From: Jinkun Jang Date: Tue, 12 Mar 2013 16:51:03 +0000 (+0900) Subject: Tizen 2.1 base X-Git-Tag: accepted/tizen_2.1/20130425.033138~885 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c731fe3e9c712b5d09891114085b0fcd052564e;p=platform%2Fframework%2Fnative%2Fuifw.git Tizen 2.1 base --- diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e50afff --- /dev/null +++ b/AUTHORS @@ -0,0 +1,8 @@ +Danny Whang +bermJin Cho +DongKyun Jeong +JongHyun Yoon +SangHee Kim +SungYul Choe +YoungKi Ahn + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..b017671 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,52 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +SET(CMAKE_INSTALL_PREFIX /usr) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +## OUTPUT PATHS +SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output/osp) + + +## Disable build rpath +SET(CMAKE_SKIP_BUILD_RPATH TRUE) + +IF(SBS OR OBS) +ADD_DEFINITIONS("-D_EXCEPT_DEPENDENCY_") +ENDIF(SBS OR OBS) + +IF(SBS) +ADD_DEFINITIONS("-D_SBS_") +ENDIF(SBS) + +## Set Assembly Compiler +#SET(CMAKE_ASM_COMPILER "${CMAKE_C_COMPILER}") + +SET(CMAKE_ASM_COMPILER_ARG1 "${CPPFLAGS} -c") +ENABLE_LANGUAGE(ASM) + +## LIBRARY PATH +LINK_DIRECTORIES (${LIBRARY_OUTPUT_PATH}) + +ADD_SUBDIRECTORY(src) + +INSTALL(FILES ${CMAKE_SOURCE_DIR}/osp-uifw.pc DESTINATION lib/pkgconfig) + +INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION lib/osp + FILES_MATCHING PATTERN "*.so*" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ) +INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/debug/ DESTINATION lib/osp/debug + FILES_MATCHING PATTERN "*" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ) + +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/usr/share/osp/themes DESTINATION ../usr/share/osp) +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/usr/share/osp/bitmaps DESTINATION ../usr/share/osp) +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/common/usr/share/osp/effects DESTINATION ../usr/share/osp) + +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/inc/ DESTINATION include/osp FILES_MATCHING PATTERN "*.h") +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/app/inc/ DESTINATION include/osp/app FILES_MATCHING PATTERN "*.h") +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/graphics/inc/ DESTINATION include/osp/graphics FILES_MATCHING PATTERN "*.h") +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/ui/inc/ DESTINATION include/osp/ui FILES_MATCHING PATTERN "*.h") diff --git a/LICENSE.APLv2 b/LICENSE.APLv2 new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE.APLv2 @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/LICENSE.Flora b/LICENSE.Flora new file mode 100644 index 0000000..9c95663 --- /dev/null +++ b/LICENSE.Flora @@ -0,0 +1,206 @@ +Flora License + +Version 1.0, May, 2012 + +http://floralicense.org/license/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Compatibility Definition Document +and passes the Compatibility Test Suite as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. + +You may add Your own attribution notices within Derivative Works +that You distribute, alongside or as an addendum to the NOTICE text +from the Work, provided that such additional attribution notices +cannot be construed as modifying the License. You may add Your own +copyright statement to Your modifications and may provide additional or +different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works +as a whole, provided Your use, reproduction, and distribution of +the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.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://floralicense.org/license/ + + 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. + diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..13d0a7a --- /dev/null +++ b/NOTICE @@ -0,0 +1,9 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Flora License, Version 1. +Please, see the LICENSE.Flora file for Flora License terms and conditions. + +Several source codes may have its original copyright owner and/or +be licensed under other than Flora License, Version 1, say, Apache License, Version 2. +Please, see copyright and license comments section in the header of each file, +and the LICENSE.APLv2 for Apache License terms and conditions. + diff --git a/inc/FGraphics.h b/inc/FGraphics.h new file mode 100644 index 0000000..e10e972 --- /dev/null +++ b/inc/FGraphics.h @@ -0,0 +1,190 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGraphics.h + * @brief This is the header file for the %Graphics namespace. + * + * This header file contains the declarations of the %Graphics namespace. + * + */ + +#ifndef _FGRAPHICS_H_ +#define _FGRAPHICS_H_ + +#include "FGrpPoint.h" +#include "FGrpFloatPoint.h" + +#include "FGrpDimension.h" +#include "FGrpFloatDimension.h" + +#include "FGrpRectangle.h" +#include "FGrpFloatRectangle.h" + +#include "FGrpFloatMatrix4.h" +#include "FGrpFloatVector4.h" +#include "FGrpFloatPoint3.h" + +#include "FGrpColor.h" + +#include "FGrpPixelFormat.h" + +#include "FGrpBufferInfo.h" + +#include "FGrpBitmapCommon.h" +#include "FGrpBitmap.h" + +#include "FGrpCanvasCommon.h" +#include "FGrpCanvas.h" + +#include "FGrpFontCommon.h" +#include "FGrpFont.h" + +#include "FGrpTextElement.h" +#include "FGrpEnrichedText.h" + +#include "FGrpCoordinateSystem.h" + +/** + * @namespace Tizen::Graphics + * @brief This namespace contains classes for drawing-related functionalities. + * + * @since 2.0 + * + * @remarks @b Header @b %file: @b \#include @b @n + * @b Library : @b osp-uifw + * + * The %Graphics namespace provides enhanced two-dimensional graphics, + * text, and imaging capabilities. + * It supports comprehensive features for rendering geometric primitives, text, and images + * in a flexible framework for developing rich user + * interfaces, sophisticated drawing applications, and image editors. + * This namespace provides additional features such as Bitmap, Font, and Color to enhance the rendered graphics. + * The user can also use basic data types, Point, Rectangle, and Dimension to construct 2D graphic objects, such as + * polygons. + * @n + * For more information on the %Graphics namespace features, see Graphics Guide. + * + * The following diagram illustrates the relationships between the classes belonging to the %Graphics namespace. + * @image html graphics_namespace_class_relationship.png + * + * The following example demonstrates how to use the %Graphics namespace. + * + * @code +#include +#include + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +bool +MyClass::GraphicsSample(void) +{ + result r = E_SUCCESS; + + // Creates a canvas instance. + Canvas* pCanvas = new Canvas(); + r = pCanvas->Construct(); + if (IsFailed(r)) + { + goto CATCH; + } + + // Clears + pCanvas->SetBackgroundColor(Color(0xFF, 0xFF, 0xFF)); + r = pCanvas->Clear(); + if (IsFailed(r)) + { + goto CATCH; + } + + // Sets the foreground color of this canvas. + pCanvas->SetForegroundColor(Color::GetColor(COLOR_ID_GREEN)); + + // Draws an ellipse. + r = pCanvas->DrawEllipse(Rectangle(50, 50, 50, 80)); + if (IsFailed(r)) + { + goto CATCH; + } + + r = pCanvas->DrawLine(Point(100, 100), Point(150, 150)); + if (IsFailed(r)) + { + goto CATCH; + } + + // Draws a circular arc. + r = pCanvas->DrawArc(Rectangle(10, 200, 50, 50), 30, 60, ARC_STYLE_PIE); + if (IsFailed(r)) + { + goto CATCH; + } + + { + // Creates a font instance. + Font font; + r = font.Construct(FONT_STYLE_PLAIN, 32); + if (IsFailed(r)) + { + goto CATCH; + } + + // Sets the font to canvas. + r = pCanvas->SetFont(font); + if (IsFailed(r)) + { + goto CATCH; + } + } + + // Draws text at the specified location. + r = pCanvas->DrawText(Point(50, 50), String(L"Hello World")); + if (IsFailed(r)) + { + goto CATCH; + } + + // Shows the drawing result on the device screen. + r = pCanvas->Show(); + if (IsFailed(r)) + { + goto CATCH; + } + + // Cleans up. + delete pCanvas; + + return true; + +CATCH: + delete pCanvas; + + return false; +} + * @endcode + * + * + * + * + */ +namespace Tizen { namespace Graphics +{ + +} } // Tizen::Graphics + +#endif // _FGRAPHICS_H_ diff --git a/inc/FGraphicsOpengl.h b/inc/FGraphicsOpengl.h new file mode 100644 index 0000000..2d0a3b7 --- /dev/null +++ b/inc/FGraphicsOpengl.h @@ -0,0 +1,42 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGraphicsOpengl.h + * @brief This is the header file for the %Opengl namespace. + * + * This header file contains the declarations of the %Opengl namespace. + * + */ + +#ifndef _FGRAPHICS_OPENGL_H_ +#define _FGRAPHICS_OPENGL_H_ + +namespace Tizen { namespace Graphics +{ + +namespace Opengl +{ +#include +#include +#include +#include + +} // Tizen::Graphics::Opengl + +} } // Tizen::Graphics +#endif // _FGRAPHICS_OPENGL_H_ diff --git a/inc/FGraphicsOpengl2.h b/inc/FGraphicsOpengl2.h new file mode 100644 index 0000000..42f6d68 --- /dev/null +++ b/inc/FGraphicsOpengl2.h @@ -0,0 +1,75 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGraphicsOpengl2.h + * @brief This is the header file for the %Opengl namespace. + * + * This header file contains the declarations of the %Opengl namespace. + * + */ + +/** + * @defgroup opengles OpenGL(R) ES + * @brief The list of OpenGL(R)ES functions. + */ + +#ifndef _FGRAPHICS_OPENGL_H_ +#define _FGRAPHICS_OPENGL_H_ + +/** + * @namespace Tizen::Graphics::Opengl + * @brief This namespace contains interfaces for %OpenGL(R). + * + * - OpenGL(R) ES + * + * @since 2.0 + * @remarks + * For OpenGL(R) ES 1.1: @n + * @b Header @b %file: @b \#include @b @n + * @b Library: @b osp-uifw @n + * For OpenGL(R) ES 2.0: @n + * @b Header @b %file: @b \#include @b @n + * @b Library: @b osp-uifw @n + * + * + * + * + * + * + * The %Opengl namespace provides support for rendering high performance 2D and 3D graphic objects using the + * OpenGL(R)(Open %Graphics Library) specification. This namespace further supports the EGL, OpenGL(R) ES 1.1, and + * OpenGL(R) ES 2.0 features. + * + * For more information on the %Opengl namespace features, see OpenGL(R) Guide. + * + * + */ +namespace Tizen { namespace Graphics +{ + +namespace Opengl +{ +#include +#include +#include +#include + +} // Tizen::Graphics::Opengl + +} } // Tizen::Graphics +#endif // _FGRAPHICS_OPENGL_H_ diff --git a/inc/FGrpBitmap.h b/inc/FGrpBitmap.h new file mode 100644 index 0000000..69b71eb --- /dev/null +++ b/inc/FGrpBitmap.h @@ -0,0 +1,491 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpBitmap.h + * @brief This is the header file for the %Bitmap class. + * + * This header file contains the declarations of the %Bitmap class. @n + * The class encapsulates a bitmap, which consists of the pixel data + * for a graphics image and its attributes. + * + */ + +#ifndef _FGRP_BITMAP_H_ +#define _FGRP_BITMAP_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Media +{ +class Image; +} } + +namespace Tizen { namespace Graphics +{ +class Canvas; + +/** + * @class Bitmap + * @brief This class encapsulates a bitmap. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %Bitmap class encapsulates a bitmap, which consists of the pixel data + * for an image and its attributes. + * @n + * For more information on the class features, see Bitmaps. + * + * + */ +class _OSP_EXPORT_ Bitmap + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + * @remarks After creating an instance of this class, one of the + * Construct() methods must be called explicitly to initialize this instance. + * + */ + Bitmap(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Bitmap(void); + + /** + * Initializes this instance of %Bitmap by copying a rectangular area of the Frame. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The rectangular area of the Frame to be copied into bitmap @n + * The width and height of the rectangle must be greater than @c 0. @n + * The area defined by @c rect is clipped to the edges of the Frame so that + * the rectangle does not fall outside the edges of the Frame. @n + * The rectangle must not fall outside the edges of the Frame entirely. @n + * If these conditions are not satisfied, an E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * + */ + result Construct(const Rectangle& rect); + + /** + * Initializes this instance of %Bitmap with the specified dimensions and pixel format. + * + * @since 2.0 + * + * @return An error code + * @param[in] dim The dimensions of the bitmap @n + * The width and height must be greater than @c 0. + * @param[in] format The pixel format + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * + */ + result Construct(const Dimension& dim, BitmapPixelFormat format); + + /** + * Initializes this instance of %Bitmap by copying the specified rectangular area of the specified canvas. + * + * @since 2.0 + * + * @return An error code + * @param[in] canvas The canvas to copy @n + * The canvas must be constructed successfully before it is passed into this method. @n + * If not, an E_INVALID_ARG exception is returned. + * @param[in] rect The rectangular area of the canvas to be copied into a bitmap @n + * The width and height of the rectangle must be greater than @c 0. @n + * The rectangle defined by @c rect is clipped to the edges of the canvas so that + * the rectangle does not fall outside the edges of the canvas. @n + * The rectangle must not fall outside the edges of the canvas entirely. @n + * If these conditions are not satisfied, an E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * + */ + result Construct(const Canvas& canvas, const Tizen::Graphics::Rectangle& rect); + + /** + * Initializes this instance of %Bitmap by copying a rectangular area of the specified bitmap. + * + * @since 2.0 + * + * @return An error code + * @param[in] bitmap The source bitmap @n + * The bitmap must be constructed successfully before it is passed into this method. @n + * If not, an E_INVALID_ARG exception is returned. + * @param[in] rect The rectangular area of the source bitmap to be copied into this bitmap @n + * The width and height of the rectangle must be greater than @c 0. @n + * The rectangle defined by @c rect is clipped to the edges of the source bitmap so that + * the rectangle does not fall outside the edges of the source bitmap. @n + * The rectangle must not fall outside the edges of the source bitmap entirely. @n + * If these conditions are not satisfied, an E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * + */ + result Construct(const Bitmap& bitmap, const Tizen::Graphics::Rectangle& rect); + + /** + * Initializes this instance of %Bitmap by using a buffer that contains raw data. + * + * @since 2.0 + * + * @return An error code + * @param[in] buffer The buffer containing raw data + * @param[in] dim The dimensions of the bitmap @n + * The width and height must be greater than @c 0. + * @param[in] pixelFormat The pixel format of raw data + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks The position property of ByteBuffer can be changed. + * + */ + result Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat); + + /** + * Initializes this instance of %Bitmap by using a buffer that contains raw data. + * + * @since 2.0 + * + * @return An error code + * @param[in] buffer The buffer containing raw data + * @param[in] dim The dimensions of the bitmap @n + * The width and height must be greater than @c 0. + * @param[in] pixelFormat The pixel format of raw data + * @param[in] bufferScaling The buffer scaling type + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_UNSUPPORTED_FORMAT The specified format is not supported. + * @remarks The position property of %ByteBuffer can be changed. + * + */ + result Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat, BufferScaling bufferScaling); + +public: + /** + * Scales the bitmap to the specified width and height. + * + * @since 2.0 + * + * @return An error code + * @param[in] dim The dimensions of the specified rectangular area @n + * The width and height must be greater than @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * + */ + result Scale(const Dimension& dim); + + /** + * Merges the specified area of the source bitmap into the calling bitmap at the given Point. + * + * @since 2.0 + * + * @return An error code + * @param[in] destPoint The X and Y coordinate of the top-left corner of the destination area in the calling bitmap instance + * @param[in] srcBitmap The source bitmap instance to copy from + * @param[in] srcRect The rectangular area to copy from the source bitmap @n + The width and height of the rectangle must be greater than or equal to @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE Either of the following conditions has occurred: @n + * - The value of the argument is outside the valid range defined by the method. @n + * - The destX, destY, srcX, or srcY has a negative value. @n + * - The specified @c srcWidth or @c srcHeight is less than @c 0. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * + */ + result Merge(const Point& destPoint, const Bitmap& srcBitmap, const Rectangle& srcRect); + + /** + * Gets the height of the bitmap. + * + * @since 2.0 + * + * @return The height of the bitmap, @n + * else @c -1 if the method fails + * + */ + int GetHeight(void) const; + + /** + * Gets the width of the bitmap. + * + * @since 2.0 + * + * @return The width of the bitmap, @n + * else @c -1 if the method fails + * + */ + int GetWidth(void) const; + + /** + * Gets the number of bits per pixel of the bitmap. + * + * @since 2.0 + * + * @return The bits per pixel, @n + * else @c -1 if the method fails + * + */ + int GetBitsPerPixel(void) const; + + /** + * Gets the pixel color format of the bitmap. + * + * @since 2.0 + * + * @return The pixel color format + * + */ + BitmapPixelFormat GetPixelColorFormat(void) const; + + /** + * Sets the scaling quality to be used for bitmap scaling. + * + * @since 2.0 + * + * @return An error code + * @param[in] quality The scaling quality to use for bitmap scaling. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * + */ + result SetScalingQuality(BitmapScalingQuality quality); + + /** + * Gets the current scaling quality. + * + * @since 2.0 + * + * @return The scaling quality + * @remarks The default value is BITMAP_SCALING_QUALITY_LOW. + * + */ + BitmapScalingQuality GetScalingQuality(void) const; + + /** + * Sets the specified color as masking color. @n + * All pixels with this color are treated as transparent. + * + * @since 2.0 + * + * @return An error code + * @param[in] pColor The color that is treated as transparent @n + * If the parameter is set to @c null, the masking color is removed from this bitmap. @n + * Only BitmapPixelFormat::BITMAP_PIXEL_FORMAT_RGB565 is supported. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * + */ + result SetMaskingColor(const Color* pColor); + + /** + * Gets a masking color. + * + * @since 2.0 + * + * @return An error code + * @param[out] color The color that is treated as transparent + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_DATA The masking color is not defined. + * + */ + result GetMaskingColor(Color& color) const; + + /** + * Sets the alpha constant. + * + * @since 2.0 + * @param[in] opacity The opacity of the bitmap @n + * This value ranges from @c 0 to @c 255. + * @remarks The alpha constant is used for the Canvas::DrawBitmap() method. + */ + void SetAlphaConstant(int opacity); + + /** + * Gets the alpha constant. + * + * @since 2.0 + * + * @return The alpha constant, @n + * else @c -1 if the method fails + */ + int GetAlphaConstant(void) const; + + /** + * Checks whether the instance is nine patched bitmap. + * + * @since 2.0 + * + * @return @c true if the instance is nine patched bitmap, @n + * else @c false + */ + bool IsNinePatchedBitmap(void) const; + + /** + * Locks a bitmap for direct pixel access. @n + * It sets up a bitmap for accessing the pixels directly. Between the calls to Bitmap::Lock and Bitmap::Unlock, + * you can write to and read from the bitmap's pixels. After you are done accessing the bitmap's pixels, + * you must call Bitmap::Unlock to release the lock. + * + * @since 2.0 + * + * @return An error code + * @param[out] info The extra information of the bitmap + * @param[in] timeout The time in milliseconds @n + * This value determines the time the caller waits for the lock to be obtained. @n + * If the lock attempt fails, E_TIMEOUT is returned. @n + * The default value is @c INFINITE, which means that the method does not return a value until the lock is acquired. + * @exception E_SUCCESS The method is successful. + * @exception E_TIMEOUT The operation is not completed within the specified time period. + * @exception E_SYSTEM An unknown operating system error has occurred. + * + */ + result Lock(BufferInfo& info, long timeout = INFINITE); + + /** + * Unlocks a bitmap. @n + * A bitmap that is locked using Bitmap::Lock() must be unlocked using Bitmap::Unlock(). + * The bitmap buffer can be modified when the bitmap is locked, but is applied only when the bitmap is unlocked. + * Therefore, all locked bitmap operations can only be used after the bitmap is unlocked using Bitmap::Unlock(). + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM An unknown operating system error has occurred. + * + */ + result Unlock(void); + + /** + * Gets a non scaled bitmap. + * + * @since 2.0 + * + * @return The non scaled bitmap, @n + * else @c null if an exception occurs + * @param[in] buffer The buffer containing raw data + * @param[in] dim The dimensions of the bitmap @n + * The width and height must be greater than @c 0. + * @param[in] pixelFormat The pixel format of raw data + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_UNSUPPORTED_FORMAT The specified format is not supported. + * + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static Bitmap* GetNonScaledBitmapN(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Bitmap(const Bitmap& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Bitmap& operator =(const Bitmap& rhs); + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // Initializes this instance of %Bitmap by using a buffer that contains raw data. + // + // @since 2.0 + // + // @return An error code + // @param[in] buffer The buffer containing raw bitmap data + // @param[in] dim The dimensions of the bitmap @n + // The width and height must be greater than @c 0. + // @param[in] pixelFormat The pixel format of the raw bitmap buffer + // @param[in] autoScaling Set to @c true to automatically scale the bitmap, @n + // else @c false + // @exception E_SUCCESS The method is successful. + // @exception E_INVALID_ARG A specified input parameter is invalid. + // @exception E_UNSUPPORTED_FORMAT The specified format is not supported. + // + result Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat, bool autoScaling); + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // Initializes this instance of %Bitmap by using a buffer that contains raw data. + // + // @since 2.0 + // + // @return An error code + // @param[in] pBuffer A pointer to the raw bitmap buffer + // @param[in] bufferSize The size of the raw bitmap buffer + // @param[in] dim The dimensions of the bitmap @n + // The width and height must be greater than @c 0. + // @param[in] pixelFormat The pixel format of the raw bitmap buffer + // @param[in] autoScaling Set to @c true to automatically scale the bitmap, @n + // else @c false + // @exception E_SUCCESS The method is successful. + // @exception E_INVALID_ARG A specified input parameter is invalid. + // @exception E_UNSUPPORTED_FORMAT The specified format is not supported + // + result Construct(const byte* pBuffer, int bufferSize, const Dimension& dim, BitmapPixelFormat pixelFormat, bool autoScaling); + + friend class Canvas; + friend class Tizen::Media::Image; + +private: + friend class _BitmapImpl; + + // + // This variable is for internal use only. + // Using this variable can cause behavioral, security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + class _BitmapImpl* __pImpl; + +}; // Bitmap + +}} // Tizen::Graphics + +#endif //_FGRP_BITMAP_H_ diff --git a/inc/FGrpBufferInfo.h b/inc/FGrpBufferInfo.h new file mode 100644 index 0000000..1e86ff1 --- /dev/null +++ b/inc/FGrpBufferInfo.h @@ -0,0 +1,166 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpBufferInfo.h + * @brief This is the header file for the %BufferInfo class. + * + * This header file contains the declarations of the %BufferInfo class. + * + */ + +#ifndef _FGRP_BUFFER_INFO_H_ +#define _FGRP_BUFFER_INFO_H_ + +#include +#include + +#include +#include +#include + +namespace Tizen { namespace Graphics +{ +/** + * @class BufferInfo + * @brief This class encapsulates the extra information for canvases and bitmaps. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %BufferInfo class provides Canvas and Bitmap related information, such as the dimension and pixel information. + * @n + * For more information on the class features, see Buffer Information. + * + * + */ +class _OSP_EXPORT_ BufferInfo + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + BufferInfo(void); + + /** + * This is the copy constructor for the %BufferInfo class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %BufferInfo + */ + BufferInfo(const BufferInfo& rhs); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~BufferInfo(void); + + /** + * This is the default assignment operator for this class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %BufferInfo + */ + BufferInfo& operator =(const BufferInfo& rhs); + + /** + * Checks whether the value of the specified instance equals the value of the current instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance equals the value of the specified instance, @n + * else @c false + * @param[in] rhs The object to compare with the current instance + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return An integer value indicating the hash value of the current instance + */ + virtual int GetHashCode(void) const; + +public: + /** + * The width of the buffer's logical dimensions in pixels. + * + * @since 2.0 + */ + int width; + + /** + * The height of the buffer's logical dimensions in pixels. + * + * @since 2.0 + */ + int height; + + /** + * The length of the buffer scan-line in bytes. + * + * @since 2.0 + */ + int pitch; + + /** + * The bits per pixel of the buffer. + * + * @since 2.0 + */ + int bitsPerPixel; + + /** + * The color format of the buffer. + * + * @since 2.0 + */ + PixelFormat pixelFormat; + + /** + * A pointer to the actual locked pixel bits. + * + * @since 2.0 + */ + void* pPixels; + +private: + friend class _BufferInfoImpl; + + // + // This variable is for internal use only. + // Using this variable can cause behavioral, security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + class _BufferInfoImpl * __pImpl; + +}; // BufferInfo + +}} // Tizen::Graphics + +#endif //_FGRP_BUFFER_INFO_H_ diff --git a/inc/FGrpCanvas.h b/inc/FGrpCanvas.h new file mode 100644 index 0000000..1d60357 --- /dev/null +++ b/inc/FGrpCanvas.h @@ -0,0 +1,961 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpCanvas.h + * @brief This is the header file for the %Canvas class. + * + * This header file contains the declarations of the %Canvas class. + * + */ + +#ifndef _FGRP_CANVAS_H_ +#define _FGRP_CANVAS_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Graphics +{ +class Font; +class EnrichedText; + +/** + * @class Canvas + * @brief This class provides methods for drawing objects. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %Canvas class provides a rectangular region to draw objects on the display device. The %Canvas instance is + * associated with a specific context. + * @n + * For more information on the class features, see Canvas. + * + */ +class _OSP_EXPORT_ Canvas + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + * @remarks After creating an instance of this class, one of the Construct() methods must be + * called explicitly to initialize this instance. + */ + Canvas(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Canvas(void); + + /** + * Initializes this instance of %Canvas to create a canvas control of the same size as that of the + * device screen. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result Construct(void); + + /** + * Initializes this instance of %Canvas with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The location and size of the canvas control on the device screen @n + * The width and height of the rectangle must be greater than @c 0. + * If this condition is not satisfied, the E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result Construct(const Rectangle& rect); + + /** + * Initializes this instance of %Canvas with the buffer information. + * + * @since 2.0 + * + * @return An error code + * @param[in] bufferInfo The information of the buffer to be used by the canvas. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The buffer information is invalid. + * @exception E_UNSUPPORTED_FORMAT The given buffer information is a format unsupported by the canvas. + * @exception E_SYSTEM An unknown operating system error has occurred + * @remarks Only PIXEL_FORMAT_ARGB8888 is supported. + */ + result Construct(const BufferInfo& bufferInfo); + +public: + /** + * Clears the current instance of %Canvas with the background color. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + */ + result Clear(void); + + /** + * Clears a rectangular region of the current instance of %Canvas with the background color. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The location and size of the rectangular region @n + * The width and height of the rectangle must be greater than or equal to @c 0. + * The rectangular region must not fall outside the edges of the + * current instance of %Canvas entirely.If these conditions are not + * satisfied, the E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result Clear(const Rectangle& rect); + + /** + * Copies the specified rectangular region from the specified instance of %Canvas to the current instance of + * %Canvas at the specified location. + * + * @since 2.0 + * + * @return An error code + * @param[in] destPoint The location to copy the rectangular region + * @param[in] srcCanvas The source %Canvas + * @param[in] srcRect The location and size of the rectangular region on the source %Canvas @n + * The rectangular region must not fall outside the edges of + * the current instance of %Canvas entirely. If this condition is + * not satisfied, the E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result Copy(const Point& destPoint, const Canvas& srcCanvas, const Rectangle& srcRect); + + /** + * Copies the scaled image of the specified rectangular region from the specified instance of + * %Canvas to the current instance of %Canvas. + * + * @since 2.0 + * + * @return An error code + * @param[in] destRect The location and size of the destination image @n + * The value of @c destRect must not fall outside the edges of + * the current instance of %Canvas entirely. If this condition is + * not satisfied, the E_OUT_OF_RANGE exception is returned. + * @param[in] srcCanvas The source %Canvas + * @param[in] srcRect The location and size of the source image @n + * The value of @c srcRect must not fall outside the edges of + * the current instance of %Canvas entirely. If this condition is + * not satisfied, the E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of this operation. + */ + result Copy(const Rectangle& destRect, const Canvas& srcCanvas, const Rectangle& srcRect); + + /** + * Gets the line style set for the current instance of %Canvas. + * + * @since 2.0 + * + * @return An instance of %LineStyle + * @remarks The default value is LINE_STYLE_SOLID. + */ + LineStyle GetLineStyle(void) const; + + /** + * Gets the line width of the current instance of %Canvas. + * + * @since 2.0 + * + * @return The line width, @n + * else @c -1 if the method fails + * @remarks The default value is 1. + */ + int GetLineWidth(void) const; + + /** + * Sets the line style for the current instance of %Canvas. + * + * @since 2.0 + * + * @return An error code + * @param[in] style The new line style for the %Canvas control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result SetLineStyle(LineStyle style); + + /** + * Sets the line width for the current instance of %Canvas. + * + * @since 2.0 + * + * @return An error code + * @param[in] width The new width for the %Canvas control @n + * The width for the %Canvas control must be greater than @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result SetLineWidth(int width); + + /** + * Gets the dash pattern of the current instance of %Canvas. + * + * @since 2.0 + * + * @return An error code + * @param[out] pattern The list containing the information of dash pattern. + * @param[out] offset The offset into the dash pattern at which the stroke must start + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specific input parameter is invalid. + */ + result GetDashPattern(Tizen::Base::Collection::IListT& pattern, int& offset) const; + + /** + * Sets the dash pattern for the current instance of %Canvas. + * + * @since 2.0 + * + * @return An error code + * @param[in] pattern The list containing the information of dash pattern. + * @param[in] offset The offset into the dash pattern at which the stroke must start + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specific input parameter is invalid. + */ + result SetDashPattern(const Tizen::Base::Collection::IListT& pattern, int offset); + + /** + * Gets the color information at the specified point. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The location of the point relative to the upper-left corner of the current instance of %Canvas @n + * The point must not fall outside the edges of %Canvas. If this + * condition is not satisfied, the E_OUT_OF_RANGE exception is returned. + * @param[out] color An instance of Color + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result GetPixel(const Point& point, Color& color) const; + + /** + * Sets a point at the specified coordinate. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The location of the point relative to the upper-left corner of the current instance of %Canvas @n + * The point must not entirely fall outside the edges of %Canvas. + * If this condition is not satisfied, the E_OUT_OF_RANGE exception + * is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result SetPixel(const Point& point); + + /** + * Draws a line between the two specified points. + * + * @since 2.0 + * + * @return An error code + * @param[in] point1 The starting point + * @param[in] point2 The end point + * @exception E_SUCCESS The method is successful. + */ + result DrawLine(const Point& point1, const Point& point2); + + /** + * Draws a rectangle. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The rectangle to be drawn on the %Canvas control @n + * The width and height of the rectangle must be greater than or equal to @c 0. + * The rectangle must not entirely fall outside the edges of + * the %Canvas control. If these conditions are not satisfied, + * the E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result DrawRectangle(const Rectangle& rect); + + /** + * Fills a rectangular region of the current instance of %Canvas with the specified color. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The fill color + * @param[in] rect The rectangular region on the %Canvas control @n + * The width and height of the rectangle must be greater than or equal to @c 0. + * The rectangle must not entirely fall outside the edges of the + * %Canvas control. If these conditions are not satisfied, the + * E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result FillRectangle(const Color& color, const Rectangle& rect); + + /** + * Draws a round-edged rectangle. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The location and size of the rectangle @n + * The width and height of the rectangle must be greater than or equal to @c 0. + * The rectangle must not entirely fall outside the edges of the + * %Canvas control. If these conditions are not satisfied, the + * E_OUT_OF_RANGE exception is returned. + * @param[in] arcDim The width and height of the round edge @n + * The width and height in the @c arcDim parameter must be greater than or equal to @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result DrawRoundRectangle(const Rectangle& rect, const Dimension& arcDim); + + /** + * Draws a filled rectangle. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The fill color + * @param[in] rect The location and size of the rectangle @n + * The width and height of the rectangle must be greater than or equal to @c 0. + * The rectangle must not entirely fall outside the edges of the + * %Canvas control. If these conditions are not satisfied, the + * E_OUT_OF_RANGE exception is returned. + * @param[in] arcDim The width and height of the round edge @n + * The width and height mentioned in the @c arcDim parameter must be greater than or equal to @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result FillRoundRectangle(const Color& color, const Rectangle& rect, const Dimension& arcDim); + + /** + * Draws an ellipse. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The location and size of the bounding rectangle @n + * The width and height of the rectangle must be greater than or equal to @c 0. + * The rectangle must not entirely fall outside the edges of the + * %Canvas control. If these conditions are not satisfied, the + * E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result DrawEllipse(const Rectangle& rect); + + /** + * Draws a filled ellipse with the specified color. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The fill color + * @param[in] rect The location and size of the bounding rectangle @n + * The width and height of the rectangle must be greater than or equal to @c 0. @n + * The rectangle must not entirely fall outside the edges of the + * %Canvas control. If these conditions are not satisfied, the + * E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result FillEllipse(const Color& color, const Rectangle& rect); + + /** + * Draws a circular arc. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The location and size of the bounding rectangle @n + * The width and height of the rectangle must be greater than or equal to @c 0. + * The rectangle must not entirely fall outside the edges of the + * %Canvas control. If these conditions are not satisfied, the + * E_OUT_OF_RANGE exception is returned. + * @param[in] startAngle The starting angle + * @param[in] endAngle The ending angle + * @param[in] arcStyle The arc style + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result DrawArc(const Rectangle& rect, int startAngle, int endAngle, ArcStyle arcStyle); + + /** + * Draws a triangle. + * + * @since 2.0 + * + * @return An error code + * @param[in] point1 The location of the first vertex + * @param[in] point2 The location of the second vertex + * @param[in] point3 The location of the third vertex + * @exception E_SUCCESS The method is successful. + */ + result DrawTriangle(const Point& point1, const Point& point2, const Point& point3); + + /** + * Draw a filled triangle with the specified color. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The fill color + * @param[in] point1 The location of the first vertex + * @param[in] point2 The location of the second vertex + * @param[in] point3 The location of the third vertex + * @exception E_SUCCESS The method is successful. + */ + result FillTriangle(const Color& color, const Point& point1, const Point& point2, const Point& point3); + + /** + * Draws a poly-line. + * + * @since 2.0 + * + * @return An error code + * @param[in] points A list containing the location of points @n + * The number of points must be greater than or equal to @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result DrawPolyline(const Tizen::Base::Collection::IList& points); + + /** + * Draws a polygon. + * + * @since 2.0 + * + * @return An error code + * @param[in] points A list containing the locations of the vertices of the polygon @n + * The number of points must be greater than or equal to @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result DrawPolygon(const Tizen::Base::Collection::IList& points); + + /** + * Draws a filled polygon with the specified color. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The fill color + * @param[in] points A list containing the locations of the vertices of the polygon @n + * The number of points must be greater than or equal to @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result FillPolygon(const Color& color, const Tizen::Base::Collection::IList& points); + + /** + * Sets a font to the %Canvas control. + * + * @since 2.0 + * + * @return An error code + * @param[in] font The font @n + * It must be constructed before being passed to this method. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result SetFont(const Font& font); + + /** + * Gets a font of the %Canvas control. + * + * @since 2.0 + * + * @return The font of the %Canvas control, @n + * else @c null if the method fails + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If a font is not set with the SetFont() method, this method returns the system default font. + */ + Font* GetFontN(void) const; + + /** + * Draws a text at the specified location. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The location to draw the text + * @param[in] text The text to draw + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OPERATION_FAILED The operation has failed. + * @remarks The foreground color (RGB value only) of the %Canvas control is used as the text color. + * @remarks The em square has a defined font size. As a result, if the font's glyph exceeds its em square, it will be scaled down when it is drawn. + */ + result DrawText(const Point& point, const Tizen::Base::String& text); + + /** + * Draws a text at the specified location and length. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The location to draw the text + * @param[in] text The text to draw + * @param[in] length The number of characters in the string @n + * It must be greater than or equal to @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_OPERATION_FAILED The operation has failed. + * @remarks The foreground color (RGB value only) of the %Canvas control is used as the text color. + * @remarks The em square has a defined font size. As a result, if the font's glyph exceeds its em square, it will be scaled down when it is drawn. + */ + result DrawText(const Point& point, const Tizen::Base::String& text, int length); + + /** + * Draws a text with an outline rendering at the specified location. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The location to draw the text + * @param[in] text The text to draw @n + * @param[in] outlineColor The color that is set as outline color + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_OPERATION_FAILED The operation has failed. + * @remarks The foreground color (RGB value only) of the %Canvas control is used as the text color. + * @remarks The em square has a defined font size. As a result, if the font's glyph exceeds its em square, it will be scaled down when it is drawn. + */ + result DrawText(const Point& point, const Tizen::Base::String& text, const Color& outlineColor); + + /** + * Draws a text with an outline rendering at the specified location and length. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The location to draw the text + * @param[in] text The text to draw + * @param[in] length The number of characters in the string @n + * It must be greater than or equal to @c 0. + * @param[in] outlineColor The color that is set as outline color + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_OPERATION_FAILED The operation has failed. + * + * @remarks The foreground color (RGB value only) of the %Canvas control is used as the text color. + * @remarks The em square has a defined font size. As a result, if the font's glyph exceeds its em square, it will be scaled down when it is drawn. + */ + result DrawText(const Point& point, const Tizen::Base::String& text, int length, const Color& outlineColor); + + /** + * Draws an enriched text at the specified area. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The location to draw the text + * @param[in] enrichedText The TextElement to draw + * @exception E_SUCCESS The method is successful. + * @exception E_DEVICE_UNAVAILABLE A specified device is invalid. + * + * @remarks The foreground color (RGB value only) of the %Canvas control is used as the text color. + * @remarks The em square has a defined font size. As a result, if the font's glyph exceeds its em square, it will be scaled down when it is drawn. + */ + result DrawText(const Point& point, const EnrichedText& enrichedText); + + /** + * Draws a bitmap image at the specified location. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The location of the upper-left corner of the bitmap + * @param[in] bitmap The bitmap to draw @n + * It must be constructed before being passed into this + * method. BitmapPixelFormat::BITMAP_PIXEL_FORMAT_R8G8B8A8 is + * not applicable for this method. The bitmap must not + * entirely fall outside the edges of the %Canvas control. If + * this condition is not satisfied, the E_OUT_OF_RANGE exception + * is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result DrawBitmap(const Point& point, const Bitmap& bitmap); + + /** + * Draws a bitmap image at the specified location. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The location and size of the scaled bitmap @n + * The rectangle must not entirely fall outside the edges of the + * %Canvas control. If this condition is not satisfied, the + * E_OUT_OF_RANGE exception is returned. + * @param[in] bitmap The bitmap to draw @n + * It must be constructed well before being passed into this + * method. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @remarks BitmapPixelFormat::BITMAP_PIXEL_FORMAT_R8G8B8A8 is not applicable for this method. + */ + result DrawBitmap(const Rectangle& rect, const Bitmap& bitmap); + + /** + * Draws a color data corresponding to a rectangle of pixels from the specified bitmap onto %Canvas. + * + * @since 2.0 + * + * @return An error code + * @param[in] destRect The destination rectangle of %Canvas @n + * The width and height of the rectangle must be greater than or equal to @c 0. + * The rectangle defined by @c destRect will be clipped at the edges + * of the %Canvas control to prevent the rectangle from falling + * outside the edges of the %Canvas control. The destination + * rectangle of a %Canvas control must not fall outside the edges + * of the %Canvas control entirely. If these conditions are not + * satisfied, the E_OUT_OF_RANGE exception is returned. + * @param[in] srcBitmap The bitmap to draw + * @param[in] srcRect The source rectangle of a bitmap @n + * The width and height of the rectangle must be greater than or equal to @c 0. + * The rectangle defined by @c srcRect will be clipped at the edges + * of the bitmap to prevent the rectangle from falling outside the + * edges of the bitmap. The source rectangle of a bitmap must not + * fall outside the edges of the bitmap entirely. If these + * conditions are not satisfied, the E_OUT_OF_RANGE exception is + * thrown. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @remarks If the source and destination rectangles are not of the same size, + * the source bitmap is stretched to match the destination rectangle. @n + * BitmapPixelFormat::BITMAP_PIXEL_FORMAT_R8G8B8A8 is not applicable for this method. + */ + result DrawBitmap(const Rectangle& destRect, const Bitmap& srcBitmap, const Rectangle& srcRect); + + /** + * Draws a flipped bitmap image at the specified location. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The location to draw the bitmap + * @param[in] bitmap The bitmap to draw @n + * It must be constructed before being passed to this method. + * @param[in] dir The flip direction + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks BitmapPixelFormat::BITMAP_PIXEL_FORMAT_R8G8B8A8 is not applicable for this method. + */ + result DrawBitmap(const Point& point, const Bitmap& bitmap, FlipDirection dir); + + /** + * Draws a rotated bitmap image at the specified location. + * + * @since 2.0 + * + * @return An error code + * @param[in] point A location to draw a bitmap image @n + * This location is relatively defined from the origin (upper-left + * corner) of the %Canvas control. + * @param[in] bitmap The bitmap to draw @n + * It must be constructed before being passed to this method. + * @param[in] pivot The center of rotation of a bitmap image @n + * This center is relatively defined from the origin (upper-left + * corner) of the bitmap. + * @param[in] degree The amount of rotation in degrees + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks BitmapPixelFormat::BITMAP_PIXEL_FORMAT_R8G8B8A8 is not applicable for this method. + * @image html graphics_rotatebitmap.PNG + */ + result DrawBitmap(const Point& point, const Bitmap& bitmap, const Point& pivot, int degree); + + /** + * Draws a nine-patched bitmap at the specified location. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The location and size of the nine-patched bitmap @n + * The rectangle must not entirely fall outside the edges of the + * %Canvas control. If this condition is not satisfied, the + * E_OUT_OF_RANGE exception is returned. + * @param[in] bitmap The bitmap to draw @n + * It must be constructed before being passed to this method. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * + * @remarks BitmapPixelFormat::BITMAP_PIXEL_FORMAT_R8G8B8A8 is not applicable for this method. @n + * The nine-patched bitmap must have a stretchable section by drawing one (or more) 1-pixel-wide black line(s) in the + * left and top part of the border. + * @image html graphics_ninepatchedbitmap.PNG + * + */ + result DrawNinePatchedBitmap(const Rectangle& rect, const Bitmap& bitmap); + + /** + * Shows the current instance of %Canvas on the device screen. + * + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications @n + * For more information, see the issue description for @ref CompCanvasShowPage "here". + * @endif + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * + */ + result Show(void); + + /** + * @if OSPCOMPAT + * @page CompCanvasShowPage Compatibility for Show(). + * @section CompCanvasShowPageIssueSection Issues + * In Tizen, memory canvas is not fully supported, and we cannot guarantee that Show() for memory canvas of Tizen does the same operation with that of OSP. + * + * -# In OSP, when Show() is called for a Memory Canvas, the canvas was copied to the screen and E_SUCCESS was returned, but the canvas is not guaranteed to be displayed properly. + * -# In Tizen, Show() does not function for a Memory Canvas, so E_UNSUPPORTED_OPERATION is returned. Memory Canvases cannot be used to directly show its content on screen. + * + * @endif + */ + + + /** + * @if OSPDEPREC + * Shows the specified rectangle of the current instance of %Canvas on the device screen. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of this method, use the Show(). + * @since 2.0 + * + * @return An error code + * @param[in] rect The bounds of the %Canvas control to display @n + * The width and height of the rectangle must be greater than or equal to @c 0. + * The rectangle must not entirely fall outside the edges of the + * %Canvas control. If these conditions are not satisfied, the + * E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * + * @remark If you use Show(Rectangle&) in Tizen, this method works differently. @n + * This method shows the screen entirely not partially in Tizen. + * @endif + */ + result Show(const Rectangle& rect); + + /** + * Gets the location and size of the current %Canvas instance on the device screen. + * + * @since 2.0 + * + * @return The Rectangle instance containing the location and size of the current %Canvas instance + * @remarks If this %Canvas instance is a Window %Canvas, it returns Rectangle(0, 0, w, h). + */ + Rectangle GetBounds(void) const; + + /** + * Sets the clip rectangle for a %Canvas control. @n + * When a clip rectangle is set, any drawing is restricted within the specified rectangular area. The + * rectangular area defined is clipped at the edges of the %Canvas control so as to prevent the clipped rectangle + * from falling outside the %Canvas control. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The bounds of the clip rectangle @n + * The width and height of the rectangle must be greater than or equal to @c 0. + * The clip rectangle for a %Canvas control must not entirely fall + * outside the edges of the %Canvas control. If these conditions are + * not satisfied, the E_OUT_OF_RANGE exception is returned. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result SetClipBounds(const Rectangle& rect); + + /** + * Gets the bounds of the clip rectangle of a %Canvas control. + * + * @since 2.0 + * + * @return An instance of Rectangle indicating the bounds of the clip rectangle + */ + Rectangle GetClipBounds(void) const; + + /** + * Locks the %Canvas control for direct pixel access. @n + * This sets up a %Canvas control for accessing the pixels directly. Between the calls to the + * Canvas::Lock() and Canvas::UnLock() methods, the data can be written to and read from the + * Canvas control's pixels. Once the operations on the %Canvas control's pixels are finished, the + * Canvas::Unlock() method must be called to release the lock. + * + * @since 2.0 + * + * @return An error code + * @param[out] info The information of the %Canvas control + * @param[in] timeout The time, in milliseconds, that the caller waits for the lock to be obtained @n + * If the lock attempt fails, E_TIMEOUT is returned. The default value + * is INFINITE, which means that the method does not return until the lock + * is acquired. + * @exception E_SUCCESS The method is successful. + * @exception E_TIMEOUT The operation cannot be completed within the specified time period. + * @exception E_SYSTEM An unknown operating system error has occurred. + * + * @remarks BufferInfo contains a valid physical memory information, regardless of the + * logical position and size of the %Canvas control. + */ + result Lock(BufferInfo& info, long timeout = INFINITE); + + /** + * Unlocks the %Canvas control. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM An unknown operating system error has occurred. + * @remarks The %Canvas control must be unlocked as soon as possible. + */ + result Unlock(void); + + /** + * Sets the foreground color. + * + * @since 2.0 + * + * @param[in] color The color that is set as foreground color + */ + void SetForegroundColor(const Color& color); + + /** + * Gets the foreground color. + * + * @since 2.0 + * + * @return The foreground color + */ + Color GetForegroundColor(void) const; + + /** + * Sets the background color. + * + * @since 2.0 + * + * @param[in] color The color that is set as background color + */ + void SetBackgroundColor(const Color& color); + + /** + * Gets the background color. + * + * @since 2.0 + * + * @return The background color + */ + Color GetBackgroundColor(void) const; + + /** + * Sets the current instance of %Canvas to the specified point. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The new position + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION Window %Canvas does not support moving the position. + */ + result SetPosition(const Point& point); + + /** + * Sets the current instance of %Canvas to the specified point. + * + * @since 2.0 + * + * @return An error code + * @param[in] x The new x-coordinate + * @param[in] y The new y-coordinate + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION Window %Canvas does not support moving the position. + */ + result SetPosition(int x, int y); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Canvas(const Canvas& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Canvas& operator =(const Canvas& rhs); + + friend class Bitmap; + friend class TextElement; + +private: + friend class _CanvasImpl; + + // + // This variable is for internal use only. + // Using this variable can cause behavioral, security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + class _CanvasImpl* __pImpl; + +}; // Canvas + +}} // Tizen::Graphics + +#endif //_FGRP_CANVAS_H_ diff --git a/inc/FGrpCanvasCommon.h b/inc/FGrpCanvasCommon.h new file mode 100644 index 0000000..9b1746a --- /dev/null +++ b/inc/FGrpCanvasCommon.h @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpCanvasCommon.h + * @brief This is the header file for the enumerations of the Canvas class. + * + * This header file contains the definitions of the enumerations of the Canvas class. + */ + +#ifndef _FGRP_CANVAS_COMMON_H_ +#define _FGRP_CANVAS_COMMON_H_ + +namespace Tizen { namespace Graphics +{ +/** + * @enum LineStyle + * + * Defines the line style. + * + * @since 2.0 + */ +enum LineStyle +{ + LINE_STYLE_SOLID = 1, /**< The solid line style */ + LINE_STYLE_MAX, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. + LINE_STYLE_MIN = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. +}; + +/** + * @enum ArcStyle + * + * Defines the arc style. + * + * @since 2.0 + */ +enum ArcStyle +{ + ARC_STYLE_ONLY = 1, /**< An arc line is drawn */ + ARC_STYLE_PIE, /**< A pie (arc and chords) is drawn */ + ARC_STYLE_CHORD, /**< A chord is drawn */ + ARC_STYLE_FILLED_PIE, /**< A filled pie is drawn */ + ARC_STYLE_FILLED_CHORD, /**< A filled chord is drawn */ + ARC_STYLE_MAX, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. + ARC_STYLE_MIN = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. +}; + +/** + * @enum FlipDirection + * + * Defines the flip direction. + * + * @since 2.0 + */ +enum FlipDirection +{ + FLIP_DIRECTION_HORIZONTAL = 1, /**< The horizontal type */ + FLIP_DIRECTION_VERTICAL, /**< The vertical type */ + FLIP_DIRECTION_MAX, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. + FLIP_DIRECTION_MIN = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. +}; + +} } // Tizen::Graphics + +#endif // _FGRP_CANVAS_COMMON_H_ diff --git a/inc/FGrpCanvasTexture.h b/inc/FGrpCanvasTexture.h new file mode 100644 index 0000000..af87599 --- /dev/null +++ b/inc/FGrpCanvasTexture.h @@ -0,0 +1,121 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpCanvasTexture.h + * @brief This is the header file for the %CanvasTexture class. + * + * This header file contains the declarations of the %CanvasTexture class. + * + */ + +#ifndef _FGRP_CANVAS_TEXTURE_H_ +#define _FGRP_CANVAS_TEXTURE_H_ + +#include + +namespace Tizen { namespace Graphics { +class Canvas; +}} + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +/** + * @class CanvasTexture + * @brief This class provides a method to bind 2D Canvas and OpenGL-ES Texture. + * With this feature, you can easily draw 2D primitives on OpenGL-ES Textures with consistency. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %CanvasTexture class provides a canvas by which you can draw 2D primitives on OpenGL-ES texture. + * + */ +class _OSP_EXPORT_ CanvasTexture + : public Tizen::Base::Object +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method be called right after calling this constructor. + * + * @since 2.0 + * + */ + CanvasTexture(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~CanvasTexture(void); + + /** + * Initializes this instance of %CanvasTexture with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] textureId Texture ID which points to the texture associated with the 2D canvas. The testure ID must be generated from glGenTextures(). + * @param[in] width The width of the input texture. The width must be greater than @c 0, and smaller or equal than GL_MAX_TEXTURE_SIZE. + * @param[in] height The height of the input texture. The height must be greater than @c 0, and smaller or equal than GL_MAX_TEXTURE_SIZE + * @exception E_SUCCESS Construction is successfully done. + * @exception E_INVALID_ARG Input parameter is invalid. + * @exception E_UNSUPPORTED_OPERATION The target device does not support full features for %CanvasTexture. + * @exception E_INVALID_STATE Getting egl information failed. It is necessary to bind egl context by using eglMakeCurrent funtion. + * @remarks There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer here. + */ + result Construct(int textureId, int width, int height); + + /** + * Returns a 2D Canvas which is associated with the Texture of %CanvasTexture. + * + * @since 2.0 + * + * @return The 2D canvas of the %CanvasTexture, @n + * else @c null if an exception occurs. + * @exception E_SUCCESS The method is successful. + * @exception E_OPERATION_FAILED Fail to construct the canvas properly, due to some reason of system. + */ + Tizen::Graphics::Canvas* GetCanvasN(void) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @param[in] rhs The source from which this instance is copied + // + CanvasTexture(const CanvasTexture& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @param[in] rhs An instance of %CanvasTexture + // + CanvasTexture& operator =(const CanvasTexture& rhs); + +private: + friend class _CanvasTextureImpl; + + class _CanvasTextureImpl* __pImpl; +}; // CanvasTexture + +}}} // Tizen::Graphics::Opengl + +#endif //_FGRP_CANVAS_TEXTURE_H_ diff --git a/inc/FGrpColor.h b/inc/FGrpColor.h new file mode 100644 index 0000000..f17a118 --- /dev/null +++ b/inc/FGrpColor.h @@ -0,0 +1,490 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpColor.h + * @brief This is the header file for the %Color class. + * + * This header file contains the declarations of the %Color class. + * + */ + +#ifndef _FGRP_COLOR_H_ +#define _FGRP_COLOR_H_ + +#include +#include + +namespace Tizen { namespace Graphics +{ + +/** + * @class Color32 + * @brief This template code makes a 32-bit combination from each color component + * @since 2.0 + * + * The following example demonstrates how to use this template code + * + * @code + * + * #include + * + * using namespace Tizen::Graphics; + * + * // 0xFFFF00FF: Opaque magenta + * const unsigned int MY_COLOR1 = Color32<255, 0, 255>::Value; + * + * // 0x80FF0000: Red with 50% opacity + * const unsigned int MY_COLOR2 = Color32<255, 0, 0, 128>::Value; + * + * @endcode + */ +template +struct Color32 +{ + enum + { + Value = static_cast(alpha) << 24 | + static_cast(red) << 16 | + static_cast(green) << 8 | + static_cast(blue) + }; +}; + +/** + * @enum ColorId + * + * Defines the color ID. + * + * @since 2.0 + */ +enum ColorId +{ + COLOR_ID_BLACK, /**< This attribute is pre-defined. Its value is black. */ + COLOR_ID_BLUE, /**< This attribute is pre-defined. Its value is blue. */ + COLOR_ID_CYAN, /**< This attribute is pre-defined. Its value is cyan. */ + COLOR_ID_GREEN, /**< This attribute is pre-defined. Its value is green. */ + COLOR_ID_GREY, /**< This attribute is pre-defined. Its value is grey. */ + COLOR_ID_MAGENTA, /**< This attribute is pre-defined. Its value is magenta. */ + COLOR_ID_RED, /**< This attribute is pre-defined. Its value is red. */ + COLOR_ID_VIOLET, /**< This attribute is pre-defined. Its value is violet. */ + COLOR_ID_YELLOW, /**< This attribute is pre-defined. Its value is yellow. */ + COLOR_ID_WHITE /**< This attribute is pre-defined. Its value is white. */ +}; + +/** + * @class Color + * @brief This class encapsulates a color. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %Color class provides an ARGB (Alpha, Red, Green, Blue) color model. + * + * For more information on the class features, see Color. + */ +class _OSP_EXPORT_ Color + : public Tizen::Base::Object +{ + +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + Color(void); + + /** + * This is the copy constructor for the %Color class. @n + * This constructor initializes the instance of %Color with the attributes of the specified instance of %Color. + * + * @since 2.0 + * + * @param[in] rhs An instance of %Color + */ + Color(const Color& rhs); + + /** + * Initializes the instance of %Color with the specified ARGB values. + * + * @since 2.0 + * + * @param[in] r The red component + * @param[in] g The green component + * @param[in] b The blue component + * @param[in] a The alpha component + */ + Color(byte r, byte g, byte b, byte a = 0xFF); + + /** + * Initializes the instance of %Color with the specified RGB value. + * + * @since 2.0 + * + * @param[in] rgb The RGB color value + * @param[in] hasAlpha Set to @c true if @c rgb contains an alpha value, @n + * else @c false + */ + Color(unsigned int rgb, bool hasAlpha = true); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Color(void); + + +public: + /** + * Checks whether the two instances of %Color are equal. + * + * @since 2.0 + * + * @return @c true if the values of the two instances of %Color are equal, @n + * else @c false + * @param[in] rhs An instance of %Color + */ + bool operator ==(const Color& rhs) const; + + /** + * Checks whether the two instances of %Color are not equal. + * + * @since 2.0 + * + * @return @c true if the values of the two instances of %Color are not equal, @n + * else @c false + * @param[in] rhs An instance of %Color + * + */ + bool operator !=(const Color& rhs) const; + + /** + * Assigns the values of the RGB components of the specified instance to the current instance of %Color. + * + * @since 2.0 + * + * @return The reference to the instance of %Color + * @param[in] rhs An instance of %Color + */ + Color& operator =(const Color& rhs); + + +public: + /** + * Checks whether the current instance of %Color equals the specified instance of %Color. + * + * @since 2.0 + * + * @return @c true if the values of the current instance is equal to the value of the specified instance, @n + * else @c false + * @param[in] rhs An instance of %Color + * @remarks This method overrides Tizen::Base::Object::Equals(). This method uses the values of the RGB components to compare the two instances. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance of %Color. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks Two equal instances must return the same hash value. For better performance, + * the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + +public: + /** + * Gets the value of the alpha component of the current instance of %Color. + * + * @since 2.0 + * + * @return A @c byte representation of the alpha component of the current instance of %Color + */ + byte GetAlpha(void) const; + + /** + * Gets the value of the red component of the current instance of %Color. + * + * @since 2.0 + * + * @return A @c byte representation of the red component of the current instance of %Color + */ + byte GetRed(void) const; + + /** + * Gets the value of the blue component of the current instance of %Color. + * + * @since 2.0 + * + * @return A @c byte representation of the blue component of the current instance of %Color + */ + byte GetBlue(void) const; + + /** + * Gets the value of the green component of the current instance of %Color. + * + * @since 2.0 + * + * @return A @c byte representation of the green component of the current instance of %Color + */ + byte GetGreen(void) const; + + /** + * Gets the ARGB components of the current instance of %Color. + * + * @since 2.0 + * + * @param[out] r The red component + * @param[out] g The green component + * @param[out] b The blue component + * @param[out] a The alpha component + */ + void GetColorComponents(byte& r, byte& g, byte& b, byte& a) const; + + /** + * Gets the 32-bit integer value of the current instance of %Color. + * + * @since 2.0 + * + * @return An unsigned integer value representing the current instance of %Color + */ + unsigned int GetRGB32(void) const; + + /** + * Sets the value of the alpha component of the current instance of %Color. + * + * @since 2.0 + * + * @param[in] a The new value of the alpha component + */ + void SetAlpha(byte a); + + /** + * Sets the value of the red component of the current instance of %Color. + * + * @since 2.0 + * + * @param[in] r The new value of the red component + */ + void SetRed(byte r); + + /** + * Sets the value of the green component of the current instance of %Color. + * + * @since 2.0 + * + * @param[in] g The new value of the green component + */ + void SetGreen(byte g); + + /** + * Sets the value of the blue component of the current instance of %Color. + * + * @since 2.0 + * + * @param[in] b The new value of the blue component + */ + void SetBlue(byte b); + + /** + * Sets the values of the ARGB components of the current instance of %Color. + * + * @since 2.0 + * + * @param[in] r The red component + * @param[in] g The green component + * @param[in] b The blue component + * @param[in] a The alpha component + */ + void SetColorComponents(byte r, byte g, byte b, byte a = 0xFF); + + /** + * Sets the current instance of %Color to the specified 32-bit integer value. + * + * @since 2.0 + * + * @param[in] rgb The new RGB color value + * @param[in] hasAlpha @c true if @c rgb contains alpha value, @n + else @c false + */ + void SetRGB32(unsigned int rgb, bool hasAlpha = true); + + /** + * Return the Color object for the specified color + * + * @since 2.0 + * @return Color The Color object + * @param[in] colorId The enum value for the specified color + */ + static Color GetColor(ColorId colorId); + + +public: + /** + * @if OSPDEPREC + * This attribute is pre-defined. Its value is black. + * + * @brief [Deprecated] + * @since 2.0 + * + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release + * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_BLACK) + * @endif + */ + const static Color COLOR_BLACK; + + /** + * @if OSPDEPREC + * This attribute is pre-defined. Its value is blue. + * + * @brief [Deprecated] + * @since 2.0 + * + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release + * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_BLUE) + * @endif + */ + const static Color COLOR_BLUE; + + /** + * @if OSPDEPREC + * This attribute is pre-defined. Its value is cyan. + * + * @brief [Deprecated] + * @since 2.0 + * + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release + * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_CYAN) + * @endif + */ + const static Color COLOR_CYAN; + + /** + * @if OSPDEPREC + * This attribute is pre-defined. Its value is green. + * + * @brief [Deprecated] + * @since 2.0 + * + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release + * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_GREEN) + * @endif + */ + const static Color COLOR_GREEN; + + /** + * @if OSPDEPREC + * This attribute is pre-defined. Its value is grey. + * + * @brief [Deprecated] + * @since 2.0 + * + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release + * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_GREY) + * @endif + */ + const static Color COLOR_GREY; + + /** + * @if OSPDEPREC + * This attribute is pre-defined. Its value is magenta. + * + * @brief [Deprecated] + * @since 2.0 + * + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release + * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_MAGENTA) + * @endif + */ + const static Color COLOR_MAGENTA; + + /** + * @if OSPDEPREC + * This attribute is pre-defined. Its value is red. + * + * @brief [Deprecated] + * @since 2.0 + * + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release + * Instead of us ing this static constant, it is recommended to use GetColor(COLOR_ID_RED) + * @endif + */ + const static Color COLOR_RED; + + /** + * @if OSPDEPREC + * This attribute is pre-defined. Its value is violet. + * + * @brief [Deprecated] + * @since 2.0 + * + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release + * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_VIOLET) + * @endif + */ + const static Color COLOR_VIOLET; + + /** + * @if OSPDEPREC + * This attribute is pre-defined. Its value is yellow. + * + * @brief [Deprecated] + * @since 2.0 + * + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release + * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_YELLOW) + * @endif + */ + const static Color COLOR_YELLOW; + + /** + * @if OSPDEPREC + * This attribute is pre-defined. Its value is cwhite. + * + * @brief [Deprecated] + * @since 2.0 + * + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release + * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_WHITE) + * @endif + */ + const static Color COLOR_WHITE; + + +private: + unsigned int __color; + + friend class _ColorImpl; + + // + // This variable is for internal use only. + // Using this variable can cause behavioral, security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + class _ColorImpl * __pImpl; + +}; // Color + +}} // Tizen::Graphics + +#endif //_FGRP_COLOR_H_ diff --git a/inc/FGrpCoordinateSystem.h b/inc/FGrpCoordinateSystem.h new file mode 100644 index 0000000..1fdc0d6 --- /dev/null +++ b/inc/FGrpCoordinateSystem.h @@ -0,0 +1,120 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpCoordinateSystem.h + * @brief This is the header file for the %CoordinateSystem class. + * + * This header file contains the declarations of the %CoordinateSystem class. + */ + +#ifndef _FGRP_COORDINATE_SYSTEM_H_ +#define _FGRP_COORDINATE_SYSTEM_H_ + + +#include + + +namespace Tizen { namespace Graphics +{ + +/** + * @class CoordinateSystem + * @brief This class provides various utility methods for coordinate handling. + * + * @since 2.0 + * + * The %CoordinateSystem class provides various utility methods for coordinate handling. + * + */ +class _OSP_EXPORT_ CoordinateSystem +{ +public: + /** + * Returns the screen resolution in logical coordinates. + * + * @since 2.0 + * + * @return The screen resolution in logical coordinates + */ + static Dimension GetLogicalResolution(void); + + /** + * Returns the screen resolution in physical coordinates. + * + * @since 2.0 + * + * @return The screen resolution in physical coordinates + */ + static Dimension GetPhysicalResolution(void); + + /** + * Converts the physical value along x-axis to the logical one. + * + * @since 2.0 + * + * @return The converted logical value for the physical one + * @param[in] physicalX An input physical value to be converted + */ + static int ConvertToLogicalX(int physicalX); + + /** + * Converts the physical value along y-axis to the logical one. + * + * @since 2.0 + * + * @return The converted logical value for the physical one + * @param[in] physicalY An input physical value to be converted + */ + static int ConvertToLogicalY(int physicalY); + + /** + * Converts the logical value along x-axis to the physical one. + * + * @since 2.0 + * + * @return The converted physical X value + * @param[in] logicalX An input logical value to be converted + */ + static int ConvertToPhysicalX(int logicalX); + + /** + * Converts the logical value along y-axis to the physical one. + * + * @since 2.0 + * + * @return The converted physical Y value + * @param[in] logicalY An input logical value to be converted + */ + static int ConvertToPhysicalY(int logicalY); + +private: + // + // This default constructor is intentionally declared as private because this class cannot be constructed. + // + CoordinateSystem(void); + + // + // This destructor is intentionally declared as private because this class cannot be constructed. + // + ~CoordinateSystem(void); + +}; // CoordinateSystem + +}} // Tizen::Graphics + +#endif // _FGRP_COORDINATE_SYSTEM_H_ diff --git a/inc/FGrpDimension.h b/inc/FGrpDimension.h new file mode 100644 index 0000000..da6a6b1 --- /dev/null +++ b/inc/FGrpDimension.h @@ -0,0 +1,178 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpDimension.h + * @brief This is the header file for the %Dimension class. + * + * This header file contains the declarations of the %Dimension class. + */ + +#ifndef _FGRP_DIMENSION_H_ +#define _FGRP_DIMENSION_H_ + +#include + +namespace Tizen { namespace Graphics +{ +/** + * @class Dimension + * @brief This class represents the width and height of a two-dimensional region. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %Dimension class provides methods to abstract and set the width and height of a two-dimensional region. + * + * For more information on the class features, see Shapes. + * + */ +class _OSP_EXPORT_ Dimension + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. @n + * This constructor initializes an instance of %Dimension with the width and the height set as @c 0. + * + * @since 2.0 + */ + Dimension(void); + + /** + * This is the copy constructor for the %Dimension class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %Dimension + */ + Dimension(const Dimension& rhs); + + /** + * Initializes an instance of %Dimension with the specified values of width and height. + * + * @since 2.0 + * + * @param[in] width The width to set + * @param[in] height The height to set + */ + Dimension(int width, int height); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Dimension(void); + + /** + * Assigns the value of the specified instance to the current instance of %Dimension. + * + * @since 2.0 + * + * @param[in] rhs An instance of %Dimension + */ + Dimension& operator =(const Dimension& rhs); + + /** + * Checks whether the two instances of %Dimension have equal width and height values. + * + * @since 2.0 + * + * @return @c true if the values of the width and height of the two instances of %Dimension are equal, @n + * else @c false + * @param[in] rhs An instance of %Dimension + */ + bool operator ==(const Dimension& rhs) const; + + /** + * Checks whether the two instances of %Dimension have different width and height values. + * + * @since 2.0 + * + * @return @c true if the values of the width and the height of the two instances of %Dimension are not equal, @n + * else @c false + * @param[in] rhs An instance of %Dimension + */ + bool operator !=(const Dimension& rhs) const; + + /** + * Checks whether the value of the current instance of %Dimension equals the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance equals the value of the specified instance, @n + * else @c false + * @param[in] rhs An instance of %Dimension + * @remarks The %Dimension class has a semantic value, which means that the + * Equals() method checks whether the two instances have the same width and height. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks Two equal instances must return the same hash value. For better performance, + * the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + /** + * Sets the size of the current instance of %Dimension. + * + * @since 2.0 + * + * @param[in] width The new width + * @param[in] height The new height + */ + void SetSize(int width, int height); + +public: + /** + * The width of the current instance of %Dimension. + * + * @since 2.0 + */ + int width; + + /** + * The height of the current instance of %Dimension. + * + * @since 2.0 + */ + int height; + +private: + friend class _DimensionImpl; + + // + // This variable is for internal use only. + // Using this variable can cause behavioral, security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + class _DimensionImpl * __pImpl; + +}; // Dimension + +}} // Tizen::Graphics + +#endif // _FGRP_DIMENSION_H_ diff --git a/inc/FGrpEnrichedText.h b/inc/FGrpEnrichedText.h new file mode 100644 index 0000000..cf9f8dd --- /dev/null +++ b/inc/FGrpEnrichedText.h @@ -0,0 +1,782 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpEnrichedText.h + * @brief This is the header file for the %EnrichedText class. + * + * This header file contains the definitions of the %EnrichedText class. + * + */ + +#ifndef _FGRP_ENRICHED_TEXT_H_ +#define _FGRP_ENRICHED_TEXT_H_ + +#include +#include +#include + +namespace Tizen { namespace Graphics +{ +/** + * @enum TextHorizontalAlignment + * + * Defines the horizontal alignment of the text. + * + * @since 2.0 + */ +enum TextHorizontalAlignment +{ + TEXT_ALIGNMENT_LEFT = 1, /**< The position of the text is towards the left of the object */ + TEXT_ALIGNMENT_CENTER, /**< The position of the text is towards the center of the object */ + TEXT_ALIGNMENT_RIGHT, /**< The position of the text is towards the right of the object */ + TEXT_ALIGNMENT_HORIZONTAL_MAX, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. + TEXT_ALIGNMENT_HORIZONTAL_MIN = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. +}; + +/** + * @enum TextVerticalAlignment + * + * Defines the vertical alignment of the text. + * + * @since 2.0 + */ +enum TextVerticalAlignment +{ + TEXT_ALIGNMENT_TOP = 1, /**< The position of the text is towards the top of the object */ + TEXT_ALIGNMENT_MIDDLE, /**< The position of the text is towards the middle of the object */ + TEXT_ALIGNMENT_BOTTOM, /**< The position of the text is towards the bottom of the object */ + TEXT_ALIGNMENT_BASELINE, /**< The position of the text is aligned along the baseline of the object */ + TEXT_ALIGNMENT_VERTICAL_MAX, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. + TEXT_ALIGNMENT_VERTICAL_MIN = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. +}; + +/** + * @enum TextWrap + * + * Defines the style of wrapping of the text in %EnrichedText. + * + * @since 2.0 + */ +enum TextWrap +{ + TEXT_WRAP_NONE = 1, /**< The wrapping of text is not applied */ + TEXT_WRAP_CHARACTER_WRAP, /**< The wrapping of text is applied at the character unit */ + TEXT_WRAP_WORD_WRAP, /**< The wrapping of text is applied at the word unit */ + TEXT_WRAP_MAX, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. + TEXT_WRAP_MIN = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. +}; + +/** + * @class EnrichedText + * @brief This class provides enriched text content. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %EnrichedText class provides methods that enable your application to support texts with various styles, such + * as font, color, and layout. An %EnrichedText instance can be drawn to a Canvas. + * + * For more information on the class features, see EnrichedText. + * + * The following example demonstrates how to use the %EnrichedText class. + * + * @code +#include +#include +#include + +using namespace Tizen::App; +using namespace Tizen::Graphics; + +bool +MyClass::EnrichedTextSample(void) +{ + result r = E_SUCCESS; + EnrichedText* pEnrichedText = null; + TextElement* pTextElement1 = null; + TextElement* pTextElement2 = null; + Bitmap* pBitmap = null; + + // Creates an EnrichedText instance and sets the attributes + pEnrichedText = new EnrichedText(); + r = pEnrichedText->Construct(Dimension(200, 200)); + if (IsFailed(r)) + { + goto CATCH; + } + pEnrichedText->SetHorizontalAlignment(TEXT_ALIGNMENT_RIGHT); + pEnrichedText->SetVerticalAlignment(TEXT_ALIGNMENT_BOTTOM); + pEnrichedText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP); + pEnrichedText->SetTextAbbreviationEnabled(true); + + // Creates a TextElement and sets attributes + pTextElement1 = new TextElement(); + r = pTextElement1->Construct(L"0123456789"); + if (IsFailed(r)) + { + goto CATCH; + } + pTextElement1->SetTextColor(Color::GetColor(COLOR_ID_BLUE)); + { + Font font; + font.Construct(FONT_STYLE_BOLD, 40); + pTextElement1->SetFont(font); + } + + // Creates another TextElement and sets the attributes + pTextElement2 = new TextElement(); + r = pTextElement2->Construct(L"abcdefghijklmn\nABCDEFGHIJKLMN"); + if (IsFailed(r)) + { + goto CATCH; + } + pTextElement2->SetTextColor(Color::GetColor(COLOR_ID_VIOLET)); + + // Creates a bitmap and scales the size + pBitmap = App::GetInstance()->GetAppResource()->GetBitmapN(L"example.bmp"); + pBitmap->Scale(Dimension(40, 40)); + + // Adds the TextElement and the bitmap to the EnrichedText + pEnrichedText->Add(*pTextElement1); + pEnrichedText->Add(*pTextElement2); + pEnrichedText->Add(*pBitmap); + + // Draws + { + Canvas canvas; + r = canvas.Construct(); + if (IsFailed(r)) + { + goto CATCH; + } + canvas.SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK)); + canvas.Clear(); + canvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), Rectangle(50, 50, 380, 380)); + + // Draws the covered area of the EnrichedText in the Canvas coordinate + int width, height; + pEnrichedText->GetSize(width, height); + canvas.FillRectangle(Color::GetColor(COLOR_ID_GREY), Rectangle(60, 60, width, height)); + + // Draws the EnrichedText at the specified Point + canvas.DrawText(Point(60, 60), *pEnrichedText); + canvas.Show(); + } + + // Cleans up + pEnrichedText->RemoveAll(true); + delete pEnrichedText; + + return true; + +CATCH: + if (pEnrichedText) + { + pEnrichedText->RemoveAll(true); + delete pEnrichedText; + } + + return false; +} + * @endcode + * + * + * + * + */ + +class _OSP_EXPORT_ EnrichedText + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + * + * @remarks After creating an instance of this class, one of the Construct() methods must be called explicitly + * to initialize this instance. + */ + EnrichedText(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~EnrichedText(void); + + /** + * Initializes this instance of %EnrichedText with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] dim The dimension to set for %EnrichedText @n + * The width and height must be greater than @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result Construct(const Tizen::Graphics::Dimension& dim); + + /** + * Inserts the TextElement instance in the %EnrichedText instance at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] elementIndex The index at which the text element is to add + * @param[in] element The TextElement to add + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result InsertAt(int elementIndex, TextElement& element); + + /** + * Removes the TextElement instance at the specified index of the %EnrichedText instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] elementIndex The index of TextElement + * @param[in] deallocate Set to @c true to deallocate the TextElement instance, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * + */ + result RemoveAt(int elementIndex, bool deallocate); + + /** + * Removes the TextElement instance from the %EnrichedText instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] element The TextElement to remove + * @param[in] deallocate Set to @c true to deallocate the TextElement instance, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * + */ + result Remove(TextElement& element, bool deallocate); + + /** + * Adds the specified TextElement instance to the %EnrichedText instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] element The TextElement to append + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * + */ + result Add(TextElement& element); + + /** + * @if OSPDEPREC + * Removes all the %TextElement instances from the %EnrichedText instance. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of this method, use the RemoveAll(). + * @since 2.0 + * @endif + * + * @return An error code + * @param[in] deallocate Set to @c true to deallocate the %TextElement instance, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @see RemoveAll() + * + */ + result RemoveAllTextElements(bool deallocate); + + /** + * Removes all the text and image elements from the %EnrichedText instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] deallocate Set to @c true to deallocate the elements to be removed, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM An unknown operating system error has occurred. + * + */ + result RemoveAll(bool deallocate); + + /** + * Gets the %TextElement instance at the specified index from the %EnrichedText instance. + * + * @since 2.0 + * + * @return The %TextElement instance at the specified index, @n + * else @c null if the method fails + * @param[in] elementIndex The index of the %TextElement + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + TextElement* GetTextElementAt(int elementIndex) const; + + /** + * Gets the count of the %TextElement instances. + * + * @since 2.0 + * + * @return The count of the %TextElement instances + */ + int GetTextElementCount(void) const; + + /** + * Sets the text size. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The new size of the %EnrichedText @n + * The width and height must be greater than @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the parameter is outside the valid range defined by the method. + */ + result SetSize(const Tizen::Graphics::Dimension& size); + + /** + * Sets the text size. + * + * @since 2.0 + * + * @return An error code + * @param[in] width The new width of %EnrichedText @n + * It must be greater than @c 0. + * @param[in] height The new height of %EnrichedText @n + * It must be greater than @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + */ + result SetSize(int width, int height); + + /** + * Gets the size. + * + * @since 2.0 + * + * @return An instance of %Dimension containing the width and the height of the %EnrichedText instance + * + */ + Tizen::Graphics::Dimension GetSize(void) const; + + /** + * Gets the size of the %EnrichedText instance. + * + * @since 2.0 + * + * @param[out] width The width of the control + * @param[out] height The height of the control + */ + void GetSize(int& width, int& height) const; + + /** + * Gets the width of the %EnrichedText instance. + * + * @since 2.0 + * + * @return The width + */ + int GetWidth(void) const; + + /** + * Gets the height of the %EnrichedText instance. + * + * @since 2.0 + * + * @return The height + */ + int GetHeight(void) const; + + + /** + * Sets the vertical alignment. + * + * @since 2.0 + * + * @return An error code + * @param[in] alignment The vertical alignment of the text + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result SetVerticalAlignment(TextVerticalAlignment alignment); + + /** + * Sets the horizontal alignment. + * + * @since 2.0 + * + * @return An error code + * @param[in] alignment The horizontal alignment of the text + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result SetHorizontalAlignment(TextHorizontalAlignment alignment); + + /** + * Gets the vertical alignment. + * + * @since 2.0 + * + * @return alignment The vertical alignment of the text + */ + TextVerticalAlignment GetVerticalAlignment(void) const; + + /** + * Gets the horizontal alignment. + * + * @since 2.0 + * + * @return alignment The horizontal alignment of the text + */ + TextHorizontalAlignment GetHorizontalAlignment(void) const; + + /** + * Sets the text wrap style. + * + * @since 2.0 + * + * @return An error code + * @param[in] wrap The text wrapping style + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result SetTextWrapStyle(TextWrap wrap); + + /** + * Gets the text wrap style. + * + * @since 2.0 + * + * @return wrap The text wrapping style in the %EnrichedText bounds + */ + TextWrap GetTextWrapStyle(void) const; + + /** + * Sets the text abbreviation status. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable text abbreviation, @n + * else @c false + * @exception E_SUCCESS The method is successful. + */ + result SetTextAbbreviationEnabled(bool enable); + + /** + * Checks whether the text abbreviation is enabled. + * + * @since 2.0 + * + * @return @c true if the text abbreviation is enabled, @n + * else @c false + */ + bool IsTextAbbreviationEnabled(void) const; + + /** + * Sets the line spacing. + * + * @since 2.0 + * + * @return An error code + * @param[in] lineSpace The space between lines + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * + */ + result SetLineSpace(int lineSpace); + + /** + * Gets the line spacing. + * + * @since 2.0 + * + * @return space The space between lines + */ + int GetLineSpace(void) const; + + /** + * Refreshes the texts and bitmap according to the %EnrichedText instance's attributes. @n + * If some attributes are changed (such as changes using @ref SetSize), you can get the exact + * information of the text position or the number of lines after this method is called. + * + * @since 2.0 + */ + void Refresh(void); + + /** + * Gets the total line count of the text in the %EnrichedText instance. + * + * @since 2.0 + * + * @return The total line count + */ + int GetTotalLineCount(void) const; + + /** + * Gets the height of the text in the %EnrichedText instance. + * + * @since 2.0 + * + * @return The line height + */ + int GetTotalLineHeight(void) const; + + /** + * Gets the displayed line count of the text in the %EnrichedText instance. @n + * + * @since 2.0 + * + * @return The displayed line count + */ + int GetDisplayLineCount(void) const; + + /** + * Gets the length of the specified line. + * + * @since 2.0 + * + * @return The line length, @n + * else @c -1 if the method fails + * @param[in] lineIndex The index of the specified line + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetLineLength(int lineIndex) const; + + /** + * Gets the first character index of the specified line. + * + * @since 2.0 + * + * @return The first text offset, @n + * else @c -1 if the method fails + * @param[in] lineIndex The line index of the %EnrichedText object + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetFirstTextIndex(int lineIndex) const; + + /** + * Gets the line index of the specified character. + * + * @since 2.0 + * + * @return The line index, @n + * else @c -1 if the method fails + * @param[in] textIndex The text index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetLineIndex(int textIndex) const; + + /** + * Gets the line height of the specified line. + * + * @since 2.0 + * + * @return The line height, @n + * else @c -1 if the method fails + * @param[in] lineIndex The line index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetLineHeight(int lineIndex) const; + + /** + * Gets the text length of the %EnrichedText object. + * + * @since 2.0 + * + * @return The text length + */ + int GetTextLength(void) const; + + /** + * Gets the extent of the %EnrichedText instance on the assumption that all TextElements are + * expanded to one line. + * + * @since 2.0 + * + * @return An error code + * @param[in] startTextIndex The starting text index of the %EnrichedText + * @param[in] textLength The length of the specified text @n + * It must be greater than or equal to @c 0. + * @param[out] width The width of the specified text + * @param[out] height The height of the specified text + * @param[out] actualLength The actual text length measured + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result GetTextExtent(int startTextIndex, int textLength, int& width, int& height, int& actualLength) const; + + /** + * Gets the extent of the %EnrichedText instance on the assumption that all %TextElements are + * expanded to one line. + * + * @since 2.0 + * @return An error code + * @param[in] startTextIndex The starting text index of the EnrichedText + * @param[in] textLength The length of the specified text @n + * It must be greater than or equal to @c 0. + * @param[out] size The extent of the specified text + * @param[out] actualLength The actual text length measured + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result GetTextExtent(int startTextIndex, int textLength, Tizen::Graphics::Dimension& size, int& actualLength) const; + + /** + * Gets the extent of the %EnrichedText instance on the assumption that all %TextElements are + * not expanded to one line. This function is useful for finding the extent of EnrichedText spanning multiple lines. + * + * @since 2.0 + * @return An instance of %Dimension containing the extent of the %EnrichedText instance, @n + * else (-1, -1) if the method fails + */ + Tizen::Graphics::Dimension GetTextExtent(void) const; + + /** + * Adds the specified bitmap image to the %EnrichedText instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] bitmap The bitmap to draw @n + * The bitmap must be constructed before being passed to this method. + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM An unknown operating system error has occurred. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result Add(const Tizen::Graphics::Bitmap& bitmap); + + /** + * Inserts the specified bitmap image to the %EnrichedText instance at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] bitmap The @c bitmap to draw @n + * The bitmap must be constructed before being passed to this method. + * @param[in] elementIndex The index at which the @c bitmap image is to add + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM An unknown operating system error has occurred. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result InsertAt(int elementIndex, const Tizen::Graphics::Bitmap& bitmap); + + /** + * Gets the information about the link at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] point A point that is within the %EnrichedText object + * @param[out] linkInfo The LinkInfo object that represents the link at the specified position + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OBJ_NOT_FOUND The required instance is not found. + * @remarks The method throws @c E_OBJ_NOT_FOUND if there is no linked text at the specified position. + * @see Tizen::Base::Utility::LinkInfo + */ + result GetLinkInfoFromPosition(const Point& point, Tizen::Base::Utility::LinkInfo& linkInfo) const; + + + /** + * Gets the information about the link at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] x The x-coordinate of a point that is within the %EnrichedText object + * @param[in] y The y-coordinate of a point that is within the %EnrichedText object + * @param[out] linkInfo The LinkInfo object that represents the link at the specified position + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OBJ_NOT_FOUND The required instance is not found. + * @remarks The method throws @c E_OBJ_NOT_FOUND if there is no linked text at the specified position. + * @see Tizen::Base::Utility::LinkInfo + */ + result GetLinkInfoFromPosition(int x, int y, Tizen::Base::Utility::LinkInfo& linkInfo) const; + + /** + * Gets the vertical alignment among text and bitmap element. + * + * @since 2.0 + * + * @return The vertical alignment among the text and the bitmap element + */ + TextVerticalAlignment GetElementVerticalAlignment(void) const; + + /** + * Sets the vertical alignment among text and bitmap element. + * + * @since 2.0 + * + * @return An error code + * @param[in] alignment The vertical alignment among the text and the bitmap element + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @remarks This method sets how one element is positioned relative to the other elements. @n + * The vertical alignment of text and bitmap elements are decided based on the maximum height among elements. + * @remarks The default alignment TEXT_ALIGNMENT_BOTTOM. + */ + result SetElementVerticalAlignment(TextVerticalAlignment alignment); + +private: + friend class _EnrichedTextImpl; + + // + // This value is for internal use only. Using this value can cause behavioral, security-related, + // and consistency-related issues in the application. + // + class _EnrichedTextImpl * __pImpl; + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + EnrichedText(const EnrichedText& font); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + EnrichedText& operator =(const EnrichedText& rhs); +}; // EnrichedText + +}} // Tizen::Graphics + +#endif // _FGRP_ENRICHED_TEXT_H_ diff --git a/inc/FGrpFloatDimension.h b/inc/FGrpFloatDimension.h new file mode 100644 index 0000000..4d5b46a --- /dev/null +++ b/inc/FGrpFloatDimension.h @@ -0,0 +1,175 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpFloatDimension.h + * @brief This is the header file for the %FloatDimension class. + * + * This header file contains the declarations of the %FloatDimension class. + */ + +#ifndef _FGRP_FLOAT_DIMENSION_H_ +#define _FGRP_FLOAT_DIMENSION_H_ + +#include + +namespace Tizen { namespace Graphics { +/** + * @class FloatDimension + * @brief This class represents the width and height of a two-dimensional region. + * + * @since 2.0 + * + * The %FloatDimension class provides methods to abstract and set the width and height of a two-dimensional region. @n + * + * For more information on the class features, see Shapes. + * + */ +class _OSP_EXPORT_ FloatDimension : + public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. @n + * This constructor initializes an instance of %FloatDimension with the width and the height set as @c 0.f. + * + * @since 2.0 + */ + FloatDimension(void); + + /** + * This is the copy constructor for the %FloatDimension class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %FloatDimension + */ + FloatDimension(const FloatDimension& rhs); + + /** + * Initializes an instance of %FloatDimension with the specified values of width and height. + * + * @since 2.0 + * + * @param[in] width The width to set + * @param[in] height The height to set + */ + FloatDimension(float width, float height); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~FloatDimension(void); + + /** + * This is the default assignment operator for this class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %FloatDimension + */ + FloatDimension& operator=(const FloatDimension& rhs); + + /** + * Checks whether the two instances of %FloatDimension have equal width and height values. + * + * @since 2.0 + * + * @return @c true if the values of the width and height of the two instances of %FloatDimension are equal, @n + * else @c false + * @param[in] rhs An instance of %FloatDimension + */ + bool operator==(const FloatDimension& rhs) const; + + /** + * Checks whether the two instances of %FloatDimension have different width and height values. + * + * @since 2.0 + * + * @return @c true if the values of the width and height of the two instances of %FloatDimension are not equal, @n + * else @c false + * @param[in] rhs An instance of %FloatDimension + */ + bool operator!=(const FloatDimension& rhs) const; + + /** + * Checks whether the value of the current instance of %FloatDimension equals the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance equals the value of the specified instance, @n + * else @c false + * @param[in] rhs An instance of %FloatDimension + * @remarks The %FloatDimension class has a semantic value, which means that the + * Equals() method checks whether the two instances have the same width and height. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks Two equal instances must return the same hash value. For better performance, + * the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + /** + * Sets the size of the current instance of %FloatDimension. + * + * @since 2.0 + * + * @param[in] width The new width + * @param[in] height The new height + */ + void SetSize(float width, float height); + +public: + /** + * The width of the current instance of %FloatDimension. + * + * @since 2.0 + */ + float width; + + /** + * The height of the current instance of %FloatDimension. + * + * @since 2.0 + */ + float height; + +private: + friend class _FloatDimensionImpl; + + // + // This variable is for internal use only. + // Using this variable can cause behavioral, security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + class _FloatDimensionImpl* __pImpl; + +}; // FloatDimension + +}} // Tizen::Graphics + +#endif // _FGRP_FLOAT_DIMENSION_H_ diff --git a/inc/FGrpFloatMatrix4.h b/inc/FGrpFloatMatrix4.h new file mode 100644 index 0000000..ceaec8c --- /dev/null +++ b/inc/FGrpFloatMatrix4.h @@ -0,0 +1,426 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpFloatMatrix4.h + * @brief This is the header file for the %FloatMatrix4 class. + * + * This header file contains the declarations of the %FloatMatrix4 class. + * + */ + +#ifndef _FGRP_FLOAT_MATRIX4_H_ +#define _FGRP_FLOAT_MATRIX4_H_ + +#include + +namespace Tizen { namespace Graphics +{ +class FloatVector4; +}} + +namespace Tizen { namespace Graphics +{ +/** + * @class FloatMatrix4 + * @brief This class encapsulates a 4 X 4 matrix. + * + * @since 2.0 + * + * The %FloatMatrix4 class provides a float precision, two-dimensional matrix class. + * + */ +class _OSP_EXPORT_ FloatMatrix4 + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. @n + * This constructor initializes a 4 X 4 identity matrix. + * + * @since 2.0 + */ + FloatMatrix4(void); + + /** + * This is the copy constructor for the %FloatMatrix4 class. @n + * This constructor initializes the instance of %FloatMatrix4 with the attributes of the specified instance of %FloatMatrix4. + * + * @since 2.0 + * + * @param[in] rhs An instance of %FloatMatrix4 + */ + FloatMatrix4(const FloatMatrix4& rhs); + + /** + * This constructor initializes the instance of %FloatMatrix4 with the attributes of the specified instance of the array. + * + * @since 2.0 + * + * @param[in] matrix The matrix with 16 float values + */ + FloatMatrix4(const float matrix[4][4]); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~FloatMatrix4(void); + + /** + * Checks whether the current instance and the specified instance of %FloatMatrix4 are equal. + * + * @since 2.0 + * + * @return @c true if all matrix members of the current instance are equal to the corresponding matrix members in the specified instance, @n + * else @c false + * @param[in] rhs An instance of %FloatMatrix4 + */ + bool operator ==(const FloatMatrix4& rhs) const; + + /** + * Checks whether the current instance and the specified instance of %FloatMatrix4 are not equal. + * + * @since 2.0 + * + * @return @c true if all matrix members of the current instance are not equal to the corresponding matrix members in the specified instance, @n + * else @c false + * @param[in] rhs An instance of %FloatMatrix4 + */ + bool operator !=(const FloatMatrix4& rhs) const; + + /** + * Assigns the values of the specified instance to the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return The reference to this instance + * @param[in] rhs An instance of %FloatMatrix4 + */ + FloatMatrix4& operator =(const FloatMatrix4& rhs); + + /** + * Assigns the value to each matrix members of current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return The reference to this instance + * @param[in] value A @c float value to assign + */ + FloatMatrix4& operator =(float value); + + /** + * Multiplies the value of the specified instance with the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return A new instance of %FloatMatrix4 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatMatrix4 + */ + FloatMatrix4 operator *(const FloatMatrix4& rhs) const; + + /** + * Multiplies the current instance of %FloatMatrix4 with %FloatVector4. + * + * @since 2.0 + * + * @return A new instance of %FloatVector4 containing the resulting value of the operation + * @param[in] vector An instance of %FloatVector4 + */ + FloatVector4 operator *(const FloatVector4& vector) const; + + /** + * Multiplies the value to each matrix members of current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return A new instance of %FloatMatrix4 containing the resulting value of the operation + * @param[in] value A @c float value to multiply + */ + FloatMatrix4 operator *(float value) const; + + /** + * Adds the value of the specified instance and the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return A new instance of %FloatMatrix4 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatMatrix4 + */ + FloatMatrix4 operator +(const FloatMatrix4& rhs) const; + + /** + * Adds the value to each matrix members of current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return A new instance of %FloatMatrix4 containing the resulting value of the operation + * @param[in] value A @c float value to add + */ + FloatMatrix4 operator +(float value) const; + + /** + * Subtracts the value of the specified instance and the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return A new instance of %FloatMatrix4 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatMatrix4 + */ + FloatMatrix4 operator -(const FloatMatrix4& rhs) const; + + /** + * Subtracts the value from each matrix members of current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return A new instance of %FloatMatrix4 containing the resulting value of the operation + * @param[in] value A @c float value to subtract + */ + FloatMatrix4 operator -(float value) const; + + /** + * Multiplies the value of the specified instance and the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return The reference to %FloatMatrix4 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatMatrix4 + */ + FloatMatrix4& operator *=(const FloatMatrix4& rhs); + + /** + * Multiplies the value to each matrix members of current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return The reference to %FloatMatrix4 containing the resulting value of the operation + * @param[in] value A @c float value to multiply + */ + FloatMatrix4& operator *=(float value); + + /** + * Adds the value of the specified instance to the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return The reference to %FloatMatrix4 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatMatrix4 + */ + FloatMatrix4& operator +=(const FloatMatrix4& rhs); + + /** + * Adds the value to each matrix members of current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return The reference to %FloatMatrix4 containing the resulting value of the operation + * @param[in] value A @c float value to add + */ + FloatMatrix4& operator +=(float value); + + /** + * Subtracts the value of the specified instance from the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return The reference to %FloatMatrix4 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatMatrix4 + */ + FloatMatrix4& operator -=(const FloatMatrix4& rhs); + + /** + * Subtracts the value from each matrix members of current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return The reference to %FloatMatrix4 containing the resulting value of the operation + * @param[in] value A @c float value to subtract + */ + FloatMatrix4& operator -=(float value); + + /** + * Gets the instance of %FloatMatrix4 resulting from the sum of the value and the specified instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return A new instance of %FloatMatrix4 containing the resulting value of the operation + * @param[in] value A @c float value to add + * @param[in] rhs An instance of %FloatMatrix4 + */ + _OSP_EXPORT_ friend FloatMatrix4 operator +(const float& value, const FloatMatrix4& rhs); + + /** + * Gets the instance of %FloatMatrix4 resulting from the product of the value and the specified instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return A new instance of %FloatMatrix4 containing the resulting value of the operation + * @param[in] value A @c float value to multiply + * @param[in] rhs An instance of %FloatMatrix4 + */ + _OSP_EXPORT_ friend FloatMatrix4 operator *(const float& value, const FloatMatrix4& rhs); + + /** + * Gets the instance of %FloatMatrix4 resulting from the difference between the value and the specified instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return A new instance of %FloatMatrix4 containing the resulting value of the operation + * @param[in] value A @c float value to subtract + * @param[in] rhs An instance of %FloatMatrix4 + */ + _OSP_EXPORT_ friend FloatMatrix4 operator -(const float& value, const FloatMatrix4& rhs); + + /** + * Checks whether the current instance of %FloatMatrix4 equals the specified instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return @c true if the values of the current instance is equal to the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %FloatMatrix4 + * @remarks This method overrides Tizen::Base::Object::Equals(). This method uses the values of the Matrix components to compare the two instances. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + /** + * Gets the hash value of the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks Two equal instances must return the same hash value. For better performance, + * the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + /** + * Gets the determinant of the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return The determinant value of the current instance + */ + float GetDeterminant(void) const; + + /** + * Gets the inverse matrix of the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return A new instance of %FloatMatrix4 containing the resulting value of the operation + * @remarks This function must be called after checking whether the matrix is invertible or not. + */ + FloatMatrix4 GetInverse(void) const; + + /** + * Gets the trace of the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return The trace of the current instance + */ + float GetTrace(void) const; + + /** + * Gets the transpose matrix of the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return A new instance of %FloatMatrix4 containing the resulting value of the operation + */ + FloatMatrix4 GetTranspose(void) const; + + /** + * Checks whether the current instance is an identity matrix. + * + * @since 2.0 + * + * @return @c true if the matrix is an identity matrix, @n + * else @c false + */ + bool IsIdentity(void) const; + + /** + * Checks whether the current matrix is invertible. + * + * @since 2.0 + * + * @return @c true if the matrix is invertible, @n + * else @c false + */ + bool IsInvertible(void) const; + + /** + * Negates the matrix members of current instance of %FloatMatrix4. + * + * @since 2.0 + */ + void Negate(void); + + /** + * Sets the identity matrix to the current instance of %FloatMatrix4. + * + * @since 2.0 + */ + void SetAsIdentity(void); + + /** + * Sets the inverse matrix to the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current instance is not invertible. + */ + result Invert(void); + + /** + * Sets the transposed matrix to the current instance of %FloatMatrix4. + * + * @since 2.0 + */ + void Transpose(void); + + /** + * Sets the matrix members of current instance of %FloatMatrix4 to zero. + * + * @since 2.0 + */ + void SetAsNull(void); + + /** + * The matrix of the current instance of %FloatMatrix4. + * + * @since 2.0 + * + * @remarks The column-major order matrix. + */ + float matrix[4][4]; + +private: + friend class _FloatMatrix4Impl; + class _FloatMatrix4Impl* __pImpl; + +}; // FloatMatrix4 + +}} // Tizen::Graphics + +#endif //_FGRP_FLOAT_MATRIX4_H_ diff --git a/inc/FGrpFloatPoint.h b/inc/FGrpFloatPoint.h new file mode 100644 index 0000000..d7de906 --- /dev/null +++ b/inc/FGrpFloatPoint.h @@ -0,0 +1,232 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpFloatPoint.h + * @brief This is the header file for the %FloatPoint class. + * + * This header file contains the declarations of the %FloatPoint class. + */ + +#ifndef _FGRP_FLOAT_POINT_H_ +#define _FGRP_FLOAT_POINT_H_ + +#include + +namespace Tizen { namespace Graphics { +/** + * @class FloatPoint + * @brief This class encapsulates a point in a two-dimensional coordinate system. + * + * @since 2.0 + * + * The %FloatPoint class represents a location in a two-dimensional coordinate space specified with an single precision floating point. + * + * For more information on the class features, see Shapes. + */ +class _OSP_EXPORT_ FloatPoint : + public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. @n + * This constructor initializes an instance of %FloatPoint with the values (0.f, 0.f). + * + * @since 2.0 + */ + FloatPoint(void); + + /** + * This is the copy constructor for the %FloatPoint class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %FloatPoint + */ + FloatPoint(const FloatPoint& rhs); + + /** + * Initializes an instance of %FloatPoint with the specified location. + * + * @since 2.0 + * + * @param[in] x The x-coordinate + * @param[in] y The y-coordinate + */ + FloatPoint(float x, float y); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~FloatPoint(void); + + /** + * This is the default assignment operator for this class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %FloatPoint + */ + FloatPoint& operator=(const FloatPoint& rhs); + + /** + * Checks whether the current instance and the specified instance of %FloatPoint are equal. + * + * @since 2.0 + * + * @return @c true if the two instances of %FloatPoint are at the same location, @n + * else @c false + * @param[in] rhs An instance of %FloatPoint + */ + bool operator==(const FloatPoint& rhs) const; + + /** + * Checks whether the current instance and the specified instance of %FloatPoint are not equal. + * + * @since 2.0 + * + * @return @c true if the two instances of %FloatPoint are at different locations, @n + * else @c false + * @param[in] rhs An instance of %FloatPoint + */ + bool operator!=(const FloatPoint& rhs) const; + + /** + * Adds the value of the specified instance of %FloatPoint and the current instance. + * + * @since 2.0 + * + * @return A new instance of %FloatPoint containing the resulting value of the operation + * @param[in] rhs An instance of %FloatPoint + */ + FloatPoint operator+(const FloatPoint& rhs) const; + + /** + * Subtracts the value of the specified instance of %FloatPoint and the current instance. + * + * @since 2.0 + * + * @return A new instance of %FloatPoint containing the resulting value of the operation + * @param[in] rhs An instance of %FloatPoint + */ + FloatPoint operator-(const FloatPoint& rhs) const; + + /** + * Adds the value of the specified instance of %FloatPoint to the current instance. + * + * @since 2.0 + * + * @param[in] point An instance of %FloatPoint + */ + FloatPoint& operator+=(const FloatPoint& point); + + /** + * Subtracts the value of the specified instance of %FloatPoint from the current instance. + * + * @since 2.0 + * + * @param[in] point An instance of %FloatPoint + */ + FloatPoint& operator-=(const FloatPoint& point); + + /** + * Checks whether the value of the specified instance of %FloatPoint equals the value of the current instance. + * + * @since 2.0 + * + * @return @c true if the value of the specified instance equals the value of the current instance, @n + * else @c false + * @param[in] rhs An instance of %FloatPoint + * @remarks The %FloatPoint class has a semantic value, which means that the + * Equals() method checks whether the two instances have the same + * location. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks Two equal instances must return the same hash value. For better performance, + * the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + /** + * Sets the x and y coordinates for the current instance of %FloatPoint. + * + * @since 2.0 + * + * @param[in] x The new x-coordinate + * @param[in] y The new y-coordinate + */ + void SetPosition(float x, float y); + + /** + * Sets the current instance of %FloatPoint. + * + * @since 2.0 + * + * @param[in] point An instance of %FloatPoint + */ + void SetPosition(const FloatPoint& point); + + /** + * Translates this %FloatPoint to the indicated distance. + * + * @since 2.0 + * + * @param[in] deltaX The distance to move this point along the x-axis + * @param[in] deltaY The distance to move this point along the y-axis + */ + void Translate(float deltaX, float deltaY); + +public: + /** + * The x-coordinate of the point. + * + * @since 2.0 + */ + float x; + + /** + * The y-coordinate of the point. + * + * @since 2.0 + */ + float y; + +private: + friend class _FloatPointImpl; + + // + // This variable is for internal use only. + // Using this variable can cause behavioral, security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + class _FloatPointImpl* __pImpl; + +}; // FloatPoint + +}} // Tizen::Graphics + +#endif // _FGRP_FLOAT_POINT_H_ diff --git a/inc/FGrpFloatPoint3.h b/inc/FGrpFloatPoint3.h new file mode 100644 index 0000000..fe91906 --- /dev/null +++ b/inc/FGrpFloatPoint3.h @@ -0,0 +1,275 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpFloatPoint3.h + * @brief This is the header file for the %FloatPoint3 class. + * + * This header file contains the declarations of the %FloatPoint3 class. + * + */ + +#ifndef _FGRP_FLOAT_POINT3_H_ +#define _FGRP_FLOAT_POINT3_H_ + +#include + +namespace Tizen { namespace Graphics +{ +class FloatVector4; +}} + +namespace Tizen { namespace Graphics +{ +/** + * @class FloatPoint3 + * @brief This class encapsulates a 3-dimensional point. + * + * @since 2.0 + * + * The %FloatPoint3 class provides a float precision, three-dimensional point class. + * + */ +class _OSP_EXPORT_ FloatPoint3 + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. @n + * This constructor initializes the instance to a 3-dimensional zero point. + * + * @since 2.0 + */ + FloatPoint3(void); + + /** + * This is the copy constructor for the %FloatPoint3 class. @n + * This constructor initializes the instance of %FloatPoint3 with the attributes of the specified instance of %FloatPoint3. + * + * @since 2.0 + * + * @param[in] rhs An instance of %FloatPoint3 + */ + FloatPoint3(const FloatPoint3& rhs); + + /** + * This constructor initializes the instance of %FloatPoint3 with the attributes of the specified instance of %FloatVector4. + * + * @since 2.0 + * + * @param[in] vector An instance of %FloatVector4 + * @remarks The normalized vector can only be converted to point. Therefore, when the input vector is not normalized then the point is converted from the normal vector of the input instance. + */ + explicit FloatPoint3(const FloatVector4& vector); + + /** + * This constructor initializes the instance of %FloatPoint3 with the attributes of the specified instance of the array. + * + * @since 2.0 + * + * @param[in] point The point with 3 float values + */ + explicit FloatPoint3(const float point[3]); + + /** + * This constructor initializes the instance of %FloatPoint3 with floating point numbers for each coordinate. + * + * @since 2.0 + * + * @param[in] x x component of point instance + * @param[in] y y component of point instance + * @param[in] z z component of point instance + */ + FloatPoint3(float x, float y, float z); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~FloatPoint3(void); + + /** + * Checks whether the current instance and the specified instance of %FloatPoint3 are equal. + * + * @since 2.0 + * + * @return @c true if all members of the current point instance are equal to the corresponding point members in the specified instance, @n + * else @c false + * @param[in] rhs An instance of %FloatPoint3 + */ + bool operator ==(const FloatPoint3& rhs) const; + + /** + * Checks whether the current instance and the specified instance of %FloatPoint3 are not equal. + * + * @since 2.0 + * + * @return @c true if all point members of the current instance are not equal to the corresponding point members in the specified instance, @n + * else @c false + * @param[in] rhs An instance of %FloatPoint3 + */ + inline bool operator !=(const FloatPoint3& rhs) const + { + return !(*this == rhs); + } + + /** + * Assigns the values of the specified instance to the current instance of %FloatPoint3. + * + * @since 2.0 + * + * @return The reference to this instance + * @param[in] rhs An instance of %FloatPoint3 + */ + FloatPoint3& operator =(const FloatPoint3& rhs); + + /** + * Multiplies the value to each point members of current instance of %FloatPoint3. + * + * @since 2.0 + * + * @return A new instance of %FloatPoint3 containing the resulting value of the operation + * @param[in] value A @c float value to multiply + */ + FloatPoint3 operator *(float value) const; + + /** + * Divides each point members of current instance of %FloatPoint3 with the specified value. + * + * @since 2.0 + * + * @return A new instance of %FloatPoint3 containing the resulting value of the operation + * @param[in] value A @c float value to divide + */ + FloatPoint3 operator /(float value) const; + + /** + * Adds the value of the specified instance and the current instance of %FloatPoint3. + * + * @since 2.0 + * + * @return A new instance of %FloatPoint3 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatPoint3 + */ + FloatPoint3 operator +(const FloatPoint3& rhs) const; + + /** + * Subtracts the value of the specified instance from the current instance of %FloatPoint3. + * + * @since 2.0 + * + * @return A new instance of %FloatPoint3 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatPoint3 + */ + FloatPoint3 operator -(const FloatPoint3& rhs) const; + + /** + * Adds the value of the specified instance to the current instance of %FloatPoint3. + * + * @since 2.0 + * + * @return The reference to %FloatPoint3 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatPoint3 + */ + FloatPoint3& operator +=(const FloatPoint3& rhs); + + /** + * Subtracts the value of the specified instance from the current instance of %FloatPoint3. + * + * @since 2.0 + * + * @return The reference to %FloatPoint3 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatPoint3 + */ + FloatPoint3& operator -=(const FloatPoint3& rhs); + + /** + * Checks whether the current instance of %FloatPoint3 equals the specified instance of %FloatPoint3. + * + * @since 2.0 + * + * @return @c true if the values of the current instance is equal to the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %FloatPoint3 + * @remarks This method overrides Tizen::Base::Object::Equals(). This method uses the values of the Point components to compare the two instances. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + /** + * Gets the hash value of the current instance of %FloatPoint3. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks Two equal instances must return the same hash value. For better performance, + * the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + /** + * x component of the current instance of %FloatPoint3. + * + * @since 2.0 + */ + float x; + + /** + * y component of the current instance of %FloatPoint3. + * + * @since 2.0 + */ + float y; + + /** + * z component of the current instance of %FloatPoint3. + * + * @since 2.0 + */ + float z; + +private: + friend class _FloatPoint3Impl; + class _FloatPoint3Impl* __pImpl; + +}; // FloatPoint3 + +/** + * Gets the instance of %FloatPoint3 resulting from the product of the value and the specified instance of %FloatPoint3. + * + * @since 2.0 + * + * @return A new instance of %FloatPoint3 containing the resulting value of the operation + * @param[in] value A @c float value to multiply + * @param[in] rhs An instance of %FloatPoint3 + */ +_OSP_EXPORT_ FloatPoint3 operator *(const float& value, const FloatPoint3& rhs); + +/** + * Gets the instance of %FloatPoint3 resulting from the divide of the value and the specified instance of %FloatPoint3. + * + * @since 2.0 + * + * @return A new instance of %FloatPoint3 containing the resulting value of the operation + * @param[in] value A @c float value to divide + * @param[in] rhs An instance of %FloatPoint3 + */ +_OSP_EXPORT_ FloatPoint3 operator /(const float& value, const FloatPoint3& rhs); + +}} // Tizen::Graphics + +#endif //_FGRP_FLOAT_POINT3_H_ diff --git a/inc/FGrpFloatRectangle.h b/inc/FGrpFloatRectangle.h new file mode 100644 index 0000000..63b6cfb --- /dev/null +++ b/inc/FGrpFloatRectangle.h @@ -0,0 +1,347 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpFloatRectangle.h + * @brief This is the header file for the %FloatRectangle class. + * + * This header file contains the declarations of the %FloatRectangle class. + */ + +#ifndef _FGRP_FLOAT_RECTANGLE_H_ +#define _FGRP_FLOAT_RECTANGLE_H_ + +#include + +namespace Tizen { namespace Graphics +{ +class FloatPoint; +class FloatDimension; + +/** + * @class FloatRectangle + * @brief This class abstracts a rectangular region. + * + * @since 2.0 + * + * The %FloatRectangle class represents a rectangular region in a coordinate space, which is specified by the rectangle + * object's top-left point (x, y) in the coordinate space, along with its width and height. + * + * For more information on the class features, see Shapes. + */ +class _OSP_EXPORT_ FloatRectangle + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. @n + * It initializes an instance of %FloatRectangle with all its attributes set to @c 0.f. + * + * @since 2.0 + * + * @remarks The attribute value is @c 0 when initialized. + */ + FloatRectangle(void); + + /** + * This is the copy constructor for the %FloatRectangle class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %FloatRectangle + */ + FloatRectangle(const FloatRectangle& rhs); + + /** + * Initializes an instance of %FloatRectangle with the specified location and dimension. + * + * @since 2.0 + * + * @param[in] x The x-coordinate of the top-left corner of the rectangle + * @param[in] y The y-coordinate of the top-left corner of the rectangle + * @param[in] width The width of the rectangle + * @param[in] height The height of the rectangle + * + */ + FloatRectangle(float x, float y, float width, float height); + + /** + * Initializes an instance of %FloatRectangle at the location specified by @c point and + * with dimension specified by @c dim. + * + * @since 2.0 + * + * @param[in] point The location of the top-left corner of the rectangle + * @param[in] dim The width and height of the rectangle + */ + FloatRectangle(const FloatPoint& point, const FloatDimension& dim); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~FloatRectangle(void); + + /** + * This is the default assignment operator for this class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %FloatRectangle + */ + FloatRectangle& operator=(const FloatRectangle& rhs); + + /** + * Checks whether the location and dimension of the current instance of %FloatRectangle match those of the + * specified instance of %FloatRectangle. + * + * @since 2.0 + * + * @return @c true if the location and dimension of the current instance match those of the specified instance, @n + * else @c false + * @param[in] rhs An instance of %FloatRectangle + */ + bool operator==(const FloatRectangle& rhs) const; + + /** + * Checks whether the location and dimension of the current instance of %FloatRectangle do not match those of the + * specified instance of %FloatRectangle. + * + * @since 2.0 + * + * @return @c true if the location and dimension of the current instance do not match those of the specified instance, @n + * else @c false + * @param[in] rhs An instance of %FloatRectangle + */ + bool operator!=(const FloatRectangle& rhs) const; + + /** + * Checks whether the specified point lies inside the current instance of %FloatRectangle. + * + * @since 2.0 + * + * @return @c true if the location represented by @c point lies inside the current instance of %FloatRectangle, @n + * else @c false + * @param[in] point An instance of FloatPoint + */ + bool Contains(const FloatPoint& point) const; + + /** + * Checks whether the value of the current instance of %FloatRectangle equals the value of the specified instance of + * %FloatRectangle. + * + * @since 2.0 + * + * @return @c true if the value of the current instance of %FloatRectangle equals the value of the specified instance of %FloatRectangle, @n + * else @c false + * @param[in] rhs An instance of %FloatRectangle + * @remarks The %FloatRectangle class has a semantic value, which means that the Equals() method checks whether the + * two instances have the same location and size. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks Two equal instances must return the same hash value. For better performance, + * the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + /** + * Gets the intersection of the current instance and the specified instance of %FloatRectangle. @n + * If the two instances of %FloatRectangle do not intersect, empty instance is returned. + * + * @since 2.0 + * + * @param[in] rect An instance of %FloatRectangle + */ + FloatRectangle GetIntersection(const FloatRectangle& rect) const; + + /** + * Checks whether the current instance of %FloatRectangle intersects with the specified instance of %FloatRectangle. + * + * @since 2.0 + * + * @return @c true if the current instance of %FloatRectangle intersects with the specified instance of %FloatRectangle, @n + * else @c false + * @param[in] rect An instance of %FloatRectangle + * + */ + bool IsIntersected(const FloatRectangle& rect) const; + + /** + * Gets the union of the current instance and the specified instance of %FloatRectangle. + * + * @since 2.0 + * + * @return An instance of %FloatRectangle containing the union of the two rectangles + * @param[in] rect An instance of %FloatRectangle + */ + FloatRectangle GetUnion(const FloatRectangle& rect) const; + + /** + * Gets the coordinates of the point at the bottom-right corner of the rectangle. + * + * @since 2.0 + * + * @return The coordinates of the point at the bottom-right corner of the rectangle + */ + FloatPoint GetBottomRight(void) const; + + /** + * Gets the coordinates of the point at the top-left corner of the rectangle. + * + * @since 2.0 + * + * @return The coordinates of the point at the top-left corner of the rectangle + */ + FloatPoint GetTopLeft(void) const; + + /** + * Checks whether this %FloatRectangle is empty. @n + * A %FloatRectangle is empty if its width or its height is less than or equal to @c 0. + * + * @since 2.0 + * + * @return @c true if this rectangle is empty, @n + * else @c false + */ + bool IsEmpty(void) const; + + /** + * Sets the size of this %FloatRectangle to match the specified FloatDimension. + * + * @since 2.0 + * + * @param[in] dim The new size for FloatDimension + */ + void SetSize(const FloatDimension& dim); + + /** + * Sets the size of this %FloatRectangle to match the specified dimension. + * + * @since 2.0 + * + * @param[in] width The new width + * @param[in] height The new height + */ + void SetSize(float width, float height); + + /** + * Sets the position of this %FloatRectangle to the specified point. + * + * @since 2.0 + * + * @param[in] point The new position + */ + void SetPosition(const FloatPoint& point); + + /** + * Sets the location of the current instance of %FloatRectangle with the specified values of the + * x and y coordinates of the top-left corner point. + * + * @since 2.0 + * + * @param[in] x The new x-coordinate + * @param[in] y The new y-coordinate + */ + void SetPosition(float x, float y); + + /** + * Sets the location and the dimensions of the current instance of %FloatRectangle with the specified x and y + * coordinates of the top-left corner point and the specified dimensions. + * + * @since 2.0 + * + * @param[in] x The new x-coordinate + * @param[in] y The new y-coordinate + * @param[in] width The new width + * @param[in] height The new height + */ + void SetBounds(float x, float y, float width, float height); + + /** + * Sets the location and the dimensions of the current instance of %FloatRectangle with the specified location and + * dimension. + * + * @since 2.0 + * + * @param[in] point An instance of FloatPoint + * @param[in] dim An instance of FloatDimension + */ + void SetBounds(const FloatPoint& point, const FloatDimension& dim); + + /** + * Translates this %FloatRectangle to the new point by the specified distance along the x-axis and y-axis. + * + * @since 2.0 + * + * @param[in] deltaX The distance to move this %FloatRectangle along the x-axis + * @param[in] deltaY The distance to move this %FloatRectangle along the y-axis + */ + void Translate(float deltaX, float deltaY); + +public: + /** + * The x-coordinate of the top-left corner of the rectangle. + * + * @since 2.0 + */ + float x; + + /** + * The y-coordinate of the top-left corner of the rectangle. + * + * @since 2.0 + */ + float y; + + /** + * The width of this rectangle. + * + * @since 2.0 + */ + float width; + + /** + * The height of this rectangle. + * + * @since 2.0 + */ + float height; + +private: + friend class _FloatRectangleImpl; + + // + // This variable is for internal use only. + // Using this variable can cause behavioral, security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + class _FloatRectangleImpl* __pImpl; + +}; // FloatRectangle + +}} // Tizen::Graphics + +#endif // _FGRP_FLOAT_RECTANGLE_H_ diff --git a/inc/FGrpFloatVector4.h b/inc/FGrpFloatVector4.h new file mode 100644 index 0000000..d9633bc --- /dev/null +++ b/inc/FGrpFloatVector4.h @@ -0,0 +1,329 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpFloatVector4.h + * @brief This is the header file for the %FloatVector4 class. + * + * This header file contains the declarations of the %FloatVector4 class. + * + */ + +#ifndef _FGRP_FLOAT_VECTOR4_H_ +#define _FGRP_FLOAT_VECTOR4_H_ + +#include + +namespace Tizen { namespace Graphics +{ +class FloatPoint3; +class FloatMatrix4; +}} + +namespace Tizen { namespace Graphics +{ +/** + * @class FloatVector4 + * @brief This class encapsulates a 4-dimensional vector. + * + * @since 2.0 + * + * The %FloatVector4 class provides a float precision, four-dimensional vector class. + * + */ +class _OSP_EXPORT_ FloatVector4 + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. @n + * This constructor initializes the instance to a 4-dimensional zero vector. + * + * @since 2.0 + */ + FloatVector4(void); + + /** + * This is the copy constructor for the %FloatVector4 class. @n + * This constructor initializes the instance of %FloatVector4 with the attributes of the specified instance of %FloatVector4. + * + * @since 2.0 + * + * @param[in] rhs An instance of %FloatVector4 + */ + FloatVector4(const FloatVector4& rhs); + + /** + * This constructor initializes the instance of %FloatVector4 with the attributes of the specified instance of %FloatPoint3. + * + * @since 2.0 + * + * @param[in] point An instance of %FloatPoint3 + * @remarks The point is converted to normal vector. + */ + explicit FloatVector4(const FloatPoint3& point); + + /** + * This constructor initializes the instance of %FloatVector4 with the attributes of the specified instance of the array. + * + * @since 2.0 + * + * @param[in] vector The vector with 4 float values + */ + explicit FloatVector4(const float vector[4]); + + /** + * This constructor initializes the instance of %FloatVector4 with floating point numbers for for each coordinate. + * + * @since 2.0 + * + * @param[in] x x component of vector instance + * @param[in] y y component of vector instance + * @param[in] z z component of vector instance + * @param[in] w w component of vector instance + */ + FloatVector4(float x, float y, float z, float w); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~FloatVector4(void); + + /** + * Checks whether the current instance and the specified instance of %FloatVector4 are equal. + * + * @since 2.0 + * + * @return @c true if all members of the current vector instance are equal to the corresponding vector members in the specified instance, @n + * else @c false + * @param[in] rhs An instance of %FloatVector4 + */ + bool operator ==(const FloatVector4& rhs) const; + + /** + * Checks whether the current instance and the specified instance of %FloatVector4 are not equal. + * + * @since 2.0 + * + * @return @c true if all vector members of the current instance are not equal to the corresponding vector members in the specified instance, @n + * else @c false + * @param[in] rhs An instance of %FloatVector4 + */ + inline bool operator !=(const FloatVector4& rhs) const + { + return !(*this == rhs); + } + + /** + * Assigns the values of the specified instance to the current instance of %FloatVector4. + * + * @since 2.0 + * + * @return The reference to this instance + * @param[in] rhs An instance of %FloatVector4 + */ + FloatVector4& operator =(const FloatVector4& rhs); + + /** + * Multiplies the value to each vector members of current instance of %FloatVector4. + * + * @since 2.0 + * + * @return A new instance of %FloatVector4 containing the resulting value of the operation + * @param[in] value A @c float value to multiply + */ + FloatVector4 operator *(float value) const; + + /** + * Divides each vector members of current instance of %FloatVector4 with the specified value. + * + * @since 2.0 + * + * @return A new instance of %FloatVector4 containing the resulting value of the operation + * @param[in] value A @c float value to divide + */ + FloatVector4 operator /(float value) const; + + /** + * Adds the value of the specified instance and the current instance of %FloatVector4. + * + * @since 2.0 + * + * @return A new instance of %FloatVector4 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatVector4 + */ + FloatVector4 operator +(const FloatVector4& rhs) const; + + /** + * Subtracts the value of the specified instance from the current instance of %FloatVector4. + * + * @since 2.0 + * + * @return A new instance of %FloatVector4 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatVector4 + */ + FloatVector4 operator -(const FloatVector4& rhs) const; + + /** + * Adds the value of the specified instance to the current instance of %FloatVector4. + * + * @since 2.0 + * + * @return The reference to %FloatVector4 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatVector4 + */ + FloatVector4& operator +=(const FloatVector4& rhs); + + /** + * Subtracts the value of the specified instance from the current instance of %FloatVector4. + * + * @since 2.0 + * + * @return The reference to %FloatVector4 containing the resulting value of the operation + * @param[in] rhs An instance of %FloatVector4 + */ + FloatVector4& operator -=(const FloatVector4& rhs); + + /** + * Calculates the dot product with the specified instance and the current instance of %FloatVector4. + * + * @since 2.0 + * + * @return The value of the operation. + * @param[in] rhs An instance of %FloatVector4 + */ + float DotProduct(const FloatVector4& rhs) const; + + /** + * Calculates the dot product with the specified instance and the current instance of %FloatVector4. + * + * @since 2.0 + * + * @return The value of the operation. + * @param[in] rhs An instance of %FloatVector4 + */ + float operator *(const FloatVector4& rhs) const; + + /** + * Checks whether the current instance of %FloatVector4 equals the specified instance of %FloatVector4. + * + * @since 2.0 + * + * @return @c true if the values of the current instance is equal to the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %FloatVector4 + * @remarks This method overrides Tizen::Base::Object::Equals(). This method uses the values of the Vector components to compare the two instances. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + /** + * Gets the hash value of the current instance of %FloatVector4. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks Two equal instances must return the same hash value. For better performance, + * the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + /** + * Gets the length of the current instance of %FloatVector4. + * + * @since 2.0 + * + * @return The length of the current instance + */ + float GetLength(void) const; + + /** + * Gets the normal vector of the current instance of %FloatVector4. + * + * @since 2.0 + * + * @return A new instance of %FloatVector4 containing the resulting value of the operation + */ + FloatVector4 GetNormal(void) const; + + /** + * Normalize the current instance of %FloatVector4. + * + * @since 2.0 + */ + void Normalize(void); + + /** + * x component of the current instance of %FloatVector4. + * + * @since 2.0 + */ + float x; + + /** + * y component of the current instance of %FloatVector4. + * + * @since 2.0 + */ + float y; + + /** + * z component of the current instance of %FloatVector4. + * + * @since 2.0 + */ + float z; + + /** + * w component of the current instance of %FloatVector4. + * + * @since 2.0 + */ + float w; + +private: + friend class _FloatVector4Impl; + class _FloatVector4Impl* __pImpl; + +}; // FloatVector4 + +/** + * Gets the instance of %FloatVector4 resulting from the product of the value and the specified instance of %FloatVector4. + * + * @since 2.0 + * + * @return A new instance of %FloatVector4 containing the resulting value of the operation + * @param[in] value A @c float value to multiply + * @param[in] rhs An instance of %FloatVector4 + */ +_OSP_EXPORT_ FloatVector4 operator *(const float& value, const FloatVector4& rhs); + +/** + * Gets the instance of %FloatVector4 resulting from the divide of the value and the specified instance of %FloatVector4. + * + * @since 2.0 + * + * @return A new instance of %FloatVector4 containing the resulting value of the operation + * @param[in] value A @c float value to divide + * @param[in] rhs An instance of %FloatVector4 + */ +_OSP_EXPORT_ FloatVector4 operator /(const float& value, const FloatVector4& rhs); + +}} // Tizen::Graphics + +#endif //_FGRP_FLOAT_VECTOR4_H_ diff --git a/inc/FGrpFont.h b/inc/FGrpFont.h new file mode 100644 index 0000000..1320d26 --- /dev/null +++ b/inc/FGrpFont.h @@ -0,0 +1,401 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpFont.h + * @brief This is the header file for the %Font class. + * + * This header file contains the declarations of the %Font class. + */ + +#ifndef _FGRP_FONT_H_ +#define _FGRP_FONT_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Graphics +{ +/** + * @class Font + * @brief This class provides methods to retrieve the font information. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %Font class encapsulates the characteristics, such as the size and style of a specific vector font. + * Fonts are used to draw text on a Canvas. + * + * For more information on the class features, see Fonts. + * + * + */ +class _OSP_EXPORT_ Font + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + * + * @remarks After creating an instance of this class, one of the + * Construct() methods must be called explicitly to initialize this instance. + */ + Font(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Font(void); + + /** + * Initializes this instance of %Font with the specified size and style. @n + * If the size and style are not specified, the default system font is set. + * + * @since 2.0 + * + * @return An error code + * @param[in] style The font style @n + * For more information, see Tizen::Graphics::FontStyle. + * @param[in] size The font size in pixels @n + * The size must be greater than @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(int style, int size); + + /** + * Initializes this instance of %Font with the specified parameters. + * + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompIoPathPage "IoPath" and @ref CompFontConstructPage "FontConstructor" issues. + * @endif + * @return An error code + * @param[in] fontNameOrPath The local file path of a font-resource file or app font name or system font name @n + * The app font name is retrieved using GetFaceName(Osp::Base::String& filepath). + * The system font name is retrieved using GetSystemFontListN(). + * @param[in] style The font style @n + * Multiple styles can be combined using the bitwise OR operator. + * @param[in] size The font size in pixels @n + * The size must be greater than @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_FILE_NOT_FOUND The specified font cannot be found or accessed. + * @exception E_UNSUPPORTED_FORMAT The specified font format is not supported. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @remarks Only TrueType font is supported. + * The value of fontNameOrPath is considered system font name if it matches one of the retrieved values using GetSystemFontListN(). + * If not, it is considered local file path of a font-resource file. + */ + result Construct(const Tizen::Base::String& fontNameOrPath, int style, int size); + + /** + * @if OSPCOMPAT + * @page CompFontConstructPage Compatibility for Construct(). + * @section CompFontConstructPageIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# In OSP, the value of 1 st parameter(fontNameOrPath) can be system font name or local font path. At first, it is compared to the retrieved values using GetSystemFontListN(). If the matched value is exist, it is considered system font name. Or, it is considered local file path of a font-resource file. + * -# In Tizen, the value of 1 st parameter(fontNameOrPath) can be app font name or system font name or local font path. At first, it is compared to the font face names in app font resource folder. If the matched value is exist, it is considered app font name. Or, it is considered system font name if it matches one of the retrieved values using GetSystemFontListN(). + * @endif + */ + + /** + * Initializes this instance of %Font with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] fontData The font data + * @param[in] style The font style @n + * Multiple styles can be combined using the bitwise OR operator. + * @param[in] size The font size in pixels @n + * The size must be greater than @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_UNSUPPORTED_FORMAT The specified font format is not supported. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + */ + result Construct(const Tizen::Base::ByteBuffer& fontData, int style, int size); + + /** + * Gets the maximum height of the current instance of %Font. + * + * @since 2.0 + * + * @return The maximum height of the current instance of %Font, @n + * else @c -1 if the method fails + */ + int GetMaxHeight(void) const; + + /** + * Gets the maximum width of the current instance of %Font. + * + * @since 2.0 + * + * @return The maximum width of the current instance of %Font, @n + * else @c -1 if the method fails + */ + int GetMaxWidth(void) const; + + /** + * Gets the ascender of the current instance of %Font. + * + * @since 2.0 + * + * @return The ascender of the current instance of %Font, @n + * else @c -1 if the method fails + */ + int GetAscender(void) const; + + /** + * Gets the descender of the current instance of %Font. + * + * @since 2.0 + * + * @return The descender of the current instance of %Font, @n + * else @c -1 if the method fails + */ + int GetDescender(void) const; + + /** + * Gets the left bear of a character. + * + * @since 2.0 + * + * @return An error code + * @param[in] character A character for getting left bear + * @param[out] leftBear The left bear of the specified @c character + * @exception E_SUCCESS The method is successful. + * @exception E_DATA_NOT_FOUND The requested data does not exist. + */ + result GetLeftBear(wchar_t character, int& leftBear) const; + + /** + * Gets the right bear of a character. + * + * @since 2.0 + * + * @return An error code + * @param[in] character A character for getting the right bear + * @param[out] rightBear The right bear of the specified @c character + * @exception E_SUCCESS The method is successful. + * @exception E_DATA_NOT_FOUND The requested data does not exist. + */ + result GetRightBear(wchar_t character, int& rightBear) const; + + /** + * Gets the width and height of the font used in the specified text. @n + * This method retrieves the font dimension of the text. + * + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see the issue description for @ref CompFontGetTextExtentPage "here". + * @endif + * + * @return An error code + * @param[in] text The string + * @param[in] length The length of @c text @n + * The length must be greater than or equal to @c 0. + * @param[out] dim The width and height of the font of the @c text + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of @c length is greater than the actual length of @c text. + */ + result GetTextExtent(const Tizen::Base::String& text, int length, Dimension& dim) const; + + /** + * @if OSPCOMPAT + * @page CompFontGetTextExtentPage Compatibility for the file path. + * @section CompFontGetTextExtentPageIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns exact height only if the font resource is designed to fit inside the emBox. @n + * + * @section CompFontGetTextExtentPageSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns exact height regardless of font design. @n + * + * @endif + */ + + /** + * Checks whether the font style of the current instance is bold. + * + * @since 2.0 + * + * @return @c true if the font style of the current instance is bold, @n + * else @c false + */ + bool IsBold(void) const; + + /** + * Checks whether the font style for the current instance is italics. + * + * @since 2.0 + * + * @return @c true if the font style for the current instance is italics, @n + * else @c false + */ + bool IsItalic(void) const; + + /** + * Checks whether the current instance has any style defined. + * + * @since 2.0 + * + * @return @c true if an extra style is not defined for the current instance, @n + * else @c false + */ + bool IsPlain(void) const; + + /** + * Checks whether the current instance has the strikeout style set. + * + * @since 2.0 + * + * @return @c true if the current instance has the strikeout style set, @n + * else @c false + */ + bool IsStrikeOut(void) const; + + /** + * Checks whether the current instance has the underline style set. + * + * @since 2.0 + * + * @return @c true if the current instance has the underline style set, @n + * else @c false + */ + bool IsUnderlined(void) const; + + /** + * Gets the font size of the current instance of %Font. + * + * @since 2.0 + * + * @return The font size, @n + * else @c -1 if the method fails + */ + int GetSize(void) const; + + /** + * Sets the strikeout style for the current instance of %Font. + * + * @since 2.0 + * + * @param[in] strikeOut Set to @c true to use the strikeout style for the current instance of %Font, @n + * else @c false + */ + void SetStrikeOut(bool strikeOut); + + /** + * Sets the underline style for the current instance of %Font. + * + * @since 2.0 + * + * @param[in] underline Set to @c true to use the underline style for the current instance of %Font, @n + * else @c false + */ + void SetUnderline(bool underline); + + /** + * Gets the system font list. + * + * @since 2.0 + * + * @return The list of system fonts @n + * The font list consists of Tizen::Base::String items. + * @remarks After using the system font list, you can call IList::RemoveAll(true) to clean up string items in the list. + */ + static Tizen::Base::Collection::IList* GetSystemFontListN(void); + + /** + * Gets the face name of the font file of the specific path. + * + * @since 2.0 + * + * @return The face name of the font file of the specific path + * @param[in] filePath The path of the font file + */ + static Tizen::Base::String GetFaceName(const Tizen::Base::String& filePath); + + /** + * Sets the character space. + * + * @since 2.0 + * + * @param[in] space A character space + */ + void SetCharSpace(int space); + + /** + * Gets the character space. + * + * @since 2.0 + * + * @return The character space of this font instance, @n + * else @c -1 if the method fails + */ + int GetCharSpace(void) const; + + /** + * Gets the face name. + * + * @since 2.0 + * + * @return The face name of this font instance + */ + Tizen::Base::String GetFaceName(void) const; + +private: + friend class _FontImpl; + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + /** + * @since 2.0 + */ + class _FontImpl* __pImpl; + + /* + * This is the copy constructor for the Font class. + * + * @remarks Do not use this constructor. + */ + Font(const Font& rhs); + Font& operator =(const Font& rhs); + +}; // Font + +}} // Tizen::Graphics + +#endif //_FGRP_FONT_H_ diff --git a/inc/FGrpFontCommon.h b/inc/FGrpFontCommon.h new file mode 100644 index 0000000..946d7dc --- /dev/null +++ b/inc/FGrpFontCommon.h @@ -0,0 +1,51 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpFontCommon.h + * @brief This is the header file for the enumerations of the %Font class. + * + * This header file contains the definitions of the enumerations of the Font class. + */ + +#ifndef _FGRP_FONT_COMMON_H_ +#define _FGRP_FONT_COMMON_H_ + +namespace Tizen { namespace Graphics +{ +/** +* @enum FontStyle +* +* Defines the style of the Font class instance. +* +* @since 2.0 +* +* @remarks Several different font styles can be combined using the "OR" operator. @n +* (For example, int style = FONT_STYLE_BOLD | FONT_STYLE_ITALIC). +*/ +enum FontStyle +{ + FONT_STYLE_PLAIN = 0x0001, /**< The plain font style */ + FONT_STYLE_BOLD = 0x0002, /**< The bold font style */ + FONT_STYLE_ITALIC = 0x0004, /** + +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +class IGlRenderer; + +/** + * @enum EglContextClientVersion + * + * Defines the Egl Context Client version of the player. + * + * @since 2.0 + * + */ +enum EglContextClientVersion +{ + EGL_CONTEXT_CLIENT_VERSION_1_X, /**< The version is 1.x */ + EGL_CONTEXT_CLIENT_VERSION_2_X /**< The version is 2.x */ +}; + +/** + * @enum EglAttributesPreset + * + * Defines the preset of EGL attributes and configurations. + * + * @since 2.0 + * + */ +enum EglAttributesPreset +{ + EGL_ATTRIBUTES_PRESET_DONT_CARE, /**< Preset Don't care */ + EGL_ATTRIBUTES_PRESET_RGB565, /**< Preset RGB565 */ + EGL_ATTRIBUTES_PRESET_ARGB8888 /**< Preset ARGB8888 */ +}; + +/** + * @class GlPlayer + * @brief This class provides a simple template for rendering 3D objects with OpenGL-ES APIs + * @since 2.0 + * @final This class is not intended for extension. + * + */ +class _OSP_EXPORT_ GlPlayer + : public Tizen::Base::Object +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + * + */ + GlPlayer(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(void). + * + * @since 2.0 + * + */ + virtual ~GlPlayer(void); + + /** + * Initializes this instance of %GlPlayer. + * + * @since 2.0 + * @return An error code + * @param[in] version EGL Context Client Version. + * @param[in] control Target control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_OPERATION The operation has failed, because of the duplicate call of Construct(). + * + * @remarks Currently, version must be 1(OpenGL-ES 1.x) or 2(OpenGL-ES 2.x) + * @remarks Currently, only Tizen::Ui::Controls::Frame and Tizen::Ui::Controls::Form are allowed as the target control, therefore, when the input Target control is not Form or Frame then E_INVALID_ARG exception is occurred. + * + */ + result Construct(EglContextClientVersion version, Tizen::Ui::Control* pControl); + + /** + * Start the %GlPlayer, and initialzie EGL status. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM Player cannot be started properly due to a severe system error. + * @exception E_INVALID_STATE The state of player is not suitable for start. For example, it is not allowable to start player when its state is pause. + * @exception E_OPENGL_ERROR There occurs an EGL error during performing EGL function. + * + * @remarks In the case that this returns E_OPENGL_ERROR exception, developers can use eglGetError() to query which EGL error is raised. + * + */ + result Start(void); + + /** + * Pause the %GlPlayer. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM Player cannot be paused properly due to a severe system error. + * @exception E_INVALID_OPERATION Fail to perform IGlRenderer::Pause function which is implemented by developers. + * @exception E_INVALID_STATE The state of player is not suitable for pause. For example, it is not allowable to pause player when it does not start after the initialization yet. + * + */ + result Pause(void); + + /** + * Resume the %GlPlayer. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM Player cannot be resumed properly due to a severe system error. + * @exception E_INVALID_OPERATION Fail to perform IGlRenderer::Resume function which is implemented by developers. + * @exception E_INVALID_STATE The state of player is not suitable for resume. For example, it is not allowable to resume player when its state is stop. + * + */ + result Resume(void); + + /** + * Stop the %GlPlayer, and reset the EGL status. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM Player cannot be stopped properly due to a severe system error. + * @exception E_INVALID_OPERATION Fail to perform IGlRenderer::Pause function which is implemented by developers. + * + * @remarks Before starting to reset the EGL status, this function calls IGlRenderer::Pause() to prevent unexpected behavior. + * + */ + result Stop(void); + + /** + * Redraw the scene. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_OPENGL_ERROR There occurs an EGL error during performing EGL function. + * @exception E_INVALID_STATE The state of player is invalid and fails to pause properly. + * + * @remarks In the case that this returns E_OPENGL_ERROR exception, developers can use eglGetError() to query which EGL error is raised. + * + */ + result Redraw(void); + + /** + * Set the FPS(frames per second) of the player. + * + * @since 2.0 + * @param[in] fps frames per second + * + * @remarks When you give negative integer for fps, then the %GlPlayer try to draw frames as fast as possible. + * + */ + void SetFps(int fps); + + /** + * Set the configuration list of EGL Attributes to initialize the EGL system. + * + * @since 2.0 + * @return An error code + * @param[in] eglConfigList a list of EGL attributes and their values. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * + * @remarks %GlPlayer initializes the EGL status with the given EGL attributes, which means that system does not guarantees to set EGL configurations with the given attributes but prefers them. + * @remarks The format of eglConfigList is the same with the attribute list as the second input parameter of eglChooseConfig function. To know about the detailed description, refer the reference page of eglChooseConfig: http://www.khronos.org/opengles/documentation/opengles1_0/html/eglChooseConfig.html + * + */ + result SetEglAttributeList(const EGLint* pEglConfigList); + + /** + * Set EGL configuration with the given preset. + * + * @since 2.0 + * @return An error code + * @param[in] preset Preset for attributes. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * + * @remarks %GlPlayer initializes the EGL status with the given EGL attributes, which means that system does not guarantees to set EGL configurations with the given attributes but prefers them. + * + */ + result SetEglAttributePreset(EglAttributesPreset preset); + + /** + * Set EGL configuration for the given Attribute with the given value. + * + * @since 2.0 + * @return An error code + * @param[in] key EGL attribute + * @param[in] value Value for the attribute + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * + * @remarks %GlPlayer initializes the EGL status with the given EGL attributes, which means that system does not guarantees to set EGL configurations with the given attributes but prefers them. + * + */ + result SetEglAttribute(EGLint key, EGLint value); + + /** + * Set the Renderer which implements %IGlRenderer interface. + * + * @since 2.0 + * @return An error code + * @param[in] renderer %IGlRenderer defines how to render the scene. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION Fail to perform IGlRenderer::InitializeGl function which is implemented by developers. + * @see %IGlRenderer + * + * @remarks If %GlPlayer already has a renderer, then the previous renderer is replaced by the new one. + * @remarks If input parameter is null, then the current renderer of %GlPlayer is detached and %GlPlayer does nothing. + * @remarks When the %IGlRenderer is replaced with the input, the GL status have to be initialized for the input %IGlRenderer. For such purpose, when the input %IGlRenderer is attached, the overrided IGlRenderer::InitializedGl() function is called. On the other hands, the previous %IGlRenderer of %GlPlayer is detached after calling the overrided %IGlRenderer::TerminateGL() function. + * + */ + result SetIGlRenderer(IGlRenderer* pRenderer); + +private: + /* + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.0 + */ + GlPlayer(const GlPlayer& rhs); + + /* + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.0 + */ + GlPlayer& operator =(const GlPlayer& rhs); + + friend class _GlPlayerImpl; + class _GlPlayerImpl* __pImpl; + +}; // GlPlayer + +}}} // Tizen::Graphics::Opengl + +#endif //_FGRP_GL_PLAYER_H_ diff --git a/inc/FGrpIGlRenderer.h b/inc/FGrpIGlRenderer.h new file mode 100644 index 0000000..8748f7e --- /dev/null +++ b/inc/FGrpIGlRenderer.h @@ -0,0 +1,158 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpIGlRenderer.h + * @brief This is the header file for the %IGlRenderer class. + * + * This header file contains the declarations of the %IGlRenderer class. + * + */ + +#ifndef _FGRP_GL_RENDERER_H_ +#define _FGRP_GL_RENDERER_H_ + +#include + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +/** + * @class IGlRenderer + * @brief This virtual class defines the interface for GlPlayer to draw 3D scene. + * @since 2.0 + * + */ +class _OSP_EXPORT_ IGlRenderer +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this. + * + * @since 2.0 + * + */ + virtual ~IGlRenderer(void) {} + + /** + * Initializes GL status and allocates necessary resources for the current Renderer such as shader, texture and so on. + * + * @since 2.0 + * @return Return true when this function successfully initialize the GL status and allocate resources, such as shader and textures. Otherwise, when this function meets some errors or exceptions, then return false. + * + */ + virtual bool InitializeGl(void) = 0; + + /** + * Terminate the Renderer to unload shader and release allocated resources. + * + * @since 2.0 + * @return Return true when this function successfully terminate the GL status and release all the resources, such as shader and textures. Otherwise, when this function meets some errors or exceptions, then return false. + * + */ + virtual bool TerminateGl(void) = 0; + + /** + * This function is called when GlPlayer draws a scene. + * Users overload this function and calls necessary operations for drawing a scene in this system. + * + * @since 2.0 + * @return Return true when this function successfully draws a scene with gl functions. Otherwise, when this function meets some errors or exceptions, then return false. + * + */ + virtual bool Draw(void) = 0; + + /** + * This function is called when GlPlayer is paused. + * Users overload this function and calls necessary operations for the pause of the system, including release resources. + * + * @since 2.0 + * @return Return true when this function successfully does intended operations for Pause state. Otherwise, when this function meets some errors or exceptions, then return false. + * + */ + virtual bool Pause(void) = 0; + + /** + * This function is called when GlPlayer is resumed. + * Users overload this function and calls necessary operations for the resume of the system, including allocation resources. + * + * @since 2.0 + * @return Return true when this function successfully does intended operations for Resume state. Otherwise, when this function meets some errors or exceptions, then return false. + * + */ + virtual bool Resume(void) = 0; + + /** + * Get the target control width. + * + * @since 2.0 + * + * @return Return the width of Target control. + * @remarks The control width is determined when you register %IGlRenderer to %GlPlayer with GlPlayer::SetIGlRenderer() function. Therefore, developers have to declare a integer variable for control width to implement this function. + * + */ + virtual int GetTargetControlWidth(void) = 0; + + /** + * Get the target control height. + * + * @since 2.0 + * + * @return Return the height of Target control. + * @remarks The control height is determined when you register %IGlRenderer to %GlPlayer with GlPlayer::SetIGlRenderer() function. Therefore, developers have to declare a integer variable for control height to implement this function. + * + */ + virtual int GetTargetControlHeight(void) = 0; + + /** + * Set the target control width. + * + * @since 2.0 + * + * @param[in] width Width of Target control. + * @remarks The control width is determined when you register %IGlRenderer to %GlPlayer with GlPlayer::SetIGlRenderer() function. Therefore, this function is used in GlPlayer::SetIGlRenderer function, and developers have to declare a integer variable for control width to implement this function. + * + */ + virtual void SetTargetControlWidth(int width) = 0; + + /** + * Get the target control height. + * + * @since 2.0 + * + * @param[in] height Height of Target control. + * @remarks The control height is determined when you register %IGlRenderer to %GlPlayer with GlPlayer::SetIGlRenderer() function. Therefore, this function is used in GlPlayer::SetIGlRenderer function, and developers have to declare a integer variable for control height to implement this function. + * + */ + virtual void SetTargetControlHeight(int height) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void IGlRenderer_Reserved1(void) {} + virtual void IGlRenderer_Reserved2(void) {} + virtual void IGlRenderer_Reserved3(void) {} + +}; // IGlRenderer + +}}} // Tizen::Graphics::Opengl + +#endif //_FGRP_GL_RENDERER_H_ diff --git a/inc/FGrpIVideoTextureUpdateListener.h b/inc/FGrpIVideoTextureUpdateListener.h new file mode 100644 index 0000000..fe55f0c --- /dev/null +++ b/inc/FGrpIVideoTextureUpdateListener.h @@ -0,0 +1,95 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpIVideoTextureUpdateListener.h + * @brief This is the header file for the %IVideoTextureUpdateListener class. + * + * This header file contains the declarations of the %IVideoTextureUpdateListener class. + * + */ + +#ifndef _FGRP_IVIDEO_TEXTURE_UPDATE_LISTENER_H_ +#define _FGRP_IVIDEO_TEXTURE_UPDATE_LISTENER_H_ + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +class VideoTexture; + +/** + * @class IVideoTextureUpdateListener + * @brief This virtual class defines the interface for VideoTexture to register a listener. + * @since 2.0 + * + */ +class _OSP_EXPORT_ IVideoTextureUpdateListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IVideoTextureUpdateListener(void) {} + + /** + * Called when a video frame on the texture is ready. + * + * @since 2.0 + * + * @param[in] pVideoTexture The VideoTexture class. + */ + virtual void OnTextureUpdated(VideoTexture* pVideoTexture) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IVideoTextureUpdateListener_Reserved1(void) {} + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IVideoTextureUpdateListener_Reserved2(void) {} + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IVideoTextureUpdateListener_Reserved3(void) {} +}; // IVideoTextureUpdateListener + +}}} // Tizen::Graphics + +#endif //_FGRP_IVIDEO_TEXTURE_UPDATE_LISTENER_H_ \ No newline at end of file diff --git a/inc/FGrpPixelFormat.h b/inc/FGrpPixelFormat.h new file mode 100644 index 0000000..a6db766 --- /dev/null +++ b/inc/FGrpPixelFormat.h @@ -0,0 +1,53 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpPixelFormat.h + * @brief This is the header file for the PixelFormat enumeration that defines the pixel information. + * + * This header file contains the definitions of the PixelFormat enumeration that defines the pixel information. + */ + +#ifndef _FGRP_PIXEL_FORMAT_H_ +#define _FGRP_PIXEL_FORMAT_H_ + +namespace Tizen { namespace Graphics +{ +/** + * @enum PixelFormat + * + * Defines the bits per pixel and the bits per component. + * + * @since 2.0 + */ +enum PixelFormat +{ + PIXEL_FORMAT_RGB565 = 1, /**< The RGB565 pixel format */ + PIXEL_FORMAT_ARGB8888, /** + +namespace Tizen { namespace Graphics +{ +/** + * @class Point + * @brief This class encapsulates a point in a two-dimensional coordinate system. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %Point class represents a location in a two-dimensional coordinate space specified with an integer precision. + * + * For more information on the class features, see Shapes. + */ +class _OSP_EXPORT_ Point + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. @n + * This initializes an instance of %Point with the values (0, 0). + * + * @since 2.0 + */ + Point(void); + + /** + * This is the copy constructor for the %Point class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %Point + */ + Point(const Point& rhs); + + /** + * Initializes an instance of %Point with the specified location. + * + * @since 2.0 + * + * @param[in] x The x-coordinate + * @param[in] y The y-coordinate + */ + Point(int x, int y); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Point(void); + + /** + * Assigns the value of the specified instance to the current instance of %Point. + * + * @since 2.0 + * + * @param[in] rhs An instance of %Point + */ + Point& operator =(const Point& rhs); + + /** + * Checks whether the current instance and the specified instance of %Point are equal. + * + * @since 2.0 + * + * @return @c true if the two instances of %Point are at the same location, @n + * else @c false + * @param[in] rhs An instance of %Point + */ + bool operator ==(const Point& rhs) const; + + /** + * Checks whether the current instance and the specified instance of %Point are not equal. + * + * @since 2.0 + * + * @return @c true if the two instances of %Point are at different locations, @n + * else @c false + * @param[in] rhs An instance of %Point + */ + bool operator !=(const Point& rhs) const; + + /** + * Adds the value of the specified instance of %Point and the current instance. + * + * @since 2.0 + * + * @return A new instance of %Point containing the resulting value of the operation + * @param[in] rhs An instance of %Point + */ + Point operator +(const Point& rhs) const; + + /** + * Subtracts the value of the specified instance of %Point and the current instance. + * + * @since 2.0 + * + * @return A new instance of %Point containing the resulting value of the operation + * @param[in] rhs An instance of %Point + */ + Point operator -(const Point& rhs) const; + + /** + * Adds the value of the specified instance of %Point to the current instance. + * + * @since 2.0 + * + * @param[in] point An instance of %Point + */ + Point& operator +=(const Point& point); + + /** + * Subtracts the value of the specified instance of %Point from the current instance. + * + * @since 2.0 + * + * @param[in] point An instance of %Point + */ + Point& operator -=(const Point& point); + + /** + * Checks whether the value of the specified instance of %Point equals the value of the current instance. + * + * @since 2.0 + * + * @return @c true if the value of the specified instance equals the value of the current instance, @n + * else @c false + * @param[in] rhs An instance of %Point + * @remarks The %Point class has a semantic value, which means that the + * Equals() method checks whether the two instances have the same + * location. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks Two equal instances must return the same hash value. For better performance, + * the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + /** + * Sets the x and y coordinates for the current instance of %Point. + * + * @since 2.0 + * + * @param[in] x The new x-coordinate + * @param[in] y The new y-coordinate + */ + void SetPosition(int x, int y); + + /** + * Sets the current instance of %Point. + * + * @since 2.0 + * + * @param[in] point An instance of %Point + */ + void SetPosition(const Point& point); + + /** + * Translates this %Point to the indicated distance. + * + * @since 2.0 + * + * @param[in] deltaX The distance to move this point along the x-axis + * @param[in] deltaY The distance to move this point along the y-axis + */ + void Translate(int deltaX, int deltaY); + +public: + /** + * The x-coordinate of the point. + * + * @since 2.0 + */ + int x; + + /** + * The y-coordinate of the point. + * + * @since 2.0 + */ + int y; + +private: + friend class _PointImpl; + + // + // This variable is for internal use only. + // Using this variable can cause behavioral, security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + class _PointImpl * __pImpl; + +}; // Point + +}} // Tizen::Graphics + +#endif // _FGRP_POINT_H_ diff --git a/inc/FGrpRectangle.h b/inc/FGrpRectangle.h new file mode 100644 index 0000000..c166650 --- /dev/null +++ b/inc/FGrpRectangle.h @@ -0,0 +1,347 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpRectangle.h + * @brief This is the header file for the %Rectangle class. + * + * This header file contains the declarations of the %Rectangle class. + */ + +#ifndef _FGRP_RECTANGLE_H_ +#define _FGRP_RECTANGLE_H_ + +#include + +namespace Tizen { namespace Graphics +{ +class Point; +class Dimension; + +/** + * @class Rectangle + * @brief This class abstracts a rectangular region. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %Rectangle class represents a rectangular region in a coordinate space, which is specified by the rectangle + * object's top-left point (x, y) in the coordinate space, along with its width and height. + * + * For more information on the class features, see Shapes. + */ +class _OSP_EXPORT_ Rectangle + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. @n + * It initializes an instance of %Rectangle with all its attributes set to @c 0. + * + * @since 2.0 + * + * @remarks The attribute value is @c 0 when initialized. + */ + Rectangle(void); + + /** + * This is the copy constructor for the %Rectangle class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %Rectangle + */ + Rectangle(const Rectangle& rhs); + + /** + * Initializes an instance of %Rectangle with the specified location and dimension. + * + * @since 2.0 + * + * @param[in] x The x-coordinate of the top-left corner of the rectangle + * @param[in] y The y-coordinate of the top-left corner of the rectangle + * @param[in] width The width of the rectangle + * @param[in] height The height of the rectangle + * + */ + Rectangle(int x, int y, int width, int height); + + /** + * Initializes an instance of %Rectangle at the location specified by @c point and + * with dimension specified by @c dim. + * + * @since 2.0 + * + * @param[in] point The location of the top-left corner of the rectangle + * @param[in] dim The width and height of the rectangle + */ + Rectangle(const Point& point, const Dimension& dim); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Rectangle(void); + + /** + * Assigns the value of the specified instance to the current instance of %Rectangle. + * + * @since 2.0 + * + * @param[in] rhs An instance of %Rectangle + */ + Rectangle& operator =(const Rectangle& rhs); + + /** + * Checks whether the location and dimension of the current instance of %Rectangle match those of the + * specified instance of %Rectangle. + * + * @since 2.0 + * + * @return @c true if the location and dimension of the current instance match those of the specified instance, @n + * else @c false + * @param[in] rhs An instance of %Rectangle + */ + bool operator ==(const Rectangle& rhs) const; + + /** + * Checks whether the location and dimension of the current instance of %Rectangle do not match those of the + * specified instance of %Rectangle. + * + * @since 2.0 + * + * @return @c true if the location and dimension of the current instance do not match those of the specified instance, @n + * else @c false + * @param[in] rhs An instance of %Rectangle + */ + bool operator !=(const Rectangle& rhs) const; + + /** + * Checks whether the specified point lies inside the current instance of %Rectangle. + * + * @since 2.0 + * + * @return @c true if the location represented by @c point lies inside the current instance of %Rectangle, @n + * else @c false + * @param[in] point An instance of %Point + */ + bool Contains(const Point& point) const; + + /** + * Checks whether the value of the current instance of %Rectangle equals the value of the specified instance of + * %Rectangle. + * + * @since 2.0 + * + * @return @c true if the value of the current instance of %Rectangle equals the value of the specified instance of %Rectangle, @n + * else @c false + * @param[in] rhs An instance of %Rectangle + * @remarks The %Rectangle class has a semantic value, which means that the Equals() method checks whether the + * two instances have the same location and size. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * Gets the intersection of the current instance and the specified instance of %Rectangle. @n + * If the two instances of %Rectangle do not intersect, empty instance is returned. + * + * @since 2.0 + * + * @param[in] rect An instance of %Rectangle + */ + Rectangle GetIntersection(const Rectangle& rect) const; + + /** + * Checks whether the current instance of %Rectangle intersects with the specified instance of %Rectangle. + * + * @since 2.0 + * + * @return @c true if the current instance of %Rectangle intersects with the specified instance of %Rectangle, @n + * else @c false + * @param[in] rect An instance of %Rectangle + * + */ + bool IsIntersected(const Rectangle& rect) const; + + /** + * Gets the union of the current instance and the specified instance of %Rectangle. + * + * @since 2.0 + * + * @return An instance of %Rectangle containing the union of the two rectangles + * @param[in] rect An instance of %Rectangle + */ + Rectangle GetUnion(const Rectangle& rect) const; + + /** + * Gets the coordinates of the point at the bottom-right corner of the rectangle. + * + * @since 2.0 + * + * @return The coordinates of the point at the bottom-right corner of the rectangle + */ + Point GetBottomRight(void) const; + + /** + * Gets the coordinates of the point at the top-left corner of the rectangle. + * + * @since 2.0 + * + * @return The coordinates of the point at the top-left corner of the rectangle + */ + Point GetTopLeft(void) const; + + /** + * Checks whether this %Rectangle is empty. @n + * A %Rectangle is empty if its width or its height is less than or equal to @c 0. + * + * @since 2.0 + * + * @return @c true if this rectangle is empty, @n + * else @c false + */ + bool IsEmpty(void) const; + + /** + * Sets the size of this %Rectangle to match the specified Dimension. + * + * @since 2.0 + * + * @param[in] dim The new size for the Dimension + */ + void SetSize(const Dimension& dim); + + /** + * Sets the size of this %Rectangle to match the specified dimension. + * + * @since 2.0 + * + * @param[in] width The new width + * @param[in] height The new height + */ + void SetSize(int width, int height); + + /** + * Sets the position of this %Rectangle to the specified point. + * + * @since 2.0 + * + * @param[in] point The new position + */ + void SetPosition(const Point& point); + + /** + * Sets the location of the current instance of %Rectangle with the specified values of the + * x and y coordinates of the top-left corner point. + * + * @since 2.0 + * + * @param[in] x The new x-coordinate + * @param[in] y The new y-coordinate + */ + void SetPosition(int x, int y); + + /** + * Sets the location and the dimensions of the current instance of %Rectangle with the specified x and y + * coordinates of the top-left corner point and the specified dimensions. + * + * @since 2.0 + * + * @param[in] x The new x coordinate + * @param[in] y The new y coordinate + * @param[in] width The new width + * @param[in] height The new height + */ + void SetBounds(int x, int y, int width, int height); + + /** + * Sets the location and the dimensions of the current instance of %Rectangle with the specified location and + * dimension. + * + * @since 2.0 + * + * @param[in] point An instance of Point + * @param[in] dim An instance of Dimension + */ + void SetBounds(const Point& point, const Dimension& dim); + + /** + * Translates this %Rectangle to the new point by the specified distance along the x-axis and y-axis. + * + * @since 2.0 + * + * @param[in] deltaX The distance to move this %Rectangle along the x-axis + * @param[in] deltaY The distance to move this %Rectangle along the y-axis + */ + void Translate(int deltaX, int deltaY); + +public: + /** + * The x-coordinate of the top-left corner of the rectangle. + * + * @since 2.0 + */ + int x; + + /** + * The y-coordinate of the top-left corner of the rectangle. + * + * @since 2.0 + */ + int y; + + /** + * The width of this rectangle. + * + * @since 2.0 + */ + int width; + + /** + * The height of this rectangle. + * + * @since 2.0 + */ + int height; + +private: + friend class _RectangleImpl; + + // + // This variable is for internal use only. + // Using this variable can cause behavioral, security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + class _RectangleImpl * __pImpl; + +}; // Rectangle + +}} // Tizen::Graphics + +#endif // _FGRP_RECTANGLE_H_ diff --git a/inc/FGrpTextElement.h b/inc/FGrpTextElement.h new file mode 100644 index 0000000..f2dfa28 --- /dev/null +++ b/inc/FGrpTextElement.h @@ -0,0 +1,337 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpTextElement.h + * @brief This is the header file for the %TextElement class. + * + * This header file contains the declarations of the %TextElement class. + */ + +#ifndef _FGRP_TEXT_ELEMENT_H_ +#define _FGRP_TEXT_ELEMENT_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Graphics +{ +/** + * @class TextElement + * @brief This class provides methods for the text elements. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %TextElement class encapsulates the characteristics of a text, such as the constant string and font style. + * A text element draws the text on to a canvas. + * + * For more information on the attributes of %TextElement, see EnrichedText. + * + */ +class _OSP_EXPORT_ TextElement + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + * + * @remarks After creating an instance of this class, one of the + * Construct() methods must be called explicitly to initialize this instance. + */ + TextElement(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~TextElement(void); + + /** + * Initializes the current instance of %TextElement with the specified text. @n + * If the text is not specified, the default system font is set. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text string + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result Construct(const Tizen::Base::String& text); + + /** + * Initializes the current instance of %TextElement with the specified text. @n + * The canvas is used for initializing the font's color attributes, such as the foreground color and the background color. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text string + * @param[in] canvas The canvas to initialize the text element @n + * It sets the foreground and background colors of the text element. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Base::String& text, const Tizen::Graphics::Canvas& canvas); + + /** + * Initializes the current instance of %TextElement. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_SYSTEM An unknown operating system error has occurred. + * @remarks To set the text, use the SetText() method. + * @see SetText() + */ + result Construct(void); + + /** + * Initializes the current instance of %TextElement to represent a linked text with the specified link information. @n + * If the link information is not specified, the default system font is set. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The linked text string + * @param[in] linkType The link type + * @param[in] link The string that contains the actual link + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM An unknown operating system error has occurred. + * @remarks If the specified @c text is an empty string or + * @c linkType is LINK_TYPE_NONE, the method returns E_INVALID_ARG. + * @see Tizen::Base::Utility::LinkInfo + */ + result Construct(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link); + + /** + * Initializes the current instance of %TextElement with the specified text and autolink mask. @n + * If the text and autolink mask are not specified, the default system font is set. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text string + * @param[in] autoLink The autolink mask @n + * Multiple link types can be combined using the bitwise OR operator (Tizen::Base::Utility::LinkType). @n + * For more information, see AutoLink Detection. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_SYSTEM An unknown operating system error has occurred. + * @remarks If @c text contains more than one detectable link, the first link is converted + * to a linked text and the rest of the links are ignored. + * @see Tizen::Base::Utility::LinkType + */ + result Construct(const Tizen::Base::String& text, unsigned long autoLink); + + /** + * Initializes the current instance of %TextElement to represent a linked text with the specified link information. @n + * If the link information is not specified, the default system font is set. + * + * @since 2.0. + * + * @return An error code + * @param[in] text The linked text string + * @param[in] linkType The link type + * @param[in] link The string that contains the actual link + * @param[in] canvas The canvas to initialize the text element @n + * It sets the foreground and background colors of the text element. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM An unknown operating system error has occurred. + * @remarks If the specified @c text is an empty string or + * @c linkType is LINK_TYPE_NONE, the method returns E_INVALID_ARG. + * @see Tizen::Base::Utility::LinkType + */ + result Construct(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link, const Tizen::Graphics::Canvas& canvas); + + /** + * Initializes the current instance of %TextElement with the specified text, autolink mask, and graphics canvas. @n + * If the parameters are not specified, the default system font is set. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text string + * @param[in] autoLink The autolink mask @n + * Multiple link types can be combined using the bitwise OR operator (Tizen::Base::Utility::LinkType). @n + * For more information, see AutoLink Detection. + * @param[in] canvas The canvas to initialize the text element @n + * It sets the foreground and background colors of the text element. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_SYSTEM An unknown operating system error has occurred. + * @remarks If @c text contains more than one detectable link, the first link is converted + * to a linked text and rest of the links are ignored. + * @see Tizen::Base::Utility::LinkType + */ + result Construct(const Tizen::Base::String& text, unsigned long autoLink, const Tizen::Graphics::Canvas& canvas); + + /** + * Gets the string that contains the actual link. + * + * @since 2.0 + * + * @return The string that contains the actual link + * @remarks If the text element contains no linked text, the method returns an empty string. + */ + Tizen::Base::String GetLink(void) const; + + /** + * Gets the type of the link of the text element. + * + * @since 2.0 + * + * @return The string that contains the actual link + * @remarks If the text element contains no linked text, the method returns LINK_TYPE_NONE. @n + * The link type of the first auto-detected link is returned. + */ + Tizen::Base::Utility::LinkType GetLinkType(void) const; + + /** + * Sets the text of %TextElement with the specified string. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The string to set + * @exception E_SUCCESS The method is successful. + */ + result SetText(const Tizen::Base::String& text); + + /** + * Sets the font of %TextElement. + * + * @since 2.0 + * + * @return An error code + * @param[in] font The font to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result SetFont(const Tizen::Graphics::Font& font); + + /** + * Sets the text color of %TextElement. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color to set + * @exception E_SUCCESS The method is successful. + */ + result SetTextColor(const Tizen::Graphics::Color& color); + + /** + * Sets the background color of %TextElement. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color to set + * @exception E_SUCCESS The method is successful. + */ + result SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * Sets the outline color of %TextElement. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color to set + * @exception E_SUCCESS The method is successful. + */ + result SetOutlineColor(const Tizen::Graphics::Color& color); + + /** + * Gets the text of %TextElement. + * + * @since 2.0 + * + * @return A string containing the text + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets the text color of %TextElement. + * + * @since 2.0 + * + * @return The foreground color + */ + Tizen::Graphics::Color GetTextColor(void) const; + + /** + * Gets the background color of %TextElement. + * + * @since 2.0 + * + * @return The background color + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + + /** + * Gets the outline color of %TextElement. + * + * @since 2.0 + * + * @return The outline color + */ + Tizen::Graphics::Color GetOutlineColor(void) const; + +private: + friend class _TextElementImpl; + + // + // This value is for internal use only. Using this value can cause behavioral, security-related, + // and consistency-related issues in the application. + // + class _TextElementImpl * __pImpl; + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + TextElement(const TextElement& font); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + TextElement& operator =(const TextElement& rhs); + +}; // TextElement + +}} // Tizen::Graphics + +#endif // _FGRP_TEXT_ELEMENT_H_ diff --git a/inc/FGrpVideoTexture.h b/inc/FGrpVideoTexture.h new file mode 100644 index 0000000..5d7f867 --- /dev/null +++ b/inc/FGrpVideoTexture.h @@ -0,0 +1,139 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpVideoTexture.h + * @brief This is the header file for the %VideoTexture class. + * + * This header file contains the declarations of the %VideoTexture class. + * + */ + +#ifndef _FGRP_VIDEO_TEXTURE_H_ +#define _FGRP_VIDEO_TEXTURE_H_ + +#include + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +class IVideoTextureUpdateListener; + +/** + * @class VideoTexture + * @brief This class provides a method to bind a video frame to OpenGL-ES Texture. + * With this feature, you can easily draw a video frame on OpenGL-ES Textures with consistency. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %VideoTexture class provides a texture by which you can draw a video frame on OpenGL-ES texture. + * + */ +class _OSP_EXPORT_ VideoTexture + : public Tizen::Base::Object +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method be called right after calling this constructor. + * + * @since 2.0 + * + */ + VideoTexture(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~VideoTexture(void); + + /** + * Initializes this instance of %VideoTexture with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] textureId Texture ID which points to the texture associated with the video frame. The testure ID must be generated from glGenTextures(). + * @param[in] width The width of the input texture. The width must be greater than @c 32, and smaller or equal than GL_MAX_TEXTURE_SIZE. + * @param[in] height The height of the input texture. The height must be greater than @c 32, and smaller or equal than GL_MAX_TEXTURE_SIZE + * @exception E_SUCCESS Construction is successfully done. + * @exception E_OUT_OF_RANGE The width or height is bigger than GL_MAX_TEXTURE_SIZE You can get max size of current device to call glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize). + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_UNSUPPORTED_OPERATION The target device does not support full features for %VideoTexture. + * @exception E_INVALID_STATE Getting egl information failed. It is necessary to bind egl context by using eglMakeCurrent funtion. + * @remarks There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer here. + */ + result Construct(int textureId, int width, int height); + + /** + * Binds the most recent frame to the texture. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS Binding is successfully done. + * @exception E_INVALID_STATE Any video frames are not ready in the texture. If IVideoTextureUpdateListener is already registered, please check whether the functions have been called. + */ + result BindTexture(void); + + /** + * Adds a listener invoked when a video frame is ready. + * + * @since 2.0 + * + * @param[in] listener The listener invoked. + * @see RemoveVideoTextureUpdateListener() + */ + void AddVideoTextureUpdateListener(IVideoTextureUpdateListener& listener); + + /** + * Removes the specified listener. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed. + @see AddVideoTextureUpdateListener() + */ + void RemoveVideoTextureUpdateListener(IVideoTextureUpdateListener& listener); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @param[in] rhs The source from which this instance is copied + // + VideoTexture(const VideoTexture& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @param[in] rhs An instance of %VideoTexture + // + VideoTexture& operator =(const VideoTexture& rhs); + +private: + friend class _VideoTextureImpl; + + class _VideoTextureImpl* __pImpl; +}; // VideoTexture + +}}} // Tizen::Graphics + +#endif //_FGRP_VIDEO_TEXTURE_H_ diff --git a/inc/FUi.h b/inc/FUi.h new file mode 100644 index 0000000..5667f90 --- /dev/null +++ b/inc/FUi.h @@ -0,0 +1,143 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi.h + * @brief This is the header file for the %Ui namespace. + * + * This header file contains the declarations and descriptions of the %Ui namespace. + */ + +#ifndef _FUI_H_ +#define _FUI_H_ + +// Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen +{ +/** + * @namespace Tizen::Ui + * @brief This namespace contains the classes and interfaces that act as the %UI foundation for the applications. + * @since 2.0 + * + * @remarks @b Header @b %file: @b \#include @b @n + * @b Library : @b osp-uifw + * + * The %Ui namespace is used to construct graphical user interfaces (UI). It contains classes and interfaces for handling + * UI-related events. In addition, it has 4 sub-namespaces: Tizen::Ui::Controls, whose classes handle the display and interaction with UI elements, Tizen::Ui::Scenes, whose classes handle scene transition using the scene management functionalities, + * Tizen::Ui::Animations, whose classes handle animation-related functionalities, and Tizen::Ui::Effects, whose classes + * handle the effect-related functionalities. + * + * For more information on the %Ui namespace features, see UI Guide. + * + * The following diagram illustrates the relationships between the classes belonging to the %Ui namespace. + * + * @image html ui_namespace_classdiagram.png + * + */ +namespace Ui +{ + +}; // Tizen::Ui +}; // Tizen +#endif // _FUI_H_ diff --git a/inc/FUiAccessibilityContainer.h b/inc/FUiAccessibilityContainer.h new file mode 100644 index 0000000..6c013af --- /dev/null +++ b/inc/FUiAccessibilityContainer.h @@ -0,0 +1,229 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAccessibilityContainer.h + * @brief This is the header file for the AccessibilityContainer class. + * + * This header file contains the declarations of the AccessibilityContainer class. + */ + +#ifndef _FUI_ACCESSIBILITY_CONTAINER_H_ +#define _FUI_ACCESSIBILITY_CONTAINER_H_ + +#include +#include +#include + +namespace Tizen { namespace Base +{ +class String; +}} // Tizen::Base + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +}}} //Tizen::Base::Collection + + +namespace Tizen { namespace Ui +{ + +class Control; +class AccessibilityElement; +class IAccessibilityListener; +class _AccessibilityContainerImpl; + +/** +* @class AccessibilityContainer +* @brief This class represents a container for accessibility element. +* @since 2.0 +* +* +* @final This class is not intended for extension. +* This class represents a container for accessibility element. + * The following example demonstrates how to use the %AccessibilityContainer class. +.* + * @code +// Sample code for AccessibilitySample.h +#include +#include + +class AccessibilitySample + : public Tizen::Ui::Controls::Form +{ +public: + AccessibilitySample(void); + virtual ~AccessibilitySample(void); + + result Initialize(void); + + virtual result OnInitializing(void); + + +private: + static const int ID_FOOTER_ITEM1 = 101; + static const int ID_FOOTER_ITEM2 = 102; + + Tizen::Graphics::Bitmap *__pTizenBitmap; +}; + + * @endcode + * + * @final This class is not intended for extension. + * This class represents a container for accessibility element. + */ +class _OSP_EXPORT_ AccessibilityContainer + : public Tizen::Base::Object +{ +public: + /** + * Gets the owner of the accessibility container + * + * @since 2.0 + * @return The control which owns this %AccessibilityContainer + * @see Control::GetAccessibilityContainer() + */ + const Control* GetOwner(void) const; + + /** + * Gets the owner of the accessibility container + * + * @since 2.0 + * @return The control which owns this %AccessibilityContainer + * @see Control::GetAccessibilityContainer() + */ + Control* GetOwner(void); + + /** + * Adds the IAccessibilityListener instance to the %AccessibilityContainer. @n + * The added listener gets notified when the accessibility status is changed. + * + * @since 2.0 + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The instance of IAccessibilityListener is already registered. + * @see RemoveAccessibilityListener() + */ + result AddAccessibilityListener(IAccessibilityListener& listener); + + /** + * Removes the IAccessibilityListener listener instance. @n + * The removed listener is not notified even when the accessibility status is changed. + * + * + * @since 2.0 + * @return An error code + * @param[in] listener The listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The instance of listener is not found. + * @see AddAccessibilityListener() + */ + result RemoveAccessibilityListener(IAccessibilityListener& listener); + + /** + * Adds the accessibility element to the %AccessibilityContainer. + * + * @since 2.0 + * @return An error code + * @param[in] element The instance of AccessibilityElement + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The instance of AccessibilityElement is already registered. + * @see RemoveElement(), RemoveAllElements() + * + */ + result AddElement(AccessibilityElement& element); + + /** + * Removes the accessibility element in the %AccessibilityContainer. + * + * @since 2.0 + * + * @return An error code + * + * @param[in] element The instance of AccessibilityElement + * + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The instance of AccessibilityElement is already registered. + * @see AddElement(), InsertElement() + * + */ + result RemoveElement(AccessibilityElement& element); + + /** + * Removes all of the accessibility elements in the %AccessibilityContainer. + * + * @since 2.0 + * + * @see AddElement, InsertElement + * + */ + void RemoveAllElements(void); + + /** + * Gets the instance of accessibility element which is the child of the %AccessibilityContainer by the name. + * + * @since 2.0 + * + * @return The instance of child element, if there exists an element which has the given name @n + * else @c null + * + * @param[in] name The name of AccessibilityElement + * + */ + AccessibilityElement* GetElement(const Tizen::Base::String& name) const; + + /** + * Gets the list of accessibility elements that are the child of the %AccessibilityContainer. + * + * @since 2.0 + * + * @return The list of child element, if there exists some elements in the container. @n + * else @c null. + * + */ + Tizen::Base::Collection::IList* GetElementsN(void) const; + +private: + // + // This default constructor is intentionally declared as private so that only the platform can create an instance + // + AccessibilityContainer(void); + + // + // This destructor is intentionally declared as private so that only the platform can delete an instance. + // + virtual ~AccessibilityContainer(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + AccessibilityContainer(const AccessibilityContainer& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + AccessibilityContainer& operator =(const AccessibilityContainer& rhs); + +private: + _AccessibilityContainerImpl* __pAccessibilityContainerImpl; + friend class _AccessibilityContainerImpl; +}; // AccessibilityContainer + +}} // Tizen::Ui +#endif //_FUI_ACCESSIBILITY_CONTAINER_H_ diff --git a/inc/FUiAccessibilityElement.h b/inc/FUiAccessibilityElement.h new file mode 100644 index 0000000..824b66a --- /dev/null +++ b/inc/FUiAccessibilityElement.h @@ -0,0 +1,192 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAccessibilityElement.h + * @brief This is the header file for the AccessibilityElement class. + * + * This header file contains the declarations of the AccessibilityElement class. + * + */ + +#ifndef _FUI_ACCESSIBILITY_ELEMENT_H_ +#define _FUI_ACCESSIBILITY_ELEMENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Base +{ + class String; +}} //Tizen::Base + +namespace Tizen { namespace Graphics +{ + class Rectangle; +}} //Tizen::Graphics + +namespace Tizen { namespace Ui +{ +class _AccessibilityElementImpl; + +/** + * @class AccessibilityElement + * @brief This class represents an accessibility element. + * @since 2.0 + * + * @final This class is not intended for extension. + * This class represents an accessibility element. + */ +class _OSP_EXPORT_ AccessibilityElement + : public Tizen::Base::Object +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + AccessibilityElement(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~AccessibilityElement(void); + + /** + * Initializes the instance of %AccessibilityElement with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] bounds The bounds of the accessibility element + * @param[in] name The name of the accessibility element + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG Either the length of name parameter is @c 0, or the bounds are smaller than @c 0. + */ + result Construct(const Tizen::Graphics::Rectangle& bounds, const Tizen::Base::String& name); + + /** + * Gets the name of the element. + * + * @since 2.0 + * @return The name of the element + */ + Tizen::Base::String GetName(void) const; + + /** + * Sets the bounds to the element. + * + * @since 2.0 + * @param[in] bounds The bounds of the accessibility element. + */ + void SetBounds(const Tizen::Graphics::Rectangle& bounds); + + /** + * Gets the bounds of the element. + * + * @since 2.0 + * @return The bounds of the element + */ + Tizen::Graphics::Rectangle GetBounds(void) const; + + /** + * Sets the label to the element. + * + * @since 2.0 + * @param[in] label The label of the accessibility element. + */ + void SetLabel(const Tizen::Base::String& label); + + /** + * Gets the label of the element. + * + * @since 2.0 + * @return The label of the element + */ + Tizen::Base::String GetLabel(void) const; + + /** + * Sets the hint to the element. + * + * @since 2.0 + * @param[in] hint The hint of the accessibility element. + */ + void SetHint(const Tizen::Base::String& hint); + + /** + * Gets the hint of the element. + * + * @since 2.0 + * @return The hint of the element + */ + Tizen::Base::String GetHint(void) const; + + /** + * Sets the trait to the element. + * + * @since 2.0 + * @param[in] trait The trait of the accessibility element. + */ + void SetTrait(const Tizen::Base::String& trait); + + + /** + * Gets the trait of the element. + * + * @since 2.0 + * @return The trait of the element + */ + Tizen::Base::String GetTrait(void) const; + + /** + * Sets the value to the element. + * + * @since 2.0 + * @param[in] value The value of the accessibility element. + */ + void SetValue(const Tizen::Base::String& value); + + /** + * Gets the value of the element. + * + * @since 2.0 + * @return The value of the element + */ + Tizen::Base::String GetValue(void) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + AccessibilityElement(const AccessibilityElement& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + AccessibilityElement& operator =(const AccessibilityElement& rhs); + +private: + friend class _AccessibilityElementImpl; + _AccessibilityElementImpl* __pAccessibilityElementImpl; +}; // AccessibilityElement + +}} // Tizen::Ui +#endif //_FUI_ACCESSIBILITY_ELEMENT_H_ diff --git a/inc/FUiAccessibilityTypes.h b/inc/FUiAccessibilityTypes.h new file mode 100644 index 0000000..5972e35 --- /dev/null +++ b/inc/FUiAccessibilityTypes.h @@ -0,0 +1,48 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAccessibilityTypes.h + * @brief This is the header file for declarations of the accessibility enumeration . + * + * This header file contains the declarations of the accessibility enumeration . + * + */ + +#ifndef _FUI_ACCESSIBILITY_TYPES_H_ +#define _FUI_ACCESSIBILITY_TYPES_H_ + +namespace Tizen { namespace Ui +{ +/** + * @enum AccessibilityScreenReaderStatus + * + * Defines the status of the accessibility screen reader. + * + * @since 2.0 + */ +enum AccessibilityScreenReaderStatus +{ + ACCESSIBILITY_SCREEN_READER_STATUS__NONE, /**< initial value.*/ + ACCESSIBILITY_SCREEN_READER_STATUS_ERROR, /** +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class AnimationBase + * @brief This class is the base class for all the Animation classes. @n + * It is an abstract base class. + * + * @since 2.0 + * + * The %AnimationBase class defines the basic animation properties, such as the interpolator to be used, the duration of the animation in milliseconds, the delay before the animation is started in milliseconds, and the repeat count. + * + */ +class _OSP_EXPORT_ AnimationBase + : public Tizen::Base::Object +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~AnimationBase(void); + + + /** + * Sets the duration of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] milliseconds The duration of the animation in milliseconds + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative. + */ + result SetDuration(long milliseconds); + + + /** + * Sets the offset value of the animation. @n + * Additionally, the %SetOffset() method alters the start value and duration for which an animation is played. + * + * @since 2.0 + * + * @return An error code + * @param[in] milliseconds The offset of the animation in milliseconds + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative or greater than the duration of the animation. + * @remarks If the start value of the animation is @c 0.0, the end value is @c 1.0, the duration is @c 100 ms and the offset value is @c 20 ms, + * the actual animation starts at @c 0th ms and plays for @c 80 ms with a start value of @c 0.2. @n + * If @c autoReverseset is set to @c true, the Backward animation plays for 100ms, from @c 1.0 to @c 0.0. + */ + result SetOffset(long milliseconds); + + + /** + * Sets the delay for the animation. @n + * The animation starts after the duration of delay has passed. + * + * @since 2.0 + * + * @return An error code + * @param[in] milliseconds The delay for the animation to start in milliseconds + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative. + * @remarks This method does not alter the start, end, and duration values of the animation. + */ + result SetDelay(long milliseconds); + + + /** + * Sets the repeat count for the animation. @n + * Repeats an animation for the specified number of times. + * + * @since 2.0 + * + * @return An error code + * @param[in] count The number of times the animation has to repeat + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative. + * @remarks A delay and offset is applied to an animation only when the animation is played for the first time. + */ + result SetRepeatCount(long count); + + + /** + * Sets the AutoReverse property of the animation. @n + * If enabled, the forward and backward animation can also be played. + * + * @since 2.0 + * + * @param[in] autoReverse Set to @c true to enable the AutoReverse property of the animation, @n + * else @c false + * @remarks If @c autoReverseset is set to @c true, the duration of the animation is doubled. + * If the repeat count is more than 1, @n + * @c autoReverse is applied to each iteration. + * Note that if @c autoReverse is set to @c true, one forward animation play and one backward animation play is one + * iteration. + */ + void SetAutoReverseEnabled(bool autoReverse); + + + /** + * Sets the scale ratio of the animation. @n + * The %SetScaleRatio() method multiplies the duration, offset, and delay using the scale ratio. + * + * @since 2.0 + * + * @return An error code + * @param[in] scaleRatio The scale ratio property of the animation + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative. + */ + result SetScaleRatio(float scaleRatio); + + + /** + * Sets the hold end value of the animation. @n + * The %SetHoldEndEnabled() method retains the end values of an animation or goes to the start value of an animation. + * + * @since 2.0 + * + * @param[in] holdEnd Set to @c true to hold the end values of the animation, @n + * else @c false + */ + void SetHoldEndEnabled(bool holdEnd); + + + /** + * Gets the duration of the animation in milliseconds. + * + * @since 2.0 + * + * @return The duration value of the animation + */ + long GetDuration(void) const; + + + /** + * Gets the offset value in milliseconds after the animation starts. + * + * @since 2.0 + * + * @return The offset value of the animation in milliseconds @n + * The default value of the offset is @c 0. + */ + long GetOffset(void) const; + + + /** + * Gets the delay value in milliseconds before the animation starts. + * + * @since 2.0 + * + * @return The delay value in milliseconds @n + * The default value of the delay is @c 0. + */ + long GetDelay(void) const; + + + /** + * Gets the repeat count value of the animation. + * + * @since 2.0 + * + * @return The repeat count value of the animation @n + * The default value of the repeat count is @c 1. + */ + long GetRepeatCount(void) const; + + + /** + * Checks whether the auto reverse is enabled. + * + * @since 2.0 + * + * @return @c true if the auto reverse is enabled, @n + * else @c false @n + * The default auto reverse value is @c false. + */ + bool IsAutoReverseEnabled(void) const; + + + /** + * Gets the scale ratio value of the animation. + * + * @since 2.0 + * + * @return The scale ratio value of the animation @n + * The default value of scale ratio is @c 1.0f. + */ + float GetScaleRatio(void) const; + + + /** + * Checks whether the hold end value of the animation is enabled. + * + * @since 2.0 + * + * @return @c true if the hold end value is enabled, @n + * else @c false @n + * The default hold end value is @c true. + */ + bool IsHoldEndEnabled(void) const; + + + /** + * Sets the interpolator type. + * + * @since 2.0 + * + * @param[in] interpolatorType The interpolator type used for the animation + */ + void SetInterpolatorType(AnimationInterpolatorType interpolatorType); + + + /** + * Gets the interpolator type. + * + * @since 2.0 + * + * @return The interpolator type of an animation @n + * The default interpolator type is @c ANIMATION_INTERPOLATOR_LINEAR. + */ + AnimationInterpolatorType GetInterpolatorType(void) const; + + + /** + * Sets the control points for Bezier interpolator. @n + * The %SetBezierControlPoints() method is supported only if the interpolator is ANIMATION_INTERPOLATOR_BEZIER. + * + * @since 2.0 + * + * @return An error code + * @param[in] time1 The control point 1 - Time @n + * The time must be in the range @c 0.0 to @c 1.0. The time value is scaled relative to the duration of the animation. + * @param[in] value1 The control point 1 - Value @n + * The value must be in the range @c 0.0 to @c 1.0. The value is scaled relative to the start and end value of the animation. + * @param[in] time2 The control point 2 - Time @n + * The time must be in the range @c 0.0 to @c 1.0. The time value is scaled relative to the duration of the animation. + * @param[in] value2 The control point 2 - Value @n + * The value must be in the range @c 0.0 to @c 1.0. The value is scaled relative to the start and end value of the animation. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION This method is not supported for the interpolator set of this instance. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks @c time1 can be greater than @c time2 and vice versa. + */ + result SetBezierControlPoints(float time1, float value1, float time2, float value2); + + + /** + * Gets the control points of the Bezier interpolator. @n + * The %GetBezierControlPoints() method is supported only if the interpolator is @c ANIMATION_INTERPOLATOR_BEZIER. @c 0 is returned for the other interpolators. + * + * @since 2.0 + * + * @return An error code + * @param[out] time1 The control point 1 - Time @n + * The default value of control point 1 is @c 0.0. + * @param[out] value1 The control point 1 - Value @n + * The default value of control point 1 is @c 0.0. + * @param[out] time2 The control point 2 - Time @n + * The default value of control point 2 is @c 0.0. + * @param[out] value2 The control point 2 - Value @n + * The default value of control point 2 is @c 0.0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION This method is not supported for the interpolator set of this instance. + * + */ + result GetBezierControlPoints(float& time1, float& value1, float& time2, float& value2) const; + + + /** + * Gets the count of key frames added to this animation. + * + * @since 2.0 + * + * @return The key frame count + */ + int GetKeyFrameCount(void) const; + + + /** + * Sets the name of the animation. + * + * @since 2.0 + * + * @param[in] name The name of the animation + */ + void SetName(const Tizen::Base::String& name); + + + /** + * Gets the name of the animation. + * + * @since 2.0 + * + * @return The name of the animation @n + * The default value of the name is an empty string. + */ + Tizen::Base::String GetName(void) const; + + + /** + * Gets the type information of this instance. + * + * @since 2.0 + * + * @return The type information of this instance + */ + virtual AnimationType GetType(void) const = 0; + + +protected: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the default constructor for this class. + // + // @since 2.0 + // + AnimationBase(void); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the copy constructor for the %AnimationBase class. + // + // @since 2.0 + // + // @param[in] animationBase An instance of AnimationBase + // @remarks The animation name of the copied %AnimationBase object will be same as the %AnimationBase object passed. + // User must change the name using the SetName() method of this class in order to make animation name unique. + // + AnimationBase(const AnimationBase& animationBase); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the constructor for this class. + // + // @since 2.0 + // + // @param[in] duration The duration of animation in milliseconds + // @param[in] interpolator The type of Interpolation used for animation's intermediate value calculation + // + AnimationBase(long duration, AnimationInterpolatorType interpolator); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %AnimationBase. + // + // @since 2.0 + // + // @param[in] value An instance of %AnimationBase + // @remarks The animation name of the returned %AnimationBase object will be same as the %AnimationBase object passed. + // User must change the name using SetName() method of this class in order to make animation name unique. + // + AnimationBase& operator =(const AnimationBase& value); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void AnimationBase_Reserved1(void); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void AnimationBase_Reserved2(void); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void AnimationBase_Reserved3(void); + + + friend class _AnimationBaseImpl; + + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This variable is for internal usage. + // + // @since 2.0 + // + class _AnimationBaseImpl* _pAnimationBaseImpl; +}; // AnimationBase + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_ANIMATION_BASE_H_ diff --git a/inc/FUiAnimAnimationGroup.h b/inc/FUiAnimAnimationGroup.h new file mode 100644 index 0000000..2989e5f --- /dev/null +++ b/inc/FUiAnimAnimationGroup.h @@ -0,0 +1,143 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimAnimationGroup.h + * @brief This is the header file for the %AnimationGroup class. + * + * This header file contains the declarations of the %AnimationGroup class and its helper classes. + */ + +#ifndef _FUI_ANIM_ANIMATION_GROUP_H_ +#define _FUI_ANIM_ANIMATION_GROUP_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class AnimationGroup + * @brief This class is used to group a set of animations together. + * + * @since 2.0 + * + * The %AnimationGroup class is used to group a set of animations together. + * + * For more information on the class features, see Animating UI Controls. + */ +class _OSP_EXPORT_ AnimationGroup + : public Tizen::Base::Object +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~AnimationGroup(void); + + + /** + * Removes all the animations from the animation group. + * + * @since 2.0 + */ + virtual void RemoveAllAnimations(void) = 0; + + + /** + * Gets the animation count value. + * + * @since 2.0 + * + * @return The total number of animations added to the group + */ + virtual int GetAnimationCount(void) const = 0; + + + /** + * Gets the type information of this instance. + * + * @since 2.0 + * + * @return The type information of this instance + */ + virtual AnimationGroupType GetType(void) const = 0; + + +protected: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the default constructor for this class. + // + // @since 2.0 + // + AnimationGroup(void); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %AnimationGroup. + // + // @since 2.0 + // + // @param[in] rhs An instance of %AnimationGroup + // + AnimationGroup& operator =(const AnimationGroup& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the copy constructor for the %AnimationGroup class. + // + // @since 2.0 + // + // @param[in] animationGroup An instance of %AnimationGroup + // + AnimationGroup(const AnimationGroup& animationGroup); + + + friend class _AnimationGroupImpl; + + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The variable for internal usage. + // + // @since 2.0 + // + class _AnimationGroupImpl* _pAnimationGroupImpl; +}; // AnimationGroup + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_ANIMATION_GROUP_H_ diff --git a/inc/FUiAnimAnimationTransaction.h b/inc/FUiAnimAnimationTransaction.h new file mode 100644 index 0000000..7321ffd --- /dev/null +++ b/inc/FUiAnimAnimationTransaction.h @@ -0,0 +1,495 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimAnimationTransaction.h + * @brief This is the header file for the %AnimationTransaction class. + * + * This header file contains the declarations of the %AnimationTransaction class. + */ + +#ifndef _FUI_ANIM_ANIMATION_TRANSACTION_H_ +#define _FUI_ANIM_ANIMATION_TRANSACTION_H_ + +#include +#include + +#include +#include +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class IVisualElementAnimationTimingFunction; +class IVisualElementAnimationValueInterpolator; + +/** + * @class AnimationTransaction + * @brief This class defines the transaction operations of the animation. + * + * @since 2.0 + * + * The %AnimationTransaction class enables the applications to define animation transactions that make a set of animations on one or more animators to start or stop at the same time. + * + * For more information on the class features, see Transactions. + * + */ +class _OSP_EXPORT_ AnimationTransaction +{ +public: + + /** + * Initializes a transaction set. @n + * Calls ControlAnimator::StartUserAnimation() or calls VisualElement::AddAnimation() + * after calling the %Begin() method and before calling the CommitTransaction() method. + * Nesting of the transaction set is allowed. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + static result Begin(void); + + + /** + * Initializes a transaction set. @n + * Calls ControlAnimator::StartUserAnimation() or calls VisualElement::AddAnimation() + * after calling the %Begin() method and before calling the CommitTransaction() method. + * Nesting of the transaction set is allowed. + * + * @since 2.0 + * + * @return An error code + * @param[out] transactionId The transaction ID @n + * Use this transaction ID for further operations related to this transaction. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + static result Begin(int& transactionId); + + + /** + * Commits a set of animation start commands that are added during the current transaction. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + static result Commit(void); + + + /** + * Stops the transaction. @n + * All the nested transactions also will be stopped. + * + * @since 2.0 + * + * @return An error code + * @param[in] transactionId The transaction ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + static result Stop(int transactionId); + + + /** + * Discards all inactive transactions. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @see Begin() + */ + static result Discard(void); + + + /** + * Gets the status of the specified transaction. + * + * @since 2.0 + * + * @return The state of the transaction + * @param[in] transactionId The transaction ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static AnimationTransactionStatus GetStatus(int transactionId); + + + /** + * Sets a default event listener to listen to the events of transactions. @n + * The set listener can listen to the events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] pListener The listener to add + * @exception E_SUCCESS The method is successful. + * @remarks Only one event listener can be set. @n + * If @c pListener is @c null, the listener already set is unregistered. @n + * An application must deregister the registered listener if the listener object needs to be deleted. + * @see SetCurrentTransactionEventListener() + */ + static result SetTransactionEventListener(IAnimationTransactionEventListener* pListener); + + + /** + * Sets a listener instance to listen to the events of a current transaction. @n + * The set listener can listen to the events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] pListener The listener to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @remarks If the listener is set using this method, the set default listener is not called. + * @see SetTransactionEventListener() + */ + static result SetCurrentTransactionEventListener(IAnimationTransactionEventListener* pListener); + + + /** + * Enables or disables the implicit animation on the current transaction. @n + * If enabled, implicit animations may be created whenever animatable properties of this instance change. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the implicit animation, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @remarks The nested transaction created after invoking this method will inherit @c enable as the default value. + * @remarks Deciding whether to enable implicit animation depends on both the flag of transaction and the flag of VisualElement. + * If both SetVisualElementImplicitAnimationEnabled() and VisualElement::SetImplicitAnimationEnabled() are set to @c true, @n + * implicit animation is enabled. + */ + static result SetVisualElementImplicitAnimationEnabled(bool enable); + + + /** + * Sets a default event listener to get the status of an animation. @n + * The IVisualElementAnimationStatusEventListener listener is called for status changes of animation. + * The added listener listens to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] pListener The pointer of listener instance to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + */ + static result SetVisualElementAnimationStatusEventListener(IVisualElementAnimationStatusEventListener* pListener); + + + /** + * Sets the default timing function of an animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] pTimingFunction The reference of interpolator instance to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + */ + static result SetVisualElementAnimationTimingFunction(const IVisualElementAnimationTimingFunction* pTimingFunction); + + + /** + * Sets the default value interpolator of an animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] pValueInterpolator The reference of InterpolatorFunction instance to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + */ + static result SetVisualElementAnimationValueInterpolator(const IVisualElementAnimationValueInterpolator* pValueInterpolator); + + + /** + * Sets the default duration of an animation in the current transaction. + * + * @since 2.0 + * + * @return An error code + * @param[in] milliseconds The duration of the animation in milliseconds + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @exception E_INVALID_ARG The value of the specified parameter is negative or lesser than the offset of the animation. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + * @see GetVisualElementAnimationDuration() + */ + static result SetVisualElementAnimationDuration(long milliseconds); + + + /** + * Gets the default duration of an animation in milliseconds in the current transaction. + * + * @since 2.0 + * + * @return The duration value of the animation + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + * @see SetVisualElementAnimationDuration() + */ + static long GetVisualElementAnimationDuration(void); + + + /** + * Sets the default offset value of an animation. @n + * Additionally, the %SetVisualElementAnimationOffset() method alters the start value and duration for which an animation is played. + * + * @since 2.0 + * + * @return An error code + * @param[in] milliseconds The offset value of the animation in milliseconds + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @exception E_INVALID_ARG The value of the specified parameter is negative or greater than the duration of the animation. + * @remarks If the start value of the animation is @c 0.0, the end value is @c 1.0, the duration is @c 100 ms and the offset value is @c 20 ms, + * the actual animation starts at @c 0th ms and plays for @c 80 ms with a start value of @c 0.2. @n + * If @c autoReverse is set to @c true, the Backward animation plays for @c 100ms, from @c 1.0 to @c 0.0. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + * @see GetVisualElementAnimationOffset() + */ + static result SetVisualElementAnimationOffset(long milliseconds); + + + /** + * Gets the default offset value in milliseconds after an animation starts. + * + * @since 2.0 + * + * @return The offset value of the animation in milliseconds @n + * The default value of the offset is @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks This is used as the default value for newly created VisualElementAnimation class or its descendant classes in the current transaction. + * @see SetVisualElementAnimationOffset() + */ + static long GetVisualElementAnimationOffset(void); + + + /** + * Sets the default delay for an animation. @n + * The animation starts after the duration of delay has passed. + * + * @since 2.0 + * + * @return An error code + * @param[in] milliseconds The delay for the animation to start in milliseconds + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @exception E_INVALID_ARG The value of the specified parameter is negative. + * @remarks This method does not alter the start, end, and duration values of the animation. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + * @see GetVisualElementAnimationDelay() + */ + static result SetVisualElementAnimationDelay(long milliseconds); + + + /** + * Gets the default delay value in milliseconds before an animation starts. + * + * @since 2.0 + * + * @return The delay value in milliseconds @n + * The default value of the delay is @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + * @see SetVisualElementAnimationDelay() + */ + static long GetVisualElementAnimationDelay(void); + + + /** + * Sets the default repeat count for an animation. @n + * Repeats an animation for the specified number of times. + * + * @since 2.0 + * + * @return An error code + * @param[in] count The number of times the animation has to repeat + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @exception E_INVALID_ARG The value of the specified parameter is negative. + * @remarks A delay and offset is applied to an animation only when the animation is played for the first time. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + * @see GetVisualElementAnimationRepeatCount() + */ + static result SetVisualElementAnimationRepeatCount(long count); + + + /** + * Gets the default repeat count value of an animation. + * + * @since 2.0 + * + * @return The repeat count value of the animation @n + * The default value of the repeat count is @c 1. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + * @see SetVisualElementAnimationRepeatCount() + */ + static long GetVisualElementAnimationRepeatCount(void); + + + /** + * Sets the default AutoReverse property of an animation. @n + * If enabled, the forward and backward animation can also be played. + * + * @since 2.0 + * + * @param[in] autoReverse Set to @c true to enable the AutoReverse property of the animation, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @remarks If @c autoReverse is set to @c true, the duration of the animation is doubled. + * If the repeat count is more than @c 1, @c autoReverse is applied to each iteration. + * Note that if @c autoReverse is set to @c true, one forward animation play + * and one backward animation play is one iteration. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + * @see IsVisualElementAnimationAutoReverseEnabled() + */ + static result SetVisualElementAnimationAutoReverseEnabled(bool autoReverse); + + + /** + * Checks whether the auto reverse is enabled. + * + * @since 2.0 + * + * @return @c true if the auto reverse is enabled, @n + * else @c false @n + * The default auto reverse value is @c false. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + * @see SetVisualElementAnimationAutoReverseEnabled() + */ + static bool IsVisualElementAnimationAutoReverseEnabled(void); + + + /** + * Sets the default scale ratio of an animation. @n + * The %SetVisualElementAnimationScaleRatio() method multiplies the duration, offset and delay using the scale ratio. + * + * @since 2.0 + * + * @return An error code + * @param[in] scaleRatio The scale ratio property of the animation + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @exception E_INVALID_ARG The value of the specified parameter is negative. + * @remarks This is used as the default value for the newly created VisualElementAnimation or its descendant classes in the current transaction. + * @see GetVisualElementAnimationScaleRatio() + */ + static result SetVisualElementAnimationScaleRatio(float scaleRatio); + + + /** + * Gets the default scale ratio value of an animation. + * + * @since 2.0 + * + * @return The scale ratio value of the animation @n + * The default value of scale ratio is @c 1.0f. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION An uncommitted transaction does not exist. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks This is used as the default value for the newly created VisualElementAnimation class or its descendant classes in the current transaction. + * @see SetVisualElementAnimationScaleRatio() + */ + static float GetVisualElementAnimationScaleRatio(void); + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the default constructor for this class. + // + // @since 2.0 + // + AnimationTransaction(void); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the destructor for this class. + // + // @since 2.0 + // + ~AnimationTransaction(void); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the copy constructor for the %AnimationTransaction class. + // + // @since 2.0 + // @param[in] transaction An instance of %AnimationTransaction + // + AnimationTransaction(const AnimationTransaction& transaction); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %AnimationTransaction. + // + // @since 2.0 + // + // @param[in] rhs An instance of %AnimationTransaction + // + AnimationTransaction& operator =(const AnimationTransaction& rhs); +}; // AnimationTransaction + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_ANIMATION_TRANSACTION_H_ diff --git a/inc/FUiAnimBezierTimingFunction.h b/inc/FUiAnimBezierTimingFunction.h new file mode 100644 index 0000000..de4f79f --- /dev/null +++ b/inc/FUiAnimBezierTimingFunction.h @@ -0,0 +1,207 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimBezierTimingFunction.h + * @brief This is the header file for the %BezierTimingFunction class. + * + * This header file contains the declarations of the %BezierTimingFunction class. + */ + +#ifndef _FUI_ANIM_BEZIER_TIMING_FUNCTION_H_ +#define _FUI_ANIM_BEZIER_TIMING_FUNCTION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class BezierTimingFunction + * @brief This class stores the information of a bezier curve timing function. + * + * @since 2.0 + * + * @remarks This class needs 2 control points of cubic bezier curve. + * + * The %BezierTimingFunction class provides bezier curve timing function related information. + * + * For more information on the class features, see Timing Function. + * + */ +class _OSP_EXPORT_ BezierTimingFunction + : public Tizen::Base::Object + , public IVisualElementAnimationTimingFunction +{ +public: + + /** + * This is the constructor for this class. + * + * @since 2.0 + */ + BezierTimingFunction(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~BezierTimingFunction(void); + + + /** + * Calculates the progress(pace) of an animation regarding the time elapsed. + * + * @since 2.0 + * + * @return The progress(pace) value calculated by bezier equation with control points @n + * @c 0 and @c 1 are the start and end values of an animation, respectively. + * @param[in] timeProgress The time progress value @n + * This must be in the range @c 0.0 to @c 1.0. + */ + virtual float CalculateProgress(float timeProgress) const; + + + /** + * Sets the control points. + * + * @since 2.0 + * + * @return An error code + * @param[in] timeProgress1 The time progress of control point 1 @n + * This must be in the range @c 0.0 to @c 1.0. + * @param[in] progress1 The progress of control point 1 @n + * This must be in the range @c 0.0 to @c 1.0. + * @param[in] timeProgress2 The time progress of control point 2 @n + * This must be in the range @c 0.0 to @c 1.0. + * @param[in] progress2 The progress of control point 2 @n + * This must be in the range @c 0.0 to @c 1.0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is less than @c 0 or greater than @c 1. + * @see GetControlPoints() + */ + result SetControlPoints(float timeProgress1, float progress1, float timeProgress2, float progress2); + + + /** + * Gets the control points. + * + * @since 2.0 + * + * @return An error code + * @param[out] timeProgress1 The time progress of control point 1 @n + * The default value is @c 0.33f. + * @param[out] progress1 The progress of control point 1 @n + * The default value is @c 0.8f. + * @param[out] timeProgress2 The time progress of control point 2 @n + * The default value is @c 0.66f. + * @param[out] progress2 The progress of control point 2 @n + * The default value is @c 0.2f. + * @exception E_SUCCESS The method is successful. + * @see SetControlPoints() + */ + result GetControlPoints(float& timeProgress1, float& progress1, float& timeProgress2, float& progress2) const; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + BezierTimingFunction(const BezierTimingFunction& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %BezierTimingFunction. + // + // @since 2.0 + // + BezierTimingFunction& operator =(const BezierTimingFunction& rhs); + + +private: + + /** + * The time progress of control point 1. + * + * @since 2.0 + */ + float __timeProgress1; + + + /** + * The progress of control point 1. + * + * @since 2.0 + */ + float __progress1; + + + /** + * The time progress of control point 2. + * + * @since 2.0 + */ + float __timeProgress2; + + + /** + * The progress of control point 2. + * + * @since 2.0 + */ + float __progress2; + + + /** + * The coefficient A for calculating bezier curve. + * + * @since 2.0 + */ + float __coefficientA; + + + /** + * The coefficient B for calculating bezier curve. + * + * @since 2.0 + */ + float __coefficientB; + + + /** + * The coefficient C for calculating bezier curve. + * + * @since 2.0 + */ + float __coefficientC; +}; // BezierTimingFunction + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_BEZIER_TIMING_FUNCTION_H_ diff --git a/inc/FUiAnimControlAnimator.h b/inc/FUiAnimControlAnimator.h new file mode 100644 index 0000000..68e130a --- /dev/null +++ b/inc/FUiAnimControlAnimator.h @@ -0,0 +1,520 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimControlAnimator.h + * @brief This is the header file for the %ControlAnimator class. + * + * This header file contains the declarations of the %ControlAnimator class. + */ + +#ifndef _FUI_ANIM_CONTROL_ANIMATOR_H_ +#define _FUI_ANIM_CONTROL_ANIMATOR_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class ControlAnimator + * @brief This class defines the animation methods for Tizen::Ui::Control. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %ControlAnimator class is used to control the animations operated in Tizen::Ui::Controls. + * + * For more information on the class features, see Animating UI Controls. + * + */ +class _OSP_EXPORT_ ControlAnimator + : public Tizen::Base::Object +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~ControlAnimator(void); + + + /** + * Starts an animation explicitly. @n + * If multiple controls need to be animated simultaneously, the controls must be part of the AnimationTransaction class. @n + * The %StartUserAnimation() method must be called after AnimationTransaction::Begin() and before AnimationTransaction::Commit(). + * + * @since 2.0 + * + * @return An error code + * @param[in] animTarget The property to animate + * @param[in] animation An object of type AnimationBase + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + * @remarks An animation is deleted at the end of the animation playback. @n + * RectangleAnimation is used to animate only one animation target at a time. + * For example, if AnimationTarget is @c ANIMATION_TARGET_SIZE, RectangleAnimation performs only the dimension animation. @n + * To perform animation using the @c ANIMATION_TARGET_POSITION and @c ANIMATION_TARGET_SIZE properties, AnimationTransaction must be used with + * a separate call for each animation target. + */ + result StartUserAnimation(AnimationTargetType animTarget, const AnimationBase& animation); + + + /** + * Starts a group of animations explicitly. @n + * If multiple controls need to be animated simultaneously, the control must be part of the AnimationTransaction class. + * The %StartUserAnimation() method must be called after AnimationTransaction::Begin() and before AnimationTransaction::Commit(). + * + * @since 2.0 + * + * @return An error code + * @param[in] animGroup An animation group having a list of animations + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + * @remarks The animations are deleted at the end of the animation playback. @n + * RectangleAnimation is used to animate only one animation target at a time. + */ + result StartUserAnimation(const AnimationGroup& animGroup); + + + /** + * Stops all the animations that are currently playing and jumps to the final frame of the animation. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result StopAllAnimations(void); + + + /** + * Stops the animation with the specified trigger type. + * + * @since 2.0 + * + * @return An error code + * @param[in] animTrigger The animator trigger type + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result StopAnimation(ControlAnimatorTriggerType animTrigger); + + + /** + * Gets the status of an animation with respect to a control. + * + * @since 2.0 + * + * @return The animation state + */ + AnimatorStatus GetStatus(void) const; + + + /** + * Gets the status of an animation for the specified animation target type. + * + * @since 2.0 + * + * @return The state of an animation with type @c animTarget + * @param[in] animTarget The animation target type + */ + AnimatorStatus GetStatus(AnimationTargetType animTarget) const; + + + /** + * Adds the IControlAnimatorEventListener listener instance to the current instance of the control. @n + * The %IControlAnimatorEventListener listener is called for status changes of animations associated with a control. + * The added listener listens to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_UNSUPPORTED_OPERATION The animation support is unavailable. + * @exception E_OBJ_ALREADY_EXIST The specified @c listener is already added. + * @exception E_SYSTEM A system error has occurred. + * @remarks For animations that are part of AnimationTransaction, the applications need to listen to IAnimationTransactionEventListener events. @n + * The IControlAnimatorEventListener events are not fired if the animation is part of a transaction. + */ + result AddControlAnimatorEventListener(IControlAnimatorEventListener& listener); + + + /** + * Removes the IControlAnimatorEventListener listener instance from the current instance of the control. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_UNSUPPORTED_OPERATION The animation support is unavailable. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveControlAnimatorEventListener(IControlAnimatorEventListener& listener); + + + /** + * Adds a IControlAnimatorDetailedEventListener listener instance to the current instance of the control. @n + * The %IControlAnimatorDetailedEventListener listener is called for status changes of each animation associated with the control. @n + * The added listener listens to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_UNSUPPORTED_OPERATION The animation support is unavailable. + * @exception E_OBJ_ALREADY_EXIST The specified @c listener is already added. + * @exception E_SYSTEM A system error has occurred. + * @remarks For animations that are part of AnimationTransaction, the applications need to listen to the IAnimationTransactionEventListener events. @n + * The IControlAnimatorDetailedEventListener events are not fired if the animation is part of a transaction. + */ + result AddControlAnimatorDetailedEventListener(IControlAnimatorDetailedEventListener& listener); + + + /** + * Removes an IControlAnimatorDetailedEventListener instance from the current instance of the control. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_UNSUPPORTED_OPERATION The animation support is unavailable. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveControlAnimatorDetailedEventListener(IControlAnimatorDetailedEventListener& listener); + + + /** + * Sets an animation group for the specified trigger type. + * + * @since 2.0 + * + * @return An error code + * @param[in] animTrigger The animator trigger type to which the animation is applied + * @param[in] pAnimation An object of type AnimationBase @n + * If @c null is passed, the default animation values are used for animation with the specified trigger type. + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPTION The specified option is not supported. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks @c ANIMATION_TRIGGER_USER is not supported. @n + * The @c holdEnd value and @c AutoReverse value are set to @c true and @c false respectively. @n + * An exception is returned if the animation group does not contain an animation with the target type that is being animated for the specified + * trigger type. The start value of an animation object of the associated target type for the specified trigger type is overwritten by the + * current property value of the Tizen::Ui::Control instance and the end value is overwritten by the value that is being set by the user. @n + * The associated target types for each trigger are as below: @n + * \verbatim + * Animation Trigger - Target Type + * ANIMATION_TRIGGER_POSITION_CHANGE - ANIMATION_TARGET_POSITION + * ANIMATION_TRIGGER_SIZE_CHANGE - ANIMATION_TARGET_SIZE + * ANIMATION_TRIGGER_SHOW_STATE_CHANGE - ANIMATION_TARGET_ALPHA + * \endverbatim + */ + result SetAnimation(ControlAnimatorTriggerType animTrigger, const AnimationGroup* pAnimation); + + + /** + * Gets a group of animations. + * + * @since 2.0 + * + * @return An animation group object at the specified animation trigger type, @n + * else @c null if the animation is empty or AnimationTriggerType is @c ANIMATION_TRIGGER_USER + * @param[in] animTrigger The animator trigger type to get an animation group object + */ + AnimationGroup* GetAnimationN(ControlAnimatorTriggerType animTrigger) const; + + + /** + * Sets the position of the control. @n + * An animation is played while changing the position of the control. + * + * @since 2.0 + * + * @return An error code + * @param[in] x The new X position of the object + * @param[in] y The new Y position of the object + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @exception E_SYSTEM A system error has occurred. + * @remarks The X and Y position of the object are relative to the top-left corner of its parent. @n + * Control::Invalidate() need not be called to display the control. The animation uses linear interpolator and is played for a default duration if + * the user does not overwrite the values using SetAnimation(). + * @see SetBounds() + * @see SetSize() + */ + result SetPosition(int x, int y); + + + /** + * Sets the position of the control. @n + * An animation is played while changing the position of the control. + * + * @since 2.0 + * + * @return An error code + * @param[in] Position The new position + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @exception E_SYSTEM A system error has occurred. + * @remarks The position of the object is relative to the top-left corner of its parent. @n + * Control::Invalidate() need not be called to display the control. @n + * The animation uses linear interpolator and is played for a default duration if the user does not overwrite the values using SetAnimation(). + * @see SetPosition() + * @see SetBounds() + * @see SetSize() + */ + result SetPosition(const Tizen::Graphics::Point& Position); + + + /** + * Sets the size of the control. @n + * An animation is played while changing the size of the control. @n + * The @c width and @c height parameters contain the width and height values of the object, respectively. + * + * @since 2.0 + * + * @return An error code + * @param[in] width The new width of the object + * @param[in] height The new height of the object + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The value of @c width or @c height is @c 0 or a negative value. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @exception E_SYSTEM A system error has occurred. + * @remarks Control::Invalidate() need not be called to display the control. @n + * The animation uses linear interpolator and is played for a duration of @c 250 ms if the user does not overwrite the values using SetAnimation(). + * @see SetBounds() + * @see SetPosition() + */ + result SetSize(int width, int height); + + + /** + * Sets the size of the control. @n + * An animation is played while changing the size of the control. @n + * The @c width becomes @c size.width, and the @c height becomes @c size.height. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The new width and height + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The value @c size.width or @c size.height is @c 0 or a negative value. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @exception E_SYSTEM A system error has occurred. + * @remarks Control::Invalidate() need not be called to display the control. @n + * The animation uses linear interpolator and is played for a duration of @c 250 ms if the user does not overwrite the values using SetAnimation(). + * @see SetSize() + * @see SetBounds() + * @see SetPosition() + */ + result SetSize(const Tizen::Graphics::Dimension& size); + + + /** + * Sets the position and size of the control. @n + * An animation is played while changing the position and size of the control. @n + * The position is set to (x, y), and the @c width and @c height parameters contain the width and height values of the object, respectively. + * + * @since 2.0 + * + * @return An error code + * @param[in] x The new X position of the object + * @param[in] y The new Y position of the object + * @param[in] width The new width of the object + * @param[in] height The new height of the object + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The value of @c width or @c height is @c 0 or a negative value. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @remarks Changing the position of a parent object does not change the position of its children, the top-left position that is relative to the + * top-left corner of the parent container. If calling this method causes re-positioning of an object or changes the size of the object, the + * system redraws the object and all its children. @n + * Control::Invalidate() need not be called to display the control. @n + * The animation uses linear interpolator and is played for a duration of @c 250 ms if the user does not overwrite the values using SetAnimation(). + * @see SetPosition() + * @see SetSize() + */ + result SetBounds(int x, int y, int width, int height); + + + /** + * Sets the position and size of the control. @n + * An animation is played while changing the position and size of the control. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The new bounds of the object + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The value of @c rect.width or @c rect.height is @c 0 or a negative value. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @remarks Control::Invalidate() need not be called to display the control. @n + * The animation uses linear interpolator and is played for a duration of @c 250 ms if the user does not overwrite the values using SetAnimation(). + * @see SetBounds() + * @see SetPosition() + * @see SetSize() + */ + result SetBounds(const Tizen::Graphics::Rectangle& rect); + + + /** + * Sets the show state of the control with animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] show The show state of the object + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @exception E_SYSTEM A system error has occurred. + * @remarks Control::Invalidate() need not be called to display the control. @n + * The animation uses linear interpolator and is played for a duration of @c 250 ms if the user does not overwrite the values using SetAnimation(). + */ + result SetShowState(bool show); + + + /** + * Checks whether animation is supported for the control with the specified target type. + * + * @since 2.0 + * + * @return @c true if animation is supported, @n + * else @c false + * @param[in] animTarget The animation target + */ + bool IsAnimationSupported(AnimationTargetType animTarget) const; + +protected: + + friend class _ControlAnimatorImpl; + + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The variable for internal usage. + // + // @since 2.0 + // + class _ControlAnimatorImpl* _pControlAnimatorImpl; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the constructor for this class. + // + // @since 2.0 + // + ControlAnimator(void); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Initializes this class. + // + // @since 2.0 + // @return An error code + // @param[in] source An instance of control class + // @exception E_SUCCESS The method is successful. + // @exception E_SYSTEM A system error has occurred. + // + result Construct(const Tizen::Ui::Control& source); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the copy constructor for this class. + // + // @since 2.0 + // + ControlAnimator(const ControlAnimator& animator); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %ControlAnimator. + + // + // @since 2.0 + // + ControlAnimator& operator =(const ControlAnimator& rhs); + + + friend class Tizen::Ui::_ControlImpl; + friend class FrameAnimator; +}; // ControlAnimator + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_CONTROL_ANIMATOR_H_ diff --git a/inc/FUiAnimDimensionAnimation.h b/inc/FUiAnimDimensionAnimation.h new file mode 100644 index 0000000..981a253 --- /dev/null +++ b/inc/FUiAnimDimensionAnimation.h @@ -0,0 +1,367 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimDimensionAnimation.h + * @brief This is the header file for the %DimensionAnimation class. + * + * This header file contains the declarations of the %DimensionAnimation class. + */ + +#ifndef _FUI_ANIM_DIMENSION_ANIMATION_H_ +#define _FUI_ANIM_DIMENSION_ANIMATION_H_ + +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class DimensionAnimation + * @brief This class animates the Tizen::Graphics::Dimension object. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %DimensionAnimation class animates an object from a Tizen::Graphics::Dimension value to another %Tizen::Graphics::Dimension value + * based on the specified interpolator type. + * + * For more information on the class features, see Animating UI Controls. + */ +class _OSP_EXPORT_ DimensionAnimation + : public AnimationBase +{ +public: + /** + * Initializes this instance of %DimensionAnimation with the specified parameters. + * + * @since 2.0 + * + * @param[in] startValue The start value for the dimension animation + * @param[in] endValue The end value for the dimension animation + * @param[in] duration The duration of animation in milliseconds + * @param[in] interpolator The type of interpolator used for the animation's intermediate value calculation + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative or the interpolator is of an invalid type. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + DimensionAnimation(const Tizen::Graphics::Dimension& startValue, const Tizen::Graphics::Dimension& endValue, long duration, AnimationInterpolatorType interpolator); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~DimensionAnimation(void); + + /** + * This is the copy constructor for the %DimensionAnimation class. + * + * @since 2.0 + * + * @param[in] dimensionAnimation An instance of %DimensionAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + DimensionAnimation(const DimensionAnimation& dimensionAnimation); + + + /** + * Assigns the value of the specified instance to the current instance of %DimensionAnimation. + * + * @since 2.0 + * + * @param[in] rhs An instance of %DimensionAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + DimensionAnimation& operator =(const DimensionAnimation& rhs); + + + /** + * Checks whether the specified instance and current instance of %DimensionAnimation have equal animation values. + * + * @since 2.0 + * + * @return @c true if the animation of the two instances of %DimensionAnimation are equal, @n + * else @c false + * @param[in] rhs An instance of %DimensionAnimation + */ + bool operator ==(const DimensionAnimation& rhs) const; + + + /** + * Checks whether the specified instance and current instance of %DimensionAnimation have different animation values. + * + * @since 2.0 + * + * @return @c true if the values of the animations of the two instances of %DimensionAnimation are not equal, @n + * else @c false + * @param[in] rhs An instance of %DimensionAnimation + */ + bool operator !=(const DimensionAnimation& rhs) const; + + + /** + * Checks whether the value of the current instance of %DimensionAnimation equals the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance equals the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %DimensionAnimation + * @remarks The %DimensionAnimation class has a semantic value that means this method checks whether the two instances have the same animation. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The two equal instances must return the same hash value. For better performance, the used hash function must generate a random + * distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + + /** + * Sets the anchor points for the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] anchorX The X value of the anchor at which the control's animation is performed + * @param[in] anchorY The Y value of the anchor at which the control's animation is performed + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks A default anchor point value is (0.0, 0.0). The range of an anchor point is @c 0.0 to @c 1.0. @n + * When the anchor point value is (0.0, 0.0), the object is scaled and the top-left corner of the object remains fixed. @n + * For all the other anchor point values, the position property is changed. + * If the anchor point value is (0.5, 0.5), the object is scaled with respect to the center. + * If the anchor point value is (1.0, 1.0), the object is scaled and the bottom-right corner of the object remains fixed. + */ + result SetAnchor(float anchorX, float anchorY); + + + /** + * Gets the anchor point associated with the animation. @n + * The default anchor point is (0.0, 0.0). + * + * @since 2.0 + * + * @param[out] anchorX The X value of the anchor at which the control's animation is performed + * @param[out] anchorY The Y value of the anchor at which the control's animation is performed + */ + void GetAnchor(float& anchorX, float& anchorY) const; + + + /** + * Gets the animated value for the current time. + * + * @since 2.0 + * + * @return An error code + * @param[in] currentTime The current time value of the animation play @n + * The value must be between @c 0 and the duration of the animation. + * @param[out] animatedValue The animated value for the current time passed as the input parameter + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * + */ + result GetAnimatedValue(long currentTime, Tizen::Graphics::Dimension& animatedValue) const; + + + /** + * Adds a keyframe to the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] time The time stamp + * @param[in] value The value at the specified @c time + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If @c time is greater than the duration, it will become the new duration and @c value becomes the new @c endValue. @n + * Also, the old duration and @c endValue will be added as a new key frame entry in the list. @n + * If a key-value pair with the current key already exists, the old value will be overwritten with the new one. @n + * An exception will be returned if @c time is equal to @c 0 or the duration of the animation. + */ + result AddKeyFrame(long time, const Tizen::Graphics::Dimension& value); + + + /** + * Gets the keyframe at a particular index in this animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index value in the keyframe list that is sorted in an increasing order of time + * @param[out] time The time stamp at the specified @c index + * @param[out] value The value at the specified @c index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks The @c time and @c value returned is the one present at the index of the sorted map list(sorted with respect to key). @n + * For example, if the user adds key-frame in the order (10,value1), (20,value2), (5,value3) and then GetKeyFrameAt(0,time,value) is called, the + * pair returned is (5,value3). + */ + result GetKeyFrameAt(int index, long& time, Tizen::Graphics::Dimension& value) const; + + + /** + * Removes the passed keyframe object from the keyframe list. + * + * @since 2.0 + * + * @return An error code + * @param[in] time The key frame time + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The keyframe @c time value is invalid. + * @exception E_OBJ_NOT_FOUND The keyframe @c time value is not found in the keyframe List. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveKeyFrame(long time); + + + /** + * Removes the keyframe present at the specified @c index from the keyframe list. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index value in the Keyframe list @n + * The value is sorted in an increasing order of time. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index parameter is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveKeyFrameAt(int index); + + + /** + * Removes all the keyframes from the animation. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveAllKeyFrames(void); + + + /** + * Sets the start value of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] startValue The start value of the animation to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetStartValue(const Tizen::Graphics::Dimension& startValue); + + + /** + * Sets the end value of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] endValue The end value of the animation to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetEndValue(const Tizen::Graphics::Dimension& endValue); + + + /** + * Gets the start value of the animation. + * + * @since 2.0 + * + * @return The start value + */ + Tizen::Graphics::Dimension GetStartValue(void) const; + + + /** + * Gets the end value of the animation. + * + * @since 2.0 + * + * @return The end value + */ + Tizen::Graphics::Dimension GetEndValue(void) const; + + + /** + * Gets the animation type information of this instance. + * + * @since 2.0 + * + * @return The animation type information of this instance + */ + virtual AnimationType GetType(void) const; + + +protected: + friend class _DimensionAnimationImpl; + + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The variable for internal usage. + // + // @since 2.0 + // + class _DimensionAnimationImpl* _pDimensionAnimationImpl; + + +private: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the default constructor for this class. + // + // @since 2.0 + // + DimensionAnimation(void); +}; // DimensionAnimation + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_DIMENSION_ANIMATION_H_ diff --git a/inc/FUiAnimDiscreteTimingFunction.h b/inc/FUiAnimDiscreteTimingFunction.h new file mode 100644 index 0000000..c55c61b --- /dev/null +++ b/inc/FUiAnimDiscreteTimingFunction.h @@ -0,0 +1,142 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimDiscreteTimingFunction.h + * @brief This is the header file for the %DiscreteTimingFunction class. + * + * This header file contains the declarations of the %DiscreteTimingFunction class. + */ + +#ifndef _FUI_ANIM_DISCRETE_TIMING_FUNCTION_H_ +#define _FUI_ANIM_DISCRETE_TIMING_FUNCTION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class DiscreteTimingFunction + * @brief This class stores the information of a discrete timing function. + * + * @since 2.0 + * + * The %DiscreteTimingFunction class provides discrete timing function related information. + * + * For more information on the class features, see Timing Function. + * + */ +class _OSP_EXPORT_ DiscreteTimingFunction + : public Tizen::Base::Object + , public IVisualElementAnimationTimingFunction +{ +public: + + /** + * This is the constructor for this class. + * + * @since 2.0 + */ + DiscreteTimingFunction(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~DiscreteTimingFunction(void); + + + /** + * Calculates the progress(pace) of an animation regarding the time elapsed. + * + * @since 2.0 + * + * @return The progress(pace) value calculated with trigger time progress value @n + * @c 0 and @c 1 are the start and end values of an animation, respectively. + * @param[in] timeProgress The time progress value @n + * This must be in the range @c 0.0 to @c 1.0. + */ + virtual float CalculateProgress(float timeProgress) const; + + + /** + * Sets the time progress value of trigger point. + * + * @since 2.0 + * + * @return An error code + * @param[in] timeProgress The time progress value of trigger point @n + * This must be in the range @c 0.0 to @c 1.0 and cannot be @c 0.0 and @c 1.0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is less than @c 0 or greater than @c 1. + * @see GetTriggerTimeProgress() + */ + result SetTriggerTimeProgress(float timeProgress); + + + /** + * Gets the time progress value of trigger point. + * + * @since 2.0 + * + * @return The time progress value of trigger point + * @see SetTriggerTimeProgress() + */ + float GetTriggerTimeProgress(void) const; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + DiscreteTimingFunction(const DiscreteTimingFunction& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %DiscreteTimingFunction. + // + // @since 2.0 + // + DiscreteTimingFunction& operator =(const DiscreteTimingFunction& rhs); + + +private: + + /** + * The time progress value of trigger point. + * + * @since 2.0 + */ + float __triggerTimeProgress; +}; // DiscreteTimingFunction + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_DISCRETE_TIMING_FUNCTION_H_ diff --git a/inc/FUiAnimDisplayContext.h b/inc/FUiAnimDisplayContext.h new file mode 100644 index 0000000..58e69c1 --- /dev/null +++ b/inc/FUiAnimDisplayContext.h @@ -0,0 +1,141 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimDisplayContext.h + * @brief This is the header file for the %DisplayContext class. + * + * This header file contains the declarations of the %DisplayContext class. + */ + +#ifndef _FUI_ANIM_DISPLAY_CONTEXT_H_ +#define _FUI_ANIM_DISPLAY_CONTEXT_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ +class _DisplayContextImpl; + +/** + * @class DisplayContext + * @brief This class represents the display resources for the displayable objects. + * + * @since 2.0 + * + * The %DisplayContext class represents the display context of the window. + * The display context is a set of display resources that includes VisualElements, VisualElementSurfaces, and frame buffer, + * and it is managed by Tizen::Ui::Controls::Window. + */ +class _OSP_EXPORT_ DisplayContext + : public Tizen::Base::Object +{ +protected: + /** + * This default constructor is intentionally declared as private to prohibit creation of an instance by a user. + * + * @since 2.0 + * + * @remarks The %DisplayContext instance cannot be created, + * it is offered by the Tizen::Ui::Controls::Window::GetDisplayContext() method. + * @see Window::GetDisplayContext() + */ + DisplayContext(void); + + + /** + * This destructor is intentionally declared as private to implement the Singleton semantic. + * + * @since 2.0 + * + * @remarks The display context is released when the Tizen::Ui::Controls::Window instance is destroyed. + * + */ + virtual ~DisplayContext(void); + + +private: + + /** + * The implementation of this copy constructor is intentionally blank to prohibit copying of objects. + * + * @since 2.0 + */ + DisplayContext(const DisplayContext& rhs); + + + /** + * The implementation of this assignment constructor is intentionally blank to prohibit assignment of objects. + * + * @since 2.0 + */ + DisplayContext& operator =(const DisplayContext& rhs); + + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void DisplayContext_Reserved1(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void DisplayContext_Reserved2(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void DisplayContext_Reserved3(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void DisplayContext_Reserved4(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void DisplayContext_Reserved5(void) {} + +protected: + friend class _DisplayContextImpl; + _DisplayContextImpl* _pDisplayContextImpl; +}; // class DisplayContext + +}}} //namespace Tizen { namespace Ui { namespace Animations + +#endif //_FUI_ANIM_DISPLAY_CONTEXT_H_ diff --git a/inc/FUiAnimEaseElasticInTimingFunction.h b/inc/FUiAnimEaseElasticInTimingFunction.h new file mode 100644 index 0000000..fcbbf52 --- /dev/null +++ b/inc/FUiAnimEaseElasticInTimingFunction.h @@ -0,0 +1,142 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimEaseElasticInTimingFunction.h + * @brief This is the header file for the %EaseElasticInTimingFunction class. + * + * This header file contains the declarations of the %EaseElasticInTimingFunction class. + */ + +#ifndef _FUI_ANIM_EASE_ELASTIC_IN_TIMING_FUNCTION_H_ +#define _FUI_ANIM_EASE_ELASTIC_IN_TIMING_FUNCTION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class EaseElasticInTimingFunction + * @brief This class stores the information of an ease-elastic-in timing function. + * + * @since 2.0 + * + * The %EaseElasticInTimingFunction class provides ease-elastic-in timing function related information. + * + * For more information on the class features, see Timing Function. + * + */ +class _OSP_EXPORT_ EaseElasticInTimingFunction + : public Tizen::Base::Object + , public IVisualElementAnimationTimingFunction +{ +public: + + /** + * This is the constructor for this class. + * + * @since 2.0 + */ + EaseElasticInTimingFunction(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~EaseElasticInTimingFunction(void); + + + /** + * Calculates the progress(pace) of an animation regarding the time elapsed. + * + * @since 2.0 + * + * @return The progress(pace) value calculated by ease-elastic-in equation with period @n + * @c 0 and @c 1 are the start and end values of an animation, respectively. + * @param[in] timeProgress The time progress value @n + * This must be in the range @c 0.0 to @c 1.0. + */ + virtual float CalculateProgress(float timeProgress) const; + + + /** + * Sets the period value as period of sine curve. + * + * @since 2.0 + * + * @return An error code + * @param[in] period The period value @n + * This must be in the range @c 0.0 to @c 1.0 and cannot be @c 0.0 and @c 1.0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is @c 0.0 or negative. + * @see GetPeriod() + */ + result SetPeriod(float period); + + + /** + * Gets the period value. + * + * @since 2.0 + * + * @return The period value + * @see SetPeriod() + */ + float GetPeriod(void) const; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + EaseElasticInTimingFunction(const EaseElasticInTimingFunction& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the copy constructor for the EaseElasticInTimingFunction class. + // + // @since 2.0 + // + EaseElasticInTimingFunction& operator= (const EaseElasticInTimingFunction& rhs); + + +private: + + /** + * The period value. + * + * @since 2.0 + */ + float __period; +}; // EaseElasticInTimingFunction + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_EASE_ELASTIC_IN_TIMING_FUNCTION_H_ diff --git a/inc/FUiAnimEaseElasticOutTimingFunction.h b/inc/FUiAnimEaseElasticOutTimingFunction.h new file mode 100644 index 0000000..d2b3bc3 --- /dev/null +++ b/inc/FUiAnimEaseElasticOutTimingFunction.h @@ -0,0 +1,142 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimEaseElasticOutTimingFunction.h + * @brief This is the header file for the %EaseElasticOutTimingFunction class. + * + * This header file contains the declarations of the %EaseElasticOutTimingFunction class. + */ + +#ifndef _FUI_ANIM_EASE_ELASTIC_OUT_TIMING_FUNCTION_H_ +#define _FUI_ANIM_EASE_ELASTIC_OUT_TIMING_FUNCTION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class EaseElasticOutTimingFunction + * @brief This class stores the information of an ease-elastic-out timing function. + * + * @since 2.0 + * + * The %EaseElasticOutTimingFunction class provides ease-elastic-out timing function related information. + * + * For more information on the class features, see Timing Function. + * + */ +class _OSP_EXPORT_ EaseElasticOutTimingFunction + : public Tizen::Base::Object + , public IVisualElementAnimationTimingFunction +{ +public: + + /** + * This is the constructor for this class. + * + * @since 2.0 + */ + EaseElasticOutTimingFunction(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~EaseElasticOutTimingFunction(void); + + + /** + * Calculates the progress(pace) of an animation regarding the time elapsed. + * + * @since 2.0 + * + * @return The progress(pace) value calculated by ease-elastic-out equation with period @n + * @c 0 and @c 1 are the start and end values of an animation, respectively. + * @param[in] timeProgress The time progress value @n + * This must be in the range @c 0.0 to @c 1.0. + */ + virtual float CalculateProgress(float timeProgress) const; + + + /** + * Sets the period value as period of sine curve. + * + * @since 2.0 + * + * @return An error code + * @param[in] period The period value @n + * This must be in the range @c 0.0 to @c 1.0 and cannot be @c 0.0 and @c 1.0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is @c 0.0 or negative. + * @see GetPeriod() + */ + result SetPeriod(float period); + + + /** + * Gets the period value. + * + * @since 2.0 + * + * @return The period value + * @see SetPeriod() + */ + float GetPeriod(void) const; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + EaseElasticOutTimingFunction(const EaseElasticOutTimingFunction& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the copy constructor for the %EaseElasticOutTimingFunction class. + // + // @since 2.0 + // + EaseElasticOutTimingFunction& operator= (const EaseElasticOutTimingFunction& rhs); + + +private: + + /** + * The period value + * + * @since 2.0 + */ + float __period; +}; // EaseElasticOutTimingFunction + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_EASE_ELASTIC_OUT_TIMING_FUNCTION_H_ diff --git a/inc/FUiAnimEaseInOutTimingFunction.h b/inc/FUiAnimEaseInOutTimingFunction.h new file mode 100644 index 0000000..464b614 --- /dev/null +++ b/inc/FUiAnimEaseInOutTimingFunction.h @@ -0,0 +1,106 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimEaseInOutTimingFunction.h + * @brief This is the header file for the %EaseInOutTimingFunction class. + * + * This header file contains the declarations of the %EaseInOutTimingFunction class. + */ + +#ifndef _FUI_ANIM_EASE_IN_OUT_TIMING_FUNCTION_H_ +#define _FUI_ANIM_EASE_IN_OUT_TIMING_FUNCTION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class EaseInOutTimingFunction + * @brief This class stores the information of a ease-inout timing function. + * + * @since 2.0 + * + * The %EaseInOutTimingFunction class provides ease-inout timing function related information. + * + * For more information on the class features, see Timing Function. + * + */ +class _OSP_EXPORT_ EaseInOutTimingFunction + : public Tizen::Base::Object + , public IVisualElementAnimationTimingFunction +{ +public: + + /** + * This is the constructor for this class. + * + * @since 2.0 + */ + EaseInOutTimingFunction(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~EaseInOutTimingFunction(void); + + + /** + * Calculates the progress(pace) of an animation regarding the time elapsed. + * + * @since 2.0 + * + * @return The progress(pace) value calculated by ease-inout equation @n + * @c 0 and @c 1 are the start and end values of an animation, respectively. + * @param[in] timeProgress The time progress value @n + * This must be in the range @c 0.0 to @c 1.0. + */ + virtual float CalculateProgress(float timeProgress) const; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + EaseInOutTimingFunction(const EaseInOutTimingFunction& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %EaseInOutTimingFunction. + // + // @since 2.0 + // + EaseInOutTimingFunction& operator =(const EaseInOutTimingFunction& rhs); +}; // EaseInOutTimingFunction + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_EASE_IN_OUT_TIMING_FUNCTION_H_ diff --git a/inc/FUiAnimEaseInTimingFunction.h b/inc/FUiAnimEaseInTimingFunction.h new file mode 100644 index 0000000..b057a6f --- /dev/null +++ b/inc/FUiAnimEaseInTimingFunction.h @@ -0,0 +1,104 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimEaseInTimingFunction.h + * @brief This is the header file for the %EaseInTimingFunction class. + * + * This header file contains the declarations of the %EaseInTimingFunction class. + */ + +#ifndef _FUI_ANIM_EASE_IN_TIMING_FUNCTION_H_ +#define _FUI_ANIM_EASE_IN_TIMING_FUNCTION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @class EaseInTimingFunction + * @brief This class stores the information of a ease-in timing function. + * + * @since 2.0 + * + * The %EaseInTimingFunction class provides ease-in timing function related information. + */ +class _OSP_EXPORT_ EaseInTimingFunction + : public Tizen::Base::Object + , public IVisualElementAnimationTimingFunction +{ +public: + + /** + * This is the constructor for this class. + * + * @since 2.0 + */ + EaseInTimingFunction(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~EaseInTimingFunction(void); + + + /** + * Calculates the progress(pace) of an animation regarding the time elapsed. + * + * @since 2.0 + * + * @return The progress(pace) value calculated by ease-in equation @n + * @c 0 and @c 1 are the start and end values of an animation, respectively. + * @param[in] timeProgress The time progress value @n + * This must be in the range @c 0.0 to @c 1.0. + */ + virtual float CalculateProgress(float timeProgress) const; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + EaseInTimingFunction(const EaseInTimingFunction& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %EaseInTimingFunction. + // + // @since 2.0 + // + EaseInTimingFunction& operator =(const EaseInTimingFunction& rhs); +}; // EaseInTimingFunction + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_EASE_IN_TIMING_FUNCTION_H_ diff --git a/inc/FUiAnimEaseOutInTimingFunction.h b/inc/FUiAnimEaseOutInTimingFunction.h new file mode 100644 index 0000000..a622fbc --- /dev/null +++ b/inc/FUiAnimEaseOutInTimingFunction.h @@ -0,0 +1,107 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimEaseOutInTimingFunction.h + * @brief This is the header file for the %EaseOutInTimingFunction class. + * + * This header file contains the declarations of the %EaseOutInTimingFunction class. + */ + +#ifndef _FUI_ANIM_EASE_OUT_IN_TIMING_FUNCTION_H_ +#define _FUI_ANIM_EASE_OUT_IN_TIMING_FUNCTION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @class EaseOutInTimingFunction + * @brief This class stores the information of a ease-outin timing function. + * + * @since 2.0 + * + * The %EaseOutInTimingFunction class provides ease-outin timing function related information. + * + * For more information on the class features, see Timing Function. + * + */ +class _OSP_EXPORT_ EaseOutInTimingFunction + : public Tizen::Base::Object + , public IVisualElementAnimationTimingFunction +{ +public: + + /** + * This is the constructor for this class. + * + * @since 2.0 + */ + EaseOutInTimingFunction(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~EaseOutInTimingFunction(void); + + + /** + * Calculates the progress(pace) of an animation regarding the time elapsed. + * + * @since 2.0 + * + * @return The progress(pace) value calculated by ease-outin equation @n + * @c 0 and @c 1 are the start and end values of an animation, respectively. + * @param[in] timeProgress The time progress value @n + * This must be in the range @c 0.0 to @c 1.0. + */ + virtual float CalculateProgress(float timeProgress) const; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + EaseOutInTimingFunction(const EaseOutInTimingFunction& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %EaseOutInTimingFunction. + // + // @since 2.0 + // + EaseOutInTimingFunction& operator =(const EaseOutInTimingFunction& rhs); +}; // EaseOutInTimingFunction + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_EASE_OUT_IN_TIMING_FUNCTION_H_ diff --git a/inc/FUiAnimEaseOutTimingFunction.h b/inc/FUiAnimEaseOutTimingFunction.h new file mode 100644 index 0000000..d69baa7 --- /dev/null +++ b/inc/FUiAnimEaseOutTimingFunction.h @@ -0,0 +1,104 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimEaseOutTimingFunction.h + * @brief This is the header file for the %EaseOutTimingFunction class. + * + * This header file contains the declarations of the %EaseOutTimingFunction class. + */ + +#ifndef _FUI_ANIM_EASE_OUT_TIMING_FUNCTION_H_ +#define _FUI_ANIM_EASE_OUT_TIMING_FUNCTION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @class EaseOutTimingFunction + * @brief This class stores the information of an ease-out timing function. + * + * @since 2.0 + * + * The %EaseOutTimingFunction class provides ease-out timing function related information. + */ +class _OSP_EXPORT_ EaseOutTimingFunction + : public Tizen::Base::Object + , public IVisualElementAnimationTimingFunction +{ +public: + + /** + * This is the constructor for this class. + * + * @since 2.0 + */ + EaseOutTimingFunction(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~EaseOutTimingFunction(void); + + + /** + * Calculates the progress(pace) of an animation regarding the time elapsed. + * + * @since 2.0 + * + * @return The progress(pace) value calculated by ease-out equation @n + * @c 0 and @c 1 are the start and end values of an animation, respectively. + * @param[in] timeProgress The time progress value @n + * This must be in the range @c 0.0 to @c 1.0. + */ + virtual float CalculateProgress(float timeProgress) const; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + EaseOutTimingFunction(const EaseOutTimingFunction& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %EaseOutTimingFunction. + // + // @since 2.0 + // + EaseOutTimingFunction& operator =(const EaseOutTimingFunction& rhs); +}; // EaseOutTimingFunction + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_EASE_OUT_TIMING_FUNCTION_H_ diff --git a/inc/FUiAnimExpInTimingFunction.h b/inc/FUiAnimExpInTimingFunction.h new file mode 100644 index 0000000..75c80ba --- /dev/null +++ b/inc/FUiAnimExpInTimingFunction.h @@ -0,0 +1,150 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimExpInTimingFunction.h + * @brief This is the header file for the %ExpInTimingFunction class. + * + * This header file contains the declarations of the %ExpInTimingFunction class. + */ + +#ifndef _FUI_ANIM_EXP_IN_TIMING_FUNCTION_H_ +#define _FUI_ANIM_EXP_IN_TIMING_FUNCTION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @class ExpInTimingFunction + * @brief This class stores the information of an exp-in timing function. + * + * @since 2.0 + * + * The %ExpInTimingFunction class provides exp-in timing function related information. + * + * For more information on the class features, see Timing Function. + * + */ +class _OSP_EXPORT_ ExpInTimingFunction + : public Tizen::Base::Object + , public IVisualElementAnimationTimingFunction +{ +public: + + /** + * This is the constructor for this class. + * + * @since 2.0 + */ + ExpInTimingFunction(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~ExpInTimingFunction(void); + + + /** + * Calculates the progress(pace) of an animation regarding the time elapsed. + * + * @since 2.0 + * + * @return The progress(pace) value calculated by exp-in equation with scale value @n + * @c 0 and @c 1 are the start and end values of an animation, respectively. + * @param[in] timeProgress The time progress value @n + * This must be in the range @c 0.0 to @c 1.0. + */ + virtual float CalculateProgress(float timeProgress) const; + + + /** + * Sets the scale value. + * + * @since 2.0 + * + * @return An error code + * @param[in] scale The scale value + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is @c 0.0 or negative. + * @see GetScaleValue() + */ + result SetScaleValue(float scale); + + + /** + * Gets the scale value. + * + * @since 2.0 + * + * @return The scale value + * @see SetScaleValue() + */ + float GetScaleValue(void) const; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + ExpInTimingFunction(const ExpInTimingFunction& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %ExpInTimingFunction. + // + // @since 2.0 + // + ExpInTimingFunction& operator =(const ExpInTimingFunction& rhs); + + +private: + + /** + * The scale value. + * + * @since 2.0 + */ + float __scale; + + + /** + * The divisor for exponential timing function. + * + * @since 2.0 + */ + float __divisor; +}; // ExpInTimingFunction + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_EXP_IN_TIMING_FUNCTION_H_ diff --git a/inc/FUiAnimExpOutTimingFunction.h b/inc/FUiAnimExpOutTimingFunction.h new file mode 100644 index 0000000..d08cd1d --- /dev/null +++ b/inc/FUiAnimExpOutTimingFunction.h @@ -0,0 +1,148 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimExpOutTimingFunction.h + * @brief This is the header file for the %ExpOutTimingFunction class. + * + * This header file contains the declarations of the %ExpOutTimingFunction class. + */ + +#ifndef _FUI_ANIM_EXP_OUT_TIMING_FUNCTION_H_ +#define _FUI_ANIM_EXP_OUT_TIMING_FUNCTION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @class ExpOutTimingFunction + * @brief This class stores the information of an exp-out timing function. + * + * @since 2.0 + * + * The %ExpOutTimingFunction class provides exp-out timing function related information. + * + * For more information on the class features, see Timing Function. + * + */ +class _OSP_EXPORT_ ExpOutTimingFunction + : public Tizen::Base::Object + , public IVisualElementAnimationTimingFunction +{ +public: + + /** + * This is the constructor for this class. + * + * @since 2.0 + */ + ExpOutTimingFunction(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~ExpOutTimingFunction(void); + + + /** + * Calculates the progress(pace) of an animation regarding the time elapsed. + * + * @since 2.0 + * + * @return The progress(pace) value calculated by exp-in equation with scale value @n + * @c 0 and @c 1 are the start and end values of an animation, respectively. + * @param[in] timeProgress The time progress value @n + * This must be in the range @c 0.0 to @c 1.0. + */ + virtual float CalculateProgress(float timeProgress) const; + + + /** + * Sets the scale value. + * + * @since 2.0 + * + * @return An error code + * @param[in] scale The scale value + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is @c 0.0 or negative. + * @see GetScaleValue() + */ + result SetScaleValue(float scale); + + + /** + * Gets the scale value. + * + * @since 2.0 + * + * @return The scale value + * @see SetScaleValue() + */ + float GetScaleValue(void) const; + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + ExpOutTimingFunction(const ExpOutTimingFunction& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %ExpOutTimingFunction. + // + // @since 2.0 + // + ExpOutTimingFunction& operator =(const ExpOutTimingFunction& rhs); + + +private: + + /** + * The scale value. + * + * @since 2.0 + */ + float __scale; + + /** + * The divisor for exponential timing function. + * + * @since 2.0 + */ + float __divisor; +}; // ExpOutTimingFunction + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_EXP_OUT_TIMING_FUNCTION_H_ diff --git a/inc/FUiAnimFloatAnimation.h b/inc/FUiAnimFloatAnimation.h new file mode 100644 index 0000000..360c417 --- /dev/null +++ b/inc/FUiAnimFloatAnimation.h @@ -0,0 +1,333 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimFloatAnimation.h + * @brief This is the header file for the %FloatAnimation class. + * + * This header file contains the declaration of the %FloatAnimation class. + */ + +#ifndef _FUI_ANIM_FLOAT_ANIMATION_H_ +#define _FUI_ANIM_FLOAT_ANIMATION_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class FloatAnimation + * @brief This class animates an object from a float value to another float value. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %FloatAnimation class animates an object from a float value to another float value based on the specified interpolator type. + * + * For more information on the class features, see Animating UI Controls. + * + */ +class _OSP_EXPORT_ FloatAnimation + : public AnimationBase +{ +public: + /** + * Initializes this instance of %FloatAnimation with the specified parameters. + * + * @since 2.0 + * + * @param[in] startValue The start value for float animation + * @param[in] endValue The end value for float animation + * @param[in] duration The duration of animation in milliseconds + * @param[in] interpolator The type of interpolation used for the intermediate value calculation of the animation + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative or the interpolator is of an invalid type. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + FloatAnimation(float startValue, float endValue, long duration, AnimationInterpolatorType interpolator); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~FloatAnimation(void); + + + /** + * Assigns the value of the specified instance to the current instance of %FloatAnimation. + * + * @since 2.0 + * + * @param[in] floatAnimation An instance of %FloatAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + FloatAnimation(const FloatAnimation& floatAnimation); + + + /** + * Assigns the value of the specified instance to the current instance of %FloatAnimation. + * + * @since 2.0 + * + * @param[in] rhs An instance of %FloatAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + FloatAnimation& operator =(const FloatAnimation& rhs); + + + /** + * Checks whether the specified instance and current instance of %FloatAnimation have equal animation values. + * + * @since 2.0 + * + * @return @c true if the animation of the two instances of %FloatAnimation are equal, @n + * else @c false + * @param[in] rhs An instance of %FloatAnimation + */ + bool operator ==(const FloatAnimation& rhs) const; + + + /** + * Checks whether the specified instance and current instance of %FloatAnimation have different animation values. + * + * @since 2.0 + * + * @return @c true if the values of the animations of the two instances of %FloatAnimation are not equal, @n + * else @c false + * @param[in] rhs An instance of %FloatAnimation + */ + bool operator !=(const FloatAnimation& rhs) const; + + + /** + * Checks whether the value of the current instance of %FloatAnimation equals the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance equals the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %FloatAnimation + * @remarks The %FloatAnimation class has a semantic value. @n + * This means that this method checks whether the two instances have the same animation. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The two equal instances must return the same hash value. For better performance, the used hash function must generate a random distribution + * for all inputs. + */ + virtual int GetHashCode(void) const; + + + /** + * Gets the animated value for the current time. + * + * @since 2.0 + * + * @return An error code + * @param[in] currentTime The current time value of the animation play @n + * The value must be between @c 0 and the duration of the animation. + * @param[out] animatedValue The animated value for the @c currentTime passed as input + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result GetAnimatedValue(long currentTime, float& animatedValue) const; + + + /** + * Adds a key frame to the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] time The time stamp + * @param[in] value The value at the specified @c time + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If @c time is greater than the duration, it becomes the new @c duration and value becomes the new @c endValue. + * Also the old @c duration and @c endValue are added as a new key frame entry in the list. + * @remarks If a key-value pair with the current key already exists, the old value is overwritten with the new value. + * @remarks An exception is returned if the @c time is equal to @c 0 or the duration of the animation. + */ + result AddKeyFrame(long time, float value); + + + /** + * Gets the keyframe at a particular index in this animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index value in the Keyframe list @n + * This value is sorted in an increasing order of time. + * @param[out] time The time stamp at the specified @c index + * @param[out] value The value at the specified @c index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks The @c time and @c value returned, are the one present at the index of the sorted map list (sorted with respect to key). + * For example, if the user adds keyframe in the order (10,value1), (20,value2), (5,value3), and + * the GetKeyFrameAt (0,time,value) is called, the pair returned is (5,value3). + */ + result GetKeyFrameAt(int index, long& time, float& value) const; + + + /** + * Removes the passed keyframe object from the keyframe list. + * + * @since 2.0 + * + * @return An error code + * @param[in] time The key frame time + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c time is invalid. + * @exception E_OBJ_NOT_FOUND The specified @c time is not found in the KeyFrame List. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveKeyFrame(long time); + + + /** + * Removes the keyframe present at the specified @c index from the keyframe list. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index value in the Keyframe list @n + * This value is sorted in an increasing order of time. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveKeyFrameAt(int index); + + + /** + * Removes all the keyframes from the animation. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveAllKeyFrames(void); + + + /** + * Sets the start value of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] startValue The start value of the animation to set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetStartValue(float startValue); + + + /** + * Sets the end value of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] endValue The end value of the animation to set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetEndValue(float endValue); + + + /** + * Gets the start value of the animation. + * + * @since 2.0 + * + * @return The start value + */ + float GetStartValue(void) const; + + + /** + * Gets the end value of the animation. + * + * @since 2.0 + * + * @return The end value + */ + float GetEndValue(void) const; + + + /** + * Gets the type information of this instance. + * + * @since 2.0 + * + * @return The type information of this instance + */ + virtual AnimationType GetType(void) const; + + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the default constructor for this class. + // + // @since 2.0 + // + FloatAnimation(void); + + + friend class _FloatAnimationImpl; + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The variable for internal usage. + // + // @since 2.0 + // + class _FloatAnimationImpl* _pFloatAnimationImpl; +}; // FloatAnimation + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_FLOAT_ANIMATION_H_ diff --git a/inc/FUiAnimFrameAnimator.h b/inc/FUiAnimFrameAnimator.h new file mode 100644 index 0000000..683632d --- /dev/null +++ b/inc/FUiAnimFrameAnimator.h @@ -0,0 +1,274 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimFrameAnimator.h + * @brief This is the header file for the %FrameAnimator class. + * + * This header file contains the declarations of the %FrameAnimator class. + */ + +#ifndef _FUI_ANIM_FRAME_ANIMATOR_H_ +#define _FUI_ANIM_FRAME_ANIMATOR_H_ + +#include + + +namespace Tizen { namespace Ui { namespace Controls +{ +class Form; +class _FrameImpl; +} } } + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @class FrameAnimator + * @brief This class defines the animation methods for Frame. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %FrameAnimator class is used to control the animations operated on a Frame. + * + * For more information on the class features, see Animating a Form Transition. + * + */ +class _OSP_EXPORT_ FrameAnimator + : public Tizen::Base::Object +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~FrameAnimator(void); + + + /** + * Adds an IFrameAnimatorEventListener instance to the current instance of the frame. @n + * The added listener can listen to events on the given event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The animation support is unavailable. + * @exception E_OBJ_ALREADY_EXIST The specified @c listener is already added. + * @exception E_SYSTEM A system error has occurred. + */ + result AddFrameAnimatorEventListener(IFrameAnimatorEventListener& listener); + + + /** + * Removes an IFrameAnimatorEventListener instance from the current instance of the frame. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The animation support is unavailable. + * @exception E_OBJ_NOT_FOUND The specified @c listener is not found. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveFrameAnimatorEventListener(IFrameAnimatorEventListener& listener); + + + /** + * Gets the animation status of the frame animator. + * + * @since 2.0 + * + * @return The animation state of the frame animator + */ + AnimatorStatus GetStatus(void) const; + + + /** + * Sets the specified form as the current form of the frame with an animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] form The form object to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + * @remarks Control::Invalidate() need not be called to display the form. @n + * To select the animation to be used during this method, use SetFormTransitionAnimation() before calling this method. + */ + result SetCurrentForm(const Tizen::Ui::Controls::Form& form); + + + /** + * Sets the type of the form transition animation. + * + * @since 2.0 + * + * @param[in] animation The type of form transition animation to set + * @param[in] duration The duration of animation in milliseconds @n + * The maximum duration is one second. + * @param[in] interpolator The type of interpolator used for the intermediate value calculation of the animation + */ + void SetFormTransitionAnimation(FrameAnimatorFormTransitionAnimation animation, long duration, AnimationInterpolatorType interpolator); + + + /** + * Gets the type of the form transition animation. + * + * @since 2.0 + * + * @param[out] animation The type of form transition animation used + * @param[out] duration The duration of animation in milliseconds + * @param[out] interpolator The type of interpolator used for the intermediate value calculation of the animation + */ + void GetFormTransitionAnimation(FrameAnimatorFormTransitionAnimation& animation, long& duration, AnimationInterpolatorType& interpolator) const; + + + /** + * Sets the control points for the Bezier interpolator. @n + * The %SetFormTransitionBezierControlPoints() method is supported only if the interpolator is @c ANIMATION_INTERPOLATOR_BEZIER. + * + * @since 2.0 + * + * @return An error code + * @param[in] time1 The control point 1 - Time @n + * The time must be within the range @c 0.0 to @c 1.0. + * @param[in] value1 The control point 1 - Value @n + * The value must be within the range @c 0.0 to @c 1.0. + * @param[in] time2 The control point 2 - Time @n + * The time must be within the range @c 0.0 to @c 1.0. + * @param[in] value2 The control point 2 - Value @n + * The value must be within the range @c 0.0 to @c 1.0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The interpolator of this instance is not ANIMATION_INTERPOLATOR_BEZIER. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result SetFormTransitionBezierControlPoints(float time1, float value1, float time2, float value2); + + + /** + * Gets the control points of the Bezier interpolator. @n + * The %GetFormTransitionBezierControlPoints() method is supported only if the interpolator is @c ANIMATION_INTERPOLATOR_BEZIER. @n + * Therefore, @c 0 will be returned for other interpolators. + * + * @since 2.0 + * + * @return An error code + * @param[out] time1 The control point 1 - Time + * @param[out] value1 The control point 1 - Value + * @param[out] time2 The control point 2 - Time + * @param[out] value2 The control point 2 - Value + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The interpolator of this instance is not ANIMATION_INTERPOLATOR_BEZIER. + */ + result GetFormTransitionBezierControlPoints(float& time1, float& value1, float& time2, float& value2) const; + + + /** + * Stops all the animations that are being played and jumps to the final frame of the animation. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result StopAllAnimations(void); + + +protected: + + friend class _FrameAnimatorImpl; + + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The variable for internal usage. + // + // @since 2.0 + // + class _FrameAnimatorImpl* _pFrameAnimatorImpl; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the constructor for this class. + // + // @since 2.0 + // + FrameAnimator(void); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Initializes this class. + // + // @since 2.0 + // @return An error code + // @param[in] source An instance of the Frame class + // @exception E_SUCCESS The method is successful. + // @exception E_SYSTEM A system error has occurred. + // + result Construct(const Tizen::Ui::Controls::Frame& source); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the copy constructor for the %FrameAnimator class. + // + // @since 2.0 + // + FrameAnimator(const FrameAnimator& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %FrameAnimator. + // + // @since 2.0 + // + FrameAnimator& operator =(const FrameAnimator& rhs); + + + friend class Tizen::Ui::Controls::_FrameImpl; +}; // FrameAnimator + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_FRAME_ANIMATOR_H_ diff --git a/inc/FUiAnimIAnimationTransactionEventListener.h b/inc/FUiAnimIAnimationTransactionEventListener.h new file mode 100644 index 0000000..c7b11c0 --- /dev/null +++ b/inc/FUiAnimIAnimationTransactionEventListener.h @@ -0,0 +1,134 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIAnimationTransactionEventListener.h + * @brief This is the header file for the %IAnimationTransactionEventListener interface. + * + * This header file contains the declarations of the %IAnimationTransactionEventListener interface. + */ + +#ifndef _FUI_ANIM_IANIMATION_TRANSACTION_EVENT_LISTENER_H_ +#define _FUI_ANIM_IANIMATION_TRANSACTION_EVENT_LISTENER_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @interface IAnimationTransactionEventListener + * @brief This interface implements the listener for the animation transaction events defined in the Tizen::Ui::Animations namespace. + * + * @since 2.0 + * + * The %IAnimationTransactionEventListener interface is the listener interface for receiving animation transaction events. + * The class that processes an animation transaction event implements this interface, and the instance created with that class is + * registered with AnimationTransaction, using the AnimationTransaction::SetTransactionEventListener() method. When the animation + * transaction event occurs, a method of that instance is invoked. + * + */ +class _OSP_EXPORT_ IAnimationTransactionEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IAnimationTransactionEventListener(void) {} + + + /** + * Called when the transaction starts. + * + * @since 2.0 + * + * @param[in] transactionId The transaction ID of the transaction for which the event has occurred + */ + virtual void OnAnimationTransactionStarted(int transactionId) = 0; + + + /** + * Called when the transaction stops. + * + * @since 2.0 + * + * @param[in] transactionId The transaction ID of the transaction for which the event has occurred + * @remarks This callback is called when user calls AnimationTransaction::Stop(). + */ + virtual void OnAnimationTransactionStopped(int transactionId) = 0; + + + /** + * Called when the transaction is finished. + * + * @since 2.0 + * + * @param[in] transactionId The ID of the transaction for which the event has occurred + * @remarks This callback is called when all the animations in a transaction are finished. + */ + virtual void OnAnimationTransactionFinished(int transactionId) = 0; + + +protected: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IAnimationTransactionEventListener_Reserved1(void) { } + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IAnimationTransactionEventListener_Reserved2(void) { } + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IAnimationTransactionEventListener_Reserved3(void) { } +}; // IAnimationTransactionEventListener + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_IANIMATION_TRANSACTION_EVENT_LISTENER_H_ diff --git a/inc/FUiAnimIControlAnimatorDetailedEventListener.h b/inc/FUiAnimIControlAnimatorDetailedEventListener.h new file mode 100644 index 0000000..42c4d4f --- /dev/null +++ b/inc/FUiAnimIControlAnimatorDetailedEventListener.h @@ -0,0 +1,195 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIControlAnimatorDetailedEventListener.h + * @brief This is the header file for the %IControlAnimatorDetailedEventListener interface. + * + * This header file contains the declarations of the %IControlAnimatorDetailedEventListener interface. + */ + +#ifndef _FUI_ANIM_ICONTROL_ANIMATOR_DETAILED_EVENT_LISTENER_H_ +#define _FUI_ANIM_ICONTROL_ANIMATOR_DETAILED_EVENT_LISTENER_H_ + +#include +#include +#include + +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } +namespace Tizen { namespace Ui { namespace Animations +{ +class ControlAnimator; +} } } +namespace Tizen { namespace Ui { namespace Animations +{ + + + +/** + * @interface IControlAnimatorDetailedEventListener + * @brief This interface implements a detailed listener for animation events. + * + * @since 2.0 + * + * The %IControlAnimatorDetailedEventListener interface is the listener interface for receiving detailed control animator events. + * The class that processes a detailed control animator event implements this interface, and the instance created with that class + * is registered with a UI control, using the ControlAnimator::AddControlAnimatorDetailedEventListener() method. When the detailed + * control animator event occurs, a method of that instance is invoked. + */ +class _OSP_EXPORT_ IControlAnimatorDetailedEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IControlAnimatorDetailedEventListener(void) {} + + + /** + * Called when an animation starts. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] control The control @n + * The animation starts on this control. + * @param[in] animTrigger The animator trigger type of the control @n + * The animation event has occurred for the specified trigger type. + * @param[in] animTarget The animation target type @n + * The animation event has occurred for the specified animation target type. In the case of implicit animations, + * @c animTarget is @c ANIMATION_TARGET_NONE. + * @param[in] pAnimation The animation object @n + * The event occurs for this animation object. In the case of implicit animations (animations not defined by the + * application), @c pAnimation is @c null. + */ + virtual void OnControlAnimationStarted(Tizen::Ui::Animations::ControlAnimator& source, Tizen::Ui::Control& control, Tizen::Ui::Animations::ControlAnimatorTriggerType animTrigger, Tizen::Ui::Animations::AnimationTargetType animTarget, Tizen::Ui::Animations::AnimationBase* pAnimation) = 0; + + + /** + * Called when an animation is repeated. @n + * This event occurs only when a user calls StartUserAnimation(). + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] control The control @n + * The animation is repeated on this control. + * @param[in] animTrigger The animator trigger type of the control @n + * The animation event has occurred for the specified trigger type. + * @param[in] animTarget The animation target type @n + * The animation event has occurred for the specified animation target type. In the case of implicit animations, + * @c animTarget is @c ANIMATION_TARGET_NONE. + * @param[in] pAnimation The animation object @n + * The event occurs for this animation object. In the case of implicit animations (animations not defined by the + * application), @c pAnimation is @c null. + * @param[in] repeatCount The current repeat count of the animation + */ + virtual void OnControlAnimationRepeated(Tizen::Ui::Animations::ControlAnimator& source, Tizen::Ui::Control& control, Tizen::Ui::Animations::ControlAnimatorTriggerType animTrigger, Tizen::Ui::Animations::AnimationTargetType animTarget, Tizen::Ui::Animations::AnimationBase* pAnimation, int repeatCount) = 0; + + + /** + * Called when an animation finishes. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] control The control @n + * The animation with the specified trigger type has finished for this control. + * @param[in] animTrigger The animator trigger type of the control @n + * The animation event has occurred for the specified trigger type. + * @param[in] animTarget The animation target type @n + * The animation event has occurred for the specified animation target type. In the case of implicit animations, + * @c animTarget is @c ANIMATION_TARGET_NONE. + * @param[in] pAnimation The animation object @n + * The event occurs for this animation object. In the case of implicit animations (animations not defined by the + * application), @c pAnimation is @c null. + */ + virtual void OnControlAnimationFinished(Tizen::Ui::Animations::ControlAnimator& source, Tizen::Ui::Control& control, Tizen::Ui::Animations::ControlAnimatorTriggerType animTrigger, Tizen::Ui::Animations::AnimationTargetType animTarget, Tizen::Ui::Animations::AnimationBase* pAnimation) = 0; + + + /** + * Called when an animation stops. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] control The control @n + * The animation with the specified trigger type has stopped for this control. + * @param[in] animTrigger The animator trigger type of the control @n + * The animation event has occurred for the specified trigger type. + * @param[in] animTarget The animation target type @n + * The animation event has occurred for the specified animation target type. In the case of implicit animations, + * @c animTarget is @c ANIMATION_TARGET_NONE. + * @param[in] pAnimation The animation object @n + * The event occurs for this animation object. In the case of implicit animations (animations not defined by the + * application), @c pAnimation is @c null. + */ + virtual void OnControlAnimationStopped(Tizen::Ui::Animations::ControlAnimator& source, Tizen::Ui::Control& control, Tizen::Ui::Animations::ControlAnimatorTriggerType animTrigger, Tizen::Ui::Animations::AnimationTargetType animTarget, Tizen::Ui::Animations::AnimationBase* pAnimation) = 0; + + +protected: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IControlAnimatorDetailedEventListener_Reserved1(void) { } + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IControlAnimatorDetailedEventListener_Reserved2(void) { } + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IControlAnimatorDetailedEventListener_Reserved3(void) { } +}; // IControlAnimatorDetailedEventListener + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_ICONTROL_ANIMATOR_DETAILED_EVENT_LISTENER_H_ diff --git a/inc/FUiAnimIControlAnimatorEventListener.h b/inc/FUiAnimIControlAnimatorEventListener.h new file mode 100644 index 0000000..57e91f8 --- /dev/null +++ b/inc/FUiAnimIControlAnimatorEventListener.h @@ -0,0 +1,146 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIControlAnimatorEventListener.h + * @brief This is the header file for the %IControlAnimatorEventListener interface. + * + * This header file contains the declarations of the %IControlAnimatorEventListener interface. + */ + +#ifndef _FUI_ANIM_ICONTROL_ANIMATOR_EVENT_LISTENER_H_ +#define _FUI_ANIM_ICONTROL_ANIMATOR_EVENT_LISTENER_H_ + +#include +#include +#include + +#include + + +namespace Tizen { namespace Ui +{ +class Control; +} } +namespace Tizen { namespace Ui { namespace Animations +{ +class ControlAnimator; +} } } + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @interface IControlAnimatorEventListener + * @brief This interface implements the listener for animation events. + * + * @since 2.0 + * + * The %IControlAnimatorEventListener interface is the listener interface for receiving control animator events. + * The class that processes a control animator event implements this interface, and the instance created with that class is + * registered with a UI control, using the ControlAnimator::AddControlAnimatorEventListener() method. When the control animator event + * occurs, a method of that instance is invoked. + */ +class _OSP_EXPORT_ IControlAnimatorEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IControlAnimatorEventListener(void) {} + + + /** + * Called when an animation starts on the specified control. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] control The control on which an animation starts + */ + virtual void OnControlAnimationStarted(Tizen::Ui::Animations::ControlAnimator& source, Tizen::Ui::Control& control) = 0; + + + /** + * Called when all the animations currently associated with a control have finished. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] control The control on which all the animations have finished + */ + virtual void OnControlAnimationFinished(Tizen::Ui::Animations::ControlAnimator& source, Tizen::Ui::Control& control) = 0; + + + /** + * Called when all the animations currently associated with a control have stopped. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] control The control on which all the animations have stopped + */ + virtual void OnControlAnimationStopped(Tizen::Ui::Animations::ControlAnimator& source, Tizen::Ui::Control& control) = 0; + + +protected: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IControlAnimatorEventListener_Reserved1(void) { } + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IControlAnimatorEventListener_Reserved2(void) { } + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IControlAnimatorEventListener_Reserved3(void) { } +}; // IControlAnimatorEventListener + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_ICONTROL_ANIMATOR_EVENT_LISTENER_H_ diff --git a/inc/FUiAnimIFrameAnimatorEventListener.h b/inc/FUiAnimIFrameAnimatorEventListener.h new file mode 100644 index 0000000..619ba36 --- /dev/null +++ b/inc/FUiAnimIFrameAnimatorEventListener.h @@ -0,0 +1,166 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIFrameAnimatorEventListener.h + * @brief This is the header file for the %IFrameAnimatorEventListener interface. + * + * This header file contains the declarations of the %IFrameAnimatorEventListener interface. + */ + +#ifndef _FUI_CTRL_IFRAME_ANIMATOR_EVENT_LISTENER_H_ +#define _FUI_CTRL_IFRAME_ANIMATOR_EVENT_LISTENER_H_ + +#include +#include +#include +#include +#include + + +namespace Tizen { namespace Ui { namespace Controls +{ +class Form; +} } } +namespace Tizen { namespace Ui { namespace Controls +{ +class Frame; +} } } +namespace Tizen { namespace Ui { namespace Animations +{ +class FrameAnimator; +} } } + +namespace Tizen { namespace Ui { namespace Animations +{ + + + +/** + * @interface IFrameAnimatorEventListener + * @brief This interface implements the listener for animation events. + * + * @since 2.0 + * + * The %IFrameAnimatorEventListener interface is the listener interface for receiving frame animator events. + * The class that processes a frame animator event implements this interface, and the instance created with that class is + * registered with a Frame, using the FrameAnimator::AddFrameAnimatorEventListener() method. When the frame animator event occurs, a + * method of that instance is invoked. + */ +class _OSP_EXPORT_ IFrameAnimatorEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IFrameAnimatorEventListener(void) {} + + + /** + * Called when the animation of a form transition starts. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] frame The frame @n + * The frame that starts the animation of a form transition. + * @param[in] form1 The form @n + * The animation starts on this form. + * @param[in] form2 The form @n + * The animation starts on this form. + */ + virtual void OnFormTransitionAnimationStarted(Tizen::Ui::Animations::FrameAnimator& source, Tizen::Ui::Controls::Frame& frame, Tizen::Ui::Controls::Form& form1, Tizen::Ui::Controls::Form& form2) = 0; + + + /** + * Called when the animation of a form transition stops. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] frame The frame @n + * The frame that stops the animation of a form transition. + * @param[in] form1 The form @n + * The animation stops on this form. + * @param[in] form2 The form @n + * The animation stops on this form. + */ + virtual void OnFormTransitionAnimationStopped(Tizen::Ui::Animations::FrameAnimator& source, Tizen::Ui::Controls::Frame& frame, Tizen::Ui::Controls::Form& form1, Tizen::Ui::Controls::Form& form2) = 0; + + + /** + * Called when the animation of a form transition finishes. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] frame The frame @n + * The frame that finishes the animation of a form transition. + * @param[in] form1 The form @n + * The animation finishes on this form. + * @param[in] form2 The form @n + * The animation finishes on this form. + */ + virtual void OnFormTransitionAnimationFinished(Tizen::Ui::Animations::FrameAnimator& source, Tizen::Ui::Controls::Frame& frame, Tizen::Ui::Controls::Form& form1, Tizen::Ui::Controls::Form& form2) = 0; + + +protected: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IFrameAnimatorEventListener_Reserved1(void) { } + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IFrameAnimatorEventListener_Reserved2(void) { } + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IFrameAnimatorEventListener_Reserved3(void) { } +}; // IFrameAnimatorEventListener + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_IFRAME_ANIMATOR_EVENT_LISTENER_H_ diff --git a/inc/FUiAnimIVisualElementAnimationProvider.h b/inc/FUiAnimIVisualElementAnimationProvider.h new file mode 100644 index 0000000..e896c22 --- /dev/null +++ b/inc/FUiAnimIVisualElementAnimationProvider.h @@ -0,0 +1,147 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIVisualElementAnimationProvider.h + * @brief This is the header file for the %IVisualElementAnimationProvider interface. + * + * This header file contains the declarations of the %IVisualElementAnimationProvider interface. + */ + +#ifndef _FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_PROVIDER_H_ +#define _FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_PROVIDER_H_ + +#include + +namespace Tizen { namespace Base { +class String; +}} // Tizen::Base + +namespace Tizen { namespace Ui { namespace Animations +{ + +class VisualElement; +class VisualElementAnimation; + +/** +* @interface IVisualElementAnimationProvider +* @brief This interface implements the provider for the events generated by the VisualElement. +* +* @since 2.0 +* +* The %IVisualElementAnimationProvider interface customizes implicit animations. The class that needs to override default implicit animations must implement this interface, and +* the instance created with that class is registered with VisualElement, using the VisualElement::SetAnimationProvider() method. +* When the properties defined in %VisualElement and its descendants are changed, the CreateAnimationForProperty() method of this interface is invoked. +* +* For more information on the class features, see Implicit and Explicit Animations. +* +*/ +class _OSP_EXPORT_ IVisualElementAnimationProvider +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IVisualElementAnimationProvider(void) {} + +public: + /** + * Invoked for creating an animation when the property is changed. + * + * @since 2.0 + * + * @return A VisualElementAnimation instance for @c property + * @param[in] target The VisualElement instance that needs implicit animation + * @param[in] property The property of this instance for which animation is required + * @remarks If implicit animation for @c property is not required, return @c null. + */ + virtual Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationForProperty(Tizen::Ui::Animations::VisualElement& target, const Tizen::Base::String& property) = 0; + + +protected: + // Reserved virtual methods for later extension. + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementAnimationProvider_Reserved1(void) {} + + + // Reserved virtual methods for later extension. + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementAnimationProvider_Reserved2(void) {} + + + // Reserved virtual methods for later extension. + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementAnimationProvider_Reserved3(void) {} + + + // Reserved virtual methods for later extension. + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementAnimationProvider_Reserved4(void) {} + + + // Reserved virtual methods for later extension. + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementAnimationProvider_Reserved5(void) {} +}; // IVisualElementAnimationProvider + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_PROVIDER_H_ diff --git a/inc/FUiAnimIVisualElementAnimationStatusEventListener.h b/inc/FUiAnimIVisualElementAnimationStatusEventListener.h new file mode 100644 index 0000000..4263ec0 --- /dev/null +++ b/inc/FUiAnimIVisualElementAnimationStatusEventListener.h @@ -0,0 +1,151 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIVisualElementAnimationStatusEventListener.h + * @brief This is the header file for the %IVisualElementAnimationStatusEventListener interface. + * + * This header file contains the declarations of the %IVisualElementAnimationStatusEventListener interface. + */ + +#ifndef _FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_STATUS_EVENT_LISTENER_H_ +#define _FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_STATUS_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Base { +class String; +}} // Tizen::Base + +namespace Tizen { namespace Ui { namespace Animations +{ + +class VisualElement; +class VisualElementAnimation; + +/** + * @interface IVisualElementAnimationStatusEventListener + * @brief This interface implements the listener for the VisualElementAnimation status events defined in the Tizen::Ui::Animations namespace. + * + * @since 2.0 + * + * The %IVisualElementAnimationStatusEventListener interface is the listener interface for receiving animation status events. + * The class that processes an animation status event implements this interface, and the instance created with that class is + * registered with an animation, using the VisualElementAnimation::SetVisualElementAnimationStatusEventListener() method or + * the AnimationTransaction::SetVisualElementAnimationStatusEventListener() method. + * When the animation status is changing, a method of that instance is invoked. + * + * For more information on the class features, see Event Handling. + * + */ +class _OSP_EXPORT_ IVisualElementAnimationStatusEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IVisualElementAnimationStatusEventListener(void); + + + /** + * Called when the animation is started. + * + * @since 2.0 + * + * @param[in] animation The animation that is started + * @param[in] keyName The key name of the animation + * @param[in] target An instance of VisualElement to which the animation is applied + * @remarks If the key name of the animation is not set, @c keyName is empty string. + */ + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target) = 0; + + + /** + * Called when the animation is repeated. + * + * @since 2.0 + * + * @param[in] animation The animation that is repeated + * @param[in] keyName The key name of the animation + * @param[in] target An instance of VisualElement to which the animation is applied + * @param[in] currentRepeatCount The current repeat count + * @remarks If the key name of the animation is not set, @c keyName is empty string. + */ + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount) = 0; + + + /** + * Called when the animation is finished. + * + * @since 2.0 + * + * @param[in] animation The animation that is finished + * @param[in] keyName The key name of the animation + * @param[in] target An instance of VisualElement to which the animation is applied + * @param[in] completedNormally @c true if the animation is completed normally, @n + * else @c false + * @remarks If the key name of the animation is not set, @c keyName is empty string. + */ + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally) = 0; + + +protected: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementAnimationStatusEventListener_Reserved1(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementAnimationStatusEventListener_Reserved2(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementAnimationStatusEventListener_Reserved3(void) {} +}; // IVisualElementAnimationStatusEventListener + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_STATUS_EVENT_LISTENER_H_ diff --git a/inc/FUiAnimIVisualElementAnimationTickEventListener.h b/inc/FUiAnimIVisualElementAnimationTickEventListener.h new file mode 100644 index 0000000..6fda443 --- /dev/null +++ b/inc/FUiAnimIVisualElementAnimationTickEventListener.h @@ -0,0 +1,120 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIVisualElementAnimationTickEventListener.h + * @brief This is the header file for the %IVisualElementAnimationTickEventListener interface. + * + * This header file contains the declarations of the %IVisualElementAnimationTickEventListener interface. + */ + +#ifndef _FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_TICK_EVENT_LISTENER_H_ +#define _FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_TICK_EVENT_LISTENER_H_ + +#include + +#include +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @interface IVisualElementAnimationTickEventListener + * @brief This interface implements the listener for the VisualElementAnimation tick events defined in the Tizen::Ui::Animations namespace. + * + * @since 2.0 + * + * The %IVisualElementAnimationTickEventListener interface is the listener interface for receiving animation tick events. + * The class that processes an animation tick event implements this interface, and the instance created with that class is registered with an animation, + * using the VisualElementValueAnimation::SetVisualElementAnimationTickEventListener() method. + * When the animation tick event occurs, a method of that instance is invoked. + * + * For more information on the class features, see Event Handling. + * + */ +class _OSP_EXPORT_ IVisualElementAnimationTickEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IVisualElementAnimationTickEventListener(void); + + + /** + * Called when a tick event has occurred. @n + * The %OnTickOccurred() callback method will be called with every tick of the animation, using the current value by the UI framework. + * + * @since 2.0 + * + * @param[in] animation The animation that is running + * @param[in] keyName The key name of the animation + * @param[in] target The VisualElement object to which the animation is applied + * @param[in] currentValue The current value + */ + virtual void OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue) = 0; + + +protected: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementAnimationTickEventListener_Reserved1(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementAnimationTickEventListener_Reserved2(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementAnimationTickEventListener_Reserved3(void) {} +}; // IVisualElementAnimationTickEventListener + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_TICK_EVENT_LISTENER_H_ diff --git a/inc/FUiAnimIVisualElementAnimationTimingFunction.h b/inc/FUiAnimIVisualElementAnimationTimingFunction.h new file mode 100644 index 0000000..440bcf2 --- /dev/null +++ b/inc/FUiAnimIVisualElementAnimationTimingFunction.h @@ -0,0 +1,109 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIVisualElementAnimationTimingFunction.h + * @brief This is the header file for the %IVisualElementAnimationTimingFunction interface. + * + * This header file contains the declarations of the %IVisualElementAnimationTimingFunction interface. + */ + +#ifndef _FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_TIMING_FUNCTION_H_ +#define _FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_TIMING_FUNCTION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @interface IVisualElementAnimationTimingFunction + * @brief This interface implements the timing function for the VisualElementAnimation defined in the Tizen::Ui::Animations namespace. + * + * @since 2.0 + * + * The %IVisualElementAnimationTimingFunction interface is the timing function interface for the pacing of an animation. + * The class that defines the pacing of an animation as a timing curve implements this interface, + * and the instance created with that class is registered with an animation, + * using the VisualElementAnimation::SetTimingFunction() method or the AnimationTransaction::SetVisualElementAnimationTimingFunction() method. + * When tick of the animation occurs, a method of that instance is invoked. + * + * For more information on the class features, see Timing Function. + * + */ +class _OSP_EXPORT_ IVisualElementAnimationTimingFunction +{ +public: + + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + IVisualElementAnimationTimingFunction(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IVisualElementAnimationTimingFunction(void); + + + /** + * Calculates the progress(pace) of an animation regarding the time elapsed. + * + * @since 2.0 + * + * @return The progress(pace) value calculated by the time progress value and the timing function type @n + * @c 0 and @c 1 are the start and end values of an animation, respectively. + * @param[in] timeProgress The time progress value @n + * This must be in the range @c 0.0 to @c 1.0. + */ + virtual float CalculateProgress(float timeProgress) const = 0; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + IVisualElementAnimationTimingFunction(const IVisualElementAnimationTimingFunction& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %IVisualElementAnimationTimingFunction. + // + // @since 2.0 + // + IVisualElementAnimationTimingFunction& operator =(const IVisualElementAnimationTimingFunction& rhs); +}; // IVisualElementAnimationTimingFunction + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_TIMING_FUNCTION_H_ diff --git a/inc/FUiAnimIVisualElementAnimationValueInterpolator.h b/inc/FUiAnimIVisualElementAnimationValueInterpolator.h new file mode 100644 index 0000000..e1f9657 --- /dev/null +++ b/inc/FUiAnimIVisualElementAnimationValueInterpolator.h @@ -0,0 +1,115 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIVisualElementAnimationValueInterpolator.h + * @brief This is the header file for the %IVisualElementAnimationValueInterpolator interface. + * + * This header file contains the declarations of the %IVisualElementAnimationValueInterpolator interface. + */ + +#ifndef _FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_VALUE_INTERPOLATOR_H_ +#define _FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_VALUE_INTERPOLATOR_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @interface IVisualElementAnimationValueInterpolator + * @brief This interface implements the interpolator for the VisualElementAnimation defined in the Tizen::Ui::Animations namespace. + * + * @since 2.0 + * + * The %IVisualElementAnimationValueInterpolator interface is the interpolator interface for interpolating on animation progress. + * The class that interpolates start value and end value implements this interface, + * and the instance created with that class is registered with an animation, + * using the VisualElementAnimation::SetValueInterpolator() method or the AnimationTransaction::SetVisualElementAnimationValueInterpolator() method. + * When tick of the animation occurs, a method of that instance is invoked. + * + * For more information on the class features, see Interpolation. + * + */ +class _OSP_EXPORT_ IVisualElementAnimationValueInterpolator +{ +public: + + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + IVisualElementAnimationValueInterpolator(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IVisualElementAnimationValueInterpolator(void); + + + /** + * Calculates the interpolated value based on the time. @n + * The %Interpolate() method will be called on every frame of an animation to calculate the current value of the specified @c progress. + * + * @since 2.0 + * + * @return An error code + * @param[in] progress The progress value from @c startValue to @c endValue @n + * The range of @c progress is decided by the IVisualElementAnimationTimingFunction interface. + * @param[in] startValue The start value + * @param[in] endValue The end value + * @param[out] value The interpolated value based on the time + * @exception E_SUCCESS The method is successful. + * @remarks If result is not E_SUCCESS, use @c startValue for the animation. + */ + virtual result Interpolate(float progress, const Tizen::Ui::Variant& startValue, const Tizen::Ui::Variant& endValue, Tizen::Ui::Variant& value) const = 0; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + IVisualElementAnimationValueInterpolator(const IVisualElementAnimationValueInterpolator& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %IVisualElementAnimationValueInterpolator. + // + // @since 2.0 + // + IVisualElementAnimationValueInterpolator& operator =(const IVisualElementAnimationValueInterpolator& rhs); +}; // IVisualElementAnimationValueInterpolator + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_IVISUAL_ELEMENT_ANIMATION_VALUE_INTERPOLATOR_H_ diff --git a/inc/FUiAnimIVisualElementContentProvider.h b/inc/FUiAnimIVisualElementContentProvider.h new file mode 100644 index 0000000..9186b55 --- /dev/null +++ b/inc/FUiAnimIVisualElementContentProvider.h @@ -0,0 +1,178 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIVisualElementContentProvider.h + * @brief This is the header file for the %IVisualElementContentProvider interface. + * + * This header file contains the declarations of the %IVisualElementContentProvider interface. + */ + +#ifndef _FUI_ANIM_IVISUAL_ELEMENT_CONTENT_PROVIDER_H_ +#define _FUI_ANIM_IVISUAL_ELEMENT_CONTENT_PROVIDER_H_ + +#include +#include + +namespace Tizen { namespace Graphics { +class Canvas; +class FloatPoint; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Animations +{ +class VisualElement; + + +/** + * @interface IVisualElementContentProvider + * @brief This interface customizes content of VisualElement. + * + * @since 2.0 + * + * The %IVisualElementContentProvider interface is the listener interface for providing content and information on it. The class that needs to customize content must implement this interface, and + * use the VisualElement::SetContentProvider() method to register to the VisualElement. + * + * For more information on the class features, see Content Provider. + * + */ +class _OSP_EXPORT_ IVisualElementContentProvider +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IVisualElementContentProvider(void) {} + +public: + /** + * %PrepareDraw() is invoked by UI framework before DrawContent() is called. + * If this method returns @c true, VisualElement can call the %DrawContent() method. + * + * @since 2.0 + * + * @return @c true if DrawContent() can be called, @n + * else @c false + * @param[in] target An instance of VisualElement to check + */ + virtual bool PrepareDraw(Tizen::Ui::Animations::VisualElement& target) = 0; + + + /** + * Fills content in the given canvas. + * + * @since 2.0 + * + * @param[in] target An instance of VisualElement to draw + * @param[in] canvas A graphic canvas for drawing + * @see VisualElement::OnDraw() + * @see VisualElement::InvalidateRectangle() + */ + virtual void DrawContent(Tizen::Ui::Animations::VisualElement& target, Tizen::Graphics::Canvas& canvas) = 0; + + + /** + * The %HitTest() method is called by VisualElement::GetChildAt(). @n + * The %GetChildAt() method traverses through a list of all children, and performs a hit test search at the @c point using this method. + * You can modify hit test search result by overriding this method. + * + * @since 2.0 + * + * @return The hit test result + * @param[in] target An instance of VisualElement to test + * @param[in] point The position of the source to check + * @remarks Hit test results must be one of the following: @n + * - Tizen::Ui::Animations::HitTestResult::HIT_TEST_NOWHERE + * - Tizen::Ui::Animations::HitTestResult::HIT_TEST_MATCH + * @see VisualElement::GetChildAt() + */ + virtual HitTestResult HitTest(Tizen::Ui::Animations::VisualElement& target, const Tizen::Graphics::FloatPoint& point) = 0; + + +protected: + // Reserved virtual methods for later extension. + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementContentProvider_Reserved1(void) {} + + + // Reserved virtual methods for later extension. + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementContentProvider_Reserved2(void) {} + + + // Reserved virtual methods for later extension. + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementContentProvider_Reserved3(void) {} + + + // Reserved virtual methods for later extension. + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementContentProvider_Reserved4(void) {} + + + // Reserved virtual methods for later extension. + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementContentProvider_Reserved5(void) {} +}; // IVisualElementContentProvider + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_IVISUAL_ELEMENT_CONTENT_PROVIDER_H_ diff --git a/inc/FUiAnimIVisualElementEventListener.h b/inc/FUiAnimIVisualElementEventListener.h new file mode 100644 index 0000000..a70d77c --- /dev/null +++ b/inc/FUiAnimIVisualElementEventListener.h @@ -0,0 +1,283 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIVisualElementEventListener.h + * @brief This is the header file for the %IVisualElementEventListener interface. + * + * This header file contains the declarations of the %IVisualElementEventListener interface. + */ + +#ifndef _FUIANIM_IVISUAL_ELEMENT_EVENT_LISTENER_H_ +#define _FUIANIM_IVISUAL_ELEMENT_EVENT_LISTENER_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +class VisualElement; + +/** +* @interface IVisualElementEventListener +* @brief This interface implements the event listener for the events generated by VisualElement. +* +* @since 2.0 +* +* The %IVisualElementEventListener interface is for receiving events on status change of VisualElement. The class that processes a status change event of %VisualElement +* implements this interface, and the instance created with that class is registered with %VisualElement, using the VisualElement::SetVisualElementEventListener() method. +* +* For more information on the class features, see Event Handling. +* +*/ +class _OSP_EXPORT_ IVisualElementEventListener + : public Tizen::Base::Runtime::IEventListener +{ +public: + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IVisualElementEventListener(void) {} + +public: + + /** + * Called when the child is attached to VisualElement. @n + * Overrides the %OnChildAttached() method to provide user-specific code just after the child is attached to the %VisualElement. + * This method is invoked when @c child is attached to @c source by @c AttachChild, @c InsertChild, @c ChangeZOder, or @c SetZOrderGroup. + * + * @since 2.0 + * + * @param[in] parent The parent instance + * @param[in] child The child instance + * @see VisualElement::AttachChild() + * @see VisualElement::InsertChild() + */ + virtual void OnChildAttached(Tizen::Ui::Animations::VisualElement& parent, Tizen::Ui::Animations::VisualElement& child) = 0; + + + /** + * Called when the child is detached to VisualElement. @n + * Overrides the %OnChildDetached() method to provide user-specific code just after the child is detached from the %VisualElement. + * This method is invoked when @c child is detached from @c source by @c AttachChild, @c InsertChild, @c ChangeZOder, or @c SetZOrderGroup. + * + * @since 2.0 + * + * @param[in] parent The parent instance + * @param[in] child The child instance + * @see VisualElement::DetachChild() + */ + virtual void OnChildDetached(Tizen::Ui::Animations::VisualElement& parent, Tizen::Ui::Animations::VisualElement& child) = 0; + + + /** + * Called when VisualElement is attached to the parent. @n + * Overrides the %OnAttached() method to provide user-specific code just after the %VisualElement is attached to the parent. + * This method is invoked when @c source is attached to @c parent by @c AttachChild, @c InsertChild, @c ChangeZOder, or @c SetZOrderGroup. + * + * @since 2.0 + * + * @param[in] child The child instance + * @param[in] parent The parent instance + * @see VisualElement::AttachChild() + * @see VisualElement::InsertChild() + */ + virtual void OnAttached(Tizen::Ui::Animations::VisualElement& child, Tizen::Ui::Animations::VisualElement& parent) = 0; + + + /** + * Called when VisualElement is detached to the parent. @n + * Overrides the %OnDetached() method to provide user-specific code just after the %VisualElement is detached from the parent. + * This method is invoked when @c source is detached from @c parent by @c AttachChild, @c InsertChild, @c ChangeZOder, @c SetZOrderGroup, or @c DetachChild. + * + * @since 2.0 + * + * @param[in] child The child instance + * @param[in] parent The parent instance + * @see VisualElement::DetachChild() + */ + virtual void OnDetached(Tizen::Ui::Animations::VisualElement& child, Tizen::Ui::Animations::VisualElement& parent) = 0; + + + /** + * Called when the transform matrix is about to be changed. @n + * Overrides the %OnTransformChanging() method to provide the user-specific code before the transform matrix is changed. + * This method is invoked when the transform matrix of @c source is about to be changed by invoking @c SetTransformMatrix. + * + * @since 2.0 + * + * @return An error code + * @param[in] source The VisualElement to change + * @param[in,out] newTransform The new transform matrix + * @remarks If this method returns @c E_SUCCESS, @c source will be applied with @c newTransform matrix, else will be cancelled. + */ + virtual result OnTransformChanging(Tizen::Ui::Animations::VisualElement& source, Tizen::Graphics::FloatMatrix4& newTransform) = 0; + + + /** + * Called when the transform matrix is changed. @n + * Overrides the %OnTransformChanged() method to provide the user-specific code just after the transform matrix is changed. + * This method is invoked when the transform matrix of @c source is changed by invoking @c SetTransformMatrix. + * + * @since 2.0 + * + * @param[in] source The VisualElement change applied + * @param[in] previousTransform The previous transform matrix + */ + virtual void OnTransformChanged(Tizen::Ui::Animations::VisualElement& source, const Tizen::Graphics::FloatMatrix4& previousTransform) = 0; + + + /** + * Called when the children transform matrix is about to be changed. @n + * Overrides the %OnChildrenTransformChanging() method to provide user-specific code before the children transform matrix is changed. + * This method is invoked when the children transform matrix of @c source is about to be changed by invoking @c SetChildrenTransformMatrix. + * + * @since 2.0 + * + * @return An error code + * @param[in] source The VisualElement to change + * @param[in,out] newTransform The new transform matrix + * @remarks If this method returns @c E_SUCCESS, @c source will be applied with @c newTransform matrix, else will be cancelled. + */ + virtual result OnChildrenTransformChanging(Tizen::Ui::Animations::VisualElement& source, Tizen::Graphics::FloatMatrix4& newTransform) = 0; + + + /** + * Called when the children transform matrix is changed. @n + * Overrides the %OnChildrenTransformChanged() method to provide user-specific code just after the children transform matrix is changed. + * This method is invoked when the children transform matrix of @c source is changed by invoking @c SetChildrenTransformMatrix. + * + * @since 2.0 + * + * @param[in] source The VisualElement change applied + * @param[in] previousTransform The previous transform matrix + */ + virtual void OnChildrenTransformChanged(Tizen::Ui::Animations::VisualElement& source, const Tizen::Graphics::FloatMatrix4& previousTransform) = 0; + + + /** + * Called when the bounds are about to be changed. @n + * Overrides the %OnBoundsChanging() method to provide user-specific code before the bounds are changed. + * This method is invoked when the bounds @c source is about to be changed by invoking @c SetBounds. + * + * @since 2.0 + * + * @return An error code + * @param[in] source The VisualElement to change + * @param[in,out] newBounds The new bounds + * @remarks If this method does not return @c E_SUCCESS, @c source is not applied with @c newBounds rectangle. + */ + virtual result OnBoundsChanging(Tizen::Ui::Animations::VisualElement& source, Tizen::Graphics::FloatRectangle& newBounds) = 0; + + + /** + * Called when the bounds are changed. @n + * Overrides the %OnBoundsChanged() method to provide user-specific code just after the bounds are changed. + * This method is invoked when the bounds of @c source is changed by invoking @c SetBounds. + * + * @since 2.0 + * + * @param[in] source The VisualElement change applied + * @param[in] previousBounds The previous bounds + */ + virtual void OnBoundsChanged(Tizen::Ui::Animations::VisualElement& source, const Tizen::Graphics::FloatRectangle& previousBounds) = 0; + + + /** + * Called when the show state is changed. @n + * Overrides the %OnShowStateChanged() method to provide user-specific code when the show state is changed. + * This method is invoked when the show state of @c source is changed by invoking @c SetShowState. + * + * @since 2.0 + * + * @param[in] source An instance whose show state is changed + * @param[in] previousShowState The previous show state + */ + virtual void OnShowStateChanged(Tizen::Ui::Animations::VisualElement& source, bool previousShowState) = 0; + + +protected: + // Reserved virtual methods for later extension. + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementEventListener_Reserved1(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementEventListener_Reserved2(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementEventListener_Reserved3(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementEventListener_Reserved4(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IVisualElementEventListener_Reserved5(void) {} +}; // IVisualElementEventListener + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_IVISUAL_ELEMENT_EVENT_LISTENER_H_ diff --git a/inc/FUiAnimIntegerAnimation.h b/inc/FUiAnimIntegerAnimation.h new file mode 100644 index 0000000..3fdc239 --- /dev/null +++ b/inc/FUiAnimIntegerAnimation.h @@ -0,0 +1,334 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIntegerAnimation.h + * @brief This is the header file for the %IntegerAnimation class. + * + * This header file contains the declarations of the %IntegerAnimation class. + */ + +#ifndef _FUI_ANIM_INTEGER_ANIMATION_H_ +#define _FUI_ANIM_INTEGER_ANIMATION_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class IntegerAnimation + * @brief This class animates an object from an integer value to another integer value. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %IntegerAnimation class animates an object from an integer value to another integer value based on the specified interpolator type. + * + * For more information on the class features, see Animating UI Controls. + */ +class _OSP_EXPORT_ IntegerAnimation + : public AnimationBase +{ +public: + /** + * Initializes this instance of %IntegerAnimation with the specified parameters. + * + * @since 2.0 + * + * @param[in] startValue The start value for Integer animation + * @param[in] endValue The end value for Integer animation + * @param[in] duration The duration of animation in milliseconds + * @param[in] interpolator The type of Interpolation @n + * This is used for the intermediate value calculation of the animation. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative or the interpolator is of an invalid type. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + IntegerAnimation(int startValue, int endValue, long duration, AnimationInterpolatorType interpolator); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IntegerAnimation(void); + + + /** + * This is the copy constructor for the %IntegerAnimation class. + * + * @since 2.0 + * + * @param[in] integerAnimation An instance of %IntegerAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + IntegerAnimation(const IntegerAnimation& integerAnimation); + + + /** + * Assigns the value of the specified instance to the current instance of %IntegerAnimation. + * + * @since 2.0 + * + * @param[in] rhs An instance of %IntegerAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + IntegerAnimation& operator =(const IntegerAnimation& rhs); + + + /** + * Checks whether the specified and current instance of %IntegerAnimation have equal animation values. + * + * @since 2.0 + * + * @return @c true if the animation of the two instances of %IntegerAnimation are equal, @n + * else @c false + * @param[in] rhs An instance of %IntegerAnimation + */ + bool operator ==(const IntegerAnimation& rhs) const; + + + /** + * Checks whether the specified instance and the current instance of %IntegerAnimation have different animation values. + * + * @since 2.0 + * + * @return @c true if the values of the animations of the two instances of %IntegerAnimation are not equal, @n + * else @c false + * @param[in] rhs An instance of %IntegerAnimation + */ + bool operator !=(const IntegerAnimation& rhs) const; + + + /** + * Checks whether the value of the current instance of %IntegerAnimation equals the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance equals the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %IntegerAnimation + * @remarks The %IntegerAnimation class has a semantic value. @n + * This means that this method checks whether the two instances have the same animation. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The two equal instances must return the same hash value. For better performance, the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + + /** + * Gets the animated value for the current time. + * + * @since 2.0 + * + * @return An error code + * @param[in] currentTime The current time value of the animation play @n + * The value must be between @c 0 and the duration of the animation. + * @param[out] animatedValue The animated value for the current time @n + * The value is passed as the input parameter. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * + */ + result GetAnimatedValue(long currentTime, int& animatedValue) const; + + + /** + * Adds a key frame to the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] time The time stamp + * @param[in] value The value at the specified @c time + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If @c time is greater than the duration, it becomes the new duration and @c value becomes the new @c endValue. + * Also the old duration and @c endValue are added as a new keyframe entry in the list. + * @remarks If a key-value pair with the current key already exists, the old value is overwritten with the new one. + * @remarks An exception is returned if @c time is equal to @c 0 or the duration of the animation. + */ + result AddKeyFrame(long time, int value); + + + /** + * Gets the keyframe at a particular index in this animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index value in the Keyframe list @n + * The value is sorted in an increasing order of time. + * @param[out] time The time stamp at the specified @c index + * @param[out] value The value at the specified @c index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks The @c time and @c value returned are present at the index of the sorted map list (sorted with respect to key). + * For example, if the user adds keyframe in the order (10,value1), (20,value2), (5,value3), and then + * GetKeyFrameAt(0,time,value) is called, the pair returned is (5,value3). + */ + result GetKeyFrameAt(int index, long& time, int& value) const; + + + /** + * Removes the specified keyframe object from the keyframe list. + * + * @since 2.0 + * + * @return An error code + * @param[in] time The key frame time + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c time value is invalid. + * @exception E_OBJ_NOT_FOUND The specified @c time is not found in the KeyFrame List. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveKeyFrame(long time); + + + /** + * Removes the keyframe present at the specified @c index from the keyframe list. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index value in the Keyframe list @n + * The value is sorted in an increasing order of time. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveKeyFrameAt(int index); + + + /** + * Removes all the keyframes from an animation. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveAllKeyFrames(void); + + + /** + * Sets the start value of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] startValue The start value of the animation to set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetStartValue(int startValue); + + + /** + * Sets the end value of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] endValue The end value of the animation to set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetEndValue(int endValue); + + + /** + * Gets the start value of the animation. + * + * @since 2.0 + * + * @return The start value + */ + int GetStartValue(void) const; + + + /** + * Gets the end value of the animation. + * + * @since 2.0 + * + * @return The end value + */ + int GetEndValue(void) const; + + + /** + * Gets the type information of this instance. + * + * @since 2.0 + * + * @return The type information of this instance + */ + virtual AnimationType GetType(void) const; + + +protected: + friend class _IntegerAnimationImpl; + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This variable is for internal usage. + // + // @since 2.0 + // + class _IntegerAnimationImpl* _pIntegerAnimationImpl; + +private: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the default constructor for this class. + // + // @since 2.0 + // + IntegerAnimation(void); +}; // IntegerAnimation + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTEGER_ANIMATION_H_ diff --git a/inc/FUiAnimLinearTimingFunction.h b/inc/FUiAnimLinearTimingFunction.h new file mode 100644 index 0000000..9ecd639 --- /dev/null +++ b/inc/FUiAnimLinearTimingFunction.h @@ -0,0 +1,107 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimLinearTimingFunction.h + * @brief This is the header file for the %LinearTimingFunction class. + * + * This header file contains the declarations of the %LinearTimingFunction class. + */ + +#ifndef _FUI_ANIM_LINEAR_TIMING_FUNCTION_H_ +#define _FUI_ANIM_LINEAR_TIMING_FUNCTION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @class LinearTimingFunction + * @brief This class stores the information of a linear timing function. + * + * @since 2.0 + * + * The %LinearTimingFunction class provides linear timing function related information. + * + * For more information on the class features, see Timing Function. + * + */ +class _OSP_EXPORT_ LinearTimingFunction + : public Tizen::Base::Object + , public IVisualElementAnimationTimingFunction +{ +public: + + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + LinearTimingFunction(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~LinearTimingFunction(void); + + + /** + * Calculates the progress(pace) of an animation regarding the time elapsed. + * + * @since 2.0 + * + * @return The progress(pace) value calculated by linear equation @n + * @c 0 and @c 1 are the start and end values of an animation, respectively. + * @param[in] timeProgress The time progress value @n + * This must be in the range @c 0.0 to @c 1.0. + */ + virtual float CalculateProgress(float timeProgress) const; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + LinearTimingFunction(const LinearTimingFunction& rhs); + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Assigns the value of the specified instance to the current instance of %LinearTimingFunction. + // + // @since 2.0 + // + LinearTimingFunction& operator =(const LinearTimingFunction& rhs); +}; // LinearTimingFunction + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_LINEAR_TIMING_FUNCTION_H_ diff --git a/inc/FUiAnimParallelAnimationGroup.h b/inc/FUiAnimParallelAnimationGroup.h new file mode 100644 index 0000000..124a239 --- /dev/null +++ b/inc/FUiAnimParallelAnimationGroup.h @@ -0,0 +1,253 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimParallelAnimationGroup.h + * @brief This is the header file for the %ParallelAnimationGroup class. + * + * This header file contains the declarations of the %ParallelAnimationGroup class. + */ + +#ifndef _FUI_ANIM_PARALLEL_ANIMATION_GROUP_H_ +#define _FUI_ANIM_PARALLEL_ANIMATION_GROUP_H_ + +#include +#include + +#include +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @class ParallelAnimationGroup + * @brief This class is used to group a set of animations together. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %ParallelAnimationGroup class is used to group a set of animations together in parallel. + */ +class _OSP_EXPORT_ ParallelAnimationGroup + : public AnimationGroup +{ +public: + + /** + * This is the default constructor for this class. + * + * @since 2.0 + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + ParallelAnimationGroup(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~ParallelAnimationGroup(void); + + + /** + * This is the copy constructor for the %ParallelAnimationGroup class. + * + * @since 2.0 + * + * @param[in] animationGroup An instance of %ParallelAnimationGroup + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + ParallelAnimationGroup(const ParallelAnimationGroup& animationGroup); + + + /** + * Assigns the value of the specified instance to the current instance of %ParallelAnimationGroup. + * + * @since 2.0 + * + * @param[in] rhs An instance of %ParallelAnimationGroup + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + ParallelAnimationGroup& operator =(const ParallelAnimationGroup& rhs); + + + /** + * Checks whether the specified instance and the current instance of %ParallelAnimationGroup have equal animation values. + * + * @since 2.0 + * + * @return @c true if the animation of the two instances of %ParallelAnimationGroup have equal values, @n + * else @c false + * @param[in] rhs An instance of %ParallelAnimationGroup + */ + bool operator ==(const ParallelAnimationGroup& rhs) const; + + + /** + * Checks whether the specified instance and the current instance of %ParallelAnimationGroup have different animation values. + * + * @since 2.0 + * + * @return @c true if the values of the animations of the two instances of %ParallelAnimationGroup are not equal, @n + * else @c false + * @param[in] rhs An instance of %ParallelAnimationGroup + */ + bool operator !=(const ParallelAnimationGroup& rhs) const; + + + /** + * Checks whether the value of the current instance of %ParallelAnimationGroup equals the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance is equal to the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %ParallelAnimationGroup + * @remarks The %ParallelAnimationGroup class has a semantic value. @n + * This means that this method checks whether the two instances have the same animation. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The two equal instances must return the same hash value. For better performance, the used hash function must generate a random + * distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + + /** + * Removes all the animations from the animation group. + * + * @since 2.0 + */ + virtual void RemoveAllAnimations(void); + + + /** + * Gets the total number of animations currently stored in a group. + * + * @since 2.0 + * + * @return The total number of animations stored in a group + */ + virtual int GetAnimationCount(void) const; + + + /** + * Adds an animation to the animation group. @n + * Each animation target can have only one animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] animTarget The animation target type @n + * The animation is applied to the specified animation target type. + * @param[in] animation An object of type AnimationBase + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If an animation is added to a target type that already has an animation associated with it, the old animation is overwritten with the new animation. + */ + result AddAnimation(AnimationTargetType animTarget, const AnimationBase& animation); + + + /** + * Removes an animation from the animation group with the specified animation target. + * + * @since 2.0 + * + * @return An error code + * @param[in] animTarget The animation target + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OBJ_NOT_FOUND The animation with the specified animation target does not exist in the animation group. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveAnimation(AnimationTargetType animTarget); + + + /** + * Gets the animation object for the specified animation target. + * + * @since 2.0 + * + * @return An animation for the specified animation target in the animation group, @n + * else @c null if the animation target is empty + * @param[in] animTarget The animation target type to get an animation object + */ + AnimationBase* GetAnimationN(AnimationTargetType animTarget) const; + + + /** + * Checks whether an animation is added for the specified target type. + * + * @since 2.0 + * + * @return @c true if an animation is associated with the specified target type, @n + * else @c false + * @param[in] animTarget The animation target type + */ + bool IsAnimationAdded(AnimationTargetType animTarget); + + + /** + * Gets the type information of this instance. + * + * @since 2.0 + * + * @return The type information of this instance + */ + virtual AnimationGroupType GetType(void) const; + + +protected: + + friend class _ParallelAnimationGroupImpl; + + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This variable is for internal usage. + // + // @since 2.0 + // + class _ParallelAnimationGroupImpl* _pParallelAnimationGroupImpl; +}; // ParallelAnimationGroup + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_PARALLEL_ANIMATION_GROUP_H_ diff --git a/inc/FUiAnimPointAnimation.h b/inc/FUiAnimPointAnimation.h new file mode 100644 index 0000000..38110bc --- /dev/null +++ b/inc/FUiAnimPointAnimation.h @@ -0,0 +1,337 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimPointAnimation.h + * @brief This is the header file for the %PointAnimation class. + * + * This header file contains the declarations of the %PointAnimation class. + */ + +#ifndef _FUI_ANIM_POINT_ANIMATION_H_ +#define _FUI_ANIM_POINT_ANIMATION_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class PointAnimation + * @brief This class animates the Tizen::Graphics::Point object. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %PointAnimation class animates an object from a Tizen::Graphics::Point value to another %Tizen::Graphics::Point value + * based on the specified interpolator type. + * + * For more information on the class features, see Animating UI Controls. + */ +class _OSP_EXPORT_ PointAnimation + : public AnimationBase +{ +public: + + /** + * Initializes this instance of %PointAnimation with the specified parameters. + * + * @since 2.0 + * + * @param[in] startValue The start value for %PointAnimation + * @param[in] endValue The end value for %PointAnimation + * @param[in] duration The duration of animation in milliseconds + * @param[in] interpolator The type of interpolator used for the intermediate value calculation of the animation + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative or the interpolator is of an invalid type. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + PointAnimation(const Tizen::Graphics::Point& startValue, const Tizen::Graphics::Point& endValue, long duration, AnimationInterpolatorType interpolator); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~PointAnimation(void); + + + /** + * This is the copy constructor for the %PointAnimation class. + * + * @since 2.0 + * + * @param[in] pointAnimation An instance of %PointAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + PointAnimation(const PointAnimation& pointAnimation); + + + /** + * Assigns the value of the specified instance to the current instance of %PointAnimation. + * + * @since 2.0 + * + * @param[in] pointAnimation An instance of %PointAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + PointAnimation& operator =(const PointAnimation& pointAnimation); + + + /** + * Checks whether the specified instance and the current instance of %PointAnimation have equal animation values. + * + * @since 2.0 + * + * @return @c true if the animation of the two instances of %PointAnimation are equal, @n + * else @c false + * @param[in] rhs An instance of %PointAnimation + */ + bool operator ==(const PointAnimation& rhs) const; + + + /** + * Checks whether the specified instance and the current instance of %PointAnimation have different animation values. + * + * @since 2.0 + * + * @return @c true if the values of the animations of the two instances of %PointAnimation are not equal, @n + * else @c false + * @param[in] rhs An instance of %PointAnimation + */ + bool operator !=(const PointAnimation& rhs) const; + + + /** + * Checks whether the value of the current instance of %PointAnimation equals the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance equals the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %PointAnimation + * @remarks The %PointAnimation class has a semantic value. @n + * This means that this method checks whether the two instances have the same animation. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The two equal instances must return the same hash value. For better performance, the used hash function must generate a random + * distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + + /** + * Gets the animated value for the current time. + * + * @since 2.0 + * + * @return An error code + * @param[in] currentTime The current time value of the animation @n + * The value must be between @c 0 and the duration of the animation. + * @param[out] animatedValue The animated value for the current time passed as the input parameter + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * + */ + result GetAnimatedValue(long currentTime, Tizen::Graphics::Point& animatedValue) const; + + + /** + * Adds a key frame to the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] time The time stamp + * @param[in] value The value at the specified @c time + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If @c time is greater than the duration, it becomes the new duration and @c value becomes the new @c endValue. @n + * The old duration and @c endValue are added as a new key frame entry in the list. @n + * If a key-value pair with the current key already exists, then the old value will be overwritten with the new one. @n + * An exception will be returned if time is equal to @c 0 or duration of the animation. + */ + result AddKeyFrame(long time, const Tizen::Graphics::Point& value); + + + /** + * Gets the keyframe at a particular index in this animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index value in the Keyframe list @n + * The value is sorted in an increasing order of time. + * @param[out] time The time stamp at the specified @c index + * @param[out] value The value at the specified @c index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks The @c time and @c value returned are present at the index of the sorted map list that is sorted with respect to the key. + * For example, if the user adds key-frame in the order (10,value1), (20,value2), (5,value3) and then + * GetKeyFrameAt(0,time,value) is called, the pair returned is (5,value3). + */ + result GetKeyFrameAt(int index, long& time, Tizen::Graphics::Point& value) const; + + + /** + * Removes the passed keyframe object from the keyframe list. + * + * @since 2.0 + * + * @return An error code + * @param[in] time The key frame time + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c time value is invalid. + * @exception E_OBJ_NOT_FOUND The specified @c time is not found in the KeyFrame List. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveKeyFrame(long time); + + + /** + * Removes the keyframe present at the specified @c index from the keyframe list. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index value in the Keyframe list @n + * The value is sorted in an increasing order of time. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveKeyFrameAt(int index); + + + /** + * Removes all the keyframes from the animation. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveAllKeyFrames(void); + + + /** + * Sets the start value of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] startValue The start value of the animation to set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetStartValue(const Tizen::Graphics::Point& startValue); + + + /** + * Sets the end value of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] endValue The end value of the animation to set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetEndValue(const Tizen::Graphics::Point& endValue); + + + /** + * Gets the start value of the animation. + * + * @since 2.0 + * + * @return The start value + */ + Tizen::Graphics::Point GetStartValue(void) const; + + + /** + * Gets the end value of the animation. + * + * @since 2.0 + * + * @return The end value + */ + Tizen::Graphics::Point GetEndValue(void) const; + + + /** + * Gets the type information of this instance. + * + * @since 2.0 + * + * @return The type information of this instance + */ + virtual AnimationType GetType(void) const; + + +protected: + + friend class _PointAnimationImpl; + + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This variable is for internal usage. + // + // @since 2.0 + // + class _PointAnimationImpl* _pPointAnimationImpl; + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the default constructor for this class. + // + // @since 2.0 + // + PointAnimation(void); +}; // PointAnimation + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_POINT_ANIMATION_H_ diff --git a/inc/FUiAnimRectangleAnimation.h b/inc/FUiAnimRectangleAnimation.h new file mode 100644 index 0000000..2700d45 --- /dev/null +++ b/inc/FUiAnimRectangleAnimation.h @@ -0,0 +1,373 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimRectangleAnimation.h + * @brief This is the header file for the %RectangleAnimation class. + * + * This header file contains the declarations of the %RectangleAnimation class. + */ + +#ifndef _FUI_ANIM_RECTANGLE_ANIMATION_H_ +#define _FUI_ANIM_RECTANGLE_ANIMATION_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class RectangleAnimation + * @brief This class animates the Tizen::Graphics::Rectangle object. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %RectangleAnimation class animates an object from a Tizen::Graphics::Rectangle value to another %Rectangle value based on the specified interpolator type. + * + * For more information on the class features, see Animating UI Controls. + */ +class _OSP_EXPORT_ RectangleAnimation + : public AnimationBase +{ +public: + + /** + * Initializes this instance of %RectangleAnimation with the specified parameters. + * + * @since 2.0 + * + * @param[in] startValue The start value for rectangle animation + * @param[in] endValue The end value for rectangle animation + * @param[in] duration The duration of animation in milliseconds + * @param[in] interpolator The type of interpolator @n + * This is used for the intermediate value calculation of the animation. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative or the interpolator is of an invalid type. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + RectangleAnimation(const Tizen::Graphics::Rectangle& startValue, const Tizen::Graphics::Rectangle& endValue, long duration, AnimationInterpolatorType interpolator); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~RectangleAnimation(void); + + + /** + * This is the copy constructor for the %RectangleAnimation class. + * + * @since 2.0 + * + * @param[in] rectangleAnimation An instance of %RectangleAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + RectangleAnimation(const RectangleAnimation& rectangleAnimation); + + + /** + * Assigns the value of the specified instance to the current instance of %RectangleAnimation. + * + * @since 2.0 + * + * @param[in] rhs An instance of %RectangleAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + RectangleAnimation& operator =(const RectangleAnimation& rhs); + + + /** + * Checks whether the specified instance and the current instance of %RectangleAnimation have equal animation values. + * + * @since 2.0 + * + * @return @c true if the animation of the two instances of %RectangleAnimation have equal values, @n + * else @c false + * @param[in] rhs An instance of %RectangleAnimation + */ + bool operator ==(const RectangleAnimation& rhs) const; + + + /** + * Checks whether the specified instance and the current instance of %RectangleAnimation have different animation values. + * + * @since 2.0 + * + * @return @c true if the values of the animations of the two instances of %RectangleAnimation are not equal, @n + * else @c false + * @param[in] rhs An instance of %RectangleAnimation + */ + bool operator !=(const RectangleAnimation& rhs) const; + + + /** + * Checks whether the value of the current instance of %RectangleAnimation is equal to the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance is equal to the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %RectangleAnimation + * @remarks The %RectangleAnimation class has a semantic value. This means that this method checks whether the two instances have the same + * animation. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The two equal instances must return the same hash value. For better performance, the used hash function must generate a random + * distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + + /** + * Sets the anchor points for the animation. + * + * @since 2.0 + * + * @param[in] anchorX The X value of the anchor @n + * The control's animation is performed at this point. The range of the anchor point is @c 0.0 to @c 1.0. + * @param[in] anchorY The Y value of the anchor @n + * The control's animation is performed at this point. The range of the anchor point is @c 0.0 to @c 1.0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks The default anchor point value is (0.0, 0.0). The range of an anchor point is @c 0.0 to @c 1.0. @n + * When the anchor point value is (0.0, 0.0), the object is scaled and the top-left corner of the object remains fixed. @n + * For all the other anchor point values, the position property is changed. @n + * If the anchor point value is (0.5, 0.5), the object is scaled with respect to the center. @n + * If the anchor point value is (1.0, 1.0), the object is scaled and the bottom-right corner of the object remains fixed. + */ + result SetAnchor(float anchorX, float anchorY); + + + /** + * Gets the anchor point associated with the animation. @n + * The default anchor point is (0.0, 0.0). + * + * @since 2.0 + * + * @param[out] anchorX The X value of the anchor @n + * The control's animation is performed at this point. + * @param[out] anchorY The Y value of the anchor @n + * The control's animation is performed at this point. + */ + void GetAnchor(float& anchorX, float& anchorY) const; + + + /** + * Gets the animated value for the current time. + * + * @since 2.0 + * + * @return An error code + * @param[in] currentTime The current time value of the animation play @n + * The value must be between @c 0 and the duration of the animation. + * @param[out] animatedValue The animated value for the current time passed as the input parameter + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * + */ + result GetAnimatedValue(long currentTime, Tizen::Graphics::Rectangle& animatedValue) const; + + + /** + * Adds a key frame to the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] time The time stamp + * @param[in] value The value at the specified @c time + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If @c time is greater than the duration, it becomes the new duration and @c value becomes the new end value. @n + * Also, the old duration and end value are added as a new keyframe entry in the list. + * @remarks If a key-value pair with the current key already exists, the old value is overwritten with the new one. + * @remarks An exception is returned if @c time is equal to @c 0 or the duration of the animation. + */ + result AddKeyFrame(long time, const Tizen::Graphics::Rectangle& value); + + + /** + * Gets the keyframe at a specified @c index in this animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index value in the Keyframe list @n + * This is sorted in an increasing order of time. + * @param[out] time The time stamp at the specified @c index + * @param[out] value The value at the specified @c index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks The @c time and @c value returned is the one present at the index of the sorted map list (sorted with respect to the key). + * For example, if the user adds keyframe in the order (10,value1), (20,value2), (5,value3), and then GetKeyFrameAt(0,time,value) is called, + * the pair returned is (5, value3). + */ + result GetKeyFrameAt(int index, long& time, Tizen::Graphics::Rectangle& value) const; + + + /** + * Removes the passed keyframe object from the keyframe list. + * + * @since 2.0 + * + * @return An error code + * @param[in] time The key frame time + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c time value is invalid. + * @exception E_OBJ_NOT_FOUND The time passed is not found in the KeyFrame list. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveKeyFrame(long time); + + + /** + * Removes the keyframe present at the specified @c index from the keyframe list. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index value in the Keyframe list @n + * This is sorted in an increasing order of time. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveKeyFrameAt(int index); + + + /** + * Removes all the keyframes from an animation. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveAllKeyFrames(void); + + + /** + * Sets the start value of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] startValue The start value of the animation to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetStartValue(const Tizen::Graphics::Rectangle& startValue); + + + /** + * Sets the end value of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] endValue The end value of the animation to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetEndValue(const Tizen::Graphics::Rectangle& endValue); + + + /** + * Gets the start value of the animation. + * + * @since 2.0 + * + * @return The start value + */ + Tizen::Graphics::Rectangle GetStartValue(void) const; + + + /** + * Gets the end value of the animation. + * + * @since 2.0 + * + * @return The end value + */ + Tizen::Graphics::Rectangle GetEndValue(void) const; + + + /** + * Gets the type information of this instance. + * + * @since 2.0 + * + * @return The type information of this instance + */ + virtual AnimationType GetType(void) const; + + +protected: + friend class _RectangleAnimationImpl; + + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This variable is for internal usage. + // + // @since 2.0 + // + class _RectangleAnimationImpl* _pRectangleAnimationImpl; + + +private: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the default constructor for this class. + // + // @since 2.0 + // + RectangleAnimation(void); +}; // RectangleAnimation + + +}}} // Tizen::Ui::Animations + +#endif // _FANIM_RECTANGLEANIMATION_H_ diff --git a/inc/FUiAnimRotateAnimation.h b/inc/FUiAnimRotateAnimation.h new file mode 100644 index 0000000..76f1b4e --- /dev/null +++ b/inc/FUiAnimRotateAnimation.h @@ -0,0 +1,231 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimRotateAnimation.h + * @brief This is the header file for the %RotateAnimation class. + * + * This header file contains the declarations of the %RotateAnimation class. + */ + +#ifndef _FUI_ANIM_ROTATE_ANIMATION_H_ +#define _FUI_ANIM_ROTATE_ANIMATION_H_ + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @class RotateAnimation + * @brief This class animates between two angle values. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %RotateAnimation class animates an object from an angle value (float) to another angle value (float) + * based on the specified interpolator type. When associated with a Control, the animation is applied on the z-axis of the %Control. + * + * For more information on the class features, see Animating UI Controls. + */ +class _OSP_EXPORT_ RotateAnimation + : public FloatAnimation +{ +public: + + /** + * Initializes this instance of %RotateAnimation with the specified parameters. + * + * @since 2.0 + * + * @param[in] startValue The start value for the rotate animation @n + * If the value is positive, the control is rotated in the clockwise direction and if the value is negative, the control + * is rotated in the anti-clockwise direction. + * @param[in] endValue The end value for the rotate animation @n + * The value must be @c 0 or @c 360, else ControlAnimator::ControlAnimator() returns an @c E_INVALID_ARG exception. + * @param[in] duration The duration of animation in milliseconds + * @param[in] interpolator The type of interpolator @n + * This is used for the intermediate value calculation of the animation. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative or the interpolator is of an invalid type. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + RotateAnimation(float startValue, float endValue, long duration, AnimationInterpolatorType interpolator); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~RotateAnimation(void); + + + /** + * This is the copy constructor for the %RotateAnimation class. + * + * @since 2.0 + * + * @param[in] rotateAnimation An instance of %RotateAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + RotateAnimation(const RotateAnimation& rotateAnimation); + + + /** + * Assigns the value of the specified instance to the current instance of %RotateAnimation. + * + * @since 2.0 + * + * @param[in] rhs An instance of %RotateAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + RotateAnimation& operator =(const RotateAnimation& rhs); + + + /** + * Checks whether the specified instance and the current instance of %RotateAnimation have equal animation values. + * + * @since 2.0 + * + * @return @c true if the animation of the two instances of %RotateAnimation have equal values, @n + * else @c false + * @param[in] rhs An instance of %RotateAnimation + */ + bool operator ==(const RotateAnimation& rhs) const; + + + /** + * Checks whether the specified instance and the current instance of %RotateAnimation have different animation values. + * + * @since 2.0 + * + * @return @c true if the values of the animations of the two instances of %RotateAnimation are not equal, @n + * else @c false + * @param[in] rhs An instance of %RotateAnimation + */ + bool operator !=(const RotateAnimation& rhs) const; + + + /** + * Checks whether the value of the current instance of %RotateAnimation is equal to the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance is equal to the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %RotateAnimation + * @remarks The %RotateAnimation class has a semantic value. This means that this method checks whether the two instances have the same animation. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The two equal instances must return the same hash value. For better performance, the used hash function must generate a random + * distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + + /** + * Sets the anchor points for the animation. + * + * @since 2.0 + * + * @param[in] anchorX The x value of the anchor @n + * The control's animation is performed at this point. The range of the anchor point is @c 0.0 to @c 1.0. + * @param[in] anchorY The y value of the anchor @n + * The control's animation is performed at this point. The range of the anchor point is @c 0.0 to @c 1.0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks The default anchor point value is (0.5, 0.5). The range of an anchor point is @c 0.0 to @c 1.0. @n + * If the anchor point value is (0.5, 0.5), the object is rotated and the center of the object remains fixed. @n + * If the anchor point value is (0.0, 0.0), the object is rotated and the top-left corner of the object remains fixed. @n + * If the anchor point value is (1.0, 1.0), the object is rotated and the right-bottom corner of the object remains fixed. + */ + result SetAnchor(float anchorX, float anchorY); + + + /** + * Gets the anchor point associated with the animation. @n + * The default anchor point is (0.5, 0.5). + * + * @since 2.0 + * + * @param[out] anchorX The x value of the anchor @n + * The control's animation is performed at this point. + * @param[out] anchorY The y value of the anchor @n + * The control's animation is performed at this point. + */ + void GetAnchor(float& anchorX, float& anchorY) const; + + + /** + * Gets the type information of this instance. + * + * @since 2.0 + * + * @return The type information of this instance + */ + virtual AnimationType GetType(void) const; + + +protected: + + friend class _RotateAnimationImpl; + + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This variable is for internal usage. + // + // @since 2.0 + // + class _RotateAnimationImpl* _pRotateAnimationImpl; + + +private: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the default constructor for this class. + // + // @since 2.0 + // + RotateAnimation(void); +}; // RotateAnimation + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_ROTATE_ANIMATION_H_ diff --git a/inc/FUiAnimSequentialAnimationGroup.h b/inc/FUiAnimSequentialAnimationGroup.h new file mode 100644 index 0000000..5671eaa --- /dev/null +++ b/inc/FUiAnimSequentialAnimationGroup.h @@ -0,0 +1,286 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimSequentialAnimationGroup.h + * @brief This is the header file for the %SequentialAnimationGroup class. + * + * This header file contains the declarations of the %SequentialAnimationGroup class. + */ + +#ifndef _FUI_ANIM_SEQUENTIAL_ANIMATION_GROUP_H_ +#define _FUI_ANIM_SEQUENTIAL_ANIMATION_GROUP_H_ + +#include +#include + +#include +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @class SequentialAnimationGroup + * @brief This class is used to group a set of animations together. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %SequentialAnimationGroup class is used to group a set of animations together in sequence. + */ +class _OSP_EXPORT_ SequentialAnimationGroup + : public AnimationGroup +{ +public: + + /** + * This is the default constructor for this class. + * + * @since 2.0 + * + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + SequentialAnimationGroup(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~SequentialAnimationGroup(void); + + + /** + * This is the copy constructor for the %SequentialAnimationGroup class. + * + * @since 2.0 + * + * @param[in] animationGroup An instance of %SequentialAnimationGroup + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + SequentialAnimationGroup(const SequentialAnimationGroup& animationGroup); + + + /** + * Assigns the value of the specified instance to the current instance of %SequentialAnimationGroup. + * + * @since 2.0 + * + * @param[in] rhs An instance of %SequentialAnimationGroup + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + SequentialAnimationGroup& operator =(const SequentialAnimationGroup& rhs); + + + /** + * Checks whether the specified instance and the current instance of %SequentialAnimationGroup have equal animation values. + * + * @since 2.0 + * + * @return @c true if the animation of the two instances of %SequentialAnimationGroup have equal values, @n + * else @c false + * @param[in] rhs An instance of %SequentialAnimationGroup + */ + bool operator ==(const SequentialAnimationGroup& rhs) const; + + + /** + * Checks whether the specified instance and the current instance of %SequentialAnimationGroup have different animation values. + * + * @since 2.0 + * + * @return @c true if the values of the animations of the two instances of %SequentialAnimationGroup are not equal, @n + * else @c false + * @param[in] rhs An instance of %SequentialAnimationGroup + */ + bool operator !=(const SequentialAnimationGroup& rhs) const; + + + /** + * Checks whether the value of the current instance of %SequentialAnimationGroup is equal to the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance is equal to the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %SequentialAnimationGroup + * @remarks The %SequentialAnimationGroup class has a semantic value. @n + * This means that this method checks whether the two instances have the same animation. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The two equal instances must return the same hash value. For better performance, the used hash function must generate a random + * distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + + /** + * Removes all the animations from the animation group. + * + * @since 2.0 + */ + virtual void RemoveAllAnimations(void); + + + /** + * Gets the number of animations currently stored in a group. + * + * @since 2.0 + * + * @return The total number of animations stored in a group + */ + virtual int GetAnimationCount(void) const; + + + /** + * Adds the specified animation to the animation group. + * + * @since 2.0 + * + * @return An error code + * @param[in] animTarget The animation target type @n + * The animation is applied to the specified animation target type. + * @param[in] animation An instance of AnimationBase + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result AddAnimation(AnimationTargetType animTarget, const AnimationBase& animation); + + + /** + * Sets the specified @c animation to the animation group. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index at which the animation is set + * @param[in] animTarget The AnimationTargetType to which the animation is applied + * @param[in] animation An instance of AnimationBase + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks If an animation is added to the same index which already has an animation associated with it, the old animation will be overwritten with the new one. + */ + result SetAnimationAt(int index, AnimationTargetType animTarget, const AnimationBase& animation); + + + /** + * Inserts the specified @c animation to the animation group. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index at which the animation is inserted + * @param[in] animTarget The AnimationTargetType to which the animation is applied + * @param[in] animation An instance of AnimationBase + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result InsertAnimationAt(int index, AnimationTargetType animTarget, const AnimationBase& animation); + + + /** + * Removes the animation from the animation group at the specified @c index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index An index value in the animation group list + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveAnimationAt(int index); + + + /** + * Gets the animation object at the specified @c index. + * + * @since 2.0 + * + * @return The animation object at the specified @c index value in the animation group, @n + * else @c null if the @c index is invalid + * @param[in] index The index value in the animation group list + */ + AnimationBase* GetAnimationAtN(int index) const; + + + /** + * Gets the target type of the animation at the specified @c index. + * + * @since 2.0 + * + * @return The target type of the animation at the specified @c index value in the animation group, @n + * else @c ANIMATION_TARGET_NONE if the specified @c index is invalid + * @param[in] index The index value in the animation group list + */ + AnimationTargetType GetAnimationTargetTypeAt(int index) const; + + + /** + * Gets the type information of this instance. + * + * @since 2.0 + * + * @return The type information of this instance + */ + virtual AnimationGroupType GetType(void) const; + + +protected: + + friend class _SequentialAnimationGroupImpl; + + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This variable is for internal usage. + // + // @since 2.0 + // + class _SequentialAnimationGroupImpl* _pSequentialAnimationGroupImpl; +}; // SequentialAnimationGroup + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_SEQUENTIAL_ANIMATION_GROUP_H_ diff --git a/inc/FUiAnimTypes.h b/inc/FUiAnimTypes.h new file mode 100644 index 0000000..457b193 --- /dev/null +++ b/inc/FUiAnimTypes.h @@ -0,0 +1,186 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimTypes.h + * @brief This is the header file for the common data types used by UI animations. + * + * This header file contains the declarations of the common data types and constants used by UI animations. + */ + +#ifndef _FUI_ANIM_TYPES_H_ +#define _FUI_ANIM_TYPES_H_ + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** @enum HitTestResult + * + * Defines the hit test result. + * + * @since 2.0 + * @see IVisualElementContentProvider::HitTest() + * @see VisualElement::OnHitTest() + */ +enum HitTestResult { + HIT_TEST_NOWHERE = 0, /**< VisualElement does not contain the specified point */ + HIT_TEST_MATCH = 1 /**< VisualElement contains the specified point */ +}; + + + + +/** + * @enum AnimationType + * + * Defines the information of the animation type. + * + * @since 2.0 + */ +enum AnimationType +{ + ANIMATION_TYPE_FLOAT_ANIMATION = 0, /**< The float animation */ + ANIMATION_TYPE_INTEGER_ANIMATION, /**< The integer animation */ + ANIMATION_TYPE_DIMENSION_ANIMATION, /**< The dimension animation */ + ANIMATION_TYPE_RECTANGLE_ANIMATION, /**< The rectangle animation */ + ANIMATION_TYPE_POINT_ANIMATION, /**< The point animation */ + ANIMATION_TYPE_ROTATE_ANIMATION, /**< The rotate animation */ +}; + + +/** + * @enum AnimationInterpolatorType + * + * Defines the interpolator type used in animations. + * + * @since 2.0 + */ +enum AnimationInterpolatorType +{ + ANIMATION_INTERPOLATOR_LINEAR = 0, /**< The linear interpolator */ + ANIMATION_INTERPOLATOR_DISCRETE, /**< The discrete interpolator*/ + ANIMATION_INTERPOLATOR_EASE_IN, /**< The easeIn interpolator*/ + ANIMATION_INTERPOLATOR_EASE_OUT, /**< The easeOut interpolator*/ + ANIMATION_INTERPOLATOR_EASE_IN_OUT, /**< The easeInOut interpolator*/ + ANIMATION_INTERPOLATOR_BEZIER, /**< The bezier interpolator @n + Sets the control points for this interpolator using AnimationBase::SetBezierControlPoints(). */ +}; + + +/** + * @enum AnimationTargetType + * + * Defines the object property for which the animations are to be applied. + * + * @since 2.0 + */ +enum AnimationTargetType +{ + ANIMATION_TARGET_NONE = -1, /**< An invalid %Animation */ + ANIMATION_TARGET_SIZE, /**< An animation for the size property */ + ANIMATION_TARGET_POSITION, /**< An animation for the position property */ + ANIMATION_TARGET_ALPHA, /**< An animation for alpha property @n The value range for playing the alpha animation must be between @c 0.0 to @c 1.0. */ + ANIMATION_TARGET_ROTATION, /**< An animation for rotate property @n The control will be rotated in the xy-plane along the z-axis. */ + ANIMATION_TARGET_MAX // This enum value is for internal use only. + // Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. +}; + + +/** + * @enum AnimatorStatus + * + * Defines the status of the animations attached to a control. + * + * @since 2.0 + */ +enum AnimatorStatus +{ + ANIMATOR_STATUS_PLAYING, /**< The animation being played */ + ANIMATOR_STATUS_STOPPED, /**< The animation stopped */ +}; + + +/** +* @enum AnimationGroupType +* +* Defines the animation group type information. +* +* @since 2.0 +*/ +enum AnimationGroupType +{ + ANIMATION_GROUP_TYPE_SEQUENTIAL = 0, /** The sequential animation group */ + ANIMATION_GROUP_TYPE_PARALLEL, /** The parallel animation group */ +}; + + +/** + * @enum AnimationTransactionStatus + * + * Defines the transaction status of the animation. + * @since 2.0 + */ +enum AnimationTransactionStatus +{ + ANIMATION_TRANSACTION_STATUS_PLAYING, /**< A transaction being played */ + ANIMATION_TRANSACTION_STATUS_STOPPED, /**< A transaction stopped */ +}; + + +/** + * @enum ControlAnimatorTriggerType + * + * Defines the trigger for animations attached to a control. + * + * @since 2.0 + */ +enum ControlAnimatorTriggerType +{ + ANIMATION_TRIGGER_USER = 0, /**< The animation attached to a control is explicitly triggered by the user */ + ANIMATION_TRIGGER_POSITION_CHANGE, /**< The animation attached to a control is implicitly triggered by changing the position of the control */ + ANIMATION_TRIGGER_SIZE_CHANGE, /**< The animation attached to a control is implicitly triggered by changing the size of the control */ + ANIMATION_TRIGGER_SHOW_STATE_CHANGE, /**< The animation attached to a control is implicitly triggered by changing the showstate of the control */ +}; + + + +/** + * @enum FrameAnimatorFormTransitionAnimation + * + * Defines the platform predefined animation set for the animation events. + * + * @since 2.0 + */ +enum FrameAnimatorFormTransitionAnimation +{ + FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_LEFT = 0, /**< The transition animation using translate left animation */ + FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_RIGHT, /**< The transition animation using translate right animation */ + FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_FADE_IN_OUT, /**< The transition animation using alpha animation */ + FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_ZOOM_IN, /**< The transition animation using scale animation */ + FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_ZOOM_OUT, /**< The transition animation using scale animation */ + FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_DEPTH_IN, /**< The transition animation using scale and alpha animation */ + FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_DEPTH_OUT, /**< The transition animation using scale and alpha animation */ + FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_MAX // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, + // and consistency-related issues in the application. +}; + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIMATIONS_TYPES_H_ diff --git a/inc/FUiAnimVisualElement.h b/inc/FUiAnimVisualElement.h new file mode 100644 index 0000000..a25ad79 --- /dev/null +++ b/inc/FUiAnimVisualElement.h @@ -0,0 +1,1352 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElement.h + * @brief This is the header file for the %VisualElement class. + * + * This header file contains the declarations of the %VisualElement class. + */ + +#ifndef _FUI_ANIM_VISUAL_ELEMENT_H_ +#define _FUI_ANIM_VISUAL_ELEMENT_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Graphics { +class Canvas; +}} + +namespace Tizen { namespace Ui { namespace Animations +{ + +class VisualElementSurface; +class _VisualElementImpl; + + +/** + * @class VisualElement + * @brief This class is a base class for all displayable objects on screen with animations. + * + * @since 2.0 + * + * The %VisualElement class is a base class for all displayable objects on screen with animations. + * It encapsulates properties about coordinates (bounds, transform matrix, children transform matrix and so on), + * contents (content bounds, clipping, opacity, show state and so on) and tree-hierarchy. + * It also provides infrastructure necessary for animations (AddAnimation(), RemoveAnimation() and so on). + * A %VisualElement object instantiated by applications works as a model object and may have a cloned counter part for presentation on screen which has a separated life-cycle. + * The presentation object is managed by system and applications must not change properties of it. + * Most animations of %VisualElement are applied on presentation objects. Properties set by applications are stored in model objects while properties of presentation objects + * are changing during implicit or explicit animations. + * + * This class also provides interfaces such as IVisualElementContentProvider, IVisualElementEventListener, and IVisualElementAnimationProvider to override default behaviors + * without inheritances. + * + * For more information on the class features, see Visual Elements. + * + */ + +class _OSP_EXPORT_ VisualElement + : public Tizen::Base::Object +{ +public: + /** + * The lowest drawing group, such as, background element. + * + * @since 2.0 + */ + static const int Z_ORDER_GROUP_LOWEST = -1000; + + + /** + * The level of the default group. + * + * @since 2.0 + */ + static const int Z_ORDER_GROUP_NORMAL = 0; + + + /** + * The highest drawing group, such as, top-most element. + * + * @since 2.0 + */ + static const int Z_ORDER_GROUP_HIGHEST = 1000; + + + /** + * @enum RenderOperation + * Defines the render operation for %VisualElement. @n + * The contents of %VisualElement will be composited on screen using this operation. + */ + enum RenderOperation + { + RENDER_OPERATION_BLEND = 0, /**< The contents will be displayed blended with underlying %VisualElements */ + RENDER_OPERATION_COPY /**< The contents will be displayed obscuring other underlying %VisualElements */ + }; + + + /** + * The object is not fully constructed after this constructor is called. + * For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + VisualElement(void); + + /** + * Initializes this instance of %VisualElement. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(void); + + /** + * Deallocates this instance and all descendants of %VisualElement. + * + * @since 2.0 + * + * @remarks This method must be used to destroy this instance. @n + * Do not use @c delete operator. + * @remarks This method first destroys children, and then it destroys the parent(this instance). + * @remarks This method will call OnDestructing() callback before deallocating the instance. + * @remarks The destructing sequence is as follows: + * 1. Destroy children recursively. + * 2. Calls %OnDestructing() callback. + * 3. Detaches from parent. + * 4. Removes all animations associated with this instance. + * 5. Deallocates this instance. + * @see Construct() + */ + void Destroy(void); + + /** + * Sets the animation provider which creates implicit animations. + * + * @since 2.0 + * + * @return An error code + * @param[in] pProvider The animation provider to create implicit animations + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION This instance does not allow to set an animation provider. @n + * The animation provider can be set to the model instance only. + * + * @see IVisualElementAnimationProvider + * @see GetAnimationProvider() + */ + result SetAnimationProvider(IVisualElementAnimationProvider* pProvider); + + /** + * Gets the assigned animation provider. + * + * @since 2.0 + * + * @return The animation provider + * @exception E_INVALID_OPERATION This instance does not allow to get an animation provider. @n + * The animation provider can be set to the model instance only. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see IVisualElementAnimationProvider + * @see SetAnimationProvider() + */ + IVisualElementAnimationProvider* GetAnimationProvider(void) const; + + /** + * Sets the content provider which customizes information on contents. + * + * @since 2.0 + * + * @param[in] pProvider The content provider to customize information on content + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION This instance does not allow to set a content provider. @n + * The content provider can be set to the model instance only. + * @see IVisualElementContentProvider + * @see GetContentProvider() + */ + result SetContentProvider(IVisualElementContentProvider* pProvider); + + /** + * Gets the assigned content provider. + * + * @since 2.0 + * + * @return The content provider + * @exception E_INVALID_OPERATION This instance does not allow to get content provider. @n + * The content provider can be set to the model instance only. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see IVisualElementContentProvider + * @see SetContentProvider() + */ + IVisualElementContentProvider* GetContentProvider(void) const; + + /** + * Sets the %VisualElement event listener. + * + * @since 2.0 + * + * @param[in] pListener The %VisualElement event listener + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION This instance does not allow to set an event listener. @n + * The event listener can be set to the model instance only. + * @see IVisualElementEventListener + * @see GetVisualElementEventListener() + */ + result SetVisualElementEventListener(IVisualElementEventListener* pListener); + + /** + * Gets the assigned %VisualElement event listener. + * + * @since 2.0 + * + * @return The %VisualElement event listener + * @exception E_INVALID_OPERATION This instance does not allow to get an event listener. @n + * The event listener can be set to the model instance only. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see IVisualElementEventListener + * @see SetVisualElementEventListener() + */ + IVisualElementEventListener* GetVisualElementEventListener(void) const; + + + /** + * Overrides the OnConstructed() method to provide user-specific initialization code. + * + * @since 2.0 + * + * @remarks This method is called after the instance is initialized by the Construct() method successfully. + * @see Construct() + * @see Destroy() + * @see OnDestructing() + */ + virtual void OnConstructed(void); + + /** + * Overrides the OnDestructing() method to provide user-specific termination code. + * + * @since 2.0 + * + * @remarks This method is called before deallocating the %VisualElement instance by the Destroy() method. + * @see Destroy() + * @see Construct() + * @see OnConstructed() + */ + virtual void OnDestructing(void); + + /** + * Called by the GetChildAt() method to check whether this instance contains the @c point specified. @n + * If the Tizen::Ui::Animations::IVisualElementAnimationProvider interface is set to this instance, + * the Tizen::Ui::Animations::IVisualElementContentProvider::HitTest() callback will be called instead. + * + * @since 2.0 + * + * @return The hit test result + * @param[in] point The hit position in the coordinate space of this instance + * @remarks Hit test results must be one of the following values: @n + * - Tizen::Ui::Animations::HitTestResult::HIT_TEST_NOWHERE + * - Tizen::Ui::Animations::HitTestResult::HIT_TEST_MATCH + * @see GetChildAt() + * @see IVisualElementContentProvider::HitTest() + */ + virtual HitTestResult OnHitTest(const Tizen::Graphics::FloatPoint& point); + + /** + * Before the system calls OnDraw() method to fill the contents, the %OnPrepareDraw() method is called to give an opportunity to hook or prepare drawing. @n + * If the [IVisualElementContentProvider](@ref Tizen::Ui::Animations::IVisualElementContentProvider) interface is set to this instance, + * the [PrepareDraw()](@ref Tizen::Ui::Animations::IVisualElementContentProvider::PrepareDraw) callback will be called instead. + * + * @since 2.0 + * + * @return @c true if OnDraw() can be called, @n + * else @c false + * @see IVisualElementContentProvider::PrepareDraw() + */ + virtual bool OnPrepareDraw(void); + + /** + * Called to fill contents on the canvas provided by the system. @n + * If the [IVisualElementContentProvider](@ref Tizen::Ui::Animations::IVisualElementContentProvider) is set to this instance, + * the [DrawContent()](@ref Tizen::Ui::Animations::IVisualElementContentProvider::DrawContent) callback will be called instead. + * + * @since 2.0 + * + * @param[in] canvas The canvas to fill the contents of %VisualElement + * @see IVisualElementContentProvider::DrawContent() + */ + virtual void OnDraw(Tizen::Graphics::Canvas& canvas); + + /** + * Overrides the %OnCreateAnimationForProperty() method to provide user-specific implicit animation. @n + * If the [IVisualElementAnimationProvider](@ref Tizen::Ui::Animations::IVisualElementAnimationProvider) interface is set to this instance, + * the [CreateAnimationForProperty()](@ref Tizen::Ui::Animations::IVisualElementAnimationProvider::CreateAnimationForProperty) callback will be called instead. + * + * @since 2.0 + * + * @return The VisualElementAnimation instance for the specified property, @n + else @c null to disable implicit animation for the property + * @param[in] property The property to animate implicitly + * @remarks The returned [Animation](@ref Tizen::Ui::Animations::VisualElementAnimation) instance must be allocated on the heap if needed. @n + * If you do not need an implicit animation for the @c property at the time this method is called, return @c null. + * @see IVisualElementAnimationProvider::CreateAnimationForProperty() + */ + virtual VisualElementAnimation* OnCreateAnimationForProperty(const Tizen::Base::String& property); + + /** + * Overrides the %OnGetPropertyRequested() method to provide user-specific properties or to change default behaviors of %VisualElement class. @n + * This method is called whenever GetProperty() is called. + * + * @since 2.0 + * + * @return The property's value + * @param[in] property The property name + * @see SetProperty() + * @see GetProperty() + * @see OnSetPropertyRequested() + */ + virtual Tizen::Ui::Variant OnGetPropertyRequested(const Tizen::Base::String& property) const; + + /** + * Overrides the %OnSetPropertyRequested() method to provide user-specific properties or to change default behaviors of %VisualElement class. @n + * This method is called whenever SetProperty() is called. + * + * @since 2.0 + * + * @return An error code + * @param[in] property The property name + * @param[in] value The value of the property to set + * @see SetProperty() + * @see GetProperty() + * @see OnGetPropertyRequested() + */ + virtual result OnSetPropertyRequested(const Tizen::Base::String& property, const Tizen::Ui::Variant& value); + + /** + * Gets the parent of this instance. + * + * @since 2.0 + * + * @return The parent of the this instance + */ + VisualElement* GetParent(void) const; + + /** + * Gets a list of children of this instance. + * + * @since 2.0 + * + * @return The list of children of this instance + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an exception occurs, this method returns @c null. + */ + Tizen::Base::Collection::IList* GetChildrenN(void) const; + + /** + * Gets the count of children. + * + * @since 2.0 + * + * @return The count of children + */ + int GetChildrenCount(void) const; + + /** + * Checks whether this instance is a child or descendant of the specified one. + * + * @since 2.0 + * + * @return @c true if this instance is a child or descendant of the specified one, @n + * else @c false + * @param[in] other An instance of %VisualElement to test relationship + */ + bool IsChildOf(const VisualElement& other) const; + + /** + * Attaches a child to this instance. @n + * The %AttachChild() method attaches the specified @c child at the highest position in the Z order group of the @c child. + * If you need to change Z-Order group, you can change it using the SetZOrderGroup() method. + * + * @since 2.0 + * + * @return An error code + * @param[in] child The %VisualElement instance to attach to this instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The input parameter is incorrect. Either of the following conditions has occurred: @n + * - The specified @c child is not instantiated successfully. @n + * - The specified @c child is this instance. @n + * - The specified @c child is already an ancestor of this instance. + * @see SetZOrderGroup() + * @see InsertChild() + * @see DetachChild() + * @see ChangeZOrder() + */ + result AttachChild(const VisualElement& child); + + /** + * Inserts a child to this instance. @n + * If @c pReference is not @c null, the Z order group of @c child will be changed into that of @c pReference and @c child will be + * placed right above or below the @c pReference instance according to the @c above parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] child The %VisualElement instance to attach to this instance + * @param[in] pReference A pointer to the %VisualElement instance that is referenced + * @param[in] above Specifies the position of @c child relative to the @c pReference + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The input parameter is incorrect. Either of the following conditions has occurred: @n + * - The specified @c child is not instantiated successfully. @n + * - The specified @c child is this instance. @n + * - The specified @c child and @c pReference are same. @n + * - The specified @c child is already an ancestor of this instance. @n + * - The parent of @c pReference is not this instance if @c pReference is not @c null. @n + * @remarks If @c above is @c true, the @c child will be attached above @c pReference in Z order, + * else it will be attached below the @c pReference %VisualElement. @n + * If @c pReference is @c null, the @c child will be attached at the highest position in the @c child's Z order group, + * else the child will be attached at the lowest position in the @c child's Z order group. + * @see SetZOrderGroup() + * @see AttachChild() + * @see DetachChild() + * @see ChangeZOrder() + */ + result InsertChild(const VisualElement& child, const VisualElement* pReference, bool above); + + /** + * Detaches a child from this instance. + * + * @since 2.0 + * + * @param[in] child The %VisualElement instance to detach from this instance + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified @c child is not a child of this instance. + * @remarks This method detaches @c child from this instance. If you need to deallocate %VisualElement, call Destroy() method, not C++ delete. + * @see InsertChild() + * @see AttachChild() + */ + result DetachChild(const VisualElement& child); + + /** + * Changes Z order of this instance. + * + * @since 2.0 + * + * @param[in] pReference A pointer to the %VisualElement instance that is referenced + * @param[in] above Specifies the position of this instance relative to the @c pReference + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The input parameter is incorrect. Either of the following conditions has occurred: @n + * - This instance does not have a parent (not attached). @n + * - This instance and @c pReference do not have same parent if @c pReference is not @c null. @n + * - The specified @c pReference is this instance. @n + * @remarks If @c above is @c true, this instance will be attached above @c pReference in Z order, + * else it will be attached below the @c pReference %VisualElement. @n + * If @c pReference is @c null, this instance will be attached at the highest position in the Z order group of this instance, + * else the child will be attached at the lowest position in the Z order group of this instance. + * @see InsertChild() + * @see AttachChild() + * @see DetachChild() + */ + result ChangeZOrder(const VisualElement* pReference, bool above); + + /** + * Gets the child of the specified @c name. @n + * If there are multiple matches of the name, it returns the first match. + * + * @since 2.0 + * + * @return The %VisualElement instance having the specified @c name @n + * else @c null if there is not %VisualElement with the specified @c name + * @param[in] name The name of the %VisualElement + * @param[in] searchDescendants @c true to find a match among all the descendants of this instance, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND There is no %VisualElement with the specified @c name. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an exception occurs, this method returns @c null. + * @see GetName() + * @see SetName() + */ + VisualElement* GetChild(const Tizen::Base::String& name, bool searchDescendants) const; + + /** + * Gets the farthest (highest Z order) %VisualElement descendant including this instance that contains a specified @c point. @n + * The OnHitTest() method or [HitTest](@ref Tizen::Ui::Animations::IVisualElementContentProvider::HitTest) callback may be called + * for descendants of this instance including itself. + * + * @since 2.0 + * + * @return The %VisualElement that contains @c point, @n + * else @c null if @c point is completely outside of this instance + * @param[in] point The position in coordinate space of this instance + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND There is no %VisualElement containing the specified @c point. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an exception occurs, this method returns @c null. + * @remarks This method assumes that all ancestors of this instance do not clip children. + * @see IVisualElementContentProvider::HitTest() + * @see OnHitTest() + * @see IsClipChildrenEnabled() + * @see SetClipChildrenEnabled() + */ + VisualElement* GetChildAt(const Tizen::Graphics::FloatPoint& point) const; + + /** + * Adds an animation without key name. + * + * @since 2.0 + * + * @return An error code + * @param[in] animation The animation instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The input parameter is incorrect. + * @exception E_INVALID_OPERATION This instance is not a model object. @n + * An animation can be added to the model instance only. + * @see RemoveAnimation() + * @see GetAnimationN() + */ + result AddAnimation(const VisualElementAnimation& animation); + + /** + * Adds an animation with key name. + * + * @since 2.0 + * + * @return An error code + * @param[in] keyName The name of the animation that is used to identify animations @n + * Empty @c keyName is allowed. + * @param[in] animation The animation instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The input parameter is incorrect. + * @exception E_OBJ_ALREADY_EXIST An animation with @c keyName already exists. + * @exception E_INVALID_OPERATION This instance is not a model object. @n + * An animation can be added to the model instance only. + * @see RemoveAnimation() + * @see GetAnimationN() + */ + result AddAnimation(const Tizen::Base::String& keyName, const VisualElementAnimation& animation); + + /** + * Removes the animation with the specified @c keyName. + * + * @since 2.0 + * + * @return An error code + * @param[in] keyName The name of the animation to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND An animation with @c keyName does not exist. + * @see AddAnimation() + * @see GetAnimationN() + */ + result RemoveAnimation(const Tizen::Base::String& keyName); + + /** + * Gets the animation playing for the specified property. + * + * @since 2.0 + * + * @return A pointer to the animation + * @param[in] keyName The name of the animation + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND An animation with @c keyName does not exist. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an exception occurs, this method returns @c null. + * @see AddAnimation() + * @see RemoveAnimation() + */ + VisualElementAnimation* GetAnimationN(const Tizen::Base::String& keyName) const; + + /** + * Removes all animations. + * + * @since 2.0 + * + * @see AddAnimation() + * @see RemoveAnimation() + */ + void RemoveAllAnimations(void); + + /** + * Adds a rectangle to update region of this instance. @n + * The update region represents the portion of the %VisualElement's area that must be redrawn by the OnDraw() method. + * + * @since 2.0 + * + * @return An error code + * @param[in] pRectangle The pointer to the rectangular region that contains the coordinates of the rectangle to add to the update region @n + * If @c pRectangle is @c null, entire area is added to the update region. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The contents of this instance is set by the SetSurface() method. + * @see SetSurface() + */ + result InvalidateRectangle(const Tizen::Graphics::FloatRectangle* pRectangle); + + /** + * Gets the smallest rectangle that completely encloses the update region of this instance. @n + * Applications can use the update region in the OnDraw() method to minimize the redrawing area to improve performance. + * The %GetUpdateRectangle() method returns an empty rectangle if it is not called inside OnDraw() method. + * + * @since 2.0 + * + * @return The rectangle to update + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an exception occurs, this method returns FloatRectangle(0.0, 0.0, -1.0, -1.0). + * @see InvalidateRectangle() + */ + Tizen::Graphics::FloatRectangle GetUpdateRectangle(void) const; + + /** + * Updates the content area of all the descendants including this instance. + * The %Draw() method will call OnDraw() or DrawContent() method only if there are regions invalidated by InvalidateRectangle(). + * The platform will call this method later automatically if applications do not call explicitly. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is not attached to the maintained tree for displaying. @n + * For displaying, this instance should be descendant of the root %VisualElement. + * @exception E_SYSTEM A system error has occurred. + * @see IVisualElementContentProvider + */ + result Draw(void); + + /** + * Marks the entire area of this instance to be flushed. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * + * @see Flush() + */ + result SetFlushNeeded(void); + + /** + * Creates and returns a graphics canvas whose bounds, position, and size are equal to those of this instance. + * + * @since 2.0 + * + * @return The graphic canvas of the %VisualElement, @n + * else @c null if an exception occurs + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_OPERATION The contents of this instance is set by the SetSurface() method. + * @exception E_OUT_OF_RANGE The size of the %VisualElement instance is @c 0 or smaller. + * @remarks This method allocates a Tizen::Graphics::Canvas whose bounds are equal to that of the %VisualElement. + * It is the developer's responsibility to deallocate the canvas after use. + * The canvas is guaranteed to be valid only if the properties of the parent %VisualElement of the canvas remain unchanged. + * Therefore, one must delete previously allocated canvas and create a new canvas using this method, + * if the size or position of the %VisualElement is changed. @n + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an exception occurs, this method returns @c null. + * @see GetCanvasN(const Tizen::Graphics::Rectangle& bounds) + */ + Tizen::Graphics::Canvas* GetCanvasN(void) const; + + + /** + * Creates and returns a graphic canvas of the specified area. + * + * @since 2.0 + * + * @return The graphic canvas of the %VisualElement, @n + * else @c null if an exception occurs + * @param[in] bounds The position relative to the top-left corner of the %VisualElement and size + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_OPERATION The contents of this instance is set by the SetSurface() method. + * @exception E_OUT_OF_RANGE The specified @c bounds do not intersect with the bounds of the %VisualElement. @n + * The width and height must be greater than @c 0. + * @remarks Only the graphic canvas of displayable %VisualElement can be obtained. + * If the specified area is not inside the %VisualElement, + * the graphics canvas of overlapped area between the %VisualElement and the specified @c bound is returned. @n + * This method allocates a Tizen::Graphics::Canvas whose bounds are equal to that of the %VisualElement. + * It is the developer's responsibility to deallocate the canvas after use. + * The canvas is guaranteed to be valid only if the properties of the parent %VisualElement of the canvas remain unchanged. + * Therefore, one must delete previously allocated canvas and create a new canvas using this method, + * if the size or position of the control is changed. @n + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an exception occurs, this method returns @c null. + * @see GetCanvasN() + */ + Tizen::Graphics::Canvas* GetCanvasN(const Tizen::Graphics::Rectangle& bounds) const; + + /** + * Gets the name of this instance. + * + * @since 2.0 + * + * @return The name of this instance + */ + Tizen::Base::String GetName(void) const; + + /** + * Sets the name of this instance. + * + * @since 2.0 + * + * @param[in] name The name of the %VisualElement instance @n + * Empty or duplicated name with other instances are also allowed. + */ + void SetName(const Tizen::Base::String& name); + + /** + * Gets the value of the %VisualElement's property. + * + * @since 2.0 + * + * @return The value of the specified property + * @param[in] property The %VisualElement's property + * @exception E_SUCCESS The method is successful. + * @exception E_KEY_NOT_FOUND The specified @c property is not found. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an exception occurs, this method returns @c Variant::NULL_VARIANT. + * @remarks Additional exceptions can occur according to the behavior of subclasses. + * @see SetProperty() + * @see OnGetPropertyRequested() + */ + Variant GetProperty(const Tizen::Base::String& property) const; + + /** + * Sets the value of the %VisualElement's property. + * + * @since 2.0 + * + * @return The property's value + * @param[in] property The %VisualElement's property + * @param[in] value The value of the %VisualElement's property to set + * @exception E_SUCCESS The method is successful. + * @exception E_KEY_NOT_FOUND The specified @c property is not found. + * @remarks Additional exceptions can occur according to the behavior of subclasses. + * @see GetProperty() + * @see OnSetPropertyRequested() + */ + result SetProperty(const Tizen::Base::String& property, const Variant& value); + + /** + * Sets the Z order group of this instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] zOrderGroup The value of Z order which must be between @c Z_ORDER_GROUP_LOWEST and @c Z_ORDER_GROUP_HIGHEST @n + * The default value is @c Z_ORDER_GROUP_NORMAL. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The @c zOrderGroup is not between @c Z_ORDER_GROUP_LOWEST and @c Z_ORDER_GROUP_HIGHEST. + * @remarks You can choose the @c zOrderGroup value as follows: @n + * - Tizen::Ui::Animations::Z_ORDER_GROUP_LOWEST @n + * - Tizen::Ui::Animations::Z_ORDER_GROUP_NORMAL @n + * - Tizen::Ui::Animations::Z_ORDER_GROUP_HIGHEST @n + * Or you can specify an integer value between @c ZORDER_GROUP_LOWEST and @c ZORDER_GROUP_HIGHEST. + * @see GetZOrderGroup() + */ + result SetZOrderGroup(int zOrderGroup); + + /** + * Gets the Z order group of this instance. + * + * @since 2.0 + * + * @return The Z order group of this instance + * @see SetZOrderGroup() + */ + int GetZOrderGroup(void) const; + + /** + * Checks whether the redraw-on-resize feature is enabled. + * + * @since 2.0 + * + * @return @c true if the redraw-on-resize feature is enabled, @n + * else @c false + * @remarks The entire content area will be added to the update region when bounds are changed if redraw-on-resize is enabled. @n + * Otherwise, current contents will be scaled for the new bounds of this instance without redrawing. + * @see SetRedrawOnResizeEnabled() + */ + bool IsRedrawOnResizeEnabled(void) const; + + /** + * Enables or disables the redraw-on-resize feature. + * + * @since 2.0 + * + * @param[in] enable Set to @c true if invalidation is needed whenever resized, @n + * else @c false + * @see IsRedrawOnResizeEnabled() + */ + void SetRedrawOnResizeEnabled(bool enable); + + /** + * Gets the position and the size of this instance. + * + * @since 2.0 + * + * @return An instance of the Tizen::Graphics::FloatRectangle that represents the position of top-left corner, @n + * the width, and the height of this instance. @n It has relative coordinate space to the parent. + * @see SetBounds() + */ + Tizen::Graphics::FloatRectangle GetBounds(void) const; + + /** + * Sets the position and the size of this instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] bounds The new bounds of this instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @remarks When the size of @c bounds is changed, the entire content area will be added to the update region of this instance if redraw-on-resize feature is enabled. + * @see GetBounds() + * @see IsRedrawOnResizeEnabled() + * @see SetRedrawOnResizeEnabled() + */ + result SetBounds(const Tizen::Graphics::FloatRectangle& bounds); + + /** + * Gets the position on the Z-axis. + * + * @since 2.0 + * + * @return The position on the Z-axis + * @see SetZPosition() + */ + float GetZPosition(void) const; + + /** + * Sets the position on the Z-axis. + * + * @since 2.0 + * + * @param[in] zPosition The position on the Z-axis + * @see GetZPosition() + */ + void SetZPosition(float zPosition); + + /** + * Checks whether this instance is visible or not. @n + * Even if the show state is @c true, this instance can be invisible when show state of one of the ancestors is @c false. + * + * @since 2.0 + * + * @return @c true if this instance is visible, @n + * else @c false + * @see GetShowState() + * @see SetShowState() + */ + bool IsVisible(void) const; + + /** + * Gets the show state of this instance. + * + * @since 2.0 + * + * @return The show state of the %VisualElement instance, @n + * else @c false + * @remarks Even if the show state is @c true, the %VisualElement is invisible if it is not attached to a parent. + * @see SetShowState() + * @see IsVisible() + */ + bool GetShowState(void) const; + + /** + * Sets the show state of this instance. + * + * @since 2.0 + * + * @param[in] show Set to @c true if this instance needs to show, @n + * else @c false + * @see GetShowState() + * @see IsVisible() + */ + void SetShowState(bool show); + + /** + * Gets the opacity of this instance. + * + * @since 2.0 + * + * @return The opacity of this instance + * @see SetOpacity() + */ + float GetOpacity(void) const; + + /** + * Sets the opacity of this instance. + * + * @since 2.0 + * + * @param[in] opacity The new opacity which must be within the range [0.0, 1.0] + * @remarks The changing opacity affects all the descendants of this instance. + * @see GetOpacity() + */ + void SetOpacity(float opacity); + + /** + * Enables or disables the implicit animation. @n + * If enabled, implicit animations may be created whenever animatable properties of this instance change. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable the implicit animation, @n + * else @c false + * @remarks The implicit animation is enabled by default. + * @see IsImplicitAnimationEnabled() + */ + void SetImplicitAnimationEnabled(bool enable); + + /** + * Checks whether the implicit animation is enabled. + * + * @since 2.0 + * + * @return @c true if the implicit animation is enabled, @n + * else @c false + * @see SetImplicitAnimationEnabled() + */ + bool IsImplicitAnimationEnabled(void) const; + + /** + * Gets the transform matrix of this instance. + * + * @since 2.0 + * + * @return The transform matrix of this instance + * @see SetTransformMatrix() + */ + Tizen::Graphics::FloatMatrix4 GetTransformMatrix(void) const; + + /** + * Sets the transform matrix of this instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] transform The transform matrix + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The input parameter is incorrect. @n + * The E_INVALID_ARG exception occurs when the specified @c transform is not invertible. + * @see GetTransformMatrix() + */ + result SetTransformMatrix(const Tizen::Graphics::FloatMatrix4& transform); + + /** + * Gets the transform matrix applied to each child. + * + * @since 2.0 + * + * @return The transform matrix applied to each child + * @remarks The transform matrix for children is typically used for the projection matrix to layout children in 3D space. + * @see SetChildrenTransformMatrix() + */ + Tizen::Graphics::FloatMatrix4 GetChildrenTransformMatrix(void) const; + + /** + * Sets the transform matrix applied to each child. + * + * @since 2.0 + * + * @return An error code + * @param[in] transform The transform matrix + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The input parameter is incorrect. @n + * The E_INVALID_ARG exception occurs when the specified @c transform is not invertible. + * @see GetChildrenTransformMatrix() + */ + result SetChildrenTransformMatrix(const Tizen::Graphics::FloatMatrix4& transform); + + + /** + * Gets the anchor point for this instance's transform matrix in uniform coordinate space + * (0.0 and 1.0 mean left/top and right/bottom of the bounds, respectively). + * + * @since 2.0 + * + * @return The anchor point of this instance + * @see SetAnchor() + */ + Tizen::Graphics::FloatPoint GetAnchor(void) const; + + /** + * Sets the anchor point of this instance's transform matrix in uniform coordinate space + * (0.0 and 1.0 mean left/top and right/bottom of the bounds, respectively). + * + * @since 2.0 + * + * @param[in] anchor The anchor point in uniform coordinate space + * @see GetAnchor() + */ + void SetAnchor(const Tizen::Graphics::FloatPoint& anchor); + + /** + * Gets the Z component of this instance's anchor point for transform matrix. + * + * @since 2.0 + * + * @return The Z component of the anchor point + * @see SetAnchorZ() + */ + float GetAnchorZ(void) const; + + /** + * Sets the Z component of this instance's anchor point for transform matrix. + * + * @since 2.0 + * + * @param[in] anchorZ The Z component of anchor point + * @see GetAnchorZ() + */ + void SetAnchorZ(float anchorZ); + + /** + * Gets the custom data of this instance. + * + * @since 2.0 + * + * @return The user data associated with this instance + * @see SetUserData() + */ + void* GetUserData(void) const; + + /** + * Sets the custom data of this instance. + * + * @since 2.0 + * + * @param[in] pUserData The user data associated with this instance + * @see GetUserData() + */ + void SetUserData(void* pUserData); + + /** + * Sets the contents of this instance with the specified VisualElementSurface. @n + * The contents of the @c pSurface is not copied by the %SetSurface() method, but shared with this instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] pSurface The pointer to VisualElementSurface @n + * If @c pSurface is @c null, surface will be created internally by system. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION This instance does not allow VisualElementSurface for contents. + * @remarks If applications modify the contents of @c pSurface, the modifications will be applied to all + * the %VisualElements which share same VisualElementSurface. But in this case, applications need to call + * the SetFlushNeeded() method for those %VisualElements because the modifications of the @c pSurface will not be applied on the screen automatically. + * @see GetSurfaceN() + */ + result SetSurface(VisualElementSurface* pSurface); + + /** + * Gets the VisualElementSurface this instance uses for its contents. + * + * @since 2.0 + * + * @return A pointer to VisualElementSurface + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an exception occurs, this method returns @c null. + * @see SetSurface() + */ + VisualElementSurface* GetSurfaceN(void) const; + + /** + * Sets the render operation of this instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] renderOperation The new rendering operation + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c renderOperation is out of range. + * @see GetRenderOperation() + */ + result SetRenderOperation(RenderOperation renderOperation); + + /** + * Gets the render operation of this instance. + * + * @since 2.0 + * + * @return The render operation of this instance + * @see SetRenderOperation() + */ + RenderOperation GetRenderOperation(void) const; + + /** + * Checks whether all the descendants are clipped to the bounds of this instance. + * + * @since 2.0 + * + * @return @c true if this instance clips all the descendants, @n + * else @c false + * @see SetClipChildrenEnabled() + */ + bool IsClipChildrenEnabled(void) const; + + /** + * Enables or disables clipping of all the descendants. + * + * @since 2.0 + * + * @param[in] clipChildren Set to @c true if all the descendants are needed to clip to the bounds of this instance, @n + * else @c false + * @see IsClipChildrenEnabled() + */ + void SetClipChildrenEnabled(bool clipChildren); + + /** + * Converts the specified @c point in @c pFromVisualElement coordinate space to this instance's coordinate space. + * + * @since 2.0 + * + * @return An error code + * @param[in,out] point The point to convert + * @param[in] pFromVisualElement The %VisualElement instance with @c point in its coordinate space + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The input parameter is incorrect. + * @remarks This instance and @c pFromVisualElement must share a common ancestor. @n + * If @c null, it is regarded that @c point is in the screen coordinate space. + * @see ConvertCoordinates(Tizen::Graphics::FloatRectangle& rectangle, const VisualElement* pFromVisualElement) + */ + result ConvertCoordinates(Tizen::Graphics::FloatPoint& point, const VisualElement* pFromVisualElement) const; + + /** + * Converts the specified @c rectangle in @c pFromVisualElement coordinate space to this instance's coordinate space. + * + * @since 2.0 + * + * @return An error code + * @param[in,out] rectangle The rectangle to convert + * @param[in] pFromVisualElement The %VisualElement instance with @c rectangle in its coordinate space + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The input parameter is incorrect. + * @exception E_SYSTEM A system error has occurred. + * @remarks This instance and @c pFromVisualElement must share a common parent. @n + * If @c null, it is regarded that @c rectangle is in the screen coordinate space. + * @see ConvertCoordinates(Tizen::Graphics::FloatPoint& point, const VisualElement* pFromVisualElement) + */ + result ConvertCoordinates(Tizen::Graphics::FloatRectangle& rectangle, const VisualElement* pFromVisualElement) const; + + /** + * Sets the sub-rectangle of contents which this instance must display. + * + * @since 2.0 + * + * @return An error code + * @param[in] contentBounds The sub-rectangle of contents to display in uniform coordinate space + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The width and height of @c contentBounds must be greater than @c 0.0. + * @remarks Default @c contentBounds is FloatRectangle(0.0, 0.0, 1.0, 1.0). + * @remarks If each component of @c contentBounds is not within the range [0.0, 1.0], the integer portion of the coordinates are + * ignored and only fractional part is used which creates a repeating contents. + * @see GetContentBounds() + */ + result SetContentBounds(const Tizen::Graphics::FloatRectangle& contentBounds); + + /** + * Gets the sub-rectangle of contents which this instance must display. + * + * @since 2.0 + * + * @return The sub-rectangle of contents to be displayed in uniform coordinate space + * @remarks Default @c contentBounds is FloatRectangle(0.0, 0.0, 1.0, 1.0). + * @see SetContentBounds() + */ + Tizen::Graphics::FloatRectangle GetContentBounds(void) const; + + /** + * Acquires the %VisualElement instance for display. + * + * @since 2.0 + * + * @return The %VisualElement instance for display(readonly) + * @remarks If this instance is a presentation object, this method returns itself. + * @see ReleasePresentationInstance() + */ + const VisualElement* AcquirePresentationInstance(void); + + /** + * Releases the %VisualElement instance for display. + * + * @since 2.0 + * + * @remarks This method should be called only after AcquirePresentationInstance() call. + * @see AcquirePresentationInstance() + */ + void ReleasePresentationInstance(void); + + /** + * Acquires the %VisualElement instance for model. + * + * @since 2.0 + * + * @return The %VisualElement instance for model(readonly) + * @remarks If this instance is a model object, this method returns itself. + * @see ReleaseModelInstance() + */ + + const VisualElement* AcquireModelInstance(void); + + /** + * Releases the %VisualElement instance for model. + * + * @since 2.0 + * + * @remarks This method should be called only after AcquireModelInstance() call. + */ + void ReleaseModelInstance(void); + + /** + * Flushes %VisualElements on screen. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks Because this method may degrade the performance of system, applications must use this method only when really needed. + * @see SetFlushNeeded() + */ + static result Flush(void); + + +protected: + /** + * This is copy constructor for the %VisualElement class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %VisualElement + * @see CloneN() + */ + VisualElement(const VisualElement& rhs); + + /** + * This is the destructor for this class. + * + * @since 2.0 + * + * @remarks The delete operator cannot be used to deallocate the %VisualElement instance. + * @see Destroy() + */ + virtual ~VisualElement(void); + + /** + * Creates and returns a polymorphic copy of this %VisualElement instance for the presentation. @n + * All descendants of %VisualElement must implement the %CloneN() method and the copy constructor appropriately. @n + * When the %VisualElement instance is created, the framework make a %VisualElement for the presentation with this method. + * + * @since 2.0 + * + * @return The clone of this instance + */ + virtual VisualElement* CloneN(void) const; + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void VisualElement_Reserved1(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void VisualElement_Reserved2(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void VisualElement_Reserved3(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void VisualElement_Reserved4(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void VisualElement_Reserved5(void) {} + + +private: + + // + // The implementation of this assignment constructor is intentionally blank to prohibit assignment of objects. + // + // @since 2.0 + // + VisualElement& operator =(const VisualElement& rhs); + + +protected: + _VisualElementImpl* _pVisualElementImpl; + + friend class _VisualElementImpl; +}; // VisualElement + + +}}} // Tizen::Ui::Animations + +#endif //_FUIANIMVISUALELEMENT_H_ diff --git a/inc/FUiAnimVisualElementAnimation.h b/inc/FUiAnimVisualElementAnimation.h new file mode 100644 index 0000000..0bf0619 --- /dev/null +++ b/inc/FUiAnimVisualElementAnimation.h @@ -0,0 +1,465 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementAnimation.h + * @brief This is the header file for the %VisualElementAnimation class. + * + * This header file contains the declarations of the %VisualElementAnimation class. + */ + +#ifndef _FUI_ANIM_VISUAL_ELEMENT_ANIMATION_H_ +#define _FUI_ANIM_VISUAL_ELEMENT_ANIMATION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +class IVisualElementAnimationStatusEventListener; +class IVisualElementAnimationTimingFunction; +class IVisualElementAnimationValueInterpolator; +class _VisualElementAnimationImpl; + +/** + * @class VisualElementAnimation + * @brief This class is the base class for all the %VisualElementAnimation classes. + * + * @since 2.0 + * + * The %VisualElementAnimation class defines the basic animation properties, such as the interpolator to be used, + * the duration of the animation in milliseconds, the delay before the animation is started in milliseconds, and the repeat count. + * + * For more information on the class features, see Visual Element Animations. + * + */ +class _OSP_EXPORT_ VisualElementAnimation + : public Tizen::Base::Object +{ +public: + + /** + * This is the default constructor for this class. + * + * @since 2.0 + * + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + VisualElementAnimation(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~VisualElementAnimation(void); + + + /** + * This is the copy constructor for the %VisualElementAnimation class. + * + * @since 2.0 + * + * @param[in] animation An instance of %VisualElementAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + VisualElementAnimation(const VisualElementAnimation& animation); + + + /** + * Assigns the value of the specified instance to the current instance of %VisualElementAnimation. + * + * @since 2.0 + * + * @param[in] rhs An instance of %VisualElementAnimation + */ + VisualElementAnimation& operator =(const VisualElementAnimation& rhs); + + + /** + * Checks whether the specified instance and current instance of %VisualElementAnimation have equal animation values. + * + * @since 2.0 + * + * @return @c true if the animation of the two instances of %VisualElementAnimation are equal, @n + * else @c false + * @param[in] rhs An instance of %VisualElementAnimation + */ + bool operator ==(const VisualElementAnimation& rhs) const; + + + /** + * Checks whether the specified instance and current instance of %VisualElementAnimation have different animation values. + * + * @since 2.0 + * + * @return @c true if the values of the animations of the two instances of %VisualElementAnimation are not equal, @n + * else @c false + * @param[in] rhs An instance of %VisualElementAnimation + */ + bool operator !=(const VisualElementAnimation& rhs) const; + + + /** + * Checks whether the value of the current instance of %VisualElementAnimation equals the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance equals the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %VisualElementAnimation + * @remarks The %VisualElementAnimation class has a semantic value which means that this method checks whether the two instances have the same animation. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The two equal instances must return the same hash value. + * For better performance, the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + + /** + * Gets the copied instance of the class. + * + * @since 2.0 + * + * @return An instance of %VisualElementAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + virtual VisualElementAnimation* CloneN(void) const; + + + /** + * Sets an IVisualElementAnimationStatusEventListener listener instance to listen to the events of a particular animation. @n + * The added listener, %IVisualElementAnimationStatusEventListener, can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] pListener The listener instance to set + */ + void SetVisualElementAnimationStatusEventListener(IVisualElementAnimationStatusEventListener* pListener); + + + /** + * Gets the IVisualElementAnimationStatusEventListener listener. + * + * @since 2.0 + * + * @return A pointer to the IVisualElementAnimationStatusEventListener instance @n + * If listener has not been set, @c null is returned. + * @see SetVisualElementAnimationStatusEventListener() + */ + IVisualElementAnimationStatusEventListener* GetVisualElementAnimationStatusEventListener(void) const; + + + /** + * Sets the timing function to calculate the animation pace. + * + * @since 2.0 + * + * @param[in] pTimingFunction The timing function instance to set + * @remarks If @c pTimingFunction is @c null, the default timing function is used which is pre-defined by the UI framework. + * @see GetTimingFunction() + */ + void SetTimingFunction(const IVisualElementAnimationTimingFunction* pTimingFunction); + + + /** + * Gets the timing function. + * + * @since 2.0 + * + * @return A pointer to the timing function instance + * If timing function has not been set, the default timing function is returned. + * @see SetTimingFunction() + */ + const IVisualElementAnimationTimingFunction* GetTimingFunction(void) const; + + + /** + * Sets the interpolator to calculate the current value for the specific time during the animation. + * + * @since 2.0 + * + * @param[in] pInterpolator The interpolator instance to set + * @remarks If @c pInterpolator is @c null, the default interpolator is used which is pre-defined by the UI framework. + * @see GetValueInterpolator() + */ + void SetValueInterpolator(const IVisualElementAnimationValueInterpolator* pInterpolator); + + + /** + * Gets the value interpolator. + * + * @since 2.0 + * + * @return A pointer to the interpolator instance + * If interpolator has not been set, the default interpolator is returned. + * @see SetValueInterpolator() + */ + const IVisualElementAnimationValueInterpolator* GetValueInterpolator(void) const; + + + /** + * Sets the duration of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] milliseconds The duration of the animation in milliseconds + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative or lesser than the offset of the animation. + * @see GetDuration() + */ + result SetDuration(long milliseconds); + + + /** + * Gets the duration of the animation in milliseconds. + * + * @since 2.0 + * + * @return The duration value of the animation + * @see SetDuration() + */ + long GetDuration(void) const; + + + /** + * Sets the offset value of the animation. @n + * Additionally, the %SetOffset() alters the start value and duration for which an animation is played. + * + * @since 2.0 + * + * @return An error code + * @param[in] milliseconds The offset of the animation in milliseconds + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative or greater than the duration of the animation. + * @remarks If the start value of the animation is @c 0.0, the end value is @c 1.0, the duration is @c 100 ms and the offset value is @c 20 ms, + * the actual animation starts at @c 0th ms and plays for @c 80 ms with a start value of @c 0.2. @n + * If @c autoReverse is set to @c true, the backward animation plays for @c 100ms, from @c 1.0 to @c 0.0. + * @see GetOffset() + */ + result SetOffset(long milliseconds); + + + /** + * Gets the offset value in milliseconds after the animation starts. + * + * @since 2.0 + * + * @return The offset value of the animation in milliseconds @n + * The default value of the offset is @c 0. + * @see SetOffset() + */ + long GetOffset(void) const; + + + /** + * Sets the delay for the animation. @n + * The animation starts after the duration of delay has passed. + * + * @since 2.0 + * + * @return An error code + * @param[in] milliseconds The delay for the animation to start in milliseconds + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative. + * @remarks This method does not alter the start, end, and duration values of the animation. + * @see GetDelay() + */ + result SetDelay(long milliseconds); + + + /** + * Gets the delay value in milliseconds before the animation starts. + * + * @since 2.0 + * + * @return The delay value in milliseconds @n + * The default value of the delay is @c 0. + * @see SetDelay() + */ + long GetDelay(void) const; + + + /** + * Sets the repeat count for the animation. @n + * Repeats an animation for the specified number of times. + * + * @since 2.0 + * + * @return An error code + * @param[in] count The number of times the animation is repeated + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is negative. + * @remarks A delay and offset is applied to an animation only when the animation is played for the first time. + * If @c count is set to @c 0, the animation is repeated indefinitely. + * @see GetRepeatCount() + */ + result SetRepeatCount(long count); + + + /** + * Gets the repeat count value of the animation. + * + * @since 2.0 + * + * @return The repeat count value of the animation @n + * The default value of the repeat count is @c 1. + * @see SetRepeatCount() + */ + long GetRepeatCount(void) const; + + + /** + * Sets the @c autoReverse property of the animation. @n + * If enabled, the forward and backward animation can also be played. + * + * @since 2.0 + * + * @param[in] autoReverse Set to @c true to enable the @c autoReverse property of the animation, @n + * else @c false + * @remarks If @c autoReverse is set to @c true, the duration of the animation is doubled. + * If the repeat count is more than @c 1, @c autoReverse is applied to each iteration. @n + * Note that if @c autoReverse is set to @c true, one forward animation play and + * one backward animation play is one iteration. + * @see IsAutoReverseEnabled() + */ + void SetAutoReverseEnabled(bool autoReverse); + + + /** + * Checks whether auto reverse is enabled. + * + * @since 2.0 + * + * @return @c true if auto reverse is enabled, @n + * else @c false @n + * The default auto reverse value is @c false. + * @see SetAutoReverseEnabled() + */ + bool IsAutoReverseEnabled(void) const; + + + /** + * Sets the scale ratio of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] scaleRatio The scale ratio value of the animation + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of the specified parameter is below @c 0. + * @remarks If @c scaleRatio is @c 0.5, then the animation speed is 2 times faster. + * @see GetScaleRatio() + */ + result SetScaleRatio(float scaleRatio); + + + /** + * Gets the scale ratio value of the animation. + * + * @since 2.0 + * + * @return The scale ratio value of the animation @n + * The default value of scale ratio is @c 1.0f. + * @see SetScaleRatio() + */ + float GetScaleRatio(void) const; + + + /** + * Sets the custom data of the animation. + * + * @since 2.0 + * + * @param[in] pUserData The user data associated with this instance + * @see GetUserData() + */ + void SetUserData(void* pUserData); + + + /** + * Gets the custom data of the animation. + * + * @since 2.0 + * + * @return The user data associated with this instance + * @see SetUserData() + */ + void* GetUserData(void) const; + + + /** + * Gets the predefined timing function by name. + * + * @since 2.0 + * + * @return The specified timing function + * @param[in] name The timing function name + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @remarks The parameter @c name must be "Linear", "EaseIn", "EaseOut", "EaseInOut", "EaseOutIn", "Discrete", "Bezier", "ExpIn", "ExpOut", "EaseElasticIn", or "EaseElasticOut". + * The specific error code can be accessed using the GetLastResult() method. + */ + static const IVisualElementAnimationTimingFunction* GetTimingFunctionByName(const Tizen::Base::String& name); + + +protected: + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the constructor for derived classes. + // + // @since 2.0 + // + VisualElementAnimation(_VisualElementAnimationImpl* pImpl); + + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // @since 2.0 + // + _VisualElementAnimationImpl* _pAnimationImpl; + + friend class _VisualElementAnimationImpl; +}; // VisualElementAnimation + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_VISUAL_ELEMENT_ANIMATION_H_ diff --git a/inc/FUiAnimVisualElementAnimationGroup.h b/inc/FUiAnimVisualElementAnimationGroup.h new file mode 100644 index 0000000..1f35f14 --- /dev/null +++ b/inc/FUiAnimVisualElementAnimationGroup.h @@ -0,0 +1,239 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementAnimationGroup.h + * @brief This is the header file for the %VisualElementAnimationGroup class. + * + * This header file contains the declarations of the %VisualElementAnimationGroup class. + */ + +#ifndef _FUI_ANIM_VISUAL_ELEMENT_ANIMATION_GROUP_H_ +#define _FUI_ANIM_VISUAL_ELEMENT_ANIMATION_GROUP_H_ + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _VisualElementAnimationGroupImpl; + +/** + * @class VisualElementAnimationGroup + * @brief This class is used to group a set of animations together. + * + * @since 2.0 + * + * The %VisualElementAnimationGroup class is used to group a set of animations together. + * + * For more information on the class features, see Groups. + */ +class _OSP_EXPORT_ VisualElementAnimationGroup + : public VisualElementAnimation +{ +public: + + /** + * This is the default constructor for this class. + * + * @since 2.0 + * + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + VisualElementAnimationGroup(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~VisualElementAnimationGroup(void); + + + /** + * This is the copy constructor for the %VisualElementAnimationGroup class. + * + * @since 2.0 + * + * @param[in] animationGroup An instance of %VisualElementAnimationGroup + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + VisualElementAnimationGroup(const VisualElementAnimationGroup& animationGroup); + + + /** + * Assigns the value of the specified instance to the current instance of %VisualElementAnimationGroup. + * + * @since 2.0 + * + * @param[in] rhs An instance of %VisualElementAnimationGroup + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + VisualElementAnimationGroup& operator =(const VisualElementAnimationGroup& rhs); + + + /** + * Checks whether the specified instance and current instance of %VisualElementAnimationGroup have equal animation values. + * + * @since 2.0 + * + * @return @c true if the animation of the two instances of %VisualElementAnimationGroup are equal, @n + * else @c false + * @param[in] rhs An instance of %VisualElementAnimationGroup + */ + bool operator ==(const VisualElementAnimationGroup& rhs) const; + + + /** + * Checks whether the specified instance and current instance of %VisualElementAnimationGroup have different animation values. + * + * @since 2.0 + * + * @return @c true if the values of the animations of the two instances of %VisualElementAnimationGroup are not equal, @n + * else @c false + * @param[in] rhs An instance of %VisualElementAnimationGroup + */ + bool operator !=(const VisualElementAnimationGroup& rhs) const; + + + /** + * Checks whether the value of the current instance of %VisualElementAnimationGroup equals the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance equals the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %VisualElementAnimationGroup + * @remarks The %VisualElementAnimationGroup class has a semantic value that means this method checks whether the two instances have the same animation. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The two equal instances must return the same hash value. + * For better performance, the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + /** + * Gets the copied instance of the class. + * + * @since 2.0 + * + * @return An instance of VisualElementAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + virtual VisualElementAnimation* CloneN(void) const; + + + /** + * Gets the number of animations currently stored in a group. + * + * @since 2.0 + * + * @return The total number of animations stored in a group + * @remarks If an error occurs, the return value is @c -1. @n + * An element of %VisualElementAnimationGroup is counted as one. + */ + int GetAnimationCount(void) const; + + + /** + * Adds the specified @c animation to the animation group without key name. + * + * @since 2.0 + * + * @return An error code + * @param[in] animation An instance of VisualElementAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @see RemoveAnimationAt() + */ + result AddAnimation(const VisualElementAnimation& animation); + + + /** + * Removes an animation from the group. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the animation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_OBJ_NOT_FOUND The specified @c index is not found. + * @see AddAnimation() + */ + result RemoveAnimationAt(int index); + + + /** + * Removes all the animations from the animation group. + * + * @since 2.0 + * + * @see AddAnimation() + * @see RemoveAnimationAt() + */ + void RemoveAllAnimations(void); + + + /** + * Gets an animation from the group. + * + * @since 2.0 + * + * @return An animation for the specified @c index in the animation group, @n + * else @c null if the animation does not exist + * @param[in] index The index of the animation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_OBJ_NOT_FOUND The animation is not found. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * This method allocates a Tizen::Ui::Animations::VisualElementAnimation. + * It is the developer's responsibility to deallocate the animation after use. + * @see AddAnimation() + * @see RemoveAnimationAt() + * @see RemoveAllAnimations() + */ + VisualElementAnimation* GetAnimationAtN(int index) const; + + +protected: + + friend class _VisualElementAnimationGroupImpl; +}; // VisualElementAnimationGroup + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_VISUAL_ELEMENT_ANIMATION_GROUP_H_ diff --git a/inc/FUiAnimVisualElementAnimationProvider.h b/inc/FUiAnimVisualElementAnimationProvider.h new file mode 100644 index 0000000..0db7b9f --- /dev/null +++ b/inc/FUiAnimVisualElementAnimationProvider.h @@ -0,0 +1,102 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementAnimationProvider.h + * @brief This is the header file for the %VisualElementAnimationProvider class. + * + * This header file contains the declarations of the %VisualElementAnimationProvider class. + */ + +#ifndef _FUI_ANIM_VISUAL_ELEMENT_ANIMATION_PROVIDER_H_ +#define _FUI_ANIM_VISUAL_ELEMENT_ANIMATION_PROVIDER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** +* @class VisualElementAnimationProvider +* @brief This class implements the provider for the events generated by the VisualElement. +* +* @since 2.0 +* +* The %VisualElementAnimationProvider class customizes the implicit animations. The class that needs to override default implicit animations must implement this interface, and +* the instance created with that class is registered with VisualElement, using the VisualElement::SetAnimationProvider() method. +* When the properties defined in %VisualElement and its descendants are changed, the CreateAnimationForProperty() method of this interface is invoked. +*/ + +class _OSP_EXPORT_ VisualElementAnimationProvider + : virtual public IVisualElementAnimationProvider +{ +public: + + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + VisualElementAnimationProvider(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~VisualElementAnimationProvider(void); + + +public: + /** + * Invoked for creating an animation when the property is changed. + * + * @since 2.0 + * + * @return A VisualElementAnimation instance for @c property + * @param[in] target The VisualElement instance that needs implicit animation + * @param[in] property The property of this instance for which animation is required + * @remarks If implicit animation for @c property is not required, return @c null. + */ + virtual VisualElementAnimation* CreateAnimationForProperty(VisualElement& target, const Tizen::Base::String& property); + + +private: + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + VisualElementAnimationProvider(const VisualElementAnimationProvider& value); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + VisualElementAnimationProvider& operator =(const VisualElementAnimationProvider& value); +}; // VisualElementAnimationProvider + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_VISUAL_ELEMENT_ANIMATION_PROVIDER_H_ + diff --git a/inc/FUiAnimVisualElementContentProvider.h b/inc/FUiAnimVisualElementContentProvider.h new file mode 100644 index 0000000..66cf42e --- /dev/null +++ b/inc/FUiAnimVisualElementContentProvider.h @@ -0,0 +1,122 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementContentProvider.h + * @brief This is the header file for the %VisualElementContentProvider class. + * + * This header file contains the declarations of the %VisualElementContentProvider class. + */ + +#ifndef _FUIANIM_VISUAL_ELEMENT_CONTENT_PROVIDER_H_ +#define _FUIANIM_VISUAL_ELEMENT_CONTENT_PROVIDER_H_ + +#include + +namespace Tizen { namespace Graphics { +class Canvas; +class FloatPoint; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Animations +{ + +class VisualElement; + +/** +* @class VisualElementContentProvider +* @brief This class customizes content of VisualElement. +* +* @since 2.0 +* +* The %VisualElementContentProvider class provides the content and information on it. The class that needs to customize content must implement this interface, and +* using the VisualElement::SetContentProvider() method register to the VisualElement. +* This class implements IVisualElementContentProvider for the default operation of the contents. +*/ +class _OSP_EXPORT_ VisualElementContentProvider + : public IVisualElementContentProvider +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + VisualElementContentProvider(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~VisualElementContentProvider(void); + +public: + /** + * Checks whether the %PrepareDraw() method is invoked by UI framework before DrawContent() is called. @n + * If this method returns @c true, VisualElement can call the %DrawContent() method. + * + * @since 2.0 + * + * @return @c true if DrawContent() can be called, @n + * else @c false + * @param[in] target The VisualElement instance to check + */ + virtual bool PrepareDraw(VisualElement& target); + + + /** + * Fills the contents in the given canvas. + * + * @since 2.0 + * + * @param[in] target The VisualElement instance to draw + * @param[in] canvas The graphic canvas for drawing + * @see VisualElement::OnDraw() + * @see VisualElement::InvalidateRectangle() + */ + virtual void DrawContent(VisualElement& target, Tizen::Graphics::Canvas& canvas); + + + /** + * The %HitTest() method is called by VisualElement::GetChildAt(). @n + * The %VisualElement::GetChildAt() method traverses through a list of all the children, and performs a hit test search at the @c point using this method. @n + * You can modify hit test search result by overriding this method. + * + * @since 2.0 + * + * @return The hit test result + * @param[in] target The VisualElement target to test + * @param[in] point The position of source to check + * @remarks Hit test results must be one of the following: @n + * - Tizen::Ui::Animations::HitTestResult::HIT_TEST_NOWHERE + * - Tizen::Ui::Animations::HitTestResult::HIT_TEST_MATCH + * @see VisualElement::GetChildAt() + */ + virtual HitTestResult HitTest(VisualElement& target, const Tizen::Graphics::FloatPoint& point); + +private: + VisualElementContentProvider(const VisualElementContentProvider& value); + VisualElementContentProvider& operator =(const VisualElementContentProvider& value); + +}; // VisualElementContentProvider + + +}}} // Tizen::Ui::Animations + +#endif //_FUIANIM_VISUAL_ELEMENT_CONTENT_PROVIDER_H_ diff --git a/inc/FUiAnimVisualElementPropertyAnimation.h b/inc/FUiAnimVisualElementPropertyAnimation.h new file mode 100644 index 0000000..1cade52 --- /dev/null +++ b/inc/FUiAnimVisualElementPropertyAnimation.h @@ -0,0 +1,190 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementPropertyAnimation.h + * @brief This is the header file for the %VisualElementPropertyAnimation class. + * + * This header file contains the declarations of the %VisualElementPropertyAnimation class. + */ + +#ifndef _FUI_ANIM_VISUAL_ELEMENT_PROPERTY_ANIMATION_H_ +#define _FUI_ANIM_VISUAL_ELEMENT_PROPERTY_ANIMATION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +class _VisualElementPropertyAnimationImpl; + +/** + * @class VisualElementPropertyAnimation + * @brief This class is for property animation. + * + * @since 2.0 + * + * The %VisualElementPropertyAnimation class defines the basic property animation. + */ +class _OSP_EXPORT_ VisualElementPropertyAnimation + : public VisualElementValueAnimation +{ +public: + + /** + * This is the default constructor for this class. + * + * @since 2.0 + * + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + VisualElementPropertyAnimation(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~VisualElementPropertyAnimation(void); + + + /** + * This is the copy constructor for the %VisualElementPropertyAnimation class. + * + * @since 2.0 + * + * @param[in] animation An instance of %VisualElementPropertyAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + VisualElementPropertyAnimation(const VisualElementPropertyAnimation& animation); + + + /** + * Assigns the value of the specified instance to the current instance of %VisualElementPropertyAnimation. + * + * @since 2.0 + * + * @param[in] rhs An instance of %VisualElementPropertyAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + VisualElementPropertyAnimation& operator =(const VisualElementPropertyAnimation& rhs); + + + /** + * Checks whether the specified instance and current instance of %VisualElementPropertyAnimation have equal animation values. + * + * @since 2.0 + * + * @return @c true if the animation of the two instances of %VisualElementPropertyAnimation are equal, @n + * else @c false + * @param[in] rhs An instance of %VisualElementPropertyAnimation + */ + bool operator ==(const VisualElementPropertyAnimation& rhs) const; + + + /** + * Checks whether the specified instance and current instance of %VisualElementPropertyAnimation have different animation values. + * + * @since 2.0 + * + * @return @c true if the values of the animations of the two instances of %VisualElementPropertyAnimation are not equal, @n + * else @c false + * @param[in] rhs An instance of %VisualElementPropertyAnimation + */ + bool operator !=(const VisualElementPropertyAnimation& rhs) const; + + + /** + * Checks whether the value of the current instance of %VisualElementPropertyAnimation equals the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance equals the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %VisualElementPropertyAnimation + * @remarks The %VisualElementPropertyAnimation class has a semantic value that means this method checks whether the two instances have the same animation. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The two equal instances must return the same hash value. + * For better performance, the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + + /** + * Gets the copied instance of the class. + * + * @since 2.0 + * + * @return An instance of VisualElementAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + virtual VisualElementAnimation* CloneN(void) const; + + + /** + * Sets the property for the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] property The property name to which the animation is applied + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @see GetPropertyName() + */ + result SetPropertyName(const Tizen::Base::String& property); + + + /** + * Gets the string of property to which the animation is applied. + * + * @since 2.0 + * + * @return A string of property + * @see SetPropertyName() + */ + Tizen::Base::String GetPropertyName(void) const; + + +protected: + + friend class _VisualElementPropertyAnimationImpl; +}; // VisualElementPropertyAnimation + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_VISUAL_ELEMENT_PROPERTY_ANIMATION_H_ diff --git a/inc/FUiAnimVisualElementSurface.h b/inc/FUiAnimVisualElementSurface.h new file mode 100644 index 0000000..2351ece --- /dev/null +++ b/inc/FUiAnimVisualElementSurface.h @@ -0,0 +1,216 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementSurface.h + * @brief This is the header file for the %VisualElementSurface class. + * + * This header file contains the declarations of the %VisualElementSurface class. + */ + +#ifndef _FUI_ANIM_VISUAL_ELEMENT_SURFACE_H_ +#define _FUI_ANIM_VISUAL_ELEMENT_SURFACE_H_ + +#include +#include +#include + +namespace Tizen { namespace Graphics +{ + class BufferInfo; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Animations +{ + +class DisplayContext; +class _VisualElementSurfaceImpl; + +/** +* @class VisualElementSurface +* @brief This class provides methods to control %VisualElementSurface. +* +* @since 2.0 +* +* The %VisualElementSurface class provides methods to control %VisualElementSurface. +*/ +class _OSP_EXPORT_ VisualElementSurface + : public Tizen::Base::Object +{ +public: + + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + VisualElementSurface(void); + + /** + * This is the copy constructor for the %VisualElementSurface class. + * + * @since 2.0 + * + * @param[in] rhs An instance of %VisualElementSurface + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks It does not perform a deep copy (shared with the source). + */ + VisualElementSurface(const VisualElementSurface& rhs); + + /** + * Assigns the value of the specified instance to the current instance of %VisualElementSurface. + * + * @since 2.0 + * + * @param[in] rhs An instance of %VisualElementSurface + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks It does not perform a deep copy (shared with the source). + */ + VisualElementSurface& operator =(const VisualElementSurface& rhs); + + /** + * This is the default destructor for this class. + * + * @since 2.0 + */ + virtual ~VisualElementSurface(void); + +public: + + /** + * Initializes this instance of %VisualElementSurface with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] displayContext The display context of the window + * @param[in] size The size of the %VisualElementSurface instance + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_INVALID_ARG The display context is invalid. + * @remarks The width and height of the @c size parameter is the logical size and must be greater than @c 0. + * @remarks If this condition is not satisfied, the E_OUT_OF_RANGE exception is returned. + * @see Tizen::Ui::Window::GetDisplayContext() + */ + result Construct(const DisplayContext& displayContext, const Tizen::Graphics::Dimension& size); + + /** + * Gets the buffer-related information of the %VisualElementSurface instance. + * + * @since 2.0 + * + * @return An error code + * @param[out] bufferInfo The buffer-related information of the surface + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result GetBufferInfo(Tizen::Graphics::BufferInfo& bufferInfo) const; + + /** + * Gets the size of the %VisualElementSurface instance. + * + * @since 2.0 + * + * @return The size of the %VisualElementSurface instance + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an error occurs, this method returns Tizen::Graphics:Dimension(0, 0). + */ + Tizen::Graphics::Dimension GetSize(void) const; + + /** + * Compares the Tizen::Base::Object instance with the calling %VisualElementSurface instance for equivalence. + * + * @since 2.0 + * + * @return @c true if the specified instance share the content with the current instance, @n + * else @c false + * @param[in] obj The object to compare with the current instance + * @see GetHashCode() + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The hash code of a buffer depends only upon its remaining elements. + */ + virtual int GetHashCode(void) const; + + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void VisualElementSurface_Reserved1(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void VisualElementSurface_Reserved2(void) {} + + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void VisualElementSurface_Reserved3(void) {} + + +private: + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + /** + * @since 2.0 + */ + _VisualElementSurfaceImpl* __pVisualElementSurfaceImpl; + + friend class _VisualElementSurfaceImpl; + +}; // VisualElementSurface + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_VISUAL_ELEMENT_SURFACE_H_ + diff --git a/inc/FUiAnimVisualElementValueAnimation.h b/inc/FUiAnimVisualElementValueAnimation.h new file mode 100644 index 0000000..bab39d3 --- /dev/null +++ b/inc/FUiAnimVisualElementValueAnimation.h @@ -0,0 +1,329 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementValueAnimation.h + * @brief This is the header file for the %VisualElementValueAnimation class. + * + * This header file contains the declarations of the %VisualElementValueAnimation class. + */ + +#ifndef _FUI_ANIM_VISUAL_ELEMENT_VALUE_ANIMATION_H_ +#define _FUI_ANIM_VISUAL_ELEMENT_VALUE_ANIMATION_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +class IVisualElementAnimationTickEventListener; +class _VisualElementValueAnimationImpl; + +/** + * @class VisualElementValueAnimation + * @brief This class is for value animation. + * + * @since 2.0 + * + * The %VisualElementValueAnimation class defines the basic value animation. + */ +class _OSP_EXPORT_ VisualElementValueAnimation + : public VisualElementAnimation +{ +public: + + /** + * This is the default constructor for this class. + * + * @since 2.0 + * + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + VisualElementValueAnimation(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~VisualElementValueAnimation(void); + + + /** + * This is the copy constructor for the %VisualElementValueAnimation class. + * + * @since 2.0 + * + * @param[in] animation An instance of %VisualElementValueAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + VisualElementValueAnimation(const VisualElementValueAnimation& animation); + + + /** + * Assigns the value of the specified instance to the current instance of %VisualElementValueAnimation. + * + * @since 2.0 + * + * @param[in] rhs An instance of %VisualElementValueAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + VisualElementValueAnimation& operator =(const VisualElementValueAnimation& rhs); + + + /** + * Checks whether the specified instance and current instance of %VisualElementValueAnimation have equal animation values. + * + * @since 2.0 + * + * @return @c true if the animation of the two instances of %VisualElementValueAnimation are equal, @n + * else @c false + * @param[in] rhs An instance of %VisualElementValueAnimation + */ + bool operator ==(const VisualElementValueAnimation& rhs) const; + + + /** + * Checks whether the specified instance and current instance of %VisualElementValueAnimation have different animation values. + * + * @since 2.0 + * + * @return @c true if the values of the animations of the two instances of %VisualElementValueAnimation are not equal, @n + * else @c false + * @param[in] rhs An instance of %VisualElementValueAnimation + */ + bool operator !=(const VisualElementValueAnimation& rhs) const; + + + /** + * Checks whether the value of the current instance of %VisualElementValueAnimation equals the value of the specified instance. + * + * @since 2.0 + * + * @return @c true if the value of the current instance equals the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %VisualElementValueAnimation + * @remarks The %VisualElementValueAnimation class has a semantic value which means that this method checks whether the two instances have the same animation. + */ + virtual bool Equals(const Tizen::Base::Object& obj) const; + + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks The two equal instances must return the same hash value. + * For better performance, the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + + + /** + * Gets the copied instance of the class. + * + * @since 2.0 + * + * @return An instance of %VisualElementAnimation + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + virtual VisualElementAnimation* CloneN(void) const; + + + /** + * Sets an IVisualElementAnimationTickEventListener listener instance to listen to the events of a particular animation. @n + * The set listener, %IVisualElementAnimationTickEventListener, can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] pListener The listener to set + */ + void SetVisualElementAnimationTickEventListener(IVisualElementAnimationTickEventListener* pListener); + + + /** + * Gets the IVisualElementAnimationTickEventListener listener. + * + * @since 2.0 + * + * @return A pointer to the IVisualElementAnimationTickEventListener instance @n + * If listener has not been set, @c null is returned. + * @see SetVisualElementAnimationTickEventListener() + */ + IVisualElementAnimationTickEventListener* GetVisualElementAnimationTickEventListener(void) const; + + + /** + * Sets the start value of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] startValue The start value of the animation to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The type of Variant is empty. + * @see GetStartValue() + */ + result SetStartValue(const Tizen::Ui::Variant& startValue); + + + /** + * Gets the start value of the animation. + * + * @since 2.0 + * + * @return The start value of animation + * @see SetStartValue() + */ + Tizen::Ui::Variant GetStartValue(void) const; + + + /** + * Sets the end value of the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] endValue The end value of the animation to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The type of Variant is empty. + * @see GetEndValue() + */ + result SetEndValue(const Tizen::Ui::Variant& endValue); + + + /** + * Gets the end value of the animation. + * + * @since 2.0 + * + * @return The end value of animation + * @see SetEndValue() + */ + Tizen::Ui::Variant GetEndValue(void) const; + + + /** + * Sets the flag to apply the end value of the animation when the animation is finished. + * + * @since 2.0 + * + * @param[in] apply Set to @c true to apply the end values of the animation, @n + * else @c false + * @remarks There is no difference in behavior with this method in value animation. @n + * So you must set the end value by seeing this value. + * @see IsEndValueApplied() + */ + void SetEndValueApplied(bool apply); + + + /** + * Checks whether the end value of the animation is applied when the animation is finished. + * + * @since 2.0 + * + * @return @c true if the end value is applied, @n + * else @c false @n + * The default value is @c true. + * @see SetEndValueApplied() + */ + bool IsEndValueApplied(void) const; + + + /** + * Adds the key frame information for the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] timeProgress The specified time progress value @n + * This must be in the range @c 0.0 to @c 1.0 and cannot be @c 0.0 and @c 1.0. + * @param[in] value The value at the specified time + * @param[in] pTimingFunction The timing function instance that is used in keyframe segment + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c value parameter is invalid. + * @exception E_OUT_OF_RANGE The specified @c timeProgress is not within the range @c 0 to @c 1 (exclusive). + * @remarks If a key-value pair with the current key already exists, the old value is overwritten with the new one. + * If timing function is @c null, the default timing function is applied. + * The timing function is applied to current pace from previous pace. + * @see RemoveKeyFrame() + * @see RemoveAllKeyFrames() + */ + result AddKeyFrame(float timeProgress, const Tizen::Ui::Variant& value, const IVisualElementAnimationTimingFunction* pTimingFunction = null); + + + /** + * Removes the key frame information for the animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] timeProgress The time progress for the key frame to remove + * This must be in the range @c 0.0 to @c 1.0 and cannot be @c 0.0 and @c 1.0. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The value of the specified parameter is not within the range @c 0 to @c 1 (exclusive). + * @exception E_OBJ_NOT_FOUND The key frame with @c timeProgress does not exist. + * @see AddKeyFrame() + * @see RemoveAllKeyFrames() + */ + result RemoveKeyFrame(float timeProgress); + + + /** + * Removes all the key frame information for the animation. + * + * @since 2.0 + * + * @see AddKeyFrame() + * @see RemoveKeyFrame() + */ + void RemoveAllKeyFrames(void); + + +protected: + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the constructor for derived classes. + // + // @since 2.0 + // + VisualElementValueAnimation(_VisualElementValueAnimationImpl* pImpl); + + + friend class _VisualElementValueAnimationImpl; +}; // VisualElementValueAnimation + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_VISUAL_ELEMENT_VALUE_ANIMATION_H_ + diff --git a/inc/FUiAnimations.h b/inc/FUiAnimations.h new file mode 100644 index 0000000..b2f3b3a --- /dev/null +++ b/inc/FUiAnimations.h @@ -0,0 +1,373 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimations.h + * @brief This is the header file for the %Animations namespace. + * + * This header file contains the declarations and descriptions of the %Animations namespace. + */ + +#ifndef _FUI_ANIMATIONS_H_ +#define _FUI_ANIMATIONS_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen +{ +namespace Ui +{ +/** + * @namespace Tizen::Ui::Animations + * @brief This namespace contains the classes for the animation-related functionalities. + * @since 2.0 + * + * @remarks @b Header @b %file: @b \#include @b @n + * @b Library : @b osp-uifw + * + * + * + * The %Animations namespace provides animation capabilities for the UI controls. + * + * For more information on the %Animations namespace features, see Animations Guide. + * + * The following diagram illustrates the relationships between the classes belonging to the %Animations namespace. + * @image html ui_animations_classdiagram.png + * + * The following examples demonstrate how to use the %Animations namespace. + * + * @code +// Sample code for Control Animation using ControlAnimator +#include +#include + +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics; + +class AnimationSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener +{ +public: + virtual result OnInitializing(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +protected: + static const int ID_BUTTON = 101; + Tizen::Ui::Controls::Button *__pButton; +}; + +result +AnimationSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Button + __pButton = new Button(); + __pButton->Construct(Rectangle(10, 200, 460, 100)); + __pButton->SetText(L"Start animation"); + __pButton->SetActionId(ID_BUTTON); + __pButton->AddActionEventListener(*this); + AddControl(*__pButton); + + return r; +} + +void +AnimationSample::OnActionPerformed(const Control& source, int actionId) +{ + switch(actionId) + { + case ID_BUTTON: + { + // Starts an animation + result r = E_SUCCESS; + + ControlAnimator* pButtonAnimator = __pButton->GetControlAnimator(); + Point startPos = __pButton->GetPosition(); + Point endPos(startPos.x, startPos.y + 200); + PointAnimation pointAnimation(startPos, + endPos, + 2000, + ANIMATION_INTERPOLATOR_LINEAR); + + pointAnimation.SetAutoReverseEnabled(true); + + r = pButtonAnimator->StartUserAnimation(ANIMATION_TARGET_POSITION, pointAnimation); + if (IsFailed(r)) + { + AppLog("Start Animation on Button Failed.\n"); + return; + } + } + break; + } +} + * @endcode + * + * @code +// Sample code for Form Transition Animation using FrameAnimator +#include +#include + +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Animations; + +bool +FrameAnimatorSample::OnAppInitializing(AppRegistry& appRegistry) +{ + // Creates instances of Form + Form1 *pForm1 = new Form1(); + pForm1->Initialize(); + + Form2* pForm2 = new Form2(); + pForm2->Initialize(); + + // Adds forms to the frame + Frame *pFrame = GetAppFrame()->GetFrame(); + pFrame->AddControl(*pForm1); + pFrame->AddControl(*pForm2); + + // Sets the current form + pFrame->SetCurrentForm(*pForm1); + + // Display the form + pForm1->Invalidate(); + + return true; +} + +// Transition from Form1 to Form2 +void +Form1::OnActionPerformed(const Control& source, int actionId) +{ + switch(actionId) + { + case ID_FOOTER_BUTTON_TRANSIT: + { + result r = E_SUCCESS; + + Frame *pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame(); + FrameAnimator *pFrameAnimator = pFrame->GetFrameAnimator(); + + Form *nextForm = static_cast(pFrame->GetControl(L"Form2")); + + if(pFrameAnimator->GetStatus() == ANIMATOR_STATUS_STOPPED) + { + pFrameAnimator->SetFormTransitionAnimation (FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_LEFT, + 1000, + ANIMATION_INTERPOLATOR_LINEAR ); + r = pFrameAnimator->SetCurrentForm (*nextForm); + if (IsFailed(r)) + { + AppLog("SetCurrentForm on the Form2 Failed.\n"); + return; + } + } + } + break; + default: + break; + } +} + +// Transition from Form2 to Form1 +void +Form2::OnActionPerformed(const Control& source, int actionId) +{ + switch(actionId) + { + case ID_FOOTER_BUTTON_TRANSIT: + { + result r = E_SUCCESS; + + Frame *pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame(); + FrameAnimator *pFrameAnimator = pFrame->GetFrameAnimator(); + + Form *nextForm = static_cast(pFrame->GetControl(L"Form1")); + if(pFrameAnimator->GetStatus() == ANIMATOR_STATUS_STOPPED) + { + pFrameAnimator->SetFormTransitionAnimation(FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_RIGHT, + 1000, + ANIMATION_INTERPOLATOR_LINEAR ); + r = pFrameAnimator->SetCurrentForm (*nextForm); + if (IsFailed(r)) + { + AppLog("SetCurrentForm on the Form1 Failed.\n"); + return; + } + } + } + break; + default: + break; + } +} + * @endcode + * + * @code + // Sample code for VisualElement and VisualElementAnimation +#include +#include +#include + +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +class VisualElementSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::Animations::VisualElementContentProvider +{ +public: + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + virtual void DrawContent(Tizen::Ui::Animations::VisualElement& target, Tizen::Graphics::Canvas& canvas); + +private: + static const int ID_FOOTER_START_ANIMATION = 101; + + Tizen::Ui::Animations::VisualElement* __pRect; +}; + +result +VisualElementSample::OnInitializing(void) +{ + __pRect = new VisualElement(); + __pRect->Construct(); + __pRect->SetName(L"Rect"); + __pRect->SetBounds(FloatRectangle(50.0f, 50.0f, 200.0f, 200.0f)); + __pRect->SetShowState(true); + __pRect->SetContentProvider(this); + + GetVisualElement()->AttachChild(*__pRect); + __pRect->InvalidateRectangle(null); + + return E_SUCCESS; +} + +result +VisualElementSample::OnTerminating(void) +{ + __pRect->Destroy(); + + return E_SUCCESS; +} + +void +VisualElementSample::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + switch(actionId) + { + case ID_FOOTER_START_ANIMATION: + { + VisualElementPropertyAnimation* pAnimation = new VisualElementPropertyAnimation(); + pAnimation->SetPropertyName(L"opacity"); + pAnimation->SetStartValue(1.0f); + pAnimation->SetEndValue(0.0f); + pAnimation->SetDuration(500); + pAnimation->SetAutoReverseEnabled(true); + + __pRect->AddAnimation(*pAnimation); + delete pAnimation; + } + break; + + default: + break; + } +} + +void +VisualElementSample::DrawContent(Tizen::Ui::Animations::VisualElement& target, Tizen::Graphics::Canvas& canvas) +{ + if (target.GetName() == L"Rect") + { + canvas.FillRectangle(Color::GetColor(COLOR_ID_WHITE), Rectangle(0, 0, 200, 200)); + } +} + * @endcode + * + * + * + */ + +namespace Animations +{ +}; + +} } // Tizen::Ui + +#endif // _FUI_ANIMATIONS_H_ diff --git a/inc/FUiCardLayout.h b/inc/FUiCardLayout.h new file mode 100755 index 0000000..e8eb4e6 --- /dev/null +++ b/inc/FUiCardLayout.h @@ -0,0 +1,156 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCardLayout.h + * @brief This is the header file for the %CardLayout class. + * + * This header file contains the declarations of the %CardLayout class. + */ + +#ifndef _FUI_CARD_LAYOUT_H_ +#define _FUI_CARD_LAYOUT_H_ + +#include + +namespace Tizen { namespace Ui +{ +class Control; + +/** + * @class CardLayout + * @brief The card layout fits a child control to the container by changing the position and the size of the child control. + * + * @since 2.0 + * + * The %CardLayout class defines the card layout for a container.@n + * + * @code +// Sample code for CardLayoutSample.h +#include + +class CardLayoutSample + : public Tizen::Ui::Controls::Form +{ +public: + bool Initialize(void); + virtual result OnInitializing(void); +}; + * @endcode + * + * @code +// Sample code for CardLayoutSample.cpp +#include + +#include "CardLayoutSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +bool +CardLayoutSample::Initialize(void) +{ + // Creates an instance of CardLayout + CardLayout formLayout; + formLayout.Construct(); + + // Applies the card layout to the form + Construct(formLayout, FORM_STYLE_NORMAL); + return true; +} + +result +CardLayoutSample::OnInitializing(void) +{ + result = E_SUCCESS; + + // Creates an instance of 1st panel + Panel* pFirstPanel = new Panel(); + pFirstPanel->Construct(Rectangle(0, 0, 50, 50)); + pFirstPanel->SetBackgroundColor(Color(0xFF, 0x40, 0x40, 0xFF)); + + // Adds the 1st panel to the form + AddControl(*pFirstPanel); + + // Creates an instance of 2nd panel + Panel* pSecondPanel = new Panel(); + pSecondPanel->Construct(Rectangle(0, 0, 50, 50)); + pSecondPanel->SetBackgroundColor(Color(0x40, 0x40, 0xFF, 0xFF)); + + // Adds the 2nd panel to the form + AddControl(*pSecondPanel); + + return r; +} + * @endcode + * + */ +class _OSP_EXPORT_ CardLayout + : public Layout +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + CardLayout(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~CardLayout(void); + + /** + * Initializes this instance of %CardLayout. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result Construct(void); + + /** + * Gets the type of the layout. + * + * @since 2.0 + * + * @return The layout type + */ + virtual LayoutType GetLayoutType(void) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + CardLayout(const CardLayout& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + CardLayout& operator =(const CardLayout& rhs); + +}; // CardLayout + +}} // Tizen::Ui + +#endif // _FUI_CARD_LAYOUT_H_ diff --git a/inc/FUiClipboard.h b/inc/FUiClipboard.h new file mode 100644 index 0000000..3a06497 --- /dev/null +++ b/inc/FUiClipboard.h @@ -0,0 +1,319 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiClipboard.h + * @brief This is the header file for the %Clipboard class. + * + * This header file contains the declarations of the %Clipboard class and its helper classes. + */ + +#ifndef _FUI_CLIPBOARD_H_ +#define _FUI_CLIPBOARD_H_ + +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class _ClipboardImpl; + +/** + * @class Clipboard + * @brief This class defines a common behavior for %Clipboard. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %Clipboard class manages the copy and paste operation between and within applications. + * + * For more information on the class features, see Clipboard. + * + * The following example demonstrates how to use the %Clipboard class. + * + * @code +// Sample code for ClipboardSample.h +#include + +class ClipboardSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener +{ +public: + ClipboardSample(void) + : __pLabel(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + // IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +private: + static const int ID_BUTTON_OK = 101; + + Tizen::Ui::Controls::Label* __pLabel; +}; + * @endcode + * + * @code +// Sample code for ClipboardSample.cpp +#include +#include +#include + +#include "ClipboardSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +bool +ClipboardSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +ClipboardSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Sets data to a clip board item + ClipboardItem item; + String resourcePath = App::GetInstance()->GetAppResourcePath(); + item.Construct(CLIPBOARD_DATA_TYPE_HTML, String(resourcePath + L"screen-size-normal/IDF_FORM.xml")); + + // Gets an instance of Clipboard and copies an item to it + Clipboard* pClipboard = Clipboard::GetInstance(); + pClipboard->CopyItem(item); + + // Creates controls to test clipboard + Button* pButton = new Button(); + pButton->Construct(Rectangle(50, 50, 200, 80), "COPY"); + pButton->SetActionId(ID_BUTTON_OK); + pButton->AddActionEventListener(*this); + AddControl(*pButton); + + __pLabel = new Label(); + __pLabel->Construct(Rectangle(0, 200, GetClientAreaBounds().width, 80), L".."); + AddControl(*__pLabel); + + return r; +} + +void +ClipboardSample::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + switch(actionId) + { + case ID_BUTTON_OK: + { + // Gets an instance of Clipboard + Clipboard* pClipboard = Clipboard::GetInstance(); + + // Retrieves a latest item + ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT + | CLIPBOARD_DATA_TYPE_HTML + | CLIPBOARD_DATA_TYPE_AUDIO + | CLIPBOARD_DATA_TYPE_VIDEO ); + + //Gets data from the clipboard item + String* pString = dynamic_cast(pItem->GetData()); + + __pLabel->SetText(*pString + L" is Copied"); + __pLabel->Invalidate(false); + + delete pItem; + } + break; + default: + break; + } +} + * @endcode + */ +class _OSP_EXPORT_ Clipboard + : public Tizen::Base::Object + , public Tizen::Ui::IClipboard +{ +public: + /** + * Gets the system clipboard. + * + * @since 2.0 + * + * @return The pointer to the system clipboard + * @remarks The copy and paste operation is performed through the system + * clipboard that can be obtained through this method. @n + * The method returns @c null if a system error occurs. + */ + static Clipboard* GetInstance(void); + + /** + * Copies the specified @c item to the system clipboard. + * + * @since 2.0 + * + * @return An error code + * @param[in] item The item to save in the system clipboard + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method returns @c E_INVALID_ARG if the specified item is + * not constructed. @n + * For the text and image data type, the data itself is copied + * by the method and kept by the system clipboard. + */ + result CopyItem(const ClipboardItem& item); + + /** + * Retrieves a collection of items that matches the specified data types from the + * system clipboard. + * + * @since 2.0 + * + * @return The pointer to a Tizen::Base::Collection::IList that contains a collection of ClipboardItem, @n + * else @c null if an error occurs + * @param[in] dataTypes The types of items @n Multiple data types can be + * combined using bitwise OR. + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The item of the specified data types is not found. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * This method returns a pointer to an Tizen::Base::Collection::IList that contains + * a collection of ClipboardItem. The returned pointer to %Tizen::Base::Collection::IList + * and all the elements in %Tizen::Base::Collection::IList must be deleted by applications. @n + * The items in %Tizen::Base::Collection::IList are sorted in the reverse order in which + * they are copied to the system clipboard. So, the first + * item in %Tizen::Base::Collection::IList is the latest one among them. @n + * @c dataType can be a combination of ClipboardDataType. + * @see Tizen::Ui::ClipboardDataType + */ + Tizen::Base::Collection::IList* RetrieveItemsN(unsigned long dataTypes); + + /** + * Retrieves the latest item for the specified data types from the system clipboard. + * + * @since 2.0 + * + * @return The pointer to a ClipboardItem instance, @n + * else @c null if an error occurs + * @param[in] dataTypes The types of items @n Multiple data types can be + * combined using bitwise OR. + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The item of the specified data types is not found. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * This method returns the pointer to a ClipboardItem instance. The + * returned %ClipboardItem must be deleted by applications. @n + * If there is no matched item in the system clipboard, this method + * returns @c null. @n + * @c dataType can be a combination of ClipboardDataType. + * @see Tizen::Ui::ClipboardDataType + */ + Tizen::Ui::ClipboardItem* RetrieveLatestItemN(unsigned long dataTypes); + + /** + * Shows the clipboard popup with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] dataTypes The types of items @n Multiple data types can be + * combined using bitwise OR. + * @param[in] listener The clipboard popup event listener + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance + * prohibits the execution of the specified + * operation. + * @exception E_SYSTEM A system error has occurred. + * @remarks @c dataTypes can decide whether the clipboard popup shows image items or not. + * If @c dataTypes contains #CLIPBOARD_DATA_TYPE_IMAGE, all types of items are shown. + * If not, text items, html items, video items, and audio items are shown except image items. @n + * This method returns @c E_INVALID_OPERATION if the clipboard popup is currently + * being shown. Furthermore, attempting to show the clipboard popup when the application is + * in the background will return @c E_INVALID_OPERATION. @n + * The clipboard popup shows the current content of the system clipboard. The user + * can clear the system clipboard or choose a clipboard item for the paste operation. + * @see Tizen::Ui::ClipboardDataType + */ + static result ShowPopup(unsigned long dataTypes, const IClipboardPopupEventListener& listener); + + /** + * Hides the clipboard popup. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method returns @c E_INVALID_OPERATION if no clipboard popup is currently being shown. + */ + static result HidePopup(void); + + /** + * Checks whether the clipboard popup is currently being shown. + * + * @since 2.0 + * + * @return @c true if the clipboard popup is being shown, @n + * else @c false + */ + static bool IsPopupVisible(void); + +private: + // + // This default constructor is intentionally declared as private to implement the Singleton semantic. + // + Clipboard(void); + + // + // This destructor is intentionally declared as private to implement the Singleton semantic. + // + virtual ~Clipboard(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Clipboard(const Clipboard& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Clipboard& operator =(const Clipboard& rhs); + +private: + friend class _ClipboardImpl; + +private: + _ClipboardImpl* __pClipboardImpl; +}; // Clipboard + +}} //Tizen::Ui + +#endif //_FUI_CLIPBOARD_H_ diff --git a/inc/FUiClipboardItem.h b/inc/FUiClipboardItem.h new file mode 100644 index 0000000..dacd7a8 --- /dev/null +++ b/inc/FUiClipboardItem.h @@ -0,0 +1,123 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiClipboardItem.h + * @brief This is the header file for the %ClipboardItem class. + * + * This header file contains the declarations of the %ClipboardItem class and its helper classes. + */ + +#ifndef _FUI_CLIPBOARD_ITEM_H_ +#define _FUI_CLIPBOARD_ITEM_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class _ClipboardItemImpl; + +/** + * @class ClipboardItem + * @brief This class defines a common behavior for %ClipboardItem. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %ClipboardItem class represents the items in the system Clipboard. The %ClipboardItem is the unit of data handling between + * the system clipboard and applications, and it contains both data itself and the type of the data. + * + * For more information on the class features, see Clipboard. + * + */ +class _OSP_EXPORT_ ClipboardItem + : public Tizen::Base::Object +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + ClipboardItem(void); + + /** + * This destructor overrides Osp::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~ClipboardItem(void); + + /** + * Initializes this instance of %ClipboardItem with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] dataType The data type + * @param[in] data The data to be copied + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks For the image data type, the bitmap instance must be deleted + * by the application after the item is copied to the clipboard. + */ + result Construct(ClipboardDataType dataType, const Tizen::Base::Object& data); + + /** + * Gets the data type of %ClipboardItem. + * + * @since 2.0 + * + * @return The data type of the clipboard item + */ + ClipboardDataType GetDataType(void) const; + + /** + * Gets the data of %ClipboardItem. + * + * @since 2.0 + * + * @return The pointer to the data + * @remarks The application needs to type-cast the returned data object + * according to its data type. + */ + Tizen::Base::Object* GetData(void) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + ClipboardItem(const ClipboardItem& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + ClipboardItem& operator =(const ClipboardItem& rhs); + +private: + friend class _ClipboardItemImpl; + +private: + _ClipboardItemImpl* __pImpl; +}; // ClipboardItem + +}} // Tizen::Ui + +#endif // _FUI_CLIPBOARD_ITEM_H_ diff --git a/inc/FUiClipboardTypes.h b/inc/FUiClipboardTypes.h new file mode 100644 index 0000000..510c511 --- /dev/null +++ b/inc/FUiClipboardTypes.h @@ -0,0 +1,50 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiClipboardTypes.h + * @brief This is the header file for the Clipboard enumeration. + * + * The Clipboard enumeration defines the data types for the system clipboard. + */ + +#ifndef _FUI_CLIPBOARD_ENUM_H_ +#define _FUI_CLIPBOARD_ENUM_H_ + +namespace Tizen { namespace Ui +{ +/** + * @enum ClipboardDataType + * + * Defines the data types supported by %Clipboard. + * + * @since 2.0 + */ +enum ClipboardDataType +{ + CLIPBOARD_DATA_TYPE_TEXT = 0x0001, /**< The text data type */ + CLIPBOARD_DATA_TYPE_HTML = 0x0002, /**< The HTML data type */ + CLIPBOARD_DATA_TYPE_IMAGE = 0x0004, /**< The image data type */ + CLIPBOARD_DATA_TYPE_VIDEO = 0x0008, /**< The video data type */ + CLIPBOARD_DATA_TYPE_AUDIO = 0x0010, /**< The audio data type */ + CLIPBOARD_DATA_TYPE_MAX = 0x7fff, // The data type max + CLIPBOARD_DATA_TYPE_NONE = 0x0000 // No data type +}; + +}} // Tizen::Ui + +#endif // _FUI_CLIPBOARD_ENUM_H_ diff --git a/inc/FUiCompositeMode.h b/inc/FUiCompositeMode.h new file mode 100644 index 0000000..b5654c8 --- /dev/null +++ b/inc/FUiCompositeMode.h @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCompositeMode.h + * @brief This is the header file for the %Container class. + * + * This header file contains the declarations of the %Container class. + */ + +#ifndef _FUI_COMPOSITE_MODE_H_ +#define _FUI_COMPOSITE_MODE_H_ + +#ifdef COMPOSITE_MODE_NONE +#undef COMPOSITE_MODE_NONE +#endif + +namespace Tizen {namespace Ui +{ + +/** +* @enum CompositeMode +* +* Defines the mode for compositing controls. +* +* @since 2.0 +*/ +enum CompositeMode +{ + /** Composites two UI controls using alpha-blending */ + COMPOSITE_MODE_ALPHA_BLENDING, + + /** Composites two UI controls in the way that the given chroma key color from one control is made transparent */ + COMPOSITE_MODE_CHROMA_KEY, + + /** Composites two UI controls in the way that one control overwrites another control */ + COMPOSITE_MODE_OVERWRITE, + + /** Does not composite the given control */ + COMPOSITE_MODE_NONE, +}; + +}} // Tizen::Ui + +#endif // _FUI_COMPOSITE_MODE_H_ diff --git a/inc/FUiContainer.h b/inc/FUiContainer.h new file mode 100644 index 0000000..9418b31 --- /dev/null +++ b/inc/FUiContainer.h @@ -0,0 +1,625 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiContainer.h + * @brief This is the header file for the %Container class. + * + * This header file contains the declarations of the %Container class. + */ + +#ifndef _FUI_CONTAINER_H_ +#define _FUI_CONTAINER_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { + +class Layout; +class _ContainerImpl; + +/** + * @class Container + * @brief This class is an abstract base class of all the generic containers of Controls. + * + * @since 2.0 + * + * @remarks As the %Container is an abstract class, use the Tizen::Ui::Controls::Panel class or another class derived from + * %Container to apply the container functionality. + * + * The %Container class is the abstract base class of all generic Control containers. A container is a UI element which can contain + * other UI elements. + * + * For more information on the class features, see Containers. + * + + * + */ +class _OSP_EXPORT_ Container + : public Control +{ + +public: + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~Container(void) = 0; + +public: + /** + * Adds the control at the end of the list maintained by the container. + * + * @since 2.0 + * + * @return An error code + * @param[in] control The control to be added to the container + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c control is an instance of Window, or this control's parent container. + * @exception E_MAX_EXCEEDED The number of child controls has exceeded the maximum limit. + * @exception E_SYSTEM A system error has occurred. + * @remarks When the control is added, it is placed at the top of the drawing stack maintained by the container.@n + * This means the last control added is drawn last + * @remarks A control becomes displayable only after it has been added to a displayable container. Some methods may not work normally if the methods + * of the control are called before adding the control to a container. After the control is added to a %Container, the OnInitializing() + * method of the control are called before adding the control to a container. After the control is added to a %Container, the + * OnInitializing() method of the control is invoked for the initialization of the control such as creating and adding child controls. + * @see Tizen::Ui::Control::OnInitializing() + * @see Tizen::Ui::Control::OnTerminating() + * @code + * { + * // Uses Panel instead of Container, because Container is an abstract class. + * Panel* pPanel = new Panel(); + * pPanel->Construct(Rectangle(100, 250, 300, 300)); + * + * Form* pForm = new Form(); + * pForm->Construct(FORM_STYLE_NORMAL|FORM_STYLE_TITLE|FORM_STYLE_INDICATOR); + * pForm->AddControl(*pPanel); + * + * //... + * pForm->Invalidate(true); + * //... + * } + * @endcode + */ + result AddControl(const Control& control); + + /** + * Before the system calls OnDraw() method to allow the user to do custom drawing, this method is called to clear the canvas. The user can override this method to change this default behavior. + * + * @since 2.0 + * + * @see GetCanvasN() + */ + virtual void OnClearBackground(void); + + /** + * Called when the container needs to draw itself. @n + * Users can override this method to display user-specific drawings. @n + * This method is called after the container has drawn itself, but just before the container draws its child controls. + * + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompOnDrawPage "here". + * @endif + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + virtual result OnDraw(void); + + /** + * @if OSPCOMPAT + * @page CompOnDrawPage Compatibility for OnDraw() + * @section CompOnDrawPage IssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The platform draws the control by calling the parent's OnDraw() callback before invoking the control's OnDraw() callback. So, the users can't control the control's drawing behavior by overriding the OnDraw() callback. + * + * @section CompOnDrawPage SolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The platform does not call the parent's OnDraw() callback before invoking the control's OnDraw() callback. Therefore, you needs to call the parent container's OnDraw() callback in the OnDraw() callback if you override this method. + * @endif + */ + + /** + * Called to notify that the control's show state is changing. + * + * @since 2.0 + * + * @param[in] showState The new show state of the control + * @see Osp::Ui::Control::SetShowState() + */ + virtual void OnShowStateChanging(bool showState); + + /** + * Called to notify that the control's show state is changed. + * + * @since 2.0 + * + * @param[in] showState The new show state of the control + * @see Tizen::Ui::Control::SetShowState() + */ + virtual void OnShowStateChanged(bool showState); + + /** + * Called to notify that the bounds of the control is changing. + * + * @since 2.0 + * + * @return An error code + * @param[in] oldRect The old position and size values of the control + * @param[in] newRect The new position and size values of the control + * @remarks If the method returns an exception, the resulting exception + * is propagated and the control's size is unchanged.@n + * Provide control specific exceptions. + * @see Tizen::Ui::Control::SetBounds() + * @see Tizen::Ui::Control::SetSize() + */ + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect); + + /** + * Called to notify that the bounds of the control is changed. + * + * @since 2.0 + * + * @return An error code + * @param[in] oldRect The old position and size values of the control + * @param[in] newRect The new position and size values of the control + * @see Tizen::Ui::Control::SetBounds() + * @see Tizen::Ui::Control::SetSize() + */ + virtual void OnBoundsChanged(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect); + + /** + * Overrides this method to indicate that the specified @c width and @c height + * can be supported or a new @c width and @c height should be applied instead + * of the specified values. + * + * @since 2.0 + * + * @return A Boolean flag that indicates whether the specified @c width + * and @ height are supported. + * @param[in, out] evaluatedSize The width and the height that need to be evaluated. + */ + virtual void OnEvaluateSize(Tizen::Graphics::Dimension& evaluatedSize); + + /** + * Removes the specified control from the container. + * + * @since 2.0 + * + * @return An error code + * @param[in] control The child control to be removed + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified instance is not found within the indicated range (that is, the @c control is not found). + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed child control is deleted from the memory. Before deletion, OnTerminating() of the child control is called. + * @see Tizen::Ui::Control::OnTerminating() + */ + result RemoveControl(const Control& control); + + /** + * Removes the specified control from the container. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the control to be removed + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed child control is deleted from the memory. Before deletion, OnTerminating() of the child control is called. + * @see Tizen::Ui::Control::OnTerminating() + */ + result RemoveControl(int index); + + /** + * Removes all the controls from the container. + * + * @since 2.0 + * + * @remarks The removed child controls are deleted from the memory. Before deletion, OnTerminating() of the child control is called. + * @see Tizen::Ui::Control::OnTerminating() + */ + void RemoveAllControls(void); + + /** + * Gets the control at the specified index of the list that is kept by the container. + * + * @since 2.0 + * + * @return The control at the specified index of the list, @n + * else @c null if the index is not valid + * @param[in] index The index of the control + */ + Control* GetControl(int index) const; + + /** + * Gets the control with the specified name. @n + * If there are multiple matches of the name, the first match is returned. + * + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompGetControlPage "here". + * @endif + * + * @return The control having the specified name, @n + * else @c null if the name is not valid + * @param[in] name The name of the control + * @param[in] recursive Set to @c true to find a match recursively, @n + * else @c false + */ + Control* GetControl(const Tizen::Base::String& name, bool recursive = false) const; + + /** + * @if OSPCOMPAT + * @page CompGetControlPage Compatibility for GetControl() + * @section CompGetControlPage IssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# GetControl() method searches for itself first and then child controls in OSP, whereas only @n + * child controls are searched for from Tizen. + * + * @section CompGetControlPage SolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * @endif + */ + + /** + * Gets the number of the controls in the container. + * + * @since 2.0 + * + * @return The number of controls in the container + */ + int GetControlCount(void) const; + + /** + * Gets a list of the controls of the container. + * + * @since 2.0 + * + * @return The list of the controls of the container + */ + Tizen::Base::Collection::IList* GetControls(void) const; + + /** + * Gets the portrait layout of the container. + * + * @since 2.0 + * + * @return The portrait layout of the container, @n + * else @c null if the layout does not exist + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The returned layout can be @c null, if it is not set. + */ + Layout* GetPortraitLayoutN(void) const; + + /** + * Gets the landscape layout of the container. + * + * @since 2.0 + * + * @return The landscape layout of the container, @n + * else @c null if the layout does not exist + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The returned layout can be @c null, if it is not set. + */ + Layout* GetLandscapeLayoutN(void) const; + + /** + * Gets the layout of the current orientation. + * + * @since 2.0 + * + * @return The layout of the current orientation, @n + * else @c null if the layout does not exist + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The returned layout can be @c null, if it is not set. + */ + Layout* GetLayoutN(void) const; + + /** + * Checks whether the specified control is a child or descendant of the container. + * + * @since 2.0 + * + * @return @c true if the specified control is within the containment hierarchy of the container, @n + * else @c false + * @param[in] control The control + */ + bool IsAncestorOf(const Control& control) const; + + /** + * Sets whether the specified child control must always be above other children. + * + * @since 2.0 + * + * @return An error code + * @param[in] control The child control + * @param[in] alwaysOnTop The Boolean value indicating that @c control + * must always be on the top + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid.@n + * The specified control is not a child of this + * container. + * @remarks If multiple child control are set as "always on top", then + * their relative order is not specified. If the specified child + * control is a container, then all its children inherit this + * property and they are "always on top" of other controls.@n + * If the method is called on a child control with a @c false + * value, then it's state becomes normal. The relative order + * of child controls in normal state is not specified. + * @see IsControlAlwaysOnTop() + */ + result SetControlAlwaysOnTop(Tizen::Ui::Control& control, bool alwaysOnTop); + + /** + * Sets whether the specified child control must always be below other children. + * + * @since 2.0 + * + * @return An error code + * @param[in] control The child control + * @param[in] alwaysAtBottom The Boolean value indicating that @c control + * must always be at the bottom. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid.@n + * The specified control is not a child of this + * container. + * @remarks If multiple child control are set as "always at bottom", then + * their relative order is not specified. If the specified child + * control is a container, then all its children inherit this + * property and they become "always at bottom" as well.@n + * If the method is called on a child control with a @c false + * value, then it's state becomes normal. The relative order + * of child controls in normal state is not specified. + * @see IsControlAlwaysAtBottom() + */ + result SetControlAlwaysAtBottom(Tizen::Ui::Control& control, bool alwaysAtBottom); + + /** + * Checks whether the specified child control is always at the bottom of + * the drawing stack. + * + * @since 2.0 + * + * @return @c true if the specified child control is set as always at the bottom, @n + * else @c false + * @param[in] control The child control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid.@n + * The specified control is not a child of this + * container. + * @remarks The specific error code can be accessed using the GetLastResult() + * method. + * @see SetControlAlwaysAtBottom() + */ + bool IsControlAlwaysAtBottom(const Tizen::Ui::Control& control) const; + + /** + * Checks whether the specified child control is always on the top of + * the drawing stack. + * + * @since 2.0 + * + * @return @c true if the specified child control is set as always on the top, @n + * else @c false + * @param[in] control The child control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified control is not a child of this + * container. + * @remarks The specific error code can be accessed using the GetLastResult() + * method. + * @see SetControlAlwaysOnTop() + */ + bool IsControlAlwaysOnTop(const Tizen::Ui::Control& control) const; + +protected: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + Container(void); + + /** + * Initializes this instance of %Container. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(void); + + /** + * Initializes this instance of %Container. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The rectangle bounds to be set + * @param[in] resizable Set to @c true to make the container resizable, @n + * else @c false + * @param[in] movable Set to @c true to make the container movable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks This method must be called from the derived classes's construct methods. + * @remarks If the @c resizable is @c false, IsResizable() returns @c false. + * @see IsResizable() + */ + result Construct(const Tizen::Graphics::Rectangle& rect, bool resizable = true, bool movable = true); + + /** + * Initializes this instance of %Container with the specified layout and rectangular region. + * + * @since 2.0 + * + * @return An error code + * @param[in] layout The layout for both the portrait and landscape mode + * @param[in] rect The location and size of the %Container + * @param[in] resizable Set to @c true to make the container resizable, @n + * else @c false + * @param[in] movable Set to @c true to make the container movable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks This method must be called from the derived classes's construct methods. + * @remarks If the @c resizable is @c false, IsResizable() returns @c false. + * @see IsResizable() + * @see Tizen::Ui::Layout + * @see Tizen::Ui::Container::GetLayoutN() + */ + result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Rectangle& rect, bool resizable = true, bool movable = true); + + /** + * Initializes this instance of %Container with the specified layouts and rectangular region. + * + * @since 2.0 + * + * @return An error code + * @param[in] portraitLayout The layout for the portrait mode + * @param[in] landscapeLayout The layout for the landscape mode + * @param[in] rect The location and size of the %Container + * @param[in] resizable Set to @c true to make the container resizable, @n + * else @c false + * @param[in] movable Set to @c true to make the container movable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks If the @c resizable is @c false, IsResizable() returns @c false. + * @see IsResizable() + * @see Tizen::Ui::Layout + * @see Tizen::Ui::Layout + * @see Tizen::Ui::Container::GetLayoutN() + * @see Tizen::Ui::Container::GetPortraitLayoutN() + * @see Tizen::Ui::Container::GetLandscapeLayoutN() + */ + result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Rectangle& rect, bool resizable = true, bool movable = true); + + /** + * Gets the index of the specified control. + * + * @since 2.0 + * @return An error code + * @param[in] control The control + * @param[out] index The index of the control + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified instance of Control is not found. + * @see SetControlAt() + * + */ + result GetControlAt(const Control& control, int& index) const; + + /** + * Sets the control at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] control The control + * @param[in] index The index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks The @c control must be first added to this container. @n + * Call the Invalidate() method after this, to apply the change to be shown. + * @see Invalidate(), GetControlAt() + * + */ + result SetControlAt(const Control& control, int index); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Container(const Container& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Container& operator =(const Container& rhs); + +protected: + friend class _ContainerImpl; + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Container_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Container_Reserved2(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Container_Reserved3(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Container_Reserved4(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Container_Reserved5(void) {} + +}; // Container + +}} //Tizen::Ui + +#endif //_FUI_CONTAINER_H_ diff --git a/inc/FUiControl.h b/inc/FUiControl.h new file mode 100644 index 0000000..622b764 --- /dev/null +++ b/inc/FUiControl.h @@ -0,0 +1,1489 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiControl.h + * @brief This is the header file for the %Control class. + * + * This header file contains the declarations of the %Control class. + */ + +#ifndef _FUI_CONTROL_H_ +#define _FUI_CONTROL_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Animations { +class ControlAnimator; +class VisualElement; +}}} + +namespace Tizen { namespace Ui { + +class AccessibilityContainer; +class Container; +class _ControlImpl; +class TouchGestureDetector; + +/** + * @class Control + * @brief This class is the abstract base class of all the UI control classes. + * + * @since 2.0 + * + * @remarks In order for a control to be displayed, it must first be bound to a window of the underlying window system. The control's window is + * created when it (or its ancestor) is added to a valid control containment hierarchy. A containment hierarchy is valid if and + * only if the root of the hierarchy is an instance of the Window class. + * + * The %Control class is the abstract base class of all user interface elements. It encapsulates a + * "window" of the underlying window system, and provides the infrastructure necessary for the + * elements to respond to user inputs. The %Control class also determines how a key event is dispatched + * and processed. + * + * For more information on the class features, see UI Controls. + * + * + * The following examples demonstrate how to use the %Control class. + * + * Size and Position + * + * @code + * // Sets the size + * pControl->SetSize(100, 100); // 100 pixels wide and 100 pixels long + * + * // Sets the position + * pControl->SetPosition(5, 5); // Control is drawn 5 pixels down and 5 pixels left from the top-left corner of its parent + * @endcode + * + * Draw and Show + * + * @code + * // Gets a instance of Canvas + * Canvas* pCanvas = pControl->GetCanvasN(); + * + * // Fills the canvas with white color + * pCanvas->Clear(Tizen::Graphics::Color(255, 255, 255)); + * + * // Shows changes on screen + * pControl->Invalidate(true); + * + * delete pCanvas; + * @endcode + * + * Key and input focus + * + * @code + * // Implements MyKeyEventListener + * IKeyEventListener* pKeyListener = new MyKeyEventListener(); + * pControl->SetFocus(); + * + * // The added key listener should be deleted after use + * pControl->AddKeyEventListener(*pKeyListener); + * @endcode + * + */ +class _OSP_EXPORT_ Control + : public Tizen::Base::Object +{ + +public: + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~Control(void); + + /** + * Adds the IFocusEventListener instance to the %Control instance. @n + * The added listener gets notified when the control gains or loses its focus. + * + * @since 2.0 + * + * @param[in] listener The event listener to add + * @see RemoveFocusEventListener() + */ + void AddFocusEventListener(IFocusEventListener& listener); + + /** + * Adds the IKeyEventListener instance to the %Control instance. @n + * The added listener gets notified when a key is pressed, released, or long pressed. + * + * @since 2.0 + * + * @param[in] listener The event listener to add + * @see RemoveKeyEventListener() + */ + void AddKeyEventListener(IKeyEventListener& listener); + + /** + * Adds the ITouchEventListener instance to the %Control instance. @n + * The added listener gets notified when a touch event such as a press or a release is fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to add + * @see RemoveTouchEventListener() + */ + void AddTouchEventListener(ITouchEventListener& listener); + + /** + * Adds the ITouchModeChangedEventListener instance to the %Control instance. @n + * The added listener gets notified when the device's touch mode is changed. + * + * @since 2.0 + * + * @param[in] listener The event listener to add + * @see RemoveTouchModeChangedEventListener() + */ + void AddTouchModeChangedEventListener(Tizen::Ui::ITouchModeChangedEventListener& listener); + + /** + * Adds the IDragDropEventListener instance to the %Control instance. @n + * The added listener gets notified when a drag or a drop happens in the control. + * + * @since 2.0 + * + * @param[in] listener The event listener to add + * @see RemoveDragDropEventListener() + */ + void AddDragDropEventListener(IDragDropEventListener& listener); + + /** + * Removes the focus listener instance. @n + * The removed listener is not notified even when focus events are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to remove + * @see AddFocusEventListener() + */ + void RemoveFocusEventListener(IFocusEventListener& listener); + + /** + * Removes the key event listener instance. @n + * The removed listener is not notified even when key events are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to remove + * @see AddKeyEventListener() + */ + void RemoveKeyEventListener(IKeyEventListener& listener); + + /** + * Removes the touch event listener instance. @n + * The removed listener is not notified even when touch events are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to remove + * @see AddTouchEventListener() + */ + void RemoveTouchEventListener(ITouchEventListener& listener); + + /** + * Removes the touch mode changed event listener instance. @n + * The removed listener is not notified even when the touch mode changed events are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to remove + * @see AddTouchModeChangedEventListener() + */ + void RemoveTouchModeChangedEventListener(Tizen::Ui::ITouchModeChangedEventListener& listener); + + /** + * Adds the IDragDropEventListener instance to the %Control instance. @n + * The added listener gets notified when a drag or a drop happens in the control. + * + * @since 2.0 + * + * @param[in] listener The event listener to add + * @see Tizen::Ui::IDragDropEventListener::OnTouchDragged() + * @see Tizen::Ui::IDragDropEventListener::OnTouchDropped() + * @see RemoveDragDropEventListener() + */ + void RemoveDragDropEventListener(IDragDropEventListener& listener); + + /** + * Overrides this method to provide user-specific initialization code before the control is added to a container. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_FAILURE The method has failed. + * @remarks This method is called when the control is about to be added to a container. + * @remarks To cancel adding this control to the parent, return @c E_FAILURE in this method. + * @see OnTerminating() + */ + virtual result OnInitializing(void); + + /** + * Overrides this method to provide user-specific termination code. + * + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompOnTerminatingPage "here". + * @endif + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_FAILURE The method has failed. + * @remarks This method is called right before the control is removed successfully from the container. + * @remarks To cancel removing this control from the parent, return @c E_FAILURE in this method. + * @see OnInitializing() + */ + virtual result OnTerminating(void); + + /** + * @if OSPCOMPAT + * @page CompOnTerminatingPage Compatibility for OnTerminating() + * @section CompOnterminatingPage IssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# OnTerminating() callback is called from child to parent. + * + * @section CompOnTerminatingPage SolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# OnTerminating() callback is called from parent to child. + * @endif + */ + + /** + * Called asynchronously when the user event that is sent by SendUserEvent() method is + * dispatched to the control. + * + * @since 2.0 + * + * @param[in] requestId The user-defined event ID + * @param[in] pArgs A pointer to the argument list + * @see SendUserEvent() + */ + virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs); + + /** + * Checks whether the control is movable. + * + * @since 2.0 + * + * @return @c true if the control is movable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks When control is not movable SetPosition() and SetBounds() return @c E_UNSUPPORTED_OPERATION. + * @see SetPosition() + * @see SetBounds() + */ + bool IsMovable(void) const; + + /** + * Checks whether the control is resizable. + * + * @since 2.0 + * + * @return @c true if the control is resizable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @remarks Even if this method returns @c true, the size can be changed internally. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks When control is not resizable, + * SetSize(), SetBounds(), SetMinimumSize() and SetMaximumSize() return @c E_UNSUPPORTED_OPERATION. + * @see SetSize() + * @see SetBounds() + * @see SetMinimumSize() + * @see SetMaximumSize() + */ + bool IsResizable(void) const; + + /** + * Gets the position and the size of the control. + * + * @since 2.0 + * + * @return An instance of the Tizen::Graphics::Rectangle that represents the position of top-left corner, + * the width, and the height of the control + * @remarks The shape of the control is rectangular that is defined by the top-left point, + * and the width or height. The position + * of the top-left point is relative to the top-left corner of the parent container. + * @see SetBounds() + */ + Tizen::Graphics::Rectangle GetBounds(void) const; + + /** + * Gets the position and the size of the control. + * + * @since 2.0 + * + * @param[out] x The x position of top-left corner of the control + * @param[out] y The y position of top-left corner of the control + * @param[out] width The width of the rectangular region + * @param[out] height The height of the rectangular region + * @remarks The shape of the control is regarded as a rectangle that is defined + * by the top-left point and the width or height. + * The position of the top-left point is relative to the top-left corner of + * the parent container. + * @see SetBounds() + */ + void GetBounds(int& x, int& y, int& width, int& height) const; + + /** + * Gets the position of the control's top-left corner. + * + * @since 2.0 + * + * @return The position of the control's top-left corner + * @remarks The position of top-left corner is relative to the top-left corner of its parent container. + * @see GetBounds() + */ + Tizen::Graphics::Point GetPosition(void) const; + + /** + * Gets the position of the control's top-left corner. + * + * @since 2.0 + * + * @param[out] x The x position of the control's top-left corner + * @param[out] y The y position of the control's top-left corner + * @remarks The position of top-left corner is relative to the top-left corner of its parent container. + * @see GetBounds() + */ + void GetPosition(int& x, int& y) const; + + /** + * Gets the size of the control. + * + * @since 2.0 + * + * @return The size of the control + * @see GetBounds() + */ + Tizen::Graphics::Dimension GetSize(void) const; + + /** + * Gets the size of the control. + * + * @since 2.0 + * + * @param[out] width The width of the control + * @param[out] height The height of the control + * @see GetBounds() + */ + void GetSize(int& width, int& height) const; + + /** + * Gets the x position of the control. @n + * The position of control is relative to the top-left corner of its parent container. + * + * @since 2.0 + * + * @return The x position of the control + * @see GetBounds() + * @see GetPosition() + * @see GetY() + */ + int GetX(void) const; + + /** + * Gets the y position of the control. @n + * The position of control is relative to the top-left corner of its parent container. + * + * @since 2.0 + * + * @return The y position of the control + * @see GetBounds() + * @see GetPosition() + * @see GetX() + */ + int GetY(void) const; + + /** + * Gets the width of the control. + * + * @since 2.0 + * + * @return The width of the control + * @see GetBounds() + * @see GetSize() + * @see GetHeight() + */ + int GetWidth(void) const; + + /** + * Gets the height of the control. + * + * @since 2.0 + * + * @return The height of the control + * @see GetBounds() + * @see GetSize() + * @see GetWidth() + */ + int GetHeight(void) const; + + /** + * Gets the minimum size of the control. + * + * @since 2.0 + * + * @return The minimum size of the control + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The first call of the method returns the system-defined minimum size. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Dimension GetMinimumSize(void) const; + + /** + * Gets the maximum size of the control. + * + * @since 2.0 + * + * @return The maximum size of the control + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The first call of the method returns the system-defined maximum size. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Dimension GetMaximumSize(void) const; + + /** + * Gets a font of the control. + * + * @since 2.0 + * + * @return The font name set in the control, @n + * else an empty string if the font is not set + * @see SetFont() + */ + Tizen::Base::String GetFont(void) const; + + /** + * Sets the position and size of the control. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The new bounds of the control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The control has not been constructed as yet. + * @exception E_UNSUPPORTED_OPERATION This control is neither movable nor resizable. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not override this method. + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. + * @see IsMovable() + * @see IsResizable() + * @see GetMinimumSize() + * @see GetMaximumSize() + * @see SetPosition() + * @see SetSize() + */ + result SetBounds(const Tizen::Graphics::Rectangle& rect); + + /** + * Sets the position and size of the control. @n + * The position is set at (x, y), and the @c width and @c height parameters contain + * the width and height values of the object, respectively. + * + * @since 2.0 + * + * @return An error code + * @param[in] x The new x position of the control + * @param[in] y The new y position of the control + * @param[in] width The new width of the control + * @param[in] height The new height of the control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The control has not been constructed as yet. + * @exception E_UNSUPPORTED_OPERATION This control is neither movable nor resizable. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not override this method. + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. + * @see IsMovable() + * @see IsResizable() + * @see GetMinimumSize() + * @see GetMaximumSize() + * @see SetPosition() + * @see SetSize() + */ + result SetBounds(int x, int y, int width, int height); + + /** + * Sets the relative position of the control. + * + * @since 2.0 + * + * @return An error code + * @param[in] Position The new position + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The control has not been constructed as yet. + * @exception E_UNSUPPORTED_OPERATION This control is not movable. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not override this method. + * @remarks The position of the control are relative to the top-left corner of its parent. + * @see IsMovable() + * @see SetBounds() + */ + result SetPosition(const Tizen::Graphics::Point& Position); + + /** + * Sets the position of the control. + * + * @since 2.0 + * @return An error code + * @param[in] x The new x position of the control + * @param[in] y The new y position of the control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The control has not been constructed as yet. + * @exception E_UNSUPPORTED_OPERATION This control is not movable. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not override this method. + * @remarks The x,y position of the control are relative to the top-left corner of its parent. + * @see IsMovable() + * @see SetBounds() + */ + result SetPosition(int x, int y); + + /** + * Sets the size of the control. @n + * + * @since 2.0 + * + * @return An error code + * @param[in] size The new width and height + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The control has not been constructed as yet. + * @exception E_UNSUPPORTED_OPERATION This control is not resizable. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not override this method. + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. + * @see IsResizable() + * @see GetMinimumSize() + * @see GetMaximumSize() + * @see SetBounds() + */ + result SetSize(const Tizen::Graphics::Dimension& size); + + /** + * Sets the size of the control. @n + * The @c width and @c height parameters contain the width and height values of the object, respectively. + * + * @since 2.0 + * + * @return An error code + * @param[in] width The new width of the control + * @param[in] height The new height of the control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The control has not been constructed as yet. + * @exception E_UNSUPPORTED_OPERATION This control is not resizable. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not override this method. + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. + * @see IsResizable() + * @see GetMinimumSize() + * @see GetMaximumSize() + * @see SetBounds() + */ + result SetSize(int width, int height); + + /** + * Sets the minimum size of the control. + * + * @since 2.0 + * + * @return An error code + * @param[in] newMinDim The new minimum size of the control + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This control is not resizable. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can affect the maximum size and the current size of the control. @n + * The control needs to be redrawn to reflect the change in its size. @n + * If the current maximum size or the control size is smaller than the new minimum size, + * it becomes the same as the new minimum size. + * @see IsResizable() + */ + result SetMinimumSize(const Tizen::Graphics::Dimension& newMinDim); + + /** + * Sets the maximum size of the control. + * + * @since 2.0 + * + * @return An error code + * @param[in] newMaxDim The new maximum size of the control + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This control is not resizable. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can affect the minimum size and the current size of the control. @n + * The control needs to be redrawn to reflect the change in its size. @n + * If the current minimum size or the control size is greater than the new maximum size, + * it becomes the same as the new maximum size. + * @see IsResizable() + */ + result SetMaximumSize(const Tizen::Graphics::Dimension& newMaxDim); + + /** + * Converts the specified screen position to the position in control's coordinate system. + * + * @since 2.0 + * + * @return The position relative to the top-left corner of the control's client-area + * @param[in] screenPosition The position relative to the top-left corner of the screen + * @see ConvertToScreenPosition() + */ + Tizen::Graphics::Point ConvertToControlPosition(const Tizen::Graphics::Point& screenPosition) const; + + /** + * Converts the specified position in the control's coordinate system to the screen position. + * + * @since 2.0 + * + * @return The position relative to the top-left corner of the screen + * @param[in] controlPosition The position relative to the top-left corner of the control's client-area + * @see ConvertToControlPosition() + */ + Tizen::Graphics::Point ConvertToScreenPosition(const Tizen::Graphics::Point& controlPosition) const; + + /** + * Sets the font of the control. + * + * @since 2.0 + * + * @return An error code + * @param[in] fontName The app font name or system font name @n + * The app font name is retrieved using Tizen::Graphics::Font::GetFaceName(Tizen::Base::String& filepath). @n + * The system font name is retrieved using Tizen::Graphics::Font::GetSystemFontListN(). + * Sets an empty string to reset. + * @exception E_SUCCESS The method is successful. + * @exception E_FILE_NOT_FOUND The specified font cannot be found or accessed. + * @remarks At first, the value of @c fontName is considered app font name if it matches one of the face names of the font files which are located in @b '/res/font'. + * If not, the value of @c fontName is considered system font name if it matches one of the retrieved values using Tizen::Graphics::Font::GetSystemFontListN(). + * @remarks The control first attempts to find the control font. If it fails, then it searches for the application default font and the system font, in sequence. + * @see GetFont() + */ + result SetFont(const Tizen::Base::String& fontName); + + /** + * Checks whether the specified @c point is inside the control. + * + * @since 2.0 + * + * @return @c true if the specified @c point is inside the control, @n + * else @c false + * @param[in] point The point to check + * @remarks The specified @c point must be defined relative to the top-left corner of the control. + */ + bool Contains(const Tizen::Graphics::Point& point) const; + + /** + * Checks whether the specified point is inside the control. + * + * @since 2.0 + * + * @return @c true if the specified point is inside the control, @n + * else @c false + * @param[in] x The x position of the point to check + * @param[in] y The y position of the point to check + * @remarks The specified point must be defined relative to the top-left corner of the control. + */ + bool Contains(int x, int y) const; + + /** + * Draws child controls recursively. + * + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompDrawPage "here". + * @endif + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * Note: This control cannot be displayed. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method calls OnDraw() immediately in a synchronous way. + * @see Show() + */ + result Draw(void); + + /** + * @if OSPCOMPAT + * @page CompDrawPage Compatibility for Draw() + * @section CompDrawPage IssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# Draw() method draws child controls in a recursive way regardless of the visibility of the parent. + * + * @section CompDrawPage SolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# Draw() method does not draw child controls if the control itself is not visible. + * @endif + */ + + /** + * Draws the control. + * + * @since 2.0 + * + * @param[in] recursive Set to @c true to draw child controls recursively, @n + * else @c false + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * Note: This control cannot be displayed. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method calls OnDraw() immediately in a synchronous way. + * @see Show() + */ + result Draw(bool recursive); + + /** + * Shows the control on the screen. + * + * @since 2.0 + * @final Although this method is virtual, it should not be overridden. + * If overridden, it may not work as expected. + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * Note: This control cannot be displayed. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not override this method. + */ + virtual result Show(void); + + /** + * Invalidates the control. + * + * @since 2.0 + * + * @param[in] recursive Set to @c true to invalidate child controls recursively, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * Note: This control cannot be displayed. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks OnDraw() is not called immediately, but called asynchronously just before the screen is updated. + * @see Show() + */ + void Invalidate(bool recursive); + + /** + * Invalidates the control of the specified position and size. + * + * @since 2.0 + * + * @param[in] bounds The position relative to the top-left corner of the control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * Note: This control cannot be displayed. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see Show() + */ + void InvalidateBounds(const Tizen::Graphics::Rectangle& bounds); + + /** + * Draws the control asynchronously. + * + * @since 2.0 + * + * @param[in] show Set to @c true to also show the control, @n + * else @c false + * @remarks This method posts a draw event in the event queue. @n + * Drawing requested by %RequestRedraw() occurs when the draw event is fired to the control. + */ + void RequestRedraw(bool show = true) const; + + /** + * Creates and returns a graphics canvas whose bounds (that is, position and size) are equal to those + * of the control. + * + * @since 2.0 + * + * @return The graphic canvas of the control, @n + * else @c null if an exception occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @remarks The method allocates a Tizen::Graphics::Canvas whose bounds are equal to that of the control. + * It is the developer's responsibility to deallocate the canvas after use. + * The canvas is guaranteed to be valid only if the properties of the parent controls of the canvas remain unchanged. + * Therefore, one must delete previously allocated canvas and create a new canvas using the %GetCanvasN() method + * if the size or position of the control is changed. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks The Frame and Form (and between different Form instances) share a single frame-buffer. Therefore, + * if custom drawing is performed on the graphic canvas of Frame and Form + * then it will appear on the screen regardless of which control is currently visible on the screen. + * @see GetCanvasN(const Tizen::Graphics::Rectangle& bounds) const + * @see GetCanvasN(int x, int y, int width, int height) const + * @code + * result + * MyForm::OnDraw(void) + * { + * result r = E_SUCCESS; + * Canvas* pCanvas = GetCanvasN(); + * if (pCanvas != null) + * { + * // add your drawing code here + * } + * if (pCanvas) + * delete pCanvas; + * // Do not call Show(). It will be called automatically after OnDraw() callback. + * return r; + * } + * @endcode + */ + Tizen::Graphics::Canvas* GetCanvasN(void) const; + + /** + * Creates and returns a graphic canvas of the control of the specified position and size. + * + * @since 2.0 + * + * @return The graphic canvas of the control, @n + * else @c null if an exception occurs + * @param[in] bounds The bounds of the graphic canvas + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified bounds does not intercept with the bounds of the control. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @remarks Only the graphic canvas of displayable controls can be obtained. + * If the specified area is not inside the control, + * the graphics canvas of overlapped area between the control and the specified bound is returned. @n + * @remarks The method allocates an Tizen::Graphics::Canvas whose bounds are equal to that of the control. + * It is the developer's responsibility to deallocate the canvas after use. + * The canvas is guaranteed to be valid only if the properties of the parent controls of the canvas remain unchanged. + * Therefore, one must delete previously allocated canvas and create a new canvas using the %GetCanvasN() method + * if the size or position of the control is changed. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks The Frame and Form (and between different Form instances) share a single frame-buffer. Therefore, + * if custom drawing is performed on the graphic canvas of Frame and Form + * then it will appear on the screen regardless of which control is currently visible on the screen. + * @see GetCanvasN(void) const + * @see GetCanvasN(int x, int y, int width, int height) const + */ + Tizen::Graphics::Canvas* GetCanvasN(const Tizen::Graphics::Rectangle& bounds) const; + + /** + * Creates and returns a graphic canvas of the specified position and size in the control. + * + * @since 2.0 + * + * @return The graphic canvas of the control, @n + * else @c null if an exception occurs + * @param[in] x The x position relative to the top-left corner of the control + * @param[in] y The y position relative to the top-left corner of the control + * @param[in] width The width of a graphic canvas + * @param[in] height The height of a graphic canvas + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified bounds does not intercept with the bounds of the control. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @remarks Only the graphic canvas of displayable controls can be obtained. + * If the specified area is not inside the control, + * the graphics canvas of the overlapped area between the control and the specified bound is returned. @n + * @remarks The method allocates an Tizen::Graphics::Canvas whose bounds are equal to that of the control. + * It is the developer's responsibility to deallocate the canvas after use. + * The canvas is guaranteed to be valid only if properties of the parent controls of the canvas remain unchanged. + * Therefore, one must delete the previously allocated canvas and create a new canvas using the %GetCanvasN() method + * if the size or position of the control is changed. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks The Frame and Form (and between different Form instances) share a single frame-buffer. Therefore, + * if custom drawing is performed on the graphic canvas of Frame and Form + * then it will appear on the screen regardless of which control is currently visible on the screen. + * @see GetCanvasN(void) const + * @see GetCanvasN(const Tizen::Graphics::Rectangle& bounds) const + */ + Tizen::Graphics::Canvas* GetCanvasN(int x, int y, int width, int height) const; + + /** + * Checks whether the control is currently visible on the screen. + * + * @since 2.0 + * + * @return @c true if the control is currently visible on the screen, @n + * else @c false + * @remarks If this method is called before the control is added to a parent, @c false is returned. + * @see GetShowState() + * @see SetShowState() + */ + bool IsVisible(void) const; + + /** + * Gets the current show state of the control. + * + * @since 2.0 + * + * @return The show state of the control + * @remarks Even if the control's state is "show", the control may not be visible. + * @see SetShowState() + * @see IsVisible() + */ + bool GetShowState(void) const; + + /** + * Sets the show state of the control. + * + * @since 2.0 + * + * @return An error code + * @param[in] state The new show state + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * Note: This control cannot be displayed. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not override this method. + * @remarks Even if this method is invoked, the control is not drawn or shown. @n + * To draw and show the control, use Invalidate() method. @n + * Once the control's show state is set to @c false, + * the show state needs to be set to @c true again before you draw and show the control. + * @see GetShowState() + * @see Invalidate() + */ + result SetShowState(bool state); + + /** + * Gets the dedicated %VisualElement instance for this control. + * + * @since 2.0 + * + * @return An instance of the VisualElement + * @remarks If an application developer modifies the state of the returned VisualElement + * and the host control is not aware of this change, then the control may behave egregiously. + * It is highly recommended to restore the %VisualElement state to avoid such conflicts. + */ + Tizen::Ui::Animations::VisualElement* GetVisualElement(void) const; + + /** + * Gets the parent of the control. + * + * @since 2.0 + * + * @return The current parent of the control + */ + Container* GetParent(void) const; + + /** + * Gets the name of the control. + * + * @since 2.0 + * + * @return The name of the control + */ + Tizen::Base::String GetName(void) const; + + /** + * Sets the name of the control. + * + * @since 2.0 + * + * @param[in] name The name of the control + */ + void SetName(const Tizen::Base::String& name); + + /** + * Checks whether the control is focusable. + * + * @since 2.0 + * + * @return @c true if control is focusable, @n + * else @c false + * @remarks The focus ability of the container classes like Panel is @c false by default. + */ + bool IsFocusable(void) const; + + /** + * Sets the focus ability of the control. @n + * Non-Focusable controls cannot take the key focus. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * Note: The control does not permit to change its focus ability. + * @exception E_SYSTEM A system error has occurred. + * @remarks The focus ability of the container classes like Panel is @c false by default. + * @remarks The RadioGroup class does not render the UI. + * Therefore, RadioGroup::SetFocusable() returns @c E_SYSTEM. + */ + result SetFocusable(bool focusable); + + /** + * Checks whether the control currently has the input focus. + * + * @since 2.0 + * + * @return @c true if the control currently has the input focus, @n + * else @c false + * @remarks If this method is called before the control is added to a parent, @c false is returned. + * @see SetFocus() + */ + bool HasFocus(void) const; + + /** + * Sets the focus to the control. @n + * This method is called if the control needs to listen to user input events such as key pressed. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * Note: This control cannot be displayed. + * @exception E_INVALID_CONDITION The control is not contained in, or is not the top z-order frame or form. + * @remarks Do not override this method. + */ + result SetFocus(void); + + /** + * Checks whether the control is enabled. + * + * @since 2.0 + * + * @return @c true if the control is enabled, @n + * else @c false + * @remarks If this method is called before the control is added to a parent, @c false is returned. + * @see SetEnabled() + */ + bool IsEnabled(void) const; + + /** + * Enables or disables the control. @n + * Only an enabled control can respond to the user input. By default, the control is enabled. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable The new state of the object + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not override this method. + */ + result SetEnabled(bool enable); + + /** + * Checks whether the device is in touch mode. @n + * When the user interacts with the device by touching it, the device is in touch mode. + * + * @since 2.0 + * + * @return @c true if the device is in touch mode, @n + * else @c false + * @remarks This method returns @c false, for devices with QWERTY keyboard. + * The user can navigate the UI using directional keys. + */ + bool IsInTouchMode(void) const; + + /** + * Enables or disables the drag operation in the %Control. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable the drag operation, @n + * else @c false + * @see SetDropEnabled() + */ + void SetDragEnabled(bool enable); + + /** + * Enables or disables the drop operations in the %Control. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable drop operations, @n + * else @c false + * @remarks To receive drop event, control's drag property has to be enabled. + * @see SetDragEnabled() + */ + void SetDropEnabled(bool enable); + + /** + * Sends a user event to the control. + * + * @since 2.0 + * + * @param[in] requestId The user-defined event ID + * @param[in] pArgs A pointer to the argument list + * @remarks This method posts a user event in the event queue + * and returns immediately to support asynchronous actions of the framework. + * @see OnUserEventReceived() + */ + void SendUserEvent(RequestId requestId, const Tizen::Base::Collection::IList* pArgs) const; + + /** + * Stops the current UI event dispatch sequence by indicating the current input event is consumed. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks If this method is invoked during an UI event (key or touch) propagation sequence, + * the method will stop the propagation and consequently the system will not be notified of the event. @n + * The method will not have any effect if no UI event is being dispatched. @n + * It is recommended that this method is called within IKeyEventListener or + * ITouchEventListener to stop the event from propagating to the next step. + */ + result ConsumeInputEvent(void); + + /** + * Gets the control animator of the current instance of %Control + * + * @since 2.0 + * + * @return A pointer to ControlAnimator, @n + * else @c null if this instance is not constructed or not added to a parent or non-animatable + */ + Tizen::Ui::Animations::ControlAnimator* GetControlAnimator(void) const; + + /** + * Adds the gesture detector to the %Control. @n + * The added gesture detector receives touch events prior to %Control. + * + * @since 2.0 + * + * @return An error code + * @param[in] gestureDetector The gesture detector + * @exception E_SUCCESS The method is successful. + * @see RemoveGestureDetector() + */ + result AddGestureDetector(const TouchGestureDetector& gestureDetector); + + /** + * Removes the gesture detector from the %Control. + * + * @since 2.0 + * + * @return An error code + * @param[in] gestureDetector The gesture detector + * @exception E_SUCCESS The method is successful. + * @see AddGestureDetector() + */ + result RemoveGestureDetector(const TouchGestureDetector& gestureDetector); + + /** + * @if OSPDEPREC + * Gets the composite mode for merging with other controls. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because changing composition mode is not allowed any more. + * @since 2.0 + * + * @return The composite mode + * @exception E_SUCCESS The method is successful. + * @remarks In Tizen, this method only returns @c COMPOSITE_MODE_ALPHA_BLENDING. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @endif + */ + Tizen::Ui::CompositeMode GetCompositeMode(void) const; + + /** + * @if OSPDEPREC + * Sets the composite mode for merging with other controls. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because changing composition mode is not allowed any more. + * @since 2.0 + * + * @return An error code + * @param[in] compositeMode The composite mode + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The method is not supported. + * @remarks In Tizen, only @c COMPOSITE_MODE_ALPHA_BLENDING is allowed. + * Otherwise, this method returns @c E_UNSUPPORTED_OPERATION. + * @endif + */ + result SetCompositeMode(Tizen::Ui::CompositeMode compositeMode); + + /** + * @if OSPDEPREC + * Gets the chroma key color value that is used for the control composition. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because chroma key color is not supported any more. + * @since 2.0 + * + * @return The chroma key color + * @exception E_UNSUPPORTED_OPERATION The method is not supported. + * @remarks In Tizen, this method always fails and returns Tizen::Graphics::Color(0, 0, 0, 0). + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @endif + */ + Tizen::Graphics::Color GetChromaKeyColor(void) const; + + /** + * @if OSPDEPREC + * Sets the chroma key color value that is used for the control composition. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because chroma key color is not supported any more. + * @since 2.0 + * + * @return An error code + * @param[in] chromaKeyColor The chroma key color + * @exception E_UNSUPPORTED_OPERATION The method is not supported. + * @remarks In Tizen, this method always fails. + * @endif + */ + result SetChromaKeyColor(Tizen::Graphics::Color chromaKeyColor); + + /** + * Captures the composited scene of the Panel control. + * + * @since 2.0 + * + * @return A Tizen::Graphics::Bitmap instance that captures the current composited scene of the Panel control, @n + * else @c null if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This method is not supported. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks This method is not supported in the following class that is derived from Panel class: + * @li OverlayPanel + * @remarks The bounds of the %Panel control must be within the client area of the Form control to get a valid composited scene. + */ + Tizen::Graphics::Bitmap* GetCapturedBitmapN(void) const; + + /** + * Gets the position and the size of the invalidated bounds. + * + * @since 2.0 + * + * @return An instance of Tizen::Graphics::Rectangle that represents the position of top-left corner, + * the width, and the height of the invalidated bounds + */ + Tizen::Graphics::Rectangle GetInvalidatedBounds(void) const; + + /** + * Enables or disables the multi-point touch of the %Control. + * + * @since 2.0 + * + * @param[in] enable A Boolean flag indicating whether to enable the multi-point touch + * + * @see IsMultipointTouchEnabled() + */ + + void SetMultipointTouchEnabled(bool enable); + + /** + * Checks whether the multi-point touch is enabled. + * + * @since 2.0 + * + * @return @c true if the multi-point touch is enabled, @n + * else @c false + * @see SetMultipointTouchEnabled() + */ + bool IsMultipointTouchEnabled(void) const; + + /** + * Gets the accessibility container. + * + * @since 2.0 + * + * @return The accessibilit container of the control, if the control supports accessibility feature. @n + * Else @c null. + * @see AccessibilityContainer::GetOwner() + */ + const AccessibilityContainer* GetAccessibilityContainer(void) const; + + /** + * Gets the accessibility container. + * + * @since 2.0 + * + * @return The accessibilit container of the control, if the control supports accessibility feature. @n + * Else @c null. + * @see AccessibilityContainer::GetOwner() + */ + AccessibilityContainer* GetAccessibilityContainer(void); + +protected: + /** + * Gets the default key event listener. + * + * @since 2.0 + * + * @return The default key event listener, @n + * else @null is returned if listener is not set or a system error has occurred + * @see SetDefaultKeyEventListener() + */ + IKeyEventListener* GetDefaultkeyEventListener(void) const; + + /** + * Gets the default touch event listener. + * + * @since 2.0 + * + * @return The default touch event listener @n + * If not listener has been set or a system error has occurred @c null is returned. + * @see SetDefaultTouchEventListener() + */ + ITouchEventListener* GetDefaultTouchEventListener(void) const; + + /** + * Sets the default key event listener. + * + * @since 2.0 + * + * @return An error code + * @param[in] pDefaultListener The default key event listener + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The registered listener will be notified to handle the key events + * after all application event listeners have been notified. + * @see GetDefaultkeyEventListener() + */ + result SetDefaultKeyEventListener(IKeyEventListener* pDefaultListener); + + /** + * Sets the default touch event listener. + * + * @since 2.0 + * + * @return An error code + * @param[in] pDefaultListener The default touch event listener + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The registered listener will be notified to handle the touch events + * after all application event listeners have been notified. + * @see GetDefaultTouchEventListener() + */ + result SetDefaultTouchEventListener(ITouchEventListener* pDefaultListener); + + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + Control(void); + + /** + * This method is for internal use only. Using this method can cause behavioral, security-related, + * and consistency-related issues in the application. + * + * Initializes this instance of %Control. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(void); + + /** + * Frees the resources allocated by Construct(). + * + * @since 2.0 + */ + void Dispose(void); + +protected: + _ControlImpl* _pControlImpl; + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Control_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Control_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Control_Reserved3(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Control_Reserved4(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Control_Reserved5(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Control_Reserved6(void) {} + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Control(const Control& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Control& operator =(const Control& rhs); + +private: + friend class _ControlImpl; +}; // Control + +}} // Tizen::Ui + +#endif // _FUI_CONTROL_H_ diff --git a/inc/FUiControls.h b/inc/FUiControls.h new file mode 100644 index 0000000..2e63307 --- /dev/null +++ b/inc/FUiControls.h @@ -0,0 +1,456 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiControls.h + * @brief This is the header file for the %Tizen::Ui::Controls namespace. + * + * This header file contains the declarations and descriptions of the %Tizen::Ui::Controls namespace. + */ + +#ifndef _FUI_CONTROLS_H_ +#define _FUI_CONTROLS_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen +{ +/** + * @namespace Tizen::Ui::Controls + * @brief This namespace contains the classes and interfaces for creating rich user interface components for the applications. + * @since 2.0 + * + * @remarks @b %Header @b %file: @b \#include @b @n + * @b Library : @b osp-uifw + * + * The %Ui::Controls namespace contains classes that have graphical representations that can be displayed on the screen as UI elements and with + * which the user can interact. + * + * For more information on the %Ui::Controls namespace features, see UI Controls Guide. + * + */ + +namespace Ui +{ + +namespace Controls +{ + +/** + * @if OSPDEPREC + * The system color for the text that appears in the indicator and the command area (for example, Header and Footer). + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * @since 2.0 + * + * @remarks Different color values can be defined for different device models. + * @endif + */ +/** + * @if OSPDEPREC + * @htmlonly + * + * @endhtmlonly + * @endif + */ +extern const Tizen::Graphics::Color SYSTEM_COLOR_TITLE_TEXT; + +/** + * @if OSPDEPREC + * The system color for the text that appears in controls, has a different background color than that of its parent (for example, Button). + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * @since 2.0 + * + * @remarks Different color values can be defined for different device models. + * @endif + */ +/** + * @if OSPDEPREC + * @htmlonly + * + * @endhtmlonly + * @endif + */ +extern const Tizen::Graphics::Color SYSTEM_COLOR_BODY_TEXT; + +/** + * @if OSPDEPREC + * The system default foreground color (for example, Label and CheckButton). + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * @since 2.0 + * + * @remarks Different color values can be defined for different device models. + * @endif + */ +/** + * @if OSPDEPREC + * @htmlonly + * + * @endhtmlonly + * @endif + */ +extern const Tizen::Graphics::Color SYSTEM_COLOR_FOREGROUND; + +/** + * @if OSPDEPREC + * The system default background color (for example, Label, Panel, and ScrollPanel). + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * @since 2.0 + * + * @remarks Different color values can be defined for different device models. + * @endif + */ +/** + * @if OSPDEPREC + * @htmlonly + * + * @endhtmlonly + * @endif + */ +extern const Tizen::Graphics::Color SYSTEM_COLOR_BACKGROUND; + +/** + * @if OSPDEPREC + * The system default color for the List background. + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * @since 2.0 + * + * @remarks Different color values can be defined for different device models. + * @endif + */ +/** + * @if OSPDEPREC + * @htmlonly + * + * @endhtmlonly + * @endif + */ +extern const Tizen::Graphics::Color SYSTEM_COLOR_LIST_BACKGROUND; + +/** + * @if OSPDEPREC + * The system default color for the Form background. + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * @since 2.0 + * + * @remarks Different color values can be defined for different device models. + * @endif + */ +/** + * @if OSPDEPREC + * @htmlonly + * + * @endhtmlonly + * @endif + */ +extern const Tizen::Graphics::Color SYSTEM_COLOR_FORM_BACKGROUND; + +/** + * @if OSPDEPREC + * The system default color for the background of the Form with grouped style child controls. + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * @since 2.0 + * + * @remarks Different color values can be defined for different device models. + * @endif + */ +/** + * @if OSPDEPREC + * @htmlonly + * + * @endhtmlonly + * @endif + */ +extern const Tizen::Graphics::Color SYSTEM_COLOR_FORM_GROUP_BACKGROUND; + +/** + * @if OSPDEPREC + * The system default color for the Popup background. + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * @since 2.0 + * + * @remarks Different color values can be defined for different device models. + * @endif + */ +/** + * @if OSPDEPREC + * @htmlonly + * + * @endhtmlonly + * @endif + */ +extern const Tizen::Graphics::Color SYSTEM_COLOR_POPUP_BACKGROUND; + +/** + * @if OSPDEPREC + * The system default color of the group item text. + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * @since 2.0 + * + * @remarks Different color values can be defined for different device models. + * @endif + */ +/** + * @if OSPDEPREC + * @htmlonly + * + * @endhtmlonly + * @endif + */ +extern const Tizen::Graphics::Color SYSTEM_COLOR_GROUP_ITEM_TEXT; + +/** + * @if OSPDEPREC + * The system default color of the list text. + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * @since 2.0 + * + * @remarks Different color values can be defined for different device models. + * @endif + */ +/** + * @if OSPDEPREC + * @htmlonly + * + * @endhtmlonly + * @endif + */ +extern const Tizen::Graphics::Color SYSTEM_COLOR_LIST_ITEM_TEXT; + +/** + * @if OSPDEPREC + * The system default color of the list item text, when an item is selected. + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * @since 2.0 + * + * @remarks Different color values can be defined for different device models. + * @endif + */ +/** + * @if OSPDEPREC + * @htmlonly + * + * @endhtmlonly + * @endif + */ +extern const Tizen::Graphics::Color SYSTEM_COLOR_LIST_ITEM_PRESSED_TEXT; + +/** + * @if OSPDEPREC + * The system default color of the list element text when the item is highlighted. + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * @since 2.0 + * + * @remarks Different color values can be defined for different device models. + * @endif + */ +/** + * @if OSPDEPREC + * @htmlonly + * + * @endhtmlonly + * @endif + */ +extern const Tizen::Graphics::Color SYSTEM_COLOR_LIST_ITEM_HIGHLIGHTED_TEXT; + +}; // Tizen::Ui::Controls +}; // Tizen::Ui +}; // Tizen +#endif // _FUI_CONTROLS_H_ diff --git a/inc/FUiCtrlAnimation.h b/inc/FUiCtrlAnimation.h new file mode 100644 index 0000000..ed84d47 --- /dev/null +++ b/inc/FUiCtrlAnimation.h @@ -0,0 +1,342 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlAnimation.h + * @brief This header file contains the declarations of the %Animation class. + * + * This header file contains the declarations of the %Animation class and its helper classes. + */ + +#ifndef _FUI_CTRL_ANIMATION_H_ +#define _FUI_CTRL_ANIMATION_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum AnimationStatus + * + * Defines the animation status. + * + * @since 2.0 + */ +enum AnimationStatus +{ + ANIMATION_STOPPED, /**< The %Animation is in 'stopped' state */ + ANIMATION_PAUSED, /**< The %Animation is in 'paused' state */ + ANIMATION_PLAYING /**< The %Animation is in 'playing' state */ +}; + + +/** + * @class Animation + * @brief This class defines the common behavior of an %Animation control. + * + * @since 2.0 + * + * The %Animation class displays a series of frames one by one that are represented by the AnimationFrame instances. + * + * For more information on the class features, see Animation. + * + * + * The following example demonstrates how to use the %Animation class. + * + * + * @code +// Sample code for AnimationSample.h +#include +#include + +class AnimationSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IAnimationEventListener +{ +public: + AnimationSample(void) + : __animationFrameList(){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // IAnimationEventListener + virtual void OnAnimationStopped(const Tizen::Ui::Control& source); + +private : + Tizen::Base::Collection::ArrayList __animationFrameList; +}; + + * @endcode + * + * @code + +// Sample code for AnimationSample.cpp +#include +#include + +#include "AnimationSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +AnimationSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +AnimationSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Gets instances of Bitmap + AppResource *pAppResource = Application::GetInstance()->GetAppResource(); + Bitmap* pBitmap1 = pAppResource->GetBitmapN(L"progressing00_big.png"); + Bitmap* pBitmap2 = pAppResource->GetBitmapN(L"progressing02_big.png"); + Bitmap* pBitmap3 = pAppResource->GetBitmapN(L"progressing04_big.png"); + Bitmap* pBitmap4 = pAppResource->GetBitmapN(L"progressing06_big.png"); + + // Creates instances of AnimationFrame + AnimationFrame* pAniFrame1 = new AnimationFrame(*pBitmap1, 1000) ; + AnimationFrame* pAniFrame2 = new AnimationFrame(*pBitmap2, 1000) ; + AnimationFrame* pAniFrame3 = new AnimationFrame(*pBitmap3, 1000) ; + AnimationFrame* pAniFrame4 = new AnimationFrame(*pBitmap4, 1000) ; + + __animationFrameList.Construct(); + __animationFrameList.Add(*pAniFrame1); + __animationFrameList.Add(*pAniFrame2); + __animationFrameList.Add(*pAniFrame3); + __animationFrameList.Add(*pAniFrame4); + + // Creates an instance of Animation + Animation* pAnimation = new Animation(); + pAnimation->Construct(Rectangle((GetClientAreaBounds().width - pBitmap1->GetWidth()) / 2, 100, + pBitmap1->GetWidth(), pBitmap1->GetHeight()), __animationFrameList); + pAnimation->SetRepeatCount(100); + pAnimation->AddAnimationEventListener(*this); + + // Adds the animation to the form + AddControl(*pAnimation); + + // Plays the animation + pAnimation->Play(); + + delete pBitmap1; + delete pBitmap2; + delete pBitmap3; + delete pBitmap4; + + return r; +} + +result +AnimationSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates added animation frames from the list + __animationFrameList.RemoveAll(true); + + return r; +} + +void +AnimationSample::OnAnimationStopped(const Control& source) +{ + // .... +} + * @endcode + * + */ +class _OSP_EXPORT_ Animation + : public Tizen::Ui::Control +{ + +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + Animation(void); + + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~Animation(void); + + + /** + * Initializes this instance of %Animation with the specified parameters. @n + * The input list of the AnimationFrame instances (@c aniFrames) should be deleted explicitly after use. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created window along with + * its width and height. + * @param[in] aniFrames An IList of %AnimationFrames used in the animation + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks A control is fully usable only after it has been added to a container, therefore some methods may fail if used earlier. @n + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. + * @see AnimationFrame + */ + result Construct(const Tizen::Graphics::Rectangle& rect, const Tizen::Base::Collection::IList& aniFrames); + + +public: + /** + * Adds a listener instance to the current instance of %Animation. @n + * The added listener can listen to the events on the given event dispatcher's context when they are fired. @n + * When an animation stops, a state change event with the state name "ANIMATION_NOTIFY_CLOSE" is fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + */ + void AddAnimationEventListener(Tizen::Ui::IAnimationEventListener& listener); + + + /** + * Removes a listener instance from the current instance of %Animation. @n + * The removed listener cannot listen to the events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + */ + void RemoveAnimationEventListener(Tizen::Ui::IAnimationEventListener& listener); + + + /** + * Sets the repeat count of the animation. @n + * If this value is not set, the default value is @c 1. + * + * @since 2.0 + * + * @param[in] count The repeat count + */ + void SetRepeatCount(int count); + + + /** + * Gets the total repeat count of the animation. + * + * @since 2.0 + * + * @return The total repeat count, @n + * else @c -1 if the %Animation instance is not constructed + */ + int GetRepeatCount(void) const; + + + /** + * Gets the current repeated count of the animation. + * + * @since 2.0 + * + * @return The current repeated count, @n + * else @c -1 if the %Animation instance is not constructed + */ + int GetCurrentRepeatedCount(void) const; + + + /** + * Gets the total image count of the animation. + * + * @since 2.0 + * + * @return The total image count, @n + * else @c -1 if the %Animation instance is not constructed + */ + int GetImageCount(void) const; + + + /** + * Plays the animation. + * + * @since 2.0 + */ + void Play(void); + + + /** + * Stops the animation. + * + * @since 2.0 + */ + void Stop(void); + + + /** + * Pauses the animation. + * + * @since 2.0 + */ + void Pause(void); + + + /** + * Gets the status of the animation. + * + * @since 2.0 + * + * @return The status of animation, @n + * else ANIMATION_STOPPED if the %Animation control is not constructed + */ + AnimationStatus GetStatus(void) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Animation(const Animation& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Animation& operator =(const Animation& rhs); + + friend class _AnimationImpl; + +}; // Animation + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ANIMATION_H_ diff --git a/inc/FUiCtrlAnimationFrame.h b/inc/FUiCtrlAnimationFrame.h new file mode 100644 index 0000000..5290b14 --- /dev/null +++ b/inc/FUiCtrlAnimationFrame.h @@ -0,0 +1,133 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlAnimationFrame.h + * @brief This is the header file for the %AnimationFrame class. + * + * This header file contains the declarations of the %AnimationFrame class and its helper classes. + */ + +#ifndef _FUI_CTRL_ANIMATION_FRAME_H_ +#define _FUI_CTRL_ANIMATION_FRAME_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _AnimationFrameImpl; + +/** + * @class AnimationFrame + * @brief This class defines the common behavior of an %AnimationFrame control. + * + * @since 2.0 + * + * The %AnimationFrame class defines the common behavior of an %AnimationFrame control. + * An animation frame includes an image to be displayed and its duration. + * The duration indicates how long the image is displayed when the animation is playing. + * + * For more information on the class features, see Animation. + * + */ +class _OSP_EXPORT_ AnimationFrame + : public Tizen::Base::Object +{ + +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + AnimationFrame(void); + + /** + * Initializes this instance of %AnimationFrame with the specified parameters. @n + * It creates an instance of %AnimationFrame with the specified image and duration. + * + * @since 2.0 + * + * @param[in] frame The bitmap to be displayed + * @param[in] duration The duration in milliseconds for which the bitmap is displayed + */ + AnimationFrame(const Tizen::Graphics::Bitmap& frame, long duration); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + ~AnimationFrame(void); + + /** + * Sets the bitmap to be displayed during animation play. + * + * @since 2.0 + * + * @param[in] frame The bitmap to be displayed + */ + void SetFrame(const Tizen::Graphics::Bitmap& frame); + + /** + * Gets the bitmap to be displayed. + * + * @since 2.0 + * + * @return The bitmap + */ + const Tizen::Graphics::Bitmap* GetFrame(void) const; + + /** + * Sets the duration for which the bitmap is displayed. + * + * @since 2.0 + * + * @param[in] duration The duration in milliseconds for which the bitmap is displayed + */ + void SetDuration(long duration); + + /** + * Gets the duration for which the bitmap is displayed. + * + * @since 2.0 + * + * @return The duration value + */ + long GetDuration(void) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + AnimationFrame(const AnimationFrame& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + AnimationFrame& operator =(const AnimationFrame& rhs); + +private: + _AnimationFrameImpl* __pAnimationFrameImpl; + +}; // AnimationFrame + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ANIMATION_FRAME_H_ diff --git a/inc/FUiCtrlButton.h b/inc/FUiCtrlButton.h new file mode 100644 index 0000000..7c969cb --- /dev/null +++ b/inc/FUiCtrlButton.h @@ -0,0 +1,516 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlButton.h + * @brief This is the header file for the %Button class. + * + * This header file contains the declarations of the %Button class and its helper classes. + */ + +#ifndef _FUI_CTRL_BUTTON_H_ +#define _FUI_CTRL_BUTTON_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @enum ButtonStatus + * + * Defines the %Button control status. + * + * @since 2.0 + */ +enum ButtonStatus +{ + BUTTON_STATUS_NORMAL, /**< The normal status */ + BUTTON_STATUS_DISABLED, /**< The disabled status */ + BUTTON_STATUS_PRESSED, /**< The pressed status */ + BUTTON_STATUS_HIGHLIGHTED /**< The highlighted status */ +}; + +/** + * @class Button + * @brief This class defines the common behavior of a %Button control. + * + * @since 2.0 + * + * The %Button class displays a rectangular area that can be pressed. + * + * For more information on the class features, see Buttons. + * + * The following example demonstrates how to use the %Button class. + * + * + * @code +// Sample code for ButtonSample.h +#include + +class ButtonSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener +{ +public: + ButtonSample(void) + : __pButton(null) + , __pBitmapButton(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + // IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +private: + static const int ID_BUTTON = 101; + static const int ID_BITMAP_BUTTON = 102; + + Tizen::Ui::Controls::Button* __pButton; + Tizen::Ui::Controls::Button* __pBitmapButton; +}; + + * @endcode + * + * @code +// Sample code for ButtonSample.cpp +#include +#include + +#include "ButtonSample.h" + +using namespace Tizen::App; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +ButtonSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +ButtonSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Button + __pButton = new Button(); + __pButton->Construct(Rectangle(50, 50, 200, 200), L"Button"); + __pButton->SetActionId(ID_BUTTON); + __pButton->AddActionEventListener(*this); + + AddControl(*__pButton); + + // Creates an instance of Button for bitmap button + __pBitmapButton = new Button(); + __pBitmapButton->Construct(Rectangle(260, 50, 200, 200)); + __pBitmapButton->SetActionId(ID_BITMAP_BUTTON); + __pBitmapButton->AddActionEventListener(*this); + + // Gets instances of Bitmap + AppResource *pAppResource = Application::GetInstance()->GetAppResource(); + Bitmap* pBitmapNormal = pAppResource->GetBitmapN(L"tizen.png"); + Bitmap* pBitmapPressed = pAppResource->GetBitmapN(L"tizen.png"); + + // Sets the bitmaps to the bitmap button + __pBitmapButton->SetNormalBackgroundBitmap(*pBitmapNormal); + __pBitmapButton->SetPressedBackgroundBitmap(*pBitmapPressed); + + // Deallocates bitmaps + delete pBitmapNormal; + delete pBitmapPressed; + + // Adds the bitmap button to the form + AddControl(*__pBitmapButton); + + return r; +} + +// IActionEventListener implementation +void +ButtonSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_BUTTON: + { + // .... + } + break; + case ID_BITMAP_BUTTON: + { + // .... + } + break; + default: + break; + } +} + * @endcode + * + */ +class _OSP_EXPORT_ Button + : public Tizen::Ui::Control +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + Button(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Button(void); + + /** + * Initializes this instance of %Button with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner @n + * of the created window along with its width and height. @n + * @param[in] text The text to be displayed on the button + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully functional only after it has been added to a container. Therefore, some methods may fail if they are used before + * adding the control to the container. + * @remarks To display the text in multi-lines or to denote the end of line, use '\\n'. + * @remarks The size of the control must be within the range defined by the minimum and maximum sizes. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, const Tizen::Base::String& text = L""); + + /** + * Adds a listener instance. @n + * The added listener can listen to events on the given event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + */ + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * Removes a listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + */ + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * Sets the action ID of the button. + * + * @since 2.0 + * + * @param[in] actionId The action ID + */ + void SetActionId(int actionId); + + /** + * Gets the action ID of the button. + * + * @since 2.0 + * + * @return An integer value representing the action ID + */ + int GetActionId(void) const; + +public: + /** + * Sets the text that the button displays. + * + * @since 2.0 + * + * @param[in] text The text of the button + * @remarks To display text in multi-lines or to denote the end of line, use '\\n'. + */ + void SetText(const Tizen::Base::String& text); + + /** + * Sets the horizontal alignment of the text of the button. + * + * @since 2.0 + * + * @param[in] alignment The horizontal text alignment + */ + void SetTextHorizontalAlignment(HorizontalAlignment alignment); + + /** + * Sets the vertical alignment of the text of the button. + * + * @since 2.0 + * + * @param[in] alignment The vertical text alignment + */ + void SetTextVerticalAlignment(VerticalAlignment alignment); + +public: + /** + * Gets the text displayed by the button. + * + * @since 2.0 + * + * @return The text of the button + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets the horizontal alignment of the text of the button. + * + * @since 2.0 + * + * @return The horizontal text alignment + */ + HorizontalAlignment GetTextHorizontalAlignment(void) const; + + /** + * Gets the vertical alignment of the text of the button. + * + * @since 2.0 + * + * @return The vertical text alignment + */ + VerticalAlignment GetTextVerticalAlignment(void) const; + + //Normal color + /** + * Sets the color of the text to be displayed on the button. + * + * @since 2.0 + * + * @param[in] color The text color to be set + */ + virtual void SetTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the color of the text to be displayed on the button. + * + * @since 2.0 + * + * @return The text color + */ + virtual Tizen::Graphics::Color GetTextColor(void) const; + + //Pressed color + /** + * Sets the text color of the button for the pressed state. + * + * @since 2.0 + * + * @param[in] color The color to be set + */ + void SetPressedTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the text color of the button for the pressed state. + * + * @since 2.0 + * + * @return The text color when the button is pressed + */ + Tizen::Graphics::Color GetPressedTextColor(void) const; + + //Disabled color + /** + * Sets the text color of the button for the disabled state. + * + * @since 2.0 + * + * @param[in] color The color to be set + */ + void SetDisabledTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the text color of the button for the disabled state. + * + * @since 2.0 + * + * @return The disabled text color + */ + Tizen::Graphics::Color GetDisabledTextColor(void) const; + + /** + * Sets the text color of the button for the highlighted state. + * + * @since 2.0 + * + * @param[in] color The color to be set + * @remarks While navigating the user interface using the directional keys, the focused UI control is highlighted. + */ + void SetHighlightedTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the text color of the button for the highlighted state. + * + * @since 2.0 + * + * @return The highlighted text color + * @remarks While navigating the user interface using the directional keys, the selected UI control is highlighted and takes the focus. + */ + Tizen::Graphics::Color GetHighlightedTextColor(void) const; + + /** + * Sets a bitmap that is to be displayed when the button is not pressed. + * + * @since 2.0 + * + * @param[in] position The location of a bitmap where it is to be displayed on the button + * @param[in] bitmap The bitmap of to be set + */ + void SetNormalBitmap(const Tizen::Graphics::Point& position, const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the bitmap that is to be displayed on the button when it is pressed. + * + * @since 2.0 + * + * @param[in] position The location of a bitmap where it is to be displayed on the Button control + * @param[in] bitmap The bitmap to be set + */ + void SetPressedBitmap(const Tizen::Graphics::Point& position, const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the disabled bitmap of the button. + * + * @since 2.0 + * + * @param[in] position The location of disabled bitmap + * @param[in] bitmap The disabled bitmap of the button + */ + void SetDisabledBitmap(const Tizen::Graphics::Point& position, const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the normal background bitmap of the button. + * + * @since 2.0 + * + * @param[in] bitmap The normal background image + */ + void SetNormalBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the pressed background bitmap of the button. + * + * @since 2.0 + * + * @param[in] bitmap The pressed background bitmap + */ + void SetPressedBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the highlighted background bitmap of the button. + * + * @since 2.0 + * + * @param[in] bitmap The highlighted background bitmap + * @remarks When a user navigates the user interface using the directional keys, the focused UI control is highlighted. + */ + void SetHighlightedBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * Gets the color of the button for the specified status. + * + * @since 2.0 + * + * @return The color, @n + * else RGBA(0, 0, 0, 0) if an error occurs + * @param[in] status The status + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetColor(ButtonStatus status) const; + + /** + * Sets the color of the button for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status + * @param[in] color The button color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetColor(ButtonStatus status, const Tizen::Graphics::Color& color); + + /** + * Gets the text size. + * + * @since 2.0 + * + * @return The size of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextSize() + */ + int GetTextSize(void) const; + + /** + * Sets the text size. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The text size + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c size must be greater than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextSize() + */ + result SetTextSize(int size); + +protected: + friend class _ButtonImpl; + +private: + // + // This is the copy constructor for this class. + // + Button(const Button& rhs); + + // + // Assigns the value of the specified instance to the current instance of %Button. + // + Button& operator =(const Button& rhs); + +}; // Button + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_BUTTON_H_ diff --git a/inc/FUiCtrlButtonItem.h b/inc/FUiCtrlButtonItem.h new file mode 100644 index 0000000..766c2f5 --- /dev/null +++ b/inc/FUiCtrlButtonItem.h @@ -0,0 +1,224 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlButtonItem.h + * @brief This is the header file for the %ButtonItem class. + * + * This header file contains the declarations of the %ButtonItem class. + */ +#ifndef _FUI_CTRL_BUTTON_ITEM_H_ +#define _FUI_CTRL_BUTTON_ITEM_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @enum ButtonItemStatus + * + * Defines the possible states of the button item. + * + * @since 2.0 + */ +enum ButtonItemStatus +{ + BUTTON_ITEM_STATUS_NORMAL, /**< The normal status */ + BUTTON_ITEM_STATUS_PRESSED, /**< The selected status */ + BUTTON_ITEM_STATUS_HIGHLIGHTED, /**< The highlighted status */ + BUTTON_ITEM_STATUS_DISABLED /**< The disabled status */ +}; + +/** + * @enum ButtonPosition + * + * Defines the possible positions of the button item. + * + * @since 2.0 + */ +enum ButtonPosition +{ + BUTTON_POSITION_LEFT = 0, /**< The position of the button is towards the left of the object */ + BUTTON_POSITION_RIGHT /**< The position of the button is towards the right of the object */ +}; + +/** + * @enum ButtonItemStyle + * + * Defines the possible styles of the button item. + * + * @since 2.0 + */ +enum ButtonItemStyle +{ + BUTTON_ITEM_STYLE_TEXT = 0, /**< The text %ButtonItem style */ + BUTTON_ITEM_STYLE_ICON /**< The icon %ButtonItem style */ +}; + +/** + * @class ButtonItem + * @brief This class is an implementation of %ButtonItem. + * + * @since 2.0 + * + * The %ButtonItem class is a helper class that specifies the + * properties of button items in a Footer or Header. + */ +class _OSP_EXPORT_ ButtonItem + : public Tizen::Base::Object +{ + +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + ButtonItem(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~ButtonItem(void); + + + /** + * Initializes this instance of %ButtonItem with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] style The style of the button item + * @param[in] actionId The action ID of the button item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c actionId of the specified item must be a positive integer. + */ + result Construct(ButtonItemStyle style, int actionId); + + + /** + * Gets the action ID of the button item. + * + * @since 2.0 + * + * @return The action ID, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetActionId(void) const; + + + /** + * Gets the text of the button item. + * + * @since 2.0 + * + * @return The item text, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::String GetText(void) const; + + + /** + * Sets the action ID of the button item. + * + * @since 2.0 + * + * @return An error code + * @param[in] actionId The action ID of the button item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c actionId of the specified item must be a positive integer. + */ + result SetActionId(int actionId); + + + /** + * Sets the background bitmap image of the button item. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The item status + * @param[in] pBitmap The background bitmap image to be set, @n + * else @c null if no bitmap image is displayed + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @remarks If the size is greater than the default size, the bitmap image is scaled accordingly. + */ + result SetBackgroundBitmap(ButtonItemStatus status, const Tizen::Graphics::Bitmap* pBitmap); + + + /** + * Sets the icon of the button item for the specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The item status + * @param[in] pIcon The icon to be set, @n + * else @c null if no icon is displayed + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @remarks If the style of %ButtonItem is BUTTON_ITEM_STYLE_TEXT, the method returns E_INVALID_OPERATION. @n + * If an icon is not set for a state, the icon for BUTTON_ITEM_STATUS_NORMAL is used. + */ + result SetIcon(ButtonItemStatus status, const Tizen::Graphics::Bitmap* pIcon); + + + /** + * Sets the text of %ButtonItem. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The style of %ButtonItem is BUTTON_ITEM_STYLE_ICON. + * @remarks If the text cannot be displayed in a line, then the text is automatically displayed in two lines and the ellipsis is applied if the text + * is longer than two lines. @n + * Use @htmlonly '\n' @endhtmlonly to denote the end of the first line. + */ + result SetText(const Tizen::Base::String& text); + + +private: + ButtonItem(const ButtonItem& rhs); + ButtonItem& operator =(const ButtonItem& rhs); + +private: + friend class _FooterImpl; + friend class _HeaderImpl; + friend class _ButtonItemImpl; + + class _ButtonItemImpl* __pImpl; +}; + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_BUTTON_ITEM_H_ diff --git a/inc/FUiCtrlCheckButton.h b/inc/FUiCtrlCheckButton.h new file mode 100644 index 0000000..66501a7 --- /dev/null +++ b/inc/FUiCtrlCheckButton.h @@ -0,0 +1,599 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlCheckButton.h + * @brief This is the header file for the %CheckButton class. + * + * This header file contains the declarations of the %CheckButton class and its helper classes. + */ + +#ifndef _FUI_CTRL_CHECK_BUTTON_H_ +#define _FUI_CTRL_CHECK_BUTTON_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @enum CheckButtonStatus + * + * Defines the %CheckButton status. + * + * @since 2.0 + */ +enum CheckButtonStatus +{ + CHECK_BUTTON_STATUS_NORMAL, /**< The normal status */ + CHECK_BUTTON_STATUS_DISABLED, /**< The disabled status */ + CHECK_BUTTON_STATUS_PRESSED, /**< The pressed status */ + CHECK_BUTTON_STATUS_HIGHLIGHTED /**< The highlighted status */ +}; + +/** + * @enum CheckButtonStyle + * + * Defines the %CheckButton style. + * + * @since 2.0 + */ +enum CheckButtonStyle +{ + CHECK_BUTTON_STYLE_MARK, /**< The mark style for multiple selection */ + CHECK_BUTTON_STYLE_MARK_WITH_DIVIDER, /**< @if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the divider style is no longer recommended @n + Instead of using the divider style, use the detailed button style. @endif */ + CHECK_BUTTON_STYLE_ONOFF, /**< @if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the on-off style is no longer recommended @n + Instead of using the on-off style, use the on-off sliding style @endif */ + CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER, /**< @if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the on-off style is no longer recommended @endif */ + CHECK_BUTTON_STYLE_RADIO, /**< The radio style for single selection */ + CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER, /**< @if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the divider style is no longer recommended @n + Instead of using the divider style, use the detailed button style @endif */ + CHECK_BUTTON_STYLE_ONOFF_SLIDING, /**< The slider style on/off */ + CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON, /**< The mark style with detail button */ + CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON, /**< The radio style with detail button */ +}; + +/** + * @class CheckButton + * @brief This class defines the common behavior of a %CheckButton control. + * + * @since 2.0 + * + * The %CheckButton class displays a rectangular area, which can be selected, and shows the current selection. + * + * For more information on the class features, see Buttons. + * + * The following example demonstrates how to use the %CheckButton class. + * + * + * @code +// Sample code for CheckButtonSample.h +#include + +class CheckButtonSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener +{ +public: + CheckButtonSample(void) + : __pCheckButton(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + // IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +private : + static const int ID_BUTTON_CHECKED = 101; + static const int ID_BUTTON_UNCHECKED = 102; + static const int ID_BUTTON_SELECTED = 103; + + Tizen::Ui::Controls::CheckButton* __pCheckButton; +}; + + * @endcode + * + * @code +// Sample Code for CheckButtonSample.cpp +#include + +#include "CheckButtonSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +CheckButtonSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +CheckButtonSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates a CheckButton + __pCheckButton = new CheckButton(); + __pCheckButton->Construct(Rectangle(50, 50, 400, 100), + CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER, BACKGROUND_STYLE_DEFAULT, false, L"CheckButton"); + __pCheckButton->SetActionId(ID_BUTTON_CHECKED, ID_BUTTON_UNCHECKED, ID_BUTTON_SELECTED); + __pCheckButton->AddActionEventListener(*this); + + // Add a CheckButton to the Form + AddControl(*__pCheckButton); + + return r; +} + +// Implements an IActionEventListener +void +CheckButtonSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_BUTTON_CHECKED: + // Todo: + break; + case ID_BUTTON_UNCHECKED: + // Todo: + break; + case ID_BUTTON_SELECTED: + // Todo: + break; + default: + break; + } +} + + * @endcode + * + */ +class _OSP_EXPORT_ CheckButton + : public Tizen::Ui::Control +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + CheckButton(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~CheckButton(void); + + /** + * Initializes this instance of %CheckButton with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created window + * along with the width and height of the window. + * @param[in] style The style of the %CheckButton control + * @param[in] backgroundStyle The background style set of the %CheckButton control + * @param[in] showTitle Set to @c true to enable the title, @n + * else @c false + * @param[in] text The text of the %CheckButton control + * @param[in] groupStyle The group style of the %CheckButton control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid.@n + * The specified size is less than the minimum size of the control. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The background style of BACKGROUND_STYLE_NONE does not work with group styles except GROUP_STYLE_NONE. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully usable only after it has been added to a container, therefore some methods may fail if used earlier. @n + */ + result Construct(const Tizen::Graphics::Rectangle& rect, CheckButtonStyle style, BackgroundStyle backgroundStyle = + BACKGROUND_STYLE_DEFAULT, bool showTitle = false, const Tizen::Base::String& text = L"", GroupStyle groupStyle = GROUP_STYLE_NONE); + + /** + * Sets the selected status of the %CheckButton control. + * + * @since 2.0 + * + * @param[in] select Set to @c true if the %CheckButton control is selected, @n + * else @c false + */ + void SetSelected(bool select); + + /** + * Checks whether the %CheckButton control has been selected. + * + * @since 2.0 + * + * @return @c true if the %CheckButton is selected, @n + * else @c false + */ + bool IsSelected(void) const; + +public: + /** + * Adds an IActionEventListener instance. @n + * The added listener can listen to events on the context of the given event dispatcher when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + */ + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * Removes an IActionEventListener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + */ + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * Sets the action IDs for the %CheckButton control. + * + * @since 2.0 + * + * @param[in] checkedActionId The action ID for the checked state + * @param[in] uncheckedActionId The action ID for the unchecked state + * @param[in] selectedActionId The action ID for the selected state + */ + void SetActionId(int checkedActionId, int uncheckedActionId, int selectedActionId = -1); + + /** + * Gets the action ID for the checked state. + * + * @since 2.0 + * + * @return An integer value representing the action ID + */ + int GetCheckedActionId(void) const; + + /** + * Gets the action ID for the unchecked state. + * + * @since 2.0 + * + * @return An integer value representing the action ID + */ + int GetUncheckedActionId(void) const; + + /** + * Gets the action ID for the selected state. + * + * @since 2.0 + * + * @return An integer value representing the action ID + */ + int GetSelectedActionId(void) const; + +public: + /** + * Sets the text that the %CheckButton control displays. + * + * @since 2.0 + * + * @param[in] text The text of the %CheckButton control + */ + void SetText(const Tizen::Base::String& text); + + /** + * Sets the horizontal alignment of the text of the %CheckButton control. + * + * @since 2.0 + * + * @param[in] alignment The horizontal text alignment + */ + void SetTextHorizontalAlignment(HorizontalAlignment alignment); + + /** + * Sets the vertical alignment of the text of the %CheckButton control. + * + * @since 2.0 + * + * @param[in] alignment The vertical text alignment + */ + void SetTextVerticalAlignment(VerticalAlignment alignment); + +public: + /** + * Gets the text of the %CheckButton control. + * + * @since 2.0 + * + * @return The text of the %CheckButton control + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets the horizontal alignment of the text of the %CheckButton control. + * + * @since 2.0 + * @return The horizontal text alignment + */ + HorizontalAlignment GetTextHorizontalAlignment(void) const; + + /** + * Gets the vertical alignment of the text of the %CheckButton control. + * + * @since 2.0 + * @return The vertical text alignment + */ + VerticalAlignment GetTextVerticalAlignment(void) const; + + /** + * Sets the title text of the %CheckButton control. + * + * @since 2.0 + * @return An error code + * @param[in] title The title text to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTitleText(const Tizen::Base::String& title); + + /** + * Gets the title text of the %CheckButton control. + * + * @since 2.0 + * @return The title text + */ + Tizen::Base::String GetTitleText(void) const; + + //Normal color + /** + * Sets the text color of the %CheckButton control. + * + * @since 2.0 + * + * @param[in] color The text color to be set + */ + void SetTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the text color of the %CheckButton control. + * + * @since 2.0 + * + * @return The text color + */ + Tizen::Graphics::Color GetTextColor(void) const; + + //Normal color + /** + * Sets the title text color of the %CheckButton control. + * + * @since 2.0 + * + * @param[in] color The text color to be set + */ + void SetTitleTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the title text color of the %CheckButton control. + * + * @since 2.0 + * + * @return The text color + */ + Tizen::Graphics::Color GetTitleTextColor(void) const; + + /** + * Sets the color of the %CheckButton control for the specified status. + * + * @since 2.0 + * @return An error code + * @param[in] color The color to be set + * @param[in] status The status + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * The operation is not supported if the background style is BACKGROUND_STYLE_NONE. + * @exception E_SYSTEM A system error has occurred. + */ + result SetColor(CheckButtonStatus status, const Tizen::Graphics::Color& color); + + /** + * Gets the color of the %CheckButton control for the specified status. + * + * @since 2.0 + * @return The color, @n + * else RGBA (0, 0, 0, 0) if an error occurs + * @param[in] status The status + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The background style is not proper. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetColor(CheckButtonStatus status) const; + + /** + * Sets the text color of the %CheckButton control for the pressed status. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The text color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetPressedTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the text color of the %CheckButton control for the pressed status. + * + * @since 2.0 + * @return The text color, @n + * else RGBA (0, 0, 0, 0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetPressedTextColor(void) const; + + /** + * Sets the title text color of the %CheckButton control for the pressed status. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The pressed title text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetPressedTitleTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the title text color of the %CheckButton for the pressed status. + * + * @since 2.0 + * + * @return The title text color, @n + * else RGBA (0, 0, 0, 0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetPressedTitleTextColor(void) const; + + /** + * Sets the text color of the %CheckButton control for the highlighted status. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The text color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetHighlightedTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the text color of the %CheckButton control for the highlighted status. + * + * @since 2.0 + * + * @return The text color, @n + * else RGBA (0, 0, 0, 0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetHighlightedTextColor(void) const; + + /** + * Sets the title text color of the %CheckButton control for the highlighted status. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The highlighted title text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetHighlightedTitleTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the title text color of the %CheckButton control for the highlighted status. + * + * @since 2.0 + * + * @return The title text color, @n + * else RGBA (0, 0, 0, 0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetHighlightedTitleTextColor(void) const; + + /** + * Sets the text color of the %CheckButton control for the disabled status. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The text color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetDisabledTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the text color of the %CheckButton control for the disabled status. + * + * @since 2.0 + * + * @return The text color, @n + * else RGBA (0, 0, 0, 0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetDisabledTextColor(void) const; + + /** + * Sets the title text color of the %CheckButton control for the disabled status. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The disabled title text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetDisabledTitleTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the title text color of %CheckButton for the disabled status. + * + * @since 2.0 + * + * @return The title text color, @n + * else RGBA (0, 0, 0, 0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetDisabledTitleTextColor(void) const; + +protected: + friend class _CheckButtonImpl; + +private: + friend class RadioGroup; + + // + // This is the copy constructor for this class. + // + CheckButton(const CheckButton& rhs); + + // + // Assigns the value of the specified instance to the current instance of %CheckButton. + // + CheckButton& operator =(const CheckButton& rhs); + +}; // CheckButton + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_CHECK_BUTTON_H_ diff --git a/inc/FUiCtrlColorPicker.h b/inc/FUiCtrlColorPicker.h new file mode 100644 index 0000000..28cc03b --- /dev/null +++ b/inc/FUiCtrlColorPicker.h @@ -0,0 +1,261 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlColorPicker.h + * @brief This is the header file for the %ColorPicker class. + * + * This header file contains the declarations of the %ColorPicker class. + */ +#ifndef _FUI_CTRL_COLOR_PICKER_H_ +#define _FUI_CTRL_COLOR_PICKER_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class ColorPicker + * @brief This class defines the common behavior of a %ColorPicker control. + * + * @since 2.0 + * + * The %ColorPicker class displays a set of 3 sliders (hue, saturation, and luminance) with which the user can define a color. + * + * For more information on the class features, see ColorPicker. + * + * The following example demonstrates how to use the %ColorPicker class. + * + * @code +// Sample code for ColorPickerSample.h +#include +#include + +class ColorPickerSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IColorChangeEventListener +{ +public: + ColorPickerSample(void) + : __pColorPicker(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + // IColorChangeEventListener + virtual void OnColorChanged(const Tizen::Ui::Control& source, const Tizen::Graphics::Color& color); + +private: + Tizen::Ui::Controls::ColorPicker* __pColorPicker; +}; + + * @endcode + * + * @code + +// Sample code for ColorPickerSample.cpp +#include "ColorPickerSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +ColorPickerSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +ColorPickerSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of ColorPicker + __pColorPicker = new ColorPicker(); + __pColorPicker->Construct(Point(10,50)); + __pColorPicker->AddColorChangeEventListener(*this); + + // Adds the color picker to the form + AddControl(*__pColorPicker); + + return r; +} + +// IColorChangeEventListener implementation +void +ColorPickerSample::OnColorChanged(const Control& source, const Color& color) +{ + // .... +} + * @endcode + */ + +class _OSP_EXPORT_ ColorPicker + : public Tizen::Ui::Control +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + ColorPicker(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ColorPicker(void); + + /** + * Initializes this instance of %ColorPicker with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The position of this %ColorPicker in the container + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully usable only after it has been added to a container. Therefore, some methods may fail if the control is used earlier. + */ + result Construct(const Tizen::Graphics::Point& point); + + /** + * Gets the current color value of %ColorPicker. + * + * @since 2.0 + * + * @return The current color value + */ + Tizen::Graphics::Color GetColor(void) const; + + /** + * Gets the current hue value of %ColorPicker. + * + * @since 2.0 + * + * @return The current hue value + * @remarks The return value is between @c 0 to @c 100. + */ + int GetHue(void) const; + + /** + * Gets the current saturation value of %ColorPicker. + * + * @since 2.0 + * + * @return The current saturation value + * @remarks The return value is between @c 0 to @c 100. + */ + int GetSaturation(void) const; + + /** + * Gets the current luminance value of %ColorPicker. + * + * @since 2.0 + * + * @return The current luminance value + * @remarks The return value is between @c 0 to @c 100. + */ + int GetLuminance(void) const; + + /** + * Sets the color value of %ColorPicker. + * + * @since 2.0 + * + * @param[in] color The color value + */ + void SetColor(const Tizen::Graphics::Color& color); + + /** + * Sets the hue value of %ColorPicker. + * + * @since 2.0 + * + * @param[in] hue The hue value of this object + * @remarks The value should be between @c 0 to @c 100. + * + */ + void SetHue(int hue); + + /** + * Sets the saturation value of %ColorPicker. + * + * @since 2.0 + * + * @param[in] saturation The saturation value of this object + * @remarks The value should be between @c 0 to @c 100. + * + */ + void SetSaturation(int saturation); + + /** + * Sets the luminance value of %ColorPicker. + * + * @since 2.0 + * + * @param[in] luminance The luminance value of this object + * @remarks The value should be between @c 0 to @c 100. + * + */ + void SetLuminance(int luminance); + + /** + * Adds a listener instance. + * The added listener can listen to events on the given event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @see RemoveColorChangeEventListener() + */ + void AddColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener); + + /** + * Removes a listener instance. + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddColorChangeEventListener() + */ + void RemoveColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + ColorPicker(const ColorPicker& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + ColorPicker& operator =(const ColorPicker& rhs); + + friend class _ColorPickerImpl; +}; // ColorPicker + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_COLOR_PICKER_H_ diff --git a/inc/FUiCtrlContextMenu.h b/inc/FUiCtrlContextMenu.h new file mode 100644 index 0000000..9296d01 --- /dev/null +++ b/inc/FUiCtrlContextMenu.h @@ -0,0 +1,733 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlContextMenu.h + * @brief This is the header file for the %ContextMenu class. + * + * This header file contains the declarations of the %ContextMenu class and its helper classes. + */ + +#ifndef _FUI_CTRL_CONTEXT_MENU_H_ +#define _FUI_CTRL_CONTEXT_MENU_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Graphics +{ +class Bitmap; +}; +}; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum ContextMenuStyle + * + * Defines the %ContextMenu style. + * + * @since 2.0 + */ +enum ContextMenuStyle +{ + CONTEXT_MENU_STYLE_LIST,/**< The style of the vertical list of image + text */ + CONTEXT_MENU_STYLE_GRID,/**< The style of the grid of buttons */ + CONTEXT_MENU_STYLE_ICON /**<@if OSPDEPREC @deprecated This enumeration field is deprecated because this style can be implemented using the CONTEXT_MENU_STYLE_GRID style @endif */ +} ; + +/** + * @enum ContextMenuItemStatus + * + * Defines the possible states of the %ContextMenu control item. + * + * @since 2.0 + */ +enum ContextMenuItemStatus +{ + CONTEXT_MENU_ITEM_STATUS_NORMAL, /**< The normal state */ + CONTEXT_MENU_ITEM_STATUS_PRESSED, /**< The pressed state */ + CONTEXT_MENU_ITEM_STATUS_HIGHLIGHTED /**< The highlighted state */ +}; + +/** + * @enum ContextMenuAnchorDirection + * + * Defines the direction of the %ContextMenu control. + * + * @since 2.0 + */ +enum ContextMenuAnchorDirection +{ + CONTEXT_MENU_ANCHOR_DIRECTION_LEFTWARD, /**< The anchor arrow direction is leftward */ + CONTEXT_MENU_ANCHOR_DIRECTION_RIGHTWARD,/**< The anchor arrow direction is rightward */ + CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD, /**< The anchor arrow direction is upward */ + CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD, /**< The anchor arrow direction is downward */ + CONTEXT_MENU_ANCHOR_DIRECTION_AUTO /**< The anchor arrow direction is auto */ +}; + +/** + * @class ContextMenu + * @brief This class defines the common behavior of a %ContextMenu control. + * + * @since 2.0 + * + * The %ContextMenu class displays a special purpose window that is used to present users with context-sensitive options. + * + * For more information on the class features, see ContextMenu. + * + * The following example demonstrates how to use the %ContextMenu class. + + * + * @code +// Sample code for ContextMenuSample.h +#include +class ContextMenuSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener +{ +public: + ContextMenuSample(void) + :__pContextMenu(null){} + + bool Initialize(void); + void ShowContextMenu(bool show); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +private: + static const int ID_CONTEXTMENU_ITEM1 = 101; + static const int ID_CONTEXTMENU_ITEM2 = 102; + static const int ID_BTN_SHOW_CONTEXTMENU = 103; + + Tizen::Ui::Controls::ContextMenu *__pContextMenu; +}; + + * @endcode + * + * @code + +// Sample code for ContextMenuSample.cpp +#include + +#include "ContextMenuSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +ContextMenuSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +ContextMenuSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of ContextMenu + __pContextMenu = new ContextMenu(); + __pContextMenu->Construct(Point(400, 150), CONTEXT_MENU_STYLE_LIST); + + __pContextMenu->AddItem(L"Item1", ID_CONTEXTMENU_ITEM1); + __pContextMenu->AddItem(L"Item2", ID_CONTEXTMENU_ITEM2); + __pContextMenu->AddActionEventListener(*this); + + // Creates an instance of Button to show the context menu + Button* pButton = new Button(); + pButton->Construct(Rectangle(50, 50, 400, 100), L"Show ContextMenu"); + pButton->SetActionId(ID_BTN_SHOW_CONTEXTMENU); + pButton->AddActionEventListener(*this); + + // Adds the button to the form + AddControl(*pButton); + + return r; +} + +// Sets the anchor position of the context menu +void +ContextMenuSample::ShowContextMenu(bool show) +{ + __pContextMenu->SetPosition(Point(300, 200)); + + // Change to desired show state + __pContextMenu->SetShowState(show); + + //Calls Show() of the control + if (show) + { + __pContextMenu->Show(); + } + else + { + Invalidate(true); + } +} + +result +ContextMenuSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the __pContextMenu + delete __pContextMenu; + + return r; +} + +// IActionEventListener implementation +void +ContextMenuSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_CONTEXTMENU_ITEM1: + { + // .... + } + break; + case ID_CONTEXTMENU_ITEM2: + { + // .... + } + break; + case ID_BTN_SHOW_CONTEXTMENU: + { + ShowContextMenu(true); + } + break; + default: + break; + } +} + * @endcode + * + */ +class _OSP_EXPORT_ ContextMenu + : public Tizen::Ui::Window +{ +public: +// Lifecycle + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + * + */ + ContextMenu(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + * + */ + virtual ~ContextMenu(void); + + /** + * Initializes this instance of %ContextMenu with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The x and y coordinates of the anchor of %ContextMenu + * @param[in] style The context menu style + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance has already been constructed. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Graphics::Point& point, ContextMenuStyle style); + + /** + * Initializes this instance of %ContextMenu with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The x and y coordinates of the anchor of the %ContextMenu control + * @param[in] style The context menu style + * @param[in] direction The anchor arrow direction + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance has already been constructed. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Graphics::Point& point, ContextMenuStyle style, ContextMenuAnchorDirection direction); + + /** + * Adds a listener instance. + * The added listener can listen to events on the given context of the event dispatcher when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + */ + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * Removes the specified listener instance. + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + */ + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + +// Operation + /** + * Appends the specified item at the end of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] normalBitmap The normal bitmap of the item + * @param[in] pPressedBitmap The pressed bitmap of the item + * @param[in] actionId The action ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the context menu is CONTEXT_MENU_STYLE_GRID. + */ + result AddItem(const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, int actionId); + + /** + * Appends the specified item at the end of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] normalBitmap The normal bitmap of the item + * @param[in] pPressedBitmap The pressed bitmap of the item + * @param[in] pHighlightedBitmap The highlighted bitmap of the item + * @param[in] actionId The action ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the context menu is CONTEXT_MENU_STYLE_GRID. @n + * When a user navigates the user interface using the directional keys, the selected UI control is highlighted and the control takes the + * focus. + */ + result AddItem(const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId); + + /** + * Appends the specified item at the end of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The string of the item to be appended + * @param[in] actionId The specified action ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_SYSTEM A system error has occurred. + */ + result AddItem(const Tizen::Base::String& text, int actionId); + + /** + * Appends the specified item at the end of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The string of the item to be appended + * @param[in] actionId The specified action ID for this item + * @param[in] normalBitmap The normal bitmap of the item + * @param[in] pPressedBitmap The pressed bitmap of the item + * @param[in] pHighlightedBitmap The highlighted bitmap of the item + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The total number of items has exceeded the maximum limit. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the context menu is CONTEXT_MENU_STYLE_LIST. + */ + result AddItem(const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap = null, const Tizen::Graphics::Bitmap* pHighlightedBitmap = null); + + /** + * Inserts the specified item at the given index of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The location + * @param[in] normalBitmap The normal bitmap of the item + * @param[in] pPressedBitmap The pressed bitmap of the item + * @param[in] actionId The specified action ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than the number of items in %ContextMenu. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the context menu is CONTEXT_MENU_STYLE_GRID. @n + * The %ContextMenu control can have a maximum of 3 icons. + */ + result InsertItemAt(int index, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, int actionId); + + /** + * Inserts the specified item at the given index of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The location + * @param[in] normalBitmap The normal bitmap of the item + * @param[in] pPressedBitmap The pressed bitmap of the item + * @param[in] pHighlightedBitmap The highlighted bitmap of the item + * @param[in] actionId The specified action ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than the number of items in %ContextMenu. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the context menu is CONTEXT_MENU_STYLE_GRID. @n + * @remarks When a user navigates the user interface using the directional keys, the selected UI control is highlighted and the control takes the focus. + */ + result InsertItemAt(int index, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId); + + /** + * Inserts the specified item at the given index of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The location + * @param[in] text The string of the item to set + * @param[in] actionId The specified action ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than the number of items in %ContextMenu. + * @exception E_SYSTEM A system error has occurred. + */ + result InsertItemAt(int index, const Tizen::Base::String& text, int actionId); + + /** + * Inserts the specified item at the given index of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The location + * @param[in] text The string of the item to set + * @param[in] actionId The specified action ID for this item + * @param[in] normalBitmap The normal bitmap of the item + * @param[in] pPressedBitmap The pressed bitmap of the item + * @param[in] pHighlightedBitmap The highlighted bitmap of the item + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than the number of items in %ContextMenu. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the context menu is CONTEXT_MENU_STYLE_LIST. + */ + result InsertItemAt(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap = null, const Tizen::Graphics::Bitmap* pHighlightedBitmap = null); + + /** + * Sets the specified item at the given index of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The location + * @param[in] normalBitmap The normal bitmap of the item + * @param[in] pPressedBitmap The pressed bitmap of the item + * @param[in] actionId The action ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than the number of items in %ContextMenu. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the context menu is CONTEXT_MENU_STYLE_GRID. + */ + result SetItemAt(int index, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, int actionId); + + /** + * Sets the specified item at the given index of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The location + * @param[in] normalBitmap The normal bitmap of the item + * @param[in] pPressedBitmap The pressed bitmap of the item + * @param[in] pHighlightedBitmap The highlighted bitmap of the item + * @param[in] actionId The action ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than the number of items in %ContextMenu. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the context menu is CONTEXT_MENU_STYLE_GRID. @n + * @remarks When a user navigates the user interface using the directional keys, @n + * the selected UI control is highlighted and the control takes the focus. + */ + result SetItemAt(int index, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId); + + /** + * Sets the specified item at the given index of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The location + * @param[in] text The string of the item to set + * @param[in] actionId The action ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index less than @c 0 or greater than the number of items in %ContextMenu. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemAt(int index, const Tizen::Base::String& text, int actionId); + + /** + * Sets the specified item at the given index of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The location + * @param[in] text The string of the item to set + * @param[in] actionId The action ID for this item + * @param[in] normalBitmap The normal bitmap of the item + * @param[in] pPressedBitmap The pressed bitmap of the item + * @param[in] pHighlightedBitmap The highlighted bitmap of the item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index less than @c 0 or greater than the number of items in %ContextMenu. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the context menu is CONTEXT_MENU_STYLE_LIST. + */ + result SetItemAt(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap = null, const Tizen::Graphics::Bitmap* pHighlightedBitmap = null); + + /** + * Removes the item at the specified index from the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The location + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveItemAt(int index); + + /** + * Removes all items from the %ContextMenu control. + * + * @since 2.0 + * + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveAllItems(void); + + /** + * Gets the number of items of the %ContextMenu control. + * + * @since 2.0 + * + * @return The number of items registered for %ContextMenu, @n + * else @c -1 if an error occurs + */ + int GetItemCount(void) const; + + /** + * Gets the index of the item with the specified action ID. + * + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if an error occurs + * @param[in] actionId The action ID + */ + int GetItemIndexFromActionId(int actionId) const; + + /** + * Gets the action ID of the item at the specified index. + * + * @since 2.0 + * + * @return The action ID of the item, @n + * else @c -1 if the specified index is invalid + * @param[in] index The index of the item + */ + int GetItemActionIdAt(int index) const; + + /** + * Gets the item text color of the %ContextMenu control for the specified status. + * + * @since 2.0 + * + * @return The item text color, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The item status + */ + Tizen::Graphics::Color GetItemTextColor(ContextMenuItemStatus status) const; + + /** + * Sets the item text color of the %ContextMenu control for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The item status + * @param[in] color The item text color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemTextColor(ContextMenuItemStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the position of the anchor. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The new position + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @remarks The x and y coordinates of the anchor are defined in the coordinate space of its parent, + * which means that @c x and @c y must be defined relative to the top-left corner (0,0) of its parent. + */ + result SetAnchorPosition(const Tizen::Graphics::Point& position); + + /** + * Gets the position of the anchor. + * + * @since 2.0 + * + * @return The position of the anchor + * @remarks The coordinate of the anchor position is defined from the top-left corner of its parent Container. + */ + Tizen::Graphics::Point GetAnchorPosition(void) const; + + /** + * Gets the color of the %ContextMenu control. + * + * @since 2.0 + * + * @return The color of %ContextMenu control, @n + * else RGBA(0, 0, 0, 0) if an error occurs + * @see SetColor() + */ + Tizen::Graphics::Color GetColor(void) const; + + /** + * Sets the color of the %ContextMenu control. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + * @see GetColor() + */ + result SetColor(const Tizen::Graphics::Color& color); + + /** + * Gets the item color for the specified status. + * + * @since 2.0 + * + * @return The color of %ContextMenu control, @n + * else RGBA(0, 0, 0, 0) if an error occurs + * @param[in] status The menu item status + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The item color for CONTEXT_MENU_ITEM_STATUS_NORMAL is not supported. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * The item color for the CONTEXT_MENU_ITEM_STATUS_NORMAL status is always the same as the color of the %ContextMenu control. + * @see SetItemColor() + */ + Tizen::Graphics::Color GetItemColor(ContextMenuItemStatus status) const; + + /** + * Sets the item color for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The menu item status + * @param[in] color The color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The item color for CONTEXT_MENU_ITEM_STATUS_NORMAL is not supported. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + * @remarks The item color for the CONTEXT_MENU_ITEM_STATUS_NORMAL status is always the same as the color of the %ContextMenu control. + * @see GetItemColor() + */ + result SetItemColor(ContextMenuItemStatus status, const Tizen::Graphics::Color& color); + + /** + * Gets maximum number of visible items. + * + * @since 2.0 + * + * @return The maximum number of visible items, @n + * else @c -1 if an error occurs + * @see SetMaxVisibleItemsCount() + */ + int GetMaxVisibleItemsCount(void) const; + + /** + * Sets maximum number of visible items. + * + * @since 2.0 + * + * @return An error code + * @param[in] maxItemsCount The maximum number of the visible menu items + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c parameter is out of possible range. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + * @remarks @c maxItemsCount should be greater than @c 0 and less than @c 8. The default value for + * the maximum number of the visible menu items is @c 4. + * @see GetMaxVisibleItemsCount() + */ + result SetMaxVisibleItemsCount(int maxItemsCount); + +protected: + friend class _ContextMenuImpl; +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + // + ContextMenu(const ContextMenu& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + // + ContextMenu& operator =(const ContextMenu& rhs); +}; // ContextMenu + +}}} // Tizen::Ui: Control + +#endif // _FUI_CTRL_CONTEXT_MENU_H_ diff --git a/inc/FUiCtrlControlsTypes.h b/inc/FUiCtrlControlsTypes.h new file mode 100644 index 0000000..34cc315 --- /dev/null +++ b/inc/FUiCtrlControlsTypes.h @@ -0,0 +1,100 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlControlsTypes.h + * @brief This is the header file for the enumerations. + * + * This header file contains the declarations of the enumerations. + */ +#ifndef _FUI_CTRL_CONTROLS_TYPES_H_ +#define _FUI_CTRL_CONTROLS_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum MarginType + * + * Defines different margin types for a control. + * + * @since 2.0 + */ +enum MarginType +{ + MARGIN_TYPE_LEFT, /**< The left side of the margin */ + MARGIN_TYPE_RIGHT, /**< The right side of the margin */ + MARGIN_TYPE_TOP, /**< The top side of the margin */ + MARGIN_TYPE_BOTTOM /**< The bottom side of the margin */ +}; + +/** + * @enum BackgroundStyle + * + * Defines the background style. + * + * @since 2.0 + */ +enum BackgroundStyle +{ + BACKGROUND_STYLE_NONE = 0, /**< The image with no background */ + BACKGROUND_STYLE_DEFAULT, /**< The default background image */ +}; + +/** + * @enum IconPosition + * + * Defines position of the text. + * + * @since 2.0 + */ +enum IconPosition +{ + ICON_POSITION_LEFT, /**< The position of the icon is to the left of the object */ + ICON_POSITION_RIGHT /**< The position of the icon is to the right of the object */ +}; + +/** + * @enum HorizontalAlignment + * + * Defines horizontal alignment of the text. + * + * @since 2.0 + */ +enum HorizontalAlignment +{ + ALIGNMENT_LEFT, /**< The text is left-aligned */ + ALIGNMENT_CENTER, /**< The text is center-aligned horizontally */ + ALIGNMENT_RIGHT /**< The text is right-aligned */ +}; + +/** + * @enum VerticalAlignment + * + * Defines vertical alignment of the text. + * + * @since 2.0 + */ +enum VerticalAlignment +{ + ALIGNMENT_TOP, /**< The text is top-aligned */ + ALIGNMENT_MIDDLE, /**< The text is center-aligned vertically */ + ALIGNMENT_BOTTOM /**< The text is bottom-aligned */ +}; + +}}}// Tizen::Ui::Controls + +#endif //_FUI_CTRL_CONTROLS_TYPES_H_ diff --git a/inc/FUiCtrlCustomItem.h b/inc/FUiCtrlCustomItem.h new file mode 100644 index 0000000..06d763f --- /dev/null +++ b/inc/FUiCtrlCustomItem.h @@ -0,0 +1,279 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlCustomItem.h + * @brief This is the header file for the %CustomItem class. + * + * This header file contains the declarations of the %CustomItem class and its helper classes. + */ + +#ifndef _FUI_CTRL_CUSTOM_ITEM_H_ +#define _FUI_CTRL_CUSTOM_ITEM_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _CustomItemImpl; + +/** + * @class CustomItem + * @brief This class defines the common behavior for %CustomItem. + * + * @since 2.0 + * + * The %CustomItem class displays a list item, which is the unit of handling a ListView or GroupedListView. It provides customized formatting of specific list items. + * + * For more information on the class features, see ListViews. + * + */ + +class _OSP_EXPORT_ CustomItem + : public ListItemBase +{ +public: + /** + * The object is not fully constructed after this constructor is + * called. For full construction, the Construct() method must be + * called right after calling this constructor. + * + * @since 2.0 + */ + CustomItem(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~CustomItem(void); + + /** + * Initializes this instance of %CustomItem with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemSize The size of the item + * @param[in] style The style of the annex + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Graphics::Dimension& itemSize, ListAnnexStyle style); + + /** + * Adds an instance of EnrichedText as an element to the %CustomItem control. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The bounds of the element + * @param[in] elementId The element ID + * @param[in] text The instance of EnrichedText + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result AddElement(const Tizen::Graphics::Rectangle& rect, int elementId, const Tizen::Graphics::EnrichedText& text); + + /** + * Adds the text as an element to the %CustomItem control. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The bounds of the element + * @param[in] elementId The element ID + * @param[in] text The text string to add + * @param[in] textSliding Set to @c true to allow a long text to slide, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If the width of the specified @c text exceeds the width of the element and @c textSliding is set to @c true, the text slides + * automatically when the user long-presses. + */ + result AddElement(const Tizen::Graphics::Rectangle& rect, int elementId, const Tizen::Base::String& text, bool textSliding = true); + + /** + * Adds the text as an element to the %CustomItem control. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The bounds of the element + * @param[in] elementId The element ID + * @param[in] text The text string to add + * @param[in] textSize The size of the text + * @param[in] normalTextColor The color of the text in the normal status + * @param[in] pressedTextColor The color of the text in the pressed status + * @param[in] highlightedTextColor The color of the text in the highlighted status + * @param[in] textSliding Set to @c true to allow a long text to slide, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The default size of text is 38 on a WVGA screen, 22 on a HVGA screen and 20 on a WQVGA screen. + */ + result AddElement(const Tizen::Graphics::Rectangle& rect, int elementId, const Tizen::Base::String& text, int textSize, const Tizen::Graphics::Color& normalTextColor, const Tizen::Graphics::Color& pressedTextColor, const Tizen::Graphics::Color& highlightedTextColor, bool textSliding = true); + + /** + * Adds the bitmap image as an element to the %CustomItem control. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The bounds of the element + * @param[in] elementId The element ID + * @param[in] normalBitmap The bitmap image displayed when the item is in normal status + * @param[in] pPressedBitmap The bitmap image displayed when the item is pressed + * @param[in] pHighlightedBitmap The bitmap image displayed when the item is highlighted + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result AddElement(const Tizen::Graphics::Rectangle& rect, int elementId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap = NULL, const Tizen::Graphics::Bitmap* pHighlightedBitmap = NULL); + + /** + * Adds the custom drawing element to the %CustomItem control. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The bounds of the element + * @param[in] elementId The element ID + * @param[in] element The custom element + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result AddElement(const Tizen::Graphics::Rectangle& rect, int elementId, const ICustomElement& element); + + /** + * Removes the element from the %CustomItem control. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveAllElements(void); + + /** + * Removes the element with the specified element ID. + * + * @since 2.0 + * + * @return An error code + * @param[in] elementId The element ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveElement(int elementId); + + /** + * Sets the selection type of an element. + * + * @since 2.0 + * + * @param[in] elementId The element ID + * @param[in] enable Set to @c true to make only the element selected when touched, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks Based on the selection type of an element, the area within which the background color changes is different when an element is touched. + */ + result SetElementSelectionEnabled(int elementId, bool enable); + + /** + * Sets the horizontal alignment of text in the specified element. + * + * @since 2.0 + * + * @param[in] elementId The element ID + * @param[in] alignment The horizontal alignment of text + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The specified element does not handle text.@n + * The specified element does not contain text. + * @exception E_SYSTEM A system error has occurred. + */ + result SetElementTextHorizontalAlignment(int elementId, HorizontalAlignment alignment); + + /** + * Sets the vertical alignment of text in the specified element. + * + * @since 2.0 + * + * @param[in] elementId The element ID + * @param[in] alignment The vertical alignment of text + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The specified element does not handle text.@n + * The specified element does not contain text. + * @exception E_SYSTEM A system error has occurred. + */ + result SetElementTextVerticalAlignment(int elementId, VerticalAlignment alignment); + + /** + * Sets the auto-link mask. + * + * @since 2.0 + * + * @return An error code + * @param[in] elementId The element ID + * @param[in] mask The auto-link mask @n + * Multiple link types can be combined using bitwise OR operator (see Tizen::Base::Utility::LinkType). @n + * For more information, see AutoLink Detection. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The specified element does not handle text. + * @exception E_SYSTEM A system error has occurred. + * @remarks When @c mask is set to @c 0, the auto-link detection is disabled. + * @see Tizen::Base::Utility::LinkType + */ + result SetElementAutoLinkMask(int elementId, unsigned long mask); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + CustomItem(const CustomItem& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + CustomItem& operator =(const CustomItem& rhs); +}; // CustomItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_CUSTOM_ITEM_H_ + diff --git a/inc/FUiCtrlCustomList.h b/inc/FUiCtrlCustomList.h new file mode 100644 index 0000000..eb11c03 --- /dev/null +++ b/inc/FUiCtrlCustomList.h @@ -0,0 +1,857 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlCustomList.h + * @brief This is the header file for the %CustomList class. + * + * This header file contains the declarations of the %CustomList class and its helper classes. + */ + +#ifndef _FUI_CTRL_CUSTOM_LIST_H_ +#define _FUI_CTRL_CUSTOM_LIST_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if OSPDEPREC + * @class CustomList + * @brief [Deprecated] This class defines the common behavior of a %CustomList control. + * + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * The %CustomList class represents a list which has user-configured items. An item in a custom list can have + * different layout and height than the other items. Each item is composed of elements, which can be texts and bitmaps + * and is configured using CustomListItem and CustomListItemFormat. + * + * When an item in a custom list is selected or deselected, an item event is generated. It is passed on to all item event listeners + * that have registered an interest in item events generated by the custom list. If an application wants to perform tasks when a custom + * list item is selected and deselected, it must implement ICustomItemEventListener and register the listener to receive events from + * the custom list by calling the custom list's AddCustomItemEventListener() method. + * + * Note that CustomListItem and CustomListItemFormat need to be created on a heap. The items of a custom list are deleted automatically + * when the %CustomList control is destroyed. If you want to remove certain list items, you must use RemoveItemAt(). CustomListItemFormat + * must be deleted by the application. + * + * Refer to CustomListItem and CustomListItemFormat. + * + * Example: + * + * @image html ui_controls_customlist.png + * + * + * This is a simple UI application that uses a %CustomList control. + * + * + * @code +//Sample code for CustomListSample.h +#include + +// Forward Declaration +class CustomListElement; + +class CustomListSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::ICustomItemEventListener +{ +public: + CustomListSample(void) + : __pCustomList(null) + , __pCustomListItemFormat(null) + , __pListElement(null){} + + bool Initialize(void); + result AddListItem(Tizen::Ui::Controls::CustomList& customList, Tizen::Base::String itemText, + Tizen::Graphics::Bitmap* pBitmapNormal, Tizen::Graphics::Bitmap* pBitmapFocused); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // ICustomItemEventListener + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int index, int itemId, Tizen::Ui::ItemStatus status); + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int index, int itemId, int elementId, Tizen::Ui::ItemStatus status); + +private: + static const int ID_LIST_ITEM = 101; + static const int ID_LIST_TEXT = 102; + static const int ID_LIST_BITMAP = 103; + static const int ID_FORMAT_CUSTOM = 104; + + Tizen::Ui::Controls::CustomList* __pCustomList; + Tizen::Ui::Controls::CustomListItemFormat* __pCustomListItemFormat; + CustomListElement* __pListElement; +}; + * @endcode + * + * @code +// Sample code for CutomListSample.cpp +#include +#include + +#include "CustomListSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +class CustomListElement + : public ICustomListElement +{ +public: + result + DrawElement(const Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& rect, CustomListItemStatus itemStatus) + { + result r = E_SUCCESS; + + Canvas* pCanvas = const_cast(&canvas); + + pCanvas->SetLineWidth(5); + pCanvas->SetForegroundColor(Color::GetColor(COLOR_ID_GREEN)); + if (pCanvas->DrawRectangle(rect) != E_SUCCESS) + { + return r; + } + + if (pCanvas->DrawText(Point(rect.x+20, rect.y+20), L"Custom") != E_SUCCESS) + { + return r; + } + + return r; + } +}; + +bool +CustomListSample::Initialize() +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +CustomListSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of CustomListElement + __pListElement = new CustomListElement(); + + // Creates an instance of CustomList + __pCustomList = new CustomList(); + __pCustomList->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), CUSTOM_LIST_STYLE_NORMAL); + __pCustomList->AddCustomItemEventListener(*this); + + // Creates an instance of CustomListItemFormat + __pCustomListItemFormat = new CustomListItemFormat(); + __pCustomListItemFormat->Construct(); + __pCustomListItemFormat->AddElement(ID_LIST_TEXT, Rectangle(10, 25, 150, 80)); + __pCustomListItemFormat->AddElement(ID_LIST_BITMAP, Rectangle(170, 10, 70, 80)); + __pCustomListItemFormat->AddElement(ID_FORMAT_CUSTOM, Rectangle(GetClientAreaBounds().width - 120, 20, 100, 60)); + __pCustomListItemFormat->SetElementEventEnabled(ID_LIST_TEXT, true); + __pCustomListItemFormat->SetElementEventEnabled(ID_LIST_BITMAP, true); + __pCustomListItemFormat->SetElementEventEnabled(ID_FORMAT_CUSTOM, true); + + // Gets instances of Bitmap + AppResource* pAppResource = Application::GetInstance()->GetAppResource(); + Bitmap *pBitmapNormal = pAppResource->GetBitmapN(L"tizen.png"); + Bitmap *pBitmapFocused = pAppResource->GetBitmapN(L"tizen.png"); + + // Adds the item to the custom list + for (int i = 0; i < 30; i++) + { + String str = L"Text"; + str.Append(i+1); + AddListItem(*__pCustomList, str, pBitmapNormal, pBitmapFocused); + } + + // Adds the custom list to the form + AddControl(*__pCustomList); + + // Deallocates bitmaps + delete pBitmapNormal; + delete pBitmapFocused; + + return r; +} + +result +CustomListSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates item format and the element + delete __pCustomListItemFormat; + delete __pListElement; + + return r; +} + +result +CustomListSample::AddListItem(CustomList& customList, String itemText, Bitmap* pBitmapNormal, Bitmap* pBitmapFocused) +{ + // Creates an instance of CustomListItem + CustomListItem* pItem = new CustomListItem(); + + pItem->Construct(100); + pItem->SetItemFormat(*__pCustomListItemFormat); + pItem->SetElement(ID_LIST_TEXT, itemText); + pItem->SetElement(ID_LIST_BITMAP, *pBitmapNormal, pBitmapFocused); + pItem->SetElement(ID_FORMAT_CUSTOM, *(static_cast(__pListElement))); + + customList.AddItem(*pItem, ID_LIST_ITEM); + + return E_SUCCESS; +} + +// ICustomItemEventListener implementation +void +CustomListSample::OnItemStateChanged(const Control& source, int index, int itemId, ItemStatus status) +{ + switch (itemId) + { + case ID_LIST_ITEM: + { + // .... + } + break; + default: + break; + } +} + +void +CustomListSample::OnItemStateChanged(const Control& source, int index, int itemId, int elementId, Tizen::Ui::ItemStatus status) +{ + switch (itemId) + { + case ID_LIST_ITEM: + { + switch (elementId) + { + case ID_LIST_TEXT: + { + // .... + } + break; + + case ID_LIST_BITMAP: + { + // .... + } + break; + default: + break; + } + } + break; + default: + break; + } +} + * @endcode + * @endif + */ +class _OSP_EXPORT_ CustomList + : public Tizen::Ui::Control +{ +public: + /** + * @if OSPDEPREC + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * @endif + */ + CustomList(void); + + /** + * @if OSPDEPREC + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * @endif + */ + virtual ~CustomList(void); + +public: + /** + * @if OSPDEPREC + * Initializes this instance of %CustomList with the specified parameters. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] rect The x and y position of the top-left corner of the %CustomList control along with the width and height of the control + * @param[in] style The style set of %CustomList + * @param[in] itemDivider Set to @c true to display the divider, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The size of the control must be within the range as defined by the minimum and maximum size. + * @remarks The minimum size of this control is 92 x 72 on a WVGA screen, 60 x 48 on a HVGA screen and 46 x 36 on a WQVGA screen. + * @endif + */ + result Construct(const Tizen::Graphics::Rectangle& rect, CustomListStyle style, bool itemDivider = true); + + + /** + * @if OSPDEPREC + * Adds the custom item event listener instance. @n + * The added listener gets notified when the state of CustomListItem is changed. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @endif + */ + void AddCustomItemEventListener(Tizen::Ui::ICustomItemEventListener& listener); + + /** + * @if OSPDEPREC + * Removes the custom item event listener instance. @n + * The removed listener is not notified even when custom item events are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @endif + */ + void RemoveCustomItemEventListener(Tizen::Ui::ICustomItemEventListener& listener); + + /** + * @if OSPDEPREC + * Adds the specified item to the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] item The custom list item to be added + * @param[in] itemId The item ID for the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specified @c itemId can be used to identify a specific CustomListItem or @n + * to associate user-allocated resources. @n + * Note that the custom list does not throw an exception @n + * if the same itemID is assigned to multiple items. @n + * @remarks The added item is deleted automatically when the list is destroyed. @n + * Do not add, insert, or set an item that already belongs to the %CustomList control. + * @endif + */ + result AddItem(const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Inserts the specified item to %CustomList at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index at which to insert the item + * @param[in] item The custom list item to be inserted + * @param[in] itemId The item ID for the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c index is less than @c 0 or greater than or equal to the item count. + * @exception E_SYSTEM A system error has occurred. + * @remarks The inserted item is deleted automatically when the list is destroyed. @n + * Do not add, insert, or set an item that already belongs to the %CustomList control. + * @endif + */ + result InsertItemAt(int index, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Sets the contents of the item at the specified index in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index at which to set the contents of the item + * @param[in] item The custom list item to be set + * @param[in] itemId The item ID for the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c index is less than @c 0 or greater than or equal to the item count. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not add, insert, or set an item that already belongs to the %CustomList control. + * @endif + */ + result SetItemAt(int index, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Removes the item at the specified index in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item to be deleted + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c index is less than @c 0 or greater than or equal to the item count. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list item is deleted from the memory. + * @endif + */ + result RemoveItemAt(int index); + + /** + * @if OSPDEPREC + * Removes all the items from the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list items are deleted from the memory. + * @endif + */ + result RemoveAllItems(void); + + /** + * @if OSPDEPREC + * Gets the item at the specified index in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return A custom list item, @n + * else @c null if the specified index is out of range + * @param[in] index The index of the item to get + * @endif + */ + const CustomListItem* GetItemAt(int index) const; + + /** + * @if OSPDEPREC + * Gets the number of items in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return The number of items in %CustomList, @n + * else @c -1 if an error occurs + * @endif + */ + int GetItemCount(void) const; + + /** + * @if OSPDEPREC + * Enables or disables the status of the item at the specified @c index in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item whose status is to be set + * @param[in] enable Set to @c true to enable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetItemEnabled(int index, bool enable); + + /** + * @if OSPDEPREC + * Checks whether the specified index in the %CustomList control is enabled. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return @c true if the item is enabled, @n + * else @c false + * @param[in] index The index of the item to be checked + * @endif + */ + bool IsItemEnabled(int index) const; + + /** + * @if OSPDEPREC + * Sets the check status of the item at the specified index in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item to be set + * @param[in] check The check status + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows selection. + * @endif + */ + result SetItemChecked(int index, bool check); + + /** + * @if OSPDEPREC + * Checks whether the item at the specified index is checked in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return @c true if the item is checked, @n + * else @c false + * @param[in] index The index of the item to check + * @remarks This method can only be used when the style of the list allows selection. + * @endif + */ + bool IsItemChecked(int index) const; + + /** + * @if OSPDEPREC + * Sets the check status for all items of the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] check The check status + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + result SetAllItemsChecked(bool check); + + + /** + * @if OSPDEPREC + * Removes the checked items of the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows multiple selections. + * @remarks The removed list items are deleted from the memory. + * @endif + */ + result RemoveAllCheckedItems(void); + + /** + * @if OSPDEPREC + * Gets the first item of all the checked items in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return The index of the first checked item, @n + * else @c -1 if no item is checked or an error occurs + * @endif + */ + int GetFirstCheckedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the last item of all the checked items in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return The index of the last checked item, @n + * else @c -1 if no item is checked or an error occurs + * @endif + */ + int GetLastCheckedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the next checked item from the specified index in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return The index of the next checked item @n + * else @c -1 if no more item after the specified index is checked, @n + * or the specified @c index is less than @c 0 or greater than the item count. + * @param[in] index The index of the %CustomList control item + * endif + */ + int GetNextCheckedItemIndexAfter(int index) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if the specified position is not inside any of the items + * @param[in] x The x position of the point + * @param[in] y The y position of the point + * @endif + */ + int GetItemIndexFromPosition(int x, int y) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if the specified position is not inside any of the items + * @param[in] position The position of the point + * @endif + */ + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + + /** + * @if OSPDEPREC + * Gets the index of the first item from the visible items in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return The index of the first item, @n + * else @c -1 if no item is visible + * @endif + */ + int GetTopDrawnItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the index of the last item from the visible items in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return The index of the last item, @n + * else @c -1 if no item is visible + * @endif + */ + int GetBottomDrawnItemIndex(void) const; + + /** + * @if OSPDEPREC + * Sets the background color of the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @param[in] color The background color + * @endif + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Sets the text to be displayed when there is no item in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @param[in] text The text message to be displayed + * @endif + */ + void SetTextOfEmptyList(const Tizen::Base::String& text); + + /** + * @if OSPDEPREC + * Sets the color of the text to be displayed when there is no item in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @param[in] color The color of the text to be displayed + * @endif + */ + void SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Gets the color of the text to display when there is no item in the CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return The color of the text to be displayed + * @endif + */ + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + /** + * @if OSPDEPREC + * Gets the index of the item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if no item has the specified item ID + * @param[in] itemId The item ID of the %CustomList control item + * @remarks One or more indexes can have the same item ID, @n + * and this method returns the first item from such items. + * @endif + */ + int GetItemIndexFromItemId(int itemId) const; + + /** + * @if OSPDEPREC + * Gets the item ID of the item at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return The item ID of the item, @n + * else @c -1 if the specified @c index is less than @c 0 or greater than the item count + * @param[in] index The index of the %CustomList control item + * @endif + */ + int GetItemIdAt(int index) const; + + /** + * @if OSPDEPREC + * Scrolls to the bottom of the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * @endif + */ + void ScrollToBottom(void); + + /** + * @if OSPDEPREC + * Scrolls to the top of the %CustomList. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * @endif + */ + void ScrollToTop(void); + + /** + * @if OSPDEPREC + * Scrolls to the item at the specified index. @n + * The specified item is drawn at the top of the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the %CustomList control item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c index is less than @c 0 or greater than the item count. + * @endif + */ + result ScrollToTop(int index); + + /** + * @if OSPDEPREC + * Draws and shows the item at the specified index in the %CustomList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use ListView class. + * @since 2.0 + * + * @return An error code + * + * @param[in] index The index of the %CustomList control item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_OPERATION The item has never been drawn before calling this method. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c index is less than @c 0 or greater than the item count. + * @endif + */ + result RefreshItem(int index); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + CustomList(const CustomList& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + CustomList& operator =(const CustomList& rhs); + + friend class _CustomListImpl; + +}; //CustomList + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_CUSTOM_LIST_H_ diff --git a/inc/FUiCtrlCustomListItem.h b/inc/FUiCtrlCustomListItem.h new file mode 100644 index 0000000..c5c6a3a --- /dev/null +++ b/inc/FUiCtrlCustomListItem.h @@ -0,0 +1,329 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlCustomListItem.h + * @brief This is the header file for the %CustomListItem class. + * + * This header file contains the declarations of the %CustomListItem class and its helper classes. + */ + +#ifndef _FUI_CTRL_CUSTOM_LIST_ITEM_H_ +#define _FUI_CTRL_CUSTOM_LIST_ITEM_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class _CustomListItemImpl; +class CustomListItemFormat; +/** + * @if OSPDEPREC + * @class CustomListItem + * @brief [Deprecated] This class defines the common behavior of an item of the CustomList control. + * + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class. + * @since 2.0 + * + * The %CustomListItem class represents a custom list item which is the unit of + * handling of a custom list. A custom list item is composed of one or more elements, + * which can be texts and bitmaps. Custom drawable elements are also supported via + * ICustomListElement. The value of the elements is set using %CustomListItem. + * + * Note that %CustomListItem needs to be created on a heap. CustomListItems will be deleted automatically + * when the CustomList is destroyed. If you want to remove certain list items, you must use RemoveItemAt(). + * + * Refer to CustomListItemFormat. + * + * @endif + */ +class _OSP_EXPORT_ CustomListItem + : public Tizen::Base::Object +{ +public: + /** + * @if OSPDEPREC + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * + * @since 2.0 + * @endif + */ + CustomListItem(void); + + /** + * @if OSPDEPREC + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * @endif + */ + virtual ~CustomListItem(void); + +public: + /** + * @if OSPDEPREC + * Initializes this instance of %CustomListItem with the specified parameter. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * + * @return An error code + * @param[in] itemHeight The height of %CustomListItem + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result Construct(int itemHeight); + + /** + * @if OSPDEPREC + * Sets the format of %CustomListItem. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * + * @param[in] itemFormat An instance of %CustomListItemFormat + * @remarks Do not delete @c itemFormat before the associated %CustomListItem is removed from %CustomList, because %CustomListItemFormat is constantly + * used while %CustomListItem is added to CustomList. + * @endif + */ + void SetItemFormat(const CustomListItemFormat& itemFormat); + + /** + * Gets the format of %CustomListItem. + * + * @since 2.0 + * + * @return A pointer to CustomListItemFormat, @n + * else @c null if a system error occurs + */ + const CustomListItemFormat* GetItemFormat(void) const; + + /** + * @if OSPDEPREC + * Sets the background bitmap image which is displayed when the item is focused. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * + * @param[in] bitmap The background bitmap image + * @remarks The specified bitmap is automatically scaled to the size of an associated item. + * @see SetNormalItemBackgroundBitmap() + * @endif + */ + void SetFocusedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * @if OSPDEPREC + * Sets the background image of the item which is displayed when the item is in normal state. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * + * @param[in] bitmap The background bitmap image + * @remarks The specified bitmap is automatically scaled to the size of an+B6 associated item. + * @see SetFocusedItemBackgroudBitmap() + * @endif + */ + void SetNormalItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * @if OSPDEPREC + * Sets the highlighted background image on the rectangle of each list item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * + * @param[in] bitmap The background image + * @remarks When a user navigates the user interface using the directional keys, @n + * the selected UI control is highlighted and takes the focus. + * @endif + */ + + void SetHighlightedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * @if OSPDEPREC + * Sets the text of the element for %CustomListItem. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * + * @return An error code + * @param[in] elementId The ID of the element + * @param[in] text The text string to be added + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks To display text in multi-lines or to denote the end of line use '\\n'. + * @endif + */ + result SetElement(int elementId, const Tizen::Base::String& text); + + /** + * @if OSPDEPREC + * Sets the bitmap of the element for %CustomListItem. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * + * @return An error code + * @param[in] elementId The ID of the element + * @param[in] normalBitmap The bitmap displayed when the item is in the normal state + * @param[in] pFocusedBitmap The bitmap displayed when the item is focused + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetElement(int elementId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pFocusedBitmap); + + + /** + * @if OSPDEPREC + * Sets the bitmap of the element for %CustomListItem. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * + * @return An error code + * @param[in] elementId The ID of the element + * @param[in] normalBitmap The bitmap displayed when the item is in the normal state + * @param[in] pFocusedBitmap The bitmap displayed when the item is selected + * @param[in] pHighlightedBitmap The bitmap displayed when the item is highlighted + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetElement(int elementId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pFocusedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + + /** + * @if OSPDEPREC + * Sets the custom element for %CustomListItem. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * + * @return An error code + * @param[in] elementId The ID of the element + * @param[in] element The custom element + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not delete @c element before the associated %CustomListItem is removed from CustomList, @n + * as ICustomListElement is constantly used while %CustomListItem is added to %CustomList. @n + * Call RefreshItem() to draw the custom element that has been set with this method. + * @endif + */ + result SetElement(int elementId, const ICustomListElement& element); + + /** + * @if OSPDEPREC + * Sets the element ID of the checkbox of %CustomListItem. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * + * @return An error code + * @param[in] elementId The ID of the element + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetCheckBox(int elementId); + + /** + * @if OSPDEPREC + * Sets the percent value of %CustomListItem. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * + * @return An error code + * @param[in] value The percent value of %CustomListItem @n + * The valid range of integers is from @c 0 to @c 100 + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetValue(int value); + + /** + * @if OSPDEPREC + * Gets the percentage value of %CustomListItem. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use CustomItem class + * @since 2.0 + * + * @return The percentage value, @n + * else @c -1 if a system error occurs + * @endif + */ + int GetValue(void) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + CustomListItem(const CustomListItem& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + CustomListItem& operator =(const CustomListItem& rhs); + +private: + + CustomListItemFormat* __pCustomListItemFormat; + _CustomListItemImpl* __pCustomListItemImpl; + + friend class _CustomListImpl; + friend class _CustomListItemImpl; + friend class _ExpandableListImpl; + friend class _SlidableListImpl; + friend class _GroupedListImpl; + friend class _SlidableGroupedListImpl; + friend class _ListImpl; + + friend class _CustomListItemDataProvider; + friend class _SlidableListItemProvider; + friend class _ListBaseImpl; + friend class _GroupedListItemDataProvider; + friend class _ExpandableListItemDataProvider; + friend class _SlidableGroupedListItemProvider; + friend class _ListItemDataProvider; +}; //CustomListItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_CUSTOM_LIST_ITEM_H_ diff --git a/inc/FUiCtrlCustomListItemFormat.h b/inc/FUiCtrlCustomListItemFormat.h new file mode 100644 index 0000000..1df299e --- /dev/null +++ b/inc/FUiCtrlCustomListItemFormat.h @@ -0,0 +1,315 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlCustomListItemFormat.h + * @brief This is the header file for the %CustomListItemFormat class. + * + * This header file contains the declarations of the %CustomListItemFormat class and its helper classes. + */ + +#ifndef _FUI_CTRL_CUSTOM_LIST_ITEM_FORMAT_H_ +#define _FUI_CTRL_CUSTOM_LIST_ITEM_FORMAT_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @if OSPDEPREC + * @class CustomListItemFormat + * @brief [Deprecated] This class defines the common behavior of an item format of a CustomList control. + * + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * The %CustomListItemFormat class defines the common behavior of an item format of a CustomList control. + * A custom list item is composed of elements, which can be texts and bitmaps. + * A custom list item format determines the configuration of elements of a list item + * and the position and the size of a custom list item. + * + * Note that %CustomListItemFormat needs to be created on a heap and it must be + * deleted explicitly after use. However, CustomListItem must + * be manually deleted because items are removed from memory by the List when + * it is destroyed. + * + * Refer to CustomListItem. + * @endif + */ +class _OSP_EXPORT_ CustomListItemFormat + : public Tizen::Base::Object +{ +public: + /** + * @if OSPDEPREC + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * @endif + */ + CustomListItemFormat(void); + + /** + * @if OSPDEPREC + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + */ + virtual ~CustomListItemFormat(void); + +public: + /** + * @if OSPDEPREC + * Initializes this instance of %CustomListItemFormat. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * + */ + result Construct(void); + + /** + * @if OSPDEPREC + * Adds the %CustomListElement with bounds equal to @c rect. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @return An error code + * @param[in] elementId The ID of the element + * @param[in] rect The bounds of the element + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result AddElement(int elementId, const Tizen::Graphics::Rectangle& rect); + + /** + * @if OSPDEPREC + * Adds the %CustomListElement with bounds equal to @c rect and size of the text @c textSize. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @return An error code + * @param[in] elementId The ID of the element + * @param[in] rect The bounds of the element + * @param[in] textSize The size of the text + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result AddElement(int elementId, const Tizen::Graphics::Rectangle& rect, int textSize); + + /** + * @if OSPDEPREC + * Adds the %CustomListElement with bounds equal to @c rect, specifying the size of text and the color of text. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @return An error code + * @param[in] elementId The ID of the element + * @param[in] rect The bounds of the element + * @param[in] textSize The size of the text + * @param[in] normalTextColor The color of the text in the normal status + * @param[in] focusedTextColor The color of the text in the focused status + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result AddElement(int elementId, const Tizen::Graphics::Rectangle& rect, int textSize, const Tizen::Graphics::Color& normalTextColor, const Tizen::Graphics::Color& focusedTextColor); + + /** + * @if OSPDEPREC + * Adds the %CustomListElement with bounds equal to @c rect, specifying the size of text and the color of text. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @return An error code + * @param[in] elementId The ID of the element + * @param[in] rect The bounds of the element + * @param[in] textSize The size of the text + * @param[in] normalTextColor The color of the text in the normal status + * @param[in] focusedTextColor The color of the text in the focused status + * @param[in] highlightedTextColor The color of the text in the highlighted status + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result AddElement(int elementId, const Tizen::Graphics::Rectangle& rect, int textSize, const Tizen::Graphics::Color& normalTextColor, const Tizen::Graphics::Color& focusedTextColor, const Tizen::Graphics::Color& highlightedTextColor); + + /** + * @if OSPDEPREC + * Gets the position and size of the element. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @return The bounds of the element, @n + * else a rectangle of (0, 0, -1, -1) if there is no element matching the specified ID + * @param[in] elementId The ID of the element + * @endif + */ + Tizen::Graphics::Rectangle GetElement(int elementId) const; + + /** + * @if OSPDEPREC + * Gets the ID of the first element. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @return The ID of the first element, @n + * else @c -1 if a system error occurs + * @endif + */ + int GetFirstElementId(void) const; + + /** + * @if OSPDEPREC + * Gets the ID of the next element of the specified element. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @return The ID of the next element of the specified element, @n + * else @c -1 if there is no element next to the element specified by @c elementId + * @param[in] elementId The ID of the element + * @endif + */ + int GetNextElementId(int elementId) const; + + /** + * @if OSPDEPREC + * Gets the ID of the first element of all enabled items. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @return The ID of the first enabled element, @n + * else @c -1 if no element is enabled + * @endif + */ + int GetFirstEnabledElementId(void) const; + + /** + * @if OSPDEPREC + * Gets the ID of the next enabled element after the specified element. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @return The ID of the next enabled element, @n + * else @c -1 if no element after the specified element is enabled + * @param[in] elementId The ID of the element + * @endif + */ + int GetNextEnabledElementId(int elementId) const; + + /** + * @if OSPDEPREC + * Gets the ID of the previous enabled element ID of the specified element. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @return The ID of the previous enabled element, @n + * else @c -1 if no element before the specified element is enabled + * @param[in] elementId The ID of the element + * @endif + */ + int GetPreviousEnabledElementId(int elementId) const; + + /** + * @if OSPDEPREC + * Sets the event status for the specified element. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @param[in] elementId The ID of the element + * @param[in] enable Set to @c true to allow the specified element to handle the events, @n + * else @c false + * @endif + */ + void SetElementEventEnabled(int elementId, bool enable); + + /** + * @if OSPDEPREC + * Checks whether the event status is enabled for the specified element. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. There is no need to use this class. + * @since 2.0 + * + * @return @c true if the event status is enabled, @n + * else @c false + * @param[in] elementId The ID of the element + * @endif + */ + bool IsElementEventEnabled(int elementId); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + CustomListItemFormat(const CustomListItemFormat& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + CustomListItemFormat& operator =(const CustomListItemFormat& rhs); + +private: + + class _CustomListItemFormatImpl* __pCustomListItemFormatImpl; + + friend class _CustomListItemImpl; + friend class _CustomListImpl; + friend class _ExpandableListImpl; + friend class _SlidableListImpl; + friend class _GroupedListImpl; + friend class _SlidableGroupedListImpl; +}; //CustomListItemFormat + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_CUSTOM_LIST_ITEM_FORMAT_H_ diff --git a/inc/FUiCtrlCustomListTypes.h b/inc/FUiCtrlCustomListTypes.h new file mode 100644 index 0000000..e2874eb --- /dev/null +++ b/inc/FUiCtrlCustomListTypes.h @@ -0,0 +1,54 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlCustomListTypes.h + * @brief This is the header file for the CustomListStyle enumeration. + * + * The CustomListStyle enumeration defines the styles for the CustomList control. + */ +#ifndef _FUI_CTRL_CUSTOM_LIST_TYPES_H_ +#define _FUI_CTRL_CUSTOM_LIST_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if OSPDEPREC + * @enum CustomListStyle + * + * Defines the styles of CustomList. + * + * @brief [Deprecated] + * @deprecated This enumeration is deprecated. Instead of using this enumeration, use ListAnnexStyle enumeration for CustomItem or SimpleItem class. @n + * @since 2.0 + * @endif + */ +enum CustomListStyle +{ + CUSTOM_LIST_STYLE_NORMAL = 0, /**< @if OSPDEPREC No mark, radio, or On/Off check @endif */ + CUSTOM_LIST_STYLE_RADIO, /**< @if OSPDEPREC The radio style for single selection @endif */ + CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER, /**< @if OSPDEPREC The radio style with divider for single selection @endif */ + CUSTOM_LIST_STYLE_MARK, /**< @if OSPDEPREC The mark style for multiple selection @endif */ + CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER, /**< @if OSPDEPREC The mark style with divider for multiple selection @endif */ + CUSTOM_LIST_STYLE_ONOFF, /**< @if OSPDEPREC The On/Off style */ + CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER /**< @if OSPDEPREC The On/Off style with divider */ +}; + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_CUSTOM_LIST_TYPES_H_ diff --git a/inc/FUiCtrlDatePicker.h b/inc/FUiCtrlDatePicker.h new file mode 100644 index 0000000..11b88dc --- /dev/null +++ b/inc/FUiCtrlDatePicker.h @@ -0,0 +1,380 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlDatePicker.h + * @brief This is the header file for the %DatePicker class. + * + * This header file contains the declarations of the %DatePicker class. + */ +#ifndef _FUI_CTRL_DATE_PICKER_H_ +#define _FUI_CTRL_DATE_PICKER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class DatePicker + * @brief This class displays a full screen %DatePicker on top of the screen. + * + * @since 2.0 + * + * @remarks One cannot change the size and the position of the %DatePicker. + * + * The %DatePicker class displays a full screen window-based selector that allows the user to select a certain date. + * + * For more information on the class features, see DatePicker, TimePicker, and DateTimePicker. + * + * The following example demonstrates how to use the %DatePicker class. + * + * @code +// Sample code for DatePickerSample.h +#include + +class DatePickerSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IDateChangeEventListener + , public Tizen::Ui::IActionEventListener +{ +public: + DatePickerSample(void) + :__pDatePicker(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + void ShowDatePicker(bool show); + + // IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + // IDateChangeEventListener + virtual void OnDateChanged(const Tizen::Ui::Control& source, int year, int month, int day); + virtual void OnDateChangeCanceled(const Tizen::Ui::Control& source); + +private: + static const int ID_BUTTON = 101; + + Tizen::Ui::Controls::DatePicker* __pDatePicker; +}; + + * @endcode + * + * @code +// Sample code for DatePickerSample.cpp +#include "DatePickerSample.h" +#include + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +DatePickerSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +DatePickerSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Button + Button* pButton = new Button(); + pButton->Construct(Rectangle(50, 50, 300, 200), L"Show DatePicker"); + pButton->SetActionId(ID_BUTTON); + pButton->AddActionEventListener(*this); + + // Adds the button to the form + AddControl(*pButton); + + // Creates an instance of DatePicker + __pDatePicker = new DatePicker(); + __pDatePicker->Construct(); + + // Adds an instace of IDateChangeEventListener + __pDatePicker->AddDateChangeEventListener(*this); + + // Shows the date picker after it's owner form is shown. + + return r; +} + +void +DatePickerSample::ShowDatePicker(bool show) +{ + // Changes to desired show state + __pDatePicker->SetShowState(show); + + // Calls Show() of the control + if (show) + { + __pDatePicker->Show(); + } + // Calls Show() of the container + else + { + Invalidate(true); + } +} + +result +DatePickerSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the date picker + delete __pDatePicker; + + return r; +} + +// IActionEventListener implementation +void +DatePickerSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_BUTTON: + { + ShowDatePicker(true); + } + break; + default: + break; + } +} + +// IDateChangeEventListener implementation +void +DatePickerSample::OnDateChanged(const Control& source, int year, int month, int day) +{ + // .... +} + +void +DatePickerSample::OnDateChangeCanceled(const Control& source) +{ + // .... +} + * @endcode + */ +class _OSP_EXPORT_ DatePicker + : public Tizen::Ui::Window +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + DatePicker(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~DatePicker(void); + + /** + * Adds a data change event listener instance. @n + * The added listener is called when the date of the %DatePicker is changed either through user manipulation or by calling one of its setters. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @see IDateChangeEventListener::OnDateChanged() + * @see IDateChangeEventListener::OnDateChangeCanceled() + * @see RemoveDateChangeEventListener() + */ + void AddDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener); + + /** + * Removes a date changed event listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see IDateChangeEventListener::OnDateChanged() + * @see IDateChangeEventListener::OnDateChangeCanceled() + * @see AddDateChangeEventListener() + */ + void RemoveDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener); + + /** + * Initializes this instance of %DatePicker with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] title The title + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Base::String& title = L""); + + /** + * Gets the current date value of the %DatePicker control. + * + * @since 2.0 + * + * @return A %DateTime instance + */ + Tizen::Base::DateTime GetDate(void) const; + + /** + * Gets the current day value of the %DatePicker control. @n + * The day value is between @c 1 to @c 31. + * + * @since 2.0 + * + * @return The current day value, @n + * else @c -1 if an error occurs + */ + int GetDay(void) const; + + /** + * Gets the current month value of the %DatePicker control. @n + * The month value is between @c 1 to @c 12. + * + * @since 2.0 + * + * @return The current month value, @n + * else @c -1 if an error occurs + */ + int GetMonth(void) const; + + /** + * Gets the current year value of the %DatePicker control. + * The year value is between @c 1 to @c 9999. + * + * @since 2.0 + * + * @return The current year value, @n + * else @c -1 if an error occurs + * + */ + int GetYear(void) const; + + /** + * Sets the date value of the %DatePicker control. + * + * @since 2.0 + * + * @param[in] date The date to be set + */ + void SetDate(const Tizen::Base::DateTime& date); + + /** + * Sets the date value of the %DatePicker control with the current date. + * + * @since 2.0 + */ + void SetCurrentDate(void); + + /** + * Sets the year value. @n + * The year value should be between @c 1 and @c 9999. + * + * @since 2.0 + * + * @return An error code + * @param[in] year The year value + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified year value is invalid. + */ + result SetYear(int year); + + /** + * Sets the month value. @n + * The month value should be between @c 1 and @c 12. + * + * @since 2.0 + * + * @return An error code + * @param[in] month The month value + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified month value is invalid. + */ + result SetMonth(int month); + + /** + * Sets the day value. @n + * The day value should be between @c 1 and @c 31. + * + * @since 2.0 + * + * @return An error code + * @param[in] day The day value + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c day is invalid. + */ + result SetDay(int day); + + /** + * Sets the valid year range. + * The range should be set in between @c 1 and @c 9999. + * + * @since 2.0 + * + * @return An error code + * @param[in] minYear The minimum year for the valid range + * @param[in] maxYear The maximum year for the valid range + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The given year range is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetYearRange(int minYear, int maxYear); + + /** + * Gets the valid year range. + * + * @since 2.0 + * + * @return An error code + * @param[out] minYear The minimum year for the valid range + * @param[out] maxYear The maximum year for the valid range + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result GetYearRange(int& minYear, int& maxYear) const; + +protected: + friend class _DatePickerImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + DatePicker(const DatePicker& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + DatePicker& operator =(const DatePicker& rhs); + +}; // DatePicker + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_DATE_PICKER_H_ diff --git a/inc/FUiCtrlDateTimePicker.h b/inc/FUiCtrlDateTimePicker.h new file mode 100644 index 0000000..543246e --- /dev/null +++ b/inc/FUiCtrlDateTimePicker.h @@ -0,0 +1,454 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlDateTimePicker.h + * @brief This is the header file for the %DateTimePicker class. + * + * This header file contains the declarations of the %DateTimePicker class. + */ +#ifndef _FUI_CTRL_DATE_TIME_PICKER_H_ +#define _FUI_CTRL_DATE_TIME_PICKER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class DateTimePicker + * @brief This class displays a full screen %DateTimePicker on top of the screen. + * + * @since 2.0 + * + * The %DateTimePicker class displays a full screen window-based selector that allows the user to select a certain date and time. + * + * For more information on the class features, see DatePicker, TimePicker, and DateTimePicker. + * + * The following example demonstrates how to use the %DateTimePicker class. + * + * @code +// Sample code for DateTimePickerSample.h +#include + +class DateTimePickerSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IDateTimeChangeEventListener + , public Tizen::Ui::IActionEventListener +{ +public: + DateTimePickerSample(void) + :__pDateTimePicker(null){} + + bool Initialize(void); + void ShowDateTimePicker(bool show); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + // IDateTimeChangeEventListener + virtual void OnDateTimeChanged(const Tizen::Ui::Control& source, int year, int month, int day, int hour, int minute); + virtual void OnDateTimeChangeCanceled(const Tizen::Ui::Control& source); + +private: + static const int ID_BUTTON = 101; + + Tizen::Ui::Controls::DateTimePicker* __pDateTimePicker; +}; + + * @endcode + * + * @code +// Sample code for DateTimePickerSample.cpp +#include + +#include "DateTimePickerSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +DateTimePickerSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +DateTimePickerSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Button + Button* pButton = new Button(); + pButton->Construct(Rectangle(50, 50, 300, 200), L"Show DateTimePicker"); + pButton->SetActionId(ID_BUTTON); + pButton->AddActionEventListener(*this); + + // Adds the button to the form + AddControl(*pButton); + + // Creates an instance of DateTimePicker + __pDateTimePicker = new DateTimePicker(); + __pDateTimePicker->Construct(); + + // Adds an instace of IDateTimeChangeEventListener + __pDateTimePicker->AddDateTimeChangeEventListener(*this); + + // Shows the date time picker after it's owner form is shown. + + return r; +} + +void +DateTimePickerSample::ShowDateTimePicker(bool show) +{ + // Changes to desired show state + __pDateTimePicker->SetShowState(show); + + // Calls Show() of the control + if (show) + { + __pDateTimePicker->Show(); + } + // Calls Show() of the container + else + { + Invalidate(true); + } +} + +result +DateTimePickerSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the date time picker + delete __pDateTimePicker; + + return r; +} + +// IActionEventListener implementation +void +DateTimePickerSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_BUTTON: + { + ShowDateTimePicker(true); + } + break; + default: + break; + } +} + +// IDateTimeChangeEventListener implementation +void +DateTimePickerSample::OnDateTimeChanged(const Control& source, int year, int month, int day, int hour, int minute) +{ + // .... +} + +void +DateTimePickerSample::OnDateTimeChangeCanceled(const Control& source) +{ + // .... +} + * @endcode + */ + +class _OSP_EXPORT_ DateTimePicker + : public Tizen::Ui::Window +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + DateTimePicker(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~DateTimePicker(void); + + /** + * Adds the IDateTimeChangeEventListener instance. @n + * The added listener gets notified when date or time of the %DateTimePicker instance is changed either by user manipulation or by calling one of its + * setters. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @see IDateTimeChangeEventListener::OnDateTimeChanged() + * @see IDateTimeChangeEventListener::OnDateTimeChangeCanceled() + * @see RemoveDateTimeChangeEventListener() + */ + void AddDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener); + + /** + * Removes the IDateTimeChangeEventListener instance. @n + * The removed listener is not called even when the date and time change events are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see IDateTimeChangeEventListener::OnDateTimeChanged() + * @see IDateTimeChangeEventListener::OnDateTimeChangeCanceled() + * @see AddDateTimeChangeEventListener() + */ + void RemoveDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener); + + /** + * Initializes this instance of %DateTimePicker to the current date and time in the wall time mode. + * + * @since 2.0 + * + * @return An error code + * @param[in] title The title + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Base::String& title = L""); + + /** + * Sets the date and time value of the %DateTimePicker control. + * + * @since 2.0 + * + * @param[in] dateTime The date and time to be set + */ + void SetDateTime(const Tizen::Base::DateTime& dateTime); + + /** + * Sets the date and time value of the %DateTimePicker control with the current date and time in the Coordinated Universal Time (UTC) mode. + * + * @since 2.0 + */ + void SetCurrentDateTime(void); + + /** + * Sets the year value of the %DateTimePicker control. + * + * @since 2.0 + * + * @return An error code + * @param[in] year The year value + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c year value is invalid. + * @exception E_SYSTEM A system error has occurred. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by SetYearRange(). + * @remarks The specified @c year should be in the range set by SetYearRange(). The default year range is from @c 1 to @c 9999. + * @see SetYearRange() + */ + result SetYear(int year); + + /** + * Sets the month value. @n + * The month value should be between @c 1 and @c 12. + * + * @since 2.0 + * + * @return An error code + * @param[in] month The month value + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c month value is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetMonth(int month); + + /** + * Sets the day value. + * The day value should be between @c 1 and @c 31. + * + * @since 2.0 + * + * @return An error code + * @param[in] day The day value + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c day value is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetDay(int day); + + /** + * Sets the hour value of the %DateTimePicker control. + * The hour value should be between @c 0 and @c 23. + * + * @since 2.0 + * + * @return An error code + * @param[in] hour The hour value to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c hour value is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetHour(int hour); + + /** + * Sets the minute value of the %DateTimePicker control. + * The minute value should be between @c 0 and @c 59. + * + * @since 2.0 + * + * @return An error code + * @param[in] minute The minute value to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c minute value is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetMinute(int minute); + + /** + * Gets the current date and time value of the %DateTimePicker control. + * + * @since 2.0 + * + * @return The current date and time + * @remarks This method does not work when %DateTimePicker style is DATETIME_PICKER_STYLE_FROMTO. + */ + Tizen::Base::DateTime GetDateTime(void) const; + + /** + * Gets the current year value of %DateTimePicker. @n + * The year value should be between @c 1 to @c 9999. + * + * @since 2.0 + * + * @return The current year value, @n + * else @c -1 if an error occurs + */ + int GetYear(void) const; + + /** + * Gets the current month value of %DateTimePicker. @n + * The month value should be between @c 1 to @c 12. + * + * @since 2.0 + * + * @return The current month value, @n + * else @c -1 if an error occurs + */ + int GetMonth(void) const; + + /** + * Gets the current day value of %DateTimePicker. @n + * The day value should be between @c 1 to @c 31. + * + * @since 2.0 + * + * @return The current day value , @n + * else @c -1 if an error occurs + */ + int GetDay(void) const; + + /** + * Gets the current hour value of the %DateTimePicker control. @n + * The hour value should be between @c 0 to @c 23. + * + * @since 2.0 + * + * @return The current hour value, @n + * else @c -1 if an error occurs + * @remarks Whether the time display mode is 12-hour or 24-hour, this method always returns the hour value ranging from @c 0 to @c 23. + */ + int GetHour(void) const; + + /** + * Gets the current minute value of the %DateTimePicker control. + * + * @since 2.0 + * + * @return The current minute value, @n + * else @c -1 if an error occurs + */ + int GetMinute(void) const; + + /** + * Sets the 12-hour or 24-hour display mode of the %DateTimePicker control. + * + * @since 2.0 + */ + void Set24HourNotationEnabled(bool enable); + + /** + * Checks whether the 24-hour notation is enabled for the %DateTimePicker control. @n + * This can be 12-hour or 24-hour mode. + * + * @since 2.0 + * + * @return @c true if the 24-hour notation is enabled, @n + * else @c false if the 12-hour notation is enabled + */ + bool Is24HourNotationEnabled(void) const; + + /** + * Sets the valid year range. @n + * The range should be set between @c 1 and @c 9999. + * + * @since 2.0 + * + * @return An error code + * @param[in] minYear The minimum year for the valid range + * @param[in] maxYear The maximum year for the valid range + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified year range is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetYearRange(int minYear, int maxYear); + + /** + * Gets the valid year range. + * + * @since 2.0 + * + * @return An error code + * @param[out] minYear The minimum year for the valid range + * @param[out] maxYear The maximum year for the valid range + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result GetYearRange(int& minYear, int& maxYear) const; + +protected: + friend class _DateTimePickerImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + DateTimePicker(const DateTimePicker& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + DateTimePicker& operator =(const DateTimePicker& rhs); + +}; // DateTimePicker + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_DATE_TIME_PICKER_H_ diff --git a/inc/FUiCtrlEditArea.h b/inc/FUiCtrlEditArea.h new file mode 100644 index 0000000..b424610 --- /dev/null +++ b/inc/FUiCtrlEditArea.h @@ -0,0 +1,1300 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlEditArea.h + * @brief This is the header file for the %EditArea class. + * + * This header file contains the declarations of the %EditArea class and its helper classes. + */ + +#ifndef _FUI_CTRL_EDIT_AREA_H_ +#define _FUI_CTRL_EDIT_AREA_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Locales +{ +class Locale; +}} // Tizen::Locales + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class EditArea + * @brief This class defines the common behavior for the %EditArea control. + * + * @since 2.0 + * + * The %EditArea class displays a multi-line text editor. + * + * For more information on the class features, see EditArea and EditField. + * + * The following example demonstrates how to use the %EditArea class. + * + * @code +// Sample code for EditAreaSample.h +#include + +class EditAreaSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::ITextEventListener +{ +public: + EditAreaSample(void) + : __pEditArea(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + // ITextEventListener + virtual void OnTextValueChanged(const Tizen::Ui::Control& source); + virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source); + +private: + Tizen::Ui::Controls::EditArea* __pEditArea; +}; + * @endcode + * + * @code +// Sample code for EditAreaSample.cpp +#include + +#include "EditAreaSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +EditAreaSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +EditAreaSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of EditArea + __pEditArea = new EditArea(); + __pEditArea->Construct(Rectangle(50, 100, 400, 150)); + __pEditArea->AddTextEventListener(*this); + + // Adds the edit area to the form + AddControl(*__pEditArea); + + return r; +} + +// ITextEventListener implementation +void +EditAreaSample::OnTextValueChanged(const Tizen::Ui::Control& source) +{ + // .... +} + +void +EditAreaSample::OnTextValueChangeCanceled(const Tizen::Ui::Control& source) +{ + // .... +} + * @endcode + * + */ +class _OSP_EXPORT_ EditArea + : public Tizen::Ui::Control +{ +// Lifecycle +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + EditArea(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~EditArea(void); + + /** + * Initializes this instance of the %EditArea control with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created window along with + * the width and height of the control. + * @param[in] inputStyle Determines whether the fullscreen keypad or overlay keypad is displayed + * @param[in] limitLength The maximum limit of the length of the text that can be displayed by %EditArea + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid.@n + * The specified @c limitLength is less than or equal to @c 0. @n + * The @c rect.width or the @c rect.height is less than 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks Some methods of the control will only work as expected when it becomes 'displayable'. + * For more information, see Control::IsDisplayable() @n + * The orientation of the full-screen style keypad is determined by the current device orientation. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, InputStyle inputStyle = INPUT_STYLE_FULLSCREEN, int limitLength = 1000); + +public: + /** + * Gets the horizontal text alignment. + * + * @since 2.0 + * + * @return The horizontal text alignment + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextAlignment() + */ + HorizontalAlignment GetTextAlignment(void) const; + + /** + * Sets the horizontal text alignment. + * + * @since 2.0 + * + * @return An error code + * @param[in] alignment The horizontal text alignment + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextAlignment() + */ + result SetTextAlignment(HorizontalAlignment alignment); + + /** + * Checks whether the view mode is enabled. + * + * @since 2.0 + * + * @return @c true if the view mode is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetViewModeEnabled() + */ + bool IsViewModeEnabled(void) const; + + /** + * Enables or disables the view mode. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the view mode, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks When the view mode is enabled, the auto-detected links will be displayed as linked text. + * @see IsViewModeEnabled() + */ + result SetViewModeEnabled(bool enable); + + /** + * Sets the auto-link mask. + * + * @since 2.0 + * + * @return An error code + * @param[in] autoLinks The auto-link mask @n + * Multiple link types can be combined using bitwise OR (see Tizen::Base::Utility::LinkType). @n + * For more information, see AutoLink Detection. + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * The operation is not supported if the input style is not INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + * @remarks When @c autoLinks is set to zero, the auto-link detection is disabled. + * @see Tizen::Base::Utility::LinkType + * @see GetAutoLinkMask() + * @see IsViewModeEnabled() + * @see SetViewModeEnabled() + */ + result SetAutoLinkMask(unsigned long autoLinks); + + /** + * Gets the auto-link mask. + * + * @since 2.0 + * + * @return The auto-link mask + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * This operation is not supported if the input style is not INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult()() method. + * @see SetAutoLinkMask() + */ + unsigned long GetAutoLinkMask(void) const; + + /** + * Adds the specified link event listener. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks This method is supported when the input style is @c INPUT_STYLE_OVERLAY.@n + * The added listener will be notified when the links are selected by the user. + * @see RemoveUiLinkEventListener() + */ + void AddUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + /** + * Removes the specified link event listener. @n + * The removed listener cannot listen to the events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @remarks This method is supported when the input style is @c INPUT_STYLE_OVERLAY. + * @see AddUiLinkEventListener() + */ + void RemoveUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + /** + * Gets the line spacing. + * + * @since 2.0 + * + * @return The line spacing, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult()() method. + * @see SetLineSpacing() + */ + int GetLineSpacing(void) const; + + /** + * Sets the line spacing. @n + * The line spacing is determined by multiplying @c multiplier to the default line spacing and adding @c extra. + * + * @code + * The line spacing = (default line spacing) * multiplier + extra + * @endcode + * @since 2.0 + * + * @return An error code + * @param[in] multiplier The line spacing multiplier + * @param[in] extra The extra line spacing + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or @n + * the specified line spacing value cannot be supported. + * @exception E_SYSTEM A system error has occurred. + * @see GetLineSpacing() + */ + result SetLineSpacing(int multiplier, int extra); + + /** + * Gets the margin value of the specified margin type. + * + * @since 2.0 + * + * @return The margin value, @n + * else @c -1 if an error occurs + * @param[in] marginType The margin type + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult()() method. + * @see SetMargin() + */ + int GetMargin(EditMarginType marginType) const; + + /** + * Sets the margin value for the specified margin type. + * + * @since 2.0 + * + * @return An error code + * @param[in] marginType The margin type + * @param[in] margin The margin value to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c margin cannot be a negative integer. + * @exception E_SYSTEM A system error has occurred. + * @see GetMargin() + */ + result SetMargin(EditMarginType marginType, int margin); + + /** + * Enables or disables the keypad action. + * + * @since 2.0 + * @return An error code + * @param[in] enable Set to @c true to enable the keypad action, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The underlying input method does not support this operation. + * @remarks Depending on the value of input param, the enter key have a enable or disable look accordingly. + */ + result SetKeypadActionEnabled(bool enable); + + /** + * Checks whether the keypad action is enabled. + * + * @since 2.0 + * @return @c true if the keypad action is enabled, @n + * else @c false + */ + bool IsKeypadActionEnabled(void) const; + + /** + * Gets the keypad action type. + * + * @since 2.0 + * + * @return The keypad action + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * This operation is not supported if the input style is not INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult()() method. + */ + Tizen::Ui::KeypadAction GetKeypadAction(void) const; + + /** + * Sets the keypad action type. + * + * @since 2.0 + * + * @return An error code + * @param[in] keypadAction The keypad action + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * This operation is not supported if the input style is not INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + * @remarks Depending on the value of @c keypadAction specified, the enter key label of the keypad will change accordingly. + */ + result SetKeypadAction(Tizen::Ui::KeypadAction keypadAction); + + /** + * Gets the keypad style. + * + * @since 2.0 + * + * @return The keypad style + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetKeypadStyle() + */ + KeypadStyle GetKeypadStyle(void) const; + + /** + * Sets the keypad style. + * + * @since 2.0 + * + * @return An error code + * @param[in] keypadStyle The keypad style + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c keypadStyle cannot be @c KEYPAD_STYLE_PASSWORD. + * @exception E_SYSTEM A system error has occurred. + * @remarks Depending on the value of the specified @c keypadStyle, the keypad's layout will change accordingly. + * @see GetKeypadStyle() + */ + result SetKeypadStyle(KeypadStyle keypadStyle); + + /** + * Checks whether the text prediction is enabled. + * + * @since 2.0 + * @return @c true if the text prediction is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @see SetTextPredictionEnabled() + */ + bool IsTextPredictionEnabled(void) const; + + /** + * Enables or disables the text prediction. + * + * @since 2.0 + * @param[in] enable Set to @c true to enable the text prediction, @n + * else @c false + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @see IsTextPredictionEnabled() + */ + result SetTextPredictionEnabled(bool enable); + + /** + * Sets the visibility of the command buttons of the overlay style keypad. + * + * @since 2.0 + * + * @return An error code + * @param[in] visible Set to @c true to make the overlay keypad command buttons visible, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * This operation is not supported if the input style is not INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + */ + result SetOverlayKeypadCommandButtonVisible(bool visible); + + /** + * Checks whether the command buttons of the overlay style keypad are visible. + * + * @since 2.0 + * + * @return @c true if the overlay command buttons are set to be visible, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * This operation is not supported if the input style is not INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult()() method. + */ + bool IsOverlayCommandButtonVisible(void) const; + + /** + * Hides the keypad. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * This operation is not supported if the input style is not INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + * @see ShowKeypad() + */ + result HideKeypad(void); + + /** + * Gets the text size. + * + * @since 2.0 + * + * @return The size of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextSize() + */ + int GetTextSize(void) const; + + /** + * Sets the text size. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The text size + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c size cannot be a negative integer. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextSize() + */ + result SetTextSize(int size); + + /** + * Gets the color of %EditArea for the specified status. + * + * @since 2.0 + * + * @return The color, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The status + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetColor(EditStatus status) const; + + /** + * Gets the text color of the specified text color type. + * + * @since 2.0 + * + * @return The color, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] type The text color type + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextColor() + */ + Tizen::Graphics::Color GetTextColor(EditTextColor type) const; + + /** + * Sets the background bitmap of the %EditArea control for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status + * @param[in] bitmap The background bitmap + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetBackgroundBitmap(EditStatus status, const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the color of the %EditArea control for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status + * @param[in] color The color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetColor() + */ + result SetColor(EditStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the %EditArea control for the specified text color type. + * + * @since 2.0 + * + * @return An error code + * @param[in] type The text color type + * @param[in] color The text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextColor() + */ + result SetTextColor(EditTextColor type, const Tizen::Graphics::Color& color); + + /** + * Gets a portion of text that is displayed by the %EditArea control. + * + * @since 2.0 + * + * @return The specified portion of the text, @n + * else an empty string if an error occurs + * @param[in] start The starting index of the range + * @param[in] end The last index of the range + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult()() method. + * @see SetText() + */ + Tizen::Base::String GetText(int start, int end) const; + + /** + * Adds the specified keypad event listener. @n + * The added listener is notified when the keypad associated with the %EditArea control is opened or closed. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @see RemoveKeypadEventListener() + */ + void AddKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + + /** + * Removes the specified keypad event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddKeypadEventListener() + */ + void RemoveKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + + /** + * Adds a text block event listener. + * The added listener is notified when the text block is selected. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks Programmatically modifying the text block does not cause the text block selection event to fire. + * @see RemoveTextBlockEventListener() + */ + void AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + /** + * Removes the specified text block event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddTextBlockEventListener() + */ + void RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + /** + * Adds a listener instance. @n + * The added listener can listen to the text related events. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @see RemoveTextEventListener() + */ + void AddTextEventListener(Tizen::Ui::ITextEventListener& listener); + + /** + * Removes a listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see AddTextEventListener() + */ + void RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener); + + /** + * Adds a listener instance to listen to the scroll panel events. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @remarks To listen to scroll panel events, the parent of the %EditArea control must be an instance of ScrollPanel. @n + * When OnOverlayControlCreated() or OnOvelayControlClosed() is called, the application resets the bounds of the controls placed + * within the %ScrollPanel. %ScrollPanel is automatically redrawn after this method is called. + * @see RemoveScrollPanelEventListener() + */ + void AddScrollPanelEventListener(Tizen::Ui::IScrollPanelEventListener& listener); + + /** + * Removes the scroll panel event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see AddScrollPanelEventListener() + */ + void RemoveScrollPanelEventListener(Tizen::Ui::IScrollPanelEventListener& listener); + + /** + * Adds a listener instance. @n + * The added listener is notified when the action event is fire by the command buttons of the keypad. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @see RemoveActionEventListener() + */ + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + + /** + * Removes a listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddActionEventListener() + */ + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * Adds a listener instance for language events. @n + * The added listener is notified when the input language is changed. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @remarks The application can recognize when the language is changed from the keypad by adding Tizen::Ui::ILanguageEventListener. + * @see RemoveLanguageEventListener() + */ + void AddLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + + /** + * Removes the specified listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see AddLanguageEventListener() + */ + void RemoveLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + + /** + * Gets the remaining length of the %EditArea control. + * + * @since 2.0 + * + * @return The remaining length of the %EditArea control, @n + * else @c -1 if an error occurs. + */ + int GetRemainingLength(void) const; + + /** + * Enables or disables the lowercase mode. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable the lowercase mode, @n + * else @c false + */ + void SetLowerCaseModeEnabled(bool enable); + + /** + * Checks whether the lowercase mode is enabled. + * + * @since 2.0 + * + * @return @c true if the lowercase mode is enabled, @n + * else @c false + */ + bool IsLowerCaseModeEnabled(void) const; + + /** + * @if OSPDEPREC + * Sets the input mode category. + * + * @brief [Deprecated] + * @deprecated We no longer provide a method to specify the list of styles which the user can set the keypad to, @n + * or the current mode to initially set the keypad to, from this list. It is recommended to use SetKeypadStyle() method instead. + * @since 2.0 + * + * @return An error code + * @param[in] categories The categories to be set @n + * Multiple input categories can be combined using bitwise OR (see Tizen::Ui::Controls::EditInputModeCategory). + * @param[in] enable The category value to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input mode category is invalid. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation @n + * The specified @c categories cannot be supported with the current keypad style. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetInputModeCategory(unsigned long categories, bool enable); + + /** + * @if OSPDEPREC + * Sets the current input mode category. + * + * @brief [Deprecated] + * @deprecated We no longer provide a method to specify the list of styles which the user can set the keypad to, @n + * or the current mode to initially set the keypad to, from this list. It is recommended to use SetKeypadStyle() method instead. + * @since 2.0 + * + * @return An error code + * @param[in] inputModeCategory An item of input category + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetCurrentInputModeCategory(EditInputModeCategory inputModeCategory); + + /** + * @if OSPDEPREC + * Gets the input mode category. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because we no longer provide a method to specify the list of styles @n + * which the user can set the keypad to. It is recommended to use GetKeypadStyle() method instead. + * @since 2.0 + * + * @return A bitwise combination of Tizen::Ui::Controls::EditInputModeCategory, @n + * else @c EDIT_INPUTMODE_ALPHA if an error occurs + * @endif + */ + unsigned long GetInputModeCategory(void) const; + + /** + * @if OSPDEPREC + * Gets the current input mode category. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because we no longer provide a method to specify the list of styles @n + * which the user can set the keypad to. It is recommended to use GetKeypadStyle() method instead. + * @since 2.0 + * + * @return The current input mode category + * @endif + */ + EditInputModeCategory GetCurrentInputModeCategory(void) const; + + /** + * Sets the cursor at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The cursor position that is to be set + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c position is less than @c 0 or greater than the maximum length. + * @exception E_SYSTEM A system error has occurred. + */ + result SetCursorPosition(int position); + + /** + * Gets the cursor position. + * + * @since 2.0 + * + * @return The current cursor position, @n + * else @c -1 if an error occurs + */ + int GetCursorPosition(void) const; + + /** + * Gets the text that is displayed by the %EditArea control. + * + * @since 2.0 + * + * @return The text of the %EditArea control, @n + * else an empty string if an error occurs + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets the length of the text that is displayed by the %EditArea control. + * + * @since 2.0 + * + * @return The length of the text, @n + * else @c -1 if an error occurs + */ + int GetTextLength(void) const; + + /** + * Sets the text of the %EditArea control. + * + * @since 2.0 + * + * @param[in] text The text that needs to be displayed by the %EditArea control. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The length of the specified @c text exceeds the system limitation or the limit length. + * @exception E_SYSTEM A system error has occurred. + * @remarks Use @htmlonly '\n' @endhtmlonly to denote the end of the line. + */ + result SetText(const Tizen::Base::String& text); + + /** + * Inserts the specified text at the current cursor position. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be inserted + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks Use @htmlonly '\n' @endhtmlonly to denote the end of the line.@n + */ + result InsertTextAtCursorPosition(const Tizen::Base::String& text); + + /** + * Appends the specified text at the end of the existing text. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be appended + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks Use @htmlonly '\n' @endhtmlonly to denote the end of the line.@n + */ + result AppendText(const Tizen::Base::String& text); + + /** + * Appends the specified character at the end of the existing text. + * + * @since 2.0 + * + * @return An error code + * @param[in] character The character to be appended + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %EditArea control. To display the + * changes, the control must be drawn again. + */ + result AppendCharacter(const Tizen::Base::Character& character); + + /** + * Inserts the text that will be displayed by bitmap at the specified text position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position to insert the text + * @param[in] text The text to be inserted + * @param[in] textImage The alternate bitmap to be drawn + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c position is outside the valid range. @n + * Either the specified @c position is greater than the number of existing text in the %EditArea or less than @c 0. + * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the maximum length of the text that can be displayed by %EditArea. + * @remarks The method modifies the text buffer that is managed by the %EditArea control. @n + * To display the changes, the control must be drawn again. The text to be inserted will be displayed by @c textImage. + */ + result InsertTextAt(int position, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& textImage); + + /** + * Appends the text that will be displayed by bitmap at the end of the existing text. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be appended + * @param[in] textImage The alternate bitmap to be drawn + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the maximum length of the text that can be displayed by %EditArea. + * @remarks The method modifies the text buffer that is managed by the %EditArea control. @n + * To display the changes, the control must be drawn again. The text to be appended will be displayed by @c textImage. + */ + result AppendText(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& textImage); + + /** + * Clears the text that is displayed by the %EditArea control. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %EditArea control. To display the + * changes, the control must be drawn again. + */ + result Clear(void); + + /** + * Deletes a character at the current cursor position. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %EditArea control. To display the + * changes, the control must be drawn again. + */ + result DeleteCharacterAtCursorPosition(void); + + /** + * Gets the range of the current text block. + * + * @since 2.0 + * + * @param[out] start The first index of the current text block + * @param[out] end The last index of the current text block + */ + void GetCurrentTextRange(int& start, int& end) const; + + /** + * Displays the guide text when there is no text in the %EditArea control. + * + * @since 2.0 + * + * @param[in] guideText The guide text + * @remarks This is the default text that is displayed in the %EditArea control when the focus is given to it. + */ + void SetGuideText(const Tizen::Base::String& guideText); + + /** + * Gets the guide text. + * + * @since 2.0 + * + * @return The guide text, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetGuideText() + */ + Tizen::Base::String GetGuideText(void) const; + + /** + * Gets the text color of the guide text. + * + * @since 2.0 + * + * @return The guide text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetGuideTextColor() + */ + Tizen::Graphics::Color GetGuideTextColor(void) const; + + /** + * Sets the text color of the guide text. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The guide text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetGuideTextColor() + */ + result SetGuideTextColor(const Tizen::Graphics::Color& color); + + /** + * Enables or disables the keypad. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable the keypad, @n + * else @c false + */ + void SetKeypadEnabled(bool enable); + + /** + * Checks whether the keypad is enabled. + * + * @since 2.0 + * + * @return @c true if the keypad is enabled, @n + * else @c false + */ + bool IsKeypadEnabled(void) const; + + /** + * Shows the keypad. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method is supported only when the input style is INPUT_STYLE_OVERLAY. + */ + result ShowKeypad(void); + + /** + * Gets the line count. + * + * @since 2.0 + * + * @return The line count + */ + int GetTextLineCount(void) const; + + /** + * Gets the range of the current text block. + * + * @since 2.0 + * + * @param[out] start The starting index of the current text block + * @param[out] end The end index of the current text block + */ + void GetBlockRange(int& start, int& end) const; + + /** + * Begins the text block from the current cursor position. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks Move the cursor position to the end of the text block. + * @see SetCursorPosition() + * @see ReleaseBlock() + * @see IsBlocked() + */ + result BeginBlock(void); + + /** + * Releases the text block. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see BeginBlock() + * @see IsBlocked() + */ + result ReleaseBlock(void); + + /** + * Checks whether a portion of the text is blocked. + * + * @since 2.0 + * + * @return @c true if the text is blocked, @n + * else @c false + * @see BeginBlock() + * @see ReleaseBlock() + */ + bool IsBlocked(void) const; + + /** + * Copies the text block to the clipboard. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see Cut(), Paste(), Remove() + */ + result Copy(void); + + /** + * Cuts the text block and copies it to the clipboard. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see Copy(), Remove(), Paste() + */ + result Cut(void); + + /** + * Pastes the copied text at the cursor position. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see Copy(), Cut(), Remove() + */ + result Paste(void); + + /** + * Removes the text that is marked by the text block. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see Copy(), Cut(), Paste() + */ + result Remove(void); + + /** + * Checks whether the text in the %EditArea control has been clipped. + * + * @since 2.0 + * + * @return @c true if the text has been clipped, @n + * else @c false + * @remarks 'Clipped' means that the text has been copied to the clipboard. + * @see Copy(), Cut(), Paste(), Remove() + */ + bool IsClipped(void) const; + + /** + * Sets the command button properties of the keypad. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position of the command button + * @param[in] text The label of the command button + * @param[in] actionId The action ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method is supported when the input style is @c INPUT_STYLE_OVERLAY. + */ + result SetOverlayKeypadCommandButton(CommandButtonPosition position, const Tizen::Base::String& text, int actionId); + + /** + * Gets the text of the specified command button. + * + * @since 2.0 + * + * @return The text of the specified command button + * @param[in] position The position of the command button + * @remarks This method is supported when the input style is @c INPUT_STYLE_OVERLAY. + */ + Tizen::Base::String GetOverlayKeypadCommandButtonText(CommandButtonPosition position) const; + + /** + * Gets the action ID of the specified command button. + * + * @since 2.0 + * + * @return The action ID of the specified command button + * @param[in] position The position of the command button + * @remarks This method is supported when the input style is @c INPUT_STYLE_OVERLAY. + */ + int GetOverlayKeypadCommandButtonActionId(CommandButtonPosition position) const; + + /** + * Sets the input language. + * + * @since 2.0 + * + * @return An error code + * @param[in] languageCode The language to be set + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The application can set the language of the current keypad that is associated with the current %EditArea. @n + * This method only works if the language to set is supported by the current preloaded keypad. + */ + result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode); + + /** + * Gets the current input language. + * + * @since 2.0 + * + * @return An error code + * @param[out] language The current input language + * @exception E_SUCCESS The method is successful. + * @remarks The application can get the current language of the keypad that is associated with the current %EditArea. + */ + result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const; + +protected: + friend class _EditAreaImpl; + +private: + EditArea(const EditArea&); + EditArea& operator =(const EditArea&); +}; // EditArea + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_EDIT_AREA_H_ diff --git a/inc/FUiCtrlEditDate.h b/inc/FUiCtrlEditDate.h new file mode 100644 index 0000000..827aede --- /dev/null +++ b/inc/FUiCtrlEditDate.h @@ -0,0 +1,337 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlEditDate.h + * @brief This is the header file for the %EditDate class. + * + * This header file contains the declarations of the %EditDate class. + */ +#ifndef _FUI_CTRL_EDITDATE_H_ +#define _FUI_CTRL_EDITDATE_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class EditDate + * @brief This class defines the common behavior of an %EditDate control. + * + * @since 2.0 + * + * The %EditDate class displays a small, fixed-size selector that allows the user to select a date. Unlike the DatePicker, %EditDate can be placed in a container. + * + * For more information on the class features, see EditDate and EditTime. + * + * The following example demonstrates how to use the %EditDate class. + * + * @code +// Sample code for EditDateSample.h +#include + +class EditDateSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IDateChangeEventListener +{ +public: + EditDateSample(void) + : __pEditDate(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + // IDateChangeEventListener + virtual void OnDateChanged(const Tizen::Ui::Control& source, int year, int month, int day); + virtual void OnDateChangeCanceled(const Tizen::Ui::Control& source); + +private: + Tizen::Ui::Controls::EditDate* __pEditDate; +}; + + * @endcode + * + * @code +// Sample code for EditDateSample.cpp +#include + +#include "EditDateSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +EditDateSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +EditDateSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of EditDate + __pEditDate = new EditDate(); + __pEditDate->Construct(Point(100, 100)); + __pEditDate->AddDateChangeEventListener(*this); + + // Adds an instace of IDateChangeEventListener + AddControl(*__pEditDate); + + return r; +} + +// IDateChangeEventListener implementation +void +EditDateSample::OnDateChanged(const Tizen::Ui::Control& source, int year, int month, int day) +{ + // .... +} + +void +EditDateSample::OnDateChangeCanceled(const Tizen::Ui::Control& source) +{ + // .... +} + * @endcode + */ +class _OSP_EXPORT_ EditDate + : public Tizen::Ui::Control +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + EditDate(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~EditDate(void); + + /** + * Adds a data change event listener instance. + * Added listener is called when the date of the DatePicker is changed either through user manipulation or by calling one of its setters. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @see IDateChangeEventListener::OnDateChanged() + * @see IDateChangeEventListener::OnDateChangeCanceled() + * @see RemoveDateChangeEventListener() + */ + void AddDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener); + + /** + * Removes a date changed event listener instance. @n + * Removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see IDateChangeEventListener::OnDateChanged() + * @see IDateChangeEventListener::OnDateChangeCanceled() + * @see AddDateChangeEventListener() + */ + void RemoveDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener); + + /** + * Initializes this instance of %EditDate with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The position of the %EditDate in the container + * @param[in] title The title + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully usable only after it has been added to a container, therefore, some methods may fail if used earlier. + */ + result Construct(const Tizen::Graphics::Point& point, const Tizen::Base::String& title = L""); + + /** + * Gets the current date value of the %EditDate control. + * + * @since 2.0 + * + * @return The date value + */ + Tizen::Base::DateTime GetDate(void) const; + + /** + * Gets the current day value of the %EditDate control. + * + * @since 2.0 + * + * @return The current day value as an integer, @n + * else @c -1 if the %EditDate instance is not constructed + */ + int GetDay(void) const; + + /** + * Gets the current month value of the %EditDate control. + * + * @since 2.0 + * + * @return The current month value as an integer, @n + * else @c -1 if the %EditDate instance is not constructed + */ + int GetMonth(void) const; + + /** + * Gets the current year value of the %EditDate control. + * + * @since 2.0 + * + * @return The current year value, @n + * else @c -1 if the %EditDate instance is not constructed + */ + int GetYear(void) const; + + /** + * Sets the designated time value of the %EditDate control. + * + * @since 2.0 + * + * @param[in] date The date to be set + */ + void SetDate(const Tizen::Base::DateTime& date); + + /** + * Sets the value of the %EditDate control using the current system date. + * + * @since 2.0 + */ + void SetCurrentDate(void); + + /** + * Sets the year value. + * The year value should be between @c 1 and @c 9999. + * + * @since 2.0 + * + * @return An error code + * @param[in] year The year to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The given year value is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetYear(int year); + + /** + * Sets the month value of the %EditDate control. + * The month value should be between @c 1 and @c 12. + * + * @since 2.0 + * + * @return An error code + * @param[in] month The month to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The given month value is invalid. + * @exception E_SYSTEM A system error has occurred. + * + */ + result SetMonth(int month); + + /** + * Sets the day value of the %EditDate control. + * The day value should be between @c 1 and @c 31. + * + * @since 2.0 + * + * @return An error code + * @param[in] day The day to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The given day value is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetDay(int day); + + /** + * Enables the %DatePicker control. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable the DatePicker control, @n + * else @c false + */ + void SetDatePickerEnabled(bool enable); + + /** + * Checks whether the DatePicker control is enabled. + * + * @since 2.0 + * + * @return @c true if the DatePicker control is enabled, @n + * else @c false + */ + bool IsDatePickerEnabled(void) const; + + /** + * Sets the valid year range. @n + * The range should be set in between @c 1 and @c 9999. + * + * @since 2.0 + * + * @return An error code + * @param[in] minYear The minimum year for the valid range + * @param[in] maxYear The maximum year for the valid range + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The given year range is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetYearRange(int minYear, int maxYear); + + /** + * Gets the valid year range. + * + * @since 2.0 + * + * @return An error code + * @param[out] minYear The minimum year for the valid range + * @param[out] maxYear The maximum year for the valid range + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result GetYearRange(int& minYear, int& maxYear) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + EditDate(const EditDate& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + EditDate& operator =(const EditDate& rhs); + + friend class _EditDateImpl; +}; // EditDate + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_EDITDATE_H_ diff --git a/inc/FUiCtrlEditField.h b/inc/FUiCtrlEditField.h new file mode 100644 index 0000000..4eb2d6b --- /dev/null +++ b/inc/FUiCtrlEditField.h @@ -0,0 +1,1307 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlEditField.h + * @brief This is the header file for the %EditField class. + * + * This header file contains the declarations of the %EditField class and its helper classes. + */ + +#ifndef _FUI_CTRL_EDIT_FIELD_H_ +#define _FUI_CTRL_EDIT_FIELD_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Locales +{ +class Locale; +}} + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class EditField + * @brief This class defines a common behavior for an %EditField control. + * + * @since 2.0 + * + * The %EditField class displays a single-line text editor. + * + * For more information on the class features, see EditArea and EditField. + * + * The following example demonstrates how to use the %EditField class. + * + * @code +// Sample code for EditFieldSample.h +#include + +class EditFieldSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::ITextEventListener +{ +public: + EditFieldSample(void) + : __pEditField(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + // ITextEventListener + virtual void OnTextValueChanged(const Tizen::Ui::Control& source); + virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source); + +private: + Tizen::Ui::Controls::EditField* __pEditField; +}; + * @endcode + * + * @code +// Sample code for EditFieldSample.cpp +#include + +#include "EditFieldSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +EditFieldSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +EditFieldSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of EditField + __pEditField = new EditField(); + __pEditField->Construct(Rectangle(50, 100, 400, 150)); + __pEditField->AddTextEventListener(*this); + + //Adds the edit field to the Form + AddControl(*__pEditField); + + return r; +} + +// ITextEventListener implementation +void +EditFieldSample::OnTextValueChanged(const Tizen::Ui::Control& source) +{ + // .... +} + +void +EditFieldSample::OnTextValueChangeCanceled(const Tizen::Ui::Control& source) +{ + // .... +} + * @endcode + * + */ + +class _OSP_EXPORT_ EditField + : public Tizen::Ui::Control +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + EditField(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~EditField(void); + + /** + * Initializes this instance of the %EditField control with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created window along with + * the width and height of the control. + * @param[in] style The style of the %EditField control + * @param[in] inputStyle The input style of the %EditField control + * @param[in] showTitle Set to @c true to display the title, @n + * else @c false + * @param[in] limitLength The limit for the length of the text in the %EditField control + * @param[in] groupStyle The table view style of the %EditField control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c limitLength is less than or equal to @c 0, or @n + * either the @c rect.width or the @c rect.height is less than @c 0. + * @exception E_UNSUPPORTED_OPTION The specified option is not supported. @n + * The title is not supported by small style %EditField. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully usable only after it has been added to a container. Therefore, some methods may fail if the control has been used + * earlier. The %EditField style of SMALL property cannot be used together with group styles. @n + * If the specified size is less than the minimum size, %EditField is constructed with the minimum size. + * @remarks Following are the input styles used for creating the different orientations of a keypad: @n + * - INPUT_STYLE_FULLSCREEN: The orientation is decided by the G-sensor value. @n + * - INPUT_STYLE_OVERLAY: The orientation is the same as that of a parent form. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, EditFieldStyle style = EDIT_FIELD_STYLE_NORMAL, InputStyle inputStyle = INPUT_STYLE_FULLSCREEN, bool showTitle = false, int limitLength = 100, GroupStyle groupStyle = GROUP_STYLE_NONE); + + /** + * Initializes this instance of the %EditField control. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The bounds of %EditField + * @param[in] style The style of the %EditField control + * @param[in] inputStyle The input style of the %EditField control + * @param[in] titleStyle The title style + * @param[in] enableClear Set to @c true to enable the clear button, @n + * else @c false + * @param[in] limitLength The limit of the length of text in the %EditField control + * @param[in] groupStyle The table view style of the %EditField control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c limitLength is less than or equal to @c 0. @n + * The specified @c rect.width or the @c rect.height is less than @c 0. + * @exception E_UNSUPPORTED_OPTION The specified option is not supported. @n + * Title is not supported in small style %EditField. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully usable only after it has been added to a container. Therefore, some methods may fail if the control is used earlier. + * The %EditField style of SMALL property cannot be used together with group styles. @n + * If the specified size is less than the minimum size, EditFied() is constructed with the minimum size. + * @remarks Following are the input styles used for creating different orientations of a keypad: @n + * - INPUT_STYLE_FULLSCREEN: The orientation is decided by the G-sensor value.@n + * - INPUT_STYLE_OVERLAY: The orientation is similar to the parent Form. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, EditFieldStyle style, InputStyle inputStyle, EditFieldTitleStyle titleStyle, bool enableClear = false, int limitLength = 100, GroupStyle groupStyle = GROUP_STYLE_NONE); + +public: + /** + * Gets the horizontal text alignment of the %EditField control. + * + * @since 2.0 + * + * @return The horizontal text alignment + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextAlignment() + */ + HorizontalAlignment GetTextAlignment(void) const; + + /** + * Sets the horizontal text alignment of the %EditField control. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextAlignment() + */ + result SetTextAlignment(HorizontalAlignment alignment); + + /** + * Checks whether the view mode is enabled. + * + * @since 2.0 + * + * @return @c true if the view mode is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * In the view mode, the auto-detected links are displayed as linked text. + * @see SetViewModeEnabled() + */ + bool IsViewModeEnabled(void) const; + + /** + * Enables or disables the view mode. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the view mode, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks In the view mode, the auto-detected links are displayed as linked text. + * @see IsViewModeEnabled() + */ + result SetViewModeEnabled(bool enable); + + /** + * Sets the auto-link mask. + * + * @since 2.0 + * + * @return An error code + * @param[in] autoLinks The auto-link mask @n + * Multiple link types can be combined using bitwise OR operator (see Tizen::Base::Utility::LinkType). @n + * For more information, see AutoLink Detection. + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation @n + * The input style is not @c INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + * @remarks When @c autoLinks is set to @c 0, the auto-link detection is disabled. + * @see Tizen::Base::Utility::LinkType + * @see GetAutoLinkMask() + * @see IsViewModeEnabled() + * @see SetViewModeEnabled() + */ + result SetAutoLinkMask(unsigned long autoLinks); + + /** + * Gets the auto-link mask. + * + * @since 2.0 + * + * @return The auto-link mask + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation @n + * The input style is not @c INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetAutoLinkMask() + */ + unsigned long GetAutoLinkMask(void) const; + + /** + * Adds a link event listener. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks This method is supported when the input style is @c INPUT_STYLE_OVERLAY. @n + * The added listener is notified when the links are selected by the user. + * @see RemoveUiLinkEventListener() + */ + void AddUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + /** + * Removes the specified link event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @remarks This method is supported when the input style is @c INPUT_STYLE_OVERLAY. + * @see AddUiLinkEventListener() + */ + void RemoveUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + /** + * Gets the margin value of the specified margin type. + * + * @since 2.0 + * + * @return The margin value of the specified margin type, @n + * else @c -1 if an error occurs + * @param[in] marginType The margin type + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetMargin() + */ + int GetMargin(EditMarginType marginType) const; + + /** + * Sets the margin for the specified margin type. + * + * @since 2.0 + * + * @return An error code + * @param[in] marginType The margin type + * @param[in] margin The margin to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c margin cannot be a negative integer. + * @exception E_SYSTEM A system error has occurred. + * @see GetMargin() + */ + result SetMargin(EditMarginType marginType, int margin); + + /** + * Enables or disables the keypad action. + * + * @since 2.0 + * @return An error code + * @param[in] enable Set to @c true to enable the keypad action, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The underlying input method does not support this operation. + * @remarks Depending on the value of input param, the enter key have a enable or disable look accordingly. + */ + result SetKeypadActionEnabled(bool enable); + + /** + * Checks whether the keypad action is enabled. + * + * @since 2.0 + * @return @c true if the keypad action is enabled, @n + * else @c false + */ + bool IsKeypadActionEnabled(void) const; + + /** + * Gets the keypad action type. + * + * @since 2.0 + * + * @return The keypad action + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The input style is not @c INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetKeypadAction() + */ + Tizen::Ui::KeypadAction GetKeypadAction(void) const; + + /** + * Sets the keypad action type. + * + * @since 2.0 + * + * @return An error code + * @param[in] keypadAction The keypad action + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The input style is not @c INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + * @remarks Based on the specified value of @c keypadAction, the enter key label of the keypad changes accordingly. + * @see GetKeypadAction() + */ + result SetKeypadAction(Tizen::Ui::KeypadAction keypadAction); + + /** + * Sets the visibility of the command buttons of the overlay style keypad. + * + * @since 2.0 + * + * @return An error code + * @param[in] visible Set to @c true to set the visibility of the overlay keypad command buttons, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The input style is not @c INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + */ + result SetOverlayKeypadCommandButtonVisible(bool visible); + + /** + * Checks whether the command buttons of the overlay style keypad are visible. + * + * @since 2.0 + * + * @return @c true if the overlay command buttons are visible, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The input style is not @c INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + bool IsOverlayCommandButtonVisible(void) const; + + /** + * Hides the keypad. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The input style is not @c INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error has occurred. + * @see ShowKeypad() + */ + result HideKeypad(void); + + /** + * Gets the position of the ellipsis. + * + * @since 2.0 + * + * @return The ellipsis position + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetEllipsisPosition() + */ + EllipsisPosition GetEllipsisPosition(void) const; + + /** + * Sets the position of the ellipsis. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The ellipsis position + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetEllipsisPosition() + */ + result SetEllipsisPosition(EllipsisPosition position); + + /** + * Gets the text size. + * + * @since 2.0 + * + * @return The size of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextSize() + */ + int GetTextSize(void) const; + + /** + * Sets the text size. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The text size + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The @c size cannot be a negative integer. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextSize() + */ + result SetTextSize(int size); + + /** + * Gets the color of the %EditField control for the specified status. + * + * @since 2.0 + * + * @return The color, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The status + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetColor(EditStatus status) const; + + /** + * Gets the text color of the specified text color type. + * + * @since 2.0 + * + * @return The color, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] type The text color type + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextColor() + */ + Tizen::Graphics::Color GetTextColor(EditTextColor type) const; + + /** + * Sets the background bitmap of the %EditField control for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status + * @param[in] bitmap The background bitmap + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetBackgroundBitmap(EditStatus status, const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the color of the %EditField control for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status + * @param[in] color The color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetColor() + */ + result SetColor(EditStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the %EditField control for the specified text color type. + * + * @since 2.0 + * + * @return An error code + * @param[in] type The text color type + * @param[in] color The text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextColor() + */ + result SetTextColor(EditTextColor type, const Tizen::Graphics::Color& color); + + /** + * Gets a portion of text that is displayed by the %EditField control. + * + * @since 2.0 + * + * @return The specified portion of the text, @n + * else an empty string if an error occurs + * @param[in] start The starting index of the range + * @param[in] end The last index of the range + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or @n + * the index is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetText() + */ + Tizen::Base::String GetText(int start, int end) const; + + /** + * Adds a keypad event listener. @n + * The added listener is notified when the keypad associated with the %EditField control is opened or closed. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @see RemoveKeypadEventListener() + */ + void AddKeypadEventListener(IKeypadEventListener& listener); + + /** + * Removes the specified keypad event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddKeypadEventListener() + */ + void RemoveKeypadEventListener(IKeypadEventListener& listener); + + /** + * Adds a text block event listener. @n + * The added listener is notified when the text block is selected. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks Programmatically modifying the text block does not cause the text block selection event to fire. + * @see RemoveTextBlockEventListener() + */ + void AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + /** + * Removes the specified text block event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddTextBlockEventListener() + */ + void RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + /** + * Adds the ITextEventListener instance. @n + * The added listener listens to events on the context of the specified event dispatcher when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + */ + void AddTextEventListener(Tizen::Ui::ITextEventListener& listener); + + /** + * Removes the ITextEventListener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + */ + void RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener); + + /** + * Adds the specified listener instance to listen to the scroll panel events. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @remarks To listen to the scroll panel events, the parent of EditArea must be an instance of ScrollPanel. @n + * When OnOverlayControlCreated() or OnOvelayControlClosed() is called, the application resets the bounds of the controls placed + * within the ScrollPanel control. ScrollPanel is automatically drawn again after this method is called. + * @see RemoveScrollPanelEventListener() + */ + void AddScrollPanelEventListener(Tizen::Ui::IScrollPanelEventListener& listener); + + /** + * Removes the specified scroll panel event listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + */ + void RemoveScrollPanelEventListener(Tizen::Ui::IScrollPanelEventListener& listener); + + /** + * Adds the specified listener instance. @n + * The added listener can listen to events on the context of the given event dispatcher when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + */ + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * Removes a listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to remove + */ + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * Adds the specified listener instance for language events. @n + * The added listener is notified when the input language is changed. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @remarks The application can recognize when the language is changed from the keypad by adding Tizen::Ui::ILanguageEventListener. + * @see RemoveLanguageEventListener() + */ + void AddLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + + /** + * Removes the specified listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see AddLanguageEventListener() + */ + void RemoveLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + + /** + * Gets the remaining length of the %EditField control. + * + * @since 2.0 + * + * @return The remaining length of the %EditField control, @n + * else @c -1 if an error occurs + */ + int GetRemainingLength(void) const; + + /** + * Enables or disables the lowercase mode. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable the lowercase mode, @n + * else @c false + */ + void SetLowerCaseModeEnabled(bool enable); + + /** + * Checks whether the lowercase mode is enabled. + * + * @since 2.0 + * + * @return @c true if the lowercase mode is enabled, @n + * else @c false + */ + bool IsLowerCaseModeEnabled(void) const; + + /** + * @if OSPDEPREC + * Sets the input mode category. + * + * @brief [Deprecated] + * @deprecated We no longer provide a method to specify the list of styles which the user can set the keypad to, @n + * or the current mode to initially set the keypad to, from this list. It is recommended to use EditFieldStyle in the Construct() method instead. + * @since 2.0 + * + * @return An error code + * @param[in] categories The categories to be set @n + * Multiple input categories can be combined using bitwise OR operator (see Tizen::Ui::Controls::EditInputModeCategory). + * @param[in] enable The category value to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input mode category is invalid. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation @n + * The specified @c categories cannot be supported with the current keypad style. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetInputModeCategory(unsigned long categories, bool enable); + + /** + * @if OSPDEPREC + * Sets the current input mode category. + * + * @brief [Deprecated] + * @deprecated We no longer provide a method to specify the list of styles which the user can set the keypad to, @n + * or the current mode to initially set the keypad to, from this list. It is recommended to use EditFieldStyle in the Construct() method instead. + * @since 2.0 + * + * @return An error code + * @param[in] inputModeCategory An item of input category + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetCurrentInputModeCategory(EditInputModeCategory inputModeCategory); + + /** + * @if OSPDEPREC + * Gets the input mode category. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because we no longer provide a method to specify the list of styles which the user can set the keypad to. + * @since 2.0 + * + * @return A bitwise combination of Tizen::Ui::Controls::EditInputModeCategory, @n + * else EDIT_INPUTMODE_ALPHA if an error occurs + * @endif + */ + unsigned long GetInputModeCategory(void) const; + + /** + * @if OSPDEPREC + * Gets the current input mode category. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because we no longer provide a method to specify the list of styles which the user can set the keypad to. + * @since 2.0 + * + * @return The current input mode category + * @endif + */ + EditInputModeCategory GetCurrentInputModeCategory(void) const; + + /** + * Sets the cursor in the %EditField control at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The cursor position that is to be set + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c position is less than @c 0 or greater than the maximum length. + * @exception E_SYSTEM A system error has occurred. + */ + result SetCursorPosition(int position); + + /** + * Gets the cursor position. + * + * @since 2.0 + * + * @return The current cursor position, @n + * else @c -1 if an error occurs + */ + int GetCursorPosition(void) const; + + /** + * Gets the text that is displayed by the %EditField control. + * + * @since 2.0 + * + * @return The text of the %EditField control, @n + * else an empty string if an error occurs + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets the length of the text that is displayed by the %EditField control. + * + * @since 2.0 + * + * @return The length of the text, @n + * else @c -1 if an error occurs + */ + int GetTextLength(void) const; + + /** + * Sets the text of the %EditField control. + * + * @since 2.0 + * + * @param[in] text The text to be displayed by the %EditField control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The length of the specified @c text exceeds the system limitation or the limit length. + * @exception E_SYSTEM A system error has occurred. + * @remarks Use @htmlonly '\n' @endhtmlonly to denote the end of the line. + */ + result SetText(const Tizen::Base::String& text); + + /** + * Inserts the specified text at the current cursor position. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be inserted + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks Use @htmlonly '\n' @endhtmlonly to denote the end of the line. + */ + result InsertTextAtCursorPosition(const Tizen::Base::String& text); + + /** + * Appends the specified text at the end of the existing text. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be appended + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks Use @htmlonly '\n' @endhtmlonly to denote the end of the line. + */ + result AppendText(const Tizen::Base::String& text); + + /** + * Appends the specified character at the end of the existing text. + * + * @since 2.0 + * + * @return An error code + * @param[in] character The character to be appended + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %EditField control. To display the + * changes, the control must be drawn again. + */ + result AppendCharacter(const Tizen::Base::Character& character); + + /** + * Clears the text that is displayed by the %EditField control. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %EditField control. To display the + * changes, the control must be drawn again. + */ + result Clear(void); + + /** + * Deletes a character at the current cursor position. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %EditField control. To display the + * changes, the control must be drawn again. + */ + result DeleteCharacterAtCursorPosition(void); + + /** + * Gets the range of the current text block. + * + * @since 2.0 + * + * @param[out] start The first index of the current text block + * @param[out] end The last index of the current text block + */ + void GetCurrentTextRange(int& start, int& end) const; + + /** + * Sets the guide text. + * + * @since 2.0 + * + * @param[in] guideText The guide text + * @remarks This is the default text that is displayed in the %EditField + * control when the focus is given to it and no text is entered. + */ + void SetGuideText(const Tizen::Base::String& guideText); + + /** + * Gets the guide text. + * + * @since 2.0 + * + * @return The guide text, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetGuideText() + */ + Tizen::Base::String GetGuideText(void) const; + + /** + * Gets the text color of the guide text. + * + * @since 2.0 + * + * @return The guide text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetGuideTextColor() + */ + Tizen::Graphics::Color GetGuideTextColor(void) const; + + /** + * Sets the text color of the guide text. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The guide text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetGuideTextColor() + */ + result SetGuideTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the text color of the title for the specified status. + * + * @since 2.0 + * + * @return The title text color, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The state of the %EditField control + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTitleTextColor() + */ + Tizen::Graphics::Color GetTitleTextColor(EditStatus status) const; + + /** + * Sets the text color of the title for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The state of the %EditField control + * @param[in] color The title text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetTitleTextColor() + */ + result SetTitleTextColor(EditStatus status, const Tizen::Graphics::Color& color); + + /** + * Enables or disables the keypad. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable the keypad, + * else @c false + */ + void SetKeypadEnabled(bool enable); + + /** + * Checks whether the keypad is enabled. + * + * @since 2.0 + * + * @return @c true if the keypad is enabled, @n + * else @c false + */ + bool IsKeypadEnabled(void) const; + + /** + * Checks whether the text prediction is enabled. + * + * @since 2.0 + * @return @c true if the text prediction is enabled, @n + * else @c false + * @see SetTextPredictionEnabled() + */ + bool IsTextPredictionEnabled(void) const; + + /** + * Enables or disables the text prediction. + * + * @since 2.0 + * @param[in] enable Set to @c true to enable the text prediction, @n + * else @c false + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @see IsTextPredictionEnabled() + */ + result SetTextPredictionEnabled(bool enable); + + /** + * Displays the keypad. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method is supported only when the input style is INPUT_STYLE_OVERLAY. + */ + result ShowKeypad(void); + + /** + * Gets the range of the current text block that is selected. + * + * @since 2.0 + * + * @param[out] start The starting index of the current block + * @param[out] end The end index of the current block + */ + void GetBlockRange(int& start, int& end) const; + + /** + * Begins the text block from the current cursor position. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks Move the cursor position to the end of the text block. + * @see SetCursorPosition() + * @see ReleaseBlock() + * @see IsBlocked() + */ + result BeginBlock(void); + + /** + * Releases the selection of the current text block. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see BeginBlock() + * @see IsBlocked() + */ + result ReleaseBlock(void); + + /** + * Checks whether a portion of the text is blocked. + * + * @since 2.0 + * + * @return @c true if the text is blocked, @n + * else @c false + * @see BeginBlock() + * @see ReleaseBlock() + */ + bool IsBlocked(void) const; + + /** + * Copies the text block to the clipboard. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see Cut(), Paste(), Remove() + */ + result Copy(void); + + /** + * Cuts the text block and copies it to the clipboard. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see Copy(), Remove(), Paste() + */ + result Cut(void); + + /** + * Pastes the copied text at the cursor position. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see Copy(), Cut(), Remove() + */ + result Paste(void); + + /** + * Removes the text that is marked by the text block. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see Copy(), Cut(), Paste() + */ + result Remove(void); + + /** + * Checks whether the text in the %EditField control is clipped. + * + * @since 2.0 + * + * @return @c true if the text is clipped, @n + * else @c false + * @remarks 'clipped' means that the text is copied to the clipboard. + * @see Copy(), Cut(), Paste(), Remove() + */ + bool IsClipped(void) const; + + /** + * Sets the title of the %EditField control. + * + * @since 2.0 + * + * @return An error code + * @param[in] title The title to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTitleText(const Tizen::Base::String& title); + + /** + * Gets the title text of the %EditField control. + * + * @since 2.0 + * + * @return The title text, @n + * else an empty string if an error occurs + */ + Tizen::Base::String GetTitleText(void) const; + + /** + * Sets the command button properties of the keypad. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position of the command button + * @param[in] text The label of the command button + * @param[in] actionId The action ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method is supported only when the input style is INPUT_STYLE_OVERLAY. + */ + result SetOverlayKeypadCommandButton(CommandButtonPosition position, const Tizen::Base::String& text, int actionId); + + /** + * Gets the text of the specified command button. + * + * @since 2.0 + * + * @return The text of the specified command button + * @param[in] position The position of the command button + * @remarks This method is supported only when the input style is INPUT_STYLE_OVERLAY. + */ + Tizen::Base::String GetOverlayKeypadCommandButtonText(CommandButtonPosition position) const; + + /** + * Gets the action ID of the specified command button. + * + * @since 2.0 + * + * @return The action ID of the specified command button + * @param[in] position The position of the command button + * @remarks This method is supported only when the input style is INPUT_STYLE_OVERLAY. + */ + int GetOverlayKeypadCommandButtonActionId(CommandButtonPosition position) const; + + /** + * Sets the input language. + * + * @since 2.0 + * + * @return An error code + * @param[in] languageCode The language to be set + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The application can set the language of the current keypad that is associated with the current %EditField. @n + * This method only works if the language to set is supported by the current preloaded keypad. + */ + result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode); + + /** + * Gets the current input language. + * + * @since 2.0 + * + * @return An error code + * @param[out] language The current input language + * @exception E_SUCCESS The method is successful. + * @remarks The application can get the current language of the keypad that is associated with the current %EditField. + */ + result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const; + +protected: + friend class _EditFieldImpl; + +private: + EditField(const EditField&); + EditField& operator =(const EditField&); + +}; // EditField + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_EDIT_FIELD_H_ diff --git a/inc/FUiCtrlEditTime.h b/inc/FUiCtrlEditTime.h new file mode 100644 index 0000000..178efa6 --- /dev/null +++ b/inc/FUiCtrlEditTime.h @@ -0,0 +1,292 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlEditTime.h + * @brief This is the header file for the %EditTime class. + * + * This header file contains the declarations of the %EditTime class. + */ +#ifndef _FUI_CTRL_EDIT_TIME_H_ +#define _FUI_CTRL_EDIT_TIME_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class EditTime + * @brief This class defines the common behavior of an %EditTime control. + * + * @since 2.0 + * + * The %EditTime class displays a small, fixed-size selector that allows the user to select a time. + * Unlike TimePicker, %EditTime can be placed in a container. + * + * For more information on the class features, see EditDate and EditTime. + * + * The following example demonstrates how to use the %EditTime class. + * + * @code +// Sample code for EditTimeSample.h +#include + +class EditTimeSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::ITimeChangeEventListener +{ +public: + EditTimeSample(void) + : __pEditTime(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + // ITimeChangeEventListener + virtual void OnTimeChanged(const Tizen::Ui::Control& source, int hour, int minute); + virtual void OnTimeChangeCanceled(const Tizen::Ui::Control& source); + +private: + Tizen::Ui::Controls::EditTime* __pEditTime; +}; + * @endcode + * + * @code +// Sample code for EditTimeSample.cpp +#include + +#include "EditTimeSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +EditTimeSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +EditTimeSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of EditTime + __pEditTime = new EditTime(); + __pEditTime->Construct(Point(100, 100)); + __pEditTime->AddTimeChangeEventListener(*this); + + //Adds the edit time to the form + AddControl(*__pEditTime); + + return r; +} + +// ITimeChangeEventListener implementation +void +EditTimeSample::OnTimeChanged(const Control& source, int hour, int minute) +{ + // .... +} + +void +EditTimeSample::OnTimeChangeCanceled(const Control& source) +{ + // .... +} + * @endcode + */ +class _OSP_EXPORT_ EditTime + : public Tizen::Ui::Control +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + EditTime(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~EditTime(void); + + /** + * Adds a time changed event listener instance. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @see ITimeChangeEventListener::OnTimeChanged() + * @see ITimeChangeEventListener::OnTimeChangeCanceled() + * @see RemoveTimeChangeEventListener() + */ + void AddTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener); + + /** + * Removes a listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see AddTimeChangeEventListener() + */ + void RemoveTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener); + + /** + * Initializes this instance of %EditTime with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] point The position of %EditTime in container + * @param[in] title The title + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Graphics::Point& point, const Tizen::Base::String& title = L""); + + /** + * Gets the current hour value of the %EditTime control. + * + * @since 2.0 + * + * @return The current hour value, @n + * else @c -1 if the %EditTime instance is not constructed @n + * The hour value is between @c 0 to @c 23. + */ + int GetHour(void) const; + + /** + * Gets the current minute value of the %EditTime control. + * + * @since 2.0 + * + * @return The current minute value, @n + * else @c -1 if this %EditTime instance is not constructed + */ + int GetMinute(void) const; + + /** + * Gets the current time value of the %EditTime control. + * + * @since 2.0 + * + * @return The time value + */ + Tizen::Base::DateTime GetTime(void) const; + + /** + * Sets the 12-hour or 24-hour display type of the %EditTime. @n + * This can be 12-hour or 24-hour type. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to set the 24-hour notation, @n + * else @c false to set the 12-hour notation + */ + void Set24HourNotationEnabled(bool enable); + + /** + * Sets the hour value of the %EditTime control. @n + * The hour value should be between @c 0 and @c 23. + * + * @since 2.0 + * + * @param[in] hour The hour value to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified hour value is invalid. + * @exception E_SYSTEM A system error has occurred. + * + */ + result SetHour(int hour); + + /** + * Sets the minute value of the %EditTime control. @n + * The minute value should be between @c 0 and @c 59. + * + * @since 2.0 + * + * @param[in] minute The minute value to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified minute value is invalid. + * @exception E_SYSTEM A system error has occurred. + * + */ + result SetMinute(int minute); + + /** + * Sets the designated time value of the %EditTime control. + * + * @since 2.0 + * + * @param[in] time The time to be set + */ + void SetTime(const Tizen::Base::DateTime& time); + + /** + * Sets the value of the %EditTime control using the current system time. + * + * @since 2.0 + */ + void SetCurrentTime(void); + + /** + * Enables TimePicker. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable %TimePicker, @n + * else @c false + */ + void SetTimePickerEnabled(bool enable); + + /** + * Checks whether TimePicker is enabled. + * + * @since 2.0 + * + * @return @c true if TimePicker is enabled, @n + * else @c false + */ + bool IsTimePickerEnabled(void) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + EditTime(const EditTime& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + EditTime& operator =(const EditTime& rhs); + + friend class _EditTimeImpl; +}; // EditTime + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_EDIT_TIME_H_ diff --git a/inc/FUiCtrlEditTypes.h b/inc/FUiCtrlEditTypes.h new file mode 100644 index 0000000..16e9c92 --- /dev/null +++ b/inc/FUiCtrlEditTypes.h @@ -0,0 +1,180 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlEditTypes.h + * @brief This is the header file for the Ui::Controls edit control enumerations. + * + * This header file contains the declarations of the Ui::Controls edit control enumerations. + */ +#ifndef _FUI_CTRL_EDIT_ENUM_H_ +#define _FUI_CTRL_EDIT_ENUM_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if OSPDEPREC + * @enum EditInputModeCategory + * + * Defines the input modes. + * + * @brief [Deprecated] + * @deprecated We no longer provide a method to specify the list of styles which the user can set the keypad to, or the current mode to initially set the keypad to, @n + * from this list. It is recommended to use the styles offered in EditFieldStyle or KeypadStyle enumerations instead. + * @since 2.0 + * @endif + */ +enum EditInputModeCategory +{ + EDIT_INPUTMODE_ALPHA = 0x0001, /**< @if OSPDEPREC The alphabetic input mode @endif */ + EDIT_INPUTMODE_PREDICTIVE = 0x0002, /**< @if OSPDEPREC The predictive input mode @endif */ + EDIT_INPUTMODE_NUMERIC = 0x0004, /**< @if OSPDEPREC The numeric input mode @endif */ + EDIT_INPUTMODE_SYMBOL = 0x0008 /**< @if OSPDEPREC The symbolic input mode @endif */ +}; + +/** + * @enum EditFieldStyle + * + * Defines the EditField style. + * + * @since 2.0 + */ +enum EditFieldStyle +{ + EDIT_FIELD_STYLE_NORMAL, /**< The normal style */ + EDIT_FIELD_STYLE_PASSWORD, /**< The password style '****' */ + EDIT_FIELD_STYLE_NORMAL_SMALL, /**< The small normal style */ + EDIT_FIELD_STYLE_PASSWORD_SMALL, /**< The small password style '****' */ + EDIT_FIELD_STYLE_EMAIL, /**< The email style */ + EDIT_FIELD_STYLE_URL, /**< The URL style */ + EDIT_FIELD_STYLE_EMAIL_SMALL, /**< The small email style */ + EDIT_FIELD_STYLE_URL_SMALL, /**< The small URL style */ + EDIT_FIELD_STYLE_NUMBER, /**< The number style */ + EDIT_FIELD_STYLE_NUMBER_SMALL, /**< The small number style */ + EDIT_FIELD_STYLE_PHONE_NUMBER, /**< The phone number style */ + EDIT_FIELD_STYLE_PHONE_NUMBER_SMALL, /**< The small phone number style */ + EDIT_FIELD_STYLE_PASSWORD_NUMBER, /**< The number password style */ + EDIT_FIELD_STYLE_PASSWORD_NUMBER_SMALL, /**< The small number password style */ + EDIT_FIELD_STYLE_IP_V4, /**< The IP V4 style */ + EDIT_FIELD_STYLE_IP_V4_SMALL, /**< The small IP V4 style */ +}; + +/** + * @enum CommandButtonPosition + * + * Defines the command button position. + * + * @since 2.0 + */ +enum CommandButtonPosition +{ + COMMAND_BUTTON_POSITION_LEFT, /**< The position is to the left */ + COMMAND_BUTTON_POSITION_RIGHT /**< The position is to the right */ +}; + +/** + * @enum EditMarginType + * + * Defines the possible margin types of EditField and EditArea. + * + * @since 2.0 + */ +enum EditMarginType +{ + EDIT_MARGIN_TYPE_VERTICAL, /**< The margin for top and bottom */ + EDIT_MARGIN_TYPE_HORIZONTAL /**< The margin for left and right */ +}; + +/** + * @enum EditTextColor + * + * Defines the possible Edit's text colors. + * + * @since 2.0 + */ +enum EditTextColor +{ + EDIT_TEXT_COLOR_NORMAL, /**< The normal text color */ + EDIT_TEXT_COLOR_DISABLED, /**< The disabled text color */ + EDIT_TEXT_COLOR_HIGHLIGHTED, /**< The selected text color */ + EDIT_TEXT_COLOR_LINK /**< The highlighted text color */ +}; + +/** + * @enum EditStatus + * + * Defines the possible Edit's states. + * + * @since 2.0 + */ +enum EditStatus +{ + EDIT_STATUS_NORMAL, /**< The normal state */ + EDIT_STATUS_DISABLED, /**< The disabled state */ + EDIT_STATUS_HIGHLIGHTED, /**< The highlighted state */ + EDIT_STATUS_PRESSED /**< The pressed state */ +}; + +/** + * @enum EditFieldTitleStyle + * + * Defines the possible styles of title. + * + * @since 2.0 + */ +enum EditFieldTitleStyle +{ + EDIT_FIELD_TITLE_STYLE_NONE = 0, /**< No title */ + EDIT_FIELD_TITLE_STYLE_INNER, /**< The title appears inside of the EditField's input field */ + EDIT_FIELD_TITLE_STYLE_TOP /**< The title appears at the top input field */ +}; + +/** + * @enum EllipsisPosition + * + * Defines the possible positions of ellipsis. + * + * @since 2.0 + */ +enum EllipsisPosition +{ + ELLIPSIS_POSITION_START = 0, /**< The ellipsis appears at the start of text block */ + ELLIPSIS_POSITION_MIDDLE, /**< The ellipsis appears at the middle of text block */ + ELLIPSIS_POSITION_END, /**< The ellipsis appears at the end of text block */ +}; + +/** + * @enum KeypadStyle + * + * Defines the initial keypad style. + * + * @since 2.0 + */ +enum KeypadStyle +{ + KEYPAD_STYLE_NORMAL = 0, /**< The normal style */ + KEYPAD_STYLE_PASSWORD, /**< The password style '****' */ + KEYPAD_STYLE_EMAIL, /**< The email style */ + KEYPAD_STYLE_URL, /**< The URL style */ + KEYPAD_STYLE_NUMBER, /**< The number style */ + KEYPAD_STYLE_PHONE_NUMBER, /**< The phone number style */ + KEYPAD_STYLE_IP_V4, /**< The IP V4 style */ +}; + +}}} // Tizen::Ui::Controls +#endif // _FUI_CTRL_EDIT_ENUM_H_ diff --git a/inc/FUiCtrlExpandableEditArea.h b/inc/FUiCtrlExpandableEditArea.h new file mode 100644 index 0000000..4f2fd73 --- /dev/null +++ b/inc/FUiCtrlExpandableEditArea.h @@ -0,0 +1,1543 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlExpandableEditArea.h + * @brief This is the header file for the %ExpandableEditArea class. + * + * This header file contains the declarations of the %ExpandableEditArea class. + */ + +#ifndef _FUI_CTRL_EXPANDABLE_EDIT_AREA_H_ +#define _FUI_CTRL_EXPANDABLE_EDIT_AREA_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Forward declaration +namespace Tizen { namespace Graphics +{ +class Rectangle; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ + +class IExpandableEditAreaEventListener; + +/** + * @enum ExpandableEditAreaStyle + * + * Defines the possible styles of the expandable edit area. + * + * @since 2.0 + */ +enum ExpandableEditAreaStyle +{ + EXPANDABLE_EDIT_AREA_STYLE_NORMAL, /**< The normal expandable edit area */ + EXPANDABLE_EDIT_AREA_STYLE_TOKEN /**< The token expandable edit area */ +}; + + +/** + * @enum ExpandableEditAreaTitleStyle + * + * Defines the possible styles of the expandable edit area title. + * + * @since 2.0 + */ +enum ExpandableEditAreaTitleStyle +{ + EXPANDABLE_EDIT_AREA_TITLE_STYLE_NONE = 0, /**< The style with no title */ + EXPANDABLE_EDIT_AREA_TITLE_STYLE_INNER, /**< The title appears as a right aligned text inside the edit text field */ + EXPANDABLE_EDIT_AREA_TITLE_STYLE_TOP /**< The title appears at the top of the edit text field */ +}; + + +/** + * @enum ExpandableEditAreaTokenStatus + * + * Defines the possible status of the expandable edit area tokens. + * + * @since 2.0 + */ +enum ExpandableEditAreaTokenStatus +{ + EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL = 0, /**< The normal status */ + EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED /**< The selected status */ +}; + + +/** + * @class ExpandableEditArea + * @brief This class is an implementation of %ExpandableEditArea. + * + * @since 2.0 + * + * The %ExpandableEditArea class displays a multi-line text editor the height of that is automatically adjusted according to the number of lines currently visible in the text box. + * + * For more information on the class features, see ExpandableEditArea. + * + * The following sample code demonstrates how to use the %ExpandableEditArea class. + * + * @code +// Sample code for ExpandableEditAreaSample.h +#include + +class ExpandableEditAreaSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IKeypadEventListener + , public Tizen::Ui::Controls::IExpandableEditAreaEventListener +{ +public: + ExpandableEditAreaSample(void) + : __pExpandableEdit(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + //IKeypadEventListener + virtual void OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction); + virtual void OnKeypadClosed(Tizen::Ui::Control& source); + virtual void OnKeypadOpened(Tizen::Ui::Control& source); + virtual void OnKeypadWillOpen(Tizen::Ui::Control& source); + + //IExpandableEditAreaEventListener + virtual void OnExpandableEditAreaLineAdded(Tizen::Ui::Controls::ExpandableEditArea& source, int newLineCount); + virtual void OnExpandableEditAreaLineRemoved(Tizen::Ui::Controls::ExpandableEditArea& source, int newLineCount); + +private: + Tizen::Ui::Controls::ExpandableEditArea* __pExpandableEdit; +}; + +// Sample code for ExpandableEditAreaSample.cpp +#include + +#include "ExpandableEditAreaSample.h" + +using namespace Tizen::Graphics;; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +bool +ExpandableEditAreaSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +ExpandableEditAreaSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + __pExpandableEdit = new ExpandableEditArea(); + __pExpandableEdit->Construct(Rectangle(25, 100, GetClientAreaBounds().width - 50, 150), + EXPANDABLE_EDIT_AREA_STYLE_NORMAL, EXPANDABLE_EDIT_AREA_TITLE_STYLE_NONE, 5); + + // Adds an instace of IKeypadEventListenerevent and an instance of IExpandableEditAreaEventListener + __pExpandableEdit->AddKeypadEventListener(*this); + __pExpandableEdit->AddExpandableEditAreaEventListener(*this); + + AddControl(*__pExpandableEdit); + + // Sets a focus to the expandable edit area + __pExpandableEdit->SetFocus(); + + return r; +} + +// IKeypadEventListener implementation +void +ExpandableEditAreaSample::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction) +{ + // .... +} + +void +ExpandableEditAreaSample::OnKeypadClosed(Tizen::Ui::Control& source) +{ + // .... +} + +void +ExpandableEditAreaSample::OnKeypadOpened(Tizen::Ui::Control& source) +{ + // .... +} + +void +ExpandableEditAreaSample::OnKeypadWillOpen(Tizen::Ui::Control& source) +{ + // .... +} + +// IExpandableEditAreaEventListener implementation +void +ExpandableEditAreaSample::OnExpandableEditAreaLineAdded(Tizen::Ui::Controls::ExpandableEditArea& source, int newLineCount) +{ + // .... +} + +void +ExpandableEditAreaSample::OnExpandableEditAreaLineRemoved(Tizen::Ui::Controls::ExpandableEditArea& source, int newLineCount) +{ + // .... +} + * @endcode + */ +class _OSP_EXPORT_ ExpandableEditArea + : public Tizen::Ui::Control +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + ExpandableEditArea(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ExpandableEditArea(void); + + /** + * Initializes this instance of %ExpandableEditArea with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the expandable edit area along with + * the width and height. + * @param[in] style The style of the expandable edit area + * @param[in] titleStyle The title style + * @param[in] maxExpandableLines The maximum number of lines to which the control can be expanded. + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPTION The specified option is not supported. @n + * The token style %ExpandabledEditArea does not support EXPANDABLE_EDIT_AREA_TITLE_STYLE_TOP. + * @exception E_MAX_EXCEEDED The number of lines has exceeded the maximum limit. + * @exception E_INVALID_ARG A specified input parameter is invalid, or @n + * the specified @c maxLines is either negative or @c 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the line count is @c 1. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, ExpandableEditAreaStyle style, ExpandableEditAreaTitleStyle titleStyle, int maxExpandableLines = 10); + +// TEXT MANAGEMENT + /** + * Appends the specified character at the end of the existing text. + * + * @since 2.0 + * + * @return An error code + * @param[in] character The character to be appended + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. @n + * The number of characters has exceeded the maximum limit. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %ExpandableEditArea control. @n + * To display the changes, the control must be drawn again. + */ + result AppendCharacter(const Tizen::Base::Character& character); + + /** + * Appends the specified text at the end of the existing text. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be appended + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit @n + * The number of characters has exceeded the maximum limit. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %ExpandableEditArea control. @n + * To display the changes, the control must be drawn again. + */ + result AppendText(const Tizen::Base::String& text); + + /** + * Appends the text that will be displayed by bitmap at the end of the existing text. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be appended @n + * It will be displayed by the @c textImage + * @param[in] textImage The alternate bitmap to be displayed + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the maximum length of the text that can be displayed by % ExpanableEditArea. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @remarks The method modifies the text buffer that is managed by the %ExpanableEditArea control. @n + * To display the changes, the control must be drawn again. The text to be appended will be displayed by the @c textImage. + */ + result AppendText(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& textImage); + + /** + * Deletes the character present at the current cursor position. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c index is negative. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n + * Either the specified @c index is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %ExpandableEditArea control. @n + * To display the changes, the control must be drawn again. + */ + result DeleteCharacterAt(int index); + + /** + * Inserts a character at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The position to insert the character + * @param[in] character The character to be inserted + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n + * Either the specified @c index is greater than the number of elements or less than @c 0. + * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds system limitations. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %ExpandableEditArea control. @n + * To display the changes, the control must be drawn again. + */ + result InsertCharacterAt(int index, const Tizen::Base::Character& character); + + /** + * Inserts the text at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The position to insert the text + * @param[in] text The text to be inserted + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n + * Either the specified @c index is greater than the number of elements or less than @c 0. + * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds system limitations. + * @exception E_SYSTEM A system error has occurred. + */ + result InsertTextAt(int index, const Tizen::Base::String& text); + + /** + * Inserts the text that will be displayed by bitmap at the specified text position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position to insert the text + * @param[in] text The text to be inserted @n + * It will be displayed by the @c textImage + * @param[in] textImage The alternate bitmap to be displayed + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c position is outside the valid range. @n + * Either the specified @c position is greater than the number of existing text in the % ExpanableEditArea or less than @c 0. + * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the maximum length of the text that can be displayed by % ExpanableEditArea. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @remarks The method modifies the text buffer that is managed by the %ExpanableEditArea control. @n + * To display the changes, the control must be drawn again. The text to be inserted will be displayed by the @c textImage. + */ + result InsertTextAt(int position, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& textImage); + + /** + * Gets the portion of the text that is displayed by the %ExpandableEditArea control. + * + * @since 2.0 + * + * @return The specified portion of the text, @n + * else an empty string if an error occurs + * @param[in] start The starting index of the range + * @param[in] end The last index of the range + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The specified @c start or @c end is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see GetText() + * @see SetText() + */ + Tizen::Base::String GetText(int start, int end) const; + + /** + * Gets the text of the %ExpandableEditArea control. + * + * @since 2.0 + * + * @return The text of the %ExpandableEditArea control, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets the text length. + * + * @since 2.0 + * + * @return The length of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetTextLength(void) const; + + /** + * Sets the text to be displayed by the %ExpandableEditArea control. + * + * @since 2.0 + * + * @param[in] text The text to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid, @n + * or the length of the specified @c text exceeds system limitations. + * @exception E_SYSTEM A system error has occurred. + * @remarks To denote the end of a line use '\\n'. + * The method modifies the text buffer that is managed by the %ExpandableEditArea control. + * To display the changes, the control must be drawn again. + */ + result SetText(const Tizen::Base::String& text); + + /** + * Clears the text that is displayed by the %ExpandableEditArea control. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %ExpandableEditArea control. + * To display the changes, the control must be drawn again. + */ + result Clear(void); + + /** + * Sets the title of the %ExpandableEditArea control. + * + * @since 2.0 + * + * @return An error code + * @param[in] title The title to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTitleText(const Tizen::Base::String& title); + + /** + * Gets the title of the %ExpandableEditArea control. + * + * @since 2.0 + * + * @return The title text of the entered string, @n + * else empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::String GetTitleText(void) const; + +// GUIDE TEXT + /** + * Gets the guide text. + * + * @since 2.0 + * + * @return The guide text, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetGuideText() + */ + Tizen::Base::String GetGuideText(void) const; + + /** + * Sets the guide text to be displayed, when there is no data in the search field. + * + * @since 2.0 + * + * @return An error code + * @param[in] guideText The guide text + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetGuideText() + */ + result SetGuideText(const Tizen::Base::String& guideText); + +// LINE MANAGEMENT + /** + * Gets the maximum line count supported by the flexible text edit. + * + * @since 2.0 + * + * @return The maximum line count, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetMaxLineCount(void) const; + + /** + * Gets the line spacing. + * + * @since 2.0 + * @return The line spacing, @n + * else @c -1 if an error occurs + * @see SetLineSpacing () + */ + int GetLineSpacing (void) const; + + /** + * Sets the line spacing. @n + * The line spacing is determined by multiplying @c multiplier to the default line spacing and adding @c extra. + * + * @code + * The line spacing = (default line spacing) * multiplier + extra + * @endcode + * + * @since 2.0 + * @return An error code + * @param[in] multiplier The line spacing multiplier + * @param[in] extra The extra line spacing + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG This exception is returned when @c multiplier or @c extra is less than 0. + * @see GetLineSpacing () + */ + result SetLineSpacing (int multiplier, int extra); + + /** + * Gets the current line count. + * + * @since 2.0 + * + * @return The line count of the text + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetTextLineCount(void) const; + +// TEXT SIZE + /** + * Gets the text size. + * + * @since 2.0 + * + * @return The size of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextSize() + */ + int GetTextSize(void) const; + + /** + * Sets the text size. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The text size + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c size is invalid, @n + * or the specified @c size is a negative integer. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextSize() + */ + result SetTextSize(int size); + +// MARGINS + /** + * Gets the margin of the specified margin type. + * + * @since 2.0 + * + * @return The margin value of the specified margin type, @n + * else @c -1 if an error occurs + * @param[in] marginType The margin type + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetMargin() + */ + int GetMargin(EditMarginType marginType) const; + + /** + * Sets the margin for the specified margin type. + * + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSetMarginPage "here". + * @endif + * @return An error code + * @param[in] marginType The margin type + * @param[in] margin The margin to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c margin cannot be negative integer. + * @exception E_SYSTEM A system error has occurred. + * @see GetMargin() + */ + result SetMargin(EditMarginType marginType, int margin); + /** + * @if OSPCOMPAT + * @page CompSetMarginPage Compatibility for SetMargin() + * @section CompSetMarginPageIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The SetMargin() method sets the margin value for ExpandableEditArea with only EXPANDABLE_EDIT_AREA_STYLE_NORMAL in API version 2.0. @n + * + * @section CompSetMarginPageSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * @endif + */ + +// LOWER CASE + /** + * Enables or disables the lowercase mode. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the lowercase mode, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks When the lowercase mode is enabled, the text input starts with a lowercase character. + * @see IsLowerCaseModeEnabled() + */ + result SetLowerCaseModeEnabled(bool enable); + + /** + * Checks whether the lowercase mode is enabled. + * + * @since 2.0 + * + * @return @c true if the lowercase mode is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetLowerCaseModeEnabled() + */ + bool IsLowerCaseModeEnabled(void) const; + +// CURSOR MANAGEMENT + /** + * Gets the cursor position. + * + * @since 2.0 + * + * @return The current cursor position, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetCursorPosition(void) const; + + /** + * Sets the cursor at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The cursor position to be set + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c position is less than @c 0 or greater than the maximum length. + * @exception E_SYSTEM A system error has occurred. + */ + result SetCursorPosition(int position); + +// TEXT BLOCKING + /** + * Gets the start and end indexes of the currently selected text block. + * + * @since 2.0 + * + * @return An error code + * @param[out] start The start index of the text block + * @param[out] end The end index of the text block + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method returns the start and end indexes as @c 0 if no text block is selected. + * @see ReleaseBlock() + * @see SetBlockRange() + */ + result GetBlockRange(int& start, int& end) const; + + /** + * Releases the selection of the current text block. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetBlockRange() + * @see SetBlockRange() + */ + result ReleaseBlock(void); + + /** + * Removes the text content of the current text block. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified instance is not found, @n + * or the text block is not selected. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveTextBlock(void); + + /** + * Sets the block range for the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] start The start index of the text block + * @param[in] end The end index of the text block + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * Either the index is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @see ReleaseBlock() + * @see GetBlockRange() + */ + result SetBlockRange(int start, int end); + +// KEYPAD MANAGEMENT + /** + * Gets the keypad action type. + * + * @since 2.0 + * + * @return The keypad action + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetKeypadAction() + */ + Tizen::Ui::KeypadAction GetKeypadAction(void) const; + + /** + * Gets the keypad style. + * + * @since 2.0 + * + * @return The keypad style + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetKeypadStyle() + */ + KeypadStyle GetKeypadStyle(void) const; + + /** + * Hides the keypad associated with the %ExpandableEditArea control. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see ShowKeypad() + */ + result HideKeypad(void); + + /** + * Checks whether the keypad is enabled. + * + * @since 2.0 + * + * @return @c true if the keypad is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetKeypadEnabled() + */ + bool IsKeypadEnabled(void) const; + + /** + * Sets the keypad action type. + * + * @since 2.0 + * + * @return An error code + * @param[in] keypadAction The keypad action + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks Depending on the value of @c keypadAction, the enter key label of the keypad will change accordingly. + * @see GetKeypadAction() + */ + result SetKeypadAction(Tizen::Ui::KeypadAction keypadAction); + + /** + * Sets the keypad style. + * + * @since 2.0 + * + * @return An error code + * @param[in] keypadStyle The keypad style + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c keypadStyle is KEYPAD_STYLE_PASSWORD. + * @exception E_SYSTEM A system error has occurred. + * @remarks Depending on the value of the keypad style, the layout of the keypad will change accordingly. + * @see GetKeypadStyle() + */ + result SetKeypadStyle(KeypadStyle keypadStyle); + + /** + * Checks whether the text prediction is enabled. + * + * @since 2.0 + * @return @c true if the text prediction is enabled, @n + * else @c false + * @see SetTextPredictionEnabled() + */ + bool IsTextPredictionEnabled(void) const; + + /** + * Enables or disables the text prediction. + * + * @since 2.0 + * @param[in] enable Set to @c true to enable the text prediction, @n + * else @c false + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @see IsTextPredictionEnabled() + */ + result SetTextPredictionEnabled(bool enable); + + /** + * Enables or disables the keypad. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the virtual keypad, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see IsKeypadEnabled() + */ + result SetKeypadEnabled(bool enable); + + /** + * Shows the keypad. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see HideKeypad() + */ + result ShowKeypad(void); + +// TOKEN FILTER + /** + * Sets the text token filter. + * + * @since 2.0 + * + * @return An error code + * @param[in] pFilter The filter + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_SYSTEM A system error has occurred. + * @remarks The %ExpandableEditArea control checks with the registered filter to decide whether the user-entered text should be replaced. + */ + result SetTokenFilter(const ITokenFilter* pFilter); + + /** + * Gets the text token filter. + * + * @since 2.0 + * + * @return The filter, @n + * else @c null if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + ITokenFilter* GetTokenFilter(void) const; + + /** + * Appends the specified token. + * + * @since 2.0 + * + * @return An error code + * @param[in] token The token to be appended + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The length of the specified @c token is @c 0. + * @exception E_SYSTEM A system error has occurred. + */ + result AppendToken(const Tizen::Base::String& token); + + /** + * Inserts the token at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The position to insert the token + * @param[in] token The token to be added + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The length of the specified @c token is @c 0. + * @exception E_SYSTEM A system error has occurred. + */ + result InsertTokenAt(int index, const Tizen::Base::String& token); + + /** + * Gets the token text at the specified index. + * + * @since 2.0 + * + * @return The token text at the specified index, @n + * else an empty string if an error occurs + * @param[in] index The position to get the token + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_OUT_OF_RANGE The specified index parameter is outside the bounds of the data structure. @n + * Either the index is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::String GetTokenAt(int index) const; + + /** + * Gets the total token count. + * + * @since 2.0 + * + * @return The total token count, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetTokenCount(void) const; + + /** + * Gets the index of the token that is selected. + * + * @since 2.0 + * + * @return The index of the selected token, @n + * else @c -1 if no token is selected or if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetSelectedTokenIndex(void) const; + + /** + * Checks whether the token editing mode is enabled. + * + * @since 2.0 + * + * @return @c true if the editing mode is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + bool IsTokenEditModeEnabled(void) const; + + /** + * Removes the token at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the token to be removed + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * Either the index is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveTokenAt(int index); + + /** + * Sets the selected state of the specified token. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the token to select + * @param[in] selected Set to @c true to select the specified token, @n + * else @c false to unselect + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * Either the index is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks The currently selected token gets unselected automatically. + */ + result SetTokenSelected(int index, bool selected); + + /** + * Enables or disables the token edit mode. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the token editing mode, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTokenEditModeEnabled(bool enable); + +// LIMIT LENGTH + /** + * Gets the limit length. + * + * @since 2.0 + * + * @return The limit length, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * The default limit length is @c 2048. + * @see SetLimitLength() + */ + int GetLimitLength(void) const; + + /** + * Sets the limit length. + * + * @since 2.0 + * + * @return An error code + * @param[in] limitLength The limit text length to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid, @n + * or the specified limit length is @c 0 or negative. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %ExpandableEditArea control. @n + * To display the changes, the control must be drawn again. + * @see GetLimitLength() + */ + result SetLimitLength(int limitLength); + +// APPEARANCES + /** + * Gets the color of the %ExpandableEditArea control for the specified status. + * + * @since 2.0 + * + * @return The color, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The status + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetColor(EditStatus status) const; + + /** + * Gets the text color of the specified text type. + * + * @since 2.0 + * + * @return The text color, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] type The text type + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified type is not supported, or @n + * the specified @c type is EDIT_TEXT_COLOR_LINK. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextColor() + */ + Tizen::Graphics::Color GetTextColor(EditTextColor type) const; + + /** + * Gets the text color of the guide text. + * + * @since 2.0 + * + * @return The guide text color, @n + * else RGBA (0,0,0,0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetGuideTextColor() + */ + Tizen::Graphics::Color GetGuideTextColor(void) const; + + /** + * Gets the text color of the title for the specified status. + * + * @since 2.0 + * + * @return The title text color, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The state of the %ExpandableEditArea control + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTitleTextColor() + */ + Tizen::Graphics::Color GetTitleTextColor(EditStatus status) const; + + /** + * Gets the color of the tokens for the specified status. + * + * @since 2.0 + * + * @return The token color, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The status + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTokenColor + */ + Tizen::Graphics::Color GetTokenColor(ExpandableEditAreaTokenStatus status) const; + + /** + * Gets the text color of tokens. + * + * @since 2.0 + * + * @return The text color, @n + * else RGBA (0,0,0,0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTokenTextColor() + */ + Tizen::Graphics::Color GetTokenTextColor(void) const; + + /** + * Gets the text color of tokens at the specified index. + * + * @since 2.0 + * + * @return The text color, @n + * else RGBA (0,0,0,0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetSelectedTokenTextColor() + */ + Tizen::Graphics::Color GetSelectedTokenTextColor(void) const; + + /** + * Sets the background bitmap of the %ExpandableEditArea control. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status + * @param[in] bitmap The background bitmap + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetBackgroundBitmap(EditStatus status, const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the color of the %ExpandableEditArea control. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status of the %ExpandableEditArea control + * @param[in] color The color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetColor() + */ + result SetColor(EditStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the guide text. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The guide text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetGuideTextColor() + */ + result SetGuideTextColor(const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the title for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status of the %ExpandableEditArea control + * @param[in] color The title text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetTitleTextColor() + */ + result SetTitleTextColor(EditStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the %ExpandableEditArea control. + * + * @since 2.0 + * + * @return An error code + * @param[in] type The text type + * @param[in] color The text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextColor() + */ + result SetTextColor(EditTextColor type, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the tokens at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The token text color + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_SYSTEM A system error has occurred. + * @see GetSelectedTokenTextColor() + */ + result SetSelectedTokenTextColor(const Tizen::Graphics::Color& color); + + /** + * Sets the color of the tokens for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status + * @param[in] color The token color + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_SYSTEM A system error has occurred. + * @see GetTokenColor() + */ + result SetTokenColor(ExpandableEditAreaTokenStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the tokens. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The token text color + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the style is not EXPANDABLE_EDIT_AREA_STYLE_TOKEN. + * @exception E_SYSTEM A system error has occurred. + * @see GetTokenTextColor() + */ + result SetTokenTextColor(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Enables or disables the auto resizing if the candidate word list appears. + * + * @brief [Deprecated] + * @deprecated This API is deprecated because it is no longer necessary to handle the resizing of expandable edit area. + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the auto resizing, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The current style of the %ExpandableEditArea does not support the operation. + * @remarks Note that when this option is enabled, the normal style %ExpandableEditArea is auto resized and the line added and removed events are + * generated if the candidate word list pop-up appears during the predictive texting. @n + * The operation is not supported by the token style %ExpandableEditArea. + * @see IsAutoResizingEnabled() + * @see Tizen::Ui::Controls::IExpandableEditAreaEventListener + * @endif + */ + result SetAutoResizingEnabled(bool enable); + + /** + * @if OSPDEPREC + * Checks whether the auto-resizing is enabled. + * + * @brief [Deprecated] + * @deprecated This API is deprecated because it is no longer necessary to handle the resizing of expandable edit area. + * @since 2.0 + * + * @return @c true if the auto-resizing is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The current style of the %ExpandableEditArea control does not support the operation. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetAutoResizingEnabled() + * @endif + */ + bool IsAutoResizingEnabled(void) const; + + /** + * Sets the input language. + * + * @since 2.0 + * + * @return An error code + * @param[in] languageCode The language to set + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The application can set the language of the current keypad that is associated with the current %ExpandableEditArea. @n + * This method only works if the language to set is supported by the current preloaded keypad. + */ + result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode); + + /** + * Gets the current input language. + * + * @since 2.0 + * + * @return An error code + * @param[out] language The current input language + * @exception E_SUCCESS The method is successful. + * @remarks The application can get the current language of the keypad that is associated with the current %ExpandableEditArea. + */ + result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const; + +// EVENT LISTENER MANAGEMENT + /** + * Adds the specified IExpandableEditAreaEventListener instance. @n + * The added listener can listen to events when a line is added or removed or when a button is pressed. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @see RemoveExpandableEditAreaEventListener() + */ + void AddExpandableEditAreaEventListener(IExpandableEditAreaEventListener& listener); + + /** + * Adds the specified IKeypadEventListener instance. @n + * The added listener is notified if the keypad associated with the edit area is opened or closed. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @see RemoveKeypadEventListener() + */ + void AddKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + + /** + * Adds the specified ITextBlockEventListener instance. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks Programmatically modifying the text block does not cause the text block selection event to fire. + * @see RemoveTextBlockEventListener() + */ + void AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + /** + * Adds the specified ITextEventListener instance. @n + * The added listener can listen to the text-changed event. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @see RemoveTextEventListener() + */ + void AddTextEventListener(Tizen::Ui::ITextEventListener& listener); + + /** + * Removes the specified IExpandableEditAreaEventListener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddActionEventListener() + */ + void RemoveExpandableEditAreaEventListener(IExpandableEditAreaEventListener& listener); + + /** + * Removes the specified IKeypadEventListener listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddKeypadEventListener() + */ + void RemoveKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + + /** + * Removes the specified ITextBlockEventListener listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddTextBlockEventListener() + */ + void RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + /** + * Removes the specified ITextEventListener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see AddTextEventListener() + */ + void RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener); + + /** + * Adds a listener instance for language events. @n + * The added listener is notified when the input language is changed. + * + * @since 2.0 + * + * @param[in] listener The listener to add + * @remarks The application can recognize when the language is changed from the keypad by adding Tizen::Ui::ILanguageEventListener. + * @see RemoveLanguageEventListener() + */ + + void AddLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + + /** + * Removes the specified listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to remove + * @see AddLanguageEventListener() + */ + + void RemoveLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + + /** + * Enables or disables the auto shrinking if the focus is lost. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable the auto shrinking, @n + * else @c false + * @remarks Note that when this option is enabled, the %ExpandableEditArea is auto shrinked + * if the %ExpandableEditArea lost its focus. @n + * @see IsAutoShrinkModeEnabled() + */ + void SetAutoShrinkModeEnabled(bool enable); + + /** + * Checks whether the auto-shrinking is enabled. + * + * @since 2.0 + * + * @return @c true if the auto-shrinking is enabled, @n + * else @c false + * @see SetAutoShrinkModeEnabled() + */ + bool IsAutoShrinkModeEnabled(void) const; + + +protected: + friend class _ExpandableEditAreaImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + ExpandableEditArea(const ExpandableEditArea& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + ExpandableEditArea& operator =(const ExpandableEditArea& rhs); +}; // ExpandableEditArea + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_EXPANDABLE_EDIT_AREA_H_ diff --git a/inc/FUiCtrlExpandableList.h b/inc/FUiCtrlExpandableList.h new file mode 100644 index 0000000..5a08381 --- /dev/null +++ b/inc/FUiCtrlExpandableList.h @@ -0,0 +1,1228 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlExpandableList.h + * @brief This is the header file for the %ExpandableList class. + * + * This header file contains the declarations of the %ExpandableList class and its helper classes. + */ + +#ifndef _FUI_CTRL_EXPANDABLE_LIST_H_ +#define _FUI_CTRL_EXPANDABLE_LIST_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if OSPDEPREC + * @class ExpandableList + * @brief [Deprecated] This class defines the common behavior of an %ExpandableList control. + * + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. @n + * @since 2.0 + * + * The %ExpandableList class defines the common behavior of an %ExpandableList control. + * An expandable list is a list with a hierarchy of depth 2. List items of %ExpandableList + * consist of main items and sub-items which are CustomListItem. Main items are inserted + * into the first level as items are inserted into List class. Sub-items are inserted under + * related main items. So, sub-items are uniquely identified with two indices: main item + * index and sub-item index. + * + * If an application wants to perform tasks when the state of a list item is changed, + * it must implement IExpandableItemEventListener and register it to the expandable list, + * It will then receive related events from %ExpandableList. + * + * Unlike GroupedList which is also a list with the hierarch of depth 2, main items of + * %ExpandableList can be expanded or closed. + * + * Note that CustomListItem and CustomListItemFormat need to be created on a heap. CustomListItems will be deleted automatically + * when the %ExpandableList itself is destroyed. If you want to remove certain list items, you must use RemoveItemAt(). CustomListItemFormat + * must be deleted by the application. + * + * Refer to CustomListItem and CustomListItemFormat. + * + * Example: + * + * @image html ui_controls_expandablelist.png + * + * This is the simple UI application which uses an %ExpandableList control. + * + * @code +//Sample code for ExpandableListSample.h +#include + +class ExpandableListSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IExpandableItemEventListener +{ +public: + ExpandableListSample(void) + : __pMainItemFormat(null) + , __pSubItemFormat(null){} + + bool Initialize(void); + result AddListMainItem(Tizen::Ui::Controls::ExpandableList& expandableList, Tizen::Base::String itemText, + Tizen::Graphics::Bitmap* pBitmapNormal, Tizen::Graphics::Bitmap* pBitmapFocused); + result AddListSubItem(Tizen::Ui::Controls::ExpandableList& expandableList, int itemId, Tizen::Base::String itemText); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // IExpandableItemEventListener + virtual void OnItemStateChanged(const Control& source, int mainIndex, int subIndex, int itemId, Tizen::Ui::ItemStatus status); + virtual void OnItemStateChanged(const Control& source, int mainIndex, int subIndex, int itemId, int elementId, Tizen::Ui::ItemStatus status); + + + +private: + static const int ID_LIST_MAINITEM = 101; + static const int ID_LIST_SUBITEM = 102; + static const int ID_LIST_TEXT = 103; + static const int ID_LIST_BITMAP = 104; + + Tizen::Ui::Controls::CustomListItemFormat* __pMainItemFormat; + Tizen::Ui::Controls::CustomListItemFormat* __pSubItemFormat; +}; + * @endcode + * + * @code +//Sample code for ExpandableListSample.cpp +#include +#include + +#include "ExpandableListSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +bool +ExpandableListSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +ExpandableListSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of ExpandableList + ExpandableList* pExpandableList = new ExpandableList(); + pExpandableList->Construct(Rectangle(0, 0, 480, 500), CUSTOM_LIST_STYLE_NORMAL); + pExpandableList->AddExpandableItemEventListener(*this); + + // Creates an instance of CustomListItemFormat of the main item + __pMainItemFormat = new CustomListItemFormat(); + __pMainItemFormat->Construct(); + __pMainItemFormat->AddElement(ID_LIST_TEXT, Rectangle(10, 25, 200, 80)); + __pMainItemFormat->AddElement(ID_LIST_BITMAP, Rectangle(220, 10, 70, 80)); + + // Creates an instance of CustomListItemFormat of the sub item + __pSubItemFormat = new CustomListItemFormat(); + __pSubItemFormat->Construct(); + __pSubItemFormat->AddElement(ID_LIST_TEXT, Rectangle(20, 25, 450, 50)); + + // Gets instances of Bitmap + AppResource *pAppResource = Application::GetInstance()->GetAppResource(); + Bitmap *pBitmapNormal = pAppResource->GetBitmapN(L"tizen.png"); + Bitmap *pBitmapFocused = pAppResource->GetBitmapN(L"tizen.png"); + + // Adds the main item + AddListMainItem(*pExpandableList, L"MainItem", pBitmapNormal, pBitmapFocused); + + // Adds the sub item + AddListSubItem(*pExpandableList, ID_LIST_MAINITEM, L"SubItem"); + + // Adds the expandable list to the form + AddControl(*pExpandableList); + + // Deallocates bitmaps + delete pBitmapNormal; + delete pBitmapFocused; + + return r; +} + +result +ExpandableListSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates item formats + delete __pMainItemFormat; + delete __pSubItemFormat; + + return r; +} + +result +ExpandableListSample::AddListMainItem(ExpandableList& expandableList, String itemText, Bitmap* pBitmapNormal, Bitmap* pBitmapFocused) +{ + result r = E_SUCCESS; + + // Creates a main instance of CustomListItem of the expandable list + CustomListItem* pMainItem = new CustomListItem(); + pMainItem->Construct(100); + pMainItem->SetItemFormat(*__pMainItemFormat); + pMainItem->SetElement(ID_LIST_TEXT, itemText); + pMainItem->SetElement(ID_LIST_BITMAP, *pBitmapNormal, pBitmapFocused); + + // Adds the item to the expandable list + expandableList.AddItem(*pMainItem, ID_LIST_MAINITEM); + + return r; +} + +result +ExpandableListSample::AddListSubItem(ExpandableList& expandableList, int itemId, String itemText) +{ + result r = E_SUCCESS; + + // Creates a sub instance of CustomListItem of the expandable list + CustomListItem* pSubItem = new CustomListItem(); + pSubItem->Construct(100); + pSubItem->SetItemFormat(*__pSubItemFormat); + pSubItem->SetElement(ID_LIST_TEXT, itemText); + + // Adds the item to the expandable list + expandableList.AddSubItem(expandableList.GetItemIndexFromItemId(ID_LIST_MAINITEM), *pSubItem, ID_LIST_SUBITEM); + + return r; +} + +// IExpandableItemEventListener implementation +void +ExpandableListSample::OnItemStateChanged(const Control& source, int mainIndex, int subIndex, int itemId, ItemStatus status) +{ + switch (itemId) + { + case ID_LIST_MAINITEM: + { + // .... + } + break; + case ID_LIST_SUBITEM: + { + // .... + } + break; + default: + break; + } +} + +void +ExpandableListSample::OnItemStateChanged(const Control& source, int mainIndex, int subIndex, int itemId, int elementId, ItemStatus status) +{ + switch (itemId) + { + case ID_LIST_MAINITEM: + { + switch (elementId) + { + case ID_LIST_TEXT: + { + // .... + } + break; + case ID_LIST_BITMAP: + { + // .... + } + break; + default: + break; + } + } + break; + case ID_LIST_SUBITEM: + { + switch (elementId) + { + case ID_LIST_TEXT: + { + // .... + } + break; + case ID_LIST_BITMAP: + { + // .... + } + break; + default: + break; + } + } + break; + default: + break; + } +} + * @endcode + * @endif + */ +class _OSP_EXPORT_ ExpandableList + : public Tizen::Ui::Control +{ +public: + /** + * @if OSPDEPREC + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * @endif + */ + ExpandableList(void); + + /** + * @if OSPDEPREC + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * @endif + */ + virtual ~ExpandableList(void); + + /** + * @if OSPDEPREC + * Initializes this instance of %ExpandableList with the specified parameters. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] rect The x, y position of the top-left corner of the %ExpandableList along with the width and the height of the control + * @param[in] style The style set + * @param[in] itemDivider Set to @c true to display the divider, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. + * The minimum size of this control is 92 x 72 on a WVGA screen, 60 x 48 on a HVGA screen and 46 x 36 on a WQVGA screen. + * @endif + */ + result Construct(const Tizen::Graphics::Rectangle& rect, CustomListStyle style, bool itemDivider = true); + + /** + * @if OSPDEPREC + * Adds the ExpandableItemEventListener instance. @n + * The added listener gets notified when the state of an item is changed. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @endif + */ + void AddExpandableItemEventListener(Tizen::Ui::IExpandableItemEventListener& listener); + + /** + * @if OSPDEPREC + * Removes the ExpandableItemEventListener instance. @n + * The removed listener is not notified even when the expandable item events are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @endif + */ + void RemoveExpandableItemEventListener(Tizen::Ui::IExpandableItemEventListener& listener); + + /** + * @if OSPDEPREC + * Adds the specified item to the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] item The CustomListItem to be added + * @param[in] itemId The item ID for the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The item ID can be used to identify the specific %CustomListItem instance or to associate the user-allocated resources. @n + * Note that %ExpandableList does not throw an exception, if the same item ID is given to multiple items. @n + * The added item is deleted automatically when the list is destroyed. @n + * Do not add, insert, or set an item which already belongs to the %ExpandableList. + * @endif + */ + result AddItem(const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Inserts the specified item to the %ExpandableList control at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index at which to insert the item + * @param[in] item The CustomListItem to be inserted + * @param[in] itemId The item ID for the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c index is less than @c 0 or greater than the item count. + * @exception E_SYSTEM A system error has occurred. + * @remarks The inserted item is deleted automatically when the list is destroyed. + * Do not add, insert, or set an item that already belongs to the %ExpandableList control. + * @endif + */ + result InsertItemAt(int mainIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Changes the contents of the item at the specified index in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index at which to set the contents of the item + * @param[in] item The CustomListItem to be set + * @param[in] itemId The item ID for the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c index is less than @c 0 or greater than the item count. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not add, insert, or set an item that already belongs to the %ExpandableList control. + * @endif + */ + result SetItemAt(int mainIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Removes the item at the specified index in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the item to be deleted + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c index is less than @c 0 or greater than the item count. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list item is deleted from the memory. + * @endif + */ + result RemoveItemAt(int mainIndex); + + /** + * @if OSPDEPREC + * Removes all the items from the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list items are deleted from the memory. + * @endif + */ + result RemoveAllItems(void); + + /** + * @if OSPDEPREC + * Gets the item at the specified index in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return A CustomListItem instance, @n + * else @c null if the specified index is out of range + * @param[in] mainIndex The index of the item + * @endif + */ + const CustomListItem* GetItemAt(int mainIndex) const; + + /** + * @if OSPDEPREC + * Adds the specified sub-item to the main item in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item to which the sub-item is added + * @param[in] item The CustomListItem instance to be added + * @param[in] itemId The item ID for the sub-item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified index is less than @c 0, or greater than the item count. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result AddSubItem(int mainIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Inserts the specified sub-item at the specified index to the main item in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item to which the sub-item is added + * @param[in] subIndex The index of the sub-item at which to insert the item + * @param[in] item The CustomListItem instance to be inserted + * @param[in] itemId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified index is less than @c 0, or greater than the item count. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result InsertSubItemAt(int mainIndex, int subIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Changes the contents of the sub-item at the specified index in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The main index of the sub-item at which to set the contents of the item + * @param[in] subIndex The sub-index of the sub-item at which to set the contents of the item + * @param[in] item The CustomListItem instance to be set + * @param[in] itemId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified index is less than @c 0, or greater than the item count. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetSubItemAt(int mainIndex, int subIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Removes the sub-item at the specified index in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item which the sub-item belongs to + * @param[in] subIndex The index of the sub-item to be deleted in the main item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified index is less than @c 0, or greater than the item count. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RemoveSubItemAt(int mainIndex, int subIndex); + + /** + * @if OSPDEPREC + * Removes all sub-items of the specified main item in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item of the %ExpandableList control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified index is less than @c 0, or greater than or equal to the item count. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RemoveAllSubItemsAt(int mainIndex); + + /** + * @if OSPDEPREC + * Gets the number of items in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return The number of items in %ExpandableList, @n + * else @c -1 if an error occurs + * @endif + */ + int GetItemCount(void) const; + + /** + * @if OSPDEPREC + * Gets the number of sub-items in the main item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return The number of sub-items in the main item, @n + * else @c -1 if an error occurs + * @param[in] mainIndex The index of the main item + * @endif + */ + int GetSubItemCount(int mainIndex) const; + + /** + * @if OSPDEPREC + * Gets the sub-item at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return A pointer to the CustomListItem instance at the specified index, @n + * else @c null if the specified index does not exist in the %ExpandableList control + * @param[in] mainIndex The index of the main item which the sub-item belongs to + * @param[in] subIndex The index of the sub-item to get in the main index + * @endif + */ + const CustomListItem* GetSubItemAt(int mainIndex, int subIndex) const; + + /** + * @if OSPDEPREC + * Gets the first item of all the checked main items in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return The index of the first checked item, @n + * else @c -1 if no main item is checked + * @endif + */ + int GetFirstCheckedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the item ID of the specified main item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return The item ID of the main item, @n + * else @c -1 if the specified @c mainIndex is less than @c 0 or greater than the main item count + * @param[in] mainIndex The index of the main item + * @endif + */ + int GetItemIdAt(int mainIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the specified main item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return The index of the main item, @n + * else @c -1 if no main item has the specified item ID + * @param[in] itemId The item ID + * @remarks A main item can have the same item ID and this method returns the first main item among such items. + * @endif + */ + int GetItemIndexFromItemId(int itemId) const; + + /** + * @if OSPDEPREC + * Gets the item ID of the specified sub-item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return The item ID of the specified sub-item, @n + * else @c -1 if the specified sub-item does not exist + * @param[in] mainIndex The index of the main item, which the sub-item belongs to + * @param[in] subIndex The index of the sub-item + * @endif + */ + int GetSubItemIdAt(int mainIndex, int subIndex) const; + + /** + * @if OSPDEPREC + * Expands or shrinks the specified main item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item + * @param[in] expand Set to @c true to expand the specified main item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c mainIndex is less than @c 0, or greater than the main item count. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetItemExpanded(int mainIndex, bool expand); + + /** + * @if OSPDEPREC + * Checks whether the main item is expanded. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return @c true if the main item is expanded, @n + * else @c false + * @param[in] mainIndex The index of the main item + * @endif + */ + bool IsItemExpanded(int mainIndex) const; + + /** + * @if OSPDEPREC + * Enables or disables the status of the main item at the specified index of the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item, for which the status is to be set + * @param[in] enable Set to @c true to enable the main item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c mainIndex is less than @c 0, or no less than the main item count. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetItemEnabled(int mainIndex, bool enable); + + /** + * @if OSPDEPREC + * Checks whether the main item at the specified index in the %ExpandableList control is enabled. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return @c true if the main item is enabled, @n + * else @c false + * @param[in] mainIndex The index of the main item to be checked + * @endif + */ + bool IsItemEnabled(int mainIndex) const; + + /** + * @if OSPDEPREC + * Sets the enabled status of the specific sub-item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item which the sub-item belongs to + * @param[in] subIndex The index of the sub-item in the main item + * @param[in] enable Set to @c true to enable the sub-item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The sub-item at the specified index does not exist. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetSubItemEnabled(int mainIndex, int subIndex, bool enable); + + /** + * @if OSPDEPREC + * Checks whether the specified sub-item is enabled. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return @c true if the specified sub-item is enabled, @n + * else @c false + * @param[in] mainIndex The index of the main item which the sub-item belongs to + * @param[in] subIndex The index of the sub-item in the main item + * @endif + */ + bool IsSubItemEnabled(int mainIndex, int subIndex) const; + + /** + * @if OSPDEPREC + * Sets the check status of the main item at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item + * @param[in] check Set to @c true to check the main item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c mainIndex is less than @c 0, or no less than the main item count. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows selection. + * @endif + */ + result SetItemChecked(int mainIndex, bool check); + + /** + * @if OSPDEPREC + * Checks whether the status of the main item at the specified index is checked. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return @c true if the main item is checked, @n + * else @c false + * @param[in] mainIndex The index of the main item + * @remarks This method can only be used when the style of the list allows selection. + * @endif + */ + bool IsItemChecked(int mainIndex) const; + + + /** + * @if OSPDEPREC + * Sets the check status of the specified sub-item of the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item which the sub-item belongs to + * @param[in] subIndex The index of the sub-item in the main index + * @param[in] check Set to @c true to check the sub-item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The sub-item at the specified index does not exist. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows selection. + * @endif + */ + result SetSubItemChecked(int mainIndex, int subIndex, bool check); + + /** + * @if OSPDEPREC + * Checks whether the specified sub-item is checked. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return @c true if the sub-item is checked, @n + * else @c false + * @param[in] mainIndex The index of the main item which the sub-item belongs to + * @param[in] subIndex The index of the sub-item in the main item + * @remarks This method can only be used when the style of the list allows selection. + * @endif + */ + bool IsSubItemChecked(int mainIndex, int subIndex) const; + + /** + * @if OSPDEPREC + * Sets the check status of all sub-items of the specified main item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item + * @param[in] check Set to @c true to check the items, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c mainIndex is less than @c 0, or greater than the main item count. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + result SetAllSubItemsChecked(int mainIndex, bool check); + + /** + * @if OSPDEPREC + * Removes all the checked sub-items of the specified main item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c mainIndex is less than @c 0, or not less than the main item count. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + result RemoveAllCheckedSubItemsAt(int mainIndex); + + /** + * @if OSPDEPREC + * Gets the first sub-item of all the checked sub-items in the main item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return The index of the first checked sub-item, @n + * else @c -1 if no sub-item is checked, or the specified main item does not exist + * @endif + */ + int GetFirstCheckedSubItemIndex(int mainIndex) const; + + /** + * @if OSPDEPREC + * Gets the last item of all the checked main items in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return The index of the last checked item, @n + * else @c -1 if no main item is checked + * @endif + */ + int GetLastCheckedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the last sub-item of all the checked sub-items in the main item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return The index of the last checked sub-item, @n + * else @c -1 if no sub-item is checked or the specified main item does not exist + * @endif + */ + int GetLastCheckedSubItemIndex(int mainIndex) const; + + /** + * @if OSPDEPREC + * Gets the next checked main item from the specified index in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return The index of the next checked main item, @n + * else @c -1 if no more main item after the specified index is checked, or the specified main item does not exist + * @param[in] mainIndex The index of the main item + * @endif + */ + int GetNextCheckedItemIndexAfter(int mainIndex) const; + + /** + * Gets the next checked sub-item from the specified index in the main item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return The index of the next checked sub-item, @n + * else @c -1 if no more sub-item after the specified index is checked, or the specified sub-item does not exist + * @param[in] mainIndex The index of the main item, that the sub-item belongs to + * @param[in] subIndex The index of the sub-item in the main item + * @endif + */ + int GetNextCheckedSubItemIndexAfter(int mainIndex, int subIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the sub-item with the specified @c itemId. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] itemId The item ID + * @param[out] mainIndex The index of the main item which the sub-item belongs to + * @param[out] subIndex The index of the sub-item + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified item is not found. + * @remarks Note that one or more sub-items can have the same item ID. This method returns the first sub-item among such sub-items. + * @endif + */ + result GetSubItemIndexFromItemId(int itemId, int& mainIndex, int& subIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] x The x position of the point + * @param[in] y The y position of the point + * @param[out] mainIndex The index of the main item which the sub-item belongs to + * @param[out] subIndex The index of the sub-item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetItemIndexFromPosition(int x, int y, int& mainIndex, int& subIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] position The position of the point + * @param[out] mainIndex The index of the main item which the sub-item belongs to + * @param[out] subIndex The index of the sub-item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& mainIndex, int& subIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the first item of the visible items in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[out] mainIndex The main index of the top drawn item + * @param[out] subIndex The sub-index of the top drawn item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks @c mainIndex is @c -1 if no item is visible. @n + * @c subIndex is @c -1 if the top item drawn is a main item. + * @endif + */ + result GetTopDrawnItemIndex(int& mainIndex, int& subIndex) const; + + + /** + * @if OSPDEPREC + * Gets the index of the last of the visible items in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[out] mainIndex The main index of the bottom drawn item + * @param[out] subIndex The sub-index of the bottom drawn item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks @c mainIndex is @c -1 if no item is visible. @n + * @c subIndex is @c -1 if the bottom item drawn is a main item. + * @endif + */ + result GetBottomDrawnItemIndex(int& mainIndex, int& subIndex) const; + + + /** + * @if OSPDEPREC + * Sets the background color of this control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @param[in] color The background color + * @endif + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Sets the text to display when there is no item in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @param[in] text The text message to be displayed + * @endif + */ + void SetTextOfEmptyList(const Tizen::Base::String& text); + + /** + * @if OSPDEPREC + * Sets the color of the text to be displayed when there is no item in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @param[in] color The color of the text to be displayed + * @endif + */ + void SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Gets the color of the text to be displayed when there is no item in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return The color of the text to be displayed + * @endif + */ + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + + /** + * @if OSPDEPREC + * Scrolls to the bottom of the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * @endif + */ + void ScrollToBottom(void); + + /** + * @if OSPDEPREC + * Scrolls to the top of the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * @endif + */ + void ScrollToTop(void); + + /** + * @if OSPDEPREC + * Scrolls to the item at the specified index. @n + * The specified item is drawn at the top of the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item + * @param[in] subIndex The index of the sub-item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_ARG The specified item does not exist. + * @endif + */ + result ScrollToTop(int mainIndex, int subIndex); + + /** + * @if OSPDEPREC + * Scrolls to the main item at the specified index. @n + * The specified main item is drawn at the top of the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_ARG The specified @c mainIndex is less than @c 0, or not less than the main item count. + * @endif + */ + result ScrollToTop(int mainIndex); + + /** + * @if OSPDEPREC + * Draws and shows the item at the specified index in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item + * @param[in] subIndex The index of the sub-item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_OPERATION The item has never been drawn before calling this method. + * @exception E_INVALID_ARG The specified item does not exist. + * @endif + */ + result RefreshSubItem(int mainIndex, int subIndex); + + /** + * @if OSPDEPREC + * Draws and shows the main item at the specified index in the %ExpandableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedTableView class. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_OPERATION The item has never been drawn before calling this method. + * @exception E_INVALID_ARG The specified @c mainIndex is invalid. + * @endif + */ + result RefreshItem(int mainIndex); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + ExpandableList(const ExpandableList& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + ExpandableList& operator =(const ExpandableList& rhs); + + friend class _ExpandableListImpl; +}; //ExpandableList + +}}} // Tizen::Ui::Controls +#endif // _FUI_CTRL_EXPANDABLE_LIST_H_ diff --git a/inc/FUiCtrlFooter.h b/inc/FUiCtrlFooter.h new file mode 100644 index 0000000..b2eeea3 --- /dev/null +++ b/inc/FUiCtrlFooter.h @@ -0,0 +1,846 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlFooter.h + * @brief This is the header file for the %Footer class. + * + * This header file contains the declarations of the %Footer class. + */ + +#ifndef _FUI_CTRL_FOOTER_H_ +#define _FUI_CTRL_FOOTER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Tizen { namespace Ui { namespace Controls +{ +class _FooterImpl; +/** + * @enum FooterStyle + * + * Defines the possible styles of a %Footer control. + * + * @since 2.0 + */ +enum FooterStyle +{ + FOOTER_STYLE_BUTTON_TEXT, /**< The text button style */ + FOOTER_STYLE_BUTTON_ICON, /**< The icon button style */ + FOOTER_STYLE_BUTTON_ICON_TEXT, /**< The icon and text button style */ + FOOTER_STYLE_SEGMENTED_TEXT, /**< The text segmented style */ + FOOTER_STYLE_SEGMENTED_ICON, /**< The icon segmented style */ + FOOTER_STYLE_SEGMENTED_ICON_TEXT, /**< The icon and text segmented style */ + FOOTER_STYLE_TAB /**< The tab style */ +}; + +/** + * @class Footer + * @brief This class is an implementation of a %Footer control. + * + * @since 2.0 + * + * The %Footer class displays a multi-purpose area at the bottom of the screen. It is used to switch between different application + * "views", or to host buttons for performing user-defined actions. + * + * For more information on the class features, see Footer. + * + * The following examples demonstrate how to use the %Footer class. + * - Constructing a footer + * When creating a %Form, specify the FORM_STYLE_FOOTER parameter in the Form::Construct() method. + * + * @code + * // Initializes + * bool + * TestForm::Initialize(void) + * { + * Construct(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER); + * } + * @endcode + * + * - Using the footer + * Gets the footer with the GetFooter() method, and sets the footer style + * + * @code + * bool + * TestForm::Initialize(void) + * { + * Footer* pFooter = GetFooter(); + * pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_TEXT); + * } + * @endcode + * + * - Adding items to the footer: + * Adds FooterItems or ButtonItems according to the footer style. The action ID registered in the Construct() method is notified + * when items are touched. + * + * @code + * bool + * TestForm::Initialize(void) + * { + * FooterItem footerItem; + * footerItem.Construct(ID_FOOTER_ITEM); + * footerItem.SetText("FooterItem"); + * + * pFooter->AddItem(footerItem); + * + * ButtonItem buttonItem; + * buttonItem.Construct(BUTTON_ITEM_STYLE_ICON, ID_HEADER_BUTTON); + * buttonItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, __pBitmap); + * + * pFooter->SetButton(BUTTON_POSITION_LEFT, buttonItem); + * + * } + * @endcode + * + * -Using the back button + * The image of back button is internally set by UI framework. + * + * @code + * bool + * TestForm::Initialize(void) + * { + * pFooter->SetBackButton(); + * } + * @endcode + */ +class _OSP_EXPORT_ Footer + : public Tizen::Ui::Control +{ +public: + /** + * Adds the specified footer item. + * + * @since 2.0 + * + * @return An error code + * @param[in] item The footer item to be added + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified item is not constructed. + * @exception E_SYSTEM A system error has occurred. + * @remarks The %Footer control does not throw any exception even though the same action ID is assigned to multiple items. @n + * However, the content of the specified item is copied to the %Footer control. @n + * Depending on the style of the %Footer control, several types of items can be added or inserted. + */ + result AddItem(const FooterItem& item); + + + /** + * Inserts the footer item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index where the item must be inserted + * @param[in] item The footer item object to be inserted + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than @c 0. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified item is not constructed. + * @exception E_SYSTEM A system error has occurred. + * @remarks The %Footer control does not throw any exception even though the same action ID is assigned to multiple items. @n + * However, the content of the specified item is copied to the %Footer control. @n + * Depending on the style of the %Footer control, several types of items can be added or inserted. + */ + result InsertItemAt(int itemIndex, const FooterItem& item); + + + /** + * Checks whether a button item is set at the specified position. + * + * @since 2.0 + * + * @return @c true if the button item is set at the specified position, @n + * else @c false + * @param[in] position The position of the button item + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + bool IsButtonSet(ButtonPosition position) const; + + + /** + * Checks whether the back button item is set. + * + * @since 2.0 + * + * @return @c true if the back button item is set, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + bool IsBackButtonSet(void) const; + + + /** + * Checks whether the tab edit mode is enabled. + * + * @since 2.0 + * + * @return @c true if the tab edit mode is set, @n + * else @c false + * @exception E_SUCCESS The method is successful. + */ + bool IsTabEditModeEnabled(void) const; + + + /** + * Gets the color of the button item for the specified state. + * + * @since 2.0 + * + * @return The color of the button item, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The status of the button item + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetButtonColor() + */ + Tizen::Graphics::Color GetButtonColor(ButtonItemStatus status) const; + + + /** + * Gets the text color of the button item for the specified state. + * + * @since 2.0 + * + * @return The text color of the button item, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The status of the button item + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetButtonTextColor() + */ + Tizen::Graphics::Color GetButtonTextColor(ButtonItemStatus status) const; + + + /** + * Gets the state of the specified button item. + * + * @since 2.0 + * + * @return The state of the button item at the specified position + * @param[in] position The position of the button item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * There is no button set at the specified position. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + ButtonItemStatus GetButtonStatus(ButtonPosition position) const; + + + /** + * Gets the state of the back button. + * + * @since 2.0 + * + * @return The state of the back button, @n + * else @c BUTTON_ITEM_STATUS_NORMAL if an error occurs. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The back button is not set. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + ButtonItemStatus GetBackButtonStatus(void) const; + + + /** + * Gets the color of the footer item for the specified item state. + * + * @since 2.0 + * + * @return The color of the item, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The item status + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetItemColor() + */ + Tizen::Graphics::Color GetItemColor(FooterItemStatus status) const; + + + /** + * Gets the number of footer items. + * + * @since 2.0 + * + * @return The number of footer items, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetItemCount(void) const; + + + /** + * Gets the state of the specified footer item. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index of the item + * @param[out] status The state of the item at the specified index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than zero. + */ + result GetItemStatus(int itemIndex, FooterItemStatus& status) const; + + + /** + * Gets the text color of the footer item for the specified item state. + * + * @since 2.0 + * + * @return The text color of the item, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The item status + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetItemTextColor(FooterItemStatus status) const; + + + /** + * Gets the style of the %Footer control. + * + * @since 2.0 + * + * @return The footer style, @n + * else @c FOOTER_STYLE_BUTTON_TEXT if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + FooterStyle GetStyle(void) const; + + + /** + * Gets the index of the currently selected item. + * + * @since 2.0 + * + * @return The selected item index,@n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is supported only when the style of the %Footer control is either segmented or tab. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetSelectedItemIndex(void) const; + + + /** + * Gets the color of the footer. + * + * @since 2.0 + * + * @return The color, @n + * else RGBA (0,0,0,0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetColor(void) const; + + + /** + * Removes all the button items. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The back button will be also removed. + */ + result RemoveAllButtons(void); + + + /** + * Removes the button item at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position of the button item to be removed + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks If no button item is set at the specified position, the method will return @c E_SUCCESS. + */ + result RemoveButtonAt(ButtonPosition position); + + + /** + * Removes the back button item. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks If the back button item is not set, the method will return @c E_SUCCESS. + */ + result RemoveBackButton(void); + + + /** + * Removes all the footer items. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The left, right, and back button items are not removed. + */ + result RemoveAllItems(void); + + + /** + * Removes the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index of the item to be removed + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveItemAt(int itemIndex); + + + /** + * Sets the background bitmap image. + * + * @since 2.0 + * + * @return An error code + * @param[in] pBitmap The background image + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + + /** + * Sets the button item at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position at which to set the specified button item. + * @param[in] button The button item to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified item is not constructed. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * There are more than 2 footer items. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is supported when the style of the %Footer control is either + * @c FOOTER_STYLE_SEGMENTED_TEXT or @c FOOTER_STYLE_SEGMENTED_ICON. + * @exception E_SYSTEM A system error has occurred. + * @remarks If there is an existing button item at the specified position, it is replaced with the new item.@n + * However, the contents of the specified item are copied to the %Footer control. + */ + result SetButton(ButtonPosition position, const ButtonItem& button); + + + /** + * Sets the button item color for the specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status of the button item + * @param[in] color The button item color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetButtonColor() + */ + result SetButtonColor(ButtonItemStatus status, const Tizen::Graphics::Color& color); + + + /** + * Enables or disables the button item at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The button item position + * @param[in] enable Set to @c true to enable the specified button item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * There is no button set at the specified position. + * @exception E_SYSTEM A system error has occurred. + */ + result SetButtonEnabled(ButtonPosition position, bool enable); + + + /** + * Enables or disables the back button. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the back button, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The back button item is not set. + * @exception E_SYSTEM A system error has occurred. + */ + result SetBackButtonEnabled(bool enable); + + + /** + * Sets the button item text color for the specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status of the button item + * @param[in] color The button item text color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetButtonTextColor() + */ + result SetButtonTextColor(ButtonItemStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the badge icon of the specified ButtonItem. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The button item position + * @param[in] pBadgeIcon The bitmap for the icon + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the style of the %Footer control is @c FOOTER_STYLE_TAB. + */ + result SetButtonBadgeIcon(ButtonPosition position, const Tizen::Graphics::Bitmap* pBadgeIcon); + + + /** + * Sets the numbered badge icon of the specified ButtonItem. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The button item position + * @param[in] number The number value that should be displayed as the badge icon + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c number must be in the range defined by @c 0 and @c 99999. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the style of the %Footer control is @c FOOTER_STYLE_TAB. + * @remarks To remove the numbered badge icon from an item, pass @c 0 as the value of @c number. + */ + result SetButtonNumberedBadgeIcon(ButtonPosition position, int number); + + + /** + * Sets the back button. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * There are more than 2 footer items. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the style of the %Footer control is @c FOOTER_STYLE_TAB. @n + * This device does not support the software back button. + * @exception E_SYSTEM A system error has occurred. + * @remarks When the back button is pressed, OnFormBackRequested() of IFormBackEventListener is called. @n + * If the right button is already set, then the button is replaced with the back button. + * @see Tizen::Ui::Controls::IFormBackEventListener + */ + result SetBackButton(void); + + + /** + * Sets the content of the footer item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index at which to set the specified item + * @param[in] item The item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than @c 0. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified item is not constructed. + * @exception E_SYSTEM A system error has occurred. + * @remarks The %Footer control does not throw any exception even though the same action ID is assigned to multiple items. @n + * However, the content of the specified item is copied to the %Footer control. + */ + result SetItemAt(int itemIndex, const FooterItem& item); + + + /** + * Sets the item color for the specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The item status + * @param[in] color The item color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The current style of the %Footer control does not support the operation. + * @exception E_SYSTEM A system error has occurred. + * @remarks It is not possible to set the item colors for the normal and disabled status of the @c FOOTER_STYLE_TAB style %Footer control. @n + Furthermore, @c FOOTER_STYLE_BUTTON_ICON style %Footer control does not support this operation. + * @see GetItemColor() + */ + result SetItemColor(FooterItemStatus status, const Tizen::Graphics::Color& color); + + + /** + * Sets the item state at the specified index in the footer. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index of the item + * @param[in] enable Set to @c true to enable the item state, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than zero. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The specified item is currently selected. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemEnabled(int itemIndex, bool enable); + + + /** + * Sets the badge icon of the specified tab style footer item. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index of the item to set the badge icon + * @param[in] pBadgeIcon The bitmap for the icon + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than @c 0. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the style of the %Footer control is @c FOOTER_STYLE_BUTTON_ICON. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemBadgeIcon(int itemIndex, const Tizen::Graphics::Bitmap* pBadgeIcon); + + + /** + * Sets the numbered badge icon of the specified footer item. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The item index + * @param[in] number The number value that must be displayed as the badge icon + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c number must be in the range defined by @c 0 and @c 99999. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than @c 0. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the style of the %Footer control is @c FOOTER_STYLE_BUTTON_ICON. + * @exception E_SYSTEM A system error has occurred. + * @remarks To remove the numbered badge icon from an item, pass @c 0 as the value of @c number. + */ + result SetItemNumberedBadgeIcon(int itemIndex, int number); + + + /** + * Sets the item text color for the specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The item status + * @param[in] color The item text color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemTextColor(FooterItemStatus status, const Tizen::Graphics::Color& color); + + + /** + * Selects the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index of the item to be selected + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is out of the range of the data structure. @n + * The specified index is either greater than or equal to the number of items or is less than zero. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The item at the specified index is disabled. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported if the %Footer control style is either @c FOOTER_STYLE_BUTTON_TEXT or @c FOOTER_STYLE_BUTTON_ICON. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemSelected(int itemIndex); + + + /** + * Sets the color of the footer. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The footer color to be set + * @exception E_SUCCESS The method is successful. + */ + result SetColor(const Tizen::Graphics::Color& color); + + + /** + * Sets the style of the footer. + * + * @since 2.0 + * + * @return An error code + * @param[in] style The footer style to set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks All items and buttons will be removed if the style is changed. + */ + result SetStyle(FooterStyle style); + + + /** + * Enables or disables the tab edit mode. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the edit mode, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the style of the %Footer control style is not @c FOOTER_STYLE_TAB. + */ + result SetTabEditModeEnabled(bool enable); + + + /** + * Adds an action event listener instance. + * OnActionPerformed() of the added listener is called when the user selects an item. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks When the user collapses the tab style %Footer control which is in the expanded mode by pressing the more button, OnActionPerformed() is called for the currently selected tab item. + */ + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + + /** + * Removes an action event listener instance. + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + */ + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + + /** + * Gets the position and size of the specified button item. + * + * @since 2.0 + * + * @return The position and size of the button item at the specified position. + * @param[in] position The position of the button item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * There is no button set at the specified position. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Rectangle GetButtonBounds(ButtonPosition position) const; + + +protected: + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This is the default constructor for this class. + // @since 2.0 + // + Footer(void); + + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This is the destructor for this class. + // @since 2.0 + // + virtual ~Footer(void); + + +private: + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // Initializes this instance of Footer with the specified parameter. + // + // @since 2.0 + // @return An error code + // @exception E_SUCCESS The method is successful. + // @exception E_SYSTEM A system error has occurred. + // + result Construct(void); + + Footer(const Footer& rhs); + Footer& operator =(const Footer& rhs); + +private: + friend class _FormImpl; + friend class _FooterImpl; + +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_FOOTER_H_ diff --git a/inc/FUiCtrlFooterItem.h b/inc/FUiCtrlFooterItem.h new file mode 100644 index 0000000..2df4503 --- /dev/null +++ b/inc/FUiCtrlFooterItem.h @@ -0,0 +1,195 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlFooterItem.h + * @brief This is the header file for the %FooterItem class. + * + * This header file contains the declarations of the %FooterItem class. + */ +#ifndef _FUI_CTRL_FOOTER_ITEM_H_ +#define _FUI_CTRL_FOOTER_ITEM_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @enum FooterItemStatus + * + * Defines the possible status of %FooterItem. + * + * @since 2.0 + */ +enum FooterItemStatus +{ + FOOTER_ITEM_STATUS_NORMAL, /**< The normal state */ + FOOTER_ITEM_STATUS_PRESSED, /**< The pressed state */ + FOOTER_ITEM_STATUS_SELECTED, /**< The selected state */ + FOOTER_ITEM_STATUS_HIGHLIGHTED, /**< The highlighted state */ + FOOTER_ITEM_STATUS_DISABLED /**< The disabled state */ +}; + +/** + * @class FooterItem + * @brief This class is an implementation of %FooterItem. + * + * @since 2.0 + * + * The %FooterItem class is a helper class that specifies the contents of the footer item. + * + *For more information on the class features, see Footer. + */ +class _OSP_EXPORT_ FooterItem + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + FooterItem(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~FooterItem(void); + + + /** + * Initializes this instance of %FooterItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] actionId The action ID of this item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c actionId of the specified item must be a positive integer. + */ + result Construct(int actionId); + + + /** + * Gets the action ID of the item. + * + * @since 2.0 + * + * @return The action ID, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetActionId(void) const; + + + /** + * Gets the text of the footer item. + * + * @since 2.0 + * + * @return The item text, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::String GetText(void) const; + + + /** + * Sets the action ID of the footer item. + * + * @since 2.0 + * + * @return An error code + * @param[in] actionId The specified action ID of the footer item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c actionId of the specified item must be a positive integer. + */ + result SetActionId(int actionId); + + + /** + * Sets the background bitmap of the footer item. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status of the footer item + * @param[in] pBitmap The background bitmap to set, @n + * else @c null if no bitmap is displayed. + * @exception E_SUCCESS The method is successful. + * @remarks If the size of the bitmap is greater than the size of the item, the bitmap is scaled down. + */ + result SetBackgroundBitmap(FooterItemStatus status, const Tizen::Graphics::Bitmap* pBitmap); + + + /** + * Sets the icon of the footer item. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status of the footer item + * @param[in] pIcon The icon to set, @n + * else @c null if no bitmap is displayed + * @exception E_SUCCESS The method is successful. + * @remarks If the size of the bitmap is greater than the default icon size, the bitmap is scaled down. @n + * The bitmap specified for the @c FOOTER_ITEM_STATUS_NORMAL will be applied for all other statues unless different bitmaps are explicitly + * set for those by using this method. @n + * Furthermore, the icon button does not support @c FOOTER_ITEM_STATUS_SELECTED status and the bitmap for the status is also ignored. + */ + result SetIcon(FooterItemStatus status, const Tizen::Graphics::Bitmap* pIcon); + + + /** + * Sets the text of the footer item. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be set + * @exception E_SUCCESS The method is successful. + * @remarks If the text cannot be displayed in a line, then the text is automatically displayed in two lines and the ellipsis is applied if the text + * is longer than two lines. @n + * Use @htmlonly '\n' @endhtmlonly to denote the end of the first line. + */ + result SetText(const Tizen::Base::String& text); + + +private: + FooterItem(const FooterItem& footerItem); + FooterItem& operator =(const FooterItem& footerItem); + +private: + friend class _FooterImpl; + friend class _FooterItemImpl; + + class _FooterItemImpl* __pImpl; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_FOOTER_ITEM_H_ diff --git a/inc/FUiCtrlForm.h b/inc/FUiCtrlForm.h new file mode 100644 index 0000000..5c5ee9a --- /dev/null +++ b/inc/FUiCtrlForm.h @@ -0,0 +1,1024 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlForm.h + * @brief This is the header file for the %Form class. + * + * This header file contains the declarations of the %Form class. + */ +#ifndef _FUI_CTRL_FORM_H_ +#define _FUI_CTRL_FORM_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class DataBindingContext; +} } // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class Header; +class Footer; +class Tab; +class IFormBackEventListener; + +/** + * @enum FormStyle + * + * Defines the %Form control style. + * + * @since 2.0 + */ +enum FormStyle +{ + FORM_STYLE_NORMAL = 0x00000000, /**< The basic form style */ + FORM_STYLE_TITLE = 0x00000001, /**<@if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the Title control is no longer recommended.@endif */ + FORM_STYLE_INDICATOR = 0x00000002, /**< The form with the indicator area */ + FORM_STYLE_SOFTKEY_0 = 0x00000010, /**<@if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the Softkey control is no longer recommended.@endif */ + FORM_STYLE_SOFTKEY_1 = 0x00000020, /**<@if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the Softkey control is no longer recommended.@endif */ + FORM_STYLE_OPTIONKEY = 0x00000040, /**<@if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the Optionkey control is no longer recommended.@endif */ + FORM_STYLE_TEXT_TAB = 0x00000100, /**<@if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the Tab control is no longer recommended. @endif */ + FORM_STYLE_ICON_TAB = 0x00000200, /**<@if OSPDEPREC @deprecated This enumeration field is deprecated because the use of the Tab control is no longer recommended. @endif */ + FORM_STYLE_HEADER = 0x00001000, /**< The form with a header */ + FORM_STYLE_FOOTER = 0x00002000 /**< The form with a footer */ +}; + + +/** + * @if OSPDEPREC + * @enum Softkey + * + * Defines the softkey. + * + * @brief [Deprecated] + * @deprecated This enumeration type is deprecated because the use of the Softkey control is no longer recommended. + * @since 2.0 + * @endif + */ +enum Softkey +{ + SOFTKEY_0, /**< @if OSPDEPREC The left softkey @endif */ + SOFTKEY_1, /**< @if OSPDEPREC The right softkey @endif */ + SOFTKEY_COUNT // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. +}; + + +/** + * @enum FormActionBar + * + * Defines the action bars that can be attached to the %Form control. + * + * @since 2.0 + */ +enum FormActionBar +{ + FORM_ACTION_BAR_INDICATOR = 0x0001, /**< The indicator */ + FORM_ACTION_BAR_HEADER = 0x0002, /**< The header */ + FORM_ACTION_BAR_FOOTER = 0x0004, /**< The footer */ + FORM_ACTION_BAR_TAB = 0x0008 /**< The tab */ // Ki-Dong,Hong.Temp +}; + + +/** + * @class Form + * @brief This class provides a container with general controls. + * + * @since 2.0 + * + * The %Form class displays a full screen container. It can contain user-created controls and system UI components, such + * as an indicator area, header, and footer. The application can have multiple forms that are all added to a single Frame. + * + * For more information on the class features, see Form. + * + * The following example demonstrates how to use the %Form class. + * + * Example: + * + *@image html ui_controls_form.png + *@n + * + * This is a simple UI application that uses a %Form. + * + * + * @code + // Creates an instance of Form + Form* pForm = new Form(); + pForm->Construct(FORM_STYLE_NORMAL| FORM_STYLE_HEADER| FORM_STYLE_FOOTER); + + // Gets a pointer of the frame + Frame *pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame(); + pFrame->AddControl(*pForm); + pFrame->SetCurrentForm(*pForm); + + // Implements MyActionEventListener + IActionEventListener* pListener = new MyActionEventListener(); + + // Adds a header + Header * pHeader = GetHeader(); + pHeader->SetTitleText(L"FormSample"); + + // Adds a footer + Footer * pFooter = GetFooter(); + pFooter->SetStyle(FOOTER_STYLE_TAB); + pFooter->AddActionEventListener(*this); + + // Calls Invalidate() to display the form + pForm->Invalidate(true) + * @endcode + * + */ +class _OSP_EXPORT_ Form + : public Tizen::Ui::Container +{ +public: +// Lifecycle + /** + * This is the default constructor for this class. + * @since 2.0 + */ + Form(void); + + /** + * This is the destructor for this class. + * @since 2.0 + */ + virtual ~Form(void); + + /** + * Initializes this instance of %Form with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] formStyle The form style @n + * Multiple form styles can be combined using bitwise OR (see Tizen::Ui::Controls::FormStyle). + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid @if OSPCOMPAT @b Since: @b 2.0 @endif. @n + * - FORM_STYLE_HEADER and FORM_STYLE_TITLE are specified at the same time. @n + * - FORM_STYLE_FOOTER and FORM_STYLE_SOFTKEY_0 are specified at the same time. @n + * - FORM_STYLE_FOOTER and FORM_STYLE_SOFTKEY_1 are specified at the same time. @n + * - FORM_STYLE_FOOTER and FORM_STYLE_OPTIONKEY are specified at the same time. + * @exception E_MAX_EXCEEDED The total number of Frames and Forms exceeds the system limitation. + * @exception E_SYSTEM A system error has occurred. + * @remarks The maximum number of Forms that an application can construct is limited by available memory. + * @see FormStyle + */ + result Construct(unsigned long formStyle); + + + /** + * Initializes this instance of %Form with the specified resource ID. @n + * This method first attempts to find the resource file in the folder that corresponds to the current screen resolution. If it fails to find the + * appropriate resource file, the method tries searching in other folders. When AutoScaling is enabled, the method first searches the folder that + * corresponds to the current screen size category and then searches the "res/screen-size-normal/" folder. + * + * @since 2.0 + * + * @return An error code + * @param[in] resourceId The resource ID describing the %Form control + * @exception E_SUCCESS The method is successful. + * @exception E_FILE_NOT_FOUND The specified file cannot be found. + * @exception E_INVALID_FORMAT The specified XML format is invalid. + * @exception E_OPERATION_FAILED The operation has failed. + */ + result Construct(const Tizen::Base::String& resourceId); + + /** + * Initializes this instance of %Form with the form style and layout. + * + * @since 2.0 + * + * @return An error code + * @param[in] layout The layout for both the portrait and landscape mode + * @param[in] formStyle The form style @n + * Multiple form styles can be combined using bitwise OR (see Tizen::Ui::Controls::FormStyle). + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or + * the specified layout is already bound to another container. + * @exception E_MAX_EXCEEDED The total number of Frames and Forms exceeds the system limitation. + * @exception E_SYSTEM A system error has occurred. + * @remarks The maximum number of Forms that an application can construct is limited by available memory. @n + * The children are arranged within the client area bounds of the form area by @c layout. + * @see FormStyle + */ + result Construct(const Tizen::Ui::Layout& layout, unsigned long formStyle); + + /** + * Initializes this instance of %Form with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] portraitLayout The layout for the portrait mode + * @param[in] landscapeLayout The layout for the landscape mode + * @param[in] formStyle The form style @n + * Multiple form styles can be combined using bitwise OR (see Tizen::Ui::Controls::FormStyle). + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or + * the specified layout is already bound to another container. + * @exception E_MAX_EXCEEDED The total number of Frames and Forms exceeds the system limitation. + * @exception E_SYSTEM A system error has occurred. + * @remarks The maximum number of Forms that an application can construct is limited by available memory. @n + * The children are arranged within the bounds of the form area by @c layout. + * @see FormStyle + */ + result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, unsigned long formStyle); + +// Operation + + /** + * Adds an IOrientationEventListener instance. @n + * The added listener can listen to the orientation changed events that are fired when the orientation mode of the screen is changed. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @remarks The %Form control can only listen to those changes to the orientation mode that are enabled by calling SetOrientation(). + * @see RemoveOrientationEventListener() + */ + void AddOrientationEventListener(Tizen::Ui::IOrientationEventListener& listener); + + + /** + * @if OSPDEPREC + * Adds an IActionEventListener instance. @n + * The added listener can listen to the action events that are fired when an option key is selected. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Optionkey control is no longer recommended. + * @since 2.0 + * + * @param[in] listener The listener to be added + * @see RemoveOptionkeyActionListener() + * @endif + */ + void AddOptionkeyActionListener(Tizen::Ui::IActionEventListener& listener); + + + /** + * @if OSPDEPREC + * Adds an IActionEventListener instance. @n + * The added listener can listen to the action events that are fired when a softkey is selected. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Softkey control is no longer recommended. + * @since 2.0 + * + * @param[in] softkey The style of the softkey + * @param[in] listener The listener to be added + * @see RemoveSoftkeyActionListener() + * @endif + */ + void AddSoftkeyActionListener(Softkey softkey, Tizen::Ui::IActionEventListener& listener); + + + /** + * @if OSPDEPREC + * Removes an IActionEventListener instance. @n + * The removed listener cannot listen to the events when they are fired. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Optionkey control is no longer recommended. + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see AddOptionkeyActionListener() + * @endif + */ + void RemoveOptionkeyActionListener(Tizen::Ui::IActionEventListener& listener); + + + /** + * Removes an IOrientationEventListener instance. @n + * The removed listener cannot listen to the events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * + * @see AddOrientationEventListener() + */ + void RemoveOrientationEventListener(Tizen::Ui::IOrientationEventListener& listener); + + + /** + * @if OSPDEPREC + * Removes an IActionEventListener instance. @n + * The removed listener cannot listen to the events when they are fired. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Softkey control is no longer recommended. + * @since 2.0 + * + * @param[in] softkey The style of the softkey + * @param[in] listener The listener to be removed + * @see AddSoftkeyActionListener() + * @endif + */ + void RemoveSoftkeyActionListener(Softkey softkey, Tizen::Ui::IActionEventListener& listener); + + +// Accessor + /** + * Gets the background color of the %Form control. + * + * @since 2.0 + * + * @return The background color of the %Form control + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + + + /** + * Gets the bounds of the client area. + * + * @since 2.0 + * + * @return The bounds of the client area + * @remarks The client area of the %Form control does not include the title, indicator, header and footer areas. + * header and footer areas. + * + */ + Tizen::Graphics::Rectangle GetClientAreaBounds(void) const; + + + /** + * Gets the style of the %Form control. + * + * @since 2.0 + * + * @return An @c unsigned @c long value representing the style of the %Form control + */ + unsigned long GetFormStyle(void) const; + + + /** + * Gets the orientation mode of the %Form control. + * + * @since 2.0 + * + * @return The orientation of the %Form control + */ + Tizen::Ui::Orientation GetOrientation(void) const; + + + /** + * Gets the current orientation status of the %Form control. + * + * @since 2.0 + * + * @return The orientation status of the %Form control, @n + * else ORIENTATION_NONE if the %Form control is not the current form of the Frame control + */ + Tizen::Ui::OrientationStatus GetOrientationStatus(void) const; + + + /** + * @if OSPDEPREC + * Gets the action ID of the specified softkey. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Softkey control is no longer recommended. + * @since 2.0 + * + * @return An integer value representing the action ID + * @param[in] softkey The softkey + * @endif + */ + int GetSoftkeyActionId(Softkey softkey) const; + + + /** + * @if OSPDEPREC + * Gets the text of the specified softkey. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Softkey control is no longer recommended. + * @since 2.0 + * + * @return The text of the softkey + * @param[in] softkey The softkey + * @endif + */ + Tizen::Base::String GetSoftkeyText(Softkey softkey) const; + + + /** + * @if OSPDEPREC + * Gets the pointer of the Tab control if it exists. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Tab control is no longer recommended. + * @since 2.0 + * + * @return A pointer to the Tab control, @n + * else @c null if there is no tab + * @remarks The retrieved pointer may be temporary. Therefore, it should not be stored after immediate use. + * @endif + */ + Tab* GetTab(void) const; + + + /** + * @if OSPDEPREC + * Gets the title of the %Form control. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Title control is no longer recommended. Instead of the %Title control, + * use the Header control. + * @since 2.0 + * + * @return The title of the %Form control + * @endif + */ + Tizen::Base::String GetTitleText(void) const; + + + /** + * @if OSPDEPREC + * Gets the horizontal alignment of the title text. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Title control is no longer recommended. Instead of the %Title control, + * use the Header control. + * @since 2.0 + * + * @return The horizontal alignment of the title text + * @remarks By default, the horizontal alignment is center aligned. + * @endif + */ + HorizontalAlignment GetTitleTextHorizontalAlignment(void) const; + + /** + * Checks whether the %Form control has an Indicator. + * + * @since 2.0 + * + * @return @c true if the %Form control has a title, @n + * else @c false + */ + bool HasIndicator(void) const; + + + /** + * @if OSPDEPREC + * Checks whether the %Form control has an optionkey. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Optionkey control is no longer recommended. + * @since 2.0 + * + * @return @c true if the %Form control has an optionkey, @n + * else @c false + * @endif + */ + bool HasOptionkey(void) const; + + + /** + * @if OSPDEPREC + * Checks whether the %Form control has the specified softkey. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Softkey control is no longer recommended. + * @since 2.0 + * + * @return @c true if the %Form control has the specified softkey, @n + * else @c false + * @param[in] softkey The required softkey + * @endif + */ + bool HasSoftkey(Softkey softkey) const; + + + /** + * @if OSPDEPREC + * Checks whether the %Form control has a tab. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Tab control is no longer recommended. + * @since 2.0 + * + * @return @c true if the %Form control has a tab, @n + * else @c false + * @endif + */ + bool HasTab(void) const; + + + /** + * @if OSPDEPREC + * Checks whether the %Form control has a title. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Title control is no longer recommended. Instead of the %Title control, + * use the Header control. + * @since 2.0 + * + * @return @c true if the %Form control has a title, @n + * else @c false + * @endif + */ + bool HasTitle(void) const; + + + /** + * @if OSPDEPREC + * Checks whether the softkey is enabled. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Softkey control is no longer recommended. + * @since 2.0 + * + * @return @c true if the softkey is enabled, @n + * else @c false + * @param[in] softkey The softkey + * @endif + */ + bool IsSoftkeyEnabled(Softkey softkey) const; + + + /** + * Sets the background color of the %Form control. + * + * @since 2.0 + * + * @param[in] color The background color to set + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + + /** + * Sets the style of the %Form control. + * + * @since 2.0 + * + * @param[in] formStyle The form style to set @n + * This parameter can be a combination of Tizen::Ui::Controls::FormStyle. + * @exception E_SUCCESS The method is successful @if OSPCOMPAT @b Since: @b 2.0 @endif. + * @exception E_INVALID_ARG A specified input parameter is invalid @if OSPCOMPAT @b Since: @b 2.0 @endif. @n + * - FORM_STYLE_HEADER and FORM_STYLE_TITLE are specified at the same time. @n + * - FORM_STYLE_FOOTER and FORM_STYLE_SOFTKEY_0 are specified at the same time. @n + * - FORM_STYLE_FOOTER and FORM_STYLE_SOFTKEY_1 are specified at the same time. @n + * - FORM_STYLE_FOOTER and FORM_STYLE_OPTIONKEY are specified at the same time. @n + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * Note that you must not change the style of %Form control that is constructed with FORM_STYLE_TEXT_TAB or FORM_STYLE_ICON_TAB style. + * A Form which is added to a container except Frame cannot have the style of @c FORM_STYLE_INDICATOR. + */ + void SetFormStyle(unsigned long formStyle); + + + /** + * @if OSPDEPREC + * Sets an action ID of the optionkey. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Optionkey control is no longer recommended. + * @since 2.0 + * + * @param[in] actionId The action ID of this button instance + * @endif + */ + void SetOptionkeyActionId(int actionId); + + + /** + * Sets the orientation of the %Form control. + * + * @since 2.0 + * + * @param[in] orientation The orientation of the %Form control + */ + void SetOrientation(Orientation orientation); + + + /** + * @if OSPDEPREC + * Sets an action ID of each softkey. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Softkey control is no longer recommended. + * @since 2.0 + * + * @param[in] softkey The softkey + * @param[in] actionId The action ID to be set + * @endif + */ + void SetSoftkeyActionId(Softkey softkey, int actionId); + + + /** + * @if OSPDEPREC + * Enables or disables the specified softkey. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Softkey control is no longer recommended. + * @since 2.0 + * + * @param[in] softkey The softkey + * @param[in] enable Set to @c true to enable this softkey @n + * else @c false + * @endif + */ + void SetSoftkeyEnabled(Softkey softkey, bool enable); + + + /** + * @if OSPDEPREC + * Sets the title icon of the %Form control. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Title control is no longer recommended. Instead of the %Title control, + * use the %Header control. + * @since 2.0 + * + * @return An error code + * @param[in] pTitleBitmap The title icon to be set, @n + * else @c null if the title icon is removed + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of a specified operation (that is, this control cannot be displayed). + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetTitleIcon(const Tizen::Graphics::Bitmap* pTitleBitmap); + + + /** + * @if OSPDEPREC + * Sets the title of this %Form control. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Title control is no longer recommended. Instead of the %Title control, + * use the Header control. + * @since 2.0 + * + * @return An error code + * @param[in] title The title to be set + * @param[in] alignment The horizontal alignment + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of a specified operation (that is, this control cannot be displayed). + * @exception E_SYSTEM A system error has occurred. + * @remarks If the size of the text exceeds the displayable area, the text slides automatically. @n + * Note that when the title icon is set along with the title text, the title retains the left alignment. + * @endif + */ + result SetTitleText(const Tizen::Base::String& title, HorizontalAlignment alignment = ALIGNMENT_CENTER); + + + /** + * @if OSPDEPREC + * Sets the icon of the softkey. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Softkey control is no longer recommended. + * @since 2.0 + * + * @param[in] softkey The softkey + * @param[in] normalBitmap The Bitmap of the normal icon + * @param[in] pPressedBitmap The Bitmap of the pressed icon + * @remarks If both the icon and text are set for a softkey at the same time, the text takes precedence over the icon. + * @endif + */ + void SetSoftkeyIcon(Softkey softkey, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap); + + /** + * @if OSPDEPREC + * Sets the text of the specified softkey. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the use of the Softkey control is no longer recommended. + * @since 2.0 + * + * @param[in] softkey The softkey + * @param[in] text The text to be set + * @remarks If both the icon and text are set for a softkey at the same time, the text takes precedence over the icon. @n + * To display text in multi-lines or to denote the end of line, use '\\n'. + * @endif + */ + void SetSoftkeyText(Softkey softkey, const Tizen::Base::String& text); + + /** + * Gets the pointer to the Footer control if it exists. + * + * @since 2.0 + * + * @return A pointer to the Footer control, @n + * else @c null if there is no %Footer + * @remarks The retrieved pointer may be temporary. Therefore, it should not be stored after immediate use. + */ + Footer* GetFooter(void) const; + + + /** + * Gets the pointer to the Header control if it exists. + * + * @since 2.0 + * + * @return A pointer to the Header control, @n + * else @c null if there is no %Header + * @remarks The retrieved pointer may be temporary. Therefore, it should not be + * stored after immediate use. + */ + Header* GetHeader(void) const; + + + /** + * Checks whether the %Form control has a Footer. + * + * @since 2.0 + * + * @return @c true if the %Form control has a Footer, @n + * else @c false + */ + bool HasFooter(void) const; + + + /** + * Checks whether the %Form control has a Header. + * + * @since 2.0 + * + * @return @c true if the %Form control has a Header, @n + * else @c false + */ + bool HasHeader(void) const; + + + /** + * Checks whether the Indicator control is visible. + * + * @since 2.0 + * + * @return @c true if the Indicator control is visible, @n + * else @c false + */ + bool IsIndicatorVisible(void) const; + + + /** + * Checks whether the Header control is visible. + * + * @since 2.0 + * + * @return @c true if the Header control is visible, @n + * else @c false + */ + bool IsHeaderVisible(void) const; + + + /** + * Checks whether the Footer control is visible. + * + * @since 2.0 + * + * @return @c true if the Footer control is visible, @n + * else @c false + */ + bool IsFooterVisible(void) const; + + + /** + * Checks whether the Indicator control is translucent. + * + * @since 2.0 + * + * @return @c true if the Indicator control is translucent, @n + * else @c false + */ + bool IsIndicatorTranslucent(void) const; + + + /** + * Checks whether the Header control is translucent. + * + * @since 2.0 + * + * @return @c true if the Header control is translucent, @n + * else @c false + */ + bool IsHeaderTranslucent(void) const; + + + /** + * Checks whether the Footer control is translucent. + * + * @since 2.0 + * + * @return @c true if the Footer control is translucent, @n + * else @c false + */ + bool IsFooterTranslucent(void) const; + + + /** + * Sets the translucency of the action bars. + * + * @since 2.0 + * + * @return An error code + * @param[in] actionBars The action bars @n + * Multiple action bars can be combined using bitwise OR (see Tizen::Ui::Controls::FormActionBar). + * @param[in] translucent Set to @c to make the action bars translucent, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of a specified operation, or + * the specified action bars do not exist. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @exception E_SYSTEM A system error has occurred. + * @remarks Modifying the translucency of the action bars causes the client area of the %Form to change. @n + * The translucency of multiple action bars can be modified at the same time by using logical OR for several values of FormActionBar. + * @remarks The method is not supported in 16-bit devices. + * @see FormActionBar + */ + result SetActionBarsTranslucent(unsigned long actionBars, bool translucent); + + + /** + * Sets the visibility state of the action bars. + * + * @since 2.0 + * + * @return An error code + * @param[in] actionBars The action bars @n + * Multiple action bars can be combined using bitwise OR (see Tizen::Ui::Controls::FormActionBar). + * @param[in] visible Set to @c true to make the action bars visible, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation, or + * the specified action bars does not exist. + * @exception E_SYSTEM A system error has occurred. + * @remarks Modifying the translucency of action bars causes the client area of the %Form to change. @n + * The visibility of multiple action bars can be modified at the same time by using logical OR for several values of FormActionBar. + * @see FormActionBar + */ + result SetActionBarsVisible(unsigned long actionBars, bool visible); + + + /** + * Creates and returns an overlay region of the specified position and size. @n + * Due to the hardware accelerated rendering, there are limitations for an overlay region. @n + * The hardware capability for an overlay region is checked by using OverlayRegion::GetWidthUnit(), OverlayRegion::GetHeightUnit() and + * OverlayRegion::GetMaxCount(). + * If the specified condition is not satisfied, E_INVALID_ARG exception is returned. + * + * @since 2.0 + * + * @return An overlay region instance + * @param[in] rect The x and y coordinates relative to the top-left corner of the form along with the width and height + * @param[in] regionType The type of the overlay region + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_MAX_EXCEEDED The number of overlay regions has reached the maximum limit. + * @exception E_UNSUPPORTED_OPTION The specified option of the overlay region type is not supported. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * If the application runs on multi-screen resolutions, the specified bounds may not meet the hardware limitations of the overlay region. @n + * In such cases, GetOverlayRegionN() returns the E_INVALID_ARG exception. To prevent this problem, the application should use the + * OverlayRegion::EvaluateBounds() method to get the validated bounds that can be used as the input bounds of the GetOverlayRegionN() method. + * @remarks Do not use OverlayRegion with OverlayPanel. If used, the E_SYSTEM exception is thrown. + */ + OverlayRegion* GetOverlayRegionN(const Tizen::Graphics::Rectangle& rect, OverlayRegionType regionType); + + + /** + * Creates and returns a graphics canvas whose bounds (position and size) are equal to the bounds of the client area of the %Form. + * + * @since 2.0 + * + * @return The graphic canvas of the %Form control, @n + * else @c null if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_RESOURCE_UNAVAILABLE The required resource is currently unavailable. + * @remarks The method allocates Tizen::Graphics::Canvas whose bounds are equal to that of the client area of the %Form. @n + * It is the responsibility of the developers to deallocate the canvas after use. + * @remarks The canvas is valid only if the properties of the parent control of the canvas remain unchanged. @n + * Therefore, delete the previously allocated canvas and create a new canvas using the GetCanvasN() method @n + * if the size or position of the control is changed. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks The Frame and %Form instances share a single frame-buffer. @n + * Therefore, the custom drawing on the graphic canvas of the Frame and %Form controls appears on the screen regardless of whether the + * control is currently visible on the screen. + */ + Tizen::Graphics::Canvas* GetClientAreaCanvasN(void) const; + + /** + * Translates the specified position to the client coordinate. + * + * @since 2.0 + * + * @return The position relative to the top-left corner of the client area, @n + * else @c (-1,-1) if the instance is invalid + * @param[in] position The position relative to the top-left corner of the %Form control + * @see TranslateFromClientAreaPosition() + */ + Tizen::Graphics::Point TranslateToClientAreaPosition(const Tizen::Graphics::Point& position) const; + + /** + * Translates the specified client position to the control coordinate. + * + * @since 2.0 + * + * @return The position relative to the top-left corner of the %Form control, @n + * else @c (-1,-1) if the instance is invalid + * @param[in] clientPosition The position relative to the top-left corner of the client area + * @see TranslateToClientAreaPosition() + */ + Tizen::Graphics::Point TranslateFromClientAreaPosition(const Tizen::Graphics::Point& clientPosition) const; + + + /** + * Sets the %Form back event listener. + * + * @since 2.0 + * + * @param[in] pFormBackEventListener The %Form back event listener to set + * @see Tizen::Ui::Controls::IFormBackEventListener. + */ + void SetFormBackEventListener(IFormBackEventListener* pFormBackEventListener); + + + /** + * Gets the data binding context. + * + * @since 2.0 + * + * @return DataBindingContext the data binding context + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + DataBindingContext* GetDataBindingContextN(void) const; + +protected: + friend class _FormImpl; + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void Form_Reserved1(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void Form_Reserved2(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void Form_Reserved3(void) { } + +// Friend Class Declaration +private: + friend class UiBuilder; + friend class Frame; + +private: + Form(const Form&); + Form& operator =(const Form&); + +}; // Form + +} } } // Tizen::Ui::Controls + +#endif // _FUI_CTRL_FORM_H_ diff --git a/inc/FUiCtrlFrame.h b/inc/FUiCtrlFrame.h new file mode 100644 index 0000000..b09eacc --- /dev/null +++ b/inc/FUiCtrlFrame.h @@ -0,0 +1,356 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlFrame.h + * @brief This is the header file for the %Frame class. + * + * This header file contains the declarations of the %Frame class. + */ +#ifndef _FUI_CTRL_FRAME_H_ +#define _FUI_CTRL_FRAME_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Animations { +class FrameAnimator; +} } } // Tizen::Ui::Animations + +namespace Tizen { namespace App { +class _AppFrame; +} } // Tizen::App + +namespace Tizen { namespace Ui { namespace Controls +{ + +class Form; +class IFrameEventListener; + +/** + * @class Frame + * @brief This class provides the main frame window for an application. + * + * @since 2.0 + * + * The %Frame class provides the main frame window for an application. + * A frame is the main top-level window of an application. It is the ultimate parent + * of all application controls. + * + * For more information on the class features, see Frame. + * + * The following example demonstrates how to use the %Frame class + * + * @code + // Gets a pointer of the frame + Frame *pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame(); + + // Creates an instance of canvas + Canvas* pCanvas = new Canvas(); + pCanvas->Construct(); + pCanvas->DrawText(Point(30, 30), L"FrameSample"); + + // Calls Invalidate(); + pFrame->Invalidate(true); + * @endcode + * + */ +class _OSP_EXPORT_ Frame + : public Tizen::Ui::Window +{ +public: +// Lifecycle + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + Frame(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Frame(void); + + /** + * Initializes this instance of %Frame with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation (that + * is, the method is called on an instance that is constructed). + * @exception E_MAX_EXCEEDED The number of Frames and Forms exceeds the system limitation. + * @exception E_SYSTEM A system error has occurred. + * @remarks The maximum number of Forms that an application can construct is limited by available memory. + */ + result Construct(void); + + /** + * Initializes this instance of %Frame with the specified position and size. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner @n + * of the created window along with its width and height. @n + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation (that + * is, the method is called on an instance that is constructed). + * @exception E_MAX_EXCEEDED The number of Frames and Forms exceeds the system limitation. + * @exception E_SYSTEM A system error has occurred. + * @remarks The maximum number of Forms that an application can construct is limited by available memory. + * @remarks The specified position and size are only applied when the show mode is not #FRAME_SHOW_MODE_FULL_SCREEN. + */ + result Construct(const Tizen::Graphics::Rectangle& rect); + +// Operation +public: + /** + * Adds an IOrientationEventListener instance. @n + * The added listener can listen to events on the given event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @remarks When OnOrientationChanged() event is fired, re-position and draw the child controls, but do not explicitly call + * the Show() method. + * @see RemoveOrientationEventListener() + */ + void AddOrientationEventListener(Tizen::Ui::IOrientationEventListener& listener); + + /** + * Adds an IFrameEventListener instance. @n + * The added listener can listen to events on the given event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @see RemoveFrameEventListener() + */ + void AddFrameEventListener(Tizen::Ui::Controls::IFrameEventListener& listener); + + /** + * Removes an IOrientationEventListener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see AddOrientationEventListener() + */ + void RemoveOrientationEventListener(Tizen::Ui::IOrientationEventListener& listener); + + /** + * Removes an IFrameEventListener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see AddFrameEventListener() + */ + void RemoveFrameEventListener(Tizen::Ui::Controls::IFrameEventListener& listener); + +// Accessor +public: + /** + * Gets the current %Form control of the %Frame control. + * + * @since 2.0 + * + * @return The current Form, @n + * else @c null if there is no %Form + * @see SetCurrentForm() + */ + Form* GetCurrentForm(void) const; + + /** + * Sets the specified Form control as the current %Form of the %Frame control. + * + * @since 2.0 + * + * @return An error code + * @param[in] form The form to be set as the current form of the %Frame control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * The specified @c form is not a child control of the %Frame control. + * @exception E_SYSTEM A system error has occurred. + * @remarks If a form is set as the current form, it becomes the topmost form amongst its siblings. @n + * SetCurrentForm() does not call Invalidate() internally, so if the current form needs to be drawn + * immediately, Invalidate() should be called after SetCurrentForm(). + * Only Frame whose show mode is @c FRAME_SHOW_MODE_FULL_SCREEN can set a Form which has the style of @c FORM_STYLE_INDICATOR as the current form. + */ + result SetCurrentForm(const Form& form); + + /** + * Gets the background color of the %Frame control. + * + * @since 2.0 + * + * @return The background color of the %Frame control + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + + /** + * Sets the background color of the %Frame control. + * + * @since 2.0 + * + * @param[in] color The background color + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * Sets the orientation mode of a frame. + * + * @since 2.0 + * + * @param[in] orientation The orientation mode of the %Frame control + * @remarks To see the change in the orientation mode, the corresponding frame must be the topmost frame in the z-order hierarchy. + * hierarchy. + */ + void SetOrientation(Tizen::Ui::Orientation orientation); + + /** + * Gets the orientation mode of the frame. + * + * @since 2.0 + * + * @return The orientation mode of the frame + */ + Tizen::Ui::Orientation GetOrientation(void) const; + + /** + * Gets the current orientation status of the frame. + * + * @since 2.0 + * + * @return The orientation status + * @remarks The method returns ORIENTATION_STATUS_NONE if the %Frame control is not drawn. + * Once it is drawn, the orientation of the %Frame control is set to portrait and the method + * returns ORIENTATION_STATUS_PORTRAIT if the application has not specified its orientation. + */ + Tizen::Ui::OrientationStatus GetOrientationStatus(void) const; + + /** + * Gets the FrameAnimator of %Frame. + * + * @since 2.0 + * + * @return %FrameAnimator, @n + * else @c null if this instance is not constructed as yet + */ + Tizen::Ui::Animations::FrameAnimator* GetFrameAnimator(void) const; + + /** + * Sets the mode to show the %Frame control. + * + * @since 2.0 + * + * @return An error code + * @param[in] mode The mode to show the %Frame control + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * @remarks The default mode is #FRAME_SHOW_MODE_FULL_SCREEN. + */ + result SetShowMode(FrameShowMode mode); + + /** + * Gets the mode to show the %Frame control. + * + * @since 2.0 + * + * @return The mode to show the %Frame control + * @remarks The default mode is #FRAME_SHOW_MODE_FULL_SCREEN. + */ + FrameShowMode GetShowMode(void) const; + +protected: + friend class _FrameImpl; + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void Frame_Reserved1(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void Frame_Reserved2(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void Frame_Reserved3(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void Frame_Reserved4(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void Frame_Reserved5(void) { } + +private: + Frame(const Frame&); + Frame& operator =(const Frame&); +}; // Frame + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_FRAME_H_ diff --git a/inc/FUiCtrlFrameTypes.h b/inc/FUiCtrlFrameTypes.h new file mode 100644 index 0000000..fee88bb --- /dev/null +++ b/inc/FUiCtrlFrameTypes.h @@ -0,0 +1,47 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlFrameTypes.h + * @brief This is the header file for the Frame type. + * + * This header file contains the declarations of the Frame type. + * + */ +#ifndef _FUI_CTRL_FRAME_TYPES_H_ +#define _FUI_CTRL_FRAME_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum FrameShowMode + * + * Defines the mode to show the Frame control. + * + * @since 2.0 + */ +enum FrameShowMode +{ + FRAME_SHOW_MODE_FULL_SCREEN, /**< The full screen mode */ + FRAME_SHOW_MODE_PARTIAL_SCREEN, /**< The partial screen mode */ + FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING, /**< The partial screen mode which is always on top of other Frames */ +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_FRAME_TYPES_H_ diff --git a/inc/FUiCtrlGallery.h b/inc/FUiCtrlGallery.h new file mode 100644 index 0000000..208c6ed --- /dev/null +++ b/inc/FUiCtrlGallery.h @@ -0,0 +1,539 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlGallery.h + * @brief This is the header file for the %Gallery class. + * + * This header file contains the declarations of the %Gallery class and its helper classes. + */ + +#ifndef _FUI_CTRL_GALLERY_H_ +#define _FUI_CTRL_GALLERY_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class Gallery + * @brief This class defines the common behavior of a %Gallery control. + * + * @since 2.0 + * + * The %Gallery class displays an image viewer that contains a collection of images (1 + * image at a time) in a horizontally scrolling list. It also supports a slide + * show that automatically displays all the images consecutively. + * + * For more information on the class features, see Gallery. + * + * The following example demonstrates how to use the %Gallery class. + * + * @code +// Sample code for GallerySample.h +#include + +class GallerySample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IGalleryItemProvider + , public Tizen::Ui::Controls::IGalleryEventListener +{ +public: + GallerySample(void) + : __pGallery(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + //IGalleryItemProvider + virtual Tizen::Ui::Controls::GalleryItem* CreateItem (int index); + virtual bool DeleteItem (int index, Tizen::Ui::Controls::GalleryItem *pItem); + virtual int GetItemCount(void); + + // IGalleryEventListener + virtual void OnGalleryCurrentItemChanged(Tizen::Ui::Controls::Gallery &gallery, int index); + virtual void OnGalleryItemClicked(Tizen::Ui::Controls::Gallery &gallery, int index); + virtual void OnGallerySlideShowStarted(Tizen::Ui::Controls::Gallery& gallery); + virtual void OnGallerySlideShowStopped(Tizen::Ui::Controls::Gallery& gallery); + +private: + Tizen::Ui::Controls::Gallery* __pGallery; +}; + * @endcode + * + * @code +// Sample code for GallerySample.cpp +#include +#include + +#include "GallerySample.h" + +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +bool +GallerySample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +GallerySample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Gallery + __pGallery = new Gallery(); + __pGallery->Construct(GetBounds()); + __pGallery->SetItemProvider(*this); + __pGallery->AddGalleryEventListener(*this); + + AddControl(*__pGallery); + + return r; +} + +// IGalleryItemProvider implementation +GalleryItem* +GallerySample::CreateItem(int index) +{ + // Gets an instance of Bitmap + AppResource* pAppResource = Application::GetInstance()->GetAppResource(); + Bitmap* pImageTemp = pAppResource->GetBitmapN(L"Image.jpg"); + + // Creates an instance of GalleryItem and registers the bitmap to the gallery item + GalleryItem* pGallery = new GalleryItem(); + pGallery->Construct(*pImageTemp); + + // Deallocates the bitmap + delete pImageTemp; + + return pGallery; +} + +bool +GallerySample::DeleteItem(int index, GalleryItem *pItem) +{ + delete pItem; + return true; +} + +int +GallerySample::GetItemCount(void) +{ + return 1; +} + +// IGalleryEventListener implementation +void + GallerySample::OnGalleryCurrentItemChanged(Gallery &gallery, int index) +{ + // .... +} + +void +GallerySample::OnGalleryItemClicked(Gallery &gallery, int index) +{ + // .... +} + +void +GallerySample::OnGallerySlideShowStarted(Gallery& gallery) +{ + // .... +} + +void +GallerySample::OnGallerySlideShowStopped(Gallery& gallery) +{ + // .... +} + * @endcode + */ + +class _OSP_EXPORT_ Gallery + : public Tizen::Ui::Control +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + Gallery(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~Gallery(void); + +public: + /** + * Initializes this instance of %Gallery with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created %Gallery control along with the + * width and height. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Graphics::Rectangle& rect); + + /** + * Sets the item provider that creates and deletes the items from the %Gallery control. + * + * @since 2.0 + * + * @return An error code + * @param[in] provider The item provider to create and delete items + * @exception E_SUCCESS The method is successful. + * @remark If an item provider is not set for the %Gallery control, the method does not work. @n + * The item provider should be allocated on a heap memory. + */ + result SetItemProvider(IGalleryItemProvider& provider); + + /** + * Adds an IGalleryEventListener instance. @n + * The added listener can listen to the item events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + */ + void AddGalleryEventListener(IGalleryEventListener& listener); + + /** + * Removes an IGalleryEventListener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + */ + void RemoveGalleryEventListener(IGalleryEventListener& listener); + + /** + * Gets the index of the current item. + * + * @since 2.0 + * + * @return The current item index of the %Gallery control + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetCurrentItemIndex(void) const; + + /** + * Sets the index of the current item. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_SYSTEM A system error has occurred. + * + */ + result SetCurrentItemIndex(int index); + + /** + * Gets the total number of items. + * + * @since 2.0 + * + * @return The total number of items, @n + * else @c -1 if an error occurs + */ + int GetItemCount(void) const; + + /** + * Refreshes the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index of the item to be refreshed + * @param[in] type The type of change for an item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + */ + result RefreshGallery(int itemIndex, GalleryRefreshType type); + + /** + * Updates all the items of a list. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method clears items in the list and reinvokes methods of the item provider to fill the list. + */ + result UpdateGallery(void); + + /** + * Sets the text of the empty %Gallery control. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text of the empty %Gallery control + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTextOfEmptyGallery(const Tizen::Base::String& text); + + /** + * Gets the text of the empty %Gallery control. + * + * @since 2.0 + * + * @return The text of the empty %Gallery control + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::String GetTextOfEmptyGallery(void) const; + + /** + * Sets the background bitmap of the %Gallery control. + * + * @since 2.0 + * + * @param[in] pBitmap The bitmap of the empty %Gallery control + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks When @c pBitmap is @c null, the %Gallery control does not have a background bitmap. The default value for the background bitmap is @c null. + * @remarks The background bitmap has a priority over the background color. When both the background bitmap and the background color are specified, + * only the bitmap is displayed. + */ + result SetBitmapOfEmptyGallery(const Tizen::Graphics::Bitmap* pBitmap); + + /** + * Sets the slide show transition animation type. + * + * @since 2.0 + * + * @param[in] animation The animation type of the %Gallery control + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method is not supported in 16-bit devices. + */ + result SetSlideShowAnimation(GalleryAnimation animation); + + /** + * Gets the transition animation type of the slide show. + * + * @since 2.0 + * + * @return The animation type of a %Gallery control + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks The method is not supported in 16-bit devices. + */ + GalleryAnimation GetSlideShowAnimation(void) const; + + /** + * Sets the duration of the slide show transition animation. + * + * @since 2.0 + * + * @param[in] duration The animation duration + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c duration is out of the possible duration range. @n + * The specified duration should be greater than or equal to 300 or less than or equals to 20000. + * @exception E_SYSTEM A system error has occurred. + * @remarks The unit of the duration is in milliseconds.@n + * The default animation duration is different for each slide show animation type. + */ + result SetSlideShowAnimationDuration(int duration); + + /** + * Gets the transition animation duration of the %Gallery control. + * + * @since 2.0 + * + * @return The animation duration, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetSlideShowAnimationDuration(void) const; + + /** + * Sets the duration of the slide-show item view. + * + * @since 2.0 + * + * @param[in] duration The item view duration + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c duration is out of possible duration range. @n + * - The specified @c duration should be greater than 10. + * @exception E_SYSTEM A system error has occurred. + * @remarks The unit of the duration is in milliseconds.@n + * The default animation duration is different for each slide show animation type. + */ + result SetSlideShowViewDuration(int duration); + + /** + * Gets the duration of the slide-show item view. + * + * @since 2.0 + * + * @return The item view duration, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using @c GetLastResult() method. + */ + int GetSlideShowViewDuration(void) const; + + /** + * Starts the slide show. + * + * @since 2.0 + * + * @return An error code + * @param[in] repeat The repeat status + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + */ + result StartSlideShow(bool repeat = false); + + /** + * Stops the slide show. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + */ + result StopSlideShow(void) const; + + /** + * Checks whether the slide show has started. + * + * @since 2.0 + * + * @return @c true if the slide show is running, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + bool IsSlideShowStarted(void) const; + + /** + * Enables or disables the image zooming. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable zooming, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks When enabled, the user can enter the zoom mode by double-clicking or pinching the current image. + */ + result SetZoomingEnabled(bool enable); + + /** + * Checks whether zooming is enabled. + * + * @since 2.0 + * + * @return @c true if zooming is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + bool IsZoomingEnabled(void) const; + + /** + * Sets the background color of the %Gallery control. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The background color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method ignores the alpha value of the @c color parameter and sets the alpha value to 255. + */ + result SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * Gets the background color of the %Gallery control. + * + * @since 2.0 + * + * @return The background color, @n + * else RGBA(0, 0, 0, 0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Gallery(const Gallery& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Gallery& operator =(const Gallery& rhs); + +protected: + friend class _GalleryImpl; +}; // Gallery + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_GALLERY_H_ diff --git a/inc/FUiCtrlGalleryItem.h b/inc/FUiCtrlGalleryItem.h new file mode 100644 index 0000000..80cd492 --- /dev/null +++ b/inc/FUiCtrlGalleryItem.h @@ -0,0 +1,125 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlGalleryItem.h + * @brief This is the header file for the %GalleryItem class. + * + * This header file contains the declarations of the %GalleryItem class and its helper classes. + */ + +#ifndef _FUI_CTRL_GALLERY_ITEM_H_ +#define _FUI_CTRL_GALLERY_ITEM_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _GalleryItemImpl; + +/** + * @class GalleryItem + * @brief This class defines the common behavior for a %GalleryItem control. + * + * @since 2.0 + * + * The %GalleryItem class represents an item of the Gallery control. An instance of the %GalleryItem class + * comprises of a bitmap image and its image rotation. @n @n + * + * For more information on the class features, see Gallery. + */ +class _OSP_EXPORT_ GalleryItem + : public Tizen::Base::Object +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + GalleryItem(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~GalleryItem(void); + +public: + /** + * Initializes this instance of %GalleryItem with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] bitmap The default bitmap image + * @param[in] rotation The rotation of the bitmap image + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Graphics::Bitmap& bitmap, GalleryImageRotation rotation = GALLERY_IMAGE_ROTATION_0); + + /** + * Initializes this instance of %GalleryItem with the specified parameters. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompIoPathPage "here". + * @endif + * @return An error code + * @param[in] bitmap The default bitmap image + * @param[in] filePath The bitmap file path + * @param[in] rotation The rotation of the bitmap image + * @exception E_SUCCESS The method is successful. + * @exception E_OVERFLOW The image specified by @c filePath has caused an overflow. + * @exception E_UNSUPPORTED_FORMAT The image specified by @c filePath is not supported. + * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed. + * @exception E_INTERRUPTED The requested operation cannot be performed due to an interruption from another thread. @n + * @exception E_ILLEGAL_ACCESS The image specified by @c filePath parameter, is protected with DRM. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specified file path is used to decode the original bitmap to show a more higher quality image when the corresponding item is zoomed. + */ + result Construct(const Tizen::Graphics::Bitmap& bitmap, const Tizen::Base::String& filePath, GalleryImageRotation rotation = GALLERY_IMAGE_ROTATION_0); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + GalleryItem(const GalleryItem& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + GalleryItem& operator =(const GalleryItem& rhs); + +private: + _GalleryItemImpl* __pImpl; + + friend class _GalleryItemImpl; +}; // GalleryItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_GALLERY_ITEM_H_ diff --git a/inc/FUiCtrlGalleryTypes.h b/inc/FUiCtrlGalleryTypes.h new file mode 100644 index 0000000..0d22c36 --- /dev/null +++ b/inc/FUiCtrlGalleryTypes.h @@ -0,0 +1,80 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlGalleryTypes.h + * @brief This is the header file for the Gallery enumerations. + * + * This header file contains the declarations of the Gallery enumerations. + * + * These enumerations define the various properties of a %Gallery control. + */ +#ifndef _FUI_CTRL_GALLERY_ENUM_H_ +#define _FUI_CTRL_GALLERY_ENUM_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum GalleryImageRotation + * + * Defines the rotation of an image of a Gallery control. + * + * @since 2.0 + * + */ +enum GalleryImageRotation +{ + GALLERY_IMAGE_ROTATION_0 = 0, /**< The no rotation */ + GALLERY_IMAGE_ROTATION_90, /**< The 90 degree clockwise rotation */ + GALLERY_IMAGE_ROTATION_180, /**< The clockwise rotation */ + GALLERY_IMAGE_ROTATION_270 /**< The anticlockwise rotation */ +}; + +/** + * @enum GalleryAnimation + * + * Defines the animation type of a Gallery control. + * + * @since 2.0 + * + */ +enum GalleryAnimation +{ + GALLERY_ANIMATION_PAGE, /**< The page turn animation */ + GALLERY_ANIMATION_DISSOLVE, /**< The dissolve animation */ + GALLERY_ANIMATION_ZOOM /**< The zoom animation */ +}; + +/** + * @enum GalleryRefreshType + * + * Defines the update type of a Gallery control. + * + * @since 2.0 + * + */ +enum GalleryRefreshType +{ + GALLERY_REFRESH_TYPE_ITEM_ADD = 0, /**< The refresh type is add */ + GALLERY_REFRESH_TYPE_ITEM_REMOVE, /**< The refresh type is remove */ + GALLERY_REFRESH_TYPE_ITEM_MODIFY /**< The refresh type is modify */ +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_GALLERY_ENUM_H_ diff --git a/inc/FUiCtrlGroupItem.h b/inc/FUiCtrlGroupItem.h new file mode 100644 index 0000000..0b079c2 --- /dev/null +++ b/inc/FUiCtrlGroupItem.h @@ -0,0 +1,209 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlGroupItem.h + * @brief This is the header file for the %GroupItem class. + * + * This header file contains the declarations of the %GroupItem class and its helper classes. + */ + +#ifndef _FUI_CTRL_GROUP_ITEM_H_ +#define _FUI_CTRL_GROUP_ITEM_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _GroupItemImpl; + +/** + * @class GroupItem + * @brief This class defines common behavior of %GroupItem. + * + * @since 2.0 + * + * The %GroupItem class displays a group item. The basic layout of the %GroupItem instance is text and a bitmap arranged horizontally in one line. The bitmap can be omitted while text must be given. + * @n + * For more information on the class features, see ListViews. + */ + +class _OSP_EXPORT_ GroupItem + : public Tizen::Base::Object +{ +public: + /** + * The object is not fully constructed after this constructor is + * called. For full construction, the Construct() method must be + * called right after calling this constructor. + * + * @since 2.0 + */ + GroupItem(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~GroupItem(void); + + /** + * Initializes this instance of %GroupItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemSize The size of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Graphics::Dimension& itemSize); + + /** + * Sets the background image of the item. + * + * @since 2.0 + * + * @return An error code + * @param[in] pBitmap The background bitmap image + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The background bitmap has priority over the background color. When both the background bitmap and background color are specified, only + * the bitmap is displayed. + */ + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + /** + * Sets the background color of the item. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The background color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, only the bitmap is displayed. @n + * The background color of the item is not applied when the item is inserted into the GroupedListView of section style. + */ + result SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * Gets the background color of the item. + * + * @since 2.0 + * + * @return The background color of the item, @n + * else RGBA(0, 0, 0, 0) if an error occurs + * @see SetBackgroundColor() + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + + /** + * Sets the color of the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextColor() + */ + result SetTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the color of the text. + * + * @since 2.0 + * + * @return The text color, @n + * else RGBA(0, 0, 0, 0) if an error occurs + * @see SetTextColor() + */ + Tizen::Graphics::Color GetTextColor(void) const; + + /** + * Sets the size of the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The size of the text + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextSize() + */ + result SetTextSize(int size); + + /** + * Gets the size of the text. + * + * @since 2.0 + * + * @return The size of the text, + * else @c -1 if an error occurs + * + * @see SetTextSize() + */ + int GetTextSize(void) const; + + /** + * Sets the text and bitmap of the element for %GroupItem. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text string to be added + * @param[in] pBitmap The bitmap to be displayed + * + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The behavior of %GroupItem is different according to the style of GroupedListView. @n + * When the style is GROUPED_LIST_VIEW_INDEXED, the text and bitmap of %GroupItem are displayed, if they are given. However, when the style + * is GROUPED_LIST_VIEW_STYLE_SECTION, the bitmap is not displayed in any case and setting an empty text to %GroupItem does not show + * %GroupItem. + */ + result SetElement(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap = null); + +protected: + friend class _GroupItemImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + GroupItem(const GroupItem& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + GroupItem& operator =(const GroupItem& rhs); + +protected: + _GroupItemImpl* _pImpl; +}; // GroupItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_GROUP_ITEM_H_ diff --git a/inc/FUiCtrlGroupTypes.h b/inc/FUiCtrlGroupTypes.h new file mode 100644 index 0000000..48b605b --- /dev/null +++ b/inc/FUiCtrlGroupTypes.h @@ -0,0 +1,47 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlGroupTypes.h + * @brief This is the header file for the table view style enumeration. + * + * This header file contains the declarations of the table view style enumeration. + */ +#ifndef _FUI_CTRL_GROUP_TYPES_H_ +#define _FUI_CTRL_GROUP_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum GroupStyle + * + * Defines the table view style of a control's border. + * + * @since 2.0 + */ +enum GroupStyle +{ + GROUP_STYLE_NONE, /**< A rectangle with no outline */ + GROUP_STYLE_SINGLE, /**< A rectangle with all corners rounded */ + GROUP_STYLE_TOP, /**< A rectangle with the two top corners rounded */ + GROUP_STYLE_MIDDLE, /**< A rectangle positioned at the center of a group */ + GROUP_STYLE_BOTTOM /**< A rectangle with the two bottom corners rounded */ +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_GROUP_TYPES_H_ diff --git a/inc/FUiCtrlGroupedList.h b/inc/FUiCtrlGroupedList.h new file mode 100644 index 0000000..8be75e8 --- /dev/null +++ b/inc/FUiCtrlGroupedList.h @@ -0,0 +1,1134 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlGroupedList.h + * @brief This is the header file for the %GroupedList class. + * + * This header file contains the declarations of the %GroupedList class and its helper classes. + */ + +#ifndef _FUI_CTRL_GROUPED_LIST_H_ +#define _FUI_CTRL_GROUPED_LIST_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls { + +/** + * @if OSPDEPREC + * @class GroupedList + * @brief [Deprecated] This class defines the common behavior of a %GroupedList control. + * + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * The %GroupedList class represents grouped items in a list. List items of + * %GroupedList consist of groups and items. A group represents grouped items and is + * inserted into the first level as items are inserted into List. Items which are + * CustomListItem are inserted under related groups. So, items are uniquely identified + * with two indices: group index and item index. + * + * If an application wants to perform tasks when the state of a list item is changed, + * it must implement IGroupedItemEventListener and register it to the grouped list, + * It will then receive related events from %GroupedList. + * + * Unlike ExpandableList which is also a list with a hierarchy of depth 2, group + * item itself does not have many functions. + * + * A typical use case of %GroupedList would be a list which groups all items alphabetically. + * + * Note that CustomListItem and CustomListItemFormat need to be created on a heap. CustomListItems will be deleted automatically + * when the %GroupedList itself is destroyed. If you want to remove certain list items, you must use RemoveItemAt(). CustomListItemFormat + * must be deleted by the application. + * + * Refer to CustomListItem and CustomListItemFormat. + * + * Example: + * + * @image html ui_controls_groupedlist.png + * + * This is the simple UI application that uses a %GroupedList control. + * + * @code +// Sample code for GroupedListSample.h +#include +#include + +class GroupedListSample + :public Tizen::Ui::Controls::Form + , public Tizen::Ui::ICustomItemEventListener +{ +public: + GroupedListSample(void) + : __pGroupedList(null) + , __pCustomListItemFormat(null){} + + bool Initialize(void); + result AddListItem(Tizen::Ui::Controls::GroupedList& groupedList, int groupId, Tizen::Base::String itemText, + Tizen::Graphics::Bitmap* pBitmapNormal, Tizen::Graphics::Bitmap* pBitmapFocused); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // ICustomItemEventListener + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int index, int itemId, Tizen::Ui::ItemStatus status); + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int index, int itemId, int elementId, Tizen::Ui::ItemStatus status); + +private: + static const int ID_LIST_ = 101; + static const int ID_LIST_TEXT = 102; + static const int ID_LIST_BITMAP = 103; + + Tizen::Ui::Controls::GroupedList* __pGroupedList; + Tizen::Ui::Controls::CustomListItemFormat* __pCustomListItemFormat; +}; + * @endcode + * + * @code +// Sample code for CutomListSample.cpp +#include +#include + +#include "GroupedListSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +bool +GroupedListSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +GroupedListSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of GroupedList + __pGroupedList = new GroupedList(); + __pGroupedList->Construct(Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height), CUSTOM_LIST_STYLE_NORMAL); + + // Creates an instance of CustomListItemFormat of the grouped list + __pCustomListItemFormat = new CustomListItemFormat(); + __pCustomListItemFormat->Construct(); + __pCustomListItemFormat->AddElement(ID_LIST_TEXT, Rectangle(10, 25, 200, 80)); + __pCustomListItemFormat->AddElement(ID_LIST_BITMAP, Rectangle(220, 10, 70, 80)); + + // Adds the groups to the grouped list + __pGroupedList->AddGroup(L"Group_1", null); + __pGroupedList->AddGroup(L"Group_2", null); + __pGroupedList->AddGroup(L"Group_3", null); + + // Gets instances of Bitmap + AppResource *pAppResource = Application::GetInstance()->GetAppResource(); + Bitmap *pBitmapNormal = pAppResource->GetBitmapN(L"tizen.png"); + Bitmap *pBitmapFocused = pAppResource->GetBitmapN(L"tizen.png"); + + // Adds the items to the grouped list + for (int i = 0; i < __pGroupedList->GetGroupCount(); i++ ) + { + AddListItem(*__pGroupedList, i, L"SubItem1", pBitmapNormal, pBitmapFocused); + AddListItem(*__pGroupedList, i, L"SubItem2", pBitmapNormal, pBitmapFocused); + AddListItem(*__pGroupedList, i, L"SubItem3", pBitmapNormal, pBitmapFocused); + AddListItem(*__pGroupedList, i, L"SubItem4", pBitmapNormal, pBitmapFocused); + } + + // Adds the grouped list to the form + AddControl(*__pGroupedList); + + // Deallocates bitmaps + delete pBitmapNormal; + delete pBitmapFocused; + + return r; +} + +result +GroupedListSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the item format + delete __pCustomListItemFormat; + + return r; +} + +result +GroupedListSample::AddListItem(GroupedList& groupedList, int groupId, String itemText, Bitmap* pBitmapNormal, Bitmap* pBitmapFocused) +{ + result r = E_SUCCESS; + + // Creates an instance of CustomListItem of the grouped list + CustomListItem* pItem = new CustomListItem(); + pItem->Construct(100); + pItem->SetItemFormat(*__pCustomListItemFormat); + pItem->SetElement(ID_LIST_TEXT, itemText); + pItem->SetElement(ID_LIST_BITMAP, *pBitmapNormal, pBitmapFocused); + + // Adds the item to the grouped list + groupedList.AddItem(groupId, *pItem, ID_LIST_); + + return r; +} + +// ICustomItemEventListener implementation +void +GroupedListSample::OnItemStateChanged(const Control& source, int index, int itemId, ItemStatus status) +{ + switch (itemId) + { + case ID_LIST_: + { + // .... + } + break; + default: + break; + } +} + +void +GroupedListSample::OnItemStateChanged(const Control& source, int index, int itemId, int elementId, ItemStatus status) +{ + switch (itemId) + { + case ID_LIST_: + { + switch (elementId) + { + case ID_LIST_TEXT: + { + // .... + } + break; + case ID_LIST_BITMAP: + { + // .... + } + break; + default: + break; + } + } + break; + default: + break; + } +} + * @endcode + * @endif + */ +class _OSP_EXPORT_ GroupedList + : public Tizen::Ui::Control +{ +public: + /** + * @if OSPDEPREC + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * @endif + */ + GroupedList(void); + + /** + * @if OSPDEPREC + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * @endif + */ + virtual ~GroupedList(void); + + /** + * @if OSPDEPREC + * Initializes this instance of %GroupedList with the specified parameters. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the X, Y coordinates of the top-left corner of the created %GroupedList along with the width and + * height. + * @param[in] style The style of the %GroupedList control + * @param[in] itemDivider Set to @c true to display an item divider, @n + * else @c false + * @param[in] fastScroll Set to @c true if to use a fast scroll, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The size of the control must be within the range as defined by the minimum and maximum size. + * @remarks The minimum size of this control is 274 x 148 on a WVGA screen, 180 x 96 on a HVGA screen and 137 x 74 on a WQVGA screen. + * @endif + */ + result Construct(const Tizen::Graphics::Rectangle& rect, CustomListStyle style, bool itemDivider = true, bool fastScroll = false); + + /** + * @if OSPDEPREC + * Adds the group to the %GroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] text The string of the group to be appended + * @param[in] pBackgroundBitmap The background bitmap of the group + * @param[in] groupId The ID of the group + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result AddGroup(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int groupId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Inserts the group of the %GroupedList control at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] text The name of the group item + * @param[in] pBackgroundBitmap The background bitmap of the group item + * @param[in] groupId The ID of the group item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The @c groupIndex is out of bounds. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result InsertGroupAt(int groupIndex, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int groupId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Sets the contents of the group of the %GroupedList control at the index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] text The string of the group to be appended + * @param[in] pBackgroundBitmap The bitmap of the group + * @param[in] groupId The ID of the group + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetGroupAt(int groupIndex, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int groupId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Removes the group of the %GroupedList control at the index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks When the specified group is removed, all the items in the group are also removed. @n + * The removed list items are deleted from the memory. + * @endif + */ + result RemoveGroupAt(int groupIndex); + + /** + * @if OSPDEPREC + * Removes all the groups of the %GroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks When the specified group is removed, all the items in the group are also removed. @n + * The removed list items are deleted from the memory. + * @endif + */ + result RemoveAllGroups(void); + + /** + * @if OSPDEPREC + * Counts all the groups of the %GroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return The count of all the groups + * @endif + */ + int GetGroupCount(void) const; + + /** + * @if OSPDEPREC + * Adds the item to the specified group. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] item The custom list item object to be added + * @param[in] itemId The specified item ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemId is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The added item is deleted automatically when the list is destroyed. @n + * Do not add, insert, or set an item that already belongs to a %GroupedList control. + * @endif + */ + result AddItem(int groupIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Inserts the item to the specified group. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index in the specified group + * @param[in] item The custom list item to be inserted + * @param[in] itemId The item ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemId is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The inserted item is deleted automatically when the list is destroyed. + * Do not add, insert, or set an item that already belongs to a %GroupedList control. + * @endif + */ + result InsertItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Sets the contents of the item in the specified group. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index in the specified group + * @param[in] item The custom list item to be set + * @param[in] itemId The item ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemId is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not add, insert, or set an item that already belongs to a %GroupedList control. + * @endif + */ + result SetItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Sets the checked status for the specified item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index of the item + * @param[in] itemIndex The item index + * @param[in] check Set to @c true to check the item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetItemChecked(int groupIndex, int itemIndex, bool check); + + /** + * @if OSPDEPREC + * Enables or disables the item at the specified index of the %GroupedList. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index of the item + * @param[in] itemIndex The item index + * @param[in] enable Set to @c true to enable the item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetItemEnabled(int groupIndex, int itemIndex, bool enable); + + /** + * @if OSPDEPREC + * Sets the background color of this control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @param[in] color The background color + * @endif + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Sets the text that is displayed when %GroupedList is empty. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @param[in] text The empty list test + * @endif + */ + void SetTextOfEmptyList(const Tizen::Base::String& text); + + /** + * @if OSPDEPREC + * Sets the color of the text that is displayed when %GroupedList is empty. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @param[in] color The color of the text to be displayed + * @endif + */ + void SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Gets the color of the text that is displayed when %GroupedList is empty. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return The color of the text to be displayed + * @endif + */ + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + /** + * @if OSPDEPREC + * Checks whether the item at the specified index of this grouped list is checked. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return @c true if the item is checked, @n + * else @c false + * @param[in] groupIndex The group index of the item + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows selection. + * @endif + */ + bool IsItemChecked(int groupIndex, int itemIndex) const; + + /** + * @if OSPDEPREC + * Checks whether the item at the specified index is enabled. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return @c true if the item is enabled, @n + * else @c false + * @param[in] groupIndex The group index of the item + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + bool IsItemEnabled(int groupIndex, int itemIndex) const; + + /** + * @if OSPDEPREC + * Removes an item in the specified group. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list item is deleted from the memory. + * @endif + */ + result RemoveItemAt(int groupIndex, int itemIndex); + + /** + * @if OSPDEPREC + * Removes all the items in the specified group. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list items are deleted from the memory. + * @endif + */ + result RemoveAllItemsAt(int groupIndex); + + /** + * @if OSPDEPREC + * Removes all the checked items in the specified group. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list items are deleted from the memory. + * @endif + */ + result RemoveAllCheckedItemsAt(int groupIndex); + + /** + * @if OSPDEPREC + * Counts all items of the %GroupedList instance. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return The item count of the specified group + * @param[in] groupIndex The group index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + int GetItemCountAt(int groupIndex) const; + + /** + * @if OSPDEPREC + * Gets the item ID of the item at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return The item ID + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index in the specified group + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + int GetItemIdAt(int groupIndex, int itemIndex) const; + + /** + * @if OSPDEPREC + * Gets the item index by the specified item ID. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] itemId The item ID + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index in the specified group + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetItemIndexFromItemId(int itemId, int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Gets the group ID at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return The group ID + * @param[in] groupIndex The group index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + int GetGroupIdAt(int groupIndex) const; + + /** + * @if OSPDEPREC + * Gets the group index from the specified group ID. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return The group index + * @param[in] groupId The ID of the group + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + int GetGroupIndexFromGroupId(int groupId) const; + + /** + * @if OSPDEPREC + * Gets the index of the last item checked. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index in the specified group + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetLastCheckedItemIndex(int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the next checked item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in,out] groupIndex The group index + * @param[in,out] itemIndex The item index in the specified group + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetNextCheckedItemIndexAfter(int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified item position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] x The x position of the point + * @param[in] y The y position of the point + * @param[out] groupIndex The index of the group which the item belongs to + * @param[out] itemIndex The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. @n + * There is no item at the specified position. + * @endif + */ + result GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified item position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] position The position of the point + * @param[out] groupIndex The index of the group which the item belongs to + * @param[out] itemIndex The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. @n + * There is no item at the specified position. + * @endif + */ + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the current top drawn list item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index of the item + * @param[out] itemIndex The item index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Removes all the items of the %GroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list items are deleted from the memory. + * @endif + */ + result RemoveAllItems(void); + + /** + * @if OSPDEPREC + * Removes all the checked items of the %GroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list items are deleted from the memory. + * @endif + */ + result RemoveAllCheckedItems(void); + + /** + * @if OSPDEPREC + * Gets the specified item of the %GroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return A custom list item + * @param[in] groupIndex The index of the group which the item belongs to + * @param[in] itemIndex The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + const CustomListItem* GetItemAt(int groupIndex, int itemIndex) const; + + /** + * @if OSPDEPREC + * Scrolls to the bottom of the %GroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * @endif + */ + void ScrollToBottom(void); + + /** + * @if OSPDEPREC + * Scrolls to the top of the %GroupedList. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * @endif + */ + void ScrollToTop(void); + + /** + * @if OSPDEPREC + * Scrolls to the item at the specified index. @n + * The specified item is drawn at the top of the %GroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result ScrollToTop(int groupIndex, int itemIndex); + + /** + * @if OSPDEPREC + * Scrolls to the group at the specified index. @n + * The specified group is drawn at the top of the %GroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result ScrollToTop(int groupIndex); + + /** + * @if OSPDEPREC + * Sets the first index list of scroll by text. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] text The text of the first index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetFastScrollMainIndex(const Tizen::Base::String& text); + + /** + * @if OSPDEPREC + * Sets the second index list of scroll by text. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] text The text of the second index @n + * Separate each second index of the first index by ',';. + * @param[in] indexDigit The index digit count + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetFastScrollSubIndex(const Tizen::Base::String& text, FastScrollIndexDigit indexDigit = SCROLL_INDEX_DIGIT_NUM_1); + + /** + * @if OSPDEPREC + * Adds the fast scroll event listener. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @param[in] listener The listener to be added + * @endif + */ + void AddFastScrollEventListener(Tizen::Ui::IFastScrollEventListener& listener); + + /** + * @if OSPDEPREC + * Removes the fast scroll event listener. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @endif + */ + void RemoveFastScrollEventListener(Tizen::Ui::IFastScrollEventListener& listener); + + /** + * @if OSPDEPREC + * Adds the grouped list item event listener. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @param[in] listener The listener to be added + * @endif + */ + void AddGroupedItemEventListener(Tizen::Ui::IGroupedItemEventListener& listener); + + /** + * @if OSPDEPREC + * Removes the grouped list item event listener. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @endif + */ + void RemoveGroupedItemEventListener(Tizen::Ui::IGroupedItemEventListener& listener); + + /** + * @if OSPDEPREC + * Gets the index of the first checked list item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index of the item + * @param[out] itemIndex The item index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetFirstCheckedItemIndex(int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Sets the checked status of all the items of the specified group with the given value. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index of the item + * @param[in] check Set to @c true to check all the items, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetAllItemsChecked(int groupIndex, bool check); + + /** + * @if OSPDEPREC + * Gets the index of the current bottom drawn list item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index of the item + * @param[out] itemIndex The item index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Draws and shows the item of %GroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemIndex is invalid. + * @exception E_INVALID_OPERATION The item has never been drawn before calling this method. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RefreshItem(int groupIndex, int itemIndex); + + /** + * @if OSPDEPREC + * Draws and shows the group of %GroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RefreshGroup(int groupIndex); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + GroupedList(const GroupedList& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + GroupedList& operator =(const GroupedList& rhs); + + friend class _GroupedListImpl; +}; //GroupedList +}}} // Tizen::Ui::Controls +#endif // _FUI_CTRL_GROUPED_LIST_H_ diff --git a/inc/FUiCtrlGroupedListView.h b/inc/FUiCtrlGroupedListView.h new file mode 100644 index 0000000..e0b0cf1 --- /dev/null +++ b/inc/FUiCtrlGroupedListView.h @@ -0,0 +1,1083 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlGroupedListView.h + * @brief This is the header file for the %GroupedListView class. + * + * This header file contains the declarations of the %GroupedListView class and its helper classes. + */ + +#ifndef _FUI_CTRL_GROUPED_LIST_VIEW_H_ +#define _FUI_CTRL_GROUPED_LIST_VIEW_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _GroupedListViewImpl; + +/** + * @class GroupedListView + * @brief This class defines the common behavior of a %GroupedListView control. + * + * @since 2.0 + * + * The %GroupedListView class displays a list of grouped items in a list. The items in a GroupedList control consist of groups and + * items. A group represents the grouped items and is placed at the first level. Each group consists of simple or custom items. + * Therefore, items are uniquely identified with two indexes: group index and item index. + * + * For more information on the class features, see ListViews. + * + * The following example demonstrates how to use the %GroupedListView class. + * + * + * @code +//Sample code for GroupedListViewSample.h + +#include + +class CustomGroupedListElement; + +class GroupedListViewSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IGroupedListViewItemEventListener + , public Tizen::Ui::Controls::IGroupedListViewItemProvider +{ +public: + GroupedListViewSample(void) + : __pGroupedListView(null) + , __pCustomGroupedListElement(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // IGroupedListViewItemEventListener + virtual void OnGroupedListViewContextItemStateChanged(Tizen::Ui::Controls::GroupedListView &listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnGroupedListViewItemStateChanged(Tizen::Ui::Controls::GroupedListView &listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListItemStatus state); + virtual void OnGroupedListViewItemSwept(Tizen::Ui::Controls::GroupedListView &listView, int groupIndex, int itemIndex, Tizen::Ui::Controls::SweepDirection direction); + + // IGroupedListViewItemProvider + virtual int GetGroupCount(void); + virtual int GetItemCount(int groupIndex); + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int groupIndex, int itemIndex, int itemWidth); + virtual Tizen::Ui::Controls::GroupItem* CreateGroupItem(int groupIndex, int itemWidth); + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth); + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::GroupItem* pItem, int itemWidth); + +private: + static const int ID_FORMAT_STRING = 100; + static const int ID_FORMAT_BITMAP = 101; + static const int ID_FORMAT_CUSTOM = 102; + static const int ID_CONTEXT_ITEM_1 = 103; + static const int ID_CONTEXT_ITEM_2 = 104; + + Tizen::Graphics::Bitmap* __pHome; + Tizen::Graphics::Bitmap* __pMsg; + Tizen::Graphics::Bitmap* __pAlarm; + Tizen::Graphics::Bitmap* __pCall; + + Tizen::Ui::Controls::GroupedListView* __pGroupedListView; + Tizen::Ui::Controls::ListContextItem* __pItemContext; + CustomGroupedListElement* __pCustomGroupedListElement; +}; + * @endcode + * + * @code +//Sample code for GroupedListViewSample.cpp +#include +#include + +#include "GroupedListViewSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +class CustomGroupedListElement + : public ICustomElement +{ +public: + bool + OnDraw(Canvas& canvas, const Rectangle& rect, ListItemDrawingStatus itemStatus) + { + Tizen::Graphics::Font font; + font.Construct(FONT_STYLE_PLAIN, 15); + canvas.SetFont(font); + canvas.SetLineWidth(3); + canvas.SetForegroundColor(Color::GetColor(COLOR_ID_GREEN)); + + if (canvas.DrawRectangle(rect) != E_SUCCESS) + { + return false; + } + + if (canvas.DrawText(Point(rect.x+10, rect.y+15), L"Custom") != E_SUCCESS) + { + return false; + } + + return true; + } +}; + +bool +GroupedListViewSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +GroupedListViewSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of IconListView + __pGroupedListView = new GroupedListView(); + __pGroupedListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), GROUPED_LIST_VIEW_STYLE_INDEXED, true, true); + __pGroupedListView->SetItemProvider(*this); + __pGroupedListView->AddGroupedListViewItemEventListener(*this); + + // Adds the icon list view to the form + AddControl(*__pGroupedListView); + + // Creates an instance of ListContextItem + __pItemContext = new ListContextItem(); + __pItemContext->Construct(); + __pItemContext->AddElement(ID_CONTEXT_ITEM_1, "Test1"); + __pItemContext->AddElement(ID_CONTEXT_ITEM_2, "Test2"); + + // Gets instances of Bitmap + AppResource* pAppResource = Application::GetInstance()->GetAppResource(); + __pHome = pAppResource->GetBitmapN(L"tizen.png"); + __pMsg = pAppResource->GetBitmapN(L"tizen.png"); + __pAlarm = pAppResource->GetBitmapN(L"tizen.png"); + __pCall = pAppResource->GetBitmapN(L"tizen.png"); + + // Creates an instance of CustomGroupedListElement + __pCustomGroupedListElement = new CustomGroupedListElement(); + + return r; +} + +result +GroupedListViewSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates bitmaps + delete __pHome; + delete __pMsg; + delete __pAlarm; + delete __pCall; + + // Deallocates the item context + delete __pItemContext; + + return r; +} + +void +GroupedListViewSample::OnGroupedListViewItemStateChanged(GroupedListView &listView, int groupIndex, int itemIndex, int elementId, ListItemStatus state) +{ + switch (elementId) + { + case ID_FORMAT_STRING: + { + // .... + } + break; + case ID_FORMAT_BITMAP: + { + // .... + } + break; + default: + break; + } +} + +void +GroupedListViewSample::OnGroupedListViewContextItemStateChanged(GroupedListView &listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus state) +{ + switch (elementId) + { + case ID_CONTEXT_ITEM_1: + { + // .... + } + break; + case ID_CONTEXT_ITEM_2: + { + // .... + } + break; + default: + break; + } +} + +// IGroupedListViewItemEventListener +void +GroupedListViewSample::OnGroupedListViewItemSwept(GroupedListView &listView, int groupIndex, int itemIndex, SweepDirection direction) +{ + // .... +} + +int +GroupedListViewSample::GetGroupCount(void) +{ + return 3; +} + +int +GroupedListViewSample::GetItemCount(int groupIndex) +{ + int itemCount = 0; + switch (groupIndex) + { + case 0: + { + itemCount = 7; + } + break; + case 1: + { + itemCount = 5; + } + break; + case 2: + { + itemCount = 3; + } + break; + default: + break; + } + + return itemCount; +} + +// IGroupedListViewItemProvider +GroupItem* +GroupedListViewSample::CreateGroupItem(int groupIndex, int itemWidth) +{ + String text("Group "); + text.Append(groupIndex+1); + + GroupItem* pItem = new GroupItem(); + pItem->Construct(Dimension(itemWidth, 40)); + pItem->SetElement(text, null); + + return pItem; +} + +ListItemBase* +GroupedListViewSample::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + // Creates an instance of CustomItem + CustomItem* pItem = new CustomItem(); + ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; + pItem->Construct(Dimension(itemWidth, 100), style); + + switch (itemIndex % 4) + { + case 0: + { + style = LIST_ANNEX_STYLE_NORMAL; + pItem->AddElement(Rectangle(10, 20, 60, 60), ID_FORMAT_BITMAP, *__pHome, null, null); + pItem->AddElement(Rectangle(150, 25, 150, 50), ID_FORMAT_STRING, L"Home", true); + } + break; + case 1: + { + style = LIST_ANNEX_STYLE_MARK; + pItem->AddElement(Rectangle(10, 20, 60, 60), ID_FORMAT_BITMAP, *__pMsg, null, null); + pItem->AddElement(Rectangle(150, 25, 150, 50), ID_FORMAT_STRING, L"Msg", true); + } + break; + case 2: + { + style = LIST_ANNEX_STYLE_ONOFF_SLIDING; + pItem->AddElement(Rectangle(10, 20, 60, 60), ID_FORMAT_BITMAP, *__pAlarm, null, null); + pItem->AddElement(Rectangle(150, 25, 150, 50), ID_FORMAT_STRING, L"Alarm", true); + } + break; + case 3: + { + style = LIST_ANNEX_STYLE_DETAILED; + pItem->AddElement(Rectangle(10, 20, 60, 60), ID_FORMAT_BITMAP, *__pCall, null, null); + pItem->AddElement(Rectangle(150, 25, 150, 50), ID_FORMAT_STRING, L"Call", true); + } + break; + default: + break; + } + pItem->AddElement(Rectangle(360, 10, 180, 80), ID_FORMAT_CUSTOM, *(static_cast(__pCustomGroupedListElement))); + pItem->SetContextItem(__pItemContext); + + return pItem; +} + +bool +GroupedListViewSample::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + return true; +} + +bool +GroupedListViewSample::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + return true; +} + * @endcode + * + */ + + +class _OSP_EXPORT_ GroupedListView + : public Tizen::Ui::Control +{ +public: + /** + * The object is not fully constructed after this constructor is + * called. For full construction, the Construct() method must be + * called right after calling this constructor. + * + * @since 2.0 + */ + GroupedListView(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~GroupedListView(void); + + /** + * @if OSPDEPREC + * Initializes this instance of %GroupedListView with the specified parameters. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class + * This instance represents the x and y coordinates of the top-left corner of the created + * %GroupedListView control along with the width and height. + * @param[in] style The style of the %GroupedListView control + * @param[in] itemDivider Set to @c true to display an item divider, @n + * else @c false + * @param[in] fastScroll Set to @c true to use the fast scroll, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * Either the @c rect.width or @c rect.height parameter has a negative value. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result Construct(const Tizen::Graphics::Rectangle& rect, GroupedListViewStyle style, bool itemDivider = true, bool fastScroll = false); + + /** + * Initializes this instance of %GroupedListView with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class + * This instance represents the x and y coordinates of the top-left corner of the created + * %GroupedListView control along with the width and height. + * @param[in] style The style of the %GroupedListView control + * @param[in] itemDivider Set to @c true to display an item divider, @n + * else @c false + * @param[in] scrollStyle Set to scroll style + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * Either the @c rect.width or @c rect.height parameter has a negative value. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, GroupedListViewStyle style, bool itemDivider, ListScrollStyle scrollStyle); + + /** + * Sets the item provider that creates and deletes items from the list. + * + * @since 2.0 + * + * @return An error code + * @param[in] provider The item provider to create and delete items + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks If an item provider is not set for the list, the list does not work. @n + * A provider should be allocated on a heap memory. + */ + result SetItemProvider(IGroupedListViewItemProvider& provider); + + /** + * Adds an IGroupedListViewItemEventListener instance that listens to the state changes of the list view items. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + */ + void AddGroupedListViewItemEventListener(IGroupedListViewItemEventListener& listener); + + /** + * Removes an IGroupedListViewItemEventListener instance that listens to the state changes of the list view items. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + */ + void RemoveGroupedListViewItemEventListener(IGroupedListViewItemEventListener& listener); + + /** + * Adds an IFastScrollListener instance that listens to the state changes of a fast scroll. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + */ + void AddFastScrollListener(IFastScrollListener& listener); + + /** + * Removes an IFastScrollListener instance that listens to the state changes of a fast scroll. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + */ + void RemoveFastScrollListener(IFastScrollListener& listener); + + /** + * Adds an IScrollEventListener instance that listens to the state changes of a scroll event. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @see IScrollEventListener::OnScrollEndReached() + * @see RemoveScrollEventListener() + */ + void AddScrollEventListener(IScrollEventListener& listener); + + /** + * Removes an IScrollEventListener instance that listens to the state changes of a scroll event. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see IScrollEventListener::OnScrollEndReached() + * @see AddScrollEventListener() + */ + void RemoveScrollEventListener(IScrollEventListener& listener); + + /** + * Adds a link event listener. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks The added listener is notified when a link is selected by the user. + * + * @see RemoveUiLinkEventListener() + */ + void AddUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + /** + * Removes the specified link event listener. + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddUiLinkEventListener() + */ + void RemoveUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + /** + * Enables or disables the sweep event. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the item sweep, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetSweepEnabled(bool enable); + + /** + * Sets the index list of the fast scroll. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text of the index + * @param[in] useSearchIcon Set to @c true to display the magnifying icon, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + */ + result SetFastScrollIndex(const Tizen::Base::String& text, bool useSearchIcon); + + /** + * Gets the group and item indexes of the top item. + * + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const; + + /** + * Gets the group and item indexes of the bottom item. + * + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const; + + + /** + * Scrolls to the item at the specified index. @n + * The specified item is drawn at the top of the %GroupedListView control. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result ScrollToItem(int groupIndex, int itemIndex); + + /** + * Scrolls to the item at the specified index. @n + * The specified item is drawn at the position specified by the item alignment. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] itemAlignment The item alignment + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result ScrollToItem(int groupIndex, int itemIndex, ListScrollItemAlignment itemAlignment); + + /** + * Checks or unchecks the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index of the item to check + * @param[in] itemIndex The index of the item to check + * @param[in] check Set to @c true to select the item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The item is disabled. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method works only when the annex style of the item allows selection. + */ + result SetItemChecked(int groupIndex, int itemIndex, bool check); + + /** + * Checks whether the item at the specified index is selected. + * + * @since 2.0 + * + * @return @c true if the item is selected, @n + * else @c false + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @remarks This method returns @c false, if the annex style of the item does not allow selection. + */ + bool IsItemChecked(int groupIndex, int itemIndex) const; + + /** + * Enables or disables the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] enable Set to @c true to enable the specified item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the annex style of the list allows selection. + */ + result SetItemEnabled(int groupIndex, int itemIndex, bool enable); + + /** + * Checks whether the item at the specified index is enabled or disabled. + * + * @since 2.0 + * + * @return @c true if the item is enabled, @n + * else @c false + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + */ + bool IsItemEnabled(int groupIndex, int itemIndex) const; + + /** + * Counts the total number of groups. + * + * @since 2.0 + * + * @return The total number of groups + */ + int GetGroupCount(void) const; + + /** + * Counts all the items of the specified group. + * + * @since 2.0 + * + * @return The total number of items in the specified group + * @param[in] groupIndex The group index + */ + int GetItemCountAt(int groupIndex) const; + + /** + * Shows the description text of the specified item. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index of the item + * @param[in] itemIndex The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If no description text is set for the item at the specified index, it is not displayed. + * + */ + result ShowItemDescriptionText(int groupIndex, int itemIndex); + + /** + * Hides the description text of the specified item. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index of the item + * @param[in] itemIndex The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result HideItemDescriptionText(int groupIndex, int itemIndex); + + /** + * Updates the specified item. @n + * For instance, LIST_REFRESH_TYPE_ITEM_ADD is used when a new item needs to be added and LIST_REFRESH_TYPE_ITEM_REMOVE is used when an item is deleted from the + * list. Moreover, LIST_REFRESH_TYPE_ITEM_MODIFY is used when the content of an existing item has changed and it needs to be updated. @n + * Note that calling this method with LIST_REFRESH_TYPE_ITEM_MODIFY invokes item provider's DeleteItem() and CreateItem() for the given index in sequence. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] type The item to be added, removed, or modified + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + * @remarks If the specified itemIndex is -1, then the method is applied to the group item with the given index. @n + * Note that if LIST_REFRESH_TYPE_ITEM_REMOVE option is used to a group item, all the items in the group (including the group item itself) are + * removed from the list. + * @remarks This method internally calls Invalidate(), so you do not need to call them to update the screen. + */ + result RefreshList(int groupIndex, int itemIndex, ListRefreshType type); + + /** + * Refreshes the specified item's element. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] elementId The item element ID + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method internally calls Invalidate(), so you do not need to call them to update the screen. + */ + result RefreshList(int groupIndex, int itemIndex, int elementId); + + /** + * Updates all the items of a list. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method clears all the items in the list and invokes the methods of the item provider again to update the list. + */ + result UpdateList(void); + + /** + * Gets the index of the item at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] x The X position of the item + * @param[in] y The Y position of the item + * @param[out] groupIndex The index of the group that the item belongs to + * @param[out] itemIndex The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred, or @n + * there is no item at the specified position. + */ + result GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex) const; + + /** + * Gets the index of the item at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position of the item + * @param[out] groupIndex The index of the group that the item belongs to + * @param[out] itemIndex The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred, or @n + * there is no item at the specified position. + */ + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex) const; + + /** + * Gets the index of the item and ID of the element at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] x The X position of the item + * @param[in] y The Y position of the item + * @param[out] groupIndex The index of the group that the item belongs to + * @param[out] itemIndex The index of the item + * @param[out] elementId The ID of the element + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred, or + * there is no item at the specified position. + * @remarks @c groupIndex and @c itemIndex are -1 when there is no list item at the specified position. + * @remarks @c elementId is -1 when there is no element at the specified position + */ + result GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex, int& elementId) const; + + /** + * Gets the index of the item and ID of the element at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position of the point + * @param[out] groupIndex The index of the group that the item belongs to + * @param[out] itemIndex The index of the item + * @param[out] elementId The ID of the element + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred, or + * there is no item at the specified position. + * @remarks @c groupIndex and @c itemIndex are -1 when there is no list item at the specified position. + * @remarks @c elementId is -1 when there is no element at the specified position + */ + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex, int& elementId) const; + + /** + * Sets the color of a section. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The section color + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation (this control cannot be displayed). + * @exception E_SYSTEM A system error has occurred. + * @remarks This method works only when the style of the %GroupedListView control is GROUPED_LIST_VIEW_STYLE_SECTION. @n + * If the device does not support the 32-bit color space, the method sets the alpha value of the specified color to @c 255. + */ + result SetSectionColor(const Tizen::Graphics::Color& color); + + /** + * Gets the color of a section. + * + * @since 2.0 + * + * @return The section color, @n + * else RGBA(0, 0, 0, 0) if the instance is invalid + */ + Tizen::Graphics::Color GetSectionColor(void) const; + + /** + * Sets the color of a division line between items. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The division line color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemDividerColor(const Tizen::Graphics::Color& color); + + /** + * Gets the color of a division line between items. + * + * @since 2.0 + * + * @return The color of a division line, @n + * else RGBA(0, 0, 0, 0) if the instance is invalid + */ + Tizen::Graphics::Color GetItemDividerColor(void) const; + + /** + * Sets the background color of this control. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The background color + * @exception E_SUCCESS The method is successful. + * @remarks If the device does not support the 32-bit color space, the method sets the alpha value of the specified color to @c 255. @n + * The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, + * only the bitmap image is displayed. + */ + result SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * Gets the background color of this control. + * + * @since 2.0 + * + * @return The background color, @n + * else RGBA(0, 0, 0, 0) if the instance is invalid + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + + /** + * Sets the bitmap of this control. + * + * @since 2.0 + * + * @return An error code + * @param[in] pBitmap The bitmap for the list + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + /** + * Sets the bitmap of the empty list. + * + * @since 2.0 + * + * @return An error code + * @param[in] pBitmap The bitmap for the empty list + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetBitmapOfEmptyList(const Tizen::Graphics::Bitmap* pBitmap); + + /** + * Sets the text of the empty list. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text for the empty list + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTextOfEmptyList(const Tizen::Base::String& text); + + /** + * Gets the text to display when there is no item in a list. + * + * @since 2.0 + * + * @return The text to be displayed, @n + * else an empty string when the instance is invalid + */ + Tizen::Base::String GetTextOfEmptyList(void) const; + + /** + * Sets the color of the text to be displayed when there is no item in a list. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color of the text to be displayed + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + /** + * Gets the color of the text to be displayed when there is no item in a list. + * + * @since 2.0 + * + * @return The color of the text to be displayed, @n + * else RGBA(0, 0, 0, 0) if the instance is invalid + */ + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + /** + * Expands the group's items. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The index of the group + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result ExpandGroup(int groupIndex); + + /** + * Collapses the group's items. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The index of the group + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result CollapseGroup(int groupIndex); + + /** + * Checks whether the group is expanded. + * + * @since 2.0 + * + * @return @c true if the group is expanded, @n + * @c else false + * + * @param[in] groupIndex The index of the group + */ + bool IsGroupExpanded(int groupIndex) const; + + /** + * Begins the reordering mode. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The reordering mode is only supported when %GroupedListView% is constructed with GroupedListViewStyle::GROUPED_LIST_VIEW_STYLE_INDEXED style. + * @see GroupedListView::Construct() + * @see IGroupedListViewItemEventListener::OnGroupedListViewItemReordered() + */ + result BeginReorderingMode(void); + + /** + * Ends the reordering mode. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The reordering mode is only supported when %GroupedListView% is constructed with GroupedListViewStyle::GROUPED_LIST_VIEW_STYLE_INDEXED style. + * @see GroupedListView::Construct() + * @see IGroupedListViewItemEventListener::OnGroupedListViewItemReordered() + */ + result EndReorderingMode(void); + + /** + * Checks whether the %GroupedListView control is in reordering mode. + * + * @since 2.0 + * + * @return @c true if the %GroupedListView is in reordering mode, + * else @c false + */ + bool IsInReorderingMode(void) const; + +protected: + friend class _GroupedListViewImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + GroupedListView(const GroupedListView& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + GroupedListView& operator =(const GroupedListView& rhs); + +}; // GroupedListView + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_GROUPED_LIST_VIEW_H_ diff --git a/inc/FUiCtrlGroupedListViewTypes.h b/inc/FUiCtrlGroupedListViewTypes.h new file mode 100644 index 0000000..569837f --- /dev/null +++ b/inc/FUiCtrlGroupedListViewTypes.h @@ -0,0 +1,44 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlGroupedListViewTypes.h + * @brief This is the header file for the GroupedListView enumerations. + * + * This header file contains the declarations of the GroupedListView enumerations. + */ +#ifndef _FUI_CTRL_GROUPED_LIST_VIEW_TYPES_H_ +#define _FUI_CTRL_GROUPED_LIST_VIEW_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @enum GroupedListViewStyle + * + * Defines the style of %GroupedListView. + * + * @since 2.0 + */ +enum GroupedListViewStyle +{ + GROUPED_LIST_VIEW_STYLE_INDEXED = 0, /**< The group and the item are displayed in a rectangular area */ + GROUPED_LIST_VIEW_STYLE_SECTION /**< All the items in the group are displayed in a rounded rectangle */ +}; // GroupedListViewStyle + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_GROUPED_LIST_VIEW_TYPES_H_ diff --git a/inc/FUiCtrlGroupedTableView.h b/inc/FUiCtrlGroupedTableView.h new file mode 100644 index 0000000..1dc8933 --- /dev/null +++ b/inc/FUiCtrlGroupedTableView.h @@ -0,0 +1,813 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlGroupedTableView.h + * @brief This is the header file for the %GroupedTableView class. + * + * This header file contains the declarations of the %GroupedTableView class and its helper classes. + */ + +#ifndef _FUI_CTRL_GROUPED_TABLE_VIEW_H_ +#define _FUI_CTRL_GROUPED_TABLE_VIEW_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class IGroupedTableViewItemProvider; +class IGroupedTableViewItemEventListener; +class IFastScrollListener; +class IScrollEventListener; + +/** + * @class GroupedTableView + * @brief This class defines common behavior for a %GroupedTableView control. + * + * @since 2.0 + * + * The %GroupedTableView class defines common behavior for a %GroupedTableView control. + * @code +//Sample code for GroupedTableViewSample.h +#include + +class GroupedTableViewSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IGroupedTableViewItemProvider + , public Tizen::Ui::Controls::IGroupedTableViewItemEventListener + , public Tizen::Ui::Controls::IFastScrollListener +{ +public: + GroupedTableViewSample(void) + : __pGroupedTableView(null) + , __pContextItem(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // IGroupedTableViewItemEventListener + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated); + + // IGroupedTableViewItemProvider + virtual int GetGroupCount(void); + virtual int GetItemCount(int groupIndex); + virtual Tizen::Ui::Controls::TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + virtual void UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth); + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + virtual void UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + virtual int GetDefaultItemHeight(void); + virtual int GetDefaultGroupItemHeight(void); + + // IFastScrollListener + virtual void OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index); + +private: + Tizen::Ui::Controls::GroupedTableView* __pGroupedTableView; + Tizen::Ui::Controls::TableViewContextItem* __pContextItem; +}; + * @endcode + * + * @code + +//Sample code for GroupedTableViewSample.cpp +#include +#include + +#include "GroupedTableViewSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui::Controls; + +bool +GroupedTableViewSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +GroupedTableViewSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of TableView + __pGroupedTableView = new GroupedTableView(); + __pGroupedTableView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), true, TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL); + __pGroupedTableView->SetItemProvider(*this); + __pGroupedTableView->AddTableViewItemEventListener(*this); + + __pGroupedTableView->AddFastScrollListener(*this); + __pGroupedTableView->SetFastScrollIndex(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ", true); + + // Adds the TableView to the form + AddControl(*__pGroupedTableView); + + // Creates an instance of TableViewContextItem + __pContextItem = new TableViewContextItem(); + __pContextItem->Construct(Dimension(720, 100)); + + Button* pButton = new Button(); + pButton->Construct(Rectangle(10, 10, 200, 80), L"Context1"); + + Button* pButton2 = new Button(); + pButton2->Construct(Rectangle(250, 10, 200, 80), L"Context2"); + + __pContextItem->AddControl(*pButton); + __pContextItem->AddControl(*pButton2); + + return r; +} + +result +GroupedTableViewSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the item context + delete __pItemContext; + __pItemContext = null; + + return r; +} + +// IGroupedTableViewItemEventListener implementation +void +GroupedTableViewSample::OnGroupedTableViewGroupItemStateChanged(GroupedTableView& tableView, int groupIndex, TableViewGroupItem* pItem, TableViewItemStatus status) +{ + if (tableView.IsGroupExpanded(groupIndex)) + { + tableView.CollapseGroup(groupIndex); + } + else + { + tableView.ExpandGroup(groupIndex); + } +} + +void +GroupedTableViewSample::OnGroupedTableViewItemStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status) +{ + // .... +} + +void +GroupedTableViewSample::OnGroupedTableViewContextItemActivationStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewContextItem* pContextItem, bool activated) +{ + // .... +} + +// IFastScrollListener implementation +void +GroupedTableViewSample::OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index) +{ + // .... +} + +// IGroupedTableViewItemProvider implementation +int +GroupedTableViewSample::GetGroupCount(void) +{ + return 26; +} + +int +GroupedTableViewSample::GetItemCount(int groupIndex) +{ + return 10; +} + +int +GroupedTableViewSample::GetDefaultItemHeight(void) +{ + return 100; +} + +int +GroupedTableViewSample::GetDefaultGroupItemHeight(void) +{ + return 80; +} + +TableViewGroupItem* +GroupedTableViewSample::CreateGroupItem(int groupIndex, int itemWidth) +{ + TableViewGroupItem* pItem = new TableViewGroupItem(); + pItem->Construct(Dimension(itemWidth, GetDefaultGroupItemHeight())); + + String text; + text.Format(30, L"Group title %d", itemIndex); + + Label* pLabel = new Label(); + pLabel->Construct(Rectangle(0, 0, itemWidth, GetDefaultGroupItemHeight(), text); + + pItem->AddControl(*pLable); + + return pItem; +} + +bool +GroupedTableViewSample::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + delete pItem; + + return true; +} + +void +GroupedTableViewSample::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + // .... +} + +TableViewItem* +GroupedTableViewSample::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL; + TableViewItem* pItem = new TableViewItem(); + + switch (itemIndex % 5) + { + case 0: + style = TABLE_VIEW_ANNEX_STYLE_NORMAL; + break; + case 1: + style = TABLE_VIEW_ANNEX_STYLE_MARK; + break; + case 2: + style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING; + break; + case 3: + style = TABLE_VIEW_ANNEX_STYLE_DETAILED; + break; + case 4: + style = TABLE_VIEW_ANNEX_STYLE_RADIO; + break; + default: + break; + } + + pItem->Construct(Dimension(itemWidth, GetDefaultItemHeight()), style); + + String text; + text.Format(30, L"TableViewItem %d", itemIndex); + + Label* pLabel = new Label(); + pLabel->Construct(Rectangle(0, 0, itemWidth, GetDefaultItemHeight(), text); + + pItem->AddControl(*pLabel); + pItem->SetContextItem(__pContextItem); + + return pItem; +} + +bool +GroupedTableViewSample::DeleteItem(int groupIndex, int itemIndex, Controls::TableViewItem* pItem) +{ + delete pItem; + + return true; +} + +void +GroupedTableViewSample::UpdateItem(int groupIndex, int itemIndex, Controls::TableViewItem* pItem) +{ + // .... +} + * @endcode + * + */ + +class _OSP_EXPORT_ GroupedTableView + : public Tizen::Ui::Container +{ +public: + /** + * The object is not fully constructed after this constructor is called. Hence, the Construct() method must be called after calling this constructor. + * + * @since 2.0 + */ + GroupedTableView(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~GroupedTableView(void); + + /** + * Initializes this instance of %GroupedTableView with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class + * This instance represents the x and y coordinates of the left top corner of the created %GroupedTableView along with the width and height. + * @param[in] itemDivider Set to @c true to display an item divider, @n + * else @c false + * @param[in] scrollStyle The style of %GroupedTableView scroll bar style + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or either the rect.width or rect.height parameter has a negative value. + * + */ + result Construct(const Tizen::Graphics::Rectangle& rect, bool itemDivider, TableViewScrollBarStyle scrollStyle); + + /** + * Sets the item provider that creates and deletes items for the grouped style table view. + * + * @since 2.0 + * + * @param[in] pProvider The item provider to create and delete items + * @remarks If an item provider is not set for the table view, the table view does not work. The specified provider should be allocated in heap memory. + * To reset the item provider, pass @c null to @c pProvider. + */ + void SetItemProvider(IGroupedTableViewItemProvider* pProvider); + + /** + * Expands the group's items. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The index of the group + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + result ExpandGroup(int groupIndex); + + /** + * Collapses the group's items. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The index of the group + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + result CollapseGroup(int groupIndex); + + /** + * Expands all groups of table view. + * + * @since 2.0 + * + */ + void ExpandAllGroup(void); + + /** + * Collapses all groups of table view. + * + * @since 2.0 + * + */ + void CollapseAllGroup(void); + + /** + * Returns whether the group is expanded or not. + * + * @since 2.0 + * + * @return @c true if the group is expanded, else @c false + * @param[in] groupIndex The index of the group + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + bool IsGroupExpanded(int groupIndex) const; + + /** + * Sets the grouped look is enabled. + * + * @since 2.0 + * + * @param[in] enable The enabled/disabled status + */ + void SetGroupedLookEnabled(bool enable); + + /** + * Returns whether the grouped look is enabled or not. + * + * @since 2.0 + * + * @return @c true if the grouped look is enabled, else @c false + */ + bool IsGroupedLookEnabled(void) const; + + /** + * Adds a listener instance that listens to state changes of table view items. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @remarks The specified listener should be allocated in heap memory. + */ + result AddGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener); + + /** + * Removes a listener instance that listens to state changes of table view items. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The listener is not found. + */ + result RemoveGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener); + + /** + * Adds a listener instance that listens to state changes of a fast scroll. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @remarks The specified listener should be allocated in heap memory. + */ + result AddFastScrollListener(IFastScrollListener& listener); + + /** + * Removes a listener instance that listens to state changes of a fast scroll. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_OBJ_NOT_FOUND The listener is not found. + */ + result RemoveFastScrollListener(IFastScrollListener& listener); + + /** + * Adds a listener instance that listens to state changes of a scroll event. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @see IScrollEventListener::OnScrollEndReached() + * @see RemoveScrollEventListener() + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @remarks The specified listener should be allocated in heap memory. + */ + result AddScrollEventListener(IScrollEventListener& listener); + + /** + * Removes a listener instance that listens to state changes of a scroll event. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to remove + * @see IScrollEventListener::OnScrollEndReached() + * @see AddScrollEventListener() + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_OBJ_NOT_FOUND The listener is not found. + */ + result RemoveScrollEventListener(IScrollEventListener& listener); + + /** + * Enables or disables the collapse by pinch gesture. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable the collapse by pinch gesture, else @c false + */ + void SetCollapseByPinchGestureEnabled(bool enable); + + /** + * Returns whether the collapse by pinch gesture is enabled or not. + * + * @since 2.0 + * + * @return @c true if the collapse by pinch gesture is enabled, else @c false + */ + bool IsCollapseByPinchGestureEnabled(void) const; + + /** + * Sets the text index of the fast scroll. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text of the index + * @param[in] useSearchIcon Set to @c true to show the magnifying icon, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + */ + result SetFastScrollIndex(const Tizen::Base::String& text, bool useSearchIcon); + + /** + * Gets the group and item indexes of the top item. + * + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND Top drawn item is not found. + */ + result GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const; + + /** + * Gets the group and item indexes of the bottom item. + * + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND Bottom drawn item is not found. + */ + result GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const; + + /** + * Scrolls to the item at the specified index. + * The specified item is drawn at the position specified by the item alignment. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] itemAlignment The item alignment + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @remarks If the specified item. itemIndex is -1, then the method is applied to the group item with the given index. + */ + result ScrollToItem(int groupIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment = TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP); + + /** + * Checks or unchecks the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] check Set to @c true to select the item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The item is disabled. + * @remarks This method works only when the annex style of the item allows selection. + */ + result SetItemChecked(int groupIndex, int itemIndex, bool check); + + /** + * Returns whether the item at the specified index is selected or not. + * + * @since 2.0 + * + * @return @c true if the item is selected, @n + * else @c false + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @remarks This method returns @c false, if the annex style of the item does not allow selection. + */ + bool IsItemChecked(int groupIndex, int itemIndex) const; + + /** + * Enables or disables the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] enable Set to @c true to enable the specified item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + result SetItemEnabled(int groupIndex, int itemIndex, bool enable); + + /** + * Returns whether the item at the specified index is enabled or disabled. + * + * @since 2.0 + * + * @return @c true if the item is enabled, @n + * else @c false + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + bool IsItemEnabled(int groupIndex, int itemIndex) const; + + /** + * Counts the total number of groups. + * + * @since 2.0 + * + * @return The total number of groups + */ + int GetGroupCount(void) const; + + /** + * Counts all the items of the specified group. + * + * @since 2.0 + * + * @return The total number of items in the specified group + * @param[in] groupIndex The group index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + int GetItemCountAt(int groupIndex) const; + + /** + * Updates the specified item. @n + * For instance, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD is used when a new item needs to be added and TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE is used when an item is deleted from the + * table view. Moreover, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY is used when the content of an existing item has changed and it needs to be updated. + * Note that calling this method with TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY invokes item provider's UpdateItem() for the given index in sequence. + * + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] type The item to be added, removed, or modified + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @remarks If the specified item. itemIndex is -1, then the method is applied to the group item with the given index. + * Note that if TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE option is used to a group item, all the items in the group (including the group item itself) are + * removed from the table view. + */ + result RefreshItem(int groupIndex, int itemIndex, TableViewRefreshType type); + + /** + * Updates all the items of a table view. + * + * @since 2.0 + * + * @remarks This method clears all the items in the table view and invokes the methods of the item provider again to update the table view. + */ + void UpdateTableView(void); + + /** + * Gets the index of the item at the specified position. + * + * @since 2.0 + * + * @param[in] position The position of the item + * @param[out] groupIndex The group index of the item on specified position + * @param[out] itemIndex The item index of the item on specified position + * @remarks This method sets both of groupIndex and itemIndex to -1 if no item is found at the given position. + */ + void GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex) const; + + /** + * Sets the color of a division line between items. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The division line color + */ + void SetItemDividerColor(const Tizen::Graphics::Color& color); + + /** + * Gets the color of a division line between items. + * + * @since 2.0 + * + * @return The color of a division line + */ + Tizen::Graphics::Color GetItemDividerColor(void) const; + + /** + * Sets the background color of this control. + * + * @since 2.0 + * + * @param[in] color The background color + * @remarks The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, + * only the bitmap image is displayed. + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * Sets the scroll input handling mode. + * + * @since 2.0 + * + * @param[in] mode The scroll input handling mode + * @see GetScrollInputMode() + */ + void SetScrollInputMode(ScrollInputMode mode); + + /** + * Gets the scroll input handling mode. + * + * @since 2.0 + * + * @return The scroll input handling mode + * @see SetScrollInputMode() + */ + ScrollInputMode GetScrollInputMode(void) const; + + /** + * Gets the background color of this control. + * + * @since 2.0 + * + * @return The background color + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + + /* + * Scrolls the list contents with the amount of pixels. + * + * @since 2.0 + * + * @return An error code + * @param[in] pixel The amount of pixels to scroll + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c pixel is out of range. + * @remarks If you call ScrollByPixel() with negative @c pixel when position of scroll is already top of contents then it will return E_OUT_OF_RANGE. + * Likewise, in case of positive @c pixel on the bottom position of scroll it will also return E_OUT_OF_RANGE. + */ + result ScrollByPixel(int pixel); + + /* + * Gets the current scroll position + * + * @since 2.0 + */ + int GetCurrentScrollPosition(void) const; + + /* + * Enables or disables the scroll of GroupedTableView items. + * + * @since 2.0 + */ + void SetScrollEnabled(bool enable); + + /* + * Checks whether the scroll is enabled or disabled. + * + * @since 2.0 + */ + bool IsScrollEnabled(void) const; + +private: + friend class _TableViewImpl; + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + GroupedTableView(const GroupedTableView& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + GroupedTableView& operator =(const GroupedTableView& rhs); +}; // GroupedTableView + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_GROUPED_TABLE_VIEW_H_ diff --git a/inc/FUiCtrlHeader.h b/inc/FUiCtrlHeader.h new file mode 100644 index 0000000..cf8c5fd --- /dev/null +++ b/inc/FUiCtrlHeader.h @@ -0,0 +1,1041 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlHeader.h + * @brief This is the header file for the %Header class. + * + * This header file contains the declarations of the %Header class. + */ +#ifndef _FUI_CTRL_HEADER_H_ +#define _FUI_CTRL_HEADER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class _HeaderImpl; + +/** + * @enum HeaderStyle + * + * Defines the possible styles of a %Header control. + * + * @since 2.0 + */ +enum HeaderStyle +{ + HEADER_STYLE_TITLE, /**< The title style */ + HEADER_STYLE_TITLE_BUTTON, /**< The title button style */ + HEADER_STYLE_SEGMENTED, /**< The segmented style */ + HEADER_STYLE_SEGMENTED_WITH_TITLE, /**< The segmented style with title */ + HEADER_STYLE_TAB, /**< The tab style */ + HEADER_STYLE_TAB_WITH_TITLE, /**< The tab with title style */ + HEADER_STYLE_BUTTON /**< The button style */ +}; + +/** + * @enum HeaderAnimationPosition + * + * Defines the possible positions of the waiting animation of a header. + * + * @since 2.0 + */ +enum HeaderAnimationPosition +{ + HEADER_ANIMATION_POSITION_TITLE, /**< The title animation */ + HEADER_ANIMATION_POSITION_BUTTON_LEFT, /**< The left button animation */ + HEADER_ANIMATION_POSITION_BUTTON_RIGHT /**< The right button animation */ +}; + +/** + * @class Header + * @brief This class is an implementation of a %Header control. + * + * @since 2.0 + * + * The %Header class displays a multi-purpose area at the top of the screen that usually acts as a placeholder for descriptive + * contents, such as a title of the current screen. It can also contain buttons for performing various user-defined tasks. + * + * For more information on the class features, see Header. + * + * The following examples demonstrate how to use the %Header class. + * + * - Constructing a header: @n + * When creating a Form, specify the FORM_STYLE_HEADER parameter in the Form::Construct() method. + * + * @code + * // Initializes + * bool + * TestForm::Initialize(void) + * { + * Construct(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER ); + * } + * @endcode + * + * - Using the header: @n + * Gets the header with the GetHeader() method, and sets the header style. + * + * @code + * bool + * TestForm::Initialize(void) + * { + * Header* pHeader = GetHeader(); + * pHeader->SetStyle(HEADER_STYLE_SEGMENTED); + * } + * @endcode + * + * - Adding items to the header: @n + * Adds HeaderItems or ButtonItems according to the header style. The action ID registered in the Construct() method is notified + * when items are touched. + * + * @code + * bool + * TestForm::Initialize(void) + * { + * HeaderItem headerItem; + * headerItem.Construct(ID_HEADER_ITEM); + * headerItem.SetText("HeaderItem"); + * + * pHeader->AddItem(headerItem); + * + * ButtonItem buttonItem; + * buttonItem.Construct(BUTTON_ITEM_STYLE_ICON, ID_HEADER_BUTTON); + * buttonItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, __pBitmap); + * + * pHeader->SetButton(BUTTON_POSITION_LEFT, buttonItem); + * + * } + * @endcode + * + * - Setting the header title and description: + * + * @code + * bool + * TestForm::Initialize(void) + * { + * pHeader->SetTitleText(L"Header Title"); + * pHeader->SetDescriptionText(L"Description Text"); + * } + * @endcode + */ +class _OSP_EXPORT_ Header + : public Tizen::Ui::Control +{ + +public: + /** + * Adds the specified header item. + * + * @since 2.0 + * + * @return An error code + * @param[in] item The HeaderItem object to be added + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified item is not constructed. + * @exception E_SYSTEM A system error has occurred. + * @remarks The %Header control does not throw any exception even though the same action ID is assigned to multiple items. @n + * However, the content of the specified item is copied to the %Header control. + */ + result AddItem(const HeaderItem& item); + + + /** + * Inserts the header item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index where the item should be inserted + * @param[in] item The HeaderItem object to be inserted + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or the index is greater than or equal to the number of elements or less than @c 0. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c item is not constructed. + * @exception E_SYSTEM A system error has occurred. + * @remarks The %Header control does not throw any exception even though the same action ID is assigned to multiple items. @n + * However, the content of the specified item is copied to the %Header control. + */ + result InsertItemAt(int itemIndex, const HeaderItem& item); + + + /** + * Checks whether a button item is set at the specified position. + * + * @since 2.0 + * + * @return @c true if the button item is set at the specified position, @n + * else @c false + * @param[in] position The position of the button item + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + bool IsButtonSet(ButtonPosition position) const; + + + /** + * Gets the state of the specified button item. + * + * @since 2.0 + * + * @return The state of the button item at the specified position, @n + * else @c BUTTON_ITEM_STATUS_NORMAL if an error occurs + * @param[in] position The position of the button item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * There is no button set at the specified position. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + ButtonItemStatus GetButtonStatus(ButtonPosition position) const; + + + /** + * Gets the color of the button item for the specified state. + * + * @since 2.0 + * + * @return The color of the button item, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The status of the button item + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetButtonColor() + */ + Tizen::Graphics::Color GetButtonColor(ButtonItemStatus status) const; + + + /** + * Gets the text color of the button item for the specified state. + * + * @since 2.0 + * + * @return The text color of the button item, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The status of the button item + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetButtonTextColor(ButtonItemStatus status) const; + + + /** + * Gets the description text of the %Header control that has the title style. + * + * @since 2.0 + * + * @return The description text, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::String GetDescriptionText(void) const; + + + /** + * Gets the description text color of the %Header control that has the title style. + * + * @since 2.0 + * + * @return The description text color, @n + * else RGBA (0,0,0,0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetDescriptionTextColor(void) const; + + + /** + * Gets the color of the header item for the specified item state. + * + * @since 2.0 + * + * @return The color of the item, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The item status + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetItemColor() + */ + Tizen::Graphics::Color GetItemColor(HeaderItemStatus status) const; + + + /** + * Gets the total number of header items. + * + * @since 2.0 + * + * @return The total number of header items, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetItemCount(void) const; + + + /** + * Gets the state of the specified header item. + * + * @since 2.0 + * + * @return The item status + * @param[in] itemIndex The index of the item + * @param[out] status The item status + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than @c 0. + */ + result GetItemStatus(int itemIndex, HeaderItemStatus& status) const; + + + /** + * Gets the text color of the header item for the specified item state. + * + * @since 2.0 + * + * @return The item's text color, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The item status + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetItemTextColor(HeaderItemStatus status) const; + + + /** + * Gets the style of the %Header control. + * + * @since 2.0 + * + * @return The %Header control style, @n + * else @c HEADER_STYLE_TITLE if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + HeaderStyle GetStyle(void) const; + + + /** + * Gets the index of the currently selected item. + * + * @since 2.0 + * + * @return The selected item index, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported when the style of the %Header control is not @c HEADER_STYLE_SEGMENTED. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetSelectedItemIndex(void) const; + + + /** + * Gets the title text of the %Header control that has the title style. + * + * @since 2.0 + * + * @return The title text, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::String GetTitleText(void) const; + + + /** + * Gets the title text color of the %Header control that has the title style. + * + * @since 2.0 + * + * @return The title text color, @n + * else RGBA (0,0,0,0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetTitleTextColor(void) const; + + + /** + * Gets the color of the %Header control. + * + * @since 2.0 + * + * @return The header color, @n + * else RGBA (0,0,0,0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetColor(void) const; + + + /** + * Gets the status of the waiting animation at the specified position. + * + * @since 2.0 + * + * @return The animation status + * @param[in] animationPos The waiting animation position + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * This method returns @c ANIMATION_STOPPED, if no animation is in progress at the specified position. + * @see PauseWaitingAnimation() + * @see PlayWaitingAnimation() + * @see StopWaitingAnimation() + */ + AnimationStatus GetWaitingAnimationStatus(HeaderAnimationPosition animationPos) const; + + + /** + * Pauses the waiting animation at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] animationPos The waiting animation position + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * No waiting animation is in progress at the specified position. + * @exception E_SYSTEM A system error has occurred. + * @see PlayWaitingAnimation() + * @see StopWaitingAnimation() + */ + result PauseWaitingAnimation(HeaderAnimationPosition animationPos); + + + /** + * Starts the waiting animation at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] animationPos The waiting animation position + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * There is no button set at the specified position (except for @c HEADER_ANIMATION_POSITION_TITLE). + * @exception E_SYSTEM A system error has occurred. + * @see SetButton() + * @see IsButtonSet() + * @see GetWaitingAnimationStatus() + * @see PauseWaitingAnimation() + * @see StopWaitingAnimation() + */ + result PlayWaitingAnimation(HeaderAnimationPosition animationPos); + + + /** + * Removes all the button items. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveAllButtons(void); + + + /** + * Removes all the %Header control items. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The left button, right button, and back button items are not removed. + */ + result RemoveAllItems(void); + + + /** + * Removes the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index of the item to be removed + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveItemAt(int itemIndex); + + + /** + * Removes the button item at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position of the button item to remove + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks If no button item is set at the specified position, the method returns @c E_SUCCESS. + */ + result RemoveButtonAt(ButtonPosition position); + + + /** + * Sets the background bitmap image. + * + * @since 2.0 + * + * @return An error code + * @param[in] pBitmap The background image + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + + /** + * Sets the button item at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position at which to set the specified button item + * @param[in] button The button item to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified item is not constructed. + * @exception E_SYSTEM A system error has occurred. + * @remarks If there is an existing button item at the specified position, it is replaced with a new item. @n + * The contents of the specified item are copied. + */ + result SetButton(ButtonPosition position, const ButtonItem& button); + + + /** + * Sets the button item color for the specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status of the button item + * @param[in] color The button item color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetButtonColor() + */ + result SetButtonColor(ButtonItemStatus status, const Tizen::Graphics::Color& color); + + + /** + * Enables or disables the button item at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The button item position + * @param[in] enable Set to @c true to enable the specified button item, @n + * else @c false to disable + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * There is no button set at the specified position. + * @exception E_SYSTEM A system error has occurred. + */ + result SetButtonEnabled(ButtonPosition position, bool enable); + + + /** + * Sets the text color of the button item for the specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status of the button item + * @param[in] color The button item text color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetButtonTextColor(ButtonItemStatus status, const Tizen::Graphics::Color& color); + + + /** + * Sets the badge icon of the specified ButtonItem. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The button item position + * @param[in] pBadgeIcon The bitmap for the icon + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the style of the %Header control is @c HEADER_STYLE_TAB or @c HEADER_STYLE_TAB_WITH_TITLE. + */ + result SetButtonBadgeIcon(ButtonPosition position, const Tizen::Graphics::Bitmap* pBadgeIcon); + + + /** + * Sets the numbered badge icon of the specified ButtonItem. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The button item position + * @param[in] number The number value that should be displayed as the badge icon + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c number must be in the range defined by @c 0 and @c 99999. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the style of the %Header control is @c HEADER_STYLE_TAB or @c HEADER_STYLE_TAB_WITH_TITLE. + * @remarks To remove the numbered badge icon from an item, pass @c 0 as the value of @c number. + */ + result SetButtonNumberedBadgeIcon(ButtonPosition position, int number); + + + /** + * Sets the contents of the %Header control item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index at which to set the specified item + * @param[in] item The item to be set + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than @c 0. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The contents of the specified item are copied. + */ + result SetItemAt(int itemIndex, const HeaderItem& item); + + + /** + * Sets the badge icon of the specified segmented style header item. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The item index + * @param[in] pBadgeIcon The bitmap for the icon + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than @c 0. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the style of the %Header control is not @c HEADER_STYLE_SEGMENTED. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemBadgeIcon(int itemIndex, const Tizen::Graphics::Bitmap* pBadgeIcon); + + + /** + * Sets the numbered badge icon of the specified segmented style header item. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The item index + * @param[in] number The number value that should be displayed as the badge icon + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c number must be in the range defined by @c 0 and @c 99999. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than @c 0. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the style of the %Header control is not @c HEADER_STYLE_SEGMENTED. + * @exception E_SYSTEM A system error has occurred. + * @remarks To remove the numbered badge icon from an item, pass @c 0 as the value of @c number. + */ + result SetItemNumberedBadgeIcon(int itemIndex, int number); + + + /** + * Sets the item color for the specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The item status + * @param[in] color The item color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetItemColor() + */ + result SetItemColor(HeaderItemStatus status, const Tizen::Graphics::Color& color); + + + /** + * Sets the item state at the specified index in the %Header control. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index of the item to be set + * @param[in] enable Set to @c true to enable the item state, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than @c 0. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The specified item is currently selected. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemEnabled(int itemIndex, bool enable); + + + /** + * Sets the item text color for the specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The item status + * @param[in] color The item text color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemTextColor(HeaderItemStatus status, const Tizen::Graphics::Color& color); + + + /** + * Sets the selected item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index of the item to be selected + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than or equal to the number of elements or less than @c 0. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The item at the specified index is disabled. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the %Header control style is @c HEADER_STYLE_TITLE. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemSelected(int itemIndex); + + + /** + * Sets the color of the %Header control. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The header color + * @exception E_SUCCESS The method is successful. + */ + result SetColor(const Tizen::Graphics::Color& color); + + + /** + * Sets the style of the %Header control. + * + * @since 2.0 + * + * @return An error code + * @param[in] style The header style to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks All items and buttons will be removed if the style is changed. + */ + result SetStyle(HeaderStyle style); + + + /** + * Sets the title icon of the %Header control that has the title style. + * + * @since 2.0 + * + * @return An error code + * @param[in] pIcon The title icon to be set @n + * Set to @c null to remove the title icon. + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance does not support the execution of the specified operation @n + * The style of the %Header control is not @c HEADER_STYLE_TITLE. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTitleIcon(const Tizen::Graphics::Bitmap* pIcon); + + + /** + * Sets the title text of the %Header control. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be set + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance does not support the execution of the specified operation. @n + * The style of the %Header control is not @c HEADER_STYLE_TITLE. + * @exception E_SYSTEM A system error has occurred. + * @remarks If the text cannot be displayed in a line, then the ellipsis is applied at the end. @n + * When the title icon is set along with the title text, the title retains the left alignment. + */ + result SetTitleText(const Tizen::Base::String& text); + + + /** + * Sets the title text color. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The title text color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance does not support the execution of the specified operation. @n + * The style of the %Header control is not @c HEADER_STYLE_TITLE. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTitleTextColor(const Tizen::Graphics::Color& color); + + + /** + * Sets the description text. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be set + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance does not support the execution of the specified operation. @n + * The style of the %Header control is not @c HEADER_STYLE_TITLE. + * @exception E_SYSTEM A system error has occurred. + * @remarks If the text cannot be displayed in a line, then the ellipsis is applied at the end. @n + * When the title icon is set along with the title text, the title retains the left alignment. + */ + result SetDescriptionText(const Tizen::Base::String& text); + + + /** + * Sets the description text color. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The description text color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance does not support the execution of the specified operation. @n + * The style of the %Header control is not @c HEADER_STYLE_TITLE. + * @exception E_SYSTEM A system error has occurred. + */ + result SetDescriptionTextColor(const Tizen::Graphics::Color& color); + + + /** + * Stops the waiting animation in progress at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] animationPos The waiting animation position + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method returns @c E_INVALID_OPERATION if no waiting animation is in progress at the specified position. + * @see GetWaitingAnimationStatus() + * @see PauseWaitingAnimation() + * @see PlayWaitingAnimation() + */ + result StopWaitingAnimation(HeaderAnimationPosition animationPos); + + + /** + * Adds an IActionEventListener instance. @n + * OnActionPerformed() of the added listener is called when the user selects an item. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + */ + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + + /** + * Removes an IActionEventListener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + */ + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + + /** + * Checks whether the tab edit mode is enabled. + * + * @since 2.0 + * + * @return @c true if the tab edit mode is set, @n + * else @c false + */ + bool IsTabEditModeEnabled(void) const; + + + /** + * Enables or disables the tab edit mode. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the edit mode, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the style of the %Header control style is not @c Header_STYLE_TAB. + */ + result SetTabEditModeEnabled(bool enable); + + + /** + * Sets the back button. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * There are more than 2 header items. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. @n + * The operation is not supported when the style of the %Header control is @c HEADER_STYLE_BUTTON. @n + * This device does not support the software back button. + * @remarks When the back button is pressed, OnFormBackRequested() of IFormBackEventListener is called. @n + * If the right button is already set, then the button is replaced with the back button. + */ + result SetBackButton(void); + + + /** + * Checks whether the back button item is set. + * + * @since 2.0 + * + * @return @c true if the back button item is set, @n + * else @c false + */ + bool IsBackButtonSet(void) const; + + + /** + * Removes the back button item. + * + * @since 2.0 + * + */ + void RemoveBackButton(void); + + + /** + * Enables or disables the back button. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the back button, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The back button item is not set. + */ + result SetBackButtonEnabled(bool enable); + + + /** + * Gets the state of the back button. + * + * @since 2.0 + * + * @return The state of the back button, @n + * else @c BUTTON_ITEM_STATUS_NORMAL if an error occurs. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The back button is not set. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + ButtonItemStatus GetBackButtonStatus(void) const; + + + /** + * Gets the position and size of the specified button item. + * + * @since 2.0 + * + * @return The position and size of the button item at the specified position. + * @param[in] position The position of the button item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * There is no button set at the specified position. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Rectangle GetButtonBounds(ButtonPosition position) const; + + +protected: + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This is the default constructor for this class. + // + // @since 2.0 + // + Header(void); + + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This is the destructor for this class. + // + // @since 2.0 + // + virtual ~Header(void); + + +private: + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // Initializes this instance of %Header with the specified parameter. + // + // @since 2.0 + // @return An error code + // @exception E_SUCCESS The method is successful. + // @exception E_SYSTEM A system error has occurred. + // + result Construct(void); + + Header(const Header& rhs); + Header& operator =(const Header& rhs); + +private: + friend class _FormImpl; + friend class _HeaderImpl; + +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_HEADER_H_ diff --git a/inc/FUiCtrlHeaderItem.h b/inc/FUiCtrlHeaderItem.h new file mode 100644 index 0000000..5d2b625 --- /dev/null +++ b/inc/FUiCtrlHeaderItem.h @@ -0,0 +1,199 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlHeaderItem.h + * @brief This is the header file for the %HeaderItem class. + * + * This header file contains the declarations of the %HeaderItem class. + */ +#ifndef _FUI_CTRL_HEADER_ITEM_H_ +#define _FUI_CTRL_HEADER_ITEM_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @enum HeaderItemStatus + * + * Defines the possible statuses of a %HeaderItem control. + * + * @since 2.0 + */ +enum HeaderItemStatus +{ + HEADER_ITEM_STATUS_NORMAL, /**< The normal status */ + HEADER_ITEM_STATUS_PRESSED, /**< The pressed status */ + HEADER_ITEM_STATUS_SELECTED, /**< The selected status */ + HEADER_ITEM_STATUS_HIGHLIGHTED, /**< The highlighted status */ + HEADER_ITEM_STATUS_DISABLED /**< The disabled status */ +}; + +/** + * @class HeaderItem + * @brief This class is an implementation of a %HeaderItem control. + * + * @since 2.0 + * + * The %HeaderItem class is a helper class that specifies the properties of the Header item. + * + * For more information on the class features, see Header. + */ +class _OSP_EXPORT_ HeaderItem + : public Tizen::Base::Object +{ +public: + + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + HeaderItem(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~HeaderItem(void); + + + /** + * Initializes this instance of %HeaderItem with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] actionId The action ID of this item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The action ID of the specified item must be a positive integer. + */ + result Construct(int actionId); + + + /** + * Gets the action ID of the %HeaderItem control. + * + * @since 2.0 + * + * @return The action ID, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetActionId(void) const; + + + /** + * Gets the text of the %HeaderItem control. + * + * @since 2.0 + * + * @return The item text, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::String GetText(void) const; + + + /** + * Sets the action ID of the %HeaderItem control. + * + * @since 2.0 + * + * @return An error code + * @param[in] actionId The specified action ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The action ID of the specified item must be a positive integer. + */ + result SetActionId(int actionId); + + + /** + * Sets the background bitmap of the %HeaderItem control. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The item status + * @param[in] pBitmap The background bitmap to set, @n + * else @c null if no bitmap is to be displayed + * @exception E_SUCCESS The method is successful. + * @remarks If the size of the bitmap is greater than the size of the item, the bitmap is scaled down. + */ + result SetBackgroundBitmap(HeaderItemStatus status, const Tizen::Graphics::Bitmap* pBitmap); + + + /** + * Sets the icon of the header item. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The status of the header item + * @param[in] pIcon The icon to be set, @n + * else @c null if no icon is to be set + * @exception E_SUCCESS The method is successful. + * @remarks If the size of the bitmap is greater than the default size, the bitmap is scaled down. @n + * The bitmap specified for the @c HEADER_ITEM_STATUS_NORMAL will be applied for all other statuses unless different bitmaps are explicitly + * set for those by using this method. @n + * Note that the specified bitmaps are ignored if the style of the Header control is not @c HEADER_STYLE_TITLE_BUTTON. @n + * Furthermore, the title button does not support @c HEADER_ITEM_STATUS_SELECTED status and the bitmap for the status is also ignored. + */ + result SetIcon(HeaderItemStatus status, const Tizen::Graphics::Bitmap* pIcon); + + + /** + * Sets the text of the %HeaderItem control. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be set + * @exception E_SUCCESS The method is successful. + * @remarks If the text cannot be displayed in a line, then the text is automatically displayed in two lines and the ellipsis is applied if the text + * is longer than two lines. @n + * Use @htmlonly '\n' @endhtmlonly to denote the end of the line. + */ + result SetText(const Tizen::Base::String& text); + + +private: + HeaderItem(const HeaderItem& headerItem); + HeaderItem& operator =(const HeaderItem& headerItem); + + +private: + friend class _HeaderImpl; + friend class _HeaderItemImpl; + + class _HeaderItemImpl * __pImpl; + +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_HEADER_ITEM_H_ diff --git a/inc/FUiCtrlICustomElement.h b/inc/FUiCtrlICustomElement.h new file mode 100644 index 0000000..acab342 --- /dev/null +++ b/inc/FUiCtrlICustomElement.h @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + + +/** + * @file FUiCtrlICustomElement.h + * @brief This is the header file for the %ICustomElement class. + * + * This header file contains the declarations of %ICustomElement and its helper classes. + */ + +#ifndef _FUI_CTRL_ICUSTOM_ELEMENT_H_ +#define _FUI_CTRL_ICUSTOM_ELEMENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @interface ICustomElement + * @brief This interface represents the common behaviors of a custom element. + * + * @since 2.0 + * + * The %ICustomElement interface is the listener interface for custom drawing in a list item. + * The class that processes a custom drawing event implements this interface. The list items are added by calling the + * AddElement(int elementId, const %ICustomElement &element) method. When the custom drawing event occurs and the list item must be + * redrawn, the OnDraw() method is invoked. + * + * For more information on the class features, see ListViews. + * + */ +class _OSP_EXPORT_ ICustomElement +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ICustomElement(void) {} + +// Operation +public: + /** + * Called when a custom element of the item is drawn. + * + * @since 2.0 + * + * @return @c true if the drawing is successful, @n + * else @c false + * @param[in] canvas The graphic canvas of the list control + * @param[in] rect The position and size of the element + * @param[in] status The status of the element + * @remarks This method must return @c true if the drawing is successful, else @c false. + */ + virtual bool OnDraw(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& rect, Tizen::Ui::Controls::ListItemDrawingStatus status) = 0; + +protected: + // + // The following methods are reserved and may change its name at any time without prior notice. + // + virtual void ICustomElement_Reserved1(void) {} + virtual void ICustomElement_Reserved2(void) {} + virtual void ICustomElement_Reserved3(void) {} +}; // ICustomElement + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ICUSTOM_ELEMENT_H_ + diff --git a/inc/FUiCtrlICustomListElement.h b/inc/FUiCtrlICustomListElement.h new file mode 100644 index 0000000..71e2fe5 --- /dev/null +++ b/inc/FUiCtrlICustomListElement.h @@ -0,0 +1,106 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlICustomListElement.h + * @brief This is the header file for the %ICustomListElement interface. + * + * This header files contains the declarations of %ICustomListElement interface. + * + */ + +#ifndef _FUI_CTRL_ICUSTOM_LIST_ELEMENT_H_ +#define _FUI_CTRL_ICUSTOM_LIST_ELEMENT_H_ + +//includes +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if OSPDEPREC + * @enum CustomListItemStatus + * + * Defines the value of status of the CustomList item. + * + * @brief [Deprecated] + * @deprecated This enumeration is deprecated. Instead of using this enumeration, use the ListItemStatus enumeration. + * @since 2.0 + * @endif + */ +enum CustomListItemStatus +{ + CUSTOM_LIST_ITEM_STATUS_NORMAL = 0, /**< @if OSPDEPREC The status of the item is normal @endif */ + CUSTOM_LIST_ITEM_STATUS_SELECTED, /**< @if OSPDEPREC The status of the item is selected @endif */ + CUSTOM_LIST_ITEM_STATUS_FOCUSED /**< @if OSPDEPREC The status of the item is focused @endif */ +}; + +/** + * @if OSPDEPREC + * @interface ICustomListElement + * @brief [Deprecated] This interface represents the common behaviors for a CustomList element. + * + * @deprecated This class is deprecated. Instead of using this class, use the ICustomElement class. + * @since 2.0 + * + * + * The %ICustomListElement interface provides interfaces used for custom drawing + * in a custom list item. + * + * If an application wants to draw its own contents in a custom list item, it must + * implement %ICustomListElement and add elements by calling SetElement(int elementId, + * const %ICustomListElement &element). When the custom list item needs to be redrawn, + * DrawElement() is called by the framework. + * @endif + */ +class _OSP_EXPORT_ ICustomListElement + : public Tizen::Base::Object +{ +public: + /** + * @if OSPDEPREC + * This is the destructor for this class. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ICustomElement class. + * @since 2.0 + * @endif + */ + virtual ~ICustomListElement(void) {} + +// Operation +public: + /** + * @if OSPDEPREC + * Draws a custom element of the item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ICustomElement class. + * @since 2.0 + * + * @return An error code + * @param[in] canvas The graphic canvas of the list control + * @param[in] rect The location and size of the CustomList element + * @param[in] itemStatus The status of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + virtual result DrawElement(const Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& rect, CustomListItemStatus itemStatus) = 0; +}; //ICustomListElement +}}} //Tizen::Ui::Controls +#endif // _FUI_CTRL_ICUSTOM_LIST_ELEMENT_H_ diff --git a/inc/FUiCtrlIExpandableEditAreaEventListener.h b/inc/FUiCtrlIExpandableEditAreaEventListener.h new file mode 100644 index 0000000..4825280 --- /dev/null +++ b/inc/FUiCtrlIExpandableEditAreaEventListener.h @@ -0,0 +1,121 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlIExpandableEditAreaEventListener.h + * @brief This is the header file for the %IExpandableEditAreaEventListener interface. + * + * This header file contains the declarations of the %IExpandableEditAreaEventListener interface. + */ +#ifndef _FUI_CTRL_IEXPANDABLE_EDIT_AREA_EVENT_LISTENER_H_ +#define _FUI_CTRL_IEXPANDABLE_EDIT_AREA_EVENT_LISTENER_H_ + +// includes +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } // Tizen::Ui + +// namespace declaration +namespace Tizen { namespace Ui { namespace Controls +{ + /** + * @interface IExpandableEditAreaEventListener + * @brief This interface defines a listener for the %ExpandableEditArea events. + * + * @since 2.0 + * + * The %IExpandableEditAreaEventListener interface is the listener interface for receiving %ExpandableEditArea events. @n + * + * For more information on the class features, see ExpandableEditArea. + * + */ +class _OSP_EXPORT_ IExpandableEditAreaEventListener + : public Tizen::Base::Runtime::IEventListener +{ + +// Lifecycle +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IExpandableEditAreaEventListener(void) {} + + +// Operations +public: + /** + * Called when a new line is added to ExpandableEditArea. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] newLineCount The new line count + */ + virtual void OnExpandableEditAreaLineAdded(Tizen::Ui::Controls::ExpandableEditArea& source, int newLineCount) = 0; + + /** + * Called when a line is removed from ExpandableEditArea. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] newLineCount The new line count + */ + virtual void OnExpandableEditAreaLineRemoved(Tizen::Ui::Controls::ExpandableEditArea& source, int newLineCount) = 0; + + +// Reserves +protected: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IExpandableEditAreaEventListener_Reserved1(void) { } + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IExpandableEditAreaEventListener_Reserved2(void) { } + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IExpandableEditAreaEventListener_Reserved3(void) { } +}; // IExpandableEditAreaEventListener + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_IEXPANDABLE_EDIT_AREA_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlIFastScrollListener.h b/inc/FUiCtrlIFastScrollListener.h new file mode 100644 index 0000000..0890518 --- /dev/null +++ b/inc/FUiCtrlIFastScrollListener.h @@ -0,0 +1,131 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlIFastScrollListener.h + * @brief This is the header file for the %IFastScrollListener interface. + * + * This header file contains the declarations of the %IFastScrollListener interface. @n + * If item event is generated, a method of this class will be called. @n + * Applications that perform tasks related to the item event call methods of this class. + * + */ +#ifndef _FUI_CTRL_IFAST_SCROLL_LISTENER_H_ +#define _FUI_CTRL_IFAST_SCROLL_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen { namespace Ui { namespace Controls +{ + +// constants +/** + * @if OSPDEPREC + * The string constant representing the index of the magnifying icon in a fast scroll. + * + * @brief [Deprecated] + * @deprecated This object is provided only for backward compatibility and will be deleted in a future release. + * Instead of using this object, it is recommended to use FAST_SCROLL_SEARCH_ICON_INDEX_STRING. + * @since 2.0 + * @endif + */ +_OSP_EXPORT_ extern const Tizen::Base::String FAST_SCROLL_SEARCH_ICON_INDEX; + +// constants +/** + * The string constant representing the index of the magnifying icon in a fast scroll. + * + * @since 2.0 + */ +_OSP_EXPORT_ extern const wchar_t* const FAST_SCROLL_SEARCH_ICON_INDEX_STRING; + +/** + * @interface IFastScrollListener + * @brief This interface implements the listener for the fast scroll event. + * + * @since 2.0 + * + * The %IFastScrollListener interface is the listener interface for receiving fast scroll events. + * The class that processes a fast scroll event implements this interface, and the instance created with that class is registered + * with a UI control, using the control's AddFastScrollListener() method. When the fast scroll event occurs, the + * OnFastScrollIndexChanged() method of that instance is invoked. + * + * For more information on the class features, see ListViews. + * + */ +class _OSP_EXPORT_ IFastScrollListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IFastScrollListener(void) {} + + /** + * Called when an index is selected. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] index The index + * @remarks When the search icon index is enabled, you can check whether the search icon index is touched by comparing @c index with the string + * constant FAST_SCROLL_SEARCH_ICON_INDEX. + * + */ + virtual void OnFastScrollIndexSelected(Tizen::Ui::Control& source, Tizen::Base::String& index) = 0; + +protected: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IFastScrollListener_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // + virtual void IFastScrollListener_Reserved2(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IFastScrollListener_Reserved3(void) {} +}; // IFastScrollListener + +}; +}; +}; + +#endif diff --git a/inc/FUiCtrlIFormBackEventListener.h b/inc/FUiCtrlIFormBackEventListener.h new file mode 100644 index 0000000..1946b74 --- /dev/null +++ b/inc/FUiCtrlIFormBackEventListener.h @@ -0,0 +1,108 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlIFormBackEventListener.h + * @brief This is the header file for the %IFormBackEventListener interface. + * + * This header file contains the declarations of the %IFormBackEventListener interface. + */ +#ifndef _FUI_CTRL_IFORM_BACK_EVENT_LISTENER_H_ +#define _FUI_CTRL_IFORM_BACK_EVENT_LISTENER_H_ + +// includes +#include + +// namespace declaration +namespace Tizen { namespace Ui { namespace Controls +{ + +class Form; + +/** + * @interface IFormBackEventListener + * @brief This interface implements the listener for Form related events. + * + * @since 2.0 + * + * The %IFormBackEventListener interface is the listener interface for receiving Form-related back button events. + * + * For more information on the class features, see Form. + */ +class IFormBackEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IFormBackEventListener(void) {} + +// Operation +public: + /** + * Called when the current %Form control needs to be closed to revert back to the previous %Form control. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @remarks This event is fired when the user clicks on the software 'back' button on the Footer control, or the hardware back button on the + * device. + */ + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source) = 0; + +// Reserves +protected: + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IFormBackEventListener_Reserved1(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IFormBackEventListener_Reserved2(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IFormBackEventListener_Reserved3(void) { } +}; // IFormBackEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_IFORM_BACK_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlIFrameEventListener.h b/inc/FUiCtrlIFrameEventListener.h new file mode 100644 index 0000000..7ab468a --- /dev/null +++ b/inc/FUiCtrlIFrameEventListener.h @@ -0,0 +1,153 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlIFrameEventListener.h + * @brief This is the header file for the %IFrameEventListener interface. + * + * This header file contains the declarations of the %IFrameEventListener interface. @n + * If a frame lifecycle event is generated, a method of this class is called. @n + * So, if an application needs to perform tasks related to the frame event, provide the implementation of the methods declared in this interface. + */ + +#ifndef _FUI_CTRL_IFRAME_EVENT_LISTENER_H_ +#define _FUI_CTRL_IFRAME_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class Frame; + +/** + * @interface IFrameEventListener + * @brief This interface implements the listener for the frame lifecycle event. + * + * @since 2.0 + * + * The %IFrameEventListener interface is the listener interface for receiving %Frame lifecycle events. + * + * For more information on the class features, see Frame. + * + */ +class _OSP_EXPORT_ IFrameEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + virtual ~IFrameEventListener(void) {} + +// Operations +public: + /** + * Called when a Frame instance is about to be destroyed. @n + * This method is called just before the system destroys the %Frame instance of an application during the application termination sequence. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @remarks This method releases any resources that need to be deallocated before the destruction of the Frame instance. + */ + virtual void OnFrameTerminating(const Tizen::Ui::Controls::Frame& source) = 0; + + /** + * Called when a Frame instance is about to be activated. @n + * This method is called just after the system activates the %Frame instance of an application. + * + * @since 2.0 + * + * @param[in] source The source of the event + */ + virtual void OnFrameActivated(const Tizen::Ui::Controls::Frame& source) { } + + /** + * Called when a Frame instance is about to be deactivated. @n + * This method is called just after the system deactivates the %Frame instance of an application. + * + * @since 2.0 + * + * @param[in] source The source of the event + */ + virtual void OnFrameDeactivated(const Tizen::Ui::Controls::Frame& source) { } + + + // Reserves +protected: + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IFrameEventListener_Reserved1(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IFrameEventListener_Reserved2(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IFrameEventListener_Reserved3(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IFrameEventListener_Reserved4(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IFrameEventListener_Reserved5(void) { } + +}; // IFrameEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_IFRAME_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlIGalleryEventListener.h b/inc/FUiCtrlIGalleryEventListener.h new file mode 100644 index 0000000..cee45e9 --- /dev/null +++ b/inc/FUiCtrlIGalleryEventListener.h @@ -0,0 +1,123 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlIGalleryEventListener.h + * @brief This is the header file for the %IGalleryEventListener interface. + * + * This header file contains the declarations of the %IGalleryEventListener interface. @n + * If an event is generated, a method of this interface is called. @n + * Therefore, when an application performs jobs related to the event, the methods of this interface are executed. + * + */ +#ifndef _FUI_CTRL_IGALLERY_EVENT_LISTENER_H_ +#define _FUI_CTRL_IGALLERY_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class Gallery; +}}} + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @interface IGalleryEventListener + * @brief This interface defines the listener for the events generated by the Gallery control. + * + * @since 2.0 + * + * The %IGalleryEventListener interface is the listener interface for receiving Gallery events. + * The class that processes a gallery event implements this interface, and the instance created using the Gallery's + * AddGalleryEventListener() method. When the gallery event occurs, a method of that instance is invoked. + * + * For more information on the class features, see Gallery. + */ +class _OSP_EXPORT_ IGalleryEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IGalleryEventListener(void) {} + + /** + * Called when the current item changes. + * + * @since 2.0 + * + * @param[in] gallery The source of the event + * @param[in] currentItemIndex The current item index + */ + virtual void OnGalleryCurrentItemChanged(Tizen::Ui::Controls::Gallery& gallery, int currentItemIndex) = 0; + + /** + * Called when the item is clicked. + * + * @since 2.0 + * + * @param[in] gallery The source of the event + * @param[in] itemIndex The index of the item + */ + virtual void OnGalleryItemClicked(Tizen::Ui::Controls::Gallery& gallery, int itemIndex) = 0; + + /** + * Called when the slide-show starts. + * + * @since 2.0 + * + * @param[in] gallery The source of the event + */ + virtual void OnGallerySlideShowStarted(Tizen::Ui::Controls::Gallery& gallery) = 0; + + /** + * Called when the slide-show stops. + * + * @since 2.0 + * + * @param[in] gallery The source of the event + */ + virtual void OnGallerySlideShowStopped(Tizen::Ui::Controls::Gallery& gallery) = 0; + + +protected: + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + virtual void GalleryEventListener_Reserved1(void) {} + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + virtual void GalleryEventListener_Reserved2(void) {} + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + virtual void GalleryEventListener_Reserved3(void) {} +}; // IGalleryEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_IGALLERY_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlIGalleryItemProvider.h b/inc/FUiCtrlIGalleryItemProvider.h new file mode 100644 index 0000000..e5d86d6 --- /dev/null +++ b/inc/FUiCtrlIGalleryItemProvider.h @@ -0,0 +1,117 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlIGalleryItemProvider.h + * @brief This is the header file for the %IGalleryItemProvider interface. + * + * This header file contains the declarations of the %IGalleryItemProvider interface. @n + * If an event is generated, a method of this interface is called. @n + * Therefore, if applications perform jobs related to the list events, use the methods of this interface. + * + */ +#ifndef _FUI_CTRL_IGALLERY_ITEM_PROVIDER_H_ +#define _FUI_CTRL_IGALLERY_ITEM_PROVIDER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @interface IGalleryItemProvider + * @brief This interface implements the provider for events on Gallery. + * + * @since 2.0 + * + * The %IGalleryItemProvider interface is the interface for handling Gallery items. The class that handles gallery items implements this + * interface, and the instance created using the Gallery's SetItemProvider() method. + * + * For more information on the class features, see Gallery. + */ +class _OSP_EXPORT_ IGalleryItemProvider +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IGalleryItemProvider(void) {} + + /** + * Gets the total number of items. + * + * @since 2.0 + * + * @return The total number of the Gallery control items + * @remarks An application that uses the Gallery control must implement this method. + */ + virtual int GetItemCount(void) = 0; + + /** + * Gets the item at the specified index from the item provider. + * + * @since 2.0 + * + * @return An item of the Gallery control + * @param[in] index The index of the item + * @see DeleteItem() + * @remarks An application that uses the Gallery control must implement this method. This method is expected to return an item that is allocated on a + * heap memory. The returned item can be of type GalleryItem. Note that when the item is not required, the Gallery control calls the + * IGalleryItemProvider::DeleteItem() method. + */ + virtual Tizen::Ui::Controls::GalleryItem* CreateItem(int index) = 0; + + /** + * Deletes the specified item. + * + * @since 2.0 + * + * @return @c true if the item is deallocated by this method, @n + * else @c false + * @param[in] index The index of the item + * @param[in] pItem The pointer to GalleryItem that is to be deleted + * @see CreateItem() + * @remarks An application that uses the Gallery control must implement this method. Using this method, an application can deallocate the item. If an + * application deallocates the item, this method returns @c true. This notifies the Gallery control to not release the item. + * Otherwise, the item is deallocated by the Gallery control. + */ + virtual bool DeleteItem(int index, Tizen::Ui::Controls::GalleryItem* pItem) = 0; + +protected: + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + virtual void GalleryItemProvider_Reserved1(void) {} + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + virtual void GalleryItemProvider_Reserved2(void) {} + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + virtual void GalleryItemProvider_Reserved3(void) {} +}; // IGalleryItemProvider + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_IGALLERY_ITEM_PROVIDER_H_ diff --git a/inc/FUiCtrlIGroupedListViewItemEventListener.h b/inc/FUiCtrlIGroupedListViewItemEventListener.h new file mode 100644 index 0000000..fc71a4f --- /dev/null +++ b/inc/FUiCtrlIGroupedListViewItemEventListener.h @@ -0,0 +1,156 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIGroupedListViewItemEventListener.h + * @brief This is the header file for the %IGroupedListViewItemEventListener interface. + * + * This header file contains the declarations of the %IGroupedListViewItemEventListener interface. + */ + +#ifndef _FUI_CTRL_IGROUPED_LIST_VIEW_ITEM_EVENT_LISTENER_H_ +#define _FUI_CTRL_IGROUPED_LIST_VIEW_ITEM_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class GroupedListView; + +/** + * @interface IGroupedListViewItemEventListener + * @brief This interface implements the listener for the events generated by the items of the GroupedListView control. + * + * @since 2.0 + * + * The %IGroupedListViewItemEventListener interface is the listener interface for receiving GroupedListView item events. + * The class that processes a list item event implements this interface, and the instance created with that class is registered + * with a UI control, using the control's AddGroupedListViewItemEventListener() method. When the list item event occurs, a + * method of that instance is invoked. + * + * For more information on the class features, see ListViews. + */ +class _OSP_EXPORT_ IGroupedListViewItemEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called + * when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IGroupedListViewItemEventListener(void) {}; + + /** + * Called when the state of an element of a GroupedListView item is changed. + * + * @since 2.0 + * + * @param[in] listView The source of the event + * @param[in] groupIndex The index of the group item + * @param[in] itemIndex The index of the item in the group + * @param[in] elementId The element ID + * @param[in] status The status of the element + * + * @remarks This method is called when an element of the %CustomItem control in the %GroupedListView control is checked, unchecked, or selected. @n + * If the method is called to notify the state change of an item's annex or the item itself, the specified elementId is set to @c -1. + */ + virtual void OnGroupedListViewItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListItemStatus status) = 0; + + /** + * Called when ListItem is swept. + * + * @since 2.0 + * @param[in] listView The source of the event + * @param[in] groupIndex The index of the group item + * @param[in] itemIndex The index of the item in the group + * @param[in] direction The sweep direction + */ + virtual void OnGroupedListViewItemSwept(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, Tizen::Ui::Controls::SweepDirection direction) = 0; + + /** + * Called when the state of an element in the ListContextItem control is changed. + * + * @since 2.0 + * + * @param[in] listView The source of the event + * @param[in] groupIndex The index of the group item + * @param[in] itemIndex The index of the item in the group + * @param[in] elementId The element ID + * @param[in] status The status of the element + */ + virtual void OnGroupedListViewContextItemStateChanged(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListContextItemStatus status) = 0; + + /** + * Called when the item or the element is long pressed. + * + * @since 2.0 + * + * @param[in] listView The source of the event + * @param[in] groupIndex The index of the group + * @param[in] itemIndex The index of the item in the group + * @param[in] elementId The element ID + * @param[in,out] invokeListViewItemCallback Indicates whether to invoke %GroupedListView item callback after this method returns + * @remarks This method is invoked when an item or an element is long pressed. @n + * When the event comes from the annex or the whole item, @c elementId is always -1. @n + * Setting @c invokeListViewItemCallback to @c true invokes GroupedListView item callbacks after this method returns. @n + * Set @c invokeListViewItemCallback to @c false to not invoke %GroupedListView item callbacks. The default value of + * @c invokeListViewItemCallback is @c true. @n + * Note that other %GroupedListView item callbacks are not called even though @c invokeListViewItemCallback is @c true, if + * %GroupedListView loses focus, for example, due to invoking a Popup or a ContextMenu in this method. + */ + virtual void OnGroupedListViewItemLongPressed(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex, int itemIndex, int elementId, bool& invokeListViewItemCallback); + + /** + * Called when GroupItem is selected. + * + * @since 2.0 + * + * @param[in] listView The source of the event + * @param[in] groupIndex The index of the group item + */ + virtual void OnGroupedListViewGroupItemSelected(Tizen::Ui::Controls::GroupedListView& listView, int groupIndex); + + /** + * Called when the item is reordered. + * + * @since 2.0 + * + * @param[in] listView The source of the event + * @param[in] groupIndexFrom The source group index of the item + * @param[in] itemIndexFrom The source item index of the item + * @param[in] groupIndexTo The target group index of the item + * @param[in] itemIndexTo The target item index of the item + */ + virtual void OnGroupedListViewItemReordered(Tizen::Ui::Controls::GroupedListView& listView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo); + +protected: + // + // Following methods are reserved and may change its name at any time without prior notice. + // + virtual void IGroupedListViewItemEventListener_Reserved1(void) {} + virtual void IGroupedListViewItemEventListener_Reserved2(void) {} + virtual void IGroupedListViewItemEventListener_Reserved3(void) {} +}; // IGroupedListViewItemEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_IGROUPED_LIST_VIEW_ITEM_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlIGroupedListViewItemProvider.h b/inc/FUiCtrlIGroupedListViewItemProvider.h new file mode 100644 index 0000000..f0a5375 --- /dev/null +++ b/inc/FUiCtrlIGroupedListViewItemProvider.h @@ -0,0 +1,176 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + + +/** + * @file FUiCtrlIGroupedListViewItemProvider.h + * @brief This is the header file for the %IGroupedListViewItemProvider interface. + * + * This header file contains the declarations of the %IGroupedListViewItemProvider interface. @n + * If an event is generated, a method of this class is called. @n + * Therefore, if an application performs jobs related to the item events, it uses the methods of this class. + * + */ +#ifndef _FUI_CTRL_IGROUPED_LIST_VIEW_ITEM_PROVIDER_H_ +#define _FUI_CTRL_IGROUPED_LIST_VIEW_ITEM_PROVIDER_H_ + +#include +#include + +namespace Tizen {namespace Ui { namespace Controls +{ + +/** + * @interface IGroupedListViewItemProvider + * @brief This interface implements the provider for the events generated by the GroupedListView control. + * + * @since 2.0 + * + * The %IGroupedListViewItemProvider interface is the interface for handling GroupedListView items. + * The class that handles list items implements this interface, and the instance created using the GroupedListView's Construct() + * method. + * + * For more information on the class features, see ListViews. + */ +class _OSP_EXPORT_ IGroupedListViewItemProvider +{ +// Operation +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called + * when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IGroupedListViewItemProvider(void) {} + + /** + * Gets the total number of groups. + * + * @since 2.0 + * + * @return The total number of groups + * @remarks This method must be implemented so that it returns the total number of groups in the GroupedListView control. + */ + virtual int GetGroupCount(void) = 0; + + /** + * Gets the total number of items in the specified group. + * + * @since 2.0 + * + * @return The total number of items in the specified group + * @param[in] groupIndex The index of the group + * @remarks This method must be implemented so that it returns the total number of items for the specified group in the GroupedListView control. + */ + virtual int GetItemCount(int groupIndex) = 0; + + /** + * Creates the group item for the specified index from the item provider. + * + * @since 2.0 + * + * @return A group item of the GroupedListView control + * @param[in] groupIndex The index of the group + * @param[in] itemWidth The width of the item + * @remarks An application that uses the GroupedListView control must implement this method. This method is expected to return a group item that is + * allocated on a heap memory. @n + * Note that when the item is not required, the GroupedListView control calls %IGroupedListViewItemProvider::DeleteGroupItem() and the + * application deallocates the item. + */ + virtual Tizen::Ui::Controls::GroupItem* CreateGroupItem(int groupIndex, int itemWidth) = 0; + + /** + * Deletes the specified group item. + * + * @since 2.0 + * + * @return @c true if the item is deallocated by this method, @n + * else @c false + * @param[in] groupIndex The index of the group + * @param[in] pItem The pointer to GroupItem that is to be deleted + * @param[in] itemWidth The width of the item + * @remarks An application that uses the %GroupedListView control must implement this method. @n + * Using this method, an application can deallocate the item. @n + * If an application deallocates the item, this method must return true. This notifies the GroupedListView control not to release the + * item. Otherwise, the item is deallocated by the GroupedListView control. + * @see CreateItem() + */ + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::GroupItem* pItem, int itemWidth) = 0; + + /** + * Creates the specified item. + * + * @since 2.0 + * + * @return An item of the list + * @param[in] groupIndex The index of the group + * @param[in] itemIndex The index of the item + * @param[in] itemWidth The width of the item + * @remarks An application that uses the GroupedListView control must implement this method. @n + * This method is expected to return an item that is allocated on a heap memory. @n + * The returned item can be a simple or custom item. @n + * Note that when the item is not required, the GroupedListView control calls %IGroupedListViewItemProvider::DeleteItem() and the application + * deallocates the item. + * @see DeleteItem() + */ + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int groupIndex, int itemIndex, int itemWidth) = 0; + + /** + * Deletes the specified item. + * + * @since 2.0 + * + * @return @c true if the item is deallocated by this method, @n + * else @c false + * @param[in] groupIndex The index of the group + * @param[in] itemIndex The index of the item + * @param[in] pItem The pointer to ListItemBase that is to be deleted + * @param[in] itemWidth The width of the item + * @remarks An application that uses the GroupedListView control must implement this method. @n + * Using this method, an application can deallocate the item. @n + * If the application deallocates the item, this method must return true. This notifies the %GroupedListView control not to release the + * item. Otherwise, the item is deallocated by the %GroupedListView control. + * @see CreateItem() + */ + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) = 0; + + + /** + * Checks whether the item can be reordered. + * + * @since 2.0 + * + * @return @c true if the item can be reordered, else @c false + * @param[in] groupIndexFrom The source group index of the item + * @param[in] groupIndexTo The target group index of the item + */ + virtual bool IsReorderable(int groupIndexFrom, int groupIndexTo); + +protected: + // + // Following methods are reserved and may change its name at any time without prior notice. + // + virtual void IGroupedListViewItemProvider_Reserved1(void) {} + virtual void IGroupedListViewItemProvider_Reserved2(void) {} + virtual void IGroupedListViewItemProvider_Reserved3(void) {} +}; // IGroupedListViewItemProvider + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_IGROUPED_LIST_VIEW_ITEM_PROVIDER_H_ diff --git a/inc/FUiCtrlIGroupedTableViewItemEventListener.h b/inc/FUiCtrlIGroupedTableViewItemEventListener.h new file mode 100644 index 0000000..f91fbf2 --- /dev/null +++ b/inc/FUiCtrlIGroupedTableViewItemEventListener.h @@ -0,0 +1,137 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlIGroupedTableViewItemEventListener.h + * @brief This is the header file for the %IGroupedTableViewItemEventListener interface. + * + * This header file contains the declarations of the %IGroupedTableViewItemEventListener interface. @n + * If an item event is generated, a method of this interface is called. + * So, if an application does some jobs related to the item event, use the methods of this interface. + * + */ +#ifndef _FUI_CTRL_IGROUPED_TABLE_VIEW_ITEM_EVENT_LISTENER_H_ +#define _FUI_CTRL_IGROUPED_TABLE_VIEW_ITEM_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class GroupedTableView; +class TableViewItem; +class TableViewGroupItem; +class TableViewContextItem; + + +/** + * @interface IGroupedTableViewItemEventListener + * @brief This interface implements the listener for item event. + * + * @since 2.0 + * + * The %IGroupedTableViewItemEventListener interface implements a listener for receiving item change events. + * The class that is interested in processing an item event implements this interface, + * and the instance created with that class is registered with a UI control, using the control's + * AddGroupedTableViewItemEventListener() method. When the item event occurs, the OnItemStateChanged() method of that object is invoked. + */ +class _OSP_EXPORT_ IGroupedTableViewItemEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + + virtual ~IGroupedTableViewItemEventListener(void) {} + + /** + * Called when the state of a TableViewGroupItem is changed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] groupIndex The group index + * @param[in] pItem The target item + * @param[in] status The status of the item + * @remarks This method is called when the TableViewGroupItem in the GroupedTableView is checked, unchecked, or selected. + */ + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) = 0; + + /** + * Called when the state of a TableViewItem in the GroupedTableView is changed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] pItem The target item + * @param[in] status The status of the item + * @remarks This method is called when the TableViewItem in the GroupedTableView is checked, unchecked, or selected. + */ + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) = 0; + + /** + * Called when the TableViewContextItem is opened or closed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] pContextItem The context item which is opened or closed + * @param[in] activated @c true if a context item is opened,@n + * @c false, otherwise + */ + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void IGroupedTableViewItemEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void IGroupedTableViewItemEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void IGroupedTableViewItemEventListener_Reserved3(void) {} +}; // IGroupedTableViewItemEventListener + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_IGROUPED_TABLE_VIEW_ITEM_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlIGroupedTableViewItemProvider.h b/inc/FUiCtrlIGroupedTableViewItemProvider.h new file mode 100644 index 0000000..58e8a5d --- /dev/null +++ b/inc/FUiCtrlIGroupedTableViewItemProvider.h @@ -0,0 +1,226 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlIGroupedTableViewItemProvider.h +* @brief This is the header file for the %IGroupedTableViewItemProvider interface. +* +* This header file contains the declarations of the %IGroupedTableViewItemProvider interface. +* If the event is generated, a method of this interface is called. +* So, if applications do jobs related to item events, use the methods of this interface. +* +*/ +#ifndef _FUI_CTRL_IGROUPED_TABLE_VIEW_ITEM_PROVIDER_H_ +#define _FUI_CTRL_IGROUPED_TABLE_VIEW_ITEM_PROVIDER_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ +class TableViewItem; +class TableViewGroupItem; + +/** + * @interface IGroupedTableViewItemProvider + * @brief This interface implements the listener for events on GroupedTableView. + * + * @since 2.0 + * + * The %IGroupedTableViewItemProvider interface implements an item provider which generates items for GroupedTableView. %GroupedTableView calls the item provider + * to request an item which is about to be displayed on a screen. Applications which use %GroupedTableView must implement the item provider. + * The class is registered with a %GroupedTableView, using the GroupedTableView's SetGroupedStyleItemProvider() method. + */ +class _OSP_EXPORT_ IGroupedTableViewItemProvider +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IGroupedTableViewItemProvider(void) {} + + /** + * Gets the total number of groups. + * + * @since 2.0 + * + * @return The total number of groups + * @remarks This method must be implemented so that it returns the total number of groups in the GroupedTableView control. + */ + virtual int GetGroupCount(void) = 0; + + /** + * Gets the total number of items in the specified group. + * + * @since 2.0 + * + * @return The total number of items in the specified group + * @param[in] groupIndex The index of the group + * @remarks This method must be implemented so that it returns the total number of items for the specified group in the GroupedTableView control. + */ + virtual int GetItemCount(int groupIndex) = 0; + + /** + * Gets the group item for the specified index from the item provider. + * + * @since 2.0 + * + * @return A group item of the GroupedTableView control + * @param[in] groupIndex The index of the group + * @param[in] itemWidth The width of the item + * @remarks An application that uses the GroupedTableView control must implement this method. This method is expected to return a group item that is + * allocated on a heap memory. + * Note that when the group item is not required, the %GroupedTableView control calls IGroupedTableViewItemProvider::DeleteGroupItem() and the + * application deallocates the item. + */ + virtual TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth) = 0; + + /** + * Deletes the specified group item. + * + * @since 2.0 + * + * @return @c true if the group item is deallocated by this method, + * else @c false + * @param[in] groupIndex The index of the group + * @param[in] pItem The pointer to TableViewGroupItem that is to be deleted + * @remarks An application that uses the GroupedTableView control must implement this method. + * Using this method, an application can deallocate the item. + * If an application deallocates the item, this method must return @c true. This notifies the %GroupedTableView control not to release the + * item. Otherwise, the item is deallocated by the %GroupedTableView control. + * @see CreateGroupItem() + */ + virtual bool DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) = 0; + + /** + * Updates the specified group item. + * + * @since 2.0 + * + * @param[in] groupIndex The group index + * @param[in] pItem The pointer to TableViewGroupItem that is to be updated + * @remarks An application that uses the GroupedTableView control must implement this method. + * This method is called when the modification of an group item is requested. + * The application can change @c pItem in this method, but should not keep @c pItem for later use. + */ + virtual void UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) = 0; + + /** + * Creates the specified item. + * + * @since 2.0 + * + * @return An item of the GroupedTableView + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] itemWidth The width of the item + * @remarks An application that uses the GroupedTableView control must implement this method. + * This method is expected to return an item that is allocated on a heap memory. + * The returned item can be a simple or custom item. + * Note that when the item is not required, the %GroupedTableView control calls IGroupedTableViewItemProvider::DeleteItem() and the application + * deallocates the item. + * @see DeleteItem() + */ + virtual TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth) = 0; + + /** + * Deletes the specified item. + * + * @since 2.0 + * + * @return @c true if the item is deallocated by this method, @n + * else @c false + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] pItem The pointer to TableViewItem that is to be deleted + * @remarks An application that uses the GroupedTableView control must implement this method. + * Using this method, an application can deallocate the item. + * If the application deallocates the item, this method must return @c true. This notifies the %GroupedTableView control not to release the + * item. Otherwise, the item is deallocated by the %GroupedTableView control. + * @see CreateItem() + */ + virtual bool DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem) = 0; + + /** + * Updates the specified item. + * + * @since 2.0 + * + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] pItem The pointer to TableViewItem that is to be updated + * @remarks An application that uses the GroupedTableView control must implement this method. + * This method is calle when the modification of an item is requested. + * The application can change @c pItem in this method, but should not keep @c pItem for later use. + */ + virtual void UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem) = 0; + + /** + * Gets the default height of an group item. + * + * @since 2.0 + * + * @return The default height of an group item + * @remarks This method must be implemented so that it returns the default height of group items in the GroupedTableView control. + */ + virtual int GetDefaultGroupItemHeight(void) = 0; + + + /** + * Gets the default height of an item. + * + * @since 2.0 + * + * @return The default height of an item + * @remarks This method must be implemented so that it returns the default height of items in the GroupedTableView control. + */ + virtual int GetDefaultItemHeight(void) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void IGroupedTableViewItemProvider_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void IGroupedTableViewItemProvider_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void IGroupedTableViewItemProvider_Reserved3(void) {} +}; // IGroupedTableViewItemProvider + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_IGROUPED_TABLE_VIEW_ITEM_PROVIDER_H_ diff --git a/inc/FUiCtrlIIconListViewItemEventListener.h b/inc/FUiCtrlIIconListViewItemEventListener.h new file mode 100644 index 0000000..b3e9be8 --- /dev/null +++ b/inc/FUiCtrlIIconListViewItemEventListener.h @@ -0,0 +1,105 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIIconListViewItemEventListener.h + * @brief This is the header file for the %IIconListViewItemEventListener interface. + * + * This header file contains the declarations of the %IIconListViewItemEventListener interface. @n + * If an item event is generated, a method of this interface is called. @n + * So, if an application does some jobs related to the item event, use the methods of this interface. + */ + +#ifndef _FUI_CTRL_IICON_LIST_VIEW_ITEM_EVENT_LISTENER_H_ +#define _FUI_CTRL_IICON_LIST_VIEW_ITEM_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class IconListView; + +/** + * @interface IIconListViewItemEventListener + * @brief This interface implements the listener for the item event. + * + * @since 2.0 + * + * The %IIconListViewItemEventListener interface is the listener interface for receiving IconListView item events. + * The class that processes a list item event implements this interface, and the instance created with that class is registered + * with a UI control, using the control's AddIIconListViewItemEventListener() method. When the list item event occurs, the + * OnIconListViewItemStateChanged() method of that instance is invoked. + * + * For more information on the class features, see ListViews. + */ +class _OSP_EXPORT_ IIconListViewItemEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IIconListViewItemEventListener(void) {} + + /** + * Called when an item event occurs. + * + * @since 2.0 + * + * @param[in] iconListView The source of the event + * @param[in] index The index of the item + * @param[in] status The item status + */ + virtual void OnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView& iconListView, int index, Tizen::Ui::Controls::IconListViewItemStatus status) = 0; + + /** + * Called when the overlay bitmap is selected. + * + * @since 2.0 + * + * @param[in] iconListView The source of the event + * @param[in] index The index of the item + * @param[in] overlayBitmapId The overlay bitmap ID + */ + virtual void OnIconListViewOverlayBitmapSelected(Tizen::Ui::Controls::IconListView& iconListView, int index, int overlayBitmapId) {} + + /** + * Called when the item is reordered. + * + * @since 2.0 + * + * @param[in] iconListView The source of the event + * @param[in] indexFrom The start index of the item + * @param[in] indexTo The final index of the item + */ + virtual void OnIconListViewItemReordered(Tizen::Ui::Controls::IconListView& iconListView, int indexFrom, int indexTo) {} + +protected: + // Following methods are reserved and may change its name at any time without prior notice. + virtual void IconListViewItemEventListener_Reserved1(void) {} + virtual void IconListViewItemEventListener_Reserved2(void) {} + virtual void IconListViewItemEventListener_Reserved3(void) {} +}; // IIconListViewItemEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_IICON_LIST_VIEW_ITEM_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlIIconListViewItemProvider.h b/inc/FUiCtrlIIconListViewItemProvider.h new file mode 100644 index 0000000..1c7a343 --- /dev/null +++ b/inc/FUiCtrlIIconListViewItemProvider.h @@ -0,0 +1,114 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIIconListViewItemProvider.h + * @brief This is the header file for the %IIconListViewItemProvider interface. + * + * This header file contains the declarations of the %IIconListViewItemProvider interface. @n + * If the event is generated, a method of this interface is called. @n + * So, if applications performs tasks related to list events, use the methods of this interface. + */ + +#ifndef _FUI_CTRL_IICON_LIST_VIEW_ITEM_PROVIDER_H_ +#define _FUI_CTRL_IICON_LIST_VIEW_ITEM_PROVIDER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class IconListView; + +/** + * @interface IIconListViewItemProvider + * @brief This interface implements the provider for events on %IconListView. + * + * @since 2.0 + * + * The %IIconListViewItemProvider interface is the interface for handling IconListView items. + * The class that handles list items implements this interface, and the instance created using the IconListView's Construct() + * method. + * + * For more information on the class features, see ListViews. + */ +class _OSP_EXPORT_ IIconListViewItemProvider +{ +// Operation +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IIconListViewItemProvider(void) {} + + /** + * Called when the IconListView is about to be drawn and requests the listener to set the number of total items. + * + * @since 2.0 + * + * @return The item count of the IconListView + * @remarks Applications which use IconListView must implement this method. This method is expected to return the number of total items in the + * %IconListView. + */ + virtual int GetItemCount(void) = 0; + + /** + * Called when items need to be loaded. + * + * @since 2.0 + * + * @return The item of the IconListView + * @param[in] index The index of the item + * @remarks Applications which use IconListView must implement this method. This method is expected to return an item which is allocated in a heap + * memory. The returned item can be IconListViewItem. Note that when the item becomes unnecessary, the %IconListView calls + * IIconListViewItemProvider::DeleteItem() and applications is in charge of deallocating the item. + * + * @see DeleteItem() + */ + virtual Tizen::Ui::Controls::IconListViewItem* CreateItem(int index) = 0; + + /** + * Called when an item becomes no longer used by the IconListView. + * + * @since 2.0 + * + * @return @c true if the item is deallocated by this method, @n + * else @c false + * + * @param[in] index The index of the item + * @param[in] pItem The pointer to the item to be deleted + * + * @remark Applications which use IconListView must implement this method. In this method, the applications have the chance of deallocating the + * item. If the application deallocates the item, this method must return @c true, notifying the %IconListView not to free the item. + * Otherwise, the item will be deallocated by the %IconListView. + * + * @see CreateItem() + */ + virtual bool DeleteItem(int index, Tizen::Ui::Controls::IconListViewItem* pItem) = 0; + +protected: + // Following methods are reserved and may change its name at any time without prior notice. + virtual void IconListViewItemProvider_Reserved1(void) {} + virtual void IconListViewItemProvider_Reserved2(void) {} + virtual void IconListViewItemProvider_Reserved3(void) {} +}; // IIconListViewItemProvider + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_IICON_LIST_VIEW_ITEM_PROVIDER_H_ diff --git a/inc/FUiCtrlIListViewItemEventListener.h b/inc/FUiCtrlIListViewItemEventListener.h new file mode 100644 index 0000000..f155a9e --- /dev/null +++ b/inc/FUiCtrlIListViewItemEventListener.h @@ -0,0 +1,144 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIListViewItemEventListener.h + * @brief This is the header file for the %IListViewItemEventListener interface. + * + * This header file contains the declarations of the %IListViewItemEventListener interface. @n + * If an item event is generated, a method of this interface is called. @n + * So, if an application does some jobs related to the item event, use the methods of this interface. + * + */ +#ifndef _FUI_CTRL_ILIST_VIEW_ITEM_EVENT_LISTENER_H_ +#define _FUI_CTRL_ILIST_VIEW_ITEM_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class ListView; + +/** + * @interface IListViewItemEventListener + * @brief This interface implements the listener for item event. + * + * @since 2.0 + * + * The %IListViewItemEventListener interface is the listener interface for receiving ListView item events. + * The class that processes a list item event implements this interface, and the instance created with that class is registered + * with a UI control, using the control's AddListViewItemEventListener() method. When the list item event occurs, a method of that + * instance is invoked. + * + * For more information on the class features, see ListViews. + */ +class _OSP_EXPORT_ IListViewItemEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called + * when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IListViewItemEventListener(void) {} + + /** + * Called when the state of an element in the ListViewItem in the ListView or GroupedListView is changed. + * + * @since 2.0 + * + * @param[in] listView The source of the event + * @param[in] index The index of the list + * @param[in] elementId The element ID + * @param[in] status The status of the element + * + * @remarks This method is called when an element of the ListViewItem in the ListView is checked, unchecked, or selected. @n + * When the event comes from the annex or the whole item, @c elementId is always @c -1. + */ + virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) = 0; + + /** + * Called when the ListItem is swept. + * + * @since 2.0 + * + * @param[in] listView The source of the event + * @param[in] index The index of the list + * @param[in] direction The sweep direction + */ + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction) = 0; + + /** + * Called when the state of an element in the %ListContextItem is changed. + * + * @since 2.0 + * + * @param[in] listView The source of the event + * @param[in] index The index of the list + * @param[in] elementId The element ID + * @param[in] status The status of the element + */ + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus status) = 0; + + /** + * Called when the item or the element is long pressed. + * + * @since 2.0 + * + * @param[in] listView The source of the event + * @param[in] index The index of the list + * @param[in] elementId The element ID + * @param[in,out] invokeListViewItemCallback Indicates whether to invoke ListView item callback after this method returns + * @remarks This method is invoked when an item or an element is long pressed. @n + * When the event comes from the annex or the whole item, @c elementId is always @c -1. + * Setting @c invokeListViewItemCallback to @c true invokes %ListView item callbacks after this method returns. + * Set @c invokeListViewItemCallback to @c false to not invoke %ListView item callbacks. The default value of + * @c invokeListViewItemCallback is @c true. + * Note that other %ListView item callbacks are not called even though @c invokeListViewItemCallback is @c true, in case that ListView + * loses the focus, for example, due to invoking a Popup or a ContextMenu in this method. + */ + virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback); + + /** + * Called when the item is reordered. + * + * @since 2.0 + * + * @param[in] listView The source of the event + * @param[in] indexFrom The start index of the item + * @param[in] indexTo The final index of the item + */ + virtual void OnListViewItemReordered(Tizen::Ui::Controls::ListView& listView, int indexFrom, int indexTo); + +protected: + // + // Following methods are reserved and may change its name at any time without prior notice. + // + virtual void IListViewItemEventListener_Reserved1(void) {} + virtual void IListViewItemEventListener_Reserved2(void) {} + virtual void IListViewItemEventListener_Reserved3(void) {} +}; // IListViewItemEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ILIST_VIEW_ITEM_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlIListViewItemProvider.h b/inc/FUiCtrlIListViewItemProvider.h new file mode 100644 index 0000000..dc24f60 --- /dev/null +++ b/inc/FUiCtrlIListViewItemProvider.h @@ -0,0 +1,116 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIListViewItemProvider.h + * @brief This is the header file for the %IListViewItemProvider interface. + * + * This header file contains the declarations of the %IListViewItemProvider interface. @n + * If the event is generated, a method of this interface is called. @n + * So, if applications do jobs related to item events, use the methods of this interface. + * + */ +#ifndef _FUI_CTRL_ILIST_VIEW_ITEM_PROVIDER_H_ +#define _FUI_CTRL_ILIST_VIEW_ITEM_PROVIDER_H_ + +#include + +namespace Tizen {namespace Ui { namespace Controls +{ + +/** + * @interface IListViewItemProvider + * @brief This interface implements the listener for events on %ListView. + * + * @since 2.0 + * + * The %IListViewItemProvider interface is the interface for handling ListView items. + * The class that handles list items implements this interface, and the instance created using the ListView's Construct() method. + * + * For more information on the class features, see ListViews. + */ +class _OSP_EXPORT_ IListViewItemProvider +{ +// Operation +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called + * when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IListViewItemProvider(void) {} + + /** + * Called when the ListView is about to be drawn and returns the number of total items. + * + * @since 2.0 + * + * @return The count of all items of the list + * @remarks This method must be implemented so that it returns the number of total items in the list. + * + */ + virtual int GetItemCount(void) = 0; + + /** + * Called when items need to be loaded. + * + * @since 2.0 + * + * @return An item of the ListView + * @param[in] index The index of the item + * @param[in] itemWidth The width of the item + * @remarks The applications that use ListView must implement this method. @n + * This method is expected to return an item which is allocated in a heap memory. @n + * The returned item can be a SimpleItem or CustomItem. @n + * Note that when the item becomes unnecessary, the ListView calls IListViewItemProvider::DeleteItem() and the application is in charge of + * deallocating the item. + * @see DeleteItem() + */ + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth) = 0; + + /** + * Called when an item becomes no longer used by the %ListView. + * + * @since 2.0 + * + * @return @c true, if the item is deallocated by this method, @n + * else @c false + * @param[in] index The index of the item + * @param[in] pItem The pointer to the item to be deleted + * @param[in] itemWidth The width of the item + * @remarks Applications which use ListView must implement this method. @n + * In this method, the applications have the chance of deallocating the item. @n + * If the application deallocates the item, this method returns @c true, notifying the %ListView not to free the item. @n + * Otherwise, the item will be deallocated by %ListView. + * @see CreateItem() + */ + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth) = 0; + +protected: + // + // Following methods are reserved and may change its name at any time without prior notice. + // + virtual void IListViewItemProvider_Reserved1(void) {} + virtual void IListViewItemProvider_Reserved2(void) {} + virtual void IListViewItemProvider_Reserved3(void) {} +}; // IListViewItemProvider + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ILIST_VIEW_ITEM_PROVIDER_H_ diff --git a/inc/FUiCtrlIProgressPopupEventListener.h b/inc/FUiCtrlIProgressPopupEventListener.h new file mode 100644 index 0000000..6fd376e --- /dev/null +++ b/inc/FUiCtrlIProgressPopupEventListener.h @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlIProgressPopupEventListener.h + * @brief This is the header file for the %IProgressPopupEventListener interface. + * + * This header file contains the declarations of the %IProgressPopupEventListener interface. @n + * If a ProgressPopup event is generated, a method of this interface is called. @n + * So, for tasks related to the ProgressPopup event, use the methods of this interface. + * + */ +#ifndef _FUI_CTRL_IPROGRESS_POPUP_EVENT_LISTENER_H_ +#define _FUI_CTRL_IPROGRESS_POPUP_EVENT_LISTENER_H_ + +#include "FBaseRtIEventListener.h" + + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + + +namespace Tizen { namespace Ui +{ +/** + * @interface IProgressPopupEventListener + * @brief This interface implements the listener for ProgressPopup event. + * @since 2.0 + * + * The %IProgressPopupEventListener interface is the listener interface for receiving an event for closing the ProgressPopup. + * The class that processes a ProgressPopup event + * implements this interface, and the instance created with that class is registered with a UI control, using the control's + * AddProgressPopupEventListener() method. When the ProgressPopup event occurs, the OnProgressPopupCanceled() method of that instance is invoked. + * + * For more information on the class features, see in individual control topics under UI Controls. + */ +class _OSP_EXPORT_ IProgressPopupEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IProgressPopupEventListener(void) {} + + /** + * Called when a ProgressPopup event occurs. + * + * @since 2.0 + */ + virtual void OnProgressPopupCanceled(void) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following methods are reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IProgressPopupEventListener_Reserved1(void) {} + virtual void IProgressPopupEventListener_Reserved2(void) {} + virtual void IProgressPopupEventListener_Reserved3(void) {} +}; // IProgressPopupEventListener + +}} // Tizen::Ui + +#endif // _FUI_CTRL_IPROGRESS_POPUP_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlIScrollEventListener.h b/inc/FUiCtrlIScrollEventListener.h new file mode 100644 index 0000000..bcc3cd5 --- /dev/null +++ b/inc/FUiCtrlIScrollEventListener.h @@ -0,0 +1,125 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlIScrollEventListener.h + * @brief This is the header file for the %IScrollEventListener interface. + * + * This header file contains the declarations of the %IScrollEventListener interface. @n + * If a change event is generated, a method of this interface is called. @n + * The applications that perform tasks related to the change events, call the methods of this interface. + * + */ +#ifndef _FUI_CTRL_ISCROLL_EVENT_LISTENER_H_ +#define _FUI_CTRL_ISCROLL_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen {namespace Ui { namespace Controls +{ + +/** + * @interface IScrollEventListener + * @brief This interface implements a listener for ScrollPanel events. + * + * @since 2.0 + * + * The %IScrollEventListener interface is the listener interface for receiving scroll events. + * The class that processes a scroll event implements this interface, and the instance created with that class is registered with + * a UI control, using the control's AddScrollEventListener() method. When the scroll event occurs, the OnScrollEndReached() + * method of that instance is invoked. + * + * For more information on the class features, see Panels and ListViews. + */ +class _OSP_EXPORT_ IScrollEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + * + */ + virtual ~IScrollEventListener(void) {} + + /** + * Called when the scroll reaches the top, bottom, left or right end. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] type The type of scroll end event + */ + virtual void OnScrollEndReached(Tizen::Ui::Control& source, Tizen::Ui::Controls::ScrollEndEvent type) = 0; + + /** + * Called continuously when the control is being scrolled. + * + * @since 2.0 + * + *@param[in] source The control being scrolled + *@param[in] scrollPos The scrolled position + */ + virtual void OnScrollPositionChanged(Tizen::Ui::Control& source, int scrollPos) {}; + + /** + * Called when the control's scroll movement has come to a stop. + * + * @since 2.0 + * + * @param[in] source The control being scrolled + */ + virtual void OnScrollStopped(Tizen::Ui::Control& source) {}; + +protected: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ScrollEventListener_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ScrollEventListener_Reserved2(void) {} + + // + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ScrollEventListener_Reserved3(void) {} + +}; // IScrollEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ISCROLL_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlISearchBarEventListener.h b/inc/FUiCtrlISearchBarEventListener.h new file mode 100644 index 0000000..cb3f3e3 --- /dev/null +++ b/inc/FUiCtrlISearchBarEventListener.h @@ -0,0 +1,144 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlISearchBarEventListener.h + * @brief This is the header file for the %ISearchBarEventListener interface. + * + * This header file contains the declarations of the %ISearchBarEventListener interface. + */ +#ifndef _FUI_CTRL_ISEARCH_BAR_EVENT_LISTENER_H_ +#define _FUI_CTRL_ISEARCH_BAR_EVENT_LISTENER_H_ + +// Includes +#include +#include + +// Namespace declaration +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @interface ISearchBarEventListener + * @brief This interface implements the listener for the SearchBar events. + * + * @since 2.0 + * + * The %ISearchBarEventListener interface is the listener interface for receiving SearchBar events. + * The class that processes a search bar event implements this interface, and the instance created with that class is registered + * with a UI control, using the control's AddSearchBarEventListener() method. When the search bar event occurs, the + * OnSearchBarModeChanged() method of that instance is invoked. + * + * For more information on the class features, see SearchBar. + */ +class _OSP_EXPORT_ ISearchBarEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~ISearchBarEventListener(void) {} + + +// Operation +public: + /** + * Called when the mode of the SearchBar is changed. + * + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSearchModeChangedPage "here" + * @endif + * @param[in] source The source of the event + * @param[in] mode The current search bar mode. + */ + virtual void OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, SearchBarMode mode) = 0; + /** + * @page CompSearchModeChangedPage Compatibility for OnSearchBarModeChanged() + * @section CompSearchModeChangedPage IssueSection Issues + * Implementing this method in OSP compatible applications has following issue: @n + * OnSearchBarModeChanged() method modifies the visibility of the current Form's Header in OSP, + * whereas current Form's header visibility is not modified in Tizen. + * + * @section CompSearchModeChangedPage SolutionSection Resolutions + * It is recommended to use Tizen API. @n + */ + +// Reserves +protected: + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + //This method is reserved and may change its name at any time without prior notice. + // + //@since 2.0 + // + virtual void ISearchBarEventListener_Reserved1(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + //This method is reserved and may change its name at any time without prior notice. + // + //@since 2.0 + // + virtual void ISearchBarEventListener_Reserved2(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + //This method is reserved and may change its name at any time without prior notice. + // + //@since 2.0 + // + virtual void ISearchBarEventListener_Reserved3(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + //This method is reserved and may change its name at any time without prior notice. + // + //@since 2.0 + // + virtual void ISearchBarEventListener_Reserved4(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + //This method is reserved and may change its name at any time without prior notice. + // + //@since 2.0 + // + virtual void ISearchBarEventListener_Reserved5(void) { } + +}; // ISearchBarEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ISEARCH_BAR_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlISectionTableViewItemEventListener.h b/inc/FUiCtrlISectionTableViewItemEventListener.h new file mode 100644 index 0000000..46b41f7 --- /dev/null +++ b/inc/FUiCtrlISectionTableViewItemEventListener.h @@ -0,0 +1,122 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlISectionTableViewItemEventListener.h + * @brief This is the header file for the %ISectionTableViewItemEventListener interface. + * + * This header file contains the declarations of the %ISectionTableViewItemEventListener interface. @n + * If an item event is generated, a method of this interface is called. + * So, if an application does some jobs related to the item event, use the methods of this interface. + * + */ +#ifndef _FUI_CTRL_ISECTION_TABLE_VIEW_ITEM_EVENT_LISTENER_H_ +#define _FUI_CTRL_ISECTION_TABLE_VIEW_ITEM_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class SectionTableView; +class TableViewItem; +class TableViewContextItem; + + +/** + * @interface ISectionTableViewItemEventListener + * @brief This interface implements the listener for item event. + * + * @since 2.0 + * + * The %ISectionTableViewItemEventListener interface implements a listener for receiving item change events. + * The class that is interested in processing an item event implements this interface, + * and the instance created with that class is registered with a UI control, using the control's + * AddSectionTableViewItemEventListener() method. When the item event occurs, the OnItemStateChanged() method of that object is invoked. + */ +class _OSP_EXPORT_ ISectionTableViewItemEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + + virtual ~ISectionTableViewItemEventListener(void) {} + /** + * Called when the state of a TableViewItem in the SectionTableView is changed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @param[in] pItem The target item + * @param[in] status The status of the item + * @remarks This method is called when the TableViewItem in the SectionTableView is checked, unchecked, or selected. + */ + virtual void OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::SectionTableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) = 0; + + /** + * Called when the TableViewContextItem is opened or closed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @param[in] pContextItem The context item which is opened or closed + * @param[in] activated @c true if a context item is opened,@n + * @c false, otherwise + */ + virtual void OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::SectionTableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void ISectionTableViewItemEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void ISectionTableViewItemEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void ISectionTableViewItemEventListener_Reserved3(void) {} +}; // ISectionTableViewItemEventListener + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_ISECTION_TABLE_VIEW_ITEM_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlISectionTableViewItemProvider.h b/inc/FUiCtrlISectionTableViewItemProvider.h new file mode 100644 index 0000000..29067b4 --- /dev/null +++ b/inc/FUiCtrlISectionTableViewItemProvider.h @@ -0,0 +1,217 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlISectionTableViewItemProvider.h + * @brief This is the header file for the %ISectionTableViewItemProvider interface. + * + * This header file contains the declarations of the %ISectionTableViewItemProvider interface. + * If the event is generated, a method of this interface is called. + * So, if applications do jobs related to item events, use the methods of this interface. + * + */ +#ifndef _FUI_CTRL_ISECTION_TABLE_VIEW_ITEM_PROVIDER_H_ +#define _FUI_CTRL_ISECTION_TABLE_VIEW_ITEM_PROVIDER_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ +class TableViewItem; + +/** + * @interface ISectionTableViewItemProvider + * @brief This interface implements the listener for events on SectionTableView. + * + * @since 2.0 + * + * The %ISectionTableViewItemProvider interface implements an item provider which generates items for SectionTableView. %SectionTableView calls the item provider + * to request an item which is about to be displayed on a screen. Applications which use %SectionTableView must implement the item provider. + * The class is registered with a %SectionTableView, using the SectionTableView's SetSectionStyleItemProvider() method. + */ +class _OSP_EXPORT_ ISectionTableViewItemProvider +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ISectionTableViewItemProvider(void) {} + + /** + * Gets the total number of groups. + * + * @since 2.0 + * + * @return The total number of groups + * @remarks This method must be implemented so that it returns the total number of groups in the SectionTableView control. + */ + virtual int GetSectionCount(void) = 0; + + /** + * Gets the total number of items in the specified group. + * + * @since 2.0 + * + * @return The total number of items in the specified group + * @param[in] sectionIndex The index of the section + * @remarks This method must be implemented so that it returns the total number of items for the specified section in the %SectionTableView control. + */ + virtual int GetItemCount(int sectionIndex) = 0; + + /** + * Creates the specified item. + * + * @since 2.0 + * + * @return An item of the SectionTableView + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @param[in] itemWidth The width of the item + * @remarks An application that uses the SectionTableView control must implement this method. + * This method is expected to return an item that is allocated on a heap memory. + * The returned item can be a simple or custom item. + * Note that when the item is not required, the %SectionTableView control calls ISectionTableViewItemProvider::DeleteItem() and the application + * deallocates the item. + * @see DeleteItem() + */ + virtual TableViewItem* CreateItem(int sectionIndex, int itemIndex, int itemWidth) = 0; + + /** + * Deletes the specified item. + * + * @since 2.0 + * + * @return @c true if the item is deallocated by this method, @n + * else @c false + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @param[in] pItem The pointer to TableViewItem to be deleted + * @remarks An application that uses the SectionTableView control must implement this method. + * Using this method, an application can deallocate the item. + * If the application deallocates the item, this method must return true. This notifies the %SectionTableView control not to release the + * item. Otherwise, the item is deallocated by the %SectionTableView control. + * @see CreateItem() + */ + virtual bool DeleteItem(int sectionIndex, int itemIndex, TableViewItem* pItem) = 0; + + /** + * Updates the specified item. + * + * @since 2.0 + * + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @param[in] pItem The pointer to TableViewItem to be updated + * @remarks An application that uses the SectionTableView control must implement this method. + * This method is calle when the modification of an item is requested. + * The application can change @c pItem in this method, but should not keep @c pItem for later use. + */ + virtual void UpdateItem(int sectionIndex, int itemIndex, TableViewItem* pItem) = 0; + + /** + * Gets the header text of a specified section. + * + * @since 2.0 + * + * @return The section header text of specified section + * @param[in] sectionIndex The index of the group + * @remarks An application that uses the SectionTableView control must implement this method. @n + * The header text will be aligned left + */ + virtual Tizen::Base::String GetSectionHeader(int sectionIndex) = 0; + + /** + * Returns whether the group has the section header or not. + * + * @since 2.0 + * + * @return @c true, if the section has an header @n + * @c false, otherwise + * @param[in] sectionIndex The index of the section + * @remarks An application that uses the SectionTableView control must implement this method. + */ + virtual bool HasSectionHeader(int sectionIndex) = 0; + + /** + * Gets the footer text of a specified section. + * + * @since 2.0 + * + * @return The footer text of specified section + * @param[in] sectionIndex The index of the section + * @remarks An application that uses the SectionTableView control must implement this method. @n + * The footer text will be aligned right. + */ + virtual Tizen::Base::String GetSectionFooter(int sectionIndex) = 0; + + /** + * Returns whether the section has the footer or not. + * + * @since 2.0 + * + * @return @c true, if the section has the footer @n + * @c false, + * @param[in] sectionIndex The index of the section + * @remarks An application that uses the SectionTableView control must implement this method. + */ + virtual bool HasSectionFooter(int sectionIndex) = 0; + + /** + * Gets the default height of an item. + * + * @since 2.0 + * + * @return The default height of an item + * @remarks This method must be implemented so that it returns the default height of items in the SectionTableView control. + */ + virtual int GetDefaultItemHeight(void) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void ISectionTableViewItemProvider_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void ISectionTableViewItemProvider_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void ISectionTableViewItemProvider_Reserved3(void) {} +}; // ISectionTableViewItemProvider + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ISECTION_TABLE_VIEW_ITEM_PROVIDER_H_ diff --git a/inc/FUiCtrlISliderEventListener.h b/inc/FUiCtrlISliderEventListener.h new file mode 100644 index 0000000..a343014 --- /dev/null +++ b/inc/FUiCtrlISliderEventListener.h @@ -0,0 +1,107 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlISliderEventListener.h + * @brief This is the header file for the %ISliderEventListener interface. + * + * This header file contains the declarations of the %ISliderEventListener interface. @n + * If a change event is generated, a method of this interface is called. @n + * So, if the applications perform tasks related to change events, use the methods of this interface. + * + */ +#ifndef _FUI_CTRL_ISLIDER_EVENT_LISTENER_H_ +#define _FUI_CTRL_ISLIDER_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class Slider; + +/** + * @interface ISliderEventListener + * @brief This interface implements the listener for all slider events. + * + * @since 2.0 + * + * The %ISliderEventListener interface is the listener interface for receiving Slider events, which are fired when the slider knob moves. + * The class that processes a slider event implements this interface, and the instance created with that class is registered with + * a UI control, using the control's AddSliderEventListener() method. When the slider event occurs, the OnSliderBarMoved() + * method of that instance is invoked. + * + * For more information on the class features, see Slider. + */ +class ISliderEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~ISliderEventListener(void) {} + + /** + * Called when the Slider bar moves. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] value The current value indicated by the knob + * @remarks This event is fired when the knob is moved until the user releases the knob. + */ + virtual void OnSliderBarMoved(Tizen::Ui::Controls::Slider& source, int value) = 0; + +protected: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void ISliderEventListener_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void ISliderEventListener_Reserved2(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void ISliderEventListener_Reserved3(void) {} + +}; // ISliderEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ISLIDER_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlISplitPanelEventListener.h b/inc/FUiCtrlISplitPanelEventListener.h new file mode 100644 index 0000000..77b118c --- /dev/null +++ b/inc/FUiCtrlISplitPanelEventListener.h @@ -0,0 +1,115 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlISplitPanelEventListener.h + * @brief This is the header file for the %ISplitPanelEventListener interface. + * + * This header file contains the declarations of the %ISplitPanelEventListener interface. @n + * If a change event is generated, a method of this class is called. @n + * So, if the applications perform tasks related to change events, use the methods of this class. + * + */ +#ifndef _FUI_CTRL_ISPLIT_PANEL_EVENT_LISTENER_H_ +#define _FUI_CTRL_ISPLIT_PANEL_EVENT_LISTENER_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @interface ISplitPanelEventListener + * @brief This interface implements the listener for all splitpanel events. + * + * @since 2.0 + * + * The %ISplitPanelEventListener interface is the listener interface for receiving splitpanel events. + * The class that processes a splitpanel event implements this interface, and the instance created with that class is registered with + * a UI control, using the control's AddSplitPanelEventListener() method. When the splitpanel event occurs, a method of that instance is invoked. + * + * For more information on the class features, see SplitPanel. + */ +class _OSP_EXPORT_ ISplitPanelEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called + * + * @since 2.0 + */ + virtual ~ISplitPanelEventListener(void) {} + + /** + * + * Called when the divider moves. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] position The position of the divider + */ + virtual void OnDividerPositionChanged(Tizen::Ui::Controls::SplitPanel& source, int position) = 0; + + /** + * Called when the divider is double pressed. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @remark This method is invoked when an divider is double pressed. + */ + virtual void OnDividerDoublePressed(Tizen::Ui::Controls::SplitPanel& source) = 0; + +protected: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void ISplitPanelEventListener_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void ISplitPanelEventListener_Reserved2(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void ISplitPanelEventListener_Reserved3(void) {} + +}; // ISplitPanelEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ISPLIT_PANEL_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlITableViewItemEventListener.h b/inc/FUiCtrlITableViewItemEventListener.h new file mode 100644 index 0000000..2f3a0d6 --- /dev/null +++ b/inc/FUiCtrlITableViewItemEventListener.h @@ -0,0 +1,132 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlITableViewItemEventListener.h + * @brief This is the header file for the %ITableViewItemEventListener interface. + * + * This header file contains the declarations of the %ITableViewItemEventListener interface. @n + * If an item event is generated, a method of this interface is called. + * So, if an application does some jobs related to the item event, use the methods of this interface. + * + */ +#ifndef _FUI_CTRL_ITABLE_VIEW_ITEM_EVENT_LISTENER_H_ +#define _FUI_CTRL_ITABLE_VIEW_ITEM_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class TableView; +class TableViewItem; +class TableViewContextItem; + +/** + * @interface ITableViewItemEventListener + * @brief This interface implements the listener for item event. + * + * @since 2.0 + * + * The %ITableViewItemEventListener interface implements a listener for receiving item change events. + * The class that is interested in processing an item event implements this interface, + * and the instance created with that class is registered with a UI control, using the control's + * AddTableViewItemEventListener() method. When the item event occurs, the OnItemStateChanged() method of that object is invoked. + */ +class _OSP_EXPORT_ ITableViewItemEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ITableViewItemEventListener(void) {} + + /** + * Called when the state of a TableViewItem in the TableView is changed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] itemIndex The item index + * @param[in] pItem The target item + * @param[in] status The status of the item + * @remarks This method is called when a TableViewItem in the TableView is checked, unchecked, or selected. + * The application can change @c pItem in this method, but should not keep @c pItem for later use. + */ + virtual void OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) = 0; + + /** + * Called when the TableViewContextItem is opened or closed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] itemIndex The item index + * @param[in] pContextItem The context item which is opened or closed + * @param[in] activated @c true if a context item is opened,@n + * @c false, otherwise + */ + virtual void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated) = 0; + + /** + * Called when the item is reordered. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] itemIndexFrom The start item index of the item + * @param[in] itemIndexTo The final item index of the item + */ + virtual void OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView, int itemIndexFrom, int itemIndexTo) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void ITableViewItemEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void ITableViewItemEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void ITableViewItemEventListener_Reserved3(void) {} +}; // ITableViewItemEventListener + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_ITABLE_VIEW_ITEM_EVENT_LISTENER_H_ diff --git a/inc/FUiCtrlITableViewItemProvider.h b/inc/FUiCtrlITableViewItemProvider.h new file mode 100644 index 0000000..0bef40d --- /dev/null +++ b/inc/FUiCtrlITableViewItemProvider.h @@ -0,0 +1,155 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlITableViewItemProvider.h + * @brief This is the header file for the %ITableViewItemProvider interface. + * + * This header file contains the declarations of the %ITableViewItemProvider interface. + * If the event is generated, a method of this interface is called. + * So, if applications do jobs related to item events, use the methods of this interface. + * + */ + +#ifndef _FUI_CTRL_ITABLE_VIEW_ITEM_PROVIDER_H_ +#define _FUI_CTRL_ITABLE_VIEW_ITEM_PROVIDER_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ +class TableViewItem; + +/** + * @interface ITableViewItemProvider + * @brief This interface implements the listener for events on TableView. + * + * @since 2.0 + * + * The %ITableViewItemProvider interface implements an item provider which generates items for TableView. %TableView calls the item provider + * to request an item which is about to be displayed on a screen. Applications which use %TableView must implement the item provider. + * The class is registered with a %TableView, using the TableView's SetSimpleStyleItemProvider() method. + */ +class _OSP_EXPORT_ ITableViewItemProvider +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ITableViewItemProvider(void) {} + + /** + * Gets the total number of items in the specified group. + * + * @since 2.0 + * + * @return The total number of items + * @remarks This method must be implemented so that it returns the total number of items for the specified group in the TableView control. + */ + virtual int GetItemCount(void) = 0; + + /** + * Creates the specified item. + * + * @since 2.0 + * + * @return An item of the TableView + * @param[in] itemIndex The item index + * @param[in] itemWidth The width of the item + * @remarks An application that uses the TableView control must implement this method. + * This method is expected to return an item that is allocated on a heap memory. + * The returned item can be a %TableViewItem or a class derived from TableViewItem. + * Note that when the item is not required, the %TableView control calls ITableViewItemProvider::DeleteItem(), allowing the application to deallocate the item. + * @see DeleteItem() + */ + virtual TableViewItem* CreateItem(int itemIndex, int itemWidth) = 0; + + /** + * Deletes the specified item. + * + * @since 2.0 + * + * @return @c true if the item is deallocated by this method, @n + * else @c false + * @param[in] itemIndex The item index + * @param[in] pItem The pointer to TableViewItem that is to be deleted + * @remarks An application that uses the TableView control must implement this method. + * Using this method, an application can deallocate the item. + * If the application deallocates the item, this method must return @c true. This notifies the %TableView not to release the + * item. Otherwise, the item is deallocated by the %TableView. + * @see CreateItem() + */ + virtual bool DeleteItem(int itemIndex, TableViewItem* pItem) = 0; + + /** + * Updates the specified item. + * + * @since 2.0 + * + * @param[in] itemIndex The item index + * @param[in] pItem The pointer to TableViewItem that is to be updated + * @remarks An application that uses the TableView control must implement this method. + * This method is called when the modification of an item is requested. + * The application can change @c pItem in this method, but should not keep @c pItem for later use. + */ + virtual void UpdateItem(int itemIndex, TableViewItem* pItem) = 0; + + /** + * Gets the default height of an item. + * + * @since 2.0 + * + * @return The default height of an item + * @remarks This method must be implemented so that it returns the default height of items in the TableView control. + */ + virtual int GetDefaultItemHeight(void) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void ITableViewItemProvider_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void ITableViewItemProvider_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void ITableViewItemProvider_Reserved3(void) {} +}; // ITableViewItemProvider + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ITABLE_VIEW_ITEM_PROVIDER_H_ diff --git a/inc/FUiCtrlITokenFilter.h b/inc/FUiCtrlITokenFilter.h new file mode 100644 index 0000000..69da6db --- /dev/null +++ b/inc/FUiCtrlITokenFilter.h @@ -0,0 +1,105 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlITokenFilter.h + * @brief This is the header file for the %ITokenFilter interface. + * + * This header file contains the declarations of the %ITokenFilter interface. + */ +#ifndef _FUI_CTRL_ITOKEN_FILTER_H_ +#define _FUI_CTRL_ITOKEN_FILTER_H_ + +// includes +#include + +// namespace declaration +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @interface ITokenFilter + * @brief This interface defines the token filter. + * + * @since 2.0 + * + * The %ITokenFilter interface is the listener interface for replacing tokenized input in the ExpandableEditArea. + * + * For more information on the class features, see ExpandableEditArea. + * + */ +class _OSP_EXPORT_ ITokenFilter +{ +// Lifecycle +public: + /** + * This is the destructor for this class. + * @since 2.0 + */ + virtual ~ITokenFilter(void) {} + +// Operation +public: + /** + * Checks whether the text tokenized by the ExpandableEditArea instance must be replaced. + * + * @since 2.0 + * + * @return @c true if the text of the current token needs to be replaced, @n + * else @c false + * @param[in] token The text of the current token + * @param[out] replacement The user-defined replacement text + */ + virtual bool ReplaceToken(const Tizen::Base::String& token, Tizen::Base::String& replacement) = 0; + + +// Reserves +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void ITokenFilter_Reserved1(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void ITokenFilter_Reserved2(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void ITokenFilter_Reserved3(void) { } +}; // ITokenFilter + +}}} //Tizen::Ui::Controls +#endif //_FUI_CTRL_ITOKEN_FILTER_H_ diff --git a/inc/FUiCtrlIconList.h b/inc/FUiCtrlIconList.h new file mode 100644 index 0000000..91abf7f --- /dev/null +++ b/inc/FUiCtrlIconList.h @@ -0,0 +1,906 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlIconList.h + * @brief This is the header file for the %IconList class. + * + * This header file contains the declarations of the %IconList class and its helper classes. + */ + +#ifndef _FUI_CTRL_ICON_LIST_H_ +#define _FUI_CTRL_ICON_LIST_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +// forward declarations +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if OSPDEPREC + * @class IconList + * @brief [Deprecated] This class defines the common behavior of an %IconList control. + * + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @remarks %IconList can display a maximum of 64 items on the screen at once (for example, 8 x 8 grid). + * %IconList is not drawn properly when it is resized. + * + * The %IconList class can be used to display a list of bitmap images and icons. When + * a list item (or icon) is pressed by the user, an item event is generated and the + * item event listeners are called to notify the change in the + * item's state (ITEM_CHECKED, ITEM_UNCHECKED and ITEM_SELECTED). + * + * When %IconList's style is set as ICON_LIST_STYLE_RADIO, only one item + * can be "selected" at a time. Whereas, if ICON_LIST_STYLE_MARK is set as + * the %IconList's style, multiple items can be "checked" at the same time. + * However, no item can be selected or checked when %IconList's style is set as + * ICON_LIST_STYLE_NORMAL. + * + * When a list item is selected by the user, the "focused" bitmap image is displayed + * instead of item's "normal" bitmap image. + * + * Please note that any image resources (bitmaps) that are allocated by application + * must be freed after they are passed to Additem()/InsertItem()/SetItem() to + * minimize memory usage. @n + * + * Example: + * + * @image html ui_controls_iconlist.png + * + *@n + * This is a simple UI application which uses a icon list control. + * + * + * @code +//Sample code for IconListSample.h +#include + +class IconListSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IItemEventListener +{ +public: + IconListSample(void) + : __pIconList(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + // IItemEventListener + virtual void OnItemStateChanged(const Tizen::Ui::Control &source, int index, int itemId, Tizen::Ui::ItemStatus status); + +private: + static const int ID_LIST_FIRSTITEM = 101; + static const int ID_LIST_SECONDITEM = 102; + + Tizen::Ui::Controls::IconList *__pIconList; +}; + * @endcode + * + * @code +//Sample code for IconListSample.cpp +#include +#include + +#include "IconListSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +bool +IconListSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +IconListSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of IconList + __pIconList = new IconList(); + __pIconList->Construct(Rectangle(0, 100, GetClientAreaBounds().width, GetClientAreaBounds().height), ICON_LIST_STYLE_NORMAL, 96, 96); + __pIconList->AddItemEventListener(*this); + + // Creates instances of String + String itemText1(L"Item1"); + String itemText2(L"Item2"); + + // Gets instances of Bitmap + AppResource* pAppResource = Application::GetInstance()->GetAppResource(); + Bitmap *pBitmapNormal1 = pAppResource->GetBitmapN(L"call.png"); + Bitmap *pBitmapFocused1 = pAppResource->GetBitmapN(L"call_focused.png"); + Bitmap *pBitmapNormal2 = pAppResource->GetBitmapN(L"home.png"); + Bitmap *pBitmapFocused2 = pAppResource->GetBitmapN(L"home_focused.png"); + + // Adds the items to the icon list + __pIconList->AddItem(&itemText1, pBitmapNormal1, pBitmapFocused1, ID_LIST_FIRSTITEM); + __pIconList->AddItem(&itemText2, pBitmapNormal2, pBitmapFocused2, ID_LIST_SECONDITEM); + + // Adds the icon list to the form + AddControl(*__pIconList); + + // Deallocates bitmaps + delete pBitmapNormal1; + delete pBitmapFocused1; + delete pBitmapNormal2; + delete pBitmapFocused2; + + return r; +} + +// IItemEventListener implementation +void +IconListSample::OnItemStateChanged (const Control &source, int index, int itemId, ItemStatus status) +{ + switch (itemId) + { + case ID_LIST_FIRSTITEM: + { + // .... + } + break; + case ID_LIST_SECONDITEM: + { + // .... + } + break; + default: + break; + } +} + * @endcode + * @endif + */ +class _OSP_EXPORT_ IconList + : public Tizen::Ui::Control +{ +public: + /** + * @if OSPDEPREC + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * @endif + */ + IconList(void); + + /** + * @if OSPDEPREC + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * @endif + */ + virtual ~IconList(void); + +public: + /** + * @if OSPDEPREC + * Initializes this instance of %IconList with the specified parameters. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the X and Y coordinates of the top-left corner of the created %IconList along with + * the width and height. @n + * @param[in] style The style set of %IconList + * @param[in] itemWidth The width of the items in the %IconList + * @param[in] itemHeight The height of the items in the %IconList + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully usable only after it has been added to a container, therefore some methods may fail if used earlier. + * @remarks The %IconList cannot display more than 64 items on screen at once. + * @remarks The size of the control must be within the range defined by the minimum and maximum size. + * @remarks The minimum size of this control is 0 x 0. + * @endif + */ + result Construct(const Tizen::Graphics::Rectangle& rect, IconListStyle style, int itemWidth, int itemHeight); + + +// Operation + /** + * @if OSPDEPREC + * Adds a listener instance. @n + * The added listener can listen to item events when they are fired. Only an item event with the ITEM_SELECTED state is fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @param[in] listener The listener to be added + * @endif + */ + void AddItemEventListener(Tizen::Ui::IItemEventListener& listener); + + /** + * @if OSPDEPREC + * Removes a listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @endif + */ + void RemoveItemEventListener(Tizen::Ui::IItemEventListener& listener); + + /** + * @if OSPDEPREC + * Sets the background bitmap of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @param[in] bitmap The background bitmap + * @endif + */ + void SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * @if OSPDEPREC + * Sets the top and left margins of the items for %IconList. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return An error code + * @param[in] topMargin The top margin of the background bitmap + * @param[in] leftMargin The left margin of the background bitmap + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The %IconList cannot display more than 64 items on screen at once. + * @endif + */ + result SetMargin(int topMargin, int leftMargin); + + + /** + * @if OSPDEPREC + * Gets the top margin of the items for the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The top margin of the background bitmap + * @endif + */ + int GetTopMargin(void) const; + + /** + * @if OSPDEPREC + * Gets the left margin of the items for the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The left margin of the background bitmap + * @endif + */ + int GetLeftMargin(void) const; + + /** + * @if OSPDEPREC + * Adds a list item with the specified text and bitmap images to the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return An error code + * @param[in] pText The item text + * @param[in] pNormalBitmap The default bitmap image + * @param[in] pFocusedBitmap The displayed bitmap image when an item is selected + * @param[in] itemId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The contents of the specified texts and bitmaps are copied and kept by %List. + * To display text in multi-lines or to denote the end of line, use '\\n'. + * @endif + */ + result AddItem(const Tizen::Base::String* pText, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pFocusedBitmap, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + + /** + * @if OSPDEPREC + * Inserts the specified text and bitmap item in the specified index of the specified %IconList. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The item text + * @param[in] pText The text item to be added + * @param[in] pNormalBitmap The default bitmap image + * @param[in] pFocusedBitmap The displayed bitmap image when an item is selected + * @param[in] itemId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The contents of the specified texts and bitmaps are copied and kept by %IconList. + * To display text in multi-lines or to denote the end of line, use '\\n'. + * @endif + */ + result InsertItemAt(int index, const Tizen::Base::String* pText, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pFocusedBitmap, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + + /** + * @if OSPDEPREC + * Sets the specified text and bitmap item in the specified index of the specified %IconList. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the List item + * @param[in] pText The item text + * @param[in] pNormalBitmap The default bitmap image + * @param[in] pFocusedBitmap The displayed bitmap image when an item is selected + * @param[in] itemId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The contents of the specified texts and bitmaps are copied and kept by %IconList. + * Call RefreshItem() to update item images. + * To display text in multi-lines or to denote the end of line, use '\\n'. + * @endif + */ + result SetItemAt(int index, const Tizen::Base::String* pText, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pFocusedBitmap, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + + /** + * @if OSPDEPREC + * Removes the item at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the %IconList item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RemoveItemAt(int index); + + /** + * @if OSPDEPREC + * Removes all items of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RemoveAllItems(void); + + /** + * @if OSPDEPREC + * Gets the column count of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The count of all the items of the %IconList control + * @endif + */ + int GetColumnCount(void) const; + + /** + * @if OSPDEPREC + * Gets the item count of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The count of all the items of the %IconList control + * @endif + */ + int GetItemCount(void) const; + + /** + * @if OSPDEPREC + * Sets the checked status of the specified item of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the %IconList item + * @param[in] check Set to @c true to check the specified item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * + * @remarks This method can only be used when the style of the list allows selection (ICON_LIST_STYLE_MARK). + * @remarks The method only changes the state of the list item. %IconList needs to be redrawn to reflect the change on the screen. + * @endif + */ + result SetItemChecked(int index, bool check); + + /** + * @if OSPDEPREC + * Checks whether the specified item of the %IconList control is checked. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return @c true if the specified item is checked, @n + * else @c false + * @param[in] index The index of the list item + * @remarks This method can only be used when the style of the list allows selection. + * @endif + */ + bool IsItemChecked(int index) const; + + /** + * @if OSPDEPREC + * Sets the checked status of all the items of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return An error code + * @param[in] check Set to @c true to check all the items, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows multiple selections (ICON_LIST_STYLE_MARK). + * @remarks The method only changes the states of the list items. %IconList needs to be redrawn to reflect the changes on the screen. + * @endif + */ + result SetAllItemsChecked(bool check); + + /** + * @if OSPDEPREC + * Removes all checked items of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + result RemoveAllCheckedItems(void); + + /** + * @if OSPDEPREC + * Gets the first checked items of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The index of the %IconList item + * @endif + */ + int GetFirstCheckedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the last checked items of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The index of the %IconList item + * @endif + */ + int GetLastCheckedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the next checked items at the specified index of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The index of the list item + * @param[in] index The index of the %IconList item + * @endif + */ + int GetNextCheckedItemIndexAfter(int index) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified item position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if there is no list item at the specified position + * @param[in] x The x position of the point + * @param[in] y The y position of the point + * @endif + */ + int GetItemIndexFromPosition(int x, int y) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified item position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if there is no list item at the specified position + * @param[in] position The position of the point + * @endif + */ + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + + /** + * @if OSPDEPREC + * Sets a horizontal alignment of the text in the current %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @param[in] alignment The horizontal alignment of the text + * @endif + */ + void SetTextHorizontalAlignment(HorizontalAlignment alignment); + + /** + * @if OSPDEPREC + * Sets a vertical alignment of the text of the current %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @param[in] alignment The vertical alignment of the icon and text + * @endif + */ + void SetTextVerticalAlignment(VerticalAlignment alignment); + + /** + * @if OSPDEPREC + * Gets the horizontal alignment of the text of the current %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The horizontal alignment of the %IconList control + * @endif + */ + HorizontalAlignment GetTextHorizontalAlignment(void) const; + + /** + * @if OSPDEPREC + * Gets the vertical alignment of the text of the current %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The vertical alignment of the %IconList control + * @endif + */ + VerticalAlignment GetTextVerticalAlignment(void) const; + + /** + * @if OSPDEPREC + * Sets the background color of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @param[in] color The background color + * @endif + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Sets the text to display when the %IconList control contains no item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @param[in] text The text + * @endif + */ + void SetTextOfEmptyList(const Tizen::Base::String& text); + + /** + * @if OSPDEPREC + * Sets the color of the text that is displayed when the %IconList control contains no item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @param[in] color The color of the text + * @endif + */ + void SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + + /** + * @if OSPDEPREC + * Gets the color of the text that is displayed when the %IconList control contains no item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The color of the text, @n + * else RGBA(0, 0, 0, 0) if an error occurs + * @endif + */ + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + + /** + * @if OSPDEPREC + * Sets the text color of the item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @param[in] textColor The color of the text + * @endif + */ + void SetItemTextColor(const Tizen::Graphics::Color& textColor); + + /** + * @if OSPDEPREC + * Gets the text color of the item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The color of the text, @n + * else RGBA(0, 0, 0, 0) if an error occurs + * @endif + */ + Tizen::Graphics::Color GetItemTextColor(void) const; + + + /** + * @if OSPDEPREC + * Sets the size of the text of the current %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @param[in] size The size of the text + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If @c size is less than the minimum size, this method fails. The minimum font size is 6 on devices of high screen density. + * @endif + */ + void SetTextSize(int size); + + + /** + * @if OSPDEPREC + * Gets the size of the text of the current %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The size of the text of the current %IconList control + * @endif + */ + int GetTextSize(void) const; + + /** + * @if OSPDEPREC + * Gets the index of the item with the specified item ID. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if there is no list item with the specified item ID + * @param[in] itemId The item ID of the list item + * @endif + */ + int GetItemIndexFromItemId(int itemId) const; + + /** + * @if OSPDEPREC + * Gets the item ID of the item at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The item ID of the item, @n + * else @c -1 if there is no list item at the specified index + * @param[in] index The index of the list item + * @endif + */ + int GetItemIdAt(int index) const; + + /** + * @if OSPDEPREC + * Sets the position of the checkbox of the current %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @param[in] position The position of the checkbox of the current %IconList control + * @remarks This method changes the position of the checkbox image displayed for the "selected" item(s), when the style of %IconList is either + * ICON_LIST_STYLE_RADIO or ICON_LIST_STYLE_MARK. + * @endif + */ + void SetCheckBoxPosition(IconListCheckBoxPosition position); + + /** + * @if OSPDEPREC + * Gets the position of the checkbox of the current %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return The position of the checkbox of the current %IconList control + * @endif + */ + IconListCheckBoxPosition GetCheckBoxPosition(void) const; + + /** + * @if OSPDEPREC + * Enables or disables focus animation. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @param[in] enable Set to @c true to enable focus animation, @n + * else @c false + * @remarks If a separate Focused Bitmap is to be used, the animation effect must be disabled. + * @endif + */ + void SetFocusAnimationEnabled(bool enable); + + /** + * @if OSPDEPREC + * Scrolls to the bottom of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * @endif + */ + void ScrollToBottom(void); + + /** + * @if OSPDEPREC + * Scrolls to the top of the %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * @endif + */ + void ScrollToTop(void); + + /** + * @if OSPDEPREC + * Scrolls the specified item to the top of %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @endif + */ + result ScrollToTop(int itemIndex); + + /** + * @if OSPDEPREC + * Draws and shows the item of %IconList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IconListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the %IconList item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @endif + */ + result RefreshItem(int index); + +public: + friend class _IconListImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + IconList(const IconList& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + IconList& operator =(const IconList& rhs); +}; //IconList + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ICON_LIST_H_ diff --git a/inc/FUiCtrlIconListTypes.h b/inc/FUiCtrlIconListTypes.h new file mode 100644 index 0000000..63ece76 --- /dev/null +++ b/inc/FUiCtrlIconListTypes.h @@ -0,0 +1,71 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlIconListTypes.h + * @brief This is the header file for the %IconList enumerations. + * + * This header file contains the declarations of the %IconList enumerations. + * + * These enumerations define the various properties of the %IconList control. + */ + +#ifndef _FUI_CTRL_ICON_LIST_TYPES_H_ +#define _FUI_CTRL_ICON_LIST_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if OSPDEPREC + * @enum IconListStyle + * + * Defines the styles of %IconList. + * + * @brief [Deprecated] + * @deprecated This enumeration is deprecated. Instead of using this enumeration, use the IconListViewStyle enumeration. + * @since 2.0 + * @endif + */ +enum IconListStyle +{ + ICON_LIST_STYLE_NORMAL = 0, /**< @if OSPDEPREC The No mark or radio check @endif */ + ICON_LIST_STYLE_RADIO, /**< @if OSPDEPREC The radio style for single selection @endif */ + ICON_LIST_STYLE_MARK, /**< @if OSPDEPREC The mark style for multiple selection @endif */ +}; + +/** + * @if OSPDEPREC + * @enum IconListCheckBoxPosition + * + * Defines the check-box position. + * + * @brief [Deprecated] + * @deprecated This enumeration is deprecated. Instead of using this enumeration, use the IconListViewCheckBoxPosition enumeration. + * @since 2.0 + * @endif + */ +enum IconListCheckBoxPosition +{ + ICON_LIST_CHECK_BOX_POSITION_TOP_LEFT, /**< @if OSPDEPREC The position of checkbox is top-left @endif */ + ICON_LIST_CHECK_BOX_POSITION_TOP_RIGHT, /**< @if OSPDEPREC The position of checkbox is top-right @endif */ + ICON_LIST_CHECK_BOX_POSITION_BOTTOM_LEFT, /**< @if OSPDEPREC The position of checkbox is bottom-left @endif */ + ICON_LIST_CHECK_BOX_POSITION_BOTTOM_RIGHT /**< @if OSPDEPREC The position of checkbox is bottom-right @endif */ +}; + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_ICON_LIST_TYPES_H_ diff --git a/inc/FUiCtrlIconListView.h b/inc/FUiCtrlIconListView.h new file mode 100644 index 0000000..86d55f5 --- /dev/null +++ b/inc/FUiCtrlIconListView.h @@ -0,0 +1,924 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIconListView.h + * @brief This is the header file for the %IconListView class. + * + * This header file contains the declarations of the %IconListView class and its helper classes. + */ + +#ifndef _FUI_CTRL_ICON_LIST_VIEW_H_ +#define _FUI_CTRL_ICON_LIST_VIEW_H_ + +//Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class IconListView + * @brief This class defines the common behavior for a %IconListView control. + * + * @since 2.0 + * + * The %IconListView class displays a 2-dimentional list of bitmap images and icons. + * + * For more information on the class features, see ListViews. + * + * The following example demonstrates how to use the %IconListView class. + * + * @code +//Sample code for IconListViewSample.h +#include + +class IconListViewSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IIconListViewItemProvider + , public Tizen::Ui::Controls::IIconListViewItemEventListener +{ +public: + IconListViewSample(void) + : __pIconListView(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // IIconListViewItemEventListener + virtual void OnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView &view, int index, Tizen::Ui::Controls::IconListViewItemStatus status); + + //IIconListViewItemProvider + virtual Tizen::Ui::Controls::IconListViewItem* CreateItem(int index); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::IconListViewItem* pItem); + virtual int GetItemCount(void); + +private: + Tizen::Graphics::Bitmap* __pHome; + Tizen::Graphics::Bitmap* __pMsg; + Tizen::Graphics::Bitmap* __pAlarm; + + Tizen::Ui::Controls::IconListView* __pIconListView; +}; + * @endcode + * + * @code +//Sample code for IconListViewSample.cpp +#include +#include + +#include "IconListViewSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +bool +IconListViewSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +IconListViewSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of IconListView + __pIconListView = new IconListView(); + __pIconListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), + Dimension(100, 100), ICON_LIST_VIEW_STYLE_NORMAL, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL); + __pIconListView->SetItemProvider(*this); + __pIconListView->AddIconListViewItemEventListener(*this); + + // Adds the icon list view to the form + AddControl(*__pIconListView); + + // Gets instances of Bitmap + AppResource* pAppResource = Application::GetInstance()->GetAppResource(); + __pHome = pAppResource->GetBitmapN(L"home.png"); + __pMsg = pAppResource->GetBitmapN(L"message.png"); + __pAlarm = pAppResource->GetBitmapN(L"alarm.png"); + + return r; +} + +result +IconListViewSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates bitmaps + delete __pHome; + delete __pMsg; + delete __pAlarm; + + return r; +} + +int +IconListViewSample::GetItemCount(void) +{ + return 3; +} + +IconListViewItem* +IconListViewSample::CreateItem(int index) +{ + // Creates an instance of IconListViewItem + IconListViewItem* pIconListview = new IconListViewItem(); + + // Creates an instance of String + String* pStr = new String(); + + switch (index % 3) + { + case 0: + { + *pStr = L"Home"; + pIconListview->Construct(*__pHome, pStr); + } + break; + case 1: + { + *pStr = L"Msg"; + pIconListview->Construct(*__pMsg, pStr); + } + break; + case 2: + { + *pStr = L"Alarm"; + pIconListview->Construct(*__pAlarm, pStr); + } + break; + } + + // Deallocates the string + delete pStr; + + return pIconListview; +} + +bool +IconListViewSample::DeleteItem(int index, IconListViewItem* pItem) +{ + delete pItem; + return true; +} + +void +IconListViewSample::OnIconListViewItemStateChanged (IconListView &view, int index, IconListViewItemStatus status) +{ + switch (index) + { + case 0: + { + // .... + } + break; + case 1: + { + // .... + } + break; + default: + break; + } +} + * @endcode + * + */ +class _OSP_EXPORT_ IconListView + : public Tizen::Ui::Control +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + IconListView(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~IconListView(void); + +public: + /** + * Initializes this instance of %IconListView with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created %IconListView along with + * the width and height. + * @param[in] itemBitmapSize The size of an icon in the %IconListView + * @param[in] style The style set of %IconListView + * @param[in] direction The direction of scroll + * @param[in] scrollStyle The scroll style of %IconListView + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully usable only after it has been added to a container, therefore some methods may fail if used earlier. + * @remarks The number of items to be displayed on a screen is calculated based on %IconListView size, item size, item spacing, and margins. @n + * The %IconListView cannot display more than 256 items on the screen at once. + * @remarks The actual size of bitmap to be displayed in %IconListView is smaller than the specified size when the border style is ICON_LIST_VIEW_ITEM_BORDER_STYLE_SHADOW. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, const Tizen::Graphics::Dimension& itemBitmapSize, IconListViewStyle style = ICON_LIST_VIEW_STYLE_NORMAL, IconListViewScrollDirection direction = ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL, IconListViewScrollStyle scrollStyle = ICON_LIST_SCROLL_STYLE_FADE_OUT); + + /** + * Sets the item provider that creates and deletes items for the %IconListView control. + * + * @since 2.0 + * + * @return An error code + * @param[in] provider The item provider to create and delete items + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks If an item provider is not set for the %IconListView, it does not work. @n + * The specified @c provider should be allocated in heap memory. + */ + result SetItemProvider(IIconListViewItemProvider& provider); + + /** + * Adds a listener instance. @n + * The added listener can listen to item events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + */ + void AddIconListViewItemEventListener(IIconListViewItemEventListener& listener); + + /** + * Removes a listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + */ + void RemoveIconListViewItemEventListener(IIconListViewItemEventListener& listener); + + /** + * Adds a listener instance that listens to state changes of a scroll event. @n + * The added listener can listen to events on the context of the given event dispatcher when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @see IScrollEventListener::OnScrollEndReached() + * @see RemoveScrollEventListener() + */ + void AddScrollEventListener(IScrollEventListener& listener); + + /** + * Removes a listener instance that listens to state changes of a scroll event. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see IScrollEventListener::OnScrollEndReached() + * @see RemoveScrollEventListener() + */ + void RemoveScrollEventListener(IScrollEventListener& listener); + + /** + * Sets the background bitmap of the %IconListView. + * + * @since 2.0 + * + * @param[in] pBitmap The background bitmap + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks When @c pBitmap is null, %IconListView does not have a background bitmap. The default value for the background bitmap is @c null. + * @remarks The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, + * only the bitmap is displayed. + */ + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + /** + * Sets the background color of this control. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The background color + * @exception E_SUCCESS The method is successful. + * @remarks The method sets the alpha value of the specified color to 255, when a device does not support 32 bit color space. + * @remarks The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, + * only the bitmap is displayed. + */ + result SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * Gets the background color of this control. + * + * @since 2.0 + * + * @return The background color, @n + * else RGBA(0, 0, 0, 0) if an error occurs + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + + /** + * Sets the margin of %IconListView. + * + * @since 2.0 + * + * @return An error code + * @param[in] type The type of margin + * @param[in] value The marginal value + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The number of items to be displayed on a screen is calculated based on %IconListView size, item size, item spacing, and + * margins. The %IconListView cannot display more than 256 items on screen at once. + */ + result SetMargin(MarginType type, int value); + + /** + * Gets the margin of %IconListView. + * + * @since 2.0 + * + * @return The marginal value of %IconListView, @n + * else @c -1 if an error occurs + * @param[in] type The type of margin + */ + int GetMargin(MarginType type) const; + + /** + * Sets the horizontal and vertical spacing between the items. + * + * @since 2.0 + * + * @return An error code + * @param[in] horizontalSpacing The spacing between items in horizontal direction + * @param[in] verticalSpacing The spacing between items in vertical direction + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The number of items to be displayed on a screen is calculated based on %IconListView size, item size, item spacing, and + * margins. The %IconListView cannot display more than 256 items on screen at once. + */ + result SetItemSpacing(int horizontalSpacing, int verticalSpacing); + + /** + * Gets the horizontal spacing between items of %IconListView. + * + * @since 2.0 + * + * @return The value of space between items in horizontal direction, @n + * else @c -1 if an error occurs + */ + int GetItemHorizontalSpacing(void) const; + + /** + * Gets the vertical spacing between items of %IconListView. + * + * @since 2.0 + * + * @return The value of space between items in vertical direction, @n + * else @c -1 if an error occurs + */ + int GetItemVerticalSpacing(void) const; + + /** + * Sets the checked status of the specified item of %IconListView. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the %IconListView item + * @param[in] check The check status + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + * @remarks This method can only be used when the style of the list allows selection. + * @remarks The method only changes the state of the list item. %IconListView needs to be redrawn to reflect the change on the screen. + */ + result SetItemChecked(int index, bool check); + + /** + * Checks whether the specified item is checked. + * + * @since 2.0 + * + * @return @c true if the specified item is checked, @n + * else @c false + * @param[in] index The index of the item + * @remarks This method can only be used when the style of the list allows selection. + */ + bool IsItemChecked(int index) const; + + /** + * Gets the index of the item at the specified position. + * + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 when there is no list item at the specified position or when the %IconListView instance is invalid + * @param[in] x The x position of a point + * @param[in] y The y position of a point + */ + int GetItemIndexFromPosition(int x, int y) const; + + /** + * Gets the index of the item at the specified position. + * + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if there is no list item at the specified position or when the %IconListView instance is invalid + * @param[in] position The position of a point + */ + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + + /** + * Sets the horizontal alignment of the text of an item. + * + * @since 2.0 + * + * @return An error code + * @param[in] alignment The horizontal alignment of the text + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTextHorizontalAlignment(HorizontalAlignment alignment); + + /** + * Sets the vertical alignment of the text of an item. + * + * @since 2.0 + * + * @return An error code + * @param[in] alignment The vertical alignment of the text + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment); + + /** + * Gets the horizontal alignment of the text of the %IconListView control. + * + * @since 2.0 + * + * @return The horizontal alignment of the text, @n + * else ALIGNMENT_LEFT when the %IconListView instance is invalid + */ + HorizontalAlignment GetTextHorizontalAlignment(void) const; + + /** + * Gets the vertical alignment of the text of the current %IconListView. + * + * @since 2.0 + * + * @return The vertical alignment of the text of an item, @n + * else ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP when the %IconListView is invalid + */ + IconListViewItemTextVerticalAlignment GetTextVerticalAlignment(void) const; + + /** + * Sets the text of the empty list. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text of the empty list + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTextOfEmptyList(const Tizen::Base::String& text); + + /** + * Gets the text to display when there is no item in the list. + * + * @since 2.0 + * + * @return The text to be displayed, @n + * else an empty string if the instance is invalid + */ + Tizen::Base::String GetTextOfEmptyList(void) const; + + /** + * Sets the color of the text that is displayed when %IconListView contains no item. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color of the text + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + /** + * Gets the color of the text to display when there is no item in the list. + * + * @since 2.0 + * + * @return The color of the text to be displayed, @n + * else RGBA(0, 0, 0, 0) if the instance is invalid + */ + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + /** + * Sets the text color of the item. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The drawing status of items + * @param[in] color The color of the text + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemTextColor(IconListViewItemDrawingStatus status, const Tizen::Graphics::Color& color); + + /** + * Gets the text color of the item. + * + * @since 2.0 + * + * @return The color of the text, @n + * else RGBA(0, 0, 0, 0) if the instance is invalid + * @param[in] status The drawing status of items + */ + Tizen::Graphics::Color GetItemTextColor(IconListViewItemDrawingStatus status) const; + + /** + * Sets the size of the text of the %IconListView control. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The size of the text + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If the specified @c size is less than the minimum size, this method fails. The minimum font size is @c 6 on devices of high screen density. + */ + result SetItemTextSize(int size); + + /** + * Gets the size of the text of the %IconListView control. + * + * @since 2.0 + * + * @return The size of the text of the %IconListView control, @n + * else @c -1 if the instance is invalid + */ + int GetItemTextSize(void) const; + + /** + * Sets the position of the checkbox of the %IconListView control. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position of the checkbox of the %IconListView + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * That is, %IconListView cannot get the position of the checkbox when the style is ICON_LIST_VIEW_STYLE_NORMAL. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method changes the position of the checkbox image displayed for the "selected" item(s), + * when the style of %IconListView is either ICON_LIST_VIEW_STYLE_RADIO and ICON_LIST_VIEW_STYLE_MARK. + */ + result SetCheckBoxPosition(IconListViewCheckBoxPosition position); + + /** + * Gets the position of the checkbox of the %IconListView control. + * + * @since 2.0 + * + * @return The position of the checkbox + * @remarks The method returns @c ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT when the style of %IconListView is ICON_LIST_VIEW_STYLE_NORMAL or + * ICON_LIST_VIEW_STYLE_DIVIDE_TEXT. + */ + IconListViewCheckBoxPosition GetCheckBoxPosition(void) const; + + /** + * Enables or disables touch animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable touch animation, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks If you want to use a separate selected bitmap, the animation effect must be disabled. + * @remarks In case that a touch animation disabled, the normal bitmap of %IconListViewItem is displayed in response to touch interaction if the + * selected bitmap of %IconListViewItem is @c null. + */ + result SetTouchAnimationEnabled(bool enable); + + /** + * Checks whether touch animation is enabled. + * + * @since 2.0 + * + * @return @c true if touch animation is enabled, @n + * else @c false if touch animation is disabled or when the instance is invalid + */ + bool IsTouchAnimationEnabled(void) const; + + /** + * Scrolls the list contents to the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + */ + result ScrollToItem(int index); + + /** + * Refreshes the specified item of %IconListView. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the %IconListView item + * @param[in] type The type of change of an item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * That is, %IconListView cannot execute RefreshList() before first drawn. + * @exception E_SYSTEM A system error has occurred. + * @exception E_OUT_OF_RANGE The specified @c index is out of range. + */ + result RefreshList(int index, ListRefreshType type); + + /** + * Updates the whole items of a list. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method clears items in the list and re-invokes the methods of the item provider to fill the list. + */ + result UpdateList(void); + + /** + * Gets the size of bitmap of the item. + * + * @since 2.0 + * + * @return An error code + * @param[out] width The width of bitmap of the item + * @param[out] height The height of bitmap of the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result GetItemBitmapSize(int& width, int& height) const; + + /** + * Gets the size of bitmap of the item. + * + * @since 2.0 + * + * @return The size of bitmap of the item, @n + * else (-1, -1) if the instance is invalid + */ + Tizen::Graphics::Dimension GetItemBitmapSize(void) const; + + /** + * Gets the size of the item. + * + * @since 2.0 + * + * @return An error code + * @param[out] width The width of the item + * @param[out] height The height of the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result GetItemSize(int& width, int& height) const; + + /** + * Gets the size of the item. + * + * @since 2.0 + * + * @return The size of the item, @n + * else (-1, -1) if the instance is invalid + */ + Tizen::Graphics::Dimension GetItemSize(void) const; + + /** + * Sets the number of item lines to be scrolled for the magnetic scroll of %IconListView. + * + * @since 2.0 + * + * @return An error code + * @param[in] scrollSize The number of item lines for the magnetic scroll of %IconListView + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c scrollSize is out of range. @n + * The specified @c scrollSize is less than @c 0 or greater than the item count shown along the scroll direction. + * @exception E_SYSTEM A system error has occurred. + * @remarks If the @c scrollSize is set to @c 0, %IconListView does not use the magnetic scroll. The initial value is @c 0. + */ + result SetMagneticScrollSize(int scrollSize); + + /** + * Gets the number of item lines for the magnetic scroll of %IconListView. + * + * @since 2.0 + * + * @return The number of item lines for the magnetic scroll of %IconListView, @n + * else @c -1 when the instance is invalid + */ + int GetMagneticScrollSize(void) const; + + /** + * Gets the number of items to be displayed per axis of %IconListView. + * + * @since 2.0 + * + * @return The number of items to be displayed per axis, @n + * else @c -1 if the instance is invalid + * @remarks The axis represents "row" when the scroll style is ICON_LIST_VIEW_SCROLLSDIRECTION_HORIZONTAL, while it represents "column" when the + * scroll style is ICON_LIST_VIEW_SCROLLDIRECTION_VERTICAL. + */ + int GetItemCountPerAxis(void) const; + + /** + * Sets the items horizontal alignment of %IconListView. + * + * @since 2.0 + * + * @return An error code + * @param[in] alignment The alignment of items + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The alignment of icon list view is not in the vertical scroll direction. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemLayoutHorizontalAlignment(HorizontalAlignment alignment); + + /** + * Sets the items vertical alignment of %IconListView. + * + * @since 2.0 + * + * @return An error code + * @param[in] alignment The alignment of items + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The alignment of icon list view is not in the horizontal scroll direction. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemLayoutVerticalAlignment(VerticalAlignment alignment); + + /** + * Gets the items horizontal alignment of %IconListView. + * + * @since 2.0 + * + * @return The alignment of items, @n + * else @c ALIGNMENT_LEFT if the instance is invalid + */ + HorizontalAlignment GetItemLayoutHorizontalAlignment(void) const; + + /** + * Gets the items vertical alignment of %IconListView. + * + * @since 2.0 + * + * @return The alignment of items, @n + * else @c ALIGNMENT_TOP if the instance is invalid + */ + VerticalAlignment GetItemLayoutVerticalAlignment(void) const; + + /** + * Sets the item border style. + * + * @since 2.0 + * + * @return An error code + * @param[in] borderStyle An item border style + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemBorderStyle(IconListViewItemBorderStyle borderStyle); + + /** + * Gets the item border style. + * + * @since 2.0 + * + * @return The item border style, @n + * else @c ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE if an error occurs + */ + IconListViewItemBorderStyle GetItemBorderStyle(void) const; + + /** + * Sets the bitmap of the empty list. + * + * @since 2.0 + * + * @return An error code + * @param[in] pBitmap The bitmap of the empty list + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetBitmapOfEmptyList(const Tizen::Graphics::Bitmap* pBitmap); + + /** + * Begins the reordering mode. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see IIconListViewItemEventListener::OnIconListViewItemReordered() + */ + result BeginReorderingMode(void); + + /** + * Ends the reordering mode. + * + * @since 2.0 + * + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see IIconListViewItemEventListener::OnIconListViewItemReordered() + */ + result EndReorderingMode(void); + + /** + * Checks whether the %IconListView is in reordering mode. + * + * @since 2.0 + * + * @return @c true if the %IconListView is in reordering mode, @n + * else @c false + */ + bool IsInReorderingMode(void) const; + +public: + friend class _IconListViewImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + IconListView(const IconListView& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + IconListView& operator =(const IconListView& rhs); + +}; // IconListView + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ICON_LIST_VIEW_H_ diff --git a/inc/FUiCtrlIconListViewItem.h b/inc/FUiCtrlIconListViewItem.h new file mode 100644 index 0000000..01d13f2 --- /dev/null +++ b/inc/FUiCtrlIconListViewItem.h @@ -0,0 +1,122 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIconListViewItem.h + * @brief This is the header file for the %IconListViewItem class. + * + * This header file contains the declarations of the %IconListViewItem class and its helper classes. + */ + +#ifndef _FUI_CTRL_ICON_LIST_VIEW_ITEM_H_ +#define _FUI_CTRL_ICON_LIST_VIEW_ITEM_H_ + +//includes +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class IconListView; +class _IconListItemProviderAdaptor; +class _IconListViewItemImpl; + +/** + * @class IconListViewItem + * @brief This class defines the common behavior of a %IconListViewItem control. + * + * @since 2.0 + * + * The %IconListViewItem class displays an IconListView item. It comprises of bitmap images and text. The value is set using the IconListView control. + * @n + * For more information on the class features, see ListViews. + */ +class _OSP_EXPORT_ IconListViewItem + : public Tizen::Base::Object +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + IconListViewItem(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~IconListViewItem(void); + +public: + /** + * Initializes this instance of %IconListViewItem with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] bitmap The default bitmap image + * @param[in] pText The item text + * @param[in] pSelectedBitmap The displayed bitmap image when an item is selected + * @param[in] pHighlightedBitmap The displayed bitmap image when an item is highlighted + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks If @c pSelectedBitmap or @c pHighlightedBitmap is @c null, @c bitmap plays its role. + */ + result Construct(const Tizen::Graphics::Bitmap& bitmap, const Tizen::Base::String* pText = null, const Tizen::Graphics::Bitmap* pSelectedBitmap = null, const Tizen::Graphics::Bitmap* pHighlightedBitmap = null); + + /** + * Sets the overlay bitmap image as an element to the item. + * + * @since 2.0 + * + * @return An error code + * @param[in] overlayBitmapId The overlay bitmap ID + * @param[in] pOverlayBitmap The pointer of the overlay bitmap image + * @param[in] horizontalAlignment The horizontal alignment of overlay bitmap. + * @param[in] verticalAlignment The vertical alignment of overlay bitmap. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks When @c pOverlayBitmap is set as @c null, The overlay bitmap of the specified location will be erased. + */ + result SetOverlayBitmap(int overlayBitmapId, const Tizen::Graphics::Bitmap* pOverlayBitmap, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment); + +private: + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + IconListViewItem(const IconListViewItem& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + IconListViewItem& operator =(const IconListViewItem& rhs); + +private: + friend class IconListView; + friend class _IconListItemProviderAdaptor; + friend class _IconListViewItemImpl; + + // This value is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + _IconListViewItemImpl* __pImpl; +}; //IconListViewItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ICON_LIST_VIEW_ITEM_H_ diff --git a/inc/FUiCtrlIconListViewTypes.h b/inc/FUiCtrlIconListViewTypes.h new file mode 100644 index 0000000..daf5405 --- /dev/null +++ b/inc/FUiCtrlIconListViewTypes.h @@ -0,0 +1,151 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIconListViewTypes.h + * @brief This is the header file for the %IconListView enumerations. + * + * This header file contains the declarations of the %IconListView enumerations. + * + * These enumerations define the various properties of the %IconListView control. + */ + +#ifndef _FUI_CTRL_ICON_LIST_VIEW_TYPES_H_ +#define _FUI_CTRL_ICON_LIST_VIEW_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum IconListViewStyle + * + * Defines the styles of the %IconListView control. + * + * @since 2.0 + */ +enum IconListViewStyle +{ + ICON_LIST_VIEW_STYLE_NORMAL = 0, /**< The No mark or radio check */ + ICON_LIST_VIEW_STYLE_RADIO, /**< The radio style for a single selection */ + ICON_LIST_VIEW_STYLE_MARK /**< The mark style for multiple selections */ +}; + +/** + * @enum IconListViewItemBorderStyle + * + * Defines the constants used to identify the border style of the item. + * + * @since 2.0 + */ +enum IconListViewItemBorderStyle +{ + ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE = 0, /**< The item that has no border */ + ICON_LIST_VIEW_ITEM_BORDER_STYLE_OUTLINE, /**< The item that has a line border */ + ICON_LIST_VIEW_ITEM_BORDER_STYLE_SHADOW /**< The item that has a bitmap border with the drop shadow effect */ +}; + +/** + * @enum IconListViewScrollDirection + * + * Defines the scroll direction of the %IconListView control. + * + * @since 2.0 + */ +enum IconListViewScrollDirection +{ + ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL, /**< The vertical direction */ + ICON_LIST_VIEW_SCROLL_DIRECTION_HORIZONTAL /**< The horizontal direction */ +}; + +/** + * @enum IconListViewItemTextVerticalAlignment + * + * Defines the vertical alignment of the item text. + * + * @since 2.0 + */ +enum IconListViewItemTextVerticalAlignment +{ + ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP, /**< The text is top-aligned inside the item */ + ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_MIDDLE, /**< The text is middle-aligned inside the item */ + ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM, /**< The text is bottom-aligned inside the item */ + ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP, /**< The text is top-aligned outside the item */ + ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_BOTTOM /**< The text is bottom-aligned outside the item */ +}; + +/** + * @enum IconListViewItemStatus + * + * Defines the constants used to identify the item state. + * + * @since 2.0 + */ +enum IconListViewItemStatus +{ + ICON_LIST_VIEW_ITEM_CHECKED = 0, /**< The item has been checked (toggle of the check area) */ + ICON_LIST_VIEW_ITEM_UNCHECKED, /**< The item has been unchecked (toggle of the check area) */ + ICON_LIST_VIEW_ITEM_SELECTED, /**< The item has been selected (non-check area of the item) */ + ICON_LIST_VIEW_ITEM_HIGHLIGHTED /**< The item has been highlighted (non-check area of the item) */ +}; + +/** + * @enum IconListViewItemDrawingStatus + * + * Defines the drawing state of the %IconListView control items. + * + * @since 2.0 + */ +enum IconListViewItemDrawingStatus +{ + ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL = 0, /**< The drawing status for normal items */ + ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED, /**< The drawing status for pressed items */ + ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED /**< The drawing status for highlighted items */ +}; + +/** + * @enum IconListViewCheckBoxPosition + * + * Defines the checkbox position. + * + * @since 2.0 + */ +enum IconListViewCheckBoxPosition +{ + ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT, /**< The position of the checkbox is top-left */ + ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT, /**< The position of the checkbox is top-right */ + ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_LEFT, /**< The position of the checkbox is bottom-left */ + ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_RIGHT /**< The position of the checkbox is bottom-right */ +}; + +/** + * @enum IconListViewScrollStyle + * + * Defines the scroll style of the %IconListView control. + * + * @since 2.0 + */ +enum IconListViewScrollStyle +{ + ICON_LIST_SCROLL_STYLE_FADE_OUT = 0, /**< The fade-out scroll style */ + ICON_LIST_SCROLL_STYLE_FIXED, /**< The fixed scroll style */ + ICON_LIST_SCROLL_STYLE_JUMP_TO_TOP, /**< The jump to top scroll style */ + ICON_LIST_SCROLL_STYLE_THUMB /**< The thumb scroll style */ +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ICON_LIST_VIEW_TYPES_H_ diff --git a/inc/FUiCtrlInputTypes.h b/inc/FUiCtrlInputTypes.h new file mode 100644 index 0000000..b877a7f --- /dev/null +++ b/inc/FUiCtrlInputTypes.h @@ -0,0 +1,45 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlInputTypes.h + * @brief This is the header file for the input property. + * + * This header file contains the declarations of the input enumeration. + */ +#ifndef _FUI_CTRL_INPUT_ENUM_H_ +#define _FUI_CTRL_INPUT_ENUM_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum InputStyle + * + * Defines the input style. + * + * @since 2.0 + */ +enum InputStyle +{ + INPUT_STYLE_FULLSCREEN = 0, /**< The full screen input mode */ + INPUT_STYLE_OVERLAY /**< The overlay input mode */ +}; + +}; +}; +}; // Tizen::Ui::Controls +#endif // _FUI_CTRL_INPUT_ENUM_H_ diff --git a/inc/FUiCtrlKeypad.h b/inc/FUiCtrlKeypad.h new file mode 100644 index 0000000..347c9cc --- /dev/null +++ b/inc/FUiCtrlKeypad.h @@ -0,0 +1,354 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlKeypad.h + * @brief This is the header file for the %Keypad class. + * + * This header file contains the declarations of the %Keypad class. + */ + +#ifndef _FUI_CTRL_KEYPAD_H_ +#define _FUI_CTRL_KEYPAD_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if OSPDEPREC + * @enum KeypadInputModeCategory + * + * Defines the keypad input mode. + * + * @brief [Deprecated] + * @deprecated We no longer provide a method to specify the list of styles which the user can set the keypad to, @n + * or the current mode to initially set the keypad to, from this list. It is recommended to use the styles offered KeypadStyle enumeration instead. + * @since 2.0 + * @endif + */ +enum KeypadInputModeCategory +{ + KEYPAD_MODE_ALPHA = 0x0001, /**< @if OSPDEPREC The alphabetic input mode @endif */ + KEYPAD_MODE_PREDICTIVE = 0x0002, /**< @if OSPDEPREC The predictive input mode @endif*/ + KEYPAD_MODE_NUMERIC = 0x0004, /**< @if OSPDEPREC The numeric input mode @endif */ + KEYPAD_MODE_SYMBOL = 0x0008 /**< @if OSPDEPREC The symbolic input mode @endif */ +}; + +/** + * @class Keypad + * @brief This class displays a keypad on top of the screen. + * + * @since 2.0 + * + * The %Keypad class displays the full screen keypad without using an EditField or EditArea. + * + * For more information on the class features, see Keypad. + * + * The following example demonstrates how to use the %Keypad class. + * + * @code +// Sample code for KeypadSample.h +#include + +class KeypadSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::ITextEventListener +{ +public: + KeypadSample(void) + : __pKeypad(null){} + + bool Initialize(void); + void ShowKeypad(bool show); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + // ITextEventListener + virtual void OnTextValueChanged(const Tizen::Ui::Control& source); + virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source); + + +private: + static const int ID_BUTTON = 101; + + Tizen::Ui::Controls::Keypad *__pKeypad; +}; + +// Sample code for KeypadSample.cpp +#include "KeypadSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +KeypadSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +KeypadSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Button and adds it to the form + Button* pButton = new Button(); + pButton->Construct(Rectangle(50, 50, 150, 150), L"Show Keypad"); + pButton->SetActionId(ID_BUTTON); + pButton->AddActionEventListener(*this); + AddControl(*pButton); + + // Creates an instance of Keypad + __pKeypad = new Keypad(); + __pKeypad->Construct(KEYPAD_STYLE_NORMAL, KEYPAD_MODE_ALPHA); + + // Adds an instance of ITextEventListener + __pKeypad->AddTextEventListener(*this); + + return r; +} + +void +KeypadSample::ShowKeypad(bool show) +{ + // Changes to desired show state + __pKeypad->SetShowState(show); + + //Calls Show() of the control + if (show) + { + __pKeypad->Show(); + } + // Calls Invalidate() of the container + else + { + Invalidate(true); + } +} + +result +KeypadSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the keypad + delete __pKeypad; + + return r; +} + +// IActionEventListener implementation +void +KeypadSample::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) +{ + switch (actionId) + { + case ID_BUTTON: + { + ShowKeypad(true); + } + break; + + default: + break; + } +} + +// ITextEventListener implementation +void +KeypadSample::OnTextValueChanged(const Tizen::Ui::Control& source) +{ + // .... +} + +void +KeypadSample::OnTextValueChangeCanceled(const Tizen::Ui::Control& source) +{ + // .... +} + * @endcode + */ + +class _OSP_EXPORT_ Keypad + : public Tizen::Ui::Window +{ +//Lifecycle +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + Keypad(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Keypad(void); + + /** + * Initializes this instance of %Keypad with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] keypadStyle The style of %Keypad + * @param[in] limitLength The limit of the length of text in EditField + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or @n + * the specified @c limitLength is less than or equal to @c 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks If the keypad style is set to password, the input mode category is ignored. + * @remarks The orientation mode of the keypad is decided based on the G-sensor value. + */ + result Construct(KeypadStyle keypadStyle, int limitLength); + + /** + * @if OSPDEPREC + * Initializes this instance of %Keypad with input styles. + * + * @brief [Deprecated] + * @deprecated We no longer provide a method to specify the list of styles which the user can set the keypad to. @n + * It is recommended to use the other Construct() method and the KeypadStyle enumeration instead. + * @since 2.0 + * + * @return An error code + * @param[in] keypadStyle The style of %Keypad + * @param[in] category The initial category that the keypad would show first + * @param[in] limitLength The limit of the length of text in EditField + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or @n + * the specified @c limitLength is less than or equal to @c 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks If the keypad style is set to password, the input mode category is ignored. + * @remarks The orientation mode of the keypad is decided based on the G-sensor value. + * @endif + */ + result Construct(KeypadStyle keypadStyle, KeypadInputModeCategory category, int limitLength = 100); + + /** + * Checks whether the text prediction is enabled. + * + * @since 2.0 + * @return @c true if the text prediction is enabled, @n + * else @c false + * @see SetTextPredictionEnabled() + */ + bool IsTextPredictionEnabled(void) const; + + /** + * Enables or disables the text prediction. + * + * @since 2.0 + * @param[in] enable Set to @c true to enable the text prediction, @n + * else @c false + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @see IsTextPredictionEnabled() + */ + result SetTextPredictionEnabled(bool enable); + + /** + * Enables single-line editing. + * + * @since 2.0 + * + * @return An error code + * @param[in] enabled Set to @c true to enable single-line editing, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The %Keypad control is currently visible. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance does not support the execution of the specified operation. @n + * The password style does not support multi-line editing. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the single-line editing is disabled and the %Keypad control supports multi-lines (except the password style that only supports single-line editing). + */ + result SetSingleLineEnabled(bool enabled); + + /** + * Checks whether single-line editing is enabled. + * + * @since 2.0 + * + * @return @c true if single-line editing is enabled, @n + * else @c false + */ + bool IsSingleLineEnabled(void) const; + + /** + * Adds a ITextEventListener instance. @n + * The added listener can listen to text changed events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + */ + void AddTextEventListener(Tizen::Ui::ITextEventListener& listener); + + /** + * Removes a ITextEventListener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + */ + void RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener); + + /** + * Gets the text of the %Keypad control. + * + * @since 2.0 + * + * @return The string value + */ + Tizen::Base::String GetText(void) const; + + /** + * Sets the text of the %Keypad control. + * + * @since 2.0 + * + * @param[in] text The text to be set + */ + void SetText(Tizen::Base::String text); + +protected: + friend class _KeypadImpl; + +private: + Keypad(const Keypad&); + Keypad& operator =(const Keypad&); + +}; // Keypad + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_KEYPAD_H_ diff --git a/inc/FUiCtrlLabel.h b/inc/FUiCtrlLabel.h new file mode 100644 index 0000000..160daa6 --- /dev/null +++ b/inc/FUiCtrlLabel.h @@ -0,0 +1,341 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlLabel.h + * @brief This is the header file for the %Label class. + * + * This header file contains the declarations of the %Label class and its helper classes. + */ + +#ifndef _FUI_CTRL_LABEL_H_ +#define _FUI_CTRL_LABEL_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class Label + * @brief This class defines the common behavior of a %Label control. + * + * @since 2.0 + * + * The %Label class displays a non-editable text field and does not accept any input from the user. + * + * For more information on the class features, see Label. + * + * The following example demonstrates how to use the %Label class. + * + * @code +// Sample code for LabelSample.h +#include + +class LabelSample + : public Tizen::Ui::Controls::Form +{ +public: + LabelSample(void) + : __pLabel(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + +private: + Tizen::Ui::Controls::Label *__pLabel; +}; + * @endcode + * + * @code +// Sample code for LabelSample.cpp +#include + +#include "LabelSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +LabelSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +LabelSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Label + __pLabel = new Label(); + __pLabel->Construct(Rectangle(100, 100, 200, 50), L"Label Text"); + __pLabel->SetTextConfig(30, LABEL_TEXT_STYLE_BOLD); + __pLabel->SetBackgroundColor(Color::GetColor(COLOR_ID_BLUE)); + + // Adds the label to the form + AddControl(*__pLabel); + + return r; +} + * @endcode + * + */ +class _OSP_EXPORT_ Label + : public Tizen::Ui::Control +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + Label(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Label(void); + + /** + * Initializes this instance of %Label with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created window along with + * the width and height of the window. + * @param[in] text The text for this label instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully usable only after it has been added to a container, therefore some methods may fail if used earlier. + * To display text in multi-lines or to denote the end of line use '\\n'. @n + * The size of the control must be within the range defined by the minimum size and the maximum size. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, const Tizen::Base::String& text); + +public: + /** + * Sets the specified text for the %Label control. + * + * @since 2.0 + * + * @param[in] text The string to set + * @remarks To display text in multi-lines or to denote the end of line use '\\n'. + */ + void SetText(const Tizen::Base::String& text); + + /** + * Gets the text of the %Label control. + * + * @since 2.0 + * + * @return The text of the %Label control, @n + * else an empty string if an error occurs + */ + Tizen::Base::String GetText(void) const; + + /** + * Sets the background bitmap of the %Label control. + * + * @since 2.0 + * + * @param[in] bitmap The background bitmap + */ + void SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the horizontal alignment of the text of the %Label control. + * + * @since 2.0 + * + * @param[in] alignment The horizontal text alignment + */ + void SetTextHorizontalAlignment(HorizontalAlignment alignment); + + /** + * Gets the horizontal alignment of the text of the %Label control. + * + * @since 2.0 + * + * @return The horizontal text alignment, @n + * else @c ALIGNMENT_LEFT if the instance is invalid + */ + HorizontalAlignment GetTextHorizontalAlignment(void) const; + + /** + * Sets the vertical alignment of the text of the %Label control. + * + * @since 2.0 + * + * @param[in] alignment The vertical text alignment + */ + void SetTextVerticalAlignment(VerticalAlignment alignment); + + /** + * Gets the vertical alignment of the text of the %Label control. + * + * @since 2.0 + * + * @return The vertical text alignment, @n + * else @c ALIGNMENT_TOP if the instance is invalid + */ + VerticalAlignment GetTextVerticalAlignment(void) const; + + /** + * Sets the background color of the %Label control. + * + * @since 2.0 + * + * @param[in] color The normal background color + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * Gets the background color of the %Label control. + * + * @since 2.0 + * + * @return The background color + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + + /** + * Sets the text color of the %Label control. + * + * @since 2.0 + * + * @param[in] color The color to be set + */ + virtual void SetTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the text color of the %Label control. + * + * @since 2.0 + * + * @return The text color + */ + virtual Tizen::Graphics::Color GetTextColor(void) const; + + /** + * Sets the text attributes of the %Label control. + * + * @since 2.0 + * + * @param[in] size The size of the text + * @param[in] style The style of the text + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * If @c size is less than the minimum size, this method fails. The minimum font size is 6 on devices of high screen density. + */ + void SetTextConfig(int size, LabelTextStyle style); + + /** + * Gets the text size of the %Label control. + * + * @since 2.0 + * + * @return The size of the text, @n + * else @c -1 if an error occurs + */ + int GetTextSize(void) const; + + /** + * Gets the text style of the %Label control. + * + * @since 2.0 + * + * @return The style of the text, @n + * else @c LABEL_TEXT_STYLE_NORMAL if the instance is invalid + */ + LabelTextStyle GetTextStyle(void) const; + + /** + * Sets the top and left margins. + * + * @since 2.0 + * + * @return An error code + * @param[in] topMargin The top margin. + * @param[in] leftMargin The left margin. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c size must be greater than @c 0. + + * @see GetTopMargin(), GetLeftMargin() + */ + result SetMargin(int topMargin, int leftMargin); + + /** + * Gets the top margin. + * + * @since 2.0 + * + * @return The size of the top margin, @n + * else @c -1 if an error occurs + * @see SetMargin() + */ + int GetTopMargin(void) const; + + /** + * Gets the left margin. + * + * @since 2.0 + * + * @return The size of the left margin, @n + * else @c -1 if an error occurs. + * @see SetMargin() + */ + int GetLeftMargin(void) const; + +protected: + friend class _LabelImpl; + +private: + // + // This is the copy constructor for this class. + // + Label(const Label& rhs); + + // + // Assigns the value of the specified instance to the current instance of %Label. + // + Label& operator =(const Label& rhs); + +}; // Label + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_LABEL_H_ diff --git a/inc/FUiCtrlLabelTypes.h b/inc/FUiCtrlLabelTypes.h new file mode 100644 index 0000000..ef33afe --- /dev/null +++ b/inc/FUiCtrlLabelTypes.h @@ -0,0 +1,58 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlLabelTypes.h + * @brief This is the header file for the LabelTextStyle enumeration. + * + * This header file contains the declarations of the LabelTextStyle enumeration. + */ +#ifndef _FUI_CTRL_LABEL_ENUM_H_ +#define _FUI_CTRL_LABEL_ENUM_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + + /** + * @enum LabelTextStyle + * + * Defines the text styles of the label. + * + * @since 2.0 + */ +enum LabelTextStyle +{ + LABEL_TEXT_STYLE_NORMAL, /**< The plain text style */ + LABEL_TEXT_STYLE_BOLD, /**< The bold text style */ + LABEL_TEXT_STYLE_ITALIC, /**< The italic text style */ +}; + + /** + * @enum LabelContentHint + * + * Defines the content update type. + * + * @since 2.0 + */ +enum LabelContentHint +{ + LABEL_CONTENT_HINT_DYNAMIC, /**< The contents will change */ + LABEL_CONTENT_HINT_STATIC /**< The contents will not change */ +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_LABEL_ENUM_H_ diff --git a/inc/FUiCtrlList.h b/inc/FUiCtrlList.h new file mode 100644 index 0000000..7aeb2e4 --- /dev/null +++ b/inc/FUiCtrlList.h @@ -0,0 +1,961 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlList.h + * @brief This is the header file for the %List class. + * + * This header file contains the declarations of the %List class and its helper classes. + */ + +#ifndef _FUI_CTRL_LIST_H_ +#define _FUI_CTRL_LIST_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Tizen { namespace Base { namespace Runtime +{ +class IEvent; +}}} // Tizen::Base::Runtime + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if OSPDEPREC + * @class List + * @brief [Deprecated] This class defines the common behavior of the %List control. + * + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * The %List class defines the common behavior of the %List control. + * A list displays the user selection in the form of a list of items. When an item + * on the list is selected or deselected, an item event occurs. It is passed on to + * any item event listeners that have registered an interest in item events generated + * by this list. + * + * If an application wants to perform something based on a list being selected and + * deselected, it must realize IItemEventListener and register the listener to + * receive events from this list, by calling the list's AddItemEventListener() method. + * + * There are several styles supported with differences in the number of columns, rows and + * types of data that can be set. The Construct has a parameter for the size of + * all 4 aspects of a list item. If the item has less than 2 rows or 2 columns, you + * only need to specify the width and height information relevant to the style selected. + * Also, the check style causes some space to be taken up on the right side of the list + * item. The framework will try to make room for the check from the right-most column, + * so the actual width of each column may be different from what you have set. + * + * @image html ui_controls_list_construct.png + * + * If the application directly allocates resources, the resources must be deleted + * (for example, text or bitmap). + * + * Example: + * + * @image html ui_controls_list.png + * + * + * This is a simple UI application which uses a list control. + * + * + * @code +//Sample code for ListSample.h +#include + +class ListSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IItemEventListener +{ +public: + ListSample(void) + : __pList(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual void OnItemStateChanged(const Tizen::Ui::Control &source, int index, int itemId, Tizen::Ui::ItemStatus status); + +private: + static const int ID_LIST_FIRSTITEM = 101; + static const int ID_LIST_SECONDITEM = 102; + + Tizen::Ui::Controls::List* __pList; +}; + * @endcode + * + * @code +//Sample code for ListSample.cpp +#include + +#include "ListSample.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +ListSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +ListSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of List + __pList = new List(); + __pList->Construct(Rectangle(0, 0, GetClientAreaBounds().width, 500), + LIST_STYLE_NORMAL, LIST_ITEM_SINGLE_TEXT, 100, 0, GetClientAreaBounds().width, 0); + __pList->AddItemEventListener(*this); + + // Sets Strings + String itemText1(L"List Item 1"); + String itemText2(L"List Item 2"); + + // Adds the items to the list + __pList->AddItem(&itemText1, null, null, null, ID_LIST_FIRSTITEM); + __pList->AddItem(&itemText2, null, null, null, ID_LIST_SECONDITEM); + + // Adds the list to the form + AddControl(*__pList); + + return r; +} + +// IItemEventListener implementation +void +ListSample::OnItemStateChanged (const Tizen::Ui::Control &source, int index, int itemId, Tizen::Ui::ItemStatus status) +{ + switch (itemId) + { + case ID_LIST_FIRSTITEM: + { + // .... + } + break; + case ID_LIST_SECONDITEM: + { + // .... + } + break; + default: + break; + } +} + * @endcode + * @endif + */ +class _OSP_EXPORT_ List + : public Tizen::Ui::Control +{ +public: + /** + * @if OSPDEPREC + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * @endif + */ + List(void); + + /** + * @if OSPDEPREC + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * @endif + */ + virtual ~List(void); + + /** + * @if OSPDEPREC + * Initializes this instance of %List with the specified parameters. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created list along with + * the width and height of the list. + * @param[in] style The style set of the list + * @param[in] itemFormat The layout of the list items + * @param[in] row1Height The height of the first row + * @param[in] row2Height The height of the second row + * @param[in] column1Width The width of the first column + * @param[in] column2Width The width of the second column + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully usable only after it has been added to a container, therefore some methods may fail if used earlier. @n + * If the given size is less than the minimum size, %List is constructed with the minimum size. @n + * When, %List is constructed with LIST_STYLE_NUMBER style, the maximum number of items supported is @c 99. + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. + * @remarks The minimum size of this control is 92 x 72 on a WVGA screen, 60 x 48 on a HVGA screen and 46 x 36 on a WQVGA screen. + * @endif + */ + result Construct(const Tizen::Graphics::Rectangle& rect, ListStyle style, ListItemFormat itemFormat, int row1Height, int row2Height, int column1Width, int column2Width); + + /** + * @if OSPDEPREC + * Adds the specified listener instance. @n + * The added listener can listen to the item events when they are fired. Only an item event with the ITEM_SELECTED state is fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @endif + */ + void AddItemEventListener(Tizen::Ui::IItemEventListener& listener); + + /** + * @if OSPDEPREC + * Removes the specified listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @endif + */ + void RemoveItemEventListener(Tizen::Ui::IItemEventListener& listener); + + /** + * @if OSPDEPREC + * Adds the item to the current %List instance. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] pText1 A pointer to the first string + * @param[in] pText2 A pointer to the second string + * @param[in] pBitmap1 A pointer to the first normal bitmap + * @param[in] pBitmap2 A pointer to the second normal bitmap + * @param[in] itemId The itemId for this item + * @exception E_SUCCESS The method is successful. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_SYSTEM A system error has occurred. + * @remarks The contents of the specified texts and bitmaps are copied and kept by the list. + * If the size of the text exceeds the displayable area, the text will slide automatically when the list item is selected. + * @endif + */ + result AddItem(const Tizen::Base::String* pText1, const Tizen::Base::String* pText2, const Tizen::Graphics::Bitmap* pBitmap1, const Tizen::Graphics::Bitmap* pBitmap2, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Inserts the specified item to list, at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index at which the item is to be inserted + * @param[in] pText1 A pointer to the first string + * @param[in] pText2 A pointer to the second string + * @param[in] pBitmap1 A pointer to the first normal bitmap + * @param[in] pBitmap2 A pointer to the second normal bitmap + * @param[in] itemId The item ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than the item count. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_SYSTEM A system error has occurred. + * @remarks The contents of the specified texts and bitmaps are copied and kept by the list. + * If the size of the text exceeds the displayable area, the text will slide automatically when a list item is selected. + * @endif + */ + result InsertItemAt(int index, const Tizen::Base::String* pText1, const Tizen::Base::String* pText2, const Tizen::Graphics::Bitmap* pBitmap1, const Tizen::Graphics::Bitmap* pBitmap2, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Sets the contents of the specified item to list at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index at which the contents of the item is to be set + * @param[in] pText1 A pointer to the first string + * @param[in] pText2 A pointer to the second string + * @param[in] pBitmap1 A pointer to the first normal bitmap + * @param[in] pBitmap2 A pointer to the second normal bitmap + * @param[in] itemId The item ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than or equal to the item count. + * @exception E_SYSTEM A system error has occurred. + * @remarks The contents of the specified texts and bitmaps are copied and kept in the list. + * If the size of the text exceeds the displayable area, the text will slide automatically when a list item is selected. + * @endif + */ + result SetItemAt(int index, const Tizen::Base::String* pText1, const Tizen::Base::String* pText2, const Tizen::Graphics::Bitmap* pBitmap1, const Tizen::Graphics::Bitmap* pBitmap2, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Removes the item at the specified index of the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index at which the item is to be deleted + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than or equal to the item count. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RemoveItemAt(int index); + + /** + * @if OSPDEPREC + * Removes all the items of the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RemoveAllItems(void); + + /** + * @if OSPDEPREC + * Gets the item count of the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The number of items in the list + * @endif + */ + int GetItemCount(void) const; + + /** + * @if OSPDEPREC + * Sets the enabled status of the specified item of the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the list item for which status is to be set + * @param[in] enable Set to @c true to enable the item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetItemEnabled(int index, bool enable); + + /** + * @if OSPDEPREC + * Checks whether the specified item is enabled. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return @c true if the item is enabled, @n + * else @c false + * @param[in] index The index of the list item + * @endif + */ + bool IsItemEnabled(int index) const; + + /** + * @if OSPDEPREC + * Sets the background bitmap image of the focused item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] bitmap The background bitmap of the focused item + * @endif + */ + void SetFocusedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * @if OSPDEPREC + * Sets the highlighted background image on the rectangle of each list item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] bitmap The background image + * @remarks When a user navigates a user interface with directional keys, the selected UI control is highlighted and takes the focus. + * @endif + */ + void SetHighlightedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * @if OSPDEPREC + * Sets the background image on the rectangle of each list item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] bitmap The background image + * @endif + */ + void SetNormalItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * @if OSPDEPREC + * Gets the index of the top-drawn item of the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the top-drawn item + * @endif + */ + int GetTopDrawnItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the index of the bottom-drawn item of the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the bottom-drawn item + * @endif + */ + int GetBottomDrawnItemIndex(void) const; + + /** + * @if OSPDEPREC + * Sets the text to be displayed when the list is empty. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] text The text message to be displayed + * @endif + */ + void SetTextOfEmptyList(const Tizen::Base::String& text); + + /** + * @if OSPDEPREC + * Sets the color of the text that is displayed when the list is empty. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] color The color of the text for an empty List + * @endif + */ + void SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Gets the color of the empty text that is displayed when the list is empty. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The empty text color, @n + * else RGBA(0, 0, 0, 0) if the instance is invalid + * @endif + */ + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + /** + * @if OSPDEPREC + * Sets the background color of this control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] color The background color + * @endif + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Sets the item text color. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] textIndex The index of the text + * @param[in] textColor The color of the text + * @endif + */ + void SetItemTextColor(ListItemText textIndex, const Tizen::Graphics::Color& textColor); + + /** + * @if OSPDEPREC + * Gets the text color of item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The item text color + * @param[in] textIndex The index of the text, @n + * else RGBA(0, 0, 0, 0) if the instance is invalid + * @endif + */ + Tizen::Graphics::Color GetItemTextColor(ListItemText textIndex) const; + + /** + * @if OSPDEPREC + * Enables the text slide. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] textIndex The text index of the list item format to slide + * @remarks If text slide is enabled, the texts which are too long to fit in the given list item slide show the remnant contents when a user touches + * the item for a long time. + * @endif + */ + void EnableTextSlide(ListItemText textIndex); + + /** + * @if OSPDEPREC + * Disables the text sliding. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * @endif + */ + void DisableTextSlide(void); + + /** + * @if OSPDEPREC + * Gets the height of the list item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The height of the item + * @endif + */ + int GetItemHeight(void) const; + + /** + * @if OSPDEPREC + * Gets the row1 height of the current list + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The row1 height of the item + * @endif + */ + int GetRow1Height(void) const; + + /** + * @if OSPDEPREC + * Gets the row2 height of the current list + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The row2 height of the item + * @endif + */ + int GetRow2Height(void) const; + + /** + * @if OSPDEPREC + * Gets the column1 width of the current list + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The column1 width of the item + * @endif + */ + int GetColumn1Width(void) const; + + /** + * @if OSPDEPREC + * Gets the column2 width of the current list + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The column2 width of the item + * @endif + */ + int GetColumn2Width(void) const; + + /** + * @if OSPDEPREC + * Sets the row1 height of the current List + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] row1Height The row1 height of the list item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks In logical pixels, the minimum height of the rows is 48. + * @endif + */ + result SetRow1Height(int row1Height); + + /** + * @if OSPDEPREC + * Sets the row2 height of the current list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] row2Height The row2 height of the list item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks In logical pixels, the minimum height of the rows is 48. + * @endif + */ + result SetRow2Height(int row2Height); + + /** + * @if OSPDEPREC + * Sets the column1 width of the current %List + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] column1Width The column1 width of the list item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetColumn1Width(int column1Width); + + /** + * @if OSPDEPREC + * Sets the column2 width of the current %List + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] column2Width The column2 width of the list item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetColumn2Width(int column2Width); + + /** + * @if OSPDEPREC + * Sets the check status of the specified item of the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the list + * @param[in] check The check status + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * + * @remarks This method can only be used when the style of the list allows selection. + * @endif + */ + result SetItemChecked(int index, bool check); + + /** + * @if OSPDEPREC + * Checks whether the specified item of the list is checked. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return @c true if the item is checked, @n + * else @c false + * @param[in] index The index of the list item + * + * @remarks This method can only be used when the style of the list allows selection. + * @endif + */ + bool IsItemChecked(int index) const; + + /** + * @if OSPDEPREC + * Sets the checked status of all the items of the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] check Set to @c true to check all the items, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + result SetAllItemsChecked(bool check); + + /** + * @if OSPDEPREC + * Removes all the checked items of the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + result RemoveAllCheckedItems(void); + + /** + * @if OSPDEPREC + * Gets the index of the first checked item from the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the first checked item + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + int GetFirstCheckedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the index of the last checked item from the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the last checked item + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + int GetLastCheckedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the index of the next checked item after the specified index from the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the next checked item + * @param[in] index The index of the item + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + int GetNextCheckedItemIndexAfter(int index) const; + + /** + * @if OSPDEPREC + * Gets the index of the item with the specified item ID. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the item + * @param[in] itemId The item ID of the list + * @remarks The method returns -1 when there is no list item with the specified item ID. + * @endif + */ + int GetItemIndexFromItemId(int itemId) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified item position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if there is no list item at the specified position + * @param[in] x The x position of the point + * @param[in] y The y position of the point + * @endif + */ + int GetItemIndexFromPosition(int x, int y) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified item position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if there is no list item at the specified position + * @param[in] position The position of the point + * @endif + */ + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + + /** + * @if OSPDEPREC + * Gets the item ID of the item at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The ID of the item, @n + * else @c -1 if there is no list item at the specified index + * @param[in] index The index of the list item + * @endif + */ + int GetItemIdAt(int index) const; + + /** + * @if OSPDEPREC + * Scrolls to the bottom of the List. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * @endif + */ + void ScrollToBottom(void); + + /** + * @if OSPDEPREC + * Scrolls to the top of the List. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * @endif + */ + void ScrollToTop(void); + + /** + * @if OSPDEPREC + * Scrolls to the item at the specified index. @n + * The specified item is drawn at the top of the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the list item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @endif + */ + result ScrollToTop(int index); + + /** + * @if OSPDEPREC + * Draws and shows the item of the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the list item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @endif + */ + result RefreshItem(int index); + + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + List(const List& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + List& operator =(const List& rhs); + + friend class _ListImpl; +}; //List + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_LIST_H_ diff --git a/inc/FUiCtrlListContextItem.h b/inc/FUiCtrlListContextItem.h new file mode 100644 index 0000000..d6b5bf4 --- /dev/null +++ b/inc/FUiCtrlListContextItem.h @@ -0,0 +1,191 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlListContextItem.h + * @brief This is the header file for the %ListContextItem class. + * + * This header file contains the declarations of the %ListContextItem class and its helper classes. + */ + +#ifndef _FUI_CTRL_LIST_CONTEXT_ITEM_H_ +#define _FUI_CTRL_LIST_CONTEXT_ITEM_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ListContextItemImpl; + +/** + * @class ListContextItem + * @brief This class defines common behavior for %ListContextItem. + * + * @since 2.0 + * + * The %ListContextItem class displays the context item for a ListView or GroupedListView. + * + * For more information on the class features, see ListViews. + */ + +class _OSP_EXPORT_ ListContextItem + : public Tizen::Base::Object +{ +public: + /** + * The object is not fully constructed after this constructor is + * called. For full construction, the Construct() method must be + * called right after calling this constructor. + * + * @since 2.0 + */ + ListContextItem(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~ListContextItem(void); + + /** + * Initializes this instance of %ListContextItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(void); + + /** + * Adds the text element to the context item. + * + * @since 2.0 + * + * @return An error code + * @param[in] elementId The ID of the element + * @param[in] text The text to display + * @param[in] enable Set to @c true, to enable this element @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result AddElement(int elementId, const Tizen::Base::String& text, bool enable = true); + + /** + * Adds the bitmap element to the context item. + * + * @since 2.0 + * @return An error code + * @param[in] elementId The ID of the element + * @param[in] normalBitmap The bitmap displayed when the item is in normal status + * @param[in] pressedBitmap The bitmap displayed when the item is pressed + * @param[in] pHighlightedBitmap The bitmap displayed when the item is highlighted + * @param[in] enable Set to @c true, to enable this element, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result AddElement(int elementId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap& pressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap = null, bool enable = true); + + /** + * Adds the text and the bitmap element to the context item. + * + * @since 2.0 + * + * @return An error code + * @param[in] elementId The ID of the element + * @param[in] text The text to display + * @param[in] normalBitmap The bitmap displayed when the item is in normal status + * @param[in] pressedBitmap The bitmap displayed when the item is pressed + * @param[in] pHighlightedBitmap The bitmap displayed when the item is highlighted + * @param[in] enable Set to @c true, to enable this element, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result AddElement(int elementId, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap& pressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap = null, bool enable = true); + + /** + * Sets the background image of a context item. + * + * @since 2.0 + * + * @return An error code + * @param[in] pBitmap The background bitmap image + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, only + * the bitmap is displayed. @n + * When @c pBitmap is set as @c null, the background color of the context item is drawn. + */ + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + /** + * Sets the background color of a context item. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The background color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, only + * the bitmap is displayed. + */ + result SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * Gets the background color of a context item. + * + * @since 2.0 + * + * @return The background color of a context item + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + +protected: + friend class _ListContextItemImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + ListContextItem(const ListContextItem& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + ListContextItem& operator =(const ListContextItem& rhs); + +private: + _ListContextItemImpl* __pImpl; +}; // ListContextItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_LIST_CONTEXT_ITEM_H_ + diff --git a/inc/FUiCtrlListItemBase.h b/inc/FUiCtrlListItemBase.h new file mode 100644 index 0000000..2790b09 --- /dev/null +++ b/inc/FUiCtrlListItemBase.h @@ -0,0 +1,230 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlListItemBase.h + * @brief This is the header file for the %ListItemBase class. + * + * This header file contains the declarations of the %ListItemBase class and its helper classes. + */ + +#ifndef _FUI_CTRL_LIST_ITEM_BASE_H_ +#define _FUI_CTRL_LIST_ITEM_BASE_H_ + +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ListItemBaseImpl; + +/** + * @class ListItemBase + * @brief This class defines common behavior for a %ListItemBase. + * + * @since 2.0 + * + * The %ListItemBase class is a base class, which represents a list item which is the unit of handling of the ListView or + * GroupedListView classes. + * + * For more information on the class features, see ListViews. + */ + +class _OSP_EXPORT_ ListItemBase + : public Tizen::Base::Object +{ +public: + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~ListItemBase(void); + + /** + * Sets the background image of the item which is displayed when the item is in specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The item drawing state + * @param[in] pBitmap The background bitmap image + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, + * only the bitmap is displayed. + */ + result SetBackgroundBitmap(ListItemDrawingStatus status, const Tizen::Graphics::Bitmap* pBitmap); + + /** + * Sets the background color of the item which is displayed when the item is in specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The item drawing state + * @param[in] color The background color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, only the bitmap is displayed. @n + * The background color of the item is not applied when the item is inserted into the GroupedListView of section style. + */ + result SetBackgroundColor(ListItemDrawingStatus status, const Tizen::Graphics::Color& color); + + /** + * Gets the background color of the item that is displayed when the item is in the specified state. + * + * @since 2.0 + * + * @return The background color of the item + * @param[in] status The item drawing state, @n + * else RGBA(0, 0, 0, 0) if an error has occurs + * @see SetBackgroundColor() + */ + Tizen::Graphics::Color GetBackgroundColor(ListItemDrawingStatus status) const; + + /** + * Sets ContextItem that is displayed when an item is swept. + * + * @since 2.0 + * + * @return An error code + * @param[in] pItem The %ListContextItem instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If the context item is not set, ListView() or GroupedListView() does not display the context item and an item sweep event is generated when an + * item is swept. @n + * The specified @c pItem should be deleted by the applications when it is no longer used. + */ + result SetContextItem(const ListContextItem* pItem); + + /** + * Sets the description text. + * + * @since 2.0 + * + * @return An error code + * @param[in] text Description text + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetDescriptionText(const Tizen::Base::String& text); + + /** + * Sets the color of the description text. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color of the description text + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetDescriptionTextColor(const Tizen::Graphics::Color& color); + + /** + * Sets the progress value of a list item. + * + * @since 2.0 + * + * @return An error code + * @param[in] value The progress value of the list item @n + * The valid values are integers from @c 0 to @c 100. + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetProgressValue(int value); + + /** + * Sets the margin of the progress bar. + * + * @since 2.0 + * + * @return An error code + * @param[in] leftMargin The left margin of the progress bar + * @param[in] rightMargin The right margin of the progress bar + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetProgressMargins(int leftMargin, int rightMargin); + + /** + * Gets the width of the annex area. + * + * @since 2.0 + * + * @return The width of the annex + * @param[in] style The style of the annex + * @remarks The width of the annex area is different among annex styles. + */ + static int GetAnnexWidth(ListAnnexStyle style); + +protected: + friend class _ListItemBaseImpl; + +protected: + // + // This default constructor is intentionally declared as private so that only the platform can create an instance. + // @since 2.0 + // + ListItemBase(void); + + // + // Initializes this instance of ListItem with the specified parameter. + // + // @since 2.0 + // + // @return An error code + // + // @param[in] itemSize The size of the item + // @param[in] style The style of Annex + // @exception E_SUCCESS The method is successful. + // @exception E_SYSTEM A system error has occurred. + // + result Construct(const Tizen::Graphics::Dimension& itemSize, ListAnnexStyle style); + + // + // The following methods are reserved and may change its name at any time without prior notice. + // + virtual void ListItemBase_Reserved1(void) {} + virtual void ListItemBase_Reserved2(void) {} + virtual void ListItemBase_Reserved3(void) {} + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + ListItemBase(const ListItemBase& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + ListItemBase& operator =(const ListItemBase& rhs); + +protected: + _ListItemBaseImpl* _pImpl; +}; // ListItemBase + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_LIST_ITEM_BASE_H_ diff --git a/inc/FUiCtrlListTypes.h b/inc/FUiCtrlListTypes.h new file mode 100644 index 0000000..617b945 --- /dev/null +++ b/inc/FUiCtrlListTypes.h @@ -0,0 +1,127 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlListTypes.h + * @brief This is the header file for the List enumerations. + * + * This header file contains the declarations of the List enumerations. + */ +#ifndef _FUI_CTRL_LIST_TYPES_H_ +#define _FUI_CTRL_LIST_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +// +//This integer is for internal use only. Using this integer can cause behavioral, security-related, +//and consistency-related issues in the application. +// +static const int LIST_ITEM_NOTFOUND = 0; + +/** + * The integer value that represents the unspecified item ID + * + * @since 2.0 + */ +static const int LIST_ITEM_UNSPECIFIED_ID = -1; + +/** + * @if OSPDEPREC + * @enum ListStyle + * + * Defines the list style. + * + * @brief [Deprecated] + * @deprecated This enumeration is deprecated. Instead of using this enumeration, use ListAnnexStyle enumeration for CustomItem or SimpleItem class. @n + * @since 2.0 + * @endif + */ +enum ListStyle +{ + LIST_STYLE_NORMAL = 0, /**< @if OSPDEPREC The normal style @endif */ + LIST_STYLE_NUMBER, /**< @if OSPDEPREC The numbered style @endif */ + LIST_STYLE_RADIO, /**< @if OSPDEPREC The radio style for single selection @endif */ + LIST_STYLE_RADIO_WITH_DIVIDER, /**< @if OSPDEPREC The radio style with divider for single selection @endif */ + LIST_STYLE_MARK, /**< @if OSPDEPREC The mark style for multiple selection @endif */ + LIST_STYLE_MARK_WITH_DIVIDER, /**< @if OSPDEPREC The mark style with divider for multiple selection @endif */ + LIST_STYLE_ONOFF, /**< @if OSPDEPREC The On/Off style @endif */ + LIST_STYLE_ONOFF_WITH_DIVIDER /**< @if OSPDEPREC The On/Off style with divider @endif */ +}; + +/** + * @if OSPDEPREC + * @enum ListItemFormat + * + * Defines the list item format. + * + * @brief [Deprecated] + * @deprecated This enumeration is deprecated. There is no need to use this enumeration. @n + * @since 2.0 + * @endif + */ +enum ListItemFormat +{ + LIST_ITEM_SINGLE_IMAGE = 0, /**< @if OSPDEPREC The single line of image @endif */ + LIST_ITEM_SINGLE_TEXT, /**< @if OSPDEPREC The single line of text @endif */ + LIST_ITEM_SINGLE_IMAGE_TEXT, /**< @if OSPDEPREC The single line of image, and text @endif */ + LIST_ITEM_SINGLE_TEXT_IMAGE, /**< @if OSPDEPREC The single line of text, and image @endif */ + LIST_ITEM_SINGLE_IMAGE_TEXT_IMAGE, /**< @if OSPDEPREC The single line of image, text, and image @endif */ + LIST_ITEM_DOUBLE_IMAGE_TEXT_FULLTEXT, /**< @if OSPDEPREC The 1st line of image and text, 2nd line of text @endif */ + LIST_ITEM_DOUBLE_FULLTEXT_IMAGE_TEXT, /**< @if OSPDEPREC The 1st line of text, 2nd line of image, and text @endif */ + LIST_ITEM_DOUBLE_TEXT_IMAGE_FULLTEXT, /**< @if OSPDEPREC The 1st line of text and image, 2nd line of text @endif */ + LIST_ITEM_DOUBLE_FULLTEXT_TEXT_IMAGE, /**< @if OSPDEPREC The 1st line of text, 2nd line of text, and image @endif */ + LIST_ITEM_DOUBLE_IMAGE_TEXT_TEXT, /**< @if OSPDEPREC A big image followed by two lines of text @endif */ + LIST_ITEM_DOUBLE_TEXT_TEXT_IMAGE /**< @if OSPDEPREC The two lines of text followed by a big image @endif */ +}; + +/** + * @if OSPDEPREC + * @enum ListItemText + * + * Defines the option of text slide. + * + * @brief [Deprecated] + * @deprecated This enumeration is deprecated. There is no need to use this enumeration. @n + * @since 2.0 + * @endif + */ +enum ListItemText +{ + LIST_ITEM_TEXT1, /**< @if OSPDEPREC The sliding of 1st text is switched on @endif */ + LIST_ITEM_TEXT2 /**< @if OSPDEPREC The sliding of 2nd text is switched on @endif */ +}; + +/** + * @if OSPDEPREC + * @enum FastScrollIndexDigit + * + * Defines the number of digits or characters of the fast scroll index. + * + * @brief [Deprecated] + * @deprecated This enumeration is deprecated. There is no need to use this enumeration. @n + * @since 2.0 + * @endif + */ +enum FastScrollIndexDigit +{ + SCROLL_INDEX_DIGIT_NUM_1, /**< @if OSPDEPREC The number of digits or characters of the index is 1 @endif */ + SCROLL_INDEX_DIGIT_NUM_2 /**< @if OSPDEPREC The number of digits or characters of the index is 2 @endif */ +}; + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_LIST_TYPES_H_ diff --git a/inc/FUiCtrlListView.h b/inc/FUiCtrlListView.h new file mode 100644 index 0000000..e8000e1 --- /dev/null +++ b/inc/FUiCtrlListView.h @@ -0,0 +1,885 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlListView.h + * @brief This is the header file for the %ListView class. + * + * This header file contains the declarations of the %ListView class and its helper classes. + */ + +#ifndef _FUI_CTRL_LIST_VIEW_H_ +#define _FUI_CTRL_LIST_VIEW_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ListViewImpl; + +/** + * @class ListView + * @brief This class defines common behavior for a %ListView control. + * + * @since 2.0 + * + * The %ListView class displays a list of simple and user-configured items. A simple item has a fixed layout consisting of a bitmap + * and a text string. A user-configured item in a %ListView instance can have a different layout and height than the other items. + * Each user-configured item is composed of elements that can be texts and bitmaps, and is configured using the CustomItem class. + * + * For more information on the class features, see ListViews. + * + * The following example demonstrates how to use the %ListView class. + * + * + * @code +//Sample code for ListViewSample.h +#include + +class ListViewSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider +{ +public: + ListViewSample(void) + : __pListView(null) + , __pItemContext(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // IListViewItemEventListener + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView &listView, int index, Tizen::Ui::Controls::SweepDirection direction); + + // IListViewItemProvider + virtual Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth); + virtual int GetItemCount(void); + +private: + static const int ID_FORMAT_STRING = 100; + static const int ID_FORMAT_BITMAP = 101; + static const int ID_CONTEXT_ITEM_1 = 103; + static const int ID_CONTEXT_ITEM_2 = 104; + + Tizen::Graphics::Bitmap* __pHome; + Tizen::Graphics::Bitmap* __pMsg; + Tizen::Graphics::Bitmap* __pAlarm; + Tizen::Graphics::Bitmap* __pCall; + + Tizen::Ui::Controls::ListView* __pListView; + Tizen::Ui::Controls::ListContextItem* __pItemContext; +}; + * @endcode + * + * @code +//Sample code for ListViewSample.cpp +#include +#include + +#include "ListViewSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui::Controls; + +bool +ListViewSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +ListViewSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of ListView + __pListView = new ListView(); + __pListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), true, false); + __pListView->SetItemProvider(*this); + __pListView->AddListViewItemEventListener(*this); + + // Adds the list view to the form + AddControl(*__pListView); + + // Creates an instance of ListContextItem + __pItemContext = new ListContextItem(); + __pItemContext->Construct(); + __pItemContext->AddElement(ID_CONTEXT_ITEM_1, L"Test1"); + __pItemContext->AddElement(ID_CONTEXT_ITEM_2, L"Test2"); + + // Gets instances of Bitmap + AppResource* pAppResource = Application::GetInstance()->GetAppResource(); + __pHome = pAppResource->GetBitmapN(L"tizen.png"); + __pMsg = pAppResource->GetBitmapN(L"tizen.png"); + __pAlarm = pAppResource->GetBitmapN(L"tizen.png"); + __pCall = pAppResource->GetBitmapN(L"tizen.png"); + + return r; +} + +result +ListViewSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates bitmaps + delete __pHome; + delete __pMsg; + delete __pAlarm; + delete __pCall; + + // Deallocates the item context + delete __pItemContext; + + return r; +} + +// IListViewItemEventListener implementation +void +ListViewSample::OnListViewItemStateChanged(ListView &listView, int index, int elementId, ListItemStatus status) +{ + switch (elementId) + { + case ID_FORMAT_BITMAP: + { + // .... + } + break; + case ID_FORMAT_STRING: + { + // .... + } + break; + default: + break; + } +} + +void +ListViewSample::OnListViewContextItemStateChanged(ListView &listView, int index, int elementId, ListContextItemStatus state) +{ + switch (elementId) + { + case ID_CONTEXT_ITEM_1: + { + // .... + } + break; + case ID_CONTEXT_ITEM_2: + { + // .... + } + break; + default: + break; + } +} + +void +ListViewSample::OnListViewItemSwept(ListView &listView, int index, SweepDirection direction) +{ + // .... +} + +// IListViewItemProvider implementation +ListItemBase* +ListViewSample::CreateItem(int index, int itemWidth) +{ + // Creates an instance of CustomItem + CustomItem* pItem = new CustomItem(); + ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; + + switch (index % 4) + { + case 0: + { + style = LIST_ANNEX_STYLE_NORMAL; + pItem->Construct(Dimension(itemWidth,112), style); + pItem->AddElement(Rectangle(10, 20, 60, 60), ID_FORMAT_BITMAP, *__pHome, null, null); + pItem->AddElement(Rectangle(80, 25, 150, 50), ID_FORMAT_STRING, L"Home", true); + } + break; + case 1: + { + style = LIST_ANNEX_STYLE_DETAILED; + pItem->Construct(Dimension(itemWidth,112), style); + pItem->AddElement(Rectangle(10, 20, 60, 60), ID_FORMAT_BITMAP, *__pMsg, null, null); + pItem->AddElement(Rectangle(80, 25, 150, 50), ID_FORMAT_STRING, L"Msg", true); + } + break; + case 2: + { + style = LIST_ANNEX_STYLE_ONOFF_SLIDING; + pItem->Construct(Dimension(itemWidth,112), style); + pItem->AddElement(Rectangle(10, 20, 60, 60), ID_FORMAT_BITMAP, *__pAlarm, null, null); + pItem->AddElement(Rectangle(80, 25, 150, 50), ID_FORMAT_STRING, L"Alarm", true); + } + break; + case 3: + { + style = LIST_ANNEX_STYLE_MARK; + pItem->Construct(Dimension(itemWidth,112), style); + pItem->AddElement(Rectangle(10, 20, 60, 60), ID_FORMAT_BITMAP, *__pCall, null, null); + pItem->AddElement(Rectangle(80, 25, 150, 50), ID_FORMAT_STRING, L"Call", true); + } + break; + default: + break; + } + + pItem->SetContextItem(__pItemContext); + + return pItem; +} + +bool +ListViewSample::DeleteItem(int index, ListItemBase* pItem, int itemWidth) +{ + delete pItem; + pItem = null; + return true; +} + +int +ListViewSample::GetItemCount(void) +{ + return 15; +} + * @endcode + * + */ +class _OSP_EXPORT_ ListView + : public Tizen::Ui::Control +{ +public: + /** + * The object is not fully constructed after this constructor is + * called. For full construction, the Construct() method must be + * called right after calling this constructor. + * + * @since 2.0 + */ + ListView(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~ListView(void); + + /** + * @if OSPDEPREC + * Initializes this instance of %ListView with the specified parameters. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the left top corner of the created %ListView along with the width + * and height. + * @param[in] itemDivider Set to @c true to display an item divider, @n + * else @c false + * @param[in] fastScroll Set to @c true to use fast scroll, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * Either the @c rect.width or @c rect.height parameter has a negative value. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result Construct(const Tizen::Graphics::Rectangle& rect, bool itemDivider = true, bool fastScroll = false); + + /** + * Initializes this instance of %ListView with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the left top corner of the created %ListView along with the width + * and height. + * @param[in] itemDivider Set to @c true to display an item divider, @n + * else @c false + * @param[in] scrollStyle Set to scroll style + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * Either the @c rect.width or @c rect.height parameter has a negative value. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, bool itemDivider, ListScrollStyle scrollStyle); + + /** + * Sets the item provider that creates and deletes items for the list. + * + * @since 2.0 + * + * @return An error code + * @param[in] provider The item provider to create and delete items + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks If an item provider is not set for the list, the list does not work. @n + * The specified @c provider should be allocated in heap memory. + */ + result SetItemProvider(IListViewItemProvider& provider); + + + /** + * Adds a listener instance that listens to state changes of list view items. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to add + */ + void AddListViewItemEventListener(IListViewItemEventListener& listener); + + /** + * Removes a listener instance that listens to state changes of list view items. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to remove + */ + void RemoveListViewItemEventListener(IListViewItemEventListener& listener); + + /** + * Adds a listener instance that listens to state changes of a fast scroll. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to add + */ + void AddFastScrollListener(IFastScrollListener& listener); + + /** + * Removes a listener instance that listens to state changes of a fast scroll. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to remove + */ + void RemoveFastScrollListener(IFastScrollListener& listener); + + /** + * Adds a listener instance that listens to state changes of a scroll event. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to add + * @see IScrollEventListener::OnScrollEndReached() + * @see RemoveScrollEventListener() + */ + void AddScrollEventListener(IScrollEventListener& listener); + + /** + * Removes a listener instance that listens to state changes of a scroll event. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to remove + * @see IScrollEventListener::OnScrollEndReached() + * @see AddScrollEventListener() + */ + void RemoveScrollEventListener(IScrollEventListener& listener); + + /** + * Adds a link event listener. + * + * @since 2.0 + * + * @param[in] listener The event listener to add + * @remarks The added listener is notified when a link is selected by the user. + * @see RemoveUiLinkEventListener() + */ + void AddUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + /** + * Removes the specified link event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to remove + * @see AddUiLinkEventListener() + */ + void RemoveUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + /** + * Sets the sweep event to enable. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Set to @c true to enable the sweep, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetSweepEnabled(bool enable); + + /** + * Sets the index list of the scroll by texts. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text of the index + * @param[in] useSearchIcon Set to @c true to show the magnifying icon, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + */ + result SetFastScrollIndex(const Tizen::Base::String& text, bool useSearchIcon); + + /** + * Gets the index of the top drawn item of the %ListView control. + * + * @since 2.0 + * + * @return The index of the top drawn item + */ + int GetTopDrawnItemIndex(void) const; + + /** + * Gets the index of the bottom drawn item of the %ListView control. + * + * @since 2.0 + * + * @return The index of the bottom drawn item + */ + int GetBottomDrawnItemIndex(void) const; + + /** + * Scrolls to the item at the specified index. @n + * The specified item is drawn at the top of the %ListView control. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result ScrollToItem(int index); + + /** + * Scrolls to the item at the specified index. @n + * The specified item is drawn at the position specified by the item alignment. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The item index + * @param[in] itemAlignment The item alignment + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result ScrollToItem(int index, ListScrollItemAlignment itemAlignment); + + /** + * Sets the check status of the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The item index + * @param[in] check The check status + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The item is disabled. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemChecked(int index, bool check); + + /** + * Checks whether the item at the specified index is checked. + * + * @since 2.0 + * + * @return @c true if the item is checked, @n + * else @c false + * @param[in] index The item index + */ + bool IsItemChecked(int index) const; + + /** + * Sets the enabled/disabled status of the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The item index + * @param[in] enable The enabled/disabled status + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * + */ + result SetItemEnabled(int index, bool enable); + + /** + * Checks whether the item at the specified index is enabled. + * + * @since 2.0 + * + * @return @c true if the item is enabled, @n + * else @c false + * @param[in] index The item index + */ + bool IsItemEnabled(int index) const; + + /** + * Counts the number of items. + * + * @since 2.0 + * + * @return The total number of items + */ + int GetItemCount(void) const; + + /** + * Shows the description text of the given item. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If no description text is set to the item of the specified index, this method does not show the description text. + * + */ + result ShowItemDescriptionText(int index); + + /** + * Hides the description text of the given item. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result HideItemDescriptionText(int index); + + /** + * Refreshes the specified item. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The item index + * @param[in] type The item to be added, removed, or modified + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + * @remarks 3 refresh types are supported: LIST_REFRESH_TYPE_ITEM_ADD, LIST_REFRESH_TYPE_ITEM_REMOVE, and LIST_REFRESH_TYPE_ITEM_MODIFY. + * - LIST_REFRESH_TYPE_ITEM_ADD is used when new data is added to the data model. @n + * - LIST_REFRESH_TYPE_ITEM_REMOVE is used when a data is deleted from the data model. @n + * - LIST_REFRESH_TYPE_ITEM_MODIFY is used when an existing data has changes and needs to be updated. @n + * Calling this method with LIST_REFRESH_TYPE_ITEM_MODIFY invokes the item provider to call DeleteItem() and CreateItem() for the given index in + * sequence. + * @remarks This method internally calls Invalidate(), so you do not need to call them to update the screen. + */ + result RefreshList(int index, ListRefreshType type); + + /** + * Refreshes the specified item's element. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The item index + * @param[in] elementId The item element ID + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method internally calls Invalidate(), so you do not need to call them to update the screen. + */ + result RefreshList(int index, int elementId); + + /** + * Updates the whole items of a list. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method clears the items in the list and re-invokes the methods of the item provider to fill the list. + */ + result UpdateList(void); + + /** + * Gets the index of the item at the specified position. + * + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if there is no list item at the specified position + * @param[in] x The X position of the point + * @param[in] y The Y position of the point + * @remarks The method returns -1 when there is no list item at the specified position. + */ + int GetItemIndexFromPosition(int x, int y) const; + + /** + * Gets the index of the item at the specified position. + * + * @since 2.0 + * + * @return The index of the item + * @param[in] position The position of the point, @n + * else @c -1 if there is no list item at the specified position + */ + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + + /** + * Gets the index of the item and ID of the element at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] x The X position of the item + * @param[in] y The Y position of the item + * @param[out] itemIndex The index of the item + * @param[out] elementId The ID of the element + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred, or @n + * there is no item at the specified position. + * @remarks The specified @c itemIndex is -1 when there is no list item at the specified position. + * @remarks The specified @c elementId is -1 when there is no element at the specified position. + */ + result GetItemIndexFromPosition(int x, int y, int& itemIndex, int& elementId) const; + + /** + * Gets the index of the item and ID of the element at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position of the point + * @param[out] itemIndex The index of the item + * @param[out] elementId The ID of the element + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred, or @n + * there is no item at the specified position. + * @remarks The specified @c itemIndex is -1 when there is no list item at the specified position. + * @remarks The specified @c elementId is -1 when there is no element at the specified position. + */ + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& itemIndex, int& elementId) const; + + /** + * Sets the color of a division line between items. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The division line color + * @exception E_SUCCESS The method is successful. + */ + result SetItemDividerColor(const Tizen::Graphics::Color& color); + + /** + * Gets the color of a division line between items. + * + * @since 2.0 + * + * @return The color of a section, @n + * else RGBA(0, 0, 0, 0) if the instance is invalid + */ + Tizen::Graphics::Color GetItemDividerColor(void) const; + + /** + * Sets the background color of this control. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The background color + * @exception E_SUCCESS The method is successful. + * @remarks The method sets the alpha value of the specified @c color to @c 255, when a device does not support 32bit color space. @n + * The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, only + * the bitmap image is displayed. + */ + result SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * Gets the background color of this control. + * + * @since 2.0 + * + * @return The background color, @n + * else RGBA(0, 0, 0, 0) if the instance is invalid + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + + /** + * Sets the bitmap of this control. + * + * @since 2.0 + * + * @return An error code + * @param[in] pBitmap The bitmap for the list + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + /** + * Sets the bitmap of the empty list. + * + * @since 2.0 + * + * @return An error code + * @param[in] pBitmap The bitmap for the empty list + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetBitmapOfEmptyList(const Tizen::Graphics::Bitmap* pBitmap); + + /** + * Sets the text of the empty list. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text for the empty list + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTextOfEmptyList(const Tizen::Base::String& text); + + /** + * Gets the text to display when there is no item in a list. + * + * @since 2.0 + * + * @return The text to display, @n + * else an empty string if the instance is invalid + */ + Tizen::Base::String GetTextOfEmptyList(void) const; + + /** + * Sets a color of the text to display when there is no item in a list. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color of the text to display + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + /** + * Gets a color of the text to display when there is no item in a list. + * + * @since 2.0 + * + * @return The color of the text to display + */ + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + /** + * Begins the reordering mode. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see IListViewItemEventListener::OnListViewItemReordered() + */ + result BeginReorderingMode(void); + + /** + * Ends the reordering mode. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see IListViewItemEventListener::OnListViewItemReordered() + */ + result EndReorderingMode(void); + + /** + * Checks whether the %ListView control is in reordering mode. + * + * @since 2.0 + * + * @return @c true if the %ListView is in reordering mode, @n + * else @c false + */ + bool IsInReorderingMode(void) const; + +protected: + friend class _ListViewImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + ListView(const ListView& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + ListView& operator =(const ListView& rhs); +}; // ListView + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_LIST_VIEW_H_ diff --git a/inc/FUiCtrlListViewTypes.h b/inc/FUiCtrlListViewTypes.h new file mode 100644 index 0000000..9c51fe5 --- /dev/null +++ b/inc/FUiCtrlListViewTypes.h @@ -0,0 +1,147 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlListViewTypes.h + * @brief This is the header file for the List enumerations. + * + * This header file contains the declarations of the List enumerations. + */ +#ifndef _FUI_CTRL_LIST_VIEW_TYPES_H_ +#define _FUI_CTRL_LIST_VIEW_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum ListAnnexStyle + * + * Defines the style of annex in the items. + * + * @since 2.0 + */ +enum ListAnnexStyle +{ + LIST_ANNEX_STYLE_NORMAL = 0, /**< The no style annex */ + LIST_ANNEX_STYLE_MARK, /**< The mark style annex for multiple selection */ + LIST_ANNEX_STYLE_ONOFF_SLIDING, /**< The slider style On/Off */ + LIST_ANNEX_STYLE_DETAILED, /**< Detailed style for further interaction */ + LIST_ANNEX_STYLE_RADIO /**< The radio style for simple look */ +}; + +/** + * @enum ListItemDrawingStatus + * + * Defines the drawing state of the items. + * + * @since 2.0 + */ +enum ListItemDrawingStatus +{ + LIST_ITEM_DRAWING_STATUS_NORMAL = 0, /**< The normal drawing state */ + LIST_ITEM_DRAWING_STATUS_PRESSED, /**< The pressed drawing state */ + LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED /**< The highlighted drawing state */ +}; + +/** + * @enum ListRefreshType + * + * Defines the update type of the list. + * + * @since 2.0 + */ +enum ListRefreshType +{ + LIST_REFRESH_TYPE_ITEM_ADD = 0, /**< The add type */ + LIST_REFRESH_TYPE_ITEM_REMOVE, /**< The remove type */ + LIST_REFRESH_TYPE_ITEM_MODIFY /**< The modify type */ +}; + +/** + * @enum ListItemStatus + * + * Defines the item state of the list. + * + * @since 2.0 + */ +enum ListItemStatus +{ + LIST_ITEM_STATUS_SELECTED = 0, /**< The selected item state */ + LIST_ITEM_STATUS_HIGHLIGHTED, /**< The highlighted item state */ + LIST_ITEM_STATUS_CHECKED, /**< The check item state */ + LIST_ITEM_STATUS_UNCHECKED, /**< The uncheck item state */ + LIST_ITEM_STATUS_MORE /**< The more item state */ +}; + +/** + * @enum ListContextItemStatus + * + * Defines the state of the context items. + * + * @since 2.0 + */ +enum ListContextItemStatus +{ + LIST_CONTEXT_ITEM_STATUS_SELECTED = 0, /**< The selected context item state */ + LIST_CONTEXT_ITEM_STATUS_HIGHLIGHTED /**< The highlighted context item state */ +}; + +/** + * @enum SweepDirection + * + * Defines the direction of the sweep interaction. + * + * @since 2.0 + */ +enum SweepDirection +{ + SWEEP_DIRECTION_LEFT = 0, /**< The left direction */ + SWEEP_DIRECTION_RIGHT /**< The right direction */ +}; + +/** + * @enum ListScrollItemAlignment + * + * Defines the alignment information for item scroll. + * + * @since 2.0 + */ +enum ListScrollItemAlignment +{ + LIST_SCROLL_ITEM_ALIGNMENT_TOP = 0, /**< The item is aligned at the top of the ListView at item scroll*/ + LIST_SCROLL_ITEM_ALIGNMENT_BOTTOM /**< The item is aligned at the bottom of the ListView at item scroll */ +}; + +/** + * @enum ListScrollStyle + * + * Defines the scroll style of the list. + * + * @since 2.0 + */ +enum ListScrollStyle +{ + SCROLL_STYLE_FADE_OUT = 0, /**< The fade-out scroll style */ + SCROLL_STYLE_FIXED, /**< The fixed scroll style */ + SCROLL_STYLE_FAST_SCROLL, /**< The fast scroll style */ + SCROLL_STYLE_JUMP_TO_TOP, /**< The jump to top scroll style */ + SCROLL_STYLE_THUMB /**< The thumb scroll style */ +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_LIST_VIEW_TYPES_H_ diff --git a/inc/FUiCtrlMessageBox.h b/inc/FUiCtrlMessageBox.h new file mode 100644 index 0000000..a4aa470 --- /dev/null +++ b/inc/FUiCtrlMessageBox.h @@ -0,0 +1,349 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlMessageBox.h + * @brief This is the header file for the %MessageBox class. + * + * This header file contains the declarations of the %MessageBox class. + */ + +#ifndef _FUI_CTRL_MESSAGE_BOX_H_ +#define _FUI_CTRL_MESSAGE_BOX_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum MessageBoxStyle + * + * Defines the %MessageBox style. + * + * @since 2.0 + */ +enum MessageBoxStyle +{ + MSGBOX_STYLE_NONE, /**< The message box does not contain push buttons: NONE */ + MSGBOX_STYLE_OK, /**< The message box contains one push button: OK */ + MSGBOX_STYLE_CANCEL, /**< The message box contains one push button: CANCEL */ + MSGBOX_STYLE_OKCANCEL, /**< The message box contains two push buttons: OK and CANCEL */ + MSGBOX_STYLE_YESNO, /**< The message box contains two push buttons: YES and NO */ + MSGBOX_STYLE_YESNOCANCEL, /**< The message box contains three push buttons: YES, NO and CANCEL */ + MSGBOX_STYLE_ABORTRETRYIGNORE, /**< The message box contains three push buttons: ABORT, RETRY, and IGNORE */ + MSGBOX_STYLE_CANCELTRYCONTINUE, /**< The message box contains three push buttons: CANCEL, TRY, and CONTINUE */ + MSGBOX_STYLE_RETRYCANCEL /**< The message box contains two push buttons: RETRY and CANCEL */ +}; + + +/** + * @enum MessageBoxModalResult + * + * Defines the %MessageBox notifications. + * + * @since 2.0 + */ +enum MessageBoxModalResult +{ + + MSGBOX_RESULT_CLOSE, /**< The message box is closed */ + MSGBOX_RESULT_OK, /**< The OK button is selected */ + MSGBOX_RESULT_CANCEL, /**< The cancel button is selected */ + MSGBOX_RESULT_YES, /**< The Yes button is selected */ + MSGBOX_RESULT_NO, /**< The No button is selected */ + MSGBOX_RESULT_ABORT, /**< The Abort button is selected */ + MSGBOX_RESULT_TRY, /**< The Try button is selected */ + MSGBOX_RESULT_RETRY, /**< The Retry button is selected */ + MSGBOX_RESULT_IGNORE, /**< The Ignore button is selected */ + MSGBOX_RESULT_CONTINUE, /**< The Continue button is selected */ +}; + + +/** + * @class MessageBox + * @brief This class implements a message box. + * + * @since 2.0 + * + * The %MessageBox class displays a confirmation message when the user is asked to confirm an action, or a warning message when the + * user wants to continue a potentially dangerous action. It can also display information, question, alarm, and lock messages, or + * the user selections. + * + * For more information on the class features, see Popup and MessageBox. + * + * The following example demonstrates how to use the %MessageBox class. + * + * @code +// Sample code for MessageBoxSample.h +#include + +class MessageBoxSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener +{ +public: + bool Initialize(void); + void OpenMessageBox(void); + virtual result OnInitializing(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +protected: + static const int ID_BTN_DO_SOMETHING = 101; +}; + * @endcode + * + * @code +// Sample code for MessageBoxSample.cpp +#include + +#include "MessageBoxSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +MessageBoxSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +MessageBoxSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Button + Button* pButton = new Button(); + pButton->Construct(Rectangle(10, 10, 350, 60), L"MessageBox Test"); + pButton->SetActionId(ID_BTN_DO_SOMETHING); + pButton->AddActionEventListener(*this); + + // Adds the button to the form + AddControl(*pButton); + + return r; +} + +void +MessageBoxSample::OpenMessageBox(void) +{ + // Creates an instance of MessageBox + MessageBox messageBox; + messageBox.Construct(L"MessageBox Title", L"MessageBox Sample Code.", MSGBOX_STYLE_OK, 3000); + + int modalResult = 0; + + // Calls ShowAndWait() : Draws and Shows itself and processes events + messageBox.ShowAndWait(modalResult); + + switch (modalResult) + { + case MSGBOX_RESULT_OK: + { + // .... + } + break; + default: + break; + } +} + +void +MessageBoxSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_BTN_DO_SOMETHING: + { + OpenMessageBox(); + } + break; + default: + break; + } +} + * @endcode + */ + +class _OSP_EXPORT_ MessageBox + : public Tizen::Ui::Window +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + MessageBox(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~MessageBox(void); + + /** + * Initializes this instance of %MessageBox with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] title The title string to be set + * @param[in] text The text string to be set + * @param[in] style The style of the %MessageBox control + * @param[in] timeout The duration of the timeout in milliseconds + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_ARG The specified @c text is too long. + * @remarks To create a %MessageBox control, call ShowAndWait() after the Construct() method is called. @n + * The message box text cannot contain over @c 399 characters. @n + * To display the text in multi-lines or to denote the end of line use '\\n'. + * @see ShowAndWait() + */ + result Construct(const Tizen::Base::String& title, const Tizen::Base::String& text, MessageBoxStyle style, unsigned long timeout = 0); + +public: + /** + * Runs the modal window. @n + * This method should be called only after calling the Construct() method. + * + * @since 2.0 + * + * @return An error code + * @param[out] modalResult The %MessageBox notification + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + virtual result ShowAndWait(int& modalResult); + + /** + * Gets the text of the %MessageBox control. + * + * @since 2.0 + * + * @return The text of this %MessageBox instance, @n + * else an empty string if the instance is invalid + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets the title of the %MessageBox control. + * + * @since 2.0 + * + * @return The title of this %MessageBox instance, @n + * else an empty string if the instance is invalid + */ + Tizen::Base::String GetTitleText(void) const; + + /** + * Gets the style of the current %MessageBox. + * + * @since 2.0 + * + * @return The style of the current %MessageBox, @n + * else @c MSGBOX_STYLE_NONE if the instance is invalid + */ + MessageBoxStyle GetMessageBoxStyle(void) const; + + /** + * Gets the timeout value of %MessageBox. + * + * @since 2.0 + * + * @return The timeout value in milliseconds, @n + * else @c 0 if the instance is invalid + */ + virtual unsigned long GetTimeout(void) const; + + /** + * Sets the color of the %MessageBox control. + * + * @since 2.0 + * + * @param[in] color The color to be set + */ + void SetColor(const Tizen::Graphics::Color& color); + + /** + * Gets the color of the %MessageBox control. + * + * @since 2.0 + * + * @return The color to be set + */ + Tizen::Graphics::Color GetColor(void) const; + + /** + * Sets the title text color of the %MessageBox control. + * + * @since 2.0 + * + * @param[in] color The title text color to be set + */ + void SetTitleTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the title text color of the %MessageBox control. + * + * @since 2.0 + * + * @return The title text color + */ + Tizen::Graphics::Color GetTitleTextColor(void) const; + + /** + * Sets the text color of the %MessageBox control. + * + * @since 2.0 + * + * @param[in] color The text color to be set + */ + void SetTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the text color of the %MessageBox control. + * + * @since 2.0 + * + * @return The text color + */ + Tizen::Graphics::Color GetTextColor(void) const; + +protected: + friend class _MessageBoxImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + MessageBox(const MessageBox& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + MessageBox& operator =(const MessageBox& rhs); + +}; // MessageBox + + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_MESSAGE_BOX_H_ diff --git a/inc/FUiCtrlOptionMenu.h b/inc/FUiCtrlOptionMenu.h new file mode 100644 index 0000000..80ad9a4 --- /dev/null +++ b/inc/FUiCtrlOptionMenu.h @@ -0,0 +1,481 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlOptionMenu.h + * @brief This is the header file for the %OptionMenu class. + * + * This header file contains the declarations of the %OptionMenu class and its helper classes. + */ + +#ifndef _FUI_CTRL_OPTION_MENU_H_ +#define _FUI_CTRL_OPTION_MENU_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if OSPDEPREC + * @class OptionMenu + * @brief [Deprecated] This class defines a common behavior for an %OptionMenu control. + * + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * The %OptionMenu class defines a common behavior for an %OptionMenu control. + * An %OptionMenu is used to present users with multiple options. Hierarchical menu + * of depth 2 can be constructed. Option menu consists of main items and sub-items. + * Unlike ContextMenu, menus cannot display bitmaps. + * + * If an application wants to perform tasks when a menu item is selected, it must + * implement IActionEventListener and register the listener by calling %OptionMenu's + * AddActionEventListener() method. It will then receive action ID associated + * with the menu item. + * Note that %OptionMenu cannot be used in a Popup. + * + * Example: + * + * @image html ui_controls_optionmenu.png + * + * This is the simple UI application which uses an %OptionMenu control. + * + * @code + // Sample code for OptionMenuSample.h + #include + +class OptionMenuSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener +{ +public: + bool Initialize(void) ; + void ShowOptionMenu(void); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +private: + static const int ID_OPTIONKEY = 100; + static const int ID_OPTIONMENU_ITEM1 = 101; + static const int ID_OPTIONMENU_ITEM2 = 102; + + Tizen::Ui::Controls::OptionMenu* __pOptionMenu; +}; + * @endcode + * + * @code +// Sample code for OptionMenuSample.cpp +#include "OptionMenuSample.h" + +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +bool +OptionMenuSample::Initialize() +{ + Construct(FORM_STYLE_OPTIONKEY|FORM_STYLE_NORMAL); + return true; +} + +result +OptionMenuSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of OptionMenu + __pOptionMenu = new OptionMenu(); + __pOptionMenu->Construct(); + __pOptionMenu->AddItem("Item1",ID_OPTIONMENU_ITEM1); + __pOptionMenu->AddItem("Item2",ID_OPTIONMENU_ITEM2); + SetOptionkeyActionId(ID_OPTIONKEY); + AddOptionkeyActionListener(*this); + + return r; +} + +result +OptionMenuSample::OnTerminating(void) +{ + result r = E_SUCCESS; + delete __pOptionMenu; + return r; +} + +void +OptionMenuSample::ShowOptionMenu(void) +{ + __pOptionMenu->SetShowState(true); + __pOptionMenu->Show(); +} + +// IActionEventListener implementation +void +OptionMenuSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_OPTIONKEY: + { + ShowOptionMenu(); + } + break; + case ID_OPTIONMENU_ITEM1: + { + // .... + } + break; + case ID_OPTIONMENU_ITEM2: + { + // .... + } + break; + default: + break; + } +} + * @endcode + * @endif + */ +class _OSP_EXPORT_ OptionMenu + : public Tizen::Ui::Window +{ +public: + /** + * @if OSPDEPREC + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * @endif + */ + OptionMenu(void); + + /** + * @if OSPDEPREC + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * @endif + */ + virtual ~OptionMenu(void); + + /** + * @if OSPDEPREC + * Initializes this instance of %OptionMenu. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM This method has failed. + * @endif + */ + result Construct(void); + + /** + * @if OSPDEPREC + * Adds a listener instance to receive action events from this control. @n + * The added listener can listen to events on the given event dispatcher's context when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @endif + */ + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * @if OSPDEPREC + * Removes the specified action event listener so that it no longer receives events from this control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @endif + */ + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * @if OSPDEPREC + * Appends new item to the end of %OptionMenu. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] text The item to be appended + * @param[in] actionId The action ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM This method has failed. + * @remarks %OptionMenu can have a maximum of 12 main items. + * @endif + */ + result AddItem(const Tizen::Base::String& text, int actionId); + + /** + * @if OSPDEPREC + * Inserts a specific item at the given index of %OptionMenu. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The main index + * @param[in] text The item to be set + * @param[in] actionId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12. + * @exception E_SYSTEM The method has failed. + * @remarks %OptionMenu can have a maximum of 12 main items. + * @endif + */ + result InsertItemAt(int mainIndex, const Tizen::Base::String& text, int actionId); + + /** + * @if OSPDEPREC + * Sets a specific item at the given index of %OptionMenu. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The main index + * @param[in] text The string of the item to be set + * @param[in] actionId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12. + * @exception E_SYSTEM The method has failed. + * @endif + */ + result SetItemAt(int mainIndex, const Tizen::Base::String& text, int actionId); + + /** + * @if OSPDEPREC + * Removes the item of the specified index from %OptionMenu. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The main index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12. + * @exception E_SYSTEM This method has failed. + * @endif + */ + result RemoveItemAt(int mainIndex); + + /** + * @if OSPDEPREC + * Gets the number of items registered for %OptionMenu. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return The number of items registered for %OptionMenu + * @endif + */ + int GetItemCount(void) const; + + /** + * @if OSPDEPREC + * Gets the index of the item with the specified action ID. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return The index of the item + * @param[in] actionId The action ID of the item + * @endif + */ + int GetItemIndexFromActionId(int actionId) const; + + /** + * @if OSPDEPREC + * Gets the action ID of the item at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return The action ID of the item + * @param[in] mainIndex The index of the item + * @endif + */ + int GetItemActionIdAt(int mainIndex) const; + + /** + * @if OSPDEPREC + * Appends new sub-item to the end of %OptionMenu. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item + * @param[in] text The string of item to be appended + * @param[in] actionId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12. + * @exception E_SYSTEM This method has failed. + * @remarks %OptionMenu can have a maximum of 32 sub-items. + * @endif + */ + result AddSubItem(int mainIndex, const Tizen::Base::String& text, int actionId); + + /** + * @if OSPDEPREC + * Inserts a specific sub-item at the given index of %OptionMenu. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item + * @param[in] subIndex The index of the sub-item + * @param[in] text The string of the item to be set + * @param[in] actionId The action ID + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12. + * @exception E_SYSTEM This method has failed. + * @remarks %OptionMenu can have a maximum of 32 sub-items. + * @endif + */ + result InsertSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId); + + /** + * @if OSPDEPREC + * Sets a specific sub-item at the given index of %OptionMenu. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item + * @param[in] subIndex The index of the sub-item + * @param[in] text The string of the item to be set + * @param[in] actionId The action ID + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12. + * @exception E_SYSTEM This method has failed. + * @endif + */ + result SetSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId); + + /** + * @if OSPDEPREC + * Removes the sub-item of the specified index from %OptionMenu. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] mainIndex The index of the main item + * @param[in] subIndex The index of the sub-item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12. + * @exception E_SYSTEM This method has failed. + * @endif + */ + result RemoveSubItemAt(int mainIndex, int subIndex); + + /** + * @if OSPDEPREC + * Gets the number of sub-items registered for %OptionMenu. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return The number of sub-items registered for %OptionMenu + * @param[in] mainIndex The index of the main item + * @endif + */ + int GetSubItemCount(int mainIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the sub-item at the specified action ID. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return The index of the item + * @param[in] actionId The action ID of the item + * @endif + */ + int GetSubItemIndexFromActionId(int actionId) const; + + /** + * @if OSPDEPREC + * Gets the action ID of the sub-item at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended. + * @since 2.0 + * + * @return The action ID of the item + * @param[in] mainIndex The index of the main item + * @param[in] subIndex The index of the sub-item + * @endif + */ + int GetSubItemActionIdAt(int mainIndex, int subIndex) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + OptionMenu(const OptionMenu&); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + OptionMenu& operator =(const OptionMenu&); + + friend class _OptionMenuImpl; +}; // OptionMenu + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_OPTION_MENU_H_ diff --git a/inc/FUiCtrlOverlayPanel.h b/inc/FUiCtrlOverlayPanel.h new file mode 100644 index 0000000..316a0b2 --- /dev/null +++ b/inc/FUiCtrlOverlayPanel.h @@ -0,0 +1,292 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlOverlayPanel.h + * @brief This is the header file for the %OverlayPanel class. + * + * This header file contains the declarations of the %OverlayPanel class. + */ +#ifndef _FUI_CTRL_OVERLAY_PANEL_H_ +#define _FUI_CTRL_OVERLAY_PANEL_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @if OSPDEPREC + * @class OverlayPanel + * @brief [Deprecated] This class is an implementation of %OverlayPanel. + * + * @deprecated This class is deprecated. Instead of using this class, use the OverlayRegion class, that supports video playback and camera preview. + * @since 2.0 + * + * @remarks The %OverlayPanel control can only be attached to a %Form control by using Tizen::Ui::Container::AddControl method, because of its native + * characteristics. Since %OverlayPanel inherits a Panel control, it can be used as a container if needed. + * + * The %OverlayPanel class is an implementation of the %OverlayPanel control. + * The %OverlayPanel is a special type of panel which is used to specify a region where the developer + * can playback video or camera preview. It is called an overlay because it is possible to overlay + * other graphics and controls on top of the panel. + * The %OverlayPanel consists of two layers, the foreground panel and background buffer which supports + * H/W accelerated rendering. Due to the hardware accelerated nature, there is a limitation with an + * %OverlayPanel. The Form that houses an %OverlayPanel can only have a black, opaque background. + * The overlay panel can manipulate the rotation, the aspect ratio and the size of input buffer. + * + * Example: Please refer to the camera preview example of Tizen::Media::Camera + * + * @endif + */ +class _OSP_EXPORT_ OverlayPanel + : public Tizen::Ui::Controls::Panel +{ +public: + /** + * @if OSPDEPREC + * @enum Rotation + * + * Defines the various rotation options. + * + * @brief [Deprecated] + * @deprecated This enumerator is deprecated. Instead of using this class, use the %OverlayRegion class, that supports video playback and camera + * preview. + * @since 2.0 + * @endif + */ + enum Rotation + { + ROTATION_NONE, /**< @if OSPDEPREC No rotation @endif */ + ROTATION_90, /**< @if OSPDEPREC The 90 degree rotation @endif */ + ROTATION_180, /**< @if OSPDEPREC The 180 degree rotation @endif */ + ROTATION_270, /**< @if OSPDEPREC The 270 degree rotation @endif */ + ROTATION_NONE_LR, /**< @if OSPDEPREC The horizontal mirroring @endif */ + ROTATION_NONE_UD, /**< @if OSPDEPREC The vertical mirroring @endif */ + ROTATION_90_LR, /**< @if OSPDEPREC The 90 degree rotation with horizontal mirroring @endif */ + ROTATION_90_UD, /**< @if OSPDEPREC The 90 degree rotation with vertical mirroring @endif */ + ROTATION_180_LR, /**< @if OSPDEPREC The 180 degree rotation with horizontal mirroring @endif */ + ROTATION_180_UD, /**< @if OSPDEPREC The 180 degree rotation with vertical mirroring @endif */ + ROTATION_270_LR, /**< @if OSPDEPREC The 270 degree rotation with horizontal mirroring @endif */ + ROTATION_270_UD, /**< @if OSPDEPREC The 270 degree rotation with vertical mirroring @endif */ + ROTATION_MAX + }; + + /** + * @if OSPDEPREC + * @enum BufferPixelFormat + * + * Defines the pixel formats. + * + * @brief [Deprecated] + * @deprecated This enumerator is deprecated. Instead of using this class, use the %OverlayRegion class, that supports video playback and camera preview. + * @since 2.0 + * @endif + */ + enum BufferPixelFormat + { + /** + * @if OSPDEPREC + * The ARGB8888 pixel format + * + * @since 2.0 + * @endif + */ + BUFFER_PIXEL_FORMAT_ARGB8888, + + /** + * @if OSPDEPREC + * The RGB565 pixel format + * + * @since 2.0 + * @endif + */ + BUFFER_PIXEL_FORMAT_RGB565, + + /** + * @if OSPDEPREC + * The 8 bit Y plane followed by 8 bit 2 X 2 subsampled U and V planes + * + * @since 2.0 + * @endif + */ + BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR + }; + + /** + * @if OSPDEPREC + * This is the default constructor for this class. + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this class, use the %OverlayRegion class, that supports video playback and camera preview. + * @since 2.0 + * @endif + */ + OverlayPanel(void); + + /** + * @if OSPDEPREC + * This is the destructor for this class. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this class, use the %OverlayRegion class, that supports video playback and camera preview. + * @since 2.0 + * @endif + */ + virtual ~OverlayPanel(void); + + /** + * @if OSPDEPREC + * Initializes this instance of %OverlayPanel at the specified rectangle. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this class, use the %OverlayRegion class, that supports video playback and camera preview. + * @since 2.0 + * + * @return An error code + * @param[in] rect The location and size of the %OverlayPanel control @n + * The maximum size is 480 x 800 on a WVGA screen, or 240 x 400 on a WQVGA screen. @n + * The minimum size of this control is 32 x 32 on a WVGA screen. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. + * @remarks Do not use %OverlayPanel in combination with %OverlayRegion. If used, %OverlayPanel may not work as expected. + * @see Tizen::Ui::Container + * @endif + */ + result Construct(const Tizen::Graphics::Rectangle& rect); + + /** + * @if OSPDEPREC + * Sets the rotation of the input buffer. @n + * All the rotations are clock-wise. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this class, use the %OverlayRegion class, that supports video playback and camera preview. + * @since 2.0 + * + * @param[in] rotation The rotation + * + * @endif + */ + void SetRendererRotation(OverlayPanel::Rotation rotation); + + /** + * @if OSPDEPREC + * Changes the size of the displayed renderer. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this class, use the %OverlayRegion class, that supports video playback and camera preview. + * @since 2.0 + * + * @param[in] dim The dimension of the window to draw + * + * @endif + */ + void SetRendererSize(Tizen::Graphics::Dimension& dim); + + /** + * @if OSPDEPREC + * Sets the aspect ratio of the renderer. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this class, use the %OverlayRegion class, that supports video playback and camera preview. + * @since 2.0 + * + * @param[in] fix Set to @c true if the renderer will display the aspect ratio of the input buffer even if the renderer and input data have + * different aspect ratios, @n + * else @c false + * @endif + */ + void SetRendererAspectRatio(bool fix); + + /** + * @if OSPDEPREC + * Sets the input buffer. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this class, use the %OverlayRegion class, that supports video playback and camera preview. + * @since 2.0 + * + * @param[in] destDim The dimension of the window to be drawn + * @param[in] srcBuffer The source buffer + * @param[in] srcDim The source dimension + * @param[in] srcFormat The pixel format of buffer data + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @exception E_UNSUPPORTED_FORMAT The specified pixel format is not supported. + * @remarks BUFFER_PIXEL_FORMAT_ARGB8888, and BUFFER_PIXEL_FORMAT_RGB565 are not supported. @n + * Control::Invalidate() methods must be called to properly display the input buffer. + * + * @endif + */ + result SetInputBuffer(const Tizen::Graphics::Dimension& destDim, const Tizen::Base::ByteBuffer& srcBuffer, const Tizen::Graphics::Dimension& srcDim, BufferPixelFormat srcFormat); + + /** + * @if OSPDEPREC + * Gets the information of the background buffer. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this class, use the %OverlayRegion class, that supports video playback and camera preview. + * @since 2.0 + * + * @return An error code + * @param[out] info The information of the background buffer + * @exception E_SUCCESS The method is successful. + * @exception E_OPERATION_FAILED The operation has failed. + * @remarks Currently, this function provides buffer information except the pointer of the RGB color buffer. @n + * Therefore, info.pPixels is always assigned @c null. + * @endif + */ + result GetBackgroundBufferInfo(Tizen::Graphics::BufferInfo& info) const; + + /** + * @if OSPDEPREC + * Gets the masking color of this control. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this class, use the %OverlayRegion class, that supports video playback and camera preview. + * @since 2.0 + * + * @return The pixel color format + * @endif + */ + Tizen::Graphics::Color GetMaskingColor(void) const; + +private: + friend class _OverlayPanelImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + OverlayPanel(const OverlayPanel& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + OverlayPanel& operator =(const OverlayPanel& rhs); + +}; // OverlayPanel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_OVERLAY_PANEL_H_ diff --git a/inc/FUiCtrlOverlayRegion.h b/inc/FUiCtrlOverlayRegion.h new file mode 100644 index 0000000..ed8a9b5 --- /dev/null +++ b/inc/FUiCtrlOverlayRegion.h @@ -0,0 +1,463 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlOverlayRegion.h + * @brief This is the header file for the %OverlayRegion class. + * + * This header file contains the declarations of the %OverlayRegion class. + */ + +#ifndef _FUI_CTRL_OVERLAY_REGION_H_ +#define _FUI_CTRL_OVERLAY_REGION_H_ + +#include +#include + +namespace Tizen { namespace Base +{ +class ByteBuffer; +}} // Tizen::Base + +namespace Tizen { namespace Graphics +{ +class Point; +class Dimension; +class Rectangle; +class BufferInfo; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum OverlayRegionBufferPixelFormat + * + * Defines the pixel formats. + * + * @since 2.0 + */ +enum OverlayRegionBufferPixelFormat +{ + OVERLAY_REGION_BUFFER_PIXEL_FORMAT_ARGB8888 = 1, /**< The ARGB8888 pixel format */ + OVERLAY_REGION_BUFFER_PIXEL_FORMAT_RGB565, /**< The RGB565 pixel format */ + OVERLAY_REGION_BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR, /**< The 8-bit Y plane followed by the 8-bit 2x2 subsampled U and V planes */ + OVERLAY_REGION_BUFFER_PIXEL_FORMAT_NV12, /**< The NV12 pixel format */ + OVERLAY_REGION_BUFFER_PIXEL_FORMAT_UYVY, /**< The UYVY pixel format */ + OVERLAY_REGION_BUFFER_PIXEL_FORMAT_MAX, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. + OVERLAY_REGION_BUFFER_PIXEL_FORMAT_MIN = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. +}; + +/** + * @enum OverlayRegionType + * + * Defines the type of an overlay region. + * + * @since 2.0 + */ +enum OverlayRegionType +{ + OVERLAY_REGION_TYPE_PRIMARY_CAMERA = 1, /**< The primary camera type @n + An overlay region displays the auto-rotated primary camera input that comes from Camera. */ + OVERLAY_REGION_TYPE_SECONDARY_CAMERA, /**< The secondary camera type @n + An overlay region displays the auto-rotated and mirrored secondary camera input that comes from Camera. */ + OVERLAY_REGION_TYPE_NORMAL, /**< The normal type @n + An overlay region displays the user input as it is. */ + OVERLAY_REGION_TYPE_MAX, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. + OVERLAY_REGION_TYPE_MIN = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. +}; + +/** + * @enum OverlayRegionEvaluationOption + * + * Defines the option for evaluating the bounds of an overlay region. + * + * @since 2.0 + */ +enum OverlayRegionEvaluationOption +{ + OVERLAY_REGION_EVALUATION_OPTION_GREATER_THAN, /**< The option evaluating the overlay region bounds and finding the minimum bounds greater than the input bounds */ + OVERLAY_REGION_EVALUATION_OPTION_LESS_THAN, /**< The option evaluating the overlay region bounds and finding the maximum bounds smaller than input bounds */ +}; + + +/** + * @class OverlayRegion + * @brief This class is an implementation of an %OverlayRegion. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %OverlayRegion class displays a region of an overlay surface, which is used to play back a video or show the camera preview. + * @n + * For more information on the class features, see OverlayRegion. + * + * @code +//Sample code for OverlayRegionSample.h +#include +#include +#include + +class OverlayRegionSample + : public Tizen::Ui::Controls::Form + , public Tizen::Media::IPlayerEventListener +{ +public: + OverlayRegionSample(void) + : __pPlayer(null) + , __pOverlayRegion(null) + , __pOverlayPanel(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // IPlayerEventListener + virtual void OnPlayerOpened(result r); + virtual void OnPlayerEndOfClip(void); + virtual void OnPlayerSeekCompleted(result r); + virtual void OnPlayerBuffering(int percent); + virtual void OnPlayerErrorOccurred(const Tizen::Media::PlayerErrorReason r); + virtual void OnPlayerInterrupted(void); + virtual void OnPlayerReleased(void); + +private: + Tizen::Media::Player* __pPlayer; + Tizen::Ui::Controls::OverlayRegion*__pOverlayRegion; + Tizen::Ui::Controls::Panel* __pOverlayPanel; +}; + * @endcode + * + * @code +//Sample code for OverlayRegionSample.cpp +#include + +#include "OverlayRegionSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui::Controls; + +bool +OverlayRegionSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +OverlayRegionSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Sets an overlay region area + int widthVideo = 480; + int HeightVideo = 320; + int positionX = (GetClientAreaBounds().width - 480) / 2; + int positionY = (GetClientAreaBounds().width - 480) / 2; + Rectangle overlayRectangle(positionX, positionY, widthVideo, HeightVideo); + + // Gets an overlay region + __pOverlayRegion = GetOverlayRegionN(overlayRectangle, OVERLAY_REGION_TYPE_NORMAL); + + // Gets buffer information + BufferInfo bufferInfo; + __pOverlayRegion->GetBackgroundBufferInfo(bufferInfo); + + // Gets a video file path + String videoFilePath = App::GetInstance()->GetAppResourcePath() + L"tizen.mp4"; + + // Creates an instance of Player + __pPlayer = new Player(); + __pPlayer->Construct(*this, &bufferInfo); + __pPlayer->SetLooping(true); + __pPlayer->OpenFile(videoFilePath); + __pPlayer->Play(); + + // Creates an instance of Panel which is overlaid with overlay region + __pOverlayPanel = new Panel(); + __pOverlayPanel->Construct(overlayRectangle); + AddControl(*__pOverlayPanel); + + // Creates instaces of Button and Label and adds controls to the panel + Label* pLabel = new Label(); + pLabel->Construct(Rectangle(0, 0, 400, 80),L"OverlayRegion Sample"); + pLabel->SetTextColor(Color::GetColor(COLOR_ID_RED)); + __pOverlayPanel->AddControl(*pLabel); + + Button* pButton = new Button(); + pButton->Construct(Rectangle(widthVideo - 200, HeightVideo - 100, 180, 80),L"BUTTON"); + __pOverlayPanel->AddControl(*pButton); + + Invalidate(true); + + return r; +} + +result +OverlayRegionSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates controls + delete __pPlayer; + delete __pOverlayRegion; + + return r; +} + +// IPlayerEventListener implementation +void +OverlayRegionSample::OnPlayerOpened(result r) +{ + // .... +} + +void +OverlayRegionSample::OnPlayerEndOfClip(void) +{ + // .... +} + +void +OverlayRegionSample::OnPlayerSeekCompleted(result r) +{ + // .... +} + +void +OverlayRegionSample::OnPlayerBuffering(int percent) +{ + // .... +} + +void +OverlayRegionSample::OnPlayerErrorOccurred(const PlayerErrorReason r) +{ + // .... +} + +void +OverlayRegionSample::OnPlayerInterrupted(void) +{ + // .... +} + +void +OverlayRegionSample::OnPlayerReleased(void) +{ + // .... +} + * @endcode + */ +class _OSP_EXPORT_ OverlayRegion + : public Tizen::Base::Object +{ +public: + /** + * This is the destructor for this class. + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~OverlayRegion(void); + + /** + * Gets the position and size of the overlay region. + * + * @since 2.0 + * + * @return An instance of Rectangle that represents the position of the top-left corner, the width, and the height of the overlay region + * @remarks The shape of an overlay region is rectangular, which is defined by the top-left point, and the width or height. The position of the top-left + * point is relative to the top-left corner of the parent form. + * + */ + Tizen::Graphics::Rectangle GetBounds(void) const; + + /** + * Gets the position and size of the overlay region. + * + * @since 2.0 + * + * @param[out] x The x position of the top-left corner of the overlay region + * @param[out] y The y position of the top-left corner of the overlay region + * @param[out] width The width of the rectangular region + * @param[out] height The height of the rectangular region + * @remarks The shape of an overlay region is rectangular, which is defined by the top-left point, and the width or height. The position of the top-left + * point is relative to the top-left corner of the parent form. + * + */ + void GetBounds(int& x, int& y, int& width, int& height) const; + + /** + * Sets the input buffer. @n + * Due to the hardware accelerated rendering, there are limitations for an input buffer. The input buffer has the same restriction regarding its size as + * the overlay region and it can be checked by using the GetWidthUnit(), GetHeightUnit() and GetMaxCount(). If the specified condition is not satisfied, + * the E_INVALID_ARG exception is returned. If an input buffer does not fit to the bounds of the overlay region, it will be scaled up or down to the overlay + * region bounds without keeping the ratio of input. + * + * @since 2.0 + * + * @return An error code + * @param[in] srcBuffer The source buffer + * @param[in] srcDim The source dimension + * @param[in] srcFormat The pixel format of buffer data + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_UNSUPPORTED_FORMAT The specified pixel format is not supported. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + */ + result SetInputBuffer(const Tizen::Base::ByteBuffer& srcBuffer, const Tizen::Graphics::Dimension& srcDim, OverlayRegionBufferPixelFormat srcFormat); + + /** + * Gets the information related to the background buffer. + * + * @since 2.0 + * + * @return An error code + * @param[out] info The information of the input buffer + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method provides the buffer information, except the pointer of a color buffer. Therefore, info.pPixels is always assigned as @c null. + */class Dimension; + + result GetBackgroundBufferInfo(Tizen::Graphics::BufferInfo& info) const; + + /** + * Shows the overlay region on the screen. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation, that is, this control cannot be displayed. + * @exception E_SYSTEM A system error has occurred. + */ + result Show(void); + + /** + * Evaluates and returns the valid position and size that are closest to the specified bounds. + * + * @since 2.0 + * + * @return @c true if the evaluation process does not meet an error, @n + * else @c false + * @param[in] option The option for evaluating the bounds of the overlay region + * @param[in, out] rect An instance of %Rectangle that represents the validated bounds of %OverlayRegion @n + * The width and height of the input rectangle must be greater than @c 0. + * @param[out] modified A boolean flag that indicates whether the specified @c rectangle is modified + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_UNSUPPORTED_OPTION A specified input parameter is not supported. + * @exception E_SYSTEM A system error has occurred. + * @remarks Due to the hardware accelerated rendering, there are limitations for an overlay region. @n + * The hardware capability for an overlay region is checked by using the GetWidthUnit(), GetHeightUnit() and GetMaxCount(). @n + * If the application runs on multi-screen resolutions, the specified bounds may not meet the hardware limitations of the overlay region. In + * such cases, GetOverlayRegionN() will return E_INVALID_ARG. @n + * To prevent this kind of problem, the application must use the OverlayRegion::EvaluateBounds() method to get a validated bounds that can be + * used as the input bounds of the GetOverlayRegionN() method. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static bool EvaluateBounds(OverlayRegionEvaluationOption option, Tizen::Graphics::Rectangle& rect, bool& modified); + + /** + * Gets the value of the width. @n + * Only a multiple of this value can be allowed as the width of an overlay region. + * + * @since 2.0 + * + * @return The value of width + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static int GetWidthUnit(void); + + /** + * Gets the value of the height. @n + * Only a multiple of this value can be allowed as the height of an overlay region. + * + * @since 2.0 + * + * @return The value of the height + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static int GetHeightUnit(void); + + /** + * Gets the maximum count of overlay regions that can be used simultaneously per application. + * + * @since 2.0 + * + * @return The maximum count of overlay regions that can be used simultaneously per application + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static int GetMaxCount(void); + + /** + * Gets the BufferPixelFormat list for the %OverlayRegion class. @n + * Each list item has a Tizen::UI::Controls::OverlayRegionBufferPixelFormat value. + * + * @since 2.0 + * + * @return A list of the pixel formats supported by the %OverlayRegion class, @n + * else @c null if no pixel format is supported or an exception occurs + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remark The specific error code can be accessed using the GetLastResult() method. @n + * The return value and each item in the list must be deleted by the caller. @n + * The format list can vary depending on the device. After checking the supported formats using this API, it's better to use a proper pixel format. @n + */ + static Tizen::Base::Collection::IListT< Tizen::Ui::Controls::OverlayRegionBufferPixelFormat >* GetSupportedBufferPixelFormatListN(void); + +private: + // + // This default constructor is intentionally declared as private so that only the platform can create an instance. + // + // @since 2.0 + // + OverlayRegion(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + OverlayRegion(const OverlayRegion& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + OverlayRegion& operator =(const OverlayRegion& rhs); + +private: + class _OverlayRegionImpl * __pOverlayRegionImpl; + + friend class _OverlayRegionImpl; + +}; // OverlayRegion + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_OVERLAY_CONTROL_H_ diff --git a/inc/FUiCtrlPanel.h b/inc/FUiCtrlPanel.h new file mode 100644 index 0000000..81e0680 --- /dev/null +++ b/inc/FUiCtrlPanel.h @@ -0,0 +1,293 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlPanel.h + * @brief This is the header file for the %Panel class. + * + * This header file contains the declarations of the %Panel class. + */ + +#ifndef _FUI_CTRL_PANEL_H_ +#define _FUI_CTRL_PANEL_H_ + +#include +#include +#include +#include + +namespace Tizen {namespace Base +{ +class String; +}} //Tizen::Base + +namespace Tizen { namespace Ui +{ +class DataBindingContext; +}} //Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class Panel + * @brief This class provides a %Panel, that is the simplest container. + * + * @since 2.0 + * + * The %Panel class displays a space where other UI elements can be placed. It is a concrete implementation of the Container class. + * + * For more information on the class features, see Panels. + * + * The following example demonstrates how to use the %Panel class. + * + * @code +// Sample code for PanelSample.h +#include + +class PanelSample + : public Tizen::Ui::Controls::Form +{ +public: + PanelSample(void) + : __pPanel(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + +private: + Tizen::Ui::Controls::Panel* __pPanel; +}; + * @endcode + * + * @code +// Sample code for PanelSample.cpp +#include + +#include "PanelSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +PanelSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +PanelSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Panel + __pPanel = new Panel(); + __pPanel->Construct(Rectangle(100, 200, 300, 300)); + __pPanel->SetBackgroundColor(Color(0x50, 0xFF, 0x38)); + + //Adds the panel to the form + AddControl(*__pPanel); + + return r; +} + * @endcode + */ +class _OSP_EXPORT_ Panel + : public Tizen::Ui::Container +{ +// Lifecycle +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + * + */ + Panel(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + * + */ + virtual ~Panel(void); + + /** + * Initializes this instance of %Panel with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The location and size of the %Panel control as an instance of Rectangle + * @param[in] groupStyle The group style of the %Panel control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specified group style determines the border look of the %Panel control. + * @see Tizen::Ui::Container, Tizen::Ui::GroupStyle + */ + result Construct(const Tizen::Graphics::Rectangle& rect, GroupStyle groupStyle = GROUP_STYLE_NONE); + + + /** + * Initializes this instance of %Panel and child controls with the specified resource ID @n + * + * This method first attempts to find the resource file in the folder that corresponds to the current screen resolution. @n + * If it fails to find the resource file, it searches in other folders in the following order when CoordinateSystem is Logical in the application manifest file @n + * the density folder that corresponds to the current screen size category "res/screen-size-normal/" folder. + * + * @since 2.0 + * + * @return An error code + * @param[in] resourceId The resource ID describing the %Panel control + * @exception E_SUCCESS The method is successful. + * @exception E_FILE_NOT_FOUND The specified file cannot be found. + * @exception E_INVALID_FORMAT The specified XML format is invalid. + * @exception E_OPERATION_FAILED The operation has failed. + */ + result Construct(const Tizen::Base::String& resourceId); + + /** + * Initializes this instance of %Panel with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] layout The layout for both the portrait and landscape modes + * @param[in] rect The location and size of the %Panel control as an instance of Rectangle + * @param[in] groupStyle The table view style of the %Panel control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified layout is already bound to another container. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specified group style determines the border look of the %Panel control. + * @see Tizen::Ui::Container, Tizen::Ui::GroupStyle + */ + result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Rectangle& rect, GroupStyle groupStyle = GROUP_STYLE_NONE); + + /** + * Initializes this instance of %Panel with the specified layouts, rectangular region, and group style. + * + * @since 2.0 + * + * @return An error code + * @param[in] portraitLayout The layout for the portrait mode + * @param[in] landscapeLayout The layout for the landscape mode + * @param[in] rect The location and size of the %Panel control as an instance of Rectangle + * @param[in] groupStyle The table view style of the %Panel control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified layout is already bound to another container. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specified group style determines the border look of the %Panel control. + * @see Tizen::Ui::Container, Tizen::Ui::GroupStyle + */ + result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Rectangle& rect, GroupStyle groupStyle = GROUP_STYLE_NONE); + + /** + * Gets the background color of the %Panel control. + * + * @since 2.0 + * + * @return The background color + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + + /** + * Sets the background color of this control. + * + * @since 2.0 + * + * @param[in] color The background color + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Enables the %Panel control to be composited to the screen buffer. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because changing composition mode is not allowed any more. + * @since 2.0 + * + * @return An error code + * @param[in] composite Set to @c true to make the %Panel control composited to the screen buffer, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks In case a %Panel is transparent and nothing is drawn on the canvas of the %Panel control, the graphic performance can be improved if the + * compositing of the %Panel control to the screen buffer is disabled. @n + * By default, compositing is enabled. For example, if a Form control has a %Panel that has a List, by disabling the compositing of the + * %Panel, the scroll performance of the %List will improve. + * @endif + */ + result SetCompositeEnabled(bool composite); + + /** + * @if OSPDEPREC + * Checks whether the %Panel control is composite to the screen buffer. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because changing composition mode is not allowed any more. + * @since 2.0 + * + * @return @c true if the %Panel control is composite to the screen buffer, @n + * else @c false + * @endif + */ + bool IsCompositeEnabled(void) const; + + /** + * Gets the data binding context. + * + * @since 2.0 + * + * @return The data binding context + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + DataBindingContext* GetDataBindingContextN(void) const; + +protected: + + friend class _PanelImpl; + + // Reserved virtual methods for later extension + + // The following methods are reserved and may change its name at any time without prior notice. + virtual void Panel_Reserved1(void) {} + + virtual void Panel_Reserved2(void) {} + + virtual void Panel_Reserved3(void) {} + +private: + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + Panel(const Panel& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + Panel& operator =(const Panel& rhs); + +}; // Panel + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_PANEL_H_ + diff --git a/inc/FUiCtrlPopup.h b/inc/FUiCtrlPopup.h new file mode 100644 index 0000000..2b7d7ca --- /dev/null +++ b/inc/FUiCtrlPopup.h @@ -0,0 +1,447 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlPopup.h + * @brief This is the header file for the %Popup class. + * + * This header file contains the declarations of the %Popup class. + */ + +#ifndef _FUI_CTRL_POPUP_H_ +#define _FUI_CTRL_POPUP_H_ + +#include + +namespace Tizen { namespace Ui +{ +class DataBindingContext; +}} // Tizen::Ui + + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class Popup + * @brief This class displays a popup on the top of the screen. + * + * @since 2.0 + * + * The %Popup class displays messages to alert the user of important changes, to request confirmation for a significant task, or to + * serve as a warning. It is an implementation of the Window class. + * + * For more information on the class features, see Popup and MessageBox. + * + * @see Tizen::Ui::Window + * + * The following example demonstrates how to use the %Popup class. + * + * @code +// Sample code for PopupSample.h +#include + +class PopupSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener +{ +public: + PopupSample(void) + : __pPopup(null){} + + bool Initialize(void); + void ShowPopup(void); + void HidePopup(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +private: + static const int ID_BUTTON_OPEN_POPUP = 501; + static const int ID_BUTTON_CLOSE_POPUP = 502; + + Tizen::Ui::Controls::Popup* __pPopup; +}; + * @endcode + * + * @code +// Sample code for PopupSample.cpp +#include + +#include "PopupSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +PopupSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +PopupSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Popup + __pPopup = new Popup(); + __pPopup->Construct(true, Dimension(600,800)); + __pPopup->SetTitleText(L"Popup Sample"); + + // Creates an instance of Button to close the popup. + Button* pCloseButton = new Button(); + pCloseButton->Construct(Rectangle(10, 10, 250, 80), L"Close Popup"); + pCloseButton->SetActionId(ID_BUTTON_CLOSE_POPUP); + pCloseButton->AddActionEventListener(*this); + + // Adds the button to the popup + __pPopup->AddControl(*pCloseButton); + + // Creates an instance of Button to open the popup. + Button* pOpenButton = new Button(); + pOpenButton->Construct(Rectangle(10, 10, 250, 60), L"Open Popup"); + pOpenButton->SetActionId(ID_BUTTON_OPEN_POPUP); + pOpenButton->AddActionEventListener(*this); + + // Adds the button to the form + AddControl(*pOpenButton); + + return r; +} + +void +PopupSample::ShowPopup(void) +{ + __pPopup->SetShowState(true); + __pPopup->Show(); +} + +void +PopupSample::HidePopup(void) +{ + __pPopup->SetShowState(false); + Invalidate(true); +} + +result +PopupSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the __pPopup + delete __pPopup; + + return r; +} + +void +PopupSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_BUTTON_OPEN_POPUP: + { + ShowPopup(); + } + break; + case ID_BUTTON_CLOSE_POPUP: + { + HidePopup(); + } + break; + default: + break; + } +} + * @endcode + */ + +class _OSP_EXPORT_ Popup + : public Tizen::Ui::Window +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + Popup(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~Popup(void); + + /** + * Initializes this instance of %Popup with the specified dimensions. + * + * @since 2.0 + * + * @return An error code + * @param[in] hasTitle Set to @c true if the %Popup control has a title, @n + * else @c false + * @param[in] dim The size of the %Popup control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(bool hasTitle, const Tizen::Graphics::Dimension& dim); + + /** + * Initializes this instance of %Popup and child controls with the specified resource ID @n + * + * This method first attempts to find the resource file in the folder that corresponds to the current screen resolution. @n + * If it fails to find the resource file, it searches in other folders in the following order when CoordinateSystem is Logical in the application manifest file @n + * the density folder that corresponds to the current screen size category "res/screen-size-normal/" folder. + * + * @since 2.0 + * + * @return An error code + * @param[in] resourceId The resource ID describing the %Popup control + * @exception E_SUCCESS The method is successful. + * @exception E_FILE_NOT_FOUND The specified file cannot be found. + * @exception E_INVALID_FORMAT The specified XML format is invalid. + * @exception E_OPERATION_FAILED The operation has failed. + */ + result Construct(const Tizen::Base::String& resourceId); + + /** + * Initializes this instance of %Popup with the specified layout and dimensions. + * + * @since 2.0 + * + * @return An error code + * @param[in] layout The layout for both the portrait and landscape mode + * @param[in] hasTitle Set to @c true if the %Popup control should have a title, @n + * else @c false + * @param[in] dim The size of the %Popup control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or + * the specified layout is already bound to another container. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Ui::Layout& layout, bool hasTitle, const Tizen::Graphics::Dimension& dim); + + /** + * Initializes this instance of %Popup with the specified layouts and dimensions. + * + * @since 2.0 + * + * @return An error code + * @param[in] portraitLayout The layout for the portrait mode + * @param[in] landscapeLayout The layout for the landscape mode + * @param[in] hasTitle Set to @c true if this %Popup control should have a title, @n + * else @c false + * @param[in] dim The size of the %Popup control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or + * the specified layout is already bound to another container. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, bool hasTitle, const Tizen::Graphics::Dimension& dim); + + /** + * Shows the modal window. @n + * + * @since 2.0 + * @return An error code + * @param[out] modalResult The %Popup's notification. @n + * This value is the 'modalResult' parameter of the EndModal() method + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The %Popup is not visible. The visible state of the %Popup should be set @c true. + * @remarks Do not call this method from Tizen::App::App::OnAppInitializing(). @n + * To show a %Popup properly from Tizen::Ui::Controls::Form::OnInitializing(), theForm must + * have been successfully drawn before the DoModal() method. + */ + result DoModal(int& modalResult); + + /** + * Closes the modal window. @n + * + * @since 2.0 + * @return An error code + * @param[in] modalResult The result value of the modal window. @n + * The value which needs to be returned as the output parameter of DoModal() method should be passed as the input argument + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The method is not supported because this popup isn't running as a modal window. + */ + result EndModal(int modalResult); + + /** + * Sets the title of the %Popup control. + * + * @since 2.0 + * + * @return An error code + * @param[in] title The title to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + virtual result SetTitleText(const Tizen::Base::String& title); + + /** + * Gets the title of the %Popup control. + * + * @since 2.0 + * + * @return The title of the %Popup control + */ + Tizen::Base::String GetTitleText(void) const; + + /** + * Gets the bounds of the client area. + * + * @since 2.0 + * + * @return The bounds of the client area in a Rectangle instance + */ + Tizen::Graphics::Rectangle GetClientAreaBounds(void) const; + + /** + * Creates and returns a graphics canvas whose bounds (position and size) are equal to the bounds of the client area of the %Popup control. + * + * @since 2.0 + * + * @return The graphic canvas of the %Popup control, @n + * else @c null if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_RESOURCE_UNAVAILABLE The required resource is currently unavailable. + * @remarks The method allocates a Tizen::Graphics::Canvas whose bounds are equal to that of the client area of the %Popup control. @n + * It is the responsibility of the developers to deallocate the canvas after use. + * @remarks The canvas is valid only if the properties of the parent control of the canvas remain unchanged. @n + * Therefore, delete the previously allocated canvas and create a new canvas using the GetCanvasN() method if the size or position of the + * control is changed. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Canvas* GetClientAreaCanvasN(void) const; + + /** + * Translates the specified position to the client coordinates. + * + * @since 2.0 + * + * @return The position in relative to the top-left corner of the client-area, @n + * else @c (-1,-1) if the instance is invalid + * @param[in] position The position relative to the top-left corner of the %Popup control + * @see TranslateFromClientAreaPosition() + */ + Tizen::Graphics::Point TranslateToClientAreaPosition(const Tizen::Graphics::Point& position) const; + + /** + * Translates the specified client position to the control coordinate. + * + * @since 2.0 + * + * @return The position in relative to the top-left corner of the %Popup control, @n + * else @c (-1,-1) if the instance is invalid + * @param[in] clientPosition The position relative to the top-left corner of the client area + * @see TranslateToClientAreaPosition() + */ + Tizen::Graphics::Point TranslateFromClientAreaPosition(const Tizen::Graphics::Point& clientPosition) const; + + /** + * Gets the color of the %Popup control. + * + * @since 2.0 + * + * @return The color, @n + * else RGBA(0, 0, 0, 0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetColor(void) const; + + /** + * Sets the color of the %Popup control. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetColor(const Tizen::Graphics::Color& color); + + /** + * Gets the title text color of the %Popup control. + * + * @since 2.0 + * + * @return The color, @n + * else RGBA(0, 0, 0, 0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetTitleTextColor(void) const; + + /** + * Sets the title text color of the %Popup control. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The title text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTitleTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the data binding context. + * + * @since 2.0 + * + * @return The data binding context + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + DataBindingContext* GetDataBindingContextN(void) const; + +protected: + friend class _PopupImpl; + + // + // The following methods are reserved and may change its name at any time without + // prior notice. + // + virtual void Popup_Reserved1(void) { } + virtual void Popup_Reserved2(void) { } + virtual void Popup_Reserved3(void) { } + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Popup(const Popup& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Popup& operator =(const Popup& rhs); + +}; // Popup + + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_POPUP_H_ diff --git a/inc/FUiCtrlProgress.h b/inc/FUiCtrlProgress.h new file mode 100644 index 0000000..9ae9a0e --- /dev/null +++ b/inc/FUiCtrlProgress.h @@ -0,0 +1,284 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlProgress.h + * @brief This is the header file for the %Progress class. + * + * This header file contains the declarations of the %Progress class and its helper classes. + */ + +#ifndef _FUI_CTRL_PROGRESS_H_ +#define _FUI_CTRL_PROGRESS_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class Progress + * @brief This class is an implementation of a %Progress control. + * + * @since 2.0 + * + * The %Progress class displays the progress of a lengthy operation in a progress bar. + * + * For more information on the class features, see Progress. + * + * The following example demonstrates how to use the %Progress class. + * + * @code +// Sample code for ProgressSample.h +#include + +class ProgressSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener +{ +public: + ProgressSample(void) + : __pProgress(null) + , __pValue(0){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual void OnActionPerformed(const Tizen::Ui::Control&, int); + +private: + static const int ID_BUTTON_CHECKED = 100; + + Tizen::Ui::Controls::Progress* __pProgress; + int __pValue; +}; + * @endcode + * + * @code +// Sample code for ProgressSample.cpp +#include + +#include "ProgressSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +ProgressSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +ProgressSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Progress + __pProgress = new Progress(); + __pProgress->Construct(Rectangle(50, 50, GetClientAreaBounds().width - 100, 100), 0, 100); + __pProgress->SetValue(__pValue); + + // Creates an instance of pButton to control progress value + Button* pButton = new Button(); + pButton->Construct(Rectangle(50, 200, 150, 100), L"Here"); + pButton->SetActionId(ID_BUTTON_CHECKED); + pButton->AddActionEventListener(*this); + + // Adds the __pProgress and the pButton to the form + AddControl(*__pProgress); + AddControl(*pButton); + + return r; +} + +void +ProgressSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_BUTTON_CHECKED : + { + if (__pValue >= 100) + { + __pValue = 0; + } + else + { + __pValue += 10; + } + __pProgress->SetValue(__pValue); + __pProgress->Invalidate(true); + } + break; + default: + break; + } +} + * @endcode + * + */ +class _OSP_EXPORT_ Progress + : public Tizen::Ui::Control +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + Progress(void); + + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~Progress(void); + + + /** + * Initializes this instance of %Progress with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created window along with + * its width and height. + * @param[in] minValue The minimum value of the current instance of %Progress + * @param[in] maxValue The maximum value of the current instance of %Progress + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The value of an argument is outside the valid range defined by the method. @n + * The specified values should be positive and @c minValue should be less than @c maxValue. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully usable only after it has been added to a container, therefore some methods may fail if used earlier. @n + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, int minValue, int maxValue); + +public: + /** + * Sets the current value of the %Progress control. @n + * If the given value is greater than the @c maxValue with which %Progress is constructed, it will be set to %maxValue. The same applies for @c minValue. + * + * @since 2.0 + * + * @param[in] value The current progress value + */ + void SetValue(int value); + + + /** + * Sets the minimum and maximum value of the %Progress control. + * + * @since 2.0 + * + * @return An error code + * @param[in] minValue The minimum value of the current instance of %Progress + * @param[in] maxValue The maximum value of the current instance of %Progress + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The value of an argument is outside the valid range defined by the method. @n + * The specified values should be positive. + * @exception E_SYSTEM A system error has occurred. + */ + result SetRange(int minValue, int maxValue); + + + /** + * Gets the current value of the %Progress control. + * + * @since 2.0 + * + * @return An integer value representing the current value of progress, @n + * else @c -1 if an error occurs + */ + int GetValue(void) const; + + + /** + * Gets the minimum value and the maximum value of the %Progress control. + * + * @since 2.0 + * + * @param[out] minValue The minimum value + * @param[out] maxValue The maximum value + */ + void GetRange(int& minValue, int& maxValue) const; + + + /** + * Gets the percent value of the %Progress control. + * + * @since 2.0 + * + * @return The progress as a percentage, @n + * else @c -1 if an error occurs + */ + int GetPercentComplete(void) const; + + + /** + * Sets the color of the bar. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method ignores the alpha value of the @c color parameter and sets the alpha value to @c 255. + */ + result SetBarColor(const Tizen::Graphics::Color& color); + + + /** + * Gets the color of the bar. + * + * @since 2.0 + * + * @return The color of the bar, @n + * else RGBA(0, 0, 0, 0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetBarColor(void) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Progress(const Progress& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Progress& operator =(const Progress& rhs); + + friend class _ProgressImpl; + +}; // Progress + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_PROGRESS_H_ diff --git a/inc/FUiCtrlProgressPopup.h b/inc/FUiCtrlProgressPopup.h new file mode 100644 index 0000000..43dbe07 --- /dev/null +++ b/inc/FUiCtrlProgressPopup.h @@ -0,0 +1,286 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlProgressPopup.h + * @brief This is the header file for the %ProgressPopup class. + * + * This header file contains the declarations of the %ProgressPopup class. + */ + +#ifndef _FUI_CTRL_PROGRESS_POPUP_H_ +#define _FUI_CTRL_PROGRESS_POPUP_H_ + +#include + +namespace Tizen { namespace Ui +{ +class IProgressPopupEventListener; +}} // Tizen::Ui + + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class ProgressPopup + * @brief This class defines the common behavior of a %ProgressPopup control. + * + * @since 2.0 + * + * The %ProgressPopup class displays processing animation to show processing status. + * It can contain a title, body text and cancel button. + * + * @see Tizen::Ui::Window + * + * The following example demonstrates how to use the %ProgressPopup class. + * + * @code +// Sample code for ProgressPopupSample.h +#include + +class ProgressPopupSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IProgressPopupEventListener +{ +public: + ProgressPopupSample(void); + virtual ~ProgressPopupSample(void); + + virtual bool Initialize(void); + void ShowProgressPopup(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + //IProgressPopupEventListener + virtual void OnProgressPopupCanceled(void); + +private: + static const int ID_BUTTON_PROGRESSPOPUP = 501; + static const int ID_BUTTON_CLOSE_PROGRESSPOPUP = 502; + + Tizen::Ui::Controls::ProgressPopup* __pProgressPopup; +}; + * @endcode + * + * @code +// Sample code for ProgressPopupSample.cpp +#include "ProgressPopupSample.h" + +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +ProgressPopupSample::ProgressPopupSample(void) + : __pProgressPopup(null) +{ +} + +ProgressPopupSample::~ProgressPopupSample(void) +{ +} + +bool +ProgressPopupSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +ProgressPopupSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of ProgressPopup + __pProgressPopup = new (std::nothrow) ProgressPopup(); + __pProgressPopup->Construct(true,false); + __pProgressPopup->SetTitleText(L"ProgressPopup Test"); + __pProgressPopup->SetText(L"Hello World!!"); + __pProgressPopup->AddProgressPopupEventListener(*this); + + // Creates an instance of Button to open the ProgressPopup + Button* pButtonProgressPopup = new Button(); + pButtonProgressPopup->Construct(Rectangle(10, 10, 250, 60), L"Open ProgressPopup"); + pButtonProgressPopup->SetActionId(ID_BUTTON_PROGRESSPOPUP); + pButtonProgressPopup->AddActionEventListener(*this); + + return r; +} + +result +ProgressPopupSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the __pProgressPopup + delete __pProgressPopup; + + return r; +} + +void +ProgressPopupSample::ShowProgressPopup(void) +{ + __pProgressPopup->SetShowState(true); + __pProgressPopup->Show(); +} + +void +ProgressPopupSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_BUTTON_PROGRESSPOPUP: + ShowProgressPopup(); + break; + default: + break; + } +} + +void +ProgressPopupSample::OnProgressPopupCanceled(void) +{ + __pProgressPopup->SetShowState(false); + Invalidate(true); +} + + * @endcode + */ +class _OSP_EXPORT_ ProgressPopup + : public Popup +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + ProgressPopup(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~ProgressPopup(void); + + /** + * Initializes this instance of %ProgressPopup with the specified parameters. + * + * @since 2.0 + * @return An error code + * @param[in] cancelButton Set to @c true if the %ProgressPopup window has a cancel button, @n + * else @c false + * @param[in] translucent Set to @c true if the %ProgressPopup window is translucent, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. @n + * This error occurs when the internal resource is not loaded. + * @remarks To show a %ProgressPopup window, call Show() or DoModal() after calling the Construct() method. @n + * By default, the title area and the body text are not shown. @n + * Use SetTitleText() and SetText() to show the title area and the body text. + * @remarks If cancelButton is set to true and ProgressPopup is closed by pressing a Cancel Button, + * out parameter of DoModal(), modalResult, is -1. + */ + result Construct(bool cancelButton, bool translucent); + + /** + * Sets the text of the %ProgressPopup window. + * + * @since 2.0 + * @return An error code + * @param[in] text The text to be set + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result SetText(const Tizen::Base::String& text); + + /** + * Gets the text of the %ProgressPopup window. + * + * @since 2.0 + * + * @return The text of the %ProgressPopup window, @n + * else an empty string if an error occurs + */ + Tizen::Base::String GetText(void) const; + + /** + * Adds a listener instance @n + * The added listener can listen to events on the given event dispatcher's context when they are fired. + * + * @since 2.0 + * @return An error code + * @param[in] listener The event listener to be added. Listener should be allocated at heap, not stack. + * @exception E_SUCCESS This method was successful. + * @exception E_OBJ_ALREADY_EXIST The listener was already exist. + */ + result AddProgressPopupEventListener(Tizen::Ui::IProgressPopupEventListener& listener); + + /** + * Removes a listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * @return An error code + * @param[in] listener The event listener to be removed. @n + * Listener should be referring to previously allocated instance which is passed as an argument to AddProgressPopupEventListener. + * @exception E_SUCCESS This method was successful. + * @exception E_OBJ_NOT_FOUND The listener was not found. + */ + result RemoveProgressPopupEventListener(Tizen::Ui::IProgressPopupEventListener& listener); + + /** + * Sets the text color of the %ProgressPopup window. + * + * @since 2.0 + * @param[in] color The text color + */ + void SetTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the text color of the %ProgressPopup window. + * + * @since 2.0 + * @return The color, @n + * else RGBA(0, 0, 0, 0) if an error occurs + */ + Tizen::Graphics::Color GetTextColor(void) const; + +protected: + friend class _ProgressPopupImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + ProgressPopup(const ProgressPopup& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + ProgressPopup& operator =(const ProgressPopup& rhs); + +}; // ProgressPopup + + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_PROGRESS_POPUP_H_ diff --git a/inc/FUiCtrlRadioGroup.h b/inc/FUiCtrlRadioGroup.h new file mode 100644 index 0000000..bbc3254 --- /dev/null +++ b/inc/FUiCtrlRadioGroup.h @@ -0,0 +1,327 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlRadioGroup.h + * @brief This is the header file for the %RadioGroup class. + * + * This header file contains the declarations of the %RadioGroup class and its helper classes. + */ + +#ifndef _FUI_CTRL_RADIO_GROUP_H_ +#define _FUI_CTRL_RADIO_GROUP_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class RadioGroup + * @brief This class is an implementation of a %RadioGroup control. + * + * @since 2.0 + * + * The %RadioGroup class displays a set of CheckButtons with radio style together in a group, allowing the user to select only + * one of the predefined set of buttons. + * @n + * For more information on the class features, see Buttons. + * + * The following example demonstrates how to use the %RadioGroup class. + * + * @code +// Sample code for RadioGroupSample.h +#include + +class RadioGroupSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener +{ +public: + RadioGroupSample(void) + : __pRadioGroup(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +private: + static const int ID_BUTTON1_CHECKED = 101; + static const int ID_BUTTON1_UNCHECKED = 102; + static const int ID_BUTTON2_CHECKED = 103; + static const int ID_BUTTON2_UNCHECKED = 104; + + Tizen::Ui::Controls::RadioGroup* __pRadioGroup; +}; + * @endcode + * + * @code +// Sample code for RadioGroupSample.cpp +#include + +#include "RadioGroupSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +RadioGroupSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +RadioGroupSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates instances of CheckButton + CheckButton *pCheckButton1 = new CheckButton(); + pCheckButton1->Construct(Rectangle(50, 50, GetClientAreaBounds().width - 100, 100), + CHECK_BUTTON_STYLE_RADIO, BACKGROUND_STYLE_DEFAULT, false, L"Radio1"); + pCheckButton1->SetActionId(ID_BUTTON1_CHECKED, ID_BUTTON1_UNCHECKED); + pCheckButton1->AddActionEventListener(*this); + + CheckButton *pCheckButton2 = new CheckButton(); + pCheckButton2->Construct(Rectangle(50, 160, GetClientAreaBounds().width - 100, 100), + CHECK_BUTTON_STYLE_RADIO,BACKGROUND_STYLE_DEFAULT, false, L"Radio2"); + pCheckButton2->SetActionId(ID_BUTTON2_CHECKED, ID_BUTTON2_UNCHECKED); + pCheckButton2->AddActionEventListener(*this); + + // Adds check buttons to the form + AddControl(*pCheckButton1); + AddControl(*pCheckButton2); + + // Creates an instance of RadioGroup + __pRadioGroup = new RadioGroup(); + __pRadioGroup->Construct(); + + // Adds the check buttons to the radio group + __pRadioGroup->Add(*pCheckButton1); + __pRadioGroup->Add(*pCheckButton2); + + return r; +} + +result +RadioGroupSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the __pRadioGroup + delete __pRadioGroup; + + return r; +} + +// IActionEventListener implementation +void +RadioGroupSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_BUTTON1_CHECKED: + { + // .... + } + break; + case ID_BUTTON1_UNCHECKED: + { + // .... + } + break; + case ID_BUTTON2_CHECKED: + { + // .... + } + break; + case ID_BUTTON2_UNCHECKED: + { + // .... + } + break; + default: + break; + } +} + * @endcode + * + */ +class _OSP_EXPORT_ RadioGroup + : public Tizen::Ui::Control +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + RadioGroup(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~RadioGroup(void); + + + /** + * Initializes this instance of %RadioGroup. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(void); + +public: + /** + * Adds the check button to the radio group. + * + * @since 2.0 + * + * @return An error code + * @param[in] checkButton The %CheckButton instance to be added + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks Only CheckButtons whose style is CHECK_BUTTON_STYLE_RADIO or CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER can be added to %RadioGroup. + */ + result Add(const CheckButton& checkButton); + + /** + * Removes the check button from the radio group. + * + * @since 2.0 + * + * @return An error code + * @param[in] checkButton The %CheckButton instance to be removed + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The object is not found. + * @exception E_SYSTEM A system error has occurred. + * @remarks Before removing %CheckButton from its parent container, it must be removed from %RadioGroup. + */ + result Remove(const CheckButton& checkButton); + +public: + /** + * Gets the number of check buttons in the radio group. + * + * @since 2.0 + * + * @return The number of check buttons in the radio group + */ + int GetItemCount(void) const; + + /** + * Selects the specified check button in the radio group. + * + * @since 2.0 + * + * @param[in] checkButton The check button to be selected + */ + void SetSelectedItem(const CheckButton& checkButton); + + /** + * Gets the selected check button in the radio group. + * + * @since 2.0 + * + * @return The pointer to the selected check button, @n + * else @c null if an error occurs or no check button in the radio group is selected + * + */ + const CheckButton* GetSelectedItem(void) const; + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is prohibited. If this method is used + // in an application, the application can get rejected during the certification + // process. + // + // (Blocked) Draws the control. + // + // @since 2.0 + // + // @return An error code + // @exception E_UNSUPPORTED_OPERATION This operation is not supported. + // + virtual result Draw(void); + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is prohibited. If this method is used + // in an application, the application can get rejected during the certification + // process. + // + // (Blocked) Shows this control. + // + // @since 2.0 + // + // @return An error code + // @exception E_UNSUPPORTED_OPERATION This operation is not supported. + // + virtual result Show(void); + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is prohibited. If this method is used + // in an application, the application can get rejected during the certification + // process. + // + // (Blocked) Gives the input focus to the control. @n + // One must call this method if the control needs to listen to the user input events such as key pressed. + // + // @since 2.0 + // + // @return An error code + // @exception E_UNSUPPORTED_OPERATION This operation is not supported. + // + virtual result SetFocus(void); + +protected: + friend class _RadioGroupImpl; + +private: + // + // This is the copy constructor for the %RadioGroup class. + // + RadioGroup(const RadioGroup& rhs); + + // + // Assigns the value of the specified instance to the current instance of %RadioGroup. + // + RadioGroup& operator =(const RadioGroup& rhs); + +}; // RadioGroup + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_RADIO_GROUP_H_ diff --git a/inc/FUiCtrlScrollEventTypes.h b/inc/FUiCtrlScrollEventTypes.h new file mode 100644 index 0000000..eb73d54 --- /dev/null +++ b/inc/FUiCtrlScrollEventTypes.h @@ -0,0 +1,50 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlScrollEventTypes.h + * @brief This is the header file for the List enumerations. + * + * @since 2.0 + * + * This header file contains the declarations of the scroll event enumerations. + */ +#ifndef _FUI_CTRL_SCROLL_EVENT_ENUM_H_ +#define _FUI_CTRL_SCROLL_EVENT_ENUM_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum ScrollEndEvent + * + * Defines constants which represent the type of scroll end event. + * + * @since 2.0 + */ +enum ScrollEndEvent +{ + SCROLL_END_EVENT_END_TOP = 0, /**< The scroll reaches top end */ + SCROLL_END_EVENT_END_BOTTOM, /**< The scroll reaches bottom end */ + SCROLL_END_EVENT_END_LEFT, /**< The scroll reaches left end */ + SCROLL_END_EVENT_END_RIGHT /**< The scroll reaches right end */ +}; + +}; +}; +}; // Tizen::Ui::Controls + +#endif diff --git a/inc/FUiCtrlScrollPanel.h b/inc/FUiCtrlScrollPanel.h new file mode 100644 index 0000000..4ed96cc --- /dev/null +++ b/inc/FUiCtrlScrollPanel.h @@ -0,0 +1,503 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlScrollPanel.h + * @brief This is the header file for the %ScrollPanel class. + * + * This header file contains the declarations of the %ScrollPanel class. + */ + +#ifndef _FUI_CTRL_SCROLL_PANEL_H_ +#define _FUI_CTRL_SCROLL_PANEL_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class ScrollPanel + * @brief This class implements a scrollable container class. + * + * @since 2.0 + * + * The %ScrollPanel class is a Panel with automatic scroll bars. + * + * For more information on the class features, see Panels. + * + * The following example demonstrates how to use the %ScrollPanel class. + * + * @code +// Sample code for ScrollPanelSample.h +#include + +class ScrollPanelSample + : public Tizen::Ui::Controls::Form +{ +public: + ScrollPanelSample(void) + : __pScrollPanel(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + +private: + Tizen::Ui::Controls::ScrollPanel* __pScrollPanel; +}; + * @endcode + * + * @code +// Sample code for ScrollPanelSample.cpp +#include + +#include "ScrollPanelSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +ScrollPanelSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +ScrollPanelSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of ScrollPanel + __pScrollPanel = new ScrollPanel(); + __pScrollPanel->Construct(Rectangle(100, 250, 400, 300)); + __pScrollPanel->SetBackgroundColor(Color::GetColor(COLOR_ID_YELLOW)); + + // Creates an instance of Button and an instance of EditField + Button* pButton = new Button(); + pButton->Construct(Rectangle(0, 80, 200, 150), L"Button"); + + EditField* pEdit = new EditField(); + pEdit->Construct(Rectangle(0, 250, 200, 150)); + pEdit->SetText(L"Edit"); + + // Adds the button and the edit field to the ScrollPanel + __pScrollPanel->AddControl(*pButton); + __pScrollPanel->AddControl(*pEdit); + + // Adds the ScrollPanel to the form + AddControl(*__pScrollPanel); + + return r; +} + * @endcode + */ + +class _OSP_EXPORT_ ScrollPanel + : public Panel +{ + +// Lifecycle +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + * + */ + ScrollPanel(void); + + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + * + */ + virtual ~ScrollPanel(void); + + + /** + * Initializes this instance of %ScrollPanel with the specified rectangular region. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The location and size of the %ScrollPanel control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The given width or height is less than 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the scroll direction is vertical and the scroll area is resized automatically. + * @see Tizen::Ui::Container + */ + result Construct(const Tizen::Graphics::Rectangle& rect); + + + /** + * Initializes this instance of %ScrollPanel and child controls with the specified resource ID @n + * + * This method first attempts to find the resource file in the folder that corresponds to the current screen resolution. @n + * If it fails to find the resource file, it searches in other folders in the following order when CoordinateSystem is Logical in the application manifest file @n + * the density folder that corresponds to the current screen size category "res/screen-size-normal/" folder. + * + * @since 2.0 + * + * @return An error code + * @param[in] resourceId The resource ID describing the %ScrollPanel control + * @exception E_SUCCESS The method is successful. + * @exception E_FILE_NOT_FOUND The specified file cannot be found. + * @exception E_INVALID_FORMAT The specified XML format is invalid. + * @exception E_OPERATION_FAILED The operation has failed. + */ + result Construct(const Tizen::Base::String& resourceId); + + /** + * Initializes this instance of %ScrollPanel with the specified rectangular region. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The location and size of the %ScrollPanel control + * @param[in] scrollDirection The scroll direction of %ScrollPanel + * @param[in] autoResizingEnable Whether to resize the client area automatically + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The given width or height is less than 0. + * @see Tizen::Ui::Container + */ + result Construct(const Tizen::Graphics::Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable); + + + /** + * Initializes this instance of %ScrollPanel with the specified layout and rectangular region. + * + * @since 2.0 + * + * @return An error code + * @param[in] layout The layout for both the portrait and landscape mode + * @param[in] rect The location and size of the %ScrollPanel control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG @c layout is already bound to another container, or the given width or the height is less than 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the scroll direction is vertical and the scroll area is resized automatically. + * @see Tizen::Ui::Container + */ + result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Rectangle& rect); + + + /** + * Initializes this instance of %ScrollPanel with the specified layout and rectangular region. + * + * @since 2.0 + * + * @return An error code + * @param[in] layout The layout for both the portrait and landscape mode + * @param[in] rect The location and size of the %ScrollPanel control + * @param[in] scrollDirection The scroll direction of %ScrollPanel + * @param[in] autoResizingEnable Whether to resize the client area automatically + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG @c layout is already bound to another container, or the given width or height is less than 0. + * @see Tizen::Ui::Container + */ + result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable); + + + /** + * Initializes this instance of %ScrollPanel with the specified layouts and rectangular region. + * + * @since 2.0 + * + * @return An error code + * @param[in] portraitLayout The layout for the portrait mode + * @param[in] landscapeLayout The layout for the landscape mode + * @param[in] rect The location and size of the %ScrollPanel control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG @c portraitLayout or @c landscapeLayout is already bound to another container, or the given width or height is less than 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the scroll direction is vertical and the scroll area is resized automatically. + * @see Tizen::Ui::Container + */ + result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Rectangle& rect); + + + /** + * Initializes this instance of %ScrollPanel with the specified layouts and rectangular region. + * + * @since 2.0 + * + * @return An error code + * @param[in] portraitLayout The layout for the portrait mode + * @param[in] landscapeLayout The layout for the landscape mode + * @param[in] rect The location and size of the %ScrollPanel control + * @param[in] scrollDirection The scroll direction of %ScrollPanel + * @param[in] autoResizingEnable Whether to resize the client area automatically + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG @c portraitLayout or @c landscapeLayout is already bound to another container, or the given width or height is less than 0. + * @see Tizen::Ui::Container + */ + result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable); + + + /** + * Adds a listener instance that listens to the state changes of a scroll event. @n + * The added listener can listen to the events on the given event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @see IScrollEventListener::OnScrollEndReached() + * @see RemoveScrollEventListener() + */ + void AddScrollEventListener(IScrollEventListener& listener); + + + /** + * Removes a listener instance that listens to the state changes of a scroll event. @n + * The removed listener cannot listen to the events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to remove + * @see IScrollEventListener::OnScrollEndReached() + * @see AddScrollEventListener() + */ + void RemoveScrollEventListener(IScrollEventListener& listener); + + + /** + * Gets the scroll position. + * + * @since 2.0 + * + * @return The scroll position + */ + int GetScrollPosition(void) const; + + + /** + * @if OSPDEPREC + * Sets the scroll position. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this method, use the SetScrollPosition(int, bool), which supports animated scroll. + * @since 2.0 + * + * @param[in] position The scroll position + * @endif + */ + void SetScrollPosition(int position); + + /** + * Sets the scroll position. + * + * @since 2.0 + * + * @param[in] position The scroll position in pixel + * @param[in] withAnimation @c true to scroll the %ScrollPanel smoothly. @n + * else @c false. + * + */ + void SetScrollPosition(int position, bool withAnimation); + + /** + * Scrolls to the bottom of %ScrollPanel. + * + * @since 2.0 + */ + void ScrollToBottom(void) const; + + + /** + * Scrolls to the top of %ScrollPanel. + * + * @since 2.0 + */ + void ScrollToTop(void) const; + + + /** + * Closes the overlay Window for supporting the overlay keypad. + * + * @since 2.0 + * + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result CloseOverlayWindow(void); + + + /** + * Gets the bounds of the client area. + * + * @since 2.0 + * + * @return The bounds of the client area + * + */ + Tizen::Graphics::Rectangle GetClientAreaBounds(void) const; + + + /** + * Sets the width of the client area. + * + * @since 2.0 + * + * @return An error code + * @param[in] width The width of the client area to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG @c width is less than the width of %ScrollPanel + * @exception E_INVALID_OPERATION The width of the client area cannot be set when auto resizing of the client area is off, or the scroll direction is vertical. + * + */ + result SetClientAreaWidth(int width); + + + /** + * Sets the height of the client area. + * + * @since 2.0 + * + * @return An error code + * @param[in] height The height of the client area to set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG @c height is less than the height of %ScrollPanel + * @exception E_INVALID_OPERATION The height of the client area cannot be set when auto resizing of the client area is off, or the scroll direction is horizontal. + * + */ + result SetClientAreaHeight(int height); + + + /** + * Gets the scroll direction of the %ScrollPanel. + * + * @since 2.0 + * + * @return Direction of %ScrollPanel + * + */ + ScrollPanelScrollDirection GetScrollDirection(void) const; + + + /** + * Gets how the scroll area the %ScrollPanel is resized. + * + * @since 2.0 + * + * @return Whether to resize the client area automatically + * + */ + bool IsScrollAreaAutoResizingEnabled(void) const; + + + /** + * Enables or disables scrolling by page, where page size is determined by the size of the %ScrollPanel. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable page scroll. + * + */ + void SetPageScrollEnabled(bool enable); + + + /** + * Checks whether scrolling by page feature is enabled. + * + * @since 2.0 + * + * @return @c true if the page scroll is enabled. @n + * else @c false. + * + */ + bool IsPageScrollEnabled(void) const; + + + /** + * Sets the visibility of scroll bar. + * + * @since 2.0 + * + * @param[in] visible Set to @c true to show scroll bar. @n + * else @c false. + * + */ + void SetScrollBarVisible(bool visible); + + + /** + * Gets the visibility of scroll bar. + * + * @since 2.0 + * + */ + bool IsScrollBarVisible(void) const; + + + /** + * Sets the scroll input handling mode. + * + * @since 2.0 + * + * @param[in] mode The scroll input handling mode + * @see GetScrollInputMode() + */ + void SetScrollInputMode(ScrollInputMode mode); + + + /** + * Gets the scroll input handling mode. + * + * @since 2.0 + * + * @return The scroll input handling mode + * @see SetScrollInputMode() + */ + ScrollInputMode GetScrollInputMode(void) const; + + +protected: + + friend class _ScrollPanelImpl; + + // Reserved virtual methods for later extension + + // The following methods are reserved and may change its name at any time without prior notice. + virtual void ScrollPanel_Reserved1(void) {} + + virtual void ScrollPanel_Reserved2(void) {} + + virtual void ScrollPanel_Reserved3(void) {} + +private: + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + ScrollPanel(const ScrollPanel& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + ScrollPanel& operator =(const ScrollPanel& rhs); + +}; // ScrollPanel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_SCROLL_PANEL_H_ diff --git a/inc/FUiCtrlScrollPanelTypes.h b/inc/FUiCtrlScrollPanelTypes.h new file mode 100644 index 0000000..114013a --- /dev/null +++ b/inc/FUiCtrlScrollPanelTypes.h @@ -0,0 +1,45 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlScrollPanelTypes.h + * @brief This is the header file for the ScrollPanel enumeration. + * + * The ScrollPanel enumeration defines the data types for the ScrollPanel. + */ +#ifndef _FUI_CTRL_SCROLL_PANEL_TYPES_H_ +#define _FUI_CTRL_SCROLL_PANEL_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum ScrollPanelScrollDirection + * + * Defines the scroll direction type of the ScrollPanel control. + * + * @since 2.0 + */ +enum ScrollPanelScrollDirection +{ + SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL = 0, /**< Vertical scroll mode */ + SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL /**< Horizontal scroll mode */ +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_SCROLL_PANEL_TYPES_H_ diff --git a/inc/FUiCtrlSearchBar.h b/inc/FUiCtrlSearchBar.h new file mode 100644 index 0000000..2a94567 --- /dev/null +++ b/inc/FUiCtrlSearchBar.h @@ -0,0 +1,1427 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlSearchBar.h + * @brief This is the header file for the %SearchBar class. + * + * This header file contains the declarations of the %SearchBar class. + */ + +#ifndef _FUI_CTRL_SEARCH_BAR_H_ +#define _FUI_CTRL_SEARCH_BAR_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Graphics +{ +class Rectangle; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ + +class ISearchBarEventListener; + +/** + * @enum SearchFieldStatus + * + * Defines the possible states of the search field of the search bar. + * + * @since 2.0 + */ +enum SearchFieldStatus +{ + SEARCH_FIELD_STATUS_NORMAL, /**< The normal state */ + SEARCH_FIELD_STATUS_HIGHLIGHTED, /**< The focus-highlighted state */ + SEARCH_FIELD_STATUS_DISABLED /**< The disabled state */ +}; + +/** + * @enum SearchBarButtonStatus + * + * Defines the possible states of the search bar button. + * + * @since 2.0 + */ +enum SearchBarButtonStatus +{ + SEARCH_BAR_BUTTON_STATUS_NORMAL = 0, /**< The normal status */ + SEARCH_BAR_BUTTON_STATUS_PRESSED, /**< The selected status */ + SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED, /**< The highlighted status */ + SEARCH_BAR_BUTTON_STATUS_DISABLED /**< The disabled status */ +}; + +/** + * @enum SearchBarMode + * + * Defines the possible modes of the search bar. + * + * @since 2.0 + */ +enum SearchBarMode +{ + SEARCH_BAR_MODE_NORMAL, /**< The normal mode */ + SEARCH_BAR_MODE_INPUT /**< The input mode */ +}; + +/** + * @class SearchBar + * @brief This class is an implementation of a search bar. + * + * @since 2.0 + * + * The %SearchBar class displays an editable search field for entering keywords and an optional button that is displayed in the + * input mode. + * + * For more information on the class features, see SearchBar. + * + * The following example demonstrates how to use the %SearchBar class. + * + * @code +// Sample code for SearchBarSample.h +#include + +class SearchBarSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::ISearchBarEventListener + , public Tizen::Ui::Controls::IListViewItemEventListener + , public Tizen::Ui::Controls::IListViewItemProvider + , public Tizen::Ui::ITextEventListener +{ +public: + SearchBarSample(void) + : __pSearchBar(null) + , __pSearchBarListView(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + // ISearchBarEventListener + virtual void OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode); + virtual void OnSearchBarContentAreaResized(Tizen::Ui::Controls::SearchBar& source, Tizen::Graphics::Dimension& size) {}; + virtual void OnTextValueChanged(const Tizen::Ui::Control& source); + virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source){}; + + // IListViewItemEventListener + virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state); + virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status); + virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView &listView, int index, Tizen::Ui::Controls::SweepDirection direction); + + //IListViewItemProvider + virtual Tizen::Ui::Controls::ListItemBase* CreateItem (int index, int itemWidth); + virtual bool DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth); + virtual int GetItemCount(void); + +private: + static const int ID_FORMAT_STRING = 500; + + Tizen::Ui::Controls::SearchBar* __pSearchBar; + Tizen::Ui::Controls::ListView* __pSearchBarListView; +}; + * @endcode + * + * @code +// Sample code for SearchBarSample.cpp +#include +#include + +#include "SearchBarSample.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +bool +SearchBarSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +SearchBarSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of SearchBar + __pSearchBar = new SearchBar(); + __pSearchBar->Construct(Rectangle(0, 0, GetClientAreaBounds().width, 110)); + __pSearchBar->SetText(L"Click here! "); + __pSearchBar->AddSearchBarEventListener(*this); + __pSearchBar->AddTextEventListener(*this); + + // Creates an instance of ListView + __pSearchBarListView = new ListView(); + __pSearchBarListView->Construct(Rectangle(0, 110, GetClientAreaBounds().width, GetClientAreaBounds().height - 110), true, false); + __pSearchBarListView->SetItemProvider(*this); + __pSearchBarListView->AddListViewItemEventListener(*this); + __pSearchBarListView->SetTextOfEmptyList(L"No search result"); + __pSearchBarListView->SetShowState(false); + __pSearchBar->SetContent(__pSearchBarListView); + + // Adds controls to the form + AddControl(*__pSearchBar); + + return r; +} + +// ISearchBarEventListener implementation +void +SearchBarSample::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, Tizen::Ui::Controls::SearchBarMode mode) +{ + Rectangle clientRect = GetClientAreaBounds(); + __pSearchBar->SetText(L""); + + if(mode == SEARCH_BAR_MODE_INPUT) + { + SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, false); + __pSearchBar->SetContentAreaSize(Dimension(clientRect.width, clientRect.height)); + __pSearchBarListView->SetSize(Dimension(clientRect.width, clientRect.height)); + __pSearchBarListView->UpdateList(); + } + else + { + SetActionBarsVisible(FORM_ACTION_BAR_FOOTER, true); + __pSearchBarListView->UpdateList(); + __pSearchBarListView->SetShowState(false); + __pSearchBar->SetText(L"Click here!"); + } + Invalidate(true); +} + +void +SearchBarSample::OnTextValueChanged(const Tizen::Ui::Control& source) +{ + if(__pSearchBarListView) + { + __pSearchBarListView->UpdateList(); + __pSearchBarListView->ScrollToItem(0); + __pSearchBarListView->SetShowState(true); + } + Invalidate(true); +} + +// IListViewItemEventListener implementation + void + SearchBarSample::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state) + { + // .... + } + + void + SearchBarSample::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView &listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status) + { + // .... + } + + void + SearchBarSample::OnListViewItemSwept(Tizen::Ui::Controls::ListView &listView, int index, Tizen::Ui::Controls::SweepDirection direction) + { + // .... + } + +//IListViewItemProvider +ListItemBase* +SearchBarSample::CreateItem (int index, int itemWidth) +{ + // Creates an instance of CustomItem + CustomItem* pItem = new CustomItem(); + ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL; + + // Gets texts of the search bar + String inputText = null; + inputText = __pSearchBar->GetText(); + + if(inputText.CompareTo(L"a") == 0 || inputText.CompareTo(L"A") == 0 ) + { + switch (index % 3) + { + case 0: + { + pItem->Construct(Dimension(itemWidth,100), style); + pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"ajo", true); + } + break; + case 1: + { + pItem->Construct(Dimension(itemWidth,100), style); + pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"aeun", true); + } + break; + case 2: + { + pItem->Construct(Dimension(itemWidth,100), style); + pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"abee", true); + } + break; + default: + break; + } + } + else if (inputText.CompareTo(L"b") == 0 || inputText.CompareTo(L"B") == 0) + { + switch (index%3) + { + case 0: + { + pItem->Construct(Dimension(itemWidth,100), style); + pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"bonge", true); + } + break; + case 1: + { + pItem->Construct(Dimension(itemWidth,100), style); + pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"bnpyo", true); + } + break; + case 2: + { + pItem->Construct(Dimension(itemWidth,100), style); + pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"bkueon", true); + } + break; + default: + break; + } + } + else + { + pItem->Construct(Dimension(itemWidth,100), style); + pItem->AddElement(Rectangle(80, 25, 200, 50), ID_FORMAT_STRING, L"default", true); + } + + return pItem; +} + +bool +SearchBarSample::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth) +{ + delete pItem; + pItem = null; + return true; +} + +int +SearchBarSample::GetItemCount(void) +{ + return 3; +} + * @endcode + * + */ + +class _OSP_EXPORT_ SearchBar + : public Tizen::Ui::Control +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + SearchBar(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~SearchBar(void); + + /** + * Initializes this instance of the %SearchBar control with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created window along with + * the width and height of the control. + * @param[in] searchBarButton Set to @c true to display the search bar button, @n + * else @c false + * @param[in] keypadAction The keypad action + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or @n + * the action ID of the specified item must be a positive integer. + * @exception E_SYSTEM A system error has occurred. + * @remarks It is recommended that %SearchBar should be placed at the top-left corner of Form's client area. + * @remarks By default, a "Cancel" button is displayed if @c searchBarButton is set to @c true. When the user presses the cancel button, + * the %SearchBar control returns to SEARCH_BAR_MODE_NORMAL automatically. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, bool searchBarButton = true, KeypadAction keypadAction = KEYPAD_ACTION_SEARCH); + + /** + * Gets the content of Control. + * + * @since 2.0 + * + * @return The control that is displayed in the content area of %SearchBar in the SEARCH_BAR_MODE_INPUT mode, @n + * else @c null if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Ui::Control* GetContent(void) const; + + /** + * Sets the content control. + * + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSetContentPage "here" + * @endif + * @return An error code + * @param[in] pContent The control that is to be displayed in the content area of the search bar + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The following controls cannot be set as the content: @n + * @li All classes derived from the Window class + * @li All picker classes (For example, DateTimePicker) + * @li Form + * @li Keypad + * @li OverlayPanel + * @exception E_SYSTEM A system error has occurred. + * @remarks The specified content control is displayed when the mode of the %SearchBar control is changed to SEARCH_BAR_MODE_INPUT. + * @see GetContentAreaSize() + * @see AddSearchBarEventListener() + * @see ISearchBarEventListener + */ + result SetContent(const Tizen::Ui::Control* pContent); + /** + * @page CompSetContentPage Compatibility for SetContent() + * @section CompSetContentPage IssueSection Issues + * Implementing this method in OSP compatible applications has the following issue: @n + * SetContent() method passes the ownership of Content control to SearchBar in OSP, + * whereas the Content control ownership remains with the caller in Tizen. + * + * @section CompSetContentPage SolutionSection Resolutions + * In Tizen, the caller should delete the previous Content control, if this method is called more than once. + */ + + /** + * Updates the content area of the %SearchBar control. + * + * @since 2.0 + * + * @return An error code + * @param[in] show Set to @c true to perform show on the content area, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The current mode of %SearchBar prohibits the execution of the method. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method performs Invalidate() on the content area. + */ + result UpdateContentArea(bool invalidate = true); + + /** + * Sets the visibility state of the content area. + * + * @since 2.0 + * + * @return An error code + * @param[in] visible Set to @c true to make the content area visible, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see IsContentAreaVisible() + */ + result SetContentAreaVisible(bool visible); + + /** + * Checks whether the content area is visible. + * + * @since 2.0 + * + * @return @c true if the content area is visible, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @see SetContentAreaVisible() + */ + bool IsContentAreaVisible(void) const; + + /** + * Sets the size of the content area of the %SearchBar control. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The size of the content area + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The width and height of @c size must be greater than or equal to @c 0. + * @remarks The content area must be resized when the orientation of the form is changed once the size of the content area is changed. + * @see GetContentAreaSize() + */ + result SetContentAreaSize(const Tizen::Graphics::Dimension& size); + + /** + * Gets the size of the content area of the %SearchBar control. + * + * @since 2.0 + * + * @return The size of the content area + * @remarks The content area is the area where the 'content' of the %SearchBar control is displayed. The size of the content areas can + * be changed at runtime. + * @see AddSearchBarEventListener() + * @see ISearchBarEventListener + */ + Tizen::Graphics::Dimension GetContentAreaSize(void) const; + +// Modes + /** + * Gets the search bar mode. + * + * @since 2.0 + * + * @return The search bar mode + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetMode() + */ + SearchBarMode GetMode(void) const; + + /** + * Checks whether the search bar mode is locked. + * + * @since 2.0 + * + * @return @c true if the mode is locked, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetModeLock() + */ + bool IsModeLocked(void) const; + + /** + * Sets the search bar mode. + * + * @since 2.0 + * + * @return An error code + * @param[in] mode The search bar mode + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation, or @n + * the mode is locked. + * @exception E_SYSTEM A system error has occurred. + * @see GetMode() + * @see SetModeLock() + */ + result SetMode(SearchBarMode mode); + + /** + * Sets the lock status of the search bar mode. + * + * @since 2.0 + * + * @return An error code + * @param[in] modeLocked Set to @c true to lock the search bar mode, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetMode() + */ + result SetModeLocked(bool modeLocked); + + /** + * Gets the action ID of the search bar button. + * + * @since 2.0 + * + * @return The action ID, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * By default, the method returns @c -1 if no user defined search bar button is set. + */ + int GetButtonActionId(void) const; + + /** + * Gets the color of the search bar button for the specified state. + * + * @since 2.0 + * + * @return The color of the search bar button, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The status of the search bar button + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetButtonColor() + */ + Tizen::Graphics::Color GetButtonColor(SearchBarButtonStatus status) const; + + /** + * Gets the text color of the search bar button for the specified state. + * + * @since 2.0 + * + * @return The text color of the search bar button, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The status of the search bar button + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetButtonTextColor(SearchBarButtonStatus status) const; + + /** + * Gets the state of the search bar button. + * + * @since 2.0 + * + * @return The state of the search bar button + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + SearchBarButtonStatus GetButtonStatus(void) const; + + /** + * Sets the user defined search bar button. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The button text + * @param[in] actionId The button action ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or @n + * the specified @c actionId must be greater than or equal to @c 0. + * @exception E_SYSTEM A system error has occurred. + */ + result SetButton(const Tizen::Base::String& text, int actionId); + + /** + * Sets the enabled status of the search bar button. + * + * @since 2.0 + * + * @return An error code + * @param[in] enabled Set to @c true to enable the search bar button, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetButtonEnabled(bool enabled); + + /** + * Sets the color of the search bar button for the specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The button status + * @param[in] color The button color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetButtonColor() + */ + result SetButtonColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the button of the %SearchBar control for the specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The button status + * @param[in] color The button text color to set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetButtonTextColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color); + + /** + * Appends the specified character at the end of the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] character The character to be added + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %SearchBar control. @n + * To display the changes, the control must be drawn again. + */ + result AppendCharacter(const Tizen::Base::Character& character); + + /** + * Appends the specified text at the end of the existing text. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be appended + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks To denote the end of a line use '\\n'. @n + * The method modifies the text buffer that is managed by the %SearchBar control. @n + * To display the changes, the control must be drawn again. + */ + result AppendText(const Tizen::Base::String& text); + + + /** + * Sets the text to be displayed. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be displayed + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks To denote the end of a line use '\\n'. @n + * The method modifies the text buffer that is managed by the %SearchBar control. @n + * To display the changes, the control must be drawn again. + */ + result SetText(const Tizen::Base::String& text); + + /** + * Inserts the character at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The position to insert the character + * @param[in] character The character to be inserted + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n + * The specified @c index is greater than the number of elements or less than @c 0. + * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the system limitation. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %SearchBar control. @n + * To display the changes, the control must be drawn again. + */ + result InsertCharacterAt(int index, const Tizen::Base::Character& character); + + /** + * Inserts the specified text at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The position at which to insert + * @param[in] text The text to be inserted + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n + * The specified @c index is greater than the number of elements or less than @c 0. + * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the system limitation. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %SearchBar control. + * To display the changes, the control must be drawn again. + */ + result InsertTextAt(int index, const Tizen::Base::String& text); + + /** + * Deletes the character at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c index is negative. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n + * The specified @c index is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %SearchBar control. @n + * To display the changes, the control must be drawn again. + */ + result DeleteCharacterAt(int index); + + /** + * Clears the text that is displayed by the %SearchBar control. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %SearchBar control. @n + * To display the changes, the control must be drawn again. + */ + result Clear(void); + + /** + * Gets the length of the text that is displayed by the %SearchBar control. + * + * @since 2.0 + * + * @return The length of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetTextLength(void) const; + + /** + * Gets the text that is displayed by the %SearchBar control. + * + * @since 2.0 + * + * @return The text displayed by the %SearchBar control, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetText() + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets a portion of text that is displayed by the %SearchBar control. + * + * @since 2.0 + * + * @return The specified portion of the text, @n + * else an empty string if an error occurs + * @param[in] start The starting index of range + * @param[in] end The last index of range + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or @n + * either the @c start or @c end parameter is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetText() + */ + Tizen::Base::String GetText(int start, int end) const; + + /** + * Gets the limit of the length of the text. + * + * @since 2.0 + * + * @return The limit of the text length, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * The default limit length is @c 500. + * @see SetLimitLength() + */ + int GetLimitLength(void) const; + + /** + * Sets the limit of the length of the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] limitLength The limit text length to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid, or @n + * the specified limit length cannot be @c 0 or negative. + * @exception E_SYSTEM A system error has occurred. + * @see GetLimitLength() + */ + result SetLimitLength(int limitLength); + + /** + * Shows the keypad associated with the %SearchBar control. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + * @see HideKeypad() + */ + result ShowKeypad(void) const; + + /** + * Hides the keypad associated with the %SearchBar control. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see ShowKeypad() + */ + result HideKeypad(void) const; + + /** + * Gets the text size of the search field. + * + * @since 2.0 + * + * @return The size of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetSearchFieldTextSize() + */ + int GetSearchFieldTextSize(void) const; + + /** + * Sets the text size of the text field of the %SearchBar control. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The text size + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid, or @n + * the specified @c size cannot be a negative value. + * @exception E_SYSTEM A system error has occurred. + * @see GetSearchFieldTextSize() + */ + result SetSearchFieldTextSize(int size); + + /** + * Gets the start and the end index of the currently selected text block. + * + * @since 2.0 + * + * @return An error code + * @param[out] start The start index of the text block + * @param[out] end The end index of the text block + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method returns @c start = 0 and @c end = 0 if no text block is selected. + * @see ReleaseBlock() + * @see SetBlockRange() + */ + result GetBlockRange(int& start, int& end) const; + + /** + * Releases the selection of the current text block. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetBlockRange() + * @see SetBlockRange() + */ + result ReleaseBlock(void); + + /** + * Sets the block range for the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] start The start index of the text block + * @param[in] end The end index of the text block + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or @n + * either the @c start or @c end parameter is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @see ReleaseBlock() + * @see GetBlockRange() + */ + result SetBlockRange(int start, int end); + + /** + * Removes the text of the selected text block. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveTextBlock(void); + + /** + * Gets the color of the %SearchBar control for the specified status. + * + * @since 2.0 + * + * @return The color of the %SearchBar control, @n + * else RGBA(0,0,0,0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetColor() + */ + Tizen::Graphics::Color GetColor(void) const; + + /** + * Gets the color of the search field for the specified status. + * + * @since 2.0 + * + * @return The color, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The search field status + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetSearchFieldColor() + */ + Tizen::Graphics::Color GetSearchFieldColor(SearchFieldStatus status) const; + + /** + * Gets the text color of the search field for the specified status. + * + * @since 2.0 + * + * @return The text color, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The search field status + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetSearchFieldTextColor() + */ + Tizen::Graphics::Color GetSearchFieldTextColor(SearchFieldStatus status) const; + + /** + * Sets the background bitmap of the %SearchBar control. + * + * @since 2.0 + * + * @return An error code + * @param[in] bitmap The background bitmap + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the color of the search bar. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetColor() + */ + result SetColor(const Tizen::Graphics::Color& color); + + /** + * Sets the color of the search field for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The state of the search field + * @param[in] color The text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetSearchFieldColor() + */ + result SetSearchFieldColor(SearchFieldStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the search field for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The state of the search field + * @param[in] color The text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetSearchFieldTextColor() + */ + result SetSearchFieldTextColor(SearchFieldStatus status, const Tizen::Graphics::Color& color); + + /** + * Gets the guide text. + * + * @since 2.0 + * + * @return The guide text, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see GetGuideText() + */ + Tizen::Base::String GetGuideText(void) const; + + /** + * Sets the guide text. @n + * This text is displayed when there is no text in the %SearchBar control. + * + * @since 2.0 + * + * @return An error code + * @param[in] guideText The guide text + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetGuideText() + */ + result SetGuideText(const Tizen::Base::String& guideText); + + /** + * Gets the text color of the guide text. + * + * @since 2.0 + * + * @return The text color of the guide text, @n + * else RGBA(0,0,0,0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetGuideTextColor() + */ + Tizen::Graphics::Color GetGuideTextColor(void) const; + + /** + * Sets the text color of the guide text. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The guide text color + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetGuideTextColor() + */ + result SetGuideTextColor(const Tizen::Graphics::Color& color); + +// Cursor + /** + * Gets the current cursor position index. + * + * @since 2.0 + * + * @return The cursor position, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetCursorPosition() + */ + int GetCursorPosition(void) const; + + /** + * Sets the cursor at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The cursor index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n + * The specified @c index is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @see GetCursorPosition() + */ + result SetCursorPosition(int index); + + /** + * Checks whether the lowercase mode is enabled. + * + * @since 2.0 + * + * @return @c true if the lowercase mode is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetLowerCaseModeEnabled() + */ + bool IsLowerCaseModeEnabled(void) const; + + /** + * Enables or disables the lowercase mode. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable the lowercase mode, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see IsLowerCaseModeEnabled() + */ + void SetLowerCaseModeEnabled(bool enable); + +// Ellipsis + /** + * Gets the ellipsis position. + * + * @since 2.0 + * + * @return The ellipsis position + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetEllipsisPosition() + */ + EllipsisPosition GetEllipsisPosition(void) const; + + /** + * Sets the ellipsis position. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The ellipsis position + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetEllipsisPosition() + */ + result SetEllipsisPosition(EllipsisPosition position); + + /** + * Sets the input language. + * + * @since 2.0 + * + * @return An error code + * @param[in] languageCode The language to set + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The application can set the language of the current keypad that is associated with the current %SearchBar. @n + * This method only works if the language to set is supported by the current preloaded keypad. + */ + + result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode); + + /** + * Gets the current input language. + * + * @since 2.0 + * + * @return An error code + * @param[out] language The current input language + * @exception E_SUCCESS The method is successful. + * @remarks The application can get the current language of the keypad that is associated with the current %SearchBar. + */ + + result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const; + + /** + * Gets the keypad action type. + * + * @since 2.0 + * + * @return The keypad action + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + KeypadAction GetKeypadAction(void) const; + + /** + * Checks whether the text prediction is enabled. + * + * @since 2.0 + * @return @c true if the text prediction is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @see SetTextPredictionEnabled() + */ + bool IsTextPredictionEnabled(void) const; + + /** + * Enables or disables the text prediction. + * + * @since 2.0 + * @param[in] enable Set to @c true to enable the text prediction, @n + * else @c false + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION This operation is not supported. + * @see IsTextPredictionEnabled() + */ + result SetTextPredictionEnabled(bool enable); + + /** + * Adds the specified action event listener. @n + * The added listener is notified when the user clicks the search bar button. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @see RemoveActionEventListener() + */ + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * Removes the specified action event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddActionEventListener() + */ + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * Adds the specified text event listener. @n + * The added listener can listen to events on the context of the specified event dispatcher when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks The added listener is notified when: @n + * @li The user presses a key on the software keypad. + * @li The user selects a word in the candidate list. + * @li The user pastes a text. + * @see RemoveTextEventListener() + */ + void AddTextEventListener(Tizen::Ui::ITextEventListener& listener); + + /** + * Removes the specified text event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddTextEventListener() + */ + void RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener); + + /** + * Adds the specified search bar event listener. @n + * The added listener can listen to events on the context of the specified event dispatcher when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks The added listener is notified when: @n + * @li The user presses a key on the software keypad. + * @li The user selects a word in the candidate list. + * @li The user pastes a text. + * @see AddSearchBarEventListener() + */ + void AddSearchBarEventListener(ISearchBarEventListener& listener); + + /** + * Removes the specified search bar event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see RemoveTextEventListener() + */ + void RemoveSearchBarEventListener(ISearchBarEventListener& listener); + + /** + * Adds the specified text block event listener. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks Programmatically, modification of the text selection does not cause the text block selection event to fire. + * @see RemoveTextBlockEventListener() + */ + void AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + /** + * Removes the specified text block event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddTextBlockEventListener() + */ + void RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + /** + * Adds the specified keypad event listener. @n + * The added listener is notified when the keypad associated with this text editor is opened or closed. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @see RemoveKeypadEventListener() + */ + void AddKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + + /** + * Removes the specified keypad event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddKeypadEventListener() + */ + void RemoveKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + + /** + * Adds a listener instance for language events. @n + * The added listener is notified when the input language is changed. + * + * @since 2.0 + * + * @param[in] listener The listener to add + * @remarks The application can recognize when the language is changed from the keypad by adding Tizen::Ui::ILanguageEventListener. + * @see RemoveLanguageEventListener() + */ + + void AddLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + + /** + * Removes the specified listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to remove + * @see AddLanguageEventListener() + */ + + void RemoveLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + + +protected: + friend class _SearchBarImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + SearchBar(const SearchBar& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + SearchBar& operator =(const SearchBar& rhs); + +}; // SearchBar + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_SEARCH_BAR_H_ diff --git a/inc/FUiCtrlSectionTableView.h b/inc/FUiCtrlSectionTableView.h new file mode 100644 index 0000000..4357851 --- /dev/null +++ b/inc/FUiCtrlSectionTableView.h @@ -0,0 +1,707 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlSectionTableView.h + * @brief This is the header file for the %SectionTableView class. + * + * This header file contains the declarations of the %SectionTableView class and its helper classes. + */ + +#ifndef _FUI_CTRL_SECTION_TABLE_VIEW_H_ +#define _FUI_CTRL_SECTION_TABLE_VIEW_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class ISectionTableViewItemProvider; +class ISectionTableViewItemEventListener; +class IFastScrollListener; +class IScrollEventListener; + +/** + * @class SectionTableView + * @brief This class defines common behavior for a %SectionTableView control. + * + * @since 2.0 + * + * The %SectionTableView class defines common behavior for a %SectionTableView control. + * @code +//Sample code for SectionTableViewSample.h +#include + +class SectionTableViewSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::ISectionTableViewItemProvider + , public Tizen::Ui::Controls::ISectionTableViewItemEventListener +{ +public: + SectionTableViewSample(void) + : __pSectionTableView(null) + , __pContextItem(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // ISectionTableViewItemEventListener + virtual void OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::SectionTableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + virtual void OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::SectionTableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated); + + // ISectionTableViewItemProvider + virtual int GetSectionCount(void); + virtual int GetItemCount(int sectionIndex); + virtual bool HasSectionHeader(int sectionIndex); + virtual bool HasSectionFooter(int sectionIndex); + virtual Tizen::Base::String GetSectionHeader(int sectionIndex); + virtual Tizen::Base::String GetSectionFooter(int sectionIndex); + virtual int GetDefaultItemHeight(void); + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int sectionIndex, int itemIndex, int itemWidth); + virtual bool DeleteItem(int sectionIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + virtual void UpdateItem(int sectionIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + +private: + Tizen::Ui::Controls::SectionTableView* __pSectionTableView; +}; + * @endcode + * + * @code + +//Sample code for SectionTableViewSample.cpp +#include +#include + +#include "SectionTableViewSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui::Controls; + +bool +SectionTableViewSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +SectionTableViewSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of TableView + __pSectionTableView = new TableView(); + __pSectionTableView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT); + __pSectionTableView->SetItemProvider(*this); + __pSectionTableView->AddTableViewItemEventListener(*this); + + // Adds the TableView to the form + AddControl(*__pSectionTableView); + return r; +} + +result +SectionTableViewSample::OnTerminating(void) +{ + return E_SUCCESS; +} + +// ISectionTableViewItemEventListener implementation +void +SectionTableViewSample::OnSectionTableViewItemStateChanged(SectionTableView& tableView, int sectionIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status) +{ + // .... +} + +void +SectionTableViewSample::OnSectionTableViewContextItemActivationStateChanged(SectionTableView& tableView, int sectionIndex, int itemIndex, TableViewContextItem* pContextItem, bool activated) +{ + // .... +} + +// ISectionTableViewItemProvider implementation +int +SectionTableViewSample::GetSectionCount(void) +{ + return 10; +} + +int +SectionTableViewSample::GetItemCount(int sectionIndex) +{ + return 5; +} + +bool +SectionTableViewSample::HasSectionHeader(int sectionIndex) +{ + true; +} + +bool +SectionTableViewSample::HasSectionFooter(int sectionIndex) +{ + true; +} + +String +SectionTableViewSample::GetSectionHeader(int sectionIndex) +{ + String text; + text.Format(30, L"Section header %d", sectionIndex); + + return text; +} + +String +SectionTableViewSample::GetSectionFooter(int sectionIndex) +{ + String text; + text.Format(30, L"Section footer %d", sectionIndex); + + return text; +} + +int +SectionTableViewSample::GetDefaultItemHeight(void) +{ + return 100; +} + +TableViewItem* +SectionTableViewSample::CreateItem(int sectionIndex, int itemIndex, int itemWidth) +{ + TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL; + TableViewItem* pItem = new TableViewItem(); + + switch (itemIndex % 5) + { + case 0: + style = TABLE_VIEW_ANNEX_STYLE_NORMAL; + break; + case 1: + style = TABLE_VIEW_ANNEX_STYLE_MARK; + break; + case 2: + style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING; + break; + case 3: + style = TABLE_VIEW_ANNEX_STYLE_DETAILED; + break; + case 4: + style = TABLE_VIEW_ANNEX_STYLE_RADIO; + break; + default: + break; + } + + pItem->Construct(Dimension(itemWidth, GetDefaultItemHeight()), style); + + String text; + text.Format(30, L"TableViewItem %d", itemIndex); + + Label* pLabel = new Label(); + pLabel->Construct(Rectangle(0, 0, itemWidth, GetDefaultItemHeight(), text); + + pItem->AddControl(*pLabel); + + return pItem; + +} + +bool +SectionTableViewSample::DeleteItem(int sectionIndex, int itemIndex, TableViewItem* pItem) +{ + delete pItem; + + return true; +} + +void +SectionTableViewSample::UpdateItem(int sectionIndex, int itemIndex, TableViewItem* pItem) +{ + // .... +} +* @endcode +* +*/ + +class _OSP_EXPORT_ SectionTableView + : public Tizen::Ui::Container +{ +public: + /** + * The object is not fully constructed after this constructor is called. Hence, the Construct() method must be called after calling this constructor. + * + * @since 2.0 + */ + SectionTableView(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~SectionTableView(void); + + /** + * Initializes this instance of %SectionTableView with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class + * This instance represents the x and y coordinates of the left top corner of the created %SectionTableView along with the width and height. + * @param[in] itemDivider Set to @c true to display an item divider, @n + * else @c false + * @param[in] scrollStyle The style of %SectionTableView scroll bar style + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or either the rect.width or rect.height parameter has a negative value. + * + */ + result Construct(const Tizen::Graphics::Rectangle& rect, bool itemDivider, TableViewScrollBarStyle scrollStyle); + + /** + * Sets the item provider that creates and deletes items for the section style table view. + * + * @since 2.0 + * + * @param[in] pProvider The item provider to create and delete items + * @remarks If an item provider is not set for the table view, the table view does not work. + * The specified provider should be allocated in heap memory. + */ + void SetItemProvider(ISectionTableViewItemProvider* pProvider); + + /** + * Sets the color of a section. + * + * @since 2.0 + * + * @param[in] color The section color + * @remarks This method works only when the style of the %SectionTableView control is TABLE_VIEW_STYLE_SECTION. + */ + void SetSectionColor(const Tizen::Graphics::Color& color); + + /** + * Gets the color of a section. + * + * @since 2.0 + * + * @return The section color + */ + Tizen::Graphics::Color GetSectionColor(void) const; + + /** + * Sets the grouped look is enabled. + * + * @since 2.0 + * + * @param[in] enable The enabled/disabled status + */ + void SetGroupedLookEnabled(bool enable); + + /** + * Returns whether the grouped look is enabled or not. + * + * @since 2.0 + * + * @return @c true if the grouped look is enabled, else @c false + */ + bool IsGroupedLookEnabled(void) const; + + /** + * Adds a listener instance that listens to state changes of table view items. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @remarks The specified listener should be allocated in heap memory. + */ + result AddSectionTableViewItemEventListener(ISectionTableViewItemEventListener& listener); + + /** + * Removes a listener instance that listens to state changes of table view items. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The listener is not found. + */ + result RemoveSectionTableViewItemEventListener(ISectionTableViewItemEventListener& listener); + + /** + * Adds a listener instance that listens to state changes of a fast scroll. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @remarks The specified listener should be allocated in heap memory. + */ + result AddFastScrollListener(IFastScrollListener& listener); + + /** + * Removes a listener instance that listens to state changes of a fast scroll. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_OBJ_NOT_FOUND The listener is not found. + */ + result RemoveFastScrollListener(IFastScrollListener& listener); + + /** + * Adds a listener instance that listens to state changes of a scroll event. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @see IScrollEventListener::OnScrollEndReached() + * @see RemoveScrollEventListener() + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @remarks The specified listener should be allocated in heap memory. + */ + result AddScrollEventListener(IScrollEventListener& listener); + + /** + * Removes a listener instance that listens to state changes of a scroll event. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to remove + * @see IScrollEventListener::OnScrollEndReached() + * @see AddScrollEventListener() + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_OBJ_NOT_FOUND The listener is not found. + */ + result RemoveScrollEventListener(IScrollEventListener& listener); + + /** + * Sets the text index of the fast scroll. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text of the index + * @param[in] useSearchIcon Set to @c true to show the magnifying icon, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + */ + result SetFastScrollIndex(const Tizen::Base::String& text, bool useSearchIcon); + + /** + * Gets the section and item indexes of the top item. + * + * @since 2.0 + * + * @return An error code + * @param[out] sectionIndex The section index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND Top drawn item is not found. + */ + result GetTopDrawnItemIndex(int& sectionIndex, int& itemIndex) const; + + /** + * Gets the section and item indexes of the bottom item. + * + * @since 2.0 + * + * @return An error code + * @param[out] sectionIndex The section index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND Bottom drawn item is not found. + */ + result GetBottomDrawnItemIndex(int& sectionIndex, int& itemIndex) const; + + /** + * Scrolls to the item at the specified index. + * The specified item is drawn at the position specified by the item alignment. + * + * @since 2.0 + * + * @return An error code + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @param[in] itemAlignment The item alignment + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + result ScrollToItem(int sectionIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment = TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP); + + /** + * Checks or unchecks the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @param[in] check Set to @c true to select the item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The item is disabled. + * @remarks This method works only when the annex style of the item allows selection. + */ + result SetItemChecked(int sectionIndex, int itemIndex, bool check); + + /** + * Returns whether the item at the specified index is selected or not. + * + * @since 2.0 + * + * @return @c true if the item is selected, @n + * else @c false + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @remarks This method returns @c false, if the annex style of the item does not allow selection. + */ + bool IsItemChecked(int sectionIndex, int itemIndex) const; + + /** + * Enables or disables the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @param[in] enable Set to @c true to enable the specified item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + result SetItemEnabled(int sectionIndex, int itemIndex, bool enable); + + /** + * Returns whether the item at the specified index is enabled or disabled. + * + * @since 2.0 + * + * @return @c true if the item is enabled, @n + * else @c false + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + bool IsItemEnabled(int sectionIndex, int itemIndex) const; + + /** + * Counts the total number of sections. + * + * @since 2.0 + * + * @return The total number of sections + */ + int GetSectionCount(void) const; + + /** + * Counts all the items of the specified section. + * + * @since 2.0 + * + * @return The total number of items in the specified section + * @param[in] sectionIndex The section index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + int GetItemCountAt(int sectionIndex) const; + + /** + * Updates the specified item. @n + * For instance, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD is used when a new item needs to be added and TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE is used when an item is deleted from the + * table view. Moreover, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY is used when the content of an existing item has changed and it needs to be updated. + * Note that calling this method with TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY invokes item provider's UpdateItem() for the given index in sequence. + * + * @since 2.0 + * + * @return An error code + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @param[in] type The item to be added, removed, or modified + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @remarks If the specified item. itemIndex is -1, then the method is applied to the section item with the given index. + * Note that if TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE option is used to a section item, all the items in the section (including the section item itself) are + * removed from the table view. + */ + result RefreshItem(int sectionIndex, int itemIndex, TableViewRefreshType type); + + /** + * Updates all the items of a table view. + * + * @since 2.0 + * + * @return An error code + * @remarks This method clears all the items in the table view and invokes the methods of the item provider again to update the table view. + */ + void UpdateTableView(void); + + /** + * Gets the index of the item at the specified position. + * + * @since 2.0 + * + * @param[in] position The position of the item + * @param[out] sectionIndex The section index of the item on specified position + * @param[out] itemIndex The item index of the item on specified position + * @remarks This method sets both of sectionIndex and itemIndex to -1 if no item is found at the given position. + */ + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& sectionIndex, int& itemIndex) const; + + /** + * Sets the color of a division line between items. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The division line color + */ + void SetItemDividerColor(const Tizen::Graphics::Color& color); + + /** + * Gets the color of a division line between items. + * + * @since 2.0 + * + * @return The color of a division line + */ + Tizen::Graphics::Color GetItemDividerColor(void) const; + + /** + * Sets the background color of this control. + * + * @since 2.0 + * + * @param[in] color The background color + * @remarks The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, + * only the bitmap image is displayed. + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * Gets the background color of this control. + * + * @since 2.0 + * + * @return The background color + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + + /** + * Sets the scroll input handling mode. + * + * @since 2.0 + * + * @param[in] mode The scroll input handling mode + * @see GetScrollInputMode() + */ + void SetScrollInputMode(ScrollInputMode mode); + + /** + * Gets the scroll input handling mode. + * + * @since 2.0 + * + * @return The scroll input handling mode + * @see SetScrollInputMode() + */ + ScrollInputMode GetScrollInputMode(void) const; + + /* + * Scrolls the list contents with the amount of pixels. + * + * @since 2.0 + * + * @return An error code + * @param[in] pixel The amount of pixels to scroll + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c pixel is out of range. + * @remarks If you call ScrollByPixel() with negative @c pixel when position of scroll is already top of contents then it will return E_OUT_OF_RANGE. + * Likewise, in case of positive @c pixel on the bottom position of scroll it will also return E_OUT_OF_RANGE. + */ + result ScrollByPixel(int pixel); + + /* + * Gets the current scroll position + * + * @since 2.0 + */ + int GetCurrentScrollPosition(void) const; + + /* + * Enables or disables the scroll of SectionTableView items. + * + * @since 2.0 + */ + void SetScrollEnabled(bool enable); + + /* + * Checks whether the scroll is enabled or disabled. + * + * @since 2.0 + */ + bool IsScrollEnabled(void) const; + +private: + friend class _TableViewImpl; + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + SectionTableView(const SectionTableView& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + SectionTableView& operator =(const SectionTableView& rhs); +}; // SectionTableView + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_SECTION_TABLE_VIEW_H_ diff --git a/inc/FUiCtrlSimpleItem.h b/inc/FUiCtrlSimpleItem.h new file mode 100644 index 0000000..00bf28b --- /dev/null +++ b/inc/FUiCtrlSimpleItem.h @@ -0,0 +1,112 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlSimpleItem.h + * @brief This is the header file for the %SimpleItem class. + * + * This header file contains the declarations of the %SimpleItem class and its helper classes. + */ + +#ifndef _FUI_CTRL_SIMPLE_ITEM_H_ +#define _FUI_CTRL_SIMPLE_ITEM_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _SimpleItemImpl; + +/** + * @class SimpleItem + * @brief This class defines the common behavior of a %SimpleItem. + * + * @since 2.0 + * + * The %SimpleItem class displays a list item, which is the unit of handling a ListView or GroupedListView. It provides the default + * formatting of the list items. + * @n + * For more information on the class features, see ListViews. + * + */ + +class _OSP_EXPORT_ SimpleItem + : public ListItemBase +{ +public: + /** + * The object is not fully constructed after this constructor is + * called. For full construction, the Construct() method must be + * called right after calling this constructor. + * + * @since 2.0 + */ + SimpleItem(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~SimpleItem(void); + + /** + * Initializes this instance of %SimpleItem with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemSize The size of the item + * @param[in] style The style of Annex + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Graphics::Dimension& itemSize, ListAnnexStyle style); + + /** + * Sets the text string and bitmap image for %SimpleItem. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text string to add + * @param[in] pBitmap The bitmap image to display + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetElement(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap = null); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + SimpleItem(const SimpleItem& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + SimpleItem& operator =(const SimpleItem& rhs); +}; // SimpleItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_SIMPLE_ITEM_H_ diff --git a/inc/FUiCtrlSlidableGroupedList.h b/inc/FUiCtrlSlidableGroupedList.h new file mode 100644 index 0000000..e0b69ec --- /dev/null +++ b/inc/FUiCtrlSlidableGroupedList.h @@ -0,0 +1,1324 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlSlidableGroupedList.h + * @brief This is the header file for the %SlidableGroupedList class. + * + * This header file contains the declarations of the %SlidableGroupedList class and its helper classes. + */ +#ifndef _FUI_CTRL_SLIDABLE_GROUPED_LIST_H_ +#define _FUI_CTRL_SLIDABLE_GROUPED_LIST_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Base { namespace Runtime +{ +class IEvent; +} } } + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if OSPDEPREC + * @class SlidableGroupedList + * @brief [Deprecated] This class defines the common behavior of the %SlidableGroupedList control. + * + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * The %SlidableGroupedList class represents a list which loads grouped + * items on demand and unloads unused grouped items to save memory. Like GroupedList, + * the list items of GroupedList consist of groups and items. A group represents grouped + * items and is inserted into the first level just as items are inserted into List. Items + * which are from CustomListItems are inserted under related groups. So, items are uniquely + * identified with two indices: group index and item index. + * + * The operation of %SlidableGroupedList is the same as that of a GroupedList, except + * that a %SlidableGroupedList does not hold all items in the memory. Most of the item manipulations + * are available when they are loaded, but the check state is maintained for all items + * whether they are loaded or not. + * ISlidableGroupedListEventListener must be implemented so that an application can + * be notified when the items need to be loaded as the user scrolls through a list. + * If an application wants to perform tasks when the state of a list item is changed, + * it must implement IGroupedItemEventListener and register it to the slidable + * grouped list. It will then receive related events from %SlidableGroupedList. + * + * Note that CustomListItem and CustomListItemFormat need to be created on a heap. CustomListItems will be deleted automatically + * when the %SlidableGroupedList itself is destroyed. If you want to remove certain list items, you must use RemoveItemAt(). CustomListItemFormat + * must be deleted by the application. + * + * Refer to CustomListItem and CustomListItemFormat. + * + * Example: + * + * @image html ui_controls_slidablegroupedlist.png + * + * This is the simple UI application which uses a %SlidableGroupedList control. + * + * @code +// Sample code for SlidableGroupedListSample.h +#include + +class SlidableGroupedListSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IGroupedItemEventListener + , public Tizen::Ui::ISlidableGroupedListEventListener +{ +public: + SlidableGroupedListSample(void) + : __pSlidableGroupedList(null) + , __pCustomListItemFormat(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + Tizen::Ui::Controls::CustomListItem* LoadListItem(int itemId); + virtual void OnItemStateChanged(const Tizen::Ui::Control &source, int groupIndex, int itemIndex, int itemId, int elementId, Tizen::Ui::ItemStatus status); + virtual void OnItemStateChanged(const Tizen::Ui::Control &source, int groupIndex, int itemIndex, int itemId, Tizen::Ui::ItemStatus status); + virtual void OnListPropertyRequested(const Tizen::Ui::Control &source); + virtual void OnLoadToTopRequested(const Tizen::Ui::Control &source, int groupIndex, int itemIndex, int numItems); + virtual void OnLoadToBottomRequested(const Tizen::Ui::Control &source, int groupIndex, int itemIndex, int numItems); + virtual void OnUnloadItemRequested(const Tizen::Ui::Control& source, int groupIndex, int itemIndex); + +private: + static const int ID_LIST_TEXT = 101; + static const int ID_LIST_BITMAP = 102; + static const int ITEM_HEIGHT = 103; + static const int ITEM_COUNT = 104; + static const int ITEM_COUNT_GROUP1 = 10; + static const int ITEM_COUNT_GROUP2 = 20; + static const int ITEM_COUNT_GROUP3 = 30; + static const int ITEM_ID_LIMITS = 30; + + Tizen::Ui::Controls::SlidableGroupedList* __pSlidableGroupedList; + Tizen::Ui::Controls::CustomListItemFormat* __pCustomListItemFormat; +}; + * @endcode + * + * @code +// Sample code for SlidableGroupedListSample.cpp +#include +#include + +#include "SlidableGroupedListSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + + +bool +SlidableGroupedListSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +SlidableGroupedListSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of SlidableGroupedList + __pSlidableGroupedList = new SlidableGroupedList(); + __pSlidableGroupedList->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), CUSTOM_LIST_STYLE_NORMAL); + __pSlidableGroupedList->AddGroupedItemEventListener(*this); + __pSlidableGroupedList->AddSlidableGroupedListEventListener(*this); + + // Creates an instance of CustomListItemFormat + __pCustomListItemFormat = new CustomListItemFormat(); + __pCustomListItemFormat->Construct(); + __pCustomListItemFormat->AddElement(ID_LIST_TEXT, Rectangle(10, 25, 240, 80)); + __pCustomListItemFormat->AddElement(ID_LIST_BITMAP, Rectangle(250, 10, 70, 80)); + + // Adds the groups to the slidable grouped list + __pSlidableGroupedList->AddGroup(L"Group1", null, ITEM_COUNT_GROUP1, ITEM_COUNT_GROUP1 * ITEM_HEIGHT); + __pSlidableGroupedList->AddGroup(L"Group2", null, ITEM_COUNT_GROUP2, ITEM_COUNT_GROUP2 * ITEM_HEIGHT); + __pSlidableGroupedList->AddGroup(L"Group3", null, ITEM_COUNT_GROUP3, ITEM_COUNT_GROUP3 * ITEM_HEIGHT); + + // Adds the slidable grouped list to the form + AddControl(*__pSlidableGroupedList); + + return r; +} + +result +SlidableGroupedListSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the item format + delete __pCustomListItemFormat; + + return r; +} + +CustomListItem* +SlidableGroupedListSample::LoadListItem(int itemId) +{ + // Gets instances of Bitmap + AppResource* pAppResource = Application::App::GetInstance()->GetAppResource(); + Bitmap *pBitmapNormal = pAppResource->GetBitmapN(L"tizen.png"); + Bitmap *pBitmapFocused = pAppResource->GetBitmapN(L"tizen.png"); + + // Creates an instance of String to set an item element + String itemText; + int groupIndex = itemId / ITEM_ID_LIMITS; + int itemIndex = itemId % ITEM_ID_LIMITS; + itemText.Format(128, L"ITEM %d-%d", groupIndex+1, itemIndex+1); + + // Creates an instance of CustomListItem + CustomListItem* pItem = new CustomListItem(); + pItem->Construct(ITEM_HEIGHT); + pItem->SetItemFormat(*__pCustomListItemFormat); + pItem->SetElement(ID_LIST_TEXT, itemText); + pItem->SetElement(ID_LIST_BITMAP, *pBitmapNormal, pBitmapFocused); + + // Deallocates bitmaps + delete pBitmapNormal; + delete pBitmapFocused; + + return pItem; +} + +// IGroupedItemEventListener implementation +void +SlidableGroupedListSample::OnItemStateChanged(const Control &source, int groupIndex, int itemIndex, int itemId, ItemStatus status) +{ + switch (itemId) + { + case 1: + { + // .... + } + break; + default: + break; + } +} + +void +SlidableGroupedListSample::OnItemStateChanged(const Control &source, int groupIndex, int itemIndex, int itemId, int elementId, ItemStatus status) +{ + switch (itemId) + { + case 1: + switch (elementId) + { + case ID_LIST_TEXT: + { + // .... + } + break; + case ID_LIST_BITMAP: + { + // .... + } + break; + } + break; + default: + break; + } +} + +// IFastScrollEventListener implementation +void +SlidableGroupedListSample::OnListPropertyRequested(const Control &source) +{ + // .... +} + +void +SlidableGroupedListSample::OnLoadToTopRequested(const Control &source, int groupIndex, int itemIndex, int numItems) +{ + for(int i=0; i < numItems; ++i) + { + // Loads items upwards + int itemId = ITEM_ID_LIMITS * groupIndex + itemIndex; + + CustomListItem* pItem = LoadListItem(itemId); + __pSlidableGroupedList->LoadItemToTop(*pItem, itemId); + } +} + +void +SlidableGroupedListSample::OnLoadToBottomRequested (const Control &source, int groupIndex, int itemIndex, int numItems) +{ + for(int i=0; i< numItems; ++i) + { + // Loads items downwards + int itemId = ITEM_ID_LIMITS * groupIndex + itemIndex + i; + + CustomListItem* pItem = LoadListItem(itemId); + __pSlidableGroupedList->LoadItemToBottom(*pItem, itemId); + } +} + +void +SlidableGroupedListSample::OnUnloadItemRequested(const Control& source, int groupIndex, int itemIndex) +{ + // Releases resources of the specified item + // .... +} + * @endcode + * @endif + */ +class _OSP_EXPORT_ SlidableGroupedList + : public Tizen::Ui::Control +{ +public: + /** + * @if OSPDEPREC + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * @endif + */ + SlidableGroupedList(void); + + /** + * @if OSPDEPREC + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * @endif + */ + virtual ~SlidableGroupedList(void); + +// Operation + /** + * @if OSPDEPREC + * Initializes this instance of %SlidableGroupedList with the specified parameters. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created %SlidableGroupedList along with + * the width and height. + * @param[in] style The style of the CustomListItem instances + * @param[in] itemDivider Set to @c true to display an item divider, @n + * else @c false + * @param[in] fastScroll Set to @c true to use fast scroll, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. @n + * @remarks The minimum size of this control is 274 x 148 on a WVGA screen, 180 x 96 on a HVGA screen and 137 x 74 on a WQVGA screen. + * + * @endif + */ + result Construct(const Tizen::Graphics::Rectangle& rect, CustomListStyle style, bool itemDivider = true, bool fastScroll = false); + + /** + * @if OSPDEPREC + * Adds the specified listener instance. + * The added listener can listen to the events on the context of the given event dispatcher when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @endif + */ + void AddSlidableGroupedListEventListener(Tizen::Ui::ISlidableGroupedListEventListener& listener); + + /** + * @if OSPDEPREC + * Removes the specified listener instance. + * The removed listener cannot listen to the events when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @endif + */ + void RemoveSlidableGroupedListEventListener(Tizen::Ui::ISlidableGroupedListEventListener& listener); + + /** + * @if OSPDEPREC + * Loads the item to the top of the %SlidableGroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] item The %CustomListItem instance + * @param[in] itemId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result LoadItemToTop(const Tizen::Ui::Controls::CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Loads the item to the end of the %SlidableGroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] item The %CustomListItem object + * @param[in] itemId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result LoadItemToBottom(const Tizen::Ui::Controls::CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Unloads all the loaded items of the %SlidableGroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result UnloadAllItems(void); + + + /** + * @if OSPDEPREC + * Removes all the items in the specified group. @n + * The group is not removed. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list items are deleted from the memory. + * @endif + */ + result RemoveAllItemsAt(int groupIndex); + + /** + * @if OSPDEPREC + * Removes all the items in the list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list items are deleted from the memory. + * @remarks After the items have been removed, the ISlidableGroupedListEventListener::OnListPropertyRequested() method is called. + * @see ISlidableGroupedListEventListener + * @endif + */ + result RemoveAllItems(void); + + /** + * @if OSPDEPREC + * Removes the specified listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @endif + */ + void RemoveFastScrollEventListener(Tizen::Ui::IFastScrollEventListener& listener); + + /** + * @if OSPDEPREC + * Removes the specified listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @endif + */ + void RemoveGroupedItemEventListener(Tizen::Ui::IGroupedItemEventListener& listener); + + /** + * @if OSPDEPREC + * Scrolls to the bottom of the %SlidableGroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * @endif + */ + void ScrollToBottom(void); + + /** + * @if OSPDEPREC + * Scrolls to the top of the %SlidableGroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * @endif + */ + void ScrollToTop(void); + + /** + * @if OSPDEPREC + * Scrolls to the item at the specified index. @n + * The specified item is drawn at the top of the %SlidableGroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result ScrollToTop(int groupIndex, int itemIndex); + + /** + * @if OSPDEPREC + * Scrolls to the group at the specified index. @n + * The specified group is drawn at the top of the %SlidableGroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result ScrollToTop(int groupIndex); + + + /** + * @if OSPDEPREC + * Sets all the items at the specified group index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @param[in] groupIndex The group index + * @param[in] check Set to @c true to check the item, @n + * else @c false to uncheck + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetAllItemsChecked(int groupIndex, bool check); + + /** + * @if OSPDEPREC + * Sets the contents of the group of the %SlidableGroupedList control at the specified group index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] text The string of the group to be appended + * @param[in] pBackgroundBitmap The bitmap of the group + * @param[in] groupId The group ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetGroupAt(int groupIndex, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int groupId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Sets the specified item as checked or unchecked. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index of the item to be checked + * @param[in] itemIndex The index of the item to be checked + * @param[in] check Set to @c true to check the item, @n + * else @c false to uncheck it + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetItemChecked(int groupIndex, int itemIndex, bool check); + + /** + * @if OSPDEPREC + * Enables or disables the item at the specified index of the %SlidableGroupedList. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index of the item to be checked + * @param[in] itemIndex The index of the item to be checked + * @param[in] enable Set to @c true to enable the item, @n + * else @c false to disable it + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetLoadedItemEnabled(int groupIndex, int itemIndex, bool enable); + + /** + * @if OSPDEPREC + * Removes all the checked items from the group. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] height The estimated/real height of the items of the group + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RemoveAllCheckedItemsAt(int groupIndex, int height); + + /** + * @if OSPDEPREC + * Removes the specified item from the group. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] height The estimated/real height of the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list item is deleted from the memory. + * @endif + */ + result RemoveItemAt(int groupIndex, int itemIndex, int height); + + + /** + * @if OSPDEPREC + * Removes the group of the %SlidableGroupedList control at the group index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks When the specified group is removed, all the items in the group are also removed. + * @remarks The removed list items are deleted from the memory. + * @endif + */ + result RemoveGroupAt(int groupIndex); + + + /** + * @if OSPDEPREC + * Gets the item at the specified indexes if the item is currently loaded. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return A pointer to the loaded item, @n + * else @c null if the specified item is not currently loaded + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @endif + */ + const Tizen::Ui::Controls::CustomListItem* GetLoadedItemAt(int groupIndex, int itemIndex) const; + + + /** + * @if OSPDEPREC + * Gets the item ID at the specified index if the item is currently loaded. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return The item ID, @n + * else LIST_ITEM_UNSPECIFIED_ID if the specified item is not currently loaded + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @endif + */ + int GetLoadedItemIdAt(int groupIndex, int itemIndex) const; + + + /** + * @if OSPDEPREC + * Gets the item index from the specified item ID. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code, @n + * else @c -1 if the specified item is not currently loaded + * @param[in] itemId The item ID + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetLoadedItemIndexFromItemId(int itemId, int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Removes all the checked items of the %SlidableGroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] height The height of the item to be deleted + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list items are deleted from the memory. + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + result RemoveAllCheckedItems(int height); + + /** + * @if OSPDEPREC + * Gets the index of the first loaded item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the last loaded item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Sets the first index list of the scroll by text. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] text The text of the first index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetFastScrollMainIndex(const Tizen::Base::String& text); + + + /** + * @if OSPDEPREC + * Sets the second index list of the scroll by text. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] text The text of the second index @n + * Each second index of the first index has to be separated by ',' + * @param[in] indexDigit The index digit count + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The sub-index of fast scroll does not support SCROLL_INDEX_DIGIT_NUM_2. Therefore, when SCROLL_INDEX_DIGIT_NUM_2 is passed to + * @c indexDigit, this method returns E_SYSTEM. + * @endif + */ + result SetFastScrollSubIndex(const Tizen::Base::String& text, FastScrollIndexDigit indexDigit = SCROLL_INDEX_DIGIT_NUM_1); + + /** + * @if OSPDEPREC + * Sets the background color of this control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @param[in] color The background color + * @endif + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Sets the text of the empty list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @param[in] text The text of the empty list + * @endif + */ + void SetTextOfEmptyList(const Tizen::Base::String& text); + + /** + * @if OSPDEPREC + * Sets the color of the text to be displayed in the absence of a %SlidableGroupedList item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @param[in] color The color of the text to be displayed + * @endif + */ + void SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Gets the color of the text to be displayed in the absence of a %SlidableGroupedList item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return The color of the text to be displayed + * @endif + */ + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + /** + * @if OSPDEPREC + * Sets the contents of the item in the specified group. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The %CustomListItem object + * @param[in] item The item + * @param[in] itemId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not add, insert, or set an item, that already belongs to %SlidableGroupedList. + * @endif + */ + result SetItemAt(int groupIndex, int itemIndex, const Tizen::Ui::Controls::CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Adds the specified listener instance. + * The added listener can listen to events on the context of the given event dispatcher when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @endif + */ + void AddFastScrollEventListener(Tizen::Ui::IFastScrollEventListener& listener); + + /** + * @if OSPDEPREC + * Adds the specified group to the %SlidableGroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] text The string of the group to be appended + * @param[in] pBackgroundBitmap The background bitmap of the group + * @param[in] itemCount The number of items of the group + * @param[in] groupHeight The total height of the items of the group + * @param[in] groupId The group ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result AddGroup(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int itemCount, int groupHeight, int groupId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Adds the specified listener instance. + * The added listener can listen to events on the context of the given event dispatcher when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @endif + */ + void AddGroupedItemEventListener(Tizen::Ui::IGroupedItemEventListener& listener); + + + /** + * @if OSPDEPREC + * Adds the item to the specified group. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] item The CustomListItem object + * @param[in] itemId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The added item is deleted automatically when the list is destroyed. + * Do not add, insert, or set an item that already belongs to %SlidableGroupedList. + * @endif + */ + result AddItem(int groupIndex, const Tizen::Ui::Controls::CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Gets the index of the current bottom drawn item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const; + + + /** + * @if OSPDEPREC + * Gets the index of the first checked list item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetFirstCheckedItemIndex(int& groupIndex, int& itemIndex) const; + + + /** + * @if OSPDEPREC + * Gets the group ID from the specified group index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return The group ID + * @param[in] groupIndex The group index + * @endif + */ + int GetGroupIdAt(int groupIndex) const; + + + /** + * @if OSPDEPREC + * Gets the group index from the specified group ID. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return The group index + * @param[in] groupId The group ID + * @endif + */ + int GetGroupIndexFromGroupId(int groupId) const; + + + /** + * @if OSPDEPREC + * Gets the index of the last checked item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetLastCheckedItemIndex(int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the next checked item after the specified item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in,out] groupIndex The group index + * @param[in,out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetNextCheckedItemIndexAfter(int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the current top drawn item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[out] groupIndex The group index + * @param[out] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified item position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] x The x position of the point + * @param[in] y The y position of the point + * @param[out] groupIndex The index of the group, that the item belongs to + * @param[out] itemIndex The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. @n + * There is no item at the specified position. + * @endif + */ + result GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified item position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] position The position of the point + * @param[out] groupIndex The index of the group, that the item belongs to + * @param[out] itemIndex The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. @n + * There is no item at the specified position. + * @endif + */ + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex) const; + + /** + * @if OSPDEPREC + * Inserts the group at the specified group index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] text The string of the group to be appended + * @param[in] pBackgroundBitmap The background bitmap of the group + * @param[in] itemCount The count of all the items in the group + * @param[in] groupHeight The total height of all the items in the group + * @param[in] groupId The group ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result InsertGroupAt(int groupIndex, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int itemCount, int groupHeight, int groupId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Checks whether the item at the specified index is checked. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return @c true if the item is checked, @n + * else @c false + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * + * @remarks This method can only be used when the style of the list allows selection. + * @endif + */ + bool IsItemChecked(int groupIndex, int itemIndex) const; + + /** + * @if OSPDEPREC + * Checks whether the item at the specified index is enabled. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return @c true if the item is enabled, @n + * else @c false + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @endif + */ + bool IsLoadedItemEnabled(int groupIndex, int itemIndex) const; + + + /** + * @if OSPDEPREC + * Checks whether the item at the specified index is currently loaded to the slidable list. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return @c true if the item is loaded, @n + * else @c false + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @endif + */ + bool IsItemLoaded(int groupIndex, int itemIndex) const; + + + /** + * @if OSPDEPREC + * Removes all the groups of the %SlidableGroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks When the specified group is removed, all the items in the group are also removed. + * @remarks The removed list items are deleted from the memory. + * @remarks After the items have been removed, the ISlidableGroupedListEventListener::OnListPropertyRequested() method is called. + * @endif + */ + result RemoveAllGroups(void); + + /** + * @if OSPDEPREC + * Gets the count of all the groups of the %SlidableGroupedList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return The count of all the groups + * @endif + */ + int GetGroupCount(void) const; + + /** + * @if OSPDEPREC + * Inserts the item to the specified group and item indices. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] item The CustomListItem object + * @param[in] itemId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The inserted item is deleted automatically when the list is destroyed. + * Do not add, insert, or set an item, that already belongs to %SlidableGroupedList. + * @endif + */ + result InsertItemAt(int groupIndex, int itemIndex, const Tizen::Ui::Controls::CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + + /** + * @if OSPDEPREC + * Gets the count of all the items in the specified group. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return The count of all the items in the specified group + * @param[in] groupIndex The group index + * @endif + */ + int GetItemCountAt(int groupIndex) const; + + /** + * @if OSPDEPREC + * Draws and shows the specified item of %SlidableGroupedList. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex or @c itemIndex is invalid. + * @exception E_INVALID_OPERATION The item has never been drawn before calling this method. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RefreshItem(int groupIndex, int itemIndex); + + /** + * @if OSPDEPREC + * Draws and shows the specified group of %SlidableGroupedList. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the %GroupedListView class. + * @since 2.0 + * + * @return An error code + * @param[in] groupIndex The group index + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c groupIndex is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RefreshGroup(int groupIndex); + +protected: + + friend class _SlidableGroupedListImpl; +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + SlidableGroupedList(const SlidableGroupedList& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + SlidableGroupedList& operator =(const SlidableGroupedList& rhs); + +}; //SlidableGroupedList + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_SLIDABLE_GROUPED_LIST_H_ diff --git a/inc/FUiCtrlSlidableList.h b/inc/FUiCtrlSlidableList.h new file mode 100644 index 0000000..f2941a5 --- /dev/null +++ b/inc/FUiCtrlSlidableList.h @@ -0,0 +1,986 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlSlidableList.h + * @brief This is the header file for the %SlidableList class. + * + * This header file contains the declarations of the %SlidableList class and its helper classes. + */ + +#ifndef _FUI_CTRL_SLIDABLE_LIST_H_ +#define _FUI_CTRL_SLIDABLE_LIST_H_ + +//Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Tizen { namespace Base { namespace Runtime +{ +class IEvent; +}}} // Tizen::Base::Runtime + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if OSPDEPREC + * @class SlidableList + * @brief [Deprecated] This class defines the common behavior of a %SlidableList control. + * + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * The %SlidableList class represents a list which loads items on demand and + * unloads unused items to save memory. The operation of %SlidableList is the same + * as that of a List, except that a %SlidableList does not hold all the items in the memory. + * Most of the item manipulations are available when they are loaded, but the check + * state is maintained for all items whether they are loaded or not. + * ISlidableListEventListener must be implemented so that an application can be + * notified when items need to be loaded as the user scrolls through a list. + * If an application wants to perform tasks when the state of a list item is changed, + * then it must implement ICustomItemEventListener and register it to the slidable list, + * It will then receive related events from %SlidableList. + * + * Note that CustomListItem and CustomListItemFormat need to be created on a heap. CustomListItems will be deleted automatically + * when the %SlidableList itself is destroyed. If you want to remove certain list items, you must use RemoveItemAt(). CustomListItemFormat + * must be deleted by the application. + * + * Refer to CustomListItem and CustomListItemFormat. + * + * Example: + * + * @image html ui_controls_slidablelist.png + * + * This is the simple UI application which uses a %SlidableList control. + * + * @code +// Sample code for SlidableListSample.h +#include + +class SlidableListSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::ICustomItemEventListener + , public Tizen::Ui::ISlidableListEventListener +{ +public: + SlidableListSample(void) + : __pSlidableList(null) + , __pCustomListItemFormat(null){} + + bool Initialize(void); + Tizen::Ui::Controls::CustomListItem* CreateListItem(Tizen::Base::String itemText, + Tizen::Graphics::Bitmap* pBitmapNormal, Tizen::Graphics::Bitmap* pBitmapFocused); + + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // ICustomItemEventListener + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int index, int itemId, Tizen::Ui::ItemStatus status); + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int index, int itemId, int elementId, Tizen::Ui::ItemStatus status); + + // ISlidableEventListener + virtual void OnListPropertyRequested (const Tizen::Ui::Control &source); + virtual void OnLoadToTopRequested(const Tizen::Ui::Control &source, int index, int numItems); + virtual void OnLoadToBottomRequested(const Tizen::Ui::Control &source, int index, int numItems); + virtual void OnUnloadItemRequested(const Tizen::Ui::Control& source, int itemIndex); + +private: + static const int ID_LIST_TEXT = 101; + static const int ID_LIST_BITMAP = 102; + static const int ITEM_COUNT = 100; + static const int ITEM_HEIGHT = 100; + + Tizen::Ui::Controls::SlidableList* __pSlidableList; + Tizen::Ui::Controls::CustomListItemFormat* __pCustomListItemFormat; +}; + * @endcode + * + * @code +// Sample code for SlidableListSample.cpp +#include +#include + +#include "SlidableListSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Controls; +using namespace Tizen::Graphics; + +bool +SlidableListSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +SlidableListSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of SlidableList + __pSlidableList = new SlidableList(); + __pSlidableList->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), CUSTOM_LIST_STYLE_NORMAL); + __pSlidableList->AddCustomItemEventListener(*this); + __pSlidableList->AddSlidableListEventListener(*this); + + // Creates an instance of CustomListItemFormat of the slidable list + __pCustomListItemFormat = new CustomListItemFormat(); + __pCustomListItemFormat->Construct(); + __pCustomListItemFormat->AddElement(ID_LIST_TEXT, Rectangle(10, 25, 200, 80)); + __pCustomListItemFormat->AddElement(ID_LIST_BITMAP, Rectangle(220, 10, 70, 80)); + + // Adds the slidable list to the form + AddControl(*__pSlidableList); + + return r; +} + +result +SlidableListSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the item format + delete __pCustomListItemFormat; + + return r; +} + +CustomListItem* +SlidableListSample::CreateListItem(String itemText, Bitmap* pBitmapNormal, Bitmap* pBitmapFocused) +{ + CustomListItem* pItem = new CustomListItem(); + + pItem->Construct(ITEM_HEIGHT); + pItem->SetItemFormat(*__pCustomListItemFormat); + pItem->SetElement(ID_LIST_TEXT, itemText); + pItem->SetElement(ID_LIST_BITMAP, *pBitmapNormal, pBitmapFocused); + + return pItem; +} + +// ICustomItemEventListener implementation +void +SlidableListSample::OnItemStateChanged(const Control& source, int index, int itemId, ItemStatus status) +{ + switch (itemId) + { + case 1: + { + // .... + } + break; + default: + break; + } +} + +void +SlidableListSample::OnItemStateChanged(const Control& source, int index, int itemId, int elementId, ItemStatus status) +{ + switch (itemId) + { + case 1: + { + switch (elementId) + { + case ID_LIST_TEXT: + { + // .... + } + break; + case ID_LIST_BITMAP: + { + // .... + } + break; + default: + break; + } + } + break; + default: + break; + } +} + +// ISlidableEventListener implementation +void +SlidableListSample::OnListPropertyRequested (const Control &source) +{ + // Sets the total count and the height of items + __pSlidableList->SetItemCountAndHeight(ITEM_COUNT, ITEM_COUNT * ITEM_HEIGHT); +} + +void +SlidableListSample::OnLoadToTopRequested(const Control &source, int index, int numItems) +{ + // Gets instances of Bitmap + AppResource *pAppResource = Application::GetInstance()->GetAppResource(); + Bitmap *pBitmapNormal = pAppResource->GetBitmapN(L"tizen.png"); + Bitmap *pBitmapFocused = pAppResource->GetBitmapN(L"tizen.png"); + + // Creates items of the slidable list + for(int i = index; i > index - numItems; i--) + { + String itemText = "ITEM_"; + itemText.Append(i); + __pSlidableList->LoadItemToTop(*CreateListItem(itemText, pBitmapNormal, pBitmapFocused), i+1); + } + + // Deallocates bitmaps + delete pBitmapNormal; + delete pBitmapFocused; +} + +void +SlidableListSample::OnLoadToBottomRequested (const Control &source, int index, int numItems) +{ + // Gets instances of Bitmap + AppResource *pAppResource = Application::GetInstance()->GetAppResource(); + Bitmap *pBitmapNormal = pAppResource->GetBitmapN(L"tizen.png"); + Bitmap *pBitmapFocused = pAppResource->GetBitmapN(L"tizen.png"); + + // Creates items of the slidable list + for(int i = index; i < index + numItems; i++) + { + String itemText = L"ITEM_"; + itemText.Append(i); + __pSlidableList->LoadItemToBottom(*CreateListItem(itemText, pBitmapNormal, pBitmapFocused), i+1); + } + + // Deallocates bitmaps + delete pBitmapNormal; + delete pBitmapFocused; +} + +void +SlidableListSample::OnUnloadItemRequested(const Control& source, int itemIndex) +{ + // Releases resources of the specified item + // .... +} + * @endcode + * @endif + */ +class _OSP_EXPORT_ SlidableList + : public Tizen::Ui::Control +{ +public: + /** + * @if OSPDEPREC + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * @endif + */ + SlidableList(void); + + /** + * @if OSPDEPREC + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * @endif + */ + virtual ~SlidableList(void); + +// Operation + + /** + * @if OSPDEPREC + * Initializes this instance of %SlidableList with the specified parameters. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] rect This instance represents the X and Y coordinates of the top-left corner of the created %SlidableList along with the width and height + * @param[in] style The style set of %CustomList + * @param[in] itemDivider Set to @c true to display an item divider, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * Either the @c rect.width or the @c rect.height is @c 0 or negative. + * @exception E_SYSTEM The method has failed. + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. + * @remarks The minimum size of this control is 92 x 72 on a WVGA screen, 60 x 48 on a HVGA screen and 46 x 36 on a WQVGA screen. + * + * @endif + */ + result Construct(const Tizen::Graphics::Rectangle& rect, CustomListStyle style, bool itemDivider = true); + + /** + * @if OSPDEPREC + * Adds a listener instance. + * The added listener can listen to events on the context of the given event dispatcher when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @endif + */ + void AddSlidableListEventListener(Tizen::Ui::ISlidableListEventListener& listener); + + /** + * @if OSPDEPREC + * Removes a listener instance. + * The removed listener cannot listen to events when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @endif + */ + void RemoveSlidableListEventListener(Tizen::Ui::ISlidableListEventListener& listener); + + /** + * @if OSPDEPREC + * Adds a listener instance. @n + * The added listener can listen to events on the context of the given event dispatcher when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @endif + */ + void AddCustomItemEventListener(Tizen::Ui::ICustomItemEventListener& listener); + + /** + * @if OSPDEPREC + * Adds the specified item to the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] item The CustomListItem to be added + * @param[in] itemId The item ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The added item is deleted automatically when the list is destroyed. @n + * Do not add, insert, or set an item which already belongs to %SlidableList. + * @endif + */ + result AddItem(const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Gets the index of the bottom drawn item from the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An integer value representing the index of the bottom drawn item + * @endif + */ + int GetBottomDrawnItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the first item of all the checked items in the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the first selected item + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + int GetFirstCheckedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the count of the number of items in the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The number of items in the %SlidableList control + * @endif + */ + int GetItemCount(void) const; + + /** + * @if OSPDEPREC + * Gets the last item of all the checked items in the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the last selected item + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + int GetLastCheckedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the radio checked item of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The next item index + * @param[in] index The item index + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + int GetNextCheckedItemIndexAfter(int index) const; + + /** + * @if OSPDEPREC + * Gets the index of the top drawn item of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the top drawn item + * @endif + */ + int GetTopDrawnItemIndex(void) const; + + /** + * @if OSPDEPREC + * Inserts the specified item in the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The item index at which to insert the item + * @param[in] item The CustomListItem to be inserted + * @param[in] itemId The item ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c index is less than @c 0 or greater than the item count. + * @exception E_SYSTEM A system error has occurred. + * @remarks The inserted item is deleted automatically when the list is destroyed. + * Do not add, insert, or set an item that already belongs to %SlidableList. + * @endif + */ + result InsertItemAt(int index, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Removes all the items of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list items are deleted from the memory. + * @remarks After items have been removed, the ISlidableListEventListener::OnListPropertyRequested() method is called. + * @see ISlidableListEventListener + * @endif + */ + result RemoveAllItems(void); + + /** + * @if OSPDEPREC + * Removes a listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @endif + */ + void RemoveCustomItemEventListener(Tizen::Ui::ICustomItemEventListener& listener); + + /** + * @if OSPDEPREC + * Scrolls to the bottom of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * @endif + */ + void ScrollToBottom(void); + + /** + * @if OSPDEPREC + * Scrolls to the top of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * @endif + */ + void ScrollToTop(void); + + /** + * @if OSPDEPREC + * Scrolls to the item at the specified index. @n + * The specified item is drawn at the top of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The item index + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @endif + */ + result ScrollToTop(int index); + + /** + * @if OSPDEPREC + * Sets the check status for all items of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] check Set to @c true to check all the items, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + result SetAllItemsChecked(bool check); + + /** + * @if OSPDEPREC + * Sets the check status of the item at the specified index of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The item index + * @param[in] check The check status + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * + * @remarks This method can only be used when the style of the list allows selection. + * @endif + */ + result SetItemChecked(int index, bool check); + + /** + * @if OSPDEPREC + * Enables or disables the status of the item at the specified index of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The item index + * @param[in] enable Set to @c true to enable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * + * @endif + */ + result SetLoadedItemEnabled(int index, bool enable); + + /** + * @if OSPDEPREC + * Sets the background color of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] color The background color + * @endif + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Sets the text to display in the absence of a %SlidableList item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] text The text message + * @endif + */ + void SetTextOfEmptyList(const Tizen::Base::String& text); + + /** + * @if OSPDEPREC + * Sets a color of the text to display in the absence of a %SlidableList item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] color The color of the text to be displayed + * @endif + */ + void SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Gets a color of the text to display in the absence of a %SlidableList item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The color of the text to be displayed + * @endif + */ + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + /** + * @if OSPDEPREC + * Gets the loaded item at the specified index of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return A CustomListItem + * @param[in] index The item index + * @endif + */ + const CustomListItem* GetLoadedItemAt(int index) const; + + /** + * @if OSPDEPREC + * Gets the index of the loaded item at the specified item ID. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The item ID + * @param[in] index The item index + * @endif + */ + int GetLoadedItemIdAt(int index) const; + + /** + * @if OSPDEPREC + * Checks whether the item at the specified index is enabled. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return @c true if the item is enabled, @n + * else @c false + * @param[in] index The item index + * @endif + */ + bool IsItemChecked(int index) const; + + /** + * @if OSPDEPREC + * Checks whether the loaded item at the specified index is enabled. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return @c true if the item is enabled, @n + * else @c false + * @param[in] index The item index + * @endif + */ + bool IsLoadedItemEnabled(int index) const; + + /** + * @if OSPDEPREC + * Gets the index of the loaded item at the specified item ID. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the item + * @param[in] itemId The item ID + * @endif + */ + int GetLoadedItemIndexFromItemId(int itemId) const; + + /** + * @if OSPDEPREC + * Loads the item to the top of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] item The %CustomListItem to be loaded + * @param[in] itemId The item ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result LoadItemToTop(const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Loads the item to the end of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] item The CustomListItem to be loaded + * @param[in] itemId The item ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result LoadItemToBottom(const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Unloads all loaded items of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result UnloadAllItems(void); + + /** + * @if OSPDEPREC + * Sets the contents of the item at the specified index of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The item index + * @param[in] item The CustomListItem to be set + * @param[in] itemId The item ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c index is less than @c 0 or greater than or equal to the item count. + * @exception E_SYSTEM A system error has occurred. + * @remarks Do not add, insert, or set an item which already belongs to %SlidableList. + * @endif + */ + result SetItemAt(int index, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + + /** + * @if OSPDEPREC + * Removes the item at the specified index of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The item index to be deleted + * @param[in] itemHeight The height of the item to be deleted + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list item is deleted from the memory. + * @endif + */ + result RemoveItemAt(int index, int itemHeight); + + /** + * @if OSPDEPREC + * Removes all the checked items of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] itemHeight The height of the item to be deleted + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The removed list items are deleted from the memory. + * @remarks This method can only be used when the style of the list allows multiple selections. + * @endif + */ + result RemoveAllCheckedItems(int itemHeight); + + /** + * @if OSPDEPREC + * Sets the number of items and the combined height of all the items of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @param[in] count The count of list items + * @param[in] listHeight The height of the list + * @endif + */ + void SetItemCountAndHeight(int count, int listHeight); + + /** + * @if OSPDEPREC + * Checks whether the specific item is loaded. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return @c true if the item is loaded, @n + * else @c false + * @param[in] index The item index + * @endif + */ + bool IsItemLoaded(int index) const; + + /** + * @if OSPDEPREC + * Gets the index of the first loaded item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the first loaded item + * @endif + */ + int GetFirstLoadedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the index of the last loaded item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the last loaded item + * @endif + */ + int GetLastLoadedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified item position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if there is no list item with the specified position + * @param[in] x The x position of the point + * @param[in] y The y position of the point + * @endif + */ + int GetItemIndexFromPosition(int x, int y) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified item position. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if there is no list item with the specified position + * @param[in] position The position of the point + * @endif + */ + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + + /** + * @if OSPDEPREC + * Draws and shows the item of the %SlidableList control. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the ListView class. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the %SlidableList item + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_OPERATION The item has never been drawn before calling this method. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @endif + */ + result RefreshItem(int index); + +protected: + + friend class _SlidableListImpl; +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + SlidableList(const SlidableList& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + SlidableList& operator =(const SlidableList& rhs); +}; //SlidableList +}}} // Tizen::Ui::Controls +#endif // _FUI_CTRL_SLIDABLE_LIST_H_ diff --git a/inc/FUiCtrlSlider.h b/inc/FUiCtrlSlider.h new file mode 100644 index 0000000..bc01d84 --- /dev/null +++ b/inc/FUiCtrlSlider.h @@ -0,0 +1,424 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlSlider.h + * @brief This is the header file for the %Slider class. + * + * This header file contains the declarations of the %Slider class and its helper classes. + */ + +#ifndef _FUI_CTRL_SLIDER_H_ +#define _FUI_CTRL_SLIDER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class Slider + * @brief This class is an implementation of a %Slider control. + * + * @since 2.0 + * + * The %Slider class displays a slider that represents changing progress or setting information. The difference between %Slider + * and Progress is that the former accepts user input by the touch of the slider icon. + * + * For more information on the class features, see Slider. + * + * The following example demonstrates how to use the %Slider class. + * + * @code +// Sample code for SliderSample.h +#include + +class SliderSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IAdjustmentEventListener +{ +public: + SliderSample(void) + : __pSlider(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual void OnAdjustmentValueChanged(const Tizen::Ui::Control& source, int adjustment); + +private: + Tizen::Ui::Controls::Slider* __pSlider; +}; + * @endcode + * + * @code +// Sample code for SliderSample.cpp +#include + +#include "SliderSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +SliderSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +SliderSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Slider + __pSlider = new Slider(); + __pSlider->Construct(Rectangle(0, 200, GetClientAreaBounds().width, 200), BACKGROUND_STYLE_DEFAULT, false, 0, 100); + __pSlider->SetValue(50); + __pSlider->AddAdjustmentEventListener(*this); + + // Adds the slider to the form + AddControl(*__pSlider); + + return r; +} + +// IAdjustmentEventListener implementation +void +SliderSample::OnAdjustmentValueChanged(const Control& source, int adjustment) +{ + // .... +} + * @endcode + * + */ +class _OSP_EXPORT_ Slider + : public Tizen::Ui::Control +{ +// Lifecycle +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + Slider(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~Slider(void); + + /** + * Initializes this instance of %Slider with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created window along with + * the width and height of the control. + * @param[in] backgroundStyle The background style set of the slider + * @param[in] showTitle Set to @c true to enable the show title, @n + * else @c false + * @param[in] minValue The minimum slider value + * @param[in] maxValue The maximum slider value + * @param[in] groupStyle The table view style of the slider + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The background style of BACKGROUND_STYLE_NONE does not work with group styles except GROUP_STYLE_NONE. + * @exception E_OUT_OF_RANGE The specified values are less than @c -99 or greater than @c 999. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully usable only after it has been added to a container. Therefore, some methods may fail if used earlier. @n + * If the given size is less than the minimum, it returns E_INVALID_ARG. + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, BackgroundStyle backgroundStyle = BACKGROUND_STYLE_DEFAULT, bool showTitle = false, int minValue = 0, int maxValue = 100, GroupStyle groupStyle = GROUP_STYLE_NONE); + + /** + * Adds a IAdjustmentEventListener instance. @n + * The added listener listens to events on the context of the specified event dispatcher when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + */ + void AddAdjustmentEventListener(Tizen::Ui::IAdjustmentEventListener& listener); + + /** + * Removes a IAdjustmentEventListener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + */ + void RemoveAdjustmentEventListener(Tizen::Ui::IAdjustmentEventListener& listener); + +// Operation +public: + /** + * Sets the range of the %Slider control. + * + * @since 2.0 + * + * @return An error code + * @param[in] minValue The minimum value of the %Slider control + * @param[in] maxValue The maximum value of the %Slider control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The specified values are greater than @c -99 or less than @c 999. + * @exception E_SYSTEM A system error has occurred. + */ + result SetRange(int minValue, int maxValue); + + /** + * Gets the minimum value and the maximum value of the slider. + * + * @since 2.0 + * + * @param[out] minValue The minimum value of the slider + * @param[out] maxValue The maximum value of the slider + */ + void GetRange(int& minValue, int& maxValue) const; + + /** + * Sets the value of the current thumb position. @n + * If the specified @c value is greater than @c maxValue, the value is set to @c maxValue, and + * if the specified @c value is less than @c minValue, the value is set to @c minValue. + * + * @since 2.0 + * + * @param[in] value The value of the position + */ + void SetValue(int value); + + /** + * Gets the value of the current thumb position. + * + * @since 2.0 + * + * @return The current thumb position + */ + int GetValue(void) const; + + /** + * Sets the icon of the slider. + * + * @since 2.0 + * + * @param[in] position The position of the icon (ICON_POSITION_LEFT/ICON_POSITION_RIGHT) + * @param[in] icon The bitmap image of the icon + * @remarks If the size of the bitmap is greater than the default size, the bitmap image is scaled down. + */ + void SetIcon(IconPosition position, const Tizen::Graphics::Bitmap& icon); + + /** + * Sets the title of the slider. + * + * @since 2.0 + * + * @return An error code + * @param[in] title The title to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetTitleText(const Tizen::Base::String& title); + + /** + * Gets the title of the slider. + * + * @since 2.0 + * + * @return The title text of the entered string, @n + * else an empty string if the %Slider instance is not constructed + */ + Tizen::Base::String GetTitleText(void) const; + + /** + * Sets the title text color of the %Slider control. + * + * @since 2.0 + * + * @param[in] color The title text color to be set + */ + void SetTitleTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the title text color of the %Slider control. + * + * @since 2.0 + * + * @return The title text color + */ + Tizen::Graphics::Color GetTitleTextColor(void) const; + + /** + * Initializes this instance of %Slider with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created window along with + * its width and height. + * @param[in] sliderStyle The style of the slider @n + * Multiple link types can be combined using bitwise OR operator. See Tizen::Ui::Controls::SliderStyle. + * @param[in] minValue The minimum slider value + * @param[in] maxValue The maximum slider value + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified minimum and maximum values are less than @c -99, or greater than @c 999. + * @exception E_INVALID_ARG A specified input parameter is invalid, or the specified @c minValue is greater than @c maxVaue. + * @exception E_SYSTEM A system error has occurred. + * @remarks A control is fully functional only after it has been added to a container. Therefore, some methods may fail if they are used before + * adding the control to the container. @n + * If the specified size is less than the minimum size, the %Slider control is constructed with the minimum size. + * @remarks The width and the height of the control must be greater than @c 0. + * @remarks The size of the control must be within the range defined by the minimum size and the maximum size. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, unsigned long sliderStyle, int minValue = 0, int maxValue = 100); + + /** + * Adds a ISliderEventListener instance. @n + * The added listener can listen to the slider-related events. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + */ + void AddSliderEventListener(ISliderEventListener& listener); + + /** + * Removes a ISliderEventListener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + */ + void RemoveSliderEventListener(ISliderEventListener& listener); + + /** + * Sets the color of the bar. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method ignores the alpha value of the @c color parameter and sets the alpha value to @c 255. + */ + result SetBarColor(const Tizen::Graphics::Color& color); + + /** + * Gets the color of the bar. + * + * @since 2.0 + * + * @return The color of the bar, @n + * else RGBA(0, 0, 0, 0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetBarColor(void) const; + + /** + * Sets the color of the slider. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The operation is not supported if the background style of the %Slider control is BACKGROUND_STYLE_NONE. + * @exception E_SYSTEM A system error has occurred. + * @remarks If a device supports only the 16-bit color space, this method considers the color as opaque by ignoring the alpha value of @c color. + */ + result SetColor(const Tizen::Graphics::Color& color); + + /** + * Gets the color of the slider. + * + * @since 2.0 + * + * @return The color , @n + * else RGBA(0, 0, 0, 0) if an instance is invalid or the background style is BACKGROUND_STYLE_NONE + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The background style is not proper. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetColor(void) const; + + /** + * Sets the bitmap image to the %Slider control Thumb. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The state of the slider thumb + * @param[in] bitmap The Thumb bitmap image + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result SetThumbBitmap(SliderThumbStatus status, const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the text color of the %Slider control Thumb. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The state of the slider thumb + * @param[in] color The color should be set for the thumb text + */ + void SetThumbTextColor(SliderThumbStatus status, const Tizen::Graphics::Color& color); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Slider(const Slider&); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Slider& operator =(const Slider&); + + friend class _SliderImpl; + +}; // Slider + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_SLIDER_H_ diff --git a/inc/FUiCtrlSliderTypes.h b/inc/FUiCtrlSliderTypes.h new file mode 100644 index 0000000..c22f1a9 --- /dev/null +++ b/inc/FUiCtrlSliderTypes.h @@ -0,0 +1,62 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlSliderTypes.h + * @brief This is the header file for the SliderStyle enumerations. + * + * This header files contains the declarations of the SliderStyle enumeration. + * + */ +#ifndef _FUI_CTRL_SLIDER_TYPES_H_ +#define _FUI_CTRL_SLIDER_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum SliderStyle + * + * Defines the slider styles. + * + * @since 2.0 + */ +enum SliderStyle +{ + SLIDER_STYLE_NONE = 0x0000, /**< The no bubble, no title slider */ + SLIDER_STYLE_BUBBLE = 0x0001, /**< The bubble style slider */ + SLIDER_STYLE_TITLE = 0x0002, /**< The title style slider */ +}; + +/** + * @enum SliderThumbStatus + * + * Defines the possible states of the slider thumb. + * + * @since 2.0 + */ + +enum SliderThumbStatus +{ + SLIDER_THUMB_STATUS_NORMAL, /**< The normal state */ + SLIDER_THUMB_STATUS_PRESSED, /**< The pressed state */ + SLIDER_THUMB_STATUS_DISABLED, /**< The disabled state */ + SLIDER_THUMB_STATUS_HIGHLIGHTED, /**< The focus-highlighted state */ +}; + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_SLIDER_TYPES_H_ diff --git a/inc/FUiCtrlSplitPanel.h b/inc/FUiCtrlSplitPanel.h new file mode 100644 index 0000000..8d7b5c1 --- /dev/null +++ b/inc/FUiCtrlSplitPanel.h @@ -0,0 +1,314 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlSplitPanel.h + * @brief This is the header file for the %SplitPanel class. + * + * This header file contains the declarations of the %SplitPanel class. + */ +#ifndef _FUI_CTRL_SPLIT_PANEL_H_ +#define _FUI_CTRL_SPLIT_PANEL_H_ + +#include +#include +#include +#include + + +namespace Tizen { namespace Ui { namespace Controls +{ + +class ISplitPanelEventListener; + +/** + * @class SplitPanel + * @brief This class is an implementation of a %SplitPanel control. + * + * @since 2.0 + * @final This class is not intended for extension. + * + * The %SplitPanel class provides the functionality of a %SplitPanel which is a control that contains two panes. + * + * For more information on the class features, see SplitPanel. + * + * The following example demonstrates how to use the %SplitPanel class. + * + * @code +// Sample code for SplitPanel.h +#include + +class SplitPanelSample + : public Tizen::Ui::Controls::Form +{ +public: + virtual result OnInitializing(void); +}; + * @endcode + * + * @code +// Sample code for SplitPanelSample.cpp +#include "SplitPanelSample.h" + +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +result +SplitPanelSample::OnInitializing(void) +{ + // Creates an instance of SplitPanel + SplitPanel* pSplitPanel = new (std::nothrow) SplitPanel(); + pSplitPanel->Construct(Rectangle(0, 0, 800, 400), + SPLIT_PANEL_DIVIDER_STYLE_MOVABLE, SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL); + + // Creates instances of Panel + Panel* pFirstPanel = new (std::nothrow) Panel(); + pFirstPanel->Construct(Rectangle(0, 0, 400, 480)); + + Panel* pSecondPanel = new (std::nothrow) Panel(); + pSecondPanel->Construct(Rectangle(0, 0, 400, 480)); + + //Sets the divider position to the slit panel + pSplitPanel->SetDividerPosition(400); + + //Sets panes to the split panel + pSplitPanel->SetPane(pFirstPanel, SPLIT_PANEL_PANE_ORDER_FIRST); + pSplitPanel->SetPane(pSecondPanel, SPLIT_PANEL_PANE_ORDER_SECOND); + + // Adds the split panel to the form + AddControl(*pSplitPanel); + + return E_SUCCESS; +} + * @endcode + * + */ + +class _OSP_EXPORT_ SplitPanel + : public Tizen::Ui::Control +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + SplitPanel(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~SplitPanel(void); + + /** + * Initializes this instance of %SplitPanel with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The location and size of the %SplitPanel control as a Rectangle instance. + * @param[in] splitPanelDividerStyle The divider style of the %SplitPanel control + * @param[in] splitPanelDividerDirection The divider direction of the %SplitPanel control @n + * The specified divider direction determines the divider is vertical or horizontal. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection); + + /** + * Adds a ISplitPanelEventListener instance. @n + * The added listener listens to events on the context of the specified event dispatcher when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The event listener already exists. + */ + result AddSplitPanelEventListener(ISplitPanelEventListener& listener); + + /** + * Removes a ISplitPanelEventListener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The event listener is not found. + */ + result RemoveSplitPanelEventListener(ISplitPanelEventListener& listener); + + /** + * Sets the pane to the %SplitPanel control. + * + * @since 2.0 + * + * @return An error code + * @param[in] pControl The control to be set. + * @param[in] paneOrder The order of pane. SPLIT_PANEL_PANE_FIRST is displayed on the left side @n + * and SPLIT_PANEL_PANE_SECOND is displayed on the right side of the %SplitPanel when its direction is SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks The %SplitPanel control must contain exactly two panes and the user can change their relative sizes. + */ + result SetPane(Control* pControl, SplitPanelPaneOrder paneOrder); + + /** + * Gets the control at the specified pane order of the %SplitPanel. + * + * @since 2.0 + * + * @return The control at the specified pane order of the %SplitPanel @n + * @c null, if there is no panel. + * @param[in] paneOrder The order of pane. SPLIT_PANEL_PANE_FIRST is displayed on the left side @n + * and SPLIT_PANEL_PANE_SECOND is displayed on the right side of the %SplitPanel when its direction is SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Control* GetPane(SplitPanelPaneOrder paneOrder) const; + + /** + * Sets the divider position of the control. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position of divider + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @see GetDividerPosition() + * @see SetMaximumDividerPosition(), GetMaximumDividerPosition() + * @see SetMinimumDividerPosition(), GetMinimumDividerPosition() + */ + result SetDividerPosition(int position); + + /** + * Gets the current divider position of the control. + * + * @since 2.0 + * + * @return The current divider position + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetDividerPosition() + * @see SetMaximumDividerPosition(), GetMaximumDividerPosition() + * @see SetMinimumDividerPosition(), GetMinimumDividerPosition() + */ + int GetDividerPosition(void) const; + + /** + * Sets the divider maximum position of the control. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position of divider. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @see GetMaximumDividerPosition() + * @see SetMinimumDividerPosition(), GetMinimumDividerPosition() + */ + result SetMaximumDividerPosition(int position); + + /** + * Gets the maximum divider position. + * + * @since 2.0 + * + * @return The maximum divider position of the control. + * @see SetMaximumDividerPosition() + * @see SetMinimumDividerPosition(), GetMinimumDividerPosition() + */ + int GetMaximumDividerPosition(void) const; + + /** + * Sets the divider minimum position of the control. + * + * @since 2.0 + * + * @return An error code + * @param[in] position The position of divider. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @see GetMinimumDividerPosition() + * @see SetMaximumDividerPosition(), GetMaximumDividerPosition() + */ + result SetMinimumDividerPosition(int position); + + /** + * Gets the minimum divider position. + * + * @since 2.0 + * + * @return The minimum divider position of the control. + * @see SetMinimumDividerPosition() + * @see SetMaximumDividerPosition(), GetMaximumDividerPosition() + */ + int GetMinimumDividerPosition(void) const; + + /** + * Maximizes the specified pane. + * + * @since 2.0 + * + * @return An error code + * @param[in] paneOrder The order of pane. + * @see IsPaneMaximized() + */ + result MaximizePane(SplitPanelPaneOrder paneOrder); + + /** + * Checks whether the specified pane is maximized. + * + * @since 2.0 + * @return @c true if the pane is maximized, @n + * else @c false + */ + bool IsPaneMaximized(SplitPanelPaneOrder paneOrder) const; + + /** + * Restores the previous pane size if the specified pane is maximized. + * + * @since 2.0 + * + * @return An error code + * @see MaximizePane() + */ + result RestorePane(void); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + SplitPanel(const SplitPanel& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + SplitPanel& operator =(const SplitPanel& rhs); + + friend class _SplitPanelImpl; + +}; // SplitPanel + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_SPLIT_PANEL_H_ diff --git a/inc/FUiCtrlSplitPanelTypes.h b/inc/FUiCtrlSplitPanelTypes.h new file mode 100644 index 0000000..94a5498 --- /dev/null +++ b/inc/FUiCtrlSplitPanelTypes.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlSplitPanelTypes.h + * @brief This is the header file for the %SplitPanel enumerations. + * + * This header file contains the declarations of the %SplitPanel enumerations. + * + */ +#ifndef _FUI_CTRL_SPLIT_PANEL_TYPES_H_ +#define _FUI_CTRL_SPLIT_PANEL_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum SplitPanelDividerStyle + * + * Defines the divider style of the %SplitPanel control. + * + * @since 2.0 + */ +enum SplitPanelDividerStyle +{ + SPLIT_PANEL_DIVIDER_STYLE_FIXED, /**< The fixed divider style */ + SPLIT_PANEL_DIVIDER_STYLE_MOVABLE /**< The movable divider style */ +}; + +/** + * @enum SplitPanelDividerDirection + * + * Defines the divider direction of the %SplitPanel control. + * + * @since 2.0 + */ +enum SplitPanelDividerDirection +{ + SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL, /**< Set to vertical divider */ + SPLIT_PANEL_DIVIDER_DIRECTION_HORIZONTAL /**< Set to horizontal divider */ +}; + +/** + * @enum SplitPanelPaneOrder + * + * Defines the pane order of the %SplitPanel control. + * + * @since 2.0 + */ +enum SplitPanelPaneOrder +{ + SPLIT_PANEL_PANE_ORDER_FIRST, + SPLIT_PANEL_PANE_ORDER_SECOND +}; + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_SPLIT_PANEL_TYPES_H_ + diff --git a/inc/FUiCtrlTab.h b/inc/FUiCtrlTab.h new file mode 100644 index 0000000..8b1b508 --- /dev/null +++ b/inc/FUiCtrlTab.h @@ -0,0 +1,729 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlTab.h + * @brief This is the header file for the %Tab class. + * + * This header file contains the declarations of the %Tab class and its helper classes. + */ + +#ifndef _FUI_CTRL_TAB_H_ +#define _FUI_CTRL_TAB_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class IActionEventListener; +}} + +namespace Tizen { namespace Ui { namespace Controls +{ +class _PublicActionEvent; + + +/** + * @if OSPDEPREC + * @class Tab + * @brief [Deprecated] This class is an implementation of a %Tab control. + * + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @remarks Note that tabs are part of a Form control, not a Frame control. This means that each tab item cannot be a form. You can associate a Panel + * control or a ScrollPanel control to each tab item. + * + * The %Tab class is an implementation of a %Tab control. + * %Tab control displays the user selection in the form of a horizontal list. Each + * item of %Tab control consists of its text string and optional bitmap image. + * Items can be added to an itemlist of the tab model with AddItem(). Items can + * be inserted into an itemlist by InsertItemAt(), updated into an itemlist by SetItemAt(), + * removed from an itemlist by RemoveItemAt(), etc. It is possible to customize the + * background image of the tab shelf, and the image of the currently selected tab item. + * A badge icon can also be used to give more information for each tab item. + * + * Example: + * + * @image html ui_controls_tab.png + * + * + * This is the simple UI application that uses a %Tab control. + * + * + * @code +//Sample code for TabSample.h + +#include + +class TabSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener +{ +public: + TabSample(void) + : __pTab(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + // IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +private: + Tizen::Ui::Controls::Tab* __pTab; +}; + * @endcode + * + * @code +// Sample code for TabSample.cpp +#include "TabSample.h" + +using namespace Tizen::Ui::Controls; + +bool +TabSample::Initialize() +{ + Construct(FORM_STYLE_NORMAL|FORM_STYLE_TEXT_TAB); + return true; +} + +result +TabSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Gets an instance of Tab + __pTab = GetTab(); + + // Adds items to the tab + __pTab->AddItem(L"First", 0); + __pTab->AddItem(L"Second", 1); + __pTab->AddActionEventListener(*this); + + return r; +} + +// IActionEventListener implementation +void +TabSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case 0: + { + // .... + } + break; + case 1: + { + // .... + } + break; + default: + break; + } +} + * @endcode + * @endif + */ +class _OSP_EXPORT_ Tab + : public Tizen::Ui::Control +{ +public: + /** + * @if OSPDEPREC + * Adds a listener instance. + * The added listener can listen to events on the context of the given event dispatcher when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @endif + */ + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * @if OSPDEPREC + * Removes a listener instance. + * The removed listener cannot listen to events when they are fired. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @endif + */ + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + +public: + /** + * @if OSPDEPREC + * Adds an item consisting of the specified text string. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] text The text string of the item + * @param[in] actionId The action ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c actionId is out of range. + * @exception E_SYSTEM A system error has occurred, or @n + * the total number of items has exceed the %Tab control's maximum item count. + * @remarks The @c actionId range is @c 0-999. @n + * The maximum number of items for %Tab with text style is @c 9. @n + * The maximum number of items for icon style %Tab is @c 8. + * @remarks This method can only be used when the %Form control has the FORM_STYLE_TEXT_TAB style. + * @endif + */ + result AddItem(const Tizen::Base::String& text, int actionId); + + /** + * @if OSPDEPREC + * Adds an item consisting of the title icon and the specified text string. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] titleIcon The bitmap for the title icon + * @param[in] text The text string of the item + * @param[in] actionId The specified @c actionId for this item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c actionId is out of range. + * @exception E_SYSTEM A system error has occurred, or @n + * the total number of items has exceed the %Tab control's maximum item count. + * @remarks The @c actionId range is @c 0-999. @n + * The maximum number of items for %Tab with text style is @c 9. @n + * The maximum number of items for icon style %Tab is @c 8. @n + * This method can only be used when the %Form control has the FORM_STYLE_TEXT_TAB style. + * @remarks If the size of bitmap is greater than the default size , the bitmap is scaled down. + * @endif + */ + result AddItem(const Tizen::Graphics::Bitmap& titleIcon, const Tizen::Base::String& text, int actionId); + + /** + * @if OSPDEPREC + * Adds the item that consists of the specified icon. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] icon The bitmap for the icon + * @param[in] actionId The specified @c actionId for this item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c actionId is out of range. + * @exception E_SYSTEM A system error has occurred, or @n + * the total number of items has exceed the %Tab control's maximum item count. + * @remarks The @c actionId range is @c 0-999. @n + * The maximum number of items for %Tab with text style is @c 9. @n + * The maximum number of items for icon style %Tab is @c 8. @n + * This method can only be used when the Form control has the FORM_STYLE_ICON_TAB style. @n + * If the size of the bitmap is greater than the default size, the bitmap is scaled down. + * @endif + */ + result AddItem(const Tizen::Graphics::Bitmap& icon, int actionId); + + /** + * @if OSPDEPREC + * Inserts the item that consists of only a text string at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item + * @param[in] text The text string of the item + * @param[in] actionId The specified @c actionId for this item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c actionId is out of range. + * @exception E_SYSTEM A system error has occurred, or @n + * the total number of items has exceed the %Tab control's maximum item count. + * @remarks The @c actionId range is @c 0-999. @n + * The maximum number of items for %Tab with text style is @c 9. @n + * The maximum number of items for icon style %Tab is @c 8. + * @remarks This method can only be used when the Form control has the FORM_STYLE_TEXT_TAB style. + * @endif + */ + result InsertItemAt(int index, const Tizen::Base::String& text, int actionId); + + /** + * @if OSPDEPREC + * Inserts the item that consists of the title icon and specified text string at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item + * @param[in] titleIcon The bitmap for the title icon + * @param[in] text The text string of the item + * @param[in] actionId The specified @c actionId for this item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c actionId is out of range. + * @exception E_SYSTEM A system error has occurred, or @n + * the total number of items has exceed the %Tab control's maximum item count. + * @remarks The @c actionId range is @c 0-999. + * @remarks The maximum number of items for %Tab with text style is @c 9. @n + * The maximum number of items for icon style %Tab is @c 8. @n + * This method can only be used when the %Form control has the FORM_STYLE_TEXT_TAB style. @n + * If the size of bitmap is greater than the default size, the bitmap is scaled down. + * @endif + */ + result InsertItemAt(int index, const Tizen::Graphics::Bitmap& titleIcon, const Tizen::Base::String& text, int actionId); + + /** + * @if OSPDEPREC + * Inserts the item which consists of the title icon and specified text string at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item + * @param[in] icon The Bitmap for the Icon + * @param[in] actionId The specified @c actionId for this item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c actionId is out of range. + * @exception E_SYSTEM A system error has occurred, or @n + * the total number of items has exceed the %Tab control's maximum item count. + * @remarks The @c actionId range is @c 0-999. + * @remarks The maximum number of items for %Tab with text style is @c 9. @n + * The maximum number of items for icon style %Tab is @c 8. @n + * This method can only be used when the Form control has the FORM_STYLE_ICON_TAB style. @n + * If the size of bitmap is greater than the default size, the bitmap is scaled down. + * @endif + */ + result InsertItemAt(int index, const Tizen::Graphics::Bitmap& icon, int actionId); + + /** + * @if OSPDEPREC + * Sets the item that consists of only a text string at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item + * @param[in] text The text string of the item + * @param[in] actionId The specified @c actionId for this item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c actionId is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks The @c actionId range is @c 0-999. @n + * This method can only be used when the Form control has the FORM_STYLE_TEXT_TAB style. + * @endif + */ + result SetItemAt(int index, const Tizen::Base::String& text, int actionId); + + /** + * @if OSPDEPREC + * Sets the item that consists of the title icon and the specified text string at the given index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item + * @param[in] titleIcon The bitmap for the title icon + * @param[in] text The text string of the item + * @param[in] actionId The action ID for the item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c actionId is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks The @c actionId range is @c 0-999. @n + * This method can only be used when the Form control has the FORM_STYLE_TEXT_TAB style. @n + * If the size of bitmap is greater than the default size, the bitmap is scaled down. + * @endif + */ + result SetItemAt(int index, const Tizen::Graphics::Bitmap& titleIcon, const Tizen::Base::String& text, int actionId); + + /** + * @if OSPDEPREC + * Sets the item that consists of only a title icon at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item + * @param[in] icon The bitmap for the icon + * @param[in] actionId The action ID for the item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c actionId is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks The @c actionId range is @c 0-999. @n + * This method can only be used when the Form control has the FORM_STYLE_ICON_TAB style. @n + * If the size of bitmap is greater than the default size, the bitmap is scaled down. + * @endif + */ + result SetItemAt(int index, const Tizen::Graphics::Bitmap& icon, int actionId); + + /** + * @if OSPDEPREC + * Removes item at the given index from the tab. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RemoveItemAt(int index); + + /** + * @if OSPDEPREC + * Removes all the items from the tab. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result RemoveAllItems(void); + + /** + * @if OSPDEPREC + * Sets the badge icon of the specified item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] actionId The specified @c actionId for this item + * @param[in] pBadgeIcon The bitmap for the icon + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c actionId is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks The @c actionId range is @c 0-999. @n + * If the size of bitmap is greater than the default size, the bitmap is scaled down. + * @endif + */ + result SetBadgeIcon(int actionId, const Tizen::Graphics::Bitmap* pBadgeIcon); + + /** + * @if OSPDEPREC + * Gets the number of items in the specified tab. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return The number of items in the tab + * @endif + */ + int GetItemCount(void) const; + + /** + * @if OSPDEPREC + * Gets the index of the item at the specified action ID. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if an error occurs + * @param[in] actionId The action ID of the item + * @remarks The @c actionId range is @c 0-999. + * @endif + */ + int GetItemIndexFromActionId(int actionId) const; + + /** + * @if OSPDEPREC + * Gets the action ID of the item at the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return The action ID of the item, @n + * else @c -1 if @c index is less than @c 0 or greater than the item count of tab + * @param[in] index The index of the item + * @endif + */ + int GetItemActionIdAt(int index) const; + + /** + * @if OSPDEPREC + * Sets the selected item for the specified index. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @param[in] index The index of the item + * @endif + */ + void SetSelectedItem(int index); + + /** + * @if OSPDEPREC + * Gets the index of the selected item from the tab. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return The index of the item, @n + * else @c -1 if an error occurs + * @endif + */ + int GetSelectedItemIndex(void) const; + + /** + * @if OSPDEPREC + * Sets the edit-enabled mode. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @param[in] enable Set to @c true to enable edit mode, @n + * else @c false + * @endif + */ + void SetEditModeEnabled(bool enable); + + /** + * @if OSPDEPREC + * Checks whether the edit mode is set. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return @c true if the edit mode is set, @n + * else @c false + * @endif + */ + bool IsEditModeEnabled(void) const; + + /** + * @if OSPDEPREC + * Sets the background bitmap of the tab. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] bitmap The background bitmap + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The background bitmap is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * @if OSPDEPREC + * Sets the background bitmap of the focused item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] bitmap The background bitmap of the focused item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The background bitmap is invalid. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result SetFocusedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * @if OSPDEPREC + * Sets the text color of the tab. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @param[in] textColor The color to be set + * @endif + */ + void SetTextColor(const Tizen::Graphics::Color& textColor); + + /** + * @if OSPDEPREC + * Gets the text color of the tab. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return The text color + * @endif + */ + Tizen::Graphics::Color GetTextColor(void) const; + + /** + * @if OSPDEPREC + * Sets the text color for the selected item of the tab. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @param[in] textColor The color to be set + * @endif + */ + void SetSelectedTextColor(const Tizen::Graphics::Color& textColor); + + /** + * @if OSPDEPREC + * Gets the text color for the selected item of the tab. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return The text color + * @endif + */ + Tizen::Graphics::Color GetSelectedTextColor(void) const; + + /** + * @if OSPDEPREC + * Gets the color of the text when the %Tab item is highlighted. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return The highlighted text color + * @remarks When a user navigates the user interface using the directional keys, the focused UI control is highlighted. + * @endif + */ + Tizen::Graphics::Color GetHighlightedTextColor(void) const; + + /** + * @if OSPDEPREC + * Sets the color of the text when the tab item is highlighted. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @param[in] color The color to be set + * @remarks When a user navigates the user interface using the directional keys, the focused UI control is highlighted. + * @endif + */ + void SetHighlightedTextColor(const Tizen::Graphics::Color& color); + + /** + * @if OSPDEPREC + * Sets the background bitmap of the highlighted tab item. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because the use of the %Tab control is no longer recommended. + * @since 2.0 + * + * @return An error code + * @param[in] bitmap The background bitmap of the focused item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The background bitmap is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The background bitmap must use the 9-patched bitmap. + * @remarks When a user navigates the user interface using the directional keys, the focused UI control is highlighted. + * @endif + */ + result SetHighlightedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + + //void SetStyle(int style); + +private: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + // @since 2.0 + // + Tab(void); + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + // @since 2.0 + // + virtual ~Tab(void); + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // Initializes this instance of %Tab with the specified parameter. + // + // @since 2.0 + // @return An error code + // @param[in] tabHandle The handle of the tab + // @exception E_SUCCESS The method is successful. + // @exception E_SYSTEM A system error has occurred. + // + result Construct(void); + + // + // Stores __BitmapItem. + // + Tizen::Base::Collection::ArrayList __items; + +private: + friend class _TabImpl; + +}; + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_TAB_H_ diff --git a/inc/FUiCtrlTabBar.h b/inc/FUiCtrlTabBar.h new file mode 100644 index 0000000..05e59c8 --- /dev/null +++ b/inc/FUiCtrlTabBar.h @@ -0,0 +1,487 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlTabBar.h + * @brief This is the header file for the %TabBar class. + * + * This header file contains the declarations of the %TabBar class. + */ +#ifndef _FUI_CTRL_TAB_BAR_H_ +#define _FUI_CTRL_TAB_BAR_H_ + +#include + +namespace Tizen { namespace Ui +{ +class IActionEventListener; +}} // Tizen::Ui +namespace Tizen { namespace Ui { namespace Controls +{ +class TabBarItem; +}}} // Tizen::Ui::Controls + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @enum TabBarItemStatus + * + * Defines the possible states of TabBarItem. + * + * @since 2.0 + */ +enum TabBarItemStatus +{ + TAB_BAR_ITEM_STATUS_NORMAL, /**< The normal state */ + TAB_BAR_ITEM_STATUS_SELECTED /**< The selected state */ +}; + + +/** + * @class TabBar + * @brief This class is an implementation of %TabBar. + * + * @since 2.0 + * + * The %TabBar class displays a list of possible options for the user selection in a horizontal list. + * + * For more information on the class features, see TabBar. + * + * The following example demonstrates how to use the %TabBar class. + * + * @code +// Sample code for TabBarSample.h +#include + +class TabBarSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::IActionEventListener +{ +public: + TabBarSample(void) + : __pTabBar(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + + // IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + +private: + static const int ID_TABBAR_ITEM1 = 100; + static const int ID_TABBAR_ITEM2 = 101; + static const int ID_TABBAR_ITEM3 = 102; + + Tizen::Ui::Controls::TabBar *__pTabBar; +}; + * @endcode + * + * @code +// Sample code for TabBarSample.cpp +#include "TabBarSample.h" + +using namespace Tizen::Ui::Controls; + +bool +TabBarSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +TabBarSample::OnInitializing() +{ + result r = E_SUCCESS; + + // Creates an instance of TabBar + __pTabBar = new TabBar(); + __pTabBar->Construct(0, 0, GetClientAreaBounds().width); + + // Creates instances of TabBarItem + TabBarItem tabBarItem1; + TabBarItem tabBarItem2; + TabBarItem tabBarItem3; + + tabBarItem1.Construct(L"1", ID_TABBAR_ITEM1); + tabBarItem2.Construct(L"2", ID_TABBAR_ITEM2); + tabBarItem3.Construct(L"3", ID_TABBAR_ITEM3); + + // Adds items to the tab bar + __pTabBar->AddItem(tabBarItem1); + __pTabBar->AddItem(tabBarItem2); + __pTabBar->AddItem(tabBarItem3); + __pTabBar->AddActionEventListener(*this); + + // Adds the tab bar to the form + AddControl(*__pTabBar); + + return r; +} + +// IActionEventListener implementation +void +TabBarSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_TABBAR_ITEM1: + { + // .... + } + break; + case ID_TABBAR_ITEM2: + { + // .... + } + break; + default: + break; + } +} + * @endcode + * + */ +class _OSP_EXPORT_ TabBar + : public Tizen::Ui::Control +{ +// Lifecycle +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + * + */ + TabBar(void); + + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + * + */ + virtual ~TabBar(void); + + /** + * Initializes this instance of %TabBar with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] x The X position of the top left corner + * @param[in] y The Y position of the top left corner + * @param[in] width The width + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(int x, int y, int width); + + +// Operation +public: + /** + * Adds the specified item. + * + * @since 2.0 + * + * @return An error code + * @param[in] item The item to be added + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c item is not constructed. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + * @remarks The maximum number of items for a %TabBar control is @c 100. @n + * However, the content of the specified item is copied to the %TabBar control. @n + * The item can be deallocated explicitly after this method call if it is created dynamically. @n + * The %TabBar control does not throw any exception even though the same action ID is assigned to multiple items. + */ + result AddItem(const TabBarItem& item); + + + /** + * Inserts the %TabBar item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item to be inserted + * @param[in] item The item to be inserted + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c item is not constructed. + * @exception E_MAX_EXCEEDED The number of items has exceeded the maximum limit. + * @exception E_OUT_OF_RANGE The specified @c index is out of the range of the data structure. @n + * The specified @c index is either greater than or equal to the number of items or is less than @c 0. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + * @remarks The maximum number of items for a %TabBar control is @c 100. @n + * However, the content of the specified item is copied to the @c %TabBar control. @n + * The item can be deallocated explicitly after this method call if it is created dynamically. @n + * The %TabBar control does not throw any exception even though the same action ID is assigned to multiple items. + */ + result InsertItemAt(int index, const TabBarItem& item); + + + /** + * Gets the color of the %TabBar control. + * + * @since 2.0 + * + * @return The color, @n + * else RGBA(0,0,0,0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetColor(void) const; + + + /** + * Gets the item count. + * + * @since 2.0 + * + * @return The item count, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetItemCount(void) const; + + + /** + * Gets the item color that is displayed when an item is selected. + * + * @since 2.0 + * + * @return The selected item color, @n + * else RGBA(0,0,0,0) if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetSelectedItemColor(void) const; + + + /** + * Gets the item text color for the specified state. + * + * @since 2.0 + * + * @return The item text color, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The item state + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetItemTextColor(TabBarItemStatus status) const; + + + /** + * Gets the index of the selected item. + * + * @since 2.0 + * + * @return The selected item index, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetSelectedItemIndex(void) const; + + + /** + * Removes the %TabBar item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is out of the range of the data structure. @n + * The specified @c index is either greater than or equal to the number of items or is less than @c 0. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + * @remarks If the currently selected item is removed, the next item is selected automatically. + */ + result RemoveItemAt(int index); + + + /** + * Removes all the items from the %TabBar control. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + */ + result RemoveAllItems(void); + + + /** + * Sets the color of the %TabBar control. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The color + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetColor(const Tizen::Graphics::Color& color); + + + /** + * Sets the content of the %TabBar item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index at which to set the specified item + * @param[in] item The item to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c item is not constructed. + * @exception E_OUT_OF_RANGE The specified @c index is out of the range of the data structure. @n + * The specified @c index is either greater than or equal to the number of items or is less than @c 0. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + * @remarks The contents of the specified item are copied. @n + * The item can be deallocated explicitly after this method call if it is created dynamically. + */ + result SetItemAt(int index, const TabBarItem& item); + + + /** + * Selects the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The index of the item to be selected + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is not within the range of the data structure. @n + * The specified @c index is either greater than or equal to the number of items or is less than @c 0. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemSelected(int index); + + + /** + * Sets the item text color for the specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The item state + * @param[in] color The item text color + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + */ + result SetItemTextColor(TabBarItemStatus status, const Tizen::Graphics::Color& color); + + + /** + * Sets the selected item color. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The item color + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + */ + result SetSelectedItemColor(const Tizen::Graphics::Color& color); + + + /** + * Sets the width of the tab bar. + * + * @since 2.0 + * + * @return An error code + * @param[in] width The width + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error has occurred. + */ + result SetWidth(int width); + + +//Listeners +public: + /** + * Adds an action event listener instance. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + + /** + * Removes an action event listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + +protected: + friend class _TabBarImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + // + TabBar(const TabBar& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + // + TabBar& operator =(const TabBar& rhs); + +}; // TabBar + +}}} // Tizen::Ui: Control +#endif //_FUI_CTRL_TAB_BAR_H_ diff --git a/inc/FUiCtrlTabBarItem.h b/inc/FUiCtrlTabBarItem.h new file mode 100644 index 0000000..0ef9813 --- /dev/null +++ b/inc/FUiCtrlTabBarItem.h @@ -0,0 +1,167 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlTabBarItem.h + * @brief This is the header file for the %TabBarItem class. + * + * This header file contains the declarations of the %TabBarItem class. + */ +#ifndef _FUI_CTRL_TAB_BAR_ITEM_H_ +#define _FUI_CTRL_TAB_BAR_ITEM_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class _TabBarItemImpl; +}; +}; +}; + + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class TabBarItem + * @brief This class is an implementation of %TabBarItem. + * + * @since 2.0 + * + * The %TabBarItem class is a helper class that specifies the contents of a tab bar item. + * + * For more information on the class features, see TabBar. + */ +class _OSP_EXPORT_ TabBarItem + : public Tizen::Base::Object +{ +// Lifecycle +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + TabBarItem(void); + + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TabBarItem(void); + + + /** + * Initializes this instance of %TabBarItem with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The item text + * @param[in] actionId The action ID of this item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The @c actionId of the specified item must be greater than or equal to @c 0. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result Construct(const Tizen::Base::String& text, int actionId); + + +// Operation +public: + /** + * Sets the action ID of the item. + * + * @since 2.0 + * + * @return An error code + * @param[in] actionId The action ID for this item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The @c actionId of the specified item must be a positive integer. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetActionId(int actionId); + + + /** + * Gets the action ID of the item. + * + * @since 2.0 + * + * @return The action ID, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetActionId(void) const; + + + /** + * Gets the text of the item. + * + * @since 2.0 + * + * @return The item text, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::String GetText(void) const; + + + /** + * Sets the text of the item. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be set + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @remarks If the size of the text exceeds the displayable area, the font size of the text is decreased automatically. + */ + result SetText(const Tizen::Base::String& text); + + +private: + friend class TabBar; + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + _TabBarItemImpl* __pTabBarItemImpl; + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + TabBarItem(const TabBarItem& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + TabBarItem& operator =(const TabBarItem& rhs); + +}; // TabBarItem + +}}} // Tizen::Ui: Control + +#endif //_FUI_CTRL_TAB_BAR_ITEM_H_ diff --git a/inc/FUiCtrlTableView.h b/inc/FUiCtrlTableView.h new file mode 100644 index 0000000..ad142df --- /dev/null +++ b/inc/FUiCtrlTableView.h @@ -0,0 +1,660 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlTableView.h + * @brief This is the header file for the %TableView class. + * + * This header file contains the declarations of the %TableView class and its helper classes. + */ + +#ifndef _FUI_CTRL_TABLE_VIEW_H_ +#define _FUI_CTRL_TABLE_VIEW_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class ITableViewItemProvider; +class ITableViewItemEventListener; +class IFastScrollListener; +class IScrollEventListener; + +/** + * @class TableView + * @brief This class defines common behavior for a %TableView control. + * + * @since 2.0 + * + * The %TableView class defines common behavior for a %TableView control. + * @code +//Sample code for TableViewSample.h +#include + +class TableViewSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::Controls::ITableViewItemProvider + , public Tizen::Ui::Controls::ITableViewItemEventListener +{ +public: + TableViewSample(void) + : __pTableView(null) + , __pContextItem(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // ITableViewItemEventListener + virtual void OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + virtual void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated); + virtual void OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView, int itemIndexFrom, int itemIndexTo); + + // ITableViewItemProvider + virtual int GetItemCount(void); + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int itemIndex, int itemWidth); + virtual bool DeleteItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + virtual void UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + virtual int GetDefaultItemHeight(void); + +private: + Tizen::Ui::Controls::TableView* __pTableView; + Tizen::Ui::Controls::TableViewContextItem* __pContextItem; +}; + * @endcode + * + * @code +//Sample code for TableViewSample.cpp +#include +#include + +#include "TableViewSample.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui::Controls; + +bool +TableViewSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +TableViewSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of TableView + __pTableView = new TableView(); + __pTableView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT); + __pTableView->SetItemProvider(*this); + __pTableView->AddTableViewItemEventListener(*this); + + // Adds the TableView to the form + AddControl(*__pTableView); + + // Creates an instance of TableViewContextItem + __pContextItem = new TableViewContextItem(); + __pContextItem->Construct(Dimension(720, 100)); + + Button* pButton = new Button(); + pButton->Construct(Rectangle(10, 10, 200, 80), L"Context1"); + + Button* pButton2 = new Button(); + pButton2->Construct(Rectangle(250, 10, 200, 80), L"Context2"); + + __pContextItem->AddControl(*pButton); + __pContextItem->AddControl(*pButton2); + + return r; +} + +result +TableViewSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the item context + delete __pItemContext; + __pItemContext = null; + + return r; +} + +// ITableViewItemEventListener implementation +void +TableViewSample::OnTableViewItemStateChanged(TableView& tableView, int itemIndex, TableViewItem* pItem, TableViewItemStatus status) +{ + // .... +} + +void +TableViewSample::OnTableViewContextItemActivationStateChanged(TableView& tableView, int itemIndex, TableViewContextItem* pContextItem, bool activated) +{ + // .... +} + +void +TableViewSample::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView, int itemIndexFrom, int itemIndexTo) +{ + // .... +} + +// ITableViewItemProvider implementation +int +TableViewSample::GetItemCount(void) +{ + return 50; +} + +int +TableViewSample::GetDefaultItemHeight(void) +{ + return 100; +} + +TableViewItem* +TableViewSample::CreateItem(int itemIndex, int itemWidth) +{ + TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL; + TableViewItem* pItem = new TableViewItem(); + + switch (itemIndex % 5) + { + case 0: + style = TABLE_VIEW_ANNEX_STYLE_NORMAL; + break; + case 1: + style = TABLE_VIEW_ANNEX_STYLE_MARK; + break; + case 2: + style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING; + break; + case 3: + style = TABLE_VIEW_ANNEX_STYLE_DETAILED; + break; + case 4: + style = TABLE_VIEW_ANNEX_STYLE_RADIO; + break; + default: + break; + } + + pItem->Construct(Dimension(itemWidth, GetDefaultItemHeight()), style); + + String text; + text.Format(30, L"TableViewItem %d", itemIndex); + + Label* pLabel = new Label(); + pLabel->Construct(Rectangle(0, 0, itemWidth, GetDefaultItemHeight(), text); + + pItem->AddControl(*pLabel); + pItem->SetContextItem(__pContextItem); + + return pItem; +} + +bool +TableViewSample::DeleteItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem) +{ + delete pItem; + + return true; +} + +void +TableViewSample::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem) +{ + // .... +} + * @endcode + * + */ + +class _OSP_EXPORT_ TableView + : public Tizen::Ui::Container +{ +public: + /** + * The object is not fully constructed after this constructor is called. Hence, the Construct() method must be called after calling this constructor. + * + * @since 2.0 + */ + TableView(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TableView(void); + + /** + * Initializes this instance of %TableView with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class + * This instance represents the x and y coordinates of the left top corner of the created %TableView along with the width and height. + * @param[in] itemDivider Set to @c true to display an item divider, @n + * else @c false + * @param[in] scrollStyle The style of %TableView scroll bar style + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or either the rect.width or rect.height parameter has a negative value. + * + */ + result Construct(const Tizen::Graphics::Rectangle& rect, bool itemDivider, TableViewScrollBarStyle scrollStyle); + + /** + * Sets the item provider that creates and deletes items for the simple style table view. + * + * @since 2.0 + * + * @param[in] pProvider The item provider to create and delete items + * @remarks If an item provider is not set for the table view, the table view does not work. The specified provider should be allocated in heap memory. + * To reset the item provider, pass @c null to @c pProvider. + */ + void SetItemProvider(ITableViewItemProvider* pProvider); + + /** + * Begins the reordering mode. + * + * @since 2.0 + * + * @see ITableViewViewItemEventListener::OnTableViewItemReordered() + */ + void BeginReorderingMode(void); + + /** + * Ends the reordering mode. + * + * @since 2.0 + * + * @see ITableViewViewItemEventListener::OnTableViewItemReordered() + */ + void EndReorderingMode(void); + + /** + * Returns whether the %TableView control is in reordering mode or not. + * + * @since 2.0 + * + * @return @c true if the %TableView is in reordering mode, @n + * else @c false + */ + bool IsInReorderingMode(void) const; + + /** + * Adds a listener instance that listens to state changes of table view items. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @remarks The specified listener should be allocated in heap memory. + */ + result AddTableViewItemEventListener(ITableViewItemEventListener& listener); + + /** + * Removes a listener instance that listens to state changes of table view items. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The listener is not found. + */ + result RemoveTableViewItemEventListener(ITableViewItemEventListener& listener); + + /** + * Adds a listener instance that listens to state changes of a fast scroll. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @remarks The specified listener should be allocated in heap memory. + */ + result AddFastScrollListener(IFastScrollListener& listener); + + /** + * Removes a listener instance that listens to state changes of a fast scroll. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_OBJ_NOT_FOUND The listener is not found. + */ + result RemoveFastScrollListener(IFastScrollListener& listener); + + /** + * Adds a listener instance that listens to state changes of a scroll event. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @see IScrollEventListener::OnScrollEndReached() + * @see RemoveScrollEventListener() + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @remarks The specified listener should be allocated in heap memory. + */ + result AddScrollEventListener(IScrollEventListener& listener); + + /** + * Removes a listener instance that listens to state changes of a scroll event. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to remove + * @see IScrollEventListener::OnScrollEndReached() + * @see AddScrollEventListener() + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_OBJ_NOT_FOUND The listener is not found. + */ + result RemoveScrollEventListener(IScrollEventListener& listener); + + /** + * Sets the index table view of the scroll by texts. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text of the index + * @param[in] useSearchIcon Set to @c true to show the magnifying icon, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + */ + result SetFastScrollIndex(const Tizen::Base::String& text, bool useSearchIcon); + + /** + * Gets the group and item indexes of the top item. + * + * @since 2.0 + * + * @return The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND Top drawn item is not found. + */ + int GetTopDrawnItemIndex(void) const; + + /** + * Gets the group and item indexes of the bottom item. + * + * @since 2.0 + * + * @return The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND Bottom drawn item is not found. + */ + int GetBottomDrawnItemIndex(void) const; + + /** + * Scrolls to the item at the specified index. + * The specified item is drawn at the position specified by the item alignment. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The targeted item index + * @param[in] itemAlignment The item alignment + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + result ScrollToItem(int itemIndex, TableViewScrollItemAlignment itemAlignment = TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP); + + /** + * Checks or unchecks the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The item index to be checked + * @param[in] check Set to @c true to select the item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @exception E_INVALID_OPERATION The item is disabled. + * @remarks This method works only when the annex style of the item allows selection. + */ + result SetItemChecked(int itemIndex, bool check); + + /** + * Returns whether the item at the specified index is selected or not. + * + * @since 2.0 + * + * @return @c true if the item is selected, @n + * else @c false + * @param[in] itemIndex The item itemIndex + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @remarks This method returns @c false, if the annex style of the item does not allow selection. + */ + bool IsItemChecked(int itemIndex) const; + + /** + * Enables or disables the item at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The item index + * @param[in] enable Set to @c true to enable the specified item, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + result SetItemEnabled(int itemIndex, bool enable); + + /** + * Returns whether the item at the specified index is enabled or disabled. + * + * @since 2.0 + * + * @return @c true if the item is enabled, @n + * else @c false + * @param[in] itemIndex The item index + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + */ + bool IsItemEnabled(int itemIndex) const; + + /** + * Counts all the items of the specified group. + * + * @since 2.0 + * + * @return The total number of items + */ + int GetItemCount(void) const; + + /** + * Updates the specified item. @n + * For instance, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD is used when a new item needs to be added and TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE is used when an item is deleted from the + * table view. Moreover, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY is used when the content of an existing item has changed and it needs to be updated. + * Note that calling this method with TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY invokes item provider's UpdateItem() for the given index in sequence. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemIndex The item index + * @param[in] type The item to be added, removed, or modified + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE A specified input parameter is invalid. + * @remarks If the specified itemIndex. + */ + result RefreshItem(int itemIndex, TableViewRefreshType type); + + /** + * Updates all the items of a table view. + * + * @since 2.0 + * + * @return An error code + * @remarks This method clears all the items in the table view and invokes the methods of the item provider again to update the table view. + */ + void UpdateTableView(void); + + /** + * Gets the index of the item at the specified position. + * + * @since 2.0 + * + * @return The item index of the item on specified position + * @param[in] position The position of the item + * @remarks This method returns -1 if no item is found at the given position. + */ + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + + /** + * Sets the color of a division line between items. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The division line color + */ + void SetItemDividerColor(const Tizen::Graphics::Color& color); + + /** + * Gets the color of a division line between items. + * + * @since 2.0 + * + * @return The color of a division line + */ + Tizen::Graphics::Color GetItemDividerColor(void) const; + + /** + * Sets the background color of this control. + * + * @since 2.0 + * + * @param[in] color The background color + * @remarks The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, + * only the bitmap image is displayed. + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + /** + * Gets the background color of this control. + * + * @since 2.0 + * + * @return The background color + */ + Tizen::Graphics::Color GetBackgroundColor(void) const; + + /** + * Sets the scroll input handling mode. + * + * @since 2.0 + * + * @param[in] mode The scroll input handling mode + * @see GetScrollInputMode() + */ + void SetScrollInputMode(ScrollInputMode mode); + + + /** + * Gets the scroll input handling mode. + * + * @since 2.0 + * + * @return The scroll input handling mode + * @see SetScrollInputMode() + */ + ScrollInputMode GetScrollInputMode(void) const; + + /* + * Scrolls the list contents with the amount of pixels. + * + * @since 2.0 + * + * @return An error code + * @param[in] pixel The amount of pixels to scroll + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c pixel is out of range. + * @remarks If you call ScrollByPixel() with negative @c pixel when position of scroll is already top of contents then it will return E_OUT_OF_RANGE. + * Likewise, in case of positive @c pixel on the bottom position of scroll it will also return E_OUT_OF_RANGE. + */ + result ScrollByPixel(int pixel); + + /* + * Gets the current scroll position + * + * @since 2.0 + */ + int GetCurrentScrollPosition(void) const; + + /* + * Enables or disables the scroll of TableView items. + * + * @since 2.0 + */ + void SetScrollEnabled(bool enable); + + /* + * Checks whether the scroll is enabled or disabled. + * + * @since 2.0 + */ + bool IsScrollEnabled(void) const; + +private: + friend class _TableViewImpl; + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + TableView(const TableView& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + TableView& operator =(const TableView& rhs); +}; // TableView + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_TABLE_VIEW_H_ diff --git a/inc/FUiCtrlTableViewContextItem.h b/inc/FUiCtrlTableViewContextItem.h new file mode 100644 index 0000000..a33ad5e --- /dev/null +++ b/inc/FUiCtrlTableViewContextItem.h @@ -0,0 +1,85 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlTableViewContextItem.h + * @brief This is the header file for the %TableViewContextItem class. + * + * This header file contains the declarations of the %TableViewContextItem class and its helper classes. + */ + +#ifndef _FUI_CTRL_TABLE_VIEW_CONTEXT_ITEM_H_ +#define _FUI_CTRL_TABLE_VIEW_CONTEXT_ITEM_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class TableViewContextItem + * @brief This class defines common behavior for a %TableViewContextItem. + * + * @since 2.0 + * + * The %TableViewContextItem class is a class which represents a context item for TableView. + * A context item is shown when a table view item is swept, if %TableViewContextItem is set to the table view item. + * + */ + +class _OSP_EXPORT_ TableViewContextItem + : public TableViewItemBase +{ +public: + /** + * The object is not fully constructed after this constructor is called. Hence, the Construct() method must be called after calling this constructor. + * + * @since 2.0 + */ + TableViewContextItem(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TableViewContextItem(void); + + /** + * Initializes this instance of %TableViewContextItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemSize The size of the item + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result Construct(const Tizen::Graphics::Dimension& itemSize); + +private: + friend class _TableViewItemImpl; + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + TableViewContextItem(const TableViewContextItem& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + TableViewContextItem& operator =(const TableViewContextItem& rhs); +}; // TableViewContextItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_TABLE_VIEW_CONTEXT_ITEM_H_ diff --git a/inc/FUiCtrlTableViewGroupItem.h b/inc/FUiCtrlTableViewGroupItem.h new file mode 100644 index 0000000..4e8f42e --- /dev/null +++ b/inc/FUiCtrlTableViewGroupItem.h @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlTableViewGroupItem.h + * @brief This is the header file for the %TableViewGroupItem class. + * + * This header file contains the declarations of the %TableViewGroupItem class and its helper classes. + */ + +#ifndef _FUI_CTRL_TABLE_VIEW_GROUP_ITEM_H_ +#define _FUI_CTRL_TABLE_VIEW_GROUP_ITEM_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class TableViewGroupItem + * @brief This class defines common behavior of %TableViewGroupItem. + * + * @since 2.0 + * + * The %TableViewGroupItem class displays a table view group item. The %TableViewGroupItem can have any layout of Controls or Containers as children. + */ + +class _OSP_EXPORT_ TableViewGroupItem + : public TableViewItemBase +{ +public: + /** + * The object is not fully constructed after this constructor is called. Hence, the Construct() method must be called after calling this constructor. + * + * @since 2.0 + */ + TableViewGroupItem(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TableViewGroupItem(void); + + /** + * Initializes this instance of %TableViewGroupItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemSize The size of the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Graphics::Dimension& itemSize); + + /** + * Initializes this instance of %TableViewGroupItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] layout The layout for both of the portrait and landscape modes + * @param[in] itemSize The size of the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Dimension& itemSize); + + /** + * Initializes this instance of %TableViewGroupItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] portraitLayout The layout for portrait mode + * @param[in] landscapeLayout The layout for landscape mode + * @param[in] itemSize The size of the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Dimension& itemSize); + +private: + friend class _TableViewItemImpl; + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + TableViewGroupItem(const TableViewGroupItem& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + TableViewGroupItem& operator =(const TableViewGroupItem& rhs); +}; // TableViewGroupItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_TABLE_VIEW_GROUP_ITEM_H_ diff --git a/inc/FUiCtrlTableViewItem.h b/inc/FUiCtrlTableViewItem.h new file mode 100644 index 0000000..d309246 --- /dev/null +++ b/inc/FUiCtrlTableViewItem.h @@ -0,0 +1,139 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlTableViewItem.h + * @brief This is the header file for the %TableViewItem class. + * + * This header file contains the declarations of the %TableViewItem class and its helper classes. + */ + +#ifndef _FUI_CTRL_TABLE_VIEW_ITEM_H_ +#define _FUI_CTRL_TABLE_VIEW_ITEM_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class TableViewContextItem; + +/** + * @class TableViewItem + * @brief This class defines common behavior for a %TableViewItem. + * + * @since 2.0 + * + * The %TableViewItem class is a base class which represents a table view item which is the unit of handling of TableView. + * + */ + +class _OSP_EXPORT_ TableViewItem + : public TableViewItemBase +{ +public: + /** + * The object is not fully constructed after this constructor is called. Hence, the Construct() method must be called after calling this constructor. + * + * @since 2.0 + */ + TableViewItem(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TableViewItem(void); + + /** + * Initializes this instance of %TableViewItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemSize The size of the item + * @param[in] style The style of Annex + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL); + + /** + * Initializes this instance of %TableViewItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] layout The layout for both of the portrait and landscape modes + * @param[in] itemSize The size of the item + * @param[in] style The style of Annex + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL); + + /** + * Initializes this instance of %TableViewItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] portraitLayout The layout for portrait mode + * @param[in] landscapeLayout The layout for landscape mode + * @param[in] itemSize The size of the item + * @param[in] style The style of Annex + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL); + + /** + * Sets context item that is displayed when an item is swept. + * + * @since 2.0 + * + * @return An error code + * @param[in] pItem The object of TableViewContextItem + * @remarks If context item is not set, TableView() does not display context item and an item sweep event is generated when an item is swept. + * pItem must be deleted by applications when it is no longer used. + */ + void SetContextItem(const TableViewContextItem* pItem); + + /** + * Get the width of the annex area. + * + * @since 2.0 + * + * @return The width of the annex + * @param[in] style The style of the annex + * @remarks The width of the annex area is different among annex styles. + */ + static int GetAnnexWidth(TableViewAnnexStyle style); + +private: + friend class _TableViewItemImpl; + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + TableViewItem(const TableViewItem& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + TableViewItem& operator =(const TableViewItem& rhs); +}; //TableViewItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_TABLE_VIEW_ITEM_H_ diff --git a/inc/FUiCtrlTableViewItemBase.h b/inc/FUiCtrlTableViewItemBase.h new file mode 100644 index 0000000..2729b0a --- /dev/null +++ b/inc/FUiCtrlTableViewItemBase.h @@ -0,0 +1,169 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlTableViewItemBase.h +* @brief This is the header file for the %TableViewItemBase class. +* +* This header file contains the declarations of the %TableViewItemBase class and its helper classes. +*/ + +#ifndef _FUI_CTRL_TABLE_VIEW_ITEM_BASE_H_ +#define _FUI_CTRL_TABLE_VIEW_ITEM_BASE_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class TableViewItemBase + * @brief This class defines common behavior for a %TableViewItemBase. + * + * @since 2.0 + * + * The %TableViewItemBase class is a base class which represents a table view item which is the unit of handling of TableView. + * + */ + +class _OSP_EXPORT_ TableViewItemBase + : public Tizen::Ui::Container +{ +public: + /** + * Sets the background image of the item which is displayed when the item is in specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] pBitmap The background bitmap image + * @param[in] status The item drawing state + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The background bitmap has priority over the background color. When both the background bitmap and the background color are specified, only the bitmap is displayed. + */ + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap, TableViewItemDrawingStatus status = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + /** + * Sets the background color of the item which is displayed when the item is in specified state. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The background color + * @param[in] status The item drawing state + */ + void SetBackgroundColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + /** + * Gets the background color of the item which is displayed when the item is in the specified state. + * + * @since 2.0 + * + * @return The background color of the item + * @param[in] status The item drawing state + * + * @remarks If an error occurs, this method returns RGBA(0, 0, 0, 0). + * @see SetBackgroundColor() + */ + Tizen::Graphics::Color GetBackgroundColor(TableViewItemDrawingStatus status = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL) const; + + /** + * Enables or disables the individual selection of a control. + * + * @since 2.0 + * + * @return An error code + * @param[in] pControl The child control to be selected individually. + * @param[in] enable Set to @c true to enable the individual selection of a control, else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result SetIndividualSelectionEnabled(const Tizen::Ui::Control* pControl, bool enable); + + /** + * Returns whether the individual selection of a control is enabled or not. + * + * @since 2.0 + * + * @return @c true if the individual selection of a control is enabled, else @c false + * @param[in] pControl The target control. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + bool IsIndividualSelectionEnabled(const Tizen::Ui::Control* pControl); + +protected: + // + // This class is constructible only as a subobject of a derived class. + // + // @since 2.0 + // + TableViewItemBase(void); + + // + // This class is destructible only as a subobject of a derived class. + // + // @since 2.0 + // + virtual ~TableViewItemBase(void); + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void TableViewItemBase_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void TableViewItemBase_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // The following method is reserved, and its name can be changed at any time without prior notice. + // + // @since 2.0 + // + virtual void TableViewItemBase_Reserved3(void) {} + +private: + friend class _TableViewItemImpl; + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + TableViewItemBase(const TableViewItemBase& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + TableViewItemBase& operator =(const TableViewItemBase& rhs); +}; // TableViewItemBase + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_TABLE_VIEW_ITEM_BASE_H_ diff --git a/inc/FUiCtrlTableViewSimpleGroupItem.h b/inc/FUiCtrlTableViewSimpleGroupItem.h new file mode 100644 index 0000000..a7864e0 --- /dev/null +++ b/inc/FUiCtrlTableViewSimpleGroupItem.h @@ -0,0 +1,157 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlTableViewSimpleGroupItem.h + * @brief This is the header file for the %TableViewSimpleGroupItem class. + * + * This header file contains the declarations of the %TableViewSimpleGroupItem class and its helper classes. + */ + +#ifndef _FUI_CTRL_TABLE_VIEW_SIMPLE_GROUP_ITEM_H_ +#define _FUI_CTRL_TABLE_VIEW_SIMPLE_GROUP_ITEM_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class TableViewSimpleGroupItem + * @brief This class defines common behavior of %TableViewSimpleGroupItem. + * + * @since 2.0 + * + * The %TableViewSimpleGroupItem class displays a table view group item. The basic layout of the %TableViewSimpleGroupItem instance is text and a bitmap arranged horizontally in one line. The bitmap can be omitted while text must be given. + */ + +class _OSP_EXPORT_ TableViewSimpleGroupItem + : public TableViewGroupItem +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + TableViewSimpleGroupItem(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TableViewSimpleGroupItem(void); + + /** + * Initializes this instance of %TableViewSimpleGroupItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemSize The size of the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Graphics::Dimension& itemSize); + + /** + * Initializes this instance of %TableViewSimpleGroupItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] layout The layout for both of the portrait and landscape modes + * @param[in] itemSize The size of the item + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Dimension& itemSize); + + /** + * Sets the text string and bitmap image for %TableViewSimpleGroupItem. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text string to be added + * @param[in] pBitmap The bitmap image to be displayed + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result SetItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap = null); + + /** + * Sets the color of the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The text color + * @param[in] status The item drawing state + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @see GetTextColor() + */ + result SetTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + /** + * Gets the color of the text. + * + * @since 2.0 + * + * @return The text color + * @param[in] status The item drawing state + * @see SetTextColor() + */ + Tizen::Graphics::Color GetTextColor(TableViewItemDrawingStatus status = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL) const; + + /** + * Sets the size of the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The size of the text + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @see GetTextSize() + */ + result SetTextSize(int size); + + /** + * Gets the size of the text. + * + * @since 2.0 + * + * @return The size of the text + * @see SetTextSize() + */ + int GetTextSize(void) const; + +private: + friend class _TableViewItemImpl; + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + TableViewSimpleGroupItem(const TableViewSimpleGroupItem& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + TableViewSimpleGroupItem& operator =(const TableViewSimpleGroupItem& rhs); +}; // TableViewSimpleGroupItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_TABLE_VIEW_SIMPLE_GROUP_ITEM_H_ diff --git a/inc/FUiCtrlTableViewSimpleItem.h b/inc/FUiCtrlTableViewSimpleItem.h new file mode 100644 index 0000000..2c0bc5e --- /dev/null +++ b/inc/FUiCtrlTableViewSimpleItem.h @@ -0,0 +1,158 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlTableViewSimpleItem.h + * @brief This is the header file for the %TableViewSimpleItem class. + * + * This header file contains the declarations of the %TableViewSimpleItem class and its helper classes. + */ + +#ifndef _FUI_CTRL_TABLE_VIEW_SIMPLE_ITEM_H_ +#define _FUI_CTRL_TABLE_VIEW_SIMPLE_ITEM_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class TableViewSimpleItem + * @brief This class defines common behavior for a %TableViewSimpleItem. + * + * @since 2.0 + * + * The %TableViewSimpleItem class is a class which represents a table view item which has one label and one bitmap. + * + */ + +class _OSP_EXPORT_ TableViewSimpleItem + : public TableViewItem +{ +public: + /** + * The object is not fully constructed after this constructor is called. Hence, the Construct() method must be called after calling this constructor. + * + * @since 2.0 + */ + TableViewSimpleItem(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TableViewSimpleItem(void); + + /** + * Initializes this instance of %TableViewSimpleItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] itemSize The size of the item + * @param[in] style The style of Annex + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL); + + /** + * Initializes this instance of TableViewItem with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] layout The layout for both of the portrait and landscape modes + * @param[in] itemSize The size of the item + * @param[in] style The style of Annex + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL); + + /** + * Sets the text string and bitmap image for %TableViewSimpleItem. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text string to be added + * @param[in] pBitmap The bitmap image to be displayed + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result SetItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap = null); + + /** + * Sets the color of the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] color The text color + * @param[in] status The item drawing state + * @see GetTextColor() + */ + void SetTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + /** + * Gets the color of the text. + * + * @since 2.0 + * + * @return The text color, + * @param[in] status The item drawing state + * @see SetTextColor() + */ + Tizen::Graphics::Color GetTextColor(TableViewItemDrawingStatus status = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL) const; + + /** + * Sets the size of the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The size of the text + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The given text size is less than 1. + * @see GetTextSize() + */ + result SetTextSize(int size); + + /** + * Gets the size of the text. + * + * @since 2.0 + * + * @return The size of the text, + * @see SetTextSize() + */ + int GetTextSize(void) const; + +private: + friend class _TableViewItemImpl; + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + TableViewSimpleItem(const TableViewSimpleItem& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + TableViewSimpleItem& operator =(const TableViewSimpleItem& rhs); +}; // TableViewSimpleItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_TABLE_VIEW_SIMPLE_ITEM_H_ diff --git a/inc/FUiCtrlTableViewTypes.h b/inc/FUiCtrlTableViewTypes.h new file mode 100644 index 0000000..9681717 --- /dev/null +++ b/inc/FUiCtrlTableViewTypes.h @@ -0,0 +1,150 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlTableViewTypes.h + * @brief This is the header file for the TableView enumerations. + * + * This header file contains the declarations of the TableView enumerations. + */ +#ifndef _FUI_CTRL_TABLE_VIEW_TYPES_H_ +#define _FUI_CTRL_TABLE_VIEW_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @enum TableViewAnnexStyle + * + * Defines the style of annex in the items. + * + * @since 2.0 + */ +enum TableViewAnnexStyle +{ + TABLE_VIEW_ANNEX_STYLE_NORMAL = 0, /**< No annex */ + TABLE_VIEW_ANNEX_STYLE_MARK, /**< Mark style check for multiple selection */ + TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING, /**< On/Off slider style */ + TABLE_VIEW_ANNEX_STYLE_DETAILED, /**< Detailed style for further interaction */ + TABLE_VIEW_ANNEX_STYLE_RADIO /**< Radio style check for simple look */ +}; + +/** + * @enum TableViewItemDrawingStatus + * + * Defines the drawing state of the items. + * + * @since 2.0 + */ +enum TableViewItemDrawingStatus +{ + TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL = 0, /**< The normal drawing state */ + TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED, /**< The pressed drawing state */ + TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED /**< The highlighted drawing state */ +}; + +/** + * @enum TableViewRefreshType + * + * Defines the update type of the TableView item. + * + * @since 2.0 + */ +enum TableViewRefreshType +{ + TABLE_VIEW_REFRESH_TYPE_ITEM_ADD = 0, /**< Refresh request of adding an item */ + TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE, /**< Refresh request of removing an item */ + TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY /**< Refresh request of modifying an item */ +}; + +/** + * @enum TableViewItemStatus + * + * Defines the item state of the TableView. + * + * @since 2.0 + */ +enum TableViewItemStatus +{ + TABLE_VIEW_ITEM_STATUS_SELECTED = 0, /**< The selected item state */ + TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED, /**< The highlighted item state */ + TABLE_VIEW_ITEM_STATUS_CHECKED, /**< The checked item state */ + TABLE_VIEW_ITEM_STATUS_UNCHECKED, /**< The unchecked item state */ + TABLE_VIEW_ITEM_STATUS_MORE /**< The more item state */ +}; + +/** + * @enum TableViewSweepDirection + * + * Defines the direction of the sweep interaction. + * + * @since 2.0 + */ +enum TableViewSweepDirection +{ + TABLE_VIEW_SWEEP_DIRECTION_LEFT = 0, /**< The left direction */ + TABLE_VIEW_SWEEP_DIRECTION_RIGHT /**< The right direction */ +}; + +/** + * @enum TableViewScrollItemAlignment + * + * Defines the alignment information for item scroll. + * + * @since 2.0 + */ +enum TableViewScrollItemAlignment +{ + TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP = 0, /**< The item is aligned at the top of the TableView at item scroll*/ + TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM /**< The item is aligned at the bottom of the TableView at item scroll */ +}; + +/** + * @enum TableViewScrollBarStyle + * + * Defines the scroll bar style of the list. + * + * @since 2.0 + */ +enum TableViewScrollBarStyle +{ + TABLE_VIEW_SCROLL_BAR_STYLE_NONE = 0, /**< No scroll bar */ + TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT, /**< The fade-out scroll bar style */ + TABLE_VIEW_SCROLL_BAR_STYLE_FIXED, /**< The fixed scroll bar style */ + TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP, /**< The jump to top scroll bar style */ + TABLE_VIEW_SCROLL_BAR_STYLE_THUMB, /**< The thumb scroll bar style */ + TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL /**< The fast scroll bar style */ + +}; + +/** + * @enum ScrollInputMode + * + * Defines the scroll interaction mode + * + * @since 2.0 + */ +enum ScrollInputMode +{ + SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION = 0, /** < Scroll interaction is available to any direction. */ + SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION /** < Scroll interaction is restricted to first direction. */ +}; + + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_TABLE_VIEW_TYPES_H_ diff --git a/inc/FUiCtrlTextBox.h b/inc/FUiCtrlTextBox.h new file mode 100644 index 0000000..4d50354 --- /dev/null +++ b/inc/FUiCtrlTextBox.h @@ -0,0 +1,738 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlTextBox.h + * @brief This is the header file for the %TextBox class. + * + * This header file contains the declarations of the %TextBox class and its helper classes. + */ + +#ifndef _FUI_CTRL_TEXT_BOX_H_ +#define _FUI_CTRL_TEXT_BOX_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class _TextBoxImpl; +}; +}; +}; + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @enum TextBoxBorder + * + * Defines the possible types of text box borders. + * + * @since 2.0 + */ +enum TextBoxBorder +{ + TEXT_BOX_BORDER_NONE, /**< No border */ + TEXT_BOX_BORDER_ROUNDED /**< The rounded border */ +}; + + +/** + * @enum TextBoxStatus + * + * Defines the possible states of the text box. + * + * @since 2.0 + */ +enum TextBoxStatus +{ + TEXT_BOX_STATUS_NORMAL, /**< The normal state */ + TEXT_BOX_STATUS_HIGHLIGHTED, /**< The focus-highlighted state */ + TEXT_BOX_STATUS_DISABLED /**< The disabled state */ +}; + + +/** + * @enum TextBoxTextColor + * + * Defines the possible text colors. + * + * @since 2.0 + */ +enum TextBoxTextColor +{ + TEXT_BOX_TEXT_COLOR_NORMAL, /**< The default text color */ + TEXT_BOX_TEXT_COLOR_HIGHLIGHTED, /**< The highlighted text color */ + TEXT_BOX_TEXT_COLOR_DISABLED, /**< The disabled text color */ + TEXT_BOX_TEXT_COLOR_BLOCKED, /**< The text block color */ + TEXT_BOX_TEXT_COLOR_LINK /**< The link text color */ +}; + + +/** + * @enum TextBoxTextStyle + * + * Defines the possible text styles. + * + * @since 2.0 + */ +enum TextBoxTextStyle +{ + TEXT_BOX_TEXT_STYLE_NORMAL = 0x0000, /**< The normal text style */ + TEXT_BOX_TEXT_STYLE_BOLD = 0x0001, /**< The bold text style */ + TEXT_BOX_TEXT_STYLE_ITALIC = 0x0002, /**< The italic text style */ + TEXT_BOX_TEXT_STYLE_UNDERLINE = 0x0004, /**< The underline text style */ + TEXT_BOX_TEXT_STYLE_STRIKEOUT = 0x0008, /**< The strikeout text style */ + TEXT_BOX_TEXT_STYLE_MAX = 0x7FFF /**< The placeholder */ +}; + +/** + * @class TextBox + * @brief This class is an implementation of a %TextBox control. + * + * @since 2.0 + * + * The %TextBox class displays a non-editable text field. + * + * For more information on the class features, see TextBox. + * + * @code +// Sample code for TextBoxSample.h +#include + +class TextBoxSample + : public Tizen::Ui::Controls::Form +{ +public: + TextBoxSample(void) + : __pTextBox(null){} + + bool Initialize(void); + virtual result OnInitializing(void); + +private: + Tizen::Ui::Controls::TextBox* __pTextBox; +}; + * @endcode + * + * @code +// Sample code for TextBoxSample.cpp +#include + +#include "TextBoxSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +TextBoxSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +TextBoxSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of TextBox + __pTextBox = new TextBox(); + __pTextBox->Construct(Rectangle(50, 50, GetClientAreaBounds().width-80, 300), TEXT_BOX_BORDER_ROUNDED); + + // Sets properties on the text box + __pTextBox->SetTextSize(50); + __pTextBox->SetText(L"Tizen Developer"); + __pTextBox->SetTextColor(TEXT_BOX_TEXT_COLOR_HIGHLIGHTED, Color::GetColor(COLOR_ID_RED)); + __pTextBox->AppendText(L"\nTizen SDK"); + + // Adds the text box to the form + AddControl(*__pTextBox); + + return r; +} + * @endcode + */ +class _OSP_EXPORT_ TextBox + : public Tizen::Ui::Control +{ +// Lifecycle +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + * + */ + TextBox(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~TextBox(void); + + /** + * Initializes this instance of %TextBox with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect An instance of the Graphics::Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner of the created window along with + * the width and height of the control. + * @param[in] border The border style + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Graphics::Rectangle& rect, TextBoxBorder border = TEXT_BOX_BORDER_ROUNDED); + +// Operation +public: + /** + * Sets the auto-link mask. + * + * @since 2.0 + * + * @return An error code + * @param[in] autoLinks The auto-link mask @n + * Multiple link types can be combined using the bitwise OR operator (see Tizen::Base::Utility::LinkType). @n + * For more information, see AutoLink Detection. + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks When @c autoLinks is set to @c 0, the auto-link detection is disabled. + * @see Tizen::Base::Utility::LinkType + * @see GetAutoLinkMask() + */ + result SetAutoLinkMask(unsigned long autoLinks); + + /** + * Gets the auto-link mask. + * + * @since 2.0 + * + * @return The auto-link mask + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetAutoLinkMask() + */ + unsigned long GetAutoLinkMask(void) const; + + /** + * Adds a link event listener. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @see RemoveUiLinkEventListener() + */ + void AddUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + /** + * Removes the specified link event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddUiLinkEventListener() + */ + void RemoveUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + +// Text + /** + * Appends the specified character at the end of the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] character The character to be added + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %TextBox control. @n + * To display the changes, the control must be drawn again. + */ + result AppendCharacter(const Tizen::Base::Character& character); + + /** + * Appends the specified text at the end of the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be appended + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks To denote the end of a line use '\\n'. @n + * The method modifies the text buffer that is managed by the %TextBox control. @n + * To display the changes, the control must be drawn again. + */ + result AppendText(const Tizen::Base::String& text); + + /** + * Clears the text that is displayed by the %TextBox control. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method modifies the text buffer that is managed by the %TextBox control. @n + * To display the changes, the control must be drawn again. + */ + result Clear(void); + + /** + * Gets the number of the lines contained in the %TextBox control. + * + * @since 2.0 + * + * @return The line count of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetLineCount(void) const; + + /** + * Gets the text that is displayed by the %TextBox control. + * + * @since 2.0 + * + * @return The text of the %TextBox control, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetText() + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets a portion of the text that is displayed by the %TextBox control. + * + * @since 2.0 + * + * @return The specified portion of the text, @n + * else an empty string if an error occurs + * @param[in] start The starting index of the range + * @param[in] end The last index of the range + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * The index is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetText() + */ + Tizen::Base::String GetText(int start, int end) const; + + /** + * Gets the length of the text that is displayed by the %TextBox control. + * + * @since 2.0 + * + * @return The length of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetTextLength(void) const; + + /** + * Inserts the character at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The position at which to insert the character + * @param[in] character The character to be inserted + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n + * The specified @c index is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + */ + result InsertCharacterAt(int index, const Tizen::Base::Character& character); + + /** + * Inserts the text at the specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index The position at which to insert the text + * @param[in] text The text to be inserted + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n + * The specified @c index is greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + */ + result InsertTextAt(int index, const Tizen::Base::String& text); + + /** + * Sets the text to be displayed. + * + * @since 2.0 + * + * @return An error code + * @param[in] text The text to be displayed + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks To denote the end of a line use '\\n'. @n + * The method modifies the text buffer that is managed by the %TextBox control. @n + * To display the changes, the control must be drawn again. + */ + result SetText(const Tizen::Base::String& text); + +// Line Spacing + /** + * Gets the line spacing. + * + * @since 2.0 + * + * @return The line spacing, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetLineSpacing() + */ + int GetLineSpacing(void) const; + + /** + * Sets the line spacing. @n + * The line spacing is determined by multiplying @c multiplier to the default line spacing and adding @c extra. @n + * + * @code + * The line spacing = (default line spacing) * multiplier + extra + * @endcode + * + * @since 2.0 + * + * @return An error code + * @param[in] multiplier The line spacing multiplier + * @param[in] extra The extra line spacing + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified line spacing value cannot be supported. + * @exception E_SYSTEM A system error has occurred. + * @see GetLineSpacing() + */ + result SetLineSpacing(int multiplier, int extra); + + // Text Alignment + /** + * Gets the horizontal text alignment. + * + * @since 2.0 + * + * @return The horizontal text alignment + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextAlignment() + */ + HorizontalAlignment GetTextAlignment(void) const; + + /** + * Sets the horizontal text alignment. + * + * @since 2.0 + * + * @return An error code + * @param[in] alignment The horizontal text alignment + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextAlignment() + */ + result SetTextAlignment(HorizontalAlignment alignment); + + // Text Size + /** + * Gets the text size of the %TextBox control. + * + * @since 2.0 + * + * @return The size of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextSize() + */ + int GetTextSize(void) const; + + /** + * Sets the text size. + * + * @since 2.0 + * + * @return An error code + * @param[in] size The text size + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c size cannot be a negative integer. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextSize() + */ + result SetTextSize(int size); + + // Text Font + /** + * @if OSPDEPREC + * Gets the font typeface name and the style mask of the %TextBox control. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this method, use the GetTextStyle() method. + * @since 2.0 + * + * @return An error code + * @param[out] typefaceName The name of the font typeface + * @param[out] style The text style (see TextBoxTextStyle) + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks Multiple styles can be combined using the bitwise OR operator. + * @see SetFontType() + * @see Tizen::Graphics::Font::GetSystemFontListN() + * @see TextBoxTextStyle + * @endif + */ + result GetFontType(Tizen::Base::String& typefaceName, unsigned long& style) const; + + /** + * Gets the text style mask of the %TextBox control. + * + * @since 2.0 + * + * @return A bitwise combination of Tizen::Ui::Controls::TextBoxTextStyle + * @see SetTextStyle() + * @see TextBoxTextStyle + */ + unsigned long GetTextStyle(void) const; + + /** + * @if OSPDEPREC + * Sets the font and the style mask of the %TextBox control. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this method, use the SetTextStyle() method. + * @since 2.0 + * + * @return An error code + * @param[in] typefaceName The name of the font typeface + * @param[in] style The text style @n + * Multiple styles can be combined using the bitwise OR operator(see TextBoxTextStyle). + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or the specified font typeface is not supported. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specified font typeface must be one of the system fonts. @n + * @c italic and @c bold cannot be applied at the same time. If the specified style mask contains both @c italic and @c bold, @c italic will + * be applied. + * @see GetFontType() + * @see Tizen::Graphics::Font::GetSystemFontListN() + * @see TextBoxTextStyle + * @endif + */ + result SetFontType(const Tizen::Base::String& typefaceName, unsigned long style); + + /** + * Sets the text style mask of the %TextBox control. + * + * @since 2.0 + * + * @return An error code + * @param[in] style The text style @n + * Multiple styles can be combined using the bitwise OR operator (see Tizen::Ui::Controls::TextBoxTextStyle). + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @see GetTextStyle() + * @see TextBoxTextStyle + */ + result SetTextStyle(unsigned long style); + + using Control::SetFont; + /** + * @if OSPDEPREC + * Sets the font to render the text. + * + * @brief [Deprecated] + * @deprecated This method is deprecated. Instead of using this method, use the SetFont(const String& fontName) method of superclass. + * @since 2.0 + * + * @return An error code + * @param[in] font The text font + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks All previously set text attributes (style, weight, decoration, and size) will be discarded. + * @endif + */ + result SetFont(const Tizen::Graphics::Font& font); + +// Text Block + /** + * Releases the selection of the current text block. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetBlockRange() + * @see SetBlockRange() + */ + result ReleaseBlock(void); + + /** + * Gets the start and the end index of the currently selected text block. + * + * @since 2.0 + * + * @return An error code + * @param[out] start The start index of the text block + * @param[out] end The end index of the text block + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The method returns @c start = 0 and @c end = 0 if there is no selected text block. + * @see ReleaseBlock() + * @see SetBlockRange() + */ + result GetBlockRange(int& start, int& end) const; + + /** + * Sets the specified block of the text. + * + * @since 2.0 + * + * @return An error code + * @param[in] start The start index of the text block + * @param[in] end The end index of the text block + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure. @n + * Either the @c start or @c end parameters are greater than the number of elements or less than @c 0. + * @exception E_SYSTEM A system error has occurred. + * @see ReleaseBlock() + * @see GetBlockRange() + */ + result SetBlockRange(int start, int end); + +// Appearances + /** + * Gets the color of the %TextBox control for the specified status. + * + * @since 2.0 + * + * @return The color of the %TextBox control, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] status The state of the %TextBox control + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetColor() + */ + Tizen::Graphics::Color GetColor(TextBoxStatus status) const; + + /** + * Gets the text color of the specified text color type. + * + * @since 2.0 + * + * @return The color, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] type The text color type + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextColor() + */ + Tizen::Graphics::Color GetTextColor(TextBoxTextColor type) const; + + /** + * Sets the background bitmap of the %TextBox control. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The state of the %TextBox control + * @param[in] bitmap The background bitmap + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see SetBackgroundColor() + */ + result SetBackgroundBitmap(TextBoxStatus status, const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the color of the %TextBox control for the specified status. + * + * @since 2.0 + * + * @return An error code + * @param[in] status The state of the %TextBox control + * @param[in] color The color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetColor() + */ + result SetColor(TextBoxStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the %TextBox control for the specified text type. + * + * @since 2.0 + * + * @return An error code + * @param[in] type The text color type + * @param[in] color The text color to be set + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see GetTextColor() + */ + result SetTextColor(TextBoxTextColor type, const Tizen::Graphics::Color& color); + + /** + * Adds a text block event listener. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks Programmatically modifying the text selection does not cause the text block selection event to fire. + * @see RemoveTextBlockEventListener() + */ + void AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + /** + * Removes the specified text block event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to be removed + * @see AddTextBlockEventListener() + */ + void RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + +protected: + friend class _TextBoxImpl; + +private: + TextBox(const TextBox& value); + TextBox& operator =(const TextBox& value); +}; //TextBox +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_TEXT_BOX_H_ diff --git a/inc/FUiCtrlTimePicker.h b/inc/FUiCtrlTimePicker.h new file mode 100644 index 0000000..646b49a --- /dev/null +++ b/inc/FUiCtrlTimePicker.h @@ -0,0 +1,331 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlTimePicker.h + * @brief This is the header file for the %TimePicker class. + * + * This header file contains the declarations of the %TimePicker class. + */ +#ifndef _FUI_CTRL_TIME_PICKER_H_ +#define _FUI_CTRL_TIME_PICKER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class TimePicker + * @brief This class displays a %TimePicker control on top of the screen. + * + * @since 2.0 + * + * The %TimePicker class displays a full screen window-based selector that allows the user to select a certain time. + * + * For more information on the class features, see DatePicker, TimePicker, and DateTimeimePicker. + * + * The following example demonstrates how to use the %TimePicker class. + * + * @code +// Sample Code for TimePickerSample.h +#include + +class TimePickerSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::ITimeChangeEventListener + , public Tizen::Ui::IActionEventListener +{ +public: + TimePickerSample(void) + : __pTimePicker(null){} + + bool Initialize(void); + void ShowTimePicker(bool show); + virtual result OnInitializing(void); + virtual result OnTerminating(void); + + // IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + // ITimeChangeEventListener + virtual void OnTimeChanged(const Tizen::Ui::Control& source, int hour, int minute); + virtual void OnTimeChangeCanceled(const Tizen::Ui::Control& source); + +private: + static const int ID_BUTTON = 101; + + Tizen::Ui::Controls::TimePicker* __pTimePicker; +}; + * @endcode + * + * @code +// Sample Code for TimePickerSample.cpp +#include + +#include "TimePickerSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +bool +TimePickerSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +TimePickerSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Createa an instance of Button + Button* pButton = new Button(); + pButton->Construct(Rectangle(50, 50, 300, 200), L"Show TimePicker"); + pButton->SetActionId(ID_BUTTON); + pButton->AddActionEventListener(*this); + + // Adda a Button to the Form + AddControl(*pButton); + + // Creates an instanceo of TimePicker + __pTimePicker = new TimePicker(); + __pTimePicker->Construct(); + + // Adds an instanceo of ITimeChangeEventListener + __pTimePicker->AddTimeChangeEventListener(*this); + + // Show TimePicker after it's owner Form is shown. + + return r; +} + +void +TimePickerSample::ShowTimePicker(bool show) +{ + // Change to desired show state + __pTimePicker->SetShowState(show); + + //Call Show() of the control + if (show) + { + __pTimePicker->Show(); + } + // Call Invalidate() of the container + else + { + Invalidate(true); + } +} + +result +TimePickerSample::OnTerminating(void) +{ + result r = E_SUCCESS; + + // Deallocates the time picker + delete __pTimePicker; + + return r; +} + +// IActionEventListener implementation +void +TimePickerSample::OnActionPerformed(const Control& source, int actionId) +{ + switch (actionId) + { + case ID_BUTTON: + ShowTimePicker(true); + break; + + default: + break; + } +} + + +// ITimeChangeEventListener implementation +void +TimePickerSample::OnTimeChanged(const Control& source, int hour, int minute) +{ + // Todo: +} + +void +TimePickerSample::OnTimeChangeCanceled(const Control& source) +{ + // Todo: +} + * @endcode + */ +class _OSP_EXPORT_ TimePicker + : public Tizen::Ui::Window +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + TimePicker(void); + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~TimePicker(void); + + /** + * Adds a time changed event listener instance. + * + * @since 2.0 + * + * @param[in] listener The listener to be added + * @see ITimeChangeEventListener::OnTimeChanged() + * @see ITimeChangeEventListener::OnTimeChangeCanceled() + * @see RemoveTimeChangeEventListener() + */ + void AddTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener); + + /** + * Removes a listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to be removed + * @see AddTimeChangeEventListener() + */ + void RemoveTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener); + + /** + * Initializes this instance of %TimePicker to the current date and time in wall time mode. + * + * @since 2.0 + * + * @return An error code + * @param[in] title The title + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(const Tizen::Base::String& title = L""); + + /** + * Gets the current hour value of the %TimePicker control. @n + * The hour value is between @c 0 to @c 23. + * + * @since 2.0 + * + * @return The current hour value, @n + * else @c -1 if an error occurs + */ + int GetHour(void) const; + + /** + * Gets the current minute value of the %TimePicker control. @n + * The minute value is between @c 0 to @c 59. + * + * @since 2.0 + * + * @return The current minute value, @n + * else @c -1 if an error occurs + */ + int GetMinute(void) const; + + /** + * Gets the current time value of the %TimePicker control. + * + * @since 2.0 + * + * @return The time value + */ + Tizen::Base::DateTime GetTime(void) const; + + /** + * Sets the 12H or 24H hour display type of the %TimePicker control. + * + * @since 2.0 + * + * @param[in] enable Set to @c true to enable the 24 hour notation, @n + * else @c false + */ + void Set24HourNotationEnabled(bool enable); + + /** + * Sets the hour value. @n + * The hour value should be between @c 0 and @c 23. + * + * @since 2.0 + * + * @param[in] hour The hour value + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c hour value is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetHour(int hour); + + /** + * Sets the minute value. @n + * The minute value should be between @c 0 and @c 59. + * + * @since 2.0 + * + * @param[in] minute The minute value + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c minute value is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetMinute(int minute); + + /** + * Sets the current time value of the %TimePicker control. + * + * @since 2.0 + * + * @param[in] time The time to be set + */ + void SetTime(const Tizen::Base::DateTime& time); + + /** + * Sets the time value of the %TimePicker control with the current system time in the Coordinated Universal Time (UTC) mode. + * + * @since 2.0 + */ + void SetCurrentTime(void); + +protected: + friend class _TimePickerImpl; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + TimePicker(const TimePicker& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + TimePicker& operator =(const TimePicker& rhs); + +}; // TimePicker + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_TIME_PICKER_H_ diff --git a/inc/FUiCustomControlBase.h b/inc/FUiCustomControlBase.h new file mode 100644 index 0000000..3be3449 --- /dev/null +++ b/inc/FUiCustomControlBase.h @@ -0,0 +1,248 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCustomControlBase.h + * @brief This is the header file for the %CustomControlBase class. + * + * This header file contains the declarations of the %CustomControlBase class and its helper classes. + */ + +#ifndef _FUI_CUSTOM_CONTROL_BASE_H_ +#define _FUI_CUSTOM_CONTROL_BASE_H_ + +#include + +namespace Tizen { namespace Ui +{ + +class _CustomControlBaseImpl; + +/** + * @if OSPDEPREC + * @class CustomControlBase + * @brief [Deprecated] This is the base class for the user-defined UI control classes. + * + * @deprecated This class is deprecated. Instead of using this class, use the Container class. + * @since 2.0 + * + * The %CustomControlBase class is the base class for the user-defined UI control classes. + * @n + * For more information on the class features, see CustomControlBase. + * @endif + */ +class _OSP_EXPORT_ CustomControlBase + : public Container +{ +// Lifecycle +public: + /** + * @if OSPDEPREC + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the Container class. + * @since 2.0 + * @endif + */ + virtual ~CustomControlBase(void); + + /** + * @if OSPDEPREC + * Notifies that the bounds of the control is about to change. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the Container class. + * @since 2.0 + * + * @return An error code + * @param[in] oldRect The old position and size values of the control + * @param[in] newRect The new position and size values of the control + * @remarks If the method returns an exception, the resulting exception + * is propagated and the control's size is unchanged. @n + * Provide control specific exceptions. + * @see Tizen::Ui::Control::SetBounds() + * @see Tizen::Ui::Control::SetSize() + * @endif + */ + virtual result PrepareBoundsChange(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect); + + /** + * @if OSPDEPREC + * Overrides this method to indicate that the specified @c width and @c height + * can be supported or a new @c width and @c height must be applied instead + * of the specified values. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the Container class. + * @since 2.0 + * + * @return A Boolean flag that indicates whether the specified @c width + * and @ height are supported + * @param[in, out] width The width that needs to evaluate + * @param[in, out] height The height that needs to evaluate + * @endif + */ + virtual bool EvaluateSize(int& width, int& height); + +protected: + /** + * @if OSPDEPREC + * The object is not fully constructed after this constructor is called. For full construction, one of the %Construct() method must be called right after calling this constructor. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the Container class. + * @since 2.0 + * @endif + */ + CustomControlBase(void); + + /** + * @if OSPDEPREC + * Initializes this instance of %CustomControlBase. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the Container class. + * @since 2.0 + * + * @return An error code + * @param[in] rect The rectangle bounds to set + * @param[in] resizable Set to @c true to make the control resizable, @n + * else @c false + * @param[in] movable Set to @c true to make the control movable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method must be called from the derived classes's construct methods. + * @remarks If the @c resizable is @c false, IsResizable() returns @c false. + * @see IsResizable() + * @endif + */ + result Construct(const Tizen::Graphics::Rectangle& rect, bool resizable = true, bool movable = true); + + /** + * @if OSPDEPREC + * Initializes this instance of %CustomControlBase with the specified layout and rectangular region. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the Container class. + * @since 2.0 + * + * @return An error code + * @param[in] layout The layout for both the portrait and landscape mode + * @param[in] rect The location and size of the %CustomControlBase + * @param[in] resizable Set to @c true to make the control resizable, @n + * else @c false + * @param[in] movable Set to @c true to make the control movable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method must be called from the derived classes's construct methods. + * @remarks If the @c resizable is @c false, IsResizable() returns @c false. + * @see IsResizable() + * @see Tizen::Ui::Layout + * @see Tizen::Ui::Container::GetLayoutN() + * @endif + */ + result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Rectangle& rect, bool resizable = true, bool movable = true); + + /** + * @if OSPDEPREC + * Initializes this instance of %CustomControlBase with the specified layouts and rectangular region. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the Container class. + * @since 2.0 + * + * @return An error code + * @param[in] portraitLayout The layout for the portrait mode + * @param[in] landscapeLayout The layout for the landscape mode + * @param[in] rect The location and size of the %CustomControlBase + * @param[in] resizable Set to @c true to make the control resizable, @n + * else @c false + * @param[in] movable Set to @c true to make the control movable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If the @c resizable is @c false, IsResizable() returns @c false. + * @see IsResizable() + * @see Tizen::Ui::Layout + * @see Tizen::Ui::Container::GetLayoutN() + * @see Tizen::Ui::Container::GetPortraitLayoutN() + * @see Tizen::Ui::Container::GetLandscapeLayoutN() + * @endif + */ + result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Rectangle& rect, bool resizable = true, bool movable = true); + +private: + /** + * @if OSPDEPREC + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the Container class. + * @since 2.0 + * @endif + */ + CustomControlBase(const CustomControlBase& rhs); + + /** + * @if OSPDEPREC + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the Container class. + * @since 2.0 + * @endif + */ + CustomControlBase& operator =(const CustomControlBase& rhs); + +protected: + friend class _CustomControlBaseImpl; + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void CustomControlBase_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void CustomControlBase_Reserved2(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void CustomControlBase_Reserved3(void) {} +}; // CustomControlBase + +}} // Tizen::Ui + +#endif // _FUI_CUSTOM_CONTROL_BASE_H_ + diff --git a/inc/FUiDataBindingContext.h b/inc/FUiDataBindingContext.h new file mode 100644 index 0000000..4f2f253 --- /dev/null +++ b/inc/FUiDataBindingContext.h @@ -0,0 +1,336 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiDataBindingContext.h + * @brief This is the header file for the %DataBindingContext class. + * + * This header file contains the declarations of the %DataBindingContext class. + */ + +#ifndef _FUI_DATA_BINDING_CONTEXT_H_ +#define _FUI_DATA_BINDING_CONTEXT_H_ + +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Base +{ +class String; +}} + +namespace Tizen { namespace Ui +{ + +class Control; +class _DataBindingContextImpl; + +/** + * @class DataBindingContext + * @brief This class represents a data binding context and the application's data source. + * + * @since 2.0 + * + * The %DataBindingContext class represents the data binding context. + * + * The following example demonstrates how to use the %DataBindingContext class. +.* + * @code +// Sample code for DataBindingSample.h +#include +#include + +class DataBindingSample + : public Tizen::Ui::Controls::Form + , public Osp::Ui::IActionEventListener +{ +public: + DataBindingSample(void); + virtual ~DataBindingSample(void); + + virtual bool Initialize(void); + virtual result OnInitializing(void); + virtual void OnActionPerformed(const Osp::Ui::Control& source, int actionId); + +private : + static const int ID_BUTTON_UNBIND = 402; + static const int ID_BUTTON_UPDATE_BINDING = 403; + static const int ID_BUTTON_BIND = 404; + + Osp::Base::Integer __bindIntegerToButtonText; + Osp::Ui::Controls::Button* __pUnbindButton; + Osp::Ui::Controls::Button* __pUpdateBindingButton; + Osp::Ui::Controls::Button* __pTargetButton; + Osp::Ui::Controls::Button* __pBindButton; +}; + + * @endcode + * + * @code + +// Sample code for DataBindingSample.cpp +#include "DataBindingSample.h" + +using namespace Tizen::App; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +bool +DataBindingSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL| FORM_STYLE_INDICATOR| FORM_STYLE_HEADER| FORM_STYLE_FOOTER); + SetFooter(); + return true; +} + +result +DataBindingSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + Header* pHeader = GetHeader(); + pHeader->SetTitleText(L"DataBinding"); + + Rectangle rect; + rect = GetClientAreaBounds(); + + __pUpdateBindingButton = new (std::nothrow) Button(); + __pUpdateBindingButton->Construct(Rectangle(10, rect.height / 6, rect.width - 20, rect.height / 6), L"BindingTarget"); + __pUpdateBindingButton->SetName("Target"); + AddControl(*__pUpdateBindingButton); + + __pTargetButton = new (std::nothrow) Button(); + __pTargetButton->Construct(Rectangle(10, (rect.height / 3) + 10 , (rect.width - 20), rect.height / 6), L"Update Binding"); + __pTargetButton->SetActionId(ID_BUTTON_UPDATE_BINDING); + __pTargetButton->AddActionEventListener(*this); + AddControl(*__pTargetButton); + + __pUnbindButton = new (std::nothrow) Button(); + __pUnbindButton->Construct(Rectangle(10, (rect.height * 2 / 3), (rect.width / 2) - 10, rect.height / 6), L"Unbind"); + __pUnbindButton->SetActionId(ID_BUTTON_UNBIND); + __pUnbindButton->AddActionEventListener(*this); + AddControl(*__pUnbindButton); + + __pBindButton = new (std::nothrow) Button(); + __pBindButton->Construct(Rectangle((rect.width / 2) + 10 , (rect.height * 2 / 3), (rect.width / 2) - 20 , rect.height / 6), L"Bind"); + __pBindButton->SetActionId(ID_BUTTON_BIND); + __pBindButton->AddActionEventListener(*this); + AddControl(*__pBindButton); + + DataBindingContext* pContext = GetDataBindingContextN(); + r = pContext->Bind(L"bindingcount", L"Target", L"text", __bindIntegerToButtonText, DATA_BINDING_DATA_TYPE_INTEGER, DATA_BINDING_FLOW_ONE_WAY, DATA_BINDING_TRIGGER_EXPLICIT, null, null, null); + delete pContext; + + return r; +} + +void +DataBindingSample::OnActionPerformed(const Control& source, int actionId) +{ + DataBindingContext* pContext = GetDataBindingContextN(); + result r = E_SUCCESS; + switch (actionId) + { + case ID_BUTTON_UNBIND: + { + pContext->Unbind(L"bindingcount"); + break; + } + case ID_BUTTON_BIND: + { + pContext->Bind(L"bindingcount", L"Target", L"text", __bindIntegerToButtonText, DATA_BINDING_DATA_TYPE_INTEGER, DATA_BINDING_FLOW_ONE_WAY, DATA_BINDING_TRIGGER_EXPLICIT, null, null, null); + break; + } + case ID_BUTTON_UPDATE_BINDING: + { + r = pContext->UpdateBinding(L"bindingcount", DATA_BINDING_DESTINATION_TYPE_TARGET); + if (r == E_SUCCESS) + { + __bindIntegerToButtonText = __bindIntegerToButtonText.ToInt() + 1; + } + break; + } + default: + break; + } + delete pContext; + Invalidate(true); +} + * @endcode + * + */ +class _OSP_EXPORT_ DataBindingContext + : public Tizen::Base::Object +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~DataBindingContext(void); + +public: + /** + * Gets the owner of this data binding context. + * + * @since 2.0 + * + * @return The context owner + */ + Control* GetContextOwner(void) const; + + /** + * Binds the specified control's property and data source. + * + * @since 2.0 + * + * @return An error code + * @param[in] bindingId The binding ID + * @param[in] controlName The name of target property owner + * @param[in] propertyName The target property name + * @param[in] dataSource The data binding source + * @param[in] sourceType The data type of the @c dataSource + * @param[in] flow The data flow type + * @param[in] trigger The data binding trigger type + * @param[in] pListener The data binding listener + * @param[in] pValidator The data validator + * @param[in] pTransformer The data transformer + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_ARG 1. sourceType is not of a supported type. + * 2. flow is not of a supported type. + * 3. trigger is not of a supported type. + * @exception E_OBJ_NOT_FOUND 1. The control named controlName does not exist. + * 2. The parameter "propertyName" is not found in control properties. + * @exception E_UNSUPPORTED_FORMAT The given transformer does not supported changing source type to target type. + * @exception E_UNSUPPORTED_OPERATION In this system, binding with the given trigger and flow is not supported. + * @remarks The propertyName parameter is defined in "UI Builder Guide". @n + * There is no duplication check for each binding ID. @n + * Please use a unique binding ID for each binding setting. + */ + result Bind(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName, Tizen::Base::Object& dataSource, DataBindingDataType sourceType, DataBindingFlow flow, DataBindingTrigger trigger, const IDataBindingListener* pListener, const IDataBindingDataValidator* pValidator, const IDataBindingDataTransformer* pTransformer = null); + + /** + * Sets the binding listener for the specified data binding. + * + * @since 2.0 + * + * @return An error code + * @param[in] bindingId The binding ID + * @param[in] pListener The data binding listener + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_OBJ_NOT_FOUND The given binding ID is not registered. + * @exception E_INVALID_ARG The given listener is not valid. + * @remarks If you give pListener parameter as 'null', the existing dataBindingEventListener will be removed. + */ + result SetDataBindingEventListener(const Tizen::Base::String& bindingId, IDataBindingListener* pListener); + + /** + * Unbinds all bindings that exist in this context. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result UnbindAll(void); + + /** + * Unbinds a binding that exists in this context. + * + * @since 2.0 + * + * @return An error code + * @param[in] bindingId The binding ID + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_OBJ_NOT_FOUND The given binding ID is not registered. + */ + result Unbind(const Tizen::Base::String& bindingId); + + /** + * Updates all 'explicit' data bindings. + * + * @since 2.0 + * + * @return An error code + * @param[in] destType The destination type + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_INVALID_ARG The specified @c destType is not of a supported type. + * @remarks If you have set a data binding listener, @n + * this function is returned after that listener is called. + * @see IDataBindingListener + */ + result UpdateAllBindings(DataBindingDestinationType destType); + + /** + * Updates the specified data binding. + * + * @since 2.0 + * + * @param[in] bindingId The binding ID + * @param[in] destType The destination type + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_OBJ_NOT_FOUND The given binding ID is not registered. + * @exception E_INVALID_OPERATION The given binding's trigger is not 'explicit' type. + * @exception E_INVALID_ARG The specified @c destType is not supported in binding ID. + * @remarks If you have set a data binding listener, @n + * this function is returned after that listener is called. + * @see IDataBindingListener + */ + result UpdateBinding(const Tizen::Base::String& bindingId, DataBindingDestinationType destType); + +private: + // + // This default constructor is intentionally declared as private so that only the platform can create an instance. + // + DataBindingContext(void); + + // + // This destructor is intentionally declared as private so that only the platform can delete an instance. + // + DataBindingContext(const Control& contextOwner); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + DataBindingContext(const DataBindingContext& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + DataBindingContext& operator =(const DataBindingContext& rhs); + +private: + _DataBindingContextImpl* __pDataBindingContextImpl; + + friend class _DataBindingContextImpl; + +}; // DataBindingContext + +} } // Tizen::Ui +#endif // _FUI_DATA_BINDING_CONTEXT_H_ diff --git a/inc/FUiDataBindingTypes.h b/inc/FUiDataBindingTypes.h new file mode 100644 index 0000000..2fb3bcb --- /dev/null +++ b/inc/FUiDataBindingTypes.h @@ -0,0 +1,92 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiDataBindingTypes.h + * @brief This is the header file for the data binding enumerations. + * + * This header file contains the declarations of the data binding enumerations. + */ + +#ifndef _FUI_DATA_BINDING_TYPES_H_ +#define _FUI_DATA_BINDING_TYPES_H_ + +namespace Tizen { namespace Ui +{ +/** + * @enum DataBindingFlow + * + * Defines the possible data flow types. + * + * @since 2.0 + */ +enum DataBindingFlow +{ + DATA_BINDING_FLOW_ONE_WAY = 0, /**< The data flow is one way from source to target */ + DATA_BINDING_FLOW_ONE_WAY_TO_SOURCE = 1, /**< The data flow is one way from target to source */ + DATA_BINDING_FLOW_TWO_WAY = 2 /**< The data flow is two way */ +}; + +/** + * @enum DataBindingTrigger + * + * Defines the possible data binding trigger types. + * + * @since 2.0 + */ +enum DataBindingTrigger +{ + DATA_BINDING_TRIGGER_IMMEDIATE = 0, /**< Immediate trigger */ + DATA_BINDING_TRIGGER_EXPLICIT = 1, /**< Explicit trigger */ +}; + +/** + * @enum DataBindingDataType + * + * Defines the possible data types for data binding source. + * + * @since 2.0 + */ +enum DataBindingDataType +{ + DATA_BINDING_DATA_TYPE_BOOLEAN = 0, /**< Boolean type */ + DATA_BINDING_DATA_TYPE_COLOR = 1, /**< Color type */ + DATA_BINDING_DATA_TYPE_DIMENSION = 2, /**< Dimension type */ + DATA_BINDING_DATA_TYPE_DOUBLE = 3, /**< Double type */ + DATA_BINDING_DATA_TYPE_FLOAT = 4, /**< Float type */ + DATA_BINDING_DATA_TYPE_INTEGER = 5, /**< Integer type */ + DATA_BINDING_DATA_TYPE_LONG = 6, /**< Long type */ + DATA_BINDING_DATA_TYPE_POINT = 7, /**< Point type */ + DATA_BINDING_DATA_TYPE_RECTANGLE = 8, /**< Rectangle type */ + DATA_BINDING_DATA_TYPE_STRING = 9 /**< String type */ +}; + +/** + * @enum DataBindingDestinationType + * + * Defines the possible destination types for explicit data bindings. + * + * @since 2.0 + */ +enum DataBindingDestinationType +{ + DATA_BINDING_DESTINATION_TYPE_SOURCE = 0, /**< Update source with latest data of associated target */ + DATA_BINDING_DESTINATION_TYPE_TARGET = 1 /**< Update target with latest data of associated source */ +}; + +}}// Tizen::Ui +#endif // _FUI_DATA_BINDING_TYPES_H_ diff --git a/inc/FUiEffects.h b/inc/FUiEffects.h new file mode 100644 index 0000000..345b69d --- /dev/null +++ b/inc/FUiEffects.h @@ -0,0 +1,60 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects.h + * @brief This is the header file for the %Effects namespace. + * + * This header file contains the declarations and descriptions of the %Effects namespace. + */ +#ifndef _FUI_EFFECTS_H_ +#define _FUI_EFFECTS_H_ + +#include "FUiEffectsEffect.h" +#include "FUiEffectsEffectManager.h" +#include "FUiEffectsIEffectEventListener.h" +#include "FUiEffectsIEffectResourceProvider.h" +#include "FUiEffectsTypes.h" + +namespace Tizen +{ +namespace Ui +{ + +/** + * @namespace Tizen::Ui::Effects + * @brief This namespace contains the classes and interfaces for the effect-related functionalities. + * @since 2.0 + * + * @remarks @b Header @b %file: @b \#include @b @n + * @b Library : @b osp-uifw + * + * The %Effects namespace provides effect capabilities. + * + * For more information on the %Effects namespace features, see Effects Guide. + * + * The following diagram illustrates the relationships between the classes belonging to the %Effects namespace. + * + * @image html effects_namespace_classdiagram.png + * + */ + +namespace Effects +{ +}}} // Tizen::Ui::Effects + +#endif //_FUI_EFFECTS_H_ + diff --git a/inc/FUiEffectsEffect.h b/inc/FUiEffectsEffect.h new file mode 100644 index 0000000..322cc2d --- /dev/null +++ b/inc/FUiEffectsEffect.h @@ -0,0 +1,377 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiEffectsEffect.h +* @brief This is the header file for the %Effect class. +* +* This header file contains the declarations of the %Effect class. +*/ + +#ifndef _FUI_EFFECTS_EFFECT_H_ +#define _FUI_EFFECTS_EFFECT_H_ + +#include +#include + + +namespace Tizen { namespace Base { +class String; +}} // Tizen::Base + +namespace Tizen { namespace Ui { +class TouchEventInfo; +class Control; +}} // Tizen::Ui + +namespace Tizen { namespace Graphics { +class Bitmap; +class Point; +}} // Tizen::Graphics + +namespace Tizen { namespace Base { namespace Collection { +class IList; +}}} // Tizen::Base::Collection + +namespace Tizen { namespace Ui { namespace Effects +{ +class IEffectEventListener; +class IEffectResourceProvider; +class _EffectImpl; + +/** +* @class Effect +* @brief This class contains API for managing effects. +* +* @since 2.0 +* +* The %Effect class contains API for managing effects. +*/ +class _OSP_EXPORT_ Effect + : public Tizen::Base::Object +{ +public: + /** + * Binds the effect to Tizen::UI::Control for rendering effect. + * + * @since 2.0 + * + * @return An error code + * @param [in] pControl Tizen::UI::Control whose content is filled by the effect + * @exception E_SUCCESS The specified effect is bound with @c control successfully. + * @exception E_OPERATION_FAILED The system has failed to initialize the 3D system. + * @exception E_IN_PROGRESS The specified effect is running now, setting, changing or resetting render target is impossible + */ + result SetRenderTarget(Tizen::Ui::Control* pControl); + + /** + * Starts the effect. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The specified effect is started successfully. + * @exception E_INVALID_STATE The specified effect has already started. + * @exception E_OPERATION_FAILED The specified effect has a runtime error in the script. + * @exception E_ALREADY_SET Other effects which use the same control as a render target are currently running. + */ + result Start(void); + + /** + * Starts the effect. + * + * @since 2.0 + * + * @return An error code + * @param [in] effectStartInfo A list of input arguments to be passed to the OnEffectStarted() method of the scripts @n + * All arguments must be represented in @c float data type. + * @exception E_SUCCESS The specified effect is started successfully. + * @exception E_INVALID_STATE The specified effect has already started. + * @exception E_OPERATION_FAILED The specified effect has a runtime error in the script. + * @exception E_ALREADY_SET Other effects which use the same control as a render target are currently running. + */ + result Start(const Tizen::Base::Collection::IList& effectStartInfo); + + /** + * Stops the effect. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The specified effect is stopped successfully. + * @exception E_INVALID_STATE The specified effect has not started as yet. + */ + result Stop(void); + + /** + * Informs the effect of a TouchPress event. + * + * @since 2.0 + * + * @return An error code + * @param [in] touchEventInfo The touch event information + * @param [in] offset The effect will regard the touch position in @c touchEventInfo translated by @c offset + * @exception E_SUCCESS The specified effect is successfully sent with a TouchPress event. + * @exception E_INVALID_STATE The specified effect has not started as yet. + * @exception E_OPERATION_FAILED There is a runtime error in the OnTouchPressed() script method or the effect is time-based. + */ + result FeedTouchPressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Tizen::Graphics::Point& offset); + + /** + * Informs the effect of a TouchPress event. + * + * @since 2.0 + * + * @return An error code + * @param [in] touchEventInfo The touch event information + * @exception E_SUCCESS The specified effect is successfully sent with a TouchPress event. + * @exception E_INVALID_STATE The specified effect has not started as yet. + * @exception E_OPERATION_FAILED There is a runtime error in the OnTouchPressed() script method or the effect is time-based. + */ + result FeedTouchPressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo); + + /** + * Informs the effect of a TouchMove event. + * + * @since 2.0 + * + * @return An error code + * @param [in] touchEventInfo The touch event information + * @param [in] offset The effect will regard the touch position in @c touchEventInfo translated by @c offset + * @exception E_SUCCESS The specified effect is successfully sent with a TouchMove event. + * @exception E_INVALID_STATE The specified effect has not started as yet. + * @exception E_OPERATION_FAILED There is a runtime error in the OnTouchMoved() script method or the effect is time-based. + */ + result FeedTouchMoveEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Tizen::Graphics::Point& offset); + + /** + * Informs the effect of a TouchMove event. + * + * @since 2.0 + * + * @return An error code + * @param [in] touchEventInfo The touch event information + * @exception E_SUCCESS The specified effect is successfully sent with a TouchMove event. + * @exception E_INVALID_STATE The specified effect has not started as yet. + * @exception E_OPERATION_FAILED There is a runtime error in the OnTouchMoved() script method or the effect is time-based. + */ + result FeedTouchMoveEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo); + + /** + * Informs the effect of a TouchRelease event. + * + * @since 2.0 + * + * @return An error code + * @param [in] touchEventInfo The touch event information + * @param [in] offset The effect will regard the touch position in @c touchEventInfo translated by @c offset + * @exception E_SUCCESS The specified effect is successfully sent with a TouchRelease event. + * @exception E_INVALID_STATE The specified effect has not started as yet. + * @exception E_OPERATION_FAILED There is a runtime error in the OnTouchReleased() script method or the effect is time-based. + */ + result FeedTouchReleaseEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Tizen::Graphics::Point& offset); + + /** + * Informs the effect of a TouchRelease event. + * + * @since 2.0 + * + * @return An error code + * @param [in] touchEventInfo The touch event information + * @exception E_SUCCESS The specified effect is successfully sent with a TouchRelease event. + * @exception E_INVALID_STATE The specified effect has not started as yet. + * @exception E_OPERATION_FAILED There is a runtime error in the OnTouchReleased() script method or the effect is time-based. + */ + result FeedTouchReleaseEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo); + + /** + * Informs the effect of a TouchDoublePress event. + * + * @since 2.0 + * + * @return An error code + * @param [in] touchEventInfo The touch event information + * @param [in] offset The effect will regard the touch position in @c touchEventInfo translated by @c offset + * @exception E_SUCCESS The specified effect is successfully sent with a TouchDoublePress event. + * @exception E_INVALID_STATE The specified effect has not started as yet. + * @exception E_OPERATION_FAILED There is a runtime error in the OnTouchDoublePressed() script method or the effect is time-based. + */ + result FeedTouchDoublePressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Tizen::Graphics::Point& offset); + + /** + * Informs the effect of a TouchDoublePress event. + * + * @since 2.0 + * + * @return An error code + * @param [in] touchEventInfo The touch event information + * @exception E_SUCCESS The specified effect is successfully sent with a TouchDoublePress event. + * @exception E_INVALID_STATE The specified effect has not started as yet. + * @exception E_OPERATION_FAILED There is a runtime error in the OnTouchDoublePressed() script method or the effect is time-based. + */ + result FeedTouchDoublePressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo); + + /** + * Sets the effect's bitmap that is used as a graphical surface in scripts. + * + * @since 2.0 + * + * @return An error code + * @param [in] bitmapId The bitmap ID to be updated + * @param [in] bitmap The bitmap content + * @exception E_SUCCESS The bitmap is updated successfully. + * @exception E_OPERATION_FAILED Updating the bitmap contents has failed. + */ + result SetBitmap(long bitmapId, const Tizen::Graphics::Bitmap& bitmap); + + /** + * Checks whether the effect is running. + * + * @since 2.0 + * + * @return @c true if the effect is running, @n + * else @c false + */ + bool IsRunning(void) const; + + /** + * Gets the effect type. + * + * @since 2.0 + * + * @return The type of effect + */ + EffectType GetType(void) const; + + /** + * Gets the name of the effect. + * + * @since 2.0 + * + * @return The name of the effect. + */ + Tizen::Base::String GetName(void) const; + + /** + * Sets the IEffectsEventListener instance to get notified when the state of the effect is changed. + * + * @since 2.0 + * + * @param [in] pListener The event listener to be set @n + * If @c pListener is @c null, the status changes of this instance are not notified anymore. + * @see GetEffectEventListener + */ + void SetEffectEventListener(IEffectEventListener* pListener); + + /** + * Gets the IEffectsEventListener instance that is registered to the instance. + * + * @since 2.0 + * + * @return The event listener + * + * @see SetEffectEventListener + */ + IEffectEventListener* GetEffectEventListener(void) const; + + /** + * Sets the IEffectsResourceProvider instance to get notified when resources are needed by the effect. + * + * @since 2.0 + * + * @param [in] pProvider The resource provider to provide the effect with bitmap resources @n + * If @c pProvider is @c null, this instance will not display effects correctly. + * + * @see GetResourceProvider + */ + void SetResourceProvider(IEffectResourceProvider* pProvider); + + /** + * Gets the IEffectsResourceProvider instance that is registered to the instance. + * + * @since 2.0 + * + * @return The resource provider + * + * @see SetResourceProvider + */ + IEffectResourceProvider* GetResourceProvider(void) const; + +protected: + /** + * This default constructor is intentionally declared as protected so that only the platform can create an instance. + * + * @since 2.0 + */ + Effect(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~Effect(void); + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void Effect_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void Effect_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void Effect_Reserved3(void) {} + +private: + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + Effect(const Effect& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + Effect& operator=(const Effect& rhs); + +private: + friend class _EffectManagerImpl; + friend class _EffectImpl; + _EffectImpl* __pEffectImpl; +}; //Effect + +}}} // Tizen::Ui::Effects + +#endif // _FUI_EFFECTS_EFFECT_H_ + diff --git a/inc/FUiEffectsEffectManager.h b/inc/FUiEffectsEffectManager.h new file mode 100644 index 0000000..9565c2d --- /dev/null +++ b/inc/FUiEffectsEffectManager.h @@ -0,0 +1,154 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiEffectsEffectManager.h +* @brief This is the header file for the %EffectManager class. +* +* This header file contains the declarations of the %EffectManager class. +*/ + +#ifndef _FUI_EFFECTS_EFFECT_MANAGER_H_ +#define _FUI_EFFECTS_EFFECT_MANAGER_H_ + +#include +#include + + +namespace Tizen { namespace Base { +class String; +}} // Tizen::Base + + +namespace Tizen { namespace Ui { namespace Effects +{ + +class _EffectManagerImpl; +class Effect; + +/** + * @class EffectManager + * @brief This class contains API for managing effects. + * + * @since 2.0 + * + * The %EffectManager class contains API for managing effects. + */ +class _OSP_EXPORT_ EffectManager + : public Tizen::Base::Object +{ +public: + /** + * Gets the effect manager instance. + * + * @since 2.0 + * + * @return A pointer to the %EffectManager instance + * @exception E_SUCCESS The %EffectManager instance is constructed successfully. + * @exception E_OPERATION_FAILED The system has failed to initialize the 3D system. + */ + static EffectManager* GetInstance(void); + + /** + * Destroys all previously created effects and their resources. @n + * Application can use OpenGL APIs only after invoking this method. + * + * @since 2.0 + */ + static void DestroyInstance(void); + + /** + * Creates a new effect from the specified effect file. + * + * @since 2.0 + * + * @return A pointer to the Effect instance, @n + * else @c null if an error occurs + * @param [in] filePath The file path of the effect + * @exception E_SUCCESS The effect is created successfully. + * @exception E_FILE_NOT_FOUND The specified effect file does not exist. + * @exception E_PARSING_FAILED A syntax error exists in the effect file. + * @remarks The DestroyEffect() method must be used to destroy the Effect instance returned. + * @see DestroyEffect() + */ + Effect* CreateEffect(const Tizen::Base::String& filePath); + + /** + * Destroys the Effect instance. + * + * @since 2.0 + * + * @param [in] effect The Effect instance to be destroyed + * @see CreateEffect() + */ + void DestroyEffect(Effect& effect); + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void EffectManager_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void EffectManager_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void EffectManager_Reserved3(void) {} + +private: + // This default constructor is intentionally declared as private to implement the Singleton semantic. + EffectManager(void); + + // This destructor is intentionally declared as private to implement the Singleton semantic. + virtual ~EffectManager(void); + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + EffectManager(const EffectManager& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + EffectManager& operator=(const EffectManager& rhs); + +private: + friend class _EffectManagerImpl; + _EffectManagerImpl* __pEffectManagerImpl; +}; //EffectManager + +}}} // Tizen::Ui::Effects + +#endif // _FUI_EFFECTS_EFFECT_MANAGER_H_ + diff --git a/inc/FUiEffectsIEffectEventListener.h b/inc/FUiEffectsIEffectEventListener.h new file mode 100644 index 0000000..e55c1c1 --- /dev/null +++ b/inc/FUiEffectsIEffectEventListener.h @@ -0,0 +1,141 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffectsIEffectEventListener.h + * @brief This is the header file for the %IEffectEventListener interface. + * + * This header file contains the declarations of the %IEffectEventListener interface. + */ + +#ifndef _FUI_EFFECTS_IEFFECT_LISTENER_H_ +#define _FUI_EFFECTS_IEFFECT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +}}} // Tizen::Base::Collection + +namespace Tizen { namespace Ui { namespace Effects +{ + +class Effect; + +/** + * @interface IEffectEventListener + * @brief This interface provides listeners for the effects. + * + * @since 2.0 + * + * This interface provides methods for notifying applications about the state change of the effects. + */ +class _OSP_EXPORT_ IEffectEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IEffectEventListener(void) {} + + /** + * Called when the effect starts. + * + * @since 2.0 + * + * @param [in] effect The effect to be started. + */ + virtual void OnEffectStarted(Effect& effect) = 0; + + /** + * Called when the effect finishes. + * + * @since 2.0 + * + * @param [in] effect The effect that is finished + * @param [in] effectResult The result of the effect + * @param [in] lastShownBitmapIds A list of last shown bitmaps @n + The listener will be notified with the bitmaps shown at the last frame. + * The item type of @c lastShownBitmapIds is Tizen::Base::Long. + */ + virtual void OnEffectFinished(Effect& effect, Tizen::Ui::Effects::EffectResult effectResult, const Tizen::Base::Collection::IList& lastShownBitmapIds) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IEffectEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IEffectEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IEffectEventListener_Reserved3(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IEffectEventListener_Reserved4(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IEffectEventListener_Reserved5(void) {} +}; // IEffectEventListener + +}}} // Tizen::Ui::Effects + +#endif // _FUI_EFFECTS_IEFFECT_LISTENER_H_ + diff --git a/inc/FUiEffectsIEffectResourceProvider.h b/inc/FUiEffectsIEffectResourceProvider.h new file mode 100644 index 0000000..cc57332 --- /dev/null +++ b/inc/FUiEffectsIEffectResourceProvider.h @@ -0,0 +1,124 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffectsIEffectResourceProvider.h + * @brief This is the header file for the %IEffectResourceProvider interface. + * + * This header file contains the declarations of the %IEffectResourceProvider interface. + */ + +#ifndef _FUI_EFFECTS_IEFFECT_RESOURCE_PROVIDER_H_ +#define _FUI_EFFECTS_IEFFECT_RESOURCE_PROVIDER_H_ + +namespace Tizen { namespace Ui { namespace Effects +{ + +class Effect; + +/** + * @interface IEffectResourceProvider + * @brief This interface implements the listener for events on Effect to provide the effects with resources. + * + * @since 2.0 + * + * The %IEffectResourceProvider interface provides methods for notifying applications about the resources needed by the effects. + * Applications have to provide the effects with appropriate resources. + */ +class _OSP_EXPORT_ IEffectResourceProvider +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IEffectResourceProvider(void) { } + + /** + * Called when the effect requires an image that is specified by its ID. + * + * @since 2.0 + * + * @return An error code + * @param [in,out] effect The effect that needs a bitmap. + * @param [in] bitmapId The bitmap ID needed. + * @remarks In general, EffectManager::SetBitmap should be used to provide this instance with a bitmap in this callback. + * @see Effect::SetBitmap() + */ + virtual result SetBitmap(Effect& effect, long bitmapId) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IEffectResourceProvider_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IEffectResourceProvider_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IEffectResourceProvider_Reserved3(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IEffectResourceProvider_Reserved4(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IEffectResourceProvider_Reserved5(void) {} +}; // IEffectResourceProvider + +}}} // Tizen::Ui::Effects + +#endif // _FUI_EFFECTS_IEFFECT_RESOURCE_PROVIDER_H_ + diff --git a/inc/FUiEffectsTypes.h b/inc/FUiEffectsTypes.h new file mode 100644 index 0000000..a12a62f --- /dev/null +++ b/inc/FUiEffectsTypes.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffectsTypes.h + * @brief This is the header for the effect-related types. + * + * This header file contains the declarations of the effect-related types. + */ +#ifndef _FUI_EFFECTS_TYPES_H_ +#define _FUI_EFFECTS_TYPES_H_ + +namespace Tizen { namespace Ui { namespace Effects +{ +/** + * @enum EffectType + * + * Defines the types of effects. + * + * @since 2.0 + */ +enum EffectType +{ + EFFECT_TYPE_TIME_BASED, /**< The effect model is not managed by user, that is, at the start of the effect @n + the final results and duration are known @n + For example, pressing the button leads to new form appearance with animation. */ + + EFFECT_TYPE_INTERACTIVE /**< The effect model is managed by user, that is, at the start of the effect it is @n + unknown when and how it will be finished */ +}; + + +/** + * @enum EffectResult + * + * Defines the result of effects. + * + * @since 2.0 + */ +enum EffectResult +{ + EFFECT_RESULT_INTERRUPTED = 1, /**< The effect is interrupted (stopped) with EffectsManager::StopEffect() */ + EFFECT_RESULT_FINISHED, /**< The effect is finished normally */ + EFFECT_RESULT_ERROR /**< There is an error during the execution of the effect */ +}; + +}}} // Tizen::Ui::Effects + +#endif // _FUI_EFFECTS_TYPES_H_ + diff --git a/inc/FUiFocusManager.h b/inc/FUiFocusManager.h new file mode 100644 index 0000000..1a9fa2a --- /dev/null +++ b/inc/FUiFocusManager.h @@ -0,0 +1,102 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiFocusManager.h + * @brief This is the header file for the %FocusManager class. + * + * This header file contains the declarations of the %FocusManager class. + */ + +#ifndef _FUI_FOCUS_MANAGER_H_ +#define _FUI_FOCUS_MANAGER_H_ + +#include + +namespace Tizen { namespace Ui +{ + +class Control; +class Window; + + +/** + * @class FocusManager + * @brief This class manages the current focus of the application owned by the UI control and its ancestor Window. + * + * @since 2.0 + * + * The %FocusManager class is used to query the application's current focus owner. + */ +class _OSP_EXPORT_ FocusManager + : public Tizen::Base::Object +{ +public: + /** + * Gets the pointer to the current focus manager. + * + * @since 2.0 + * + * @return The current focus manager instance + */ + static FocusManager* GetInstance(void); + + /** + * Gets the current focus owner. + * + * @since 2.0 + * + * @return The current focus owner + * @remarks The method returns the current focus owner of this application. + */ + Control* GetCurrentFocusOwner(void) const; + + /** + * Gets the current focused Window. + * + * @since 2.0 + * + * @return The current focused Window + * @remarks The method returns the application's current focus owner's ancestor Window or the %Window that is currently focused. + */ + Window* GetCurrentFocusedWindow(void) const; + +private: + // + // This default constructor is intentionally declared as private so that only the platform can create an instance. + // + FocusManager(void); + + // + // This destructor is intentionally declared as private so that only the platform can delete an instance. + // + virtual ~FocusManager(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + FocusManager(const FocusManager& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + FocusManager& operator=(const FocusManager& rhs); +}; // FocusManager + +}} // Tizen::Ui + +#endif // _FUI_FOCUS_MANAGER_H_ diff --git a/inc/FUiGridLayout.h b/inc/FUiGridLayout.h new file mode 100755 index 0000000..c6ee3ff --- /dev/null +++ b/inc/FUiGridLayout.h @@ -0,0 +1,460 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiGridLayout.h + * @brief This is the header file for the %GridLayout class. + * + * This header file contains the declarations of the %GridLayout class. + */ + +#ifndef _FUI_GRID_LAYOUT_H_ +#define _FUI_GRID_LAYOUT_H_ + +#include + +namespace Tizen { namespace Ui +{ +class Control; + +/** + * @class GridLayout + * @brief The grid layout positions the children of a container in a rectangular grid. + * + * @since 2.0 + * + * The %GridLayout class defines the grid layout for a Container. The layout positions the children of the %Container in a rectangular grid. + * @n + * For more information on the class features, see Grid Layout. + * + * @code +// Sample code for GridLayoutSample.h +#include + +class GridLayoutSample + : public Tizen::Ui::Controls::Form +{ +public: + bool Initialize(void); + virtual result OnInitializing(void); +}; + * @endcode + * + * @code +// Sample code for GridLayoutSample.cpp +#include + +#include "GridLayoutSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +bool +GridLayoutSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +GridLayoutSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of GridLayout + GridLayout gridPanelLayout; + gridPanelLayout.Construct(2, 3); + + // Creates an instance of Panel and applies it to grid layout + Panel* pPanel = new Panel(); + pPanel->Construct(gridPanelLayout, Rectangle((GetClientAreaBounds().width - 440)/2, (GetClientAreaBounds().height - 700)/2, 440, 700)); + { + // Creates instances of Label and an instanceo of Button + Label* pLabel1 = new Label(); + pLabel1->Construct(Rectangle(0, 0, 100, 200), L"Label1\n(0, 0)"); + pLabel1->SetBackgroundColor(Color(0x00, 0x10, 0x80, 0xFF)); + pPanel->AddControl(*pLabel1); + + Label* pLabel2 = new Label(); + pLabel2->Construct(Rectangle(0, 0, 100, 200), L"Label2\n(0, 1)"); + pLabel2->SetBackgroundColor(Color(0x00, 0x20, 0xA0, 0xFF)); + pPanel->AddControl(*pLabel2); + + Label* pLabel3 = new Label(); + pLabel3->Construct(Rectangle(0, 0, 100, 200), L"Label3\n(0, 2)"); + pLabel3->SetBackgroundColor(Color(0x00, 0x30, 0xC0, 0xFF)); + pPanel->AddControl(*pLabel3); + + Label* pLabel4 = new Label(); + pLabel4->Construct(Rectangle(0, 0, 100, 200), L"Label4\n(1, 0)"); + pLabel4->SetBackgroundColor(Color(0x00, 0x40, 0xE0, 0xFF)); + pPanel->AddControl(*pLabel4); + + Button* pButton = new Button(); + pButton->Construct(Rectangle(0, 0, 100, 200), L"Button\n(1, 1)"); + pPanel->AddControl(*pButton); + + // Sets position to each label and button in grid layout + gridPanelLayout.SetPosition(*pLabel1, 0, 0, 1, 1); + gridPanelLayout.SetPosition(*pLabel2, 0, 1, 1, 1); + gridPanelLayout.SetPosition(*pLabel3, 0, 2, 1, 1); + gridPanelLayout.SetPosition(*pLabel4, 1, 0, 1, 1); + gridPanelLayout.SetPosition(*pButton, 1, 1, 1, 2); + + // Sets stretchability each label and button in grid layout + gridPanelLayout.SetColumnStretchable(0, true); + gridPanelLayout.SetColumnStretchable(1, true); + gridPanelLayout.SetColumnStretchable(2, true); + gridPanelLayout.SetRowStretchable(1, true); + + // Sets spacing + gridPanelLayout.SetColumnSpacing(1, 10); + gridPanelLayout.SetRowSpacing(1, 10); + } + + // Adds the top panel to the form + AddControl(*pPanel); + + return r; +} + * @endcode + * + */ + +class _OSP_EXPORT_ GridLayout + : public Layout +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + * + * @remarks After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance. + */ + GridLayout(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~GridLayout(void); + + /** + * Initializes this instance of %GridLayout with the specified parameters. + * + * @since 2.0 + * + * @return An error code + * @param[in] rowCount The number of rows + * @param[in] columnCount The number of columns + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified index is out of range. @n + * Either @c rowCount or @c columnCount is @c 0 or negative. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(int rowCount, int columnCount); + + /** + * Gets the type of the layout. + * + * @since 2.0 + * + * @return The layout type + */ + virtual LayoutType GetLayoutType(void) const; + + /** + * Gets the number of rows in a grid layout. + * + * @since 2.0 + * + * @return The number of rows + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetRowCount(void) const; + + /** + * Gets the number of columns in a grid layout. + * + * @since 2.0 + * + * @return The number of columns + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetColumnCount(void) const; + + /** + * Sets the stretching ability of the specified column. + * + * @since 2.0 + * + * @return An error code + * @param[in] columnIndex The column index + * @param[in] stretchable Set to @c true to make the column stretchable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result SetColumnStretchable(int columnIndex, bool stretchable); + + /** + * Sets the shrinking ability of the specified column. + * + * @since 2.0 + * + * @return An error code + * @param[in] columnIndex The column index + * @param[in] shrinkable Set to @c true to make the column shrinkable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result SetColumnShrinkable(int columnIndex, bool shrinkable); + + /** + * Sets the collapsibility of a column. + * + * @since 2.0 + * + * @return An error code + * @param[in] columnIndex The column index + * @param[in] collapsed Set to @c true to make the column collapsible, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result SetColumnCollapsed(int columnIndex, bool collapsed); + + /** + * Sets the stretching ability of all the columns. + * + * @since 2.0 + * + * @return An error code + * @param[in] stretchable Set to @c true to set all columns as stretchable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetAllColumnsStretchable(bool stretchable); + + /** + * Sets the shrinking ability of all the columns. + * + * @since 2.0 + * + * @return An error code + * @param[in] shrinkable Set to @c true to set all columns as shrinkable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetAllColumnsShrinkable(bool shrinkable); + + /** + * Sets the space before the specified column index. + * + * @since 2.0 + * + * @return An error code + * @param[in] columnIndex The column index + * @param[in] space An @c int representing the space + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The specified index is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method does not perform any operation if the value of @c columnIndex is 0. + * @remarks The column spacing cannot be applied to the first column. + */ + result SetColumnSpacing(int columnIndex, int space); + + /** + * Sets the stretching ability of the specified row. + * + * @since 2.0 + * + * @return An error code + * @param[in] rowIndex The row index + * @param[in] stretchable Set to @c true to make the row stretchable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result SetRowStretchable(int rowIndex, bool stretchable); + + /** + * Sets the shrinking ability of the specified row. + * + * @since 2.0 + * + * @return An error code + * @param[in] rowIndex The row index + * @param[in] shrinkable Set to @c true to make the row shrinkable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result SetRowShrinkable(int rowIndex, bool shrinkable); + + /** + * Sets the collapsibility of the specified row. + * + * @since 2.0 + * + * @return An error code + * @param[in] rowIndex The row index + * @param[in] collapsed Set to @c true to make the row as collapsible, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_RANGE The specified index is out of range. + * @exception E_SYSTEM A system error has occurred. + */ + result SetRowCollapsed(int rowIndex, bool collapsed); + + /** + * Sets the stretching ability of all the rows. + * + * @since 2.0 + * + * @return An error code + * @param[in] stretchable Set to @c true to set all the rows as stretchable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetAllRowsStretchable(bool stretchable); + + /** + * Sets the shrinking ability of all the rows. + * + * @since 2.0 + * + * @return An error code + * @param[in] shrinkable Set to @c true to set all the rows as shrinkable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result SetAllRowsShrinkable(bool shrinkable); + + /** + * Sets the space before the specified column index. + * + * @since 2.0 + * + * @return An error code + * @param[in] rowIndex The row index + * @param[in] space An @c int representing the space + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OUT_OF_RANGE The specified index is out of range. + * @exception E_SYSTEM A system error has occurred. + * @remarks This method does not perform any operation if the value of @c rowIndex is @c 0. + * @remarks The row spacing cannot be applied to the first column. + */ + result SetRowSpacing(int rowIndex, int space); + + /** + * Sets the position and span of the control. @n + * Adds the control at the specified position. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the position is set + * @param[in] rowStartIndex The row index + * @param[in] columnStartIndex The column index + * @param[in] rowSpan The row span specifies the total number of cells in a row that are to be merged into a cell + * @param[in] columnSpan The column span specifies the total number of cells in a column that are to be merged into a cell + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG Either of the following conditions has occurred: @n + * - A specified input parameter is invalid. @n + * - Either @c rowSpan or @c columnSpan is @c 0 or negative. @n + * - The specified @c childControl parameter is not a child of the container that owns the layout. @n + * - The specified span has tried to include a cell, which is already included in another span. + * @exception E_OUT_OF_RANGE The specified index is out of range, or @n + * the calculated range of the cell is out of the grid. + * @exception E_SYSTEM A system error has occurred. + */ + result SetPosition(Control& childControl, int rowStartIndex, int columnStartIndex, int rowSpan, int columnSpan); + + /** + * Sets the horizontal alignment and the vertical alignment. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the alignment is set + * @param[in] horizontalAlignment The horizontal alignment + * @param[in] verticalAlignment The vertical alignment + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the value of @c horizontalAlignment is HORIZONTAL_ALIGN_LEFT and the value of @c verticalAlignment is + * VERTICAL_ALIGN_TOP. + * The column width is set to the largest width amongst controls in the column, and the row height is set to the largest + * height amongst controls in the row. + * Therefore, the smaller controls have vertical or horizontal margins around them, and they are repositioned in cells + * according to the alignment options. + */ + result SetAlignment(Control& childControl, LayoutHorizontalAlignment horizontalAlignment, LayoutVerticalAlignment verticalAlignment); + + /** + * Sets the margins of the specified control. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the margins are set + * @param[in] left The left margin + * @param[in] right The right margin + * @param[in] top The top margin + * @param[in] bottom The bottom margin + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the margins are set to @c 0. + */ + result SetMargin(Control& childControl, int left, int right, int top, int bottom); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + GridLayout(const GridLayout& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + GridLayout& operator =(const GridLayout& rhs); +}; // GridLayout + +}} // Tizen::Ui + +#endif // _FUI_GRID_LAYOUT_H_ diff --git a/inc/FUiHorizontalBoxLayout.h b/inc/FUiHorizontalBoxLayout.h new file mode 100755 index 0000000..275b2c1 --- /dev/null +++ b/inc/FUiHorizontalBoxLayout.h @@ -0,0 +1,361 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiHorizontalBoxLayout.h + * @brief This is the header file for the %HorizontalBoxLayout class. + * + * This header file contains the declarations of the %HorizontalBoxLayout class. + */ + +#ifndef _FUI_HORIZONTAL_BOX_LAYOUT_H_ +#define _FUI_HORIZONTAL_BOX_LAYOUT_H_ + +#include + +namespace Tizen { namespace Ui +{ +class Control; + +/** + * @class HorizontalBoxLayout + * @brief The horizontal box layout positions the children of a container horizontally. + * + * @since 2.0 + * + * The %HorizontalBoxLayout class defines the horizontal box layout for a Container. The layout positions the children of the %Container horizontally. + * @n + * For more information on the class features, see Vertical and Horizontal Box Layouts. + * + * @code +// Sample code for HorizontalBoxLayoutSample.h +#include + +class HorizontalBoxLayoutSample + : public Tizen::Ui::Controls::Form +{ +public: + bool Initialize(void); + virtual result OnInitializing(void); +}; + * @endcode + * + * @code +// Sample code for HorizontalBoxLayoutSample.cpp +#include + +#include "HorizontalBoxLayoutSample.h" + +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui; +using namespace Tizen::Graphics; + +bool +HorizontalBoxLayoutSample::Initialize(void) +{ + //Creates an instance of VerticalBoxLayout + VerticalBoxLayout formLayout; + formLayout.Construct(VERTICAL_DIRECTION_DOWNWARD); + + // Applies the vertical box layout to the form + Construct(formLayout, FORM_STYLE_NORMAL); + return true; +} + +result +HorizontalBoxLayoutSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of HorizontalBoxLayout for the top panel + HorizontalBoxLayout topPanelLayout; + topPanelLayout.Construct(HORIZONTAL_DIRECTION_RIGHTWARD); + + // Creates an instance of Panel and applies it to the horizontal box layout + Panel* pTopPanel = new Panel(); + pTopPanel->Construct(topPanelLayout, Rectangle(0, 0, GetClientAreaBounds().width, 450)); + { + // Creates instances of Label and an instance of Button + Label* pLabel1 = new Label(); + pLabel1->Construct(Rectangle(0,0,GetClientAreaBounds().width/4,100), L"TOP"); + pLabel1->SetTextConfig(20, LABEL_TEXT_STYLE_NORMAL); + pLabel1->SetBackgroundColor(Color(0x00, 0x10, 0x80, 0xFF)); + pTopPanel->AddControl(*pLabel1); + + Label* pLabel2 = new Label(); + pLabel2->Construct(Rectangle(0,0,GetClientAreaBounds().width/4,100), L"MIDDLE"); + pLabel2->SetTextConfig(20, LABEL_TEXT_STYLE_NORMAL); + pLabel2->SetBackgroundColor(Color(0x00, 0x20, 0xA0, 0xFF)); + pTopPanel->AddControl(*pLabel2); + + Label* pLabel3 = new Label(); + pLabel3->Construct(Rectangle(0,0,GetClientAreaBounds().width/4,100), L"BOTTOM"); + pLabel3->SetTextConfig(20, LABEL_TEXT_STYLE_NORMAL); + pLabel3->SetBackgroundColor(Color(0x00, 0x30, 0xC0, 0xFF)); + pTopPanel->AddControl(*pLabel3); + + Button* pButton = new Button(); + pButton->Construct(Rectangle(0,0,GetClientAreaBounds().width/4 - 10,100), L"FIT\nTO\nPARENT"); + pButton->SetTextSize(20); + pTopPanel->AddControl(*pButton); + + // Sets relations each label and button + topPanelLayout.SetVerticalAlignment(*pLabel1, LAYOUT_VERTICAL_ALIGN_TOP); + topPanelLayout.SetVerticalAlignment(*pLabel2, LAYOUT_VERTICAL_ALIGN_MIDDLE); + topPanelLayout.SetVerticalAlignment(*pLabel3, LAYOUT_VERTICAL_ALIGN_BOTTOM); + topPanelLayout.SetSpacing(*pButton, 10); + topPanelLayout.SetVerticalFitPolicy(*pButton, FIT_POLICY_PARENT); + } + // Adds the top panel to the form + AddControl(*pTopPanel); + + // Creates an instance of HorizontalBoxLayout for bottom panel + HorizontalBoxLayout bottomPanelLayout; + bottomPanelLayout.Construct(HORIZONTAL_DIRECTION_RIGHTWARD); + + // Creates an instance of Panel and applies it to the horizontal box layout + Panel* pBottomPanel = new Panel(); + pBottomPanel->Construct(bottomPanelLayout, Rectangle(0, 0, 400, 500)); + { + // Creates instances of Label + Label* pLabel1 = new Label(); + pLabel1->Construct(Rectangle(0,0,30,100), L"W\n1.0f"); + pLabel1->SetBackgroundColor(Color(0x00, 0x10, 0x80, 0xFF)); + pBottomPanel->AddControl(*pLabel1); + + Label* pLabel2 = new Label(); + pLabel2->Construct(Rectangle(0,0,30,100), L"W\n2.0f"); + pLabel2->SetBackgroundColor(Color(0x00, 0x20, 0xA0, 0xFF)); + pBottomPanel->AddControl(*pLabel2); + + Label* pLabel3 = new Label(); + pLabel3->Construct(Rectangle(0,0,30,100), L"W\n3.0f"); + pLabel3->SetBackgroundColor(Color(0x00, 0x30, 0xC0, 0xFF)); + pBottomPanel->AddControl(*pLabel3); + + // Sets relations each label + bottomPanelLayout.SetVerticalFitPolicy(*pLabel1, FIT_POLICY_PARENT); + bottomPanelLayout.SetVerticalFitPolicy(*pLabel2, FIT_POLICY_PARENT); + bottomPanelLayout.SetVerticalFitPolicy(*pLabel3, FIT_POLICY_PARENT); + bottomPanelLayout.SetWeight(*pLabel1, 1.0f); + bottomPanelLayout.SetWeight(*pLabel2, 2.0f); + bottomPanelLayout.SetWeight(*pLabel3, 3.0f); + } + + // Adds the bottom panel to the form + AddControl(*pBottomPanel); + + //Gets the layout of the form + VerticalBoxLayout* pFormLayout = dynamic_cast(this->GetLayoutN()); + + // Sets relations between panels + pFormLayout->SetHorizontalFitPolicy(*pTopPanel, FIT_POLICY_PARENT); + pFormLayout->SetSpacing(*pBottomPanel, 30); + pFormLayout->SetHorizontalFitPolicy(*pBottomPanel, FIT_POLICY_PARENT); + + return r; +} + * @endcode + * + */ + +class _OSP_EXPORT_ HorizontalBoxLayout + : public Layout +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + * + * @remarks After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance. + */ + HorizontalBoxLayout(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~HorizontalBoxLayout(void); + + /** + * Initializes this instance of %HorizontalBoxLayout with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] direction The direction in which the children are attached + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(HorizontalDirection direction); + + /** + * Gets the direction of %HorizontalBoxLayout. + * + * @since 2.0 + * + * @return An error code + * @param[out] direction The direction in which the children are attached + * @exception E_SUCCESS The method is successful. + */ + result GetDirection(HorizontalDirection& direction) const; + + /** + * Gets the type of the layout. + * + * @since 2.0 + * + * @return The layout type + */ + virtual LayoutType GetLayoutType(void) const; + + /** + * Sets the vertical alignment of the specified control. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the alignment is set + * @param[in] alignment The vertical alignment + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the horizontal alignment is VERTICAL_ALIGN_TOP. + */ + result SetVerticalAlignment(Control& childControl, LayoutVerticalAlignment alignment); + + /** + * Sets the space between the specified control and its predecessor. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the space is set + * @param[in] space The space + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the spacing is set to @c 0. + */ + result SetSpacing(Control& childControl, int space); + + /** + * Sets the vertical margins of the specified control. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the margins are set + * @param[in] top The top margin + * @param[in] bottom The bottom margin + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the margins are set to @c 0. + */ + result SetVerticalMargin(Control& childControl, int top, int bottom); + + /** + * Sets the width of the specified control with the fixed length. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the width is set + * @param[in] width The value of the width + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result SetWidth(Control& childControl, int width); + + /** + * Sets the width of the specified control with the fitting policy. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the width is set + * @param[in] policy The fitting policy for the width + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks Setting FIT_POLICY_PARENT as @c policy does not cause the width of control to change. + */ + result SetHorizontalFitPolicy(Control& childControl, FitPolicy policy); + + /** + * Sets the height of the specified control with a fixed length. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the height is set + * @param[in] height The value of the height + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result SetHeight(Control& childControl, int height); + + /** + * Sets the height of the specified control with the fitting policy. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the height is set + * @param[in] policy The fitting policy for the height + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result SetVerticalFitPolicy(Control& childControl, FitPolicy policy); + + /** + * Sets the weight of the specified control. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the weight is set + * @param[in] weight The weight that indicates how much extra space the control occupies in proportion to it, in the %HorizontalBoxLayout + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the weight is set to @c 0.0f. + */ + result SetWeight(Control& childControl, float weight); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + HorizontalBoxLayout(const HorizontalBoxLayout& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + HorizontalBoxLayout& operator =(const HorizontalBoxLayout& rhs); +}; // HorizontalBoxLayout + +}} // Tizen::Ui + +#endif // _FUI_HORIZONTAL_BOX_LAYOUT_H_ diff --git a/inc/FUiIAccessibilityListener.h b/inc/FUiIAccessibilityListener.h new file mode 100644 index 0000000..5103004 --- /dev/null +++ b/inc/FUiIAccessibilityListener.h @@ -0,0 +1,142 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIAccessibilityListener.h + * @brief This is the header file for the IAccessibilityListener interface. + * + * This header file contains the declarations of the IAccessibilityListener interface.. + */ + +#ifndef _FUI_IACCESSIBILITY_LISTENER_H_ +#define _FUI_IACCESSIBILITY_LISTENER_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class AccessibilityElement; +class Control; + +/** + * @interface IAccessibilityListener + * @brief This interface is the listener interface for accessibility screen reader + * + * @since 2.0 + * + * This %IAccessibilityListener defines methods for accessibility screen reader + * + */ +class _OSP_EXPORT_ IAccessibilityListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IAccessibilityListener(void) {} + + /** + * Notifies when the accessibility element gets a focus. + * + * @since 2.0 + * @param[in] control The control that has a accessibility element. + * @param[in] element The element. + */ + virtual void OnAccessibilityFocusIn(const Control& control, const AccessibilityElement& element) = 0; + + /** + * Notifies when the accessibility element losts a focus. + * + * @since 2.0 + * @param[in] control The control that has a accessibility element. + * @param[in] element The element. + */ + virtual void OnAccessibilityFocusOut(const Control& control, const AccessibilityElement& element) = 0; + + /** + * Notifies when the accessibility element is operated. + * + * @since 2.0 + * @param[in] control The control that has a accessibility element. + * @param[in] element The element. + */ + virtual void OnAccessibilityActionPerformed(const Control& control, const AccessibilityElement& element) = 0; + + /** + * Notifies when the accessibility screen status is changed. + * + * @since 2.0 + * @param[in] control The control that has a accessibility element. + * @param[in] element The focused element. + * @param[in] status The changed status. + */ + virtual void OnAccessibilityScreenReaderStatusChanged(const Control& control, const AccessibilityElement& element, AccessibilityScreenReaderStatus status) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + virtual void IAccessibilityListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + virtual void IAccessibilityListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + virtual void IAccessibilityListener_Reserved3(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + virtual void IAccessibilityListener_Reserved4(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + virtual void IAccessibilityListener_Reserved5(void) {} +}; // IAccessibilityListener + +}} // Tizen::Ui +#endif // _FUI_IACCESSIBILITY_LISTENER_H_ diff --git a/inc/FUiIActionEventListener.h b/inc/FUiIActionEventListener.h new file mode 100644 index 0000000..23ab583 --- /dev/null +++ b/inc/FUiIActionEventListener.h @@ -0,0 +1,109 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiIActionEventListener.h + * @brief This is the header file for the %IActionEventListener interface. + * + * This header file contains the declarations of the IActionEventListener interface. @n + * If an action event is generated, a method of this interface is called. @n + * So, for tasks related to the action event, use the methods of this interface. + * + */ +#ifndef _FUI_IACTION_EVENT_LISTENER_H_ +#define _FUI_IACTION_EVENT_LISTENER_H_ + +#include "FBaseRtIEventListener.h" + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen {namespace Ui +{ +/** + * @interface IActionEventListener + * @brief This interface implements the listener for action event. + * + * @since 2.0 + * + * The %IActionEventListener interface is the listener interface for receiving action events, for example, from Buttons. + * The class that processes an action event + * implements this interface, and the instance created with that class is registered with a UI control, using the control's + * AddActionEventListener() method. When the action event occurs, the OnActionPerformed() method of that instance is invoked. + * @n + * For more information on the class features, see in individual control topics under UI Controls. + */ +class _OSP_EXPORT_ IActionEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IActionEventListener(void) {} + + /** + * Called when an action event occurs. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] actionId The information about the action event + */ + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IActionEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IActionEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IActionEventListener_Reserved3(void) {} +}; // IActionEventListener + +}} // Tizen::Ui + +#endif // _FUI_IACTION_EVENT_LISTENER_H_ diff --git a/inc/FUiIAdjustmentEventListener.h b/inc/FUiIAdjustmentEventListener.h new file mode 100644 index 0000000..49771e0 --- /dev/null +++ b/inc/FUiIAdjustmentEventListener.h @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiIAdjustmentEventListener.h + * @brief This is the header file for the %IAdjustmentEventListener interface. + * + * This header file contains the declarations of the %IAdjustmentEventListener interface. @n + * If a change event is generated, a method of this interface is called. @n + * So, for tasks related to change events, use the methods of this interface. + * + */ +#ifndef _FUI_IADJUSTMENT_EVENT_LISTENER_H_ +#define _FUI_IADJUSTMENT_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen {namespace Ui +{ +class Control; + +/** + * @interface IAdjustmentEventListener + * @brief This interface implements the listener for adjustment events. + * + * @since 2.0 + * + * The %IAdjustmentEventListener interface is the listener interface for receiving adjustment events, which + * are fired when the knob of a Slider moves. The class that processes an adjustment event implements this interface, and the + * instance created with that class is registered with a UI control, using the control's AddAdjustmentEventListener() method. + * When the adjustment event occurs, the OnAdjustmentValueChanged() method of that instance is invoked. + * @n + * For more information on the class features, see Slider. + + */ +class IAdjustmentEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IAdjustmentEventListener(void) {} + + /** + * Called when a change event occurs. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] adjustment The adjustment value + */ + virtual void OnAdjustmentValueChanged(const Tizen::Ui::Control& source, int adjustment) = 0; + +protected: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // without prior notice. + // + // @since 2.0 + // + virtual void IAdjustmentEventListener_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // without prior notice. + // + // @since 2.0 + // + virtual void IAdjustmentEventListener_Reserved2(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // without prior notice. + // + // @since 2.0 + // + virtual void IAdjustmentEventListener_Reserved3(void) {} + +}; // IAdjustmentEventListener + +}} // Tizen::Ui + +#endif // _FUI_IADJUSTMENT_EVENT_LISTENER_H_ diff --git a/inc/FUiIAnimationEventListener.h b/inc/FUiIAnimationEventListener.h new file mode 100644 index 0000000..4151466 --- /dev/null +++ b/inc/FUiIAnimationEventListener.h @@ -0,0 +1,111 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiIAnimationEventListener.h + * @brief This is the header file for the %IAnimationEventListener interface. + * + * This header file contains the declarations of the %IAnimationEventListener interface. + * If a change event is generated, a method of this interface is called. + * So, for tasks related to change events, use the methods of this interface. + * + */ +#ifndef _FUI_IANIMATION_EVENT_LISTENER_H_ +#define _FUI_IANIMATION_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +class Control; + +/** + * @interface IAnimationEventListener + * @brief This interface implements the listener for animation events. + * + * @since 2.0 + * + * The %IAnimationEventListener interface is the listener interface for receiving animation events. + * The class that processes an animation event implements this interface, and the instance created with that class is registered + * with a UI control, using the control's @ref Tizen::Ui::Controls::Animation::AddAnimationEventListener() method. When the animation event occurs, the + * @ref OnAnimationStopped() method of that instance is invoked. + * @n + * For more information on the class features, see Animation. + * + * + */ +class IAnimationEventListener + : public Tizen::Base::Runtime::IEventListener +{ + +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IAnimationEventListener(void) {} + + /** + * Called when the animation is stopped. + * + * @since 2.0 + * + * @param[in] source The source of the event + */ + virtual void OnAnimationStopped(const Tizen::Ui::Control& source) = 0; + +protected: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // without prior notice. + // + // @since 2.0 + // + virtual void IAnimationEventListener_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // without prior notice. + // + // @since 2.0 + // + virtual void IAnimationEventListener_Reserved2(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // without prior notice. + // + // @since 2.0 + // + virtual void IAnimationEventListener_Reserved3(void) {} + +}; // IAnimationEventListener + +}} // Tizen::Ui + +#endif // _FUI_IANIMATION_EVENT_LISTENER_H_ diff --git a/inc/FUiIClipboard.h b/inc/FUiIClipboard.h new file mode 100644 index 0000000..0b5f2cf --- /dev/null +++ b/inc/FUiIClipboard.h @@ -0,0 +1,152 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIClipboard.h + * @brief This is the header file for the %IClipboard interface. + * + * This header file contains the declarations of the %IClipboard interface and its helper classes. + */ + +#ifndef _FUI_ICLIPBOARD_H_ +#define _FUI_ICLIPBOARD_H_ + +#include + +namespace Tizen { namespace Ui +{ +// +// This class is for internal use only. Using this method can cause behavioral, security-related, +// and consistency-related issues in the application. +// +// @interface IClipboard +// @brief This interface defines the operations of %IClipboard. +// +// @since 2.0 +// +// The %IClipboard interface defines the operations of clipboard. +class _OSP_EXPORT_ IClipboard +{ +public: + // + // This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + // + // @since 2.0 + // + virtual ~IClipboard(void) {} + +public: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Copies the specified item to the system Clipboard. + // + // @since 2.0 + // + // @return An error code + // @param[in] item The item to be saved in the system clipboard + // @exception E_SUCCESS The method is successful. + // @exception E_INVALID_ARG A specified input parameter is invalid. + // @exception E_SYSTEM A system error has occurred. + // @remarks The method returns E_INVALID_ARG if the specified item is + // not constructed.@n + // For the text and image data type, the data itself is copied + // by the method and kept by the system clipboard. + // + virtual result CopyItem(const ClipboardItem& item) = 0; + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Gets a collection of items that matches the specified data types from the + // system clipboard. + // + // @since 2.0 + // + // @return The pointer to an IList which contains a collection of ClipboardItem, @n + // else @c null if an error occurs + // @param[in] dataTypes The types of items. Multiple data types can be + // combined using bitwise OR (Tizen::Ui::ClipboardDataType). + // @exception E_SUCCESS The method is successful. + // @exception E_OBJ_NOT_FOUND The items of the specified data are not found. + // @exception E_SYSTEM A system error has occurred. + // @remarks The specific error code can be accessed using the GetLastResult() method. @n + // This method returns the pointer to an IList which contains + // a collection of ClipboardItem. The returned pointer to IList + // and all elements in IList must be deleted by applications.@n + // The items in IList are sorted in the reverse order in which + // they are copied to the system clipboard. So, the first + // item in IList is the latest one among them. @n + // @c dataType can be a combination of ClipboardDataType. + // + virtual Tizen::Base::Collection::IList* RetrieveItemsN(unsigned long dataTypes) = 0; + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Gets the latest item for the specified data types from the system clipboard. + // + // @since 2.0 + // + // @return The pointer to a ClipboardItem, @n + // else @c null if an error occurs + // @param[in] dataTypes The types of items. Multiple data types can be + // combined using bitwise OR (Tizen::Ui::ClipboardDataType). + // @exception E_SUCCESS The method is successful. + // @exception E_OBJ_NOT_FOUND The item of the specified data types is not found. + // @exception E_SYSTEM A system error has occurred. + // @remarks The specific error code can be accessed using the GetLastResult() method. @n + // This method returns the pointer to a ClipboardItem. The + // returned ClipboardItem must be deleted by applications.@n + // If there is no matched item in the system clipboard, this method + // returns @c null. @n + // @c dataType can be a combination of ClipboardDataType. + // + virtual Tizen::Ui::ClipboardItem* RetrieveLatestItemN(unsigned long dataTypes) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IClipboard_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IClipboard_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IClipboard_Reserved3(void) {} +}; // IClipboard + +}} // Tizen::Ui + +#endif //_FUI_ICLIPBOARD_H_ diff --git a/inc/FUiIClipboardPopupEventListener.h b/inc/FUiIClipboardPopupEventListener.h new file mode 100644 index 0000000..b6ab9cc --- /dev/null +++ b/inc/FUiIClipboardPopupEventListener.h @@ -0,0 +1,97 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIClipboardPopupEventListener.h + * @brief This is the header file for the %IClipboardPopupEventListener interface. + * + * This header file contains the declarations of the %IClipboardPopupEventListener interface. @n + * If the item event is generated, a method of this interface will be called. @n + * The applications that perform tasks related to the item event, must call methods of this interface. + */ + +#ifndef _FUI_ICLIPBOARD_POPUP_EVENT_LISTENER_H_ +#define _FUI_ICLIPBOARD_POPUP_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui +{ +class ClipboardItem; + +/** + * @interface IClipboardPopupEventListener + * @brief This interface defines the listener for clipboard pop-up events. + * + * @since 2.0 + * + * The %IClipboardPopupEventListener interface is the listener interface for receiving clipboard pop-up events. + * @n + * For more information on the class features, see Clipboard. + */ +class _OSP_EXPORT_ IClipboardPopupEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IClipboardPopupEventListener(void) {} + + /** + * Called when the clipboard popup is closed by user interaction. + * + * @since 2.0 + * + * @param[in] pClipboardItem The pointer to ClipboardItem that + * is selected, @n + * else @c null if no item is selected + * @remarks @c pClipboardItem is deleted by the system after this method call. + */ + virtual void OnClipboardPopupClosed(const ClipboardItem* pClipboardItem) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IClipboardPopupEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IClipboardPopupEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IClipboardPopupEventListener_Reserved3(void) {} +}; // IClipboardPopupEventListener + +}} // Tizen::Ui + +#endif //_FUI_ICLIPBOARD_POPUP_EVENT_LISTENER_H_ diff --git a/inc/FUiIColorChangeEventListener.h b/inc/FUiIColorChangeEventListener.h new file mode 100644 index 0000000..06634f3 --- /dev/null +++ b/inc/FUiIColorChangeEventListener.h @@ -0,0 +1,114 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiIColorChangeEventListener.h + * @brief This is the header file for the %IColorChangeEventListener interface. + * + * This header file contains the declarations of the %IColorChangeEventListener interface. + * If a change event is generated, a method of this interface is called. + * So, for tasks related to change events, use the methods of this interface. + * + */ +#ifndef _FUI_ICOLOR_CHANGE_EVENT_LISTENER_H_ +#define _FUI_ICOLOR_CHANGE_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Graphics +{ +class Color; +}} // Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +class Control; + +/** + * @interface IColorChangeEventListener + * @brief This interface implements the listener for the color change events. + * + * @since 2.0 + * + * The %IColorChangeEventListener interface is the listener interface for receiving color change events. + * The class that processes a color change event implements this interface, and the instance created with that class is + * registered with a UI control, using the control's AddColorChangeEventListener() method. When the color change event occurs, + * the OnColorChanged() method of that instance is invoked. + * @n + * For more information on the class features, see ColorPicker. + */ +class IColorChangeEventListener + : public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IColorChangeEventListener(void) {} + + /** + * Called when there is a change in Color. @n + * The %Color instance is passed as an input parameter. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] color The color + */ + virtual void OnColorChanged(const Tizen::Ui::Control& source, const Tizen::Graphics::Color& color) = 0; + +protected: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IColorChangeEventListener_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IColorChangeEventListener_Reserved2(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IColorChangeEventListener_Reserved3(void) {} +}; // IColorChangeEventListener + +}} // Tizen::Ui + +#endif // _FUI_ICOLOR_CHANGE_EVENT_LISTENER_H_ diff --git a/inc/FUiICustomItemEventListener.h b/inc/FUiICustomItemEventListener.h new file mode 100644 index 0000000..46bb675 --- /dev/null +++ b/inc/FUiICustomItemEventListener.h @@ -0,0 +1,115 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiICustomItemEventListener.h + * @brief This is the header file for the %ICustomItemEventListener interface. + * + * This header file contains the declarations of the ICustomItemEventListener interface. @n + * If an item event is generated, a method of this interface is called. @n + * Application doing tasks related to the item event use the methods of this interface. + * + */ +#ifndef _FUI_ICUSTOM_ITEM_EVENT_LISTENER_H_ +#define _FUI_ICUSTOM_ITEM_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui +{ + +/** + * @if OSPDEPREC + * @interface ICustomItemEventListener + * @brief [Deprecated] This interface implements the listener for the item event. + * + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * + * The %ICustomItemEventListener interface is the listener interface for receiving item events. The class that processes an item event + * implements this interface, and the instance created with that class is registered with a UI control, using the control's + * AddCustomItemEventListener() method. When the item event occurs, the OnItemStateChanged() method of that object is invoked. + * @endif + */ +class _OSP_EXPORT_ ICustomItemEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * @if OSPDEPREC + * This is the destructor for this class. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * @endif + */ + virtual ~ICustomItemEventListener(void) {} + + /** + * @if OSPDEPREC + * Called when the state of CustomListItem is changed. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * + * @param[in] source The source control from which the event is fired + * @param[in] index The index of the item + * @param[in] itemId The item ID + * @param[in] status The state of the item + * @remarks Implement this method in a class which derives %ICustomItemEventListener to handle the user interaction at the CustomListItem. + * @remarks If CustomList is constructed with CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER, this method is called when the radio button is selected. + * @endif + */ + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int index, int itemId, Tizen::Ui::ItemStatus status) = 0; + + + /** + * @if OSPDEPREC + * Called when the state of an element in the CustomListItem is changed. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * + * @param[in] source The source control from which the event is fired + * @param[in] index The index of the item + * @param[in] itemId The item ID + * @param[in] elementId The element ID + * @param[in] status The state of the element + * @remarks Implement this method in a class which derives %ICustomItemEventListener to handle the user interaction at the element in + * CustomListItem. + * @remarks If CustomList is constructed with CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER, this method is not called when the radio button is selected. + * Instead, OnItemStateChanged(const Tizen::Ui::Control& source, int index, int itemId, Tizen::Ui::ItemStatus status) is called. + * @endif + */ + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int index, int itemId, int elementId, Tizen::Ui::ItemStatus status) = 0; + + +}; //ICustomItemEventListener + +}} // Tizen::Ui + +#endif // _FUI_ICUSTOM_ITEM_EVENT_LISTENER_H_ diff --git a/inc/FUiIDataBindingDataTransformer.h b/inc/FUiIDataBindingDataTransformer.h new file mode 100644 index 0000000..1c13f4a --- /dev/null +++ b/inc/FUiIDataBindingDataTransformer.h @@ -0,0 +1,138 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIDataBindingDataTransformer.h + * @brief This is the header file for the %IDataBindingDataTransformer interface. + * + * This header file contains the declarations of the %IDataBindingDataTransformer interface. + */ + +#ifndef _FUI_IDATA_BINDING_DATA_TRANSFORMER_H_ +#define _FUI_IDATA_BINDING_DATA_TRANSFORMER_H_ + +#include + +namespace Tizen { namespace Base +{ +class String; +class Object; +}} + +namespace Tizen { namespace Ui +{ + +/** + * @interface IDataBindingDataTransformer + * @brief This interface defines methods for transforming the value of the data that will be updated to the binding target or source. + * + * @since 2.0 + * + * The %IDataBindingDataTransformer interface defines methods for transforming the value of source type to the value of destination type. + */ +class _OSP_EXPORT_ IDataBindingDataTransformer +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IDataBindingDataTransformer(void) {}; + + /** + * Transforms the value of the data of source type to value of target type. + * @since 2.0 + * @return @c true if it is successful to convert source to target @n + * else @c false + * @param[in] bindingId the specified binding id + * @param[in] sourceType The source data type + * @param[in] sourceData The data source + * @param[in] targetType The target data type + * @param[out] targetData The data target + */ + virtual bool TransformSourceToTarget(const Tizen::Base::String& bindingId, DataBindingDataType sourceType, const Tizen::Base::Object& sourceData, DataBindingDataType targetType, Tizen::Base::Object& targetData) = 0; + + /** + * Transforms the value of the data of target type to value of source type. + * @since 2.0 + * @return @c true if it is successful to convert target to source @n + * else @c false + * @param[in] bindingId the specified binding id + * @param[in] targetType The target data type + * @param[in] targetData The data target + * @param[in] sourceType The source data type + * @param[out] sourceData The data source + */ + virtual bool TransformTargetToSource(const Tizen::Base::String& bindingId, DataBindingDataType targetType, const Tizen::Base::Object& targetData, DataBindingDataType sourceType, Tizen::Base::Object& sourceData) = 0; + + /** + * Checks whether the this transformer can convert the source type to target type + * + * @since 2.0 + * @return @c true It is possible to transform source type to target type, @n + * else @c It's not possible + * @param[in] bindingId the specified binding id + * @param[in] sourceType The source data type + * @param[in] targetType The taret data type + */ + virtual bool IsSourceToTargetTransformable(const Tizen::Base::String& bindingId, DataBindingDataType sourceType, DataBindingDataType targetType) = 0; + + /** + * Checks whether the this transformer can convert the target type to source type + * + * @since 2.0 + * @return @c true It is possible to transform target type to source type, @n + * else @c It's not possible + * @param[in] bindingId the specified binding id + * @param[in] targetType The taret data type + * @param[in] sourceType The source data type + */ + virtual bool IsTargetToSourceTransformable(const Tizen::Base::String& bindingId, DataBindingDataType targetType, DataBindingDataType sourceType) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IDataBingingDataTransformer_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IDataBingingDataTransformer_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IDataBingingDataTransformer_Reserved3(void) {} + +}; // IDataBindingDataTransformer + +}} // Tizen::Ui +#endif // _FUI_IDATA_BINDING_DATA_TRANSFORMER_H_ diff --git a/inc/FUiIDataBindingDataValidator.h b/inc/FUiIDataBindingDataValidator.h new file mode 100644 index 0000000..375d431 --- /dev/null +++ b/inc/FUiIDataBindingDataValidator.h @@ -0,0 +1,111 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIDataBindingDataValidator.h + * @brief This is the header file for the %IDataBindingDataValidator interface. + * + * This header file contains the declarations of the %IDataBindingDataValidator interface. + */ + +#ifndef _FUI_IDATA_BINDING_DATA_VALIDATOR_H_ +#define _FUI_IDATA_BINDING_DATA_VALIDATOR_H_ + +#include + +namespace Tizen { namespace Base +{ +class String; +class Object; +}} + +namespace Tizen { namespace Ui +{ + +/** + * @interface IDataBindingDataValidator + * @brief This interface defines methods for validating the value of transformed data that will be updated to the binding + * target or source. + * + * @since 2.0 + * + * The %IDataBindingDataValidator interface defines methods for validating the value of transformed data that will be updated to the binding. + */ +class _OSP_EXPORT_ IDataBindingDataValidator +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IDataBindingDataValidator(void) {}; + + /** + * Validates the value of the transformed data that will be updated to the binding target. + * + * @since 2.0 + * @return @c true if the specified value is valid, @n + * else @c false + * @param[in] bindingId The binding Id to validate + * @param[in] data The data to validate + */ + virtual bool ValidateDataToTarget(const Tizen::Base::String& bindingId, const Tizen::Base::Object& data) = 0; + + /** + * Validates the value of the transformed data that will be updated to the binding source. + * + * @since 2.0 + * @return @c true if the specified value is valid, @n + * else @c false + * @param[in] bindingId The binding Id to validate + * @param[in] data The data to validate + */ + virtual bool ValidateDataToSource( const Tizen::Base::String& bindingId, const Tizen::Base::Object& data) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IDataBindingDataValidator_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IDataBindingDataValidator_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IDataBindingDataValidator_Reserved3(void) {} + +}; // IDataBindingDataValidator + +}} // Tizen::Ui +#endif // _FUI_IDATA_BINDING_DATA_VALIDATOR_H_ diff --git a/inc/FUiIDataBindingListener.h b/inc/FUiIDataBindingListener.h new file mode 100644 index 0000000..c64fd75 --- /dev/null +++ b/inc/FUiIDataBindingListener.h @@ -0,0 +1,118 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIDataBindingListener.h + * @brief This is the header file for the %IDataBindingListener interface. + * + * This header file contains the declarations of the %IDataBindingListener interface. + */ + +#ifndef _FUI_IDATA_BINDING_LISTENER_H_ +#define _FUI_IDATA_BINDING_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +/** + * @interface IDataBindingListener + * @brief This interface is the listener interface for receiving data binding-related events. + * + * @since 2.0 + * + * The %IDataBindingListener interface defines methods for receiving data binding-related events. + */ +class _OSP_EXPORT_ IDataBindingListener + : public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IDataBindingListener(void) {}; + + /** + * Called when the data transfer for source is completed by the data binding. + * + * @since 2.0 + * + * @param[in] bindingId The binding ID + * @param[in] controlName The name of binding target control + * @param[in] propertyName The name of binding target property + */ + virtual void OnDataBindingSourceUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName) = 0; + + /** + * Called when the data transfer for target is completed by the data binding. + * + * @since 2.0 + * + * @param[in] bindingId The binding ID + * @param[in] controlName The name of binding target control + * @param[in] propertyName The name of binding target property + */ + virtual void OnDataBindingTargetUpdated(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName) = 0; + + /** + * Called when a validation has failed during data transfer. + * + * @since 2.0 + * + * @param[in] bindingId The binding ID + * @param[in] controlName The name of binding target control + * @param[in] propertyName The name of binding target property + * @param[in] destType The data binding destination type + */ + virtual void OnDataBindingValidationFailed(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName, DataBindingDestinationType destType) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IDataBindingListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IDataBindingListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IDataBindingListener_Reserved3(void) {} + +}; // IDataBindingListener; + +}} // Tizen::Ui +#endif // _FUI_IDATA_BINDING_LISTENER_H_ diff --git a/inc/FUiIDateChangeEventListener.h b/inc/FUiIDateChangeEventListener.h new file mode 100644 index 0000000..dc3df7e --- /dev/null +++ b/inc/FUiIDateChangeEventListener.h @@ -0,0 +1,127 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiIDateChangeEventListener.h + * @brief This is the header file for the %IDateChangeEventListener interface. + * + * This header file contains the declarations of the %IDateChangeEventListener interface. + * If a change event is generated, a method of this interface is called. + * So, for tasks related to the change events, use the methods of this interface. + * + */ +#ifndef _FUI_IDATE_CHANGE_EVENT_LISTENER_H_ +#define _FUI_IDATE_CHANGE_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui +{ + +/** + * @interface IDateChangeEventListener + * @brief This interface implements the listener for Date change events. + * + * @since 2.0 + * + * The %IDateChangeEventListener interface is the listener interface for receiving date change events. + * The class that processes a date change event implements this interface, and the instance created with that class is registered + * with a UI control, using the control's AddDateChangeEventListener() method. When the date change event occurs, the + * OnDateChanged() method of that instance is invoked. + * @n + * For more information on the class features, see EditDate and EditTime and DatePicker, TimePicker, and DateTimePicker. + */ +class _OSP_EXPORT_ IDateChangeEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IDateChangeEventListener(void) {} + + /** + * Called when there is a change in the date. @n + * The changed values of the year, month, and day are passed as input parameters. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] year The year + * @param[in] month The month + * @param[in] day The day + */ + virtual void OnDateChanged(const Tizen::Ui::Control& source, int year, int month, int day) = 0; + + + /** + * Called when the change in date is canceled. + * + * @since 2.0 + * + * @param[in] source The source of the event + */ + virtual void OnDateChangeCanceled(const Tizen::Ui::Control& source) = 0; + +protected: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IDateChangeEventListener_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IDateChangeEventListener_Reserved2(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IDateChangeEventListener_Reserved3(void) {} + +}; // IDateChangeEventListener + +}} // Tizen::Ui + +#endif // _FUI_IDATE_CHANGE_EVENT_LISTENER_H_ diff --git a/inc/FUiIDateTimeChangeEventListener.h b/inc/FUiIDateTimeChangeEventListener.h new file mode 100644 index 0000000..3f92c6c --- /dev/null +++ b/inc/FUiIDateTimeChangeEventListener.h @@ -0,0 +1,126 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiIDateTimeChangeEventListener.h + * @brief This is the header file for the %IDateTimeChangeEventListener interface. + * + * This header file contains the declarations of the %IDateTimeChangeEventListener interface. @n + * If a change event is generated, a method of this class is called. @n + * So, if applications perform jobs related to change events, they use the methods of this class. + * + */ +#ifndef _FUI_IDATETIME_CHANGE_EVENT_LISTENER_H_ +#define _FUI_IDATETIME_CHANGE_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui +{ + +/** + * @interface IDateTimeChangeEventListener + * @brief This interface implements the listener for Date and Time change events. + * + * @since 2.0 + * + * The %IDateTimeChangeEventListener interface is the listener interface for receiving date and time change events. + * The class that processes a date and time change event implements this interface, and the instance created with that class is + * registered with a UI control, using the control's AddDateTimeChangeEventListener() method. When the date and time change event + * occurs, the OnDateTimeChanged() method of that instance is invoked. + * @n + * For more information on the class features, see DatePicker, TimePicker, and DateTimePicker. + */ +class _OSP_EXPORT_ IDateTimeChangeEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IDateTimeChangeEventListener(void) {} + + /** + * Called when there is a change in DateTime. @n + * The changed values of day, month, year, hour and minute are passed as input parameters. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] year The year value + * @param[in] month The month value + * @param[in] day The day value + * @param[in] hour The hour value + * @param[in] minute The minute value + * + */ + virtual void OnDateTimeChanged(const Tizen::Ui::Control& source, int year, int month, int day, int hour, int minute) = 0; + + + /** + * Called when the date and time change is canceled. + * + * @since 2.0 + * + * @param[in] source The source of the event + */ + virtual void OnDateTimeChangeCanceled(const Tizen::Ui::Control& source) = 0; + +protected: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IDateTimeChangeEventListener_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IDateTimeChangeEventListener_Reserved2(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.0 + // + virtual void IDateTimeChangeEventListener_Reserved3(void) {} +}; // IDateTimeChangeEventListener + +}} // Tizen::Ui + +#endif // _FUI_IDATETIME_CHANGE_EVENT_LISTENER_H_ diff --git a/inc/FUiIDragDropEventListener.h b/inc/FUiIDragDropEventListener.h new file mode 100644 index 0000000..dd1fbcb --- /dev/null +++ b/inc/FUiIDragDropEventListener.h @@ -0,0 +1,109 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiIDragDropEventListener.h +* @brief This is the header file for the %IDragDropEventListener interface. +* +* This header file contains the declarations of the %IDragDropEventListener interface. +*/ +#ifndef _FUI_IDRAG_DROP_EVENT_LISTENER_H_ +#define _FUI_IDRAG_DROP_EVENT_LISTENER_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ + +class Control; + +/** + * @interface IDragDropEventListener + * @brief This interface implements the listener for a drag and drop event. + * + * @since 2.0 + * + * The %IDragDropEventListener interface is the listener interface for receiving drag and drop events. + * The class that processes a drag and drop event implements this interface, and the instance created with that class is + * registered with a UI control, using the control's AddDragDropEventListener() method. When the drag and drop event occurs, a + * method of that instance is invoked. + * @n + * For more information on the class features, see Event Listeners. + */ +class _OSP_EXPORT_ IDragDropEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This is the destructor for this class. + // + // @since 2.0 + // + virtual ~IDragDropEventListener(void) {} + + /** + * Called when an entity is dragged. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] startPosition The start position + * @param[in] currentPosition The current position + */ + virtual void OnTouchDragged(const Tizen::Ui::Control& source, + const Tizen::Graphics::Point& startPosition, const Tizen::Graphics::Point& currentPosition) = 0; + + /** + * Called when an entity is dropped. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] startPosition The start position + * @param[in] currentPosition The current position + */ + virtual void OnTouchDropped(const Tizen::Ui::Control& source, + const Tizen::Graphics::Point& startPosition, const Tizen::Graphics::Point& currentPosition) = 0; + +protected: + // Reserved virtual methods for later extension + // + // The following methods are reserved and may change its name at any time without prior notice. + // + virtual void IDragDropEventListener_Reserved1(void) {} + + // Reserved virtual methods for later extension + // + // The following methods are reserved and may change its name at any time without prior notice. + // + virtual void IDragDropEventListener_Reserved2(void) {} + + // Reserved virtual methods for later extension + // + // The following methods are reserved and may change its name at any time without prior notice. + // + virtual void IDragDropEventListener_Reserved3(void) {} +}; // IDragDropEventListener + +} } // Tizen::Ui + +#endif // _FUI_IDRAG_DROP_EVENT_LISTENER_H_ diff --git a/inc/FUiIExpandableItemEventListener.h b/inc/FUiIExpandableItemEventListener.h new file mode 100644 index 0000000..e20b8f6 --- /dev/null +++ b/inc/FUiIExpandableItemEventListener.h @@ -0,0 +1,116 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIExpandableItemEventListener.h + * @brief This is the header file for the %IExpandableItemEventListener interface. + * + * This header file contains the declarations of the %IExpandableItemEventListener interface. @n + * If an item event is generated, a method of this interface is called. + * + */ +#ifndef _FUI_IEXPANDABLE_ITEM_EVENT_LISTENER_H_ +#define _FUI_IEXPANDABLE_ITEM_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui +{ + +/** + * @if OSPDEPREC + * @interface IExpandableItemEventListener + * @brief [Deprecated] This interface implements a listener for the item events. + * + * @deprecated This listener is deprecated. Instead of using this class, use IGroupedTableViewItemEventListener. + * @since 2.0 + * + * The %IExpandableItemEventListener interface implements a listener for the item events. + * A class that needs to process an item event + * must implement this interface. The object created with that class is registered with a UI Control using the controls. + * ExpandableList::AddExpandableItemEventListener() method. When the item event occurs, that instance's OnItemStateChanged() method is invoked. + * @endif + */ +class _OSP_EXPORT_ IExpandableItemEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * @if OSPDEPREC + * This is the destructor for this class. + * + * @brief [Deprecated] + * @deprecated This listener is deprecated. This listener is deprecated. Instead of using this class, use + * IGroupedTableViewEventListener. + * @since 2.0 + * @endif + */ + virtual ~IExpandableItemEventListener(void) {} + + /** + * @if OSPDEPREC + * Called when the state of CustomListItem in the ExpandableList is changed. @n + * If a main item is selected, the index of the sub-item is @c -1. + * + * @brief [Deprecated] + * @deprecated This listener is deprecated. Instead of using this class, use IGroupedTableViewEventListener. + * @since 2.0 + * + * @param[in] source The source control from which the event is fired + * @param[in] mainIndex The main index of the item + * @param[in] subIndex The sub index of the item + * @param[in] itemId The item ID + * @param[in] status The state of the item + * @remarks Implement this method in a class that derives %IExpandableItemEventListener to handle the user interaction at the CustomListItem of the + * ExpandableList. + * @endif + */ + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int mainIndex, int subIndex, int itemId, Tizen::Ui::ItemStatus status) = 0; + + + /** + * @if OSPDEPREC + * Called when the state of an element in CustomListItem in ExpandableList is changed. @n + * If a main item is selected, the index of the sub-item is @c -1. + * @brief [Deprecated] + * @deprecated This listener is deprecated. Instead of using this class, use IGroupedTableViewEventListener. + * @since 2.0 + * + * @param[in] source The source control from which the event is fired + * @param[in] mainIndex The main index of the item + * @param[in] subIndex The sub index of the item + * @param[in] itemId The item ID + * @param[in] elementId The element ID + * @param[in] status The state of the element + * @remarks Implement this method in a class that derives %IExpandableItemEventListener to handle the user interaction at the element in + * CustomListItem of ExpandableList. + * @endif + */ + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int mainIndex, int subIndex, int itemId, int elementId, Tizen::Ui::ItemStatus status) = 0; + +}; //IExpandableItemEventListener + +}} // Tizen::Ui + +#endif // _FUI_IEXPANDABLE_ITEM_EVENT_LISTENER_H_ diff --git a/inc/FUiIFastScrollEventListener.h b/inc/FUiIFastScrollEventListener.h new file mode 100644 index 0000000..a933728 --- /dev/null +++ b/inc/FUiIFastScrollEventListener.h @@ -0,0 +1,138 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiIFastScrollEventListener.h + * @brief This is the header file for the %IFastScrollEventListener interface. + * + * This header file contains declarations of the %IFastScrollEventListener interface. + * If item event is generated, a method of this interface will be called. + * Applications that do some jobs related to item event, call methods of this interface. + * + */ +#ifndef _FUI_IFAST_SCROLL_EVENT_LISTENER_H_ +#define _FUI_IFAST_SCROLL_EVENT_LISTENER_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui +{ + +/** + * @if OSPDEPREC + * @interface IFastScrollEventListener + * @brief [Deprecated] This interface implements the listener for fast scroll event. + * + * @deprecated This class is deprecated. Instead of using this class, use the IFastScrollListener class. + * @since 2.0 + * + * + * The %IFastScrollEventListener interface for receiving item events. The class that processes a fast scroll + * implements this interface, and the object created with that class is registered with a UI control, using the control's + * AddFastScrollEventListener method. When an item event occurs, the object's OnItemStateChanged() method is invoked. + * @endif + */ +class _OSP_EXPORT_ IFastScrollEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * @if OSPDEPREC + * This is the destructor for this class. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IFastScrollListener class. + * @since 2.0 + * @endif + */ + virtual ~IFastScrollEventListener(void) {} + + /** + * @if OSPDEPREC + * Called when a main index is selected. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IFastScrollListener class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] mainIndex The main index + * @endif + */ + virtual void OnMainIndexChanged(const Tizen::Ui::Control& source, Tizen::Base::Character& mainIndex) = 0; + + /** + * @if OSPDEPREC + * Called when a sub index is selected. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IFastScrollListener class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] mainIndex The main index + * @param[in] subIndex The sub index + * @endif + */ + virtual void OnSubIndexChanged(const Tizen::Ui::Control& source, Tizen::Base::Character& mainIndex, Tizen::Base::Character& subIndex) = 0; + + /** + * @if OSPDEPREC + * Called when a main index is expanded. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IFastScrollListener class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] mainIndex The main index + * @endif + */ + virtual void OnMainIndexSelected(const Tizen::Ui::Control& source, Tizen::Base::Character& mainIndex) = 0; + + /** + * @if OSPDEPREC + * Called when a sub index is expanded. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use the IFastScrollListener class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] mainIndex The main index + * @param[in] subIndex The sub index + * @endif + */ + virtual void OnSubIndexSelected(const Tizen::Ui::Control& source, Tizen::Base::Character& mainIndex, Tizen::Base::Character& subIndex) = 0; + +protected: + + virtual void IFastScrollEventListener_Reserved1(void) {} + virtual void IFastScrollEventListener_Reserved2(void) {} + virtual void IFastScrollEventListener_Reserved3(void) {} +}; // IFastScrollEventListener + +}} + +#endif // _FUI_IFAST_SCROLL_EVENT_LISTENER_H_ diff --git a/inc/FUiIFocusEventListener.h b/inc/FUiIFocusEventListener.h new file mode 100644 index 0000000..2b9cfbd --- /dev/null +++ b/inc/FUiIFocusEventListener.h @@ -0,0 +1,124 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIFocusEventListener.h + * @brief This is the header file for the %IFocusEventListener interface. + * + * This header file contains the declarations of the %IFocusEventListener interface. + */ + +#ifndef _FUI_IFOCUS_EVENT_LISTENER_H_ +#define _FUI_IFOCUS_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui +{ + +class Control; + +/** + * @enum FocusStatus + * + * Defines constants used to identify focus status. + * + * @since 2.0 + * + */ + +enum FocusStatus +{ + FOCUS_GAINED = 0, // The Control has gained focus + FOCUS_LOST = 1 // The Control has lost focus +}; + +/** + * @interface IFocusEventListener + * @brief This interface is used as the argument to focus the event listener. + * + * @since 2.0 + * + * The %IFocusEventListener interface is the listener interface for receiving focus events. + * The class that processes a focus event implements this interface, and the instance created with that class is registered with a + * UI control, using the control's AddFocusEventListener() method. When the focus event occurs, a method of that instance is + * invoked. + * @n + * For more information on the class features, see Event Listeners. + */ +class _OSP_EXPORT_ IFocusEventListener + : public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + * + */ + virtual ~IFocusEventListener(void) {} + + /** + * Called when Control gains the input focus. + * + * @since 2.0 + * + * @param[in] source The source of the event + */ + virtual void OnFocusGained(const Tizen::Ui::Control& source) = 0; + + /** + * Called when Control loses the input focus. + * + * @since 2.0 + * + * @param[in] source The source of the event + */ + virtual void OnFocusLost(const Tizen::Ui::Control& source) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IFocusEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IIFocusEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IIFocusEventListener_Reserved3(void) {} +}; // IFocusEventListener + +}} // Tizen::Ui + +#endif // _FUI_IFOCUS_EVENT_LISTENER_H_ diff --git a/inc/FUiIGroupedItemEventListener.h b/inc/FUiIGroupedItemEventListener.h new file mode 100644 index 0000000..5111668 --- /dev/null +++ b/inc/FUiIGroupedItemEventListener.h @@ -0,0 +1,123 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIGroupedItemEventListener.h + * @brief This is the header file for the %IGroupedItemEventListener interface. + * + * This header file contains the declarations of the %IGroupedItemEventListener interface. + */ + +#ifndef _FUI_IGROUPED_ITEM_EVENT_LISTENER_H_ +#define _FUI_IGROUPED_ITEM_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui +{ + +/** + * @if OSPDEPREC + * @interface IGroupedItemEventListener + * @brief [Deprecated] This interface implements the listener for the events on the items of GroupedList. + * + * @deprecated This class is deprecated. Instead of using this class, use IGroupedListViewItemEventListener class. + * @since 2.0 + * + * + * The %IGroupedItemEventListener interface implements a listener for detecting state changes on the item of the grouped list. + * The interface is registered with a GroupedList, using the control's AddGroupedItemEventListener() method. + * @endif + */ +class _OSP_EXPORT_ IGroupedItemEventListener + : public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * @if OSPDEPREC + * This is the default constructor for this class. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use IGroupedListViewItemEventListener class. + * @since 2.0 + * @endif + */ + IGroupedItemEventListener(void) {}; + + /** + * @if OSPDEPREC + * This is the destructor for this class. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use IGroupedListViewItemEventListener class. + * @since 2.0 + * @endif + */ + virtual ~IGroupedItemEventListener(void) {}; + + /** + * @if OSPDEPREC + * Called when the state of an element in the CustomListItem instance in the GroupedList instance is changed. @n + * For example, this method is called when an element of %CustomListItem in %GroupedList is checked, unchecked, or selected. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use IGroupedListViewItemEventListener class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] groupIndex The index of the list group + * @param[in] itemIndex The index of the list item in the specified group + * @param[in] itemId The item ID + * @param[in] elementId The element ID + * @param[in] status The state of the element + * @remarks If GroupedList or SlidableGroupedList is constructed with CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER, this method is not called when the + * radio button is selected. Instead, OnItemStateChanged(const Tizen::Ui::Control &source, int groupIndex, int itemIndex, int itemId, + * Tizen::Ui::ItemStatus status) is called. + * @endif + */ + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int groupIndex, int itemIndex, int itemId, int elementId, Tizen::Ui::ItemStatus status) = 0; + + /** + * @if OSPDEPREC + * Called when the state of an item in the grouped list is changed. @n + * For example, this method is called when an item of the GroupedList control is checked, unchecked, or selected. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use IGroupedListViewItemEventListener class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] groupIndex The index of the list group + * @param[in] itemIndex The index of the list item in the specified group + * @param[in] itemId The item ID + * @param[in] status The state of the item + * @remarks If GroupedList or SlidableGroupedList is constructed with CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER, this method is called when the radio + * button is selected. + * @endif + */ + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int groupIndex, int itemIndex, int itemId, Tizen::Ui::ItemStatus status) = 0; +}; //IGroupedItemEventListener + +}} // Tizen::Ui + +#endif //_FUI_IGROUPED_ITEM_EVENT_LISTENER_H_ diff --git a/inc/FUiIInputConnectionEventListener.h b/inc/FUiIInputConnectionEventListener.h new file mode 100644 index 0000000..8fbc4da --- /dev/null +++ b/inc/FUiIInputConnectionEventListener.h @@ -0,0 +1,179 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIInputConnectionEventListener.h + * @brief This is the header file for the %IInputConnectionEventListener class. + * + * This header file contains the declarations of the %IInputConnectionEventListener class. + * + * + */ + +#ifndef _FUI_IINPUT_CONNECTION_EVENT_LISTENER_H_ +#define _FUI_IINPUT_CONNECTION_EVENT_LISTENER_H_ + +#include +#include +#include + +namespace Tizen { namespace Base { +class String; +}} // Tizen::Base + +namespace Tizen { namespace Graphics { +class Rectangle; +}} // Tizen::Graphics + + +namespace Tizen { namespace Ui { + +class InputConnection; + +/** + * @class IInputConnectionEventListener + * @brief This is the header file for the %IInputConnectionEventListener class. + * This header file contains the declarations of the %IInputConnectionEventListener class. + * It's possible to not work the callback depending on the current InputMethod. + * @since 2.0 + * + * The %IInputConnectionEventListener interface defines methods for processing between the InputConnection and the input method. + */ +class _OSP_EXPORT_ IInputConnectionEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IInputConnectionEventListener(void) {} + + /** + * Notifies when the show state of the InputPanel is changed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] showState The state + */ + virtual void OnInputConnectionPanelShowStateChanged(Tizen::Ui::InputConnection& source, Tizen::Ui::InputPanelShowState showState) = 0; + + /** + * Notifies when the language of the InputPanel is changed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] language The language code + */ + virtual void OnInputConnectionPanelLanguageChanged(Tizen::Ui::InputConnection& source, Tizen::Locales::LanguageCode language) = 0; + + /** + * Notifies when the size of the InputPanel is changed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] bounds The size + */ + virtual void OnInputConnectionPanelBoundsChanged(Tizen::Ui::InputConnection& source, const Tizen::Graphics::Rectangle& bounds) = 0; + + /** + * Notifies when the show state of the Text-Prediction is changed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] isShown The state + */ + virtual void OnInputConnectionTextPredictionShowStateChanged(Tizen::Ui::InputConnection& source, bool isShown) = 0; + + /** + * Notifies when the size of the Text-Prediction is changed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] bounds The size + */ + virtual void OnInputConnectionTextPredictionBoundsChanged(Tizen::Ui::InputConnection& source, const Tizen::Graphics::Rectangle& bounds) = 0; + + /** + * Notifies when the key of the InputPanel is selected. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] committedText The committed text. + */ + virtual void OnInputConnectionTextCommitted(Tizen::Ui::InputConnection& source, const Tizen::Base::String& committedText) = 0; + + /** + * Notifies when the key of the InputPanel is selected during the composing. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] composingText The composing text. + * @param[in] cursorPosition the current cursor position. + */ + virtual void OnInputConnectionComposingTextChanged(Tizen::Ui::InputConnection& source, const Tizen::Base::String& composingText, int cursorPosition) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IInputConnectionEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IInputConnectionEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IInputConnectionEventListener_Reserved3(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IInputConnectionEventListener_Reserved4(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IInputConnectionEventListener_Reserved5(void) {} +}; // IInputConnectionEventListener + +}} // Tizen::Ui +#endif // _FUI_IINPUT_CONNECTION_EVENT_LISTENER_H_ diff --git a/inc/FUiIInputConnectionProvider.h b/inc/FUiIInputConnectionProvider.h new file mode 100644 index 0000000..7c9e2db --- /dev/null +++ b/inc/FUiIInputConnectionProvider.h @@ -0,0 +1,111 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIInputConnectionProvider.h + * @brief This is the header file for the %IInputConnectionProvider class. + * + * This header file contains the declarations of the %IInputConnectionProvider class. + * + * + */ + +#ifndef _FUI_IINPUT_CONNECTION_PROVIDER_H_ +#define _FUI_IINPUT_CONNECTION_PROVIDER_H_ + +#include + +namespace Tizen { namespace Base { +class String; +}} // Tizen::Base + +namespace Tizen { namespace Ui { + +class InputConnection; + +/** + * @class IInputConnectionProvider + * @brief This is the header file for the %IInputConnectionProvider class. + * This header file contains the declarations of the %IInputConnectionProvider class. + * It's possible to not work the callback depending on the current active Input Method. + * @since 2.0 + * + * The %IInputConnectionProvider interface defines methods for processing between the InputConnection and the input method. + */ +class _OSP_EXPORT_ IInputConnectionProvider +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IInputConnectionProvider(void) {} + + /** + * Called when the text needs to be deleted. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] offset The position to be deleted before the current cursor position. + * @param[in] charCount The number of characters to be deleted. + */ + virtual void DeleteSurroundingText(Tizen::Ui::InputConnection& source, int offset, int charCount) = 0; + + /** + * Called when the input method requests the previous text. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[out] text The text to be sent to the Input Method. + * @param[out] cursorPosition The current cursor position to be sent to the Input Method. + * @remarks The text will be used for processing the auto-capitalization/auto-period. At least three letters in front of the cursor are required. + */ + virtual void GetPreviousText(Tizen::Ui::InputConnection& source, Tizen::Base::String& text, int& cursorPosition) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IInputConnectionProvider_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IInputConnectionProvider_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IInputConnectionProvider_Reserved3(void) {} +}; // IInputConnectionProvider + +}} // Tizen::Ui +#endif // _FUI_IINPUT_CONNECTION_PROVIDER_H_ + diff --git a/inc/FUiIItemEventListener.h b/inc/FUiIItemEventListener.h new file mode 100644 index 0000000..9d5b81a --- /dev/null +++ b/inc/FUiIItemEventListener.h @@ -0,0 +1,105 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIItemEventListener.h + * @brief This is the header file for the %IItemEventListener interface. + * + * This header file contains the declarations of the %IItemEventListener interface. @n + * If an item event is generated, a method of this class is called. @n + * So, if an application performs tasks related to the item event, use the methods of this class. + * + */ +#ifndef _FUI_IITEM_EVENT_LISTENER_H_ +#define _FUI_IITEM_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui +{ +/** + * @if OSPDEPREC + * @enum ItemStatus + * + * Defines the constants used to identify the item state. + * + * @brief [Deprecated] + * @deprecated This enumeration is deprecated. Instead of using this enumeration, use the ListItemStatus enumeration. + * @since 2.0 + * @endif + */ +enum ItemStatus +{ + ITEM_CHECKED = 0, /**< @if OSPDEPREC The item has been checked (toggle of the check area) @endif */ + ITEM_UNCHECKED, /**< @if OSPDEPREC The item has been unchecked (toggle of the check area) @endif */ + ITEM_SELECTED, /**< @if OSPDEPREC The item has been selected (non-check area of the item) @endif */ + ITEM_HIGHLIGHTED /**< @if OSPDEPREC The item has been highlighted (non-check area of the item) @endif */ +}; + +/** + * @if OSPDEPREC + * @interface IItemEventListener + * @brief [Deprecated] This interface implements the listener for the item event. + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * + * The %IItemEventListener interface is the listener interface for receiving item events. The class that processes an item event + * implements this interface, and the instance created with that class is registered with a UI control, using the control's + * AddItemEventListener() method. When the item event occurs, the OnItemStateChanged() method of that instance is invoked. + * @endif + */ +class _OSP_EXPORT_ IItemEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * @if OSPDEPREC + * This is the destructor for this class. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * @endif + */ + virtual ~IItemEventListener(void) {} + + /** + * @if OSPDEPREC + * Called when an item event occurs. + * + * @brief [Deprecated] + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] index The index of the item + * @param[in] itemId The item ID + * @param[in] status The item status + * @endif + */ + virtual void OnItemStateChanged(const Tizen::Ui::Control& source, int index, int itemId, Tizen::Ui::ItemStatus status) = 0; +}; //IItemEventListener + +}} // Tizen::Ui + +#endif // _FUI_IITEM_EVENT_LISTENER_H_ diff --git a/inc/FUiIKeyEventListener.h b/inc/FUiIKeyEventListener.h new file mode 100644 index 0000000..ec1917f --- /dev/null +++ b/inc/FUiIKeyEventListener.h @@ -0,0 +1,580 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIKeyEventListener.h + * @brief This is the header file for the %IKeyEventListener interface. + * + * This header file contains the declarations of the %IKeyEventListener interface. @n + * If a key event is generated, a method of this interface is called. @n + * If an application performs tasks related to the key event, use the methods of this interface. + */ + +#ifndef _FUI_IKEY_EVENT_LISTENER_H_ +#define _FUI_IKEY_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen {namespace Ui +{ +class Control; +/** + * @enum KeyCode + * + * Defines the list of keys supported by the system. @n + * Note that certain keys may not be available on all devices. @n + * Please use the Tizen::Ui::KeyboardMap class to query the availability of a specific key on the target device. + * + * @since 2.0 + */ +enum KeyCode +{ + /** + * The invalid key + */ + KEY_INVALID = 0x0000, + + /** + * The up side key + */ + KEY_SIDE_UP, + + /** + * The down side key + */ + KEY_SIDE_DOWN, + + /** + * The Ok key + */ + KEY_OK, + + /** + * The clear key + */ + KEY_CLEAR, + + /** + * The camera key + */ + KEY_CAMERA, + + /** + * The task switcher key + */ + KEY_SWITCH, + + /** + * The 0 key + */ + KEY_0, + + /** + * The 1 key + */ + KEY_1, + + /** + * The 2 key + */ + KEY_2, + + /** + * The 3 key + */ + KEY_3, + + /** + * The 4 key + */ + KEY_4, + + /** + * The 5 key + */ + KEY_5, + + /** + * The 6 key + */ + KEY_6, + + /** + * The 7 key + */ + KEY_7, + + /** + * The 8 key + */ + KEY_8, + + /** + * The 9 key + */ + KEY_9, + + /** + * The asterisk key + */ + KEY_ASTERISK, + + /** + * The sharp key + */ + KEY_SHARP, + + /** + * The left directional key + */ + KEY_LEFT, + + /** + * The up directional key + */ + KEY_UP, + + /** + * The down directional key + */ + KEY_DOWN, + + /** + * The right directional key + */ + KEY_RIGHT, + + /* + * The Placeholder + */ + KEY_MAX, + + /** + * The A key + */ + KEY_A, + + /** + * The B key + */ + KEY_B, + + /** + * The C key + */ + KEY_C, + + /** + * The D key + */ + KEY_D, + + /** + * The E key + */ + KEY_E, + + /** + * The F key + */ + KEY_F, + + /** + * The G key + */ + KEY_G, + + /** + * The H key + */ + KEY_H, + + /** + * The I key + */ + KEY_I, + + /** + * The J key + */ + KEY_J, + + /** + * The K key + */ + KEY_K, + + /** + * The L key + */ + KEY_L, + + /** + * The M key + */ + KEY_M, + + /** + * The N key + */ + KEY_N, + + /** + * The O key + */ + KEY_O, + + /** + * The P key + */ + KEY_P, + + /** + * The Q key + */ + KEY_Q, + + /** + * The R key + */ + KEY_R, + + /** + * The S key + */ + KEY_S, + + /** + * The T key + */ + KEY_T, + + /** + * The U key + */ + KEY_U, + + /** + * The V key + */ + KEY_V, + + /** + * The W key + */ + KEY_W, + + /** + * The Y key + */ + KEY_Y, + + /** + * The X key + */ + KEY_X, + + /** + * The Z key + */ + KEY_Z, + + /** + * The backspace key + */ + KEY_BACKSPACE, + + /** + * The comma key + */ + KEY_COMMA, + + /** + * The enter key + */ + KEY_ENTER, + + /** + * The Caps Lock key + */ + KEY_CAPSLOCK, + + /** + * The Question key + */ + KEY_QUESTION, + + /** + * The Alt key + */ + KEY_ALT, + + /** + * The Language Symbol key + */ + KEY_SYM, + + /** + * The Language Setting key + */ + KEY_SETTING, + + /** + * The Space key + */ + KEY_SPACE, + + /** + * The Dot key + */ + KEY_DOT, + + /** + * The Function key + */ + KEY_FN, + + /** + * The camera half shutter key + */ + KEY_CAMERA_HALF_SHUTTER, + + /** + * The Character symbol 1 key + */ + KEY_CHAR_SYM_1, + + /** + * The Character symbol 2 key + */ + KEY_CHAR_SYM_2, + + /** + * The Character symbol 3 key + */ + KEY_CHAR_SYM_3, + + /** + * The Character symbol 4 key + */ + KEY_CHAR_SYM_4, + + /** + * The Character symbol 5 key + */ + KEY_CHAR_SYM_5, + + /** + * The Character symbol 6 key + */ + KEY_CHAR_SYM_6, + + /** + * The Character symbol 7 key + */ + KEY_CHAR_SYM_7, + + /** + * The Character symbol 8 key + */ + KEY_CHAR_SYM_8, + + /** + * The Character symbol 9 key + */ + KEY_CHAR_SYM_9, + + /** + * The Character symbol A key + */ + KEY_CHAR_SYM_A, + + /** + * The Character symbol B key + */ + KEY_CHAR_SYM_B, + + /** + * The Character symbol C key + */ + KEY_CHAR_SYM_C, + + /** + * The Character symbol D key + */ + KEY_CHAR_SYM_D, + + /** + * The Character symbol E key + */ + KEY_CHAR_SYM_E, + + /** + * The Character symbol F key + */ + KEY_CHAR_SYM_F, + + /** + * The Special function 1 key + */ + KEY_FN_1, + + /** + * The Special function 2 key + */ + KEY_FN_2, + + /** + * The Special function 3 key + */ + KEY_FN_3, + + /** + * The Special function 4 key + */ + KEY_FN_4, + + /** + * The Special function 5 key + */ + KEY_FN_5, + + /** + * The power key + */ + KEY_POWER_HOLD, + + /** + * The delete key + */ + KEY_DELETE, + + /* + * placeholder key + */ + KEY_HARDWARE_MAX +}; + + +/** + * @enum KeyState + * + * Defines the state of the key. + * + * @since 2.0 + */ +enum KeyState +{ + KEY_PRESSED = 0x0001, /**< The key is pressed */ + KEY_RELEASED = 0x0002, /**< The key is released */ + KEY_LONGPRESSED = 0x0003 /**< The key pressed and held down over a predefined duration */ +}; + +/** + * @interface IKeyEventListener + * @brief This interface implements the listener for the key event. + * + * @since 2.0 + * + * @remarks Use the ITextEventListener interface to listen to key events related to the virtual keypad used with EditField and EditArea. + * + * The %IKeyEventListener interface is the listener interface for receiving key events, which are fired when hardware keyboard keys are pressed or + * released. The class that processes a key event implements this interface, and the instance created with that class is + * registered with a UI control, using the control's AddKeyEventListener() method. When the key event occurs, a method of that + * instance is invoked. + * + * For more information on the class features, see Event Listeners. + * + * + */ +class _OSP_EXPORT_ IKeyEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + * + */ + virtual ~IKeyEventListener(void) {} + + /** + * Called when a key is pressed. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] keyCode The key code + */ + virtual void OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode) = 0; + + /** + * Called when a key is released. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] keyCode The key code + */ + virtual void OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode) = 0; + + /** + * Called when a key is pressed and held down for some time. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] keyCode The key code + * @remarks The key long pressed event is fired after the key pressed event is initially generated. + */ + virtual void OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IKeyEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IKeyEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IKeyEventListener_Reserved3(void) {} + +}; // IKeyEventListener + +}} // Tizen::Ui + +#endif //_FUI_IKEY_EVENT_LISTENER_H_ diff --git a/inc/FUiIKeypadEventListener.h b/inc/FUiIKeypadEventListener.h new file mode 100644 index 0000000..6871ec1 --- /dev/null +++ b/inc/FUiIKeypadEventListener.h @@ -0,0 +1,181 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiIKeypadEventListener.h + * @brief This is the header file for the %IKeypadEventListener interface. + * + * This header file contains the declarations of the %IKeypadEventListener interface. + */ +#ifndef _FUI_IKEYPAD_EVENT_LISTENER_H_ +#define _FUI_IKEYPAD_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Graphics +{ +class Dimension; +}} // Tizen::Graphics + +// Namespace declaration +namespace Tizen { namespace Ui +{ + +class Control; + +/** + * @enum KeypadAction + * + * Defines the possible keypad action types. + * + * @since 2.0 + */ +enum KeypadAction +{ + KEYPAD_ACTION_ENTER, /**< The Enter key */ + KEYPAD_ACTION_GO, /**< The Go key */ + KEYPAD_ACTION_NEXT, /**< The Next key */ + KEYPAD_ACTION_SEND, /**< The Send key */ + KEYPAD_ACTION_SEARCH, /**< The Search key */ + KEYPAD_ACTION_LOGIN, /**< The Login key */ + KEYPAD_ACTION_SIGN_IN, /**< The Sign-In key */ + KEYPAD_ACTION_JOIN, /**< The Join key */ + KEYPAD_ACTION_DONE /**< The Done key */ +}; + +/** + * @interface IKeypadEventListener + * @brief This interface implements the listener for the keypad events. + * + * @since 2.0 + * + * The %IKeypadEventListener interface is the listener interface for receiving software keypad events. + * The class that processes a software keypad event implements this interface, and the instance created with that class is + * registered with a UI control, using the control's AddKeypadEventListener() method. When the software keypad event occurs, a + * method of that instance is invoked. + * @n + * For more information on the class features, see EditArea and EditField, SearchBar and ExpandableEditArea. + + */ +class _OSP_EXPORT_ IKeypadEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IKeypadEventListener(void) {} + + +// Operation +public: + /** + * Called when the keypad is about to be shown on the screen. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @remarks When the software keypad appears on the screen, the client area of the current Form is adjusted to account for the space that is taken + * up by the software keypad. + * @see Tizen::Ui::Controls::Form::GetClientAreaBounds() + */ + virtual void OnKeypadWillOpen(Tizen::Ui::Control& source) = 0; + + /** + * Called when the keypad is shown on the screen. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @remarks When the software keypad appears on the screen, the client area of the current Form is adjusted to account for the space that is taken + * up by the software keypad. + * @see Tizen::Ui::Controls::Form::GetClientAreaBounds() + */ + virtual void OnKeypadOpened(Tizen::Ui::Control& source) = 0; + + /** + * Called when the keypad is hidden from the screen. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @see Tizen::Ui::Controls::Form::GetClientAreaBounds() + */ + virtual void OnKeypadClosed(Tizen::Ui::Control& source) = 0; + + /** + * Called when the keypad action button is pressed. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] keypadAction The keypad action + * @see KeypadAction + */ + virtual void OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction) = 0; + + /** + * Called when the keypad bounds are changed, for instance when the predictive text window which is located in the upper side of the keypad is shown. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @see Tizen::Ui::Controls::Form::GetClientAreaBounds() + */ + virtual void OnKeypadBoundsChanged(Tizen::Ui::Control& source) {}; + +// Reserves +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IKeypadEventListener_Reserved1(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IKeypadEventListener_Reserved2(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IKeypadEventListener_Reserved3(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IKeypadEventListener_Reserved4(void) { } +}; // IKeypadEventListener +}} // Tizen::Ui + +#endif // _FUI_IKEYPAD_EVENT_LISTENER_H_ diff --git a/inc/FUiILanguageEventListener.h b/inc/FUiILanguageEventListener.h new file mode 100644 index 0000000..102fd1f --- /dev/null +++ b/inc/FUiILanguageEventListener.h @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiILanguageEventListener.h + * @brief This is the header file for the %ILanguageEventListener class. + * + * This header file contains the declarations of the %ILanguageEventListener class. + */ + +#ifndef _FUI_ILANGUAGE_EVENT_LISTENER_H_ +#define _FUI_ILANGUAGE_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen {namespace Ui +{ + +class Control; + +/** + * @interface ILanguageEventListener + * @brief This interface implements the listener for the language event. + * + * @since 2.0 + * + * The %ILanguageEventListener interface receives language events. The class that processes a language event + * implements this interface, and the instance created with that class is registered with a UI control, using the control's + * AddLanguageEventListener() method. + * + * When the current input language is changed (for example, when the user toggles the input language from the virtual + * keypad, the listener's OnLanguageChanged() method is invoked. + */ + +class _OSP_EXPORT_ ILanguageEventListener + : public Tizen::Base::Runtime::IEventListener +{ + +// Operation + +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + ILanguageEventListener(void) {}; + + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ILanguageEventListener(void) {} + + /** + * Called when the input language is changed. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] oldLanguage The previous input language + * @param[in] newLanguage The current input language + */ + virtual void OnLanguageChanged(const Tizen::Ui::Control& source, Tizen::Locales::LanguageCode oldLanguage, Tizen::Locales::LanguageCode newLanguage) = 0; + +// Reserves +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ILanguageEventListener_Reserved1(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ILanguageEventListener_Reserved2(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ILanguageEventListener_Reserved3(void) { } +}; // ILanguageEventListener + +}} // Tizen::Ui + +#endif diff --git a/inc/FUiIOrientationEventListener.h b/inc/FUiIOrientationEventListener.h new file mode 100644 index 0000000..d2701e1 --- /dev/null +++ b/inc/FUiIOrientationEventListener.h @@ -0,0 +1,136 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIOrientationEventListener.h + * @brief This is the header file for the %IOrientationEventListener interface. + * + * This header file contains the declarations of the %IOrientationEventListener interface. @n + * If an orientation event is generated, a method of this class is called. @n + * So, if an application performs tasks related to the orientation event, use the methods of this class. + * + */ + +#ifndef _FUI_IORIENTATION_EVENT_LISTENER_H_ +#define _FUI_IORIENTATION_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui +{ +class Control; + +/** + * @enum Orientation + * + * Defines the constants used to identify the orientations that a control supports. + * + * @since 2.0 + */ +enum Orientation +{ + ORIENTATION_NONE, /**< The control has no orientation style */ + ORIENTATION_PORTRAIT, /**< The control has vertical orientation style */ + ORIENTATION_LANDSCAPE, /**< The control has horizontal orientation style */ + ORIENTATION_PORTRAIT_REVERSE, /**< The control has vertical upside-down orientation style */ + ORIENTATION_LANDSCAPE_REVERSE, /**< The control has horizontal reverse orientation style */ + ORIENTATION_AUTOMATIC = 6, /**< The control has vertical, horizontal, and horizontal reverse orientation styles */ + ORIENTATION_AUTOMATIC_FOUR_DIRECTION = 8, /**< The control has four-directional orientation style */ +}; + +/** + * @enum OrientationStatus + * + * Defines the constants used to identify the current orientation of a control. + * + * @since 2.0 + */ +enum OrientationStatus +{ + ORIENTATION_STATUS_NONE = 0, /**< The control orientation status is not determined @if OSPCOMPAT @b Since: @b 2.0 @endif */ + ORIENTATION_STATUS_PORTRAIT = ORIENTATION_PORTRAIT, /**< The control is set to vertical orientation */ + ORIENTATION_STATUS_LANDSCAPE = ORIENTATION_LANDSCAPE, /**< The control is set to horizontal orientation */ + ORIENTATION_STATUS_PORTRAIT_REVERSE = ORIENTATION_PORTRAIT_REVERSE, /**< The control is set to vertical upside-down orientation */ + ORIENTATION_STATUS_LANDSCAPE_REVERSE = ORIENTATION_LANDSCAPE_REVERSE, /**< The control is set to horizontal reverse orientation */ +}; + +/** + * @interface IOrientationEventListener + * @brief This interface implements the listener for orientation events. + * + * @since 2.0 + * + * The %IOrientationEventListener interface is the listener interface for receiving orientation events. + * The class that processes an orientation event implements this interface, and the instance created with that class is registered + * with a UI control, using the control's AddOrientationEventListener() method. When the orientation event occurs, the + * OnOrientationChanged() method of that instance is invoked. + * @n + * For more information on the class features, see Form. + */ +class _OSP_EXPORT_ IOrientationEventListener + : public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IOrientationEventListener(void) {} + + /** + * Called when an orientation event occurs. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] orientationStatus The information about the orientation event + * @remarks The orientation changed event is fired on %Control for which orientation mode change has been enabled by calling SetOrientation(). + * @see Tizen::Ui::Controls::Frame + * @see Tizen::Ui::Controls::Form + */ + virtual void OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IOrientationEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IOrientationEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IOrientationEventListener_Reserved3(void) {} +}; // IOrientationEventListener + +}} // Tizen::Ui + +#endif // _FUI_IORIENTATION_EVENT_LISTENER_H_ diff --git a/inc/FUiIScrollPanelEventListener.h b/inc/FUiIScrollPanelEventListener.h new file mode 100644 index 0000000..ab0291f --- /dev/null +++ b/inc/FUiIScrollPanelEventListener.h @@ -0,0 +1,145 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIScrollPanelEventListener.h + * @brief This is the header file for the %IScrollPanelEventListener interface. + * + * This header file contains the declarations of the %IScrollPanelEventListener interface. @n + * If a change event is generated, a method of this interface is called. @n + * Applications that do jobs related to change events call the methods of this interface. + * + */ +#ifndef _FUI_ISCROLL_PANEL_EVENT_LISTENER_H_ +#define _FUI_ISCROLL_PANEL_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen {namespace Ui +{ + +/** + * @interface IScrollPanelEventListener + * @brief This interface implements a listener for %ScrollPanel events. + * + * @since 2.0 + * + * The %IScrollPanelEventListener interface is the listener interface for receiving change events related to controls (especially an overlay keypad) within the + * ScrollPanel. The class that processes a change event implements this interface, and the instance created with that class is + * registered with a UI control, using the control's AddScrollPanelEventListener() method. When the change event occurs, a method + * of that instance is invoked. + * @n + * For more information on the class features, see Panels and Using EditArea or EditField Overlay Keypad with ScrollPanel. + + */ +class _OSP_EXPORT_ IScrollPanelEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IScrollPanelEventListener(void) {} + + /** + * Called when an overlay keypad is created on the ScrollPanel control. + * + * @since 2.0 + * + * @param[in] source The source of the event + */ + virtual void OnOverlayControlCreated(const Tizen::Ui::Control& source) = 0; + + /** + * Called when an overlay keypad is opened on the ScrollPanel control. + * + * @since 2.0 + * + * @param[in] source The source of the event + */ + virtual void OnOverlayControlOpened(const Tizen::Ui::Control& source) = 0; + + /** + * Called when an overlay keypad is closed on the ScrollPanel control. + * + * @since 2.0 + * + * @param[in] source The source of the event + */ + virtual void OnOverlayControlClosed(const Tizen::Ui::Control& source) = 0; + + /** + * Called when a control is selected on the ScrollPanel control . + * + * @since 2.0 + * + * @param[in] source The source of the event + */ + virtual void OnOtherControlSelected(const Tizen::Ui::Control& source) = 0; + + // Reserves +protected: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IScrollPanelEventListener_Reserved1(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IScrollPanelEventListener_Reserved2(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void IScrollPanelEventListener_Reserved3(void) { } + +}; // IScrollPanelEventListener + + +}} // Tizen::Ui + +#endif // _FUI_ISCROLL_PANEL_EVENT_LISTENER_H_ diff --git a/inc/FUiISlidableGroupedListEventListener.h b/inc/FUiISlidableGroupedListEventListener.h new file mode 100644 index 0000000..9c22671 --- /dev/null +++ b/inc/FUiISlidableGroupedListEventListener.h @@ -0,0 +1,131 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiISlidableGroupedListEventListener.h + * @brief This is the header file for the %ISlidableGroupedListEventListener interface. + * + * This header file contains the declarations of the %ISlidableGroupedListEventListener interface. @n + * If an event is generated, a method of this class is called. @n + * So, if an application performs tasks related to item events, it uses the methods of this class. + * + */ +#ifndef _FUI_ISLIDABLE_GROUPED_LIST_EVENT_LISTENER_H_ +#define _FUI_ISLIDABLE_GROUPED_LIST_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui +{ + +/** + * @if OSPDEPREC + * @interface ISlidableGroupedListEventListener + * @brief [Deprecated] This interface implements the listener for events on SlidableGroupedList. + * @deprecated This class is deprecated. Instead of using this class, use IGroupedListViewItemEventListener class. + * @since 2.0 + * + * The %ISlidableGroupedListEventListener interface implements a listener for receiving scroll events on %SlidableGroupedList. @n + * The role of this interface is similar to ISlidableListEventListener. + * The class is registered with a %SlidableGroupedList, using the control's AddSlidableGroupedListEventListener() method. + * @endif + */ +class _OSP_EXPORT_ ISlidableGroupedListEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * @if OSPDEPREC + * This is the destructor for this class. + * + * @brief [Deprecated] This interface implements the listener for events on SlidableGroupedList. + * @deprecated This class is deprecated. Instead of using this class, use IGroupedListViewItemEventListener class. + * @since 2.0 + * @endif + */ + virtual ~ISlidableGroupedListEventListener(void) {} + + /** + * @if OSPDEPREC + * Called when the %SlidableGroupedList is about to be drawn and requests the listener to set the properties of the list such as the total height and the + * number of items in each group. + * + * @brief [Deprecated] This interface implements the listener for events on SlidableGroupedList. + * @deprecated This class is deprecated. Instead of using this class, use IGroupedListViewItemEventListener class. + * @since 2.0 + * @param[in] source The source of the event + * @endif + */ + virtual void OnListPropertyRequested(const Tizen::Ui::Control& source) = 0; + + /** + * @if OSPDEPREC + * Called when the items need to be loaded to the top. + * + * @brief [Deprecated] This interface implements the listener for events on SlidableGroupedList. + * @deprecated This class is deprecated. Instead of using this class, use IGroupedListViewItemEventListener class. + * @since 2.0 + * @param[in] source The source of the event + * @param[in] groupIndex The index of the list group + * @param[in] itemIndex The index of the list item in the specified group + * @param[in] numItems The number of items + * @endif + */ + virtual void OnLoadToTopRequested(const Tizen::Ui::Control& source, int groupIndex, int itemIndex, int numItems) = 0; + + /** + * @if OSPDEPREC + * Called when the items need to be loaded to the bottom. + * + * @brief [Deprecated] This interface implements the listener for events on SlidableGroupedList. + * @deprecated This class is deprecated. Instead of using this class, use IGroupedListViewItemEventListener class. + * @since 2.0 + * @param[in] source The source of the event + * @param[in] groupIndex The index of the list group + * @param[in] itemIndex The index of the list item in the specified group + * @param[in] numItems The number of items + * @endif + */ + virtual void OnLoadToBottomRequested(const Tizen::Ui::Control& source, int groupIndex, int itemIndex, int numItems) = 0; + + /** + * @if OSPDEPREC + * Called when an item is about to be unloaded from memory. @n + * The user-allocated resources associated with the item to be unloaded need to be freed when OnUnloadItemRequested() is called. + * + * @brief [Deprecated] This interface implements the listener for events on SlidableGroupedList. + * @deprecated This class is deprecated. Instead of using this class, use IGroupedListViewItemEventListener class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] groupIndex The index of the list group + * @param[in] itemIndex The index of the list item in the specified group + * @endif + */ + virtual void OnUnloadItemRequested(const Tizen::Ui::Control& source, int groupIndex, int itemIndex) = 0; + +}; //ISlidableGroupedListEventListener + +}} //Tizen::Ui + +#endif // _FUI_ISLIDABLE_GROUPED_LIST_EVENT_LISTENER_H_ diff --git a/inc/FUiISlidableListEventListener.h b/inc/FUiISlidableListEventListener.h new file mode 100644 index 0000000..3674979 --- /dev/null +++ b/inc/FUiISlidableListEventListener.h @@ -0,0 +1,131 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiISlidableListEventListener.h + * @brief This is the header file for the %ISlidableListEventListener interface. + * + * This header file contains the declarations of the %ISlidableListEventListener interface. @n + * If the event is generated, a method of this class is called. @n + * So, if applications do jobs related to item events, use the methods of this class. + * + */ +#ifndef _FUI_ISLIDABLE_LIST_EVENT_LISTENER_H_ +#define _FUI_ISLIDABLE_LIST_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui +{ + +/** + * @if OSPDEPREC + * @interface ISlidableListEventListener + * @brief [Deprecated] This interface implements the listener for events on %SlidableList. + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * + * + * The %ISlidableListEventListener interface implements a listener for receiving scroll events on SlidableList. This listener is implemented + * to allow the application to load the items as needed, as the user scrolls through the list. + * The class is registered with a SlidableList, using the control's AddSlidableListEventListener() method. + * @endif + */ +class _OSP_EXPORT_ ISlidableListEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * @if OSPDEPREC + * This is the destructor for this class. + * + * @brief [Deprecated] This interface implements the listener for events on %SlidableList. + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * @endif + */ + virtual ~ISlidableListEventListener(void) {} + + /** + * @if OSPDEPREC + * Called when the slidable list is about to be drawn and requests to set the properties of the list such as the total height. + * + * @brief [Deprecated] This interface implements the listener for events on %SlidableList. + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * + * @param[in] source The source of the event + * @endif + */ + virtual void OnListPropertyRequested(const Tizen::Ui::Control& source) = 0; + + /** + * @if OSPDEPREC + * Called when the items need to be loaded to the top. + * + * @brief [Deprecated] This interface implements the listener for events on %SlidableList. + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] index The index of the item + * @param[in] numItems The number of items + * @endif + */ + virtual void OnLoadToTopRequested(const Tizen::Ui::Control& source, int index, int numItems) = 0; + + /** + * @if OSPDEPREC + * Called when the items need to be loaded to the bottom. + * + * @brief [Deprecated] This interface implements the listener for events on %SlidableList. + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] index The index of the item + * @param[in] numItems The number of items + * @endif + */ + virtual void OnLoadToBottomRequested(const Tizen::Ui::Control& source, int index, int numItems) = 0; + + /** + * @if OSPDEPREC + * Called when an item is about to be unloaded from memory. @n + * The user-allocated resources associated with the item must be freed before unloading, when OnUnloadItemRequested() is called. + * + * @brief [Deprecated] This interface implements the listener for events on %SlidableList. + * @deprecated This class is deprecated. Instead of using this class, use IListViewItemEventListener class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] index The index of the item + * @endif + */ + virtual void OnUnloadItemRequested(const Tizen::Ui::Control& source, int index) = 0; + +}; //ISlidableListEventListener + +}} //Tizen::Ui + +#endif // _FUI_ISLIDABLE_LIST_EVENT_LISTENER_H_ diff --git a/inc/FUiITextBlockEventListener.h b/inc/FUiITextBlockEventListener.h new file mode 100644 index 0000000..07e034a --- /dev/null +++ b/inc/FUiITextBlockEventListener.h @@ -0,0 +1,125 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiITextBlockEventListener.h + * @brief This is the header file for the %ITextBlockEventListener interface. + * + * This header file contains the declarations of the %ITextBlockEventListener interface. + */ +#ifndef _FUI_ITEXT_BLOCK_EVENT_LISTENER_H_ +#define _FUI_ITEXT_BLOCK_EVENT_LISTENER_H_ + +// Includes +#include + +// Forward declaration +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +// Namespace declaration +namespace Tizen { namespace Ui +{ +/** + * @interface ITextBlockEventListener + * @brief This interface implements the listener for the text block events. + * + * @since 2.0 + * + * The %ITextBlockEventListener interface is the listener interface for receiving text block selection events, for example, from EditFields. + * The class that processes a text block selection event implements this interface, and the instance created with that class is + * registered with a UI control, using the control's AddTextBlockEventListener() method. When the text block selection event + * occurs, the OnTextBlockSelected() method of that instance is invoked. + * + * For more information on the class features, see EditArea and EditField. + + */ +class _OSP_EXPORT_ ITextBlockEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ITextBlockEventListener(void) {} + + +// Operation +public: + /** + * Called when a text block is selected. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] start The start index of the selected text block + * @param[in] end The end index of the selected text block + */ + virtual void OnTextBlockSelected(Tizen::Ui::Control& source, int start, int end) = 0; + + +// Reserves +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ITextBlockEventListener_Reserved1(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ITextBlockEventListener_Reserved2(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ITextBlockEventListener_Reserved3(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ITextBlockEventListener_Reserved4(void) { } + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ITextBlockEventListener_Reserved5(void) { } +}; // ITextBlockEventListener + +}} //Tizen::Ui + +#endif // _FUI_ITEXT_BLOCK_EVENT_LISTENER_H_ diff --git a/inc/FUiITextEventListener.h b/inc/FUiITextEventListener.h new file mode 100644 index 0000000..3b2130c --- /dev/null +++ b/inc/FUiITextEventListener.h @@ -0,0 +1,120 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiITextEventListener.h + * @brief This is the header file for the %ITextEventListener interface. + * + * This header file contains the declarations of the %ITextEventListener interface. @n + * If a change event is generated, a method of this interface is called. @n + * So, if the applications perform tasks related to change events, use the methods of this interface. + * + */ +#ifndef _FUI_ITEXT_EVENT_LISTENER_H_ +#define _FUI_ITEXT_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen {namespace Ui +{ + +/** + * @interface ITextEventListener + * @brief This interface implements the listener for text events. + * + * @since 2.0 + * + * The %ITextEventListener interface is the listener interface for receiving text events, for example, from EditFields. + * The class that processes a text event implements this interface, and the instance created with that class is registered with a + * UI control, using the control's AddTextEventListener() method. When the text event occurs, the OnTextValueChanged() method of + * that instance is invoked. + * + * For more information on the class features, see EditArea and EditField, ExpandableEditArea, TextBox, and SearchBar. + + */ +class ITextEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~ITextEventListener(void) {} + + /** + * Called when a text is changed. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @remarks For EditField or EditArea with INPUT_STYLE_FULLSCREEN input style, this listener method is invoked when the user presses "Done" + * soft-key. Whereas, for %EditField or %EditArea with INPUT_STYLE_OVERLAY input style, this method is called whenever the user presses a + * key. + * @remarks Note that when a non-character key is pressed, OnTextValueChanged() callback is invoked. + */ + virtual void OnTextValueChanged(const Tizen::Ui::Control& source) = 0; + + /** + * Called when a change made to the text is canceled. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @remarks This listener method is called when the user presses "Cancel" soft-key for EditField or EditArea with INPUT_STYLE_FULLSCREEN input + * style. + */ + virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source) = 0; + +// Reserves +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ITextEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ITextEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void ITextEventListener_Reserved3(void) {} +}; // ITextEventListener + +}} // Tizen::Ui + +#endif // _FUI_ITEXT_EVENT_LISTENER_H_ diff --git a/inc/FUiITimeChangeEventListener.h b/inc/FUiITimeChangeEventListener.h new file mode 100644 index 0000000..4051676 --- /dev/null +++ b/inc/FUiITimeChangeEventListener.h @@ -0,0 +1,125 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiITimeChangeEventListener.h + * @brief This is the header file for the %ITimeChangeEventListener interface. + * + * This header file contains the declarations of the %ITimeChangeEventListener interface. @n + * If a change event is generated, a method of this class is called. @n + * So, for tasks related to change events, use the methods of this class. + * + */ +#ifndef _FUI_ITIME_CHANGE_EVENT_LISTENER_H_ +#define _FUI_ITIME_CHANGE_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui +{ + +/** + * @interface ITimeChangeEventListener + * @brief This interface implements the listener for the time change events. + * + * @since 2.0 + * + * The %ITimeChangeEventListener interface is the listener interface for receiving time change events. + * The class that processes a time change event implements this interface, and the instance created with that class is registered + * with a UI control, using the control's AddTimeChangeEventListener() method. When the time change event occurs, the + * OnTimeChanged() method of that instance is invoked. + * + * For more information on the class features, see EditDate and EditTime and DatePicker, TimePicker, and DateTimePicker. + + */ +class _OSP_EXPORT_ ITimeChangeEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~ITimeChangeEventListener(void) {} + + /** + * Called when there is a change in time. @n + * The changed hour and minute values are passed as input parameters. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] hour The hour + * @param[in] minute The minute + */ + virtual void OnTimeChanged(const Tizen::Ui::Control& source, int hour, int minute) = 0; + + /** + * Called when a time change is canceled. + * + * @since 2.0 + * + * @param[in] source The source of the event + */ + virtual void OnTimeChangeCanceled(const Tizen::Ui::Control& source) = 0; + +protected: + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // The following method is reserved, and their names can be changed + // at any time without prior notice. + // + // @since 2.0 + // + virtual void ITimeChangeEventListener_Reserved1(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // The following method is reserved, and their names can be changed + // at any time without prior notice. + // + // @since 2.0 + // + virtual void ITimeChangeEventListener_Reserved2(void) {} + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // The following method is reserved, and their names can be changed + // at any time without prior notice. + // + // @since 2.0 + // + virtual void ITimeChangeEventListener_Reserved3(void) {} +}; // ITimeChangeEventListener + +}} // Tizen::Ui + +#endif // _FUI_ITIME_CHANGE_EVENT_LISTENER_H_ diff --git a/inc/FUiITouchCustomGestureEventListener.h b/inc/FUiITouchCustomGestureEventListener.h new file mode 100644 index 0000000..0309340 --- /dev/null +++ b/inc/FUiITouchCustomGestureEventListener.h @@ -0,0 +1,122 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiITouchCustomGestureEventListener.h +* @brief This is the header file for the %ITouchCustomGestureEventListener interface. +* +* This header file contains the declarations of the %ITouchCustomGestureEventListener interface. +*/ + +#ifndef _FUI_ITOUCH_CUSTOM_GESTURE_EVENT_LISTENER_H_ +#define _FUI_ITOUCH_CUSTOM_GESTURE_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui +{ + +/** + * @class ITouchCustomGestureEventListener + * @brief This interface is used as the argument to the touch custom gesture event listener. + * @since 2.0 + * + * The %ITouchCustomGestureEventListener interface is the listener interface for receiving custom gesture events. + * The class that processes a custom gesture event implements this interface, and the instance created with that class is registered with a + * gesture detector, using the gesture detector's AddGestureEventListener() method. When the custom gesture event occurs, a method of that instance is + * invoked. + * + */ +class _OSP_EXPORT_ ITouchCustomGestureEventListener + : virtual public ITouchGestureEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ITouchCustomGestureEventListener(void) {} + + /** + * Called when a custom gesture detection is started. + * + * @since 2.0 + * + * @param[in] gestureDetector The custom gesture detector instance + */ + virtual void OnCustomGestureStarted(Tizen::Ui::TouchGestureDetector& gestureDetector) = 0; + + /** + * Called when a custom gesture is detected and is in progress. + * + * @since 2.0 + * + * @param[in] gestureDetector The custom gesture detector instance + */ + virtual void OnCustomGestureChanged(Tizen::Ui::TouchGestureDetector& gestureDetector) = 0; + + /** + * Called when a custom gesture detection is finished. + * + * @since 2.0 + * + * @param[in] gestureDetector The custom gesture detector instance + */ + virtual void OnCustomGestureFinished(Tizen::Ui::TouchGestureDetector& gestureDetector) = 0; + + /** + * Called when a custom gesture detection is canceled. + * + * @since 2.0 + * + * @param[in] gestureDetector The custom gesture detector instance + */ + virtual void OnCustomGestureCanceled(Tizen::Ui::TouchGestureDetector& gestureDetector) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchCustomGestureEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchCustomGestureEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchCustomGestureEventListener_Reserved3(void) {} +}; // ITouchCustomGestureEventListener + +}} // Tizen::Ui + +#endif // _FUI_ITOUCH_CUSTOM_GESTURE_EVENT_LISTENER_H_ diff --git a/inc/FUiITouchEventListener.h b/inc/FUiITouchEventListener.h new file mode 100644 index 0000000..f230acf --- /dev/null +++ b/inc/FUiITouchEventListener.h @@ -0,0 +1,193 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiITouchEventListener.h +* @brief This is the header file for the %ITouchEventListener interface. +* +* This header file contains the declarations of the %ITouchEventListener interface. +*/ + +#ifndef _FUI_ITOUCH_EVENT_LISTENER_H_ +#define _FUI_ITOUCH_EVENT_LISTENER_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ + +class Control; + +/** + * @interface ITouchEventListener + * @brief This interface is used as the argument to the touch event listener. + * + * @since 2.0 + * + * The %ITouchEventListener interface is the listener interface for receiving touch events. + * The class that processes a touch event implements this interface, and the instance created with that class is registered with a + * UI control, using the control's AddTouchEventListener() method. When the touch event occurs, a method of that instance is + * invoked. + * @n + * For more information on the class features, see Event Listeners. + */ +class _OSP_EXPORT_ ITouchEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + * + */ + virtual ~ITouchEventListener(void) {} + + /** + * Called when an entity is touch pressed. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo & touchInfo) = 0; + + /** + * @if OSPDEPREC + * Called when an entity is touched and held for a long time. + * + * @brief [Deprecated] + * @deprecated This callback is deprecated. + * If you want to listen to "long press" touch event, it is recommended to use TouchLongPressGestureDetector class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + * @endif + */ + virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + + /** + * Called when an entity is touch released. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) = 0; + + /** + * Called when an entity is touch moved. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) = 0; + + /** + * @if OSPDEPREC + * Called when an entity is touched and double-pressed. + * + * @brief [Deprecated] + * @deprecated This callback is deprecated. + * If you want to listen to "double press" touch event, it is recommended to use TouchTapGestureDetector class. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + * @endif + */ + virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + + /** + * Called when the user has touched down on a control, drags finger out of control's bounds, and then drags finger back in to the control's bounds. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) = 0; + + /** + * Called when the user touches down on a control and drags finger out of control's bounds + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) = 0; + + /** + * Called when the touch is canceled. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual void OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {} + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchEventListener_Reserved3(void) {} + +}; // ITouchEventListener + +}} // Tizen::Ui + +#endif // _FUI_ITOUCH_EVENT_LISTENER_H_ diff --git a/inc/FUiITouchFlickGestureEventListener.h b/inc/FUiITouchFlickGestureEventListener.h new file mode 100644 index 0000000..df3f7ce --- /dev/null +++ b/inc/FUiITouchFlickGestureEventListener.h @@ -0,0 +1,105 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiITouchFlickGestureEventListener.h + * @brief This is the header file for the %ITouchFlickGestureEventListener interface. + * + * This header file contains the declarations of the %ITouchFlickGestureEventListener interface. + */ + +#ifndef _FUI_ITOUCH_FLICK_GESTURE_EVENT_LISTENER_H_ +#define _FUI_ITOUCH_FLICK_GESTURE_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +/** + * @class ITouchFlickGestureEventListener + * @brief This interface implements the listener for the touch flick gesture events. + * @since 2.0 + * + * The %ITouchFlickGestureEventListener interface is the listener interface for receiving flick gesture events. + * The class that processes a flick gesture event implements this interface, and the instance created with that class is registered with a + * flick gesture detector, using the gesture detector's AddFlickGestureEventListener() method. When the flick gesture event occurs, a method of that instance is + * invoked. + * + */ +class _OSP_EXPORT_ ITouchFlickGestureEventListener + : virtual public ITouchGestureEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ITouchFlickGestureEventListener(void) {} + + /** + * Called when a flick gesture is detected. + * + * @since 2.0 + * + * @param[in] gestureDetector The flick gesture detector instance + */ + virtual void OnFlickGestureDetected(Tizen::Ui::TouchFlickGestureDetector& gestureDetector) = 0; + + /** + * Called when a flick gesture detection is canceled. + * + * @since 2.0 + * + * @param[in] gestureDetector The flick gesture detector instance + */ + virtual void OnFlickGestureCanceled(Tizen::Ui::TouchFlickGestureDetector& gestureDetector) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchFlickGestureEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchFlickGestureEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchFlickGestureEventListener_Reserved3(void) {} +}; // ITouchFlickGestureEventListener + +}} // Tizen::Ui + +#endif // _FUI_ITOUCH_FLICK_GESTURE_EVENT_LISTENER_H_ diff --git a/inc/FUiITouchGestureEventListener.h b/inc/FUiITouchGestureEventListener.h new file mode 100644 index 0000000..0218a11 --- /dev/null +++ b/inc/FUiITouchGestureEventListener.h @@ -0,0 +1,86 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiITouchGestureEventListener.h + * @brief This is the header file for the %ITouchGestureEventListener interface. + * + * This header file contains the declarations of the %ITouchGestureEventListener interface. + */ + +#ifndef _FUI_ITOUCH_GESTURE_EVENT_LISTENER_H_ +#define _FUI_ITOUCH_GESTURE_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui +{ + +/** + * @class ITouchGestureEventListener + * @brief This is a base interface that all gesture event listeners must implement. + * + * @since 2.0 + * + * The %ITouchGestureEventListener interface is a base interface that all gesture event listeners must implement. + * The event listener can listen when the specific event occurs. The event listener + * has several methods, and each method is called when a specific event occurs. + * + */ +class _OSP_EXPORT_ ITouchGestureEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ITouchGestureEventListener(void) {} + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchGestureEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchGestureEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchGestureEventListener_Reserved3(void) {} +}; // ITouchGestureEventListener + +}} // Tizen::Ui + +#endif // _FUI_ITOUCH_GESTURE_EVENT_LISTENER_H_ diff --git a/inc/FUiITouchLongPressGestureEventListener.h b/inc/FUiITouchLongPressGestureEventListener.h new file mode 100644 index 0000000..3b9bcf3 --- /dev/null +++ b/inc/FUiITouchLongPressGestureEventListener.h @@ -0,0 +1,106 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiITouchLongPressGestureEventListener.h + * @brief This is the header file for the %ITouchLongPressGestureEventListener interface. + * + * This header file contains the declarations of the %ITouchLongPressGestureEventListener interface. + */ + +#ifndef _FUI_ITOUCH_LONG_PRESS_GESTURE_EVENT_LISTENER_H_ +#define _FUI_ITOUCH_LONG_PRESS_GESTURE_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +/** + * @class ITouchLongPressGestureEventListener + * @brief This interface implements the listener for the touch long press gesture events. + * + * @since 2.0 + * + * The %ITouchLongPressGestureEventListener interface is the listener interface for receiving long press gesture events. + * The class that processes a long press gesture event implements this interface, and the instance created with that class is registered with a + * long press gesture detector, using the gesture detector's AddLongPressGestureEventListener() method. When the long press gesture event occurs, a method of that instance is + * invoked. + */ +class _OSP_EXPORT_ ITouchLongPressGestureEventListener + : virtual public ITouchGestureEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~ITouchLongPressGestureEventListener(void) {} + + /** + * Called when a long press gesture is detected. + * + * @since 2.0 + * + * @param[in] gestureDetector The long press gesture detector instance + */ + virtual void OnLongPressGestureDetected(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector) = 0; + + /** + * Called when a long press detection is canceled. + * + * @since 2.0 + * + * @param[in] gestureDetector The long press gesture detector instance + */ + virtual void OnLongPressGestureCanceled(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchLongPressGestureEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchLongPressGestureEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchLongPressGestureEventListener_Reserved3(void) {} +}; // ITouchLongPressGestureEventListener + +}} // Tizen::Ui + +#endif // _FUI_ITOUCH_LONG_PRESS_GESTURE_EVENT_LISTENER_H_ diff --git a/inc/FUiITouchModeChangedEventListener.h b/inc/FUiITouchModeChangedEventListener.h new file mode 100644 index 0000000..2b0b995 --- /dev/null +++ b/inc/FUiITouchModeChangedEventListener.h @@ -0,0 +1,101 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiITouchModeChangedEventListener.h + * @brief This is the header file for the %ITouchModeChangedEventListener interface. + * + * This header file contains the declarations of the %ITouchModeChangedEventListener interface. @n + * If the touch mode of a device is changed, a method of this interface is called. + * Therefore, if an application performs tasks related to the touch mode event, use the methods of this interface. + * + */ + +#ifndef _FUI_ITOUCH_MODE_CHANGED_EVENT_LISTENER_H_ +#define _FUI_ITOUCH_MODE_CHANGED_EVENT_LISTENER_H_ + +#include + +namespace Tizen {namespace Ui +{ +class Control; + +/** + * @interface ITouchModeChangedEventListener + * @brief This interface implements the listener for the touch mode changed event. + * + * @since 2.0 + * + * The %ITouchModeChangedEventListener interface is the listener interface for receiving touch mode change events. + * @n + * For more information on the class features, see Event Listeners. + */ +class _OSP_EXPORT_ ITouchModeChangedEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ITouchModeChangedEventListener(void) {}; + + /** + * Called when an action event occurs. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] isInTouchMode The current mode + */ + virtual void OnTouchModeChanged(const Tizen::Ui::Control& source, bool isInTouchMode) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchModeChangedEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchModeChangedEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchModeChangedEventListener_Reserved3(void) {} + +}; // ITouchModeChangedEventListener + +}} // Tizen::Ui + +#endif // _FUI_ITOUCH_MODE_CHANGED_EVENT_LISTENER_H_ diff --git a/inc/FUiITouchPanningGestureEventListener.h b/inc/FUiITouchPanningGestureEventListener.h new file mode 100644 index 0000000..bf6c2f0 --- /dev/null +++ b/inc/FUiITouchPanningGestureEventListener.h @@ -0,0 +1,124 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiITouchPanningGestureEventListener.h + * @brief This is the header file for the %ITouchPanningGestureEventListener interface. + * + * This header file contains the declarations of the %ITouchPanningGestureEventListener interface. + */ +#ifndef _FUI_ITOUCH_PANNING_GESTURE_EVENT_LISTENER_H_ +#define _FUI_ITOUCH_PANNING_GESTURE_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +/** + * @class ITouchPanningGestureEventListener + * @brief This interface implements the listener for the touch panning gesture events. + * + * @since 2.0 + * + * The %ITouchPanningGestureEventListener interface is the listener interface for receiving panning gesture events. + * The class that processes a panning gesture event implements this interface, and the instance created with that class is registered with a + * panning gesture detector, using the gesture detector's AddPanningGestureEventListener() method. When the panning gesture event occurs, a method of that instance is + * invoked. + * + */ +class _OSP_EXPORT_ ITouchPanningGestureEventListener + : virtual public ITouchGestureEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ITouchPanningGestureEventListener(void) {} + + /** + * Called when a panning gesture detection is started. + * + * @since 2.0 + * + * @param[in] gestureDetector The panning gesture detector instance + */ + virtual void OnPanningGestureStarted(Tizen::Ui::TouchPanningGestureDetector& gestureDetector) = 0; + + /** + * Called when a panning gesture is detected and is in progress. + * + * @since 2.0 + * + * @param[in] gestureDetector The panning gesture detector instance + */ + virtual void OnPanningGestureChanged(Tizen::Ui::TouchPanningGestureDetector& gestureDetector) = 0; + + /** + * Called when a panning gesture detection is finished. + * + * @since 2.0 + * + * @param[in] gestureDetector The panning gesture detector instance + */ + virtual void OnPanningGestureFinished(Tizen::Ui::TouchPanningGestureDetector& gestureDetector) = 0; + + /** + * Called when a panning gesture detection is canceled. + * + * @since 2.0 + * + * @param[in] gestureDetector The panning gesture detector instance + */ + virtual void OnPanningGestureCanceled(Tizen::Ui::TouchPanningGestureDetector& gestureDetector) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchPanningGestureEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchPanningGestureEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchPanningGestureEventListener_Reserved3(void) {} +}; //ITouchPanningGestureEventListener + +}} // Tizen::Ui + +#endif //_FUI_ITOUCH_PANNING_GESTURE_EVENT_LISTENER_H_ diff --git a/inc/FUiITouchPinchGestureEventListener.h b/inc/FUiITouchPinchGestureEventListener.h new file mode 100644 index 0000000..aea1cc8 --- /dev/null +++ b/inc/FUiITouchPinchGestureEventListener.h @@ -0,0 +1,125 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiITouchPinchGestureEventListener.h + * @brief This is the header file for the %ITouchPinchGestureEventListener interface. + * + * This header file contains the declarations of the %ITouchPinchGestureEventListener interface. + */ + +#ifndef _FUI_ITOUCH_PINCH_GESTURE_EVENT_LISTENER_H_ +#define _FUI_ITOUCH_PINCH_GESTURE_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +/** + * @class ITouchPinchGestureEventListener + * @brief This interface implements the listener for the touch pinch gesture events. + * + * @since 2.0 + * + * The %ITouchPinchGestureEventListener interface is the listener interface for receiving pinch gesture events. + * The class that processes a pinch gesture event implements this interface, and the instance created with that class is registered with a + * pinch gesture detector, using the gesture detector's AddPinchGestureEventListener() method. When the pinch gesture event occurs, a method of that instance is + * invoked. + * + */ +class _OSP_EXPORT_ ITouchPinchGestureEventListener + : virtual public ITouchGestureEventListener +{ + +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ITouchPinchGestureEventListener(void) {} + + /** + * Called when a pinch gesture detection is started. + * + * @since 2.0 + * + * @param[in] gestureDetector The pinch gesture detector instance + */ + virtual void OnPinchGestureStarted(Tizen::Ui::TouchPinchGestureDetector& gestureDetector) = 0; + + /** + * Called when a pinch gesture is detected and is in progress. + * + * @since 2.0 + * + * @param[in] gestureDetector The pinch gesture detector instance + */ + virtual void OnPinchGestureChanged(Tizen::Ui::TouchPinchGestureDetector& gestureDetector) = 0; + + /** + * Called when a pinch gesture detection is finished. + * + * @since 2.0 + * + * @param[in] gestureDetector The pinch gesture detector instance + */ + virtual void OnPinchGestureFinished(Tizen::Ui::TouchPinchGestureDetector& gestureDetector) = 0; + + /** + * Called when a pinch gesture detection is canceled. + * + * @since 2.0 + * + * @param[in] gestureDetector The pinch gesture detector instance + */ + virtual void OnPinchGestureCanceled(Tizen::Ui::TouchPinchGestureDetector& gestureDetector) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchPinchGestureEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchPinchGestureEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchPinchGestureEventListener_Reserved3(void) {} +}; // ITouchPinchGestureEventListener + +}} // Tizen::Ui + +#endif // _FUI_ITOUCH_PINCH_GESTURE_EVENT_LISTENER_H_ diff --git a/inc/FUiITouchRotationGestureEventListener.h b/inc/FUiITouchRotationGestureEventListener.h new file mode 100644 index 0000000..6a53c7c --- /dev/null +++ b/inc/FUiITouchRotationGestureEventListener.h @@ -0,0 +1,124 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiITouchRotationGestureEventListener.h + * @brief This is the header file for the %ITouchRotationGestureEventListener interface. + * + * This header file contains the declarations of the %ITouchRotationGestureEventListener interface. + */ +#ifndef _FUI_ITOUCH_ROTATION_GESTURE_EVENT_LISTENER_H_ +#define _FUI_ITOUCH_ROTATION_GESTURE_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +/** + * @class ITouchRotationGestureEventListener + * @brief This interface implements the listener for the touch rotation gesture events. + * + * @since 2.0 + * + * The %ITouchRotationGestureEventListener interface is the listener interface for receiving pinch gesture events. + * The class that processes a rotation gesture event implements this interface, and the instance created with that class is registered with a + * rotation gesture detector, using the gesture detector's AddRotationGestureEventListener() method. When the rotation gesture event occurs, a method of that instance is + * invoked. + * + */ +class _OSP_EXPORT_ ITouchRotationGestureEventListener + : virtual public ITouchGestureEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ITouchRotationGestureEventListener(void) {} + + /** + * Called when a rotation gesture detection is started. + * + * @since 2.0 + * + * @param[in] gestureDetector The rotation gesture detector instance + */ + virtual void OnRotationGestureStarted(Tizen::Ui::TouchRotationGestureDetector& gestureDetector) = 0; + + /** + * Called when a rotation gesture is detected and is in progress. + * + * @since 2.0 + * + * @param[in] gestureDetector The rotation gesture detector instance + */ + virtual void OnRotationGestureChanged(Tizen::Ui::TouchRotationGestureDetector& gestureDetector) = 0; + + /** + * Called when a rotation gesture detection is finished. + * + * @since 2.0 + * + * @param[in] gestureDetector The rotation gesture detector instance + */ + virtual void OnRotationGestureFinished(Tizen::Ui::TouchRotationGestureDetector& gestureDetector) = 0; + + /** + * Called when a rotation gesture detection is canceled. + * + * @since 2.0 + * + * @param[in] gestureDetector The rotation gesture detector instance + */ + virtual void OnRotationGestureCanceled(Tizen::Ui::TouchRotationGestureDetector& gestureDetector) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchRotationGestureEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchRotationGestureEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchRotationGestureEventListener_Reserved3(void) {} +}; // ITouchRotationGestureEventListener + +}} // Tizen::Ui + +#endif //_FUI_ITOUCH_ROTATION_GESTURE_EVENT_LISTENER_H_ diff --git a/inc/FUiITouchTapGestureEventListener.h b/inc/FUiITouchTapGestureEventListener.h new file mode 100644 index 0000000..154304b --- /dev/null +++ b/inc/FUiITouchTapGestureEventListener.h @@ -0,0 +1,106 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiITouchTapGestureEventListener.h + * @brief This is the header file for the %ITouchTapGestureEventListener interface. + * + * This header file contains the declarations of the %ITouchTapGestureEventListener interface. + */ + +#ifndef _FUI_ITOUCH_TAP_GESTURE_EVENT_LISTENER_H_ +#define _FUI_ITOUCH_TAP_GESTURE_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +/** + * @class ITouchTapGestureEventListener + * @brief This interface implements the listener for the touch tap gesture events. + * + * @since 2.0 + * + * The %ITouchTapGestureEventListener interface is the listener interface for receiving tap gesture events. + * The class that processes a tap gesture event implements this interface, and the instance created with that class is registered with a + * tap gesture detector, using the gesture detector's AddTapGestureEventListener() method. When the tap gesture event occurs, a method of that instance is + * invoked. + * + */ +class _OSP_EXPORT_ ITouchTapGestureEventListener + : virtual public ITouchGestureEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ITouchTapGestureEventListener(void) {} + + /** + * Called when a tap gesture is detected. + * + * @since 2.0 + * + * @param[in] gestureDetector The tap gesture detector instance + */ + virtual void OnTapGestureDetected(Tizen::Ui::TouchTapGestureDetector& gestureDetector) = 0; + + /** + * Called when a tap gesture detection is canceled. + * + * @since 2.0 + * + * @param[in] gestureDetector The tap gesture detector instance + */ + virtual void OnTapGestureCanceled(Tizen::Ui::TouchTapGestureDetector& gestureDetector) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchTapGestureEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchTapGestureEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void ITouchTapGestureEventListener_Reserved3(void) {} +}; // ITouchTapGestureEventListener + +}} // Tizen::Ui + +#endif //_FUI_ITOUCH_TAP_GESTURE_EVENT_LISTENER_H_ diff --git a/inc/FUiIUiLinkEventListener.h b/inc/FUiIUiLinkEventListener.h new file mode 100644 index 0000000..f0f06b6 --- /dev/null +++ b/inc/FUiIUiLinkEventListener.h @@ -0,0 +1,112 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIUiLinkEventListener.h + * @brief This is the header file for the %IUiLinkEventListener interface. + * + * This header file contains the declarations of the %IUiLinkEventListener interface. + */ +#ifndef _FUI_IUI_LINK_EVENT_LISTENER_H_ +#define _FUI_IUI_LINK_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Base +{ +class String; +}} // Tizen::Base + +// Namespace declaration +namespace Tizen { namespace Ui +{ + +class Control; + +/** + * @interface IUiLinkEventListener + * @brief This interface implements the listener for link events. + * + * @since 2.0 + * + * The %IUiLinkEventListener interface is the listener interface for receiving link click events, for example, from EditFields. + * The class that processes a link click event implements this interface, and the instance created with that class is registered + * with a UI control, using the control's AddUiLinkEventListener() method. When the link click event occurs, the OnLinkClicked() + * method of that instance is invoked. + * @n + * For more information on the class features, see EditArea and EditField, TextBox, and ListViews. + + */ +class _OSP_EXPORT_ IUiLinkEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IUiLinkEventListener(void) {} + + // Operation +public: + /** + * Called when a link is clicked. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] text The text + * @param[in] linkType The link type + * @param[in] link The optional link text + * @remarks If the clicked link does not contain an optional link text, then the value of @c text and @c link will be the same. + */ + virtual void OnLinkClicked(Tizen::Ui::Control& source, const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link) = 0; + +// Reserves +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IUiLinkEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IUiLinkEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void IUiLinkEventListener_Reserved3(void) {} +}; // IUiLinkEventListener + +} } // Tizen::Ui + +#endif // _FUI_IUI_LINK_EVENT_LISTENER_H_ diff --git a/inc/FUiIWindowEventListener.h b/inc/FUiIWindowEventListener.h new file mode 100644 index 0000000..db8a608 --- /dev/null +++ b/inc/FUiIWindowEventListener.h @@ -0,0 +1,113 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiIWindowEventListener.h + * @brief This is the header file for the %IWindowEventListener interface. + * + * This header file contains the declarations of the %IWindowEventListener interface. @n + * If a window event is generated, a method of this interface is called. @n + * So, if an application does some jobs related to the window event, use the methods of this interface. + * + */ + +#ifndef _FUI_IWINDOW_EVENT_LISTENER_H_ +#define _FUI_IWINDOW_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen {namespace Ui +{ + +class Window; + +/** + * @interface IWindowEventListener + * @brief This interface implements the listener for the window event. + * + * @since 2.0 + * + * The %IWindowEventListener interface for receiving window events. The class that processes a window event + * implements this interface, and the instance created with that class is registered with a Window using Window's + * AddWindowEventListener() method. When the window event occurs, the OnWindowActivated(), or OnWindowDeactivated() method of that instance is invoked. + */ +class _OSP_EXPORT_ IWindowEventListener + : public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + * + */ + virtual ~IWindowEventListener(void) {} + + /** + * Called when a window becomes the topmost window. + * + * @since 2.0 + * + * @param[in] source The source of the event + * + */ + virtual void OnWindowActivated(const Tizen::Ui::Window& source) = 0; + + /** + * Called when the window is no longer the topmost window. + * + * @since 2.0 + * + * @param[in] source The source of the event + * + */ + virtual void OnWindowDeactivated(const Tizen::Ui::Window& source) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IWindowEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IWindowEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + virtual void IWindowEventListener_Reserved3(void) {} +}; + +}}; // Tizen::Ui + +#endif // _FUI_IWINDOW_EVENT_LISTENER_H_ diff --git a/inc/FUiInputConnection.h b/inc/FUiInputConnection.h new file mode 100644 index 0000000..facaadb --- /dev/null +++ b/inc/FUiInputConnection.h @@ -0,0 +1,384 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiInputConnection.h + * @brief This is the header file for the %InputConnection class. + * + * This header file contains the declarations of the %InputConnection class. + */ + +#ifndef _FUI_INPUT_CONNECTION_H_ +#define _FUI_INPUT_CONNECTION_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { + +class _InputConnectionImpl; +class Control; + + +/** + * @class InputConnection + * @brief This is the header file for the %InputConnection class. + * This header file contains the declarations of the %InputConnection class. + * @since 2.0 + * + * @final This class is not intended for extension. + * + * Example: + * + * This is a simple editor that uses an %InputConnection. + * + * + * @code +// Sample code for EditorSample.h +#include +#include +#include + +namespace Tizen { namespace Ui { + +class EditorSample : +public Tizen::Ui::Control, +public Tizen::Ui::IInputConnectionEventListener, +public Tizen::Ui::IInputConnectionProvider +{ +protected: + +public: + virtual result OnInitializing(); + + result ShowKeypad(); + result HideKeypad(); + virtual void OnInputConnectionPanelShowStateChanged(Tizen::Ui::InputConnection& source, Tizen::Ui::InputPanelShowState showState); + virtual void OnInputConnectionPanelLanguageChanged(Tizen::Ui::InputConnection& source, Tizen::Locales::LanguageCode language); + virtual void OnInputConnectionPanelBoundsChanged(Tizen::Ui::InputConnection& source, const Tizen::Graphics::Rectangle& bounds); + virtual void OnInputConnectionTextPredictionShowStateChanged(Tizen::Ui::InputConnection& source, bool isShown); + virtual void OnInputConnectionTextPredictionBoundsChanged(Tizen::Ui::InputConnection& source, const Tizen::Graphics::Rectangle& bounds); + virtual void OnInputConnectionTextCommitted(Tizen::Ui::InputConnection& source, const Tizen::Base::String& committedText); + virtual void OnInputConnectionComposingTextChanged(Tizen::Ui::InputConnection& source, const Tizen::Base::String& preEditText, int cursorPosition){}; + virtual void DeleteSurroundingText(Tizen::Ui::InputConnection& source, int offset, int chars){}; + virtual void GetPreviousText(Tizen::Ui::InputConnection& source, Tizen::Base::String& text, int& cursorPosition){}; + +private: + InputConnection* __pImf; + bool __bindStatus; +}; + +}} + * @endcode + * + * @code +// Sample code for EditorSample.cpp +#include "EditorSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +void +EditorSample::OnInputConnectionPanelShowStateChanged(InputConnection& source, InputPanelShowState showState) + { + // .... + } + +void +EditorSample::OnInputConnectionPanelLanguageChanged(InputConnection& source, Tizen::Locales::LanguageCode language) +{ + // .... +} + +void +EditorSample::OnInputConnectionPanelBoundsChanged(InputConnection& source, const Tizen::Graphics::Rectangle& bounds) +{ + // .... +} + +void +EditorSample::OnInputConnectionTextPredictionShowStateChanged(InputConnection& source, bool isShown) +{ + // .... +} + +void +EditorSample::OnInputConnectionTextPredictionBoundsChanged(InputConnection& source, const Tizen::Graphics::Rectangle& bounds) +{ + // .... +} + +void +EditorSample::OnInputConnectionTextCommitted(InputConnection& source, const Tizen::Base::String& committedText) +{ + // .... +} + +result +EditorSample::OnInitializing() +{ + result r = E_SUCCESS; + + __bindStatus = false; + + // Creates an instance of InputConnection + __pImf = new (std::nothrow) InputConnection(); + __pImf->Construct(this, *this, *this); + + return r; +} + +result +EditorSample::ShowKeypad() +{ + result r = E_SUCCESS; + + if(!__bindStatus) + { + __pImf->BindInputMethod(); + __bindStatus = true; + __pImf->ShowInputPanel(); + } + + return r; +} + +result +EditorSample::HideKeypad() +{ + result r = E_SUCCESS; + + if (__bindStatus != false) + { + __pImf->HideInputPanel(); + __pImf->UnbindInputMethod(); + __bindStatus = false; + } + + return r; +} + + * @endcode + * + */ + +class _OSP_EXPORT_ InputConnection + : public Tizen::Base::Object +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + InputConnection(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~InputConnection(void); + + /** + * Initializes this instance of the %InputConnection with the specified parameter. + * + * @since 2.0 + * @return An error code + * @param[in] pControl The source object for connecting the Input Method. + * @param[in] listener An instance of the %IInputConnectionEventListener for processing the event + * @param[in] provider The %InputConnection provider + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + */ + result Construct(const Control* pControl, IInputConnectionEventListener& listener, IInputConnectionProvider& provider); + + /** + * Binds the %InputConnection to the current active Input Method + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @see UnbindInputMethod() + * @remarks This method should be called when the %Control object has the input focus. + */ + result BindInputMethod(void); + + /** + * Unbinds the %InputConnection from the current active Input Method. It will no longer be valid for the Input Method. + * + * @since 2.0 + * @see BindInputMethod() + */ + void UnbindInputMethod(void); + + /** + * Asks the current active Input Method to show the Input Panel which contains the keyboard. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method. + * @see HideInputPanel() + */ + result ShowInputPanel(void); + + /** + * Asks the current active Input Method to hide the active Input Panel which contains the keyboard. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method. + * @see ShowInputPanel() + */ + result HideInputPanel(void); + + /** + * Sets the style of the current active Input Panel. + * + * @since 2.0 + * @param[in] style The style of the Input Panel. + * @remarks This method may not work, depending on the current active Input Method. + */ + void SetInputPanelStyle(InputPanelStyle style); + + /** + * Sets the auto-capitalization mode. + * + * @since 2.0 + * @param[in] autoCapitalizationMode The auto-capitalization mode. + * @remarks This method may not work, depending on the current active Input Method. + */ + void SetAutoCapitalizationMode(AutoCapitalizationMode autoCapitalizationMode); + + /** + * Finishes text composition. + * This will typically cause the Input Method to exit the composing state. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method. + */ + result FinishTextComposition(void); + + /** + * Sets the type of ActionKey. + * + * @since 2.0 + * @param[in] inputPanelAction The InputPanel action + * @remarks This method may not work, depending on the current active Input Method. + */ + void SetInputPanelAction(InputPanelAction inputPanelAction); + + /** + * Enables or disables the ActionKey. + * + * @since 2.0 + * @param[in] enable Set to @c true to enable the ActionKey, @n + * else @c false + * @remarks This method may not work, depending on the current active Input Method. + */ + void SetInputPanelActionEnabled(bool enable); + + /** + * Sets the language of the current active Input Panel. + * + * @since 2.0 + * @param[in] languageCode The language to set + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks This method may not work, depending on the current active Input Method. + */ + result SetInputPanelLanguage(Tizen::Locales::LanguageCode languageCode); + + /** + * Sets the cursor at the specified position. + * + * @since 2.0 + * @param[in] position The cursor position that is to be set + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method. + */ + result SetCursorPosition(int position); + + /** + * Sets the bounds of the cursor + * + * @since 2.0 + * @param[in] rect the rectangle to be set + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method. + */ + result SetCursorBounds(const Tizen::Graphics::Rectangle& rect); + + /** + * Gets the bounds of the current active Input Panel. + * + * @since 2.0 + * @return An instance of the rectangle that represents the position of the top-left corner, + * the width, and the height of the Input Panel. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Rectangle GetInputPanelBounds(void) const; + + /** + * Enables or disables text prediction. + * + * @since 2.0 + * @param[in] enable Set to @c true to enable text prediction, @n + * else @c false + * @remarks This method may not work, depending on the current active Input Method. + */ + void SetTextPredictionEnabled(bool enable); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + InputConnection(const InputConnection& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.0 + // + InputConnection& operator=(const InputConnection& rhs); + +private: + friend class _InputConnectionImpl; + _InputConnectionImpl* __pInputConnectionImpl; + +}; // InputConnection + +}} // Tizen::Ui + +#endif // _FUI_INPUT_CONNECTION_H_ diff --git a/inc/FUiInputConnectionTypes.h b/inc/FUiInputConnectionTypes.h new file mode 100644 index 0000000..9b371f2 --- /dev/null +++ b/inc/FUiInputConnectionTypes.h @@ -0,0 +1,96 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiInputConnectionTypes.h + * @brief This is the header file for the data types. + * + * This header file contains the declarations of commonly used types. + * + */ + + +#ifndef _FUI_INPUT_CONNECTION_TYPES_H_ +#define _FUI_INPUT_CONNECTION_TYPES_H_ + +namespace Tizen { namespace Ui { + + +/** + * @enum InputPanelStyle + * Defines the style of the InputPanel. + * + * @since 2.0 + */ +enum InputPanelStyle +{ + INPUT_PANEL_STYLE_NORMAL, /**< Default style */ + INPUT_PANEL_STYLE_EMAIL, /**< Email style */ + INPUT_PANEL_STYLE_URL, /**< URL style */ + INPUT_PANEL_STYLE_NUMBER, /**< Number style */ + INPUT_PANEL_STYLE_NUMBER_ONLY, /**< Number Only style */ + INPUT_PANEL_STYLE_PHONE_NUMBER, /**< Phone Number style */ + INPUT_PANEL_STYLE_IP /**< IP style */ +}; + +/** + * @enum InputPanelShowState + * Defines the state of the InputPanel + * + * @since 2.0 + */ +enum InputPanelShowState +{ + INPUT_PANEL_SHOW_STATE_SHOW, /**< Show State */ + INPUT_PANEL_SHOW_STATE_HIDE /**< Hide State */ +}; + +/** + * @enum AutoCapitalizationMode + * Defines the type of the AutoCapitalization + * + * @since 2.0 + */ +enum AutoCapitalizationMode +{ + AUTO_CAPITALIZATION_MODE_NONE, /**< AutoCapitalization None Mode */ + AUTO_CAPITALIZATION_MODE_WORD, /**< AutoCapitalization WORD Mode */ + AUTO_CAPITALIZATION_MODE_SENTENCE, /**< AutoCapitalization Sentence Mode */ + AUTO_CAPITALIZATION_MODE_ALL /**< AutoCapitalization All Mode */ +}; + +/** + * @enum InputPanelAction + * + * Defines the possible keypad action types. + * @since 2.0 + */ +enum InputPanelAction +{ + INPUT_PANEL_ACTION_ENTER, /**< The Enter key */ + INPUT_PANEL_ACTION_GO, /**< The Go key */ + INPUT_PANEL_ACTION_NEXT, /**< The Next key */ + INPUT_PANEL_ACTION_SEND, /**< The Send key */ + INPUT_PANEL_ACTION_SEARCH, /**< The Search key */ + INPUT_PANEL_ACTION_LOGIN, /**< The Login key */ + INPUT_PANEL_ACTION_SIGN_IN, /**< The Sign-In key */ + INPUT_PANEL_ACTION_JOIN, /**< The Join key */ + INPUT_PANEL_ACTION_DONE /**< The Done key */ +}; + +}} // Tizen::Ui + +#endif // _FUI_INPUT_CONNECTION_TYPES_H_ diff --git a/inc/FUiKeyEventManager.h b/inc/FUiKeyEventManager.h new file mode 100644 index 0000000..a08bed1 --- /dev/null +++ b/inc/FUiKeyEventManager.h @@ -0,0 +1,135 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiKeyEventManager.h + * @brief This is the header file for the %KeyEventManager class. + * + * This header file contains the declarations of the %KeyEventManager class. + */ + +#ifndef _FUI_KEY_EVENT_MANAGER_H_ +#define _FUI_KEY_EVENT_MANAGER_H_ + +#include +#include +#include + +namespace Tizen { namespace Base { namespace Runtime +{ +class _IEvent; +class IEventArg; +}}} + +namespace Tizen {namespace Ui +{ +class Control; + +/** + * @class KeyEventManager + * @brief This class manages the key events that are fired within the context of this application. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %KeyEventManager class listens to all key events that are generated within the application's context. + * @n + * For more information on the class features, see Event Listeners. + */ +class _OSP_EXPORT_ KeyEventManager + : public Tizen::Base::Object +{ +public: + /** + * This destructor overrides Osp::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~KeyEventManager(void); + + /** + * Gets the pointer to the current key event manager. + * + * @since 2.0 + * + * @return The current %KeyEventManager instance + */ + static KeyEventManager* GetInstance(void); + + /** + * Adds an application-wide %IKeyEventListener instance. @n + * The added listeners get notified when a key is pressed, released, or long pressed within the context of this application. + * + * @since 2.0 + * + * @param[in] listener The event listener to be added + * @remarks The listener is called after the key event is delivered to the focused control's key event listeners, but before the + * key event is passed onto the focused control itself. @n + * Moreover, if the key needs to be consumed by the control itself, the added listeners will not be notified. + * @see RemoveKeyEventListener () + */ + void AddKeyEventListener(IKeyEventListener& listener); + + /** + * Removes the %IKeyEventListener instance. @n + * The removed listener is not notified even when the key events are fired. + * + * @since 2.0 + * + * @return listener The current application-wide key event listener to be removed + * @see AddKeyEventListener() + */ + void RemoveKeyEventListener(IKeyEventListener& listener); + +protected: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + KeyEventManager(void); + + /** + * Initializes this instance of %KeyEventManager. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(void); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + KeyEventManager(const KeyEventManager& value); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + KeyEventManager& operator =(const KeyEventManager& value); + + static void InitializeInstance(void); + +}; // KeyEventManager + +}} // Tizen::Ui + +#endif // _FUI_KEY_EVENT_MANAGER_H_ diff --git a/inc/FUiKeyboardMap.h b/inc/FUiKeyboardMap.h new file mode 100644 index 0000000..4742cf4 --- /dev/null +++ b/inc/FUiKeyboardMap.h @@ -0,0 +1,308 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiKeyboardMap.h + * @brief This is the header file for the %KeyboardMap class. + * + * This header file contains the declarations of the %KeyboardMap class. + */ + +#ifndef _FUI_KEYBOARD_MAP_H_ +#define _FUI_KEYBOARD_MAP_H_ + +#include +#include +#include +#include + +namespace Tizen {namespace Ui +{ +/** + * @if OSPDEPREC + * @enum KeyboardKeyLabelType + * + * Defines the key label types. @n + * It defines the types of labels that are printed on the corresponding key of the QWERTY keyboard. Only the printing + * keys have one or more text labels. + * + * @brief [Deprecated] + * @deprecated This enum is deprecated because it is not supported by platform. + * @since 2.0 + * @endif + */ +enum KeyboardKeyLabelType +{ + /** + * @if OSPDEPREC + * The first label to be displayed + * @endif + */ + KEYBOARD_KEY_LABEL_1 = 0x0000, + + /** + * @if OSPDEPREC + * The second label to be displayed after KEY_CAPSLOCK or KEY_FN is pressed + * @endif + */ + KEYBOARD_KEY_LABEL_2, + + /** + * @if OSPDEPREC + * The third label to be displayed when the key is toggled twice (without pressing KEY_CAPSLOCK or KEY_FN) + * @endif + */ + KEYBOARD_KEY_LABEL_3, + + /** + * @if OSPDEPREC + * The fourth label to be displayed when the key is toggled the third time (without pressing KEY_CAPSLOCK or KEY_FN) + * @endif + */ + KEYBOARD_KEY_LABEL_4, + + /* + * @if OSPDEPREC + * The max value + * @endif + */ + KEYBOARD_KEY_LABEL_MAX = 255 +}; + + +/** + * @if OSPDEPREC + * @class KeyboardMap + * @brief [Deprecated] This class manages the hardware keyboard key mapping. + * @deprecated This class is deprecated because it is not supported by platform. + * @since 2.0 + * + * The %KeyboardMap class maintains a map of hardware keys. You can query the current + * hardware keyboard type of the device and check the availability of a + * specific key. Furthermore, you can query the labels that are printed on the + * hardware keyboard of a specific key. + * + * The following example demonstrates how to get the type of the keyboard and the property of each key: + * + * @code + * KeyboardMap* pKeyboardMap = KeyboardMap::GetInstance(); + * if (pKeyboardMap != null) + * { + * // Gets the keyboard type + * String type = pKeyboardMap->GetKeyboardType(); + * AppLog("The current hardware keyboard type = %ls", type.GetPointer()); + * + * // Checks properties of the hardware key + * bool available = pKeyboardMap->IsKeyAvailable(KEY_A); + * bool printing = pKeyboardMap->IsPrintingKey(KEY_A); + * String l1 = pKeyboardMap->GetDisplayableLabel(KEY_A); + * String l2 = pKeyboardMap->GetDisplayableLabel(KEY_A, KEYBOARD_KEY_LABEL_2); + * String l3 = pKeyboardMap->GetDisplayableLabel(KEY_A, KEYBOARD_KEY_LABEL_3); + * String l4 = pKeyboardMap->GetDisplayableLabel(KEY_A, KEYBOARD_KEY_LABEL_4); + * } + * @endcode + * @endif + */ +class _OSP_EXPORT_ KeyboardMap + : public Tizen::Base::Object +{ +public: + /** + * @if OSPDEPREC + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @brief [Deprecated] + * @deprecated This class is deprecated because it is not supported by platform. + * @since 2.0 + * @endif + */ + virtual ~KeyboardMap(void); + + /** + * @if OSPDEPREC + * Gets the pointer to the %KeyboardMap instance. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because it is not supported by platform. + * @since 2.0 + * + * @return The current %KeyboardMap instance + * @endif + */ + static KeyboardMap* GetInstance(void); + +public: + /** + * @if OSPDEPREC + * Checks whether the specified key is a printing key (the key has one or more labels printed on the corresponding key). + * + * @brief [Deprecated] + * @deprecated This class is deprecated because it is not supported by platform. + * @since 2.0 + * + * @return @c true if the specified key is a printing key, @n + * else @c false + * @param[in] keyCode The key + * @endif + */ + bool IsPrintingKey(KeyCode keyCode) const; + + /** + * @if OSPDEPREC + * Checks whether the specified key is available on the current keyboard. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because it is not supported by platform. + * @since 2.0 + * + * @return @c true if the specified key is available on the current keyboard, @n + * else @c false + * @param[in] keyCode The key + * @endif + */ + bool IsKeyAvailable(KeyCode keyCode) const; + + /** + * @if OSPDEPREC + * Gets the name of the keyboard type. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because it is not supported by platform. + * @since 2.0 + * + * @return The name of the keyboard type + * @remarks The name of the keyboard type follows the following naming convention: @n + * GENERAL-TYPE_KEY-LAYOUT_LANGUAGE/COUNTRY/REGION (for example, QWERTY_11x4_EUROPE, + * NUMERIC_3x4_EUROPE). @n If the device does not have a keyboard, the method returns "NONE". @n + * @remarks + * Supported keyboard types + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Keyboard Type Languages
QWERTY_11x4_GLOBAL English
QWERTY_11x4_EUROPE English
QWERTY_11x4_UK English
QWERTY_11x4_FRANCE French, English
QWERTY_11x4_GERMAN German, English
QWERTY_11x4_GREECE Greek, English
QWERTY_11x4_ITALY Italian, English
QWERTY_11x4_NORDIC North Germanic
QWERTY_11x4_RUSSIA Russian, English
QWERTY_11x4_SPAIN Spanish, English
QWERTY_11x4_TURKEY English
QWERTY_11x4_NORTH-AFRICA English, English
QWERTY_11x4_ARAB Arabic, English
QWERTY_11x4_IRAN Farsi, English
QWERTY_11x4_PARKISTAN Urdu, English
QWERTY_11x4_ISRAEL Hebrew, English
QWERTY_11x4_CHINA English
QWERTY_11x4_HONGKONG Chinese Traditional, English
QWERTY_11x4_SINGAPORE English
QWERTY_11x4_THAILAND Thai, English
QWERTY_11x4_TAIWAN Chinese Traditional, English
QWERTY_11x4_VIETNAM Vietnamese, English
QWERTY_11x4_JAPAN Japanese, English
QWERTY_11x4_KOREA Korean, English
QWERTY_11x4_NORTH-AMERICA English
+ * @endif + */ + Tizen::Base::String GetKeyboardType(void) const; + + /** + * @if OSPDEPREC + * Gets the label of the specified key. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because it is not supported by platform. + * @since 2.0 + * + * @return The text of the label, @n + * else an empty string if the specified key is not a printing key or the secondary/tertiary character label is not defined + * @param[in] keyCode The key + * @param[in] type The keyboard key label type + * @endif + */ + Tizen::Base::String GetDisplayableLabel(KeyCode keyCode, KeyboardKeyLabelType type = KEYBOARD_KEY_LABEL_1) const; + +protected: + /** + * @if OSPDEPREC + * This is the default constructor for this class. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because it is not supported by platform. + * @since 2.0 + * @endif + */ + KeyboardMap(void); + + /** + * @if OSPDEPREC + * Initializes this instance of %KeyboardMap. + * + * @brief [Deprecated] + * @deprecated This class is deprecated because it is not supported by platform. + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_IO An IO error has occurred. + * @exception E_SYSTEM A system error has occurred. + * @endif + */ + result Construct(void); + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // Gets KeyCode of the specified system key. + // + // @since 2.0 + // @return The key code + // @param[in] systemKeyCode The system key + // + KeyCode GetKeyCode(int systemKeyCode) const; + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without + // prior notice. + // + // Loads keyboard map table from file. + // + // @since 2.0 + // @return An error code + // @exception E_SUCCESS The method is successful. + // @exception E_IO An unexpected IO error has occurred. + // @exception E_SYSTEM A system error has occurred. + // + result LoadKeyboarMapFromFile(void); +private: + static void InitializeInstance(void); + +}; // KeyboardMap + +}} // Tizen::Ui + +#endif // _FUI_KEYBOARD_MAP_H_ diff --git a/inc/FUiLayout.h b/inc/FUiLayout.h new file mode 100644 index 0000000..5764303 --- /dev/null +++ b/inc/FUiLayout.h @@ -0,0 +1,101 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiLayout.h + * @brief This is the header file for the %Layout class. + * + * This header file contains the declarations of the %Layout class. + */ + +#ifndef _FUI_LAYOUT_H_ +#define _FUI_LAYOUT_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +/** + * @class Layout + * @brief This class is the abstract base class of all the %Layout classes. + * + * @since 2.0 + * + * The %Layout class is the abstract base class of all the %Layout classes. + * @n + * For more information on the class features, see Layout. + */ +class _OSP_EXPORT_ Layout + : public Tizen::Base::Object +{ +public: + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~Layout(void); + + /** + * Gets the type of the layout. + * + * @since 2.0 + * + * @return The layout type + */ + virtual LayoutType GetLayoutType(void) const = 0; + + /** + * Updates the layout. + * + * @since 2.0 + * + * @return An error code + * + * @exception E_SUCCESS The method is successful. + */ + result Update(void); + +protected: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + Layout(void); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Layout(const Layout& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Layout& operator =(const Layout& rhs); + +protected: + void* _pImpl; + friend class _LayoutImpl; +}; // Layout + +}} // Tizen::Ui + +#endif // _FUI_LAYOUT_H_ diff --git a/inc/FUiLayoutTypes.h b/inc/FUiLayoutTypes.h new file mode 100644 index 0000000..891b8e4 --- /dev/null +++ b/inc/FUiLayoutTypes.h @@ -0,0 +1,163 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiLayoutTypes.h + * @brief This is the header file for the layout enumerations. + * + * This header file contains the declarations of the layout enumerations. + */ +#ifndef _FUI_LAYOUT_ENUM_H_ +#define _FUI_LAYOUT_ENUM_H_ + +namespace Tizen { namespace Ui +{ + +/** + * @enum LayoutType + * + * Defines the layout type. + * + * @since 2.0 + */ +enum LayoutType +{ + LAYOUT_RELATIVE, /**< The relative layout */ + LAYOUT_VERTICAL_BOX, /**< The vertical box layout */ + LAYOUT_HORIZONTAL_BOX, /**< The horizontal box layout */ + LAYOUT_GRID, /**< The grid layout */ + LAYOUT_CARD /**< The card layout */ +}; + +/** + * @enum RectangleEdgeRelation + * + * Defines the relative relation between the source control and the target control. + * + * @since 2.0 + */ +enum RectangleEdgeRelation +{ + RECT_EDGE_RELATION_LEFT_TO_LEFT, /**< The left edge of the source control is aligned with the left edge of the target control */ + RECT_EDGE_RELATION_LEFT_TO_RIGHT, /**< The left edge of the source control is aligned with the right edge of the target control */ + RECT_EDGE_RELATION_RIGHT_TO_RIGHT, /**< The right edge of the source control is aligned with the right edge of the target control */ + RECT_EDGE_RELATION_RIGHT_TO_LEFT, /**< The right edge of the source control is aligned with the left edge of the target control */ + RECT_EDGE_RELATION_TOP_TO_TOP, /**< The top edge of the source control is aligned with the top edge of the target control */ + RECT_EDGE_RELATION_TOP_TO_BOTTOM, /**< The top edge of the source control is aligned with the bottom edge of the target control */ + RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM, /**< The bottom edge of the source control is aligned with the bottom edge of the target control */ + RECT_EDGE_RELATION_BOTTOM_TO_TOP /**< The bottom edge of the source control is aligned with the top edge of the target control */ +}; + +/** + * @enum RectangleEdgeType + * + * Defines the edges of a rectangle. + * + * @since 2.0 + */ +enum RectangleEdgeType +{ + RECT_EDGE_LEFT, /**< The left edge of a rectangle */ + RECT_EDGE_RIGHT, /**< The right edge of a rectangle */ + RECT_EDGE_TOP, /**< The top edge of a rectangle */ + RECT_EDGE_BOTTOM /**< The bottom edge of a rectangle */ +}; + +/** + * @enum CenterAlignmentType + * + * Defines the center alignment for a control. + * + * @since 2.0 + */ +enum CenterAlignmentType +{ + CENTER_ALIGN_HORIZONTAL, /**< Centers the child control horizontally with respect to the left and right side of its parent control */ + CENTER_ALIGN_VERTICAL /**< Centers the child control vertically with respect to the top and bottom side of its parent control */ +}; + +/** + * @enum FitPolicy + * + * Defines the fitting policy for a control. + * + * @since 2.0 + */ +enum FitPolicy +{ + FIT_POLICY_FIXED, /**< The fixed size of a control */ + FIT_POLICY_CONTENT, /**< The size of the control that is large enough to fit its internal content */ + FIT_POLICY_PARENT /**< The size of the control that is as large as its parent control */ +}; + +/** + * @enum VerticalDirection + * + * Defines the direction for the vertical box layout. + * + * @since 2.0 + */ +enum VerticalDirection +{ + VERTICAL_DIRECTION_DOWNWARD, /**< The direction that runs from top to bottom */ + VERTICAL_DIRECTION_UPWARD /**< The direction that runs from bottom to top */ +}; + +/** + * @enum HorizontalDirection + * + * Defines the direction for the horizontal box layout. + * + * @since 2.0 + */ +enum HorizontalDirection +{ + HORIZONTAL_DIRECTION_RIGHTWARD, /**< The direction that runs from left to right */ + HORIZONTAL_DIRECTION_LEFTWARD /**< The direction that runs from right to left */ +}; + +/** + * @enum LayoutHorizontalAlignment + * + * Defines the horizontal alignment for the grid layout. + * + * @since 2.0 + */ +enum LayoutHorizontalAlignment +{ + LAYOUT_HORIZONTAL_ALIGN_LEFT, /**< The horizontal left alignment of the control */ + LAYOUT_HORIZONTAL_ALIGN_CENTER, /**< The horizontal center alignment of the control */ + LAYOUT_HORIZONTAL_ALIGN_RIGHT /**< The horizontal right alignment of the control */ +}; + +/** + * @enum LayoutVerticalAlignment + * + * Defines the vertical alignment for the grid layout. + * + * @since 2.0 + */ +enum LayoutVerticalAlignment +{ + LAYOUT_VERTICAL_ALIGN_TOP, /**< The vertical top alignment of the control */ + LAYOUT_VERTICAL_ALIGN_MIDDLE, /**< The vertical middle alignment of the control */ + LAYOUT_VERTICAL_ALIGN_BOTTOM /**< The vertical bottom alignment of the control */ +}; + +}} // Tizen::Ui + +#endif // _FUI_LAYOUT_ENUM_H_ diff --git a/inc/FUiRelativeLayout.h b/inc/FUiRelativeLayout.h new file mode 100755 index 0000000..48c4e70 --- /dev/null +++ b/inc/FUiRelativeLayout.h @@ -0,0 +1,389 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiRelativeLayout.h + * @brief This is the header file for the %RelativeLayout class. + * + * This header file contains the declarations of the %RelativeLayout class. + */ + +#ifndef _FUI_RELATIVE_LAYOUT_H_ +#define _FUI_RELATIVE_LAYOUT_H_ + +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} + +namespace Tizen { namespace Ui +{ + +/** + * @class RelativeLayout + * @brief The relative layout positions the children of a container in a manner that is relative to other children or its parent container. + * + * @since 2.0 + * + * The %RelativeLayout class defines the relative layout for a Container. The layout positions the children of the %Container relative to the + * Container or its other children. @n + * + * For more information on the class features, see Relative Layout. + * + * @code +// Sample code for RelativeLayoutSample.h +#include + +class RelativeLayoutSample + : public Tizen::Ui::Controls::Form +{ +public: + bool Initialize(void); + virtual result OnInitializing(void); +}; + * @endcode + * + * @code +// Sample code for RelativeLayoutSample.cpp +#include + +#include "RelativeLayoutSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +bool +RelativeLayoutSample::Initialize(void) +{ + // Creates an instance of RelativeLayout + RelativeLayout relativeFormLayout; + relativeFormLayout.Construct(); + + // Applies the relative layout to the form + Construct(relativeFormLayout, FORM_STYLE_NORMAL); + return true; +} + +result +RelativeLayoutSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of RelativeLayout for the top panel + RelativeLayout topPanelLayout; + topPanelLayout.Construct(); + + // Creates an instance of Panel and applies it to the relative layout + Panel* pTopRelativePanel = new Panel(); + pTopRelativePanel->Construct(topPanelLayout, Rectangle(0, 0, 300, 300)); + { + // Creates instances of Button + Button* pUpButton = new Button(); + pUpButton->Construct(Rectangle(0,0,200,100), "UP"); + pTopRelativePanel->AddControl(*pUpButton); + + Button* pMiddleButton = new Button(); + pMiddleButton->Construct(Rectangle(0,0,200,100), "CENTER"); + pTopRelativePanel->AddControl(*pMiddleButton); + + Button* pDownButton = new Button(); + pDownButton->Construct(Rectangle(0,0,200,100), "DOWN"); + pTopRelativePanel->AddControl(*pDownButton); + + // Sets relations between the pUpButton and pMiddleButton + topPanelLayout.SetRelation(*pUpButton, *pMiddleButton, RECT_EDGE_RELATION_LEFT_TO_LEFT); + topPanelLayout.SetRelation(*pUpButton, *pMiddleButton, RECT_EDGE_RELATION_BOTTOM_TO_TOP); + topPanelLayout.SetMargin(*pUpButton, 0, 0, 0, 10); + + // Sets the middle button + topPanelLayout.SetCenterAligned(*pMiddleButton, CENTER_ALIGN_HORIZONTAL); + topPanelLayout.SetCenterAligned(*pMiddleButton, CENTER_ALIGN_VERTICAL); + topPanelLayout.SetMargin(*pMiddleButton, 10, 10, 10, 10); + + // Sets relations between the pDownButton and the pMiddleButton + topPanelLayout.SetRelation(*pDownButton, *pMiddleButton, RECT_EDGE_RELATION_RIGHT_TO_RIGHT); + topPanelLayout.SetRelation(*pDownButton, *pMiddleButton, RECT_EDGE_RELATION_TOP_TO_BOTTOM); + topPanelLayout.SetMargin(*pDownButton, 0, 0, 10, 0); + } + + // Adds the top panel to the form + AddControl(*pTopRelativePanel); + + // Creates an instance of RelativeLayout for the bottom panel + RelativeLayout bottomPanelLayout; + bottomPanelLayout.Construct(); + + // Creates an instance of Panel and applies it to the relative layout + Panel* pBottomRelativePanel = new Panel(); + pBottomRelativePanel->Construct(bottomPanelLayout, Rectangle(0, 0, 300, 300)); + { + // Creates instances of Label + Label* pFixedLabel = new Label(); + pFixedLabel->Construct(Rectangle(0, 0, 150, 80), L"FIXED"); + pFixedLabel->SetBackgroundColor(Color::GetColor(COLOR_ID_YELLOW)); + pFixedLabel->SetTextColor(Color::GetColor(COLOR_ID_BLACK)); + pBottomRelativePanel->AddControl(*pFixedLabel); + + Label* pScalableLabel = new Label(); + pScalableLabel->Construct(Rectangle(0, 0, 150, 80), L"SCALABLE <=>"); + pScalableLabel->SetBackgroundColor(Color::GetColor(COLOR_ID_BLUE)); + pScalableLabel->SetTextColor(Color::GetColor(COLOR_ID_BLACK)); + pBottomRelativePanel->AddControl(*pScalableLabel); + + // Sets relations between the fixed label and the panel + bottomPanelLayout.SetCenterAligned(*pFixedLabel, CENTER_ALIGN_VERTICAL); + bottomPanelLayout.SetRelation(*pFixedLabel, *pBottomRelativePanel, RECT_EDGE_RELATION_LEFT_TO_LEFT); + bottomPanelLayout.SetRelation(*pFixedLabel, *pBottomRelativePanel, RECT_EDGE_RELATION_TOP_TO_TOP); + bottomPanelLayout.SetMargin(*pFixedLabel, 30, 30, 30, 30); + + // Sets relations between the scalable label and the panel + bottomPanelLayout.SetCenterAligned(*pScalableLabel, CENTER_ALIGN_VERTICAL); + bottomPanelLayout.SetRelation(*pScalableLabel, *pFixedLabel, RECT_EDGE_RELATION_LEFT_TO_RIGHT); + bottomPanelLayout.SetRelation(*pScalableLabel, *pFixedLabel, RECT_EDGE_RELATION_LEFT_TO_RIGHT); + bottomPanelLayout.SetRelation(*pScalableLabel, *pBottomRelativePanel, RECT_EDGE_RELATION_RIGHT_TO_RIGHT); + bottomPanelLayout.SetRelation(*pScalableLabel, *pBottomRelativePanel, RECT_EDGE_RELATION_TOP_TO_TOP); + bottomPanelLayout.SetMargin(*pScalableLabel, 30, 30, 30, 30); + } + + // Adds the bottom panel to the form + AddControl(*pBottomRelativePanel); + + //Gets the layout of the form + RelativeLayout* pFormLayout = dynamic_cast(this->GetLayoutN()); + + // Sets relations of the top relative panel + pFormLayout->SetRelation(*pTopRelativePanel, *this, RECT_EDGE_RELATION_LEFT_TO_LEFT); + pFormLayout->SetRelation(*pTopRelativePanel, *this, RECT_EDGE_RELATION_RIGHT_TO_RIGHT); + pFormLayout->SetRelation(*pTopRelativePanel, *this, RECT_EDGE_RELATION_TOP_TO_TOP); + + // Sets relations of the bottom relative panel + pFormLayout->SetRelation(*pBottomRelativePanel, *this, RECT_EDGE_RELATION_LEFT_TO_LEFT); + pFormLayout->SetRelation(*pBottomRelativePanel, *this, RECT_EDGE_RELATION_RIGHT_TO_RIGHT); + pFormLayout->SetRelation(*pBottomRelativePanel, *this, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM); + + // Sets relations between the top relative panel and the bottom relative panel + pFormLayout->SetHorizontalFitPolicy(*pTopRelativePanel, FIT_POLICY_PARENT); + pFormLayout->SetHorizontalFitPolicy(*pBottomRelativePanel, FIT_POLICY_PARENT); + pFormLayout->SetVerticalFitPolicy(*pBottomRelativePanel, FIT_POLICY_FIXED); + pFormLayout->SetRelation(*pTopRelativePanel, *pBottomRelativePanel, RECT_EDGE_RELATION_BOTTOM_TO_TOP); + + return r; +} + * @endcode + * + */ +class _OSP_EXPORT_ RelativeLayout + : public Layout +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + * + * @remarks After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance. + */ + RelativeLayout(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~RelativeLayout(void); + + /** + * Initializes this instance of %RelativeLayout. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(void); + + /** + * Gets the type of the layout. + * + * @since 2.0 + * + * @return The layout type + */ + virtual LayoutType GetLayoutType(void) const; + + /** + * Sets the relation of the specified child control for the edge with other control. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the relation is set + * @param[in] targetControl The target control @n + * It must be a parent or sibling. + * @param[in] edgeRelation The edge of the specified control to be aligned with the edge of the target control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * Either the specified @c childControl or the specified @c targetControl is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result SetRelation(Control& childControl, const Control& targetControl, RectangleEdgeRelation edgeRelation); + + /** + * Resets the relation of the specified control for the vertical edge. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the relation is reset + * @param[in] edgeType The edge type of the specified control + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result ResetRelation(Control& childControl, RectangleEdgeType edgeType); + + /** + * Sets the specified control at the center of the parent control. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control to be center aligned + * @param[in] alignment The center alignment for a control either vertically or horizontally + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks The relation value that is set to a child control is ignored when the center-alignment is applied to the control. + */ + result SetCenterAligned(Control& childControl, CenterAlignmentType alignment); + + /** + * Resets the center position of the specified control. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control to be center aligned + * @param[in] alignment The center alignment for a control either vertically or horizontally + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result ResetCenterAligned(Control& childControl, CenterAlignmentType alignment); + + /** + * Sets the margins of the specified control. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the margins are set + * @param[in] left The left margin + * @param[in] right The right margin + * @param[in] top The top margin + * @param[in] bottom The bottom margin + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the margins are set to @c 0. + */ + result SetMargin(Control& childControl, int left, int right, int top, int bottom); + + /** + * Sets the width of the specified control to the fixed size. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the width is set + * @param[in] width The value of the width + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result SetWidth(Control& childControl, int width); + + /** + * Sets the width of the specified control as per the fitting policy. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the width is set + * @param[in] policy The fitting policy for the width + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result SetHorizontalFitPolicy(Control& childControl, FitPolicy policy); + + /** + * Sets the height of the specified control to the fixed size. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the height is set + * @param[in] height The value of the height + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result SetHeight(Control& childControl, int height); + + /** + * Sets the height of the specified control as per the fitting policy. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the height is set + * @param[in] policy The fitting policy for the height + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result SetVerticalFitPolicy(Control& childControl, FitPolicy policy); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + RelativeLayout(const RelativeLayout& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + RelativeLayout& operator =(const RelativeLayout& rhs); + +}; // RelativeLayout + +}} // Tizen::Ui + +#endif // _FUI_RELATIVE_LAYOUT_H_ diff --git a/inc/FUiScenes.h b/inc/FUiScenes.h new file mode 100644 index 0000000..21d2404 --- /dev/null +++ b/inc/FUiScenes.h @@ -0,0 +1,66 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenes.h + * @brief This is the header file for the %Scenes namespace. + * + * This header file contains the declarations and descriptions of the %Tizen::Ui::Scenes namespace. + */ + +#ifndef _FUI_SCENES_H_ +#define _FUI_SCENES_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Tizen { namespace Ui +{ +/** + * @namespace Tizen::Ui::Scenes + * @brief This namespace contains the classes for the scene management and its related functions. + * @since 2.0 + * + * @remarks @b Header @b %file: @b \#include @b @n + * @b Library : @b osp-uifw + * + * The %Scenes namespace provides easy and simplified screen transition methods for form-based UI applications using the scene management feature. + * @n + * For more information on the class features, see Scene Management. + * + * The following diagram illustrates the relationships between the classes belonging to the %Scenes namespace. + * + * @image html ui_scenes_namespace_classdiagram.png + */ + +namespace Scenes +{ +} +} } // Tizen::Ui + +#endif //_FUI_SCENES_H_ diff --git a/inc/FUiScenesBackwardSceneTransition.h b/inc/FUiScenesBackwardSceneTransition.h new file mode 100644 index 0000000..8978001 --- /dev/null +++ b/inc/FUiScenesBackwardSceneTransition.h @@ -0,0 +1,123 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesBackwardSceneTransition.h + * @brief This is the header file for the %BackwardSceneTransition class. + * + * This header file contains the declarations of the %BackwardSceneTransition class. + */ + +#ifndef _FUI_SCENES_BACKWARD_SCENE_TRANSITION_H_ +#define _FUI_SCENES_BACKWARD_SCENE_TRANSITION_H_ + +#include + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +/** + * @class BackwardSceneTransition + * @brief This class is the %BackwardSceneTransition class of a Tizen native application. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %BackwardSceneTransition class contains transition information, such as transition direction, transition destination, + * animation type, history option, and destroy option. By default, the transition direction is set as SCENE_TRANSITION_DIRECTION_BACKWARD + * and the history option is set as SCENE_HISTORY_OPTION_NO_HISTORY. @n + * + * For more information on the class features, see Scene Management. + */ +class _OSP_EXPORT_ BackwardSceneTransition + : public Tizen::Ui::Scenes::SceneTransition +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + * + * @remarks Use this constructor for adjacent backward transition with default options + * (SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_DESTROY_OPTION_DESTROY). + */ + BackwardSceneTransition(void); + + /** + * Initializes this instance of %BackwardSceneTransition with the specified parameters. + * + * @since 2.0 + * + * @param[in] animationType The transition animation type + * @param[in] destroyOption The destroy option whether to destroy the current scene or not + * @remarks Use this constructor for adjacent backward transition. + */ + BackwardSceneTransition(SceneTransitionAnimationType animationType, + SceneDestroyOption destroyOption = SCENE_DESTROY_OPTION_DESTROY); + + /** + * Initializes this instance of %BackwardSceneTransition with the specified parameters. + * + * @since 2.0 + * + * @param[in] destinationSceneId The scene ID of transition destination + * @param[in] animationType The transition animation type + * @param[in] destroyOption The destroy option whether to destroy the current scene or not + * @remarks Use this constructor for non-adjacent backward transition. + */ + BackwardSceneTransition(const SceneId& destinationSceneId, + SceneTransitionAnimationType animationType = SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SceneDestroyOption destroyOption = SCENE_DESTROY_OPTION_DESTROY); + + /** + * This destructor overrides Tizen::Ui::Scenes::SceneTransition::~SceneTransition(). + * + * @since 2.0 + */ + virtual ~BackwardSceneTransition(void); + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void BackwardSceneTransition_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void BackwardSceneTransition_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void BackwardSceneTransition_Reserved3(void) {} + +}; // BackwardSceneTransition +} } } // Tizen::Ui::Scenes + +#endif // _FUI_SCENES_BACKWARD_SCENE_TRANSITION_H_ diff --git a/inc/FUiScenesForwardSceneTransition.h b/inc/FUiScenesForwardSceneTransition.h new file mode 100644 index 0000000..44405f8 --- /dev/null +++ b/inc/FUiScenesForwardSceneTransition.h @@ -0,0 +1,126 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesForwardSceneTransition.h + * @brief This is the header file for the %ForwardSceneTransition class. + * + * This header file contains the declarations of the %ForwardSceneTransition class. + */ + +#ifndef _FUI_SCENES_FORWARD_SCENE_TRANSITION_H_ +#define _FUI_SCENES_FORWARD_SCENE_TRANSITION_H_ + +#include + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +/** + * @class ForwardSceneTransition + * @brief This class is the %ForwardSceneTransition class of a Tizen native application. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %ForwardSceneTransition class contains transition information, such as transition direction, transition destination, + * animation type, history option, and destroy option. By default, the transition direction is set as SCENE_TRANSITION_DIRECTION_FORWARD. @n + * + * For more information on the class features, see Scene Management. + */ +class _OSP_EXPORT_ ForwardSceneTransition + : public Tizen::Ui::Scenes::SceneTransition +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + * + * @remarks Use this constructor for transition through the policy provider with default options + * (SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_KEEP). + */ + ForwardSceneTransition(void); + + /** + * Initializes this instance of %ForwardSceneTransition with the specified parameters. + * + * @since 2.0 + * + * @param[in] destinationSceneId The scene ID of transition destination + * @param[in] animationType The transition animation type + * @param[in] historyOption The history option whether to add the current scene to the history or not + * @param[in] destroyOption The destroy option whether to destroy the current scene or not + * @remarks Use this constructor for transition to the specified @c destinationSceneId with options. + */ + ForwardSceneTransition(const SceneId& destinationSceneId, + SceneTransitionAnimationType animationType = SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SceneHistoryOption historyOption = SCENE_HISTORY_OPTION_ADD_HISTORY, + SceneDestroyOption destroyOption = SCENE_DESTROY_OPTION_KEEP); + + /** + * Initializes this instance of %ForwardSceneTransition with the specified parameters. + * + * @since 2.0 + * + * @param[in] animationType The transition animation type + * @param[in] historyOption The history option whether to add the current scene to the history or not + * @param[in] destroyOption The destroy option whether to destroy the current scene or not + * @remarks Use this constructor for transition through the policy provider. + */ + ForwardSceneTransition(SceneTransitionAnimationType animationType, + SceneHistoryOption historyOption = SCENE_HISTORY_OPTION_ADD_HISTORY, + SceneDestroyOption destroyOption = SCENE_DESTROY_OPTION_KEEP); + + /** + * This destructor overrides Tizen::Ui::Scenes::SceneTransition::~SceneTransition(). + * + * @since 2.0 + */ + virtual ~ForwardSceneTransition(void); + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ForwardSceneTransition_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ForwardSceneTransition_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ForwardSceneTransition_Reserved3(void) {} + +}; // ForwardSceneTransition +} } } // Tizen::Ui::Scenes + +#endif // _FUI_SCENES_FORWARD_SCENE_TRANSITION_H_ diff --git a/inc/FUiScenesIFormFactory.h b/inc/FUiScenesIFormFactory.h new file mode 100644 index 0000000..1f11cb4 --- /dev/null +++ b/inc/FUiScenesIFormFactory.h @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesIFormFactory.h + * @brief This is the header file for the %IFormFactory interface. + * + * This header file contains the declarations of the %IFormFactory interface. + */ + +#ifndef _FUI_SCENES_IFORM_FACTORY_H_ +#define _FUI_SCENES_IFORM_FACTORY_H_ + +#include +#include + + +namespace Tizen { namespace Ui { namespace Controls +{ +class Form; +}}} + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +/** + * @interface IFormFactory + * @brief This interface is the factory interface for creating the Form control instance. + * + * @since 2.0 + * + * The %IFormFactory interface is the factory interface for creating the Form control instance. + * The SceneManager calls CreateFormN() with form ID string when an instance of %Form control is required. + * + * For more information on the class features, see Scene Management. + */ +class _OSP_EXPORT_ IFormFactory +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, + * the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IFormFactory(void) {} + + /** + * Creates a Form instance. + * + * @since 2.0 + * + * @return A pointer to a new Form instance + * @param[in] formId The form ID string that specifies the ID of the Form to create + * @param[in] sceneId The scene ID corresponding to the Form + * @remarks The new instance managed by the SceneManager class must not be deleted manually. + */ + virtual Tizen::Ui::Controls::Form* CreateFormN(const Tizen::Base::String& formId, const Tizen::Ui::Scenes::SceneId& sceneId) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void IFormFactory_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void IFormFactory_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void IFormFactory_Reserved3(void) {} + +}; // IFormFactory +} } } // Tizen::Ui::Scenes + +#endif //_FUI_SCENES_IFORM_FACTORY_H_ diff --git a/inc/FUiScenesIPanelFactory.h b/inc/FUiScenesIPanelFactory.h new file mode 100644 index 0000000..d4f652e --- /dev/null +++ b/inc/FUiScenesIPanelFactory.h @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesIPanelFactory.h + * @brief This is the header file for the %IPanelFactory interface. + * + * This header file contains the declarations of the %IPanelFactory interface. + */ + +#ifndef _FUI_SCENES_IPANEL_FACTORY_H_ +#define _FUI_SCENES_IPANEL_FACTORY_H_ + +#include +#include + + +namespace Tizen { namespace Ui { namespace Controls +{ +class Panel; +}}} + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +/** + * @interface IPanelFactory + * @brief This interface is the factory interface for creating the Panel control instance. + * + * @since 2.0 + * + * The %IPanelFactory interface is the factory interface for creating the Panel control instance. + * The SceneManager class calls CreatePanelN() with panel ID string when an instance of %Panel control is required. + * + * For more information on the class features, see Scene Management. + */ +class _OSP_EXPORT_ IPanelFactory +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, + * the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~IPanelFactory(void) {} + + /** + * Creates a Panel instance. + * + * @since 2.0 + * + * @return A pointer to a new Panel instance + * @param[in] panelId The panel ID string that specifies the ID of the Panel to create + * @param[in] sceneId The scene ID corresponding to the Panel + * @remarks The new instance managed by the SceneManager class must not be deleted manually. + */ + virtual Tizen::Ui::Controls::Panel* CreatePanelN(const Tizen::Base::String& panelId, const Tizen::Ui::Scenes::SceneId& sceneId) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void IPanelFactory_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void IPanelFactory_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void IPanelFactory_Reserved3(void) {} + +}; // IPanelFactory +} } } // Tizen::Ui::Scenes + +#endif //_FUI_SCENES_IPANEL_FACTORY_H_ diff --git a/inc/FUiScenesISceneAnimationProvider.h b/inc/FUiScenesISceneAnimationProvider.h new file mode 100644 index 0000000..c4f0b85 --- /dev/null +++ b/inc/FUiScenesISceneAnimationProvider.h @@ -0,0 +1,109 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesISceneAnimationProvider.h + * @brief This is the header file for the %ISceneAnimationProvider interface. + * + * This header file contains the declarations of the %ISceneAnimationProvider interface. + */ + +#ifndef _FUI_SCENES_ISCENE_ANIMATION_PROVIDER_H_ +#define _FUI_SCENES_ISCENE_ANIMATION_PROVIDER_H_ + +#include + + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +}}} + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +/** + * @interface ISceneAnimationProvider + * @brief This interface is the interface for providing custom animation operation on scene transition. + * + * @since 2.0 + * + * The %ISceneAnimationProvider interface is the interface for providing custom animation operation on scene transition. + * + * For more information on the class features, see Transition Animations. + */ +class _OSP_EXPORT_ ISceneAnimationProvider +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, + * the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ISceneAnimationProvider(void) {} + + /** + * Called on scene transition exactly before current Form (form to form transition) is changed or show state + * (panel to panel transition) is changed. + * + * @since 2.0 + * + * @param[in] sceneId The scene ID that requires the animator settings + * @param[in] pArgs A pointer to an argument list + * @param[in] type The animation type + * @param[in] formTransition Set to @c true if the transition is form to form transition, @n + * else @c false if the transition is panel to panel transition (Based on same Form) + * @remarks To show custom scene transition animation, add animator modification code in this callback. @n + * Animation is initiated by SceneManager after this method is called. + * The form to form transition animation is triggered by Tizen::Ui::Animations::FrameAnimator::SetCurrentForm(), + * and the panel to panel transition animation is triggered by Tizen::Ui::Animations::ControlAnimator::SetShowState(). + * + */ + virtual void PrepareAnimation(const Tizen::Ui::Scenes::SceneId& sceneId, Tizen::Base::Collection::IList* pArgs, + Tizen::Ui::Scenes::SceneTransitionAnimationType type, bool formTransition) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ISceneAnimationProvider_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ISceneAnimationProvider_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ISceneAnimationProvider_Reserved3(void) {} + +}; // ISceneAnimationProvider +} } } // Tizen::Ui::Scenes + +#endif //_FUI_SCENES_ISCENE_ANIMATION_PROVIDER_H_ diff --git a/inc/FUiScenesISceneEventListener.h b/inc/FUiScenesISceneEventListener.h new file mode 100644 index 0000000..e401399 --- /dev/null +++ b/inc/FUiScenesISceneEventListener.h @@ -0,0 +1,123 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesISceneEventListener.h + * @brief This is the header file for the %ISceneEventListener interface. + * + * This header file contains the declarations of the %ISceneEventListener interface. + */ + +#ifndef _FUI_SCENES_ISCENE_EVENT_LISTENER_H_ +#define _FUI_SCENES_ISCENE_EVENT_LISTENER_H_ + +#include +#include +#include +#include + + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +}}} + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +/** + * @interface ISceneEventListener + * @brief This interface is the listener interface for receiving the scene transition events. + * + * @since 2.0 + * + * The %ISceneEventListener interface is the listener interface for receiving the scene transition events. + * The class that processes a scene transition event implements this interface and registers using + * the SceneManager::AddSceneEventListener() method. + * + * For more information on the class features, see Scene Management. + */ +class _OSP_EXPORT_ ISceneEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, + * the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ISceneEventListener(void) {} + + /** + * Called after setting as current scene. @n + * The UI element (Tizen::Ui::Controls::Form or Tizen::Ui::Controls::Panel) + * has been added to a container (Frame or Form) and is ready to update. + * + * @since 2.0 + * + * @param[in] previousSceneId The scene ID of the deactivated scene + * @param[in] currentSceneId The scene ID of the newly activated scene + * @param[in] pArgs A pointer to an argument list that is user-specified + * @remarks The argument list must be cleaned up to free memory. + */ + virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs) = 0; + + /** + * Called when the current scene is deactivated. + * + * @since 2.0 + * + * @param[in] currentSceneId The scene ID of the scene being deactivated + * @param[in] nextSceneId The scene ID of the next active scene + * + */ + virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) = 0; + + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ISceneEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ISceneEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ISceneEventListener_Reserved3(void) {} + +}; // ISceneEventListener +} } } // Tizen::Ui::Scenes + +#endif //_FUI_SCENES_ISCENE_EVENT_LISTENER_H_ diff --git a/inc/FUiScenesISceneManagerEventListener.h b/inc/FUiScenesISceneManagerEventListener.h new file mode 100644 index 0000000..c5c0cfa --- /dev/null +++ b/inc/FUiScenesISceneManagerEventListener.h @@ -0,0 +1,109 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesISceneManagerEventListener.h + * @brief This is the header file for the %ISceneManagerEventListener interface. + * + * This header file contains the declarations of the %ISceneManagerEventListener interface. + */ + +#ifndef _FUI_SCENES_ISCENE_MANAGER_EVENT_LISTENER_H_ +#define _FUI_SCENES_ISCENE_MANAGER_EVENT_LISTENER_H_ + +#include +#include + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +/** + * @interface ISceneManagerEventListener + * @brief This interface provides listeners for managing scenes and scene states. + * + * @since 2.0 + * + * The %ISceneManagerEventListener interface provides listeners for managing scenes and scene states. + * + * For more information on the class features, see Scene Management. + */ +class _OSP_EXPORT_ ISceneManagerEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, + * the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ISceneManagerEventListener(void) {} + + /** + * Called when the scene transition is started. + * + * @since 2.0 + * + * @param[in] currentSceneId The scene ID of the scene being deactivated + * @param[in] nextSceneId The scene ID of the next active scene + * + */ + virtual void OnSceneTransitionStarted(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Ui::Scenes::SceneId& nextSceneId) = 0; + + /** + * Called after the scene transition is completed. + * + * @since 2.0 + * + * @param[in] previousSceneId The scene ID of the deactivated scene + * @param[in] currentSceneId The scene ID of the newly activated scene + * @remarks This method is called after the scene is activated using the ISceneEventListener::OnSceneActivatedN() callback method. + */ + virtual void OnSceneTransitionCompleted(const Tizen::Ui::Scenes::SceneId& previousSceneId, + const Tizen::Ui::Scenes::SceneId& currentSceneId) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ISceneManagerEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ISceneManagerEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ISceneManagerEventListener_Reserved3(void) {} + +}; // ISceneManagerEventListener +} } } // Tizen::Ui::Scenes + +#endif //_FUI_SCENES_ISCENE_MANAGER_EVENT_LISTENER_H_ diff --git a/inc/FUiScenesISceneTransitionPolicyProvider.h b/inc/FUiScenesISceneTransitionPolicyProvider.h new file mode 100644 index 0000000..c2f7e1d --- /dev/null +++ b/inc/FUiScenesISceneTransitionPolicyProvider.h @@ -0,0 +1,104 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesISceneTransitionPolicyProvider.h + * @brief This is the header file for the %ISceneTransitionPolicyProvider interface. + * + * This header file contains the declarations of the %ISceneTransitionPolicyProvider interface. + */ + +#ifndef _FUI_SCENES_ISCENE_TRANSITION_POLICY_PROVIDER_H_ +#define _FUI_SCENES_ISCENE_TRANSITION_POLICY_PROVIDER_H_ + +#include + + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +}}} + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +/** + * @interface ISceneTransitionPolicyProvider + * @brief This interface provides the scene transition policies. + * + * @since 2.0 + * + * The %ISceneTransitionPolicyProvider interface is used to provide the scenario logic for scene transitions. + * + * For more information on the class features, see Scene Management. + */ +class _OSP_EXPORT_ ISceneTransitionPolicyProvider +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, + * the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~ISceneTransitionPolicyProvider(void) {} + + /** + * Gets the next scene. @n + * Called on SceneManager#GoForward(const Tizen::Base::Collection::IList*,SceneTransitionAnimationType,SceneHistoryOption,SceneDestroyOption) + * to determine the next scene. + * + * @since 2.0 + * + * @return A scene ID + * @param[in] currentSceneId The scene ID of the active Scene + * @param[in] pArgs A pointer to an argument list + */ + virtual Tizen::Ui::Scenes::SceneId GetNextScene(const Tizen::Ui::Scenes::SceneId& currentSceneId, + const Tizen::Base::Collection::IList* pArgs) = 0; + + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ISceneTransitionPolicyProvider_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ISceneTransitionPolicyProvider_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void ISceneTransitionPolicyProvider_Reserved3(void) {} + +}; // ISceneTransitionPolicyProvider +} } } // Tizen::Ui::Scenes + +#endif //_FUI_SCENES_ISCENE_TRANSITION_POLICY_PROVIDER_H_ diff --git a/inc/FUiScenesScene.h b/inc/FUiScenesScene.h new file mode 100644 index 0000000..8299c95 --- /dev/null +++ b/inc/FUiScenesScene.h @@ -0,0 +1,193 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesScene.h + * @brief This is the header file for the %Scene class. + * + * This header file contains the declarations of the %Scene class. + */ + +#ifndef _FUI_SCENES_SCENE_H_ +#define _FUI_SCENES_SCENE_H_ + +#include +#include + + +namespace Tizen { namespace Ui { namespace Controls +{ +class Form; +class Panel; +}}} + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +class ISceneEventListener; + +/** + * @class Scene + * @brief This class is the %Scene class of a Tizen native applications. + * + * @since 2.0 + * + * The %Scene is the basic unit of UI switching. @n + * The %Scene class is the item class for scene management. It represents individual UI scene. + * A scene is combination of form and panel, panel can be omitted. + * + * For more information on the class features, see Scene Management. + */ +class _OSP_EXPORT_ Scene + : public Tizen::Base::Object +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Scene(void); + + /** + * Checks whether the specified instance of %Scene equals the current instance. + * + * @since 2.0 + * + * @return @c true if the specified instance equals the current instance, @n + * else @c false + * @param[in] rhs An instance of %Scene + * @remarks The method returns @c false if the specified object is not %Scene. + */ + virtual bool Equals(const Object& rhs) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * Gets the string ID of %Scene. + * + * @since 2.0 + * + * @return The name of %Scene + * @see SetSceneId() + */ + SceneId GetSceneId(void) const; + + /** + * Gets the string ID of Form. + * + * @since 2.0 + * + * @return The name of Form + */ + Tizen::Base::String GetFormId(void) const; + + /** + * Gets the string ID of Panel. + * + * @since 2.0 + * + * @return The name of Panel, @n + * else an empty string if the Panel is not specified + */ + Tizen::Base::String GetPanelId(void) const; + + /** + * Gets the associated Form instance pointer. + * + * @since 2.0 + * + * @return The Form instance pointer + * @see SetForm() + */ + Tizen::Ui::Controls::Form* GetForm(void) const; + + /** + * Gets the associated Panel instance pointer. + * + * @since 2.0 + * + * @return The Panel instance pointer, @n + * else a @c null pointer if the %Panel is not specified + * @remarks The Panel is optional component of %Scene so it may not be always valid. + * @see SetPanel() + */ + Tizen::Ui::Controls::Panel* GetPanel(void) const; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void Scene_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void Scene_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void Scene_Reserved3(void) {} + +private: + /** + * This default constructor is intentionally declared as private so that only the platform can create an instance. + * + * @since 2.0 + */ + Scene(void); + + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.0 + */ + Scene(const Scene& rhs); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.0 + */ + Scene& operator =(const Scene& rhs); + +private: + friend class _SceneImpl; + class _SceneImpl* __pSceneImpl; + +}; // Scene +} } } // Tizen::Ui::Scenes + +#endif //_FUI_SCENES_SCENE_H_ diff --git a/inc/FUiScenesSceneManager.h b/inc/FUiScenesSceneManager.h new file mode 100644 index 0000000..97ad0f6 --- /dev/null +++ b/inc/FUiScenesSceneManager.h @@ -0,0 +1,525 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesSceneManager.h + * @brief This is the header file for the %SceneManager class. + * + * This header file contains the declarations of the %SceneManager class. + */ + +#ifndef _FUI_SCENES_SCENE_MANAGER_H_ +#define _FUI_SCENES_SCENE_MANAGER_H_ + +#include +#include +#include +#include + + +namespace Tizen { namespace Ui { namespace Controls +{ +class Form; +class Panel; +}}} +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +template class IListT; +}}} + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +class Scene; +class ForwardSceneTransition; +class BackwardSceneTransition; +class IFormFactory; +class IPanelFactory; +class ISceneEventListener; +class ISceneManagerEventListener; +class ISceneAnimationProvider; +class ISceneTransitionPolicyProvider; + +/** + * @class SceneManager + * @brief This class provides methods to manage scenes and scene states. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %SceneManager class provides methods to manage scenes and scene states. This class is simplified to a single method call for UI Scene transition that changes the GUI, such as + * form to form transition or tab to tab transition. @n + * + * For more information on the class features, see Scene Management and Transition Animations. + */ +class _OSP_EXPORT_ SceneManager + : public Tizen::Base::Object +{ +public: + /** + * Gets the %SceneManager instance. + * + * @since 2.0 + * + * @return A pointer to the %SceneManager instance if successful, @n + * else @c null if it fails + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static SceneManager* GetInstance(void); + + /** + * Registers a form factory. @n + * The IFormFactory::CreateFormN() is called when a new form is required. + * + * @since 2.0 + * + * @return An error code + * @param[in] formFactory The user-defined form factory instance + * @exception E_SUCCESS The method is successful. + * @see IFormFactory, IFormFactory::CreateFormN() + */ + result RegisterFormFactory(const IFormFactory& formFactory); + + /** + * Registers a panel factory. @n + * The IPanelFactory::CreatePanelN() is called when a new panel is required. + * + * @since 2.0 + * + * @return An error code + * @param[in] panelFactory The user-defined panel factory instance + * @exception E_SUCCESS The method is successful. + * @see IPanelFactory, IPanelFactory::CreatePanelN() + */ + result RegisterPanelFactory(const IPanelFactory& panelFactory); + + /** + * Registers a scene. + * A scene is combination of a form and a panel. + * + * @since 2.0 + * + * @return An error code + * @param[in] sceneId The scene ID + * @param[in] formId The form ID string + * @param[in] panelId The panel ID string + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OBJ_ALREADY_EXIST The specified @c sceneId already exists. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * + */ + result RegisterScene(const SceneId& sceneId, const Tizen::Base::String& formId, const Tizen::Base::String& panelId); + + /** + * Registers scene(s) with the specified resource ID. + * This method does not remove a scene that is already registered. + * + * @since 2.0 + * + * @return An error code + * @param[in] resourceId The resource ID of the scene(s) + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_FILE_NOT_FOUND The corresponding resource file is not found. + * @exception E_OBJ_ALREADY_EXIST A scene ID already exists. + * @exception E_SYSTEM A system error has occurred. + * @remarks A duplicated scene (scene ID) will not be registered. Also it throws the E_OBJ_ALREADY_EXIST exception. + * @see UnregisterScene() + * + */ + result RegisterScene(const Tizen::Base::String& resourceId); + + /** + * Unregisters the specified scene. + * + * @since 2.0 + * + * @return An error code + * @param[in] sceneId The scene ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OBJ_NOT_FOUND The specified @c sceneId does not exist. + * @see RegisterScene() + */ + result UnregisterScene(const SceneId& sceneId); + + /** + * Adds a %SceneManager event listener. + * + * @since 2.0 + * + * @return An error code + * @param[in] sceneManagerEventListener An instance of ISceneManagerEventListener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_OBJ_ALREADY_EXIST The listener with the specified type is already added. + * @see RemoveSceneManagerEventListener(), ISceneManagerEventListener, + * ISceneManagerEventListener::OnSceneTransitionCompleted(), + * ISceneManagerEventListener::OnSceneTransitionStarted() + */ + result AddSceneManagerEventListener(ISceneManagerEventListener& sceneManagerEventListener); + + /** + * Removes a %SceneManager event listener. + * + * @since 2.0 + * + * @return An error code + * @param[in] sceneManagerEventListener An instance of ISceneManagerEventListener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified listener is not found. + * @see AddSceneManagerEventListener(), ISceneManagerEventListener + */ + result RemoveSceneManagerEventListener(ISceneManagerEventListener& sceneManagerEventListener); + + /** + * Adds a Scene event listener. + * + * @since 2.0 + * + * @return An error code + * @param[in] sceneId The target scene ID + * @param[in] sceneEventListener An instance of ISceneEventListener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_INVALID_ARG The specified @c sceneId is invalid. + * @exception E_OBJ_ALREADY_EXIST The listener with the specified type is already added. + * @see RemoveSceneEventListener, ISceneEventListener, + * ISceneEventListener::OnSceneActivatedN(), ISceneEventListener::OnSceneDeactivated() + */ + result AddSceneEventListener(const SceneId& sceneId, ISceneEventListener& sceneEventListener); + + /** + * Removes a Scene event listener. + * + * @since 2.0 + * + * @return An error code + * @param[in] sceneId The target scene ID + * @param[in] sceneEventListener An instance of ISceneEventListener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c sceneId is invalid. + * @exception E_OBJ_NOT_FOUND The specified @c sceneId is not found. + * @see AddSceneEventListener, ISceneEventListener + */ + result RemoveSceneEventListener(const SceneId& sceneId, ISceneEventListener& sceneEventListener); + + /** + * Sets a Scene animation provider. + * + * @since 2.0 + * + * @return An error code + * @param[in] sceneId The target scene ID + * @param[in] pSceneAnimationProvider An instance of ISceneAnimationProvider to set, or null to clear previous one. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c sceneId is invalid. + * @exception E_OBJ_NOT_FOUND The specified scene is not found. + * @see ISceneAnimationProvider + */ + result SetSceneAnimationProvider(const SceneId& sceneId, ISceneAnimationProvider* pSceneAnimationProvider); + + /** + * Sets a Scene transition policy provider. + * + * @since 2.0 + * + * @return An error code + * @param[in] pSceneTransitionPolicyProvider An instance of ISceneTransitionPolicyProvider to set, + * or null to clear previous one. + * @exception E_SUCCESS The method is successful. + * @see ISceneTransitionPolicyProvider, ISceneTransitionPolicyProvider::GetNextScene(), GoForward() + */ + result SetSceneTransitionPolicyProvider(ISceneTransitionPolicyProvider* pSceneTransitionPolicyProvider); + + /** + * Sets the default values for the individual animation types. + * + * @since 2.0 + * + * @return An error code + * @param[in] animationType The target animation type + * @param[in] duration The duration of the animation in milliseconds @n The maximum duration is one second. + * @param[in] interpolatorType The type of interpolator used for the intermediate value calculation of the animation + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks It throws an E_INVALID_ARG exception if the animationType is SCENE_TRANSITION_ANIMATION_TYPE_NONE + * or SCENE_TRANSITION_ANIMATION_TYPE_CUSTOM. + * @see GoForward(), GoBackward() + */ + result SetFormTransitionAnimationDefaultValues(SceneTransitionAnimationType animationType, long duration, + Tizen::Ui::Animations::AnimationInterpolatorType interpolatorType); + + /** + * Requests forward scene transition with the specified scene transition. + * + * @since 2.0 + * + * @return An error code + * @param[in] sceneTransition The scene transition that describes the destination and options + * @param[in] pArgs A pointer to an IList that contains the scene transition parameters + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_IN_PROGRESS A previous transition is in progress. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_OBJ_NOT_FOUND The destination scene ID is not found in the registered scenes. + * @exception E_INVALID_STATE The factory instance ( @ref IFormFactory, @ref IPanelFactory ) or + * ISceneTransitionPolicyProvider is not set. + * @exception E_SYSTEM A system error has occurred. @n + * (Internal logic or failed to create control from a factory). + * @remarks To use the policy provider operation, SceneTransition's destinationSceneId must be of length 0, + * also you must register the user-defined ISceneTransitionPolicyProvider and implement the + * ISceneTransitionPolicyProvider::GetNextScene() callback method. + **/ + result GoForward(const ForwardSceneTransition& sceneTransition, const Tizen::Base::Collection::IList* pArgs = null); + + /** + * Requests forward scene transition with the specified transition ID. + * + * @since 2.0 + * + * @return An error code + * @param[in] transitionId The transition ID that describes the destination and options + * @param[in] pArgs A pointer to an IList that contains the scene transition parameters + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_IN_PROGRESS A previous transition is in progress. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_OBJ_NOT_FOUND The destination scene ID is not found in the registered scenes. + * @exception E_INVALID_STATE The factory instance ( @ref IFormFactory, @ref IPanelFactory ) or + * ISceneTransitionPolicyProvider is not set. + * @exception E_SYSTEM A system error has occurred. @n + * (Internal logic or failed to create control from a factory). + * @remarks To use the policy provider operation, SceneTransition's destinationSceneId must be of length 0, + * also you must register the user-defined ISceneTransitionPolicyProvider and implement the + * ISceneTransitionPolicyProvider::GetNextScene() callback method. + **/ + result GoForward(const SceneTransitionId& transitionId, const Tizen::Base::Collection::IList* pArgs = null); + + /** + * Requests backward scene transition with the specified scene transition. + * + * @since 2.0 + * + * @return An error code + * @param[in] sceneTransition The scene transition that describes the destination and options + * @param[in] pArgs A pointer to an IList that contains the scene transition parameters + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_IN_PROGRESS A previous transition is in progress. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_OBJ_NOT_FOUND The scene ID of the previous scene in the internal history is not found in + * the current registered scenes. + * @exception E_INVALID_STATE The factory instance ( @ref IFormFactory, @ref IPanelFactory ) or + * ISceneTransitionPolicyProvider is not set. + * @exception E_UNDERFLOW The scene history is empty. + * @exception E_SYSTEM A system error has occurred. @n + * (Internal logic or failed to create control from a factory). + * @remarks An item removed from the internal history except the E_SYSTEM exception case. @n + * For non-adjacent backward transition, the current scene and the scenes between the current scene and + * the requested scene would be destroyed if SCENE_DESTROY_OPTION_KEEP is not specified as destroyOption. @n + * If the destroy option is selected then the sibling panel scenes (sharing same base form) are also destroyed. + */ + result GoBackward(const BackwardSceneTransition& sceneTransition, const Tizen::Base::Collection::IList* pArgs = null); + + /** + * Requests backward scene transition with the specified transition ID. + * + * @since 2.0 + * + * @return An error code + * @param[in] transitionId The transition ID that describes the destination and options + * @param[in] pArgs A pointer to an IList that contains the scene transition parameters + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_IN_PROGRESS A previous transition is in progress. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_OBJ_NOT_FOUND The scene ID of the previous scene in the internal history is not found in + * the current registered scenes. + * @exception E_INVALID_STATE The factory instance ( @ref IFormFactory, @ref IPanelFactory ) or + * ISceneTransitionPolicyProvider is not set. + * @exception E_UNDERFLOW The scene history is empty. + * @exception E_SYSTEM A system error has occurred. @n + * (Internal logic or failed to create control from a factory). + * @remarks An item removed from the internal history except the E_SYSTEM exception case. @n + * For non-adjacent backward transition, the current scene and the scenes between the current scene and + * the requested scene would be destroyed if SCENE_DESTROY_OPTION_KEEP is not specified as destroyOption. @n + * If the destroy option is selected then the sibling panel scenes (sharing same base form) are also destroyed. + */ + result GoBackward(const SceneTransitionId& transitionId, const Tizen::Base::Collection::IList* pArgs = null); + + /** + * Gets a pointer to the current Scene instance. + * + * @since 2.0 + * + * @return A pointer to the current Scene instance + * @see GetCurrentSceneId() + */ + Scene* GetCurrentScene(void) const; + + /** + * Gets the current scene ID string. + * + * @since 2.0 + * + * @return The scene ID + * @see GetCurrentScene() + */ + SceneId GetCurrentSceneId(void) const; + + /** + * Checks whether the Scene instance with the specified sceneId has been destroyed or not. + * + * @since 2.0 + * + * @return @c true if the scene instance has not been destroyed, @n + * else @c false + * @param[in] sceneId The scene ID + * @remarks This function is useful to check state of the scene, because the scene lifetime is determined + * by scene transition option and user can destroy the scene in real time. + */ + bool IsSceneAlive(const SceneId& sceneId) const; + + /** + * Destroys the specified scene. + * + * @since 2.0 + * + * @return An error code + * @param[in] sceneId The scene ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The current scene cannot be destroyed. + * @exception E_OBJ_NOT_FOUND The specified @c sceneId does not exist. + * @exception E_SYSTEM A system error has occurred. + */ + result DestroyScene(const SceneId& sceneId); + + /** + * Brings the current scene to the topmost to get back the control of scene management. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_OPERATION_FAILED The current scene is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks If a user sets a form as a current form on a frame by calling SetCurrentForm(), + * they will no longer be under the control of %SceneManager. In this case, + * they can get back the control of scene management easily by calling this method. + * @see Tizen::Ui::Controls::Frame::SetCurrentForm + */ + result BringCurrentSceneToTop(void); + + /** + * Clears the scene history. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @see AddSceneHistory() + */ + result ClearSceneHistory(void); + + /** + * Adds the scene to the scene history. + * + * @since 2.0 + * + * @return An error code + * @param[in] sceneId The scene ID + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OBJ_NOT_FOUND The specified @c sceneId is not found in the registered scenes. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @see ClearSceneHistory() + */ + result AddToSceneHistory(const SceneId& sceneId); + + /** + * Gets the scene history list. + * + * @since 2.0 + * + * @return A pointer to the list that contains the scene history + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::Collection::IListT* GetSceneHistoryN(void) const; + +private: + /** + * This default constructor is intentionally declared as private to implement the Singleton semantic. + * + * @since 2.0 + */ + SceneManager(void); + + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.0 + */ + SceneManager(const SceneManager& rhs); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.0 + */ + SceneManager& operator =(const SceneManager& rhs); + + /** + * This destructor is intentionally declared as private to implement the Singleton semantic. + * + * @since 2.0 + */ + virtual ~SceneManager(void); + + /** + * Initializes the instance of the this class. + * + * @since 2.0 + * + * @return An error code. + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * + */ + result Construct(void); + + static void InitSingleton(void); + static void DestroySingleton(void); + +private: + friend class _SceneManagerImpl; + class _SceneManagerImpl* __pSceneManagerImpl; + static SceneManager* __pSceneManagerInstance; + +}; // SceneManager +} } } // Tizen::Ui::Scenes + +#endif //_FUI_SCENES_SCENE_MANAGER_H_ diff --git a/inc/FUiScenesSceneTransition.h b/inc/FUiScenesSceneTransition.h new file mode 100644 index 0000000..6f42834 --- /dev/null +++ b/inc/FUiScenesSceneTransition.h @@ -0,0 +1,268 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesSceneTransition.h + * @brief This is the header file for the %SceneTransition class. + * + * This header file contains the declarations of the %SceneTransition class. + */ + +#ifndef _FUI_SCENES_SCENE_TRANSITION_H_ +#define _FUI_SCENES_SCENE_TRANSITION_H_ + +#include +#include + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +/** + * @class SceneTransition + * @brief This class is the %SceneTransition class of a Tizen native application. + * + * @since 2.0 + * + * The %SceneTransition class contains transition information, such as transition direction, transition destination, + * animation type, history option, and destroy option. @n + * + * For more information on the class features, see Scene Management. + */ +class _OSP_EXPORT_ SceneTransition + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + SceneTransition(void); + + /** + * Copying of objects using this copy constructor is allowed. + * + * @since 2.0 + * + * @param[in] rhs An instance of %SceneTransition + */ + SceneTransition(const SceneTransition& rhs); + + /** + * Initializes this instance of %SceneTransition with the specified parameters. + * + * @since 2.0 + * + * @param[in] direction The transition direction + * @param[in] destinationSceneId The scene ID of transition destination + * @param[in] animationType The transition animation type + * @param[in] historyOption The history option whether to add the current scene to the history or not + * @param[in] destroyOption The destroy option whether to destroy the current scene or not + */ + SceneTransition(SceneTransitionDirection direction, const SceneId& destinationSceneId, + SceneTransitionAnimationType animationType, + SceneHistoryOption historyOption, SceneDestroyOption destroyOption); + + /** + * Assigns the value of the specified instance to the current instance of %SceneTransition. + * + * @since 2.0 + * + * @param[in] rhs An instance of %SceneTransition + */ + SceneTransition& operator =(const SceneTransition& rhs); + + /** + * Checks whether the specified instance of %SceneTransition equals the current instance. + * + * @since 2.0 + * + * @return @c true if the specified instance equals the current instance, @n + * else @c false + * @param[in] rhs An instance of %SceneTransition + * @remarks The method returns @c false if the specified object is not Scene. + */ + virtual bool Equals(const Object& rhs) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~SceneTransition(void); + + +// result SetTransitionId(TransitionId& transitionId); + + /** + * Sets the scene transition direction. + * + * @since 2.0 + * + * @return An error code + * @param[in] direction The transition direction + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * + */ + result SetDirection(SceneTransitionDirection direction); + + /** + * Gets the scene transition direction. + * + * @since 2.0 + * + * @return The direction of scene transition + * + */ + SceneTransitionDirection GetDirection(void) const; + + /** + * Sets the scene transition destination scene. + * + * @since 2.0 + * + * @return An error code + * @param[in] sceneId The scene ID of transition destination + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * + */ + result SetDestinationSceneId(const SceneId& sceneId); + + /** + * Gets the scene transition destination scene. + * + * @since 2.0 + * + * @return The scene ID of transition destination + * + */ + SceneId GetDestinationSceneId(void) const; + + /** + * Sets the scene transition animation type. + * + * @since 2.0 + * + * @return An error code + * @param[in] animationType The transition animation type + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * + */ + result SetAnimationType(SceneTransitionAnimationType animationType); + + /** + * Gets the scene transition animation type. + * + * @since 2.0 + * + * @return The transition animation type + * + */ + SceneTransitionAnimationType GetAnimationType(void) const; + + /** + * Sets the scene transition history option. + * + * @since 2.0 + * + * @return An error code + * @param[in] historyOption The history option whether to add the current scene to the history or not + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * + */ + result SetHistoryOption(SceneHistoryOption historyOption); + + /** + * Gets the scene transition history option. + * + * @since 2.0 + * + * @return The history option + * + */ + SceneHistoryOption GetHistoryOption(void) const; + + /** + * Sets the scene transition destroy option. + * + * @since 2.0 + * + * @return An error code + * @param[in] destroyOption The destroy option whether to destroy the current scene or not + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * + */ + result SetDestroyOption(SceneDestroyOption destroyOption); + + /** + * Gets the scene transition destroy option. + * + * @since 2.0 + * + * @return The destroy option + * + */ + SceneDestroyOption GetDestroyOption(void) const; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void SceneTransition_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void SceneTransition_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.0 + // + virtual void SceneTransition_Reserved3(void) {} + +private: + friend class _SceneTransitionImpl; + class _SceneTransitionImpl* __pSceneTransitionImpl; + +}; // SceneTransition +} } } // Tizen::Ui::Scenes + +#endif // _FUI_SCENES_SCENE_TRANSITION_H_ diff --git a/inc/FUiScenesTypes.h b/inc/FUiScenesTypes.h new file mode 100644 index 0000000..57a722c --- /dev/null +++ b/inc/FUiScenesTypes.h @@ -0,0 +1,111 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesTypes.h + * @brief This is the header file for the common data types used by the scene management. + * + * This header file contains the declarations of the common data types and constants used by the scene management. + */ + +#ifndef _FUI_SCENES_TYPES_H_ +#define _FUI_SCENES_TYPES_H_ + + +#include + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +/** + * The scene ID. + * + * @since 2.0 + */ +typedef Tizen::Base::String SceneId; + +/** + * The transition ID. + * + * @since 2.0 + */ +typedef Tizen::Base::String SceneTransitionId; + +/** + * @enum SceneTransitionDirection + * + * Defines the scene transition directions whether forward or backward. + * + * @since 2.0 + */ +enum SceneTransitionDirection +{ + SCENE_TRANSITION_DIRECTION_FORWARD, /**< The transition is forward */ + SCENE_TRANSITION_DIRECTION_BACKWARD, /**< The transition is backward */ +}; + +/** + * @enum SceneHistoryOption + * + * Defines the scene history operation options whether to add to history or not. + * + * @since 2.0 + */ +enum SceneHistoryOption +{ + SCENE_HISTORY_OPTION_ADD_HISTORY, /**< The current scene would be added to history */ + SCENE_HISTORY_OPTION_NO_HISTORY, /**< The current scene would not be added to history */ +}; + +/** + * @enum SceneDestroyOption + * + * Defines the scene destroy options. + * + * @since 2.0 + */ +enum SceneDestroyOption +{ + SCENE_DESTROY_OPTION_KEEP, /**< The current scene will not be destroyed */ + SCENE_DESTROY_OPTION_DESTROY, /**< The current scene will be destroyed after the transition is completed */ +}; + +/** + * @enum SceneTransitionAnimationType + * + * Defines the scene transition animation types. + * + * @since 2.0 + * + * @see Tizen::Ui::Animations::FrameAnimatorFormTransitionAnimation + */ +enum SceneTransitionAnimationType +{ + SCENE_TRANSITION_ANIMATION_TYPE_NONE, /**< No transition animation */ + SCENE_TRANSITION_ANIMATION_TYPE_CUSTOM, /**< The custom transition animation with ISceneAnimationProvider */ + SCENE_TRANSITION_ANIMATION_TYPE_LEFT, /**< The transition animation using translate left animation */ + SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, /**< The transition animation using translate right animation */ + SCENE_TRANSITION_ANIMATION_TYPE_FADE_IN_OUT, /**< The transition animation using alpha animation */ + SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_IN, /**< The transition animation using scale animation */ + SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_OUT, /**< The transition animation using scale animation */ + SCENE_TRANSITION_ANIMATION_TYPE_DEPTH_IN, /**< The transition animation using scale and alpha animation */ + SCENE_TRANSITION_ANIMATION_TYPE_DEPTH_OUT, /**< The transition animation using scale and alpha animation */ +}; +} } } // Tizen::Ui::Scenes + +#endif //_FUI_SCENES_TYPES_H_ diff --git a/inc/FUiSystemUtil.h b/inc/FUiSystemUtil.h new file mode 100755 index 0000000..edec3aa --- /dev/null +++ b/inc/FUiSystemUtil.h @@ -0,0 +1,167 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiSystemUtil.h + * @brief This is the header file for the SystemUtil + * + * This header file contains the declarations of the SystemUtil class. + * + */ + +#ifndef _FUI_SYSTEM_UTIL_H_ +#define _FUI_SYSTEM_UTIL_H_ + +#include + +namespace Tizen { namespace Graphics +{ +class Bitmap; +class Point; +}} + +namespace Tizen { namespace Ui +{ + +/** + * @enum KeyEventType + * + * Defines key event types. + * + * @since 2.0 + */ +enum KeyEventType +{ + KEY_EVENT_TYPE_PRESSED, /**< Key pressed event type */ + KEY_EVENT_TYPE_RELEASED, /**< Key released event type */ +}; + +/** + * @enum TouchEventType + * + * Defines touch event types. + * + * @since 2.0 + */ +enum TouchEventType +{ + TOUCH_EVENT_TYPE_PRESSED, /**< Touch pressed event type */ + TOUCH_EVENT_TYPE_RELEASED, /**< Touch released event type */ + TOUCH_EVENT_TYPE_MOVED /**< Touch moved event type */ +}; + +/** + * @if VISPARTNER-MANUFACTURER + * @class SystemUtil + * @brief This is a class for system utililty such as touch, key, and capturing screen. It provides + * functionalities to simulate user inputs. + * @since 2.0 + * @final This class is not intended for extension. + * @visibility partner-manufacturer + * + * This class provides methods to generate user's input events such as + * touch and key events for helping test application and to capture current screen. + * @endif + */ +class _OSP_EXPORT_ SystemUtil +{ +public: + /** + * @if VISPARTNER-MANUFACTURER + * Generates a key event + * + * @since 2.0 + * @visibility partner-manufacturer + * @privilege %http://tizen.org/privilege/inputmanager + * + * @return An error code + * @param[in] keyEvent The event type of the key to be generated + * @param[in] keyCode The code of the key + * @exception E_SUCCESS The method was successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_OPERATION_FAILED An error occurred in the underlying system. + * @exception E_INVALID_ARG The specified @c keyEvent or @c keyCode is not supported. + * @endif + */ + static result GenerateKeyEvent(KeyEventType keyEvent, KeyCode keyCode); + + /** + * @if VISPARTNER-MANUFACTURER + * Generates a touch event + * + * @since 2.0 + * @visibility partner-manufacturer + * @privilege %http://tizen.org/privilege/inputmanager + * + * @return An error code + * @param[in] touchEvent The event type of the touch to be generated + * @param[in] point The point on which the touch occurs + * @exception E_SUCCESS The method was successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_OPERATION_FAILED An error occurred in the underlying system. + * @exception E_INVALID_ARG The specified @c touchEvent is not supported. + * @endif + */ + static result GenerateTouchEvent(TouchEventType touchEvent, const Tizen::Graphics::Point& point); + + /** + * @if VISPARTNER-MANUFACTURER + * Captures a screen + * + * @since 2.0 + * @visibility partner-manufacturer + * @privilege %http://tizen.org/privilege/inputmanager + * + * @return A pointer to the captured screen bitmap, @n + * else @c null if it fails to capture screen + * @exception E_SUCCESS The method was successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_OPERATION_FAILED An error occurred in the underlying system. + * @remarks There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer here. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * The returned bitmap should be deleted by the application after use. + * @endif + */ + static Tizen::Graphics::Bitmap* CaptureScreenN(void); + +private: + // + // This default constructor is intentionally declared as private because this class cannot be constructed. + // + SystemUtil(void); + + // + // This destructor is intentionally declared as private because this class cannot be constructed. + // + SystemUtil(const SystemUtil& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + SystemUtil& operator =(const SystemUtil& rhs); + + // + // This is a destructor for this class. + // This destructor is intentionally declared as private because this class cannot be constructed. + // + ~SystemUtil(void); + +}; //SystemUtil + +}} //Tizen::Ui +#endif + diff --git a/inc/FUiTouch.h b/inc/FUiTouch.h new file mode 100644 index 0000000..2f00f60 --- /dev/null +++ b/inc/FUiTouch.h @@ -0,0 +1,387 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiTouch.h + * @brief This is the header file for the %Touch class. + * + * This header file contains the declarations of the %Touch class.get + * + */ + +#ifndef _FUI_TOUCH_H_ +#define _FUI_TOUCH_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ + +class Control; +/** + * @if OSPDEPREC + * @class Touch + * @brief [Deprecated] This class supports multi-point touch for %Touch devices. + * + * @deprecated This class is deprecated because the use of the %Touch is no longer recommended. Instead of using this class, use Tizen::Ui::TouchEventManager class. + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %Touch class supports multi-point touch, and provides information about touch events. + * + * The following example demonstrates how to use the %Touch class. + * @code +// Sample code for TouchSample.h +#include + +class TouchSample + : public Tizen::Ui::Controls::Form + , public Tizen::Ui::ITouchEventListener +{ +public: + bool Initialize(void); + virtual result OnInitializing(void); + void DisplayMultipointTouchInfo(const Tizen::Ui::Control &source); + + // ITouchEventListener + virtual void OnTouchDoublePressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchFocusIn(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchFocusOut(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchLongPressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchMoved(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchPressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchReleased(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); +}; + * @endcode + * + * @code +// Sample code for TouchSample.cpp +#include +#include + +#include "TouchSample.h" + +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +bool +TouchSample::Initialize(void) +{ + Construct(FORM_STYLE_NORMAL); + return true; +} + +result +TouchSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of Touch + Touch touch; + touch.SetMultipointEnabled(*this, true); + AddTouchEventListener(*this); + + return r; +} + +void +TouchSample::DisplayMultipointTouchInfo(const Control &source) +{ + Touch touch; + IList *pList = touch.GetTouchInfoListN(source); + if (pList) + { + for(int i = 0; i < pList->GetCount(); i++ ) + { + TouchInfo *pTouchInfo = static_cast(pList->GetAt(i)); + AppLog("OnTouchMoved : [%d]%d,%d - %d", pTouchInfo->id, pTouchInfo->position.x, pTouchInfo->position.y, pTouchInfo->status); + } + pList->RemoveAll(true); + delete pList; + } +} + +// ITouchEventListeners implementation +void +TouchSample::OnTouchDoublePressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + AppLog("OnTouchDoublePressed is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y); + DisplayMultipointTouchInfo(source); +} + +void +TouchSample::OnTouchFocusIn(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + AppLog("OnTouchFocusIn is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y); + DisplayMultipointTouchInfo(source); +} + +void +TouchSample::OnTouchFocusOut(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + AppLog("OnTouchFocusOut is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y); + DisplayMultipointTouchInfo(source); +} + +void +TouchSample::OnTouchLongPressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + AppLog("OnTouchLongPressed is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y); + DisplayMultipointTouchInfo(source); +} + +void +TouchSample::OnTouchMoved(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + AppLog("OnTouchMoved is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y); + DisplayMultipointTouchInfo(source); +} + +void +TouchSample::OnTouchPressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + AppLog("OnTouchPressed is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y); + DisplayMultipointTouchInfo(source); +} + +void +TouchSample::OnTouchReleased(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + AppLog("OnTouchReleased is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y); + DisplayMultipointTouchInfo(source); +} + * @endcode + * @endif + */ +class _OSP_EXPORT_ Touch + : public Tizen::Base::Object +{ +public: + /** + * @if OSPDEPREC + * This is the default constructor for this class. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::TouchEventManager class. + * @since 2.0 + * @endif + */ + Touch(void); + + /** + * @if OSPDEPREC + * This destructor overrides Osp::Base::Object::~Object(). + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::TouchEventManager class. + * @since 2.0 + * @endif + */ + virtual ~Touch(void); + +public: + /** + * @if OSPDEPREC + * Enables or disables the multi-point touch of the Control. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::Control::SetMultipointTouchEnabled() method. + * @since 2.0 + * + * @return An error code + * @param[in] control The control + * @param[in] enable A Boolean flag indicating whether to enable to the multi-point touch + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see IsMultipointEnabled() + * @endif + */ + result SetMultipointEnabled(const Tizen::Ui::Control& control, bool enable); + + /** + * @if OSPDEPREC + * Checks whether the multi-point touch is enabled. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::Control::IsMultipointTouchEnabled() method. + * @since 2.0 + * + * @return @c true if the multi-point touch is enabled, @n + * else @c false + * @see IsMultipointEnabled() + * @endif + */ + bool IsMultipointEnabled(const Tizen::Ui::Control& control) const; + + + /** + * @if OSPDEPREC + * Gets the touch position. + * If there is only a single touch, that is returned. If there are multi-point touches, then the position of the last touch is returned. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. + * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method. + * @since 2.0 + * + * @return The coordinates of the touch + * @remarks If an error occurs, this method returns Point(-1, -1). + * @endif + */ + Tizen::Graphics::Point GetPosition(void) const; + + /** + * @if OSPDEPREC + * Gets the touch position by ID. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. + * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method. + * @since 2.0 + * + * @return The coordinates of the touch + * @param[in] id The ID of the touch + * @remarks If an error occurs, this method returns Point(-1, -1). + * @endif + */ + Tizen::Graphics::Point GetPosition(unsigned long id) const; + + /** + * @if OSPDEPREC + * Gets the touch position relative to the specified control. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. + * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method. + * @since 2.0 + * + * @return The coordinates of the touch + * @param[in] control The source control + * @remarks If an error occurs, this method returns Point(-1, -1). + * @endif + */ + Tizen::Graphics::Point GetPosition(const Tizen::Ui::Control& control) const; + + /** + * @if OSPDEPREC + * Gets the touch position relative to the specified control by ID. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. + * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method. + * @since 2.0 + * + * @return The coordinates of the touch + * @param[in] control The source control + * @param[in] id The ID of the touch + * @remarks If an error occurs, this method returns Point(-1, -1). + * @endif + */ + Tizen::Graphics::Point GetPosition(const Tizen::Ui::Control& control, unsigned long id) const; + + /** + * @if OSPDEPREC + * Gets the status of the touch by ID. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. + * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() and use the Tizen::Ui::TouchEventInfo::GetTouchStatus() method. + * @since 2.0 + * + * @param[in] id The ID of the touch + * @return The touch status + * @endif + */ + TouchStatus GetTouchStatus(unsigned long id) const; + + /** + * @if OSPDEPREC + * Gets the list of the multi-point touches, each represented by TouchInfo. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method. + * @since 2.0 + * + * @return List of the TouchInfo + * @see Tizen::Ui::TouchInfo + * @endif + */ + Tizen::Base::Collection::IList* GetTouchInfoListN(void) const; + + /** + * @if OSPDEPREC + * Gets the list of the multi-point touch positions relative to the specified control, each represented by TouchInfo. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method. + * @since 2.0 + * + * @return A list of the TouchInfo instances + * @param[in] control The source object for calculating the coordinates + * @see Tizen::Ui::TouchInfo + * @endif + */ + Tizen::Base::Collection::IList* GetTouchInfoListN(const Tizen::Ui::Control& control) const; + + /** + * @if OSPDEPREC + * Gets the count of the multi-point touches. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, get the count of Tizen::Ui::TouchEventManager::GetTouchInfoListN() method. + * @since 2.0 + * + * @return The number of the multi-point touches + * @endif + */ + int GetPointCount(void) const; + + /** + * @if OSPDEPREC + * Gets the point ID at the given index. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %Touch class is not supported any more. + * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() and use the Tizen::Ui::TouchEventInfo::GetPointId() method. + * @since 2.0 + * + * @return The touch point ID + * @param[in] index The index of the touch + * @endif + */ + unsigned long GetPointId(int index) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Touch(const Touch&); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Touch& operator =(const Touch&); +}; // Touch + +}} // Tizen::Ui + +#endif // _FUI_TOUCH_H_ diff --git a/inc/FUiTouchEventInfo.h b/inc/FUiTouchEventInfo.h new file mode 100644 index 0000000..3c5d0d9 --- /dev/null +++ b/inc/FUiTouchEventInfo.h @@ -0,0 +1,166 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiTouchEventInfo.h + * @brief This is the header file for the %TouchEventInfo class. + * + * This header file contains the declarations of the %TouchEventInfo class. + * + */ + +#ifndef _FUI_TOUCH_EVENT_INFO_H_ +#define _FUI_TOUCH_EVENT_INFO_H_ + +#include +#include + +namespace Tizen { namespace Base { namespace Runtime +{ +class IEventArg; +}}} + +namespace Tizen { namespace Ui +{ + +class _TouchEventInfoImpl; + +/** + * @enum TouchStatus + * + * Defines constants used to identify touch status. + * + * @since 2.0 + */ +enum TouchStatus +{ + TOUCH_PRESSED, /**< The touch pressed event type */ + TOUCH_LONG_PRESSED, /**< The touch long pressed event type */ + TOUCH_RELEASED, /**< The touch released event type */ + TOUCH_MOVED, /**< The touch moved event type */ + TOUCH_DOUBLE_PRESSED, /**< The touch double pressed event type */ + TOUCH_FOCUS_IN, /**< The touch focus-in event type */ + TOUCH_FOCUS_OUT, /**< The touch focus-out event type */ + TOUCH_CANCELED, /**< The touch canceled event type */ +}; + +/** + * @class TouchEventInfo + * @brief This class stores the information of each touch events. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %TouchEventInfo class provides the touch event information: touch position, status, ID, and so on. + * @see ITouchEventListener, ITouchEventListener::OnTouchPressed(), @if OSPDEREC ITouchEventListener::OnTouchLongPressed(), @endif ITouchEventListener::OnTouchReleased(), ITouchEventListener::OnTouchMoved(), @if OSPDEPREC ITouchEventListener::OnTouchDoublePressed(), @endif ITouchEventListener::OnTouchFocusIn(), ITouchEventListener::OnTouchFocusOut() + * + */ +class _OSP_EXPORT_ TouchEventInfo + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + TouchEventInfo(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TouchEventInfo(void); + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // + // Initializes this instance of %TouchEventInfo with the specified parameters. + // + // @since 2.0 + // @return An error code + // @param[in] eventArg The touch event argument + // + result Construct(const Tizen::Base::Runtime::IEventArg& eventArg); + + /** + * Gets the ID of the current touch event. + * + * @since 2.0 + * + * @return The ID of the current touch event + */ + unsigned long GetPointId(void) const; + + /** + * Gets the start position of the touch event. + * + * @since 2.0 + * + * @return The start position of the touch event + */ + Tizen::Graphics::Point GetStartPosition(void) const; + + /** + * Gets the current position of the touch event. + * + * @since 2.0 + * + * @return The current position of the touch event + */ + Tizen::Graphics::Point GetCurrentPosition(void) const; + + /** + * Gets the touch status. + * + * @since 2.0 + * + * @return The touch status + */ + TouchStatus GetTouchStatus(void) const; + + /** + * Checks whether the touch status is flick. + * + * @since 2.0 + * + * @return @c true if the touch status is flick, @n + * else @c false + */ + bool IsFlicked(void) const; + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + TouchEventInfo(const TouchEventInfo&); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + TouchEventInfo& operator =(const TouchEventInfo&); + +private: + _TouchEventInfoImpl* __pTouchEventInfoImpl; +}; // TouchEventInfo + +}} //Tizen::Ui + +#endif // _FUI_TOUCH_EVENT_INFO_H_ diff --git a/inc/FUiTouchEventManager.h b/inc/FUiTouchEventManager.h new file mode 100644 index 0000000..3fa286a --- /dev/null +++ b/inc/FUiTouchEventManager.h @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiTouchEventManager.h + * @brief This is the header file for the %TouchEventManager class. + * + * This header file contains the declarations of the %TouchEventManager class. + * + */ + +#ifndef _FUI_TOUCH_EVENT_MANAGER_H_ +#define _FUI_TOUCH_EVENT_MANAGER_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ + +class _TouchEventManagerImpl; +/** + * @class TouchEventManager + * @brief This class stores the information of each touch events. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %TouchEventManager class provides the touch event information: touch position, status, ID, and so on. + * @see TouchEventInfo + * + */ +class _OSP_EXPORT_ TouchEventManager + : public Tizen::Base::Object +{ +public: + /** + * Gets the instance of the %TouchEventManager. + * + * @since 2.0 + * @return A instance of the %TouchEventManager + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @remarks This method provides a global point of access to the TouchEventManager. And the specific error code can be accessed using the + * GetLastResult() method. + */ + static TouchEventManager* GetInstance(void); + + /** + * Gets the list of the multi-point touches, each represented by TouchEventInfo. + * + * @since 2.0 + * @return List of the TouchEventInfo + * @see Tizen::Ui::TouchEventInfo + * + */ + Tizen::Base::Collection::IListT* GetTouchInfoListN(void) const; + +private: + // + // This default constructor is intentionally declared as private to implement the Singleton semantic. + // + TouchEventManager(void); + + // + // This destructor is intentionally declared as private to implement the Singleton semantic. + // + virtual ~TouchEventManager(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + TouchEventManager(const TouchEventManager& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + TouchEventManager& operator =(const TouchEventManager& rhs); + +private: + _TouchEventManagerImpl* __pTouchEventManagerImpl; +}; // TouchEventManager + +}} //Tizen::Ui + +#endif // _FUI_TOUCH_EVENT_MANAGER_H_ diff --git a/inc/FUiTouchFlickGestureDetector.h b/inc/FUiTouchFlickGestureDetector.h new file mode 100644 index 0000000..e05256b --- /dev/null +++ b/inc/FUiTouchFlickGestureDetector.h @@ -0,0 +1,168 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiTouchFlickGestureDetector.h + * @brief This is the header file for the %TouchFlickGestureDetector class. + * + * This header file contains the declarations of the %TouchFlickGestureDetector class. + * + */ +#ifndef _FUI_TOUCH_FLICK_GESTURE_DETECTOR_H_ +#define _FUI_TOUCH_FLICK_GESTURE_DETECTOR_H_ + +#include + +namespace Tizen { namespace Ui +{ + +class ITouchFlickGestureEventListener; + +/** + * @enum FlickDirection + * + * Defines the direction of a flick gesture. + * + * @since 2.0 + */ +enum FlickDirection +{ + FLICK_DIRECTION_NONE = -1, /**< Undefined flick direction */ + FLICK_DIRECTION_RIGHT, /**< Rightward flick */ + FLICK_DIRECTION_UP, /**< Upward flick */ + FLICK_DIRECTION_LEFT, /**< Leftward flick */ + FLICK_DIRECTION_DOWN /**< Downward flick */ +}; + +/** + * @class TouchFlickGestureDetector + * @brief This class stores the information of a flick gesture detector. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %TouchFlickGestureDetector class supports flicking of touches, and provides information about flick gesture detector. + * + */ +class _OSP_EXPORT_ TouchFlickGestureDetector + : public Tizen::Ui::TouchGestureDetector +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + TouchFlickGestureDetector(void); + + /** + * This destructor overrides Osp::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TouchFlickGestureDetector(void); + +public: + /** + * Initializes this instance of %TouchFlickGestureDetector. + * + * @since 2.0 + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result Construct(void); + + /** + * Adds the ITouchFlickGestureEventListener instance to the flick gesture detector instance. @n + * The added listener gets notified when a gesture is recognized. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @see RemoveFlickGestureEventListener() + */ + result AddFlickGestureEventListener(Tizen::Ui::ITouchFlickGestureEventListener& listener); + + /** + * Removes the IFlickGestureEventListener instance from the flick gesture detector instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified @c listener is not found. + * @see AddFlickGestureEventListener() + */ + result RemoveFlickGestureEventListener(Tizen::Ui::ITouchFlickGestureEventListener& listener); + + /** + * Gets the distance of flick. + * + * @since 2.0 + * + * @return An error code + * @param[out] xDistance The distance in x direction + * @param[out] yDistance The distance in y direction + * @exception E_SUCCESS The method is successful. + * @remarks If an error occurs, this method returns the x distance of -1 and the y distance of -1. + */ + result GetDistance(int& xDistance, int& yDistance) const; + + /** + * Gets the duration of flick. + * + * @since 2.0 + * + * @return The duration of flick + * @exception E_SUCCESS The method is successful. + * @remarks If an error occurs, this method returns -1. + */ + int GetDuration(void) const; + + /** + * Gets the direction of flick. + * + * @since 2.0 + * + * @return The direction of flick + * @exception E_SUCCESS The method is successful. + * @remarks If an error occurs, this method returns FLICK_DIRECTION_NONE. + */ + Tizen::Ui::FlickDirection GetDirection(void) const; +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + TouchFlickGestureDetector(const TouchFlickGestureDetector& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + TouchFlickGestureDetector& operator =(const TouchFlickGestureDetector& rhs); + +private: + friend class _TouchFlickGestureDetectorImpl; +}; // TouchFlickGestureDetector + +}} // Tizen::Ui + +#endif //_FUI_TOUCH_FLICK_GESTURE_DETECTOR_H_ diff --git a/inc/FUiTouchGestureDetector.h b/inc/FUiTouchGestureDetector.h new file mode 100644 index 0000000..9033d49 --- /dev/null +++ b/inc/FUiTouchGestureDetector.h @@ -0,0 +1,292 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiTouchGestureDetector.h + * @brief This is the header file for the %TouchGestureDetector class. + * + * This header file contains the declarations of the %TouchGestureDetector class. + * + */ +#ifndef _FUI_TOUCH_GESTURE_DETECTOR_H_ +#define _FUI_TOUCH_GESTURE_DETECTOR_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +/** + * @enum TouchGestureDetectorState + * + * Defines the state of a gesture detector. + * + * @since 2.0 + */ +enum TouchGestureDetectorState +{ + GESTURE_DETECTOR_STATE_READY, /**< The gesture detector is ready to recognize the gesture */ + GESTURE_DETECTOR_STATE_STARTED, /**< The gesture detector first recognizes the continuous gesture */ + GESTURE_DETECTOR_STATE_CHANGED, /**< A subsequent change happens to the continuous gesture */ + GESTURE_DETECTOR_STATE_FINISHED, /**< The discrete gesture is recognized or the continuous gesture ends */ + GESTURE_DETECTOR_STATE_FAILED, /**< The gesture detector fails in recognizing the gesture */ +}; + +class Control; +class ITouchGestureEventListener; +class _TouchGestureDetectorImpl; + +/** + * @class TouchGestureDetector + * @brief This class stores the information of a gesture detector. + * + * @since 2.0 + * + * The %TouchGestureDetector class defines a common behavior for gesture detectors and provides information about gesture detector. + * + */ + class _OSP_EXPORT_ TouchGestureDetector + : public Tizen::Base::Object +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + TouchGestureDetector(void); + + /** + * This destructor overrides Osp::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TouchGestureDetector(void); + +public: + /** + * Initializes this instance of %TouchGestureDetector. + * + * @since 2.0 + * + * @exception E_SUCCESS The method is successful. + */ + result Construct(void); + + /** + * Gets the control which the gesture detector is attached to. + * If an error occurs, this method returns @c null. + * + * @since 2.0 + * + * @return The control which the gesture detector is attached to. + * @exception E_SUCCESS The method is successful. + */ + Control* GetControl(void) const; + + /** + * Enables or disables delaying touch event on Control. + * The %TouchGestureDetector receives touch events prior to a UI control to which it is added. + * Depending on a gesture that it tries to recognize, it is decided whether touch events need to be delivered to the UI control. + * If touch events must not be delivered to the UI control while gesture recognition is in progress, call this method with @c false argument. + * When the recognition finishes as success, delivering delayed touch events is dependent on IsCancelTouchEventOnSuccessEnabled(). + * When the recognition finishes as fail, all delayed touch events are fired sequentially. + * The default value is @c false. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Whether to delay events + * @exception E_SUCCESS The method is successful. + * @see IsDelayTouchEventEnabled() + * @see SetCancelTouchEventOnSuccessEnabled() + */ + result SetDelayTouchEventEnabled(bool enable); + + /** + * Checks whether delaying touch event to Control is enabled. + * + * @since 2.0 + * + * @return @c true if delaying touch event is enabled, @n + * else @c false if delaying touch event is disabled + * @exception E_SUCCESS The method is successful. + * @see SetDelayTouchEventEnabled() + */ + bool IsDelayTouchEventEnabled(void) const; + + /** + * Enables or disables canceling touch event after a gesture is recognized. + * If canceling touch event is enabled and a gesture is recognized, touch events which have been queued are not delivered to a UI control and discarded. + * The default value is @c false. + * + * @since 2.0 + * + * @return An error code + * @param[in] enable Whether to cancel touch event + * @exception E_SUCCESS The method is successful. + * @see IsCancelTouchEventOnSuccessEnabled() + * @see SetDelayTouchEventEnabled() + */ + result SetCancelTouchEventOnSuccessEnabled(bool enable); + + /** + * Checks whether touch events are canceled after a gesture is recognized. + * + * @since 2.0 + * + * @return @c true if canceling touch event is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @see SetCancelTouchEventOnSuccessEnabled() + */ + bool IsCancelTouchEventOnSuccessEnabled(void) const; + + /** + * Sets priority between gesture detectors. + * + * @since 2.0 + * + * @return An error code + * @param[in] gestureDetector The gesture detector + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The @c gestureDetector is invalid. + * @remarks If you want to set relationship between gesture detectors, call this method. + * If @c gestureDetector fails in recognizing a gesture, the gesture detector which waits for it starts the processing of recognizing. + * If @c gestureDetector succeeds in recognizing a gesture, + * the state of the gesture detector which waits for it changes to GESTURE_DETECTOR_STATE_FAIL. + */ + result StartOnFailureOf(const TouchGestureDetector& gestureDetector); + + /** + * Called when touch is pressed in the Control which the gesture detector is attached to. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] touchInfo The touch event information + */ + virtual void OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchInfo); + + /** + * Called when touch is moved in the Control which the gesture detector is attached to. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] touchInfo The touch event information + */ + virtual void OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchInfo); + + /** + * Called when touch is released in the Control which the gesture detector is attached to. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] touchInfo The touch event information + */ + virtual void OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchInfo); + + /** + * Called when touch is canceled in the Control which the gesture detector is attached to. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] touchInfo The touch event information + */ + virtual void OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchInfo); + +protected: + /** + * Sets the current state of gesture detector. + * You can call this method only inherit %TouchGestureDetector directly. + * + * @since 2.0 + * + * @return An error code + * @param[in] state Gesture detector state + * @exception E_SUCCESS The method is successful. + * @see GetDetectorState() + */ + result SetDetectorState(Tizen::Ui::TouchGestureDetectorState state); + + /** + * Gets the current state of gesture detector. + * If an error occurs, this method returns @c GESTURE_DETECTOR_STATE_READY. + * + * @since 2.0 + * + * @return The current state of gesture detector + * @exception E_SUCCESS The method is successful. + * @see SetDetectorState() + */ + Tizen::Ui::TouchGestureDetectorState GetDetectorState(void) const; + + /** + * Adds the IGestureEventListener instance to the gesture detector instance. @n + * The added listener gets notified when a gesture is recognized. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @see RemoveGestureEventListener() + */ + result AddGestureEventListener(Tizen::Ui::ITouchGestureEventListener& listener); + + /** + * Removes the gesture listener instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The @c listener is not found. + * @see AddGestureEventListener() + */ + result RemoveGestureEventListener(Tizen::Ui::ITouchGestureEventListener& listener); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + TouchGestureDetector(const TouchGestureDetector& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + TouchGestureDetector& operator =(const TouchGestureDetector& rhs); + +protected: + friend class _TouchGestureDetectorImpl; + + // + // This variable is for internal use only. Using this variable can cause behavioral, + // security-related, and consistency-related issues in the application. + // + _TouchGestureDetectorImpl* __pTouchGestureDetectorImpl; +}; // TouchGestureDetector + +}} // Tizen::Ui + +#endif //_FUI_TOUCH_GESTURE_DETECTOR_H_ \ No newline at end of file diff --git a/inc/FUiTouchInfo.h b/inc/FUiTouchInfo.h new file mode 100644 index 0000000..03bc75b --- /dev/null +++ b/inc/FUiTouchInfo.h @@ -0,0 +1,109 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiTouchInfo.h + * @brief This is the header file for the %TouchInfo class. + * + * This header file contains the declarations of the %TouchInfo class. + * + */ + +#ifndef _FUI_TOUCH_INFO_H_ +#define _FUI_TOUCH_INFO_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +class Control; + +/** + * @if OSPDEPREC + * @class TouchInfo + * @brief [Deprecated] This class stores the information of a touch event. + * + * @deprecated This class is deprecated because the use of the %TouchInfo is no longer recommended. Instead of using this class, use Tizen::Ui::TouchEventInfo class. + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %TouchInfo class provides touch-related information to support multi-point touch. + * @endif + */ +class _OSP_EXPORT_ TouchInfo + : public Tizen::Base::Object +{ +public: + /** + * @if OSPDEPREC + * This is the default constructor for this class. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %TouchInfo class is not supported any more. Instead, use the Tizen::Ui::TouchEventInfo class. + * @since 2.0 + * @endif + */ + TouchInfo(void) + : id(0) + , position(0, 0) + , status(TOUCH_PRESSED) + { + } + + /** + * @if OSPDEPREC + * The ID of the Touch instance. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %TouchInfo class is not supported any more. Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() + * and use the Tizen::Ui::TouchEventInfo::GetPointId() method. + * @since 2.0 + * @endif + */ + unsigned long id; + + /** + * @if OSPDEPREC + * The position of the Touch instance. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %TouchInfo class is not supported any more. Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() + * and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method. + * @since 2.0 + * @endif + */ + Tizen::Graphics::Point position; + + /** + * @if OSPDEPREC + * The status of the Touch instance, using only the @c TOUCH_PRESSED and @c TOUCH_RELEASED states. + * + * @brief [Deprecated] + * @deprecated This method is deprecated because the %TouchInfo class is not supported any more. Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() + * and use the Tizen::Ui::TouchEventInfo::GetTouchStatus() method. + * @since 2.0 + * @endif + */ + TouchStatus status; +}; // TouchInfo + +}} // Tizen::Ui + +#endif // _FUI_TOUCH_INFO_H_ diff --git a/inc/FUiTouchLongPressGestureDetector.h b/inc/FUiTouchLongPressGestureDetector.h new file mode 100644 index 0000000..9074119 --- /dev/null +++ b/inc/FUiTouchLongPressGestureDetector.h @@ -0,0 +1,201 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiTouchLongPressGestureDetector.h + * @brief This is the header file for the %TouchLongPressGestureDetector class. + * + * This header file contains the declarations of the %TouchLongPressGestureDetector class. + * + */ + +#ifndef _FUI_TOUCH_LONG_PRESS_GESTURE_DETECTOR_H_ +#define _FUI_TOUCH_LONG_PRESS_GESTURE_DETECTOR_H_ + +#include + +namespace Tizen { namespace Ui +{ + +class ITouchLongPressGestureEventListener; + +/** + * @class TouchLongPressGestureDetector + * @brief This class stores the information of a long press gesture detector. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %TouchLongPressGestureDetector class supports changing conditions of long press gesture, and provides information about long press gesture detector. + * + */ +class _OSP_EXPORT_ TouchLongPressGestureDetector + : public Tizen::Ui::TouchGestureDetector +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + TouchLongPressGestureDetector(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TouchLongPressGestureDetector(void); + + /** + * Initializes this instance of %TouchLongPressGestureDetector. + * + * @since 2.0 + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result Construct(void); + + /** + * Adds the ITouchLongPressGestureEventListener instance to the long press gesture detector instance. @n + * The added listener gets notified when a gesture is recognized. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @see RemoveLongPressGestureEventListener() + */ + result AddLongPressGestureEventListener(Tizen::Ui::ITouchLongPressGestureEventListener& listener); + + /** + * Removes the ITouchLongPressGestureEventListener instance from the long press gesture detector instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified @c listener is not found. + * @see AddLongPressGestureEventListener() + */ + result RemoveLongPressGestureEventListener(Tizen::Ui::ITouchLongPressGestureEventListener& listener); + + /** + * Sets the duration needed for the recognition of long press gesture. + * + * @since 2.0 + * + * @param[in] duration The time duration + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c duration is less than @c 0. + * @remarks The default value is @c 500 milliseconds. + * @see GetDuration() + * + */ + result SetDuration(int duration); + + /** + * Gets the duration needed for the recognition of long press gesture. + * + * @since 2.0 + * + * @return The time duration + * @exception E_SUCCESS The method is successful. + * @remarks If an error occurs, this method returns -1. + * @see SetDuration() + */ + int GetDuration(void) const; + + /** + * Sets the allowed displacement of touch move for the recognition of long press gesture. + * + * @since 2.0 + * + * @param[in] allowance The allowed move displacement + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c allowance is less than @c 0. + * @remarks The long press gesture is recognized when touch is pressed and moved within the given allowed displacement from the first touch point for the given duration. + * The default allowance is @c 10. + * @see GetMoveAllowance() + * + */ + result SetMoveAllowance(int allowance); + + /** + * Gets the allowed move bounds. + * + * @since 2.0 + * + * @return The allowed move bounds + * @exception E_SUCCESS The method is successful. + * @remarks If an error occurs, this method returns -1. + * @see SetMoveAllowance() + * + */ + int GetMoveAllowance(void) const; + + /** + * Sets the finger count for the recognition of long press gesture at the same time. + * + * @since 2.0 + * + * @param[in] count The finger count for long press gesture + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c count is less than @c 0. + * @remarks The default value is @c 1. + * It is recommended to check the maximum touch count of a device before changing the touch count of a gesture detector. + * You can set the gesture touch count to more than the maximum device touch count, but the gesture recognition may not work as you expected. + * @see GetTouchCount() + * + */ + result SetTouchCount(int count); + + /** + * Gets the finger count for the recognition of long press gesture at the same time. + * + * @since 2.0 + * + * @return The finger count for long press gesture + * @exception E_SUCCESS The method is successful. + * @remarks If an error occurs, this method returns -1. + * @see GetTouchCount() + * + */ + int GetTouchCount(void) const; + +private: + // + // This is the copy constructor for this class. + // + TouchLongPressGestureDetector(const TouchLongPressGestureDetector& rhs); + + // + // Assigns the value of the specified instance to the current instance of %TouchLongPressGestureDetector. + // + TouchLongPressGestureDetector& operator =(const TouchLongPressGestureDetector& rhs); + +protected: + friend class _TouchLongPressGestureDetectorImpl; +}; // TouchLongPressGestureDetector + +}} // Tizen::Ui + +#endif //_FUI_TOUCH_LONG_PRESS_GESTURE_DETECTOR_H_ diff --git a/inc/FUiTouchPanningGestureDetector.h b/inc/FUiTouchPanningGestureDetector.h new file mode 100644 index 0000000..92abf7f --- /dev/null +++ b/inc/FUiTouchPanningGestureDetector.h @@ -0,0 +1,159 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiTouchPanningGestureDetector.h + * @brief This is the header file for the %TouchPanningGestureDetector class. + * + * This header file contains the declarations of the %TouchPanningGestureDetector class. + * + */ + +#ifndef _FUI_TOUCH_PANNING_GESTURE_DETECTOR_H_ +#define _FUI_TOUCH_PANNING_GESTURE_DETECTOR_H_ + +#include + +namespace Tizen { namespace Ui +{ + +class ITouchPanningGestureEventListener; + +/** + * @class TouchPanningGestureDetector + * @brief This class stores the information of a panning gesture detector. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %TouchPanningGestureDetector class supports changing condition of panning gesture, and provides information about panning gesture detector. + * + */ +class _OSP_EXPORT_ TouchPanningGestureDetector + : public Tizen::Ui::TouchGestureDetector +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + TouchPanningGestureDetector(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TouchPanningGestureDetector(void); + + /** + * Initializes this instance of %TouchPanningGestureDetector. + * + * @since 2.0 + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result Construct(void); + + /** + * Adds the ITouchPanningGestureEventListener instance to the panning gesture detector instance. @n + * The added listener gets notified when a gesture is recognized. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @see RemoveRotationGestureEventListener() + */ + result AddPanningGestureEventListener(Tizen::Ui::ITouchPanningGestureEventListener& listener); + + /** + * Removes the ITouchPanningGestureEventListener instance from the panning gesture detector instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified @c listener is not found. + * @see AddRotationGestureEventListener() + */ + result RemovePanningGestureEventListener(Tizen::Ui::ITouchPanningGestureEventListener& listener); + + /** + * Gets the list of the touched points represented by TouchInfo. + * + * @since 2.0 + * + * @return A list of the TouchInfo + * @exception E_SUCCESS The method is successful. + * @remarks If an error occurs, this method returns @c null. + * @see Tizen::Ui::TouchInfo + */ + Tizen::Base::Collection::IList* GetTouchInfoListN(void) const; + + /** + * Sets the finger count for the recognition of panning gesture at the same time. + * + * @since 2.0 + * + * @param[in] count The finger count for panning gesture + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c count is less than @c 0. + * @remarks The default value is @c 1. + * It is recommended to check the maximum touch count of a device before changing the touch count of a gesture detector. + * You can set the gesture touch count to more than the maximum device touch count, but the gesture recognition may not work as you expected. + * @see GetTouchCount() + * + */ + result SetTouchCount(int count); + + /** + * Gets the finger count for the recognition of panning gesture at the same time. + * + * @since 2.0 + * + * @return The finger count for panning gesture + * @exception E_SUCCESS The method is successful. + * @remarks If an error occurs, this method returns -1. + * @see SetTouchCount() + * + */ + int GetTouchCount(void) const; + +private: + // + // This is the copy constructor for this class. + // + TouchPanningGestureDetector(const TouchPanningGestureDetector& rhs); + + // + // Assigns the value of the specified instance to the current instance of %TouchPanningGestureDetector. + // + TouchPanningGestureDetector& operator =(const TouchPanningGestureDetector& rhs); + +protected: + friend class _TouchPanningGestureDetectorImpl; +}; // TouchPanningGestureDetector + +}} // Tizen::Ui + +#endif //_FUI_TOUCH_PANNING_GESTURE_DETECTOR_H_ diff --git a/inc/FUiTouchPinchGestureDetector.h b/inc/FUiTouchPinchGestureDetector.h new file mode 100644 index 0000000..b59d09b --- /dev/null +++ b/inc/FUiTouchPinchGestureDetector.h @@ -0,0 +1,140 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiTouchPinchGestureDetector.h + * @brief This is the header file for the %TouchPinchGestureDetector class. + * + * This header file contains the declarations of the %TouchPinchGestureDetector class. + * + */ + +#ifndef _FUI_TOUCH_PINCH_GESTURE_DETECTOR_H_ +#define _FUI_TOUCH_PINCH_GESTURE_DETECTOR_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +class ITouchPinchGestureEventListener; + +/** + * @class TouchPinchGestureDetector + * @brief This class stores the information of a pinch gesture detector. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %TouchPinchGestureDetector class provides information about pinch gesture detector. + * + */ +class _OSP_EXPORT_ TouchPinchGestureDetector + : public Tizen::Ui::TouchGestureDetector +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + TouchPinchGestureDetector(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TouchPinchGestureDetector(void); + + /** + * Initializes this instance of %TouchPinchGestureDetector. + * + * @since 2.0 + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result Construct(void); + + /** + * Adds the ITouchPinchGestureEventListener instance to the pinch gesture detector instance. @n + * The added listener gets notified when a gesture is recognized. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @see RemoveRotationGestureEventListener() + */ + result AddPinchGestureEventListener(Tizen::Ui::ITouchPinchGestureEventListener& listener); + + /** + * Removes the ITouchPinchGestureEventListener instance from the pinch gesture detector instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified @c listener is not found. + * @see AddRotationGestureEventListener() + */ + result RemovePinchGestureEventListener(Tizen::Ui::ITouchPinchGestureEventListener& listener); + + /** + * Gets the center position of two touch points. + * + * @since 2.0 + * + * @return The center point + * @exception E_SUCCESS The method is successful. + * @remarks If an error occurs, this method returns Point(-1, -1). + */ + Tizen::Graphics::Point GetCenterPoint(void) const; + + /** + * Gets the scale factor among touched point + * + * @since 2.0 + * + * @return The scale factor among touched points + * @remarks Get scale factor for a pinch gesture in progress + */ + int GetScale(void) const; + +private: + // + // This is the copy constructor for this class. + // + TouchPinchGestureDetector(const TouchPinchGestureDetector& rhs); + + // + // Assigns the value of the specified instance to the current instance of %TouchPinchGestureDetector. + // + TouchPinchGestureDetector& operator =(const TouchPinchGestureDetector& rhs); + +protected: + friend class _TouchPinchGestureDetectorImpl; +}; // TouchPinchGestureDetector + +}} // Tizen::Ui + +#endif //_FUI_TOUCH_PINCH_GESTURE_DETECTOR_H_ diff --git a/inc/FUiTouchRotationGestureDetector.h b/inc/FUiTouchRotationGestureDetector.h new file mode 100644 index 0000000..6ef0bc5 --- /dev/null +++ b/inc/FUiTouchRotationGestureDetector.h @@ -0,0 +1,140 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiTouchRotationGestureDetector.h + * @brief This is the header file for the %TouchRotationGestureDetector class. + * + * This header file contains the declarations of the %TouchRotationGestureDetector class. + * + */ + +#ifndef _FUI_TOUCH_ROTATION_GESTURE_DETECTOR_H_ +#define _FUI_TOUCH_ROTATION_GESTURE_DETECTOR_H_ + +#include + +namespace Tizen { namespace Ui +{ + +class ITouchRotationGestureEventListener; + +/** + * @class TouchRotationGestureDetector + * @brief This class stores the information of a rotation gesture detector. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %TouchRotationGestureDetector class provides information about rotation gesture detector. + * + */ +class _OSP_EXPORT_ TouchRotationGestureDetector + : public Tizen::Ui::TouchGestureDetector +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + TouchRotationGestureDetector(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TouchRotationGestureDetector(void); + + /** + * Initializes this instance of %TouchRotationGestureDetector. + * + * @since 2.0 + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result Construct(void); + + /** + * Adds the ITouchRotationGestureEventListener instance to the rotation gesture detector instance. @n + * The added listener gets notified when a gesture is recognized. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @see RemoveRotationGestureEventListener() + */ + result AddRotationGestureEventListener(Tizen::Ui::ITouchRotationGestureEventListener& listener); + + /** + * Removes the ITouchRotationGestureEventListener instance from the rotation gesture detector instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified @c listener is not found. + * @see AddRotationGestureEventListener() + */ + result RemoveRotationGestureEventListener(Tizen::Ui::ITouchRotationGestureEventListener& listener); + + /** + * Gets the angle between the previous touch points and the current touch points. + * + * @since 2.0 + * + * @return The angle between two touch points + * @exception E_SUCCESS The method is successful. + * @remarks If an error occurs, this method returns -1. + */ + float GetAngle(void) const; + + /** + * Gets the distance between two touch points. + * + * @since 2.0 + * + * @return The distance between two touch points + * @exception E_SUCCESS The method is successful. + * @remarks If an error occurs, this method returns -1. + */ + int GetDistance(void) const; + +private: + // + // This is the copy constructor for this class. + // + TouchRotationGestureDetector(const TouchRotationGestureDetector& rhs); + + // + // Assigns the value of the specified instance to the current instance of %TouchRotationGestureDetector. + // + TouchRotationGestureDetector& operator =(const TouchRotationGestureDetector& rhs); + +protected: + friend class _TouchRotationGestureDetectorImpl; +}; // TouchRotationGestureDetector + +}} // Tizen::Ui + +#endif //_FUI_TOUCH_ROTATION_GESTURE_DETECTOR_H_ diff --git a/inc/FUiTouchTapGestureDetector.h b/inc/FUiTouchTapGestureDetector.h new file mode 100644 index 0000000..8eb92f2 --- /dev/null +++ b/inc/FUiTouchTapGestureDetector.h @@ -0,0 +1,229 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiTouchTapGestureDetector.h + * @brief This is the header file for the %TouchTapGestureDetector class. + * + * This header file contains the declarations of the %TouchTapGestureDetector class. + * + */ + +#ifndef _FUI_TOUCH_TAP_GESTURE_DETECTOR_H_ +#define _FUI_TOUCH_TAP_GESTURE_DETECTOR_H_ + +#include + +namespace Tizen { namespace Ui +{ + +class ITouchTapGestureEventListener; + +/** + * @class TouchTapGestureDetector + * @brief This class stores the information of a tap gesture detector. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %TouchTapGestureDetector class supports changing conditions of tap gesture, and provides information about tap gesture detector. + * + */ +class _OSP_EXPORT_ TouchTapGestureDetector + : public Tizen::Ui::TouchGestureDetector +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + TouchTapGestureDetector(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~TouchTapGestureDetector(void); + + /** + * Initializes this instance of %TouchTapGestureDetector. + * + * @since 2.0 + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result Construct(void); + + /** + * Adds the ITouchTapGestureEventListener instance to the tap gesture detector instance. @n + * The added listener gets notified when a gesture is recognized. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The event listener to add + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @see RemoveTapGestureEventListener() + */ + result AddTapGestureEventListener(Tizen::Ui::ITouchTapGestureEventListener& listener); + + /** + * Removes the ITouchTapGestureEventListener instance from the tap gesture detector instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener The listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified @c listener is not found. + * @see AddTapGestureEventListener() + */ + result RemoveTapGestureEventListener(Tizen::Ui::ITouchTapGestureEventListener& listener); + + /** + * Sets the tap count required for the recognition of tap gesture. + * + * @since 2.0 + * + * @param[in] count The tap count + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c tap count is less than @c 0. + * @remarks The default value is @c 2. + * @see GetTapCount() + * + */ + result SetTapCount(int count); + + /** + * Gets the tap count required for the recognition of tap gesture. + * + * @since 2.0 + * + * @return The tap count + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an error occurs, this method returns @c -1. + * @see SetTapCount() + */ + int GetTapCount(void) const; + + /** + * Sets the time interval between taps. + * + * @since 2.0 + * + * @param[in] interval The time interval between taps + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c interval is less than @c 0. + * @remarks If the interval between touches is longer than @c interval, the sequence of touch actions is not recognized as a tap gesture. The default value is @c 330. + * @see GetTapInterval() + * + */ + result SetTapInterval(int interval); + + /** + * Gets the time interval between taps. + * + * @since 2.0 + * + * @return The time interval between taps + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an error occurs, this method returns @c -1. + * @see SetTapInterval() + */ + int GetTapInterval(void) const; + + /** + * Sets the finger count for the recognition of tap gesture at the same time. + * + * @since 2.0 + * + * @param[in] count The finger count for long press gesture + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c count is less than @c 0. + * @remarks If the touch count at the same time is less than @c count, the sequence of touch actions is not recognized as a tap gesture. The default value is @c 1. @n + * It is recommended to check the maximum touch count of a device before changing the touch count of a gesture detector. + * You can set the gesture touch count to more than the maximum device touch count, but the gesture recognition may not work as you expected. + * @see GetTouchCount() + * + */ + result SetTouchCount(int count); + + /** + * Gets the finger count for the recognition of tap gesture at the same time. + * + * @since 2.0 + * + * @return The finger count for tap gesture + * @exception E_SUCCESS The method is successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks If an error occurs, this method returns @c -1. + * @see GetTouchCount() + * + */ + int GetTouchCount(void) const; + + /** + * Sets the allowed displacement between touches for the recognition of tap gesture. + * + * @since 2.0 + * + * @param[in] allowance The allowed displacement between touches + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c allowance is less than @c 0. + * @exception E_INVALID_CONDITION %Touch count is more than @c 2. + * @remarks The tap gesture is recognized when touches are pressed within the given allowed displacement from the first touch point. The default allowance is @c 10. @n + * MoveAllowance is effective only when touch count is @c 1. If touch count is more than 1, MoveAllowance is ignored. + * @see GetMoveAllowance() + * + */ + result SetMoveAllowance(int allowance); + + /** + * Gets ths allowed displacement between touches for the recognition of tap gesture. + * + * @since 2.0 + * + * @return The allowed displacement between touches + * @exception E_SUCCESS The method is successful. + * @remarks If an error occurs, this method returns @c -1. + * @see SetMoveAllowance() + */ + int GetMoveAllowance(void) const; +private: + // + // This is the copy constructor for this class. + // + TouchTapGestureDetector(const TouchTapGestureDetector& rhs); + + // + // Assigns the value of the specified instance to the current instance of %TouchTapGestureDetector. + // + TouchTapGestureDetector& operator =(const TouchTapGestureDetector& rhs); + +protected: + friend class _TouchTapGestureDetectorImpl; +}; // TouchTapGestureDetector + +}} // Tizen::Ui + +#endif //_FUI_TOUCH_TAP_GESTURE_DETECTOR_H_ diff --git a/inc/FUiUiConfiguration.h b/inc/FUiUiConfiguration.h new file mode 100644 index 0000000..4ca8538 --- /dev/null +++ b/inc/FUiUiConfiguration.h @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiUiConfiguration.h + * @brief This is the header file for the %UiConfiguration class. + * + * This header file contains the declarations of the %UiConfiguration class. + */ + +#ifndef _FUI_UI_CONFIGURATION_H_ +#define _FUI_UI_CONFIGURATION_H_ + +namespace Tizen { namespace Base { +class String; +}} // Tizen::Base + +namespace Tizen { namespace Ui { + +class _OSP_EXPORT_ UiConfiguration +{ +public: + /** + * Sets the default font to all the Controls. + * + * @since 2.0 + * + * @return An error code + * @param[in] fontName The app font name or system font name @n + * The app font name is retrieved using Tizen::Graphics::GetFaceName(Tizen::Base::String& filepath). + * The system font name is retrieved using Tizen::Graphics::Font::GetSystemFontListN(). + * Sets an empty string if you want to reset + * @exception E_SUCCESS The method is successful. + * @exception E_FILE_NOT_FOUND The specified font cannot be found or accessed. + * @remarks At First, the value of fontName is considered app font name if it matches one of the face names of the font files which is located in '/res/font'. + * If not, the value of fontName is considered system font name if it matches one of the retrieved values using GetSystemFontListN(). + * @remarks The control first attempt to find the control font. If it fails, then it searches for the application default font and the system font, in sequence. + * @see GetDefaultFont() + */ + static result SetDefaultFont(const Tizen::Base::String& fontName); + + /** + * Gets the default font for all the Controls. + * + * @since 2.0 + * + * @return The app font name or system font name @n + * else an empty string if the default font is not set + * @see SetDefaultFont() + */ + static Tizen::Base::String GetDefaultFont(void); + + +private: + // + // This default constructor is intentionally declared as private because this class cannot be constructed. + // + UiConfiguration(void); + + // + // This destructor is intentionally declared as private because this class cannot be constructed. + // + ~UiConfiguration(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + UiConfiguration(const UiConfiguration& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + UiConfiguration& operator =(const UiConfiguration& rhs); + +}; // UiConfiguration + +}} // Tizen::Ui + +#endif // _FUI_UI_CONFIGURATION_H_ diff --git a/inc/FUiVariant.h b/inc/FUiVariant.h new file mode 100644 index 0000000..b73bcc8 --- /dev/null +++ b/inc/FUiVariant.h @@ -0,0 +1,894 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiVariant.h + * @brief This is the header file for the %Variant class. + * + * This header file contains the declarations of the %Variant class. + */ +#ifndef _FUI_VARIANT_H_ +#define _FUI_VARIANT_H_ + +#include +#include + +namespace Tizen { namespace Base +{ + class DateTime; +} } + +namespace Tizen { namespace Graphics +{ + class Rectangle; + class Dimension; + class Point; + class Color; + class FloatPoint; + class FloatRectangle; + class FloatDimension; + class FloatMatrix4; +} } + +namespace Tizen { namespace Ui +{ + +class _VariantImpl; + +/** + * @enum VariantType + * + * Defines the types which %Variant can hold. + * + * @since 2.0 + */ +enum VariantType +{ + VARIANT_TYPE_NONE = 0, /**< The type for invalid variant */ + VARIANT_TYPE_INT, /**< The @c int type */ + VARIANT_TYPE_UINT, /**< The unsigned @c int type */ + VARIANT_TYPE_BOOL, /**< The @c bool type */ + VARIANT_TYPE_FLOAT, /**< The @c float type */ + VARIANT_TYPE_DOUBLE, /**< The @c double type */ + VARIANT_TYPE_LONG, /**< The @c long type */ + VARIANT_TYPE_ULONG, /**< The unsigned @c long type */ + VARIANT_TYPE_LONGLONG, /**< The @c long @c long type */ + VARIANT_TYPE_ULONGLONG, /**< The unsigned @c long @c long type */ + VARIANT_TYPE_STRING, /**< The String type */ + VARIANT_TYPE_DATETIME, /**< The DateTime type */ + VARIANT_TYPE_COLOR, /**< The Color type */ + VARIANT_TYPE_POINT, /**< The Point type */ + VARIANT_TYPE_FLOAT_POINT, /**< The FloatPoint type */ + VARIANT_TYPE_RECTANGLE, /**< The Rectangle type */ + VARIANT_TYPE_FLOAT_RECTANGLE, /**< The FloatRectangle type */ + VARIANT_TYPE_DIMENSION, /**< The Dimension type */ + VARIANT_TYPE_FLOAT_DIMENSION, /**< The FloatDimension type */ + VARIANT_TYPE_FLOAT_MATRIX4 /**< The FloatMatrix4 type */ +}; + +/** + * @class Variant + * @brief This class abstracts a %Variant value. + * + * @since 2.0 + * + * The %Variant class represents a %Variant type which can hold any of the basic type values. + * + */ +class _OSP_EXPORT_ Variant + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + Variant(void); + + /** + * This is the copy constructor for the %Variant class. + * + * @since 2.0 + * + * @param[in] value A reference to the %Variant instance to copy + */ + Variant(const Variant& value); + + /** + * Initializes this instance of %Variant with the specified @c int value. + * + * @since 2.0 + * + * @param[in] value An @c int value + */ + Variant(int value); + + /** + * Initializes this instance of %Variant with the specified unsigned @c int value. + * + * @since 2.0 + * + * @param[in] value An unsigned @c int value + */ + Variant(unsigned int value); + + /** + * Initializes this instance of %Variant with the specified bool value. + * + * @since 2.0 + * + * @param[in] value A bool value + */ + Variant(bool value); + + /** + * Initializes this instance of %Variant with the specified @c float value. + * + * @since 2.0 + * + * @param[in] value A @c float value + */ + Variant(float value); + + /** + * Initializes this instance of %Variant with the specified @c double value. + * + * @since 2.0 + * + * @param[in] value A @c double value + */ + Variant(double value); + + /** + * Initializes this instance of %Variant with the specified @c long value. + * + * @since 2.0 + * + * @param[in] value A @c long value + */ + Variant(long value); + + /** + * Initializes this instance of %Variant with the specified unsigned @c long value. + * + * @since 2.0 + * + * @param[in] value An unsigned @c long value + */ + Variant(unsigned long value); + + /** + * Initializes this instance of %Variant with the specified @c long @c long value. + * + * @since 2.0 + * + * @param[in] value A @c long @c long value + */ + Variant(long long value); + + /** + * Initializes this instance of %Variant with the specified unsigned @c long @c long value. + * + * @since 2.0 + * + * @param[in] value An unsigned @c long @c long value + */ + Variant(unsigned long long value); + + /** + * Initializes this instance of %Variant with the specified array of characters. + * + * @since 2.0 + * + * @param[in] pValue An array of characters value + */ + Variant(const char* pValue); + + /** + * Initializes this instance of %Variant with the specified array of Unicode characters. + * + * @since 2.0 + * + * @param[in] pValue An array of Unicode characters value + */ + Variant(const wchar_t* pValue); + + /** + * Initializes this instance of %Variant with the specified unsigned string value. + * + * @since 2.0 + * + * @param[in] value An unsigned string value + */ + Variant(const Tizen::Base::String& value); + + /** + * Initializes this instance of %Variant with the specified unsigned datetime value. + * + * @since 2.0 + * + * @param[in] value An unsigned datetime value + */ + Variant(const Tizen::Base::DateTime& value); + + /** + * Initializes this instance of %Variant with the specified unsigned color value. + * + * @since 2.0 + * + * @param[in] value An unsigned color value + */ + Variant(const Tizen::Graphics::Color& value); + + /** + * Initializes this instance of %Variant with the specified unsigned point value. + * + * @since 2.0 + * + * @param[in] value An unsigned point value + */ + Variant(const Tizen::Graphics::Point& value); + + /** + * Initializes this instance of %Variant with the specified floatpoint value. + * + * @since 2.0 + * + * @param[in] value A floatpoint value + */ + Variant(const Tizen::Graphics::FloatPoint& value); + + /** + * Initializes this instance of %Variant with the specified rectangle value. + * + * @since 2.0 + * + * @param[in] value A rectangle value + */ + Variant(const Tizen::Graphics::Rectangle& value); + + /** + * Initializes this instance of %Variant with the specified float-rectangle value. + * + * @since 2.0 + * + * @param[in] value A float-rectangle value + */ + Variant(const Tizen::Graphics::FloatRectangle& value); + + /** + * Initializes this instance of %Variant with the specified dimension value. + * + * @since 2.0 + * + * @param[in] value A dimension value + */ + Variant(const Tizen::Graphics::Dimension& value); + + /** + * Initializes this instance of %Variant with the specified float-dimension value. + * + * @since 2.0 + * + * @param[in] value A float-dimension value + */ + Variant(const Tizen::Graphics::FloatDimension& value); + + /** + * Initializes this instance of %Variant with the specified float-matrix4 value. + * + * @since 2.0 + * + * @param[in] value A float-matrix4 value + */ + Variant(const Tizen::Graphics::FloatMatrix4& value); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Variant(void); + + /** + * Assigns the value of the specified instance to the current instance of %Variant. + * + * @since 2.0 + * + * @return A reference to the %Variant instance + * @param[in] rhs An instance of %Variant to copy + */ + Variant& operator =(const Variant& rhs); + + /** + * Assigns the value of the specified instance to the current instance of %Variant. + * + * @since 2.0 + * + * @return A reference to the %Variant instance + * @param[in] rhs An @c int value + */ + Variant& operator =(int rhs); + + /** + * Assigns the value of the specified instance to the current instance of %Variant. + * + * @since 2.0 + * + * @return A reference to the %Variant instance + * @param[in] rhs An unsigned @c int value + * + */ + Variant& operator =(unsigned int rhs); + + /** + * Assigns the value of the specified instance to the current instance of %Variant. + * + * @since 2.0 + * @return A reference to the %Variant instance + * @param[in] rhs A @c bool value + * + */ + Variant& operator =(bool rhs); + + /** + * Assigns the value of the specified instance to the current instance of %Variant. + * + * @since 2.0 + * + * @return A reference to the %Variant instance + * @param[in] rhs A @c float value + * + */ + Variant& operator =(float rhs); + + /** + * Assigns the value of the specified instance to the current instance of %Variant. + * + * @since 2.0 + * + * @return A reference to the %Variant instance + * @param[in] rhs A @c double value + * + */ + Variant& operator =(double rhs); + + /** + * Assigns the value of the specified instance to the current instance of %Variant. + * + * @since 2.0 + * + * @return A reference to the %Variant instance + * @param[in] rhs A @c long value + * + */ + Variant& operator =(long rhs); + + /** + * Assigns the value of the specified instance to the current instance of %Variant. + * + * @since 2.0 + * + * @return A reference to the %Variant instance + * @param[in] rhs An unsigned @c long value + * + */ + Variant& operator =(unsigned long rhs); + + /** + * Assigns the value of the specified instance to the current instance of %Variant. + * + * @since 2.0 + * + * @return A reference to the %Variant instance + * @param[in] rhs A @c long @c long value + * + */ + Variant& operator =(long long rhs); + + /** + * Assigns the value of the specified instance to the current instance of %Variant. + * + * @since 2.0 + * @return A reference to the %Variant instance + * @param[in] rhs An unsigned @c long @c long value + * + */ + Variant& operator =(unsigned long long rhs); + + /** + * Assigns the value of the pointer to the current instance of %Variant. + * + * @since 2.0 + * + * @return A reference to the %Variant instance + * @param[in] pRhs A pointer to an array of characters + * + */ + Variant& operator =(const char* pRhs); + + /** + * Assigns the value of the pointer to the current instance of %Variant. + * + * @since 2.0 + * + * @return A reference to the %Variant instance + * @param[in] pRhs A pointer to an array of Unicode characters + * + */ + Variant& operator =(const wchar_t* pRhs); + + /** + * Assigns the value of the specified instance of Tizen::Base::String to the current instance of %Variant. + * + * @since 2.0 + * + * @return A reference to the %Variant instance + * @param[in] rhs An instance of Tizen::Base::String + */ + Variant& operator =(const Tizen::Base::String& rhs); + + /** + * Assigns the value of the specified instance of Tizen::Base::DateTime to the current instance of %Variant. + * + * @since 2.0 + * + * @return A reference to the %Variant instance + * @param[in] rhs An instance of Tizen::Base::DateTime + */ + Variant& operator =(const Tizen::Base::DateTime& rhs); + + /** + * Assigns the value of the specified instance of Tizen::Graphics::Color to the current instance of %Variant. + * + * @since 2.0 + * @return A reference to the %Variant instance + * @param[in] rhs An instance of Tizen::Graphics::Color + */ + Variant& operator =(const Tizen::Graphics::Color& rhs); + + /** + * Assigns the value of the specified instance of Tizen::Graphics::Point to the current instance of %Variant. + * + * @since 2.0 + * @return A reference to the %Variant instance + * @param[in] rhs An instance of Tizen::Graphics::Point + */ + Variant& operator =(const Tizen::Graphics::Point& rhs); + + /** + * Assigns the value of the specified instance of Tizen::Graphics::FloatPoint to the current instance of %Variant. + * + * @since 2.0 + * @return A reference to the %Variant instance + * @param[in] rhs An instance of Tizen::Graphics::FloatPoint + */ + Variant& operator =(const Tizen::Graphics::FloatPoint& rhs); + + /** + * Assigns the value of the specified instance of Tizen::Graphics::Rectangle to the current instance of %Variant. + * + * @since 2.0 + * @return A reference to the %Variant instance + * @param[in] rhs An instance of Tizen::Graphics::Rectangle + */ + Variant& operator =(const Tizen::Graphics::Rectangle& rhs); + + /** + * Assigns the value of the specified instance of Tizen::Graphics::FloatRectangle to the current instance of %Variant. + * + * @since 2.0 + * @return A reference to the %Variant instance + * @param[in] rhs An instance of Tizen::Graphics::FloatRectangle + */ + Variant& operator =(const Tizen::Graphics::FloatRectangle& rhs); + + /** + * Assigns the value of the specified instance of Tizen::Graphics::Dimension to the current instance of %Variant. + * + * @since 2.0 + * @return A reference to the %Variant instance + * @param[in] rhs An instance of Tizen::Graphics::Dimension + */ + Variant& operator =(const Tizen::Graphics::Dimension& rhs); + + /** + * Assigns the value of the specified instance of Tizen::Graphics::FloatDimension to the current instance of %Variant. + * + * @since 2.0 + * @return A reference to the %Variant instance + * @param[in] rhs An instance of Tizen::Graphics::FloatDimension + */ + Variant& operator =(const Tizen::Graphics::FloatDimension& rhs); + + /** + * Assigns the value of the specified instance of Tizen::Graphics::FloatMatrix4 to the current instance of %Variant. + * + * @since 2.0 + * @return A reference to the %Variant instance + * @param[in] rhs An instance of Tizen::Graphics::FloatMatrix4 + */ + Variant& operator =(const Tizen::Graphics::FloatMatrix4& rhs); + + /** + * Checks whether the specified instance and current instance of %Variant have equal values. + * + * @since 2.0 + * @return @c true if the two instances of %Variant are equal, @n + * else @c false + * @param[in] lhs An instance of %Variant + * @param[in] rhs An instance of %Variant + */ + _OSP_EXPORT_ friend bool operator ==(const Variant& lhs, const Variant& rhs); + + /** + * Checks whether the specified instance and current instance of %Variant have different values. + * @since 2.0 + * + * @return @c true if the values of the two instances of %Variant are not equal, @n + * else @c false + * @param[in] lhs An instance of %Variant + * @param[in] rhs An instance of %Variant + * + */ + _OSP_EXPORT_ friend bool operator !=(const Variant& lhs, const Variant& rhs); + + /** + * Gets the signed @c int equivalent of the current instance. + * + * @since 2.0 + * + * @return Signed @c int equivalent of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_INT. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_INT. + * + */ + int ToInt(void) const; + + /** + * Gets the unsigned @c int equivalent of the current instance. + * + * @since 2.0 + * + * @return Unsigned @c int equivalent of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_UINT. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_UINT. + * + */ + unsigned int ToUInt(void) const; + + /** + * Gets the @c bool equivalent of the current instance. + * + * @since 2.0 + * + * @return @c bool equivalent of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_BOOL. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns @c false and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_BOOL. + * + */ + bool ToBool(void) const; + + /** + * Gets the @c float equivalent of the current instance. + * + * @since 2.0 + * + * @return @c float equivalent of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_FLOAT. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_FLOAT. + * + */ + float ToFloat(void) const; + + /** + * Gets the @c double equivalent of the current instance. + * + * @since 2.0 + * + * @return @c double equivalent of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_DOUBLE. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_DOUBLE. + * + */ + double ToDouble(void) const; + + /** + * Gets the signed @c long equivalent of the current instance. + * + * @since 2.0 + * + * @return Signed @c long equivalent of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_LONG. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_LONG. + * + */ + long ToLong(void) const; + + /** + * Gets the unsigned @c int equivalent of the current instance. + * + * @since 2.0 + * + * @return Unsigned @c long equivalent of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_ULONG. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_ULONG. + * + */ + unsigned long ToULong(void) const; + + /** + * Gets the signed @c long @c long equivalent of the current instance. + * + * @since 2.0 + * + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_LONGLONG. + * + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_LONGLONG. + * + */ + long long ToLongLong(void) const; + + /** + * Gets the unsigned @c long @c long equivalent of the current instance. + * + * @since 2.0 + * + * @return Unsigned @c long @c long equivalent of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_ULONGLONG. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_ULONGLONG. + * + */ + unsigned long long ToULongLong(void) const; + + /** + * Gets the Tizen::Base::String representation of the value of the current instance. + * + * @since 2.0 + * + * @return A Tizen::Base::String representing the value of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_STRING. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns String("") and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_STRING. + * + */ + Tizen::Base::String ToString(void) const; + + /** + * Gets the Tizen::Base::DateTime representation of the value of the current instance. + * + * @since 2.0 + * + * @return A Tizen::Base::DateTime representing the value of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_DATETIME. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns DateTime and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_DATETIME. + * + */ + Tizen::Base::DateTime ToDateTime(void) const; + + /** + * Gets the Tizen::Graphics::Color representation of the value of the current instance. + * + * @since 2.0 + * + * @return A Tizen::Graphics::Color representing the value of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_COLOR. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns Color and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_COLOR. + * + */ + Tizen::Graphics::Color ToColor(void) const; + + /** + * Gets the Tizen::Graphics::Point representation of the value of the current instance. + * + * @since 2.0 + * + * @return A Tizen::Graphics::Point representing the value of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_POINT. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns Point and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_POINT. + * + */ + Tizen::Graphics::Point ToPoint(void) const; + + /** + * Gets the Tizen::Graphics::FloatPoint representation of the value of the current instance. + * + * @since 2.0 + * + * @return A Tizen::Graphics::FloatPoint representing the value of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_FLOATPOINT. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns FloatPoint and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_FLOATPOINT. + * + */ + Tizen::Graphics::FloatPoint ToFloatPoint(void) const; + + /** + * Gets the Tizen::Graphics::Rectangle representation of the value of the current instance. + * + * @since 2.0 + * + * @return A Tizen::Graphics::Rectangle representing the value of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_RECTANGLE. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns Rectangle and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_RECTANGLE. + * + */ + Tizen::Graphics::Rectangle ToRectangle(void) const; + + /** + * Gets the Tizen::Graphics::FloatRectangle representation of the value of the current instance. + * + * @since 2.0 + * + * @return A Tizen::Graphics::FloatRectangle representing the value of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_FLOATRECTANGLE. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns FloatRectangle and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_FLOATRECTANGLE. + * + */ + Tizen::Graphics::FloatRectangle ToFloatRectangle(void) const; + + /** + * Gets the Tizen::Graphics::Dimension representation of the value of the current instance. + * + * @since 2.0 + * + * @return A Tizen::Graphics::Dimension representing the value of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_DIMENSION. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns Dimension and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_DIMENSION. + * + */ + Tizen::Graphics::Dimension ToDimension(void) const; + + /** + * Gets the Tizen::Graphics::FloatDimension representation of the value of the current instance. + * + * @since 2.0 + * + * @return A Tizen::Graphics::FloatDimension representing the value of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_FLOATDIMENSION. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns FloatDimension and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_FLOATDIMENSION. + * + */ + Tizen::Graphics::FloatDimension ToFloatDimension(void) const; + + /** + * Gets the Tizen::Graphics::FloatMatrix4 representation of the value of the current instance. + * + * @since 2.0 + * + * @return A Tizen::Graphics::FloatMatrix4 representing the value of the current instance + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_FLOATMATRIX4. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * The method returns FloatMatrix4 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_FLOATMATRIX4. + * + */ + Tizen::Graphics::FloatMatrix4 ToFloatMatrix4(void) const; + + /** + * Checks whether the variant is empty. + * + * @since 2.0 + * + * @return @c true if the current instance is @c NULL_VARIANT, @n + * else @c false + */ + bool IsEmpty(void) const; + + /** + * Gets the type of the variant. + * + * @since 2.0 + * + * @return The variant type + */ + VariantType GetType(void) const; + + /** + * Checks whether the current instance of %Variant equals the specified instance of %Variant. + * + * @since 2.0 + * + * @return @c true if the values of the current instance is equal to the value of the specified instance, @n + * else @c false + * @param[in] obj An instance of %Variant + * @remarks This method overrides Tizen::Base::Object::Equals(). This method uses the values of the %Variant to compare the two instances. + */ + virtual bool Equals(const Object& obj) const; + + /** + * Gets the hash value of the current instance. + * + * @since 2.0 + * + * @return The hash value of the current instance + * @remarks Two equal instances must return the same hash value. For better performance, the used hash function must generate a random distribution for all inputs. + */ + virtual int GetHashCode(void) const; + +public: + /** + * A constant represents a @c null value. + * + * @since 2.0 + */ + static const Variant NULL_VARIANT; + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is prohibited. If this method is used in an application, the application can get rejected during + // the certification process. + // + // @since 2.0 + // + const _VariantImpl* GetVariantImpl(void) const; + + // + // This method is for internal use only. + // Using this method can cause behavioral, security-related, and consistency-related issues in the application. + // + // This method is prohibited. If this method is used in an application, the application can get rejected during + // the certification process. + // + // @since 2.0 + // + _VariantImpl* GetVariantImpl(void); + +private: + _VariantImpl* __pVariantImpl; +}; // Variant + +} } // Tizen::Ui + +#endif // _FUI_VARIANT_H_ diff --git a/inc/FUiVerticalBoxLayout.h b/inc/FUiVerticalBoxLayout.h new file mode 100644 index 0000000..3330f48 --- /dev/null +++ b/inc/FUiVerticalBoxLayout.h @@ -0,0 +1,356 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiVerticalBoxLayout.h + * @brief This is the header file for the %VerticalBoxLayout class. + * + * This header file contains the declarations of the %VerticalBoxLayout class. + */ +#ifndef _FUI_VERTICAL_BOX_LAYOUT_H_ +#define _FUI_VERTICAL_BOX_LAYOUT_H_ + +#include + +namespace Tizen { namespace Ui +{ +class Control; + +/** + * @class VerticalBoxLayout + * @brief The vertical box layout positions the children of a container vertically. + * + * @since 2.0 + * + * The %VerticalBoxLayout class defines the vertical box layout for a Container. The layout positions the children of the %Container vertically. + * + * For more information on the class features, see Vertical and Horizontal Box Layouts. + * + * @code +// Sample code for VerticalBoxLayoutSample.h +#include + +class VerticalBoxLayoutSample + : public Tizen::Ui::Controls::Form +{ +public: + bool Initialize(void); + virtual result OnInitializing(void); +}; + * @endcode + * + * @code +// Sample code for VerticalBoxLayoutSample.cpp +#include + +#include "VerticalBoxLayoutSample.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +bool +VerticalBoxLayoutSample::Initialize(void) +{ + //Creates an instance of VerticalBoxLayout + VerticalBoxLayout formLayout; + formLayout.Construct(VERTICAL_DIRECTION_DOWNWARD); + + // Applies the vertical box layout to the form + Construct(formLayout, FORM_STYLE_NORMAL); + return true; +} + +result +VerticalBoxLayoutSample::OnInitializing(void) +{ + result r = E_SUCCESS; + + // Creates an instance of VerticalBoxLayout for the top panel + VerticalBoxLayout topPanelLayout; + topPanelLayout.Construct(VERTICAL_DIRECTION_DOWNWARD); + + // Creates an instance of Panel and applies it to the vertical box layout + Panel* pTopPanel = new Panel(); + pTopPanel->Construct(topPanelLayout, Rectangle(0, 0, GetClientAreaBounds().width, 350)); + { + // Creates instances of Label and a instance of Button + Label* pLabel1 = new Label(); + pLabel1->Construct(Rectangle(0,0,150,80), L"RIGHT"); + pLabel1->SetBackgroundColor(Color(0x00, 0x10, 0x80, 0xFF)); + pTopPanel->AddControl(*pLabel1); + + Label* pLabel2 = new Label(); + pLabel2->Construct(Rectangle(0,0,200,80), L"CENTER"); + pLabel2->SetBackgroundColor(Color(0x00, 0x20, 0xA0, 0xFF)); + pTopPanel->AddControl(*pLabel2); + + Label* pLabel3 = new Label(); + pLabel3->Construct(Rectangle(0,0,150,80), L"LEFT"); + pLabel3->SetBackgroundColor(Color(0x00, 0x30, 0xC0, 0xFF)); + pTopPanel->AddControl(*pLabel3); + + Button* pButton = new Button(); + pButton->Construct(Rectangle(0,0,150,80), "FIT TO PARENT"); + pTopPanel->AddControl(*pButton); + + // Sets relations each label and button + topPanelLayout.SetHorizontalAlignment(*pLabel1, LAYOUT_HORIZONTAL_ALIGN_RIGHT); + topPanelLayout.SetHorizontalAlignment(*pLabel2, LAYOUT_HORIZONTAL_ALIGN_CENTER); + topPanelLayout.SetHorizontalAlignment(*pLabel3, LAYOUT_HORIZONTAL_ALIGN_LEFT); + topPanelLayout.SetSpacing(*pButton, 10); + topPanelLayout.SetHorizontalFitPolicy(*pButton, FIT_POLICY_PARENT); + } + + // Adds the top panel to the form + AddControl(*pTopPanel); + + // Creates an instance of VerticalBoxLayout for the bottom panel + VerticalBoxLayout bottomPanelLayout; + bottomPanelLayout.Construct(VERTICAL_DIRECTION_DOWNWARD); + + // Creates an instance of Panel and applies it to the vertial box layout + Panel* pBottomPanel = new Panel(); + pBottomPanel->Construct(bottomPanelLayout, Rectangle(0, 0, GetClientAreaBounds().width, 450)); + { + // Creates instances of Label + Label* pLabel1 = new Label(); + pLabel1->Construct(Rectangle(0,0,100,50), L"WEIGHT = 1.0f"); + pLabel1->SetBackgroundColor(Color(0x00, 0x10, 0x80, 0xFF)); + pBottomPanel->AddControl(*pLabel1); + + Label* pLabel2 = new Label(); + pLabel2->Construct(Rectangle(0,0,100,50), L"WEIGHT = 2.0f"); + pLabel2->SetBackgroundColor(Color(0x00, 0x20, 0xA0, 0xFF)); + pBottomPanel->AddControl(*pLabel2); + + Label* pLabel3 = new Label(); + pLabel3->Construct(Rectangle(0,0,100,50), L"WEIGHT = 3.0f"); + pLabel3->SetBackgroundColor(Color(0x00, 0x30, 0xC0, 0xFF)); + pBottomPanel->AddControl(*pLabel3); + + // Sets relations each label + bottomPanelLayout.SetHorizontalFitPolicy(*pLabel1, FIT_POLICY_PARENT); + bottomPanelLayout.SetHorizontalFitPolicy(*pLabel2, FIT_POLICY_PARENT); + bottomPanelLayout.SetHorizontalFitPolicy(*pLabel3, FIT_POLICY_PARENT); + bottomPanelLayout.SetWeight(*pLabel1, 1.0f); + bottomPanelLayout.SetWeight(*pLabel2, 2.0f); + bottomPanelLayout.SetWeight(*pLabel3, 3.0f); + } + + // Adds the bottom panel to the form + AddControl(*pBottomPanel); + + //Gets the layout of the form + VerticalBoxLayout* pFormLayout = dynamic_cast(this->GetLayoutN()); + + // Sets relations between panels + pFormLayout->SetHorizontalFitPolicy(*pTopPanel, FIT_POLICY_PARENT); + pFormLayout->SetSpacing(*pBottomPanel, 50); + pFormLayout->SetHorizontalFitPolicy(*pBottomPanel, FIT_POLICY_PARENT); + + return r; +} + * @endcode + * + */ +class _OSP_EXPORT_ VerticalBoxLayout + : public Layout +{ +public: + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + * + * @remarks After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance. + */ + VerticalBoxLayout(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~VerticalBoxLayout(void); + + /** + * Initializes this instance of %VerticalBoxLayout with the specified parameter. + * + * @since 2.0 + * + * @return An error code + * @param[in] direction The direction in which the children are attached + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(VerticalDirection direction); + + /** + * Gets the direction of the %VerticalBoxLayout. + * + * @since 2.0 + * + * @return An error code + * @param[out] direction The direction in which the children are attached + * @exception E_SUCCESS The method is successful. + */ + result GetDirection(VerticalDirection& direction) const; + + /** + * Gets the type of the layout. + * + * @since 2.0 + * + * @return The layout type + */ + virtual LayoutType GetLayoutType(void) const; + + /** + * Sets the horizontal alignment of the specified control. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the alignment is set + * @param[in] alignment The horizontal alignment + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the horizontal alignment is HORIZONTAL_ALIGNLEFT. + */ + result SetHorizontalAlignment(Control& childControl, LayoutHorizontalAlignment alignment); + + /** + * Sets the space between the specified control and its predecessor. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the space is set + * @param[in] space The space + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the spacing is set to @c 0. + */ + result SetSpacing(Control& childControl, int space); + + /** + * Sets the horizontal margins of the specified control. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the margins are set + * @param[in] left The left margin + * @param[in] right The right margin + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the margins are set to @c 0. + */ + result SetHorizontalMargin(Control& childControl, int left, int right); + + /** + * Sets the width of the specified control with the fixed length. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the width is set + * @param[in] width The value of the width + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result SetWidth(Control& childControl, int width); + + /** + * Sets the width of the specified control with the fitting policy. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the width is set + * @param[in] policy The fitting policy for the width + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result SetHorizontalFitPolicy(Control& childControl, FitPolicy policy); + + /** + * Sets the height of the specified control with a fixed length. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the height is set + * @param[in] height The value of the height + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + */ + result SetHeight(Control& childControl, int height); + + /** + * Sets the height of the specified control with the fitting policy. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the height is set + * @param[in] policy The fitting policy for the height + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks Setting FIT_POLICY_PARENT as @c policy does not cause the height of the control to change. + */ + result SetVerticalFitPolicy(Control& childControl, FitPolicy policy); + + /** + * Sets the weight of the specified control. + * + * @since 2.0 + * + * @return An error code + * @param[in] childControl The control for which the weight is set + * @param[in] weight The weight that indicates how much extra space the control occupies in proportion to it, in the %VerticalBoxLayout. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified @c childControl parameter is not a child of the container that owns the layout. + * @exception E_SYSTEM A system error has occurred. + * @remarks By default, the weight is set to @c 0.0f. + */ + result SetWeight(Control& childControl, float weight); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + VerticalBoxLayout(const VerticalBoxLayout& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + VerticalBoxLayout& operator =(const VerticalBoxLayout& rhs); +}; // VerticalBoxLayout + +}} // Tizen::Ui + +#endif // _FUI_VERTICAL_BOX_LAYOUT_H_ diff --git a/inc/FUiWindow.h b/inc/FUiWindow.h new file mode 100755 index 0000000..3762ff1 --- /dev/null +++ b/inc/FUiWindow.h @@ -0,0 +1,306 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiWindow.h + * @brief This is the header file for the %Window class. + * + * This header file contains the declarations of the %Window class. + */ + +#ifndef _FUI_WINDOW_H_ +#define _FUI_WINDOW_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Animations { +class DisplayContext; +}}} + +namespace Tizen { namespace Ui +{ + +class _WindowImpl; + +/** + * @enum WindowState + * + * Defines the state of %Window. + * + * @since 2.0 + */ +enum WindowState +{ + WINDOW_STATE_INITIALIZED = 0x0000, /**< The initial state of the window */ + WINDOW_STATE_ACTIVATED = 0x0001, /**< The state indicates that the window is the topmost window */ + WINDOW_STATE_DEACTIVATED = 0x0002, /**< The state indicates that the window is not the topmost window */ +}; + +/** + * @enum WindowZOrderGroup + * + * Defines the Z order group of %Window. + * + * @since 2.0 + */ +enum WindowZOrderGroup +{ + WINDOW_Z_ORDER_GROUP_HIGHEST, /** The highest group for windows such as the call screen */ + WINDOW_Z_ORDER_GROUP_HIGH, /** The high qroup for windows such as the lock screen */ + WINDOW_Z_ORDER_GROUP_NORMAL, /** The default group of apps */ +}; + +/** + * @class Window + * @brief This class provides abstract top-level 'window' objects. + * + * @since 2.0 + * + * The %Window is a top-level window such as Controls::Frame, Controls::MessageBox, and Controls::Popup. + * The descendants of a %Window can exist outside of their applications's bounds. + * The %Window class is an abstract base class. + * + */ +class _OSP_EXPORT_ Window + : public Container +{ + +public: + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.0 + */ + virtual ~Window(void) = 0; + + /** + * Adds the listener instance. @n + * The added listener can listen to events on when they are fired. + * + * @since 2.0 + * + * @param[in] listener The event listener to add + * @see RemoveWindowEventListener() + */ + void AddWindowEventListener(Tizen::Ui::IWindowEventListener& listener); + + /** + * Removes a listener instance. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * + * @param[in] listener The listener to remove + * @see AddWindowEventListener() + */ + void RemoveWindowEventListener(Tizen::Ui::IWindowEventListener& listener); + + /** + * Shows the %Window. + * + * @since 2.0 + * + * @final Although this method is virtual, it should not be overridden. + * If overridden, it may not work as expected. + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation, or + * this control is not 'displayable'. + * @exception E_SYSTEM A system error has occurred. + */ + virtual result Show(void); + + /** + * Sets the owner of the window. + * + * @since 2.0 + * + * @param[in] pControl The control + * @remarks The ownership of @c pControl is not transferred to this instance. It is the developer's responsibility to deallocate @c pControl even after calling this method. + */ + void SetOwner(Tizen::Ui::Control *pControl); + + /** + * @if VISPARTNER-OPERATOR + * Sets the Z order group of %Window. + * + * @since 2.0 + * + * @visibility partner-operator + * @privilege %http://tizen.org/privilege/uimanager + * + * @return An error code + * @param[in] windowZOrderGroup The Z order group of %Window + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @remarks If this method is not explicitly called, the Z order group of %Window is set to #WINDOW_Z_ORDER_GROUP_NORMAL. + * @endif + */ + result SetZOrderGroup(WindowZOrderGroup windowZOrderGroup); + + /** + * Gets the current state of the window. + * + * @since 2.0 + * + * @return The current state of the window + */ + WindowState GetWindowState(void) const; + + /** + * Gets the display context of the window. + * + * @since 2.0 + * + * @return A pointer to the DisplayContext instance + */ + Tizen::Ui::Animations::DisplayContext* GetDisplayContext(void) const; + +protected: + /** + * Initializes this instance of %Window. + * + * @since 2.0 + * + * @return An error code + * @param[in] rect The rectangle bounds to set + * @param[in] resizable Set to @c true to make the window resizable, @n + * else @c false + * @param[in] movable Set to @c true to make the window movable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks This method must be called from the derived classes's construct methods. + * @remarks If the @c resizable is @c false, IsResizable() returns @c false. + * @see IsResizable() + */ + result Construct(const Tizen::Graphics::Rectangle& rect, bool resizable = true, bool movable = true); + + /** + * Initializes this instance of %Window with the specified layout and rectangular region. + * + * @since 2.0 + * + * @return An error code + * @param[in] layout The layout for both the portrait and landscape mode + * @param[in] rect The location and size of the %window + * @param[in] resizable Set to @c true to make the window resizable, @n + * else @c false + * @param[in] movable Set to @c true to make the window movable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks This method must be called from the derived classes's construct methods. + * @remarks If the @c resizable is @c false, IsResizable() returns @c false. + * @see IsResizable() + * @see Tizen::Ui::Layout + * @see Tizen::Ui::Container::GetLayoutN() + */ + result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Rectangle& rect, bool resizable = true, bool movable = true); + + /** + * Initializes this instance of %Window with the specified layouts and rectangular region. + * + * @since 2.0 + * + * @return An error code + * @param[in] portraitLayout The layout for the portrait mode + * @param[in] landscapeLayout The layout for the landscape mode + * @param[in] rect The location and size of the %Window + * @param[in] resizable Set to @c true to make the window resizable, @n + * else @c false + * @param[in] movable Set to @c true to make the window movable, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @remarks If the @c resizable is @c false, IsResizable() returns @c false. + * @see IsResizable() + * @see Tizen::Ui::Layout + * @see Tizen::Ui::Container::GetLayoutN() + * @see Tizen::Ui::Container::GetPortraitLayoutN() + * @see Tizen::Ui::Container::GetLandscapeLayoutN() + */ + result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Rectangle& rect, bool resizable = true, bool movable = true); + + /** + * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor. + * + * @since 2.0 + */ + Window(void); + +private: + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + Window(const Window& rhs); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + Window& operator =(const Window& rhs); + +protected: + friend class _WindowImpl; + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Window_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Window_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Window_Reserved3(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Window_Reserved4(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // This method is reserved and may change its name at any time without prior notice. + // + virtual void Window_Reserved5(void) {} +}; // Window + +}} // Tizen::Ui + +#endif //_FUI_WINDOW_H_ diff --git a/inc/egl.h b/inc/egl.h new file mode 100644 index 0000000..301e4a3 --- /dev/null +++ b/inc/egl.h @@ -0,0 +1,570 @@ +/* $Change: 1028567 $ */ +/* -*- mode: c; tab-width: 8; -*- */ +/* vi: set sw=4 ts=8: */ +/* Reference version of egl.h for EGL 1.4. + * $Revision: #1 $ on $Date: 2011/08/12 $ + */ + +/* +** Copyright (c) 2007-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/** + * @file egl.h + * @brief This is the header file for the EGL. + * + * This header file contains the declarations of the EGL. + */ + +#ifndef __egl_h_ +#define __egl_h_ + +/* All platform-dependent types and macro boilerplate (such as EGLAPI + * and EGLAPIENTRY) should go in eglplatform.h. + */ +#include "eglplatform.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup opengles + * + * @{ + */ + +/* EGL Types */ +/* EGLint is defined in eglplatform.h */ + +/*! \var typedef unsigned int EGLBoolean + \brief A type definition for EGLBoolean. +*/ +typedef unsigned int EGLBoolean; + +/*! \var typedef unsigned int EGLenum + \brief A type definition for EGLenum. +*/ +typedef unsigned int EGLenum; + +/*! \var typedef void *EGLConfig + \brief A type definition for EGLConfig. +*/ +typedef void* EGLConfig; + +/*! \var typedef void *EGLContext + \brief A type definition for EGLContext. +*/ +typedef void* EGLContext; + +/*! \var typedef void *EGLDisplay + \brief A type definition for EGLDisplay. +*/ +typedef void* EGLDisplay; + +/*! \var typedef void *EGLSurface + \brief A type definition for EGLSurface. +*/ +typedef void* EGLSurface; + +/*! \var typedef void *EGLClientBuffer + \brief A type definition for EGLClientBuffer. +*/ +typedef void* EGLClientBuffer; + +/* EGL Versioning */ +#define EGL_VERSION_1_0 1 +#define EGL_VERSION_1_1 1 +#define EGL_VERSION_1_2 1 +#define EGL_VERSION_1_3 1 +#define EGL_VERSION_1_4 1 + +/* EGL Enumerants. Bitmasks and other exceptional cases aside, most + * enums are assigned unique values starting at 0x3000. + */ + +/* EGL aliases */ +#define EGL_FALSE 0 +#define EGL_TRUE 1 + +/* Out-of-band handle values */ +#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0) +#define EGL_NO_CONTEXT ((EGLContext) 0) +#define EGL_NO_DISPLAY ((EGLDisplay) 0) +#define EGL_NO_SURFACE ((EGLSurface) 0) + +/* Out-of-band attribute value */ +#define EGL_DONT_CARE ((EGLint) - 1) + +/* Errors / GetError return values */ +#define EGL_SUCCESS 0x3000 +#define EGL_NOT_INITIALIZED 0x3001 +#define EGL_BAD_ACCESS 0x3002 +#define EGL_BAD_ALLOC 0x3003 +#define EGL_BAD_ATTRIBUTE 0x3004 +#define EGL_BAD_CONFIG 0x3005 +#define EGL_BAD_CONTEXT 0x3006 +#define EGL_BAD_CURRENT_SURFACE 0x3007 +#define EGL_BAD_DISPLAY 0x3008 +#define EGL_BAD_MATCH 0x3009 +#define EGL_BAD_NATIVE_PIXMAP 0x300A +#define EGL_BAD_NATIVE_WINDOW 0x300B +#define EGL_BAD_PARAMETER 0x300C +#define EGL_BAD_SURFACE 0x300D +#define EGL_CONTEXT_LOST 0x300E /* EGL 1.1 - IMG_power_management */ + +/* Reserved 0x300F-0x301F for additional errors */ + +/* Config attributes */ +#define EGL_BUFFER_SIZE 0x3020 +#define EGL_ALPHA_SIZE 0x3021 +#define EGL_BLUE_SIZE 0x3022 +#define EGL_GREEN_SIZE 0x3023 +#define EGL_RED_SIZE 0x3024 +#define EGL_DEPTH_SIZE 0x3025 +#define EGL_STENCIL_SIZE 0x3026 +#define EGL_CONFIG_CAVEAT 0x3027 +#define EGL_CONFIG_ID 0x3028 +#define EGL_LEVEL 0x3029 +#define EGL_MAX_PBUFFER_HEIGHT 0x302A +#define EGL_MAX_PBUFFER_PIXELS 0x302B +#define EGL_MAX_PBUFFER_WIDTH 0x302C +#define EGL_NATIVE_RENDERABLE 0x302D +#define EGL_NATIVE_VISUAL_ID 0x302E +#define EGL_NATIVE_VISUAL_TYPE 0x302F +#define EGL_PRESERVED_RESOURCES 0x3030 +#define EGL_SAMPLES 0x3031 +#define EGL_SAMPLE_BUFFERS 0x3032 +#define EGL_SURFACE_TYPE 0x3033 +#define EGL_TRANSPARENT_TYPE 0x3034 +#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 +#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 +#define EGL_TRANSPARENT_RED_VALUE 0x3037 +#define EGL_NONE 0x3038 /* Attrib list terminator */ +#define EGL_BIND_TO_TEXTURE_RGB 0x3039 +#define EGL_BIND_TO_TEXTURE_RGBA 0x303A +#define EGL_MIN_SWAP_INTERVAL 0x303B +#define EGL_MAX_SWAP_INTERVAL 0x303C +#define EGL_LUMINANCE_SIZE 0x303D +#define EGL_ALPHA_MASK_SIZE 0x303E +#define EGL_COLOR_BUFFER_TYPE 0x303F +#define EGL_RENDERABLE_TYPE 0x3040 +#define EGL_MATCH_NATIVE_PIXMAP 0x3041 /* Pseudo-attribute (not queryable) */ +#define EGL_CONFORMANT 0x3042 + +/* Reserved 0x3041-0x304F for additional config attributes */ + +/* Config attribute values */ +#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */ +#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* EGL_CONFIG_CAVEAT value */ +#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */ +#define EGL_RGB_BUFFER 0x308E /* EGL_COLOR_BUFFER_TYPE value */ +#define EGL_LUMINANCE_BUFFER 0x308F /* EGL_COLOR_BUFFER_TYPE value */ + +/* More config attribute values, for EGL_TEXTURE_FORMAT */ +#define EGL_NO_TEXTURE 0x305C +#define EGL_TEXTURE_RGB 0x305D +#define EGL_TEXTURE_RGBA 0x305E +#define EGL_TEXTURE_2D 0x305F + +/* Config attribute mask bits */ +#define EGL_PBUFFER_BIT 0x0001 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_PIXMAP_BIT 0x0002 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_WINDOW_BIT 0x0004 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */ +#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */ + +#define EGL_OPENGL_ES_BIT 0x0001 /* EGL_RENDERABLE_TYPE mask bits */ +#define EGL_OPENVG_BIT 0x0002 /* EGL_RENDERABLE_TYPE mask bits */ +#define EGL_OPENGL_ES2_BIT 0x0004 /* EGL_RENDERABLE_TYPE mask bits */ +#define EGL_OPENGL_BIT 0x0008 /* EGL_RENDERABLE_TYPE mask bits */ + +/* QueryString targets */ +#define EGL_VENDOR 0x3053 +#define EGL_VERSION 0x3054 +#define EGL_EXTENSIONS 0x3055 +#define EGL_CLIENT_APIS 0x308D + +/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */ +#define EGL_HEIGHT 0x3056 +#define EGL_WIDTH 0x3057 +#define EGL_LARGEST_PBUFFER 0x3058 +#define EGL_TEXTURE_FORMAT 0x3080 +#define EGL_TEXTURE_TARGET 0x3081 +#define EGL_MIPMAP_TEXTURE 0x3082 +#define EGL_MIPMAP_LEVEL 0x3083 +#define EGL_RENDER_BUFFER 0x3086 +#define EGL_VG_COLORSPACE 0x3087 +#define EGL_VG_ALPHA_FORMAT 0x3088 +#define EGL_HORIZONTAL_RESOLUTION 0x3090 +#define EGL_VERTICAL_RESOLUTION 0x3091 +#define EGL_PIXEL_ASPECT_RATIO 0x3092 +#define EGL_SWAP_BEHAVIOR 0x3093 +#define EGL_MULTISAMPLE_RESOLVE 0x3099 + +/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */ +#define EGL_BACK_BUFFER 0x3084 +#define EGL_SINGLE_BUFFER 0x3085 + +/* OpenVG color spaces */ +#define EGL_VG_COLORSPACE_sRGB 0x3089 /* EGL_VG_COLORSPACE value */ +#define EGL_VG_COLORSPACE_LINEAR 0x308A /* EGL_VG_COLORSPACE value */ + +/* OpenVG alpha formats */ +#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B /* EGL_ALPHA_FORMAT value */ +#define EGL_VG_ALPHA_FORMAT_PRE 0x308C /* EGL_ALPHA_FORMAT value */ + +/* Constant scale factor by which fractional display resolutions & + * aspect ratio are scaled when queried as integer values. + */ +#define EGL_DISPLAY_SCALING 10000 + +/* Unknown display resolution/aspect ratio */ +#define EGL_UNKNOWN ((EGLint) - 1) + +/* Back buffer swap behaviors */ +#define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */ +#define EGL_BUFFER_DESTROYED 0x3095 /* EGL_SWAP_BEHAVIOR value */ + +/* CreatePbufferFromClientBuffer buffer types */ +#define EGL_OPENVG_IMAGE 0x3096 + +/* QueryContext targets */ +#define EGL_CONTEXT_CLIENT_TYPE 0x3097 + +/* CreateContext attributes */ +#define EGL_CONTEXT_CLIENT_VERSION 0x3098 + +/* Multisample resolution behaviors */ +#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */ +#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B /* EGL_MULTISAMPLE_RESOLVE value */ + +/* BindAPI/QueryAPI targets */ +#define EGL_OPENGL_ES_API 0x30A0 +#define EGL_OPENVG_API 0x30A1 +#define EGL_OPENGL_API 0x30A2 + +/* GetCurrentSurface targets */ +#define EGL_DRAW 0x3059 +#define EGL_READ 0x305A + +/* WaitNative engines */ +#define EGL_CORE_NATIVE_ENGINE 0x305B + +/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */ +#define EGL_COLORSPACE EGL_VG_COLORSPACE +#define EGL_ALPHA_FORMAT EGL_VG_ALPHA_FORMAT +#define EGL_COLORSPACE_sRGB EGL_VG_COLORSPACE_sRGB +#define EGL_COLORSPACE_LINEAR EGL_VG_COLORSPACE_LINEAR +#define EGL_ALPHA_FORMAT_NONPRE EGL_VG_ALPHA_FORMAT_NONPRE +#define EGL_ALPHA_FORMAT_PRE EGL_VG_ALPHA_FORMAT_PRE + +/* EGL extensions must request enum blocks from the Khronos + * API Registrar, who maintains the enumerant registry. Submit + * a bug in Khronos Bugzilla against task "Registry". + */ + +/* +** FIXME: The EGL_SEQUENCE_ITEM_SYMB token is temporary until an +** official name and value are assigned. +*/ +#define EGL_SEQUENCE_ITEM_SYMB 0x6000 + +/* EGL Functions */ + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLint eglGetError(void); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglTerminate(EGLDisplay dpy); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +const char* eglQueryString(EGLDisplay dpy, EGLint name); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglBindAPI(EGLenum api); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLenum eglQueryAPI(void); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglWaitClient(void); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglReleaseThread(void); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint* attrib_list); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLContext eglGetCurrentContext(void); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLSurface eglGetCurrentSurface(EGLint readdraw); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLDisplay eglGetCurrentDisplay(void); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglWaitGL(void); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglWaitNative(EGLint engine); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); + +/* This is a generic function pointer type, whose name indicates it must + * be cast to the proper type *and calling convention* before use. + */ +/*! \var typedef void (*__eglMustCastToProperFunctionPointerType)(void) + \brief A type definition for __eglMustCastToProperFunctionPointerType. +*/ +typedef void (*__eglMustCastToProperFunctionPointerType)(void); + +/* Now, define eglGetProcAddress using the generic function ptr. type */ +/** + * @page EGLeglGetProcAddress Compatibility for eglGetProcAddress. + * @section CompClassNameMethodNamePageIssueSection Issues + * Implementation of this method in API versions prior to 1.2 has the following issue: @n + * + * -# This method does not work as expected in API versions prior to 1.2. + * + * @section CompClassNameMethodNamePageSolutionSection Resolutions + * The issue mentioned above is resolved in API version 1.2, and it is recommended to use API version 1.2 or above. @n +*/ +/** + * Returns function pointer of a GL or an EGL extension function. + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + * +*/ +EGLAPI __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char* procname); + +/** + * You can find more details at the Khronos Group site: http://www.khronos.org/registry/egl + * + * @since 2.0 + */ +EGLBoolean eglUpdateBufferOSP(EGLDisplay dpy, EGLSurface surface); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __egl_h_ */ diff --git a/inc/egl_macro.h b/inc/egl_macro.h new file mode 100644 index 0000000..85537b9 --- /dev/null +++ b/inc/egl_macro.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _EGL_MACRO_H_ +#define _EGL_MACRO_H_ + +#define eglGetError _SglGetError +#define eglGetDisplay _SglGetDisplay +#define eglInitialize _SglInitialize +#define eglTerminate _SglTerminate +#define eglQueryString _SglQueryString +#define eglGetConfigs _SglGetConfigs +#define eglChooseConfig _SglChooseConfig +#define eglGetConfigAttrib _SglGetConfigAttrib +#define eglCreateWindowSurface _SglCreateWindowSurface +#define eglCreatePbufferSurface _SglCreatePbufferSurface +#define eglCreatePixmapSurface _SglCreatePixmapSurface +#define eglDestroySurface _SglDestroySurface +#define eglQuerySurface _SglQuerySurface +#define eglBindAPI _SglBindAPI +#define eglQueryAPI _SglQueryAPI +#define eglWaitClient _SglWaitClient +#define eglReleaseThread _SglReleaseThread +#define eglCreatePbufferFromClientBuffer _SglCreatePbufferFromClientBuffer +#define eglSurfaceAttrib _SglSurfaceAttrib +#define eglBindTexImage _SglBindTexImage +#define eglReleaseTexImage _SglReleaseTexImage +#define eglSwapInterval _SglSwapInterval +#define eglCreateContext _SglCreateContext +#define eglDestroyContext _SglDestroyContext +#define eglMakeCurrent _SglMakeCurrent +#define eglGetCurrentContext _SglGetCurrentContext +#define eglGetCurrentSurface _SglGetCurrentSurface +#define eglGetCurrentDisplay _SglGetCurrentDisplay +#define eglQueryContext _SglQueryContext +#define eglWaitGL _SglWaitGL +#define eglWaitNative _SglWaitNative +#define eglSwapBuffers _SglSwapBuffers +#define eglCopyBuffers _SglCopyBuffers +#define eglGetProcAddress _SglGetProcAddress +#define eglUpdateBufferOSP _SglUpdateBufferOSP + +#endif // _EGL_MACRO_H_ diff --git a/inc/eglext.h b/inc/eglext.h new file mode 100644 index 0000000..a9dbc86 --- /dev/null +++ b/inc/eglext.h @@ -0,0 +1,325 @@ +#ifndef __eglext_h_ +#define __eglext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007-2010 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +#include + +/*************************************************************/ + +/* Header file version number */ +/* Current version at http://www.khronos.org/registry/egl/ */ +/* $Revision: 13164 $ on $Date: 2010-12-09 01:26:57 -0800 (Thu, 09 Dec 2010) $ */ +#define EGL_EGLEXT_VERSION 9 + +#ifndef EGL_KHR_config_attribs +#define EGL_KHR_config_attribs 1 +#define EGL_CONFORMANT_KHR 0x3042 /* EGLConfig attribute */ +#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 /* EGL_SURFACE_TYPE bitfield */ +#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 /* EGL_SURFACE_TYPE bitfield */ +#endif + +#ifndef EGL_KHR_lock_surface +#define EGL_KHR_lock_surface 1 +#define EGL_READ_SURFACE_BIT_KHR 0x0001 /* EGL_LOCK_USAGE_HINT_KHR bitfield */ +#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 /* EGL_LOCK_USAGE_HINT_KHR bitfield */ +#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 /* EGL_SURFACE_TYPE bitfield */ +#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 /* EGL_SURFACE_TYPE bitfield */ +#define EGL_MATCH_FORMAT_KHR 0x3043 /* EGLConfig attribute */ +#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 /* EGL_MATCH_FORMAT_KHR value */ +#define EGL_FORMAT_RGB_565_KHR 0x30C1 /* EGL_MATCH_FORMAT_KHR value */ +#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 /* EGL_MATCH_FORMAT_KHR value */ +#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 /* EGL_MATCH_FORMAT_KHR value */ +#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 /* eglLockSurfaceKHR attribute */ +#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 /* eglLockSurfaceKHR attribute */ +#define EGL_BITMAP_POINTER_KHR 0x30C6 /* eglQuerySurface attribute */ +#define EGL_BITMAP_PITCH_KHR 0x30C7 /* eglQuerySurface attribute */ +#define EGL_BITMAP_ORIGIN_KHR 0x30C8 /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC /* eglQuerySurface attribute */ +#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD /* eglQuerySurface attribute */ +#define EGL_LOWER_LEFT_KHR 0x30CE /* EGL_BITMAP_ORIGIN_KHR value */ +#define EGL_UPPER_LEFT_KHR 0x30CF /* EGL_BITMAP_ORIGIN_KHR value */ +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface); +#endif + +#ifndef EGL_KHR_image +#define EGL_KHR_image 1 +#define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */ +typedef void *EGLImageKHR; +#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); +#endif + +#ifndef EGL_KHR_vg_parent_image +#define EGL_KHR_vg_parent_image 1 +#define EGL_VG_PARENT_IMAGE_KHR 0x30BA /* eglCreateImageKHR target */ +#endif + +#ifndef EGL_KHR_gl_texture_2D_image +#define EGL_KHR_gl_texture_2D_image 1 +#define EGL_GL_TEXTURE_2D_KHR 0x30B1 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC /* eglCreateImageKHR attribute */ +#endif + +#ifndef EGL_KHR_gl_texture_cubemap_image +#define EGL_KHR_gl_texture_cubemap_image 1 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 /* eglCreateImageKHR target */ +#endif + +#ifndef EGL_KHR_gl_texture_3D_image +#define EGL_KHR_gl_texture_3D_image 1 +#define EGL_GL_TEXTURE_3D_KHR 0x30B2 /* eglCreateImageKHR target */ +#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD /* eglCreateImageKHR attribute */ +#endif + +#ifndef EGL_KHR_gl_renderbuffer_image +#define EGL_KHR_gl_renderbuffer_image 1 +#define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */ +#endif + +#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */ +#ifndef EGL_KHR_reusable_sync +#define EGL_KHR_reusable_sync 1 + +typedef void* EGLSyncKHR; +typedef khronos_utime_nanoseconds_t EGLTimeKHR; + +#define EGL_SYNC_STATUS_KHR 0x30F1 +#define EGL_SIGNALED_KHR 0x30F2 +#define EGL_UNSIGNALED_KHR 0x30F3 +#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 +#define EGL_CONDITION_SATISFIED_KHR 0x30F6 +#define EGL_SYNC_TYPE_KHR 0x30F7 +#define EGL_SYNC_REUSABLE_KHR 0x30FA +#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR bitfield */ +#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull +#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#endif +#endif + +#ifndef EGL_KHR_image_base +#define EGL_KHR_image_base 1 +/* Most interfaces defined by EGL_KHR_image_pixmap above */ +#define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */ +#endif + +#ifndef EGL_KHR_image_pixmap +#define EGL_KHR_image_pixmap 1 +/* Interfaces defined by EGL_KHR_image above */ +#endif + +#ifndef EGL_IMG_context_priority +#define EGL_IMG_context_priority 1 +#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 +#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 +#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 +#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 +#endif + +#ifndef EGL_KHR_lock_surface2 +#define EGL_KHR_lock_surface2 1 +#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 +#endif + +#ifndef EGL_NV_coverage_sample +#define EGL_NV_coverage_sample 1 +#define EGL_COVERAGE_BUFFERS_NV 0x30E0 +#define EGL_COVERAGE_SAMPLES_NV 0x30E1 +#endif + +#ifndef EGL_NV_depth_nonlinear +#define EGL_NV_depth_nonlinear 1 +#define EGL_DEPTH_ENCODING_NV 0x30E2 +#define EGL_DEPTH_ENCODING_NONE_NV 0 +#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 +#endif + +#if KHRONOS_SUPPORT_INT64 /* EGLTimeNV requires 64-bit uint support */ +#ifndef EGL_NV_sync +#define EGL_NV_sync 1 +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 +#define EGL_SYNC_STATUS_NV 0x30E7 +#define EGL_SIGNALED_NV 0x30E8 +#define EGL_UNSIGNALED_NV 0x30E9 +#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 +#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull +#define EGL_ALREADY_SIGNALED_NV 0x30EA +#define EGL_TIMEOUT_EXPIRED_NV 0x30EB +#define EGL_CONDITION_SATISFIED_NV 0x30EC +#define EGL_SYNC_TYPE_NV 0x30ED +#define EGL_SYNC_CONDITION_NV 0x30EE +#define EGL_SYNC_FENCE_NV 0x30EF +#define EGL_NO_SYNC_NV ((EGLSyncNV)0) +typedef void* EGLSyncNV; +typedef khronos_utime_nanoseconds_t EGLTimeNV; +#ifdef EGL_EGLEXT_PROTOTYPES +EGLSyncNV eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +EGLBoolean eglDestroySyncNV (EGLSyncNV sync); +EGLBoolean eglFenceNV (EGLSyncNV sync); +EGLint eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +EGLBoolean eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); +EGLBoolean eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); +#endif +#endif + +#if KHRONOS_SUPPORT_INT64 /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */ +#ifndef EGL_KHR_fence_sync +#define EGL_KHR_fence_sync 1 +/* Reuses most tokens and entry points from EGL_KHR_reusable_sync */ +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 +#define EGL_SYNC_CONDITION_KHR 0x30F8 +#define EGL_SYNC_FENCE_KHR 0x30F9 +#endif +#endif + +#ifndef EGL_HI_clientpixmap +#define EGL_HI_clientpixmap 1 + +/* Surface Attribute */ +#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 +/* + * Structure representing a client pixmap + * (pixmap's data is in client-space memory). + */ +struct EGLClientPixmapHI +{ + void* pData; + EGLint iWidth; + EGLint iHeight; + EGLint iStride; +}; + +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap); +#endif /* EGL_HI_clientpixmap */ + +#ifndef EGL_HI_colorformats +#define EGL_HI_colorformats 1 +/* Config Attribute */ +#define EGL_COLOR_FORMAT_HI 0x8F70 +/* Color Formats */ +#define EGL_COLOR_RGB_HI 0x8F71 +#define EGL_COLOR_RGBA_HI 0x8F72 +#define EGL_COLOR_ARGB_HI 0x8F73 +#endif /* EGL_HI_colorformats */ + +#ifndef EGL_MESA_drm_image +#define EGL_MESA_drm_image 1 +#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 /* CreateDRMImageMESA attribute */ +#define EGL_DRM_BUFFER_USE_MESA 0x31D1 /* CreateDRMImageMESA attribute */ +#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 /* EGL_IMAGE_FORMAT_MESA attribute value */ +#define EGL_DRM_BUFFER_MESA 0x31D3 /* eglCreateImageKHR target */ +#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 +#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 /* EGL_DRM_BUFFER_USE_MESA bits */ +#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 /* EGL_DRM_BUFFER_USE_MESA bits */ +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif + +#ifndef EGL_NV_post_sub_buffer +#define EGL_NV_post_sub_buffer 1 +#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif + +#ifndef EGL_SEC_image_map +#define EGL_SEC_image_map 1 +#define EGL_MAP_GL_TEXTURE_2D_SEC 0x3201 /* eglCreateImageKHR target */ +#define EGL_MAP_GL_TEXTURE_HEIGHT_SEC 0x3202 /* eglCreateImageKHR attribute */ +#define EGL_MAP_GL_TEXTURE_WIDTH_SEC 0x3203 /* eglCreateImageKHR attribute */ +#define EGL_MAP_GL_TEXTURE_FORMAT_SEC 0x3204 /* eglCreateImageKHR attribute, Specifies the number of color components in the mapped texture. */ +#define EGL_MAP_GL_TEXTURE_RGB_SEC 0x3205 /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */ +#define EGL_MAP_GL_TEXTURE_RGBA_SEC 0x3206 /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */ +#define EGL_MAP_GL_TEXTURE_BGRA_SEC 0x3207 /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */ +#define EGL_MAP_GL_TEXTURE_LUMINANCE_SEC 0x3208 /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */ +#define EGL_MAP_GL_TEXTURE_LUMINANCE_ALPHA_SEC 0x3209 /* More config attribute value, for EGL_MAP_GL_TEXTURE_FORMAT_SEC */ +#define EGL_MAP_GL_TEXTURE_PIXEL_TYPE_SEC 0x320a /* eglCreateImageKHR attribute, Specifies the data type of the pixel data. */ +#define EGL_MAP_GL_TEXTURE_UNSIGNED_BYTE_SEC 0x320b /* More config attribute value, for EGL_MAP_GL_TEXTURE_PIXEL_TYPE_SEC */ +#define EGL_MAP_GL_TEXTURE_STRIDE_IN_BYTES_SEC 0x320c /* GetImageAttribSEC target */ + +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI void * EGLAPIENTRY eglMapImageSEC (EGLDisplay dpy, EGLImageKHR image); +EGLAPI EGLBoolean EGLAPIENTRY eglUnmapImageSEC (EGLDisplay dpy, EGLImageKHR image); +EGLAPI EGLBoolean EGLAPIENTRY eglGetImageAttribSEC (EGLDisplay dpy, EGLImageKHR image, EGLint attribute, EGLint *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef void * (EGLAPIENTRYP PFNEGLMAPIMAGESECPROC) (EGLDisplay dpy, EGLImageKHR image); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNMAPIMAGESECPROC) (EGLDisplay dpy, EGLImageKHR image); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETIMAGEATTRIBSECPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint attribute, EGLint *value); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inc/eglplatform.h b/inc/eglplatform.h new file mode 100644 index 0000000..56bd4df --- /dev/null +++ b/inc/eglplatform.h @@ -0,0 +1,180 @@ +/* $Change: 1028567 $ */ + +/** + * @file eglplatform.h + * @brief This is the header file for the eglplatform. + * + * This header file contains the declarations of the eglplatform. + */ + +#ifndef __eglplatform_h_ +#define __eglplatform_h_ + +/* +** Copyright (c) 2007-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + */ + +/* Platform-specific types and definitions for egl.h + * $Revision: #1 $ on $Date: 2011/08/12 $ + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) + * by filing a bug against product "EGL" component "Registry". + */ + +#ifdef _FGRAPHICS_OPENGL_H_ +}}} +#endif + +namespace Tizen { namespace Ui +{ +class Control; +}; +}; +namespace Tizen { namespace Graphics +{ +class Bitmap; +}; +}; + +#ifdef _FGRAPHICS_OPENGL_H_ +namespace Tizen { namespace Graphics { namespace Opengl +{ +#endif + + +#include "khrplatform.h" + + +/* Macros used in EGL function prototype declarations. + * + * EGL functions should be prototyped as: + * + * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); + * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); + * + * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h + */ + +/** + * @addtogroup opengles + * + * @{ + */ + +#ifndef _WIN32 +#define EGLAPI +#define EGLAPIENTRY +#else +#ifndef EGLAPIENTRY +#define EGLAPIENTRY __stdcall +#endif +#ifndef EGLAPI +#define EGLAPI +#endif +#endif + +#define EGLAPIENTRYP KHRONOS_APIENTRY* +/* +** Types and resources +*/ + +/*! \var typedef int EGLint + \brief A type definition for EGLConfig. +*/ +typedef int EGLint; + +#ifdef _WIN32 +typedef void* EGLNativeDisplayType; +class Tizen::Ui::Control; +typedef Tizen::Ui::Control* EGLNativeWindowType; +class Tizen::Graphics::Bitmap; +typedef Tizen::Graphics::Bitmap* EGLNativePixmapType; + +#elif FEATURE_SYSLSI_S5PC110 +typedef int EGLNativeDisplayType; +typedef void* EGLNativeWindowType; +typedef struct +{ + void* pBuffer; + long lWidth; + long lHeight; + enum + { + NUEGL_PIXELFORMAT_565 = 0, + NUEGL_PIXELFORMAT_4444 = 1, + NUEGL_PIXELFORMAT_8888 = 2, + NUEGL_PIXELFORMAT_1555 = 3, + NUEGL_PIXELFORMAT_force_to_32_bits = 0x12345678 + } ePixelFormat; + enum + { + NUEGL_ROTATE_0 = 0, + NUEGL_ROTATE_90 = 1, + NUEGL_ROTATE_180 = 2, + NUEGL_ROTATE_270 = 3, + NUEGL_ROTATE_force_to_32_bits = 0x12345678 + } eRotation; +} sEGLNativePixmapType; +typedef sEGLNativePixmapType* EGLNativePixmapType; +#else + +/*! \var typedef void *EGLNativeDisplayType + \brief A type definition for EGLNativeDisplayType. +*/ +typedef void* EGLNativeDisplayType; + +/*! \var typedef void *EGLNativeWindowType + \brief A type definition for EGLNativeWindowType. +*/ +typedef void* EGLNativeWindowType; + +/*! \var typedef void *EGLNativePixmapType + \brief A type definition for EGLNativePixmapType. +*/ +typedef void* EGLNativePixmapType; +#endif + +/*! \var typedef EGLNativeDisplayType NativeDisplayType + \brief A type definition for NativeDisplayType. +*/ +typedef EGLNativeDisplayType NativeDisplayType; + +/*! \var typedef EGLNativePixmapType NativePixmapType + \brief A type definition for NativePixmapType. +*/ +typedef EGLNativePixmapType NativePixmapType; + +/*! \var typedef EGLNativeWindowType NativeWindowType + \brief A type definition for NativeWindowType. +*/ +typedef EGLNativeWindowType NativeWindowType; + +#include "egl_macro.h" + +/** + * @} + */ + +#endif /* __eglplatform_h_ */ diff --git a/inc/gl.h b/inc/gl.h new file mode 100644 index 0000000..b74e1b4 --- /dev/null +++ b/inc/gl.h @@ -0,0 +1,1530 @@ +/* $Change: 1028567 $ */ +#ifndef __gl_h_ +#define __gl_h_ + +/* $Revision: #1 $ on $Date: 2011/08/12 $ */ + +/** + * @file gl.h + * @brief This is the header file for the OpenGL(R) ES 1.1. + * + * This header file contains the declarations of the OpenGL(R) ES 1.1. + */ + +#include "glplatform.h" +#include "glmacro.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/** + * @addtogroup opengles + * + * @{ + */ + +/*------------------------------------------------------------------------- + * Data type definitions + *-----------------------------------------------------------------------*/ + +#if 0 // move to "khrplatform.h" +typedef void GLvoid; +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef khronos_int8_t GLbyte; +typedef short GLshort; +typedef int GLint; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef khronos_float_t GLfloat; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_int32_t GLclampx; + +typedef khronos_intptr_t GLintptr; +typedef khronos_ssize_t GLsizeiptr; +#endif + +/*************************************************************/ + +/* OpenGL ES core versions */ +#define GL_VERSION_ES_CM_1_0 1 +#define GL_VERSION_ES_CL_1_0 1 +#define GL_VERSION_ES_CM_1_1 1 +#define GL_VERSION_ES_CL_1_1 1 + +/* ClearBufferMask */ +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 + +/* Boolean */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* BeginMode */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 + +/* AlphaFunction */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 + +/* BlendingFactorDest */ +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 + +/* BlendingFactorSrc */ +/* GL_ZERO */ +/* GL_ONE */ +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +/* GL_SRC_ALPHA */ +/* GL_ONE_MINUS_SRC_ALPHA */ +/* GL_DST_ALPHA */ +/* GL_ONE_MINUS_DST_ALPHA */ + +/* ClipPlaneName */ +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 + +/* ColorMaterialFace */ +/* GL_FRONT_AND_BACK */ + +/* ColorMaterialParameter */ +/* GL_AMBIENT_AND_DIFFUSE */ + +/* ColorPointerType */ +/* GL_UNSIGNED_BYTE */ +/* GL_FLOAT */ +/* GL_FIXED */ + +/* CullFaceMode */ +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 + +/* DepthFunction */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* EnableCap */ +#define GL_FOG 0x0B60 +#define GL_LIGHTING 0x0B50 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_ALPHA_TEST 0x0BC0 +#define GL_BLEND 0x0BE2 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +/* GL_LIGHT0 */ +/* GL_LIGHT1 */ +/* GL_LIGHT2 */ +/* GL_LIGHT3 */ +/* GL_LIGHT4 */ +/* GL_LIGHT5 */ +/* GL_LIGHT6 */ +/* GL_LIGHT7 */ +#define GL_POINT_SMOOTH 0x0B10 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_NORMALIZE 0x0BA1 +#define GL_RESCALE_NORMAL 0x803A +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 + +/* ErrorCode */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 + +/* FogMode */ +/* GL_LINEAR */ +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 + +/* FogParameter */ +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_COLOR 0x0B66 + +/* FrontFaceDirection */ +#define GL_CW 0x0900 +#define GL_CCW 0x0901 + +/* GetPName */ +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_LINE_WIDTH 0x0B21 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_SHADE_MODEL 0x0B54 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_MATRIX_MODE 0x0BA0 +#define GL_VIEWPORT 0x0BA2 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_ALPHA_TEST_FUNC 0x0BC1 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB + +/* GetTextureParameter */ +/* GL_TEXTURE_MAG_FILTER */ +/* GL_TEXTURE_MIN_FILTER */ +/* GL_TEXTURE_WRAP_S */ +/* GL_TEXTURE_WRAP_T */ + +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 + +/* HintMode */ +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* HintTarget */ +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_FOG_HINT 0x0C54 +#define GL_GENERATE_MIPMAP_HINT 0x8192 + +/* LightModelParameter */ +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 + +/* LightParameter */ +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 + +/* DataType */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C + +/* LogicOp */ +#define GL_CLEAR 0x1500 +#define GL_AND 0x1501 +#define GL_AND_REVERSE 0x1502 +#define GL_COPY 0x1503 +#define GL_AND_INVERTED 0x1504 +#define GL_NOOP 0x1505 +#define GL_XOR 0x1506 +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_EQUIV 0x1509 +#define GL_INVERT 0x150A +#define GL_OR_REVERSE 0x150B +#define GL_COPY_INVERTED 0x150C +#define GL_OR_INVERTED 0x150D +#define GL_NAND 0x150E +#define GL_SET 0x150F + +/* MaterialFace */ +/* GL_FRONT_AND_BACK */ + +/* MaterialParameter */ +#define GL_EMISSION 0x1600 +#define GL_SHININESS 0x1601 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +/* GL_AMBIENT */ +/* GL_DIFFUSE */ +/* GL_SPECULAR */ + +/* MatrixMode */ +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 + +/* NormalPointerType */ +/* GL_BYTE */ +/* GL_SHORT */ +/* GL_FLOAT */ +/* GL_FIXED */ + +/* PixelFormat */ +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A + +/* PixelStoreParameter */ +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 + +/* PixelType */ +/* GL_UNSIGNED_BYTE */ +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 + +/* ShadingModel */ +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 + +/* StencilFunction */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* StencilOp */ +/* GL_ZERO */ +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +/* GL_INVERT */ + +/* StringName */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* TexCoordPointerType */ +/* GL_SHORT */ +/* GL_FLOAT */ +/* GL_FIXED */ +/* GL_BYTE */ + +/* TextureEnvMode */ +#define GL_MODULATE 0x2100 +#define GL_DECAL 0x2101 +/* GL_BLEND */ +#define GL_ADD 0x0104 +/* GL_REPLACE */ + +/* TextureEnvParameter */ +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_ENV_COLOR 0x2201 + +/* TextureEnvTarget */ +#define GL_TEXTURE_ENV 0x2300 + +/* TextureMagFilter */ +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 + +/* TextureMinFilter */ +/* GL_NEAREST */ +/* GL_LINEAR */ +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 + +/* TextureParameterName */ +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_GENERATE_MIPMAP 0x8191 + +/* TextureTarget */ +/* GL_TEXTURE_2D */ + +/* TextureUnit */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 + +/* TextureWrapMode */ +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F + +/* VertexPointerType */ +/* GL_SHORT */ +/* GL_FLOAT */ +/* GL_FIXED */ +/* GL_BYTE */ + +/* LightName */ +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 + +/* Buffer Objects */ +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 + +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A + +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 + +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 + +/* Texture combine + dot3 */ +#define GL_SUBTRACT 0x84E7 +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A + +#define GL_ALPHA_SCALE 0x0D1C + +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC1_ALPHA 0x8589 +#define GL_SRC2_ALPHA 0x858A + +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF + +/*------------------------------------------------------------------------* + * required OES extension tokens + *------------------------------------------------------------------------*/ + +/* OES_read_format */ +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +/* GL_OES_compressed_paletted_texture */ +#ifndef GL_OES_compressed_paletted_texture +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif + +/* OES_point_size_array */ +#ifndef GL_OES_point_size_array +#define GL_POINT_SIZE_ARRAY_OES 0x8B9C +#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A +#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B +#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C +#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F +#endif + +/* GL_OES_point_sprite */ +#ifndef GL_OES_point_sprite +#define GL_POINT_SPRITE_OES 0x8861 +#define GL_COORD_REPLACE_OES 0x8862 +#endif + +/*************************************************************/ + +/* Available only in Common profile */ +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glAlphaFunc(GLenum func, GLclampf ref); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glClearDepthf(GLclampf depth); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glClipPlanef(GLenum plane, const GLfloat* equation); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glFogf(GLenum pname, GLfloat param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glFogfv(GLenum pname, const GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glFrustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetClipPlanef(GLenum pname, GLfloat eqn[4]); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetLightfv(GLenum light, GLenum pname, GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetMaterialfv(GLenum face, GLenum pname, GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetTexEnvfv(GLenum env, GLenum pname, GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLightModelf(GLenum pname, GLfloat param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLightModelfv(GLenum pname, const GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLightf(GLenum light, GLenum pname, GLfloat param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLineWidth(GLfloat width); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLoadMatrixf(const GLfloat* m); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glMaterialf(GLenum face, GLenum pname, GLfloat param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glMaterialfv(GLenum face, GLenum pname, const GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glMultMatrixf(const GLfloat* m); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glPointParameterf(GLenum pname, GLfloat param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glPointParameterfv(GLenum pname, const GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glPointSize(GLfloat size); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexEnvf(GLenum target, GLenum pname, GLfloat param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexEnvfv(GLenum target, GLenum pname, const GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z); + +/* Available in both Common and Common-Lite profiles */ +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glActiveTexture(GLenum texture); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glAlphaFuncx(GLenum func, GLclampx ref); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glBindTexture(GLenum target, GLuint texture); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glClear(GLbitfield mask); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glClearDepthx(GLclampx depth); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glClearStencil(GLint s); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glClientActiveTexture(GLenum texture); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glClipPlanex(GLenum plane, const GLfixed* equation); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glColor4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glCullFace(GLenum mode); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glDepthFunc(GLenum func); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glDepthMask(GLboolean flag); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glDepthRangex(GLclampx zNear, GLclampx zFar); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glDisable(GLenum cap); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glDisableClientState(GLenum array); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glEnable(GLenum cap); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glEnableClientState(GLenum array); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glFinish(void); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glFlush(void); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glFogx(GLenum pname, GLfixed param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glFogxv(GLenum pname, const GLfixed* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glFrontFace(GLenum mode); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glFrustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetClipPlanex(GLenum pname, GLfixed eqn[4]); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API GLenum GL_APIENTRY glGetError(void); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetFixedv(GLenum pname, GLfixed* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetLightxv(GLenum light, GLenum pname, GLfixed* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetMaterialxv(GLenum face, GLenum pname, GLfixed* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetPointerv(GLenum pname, void** params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API const GLubyte* GL_APIENTRY glGetString(GLenum name); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetTexEnviv(GLenum env, GLenum pname, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetTexEnvxv(GLenum env, GLenum pname, GLfixed* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glGetTexParameterxv(GLenum target, GLenum pname, GLfixed* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glHint(GLenum target, GLenum mode); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API GLboolean GL_APIENTRY glIsBuffer(GLuint buffer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API GLboolean GL_APIENTRY glIsEnabled(GLenum cap); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API GLboolean GL_APIENTRY glIsTexture(GLuint texture); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLightModelx(GLenum pname, GLfixed param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLightModelxv(GLenum pname, const GLfixed* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLightx(GLenum light, GLenum pname, GLfixed param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLightxv(GLenum light, GLenum pname, const GLfixed* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLineWidthx(GLfixed width); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLoadIdentity(void); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLoadMatrixx(const GLfixed* m); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glLogicOp(GLenum opcode); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glMaterialx(GLenum face, GLenum pname, GLfixed param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glMaterialxv(GLenum face, GLenum pname, const GLfixed* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glMatrixMode(GLenum mode); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glMultMatrixx(const GLfixed* m); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glNormalPointer(GLenum type, GLsizei stride, const GLvoid* pointer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glPixelStorei(GLenum pname, GLint param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glPointParameterx(GLenum pname, GLfixed param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glPointParameterxv(GLenum pname, const GLfixed* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glPointSizex(GLfixed size); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glPolygonOffsetx(GLfixed factor, GLfixed units); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glPopMatrix(void); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glPushMatrix(void); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glSampleCoveragex(GLclampx value, GLboolean invert); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glScalex(GLfixed x, GLfixed y, GLfixed z); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glShadeModel(GLenum mode); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glStencilMask(GLuint mask); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexEnvi(GLenum target, GLenum pname, GLint param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexEnvx(GLenum target, GLenum pname, GLfixed param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexEnviv(GLenum target, GLenum pname, const GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexEnvxv(GLenum target, GLenum pname, const GLfixed* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexParameterx(GLenum target, GLenum pname, GLfixed param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexParameterxv(GLenum target, GLenum pname, const GLfixed* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glTranslatex(GLfixed x, GLfixed y, GLfixed z); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 1.1. + * + * @since 2.0 + */ +GL_API void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height); + +/*------------------------------------------------------------------------* + * Required OES extension functions + *------------------------------------------------------------------------*/ + +/* GL_OES_read_format */ +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +/* GL_OES_compressed_paletted_texture */ +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#endif + +/* GL_OES_point_size_array */ +#ifndef GL_OES_point_size_array +#define GL_OES_point_size_array 1 +/** + * @page EGLglPointSizePointerOES Compatibility for glPointSizePointerOES. + * @section CompClassNameMethodNamePageIssueSection Issues + * Implementation of this method in API versions prior to 1.2 has the following issue: @n + * + * -# This method does not work as expected in API versions prior to 1.2. + * + * @section CompClassNameMethodNamePageSolutionSection Resolutions + * The issue mentioned above is resolved in API version 1.1, and it is recommended to use API version 1.2 or above. +*/ +/** + * + * Defines an array of point sizes. + * You can find more details at the Khronos Group site: http://www.khronos.org/opengles/sdk/1.1/docs/man. + * + * @since 2.0 + * +*/ +GL_API void GL_APIENTRY glPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid* pointer); +#endif + +/* GL_OES_point_sprite */ +#ifndef GL_OES_point_sprite +#define GL_OES_point_sprite 1 +#endif + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __gl_h_ */ diff --git a/inc/gl2.h b/inc/gl2.h new file mode 100644 index 0000000..4a09cac --- /dev/null +++ b/inc/gl2.h @@ -0,0 +1,1354 @@ +/* $Change: 1028567 $ */ +#ifndef __gl2_h_ +#define __gl2_h_ + +/* $Revision: #1 $ on $Date: 2011/08/12 $ */ + +/** + * @file gl2.h + * @brief This is the header file for the OpenGL(R) ES 2.0. + * + * This header file contains the declarations of the OpenGL(R) ES 2.0. + */ + +#include "gl2platform.h" +#include "gl2macro.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/** + * @addtogroup opengles + * + * @{ + */ + +/*------------------------------------------------------------------------- + * Data type definitions + *-----------------------------------------------------------------------*/ + +#if 0 // move to "khrplatform.h" +typedef void GLvoid; +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef khronos_int8_t GLbyte; +typedef short GLshort; +typedef int GLint; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef khronos_float_t GLfloat; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; + +/* GL types for handling large vertex buffer objects */ +typedef khronos_intptr_t GLintptr; +typedef khronos_ssize_t GLsizeiptr; +#endif + +/* OpenGL ES core versions */ +#define GL_ES_VERSION_2_0 1 + +/* ClearBufferMask */ +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 + +/* Boolean */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* BeginMode */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 + +/* AlphaFunction (not supported in ES20) */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* BlendingFactorDest */ +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 + +/* BlendingFactorSrc */ +/* GL_ZERO */ +/* GL_ONE */ +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +/* GL_SRC_ALPHA */ +/* GL_ONE_MINUS_SRC_ALPHA */ +/* GL_DST_ALPHA */ +/* GL_ONE_MINUS_DST_ALPHA */ + +/* BlendEquationSeparate */ +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ +#define GL_BLEND_EQUATION_ALPHA 0x883D + +/* BlendSubtract */ +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B + +/* Separate Blend Functions */ +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 + +/* Buffer Objects */ +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 + +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 + +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 + +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 + +/* CullFaceMode */ +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 + +/* DepthFunction */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* EnableCap */ +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 + +/* ErrorCode */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 + +/* FrontFaceDirection */ +#define GL_CW 0x0900 +#define GL_CCW 0x0901 + +/* GetPName */ +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB + +/* GetTextureParameter */ +/* GL_TEXTURE_MAG_FILTER */ +/* GL_TEXTURE_MIN_FILTER */ +/* GL_TEXTURE_WRAP_S */ +/* GL_TEXTURE_WRAP_T */ + +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 + +/* HintMode */ +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* HintTarget */ +#define GL_GENERATE_MIPMAP_HINT 0x8192 + +/* DataType */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C + +/* PixelFormat */ +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A + +/* PixelType */ +/* GL_UNSIGNED_BYTE */ +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 + +/* Shaders */ +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D + +/* StencilFunction */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 + +/* StencilOp */ +/* GL_ZERO */ +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 + +/* StringName */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* TextureMagFilter */ +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 + +/* TextureMinFilter */ +/* GL_NEAREST */ +/* GL_LINEAR */ +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 + +/* TextureParameterName */ +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 + +/* TextureTarget */ +/* GL_TEXTURE_2D */ +#define GL_TEXTURE 0x1702 + +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C + +/* TextureUnit */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 + +/* TextureWrapMode */ +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 + +/* Uniform Types */ +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 + +/* Vertex Arrays */ +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F + +/* Read Format */ +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B + +/* Shader Source */ +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA + +/* Shader Binary */ +#define GL_PLATFORM_BINARY 0x8D63 +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 + +/* Shader Precision-Specified Types */ +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 + +/* Framebuffer Object. */ +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 + +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX 0x1901 +#define GL_STENCIL_INDEX8 0x8D48 + +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 + +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 + +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 + +#define GL_NONE 0 + +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS 0x8CDA +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD + +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 + +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 + +/*------------------------------------------------------------------------- + * GL core functions. + *-----------------------------------------------------------------------*/ + +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glActiveTexture(GLenum texture); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glAttachShader(GLuint program, GLuint shader); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const char* name); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glBindTexture(GLenum target, GLuint texture); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glBlendEquation(GLenum mode); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glClear(GLbitfield mask); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glClearDepthf(GLclampf depth); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glClearStencil(GLint s); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glCompileShader(GLuint shader); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL GLuint GL_APIENTRY glCreateProgram(void); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL GLuint GL_APIENTRY glCreateShader(GLenum type); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glCullFace(GLenum mode); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDeleteProgram(GLuint program); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDeleteShader(GLuint shader); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDepthFunc(GLenum func); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDepthMask(GLboolean flag); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDetachShader(GLuint program, GLuint shader); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDisable(GLenum cap); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray(GLuint index); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glEnable(GLenum cap); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray(GLuint index); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glFinish(void); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glFlush(void); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glFrontFace(GLenum mode); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGenerateMipmap(GLenum target); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL int GL_APIENTRY glGetAttribLocation(GLuint program, const char* name); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL GLenum GL_APIENTRY glGetError(void); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL const GLubyte* GL_APIENTRY glGetString(GLenum name); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL int GL_APIENTRY glGetUniformLocation(GLuint program, const char* name); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glHint(GLenum target, GLenum mode); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL GLboolean GL_APIENTRY glIsBuffer(GLuint buffer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL GLboolean GL_APIENTRY glIsEnabled(GLenum cap); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL GLboolean GL_APIENTRY glIsProgram(GLuint program); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL GLboolean GL_APIENTRY glIsShader(GLuint shader); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL GLboolean GL_APIENTRY glIsTexture(GLuint texture); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glLineWidth(GLfloat width); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glLinkProgram(GLuint program); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glPixelStorei(GLenum pname, GLint param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler(void); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glStencilMask(GLuint mask); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform1f(GLint location, GLfloat x); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform1i(GLint location, GLint x); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glUseProgram(GLuint program); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glValidateProgram(GLuint program); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glVertexAttrib1f(GLuint indx, GLfloat x); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glVertexAttrib1fv(GLuint indx, const GLfloat* values); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glVertexAttrib2fv(GLuint indx, const GLfloat* values); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glVertexAttrib3fv(GLuint indx, const GLfloat* values); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glVertexAttrib4fv(GLuint indx, const GLfloat* values); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr); +/** + * You can find more details at the Khronos Group site: Khronos Group site - OpenGL(R) ES 2.0. + * + * @since 2.0 + */ +GL_APICALL void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __gl2_h_ */ diff --git a/inc/gl2ext.h b/inc/gl2ext.h new file mode 100644 index 0000000..bddf955 --- /dev/null +++ b/inc/gl2ext.h @@ -0,0 +1,656 @@ +#ifndef __gl2ext_h_ +#define __gl2ext_h_ + +#include "gl2platform.h" + +#if defined(FEATURE_SAMSUNG_LSI) && !defined(_WIN32) +#include "GLES2/GL2_OGL2.h" +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY * +#endif + +#define GL_GLEXT_PROTOTYPES + +/*------------------------------------------------------------------------* + * OES extension tokens + *------------------------------------------------------------------------*/ + +/* GL_OES_compressed_ETC1_RGB8_texture */ +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_ETC1_RGB8_OES 0x8D64 +#endif + +/* GL_OES_compressed_paletted_texture */ +#ifndef GL_OES_compressed_paletted_texture +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif + +/* GL_OES_depth24 */ +#ifndef GL_OES_depth24 +#define GL_DEPTH_COMPONENT24_OES 0x81A6 +#endif + +/* GL_OES_depth32 */ +#ifndef GL_OES_depth32 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#endif + +/* GL_OES_depth_texture */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +typedef void* GLeglImageOES; +#endif + +/* GL_OES_get_program_binary */ +#ifndef GL_OES_get_program_binary +#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE +#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF +#endif + +/* GL_OES_mapbuffer */ +#ifndef GL_OES_mapbuffer +#define GL_WRITE_ONLY_OES 0x88B9 +#define GL_BUFFER_ACCESS_OES 0x88BB +#define GL_BUFFER_MAPPED_OES 0x88BC +#define GL_BUFFER_MAP_POINTER_OES 0x88BD +#endif + +/* GL_OES_packed_depth_stencil */ +#ifndef GL_OES_packed_depth_stencil +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif + +/* GL_OES_rgb8_rgba8 */ +#ifndef GL_OES_rgb8_rgba8 +#define GL_RGB8_OES 0x8051 +#define GL_RGBA8_OES 0x8058 +#endif + +/* GL_OES_standard_derivatives */ +#ifndef GL_OES_standard_derivatives +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B +#endif + +/* GL_OES_stencil1 */ +#ifndef GL_OES_stencil1 +#define GL_STENCIL_INDEX1_OES 0x8D46 +#endif + +/* GL_OES_stencil4 */ +#ifndef GL_OES_stencil4 +#define GL_STENCIL_INDEX4_OES 0x8D47 +#endif + +/* GL_OES_texture3D */ +#ifndef GL_OES_texture3D +#define GL_TEXTURE_WRAP_R_OES 0x8072 +#define GL_TEXTURE_3D_OES 0x806F +#define GL_TEXTURE_BINDING_3D_OES 0x806A +#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 +#define GL_SAMPLER_3D_OES 0x8B5F +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 +#endif + +/* GL_OES_texture_half_float */ +#ifndef GL_OES_texture_half_float +#define GL_HALF_FLOAT_OES 0x8D61 +#endif + +/* GL_OES_vertex_half_float */ +/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */ + +/* GL_OES_vertex_type_10_10_10_2 */ +#ifndef GL_OES_vertex_type_10_10_10_2 +#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 +#define GL_INT_10_10_10_2_OES 0x8DF7 +#endif + +/*------------------------------------------------------------------------* + * AMD extension tokens + *------------------------------------------------------------------------*/ + +/* GL_AMD_compressed_3DC_texture */ +#ifndef GL_AMD_compressed_3DC_texture +#define GL_3DC_X_AMD 0x87F9 +#define GL_3DC_XY_AMD 0x87FA +#endif + +/* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_compressed_ATC_texture +#define GL_ATC_RGB_AMD 0x8C92 +#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE +#endif + +/* GL_AMD_program_binary_Z400 */ +#ifndef GL_AMD_program_binary_Z400 +#define GL_Z400_BINARY_AMD 0x8740 +#endif + +/* GL_AMD_performance_monitor */ +#ifndef GL_AMD_performance_monitor +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +#endif + +/*------------------------------------------------------------------------* + * EXT extension tokens + *------------------------------------------------------------------------*/ + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +/* GL_EXT_texture_type_2_10_10_10_REV */ +#ifndef GL_EXT_texture_type_2_10_10_10_REV +#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 +#endif + +/* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_BGRA 0x80E1 +#endif + +/*------------------------------------------------------------------------* + * IMG extension tokens + *------------------------------------------------------------------------*/ + +/* GL_IMG_read_format */ +#ifndef GL_IMG_read_format +#define GL_BGRA 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#endif + +/* GL_IMG_texture_compression_pvrtc */ +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#endif + +/*------------------------------------------------------------------------* + * NV extension tokens + *------------------------------------------------------------------------*/ + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +/*------------------------------------------------------------------------* + * QCOM extension tokens + *------------------------------------------------------------------------*/ + +/* GL_QCOM_driver_control */ +/* No new tokens introduced by this extension. */ + +/* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_perfmon_global_mode +#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 +#endif + +/*------------------------------------------------------------------------* + * End of extension tokens, start of corresponding extension functions + *------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------* + * OES extension functions + *------------------------------------------------------------------------*/ + +/* GL_OES_compressed_ETC1_RGB8_texture */ +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_OES_compressed_ETC1_RGB8_texture 1 +#endif + +/* GL_OES_compressed_paletted_texture */ +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#endif + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image); +GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image); +#endif +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)(GLenum target, GLeglImageOES image); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC)(GLenum target, GLeglImageOES image); +#endif + +/* GL_OES_depth24 */ +#ifndef GL_OES_depth24 +#define GL_OES_depth24 1 +#endif + +/* GL_OES_depth32 */ +#ifndef GL_OES_depth32 +#define GL_OES_depth32 1 +#endif + +/* GL_OES_depth_texture */ +#ifndef GL_OES_depth_texture +#define GL_OES_depth_texture 1 +#endif + +/* GL_OES_element_index_uint */ +#ifndef GL_OES_element_index_uint +#define GL_OES_element_index_uint 1 +#endif + +/* GL_OES_fbo_render_mipmap */ +#ifndef GL_OES_fbo_render_mipmap +#define GL_OES_fbo_render_mipmap 1 +#endif + +/* GL_OES_fragment_precision_high */ +#ifndef GL_OES_fragment_precision_high +#define GL_OES_fragment_precision_high 1 +#endif + +/* GL_OES_get_program_binary */ +#ifndef GL_OES_get_program_binary +#define GL_OES_get_program_binary 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, void* binary); +GL_APICALL void GL_APIENTRY glProgramBinaryOES(GLuint program, GLenum binaryFormat, const void* binary, GLint length); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC)(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, + void* binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC)(GLuint program, GLenum binaryFormat, const void* binary, GLint length); +#endif + +/* GL_OES_mapbuffer */ +#ifndef GL_OES_mapbuffer +#define GL_OES_mapbuffer 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void* GL_APIENTRY glMapBufferOES(GLenum target, GLenum access); +GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, void** params); +#endif +#endif // not supported +typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC)(GLenum target, GLenum access); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC)(GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC)(GLenum target, GLenum pname, void** params); +#endif + +/* GL_OES_packed_depth_stencil */ +#ifndef GL_OES_packed_depth_stencil +#define GL_OES_packed_depth_stencil 1 +#endif + +/* GL_OES_rgb8_rgba8 */ +#ifndef GL_OES_rgb8_rgba8 +#define GL_OES_rgb8_rgba8 1 +#endif + +/* GL_OES_standard_derivatives */ +#ifndef GL_OES_standard_derivatives +#define GL_OES_standard_derivatives 1 +#endif + +/* GL_OES_stencil1 */ +#ifndef GL_OES_stencil1 +#define GL_OES_stencil1 1 +#endif + +/* GL_OES_stencil4 */ +#ifndef GL_OES_stencil4 +#define GL_OES_stencil4 1 +#endif + +/* GL_OES_texture_3D */ +#ifndef GL_OES_texture_3D +#define GL_OES_texture_3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); +GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#endif +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, + const GLvoid* pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, + const void* pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, + const void* data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, const void* data); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level, GLint zoffset); +#endif + +/* GL_OES_texture_float_linear */ +#ifndef GL_OES_texture_float_linear +#define GL_OES_texture_float_linear 1 +#endif + +/* GL_OES_texture_half_float_linear */ +#ifndef GL_OES_texture_half_float_linear +#define GL_OES_texture_half_float_linear 1 +#endif + +/* GL_OES_texture_float */ +#ifndef GL_OES_texture_float +#define GL_OES_texture_float 1 +#endif + +/* GL_OES_texture_half_float */ +#ifndef GL_OES_texture_half_float +#define GL_OES_texture_half_float 1 +#endif + +/* GL_OES_texture_npot */ +#ifndef GL_OES_texture_npot +#define GL_OES_texture_npot 1 +#endif + +/* GL_OES_vertex_half_float */ +#ifndef GL_OES_vertex_half_float +#define GL_OES_vertex_half_float 1 +#endif + +/* GL_OES_vertex_type_10_10_10_2 */ +#ifndef GL_OES_vertex_type_10_10_10_2 +#define GL_OES_vertex_type_10_10_10_2 1 +#endif + +/*------------------------------------------------------------------------* + * AMD extension functions + *------------------------------------------------------------------------*/ + +/* GL_AMD_compressed_3DC_texture */ +#ifndef GL_AMD_compressed_3DC_texture +#define GL_AMD_compressed_3DC_texture 1 +#endif + +/* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_compressed_ATC_texture +#define GL_AMD_compressed_ATC_texture 1 +#endif + +/* GL_AMD_program_binary_Z400 */ +#ifndef GL_AMD_program_binary_Z400 +#define GL_AMD_program_binary_Z400 1 +#endif + +/* AMD_performance_monitor */ +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD(GLint* numGroups, GLsizei groupsSize, GLuint* groups); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD(GLuint group, GLint* numCounters, GLint* maxActiveCounters, GLsizei counterSize, GLuint* counters); +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei* length, char* groupString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, char* counterString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, void* data); +GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD(GLsizei n, GLuint* monitors); +GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD(GLsizei n, GLuint* monitors); +GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* countersList); +GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD(GLuint monitor); +GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD(GLuint monitor); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint* bytesWritten); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC)(GLint* numGroups, GLsizei groupsSize, GLuint* groups); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC)(GLuint group, GLint* numCounters, GLint* maxActiveCounters, + GLsizei counterSize, GLuint* counters); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC)(GLuint group, GLsizei bufSize, GLsizei* length, + char* groupString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC)(GLuint group, GLuint counter, GLsizei bufSize, + GLsizei* length, char* counterString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC)(GLuint group, GLuint counter, GLenum pname, void* data); +typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC)(GLsizei n, GLuint* monitors); +typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC)(GLsizei n, GLuint* monitors); +typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC)(GLuint monitor, GLboolean enable, GLuint group, + GLint numCounters, GLuint* countersList); +typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC)(GLuint monitor); +typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC)(GLuint monitor); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC)(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, + GLint* bytesWritten); +#endif + +/*------------------------------------------------------------------------* + * EXT extension functions + *------------------------------------------------------------------------*/ + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +/* GL_EXT_texture_type_2_10_10_10_REV */ +#ifndef GL_EXT_texture_type_2_10_10_10_REV +#define GL_EXT_texture_type_2_10_10_10_REV 1 +#endif + +/* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_EXT_texture_format_BGRA8888 1 +#endif + +/*------------------------------------------------------------------------* + * IMG extension functions + *------------------------------------------------------------------------*/ + +/* GL_IMG_read_format */ +#ifndef GL_IMG_read_format +#define GL_IMG_read_format 1 +#endif + +/* GL_IMG_texture_compression_pvrtc */ +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_IMG_texture_compression_pvrtc 1 +#endif + +/*------------------------------------------------------------------------* + * NV extension functions + *------------------------------------------------------------------------*/ + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDeleteFencesNV(GLsizei, const GLuint*); +GL_APICALL void GL_APIENTRY glGenFencesNV(GLsizei, GLuint*); +GL_APICALL GLboolean GL_APIENTRY glIsFenceNV(GLuint); +GL_APICALL GLboolean GL_APIENTRY glTestFenceNV(GLuint); +GL_APICALL void GL_APIENTRY glGetFenceivNV(GLuint, GLenum, GLint*); +GL_APICALL void GL_APIENTRY glFinishFenceNV(GLuint); +GL_APICALL void GL_APIENTRY glSetFenceNV(GLuint, GLenum); +#endif +typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC)(GLsizei n, const GLuint* fences); +typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC)(GLsizei n, GLuint* fences); +typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC)(GLuint fence); +typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC)(GLuint fence); +typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC)(GLuint fence, GLenum pname, GLint* params); +typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC)(GLuint fence); +typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC)(GLuint fence, GLenum condition); +#endif + +/*------------------------------------------------------------------------* + * QCOM extension functions + *------------------------------------------------------------------------*/ + +/* GL_QCOM_driver_control */ +#ifndef GL_QCOM_driver_control +#define GL_QCOM_driver_control 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM(GLint* num, GLsizei size, GLuint* driverControls); +GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei* length, char* driverControlString); +GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM(GLuint driverControl); +GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM(GLuint driverControl); +#endif +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC)(GLint* num, GLsizei size, GLuint* driverControls); +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC)(GLuint driverControl, GLsizei bufSize, GLsizei* length, + char* driverControlString); +typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC)(GLuint driverControl); +typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC)(GLuint driverControl); +#endif + +/* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_perfmon_global_mode +#define GL_QCOM_perfmon_global_mode 1 +#endif + +/*------------------------------------------------------------------------* + * Samsung extension functions + *------------------------------------------------------------------------*/ + +#define GL_BGRA 0x80E1 + +/* Binary Shader(C110) */ +#define GL_S5PC110_BINARY_SHADER 0x8C0A + +/* ErrorCode */ +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 + +/* Get PName */ +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_MAX_TEXTURE_UNITS 0x84E2 + +//sanvd added this extension for supporting s3tc +//OES_texture_compression_S3TC +#define GL_RGB_S3TC_OES 0x83F0 +#define GL_RGBA_S3TC_OES 0x83F1 + +/* PointSize */ +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 + +GL_APICALL void GL_APIENTRY glPointSize(GLfloat size); + + +/* EN_EXT */ +#define EN_EXT_ALPHA_TEST_EXP +#define EN_EXT_VARYING_INTERPOLATION_EXP +#define EN_EXT_LOGIC_OP_EXP +#define EN_EXT_POINT_SPRITE_EXP + +#ifdef EN_EXT_ALPHA_TEST_EXP +#define GL_ALPHA_TEST_EXP 0x0BC0 +#define GL_ALPHA_TEST_FUNC_EXP 0x0BC1 +#define GL_ALPHA_TEST_REF_EXP 0x0BC2 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glAlphaFuncEXP(GLenum func, GLclampf ref); +#else +typedef void (GL_APIENTRYP PFNGLALPHAFUNCPROC)(GLenum func, GLclampf ref); +#endif +#endif //EN_EXT_ALPHA_TEST_EXP + +#ifdef EN_EXT_VARYING_INTERPOLATION_EXP +#define GL_FLAT_EXP 0x1D00 +#define GL_SMOOTH_EXP 0x1D01 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glVaryingInterpolationEXP(const char* name, GLenum mode); +GL_APICALL void GL_APIENTRY glGetVaryingInterpolationEXP(const char* name, GLint* params); +#else +typedef void (GL_APIENTRYP PFNGLVARYINGINTERPOLATIONPROC)(const char* name, GLenum mode); +typedef void (GL_APIENTRYP PFNGLGETVARYINGINTERPOLATIONPROC)(const char* name, GLint* params); +#endif +#endif //EN_EXT_VARYING_INTERPOLATION_EXP + +#ifdef EN_EXT_LOGIC_OP_EXP +#define GL_LOGIC_OP_MODE_EXP 0x0BF0 +#define GL_COLOR_LOGIC_OP_EXP 0x0BF2 +#define GL_CLEAR_EXP 0x1500 +#define GL_AND_EXP 0x1501 +#define GL_AND_REVERSE_EXP 0x1502 +#define GL_COPY_EXP 0x1503 +#define GL_AND_INVERTED_EXP 0x1504 +#define GL_NOOP_EXP 0x1505 +#define GL_XOR_EXP 0x1506 +#define GL_OR_EXP 0x1507 +#define GL_NOR_EXP 0x1508 +#define GL_EQUIV_EXP 0x1509 +#define GL_INVERT_EXP 0x150A +#define GL_OR_REVERSE_EXP 0x150B +#define GL_COPY_INVERTED_EXP 0x150C +#define GL_OR_INVERTED_EXP 0x150D +#define GL_NAND_EXP 0x150E +#define GL_SET_EXP 0x150F +#endif //EN_EXT_LOGIC_OP_EXP + +#ifdef EN_EXT_ALPHA_TEST_EXP +#define GL_ALPHA_TEST_EXP 0x0BC0 +#define GL_ALPHA_TEST_FUNC_EXP 0x0BC1 +#define GL_ALPHA_TEST_REF_EXP 0x0BC2 +#endif //EN_EXT_ALPHA_TEST_EXP + +#ifdef EN_EXT_POINT_SPRITE_EXP +#define GL_POINT_SPRITE_OES_EXP 0x8861 +#endif + +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glLogicOpEXP(GLenum op); +#else +typedef void (GL_APIENTRYP PFNGLLOGICOPPROC)(GLenum op); +#endif + +/* zepplin 2008.05.08 added */ +GL_APICALL void GL_APIENTRY glDrawArraysWrap(GLenum mode, GLint first, GLsizei count, GLint MatPos, const GLfloat* Matdt, /*GLsizei MatSize, GLboolean MatBool,*/ + GLint BoolPos, GLint Boolptr, GLuint shaderNum, void* shaderStr); +GL_APICALL void GL_APIENTRY glDrawElementsWrap(GLenum mode, GLsizei count, GLenum type, const void* indices, GLint MatPos, const GLfloat* Matdt, /*GLsizei MatSize, GLboolean MatBool,*/ + GLint BoolPos, GLint Boolptr, GLuint shaderNum, void* shaderStr); + + +#ifdef CHIP_VERIFY_ACTIVATE +GL_APICALL GLuint GL_APIENTRY glChipVerification(GLuint key); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __gl2ext_h_ */ diff --git a/inc/gl2macro.h b/inc/gl2macro.h new file mode 100644 index 0000000..0ba3a9b --- /dev/null +++ b/inc/gl2macro.h @@ -0,0 +1,164 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _GL2_MACRO_H_ +#define _GL2_MACRO_H_ + +#define glActiveTexture _GlActiveTexture_2 +#define glAttachShader _GlAttachShader_2 +#define glBindAttribLocation _GlBindAttribLocation_2 +#define glBindBuffer _GlBindBuffer_2 +#define glBindFramebuffer _GlBindFramebuffer_2 +#define glBindRenderbuffer _GlBindRenderbuffer_2 +#define glBindTexture _GlBindTexture_2 +#define glBlendColor _GlBlendColor_2 +#define glBlendEquation _GlBlendEquation_2 +#define glBlendEquationSeparate _GlBlendEquationSeparate_2 +#define glBlendFunc _GlBlendFunc_2 +#define glBlendFuncSeparate _GlBlendFuncSeparate_2 +#define glBufferData _GlBufferData_2 +#define glBufferSubData _GlBufferSubData_2 +#define glCheckFramebufferStatus _GlCheckFramebufferStatus_2 +#define glClear _GlClear_2 +#define glClearColor _GlClearColor_2 +#define glClearDepthf _GlClearDepthf_2 +#define glClearStencil _GlClearStencil_2 +#define glColorMask _GlColorMask_2 +#define glCompileShader _GlCompileShader_2 +#define glCompressedTexImage2D _GlCompressedTexImage2D_2 +#define glCompressedTexSubImage2D _GlCompressedTexSubImage2D_2 +#define glCopyTexImage2D _GlCopyTexImage2D_2 +#define glCopyTexSubImage2D _GlCopyTexSubImage2D_2 +#define glCreateProgram _GlCreateProgram_2 +#define glCreateShader _GlCreateShader_2 +#define glCullFace _GlCullFace_2 +#define glDeleteBuffers _GlDeleteBuffers_2 +#define glDeleteFramebuffers _GlDeleteFramebuffers_2 +#define glDeleteProgram _GlDeleteProgram_2 +#define glDeleteRenderbuffers _GlDeleteRenderbuffers_2 +#define glDeleteShader _GlDeleteShader_2 +#define glDeleteTextures _GlDeleteTextures_2 +#define glDepthFunc _GlDepthFunc_2 +#define glDepthMask _GlDepthMask_2 +#define glDepthRangef _GlDepthRangef_2 +#define glDetachShader _GlDetachShader_2 +#define glDisable _GlDisable_2 +#define glDisableVertexAttribArray _GlDisableVertexAttribArray_2 +#define glDrawArrays _GlDrawArrays_2 +#define glDrawElements _GlDrawElements_2 +#define glEnable _GlEnable_2 +#define glEnableVertexAttribArray _GlEnableVertexAttribArray_2 +#define glFinish _GlFinish_2 +#define glFlush _GlFlush_2 +#define glFramebufferRenderbuffer _GlFramebufferRenderbuffer_2 +#define glFramebufferTexture2D _GlFramebufferTexture2D_2 +#define glFrontFace _GlFrontFace_2 +#define glGenBuffers _GlGenBuffers_2 +#define glGenerateMipmap _GlGenerateMipmap_2 +#define glGenFramebuffers _GlGenFramebuffers_2 +#define glGenRenderbuffers _GlGenRenderbuffers_2 +#define glGenTextures _GlGenTextures_2 +#define glGetActiveAttrib _GlGetActiveAttrib_2 +#define glGetActiveUniform _GlGetActiveUniform_2 +#define glGetAttachedShaders _GlGetAttachedShaders_2 +#define glGetAttribLocation _GlGetAttribLocation_2 +#define glGetBooleanv _GlGetBooleanv_2 +#define glGetBufferParameteriv _GlGetBufferParameteriv_2 +#define glGetError _GlGetError_2 +#define glGetFloatv _GlGetFloatv_2 +#define glGetFramebufferAttachmentParameteriv _GlGetFramebufferAttachmentParameteriv_2 +#define glGetIntegerv _GlGetIntegerv_2 +#define glGetProgramiv _GlGetProgramiv_2 +#define glGetProgramInfoLog _GlGetProgramInfoLog_2 +#define glGetRenderbufferParameteriv _GlGetRenderbufferParameteriv_2 +#define glGetShaderiv _GlGetShaderiv_2 +#define glGetShaderInfoLog _GlGetShaderInfoLog_2 +#define glGetShaderPrecisionFormat _GlGetShaderPrecisionFormat_2 +#define glGetShaderSource _GlGetShaderSource_2 +#define glGetString _GlGetString_2 +#define glGetTexParameterfv _GlGetTexParameterfv_2 +#define glGetTexParameteriv _GlGetTexParameteriv_2 +#define glGetUniformfv _GlGetUniformfv_2 +#define glGetUniformiv _GlGetUniformiv_2 +#define glGetUniformLocation _GlGetUniformLocation_2 +#define glGetVertexAttribfv _GlGetVertexAttribfv_2 +#define glGetVertexAttribiv _GlGetVertexAttribiv_2 +#define glGetVertexAttribPointerv _GlGetVertexAttribPointerv_2 +#define glHint _GlHint_2 +#define glIsBuffer _GlIsBuffer_2 +#define glIsEnabled _GlIsEnabled_2 +#define glIsFramebuffer _GlIsFramebuffer_2 +#define glIsProgram _GlIsProgram_2 +#define glIsRenderbuffer _GlIsRenderbuffer_2 +#define glIsShader _GlIsShader_2 +#define glIsTexture _GlIsTexture_2 +#define glLineWidth _GlLineWidth_2 +#define glLinkProgram _GlLinkProgram_2 +#define glPixelStorei _GlPixelStorei_2 +#define glPolygonOffset _GlPolygonOffset_2 +#define glReadPixels _GlReadPixels_2 +#define glReleaseShaderCompiler _GlReleaseShaderCompiler_2 +#define glRenderbufferStorage _GlRenderbufferStorage_2 +#define glSampleCoverage _GlSampleCoverage_2 +#define glScissor _GlScissor_2 +#define glShaderBinary _GlShaderBinary_2 +#define glShaderSource _GlShaderSource_2 +#define glStencilFunc _GlStencilFunc_2 +#define glStencilFuncSeparate _GlStencilFuncSeparate_2 +#define glStencilMask _GlStencilMask_2 +#define glStencilMaskSeparate _GlStencilMaskSeparate_2 +#define glStencilOp _GlStencilOp_2 +#define glStencilOpSeparate _GlStencilOpSeparate_2 +#define glTexImage2D _GlTexImage2D_2 +#define glTexParameterf _GlTexParameterf_2 +#define glTexParameterfv _GlTexParameterfv_2 +#define glTexParameteri _GlTexParameteri_2 +#define glTexParameteriv _GlTexParameteriv_2 +#define glTexSubImage2D _GlTexSubImage2D_2 +#define glUniform1i _GlUniform1i_2 +#define glUniform2i _GlUniform2i_2 +#define glUniform3i _GlUniform3i_2 +#define glUniform4i _GlUniform4i_2 +#define glUniform1f _GlUniform1f_2 +#define glUniform2f _GlUniform2f_2 +#define glUniform3f _GlUniform3f_2 +#define glUniform4f _GlUniform4f_2 +#define glUniform1iv _GlUniform1iv_2 +#define glUniform2iv _GlUniform2iv_2 +#define glUniform3iv _GlUniform3iv_2 +#define glUniform4iv _GlUniform4iv_2 +#define glUniform1fv _GlUniform1fv_2 +#define glUniform2fv _GlUniform2fv_2 +#define glUniform3fv _GlUniform3fv_2 +#define glUniform4fv _GlUniform4fv_2 +#define glUniformMatrix2fv _GlUniformMatrix2fv_2 +#define glUniformMatrix3fv _GlUniformMatrix3fv_2 +#define glUniformMatrix4fv _GlUniformMatrix4fv_2 +#define glUseProgram _GlUseProgram_2 +#define glValidateProgram _GlValidateProgram_2 +#define glVertexAttrib1f _GlVertexAttrib1f_2 +#define glVertexAttrib2f _GlVertexAttrib2f_2 +#define glVertexAttrib3f _GlVertexAttrib3f_2 +#define glVertexAttrib4f _GlVertexAttrib4f_2 +#define glVertexAttrib1fv _GlVertexAttrib1fv_2 +#define glVertexAttrib2fv _GlVertexAttrib2fv_2 +#define glVertexAttrib3fv _GlVertexAttrib3fv_2 +#define glVertexAttrib4fv _GlVertexAttrib4fv_2 +#define glVertexAttribPointer _GlVertexAttribPointer_2 +#define glViewport _GlViewport_2 + +#endif // _GL2_MACRO_H_ diff --git a/inc/gl2platform.h b/inc/gl2platform.h new file mode 100644 index 0000000..84ecbb6 --- /dev/null +++ b/inc/gl2platform.h @@ -0,0 +1,28 @@ +#ifndef __gl2platform_h_ +#define __gl2platform_h_ + + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h + * Last modified on 2008/12/19 + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) + * by filing a bug against product "OpenGL-ES" component "Registry". + */ + +#include "khrplatform.h" + +#ifndef GL_APICALL +#define GL_APICALL KHRONOS_APICALL +#endif + +#define GL_APIENTRY //KHRONOS_APIENTRY + +#endif /* __gl2platform_h_ */ diff --git a/inc/glext.h b/inc/glext.h new file mode 100644 index 0000000..20fb4dd --- /dev/null +++ b/inc/glext.h @@ -0,0 +1,899 @@ +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY * +#endif + +#define GL_GLEXT_PROTOTYPES + +/*------------------------------------------------------------------------* + * OES extension tokens + *------------------------------------------------------------------------*/ + +/* GL_OES_blend_equation_separate */ +#ifndef GL_OES_blend_equation_separate +/* BLEND_EQUATION_RGB_OES same as BLEND_EQUATION_OES */ +#define GL_BLEND_EQUATION_RGB_OES 0x8009 +#define GL_BLEND_EQUATION_ALPHA_OES 0x883D +#endif + +/* GL_OES_blend_func_separate */ +#ifndef GL_OES_blend_func_separate +#define GL_BLEND_DST_RGB_OES 0x80C8 +#define GL_BLEND_SRC_RGB_OES 0x80C9 +#define GL_BLEND_DST_ALPHA_OES 0x80CA +#define GL_BLEND_SRC_ALPHA_OES 0x80CB +#endif + +/* GL_OES_blend_subtract */ +#ifndef GL_OES_blend_subtract +#define GL_BLEND_EQUATION_OES 0x8009 +#define GL_FUNC_ADD_OES 0x8006 +#define GL_FUNC_SUBTRACT_OES 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_OES 0x800B +#endif + +/* GL_OES_compressed_ETC1_RGB8_texture */ +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_ETC1_RGB8_OES 0x8D64 +#endif + +/* GL_OES_depth24 */ +#ifndef GL_OES_depth24 +#define GL_DEPTH_COMPONENT24_OES 0x81A6 +#endif + +/* GL_OES_depth32 */ +#ifndef GL_OES_depth32 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#endif + +/* GL_OES_draw_texture */ +#ifndef GL_OES_draw_texture +#define GL_TEXTURE_CROP_RECT_OES 0x8B9D +#endif + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +typedef void* GLeglImageOES; +#endif + +/* GL_OES_fixed_point */ +#ifndef GL_OES_fixed_point +#define GL_FIXED_OES 0x140C +#endif + +/* GL_OES_framebuffer_object */ +#ifndef GL_OES_framebuffer_object +#define GL_NONE_OES 0 +#define GL_FRAMEBUFFER_OES 0x8D40 +#define GL_RENDERBUFFER_OES 0x8D41 +#define GL_RGBA4_OES 0x8056 +#define GL_RGB5_A1_OES 0x8057 +#define GL_RGB565_OES 0x8D62 +#define GL_DEPTH_COMPONENT16_OES 0x81A5 +#define GL_RENDERBUFFER_WIDTH_OES 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_OES 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_OES 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE_OES 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_OES 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_OES 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_OES 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_OES 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_OES 0x8D55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES 0x8CD3 +#define GL_COLOR_ATTACHMENT0_OES 0x8CE0 +#define GL_DEPTH_ATTACHMENT_OES 0x8D00 +#define GL_STENCIL_ATTACHMENT_OES 0x8D20 +#define GL_FRAMEBUFFER_COMPLETE_OES 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES 0x8CDA +#define GL_FRAMEBUFFER_UNSUPPORTED_OES 0x8CDD +#define GL_FRAMEBUFFER_BINDING_OES 0x8CA6 +#define GL_RENDERBUFFER_BINDING_OES 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE_OES 0x84E8 +#define GL_INVALID_FRAMEBUFFER_OPERATION_OES 0x0506 +#endif + +/* GL_OES_mapbuffer */ +#ifndef GL_OES_mapbuffer +#define GL_WRITE_ONLY_OES 0x88B9 +#define GL_BUFFER_ACCESS_OES 0x88BB +#define GL_BUFFER_MAPPED_OES 0x88BC +#define GL_BUFFER_MAP_POINTER_OES 0x88BD +#endif + +/* GL_OES_matrix_get */ +#ifndef GL_OES_matrix_get +#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D +#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E +#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F +#endif + +/* GL_OES_matrix_palette */ +#ifndef _WIN32 // _WIN32 +#ifndef GL_OES_matrix_palette +#define GL_MAX_VERTEX_UNITS_OES 0x86A4 +#define GL_MAX_PALETTE_MATRICES_OES 0x8842 +#define GL_MATRIX_PALETTE_OES 0x8840 +#define GL_MATRIX_INDEX_ARRAY_OES 0x8844 +#define GL_WEIGHT_ARRAY_OES 0x86AD +#define GL_CURRENT_PALETTE_MATRIX_OES 0x8843 +#define GL_MATRIX_INDEX_ARRAY_SIZE_OES 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_OES 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_OES 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_OES 0x8849 +#define GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES 0x8B9E +#define GL_WEIGHT_ARRAY_SIZE_OES 0x86AB +#define GL_WEIGHT_ARRAY_TYPE_OES 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_OES 0x86AA +#define GL_WEIGHT_ARRAY_POINTER_OES 0x86AC +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_OES 0x889E +#endif +#endif //_WIN32 + +/* GL_OES_packed_depth_stencil */ +#ifndef GL_OES_packed_depth_stencil +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif + +/* GL_OES_rgb8_rgba8 */ +#ifndef GL_OES_rgb8_rgba8 +#define GL_RGB8_OES 0x8051 +#define GL_RGBA8_OES 0x8058 +#endif + +/* GL_OES_stencil1 */ +#ifndef GL_OES_stencil1 +#define GL_STENCIL_INDEX1_OES 0x8D46 +#endif + +/* GL_OES_stencil4 */ +#ifndef GL_OES_stencil4 +#define GL_STENCIL_INDEX4_OES 0x8D47 +#endif + +/* GL_OES_stencil8 */ +#ifndef GL_OES_stencil8 +#define GL_STENCIL_INDEX8_OES 0x8D48 +#endif + +/* GL_OES_stencil_wrap */ +#ifndef GL_OES_stencil_wrap +#define GL_INCR_WRAP_OES 0x8507 +#define GL_DECR_WRAP_OES 0x8508 +#endif + +/* GL_OES_texture_cube_map */ +#ifndef GL_OES_texture_cube_map +#define GL_NORMAL_MAP_OES 0x8511 +#define GL_REFLECTION_MAP_OES 0x8512 +#define GL_TEXTURE_CUBE_MAP_OES 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_OES 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES 0x851C +#define GL_TEXTURE_GEN_MODE_OES 0x2500 +#define GL_TEXTURE_GEN_STR_OES 0x8D60 +#endif + +/* GL_OES_texture_mirrored_repeat */ +#ifndef GL_OES_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_OES 0x8370 +#endif + +/*------------------------------------------------------------------------* + * AMD extension tokens + *------------------------------------------------------------------------*/ + +/* GL_AMD_compressed_3DC_texture */ +#ifndef GL_AMD_compressed_3DC_texture +#define GL_3DC_X_AMD 0x87F9 +#define GL_3DC_XY_AMD 0x87FA +#endif + +/* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_compressed_ATC_texture +#define GL_ATC_RGB_AMD 0x8C92 +#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE +#endif + +/*------------------------------------------------------------------------* + * EXT extension tokens + *------------------------------------------------------------------------*/ + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +/* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_BGRA 0x80E1 +#endif + +/*------------------------------------------------------------------------* + * IMG extension tokens + *------------------------------------------------------------------------*/ + +/* GL_IMG_read_format */ +#ifndef GL_IMG_read_format +#define GL_BGRA 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#endif + +/* GL_IMG_texture_compression_pvrtc */ +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#endif + +/* GL_IMG_user_clip_plane */ +#ifndef GL_IMG_user_clip_plane +#define GL_CLIP_PLANE0_IMG 0x3000 +#define GL_CLIP_PLANE1_IMG 0x3001 +#define GL_CLIP_PLANE2_IMG 0x3002 +#define GL_CLIP_PLANE3_IMG 0x3003 +#define GL_CLIP_PLANE4_IMG 0x3004 +#define GL_CLIP_PLANE5_IMG 0x3005 +#define GL_MAX_CLIP_PLANES_IMG 0x0D32 +#endif + +/* GL_IMG_texture_env_enhanced_fixed_function */ +#ifndef GL_IMG_texture_env_enhanced_fixed_function +#define GL_MODULATE_COLOR_IMG 0x8C04 +#define GL_RECIP_ADD_SIGNED_ALPHA_IMG 0x8C05 +#define GL_TEXTURE_ALPHA_MODULATE_IMG 0x8C06 +#define GL_FACTOR_ALPHA_MODULATE_IMG 0x8C07 +#define GL_FRAGMENT_ALPHA_MODULATE_IMG 0x8C08 +#define GL_ADD_BLEND_IMG 0x8C09 +#define GL_DOT3_RGBA_IMG 0x86AF +#endif + +/*------------------------------------------------------------------------* + * NV extension tokens + *------------------------------------------------------------------------*/ + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +/*------------------------------------------------------------------------* + * QCOM extension tokens + *------------------------------------------------------------------------*/ + +/* GL_QCOM_driver_control */ +/* No new tokens introduced by this extension. */ + +/* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_perfmon_global_mode +#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 +#endif + +/*------------------------------------------------------------------------* + * End of extension tokens, start of corresponding extension functions + *------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------* + * OES extension functions + *------------------------------------------------------------------------*/ + +/* GL_OES_blend_equation_separate */ +#ifndef GL_OES_blend_equation_separate +#define GL_OES_blend_equation_separate 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glBlendEquationSeparateOES(GLenum modeRGB, GLenum modeAlpha); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEOESPROC)(GLenum modeRGB, GLenum modeAlpha); +#endif + +/* GL_OES_blend_func_separate */ +#ifndef GL_OES_blend_func_separate +#define GL_OES_blend_func_separate 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glBlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEOESPROC)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +/* GL_OES_blend_subtract */ +#ifndef GL_OES_blend_subtract +#define GL_OES_blend_subtract 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glBlendEquationOES(GLenum mode); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONOESPROC)(GLenum mode); +#endif + +/* GL_OES_byte_coordinates */ +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +#endif + +/* GL_OES_compressed_ETC1_RGB8_texture */ +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_OES_compressed_ETC1_RGB8_texture 1 +#endif + +/* GL_OES_depth24 */ +#ifndef GL_OES_depth24 +#define GL_OES_depth24 1 +#endif + +/* GL_OES_depth32 */ +#ifndef GL_OES_depth32 +#define GL_OES_depth32 1 +#endif + +/* GL_OES_draw_texture */ +#ifndef GL_OES_draw_texture +#define GL_OES_draw_texture 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); +GL_API void GL_APIENTRY glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height); +GL_API void GL_APIENTRY glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); +GL_API void GL_APIENTRY glDrawTexsvOES(const GLshort* coords); +GL_API void GL_APIENTRY glDrawTexivOES(const GLint* coords); +GL_API void GL_APIENTRY glDrawTexxvOES(const GLfixed* coords); +GL_API void GL_APIENTRY glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); +GL_API void GL_APIENTRY glDrawTexfvOES(const GLfloat* coords); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLDRAWTEXSOESPROC)(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); +typedef void (GL_APIENTRYP PFNGLDRAWTEXIOESPROC)(GLint x, GLint y, GLint z, GLint width, GLint height); +typedef void (GL_APIENTRYP PFNGLDRAWTEXXOESPROC)(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); +typedef void (GL_APIENTRYP PFNGLDRAWTEXSVOESPROC)(const GLshort* coords); +typedef void (GL_APIENTRYP PFNGLDRAWTEXIVOESPROC)(const GLint* coords); +typedef void (GL_APIENTRYP PFNGLDRAWTEXXVOESPROC)(const GLfixed* coords); +typedef void (GL_APIENTRYP PFNGLDRAWTEXFOESPROC)(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); +typedef void (GL_APIENTRYP PFNGLDRAWTEXFVOESPROC)(const GLfloat* coords); +#endif + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image); +GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)(GLenum target, GLeglImageOES image); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC)(GLenum target, GLeglImageOES image); +#endif + +/* GL_OES_element_index_uint */ +#ifndef GL_OES_element_index_uint +#define GL_OES_element_index_uint 1 +#endif + +/* GL_OES_extended_matrix_palette */ +#ifndef GL_OES_extended_matrix_palette +#define GL_OES_extended_matrix_palette 1 +#endif + +/* GL_OES_fbo_render_mipmap */ +#ifndef GL_OES_fbo_render_mipmap +#define GL_OES_fbo_render_mipmap 1 +#endif + +/* GL_OES_fixed_point */ +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glAlphaFuncxOES(GLenum func, GLclampx ref); +GL_API void GL_APIENTRY glClearColorxOES(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); +GL_API void GL_APIENTRY glClearDepthxOES(GLclampx depth); +GL_API void GL_APIENTRY glClipPlanexOES(GLenum plane, const GLfixed* equation); +GL_API void GL_APIENTRY glColor4xOES(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GL_API void GL_APIENTRY glDepthRangexOES(GLclampx zNear, GLclampx zFar); +GL_API void GL_APIENTRY glFogxOES(GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glFogxvOES(GLenum pname, const GLfixed* params); +GL_API void GL_APIENTRY glFrustumxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +GL_API void GL_APIENTRY glGetClipPlanexOES(GLenum pname, GLfixed eqn[4]); +GL_API void GL_APIENTRY glGetFixedvOES(GLenum pname, GLfixed* params); +GL_API void GL_APIENTRY glGetLightxvOES(GLenum light, GLenum pname, GLfixed* params); +GL_API void GL_APIENTRY glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed* params); +GL_API void GL_APIENTRY glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed* params); +GL_API void GL_APIENTRY glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed* params); +GL_API void GL_APIENTRY glLightModelxOES(GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glLightModelxvOES(GLenum pname, const GLfixed* params); +GL_API void GL_APIENTRY glLightxOES(GLenum light, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glLightxvOES(GLenum light, GLenum pname, const GLfixed* params); +GL_API void GL_APIENTRY glLineWidthxOES(GLfixed width); +GL_API void GL_APIENTRY glLoadMatrixxOES(const GLfixed* m); +GL_API void GL_APIENTRY glMaterialxOES(GLenum face, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glMaterialxvOES(GLenum face, GLenum pname, const GLfixed* params); +GL_API void GL_APIENTRY glMultMatrixxOES(const GLfixed* m); +GL_API void GL_APIENTRY glMultiTexCoord4xOES(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GL_API void GL_APIENTRY glNormal3xOES(GLfixed nx, GLfixed ny, GLfixed nz); +GL_API void GL_APIENTRY glOrthoxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +GL_API void GL_APIENTRY glPointParameterxOES(GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glPointParameterxvOES(GLenum pname, const GLfixed* params); +GL_API void GL_APIENTRY glPointSizexOES(GLfixed size); +GL_API void GL_APIENTRY glPolygonOffsetxOES(GLfixed factor, GLfixed units); +GL_API void GL_APIENTRY glRotatexOES(GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GL_API void GL_APIENTRY glSampleCoveragexOES(GLclampx value, GLboolean invert); +GL_API void GL_APIENTRY glScalexOES(GLfixed x, GLfixed y, GLfixed z); +GL_API void GL_APIENTRY glTexEnvxOES(GLenum target, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glTexEnvxvOES(GLenum target, GLenum pname, const GLfixed* params); +GL_API void GL_APIENTRY glTexParameterxOES(GLenum target, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glTexParameterxvOES(GLenum target, GLenum pname, const GLfixed* params); +GL_API void GL_APIENTRY glTranslatexOES(GLfixed x, GLfixed y, GLfixed z); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLALPHAFUNCXOESPROC)(GLenum func, GLclampx ref); +typedef void (GL_APIENTRYP PFNGLCLEARCOLORXOESPROC)(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); +typedef void (GL_APIENTRYP PFNGLCLEARDEPTHXOESPROC)(GLclampx depth); +typedef void (GL_APIENTRYP PFNGLCLIPPLANEXOESPROC)(GLenum plane, const GLfixed* equation); +typedef void (GL_APIENTRYP PFNGLCOLOR4XOESPROC)(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEXOESPROC)(GLclampx zNear, GLclampx zFar); +typedef void (GL_APIENTRYP PFNGLFOGXOESPROC)(GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLFOGXVOESPROC)(GLenum pname, const GLfixed* params); +typedef void (GL_APIENTRYP PFNGLFRUSTUMXOESPROC)(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, + GLfixed zFar); +typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEXOESPROC)(GLenum pname, GLfixed eqn[4]); +typedef void (GL_APIENTRYP PFNGLGETFIXEDVOESPROC)(GLenum pname, GLfixed* params); +typedef void (GL_APIENTRYP PFNGLGETLIGHTXVOESPROC)(GLenum light, GLenum pname, GLfixed* params); +typedef void (GL_APIENTRYP PFNGLGETMATERIALXVOESPROC)(GLenum face, GLenum pname, GLfixed* params); +typedef void (GL_APIENTRYP PFNGLGETTEXENVXVOESPROC)(GLenum env, GLenum pname, GLfixed* params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC)(GLenum target, GLenum pname, GLfixed* params); +typedef void (GL_APIENTRYP PFNGLLIGHTMODELXOESPROC)(GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLLIGHTMODELXVOESPROC)(GLenum pname, const GLfixed* params); +typedef void (GL_APIENTRYP PFNGLLIGHTXOESPROC)(GLenum light, GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLLIGHTXVOESPROC)(GLenum light, GLenum pname, const GLfixed* params); +typedef void (GL_APIENTRYP PFNGLLINEWIDTHXOESPROC)(GLfixed width); +typedef void (GL_APIENTRYP PFNGLLOADMATRIXXOESPROC)(const GLfixed* m); +typedef void (GL_APIENTRYP PFNGLMATERIALXOESPROC)(GLenum face, GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLMATERIALXVOESPROC)(GLenum face, GLenum pname, const GLfixed* params); +typedef void (GL_APIENTRYP PFNGLMULTMATRIXXOESPROC)(const GLfixed* m); +typedef void (GL_APIENTRYP PFNGLMULTITEXCOORD4XOESPROC)(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (GL_APIENTRYP PFNGLNORMAL3XOESPROC)(GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (GL_APIENTRYP PFNGLORTHOXOESPROC)(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, + GLfixed zFar); +typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXOESPROC)(GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXVOESPROC)(GLenum pname, const GLfixed* params); +typedef void (GL_APIENTRYP PFNGLPOINTSIZEXOESPROC)(GLfixed size); +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETXOESPROC)(GLfixed factor, GLfixed units); +typedef void (GL_APIENTRYP PFNGLROTATEXOESPROC)(GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEXOESPROC)(GLclampx value, GLboolean invert); +typedef void (GL_APIENTRYP PFNGLSCALEXOESPROC)(GLfixed x, GLfixed y, GLfixed z); +typedef void (GL_APIENTRYP PFNGLTEXENVXOESPROC)(GLenum target, GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLTEXENVXVOESPROC)(GLenum target, GLenum pname, const GLfixed* params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXOESPROC)(GLenum target, GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXVOESPROC)(GLenum target, GLenum pname, const GLfixed* params); +typedef void (GL_APIENTRYP PFNGLTRANSLATEXOESPROC)(GLfixed x, GLfixed y, GLfixed z); +#endif + +/* GL_OES_framebuffer_object */ +#ifndef GL_OES_framebuffer_object +#define GL_OES_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API GLboolean GL_APIENTRY glIsRenderbufferOES(GLuint renderbuffer); +GL_API void GL_APIENTRY glBindRenderbufferOES(GLenum target, GLuint renderbuffer); +GL_API void GL_APIENTRY glDeleteRenderbuffersOES(GLsizei n, const GLuint* renderbuffers); +GL_API void GL_APIENTRY glGenRenderbuffersOES(GLsizei n, GLuint* renderbuffers); +GL_API void GL_APIENTRY glRenderbufferStorageOES(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_API void GL_APIENTRY glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint* params); +GL_API GLboolean GL_APIENTRY glIsFramebufferOES(GLuint framebuffer); +GL_API void GL_APIENTRY glBindFramebufferOES(GLenum target, GLuint framebuffer); +GL_API void GL_APIENTRY glDeleteFramebuffersOES(GLsizei n, const GLuint* framebuffers); +GL_API void GL_APIENTRY glGenFramebuffersOES(GLsizei n, GLuint* framebuffers); +GL_API GLenum GL_APIENTRY glCheckFramebufferStatusOES(GLenum target); +GL_API void GL_APIENTRY glFramebufferRenderbufferOES(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_API void GL_APIENTRY glFramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_API void GL_APIENTRY glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint* params); +GL_API void GL_APIENTRY glGenerateMipmapOES(GLenum target); +#endif +typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFEROESPROC)(GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFEROESPROC)(GLenum target, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSOESPROC)(GLsizei n, const GLuint* renderbuffers); +typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSOESPROC)(GLsizei n, GLuint* renderbuffers); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEOESPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVOESPROC)(GLenum target, GLenum pname, GLint* params); +typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFEROESPROC)(GLuint framebuffer); +typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFEROESPROC)(GLenum target, GLuint framebuffer); +typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSOESPROC)(GLsizei n, const GLuint* framebuffers); +typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSOESPROC)(GLsizei n, GLuint* framebuffers); +typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSOESPROC)(GLenum target); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEROESPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, + GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DOESPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC)(GLenum target, GLenum attachment, GLenum pname, + GLint* params); +typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPOESPROC)(GLenum target); +#endif + +/* GL_OES_mapbuffer */ +#ifndef GL_OES_mapbuffer +#define GL_OES_mapbuffer 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API void* GL_APIENTRY glMapBufferOES(GLenum target, GLenum access); +GL_API GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target); +GL_API void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, void** params); +#endif +#endif // not supported +typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC)(GLenum target, GLenum access); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC)(GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC)(GLenum target, GLenum pname, void** params); +#endif + +/* GL_OES_matrix_get */ +#ifndef GL_OES_matrix_get +#define GL_OES_matrix_get 1 +#endif + +/* GL_OES_matrix_palette */ +#ifndef _WIN32 // _WIN32 +#ifndef GL_OES_matrix_palette +#define GL_OES_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glCurrentPaletteMatrixOES(GLuint matrixpaletteindex); +GL_API void GL_APIENTRY glLoadPaletteFromModelViewMatrixOES(void); +GL_API void GL_APIENTRY glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); +GL_API void GL_APIENTRY glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); +#endif +typedef void (GL_APIENTRYP PFNGLCURRENTPALETTEMATRIXOESPROC)(GLuint matrixpaletteindex); +typedef void (GL_APIENTRYP PFNGLLOADPALETTEFROMMODELVIEWMATRIXOESPROC)(void); +typedef void (GL_APIENTRYP PFNGLMATRIXINDEXPOINTEROESPROC)(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); +typedef void (GL_APIENTRYP PFNGLWEIGHTPOINTEROESPROC)(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); +#endif +#endif //_WIN32 + +/* GL_OES_packed_depth_stencil */ +#ifndef GL_OES_packed_depth_stencil +#define GL_OES_packed_depth_stencil 1 +#endif + +/* GL_OES_query_matrix */ +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API GLbitfield GL_APIENTRY glQueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]); +#endif +#endif // not supported +typedef GLbitfield (GL_APIENTRYP PFNGLQUERYMATRIXXOESPROC)(GLfixed mantissa[16], GLint exponent[16]); +#endif + +/* GL_OES_rgb8_rgba8 */ +#ifndef GL_OES_rgb8_rgba8 +#define GL_OES_rgb8_rgba8 1 +#endif + +/* GL_OES_single_precision */ +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glDepthRangefOES(GLclampf zNear, GLclampf zFar); +GL_API void GL_APIENTRY glFrustumfOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +GL_API void GL_APIENTRY glOrthofOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +GL_API void GL_APIENTRY glClipPlanefOES(GLenum plane, const GLfloat* equation); +GL_API void GL_APIENTRY glGetClipPlanefOES(GLenum pname, GLfloat eqn[4]); +GL_API void GL_APIENTRY glClearDepthfOES(GLclampf depth); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFOESPROC)(GLclampf zNear, GLclampf zFar); +typedef void (GL_APIENTRYP PFNGLFRUSTUMFOESPROC)(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, + GLfloat zFar); +typedef void (GL_APIENTRYP PFNGLORTHOFOESPROC)(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, + GLfloat zFar); +typedef void (GL_APIENTRYP PFNGLCLIPPLANEFOESPROC)(GLenum plane, const GLfloat* equation); +typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEFOESPROC)(GLenum pname, GLfloat eqn[4]); +typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFOESPROC)(GLclampf depth); +#endif + +/* GL_OES_stencil1 */ +#ifndef GL_OES_stencil1 +#define GL_OES_stencil1 1 +#endif + +/* GL_OES_stencil4 */ +#ifndef GL_OES_stencil4 +#define GL_OES_stencil4 1 +#endif + +/* GL_OES_stencil8 */ +#ifndef GL_OES_stencil8 +#define GL_OES_stencil8 1 +#endif + +/* GL_OES_stencil_wrap */ +#ifndef GL_OES_stencil_wrap +#define GL_OES_stencil_wrap 1 +#endif + +/* GL_OES_texture_cube_map */ +#ifndef GL_OES_texture_cube_map +#define GL_OES_texture_cube_map 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glTexGenfOES(GLenum coord, GLenum pname, GLfloat param); +GL_API void GL_APIENTRY glTexGenfvOES(GLenum coord, GLenum pname, const GLfloat* params); +GL_API void GL_APIENTRY glTexGeniOES(GLenum coord, GLenum pname, GLint param); +GL_API void GL_APIENTRY glTexGenivOES(GLenum coord, GLenum pname, const GLint* params); +GL_API void GL_APIENTRY glTexGenxOES(GLenum coord, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glTexGenxvOES(GLenum coord, GLenum pname, const GLfixed* params); +GL_API void GL_APIENTRY glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat* params); +GL_API void GL_APIENTRY glGetTexGenivOES(GLenum coord, GLenum pname, GLint* params); +GL_API void GL_APIENTRY glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed* params); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLTEXGENFOESPROC)(GLenum coord, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLTEXGENFVOESPROC)(GLenum coord, GLenum pname, const GLfloat* params); +typedef void (GL_APIENTRYP PFNGLTEXGENIOESPROC)(GLenum coord, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLTEXGENIVOESPROC)(GLenum coord, GLenum pname, const GLint* params); +typedef void (GL_APIENTRYP PFNGLTEXGENXOESPROC)(GLenum coord, GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLTEXGENXVOESPROC)(GLenum coord, GLenum pname, const GLfixed* params); +typedef void (GL_APIENTRYP PFNGLGETTEXGENFVOESPROC)(GLenum coord, GLenum pname, GLfloat* params); +typedef void (GL_APIENTRYP PFNGLGETTEXGENIVOESPROC)(GLenum coord, GLenum pname, GLint* params); +typedef void (GL_APIENTRYP PFNGLGETTEXGENXVOESPROC)(GLenum coord, GLenum pname, GLfixed* params); +#endif + +/* GL_OES_texture_env_crossbar */ +#ifndef GL_OES_texture_env_crossbar +#define GL_OES_texture_env_crossbar 1 +#endif + +/* GL_OES_texture_mirrored_repeat */ +#ifndef GL_OES_texture_mirrored_repeat +#define GL_OES_texture_mirrored_repeat 1 +#endif + +/*------------------------------------------------------------------------* + * AMD extension functions + *------------------------------------------------------------------------*/ + +/* GL_AMD_compressed_3DC_texture */ +#ifndef GL_AMD_compressed_3DC_texture +#define GL_AMD_compressed_3DC_texture 1 +#endif + +/* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_compressed_ATC_texture +#define GL_AMD_compressed_ATC_texture 1 +#endif + +/*------------------------------------------------------------------------* + * EXT extension functions + *------------------------------------------------------------------------*/ + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +/* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_EXT_texture_format_BGRA8888 1 +#endif + +/*------------------------------------------------------------------------* + * IMG extension functions + *------------------------------------------------------------------------*/ + +/* GL_IMG_read_format */ +#ifndef GL_IMG_read_format +#define GL_IMG_read_format 1 +#endif + +/* GL_IMG_texture_compression_pvrtc */ +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_IMG_texture_compression_pvrtc 1 +#endif + +/* GL_IMG_user_clip_plane */ +#ifndef GL_IMG_user_clip_plane +#define GL_IMG_user_clip_plane 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glClipPlanefIMG(GLenum, const GLfloat*); +GL_API void GL_APIENTRY glClipPlanexIMG(GLenum, const GLfixed*); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLCLIPPLANEFIMG)(GLenum p, const GLfloat* eqn); +typedef void (GL_APIENTRYP PFNGLCLIPPLANEXIMG)(GLenum p, const GLfixed* eqn); +#endif + +/* GL_IMG_texture_env_enhanced_fixed_function */ +#ifndef GL_IMG_texture_env_enhanced_fixed_function +#define GL_IMG_texture_env_enhanced_fixed_function 1 +#endif + +/*------------------------------------------------------------------------* + * NV extension functions + *------------------------------------------------------------------------*/ + +/* NV_fence */ +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glDeleteFencesNV(GLsizei, const GLuint*); +GL_API void GL_APIENTRY glGenFencesNV(GLsizei, GLuint*); +GL_API GLboolean GL_APIENTRY glIsFenceNV(GLuint); +GL_API GLboolean GL_APIENTRY glTestFenceNV(GLuint); +GL_API void GL_APIENTRY glGetFenceivNV(GLuint, GLenum, GLint*); +GL_API void GL_APIENTRY glFinishFenceNV(GLuint); +GL_API void GL_APIENTRY glSetFenceNV(GLuint, GLenum); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC)(GLsizei n, const GLuint* fences); +typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC)(GLsizei n, GLuint* fences); +typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC)(GLuint fence); +typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC)(GLuint fence); +typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC)(GLuint fence, GLenum pname, GLint* params); +typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC)(GLuint fence); +typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC)(GLuint fence, GLenum condition); +#endif + +/*------------------------------------------------------------------------* + * QCOM extension functions + *------------------------------------------------------------------------*/ + +/* GL_QCOM_driver_control */ +#ifndef GL_QCOM_driver_control +#define GL_QCOM_driver_control 1 +#if 0 // not supported +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glGetDriverControlsQCOM(GLint* num, GLsizei size, GLuint* driverControls); +GL_API void GL_APIENTRY glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei* length, char* driverControlString); +GL_API void GL_APIENTRY glEnableDriverControlQCOM(GLuint driverControl); +GL_API void GL_APIENTRY glDisableDriverControlQCOM(GLuint driverControl); +#endif +#endif // not supported +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC)(GLint* num, GLsizei size, GLuint* driverControls); +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC)(GLuint driverControl, GLsizei bufSize, GLsizei* length, + char* driverControlString); +typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC)(GLuint driverControl); +typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC)(GLuint driverControl); +#endif + +/* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_perfmon_global_mode +#define GL_QCOM_perfmon_global_mode 1 +#endif + +/*------------------------------------------------------------------------* + * Samsung extension functions + *------------------------------------------------------------------------*/ + +/* PName */ +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 + +/* PVRTC */ +#define GL_PVRTC2_OES 0x1911 +#define GL_PVRTC4_OES 0x1912 + +// +// For sync OpenGLES 2.0 */ +// +/* Separate Blend Functions */ +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 + +/* Vertex Arrays */ +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F + +/* Shaders */ +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 + +/* Framebuffer Object. */ +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 + +/** Texture and Texture Environment as in ShaderInterface.doc **/ +// +// Texture environment modes +// +#define TEX_ENV_MODE_REPLACE 1 +#define TEX_ENV_MODE_MODULATE 2 +#define TEX_ENV_MODE_ADD 3 +#define TEX_ENV_MODE_DECAL 4 +#define TEX_ENV_MODE_BLEND 5 +#define TEX_ENV_MODE_COMBINE 6 +// +// Combine RGB +// +#define TEX_COMBINE_RGB_REPLACE 1 +#define TEX_COMBINE_RGB_MODULATE 2 +#define TEX_COMBINE_RGB_ADD 3 +#define TEX_COMBINE_RGB_ADD_SIGNED 4 +#define TEX_COMBINE_RGB_INTERPOLATE 5 +#define TEX_COMBINE_RGB_SUBTRACT 6 +#define TEX_COMBINE_RGB_DOT3_RGB 7 +#define TEX_COMBINE_RGB_DOT3_RGBA 8 + +// +// Combine Alpha +// +#define TEX_COMBINE_ALPHA_REPLACE 1 +#define TEX_COMBINE_ALPHA_MODULATE 2 +#define TEX_COMBINE_ALPHA_ADD 3 +#define TEX_COMBINE_ALPHA_ADD_SIGNED 4 +#define TEX_COMBINE_ALPHA_INTERPOLATE 5 +#define TEX_COMBINE_ALPHA_SUBTRACT 6 + + +// +// Combiner RGB and ALPHA source arguments +// +#define TEX_ENV_COMBINER_SRC_TEXTURE 1 +#define TEX_ENV_COMBINER_SRC_CONSTANT 2 +#define TEX_ENV_COMBINER_SRC_PRIMARY_COLOR 3 +#define TEX_ENV_COMBINER_SRC_PREVIOUS 4 + +// +// Combiner RGB operands +// +#define TEX_ENV_COMBINER_RGB_OP_SRC_COLOR 1 +#define TEX_ENV_COMBINER_RGB_OP_ONE_MINUS_SRC_COLOR 2 +#define TEX_ENV_COMBINER_RGB_OP_SRC_ALPHA 3 +#define TEX_ENV_COMBINER_RGB_OP_ONE_MINUS_SRC_ALPHA 4 + +// +// Combiner ALPHA operands +// +#define TEX_ENV_COMBINER_ALPHA_OP_SRC_ALPHA 1 +#define TEX_ENV_COMBINER_ALPHA_OP_ONE_MINUS_SRC_ALPHA 2 + +// +// Fog mode +// +#define FOGMODE_LINEAR 1 +#define FOGMODE_EXP 2 +#define FOGMODE_EXP2 3 + +#ifdef __cplusplus +} +#endif + +#endif /* __glext_h_ */ diff --git a/inc/glmacro.h b/inc/glmacro.h new file mode 100644 index 0000000..9e057e3 --- /dev/null +++ b/inc/glmacro.h @@ -0,0 +1,190 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _GL_MACRO_H_ +#define _GL_MACRO_H_ + +#define glAlphaFunc _GlAlphaFunc_1 +#define glClearColor _GlClearColor_1 +#define glClearDepthf _GlClearDepthf_1 +#define glClipPlanef _GlClipPlanef_1 +#define glColor4f _GlColor4f_1 +#define glDepthRangef _GlDepthRangef_1 +#define glFogf _GlFogf_1 +#define glFogfv _GlFogfv_1 +#define glFrustumf _GlFrustumf_1 +#define glGetClipPlanef _GlGetClipPlanef_1 +#define glGetFloatv _GlGetFloatv_1 +#define glGetLightfv _GlGetLightfv_1 +#define glGetMaterialfv _GlGetMaterialfv_1 +#define glGetTexEnvfv _GlGetTexEnvfv_1 +#define glGetTexParameterfv _GlGetTexParameterfv_1 +#define glLightModelf _GlLightModelf_1 +#define glLightModelfv _GlLightModelfv_1 +#define glLightf _GlLightf_1 +#define glLightfv _GlLightfv_1 +#define glLineWidth _GlLineWidth_1 +#define glLoadMatrixf _GlLoadMatrixf_1 +#define glMaterialf _GlMaterialf_1 +#define glMaterialfv _GlMaterialfv_1 +#define glMultMatrixf _GlMultMatrixf_1 +#define glMultiTexCoord4f _GlMultiTexCoord4f_1 +#define glNormal3f _GlNormal3f_1 +#define glOrthof _GlOrthof_1 +#define glPointParameterf _GlPointParameterf_1 +#define glPointParameterfv _GlPointParameterfv_1 +#define glPointSize _GlPointSize_1 +#define glPolygonOffset _GlPolygonOffset_1 +#define glRotatef _GlRotatef_1 +#define glScalef _GlScalef_1 +#define glTexEnvf _GlTexEnvf_1 +#define glTexEnvfv _GlTexEnvfv_1 +#define glTexParameterf _GlTexParameterf_1 +#define glTexParameterfv _GlTexParameterfv_1 +#define glTranslatef _GlTranslatef_1 +#define glActiveTexture _GlActiveTexture_1 +#define glAlphaFuncx _GlAlphaFuncx_1 +#define glBindBuffer _GlBindBuffer_1 +#define glBindTexture _GlBindTexture_1 +#define glBlendFunc _GlBlendFunc_1 +#define glBufferData _GlBufferData_1 +#define glBufferSubData _GlBufferSubData_1 +#define glClear _GlClear_1 +#define glClearColorx _GlClearColorx_1 +#define glClearDepthx _GlClearDepthx_1 +#define glClearStencil _GlClearStencil_1 +#define glClientActiveTexture _GlClientActiveTexture_1 +#define glClipPlanex _GlClipPlanex_1 +#define glColor4ub _GlColor4ub_1 +#define glColor4x _GlColor4x_1 +#define glColorMask _GlColorMask_1 +#define glColorPointer _GlColorPointer_1 +#define glCompressedTexImage2D _GlCompressedTexImage2D_1 +#define glCompressedTexSubImage2D _GlCompressedTexSubImage2D_1 +#define glCopyTexImage2D _GlCopyTexImage2D_1 +#define glCopyTexSubImage2D _GlCopyTexSubImage2D_1 +#define glCullFace _GlCullFace_1 +#define glDeleteBuffers _GlDeleteBuffers_1 +#define glDeleteTextures _GlDeleteTextures_1 +#define glDepthFunc _GlDepthFunc_1 +#define glDepthMask _GlDepthMask_1 +#define glDepthRangex _GlDepthRangex_1 +#define glDisable _GlDisable_1 +#define glDisableClientState _GlDisableClientState_1 +#define glDrawArrays _GlDrawArrays_1 +#define glDrawElements _GlDrawElements_1 +#define glEnable _GlEnable_1 +#define glEnableClientState _GlEnableClientState_1 +#define glFinish _GlFinish_1 +#define glFlush _GlFlush_1 +#define glFogx _GlFogx_1 +#define glFogxv _GlFogxv_1 +#define glFrontFace _GlFrontFace_1 +#define glFrustumx _GlFrustumx_1 +#define glGetBooleanv _GlGetBooleanv_1 +#define glGetBufferParameteriv _GlGetBufferParameteriv_1 +#define glGetClipPlanex _GlGetClipPlanex_1 +#define glGenBuffers _GlGenBuffers_1 +#define glGenTextures _GlGenTextures_1 +#define glGetError _GlGetError_1 +#define glGetFixedv _GlGetFixedv_1 +#define glGetIntegerv _GlGetIntegerv_1 +#define glGetLightxv _GlGetLightxv_1 +#define glGetMaterialxv _GlGetMaterialxv_1 +#define glGetPointerv _GlGetPointerv_1 +#define glGetString _GlGetString_1 +#define glGetTexEnviv _GlGetTexEnviv_1 +#define glGetTexEnvxv _GlGetTexEnvxv_1 +#define glGetTexParameteriv _GlGetTexParameteriv_1 +#define glGetTexParameterxv _GlGetTexParameterxv_1 +#define glHint _GlHint_1 +#define glIsBuffer _GlIsBuffer_1 +#define glIsEnabled _GlIsEnabled_1 +#define glIsTexture _GlIsTexture_1 +#define glLightModelx _GlLightModelx_1 +#define glLightModelxv _GlLightModelxv_1 +#define glLightx _GlLightx_1 +#define glLightxv _GlLightxv_1 +#define glLineWidthx _GlLineWidthx_1 +#define glLoadIdentity _GlLoadIdentity_1 +#define glLoadMatrixx _GlLoadMatrixx_1 +#define glLogicOp _GlLogicOp_1 +#define glMaterialx _GlMaterialx_1 +#define glMaterialxv _GlMaterialxv_1 +#define glMatrixMode _GlMatrixMode_1 +#define glMultMatrixx _GlMultMatrixx_1 +#define glMultiTexCoord4x _GlMultiTexCoord4x_1 +#define glNormal3x _GlNormal3x_1 +#define glNormalPointer _GlNormalPointer_1 +#define glOrthox _GlOrthox_1 +#define glPixelStorei _GlPixelStorei_1 +#define glPointParameterx _GlPointParameterx_1 +#define glPointParameterxv _GlPointParameterxv_1 +#define glPointSizex _GlPointSizex_1 +#define glPolygonOffsetx _GlPolygonOffsetx_1 +#define glPopMatrix _GlPopMatrix_1 +#define glPushMatrix _GlPushMatrix_1 +#define glReadPixels _GlReadPixels_1 +#define glRotatex _GlRotatex_1 +#define glSampleCoverage _GlSampleCoverage_1 +#define glSampleCoveragex _GlSampleCoveragex_1 +#define glScalex _GlScalex_1 +#define glScissor _GlScissor_1 +#define glShadeModel _GlShadeModel_1 +#define glStencilFunc _GlStencilFunc_1 +#define glStencilMask _GlStencilMask_1 +#define glStencilOp _GlStencilOp_1 +#define glTexCoordPointer _GlTexCoordPointer_1 +#define glTexEnvi _GlTexEnvi_1 +#define glTexEnvx _GlTexEnvx_1 +#define glTexEnviv _GlTexEnviv_1 +#define glTexEnvxv _GlTexEnvxv_1 +#define glTexImage2D _GlTexImage2D_1 +#define glTexParameteri _GlTexParameteri_1 +#define glTexParameterx _GlTexParameterx_1 +#define glTexParameteriv _GlTexParameteriv_1 +#define glTexParameterxv _GlTexParameterxv_1 +#define glTexSubImage2D _GlTexSubImage2D_1 +#define glTranslatex _GlTranslatex_1 +#define glVertexPointer _GlVertexPointer_1 +#define glViewport _GlViewport_1 +#define glPointSizePointerOES _GlPointSizePointerOES_1 +#define glCurrentPaletteMatrixOES _GlCurrentPaletteMatrixOES_1 +#define glLoadPaletteFromModelViewMatrixOES _GlLoadPaletteFromModelViewMatrixOES_1 +#define glMatrixIndexPointerOES _GlMatrixIndexPointerOES_1 +#define glWeightPointerOES _GlWeightPointerOES_1 + +//Start of FBO Functions +#define glIsRenderbufferOES _GlIsRenderbufferOES_1 +#define glBindRenderbufferOES _GlBindRenderbufferOES_1 +#define glDeleteRenderbuffersOES _GlDeleteRenderbuffersOES_1 +#define glGenRenderbuffersOES _GlGenRenderbuffersOES_1 +#define glRenderbufferStorageOES _GlRenderbufferStorageOES_1 +#define glGetRenderbufferParameterivOES _GlGetRenderbufferParameterivOES_1 +#define glIsFramebufferOES _GlIsFramebufferOES_1 +#define glBindFramebufferOES _GlBindFramebufferOES_1 +#define glDeleteFramebuffersOES _GlDeleteFramebuffersOES_1 +#define glGenFramebuffersOES _GlGenFramebuffersOES_1 +#define glCheckFramebufferStatusOES _GlCheckFramebufferStatusOES_1 +#define glFramebufferRenderbufferOES _GlFramebufferRenderbufferOES_1 +#define glFramebufferTexture2DOES _GlFramebufferTexture2DOES_1 +#define glGetFramebufferAttachmentParameterivOES _GlGetFramebufferAttachmentParameterivOES_1 +#define glGenerateMipmapOES _GlGenerateMipmapOES_1 +//End of FBO Functions + + +#endif // _GL_MACRO_H_ diff --git a/inc/glplatform.h b/inc/glplatform.h new file mode 100644 index 0000000..eef2e5b --- /dev/null +++ b/inc/glplatform.h @@ -0,0 +1,27 @@ +#ifndef __glplatform_h_ +#define __glplatform_h_ + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/* Platform-specific types and definitions for OpenGL ES 1.X gl.h + * Last modified on 2008/12/19 + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) + * by filing a bug against product "OpenGL-ES" component "Registry". + */ + +#include "khrplatform.h" + +#ifndef GL_API +#define GL_API KHRONOS_APICALL +#endif + +#define GL_APIENTRY //KHRONOS_APIENTRY + +#endif /* __glplatform_h_ */ diff --git a/inc/khrplatform.h b/inc/khrplatform.h new file mode 100644 index 0000000..f09d45c --- /dev/null +++ b/inc/khrplatform.h @@ -0,0 +1,569 @@ +/* $Change: 1028567 $ */ +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * $Revision: #1 $ on $Date: 2011/08/12 $ + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by sending them to the public Khronos Bugzilla + * (http://khronos.org/bugzilla) by filing a bug against product + * "Khronos (general)" component "Registry". + * + * A predefined template which fills in some of the bug fields can be + * reached using http://tinyurl.com/khrplatform-h-bugreport, but you + * must create a Bugzilla login first. + * + * + * See the Implementer's Guidelines for information about where this file + * must be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file must be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h must only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This must + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +/** + * @addtogroup opengles + * + * @{ + */ + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(_WIN32) +#ifdef __KHRONOS_EXPORTS +#define KHRONOS_APICALL __declspec(dllexport) +#else +#define KHRONOS_APICALL __declspec(dllimport) +#endif +//#define KHRONOS_APICALL extern +#elif defined(__SYMBIAN32__) +#define KHRONOS_APICALL IMPORT_C +#else +#define KHRONOS_APICALL extern +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) +/* Win32 but not WinCE */ +#define KHRONOS_APIENTRY __stdcall +#else +#define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined(__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// Using +// @since 2.0 +// +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS) || defined(__sgi) + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// Using +// @since 2.0 +// +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// Win32 +// @since 2.0 +// +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// Sun or Digital +// @since 2.0 +// +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// Generic fallback +// @since 2.0 +// +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef signed char khronos_int8_t +// \brief A type definition for khronos_int8_t. +// @since 2.0 +// +typedef signed char khronos_int8_t; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef unsigned char khronos_uint8_t +// \brief A type definition for khronos_uint8_t. +// @since 2.0 +// +typedef unsigned char khronos_uint8_t; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef signed short int khronos_int16_t +// \brief A type definition for khronos_int16_t. +// @since 2.0 +// +typedef signed short int khronos_int16_t; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef unsigned short int khronos_uint16_t +// \brief A type definition for khronos_uint16_t. +// @since 2.0 +// +typedef unsigned short int khronos_uint16_t; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef signed long int khronos_intptr_t +// \brief A type definition for khronos_intptr_t. +// @since 2.0 +// +typedef signed long int khronos_intptr_t; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef unsigned long int khronos_uintptr_t +// \brief A type definition for khronos_uintptr_t. +// @since 2.0 +// +typedef unsigned long int khronos_uintptr_t; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef signed long int khronos_ssize_t +// \brief A type definition for khronos_ssize_t. +// @since 2.0 +// +typedef signed long int khronos_ssize_t; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef unsigned long int khronos_usize_t +// \brief A type definition for khronos_usize_t. +// @since 2.0 +// +typedef unsigned long int khronos_usize_t; + +#if KHRONOS_SUPPORT_FLOAT +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// Float type +// @since 2.0 +// +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// Time types +// +// These types can be used to represent a time interval in nanoseconds or +// an absolute Unadjusted System Time. The Unadjusted System Time is the number +// of nanoseconds since some arbitrary system event (for example, since the last +// time the system booted). It is an unsigned 64-bit value that wraps back to 0 after every 584 years. +// The time intervals can be either signed or unsigned. +// @since 2.0 +// +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// Dummy value used to pad enum types to 32 bits. +// @since 2.0 +// +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// Enumerated boolean type +// +// Values other than zero must be considered to be true. Therefore +// comparisons must not be made against KHRONOS_TRUE. +// @since 2.0 +// +typedef enum +{ + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + + + +/*------------------------------------------------------------------------- + * Data type definitions for GL APIs + *-----------------------------------------------------------------------*/ + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef void GLvoid +// \brief A type definition for GLvoid. +// @since 2.0 +// +typedef void GLvoid; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef unsigned int GLenum +// \brief A type definition for GLenum. +// @since 2.0 +// +typedef unsigned int GLenum; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef unsigned char GLboolean +// \brief A type definition for GLboolean. +// @since 2.0 +// +typedef unsigned char GLboolean; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef unsigned int GLbitfield +// \brief A type definition for GLbitfield. +// @since 2.0 +// +typedef unsigned int GLbitfield; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef signed char GLbyte +// \brief A type definition for GLbyte. +// @since 2.0 +// +typedef khronos_int8_t GLbyte; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef short GLshort +// \brief A type definition for GLshort. +// @since 2.0 +// +typedef short GLshort; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef int GLint +// \brief A type definition for GLint. +// @since 2.0 +// +typedef int GLint; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef int GLsizei +// \brief A type definition for GLsizei. +// @since 2.0 +// +typedef int GLsizei; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef khronos_uint8_t GLubyte +// \brief A type definition for GLubyte. +// @since 2.0 +// +typedef khronos_uint8_t GLubyte; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef unsigned short GLushort +// \brief A type definition for GLushort. +// @since 2.0 +// +typedef unsigned short GLushort; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var unsigned int GLuint +// \brief A type definition for GLuint. +// @since 2.0 +// +typedef unsigned int GLuint; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef khronos_float_t GLfloat +// \brief A type definition for GLfloat. +// @since 2.0 +// +typedef khronos_float_t GLfloat; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef khronos_float_t GLclampf +// \brief A type definition for GLclampf. +// @since 2.0 +// +typedef khronos_float_t GLclampf; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef khronos_int32_t GLfixed +// \brief A type definition for GLfixed. +// @since 2.0 +// +typedef khronos_int32_t GLfixed; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef khronos_int32_t GLclampx +// \brief A type definition for GLclampx. +// @since 2.0 +// +typedef khronos_int32_t GLclampx; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef khronos_intptr_t GLintptr +// \brief A type definition for GLintptr. +// @since 2.0 +// +typedef khronos_intptr_t GLintptr; + +// +// This method is for internal use only. +// Using this method can cause behavioral, security-related, and consistency-related issues in the application. +// +// \var typedef khronos_ssize_t GLsizeiptr +// \brief A type definition for GLsizeiptr. +// @since 2.0 +// +typedef khronos_ssize_t GLsizeiptr; + +/** + * @} + */ + +#endif /* __khrplatform_h_ */ diff --git a/osp-uifw.manifest b/osp-uifw.manifest new file mode 100644 index 0000000..ae3e6f7 --- /dev/null +++ b/osp-uifw.manifest @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/osp-uifw.pc.in b/osp-uifw.pc.in new file mode 100755 index 0000000..c064287 --- /dev/null +++ b/osp-uifw.pc.in @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=/usr/lib/osp +includedir=/usr/include/osp + +Name: @PC_NAME@ +Description: @PACKAGE_DESCRIPTION@ +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} @PC_LDFLAGS@ +Cflags: -I${includedir} \ No newline at end of file diff --git a/packaging/osp-uifw.spec b/packaging/osp-uifw.spec new file mode 100755 index 0000000..c96e58a --- /dev/null +++ b/packaging/osp-uifw.spec @@ -0,0 +1,147 @@ +%define debug_package %{nil} +%define __strip /bin/true + +Name: osp-uifw +Summary: The UI Framework library of OSP +Version: 1.2.0.0 +Release: 44 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(capi-system-device) +BuildRequires: pkgconfig(capi-system-runtime-info) +BuildRequires: pkgconfig(bundle) +BuildRequires: pkgconfig(appsvc) +BuildRequires: pkgconfig(cairo) +BuildRequires: pkgconfig(chromium) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(dbus-1) +BuildRequires: pkgconfig(edbus) +BuildRequires: pkgconfig(elementary) +BuildRequires: pkgconfig(evas) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(ethumb) +BuildRequires: pkgconfig(ewebkit2) +BuildRequires: pkgconfig(xdamage) +%ifarch %{ix86} +BuildRequires: pkgconfig(egl) +%else +BuildRequires: pkgconfig(gles20) +%endif +BuildRequires: pkgconfig(fribidi) +BuildRequires: pkgconfig(freetype2) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(harfbuzz) +BuildRequires: pkgconfig(icu-i18n) +BuildRequires: pkgconfig(libdri2) +BuildRequires: pkgconfig(libdrm) +BuildRequires: pkgconfig(libdrm_slp) +BuildRequires: pkgconfig(libpng) +BuildRequires: pkgconfig(libwbxml2) +BuildRequires: pkgconfig(osp-appfw) +BuildRequires: pkgconfig(osp-speech) +BuildRequires: osp-appfw-internal-devel +BuildRequires: pkgconfig(osp-image-core) +BuildRequires: osp-image-core-internal-devel +BuildRequires: pkgconfig(pango) +BuildRequires: pkgconfig(pixman-1) +BuildRequires: pkgconfig(pkgmgr) +BuildRequires: pkgconfig(tts) +BuildRequires: pkgconfig(utilX) +BuildRequires: pkgconfig(xfixes) +BuildRequires: pkgconfig(xv) +BuildRequires: pkgconfig(xtst) +BuildRequires: libexif-devel +BuildRequires: liblua-devel +BuildRequires: libtiff-devel +BuildRequires: tolua++-devel + +# runtime requires +Requires: capi-appfw-application +Requires: capi-system-info +Requires: osp-appfw +Requires: osp-image-core +Requires: osp-speech + +Provides: libosp-uifw.so.1 + +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description +The UI Framework library of OSP + +%package devel +Summary: The UI Framework library of OSP (Development) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description devel +The UI Framework library of OSP (DEV) + +%package internal-devel +Summary: osp ui framework internel (Internal) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description internal-devel +The UI Framework library of OSP (Internal-DEV) + +%package debug +Summary: The UI Framework library of OSP (Development) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description debug +The UI Framework library of OSP (DEV) + +%prep +%setup -q + + +%build +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +%ifarch %{ix86} +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=x86 +%else +CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=arm +%endif + +# Call make instruction with smp support +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/usr/share/license +cp %{_builddir}/%{name}-%{version}/LICENSE.APLv2 %{buildroot}/usr/share/license/%{name} +cp %{_builddir}/%{name}-%{version}/LICENSE.Flora %{buildroot}/usr/share/license/%{name} + +%make_install + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%files +%manifest osp-uifw.manifest +/usr/share/license/%{name} +/usr/share/osp/bitmaps/* +/usr/share/osp/themes/* +/usr/share/osp/effects/* +%{_libdir}/osp/libosp-uifw.so* + +%files devel +%{_includedir}/osp/*.h +%{_libdir}/pkgconfig/osp-uifw.pc + +%files internal-devel +%{_includedir}/osp/app/*.h +%{_includedir}/osp/graphics/*.h +%{_includedir}/osp/ui/*.h + +%files debug +%{_libdir}/osp/debug/*.so* + diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_Title_btn.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_Title_btn.9.png new file mode 100755 index 0000000..637904c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_Title_btn.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_Title_btn_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_Title_btn_press.9.png new file mode 100755 index 0000000..72c6284 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_Title_btn_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_arrow_button_press_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_arrow_button_press_bg.9.png new file mode 100755 index 0000000..27b873b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_arrow_button_press_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_arrow_button_press_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_arrow_button_press_ef.9.png new file mode 100755 index 0000000..8219317 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_arrow_button_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_arrow_left.png b/res/common/usr/share/osp/bitmaps/480x800/00_arrow_left.png new file mode 100755 index 0000000..e9ab8d8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_arrow_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_arrow_right.png b/res/common/usr/share/osp/bitmaps/480x800/00_arrow_right.png new file mode 100755 index 0000000..577259f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_arrow_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_badge_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_badge_bg.9.png new file mode 100644 index 0000000..c1bf333 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_badge_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_badge_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_badge_bg_ef.9.png new file mode 100644 index 0000000..776d7f5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_badge_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_btn_circle_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_btn_circle_bg.png new file mode 100755 index 0000000..8d0d598 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_btn_circle_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_btn_circle_bg_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_btn_circle_bg_ef.png new file mode 100755 index 0000000..5cbf3fe Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_btn_circle_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_btn_circle_bg_p_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_btn_circle_bg_p_ef.png new file mode 100755 index 0000000..30b56ba Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_btn_circle_bg_p_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_01.9.png new file mode 100644 index 0000000..eb0fd8b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_01_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_01_bg.9.png new file mode 100755 index 0000000..6e59b4a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_01_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_01_bg_p_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_01_bg_p_ef.9.png new file mode 100755 index 0000000..9dff71e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_01_bg_p_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_01_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_01_ef.9.png new file mode 100644 index 0000000..ec4b775 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_01_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_01_ef_dim.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_01_ef_dim.9.png new file mode 100644 index 0000000..0e5238a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_01_ef_dim.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_01_ef_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_01_ef_press.9.png new file mode 100644 index 0000000..2285b3e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_01_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_02.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_02.9.png new file mode 100644 index 0000000..3536d22 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_02.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_02_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_02_ef.9.png new file mode 100644 index 0000000..11dfdf6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_02_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_02_ef_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_02_ef_press.9.png new file mode 100644 index 0000000..c4774d5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_02_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_03.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_03.9.png new file mode 100644 index 0000000..71756ae Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_03.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_03_dim_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_03_dim_ef.9.png new file mode 100644 index 0000000..4749b1f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_03_dim_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_03_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_03_ef.9.png new file mode 100644 index 0000000..4749b1f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_03_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_03_ef_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_03_ef_press.9.png new file mode 100644 index 0000000..1d97aec Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_03_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_06_dim.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_06_dim.9.png new file mode 100755 index 0000000..450ed67 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_06_dim.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_06_normal.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_06_normal.9.png new file mode 100755 index 0000000..355f50d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_06_normal.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_06_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_06_press.9.png new file mode 100755 index 0000000..2bae489 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_06_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_call.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_call.png new file mode 100644 index 0000000..3664975 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_call.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_call_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_call_ef.png new file mode 100644 index 0000000..f82b727 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_call_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_cancel.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_cancel.png new file mode 100755 index 0000000..cc6f5e2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_cancel.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_cancel.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_cancel.png new file mode 100644 index 0000000..14141a1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_cancel.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_cancel_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_cancel_ef.png new file mode 100644 index 0000000..4450f61 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_cancel_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_closed.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_closed.png new file mode 100644 index 0000000..4e392fb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_closed.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_closed_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_closed_ef.png new file mode 100644 index 0000000..7fc420e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_closed_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_minus.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_minus.png new file mode 100644 index 0000000..76582f3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_minus.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_minus_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_minus_ef.png new file mode 100644 index 0000000..549f0e2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_minus_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_opened.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_opened.png new file mode 100644 index 0000000..86565d2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_opened.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_opened_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_opened_ef.png new file mode 100644 index 0000000..fba762c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_opened_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_send.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_send.png new file mode 100644 index 0000000..23838c2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_send.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_send_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_send_ef.png new file mode 100644 index 0000000..38548e1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_expand_send_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_info.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_info.png new file mode 100644 index 0000000..1e4e013 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_info.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_info_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_info_ef.png new file mode 100644 index 0000000..49ce801 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_info_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_left.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_left.png new file mode 100644 index 0000000..2da01a9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_left_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_left_ef.png new file mode 100644 index 0000000..e805dd4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_left_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_minus.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_minus.png new file mode 100755 index 0000000..622616c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_minus.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_normal.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_normal.9.png new file mode 100755 index 0000000..d64969f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_normal.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_normal_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_normal_bg.9.png new file mode 100755 index 0000000..325b542 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_normal_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_normal_effect_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_normal_effect_01.9.png new file mode 100755 index 0000000..87f9a6c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_normal_effect_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_off.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_off.png new file mode 100644 index 0000000..34e311f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_off.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_off_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_off_01.png new file mode 100755 index 0000000..8527721 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_off_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_off_dim.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_off_dim.png new file mode 100644 index 0000000..5a023d4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_off_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_off_dim_temp.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_off_dim_temp.png new file mode 100644 index 0000000..5a023d4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_off_dim_temp.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_off_temp.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_off_temp.png new file mode 100644 index 0000000..c3d3155 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_off_temp.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_on.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_on.png new file mode 100644 index 0000000..4ce2e84 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_on.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_on_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_on_01.png new file mode 100755 index 0000000..bfdc233 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_on_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_on_dim.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_on_dim.png new file mode 100644 index 0000000..8ebea42 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_on_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_on_dim_temp.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_on_dim_temp.png new file mode 100644 index 0000000..8ebea42 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_on_dim_temp.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_on_off_handler.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_on_off_handler.png new file mode 100644 index 0000000..645e3b0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_on_off_handler.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_on_temp.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_on_temp.png new file mode 100644 index 0000000..a4baf3b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_on_temp.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_plus.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_plus.png new file mode 100644 index 0000000..6ba5a3b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_plus.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_plus_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_plus_ef.png new file mode 100644 index 0000000..613b8cb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_plus_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_radio.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio.png new file mode 100644 index 0000000..64a8f27 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_dim.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_dim.png new file mode 100644 index 0000000..7f732b2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_normal1.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_normal1.png new file mode 100755 index 0000000..8bd056d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_normal1.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_normal2.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_normal2.png new file mode 100755 index 0000000..805aa5e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_normal2.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_press.png new file mode 100644 index 0000000..789d761 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_press1.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_press1.png new file mode 100755 index 0000000..ebc3620 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_press1.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_press2.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_press2.png new file mode 100755 index 0000000..41e99b4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_press2.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_select.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_select.png new file mode 100644 index 0000000..d2b8556 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_select.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_select_dim.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_select_dim.png new file mode 100644 index 0000000..bd87ae2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_radio_select_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_rename.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_rename.png new file mode 100644 index 0000000..39a9e71 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_rename.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_rename_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_rename_ef.png new file mode 100644 index 0000000..129dace Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_rename_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_reveal.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_reveal.png new file mode 100755 index 0000000..a870d74 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_reveal.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_right.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_right.png new file mode 100644 index 0000000..3657da2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_right_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_right_ef.png new file mode 100644 index 0000000..adabc3d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_right_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_01.9.png new file mode 100755 index 0000000..935687c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_02.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_02.9.png new file mode 100755 index 0000000..46e03a1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_02.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_03.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_03.9.png new file mode 100755 index 0000000..e98ea71 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_03.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_ef_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_ef_01.9.png new file mode 100755 index 0000000..7335e58 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_ef_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_ef_02.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_ef_02.9.png new file mode 100755 index 0000000..ab83fdb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_ef_02.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_ef_03.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_ef_03.9.png new file mode 100755 index 0000000..7666f17 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_seg_f_bg_ef_03.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_send.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_send.png new file mode 100755 index 0000000..5ff5764 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_send.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_warning.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_warning.png new file mode 100755 index 0000000..63324dc Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_warning.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_warring.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_warring.png new file mode 100644 index 0000000..7e63d67 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_warring.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_warring_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_warring_ef.png new file mode 100644 index 0000000..358c8af Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_warring_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_web.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_web.9.png new file mode 100644 index 0000000..04eeaca Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_web.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_button_web_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_button_web_press.9.png new file mode 100644 index 0000000..99b3abb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_button_web_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_category_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_category_bg.9.png new file mode 100755 index 0000000..200a7e1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_category_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_category_button.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_category_button.9.png new file mode 100755 index 0000000..be74e84 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_category_button.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_category_button_focus.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_category_button_focus.9.png new file mode 100755 index 0000000..ad44aab Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_category_button_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_category_left_button.png b/res/common/usr/share/osp/bitmaps/480x800/00_category_left_button.png new file mode 100755 index 0000000..7b7a58d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_category_left_button.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_category_left_button_arrow.png b/res/common/usr/share/osp/bitmaps/480x800/00_category_left_button_arrow.png new file mode 100755 index 0000000..970ca8b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_category_left_button_arrow.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_category_left_gd.png b/res/common/usr/share/osp/bitmaps/480x800/00_category_left_gd.png new file mode 100755 index 0000000..7b7a58d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_category_left_gd.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_category_panel_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_category_panel_bg.9.png new file mode 100755 index 0000000..27b873b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_category_panel_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_category_panel_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_category_panel_bg_ef.9.png new file mode 100755 index 0000000..7780e93 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_category_panel_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_category_right_button.png b/res/common/usr/share/osp/bitmaps/480x800/00_category_right_button.png new file mode 100755 index 0000000..f4b75b6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_category_right_button.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_category_right_button_arrow.png b/res/common/usr/share/osp/bitmaps/480x800/00_category_right_button_arrow.png new file mode 100755 index 0000000..8d37079 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_category_right_button_arrow.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_category_right_gd.png b/res/common/usr/share/osp/bitmaps/480x800/00_category_right_gd.png new file mode 100755 index 0000000..f4b75b6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_category_right_gd.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_check.png b/res/common/usr/share/osp/bitmaps/480x800/00_check.png new file mode 100755 index 0000000..c4b61da Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_check.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_check_angle.png b/res/common/usr/share/osp/bitmaps/480x800/00_check_angle.png new file mode 100755 index 0000000..ed0efb8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_check_angle.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_check_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_check_bg.png new file mode 100644 index 0000000..bda4edf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_check_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_check_bg_dim.png b/res/common/usr/share/osp/bitmaps/480x800/00_check_bg_dim.png new file mode 100644 index 0000000..9e3331a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_check_bg_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_check_bg_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_check_bg_press.png new file mode 100644 index 0000000..7f7548f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_check_bg_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_check_checking.png b/res/common/usr/share/osp/bitmaps/480x800/00_check_checking.png new file mode 100644 index 0000000..79e33b4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_check_checking.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_check_checking_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_check_checking_bg.png new file mode 100755 index 0000000..9bcb1a5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_check_checking_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_check_checking_dim.png b/res/common/usr/share/osp/bitmaps/480x800/00_check_checking_dim.png new file mode 100644 index 0000000..1413cb6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_check_checking_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_check_dim.png b/res/common/usr/share/osp/bitmaps/480x800/00_check_dim.png new file mode 100755 index 0000000..8f64005 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_check_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_check_index_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_check_index_bg.png new file mode 100755 index 0000000..525e04b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_check_index_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_circle_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_circle_bg.png new file mode 100644 index 0000000..ec0f376 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_circle_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_circle_bg_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_circle_bg_ef.png new file mode 100644 index 0000000..e4deabd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_circle_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_circle_bg_ef_dim.png b/res/common/usr/share/osp/bitmaps/480x800/00_circle_bg_ef_dim.png new file mode 100644 index 0000000..e4deabd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_circle_bg_ef_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_circle_bg_ef_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_circle_bg_ef_press.png new file mode 100644 index 0000000..c5751a8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_circle_bg_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_brightness.png b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_brightness.png new file mode 100644 index 0000000..aa51c52 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_brightness.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_brightness_h.png b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_brightness_h.png new file mode 100644 index 0000000..580124f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_brightness_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_btn_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_btn_bg.9.png new file mode 100755 index 0000000..d64969f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_btn_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_btn_left.png b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_btn_left.png new file mode 100755 index 0000000..e470403 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_btn_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_btn_right.png b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_btn_right.png new file mode 100755 index 0000000..ed6ade9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_btn_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_color.png b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_color.png new file mode 100644 index 0000000..9f555ee Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_color.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_color_h.png b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_color_h.png new file mode 100644 index 0000000..93d82ea Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_color_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_custom_color.png b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_custom_color.png new file mode 100644 index 0000000..49d9f5a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_custom_color.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_custom_color_h.png b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_custom_color_h.png new file mode 100644 index 0000000..efc8c68 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_custom_color_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_focus.png b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_focus.png new file mode 100644 index 0000000..ee33aab Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_focus.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_saturation.png b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_saturation.png new file mode 100644 index 0000000..7cfea3b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_saturation.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_saturation_h.png b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_saturation_h.png new file mode 100644 index 0000000..1a94c64 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_color_picker_saturation_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_contacts_button_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_contacts_button_bg.9.png new file mode 100644 index 0000000..67e5718 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_contacts_button_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_bg.9.png new file mode 100755 index 0000000..99c1ed0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_bg_01.9.png new file mode 100755 index 0000000..dfbe205 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_bg_effect.9.png new file mode 100755 index 0000000..d2ace05 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_bottom.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_bottom.png new file mode 100755 index 0000000..beb51c0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_bottom.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_bottom_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_bottom_01.png new file mode 100755 index 0000000..2b68d00 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_bottom_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_bottom_effect.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_bottom_effect.png new file mode 100755 index 0000000..b965135 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_bottom_effect.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_left.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_left.png new file mode 100755 index 0000000..4dacb1d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_left_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_left_01.png new file mode 100755 index 0000000..7332a6e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_left_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_left_effect.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_left_effect.png new file mode 100755 index 0000000..e930c87 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_left_effect.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_right.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_right.png new file mode 100755 index 0000000..e6fdf99 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_right_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_right_01.png new file mode 100755 index 0000000..70f5f02 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_right_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_right_effect.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_right_effect.png new file mode 100755 index 0000000..c839d8e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_right_effect.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_top.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_top.png new file mode 100755 index 0000000..c898ab2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_top.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_top_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_top_01.png new file mode 100755 index 0000000..3bfb34f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_top_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_top_effect.png b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_top_effect.png new file mode 100755 index 0000000..ee9ae22 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_context_popup_tail_top_effect.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_center_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_center_bg.9.png new file mode 100755 index 0000000..62e21ca Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_center_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_center_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_center_bg_effect.9.png new file mode 100755 index 0000000..77137a2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_center_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_center_bg_press_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_center_bg_press_effect.9.png new file mode 100755 index 0000000..a1cb877 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_center_bg_press_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_dot.png b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_dot.png new file mode 100755 index 0000000..6a7fc53 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_dot.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_left_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_left_bg.9.png new file mode 100755 index 0000000..f011531 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_left_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_left_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_left_bg_effect.9.png new file mode 100755 index 0000000..4c8f57a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_left_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_left_bg_press_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_left_bg_press_effect.9.png new file mode 100755 index 0000000..7ae5980 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_left_bg_press_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_right_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_right_bg.9.png new file mode 100755 index 0000000..de4154d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_right_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_right_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_right_bg_effect.9.png new file mode 100755 index 0000000..966793a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_right_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_right_bg_press_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_right_bg_press_effect.9.png new file mode 100755 index 0000000..a175af3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_date_picker_right_bg_press_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_detail_button#5.png b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button#5.png new file mode 100755 index 0000000..cdfaefa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button#5.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_detail_button.png b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button.png new file mode 100755 index 0000000..cdfaefa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_01.png new file mode 100755 index 0000000..a4d932f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_01_dim.png b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_01_dim.png new file mode 100755 index 0000000..725440f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_01_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_01_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_01_press.png new file mode 100755 index 0000000..d7b6491 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_01_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_dim#1.png b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_dim#1.png new file mode 100755 index 0000000..9f4d74e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_dim#1.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_dim.png b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_dim.png new file mode 100755 index 0000000..9f4d74e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_press#3.png b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_press#3.png new file mode 100755 index 0000000..17f41d6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_press#3.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_press.png new file mode 100755 index 0000000..17f41d6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_detail_button_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_dialogue_group_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_dialogue_group_bg.9.png new file mode 100755 index 0000000..4761eac Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_dialogue_group_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_dialogue_group_bg_bar.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_dialogue_group_bg_bar.9.png new file mode 100755 index 0000000..4dc704d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_dialogue_group_bg_bar.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_divider_line.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_divider_line.9.png new file mode 100644 index 0000000..307a39f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_divider_line.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_divider_line_translucent.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_divider_line_translucent.9.png new file mode 100644 index 0000000..9a9bda2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_divider_line_translucent.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_bg.9.png new file mode 100755 index 0000000..a5fba96 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_clear.png b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_clear.png new file mode 100644 index 0000000..bf28a34 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_clear.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_line_round_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_line_round_bg_01.9.png new file mode 100644 index 0000000..2e75e09 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_line_round_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_line_squre_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_line_squre_bg_01.9.png new file mode 100644 index 0000000..9bdef0e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_line_squre_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_no_line_round_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_no_line_round_bg.9.png new file mode 100644 index 0000000..a7ddf3a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_no_line_round_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_no_line_square_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_no_line_square_bg.9.png new file mode 100644 index 0000000..2a931d3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_no_line_square_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_round_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_round_bg.9.png new file mode 100755 index 0000000..deef7d8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_round_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_round_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_round_bg_ef.9.png new file mode 100755 index 0000000..30c1556 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_edit_field_round_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_effect_tab_bounce_left.png b/res/common/usr/share/osp/bitmaps/480x800/00_effect_tab_bounce_left.png new file mode 100644 index 0000000..529e3cd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_effect_tab_bounce_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_effect_tab_bounce_right.png b/res/common/usr/share/osp/bitmaps/480x800/00_effect_tab_bounce_right.png new file mode 100644 index 0000000..efe5054 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_effect_tab_bounce_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_popup_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_popup_bg.9.png new file mode 100755 index 0000000..d80d3fc Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_popup_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_popup_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_popup_bg_ef.9.png new file mode 100755 index 0000000..f06c275 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_popup_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_rollover_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_rollover_bg.9.png new file mode 100755 index 0000000..b9a50be Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_rollover_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_rollover_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_rollover_bg_focus.9.png new file mode 100755 index 0000000..39697b4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_rollover_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_rollover_bg_line_focus.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_rollover_bg_line_focus.9.png new file mode 100755 index 0000000..8631bc1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_fast_scroll_rollover_bg_line_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_footer_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_footer_bg.9.png new file mode 100755 index 0000000..c2284e9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_footer_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_footer_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_footer_bg_01.9.png new file mode 100755 index 0000000..ab9dc9e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_footer_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_footer_icon_close.png b/res/common/usr/share/osp/bitmaps/480x800/00_footer_icon_close.png new file mode 100755 index 0000000..1601390 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_footer_icon_close.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_footer_icon_close_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_footer_icon_close_press.png new file mode 100755 index 0000000..8d0f692 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_footer_icon_close_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_footer_icon_more.png b/res/common/usr/share/osp/bitmaps/480x800/00_footer_icon_more.png new file mode 100755 index 0000000..1437796 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_footer_icon_more.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_footer_icon_more_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_footer_icon_more_press.png new file mode 100755 index 0000000..2925aec Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_footer_icon_more_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_grid_select_check.png b/res/common/usr/share/osp/bitmaps/480x800/00_grid_select_check.png new file mode 100755 index 0000000..2e90860 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_grid_select_check.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_grid_select_check_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_grid_select_check_bg.png new file mode 100755 index 0000000..b7b6fc1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_grid_select_check_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_grid_select_check_bg_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_grid_select_check_bg_press.png new file mode 100755 index 0000000..ea085aa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_grid_select_check_bg_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bg.9.png new file mode 100755 index 0000000..ce44719 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bg_focus.9.png new file mode 100644 index 0000000..94dc214 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bg_p.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bg_p.9.png new file mode 100755 index 0000000..134d87b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bg_p.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bg_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bg_press.9.png new file mode 100755 index 0000000..cb2bdad Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bg_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bottom_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bottom_bg.9.png new file mode 100755 index 0000000..a2cef7e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bottom_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bottom_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bottom_bg_focus.9.png new file mode 100644 index 0000000..3d18daf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bottom_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bottom_bg_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bottom_bg_press.9.png new file mode 100755 index 0000000..500858b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_bottom_bg_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_center_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_center_bg.9.png new file mode 100755 index 0000000..7ecd1a1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_center_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_center_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_center_bg_focus.9.png new file mode 100644 index 0000000..8123812 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_center_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_center_bg_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_center_bg_press.9.png new file mode 100755 index 0000000..12128af Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_center_bg_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_h_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_h_bg.9.png new file mode 100755 index 0000000..4715bbe Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_h_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_input_outline_h.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_input_outline_h.9.png new file mode 100755 index 0000000..a144a0f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_input_outline_h.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_normal_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_normal_bg.9.png new file mode 100755 index 0000000..a65fdaf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_normal_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_top_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_top_bg.9.png new file mode 100755 index 0000000..d6b52df Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_top_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_top_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_top_bg_focus.9.png new file mode 100644 index 0000000..35cdd97 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_top_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_top_bg_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_top_bg_press.9.png new file mode 100755 index 0000000..b057ab0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_groupedlist_top_bg_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_header_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_header_bg.9.png new file mode 100755 index 0000000..dc7d9c3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_header_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_header_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_header_bg_01.9.png new file mode 100755 index 0000000..283360a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_header_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_header_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_header_bg_effect.9.png new file mode 100755 index 0000000..95caa23 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_header_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_header_button_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_header_button_bg.9.png new file mode 100755 index 0000000..c1b0ae9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_header_button_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_header_button_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_header_button_bg_effect.9.png new file mode 100755 index 0000000..841020e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_header_button_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_header_button_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_header_button_bg_focus.9.png new file mode 100755 index 0000000..5a4f9ee Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_header_button_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_header_button_bg_press_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_header_button_bg_press_effect.9.png new file mode 100755 index 0000000..700c2d0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_header_button_bg_press_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_header_title_handler.png b/res/common/usr/share/osp/bitmaps/480x800/00_header_title_handler.png new file mode 100755 index 0000000..082f3ca Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_header_title_handler.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_Back.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_Back.png new file mode 100644 index 0000000..75880ae Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_Back.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_Back_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_Back_ef.png new file mode 100644 index 0000000..da92534 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_Back_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_Back_ef_02.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_Back_ef_02.png new file mode 100644 index 0000000..c2cc7f9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_Back_ef_02.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_Back_trans_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_Back_trans_ef.png new file mode 100644 index 0000000..adba7cf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_Back_trans_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_back.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_back.png new file mode 100755 index 0000000..970619b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_back.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_edit.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_edit.png new file mode 100644 index 0000000..8005ca1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_edit.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_edit_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_edit_ef.png new file mode 100644 index 0000000..80bc218 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_edit_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_jump.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_jump.png new file mode 100755 index 0000000..4a9a404 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_jump.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_jump_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_jump_ef.png new file mode 100755 index 0000000..2ea1f9a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_jump_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_jump_left.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_jump_left.png new file mode 100755 index 0000000..b7ec314 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_jump_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_jump_left_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_jump_left_ef.png new file mode 100755 index 0000000..9d984ca Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_jump_left_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_more.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_more.png new file mode 100644 index 0000000..81e0c98 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_more.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_more_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_more_ef.png new file mode 100644 index 0000000..8a0b4d3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_more_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_plus.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_plus.png new file mode 100644 index 0000000..1b10333 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_plus.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_icon_plus_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_icon_plus_ef.png new file mode 100644 index 0000000..b910f02 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_icon_plus_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_iconlist_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_iconlist_bg.9.png new file mode 100755 index 0000000..30726b2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_iconlist_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_indexlist_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_indexlist_bg.9.png new file mode 100755 index 0000000..aa4d47c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_indexlist_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_indexlist_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_indexlist_bg_ef.9.png new file mode 100755 index 0000000..96342f6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_indexlist_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_label_01_normal.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_label_01_normal.9.png new file mode 100755 index 0000000..355f50d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_label_01_normal.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg.9.png new file mode 100644 index 0000000..351f138 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_bottom.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_bottom.9.png new file mode 100644 index 0000000..90d73b9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_bottom.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_bottom_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_bottom_ef.9.png new file mode 100644 index 0000000..fbd5ccf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_bottom_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_center.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_center.9.png new file mode 100644 index 0000000..23c6cf2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_center.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_center_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_center_ef.9.png new file mode 100644 index 0000000..4c7079f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_center_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_ef.9.png new file mode 100644 index 0000000..2ae976d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_top.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_top.9.png new file mode 100644 index 0000000..44d946a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_top.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_top_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_top_ef.9.png new file mode 100644 index 0000000..744ebb0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_group_bg_top_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_01.png new file mode 100644 index 0000000..5c8edae Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_02.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_02.png new file mode 100644 index 0000000..69c4883 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_02.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_03.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_03.png new file mode 100644 index 0000000..38d71c9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_03.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_04.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_04.png new file mode 100644 index 0000000..03fb040 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_04.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_05.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_05.png new file mode 100644 index 0000000..1503155 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_05.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_06.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_06.png new file mode 100644 index 0000000..71084d4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_06.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_07.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_07.png new file mode 100644 index 0000000..2ce2f62 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_07.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_08.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_08.png new file mode 100644 index 0000000..09c3741 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_08.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_09.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_09.png new file mode 100644 index 0000000..3e26bc2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_09.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_10.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_10.png new file mode 100644 index 0000000..d9b1a81 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_10.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_11.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_11.png new file mode 100644 index 0000000..4283d7a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_11.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_12.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_12.png new file mode 100644 index 0000000..3093723 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_12.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_13.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_13.png new file mode 100644 index 0000000..ae24e4f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_13.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_14.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_14.png new file mode 100644 index 0000000..5d750b5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_14.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_15.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_15.png new file mode 100644 index 0000000..b1b5258 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_15.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_16.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_16.png new file mode 100644 index 0000000..e81933f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_16.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_17.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_17.png new file mode 100644 index 0000000..215eb4f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_17.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_18.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_18.png new file mode 100644 index 0000000..ab0c642 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_18.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_19.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_19.png new file mode 100644 index 0000000..de80cfb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_19.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_20.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_20.png new file mode 100644 index 0000000..947f774 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_20.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_21.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_21.png new file mode 100644 index 0000000..36957e5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_21.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_22.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_22.png new file mode 100644 index 0000000..f8735b1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_22.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_23.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_23.png new file mode 100644 index 0000000..26b9732 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_23.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_24.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_24.png new file mode 100644 index 0000000..9442c49 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_24.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_25.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_25.png new file mode 100644 index 0000000..802740b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_25.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_26.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_26.png new file mode 100644 index 0000000..e7d9aff Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_26.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_27.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_27.png new file mode 100644 index 0000000..0e7d812 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_27.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_28.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_28.png new file mode 100644 index 0000000..42b02bb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_28.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_29.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_29.png new file mode 100644 index 0000000..b186bb3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_29.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_process_30.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_30.png new file mode 100644 index 0000000..efedad3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_process_30.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_progress_bar.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_progress_bar.9.png new file mode 100755 index 0000000..191e333 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_progress_bar.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_progress_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_progress_bg.9.png new file mode 100755 index 0000000..80d12bf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_progress_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_slider_icon_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_slider_icon_bg.9.png new file mode 100755 index 0000000..d64969f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_slider_icon_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_slider_icon_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_slider_icon_bg_effect.9.png new file mode 100755 index 0000000..87f9a6c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_slider_icon_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_list_slider_icon_bg_effect_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_list_slider_icon_bg_effect_01.9.png new file mode 100755 index 0000000..d0fb0dd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_list_slider_icon_bg_effect_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_on_button_controller#5.png b/res/common/usr/share/osp/bitmaps/480x800/00_on_button_controller#5.png new file mode 100755 index 0000000..bb85e93 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_on_button_controller#5.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_contextual_popup_arrow.png b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_contextual_popup_arrow.png new file mode 100755 index 0000000..5367c6b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_contextual_popup_arrow.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg.png new file mode 100644 index 0000000..6dc0020 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_ef.png new file mode 100644 index 0000000..35bea63 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_ef_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_ef_press.png new file mode 100644 index 0000000..638e68d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_p.png b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_p.png new file mode 100755 index 0000000..6c729bf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_p.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_p_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_p_ef.png new file mode 100755 index 0000000..95ed934 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_p_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_press.png new file mode 100644 index 0000000..dedb347 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_option_panel_handle_bg_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_option_tray_tail_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_option_tray_tail_bg.png new file mode 100755 index 0000000..3d16da3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_option_tray_tail_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_overscrolling_bottom.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_overscrolling_bottom.9.png new file mode 100644 index 0000000..3be0788 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_overscrolling_bottom.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_overscrolling_left.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_overscrolling_left.9.png new file mode 100644 index 0000000..860463f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_overscrolling_left.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_overscrolling_right.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_overscrolling_right.9.png new file mode 100644 index 0000000..b187aaa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_overscrolling_right.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_overscrolling_top.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_overscrolling_top.9.png new file mode 100644 index 0000000..45f86a7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_overscrolling_top.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_panel_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_panel_bg.9.png new file mode 100755 index 0000000..65a79dd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_panel_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_arrow.png b/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_arrow.png new file mode 100755 index 0000000..d7f216c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_arrow.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_bg.9.png new file mode 100644 index 0000000..673c044 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_bg_ef.9.png new file mode 100644 index 0000000..24bf5b0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_bg_ef_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_bg_ef_press.9.png new file mode 100644 index 0000000..b8a38ea Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_bg_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_bg_p_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_bg_p_ef.9.png new file mode 100755 index 0000000..2d699a2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_panel_handle_bg_p_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_panel_list_press_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_panel_list_press_bg.9.png new file mode 100755 index 0000000..2705803 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_panel_list_press_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_panel_list_press_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_panel_list_press_bg_ef.9.png new file mode 100755 index 0000000..0f80eeb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_panel_list_press_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bg.9.png new file mode 100755 index 0000000..4b49813 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bg_ef.9.png new file mode 100755 index 0000000..534bf1b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bg_effect.9.png new file mode 100755 index 0000000..206b062 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bottom_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bottom_bg.9.png new file mode 100755 index 0000000..b941575 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bottom_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_bg.9.png new file mode 100755 index 0000000..20664e6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_bg_ef.9.png new file mode 100755 index 0000000..cb04f16 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_bottom_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_bottom_bg.png new file mode 100755 index 0000000..733c790 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_bottom_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_bottom_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_bottom_ef.png new file mode 100755 index 0000000..2abbadc Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_bottom_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_left_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_left_bg.png new file mode 100755 index 0000000..8dee9d8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_left_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_left_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_left_ef.png new file mode 100755 index 0000000..e22a1b3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_left_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_right_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_right_bg.png new file mode 100755 index 0000000..061c270 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_right_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_right_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_right_ef.png new file mode 100755 index 0000000..0e70530 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_right_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_top_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_top_bg.png new file mode 100755 index 0000000..ed639af Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_top_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_top_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_top_ef.png new file mode 100755 index 0000000..fea3a6f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_bubble_tail_top_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_popup_title_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_popup_title_bg.9.png new file mode 100755 index 0000000..b4be8c0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_popup_title_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_00.png b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_00.png new file mode 100755 index 0000000..0297d91 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_00.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_01.png new file mode 100755 index 0000000..3118e40 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_02.png b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_02.png new file mode 100755 index 0000000..3152a59 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_02.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_03.png b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_03.png new file mode 100755 index 0000000..7d6e2bd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_03.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_04.png b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_04.png new file mode 100755 index 0000000..b7fe4c3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_04.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_05.png b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_05.png new file mode 100755 index 0000000..b20cf11 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_05.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_06.png b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_06.png new file mode 100755 index 0000000..08a44fe Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_06.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_07.png b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_07.png new file mode 100755 index 0000000..d526460 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_07.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_08.png b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_08.png new file mode 100755 index 0000000..3d8fe4e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_08.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_09.png b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_09.png new file mode 100755 index 0000000..40987ba Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_processing_ani_52x52_09.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_progress.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_progress.9.png new file mode 100755 index 0000000..d2062a9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_progress.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_progress_bar.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_progress_bar.9.png new file mode 100644 index 0000000..7f8a38c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_progress_bar.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_progress_bar_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_progress_bar_ef.9.png new file mode 100644 index 0000000..ed7f99e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_progress_bar_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_progress_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_progress_bg.9.png new file mode 100644 index 0000000..b9550c8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_progress_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_progress_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_progress_ef.9.png new file mode 100755 index 0000000..1df40c8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_progress_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_progress_ef_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_progress_ef_bg.9.png new file mode 100644 index 0000000..8431c08 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_progress_ef_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_reorder_group_list_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_reorder_group_list_bg.9.png new file mode 100755 index 0000000..a464f33 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_reorder_group_list_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar.9.png new file mode 100644 index 0000000..7afa4f3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_ef.9.png new file mode 100644 index 0000000..6ae4958 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_handler_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_handler_bg.9.png new file mode 100755 index 0000000..1a3304f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_handler_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_handler_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_handler_bg_ef.9.png new file mode 100755 index 0000000..28f027d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_handler_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_handler_h.png b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_handler_h.png new file mode 100755 index 0000000..a909f20 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_handler_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_handler_v.png b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_handler_v.png new file mode 100755 index 0000000..03f3566 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_bar_handler_v.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_scroll_icon_jump.png b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_icon_jump.png new file mode 100755 index 0000000..2c97bc4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_icon_jump.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_scroll_icon_jump_left.png b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_icon_jump_left.png new file mode 100755 index 0000000..bb738d6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_scroll_icon_jump_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_search_clear_icon_normal.png b/res/common/usr/share/osp/bitmaps/480x800/00_search_clear_icon_normal.png new file mode 100755 index 0000000..3bafd02 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_search_clear_icon_normal.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_search_clear_icon_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_search_clear_icon_press.png new file mode 100755 index 0000000..6ae38e7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_search_clear_icon_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_search_edit_field_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_search_edit_field_bg.9.png new file mode 100644 index 0000000..4f20436a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_search_edit_field_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_search_edit_field_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_search_edit_field_bg_ef.9.png new file mode 100644 index 0000000..f7de001 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_search_edit_field_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_search_icon.png b/res/common/usr/share/osp/bitmaps/480x800/00_search_icon.png new file mode 100644 index 0000000..6e65d5b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_search_icon.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_search_icon_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_search_icon_ef.png new file mode 100644 index 0000000..d8d6f54 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_search_icon_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_seg_line.png b/res/common/usr/share/osp/bitmaps/480x800/00_seg_line.png new file mode 100755 index 0000000..316081f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_seg_line.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_seg_line_tr.png b/res/common/usr/share/osp/bitmaps/480x800/00_seg_line_tr.png new file mode 100755 index 0000000..0724911 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_seg_line_tr.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_bg.9.png new file mode 100755 index 0000000..ed8a75b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_bg_effect.9.png new file mode 100755 index 0000000..d064c76 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle.9.png new file mode 100755 index 0000000..8b6592f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle.png new file mode 100644 index 0000000..7c8f2db Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_dim.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_dim.png new file mode 100755 index 0000000..6ae009d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_ef.png new file mode 100644 index 0000000..0294853 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_ef_dim.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_ef_dim.png new file mode 100644 index 0000000..29b644a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_ef_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_ef_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_ef_press.png new file mode 100644 index 0000000..7f40f25 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_press.png new file mode 100755 index 0000000..c9b8ed9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_handle_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_popup_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_popup_bg.png new file mode 100644 index 0000000..6b43d18 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_popup_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_popup_bg_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_popup_bg_ef.png new file mode 100644 index 0000000..fa00c2c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_popup_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_popup_bottom_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_popup_bottom_bg.png new file mode 100644 index 0000000..b67f692 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_popup_bottom_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_slider_popup_bottom_bg_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_slider_popup_bottom_bg_ef.png new file mode 100644 index 0000000..5074a98 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_slider_popup_bottom_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_icon_add.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_icon_add.png new file mode 100644 index 0000000..4dc5c60 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_icon_add.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_icon_zoom.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_icon_zoom.png new file mode 100644 index 0000000..3e7f540 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_icon_zoom.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_bg.png new file mode 100644 index 0000000..21fda21 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_bg_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_bg_ef.png new file mode 100644 index 0000000..047f5c7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_bg_ef_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_bg_ef_press.png new file mode 100644 index 0000000..bbee11d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_bg_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_bg_p_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_bg_p_ef.png new file mode 100755 index 0000000..8fe83a2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_bg_p_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_text_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_text_bg.png new file mode 100644 index 0000000..6c81312 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_text_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_text_bg_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_text_bg_ef.png new file mode 100644 index 0000000..192c8c2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_text_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_text_bg_ef_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_text_bg_ef_press.png new file mode 100644 index 0000000..97c21dc Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_text_bg_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_text_bg_p_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_text_bg_p_ef.png new file mode 100755 index 0000000..eff4c33 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_left_text_bg_p_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_bg.png new file mode 100644 index 0000000..6551e3b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_bg_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_bg_ef.png new file mode 100644 index 0000000..8f64858 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_bg_ef_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_bg_ef_press.png new file mode 100644 index 0000000..4d3df0b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_bg_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_bg_p_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_bg_p_ef.png new file mode 100755 index 0000000..c61e577 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_bg_p_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_text_bg.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_text_bg.png new file mode 100644 index 0000000..0a03b37 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_text_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_text_bg_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_text_bg_ef.png new file mode 100644 index 0000000..30a9401 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_text_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_text_bg_ef_press.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_text_bg_ef_press.png new file mode 100644 index 0000000..b871be6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_text_bg_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_text_bg_p_ef.png b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_text_bg_p_ef.png new file mode 100755 index 0000000..84ea5b9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_softkey_right_text_bg_p_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_bg.9.png new file mode 100644 index 0000000..3f45f91 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_bg_ef_h.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_bg_ef_h.9.png new file mode 100644 index 0000000..ca4689e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_bg_ef_h.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_bg_ef_v.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_bg_ef_v.9.png new file mode 100644 index 0000000..ba6a19b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_bg_ef_v.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_h.png b/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_h.png new file mode 100644 index 0000000..a2d4c62 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_v.png b/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_v.png new file mode 100644 index 0000000..ae6fd33 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_splite_handler_v.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_tab_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_tab_bg.9.png new file mode 100644 index 0000000..27b873b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_tab_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_tab_focus.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_tab_focus.9.png new file mode 100644 index 0000000..68b47e8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_tab_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_tab_icon_more_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_tab_icon_more_01.png new file mode 100755 index 0000000..ceefaab Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_tab_icon_more_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_tab_icon_more_02.png b/res/common/usr/share/osp/bitmaps/480x800/00_tab_icon_more_02.png new file mode 100755 index 0000000..90f6707 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_tab_icon_more_02.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_tab_move_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_tab_move_bg.9.png new file mode 100755 index 0000000..20ec28f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_tab_move_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_tab_move_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_tab_move_bg_ef.9.png new file mode 100755 index 0000000..35249f7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_tab_move_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_tab_press_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_tab_press_ef.9.png new file mode 100644 index 0000000..2635b75 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_tab_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_thumbs_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_thumbs_bg_focus.9.png new file mode 100755 index 0000000..c73b844 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_thumbs_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_thumbs_line_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_thumbs_line_bg.9.png new file mode 100755 index 0000000..fc70524 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_thumbs_line_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_thumbs_loading_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_thumbs_loading_bg.9.png new file mode 100755 index 0000000..cffac37 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_thumbs_loading_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_tick_box_normal.png b/res/common/usr/share/osp/bitmaps/480x800/00_tick_box_normal.png new file mode 100755 index 0000000..cc03432 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_tick_box_normal.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_btn.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_btn.9.png new file mode 100755 index 0000000..c1b0ae9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_btn.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_btn_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_btn_effect.9.png new file mode 100755 index 0000000..841020e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_btn_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_btn_press_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_btn_press_effect.9.png new file mode 100755 index 0000000..700c2d0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_btn_press_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_keypad_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_keypad_bg.9.png new file mode 100755 index 0000000..5656bad Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_keypad_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_keypad_button_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_keypad_button_bg.9.png new file mode 100755 index 0000000..68da617 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_keypad_button_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_keypad_button_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_keypad_button_bg_ef.9.png new file mode 100755 index 0000000..d94c74e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_time_picker_keypad_button_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_timepicker_number_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_timepicker_number_bg.9.png new file mode 100755 index 0000000..41009da Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_timepicker_number_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_timepicker_tail.png b/res/common/usr/share/osp/bitmaps/480x800/00_timepicker_tail.png new file mode 100644 index 0000000..44fe43a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_timepicker_tail.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_timepicker_tail_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_timepicker_tail_01.png new file mode 100644 index 0000000..ce2ce53 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_timepicker_tail_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_title_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_title_bg.9.png new file mode 100755 index 0000000..27b873b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_title_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_title_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_title_bg_ef.9.png new file mode 100755 index 0000000..662181f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_title_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_title_btn_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_title_btn_bg.9.png new file mode 100755 index 0000000..3660e91 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_title_btn_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_title_btn_bg_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_title_btn_bg_press.9.png new file mode 100755 index 0000000..940d14c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_title_btn_bg_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_title_button_bg_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_title_button_bg_press.9.png new file mode 100755 index 0000000..089c760 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_title_button_bg_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_title_icon_more.png b/res/common/usr/share/osp/bitmaps/480x800/00_title_icon_more.png new file mode 100755 index 0000000..f395cb2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_title_icon_more.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_title_line.png b/res/common/usr/share/osp/bitmaps/480x800/00_title_line.png new file mode 100755 index 0000000..30c837e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_title_line.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_bg.9.png new file mode 100755 index 0000000..41009da Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_btn_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_btn_bg.9.png new file mode 100755 index 0000000..cf7a6be Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_btn_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_btn_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_btn_bg_ef.9.png new file mode 100755 index 0000000..34d0605 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_btn_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_btn_bg_p_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_btn_bg_p_ef.9.png new file mode 100755 index 0000000..6fb1c28 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_btn_bg_p_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button.9.png new file mode 100644 index 0000000..7584459 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_bg.9.png new file mode 100644 index 0000000..fef7449 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_bg_center.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_bg_center.9.png new file mode 100644 index 0000000..2a14dc7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_bg_center.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_bg_left.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_bg_left.9.png new file mode 100644 index 0000000..65fe1d2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_bg_left.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_bg_right.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_bg_right.9.png new file mode 100644 index 0000000..a12b54c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_bg_right.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_center_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_center_ef.9.png new file mode 100644 index 0000000..558a2fa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_center_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_center_press_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_center_press_ef.9.png new file mode 100644 index 0000000..f59c8d8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_center_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_ef.9.png new file mode 100644 index 0000000..198294e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_ef_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_ef_press.9.png new file mode 100644 index 0000000..5f57f47 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_left_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_left_ef.9.png new file mode 100644 index 0000000..422b034 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_left_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_left_ef_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_left_ef_press.9.png new file mode 100644 index 0000000..de8934b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_left_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_press.9.png new file mode 100644 index 0000000..34de8d2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_right_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_right_ef.9.png new file mode 100644 index 0000000..4d66dac Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_right_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_right_press_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_right_press_ef.9.png new file mode 100644 index 0000000..5ea7c49 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_button_right_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_line.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_line.png new file mode 100755 index 0000000..72edead Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_line.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_line_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_line_01.png new file mode 100644 index 0000000..241ac95 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_line_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_press.9.png new file mode 100755 index 0000000..b982efa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_center.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_center.9.png new file mode 100644 index 0000000..ef6633f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_center.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_center_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_center_press.9.png new file mode 100644 index 0000000..dfa75c0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_center_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_left.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_left.9.png new file mode 100644 index 0000000..8fb5561 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_left.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_left_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_left_press.9.png new file mode 100644 index 0000000..f324dca Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_left_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_right.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_right.9.png new file mode 100644 index 0000000..363f3c2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_right.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_right_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_right_press.9.png new file mode 100644 index 0000000..d524ed0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_toolbar_trans_button_right_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_transparent_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_transparent_bg.9.png new file mode 100755 index 0000000..1606d60 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_transparent_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_value_progress_bar.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_value_progress_bar.9.png new file mode 100755 index 0000000..5e24eb0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_value_progress_bar.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_value_progress_bar_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_value_progress_bar_effect.9.png new file mode 100755 index 0000000..678ad16 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_value_progress_bar_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_value_progress_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_value_progress_bg.9.png new file mode 100755 index 0000000..b0b6059 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_value_progress_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_value_progress_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_value_progress_bg_effect.9.png new file mode 100755 index 0000000..35a8b56 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_value_progress_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_Back_btn_normal.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_Back_btn_normal.9.png new file mode 100755 index 0000000..2197826 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_Back_btn_normal.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_Back_btn_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_Back_btn_press.9.png new file mode 100755 index 0000000..29fa717 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_Back_btn_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_badge.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_badge.9.png new file mode 100755 index 0000000..15d51bb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_badge.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_control_tabbar_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_control_tabbar_bg.9.png new file mode 100755 index 0000000..abccffc Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_control_tabbar_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_control_toolbar_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_control_toolbar_bg.9.png new file mode 100755 index 0000000..a65a4b2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_control_toolbar_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_divider_line.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_divider_line.9.png new file mode 100755 index 0000000..58b1438 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_divider_line.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_01.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_01.png new file mode 100755 index 0000000..ca83022 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_01_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_01_32x32.png new file mode 100755 index 0000000..556fd00 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_01_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_02.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_02.png new file mode 100755 index 0000000..39f1815 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_02.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_02_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_02_32x32.png new file mode 100755 index 0000000..e3f6661 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_02_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_03.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_03.png new file mode 100755 index 0000000..fe26b18 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_03.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_03_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_03_32x32.png new file mode 100755 index 0000000..aabd74d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_03_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_04.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_04.png new file mode 100755 index 0000000..c486331 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_04.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_04_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_04_32x32.png new file mode 100755 index 0000000..6752381 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_04_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_05.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_05.png new file mode 100755 index 0000000..194bf24 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_05.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_05_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_05_32x32.png new file mode 100755 index 0000000..026bf39 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_05_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_06.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_06.png new file mode 100755 index 0000000..b9501fe Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_06.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_06_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_06_32x32.png new file mode 100755 index 0000000..76ad804 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_06_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_07.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_07.png new file mode 100755 index 0000000..2ae3041 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_07.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_07_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_07_32x32.png new file mode 100755 index 0000000..3ff8e86 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_07_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_08.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_08.png new file mode 100755 index 0000000..0c0d8f4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_08.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_08_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_08_32x32.png new file mode 100755 index 0000000..35964af Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_08_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_09.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_09.png new file mode 100755 index 0000000..767f140 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_09.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_09_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_09_32x32.png new file mode 100755 index 0000000..acc0e33 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_09_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_10.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_10.png new file mode 100755 index 0000000..ebe9fee Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_10.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_10_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_10_32x32.png new file mode 100755 index 0000000..732ab34 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_10_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_11.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_11.png new file mode 100755 index 0000000..905a9d0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_11.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_11_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_11_32x32.png new file mode 100755 index 0000000..5bb451a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_11_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_12.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_12.png new file mode 100755 index 0000000..6c3dcac Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_12.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_12_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_12_32x32.png new file mode 100755 index 0000000..d411a19 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_12_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_13.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_13.png new file mode 100755 index 0000000..7712265 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_13.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_13_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_13_32x32.png new file mode 100755 index 0000000..4df5086 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_13_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_14.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_14.png new file mode 100755 index 0000000..459293f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_14.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_14_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_14_32x32.png new file mode 100755 index 0000000..eda2bb4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_14_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_15.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_15.png new file mode 100755 index 0000000..1e5ed6f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_15.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_15_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_15_32x32.png new file mode 100755 index 0000000..5a1225e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_15_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_16.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_16.png new file mode 100755 index 0000000..3d28ca7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_16.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_16_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_16_32x32.png new file mode 100755 index 0000000..3fb7f2b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_16_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_17.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_17.png new file mode 100755 index 0000000..137d3ea Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_17.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_17_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_17_32x32.png new file mode 100755 index 0000000..d40c3a4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_17_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_18.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_18.png new file mode 100755 index 0000000..bb22bbc Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_18.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_18_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_18_32x32.png new file mode 100755 index 0000000..b6f87c0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_18_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_19.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_19.png new file mode 100755 index 0000000..de0ea44 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_19.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_19_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_19_32x32.png new file mode 100755 index 0000000..e06e91c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_19_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_20.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_20.png new file mode 100755 index 0000000..02542e6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_20.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_20_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_20_32x32.png new file mode 100755 index 0000000..b7fea9c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_20_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_21.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_21.png new file mode 100755 index 0000000..baa770b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_21.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_21_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_21_32x32.png new file mode 100755 index 0000000..9b953a6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_21_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_22.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_22.png new file mode 100755 index 0000000..01f36aa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_22.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_22_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_22_32x32.png new file mode 100755 index 0000000..e4da281 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_22_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_23.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_23.png new file mode 100755 index 0000000..cb677e1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_23.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_23_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_23_32x32.png new file mode 100755 index 0000000..a63c879 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_23_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_24.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_24.png new file mode 100755 index 0000000..2a3b94e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_24.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_24_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_24_32x32.png new file mode 100755 index 0000000..d3c8964 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_24_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_25.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_25.png new file mode 100755 index 0000000..1e875c4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_25.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_25_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_25_32x32.png new file mode 100755 index 0000000..480b0b4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_25_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_26.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_26.png new file mode 100755 index 0000000..afd7abd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_26.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_26_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_26_32x32.png new file mode 100755 index 0000000..73a1a83 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_26_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_27.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_27.png new file mode 100755 index 0000000..940229a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_27.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_27_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_27_32x32.png new file mode 100755 index 0000000..c06818a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_27_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_28.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_28.png new file mode 100755 index 0000000..ce23b0d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_28.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_28_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_28_32x32.png new file mode 100755 index 0000000..015dda9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_28_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_29.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_29.png new file mode 100755 index 0000000..b5d29fc Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_29.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_29_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_29_32x32.png new file mode 100755 index 0000000..01d8f98 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_29_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_30.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_30.png new file mode 100755 index 0000000..762a1fe Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_30.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_30_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_30_32x32.png new file mode 100755 index 0000000..8633efe Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_list_process_30_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_thumbs_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_thumbs_bg.9.png new file mode 100755 index 0000000..463401a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_thumbs_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/00_winset_title_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/00_winset_title_bg.9.png new file mode 100755 index 0000000..0e5ea48 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/00_winset_title_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/04_textinput_qwerty_button.9.png b/res/common/usr/share/osp/bitmaps/480x800/04_textinput_qwerty_button.9.png new file mode 100755 index 0000000..521b9c5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/04_textinput_qwerty_button.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/04_textinput_qwerty_button_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/04_textinput_qwerty_button_01.9.png new file mode 100755 index 0000000..de496ad Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/04_textinput_qwerty_button_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/04_textinput_qwerty_button_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/04_textinput_qwerty_button_press.9.png new file mode 100755 index 0000000..82f66a7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/04_textinput_qwerty_button_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/Off_Background#5.png b/res/common/usr/share/osp/bitmaps/480x800/Off_Background#5.png new file mode 100755 index 0000000..09c9745 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/Off_Background#5.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/On_Background#5.png b/res/common/usr/share/osp/bitmaps/480x800/On_Background#5.png new file mode 100755 index 0000000..2d23ccb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/On_Background#5.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/TTS_focus.9.png b/res/common/usr/share/osp/bitmaps/480x800/TTS_focus.9.png new file mode 100755 index 0000000..575f34c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/TTS_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/TTS_popup_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/TTS_popup_bg.9.png new file mode 100755 index 0000000..f52341f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/TTS_popup_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_btn_circle_bg_ef.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_btn_circle_bg_ef.png new file mode 100755 index 0000000..e81ddc4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_btn_circle_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_button_01_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_01_bg_ef.9.png new file mode 100755 index 0000000..2d26162 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_01_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_button_edit_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_edit_bg_ef.9.png new file mode 100755 index 0000000..3973542 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_edit_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_button_radio_normal1.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_radio_normal1.png new file mode 100755 index 0000000..333c580 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_radio_normal1.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_button_radio_normal2.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_radio_normal2.png new file mode 100755 index 0000000..c1ad8c6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_radio_normal2.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_button_seg_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_seg_bg_ef.9.png new file mode 100755 index 0000000..e8332b1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_seg_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_button_seg_f_bg_ef_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_seg_f_bg_ef_01.9.png new file mode 100755 index 0000000..d115036 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_seg_f_bg_ef_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_button_seg_f_bg_ef_02.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_seg_f_bg_ef_02.9.png new file mode 100755 index 0000000..5189da4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_seg_f_bg_ef_02.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_button_seg_f_bg_ef_03.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_seg_f_bg_ef_03.9.png new file mode 100755 index 0000000..6c4dc61 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_button_seg_f_bg_ef_03.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_check_bg.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_check_bg.png new file mode 100755 index 0000000..5be91b5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_check_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_color_picker_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_color_picker_bg.9.png new file mode 100755 index 0000000..9dfd622 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_color_picker_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_dialogue_group_bg_line.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_dialogue_group_bg_line.9.png new file mode 100755 index 0000000..18f2710 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_dialogue_group_bg_line.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_edit_field_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_edit_field_bg_ef.9.png new file mode 100755 index 0000000..6355279 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_edit_field_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_groupedlist_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_groupedlist_bg_01.9.png new file mode 100755 index 0000000..f4f94aa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_groupedlist_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_groupedlist_bottom_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_groupedlist_bottom_bg_01.9.png new file mode 100755 index 0000000..01a9880 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_groupedlist_bottom_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_groupedlist_center_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_groupedlist_center_bg_01.9.png new file mode 100755 index 0000000..d03c12d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_groupedlist_center_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_groupedlist_top_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_groupedlist_top_bg_01.9.png new file mode 100755 index 0000000..35b53e4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_groupedlist_top_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_indexlist_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_indexlist_bg_ef.9.png new file mode 100755 index 0000000..eb3b854 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_indexlist_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_indexlist_icon_line.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_indexlist_icon_line.png new file mode 100755 index 0000000..7205482 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_indexlist_icon_line.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_01_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_01_32x32.png new file mode 100644 index 0000000..556fd00 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_01_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_02_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_02_32x32.png new file mode 100644 index 0000000..e3f6661 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_02_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_03_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_03_32x32.png new file mode 100644 index 0000000..aabd74d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_03_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_04_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_04_32x32.png new file mode 100644 index 0000000..6752381 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_04_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_05_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_05_32x32.png new file mode 100644 index 0000000..026bf39 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_05_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_06_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_06_32x32.png new file mode 100644 index 0000000..76ad804 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_06_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_07_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_07_32x32.png new file mode 100644 index 0000000..3ff8e86 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_07_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_08_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_08_32x32.png new file mode 100644 index 0000000..35964af Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_08_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_09_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_09_32x32.png new file mode 100644 index 0000000..acc0e33 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_09_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_10_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_10_32x32.png new file mode 100644 index 0000000..732ab34 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_10_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_11_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_11_32x32.png new file mode 100644 index 0000000..5bb451a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_11_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_12_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_12_32x32.png new file mode 100644 index 0000000..d411a19 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_12_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_13_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_13_32x32.png new file mode 100644 index 0000000..4df5086 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_13_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_14_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_14_32x32.png new file mode 100644 index 0000000..eda2bb4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_14_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_15_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_15_32x32.png new file mode 100644 index 0000000..5a1225e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_15_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_16_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_16_32x32.png new file mode 100644 index 0000000..3fb7f2b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_16_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_17_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_17_32x32.png new file mode 100644 index 0000000..d40c3a4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_17_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_18_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_18_32x32.png new file mode 100644 index 0000000..b6f87c0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_18_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_19_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_19_32x32.png new file mode 100644 index 0000000..e06e91c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_19_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_20_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_20_32x32.png new file mode 100644 index 0000000..b7fea9c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_20_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_21_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_21_32x32.png new file mode 100644 index 0000000..9b953a6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_21_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_22_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_22_32x32.png new file mode 100644 index 0000000..e4da281 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_22_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_23_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_23_32x32.png new file mode 100644 index 0000000..a63c879 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_23_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_24_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_24_32x32.png new file mode 100644 index 0000000..d3c8964 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_24_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_25_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_25_32x32.png new file mode 100644 index 0000000..480b0b4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_25_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_26_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_26_32x32.png new file mode 100644 index 0000000..73a1a83 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_26_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_27_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_27_32x32.png new file mode 100644 index 0000000..c06818a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_27_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_28_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_28_32x32.png new file mode 100644 index 0000000..015dda9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_28_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_29_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_29_32x32.png new file mode 100644 index 0000000..01d8f98 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_29_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_30_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_30_32x32.png new file mode 100644 index 0000000..8633efe Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_list_process_30_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bg_ef.9.png new file mode 100755 index 0000000..2b4a8bc Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bottom_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bottom_bg.9.png new file mode 100755 index 0000000..31b9ea4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bottom_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_bg_ef.9.png new file mode 100755 index 0000000..b1e219d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_tail_bottom_ef.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_tail_bottom_ef.png new file mode 100755 index 0000000..3f5688b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_tail_bottom_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_tail_left_ef.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_tail_left_ef.png new file mode 100755 index 0000000..f9ce89a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_tail_left_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_tail_right_ef.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_tail_right_ef.png new file mode 100755 index 0000000..68f1437 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_tail_right_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_tail_top_ef.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_tail_top_ef.png new file mode 100755 index 0000000..5b2d7b8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_bubble_tail_top_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_button_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_button_bg_ef.9.png new file mode 100755 index 0000000..2d26162 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_button_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_title_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_title_bg.9.png new file mode 100755 index 0000000..e8f397f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_title_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_title_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_title_bg_ef.9.png new file mode 100755 index 0000000..729a6b9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_popup_title_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_reorder_group_list_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_reorder_group_list_bg.9.png new file mode 100755 index 0000000..9f92081 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_reorder_group_list_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_scroll_bar_handler_h.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_scroll_bar_handler_h.png new file mode 100755 index 0000000..7075599 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_scroll_bar_handler_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_scroll_bar_handler_v.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_scroll_bar_handler_v.png new file mode 100755 index 0000000..1e99694 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_scroll_bar_handler_v.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_slider_handle_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_slider_handle_bg_ef.9.png new file mode 100755 index 0000000..fb9e4d9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_slider_handle_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_tab_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_tab_bg_ef.9.png new file mode 100755 index 0000000..13dcf9d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_tab_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_tab_bg_focus_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_tab_bg_focus_ef.9.png new file mode 100755 index 0000000..a311322 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_tab_bg_focus_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_tab_bg_line_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_tab_bg_line_ef.9.png new file mode 100755 index 0000000..c3bb641 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_tab_bg_line_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_title_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_title_bg_ef.9.png new file mode 100755 index 0000000..9673508 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_title_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_title_btn_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_title_btn_bg_ef.9.png new file mode 100755 index 0000000..d115036 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_title_btn_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_title_button_bg_ef_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_title_button_bg_ef_press.9.png new file mode 100755 index 0000000..f7d7e75 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_title_button_bg_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_title_option_btn_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_title_option_btn_bg_ef.9.png new file mode 100755 index 0000000..9858d2d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_title_option_btn_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_bg_ef.9.png new file mode 100755 index 0000000..a1d1010 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_ef_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_ef_press.9.png new file mode 100755 index 0000000..bcd01e5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_press_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_press_ef.9.png new file mode 100755 index 0000000..bcd01e5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_tab_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_tab_bg_ef.9.png new file mode 100755 index 0000000..054e85e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_tab_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_tab_bg_focus_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_tab_bg_focus_ef.9.png new file mode 100755 index 0000000..2031712 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_tab_bg_focus_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_tab_bg_line_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_tab_bg_line_ef.9.png new file mode 100755 index 0000000..e5eb4b9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_toolbar_tab_bg_line_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/black/00_winset_badge.9.png b/res/common/usr/share/osp/bitmaps/480x800/black/00_winset_badge.9.png new file mode 100755 index 0000000..6d21d4e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/black/00_winset_badge.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon02_left.png b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon02_left.png new file mode 100755 index 0000000..863c1f6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon02_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon02_left_press.png b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon02_left_press.png new file mode 100755 index 0000000..7e94e5f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon02_left_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon02_right.png b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon02_right.png new file mode 100755 index 0000000..8e6673c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon02_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon02_right_press.png b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon02_right_press.png new file mode 100755 index 0000000..ab6b886 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon02_right_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon_left.png b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon_left.png new file mode 100755 index 0000000..f632684 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon_left_press.png b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon_left_press.png new file mode 100755 index 0000000..24d3570 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon_left_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon_right.png b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon_right.png new file mode 100755 index 0000000..e9df81d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon_right_press.png b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon_right_press.png new file mode 100755 index 0000000..a81b556 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_Icon_right_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/copy&paste_icon_search.png b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_icon_search.png new file mode 100644 index 0000000..d5db307 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/copy&paste_icon_search.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_btn_circle_bg_ef.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_btn_circle_bg_ef.png new file mode 100755 index 0000000..51c78e1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_btn_circle_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_button_01_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_01_bg_ef.9.png new file mode 100755 index 0000000..2ab934f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_01_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_button_edit_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_edit_bg_ef.9.png new file mode 100755 index 0000000..2294c60 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_edit_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_button_radio_normal1.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_radio_normal1.png new file mode 100755 index 0000000..717df03 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_radio_normal1.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_button_radio_normal2.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_radio_normal2.png new file mode 100755 index 0000000..0644a2e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_radio_normal2.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_button_seg_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_seg_bg_ef.9.png new file mode 100755 index 0000000..144f0db Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_seg_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_button_seg_f_bg_ef_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_seg_f_bg_ef_01.9.png new file mode 100755 index 0000000..9856e1e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_seg_f_bg_ef_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_button_seg_f_bg_ef_02.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_seg_f_bg_ef_02.9.png new file mode 100755 index 0000000..49c6f1b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_seg_f_bg_ef_02.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_button_seg_f_bg_ef_03.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_seg_f_bg_ef_03.9.png new file mode 100755 index 0000000..9b8d022 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_button_seg_f_bg_ef_03.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_check_bg.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_check_bg.png new file mode 100755 index 0000000..e299b87 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_check_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_color_picker_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_color_picker_bg.9.png new file mode 100755 index 0000000..3ae794d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_color_picker_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_dialogue_group_bg_line.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_dialogue_group_bg_line.9.png new file mode 100755 index 0000000..107016f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_dialogue_group_bg_line.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_edit_field_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_edit_field_bg_ef.9.png new file mode 100755 index 0000000..96a0065 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_edit_field_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_groupedlist_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_groupedlist_bg_01.9.png new file mode 100755 index 0000000..91d1279 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_groupedlist_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_groupedlist_bottom_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_groupedlist_bottom_bg_01.9.png new file mode 100755 index 0000000..7719a80 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_groupedlist_bottom_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_groupedlist_center_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_groupedlist_center_bg_01.9.png new file mode 100755 index 0000000..d8a481f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_groupedlist_center_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_groupedlist_top_bg_01.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_groupedlist_top_bg_01.9.png new file mode 100755 index 0000000..046bf3a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_groupedlist_top_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_indexlist_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_indexlist_bg_ef.9.png new file mode 100755 index 0000000..5254498 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_indexlist_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_indexlist_icon_line.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_indexlist_icon_line.png new file mode 100755 index 0000000..ac6eb1f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_indexlist_icon_line.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_01_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_01_32x32.png new file mode 100644 index 0000000..92d3686 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_01_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_02_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_02_32x32.png new file mode 100644 index 0000000..3cba306 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_02_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_03_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_03_32x32.png new file mode 100644 index 0000000..9babc31 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_03_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_04_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_04_32x32.png new file mode 100644 index 0000000..3c72df5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_04_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_05_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_05_32x32.png new file mode 100644 index 0000000..bbb14cd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_05_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_06_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_06_32x32.png new file mode 100644 index 0000000..3719b53 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_06_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_07_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_07_32x32.png new file mode 100644 index 0000000..009b81f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_07_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_08_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_08_32x32.png new file mode 100644 index 0000000..4a32e15 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_08_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_09_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_09_32x32.png new file mode 100644 index 0000000..aed8bf2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_09_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_10_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_10_32x32.png new file mode 100644 index 0000000..f6f3194 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_10_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_11_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_11_32x32.png new file mode 100644 index 0000000..54db6c9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_11_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_12_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_12_32x32.png new file mode 100644 index 0000000..284b090 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_12_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_13_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_13_32x32.png new file mode 100644 index 0000000..09c9aa9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_13_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_14_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_14_32x32.png new file mode 100644 index 0000000..cd075b3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_14_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_15_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_15_32x32.png new file mode 100644 index 0000000..885030c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_15_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_16_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_16_32x32.png new file mode 100644 index 0000000..26a877a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_16_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_17_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_17_32x32.png new file mode 100644 index 0000000..ff746b7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_17_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_18_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_18_32x32.png new file mode 100644 index 0000000..07aeffd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_18_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_19_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_19_32x32.png new file mode 100644 index 0000000..16a9e1b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_19_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_20_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_20_32x32.png new file mode 100644 index 0000000..b409b03 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_20_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_21_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_21_32x32.png new file mode 100644 index 0000000..d5de1fb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_21_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_22_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_22_32x32.png new file mode 100644 index 0000000..fae4ddd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_22_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_23_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_23_32x32.png new file mode 100644 index 0000000..02d9314 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_23_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_24_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_24_32x32.png new file mode 100644 index 0000000..ff35805 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_24_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_25_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_25_32x32.png new file mode 100644 index 0000000..e027879 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_25_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_26_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_26_32x32.png new file mode 100644 index 0000000..bb86e11 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_26_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_27_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_27_32x32.png new file mode 100644 index 0000000..f2c2e5b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_27_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_28_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_28_32x32.png new file mode 100644 index 0000000..759af64 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_28_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_29_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_29_32x32.png new file mode 100644 index 0000000..42d4c29 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_29_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_30_32x32.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_30_32x32.png new file mode 100644 index 0000000..e78bff4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_list_process_30_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bg_ef.9.png new file mode 100755 index 0000000..68a2b9f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bottom_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bottom_bg.9.png new file mode 100755 index 0000000..549e5ed Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bottom_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_bg_ef.9.png new file mode 100755 index 0000000..726ba72 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_tail_bottom_ef.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_tail_bottom_ef.png new file mode 100755 index 0000000..c75ab53 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_tail_bottom_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_tail_left_ef.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_tail_left_ef.png new file mode 100755 index 0000000..7699e81 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_tail_left_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_tail_right_ef.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_tail_right_ef.png new file mode 100755 index 0000000..072a66d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_tail_right_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_tail_top_ef.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_tail_top_ef.png new file mode 100755 index 0000000..7396d5d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_bubble_tail_top_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_button_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_button_bg_ef.9.png new file mode 100755 index 0000000..2ab934f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_button_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_title_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_title_bg.9.png new file mode 100755 index 0000000..f08f763 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_title_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_title_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_title_bg_ef.9.png new file mode 100755 index 0000000..de65213 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_popup_title_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_reorder_group_list_bg.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_reorder_group_list_bg.9.png new file mode 100755 index 0000000..8598ba7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_reorder_group_list_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_scroll_bar_handler_h.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_scroll_bar_handler_h.png new file mode 100755 index 0000000..a909f20 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_scroll_bar_handler_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_scroll_bar_handler_v.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_scroll_bar_handler_v.png new file mode 100755 index 0000000..03f3566 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_scroll_bar_handler_v.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_slider_handle_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_slider_handle_bg_ef.9.png new file mode 100755 index 0000000..6cd956c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_slider_handle_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_title_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_title_bg_ef.9.png new file mode 100755 index 0000000..662181f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_title_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_title_btn_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_title_btn_bg_ef.9.png new file mode 100755 index 0000000..fc5196f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_title_btn_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_title_button_bg_ef_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_title_button_bg_ef_press.9.png new file mode 100755 index 0000000..63a0203 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_title_button_bg_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_title_option_btn_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_title_option_btn_bg_ef.9.png new file mode 100755 index 0000000..144f0db Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_title_option_btn_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_bg_ef.9.png new file mode 100755 index 0000000..062aa34 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_ef_press.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_ef_press.9.png new file mode 100755 index 0000000..30ab16e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_press_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_press_ef.9.png new file mode 100755 index 0000000..30ab16e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_tab_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_tab_bg_ef.9.png new file mode 100755 index 0000000..ec0e890 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_tab_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_tab_bg_focus_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_tab_bg_focus_ef.9.png new file mode 100755 index 0000000..8c0593e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_tab_bg_focus_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_tab_bg_line_ef.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_tab_bg_line_ef.9.png new file mode 100755 index 0000000..8ac0c42 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_toolbar_tab_bg_line_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/480x800/white/00_winset_badge.9.png b/res/common/usr/share/osp/bitmaps/480x800/white/00_winset_badge.9.png new file mode 100755 index 0000000..5f11f65 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/480x800/white/00_winset_badge.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_Title_btn.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_Title_btn.9.png new file mode 100755 index 0000000..637904c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_Title_btn.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_Title_btn_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_Title_btn_press.9.png new file mode 100755 index 0000000..72c6284 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_Title_btn_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_arrow_button_press_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_arrow_button_press_bg.9.png new file mode 100755 index 0000000..27b873b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_arrow_button_press_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_arrow_button_press_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_arrow_button_press_ef.9.png new file mode 100755 index 0000000..8219317 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_arrow_button_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_arrow_left.png b/res/common/usr/share/osp/bitmaps/720x1280/00_arrow_left.png new file mode 100644 index 0000000..698bce9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_arrow_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_arrow_right.png b/res/common/usr/share/osp/bitmaps/720x1280/00_arrow_right.png new file mode 100644 index 0000000..a176c42 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_arrow_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_badge_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_badge_bg.9.png new file mode 100644 index 0000000..8bf6192 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_badge_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_badge_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_badge_bg_ef.9.png new file mode 100644 index 0000000..5ebfbee Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_badge_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_btn_circle_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_btn_circle_bg.png new file mode 100755 index 0000000..1693f7d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_btn_circle_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_btn_circle_bg_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_btn_circle_bg_ef.png new file mode 100755 index 0000000..d249135 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_btn_circle_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_btn_circle_bg_p_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_btn_circle_bg_p_ef.png new file mode 100755 index 0000000..9d16b9c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_btn_circle_bg_p_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_01.9.png new file mode 100644 index 0000000..eb0fd8b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_bg.9.png new file mode 100755 index 0000000..8ffbf20 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_bg_p_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_bg_p_ef.9.png new file mode 100755 index 0000000..46f901d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_bg_p_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_ef.9.png new file mode 100644 index 0000000..ec4b775 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_ef_dim.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_ef_dim.9.png new file mode 100644 index 0000000..0e5238a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_ef_dim.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_ef_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_ef_press.9.png new file mode 100644 index 0000000..2285b3e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_01_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_02.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_02.9.png new file mode 100644 index 0000000..3536d22 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_02.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_02_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_02_ef.9.png new file mode 100644 index 0000000..11dfdf6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_02_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_02_ef_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_02_ef_press.9.png new file mode 100644 index 0000000..c4774d5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_02_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_03.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_03.9.png new file mode 100644 index 0000000..71756ae Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_03.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_03_dim_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_03_dim_ef.9.png new file mode 100644 index 0000000..4749b1f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_03_dim_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_03_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_03_ef.9.png new file mode 100644 index 0000000..4749b1f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_03_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_03_ef_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_03_ef_press.9.png new file mode 100644 index 0000000..1d97aec Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_03_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_06_dim.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_06_dim.9.png new file mode 100755 index 0000000..450ed67 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_06_dim.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_06_normal.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_06_normal.9.png new file mode 100755 index 0000000..355f50d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_06_normal.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_06_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_06_press.9.png new file mode 100755 index 0000000..2bae489 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_06_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_call.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_call.png new file mode 100644 index 0000000..3664975 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_call.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_call_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_call_ef.png new file mode 100644 index 0000000..f82b727 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_call_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_cancel.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_cancel.png new file mode 100755 index 0000000..4f48af4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_cancel.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_cancel.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_cancel.png new file mode 100644 index 0000000..14141a1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_cancel.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_cancel_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_cancel_ef.png new file mode 100644 index 0000000..4450f61 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_cancel_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_closed.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_closed.png new file mode 100644 index 0000000..4e392fb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_closed.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_closed_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_closed_ef.png new file mode 100644 index 0000000..7fc420e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_closed_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_minus.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_minus.png new file mode 100644 index 0000000..76582f3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_minus.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_minus_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_minus_ef.png new file mode 100644 index 0000000..549f0e2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_minus_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_opened.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_opened.png new file mode 100644 index 0000000..86565d2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_opened.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_opened_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_opened_ef.png new file mode 100644 index 0000000..fba762c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_opened_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_send.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_send.png new file mode 100644 index 0000000..23838c2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_send.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_send_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_send_ef.png new file mode 100644 index 0000000..38548e1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_expand_send_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_info.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_info.png new file mode 100644 index 0000000..1e4e013 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_info.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_info_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_info_ef.png new file mode 100644 index 0000000..49ce801 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_info_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_left.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_left.png new file mode 100644 index 0000000..05833b3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_left_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_left_ef.png new file mode 100644 index 0000000..e805dd4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_left_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_minus.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_minus.png new file mode 100755 index 0000000..da42b24 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_minus.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_normal.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_normal.9.png new file mode 100755 index 0000000..d64969f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_normal.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_normal_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_normal_bg.9.png new file mode 100755 index 0000000..325b542 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_normal_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_normal_effect_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_normal_effect_01.9.png new file mode 100755 index 0000000..87f9a6c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_normal_effect_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_off.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_off.png new file mode 100644 index 0000000..da82063 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_off.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_off_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_off_01.png new file mode 100755 index 0000000..ffa057d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_off_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_off_dim.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_off_dim.png new file mode 100644 index 0000000..207fb76 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_off_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_off_dim_temp.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_off_dim_temp.png new file mode 100644 index 0000000..207fb76 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_off_dim_temp.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_off_temp.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_off_temp.png new file mode 100644 index 0000000..74cce92 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_off_temp.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_on.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_on.png new file mode 100644 index 0000000..7ad2614 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_on.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_01.png new file mode 100755 index 0000000..35cdc63 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_dim.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_dim.png new file mode 100644 index 0000000..2c0be37 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_dim_temp.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_dim_temp.png new file mode 100644 index 0000000..2c0be37 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_dim_temp.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_off_handler.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_off_handler.png new file mode 100644 index 0000000..d17f283 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_off_handler.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_temp.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_temp.png new file mode 100644 index 0000000..88d5618 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_on_temp.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_plus.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_plus.png new file mode 100644 index 0000000..6ba5a3b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_plus.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_plus_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_plus_ef.png new file mode 100644 index 0000000..613b8cb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_plus_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio.png new file mode 100644 index 0000000..5ab6c09 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_dim.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_dim.png new file mode 100644 index 0000000..a3ca80d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_normal1.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_normal1.png new file mode 100755 index 0000000..5295687 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_normal1.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_normal2.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_normal2.png new file mode 100755 index 0000000..e80b3a8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_normal2.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_press.png new file mode 100644 index 0000000..8384ac0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_press1.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_press1.png new file mode 100755 index 0000000..7e5a8a1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_press1.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_press2.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_press2.png new file mode 100755 index 0000000..49a92d9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_press2.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_select.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_select.png new file mode 100644 index 0000000..4fd17d0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_select.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_select_dim.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_select_dim.png new file mode 100644 index 0000000..1a37a82 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_radio_select_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_rename.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_rename.png new file mode 100644 index 0000000..39a9e71 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_rename.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_rename_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_rename_ef.png new file mode 100644 index 0000000..129dace Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_rename_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_reveal.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_reveal.png new file mode 100755 index 0000000..600bc9d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_reveal.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_right.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_right.png new file mode 100644 index 0000000..13c3c06 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_right_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_right_ef.png new file mode 100644 index 0000000..adabc3d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_right_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_01.9.png new file mode 100755 index 0000000..935687c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_02.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_02.9.png new file mode 100755 index 0000000..46e03a1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_02.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_03.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_03.9.png new file mode 100755 index 0000000..e98ea71 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_03.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_ef_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_ef_01.9.png new file mode 100755 index 0000000..7335e58 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_ef_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_ef_02.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_ef_02.9.png new file mode 100755 index 0000000..ab83fdb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_ef_02.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_ef_03.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_ef_03.9.png new file mode 100755 index 0000000..7666f17 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_seg_f_bg_ef_03.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_send.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_send.png new file mode 100755 index 0000000..74e07e4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_send.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_warning.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_warning.png new file mode 100755 index 0000000..ac50dae Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_warning.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_warring.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_warring.png new file mode 100644 index 0000000..7e63d67 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_warring.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_warring_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_warring_ef.png new file mode 100644 index 0000000..358c8af Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_warring_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_web.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_web.9.png new file mode 100644 index 0000000..04eeaca Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_web.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_button_web_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_button_web_press.9.png new file mode 100644 index 0000000..99b3abb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_button_web_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_bg.9.png new file mode 100755 index 0000000..200a7e1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_button.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_button.9.png new file mode 100644 index 0000000..afba73c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_button.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_button_focus.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_button_focus.9.png new file mode 100644 index 0000000..29b077d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_button_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_left_button.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_left_button.png new file mode 100755 index 0000000..7b7a58d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_left_button.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_left_button_arrow.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_left_button_arrow.png new file mode 100755 index 0000000..970ca8b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_left_button_arrow.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_left_gd.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_left_gd.png new file mode 100755 index 0000000..7b7a58d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_left_gd.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_left_gradation.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_left_gradation.png new file mode 100644 index 0000000..e4345f5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_left_gradation.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_panel_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_panel_bg.9.png new file mode 100644 index 0000000..f9a37b3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_panel_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_panel_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_panel_bg_ef.9.png new file mode 100644 index 0000000..162e8e6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_panel_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_right_button.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_right_button.png new file mode 100755 index 0000000..f4b75b6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_right_button.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_right_button_arrow.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_right_button_arrow.png new file mode 100755 index 0000000..8d37079 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_right_button_arrow.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_right_gd.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_right_gd.png new file mode 100755 index 0000000..f4b75b6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_right_gd.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_category_right_gradation.png b/res/common/usr/share/osp/bitmaps/720x1280/00_category_right_gradation.png new file mode 100644 index 0000000..d36d07c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_category_right_gradation.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_check.png b/res/common/usr/share/osp/bitmaps/720x1280/00_check.png new file mode 100755 index 0000000..c4b61da Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_check.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_check_angle.png b/res/common/usr/share/osp/bitmaps/720x1280/00_check_angle.png new file mode 100755 index 0000000..ed0efb8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_check_angle.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_check_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_check_bg.png new file mode 100644 index 0000000..df4de40 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_check_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_check_bg_dim.png b/res/common/usr/share/osp/bitmaps/720x1280/00_check_bg_dim.png new file mode 100644 index 0000000..edc25fe Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_check_bg_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_check_bg_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_check_bg_press.png new file mode 100644 index 0000000..693abcf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_check_bg_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_check_checking.png b/res/common/usr/share/osp/bitmaps/720x1280/00_check_checking.png new file mode 100644 index 0000000..92c9b4d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_check_checking.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_check_checking_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_check_checking_bg.png new file mode 100755 index 0000000..9bcb1a5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_check_checking_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_check_checking_dim.png b/res/common/usr/share/osp/bitmaps/720x1280/00_check_checking_dim.png new file mode 100644 index 0000000..f04b739 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_check_checking_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_check_dim.png b/res/common/usr/share/osp/bitmaps/720x1280/00_check_dim.png new file mode 100755 index 0000000..8f64005 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_check_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_check_index_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_check_index_bg.png new file mode 100755 index 0000000..2aff1e9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_check_index_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_circle_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_circle_bg.png new file mode 100644 index 0000000..629b7d9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_circle_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_circle_bg_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_circle_bg_ef.png new file mode 100644 index 0000000..8d81e9d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_circle_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_circle_bg_ef_dim.png b/res/common/usr/share/osp/bitmaps/720x1280/00_circle_bg_ef_dim.png new file mode 100644 index 0000000..aeac2c2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_circle_bg_ef_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_circle_bg_ef_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_circle_bg_ef_press.png new file mode 100644 index 0000000..53155ce Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_circle_bg_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_brightness.png b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_brightness.png new file mode 100644 index 0000000..fd8e44d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_brightness.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_brightness_h.png b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_brightness_h.png new file mode 100644 index 0000000..a163521 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_brightness_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_btn_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_btn_bg.9.png new file mode 100755 index 0000000..d64969f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_btn_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_btn_left.png b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_btn_left.png new file mode 100755 index 0000000..b675fbd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_btn_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_btn_right.png b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_btn_right.png new file mode 100755 index 0000000..e856553 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_btn_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_color.png b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_color.png new file mode 100644 index 0000000..1e8702b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_color.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_color_h.png b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_color_h.png new file mode 100644 index 0000000..7348715 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_color_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_custom_color.png b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_custom_color.png new file mode 100644 index 0000000..76db50a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_custom_color.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_custom_color_h.png b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_custom_color_h.png new file mode 100644 index 0000000..20a43d0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_custom_color_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_focus.png b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_focus.png new file mode 100644 index 0000000..8e0ed9a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_focus.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_saturation.png b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_saturation.png new file mode 100644 index 0000000..8edd433 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_saturation.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_saturation_h.png b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_saturation_h.png new file mode 100644 index 0000000..f466e7b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_color_picker_saturation_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_contacts_button_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_contacts_button_bg.9.png new file mode 100644 index 0000000..1d49d6e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_contacts_button_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_bg.9.png new file mode 100755 index 0000000..99c1ed0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_bg_01.9.png new file mode 100755 index 0000000..dfbe205 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_bg_effect.9.png new file mode 100755 index 0000000..d2ace05 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_bottom.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_bottom.png new file mode 100755 index 0000000..beb51c0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_bottom.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_bottom_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_bottom_01.png new file mode 100755 index 0000000..2b68d00 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_bottom_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_bottom_effect.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_bottom_effect.png new file mode 100755 index 0000000..b965135 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_bottom_effect.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_left.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_left.png new file mode 100755 index 0000000..4dacb1d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_left_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_left_01.png new file mode 100755 index 0000000..7332a6e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_left_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_left_effect.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_left_effect.png new file mode 100755 index 0000000..e930c87 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_left_effect.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_right.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_right.png new file mode 100755 index 0000000..e6fdf99 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_right_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_right_01.png new file mode 100755 index 0000000..70f5f02 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_right_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_right_effect.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_right_effect.png new file mode 100755 index 0000000..c839d8e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_right_effect.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_top.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_top.png new file mode 100755 index 0000000..c898ab2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_top.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_top_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_top_01.png new file mode 100755 index 0000000..3bfb34f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_top_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_top_effect.png b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_top_effect.png new file mode 100755 index 0000000..ee9ae22 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_context_popup_tail_top_effect.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_center_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_center_bg.9.png new file mode 100755 index 0000000..62e21ca Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_center_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_center_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_center_bg_effect.9.png new file mode 100755 index 0000000..77137a2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_center_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_center_bg_press_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_center_bg_press_effect.9.png new file mode 100755 index 0000000..a1cb877 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_center_bg_press_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_dot.png b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_dot.png new file mode 100755 index 0000000..6a7fc53 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_dot.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_left_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_left_bg.9.png new file mode 100755 index 0000000..f011531 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_left_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_left_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_left_bg_effect.9.png new file mode 100755 index 0000000..4c8f57a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_left_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_left_bg_press_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_left_bg_press_effect.9.png new file mode 100755 index 0000000..7ae5980 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_left_bg_press_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_right_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_right_bg.9.png new file mode 100755 index 0000000..de4154d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_right_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_right_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_right_bg_effect.9.png new file mode 100755 index 0000000..966793a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_right_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_right_bg_press_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_right_bg_press_effect.9.png new file mode 100755 index 0000000..a175af3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_date_picker_right_bg_press_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button#5.png b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button#5.png new file mode 100755 index 0000000..cdfaefa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button#5.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button.png b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button.png new file mode 100755 index 0000000..cdfaefa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_01.png new file mode 100755 index 0000000..a4d932f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_01_dim.png b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_01_dim.png new file mode 100755 index 0000000..725440f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_01_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_01_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_01_press.png new file mode 100755 index 0000000..d7b6491 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_01_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_dim#1.png b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_dim#1.png new file mode 100755 index 0000000..9f4d74e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_dim#1.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_dim.png b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_dim.png new file mode 100755 index 0000000..9f4d74e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_press#3.png b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_press#3.png new file mode 100755 index 0000000..17f41d6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_press#3.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_press.png new file mode 100755 index 0000000..17f41d6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_detail_button_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_dialogue_group_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_dialogue_group_bg.9.png new file mode 100755 index 0000000..f9a37b3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_dialogue_group_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_dialogue_group_bg_bar.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_dialogue_group_bg_bar.9.png new file mode 100755 index 0000000..2ef6743 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_dialogue_group_bg_bar.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_divider_line.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_divider_line.9.png new file mode 100644 index 0000000..307a39f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_divider_line.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_divider_line_translucent.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_divider_line_translucent.9.png new file mode 100644 index 0000000..9a9bda2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_divider_line_translucent.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_bg.9.png new file mode 100755 index 0000000..a84453e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_clear.png b/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_clear.png new file mode 100644 index 0000000..e9fa197 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_clear.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_line_round_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_line_round_bg_01.9.png new file mode 100644 index 0000000..2e75e09 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_line_round_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_line_squre_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_line_squre_bg_01.9.png new file mode 100644 index 0000000..9bdef0e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_line_squre_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_no_line_round_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_no_line_round_bg.9.png new file mode 100644 index 0000000..a7ddf3a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_no_line_round_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_no_line_square_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_no_line_square_bg.9.png new file mode 100644 index 0000000..2a931d3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_edit_field_no_line_square_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_effect_tab_bounce_left.png b/res/common/usr/share/osp/bitmaps/720x1280/00_effect_tab_bounce_left.png new file mode 100644 index 0000000..f761e22 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_effect_tab_bounce_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_effect_tab_bounce_right.png b/res/common/usr/share/osp/bitmaps/720x1280/00_effect_tab_bounce_right.png new file mode 100644 index 0000000..0da390e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_effect_tab_bounce_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_popup_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_popup_bg.9.png new file mode 100755 index 0000000..7f44a47 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_popup_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_popup_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_popup_bg_ef.9.png new file mode 100755 index 0000000..0c3bf92 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_popup_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_rollover_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_rollover_bg.9.png new file mode 100755 index 0000000..b9a50be Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_rollover_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_rollover_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_rollover_bg_focus.9.png new file mode 100755 index 0000000..39697b4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_rollover_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_rollover_bg_line_focus.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_rollover_bg_line_focus.9.png new file mode 100755 index 0000000..94a1da0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_fast_scroll_rollover_bg_line_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_bg.9.png new file mode 100755 index 0000000..c2284e9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_bg_01.9.png new file mode 100755 index 0000000..ab9dc9e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_button_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_button_bg.9.png new file mode 100755 index 0000000..1513967 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_button_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_button_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_button_ef.9.png new file mode 100755 index 0000000..b0ee9a4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_button_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_button_ef_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_button_ef_press.9.png new file mode 100755 index 0000000..0767f68 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_button_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_Back.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_Back.png new file mode 100755 index 0000000..8ca78b3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_Back.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_Back_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_Back_ef.png new file mode 100755 index 0000000..692c8ee Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_Back_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_Back_ef_02.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_Back_ef_02.png new file mode 100755 index 0000000..2a693f1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_Back_ef_02.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_close.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_close.png new file mode 100755 index 0000000..1601390 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_close.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_close_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_close_press.png new file mode 100755 index 0000000..8d0f692 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_close_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_more.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_more.png new file mode 100755 index 0000000..1437796 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_more.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_more2.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_more2.png new file mode 100755 index 0000000..c607fdc Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_more2.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_more2_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_more2_ef.png new file mode 100755 index 0000000..74eb55a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_more2_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_more_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_more_press.png new file mode 100755 index 0000000..2925aec Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_footer_icon_more_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_grid_select_check.png b/res/common/usr/share/osp/bitmaps/720x1280/00_grid_select_check.png new file mode 100755 index 0000000..c34b70b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_grid_select_check.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_grid_select_check_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_grid_select_check_bg.png new file mode 100755 index 0000000..7921f38 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_grid_select_check_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_grid_select_check_bg_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_grid_select_check_bg_press.png new file mode 100755 index 0000000..61d5ded Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_grid_select_check_bg_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg.9.png new file mode 100755 index 0000000..708e8e0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg_01.9.png new file mode 100755 index 0000000..7ceaf54 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg_focus.9.png new file mode 100644 index 0000000..94dc214 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg_p.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg_p.9.png new file mode 100755 index 0000000..134d87b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg_p.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg_press.9.png new file mode 100755 index 0000000..0fc1eb9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bg_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bottom_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bottom_bg.9.png new file mode 100755 index 0000000..6400ab7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bottom_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bottom_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bottom_bg_01.9.png new file mode 100755 index 0000000..70d64eb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bottom_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bottom_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bottom_bg_focus.9.png new file mode 100644 index 0000000..3d18daf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bottom_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bottom_bg_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bottom_bg_press.9.png new file mode 100755 index 0000000..081b24a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_bottom_bg_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_center_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_center_bg.9.png new file mode 100755 index 0000000..c1b07ed Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_center_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_center_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_center_bg_01.9.png new file mode 100755 index 0000000..3dccf23 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_center_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_center_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_center_bg_focus.9.png new file mode 100644 index 0000000..8123812 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_center_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_center_bg_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_center_bg_press.9.png new file mode 100755 index 0000000..423ce61 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_center_bg_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_h_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_h_bg.9.png new file mode 100755 index 0000000..4715bbe Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_h_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_input_outline_h.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_input_outline_h.9.png new file mode 100755 index 0000000..a144a0f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_input_outline_h.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_normal_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_normal_bg.9.png new file mode 100755 index 0000000..a65fdaf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_normal_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_top_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_top_bg.9.png new file mode 100755 index 0000000..5bfed6f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_top_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_top_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_top_bg_01.9.png new file mode 100755 index 0000000..052c224 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_top_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_top_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_top_bg_focus.9.png new file mode 100644 index 0000000..35cdd97 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_top_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_top_bg_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_top_bg_press.9.png new file mode 100755 index 0000000..2c267a5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_groupedlist_top_bg_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_badge_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_badge_bg.9.png new file mode 100755 index 0000000..c00a6f8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_badge_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_badge_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_badge_bg_ef.9.png new file mode 100755 index 0000000..f5b3d4c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_badge_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_bg.9.png new file mode 100755 index 0000000..dc7d9c3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_bg_01.9.png new file mode 100755 index 0000000..283360a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_bg_effect.9.png new file mode 100755 index 0000000..95caa23 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_bg.9.png new file mode 100755 index 0000000..c1b0ae9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_bg_effect.9.png new file mode 100755 index 0000000..841020e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_bg_focus.9.png new file mode 100755 index 0000000..5a4f9ee Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_bg_press_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_bg_press_effect.9.png new file mode 100755 index 0000000..700c2d0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_bg_press_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_web.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_web.9.png new file mode 100755 index 0000000..04eeaca Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_web.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_web_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_web_press.9.png new file mode 100755 index 0000000..99b3abb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_button_web_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_icon_edit.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_icon_edit.png new file mode 100755 index 0000000..5b1003b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_icon_edit.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_icon_edit_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_icon_edit_ef.png new file mode 100755 index 0000000..0abf443 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_icon_edit_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_icon_plus.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_icon_plus.png new file mode 100755 index 0000000..86206a6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_icon_plus.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_icon_plus_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_icon_plus_ef.png new file mode 100755 index 0000000..312417b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_icon_plus_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_tab_press_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_tab_press_ef.9.png new file mode 100755 index 0000000..6f960fd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_tab_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_header_title_handler.png b/res/common/usr/share/osp/bitmaps/720x1280/00_header_title_handler.png new file mode 100755 index 0000000..082f3ca Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_header_title_handler.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_Back.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_Back.png new file mode 100644 index 0000000..78a10cb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_Back.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_Back_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_Back_ef.png new file mode 100644 index 0000000..4e5c784 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_Back_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_Back_ef_02.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_Back_ef_02.png new file mode 100644 index 0000000..17ccfa3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_Back_ef_02.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_Back_trans_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_Back_trans_ef.png new file mode 100644 index 0000000..b663c19 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_Back_trans_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_add.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_add.png new file mode 100755 index 0000000..aedfb70 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_add.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_back.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_back.png new file mode 100755 index 0000000..49b3ba1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_back.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_edit.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_edit.png new file mode 100644 index 0000000..8005ca1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_edit.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_edit_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_edit_ef.png new file mode 100644 index 0000000..80bc218 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_edit_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_jump.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_jump.png new file mode 100755 index 0000000..79b8eef Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_jump.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_jump_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_jump_ef.png new file mode 100755 index 0000000..222bbea Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_jump_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_jump_left.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_jump_left.png new file mode 100755 index 0000000..57eece7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_jump_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_jump_left_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_jump_left_ef.png new file mode 100755 index 0000000..3b23a4f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_jump_left_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_more.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_more.png new file mode 100644 index 0000000..deab830 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_more.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_more_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_more_ef.png new file mode 100644 index 0000000..01278a5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_more_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_plus.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_plus.png new file mode 100644 index 0000000..1b10333 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_plus.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_icon_plus_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_plus_ef.png new file mode 100644 index 0000000..b910f02 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_icon_plus_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_iconlist_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_iconlist_bg.9.png new file mode 100755 index 0000000..30726b2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_iconlist_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_indexlist_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_indexlist_bg.9.png new file mode 100755 index 0000000..aa4d47c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_indexlist_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_indexlist_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_indexlist_bg_ef.9.png new file mode 100755 index 0000000..96342f6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_indexlist_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_label_01_normal.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_label_01_normal.9.png new file mode 100755 index 0000000..355f50d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_label_01_normal.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg.9.png new file mode 100644 index 0000000..351f138 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_bottom.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_bottom.9.png new file mode 100644 index 0000000..90d73b9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_bottom.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_bottom_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_bottom_ef.9.png new file mode 100644 index 0000000..fbd5ccf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_bottom_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_center.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_center.9.png new file mode 100644 index 0000000..23c6cf2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_center.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_center_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_center_ef.9.png new file mode 100644 index 0000000..4c7079f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_center_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_ef.9.png new file mode 100644 index 0000000..2ae976d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_top.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_top.9.png new file mode 100644 index 0000000..44d946a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_top.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_top_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_top_ef.9.png new file mode 100644 index 0000000..744ebb0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_group_bg_top_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_01.png new file mode 100644 index 0000000..5c8fbb4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_02.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_02.png new file mode 100644 index 0000000..eeec62e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_02.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_03.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_03.png new file mode 100644 index 0000000..45f82b9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_03.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_04.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_04.png new file mode 100644 index 0000000..251e3ba Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_04.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_05.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_05.png new file mode 100644 index 0000000..e278217 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_05.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_06.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_06.png new file mode 100644 index 0000000..1e47db8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_06.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_07.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_07.png new file mode 100644 index 0000000..18d5db9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_07.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_08.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_08.png new file mode 100644 index 0000000..0cabf18 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_08.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_09.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_09.png new file mode 100644 index 0000000..94bba2b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_09.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_10.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_10.png new file mode 100644 index 0000000..2e5b2b7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_10.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_11.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_11.png new file mode 100644 index 0000000..264e6b5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_11.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_12.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_12.png new file mode 100644 index 0000000..c49841e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_12.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_13.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_13.png new file mode 100644 index 0000000..cdec394 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_13.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_14.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_14.png new file mode 100644 index 0000000..aeb2852 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_14.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_15.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_15.png new file mode 100644 index 0000000..b37ee4a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_15.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_16.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_16.png new file mode 100644 index 0000000..5bb072b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_16.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_17.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_17.png new file mode 100644 index 0000000..b7e6eb6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_17.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_18.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_18.png new file mode 100644 index 0000000..e5ce36b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_18.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_19.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_19.png new file mode 100644 index 0000000..40b4e7d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_19.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_20.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_20.png new file mode 100644 index 0000000..b50abde Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_20.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_21.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_21.png new file mode 100644 index 0000000..e7cc057 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_21.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_22.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_22.png new file mode 100644 index 0000000..35e93e3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_22.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_23.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_23.png new file mode 100644 index 0000000..50990db Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_23.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_24.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_24.png new file mode 100644 index 0000000..3dfea10 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_24.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_25.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_25.png new file mode 100644 index 0000000..4878a78 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_25.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_26.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_26.png new file mode 100644 index 0000000..b57750f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_26.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_27.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_27.png new file mode 100644 index 0000000..c8cee33 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_27.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_28.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_28.png new file mode 100644 index 0000000..db51809 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_28.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_29.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_29.png new file mode 100644 index 0000000..2fb304e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_29.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_30.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_30.png new file mode 100644 index 0000000..9868089 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_process_30.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_progress_bar.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_progress_bar.9.png new file mode 100755 index 0000000..191e333 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_progress_bar.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_progress_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_progress_bg.9.png new file mode 100755 index 0000000..80d12bf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_progress_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_slider_icon_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_slider_icon_bg.9.png new file mode 100755 index 0000000..d64969f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_slider_icon_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_slider_icon_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_slider_icon_bg_effect.9.png new file mode 100755 index 0000000..87f9a6c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_slider_icon_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_list_slider_icon_bg_effect_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_list_slider_icon_bg_effect_01.9.png new file mode 100755 index 0000000..d0fb0dd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_list_slider_icon_bg_effect_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_on_button_controller#5.png b/res/common/usr/share/osp/bitmaps/720x1280/00_on_button_controller#5.png new file mode 100755 index 0000000..bb85e93 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_on_button_controller#5.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_contextual_popup_arrow.png b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_contextual_popup_arrow.png new file mode 100644 index 0000000..c61954e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_contextual_popup_arrow.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg.png new file mode 100644 index 0000000..bc62f6a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_ef.png new file mode 100644 index 0000000..376e9ec Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_ef_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_ef_press.png new file mode 100644 index 0000000..94b62db Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_p.png b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_p.png new file mode 100755 index 0000000..42e5229 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_p.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_p_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_p_ef.png new file mode 100755 index 0000000..e8bbaac Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_p_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_press.png new file mode 100644 index 0000000..a6ff057 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_option_panel_handle_bg_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_option_tray_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_option_tray_bg.9.png new file mode 100755 index 0000000..f9a37b3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_option_tray_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_option_tray_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_option_tray_bg_ef.9.png new file mode 100755 index 0000000..0fb614f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_option_tray_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_option_tray_tail_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_option_tray_tail_bg.png new file mode 100755 index 0000000..a378107 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_option_tray_tail_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_option_tray_tail_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_option_tray_tail_ef.png new file mode 100755 index 0000000..7b1fda9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_option_tray_tail_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_overscrolling_bottom.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_overscrolling_bottom.9.png new file mode 100755 index 0000000..3be0788 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_overscrolling_bottom.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_overscrolling_left.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_overscrolling_left.9.png new file mode 100755 index 0000000..860463f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_overscrolling_left.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_overscrolling_right.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_overscrolling_right.9.png new file mode 100755 index 0000000..b187aaa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_overscrolling_right.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_overscrolling_top.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_overscrolling_top.9.png new file mode 100755 index 0000000..45f86a7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_overscrolling_top.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_panel_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_bg.9.png new file mode 100644 index 0000000..f9a37b3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_arrow.png b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_arrow.png new file mode 100644 index 0000000..06b9bce Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_arrow.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_bg.9.png new file mode 100644 index 0000000..673c044 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_bg_ef.9.png new file mode 100644 index 0000000..24bf5b0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_bg_ef_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_bg_ef_press.9.png new file mode 100644 index 0000000..b8a38ea Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_bg_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_bg_p_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_bg_p_ef.9.png new file mode 100755 index 0000000..b8a38ea Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_handle_bg_p_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_panel_list_press_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_list_press_bg.9.png new file mode 100755 index 0000000..a2cf5ca Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_list_press_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_panel_list_press_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_list_press_bg_ef.9.png new file mode 100755 index 0000000..121ec18 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_panel_list_press_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bg.9.png new file mode 100755 index 0000000..e63e014 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bg_ef.9.png new file mode 100755 index 0000000..210dbac Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bottom_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bottom_bg.9.png new file mode 100755 index 0000000..b941575 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bottom_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_bg.9.png new file mode 100755 index 0000000..1e8de8f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_bg_ef.9.png new file mode 100755 index 0000000..cb04f16 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_bottom_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_bottom_bg.png new file mode 100755 index 0000000..733c790 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_bottom_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_bottom_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_bottom_ef.png new file mode 100755 index 0000000..2abbadc Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_bottom_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_left_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_left_bg.png new file mode 100755 index 0000000..8dee9d8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_left_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_left_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_left_ef.png new file mode 100755 index 0000000..e22a1b3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_left_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_right_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_right_bg.png new file mode 100755 index 0000000..061c270 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_right_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_right_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_right_ef.png new file mode 100755 index 0000000..0e70530 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_right_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_top_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_top_bg.png new file mode 100755 index 0000000..ed639af Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_top_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_top_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_top_ef.png new file mode 100755 index 0000000..fea3a6f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_bubble_tail_top_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_popup_title_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_title_bg.9.png new file mode 100755 index 0000000..b4be8c0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_popup_title_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_00.png b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_00.png new file mode 100755 index 0000000..0297d91 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_00.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_01.png new file mode 100755 index 0000000..3118e40 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_02.png b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_02.png new file mode 100755 index 0000000..3152a59 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_02.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_03.png b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_03.png new file mode 100755 index 0000000..7d6e2bd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_03.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_04.png b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_04.png new file mode 100755 index 0000000..b7fe4c3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_04.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_05.png b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_05.png new file mode 100755 index 0000000..b20cf11 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_05.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_06.png b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_06.png new file mode 100755 index 0000000..08a44fe Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_06.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_07.png b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_07.png new file mode 100755 index 0000000..d526460 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_07.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_08.png b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_08.png new file mode 100755 index 0000000..3d8fe4e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_08.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_09.png b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_09.png new file mode 100755 index 0000000..40987ba Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_processing_ani_52x52_09.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_progress.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_progress.9.png new file mode 100755 index 0000000..4cf7aa0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_progress.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bar.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bar.9.png new file mode 100644 index 0000000..2b1530d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bar.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bar_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bar_ef.9.png new file mode 100644 index 0000000..6903f94 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bar_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bar_ef_m.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bar_ef_m.9.png new file mode 100644 index 0000000..9914645 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bar_ef_m.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bar_m.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bar_m.9.png new file mode 100644 index 0000000..0909cdf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bar_m.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bg.9.png new file mode 100644 index 0000000..e3d0912 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_progress_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_ef.9.png new file mode 100755 index 0000000..86e2805 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_progress_ef_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_ef_bg.9.png new file mode 100644 index 0000000..527529a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_progress_ef_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_reorder_group_list_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_reorder_group_list_bg.9.png new file mode 100755 index 0000000..a464f33 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_reorder_group_list_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar.9.png new file mode 100755 index 0000000..7afa4f3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_ef.9.png new file mode 100755 index 0000000..6ae4958 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_handler_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_handler_bg.9.png new file mode 100755 index 0000000..fe1e470 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_handler_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_handler_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_handler_bg_ef.9.png new file mode 100755 index 0000000..a72bcaa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_handler_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_handler_h.png b/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_handler_h.png new file mode 100755 index 0000000..c1d9feb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_handler_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_handler_v.png b/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_handler_v.png new file mode 100755 index 0000000..4172a3d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_scroll_bar_handler_v.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_search_clear_icon_normal.png b/res/common/usr/share/osp/bitmaps/720x1280/00_search_clear_icon_normal.png new file mode 100755 index 0000000..3bafd02 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_search_clear_icon_normal.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_search_clear_icon_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_search_clear_icon_press.png new file mode 100755 index 0000000..6ae38e7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_search_clear_icon_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_search_edit_field_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_search_edit_field_bg.9.png new file mode 100644 index 0000000..4f20436a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_search_edit_field_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_search_edit_field_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_search_edit_field_bg_ef.9.png new file mode 100644 index 0000000..f7de001 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_search_edit_field_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_search_icon.png b/res/common/usr/share/osp/bitmaps/720x1280/00_search_icon.png new file mode 100644 index 0000000..b70a9df Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_search_icon.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_search_icon_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_search_icon_ef.png new file mode 100644 index 0000000..3de0d79 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_search_icon_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_seg_line.png b/res/common/usr/share/osp/bitmaps/720x1280/00_seg_line.png new file mode 100755 index 0000000..f90232c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_seg_line.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_seg_line_tr.png b/res/common/usr/share/osp/bitmaps/720x1280/00_seg_line_tr.png new file mode 100755 index 0000000..f7404f0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_seg_line_tr.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_bg.9.png new file mode 100755 index 0000000..ed8a75b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_bg_effect.9.png new file mode 100755 index 0000000..d064c76 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle.9.png new file mode 100755 index 0000000..2c6e44c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle.png new file mode 100644 index 0000000..dbecdc4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_dim.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_dim.png new file mode 100755 index 0000000..6ae009d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_ef.png new file mode 100644 index 0000000..1e0b804 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_ef_dim.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_ef_dim.png new file mode 100644 index 0000000..a20c86a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_ef_dim.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_ef_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_ef_press.png new file mode 100644 index 0000000..aa7428d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_press.png new file mode 100755 index 0000000..c9b8ed9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_handle_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_popup_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_popup_bg.png new file mode 100644 index 0000000..4d2bfa4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_popup_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_popup_bg_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_popup_bg_ef.png new file mode 100644 index 0000000..ce9d94e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_popup_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_popup_bottom_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_popup_bottom_bg.png new file mode 100644 index 0000000..3ebaff1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_popup_bottom_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_slider_popup_bottom_bg_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_popup_bottom_bg_ef.png new file mode 100644 index 0000000..6865154 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_slider_popup_bottom_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_icon_add.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_icon_add.png new file mode 100644 index 0000000..853af6e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_icon_add.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_icon_zoom.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_icon_zoom.png new file mode 100644 index 0000000..30f593e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_icon_zoom.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_bg.png new file mode 100644 index 0000000..08c5de1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_bg_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_bg_ef.png new file mode 100644 index 0000000..af14e87 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_bg_ef_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_bg_ef_press.png new file mode 100644 index 0000000..6dd7068 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_bg_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_bg_p_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_bg_p_ef.png new file mode 100755 index 0000000..6dd7068 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_bg_p_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_text_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_text_bg.png new file mode 100644 index 0000000..5312b2d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_text_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_text_bg_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_text_bg_ef.png new file mode 100644 index 0000000..66f0ec5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_text_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_text_bg_ef_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_text_bg_ef_press.png new file mode 100644 index 0000000..e357173 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_text_bg_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_text_bg_p_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_text_bg_p_ef.png new file mode 100755 index 0000000..e357173 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_left_text_bg_p_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_bg.png new file mode 100644 index 0000000..9583cee Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_bg_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_bg_ef.png new file mode 100644 index 0000000..8960768 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_bg_ef_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_bg_ef_press.png new file mode 100644 index 0000000..aa6ae7c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_bg_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_bg_p_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_bg_p_ef.png new file mode 100755 index 0000000..aa6ae7c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_bg_p_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_text_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_text_bg.png new file mode 100644 index 0000000..4ac1b7b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_text_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_text_bg_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_text_bg_ef.png new file mode 100644 index 0000000..00e084c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_text_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_text_bg_ef_press.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_text_bg_ef_press.png new file mode 100644 index 0000000..f8fdce7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_text_bg_ef_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_text_bg_p_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_text_bg_p_ef.png new file mode 100755 index 0000000..f8fdce7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_softkey_right_text_bg_p_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_bg.9.png new file mode 100644 index 0000000..3f45f91 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_bg_ef_h.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_bg_ef_h.9.png new file mode 100644 index 0000000..ca4689e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_bg_ef_h.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_bg_ef_v.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_bg_ef_v.9.png new file mode 100644 index 0000000..ba6a19b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_bg_ef_v.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_h.png b/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_h.png new file mode 100644 index 0000000..f6f2c97 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_v.png b/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_v.png new file mode 100644 index 0000000..d0cf6bb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_splite_handler_v.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_tab_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_bg.9.png new file mode 100644 index 0000000..27b873b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_tab_focus.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_focus.9.png new file mode 100644 index 0000000..68b47e8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_tab_icon_more_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_icon_more_01.png new file mode 100755 index 0000000..a2c40da Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_icon_more_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_tab_icon_more_02.png b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_icon_more_02.png new file mode 100755 index 0000000..815969e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_icon_more_02.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_tab_move_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_move_bg.9.png new file mode 100755 index 0000000..2cac380 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_move_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_tab_move_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_move_bg_ef.9.png new file mode 100755 index 0000000..f5ec79b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_move_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_tab_press_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_press_ef.9.png new file mode 100644 index 0000000..2635b75 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_tab_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_thumbs_bg_focus.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_thumbs_bg_focus.9.png new file mode 100755 index 0000000..c73b844 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_thumbs_bg_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_thumbs_line_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_thumbs_line_bg.9.png new file mode 100755 index 0000000..fc70524 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_thumbs_line_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_thumbs_loading_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_thumbs_loading_bg.9.png new file mode 100755 index 0000000..cffac37 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_thumbs_loading_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_tick_box_normal.png b/res/common/usr/share/osp/bitmaps/720x1280/00_tick_box_normal.png new file mode 100755 index 0000000..cc03432 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_tick_box_normal.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_btn.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_btn.9.png new file mode 100755 index 0000000..c1b0ae9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_btn.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_btn_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_btn_effect.9.png new file mode 100755 index 0000000..841020e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_btn_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_btn_press_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_btn_press_effect.9.png new file mode 100755 index 0000000..700c2d0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_btn_press_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_keypad_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_keypad_bg.9.png new file mode 100755 index 0000000..6fdd82b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_keypad_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_keypad_button_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_keypad_button_bg.9.png new file mode 100755 index 0000000..261cbcb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_keypad_button_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_keypad_button_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_keypad_button_bg_ef.9.png new file mode 100755 index 0000000..a9108b6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_time_picker_keypad_button_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_timepicker_number_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_timepicker_number_bg.9.png new file mode 100755 index 0000000..41009da Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_timepicker_number_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_timepicker_tail.png b/res/common/usr/share/osp/bitmaps/720x1280/00_timepicker_tail.png new file mode 100755 index 0000000..1b8581b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_timepicker_tail.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_timepicker_tail_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_timepicker_tail_01.png new file mode 100755 index 0000000..6710de0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_timepicker_tail_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_title_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_title_bg.9.png new file mode 100755 index 0000000..f9a37b3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_title_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_title_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_title_bg_ef.9.png new file mode 100755 index 0000000..0598ee4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_title_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_title_btn_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_title_btn_bg.9.png new file mode 100755 index 0000000..01d4943 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_title_btn_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_title_btn_bg_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_title_btn_bg_press.9.png new file mode 100755 index 0000000..a711fca Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_title_btn_bg_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_title_button_bg_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_title_button_bg_press.9.png new file mode 100755 index 0000000..036bf20 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_title_button_bg_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_title_icon_more.png b/res/common/usr/share/osp/bitmaps/720x1280/00_title_icon_more.png new file mode 100755 index 0000000..3f02443 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_title_icon_more.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_title_icon_search.png b/res/common/usr/share/osp/bitmaps/720x1280/00_title_icon_search.png new file mode 100755 index 0000000..1f09962 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_title_icon_search.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_title_line.png b/res/common/usr/share/osp/bitmaps/720x1280/00_title_line.png new file mode 100755 index 0000000..846d623 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_title_line.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_bg.9.png new file mode 100755 index 0000000..f9a37b3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_bg.9.png new file mode 100755 index 0000000..8ffbf20 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_bg_ef.9.png new file mode 100755 index 0000000..3d718cf Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_bg_ef_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_bg_ef_01.9.png new file mode 100755 index 0000000..224c1ad Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_bg_ef_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_bg_p_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_bg_p_ef.9.png new file mode 100755 index 0000000..84edc43 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_bg_p_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_focus.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_focus.9.png new file mode 100755 index 0000000..46f901d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_btn_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button.9.png new file mode 100644 index 0000000..e0a35bd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_bg.9.png new file mode 100644 index 0000000..30a8e1c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_bg_center.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_bg_center.9.png new file mode 100644 index 0000000..2a14dc7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_bg_center.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_bg_left.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_bg_left.9.png new file mode 100644 index 0000000..65fe1d2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_bg_left.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_bg_right.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_bg_right.9.png new file mode 100644 index 0000000..a12b54c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_bg_right.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_center_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_center_ef.9.png new file mode 100644 index 0000000..558a2fa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_center_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_center_press_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_center_press_ef.9.png new file mode 100644 index 0000000..f59c8d8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_center_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_ef.9.png new file mode 100644 index 0000000..5770957 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_ef_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_ef_press.9.png new file mode 100644 index 0000000..acfa1f6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_left_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_left_ef.9.png new file mode 100644 index 0000000..422b034 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_left_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_left_ef_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_left_ef_press.9.png new file mode 100644 index 0000000..de8934b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_left_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_press.9.png new file mode 100644 index 0000000..d162fd8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_right_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_right_ef.9.png new file mode 100644 index 0000000..4d66dac Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_right_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_right_press_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_right_press_ef.9.png new file mode 100644 index 0000000..5ea7c49 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_button_right_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_divider_line.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_divider_line.9.png new file mode 100755 index 0000000..307a39f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_divider_line.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_line.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_line.png new file mode 100755 index 0000000..846d623 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_line.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_line_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_line_01.png new file mode 100644 index 0000000..241ac95 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_line_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_press.9.png new file mode 100755 index 0000000..4f54c7f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_center.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_center.9.png new file mode 100644 index 0000000..ef6633f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_center.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_center_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_center_press.9.png new file mode 100644 index 0000000..dfa75c0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_center_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_left.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_left.9.png new file mode 100644 index 0000000..8fb5561 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_left.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_left_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_left_press.9.png new file mode 100644 index 0000000..f324dca Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_left_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_right.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_right.9.png new file mode 100644 index 0000000..363f3c2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_right.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_right_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_right_press.9.png new file mode 100644 index 0000000..d524ed0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_toolbar_trans_button_right_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_transparent_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_transparent_bg.9.png new file mode 100755 index 0000000..1606d60 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_transparent_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_value_progress_bar.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_value_progress_bar.9.png new file mode 100755 index 0000000..5e24eb0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_value_progress_bar.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_value_progress_bar_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_value_progress_bar_effect.9.png new file mode 100755 index 0000000..678ad16 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_value_progress_bar_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_value_progress_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_value_progress_bg.9.png new file mode 100755 index 0000000..b0b6059 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_value_progress_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_value_progress_bg_effect.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_value_progress_bg_effect.9.png new file mode 100755 index 0000000..35a8b56 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_value_progress_bg_effect.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_Back_btn_normal.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_Back_btn_normal.9.png new file mode 100755 index 0000000..2197826 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_Back_btn_normal.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_Back_btn_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_Back_btn_press.9.png new file mode 100755 index 0000000..29fa717 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_Back_btn_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_badge.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_badge.9.png new file mode 100755 index 0000000..e6917c7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_badge.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_control_tabbar_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_control_tabbar_bg.9.png new file mode 100755 index 0000000..abccffc Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_control_tabbar_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_control_toolbar_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_control_toolbar_bg.9.png new file mode 100755 index 0000000..a65a4b2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_control_toolbar_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_divider_line.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_divider_line.9.png new file mode 100755 index 0000000..58b1438 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_divider_line.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_01.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_01.png new file mode 100755 index 0000000..8124a7b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_01.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_02.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_02.png new file mode 100755 index 0000000..c4428f7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_02.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_03.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_03.png new file mode 100755 index 0000000..33458d5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_03.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_04.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_04.png new file mode 100755 index 0000000..b3f8ef6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_04.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_05.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_05.png new file mode 100755 index 0000000..cb53465 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_05.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_06.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_06.png new file mode 100755 index 0000000..1fc9501 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_06.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_07.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_07.png new file mode 100755 index 0000000..1174beb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_07.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_08.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_08.png new file mode 100755 index 0000000..9386d3a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_08.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_09.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_09.png new file mode 100755 index 0000000..19c608c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_09.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_10.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_10.png new file mode 100755 index 0000000..72334f2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_10.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_11.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_11.png new file mode 100755 index 0000000..77ac2f2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_11.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_12.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_12.png new file mode 100755 index 0000000..466c052 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_12.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_13.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_13.png new file mode 100755 index 0000000..d6047fc Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_13.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_14.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_14.png new file mode 100755 index 0000000..ee0cee5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_14.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_15.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_15.png new file mode 100755 index 0000000..9733288 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_15.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_16.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_16.png new file mode 100755 index 0000000..fb6b7c6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_16.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_17.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_17.png new file mode 100755 index 0000000..4ff8db8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_17.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_18.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_18.png new file mode 100755 index 0000000..d1fde2d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_18.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_19.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_19.png new file mode 100755 index 0000000..c2bb19b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_19.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_20.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_20.png new file mode 100755 index 0000000..50d9e81 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_20.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_21.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_21.png new file mode 100755 index 0000000..c65fe5c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_21.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_22.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_22.png new file mode 100755 index 0000000..b7b4443 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_22.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_23.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_23.png new file mode 100755 index 0000000..f102b8b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_23.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_24.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_24.png new file mode 100755 index 0000000..a47ff9b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_24.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_25.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_25.png new file mode 100755 index 0000000..b306a07 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_25.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_26.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_26.png new file mode 100755 index 0000000..21af3ff Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_26.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_27.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_27.png new file mode 100755 index 0000000..398d438 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_27.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_28.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_28.png new file mode 100755 index 0000000..e0721fa Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_28.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_29.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_29.png new file mode 100755 index 0000000..4fcda20 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_29.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_30.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_30.png new file mode 100755 index 0000000..1c5064b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_list_process_30.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_thumbs_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_thumbs_bg.9.png new file mode 100755 index 0000000..463401a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_thumbs_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/00_winset_title_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_title_bg.9.png new file mode 100755 index 0000000..0e5ea48 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/00_winset_title_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/04_textinput_qwerty_button.9.png b/res/common/usr/share/osp/bitmaps/720x1280/04_textinput_qwerty_button.9.png new file mode 100755 index 0000000..521b9c5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/04_textinput_qwerty_button.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/04_textinput_qwerty_button_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/04_textinput_qwerty_button_01.9.png new file mode 100755 index 0000000..de496ad Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/04_textinput_qwerty_button_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/04_textinput_qwerty_button_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/04_textinput_qwerty_button_press.9.png new file mode 100755 index 0000000..82f66a7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/04_textinput_qwerty_button_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/Off_Background#5.png b/res/common/usr/share/osp/bitmaps/720x1280/Off_Background#5.png new file mode 100755 index 0000000..09c9745 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/Off_Background#5.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/On_Background#5.png b/res/common/usr/share/osp/bitmaps/720x1280/On_Background#5.png new file mode 100755 index 0000000..2d23ccb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/On_Background#5.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/TTS_focus.9.png b/res/common/usr/share/osp/bitmaps/720x1280/TTS_focus.9.png new file mode 100755 index 0000000..575f34c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/TTS_focus.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/TTS_popup_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/TTS_popup_bg.9.png new file mode 100755 index 0000000..f52341f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/TTS_popup_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_btn_circle_bg_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_btn_circle_bg_ef.png new file mode 100755 index 0000000..17b3c56 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_btn_circle_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_01_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_01_bg_ef.9.png new file mode 100755 index 0000000..271032a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_01_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_edit_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_edit_bg_ef.9.png new file mode 100755 index 0000000..be4a1d2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_edit_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_radio_normal1.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_radio_normal1.png new file mode 100755 index 0000000..cb930a5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_radio_normal1.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_radio_normal2.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_radio_normal2.png new file mode 100755 index 0000000..bab4ba8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_radio_normal2.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_seg_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_seg_bg_ef.9.png new file mode 100755 index 0000000..07685ed Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_seg_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_seg_f_bg_ef_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_seg_f_bg_ef_01.9.png new file mode 100755 index 0000000..c582427 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_seg_f_bg_ef_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_seg_f_bg_ef_02.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_seg_f_bg_ef_02.9.png new file mode 100755 index 0000000..4445380 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_seg_f_bg_ef_02.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_seg_f_bg_ef_03.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_seg_f_bg_ef_03.9.png new file mode 100755 index 0000000..3872e2c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_button_seg_f_bg_ef_03.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_check_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_check_bg.png new file mode 100755 index 0000000..ec67bf1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_check_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_color_picker_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_color_picker_bg.9.png new file mode 100755 index 0000000..4b47c20 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_color_picker_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_dialogue_group_bg_line.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_dialogue_group_bg_line.9.png new file mode 100755 index 0000000..e9af669 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_dialogue_group_bg_line.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_edit_field_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_edit_field_bg_ef.9.png new file mode 100755 index 0000000..2eb59e6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_edit_field_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_groupedlist_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_groupedlist_bg_01.9.png new file mode 100755 index 0000000..61cc955 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_groupedlist_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_groupedlist_bottom_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_groupedlist_bottom_bg_01.9.png new file mode 100755 index 0000000..cb8146b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_groupedlist_bottom_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_groupedlist_center_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_groupedlist_center_bg_01.9.png new file mode 100755 index 0000000..ed96713 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_groupedlist_center_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_groupedlist_top_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_groupedlist_top_bg_01.9.png new file mode 100755 index 0000000..1c91af8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_groupedlist_top_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_indexlist_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_indexlist_bg_ef.9.png new file mode 100755 index 0000000..28cd706 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_indexlist_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_indexlist_icon_line.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_indexlist_icon_line.png new file mode 100755 index 0000000..b818731 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_indexlist_icon_line.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_01_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_01_32x32.png new file mode 100644 index 0000000..556fd00 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_01_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_02_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_02_32x32.png new file mode 100644 index 0000000..e3f6661 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_02_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_03_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_03_32x32.png new file mode 100644 index 0000000..aabd74d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_03_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_04_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_04_32x32.png new file mode 100644 index 0000000..6752381 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_04_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_05_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_05_32x32.png new file mode 100644 index 0000000..026bf39 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_05_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_06_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_06_32x32.png new file mode 100644 index 0000000..76ad804 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_06_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_07_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_07_32x32.png new file mode 100644 index 0000000..3ff8e86 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_07_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_08_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_08_32x32.png new file mode 100644 index 0000000..35964af Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_08_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_09_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_09_32x32.png new file mode 100644 index 0000000..acc0e33 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_09_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_10_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_10_32x32.png new file mode 100644 index 0000000..732ab34 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_10_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_11_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_11_32x32.png new file mode 100644 index 0000000..5bb451a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_11_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_12_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_12_32x32.png new file mode 100644 index 0000000..d411a19 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_12_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_13_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_13_32x32.png new file mode 100644 index 0000000..4df5086 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_13_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_14_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_14_32x32.png new file mode 100644 index 0000000..eda2bb4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_14_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_15_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_15_32x32.png new file mode 100644 index 0000000..5a1225e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_15_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_16_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_16_32x32.png new file mode 100644 index 0000000..3fb7f2b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_16_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_17_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_17_32x32.png new file mode 100644 index 0000000..d40c3a4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_17_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_18_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_18_32x32.png new file mode 100644 index 0000000..b6f87c0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_18_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_19_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_19_32x32.png new file mode 100644 index 0000000..e06e91c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_19_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_20_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_20_32x32.png new file mode 100644 index 0000000..b7fea9c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_20_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_21_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_21_32x32.png new file mode 100644 index 0000000..9b953a6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_21_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_22_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_22_32x32.png new file mode 100644 index 0000000..e4da281 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_22_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_23_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_23_32x32.png new file mode 100644 index 0000000..a63c879 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_23_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_24_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_24_32x32.png new file mode 100644 index 0000000..d3c8964 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_24_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_25_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_25_32x32.png new file mode 100644 index 0000000..480b0b4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_25_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_26_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_26_32x32.png new file mode 100644 index 0000000..73a1a83 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_26_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_27_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_27_32x32.png new file mode 100644 index 0000000..c06818a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_27_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_28_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_28_32x32.png new file mode 100644 index 0000000..015dda9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_28_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_29_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_29_32x32.png new file mode 100644 index 0000000..01d8f98 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_29_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_30_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_30_32x32.png new file mode 100644 index 0000000..8633efe Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_list_process_30_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bg_ef.9.png new file mode 100755 index 0000000..e7a94b7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bottom_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bottom_bg.9.png new file mode 100755 index 0000000..eada0e7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bottom_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_bg_ef.9.png new file mode 100755 index 0000000..9b6ee97 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_tail_bottom_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_tail_bottom_ef.png new file mode 100755 index 0000000..39f8f8f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_tail_bottom_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_tail_left_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_tail_left_ef.png new file mode 100755 index 0000000..e74d333 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_tail_left_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_tail_right_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_tail_right_ef.png new file mode 100755 index 0000000..9fd5a4c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_tail_right_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_tail_top_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_tail_top_ef.png new file mode 100755 index 0000000..6c0eb22 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_bubble_tail_top_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_button_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_button_bg_ef.9.png new file mode 100755 index 0000000..271032a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_button_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_title_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_title_bg.9.png new file mode 100755 index 0000000..ebe1f72 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_title_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_title_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_title_bg_ef.9.png new file mode 100755 index 0000000..194b81b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_popup_title_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_reorder_group_list_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_reorder_group_list_bg.9.png new file mode 100755 index 0000000..9a78401 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_reorder_group_list_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_scroll_bar_handler_h.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_scroll_bar_handler_h.png new file mode 100755 index 0000000..e10b964 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_scroll_bar_handler_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_scroll_bar_handler_v.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_scroll_bar_handler_v.png new file mode 100755 index 0000000..b6c4e4c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_scroll_bar_handler_v.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_slider_handle_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_slider_handle_bg_ef.9.png new file mode 100755 index 0000000..3cb951d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_slider_handle_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_tab_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_tab_bg_ef.9.png new file mode 100755 index 0000000..cff4650 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_tab_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_tab_bg_focus_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_tab_bg_focus_ef.9.png new file mode 100755 index 0000000..ca3c5fd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_tab_bg_focus_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_tab_bg_line_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_tab_bg_line_ef.9.png new file mode 100755 index 0000000..c7e4078 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_tab_bg_line_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_title_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_title_bg_ef.9.png new file mode 100755 index 0000000..2c36a15 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_title_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_title_btn_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_title_btn_bg_ef.9.png new file mode 100755 index 0000000..c582427 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_title_btn_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_title_button_bg_ef_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_title_button_bg_ef_press.9.png new file mode 100755 index 0000000..f5a9958 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_title_button_bg_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_title_option_btn_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_title_option_btn_bg_ef.9.png new file mode 100755 index 0000000..a53b8a3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_title_option_btn_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_bg_ef.9.png new file mode 100755 index 0000000..563c4f0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_ef_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_ef_press.9.png new file mode 100755 index 0000000..7a01d37 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_press_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_press_ef.9.png new file mode 100755 index 0000000..7a01d37 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_tab_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_tab_bg_ef.9.png new file mode 100755 index 0000000..2a00506 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_tab_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_tab_bg_focus_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_tab_bg_focus_ef.9.png new file mode 100755 index 0000000..239d83f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_tab_bg_focus_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_tab_bg_line_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_tab_bg_line_ef.9.png new file mode 100755 index 0000000..6eb92e1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_toolbar_tab_bg_line_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/black/00_winset_badge.9.png b/res/common/usr/share/osp/bitmaps/720x1280/black/00_winset_badge.9.png new file mode 100755 index 0000000..ac9ba3c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/black/00_winset_badge.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon02_left.png b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon02_left.png new file mode 100755 index 0000000..863c1f6 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon02_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon02_left_press.png b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon02_left_press.png new file mode 100755 index 0000000..7e94e5f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon02_left_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon02_right.png b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon02_right.png new file mode 100755 index 0000000..8e6673c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon02_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon02_right_press.png b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon02_right_press.png new file mode 100755 index 0000000..ab6b886 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon02_right_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon_left.png b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon_left.png new file mode 100755 index 0000000..f632684 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon_left.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon_left_press.png b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon_left_press.png new file mode 100755 index 0000000..24d3570 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon_left_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon_right.png b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon_right.png new file mode 100755 index 0000000..e9df81d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon_right.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon_right_press.png b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon_right_press.png new file mode 100755 index 0000000..a81b556 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_Icon_right_press.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_icon_search.png b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_icon_search.png new file mode 100644 index 0000000..1eab182 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/copy&paste_icon_search.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_btn_circle_bg_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_btn_circle_bg_ef.png new file mode 100755 index 0000000..2514e2e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_btn_circle_bg_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_01_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_01_bg_ef.9.png new file mode 100755 index 0000000..bff4668 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_01_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_edit_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_edit_bg_ef.9.png new file mode 100755 index 0000000..4f5df27 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_edit_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_radio_normal1.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_radio_normal1.png new file mode 100755 index 0000000..22df054 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_radio_normal1.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_radio_normal2.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_radio_normal2.png new file mode 100755 index 0000000..7c94db0 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_radio_normal2.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_seg_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_seg_bg_ef.9.png new file mode 100755 index 0000000..c845459 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_seg_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_seg_f_bg_ef_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_seg_f_bg_ef_01.9.png new file mode 100755 index 0000000..e8e25bb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_seg_f_bg_ef_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_seg_f_bg_ef_02.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_seg_f_bg_ef_02.9.png new file mode 100755 index 0000000..09d9ff9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_seg_f_bg_ef_02.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_seg_f_bg_ef_03.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_seg_f_bg_ef_03.9.png new file mode 100755 index 0000000..c3758cd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_button_seg_f_bg_ef_03.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_check_bg.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_check_bg.png new file mode 100755 index 0000000..65946b9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_check_bg.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_color_picker_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_color_picker_bg.9.png new file mode 100755 index 0000000..4a33a07 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_color_picker_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_dialogue_group_bg_line.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_dialogue_group_bg_line.9.png new file mode 100755 index 0000000..7cfcb88 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_dialogue_group_bg_line.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_edit_field_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_edit_field_bg_ef.9.png new file mode 100755 index 0000000..22710ba Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_edit_field_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_edit_field_round_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_edit_field_round_bg.9.png new file mode 100755 index 0000000..deef7d8 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_edit_field_round_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_edit_field_round_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_edit_field_round_bg_ef.9.png new file mode 100755 index 0000000..30c1556 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_edit_field_round_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_groupedlist_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_groupedlist_bg_01.9.png new file mode 100755 index 0000000..f20e24c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_groupedlist_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_groupedlist_bottom_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_groupedlist_bottom_bg_01.9.png new file mode 100755 index 0000000..65c4668 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_groupedlist_bottom_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_groupedlist_center_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_groupedlist_center_bg_01.9.png new file mode 100755 index 0000000..3dccf23 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_groupedlist_center_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_groupedlist_top_bg_01.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_groupedlist_top_bg_01.9.png new file mode 100755 index 0000000..850352c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_groupedlist_top_bg_01.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_indexlist_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_indexlist_bg_ef.9.png new file mode 100755 index 0000000..55fdcf1 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_indexlist_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_indexlist_icon_line.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_indexlist_icon_line.png new file mode 100755 index 0000000..aa04e16 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_indexlist_icon_line.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_01_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_01_32x32.png new file mode 100644 index 0000000..92d3686 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_01_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_02_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_02_32x32.png new file mode 100644 index 0000000..3cba306 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_02_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_03_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_03_32x32.png new file mode 100644 index 0000000..9babc31 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_03_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_04_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_04_32x32.png new file mode 100644 index 0000000..3c72df5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_04_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_05_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_05_32x32.png new file mode 100644 index 0000000..bbb14cd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_05_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_06_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_06_32x32.png new file mode 100644 index 0000000..3719b53 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_06_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_07_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_07_32x32.png new file mode 100644 index 0000000..009b81f Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_07_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_08_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_08_32x32.png new file mode 100644 index 0000000..4a32e15 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_08_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_09_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_09_32x32.png new file mode 100644 index 0000000..aed8bf2 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_09_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_10_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_10_32x32.png new file mode 100644 index 0000000..f6f3194 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_10_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_11_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_11_32x32.png new file mode 100644 index 0000000..54db6c9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_11_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_12_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_12_32x32.png new file mode 100644 index 0000000..284b090 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_12_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_13_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_13_32x32.png new file mode 100644 index 0000000..09c9aa9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_13_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_14_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_14_32x32.png new file mode 100644 index 0000000..cd075b3 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_14_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_15_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_15_32x32.png new file mode 100644 index 0000000..885030c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_15_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_16_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_16_32x32.png new file mode 100644 index 0000000..26a877a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_16_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_17_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_17_32x32.png new file mode 100644 index 0000000..ff746b7 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_17_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_18_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_18_32x32.png new file mode 100644 index 0000000..07aeffd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_18_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_19_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_19_32x32.png new file mode 100644 index 0000000..16a9e1b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_19_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_20_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_20_32x32.png new file mode 100644 index 0000000..b409b03 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_20_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_21_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_21_32x32.png new file mode 100644 index 0000000..d5de1fb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_21_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_22_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_22_32x32.png new file mode 100644 index 0000000..fae4ddd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_22_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_23_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_23_32x32.png new file mode 100644 index 0000000..02d9314 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_23_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_24_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_24_32x32.png new file mode 100644 index 0000000..ff35805 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_24_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_25_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_25_32x32.png new file mode 100644 index 0000000..e027879 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_25_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_26_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_26_32x32.png new file mode 100644 index 0000000..bb86e11 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_26_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_27_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_27_32x32.png new file mode 100644 index 0000000..f2c2e5b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_27_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_28_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_28_32x32.png new file mode 100644 index 0000000..759af64 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_28_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_29_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_29_32x32.png new file mode 100644 index 0000000..42d4c29 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_29_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_30_32x32.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_30_32x32.png new file mode 100644 index 0000000..e78bff4 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_list_process_30_32x32.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bg_ef.9.png new file mode 100755 index 0000000..f19a0ab Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bottom_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bottom_bg.9.png new file mode 100755 index 0000000..51db12d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bottom_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_bg_ef.9.png new file mode 100755 index 0000000..d204e6a Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_tail_bottom_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_tail_bottom_ef.png new file mode 100755 index 0000000..ca16397 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_tail_bottom_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_tail_left_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_tail_left_ef.png new file mode 100755 index 0000000..481a785 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_tail_left_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_tail_right_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_tail_right_ef.png new file mode 100755 index 0000000..066492d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_tail_right_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_tail_top_ef.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_tail_top_ef.png new file mode 100755 index 0000000..d63a128 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_bubble_tail_top_ef.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_button_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_button_bg_ef.9.png new file mode 100755 index 0000000..bff4668 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_button_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_title_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_title_bg.9.png new file mode 100755 index 0000000..f5039fd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_title_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_title_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_title_bg_ef.9.png new file mode 100755 index 0000000..975da3e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_popup_title_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_reorder_group_list_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_reorder_group_list_bg.9.png new file mode 100755 index 0000000..1ad937d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_reorder_group_list_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_scroll_bar_handler_h.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_scroll_bar_handler_h.png new file mode 100755 index 0000000..c1d9feb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_scroll_bar_handler_h.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_scroll_bar_handler_v.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_scroll_bar_handler_v.png new file mode 100755 index 0000000..4172a3d Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_scroll_bar_handler_v.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_bg.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_bg.9.png new file mode 100755 index 0000000..ed8a75b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_bg.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_handle.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_handle.9.png new file mode 100755 index 0000000..c9f4b87 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_handle.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_handle_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_handle_bg_ef.9.png new file mode 100755 index 0000000..a9129ed Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_handle_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_handle_dim.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_handle_dim.9.png new file mode 100755 index 0000000..58e701b Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_handle_dim.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_handle_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_handle_press.9.png new file mode 100755 index 0000000..f855145 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_slider_handle_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_title_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_title_bg_ef.9.png new file mode 100755 index 0000000..d58bce5 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_title_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_title_btn_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_title_btn_bg_ef.9.png new file mode 100755 index 0000000..1cb56fb Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_title_btn_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_title_button_bg_ef_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_title_button_bg_ef_press.9.png new file mode 100755 index 0000000..38445bd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_title_button_bg_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_title_option_btn_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_title_option_btn_bg_ef.9.png new file mode 100755 index 0000000..a058b6e Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_title_option_btn_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_bg_ef.9.png new file mode 100755 index 0000000..34ad657 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_ef_press.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_ef_press.9.png new file mode 100755 index 0000000..b28acd9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_ef_press.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_press_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_press_ef.9.png new file mode 100755 index 0000000..b28acd9 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_press_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_tab_bg_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_tab_bg_ef.9.png new file mode 100755 index 0000000..174f94c Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_tab_bg_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_tab_bg_focus_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_tab_bg_focus_ef.9.png new file mode 100755 index 0000000..3c2eecd Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_tab_bg_focus_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_tab_bg_line_ef.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_tab_bg_line_ef.9.png new file mode 100755 index 0000000..4fcbcae Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_toolbar_tab_bg_line_ef.9.png differ diff --git a/res/common/usr/share/osp/bitmaps/720x1280/white/00_winset_badge.9.png b/res/common/usr/share/osp/bitmaps/720x1280/white/00_winset_badge.9.png new file mode 100755 index 0000000..2bdff30 Binary files /dev/null and b/res/common/usr/share/osp/bitmaps/720x1280/white/00_winset_badge.9.png differ diff --git a/res/common/usr/share/osp/effects/gallery_page_curling.eff b/res/common/usr/share/osp/effects/gallery_page_curling.eff new file mode 100755 index 0000000..460ded8 Binary files /dev/null and b/res/common/usr/share/osp/effects/gallery_page_curling.eff differ diff --git a/res/common/usr/share/osp/themes/black.xml b/res/common/usr/share/osp/themes/black.xml new file mode 100755 index 0000000..394e1ac --- /dev/null +++ b/res/common/usr/share/osp/themes/black.xml @@ -0,0 +1,244 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/common/usr/share/osp/themes/white.xml b/res/common/usr/share/osp/themes/white.xml new file mode 100755 index 0000000..c66a404 --- /dev/null +++ b/res/common/usr/share/osp/themes/white.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100755 index 0000000..badb99c --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,42 @@ +SET(SLP_INCLUDE_DIRS + /usr/include + /usr/include/appfw + /usr/include/glib-2.0 + /usr/lib/glib-2.0/include + /usr/include/cairo + /usr/include/chromium + /usr/include/dlog + /usr/include/dbus-1.0 + /usr/include/dri2 + /usr/include/libdrm + /usr/lib/dbus-1.0/include + /usr/include/e_dbus-1 + /usr/include/elementary-1 + /usr/include/efreet-1 + /usr/include/ecore-1 + /usr/include/edje-1 + /usr/include/evas-1 + /usr/include/eet-1 + /usr/include/eina-1 + /usr/include/eina-1/eina + /usr/include/ethumb-1 + /usr/include/freetype2 + /usr/include/fribidi + /usr/include/harfbuzz + /usr/include/libxml2 + /usr/include/minizip + /usr/include/pango-1.0 + /usr/include/pixman-1 + /usr/include/system + /usr/include/vconf +) + + +## Add SubModules +ADD_SUBDIRECTORY(graphics) +ADD_SUBDIRECTORY(graphics/opengl) +ADD_SUBDIRECTORY(ui) +ADD_SUBDIRECTORY(uifw) + + + diff --git a/src/app/FAppUiApp.cpp b/src/app/FAppUiApp.cpp new file mode 100644 index 0000000..a163b6c --- /dev/null +++ b/src/app/FAppUiApp.cpp @@ -0,0 +1,176 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// 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. +// + +/** + * @file FAppUiApp.cpp + * @brief This is the implementation for the UiApp class. + */ + +#include +#include +#include + +#include +#include "FApp_AppImpl.h" +#include "FApp_UiAppImpl.h" +#include "FApp_AppInfo.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui::Controls; + +namespace Tizen { namespace App +{ + +UiApp::UiApp(void) +{ + __pUiAppImpl = new (std::nothrow) _UiAppImpl(this); + SysAssertf(__pUiAppImpl != null, "Allocating memory for UiApp instance failed."); + SysTryReturnVoidResult(NID_APP, __pUiAppImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); +} + + +UiApp::~UiApp(void) +{ + delete __pUiAppImpl; +} + + +IAppFrame* +UiApp::GetAppFrame(void) const +{ + SysAssertf(__pUiAppImpl != null, "Getting UiApp instance failed."); + + return __pUiAppImpl->GetAppFrame(); +} + + +result +UiApp::AddFrame(const Frame& frame) +{ + SysAssertf(__pUiAppImpl != null, "Getting UiApp instance failed."); + + return __pUiAppImpl->AddFrame(frame); +} + + +result +UiApp::RemoveFrame(const Frame& frame) +{ + SysAssertf(__pUiAppImpl != null, "Getting UiApp instance failed."); + + return __pUiAppImpl->RemoveFrame(frame); +} + + +IList* +UiApp::GetFrameList(void) const +{ + SysAssertf(__pUiAppImpl != null, "Getting UiApp instance failed."); + + return __pUiAppImpl->GetFrameList(); +} + + +Frame* +UiApp::GetFrame(const String& name) const +{ + SysAssertf(__pUiAppImpl != null, "Getting UiApp instance failed."); + + return __pUiAppImpl->GetFrame(name); +} + + +Frame* +UiApp::GetFrameAt(int index) const +{ + SysAssertf(__pUiAppImpl != null, "Getting UiApp instance failed."); + + return __pUiAppImpl->GetFrameAt(index); +} + + +AppUiState +UiApp::GetAppUiState(void) const +{ + SysAssertf(__pUiAppImpl != null, "Getting UiApp instance failed."); + + return __pUiAppImpl->GetAppUiState(); +} + + +void +UiApp::OnForeground(void) +{ + +} + + +void +UiApp::OnBackground(void) +{ + +} + + +UiApp* +UiApp::GetInstance(void) +{ + _UiAppImpl* pUiAppImpl = _UiAppImpl::GetInstance(); + if (pUiAppImpl == null) + { + return null; + } + + return pUiAppImpl->GetUiAppInstance(); +} + + +result +UiApp::Execute(UiAppInstanceFactory pUiAppFactory, const IList* pArguments) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_APP, pUiAppFactory != null, E_INVALID_ARG, "pUiAppFactory must not be null."); + SysTryReturnResult(NID_APP, pArguments != null, E_INVALID_ARG, "pArguments must not be null."); + _AppInfo::SetAppType(_APP_TYPE_UI_APP); + + ClearLastResult(); + UiApp* pUiApp = pUiAppFactory(); + SysTryReturnResult(NID_APP, pUiApp != null, E_OUT_OF_MEMORY, "App allocation failed."); + SysTryReturnResult(NID_APP, !IsFailed(GetLastResult()), E_OUT_OF_MEMORY, "App allocation failed with %s.", GetLastResult()); + + _AppImpl* pAppImpl = _AppImpl::GetInstance(); + SysTryReturnResult(NID_APP, pAppImpl != null, E_SYSTEM, "application instance is not available."); + + _UiAppImpl* pUiAppImpl = _UiAppImpl::GetInstance(); + SysTryReturnResult(NID_APP, pUiAppImpl != null, E_INVALID_STATE, "Getting UiApp instance failed."); + + r = pAppImpl->Construct(pArguments); + SysTryCatch(NID_APP, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] %s.", GetErrorMessage(r)); + + r = pAppImpl->Execute(pUiAppImpl); + SysTryCatch(NID_APP, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] %s.", GetErrorMessage(r)); + +CATCH: + delete pUiApp; + + return r; +} + + +} } //Tizen::App diff --git a/src/app/FApp_AppFrame.cpp b/src/app/FApp_AppFrame.cpp new file mode 100644 index 0000000..a2d95fc --- /dev/null +++ b/src/app/FApp_AppFrame.cpp @@ -0,0 +1,162 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// 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. +// + +/** + * @file FApp_AppFrame.cpp + * @brief This is the implementation for the _AppFrame class. + */ + +#include + +#include + +#include "FApp_AppFrame.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +namespace Tizen { namespace App +{ + + +_AppFrame::_AppFrame(void) + : __pFrame(null) +{ +} + + +_AppFrame::_AppFrame(Frame& frame) + : __pFrame(&frame) +{ +} + + +_AppFrame::~_AppFrame(void) +{ +} + + +result +_AppFrame::Construct(void) +{ + result r = E_SUCCESS; + + return r; +} + + +result +_AppFrame::SetFrame(Frame* pFrame) +{ + result r = E_SUCCESS; + + __pFrame = pFrame; + + return r; +} + + +Canvas* +_AppFrame::GetCanvasN(void) const +{ + Canvas* pCanvas = null; + + SysTryCatch(NID_APP, __pFrame != null, , E_INVALID_STATE, "[E_INVALID_STATE] Frame instance must not be null."); + + pCanvas = __pFrame->GetCanvasN(); + SysTryCatch(NID_APP, pCanvas != null, , E_INVALID_STATE, "[E_SYSTEM] Failed while fetching the canvas."); + +CATCH: + return pCanvas; +} + + +result +_AppFrame::AddKeyEventListener(IKeyEventListener& listener) +{ + SysTryReturn(NID_APP, __pFrame != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Frame instance must not be null."); + + __pFrame->AddKeyEventListener(listener); + + return E_SUCCESS; +} + + +result +_AppFrame::RemoveKeyEventListener(IKeyEventListener& listener) +{ + SysTryReturnResult(NID_APP, __pFrame != null, E_INVALID_STATE, "Frame instance must not be null."); + + __pFrame->RemoveKeyEventListener(listener); + + return E_SUCCESS; +} + + +result +_AppFrame::AddTouchEventListener(ITouchEventListener& listener) +{ + SysTryReturnResult(NID_APP, __pFrame != null, E_INVALID_STATE, "Frame instance must not be null."); + + __pFrame->AddTouchEventListener(listener); + + return E_SUCCESS; +} + + +result +_AppFrame::RemoveTouchEventListener(ITouchEventListener& listener) +{ + SysTryReturnResult(NID_APP, __pFrame != null, E_INVALID_STATE, "Frame instance must not be null."); + + __pFrame->RemoveTouchEventListener(listener); + + return E_SUCCESS; +} + + +result +_AppFrame::AddWindowEventListener(IWindowEventListener& listener) +{ + SysTryReturnResult(NID_APP, __pFrame != null, E_INVALID_STATE, "Frame instance must not be null."); + + __pFrame->AddWindowEventListener(listener); + + return E_SUCCESS; +} + + +result +_AppFrame::RemoveWindowEventListener(IWindowEventListener& listener) +{ + SysTryReturnResult(NID_APP, __pFrame != null, E_INVALID_STATE, "Frame instance must not be null."); + + __pFrame->RemoveWindowEventListener(listener); + + return E_SUCCESS; +} + + +Frame* +_AppFrame::GetFrame(void) +{ + return __pFrame; +} + + +} } // Tizen::App diff --git a/src/app/FApp_AppResourceBitmap.cpp b/src/app/FApp_AppResourceBitmap.cpp new file mode 100644 index 0000000..de145f1 --- /dev/null +++ b/src/app/FApp_AppResourceBitmap.cpp @@ -0,0 +1,200 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// 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. +// + +/** + * @file FApp_AppResourceBitmap.cpp + * @brief This is the implementation for the _AppResourceBitmap class. + */ +#include + +#include +#include +#include +#include +#include +#include + +#include "FApp_AppResourceBitmap.h" +#include "FApp_AppResourceBitmapUtil.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Media; + +static const int BITMAP_PIXEL_FORMAT_INVALID = BITMAP_PIXEL_FORMAT_MIN; + +namespace Tizen { namespace App +{ + +_AppResourceBitmap* _AppResourceBitmap::__pTheInstance = null; + +_AppResourceBitmap::_AppResourceBitmap(void) + : __pAppResourceBitmapUtil(null) +{ +} + +_AppResourceBitmap::~_AppResourceBitmap(void) +{ +} + +void +_AppResourceBitmap::InitAppResourceBitmap(void) +{ + if (__pTheInstance != null) + { + return; + } + + static _AppResourceBitmap instance; + result r = instance.Construct(); + SysTryReturnVoidResult(NID_APP, r == E_SUCCESS, E_FAILURE, "[E_FAILURE] Failed to construct an _AppResourceBitmapImpl instance."); + + __pTheInstance = &instance; +} + +_AppResourceBitmap* +_AppResourceBitmap::GetInstance(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (__pTheInstance == null) + { + pthread_once(&once_block, InitAppResourceBitmap); + } + + return __pTheInstance; +} + +_AppResourceBitmap* +_AppResourceBitmap::GetInstanceByAppId(const String& appId) +{ + _AppResourceBitmap* pAppResourceBitmap = null; + + pAppResourceBitmap = new (std::nothrow) _AppResourceBitmap(); + SysTryReturn(NID_APP, pAppResourceBitmap != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pAppResourceBitmap->Construct(appId); + SysTryCatch(NID_APP, r == E_SUCCESS, , E_FAILURE, "[E_FAILURE] Failed to construct an _AppResourceBitmapImpl instance."); + + return pAppResourceBitmap; + +CATCH: + delete pAppResourceBitmap; + return null; +} + +result +_AppResourceBitmap::Construct(void) +{ + SysAssertf(!__pAppResourceBitmapUtil, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + unique_ptr<_AppResourceBitmapUtil> pNewAppResourceBitmapUtil(new (std::nothrow) _AppResourceBitmapUtil()); + SysTryReturnResult(NID_APP, pNewAppResourceBitmapUtil != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pNewAppResourceBitmapUtil->Construct(); + SysTryReturnResult(NID_APP, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to construct an _AppResourceBitmapUtil instance."); + + __pAppResourceBitmapUtil = move(pNewAppResourceBitmapUtil); + + return r; +} + +result +_AppResourceBitmap::Construct(const String& appId) +{ + SysAssertf(!__pAppResourceBitmapUtil, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + unique_ptr<_AppResourceBitmapUtil> pNewAppResourceBitmapUtil(new (std::nothrow) _AppResourceBitmapUtil()); + SysTryReturnResult(NID_APP, pNewAppResourceBitmapUtil != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pNewAppResourceBitmapUtil->Construct(appId); + SysTryReturnResult(NID_APP, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to construct an _AppResourceBitmapUtil instance."); + + __pAppResourceBitmapUtil = move(pNewAppResourceBitmapUtil); + + return r; +} + + +Bitmap* +_AppResourceBitmap::GetBitmapN(const String& imageFileName, BitmapPixelFormat pixelFormat) const +{ + ClearLastResult(); + SysTryReturn(NID_APP, imageFileName.IsEmpty() == false, null, E_INVALID_ARG, "[%s] Invalid argument is used. (imageFileName = null)", imageFileName.GetPointer()); + SysTryReturn(NID_APP, (pixelFormat >= BITMAP_PIXEL_FORMAT_MIN && pixelFormat < BITMAP_PIXEL_FORMAT_MAX), + null, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] The image file format or specified pixel format(%d) is not supported.", pixelFormat); + + // GetResourcePath + String resourcePath(null); + bool imageScaling(true); + _AppResourceBitmapUtil::_Density resourceDensity = _AppResourceBitmapUtil::DENSITY_NONE; + + result r = __pAppResourceBitmapUtil->GetResourcePath(imageFileName, resourcePath, resourceDensity, imageScaling); + SysTryReturn(NID_APP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturn(NID_APP, resourcePath.IsEmpty() == false, null, r = E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] The specified file does not exist."); + + + // GetBitmapN + Bitmap* pBitmap = null; + + if (pixelFormat == BITMAP_PIXEL_FORMAT_INVALID) + { + if (_ImageUtil::HasAlphaChannel(resourcePath)) + { + pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, BITMAP_PIXEL_FORMAT_ARGB8888, imageScaling); + } + else + { + const Color& magentaColor = Color::GetColor(COLOR_ID_MAGENTA); + pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, BITMAP_PIXEL_FORMAT_RGB565, imageScaling, &magentaColor); + } + } + else + { + pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, pixelFormat, imageScaling); + } + + SysLog(NID_APP, "The current value of bitmap path is %S(%S) and pixel format is %d", resourcePath.GetPointer(), imageScaling?L"scaled":L"not scaled", pixelFormat); + + + r = GetLastResult(); + SysTryReturn(NID_APP, pBitmap != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pBitmap; +} + +}} // Tizen::App + +#ifdef __cplusplus +extern "C" +{ +#endif +_OSP_EXPORT_ Tizen::App::_IAppResourceBitmap* +_Create_IAppResourceBitmapInstanceN(void) +{ + return Tizen::App::_AppResourceBitmap::GetInstance(); +} + +_OSP_EXPORT_ Tizen::App::_IAppResourceBitmap* +_Create_IAppResourceBitmapInstanceByAppIdN(const String& appId) +{ + return Tizen::App::_AppResourceBitmap::GetInstanceByAppId(appId); +} +#ifdef __cplusplus +} +#endif diff --git a/src/app/FApp_AppResourceBitmap.h b/src/app/FApp_AppResourceBitmap.h new file mode 100644 index 0000000..80b494c --- /dev/null +++ b/src/app/FApp_AppResourceBitmap.h @@ -0,0 +1,112 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// 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. +// + +/** + * @file FApp_AppResourceBitmap.h + * @brief This is the header file of the _AppResourceBitmap class. + */ + +#ifndef _FAPP_INTERNAL_APP_RESOURCE_BITMAP_H_ +#define _FAPP_INTERNAL_APP_RESOURCE_BITMAP_H_ + +#include + +#include +#include +#include +#include "FApp_IAppResourceBitmap.h" + +namespace Tizen { namespace App +{ +class _AppResourceBitmapUtil; + +class _AppResourceBitmap + : public Tizen::Base::Object + , public _IAppResourceBitmap +{ +public: + /** + * Gets the bitmap at the specified path. @n + * The %GetBitmapN() method interprets the given resource path and reads the best matching image file for the current device resolution. @n + * To load the bitmap image from a file, give the name of the file as the input parameter and not the file path (For example: "img.png"). + * Then, the system will first look for the image file in the folder specific to the current device resolution, such as + * '720x1280' and if the file does not exist, it will then search the folder that corresponds to the current screen density, + * such as 'screen-density-xhigh'. After searching the density folder, all the other density folders are searched in the order high to low. + * Currently supported image formats are: JPEG, GIF, PNG, BMP, TIFF, and WBMP. + * + * In this method, the system decides the proper pixel format. + * Currently supported image formats are: JPEG, GIF, PNG, BMP, TIFF, and WBMP. + * + * @since 2.0 + * + * @return A pointer to the Tizen::Graphics::Bitmap instance generated from the specified file + * @param[in] imagePath The relative path starting from the density directory @b "res/screen-density-XXX/" or @b "res/AxB", @n + * where A and B represent the width and height of the screen of the supported device models, respectively + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_UNSUPPORTED_FORMAT The image file format is not supported. + * @exception E_FILE_NOT_FOUND The specified file cannot be found. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @remarks There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer here. + */ + virtual Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat) const; + + static _AppResourceBitmap* GetInstance(void); + + static _AppResourceBitmap* GetInstanceByAppId(const Tizen::Base::String& appId); + +private: + /** + * This is the default constructor for this class. + */ + _AppResourceBitmap(void); + + /** + * This is the copy constructor for this class. + */ + _AppResourceBitmap(const _AppResourceBitmap& rhs); + + /** + * This is the destructor for this class. + */ + virtual ~_AppResourceBitmap(void); + + /** + * Initializes this instance of _AppResourceBitmap. + */ + result Construct(void); + + result Construct(const Tizen::Base::String& appId); + + /** + * This is the assignment operator for this class. + */ + _AppResourceBitmap& operator =(const _AppResourceBitmap& rhs); + + static void InitAppResourceBitmap(void); + +private: + std::unique_ptr<_AppResourceBitmapUtil> __pAppResourceBitmapUtil; + + static _AppResourceBitmap* __pTheInstance; + +}; // _AppResourceBitmap + +}} // Tizen::App + +#endif // _FAPP_INTERNAL_APP_RESOURCE_BITMAP_H_ diff --git a/src/app/FApp_AppResourceBitmapUtil.cpp b/src/app/FApp_AppResourceBitmapUtil.cpp new file mode 100644 index 0000000..0c2fb17 --- /dev/null +++ b/src/app/FApp_AppResourceBitmapUtil.cpp @@ -0,0 +1,559 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// 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. +// + +/** + * @file FApp_AppResourceBitmapUtil.cpp + * @brief This is the implementation for the _AppResourceBitmapUtil class. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include "FAppPkg_PackageInfoImpl.h" +#include "FApp_AppInfo.h" +#include "FApp_AppResourceBitmapUtil.h" + +using namespace std; +using namespace Tizen::App::Package; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Io; +using namespace Tizen::Media; +using namespace Tizen::Ui; + +namespace // unnamed +{ +MediaPixelFormat +ConvertBitmapPixelFormatToMediaPixelFormat(BitmapPixelFormat format) +{ + MediaPixelFormat out = MEDIA_PIXEL_FORMAT_NONE; + switch (format) + { + case BITMAP_PIXEL_FORMAT_RGB565: + out = MEDIA_PIXEL_FORMAT_RGB565LE; + break; + case BITMAP_PIXEL_FORMAT_ARGB8888: + out = MEDIA_PIXEL_FORMAT_BGRA8888; + break; + case BITMAP_PIXEL_FORMAT_R8G8B8A8: + out = MEDIA_PIXEL_FORMAT_RGBA8888; + break; + default: + break; + } + return out; +}} // unnamed namespace + +namespace Tizen { namespace Graphics +{ +result +_CreateCoordinateTransformer(_ICoordinateSystemTransformer*& pTransformer, int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize); +}} // Tizen::Graphics + +namespace Tizen { namespace App +{ + +_AppResourceBitmapUtil::_AppResourceBitmapUtil(void) + : __physicalResolutionDim(0, 0) + , __physicalBaseScreenSize(BASE_SCREEN_SIZE_DEFAULT) + , __resolutionDirectories(L"") + , __sortedDensityDirectories() +{ + for (int i = 0; i < DENSITY_MAX; i++) + { + __sortedDensity[i] = DENSITY_NONE; + } + __physicalResolutionDim = _CoordinateSystem::GetInstance()->GetPhysicalResolutionDim(); + __physicalBaseScreenSize = _CoordinateSystem::GetInstance()->GetPhysicalBaseScreenSize(); +} + +_AppResourceBitmapUtil::~_AppResourceBitmapUtil(void) +{ +} + +result +_AppResourceBitmapUtil::Construct(void) +{ + int deviceDPI = 0; + result r = Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/screen.dpi", deviceDPI); + SysTryReturnResult(NID_APP, r == E_SUCCESS, r, "[%s] Failed to get Screen DPI", GetErrorMessage(r)); + + // 1. Get directory path matched device's resolution (e.g.720x1280) + if (GetDirectoryPath(DENSITY_NONE, __resolutionDirectories) == false) + { + __resolutionDirectories = L""; + SysLog(NID_APP, "Failed to get a Device Resolution Directory path"); + } + + // 2. Get screen density & directory path matched device's DPI (e.g.screen-density-xhigh) + if (deviceDPI >= DPI_FOR_XHIGH) + { + __sortedDensity[0] = DENSITY_XHIGH; + } + else if (deviceDPI >= DPI_FOR_HIGH) + { + __sortedDensity[0] = DENSITY_HIGH; + } + else if (deviceDPI >= DPI_FOR_MIDDLE) + { + __sortedDensity[0] = DENSITY_MIDDLE; + } + else if (deviceDPI < DPI_FOR_MIDDLE && deviceDPI >= DPI_FOR_LOW) + { + __sortedDensity[0] = DENSITY_LOW; + } + else + { + __sortedDensity[0] = DENSITY_XHIGH; + SysLog(NID_APP, "Failed to get a Device Density (DPI = %d)", deviceDPI); + } + + if (GetDirectoryPath(__sortedDensity[0], __sortedDensityDirectories[0]) == false) + { + __sortedDensityDirectories[0] = L""; + SysLog(NID_APP, "Failed to get a Device Density Directory path"); + } + + // 3. Get screen density & directory path with fall back system (XHIGH-HIGH-MIDDLE-LOW) + int densityIndex = 1; + + for (int currentDensity = DENSITY_XHIGH; currentDensity >= DENSITY_LOW; currentDensity--) + { + SysAssert(densityIndex > DENSITY_NONE && densityIndex < DENSITY_MAX); + + if (static_cast(__sortedDensity[0]) == currentDensity) + { + continue; + } + + __sortedDensity[densityIndex] = static_cast<_Density>(currentDensity); + + if (GetDirectoryPath(__sortedDensity[densityIndex], __sortedDensityDirectories[densityIndex]) == false) + { + __sortedDensityDirectories[densityIndex] = L""; + SysLog(NID_APP, "Failed to get a %dth Fall-Back Directory path", densityIndex); + } + + densityIndex++; + } + + return r; +} + +result +_AppResourceBitmapUtil::Construct(const String& appId) +{ + int deviceDPI = 0; + result r = Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/screen.dpi", deviceDPI); + SysTryReturnResult(NID_APP, r == E_SUCCESS, r, "[%s] Failed to get Screen DPI", GetErrorMessage(r)); + + // 1. Get directory path matched device's resolution (e.g.720x1280) + if (GetDirectoryPath(DENSITY_NONE, __resolutionDirectories, appId) == false) + { + __resolutionDirectories = L""; + SysLog(NID_APP, "Failed to get a Device Resolution Directory path"); + } + + // 2. Get screen density & directory path matched device's DPI (e.g.screen-density-xhigh) + if (deviceDPI >= DPI_FOR_XHIGH) + { + __sortedDensity[0] = DENSITY_XHIGH; + } + else if (deviceDPI >= DPI_FOR_HIGH) + { + __sortedDensity[0] = DENSITY_HIGH; + } + else if (deviceDPI >= DPI_FOR_MIDDLE) + { + __sortedDensity[0] = DENSITY_MIDDLE; + } + else if (deviceDPI < DPI_FOR_MIDDLE && deviceDPI >= DPI_FOR_LOW) + { + __sortedDensity[0] = DENSITY_LOW; + } + else + { + __sortedDensity[0] = DENSITY_XHIGH; + SysLog(NID_APP, "Failed to get a Device Density (DPI = %d)", deviceDPI); + } + + if (GetDirectoryPath(__sortedDensity[0], __sortedDensityDirectories[0], appId) == false) + { + __sortedDensityDirectories[0] = L""; + SysLog(NID_APP, "Failed to get a Device Density Directory path"); + } + + // 3. Get screen density & directory path with fall back system (XHIGH-HIGH-MIDDLE-LOW) + int densityIndex = 1; + + for (int currentDensity = DENSITY_XHIGH; currentDensity >= DENSITY_LOW; currentDensity--) + { + SysAssert(densityIndex > DENSITY_NONE && densityIndex < DENSITY_MAX); + + if (static_cast(__sortedDensity[0]) == currentDensity) + { + continue; + } + + __sortedDensity[densityIndex] = static_cast<_Density>(currentDensity); + + if (GetDirectoryPath(__sortedDensity[densityIndex], __sortedDensityDirectories[densityIndex], appId) == false) + { + __sortedDensityDirectories[densityIndex] = L""; + SysLog(NID_APP, "Failed to get a %dth Fall-Back Directory path", densityIndex); + } + + densityIndex++; + } + + return r; +} + +// Get Resource DirectoryPath +bool +_AppResourceBitmapUtil::GetDirectoryPath(const _Density resourceDirectory, String& dirPath) const +{ + const String& homePath(_AppInfo::GetAppRootPath() + L"res/"); + + switch (resourceDirectory) + { + case DENSITY_NONE: + switch (__physicalResolutionDim.width) + { + case 720: + dirPath = L"720x1280"; + break; + + case 480: + dirPath = L"480x800"; + break; + + case 240: + dirPath = L"240x400"; + break; + + case 320: + dirPath = L"320x480"; + break; + + default: + break; + } + break; + + case DENSITY_XHIGH: + dirPath = L"screen-density-xhigh"; + break; + + case DENSITY_HIGH: + dirPath = L"screen-density-high"; + break; + + case DENSITY_MIDDLE: + dirPath = L"screen-density-middle"; + break; + + case DENSITY_LOW: + dirPath = L"screen-density-low"; + break; + + default: + dirPath = L'\0'; + return false; + } + + result r = dirPath.Insert(homePath, 0); + SysTryReturn(NID_APP, r == E_SUCCESS, false, r, "[%s] Failed to insert string.", GetErrorMessage(r)); + + if ( File::IsFileExist(dirPath) == false ) + { + dirPath = L'\0'; + return false; + } + return true; +} + +bool +_AppResourceBitmapUtil::GetDirectoryPath(const _Density resourceDirectory, String& dirPath, const String& appId) const +{ + PackageInfo* pPkgInfo = null; + pPkgInfo = _PackageManagerImpl::GetInstance()->GetPackageInfoN(appId); + _PackageInfoImpl* pPkgInfoImpl = _PackageInfoImpl::GetInstance(pPkgInfo); + SysTryReturn(NID_APP, pPkgInfoImpl != null, false, E_APP_NOT_INSTALLED, "[E_APP_NOT_INSTALLED] Failed to create the package info instance"); + + const String& homePath(pPkgInfoImpl->GetAppRootPath() + L"/res/"); + + delete pPkgInfo; + + switch (resourceDirectory) + { + case DENSITY_NONE: + switch (__physicalResolutionDim.width) + { + case 720: + dirPath = L"720x1280"; + break; + + case 480: + dirPath = L"480x800"; + break; + + case 240: + dirPath = L"240x400"; + break; + + case 320: + dirPath = L"320x480"; + break; + + default: + break; + } + break; + + case DENSITY_XHIGH: + dirPath = L"screen-density-xhigh"; + break; + + case DENSITY_HIGH: + dirPath = L"screen-density-high"; + break; + + case DENSITY_MIDDLE: + dirPath = L"screen-density-middle"; + break; + + case DENSITY_LOW: + dirPath = L"screen-density-low"; + break; + + default: + dirPath = L'\0'; + return false; + } + + result r = dirPath.Insert(homePath, 0); + SysTryReturn(NID_APP, r == E_SUCCESS, false, r, "[%s] Failed to insert string.", GetErrorMessage(r)); + + if ( File::IsFileExist(dirPath) == false ) + { + dirPath = L'\0'; + return false; + } + return true; +} + +// Get Resource File Path +bool +_AppResourceBitmapUtil::GetFilePath(const String& directoryPath, const String& fileName, String& filePath) const +{ + if (directoryPath == null) + { + filePath = null; + return false; + } + + const String& normalizedPseudoPath = NormalizePath(fileName); + SysAssert(normalizedPseudoPath.StartsWith(L"/", 0)); + + filePath = directoryPath + normalizedPseudoPath; + + return true; +} + +// Normalizing Path +String +_AppResourceBitmapUtil::NormalizePath(const String& path) const +{ + String normalizedPath = path; + + normalizedPath.Replace(L'\\', L'/'); + + if (normalizedPath.StartsWith(L"/", 0) == false) + { + result r = normalizedPath.Insert(L'/', 0); + SysTryLog(NID_APP, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + } + + return normalizedPath; +} + +// Get Matched Resource File Path +result +_AppResourceBitmapUtil::GetResourcePath(const String& fileName, String& resourcePath, _Density& resourceDensity, bool& imageScaling) const +{ + result r = E_SUCCESS; + + // 1. Try to search resolution Folder + String resourcePathForResolution(L""); + + if (__resolutionDirectories.IsEmpty() == false && + GetFilePath(__resolutionDirectories, fileName, resourcePathForResolution)) + { + if (File::IsFileExist(resourcePathForResolution)) + { + resourcePath = resourcePathForResolution; + resourceDensity = DENSITY_NONE; + imageScaling = false; + + r = E_SUCCESS; + return r; + } + } + + // 2. Try to search resource directory matched device's DPI + String resourcePathForDensity(L""); + + if (__sortedDensityDirectories[0].IsEmpty() == false && + GetFilePath(__sortedDensityDirectories[0], fileName, resourcePathForDensity)) + { + if (File::IsFileExist(resourcePathForDensity)) + { + resourcePath = resourcePathForDensity; + resourceDensity = __sortedDensity[0]; + imageScaling = _CoordinateSystem::GetInstance()->IsTransformEnabled(); + + r = E_SUCCESS; + return r; + } + } + + // 3. Try to find the alternative path with fall back + int fallbackIndex = 1; + String alternativeResourcePath(L""); + + for (int findingDensity = DENSITY_XHIGH; findingDensity > DENSITY_LOW; findingDensity--) + { + if (__sortedDensityDirectories[fallbackIndex].IsEmpty() == false && + GetFilePath(__sortedDensityDirectories[fallbackIndex], fileName, alternativeResourcePath)) + { + if (File::IsFileExist(alternativeResourcePath)) + { + resourcePath = alternativeResourcePath; + resourceDensity = __sortedDensity[fallbackIndex]; + imageScaling = true; + + r = E_SUCCESS; + return r; + } + } + fallbackIndex++; + } + + SysTryReturn(NID_APP, r == E_SUCCESS, E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] The specified file cannot be found."); + return r; +} + +// GetBitmapN +Bitmap* +_AppResourceBitmapUtil::GetBitmapN(const String& resourcePath, const _Density resourceDensity, + BitmapPixelFormat pixelFormat, bool imageScaling, const Color* pChromaKeyColor) const +{ + ClearLastResult(); + SysTryReturn(NID_APP, (pixelFormat > BITMAP_PIXEL_FORMAT_MIN && pixelFormat < BITMAP_PIXEL_FORMAT_MAX), null, + E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] The image file format or specified pixel format(%d) is not supported.", pixelFormat); + + result r = E_SUCCESS; + + unique_ptr pBitmap; + + if (!pChromaKeyColor && imageScaling == false) // NonScaling + { + pBitmap.reset(new (std::nothrow) Bitmap()); + SysTryReturn(NID_APP, pBitmap != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = _BitmapImpl::GetInstance(*pBitmap)->Construct(resourcePath, pixelFormat); + SysTryReturn(NID_APP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pBitmap.release(); + } + else // Scaling + { + MediaPixelFormat format = ConvertBitmapPixelFormatToMediaPixelFormat(pixelFormat); + int imageWidth(-1); + int imageHeight(-1); + + std::unique_ptr pBuffer(_ImageDecoder::DecodeToBufferN(resourcePath, format, imageWidth, imageHeight)); + r = GetLastResult(); + SysTryReturn(NID_APP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturn(NID_APP, pBuffer != null, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + pBitmap.reset(_BitmapImpl::GetNonScaledBitmapN(*pBuffer, Dimension(imageWidth, imageHeight), pixelFormat)); + r = GetLastResult(); + SysTryReturn(NID_APP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturn(NID_APP, pBitmap != null, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + int resourceLogicalCoordinate = __physicalResolutionDim.width; + + switch (resourceDensity) + { + case DENSITY_XHIGH: + resourceLogicalCoordinate = 720; + break; + + case DENSITY_HIGH: + resourceLogicalCoordinate = 480; + break; + + case DENSITY_MIDDLE: + resourceLogicalCoordinate = 320; + break; + + case DENSITY_LOW: + resourceLogicalCoordinate = 240; + break; + + default: + break; + } + + _ICoordinateSystemTransformer* pTempXformer(null); + r = _CreateCoordinateTransformer(pTempXformer, + resourceLogicalCoordinate, __physicalBaseScreenSize, + Dimension(_CoordinateSystem::GetInstance()->GetLogicalResolutionInt(), _CoordinateSystem::GetInstance()->GetLogicalResolutionInt()), _CoordinateSystem::GetInstance()->GetLogicalBaseScreenSize()); + + std::unique_ptr<_ICoordinateSystemTransformer> pXformer(pTempXformer); + SysTryReturn(NID_APP, pXformer != null, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + SysTryReturn(NID_APP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + Dimension baseImageSize = pXformer->Transform(Dimension(imageWidth, imageHeight)); + r = GetLastResult(); + SysTryReturn(NID_APP, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + r = pBitmap->Scale(baseImageSize); + SysTryReturn(NID_APP, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + } + + if (pChromaKeyColor != null) + { + r = pBitmap->SetMaskingColor(pChromaKeyColor); + SysTryReturn(NID_APP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + SetLastResult(E_SUCCESS); + + return pBitmap.release(); +} + +}} // Tizen::App diff --git a/src/app/FApp_AppResourceBitmapUtil.h b/src/app/FApp_AppResourceBitmapUtil.h new file mode 100644 index 0000000..c540274 --- /dev/null +++ b/src/app/FApp_AppResourceBitmapUtil.h @@ -0,0 +1,118 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// 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. +// + +/** + * @file FApp_AppResourceBitmapUtil.h + * @brief This is the header file of the _AppResourceBitmapUtil. + */ + +#ifndef _FAPP_INTERNAL_APP_RESOURCE_BITMAP_UTIL_H_ +#define _FAPP_INTERNAL_APP_RESOURCE_BITMAP_UTIL_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Graphics +{ +class Bitmap; +class Color; +}} // Tizen::Graphics + +namespace Tizen { namespace Media +{ +class Image; +}} // Tizen::Media + +namespace Tizen { namespace App +{ +class _AppResourceBitmapUtil + : public Tizen::Base::Object +{ +public: + enum _Density + { + DENSITY_NONE = -1, + + DENSITY_LOW = 0, + DENSITY_MIDDLE = 1, + DENSITY_HIGH = 2, + DENSITY_XHIGH = 3, + + DENSITY_MAX = 4 + }; + + // + // This is the default constructor for this class. + // + _AppResourceBitmapUtil(void); + + /** + * This is the destructor for this class. + */ + virtual ~_AppResourceBitmapUtil(void); + + result Construct(void); + + result Construct(const Tizen::Base::String& appId); + + // Generates the directory path from the specified resolution. + bool GetDirectoryPath(_Density resourceDirectory, Tizen::Base::String& dirPath) const; + + bool GetDirectoryPath(_Density resourceDirectory, Tizen::Base::String& dirPath, const Tizen::Base::String& appId) const; + + // Generates the real path using a pseudo-path and the specified resolution. + bool GetFilePath(const Tizen::Base::String& directoryPath, const Tizen::Base::String& fileName, Tizen::Base::String& filePath) const; + + // The normalized path starts with and is divided by '/'. + // ex. L"/Dir1/Dir2/Dir3/File" + Tizen::Base::String NormalizePath(const Tizen::Base::String& path) const; + + // Generates the real path and examine whether the size of the resource is logical or physical by processing the input path. + result GetResourcePath(const Tizen::Base::String& fileName, Tizen::Base::String& resourcePath, _Density& resourceDensity, bool& imageScaling) const; + + // Create Bitmap from real image path + Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& resourcePath, _Density resourceDensity, + Tizen::Graphics::BitmapPixelFormat pixelFormat, bool imageScaling, const Tizen::Graphics::Color* pChromaKeyColor = null) const; + +private: + static const int DPI_FOR_XHIGH = 290; + static const int DPI_FOR_HIGH = 200; + static const int DPI_FOR_MIDDLE = 150; + static const int DPI_FOR_LOW = 0; + + Tizen::Graphics::Dimension __physicalResolutionDim; + Tizen::Graphics::_BaseScreenSize __physicalBaseScreenSize; + + // resource directory path for only device's resolution. + Tizen::Base::String __resolutionDirectories; + + /** + * Index information of __sortedDensity & __sortedDensityDirectories. + * '0' is for screen density matched device's DPI. + * '1', '2', '3' is for screen density with fall back system. + */ + _Density __sortedDensity[DENSITY_MAX]; + Tizen::Base::String __sortedDensityDirectories[DENSITY_MAX]; + +}; // _AppResourceBitmapUtil + +}} // Tizen::App + +#endif // _FAPP_INTERNAL_APP_RESOURCE_BITMAP_UTIL_H_ diff --git a/src/app/FApp_UiAppImpl.cpp b/src/app/FApp_UiAppImpl.cpp new file mode 100644 index 0000000..ddbe488 --- /dev/null +++ b/src/app/FApp_UiAppImpl.cpp @@ -0,0 +1,522 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// 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. +// + +/** + * @file FApp_UiAppImpl.cpp + * @brief This is the implementation for the _UiAppImpl class. + */ + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FApp_AppFrame.h" +#include "FApp_AppInfo.h" +#include "FApp_AppImpl.h" +#include "FApp_UiAppImpl.h" +#include "FApp_AppArg.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::System; +using namespace Tizen::Graphics; + + +extern "C" int appsvc_request_transient_app(bundle*, Ecore_X_Window, appsvc_host_res_fn, void*); + +namespace Tizen { namespace App +{ + +_UiAppImpl* _UiAppImpl::__pUiAppImpl = null; + + +_UiAppImpl::_UiAppImpl(UiApp* pUiApp) + : __pAppFrame(null) + , __pAppImpl(_AppImpl::GetInstance()) + , __appUiState(APP_UI_STATE_BACKGROUND) + , __pFrameList(null) + , __pUiApp(pUiApp) +{ + __pUiAppImpl = this; + __pFrameList = new (std::nothrow) ArrayList(); + SysTryReturnVoidResult(NID_APP, __pFrameList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + __pFrameList->Construct(); + SysTryReturnVoidResult(NID_APP, __pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed."); +} + + +_UiAppImpl::~_UiAppImpl(void) +{ + RemoveAllFrames(); + + delete __pAppFrame; + __pUiAppImpl = null; +} + + +bool +_UiAppImpl::OnCreate(void) +{ + SysLog(NID_APP, "Platform creation event."); + + _AppInfo::SetAppState(INITIALIZING); + + return true; +} + + +static int +TransientResponseCb(void* pData) +{ + SysLog(NID_APP, "Handling cleanup for submode app."); + + // platform invokes ecore_main_loop_quit() after returning this callback + return 0; +} + +void +_UiAppImpl::OnService(service_s* service, bool initial) +{ + Frame* pFrame = dynamic_cast(__pFrameList->GetAt(0)); + + // [INFO] to confirm that the window is not foreground + _EcoreEvas* pEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + if (pEvas) + { + int pid = pEvas->GetProcessId(pEvas->GetActiveWindow()); + SysLog(NID_APP, "%d -> %d", pid, _AppInfo::GetProcessId()); + if (pid != _AppInfo::GetProcessId()) + { + if (!initial) + { + if (pFrame != null) + { + _FrameImpl* pFrameImpl = _FrameImpl::GetInstance(*pFrame); + + // [FIXME] Multi window handling + if (pFrameImpl != null) + { + pEvas->ActivateWindow(pFrameImpl->GetCore()); + } + } + } + } + } + + // make OnForeground event + if (pFrame != null) + { + // handle submode + if (pEvas && _AppInfo::IsSubMode()) + { + _FrameImpl* pFrameImpl = _FrameImpl::GetInstance(*pFrame); + if (pFrameImpl != null) + { + unsigned int curHandle = pFrameImpl->GetNativeHandle(); + + bundle* pBundle = _AppArg::GetBundleFromSvc(service); + int ret = appsvc_request_transient_app(pBundle, curHandle, TransientResponseCb, NULL); + + SysLog(NID_APP, "Transient sets for (0x%x) with result (%d).", curHandle, ret); + } + } + + OnResume(); + //pFrame->Show(); + } +} + + +void +_UiAppImpl::OnTerminate(void) +{ + SysLog(NID_APP, "Termination event 0x%x state", _AppInfo::GetAppState()); + + if (OnUiAppImplTerminating() != true) + { + SysLog(NID_APP, "[E_SYSTEM] The Termination of application failed."); + } +} + + +void +_UiAppImpl::OnResume(void) +{ + SysLog(NID_APP, "System resume event on 0x%x state", _AppInfo::GetAppState()); + + if (_AppInfo::GetAppState() == RUNNING) + { + OnForeground(); + } +} + + +void +_UiAppImpl::OnPause(void) +{ + SysLog(NID_APP, "System pause event on 0x%x state", _AppInfo::GetAppState()); + + if (_AppInfo::GetAppState() == RUNNING) + { + OnBackground(); + } +} + + +void +_UiAppImpl::OnDeviceOrientationChanged(app_device_orientation_e orientation) +{ + SysLog(NID_APP, "System device orientation event."); + + _ControlImplManager* pControlImplManager = _ControlImplManager::GetInstance(); + if (pControlImplManager == null) + { + SysLog(NID_APP, "Device orientation event arrived too early."); + return; + } + + pControlImplManager->OnScreenRotated(orientation); +} + + +long +_UiAppImpl::OnWindowHandleRequest(void) +{ + const _EcoreEvas* const pEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + return (pEvas) ? static_cast(pEvas->GetXWindow()) : -1; +} + + +result +_UiAppImpl::AddFrame(const Frame& frame) +{ + result r = E_SUCCESS; + Frame& tmpFrame = const_cast (frame); + + SysTryReturnResult(NID_APP, __pFrameList != null, E_INVALID_STATE, "Getting FrameList failed."); + SysTryReturnResult(NID_APP, !__pFrameList->Contains(tmpFrame), E_OBJ_ALREADY_EXIST, "The frame is already registered."); + + _WindowImpl* pFrameImpl = _WindowImpl::GetInstance(tmpFrame); + SysTryReturnResult(NID_APP, pFrameImpl != null, E_INVALID_ARG, "The frame is not constructed yet."); + + __pFrameList->Add(tmpFrame); + r = pFrameImpl->Open(false); // Attach to the main tree without 'draw & show'. + if (IsFailed(r)) + { + SysLog(NID_UI, "Failed to attach frame."); + __pFrameList->Remove(tmpFrame); + } + + return r; +} + + +IAppFrame* +_UiAppImpl::GetAppFrame(void) +{ + SysTryReturn(NID_APP, __pFrameList != null, null, E_INVALID_STATE, "[E_INVALID_STATE] Getting FrameList failed."); + int frameCount = __pFrameList->GetCount(); + + if (frameCount <= 0) + { + SysLogException(NID_APP, E_OBJ_NOT_FOUND, "There is no frame !!! use AddFrame() before call GetAppFrame()"); + SysAssertf(false, "There is no frame !!! use AddFrame() before call GetAppFrame()"); + } + + Frame* pFrame = dynamic_cast (__pFrameList->GetAt(frameCount - 1)); + + if (pFrame == null) + { + SysLogException(NID_APP, E_OBJ_NOT_FOUND, "There is no frame !!! use AddFrame() before call GetAppFrame()"); + SysAssertf(false, "There is no frame !!! use AddFrame() before call GetAppFrame()"); + } + + if (__pAppFrame == null) + { + __pAppFrame = new (std::nothrow) _AppFrame(*pFrame); + SysTryReturn(NID_APP, __pAppFrame != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + __pAppFrame->Construct(); + } + else if (__pAppFrame->GetFrame() != pFrame) + { + __pAppFrame->SetFrame(pFrame); + } + + return __pAppFrame; +} + + +result +_UiAppImpl::RemoveFrame(const Frame& frame) +{ + result r = E_SUCCESS; + SysTryReturnResult(NID_APP, __pFrameList != null, E_INVALID_STATE, "Getting FrameList failed."); + + r = __pFrameList->Remove(frame); + if (!IsFailed(r)) + { + delete &frame; + } + + return r; +} + + +result +_UiAppImpl::RemoveAllFrames(void) +{ + result r = E_SUCCESS; + SysTryReturnResult(NID_APP, __pFrameList != null, E_INVALID_STATE, "Getting FrameList failed."); + + if (__pFrameList->GetCount() > 0) + { + __pFrameList->RemoveAll(true); + } + + delete __pFrameList; + __pFrameList = null; + + return r; +} + + +IList* +_UiAppImpl::GetFrameList(void) +{ + return __pFrameList; +} + + +Frame* +_UiAppImpl::GetFrame(const String& name) +{ + Frame* pFrame = null; + SysTryReturn(NID_APP, __pFrameList != null, null, E_INVALID_STATE, "[E_INVALID_STATE] Getting FrameList failed."); + int frameCount = __pFrameList->GetCount(); + + for (int i = 0; i < frameCount; i++) + { + pFrame = dynamic_cast (__pFrameList->GetAt(i)); + + if (pFrame != null && pFrame->GetName() == name) + { + return pFrame; + } + } + + return null; +} + + +Frame* +_UiAppImpl::GetFrameAt(int index) +{ + Frame* pFrame = null; + SysTryReturn(NID_APP, __pFrameList != null, null, E_INVALID_STATE, "[E_INVALID_STATE] Getting FrameList failed."); + SysTryReturn(NID_APP, index >= 0, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is less than 0."); + + int frameCount = __pFrameList->GetCount(); + SysTryReturn(NID_APP, index < frameCount, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is greater than the number of frames."); + + pFrame = dynamic_cast (__pFrameList->GetAt(index)); + + return pFrame; +} + +// For header inclusion dependency, elementary-1/elm_config.h is not included +extern "C" const char* elm_config_preferred_engine_set(const char*); + +bool +_UiAppImpl::OnAppInitializing(void) +{ + // Do Ui related initializing for UiApp + result r = InitializeUiFramework(); + if (IsFailed(r)) + { + SysLogException(NID_APP, E_SYSTEM, "Getting resolution information failure. Application may not be installed correctly."); + _Process::Exit(-1); + } + + _KeyEventManager* pKeyManager = _KeyEventManager::GetInstance(); + if (pKeyManager) + { + pKeyManager->AddKeyEventListener(*this); + } + + // API versioning for initial frame creation + if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { // if API version is less than 3.0, create initial frame + Frame* pDefaultFrame = new (std::nothrow) Frame(); + SysTryReturn(NID_APP, pDefaultFrame != null, false, r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Frame creation failed."); + pDefaultFrame->Construct(); + AddFrame(*pDefaultFrame); + SysLog(NID_APP, "Default frame is added for API version %d.", _AppInfo::GetApiVersion()); + } + + SysTryReturn(NID_APP, __pUiApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting UiApp instance failed."); + + SysLog(NID_APP, "Entering user OnAppInitializing()."); + const bool bReturn = __pUiApp->OnAppInitializing(*(AppRegistry::GetInstance())); + + SysLog(NID_APP, "Back to the platform initializing routine."); + return bReturn; +} + + +bool +_UiAppImpl::OnAppInitialized(void) +{ + SysTryReturn(NID_APP, __pUiApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting UiApp instance failed."); + + if (__pUiApp->OnAppInitialized()) + { + if (__pFrameList->GetCount() > 0) + { + return true; + } + else + { + SysLogException(NID_APP, E_OBJ_NOT_FOUND, "There is no frame !!! use AddFrame() before returning OnAppInitialized()"); + SysAssertf(false, "There is no frame !!! use AddFrame() before returning OnAppInitialized()"); + } + } + return false; +} + + +bool +_UiAppImpl::OnUiAppImplTerminating(void) +{ + bool result = false; + + RemoveAllFrames(); + + if (_AppInfo::GetAppState() != TERMINATED) + { + result = __pUiApp->OnAppTerminating(*(AppRegistry::GetInstance()), false); + _AppInfo::SetAppState(TERMINATED); + } + + // Do Ui related finalizing for UiApp + FinalizeUiFramework(); + + return result; +} + + +bool +_UiAppImpl::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) +{ + return false; +} + + +bool +_UiAppImpl::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) +{ + if (__appUiState == APP_UI_STATE_FOREGROUND) + { + if (keyInfo.GetKeyCode() == _KEY_END) + { + SysTryReturn(NID_APP, __pUiApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting UI App instance failed."); + + if (__pUiApp->OnAppWillTerminate()) + { + __pUiApp->Terminate(); + return true; + } + } + } + return false; +} + + +void +_UiAppImpl::OnForeground(void) +{ + result r = E_SUCCESS; + + SysLog(NID_APP, "Invoking application callback."); + + __appUiState = APP_UI_STATE_FOREGROUND; + __pUiApp->OnForeground(); + + SysLog(NID_APP, "Returned from application callback."); + + r = _PowerManagerImpl::OnForeground(); + + SysTryLog(NID_APP, !IsFailed(r), "Failed to send foreground event to powermanager"); +} + + +void +_UiAppImpl::OnBackground(void) +{ + result r = E_SUCCESS; + + SysLog(NID_APP, "Invoking application callback."); + + __appUiState = APP_UI_STATE_BACKGROUND; + __pUiApp->OnBackground(); + + SysLog(NID_APP, "Returned from application callback."); + + r = _PowerManagerImpl::OnBackground(); + + SysTryLog(NID_APP, !IsFailed(r), "Failed to send background event to powermanager"); +} + + +AppUiState +_UiAppImpl::GetAppUiState(void) const +{ + return __appUiState; +} + + +_UiAppImpl* +_UiAppImpl::GetInstance(void) +{ + return __pUiAppImpl; +} + + +UiApp* +_UiAppImpl::GetUiAppInstance(void) +{ + return __pUiApp; +} + + +} } //Tizen::App diff --git a/src/app/inc/FApp_AppFrame.h b/src/app/inc/FApp_AppFrame.h new file mode 100644 index 0000000..047b2c7 --- /dev/null +++ b/src/app/inc/FApp_AppFrame.h @@ -0,0 +1,123 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// 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. +// + +/** + * @file FApp_AppFrame.h + * @brief This is the header file for _AppFrame. + */ + +#ifndef _FAPP_INTERNAL_APP_FRAME_H_ +#define _FAPP_INTERNAL_APP_FRAME_H_ + +#include +#include +#include + +namespace Tizen { namespace Graphics { class Canvas; } } +namespace Tizen { namespace Ui { class IKeyEventListener; } } +namespace Tizen { namespace Ui { class ITouchEventListener; } } +namespace Tizen { namespace Ui { class IWindowEventListener; } } +namespace Tizen { namespace Ui { namespace Controls { class Frame; } } } + +namespace Tizen { namespace App +{ + +// +// @class _AppFrame +// @brief This is implementation of the application frame. +// @since 1.0 +// +class _AppFrame + : public Tizen::Base::Object + , public virtual IAppFrame +{ +public: + + _AppFrame(Tizen::Ui::Controls::Frame& pFrame); + + /** + * Constructs this instance. + * + * @return An error code. + * @exception E_SUCCESS - This method is successful. + * @exception E_OUT_OF_MEMORY - Memory allocation failed. + * @exception E_INVALID_STATE - Already constructed. + * @exception E_SYSTEM - System internal error. + */ + result Construct(void); + + /** + * This is a destructor. + */ + virtual ~_AppFrame(void); + + /** + * Gets the application frame's canvas. + * + * @return See above. + */ + virtual Tizen::Graphics::Canvas* GetCanvasN(void) const; + + /** + * Adds a listener for key event. + * + * @param[in] pListener a listener for key event + * @return An error code. + * @exception E_SUCCESS - This method is successful. + * @exception E_OUT_OF_MEMORY - Memory allocation has failed. + */ + virtual result AddKeyEventListener(Tizen::Ui::IKeyEventListener& listener); + + /** + * Removes an existing key event listener. + * + * @param[in] pListener a listener to be removed + * @return An error code. + * @exception E_SUCCESS - This method is successful. + * @exception E_OBJ_NOT_FOUND - The specified object is not found. + */ + virtual result RemoveKeyEventListener(Tizen::Ui::IKeyEventListener& listener); + + virtual result AddTouchEventListener(Tizen::Ui::ITouchEventListener& listener); + + virtual result RemoveTouchEventListener(Tizen::Ui::ITouchEventListener& listener); + + virtual result AddWindowEventListener(Tizen::Ui::IWindowEventListener& listener); + + virtual result RemoveWindowEventListener(Tizen::Ui::IWindowEventListener& listener); + + virtual Tizen::Ui::Controls::Frame* GetFrame(void); + + result SetFrame(Tizen::Ui::Controls::Frame* pFrame); + +private: + /** + * This is a default constructor. + */ + _AppFrame(void); + + _AppFrame(const _AppFrame& value); + + _AppFrame& operator =(const _AppFrame& value); + +private: + Tizen::Ui::Controls::Frame* __pFrame; +}; // _AppFrame + +} } // Tizen::App + +#endif // _FAPP_INTERNAL_APP_FRAME_H_ diff --git a/src/app/inc/FApp_UiAppImpl.h b/src/app/inc/FApp_UiAppImpl.h new file mode 100644 index 0000000..f1c8162 --- /dev/null +++ b/src/app/inc/FApp_UiAppImpl.h @@ -0,0 +1,331 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// 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. +// + +/** + * @file FApp_UiAppImpl.h + * @brief This is the header file for the %_UiAppImpl class. + */ + +#ifndef _FAPP_INTERNAL_UI_APP_IMPL_H_ +#define _FAPP_INTERNAL_UI_APP_IMPL_H_ + +#include + +#include +#include + +#include +#include + +#include "FApp_IAppImpl.h" + +namespace Tizen { namespace Base { namespace Collection { class IList; } } } +namespace Tizen { namespace Ui {namespace Controls { class Frame; } } } + +namespace Tizen { namespace App +{ + +class IAppFrame; +class _AppFrame; + +/** + * @class _UiAppImpl + * @brief This class is the Impl class of a UiApp class. + * @since 2.0 + * + * This class is the Impl class of a UiApp class. + */ +class _OSP_EXPORT_ _UiAppImpl + : public Tizen::Base::Object + , public Tizen::App::_IAppImpl + , public Tizen::Ui::_IKeyEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * Returns the _UiAppImpl's instance pointer. + * + * @since 2.0 + * @return A pointer to the %_UiAppImpl instance, @n + * else @c null if it fails + */ + static _UiAppImpl* GetInstance(void); + + /** + * Returns the UiApp's instance pointer. + * + * @since 2.0 + * @return A pointer to the %UiApp instance, @n + * else @c null if it fails + */ + UiApp* GetUiAppInstance(void); + + /** + * Called when the application is started + * + * @since 2.0 + * @return @c true if the method is successful, @n + * else @c false + * @param[in] user_data The user data passed from the callback registration function + * @remarks This is a system dependent callback function + */ + virtual bool OnCreate(void); + + /** + * Called when other application send the launch request to the application + * + * @since 2.0 + * @param[in] service The handle to the service + * @param[in] user_data The user data passed from the callback registration function + * @remarks This is a system dependent callback function + */ + virtual void OnService(service_s* service, bool initial); + + /** + * Called when the application is completely obscured by another application and becomes invisible + * + * @since 2.0 + * @param[in] user_data The user data passed from the callback registration function + * @remarks This is a system dependent callback function + */ + virtual void OnPause(void); + + /** + * Called when the application becomes visible + * + * @since 2.0 + * @param[in] user_data The user data passed from the callback registration function + * @remarks This is a system dependent callback function + */ + virtual void OnResume(void); + + /** + * Called once after the main loop of application exits + * + * @since 2.0 + * @param[in] user_data The user data passed from the callback registration function + * @remarks This is a system dependent callback function + */ + virtual void OnTerminate(void); + + /** + * Called when an orintation event occurs. + * + * @since 2.0 + * @param[in] orientation The information about the orientation event + */ + virtual void OnDeviceOrientationChanged(app_device_orientation_e orientation); + + /** + * Called when the application's state changes to Tizen::App::AppState::INITIALIZING. @n + * + * @since 2.0 + * @return @c true if the method is successful, @n + * else @c false + */ + virtual bool OnAppInitializing(void); + + /** + * Called when the application's INITIALIZING state is finished + * + * @since 2.0 + * @return @c true if the method is successful, @n + * else @c false + */ + virtual bool OnAppInitialized(void); + + + /** + * Called when the internal window handle is required. + * + * @since 2.0 + */ + virtual long OnWindowHandleRequest(void); + + /** + * Called when the application's state change to Tizen::App::AppState::TERMINATING. @n + * + * @since 2.0 + * @param[in] forcedTermination @c true if the application terminate by system or other application, else @c false. + * @return @c true if the method is successful, @n + * else @c false + */ + bool OnUiAppImplTerminating(void); + + /** + * Gets the first frame in the frame list of the UI application. @n + * + * @since 2.0 + * + * @return A pointer to the IAppFrame interface of the frame, @n + * else @c null if it fails + */ + IAppFrame* GetAppFrame(void); + + /** + * Notifies when a key is pressed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] keyCode The key code + */ + virtual bool OnKeyPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_KeyInfo& keyInfo); + + /** + * Notifies when a key is released. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] keyCode The key code + */ + virtual bool OnKeyReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_KeyInfo& keyInfo); + +private: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _UiAppImpl(void); + + /** + * This is the constructor for this class. + * + * @since 2.0 + */ + _UiAppImpl(UiApp* pUiApp); + + /** + * This is the copy constructor for the this class. + */ + _UiAppImpl(const _UiAppImpl& source); + + /** + * This is the assignment operator for this class. + */ + _UiAppImpl& operator =(const _UiAppImpl& source); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_UiAppImpl(void); + + /** + * Delete all frames of Ui application. @n + * + * @since 2.0 + * + * @return An error code + */ + result RemoveAllFrames(void); + + /** + * Adds the frame at the end of the list maintained by the UI application. @n + * + * @since 2.0 + * + * @return An error code + * @param[in] frame The frame to be added to the UI application + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE The application state is invalid. + * @exception E_OBJ_ALREADY_EXIST The frame to be added is already registered to the UI application. + * @exception E_OUT_OF_MEMORY Insufficient memory. + * @exception E_MAX_EXCEEDED The number of frame has exceeded the maximum limit. + * @exception E_SYSTEM A system error occurred. + */ + result AddFrame(const Tizen::Ui::Controls::Frame& frame); + + /** + * Removes the specified frame from the UI application. @n + * + * @since 2.0 + * + * @return An error code + * @param[in] frame The frame to be removed + * @exception E_SUCCESS The method was successful. + * @exception E_OBJ_NOT_FOUND The specified frame is not found. + * @exception E_SYSTEM A system error occurred. + * @remarks The removed frame is deleted from the memory. + */ + result RemoveFrame(const Tizen::Ui::Controls::Frame& frame); + + /** + * Gets the list of the frames of the UI application. @n + * + * @since 2.0 + * + * @return A pointer to IList that contains the registered frames @n + * else @c null if it fails + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE The application state is invalid. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::Collection::IList* GetFrameList(void); + + /** + * Gets the frame with the specified name. @n + * + * @since 2.0 + * + * @return A pointer to the frame having the specified name@n + * else @c null if it fails + * @param[in] name The name of the frame + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The frame which has specified name is not fount. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Ui::Controls::Frame* GetFrame(const Tizen::Base::String& name); + + Tizen::Ui::Controls::Frame* GetFrameAt(int index); + + /** + * Gets the UI state of the UI application. + * + * @since 2.0 + * @return The UI state of the UI application + */ + AppUiState GetAppUiState(void) const; + + void OnForeground(void); + + void OnBackground(void); + +private: + static _UiAppImpl* __pUiAppImpl; + + _AppFrame* __pAppFrame; + + _AppImpl* __pAppImpl; + + AppUiState __appUiState; + + Tizen::Base::Collection::ArrayList* __pFrameList; + + UiApp* __pUiApp; + + friend class UiApp; + + friend class _ImeAppImpl; +}; //_UiAppImpl + +} } //Tizen::App + +#endif // _FAPP_INTERNAL_UI_APP_IMPL_H_ diff --git a/src/graphics/CMakeLists.txt b/src/graphics/CMakeLists.txt new file mode 100755 index 0000000..8c9f14a --- /dev/null +++ b/src/graphics/CMakeLists.txt @@ -0,0 +1,108 @@ +SET (this_target graphics) + +INCLUDE_DIRECTORIES( + ${SLP_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/inc + ${CMAKE_SOURCE_DIR}/src/ui/inc + inc + text + /usr/include/osp + /usr/include/osp/app + /usr/include/osp/base + /usr/include/osp/io + /usr/include/osp/media + /usr/include/osp/system +) + +SET (${this_target}_SOURCE_FILES + FGrpBitmap.cpp + FGrpBufferInfo.cpp + FGrpCanvas.cpp + FGrpColor.cpp + FGrpCoordinateSystem.cpp + FGrpDimension.cpp + FGrpFont.cpp + FGrpTextElement.cpp + FGrpEnrichedText.cpp + FGrpFloatPoint.cpp + FGrpFloatDimension.cpp + FGrpFloatRectangle.cpp + FGrpFloatMatrix4.cpp + FGrpFloatPoint3.cpp + FGrpFloatVector4.cpp + FGrpPoint.cpp + FGrpRectangle.cpp + FGrp_BitmapImpl.cpp + FGrp_Bitmap.cpp + FGrp_BitmapScreenCapture.cpp + FGrp_BitmapTool.cpp + FGrp_BitmapUtil.cpp + FGrp_Callback.cpp + FGrp_Canvas.cpp + FGrp_CanvasImpl.cpp + FGrp_CanvasCairo.cpp + FGrp_CanvasPixman.cpp + FGrp_CanvasRasterOp.cpp + FGrp_CanvasShow.cpp + FGrp_CanvasGpArc.cpp + FGrp_CanvasGpEllipse.cpp + FGrp_CanvasGpFillPolygon.cpp + FGrp_CanvasGpLine.cpp + FGrp_CanvasGpRoundRect.cpp + FGrp_CanvasGpTriangle.cpp + FGrp_NonScale.cpp + FGrp_FontImpl.cpp + FGrp_BufferInfoImpl.cpp + FGrp_CoordinateSystem.cpp + FGrp_CoordinateSystemImpl.cpp + FGrp_CoordinateSystemDeviceSpec.cpp + FGrp_Font.cpp + FGrp_FontBidiManager.cpp + FGrp_FontRsrcManager.cpp + FGrp_FontFt2.cpp + FGrp_FontCache.cpp + FGrp_FontMemoryManager.cpp + FGrp_Screen.cpp + FGrp_TextElementImpl.cpp + FGrp_EnrichedTextImpl.cpp + util/FGrp_Util.cpp + util/FGrp_UtilPixmap.cpp + util/FGrp_UtilScratchpad.cpp + effect/FGrp_EffectAlpha.cpp + effect/FGrp_EffectFlip.cpp + effect/FGrp_EffectManip.cpp + effect/FGrp_EffectRotate.cpp + effect/FGrp_EffectScale.cpp + effect/FGrp_EffectScale2.cpp + text/FGrp_TextTextColumn.cpp + text/FGrp_TextTextElement.cpp + text/FGrp_TextTextComposite.cpp + text/FGrp_TextTextCutLink.cpp + text/FGrp_TextTextCutLinkParser.cpp + text/FGrp_TextTextCutLinkListInfo.cpp + text/FGrp_TextTextImage.cpp + text/FGrp_TextTextLine.cpp + text/FGrp_TextTextObject.cpp + text/FGrp_TextTextSimple.cpp + text/FGrp_TextTextSimpleList.cpp + text/FGrp_TextTextUtility.cpp + text/FGrp_TextTextWidthManager.cpp +) + + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") + +## Add Definitions +ADD_DEFINITIONS(${OSP_DEFINITIONS} -D_MODEL_RES_WVGA) + +## SET EXTRA COMPILER FLAGS +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC" ) + +## SET C COMPILER FLAGS +SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## SET CPP COMPILER FLAGS +SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## Create Library +ADD_LIBRARY (${this_target} STATIC ${${this_target}_SOURCE_FILES}) diff --git a/src/graphics/FGrpBitmap.cpp b/src/graphics/FGrpBitmap.cpp new file mode 100644 index 0000000..6d0a302 --- /dev/null +++ b/src/graphics/FGrpBitmap.cpp @@ -0,0 +1,356 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpBitmap.cpp + * @brief This is the implementation file for Bitmap class. + * + */ + +#include + +#include + +#include + +#include "FGrp_BitmapImpl.h" +#include "FGrp_BitmapUtil.h" +#include "util/FGrp_Util.h" + + +#define CHECK_INSTANCE \ + SysTryReturnResult(NID_GRP, this->__pImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Fails to allocate memory.") + +#define CHECK_INSTANCE_EX(_result) \ + SysTryReturn(NID_GRP, this->__pImpl != null, _result, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Fails to allocate memory.") + +#define CHECK_INSTANCE_VOID \ + SysTryReturnVoidResult(NID_GRP, this->__pImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Fails to allocate memory.") + + +#define CHECK_NOT_CONSTRUCTED \ + CHECK_INSTANCE; \ + SysAssertf(!this->__pImpl->IsConstructed(), \ + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + +#define CHECK_CONSTRUCTED \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed. Construct() should be called before use."); + +#define CHECK_CONSTRUCTED_EX(_result) \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed. Construct() should be called before use."); + +#define CHECK_CONSTRUCTED_VOID \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed. Construct() should be called before use."); + + +namespace Tizen { namespace Graphics +{ + +Bitmap::Bitmap(void) + : __pImpl(new (std::nothrow)_BitmapImpl) +{ +} + +Bitmap::~Bitmap(void) +{ + delete __pImpl; +} + +result +Bitmap::Construct(const Rectangle& vc_rect) +{ + CHECK_NOT_CONSTRUCTED; + + result r = this->__pImpl->Construct(vc_rect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Bitmap::Construct(const Dimension& vc_dim, BitmapPixelFormat pixelFormat) +{ + CHECK_NOT_CONSTRUCTED; + + result r = this->__pImpl->Construct(vc_dim, pixelFormat); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Bitmap::Construct(const Canvas& canvas, const Rectangle& vc_rect) +{ + CHECK_NOT_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&canvas), E_INVALID_ARG, "The source canvas is invalid.\n"); + + result r = this->__pImpl->Construct(*_CanvasImpl::GetInstance(canvas), vc_rect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Bitmap::Construct(const Bitmap& bitmap, const Rectangle& vc_rect) +{ + CHECK_NOT_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&bitmap), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + const Tizen::Graphics::_BitmapImpl& impl = *bitmap.__pImpl; + + result r = this->__pImpl->Construct(impl, vc_rect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Bitmap::Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& rq_dim, BitmapPixelFormat pixelFormat) +{ + CHECK_NOT_CONSTRUCTED; + + // notice!! + result r = this->Construct(buffer, rq_dim, pixelFormat, true); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Bitmap::Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& rq_dim, BitmapPixelFormat pixelFormat, bool autoScaling) +{ + CHECK_NOT_CONSTRUCTED; + + result r = this->__pImpl->Construct(buffer, rq_dim, pixelFormat, autoScaling); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Bitmap::Construct(const byte* pBuffer, int bufSize, const Dimension& rq_dim, BitmapPixelFormat pixelFormat, bool autoScaling) +{ + CHECK_NOT_CONSTRUCTED; + + result r = this->__pImpl->Construct(pBuffer, bufSize, rq_dim, pixelFormat, autoScaling); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Bitmap::Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& rq_dim, BitmapPixelFormat pixelFormat, + BufferScaling bufferScaling) +{ + CHECK_NOT_CONSTRUCTED; + + result r = this->__pImpl->Construct(buffer, rq_dim, pixelFormat, bufferScaling); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Bitmap::Scale(const Dimension& vc_dim) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Scale(vc_dim); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Bitmap::Merge(const Point& vc_dest, const Bitmap& src, const Rectangle& vc_srcRect) +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&src), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + const Tizen::Graphics::_BitmapImpl& impl = *src.__pImpl; + + result r = this->__pImpl->Merge(vc_dest, impl, vc_srcRect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +int +Bitmap::GetHeight() const +{ + CHECK_CONSTRUCTED_EX(-1); + + return this->__pImpl->GetHeight(); +} + +int +Bitmap::GetWidth() const +{ + CHECK_CONSTRUCTED_EX(-1); + + return this->__pImpl->GetWidth(); +} + +int +Bitmap::GetBitsPerPixel() const +{ + CHECK_CONSTRUCTED_EX(-1); + + return this->__pImpl->GetBitsPerPixel(); +} + +BitmapPixelFormat +Bitmap::GetPixelColorFormat() const +{ + CHECK_CONSTRUCTED_EX(BITMAP_PIXEL_FORMAT_MAX); + + return this->__pImpl->GetPixelColorFormat(); +} + +result +Bitmap::SetScalingQuality(BitmapScalingQuality quality) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetScalingQuality(quality); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r,"[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +BitmapScalingQuality +Bitmap::GetScalingQuality(void) const +{ + CHECK_CONSTRUCTED_EX(BITMAP_SCALING_QUALITY_LOW); + + return this->__pImpl->GetScalingQuality(); +} + +result +Bitmap::SetMaskingColor(const Color* pColor) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetMaskingColor(pColor); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Bitmap::GetMaskingColor(Color& color) const +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->GetMaskingColor(color); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +Bitmap::SetAlphaConstant(int opacity) +{ + CHECK_CONSTRUCTED_VOID; + + return this->__pImpl->SetAlphaConstant(opacity); +} + +int +Bitmap::GetAlphaConstant(void) const +{ + CHECK_CONSTRUCTED_EX(-1); + + return this->__pImpl->GetAlphaConstant(); +} + +bool +Bitmap::IsNinePatchedBitmap(void) const +{ + CHECK_CONSTRUCTED_EX(false); + + return this->__pImpl->IsNinePatchedBitmap(); +} + +result +Bitmap::Lock(BufferInfo& info, long timeout) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Lock(info, timeout); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Bitmap::Unlock() +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Unlock(); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Bitmap* +Bitmap::GetNonScaledBitmapN(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat) +{ + _BitmapImpl* pBitmapImpl = _BitmapImpl::GetNonScaledBitmapImplN(buffer, dim, pixelFormat); + + if (pBitmapImpl == null) + { + return null; + } + + Bitmap* pReturnBitmap = Tizen::Graphics::_BitmapUtil::CreateBitmapN(pBitmapImpl); + + if (pReturnBitmap == null) + { + result r = GetLastResult(); + + SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return null; + } + + return pReturnBitmap; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpBufferInfo.cpp b/src/graphics/FGrpBufferInfo.cpp new file mode 100644 index 0000000..9e7d08f --- /dev/null +++ b/src/graphics/FGrpBufferInfo.cpp @@ -0,0 +1,136 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpBufferInfo.cpp + * @brief This is the implementation file for internal BufferInfo class. + * + */ + +#include + +#include + +#include + +#include "FGrp_BufferInfoImpl.h" + + +using namespace Tizen::Base; + + +namespace Tizen { namespace Graphics +{ + +BufferInfo::BufferInfo(void) + : width(0) + , height(0) + , pitch(0) + , bitsPerPixel(0) + , pixelFormat(PIXEL_FORMAT_MIN) + , pPixels(null) + , __pImpl(null) +{ + __pImpl = new (std::nothrow) _BufferInfoImpl; + + SysTryReturnVoidResult(NID_GRP, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); +} + +BufferInfo::BufferInfo(const BufferInfo& rhs) + : width(rhs.width) + , height(rhs.height) + , pitch(rhs.pitch) + , bitsPerPixel(rhs.bitsPerPixel) + , pixelFormat(rhs.pixelFormat) + , pPixels(rhs.pPixels) + , __pImpl(null) +{ + if (_BufferInfoImpl::GetInstance(rhs) != null) + { + __pImpl = new (std::nothrow) _BufferInfoImpl(*_BufferInfoImpl::GetInstance(rhs)); + + SysTryReturnVoidResult(NID_GRP, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + } +} + +BufferInfo::~BufferInfo(void) +{ + if (__pImpl) + { + delete __pImpl; + __pImpl = null; + } +} + +BufferInfo& +BufferInfo::operator =(const BufferInfo& rhs) +{ + if (this == &rhs) + { + return *this; + } + + this->width = rhs.width; + this->height = rhs.height; + this->pitch = rhs.pitch; + this->bitsPerPixel = rhs.bitsPerPixel; + this->pixelFormat = rhs.pixelFormat; + this->pPixels = rhs.pPixels; + + if (this->__pImpl && _BufferInfoImpl::GetInstance(rhs)) + { + *(this->__pImpl) = *_BufferInfoImpl::GetInstance(rhs); + } + + return *this; +} + +bool +BufferInfo::Equals(const Tizen::Base::Object& rhs) const +{ + if (&rhs == null) + { + return false; + } + + const BufferInfo* pBufferInfo = dynamic_cast (&rhs); + + if (pBufferInfo == null) + { + return false; + } + + return ((this->width == pBufferInfo->width && + this->height == pBufferInfo->height && + this->pitch == pBufferInfo->pitch && + this->bitsPerPixel == pBufferInfo->bitsPerPixel && + this->pixelFormat == pBufferInfo->pixelFormat && + this->pPixels == pBufferInfo->pPixels) ? true : false); +} + +int +BufferInfo::GetHashCode(void) const +{ + return ((((this->width & 0xFF) << 24) | + ((this->height & 0xFF) << 16) | + ((this->pitch & 0xF) << 12) | + ((this->bitsPerPixel & 0xF) << 8) | + ((this->pixelFormat & 0xF) << 4)) ^ + (reinterpret_cast(this->pPixels))); +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpCanvas.cpp b/src/graphics/FGrpCanvas.cpp new file mode 100644 index 0000000..8a0365c --- /dev/null +++ b/src/graphics/FGrpCanvas.cpp @@ -0,0 +1,763 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpCanvas.cpp + * @brief This is the implementation file for Canvas class. + * + */ + +#include + +#include + +#include + +#include "FGrp_CanvasImpl.h" +#include "util/FGrp_Util.h" + + +#define CHECK_INSTANCE \ + SysTryReturnResult(NID_GRP, this->__pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Fails to allocate memory.") + +#define CHECK_INSTANCE_EX(_result) \ + SysTryReturn(NID_GRP, this->__pImpl, _result, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Fails to allocate memory.") + +#define CHECK_INSTANCE_VOID \ + SysTryReturnVoidResult(NID_GRP, this->__pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Fails to allocate memory.") + + +#define CHECK_NOT_CONSTRUCTED \ + ClearLastResult(); \ + CHECK_INSTANCE; \ + SysAssertf(!this->__pImpl->IsConstructed(), \ + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class"); + +#define CHECK_CONSTRUCTED \ + ClearLastResult(); \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed. Construct() should be called before use."); + +#define CHECK_CONSTRUCTED_EX(_result) \ + ClearLastResult(); \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed. Construct() should be called before use."); + +#define CHECK_CONSTRUCTED_VOID \ + ClearLastResult(); \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed. Construct() should be called before use."); + + +namespace Tizen { namespace Graphics +{ + +Canvas::Canvas(void) + : __pImpl(0) +{ + __pImpl = new (std::nothrow) _CanvasImpl; +} + +Canvas::~Canvas(void) +{ + delete __pImpl; +} + +result +Canvas::Construct(void) +{ + CHECK_NOT_CONSTRUCTED; + + result r = this->__pImpl->Construct(); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::Construct(const Rectangle& vcRect) +{ + CHECK_NOT_CONSTRUCTED; + + result r = this->__pImpl->Construct(vcRect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::Construct(const BufferInfo& bufferInfo) +{ + CHECK_NOT_CONSTRUCTED; + + result r = this->__pImpl->Construct(bufferInfo); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::Clear(void) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Clear(); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::Clear(const Rectangle& vcRect) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Clear(vcRect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::Copy(const Point& vcDestPoint, const Canvas& canvas, const Rectangle& vcSrcRect) +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&canvas), E_INVALID_ARG, "The source canvas is invalid.\n"); + + const Tizen::Graphics::_CanvasImpl& impl = *canvas.__pImpl; + + result r = this->__pImpl->Copy(vcDestPoint, impl, vcSrcRect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::Copy(const Rectangle& vcDestRect, const Canvas& canvas, const Rectangle& vcSrcRect) +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&canvas), E_INVALID_ARG, "The source canvas is invalid.\n"); + + const Tizen::Graphics::_CanvasImpl& impl = *canvas.__pImpl; + + result r = this->__pImpl->Copy(vcDestRect, impl, vcSrcRect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawArc(const Rectangle& vcBounds, int startAngle, int endAngle, ArcStyle arcStyle) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->DrawArc(vcBounds, startAngle, endAngle, arcStyle); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawBitmap(const Rectangle& vcRect, const Bitmap& bitmap) +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&bitmap), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + const Tizen::Graphics::_BitmapImpl& impl = *bitmap.__pImpl; + + result r = this->__pImpl->DrawBitmap(vcRect, impl); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawBitmap(const Point& vcPoint, const Bitmap& bitmap) +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&bitmap), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + const Tizen::Graphics::_BitmapImpl& impl = *bitmap.__pImpl; + + result r = this->__pImpl->DrawBitmap(vcPoint, impl); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawBitmap(const Rectangle& vcDestRect, const Bitmap& srcBitmap, const Rectangle& vcSrcRect) +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&srcBitmap), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + const Tizen::Graphics::_BitmapImpl& impl = *srcBitmap.__pImpl; + + result r = this->__pImpl->DrawBitmap(vcDestRect, impl, vcSrcRect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawBitmap(const Point& vcPoint, const Bitmap& bitmap, FlipDirection dir) +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&bitmap), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + const Tizen::Graphics::_BitmapImpl& impl = *bitmap.__pImpl; + + result r = this->__pImpl->DrawBitmap(vcPoint, impl, dir); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawBitmap(const Point& vcPoint, const Bitmap& bitmap, const Point& vcPivot, int degree) +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&bitmap), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + const Tizen::Graphics::_BitmapImpl& impl = *bitmap.__pImpl; + + result r = this->__pImpl->DrawBitmap(vcPoint, impl, vcPivot, degree); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawNinePatchedBitmap(const Rectangle& vcRect, const Bitmap& bitmap) +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&bitmap), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + const Tizen::Graphics::_BitmapImpl& impl = *bitmap.__pImpl; + + result r = this->__pImpl->DrawNinePatchedBitmap(vcRect, impl); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawEllipse(const Rectangle& vcBounds) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->DrawEllipse(vcBounds); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawLine(const Point& vcPoint1, const Point& vcPoint2) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->DrawLine(vcPoint1, vcPoint2); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawPolygon(const Tizen::Base::Collection::IList& vcPoints) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->DrawPolygon(vcPoints); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawPolyline(const Tizen::Base::Collection::IList& vcPoints) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->DrawPolyline(vcPoints); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawRectangle(const Rectangle& vcRect) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->DrawRectangle(vcRect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawRoundRectangle(const Rectangle& vcRect, const Dimension& vcArcDim) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->DrawRoundRectangle(vcRect, vcArcDim); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawTriangle(const Point& vcPoint1, const Point& vcPoint2, const Point& vcPoint3) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->DrawTriangle(vcPoint1, vcPoint2, vcPoint3); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::FillEllipse(const Color& color, const Rectangle& vcBounds) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->FillEllipse(color, vcBounds); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::FillPolygon(const Color& color, const Tizen::Base::Collection::IList& vcPoints) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->FillPolygon(color, vcPoints); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::FillRectangle(const Color& color, const Rectangle& vcRect) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->FillRectangle(color, vcRect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::FillRoundRectangle(const Color& color, const Rectangle& vcRect, const Dimension& vcArcDim) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->FillRoundRectangle(color, vcRect, vcArcDim); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::FillTriangle(const Color& color, const Point& vcPoint1, const Point& vcPoint2, const Point& vcPoint3) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->FillTriangle(color, vcPoint1, vcPoint2, vcPoint3); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawText(const Point& vcPoint, const Tizen::Base::String& text) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->DrawText(vcPoint, text); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawText(const Point& vcPoint, const Tizen::Base::String& text, int length) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->DrawText(vcPoint, text, 0, length); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawText(const Point& vcPoint, const Tizen::Base::String& text, const Color& outlineColor) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->DrawText(vcPoint, text, 0, outlineColor); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawText(const Point& vcPoint, const Tizen::Base::String& text, int length, const Color& outlineColor) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->DrawText(vcPoint, text, 0, length, outlineColor); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::DrawText(const Point& vcPoint, const EnrichedText& etext) +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&etext), E_INVALID_ARG, "The source enriched text is invalid.\n"); + + result r = this->__pImpl->DrawText(vcPoint, etext); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Rectangle +Canvas::GetBounds(void) const +{ + CHECK_CONSTRUCTED_EX(Rectangle()); + + return this->__pImpl->GetBounds(); +} + +LineStyle +Canvas::GetLineStyle() const +{ + CHECK_CONSTRUCTED_EX(LINE_STYLE_MAX); + + return this->__pImpl->GetLineStyle(); +} + +int +Canvas::GetLineWidth() const +{ + CHECK_CONSTRUCTED_EX(-1); + + return this->__pImpl->GetLineWidth(); +} + +result +Canvas::SetLineStyle(LineStyle style) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetLineStyle(style); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::SetLineWidth(int vcWidth) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetLineWidth(vcWidth); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::GetDashPattern(Tizen::Base::Collection::IListT& pattern, int& offset) const +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->GetDashPattern(pattern, offset); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::SetDashPattern(const Tizen::Base::Collection::IListT& pattern, int offset) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetDashPattern(pattern, offset); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +#if 0 // Not public feature yet + +result +Canvas::SetDrawingQuality(BitmapDrawingQuality quality) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetDrawingQuality(quality); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r,"[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +BitmapDrawingQuality +Canvas::GetDrawingQuality(void) const +{ + CHECK_CONSTRUCTED_EX(BITMAP_DRAWING_QUALITY_LOW); + + return this->__pImpl->GetDrawingQuality(); +} + +#endif + +result +Canvas::GetPixel(const Point& vcPoint, Color& color) const +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->GetPixel(vcPoint, color); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::SetPixel(const Point& vcPoint) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetPixel(vcPoint); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::Show() +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Show(); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::Show(const Rectangle& vcRect) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Show(vcRect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::SetFont(const Font& font) +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, _Util::CheckValidity(&font), E_INVALID_ARG, "The source font is invalid.\n"); + + result r = this->__pImpl->SetFont(font); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Font* +Canvas::GetFontN(void) const +{ + CHECK_CONSTRUCTED_EX(null); + + Font* pReturnFont = this->__pImpl->GetFontN(); + + if (pReturnFont == null) + { + result r = GetLastResult(); + + SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return null; + } + + return pReturnFont; +} + +result +Canvas::SetClipBounds(const Rectangle& vcRect) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetClipBounds(vcRect); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Rectangle +Canvas::GetClipBounds(void) const +{ + CHECK_CONSTRUCTED_EX(Rectangle()); + + return this->__pImpl->GetClipBounds(); +} + +result +Canvas::Lock(BufferInfo& info, long timeout) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Lock(info, timeout); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::Unlock() +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Unlock(); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +Canvas::SetForegroundColor(const Color& fgColor) +{ + CHECK_CONSTRUCTED_VOID; + + return this->__pImpl->SetForegroundColor(fgColor); +} + +Color +Canvas::GetForegroundColor(void) const +{ + CHECK_CONSTRUCTED_EX(Color::GetColor(COLOR_ID_BLACK)); + + return this->__pImpl->GetForegroundColor(); +} + +void +Canvas::SetBackgroundColor(const Color& bgColor) +{ + CHECK_CONSTRUCTED_VOID; + + return this->__pImpl->SetBackgroundColor(bgColor); +} + +Color +Canvas::GetBackgroundColor(void) const +{ + CHECK_CONSTRUCTED_EX(Color::GetColor(COLOR_ID_BLACK)); + + return this->__pImpl->GetBackgroundColor(); +} + +result +Canvas::SetPosition(const Point& vcPoint) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetPosition(vcPoint); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Canvas::SetPosition(int vcX, int vcY) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetPosition(vcX, vcY); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpColor.cpp b/src/graphics/FGrpColor.cpp new file mode 100644 index 0000000..968c223 --- /dev/null +++ b/src/graphics/FGrpColor.cpp @@ -0,0 +1,235 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpColor.cpp + * @brief This is the implementation file for Color class. + * + * This file contains implementation of Color class. + * + */ + +#include + + +namespace Tizen { namespace Graphics +{ + +Color::Color(void) + : __color(0) + , __pImpl(null) +{ +} + +Color::Color(const Color& rhs) + : __color(0) + , __pImpl(null) +{ + __color = rhs.GetRGB32(); +} + +Color::Color(byte red, byte green, byte blue, byte alpha) + : __color(0) + , __pImpl(null) +{ + SetColorComponents(red, green, blue, alpha); +} + +Color::Color(unsigned int rgb, bool hasAlpha) + : __pImpl(null) +{ + SetRGB32(rgb, hasAlpha); +} + +Color::~Color(void) +{ +} + +bool +Color::operator ==(const Color& rhs) const +{ + return (__color == rhs.__color); +} + +bool +Color::operator !=(const Color& rhs) const +{ + return (!operator ==(rhs)); +} + +Color& +Color::operator =(const Color& rhs) +{ + if (this == &rhs) + { + return *this; + } + + __color = rhs.GetRGB32(); + + return (*this); +} + +bool +Color::Equals(const Tizen::Base::Object& rhs) const +{ + if (&rhs == null) + { + return false; + } + + const Color* pColor = dynamic_cast (&rhs); + + if (pColor == null) + { + return false; + } + + return (*this == *pColor); +} + +int +Color::GetHashCode(void) const +{ + return int(__color); +} + +byte +Color::GetAlpha(void) const +{ + return byte((__color >> 24) & 0xFF); +} + +byte +Color::GetRed(void) const +{ + return byte((__color >> 16) & 0xFF); +} + +byte +Color::GetGreen(void) const +{ + return byte((__color >> 8) & 0xFF); +} + +byte +Color::GetBlue(void) const +{ + return byte((__color >> 0) & 0xFF); +} + +void +Color::GetColorComponents(byte& red, byte& green, byte& blue, byte& alpha) const +{ + red = GetRed(); + green = GetGreen(); + blue = GetBlue(); + alpha = GetAlpha(); +} + +unsigned int +Color::GetRGB32(void) const +{ + return __color; +} + +void +Color::SetAlpha(byte alpha) +{ + __color &= (0x00FFFFFF); + __color |= ((alpha & 0xFF) << 24); +} + +void +Color::SetRed(byte red) +{ + __color &= (0xFF00FFFF); + __color |= ((red & 0xFF) << 16); +} + +void +Color::SetGreen(byte green) +{ + __color &= (0xFFFF00FF); + __color |= ((green & 0xFF) << 8); +} + +void +Color::SetBlue(byte blue) +{ + __color &= (0xFFFFFF00); + __color |= ((blue & 0xFF) << 0); +} + +void +Color::SetColorComponents(byte red, byte green, byte blue, byte alpha) +{ + SetRed(red); + SetGreen(green); + SetBlue(blue); + SetAlpha(alpha); +} + +void +Color::SetRGB32(unsigned int rgb, bool hasAlpha) +{ + __color = ((hasAlpha ? rgb : (0xFF000000 | rgb))); +} + +Color +Color::GetColor(ColorId colorId) +{ + Color color(0xFF000000); + + switch (colorId) + { + case COLOR_ID_BLACK: + color.SetRGB32(0xFF000000); + break; + case COLOR_ID_BLUE: + color.SetRGB32(0xFF0000FF); + break; + case COLOR_ID_CYAN: + color.SetRGB32(0xFF00FFFF); + break; + case COLOR_ID_GREEN: + color.SetRGB32(0xFF00FF00); + break; + case COLOR_ID_GREY: + color.SetRGB32(0xFFC0C0C0); + break; + case COLOR_ID_MAGENTA: + color.SetRGB32(0xFFFF00FF); + break; + case COLOR_ID_RED: + color.SetRGB32(0xFFFF0000); + break; + case COLOR_ID_VIOLET: + color.SetRGB32(0xFF4F2F4F); + break; + case COLOR_ID_YELLOW: + color.SetRGB32(0xFFFFFF00); + break; + case COLOR_ID_WHITE: + color.SetRGB32(0xFFFFFFFF); + break; + } + + return color; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpCoordinateSystem.cpp b/src/graphics/FGrpCoordinateSystem.cpp new file mode 100644 index 0000000..51aaf74 --- /dev/null +++ b/src/graphics/FGrpCoordinateSystem.cpp @@ -0,0 +1,120 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpCoordinateSystem.cpp + * @brief This is the cpp file for CoordinateSystem class. + * + */ + +#include + +#include + +#include "FGrp_CoordinateSystem.h" +#include "FGrp_Screen.h" + + +namespace // unnamed +{ + +Tizen::Graphics::Dimension +ConvertToDimension(Tizen::Graphics::_LogicalResolution logicalResolution) +{ + int width = 0; + int height = 0; + + switch (logicalResolution) + { + case Tizen::Graphics::RESOLUTION_LOGICAL_240: + width = 240; + height = 400; + break; + case Tizen::Graphics::RESOLUTION_LOGICAL_320: + width = 320; + height = 480; + break; + case Tizen::Graphics::RESOLUTION_LOGICAL_480: + width = 480; + height = 800; + break; + case Tizen::Graphics::RESOLUTION_LOGICAL_720: + width = 720; + height = 1280; + break; + default: + width = Tizen::Graphics::_CoordinateSystem::GetInstance()->GetLogicalResolutionInt(); + height = Tizen::Graphics::CoordinateSystem::ConvertToLogicalY(Tizen::Graphics::_Screen::GetHeight()); + break; + } + + return Tizen::Graphics::Dimension(width,height); +} + +} + + +namespace Tizen { namespace Graphics +{ + +Dimension +CoordinateSystem::GetLogicalResolution(void) +{ + _LogicalResolution logicalResolution = Tizen::Graphics::_CoordinateSystem::GetInstance()->GetLogicalResolution(); + + return ConvertToDimension(logicalResolution); +} + +Dimension +CoordinateSystem::GetPhysicalResolution(void) +{ + return Dimension(_Screen::GetWidth(), _Screen::GetHeight()); +} + +int +CoordinateSystem::ConvertToLogicalX(int physicalX) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + + return (pTransformer) ? pTransformer->TransformHorizontal(physicalX) : physicalX; +} + +int +CoordinateSystem::ConvertToLogicalY(int physicalY) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + + return (pTransformer) ? pTransformer->TransformVertical(physicalY) : physicalY; +} + +int +CoordinateSystem::ConvertToPhysicalX(int logicalX) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer(); + + return (pTransformer) ? pTransformer->TransformHorizontal(logicalX) : logicalX; +} + +int +CoordinateSystem::ConvertToPhysicalY(int logicalY) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer(); + + return (pTransformer) ? pTransformer->TransformVertical(logicalY) : logicalY; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpDimension.cpp b/src/graphics/FGrpDimension.cpp new file mode 100644 index 0000000..46c6c75 --- /dev/null +++ b/src/graphics/FGrpDimension.cpp @@ -0,0 +1,119 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpDimension.cpp + * @brief This is the implementation file for Dimension class. + * + * This file contains implementation of Point class. + * + */ + +#include + + +namespace Tizen { namespace Graphics +{ + +Dimension::Dimension(void) + : width(0) + , height(0) + , __pImpl(null) +{ +} + +Dimension::Dimension(const Dimension & rhs) + : width(rhs.width) + , height(rhs.height) + , __pImpl(null) +{ +} + +Dimension::Dimension(int width_, int height_) + : width(width_) + , height(height_) + , __pImpl(null) +{ +} + +Dimension::~Dimension(void) +{ +} + +Dimension& +Dimension::operator= (const Dimension & rhs) +{ + if (this == &rhs) + { + return *this; + } + + this->width = rhs.width; + this->height = rhs.height; + this->__pImpl = null; + + return *this; +} + +bool +Dimension::operator ==(const Dimension& rhs) const +{ + return ((this->width == rhs.width && this->height == rhs.height) ? true : false); +} + +bool +Dimension::operator !=(const Dimension& rhs) const +{ + return (!operator ==(rhs)); +} + +bool +Dimension::Equals(const Tizen::Base::Object& rhs) const +{ + if (&rhs == null) + { + return false; + } + + const Dimension* pDim = dynamic_cast (&rhs); + + if (pDim == null) + { + return false; + } + + return (*this == *pDim); +} + +int +Dimension::GetHashCode(void) const +{ + int bits = this->width; + + bits ^= this->height * 31; + + return (((int) bits) ^ ((int) (bits >> 16))); +} + +void +Dimension::SetSize(int width, int height) +{ + this->width = width; + this->height = height; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpEnrichedText.cpp b/src/graphics/FGrpEnrichedText.cpp new file mode 100644 index 0000000..86bafb3 --- /dev/null +++ b/src/graphics/FGrpEnrichedText.cpp @@ -0,0 +1,424 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FGrpEnrichedText.cpp +* @brief This is the cpp file for EnrichedText class. +*/ + +#include + +#include +#include +#include +#include + +#include + +#include "FGrp_EnrichedTextImpl.h" +#include "FGrp_ResUtil.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Utility; + +#define CHECK_NOT_CONSTRUCTED \ + SysTryReturnResult(NID_GRP, this->__pImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Fails to allocate memory.") \ + SysAssertf(!this->__pImpl->IsConstructed(), \ + "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + +#define CHECK_CONSTRUCTED \ + ClearLastResult(); \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed. Construct() should be called before use."); + +#define CHECK_CONSTRUCTED_EX(_result) \ + ClearLastResult(); \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed. Construct() should be called before use."); + +#define CHECK_CONSTRUCTED_VOID \ + ClearLastResult(); \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed. Construct() should be called before use."); + +namespace Tizen { namespace Graphics +{ + +EnrichedText::EnrichedText() +{ + __pImpl = new (std::nothrow) _EnrichedTextImpl; +} + +EnrichedText::~EnrichedText() +{ + if (__pImpl) + { + delete __pImpl; + __pImpl = null; + } +} + +result +EnrichedText::Construct(const Tizen::Graphics::Dimension& dim) +{ + CHECK_NOT_CONSTRUCTED; + + result r = __pImpl->Construct(dim); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +EnrichedText::InsertAt(int elementIndex, Tizen::Graphics::TextElement& element) +{ + CHECK_CONSTRUCTED; + + return __pImpl->InsertAt(elementIndex, element); +} + +result +EnrichedText::RemoveAt(int elementIndex, bool deallocate) +{ + CHECK_CONSTRUCTED; + + return __pImpl->RemoveAt(elementIndex, deallocate); +} + +result +EnrichedText::Remove(Tizen::Graphics::TextElement& element, bool deallocate) +{ + CHECK_CONSTRUCTED; + + return __pImpl->Remove(element, deallocate); +} + +result +EnrichedText::Add(Tizen::Graphics::TextElement& element) +{ + CHECK_CONSTRUCTED; + + return __pImpl->Add(element); +} + +result +EnrichedText::RemoveAllTextElements(bool deallocate) +{ + CHECK_CONSTRUCTED; + + return __pImpl->RemoveAllTextElements(deallocate); +} + +result +EnrichedText::RemoveAll(bool deallocate) +{ + CHECK_CONSTRUCTED; + + return __pImpl->RemoveAll(deallocate); +} + +TextElement* +EnrichedText::GetTextElementAt(int elementIndex) const +{ + CHECK_CONSTRUCTED_EX(null); + + return __pImpl->GetTextElementAt(elementIndex); +} + +int +EnrichedText::GetTextElementCount(void) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetTextElementCount(); +} + +result +EnrichedText::SetSize(const Tizen::Graphics::Dimension& size) +{ + CHECK_CONSTRUCTED; + + return __pImpl->SetSize(size); +} + +result +EnrichedText::SetSize(int width, int height) +{ + CHECK_CONSTRUCTED; + + return __pImpl->SetSize(width, height); +} + +Tizen::Graphics::Dimension +EnrichedText::GetSize(void) const +{ + CHECK_CONSTRUCTED_EX(Dimension(0, 0)); + + return __pImpl->GetSize(); +} + +void +EnrichedText::GetSize(int& width, int& height) const +{ + CHECK_CONSTRUCTED_VOID; + + return __pImpl->GetSize(width, height); +} + +int +EnrichedText::GetWidth(void) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetWidth(); +} + +int +EnrichedText::GetHeight(void) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetHeight(); +} + +result +EnrichedText::SetVerticalAlignment(TextVerticalAlignment alignment) +{ + CHECK_CONSTRUCTED; + + return __pImpl->SetVerticalAlignment(alignment); +} + +result +EnrichedText::SetHorizontalAlignment(TextHorizontalAlignment alignment) +{ + CHECK_CONSTRUCTED; + + return __pImpl->SetHorizontalAlignment(alignment); +} + +TextVerticalAlignment +EnrichedText::GetVerticalAlignment(void) const +{ + CHECK_CONSTRUCTED_EX(TEXT_ALIGNMENT_VERTICAL_MIN); + + return __pImpl->GetVerticalAlignment(); +} + +TextHorizontalAlignment +EnrichedText::GetHorizontalAlignment(void) const +{ + CHECK_CONSTRUCTED_EX(TEXT_ALIGNMENT_HORIZONTAL_MIN); + + return __pImpl->GetHorizontalAlignment(); +} + +result +EnrichedText::SetTextWrapStyle(TextWrap wrap) +{ + CHECK_CONSTRUCTED; + + return __pImpl->SetTextWrapStyle(wrap); +} + +TextWrap +EnrichedText::GetTextWrapStyle(void) const +{ + CHECK_CONSTRUCTED_EX(TEXT_WRAP_MIN); + + return __pImpl->GetTextWrapStyle(); +} + +result +EnrichedText::SetTextAbbreviationEnabled(bool enable) +{ + CHECK_CONSTRUCTED; + + return __pImpl->SetTextAbbreviationEnabled(enable); +} + +bool +EnrichedText::IsTextAbbreviationEnabled(void) const +{ + CHECK_CONSTRUCTED_EX(false); + + return __pImpl->IsTextAbbreviationEnabled(); +} + +result +EnrichedText::SetLineSpace(int lineSpace) +{ + CHECK_CONSTRUCTED; + + return __pImpl->SetLineSpace(lineSpace); +} + +int +EnrichedText::GetLineSpace(void) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetLineSpace(); +} + +void +EnrichedText::Refresh(void) +{ + CHECK_CONSTRUCTED_VOID; + + return __pImpl->Refresh(); +} + +int +EnrichedText::GetTotalLineCount(void) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetTotalLineCount(); +} + +int +EnrichedText::GetTotalLineHeight(void) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetTotalLineHeight(); +} + +int +EnrichedText::GetDisplayLineCount(void) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetDisplayLineCount(); +} + +int +EnrichedText::GetLineLength(int lineIndex) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetLineLength(lineIndex); +} + +int +EnrichedText::GetFirstTextIndex(int lineIndex) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetFirstTextIndex(lineIndex); +} + +int +EnrichedText::GetLineIndex(int textIndex) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetLineIndex(textIndex); +} + +int +EnrichedText::GetLineHeight(int lineIndex) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetLineHeight(lineIndex); +} + +int +EnrichedText::GetTextLength(void) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetTextLength(); +} + +result +EnrichedText::GetTextExtent(int startTextIndex, int textLength, int& width, int& height, int& actualLength) const +{ + CHECK_CONSTRUCTED; + + return __pImpl->GetTextExtent(startTextIndex, textLength, width, height, actualLength); +} + +result +EnrichedText::GetTextExtent(int startTextIndex, int textLength, Tizen::Graphics::Dimension& size, int& actualLength) const +{ + CHECK_CONSTRUCTED; + + return __pImpl->GetTextExtent(startTextIndex, textLength, size, actualLength); +} + +Tizen::Graphics::Dimension +EnrichedText::GetTextExtent(void) const +{ + CHECK_CONSTRUCTED_EX(Dimension(-1, -1)); + + return __pImpl->GetTextExtent(); +} + +result +EnrichedText::Add(const Tizen::Graphics::Bitmap& bitmap) +{ + CHECK_CONSTRUCTED; + + return __pImpl->Add(bitmap); +} + +result +EnrichedText::InsertAt(int elementIndex, const Tizen::Graphics::Bitmap& bitmap) +{ + CHECK_CONSTRUCTED; + + return __pImpl->InsertAt(elementIndex, bitmap); +} + +result +EnrichedText::GetLinkInfoFromPosition(const Point& point, Tizen::Base::Utility::LinkInfo& linkInfo) const +{ + CHECK_CONSTRUCTED; + + return __pImpl->GetLinkInfoFromPosition(point, linkInfo); +} + +result +EnrichedText::GetLinkInfoFromPosition(int x, int y, Tizen::Base::Utility::LinkInfo& linkInfo) const +{ + CHECK_CONSTRUCTED; + + return __pImpl->GetLinkInfoFromPosition(x, y, linkInfo); +} + +TextVerticalAlignment +EnrichedText::GetElementVerticalAlignment(void) const +{ + CHECK_CONSTRUCTED_EX(TEXT_ALIGNMENT_VERTICAL_MIN); + + return __pImpl->GetElementVerticalAlignment(); +} + +result +EnrichedText::SetElementVerticalAlignment(TextVerticalAlignment alignment) +{ + CHECK_CONSTRUCTED; + + return __pImpl->SetElementVerticalAlignment(alignment); +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpFloatDimension.cpp b/src/graphics/FGrpFloatDimension.cpp new file mode 100644 index 0000000..0ec2440 --- /dev/null +++ b/src/graphics/FGrpFloatDimension.cpp @@ -0,0 +1,134 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpFloatDimension.cpp + * @brief This is the implementation file for FloatDimension class. + * + * This file contains implementation of Point class. + * + */ + +#include + + +namespace // unnamed +{ + +// epsilon is assumed to be 0.00001f, not 1.192092896e-07f +const float _EPSILON = 0.00001f; + +inline bool +_IsEqual(float f1, float f2) +{ + return (((f1 > f2) ? f1 - f2 : f2 - f1) < _EPSILON); +} + +} + +namespace Tizen { namespace Graphics +{ + +FloatDimension::FloatDimension(void) + : width(0.0f) + , height(0.0f) + , __pImpl(null) +{ +} + +FloatDimension::FloatDimension(const FloatDimension& rhs) + : width(rhs.width) + , height(rhs.height) + , __pImpl(null) +{ +} + +FloatDimension::FloatDimension(float width_, float height_) + : width(width_) + , height(height_) + , __pImpl(null) +{ +} + +FloatDimension::~FloatDimension(void) +{ +} + +FloatDimension& +FloatDimension::operator=(const FloatDimension& rhs) +{ + if (this == &rhs) + { + return *this; + } + + this->width = rhs.width; + this->height = rhs.height; + this->__pImpl = null; + + return *this; +} + +bool +FloatDimension::operator ==(const FloatDimension& rhs) const +{ + return ((_IsEqual(this->width, rhs.width) && _IsEqual(this->height, rhs.height)) ? true : false); +} + +bool +FloatDimension::operator !=(const FloatDimension& rhs) const +{ + return (!operator ==(rhs)); +} + +bool +FloatDimension::Equals(const Tizen::Base::Object& rhs) const +{ + if (&rhs == null) + { + return false; + } + + const FloatDimension* pDim = dynamic_cast (&rhs); + + if (pDim == null) + { + return false; + } + + return (*this == *pDim); +} + +int +FloatDimension::GetHashCode(void) const +{ + const float inverseEpsilon = 1.0f / _EPSILON; + + int reinterpretedX = int(this->width * inverseEpsilon); + int reinterpretedY = int(this->height * inverseEpsilon); + + return reinterpretedX ^ (reinterpretedY * 31); +} + +void +FloatDimension::SetSize(float width, float height) +{ + this->width = width; + this->height = height; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpFloatMatrix4.cpp b/src/graphics/FGrpFloatMatrix4.cpp new file mode 100644 index 0000000..37f0ccf --- /dev/null +++ b/src/graphics/FGrpFloatMatrix4.cpp @@ -0,0 +1,699 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpFloatMatrix4.cpp + * @brief This is the implementation for FloatMatrix class. + */ + +#include +#include +#include +#include + + +namespace Tizen { namespace Graphics +{ + +static const int MATRIX_SIZE = sizeof(float) * 16; +#define SWAP_VALUES(a, b, tmp) tmp = a; a = b; b = tmp; + +FloatMatrix4::FloatMatrix4(void) + : __pImpl(null) +{ + SetAsIdentity(); +} + +FloatMatrix4::FloatMatrix4(const FloatMatrix4& rhs) + : __pImpl(null) +{ + memcpy(matrix, rhs.matrix, MATRIX_SIZE); +} + +FloatMatrix4::FloatMatrix4(const float matrix[4][4]) + : __pImpl(null) +{ + memcpy(this->matrix, matrix, MATRIX_SIZE); +} + +FloatMatrix4::~FloatMatrix4(void) +{ +} + +bool +FloatMatrix4::operator ==(const FloatMatrix4& rhs) const +{ + if (this == &rhs) + { + return true; + } + + return (matrix[0][0] == rhs.matrix[0][0] && + matrix[0][1] == rhs.matrix[0][1] && + matrix[0][2] == rhs.matrix[0][2] && + matrix[0][3] == rhs.matrix[0][3] && + matrix[1][0] == rhs.matrix[1][0] && + matrix[1][1] == rhs.matrix[1][1] && + matrix[1][2] == rhs.matrix[1][2] && + matrix[1][3] == rhs.matrix[1][3] && + matrix[2][0] == rhs.matrix[2][0] && + matrix[2][1] == rhs.matrix[2][1] && + matrix[2][2] == rhs.matrix[2][2] && + matrix[2][3] == rhs.matrix[2][3] && + matrix[3][0] == rhs.matrix[3][0] && + matrix[3][1] == rhs.matrix[3][1] && + matrix[3][2] == rhs.matrix[3][2] && + matrix[3][3] == rhs.matrix[3][3]); +} + +bool +FloatMatrix4::operator !=(const FloatMatrix4& rhs) const +{ + return !(*this == rhs); +} + +FloatMatrix4& +FloatMatrix4::operator =(const FloatMatrix4& rhs) +{ + if (this != &rhs) + { + memcpy(matrix, rhs.matrix, MATRIX_SIZE); + } + + return *this; +} + +FloatMatrix4& +FloatMatrix4::operator =(float value) +{ + matrix[0][0] = value; + matrix[1][0] = value; + matrix[2][0] = value; + matrix[3][0] = value; + + matrix[0][1] = value; + matrix[1][1] = value; + matrix[2][1] = value; + matrix[3][1] = value; + + matrix[0][2] = value; + matrix[1][2] = value; + matrix[2][2] = value; + matrix[3][2] = value; + + matrix[0][3] = value; + matrix[1][3] = value; + matrix[2][3] = value; + matrix[3][3] = value; + + return *this; +} + +FloatMatrix4 +FloatMatrix4::operator *(const FloatMatrix4& rhs) const +{ + FloatMatrix4 resultMatrix; + + resultMatrix.matrix[0][0] = (this->matrix[0][0] * rhs.matrix[0][0]) + + (this->matrix[1][0] * rhs.matrix[0][1]) + + (this->matrix[2][0] * rhs.matrix[0][2]) + + (this->matrix[3][0] * rhs.matrix[0][3]); + resultMatrix.matrix[1][0] = (this->matrix[0][0] * rhs.matrix[1][0]) + + (this->matrix[1][0] * rhs.matrix[1][1]) + + (this->matrix[2][0] * rhs.matrix[1][2]) + + (this->matrix[3][0] * rhs.matrix[1][3]); + resultMatrix.matrix[2][0] = (this->matrix[0][0] * rhs.matrix[2][0]) + + (this->matrix[1][0] * rhs.matrix[2][1]) + + (this->matrix[2][0] * rhs.matrix[2][2]) + + (this->matrix[3][0] * rhs.matrix[2][3]); + resultMatrix.matrix[3][0] = (this->matrix[0][0] * rhs.matrix[3][0]) + + (this->matrix[1][0] * rhs.matrix[3][1]) + + (this->matrix[2][0] * rhs.matrix[3][2]) + + (this->matrix[3][0] * rhs.matrix[3][3]); + + resultMatrix.matrix[0][1] = (this->matrix[0][1] * rhs.matrix[0][0]) + + (this->matrix[1][1] * rhs.matrix[0][1]) + + (this->matrix[2][1] * rhs.matrix[0][2]) + + (this->matrix[3][1] * rhs.matrix[0][3]); + resultMatrix.matrix[1][1] = (this->matrix[0][1] * rhs.matrix[1][0]) + + (this->matrix[1][1] * rhs.matrix[1][1]) + + (this->matrix[2][1] * rhs.matrix[1][2]) + + (this->matrix[3][1] * rhs.matrix[1][3]); + resultMatrix.matrix[2][1] = (this->matrix[0][1] * rhs.matrix[2][0]) + + (this->matrix[1][1] * rhs.matrix[2][1]) + + (this->matrix[2][1] * rhs.matrix[2][2]) + + (this->matrix[3][1] * rhs.matrix[2][3]); + resultMatrix.matrix[3][1] = (this->matrix[0][1] * rhs.matrix[3][0]) + + (this->matrix[1][1] * rhs.matrix[3][1]) + + (this->matrix[2][1] * rhs.matrix[3][2]) + + (this->matrix[3][1] * rhs.matrix[3][3]); + + resultMatrix.matrix[0][2] = (this->matrix[0][2] * rhs.matrix[0][0]) + + (this->matrix[1][2] * rhs.matrix[0][1]) + + (this->matrix[2][2] * rhs.matrix[0][2]) + + (this->matrix[3][2] * rhs.matrix[0][3]); + resultMatrix.matrix[1][2] = (this->matrix[0][2] * rhs.matrix[1][0]) + + (this->matrix[1][2] * rhs.matrix[1][1]) + + (this->matrix[2][2] * rhs.matrix[1][2]) + + (this->matrix[3][2] * rhs.matrix[1][3]); + resultMatrix.matrix[2][2] = (this->matrix[0][2] * rhs.matrix[2][0]) + + (this->matrix[1][2] * rhs.matrix[2][1]) + + (this->matrix[2][2] * rhs.matrix[2][2]) + + (this->matrix[3][2] * rhs.matrix[2][3]); + resultMatrix.matrix[3][2] = (this->matrix[0][2] * rhs.matrix[3][0]) + + (this->matrix[1][2] * rhs.matrix[3][1]) + + (this->matrix[2][2] * rhs.matrix[3][2]) + + (this->matrix[3][2] * rhs.matrix[3][3]); + + resultMatrix.matrix[0][3] = (this->matrix[0][3] * rhs.matrix[0][0]) + + (this->matrix[1][3] * rhs.matrix[0][1]) + + (this->matrix[2][3] * rhs.matrix[0][2]) + + (this->matrix[3][3] * rhs.matrix[0][3]); + resultMatrix.matrix[1][3] = (this->matrix[0][3] * rhs.matrix[1][0]) + + (this->matrix[1][3] * rhs.matrix[1][1]) + + (this->matrix[2][3] * rhs.matrix[1][2]) + + (this->matrix[3][3] * rhs.matrix[1][3]); + resultMatrix.matrix[2][3] = (this->matrix[0][3] * rhs.matrix[2][0]) + + (this->matrix[1][3] * rhs.matrix[2][1]) + + (this->matrix[2][3] * rhs.matrix[2][2]) + + (this->matrix[3][3] * rhs.matrix[2][3]); + resultMatrix.matrix[3][3] = (this->matrix[0][3] * rhs.matrix[3][0]) + + (this->matrix[1][3] * rhs.matrix[3][1]) + + (this->matrix[2][3] * rhs.matrix[3][2]) + + (this->matrix[3][3] * rhs.matrix[3][3]); + + return resultMatrix; +} + +FloatVector4 +FloatMatrix4::operator *(const FloatVector4& vector) const +{ + FloatVector4 resultVector; + + resultVector.x = (matrix[0][0] * vector.x) + (matrix[1][0] * vector.y) + + (matrix[2][0] * vector.z) + (matrix[3][0] * vector.w); + resultVector.y = (matrix[0][1] * vector.x) + (matrix[1][1] * vector.y) + + (matrix[2][1] * vector.z) + (matrix[3][1] * vector.w); + resultVector.z = (matrix[0][2] * vector.x) + (matrix[1][2] * vector.y) + + (matrix[2][2] * vector.z) + (matrix[3][2] * vector.w); + resultVector.w = (matrix[0][3] * vector.x) + (matrix[1][3] * vector.y) + + (matrix[2][3] * vector.z) + (matrix[3][3] * vector.w); + + return resultVector; +} + +FloatMatrix4 +FloatMatrix4::operator *(float value) const +{ + FloatMatrix4 resultMatrix(matrix); + + resultMatrix.matrix[0][0] *= value; + resultMatrix.matrix[0][1] *= value; + resultMatrix.matrix[0][2] *= value; + resultMatrix.matrix[0][3] *= value; + + resultMatrix.matrix[1][0] *= value; + resultMatrix.matrix[1][1] *= value; + resultMatrix.matrix[1][2] *= value; + resultMatrix.matrix[1][3] *= value; + + resultMatrix.matrix[2][0] *= value; + resultMatrix.matrix[2][1] *= value; + resultMatrix.matrix[2][2] *= value; + resultMatrix.matrix[2][3] *= value; + + resultMatrix.matrix[3][0] *= value; + resultMatrix.matrix[3][1] *= value; + resultMatrix.matrix[3][2] *= value; + resultMatrix.matrix[3][3] *= value; + + return resultMatrix; +} + +FloatMatrix4 +FloatMatrix4::operator +(const FloatMatrix4& rhs) const +{ + FloatMatrix4 resultMatrix(matrix); + + resultMatrix.matrix[0][0] += rhs.matrix[0][0]; + resultMatrix.matrix[0][1] += rhs.matrix[0][1]; + resultMatrix.matrix[0][2] += rhs.matrix[0][2]; + resultMatrix.matrix[0][3] += rhs.matrix[0][3]; + + resultMatrix.matrix[1][0] += rhs.matrix[1][0]; + resultMatrix.matrix[1][1] += rhs.matrix[1][1]; + resultMatrix.matrix[1][2] += rhs.matrix[1][2]; + resultMatrix.matrix[1][3] += rhs.matrix[1][3]; + + resultMatrix.matrix[2][0] += rhs.matrix[2][0]; + resultMatrix.matrix[2][1] += rhs.matrix[2][1]; + resultMatrix.matrix[2][2] += rhs.matrix[2][2]; + resultMatrix.matrix[2][3] += rhs.matrix[2][3]; + + resultMatrix.matrix[3][0] += rhs.matrix[3][0]; + resultMatrix.matrix[3][1] += rhs.matrix[3][1]; + resultMatrix.matrix[3][2] += rhs.matrix[3][2]; + resultMatrix.matrix[3][3] += rhs.matrix[3][3]; + + return resultMatrix; +} + +FloatMatrix4 +FloatMatrix4::operator +(float value) const +{ + FloatMatrix4 resultMatrix(matrix); + + resultMatrix.matrix[0][0] += value; + resultMatrix.matrix[0][1] += value; + resultMatrix.matrix[0][2] += value; + resultMatrix.matrix[0][3] += value; + + resultMatrix.matrix[1][0] += value; + resultMatrix.matrix[1][1] += value; + resultMatrix.matrix[1][2] += value; + resultMatrix.matrix[1][3] += value; + + resultMatrix.matrix[2][0] += value; + resultMatrix.matrix[2][1] += value; + resultMatrix.matrix[2][2] += value; + resultMatrix.matrix[2][3] += value; + + resultMatrix.matrix[3][0] += value; + resultMatrix.matrix[3][1] += value; + resultMatrix.matrix[3][2] += value; + resultMatrix.matrix[3][3] += value; + + return resultMatrix; +} + +FloatMatrix4 +FloatMatrix4::operator -(const FloatMatrix4& rhs) const +{ + FloatMatrix4 resultMatrix(matrix); + + resultMatrix.matrix[0][0] -= rhs.matrix[0][0]; + resultMatrix.matrix[0][1] -= rhs.matrix[0][1]; + resultMatrix.matrix[0][2] -= rhs.matrix[0][2]; + resultMatrix.matrix[0][3] -= rhs.matrix[0][3]; + + resultMatrix.matrix[1][0] -= rhs.matrix[1][0]; + resultMatrix.matrix[1][1] -= rhs.matrix[1][1]; + resultMatrix.matrix[1][2] -= rhs.matrix[1][2]; + resultMatrix.matrix[1][3] -= rhs.matrix[1][3]; + + resultMatrix.matrix[2][0] -= rhs.matrix[2][0]; + resultMatrix.matrix[2][1] -= rhs.matrix[2][1]; + resultMatrix.matrix[2][2] -= rhs.matrix[2][2]; + resultMatrix.matrix[2][3] -= rhs.matrix[2][3]; + + resultMatrix.matrix[3][0] -= rhs.matrix[3][0]; + resultMatrix.matrix[3][1] -= rhs.matrix[3][1]; + resultMatrix.matrix[3][2] -= rhs.matrix[3][2]; + resultMatrix.matrix[3][3] -= rhs.matrix[3][3]; + + return resultMatrix; +} + +FloatMatrix4 +FloatMatrix4::operator -(float value) const +{ + FloatMatrix4 resultMatrix(matrix); + + resultMatrix.matrix[0][0] -= value; + resultMatrix.matrix[0][1] -= value; + resultMatrix.matrix[0][2] -= value; + resultMatrix.matrix[0][3] -= value; + + resultMatrix.matrix[1][0] -= value; + resultMatrix.matrix[1][1] -= value; + resultMatrix.matrix[1][2] -= value; + resultMatrix.matrix[1][3] -= value; + + resultMatrix.matrix[2][0] -= value; + resultMatrix.matrix[2][1] -= value; + resultMatrix.matrix[2][2] -= value; + resultMatrix.matrix[2][3] -= value; + + resultMatrix.matrix[3][0] -= value; + resultMatrix.matrix[3][1] -= value; + resultMatrix.matrix[3][2] -= value; + resultMatrix.matrix[3][3] -= value; + + return resultMatrix; +} + +FloatMatrix4& +FloatMatrix4::operator *=(const FloatMatrix4& rhs) +{ + *this = *this * rhs; + return *this; +} + +FloatMatrix4& +FloatMatrix4::operator *=(float value) +{ + *this = *this * value; + return *this; +} + +FloatMatrix4& +FloatMatrix4::operator +=(const FloatMatrix4& rhs) +{ + *this = *this + rhs; + return *this; +} + +FloatMatrix4& +FloatMatrix4::operator +=(float value) +{ + *this = *this + value; + return *this; +} + +FloatMatrix4& +FloatMatrix4::operator -=(const FloatMatrix4& rhs) +{ + *this = *this - rhs; + return *this; +} + +FloatMatrix4& +FloatMatrix4::operator -=(float value) +{ + *this = *this - value; + return *this; +} + +FloatMatrix4 +operator +(const float& value, const FloatMatrix4& rhs) +{ + return rhs + value; +} + +FloatMatrix4 +operator *(const float& value, const FloatMatrix4& rhs) +{ + return rhs * value; +} + +FloatMatrix4 +operator -(const float& value, const FloatMatrix4& rhs) +{ + FloatMatrix4 returnMatrix(rhs); + returnMatrix.Negate(); + returnMatrix += value; + return returnMatrix; +} + +bool +FloatMatrix4::Equals(const Tizen::Base::Object& obj) const +{ + const FloatMatrix4* pMatrix = dynamic_cast (&obj); + + if (pMatrix == null) + { + return false; + } + + return (*this == *pMatrix); +} + +int +FloatMatrix4::GetHashCode(void) const +{ + return (Tizen::Base::Float::GetHashCode(matrix[0][0]) + Tizen::Base::Float::GetHashCode(matrix[1][0]) + + Tizen::Base::Float::GetHashCode(matrix[2][0]) + Tizen::Base::Float::GetHashCode(matrix[3][0]) + + Tizen::Base::Float::GetHashCode(matrix[0][1]) + Tizen::Base::Float::GetHashCode(matrix[1][1]) + + Tizen::Base::Float::GetHashCode(matrix[2][1]) + Tizen::Base::Float::GetHashCode(matrix[3][1]) + + Tizen::Base::Float::GetHashCode(matrix[0][2]) + Tizen::Base::Float::GetHashCode(matrix[1][2]) + + Tizen::Base::Float::GetHashCode(matrix[2][2]) + Tizen::Base::Float::GetHashCode(matrix[3][2]) + + Tizen::Base::Float::GetHashCode(matrix[0][3]) + Tizen::Base::Float::GetHashCode(matrix[1][3]) + + Tizen::Base::Float::GetHashCode(matrix[2][3]) + Tizen::Base::Float::GetHashCode(matrix[3][3])); +} + +float +FloatMatrix4::GetDeterminant(void) const +{ + float a0 = matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]; + float a1 = matrix[0][0] * matrix[1][2] - matrix[0][2] * matrix[1][0]; + float a2 = matrix[0][0] * matrix[1][3] - matrix[0][3] * matrix[1][0]; + float a3 = matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1]; + float a4 = matrix[0][1] * matrix[1][3] - matrix[0][3] * matrix[1][1]; + float a5 = matrix[0][2] * matrix[1][3] - matrix[0][3] * matrix[1][2]; + + float b0 = matrix[2][0] * matrix[3][1] - matrix[2][1] * matrix[3][0]; + float b1 = matrix[2][0] * matrix[3][2] - matrix[2][2] * matrix[3][0]; + float b2 = matrix[2][0] * matrix[3][3] - matrix[2][3] * matrix[3][0]; + float b3 = matrix[2][1] * matrix[3][2] - matrix[2][2] * matrix[3][1]; + float b4 = matrix[2][1] * matrix[3][3] - matrix[2][3] * matrix[3][1]; + float b5 = matrix[2][2] * matrix[3][3] - matrix[2][3] * matrix[3][2]; + + return a0 * b5 - a1 * b4 + a2 * b3 + a3 * b2 - a4 * b1 + a5 * b0; +} + +FloatMatrix4 +FloatMatrix4::GetInverse(void) const +{ + float a0 = matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]; + float a1 = matrix[0][0] * matrix[1][2] - matrix[0][2] * matrix[1][0]; + float a2 = matrix[0][0] * matrix[1][3] - matrix[0][3] * matrix[1][0]; + float a3 = matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1]; + float a4 = matrix[0][1] * matrix[1][3] - matrix[0][3] * matrix[1][1]; + float a5 = matrix[0][2] * matrix[1][3] - matrix[0][3] * matrix[1][2]; + + float b0 = matrix[2][0] * matrix[3][1] - matrix[2][1] * matrix[3][0]; + float b1 = matrix[2][0] * matrix[3][2] - matrix[2][2] * matrix[3][0]; + float b2 = matrix[2][0] * matrix[3][3] - matrix[2][3] * matrix[3][0]; + float b3 = matrix[2][1] * matrix[3][2] - matrix[2][2] * matrix[3][1]; + float b4 = matrix[2][1] * matrix[3][3] - matrix[2][3] * matrix[3][1]; + float b5 = matrix[2][2] * matrix[3][3] - matrix[2][3] * matrix[3][2]; + + float determinant = a0 * b5 - a1 * b4 + a2 * b3 + a3 * b2 - a4 * b1 + a5 * b0; + + if (Tizen::Base::Float::Compare(determinant, 0.0f) == 0) + { + return *this; + } + + float inverseMatrix[4][4]; + + inverseMatrix[0][0] = (matrix[1][1] * b5 - matrix[1][2] * b4 + matrix[1][3] * b3) / determinant; + inverseMatrix[1][0] = (-matrix[1][0] * b5 + matrix[1][2] * b2 - matrix[1][3] * b1) / determinant; + inverseMatrix[2][0] = (matrix[1][0] * b4 - matrix[1][1] * b2 + matrix[1][3] * b0) / determinant; + inverseMatrix[3][0] = (-matrix[1][0] * b3 + matrix[1][1] * b1 - matrix[1][2] * b0) / determinant; + + inverseMatrix[0][1] = (-matrix[0][1] * b5 + matrix[0][2] * b4 - matrix[0][3] * b3) / determinant; + inverseMatrix[1][1] = (matrix[0][0] * b5 - matrix[0][2] * b2 + matrix[0][3] * b1) / determinant; + inverseMatrix[2][1] = (-matrix[0][0] * b4 + matrix[0][1] * b2 - matrix[0][3] * b0) / determinant; + inverseMatrix[3][1] = (matrix[0][0] * b3 - matrix[0][1] * b1 + matrix[0][2] * b0) / determinant; + + inverseMatrix[0][2] = (matrix[3][1] * a5 - matrix[3][2] * a4 + matrix[3][3] * a3) / determinant; + inverseMatrix[1][2] = (-matrix[3][0] * a5 + matrix[3][2] * a2 - matrix[3][3] * a1) / determinant; + inverseMatrix[2][2] = (matrix[3][0] * a4 - matrix[3][1] * a2 + matrix[3][3] * a0) / determinant; + inverseMatrix[3][2] = (-matrix[3][0] * a3 + matrix[3][1] * a1 - matrix[3][2] * a0) / determinant; + + inverseMatrix[0][3] = (-matrix[2][1] * a5 + matrix[2][2] * a4 - matrix[2][3] * a3) / determinant; + inverseMatrix[1][3] = (matrix[2][0] * a5 - matrix[2][2] * a2 + matrix[2][3] * a1) / determinant; + inverseMatrix[2][3] = (-matrix[2][0] * a4 + matrix[2][1] * a2 - matrix[2][3] * a0) / determinant; + inverseMatrix[3][3] = (matrix[2][0] * a3 - matrix[2][1] * a1 + matrix[2][2] * a0) / determinant; + + return FloatMatrix4(inverseMatrix); +} + +float +FloatMatrix4::GetTrace(void) const +{ + return matrix[0][0] + matrix[1][1] + matrix[2][2] + matrix[3][3]; +} + +FloatMatrix4 +FloatMatrix4::GetTranspose(void) const +{ + FloatMatrix4 transposeMatrix(matrix); + transposeMatrix.Transpose(); + + return transposeMatrix; +} + +bool +FloatMatrix4::IsIdentity(void) const +{ + if ((Tizen::Base::Float::Compare(matrix[0][0], 1.0f) != 0) || (Tizen::Base::Float::Compare(matrix[1][1], 1.0f) != 0) || + (Tizen::Base::Float::Compare(matrix[2][2], 1.0f) != 0) || (Tizen::Base::Float::Compare(matrix[3][3], 1.0f) != 0)) + { + return false; + } + + if ((Tizen::Base::Float::Compare(matrix[0][1], 0.0f) != 0) || (Tizen::Base::Float::Compare(matrix[0][2], 0.0f) != 0) || + (Tizen::Base::Float::Compare(matrix[0][3], 0.0f) != 0) || (Tizen::Base::Float::Compare(matrix[1][0], 0.0f) != 0) || + (Tizen::Base::Float::Compare(matrix[1][2], 0.0f) != 0) || (Tizen::Base::Float::Compare(matrix[1][3], 0.0f) != 0) || + (Tizen::Base::Float::Compare(matrix[2][0], 0.0f) != 0) || (Tizen::Base::Float::Compare(matrix[2][1], 0.0f) != 0) || + (Tizen::Base::Float::Compare(matrix[2][3], 0.0f) != 0) || (Tizen::Base::Float::Compare(matrix[3][0], 0.0f) != 0) || + (Tizen::Base::Float::Compare(matrix[3][1], 0.0f) != 0) || (Tizen::Base::Float::Compare(matrix[3][2], 0.0f) != 0)) + { + return false; + } + + return true; +} + +bool +FloatMatrix4::IsInvertible(void) const +{ + if (Tizen::Base::Float::Compare(GetDeterminant(), 0.0f) == 0) + { + return false; + } + + return true; +} + +void +FloatMatrix4::Negate(void) +{ + matrix[0][0] = -matrix[0][0]; + matrix[0][1] = -matrix[0][1]; + matrix[0][2] = -matrix[0][2]; + matrix[0][3] = -matrix[0][3]; + + matrix[1][0] = -matrix[1][0]; + matrix[1][1] = -matrix[1][1]; + matrix[1][2] = -matrix[1][2]; + matrix[1][3] = -matrix[1][3]; + + matrix[2][0] = -matrix[2][0]; + matrix[2][1] = -matrix[2][1]; + matrix[2][2] = -matrix[2][2]; + matrix[2][3] = -matrix[2][3]; + + matrix[3][0] = -matrix[3][0]; + matrix[3][1] = -matrix[3][1]; + matrix[3][2] = -matrix[3][2]; + matrix[3][3] = -matrix[3][3]; +} + +void +FloatMatrix4::SetAsIdentity(void) +{ + matrix[0][0] = 1.0f; + matrix[0][1] = 0.0f; + matrix[0][2] = 0.0f; + matrix[0][3] = 0.0f; + + matrix[1][0] = 0.0f; + matrix[1][1] = 1.0f; + matrix[1][2] = 0.0f; + matrix[1][3] = 0.0f; + + matrix[2][0] = 0.0f; + matrix[2][1] = 0.0f; + matrix[2][2] = 1.0f; + matrix[2][3] = 0.0f; + + matrix[3][0] = 0.0f; + matrix[3][1] = 0.0f; + matrix[3][2] = 0.0f; + matrix[3][3] = 1.0f; +} + +result +FloatMatrix4::Invert(void) +{ + float a0 = matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]; + float a1 = matrix[0][0] * matrix[1][2] - matrix[0][2] * matrix[1][0]; + float a2 = matrix[0][0] * matrix[1][3] - matrix[0][3] * matrix[1][0]; + float a3 = matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1]; + float a4 = matrix[0][1] * matrix[1][3] - matrix[0][3] * matrix[1][1]; + float a5 = matrix[0][2] * matrix[1][3] - matrix[0][3] * matrix[1][2]; + + float b0 = matrix[2][0] * matrix[3][1] - matrix[2][1] * matrix[3][0]; + float b1 = matrix[2][0] * matrix[3][2] - matrix[2][2] * matrix[3][0]; + float b2 = matrix[2][0] * matrix[3][3] - matrix[2][3] * matrix[3][0]; + float b3 = matrix[2][1] * matrix[3][2] - matrix[2][2] * matrix[3][1]; + float b4 = matrix[2][1] * matrix[3][3] - matrix[2][3] * matrix[3][1]; + float b5 = matrix[2][2] * matrix[3][3] - matrix[2][3] * matrix[3][2]; + + float determinant = a0 * b5 - a1 * b4 + a2 * b3 + a3 * b2 - a4 * b1 + a5 * b0; + + SysTryReturnResult(NID_GRP, Tizen::Base::Float::Compare(determinant, 0.0f) != 0, E_INVALID_OPERATION, "The current instance is not invertible."); + + float inverseMatrix[4][4]; + + inverseMatrix[0][0] = (matrix[1][1] * b5 - matrix[1][2] * b4 + matrix[1][3] * b3) / determinant; + inverseMatrix[1][0] = (-matrix[1][0] * b5 + matrix[1][2] * b2 - matrix[1][3] * b1) / determinant; + inverseMatrix[2][0] = (matrix[1][0] * b4 - matrix[1][1] * b2 + matrix[1][3] * b0) / determinant; + inverseMatrix[3][0] = (-matrix[1][0] * b3 + matrix[1][1] * b1 - matrix[1][2] * b0) / determinant; + + inverseMatrix[0][1] = (-matrix[0][1] * b5 + matrix[0][2] * b4 - matrix[0][3] * b3) / determinant; + inverseMatrix[1][1] = (matrix[0][0] * b5 - matrix[0][2] * b2 + matrix[0][3] * b1) / determinant; + inverseMatrix[2][1] = (-matrix[0][0] * b4 + matrix[0][1] * b2 - matrix[0][3] * b0) / determinant; + inverseMatrix[3][1] = (matrix[0][0] * b3 - matrix[0][1] * b1 + matrix[0][2] * b0) / determinant; + + inverseMatrix[0][2] = (matrix[3][1] * a5 - matrix[3][2] * a4 + matrix[3][3] * a3) / determinant; + inverseMatrix[1][2] = (-matrix[3][0] * a5 + matrix[3][2] * a2 - matrix[3][3] * a1) / determinant; + inverseMatrix[2][2] = (matrix[3][0] * a4 - matrix[3][1] * a2 + matrix[3][3] * a0) / determinant; + inverseMatrix[3][2] = (-matrix[3][0] * a3 + matrix[3][1] * a1 - matrix[3][2] * a0) / determinant; + + inverseMatrix[0][3] = (-matrix[2][1] * a5 + matrix[2][2] * a4 - matrix[2][3] * a3) / determinant; + inverseMatrix[1][3] = (matrix[2][0] * a5 - matrix[2][2] * a2 + matrix[2][3] * a1) / determinant; + inverseMatrix[2][3] = (-matrix[2][0] * a4 + matrix[2][1] * a2 - matrix[2][3] * a0) / determinant; + inverseMatrix[3][3] = (matrix[2][0] * a3 - matrix[2][1] * a1 + matrix[2][2] * a0) / determinant; + + memcpy(matrix, inverseMatrix, MATRIX_SIZE); + + return E_SUCCESS; +} + +void +FloatMatrix4::Transpose(void) +{ + float tmp = 0.0f; + SWAP_VALUES(matrix[0][1], matrix[1][0], tmp); + SWAP_VALUES(matrix[0][2], matrix[2][0], tmp); + SWAP_VALUES(matrix[0][3], matrix[3][0], tmp); + + SWAP_VALUES(matrix[1][2], matrix[2][1], tmp); + SWAP_VALUES(matrix[1][3], matrix[3][1], tmp); + + SWAP_VALUES(matrix[2][3], matrix[3][2], tmp); +} + +void +FloatMatrix4::SetAsNull(void) +{ + matrix[0][0] = 0.0f; + matrix[0][1] = 0.0f; + matrix[0][2] = 0.0f; + matrix[0][3] = 0.0f; + + matrix[1][0] = 0.0f; + matrix[1][1] = 0.0f; + matrix[1][2] = 0.0f; + matrix[1][3] = 0.0f; + + matrix[2][0] = 0.0f; + matrix[2][1] = 0.0f; + matrix[2][2] = 0.0f; + matrix[2][3] = 0.0f; + + matrix[3][0] = 0.0f; + matrix[3][1] = 0.0f; + matrix[3][2] = 0.0f; + matrix[3][3] = 0.0f; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpFloatPoint.cpp b/src/graphics/FGrpFloatPoint.cpp new file mode 100644 index 0000000..02ca099 --- /dev/null +++ b/src/graphics/FGrpFloatPoint.cpp @@ -0,0 +1,183 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpFloatPoint.cpp + * @brief This is the implementation file for FloatPoint class. + * + * This file contains implementation of FloatPoint class. + * + */ + +#include + + +namespace // unnamed +{ + +// epsilon is assumed to be 0.00001f, not 1.192092896e-07f +const float _EPSILON = 0.00001f; + +inline bool +_IsEqual(float f1, float f2) +{ + return (((f1 > f2) ? f1 - f2 : f2 - f1) < _EPSILON); +} + +} + +namespace Tizen { namespace Graphics +{ + +FloatPoint::FloatPoint(void) + : x(0.0f) + , y(0.0f) + , __pImpl(null) +{ +} + +FloatPoint::FloatPoint(const FloatPoint& rhs) + : x(rhs.x) + , y(rhs.y) + , __pImpl(null) +{ +} + +FloatPoint::FloatPoint(float x_, float y_) + : x(x_) + , y(y_) + , __pImpl(null) +{ +} + +FloatPoint::~FloatPoint(void) +{ +} + +FloatPoint& +FloatPoint::operator=(const FloatPoint& rhs) +{ + if (this == &rhs) + { + return *this; + } + + this->x = rhs.x; + this->y = rhs.y; + this->__pImpl = null; + + return *this; +} + +bool +FloatPoint::operator ==(const FloatPoint& rhs) const +{ + return ((_IsEqual(this->x, rhs.x) && _IsEqual(this->y, rhs.y)) ? true : false); +} + +bool +FloatPoint::operator !=(const FloatPoint& rhs) const +{ + return (!operator ==(rhs)); +} + +FloatPoint +FloatPoint::operator +(const FloatPoint& rhs) const +{ + FloatPoint point; + + point.x = this->x + rhs.x; + point.y = this->y + rhs.y; + + return point; +} + +FloatPoint +FloatPoint::operator -(const FloatPoint& rhs) const +{ + FloatPoint point; + + point.x = this->x - rhs.x; + point.y = this->y - rhs.y; + + return point; +} + +FloatPoint& +FloatPoint::operator +=(const FloatPoint& point) +{ + this->x += point.x; + this->y += point.y; + + return *this; +} + +FloatPoint& +FloatPoint::operator -=(const FloatPoint& point) +{ + this->x -= point.x; + this->y -= point.y; + + return *this; +} + +bool +FloatPoint::Equals(const Object& rhs) const +{ + const FloatPoint* pPoint = dynamic_cast (&rhs); + + if (pPoint == null) + { + return false; + } + + return (*this == *pPoint); +} + +int +FloatPoint::GetHashCode(void) const +{ + const float inverseEpsilon = 1.0f / _EPSILON; + + int reinterpretedX = int(this->x * inverseEpsilon); + int reinterpretedY = int(this->y * inverseEpsilon); + + return reinterpretedX ^ (reinterpretedY * 31); +} + +void +FloatPoint::SetPosition(float x, float y) +{ + this->x = x; + this->y = y; +} + +void +FloatPoint::SetPosition(const FloatPoint& point) +{ + this->x = point.x; + this->y = point.y; +} + +void +FloatPoint::Translate(float x, float y) +{ + this->x += x; + this->y += y; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpFloatPoint3.cpp b/src/graphics/FGrpFloatPoint3.cpp new file mode 100644 index 0000000..eb11387 --- /dev/null +++ b/src/graphics/FGrpFloatPoint3.cpp @@ -0,0 +1,177 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpFloatPoint3.cpp + * @brief This is the implementation for %FloatPoint3 class. + */ + +#include +#include +#include +#include + +namespace Tizen { namespace Graphics +{ +FloatPoint3::FloatPoint3(void) + : __pImpl(null) +{ + x = 0.0f; + y = 0.0f; + z = 0.0f; +} + +FloatPoint3::FloatPoint3(const FloatPoint3& rhs) + : __pImpl(null) +{ + x = rhs.x; + y = rhs.y; + z = rhs.z; +} + +FloatPoint3::FloatPoint3(const FloatVector4& vector) + : __pImpl(null) +{ + FloatVector4 normalizedVector = vector.GetNormal(); + + x = normalizedVector.x; + y = normalizedVector.y; + z = normalizedVector.z; +} + +FloatPoint3::FloatPoint3(const float point[3]) + : __pImpl(null) +{ + this->x = point[0]; + this->y = point[1]; + this->z = point[2]; +} + +FloatPoint3::FloatPoint3(float x, float y, float z) + : __pImpl(null) +{ + this->x = x; + this->y = y; + this->z = z; +} + +FloatPoint3::~FloatPoint3(void) +{ +} + +bool +FloatPoint3::operator ==(const FloatPoint3& rhs) const +{ + if (this == &rhs) + { + return true; + } + + return (x == rhs.x && y == rhs.y && z == rhs.z); +} + +FloatPoint3& +FloatPoint3::operator =(const FloatPoint3& rhs) +{ + if (this != &rhs) + { + x = rhs.x; + y = rhs.y; + z = rhs.z; + } + + return *this; +} + +FloatPoint3 +FloatPoint3::operator *(float value) const +{ + return FloatPoint3(x * value, y * value, z * value); +} + +FloatPoint3 +FloatPoint3::operator /(float value) const +{ + return FloatPoint3(x / value, y / value, z / value); +} + +FloatPoint3 +FloatPoint3::operator +(const FloatPoint3& rhs) const +{ + return FloatPoint3(x + rhs.x, y + rhs.y, z + rhs.z); +} + +FloatPoint3 +FloatPoint3::operator -(const FloatPoint3& rhs) const +{ + return FloatPoint3(x - rhs.x, y - rhs.y, z - rhs.z); +} + +FloatPoint3& +FloatPoint3::operator +=(const FloatPoint3& rhs) +{ + this->x += rhs.x; + this->y += rhs.y; + this->z += rhs.z; + + return *this; +} + +FloatPoint3& +FloatPoint3::operator -=(const FloatPoint3& rhs) +{ + this->x -= rhs.x; + this->y -= rhs.y; + this->z -= rhs.z; + + return *this; +} + +bool +FloatPoint3::Equals(const Tizen::Base::Object& obj) const +{ + const FloatPoint3* pVector = dynamic_cast (&obj); + + if (pVector == null) + { + return false; + } + + return (*this == *pVector); +} + +int +FloatPoint3::GetHashCode(void) const +{ + return (Tizen::Base::Float::GetHashCode(x) + + Tizen::Base::Float::GetHashCode(y) + + Tizen::Base::Float::GetHashCode(z)); +} + +FloatPoint3 +operator *(const float& value, const FloatPoint3& rhs) +{ + return rhs * value; +} + +FloatPoint3 +operator /(const float& value, const FloatPoint3& rhs) +{ + return rhs / value; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpFloatRectangle.cpp b/src/graphics/FGrpFloatRectangle.cpp new file mode 100644 index 0000000..b36a4a6 --- /dev/null +++ b/src/graphics/FGrpFloatRectangle.cpp @@ -0,0 +1,334 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpFloatRectangle.cpp + * @brief This is the implementation file for FloatRectangle class. + * + * This file contains implementation of FloatRectangle class. + * + */ + +#include +#include +#include + +#include + +#include "util/FGrp_Util.h" + + +namespace // unnamed +{ + +const float _EMPTY = -1.0f; + +// epsilon is assumed to be 0.00001f, not 1.192092896e-07f +const float _EPSILON = 0.00001f; + +inline bool +_IsEqual(float f1, float f2) +{ + return (((f1 > f2) ? f1 - f2 : f2 - f1) < _EPSILON); +} + +} + +namespace Tizen { namespace Graphics +{ + +FloatRectangle::FloatRectangle() + : x(0.0f) + , y(0.0f) + , width(_EMPTY) + , height(_EMPTY) + , __pImpl(null) +{ +} + +FloatRectangle::FloatRectangle(const FloatRectangle& rhs) + : x(rhs.x) + , y(rhs.y) + , width(rhs.width) + , height(rhs.height) + , __pImpl(null) +{ +} + +FloatRectangle::FloatRectangle(float x_, float y_, float width_, float height_) + : x(x_) + , y(y_) + , width(width_) + , height(height_) + , __pImpl(null) +{ +} + +FloatRectangle::FloatRectangle(const FloatPoint& pt, const FloatDimension& dim) + : x(pt.x) + , y(pt.y) + , width(dim.width) + , height(dim.height) + , __pImpl(null) +{ +} + +FloatRectangle::~FloatRectangle() +{ +} + +FloatRectangle& +FloatRectangle::operator=(const FloatRectangle& rhs) +{ + if (this == &rhs) + { + return *this; + } + + this->x = rhs.x; + this->y = rhs.y; + this->width = rhs.width; + this->height = rhs.height; + this->__pImpl = null; + + return *this; +} +bool +FloatRectangle::operator ==(const FloatRectangle& rhs) const +{ + return ((_IsEqual(this->x, rhs.x) && _IsEqual(this->y, rhs.y) && _IsEqual(this->width, rhs.width) && _IsEqual(this->height, rhs.height)) ? true : false); +} + +bool +FloatRectangle::operator !=(const FloatRectangle& rhs) const +{ + return (!operator ==(rhs)); +} + +bool +FloatRectangle::Contains(const FloatPoint& point) const +{ + if (IsEmpty()) + { + return false; + } + + if (this->x <= point.x && point.x < (this->x + this->width) && + this->y <= point.y && point.y < (this->y + this->height)) + { + return true; + } + + return false; +} + +bool +FloatRectangle::Equals(const Tizen::Base::Object& rhs) const +{ + if (&rhs == null) + { + return false; + } + + const FloatRectangle* pRect = dynamic_cast (&rhs); + + if (pRect == null) + { + return false; + } + + return (*this == *pRect); +} + +int +FloatRectangle::GetHashCode(void) const +{ + int intX = int(this->x); + int intY = int(this->y); + int intWidth = int(this->width); + int intHeight = int(this->height); + + return ((intX & 0xFF) << 24) | ((intY & 0xFF) << 16) | ((intWidth & 0xFF) << 8) | (intHeight & 0xFF); +} + +FloatRectangle +FloatRectangle::GetIntersection(const FloatRectangle& rect) const +{ + FloatRectangle rectResult(0.0f, 0.0f, _EMPTY, _EMPTY); + + if (rect.IsEmpty()) + { + return rectResult; + } + + _Util::Rectangle out; + _Util::Rectangle src1; + _Util::Rectangle src2; + + src1.x = this->x; + src1.y = this->y; + src1.w = this->width; + src1.h = this->height; + + src2.x = rect.x; + src2.y = rect.y; + src2.w = rect.width; + src2.h = rect.height; + + if (!_Util::IntersectRect(out, src1, src2)) + { + return rectResult; + } + + if (out.w <= 0.0f) + { + out.w = _EMPTY; + } + + if (out.h <= 0.0f) + { + out.h = _EMPTY; + } + + // set + rectResult.SetBounds(out.x, out.y, out.w, out.h); + + return rectResult; +} + +bool +FloatRectangle::IsIntersected(const FloatRectangle& rect) const +{ + if (rect.IsEmpty()) + { + return false; + } + + _Util::Rectangle out; + _Util::Rectangle src1; + _Util::Rectangle src2; + + src1.x = this->x; + src1.y = this->y; + src1.w = this->width; + src1.h = this->height; + + src2.x = rect.x; + src2.y = rect.y; + src2.w = rect.width; + src2.h = rect.height; + + return _Util::IntersectRect(out, src1, src2); +} + +FloatRectangle +FloatRectangle::GetUnion(const FloatRectangle& rect) const +{ + FloatRectangle rectResult(0.0f, 0.0f, _EMPTY, _EMPTY); + + if (rect.IsEmpty()) + { + return rectResult; + } + + rectResult.x = _Util::Min(this->x, rect.x); + rectResult.y = _Util::Min(this->y, rect.y); + rectResult.width = _Util::Max((this->x + this->width), (rect.x + rect.width)); + rectResult.width -= rectResult.x; + rectResult.height = _Util::Max((this->y + this->height), (rect.y + rect.height)); + rectResult.height -= rectResult.y; + + return rectResult; +} + +FloatPoint +FloatRectangle::GetBottomRight(void) const +{ + return FloatPoint(this->x + this->width, this->y + this->height); +} + +FloatPoint +FloatRectangle::GetTopLeft(void) const +{ + return FloatPoint(this->x, this->y); +} + +void +FloatRectangle::SetBounds(float x, float y, float width, float height) +{ + this->x = x; + this->y = y; + this->width = width; + this->height = height; +} + +void +FloatRectangle::SetBounds(const FloatPoint& pt, const FloatDimension& dim) +{ + this->x = pt.x; + this->y = pt.y; + this->width = dim.width; + this->height = dim.height; +} + +bool +FloatRectangle::IsEmpty() const +{ + if (this->width <= 0.0f || this->height <= 0.0f) + { + return true; + } + + return false; +} + +void +FloatRectangle::SetSize(const FloatDimension& dim) +{ + this->width = dim.width; + this->height = dim.height; +} + +void +FloatRectangle::SetSize(float width, float height) +{ + this->width = width; + this->height = height; +} + +void +FloatRectangle::SetPosition(const FloatPoint& point) +{ + this->x = point.x; + this->y = point.y; +} + +void +FloatRectangle::SetPosition(float x, float y) +{ + this->x = x; + this->y = y; +} + +void +FloatRectangle::Translate(float x, float y) +{ + this->x += x; + this->y += y; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpFloatVector4.cpp b/src/graphics/FGrpFloatVector4.cpp new file mode 100644 index 0000000..dec014d --- /dev/null +++ b/src/graphics/FGrpFloatVector4.cpp @@ -0,0 +1,225 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FGrpFloatVector4.cpp + * @brief This is the implementation for %FloatVector4 class. + */ + +#include +#include +#include +#include + + +namespace Tizen { namespace Graphics +{ +FloatVector4::FloatVector4(void) + : __pImpl(null) +{ + x = 0.0f; + y = 0.0f; + z = 0.0f; + w = 0.0f; +} + +FloatVector4::FloatVector4(const FloatVector4& rhs) + : __pImpl(null) +{ + x = rhs.x; + y = rhs.y; + z = rhs.z; + w = rhs.w; +} + +FloatVector4::FloatVector4(const FloatPoint3& point) + : __pImpl(null) +{ + x = point.x; + y = point.y; + z = point.z; + w = 1.0f; +} + +FloatVector4::FloatVector4(const float vector[4]) + : __pImpl(null) +{ + this->x = vector[0]; + this->y = vector[1]; + this->z = vector[2]; + this->w = vector[3]; +} + +FloatVector4::FloatVector4(float x, float y, float z, float w) + : __pImpl(null) +{ + this->x = x; + this->y = y; + this->z = z; + this->w = w; +} + +FloatVector4::~FloatVector4(void) +{ +} + +bool +FloatVector4::operator ==(const FloatVector4& rhs) const +{ + if (this == &rhs) + { + return true; + } + + return (x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w); +} + +FloatVector4& +FloatVector4::operator =(const FloatVector4& rhs) +{ + if (this != &rhs) + { + x = rhs.x; + y = rhs.y; + z = rhs.z; + w = rhs.w; + } + + return *this; +} + +FloatVector4 +FloatVector4::operator *(float value) const +{ + return FloatVector4(x * value, y * value, z * value, w * value); +} + +FloatVector4 +FloatVector4::operator /(float value) const +{ + return FloatVector4(x / value, y / value, z / value, w / value); +} + +FloatVector4 +FloatVector4::operator +(const FloatVector4& rhs) const +{ + return FloatVector4(x + rhs.x, y + rhs.y, z + rhs.z, w + rhs.w); +} + +FloatVector4 +FloatVector4::operator -(const FloatVector4& rhs) const +{ + return FloatVector4(x - rhs.x, y - rhs.y, z - rhs.z, w - rhs.w); +} + +FloatVector4& +FloatVector4::operator +=(const FloatVector4& rhs) +{ + this->x += rhs.x; + this->y += rhs.y; + this->z += rhs.z; + this->w += rhs.w; + + return *this; +} + +FloatVector4& +FloatVector4::operator -=(const FloatVector4& rhs) +{ + this->x -= rhs.x; + this->y -= rhs.y; + this->z -= rhs.z; + this->w -= rhs.w; + + return *this; +} + +float +FloatVector4::DotProduct(const FloatVector4& rhs) const +{ + return ((x * rhs.x) + + (y * rhs.y) + + (z * rhs.z) + + (w * rhs.w)); +} + +float +FloatVector4::operator *(const FloatVector4& rhs) const +{ + return DotProduct(rhs); +} + +FloatVector4 +operator *(const float& value, const FloatVector4& rhs) +{ + return rhs * value; +} + +FloatVector4 +operator /(const float& value, const FloatVector4& rhs) +{ + return rhs / value; +} + +bool +FloatVector4::Equals(const Tizen::Base::Object& obj) const +{ + const FloatVector4* pVector = dynamic_cast (&obj); + + if (pVector == null) + { + return false; + } + + return (*this == *pVector); +} + +int +FloatVector4::GetHashCode(void) const +{ + return (Tizen::Base::Float::GetHashCode(x) + + Tizen::Base::Float::GetHashCode(y) + + Tizen::Base::Float::GetHashCode(z) + + Tizen::Base::Float::GetHashCode(w)); +} + +float +FloatVector4::GetLength(void) const +{ + return sqrt((x * x) + (y * y) + (z * z) + (w * w)); +} + +FloatVector4 +FloatVector4::GetNormal(void) const +{ + float length = GetLength(); + + return (*this / length); +} + +void +FloatVector4::Normalize(void) +{ + float length = GetLength(); + + x /= length; + y /= length; + z /= length; + w /= length; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpFont.cpp b/src/graphics/FGrpFont.cpp new file mode 100644 index 0000000..c7842dc --- /dev/null +++ b/src/graphics/FGrpFont.cpp @@ -0,0 +1,304 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpFont.cpp + * @brief This is the implementation file for Font class. + * + * This header file contains implementation of Font class. + * + */ + +#include +#include +#include + +#include + +#include "FGrp_FontImpl.h" +#include "FGrp_ResUtil.h" + +#define CHECK_NOT_CONSTRUCTED \ + SysTryReturnResult(NID_GRP, this->__pImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Fails to allocate memory.") \ + SysAssertf(!this->__pImpl->IsConstructed(), \ + "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + +#define CHECK_CONSTRUCTED \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed! Construct() should be called before use."); + +#define CHECK_CONSTRUCTED_EX(_result) \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed! Construct() should be called before use."); + +#define CHECK_CONSTRUCTED_VOID \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed! Construct() should be called before use."); + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Graphics +{ + +Font::Font() +{ + __pImpl = new (std::nothrow) _FontImpl; +} + +Font::Font(const Font& rhs) +{ + __pImpl = rhs.__pImpl->CloneN(); +} + +Font::~Font(void) +{ + delete __pImpl; + __pImpl = null; +} + +result +Font::Construct(int style, int vc_size) +{ + CHECK_NOT_CONSTRUCTED; + + // check input param. + SysTryReturnResult(NID_GRP, vc_size > 0, E_INVALID_ARG, "Font size should be greater than 0"); + SysTryReturnResult(NID_GRP, FONT_STYLE_MIN < style && style <= (FONT_STYLE_PLAIN | FONT_STYLE_BOLD | FONT_STYLE_ITALIC), E_INVALID_ARG, + "Style(%d) is invalid", style); + + result r = __pImpl->Construct(style, vc_size); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Font::Construct(const Tizen::Base::String& fontNameOrPath, int style, int vc_size) +{ + CHECK_NOT_CONSTRUCTED; + + // check input param. + SysTryReturnResult(NID_GRP, vc_size > 0, E_INVALID_ARG, "Font size should be greater than 0"); + SysTryReturnResult(NID_GRP, FONT_STYLE_MIN < style && style <= (FONT_STYLE_PLAIN | FONT_STYLE_BOLD | FONT_STYLE_ITALIC), E_INVALID_ARG, + "Style(%d) is invalid.\n", style); + SysTryReturnResult(NID_GRP, fontNameOrPath.GetLength() > 0, E_FILE_NOT_FOUND, "The specified font could not be found or accessed"); + SysTryReturnResult(NID_GRP, !fontNameOrPath.EndsWith(L"/") && !fontNameOrPath.EndsWith(L"\\"), E_FILE_NOT_FOUND, + "The specified font could not be found or accessed.\n"); + + result r = __pImpl->Construct(fontNameOrPath, style, vc_size); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Font::Construct(const Tizen::Base::ByteBuffer& fontData, int style, int vc_size) +{ + CHECK_NOT_CONSTRUCTED; + + // check input param. + SysTryReturnResult(NID_GRP, fontData.GetLimit() > 0, E_INVALID_ARG, "Buffer size should be greater than 0"); + SysTryReturnResult(NID_GRP, vc_size > 0, E_INVALID_ARG, "FontEx size should be greater than 0"); + SysTryReturnResult(NID_GRP, style > FONT_STYLE_MIN && style <= (FONT_STYLE_PLAIN | FONT_STYLE_BOLD | FONT_STYLE_ITALIC), E_INVALID_ARG, + "Style(%d) is invalid", style); + + result r = __pImpl->Construct(fontData, style, vc_size); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +int +Font::GetMaxHeight(void) const +{ + CHECK_CONSTRUCTED_EX(-1); + + return __pImpl->GetMaxHeight(); +} + +int +Font::GetMaxWidth(void) const +{ + CHECK_CONSTRUCTED_EX(-1); + + return __pImpl->GetMaxWidth(); +} + +int +Font::GetAscender(void) const +{ + CHECK_CONSTRUCTED_EX(-1); + + return __pImpl->GetAscender(); +} + +int +Font::GetDescender(void) const +{ + CHECK_CONSTRUCTED_EX(-1); + + return __pImpl->GetDescender(); +} + +result +Font::GetLeftBear(wchar_t character, int& vc_leftBear) const +{ + CHECK_CONSTRUCTED; + + return __pImpl->GetLeftBear(character, vc_leftBear); +} + +result +Font::GetRightBear(wchar_t character, int& vc_rightBear) const +{ + CHECK_CONSTRUCTED; + + return __pImpl->GetRightBear(character, vc_rightBear); +} + +result +Font::GetTextExtent(const Tizen::Base::String& text, int length, Dimension& vc_dim) const +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_GRP, length >= 0 && length <= text.GetLength(), E_OUT_OF_RANGE, + "The length(%d) of the given text is out of range", length); + + if (length == 0 || text.GetLength() == 0) + { + return E_SUCCESS; + } + + result r = __pImpl->GetTextExtent(text, length, vc_dim); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (!Tizen::App::_AppInfo::IsOspCompat()) + { + vc_dim.height = GetMaxHeight(); + } + + return E_SUCCESS; +} + +bool +Font::IsBold(void) const +{ + CHECK_CONSTRUCTED_EX(false); + + return __pImpl->IsBold(); +} + +bool +Font::IsItalic(void) const +{ + CHECK_CONSTRUCTED_EX(false); + + return __pImpl->IsItalic(); +} + +bool +Font::IsPlain(void) const +{ + CHECK_CONSTRUCTED_EX(false); + + return __pImpl->IsPlain(); +} + +bool +Font::IsStrikeOut(void) const +{ + CHECK_CONSTRUCTED_EX(false); + + return __pImpl->IsStrikeOut(); +} + +bool +Font::IsUnderlined(void) const +{ + CHECK_CONSTRUCTED_EX(false); + + return __pImpl->IsUnderlined(); +} + +int +Font::GetSize(void) const +{ + CHECK_CONSTRUCTED_EX(-1); + + return __pImpl->GetSize(); +} + +void +Font::SetStrikeOut(bool strikeout) +{ + CHECK_CONSTRUCTED_VOID; + + return __pImpl->SetStrikeOut(strikeout); +} + +void +Font::SetUnderline(bool underline) +{ + CHECK_CONSTRUCTED_VOID; + + return __pImpl->SetUnderline(underline); +} + +void +Font::SetCharSpace(int vc_space) +{ + CHECK_CONSTRUCTED_VOID; + + return __pImpl->SetCharSpace(vc_space); +} + +int +Font::GetCharSpace(void) const +{ + CHECK_CONSTRUCTED_EX(0); + + return __pImpl->GetCharSpace(); +} + +Tizen::Base::String +Font::GetFaceName(void) const +{ + CHECK_CONSTRUCTED_EX(""); + + return __pImpl->GetFaceName(); +} + +Tizen::Base::Collection::IList* +Font::GetSystemFontListN(void) +{ + return _FontImpl::GetSystemFontListN(); +} + +Tizen::Base::String +Font::GetFaceName(const Tizen::Base::String& filePath) +{ + return _FontImpl::GetFaceName(filePath); +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpPoint.cpp b/src/graphics/FGrpPoint.cpp new file mode 100644 index 0000000..5129b14 --- /dev/null +++ b/src/graphics/FGrpPoint.cpp @@ -0,0 +1,168 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpPoint.cpp + * @brief This is the implementation file for Point class. + * + * This file contains implementation of Point class. + * + */ + +#include + + +namespace Tizen { namespace Graphics +{ + +Point::Point(void) + : x(0) + , y(0) + , __pImpl(null) +{ +} + +Point::Point(const Point & rhs) + : x(rhs.x) + , y(rhs.y) + , __pImpl(null) +{ +} + +Point::Point(int x_, int y_) + : x(x_) + , y(y_) + , __pImpl(null) +{ +} + +Point::~Point(void) +{ +} + +Point& +Point::operator =(const Point & rhs) +{ + if (this == &rhs) + { + return *this; + } + + this->x = rhs.x; + this->y = rhs.y; + this->__pImpl = null; + + return *this; +} + +bool +Point::operator ==(const Point& rhs) const +{ + return ((this->x == rhs.x && this->y == rhs.y) ? true : false); +} + +bool +Point::operator !=(const Point& rhs) const +{ + return (!operator ==(rhs)); +} + +Point +Point::operator +(const Point& rhs) const +{ + Point point; + + point.x = this->x + rhs.x; + point.y = this->y + rhs.y; + + return point; +} + +Point +Point::operator -(const Point& rhs) const +{ + Point point; + + point.x = this->x - rhs.x; + point.y = this->y - rhs.y; + + return point; +} + +Point& +Point::operator +=(const Point& point) +{ + this->x += point.x; + this->y += point.y; + + return *this; +} + +Point& +Point::operator -=(const Point& point) +{ + this->x -= point.x; + this->y -= point.y; + + return *this; +} + +bool +Point::Equals(const Object& rhs) const +{ + const Point* pPoint = dynamic_cast (&rhs); + + if (pPoint == null) + { + return false; + } + + return (*this == *pPoint); +} + +int +Point::GetHashCode(void) const +{ + int bits = this->x; + + bits ^= this->y * 31; + + return (((int) bits) ^ ((int) (bits >> 16))); +} + +void +Point::SetPosition(int x, int y) +{ + this->x = x; + this->y = y; +} + +void +Point::SetPosition(const Point& point) +{ + this->x = point.x; + this->y = point.y; +} + +void +Point::Translate(int x, int y) +{ + this->x += x; + this->y += y; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpRectangle.cpp b/src/graphics/FGrpRectangle.cpp new file mode 100644 index 0000000..4660ae7 --- /dev/null +++ b/src/graphics/FGrpRectangle.cpp @@ -0,0 +1,321 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpRectangle.cpp + * @brief This is the implementation file for Rectangle class. + * + * This file contains implementation of Rectangle class. + * + */ + +#include +#include +#include + +#include + +#include "util/FGrp_Util.h" + + +namespace Tizen { namespace Graphics +{ + +namespace // unnamed +{ + +const int _EMPTY = -1; + +} + +Rectangle::Rectangle() + : x(0) + , y(0) + , width(_EMPTY) + , height(_EMPTY) + , __pImpl(null) +{ +} + +Rectangle::Rectangle(const Rectangle & rhs) + : x(rhs.x) + , y(rhs.y) + , width(rhs.width) + , height(rhs.height) + , __pImpl(null) +{ +} + +Rectangle::Rectangle(int x_, int y_, int width_, int height_) + : x(x_) + , y(y_) + , width(width_) + , height(height_) + , __pImpl(null) +{ +} + +Rectangle::Rectangle(const Point& pt, const Dimension& dim) + : x(pt.x) + , y(pt.y) + , width(dim.width) + , height(dim.height) + , __pImpl(null) +{ +} + +Rectangle::~Rectangle() +{ +} + +Rectangle& +Rectangle::operator =(const Rectangle & rhs) +{ + if (this == &rhs) + { + return *this; + } + + this->x = rhs.x; + this->y = rhs.y; + this->width = rhs.width; + this->height = rhs.height; + this->__pImpl = null; + + return *this; +} + +bool +Rectangle::operator ==(const Rectangle& rhs) const +{ + return ((this->x == rhs.x && this->y == rhs.y && this->width == rhs.width && this->height == rhs.height) ? true : false); +} + +bool +Rectangle::operator !=(const Rectangle& rhs) const +{ + return (!operator ==(rhs)); +} + +bool +Rectangle::Contains(const Point& point) const +{ + if (IsEmpty()) + { + return false; + } + + if (this->x <= point.x && point.x < (this->x + this->width) && + this->y <= point.y && point.y < (this->y + this->height)) + { + return true; + } + + return false; +} + +bool +Rectangle::Equals(const Tizen::Base::Object& rhs) const +{ + if (&rhs == null) + { + return false; + } + + const Rectangle* pRect = dynamic_cast (&rhs); + + if (pRect == null) + { + return false; + } + + return (*this == *pRect); +} + +int +Rectangle::GetHashCode(void) const +{ + return ((this->x & 0xFF) << 24) | ((this->y & 0xFF) << 16) | ((this->width & 0xFF) << 8) | (this->height & 0xFF); +} + +Rectangle +Rectangle::GetIntersection(const Rectangle& rect) const +{ + Rectangle rectResult; + + if (rect.IsEmpty() || this->IsEmpty()) + { + return rectResult; + } + + _Util::Rectangle out; + _Util::Rectangle src1; + _Util::Rectangle src2; + + src1.x = this->x; + src1.y = this->y; + src1.w = this->width; + src1.h = this->height; + + src2.x = rect.x; + src2.y = rect.y; + src2.w = rect.width; + src2.h = rect.height; + + if (!_Util::IntersectRect(out, src1, src2)) + { + return rectResult; + } + + if (out.w <= 0) + { + out.w = _EMPTY; + } + + if (out.h <= 0) + { + out.h = _EMPTY; + } + + // set + rectResult.SetBounds(out.x, out.y, out.w, out.h); + + return rectResult; +} + +bool +Rectangle::IsIntersected(const Rectangle& rect) const +{ + if (rect.IsEmpty()) + { + return false; + } + + _Util::Rectangle out; + _Util::Rectangle src1; + _Util::Rectangle src2; + + src1.x = this->x; + src1.y = this->y; + src1.w = this->width; + src1.h = this->height; + + src2.x = rect.x; + src2.y = rect.y; + src2.w = rect.width; + src2.h = rect.height; + + return _Util::IntersectRect(out, src1, src2); +} + +Rectangle +Rectangle::GetUnion(const Rectangle& rect) const +{ + Rectangle rectResult; + + if (rect.IsEmpty() || this->IsEmpty()) + { + return rectResult; + } + + rectResult.x = _Util::Min(this->x, rect.x); + rectResult.y = _Util::Min(this->y, rect.y); + rectResult.width = _Util::Max((this->x + this->width), (rect.x + rect.width)); + rectResult.width -= rectResult.x; + rectResult.height = _Util::Max((this->y + this->height), (rect.y + rect.height)); + rectResult.height -= rectResult.y; + + return rectResult; +} + +Point +Rectangle::GetBottomRight(void) const +{ + return Point(this->x + this->width, this->y + this->height); +} + +Point +Rectangle::GetTopLeft(void) const +{ + return Point(this->x, this->y); +} + +void +Rectangle::SetBounds(int x, int y, int width, int height) +{ + this->x = x; + this->y = y; + this->width = width; + this->height = height; +} + +void +Rectangle::SetBounds(const Point& pt, const Dimension& dim) +{ + this->x = pt.x; + this->y = pt.y; + this->width = dim.width; + this->height = dim.height; +} + +bool +Rectangle::IsEmpty() const +{ + if (this->width <= 0 || this->height <= 0) + { + return true; + } + + return false; +} + +void +Rectangle::SetSize(const Dimension& dim) +{ + this->width = dim.width; + this->height = dim.height; +} + +void +Rectangle::SetSize(int width, int height) +{ + this->width = width; + this->height = height; +} + +void +Rectangle::SetPosition(const Point& point) +{ + this->x = point.x; + this->y = point.y; +} + +void +Rectangle::SetPosition(int x, int y) +{ + this->x = x; + this->y = y; +} + +void +Rectangle::Translate(int x, int y) +{ + this->x += x; + this->y += y; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrpTextElement.cpp b/src/graphics/FGrpTextElement.cpp new file mode 100644 index 0000000..fcc6c8d --- /dev/null +++ b/src/graphics/FGrpTextElement.cpp @@ -0,0 +1,237 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FGrpTextElement.cpp +* @brief This is the cpp file for TextElement class. +*/ + +#include + +#include +#include +#include + +#include + +#include "FGrp_TextElementImpl.h" +#include "FGrp_ResUtil.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; + +#define CHECK_NOT_CONSTRUCTED \ + SysTryReturnResult(NID_GRP, this->__pImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Fails to allocate memory.") \ + SysAssertf(!this->__pImpl->IsConstructed(), \ + "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + +#define CHECK_CONSTRUCTED \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed! Construct() should be called before use."); + +#define CHECK_CONSTRUCTED_EX(_result) \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsConstructed(), \ + "Not yet constructed! Construct() should be called before use."); + +namespace Tizen { namespace Graphics +{ + +TextElement::TextElement() +{ + __pImpl = new (std::nothrow) _TextElementImpl; +} + +TextElement::~TextElement() +{ + if (__pImpl) + { + delete __pImpl; + __pImpl = null; + } +} + +result +TextElement::Construct(const Tizen::Base::String& text) +{ + CHECK_NOT_CONSTRUCTED; + + result r = __pImpl->Construct(text); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +TextElement::Construct(const Tizen::Base::String& text, const Tizen::Graphics::Canvas& canvas) +{ + CHECK_NOT_CONSTRUCTED; + + result r = __pImpl->Construct(text, canvas); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +TextElement::Construct(void) +{ + CHECK_NOT_CONSTRUCTED; + + result r = __pImpl->Construct(); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +TextElement::Construct(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link) +{ + CHECK_NOT_CONSTRUCTED; + + result r = __pImpl->Construct(text, linkType, link); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +TextElement::Construct(const Tizen::Base::String& text, unsigned long autoLink) +{ + CHECK_NOT_CONSTRUCTED; + + result r = __pImpl->Construct(text, autoLink); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +TextElement::Construct(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link, + const Tizen::Graphics::Canvas& canvas) +{ + CHECK_NOT_CONSTRUCTED; + + result r = __pImpl->Construct(text, linkType, link, canvas); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +TextElement::Construct(const Tizen::Base::String& text, unsigned long autoLink, const Tizen::Graphics::Canvas& canvas) +{ + CHECK_NOT_CONSTRUCTED; + + result r = __pImpl->Construct(text, autoLink, canvas); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Tizen::Base::String +TextElement::GetLink(void) const +{ + CHECK_CONSTRUCTED_EX(String()); + + return __pImpl->GetLink(); +} + +Tizen::Base::Utility::LinkType +TextElement::GetLinkType(void) const +{ + CHECK_CONSTRUCTED_EX(LINK_TYPE_NONE); + + return __pImpl->GetLinkType(); +} + +result +TextElement::SetText(const Tizen::Base::String& text) +{ + CHECK_CONSTRUCTED; + + return __pImpl->SetText(text); +} + +result +TextElement::SetFont(const Tizen::Graphics::Font& font) +{ + CHECK_CONSTRUCTED; + + result r = __pImpl->SetFont(font); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r)); + + return r; +} + +result +TextElement::SetTextColor(const Tizen::Graphics::Color& color) +{ + CHECK_CONSTRUCTED; + + return __pImpl->SetTextColor(color); +} + +result +TextElement::SetBackgroundColor(const Tizen::Graphics::Color& color) +{ + CHECK_CONSTRUCTED; + + return __pImpl->SetBackgroundColor(color); +} + +result +TextElement::SetOutlineColor(const Tizen::Graphics::Color& color) +{ + CHECK_CONSTRUCTED; + + return __pImpl->SetOutlineColor(color); +} + +Tizen::Base::String +TextElement::GetText() const +{ + CHECK_CONSTRUCTED_EX(String()); + + return __pImpl->GetText(); +} + +Tizen::Graphics::Color +TextElement::GetTextColor() const +{ + CHECK_CONSTRUCTED_EX(Color::GetColor(COLOR_ID_BLACK)); + + return __pImpl->GetTextColor(); +} + +Tizen::Graphics::Color +TextElement::GetBackgroundColor() const +{ + CHECK_CONSTRUCTED_EX(Color::GetColor(COLOR_ID_BLACK)); + + return __pImpl->GetBackgroundColor(); +} + +Tizen::Graphics::Color +TextElement::GetOutlineColor() const +{ + CHECK_CONSTRUCTED_EX(Color::GetColor(COLOR_ID_BLACK)); + + return __pImpl->GetOutlineColor(); +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_Bitmap.cpp b/src/graphics/FGrp_Bitmap.cpp new file mode 100644 index 0000000..0b0dcd0 --- /dev/null +++ b/src/graphics/FGrp_Bitmap.cpp @@ -0,0 +1,1139 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Bitmap.cpp + * @brief This is the implementation file for _Bitmap class. + * + */ + +#include +#include + +#include + +#include +#include +#include + +#include + +#include "FGrp_BufferInfoImpl.h" +#include "FGrp_Bitmap.h" +#include "FGrp_Canvas.h" +#include "FGrp_CanvasPixman.h" +#include "FGrp_Screen.h" +#include "util/FGrp_UtilTemplate.h" +#include "effect/FGrp_Effect.h" + +//////////////////////////////////////////////////////////////////////////////// + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace // unnamed +{ + +bool +_CheckValidityOfRectangle(const Tizen::Graphics::Rectangle& rect) +{ + return ((rect.width > 0) && (rect.height > 0)); +} + +bool +_CheckValidity(const Tizen::Graphics::Rectangle& rtSrc, const Tizen::Graphics::Rectangle& rtDest) +{ + // check 1. is width/height less or equal than 0? + if (rtSrc.width <= 0 || rtSrc.height <= 0 || rtDest.width <= 0 || rtDest.height <= 0) + { + return false; // "[E_OUT_OF_RANGE] The argument is out of range. (src(w:%d,h:%d), dst(w:%d,h:%d))\n", rtSrc.width, rtSrc.height, rtDest.width, rtDest.height); + } + + // check 2. is src exiting outside of dest entirely? + if (rtSrc.x > rtDest.x + rtDest.width - 1 || rtSrc.x + rtSrc.width - 1 < rtDest.x) + { + return false; // "[E_OUT_OF_RANGE] The argument is out of range. (src(x:%d,y:%d,w:%d,h:%d), dst(x:%d,y:%d,w:%d,h:%d))\n", rtSrc.x, rtSrc.y, rtSrc.width, rtSrc.height, rtDest.x, rtDest.y, rtDest.width, rtDest.height); + } + + if (rtSrc.y > rtDest.y + rtDest.height - 1 || rtSrc.y + rtSrc.height - 1 < rtDest.y) + { + return false; // "[E_OUT_OF_RANGE] The argument is out of range. (src(x:%d,y:%d,w:%d,h:%d), dst(x:%d,y:%d,w:%d,h:%d))\n", rtSrc.x, rtSrc.y, rtSrc.width, rtSrc.height, rtDest.x, rtDest.y, rtDest.width, rtDest.height); + } + + return true; +} + +bool +_IsOpaqueAllOver(Tizen::Graphics::_Bitmap* pBitmap) +{ + bool ret = false; + + if (pBitmap == null) + { + return ret; + } + + Tizen::Graphics::BufferInfo dstBufferInfo; + + if (pBitmap->Lock(dstBufferInfo) == E_SUCCESS) + { + const Tizen::Graphics::_Util::Pixmap dstImage(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + ret = Tizen::Graphics::_Effect::IsOpaqueAllOver(dstImage); + + pBitmap->Unlock(); + } + + return ret; +} + +typedef result (::Tizen::Graphics::_Bitmap::* _FnLock)(Tizen::Graphics::BufferInfo&, long); +typedef result (::Tizen::Graphics::_Bitmap::* _FnUnlock)(void); + +bool +_IsOpaqueAllOver(Tizen::Graphics::_Bitmap* pBitmap, _FnLock fnLock, _FnUnlock fnUnlock) +{ + bool ret = false; + + if (pBitmap == null) + { + return ret; + } + + Tizen::Graphics::BufferInfo dstBufferInfo; + if ((pBitmap->*fnLock)(dstBufferInfo, INFINITE) == E_SUCCESS) + { + const Tizen::Graphics::_Util::Pixmap dstImage(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + ret = Tizen::Graphics::_Effect::IsOpaqueAllOver(dstImage); + + (pBitmap->*fnUnlock)(); + } + + return ret; +} + +class _BitmapImplExHack + : public _Bitmap +{ +public: + void SetOwnership(bool ownership) + { + this->_SetOwnership(ownership); + } + + void ChangeBuffer(bool ownership, unsigned char* pBuffer) + { + this->_ChangeBuffer(ownership, pBuffer); + } +}; // _BitmapImplExHack + +template +result +_CreateBitmapFromBufferInfo(_Bitmap* thiz, BufferInfo& sourBufferInfo, int x, int y, int width, int height) +{ + std::unique_ptr pDestBuffer(new (std::nothrow) unsigned char[width * height * sizeof(Pixel)]); + + if (pDestBuffer == null) + { + return E_OUT_OF_MEMORY; + } + + std::auto_ptr<_Util::ScratchPad > pSourScratchPadAuto(new (std::nothrow) _Util::ScratchPad((Pixel*) sourBufferInfo.pPixels, sourBufferInfo.width, sourBufferInfo.height, sourBufferInfo.pitch / sizeof(Pixel))); + std::auto_ptr<_Util::ScratchPad > pDestScratchPadAuto(new (std::nothrow) _Util::ScratchPad((Pixel*) pDestBuffer.get(), width, height, width)); + + _Util::ScratchPad* pSourScratchPad = pSourScratchPadAuto.get(); + _Util::ScratchPad* pDestScratchPad = pDestScratchPadAuto.get(); + + if (pSourScratchPad == null || pDestScratchPad == null) + { + return E_OUT_OF_MEMORY; + } + + pDestScratchPad->BitBlt(0, 0, pSourScratchPad, x, y, width, height); + + result r = thiz->Construct((void*) pDestBuffer.get(), width, height, sizeof(Pixel) * 8); + + if (r != E_SUCCESS) + { + return r; + } + + pDestBuffer.release(); + + static_cast<_BitmapImplExHack*>(thiz)->SetOwnership(true); + + return E_SUCCESS; +} + +template +result +_Resize(_Bitmap* thiz, _Util::ScratchPad*& pScratchPad, int width, int height, BitmapScalingQuality quality = BITMAP_SCALING_QUALITY_LOW) +{ + std::unique_ptr pDestBuffer(new (std::nothrow) unsigned char[width * height * sizeof(Pixel)]); + + if (pDestBuffer == null) + { + return E_OUT_OF_MEMORY; + } + + memset(pDestBuffer.get(), 0, width * height * sizeof(Pixel)); + + Pixel* pAddr; + int pitch; + + pScratchPad->GetBuffer(pAddr, pitch); + + _Util::Pixmap srcImageEx(pScratchPad->GetWidth(), pScratchPad->GetHeight(), sizeof(Pixel) * 8, pAddr, pitch * sizeof(Pixel)); + _Util::Pixmap dstImageEx(width, height, sizeof(Pixel) * 8, pDestBuffer.get(), width * sizeof(Pixel)); + + bool isDone = Tizen::Graphics::_Pixman::ResizePixmap(dstImageEx, srcImageEx, quality); + + if (!isDone) + { + switch (quality) + { + case BITMAP_SCALING_QUALITY_LOW: + isDone = Tizen::Graphics::_Effect::ScaleImage(dstImageEx, 0, 0, width, height, srcImageEx, Tizen::Graphics::_Effect::ROP_COPY); + break; + case BITMAP_SCALING_QUALITY_MID: + isDone = Tizen::Graphics::_Effect::ScaleImageInterpolation(dstImageEx, 0, 0, width, height, srcImageEx, Tizen::Graphics::_Effect::DEFAULT_FILTER_GOOD); + break; + case BITMAP_SCALING_QUALITY_HIGH: + isDone = Tizen::Graphics::_Effect::ScaleImageInterpolation(dstImageEx, 0, 0, width, height, srcImageEx, Tizen::Graphics::_Effect::DEFAULT_FILTER_BEST); + break; + } + } + + if (!isDone) + { + return E_SYSTEM; + } + + _Util::ScratchPad* pTempScratchPad = new (std::nothrow) _Util::ScratchPad((Pixel*) pDestBuffer.get(), width, height, width); + + if (pTempScratchPad == null) + { + return E_OUT_OF_MEMORY; + } + + // swap them. + delete pScratchPad; + pScratchPad = pTempScratchPad; + + //?? need to be verified again for clearing + static_cast<_BitmapImplExHack*>(thiz)->ChangeBuffer(true, (unsigned char*) pDestBuffer.release()); + + return E_SUCCESS; +} + +template +result +_MergeWithConversion(_Util::ScratchPad* pDestScratchPad, int destX, int destY, _Util::ScratchPad* pSourScratchPad, int srcX, int srcY, int srcWidth, int srcHeight) +{ + _Util::Pixmap* pSrcImageEx = null; + + { + _Util::ScratchPad& srcScratchPad = *pSourScratchPad; + + SourPixel* pAddr; + int pitch; + + srcScratchPad.GetBuffer(pAddr, pitch); + + { + _Util::Pixmap srcImageEx(srcScratchPad.GetWidth(), srcScratchPad.GetHeight(), sizeof(SourPixel) * 8, pAddr, pitch * sizeof(SourPixel)); + + pSrcImageEx = srcImageEx.GetClone(sizeof(DestPixel) * 8); + } + + if (pSrcImageEx == null) + { + return E_SYSTEM; + } + } + + _Util::ScratchPad srcScratchPad((DestPixel*) pSrcImageEx->pBitmap, pSrcImageEx->width, pSrcImageEx->height, pSrcImageEx->bytesPerLine / sizeof(DestPixel)); + + pDestScratchPad->BitBlt(destX, destY, &srcScratchPad, srcX, srcY, srcWidth, srcHeight); + + delete pSrcImageEx; + + return E_SUCCESS; +} + +} + +namespace Tizen { namespace Graphics +{ + +bool _GetScreenShot(int depth, unsigned char*& pOutBuffer, int& screenWidth, int& screenHeight); + +_Bitmap::_Bitmap(void) + : __timeStamp(0) + , __opacity(255) + , __isOpaqueAllOver(0) + , __hasOwnership(true) + , __pBuffer(null) + , __isPremultiplied(false) + , __hasMaskingColor(false) + , __maskingColor(0) + , __bitmapPixelFormat(BITMAP_PIXEL_FORMAT_MIN) + , __scalingQuality(BITMAP_SCALING_QUALITY_LOW) + , __pScratchPad32(null) + , __pScratchPad16(null) + , __pLockCallbackFunc(null) + , __pLockCallbackParam(null) + , __pUnlockCallbackFunc(null) + , __pUnlockCallbackParam(null) +{ +} + +_Bitmap::~_Bitmap(void) +{ + delete __pScratchPad32; + delete __pScratchPad16; + + if (__hasOwnership) + { + delete[] __pBuffer; + } +} + +result +_Bitmap::Construct(const Rectangle& rect) +{ + //?? what do you do in the case of 16-bit? + const int systemBpp = _Screen::GetBytesPerPixel(); + + SysTryReturnResult(NID_GRP, (systemBpp == 32) || (systemBpp == 16), E_SYSTEM, "Screen depth is not available."); + + int x = rect.x; + int y = rect.y; + int width = rect.width; + int height = rect.height; + + { + size_t allocSize = width * height * systemBpp; + + std::unique_ptr pAllocated(new (std::nothrow) unsigned char[allocSize]); + + SysTryReturnResult(NID_GRP, pAllocated, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The bitmap memory is insufficient"); + + result r = this->Construct((void*) pAllocated.get(), width, height, systemBpp); + + SysTryReturnResult(NID_GRP, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + // copy contents from the current screen + { + unsigned char* pCapturedBuffer = null; + int bufferWidth = 0; + int bufferHeight = 0; + + if (_GetScreenShot(systemBpp, pCapturedBuffer, bufferWidth, bufferHeight)) + { + switch (systemBpp) + { + case 32: + if (__pScratchPad32) + { + _Util::ScratchPad capturedScratchPad((unsigned long*) pCapturedBuffer, bufferWidth, bufferHeight, bufferWidth); + __pScratchPad32->BitBlt(0, 0, &capturedScratchPad, x, y, width, height); + } + break; + case 16: + if (__pScratchPad16) + { + _Util::ScratchPad capturedScratchPad((unsigned short*) pCapturedBuffer, bufferWidth, bufferHeight, bufferWidth); + __pScratchPad16->BitBlt(0, 0, &capturedScratchPad, x, y, width, height); + } + break; + } + + delete[] pCapturedBuffer; + } + } + + this->__hasOwnership = true; + + this->__isOpaqueAllOver = _IsOpaqueAllOver(this); + + this->__bitmapPixelFormat = (systemBpp == 32) ? BITMAP_PIXEL_FORMAT_ARGB8888 : BITMAP_PIXEL_FORMAT_RGB565; + + pAllocated.release(); + + return E_SUCCESS; + } +} + +result +_Bitmap::Construct(const Dimension& dim, BitmapPixelFormat pixelFormat) +{ + int size = dim.width * dim.height; + int bytesPerPixel = 0; + + switch (pixelFormat) + { + case BITMAP_PIXEL_FORMAT_RGB565: + size *= sizeof(unsigned short); + bytesPerPixel = sizeof(unsigned short); + break; + case BITMAP_PIXEL_FORMAT_ARGB8888: + case BITMAP_PIXEL_FORMAT_R8G8B8A8: + size *= sizeof(unsigned long); + bytesPerPixel = sizeof(unsigned long); + break; + default: + SysTryReturnResult(NID_GRP, 0, E_INVALID_ARG, "BitmapPixelFormat(%d) is invalid argument.\n", pixelFormat); + break; + } + + int width = dim.width; + int height = dim.height; + + { + size_t allocSize = width * height * bytesPerPixel; + + std::unique_ptr pAllocated(new (std::nothrow) unsigned char[allocSize]); + + SysTryReturnResult(NID_GRP, pAllocated, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The bitmap memory is insufficient"); + + result r = this->Construct((void*) pAllocated.get(), width, height, bytesPerPixel * 8); + + SysTryReturnResult(NID_GRP, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + memset(pAllocated.get(), 0, allocSize); + + this->__hasOwnership = true; + + this->__isOpaqueAllOver = _IsOpaqueAllOver(this); + + this->__bitmapPixelFormat = pixelFormat; + + pAllocated.release(); + + return r; + } +} + +result +_Bitmap::Construct(const _Canvas& canvas, const Rectangle& rect) +{ + SysTryReturnResult(NID_GRP, canvas.IsValid(), E_INVALID_ARG, "A canvas is invalid.\n"); + + result r = E_SYSTEM; + + int x = rect.x; + int y = rect.y; + int width = rect.width; + int height = rect.height; + + BufferInfo sourBI; + + if (const_cast<_Canvas&>(canvas).Lock(sourBI) == E_SUCCESS) + { + switch (sourBI.bitsPerPixel) + { + case 16: + r = _CreateBitmapFromBufferInfo(this, sourBI, x, y, width, height); + break; + + case 32: + r = _CreateBitmapFromBufferInfo(this, sourBI, x, y, width, height); + break; + + default: + break; + } + + const_cast<_Canvas&>(canvas).Unlock(); + } + + this->__isOpaqueAllOver = _IsOpaqueAllOver(this); + + this->__bitmapPixelFormat = (sourBI.bitsPerPixel == 32) ? BITMAP_PIXEL_FORMAT_ARGB8888 : BITMAP_PIXEL_FORMAT_RGB565; + + return r; +} + +result +_Bitmap::Construct(const _Bitmap& bitmap, const Rectangle& rect) +{ + result r = E_SYSTEM; + + int x = rect.x; + int y = rect.y; + int width = rect.width; + int height = rect.height; + + BufferInfo sourBI; + + if (const_cast<_Bitmap&>(bitmap).Lock(sourBI) == E_SUCCESS) + { + switch (bitmap.GetBitsPerPixel()) + { + case 16: + r = _CreateBitmapFromBufferInfo(this, sourBI, x, y, width, height); + break; + + case 32: + r = _CreateBitmapFromBufferInfo(this, sourBI, x, y, width, height); + break; + + default: + break; + } + + const_cast<_Bitmap&>(bitmap).Unlock(); + } + + this->__isOpaqueAllOver = _IsOpaqueAllOver(this); + + //?? need to make a versioning for BITMAP_PIXEL_FORMAT_B8G8R8A8 + this->__bitmapPixelFormat = (bitmap.GetBitsPerPixel() == 32) ? BITMAP_PIXEL_FORMAT_ARGB8888 : BITMAP_PIXEL_FORMAT_RGB565; + + return r; +} + +result +_Bitmap::Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat) +{ + int bytesPerPixel = 0; + + switch (pixelFormat) + { + case BITMAP_PIXEL_FORMAT_RGB565: + bytesPerPixel = 2; + break; + case BITMAP_PIXEL_FORMAT_ARGB8888: + case BITMAP_PIXEL_FORMAT_R8G8B8A8: + bytesPerPixel = 4; + break; + default: + return E_SYSTEM; + } + + // SysAssert(bytesPerPixel > 0); + + int width = dim.width; + int height = dim.height; + + { + size_t allocSize = width * height * bytesPerPixel; + + std::unique_ptr pAllocated(new (std::nothrow) unsigned char[allocSize]); + + SysTryReturnResult(NID_GRP, pAllocated, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The bitmap memory is insufficient"); + + result r = this->Construct((void*) pAllocated.get(), width, height, bytesPerPixel * 8); + + SysTryReturnResult(NID_GRP, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + memcpy(pAllocated.get(), buffer.GetPointer(), allocSize); + + this->__hasOwnership = true; + + this->__isOpaqueAllOver = _IsOpaqueAllOver(this); + + this->__bitmapPixelFormat = pixelFormat; + + pAllocated.release(); + + return r; + } +} + +result +_Bitmap::Construct(const byte* pBuffer, int bufSize, const Dimension& dim, BitmapPixelFormat pixelFormat) +{ + // already checks all parameters + + // BitmapInterfaceCreator bitmapInterface(pBuffer, bufSize, dim.width, dim.height, pixelFormat); + // result r = bitmapInterface.Result(); + // __pBitmapInterface = (r == E_SUCCESS) ? bitmapInterface.GetDuplicate() : null; + + int bytesPerPixel = 0; + + switch (pixelFormat) + { + case BITMAP_PIXEL_FORMAT_RGB565: + bytesPerPixel = 2; + break; + case BITMAP_PIXEL_FORMAT_ARGB8888: + case BITMAP_PIXEL_FORMAT_R8G8B8A8: + bytesPerPixel = 4; + break; + default: + return E_SYSTEM; + } + + // SysAssert(bytesPerPixel > 0); + + int width = dim.width; + int height = dim.height; + + { + result r = this->Construct((void*) pBuffer, width, height, bytesPerPixel * 8); + + if (r == E_SUCCESS) + { + __hasOwnership = true; + } + + this->__isOpaqueAllOver = _IsOpaqueAllOver(this); + + this->__bitmapPixelFormat = pixelFormat; + + return r; + } +} + +result +_Bitmap::Construct(const void* pExtBuffer, int width, int height, int bitsPerPixel) +{ + switch (bitsPerPixel) + { + case 16: + { + typedef unsigned short Pixel; + + __pScratchPad16 = new (std::nothrow) _Util::ScratchPad((Pixel*) pExtBuffer, width, height, width); + __pBuffer = (unsigned char*) pExtBuffer; + } + break; + case 32: + { + typedef unsigned long Pixel; + + __pScratchPad32 = new (std::nothrow) _Util::ScratchPad((Pixel*) pExtBuffer, width, height, width); + __pBuffer = (unsigned char*) pExtBuffer; + } + break; + default: + return E_SYSTEM; + } + + SysTryReturnResult(NID_GRP, __pScratchPad16 || __pScratchPad32, E_OUT_OF_MEMORY, "The memory is insufficient"); + + this->__hasOwnership = false; + this->__isOpaqueAllOver = true; + + this->__bitmapPixelFormat = (bitsPerPixel == 32) ? BITMAP_PIXEL_FORMAT_ARGB8888 : BITMAP_PIXEL_FORMAT_RGB565; + + return E_SUCCESS; +} + +bool +_Bitmap::IsValid(void) const +{ + return (__pScratchPad16 || __pScratchPad32); +} + +void +_Bitmap::_SetOwnership(bool ownership) +{ + this->__hasOwnership = ownership; +} + +void +_Bitmap::_ChangeBuffer(bool ownership, unsigned char* pBuffer) +{ + if (this->__hasOwnership) + { + delete[] this->__pBuffer; + } + + this->__hasOwnership = ownership; + this->__pBuffer = pBuffer; +} + +result +_Bitmap::Scale(const Dimension& dim) +{ + SysTryReturnResult(NID_GRP, this->IsValid(), E_OPERATION_FAILED, "This instance is not constructed yet.\n"); + + SysTryReturnResult(NID_GRP, dim.width > 0 && dim.height > 0, E_OUT_OF_RANGE, "Both of width(%d) and height(%d) MUST be greater than 0.\n", dim.width, dim.height); + + switch (this->__scalingQuality) + { + case BITMAP_SCALING_QUALITY_MID: + case BITMAP_SCALING_QUALITY_HIGH: + return this->__ScaleEx(dim.width, dim.height, this->__scalingQuality); + default: + return this->__Scale(dim.width, dim.height); + } +} + +result +_Bitmap::ScaleEx(const Dimension& dim, BitmapScalingQuality quality) +{ + SysTryReturnResult(NID_GRP, this->IsValid(), E_OPERATION_FAILED, "This instance is not constructed yet.\n"); + + SysTryReturnResult(NID_GRP, dim.width > 0 && dim.height > 0, E_OUT_OF_RANGE, "Both of width(%d) and height(%d) MUST be greater than 0.\n", dim.width, dim.height); + + switch (quality) + { + case BITMAP_SCALING_QUALITY_HIGH: + case BITMAP_SCALING_QUALITY_MID: + return this->__ScaleEx(dim.width, dim.height, quality); + case BITMAP_SCALING_QUALITY_LOW: + default: + return this->__Scale(dim.width, dim.height); + } +} + +result +_Bitmap::Merge(const Point& dest, const _Bitmap& src, const Rectangle& srcRect) +{ + // check arg. + SysTryReturnResult(NID_GRP, this->IsValid(), E_OPERATION_FAILED, "This instance is not constructed yet.\n"); + + if ((srcRect.width == 0) || (srcRect.height == 0)) + { + return E_SUCCESS; + } + + Rectangle rtBitmap(0, 0, src.GetWidth(), src.GetHeight()); + + if (!_CheckValidity(srcRect, rtBitmap)) + { + return E_SUCCESS; + } + + // TODO, shkim, I'm not sure why it's E_OUT_OF_RANGE? + // TryReturnI(NID_GRP, srcRect.x >= 0 && srcRect.y >= 0, E_OUT_OF_RANGE, "the argument is out of range.\n"); + + SysTryReturnResult(NID_GRP, src.IsValid(), E_INVALID_ARG, "The specified source bitmap is invalid.\n"); + + result r = this->__Merge(dest.x, dest.y, src, srcRect.x, srcRect.y, srcRect.width, srcRect.height); + + if (this->__isOpaqueAllOver != src.__isOpaqueAllOver) + { + this->__isOpaqueAllOver = _IsOpaqueAllOver(this, &_Bitmap::__Lock, &_Bitmap::__Unlock); + } + + return r; +} + +int +_Bitmap::GetHeight() const +{ + SysTryReturn(NID_GRP, this->IsValid(), -1, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + if (__pScratchPad16) + { + return __pScratchPad16->GetHeight(); + } + else + { + return __pScratchPad32->GetHeight(); + } +} + +int +_Bitmap::GetWidth() const +{ + SysTryReturn(NID_GRP, this->IsValid(), -1, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + if (__pScratchPad16) + { + return __pScratchPad16->GetWidth(); + } + else + { + return __pScratchPad32->GetWidth(); + } +} + +int +_Bitmap::GetBitsPerPixel() const +{ + SysTryReturn(NID_GRP, this->IsValid(), -1, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + if (__pScratchPad16) + { + return 16; + } + else + { + return 32; + } +} + +BitmapPixelFormat +_Bitmap::GetPixelColorFormat() const +{ + SysTryReturn(NID_GRP, this->IsValid(), BITMAP_PIXEL_FORMAT_MAX, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + return this->__bitmapPixelFormat; +} + +result +_Bitmap::SetMaskingColor(const Color* pColor) +{ + SysTryReturnResult(NID_GRP, this->IsValid(), E_OPERATION_FAILED, "This instance is not constructed yet.\n"); + SysTryReturnResult(NID_GRP, this->GetPixelColorFormat() == BITMAP_PIXEL_FORMAT_RGB565, E_INVALID_ARG, "Only BitmapPixelFormat::BITMAP_PIXEL_FORMAT_RGB565 is supported\n"); + + if (pColor) + { + __hasMaskingColor = true; + __maskingColor = pColor->GetRGB32(); + } + else + { + __hasMaskingColor = false; + __maskingColor = 0; + } + + return E_SUCCESS; +} + +result +_Bitmap::GetMaskingColor(Color& color) const +{ + SysTryReturnResult(NID_GRP, this->IsValid(), E_OPERATION_FAILED, "This instance is not constructed yet.\n"); + SysTryReturnResult(NID_GRP, this->GetPixelColorFormat() == BITMAP_PIXEL_FORMAT_RGB565, E_INVALID_DATA, "Only BitmapPixelFormat::BITMAP_PIXEL_FORMAT_RGB565 is supported\n"); + + if (!__hasMaskingColor) + { + return E_INVALID_DATA; + } + + color = Color(__maskingColor); + + return E_SUCCESS; +} + +void +_Bitmap::SetAlphaConstant(int opacity) +{ + if (opacity < 0) + { + opacity = 0; + } + + if (opacity > 255) + { + opacity = 255; + } + + this->__opacity = opacity; +} + +int +_Bitmap::GetAlphaConstant(void) const +{ + return this->__opacity; +} + +void +_Bitmap::SetScalingQuality(BitmapScalingQuality quality) +{ + switch (quality) + { + case BITMAP_SCALING_QUALITY_LOW: + case BITMAP_SCALING_QUALITY_MID: + case BITMAP_SCALING_QUALITY_HIGH: + this->__scalingQuality = quality; + break; + default: + break; + } +} + +BitmapScalingQuality +_Bitmap::GetScalingQuality(void) const +{ + return this->__scalingQuality; +} + +bool +_Bitmap::IsNinePatchedBitmap(void) const +{ + SysTryReturn(NID_GRP, this->IsValid(), false, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + BufferInfo dstBufferInfo; + bool ret = false; + + if (const_cast<_Bitmap*>(this)->Lock(dstBufferInfo) == E_SUCCESS) + { + const Tizen::Graphics::_Util::Pixmap dstImage(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + ret = Tizen::Graphics::_Effect::IsNinePatchedBitmap(dstImage); + + const_cast<_Bitmap*>(this)->Unlock(); + } + + return ret; +} + +result +_Bitmap::Lock(BufferInfo& info, long timeout) +{ + SysTryReturnResult(NID_GRP, this->IsValid(), E_OPERATION_FAILED, "This instance is not constructed yet.\n"); + + if (this->__pLockCallbackFunc) + { + this->__pLockCallbackFunc(this->__pLockCallbackParam); + } + + return this->__Lock(info, timeout); +} + +result +_Bitmap::Unlock() +{ + SysTryReturnResult(NID_GRP, this->IsValid(), E_OPERATION_FAILED, "This instance is not constructed yet.\n"); + + result r = this->__Unlock(); + + this->__isOpaqueAllOver = _IsOpaqueAllOver(this, &_Bitmap::__Lock, &_Bitmap::__Unlock); + + if (this->__pUnlockCallbackFunc) + { + this->__pUnlockCallbackFunc(this->__pUnlockCallbackParam); + } + + return r; +} + +result +_Bitmap::LockFast(BufferInfo& info, long timeout) +{ + SysTryReturnResult(NID_GRP, this->IsValid(), E_OPERATION_FAILED, "This instance is not constructed yet.\n"); + + if (this->__pLockCallbackFunc) + { + this->__pLockCallbackFunc(this->__pLockCallbackParam); + } + + return this->__Lock(info, timeout); +} + +result +_Bitmap::UnlockFast() +{ + SysTryReturnResult(NID_GRP, this->IsValid(), E_OPERATION_FAILED, "This instance is not constructed yet.\n"); + + result r = this->__Unlock(); + + if (this->__pUnlockCallbackFunc) + { + this->__pUnlockCallbackFunc(this->__pUnlockCallbackParam); + } + + return r; +} + +void +_Bitmap::UpdateOpaqueInfo(void) +{ + if (this->IsValid()) + { + this->__isOpaqueAllOver = _IsOpaqueAllOver(this, &_Bitmap::__Lock, &_Bitmap::__Unlock); + } +} + +void +_Bitmap::SetTimeStamp(unsigned long timeStamp) +{ + __timeStamp = timeStamp; +} + +int +_Bitmap::GetTimeStamp(void) const +{ + return __timeStamp; +} + +bool +_Bitmap::IsPremultiplied(void) const +{ + return __isPremultiplied; +} + +void +_Bitmap::AssignUserBuffer(unsigned char* pExtBuffer, int bytesPerLine) +{ + if (this->__pScratchPad32) + { + typedef unsigned long Pixel; + + _Util::ScratchPad* pBackupScratchPad32 = __pScratchPad32; + + __pScratchPad32 = new (std::nothrow) _Util::ScratchPad((Pixel*) pExtBuffer, pBackupScratchPad32->GetWidth(), pBackupScratchPad32->GetHeight(), bytesPerLine / sizeof(Pixel)); + + if (__pScratchPad32 == null) + { + __pScratchPad32 = pBackupScratchPad32; + return; + } + + delete pBackupScratchPad32; + + this->_ChangeBuffer(false, pExtBuffer); + } + else if (this->__pScratchPad16) + { + typedef unsigned short Pixel; + + _Util::ScratchPad* pBackupScratchPad16 = __pScratchPad16; + + __pScratchPad16 = new (std::nothrow) _Util::ScratchPad((Pixel*) pExtBuffer, pBackupScratchPad16->GetWidth(), pBackupScratchPad16->GetHeight(), bytesPerLine / sizeof(Pixel)); + + if (__pScratchPad16 == null) + { + __pScratchPad16 = pBackupScratchPad16; + return; + } + + delete pBackupScratchPad16; + + this->_ChangeBuffer(false, pExtBuffer); + } +} + +void +_Bitmap::SetCallback(void (* LockCallback)(void*), void* pLockCallbackParam, + void (* UnlockCallback)(void*), void* pUnlockCallbackParam) +{ + this->__pLockCallbackFunc = LockCallback; + this->__pLockCallbackParam = pLockCallbackParam; + + this->__pUnlockCallbackFunc = UnlockCallback; + this->__pUnlockCallbackParam = pUnlockCallbackParam; +} + +result +_Bitmap::__Scale(int width, int height) +{ + SysAssert(!(__pScratchPad16 == null && __pScratchPad32 == null)); + + if (__pScratchPad16) + { + return _Resize(this, __pScratchPad16, width, height); + } + else + { + //?? the alpha channel is applied twice in the 32-bit bitmap + return _Resize(this, __pScratchPad32, width, height); + } +} + +result +_Bitmap::__ScaleEx(int width, int height, BitmapScalingQuality quality) +{ + SysAssert(!(__pScratchPad16 == null && __pScratchPad32 == null)); + + if (__pScratchPad16) + { + return _Resize(this, __pScratchPad16, width, height, quality); + } + else + { + return _Resize(this, __pScratchPad32, width, height, quality); + } +} + +result +_Bitmap::__Merge(int destX, int destY, const _Bitmap& src, int srcX, int srcY, int srcWidth, int srcHeight) +{ + SysAssert(!(__pScratchPad16 == null && __pScratchPad32 == null)); + + const _Bitmap* pSrcBitmap = &src; + + if (pSrcBitmap == null) + { + return E_SYSTEM; + } + + if (pSrcBitmap->__pScratchPad16 == null && pSrcBitmap->__pScratchPad32 == null) + { + return E_SYSTEM; + } + + if (__pScratchPad16) + { + if (pSrcBitmap->__pScratchPad16) + { + __pScratchPad16->BitBlt(destX, destY, pSrcBitmap->__pScratchPad16, srcX, srcY, srcWidth, srcHeight); + + return E_SUCCESS; + } + else + { + return _MergeWithConversion(__pScratchPad16, destX, destY, pSrcBitmap->__pScratchPad32, srcX, srcY, srcWidth, srcHeight); + } + } + else + { + if (pSrcBitmap->__pScratchPad32) + { + __pScratchPad32->BitBlt(destX, destY, pSrcBitmap->__pScratchPad32, srcX, srcY, srcWidth, srcHeight); + + return E_SUCCESS; + } + else + { + return _MergeWithConversion(__pScratchPad32, destX, destY, pSrcBitmap->__pScratchPad16, srcX, srcY, srcWidth, srcHeight); + } + } +} + +result +_Bitmap::__Lock(BufferInfo& info, long timeout) +{ + SysAssert(!(__pScratchPad16 == null && __pScratchPad32 == null)); + + if (this->__pBuffer == null) + { + return E_SYSTEM; + } + + if (_BufferInfoImpl::GetInstance(info) != null) + { + _BufferInfoImpl::GetInstance(info)->SetHandle(_BufferInfoImpl::HANDLE_TYPE_NONE, 0); + } + + if (__pScratchPad16) + { + info.width = __pScratchPad16->GetWidth(); + info.height = __pScratchPad16->GetHeight(); + info.pitch = __pScratchPad16->GetWidth() * 2; + info.bitsPerPixel = 16; + info.pixelFormat = PIXEL_FORMAT_RGB565; + info.pPixels = (void*) this->__pBuffer; + //info.__handle = INVALID_HANDLE; + } + else + { + info.width = __pScratchPad32->GetWidth(); + info.height = __pScratchPad32->GetHeight(); + info.pitch = __pScratchPad32->GetWidth() * 4; + info.bitsPerPixel = 32; + info.pixelFormat = PIXEL_FORMAT_ARGB8888; + info.pPixels = (void*) this->__pBuffer; + //info.__handle = INVALID_HANDLE; + } + + return E_SUCCESS; +} + +result +_Bitmap::__Unlock(void) +{ + return E_SUCCESS; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_Bitmap.h b/src/graphics/FGrp_Bitmap.h new file mode 100644 index 0000000..6cd9277 --- /dev/null +++ b/src/graphics/FGrp_Bitmap.h @@ -0,0 +1,142 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Bitmap.h + * @brief This is the header file for _Bitmap class. + * + */ + +#ifndef _FGRP_INTERNAL_BITMAP_H_ +#define _FGRP_INTERNAL_BITMAP_H_ + +#include +#include + +#include "util/FGrp_UtilScratchpad.h" + + +namespace Tizen { namespace Graphics +{ +class Point; +class Dimension; +class Rectangle; +class Color; +class BufferInfo; + +class _Canvas; + +class _Bitmap +{ +public: + _Bitmap(void); + ~_Bitmap(void); + + result Construct(const Rectangle& rect); + result Construct(const Dimension& dim, BitmapPixelFormat format); + result Construct(const _Canvas& canvas, const Rectangle& rect); + result Construct(const _Bitmap& bitmap, const Rectangle& rect); + result Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat); + result Construct(const byte* pBuffer, int bufSize, const Dimension& rq_dim, BitmapPixelFormat pixelFormat); + result Construct(const void* pExtBuffer, int width, int height, int bitsPerPixel); + + bool IsValid(void) const; + + result Scale(const Dimension& dim); + result ScaleEx(const Dimension& dim, BitmapScalingQuality quality); + result Merge(const Point& destPoint, const _Bitmap& srcBitmap, const Rectangle& srcRect); + + int GetHeight(void) const; + int GetWidth(void) const; + int GetBitsPerPixel(void) const; + BitmapPixelFormat GetPixelColorFormat(void) const; + + result SetMaskingColor(const Color* pColor); + result GetMaskingColor(Color& color) const; + + void SetAlphaConstant(int opacity); + int GetAlphaConstant(void) const; + + void SetScalingQuality(BitmapScalingQuality quality); + BitmapScalingQuality GetScalingQuality(void) const; + + bool IsNinePatchedBitmap(void) const; + + result Lock(BufferInfo& info, long timeout = INFINITE); + result Unlock(void); + + result LockFast(BufferInfo& info, long timeout = INFINITE); + result UnlockFast(void); + + void UpdateOpaqueInfo(void); + + void SetTimeStamp(unsigned long timeStamp); + int GetTimeStamp(void) const; + + bool IsPremultiplied(void) const; + + // for the Pixmap only + void AssignUserBuffer(unsigned char* pBuffer, int bytesPerLine); + + void SetCallback(void (* LockCallback)(void*), void* pLockCallbackParam, + void (* UnlockCallback)(void*), void* pUnlockCallbackParam); + +protected: + void _SetOwnership(bool ownership); + void _ChangeBuffer(bool ownership, unsigned char* pBuffer); + +private: + _Bitmap(const _Bitmap& src); + _Bitmap& operator =(const _Bitmap& value); + + result __Scale(int width, int height); + result __ScaleEx(int width, int height, BitmapScalingQuality quality); + result __Merge(int destX, int destY, const _Bitmap& src, int srcX, int srcY, int srcWidth, int srcHeight); + + result __Lock(BufferInfo& info, long timeout = INFINITE); + result __Unlock(void); + +private: + unsigned long __timeStamp; + int __opacity; + long __isOpaqueAllOver; + + bool __hasOwnership; + unsigned char* __pBuffer; + bool __isPremultiplied; + bool __hasMaskingColor; + unsigned long __maskingColor; + + BitmapPixelFormat __bitmapPixelFormat; + BitmapScalingQuality __scalingQuality; + + _Util::ScratchPad * __pScratchPad32; + _Util::ScratchPad * __pScratchPad16; + + void (* __pLockCallbackFunc)(void*); + void* __pLockCallbackParam; + void (* __pUnlockCallbackFunc)(void*); + void* __pUnlockCallbackParam; + + friend class _Canvas; + friend class _BitmapImpl; + +}; // _Bitmap + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_BITMAP_H_ diff --git a/src/graphics/FGrp_BitmapCoordHolder.h b/src/graphics/FGrp_BitmapCoordHolder.h new file mode 100644 index 0000000..5764862 --- /dev/null +++ b/src/graphics/FGrp_BitmapCoordHolder.h @@ -0,0 +1,51 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_BitmapCoordHolder.h + * @brief This is the header file for _BitmapUtil namespace. + * + */ + +#ifndef _FGRP_INTERNAL_BITMAPCOORDHOLDER_H_ +#define _FGRP_INTERNAL_BITMAPCOORDHOLDER_H_ + + +#include "FGrp_ResUtil.h" + + +namespace Tizen { namespace Graphics +{ + +struct _BitmapCoordHolder +{ + _ResUtil::CoordHolder <_ResUtil::Rect> bitmapSize; + + void Init(_ResUtil::Rect area) + { + bitmapSize = area; + } + void Init(const Rectangle& rect) + { + _ResUtil::Rect area(rect.x, rect.y, rect.width, rect.height); + this->Init(area); + } +}; + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_BITMAPCOORDHOLDER_H_ diff --git a/src/graphics/FGrp_BitmapImpl.cpp b/src/graphics/FGrp_BitmapImpl.cpp new file mode 100644 index 0000000..3ad683e --- /dev/null +++ b/src/graphics/FGrp_BitmapImpl.cpp @@ -0,0 +1,1828 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_BitmapImpl.cpp + * @brief This is the implementation file for _BitmapImpl class. + * + */ + +#include +#include +#include + +#include +#include + +#include + +#include + +#include "FGrp_BitmapImpl.h" +#include "FGrp_BitmapUtil.h" +#include "FGrp_BitmapCoordHolder.h" +#include "FGrp_Bitmap.h" +#include "FGrp_Canvas.h" +#include "FGrp_NonScale.h" +#include "FGrp_ResUtil.h" +#include "util/FGrp_Util.h" +#include "effect/FGrp_Effect.h" +#include "effect/FGrp_EffectFunc.h" + +using namespace Tizen::Base; + +#define INSTANCE_IS_VALID (this && const_cast<_BitmapImpl*>(this)->__CheckValidity()) +#define BITMAPIMPL_IS_VALID(pBitmapImpl) (pBitmapImpl && const_cast<_BitmapImpl*>(pBitmapImpl)->__CheckValidity(true)) +#define IS_BITMAPIMPL_VALID(pBitmapImpl) (pBitmapImpl && const_cast<_BitmapImpl*>(pBitmapImpl)->__CheckValidity(false)) + + +namespace // unnamed +{ + +bool +_CheckValidityOfRectangle(const Tizen::Graphics::Rectangle& rect) +{ + return ((rect.width > 0) && (rect.height > 0)); +} + +bool +_CheckValidity(const Tizen::Graphics::Rectangle& rtSrc, const Tizen::Graphics::Rectangle& rtDest) +{ + // check 1. is width/height less or equal than 0? + if (rtSrc.width <= 0 || rtSrc.height <= 0 || rtDest.width <= 0 || rtDest.height <= 0) + { + return false; // "[E_OUT_OF_RANGE] The argument is out of range. (src(w:%d,h:%d), dst(w:%d,h:%d))", rtSrc.width, rtSrc.height, rtDest.width, rtDest.height); + } + + // check 2. is src exiting outside of dest entirely? + if (rtSrc.x > rtDest.x + rtDest.width - 1 || rtSrc.x + rtSrc.width - 1 < rtDest.x) + { + return false; // "[E_OUT_OF_RANGE] The argument is out of range. (src(x:%d,y:%d,w:%d,h:%d), dst(x:%d,y:%d,w:%d,h:%d))", rtSrc.x, rtSrc.y, rtSrc.width, rtSrc.height, rtDest.x, rtDest.y, rtDest.width, rtDest.height); + } + + if (rtSrc.y > rtDest.y + rtDest.height - 1 || rtSrc.y + rtSrc.height - 1 < rtDest.y) + { + return false; // "[E_OUT_OF_RANGE] The argument is out of range. (src(x:%d,y:%d,w:%d,h:%d), dst(x:%d,y:%d,w:%d,h:%d))", rtSrc.x, rtSrc.y, rtSrc.width, rtSrc.height, rtDest.x, rtDest.y, rtDest.width, rtDest.height); + } + + return true; +} + +int +_GetBytesPerPixel(Tizen::Graphics::BitmapPixelFormat pixelFormat) +{ + if (pixelFormat == Tizen::Graphics::BITMAP_PIXEL_FORMAT_RGB565) + { + return 2; + } + else if (pixelFormat == Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888 || pixelFormat == Tizen::Graphics::BITMAP_PIXEL_FORMAT_R8G8B8A8) + { + return 4; + } + else + { + return 0; + } +} + +result +_CheckBufferSize(const Tizen::Base::ByteBuffer& buffer, const Tizen::Graphics::Dimension& dim, Tizen::Graphics::BitmapPixelFormat pixelFormat) +{ + int bytePerPixel = _GetBytesPerPixel(pixelFormat); + + if (bytePerPixel == 0) + { + SysTryReturnResult(NID_GRP, 0, E_INVALID_ARG, "BitmapPixelFormat(%d) is the invalid argument.", pixelFormat); + } + + int byteNum = buffer.GetLimit(); + int expectedBufferSize = dim.width * dim.height * bytePerPixel; + + SysTryReturnResult(NID_GRP, expectedBufferSize <= byteNum, E_INVALID_ARG, "A buffer size is not correct. (expected: %d, actual: %d)", expectedBufferSize, byteNum); + + return E_SUCCESS; +} + +bool +_ScaleBuffer(const Tizen::Base::ByteBuffer& destBuffer, const Tizen::Graphics::Dimension& destSize, const Tizen::Base::ByteBuffer& sourBuffer, const Tizen::Graphics::Dimension& sourSize, Tizen::Graphics::BitmapPixelFormat pixelFormat) +{ + switch (pixelFormat) + { + case Tizen::Graphics::BITMAP_PIXEL_FORMAT_RGB565: + { + Tizen::Graphics::_Util::Pixmap dstImage(destSize.width, destSize.height, 16, (void*) destBuffer.GetPointer()); + Tizen::Graphics::_Util::Pixmap srcImage(sourSize.width, sourSize.height, 16, (void*) sourBuffer.GetPointer()); + return Tizen::Graphics::_Effect::ScaleImage(dstImage, 0, 0, destSize.width, destSize.height, srcImage); + } + case Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888: + { + Tizen::Graphics::_Util::Pixmap dstImage(destSize.width, destSize.height, 32, (void*) destBuffer.GetPointer()); + Tizen::Graphics::_Util::Pixmap srcImage(sourSize.width, sourSize.height, 32, (void*) sourBuffer.GetPointer()); + return Tizen::Graphics::_Effect::ScaleImage(dstImage, 0, 0, destSize.width, destSize.height, srcImage); + } + case Tizen::Graphics::BITMAP_PIXEL_FORMAT_R8G8B8A8: + return false; + default: + return false; + } +} + +bool +_UpdateScaledBitmapEx(Tizen::Graphics::_Bitmap* pSrcBitmap, Tizen::Graphics::_Bitmap* pDstBitmap) +{ + if (!(pSrcBitmap && pDstBitmap && pSrcBitmap->GetPixelColorFormat() == pDstBitmap->GetPixelColorFormat())) + { + return false; + } + + Tizen::Graphics::BufferInfo srcBufferInfo; + Tizen::Graphics::BufferInfo dstBufferInfo; + + { + if (pSrcBitmap->Lock(srcBufferInfo) != E_SUCCESS) + { + return false; + } + + result r = pDstBitmap->Lock(dstBufferInfo); + if (r != E_SUCCESS) + { + pSrcBitmap->Unlock(); + return false; + } + } + + bool ret = false; + + do + { + switch (pSrcBitmap->GetPixelColorFormat()) + { + case Tizen::Graphics::BITMAP_PIXEL_FORMAT_RGB565: + { + Tizen::Graphics::_Util::Pixmap dstImage(dstBufferInfo.width, dstBufferInfo.height, 16, (void*) dstBufferInfo.pPixels); + Tizen::Graphics::_Util::Pixmap srcImage(srcBufferInfo.width, srcBufferInfo.height, 16, (void*) srcBufferInfo.pPixels); + ret = Tizen::Graphics::_Effect::ScaleImage(dstImage, 0, 0, dstBufferInfo.width, dstBufferInfo.height, srcImage); + } + break; + + case Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888: + { + Tizen::Graphics::_Util::Pixmap dstImage(dstBufferInfo.width, dstBufferInfo.height, 32, (void*) dstBufferInfo.pPixels); + Tizen::Graphics::_Util::Pixmap srcImage(srcBufferInfo.width, srcBufferInfo.height, 32, (void*) srcBufferInfo.pPixels); + ret = Tizen::Graphics::_Effect::ScaleImage(dstImage, 0, 0, dstBufferInfo.width, dstBufferInfo.height, srcImage); + } + break; + + case Tizen::Graphics::BITMAP_PIXEL_FORMAT_R8G8B8A8: + default: + break; + } + } + while (0); + + pSrcBitmap->Unlock(); + pDstBitmap->Unlock(); + + return ret; +} + +//////////////////////////////////////////////////////////////////////////////// + +unsigned long +_UpdateBitmapTimeStampInternal(void) +{ + static unsigned long staticTimeStamp = 0; + + ++staticTimeStamp; + + staticTimeStamp = (staticTimeStamp == 0) ? (staticTimeStamp + 1) : staticTimeStamp; + + return staticTimeStamp; +} + +} + +//////////////////////////////////////////////////////////////////////////////// + +namespace Tizen { namespace Graphics +{ + +unsigned long +_GetBitmapTimeStamp(const Tizen::Graphics::_BitmapImpl& bitmap) +{ + Tizen::Graphics::_Bitmap* _nativeBitmap = Tizen::Graphics::GetBitmapEx(bitmap); + + return (_nativeBitmap) ? _nativeBitmap->GetTimeStamp() : 0; +} + +unsigned long +_UpdateBitmapTimeStamp(Tizen::Graphics::_BitmapImpl& bitmap) +{ + Tizen::Graphics::_Bitmap* _nativeBitmap = Tizen::Graphics::GetBitmapEx(bitmap); + + if (_nativeBitmap) + { + _nativeBitmap->SetTimeStamp(_UpdateBitmapTimeStampInternal()); + return _nativeBitmap->GetTimeStamp(); + } + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// + +_BitmapImpl::_BitmapImpl(void) +: _sharedItem(std::tr1::shared_ptr<_SharedItem>(new (std::nothrow)_SharedItem)) +{ + if (this->_sharedItem.get()) + { + this->_sharedItem->nativeBitmap.reset(new (std::nothrow) _Bitmap); + this->_sharedItem->coordHolder.reset(new (std::nothrow) _BitmapCoordHolder); + this->_sharedItem->lazyScaling = 0; + this->_sharedItem->scaledNativeBitmap.reset(null); + this->_sharedItem->pDestroyCallbackFunc = null; + this->_sharedItem->pDestroyCallbackParam = null; + this->_sharedItem->pLockCallbackFunc = null; + this->_sharedItem->pLockCallbackParam = null; + this->_sharedItem->pUnlockCallbackFunc = null; + this->_sharedItem->pUnlockCallbackParam = null; + this->_sharedItem->isMutable = true; + this->_sharedItem->associated.pixelFormat = BITMAP_PIXEL_FORMAT_ARGB8888; + + if (this->_sharedItem->nativeBitmap.get() == null || this->_sharedItem->coordHolder.get() == null) + { + this->_sharedItem->nativeBitmap.reset(); + this->_sharedItem->coordHolder.reset(); + this->_sharedItem.reset(); + + return; + } + } + + _UpdateBitmapTimeStamp(*this); +} + +_BitmapImpl::~_BitmapImpl(void) +{ + if (this->_sharedItem.get()) + { + if (this->_sharedItem->pDestroyCallbackFunc) + { + if (this->_sharedItem.unique()) + { + this->_sharedItem->pDestroyCallbackFunc(this->_sharedItem->pDestroyCallbackParam); + } + } + } +} + +bool +_BitmapImpl::IsConstructed(void) const +{ + return (this->_sharedItem.get() && (this->_sharedItem->nativeBitmap->IsValid() || !this->_sharedItem->associated.fileName.IsEmpty())); +} + +result +_BitmapImpl::Construct(const Rectangle& vc_rect) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_sharedItem.get(), E_OUT_OF_MEMORY, "Fails to allocate memory."); + + SysTryReturnResult(NID_GRP, _CheckValidityOfRectangle(vc_rect), E_INVALID_ARG, "Both of width(%d) and height(%d) of 'rect' MUST be greater than 0.", vc_rect.width, vc_rect.height); + + SysTryReturnResult(NID_GRP, vc_rect.x >= 0 && vc_rect.y >= 0, E_OUT_OF_RANGE, "The argument is out of range. (rect(x:%d,y:%d,w:%d,h:%d)).", vc_rect.x, vc_rect.y, vc_rect.width, vc_rect.height); + + if (_ResUtil::NeedToConvertCoord()) + { + Rectangle pc_rect = _ResUtil::ConvertToPhyCoord(vc_rect); + + // special case + pc_rect.width = (pc_rect.width > 0) ? pc_rect.width : 1; + pc_rect.height = (pc_rect.height > 0) ? pc_rect.height : 1; + + result r = this->_sharedItem->nativeBitmap->Construct(pc_rect); + + if (!IsFailed(r)) + { + this->_sharedItem->coordHolder->Init(vc_rect); + this->_sharedItem->coordHolder->bitmapSize.phyCoord.w = pc_rect.width; + this->_sharedItem->coordHolder->bitmapSize.phyCoord.h = pc_rect.height; + } + + return r; + } + else + { + return this->_sharedItem->nativeBitmap->Construct(vc_rect); + } +} + +result +_BitmapImpl::Construct(const Dimension& vc_dim, BitmapPixelFormat pixelFormat) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_sharedItem.get(), E_OUT_OF_MEMORY, "Fails to allocate memory."); + + // check arg. + SysTryReturnResult(NID_GRP, vc_dim.width > 0 && vc_dim.height > 0, E_INVALID_ARG, "Both of width(%d) and height(%d) of 'dim' MUST be greater than 0.", vc_dim.width, vc_dim.height); + + int size = vc_dim.width * vc_dim.height; + + switch (pixelFormat) + { + case BITMAP_PIXEL_FORMAT_RGB565: + size *= sizeof(unsigned short); + break; + case BITMAP_PIXEL_FORMAT_ARGB8888: + case BITMAP_PIXEL_FORMAT_R8G8B8A8: + size *= sizeof(unsigned long); + break; + default: + SysTryReturnResult(NID_GRP, 0, E_INVALID_ARG, "BitmapPixelFormat(%d) is invalid argument.", pixelFormat); + break; + } + + if (_ResUtil::NeedToConvertCoord()) + { + Dimension pc_dim = _ResUtil::ConvertToPhyCoord(vc_dim); + + // special case + pc_dim.width = (pc_dim.width > 0) ? pc_dim.width : 1; + pc_dim.height = (pc_dim.height > 0) ? pc_dim.height : 1; + + result r = this->_sharedItem->nativeBitmap->Construct(pc_dim, pixelFormat); + + if (!IsFailed(r)) + { + _ResUtil::Rect vc_rect(0, 0, vc_dim.width, vc_dim.height); + + this->_sharedItem->coordHolder->Init(vc_rect); + this->_sharedItem->coordHolder->bitmapSize.phyCoord.w = pc_dim.width; + this->_sharedItem->coordHolder->bitmapSize.phyCoord.h = pc_dim.height; + } + + return r; + } + else + { + return this->_sharedItem->nativeBitmap->Construct(vc_dim, pixelFormat); + } +} + +result +_BitmapImpl::Construct(const _CanvasImpl& canvas, const Rectangle& vc_rect) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_sharedItem.get(), E_OUT_OF_MEMORY, "Fails to allocate memory."); + + SysTryReturnResult(NID_GRP, &canvas, E_INVALID_ARG, "A canvas is invalid."); + SysTryReturnResult(NID_GRP, canvas._pNativeCanvas && canvas._pNativeCanvas->IsValid(), E_INVALID_ARG, "A canvas is invalid."); + + Rectangle rtCanvas = canvas.GetBounds(); + + SysTryReturnResult(NID_GRP, !rtCanvas.IsEmpty(), E_INVALID_ARG, "A canvas is empty."); + + SysTryReturnResult(NID_GRP, _CheckValidityOfRectangle(vc_rect), E_INVALID_ARG, "Both of width(%d) and height(%d) of 'rect' MUST be greater than 0.", vc_rect.width, vc_rect.height); + + SysTryReturnResult(NID_GRP, _CheckValidity(vc_rect, rtCanvas), E_OUT_OF_RANGE, "The argument is out of range. (rect(x:%d,y:%d,w:%d,h:%d)).", vc_rect.x, vc_rect.y, vc_rect.width, vc_rect.height); + + Tizen::Graphics::_Canvas* pCanvasEx = canvas._pNativeCanvas; + + if (_ResUtil::NeedToConvertCoord()) + { + Rectangle pc_rect = _ResUtil::ConvertToPhyCoord(vc_rect); + + // special case (kiniirana) + pc_rect.width = (pc_rect.width > 0) ? pc_rect.width : 1; + pc_rect.height = (pc_rect.height > 0) ? pc_rect.height : 1; + + result r = this->_sharedItem->nativeBitmap->Construct(*pCanvasEx, pc_rect); + + if (!IsFailed(r)) + { + this->_sharedItem->coordHolder->Init(vc_rect); + } + + return r; + } + else + { + return this->_sharedItem->nativeBitmap->Construct(*pCanvasEx, vc_rect); + } +} + +result +_BitmapImpl::Construct(const _BitmapImpl& bitmap, const Rectangle& vc_rect) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_sharedItem.get(), E_OUT_OF_MEMORY, "Fails to allocate memory."); + + SysTryReturnResult(NID_GRP, BITMAPIMPL_IS_VALID(&bitmap), E_INVALID_ARG, "The source bitmap is invalid."); + + Rectangle rtBitmap(0, 0, bitmap.GetWidth(), bitmap.GetHeight()); + + SysTryReturnResult(NID_GRP, _CheckValidityOfRectangle(vc_rect), E_INVALID_ARG, "Both of width(%d) and height(%d) of 'rect' MUST be greater than 0.", vc_rect.width, vc_rect.height); + + SysTryReturnResult(NID_GRP, _CheckValidity(vc_rect, rtBitmap), E_OUT_OF_RANGE, "The argument is out of range. (rect(x:%d,y:%d,w:%d,h:%d)).", vc_rect.x, vc_rect.y, vc_rect.width, vc_rect.height); + + _Bitmap* pSrcBitmapEx = Tizen::Graphics::GetBitmapEx(bitmap); + + if (_ResUtil::NeedToConvertCoord()) + { + result r = E_SUCCESS; + Rectangle pc_rect = _ResUtil::ConvertToPhyCoord(vc_rect); + + // special case + pc_rect.width = (pc_rect.width > 0) ? pc_rect.width : 1; + pc_rect.height = (pc_rect.height > 0) ? pc_rect.height : 1; + + if (Tizen::Graphics::IsLazyScalingBitmap(bitmap)) + { + _Bitmap* pSrcScaledBitmapEx = Tizen::Graphics::GetScaledBitmapEx(bitmap); + + r = this->_sharedItem->nativeBitmap->Construct(*pSrcScaledBitmapEx, pc_rect); + } + else + { + r = this->_sharedItem->nativeBitmap->Construct(*pSrcBitmapEx, pc_rect); + } + + if (!IsFailed(r)) + { + this->_sharedItem->coordHolder->Init(vc_rect); + } + + return r; + } + else + { + return this->_sharedItem->nativeBitmap->Construct(*pSrcBitmapEx, vc_rect); + } +} + +result +_BitmapImpl::Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& rq_dim, BitmapPixelFormat pixelFormat) +{ +#if 1 + return this->Construct(buffer, rq_dim, pixelFormat, true); +#else +// return this->Construct(buffer, rq_dim, pixelFormat, BUFFER_SCALING_AUTO); +// return this->Construct(buffer, rq_dim, pixelFormat, BUFFER_SCALING_NONE); + + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, __pImpl && this->_nativeBitmap, E_OUT_OF_MEMORY, "Fails to allocate memory."); + + SysTryReturnResult(NID_GRP, rq_dim.width > 0 && rq_dim.height > 0, E_INVALID_ARG, "Both of width(%d) and height(%d) of a dimension MUST be greater than 0.", rq_dim.width, rq_dim.height); + + SysTryReturnResult(NID_GRP, BITMAP_PIXEL_FORMAT_MIN < pixelFormat && pixelFormat < BITMAP_PIXEL_FORMAT_MAX, E_INVALID_ARG, "BitmapPixelFormat(%d) is the invalid argument.", pixelFormat); + + { + // buffer size should be verified. + int bytePerPixel = 0; + if (BITMAP_PIXEL_FORMAT_RGB565 == pixelFormat) + { + bytePerPixel = 2; + } + else if (BITMAP_PIXEL_FORMAT_ARGB8888 == pixelFormat || BITMAP_PIXEL_FORMAT_R8G8B8A8 == pixelFormat) + { + bytePerPixel = 4; + } + else + { + SysTryReturnResult(NID_GRP, 0, E_INVALID_ARG, "BitmapPixelFormat(%d) is the invalid argument.", pixelFormat); + } + + int byteNum = buffer.GetLimit(); + int expectedBufferSize = rq_dim.width * rq_dim.height * bytePerPixel; + + SysTryReturnResult(NID_GRP, expectedBufferSize <= byteNum, E_INVALID_ARG, "A buffer size is not correct."); + } + + if (_ResUtil::NeedToConvertCoord()) + { + Dimension vc_dim; + Dimension pc_dim; + + vc_dim = rq_dim; + pc_dim = _ResUtil::ConvertToPhyCoord(vc_dim); + + // special case + pc_dim.width = (pc_dim.width > 0) ? pc_dim.width : 1; + pc_dim.height = (pc_dim.height > 0) ? pc_dim.height : 1; + + if (pc_dim.width * 2 == rq_dim.width && pc_dim.height * 2 == rq_dim.height) + { + int pitch = rq_dim.width; + + if (pixelFormat == BITMAP_PIXEL_FORMAT_ARGB8888) + { + const unsigned long MASK = 0x00FF00FF; + + unsigned long* pBuffer = (unsigned long*) buffer.GetPointer(); + for (int y = 0; y < pc_dim.height; y++) + { + for (int x = 0; x < pc_dim.width; x++) + { + unsigned long add1 = (pBuffer[0] & MASK) + (pBuffer[1] & MASK) + (pBuffer[pitch] & MASK) + (pBuffer[pitch + 1] & MASK); + unsigned long add2 = ((pBuffer[0] >> 8) & MASK) + ((pBuffer[1] >> 8) & MASK) + ((pBuffer[pitch] >> 8) & MASK) + ((pBuffer[pitch + 1] >> 8) & MASK); + + unsigned long pix = ((add1 >> 2) & MASK) | (((add2 >> 2) & MASK) << 8); + + pBuffer[0] = pix; + pBuffer[1] = pix; + pBuffer[pitch] = pix; + pBuffer[pitch + 1] = pix; + + pBuffer += 2; + } + pBuffer += pitch; + } + } + else if (pixelFormat == BITMAP_PIXEL_FORMAT_RGB565) + { + const unsigned short MASK1 = 0xF81F; + const unsigned short MASK2 = 0x07E0; + const unsigned short CHROMAKEY = 0xF81F | 0x0020; + + bool hasChromakey; + { + unsigned short* pBuffer = (unsigned short*) buffer.GetPointer(); + unsigned short* pBufferEnd = pBuffer + rq_dim.width * rq_dim.height; + + while (pBuffer < pBufferEnd) + { + if (*pBuffer == CHROMAKEY) + { + break; + } + + ++pBuffer; + } + + hasChromakey = (pBuffer < pBufferEnd); + } + + if (hasChromakey) + { + ; // pass through default scaling algorithm + } + else + { + unsigned short* pBuffer = (unsigned short*) buffer.GetPointer(); + + for (int y = 0; y < pc_dim.height; y++) + { + for (int x = 0; x < pc_dim.width; x++) + { + unsigned long add1 = (unsigned long) (pBuffer[0] & MASK1) + (unsigned long) (pBuffer[1] & MASK1) + (unsigned long) (pBuffer[pitch] & MASK1) + (unsigned long) (pBuffer[pitch + 1] & MASK1); + unsigned long add2 = (pBuffer[0] & MASK2) + (pBuffer[1] & MASK2) + (pBuffer[pitch] & MASK2) + (pBuffer[pitch + 1] & MASK2); + + unsigned long pix = ((add1 >> 2) & MASK1) | ((add2 >> 2) & MASK2); + + pBuffer[0] = pix; + pBuffer[1] = pix; + pBuffer[pitch] = pix; + pBuffer[pitch + 1] = pix; + + pBuffer += 2; + } + pBuffer += pitch; + } + } + } + } + + result r = this->_nativeBitmap->Construct(buffer, rq_dim, pixelFormat); + + if (!IsFailed(r)) + { + this->_nativeBitmap->Scale(pc_dim); + + Rect vc_rect(0, 0, vc_dim.width, vc_dim.height); + Rect pc_rect(0, 0, pc_dim.width, pc_dim.height); + + this->_coordHolder->bitmapSize.required = vc_rect; + this->_coordHolder->bitmapSize.phyCoord = pc_rect; + this->_coordHolder->bitmapSize.virCoord = vc_rect; + } + + return r; + } + else + { + return this->_nativeBitmap->Construct(buffer, rq_dim, pixelFormat); + } + +#endif +} + +result +_BitmapImpl::Construct(const BufferInfo& bufferInfo) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_sharedItem.get(), E_OUT_OF_MEMORY, "Fails to allocate memory."); + + SysTryReturnResult(NID_GRP, (bufferInfo.width > 0) && (bufferInfo.height > 0) && (bufferInfo.pitch > 0) + , E_INVALID_ARG + , "Invalid argument (BufferInfo::width = %d, BufferInfo::height = %d, BufferInfo::pitch = %d)" + , bufferInfo.width, bufferInfo.height, bufferInfo.pitch); + + SysTryReturnResult(NID_GRP, bufferInfo.bitsPerPixel > 0 + , E_INVALID_ARG + , "Invalid argument (BufferInfo::bitsPerPixel = %d)" + , bufferInfo.bitsPerPixel); + + SysTryReturnResult(NID_GRP, (bufferInfo.pixelFormat > PIXEL_FORMAT_MIN) && (bufferInfo.pixelFormat < PIXEL_FORMAT_MAX) + , E_INVALID_ARG + , "Invalid argument (BufferInfo::pixelFormat = %d)" + , bufferInfo.pixelFormat); + + SysTryReturnResult(NID_GRP, bufferInfo.pPixels != null + , E_INVALID_ARG + , "Invalid argument (BufferInfo::pPixels = null)"); + + SysTryReturnResult(NID_GRP, bufferInfo.bitsPerPixel == 32 || bufferInfo.bitsPerPixel == 16 + , E_UNSUPPORTED_FORMAT + , "Unsupported format (BufferInfo::bitsPerPixel = %d)" + , bufferInfo.bitsPerPixel); + + BitmapPixelFormat bitmapPixelFormat = BITMAP_PIXEL_FORMAT_MIN; + + switch (bufferInfo.pixelFormat) + { + case PIXEL_FORMAT_RGB565: + bitmapPixelFormat = BITMAP_PIXEL_FORMAT_RGB565; + break; + case PIXEL_FORMAT_ARGB8888: + bitmapPixelFormat = BITMAP_PIXEL_FORMAT_ARGB8888; + break; + case PIXEL_FORMAT_R8G8B8A8: + bitmapPixelFormat = BITMAP_PIXEL_FORMAT_R8G8B8A8; + break; + default: + break; + } + + SysTryReturnResult(NID_GRP, bitmapPixelFormat != BITMAP_PIXEL_FORMAT_MIN + , E_UNSUPPORTED_FORMAT + , "Unsupported format (BufferInfo::pixelFormat = %d)" + , bufferInfo.pixelFormat); + + result r = this->Construct(static_cast(bufferInfo.pPixels), bufferInfo.pitch * bufferInfo.height, Dimension(bufferInfo.width, bufferInfo.height), bitmapPixelFormat, false); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + this->_sharedItem->nativeBitmap->_SetOwnership(false); + + return E_SUCCESS; +} + +result +_BitmapImpl::Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& rq_dim, BitmapPixelFormat pixelFormat, bool autoScaling) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_sharedItem.get(), E_OUT_OF_MEMORY, "Fails to allocate memory."); + + SysTryReturnResult(NID_GRP, rq_dim.width > 0 && rq_dim.height > 0, E_INVALID_ARG, "Both of width(%d) and height(%d) of a dimension MUST be greater than 0.", rq_dim.width, rq_dim.height); + + SysTryReturnResult(NID_GRP, BITMAP_PIXEL_FORMAT_MIN < pixelFormat && pixelFormat < BITMAP_PIXEL_FORMAT_MAX, E_INVALID_ARG, "BitmapPixelFormat(%d) is the invalid argument.", pixelFormat); + + result r = _CheckBufferSize(buffer, rq_dim, pixelFormat); + + if (r != E_SUCCESS) + { + return r; + } + + if (_ResUtil::NeedToConvertCoord()) + { + result r = this->_sharedItem->nativeBitmap->Construct(buffer, rq_dim, pixelFormat); + + if (!IsFailed(r)) + { + Dimension vc_dim; + Dimension pc_dim; + + if (autoScaling) + { + vc_dim = rq_dim; + pc_dim = _ResUtil::ConvertToPhyCoord(vc_dim); + + // special case + pc_dim.width = (pc_dim.width > 0) ? pc_dim.width : 1; + pc_dim.height = (pc_dim.height > 0) ? pc_dim.height : 1; + + const BitmapScalingQuality quality = BITMAP_SCALING_QUALITY_LOW; + + this->_sharedItem->nativeBitmap->ScaleEx(pc_dim, quality); + } + else + { + pc_dim = rq_dim; + vc_dim = _ResUtil::ConvertToVirCoord(pc_dim); + } + + _ResUtil::Rect vc_rect(0, 0, vc_dim.width, vc_dim.height); + _ResUtil::Rect pc_rect(0, 0, pc_dim.width, pc_dim.height); + + this->_sharedItem->coordHolder->bitmapSize.required = vc_rect; + this->_sharedItem->coordHolder->bitmapSize.phyCoord = pc_rect; + this->_sharedItem->coordHolder->bitmapSize.virCoord = vc_rect; + } + + return r; + } + else + { + return this->_sharedItem->nativeBitmap->Construct(buffer, rq_dim, pixelFormat); + } +} + +result +_BitmapImpl::Construct(const byte* pBuffer, int bufSize, const Dimension& rq_dim, BitmapPixelFormat pixelFormat, bool autoScaling) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_sharedItem.get(), E_OUT_OF_MEMORY, "Fails to allocate memory."); + + SysTryReturnResult(NID_GRP, pBuffer, E_INVALID_ARG, "The specified buffer pointer is invalid.", rq_dim.width, rq_dim.height); + + SysTryReturnResult(NID_GRP, rq_dim.width > 0 && rq_dim.height > 0, E_INVALID_ARG, "Both of width(%d) and height(%d) of a dimension MUST be greater than 0.", rq_dim.width, rq_dim.height); + + SysTryReturnResult(NID_GRP, pixelFormat > BITMAP_PIXEL_FORMAT_MIN && pixelFormat < BITMAP_PIXEL_FORMAT_MAX, E_INVALID_ARG, "BitmapPixelFormat(%d) is the invalid argument.", pixelFormat); + + SysTryReturnResult(NID_GRP, (bufSize > 0) && (bufSize >= rq_dim.width * rq_dim.height * _GetBytesPerPixel(pixelFormat)), E_INVALID_ARG, "The specified buffer size is too small (buffer size = %d, dim(%d, %d))", bufSize, rq_dim.width, rq_dim.height); + + if (_ResUtil::NeedToConvertCoord()) + { + result r = this->_sharedItem->nativeBitmap->Construct(pBuffer, bufSize, rq_dim, pixelFormat); + + if (!IsFailed(r)) + { + Dimension vc_dim; + Dimension pc_dim; + + if (autoScaling) + { + vc_dim = rq_dim; + pc_dim = _ResUtil::ConvertToPhyCoord(vc_dim); + + // special case + pc_dim.width = (pc_dim.width > 0) ? pc_dim.width : 1; + pc_dim.height = (pc_dim.height > 0) ? pc_dim.height : 1; + + const BitmapScalingQuality quality = BITMAP_SCALING_QUALITY_LOW; + + this->_sharedItem->nativeBitmap->ScaleEx(pc_dim, quality); + } + else + { + pc_dim = rq_dim; + vc_dim = _ResUtil::ConvertToVirCoord(pc_dim); + } + + _ResUtil::Rect vc_rect(0, 0, vc_dim.width, vc_dim.height); + _ResUtil::Rect pc_rect(0, 0, pc_dim.width, pc_dim.height); + + this->_sharedItem->coordHolder->bitmapSize.required = vc_rect; + this->_sharedItem->coordHolder->bitmapSize.phyCoord = pc_rect; + this->_sharedItem->coordHolder->bitmapSize.virCoord = vc_rect; + } + + return r; + } + else + { + return this->_sharedItem->nativeBitmap->Construct(pBuffer, bufSize, rq_dim, pixelFormat); + } +} + +result +_BitmapImpl::Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& rq_dim, BitmapPixelFormat pixelFormat, BufferScaling bufferScaling) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_sharedItem.get(), E_OUT_OF_MEMORY, "Fails to allocate memory."); + + SysTryReturnResult(NID_GRP, rq_dim.width > 0 && rq_dim.height > 0, E_INVALID_ARG, "Both of width(%d) and height(%d) of a dimension MUST be greater than 0.", rq_dim.width, rq_dim.height); + + SysTryReturnResult(NID_GRP, pixelFormat > BITMAP_PIXEL_FORMAT_MIN && pixelFormat < BITMAP_PIXEL_FORMAT_MAX, E_INVALID_ARG, "BitmapPixelFormat(%d) is the invalid argument.", pixelFormat); + + result r = _CheckBufferSize(buffer, rq_dim, pixelFormat); + + if (r != E_SUCCESS) + { + return r; + } + + switch (bufferScaling) + { + case BUFFER_SCALING_AUTO: + return this->Construct(buffer, rq_dim, pixelFormat, true); + case BUFFER_SCALING_NONE: + break; + default: + SysTryReturnResult(NID_GRP, 0, E_INVALID_ARG, "BufferScaling(%d) is the invalid argument.", pixelFormat); + break; + } + + if (_ResUtil::NeedToConvertCoord()) + { + result r = this->_sharedItem->nativeBitmap->Construct(buffer, rq_dim, pixelFormat); + + if (!IsFailed(r)) + { + Dimension vc_dim = rq_dim; + Dimension pc_dim = _ResUtil::ConvertToPhyCoord(vc_dim); + + // special case + pc_dim.width = (pc_dim.width > 0) ? pc_dim.width : 1; + pc_dim.height = (pc_dim.height > 0) ? pc_dim.height : 1; + + this->_sharedItem->lazyScaling = 1; + + _ResUtil::Rect vc_rect(0, 0, vc_dim.width, vc_dim.height); + _ResUtil::Rect pc_rect(0, 0, pc_dim.width, pc_dim.height); + + this->_sharedItem->coordHolder->bitmapSize.required = vc_rect; + this->_sharedItem->coordHolder->bitmapSize.phyCoord = pc_rect; + this->_sharedItem->coordHolder->bitmapSize.virCoord = vc_rect; + + { + bool isScaledBufferAvailable = false; + + Tizen::Base::ByteBuffer scaledBuffer; + + { + int scaledCapacity = _GetBytesPerPixel(pixelFormat) * (pc_dim.width * pc_dim.height); + SysAssert(scaledCapacity > 0); + + // OOM ignored + isScaledBufferAvailable = (scaledBuffer.Construct(scaledCapacity) == E_SUCCESS); + } + + if (isScaledBufferAvailable) + { + _ScaleBuffer(scaledBuffer, pc_dim, buffer, vc_dim, pixelFormat); + + this->_sharedItem->scaledNativeBitmap.reset(new (std::nothrow) _Bitmap); + + if (this->_sharedItem->scaledNativeBitmap.get()) + { + if (this->_sharedItem->scaledNativeBitmap->Construct(scaledBuffer, pc_dim, pixelFormat) == E_SUCCESS) + { + // Post-processing + + // BufferInfo bufferInfo; + // this->_scaledNativeBitmap->Lock(bufferInfo); + // this->_scaledNativeBitmap->Unlock(); + ; + } + else + { + this->_sharedItem->scaledNativeBitmap.reset(null); + } + } + } + } + } + + return r; + } + else + { + return this->_sharedItem->nativeBitmap->Construct(buffer, rq_dim, pixelFormat); + } +} + +result +_BitmapImpl::Construct(const Tizen::Base::String& fileName, BitmapPixelFormat pixelFormat) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_sharedItem.get(), E_OUT_OF_MEMORY, "Fails to allocate memory."); + + switch (pixelFormat) + { + case BITMAP_PIXEL_FORMAT_RGB565: + case BITMAP_PIXEL_FORMAT_ARGB8888: + case BITMAP_PIXEL_FORMAT_R8G8B8A8: + break; + default: + SysTryReturnResult(NID_GRP, false, E_INVALID_ARG, "BitmapPixelFormat(%d) is invalid argument.", pixelFormat); + break; + } + + SysTryReturnResult(NID_GRP, Tizen::Io::File::IsFileExist(fileName), E_INVALID_ARG, "The specified file is not found."); + + // This function doesn't verify the specified image file. + this->_sharedItem->associated.fileName = fileName; + this->_sharedItem->associated.pixelFormat = pixelFormat; + + return E_SUCCESS; +} + +const Tizen::Base::String& +_BitmapImpl::GetFileName(void) const +{ + if (this && this->_sharedItem.get()) + { + return this->_sharedItem->associated.fileName; + } + else + { + static Tizen::Base::String emptyString; + emptyString.Clear(); + + return emptyString; + } +} + +result +_BitmapImpl::Scale(const Dimension& vc_dim) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, vc_dim.width > 0 && vc_dim.height > 0, E_OUT_OF_RANGE, "Both of width(%d) and height(%d) MUST be greater than 0.", vc_dim.width, vc_dim.height); + + if (vc_dim.width == this->GetWidth() && vc_dim.height == this->GetHeight()) + { + return E_SUCCESS; + } + + _UpdateBitmapTimeStamp(*this); + + if (_ResUtil::NeedToConvertCoord()) + { + if (this->_sharedItem->lazyScaling && this->_sharedItem->scaledNativeBitmap.get()) + { + Dimension pc_dim = _ResUtil::ConvertToPhyCoord(vc_dim); + + // special case + pc_dim.width = (pc_dim.width > 0) ? pc_dim.width : 1; + pc_dim.height = (pc_dim.height > 0) ? pc_dim.height : 1; + + result r = this->_sharedItem->nativeBitmap->Scale(vc_dim); + + if (!IsFailed(r)) + { + Rectangle vc_rect(0, 0, vc_dim.width, vc_dim.height); + + this->_sharedItem->coordHolder->Init(vc_rect); + this->_sharedItem->coordHolder->bitmapSize.phyCoord.w = pc_dim.width; + this->_sharedItem->coordHolder->bitmapSize.phyCoord.h = pc_dim.height; + + result r = this->_sharedItem->scaledNativeBitmap->Scale(pc_dim); + + if (!IsFailed(r)) + { + _UpdateScaledBitmapEx(this->_sharedItem->nativeBitmap.get(), this->_sharedItem->scaledNativeBitmap.get()); + } + } + + return r; + } + else + { + Dimension pc_dim = _ResUtil::ConvertToPhyCoord(vc_dim); + + // special case + pc_dim.width = (pc_dim.width > 0) ? pc_dim.width : 1; + pc_dim.height = (pc_dim.height > 0) ? pc_dim.height : 1; + + result r = this->_sharedItem->nativeBitmap->Scale(pc_dim); + + if (!IsFailed(r)) + { + Rectangle vc_rect(0, 0, vc_dim.width, vc_dim.height); + + this->_sharedItem->coordHolder->Init(vc_rect); + this->_sharedItem->coordHolder->bitmapSize.phyCoord.w = pc_dim.width; + this->_sharedItem->coordHolder->bitmapSize.phyCoord.h = pc_dim.height; + } + + return r; + } + } + else + { + return this->_sharedItem->nativeBitmap->Scale(vc_dim); + } +} + +result +_BitmapImpl::Merge(const Point& vc_dest, const _BitmapImpl& src, const Rectangle& vc_srcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, &src && src._sharedItem.get(), E_INVALID_ARG, "The source bitmap is invalid."); + + SysTryReturnResult(NID_GRP, src._sharedItem->nativeBitmap->IsValid(), E_INVALID_ARG, "The source bitmap is invalid."); + + SysTryReturnResult(NID_GRP, &vc_srcRect, E_INVALID_ARG, "The source rectangle is invalid."); + SysTryReturnResult(NID_GRP, &vc_dest, E_INVALID_ARG, "The destination position is invalid."); + SysTryReturnResult(NID_GRP, vc_dest.x >= 0 && vc_dest.y >= 0, E_OUT_OF_RANGE, "The argument is out of range. (dest(x:%d,y:%d)).", vc_dest.x, vc_dest.y); + + SysTryReturnResult(NID_GRP, (vc_srcRect.width >= 0) && (vc_srcRect.height >= 0), E_INVALID_ARG, "The given rectangle(width:%d,height:%d) is invalid.", vc_srcRect.width, vc_srcRect.height); + + if ((vc_srcRect.width == 0) || (vc_srcRect.height == 0)) + { + return E_SUCCESS; + } + + _UpdateBitmapTimeStamp(*this); + + Rectangle rtBitmap(0, 0, src.GetWidth(), src.GetHeight()); + SysTryReturnResult(NID_GRP, _CheckValidity(vc_srcRect, rtBitmap), E_OUT_OF_RANGE, "The argument is out of range. (srcRect(x:%d,y:%d,w:%d,h:%d)).", vc_srcRect.x, vc_srcRect.y, vc_srcRect.width, vc_srcRect.height); + + _Bitmap* pSrcBitmapEx = Tizen::Graphics::GetBitmapEx(src); + _Bitmap* pDstBitmapEx = this->_sharedItem->nativeBitmap.get(); + + if (_ResUtil::NeedToConvertCoord()) + { + Point pc_dest = _ResUtil::ConvertToPhyCoord(vc_dest); + Rectangle pc_srcRect = _ResUtil::ConvertToPhyCoord(vc_srcRect); + + /* + case 0: scaled bitmap -> scaled bitmap + merge level 0 + case 1: scaled bitmap -> lazy scaled bitmap + merge level 0 from the scaled source bitmap + merge level 0(src) and level 1(dst) + case 2: lazy scaled bitmap -> scaled bitmap + merge level 1(src) and level 0(dst) + case 3: lazy scaled bitmap -> lazy scaled bitmap + merge level 0 (using virtual coordinate) + merge level 1 (using physical coordinate) + */ + int caseNo = (Tizen::Graphics::IsLazyScalingBitmap(src)) ? 2 : 0; + caseNo += (Tizen::Graphics::IsLazyScalingBitmap(*this)) ? 1 : 0; + + switch (caseNo) + { + case 0: // source: pre-scale, destination: pre-scale --> merge by using the physical coordinate + { + return pDstBitmapEx->Merge(pc_dest, *pSrcBitmapEx, pc_srcRect); + } + case 1: // source: pre-scale --> level0 bitmap: merge after enlarging, level1 bitmap: merge from source directly + { + result r = E_SUCCESS; + + // step 1 + { + _Bitmap srcResizedBitmap; + { + Dimension srcVirDim(src._sharedItem->coordHolder->bitmapSize.virCoord.w, src._sharedItem->coordHolder->bitmapSize.virCoord.h); + + r = srcResizedBitmap.Construct(srcVirDim, pSrcBitmapEx->GetPixelColorFormat()); + SysTryReturnResult(NID_GRP, !IsFailed(r), E_OUT_OF_MEMORY, "Fails to allocate memory."); + } + + _UpdateScaledBitmapEx(pSrcBitmapEx, &srcResizedBitmap); + + r = pDstBitmapEx->Merge(vc_dest, srcResizedBitmap, vc_srcRect); + } + + // step 2 + if (!IsFailed(r) && this->_sharedItem->scaledNativeBitmap.get()) + { + return this->_sharedItem->scaledNativeBitmap->Merge(pc_dest, *pSrcBitmapEx, pc_srcRect); + } + + return r; + } + case 2: // destination: pre-scale --> merge from the level1 bitmap of source + { + _Bitmap* pSrcScaledBitmapEx = Tizen::Graphics::GetScaledBitmapEx(src); + + + if (pSrcScaledBitmapEx) + { + return pDstBitmapEx->Merge(pc_dest, *pSrcScaledBitmapEx, pc_srcRect); + } + else + { + SysTryReturnResult(NID_GRP, 0, E_INVALID_ARG, "The source bitmap is invalid."); + } + + return E_INVALID_ARG; + } + case 3: // source: lazy-scale, destination: lazy-scale --> merge between level0, merge between level1 + { + result r = pDstBitmapEx->Merge(vc_dest, *pSrcBitmapEx, vc_srcRect); + + _Bitmap* pSrcScaledBitmapEx = Tizen::Graphics::GetScaledBitmapEx(src); + + if (this->_sharedItem->scaledNativeBitmap.get() && pSrcScaledBitmapEx) + { + this->_sharedItem->scaledNativeBitmap->Merge(pc_dest, *pSrcScaledBitmapEx, pc_srcRect); + } + + return r; + } + default: + SysAssert(0); + return E_INVALID_ARG; + } + } + else + { + return pDstBitmapEx->Merge(vc_dest, *pSrcBitmapEx, vc_srcRect); + } + + // for removing compiler warnings + return E_OPERATION_FAILED; +} + +int +_BitmapImpl::GetHeight() const +{ + if (!(INSTANCE_IS_VALID)) + { + SysLog(NID_GRP, "[E_OPERATION_FAILED] This instance is not constructed yet."); + return -1; + } + + if (_ResUtil::NeedToConvertCoord()) + { + return this->_sharedItem->coordHolder->bitmapSize.required.h; + } + else + { + return this->_sharedItem->nativeBitmap->GetHeight(); + } +} + +int +_BitmapImpl::GetWidth() const +{ + if (!(INSTANCE_IS_VALID)) + { + SysLog(NID_GRP, "[E_OPERATION_FAILED] This instance is not constructed yet."); + return -1; + } + + if (_ResUtil::NeedToConvertCoord()) + { + return this->_sharedItem->coordHolder->bitmapSize.required.w; + } + else + { + return this->_sharedItem->nativeBitmap->GetWidth(); + } +} + +int +_BitmapImpl::GetBitsPerPixel() const +{ + if (!(INSTANCE_IS_VALID)) + { + SysLog(NID_GRP, "[E_OPERATION_FAILED] This instance is not constructed yet."); + return -1; + } + + return this->_sharedItem->nativeBitmap->GetBitsPerPixel(); +} + +BitmapPixelFormat +_BitmapImpl::GetPixelColorFormat() const +{ + if (!(INSTANCE_IS_VALID)) + { + SysLog(NID_GRP, "[E_OPERATION_FAILED] This instance is not constructed yet."); + return BITMAP_PIXEL_FORMAT_MAX; + } + + return this->_sharedItem->nativeBitmap->GetPixelColorFormat(); +} + +result +_BitmapImpl::SetMaskingColor(const Color* pColor) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + _UpdateBitmapTimeStamp(*this); + + return this->_sharedItem->nativeBitmap->SetMaskingColor(pColor); +} + +result +_BitmapImpl::GetMaskingColor(Color& color) const +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return this->_sharedItem->nativeBitmap->GetMaskingColor(color); +} + +void +_BitmapImpl::SetAlphaConstant(int opacity) +{ + if (INSTANCE_IS_VALID) + { + _UpdateBitmapTimeStamp(*this); + + this->_sharedItem->nativeBitmap->SetAlphaConstant(opacity); + } +} + +int +_BitmapImpl::GetAlphaConstant(void) const +{ + return (INSTANCE_IS_VALID) ? this->_sharedItem->nativeBitmap->GetAlphaConstant() : -1; +} + +result +_BitmapImpl::SetScalingQuality(BitmapScalingQuality quality) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + switch (quality) + { + case BITMAP_SCALING_QUALITY_LOW: + case BITMAP_SCALING_QUALITY_MID: + case BITMAP_SCALING_QUALITY_HIGH: + break; + default: + return E_INVALID_ARG; + } + + _UpdateBitmapTimeStamp(*this); + + this->_sharedItem->nativeBitmap->SetScalingQuality(quality); + + return E_SUCCESS; +} + +BitmapScalingQuality +_BitmapImpl::GetScalingQuality(void) const +{ + return (INSTANCE_IS_VALID) ? this->_sharedItem->nativeBitmap->GetScalingQuality() : BITMAP_SCALING_QUALITY_LOW; +} + +bool +_BitmapImpl::IsNinePatchedBitmap(void) const +{ + if (!(INSTANCE_IS_VALID)) + { + SysLog(NID_GRP, "[E_OPERATION_FAILED] This instance is not constructed yet."); + return false; + } + + _Bitmap* pRefBitmap = (this->_sharedItem->lazyScaling && this->_sharedItem->scaledNativeBitmap.get()) ? this->_sharedItem->scaledNativeBitmap.get() : this->_sharedItem->nativeBitmap.get(); + + return pRefBitmap->IsNinePatchedBitmap(); +} + +void +_BitmapImpl::SetAsImmutable(void) +{ + if (INSTANCE_IS_VALID) + { + if (this->_sharedItem->isMutable) + { + BufferInfo bi; + + if (this->Lock(bi) == E_SUCCESS) + { + _Util::Pixmap dstImage(bi.width, bi.height, bi.bitsPerPixel, (void*)bi.pPixels, bi.pitch); + dstImage.ConvertPremultiplied(); + + this->Unlock(); + } + + this->_sharedItem->isMutable = false; + this->_sharedItem->nativeBitmap->__isPremultiplied = true; + + //?? this->_sharedItem->scaledNativeBitmap + } + } +} + +bool +_BitmapImpl::IsMutable(void) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, false, "This instance is not constructed yet."); + + return this->_sharedItem->isMutable; +} + +result +_BitmapImpl::Lock(BufferInfo& info, long timeout) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + _UpdateBitmapTimeStamp(*this); + + return this->_sharedItem->nativeBitmap->Lock(info, timeout); +} + +result +_BitmapImpl::Unlock() +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + result r = this->_sharedItem->nativeBitmap->Unlock(); + + _UpdateBitmapTimeStamp(*this); + + if ((r == E_SUCCESS) && (this->_sharedItem->lazyScaling)) + { + if (this->_sharedItem->scaledNativeBitmap.get()) + { + _UpdateScaledBitmapEx(this->_sharedItem->nativeBitmap.get(), this->_sharedItem->scaledNativeBitmap.get()); + this->_sharedItem->scaledNativeBitmap->UpdateOpaqueInfo(); + } + } + + return r; +} + +result +_BitmapImpl::LockFast(BufferInfo& info, long timeout) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + _UpdateBitmapTimeStamp(*this); + + return this->_sharedItem->nativeBitmap->LockFast(info, timeout); +} + +result +_BitmapImpl::UnlockFast() +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + result r = this->_sharedItem->nativeBitmap->UnlockFast(); + + _UpdateBitmapTimeStamp(*this); + + if ((r == E_SUCCESS) && (this->_sharedItem->lazyScaling)) + { + if (this->_sharedItem->scaledNativeBitmap.get()) + { + _UpdateScaledBitmapEx(this->_sharedItem->nativeBitmap.get(), this->_sharedItem->scaledNativeBitmap.get()); + } + } + + return r; +} + +bool +_BitmapImpl::_SetCallback(void (* DestroyCallback)(void*), void* pDestroyCallbackParam, + void (* LockCallback)(void*), void* pLockCallbackParam, + void (* UnlockCallback)(void*), void* pUnlockCallbackParam) +{ + if (!(INSTANCE_IS_VALID)) + { + SysLog(NID_GRP, "[E_OPERATION_FAILED] This instance is not constructed yet."); + return false; + } + + _UpdateBitmapTimeStamp(*this); + + this->_sharedItem->pDestroyCallbackFunc = DestroyCallback; + this->_sharedItem->pDestroyCallbackParam = pDestroyCallbackParam; + + this->_sharedItem->pLockCallbackFunc = LockCallback; + this->_sharedItem->pLockCallbackParam = pLockCallbackParam; + + this->_sharedItem->pUnlockCallbackFunc = UnlockCallback; + this->_sharedItem->pUnlockCallbackParam = pUnlockCallbackParam; + + if (this->_sharedItem->nativeBitmap.get()) + { + this->_sharedItem->nativeBitmap->SetCallback(LockCallback, pLockCallbackParam, UnlockCallback, pUnlockCallbackParam); + } + + if (this->_sharedItem->scaledNativeBitmap.get()) + { + this->_sharedItem->scaledNativeBitmap->SetCallback(LockCallback, pLockCallbackParam, UnlockCallback, pUnlockCallbackParam); + } + + return true; +} + +Bitmap* +_BitmapImpl::GetExpandedBitmapN(const Bitmap& ninePatchedBitmap, int width, int height) +{ + SysTryReturn(NID_GRP, width > 0 && height > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid (width = %d, height = %d)", width, height); + + SysTryReturn(NID_GRP, &ninePatchedBitmap, null, E_INVALID_ARG, "[E_INVALID_ARG] The given bitmap is invalid (null reference passed)"); + + const _BitmapImpl* pSrcBitmapImpl = _BitmapImpl::GetInstance(ninePatchedBitmap); + + SysTryReturn(NID_GRP, BITMAPIMPL_IS_VALID(pSrcBitmapImpl), null, E_INVALID_ARG, "[E_INVALID_ARG] The given bitmap is invalid"); + + SysTryReturn(NID_GRP, pSrcBitmapImpl->IsNinePatchedBitmap(), null, E_INVALID_ARG, "[E_INVALID_ARG] The given bitmap is not a nine-patched bitmap"); + + BitmapPixelFormat pixelFormat = pSrcBitmapImpl->GetPixelColorFormat(); + + switch (pixelFormat) + { + case BITMAP_PIXEL_FORMAT_RGB565: + case BITMAP_PIXEL_FORMAT_ARGB8888: + break; + default: + SysTryReturn(NID_GRP, false, null, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] Pixel format of the given bitmap is invalid (%d)", pixelFormat); + break; + } + + std::auto_ptr expandedBitmap(new (std::nothrow) Bitmap); + + SysTryReturn(NID_GRP, expandedBitmap.get(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed (new Bitmap)"); + + result r = expandedBitmap->Construct(Dimension(width, height), pixelFormat); + + SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _BitmapImpl* pDstBitmapImpl = _BitmapImpl::GetInstance(*expandedBitmap.get()); + + SysAssert(pDstBitmapImpl != null); + + { + _Util::LockManager srcBitmap(*pSrcBitmapImpl); + _Util::LockManager dstBitmap(*pDstBitmapImpl); + + SysTryReturn(NID_GRP, srcBitmap.IsValid(), null, srcBitmap.GetResult(), "[%s] Buffer locking of the source bitmap failed", srcBitmap.GetResult()); + SysTryReturn(NID_GRP, dstBitmap.IsValid(), null, dstBitmap.GetResult(), "[%s] Buffer locking of the target bitmap failed", dstBitmap.GetResult()); + + if (dstBitmap.GetBufferInfo().width < srcBitmap.GetBufferInfo().width - 2 || + dstBitmap.GetBufferInfo().height < srcBitmap.GetBufferInfo().height - 2) + { + // down-scales from the source bitmap only + const BufferInfo& srcBufferInfo = srcBitmap.GetBufferInfo(); + const BufferInfo& dstBufferInfo = dstBitmap.GetBufferInfo(); + + memset(dstBufferInfo.pPixels, 0, dstBufferInfo.pitch * dstBufferInfo.height); + + _Util::Pixmap dstImage(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, (void*) dstBufferInfo.pPixels, dstBufferInfo.pitch); + + Rectangle sourRect(1, 1, srcBufferInfo.width - 2, srcBufferInfo.height - 2); + Rectangle destRect(0, 0, dstBufferInfo.width, dstBufferInfo.height); + + unsigned char* pSrcPixels = (unsigned char*) srcBufferInfo.pPixels + sourRect.y * srcBufferInfo.pitch + sourRect.x * (srcBufferInfo.bitsPerPixel / 8); + _Util::Pixmap srcImage(sourRect.width, sourRect.height, srcBufferInfo.bitsPerPixel, (void*) pSrcPixels, srcBufferInfo.pitch); + + Tizen::Graphics::_Effect::ScaleImage(dstImage, destRect.x, destRect.y, destRect.width, destRect.height, srcImage, Tizen::Graphics::_Effect::ROP_COPY); + } + else + { + const BufferInfo& srcBufferInfo = srcBitmap.GetBufferInfo(); + const BufferInfo& dstBufferInfo = dstBitmap.GetBufferInfo(); + + memset(dstBufferInfo.pPixels, 0, dstBufferInfo.pitch * dstBufferInfo.height); + + _Util::Pixmap dstImage(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, (void*) dstBufferInfo.pPixels, dstBufferInfo.pitch); + + _Util::AccumList<_Util::Pair<_Util::Rectangle, _Util::Rectangle > > boundsList; + + Rectangle destRect(0, 0, dstBufferInfo.width, dstBufferInfo.height); + + // assert(pSrcBitmapImpl->_nativeBitmap); + r = _Util::GetPatchList(boundsList, destRect, *pSrcBitmapImpl->_sharedItem->nativeBitmap.get()); + + SysTryReturn(NID_GRP, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] _Util::GetPatchList() failed (error = %#x)", r); + + _Util::AccumList<_Util::Pair<_Util::Rectangle, _Util::Rectangle > >::Iterator iter = boundsList.Begin(); + + while (iter != boundsList.End()) + { + Rectangle destRect(iter->first.x, iter->first.y, iter->first.w, iter->first.h); + Rectangle sourRect(iter->second.x, iter->second.y, iter->second.w, iter->second.h); + + { + unsigned char* pSrcPixels = (unsigned char*) srcBufferInfo.pPixels + sourRect.y * srcBufferInfo.pitch + sourRect.x * (srcBufferInfo.bitsPerPixel / 8); + _Util::Pixmap srcImage(sourRect.width, sourRect.height, srcBufferInfo.bitsPerPixel, (void*) pSrcPixels, srcBufferInfo.pitch); + + Tizen::Graphics::_Effect::ScaleImage(dstImage, destRect.x, destRect.y, destRect.width, destRect.height, srcImage, Tizen::Graphics::_Effect::ROP_COPY); + } + + ++iter; + } + } + } + + return expandedBitmap.release(); +} + +Bitmap* +_BitmapImpl::GetColorReplacedBitmapN(const Bitmap& bitmap, const Color& replacedColor, const Color& newColor) +{ + SysTryReturn(NID_GRP, &bitmap, null, E_INVALID_ARG, "[E_INVALID_ARG] The given bitmap is invalid (null reference passed)"); + + std::auto_ptr pRetBitmap; + + { + Bitmap* pSrcBitmap = const_cast(&bitmap); + + BufferInfo biSrc; + pSrcBitmap->Lock(biSrc); + { + pRetBitmap.reset(_BitmapUtil::CreateBitmapN(Dimension(biSrc.width, biSrc.height), biSrc.bitsPerPixel)); + + if (pRetBitmap.get()) + { + BufferInfo biDst; + pRetBitmap->Lock(biDst); + + if ((biSrc.pitch == biDst.pitch) && (biSrc.height == biDst.height)) + { + memcpy(biDst.pPixels, biSrc.pPixels, biDst.pitch * biDst.height); + } + + pRetBitmap->Unlock(); + } + } + pSrcBitmap->Unlock(); + + SysTryReturn(NID_GRP, pRetBitmap.get(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] New bitmap construction failed"); + } + + BufferInfo bufferInfo; + + result r = pRetBitmap->Lock(bufferInfo); + + SysTryReturn(NID_GRP, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] The allocated bitmap cannot retrieve the own buffer address"); + + if (bufferInfo.bitsPerPixel == 32) + { + typedef unsigned long Pixel; + + Pixel keyColor = replacedColor.GetRGB32() & 0x00FFFFFF; + Pixel chgColor = newColor.GetRGB32() & 0x00FFFFFF; + Pixel* pBuffer = reinterpret_cast(bufferInfo.pPixels); + int padding = bufferInfo.pitch * 8 / bufferInfo.bitsPerPixel - bufferInfo.width; + + Pixel keyAlpha = (newColor.GetRGB32() & 0xFF000000) >> 24; + keyAlpha += (keyAlpha >> 7); + + if (keyAlpha < 256) + { + for (int y = 0; y < bufferInfo.height; y++) + { + for (int x = 0; x < bufferInfo.width; x++) + { + // if buffer.rgb = replacedColor.rgb then begin + // buffer.a <- buffer.a * newColor.a; + // buffer.r <- newColor.r; + // buffer.g <- newColor.g; + // buffer.b <- newColor.b; + // end if + + if ((*pBuffer & 0x00FFFFFF) == keyColor) + { + Pixel alpha = (*pBuffer >> 8) & 0x00FF0000; + alpha = (alpha * keyAlpha) & 0xFF000000; + + *pBuffer = alpha | chgColor; + } + + ++pBuffer; + } + + pBuffer += padding; + } + } + else + { + for (int y = 0; y < bufferInfo.height; y++) + { + for (int x = 0; x < bufferInfo.width; x++) + { + // if buffer.rgb = replacedColor.rgb then begin + // buffer.a <- buffer.a; + // buffer.r <- newColor.r; + // buffer.g <- newColor.g; + // buffer.b <- newColor.b; + // end if + + if ((*pBuffer & 0x00FFFFFF) == keyColor) + { + *pBuffer = (*pBuffer & 0xFF000000) | chgColor; + } + + ++pBuffer; + } + + pBuffer += padding; + } + } + } + else if (bufferInfo.bitsPerPixel == 16) + { + typedef unsigned short Pixel; + + Pixel keyColor = 0; + Pixel chgColor = 0; + Pixel* pBuffer = reinterpret_cast(bufferInfo.pPixels); + int padding = bufferInfo.pitch * 8 / bufferInfo.bitsPerPixel - bufferInfo.width; + + { + unsigned long color32 = replacedColor.GetRGB32(); + _Effect::Func::ConvertColorFormatFast(&keyColor, &color32); + } + + { + unsigned long color32 = newColor.GetRGB32() & 0x00FFFFFF; + _Effect::Func::ConvertColorFormatFast(&chgColor, &color32); + } + + for (int y = 0; y < bufferInfo.height; y++) + { + for (int x = 0; x < bufferInfo.width; x++) + { + if (*pBuffer == keyColor) + { + *pBuffer = chgColor; + } + + ++pBuffer; + } + + pBuffer += padding; + } + } + else + { + return null; + } + + pRetBitmap->Unlock(); + + return pRetBitmap.release(); +} + +Bitmap* +_BitmapImpl::CloneN(const Bitmap& bitmap) +{ + const _BitmapImpl* pSrcBitmapImpl = null; + _BitmapImpl* pDstBitmapImpl = null; + + // source bitmap verification + { + SysTryReturn(NID_GRP, &bitmap, null, E_INVALID_ARG, "[E_INVALID_ARG] The given bitmap is invalid (null reference passed)"); + + pSrcBitmapImpl = _BitmapImpl::GetInstance(bitmap); + + SysTryReturn(NID_GRP, IS_BITMAPIMPL_VALID(pSrcBitmapImpl), null, E_INVALID_ARG, "[E_INVALID_ARG] The given bitmap is invalid"); + } + + // destination bitmap allocation + std::auto_ptr pRetBitmap(new (std::nothrow) Bitmap); + + { + SysTryReturn(NID_GRP, pRetBitmap.get(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed (new Bitmap)"); + + pDstBitmapImpl = _BitmapImpl::GetInstance(*pRetBitmap.get()); + + SysTryReturn(NID_GRP, pDstBitmapImpl && pDstBitmapImpl->_sharedItem.get() && !pDstBitmapImpl->_sharedItem->nativeBitmap->IsValid(), null, E_SYSTEM, "[E_SYSTEM] The allocated bitmap is invalid"); + } + + pDstBitmapImpl->_sharedItem = pSrcBitmapImpl->_sharedItem; + + return pRetBitmap.release(); +} + +_BitmapImpl* +_BitmapImpl::GetNonScaledBitmapImplN(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat) +{ + return _NonScale::CreateBitmapN(buffer, dim, pixelFormat); +} + +Bitmap* +_BitmapImpl::GetNonScaledBitmapN(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat) +{ + _BitmapImpl* pBitmapImpl = _BitmapImpl::GetNonScaledBitmapImplN(buffer, dim, pixelFormat); + + if (pBitmapImpl == null) + { + return null; + } + + return Tizen::Graphics::_BitmapUtil::CreateBitmapN(pBitmapImpl); +} + +_BitmapImpl*& +_BitmapImpl::_GetBitmapImpl(Bitmap* pBitmap) +{ + return pBitmap->__pImpl; +} + +_BitmapImpl* +_BitmapImpl::GetInstance(Bitmap& bitmap) +{ + return (&bitmap != null) ? bitmap.__pImpl : null; +} + +const _BitmapImpl* +_BitmapImpl::GetInstance(const Bitmap& bitmap) +{ + return (&bitmap != null) ? bitmap.__pImpl : null; +} + +bool +_BitmapImpl::__CheckValidity(bool canBufferExpand) +{ + if (this->_sharedItem.get()) + { + if (this->_sharedItem->nativeBitmap->IsValid()) + { + return true; + } + + if (!this->_sharedItem->associated.fileName.IsEmpty()) + { + if (canBufferExpand) + { + if (!__RealizeBuffer()) + { + // linkedFileName does not exist or is not a image file. + this->Construct(Dimension(1, 1), BITMAP_PIXEL_FORMAT_ARGB8888); + } + + this->_sharedItem->associated.fileName.Clear(); + } + + return true; + } + } + + return false; +} + +bool +_BitmapImpl::__RealizeBuffer(void) +{ + int imageWidth = 0; + int imageHeight = 0; + + Tizen::Media::MediaPixelFormat format = Tizen::Media::MEDIA_PIXEL_FORMAT_BGRA8888; + + // The following does not consider the case of big-endian + switch (this->_sharedItem->associated.pixelFormat) + { + case BITMAP_PIXEL_FORMAT_RGB565: + format = Tizen::Media::MEDIA_PIXEL_FORMAT_RGB565LE; + break; + case BITMAP_PIXEL_FORMAT_R8G8B8A8: + format = Tizen::Media::MEDIA_PIXEL_FORMAT_RGBA8888; + break; + case BITMAP_PIXEL_FORMAT_ARGB8888: + default: + format = Tizen::Media::MEDIA_PIXEL_FORMAT_BGRA8888; + break; + } + + std::auto_ptr pImageBuffer(Tizen::Media::_ImageDecoder::DecodeToBufferN(this->_sharedItem->associated.fileName, format, imageWidth, imageHeight)); + + if (pImageBuffer.get() == null) + { + return false; + } + + std::auto_ptr<_BitmapImpl> pTempBitmapImpl(_BitmapImpl::GetNonScaledBitmapImplN(*pImageBuffer, Dimension(imageWidth, imageHeight), this->_sharedItem->associated.pixelFormat)); + + if (pTempBitmapImpl.get() == null || pTempBitmapImpl->_sharedItem.get() == null) + { + return false; + } + + pImageBuffer.reset(); + + this->_sharedItem->Move(*(pTempBitmapImpl->_sharedItem.get())); + + return true; +} + +void _BitmapImpl::_SharedItem::Move(_BitmapImpl::_SharedItem& source) +{ + std::swap(this->nativeBitmap, source.nativeBitmap); + std::swap(this->coordHolder, source.coordHolder); + std::swap(this->lazyScaling, source.lazyScaling); + std::swap(this->scaledNativeBitmap, source.scaledNativeBitmap); + std::swap(this->isMutable, source.isMutable); +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_BitmapScreenCapture.cpp b/src/graphics/FGrp_BitmapScreenCapture.cpp new file mode 100644 index 0000000..85690e0 --- /dev/null +++ b/src/graphics/FGrp_BitmapScreenCapture.cpp @@ -0,0 +1,209 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_BitmapScreenCapture.cpp + * @brief This is the cpp file for BitmapScreenCapture. + * + */ + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "FGrp_Callback.h" + + +namespace // unnamed +{ + Window + GetEvasWindow(void) + { + Ecore_Evas* pEcoreEvas = static_cast(Tizen::Graphics::_GetDefaultFrameEcoreEvasHandle()); + + if (pEcoreEvas == null) + { + return BadWindow; + } + + return (Window) ecore_evas_window_get(pEcoreEvas); + } +} + +namespace Tizen { namespace Graphics +{ + +bool +_GetScreenShot(int depth, unsigned char*& pOutBuffer, int& screenWidth, int& screenHeight) +{ + // check input parameter + { + switch (depth) + { + case 32: + break; + case 16: + default: + return false; + } + + // pBuffer should be NULL pointer + if (pOutBuffer != NULL) + { + return false; + } + } + + unsigned char* pTempBuffer = 0; + + Display* pDisplay = XOpenDisplay(NULL); + int displayWidth = DisplayWidth(pDisplay, DefaultScreen(pDisplay)); + int displayHeight = DisplayHeight(pDisplay, DefaultScreen(pDisplay)); + + // Can not use a root window --> RootWindow(pDisplay, DefaultScreen(pDisplay)) + Window root = GetEvasWindow(); + + XShmSegmentInfo shmInfo; + XImage* pXimage = XShmCreateImage(pDisplay, DefaultVisualOfScreen(DefaultScreenOfDisplay(pDisplay)), 24, ZPixmap, + NULL, &shmInfo, (unsigned int) displayWidth, (unsigned int) displayHeight); + if (pXimage == NULL) + { + goto CLEAN_UP; + } + + shmInfo.shmid = shmget(IPC_PRIVATE, pXimage->bytes_per_line * pXimage->height, IPC_CREAT | 0777); + + pXimage->data = (char*) shmat(shmInfo.shmid, 0, 0); + shmInfo.shmaddr = pXimage->data; + shmInfo.readOnly = False; + + if (!XShmAttach(pDisplay, &shmInfo)) + { + goto CLEAN_UP; + } + + if (!XShmGetImage(pDisplay, root, pXimage, 0, 0, AllPlanes)) + { + goto CLEAN_UP; + } + + XSync(pDisplay, False); + + // Apply screen rotation + { +#if 0 + char* rot_buffer; + Atom atom_rotaion; + int rotate; + + atom_rotaion = XInternAtom(dpy, "X_SCREEN_ROTATION", True); + + if (!atom_rotaion || !getXwindowProperty(root, atom_rotaion, XA_CARDINAL, (unsigned char*) &rotate, 1)) + { + rotate = RR_Rotate_0; + } + + if (rotate == RR_Rotate_90 || rotate == RR_Rotate_270) + { + rot_buffer = calloc(ximage->bytes_per_line * ximage->height, 1); + + convert_image((uint32_t*) ximage->data, + (uint32_t*) rot_buffer, + PIXMAN_x8b8g8r8, PIXMAN_x8b8g8r8, + height, width, width, height, + (rotate == RR_Rotate_90) ? 90 : 270); + + ret = rot_buffer; + } + + // assign buffer + { + //?? + } + + // release + if (rot_buffer) + { + free(rot_buffer); + rot_buffer = NULL; + } +#endif + } + + // copy from the captured buffer + { + int bufferSize = pXimage->bytes_per_line * pXimage->height; + + pTempBuffer = new (std::nothrow) unsigned char[bufferSize]; + + if (pTempBuffer == NULL) + { + goto CLEAN_UP; + } + + memcpy(pTempBuffer, pXimage->data, bufferSize); + } + + // result + pOutBuffer = pTempBuffer; + screenWidth = pXimage->width; + screenHeight = pXimage->height; + + // release the captured buffer + { + XShmDetach(pDisplay, &shmInfo); + shmdt(shmInfo.shmaddr); + shmctl(shmInfo.shmid, IPC_RMID, NULL); + + XDestroyImage(pXimage); + pXimage = NULL; + + XCloseDisplay(pDisplay); + } + + return true; + +CLEAN_UP: + delete[] pTempBuffer; + + if (pXimage) + { + XShmDetach(pDisplay, &shmInfo); + shmdt(shmInfo.shmaddr); + shmctl(shmInfo.shmid, IPC_RMID, NULL); + + XDestroyImage(pXimage); + pXimage = NULL; + } + + XCloseDisplay(pDisplay); + + return false; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_BitmapTool.cpp b/src/graphics/FGrp_BitmapTool.cpp new file mode 100644 index 0000000..f4039f9 --- /dev/null +++ b/src/graphics/FGrp_BitmapTool.cpp @@ -0,0 +1,52 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_BitmapTool.cpp + * @brief This is the cpp file for internal util class. + * + */ + +#include "FGrp_BitmapTool.h" +#include "FGrp_BitmapUtil.h" + + +namespace Tizen { namespace Graphics +{ + +result +_BitmapTool::ChangeBuffer(Tizen::Graphics::Bitmap& srcBitmap, void* pBuffer, long bytesPerLine, void (* DestroyCallback)(void*), void* pCallbackParam) +{ + return _BitmapUtil::ChangeBuffer(srcBitmap, pBuffer, bytesPerLine, DestroyCallback, pCallbackParam); +} + +bool +_BitmapTool::SetCallback(Tizen::Graphics::Bitmap& bitmap, + void (* DestroyCallback)(void*), void* pCallbackParam, + void (* LockCallback)(void*), void* pLockParam, + void (* UnlockCallback)(void*), void* pUnlockParam) +{ + return _BitmapUtil::SetCallback(bitmap, DestroyCallback, pCallbackParam, LockCallback, pLockParam, UnlockCallback, pUnlockParam); +} + +void +_BitmapTool::ResetCallback(Tizen::Graphics::Bitmap& bitmap) +{ + _BitmapUtil::ResetCallback(bitmap); +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_BitmapUtil.cpp b/src/graphics/FGrp_BitmapUtil.cpp new file mode 100644 index 0000000..08d4ccc --- /dev/null +++ b/src/graphics/FGrp_BitmapUtil.cpp @@ -0,0 +1,302 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_BitmapUtil.cpp + * @brief This is the cpp file for internal util class. + * + */ + +#include +#include + +#include + +#include + +#include "FGrp_BitmapUtil.h" +#include "FGrp_Bitmap.h" +#include "FGrp_ResUtil.h" +#include "util/FGrp_UtilTemplate.h" + + +namespace Tizen { namespace Graphics +{ + +unsigned long _GetBitmapTimeStamp(const Tizen::Graphics::_BitmapImpl& bitmap); +unsigned long _UpdateBitmapTimeStamp(Tizen::Graphics::_BitmapImpl& bitmap); + +BitmapTemp::BitmapTemp(Canvas& canvas) + : _BitmapImpl() + , __isValid(false) +{ + BufferInfo canvasDesc; + result r = canvas.Lock(canvasDesc); + + if (r == E_SUCCESS) + { + { + // + // ykahn 2011/07/25 + // + int pixelPerLine = canvasDesc.pitch / (canvasDesc.bitsPerPixel / 8); + + // 'pitch' can be a negative value + pixelPerLine = (pixelPerLine >= 0) ? pixelPerLine : -pixelPerLine; + + // new width = max(pixelPerLine, canvasDesc.width) + canvasDesc.width = (pixelPerLine > canvasDesc.width) ? pixelPerLine : canvasDesc.width; + } + + this->_sharedItem->nativeBitmap->Construct((void*) canvasDesc.pPixels, canvasDesc.width, canvasDesc.height, + canvasDesc.bitsPerPixel); + + Dimension pc_dim(canvasDesc.width, canvasDesc.height); + Dimension vc_dim(canvas.GetBounds().width, canvas.GetBounds().height); + + _ResUtil::Rect vc_rect(0, 0, vc_dim.width, vc_dim.height); + _ResUtil::Rect pc_rect(0, 0, pc_dim.width, pc_dim.height); + + this->_sharedItem->coordHolder->bitmapSize.required = vc_rect; + this->_sharedItem->coordHolder->bitmapSize.phyCoord = pc_rect; + this->_sharedItem->coordHolder->bitmapSize.virCoord = vc_rect; + + canvas.Unlock(); + + __isValid = true; + } +} + +BitmapTemp::BitmapTemp(void* pBuffer, int width, int height, int depth) + : _BitmapImpl() + , __isValid(false) +{ + if (pBuffer == null || width <= 0 || height <= 0 || !(depth == 16 || depth == 32)) + { + return; + } + + result r = this->_sharedItem->nativeBitmap->Construct((void*) pBuffer, width, height, depth); + + if (r != E_SUCCESS) + { + return; + } + + Dimension pc_dim(width, height); + Dimension vc_dim = _ResUtil::ConvertToVirCoord(pc_dim); + + _ResUtil::Rect vc_rect(0, 0, vc_dim.width, vc_dim.height); + _ResUtil::Rect pc_rect(0, 0, pc_dim.width, pc_dim.height); + + this->_sharedItem->coordHolder->bitmapSize.required = vc_rect; + this->_sharedItem->coordHolder->bitmapSize.phyCoord = pc_rect; + this->_sharedItem->coordHolder->bitmapSize.virCoord = vc_rect; + + __isValid = true; +} + +BitmapTemp::BitmapTemp(Dimension physicalSize, int depth) + : _BitmapImpl() + , __isValid(false) +{ + if (physicalSize.width <= 0 || physicalSize.height <= 0 || !(depth == 16 || depth == 32)) + { + return; + } + + result r = this->_sharedItem->nativeBitmap->Construct(physicalSize, (depth == 32) ? BITMAP_PIXEL_FORMAT_ARGB8888 : BITMAP_PIXEL_FORMAT_RGB565); + + if (r != E_SUCCESS) + { + return; + } + + Dimension pcDim(physicalSize.width, physicalSize.height); + Dimension vcDim = _ResUtil::ConvertToVirCoord(pcDim); + + _ResUtil::Rect vcRect(0, 0, vcDim.width, vcDim.height); + _ResUtil::Rect pcRect(0, 0, pcDim.width, pcDim.height); + + this->_sharedItem->coordHolder->bitmapSize.required = vcRect; + this->_sharedItem->coordHolder->bitmapSize.phyCoord = pcRect; + this->_sharedItem->coordHolder->bitmapSize.virCoord = vcRect; + + __isValid = true; +} + +BitmapTemp::~BitmapTemp() +{ +} + +bool +BitmapTemp::IsValid(void) +{ + return __isValid; +} + +//////////////////////////////////////////////////////////////////////////////// + +unsigned long +Tizen::Graphics::_BitmapUtil::GetTimeStamp(const Tizen::Graphics::Bitmap& bitmap) +{ + const Tizen::Graphics::_BitmapImpl* pBitmapImpl = Tizen::Graphics::_BitmapImpl::GetInstance(bitmap); + + if (pBitmapImpl) + { + return _GetBitmapTimeStamp(*pBitmapImpl); + } + + return 0; +} + +unsigned long +Tizen::Graphics::_BitmapUtil::UpdateTimeStamp(Tizen::Graphics::Bitmap& bitmap) +{ + Tizen::Graphics::_BitmapImpl* pBitmapImpl = Tizen::Graphics::_BitmapImpl::GetInstance(bitmap); + + if (pBitmapImpl) + { + return _UpdateBitmapTimeStamp(*pBitmapImpl); + } + + return 0; +} + +Tizen::Graphics::Bitmap* +Tizen::Graphics::_BitmapUtil::CreateBitmapN(_BitmapImpl* pBitmapImpl) +{ + if (pBitmapImpl == null) + { + return 0; + } + + std::auto_ptr bitmap(new (std::nothrow) Tizen::Graphics::Bitmap); + + SysTryReturn(NID_GRP, bitmap.get() != 0, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + // change the implentation instance of Bitmap class + { + // exception of ICLS-CLSIF-03 + class _BitmapImplHack + : public _BitmapImpl + { + public: + static _BitmapImpl*& GetBitmapImplRef(Bitmap* pBitmap) + { + return _BitmapImpl::_GetBitmapImpl(pBitmap); + } + }; // _BitmapImplHack + + Tizen::Graphics::_BitmapImpl*& pRefBitmapImpl = _BitmapImplHack::GetBitmapImplRef(bitmap.get()); + + delete pRefBitmapImpl; + pRefBitmapImpl = pBitmapImpl; + } + + return bitmap.release(); +} + +Tizen::Graphics::Bitmap* +Tizen::Graphics::_BitmapUtil::CreateBitmapN(void* pBuffer, int width, int height, int depth) +{ + std::auto_ptr bitmapTemp(new (std::nothrow) Tizen::Graphics::BitmapTemp(pBuffer, width, height, + depth)); + + SysTryReturn(NID_GRP, bitmapTemp.get() && bitmapTemp->IsValid(), 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + Tizen::Graphics::Bitmap* pBitmap = Tizen::Graphics::_BitmapUtil::CreateBitmapN(bitmapTemp.get()); + + if (pBitmap) + { + // abandon ownership + bitmapTemp.release(); + } + + return pBitmap; +} + +Tizen::Graphics::Bitmap* +Tizen::Graphics::_BitmapUtil::CreateBitmapN(Dimension physicalSize, int depth) +{ + std::auto_ptr bitmapTemp(new (std::nothrow) Tizen::Graphics::BitmapTemp(physicalSize, depth)); + + SysTryReturn(NID_GRP, bitmapTemp.get() && bitmapTemp->IsValid(), 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + Tizen::Graphics::Bitmap* pBitmap = Tizen::Graphics::_BitmapUtil::CreateBitmapN(bitmapTemp.get()); + + if (pBitmap) + { + // abandon ownership + bitmapTemp.release(); + } + + return pBitmap; +} + +result +Tizen::Graphics::_BitmapUtil::ChangeBuffer(Tizen::Graphics::Bitmap& srcBitmap, void* pBuffer, long bytesPerLine, void (* DestroyCallback)(void*), void* pCallbackParam) +{ + if (_BitmapImpl::GetInstance(srcBitmap) == null) + { + return E_SYSTEM; + } + + _Bitmap* pNativeBitmap = GetBitmapEx(srcBitmap); + + if (pNativeBitmap == null) + { + return E_SYSTEM; + } + + if (!SetCallback(srcBitmap, DestroyCallback, pCallbackParam, null, null, null, null)) + { + return E_SYSTEM; + } + + pNativeBitmap->AssignUserBuffer((unsigned char*) pBuffer, bytesPerLine); + + return E_SUCCESS; +} + +bool +Tizen::Graphics::_BitmapUtil::SetCallback(Tizen::Graphics::Bitmap& bitmap, + void (* DestroyCallback)(void*), void* pCallbackParam, + void (* LockCallback)(void*), void* pLockParam, + void (* UnlockCallback)(void*), void* pUnlockParam) +{ + Tizen::Graphics::_BitmapImpl* pBitmapImpl = _BitmapImpl::GetInstance(bitmap); + + _BitmapImplHack* pBitmapImplHack = static_cast <_BitmapImplHack*>(pBitmapImpl); + + return (pBitmapImplHack) ? pBitmapImplHack->SetCallback(DestroyCallback, pCallbackParam, LockCallback, pLockParam, UnlockCallback, pUnlockParam) : false; +} + +void +Tizen::Graphics::_BitmapUtil::ResetCallback(Tizen::Graphics::Bitmap& bitmap) +{ + Tizen::Graphics::_BitmapImpl* pBitmapImpl = _BitmapImpl::GetInstance(bitmap); + + _BitmapImplHack* pBitmapImplHack = static_cast <_BitmapImplHack*>(pBitmapImpl); + + if (pBitmapImplHack) + { + pBitmapImplHack->ResetCallback(); + } +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_BitmapUtil.h b/src/graphics/FGrp_BitmapUtil.h new file mode 100644 index 0000000..3ed8769 --- /dev/null +++ b/src/graphics/FGrp_BitmapUtil.h @@ -0,0 +1,218 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_BitmapUtil.h + * @brief This is the header file for _BitmapUtil namespace. + * + */ + +#ifndef _FGRP_INTERNAL_BITMAPUTIL_H_ +#define _FGRP_INTERNAL_BITMAPUTIL_H_ + +#include + +#include + +#include "FGrp_BitmapImpl.h" +#include "FGrp_BitmapCoordHolder.h" + + +namespace Tizen { namespace Graphics +{ + +namespace _BitmapUtil +{ + +unsigned long GetTimeStamp(const Tizen::Graphics::Bitmap& bitmap); + +unsigned long UpdateTimeStamp(Tizen::Graphics::Bitmap& bitmap); + +// the ownership of 'bitmapImpl' moves to the new Bitmap instance +Bitmap* CreateBitmapN(Tizen::Graphics::_BitmapImpl* bitmapImpl); + +// it doesn't move the ownership of 'pBuffer' +Bitmap* CreateBitmapN(void* pBuffer, int width, int height, int depth); + +// This function can create a raw bitmap from physical size +Bitmap* CreateBitmapN(Dimension physicalSize, int depth); + +// This function changes the buffer of the specified bitmap to the user defined buffer +// The user buffer size MUST be same as the original bitmap size +result ChangeBuffer(Tizen::Graphics::Bitmap& srcBitmap, void* pBuffer, long bytesPerLine, void (* DestroyCallback)(void*), void* pCallbackParam); + +bool SetCallback(Tizen::Graphics::Bitmap& bitmap, + void (* DestroyCallback)(void*), void* pCallbackParam, + void (* LockCallback)(void*), void* pLockParam, + void (* UnlockCallback)(void*), void* pUnlockParam); + +void ResetCallback(Tizen::Graphics::Bitmap& bitmap); + +} // Tizen::Graphics::_BitmapUtil + + +class BitmapTemp + : public _BitmapImpl +{ +public: + BitmapTemp(Canvas& canvas); + BitmapTemp(void* pBuffer, int width, int height, int depth); + BitmapTemp(Dimension physicalSize, int depth); + + virtual ~BitmapTemp(); + + bool IsValid(void); + +private: + bool __isValid; + +}; // BitmapTemp + +}} // Tizen::Graphics + + +namespace Tizen { namespace Graphics +{ + +class _BitmapImplHack + : public _BitmapImpl +{ +public: + _Bitmap* GetBitmapEx(void) const + { + return (this && this->_sharedItem.get()) ? this->_sharedItem->nativeBitmap.get() : 0; + } + + _Bitmap* GetScaledBitmapEx(void) const + { + return (this && this->_sharedItem.get()) ? this->_sharedItem->scaledNativeBitmap.get() : 0; + } + + bool IsLazyScalingBitmap(void) const + { + return (this && this->_sharedItem.get()) ? (this->_sharedItem->lazyScaling != 0) : false; + } + + bool IsLazyScalingBitmap(Tizen::Graphics::Dimension& virSize, Tizen::Graphics::Dimension& phySize) const + { + if (this->_sharedItem.get() == 0 || this->_sharedItem->lazyScaling == 0) + { + return false; + } + + virSize.width = this->_sharedItem->coordHolder->bitmapSize.virCoord.w; + virSize.height = this->_sharedItem->coordHolder->bitmapSize.virCoord.h; + phySize.width = this->_sharedItem->coordHolder->bitmapSize.phyCoord.w; + phySize.height = this->_sharedItem->coordHolder->bitmapSize.phyCoord.h; + + return true; + } + + bool SetCallback(void (* DestroyCallback)(void*), void* pDestroyCallbackParam, + void (* LockCallback)(void*), void* pLockCallbackParam, + void (* UnlockCallback)(void*), void* pUnlockCallbackParam) + { + if (this->_sharedItem.get() == 0) + { + return false; + } + + return this->_SetCallback(DestroyCallback, pDestroyCallbackParam, LockCallback, pLockCallbackParam, UnlockCallback, pUnlockCallbackParam); + } + + void ResetCallback(void) + { + if (this->_sharedItem.get() == 0) + { + return; + } + + this->_sharedItem->pDestroyCallbackFunc = null; + this->_sharedItem->pDestroyCallbackParam = null; + this->_sharedItem->pLockCallbackFunc = null; + this->_sharedItem->pLockCallbackParam = null; + this->_sharedItem->pUnlockCallbackFunc = null; + this->_sharedItem->pUnlockCallbackParam = null; + } + +}; // _BitmapImplHack + +inline _Bitmap* +GetBitmapEx(const Tizen::Graphics::_BitmapImpl& bitmap) +{ + const _BitmapImplHack* pBitmapImplHack = static_cast (&bitmap); + + return (pBitmapImplHack) ? pBitmapImplHack->GetBitmapEx() : null; +} + +inline _Bitmap* +GetScaledBitmapEx(const Tizen::Graphics::_BitmapImpl& bitmap) +{ + const _BitmapImplHack* pBitmapImplHack = static_cast (&bitmap); + + return (pBitmapImplHack) ? pBitmapImplHack->GetScaledBitmapEx() : null; +} + +inline bool +IsLazyScalingBitmap(const Tizen::Graphics::_BitmapImpl& bitmap) +{ + const _BitmapImplHack* pBitmapImplHack = static_cast (&bitmap); + + return (pBitmapImplHack) ? pBitmapImplHack->IsLazyScalingBitmap() : false; +} + +inline bool +IsLazyScalingBitmap(const Tizen::Graphics::_BitmapImpl& bitmap, Tizen::Graphics::Dimension& virSize, + Tizen::Graphics::Dimension& phySize) +{ + const _BitmapImplHack* pBitmapImplHack = static_cast (&bitmap); + + return (pBitmapImplHack) ? pBitmapImplHack->IsLazyScalingBitmap(virSize, phySize) : false; +} + +}} // Tizen::Graphics + +namespace Tizen { namespace Graphics +{ + +inline _Bitmap* +GetBitmapEx(const Tizen::Graphics::Bitmap& bitmap) +{ + return GetBitmapEx(*_BitmapImpl::GetInstance(bitmap)); +} + +inline _Bitmap* +GetScaledBitmapEx(const Tizen::Graphics::Bitmap& bitmap) +{ + return GetScaledBitmapEx(*_BitmapImpl::GetInstance(bitmap)); +} + +inline bool +IsLazyScalingBitmap(const Tizen::Graphics::Bitmap& bitmap) +{ + return IsLazyScalingBitmap(*_BitmapImpl::GetInstance(bitmap)); +} + +inline bool +IsLazyScalingBitmap(const Tizen::Graphics::Bitmap& bitmap, Tizen::Graphics::Dimension& virSize, Tizen::Graphics::Dimension& phySize) +{ + return IsLazyScalingBitmap(*_BitmapImpl::GetInstance(bitmap), virSize, phySize); +} + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_BITMAPUTIL_H_ diff --git a/src/graphics/FGrp_BufferInfoImpl.cpp b/src/graphics/FGrp_BufferInfoImpl.cpp new file mode 100644 index 0000000..602367d --- /dev/null +++ b/src/graphics/FGrp_BufferInfoImpl.cpp @@ -0,0 +1,164 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_BufferInfoImpl.cpp + * @brief This is the implementation file for %_BufferInfoImpl class. + * + */ + +#include + +#include "FGrp_BufferInfoImpl.h" + + +namespace Tizen { namespace Graphics +{ + +_BufferInfoImpl::_BufferInfoImpl() + : __handleType(HANDLE_TYPE_NONE) + , __handle(INVALID_BUFFER_HANDLE) + , __orientation(ORIENTATION_PORTRAIT) + , __rotation(ROTATION_0) +{ +} + +_BufferInfoImpl::_BufferInfoImpl(const _BufferInfoImpl& src) + : __handleType(src.__handleType) + , __handle(src.__handle) + , __orientation(src.__orientation) + , __rotation(ROTATION_0) +{ +} + +_BufferInfoImpl::~_BufferInfoImpl() +{ +} + +_BufferInfoImpl& +_BufferInfoImpl::operator =(const _BufferInfoImpl& rhs) +{ + if (this == &rhs) + { + return *this; + } + + this->__handle = rhs.__handle; + this->__orientation = rhs.__orientation; + + return *this; +} + +int +_BufferInfoImpl::GetHandle(HandleType handleType) const +{ + switch (handleType) + { + case HANDLE_TYPE_OVERLAY_REGION: + case HANDLE_TYPE_VE_SURFACE: + case HANDLE_TYPE_CANVAS_TEXTURE: + return (__handleType == handleType) ? __handle : INVALID_BUFFER_HANDLE; + case HANDLE_TYPE_NONE: + default: + return INVALID_BUFFER_HANDLE; + } +} + +void +_BufferInfoImpl::SetHandle(HandleType handleType, int handle) +{ + switch (handleType) + { + case HANDLE_TYPE_NONE: + __handleType = HANDLE_TYPE_NONE; + __handle = INVALID_BUFFER_HANDLE; + break; + case HANDLE_TYPE_OVERLAY_REGION: + case HANDLE_TYPE_VE_SURFACE: + case HANDLE_TYPE_CANVAS_TEXTURE: + __handleType = handleType; + __handle = handle; + break; + } +} + +_BufferInfoImpl::Orientation +_BufferInfoImpl::GetOrientation(void) const +{ + return __orientation; +} + +void +_BufferInfoImpl::SetOrientation(_BufferInfoImpl::Orientation orientation) +{ + if (orientation >= ORIENTATION_PORTRAIT && orientation <= ORIENTATION_LANDSCAPE_REVERSE) + { + __orientation = orientation; + } + else + { + __orientation = ORIENTATION_PORTRAIT; + } +} + +Rectangle +_BufferInfoImpl::GetBounds(void) const +{ + return __bounds; +} + +void +_BufferInfoImpl::SetBounds(const Rectangle& bounds) +{ + __bounds.x = bounds.x; + __bounds.y = bounds.y; + __bounds.width = bounds.width; + __bounds.height = bounds.height; +} + +_BufferInfoImpl::Rotation +_BufferInfoImpl::GetRotation(void) const +{ + return __rotation; +} + +void +_BufferInfoImpl::SetRotation(_BufferInfoImpl::Rotation rotation) +{ + if (rotation >= ROTATION_0 && rotation <= ROTATION_270) + { + __rotation = rotation; + } + else + { + __rotation = ROTATION_0; + } +} + +_BufferInfoImpl* +_BufferInfoImpl::GetInstance(BufferInfo& bufferInfo) +{ + return (&bufferInfo != null) ? bufferInfo.__pImpl : null; +} + +const _BufferInfoImpl* +_BufferInfoImpl::GetInstance(const BufferInfo& bufferInfo) +{ + return (&bufferInfo != null) ? bufferInfo.__pImpl : null; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_Callback.cpp b/src/graphics/FGrp_Callback.cpp new file mode 100644 index 0000000..7861394 --- /dev/null +++ b/src/graphics/FGrp_Callback.cpp @@ -0,0 +1,48 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Callback.cpp + * @brief This is the implementation file for the callback functions in Tizen::Graphics namespace. + * + */ + +#include "FGrp_Callback.h" + +namespace Tizen { namespace Graphics +{ + void* (*_GetDefaultFrameEcoreEvasHandle)(void) = _GetNull; + void* (*_GetDefaultFrameEvasHandle)(void) = _GetNull; + Color (*_GetDefaultForegroundColor)(void) = _GetBlack; + Color (*_GetDefaultBackgroundColor)(void) = _GetWhite; + + void* _GetNull(void) + { + return 0; + } + + Color _GetWhite(void) + { + return Color(0xFFFFFFFF); + } + + Color _GetBlack(void) + { + return Color(0xFF000000); + } + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_Callback.h b/src/graphics/FGrp_Callback.h new file mode 100644 index 0000000..88a2761 --- /dev/null +++ b/src/graphics/FGrp_Callback.h @@ -0,0 +1,42 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Callback.h + * @brief This is the header file for the callback functions in Tizen::Graphics namespace. + * + */ + +#ifndef _FGRP_INTERNAL_CALLBACK_H_ +#define _FGRP_INTERNAL_CALLBACK_H_ + +#include + +namespace Tizen { namespace Graphics +{ + extern void* (*_GetDefaultFrameEcoreEvasHandle)(void); + extern void* (*_GetDefaultFrameEvasHandle)(void); + extern Color (*_GetDefaultForegroundColor)(void); + extern Color (*_GetDefaultBackgroundColor)(void); + + void* _GetNull(void); + Color _GetWhite(void); + Color _GetBlack(void); + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_CALLBACK_H_ diff --git a/src/graphics/FGrp_Canvas.cpp b/src/graphics/FGrp_Canvas.cpp new file mode 100644 index 0000000..8a734bc --- /dev/null +++ b/src/graphics/FGrp_Canvas.cpp @@ -0,0 +1,3932 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Canvas.cpp + * @brief This is the implementation file for _Canvas class. + * + */ + +#include +#include + +#include +#include + +#include + +#include + +#include + +#include +#include + +#include + +#include "FGrp_BufferInfoImpl.h" +#include "FGrp_Callback.h" +#include "FGrp_Canvas.h" +#include "FGrp_CanvasGpPrimitive.h" +#include "FGrp_CanvasRasterOp.h" +#include "FGrp_Bitmap.h" +#include "FGrp_Font.h" +#include "FGrp_Screen.h" +#include "FGrp_ResUtil.h" +#include "FGrp_CanvasCairo.h" +#include "FGrp_CanvasPixman.h" +#include "util/FGrp_Util.h" +#include "effect/FGrp_Effect.h" + +//////////////////////////////////////////////////////////////////////////////// + +#if !defined(M_PI) +#define M_PI 3.14159265358979323846 +#endif + +#define USE_CAIRO + +//////////////////////////////////////////////////////////////////////////////// + +#define SET_CAIRO_DASH_STYLE \ + _Cairo::SetDash(pCairo->pCairo, this->__dashData.pattern.Begin(), int(this->__dashData.pattern.Size()), this->__dashData.offset) + +#define RESET_CAIRO_DASH_STYLE \ + _Cairo::ResetDash(pCairo->pCairo) + +#define SET_CAIRO_CLIPPING \ + if (this->__isClipBoundsSet) \ + { \ + _Cairo::SetClip(pCairo->pCairo, this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); \ + } + +#define RESET_CAIRO_CLIPPING \ + if (this->__isClipBoundsSet) \ + { \ + _Cairo::ResetClip(pCairo->pCairo); \ + } + +#define SET_CAIRO_BLENDING \ + _Cairo::SetBlending(pCairo->pCairo, _ConvertParam(this->__blendingMode)); + +#define RESET_CAIRO_BLENDING \ + _Cairo::SetBlending(pCairo->pCairo, CAIRO_OPERATOR_OVER); + + +//////////////////////////////////////////////////////////////////////////////// + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; + +//////////////////////////////////////////////////////////////////////////////// +// internal utility + +namespace +{ + +template +Dest _ConvertParam(Sour val); + +template<> +Tizen::Graphics::_Effect::Rop +_ConvertParam(Tizen::Graphics::_Canvas::BlendOption blendOption) +{ + switch (blendOption) + { + case Tizen::Graphics::_Canvas::BLEND_COPY: + return Tizen::Graphics::_Effect::ROP_COPY; + case Tizen::Graphics::_Canvas::BLEND_ALPHABLEND: + return Tizen::Graphics::_Effect::ROP_ALPHABLEND; + default: + return Tizen::Graphics::_Effect::ROP_ALPHABLEND; + } +} + +template<> +cairo_operator_t +_ConvertParam(Tizen::Graphics::BlendingMode blendingMode) +{ + switch (blendingMode) + { + case Tizen::Graphics::BLENDING_MODE_CLEAR: + return CAIRO_OPERATOR_CLEAR; + case Tizen::Graphics::BLENDING_MODE_SRC: + return CAIRO_OPERATOR_SOURCE; + case Tizen::Graphics::BLENDING_MODE_DST: + return CAIRO_OPERATOR_DEST; + case Tizen::Graphics::BLENDING_MODE_SRC_OVER: + return CAIRO_OPERATOR_OVER; + case Tizen::Graphics::BLENDING_MODE_DST_OVER: + return CAIRO_OPERATOR_DEST_OVER; + case Tizen::Graphics::BLENDING_MODE_SRC_IN: + return CAIRO_OPERATOR_IN; + case Tizen::Graphics::BLENDING_MODE_DST_IN: + return CAIRO_OPERATOR_DEST_IN; + case Tizen::Graphics::BLENDING_MODE_SRC_OUT: + return CAIRO_OPERATOR_OUT; + case Tizen::Graphics::BLENDING_MODE_DST_OUT: + return CAIRO_OPERATOR_DEST_OUT; + case Tizen::Graphics::BLENDING_MODE_SRC_ATOP: + return CAIRO_OPERATOR_ATOP; + case Tizen::Graphics::BLENDING_MODE_DST_ATOP: + return CAIRO_OPERATOR_DEST_ATOP; + case Tizen::Graphics::BLENDING_MODE_DST_XOR: + return CAIRO_OPERATOR_XOR; + case Tizen::Graphics::BLENDING_MODE_ADD: + return CAIRO_OPERATOR_ADD; + case Tizen::Graphics::BLENDING_MODE_SATURATE: + return CAIRO_OPERATOR_SATURATE; + default: + return CAIRO_OPERATOR_OVER; + } +} + +inline unsigned short +_ConvertRGB888ToRGB565(unsigned char red, unsigned char green, unsigned char blue) +{ + typedef unsigned short ColorType; + + return (ColorType(red >> 3) << 11) | (ColorType(green >> 2) << 5) | ColorType(blue >> 3); +} + +Evas_Object* +_GetWindowSourceObject(Handle handle) +{ + Evas_Object* pSourceObject = evas_object_image_source_get((Evas_Object*) handle); + + return (pSourceObject) ? pSourceObject : (Evas_Object*) handle; +} + +int +_GetWindowWidth(Handle handle) +{ + int width = 0; + int height = 0; + + evas_object_image_size_get(_GetWindowSourceObject(handle), &width, &height); + + return width; +} + +int +_GetWindowHeight(Handle handle) +{ + int width = 0; + int height = 0; + + evas_object_image_size_get(_GetWindowSourceObject(handle), &width, &height); + + return height; +} + +/////////////////////////////////////////////// +// class _GenericBufferFrameBuffer + +template +class _GenericBufferFrameBuffer + : public Tizen::Graphics::_Util::GenericBufferBase +{ +public: + _GenericBufferFrameBuffer(Handle handle, int _width, int _height) + { + this->__pAssociatedBuffer = this->_pBuffer = (Pixel*) evas_object_image_data_get(_GetWindowSourceObject(handle), EINA_TRUE); + + int pitch = evas_object_image_stride_get(_GetWindowSourceObject(handle)) / int(sizeof(Pixel)); + pitch = (pitch) ? pitch : _width; + + if (this->_pBuffer == null) + { + SysLog(NID_GRP, "[] evas_object_image_data_get(%d) failed!", handle); + } + + this->_pitch = pitch; + this->_padding = this->_pitch - _width; + this->_rect.x = 0; + this->_rect.y = 0; + this->_rect.w = _width; + this->_rect.h = _height; + this->_pHandle = reinterpret_cast(handle); + + this->__associatedHandle = handle; + this->__hasOwnership = false; + } + + _GenericBufferFrameBuffer(Handle handle, int _x, int _y, int _width, int _height, int pitch) + { + this->__pAssociatedBuffer = this->_pBuffer = (Pixel*) evas_object_image_data_get(_GetWindowSourceObject(handle), EINA_TRUE); + + if (pitch == 0) + { + pitch = evas_object_image_stride_get(_GetWindowSourceObject(handle)) / int(sizeof(Pixel)); + pitch = (pitch) ? pitch : _GetWindowWidth(handle); + } + + if (this->_pBuffer == null) + { + SysLog(NID_GRP, "[] evas_object_image_data_get(%d) failed!", handle); + } + + this->_pBuffer += (_y * pitch + _x); + + this->_pitch = pitch; + this->_padding = this->_pitch - _width; + this->_rect.x = _x; + this->_rect.y = _y; + this->_rect.w = _width; + this->_rect.h = _height; + this->_pHandle = reinterpret_cast(handle); + + this->__associatedHandle = handle; + this->__hasOwnership = false; + } + + _GenericBufferFrameBuffer(int width, int height) + : __pAssociatedBuffer(0) + { + this->_pBuffer = new (std::nothrow) Pixel[width * height]; + + if (this->_pBuffer == null) + { + width = 0; + height = 0; + } + + this->_pitch = width; + this->_padding = this->_pitch - width; + this->_rect.x = 0; + this->_rect.y = 0; + this->_rect.w = width; + this->_rect.h = height; + this->_pHandle = 0; + + this->__associatedHandle = 0; + this->__hasOwnership = (this->_pBuffer != null); + } + + _GenericBufferFrameBuffer(Pixel* pBuffer, int width, int height, int pitch) + : __pAssociatedBuffer(0) + { + this->_pBuffer = pBuffer; + + this->_pitch = pitch; + this->_padding = this->_pitch - width; + this->_rect.x = 0; + this->_rect.y = 0; + this->_rect.w = width; + this->_rect.h = height; + this->_pHandle = 0; + + this->__associatedHandle = 0; + this->__hasOwnership = false; + } + + virtual ~_GenericBufferFrameBuffer(void) + { + if (this->__associatedHandle != 0 && this->__pAssociatedBuffer != null) + { + evas_object_image_data_set(_GetWindowSourceObject(this->__associatedHandle), this->__pAssociatedBuffer); + } + + if (this->__hasOwnership) + { + delete[] this->_pBuffer; + this->_pBuffer = 0; + } + } + +private: + _GenericBufferFrameBuffer(const _GenericBufferFrameBuffer&); + _GenericBufferFrameBuffer& operator =(const _GenericBufferFrameBuffer&); + + void* __pAssociatedBuffer; + Handle __associatedHandle; + bool __hasOwnership; + +}; + +} + + +namespace +{ + +enum _ClipResult +{ + CLIP_REJECT, // Clipped rejected + CLIP_CLIPPED, // Clipped accepted + CLIP_ACCEPT // Accepted +}; + +_ClipResult +_ClipRectangle(int& srcX, int& srcY, int& srcW, int& srcH, int clipX, int clipY, int clipW, int clipH) +{ + if (clipW <= 0 || clipH <= 0) + { + return CLIP_REJECT; + } + + _ClipResult returnValue = CLIP_ACCEPT; + + int srcEndX = srcX + srcW - 1; + int srcEndY = srcY + srcH - 1; + int clipEndX = clipX + clipW - 1; + int clipEndY = clipY + clipH - 1; + + if (srcX > clipEndX || srcEndX < clipX) + { + return CLIP_REJECT; + } + + if (srcY > clipEndY || srcEndY < clipY) + { + return CLIP_REJECT; + } + + if (srcX < clipX) + { + srcX = clipX; + + returnValue = CLIP_CLIPPED; + } + + if (srcEndX > clipEndX) + { + srcEndX = clipEndX; + + returnValue = CLIP_CLIPPED; + } + + if (srcY < clipY) + { + srcY = clipY; + + returnValue = CLIP_CLIPPED; + } + + if (srcEndY > clipEndY) + { + srcEndY = clipEndY; + + returnValue = CLIP_CLIPPED; + } + + srcW = srcEndX - srcX + 1; + srcH = srcEndY - srcY + 1; + + return returnValue; +} + +unsigned long +_ComposeColor(unsigned long color32, int opacity) +{ + unsigned char alpha = (unsigned char) (((color32) >> 24)); + unsigned char red = (unsigned char) (((color32) >> 16)); + unsigned char green = (unsigned char) (((color32) >> 8)); + unsigned char blue = (unsigned char) ((color32)); + + alpha = (unsigned char) ((alpha * opacity + 255) >> 8); + red = (unsigned char) ((red * opacity + 255) >> 8); + green = (unsigned char) ((green * opacity + 255) >> 8); + blue = (unsigned char) ((blue * opacity + 255) >> 8); + + return (unsigned long) (((unsigned long) (alpha) << 24) | ((unsigned long) (red) << 16) | ((unsigned long) (green) << 8) | (unsigned long) (blue)); +} + +template +void +_ClearRectangleWithClip(Tizen::Graphics::_Util::ScratchPad* pScratchPad, Pixel color, const Tizen::Graphics::_Util::Rectangle& rect, const Tizen::Graphics::_Util::Rectangle& clip) +{ + if (pScratchPad == null) + { + return; + } + + // clipping + int x1 = rect.x; + int y1 = rect.y; + int x2 = x1 + rect.w; + int y2 = y1 + rect.h; + + x1 = (x1 >= clip.x) ? x1 : clip.x; + y1 = (y1 >= clip.y) ? y1 : clip.y; + + x2 = (x2 <= clip.x + clip.w) ? x2 : clip.x + clip.w; + y2 = (y2 <= clip.y + clip.h) ? y2 : clip.y + clip.h; + + if ((x2 - x1) > 0 && (y2 - y1) > 0) + { + pScratchPad->FillRect(x1, y1, x2 - x1, y2 - y1, color); + } +} + +template +void +_FillRectangleWithClip(Tizen::Graphics::_Util::ScratchPad* pScratchPad, Pixel color, const Tizen::Graphics::_Util::Rectangle& rect, const Tizen::Graphics::_Util::Rectangle& clip) +{ + if (pScratchPad == null) + { + return; + } + + // alpha-fill-rect() applied + pScratchPad->RegisterFillRect(Tizen::Graphics::_RasterOp::FnFillRectAlpha32Bit); + _ClearRectangleWithClip(pScratchPad, color, rect, clip); + pScratchPad->RegisterFillRect(null); +} + +} + +namespace +{ + +typedef Tizen::Graphics::_Canvas::SystemPixel _SystemPixel; +typedef Tizen::Graphics::_Util::ScratchPad<_SystemPixel> _ScratchPad32; + +static std::unique_ptr<_SystemPixel[]> _systemFontBuffer; +static std::auto_ptr<_ScratchPad32> _systemFont; + +} + +//////////////////////////////////////////////////////////////////////////////// +// Tizen::Graphics::_Canvas + +namespace Tizen { namespace Graphics +{ + +bool _CanvasShowFromMemory(int xDest, int yDest, int xSour, int ySour, int wSour, int hSour, void* pMemory, int width, int height, int depth, int bytesPerLine); +void _FlushCanvas(void); + +namespace +{ + +void +_ApplySrcBitmapAttrib(_Util::Pixmap& srcImage, const _Bitmap& bitmap, long isOpaque) +{ + Color maskingColor; + + if (bitmap.GetBitsPerPixel() == 16) + { + if (bitmap.GetMaskingColor(maskingColor) == E_SUCCESS) + { + srcImage.enableColorKey = 1; + srcImage.colorKey = _ConvertRGB888ToRGB565(maskingColor.GetRed(), maskingColor.GetGreen(), maskingColor.GetBlue()); + } + } + + srcImage.isOpaque = isOpaque; + srcImage.isPremultiplied = bitmap.IsPremultiplied(); +} + +// retrieving bounds rectangle which has (0,0,w,h). +Rectangle +_GetBoundsRel(const _Canvas& canvas) +{ + Rectangle rect = canvas.GetBounds(); + rect.x = 0; + rect.y = 0; + + return rect; +} +} + +void +_FillRectangleWithClip32(_Util::ScratchPad* pScratchPad, unsigned long color, const _Util::Rectangle& rect, const _Util::Rectangle& clip) +{ + _FillRectangleWithClip(pScratchPad, color, rect, clip); +} + +struct _NativeGfxEngine +{ + cairo_t* pCairo; + cairo_surface_t* pCairoSurface; + + _NativeGfxEngine() + : pCairo(0) + , pCairoSurface(0) + { + } + ~_NativeGfxEngine() + { + if (pCairo) + { + cairo_destroy(pCairo); + } + + if (pCairoSurface) + { + cairo_surface_destroy(pCairoSurface); + } + } +}; + + +_Canvas::_Canvas(void) + : _pNativeGfxEngine(static_cast(new (std::nothrow)_NativeGfxEngine)) + , __pParent(0) + , __pFont(0) + , __pPriorityFont(0) + , __windowHandle(INVALID_HANDLE) + , __blendOption(Tizen::Graphics::_Canvas::BLEND_ALPHABLEND) + , __pSurface(0) + , __pScratchPad(0) + , __xBufferPos(0) + , __yBufferPos(0) + , __pBuffer(0) + , __fgColor(0xFFFFFFFF) + , __bgColor(0x00000000) + , __fgOpacity(255) + , __bgOpacity(255) + , __lineWidth(1) + , __lineStyle(LINE_STYLE_SOLID) + , __isClipBoundsSet(false) + , __textOrigin(TEXT_ORIGIN_LEFT_TOP) + , __applyEmoji(true) + , __bitmapDrawingQuality(BITMAP_DRAWING_QUALITY_LOW) + , __blendingMode(BLENDING_MODE_SRC_OVER) + , __useStableRenderer(true) +{ + __fgColorNative = Color(__fgColor); + __bgColorNative = Color(__bgColor); + + __dashData.offset = 0; + + __ComposeFgColor(); + __ComposeBgColor(); +} + +_Canvas::~_Canvas(void) +{ + delete __pScratchPad; + delete __pSurface; + + if (_pNativeGfxEngine) + { + delete static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + } +} + +result +_Canvas::Construct(void) +{ + return this->Construct(Rectangle(0, 0, _Screen::GetWidth(), _Screen::GetHeight())); +} + +result +_Canvas::Construct(const Rectangle& rect) +{ + result r = E_SUCCESS; + + _GenericBufferFrameBuffer* pTemp = new (std::nothrow) _GenericBufferFrameBuffer(rect.width, rect.height); + + SysTryReturnResult(NID_GRP, pTemp, E_OUT_OF_MEMORY, " _GenericBufferFrameBuffer<> cannot be allocated."); + + this->__pSurface = new (std::nothrow) _Util::GenericBuffer(pTemp); + + SysTryCatch(NID_GRP, this->__pSurface, delete pTemp; + r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] _Util::GenericBuffer<> cannot be allocated."); + + this->__pBuffer = (unsigned long*) __pSurface->GetBufferAddr(); + this->__pScratchPad = new (std::nothrow) _Util::ScratchPad(__pBuffer, rect.width, rect.height, rect.width); + + SysTryCatch(NID_GRP, this->__pScratchPad, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] _Util::ScratchPad<> cannot be allocated."); + + this->__pScratchPad->FillRect(0, 0, this->__pScratchPad->GetWidth(), this->__pScratchPad->GetHeight(), 0x00000000); + + this->__xBufferPos = rect.x; + this->__yBufferPos = rect.y; + +#if defined(USE_CAIRO) + { + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo) + { + pCairo->pCairoSurface = cairo_image_surface_create_for_data((unsigned char*) this->__pBuffer, CAIRO_FORMAT_ARGB32, rect.width, rect.height, rect.width * 4); + pCairo->pCairo = cairo_create(pCairo->pCairoSurface); + } + } +#endif + + __InitFgBgColorFromTheme(); + + return E_SUCCESS; + +CATCH: + delete this->__pScratchPad; + this->__pScratchPad = null; + + delete this->__pSurface; + this->__pSurface = null; + + return r; +} + +result +_Canvas::Construct(Handle windowHandle, const Rectangle& rect) +{ + SysTryReturnResult(NID_GRP, rect.width >= 0 && rect.height >= 0, E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.\n", rect.width, rect.height); + + result r = E_SUCCESS; + + int x1 = rect.x; + int y1 = rect.y; + int x2 = x1 + rect.width; + int y2 = y1 + rect.height; + + if (x1 < 0) + { + x1 = 0; + } + + if (y1 < 0) + { + y1 = 0; + } + + if (x2 > _GetWindowWidth(windowHandle)) + { + x2 = _GetWindowWidth(windowHandle); + } + + if (y2 > _GetWindowHeight(windowHandle)) + { + y2 = _GetWindowHeight(windowHandle); + } + + SysTryReturnResult(NID_GRP, (x2 - x1 >= 0) && (y2 - y1 >= 0), E_OUT_OF_RANGE, "The given rectangle(x1:%d,y1:%d,x2:%d,y2:%d) is out of range.", x1, y1, x2, y2); + + int bufferWidth = x2 - x1; + int bufferHeight = y2 - y1; + int sourcePitch = 0; + + _GenericBufferFrameBuffer* pTemp = new (std::nothrow) _GenericBufferFrameBuffer(windowHandle, x1, y1, bufferWidth, bufferHeight, 0); + + SysTryReturnResult(NID_GRP, pTemp, E_OUT_OF_MEMORY, "_GenericBufferFrameBuffer<> cannot be allocated."); + + this->__pSurface = new (std::nothrow) _Util::GenericBuffer(pTemp); + + SysTryCatch(NID_GRP, this->__pSurface, delete pTemp; + r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] _Util::GenericBuffer<> cannot be allocated."); + + this->__pBuffer = (unsigned long*) __pSurface->GetBufferAddr(); + sourcePitch = __pSurface->GetPitch(); + + this->__pScratchPad = new (std::nothrow) _Util::ScratchPad(__pBuffer, bufferWidth, bufferHeight, sourcePitch); + + SysTryCatch(NID_GRP, this->__pScratchPad, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] _Util::ScratchPad<> cannot be allocated."); + + this->__windowHandle = windowHandle; + + this->__xBufferPos = x1; + this->__yBufferPos = y1; + +#if defined(USE_CAIRO) + { + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo) + { + pCairo->pCairoSurface = cairo_image_surface_create_for_data((unsigned char*) this->__pBuffer, CAIRO_FORMAT_ARGB32, bufferWidth, bufferHeight, sourcePitch * 4); + pCairo->pCairo = cairo_create(pCairo->pCairoSurface); + } + } +#endif + + __InitFgBgColorFromTheme(); + + return E_SUCCESS; + +CATCH: + delete this->__pScratchPad; + this->__pScratchPad = null; + + delete this->__pSurface; + this->__pSurface = null; + + return r; +} + +result +_Canvas::Construct(_Canvas* pSourceCanvas, const Rectangle& subRegion) +{ + SysTryReturnResult(NID_GRP, pSourceCanvas, E_INVALID_ARG, "The source canvas is invalid"); + + SysTryReturnResult(NID_GRP, pSourceCanvas->IsValid(), E_INVALID_ARG, "The source canvas is invalid"); + + result r = E_SUCCESS; + + int x1 = subRegion.x; + int y1 = subRegion.y; + int x2 = x1 + subRegion.width; + int y2 = y1 + subRegion.height; + + if (x1 < 0) + { + x1 = 0; + } + + if (y1 < 0) + { + y1 = 0; + } + + if (x2 > pSourceCanvas->GetBounds().width) + { + x2 = pSourceCanvas->GetBounds().width; + } + + if (y2 > pSourceCanvas->GetBounds().height) + { + y2 = pSourceCanvas->GetBounds().height; + } + + SysTryReturnResult(NID_GRP, (x2 - x1 > 0) && (y2 - y1 > 0), E_OUT_OF_RANGE, "The given rectangle(x1:%d,y1:%d,x2:%d,y2:%d) is out of range.", subRegion.x, subRegion.y, subRegion.width, subRegion.height); + + int bufferWidth = x2 - x1; + int bufferHeight = y2 - y1; + + int sourcePitch = pSourceCanvas->__pSurface->GetPitch(); + + if (pSourceCanvas->__windowHandle != INVALID_HANDLE) + { + _GenericBufferFrameBuffer* pTemp = new (std::nothrow) _GenericBufferFrameBuffer(pSourceCanvas->__windowHandle, x1, y1, bufferWidth, bufferHeight, sourcePitch); + + SysTryReturnResult(NID_GRP, pTemp, E_OUT_OF_MEMORY, "_GenericBufferFrameBuffer<> cannot be allocated."); + + this->__pSurface = new (std::nothrow) _Util::GenericBuffer(pTemp); + + if (this->__pSurface == null) + { + delete pTemp; + SysTryReturnResult(NID_GRP, false, E_OUT_OF_MEMORY, "_Util::GenericBuffer<> cannot be allocated."); + } + } + else + { + SystemPixel* pBuffer = pSourceCanvas->__pSurface->GetBufferAddr(); + pBuffer += y1 * sourcePitch + x1; + + _GenericBufferFrameBuffer* pTemp = new (std::nothrow) _GenericBufferFrameBuffer(pBuffer, bufferWidth, bufferHeight, sourcePitch); + + SysTryReturnResult(NID_GRP, pTemp, E_OUT_OF_MEMORY, "_GenericBufferFrameBuffer<> cannot be allocated."); + + this->__pSurface = new (std::nothrow) _Util::GenericBuffer(pTemp); + + if (this->__pSurface == null) + { + delete pTemp; + SysTryReturnResult(NID_GRP, false, E_OUT_OF_MEMORY, "_Util::GenericBuffer<> cannot be allocated."); + } + } + + this->__pBuffer = (unsigned long*) __pSurface->GetBufferAddr(); + this->__pScratchPad = new (std::nothrow) _Util::ScratchPad(__pBuffer, bufferWidth, bufferHeight, sourcePitch); + + SysTryCatch(NID_GRP, this->__pScratchPad, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] _Util::ScratchPad<> cannot be allocated."); + + this->__pParent = pSourceCanvas; + this->__xBufferPos = x1; + this->__yBufferPos = y1; + + // duplicate + // must re-assign by _CanvasImpl::GetSubCanvasN() + this->__pFont = pSourceCanvas->__pFont; + + this->__pPriorityFont = pSourceCanvas->__pPriorityFont; + + // copy directly + this->__windowHandle = pSourceCanvas->__windowHandle; + this->__blendOption = pSourceCanvas->__blendOption; + this->__fgColor = pSourceCanvas->__fgColor; + this->__bgColor = pSourceCanvas->__bgColor; + this->__fgColorNative = pSourceCanvas->__fgColorNative; + this->__bgColorNative = pSourceCanvas->__bgColorNative; + this->__fgOpacity = pSourceCanvas->__fgOpacity; + this->__bgOpacity = pSourceCanvas->__bgOpacity; + this->__lineWidth = pSourceCanvas->__lineWidth; + this->__lineStyle = pSourceCanvas->__lineStyle; + + // copy exception + this->__isClipBoundsSet = false; + this->__clipBounds = Rectangle(0, 0, bufferWidth, bufferHeight); + +#if defined(USE_CAIRO) + { + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo) + { + pCairo->pCairoSurface = cairo_image_surface_create_for_data((unsigned char*) this->__pBuffer, CAIRO_FORMAT_ARGB32, bufferWidth, bufferHeight, sourcePitch * 4); + pCairo->pCairo = cairo_create(pCairo->pCairoSurface); + } + } +#endif + + return E_SUCCESS; + +CATCH: + delete this->__pScratchPad; + this->__pScratchPad = null; + + delete this->__pSurface; + this->__pSurface = null; + + return r; +} + +result +_Canvas::Construct(const BufferInfo& bufferInfo) +{ + // all parameters checked + + result r = E_SUCCESS; + + _GenericBufferFrameBuffer* pTemp = new (std::nothrow) _GenericBufferFrameBuffer(static_cast(bufferInfo.pPixels), bufferInfo.width, bufferInfo.height, bufferInfo.pitch * 8 / bufferInfo.bitsPerPixel); + + SysTryReturnResult(NID_GRP + , pTemp + , E_OUT_OF_MEMORY + , " _GenericBufferFrameBuffer<> cannot be allocated."); + + this->__pSurface = new (std::nothrow) _Util::GenericBuffer(pTemp); + + SysTryCatch(NID_GRP + , this->__pSurface + , delete pTemp; r = E_OUT_OF_MEMORY + , E_OUT_OF_MEMORY + , "[E_OUT_OF_MEMORY] _Util::GenericBuffer<> cannot be allocated."); + + this->__pBuffer = (unsigned long*) __pSurface->GetBufferAddr(); + this->__pScratchPad = new (std::nothrow) _Util::ScratchPad(__pBuffer, bufferInfo.width, bufferInfo.height, bufferInfo.pitch * 8 / bufferInfo.bitsPerPixel); + + SysTryCatch(NID_GRP + , this->__pScratchPad + , r = E_OUT_OF_MEMORY + , E_OUT_OF_MEMORY + , "[E_OUT_OF_MEMORY] _Util::ScratchPad<> cannot be allocated."); + + this->__xBufferPos = 0; + this->__yBufferPos = 0; + +#if defined(USE_CAIRO) + { + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo) + { + pCairo->pCairoSurface = cairo_image_surface_create_for_data((unsigned char*) this->__pBuffer, CAIRO_FORMAT_ARGB32, bufferInfo.width, bufferInfo.height, bufferInfo.pitch); + pCairo->pCairo = cairo_create(pCairo->pCairoSurface); + } + } +#endif + + __InitFgBgColorFromTheme(); + + return E_SUCCESS; + +CATCH: + delete this->__pScratchPad; + this->__pScratchPad = null; + + delete this->__pSurface; + this->__pSurface = null; + + return r; +} + +bool +_Canvas::IsValid() const +{ + return (this && this->__pSurface); +} + +result +_Canvas::Clear(void) +{ + if (this->__isClipBoundsSet) + { + _Util::Rectangle clip = + { + this->__clipBounds.x, + this->__clipBounds.y, + this->__clipBounds.width, + this->__clipBounds.height + }; + + _Util::Rectangle rect = + { + 0, + 0, + __pScratchPad->GetWidth(), + __pScratchPad->GetHeight() + }; + + _ClearRectangleWithClip(__pScratchPad, __bgColor, rect, clip); + } + else + { + __pScratchPad->FillRect(0, 0, __pScratchPad->GetWidth(), __pScratchPad->GetHeight(), __bgColor); + } + + return E_SUCCESS; +} + +result +_Canvas::Clear(const Rectangle& rect) +{ + if ((rect.width == 0) || (rect.height == 0)) + { + return E_SUCCESS; + } + + if (this->__isClipBoundsSet) + { + _Util::Rectangle clip = + { + this->__clipBounds.x, + this->__clipBounds.y, + this->__clipBounds.width, + this->__clipBounds.height + }; + + _Util::Rectangle rect1 = + { + rect.x, + rect.y, + rect.width, + rect.height + }; + + _ClearRectangleWithClip(__pScratchPad, __bgColor, rect1, clip); + } + else + { + __pScratchPad->FillRect(rect.x, rect.y, rect.width, rect.height, __bgColor); + } + + return E_SUCCESS; +} + +result +_Canvas::Copy(const Point& destPoint, const _Canvas& canvas, const Rectangle& srcRect) +{ + // special case + if (srcRect.width == 0 || srcRect.height == 0) + { + return E_SUCCESS; + } + + return this->__Copy(destPoint, canvas, srcRect); +} + +result +_Canvas::Copy(const Rectangle& destRect, const _Canvas& canvas, const Rectangle& srcRect) +{ + // special case + if (srcRect.width == 0 || srcRect.height == 0 || destRect.width == 0 || destRect.height == 0) + { + return E_SUCCESS; + } + + return this->__Copy(destRect, canvas, srcRect); +} + +result +_Canvas::Copy(const Point& destPoint, const _Canvas& canvas, const Rectangle& srcRect, BlendingMode blendingMode) +{ + _Util::LockManager srcLock(canvas); + _Util::LockManager dstLock(*this); + + SysTryReturnResult(NID_GRP, srcLock.IsValid(), E_OPERATION_FAILED, "The source canvas cannot be locked."); + SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked"); + + const BufferInfo& srcBufferInfo = srcLock.GetBufferInfo(); + const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo(); + + { + _Util::Pixmap srcImageUnclipped(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + _Util::Pixmap srcImage = srcImageUnclipped.GetSubBitmap(srcRect.x, srcRect.y, srcRect.width, srcRect.height); + + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(destPoint.x, destPoint.y, srcRect.width, srcRect.height); + + _Pixman::CopyPixmap(dstImage, srcImage, GetDrawingQuality(), blendingMode); + } + + return E_SUCCESS; +} + +result +_Canvas::CopyReverse(const Point& destPoint, const _Canvas& srcCanvas, const Rectangle& srcRect) +{ + // special case + if (srcRect.width == 0 || srcRect.height == 0) + { + return E_SUCCESS; + } + + if (__pScratchPad == null) + { + return E_SYSTEM; + } + + const _Canvas* pSrcCanvas = &srcCanvas; + + if (pSrcCanvas == null) + { + return E_SYSTEM; + } + + if (pSrcCanvas->__pScratchPad == null) + { + return E_SYSTEM; + } + + Rectangle clippedSrcRect(srcRect); + + if (_ClipRectangle(clippedSrcRect.x, clippedSrcRect.y, clippedSrcRect.width, clippedSrcRect.height, 0, 0, pSrcCanvas->__pScratchPad->GetWidth(), pSrcCanvas->__pScratchPad->GetHeight()) == CLIP_REJECT) + { + return E_SYSTEM; + } + + __pScratchPad->RegisterBitBlt(_RasterOp::FnBitBlt32BitCopyReverse); + __pScratchPad->BitBlt(destPoint.x, destPoint.y, pSrcCanvas->__pScratchPad, clippedSrcRect.x, clippedSrcRect.y, clippedSrcRect.width, clippedSrcRect.height); + __pScratchPad->RegisterBitBlt(null); + + return E_SUCCESS; +} + +namespace +{ + +// spec. from SDK 1.0 + +template +void +_ReviseAngle(T& startAngle, T& endAngle) +{ + T zeroPi = T(0); + T twoPi = T(360); + + { + // startAngle = startAngle % twoPi; + int mod = int(startAngle / twoPi); + startAngle = startAngle - twoPi * mod; + + //endAngle = endAngle % twoPi; + mod = int(endAngle / twoPi); + endAngle = endAngle - twoPi * mod; + } + + if (startAngle < zeroPi || endAngle < zeroPi) + { + startAngle += twoPi; + endAngle += twoPi; + } + + if (startAngle > endAngle) + { + endAngle += twoPi; + } +} + +} + +result +_Canvas::DrawArc(const _Util::Rectangle& bounds, double startAngle, double endAngle, ArcStyle arcStyle) +{ + if ((bounds.w <= 0.0) || (bounds.h <= 0.0)) + { + return E_SUCCESS; + } + + // this->__lineWidth is always greater than 0 + + unsigned long composedColor = _ComposeColor(this->__fgColor, this->__fgOpacity); + + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo && pCairo->pCairo) + { + SET_CAIRO_DASH_STYLE; + SET_CAIRO_CLIPPING; + + double startDstAngle = (180.0 / M_PI) * atan2(sin(startAngle*M_PI / 180.0) * bounds.w / bounds.h, cos(startAngle * M_PI / 180.0)); + double endDstAngle = (180.0 / M_PI) * atan2(sin(endAngle * M_PI / 180.0) * bounds.w / bounds.h, cos(endAngle * M_PI / 180.0)); + + startDstAngle += (abs(startAngle - startDstAngle) <= 90.0) ? 0.0 : (startDstAngle < 0.0 && startAngle >= 0.0) ? 360.0 : (startDstAngle >= 0.0 && startAngle < 0.0) ? -360.0 : 0.0; + endDstAngle += (abs(endAngle - endDstAngle) <= 90.0) ? 0.0 : (endDstAngle < 0.0 && endAngle >= 0.0) ? 360.0 : (endDstAngle >= 0.0 && endAngle < 0.0) ? -360.0 : 0.0; + + _ReviseAngle(startDstAngle, endDstAngle); + + switch (arcStyle) + { + case ARC_STYLE_ONLY: + if (__lineWidth.applied != _Util::ScalarHolder::AS_INTEGER) + { + _Cairo::DrawArc(pCairo->pCairo, this->__lineWidth.asDouble, composedColor, bounds, startDstAngle, endDstAngle, _Cairo::DRAW_ARC_STYLE_ARC); + } + else + { + _Cairo::DrawArc(pCairo->pCairo, this->__lineWidth.asInteger, composedColor, bounds, startDstAngle, endDstAngle, _Cairo::DRAW_ARC_STYLE_ARC); + } + break; + + case ARC_STYLE_PIE: + if (__lineWidth.applied != _Util::ScalarHolder::AS_INTEGER) + { + _Cairo::DrawArc(pCairo->pCairo, this->__lineWidth.asDouble, composedColor, bounds, startDstAngle, endDstAngle, _Cairo::DRAW_ARC_STYLE_PIE); + } + else + { + _Cairo::DrawArc(pCairo->pCairo, this->__lineWidth.asInteger, composedColor, bounds, startDstAngle, endDstAngle, _Cairo::DRAW_ARC_STYLE_PIE); + } + break; + + case ARC_STYLE_CHORD: + if (__lineWidth.applied != _Util::ScalarHolder::AS_INTEGER) + { + _Cairo::DrawArc(pCairo->pCairo, this->__lineWidth.asDouble, composedColor, bounds, startDstAngle, endDstAngle, _Cairo::DRAW_ARC_STYLE_CHORD); + } + else + { + _Cairo::DrawArc(pCairo->pCairo, this->__lineWidth.asInteger, composedColor, bounds, startDstAngle, endDstAngle, _Cairo::DRAW_ARC_STYLE_CHORD); + } + break; + + case ARC_STYLE_FILLED_PIE: + _Cairo::FillArc(pCairo->pCairo, composedColor, bounds, startDstAngle, endDstAngle, _Cairo::FILL_ARC_STYLE_PIE); + break; + + case ARC_STYLE_FILLED_CHORD: + _Cairo::FillArc(pCairo->pCairo, composedColor, bounds, startDstAngle, endDstAngle, _Cairo::FILL_ARC_STYLE_CHORD); + break; + + default: + return E_SYSTEM; + } + + RESET_CAIRO_CLIPPING; + RESET_CAIRO_DASH_STYLE; + + return E_SUCCESS; + } + else + { + _CanvasArc arc; + _GpBufferInfo info; + + memset(&info, 0, sizeof(info)); + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.bitsPerPixel = 32; + info.pixelPerLine = bufferPitch; + info.pPixels = (void*) pBufferAddr; + info.color32 = composedColor; + info.isClipBoundsSet = this->__isClipBoundsSet; + info.clipBounds.SetBounds(this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); + + arc.SetLineWidth(this->__lineWidth.asInteger); + + _ReviseAngle(startAngle, endAngle); + + return arc.DrawArc(int(bounds.x), int(bounds.y), int(bounds.w), int(bounds.h), int(startAngle), int(endAngle), arcStyle, info); + } +} + +result +_Canvas::DrawBitmap(const Rectangle& rect, const _Bitmap& bitmap) +{ + SysTryReturnResult(NID_GRP, &bitmap && bitmap.IsValid(), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + if (rect.width <= 0 || rect.height <= 0) + { + return E_SUCCESS; + } + + int alphaConstant = this->_GetAlphaAttenuation(bitmap); + + Rectangle clipRect; + + this->__GetClipBounds(clipRect); + + if (alphaConstant >= 255) + { + bool pass = false; + + _Util::LockManager srcLock(bitmap); + _Util::LockManager dstLock(*this); + + SysTryReturnResult(NID_GRP, srcLock.IsValid(), E_OPERATION_FAILED, "The source bitmap cannot be locked.\n"); + SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked.\n"); + + const BufferInfo& srcBufferInfo = srcLock.GetBufferInfo(); + const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo(); + + { + if (!this->__useStableRenderer && srcBufferInfo.bitsPerPixel == 32) + { + _Util::Rectangle outRect = { 0, 0, -1, -1 }; + _Util::Rectangle dstRect = { rect.x, rect.y, rect.width, rect.height }; + _Util::Rectangle tgtRect = { clipRect.x, clipRect.y, clipRect.width, clipRect.height }; + + _Util::IntersectRect(outRect, tgtRect, dstRect); + + // assert(rect.width > 0 && rect.height > 0); + + _Util::Bounds outBounds = { outRect.x, outRect.y, outRect.x + outRect.w, outRect.y + outRect.h }; + _Util::Bounds dstBounds = { dstRect.x, dstRect.y, dstRect.x + dstRect.w, dstRect.y + dstRect.h }; + _Util::Bounds srcBounds = + { + (outBounds.x1 - dstBounds.x1) * srcBufferInfo.width / (dstBounds.x2 - dstBounds.x1), + (outBounds.y1 - dstBounds.y1) * srcBufferInfo.height / (dstBounds.y2 - dstBounds.y1), + srcBufferInfo.width + (outBounds.x2 - dstBounds.x2) * srcBufferInfo.width / (dstBounds.x2 - dstBounds.x1), + srcBufferInfo.height + (outBounds.y2 - dstBounds.y2) * srcBufferInfo.height / (dstBounds.y2 - dstBounds.y1), + }; + + srcBounds.x1 = (srcBounds.x1 >= 0) ? srcBounds.x1 : 0; + srcBounds.y1 = (srcBounds.y1 >= 0) ? srcBounds.y1 : 0; + srcBounds.x2 = (srcBounds.x2 <= srcBufferInfo.width) ? srcBounds.x2 : srcBufferInfo.width; + srcBounds.y2 = (srcBounds.y2 <= srcBufferInfo.height) ? srcBounds.y2 : srcBufferInfo.height; + + _Util::Pixmap srcImageUnclipped(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + _Util::Pixmap srcImage = srcImageUnclipped.GetSubBitmap(srcBounds.x1, srcBounds.y1, srcBounds.x2 - srcBounds.x1, srcBounds.y2 - srcBounds.y1); + _ApplySrcBitmapAttrib(srcImage, bitmap, bitmap.__isOpaqueAllOver); + + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(outRect.x, outRect.y, outRect.w, outRect.h); + + pass = _Pixman::ScalePixmap(dstImage, srcImage, GetDrawingQuality()); + } + + if (!pass) + { + _Util::Pixmap srcImage(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + _ApplySrcBitmapAttrib(srcImage, bitmap, bitmap.__isOpaqueAllOver); + + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height); + + pass = Tizen::Graphics::_Effect::ScaleImage(dstImage, rect.x - clipRect.x, rect.y - clipRect.y, rect.width, rect.height, srcImage, _ConvertParam<_Effect::Rop>(this->__blendOption)); + } + + } + + SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); + + return E_SUCCESS; + } + else + { + _Util::Pixmap tmpImage(rect.width, rect.height, bitmap.GetBitsPerPixel()); + + // copies the source bitmap to the scaled bitmap + { + // ykahn, 2011/10/11 patched + { + _ApplySrcBitmapAttrib(tmpImage, bitmap, bitmap.__isOpaqueAllOver); + + if (tmpImage.depth == 16) + { + if (tmpImage.enableColorKey) + { + typedef unsigned short Pixel; + + Pixel colorKey = (Pixel) tmpImage.colorKey; + Pixel* pDest = (Pixel*) tmpImage.pBitmap; + Pixel* pDestEnd = pDest + (tmpImage.bytesPerLine * tmpImage.height / (tmpImage.depth / 8)); + + while (pDest < pDestEnd) + { + *pDest++ = colorKey; + } + } + else + { + ; + } + } + else if (tmpImage.depth == 32) + { + typedef unsigned long Pixel; + + Pixel fillColor = 0; + Pixel* pDest = (Pixel*) tmpImage.pBitmap; + Pixel* pDestEnd = pDest + (tmpImage.bytesPerLine * tmpImage.height / (tmpImage.depth / 8)); + + while (pDest < pDestEnd) + { + *pDest++ = fillColor; + } + } + } + + bool pass = false; + + { + _Util::LockManager srcLock(bitmap); + SysTryReturnResult(NID_GRP, srcLock.IsValid(), E_OPERATION_FAILED, "The source bitmap cannot be locked.\n"); + + const BufferInfo& srcBufferInfo = srcLock.GetBufferInfo(); + + { + _Util::Pixmap srcImage(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + _ApplySrcBitmapAttrib(srcImage, bitmap, bitmap.__isOpaqueAllOver); + + pass = Tizen::Graphics::_Effect::ScaleImage(tmpImage, 0, 0, rect.width, rect.height, srcImage, Tizen::Graphics::_Effect::ROP_COPY); + } + } + + SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); + } + + { + bool pass = false; + + { + _Util::LockManager dstLock(*this); + SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked.\n"); + + const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo(); + + { + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height); + + pass = Tizen::Graphics::_Effect::DrawImageWithAlpha(dstImage, rect.x - clipRect.x, rect.y - clipRect.y, tmpImage, alphaConstant); + } + } + + SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); + } + + return E_SUCCESS; + } +} + + +result +_Canvas::DrawBitmap(const Point& point, const _Bitmap& bitmap) +{ + SysTryReturnResult(NID_GRP, &bitmap && bitmap.IsValid(), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + int alphaConstant = this->_GetAlphaAttenuation(bitmap); + + { + Rectangle clipRect; + + this->__GetClipBounds(clipRect); + + bool pass = false; + + { + _Util::LockManager srcLock(bitmap); + _Util::LockManager dstLock(*this); + + SysTryReturnResult(NID_GRP, srcLock.IsValid(), E_OPERATION_FAILED, "The source bitmap cannot be locked.\n"); + SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked.\n"); + + const BufferInfo& srcBufferInfo = srcLock.GetBufferInfo(); + const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo(); + + { + _Util::Pixmap srcImage(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + _ApplySrcBitmapAttrib(srcImage, bitmap, bitmap.__isOpaqueAllOver); + + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height); + + if (srcBufferInfo.pixelFormat == PIXEL_FORMAT_RGB565 && srcImage.enableColorKey == 0 && dstBufferInfo.pixelFormat == PIXEL_FORMAT_ARGB8888 && !this->__isClipBoundsSet) + { + pixman_image_t* pPixmanSrc = pixman_image_create_bits(PIXMAN_r5g6b5, srcBufferInfo.width, srcBufferInfo.height, (uint32_t*)srcBufferInfo.pPixels, srcBufferInfo.pitch); + pixman_image_t* pPixmanDst = pixman_image_create_bits(PIXMAN_a8r8g8b8, dstBufferInfo.width, dstBufferInfo.height, (uint32_t*)dstBufferInfo.pPixels, dstBufferInfo.pitch); + + if (pPixmanSrc && pPixmanDst) + { + pixman_image_composite32(PIXMAN_OP_SRC, pPixmanSrc, NULL, pPixmanDst, 0, 0, 0, 0, point.x, point.y, srcBufferInfo.width, srcBufferInfo.height); + pass = true; + } + + if (pPixmanDst) + { + pixman_image_unref(pPixmanDst); + } + + if (pPixmanSrc) + { + pixman_image_unref(pPixmanSrc); + } + } + } + { + Color color; + bool isPixmanSupported = !this->__useStableRenderer && bitmap.GetMaskingColor(color ) != E_SUCCESS && alphaConstant >= 255; + if (isPixmanSupported) + { + _Util::Rectangle outRect = { 0, 0, -1, -1 }; + _Util::Rectangle dstRect = { point.x, point.y, srcBufferInfo.width, srcBufferInfo.height }; + _Util::Rectangle tgtRect = { clipRect.x, clipRect.y, clipRect.width, clipRect.height }; + + if (_Util::IntersectRect(outRect, tgtRect, dstRect)) + { + // assert(rect.width > 0 && rect.height > 0); + + _Util::Bounds outBounds = { outRect.x, outRect.y, outRect.x + outRect.w, outRect.y + outRect.h }; + _Util::Bounds dstBounds = { dstRect.x, dstRect.y, dstRect.x + dstRect.w, dstRect.y + dstRect.h }; + _Util::Bounds srcBounds = + { + (outBounds.x1 - dstBounds.x1), + (outBounds.y1 - dstBounds.y1), + srcBufferInfo.width + (outBounds.x2 - dstBounds.x2), + srcBufferInfo.height + (outBounds.y2 - dstBounds.y2), + }; + + srcBounds.x1 = (srcBounds.x1 >= 0) ? srcBounds.x1 : 0; + srcBounds.y1 = (srcBounds.y1 >= 0) ? srcBounds.y1 : 0; + srcBounds.x2 = (srcBounds.x2 <= srcBufferInfo.width) ? srcBounds.x2 : srcBufferInfo.width; + srcBounds.y2 = (srcBounds.y2 <= srcBufferInfo.height) ? srcBounds.y2 : srcBufferInfo.height; + + _Util::Pixmap srcImageUnclipped(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + _Util::Pixmap srcImage = srcImageUnclipped.GetSubBitmap(srcBounds.x1, srcBounds.y1, srcBounds.x2 - srcBounds.x1, srcBounds.y2 - srcBounds.y1); + _ApplySrcBitmapAttrib(srcImage, bitmap, bitmap.__isOpaqueAllOver); + + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(outRect.x, outRect.y, outRect.w, outRect.h); + + pass = _Pixman::CopyPixmap(dstImage, srcImage, GetDrawingQuality(), BLENDING_MODE_SRC_OVER); + } + } + + if (!pass) + { + _Util::Pixmap srcImage(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + _ApplySrcBitmapAttrib(srcImage, bitmap, bitmap.__isOpaqueAllOver); + + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height); + + pass = Tizen::Graphics::_Effect::DrawImageWithAlpha(dstImage, point.x - clipRect.x, point.y - clipRect.y, srcImage, alphaConstant); + } + } + } + + SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); + + return E_SUCCESS; + } +} + +result +_Canvas::DrawBitmap(const Rectangle& destRect, const _Bitmap& srcBitmap, const Rectangle& srcRect) +{ + SysTryReturnResult(NID_GRP, &srcBitmap && srcBitmap.IsValid(), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + if (srcRect.width == 0 || srcRect.height == 0) + { + return E_SUCCESS; + } + + if (destRect.width == 0 || destRect.height == 0) + { + return E_SUCCESS; + } + + int alphaConstant = this->_GetAlphaAttenuation(srcBitmap); + + Rectangle clipRect; + + this->__GetClipBounds(clipRect); + + if (alphaConstant >= 255) + { + bool pass = false; + + _Util::LockManager srcLock(srcBitmap); + _Util::LockManager dstLock(*this); + + SysTryReturnResult(NID_GRP, srcLock.IsValid(), E_OPERATION_FAILED, "The source bitmap cannot be locked.\n"); + SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked.\n"); + + const BufferInfo& srcBufferInfo = srcLock.GetBufferInfo(); + const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo(); + + { + if (!this->__useStableRenderer && srcBufferInfo.bitsPerPixel == 32) + { + _Util::Rectangle outRect = { 0, 0, -1, -1 }; + _Util::Rectangle dstRect = { destRect.x, destRect.y, destRect.width, destRect.height }; + _Util::Rectangle tgtRect = { clipRect.x, clipRect.y, clipRect.width, clipRect.height }; + + _Util::IntersectRect(outRect, tgtRect, dstRect); + + // assert(destRect.width > 0 && destRect.height > 0); + + _Util::Bounds outBounds = { outRect.x, outRect.y, outRect.x + outRect.w, outRect.y + outRect.h }; + _Util::Bounds dstBounds = { dstRect.x, dstRect.y, dstRect.x + dstRect.w, dstRect.y + dstRect.h }; + _Util::Bounds srcBounds = + { + srcRect.x + (outBounds.x1 - dstBounds.x1) * srcRect.width / (dstBounds.x2 - dstBounds.x1), + srcRect.y + (outBounds.y1 - dstBounds.y1) * srcRect.height / (dstBounds.y2 - dstBounds.y1), + (srcRect.x + srcRect.width) + (outBounds.x2 - dstBounds.x2) * srcRect.width / (dstBounds.x2 - dstBounds.x1), + (srcRect.y + srcRect.height) + (outBounds.y2 - dstBounds.y2) * srcRect.height / (dstBounds.y2 - dstBounds.y1), + }; + + srcBounds.x1 = (srcBounds.x1 >= srcRect.x) ? srcBounds.x1 : srcRect.x; + srcBounds.y1 = (srcBounds.y1 >= srcRect.y) ? srcBounds.y1 : srcRect.y; + srcBounds.x2 = (srcBounds.x2 <= (srcRect.x + srcRect.width)) ? srcBounds.x2 : (srcRect.x + srcRect.width); + srcBounds.y2 = (srcBounds.y2 <= (srcRect.y + srcRect.height)) ? srcBounds.y2 : (srcRect.y + srcRect.height); + + _Util::Pixmap srcImageUnclipped(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + _Util::Pixmap srcImage = srcImageUnclipped.GetSubBitmap(srcBounds.x1, srcBounds.y1, srcBounds.x2 - srcBounds.x1, srcBounds.y2 - srcBounds.y1); + _ApplySrcBitmapAttrib(srcImage, srcBitmap, srcBitmap.__isOpaqueAllOver); + + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(outRect.x, outRect.y, outRect.w, outRect.h); + + pass = _Pixman::ScalePixmap(dstImage, srcImage, GetDrawingQuality()); + } + + if (!pass) + { + unsigned char* pPixels = (unsigned char*) srcBufferInfo.pPixels + srcRect.y * srcBufferInfo.pitch + srcRect.x * (srcBufferInfo.bitsPerPixel / 8); + + _Util::Pixmap srcImage(srcRect.width, srcRect.height, srcBufferInfo.bitsPerPixel, (void*) pPixels, srcBufferInfo.pitch); + _ApplySrcBitmapAttrib(srcImage, srcBitmap, srcBitmap.__isOpaqueAllOver); + + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height); + + pass = Tizen::Graphics::_Effect::ScaleImage(dstImage, destRect.x - clipRect.x, destRect.y - clipRect.y, destRect.width, destRect.height, srcImage, _ConvertParam<_Effect::Rop>(this->__blendOption)); + } + + } + + SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); + + return E_SUCCESS; + } + else + { + _Util::Pixmap tmpImage(destRect.width, destRect.height, srcBitmap.GetBitsPerPixel()); + + // copies the source bitmap to the scaled bitmap + { + // ykahn, 2011/10/11 patched + { + _ApplySrcBitmapAttrib(tmpImage, srcBitmap, srcBitmap.__isOpaqueAllOver); + + if (tmpImage.depth == 16) + { + if (tmpImage.enableColorKey) + { + typedef unsigned short Pixel; + + Pixel colorKey = (Pixel) tmpImage.colorKey; + Pixel* pDest = (Pixel*) tmpImage.pBitmap; + Pixel* pDestEnd = pDest + (tmpImage.bytesPerLine * tmpImage.height / (tmpImage.depth / 8)); + + while (pDest < pDestEnd) + { + *pDest++ = colorKey; + } + } + else + { + } + } + else if (tmpImage.depth == 32) + { + typedef unsigned long Pixel; + + Pixel fillColor = 0; + Pixel* pDest = (Pixel*) tmpImage.pBitmap; + Pixel* pDestEnd = pDest + (tmpImage.bytesPerLine * tmpImage.height / (tmpImage.depth / 8)); + + while (pDest < pDestEnd) + { + *pDest++ = fillColor; + } + } + } + + bool pass = false; + + { + _Util::LockManager srcLock(srcBitmap); + SysTryReturnResult(NID_GRP, srcLock.IsValid(), E_OPERATION_FAILED, "The source bitmap cannot be locked.\n"); + + const BufferInfo& srcBufferInfo = srcLock.GetBufferInfo(); + + { + unsigned char* pPixels = (unsigned char*) srcBufferInfo.pPixels + srcRect.y * srcBufferInfo.pitch + srcRect.x * (srcBufferInfo.bitsPerPixel / 8); + + _Util::Pixmap srcImage(srcRect.width, srcRect.height, srcBufferInfo.bitsPerPixel, (void*) pPixels, srcBufferInfo.pitch); + _ApplySrcBitmapAttrib(srcImage, srcBitmap, srcBitmap.__isOpaqueAllOver); + + pass = Tizen::Graphics::_Effect::ScaleImage(tmpImage, 0, 0, destRect.width, destRect.height, srcImage, Tizen::Graphics::_Effect::ROP_COPY); + } + } + + SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); + } + + { + bool pass = false; + + { + _Util::LockManager dstLock(*this); + SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked.\n"); + + const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo(); + + { + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height); + + pass = Tizen::Graphics::_Effect::DrawImageWithAlpha(dstImage, destRect.x - clipRect.x, destRect.y - clipRect.y, tmpImage, alphaConstant); + } + } + + SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); + } + + return E_SUCCESS; + } +} + +result +_Canvas::DrawBitmapForNinePatchedBitmap(const Rectangle& destRect, const _Bitmap& srcBitmap, const Rectangle& srcRect) +{ + SysTryReturnResult(NID_GRP, &srcBitmap && srcBitmap.IsValid(), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + if (srcRect.width == 0 || srcRect.height == 0) + { + return E_SUCCESS; + } + + if (destRect.width == 0 || destRect.height == 0) + { + return E_SUCCESS; + } + + int alphaConstant = this->_GetAlphaAttenuation(srcBitmap); + + Rectangle clipRect; + + this->__GetClipBounds(clipRect); + + if (alphaConstant >= 255) + { + bool pass = false; + + _Util::LockManager srcLock(srcBitmap); + _Util::LockManager dstLock(*this); + + SysTryReturnResult(NID_GRP, srcLock.IsValid(), E_OPERATION_FAILED, "The source bitmap cannot be locked.\n"); + SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked.\n"); + + const BufferInfo& srcBufferInfo = srcLock.GetBufferInfo(); + const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo(); + + { + if (srcBufferInfo.bitsPerPixel == 32) + { + _Util::Rectangle outRect = { 0, 0, -1, -1 }; + _Util::Rectangle dstRect = { destRect.x, destRect.y, destRect.width, destRect.height }; + _Util::Rectangle tgtRect = { clipRect.x, clipRect.y, clipRect.width, clipRect.height }; + + _Util::IntersectRect(outRect, tgtRect, dstRect); + + // assert(destRect.width > 0 && destRect.height > 0); + + _Util::Bounds outBounds = { outRect.x, outRect.y, outRect.x + outRect.w, outRect.y + outRect.h }; + _Util::Bounds dstBounds = { dstRect.x, dstRect.y, dstRect.x + dstRect.w, dstRect.y + dstRect.h }; + _Util::Bounds srcBounds = + { + srcRect.x + (outBounds.x1 - dstBounds.x1) * srcRect.width / (dstBounds.x2 - dstBounds.x1), + srcRect.y + (outBounds.y1 - dstBounds.y1) * srcRect.height / (dstBounds.y2 - dstBounds.y1), + (srcRect.x + srcRect.width) + (outBounds.x2 - dstBounds.x2) * srcRect.width / (dstBounds.x2 - dstBounds.x1), + (srcRect.y + srcRect.height) + (outBounds.y2 - dstBounds.y2) * srcRect.height / (dstBounds.y2 - dstBounds.y1), + }; + + srcBounds.x1 = (srcBounds.x1 >= srcRect.x) ? srcBounds.x1 : srcRect.x; + srcBounds.y1 = (srcBounds.y1 >= srcRect.y) ? srcBounds.y1 : srcRect.y; + srcBounds.x2 = (srcBounds.x2 <= (srcRect.x + srcRect.width)) ? srcBounds.x2 : (srcRect.x + srcRect.width); + srcBounds.y2 = (srcBounds.y2 <= (srcRect.y + srcRect.height)) ? srcBounds.y2 : (srcRect.y + srcRect.height); + + _Util::Pixmap srcImageUnclipped(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + _Util::Pixmap srcImage = srcImageUnclipped.GetSubBitmap(srcBounds.x1, srcBounds.y1, srcBounds.x2 - srcBounds.x1, srcBounds.y2 - srcBounds.y1); + _ApplySrcBitmapAttrib(srcImage, srcBitmap, srcBitmap.__isOpaqueAllOver); + + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(outRect.x, outRect.y, outRect.w, outRect.h); + + pass = _Pixman::ScalePixmap(dstImage, srcImage, GetDrawingQuality(), GetBlendingMode()); + } + + if (!pass) + { + unsigned char* pPixels = (unsigned char*) srcBufferInfo.pPixels + srcRect.y * srcBufferInfo.pitch + srcRect.x * (srcBufferInfo.bitsPerPixel / 8); + + _Util::Pixmap srcImage(srcRect.width, srcRect.height, srcBufferInfo.bitsPerPixel, (void*) pPixels, srcBufferInfo.pitch); + _ApplySrcBitmapAttrib(srcImage, srcBitmap, srcBitmap.__isOpaqueAllOver); + + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height); + + pass = Tizen::Graphics::_Effect::ScaleImage(dstImage, destRect.x - clipRect.x, destRect.y - clipRect.y, destRect.width, destRect.height, srcImage, _ConvertParam<_Effect::Rop>(this->__blendOption)); + } + + } + + SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); + + return E_SUCCESS; + } + else + { + _Util::Pixmap tmpImage(destRect.width, destRect.height, srcBitmap.GetBitsPerPixel()); + + // copies the source bitmap to the scaled bitmap + { + // ykahn, 2011/10/11 patched + { + _ApplySrcBitmapAttrib(tmpImage, srcBitmap, srcBitmap.__isOpaqueAllOver); + + if (tmpImage.depth == 16) + { + if (tmpImage.enableColorKey) + { + typedef unsigned short Pixel; + + Pixel colorKey = (Pixel) tmpImage.colorKey; + Pixel* pDest = (Pixel*) tmpImage.pBitmap; + Pixel* pDestEnd = pDest + (tmpImage.bytesPerLine * tmpImage.height / (tmpImage.depth / 8)); + + while (pDest < pDestEnd) + { + *pDest++ = colorKey; + } + } + else + { + } + } + else if (tmpImage.depth == 32) + { + typedef unsigned long Pixel; + + Pixel fillColor = 0; + Pixel* pDest = (Pixel*) tmpImage.pBitmap; + Pixel* pDestEnd = pDest + (tmpImage.bytesPerLine * tmpImage.height / (tmpImage.depth / 8)); + + while (pDest < pDestEnd) + { + *pDest++ = fillColor; + } + } + } + + bool pass = false; + + { + _Util::LockManager srcLock(srcBitmap); + SysTryReturnResult(NID_GRP, srcLock.IsValid(), E_OPERATION_FAILED, "The source bitmap cannot be locked.\n"); + + const BufferInfo& srcBufferInfo = srcLock.GetBufferInfo(); + + { + unsigned char* pPixels = (unsigned char*) srcBufferInfo.pPixels + srcRect.y * srcBufferInfo.pitch + srcRect.x * (srcBufferInfo.bitsPerPixel / 8); + + _Util::Pixmap srcImage(srcRect.width, srcRect.height, srcBufferInfo.bitsPerPixel, (void*) pPixels, srcBufferInfo.pitch); + _ApplySrcBitmapAttrib(srcImage, srcBitmap, srcBitmap.__isOpaqueAllOver); + + pass = Tizen::Graphics::_Effect::ScaleImage(tmpImage, 0, 0, destRect.width, destRect.height, srcImage, Tizen::Graphics::_Effect::ROP_COPY); + } + } + + SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); + } + + { + bool pass = false; + + { + _Util::LockManager dstLock(*this); + SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked.\n"); + + const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo(); + + { + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height); + + pass = Tizen::Graphics::_Effect::DrawImageWithAlpha(dstImage, destRect.x - clipRect.x, destRect.y - clipRect.y, tmpImage, alphaConstant); + } + } + + SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); + } + + return E_SUCCESS; + } +} + +result +_Canvas::DrawBitmap(const Point& point, const _Bitmap& bitmap, FlipDirection dir) +{ + SysTryReturnResult(NID_GRP, &bitmap && bitmap.IsValid(), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + int alphaConstant = this->_GetAlphaAttenuation(bitmap); + + Rectangle clipRect; + + this->__GetClipBounds(clipRect); + + { + _Util::Pixmap* pFlippedImage = 0; + + { + _Util::LockManager srcLock(bitmap); + SysTryReturnResult(NID_GRP, srcLock.IsValid(), E_OPERATION_FAILED, "The source bitmap cannot be locked.\n"); + + const BufferInfo& srcBufferInfo = srcLock.GetBufferInfo(); + + Tizen::Graphics::_Effect::Flip flip = (dir == FLIP_DIRECTION_HORIZONTAL) ? Tizen::Graphics::_Effect::FLIP_HORIZONTAL : Tizen::Graphics::_Effect::FLIP_VERTICAL; + + { + _Util::Pixmap srcImage(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + + pFlippedImage = Tizen::Graphics::_Effect::GetFlippedImage(srcImage, flip); + } + } + + SysTryReturnResult(NID_GRP, pFlippedImage, E_INVALID_ARG, "The source bitmap is invalid.\n"); + + _ApplySrcBitmapAttrib(*pFlippedImage, bitmap, bitmap.__isOpaqueAllOver); + + std::auto_ptr<_Util::Pixmap> autoReleasingImage(pFlippedImage); + + { + bool pass = false; + + { + _Util::LockManager dstLock(*this); + SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked.\n"); + + const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo(); + + { + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height); + + pass = Tizen::Graphics::_Effect::DrawImageWithAlpha(dstImage, point.x - clipRect.x, point.y - clipRect.y, *pFlippedImage, alphaConstant); + } + } + + SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); + } + + return E_SUCCESS; + } +} + +result +_Canvas::DrawBitmap(const Point& point, const _Bitmap& bitmap, const Point& pivot, int degree) +{ + SysTryReturnResult(NID_GRP, &bitmap && bitmap.IsValid(), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + Rectangle clipRect; + + this->__GetClipBounds(clipRect); + + int alphaConstant = this->_GetAlphaAttenuation(bitmap); + + if (alphaConstant >= 255 && !bitmap.__hasMaskingColor) + { + bool pass = false; + + _Util::LockManager srcLock(bitmap); + _Util::LockManager dstLock(*this); + + SysTryReturnResult(NID_GRP, srcLock.IsValid(), E_OPERATION_FAILED, "The source bitmap cannot be locked."); + SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked."); + + const BufferInfo& srcBufferInfo = srcLock.GetBufferInfo(); + const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo(); + + if (!this->__useStableRenderer) + { + _Util::Pixmap srcImage(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + _ApplySrcBitmapAttrib(srcImage, bitmap, bitmap.__isOpaqueAllOver); + + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height); + + pass = _Pixman::RotatePixmap(dstImage, srcImage, GetDrawingQuality(), point.x - clipRect.x, point.y - clipRect.y, double(degree), pivot.x, pivot.y); + } + + if (pass) + { + return E_SUCCESS; + } + } + +/* + if (alphaConstant >= 255) + { + return pCanvasInterface->DrawBitmap(point.x, point.y, *((IBitmapPi*)*(IBitmapPi**)bitmap.__pImpl), pivot.x, pivot.y, degree); + } + else +*/ + { + _Util::LockManager srcLock(bitmap); + _Util::LockManager dstLock(*this); + + SysTryReturnResult(NID_GRP, srcLock.IsValid(), E_OPERATION_FAILED, "The source bitmap cannot be locked.\n"); + SysTryReturnResult(NID_GRP, dstLock.IsValid(), E_OPERATION_FAILED, "The canvas cannot be locked.\n"); + + const BufferInfo& srcBufferInfo = srcLock.GetBufferInfo(); + const BufferInfo& dstBufferInfo = dstLock.GetBufferInfo(); + + _Util::Pixmap srcImage(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + _Util::Pixmap dstImageUnclipped(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + _Util::Pixmap dstImage = dstImageUnclipped.GetSubBitmap(clipRect.x, clipRect.y, clipRect.width, clipRect.height); + + _ApplySrcBitmapAttrib(srcImage, bitmap, bitmap.__isOpaqueAllOver); + + // angle, xOffset, yOffset + Tizen::Graphics::_Effect::RotateDesc rotateDesc = { degree, pivot.x, pivot.y }; + bool pass = Tizen::Graphics::_Effect::RotateImage(dstImage, point.x - clipRect.x, point.y - clipRect.y, srcImage, rotateDesc, alphaConstant); + + SysTryReturnResult(NID_GRP, pass, E_INVALID_ARG, "The source bitmap is invalid.\n"); + + return E_SUCCESS; + } +} + +result +_Canvas::DrawNinePatchedBitmap(const Rectangle& rect, const _Bitmap& bitmap) +{ + SysTryReturnResult(NID_GRP, &bitmap && bitmap.IsValid(), E_INVALID_ARG, "The source bitmap is invalid.\n"); + + // down-scales the source bitmap + if (rect.width < bitmap.GetWidth() - 2 || rect.height < bitmap.GetHeight() - 2) + { +#if 1 + int dstW = rect.width; + int dstH = rect.height; + int srcW = bitmap.GetWidth() - 2; + int srcH = bitmap.GetHeight() - 2; + + if (dstW <= 0 || dstH <= 0) + { + return E_SUCCESS; + } + + if (dstW * srcH < dstH * srcW) + { + // fit to width + dstW = srcW; + dstH = dstH * srcW / dstW; + } + else + { + // fit to height + dstW = dstW * srcH / dstH; + dstH = srcH; + } + + result r; + + { + const int PADDING = 1; + + _Bitmap expandedBitmap; + + r = expandedBitmap.Construct(Dimension(dstW + PADDING * 2, dstH + PADDING * 2), BITMAP_PIXEL_FORMAT_ARGB8888); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Util::LockManager dstBitmap(expandedBitmap); + + { + const BufferInfo& dstBufferInfo = dstBitmap.GetBufferInfo(); + + memset(dstBufferInfo.pPixels, 0, dstBufferInfo.pitch * dstBufferInfo.height); + + _Canvas expandedCanvas; + + r = expandedCanvas.Construct(dstBufferInfo); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + expandedCanvas.SetDrawingQuality(BITMAP_DRAWING_QUALITY_HIGH); + expandedCanvas.SetBlendingMode(BLENDING_MODE_SRC); + + _Util::Pixmap dstImage(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, (void*) dstBufferInfo.pPixels, dstBufferInfo.pitch); + + _Util::AccumList<_Util::Pair<_Util::Rectangle, _Util::Rectangle > > boundsList; + + r = _Util::GetPatchList(boundsList, Rectangle(PADDING, PADDING, dstBufferInfo.width - PADDING * 2, dstBufferInfo.height - PADDING * 2), bitmap); + + SysTryReturn(NID_GRP, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] _Util::GetPatchList() failed (error = %#x)", r); + + _Util::AccumList<_Util::Pair<_Util::Rectangle, _Util::Rectangle > >::Iterator iter = boundsList.Begin(); + + int alphaConstant = bitmap.GetAlphaConstant(); + const_cast<_Bitmap*>(&bitmap)->SetAlphaConstant(255); + + while (iter != boundsList.End()) + { + Rectangle destRect(iter->first.x, iter->first.y, iter->first.w, iter->first.h); + Rectangle sourRect(iter->second.x, iter->second.y, iter->second.w, iter->second.h); + + expandedCanvas.DrawBitmapForNinePatchedBitmap(destRect, bitmap, sourRect); + + ++iter; + } + + const_cast<_Bitmap*>(&bitmap)->SetAlphaConstant(alphaConstant); + expandedBitmap.SetAlphaConstant(alphaConstant); + } + + // not <- PADDING * 2> + Tizen::Graphics::Rectangle srcRect(PADDING, PADDING, expandedBitmap.GetWidth() - PADDING, expandedBitmap.GetHeight() - PADDING); + + return this->DrawBitmap(rect, expandedBitmap, srcRect); + } + +#else // old spec. + Tizen::Graphics::Rectangle srcRect(1, 1, bitmap.GetWidth() - 2, bitmap.GetHeight() - 2); + + return this->DrawBitmap(rect, bitmap, srcRect); +#endif + } + + _Util::AccumList<_Util::Pair<_Util::Rectangle, _Util::Rectangle > > boundsList; + + result r = _Util::GetPatchList(boundsList, rect, bitmap); + + if (r == E_SUCCESS) + { + _Util::AccumList<_Util::Pair<_Util::Rectangle, _Util::Rectangle > >::Iterator iter = boundsList.Begin(); + + while (iter != boundsList.End()) + { + Rectangle destRect(iter->first.x, iter->first.y, iter->first.w, iter->first.h); + Rectangle sourRect(iter->second.x, iter->second.y, iter->second.w, iter->second.h); + + DrawBitmapForNinePatchedBitmap(destRect, bitmap, sourRect); + + ++iter; + } + } + + return r; +} + +result +_Canvas::DrawEllipse(const _Util::Rectangle& bounds) +{ + _Util::Rectangle doubleBounds = + { + double(bounds.x), + double(bounds.y), + double(bounds.w), + double(bounds.h) + }; + + return this->DrawEllipse(doubleBounds); +} + +result +_Canvas::DrawEllipse(const _Util::Rectangle& bounds) +{ + if ((bounds.w <= 0.0) || (bounds.h <= 0.0)) + { + return E_SUCCESS; + } + + // this->__lineWidth is always greater than 0 + + unsigned long composedColor = _ComposeColor(this->__fgColor, this->__fgOpacity); + + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + int x1 = this->GetBounds().x; + int y1 = this->GetBounds().y; + int x2 = x1 + this->GetBounds().width; + int y2 = y1 + this->GetBounds().height; + + if (this->__isClipBoundsSet) + { + x1 = (this->__clipBounds.x > x1) ? this->__clipBounds.x : x1; + y1 = (this->__clipBounds.y > y1) ? this->__clipBounds.y : y1; + x2 = (this->__clipBounds.x + this->__clipBounds.width < x2) ? this->__clipBounds.x + this->__clipBounds.width : x2; + y2 = (this->__clipBounds.y + this->__clipBounds.height < y2) ? this->__clipBounds.y + this->__clipBounds.height : y2; + } + + bool shouldWorkaround = ((bounds.x < x1) || (bounds.y < y1) || (bounds.x + bounds.w > x2) || (bounds.y + bounds.h > y2)) && (__dashData.pattern.Size() == 0); + + if (!shouldWorkaround && pCairo && pCairo->pCairo) + { + SET_CAIRO_DASH_STYLE; + SET_CAIRO_CLIPPING; + + if (__lineWidth.applied != _Util::ScalarHolder::AS_INTEGER) + { + _Cairo::DrawEllipse(pCairo->pCairo, this->__lineWidth.asDouble, composedColor, bounds); + } + else + { + _Cairo::DrawEllipse(pCairo->pCairo, this->__lineWidth.asInteger, composedColor, bounds); + } + + RESET_CAIRO_CLIPPING; + RESET_CAIRO_DASH_STYLE; + + return E_SUCCESS; + } + else + { + _CanvasEllipse ellipse; + _GpBufferInfo info; + + memset(&info, 0, sizeof(info)); + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.bitsPerPixel = 32; + info.pixelPerLine = bufferPitch; + info.pPixels = (void*) pBufferAddr; + info.color32 = composedColor; + info.isClipBoundsSet = this->__isClipBoundsSet; + info.clipBounds.SetBounds(this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); + + ellipse.SetLineWidth(this->__lineWidth.asInteger); + + return ellipse.DrawEllipse(int(bounds.x), int(bounds.y), int(bounds.w), int(bounds.h), info); + } +} + +result +_Canvas::DrawLine(const _Util::Point& point1, const _Util::Point& point2) +{ + _Util::Point doublePoint1 = + { + double(point1.x), + double(point1.y) + }; + + _Util::Point doublePoint2 = + { + double(point2.x), + double(point2.y) + }; + + return this->DrawLine(doublePoint1, doublePoint2); +} + +result +_Canvas::DrawLine(const _Util::Point& point1, const _Util::Point& point2) +{ + // this->__lineWidth is always greater than 0 + + unsigned long composedColor = _ComposeColor(this->__fgColor, this->__fgOpacity); + + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo && pCairo->pCairo) + { + _Util::Point point[] = + { + { point1.x, point1.y }, + { point2.x, point2.y } + }; + + SET_CAIRO_DASH_STYLE; + SET_CAIRO_CLIPPING; + + if (__lineWidth.applied != _Util::ScalarHolder::AS_INTEGER) + { + _Cairo::Drawline(pCairo->pCairo, this->__lineWidth.asDouble, composedColor, point, 2); + } + else + { + _Cairo::Drawline(pCairo->pCairo, this->__lineWidth.asInteger, composedColor, point, 2); + } + + RESET_CAIRO_CLIPPING; + RESET_CAIRO_DASH_STYLE; + + return E_SUCCESS; + } + else + { + _CanvasLine line; + _GpBufferInfo info; + + _GpPoint startPt = + { + int(point1.x), + int(point1.y) + }; + + _GpPoint endPt = + { + int(point2.x), + int(point2.y) + }; + + memset(&info, 0, sizeof(info)); + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.bitsPerPixel = 32; + info.pixelPerLine = bufferPitch; + info.pPixels = (void*) pBufferAddr; + info.color32 = composedColor; + info.isClipBoundsSet = this->__isClipBoundsSet; + info.clipBounds.SetBounds(this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); + + line.SetLineWidth(this->__lineWidth.asInteger); + + if (this->__lineWidth.asInteger == 1) + { + if ((startPt.x == endPt.x) && (startPt.y == endPt.y)) + { + this->SetPixel(point1); + return E_SUCCESS; + } + } + + return line.DrawLine(startPt, endPt, info); + } +} + +result +_Canvas::DrawPolygon(const _Util::Point* pPoints, unsigned int pointCount) +{ + // this->__lineWidth is always greater than 0 + + if (pointCount == 1) + { + return this->SetPixel(pPoints[0]); + } + + unsigned long composedColor = _ComposeColor(this->__fgColor, this->__fgOpacity); + + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo && pCairo->pCairo) + { + SET_CAIRO_DASH_STYLE; + SET_CAIRO_CLIPPING; + + _Cairo::DrawPolygon(pCairo->pCairo, this->__lineWidth.asInteger, composedColor, pPoints, pointCount); + + RESET_CAIRO_CLIPPING; + RESET_CAIRO_DASH_STYLE; + + return E_SUCCESS; + } + else + { + std::unique_ptr<_GpPoint[]> tempPoints(new (std::nothrow) _GpPoint[pointCount]); + + _GpPoint* pTempPoints = tempPoints.get(); + + if (pTempPoints == null) + { + return E_SYSTEM; + } + + for (unsigned int i = 0; i < pointCount; i++) + { + pTempPoints[i].x = int(pPoints[i].x); + pTempPoints[i].y = int(pPoints[i].y); + } + + _CanvasLine line; + _GpBufferInfo info; + + memset(&info, 0, sizeof(info)); + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.bitsPerPixel = 32; + info.pixelPerLine = bufferPitch; + info.pPixels = (void*) pBufferAddr; + info.color32 = composedColor; + info.isClipBoundsSet = this->__isClipBoundsSet; + info.clipBounds.SetBounds(this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); + + line.SetLineWidth(this->__lineWidth.asInteger); + + result r = line.DrawPolygon(int(pointCount), pTempPoints, info); + + return r; + } +} + +result +_Canvas::DrawPolyline(const _Util::Point* pPoints, unsigned int pointCount) +{ + // this->__lineWidth is always greater than 0 + + if (pointCount == 1) + { + return this->SetPixel(pPoints[0]); + } + + unsigned long composedColor = _ComposeColor(this->__fgColor, this->__fgOpacity); + + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo && pCairo->pCairo) + { + SET_CAIRO_DASH_STYLE; + SET_CAIRO_CLIPPING; + + if (__lineWidth.applied != _Util::ScalarHolder::AS_INTEGER) + { + _Cairo::DrawPolyline(pCairo->pCairo, this->__lineWidth.asDouble, composedColor, pPoints, pointCount); + } + else + { + _Cairo::DrawPolyline(pCairo->pCairo, this->__lineWidth.asInteger, composedColor, pPoints, pointCount); + } + + RESET_CAIRO_CLIPPING; + RESET_CAIRO_DASH_STYLE; + + return E_SUCCESS; + } + else + { + std::unique_ptr<_GpPoint[]> tempPoints(new (std::nothrow) _GpPoint[pointCount]); + + _GpPoint* pTempPoints = tempPoints.get(); + + if (pTempPoints == null) + { + return E_SYSTEM; + } + + for (unsigned int i = 0; i < pointCount; i++) + { + pTempPoints[i].x = int(pPoints[i].x); + pTempPoints[i].y = int(pPoints[i].y); + } + + _CanvasLine line; + _GpBufferInfo info; + + memset(&info, 0, sizeof(info)); + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.bitsPerPixel = 32; + info.pixelPerLine = bufferPitch; + info.pPixels = (void*) pBufferAddr; + info.color32 = composedColor; + info.isClipBoundsSet = this->__isClipBoundsSet; + info.clipBounds.SetBounds(this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); + + line.SetLineWidth(this->__lineWidth.asInteger); + + result r = line.DrawPolyLine(int(pointCount), pTempPoints, info); + + return r; + } +} + +result +_Canvas::DrawRectangle(const _Util::Rectangle& rect) +{ + _Util::Rectangle doubleRect = + { + double(rect.x), + double(rect.y), + double(rect.w), + double(rect.h) + }; + + return this->DrawRectangle(doubleRect); +} + +result +_Canvas::DrawRectangle(const _Util::Rectangle& rectangle) +{ + if ((rectangle.w <= 0.0) || (rectangle.h <= 0.0)) + { + return E_SUCCESS; + } + + unsigned long composedColor = _ComposeColor(this->__fgColor, this->__fgOpacity); + + bool tryToDrawWithCairo = (__lineWidth.applied == _Util::ScalarHolder::AS_DOUBLE || __lineWidth.asInteger > 1 || __dashData.pattern.Size() > 0); + + if (tryToDrawWithCairo) + { + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo && pCairo->pCairo) + { + SET_CAIRO_DASH_STYLE; + SET_CAIRO_CLIPPING; + + if (__lineWidth.applied != _Util::ScalarHolder::AS_INTEGER) + { + _Cairo::DrawRectangle(pCairo->pCairo, this->__lineWidth.asDouble, composedColor, rectangle); + } + else + { + _Cairo::DrawRectangle(pCairo->pCairo, this->__lineWidth.asInteger, composedColor, rectangle); + } + + RESET_CAIRO_CLIPPING; + RESET_CAIRO_DASH_STYLE; + + return E_SUCCESS; + } + } + + // falls through legacy drawing solution + + int x1 = static_cast(rectangle.x); + int y1 = static_cast(rectangle.y); + int x2 = x1 + static_cast(rectangle.w) - 1; + int y2 = y1 + static_cast(rectangle.h) - 1; + + if (this->__lineWidth.asInteger == 1) + { + if (!this->__isClipBoundsSet) + { + __pScratchPad->RegisterFillRect(_RasterOp::FnFillRectAlpha32Bit); + + if (x2 > x1 && y2 > y1) + { + __pScratchPad->FillRect(x1, y1, x2 - x1, 1, composedColor); + __pScratchPad->FillRect(x2, y1, 1, y2 - y1, composedColor); + + __pScratchPad->FillRect(x1 + 1, y2, x2 - x1, 1, composedColor); + __pScratchPad->FillRect(x1, y1 + 1, 1, y2 - y1, composedColor); + } + else + { + __pScratchPad->FillRect(x1, y1, static_cast(rectangle.w), static_cast(rectangle.h), composedColor); + } + + __pScratchPad->RegisterFillRect(null); + } + else + { + _Util::Rectangle clip = { this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height }; + + if (x2 > x1 && y2 > y1) + { + _Util::Rectangle rect1 = { x1, y1, x2 - x1, 1 }; + _Util::Rectangle rect2 = { x2, y1, 1, y2 - y1 }; + _Util::Rectangle rect3 = { x1 + 1, y2, x2 - x1, 1 }; + _Util::Rectangle rect4 = { x1, y1 + 1, 1, y2 - y1 }; + + _FillRectangleWithClip(__pScratchPad, composedColor, rect1, clip); + _FillRectangleWithClip(__pScratchPad, composedColor, rect2, clip); + _FillRectangleWithClip(__pScratchPad, composedColor, rect3, clip); + _FillRectangleWithClip(__pScratchPad, composedColor, rect4, clip); + } + else + { + _Util::Rectangle rect1 = { x1, y1, static_cast(rectangle.w), static_cast(rectangle.h) }; + + _FillRectangleWithClip(__pScratchPad, composedColor, rect1, clip); + } + } + + return E_SUCCESS; + } + else if (this->__lineWidth.asInteger > 1) + { + _GpPoint tempPoints[4] = + { + { x1, y1 }, + { x2, y1 }, + { x2, y2 }, + { x1, y2 } + }; + + _CanvasLine line; + _GpBufferInfo info; + + memset(&info, 0, sizeof(info)); + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.bitsPerPixel = 32; + info.pixelPerLine = bufferPitch; + info.pPixels = (void*) pBufferAddr; + info.color32 = composedColor; + info.isClipBoundsSet = this->__isClipBoundsSet; + info.clipBounds.SetBounds(this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); + + line.SetLineWidth(this->__lineWidth.asInteger); + + result r = line.DrawPolygon(4, tempPoints, info); + + return r; + } + + // this->__lineWidth is always greater than 0 + return E_SUCCESS; +} + +result +_Canvas::DrawRoundRectangle(const _Util::Rectangle& rect, const _Util::Dimension& arcDim) +{ + _Util::Rectangle doubleRect = + { + double(rect.x), + double(rect.y), + double(rect.w), + double(rect.h) + }; + + _Util::Dimension doubleArcDim = + { + double(rect.w), + double(rect.h) + }; + + return this->DrawRoundRectangle(doubleRect, doubleArcDim); +} + +result +_Canvas::DrawRoundRectangle(const _Util::Rectangle& rect, const _Util::Dimension& arcDim) +{ + if ((rect.w <= 0.0) || (rect.h <= 0)) + { + return E_SUCCESS; + } + + if ((int(arcDim.w) == 0) || (int(arcDim.h) == 0)) + { + return this->DrawRectangle(rect); + } + + _Util::Dimension revisedArcDim = + { + (arcDim.w <= rect.w / 2.0) ? arcDim.w : rect.w / 2.0, + (arcDim.h <= rect.h / 2.0) ? arcDim.h : rect.h / 2.0 + }; + + // this->__lineWidth is always greater than 0 + + unsigned long composedColor = _ComposeColor(this->__fgColor, this->__fgOpacity); + + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo && pCairo->pCairo) + { + SET_CAIRO_DASH_STYLE; + SET_CAIRO_CLIPPING; + + if (__lineWidth.applied != _Util::ScalarHolder::AS_INTEGER) + { + _Cairo::DrawRoundRectangle(pCairo->pCairo, this->__lineWidth.asDouble, composedColor, rect, revisedArcDim); + } + else + { + _Cairo::DrawRoundRectangle(pCairo->pCairo, this->__lineWidth.asInteger, composedColor, rect, revisedArcDim); + } + + RESET_CAIRO_CLIPPING; + RESET_CAIRO_DASH_STYLE; + + return E_SUCCESS; + } + else + { + _CanvasRoundRect roundRect; + _GpBufferInfo info; + + memset(&info, 0, sizeof(info)); + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.bitsPerPixel = 32; + info.pixelPerLine = bufferPitch; + info.pPixels = (void*) pBufferAddr; + info.color32 = composedColor; + info.isClipBoundsSet = this->__isClipBoundsSet; + info.clipBounds.SetBounds(this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); + + roundRect.SetLineWidth(this->__lineWidth.asInteger); + + return roundRect.DrawRoundRect(int(rect.x), int(rect.y), int(rect.w), int(rect.h), int(revisedArcDim.w), int(revisedArcDim.h), info); + } +} + +result +_Canvas::DrawTriangle(const _Util::Point& point1, const _Util::Point& point2, const _Util::Point& point3) +{ + // this->__lineWidth is always greater than 0 + + unsigned long composedColor = _ComposeColor(this->__fgColor, this->__fgOpacity); + + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo && pCairo->pCairo) + { + _Util::Point point[] = + { + { point1.x, point1.y }, + { point2.x, point2.y }, + { point3.x, point3.y } + }; + + SET_CAIRO_DASH_STYLE; + SET_CAIRO_CLIPPING; + + if (__lineWidth.applied != _Util::ScalarHolder::AS_INTEGER) + { + _Cairo::DrawPolygon(pCairo->pCairo, this->__lineWidth.asDouble, composedColor, point, 3); + } + else + { + _Cairo::DrawPolygon(pCairo->pCairo, this->__lineWidth.asInteger, composedColor, point, 3); + } + + RESET_CAIRO_CLIPPING; + RESET_CAIRO_DASH_STYLE; + + return E_SUCCESS; + } + else + { + _CanvasTriangle triangle; + _GpBufferInfo info; + + memset(&info, 0, sizeof(info)); + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.bitsPerPixel = 32; + info.pixelPerLine = bufferPitch; + info.pPixels = (void*) pBufferAddr; + info.color32 = composedColor; + info.isClipBoundsSet = this->__isClipBoundsSet; + info.clipBounds.SetBounds(this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); + + triangle.SetLineWidth(this->__lineWidth.asInteger); + + _GpPoint p1 = { int(point1.x), int(point1.y) }; + _GpPoint p2 = { int(point2.x), int(point2.y) }; + _GpPoint p3 = { int(point3.x), int(point3.y) }; + + return triangle.DrawTriangle(p1, p2, p3, info); + } +} + +result +_Canvas::FillTriangle(const Color& color, const _Util::Point& point1, const _Util::Point& point2, const _Util::Point& point3) +{ + unsigned long composedColor = _ComposeColor(color.GetRGB32(), this->__fgOpacity); + + _Util::Point doublePoint1 = + { + double(point1.x), + double(point1.y) + }; + + _Util::Point doublePoint2 = + { + double(point1.x), + double(point1.y) + }; + + _Util::Point doublePoint3 = + { + double(point1.x), + double(point1.y) + }; + + return this->__FillTriangle(composedColor, doublePoint1, doublePoint2, doublePoint3); +} + +result +_Canvas::FillTriangle(const Color& color, const _Util::Point& point1, const _Util::Point& point2, const _Util::Point& point3) +{ + unsigned long composedColor = _ComposeColor(color.GetRGB32(), this->__fgOpacity); + + return this->__FillTriangle(composedColor, point1, point2, point3); +} + +result +_Canvas::__FillTriangle(unsigned long composedColor, const _Util::Point& point1, const _Util::Point& point2, const _Util::Point& point3) +{ + // this->__lineWidth is always greater than 0 + + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo && pCairo->pCairo) + { + _Util::Point point[] = + { + { point1.x, point1.y }, + { point2.x, point2.y }, + { point3.x, point3.y } + }; + + SET_CAIRO_CLIPPING; + + _Cairo::FillPolygon(pCairo->pCairo, composedColor, point, 3); + + RESET_CAIRO_CLIPPING; + + return E_SUCCESS; + } + else + { + _CanvasTriangle triangle; + _GpBufferInfo info; + + memset(&info, 0, sizeof(info)); + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.bitsPerPixel = 32; + info.pixelPerLine = bufferPitch; + info.pPixels = (void*) pBufferAddr; + info.color32 = composedColor; + info.isClipBoundsSet = this->__isClipBoundsSet; + info.clipBounds.SetBounds(this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); + + triangle.SetLineWidth(this->__lineWidth.asInteger); + + return triangle.FillTriangle(int(point1.x), int(point1.y), int(point2.x), int(point2.y), int(point3.x), int(point3.y), info); + } +} + +result +_Canvas::__FillEllipse(unsigned long composedColor, const _Util::Rectangle& bounds) +{ + if ((bounds.w <= 0.0) || (bounds.h <= 0.0)) + { + return E_SUCCESS; + } + + // this->__lineWidth is always greater than 0 + + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo && pCairo->pCairo) + { + SET_CAIRO_CLIPPING; + + _Cairo::FillEllipse(pCairo->pCairo, composedColor, bounds); + + RESET_CAIRO_CLIPPING; + + return E_SUCCESS; + } + else + { + _CanvasEllipse ellipse; + _GpBufferInfo info; + + memset(&info, 0, sizeof(info)); + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.bitsPerPixel = 32; + info.pixelPerLine = bufferPitch; + info.pPixels = (void*) pBufferAddr; + info.color32 = composedColor; + info.isClipBoundsSet = this->__isClipBoundsSet; + info.clipBounds.SetBounds(this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); + + ellipse.SetLineWidth(this->__lineWidth.asInteger); + + return ellipse.FillElliepse(int(bounds.x), int(bounds.y), int(bounds.w), int(bounds.h), info); + } +} + +result +_Canvas::FillEllipse(const Color& color, const _Util::Rectangle& bounds) +{ + unsigned long composedColor = _ComposeColor(color.GetRGB32(), this->__fgOpacity); + + _Util::Rectangle doubleBounds = + { + double(bounds.x), + double(bounds.y), + double(bounds.w), + double(bounds.h) + }; + + return this->__FillEllipse(composedColor, doubleBounds); +} + +result +_Canvas::FillEllipse(const Color& color, const _Util::Rectangle& bounds) +{ + unsigned long composedColor = _ComposeColor(color.GetRGB32(), this->__fgOpacity); + + return this->__FillEllipse(composedColor, bounds); +} + +result +_Canvas::FillPolygon(const Color& color, const _Util::Point* pPoints, unsigned int pointCount) +{ + // + // Implementation of this method in API versions prior to 2.0 has the following issue: + // + // -# If there are 4 input points and conditions below is satisfied, the drawing result does not match the expected behavior. @n + // + // "point[0].x == point[3].x && point[1].x == point[2].x && point[0].y == point[1].y && point[2].y == point[3].y" + // + // there are 4 cases can be occurred. + // + // [case1] (p[0]->x > p[1]->x && p[0]->y > p[3]->y) + // + // p2________p3 + // | | + // | | + // | | <--- expected result + // | | + // p1--------p0_________ + // | | + // | | + // | | <--- wrong result + // | | + // --------- + // + // [case2] (p[0]->x < p[1]->x && p[0]->y > p[3]->y) + // + // p3________p2 + // | | + // | | + // | | <--- expected result + // | | + // p0--------p1 + // | | + // | | + // | | <--- wrong result + // | | + // --------- + // + // [case3] (p[0]->x < p[1]->x && p[0]->y < p[3]->y) + // + // p0________p1 + // | | + // | | + // | | <--- no problem. + // | | + // p3--------p2 + // + // + // [case4] (p[0]->x > p[1]->x && p[0]->y < p[3]->y) + // + // p1________p0________ + // | | | + // | | | + // | | | <--- wrong result + // | | | + // p2--------p3-------- + // ^ + // | + // -- expected result + // + // The issue mentioned above is resolved in API version 2.0, So, check the SDK version and emulate problem before step forward furthermore. + // + // CR approved, no. EP-47D6817268074396919211307C39CA55 + // + + // this->__lineWidth is always greater than 0 + + unsigned long composedColor = _ComposeColor(color.GetRGB32(), this->__fgOpacity); + + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo && pCairo->pCairo) + { + SET_CAIRO_CLIPPING; + + _Cairo::FillPolygon(pCairo->pCairo, composedColor, pPoints, pointCount); + + RESET_CAIRO_CLIPPING; + + return E_SUCCESS; + } + else + { + _CanvasFillPolygon polygon; + _GpBufferInfo info; + + memset(&info, 0, sizeof(info)); + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.bitsPerPixel = 32; + info.pixelPerLine = bufferPitch; + info.pPixels = (void*) pBufferAddr; + info.color32 = composedColor; + info.isClipBoundsSet = this->__isClipBoundsSet; + info.clipBounds.SetBounds(this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); + + polygon.SetLineWidth(this->__lineWidth.asInteger); + + std::unique_ptr<_GpPoint[]> tempPoints(new (std::nothrow) _GpPoint[pointCount]); + + _GpPoint* pTempPoints = tempPoints.get(); + + if (pTempPoints == null) + { + return E_SYSTEM; + } + + for (unsigned int i = 0; i < pointCount; i++) + { + pTempPoints[i].x = int(pPoints[i].x); + pTempPoints[i].y = int(pPoints[i].y); + } + + result r = polygon.FillPolygon(int(pointCount), pTempPoints, info); + + return r; + } +} + +result +_Canvas::__FillRectangle(unsigned long composedColor, const _Util::Rectangle& rectangle) +{ + if ((rectangle.w <= 0.0) || (rectangle.h <= 0.0)) + { + return E_SUCCESS; + } + + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo && pCairo->pCairo) + { + SET_CAIRO_CLIPPING; + + _Cairo::FillRectangle(pCairo->pCairo, composedColor, rectangle); + + RESET_CAIRO_CLIPPING; + + return E_SUCCESS; + } + else + { + _Util::Rectangle rect = + { + static_cast(rectangle.x), + static_cast(rectangle.y), + static_cast(rectangle.w), + static_cast(rectangle.h) + }; + + if (this->__isClipBoundsSet) + { + int x1 = rect.x; + int y1 = rect.y; + int x2 = x1 + rect.w; + int y2 = y1 + rect.h; + + x1 = (x1 >= this->__clipBounds.x) ? x1 : this->__clipBounds.x; + y1 = (y1 >= this->__clipBounds.y) ? y1 : this->__clipBounds.y; + + x2 = (x2 <= this->__clipBounds.x + this->__clipBounds.width) ? x2 : this->__clipBounds.x + this->__clipBounds.width; + y2 = (y2 <= this->__clipBounds.y + this->__clipBounds.height) ? y2 : this->__clipBounds.y + this->__clipBounds.height; + + rect.x = x1; + rect.y = y1; + rect.w = x2 - x1; + rect.h = y2 - y1; + } + + if (rect.w > 0 && rect.h > 0) + { + // alpha-fill-rect() applied + __pScratchPad->RegisterFillRect(_RasterOp::FnFillRectAlpha32Bit); + __pScratchPad->FillRect(rect.x, rect.y, rect.w, rect.h, composedColor); + __pScratchPad->RegisterFillRect(null); + } + } + + return E_SUCCESS; +} + +result +_Canvas::FillRectangle(const Color& color, const Rectangle& rect) +{ + unsigned long composedColor = _ComposeColor(color.GetRGB32(), this->__fgOpacity); + + return this->__FillRectangle(composedColor, _Util::Convert >(rect)); +} + +result +_Canvas::FillRectangle(const Color& color, const _Util::Rectangle& rect) +{ + unsigned long composedColor = _ComposeColor(color.GetRGB32(), this->__fgOpacity); + + _Util::Rectangle doubleRect = + { + double(rect.x), + double(rect.y), + double(rect.w), + double(rect.h) + }; + + return this->__FillRectangle(composedColor, doubleRect); +} + +result +_Canvas::FillRectangle(const Color& color, const _Util::Rectangle& rect) +{ + unsigned long composedColor = _ComposeColor(color.GetRGB32(), this->__fgOpacity); + + return this->__FillRectangle(composedColor, rect); +} + +result +_Canvas::FillRoundRectangle(const Color& color, const _Util::Rectangle& rect, const _Util::Dimension& arcDim) +{ + unsigned long composedColor = _ComposeColor(color.GetRGB32(), this->__fgOpacity); + + _Util::Rectangle doubleRect = + { + double(rect.x), + double(rect.y), + double(rect.w), + double(rect.h) + }; + + _Util::Dimension doubleArcDim = + { + double(rect.w), + double(rect.h) + }; + + return this->__FillRoundRectangle(composedColor, doubleRect, doubleArcDim); +} + +result +_Canvas::FillRoundRectangle(const Color& color, const _Util::Rectangle& rect, const _Util::Dimension& arcDim) +{ + unsigned long composedColor = _ComposeColor(color.GetRGB32(), this->__fgOpacity); + + return this->__FillRoundRectangle(composedColor, rect, arcDim); +} + +result +_Canvas::__FillRoundRectangle(unsigned long composedColor, const _Util::Rectangle& rect, const _Util::Dimension& arcDim) +{ + if ((rect.w <= 0.0) || (rect.h <= 0.0)) + { + return E_SUCCESS; + } + + if ((int(arcDim.w) <= 0) || (int(arcDim.h) <= 0)) + { + return this->__FillRectangle(composedColor, rect); + } + + _Util::Dimension revisedArcDim = + { + (arcDim.w <= rect.w / 2.0) ? arcDim.w : rect.w / 2.0, + (arcDim.h <= rect.h / 2.0) ? arcDim.h : rect.h / 2.0 + }; + + // this->__lineWidth is always greater than 0 + + _NativeGfxEngine* pCairo = static_cast<_NativeGfxEngine*>(_pNativeGfxEngine); + + if (pCairo && pCairo->pCairo) + { + SET_CAIRO_CLIPPING; + + _Cairo::FillRoundRectangle(pCairo->pCairo, composedColor, rect, revisedArcDim); + + RESET_CAIRO_CLIPPING; + + return E_SUCCESS; + } + else + { + _CanvasRoundRect roundRect; + _GpBufferInfo info; + + memset(&info, 0, sizeof(info)); + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.bitsPerPixel = 32; + info.pixelPerLine = bufferPitch; + info.pPixels = (void*) pBufferAddr; + info.color32 = composedColor; + info.isClipBoundsSet = this->__isClipBoundsSet; + info.clipBounds.SetBounds(this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height); + + roundRect.SetLineWidth(this->__lineWidth.asInteger); + + return roundRect.FillRoundRectangle(int(rect.x), int(rect.y), int(rect.w), int(rect.h), int(revisedArcDim.w), int(revisedArcDim.h), info); + } +} + +result +_Canvas::DrawText(const Point& point, const Tizen::Base::String& text) +{ + return _Font::DrawText(*this, point, text, 0, text.GetLength()); +} + +result +_Canvas::DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, int length) +{ + return _Font::DrawText(*this, point, text, startIndex, length); +} + +result +_Canvas::DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor) +{ + return _Font::DrawText(*this, point, text, startIndex, length, outlineColor); +} + +Rectangle +_Canvas::GetBounds(void) const +{ + Rectangle rect(this->__xBufferPos, this->__yBufferPos, __pScratchPad->GetWidth(), __pScratchPad->GetHeight()); + + if (this->__windowHandle != INVALID_HANDLE) + { + rect.x = 0; + rect.y = 0; + } + + return rect; +} + +LineStyle +_Canvas::GetLineStyle() const +{ + SysTryReturn(NID_GRP, this && this->__pSurface, LINE_STYLE_MAX, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + return this->__lineStyle; +} + +int +_Canvas::GetLineWidth() const +{ + SysTryReturn(NID_GRP, this && this->__pSurface, -1, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + return this->__lineWidth.asInteger; +} + +result +_Canvas::SetLineStyle(LineStyle style) +{ + this->__lineStyle = style; + + return E_SUCCESS; +} + +result +_Canvas::SetLineWidth(int width, float widthAsFloat) +{ + SysTryReturnResult(NID_GRP, width > 0, E_OUT_OF_RANGE, "The given line width(%d) is out of range.\n", width); + + this->__lineWidth = width; + this->__lineWidth.asDouble = double(widthAsFloat); + + return E_SUCCESS; +} + +result +_Canvas::SetLineWidth(float width) +{ + SysTryReturnResult(NID_GRP, width > 0.0f, E_OUT_OF_RANGE, "The given line width(%f) is out of range.\n", width); + + this->__lineWidth = width; + + return E_SUCCESS; +} + +result +_Canvas::SetDashPattern(const Tizen::Graphics::_Util::AccumList& dashValueList, double offset) +{ + SysTryReturn(NID_GRP, this && this->__pSurface, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + { + Tizen::Graphics::_Util::AccumList listSwap; + this->__dashData.pattern.Swap(listSwap); + + this->__dashData.offset = 0.0; + } + + { + Tizen::Graphics::_Util::AccumList::ConstIterator dashIterator = dashValueList.Begin(); + + for (; dashIterator != dashValueList.End(); dashIterator++) + { + this->__dashData.pattern.Push(*dashIterator); + } + + this->__dashData.offset = offset; + } + + return E_SUCCESS; +} + +void +_Canvas::SetDrawingQuality(BitmapDrawingQuality quality) +{ + // 'quality' is verified in _CanvasImpl::SetDrawingQuality() + this->__bitmapDrawingQuality = quality; +} + +BitmapDrawingQuality +_Canvas::GetDrawingQuality(void) const +{ + return this->__bitmapDrawingQuality; +} + +void +_Canvas::SetBlendingMode(BlendingMode blendingMode) +{ + // 'blendingMode' is verified in _CanvasImpl::SetBlendingMode() + this->__blendingMode = blendingMode; +} + +BlendingMode +_Canvas::GetBlendingMode(void) const +{ + return this->__blendingMode; +} + +result +_Canvas::GetPixel(const Point& point, Color& color) const +{ + Point pos(point.x, point.y); + + // [ykahn 2011.06.27] revise the value of 'point' if it goes out-of-range + { + Rectangle rtCanvas = _GetBoundsRel(*this); + + SysTryReturnResult(NID_GRP, !rtCanvas.IsEmpty(), E_OUT_OF_RANGE, "Cannot get the bounds of the canvas.\n"); + + if (pos.x >= rtCanvas.width && rtCanvas.width >= 1) + { + pos.x = rtCanvas.width - 1; + } + + if (pos.y >= rtCanvas.height && rtCanvas.height >= 1) + { + pos.y = rtCanvas.height - 1; + } + } + + { + result r = E_OUT_OF_RANGE; + + Rectangle rect = this->GetBounds(); + + rect.x = 0; + rect.y = 0; + + if ((point.x >= rect.x && point.x < rect.x + rect.width) && (point.y >= rect.y && point.y < rect.y + rect.height)) + { + BufferInfo info; + + (const_cast<_Canvas*>(this))->Lock(info); + + if (info.bitsPerPixel == 32) + { + unsigned long* pDest32 = (unsigned long*) info.pPixels; + long pitch = info.pitch / 4; + + color.SetRGB32(pDest32[pitch * point.y + point.x], true); + + r = E_SUCCESS; + } + else if (info.bitsPerPixel == 16) + { + unsigned short* pDest16 = (unsigned short*) info.pPixels; + long pitch = info.pitch / 2; + + unsigned short color16 = pDest16[pitch * point.y + point.x]; + + unsigned long r = (color16 & 0xF800) >> 8; + unsigned long g = (color16 & 0x07E0) >> 3; + unsigned long b = (color16 & 0x001F) << 3; + + r += (r >> 5); + g += (g >> 6); + b += (b >> 5); + + unsigned long color32 = 0xFF000000 | (r << 16) | (g << 8) | (b); + + color.SetRGB32(color32, true); + + r = E_SUCCESS; + } + + (const_cast<_Canvas*>(this))->Unlock(); + } + + return r; + } +} + +result +_Canvas::SetPixel(const _Util::Point& point) +{ + unsigned long composedColor = _ComposeColor(this->__fgColor, this->__fgOpacity); + + if (!this->__isClipBoundsSet) + { + __pScratchPad->FillRect(point.x, point.y, 1, 1, composedColor); + } + else + { + _Util::Rectangle rect = { point.x, point.y, 1, 1 }; + _Util::Rectangle clip = { this->__clipBounds.x, this->__clipBounds.y, this->__clipBounds.width, this->__clipBounds.height }; + + _FillRectangleWithClip(__pScratchPad, composedColor, rect, clip); + } + + return E_SUCCESS; +} + +result +_Canvas::SetPixel(const _Util::Point& point) +{ + _Util::Rectangle doubleRect = + { + point.x, + point.y, + 1.0, + 1.0 + }; + + unsigned long composedColor = _ComposeColor(this->__fgColor, this->__fgOpacity); + + this->__FillRectangle(composedColor, doubleRect); + + return E_SUCCESS; +} + +result +_Canvas::Show() +{ + int bufferWidth = __pSurface->GetWidth(); + int bufferHeight = __pSurface->GetHeight(); + int bufferPpl = __pSurface->GetPitch(); + + // cannot use 'if (__pSurface->GetHandle())' + if (this->__windowHandle != INVALID_HANDLE) + { +#if 0 + evas_object_image_pixels_dirty_set((Evas_Object*) this->__windowHandle, true); +#else + Evas_Object* pSourceObject = _GetWindowSourceObject(this->__windowHandle); + evas_object_image_data_set(pSourceObject, evas_object_image_data_get(pSourceObject, EINA_TRUE)); + evas_object_image_data_update_add(pSourceObject, 0, 0, bufferWidth, bufferHeight); +#endif + + evas_object_show((Evas_Object*) this->__windowHandle); + + _FlushCanvas(); + } + else + { + SysTryReturnResult(NID_GRP, Tizen::App::_AppInfo::IsOspCompat(), E_UNSUPPORTED_OPERATION, "This method is unsupported in Tizen."); + + _CanvasShowFromMemory(this->__xBufferPos, this->__yBufferPos, 0, 0, bufferWidth, bufferHeight, __pBuffer, bufferWidth, bufferHeight, 32, bufferPpl * 4); + } + + return E_SUCCESS; +} + +result +_Canvas::Show(const Rectangle& rect) +{ + if ((rect.width == 0) || (rect.height == 0)) + { + return E_SUCCESS; + } + + if (this->__windowHandle != INVALID_HANDLE) + { + int x1 = rect.x; + int x2 = rect.x + rect.width; + int y1 = rect.y; + int y2 = rect.y + rect.height; + + if (x1 + 1 < x2) + { + x1++; + } + + if (x2 - 1 > x1) + { + x2--; + } + + if (y1 + 1 < y2) + { + y1++; + } + + if (y2 - 1 > y1) + { + y2--; + } + +#if 0 + evas_object_image_pixels_dirty_set((Evas_Object*) this->__windowHandle, true); + // same as evas_object_image_data_update_add((Evas_Object*)this->__windowHandle, rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2), if (width >= 3) and (height >= 3) + evas_object_image_data_update_add((Evas_Object*) this->__windowHandle, x1, y1, x2 - x1, y2 - y1); +#else + Evas_Object* pSourceObject = _GetWindowSourceObject(this->__windowHandle); + evas_object_image_data_set(pSourceObject, evas_object_image_data_get(pSourceObject, EINA_TRUE)); + evas_object_image_data_update_add(pSourceObject, x1, y1, x2 - x1, y2 - y1); +#endif + + evas_object_show((Evas_Object*) this->__windowHandle); + + _FlushCanvas(); + } + else + { + SysTryReturnResult(NID_GRP, Tizen::App::_AppInfo::IsOspCompat(), E_UNSUPPORTED_OPERATION, "This method is unsupported in Tizen."); + + int bufferWidth = __pSurface->GetWidth(); + int bufferHeight = __pSurface->GetHeight(); + int bufferPpl = __pSurface->GetPitch(); + + _CanvasShowFromMemory(this->__xBufferPos + rect.x, this->__yBufferPos + rect.y, rect.x, rect.y, rect.width, rect.height, __pBuffer, bufferWidth, bufferHeight, 32, bufferPpl * 4); + } + + return E_SUCCESS; +} + +result +_Canvas::SetFont(const _Font& font) +{ + SysTryReturn(NID_GRP, this && this->__pSurface, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + // weak reference + this->__pFont = const_cast<_Font*>(&font); + + return E_SUCCESS; +} + +result +_Canvas::SetPriorityFont(const _Font& font) +{ + SysTryReturn(NID_GRP, this && this->__pSurface, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + // weak reference + this->__pPriorityFont = const_cast<_Font*>(&font); + + return E_SUCCESS; +} + +void +_Canvas::ResetPriorityFont(void) +{ + // nullify weak reference + this->__pPriorityFont = null; +} + +result +_Canvas::SetClipBounds(const Rectangle& rect) +{ + if (__pScratchPad == null) + { + return E_SYSTEM; + } + + int x1 = rect.x; + int y1 = rect.y; + int x2 = x1 + rect.width; + int y2 = y1 + rect.height; + + x1 = (x1 > 0) ? x1 : 0; + y1 = (y1 > 0) ? y1 : 0; + x2 = (x2 < __pScratchPad->GetWidth()) ? x2 : __pScratchPad->GetWidth(); + y2 = (y2 < __pScratchPad->GetHeight()) ? y2 : __pScratchPad->GetHeight(); + + x2 = (x1 > x2) ? x1 : x2; + y2 = (y1 > y2) ? y1 : y2; + + if (x1 == 0 && y1 == 0 && x2 == __pScratchPad->GetWidth() && y2 == __pScratchPad->GetHeight()) + { + this->__isClipBoundsSet = false; + } + else + { + this->__isClipBoundsSet = true; + } + + this->__clipBounds.SetBounds(x1, y1, x2 - x1, y2 - y1); + + return E_SUCCESS; +} + +Rectangle +_Canvas::GetClipBounds(void) const +{ + Rectangle rect; + + SysTryReturn(NID_GRP, this && this->__pSurface, rect, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + this->__GetClipBounds(rect); + + return rect; +} + +result +_Canvas::Lock(BufferInfo& info, long timeout) +{ + if (__pScratchPad == null) + { + return E_SYSTEM; + } + + if (_BufferInfoImpl::GetInstance(info) != null) + { + _BufferInfoImpl::GetInstance(info)->SetHandle(_BufferInfoImpl::HANDLE_TYPE_NONE, 0); + } + + SystemPixel* pBufferAddr = null; + int bufferPitch = 0; + + __pScratchPad->GetBuffer(pBufferAddr, bufferPitch); + + info.width = __pScratchPad->GetWidth(); + info.height = __pScratchPad->GetHeight(); + info.pitch = bufferPitch * sizeof(_SystemPixel); + info.bitsPerPixel = sizeof(_SystemPixel) * 8; + info.pixelFormat = PIXEL_FORMAT_ARGB8888; + info.pPixels = (void*) pBufferAddr; + //info.__handle = INVALID_HANDLE; + + return E_SUCCESS; +} + +result +_Canvas::Unlock() +{ + return E_SUCCESS; +} + +void +_Canvas::SetForegroundColor(const Color& fgColor) +{ + this->__fgColorNative = fgColor; + this->__ComposeFgColor(); +} + +Color +_Canvas::GetForegroundColor(void) +{ + return Color(this->__fgColor); +} + +void +_Canvas::SetBackgroundColor(const Color& bgColor) +{ + this->__bgColorNative = bgColor; + this->__ComposeBgColor(); +} + +Color +_Canvas::GetBackgroundColor(void) +{ + return Color(this->__bgColor); +} + +void +_Canvas::SetForegroundOpacity(int level) +{ + SysTryReturnVoidResult(NID_GRP, this && this->__pSurface, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + if (level < 0) + { + level = 0; + } + + if (level > 255) + { + level = 255; + } + + this->__fgOpacity = level; + this->__ComposeFgColor(); +} + +int +_Canvas::GetForegroundOpacity(void) +{ + SysTryReturn(NID_GRP, this && this->__pSurface, 255, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + return this->__fgOpacity; +} + +void +_Canvas::SetBackgroundOpacity(int level) +{ + SysTryReturnVoidResult(NID_GRP, this && this->__pSurface, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + if (level < 0) + { + level = 0; + } + + if (level > 255) + { + level = 255; + } + + this->__bgOpacity = level; + this->__ComposeBgColor(); +} + +int +_Canvas::GetBackgroundOpacity(void) +{ + SysTryReturn(NID_GRP, this && this->__pSurface, 255, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + return this->__bgOpacity; +} + +result +_Canvas::SetPosition(int x, int y) +{ + SysTryReturnResult(NID_GRP, this->__windowHandle == INVALID_HANDLE, E_UNSUPPORTED_OPERATION, "Window canvas does not support moving the position.\n"); + + __xBufferPos = x; + __yBufferPos = y; + + return E_SUCCESS; +} + +_Canvas* +_Canvas::GetInstance(_CanvasImpl& canvas) +{ + return (&canvas != null) ? canvas._pNativeCanvas : null; +} + +const _Canvas* +_Canvas::GetInstance(const _CanvasImpl& canvas) +{ + return (&canvas != null) ? canvas._pNativeCanvas : null; +} + +bool +_Canvas::_IsWindowCanvas(void) const +{ + if (!(this && this->__pSurface)) + { + return false; + } + + return (this->__windowHandle != INVALID_HANDLE); +} + +result +_Canvas::_SetPosition(int x, int y) +{ + if (!(this && this->__pSurface)) + { + return E_OPERATION_FAILED; + } + + if (this->__windowHandle != INVALID_HANDLE) + { + return E_UNSUPPORTED_OPERATION; + } + + //?? what is this function ? + __xBufferPos = x; + __yBufferPos = y; + + return E_SUCCESS; +} + +int +_Canvas::_GetAlphaAttenuation(const _Bitmap& bitmap) const +{ + // 'bitmap' and 'this' are always valid. + + int alphaConstant = bitmap.GetAlphaConstant(); + + alphaConstant = (alphaConstant > 255) ? 255 : alphaConstant; + alphaConstant = (alphaConstant < 0) ? 0 : alphaConstant; + + int fgOpacity = this->__fgOpacity; + + if (fgOpacity > 0 && fgOpacity < 255) + { + fgOpacity += (fgOpacity >> 7); + alphaConstant = (alphaConstant * fgOpacity) >> 8; + } + + return alphaConstant; +} + +void +_Canvas::_SetBlendOption(_Canvas::BlendOption blendOption) +{ + if (!(this && this->__pSurface)) + { + return; + } + + if (blendOption < BLEND_MIN || blendOption >= BLEND_MAX) + { + return; + } + + this->__blendOption = blendOption; +} + +_Canvas::BlendOption +_Canvas::_GetBlendOption(void) const +{ + if (!(this && this->__pSurface)) + { + // default + return BLEND_ALPHABLEND; + } + + return this->__blendOption; +} + +void +_Canvas::__InitFgBgColorFromTheme(void) +{ + __fgColorNative = (_GetDefaultForegroundColor) ? _GetDefaultForegroundColor() : Color(0xFF000000); + __bgColorNative = (_GetDefaultBackgroundColor) ? _GetDefaultBackgroundColor() : Color(0xFFFFFFFF); + + this->__ComposeFgColor(); + this->__ComposeBgColor(); +} + +void +_Canvas::__ComposeFgColor(void) +{ + this->__fgColor = _ComposeColor(this->__fgColorNative.GetRGB32(), this->__fgOpacity); +} + +void +_Canvas::__ComposeBgColor(void) +{ + this->__bgColor = _ComposeColor(this->__bgColorNative.GetRGB32(), this->__bgOpacity); +} + +void +_Canvas::__GetClipBounds(Rectangle& rect) const +{ + if (this->__isClipBoundsSet) + { + rect = this->__clipBounds; + } + else + { + rect = Rectangle(0, 0, __pScratchPad->GetWidth(), __pScratchPad->GetHeight()); + } +} + +result +_Canvas::__Copy(const Point& destPoint, const _Canvas& srcCanvas, const Rectangle& srcRect) +{ + const _Canvas* pSrcCanvas = &srcCanvas; + + Rectangle clippedSrcRect(srcRect); + + if (_ClipRectangle(clippedSrcRect.x, clippedSrcRect.y, clippedSrcRect.width, clippedSrcRect.height, 0, 0, pSrcCanvas->__pScratchPad->GetWidth(), pSrcCanvas->__pScratchPad->GetHeight()) == CLIP_REJECT) + { + return E_SUCCESS; + } + + __pScratchPad->BitBlt(destPoint.x, destPoint.y, pSrcCanvas->__pScratchPad, clippedSrcRect.x, clippedSrcRect.y, clippedSrcRect.width, clippedSrcRect.height); + + return E_SUCCESS; +} + +result +_Canvas::__Copy(const Rectangle& destRect, const _Canvas& srcCanvas, const Rectangle& srcRect) +{ + const _Canvas* pSrcCanvas = &srcCanvas; + + Rectangle clippedSrcRect(srcRect); + + if (_ClipRectangle(clippedSrcRect.x, clippedSrcRect.y, clippedSrcRect.width, clippedSrcRect.height, 0, 0, pSrcCanvas->__pScratchPad->GetWidth(), pSrcCanvas->__pScratchPad->GetHeight()) == CLIP_REJECT) + { + return E_SUCCESS; + } + + { + SystemPixel* pSrcAddr = null; + int srcPitch = 0; + + pSrcCanvas->__pScratchPad->GetBuffer(pSrcAddr, srcPitch); + pSrcAddr += srcPitch * clippedSrcRect.y + clippedSrcRect.x; + + SystemPixel* pDstAddr = null; + int dstPitch = 0; + + __pScratchPad->GetBuffer(pDstAddr, dstPitch); + + _Util::Pixmap srcImageEx(clippedSrcRect.width, clippedSrcRect.height, sizeof(SystemPixel) * 8, pSrcAddr, srcPitch * sizeof(SystemPixel)); + _Util::Pixmap dstImageEx(__pScratchPad->GetWidth(), __pScratchPad->GetHeight(), sizeof(SystemPixel) * 8, pDstAddr, dstPitch * sizeof(SystemPixel)); + + Tizen::Graphics::_Effect::ScaleImage(dstImageEx, destRect.x, destRect.y, destRect.width, destRect.height, srcImageEx); + } + + return E_SUCCESS; +} + +}} // Tizen::Graphics + diff --git a/src/graphics/FGrp_Canvas.h b/src/graphics/FGrp_Canvas.h new file mode 100644 index 0000000..214a1a2 --- /dev/null +++ b/src/graphics/FGrp_Canvas.h @@ -0,0 +1,266 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Canvas.h + * @brief This is the header file for the _Canvas class. + * + */ + +#ifndef _FGRP_INTERNAL_CANVAS_H_ +#define _FGRP_INTERNAL_CANVAS_H_ + +#include +#include + +#include + +#include "FGrp_CanvasImpl.h" + +#include "util/FGrp_UtilPixmap.h" +#include "util/FGrp_UtilScratchpad.h" +#include "util/FGrp_UtilTemplate.h" +#include "util/FGrp_Util.h" + + +namespace Tizen { namespace Ui {namespace Animations +{ +class _VisualElementCanvas; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Graphics +{ +class Point; +class FloatPoint; +class Dimension; +class FloatDimension; +class Rectangle; +class FloatRectangle; +class BufferInfo; + +class _CanvasImpl; +class _Bitmap; +class _Font; + +class _Canvas +{ +public: + typedef unsigned long SystemPixel; + + enum BlendOption + { + BLEND_MIN = 0, + BLEND_COPY = BLEND_MIN, + BLEND_ALPHABLEND, + BLEND_MAX, + }; + +public: + _Canvas(void); + virtual ~_Canvas(void); + + result Construct(void); + result Construct(const Rectangle& rect); + result Construct(Handle windowHandle, const Rectangle& rect); + result Construct(_Canvas* pSourceCanvas, const Rectangle& subRegion); + result Construct(const BufferInfo& bufferInfo); + + bool IsValid(void) const; + + result Clear(void); + result Clear(const Rectangle& rect); + + result Copy(const Point& destPoint, const _Canvas& srcCanvas, const Rectangle& srcRect); + result Copy(const Rectangle& destRect, const _Canvas& srcCanvas, const Rectangle& srcRect); + result Copy(const Point& destPoint, const _Canvas& srcCanvas, const Rectangle& srcRect, BlendingMode blendingMode); + result CopyReverse(const Point& destPoint, const _Canvas& srcCanvas, const Rectangle& srcRect); + + result SetLineStyle(LineStyle style); + LineStyle GetLineStyle(void) const; + + result SetLineWidth(int width, float auxWidth); + result SetLineWidth(float width); // floating-point version + int GetLineWidth(void) const; + + result SetDashPattern(const Tizen::Graphics::_Util::AccumList& dashValueList, double offset); + + void SetDrawingQuality(BitmapDrawingQuality quality); + BitmapDrawingQuality GetDrawingQuality(void) const; + + void SetBlendingMode(BlendingMode blendingMode); + BlendingMode GetBlendingMode(void) const; + + result GetPixel(const Point& point, Color& color) const; + + result SetPixel(const _Util::Point& point); + result SetPixel(const _Util::Point& point); // floating-point version + + result DrawRectangle(const _Util::Rectangle& rect); + result DrawRectangle(const _Util::Rectangle& rect); // floating-point version + result FillRectangle(const Color& color, const Rectangle& rect); + result FillRectangle(const Color& color, const _Util::Rectangle& rect); + result FillRectangle(const Color& color, const _Util::Rectangle& rect); // floating-point version + + result DrawRoundRectangle(const _Util::Rectangle& rect, const _Util::Dimension& arcDim); + result DrawRoundRectangle(const _Util::Rectangle& rect, const _Util::Dimension& arcDim); // floating-point version + result FillRoundRectangle(const Color& color, const _Util::Rectangle& rect, const _Util::Dimension& arcDim); + result FillRoundRectangle(const Color& color, const _Util::Rectangle& rect, const _Util::Dimension& arcDim); // floating-point version + + result DrawEllipse(const _Util::Rectangle& rect); + result DrawEllipse(const _Util::Rectangle& rect); // floating-point version + result FillEllipse(const Color& color, const _Util::Rectangle& rect); + result FillEllipse(const Color& color, const _Util::Rectangle& rect); // floating-point version + + result DrawArc(const _Util::Rectangle& rect, double startAngle, double endAngle, ArcStyle arcStyle); // floating-point version + + result DrawTriangle(const _Util::Point& point1, const _Util::Point& point2, const _Util::Point& point3); // floating-point version + result FillTriangle(const Color& color, const _Util::Point& point1, const _Util::Point& point2, const _Util::Point& point3); + result FillTriangle(const Color& color, const _Util::Point& point1, const _Util::Point& point2, const _Util::Point& point3); // floating-point version + + result DrawLine(const _Util::Point& point1, const _Util::Point& point2); + result DrawLine(const _Util::Point& point1, const _Util::Point& point2); // floating-point version + result DrawPolyline(const _Util::Point* pPoints, unsigned int pointCount); + result DrawPolygon(const _Util::Point* pPoints, unsigned int pointCount); + result FillPolygon(const Color& color, const _Util::Point* pPoints, unsigned int pointCount); + + result SetFont(const _Font& font); + + result SetPriorityFont(const _Font& font); + void ResetPriorityFont(void); + + result DrawText(const Point& point, const Tizen::Base::String& text); + result DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, int length); + result DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor); + + result DrawBitmap(const Point& point, const _Bitmap& bitmap); + result DrawBitmap(const Rectangle& rect, const _Bitmap& bitmap); + result DrawBitmap(const Rectangle& destRect, const _Bitmap& srcBitmap, const Rectangle& srcRect); + result DrawBitmapForNinePatchedBitmap(const Rectangle& destRect, const _Bitmap& srcBitmap, const Rectangle& srcRect); + result DrawBitmap(const Point& point, const _Bitmap& bitmap, FlipDirection dir); + result DrawBitmap(const Point& point, const _Bitmap& bitmap, const Point& pivot, int degree); + result DrawNinePatchedBitmap(const Rectangle& rect, const _Bitmap& bitmap); + + result Show(void); + result Show(const Rectangle& rect); + + Rectangle GetBounds(void) const; + + result SetClipBounds(const Rectangle& rect); + Rectangle GetClipBounds(void) const; + + result Lock(BufferInfo& info, long timeout = INFINITE); + result Unlock(void); + + void SetForegroundColor(const Color& color); + Color GetForegroundColor(void); + void SetBackgroundColor(const Color& color); + Color GetBackgroundColor(void); + + void SetForegroundOpacity(int level); + int GetForegroundOpacity(void); + void SetBackgroundOpacity(int level); + int GetBackgroundOpacity(void); + + result SetPosition(int x, int y); + + static _Canvas* GetInstance(_CanvasImpl& canvas); + static const _Canvas* GetInstance(const _CanvasImpl& canvas); + +protected: + bool _IsWindowCanvas(void) const; + result _SetPosition(int x, int y); + int _GetAlphaAttenuation(const _Bitmap& bitmap) const; + + void _SetBlendOption(BlendOption); + BlendOption _GetBlendOption(void) const; + +private: + _Canvas(const _Canvas& canvas); + _Canvas& operator =(const _Canvas& value); + + void __InitFgBgColorFromTheme(void); + + void __ComposeFgColor(void); + void __ComposeBgColor(void); + + void __GetClipBounds(Rectangle& rect) const; + + result __Copy(const Point& destPoint, const _Canvas& srcCanvas, const Rectangle& srcRect); + result __Copy(const Rectangle& destRect, const _Canvas& srcCanvas, const Rectangle& srcRect); + + result __FillRectangle(unsigned long composedColor, const _Util::Rectangle& rectangle); + + result __FillRoundRectangle(unsigned long composedColor, const _Util::Rectangle& rect, const _Util::Dimension& arcDim); + + result __FillEllipse(unsigned long composedColor, const _Util::Rectangle& bounds); + + result __FillTriangle(unsigned long composedColor, const _Util::Point& point1, const _Util::Point& point2, const _Util::Point& point3); + + result __DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, int length); + result __DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor); + +protected: + void* _pNativeGfxEngine; + +private: + Tizen::Graphics::_Canvas* __pParent; + Tizen::Graphics::_Font* __pFont; // weak reference + Tizen::Graphics::_Font* __pPriorityFont; // weak reference + Handle __windowHandle; + Tizen::Graphics::_Canvas::BlendOption __blendOption; + + _Util::GenericBuffer * __pSurface; + _Util::ScratchPad * __pScratchPad; + + int __xBufferPos; + int __yBufferPos; + unsigned long* __pBuffer; + unsigned long __fgColor; + unsigned long __bgColor; + Color __fgColorNative; + Color __bgColorNative; + int __fgOpacity; + int __bgOpacity; + _Util::ScalarHolder __lineWidth; + LineStyle __lineStyle; + bool __isClipBoundsSet; + Rectangle __clipBounds; + TextOrigin __textOrigin; + bool __applyEmoji; + + struct + { + Tizen::Graphics::_Util::AccumList pattern; + double offset; + } __dashData; + + BitmapDrawingQuality __bitmapDrawingQuality; + BlendingMode __blendingMode; + + // for performance test + bool __useStableRenderer; + + friend class _CanvasImpl; + friend class _Bitmap; + friend class _Font; + friend class Tizen::Ui::Animations::_VisualElementCanvas; + +}; // _Canvas + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_CANVAS_H_ diff --git a/src/graphics/FGrp_CanvasCairo.cpp b/src/graphics/FGrp_CanvasCairo.cpp new file mode 100644 index 0000000..ba58f45 --- /dev/null +++ b/src/graphics/FGrp_CanvasCairo.cpp @@ -0,0 +1,727 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasCairo.cpp + * @brief This is the implementation file for the cairo solution. + * + */ + +#include "FGrp_CanvasCairo.h" +#include "util/FGrp_UtilTemplate.h" + +namespace Tizen { namespace Graphics +{ + +namespace _Util +{ + +template <> +AutoDeletor::~AutoDeletor(void) +{ + if (__pPtr) + { + cairo_destroy(__pPtr); + } +} + +template <> +AutoDeletor::~AutoDeletor(void) +{ + if (__pPtr) + { + cairo_surface_destroy(__pPtr); + } +} + +template <> +AutoDeletor::~AutoDeletor(void) +{ + if (__pPtr) + { + cairo_pattern_destroy(__pPtr); + } +} + +} // _Util + +namespace _Cairo +{ + +const double _DOUBLE_PI = 3.141592; + +void +SetColor(cairo_t* pCairo, unsigned long composedColor) +{ + double a = ((composedColor >> 24) & 0xFF) * 1.0 / 255.0; + double r = ((composedColor >> 16) & 0xFF) * 1.0 / 255.0; + double g = ((composedColor >> 8) & 0xFF) * 1.0 / 255.0; + double b = ((composedColor >> 0) & 0xFF) * 1.0 / 255.0; + + cairo_set_source_rgba(pCairo, r, g, b, a); +} + +template <> +void +SetClip(cairo_t* pCairo, int x, int y, int width, int height) +{ + cairo_new_path(pCairo); + cairo_rectangle(pCairo, x, y, width, height); + cairo_clip(pCairo); + cairo_new_path(pCairo); +} + +template <> +void +SetClip(cairo_t* pCairo, float x, float y, float width, float height) +{ + + cairo_new_path(pCairo); + cairo_rectangle(pCairo, x, y, width, height); + cairo_clip(pCairo); + cairo_new_path(pCairo); +} + +void +ResetClip(cairo_t* pCairo) +{ + cairo_reset_clip(pCairo); +} + +void +SetDash(cairo_t* pCairo, double* pDashes, int dashCount, double offset) +{ + cairo_set_dash(pCairo, pDashes, dashCount, offset); +} + +void +ResetDash(cairo_t* pCairo) +{ + cairo_set_dash(pCairo, 0, 0, 0.0); +} + +template <> +void +DrawRoundRectangle(cairo_t* pCairo, double lineWidth, unsigned long composedColor, const _Util::Rectangle& rect, const _Util::Dimension& arcDim) +{ + double x = rect.x; + double y = rect.y; + double width = rect.w; + double height = rect.h; + double radiusHorizontal = arcDim.w; + double radiusVertical = arcDim.h; + double radius = (radiusHorizontal > radiusVertical) ? radiusHorizontal : radiusVertical; + double scalingFactorHorizental = radius / radiusHorizontal; + double scalingFactorVertical = radius / radiusVertical; + double degrees = _DOUBLE_PI / 180.0; + + cairo_save(pCairo); + cairo_scale(pCairo, radiusHorizontal / radius, radiusVertical / radius); + cairo_new_sub_path(pCairo); + cairo_arc(pCairo, (x + width - radiusHorizontal) * scalingFactorHorizental, (y + radiusVertical) * scalingFactorVertical, radius, -90 * degrees, 0 * degrees); + cairo_arc(pCairo, (x + width - radiusHorizontal) * scalingFactorHorizental, (y + height - radiusVertical) * scalingFactorVertical, radius, 0 * degrees, 90 * degrees); + cairo_arc(pCairo, (x + radiusHorizontal) * scalingFactorHorizental, (y + height - radiusVertical) * scalingFactorVertical, radius, 90 * degrees, 180 * degrees); + cairo_arc(pCairo, (x + radiusHorizontal) * scalingFactorHorizental, (y + radiusVertical) * scalingFactorVertical, radius, 180 * degrees, 270 * degrees); + cairo_close_path(pCairo); + cairo_restore(pCairo); + + SetColor(pCairo, composedColor); + + cairo_set_line_width(pCairo, lineWidth); + cairo_set_line_cap(pCairo, CAIRO_LINE_CAP_ROUND); + cairo_stroke(pCairo); +} + +template <> +void +DrawRoundRectangle(cairo_t* pCairo, int lineWidth, unsigned long composedColor, const _Util::Rectangle& rect, const _Util::Dimension& arcDim) +{ + double offset = (lineWidth % 2) ? 0.5 : 0.0; + + _Util::Rectangle revisedRect = + { + rect.x + offset, + rect.y + offset, + rect.w, + rect.h + }; + + DrawRoundRectangle(pCairo, double(lineWidth), composedColor, revisedRect, arcDim); +} + +void +FillRoundRectangle(cairo_t* pCairo, unsigned long composedColor, const _Util::Rectangle& rect, const _Util::Dimension& arcDim) +{ + double x = rect.x; + double y = rect.y; + double width = rect.w; + double height = rect.h; + double radiusHorizontal = arcDim.w; + double radiusVertical = arcDim.h; + double radius = (radiusHorizontal > radiusVertical) ? radiusHorizontal : radiusVertical; + double degrees = _DOUBLE_PI / 180.0; + double scalingFactorHorizental = radius / radiusHorizontal; + double scalingFactorVertical = radius / radiusVertical; + + cairo_save(pCairo); + cairo_scale(pCairo, radiusHorizontal / radius, radiusVertical / radius); + cairo_new_sub_path(pCairo); + cairo_arc(pCairo, (x + width - radiusHorizontal) * scalingFactorHorizental, (y + radiusVertical) * scalingFactorVertical, radius, -90 * degrees, 0 * degrees); + cairo_arc(pCairo, (x + width - radiusHorizontal) * scalingFactorHorizental, (y + height - radiusVertical) * scalingFactorVertical, radius, 0 * degrees, 90 * degrees); + cairo_arc(pCairo, (x + radiusHorizontal) * scalingFactorHorizental, (y + height - radiusVertical) * scalingFactorVertical, radius, 90 * degrees, 180 * degrees); + cairo_arc(pCairo, (x + radiusHorizontal) * scalingFactorHorizental, (y + radiusVertical) * scalingFactorVertical, radius, 180 * degrees, 270 * degrees); + cairo_close_path(pCairo); + cairo_restore(pCairo); + + SetColor(pCairo, composedColor); + + cairo_fill(pCairo); +} + +template <> +void +Drawline(cairo_t* pCairo, double lineWidth, unsigned long composedColor, const _Util::Point point[], int numPoint) +{ + if (numPoint != 2) + { + return; + } + + { + cairo_new_path(pCairo); + cairo_move_to(pCairo, point[0].x, point[0].y); + + for (int i = 1; i < numPoint; i++) + { + cairo_line_to(pCairo, point[i].x, point[i].y); + } + } + + SetColor(pCairo, composedColor); + + cairo_set_line_width(pCairo, lineWidth); + cairo_set_line_cap(pCairo, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join(pCairo, CAIRO_LINE_JOIN_ROUND); + + cairo_stroke(pCairo); +} + +template <> +void +Drawline(cairo_t* pCairo, int lineWidth, unsigned long composedColor, const _Util::Point point[], int numPoint) +{ + if (numPoint != 2) + { + return; + } + + double offset = (lineWidth % 2) ? 0.5 : 0.0; + + { + cairo_new_path(pCairo); + cairo_move_to(pCairo, point[0].x + offset, point[0].y + offset); + + for (int i = 1; i < numPoint; i++) + { + cairo_line_to(pCairo, point[i].x + offset, point[i].y + offset); + } + } + + SetColor(pCairo, composedColor); + + cairo_set_line_width(pCairo, lineWidth); + cairo_set_line_cap(pCairo, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join(pCairo, CAIRO_LINE_JOIN_ROUND); + + cairo_stroke(pCairo); +} + +void +FillRectangle(cairo_t* pCairo, unsigned long composedColor, const _Util::Rectangle& rect) +{ + cairo_rectangle(pCairo, rect.x, rect.y, rect.w, rect.h); + SetColor(pCairo, composedColor); + cairo_fill(pCairo); +} + +template <> +void +DrawRectangle(cairo_t* pCairo, double lineWidth, unsigned long composedColor, const _Util::Rectangle& rect) +{ + double x1 = rect.x; + double y1 = rect.y; + double x2 = x1 + rect.w; + double y2 = y1 + rect.h; + + { + cairo_new_path(pCairo); + + cairo_move_to(pCairo, x1, y1); + cairo_line_to(pCairo, x2, y1); + cairo_line_to(pCairo, x2, y2); + cairo_line_to(pCairo, x1, y2); + + cairo_close_path(pCairo); + } + + SetColor(pCairo, composedColor); + + cairo_set_line_width(pCairo, lineWidth); + cairo_set_line_cap(pCairo, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join(pCairo, CAIRO_LINE_JOIN_ROUND); + + cairo_stroke(pCairo); +} + +template <> +void +DrawRectangle(cairo_t* pCairo, int lineWidth, unsigned long composedColor, const _Util::Rectangle& rect) +{ + double offset = (lineWidth % 2) ? 0.5 : 0.0; + + _Util::Rectangle revisedRect = { rect.x + offset, rect.y + offset, rect.w, rect.h }; + + DrawRectangle(pCairo, double(lineWidth), composedColor, revisedRect); +} + +template <> +void +DrawPolyline(cairo_t* pCairo, double lineWidth, unsigned long composedColor, const _Util::Point point[], int numPoint) +{ + if (numPoint <= 0) + { + return; + } + + { + cairo_new_path(pCairo); + cairo_move_to(pCairo, point[0].x, point[0].y ); + + for (int i = 1; i < numPoint; i++) + { + cairo_line_to(pCairo, point[i].x, point[i].y); + } + } + + SetColor(pCairo, composedColor); + + cairo_set_line_width(pCairo, lineWidth); + cairo_set_line_cap(pCairo, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join(pCairo, CAIRO_LINE_JOIN_ROUND); + + cairo_stroke(pCairo); +} + +template <> +void +DrawPolyline(cairo_t* pCairo, int lineWidth, unsigned long composedColor, const _Util::Point point[], int numPoint) +{ + if (numPoint <= 0) + { + return; + } + + { + double offset = (lineWidth % 2) ? 0.5 : 0.0; + + cairo_new_path(pCairo); + cairo_move_to(pCairo, point[0].x + offset, point[0].y + offset); + + for (int i = 1; i < numPoint; i++) + { + cairo_line_to(pCairo, point[i].x + offset, point[i].y + offset); + } + } + + SetColor(pCairo, composedColor); + + cairo_set_line_width(pCairo, lineWidth); + cairo_set_line_cap(pCairo, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join(pCairo, CAIRO_LINE_JOIN_ROUND); + + cairo_stroke(pCairo); +} + +template <> +void +DrawPolygon(cairo_t* pCairo, double lineWidth, unsigned long composedColor, const _Util::Point point[], int numPoint) +{ + if (numPoint <= 0) + { + return; + } + + { + cairo_new_path(pCairo); + cairo_move_to(pCairo, point[0].x, point[0].y); + + for (int i = 1; i < numPoint; i++) + { + cairo_line_to(pCairo, point[i].x, point[i].y); + } + + cairo_close_path(pCairo); + } + + SetColor(pCairo, composedColor); + + cairo_set_line_width(pCairo, lineWidth); + cairo_set_line_cap(pCairo, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join(pCairo, CAIRO_LINE_JOIN_ROUND); + + cairo_stroke(pCairo); +} + +template <> +void +DrawPolygon(cairo_t* pCairo, int lineWidth, unsigned long composedColor, const _Util::Point point[], int numPoint) +{ + if (numPoint <= 0) + { + return; + } + + { + double offset = (lineWidth % 2) ? 0.5 : 0.0; + + cairo_new_path(pCairo); + cairo_move_to(pCairo, point[0].x + offset, point[0].y + offset); + + for (int i = 1; i < numPoint; i++) + { + cairo_line_to(pCairo, point[i].x + offset, point[i].y + offset); + } + + cairo_close_path(pCairo); + } + + SetColor(pCairo, composedColor); + + cairo_set_line_width(pCairo, lineWidth); + cairo_set_line_cap(pCairo, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join(pCairo, CAIRO_LINE_JOIN_ROUND); + + cairo_stroke(pCairo); +} + +void +FillPolygon(cairo_t* pCairo, unsigned long composedColor, const _Util::Point point[], int numPoint) +{ + if (numPoint <= 0) + { + return; + } + + { + cairo_new_path(pCairo); + cairo_move_to(pCairo, point[0].x, point[0].y); + + for (int i = 1; i < numPoint; i++) + { + cairo_line_to(pCairo, point[i].x, point[i].y); + } + + cairo_close_path(pCairo); + } + + SetColor(pCairo, composedColor); + + cairo_set_fill_rule(pCairo, CAIRO_FILL_RULE_EVEN_ODD); + cairo_fill(pCairo); +} + +template <> +void +DrawEllipse(cairo_t* pCairo, double lineWidth, unsigned long composedColor, const _Util::Rectangle& bounds) +{ + double x = bounds.x; + double y = bounds.y; + double widthHalf = bounds.w * 1.0 / 2.0; + double heightHalf = bounds.h * 1.0 / 2.0; + + { + double ux = lineWidth; + double uy = lineWidth; + cairo_device_to_user_distance(pCairo, &ux, &uy); + cairo_set_line_width(pCairo, (ux < uy) ? uy : ux); + } + + SetColor(pCairo, composedColor); + + cairo_new_path(pCairo); + + cairo_save(pCairo); + { + cairo_translate(pCairo, x + widthHalf, y + heightHalf); + + double radius = (widthHalf > heightHalf) ? widthHalf : heightHalf; + + cairo_scale(pCairo, widthHalf / radius, heightHalf / radius); + + cairo_arc(pCairo, 0.0, 0.0, radius, 0.0, 2 * _DOUBLE_PI); + } + cairo_restore(pCairo); + + cairo_set_line_cap(pCairo, CAIRO_LINE_CAP_ROUND); + cairo_stroke(pCairo); +} + +template <> +void +DrawEllipse(cairo_t* pCairo, int lineWidth, unsigned long composedColor, const _Util::Rectangle& bounds) +{ + double offset = (lineWidth % 2) ? 0.5f : 0.0f; + + _Util::Rectangle revisedBounds = + { + bounds.x + offset, + bounds.y + offset, + bounds.w, + bounds.h + }; + + DrawEllipse(pCairo, double(lineWidth), composedColor, revisedBounds); +} + +void +FillEllipse(cairo_t* pCairo, unsigned long composedColor, const _Util::Rectangle& bounds) +{ + double x = bounds.x; + double y = bounds.y; + double width = bounds.w; + double height = bounds.h; + + cairo_new_path(pCairo); + + cairo_save(pCairo); + { + cairo_translate(pCairo, x + width / 2.0, y + height / 2.0); + cairo_scale(pCairo, width / 2.0, height / 2.0); + + double a = ((composedColor >> 24) & 0xFF) * 1.0 / 255.0; + double r = ((composedColor >> 16) & 0xFF) * 1.0 / 255.0; + double g = ((composedColor >> 8) & 0xFF) * 1.0 / 255.0; + double b = ((composedColor >> 0) & 0xFF) * 1.0 / 255.0; + + cairo_set_source_rgba(pCairo, r, g, b, a); + + cairo_arc(pCairo, 0.0, 0.0, 1.0, 0.0, 2 * _DOUBLE_PI); + cairo_fill(pCairo); + } + cairo_restore(pCairo); +} + +template <> +void +DrawArc(cairo_t* pCairo, double lineWidth, unsigned long composedColor, const _Util::Rectangle& bounds, double startAngle, double endAngle, DrawArcStyle arcType) +{ + double x = bounds.x; + double y = bounds.y; + double widthHalf = bounds.w * 1.0 / 2.0; + double heightHalf = bounds.h * 1.0 / 2.0; + double angle1 = (360 - startAngle) * 1.0 * (_DOUBLE_PI / 180.0); + double angle2 = (360 - endAngle) * 1.0 * (_DOUBLE_PI / 180.0); + + { + double ux = lineWidth; + double uy = lineWidth; + cairo_device_to_user_distance(pCairo, &ux, &uy); + cairo_set_line_width(pCairo, (ux < uy) ? uy : ux); + } + + SetColor(pCairo, composedColor); + + cairo_new_path(pCairo); + + switch (arcType) + { + case DRAW_ARC_STYLE_ARC: + cairo_save(pCairo); + { + cairo_translate(pCairo, x + widthHalf, y + heightHalf); + + double radius = (widthHalf > heightHalf) ? widthHalf : heightHalf; + + cairo_scale(pCairo, widthHalf / radius, heightHalf / radius); + + cairo_arc_negative(pCairo, 0.0, 0.0, radius, angle1, angle2); + } + cairo_restore(pCairo); + break; + case DRAW_ARC_STYLE_PIE: + cairo_save(pCairo); + { + cairo_translate(pCairo, x + widthHalf, y + heightHalf); + + double radius = (widthHalf > heightHalf) ? widthHalf : heightHalf; + + cairo_scale(pCairo, widthHalf / radius, heightHalf / radius); + + cairo_arc_negative(pCairo, 0.0, 0.0, radius, angle1, angle2); + cairo_line_to(pCairo, 0.5, 0.5); + cairo_close_path(pCairo); + } + cairo_restore(pCairo); + break; + case DRAW_ARC_STYLE_CHORD: + cairo_save(pCairo); + { + cairo_translate(pCairo, x + widthHalf, y + heightHalf); + + double radius = (widthHalf > heightHalf) ? widthHalf : heightHalf; + + cairo_scale(pCairo, widthHalf / radius, heightHalf / radius); + + cairo_arc_negative(pCairo, 0.0, 0.0, radius, angle1, angle2); + cairo_close_path(pCairo); + } + cairo_restore(pCairo); + break; + default: + return; + } + + cairo_set_line_cap(pCairo, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join(pCairo, CAIRO_LINE_JOIN_ROUND); + cairo_stroke(pCairo); +} + +template <> +void +DrawArc(cairo_t* pCairo, int lineWidth, unsigned long composedColor, const _Util::Rectangle& bounds, double startAngle, double endAngle, DrawArcStyle arcType) +{ + float offset = (lineWidth % 2) ? 0.5f : 0.0f; + + _Util::Rectangle revisedBounds = + { + bounds.x + offset, + bounds.y + offset, + bounds.w, + bounds.h + }; + + DrawArc(pCairo, double(lineWidth), composedColor, revisedBounds, startAngle, endAngle, arcType); +} + +void +FillArc(cairo_t* pCairo, unsigned long composedColor, const _Util::Rectangle& bounds, double startAngle, double endAngle, FillArcStyle arcType) +{ + double x = bounds.x; + double y = bounds.y; + double widthHalf = bounds.w * 1.0 / 2.0; + double heightHalf = bounds.h * 1.0 / 2.0; + double angle1 = (360 - startAngle) * 1.0 * (_DOUBLE_PI / 180.0); + double angle2 = (360 - endAngle) * 1.0 * (_DOUBLE_PI / 180.0); + + SetColor(pCairo, composedColor); + + cairo_new_path(pCairo); + + switch (arcType) + { + case FILL_ARC_STYLE_PIE: + cairo_save(pCairo); + { + cairo_translate(pCairo, x + widthHalf, y + heightHalf); + + double radius = (widthHalf > heightHalf) ? widthHalf : heightHalf; + + cairo_scale(pCairo, widthHalf / radius, heightHalf / radius); + + cairo_arc_negative(pCairo, 0.0, 0.0, radius, angle1, angle2); + cairo_line_to(pCairo, 0.5, 0.5); + cairo_close_path(pCairo); + } + cairo_restore(pCairo); + break; + case FILL_ARC_STYLE_CHORD: + cairo_save(pCairo); + { + cairo_translate(pCairo, x + widthHalf, y + heightHalf); + + double radius = (widthHalf > heightHalf) ? widthHalf : heightHalf; + + cairo_scale(pCairo, widthHalf / radius, heightHalf / radius); + + cairo_arc_negative(pCairo, 0.0, 0.0, radius, angle1, angle2); + cairo_close_path(pCairo); + } + cairo_restore(pCairo); + break; + default: + return; + } + + cairo_fill(pCairo); +} + +bool +ScalePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, PatternFilter patternFilter) +{ + if (srcImage.width <= 0 || srcImage.height <= 0 || dstImage.width <= 0 || dstImage.height <= 0) + { + return true; + } + + if (srcImage.depth != 32 || dstImage.depth != 32) + { + return false; + } + + _Util::AutoDeletor srcSurface(cairo_image_surface_create_for_data((unsigned char*)srcImage.pBitmap, CAIRO_FORMAT_ARGB32, srcImage.width, srcImage.height, srcImage.bytesPerLine)); + _Util::AutoDeletor dstSurface(cairo_image_surface_create_for_data((unsigned char*)dstImage.pBitmap, CAIRO_FORMAT_ARGB32, dstImage.width, dstImage.height, dstImage.bytesPerLine)); + + if (srcSurface.IsValid() && dstSurface.IsValid()) + { + _Util::AutoDeletor srcPattern(cairo_pattern_create_for_surface(srcSurface)); + _Util::AutoDeletor dstCairo(cairo_create(dstSurface)); + + if (srcPattern.IsValid() && dstCairo.IsValid()) + { + cairo_matrix_t cairoMatrix; + cairo_matrix_init_scale(&cairoMatrix, double(srcImage.width) / double(dstImage.width), double(srcImage.height) / double(dstImage.height)); + cairo_pattern_set_matrix(srcPattern, &cairoMatrix); + + switch (patternFilter) + { + case PATTERN_FILTER_FAST: + cairo_pattern_set_filter(srcPattern, CAIRO_FILTER_FAST); + break; + case PATTERN_FILTER_GOOD: + cairo_pattern_set_filter(srcPattern, CAIRO_FILTER_GOOD); + break; + case PATTERN_FILTER_BEST: + cairo_pattern_set_filter(srcPattern, CAIRO_FILTER_BEST); + break; + default: + cairo_pattern_set_filter(srcPattern, CAIRO_FILTER_FAST); + break; + }; + + cairo_set_source(dstCairo, srcPattern); + cairo_paint(dstCairo); + + return true; + } + } + + return false; +} + +} // _Cairo + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_CanvasCairo.h b/src/graphics/FGrp_CanvasCairo.h new file mode 100644 index 0000000..1257cdb --- /dev/null +++ b/src/graphics/FGrp_CanvasCairo.h @@ -0,0 +1,108 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasCairo.h + * @brief This is the header file for the cairo solution. + * + */ + +#ifndef _FGRP_INTERNAL_CANVASCAIRO_H_ +#define _FGRP_INTERNAL_CANVASCAIRO_H_ + +#include + +#include "../util/FGrp_UtilType.h" +#include "../util/FGrp_UtilPixmap.h" + + +namespace Tizen { namespace Graphics +{ + +namespace _Cairo +{ + +enum DrawArcStyle +{ + DRAW_ARC_STYLE_ARC, + DRAW_ARC_STYLE_PIE, + DRAW_ARC_STYLE_CHORD +}; + +enum FillArcStyle +{ + FILL_ARC_STYLE_PIE, + FILL_ARC_STYLE_CHORD +}; + +enum PatternFilter +{ + PATTERN_FILTER_FAST, + PATTERN_FILTER_GOOD, + PATTERN_FILTER_BEST +}; + + +void SetColor(cairo_t* pCairo, unsigned long composedColor); + +template +void SetClip(cairo_t* pCairo, T x, T y, T width, T height); + +void ResetClip(cairo_t* pCairo); + +void SetDash(cairo_t* pCairo, double* pDashes, int dashCount, double offset); + +void ResetDash(cairo_t* pCairo); + +template +void DrawRoundRectangle(cairo_t* pCairo, T lineWidth, unsigned long composedColor, const _Util::Rectangle& rect, const _Util::Dimension& arcDim); + +void FillRoundRectangle(cairo_t* pCairo, unsigned long composedColor, const _Util::Rectangle& rect, const _Util::Dimension& arcDim); + +template +void Drawline(cairo_t* pCairo, T lineWidth, unsigned long composedColor, const _Util::Point point[], int numPoint); + +template +void DrawRectangle(cairo_t* pCairo, T lineWidth, unsigned long composedColor, const _Util::Rectangle& rect); + +void FillRectangle(cairo_t* pCairo, unsigned long composedColor, const _Util::Rectangle& rect); + +template +void DrawPolyline(cairo_t* pCairo, T lineWidth, unsigned long composedColor, const _Util::Point point[], int numPoint); + +template +void DrawPolygon(cairo_t* pCairo, T lineWidth, unsigned long composedColor, const _Util::Point point[], int numPoint); + +void FillPolygon(cairo_t* pCairo, unsigned long composedColor, const _Util::Point point[], int numPoint); + +template +void DrawEllipse(cairo_t* pCairo, T lineWidth, unsigned long composedColor, const _Util::Rectangle& bounds); + +void FillEllipse(cairo_t* pCairo, unsigned long composedColor, const _Util::Rectangle& bounds); + +template +void DrawArc(cairo_t* pCairo, T lineWidth, unsigned long composedColor, const _Util::Rectangle& bounds, double startAngle, double endAngle, DrawArcStyle arcType); + +void FillArc(cairo_t* pCairo, unsigned long composedColor, const _Util::Rectangle& bounds, double startAngle, double endAngle, FillArcStyle arcType); + +bool ScalePixmap(_Util::Pixmap& dstImage, const _Util::Pixmap& srcImage, PatternFilter patternFilter); + +} // Tizen::Graphics::_Cairo + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_CANVASCAIRO_H_ diff --git a/src/graphics/FGrp_CanvasCoordHolder.h b/src/graphics/FGrp_CanvasCoordHolder.h new file mode 100644 index 0000000..4d2fffc --- /dev/null +++ b/src/graphics/FGrp_CanvasCoordHolder.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasCoordHolder.h + * @brief This is the header file for _CanvasImpl class. + * + */ + +#ifndef _FGRP_INTERNAL_CANVASCOORDHOLDER_H_ +#define _FGRP_INTERNAL_CANVASCOORDHOLDER_H_ + + +#include "FGrp_ResUtil.h" + + +namespace Tizen { namespace Graphics +{ + +struct _CanvasCoordHolder +{ + _ResUtil::CoordHolder <_ResUtil::Rect> canvasSize; + _ResUtil::CoordHolder <_ResUtil::Rect> clipBounds; + _ResUtil::CoordHolder lineWidth; + _ResUtil::CoordHolder <_ResUtil::Pos> canvasPos; + + void Init(_ResUtil::Rect area) + { + canvasSize = area; + clipBounds = area; + lineWidth = 1; + canvasPos = _ResUtil::Pos(area.x, area.y); + } + void Init(const Rectangle& rect) + { + _ResUtil::Rect area(rect.x, rect.y, rect.width, rect.height); + this->Init(area); + } +}; + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_CANVASCOORDHOLDER_H_ diff --git a/src/graphics/FGrp_CanvasGpArc.cpp b/src/graphics/FGrp_CanvasGpArc.cpp new file mode 100644 index 0000000..5103af6 --- /dev/null +++ b/src/graphics/FGrp_CanvasGpArc.cpp @@ -0,0 +1,1640 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasGpArc.cpp + * @brief This is the implementation file for _CanvasArc class. + * + */ + +#include +#include +#include + +#include +#include "FGrp_CanvasGpPrimitive.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace // unnamed +{ + +const int _ARC_DELTA_SOLID_LINE = 4; +const int _ARC_DELTA_DOT_LINE = 1; +const int _MAX_ARC_OUTLINE_POINTS = 20000; +const int _MAX_STACK_COUNT = 200; + +const float _SINE_TABLE[] = // 91 items +{ + (float) 0.000000, (float) 0.017452, (float) 0.034899, (float) 0.052336, (float) 0.069756, + (float) 0.087156, (float) 0.104528, (float) 0.121869, (float) 0.139173, (float) 0.156434, + (float) 0.173648, (float) 0.190809, (float) 0.207912, (float) 0.224951, (float) 0.241922, + (float) 0.258819, (float) 0.275637, (float) 0.292372, (float) 0.309017, (float) 0.325568, + (float) 0.342020, (float) 0.358368, (float) 0.374607, (float) 0.390731, (float) 0.406737, + (float) 0.422618, (float) 0.438371, (float) 0.453990, (float) 0.469471, (float) 0.484810, + (float) 0.500000, (float) 0.515038, (float) 0.529919, (float) 0.544639, (float) 0.559193, + (float) 0.573576, (float) 0.587785, (float) 0.601815, (float) 0.615661, (float) 0.629320, + (float) 0.642788, (float) 0.656059, (float) 0.669131, (float) 0.681998, (float) 0.694658, + (float) 0.707107, (float) 0.719340, (float) 0.731354, (float) 0.743145, (float) 0.754709, + (float) 0.766044, (float) 0.777146, (float) 0.788011, (float) 0.798635, (float) 0.809017, + (float) 0.819152, (float) 0.829037, (float) 0.838670, (float) 0.848048, (float) 0.857167, + (float) 0.866025, (float) 0.874620, (float) 0.882948, (float) 0.891006, (float) 0.898794, + (float) 0.906308, (float) 0.913545, (float) 0.920505, (float) 0.927184, (float) 0.933580, + (float) 0.939693, (float) 0.945518, (float) 0.951056, (float) 0.956305, (float) 0.961262, + (float) 0.965926, (float) 0.970296, (float) 0.974370, (float) 0.978148, (float) 0.981627, + (float) 0.984808, (float) 0.987688, (float) 0.990268, (float) 0.992546, (float) 0.994522, + (float) 0.996195, (float) 0.997564, (float) 0.998630, (float) 0.999391, (float) 0.999848, + (float) 1.000000 +}; + +} + +namespace Tizen { namespace Graphics +{ + +bool +_CanvasArc::SetLineWidth(int lineWidth) +{ + __lineWidth = lineWidth; + + return true; +} + +int +_CanvasArc::GetLineWidth(void) const +{ + return __lineWidth; +} + +result +_CanvasArc::DrawArc(int rectX, int rectY, int rectW, int rectH, int startAngle, int endAngle, ArcStyle arcType, const _GpBufferInfo& bufInfo) +{ + int x; + int y; + int x1; + int y1; + int theta; + int centerX; + int centerY; + int radiusX; + int radiusY; + int halfLineW; + int preX = -1000; + int preY = -1000; + + bool isEllipse = false; + bool isClipped = true; + + _GpPoint* pPoints = null; + + int pixelCount; + + _CanvasEllipse ellipse; + _CanvasLine line; + + if (rectW < 1 || rectH < 1) + { + return E_SUCCESS; + } + + if (startAngle < 0 || endAngle < 0) + { + return E_SYSTEM; + } + + if (arcType < ARC_STYLE_ONLY || arcType > ARC_STYLE_FILLED_CHORD) + { + return E_SYSTEM; + } + + ellipse.SetLineWidth(__lineWidth); + line.SetLineWidth(__lineWidth); + + if (rectW == 1 && rectH == 1) + { + return (line._DrawPixelWithClipping(rectX, rectY, bufInfo) == GP_RESULT_FAIL ? E_SYSTEM : E_SUCCESS); + } + + if ((bufInfo.bitsPerPixel == 32 && (bufInfo.color32 & 0xFF000000) != 0xFF000000) || (rectW > 1200) || (rectH > 1200)) + { + switch (arcType) + { + case ARC_STYLE_ONLY: + case ARC_STYLE_PIE: + case ARC_STYLE_CHORD: + return __Draw32BitArc(rectX, rectY, rectW, rectH, startAngle, endAngle, arcType, bufInfo) ? E_SUCCESS : E_SYSTEM; + case ARC_STYLE_FILLED_PIE: + case ARC_STYLE_FILLED_CHORD: +// ret = __WmDraw32BitsFilledArc(gc, rectX, rectY, rectW, rectH, startAngle, endAngle, arcType); + break; + default: + break; + } + } + + if (startAngle == endAngle) + { + if (arcType == ARC_STYLE_FILLED_CHORD) + { + // Even width, height + if (rectW % 2 == 0) + { + rectW--; + } + + if (rectH % 2 == 0) + { + rectH--; + } + + // Radius + radiusX = rectW >> 1; + radiusY = rectH >> 1; + + // Center + centerX = rectX + radiusX; + centerY = rectY + radiusY; + + x = (int) (radiusX * __Cosine(startAngle) + 0.5); + y = (int) (radiusY * __Sine(startAngle) + 0.5); + + return (line._DrawPixelWithClipping(centerX + x, centerY + y, bufInfo) == GP_RESULT_FAIL ? E_SYSTEM : E_SUCCESS); + } + } + else if (GP_ABS(endAngle - startAngle) % 360 == 0) + { + isEllipse = true; + } + + pPoints = new (std::nothrow) _GpPoint[_MAX_ARC_OUTLINE_POINTS]; + + if (pPoints == null) + { + SysLog(NID_GRP, "DrawArc: Memory allocation is failed!\n"); + + return E_SYSTEM; + } + + memset(pPoints, 0, sizeof(pPoints[0]) * _MAX_ARC_OUTLINE_POINTS); + + // Swap angle + if (startAngle > endAngle) + { + GP_SWAP(startAngle, endAngle); + } + + // Get line width + halfLineW = (__lineWidth + 1) >> 1; + + if (line._IsInClipRect(rectX - halfLineW, rectY - halfLineW, rectW + (halfLineW << 1), rectH + (halfLineW << 1), bufInfo)) + { + isClipped = false; + line._SetNotClipFunction(true); + } + + // Even width, height + if (rectW % 2 == 0) + { + rectW--; + } + + if (rectH % 2 == 0) + { + rectH--; + } + + // Radius + radiusX = rectW >> 1; + radiusY = rectH >> 1; + + // Center + centerX = rectX + radiusX; + centerY = rectY + radiusY; + + if (arcType == ARC_STYLE_FILLED_PIE || arcType == ARC_STYLE_FILLED_CHORD) + { + pixelCount = 0; + } + + __GetArcVertices(radiusX, radiusY, startAngle, &x, &y); + + preX = x; + preY = y; + + if (arcType >= ARC_STYLE_ONLY && arcType <= ARC_STYLE_CHORD) + { + if (__lineWidth > 1) + { + int halfLineW = __lineWidth >> 1; + + for (theta = startAngle; theta <= endAngle; theta += _ARC_DELTA_SOLID_LINE) + { + if (theta + _ARC_DELTA_SOLID_LINE >= endAngle) + { + theta = endAngle; + } + + __GetArcVertices(radiusX, radiusY, theta, &x, &y); + + if (GP_ABS(x - preX) >= 2 || GP_ABS(y - preY) >= 2) + { + _GpPoint startPoint = { centerX + preX, centerY - preY }; + _GpPoint endPoint = { centerX + x, centerY - y }; + + line.DrawLine(startPoint, endPoint, bufInfo); + } + else + { + ellipse.FillElliepse(centerX + x - halfLineW, centerY - y - halfLineW, __lineWidth, __lineWidth, bufInfo); + } + + preX = x; + preY = y; + } + + if (theta < endAngle + _ARC_DELTA_SOLID_LINE) + { + __GetArcVertices(radiusX, radiusY, theta, &x, &y); + + if (GP_ABS(x - preX) >= 2 || GP_ABS(y - preY) >= 2) + { + _GpPoint startPoint = { centerX + preX, centerY - preY }; + _GpPoint endPoint = { centerX + x, centerY - y }; + + line.DrawLine(startPoint, endPoint, bufInfo); + } + else + { + ellipse.FillElliepse(centerX + x - halfLineW, centerY - y - halfLineW, __lineWidth, __lineWidth, bufInfo); + } + } + } + else + { + for (theta = startAngle; theta <= endAngle; theta += _ARC_DELTA_SOLID_LINE) + { + if (theta + _ARC_DELTA_SOLID_LINE >= endAngle) + { + theta = endAngle; + } + + __GetArcVertices(radiusX, radiusY, theta, &x, &y); + + _GpPoint tempPoint1 = { centerX + preX, centerY - preY }; + _GpPoint tempPoint2 = { centerX + x, centerY - y }; + + line._DrawUnitLineSlant(tempPoint1, tempPoint2, bufInfo); + + preX = x; + preY = y; + } + + if (theta < endAngle + _ARC_DELTA_SOLID_LINE) + { + __GetArcVertices(radiusX, radiusY, endAngle, &x, &y); + + _GpPoint tempPoint1 = { centerX + preX, centerY - preY }; + _GpPoint tempPoint2 = { centerX + x, centerY - y }; + + line._DrawUnitLineSlant(tempPoint1, tempPoint2, bufInfo); + } + } + } + else + { + for (theta = startAngle; theta <= endAngle; theta += _ARC_DELTA_SOLID_LINE) + { + if (theta + _ARC_DELTA_SOLID_LINE >= endAngle) + { + theta = endAngle; + } + + __GetArcVertices(radiusX, radiusY, theta, &x, &y); + __SaveLine(centerX + preX, centerY - preY, centerX + x, centerY - y, pPoints, &pixelCount); + preX = x; + preY = y; + + } + + if (theta < endAngle + _ARC_DELTA_SOLID_LINE) + { + __GetArcVertices(radiusX, radiusY, endAngle, &x, &y); + __SaveLine(centerX + preX, centerY - preY, centerX + x, centerY - y, pPoints, &pixelCount); + } + } + + switch (arcType) + { + case ARC_STYLE_FILLED_PIE: + if (isEllipse == null) + { + __GetArcVertices(radiusX, radiusY, startAngle, &x, &y); + __SaveLine(centerX, centerY, centerX + x, centerY - y, pPoints, &pixelCount); + + __GetArcVertices(radiusX, radiusY, endAngle, &x, &y); + __SaveLine(centerX, centerY, centerX + x, centerY - y, pPoints, &pixelCount); + } + __FillArcWithEvenOdd(pPoints, pixelCount, isClipped, bufInfo); + break; + + case ARC_STYLE_PIE: + if (isEllipse == null) + { + _GpPoint startPoint = { centerX, centerY }; + + { + __GetArcVertices(radiusX, radiusY, startAngle, &x, &y); + + _GpPoint endPoint = { centerX + x, centerY - y }; + + if (__lineWidth > 1) + { + line.DrawLine(startPoint, endPoint, bufInfo); + } + else + { + line._DrawUnitLineSlant(startPoint, endPoint, bufInfo); + } + } + + { + __GetArcVertices(radiusX, radiusY, endAngle, &x, &y); + + _GpPoint endPoint = { centerX + x, centerY - y }; + + if (__lineWidth > 1) + { + line.DrawLine(startPoint, endPoint, bufInfo); + } + else + { + line._DrawUnitLineSlant(startPoint, endPoint, bufInfo); + } + } + + } + break; + + case ARC_STYLE_FILLED_CHORD: + if (isEllipse == null) + { + __GetArcVertices(radiusX, radiusY, startAngle, &x, &y); + __GetArcVertices(radiusX, radiusY, endAngle, &x1, &y1); + + __SaveLine(centerX + x, centerY - y, centerX + x1, centerY - y1, pPoints, &pixelCount); + } + __FillArcWithEvenOdd(pPoints, pixelCount, isClipped, bufInfo); + break; + + case ARC_STYLE_CHORD: + if (isEllipse == null) + { + __GetArcVertices(radiusX, radiusY, startAngle, &x, &y); + __GetArcVertices(radiusX, radiusY, endAngle, &x1, &y1); + + _GpPoint startPoint = { centerX + x, centerY - y }; + _GpPoint endPoint = { centerX + x1, centerY - y1 }; + + if (__lineWidth > 1) + { + line.DrawLine(startPoint, endPoint, bufInfo); + } + else + { + line._DrawUnitLineSlant(startPoint, endPoint, bufInfo); + } + } + break; + + default: + // Skip + break; + } + + if (arcType == ARC_STYLE_FILLED_PIE || arcType == ARC_STYLE_FILLED_CHORD) + { + pixelCount = 0; + } + + delete[] pPoints; + + return E_SUCCESS; +} + +bool +_CanvasArc::__GetArcVertices(int radiusX, int radiusY, int theta, int* pX, int* pY) const +{ + float degree; + float r; + float t1x; + float t1y; + float sinR; + float cosR; + float t2x; + float t2y; + _CanvasLine line; + + degree = (float) theta; + + r = (float) atan2(radiusX * sin(_GP_DEGREE2RADIAN(degree)), radiusY * cos(_GP_DEGREE2RADIAN(degree))); + + while (r < 0) + { + r = r + 2 * _PI; + } + + sinR = (float) sin(r); + cosR = (float) cos(r); + + t1x = radiusX * cosR; + t1y = radiusY * sinR; + + line._Rotate2DPoint(t1x, t1y, 0, &t2x, &t2y); + + *pX = (int) t2x; + *pY = (int) t2y; + + return true; +} + +float +_CanvasArc::__Sine(int degree) const +{ + degree %= 360; + + if (degree <= 90) + { + return _SINE_TABLE[degree]; + } + else if (degree <= 180) + { + return _SINE_TABLE[180 - degree]; + } + else if (degree <= 270) + { + return -_SINE_TABLE[degree - 180]; + } + else + { + return -_SINE_TABLE[360 - degree]; + } +} + +float +_CanvasArc::__Cosine(int degree) const +{ + return __Sine(degree + 90); +} + +bool +_CanvasArc::__SaveLine(int x1, int y1, int x2, int y2, _GpPoint* pPoints, int* pPixelCount) const +{ + if ((x1 == x2) && (y1 == y2)) + { + return true; + } + else if (y1 == y2) + { + return true; // Horizontal Line + } + else + { + register int x; + register int y; + int iy1; + int iy2; + int startY; + int endY; + int incdec; + long tmpX; + long dx; + long dy; + int pointCount; + + iy1 = y1; + iy2 = y2; + + if (y1 < y2) + { + startY = iy1; + endY = iy2 - 1; + incdec = 1; + } + else + { + startY = iy1 - 1; + endY = iy2; + incdec = -1; + } + dx = x2 - x1; + dy = y2 - y1; + + // Get point count + pointCount = *pPixelCount; + + if (dx == 0) + { + for (y = startY; y != endY + incdec; y += incdec) + { + if (pointCount < _MAX_ARC_OUTLINE_POINTS) + { + pPoints[pointCount].x = x1; + pPoints[pointCount].y = y; + pointCount++; + } + else + { + SysLog(NID_GRP, "__SaveLine: buffer overflow!\n"); + return false; + } + } + } + else + { + for (y = startY; y != endY + incdec; y += incdec) + { + tmpX = ((y - y1) * dx) / dy; + x = x1 + tmpX; + + if (pointCount < _MAX_ARC_OUTLINE_POINTS) + { + pPoints[pointCount].x = x; + pPoints[pointCount].y = y; + pointCount++; + } + else + { + SysLog(NID_GRP, "__SaveLine: buffer overflow!\n"); + return false; + } + } + } + *pPixelCount = pointCount; + } + + return true; +} + +bool +_CanvasArc::__FillArcWithEvenOdd(_GpPoint* pPoints, int pixelCount, bool clip, const _GpBufferInfo& bufInfo) const +{ + int i; + int x1; + int y1; + int x2; + int y2; + int clipX = 0; + int clipY = 0; + int clipEndX = 0; + int clipEndY = 0; + _CanvasLine line; + + if (pPoints == null) + { + return true; + } + + if (pixelCount <= 1) + { + return true; + } + + line.SetLineWidth(__lineWidth); + + if (clip) + { + if (bufInfo.isClipBoundsSet) + { + clipX = bufInfo.clipBounds.x; + clipY = bufInfo.clipBounds.y; + clipEndX = clipX + bufInfo.clipBounds.width - 1; + clipEndY = clipY + bufInfo.clipBounds.height - 1; + } + else + { + clipX = 0; + clipY = 0; + clipEndX = bufInfo.width - 1; + clipEndY = bufInfo.height - 1; + } + } + + // Sort points + __QuickSort(pPoints, 0, pixelCount - 1); + + // Filling + for (i = 0; i < pixelCount - 1; ) + { + x1 = pPoints[i].x; + y1 = pPoints[i].y; + x2 = pPoints[i + 1].x; + y2 = pPoints[i + 1].y; + + if (y1 == y2) + { + if (x1 == x2) + { + if (clip) + { + if (x1 < clipX || x1 > clipEndX) + { + goto CLIP_EXIT; + } + + if (y1 < clipY || y1 > clipEndY) + { + goto CLIP_EXIT; + } + } + + line._DrawPixel(x1, y1, bufInfo); + } + else + { + // Swapping + if (x1 > x2) + { + GP_SWAP(x1, x2); + } + + if (clip) + { + if (y1 < clipY || y1 > clipEndY) + { + goto CLIP_EXIT; + } + + if (x2 < clipX || x1 > clipEndX) + { + goto CLIP_EXIT; + } + + if (x1 < clipX) + { + x1 = clipX; + } + + if (x2 > clipEndX) + { + x2 = clipEndX; + } + } + + // draw primitive line + line._DrawUnitLineHorizontal(x1, x2, y1, bufInfo); + } +CLIP_EXIT: + i += 2; + } + else // Exception handling + { + i++; + } + } + + return true; +} + +void +_CanvasArc::__QuickSort(_GpPoint* pPoints, int left, int right) const +{ + GpArcStack stack[_MAX_STACK_COUNT]; + _GpPoint tmp; + _GpPoint pivot; + GpArcDiffResult result; + register int i; + register int j; + register int top = 1; + + // Check parameter + if (pPoints == null) + { + return; + } + + // init stack + stack[0].left = -1; + stack[0].right = -1; + + stack[top].left = left; + stack[top].right = right; + do + { + left = stack[top].left; + + if (left < 0) + { + break; + } + + right = stack[top--].right; + + if (right < 0) + { + break; + } + + do + { + i = left; + j = right; + pivot = pPoints[((left + right) >> 1)]; + do + { + while (true) + { + if (pPoints[i].y > pivot.y) + { + result = DIFF_RESULT_GREAT; + } + else if (pPoints[i].y == pivot.y) + { + if (pPoints[i].x > pivot.x) + { + result = DIFF_RESULT_GREAT; + } + else if (pPoints[i].x == pivot.x) + { + result = DIFF_RESULT_EQUAL; + } + else + { + result = DIFF_RESULT_LITTLE; + } + } + else + { + result = DIFF_RESULT_LITTLE; + } + + if (result == DIFF_RESULT_LITTLE) + { + i++; + } + else + { + break; + } + } + + while (true) + { + if (pPoints[j].y > pivot.y) + { + result = DIFF_RESULT_GREAT; + } + else if (pPoints[j].y == pivot.y) + { + if (pPoints[j].x > pivot.x) + { + result = DIFF_RESULT_GREAT; + } + else if (pPoints[j].x == pivot.x) + { + result = DIFF_RESULT_EQUAL; + } + else + { + result = DIFF_RESULT_LITTLE; + } + } + else + { + result = DIFF_RESULT_LITTLE; + } + + if (result == DIFF_RESULT_GREAT) + { + j--; + } + else + { + break; + } + } + + if (i <= j) + { + tmp = pPoints[i]; + pPoints[i] = pPoints[j]; + pPoints[j] = tmp; + i++; + j--; + } + } + while (i <= j); + + if (j - left < right - i) + { + if (i < right) + { + if (top >= _MAX_STACK_COUNT - 1) + { + return; + } + + stack[++top].left = i; + stack[top].right = right; + } + right = j; + } + else + { + if (left < j) + { + if (top >= _MAX_STACK_COUNT - 1) + { + return; + } + + stack[++top].left = left; + stack[top].right = j; + } + left = i; + } + } + while (left < right); + } + while (top != -1); +} + + +bool +_CanvasArc::__Draw32BitArc(int rectX, int rectY, int rectW, int rectH, int d0, int d1, ArcStyle arcType, const _GpBufferInfo& bufInfo) +{ + int dx; + int dy; + float rx; + float ry; + float centerX; + float centerY; + int cx; + int cy; + + if ((rectW <= 0) || (rectH <= 0)) + { + return true; + } + + if ((d0 % 360 == d1 % 360) && (d1 - d0 != 360)) + { + return true; + } + + dx = (rectW + 1) % 2; + dy = (rectH + 1) % 2; + + rx = (float) (rectW / 2 - dx); + ry = (float) (rectH / 2 - dy); + + if (dx) + { + rx += 0.5f; + } + + if (dy) + { + ry += 0.5f; + } + + centerX = (float) (rectX) + rx; + centerY = (float) (rectY) + ry; + + cx = (int) (centerX); + cy = (int) (centerY); + + if (__lineWidth < 2) + { + _GpFloatPoint* pEllipsePoint = null; + int n; + int i; + _GpPoint* pPoints = null; + bool isConnected = false; + _CanvasLine line; + + n = line._MakeEllipseArcPointArray(&pEllipsePoint, null, centerX, centerY, rx, ry, d0, d1, 0); + + if (n < 2) + { + SysLog(NID_GRP, "__Draw32BitArc: _MakeEllipseArcPointArray is failed!\n"); + + if (pEllipsePoint) + { + delete[] pEllipsePoint; + } + + return false; + } + + pPoints = new (std::nothrow) _GpPoint[n + 1]; + + if (pPoints == null) + { + SysLog(NID_GRP, "__Draw32BitArc: Memory allocation is failed!\n"); + + if (pEllipsePoint) + { + delete[] pEllipsePoint; + } + + return false; + } + + for (i = 0; i < n; i++) + { + pPoints[i].x = (int) pEllipsePoint[i].fx; + pPoints[i].y = (int) pEllipsePoint[i].fy; + } + + pPoints[n].x = 0; + pPoints[n].y = 0; + + switch (arcType) + { + case ARC_STYLE_ONLY: + break; + case ARC_STYLE_CHORD: + isConnected = true; + break; + case ARC_STYLE_PIE: + isConnected = true; + pPoints[n].x = cx; + pPoints[n].y = cy; + n++; + break; + default: + SysLog(NID_GRP, "__Draw32BitArc: Invalid arc [%d]type - 1!\n", arcType); + delete[] pEllipsePoint; + delete[] pPoints; + + return false; + } + + line._DrawPolyLine(n, pPoints, isConnected, bufInfo); + + delete[] pEllipsePoint; + delete[] pPoints; + + return true; + } + else + { + switch (arcType) + { + case ARC_STYLE_ONLY: + if (!__DrawThickContinuousArc(cx, cy, rectW / 2, rectH / 2, d0, d1, bufInfo)) + { + SysLog(NID_GRP, "__Draw32BitArc: __DrawThickContinuousArc is failed!\n"); + + return false; + } + break; + case ARC_STYLE_PIE: + if (!__DrawThickContinuousPie(cx, cy, rectW / 2, rectH / 2, d0, d1, bufInfo)) + { + SysLog(NID_GRP, "__Draw32BitArc: __DrawThickContinuousPie is failed!\n"); + + return false; + } + break; + case ARC_STYLE_CHORD: + if (!__DrawThickContinuousChord(cx, cy, rectW / 2, rectH / 2, d0, d1, bufInfo)) + { + SysLog(NID_GRP, "__Draw32BitArc: __DrawThickContinuousChord is failed!\n"); + + return false; + } + break; + default: + SysLog(NID_GRP, "__Draw32BitArc: Invalid arc [%d]type - 2!\n", arcType); + + return false; + } + } + + return true; +} + +bool +_CanvasArc::__DrawThickContinuousArc(int cx, int cy, int halfW, int halfH, int d0, int d1, const _GpBufferInfo& bufInfo) const +{ + int ellipsePointCount; + int i; + bool result; + _GpFloatPoint* pEllipsePoint = null; + _GpFloatPoint* pEpNormal = null; + float wl; + float wr; + _GpPolygon* pPolygon = null; + _GpPoint* pTempPoints = null; + _GpVertex* pVertex = null; + _CanvasLine line; + + float radiusX = (float) halfW; + float radiusY = (float) halfH; + + float centerX = (float) cx; + float centerY = (float) cy; + + line.SetLineWidth(__lineWidth); + ellipsePointCount = line._MakeEllipseArcPointArray(&pEllipsePoint, &pEpNormal, centerX, centerY, radiusX, radiusY, d0, d1, 0); + + if (ellipsePointCount < 2 || pEllipsePoint == null || pEpNormal == null) + { + SysLog(NID_GRP, "__DrawThickContinuousArc: _MakeEllipseArcPointArray is failed!\n"); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + _CalcLeftRightWidth(&wl, &wr); + + pPolygon = new (std::nothrow) _GpPolygon; + + if (pPolygon == null) + { + SysLog(NID_GRP, "__DrawThickContinuousArc: _CreatePolygon is failed!\n"); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + if (!line._PatchRoundCap(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, pEpNormal[0].fy, -pEpNormal[0].fx, true)) + { + SysLog(NID_GRP, "__DrawThickContinuousArc: _PatchRoundCap is failed - 1!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + for (i = 0; i < ellipsePointCount; i++) + { + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx - (pEpNormal[i].fx * wl)), (int) (pEllipsePoint[i].fy - (pEpNormal[i].fy * wl)), 0); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousArc: _AddPolygonVertex is failed - 1!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + (pEpNormal[i].fx * wr)), (int) (pEllipsePoint[i].fy + (pEpNormal[i].fy * wr)), 1); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousArc: _AddPolygonVertex is failed - 1!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + } + + i = ellipsePointCount - 1; + + if (!line._PatchRoundCap(pPolygon, (int) pEllipsePoint[i].fx, (int) pEllipsePoint[i].fy, pEpNormal[i].fy, -pEpNormal[i].fx, false)) + { + SysLog(NID_GRP, "__DrawThickContinuousArc: _PatchRoundCap is failed - 2!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + //release memory + delete[] pEllipsePoint; + pEllipsePoint = null; + + delete[] pEpNormal; + pEpNormal = null; + + pTempPoints = new (std::nothrow) _GpPoint[pPolygon->n]; + + if (pTempPoints == null) + { + SysLog(NID_GRP, "__DrawThickContinuousArc: Memory allocation is failed - 2!\n"); + line._FreePolygon(pPolygon); + + return false; + } + + for (i = 0, pVertex = pPolygon->pFirst; pVertex != null; i++, pVertex = pVertex->pNext) + { + pTempPoints[i] = pVertex->point; + } + + line._FillPolygon(pPolygon->n, pTempPoints, false, bufInfo); + + line._FreePolygon(pPolygon); + + delete[] pTempPoints; + + return true; +} + +bool +_CanvasArc::__DrawThickContinuousPie(int cx, int cy, int halfW, int halfH, int d0, int d1, const _GpBufferInfo& bufInfo) const +{ + int ellipsePointCount; + int i; + int result; + _GpFloatPoint* pEllipsePoint = null; + _GpFloatPoint* pEpNormal = null; + float wl; + float wr; + float ox; + float oy; + float qx; + float qy; + _GpPolygon* pPolygon = null; + _GpVertex* pVertex = null; + _GpPoint* pTempPoints = null; + _CanvasLine line; + + float radiusX = (float) halfW; + float radiusY = (float) halfH; + + float centerX = (float) cx; + float centerY = (float) cy; + + line.SetLineWidth(__lineWidth); + ellipsePointCount = line._MakeEllipseArcPointArray(&pEllipsePoint, &pEpNormal, centerX, centerY, radiusX, radiusY, d0, d1, 0); + + if (ellipsePointCount < 2 || pEllipsePoint == null || pEpNormal == null) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: _MakeEllipseArcPointArray is failed!\n"); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + _CalcLeftRightWidth(&wl, &wr); + + pPolygon = new (std::nothrow) _GpPolygon; + + if (pPolygon == null) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: _CreatePolygon is failed!\n"); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + if (!line._PatchRoundCap(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, pEpNormal[0].fy, -pEpNormal[0].fx, true)) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: _PatchRoundCap is failed - 1!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + for (i = 0; i < ellipsePointCount; i++) + { + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx - (pEpNormal[i].fx * wl)), (int) (pEllipsePoint[i].fy - (pEpNormal[i].fy * wl)), 0); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: _AddPolygonVertex is failed - 1!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + (pEpNormal[i].fx * wr)), (int) (pEllipsePoint[i].fy + (pEpNormal[i].fy * wr)), 1); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: _AddPolygonVertex is failed - 2!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + } + + i = ellipsePointCount - 1; + + _GpPoint pt1 = { (int) pEllipsePoint[i].fx, (int) pEllipsePoint[i].fy }; + _GpPoint pt2 = { cx, cy }; + + line._GetOrientationUnitVector(pt1, pt2, &ox, &oy); + + result = line._PatchJoint(pPolygon, (int) pEllipsePoint[i].fx, (int) pEllipsePoint[i].fy, pEpNormal[i].fy, -pEpNormal[i].fx, ox, oy); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: _PatchJoint is failed -1!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + pt1.x = (int) pEllipsePoint[i].fx; + pt1.y = (int) pEllipsePoint[i].fy; + pt2.x = cx; + pt2.y = cy; + + result = line._PatchThickContinuousLine(pPolygon, pt1, pt2, ox, oy, 0, 0); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: _PatchThickContinuousLine is failed -1!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + pt1.x = cx; + pt1.y = cy; + pt2.x = (int) pEllipsePoint[0].fx; + pt2.y = (int) pEllipsePoint[0].fy; + + line._GetOrientationUnitVector(pt1, pt2, &qx, &qy); + + result = line._PatchJoint(pPolygon, cx, cy, ox, oy, qx, qy); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: _PatchJoint is failed-2!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + pt1.x = cx; + pt1.y = cy; + pt2.x = (int) pEllipsePoint[0].fx; + pt2.y = (int) pEllipsePoint[0].fy; + + result = line._PatchThickContinuousLine(pPolygon, pt1, pt2, qx, qy, 0, 0); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: _PatchThickContinuousLine is failed-2!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._PatchJoint(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, qx, qy, pEpNormal[0].fy, -pEpNormal[0].fx); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: _PatchJoint is failed-3!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[0].fx + (pEpNormal[0].fx * wl)), (int) (pEllipsePoint[0].fy + (pEpNormal[0].fy * wl)), 0); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: _AddPolygonVertex is failed - 3!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[0].fx + (pEpNormal[0].fx * wr)), (int) (pEllipsePoint[0].fy + (pEpNormal[0].fy * wr)), 1); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: _AddPolygonVertex is failed - 4!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + delete[] pEllipsePoint; + pEllipsePoint = null; + + delete[] pEpNormal; + pEpNormal = null; + + pTempPoints = new (std::nothrow) _GpPoint[pPolygon->n]; + + if (pTempPoints == null) + { + SysLog(NID_GRP, "__DrawThickContinuousPie: Memory allocation is failed - 2!\n"); + line._FreePolygon(pPolygon); + return false; + } + + for (i = 0, pVertex = pPolygon->pFirst; pVertex != null; i++, pVertex = pVertex->pNext) + { + pTempPoints[i].x = pVertex->point.x; + pTempPoints[i].y = pVertex->point.y; + } + + line._FillPolygon(pPolygon->n, pTempPoints, false, bufInfo); + + line._FreePolygon(pPolygon); + + delete[] pTempPoints; + + return true; +} + +bool +_CanvasArc::__DrawThickContinuousChord(int cx, int cy, int halfW, int halfH, int d0, int d1, const _GpBufferInfo& bufInfo) const +{ + int ellipsePointCount; + int i; + _GpFloatPoint* pEllipsePoint = null; + _GpFloatPoint* pEpNormal = null; + float wl; + float wr; + float ox; + float oy; + _GpPolygon* pPolygon = null; + _GpPoint* pTempPoints = null; + _GpVertex* pVertex = null; + _CanvasLine line; + + bool result = true; + + float radiusX = (float) halfW; + float radiusY = (float) halfH; + + float centerX = (float) cx; + float centerY = (float) cy; + + line.SetLineWidth(__lineWidth); + ellipsePointCount = line._MakeEllipseArcPointArray(&pEllipsePoint, &pEpNormal, centerX, centerY, radiusX, radiusY, d0, d1, 0); + + if (ellipsePointCount < 2 || pEllipsePoint == null || pEpNormal == null) + { + SysLog(NID_GRP, "__DrawThickContinuousChord: _MakeEllipseArcPointArray is failed!\n"); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + _CalcLeftRightWidth(&wl, &wr); + + pPolygon = new (std::nothrow) _GpPolygon; + + if (pPolygon == null) + { + SysLog(NID_GRP, "__DrawThickContinuousChord: _CreatePolygon is failed!\n"); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + if (!line._PatchRoundCap(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, pEpNormal[0].fy, -pEpNormal[0].fx, true)) + { + SysLog(NID_GRP, "__DrawThickContinuousChord: _PatchRoundCap is failed - 1!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + for (i = 0; i < ellipsePointCount; i++) + { + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx - (pEpNormal[i].fx * wl)), (int) (pEllipsePoint[i].fy - (pEpNormal[i].fy * wl)), 0); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousChord: _AddPolygonVertex is failed - 1!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + (pEpNormal[i].fx * wr)), (int) (pEllipsePoint[i].fy + (pEpNormal[i].fy * wr)), 1); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousChord: _AddPolygonVertex is failed - 1!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + } + + if ((d0 % 360) != (d1 % 360)) + { + i = ellipsePointCount - 1; + + _GpPoint pt1 = { (int) pEllipsePoint[i].fx, (int) pEllipsePoint[i].fy }; + _GpPoint pt2 = { (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy }; + + line._GetOrientationUnitVector(pt1, pt2, &ox, &oy); + + result = line._PatchJoint(pPolygon, (int) pEllipsePoint[i].fx, (int) pEllipsePoint[i].fy, pEpNormal[i].fy, -pEpNormal[i].fx, ox, oy); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousChord: _PatchJoint is failed - 1!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + pt1.x = (int) pEllipsePoint[i].fx; + pt1.y = (int) pEllipsePoint[i].fy; + pt2.x = (int) pEllipsePoint[0].fx; + pt2.y = (int) pEllipsePoint[0].fy; + + result = line._PatchThickContinuousLine(pPolygon, pt1, pt2, ox, oy, 0, 0); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousChord: _PatchJoint is failed - 1!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._PatchJoint(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, ox, oy, pEpNormal[0].fy, -pEpNormal[0].fx); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousChord: _PatchJoint is failed - 2!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[0].fx + (pEpNormal[0].fx * wl)), (int) (pEllipsePoint[0].fy + (pEpNormal[0].fy * wl)), 0); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousChord: _AddPolygonVertex is failed - 2!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[0].fx + (pEpNormal[0].fx * wr)), (int) (pEllipsePoint[0].fy + (pEpNormal[0].fy * wr)), 1); + + if (!result) + { + SysLog(NID_GRP, "__DrawThickContinuousChord: _AddPolygonVertex is failed - 3!\n"); + + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + } + + delete[] pEllipsePoint; + pEllipsePoint = null; + + delete[] pEpNormal; + pEpNormal = null; + + pTempPoints = new (std::nothrow) _GpPoint[pPolygon->n]; + + if (pTempPoints == null) + { + SysLog(NID_GRP, "__DrawThickContinuousChord: Memory allocation is failed!\n"); + line._FreePolygon(pPolygon); + + return false; + } + + for (i = 0, pVertex = pPolygon->pFirst; pVertex != null; i++, pVertex = pVertex->pNext) + { + pTempPoints[i].x = pVertex->point.x; + pTempPoints[i].y = pVertex->point.y; + } + + line._FillPolygon(pPolygon->n, pTempPoints, false, bufInfo); + + line._FreePolygon(pPolygon); + + delete[] pTempPoints; + + return true; +} + +void +_CanvasArc::_CalcLeftRightWidth(float* pWidthLeft, float* pWidthRight) const +{ + if (__lineWidth % 2 == 0) + { + *pWidthRight = __lineWidth / 2.0f; + *pWidthLeft = *pWidthRight - 1.0f; + } + else + { + *pWidthLeft = *pWidthRight = (__lineWidth - 1) / 2.0f; + } + + return; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_CanvasGpEllipse.cpp b/src/graphics/FGrp_CanvasGpEllipse.cpp new file mode 100644 index 0000000..3cddd63 --- /dev/null +++ b/src/graphics/FGrp_CanvasGpEllipse.cpp @@ -0,0 +1,537 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasGpEllipse.cpp + * @brief This is the implementation file for _CanvasEllipse class. + * + */ + +#include + +#include "FGrp_CanvasGpPrimitive.h" + + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Graphics +{ + +bool +_CanvasEllipse::SetLineWidth(int lineWidth) +{ + __lineWidth = lineWidth; + + return true; +} + +int +_CanvasEllipse::GetLineWidth(void) const +{ + return __lineWidth; +} + +result +_CanvasEllipse::DrawEllipse(int rectX, int rectY, int rectW, int rectH, const _GpBufferInfo& bufInfo) const +{ + long d; + long a2; + long b2; + int x; + int y; + int halfLineWidth; + int centerX; + int centerY; + int radiusX; + int radiusY; + _CanvasLine line; + _GpResult ret = GP_RESULT_FAIL; + + line.SetLineWidth(__lineWidth); + + if (rectW == 1 && rectH == 1) + { + ret = line._DrawPixelWithClipping(rectX, rectY, bufInfo); + + return (ret == GP_RESULT_FAIL ? E_SYSTEM : E_SUCCESS); + } + + if ((bufInfo.bitsPerPixel == 32 && (bufInfo.color32 & 0xFF000000) != 0xFF000000) || (rectW > 1200) || (rectH > 1200)) + { + _CanvasArc arc; + arc.SetLineWidth(__lineWidth); + + return arc.DrawArc(rectX, rectY, rectW, rectH, 0, 360, ARC_STYLE_ONLY, bufInfo); + } + + if (__lineWidth > 1) + { + bool result = __DrawEllipseWithWidth(rectX, rectY, rectW, rectH, bufInfo); + + return ((result == false) ? E_SYSTEM : E_SUCCESS); + } + + halfLineWidth = (__lineWidth + 1) >> 1; + + if (line._IsInClipRect(rectX - halfLineWidth, rectY - halfLineWidth, rectW + (halfLineWidth << 1), rectH + (halfLineWidth << 1), bufInfo)) + { + line._SetNotClipFunction(true); + } + else + { + line._SetClipFunction(true); + } + + if (rectW < 3) + { + for (x = rectX; x < rectX + rectW; x++) + { + ret = (line.*line.pFuncVerticalLine)(x, rectY, rectY + rectH - 1, bufInfo); + } + + return (ret == GP_RESULT_FAIL ? E_SYSTEM : E_SUCCESS); + } + + if (rectH < 3) + { + for (y = rectY; y < rectY + rectH; y++) + { + ret = (line.*line.pFuncHorizontalLine)(rectX, rectX + rectW - 1, y, bufInfo); + } + + return (ret == GP_RESULT_FAIL ? E_SYSTEM : E_SUCCESS); + } + + // Even width, height + if (rectW % 2 == 0) + { + rectW--; + } + + if (rectH % 2 == 0) + { + rectH--; + } + + // Radius + radiusX = rectW >> 1; + radiusY = rectH >> 1; + + // Center + centerX = rectX + radiusX; + centerY = rectY + radiusY; + + a2 = (long) (radiusX * radiusX); + b2 = (long) (radiusY * radiusY); + + x = 0; + y = radiusY; + d = (4 * b2 + a2 * (1 - 4 * radiusY)) / 4; + + (line.*line.pFuncSetPixel)((-x + centerX), (-y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((x + centerX), (-y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((-x + centerX), (y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((x + centerX), (y + centerY), bufInfo); + + while (b2 * x <= a2 * y) + { + ++x; + + if (d < 0) + { + d += b2 * (2 * x + 1); + } + else + { + --y; + d += b2 * (2 * x + 1) - 2 * a2 * y; + } + + (line.*line.pFuncSetPixel)((-x + centerX), (-y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((x + centerX), (-y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((-x + centerX), (y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((x + centerX), (y + centerY), bufInfo); + + } + + x = radiusX; + y = 0; + d = (4 * a2 + b2 * (1 - 4 * radiusX)) / 4; + + (line.*line.pFuncSetPixel)((-x + centerX), (-y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((x + centerX), (-y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((-x + centerX), (y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((x + centerX), (y + centerY), bufInfo); + + while (b2 * x > a2 * y) + { + ++y; + + if (d < 0) + { + d += a2 * (2 * y + 1); + } + else + { + --x; + d += -2 * b2 * x + a2 * (2 * y + 1); + } + + (line.*line.pFuncSetPixel)((-x + centerX), (-y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((x + centerX), (-y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((-x + centerX), (y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((x + centerX), (y + centerY), bufInfo); + + } + + return E_SUCCESS; +} + +bool +_CanvasEllipse::__DrawEllipseWithWidth(int rectX, int rectY, int rectW, int rectH, const _GpBufferInfo& bufInfo) const +{ + long d; + long a2; + long b2; + int x; + int y; + int centerX; + int centerY; + int radiusX; + int radiusY; + int halfLineW; + int halfLineW2; + _CanvasLine line; + _CanvasEllipse ellipse; + _GpResult ret = GP_RESULT_FAIL; + + if (rectW < 1 || rectH < 1) + { + return true; + } + + halfLineW = __lineWidth >> 1; + halfLineW2 = (__lineWidth + 1) >> 1; + + line.SetLineWidth(__lineWidth); + ellipse.SetLineWidth(__lineWidth); + + if (line._IsInClipRect(rectX - halfLineW2, rectY - halfLineW2, rectW + (halfLineW2 << 1), rectH + (halfLineW2 << 1), bufInfo)) + { + line._SetNotClipFunction(true); + } + else + { + line._SetClipFunction(true); + } + + if (rectW < 3) + { + for (x = rectX; x < rectX + rectW; x++) + { + ret = (line.*line.pFuncVerticalLine)(x, rectY, rectY + rectH - 1, bufInfo); + } + + return (ret == GP_RESULT_FAIL ? false : true); + } + + if (rectH < 3) + { + for (y = rectY; y < rectY + rectH; y++) + { + ret = (line.*line.pFuncHorizontalLine)(rectX, rectX + rectW - 1, y, bufInfo); + } + + return (ret == GP_RESULT_FAIL ? false : true); + } + + // Radius + radiusX = rectW >> 1; + radiusY = rectH >> 1; + + if (rectW % 2 == 0) + { + radiusX--; + } + + if (rectH % 2 == 0) + { + radiusY--; + } + + // Center + centerX = rectX + radiusX; + centerY = rectY + radiusY; + + a2 = (long) (radiusX * radiusX); + b2 = (long) (radiusY * radiusY); + + x = 0; + y = radiusY; + d = (4 * b2 + a2 * (1 - 4 * radiusY)) / 4; + + // Get GC info + if (bufInfo.bitsPerPixel == 16) + { + // To do 16 bpp + return false; + } + + ellipse.FillElliepse(x + centerX - halfLineW, y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + ellipse.FillElliepse(x + centerX - halfLineW, -y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + ellipse.FillElliepse(-x + centerX - halfLineW, -y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + ellipse.FillElliepse(-x + centerX - halfLineW, y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + + while (b2 * x <= a2 * y) + { + ++x; + + if (d < 0) + { + d += b2 * (2 * x + 1); + } + else + { + --y; + d += b2 * (2 * x + 1) - 2 * a2 * y; + } + + ellipse.FillElliepse(x + centerX - halfLineW, y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + ellipse.FillElliepse(x + centerX - halfLineW, -y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + ellipse.FillElliepse(-x + centerX - halfLineW, -y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + ellipse.FillElliepse(-x + centerX - halfLineW, y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + + } + + x = radiusX; + y = 0; + d = (4 * a2 + b2 * (1 - 4 * radiusX)) / 4; + + ellipse.FillElliepse(x + centerX - halfLineW, y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + ellipse.FillElliepse(x + centerX - halfLineW, -y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + ellipse.FillElliepse(-x + centerX - halfLineW, -y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + ellipse.FillElliepse(-x + centerX - halfLineW, y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + + while (b2 * x > a2 * y) + { + ++y; + + if (d < 0) + { + d += a2 * (2 * y + 1); + } + else + { + --x; + d += -2 * b2 * x + a2 * (2 * y + 1); + } + + ellipse.FillElliepse(x + centerX - halfLineW, y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + ellipse.FillElliepse(x + centerX - halfLineW, -y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + ellipse.FillElliepse(-x + centerX - halfLineW, -y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + ellipse.FillElliepse(-x + centerX - halfLineW, y + centerY - halfLineW, __lineWidth, __lineWidth, bufInfo); + } + + return true; +} + +result +_CanvasEllipse::FillElliepse(int rectX, int rectY, int rectW, int rectH, const _GpBufferInfo& bufInfo) const +{ + long d; + long a2; + long b2; + int x; + int y; + int halfLineWidth; + int centerX; + int centerY; + int radiusX; + int radiusY; + unsigned long* pFrmbuf32 = null; + _GpResult ret = GP_RESULT_FAIL; + _GpResult ret2 = GP_RESULT_FAIL; + + _CanvasLine line; + line.SetLineWidth(__lineWidth); + + if (rectW < 0 || rectH < 0) + { + return E_SYSTEM; + } + + if ((bufInfo.bitsPerPixel == 32 && (bufInfo.color32 & 0xFF000000) != 0xFF000000) || (rectW > 1200) || (rectH > 1200)) + { + _CanvasArc arc; + arc.SetLineWidth(__lineWidth); + + return arc.DrawArc(rectX, rectY, rectW, rectH, 0, 360, ARC_STYLE_FILLED_PIE, bufInfo); + } + + halfLineWidth = (__lineWidth + 1) >> 1; + + if (line._IsInClipRect(rectX - halfLineWidth, rectY - halfLineWidth, rectW + (halfLineWidth << 1), rectH + (halfLineWidth << 1), bufInfo)) + { + line._SetNotClipFunction(false); + } + else + { + line._SetClipFunction(false); + } + + if (rectW < 3) + { + for (x = rectX; x < rectX + rectW; x++) + { + ret = (line.*line.pFuncVerticalLine)(x, rectY, rectY + rectH - 1, bufInfo); + } + + return (ret == GP_RESULT_FAIL ? E_SYSTEM : E_SUCCESS); + } + + if (rectH < 3) + { + for (y = rectY; y < rectY + rectH; y++) + { + ret = (line.*line.pFuncHorizontalLine)(rectX, rectX + rectW - 1, y, bufInfo); + } + + return (ret == GP_RESULT_FAIL ? E_SYSTEM : E_SUCCESS); + } + + // Even width, height + if (rectW % 2 == 0) + { + rectW--; + } + + if (rectH % 2 == 0) + { + rectH--; + } + + // Radius + radiusX = rectW >> 1; + radiusY = rectH >> 1; + + // Center + centerX = rectX + radiusX; + centerY = rectY + radiusY; + + a2 = (long) (radiusX * radiusX); + b2 = (long) (radiusY * radiusY); + + x = 0; + y = radiusY; + d = (4 * b2 + a2 * (1 - 4 * radiusY)) / 4; + + ret = (line.*line.pFuncHorizontalLine)(-x + centerX, x + centerX, -y + centerY, bufInfo); + ret2 = (line.*line.pFuncHorizontalLine)(-x + centerX, x + centerX, y + centerY, bufInfo); + + if (ret == GP_RESULT_FAIL || ret2 == GP_RESULT_FAIL) + { + return E_SYSTEM; + } + + if (bufInfo.bitsPerPixel == 32) + { + pFrmbuf32 = (unsigned long*) bufInfo.pPixels; + + if (pFrmbuf32 == null) + { + return E_SYSTEM; + } + } + else + { + // To do 16bpp + return E_SYSTEM; + } + + while (b2 * x <= a2 * y) + { + ++x; + + if (d < 0) + { + d += b2 * (2 * x + 1); + + ret = (line.*line.pFuncSetPixel)((-x + centerX), (-y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((x + centerX), (-y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((-x + centerX), (y + centerY), bufInfo); + (line.*line.pFuncSetPixel)((x + centerX), (y + centerY), bufInfo); + } + else + { + --y; + d += b2 * (2 * x + 1) - 2 * a2 * y; + + (line.*line.pFuncHorizontalLine)(-x + centerX, x + centerX, -y + centerY, bufInfo); + ret = (line.*line.pFuncHorizontalLine)(-x + centerX, x + centerX, y + centerY, bufInfo); + } + + if (ret == GP_RESULT_FAIL) + { + SysLog(NID_GRP, "FillEllipse: Drawing is failed!\n"); + + return E_SYSTEM; + } + } + + x = radiusX; + y = 0; + d = (4 * a2 + b2 * (1 - 4 * radiusX)) / 4; + + (line.*line.pFuncHorizontalLine)(-x + centerX, x + centerX, -y + centerY, bufInfo); + ret = (line.*line.pFuncHorizontalLine)(-x + centerX, x + centerX, y + centerY, bufInfo); + + if (ret == GP_RESULT_FAIL) + { + SysLog(NID_GRP, "FillEllipse: Drawing is failed!\n"); + + return E_SYSTEM; + } + + while (b2 * x > a2 * y) + { + ++y; + + if (d < 0) + { + d += a2 * (2 * y + 1); + } + else + { + --x; + d += -2 * b2 * x + a2 * (2 * y + 1); + } + + (line.*line.pFuncHorizontalLine)(-x + centerX, x + centerX, -y + centerY, bufInfo); + ret = (line.*line.pFuncHorizontalLine)(-x + centerX, x + centerX, y + centerY, bufInfo); + + if (ret == GP_RESULT_FAIL) + { + SysLog(NID_GRP, "FillEllipse: _DrawUnitLineHorizontal is failed!\n"); + + return E_SYSTEM; + } + } + + return E_SUCCESS; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_CanvasGpFillPolygon.cpp b/src/graphics/FGrp_CanvasGpFillPolygon.cpp new file mode 100644 index 0000000..f24efdc --- /dev/null +++ b/src/graphics/FGrp_CanvasGpFillPolygon.cpp @@ -0,0 +1,402 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasGpFillPolygon.cpp + * @brief This is the implementation file for _CanvasFillPolygon class. + * + */ + +#include +#include + +#include + +#include "FGrp_CanvasGpPrimitive.h" +#include "util/FGrp_UtilScratchpad.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +typedef unsigned long SystemPixel; + +namespace Tizen { namespace Graphics +{ + +bool +_CanvasFillPolygon::SetLineWidth(int lineWidth) +{ + __lineWidth = lineWidth; + return true; +} + +int +_CanvasFillPolygon::GetLineWidth(void) const +{ + return __lineWidth; +} + +result +_CanvasFillPolygon::FillPolygon(int ptCount, _GpPoint* pPoints, const _GpBufferInfo& bufInfo) +{ + _GpEdgeTable et; + _GpEdgeTableEntry aet; + _GpEdgeTableEntry* pPrevAet = null; + _GpEdgeTableEntry* pAetPtr = null; + _GpEdgeTableEntry* pWetePtr = null; + _GpEdgeTableEntry* pEteBuf = null; + _GpScanLineListBlock* pSllb = null; + _GpScanLineList* pSll = null; + int i; + int y; + int stitch = 1; + int fixWaet = 0; + _CanvasLine line; + _CanvasTriangle triangle; + _GpPoint* pTempPoints = null; + bool err = false; + + if (ptCount < 1) + { + return E_SYSTEM; + } + + line.SetLineWidth(__lineWidth); + triangle.SetLineWidth(__lineWidth); + + if (ptCount == 1) + { + return (line._DrawPixelWithClipping(pPoints[0].x, pPoints[0].y, bufInfo) == GP_RESULT_FAIL ? E_SYSTEM : E_SUCCESS); + } + else if (ptCount == 2) + { + return line.DrawLine(pPoints[0], pPoints[1], bufInfo); + } + else if (ptCount == 3) + { + return triangle.FillTriangle(pPoints[0].x, pPoints[0].y, pPoints[1].x, pPoints[1].y, pPoints[2].x, pPoints[2].y, bufInfo); + } + else if (ptCount == 4) + { + if (pPoints[0].x == pPoints[3].x && pPoints[1].x == pPoints[2].x && pPoints[0].y == pPoints[1].y && pPoints[2].y == pPoints[3].y) + { + if (bufInfo.bitsPerPixel == 32) + { + int rectX; + int rectY; + + rectX = GP_MIN(pPoints[0].x, pPoints[1].x); + rectY = GP_MIN(pPoints[0].y, pPoints[2].y); + + _Util::ScratchPad rect((unsigned long*) bufInfo.pPixels, bufInfo.width, bufInfo.height, bufInfo.pixelPerLine); + rect.FillRect(rectX, rectY, GP_ABS(pPoints[1].x - pPoints[0].x) + 1, GP_ABS(pPoints[3].y - pPoints[0].y) + 1, bufInfo.color32); + } + else + { + // To do 16 bpp + SysLog(NID_GRP, "FillPolygon: not support 16 bpp -1!\n"); + return E_SYSTEM; + } + + return E_SUCCESS; + } + else if (pPoints[0].y == pPoints[3].y && pPoints[1].y == pPoints[2].y && pPoints[0].x == pPoints[1].x && pPoints[2].x == pPoints[3].x) + { + if (bufInfo.bitsPerPixel == 32) + { + int rectX; + int rectY; + + rectX = GP_MIN(pPoints[0].x, pPoints[2].x); + rectY = GP_MIN(pPoints[0].y, pPoints[1].y); + + _Util::ScratchPad rect((unsigned long*) bufInfo.pPixels, bufInfo.width, bufInfo.height, bufInfo.pixelPerLine); + rect.FillRect(rectX, rectY, GP_ABS(pPoints[3].x - pPoints[0].x) + 1, GP_ABS(pPoints[1].y - pPoints[0].y) + 1, bufInfo.color32); + } + else + { + SysLog(NID_GRP, "FillPolygon: not support 16 bpp -2!\n"); + return E_SYSTEM; + } + + return E_SUCCESS; + } + } + + pEteBuf = new (std::nothrow) _GpEdgeTableEntry[ptCount]; + + if (pEteBuf == null) + { + SysLog(NID_GRP, "FillPolygon: EteBuf allcation is failed!\n"); + + return E_SYSTEM; + } + + pSllb = new (std::nothrow) _GpScanLineListBlock; + + if (pSllb == null) + { + delete[] pEteBuf; + SysLog(NID_GRP, "FillPolygon: pSllb allcation is failed!\n"); + + return false; + } + + memset(pSllb, 0, sizeof(*pSllb)); + + pTempPoints = new (std::nothrow) _GpPoint[ptCount]; + + if (pTempPoints == null) + { + delete[] pEteBuf; + + line._FreeSllb(pSllb); + + return E_SYSTEM; + } + + for (i = 0; i < ptCount; i++) + { + pTempPoints[i] = pPoints[i]; + } + + if (line._CreateEtAndAet(ptCount, pTempPoints, &et, &aet, pEteBuf, pSllb) == null) + { + delete[] pEteBuf; + + line._FreeSllb(pSllb); + SysLog(NID_GRP, "FillPolygon: _CreateEtAndAet is failed!\n"); + + delete[] pTempPoints; + + return E_SYSTEM; + } + + pSll = et.scanLines.pNext; + + _GpRect clipRect; + if (bufInfo.isClipBoundsSet) + { + clipRect = bufInfo.clipBounds; + } + else + { + clipRect.SetBounds(0, 0, bufInfo.width, bufInfo.height); + } + + for (y = et.minY; y < et.maxY + stitch; y++) + { + if (pSll != null && y == pSll->scanLine) + { + line._LoadAet(&aet, pSll->pEdgeList); + line._ComputeWaet(&aet); + pSll = pSll->pNext; + } + + pPrevAet = &aet; + pAetPtr = aet.pNext; + pWetePtr = pAetPtr; + + while (pAetPtr != null) + { + if (pWetePtr == pAetPtr) + { + { + int x1 = pAetPtr->minor; + int x2 = pAetPtr->pWNext->minor + stitch - 1; + int horY = y; + int clipEndX; + + //if (pGC->bMemGC == null) + //{ + // x1 += pGC->rcGC.x; + // x2 += pGC->rcGC.x; + // horY += pGC->rcGC.y; + //} + + clipEndX = clipRect.x + clipRect.width - 1; + + // Swapping + if (x1 > x2) + { + GP_SWAP(x1, x2); + } + + if (y < clipRect.y || y > (clipRect.y + clipRect.height - 1)) + { + goto CLIP_EXIT; + } + + if (x1 > clipEndX || x2 < clipRect.x) + { + goto CLIP_EXIT; + } + + if (x1 < clipRect.x) + { + x1 = clipRect.x; + } + + if (x2 > clipEndX) + { + x2 = clipEndX; + } + + // draw primitive line + if ((bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels; + while (x1 <= x2) + { + pFrmbuf32[bufInfo.pixelPerLine * horY + x1] = bufInfo.color32; + x1++; + } + } + else + { + if (line.__DrawHorizontalLineWithOpacity32(x1, x2, horY, bufInfo) == GP_RESULT_FAIL) + { + return E_SYSTEM; + } + } + +CLIP_EXIT: + err = true; + + } + + pWetePtr = pWetePtr->pWNext; + while (pWetePtr != pAetPtr) + { + if (pAetPtr == null) + { + break; + } + + if (pAetPtr->maxY == y) + { + pPrevAet->pNext = pAetPtr->pNext; + pAetPtr = pPrevAet->pNext; + fixWaet = 1; + if (pAetPtr != null) + { + pAetPtr->pBack = pPrevAet; + } + } + else + { + if (pAetPtr->gradient1 > 0) + { + if (pAetPtr->direction > 0) + { + pAetPtr->minor += pAetPtr->gradient1; + pAetPtr->direction += pAetPtr->inc1; + } + else + { + pAetPtr->minor += pAetPtr->gradient; + pAetPtr->direction += pAetPtr->inc2; + } + } + else + { + if (pAetPtr->direction >= 0) + { + pAetPtr->minor += pAetPtr->gradient1; + pAetPtr->direction += pAetPtr->inc1; + } + else + { + pAetPtr->minor += pAetPtr->gradient; + pAetPtr->direction += pAetPtr->inc2; + } + } + pPrevAet = pAetPtr; + pAetPtr = pAetPtr->pNext; + } + } + pWetePtr = pWetePtr->pWNext; + } + + if (pAetPtr == null) + { + break; + } + + if (pAetPtr->maxY == y) + { + pPrevAet->pNext = pAetPtr->pNext; + pAetPtr = pPrevAet->pNext; + fixWaet = 1; + + if (pAetPtr != null) + { + pAetPtr->pBack = pPrevAet; + } + } + else + { + if (pAetPtr->gradient1 > 0) + { + if (pAetPtr->direction > 0) + { + pAetPtr->minor += pAetPtr->gradient1; + pAetPtr->direction += pAetPtr->inc1; + } + else + { + pAetPtr->minor += pAetPtr->gradient; + pAetPtr->direction += pAetPtr->inc2; + } + } + else + { + if (pAetPtr->direction >= 0) + { + pAetPtr->minor += pAetPtr->gradient1; + pAetPtr->direction += pAetPtr->inc1; + } + else + { + pAetPtr->minor += pAetPtr->gradient; + pAetPtr->direction += pAetPtr->inc2; + } + } + + pPrevAet = pAetPtr; + pAetPtr = pAetPtr->pNext; + } + } + + if (line._InsertionSort(&aet) || fixWaet) + { + line._ComputeWaet(&aet); + fixWaet = 0; + } + } + + delete[] pTempPoints; + + delete[] pEteBuf; + + line._FreeSllb(pSllb); + + return E_SUCCESS; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_CanvasGpLine.cpp b/src/graphics/FGrp_CanvasGpLine.cpp new file mode 100644 index 0000000..8089bac --- /dev/null +++ b/src/graphics/FGrp_CanvasGpLine.cpp @@ -0,0 +1,2393 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasGpLine.cpp + * @brief This is the implementation file for _CanvasLine class. + * + */ + +#include +#include +#include + +#include + +#include + +#include "FGrp_CanvasGpPrimitive.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Graphics +{ + +bool +_CanvasLine::SetLineWidth(int lineWidth) +{ + __lineWidth = lineWidth; + + return true; +} + +int +_CanvasLine::GetLineWidth(void) const +{ + return __lineWidth; +} + +result +_CanvasLine::DrawLine(const _GpPoint& startPt, const _GpPoint& endPt, const _GpBufferInfo& bufInfo) +{ + _GpRect rcLine; + int halfLineW; + _GpResult ret = GP_RESULT_FAIL; + bool finalRet = false; + bool clip = true; + + halfLineW = __lineWidth >> 1; + + if (startPt.x > endPt.x) + { + rcLine.x = endPt.x; + rcLine.width = startPt.x - endPt.x + 1; + } + else + { + rcLine.x = startPt.x; + rcLine.width = endPt.x - startPt.x + 1; + } + + if (startPt.y > endPt.y) + { + rcLine.y = endPt.y; + rcLine.height = startPt.y - endPt.y + 1; + } + else + { + rcLine.y = startPt.y; + rcLine.height = endPt.y - startPt.y + 1; + } + + if (_IsInClipRect(rcLine.x - halfLineW, rcLine.y - halfLineW, rcLine.width + __lineWidth, rcLine.height + __lineWidth, bufInfo)) + { + _SetNotClipFunction(true); + clip = false; + } + + if (__lineWidth == 1) + { + if (startPt.x == endPt.x) + { + ret = (this->*pFuncVerticalLine)(startPt.x, startPt.y, endPt.y, bufInfo); + } + else if (startPt.y == endPt.y) + { + ret = (this->*pFuncHorizontalLine)(startPt.x, endPt.x, startPt.y, bufInfo); + } + else + { + ret = _DrawUnitLineSlant(startPt, endPt, bufInfo); + } + } + else + { + if ((bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + finalRet = __DrawWideLine(startPt, endPt, bufInfo); + } + else if ((bufInfo.color32 & 0xFF000000) > 0) + { + finalRet = __DrawWideLineWithOpacity32(startPt, endPt, bufInfo); + } + } + + if (__lineWidth > 2 && (bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + if (__lineWidth > 4) + { + int lineW = __lineWidth; + + if (lineW % 2 == 0) + { + halfLineW--; + lineW--; + } + + _CanvasEllipse ellipse; + + ellipse.SetLineWidth(lineW); + + // Line Round End + if (ellipse.FillElliepse(startPt.x - halfLineW, startPt.y - halfLineW, lineW, lineW, bufInfo) == E_SYSTEM) + { + SysLog(NID_GRP, "DrawLine: FillElliepse() is failed!\n"); + finalRet = false; + } + + if (ellipse.FillElliepse(endPt.x - halfLineW, endPt.y - halfLineW, lineW, lineW, bufInfo) == E_SYSTEM) + { + SysLog(NID_GRP, "DrawLine: FillElliepse() is failed!\n"); + finalRet = false; + } + } + else if (__lineWidth == 4) + { + SetLineWidth(1); + + (this->*pFuncHorizontalLine)(startPt.x - 1, startPt.x, startPt.y - 2, bufInfo); + (this->*pFuncHorizontalLine)(startPt.x - 2, startPt.x + 1, startPt.y - 1, bufInfo); + (this->*pFuncHorizontalLine)(startPt.x - 2, startPt.x + 1, startPt.y, bufInfo); + (this->*pFuncHorizontalLine)(startPt.x - 1, startPt.x, startPt.y + 1, bufInfo); + + (this->*pFuncHorizontalLine)(endPt.x - 1, endPt.x, endPt.y - 2, bufInfo); + (this->*pFuncHorizontalLine)(endPt.x - 2, endPt.x + 1, endPt.y - 1, bufInfo); + (this->*pFuncHorizontalLine)(endPt.x - 2, endPt.x + 1, endPt.y, bufInfo); + (this->*pFuncHorizontalLine)(endPt.x - 1, endPt.x, endPt.y + 1, bufInfo); + + SetLineWidth(4); + } + else // __lineWidth = 3 + { + SetLineWidth(1); + + (this->*pFuncHorizontalLine)(startPt.x, startPt.x, startPt.y - 1, bufInfo); + (this->*pFuncHorizontalLine)(startPt.x - 1, startPt.x + 1, startPt.y, bufInfo); + (this->*pFuncHorizontalLine)(startPt.x, startPt.x, startPt.y + 1, bufInfo); + + (this->*pFuncHorizontalLine)(endPt.x, endPt.x, endPt.y - 1, bufInfo); + (this->*pFuncHorizontalLine)(endPt.x - 1, endPt.x + 1, endPt.y, bufInfo); + (this->*pFuncHorizontalLine)(endPt.x, endPt.x, endPt.y + 1, bufInfo); + + SetLineWidth(3); + } + } + + if (!clip) + { + _SetClipFunction(true); + } + + return ((ret == GP_RESULT_FAIL) && (finalRet == false) ? E_SYSTEM : E_SUCCESS); +} + +_GpResult +_CanvasLine::_DrawUnitLineVertical(int x, int startY, int endY, const _GpBufferInfo& bufInfo) +{ + Point pt(x, startY); + + if (bufInfo.bitsPerPixel == 32) + { + unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels; + + if (pFrmbuf32) + { + if (startY > endY) + { + GP_SWAP(startY, endY); + pt.y = startY; + } + + if ((bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + while (pt.y < endY) + { + pFrmbuf32[bufInfo.pixelPerLine * pt.y + pt.x] = bufInfo.color32; + pt.y++; + } + } + else if ((bufInfo.color32 & 0xFF000000) > 0) + { + while (pt.y < endY) + { + __DrawHorizontalLineWithOpacity32(pt.x, pt.x, pt.y, bufInfo); + pt.y++; + } + } + } + else + { + SysLog(NID_GRP, "_DrawUnitLineVertical: pFrmbuf32 is invalid!\n"); + return GP_RESULT_FAIL; + } + } + else + { + // To do 16 bpp + SysLog(NID_GRP, "_DrawUnitLineVertical: not support 16 bpp!\n"); + return GP_RESULT_FAIL; + } + + return GP_RESULT_SUCCESS; +} + +_GpResult +_CanvasLine::_DrawUnitLineHorizontal(int startX, int endX, int y, const _GpBufferInfo& bufInfo) +{ + Point pt(startX, y); + + if (bufInfo.bitsPerPixel == 32) + { + unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels; + + if (pFrmbuf32) + { + if (startX > endX) + { + GP_SWAP(startX, endX); + pt.x = startX; + } + + if ((bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + while (pt.x <= endX) + { + pFrmbuf32[bufInfo.pixelPerLine * pt.y + pt.x] = bufInfo.color32; + pt.x++; + } + } + else if ((bufInfo.color32 & 0xFF000000) > 0) + { + __DrawHorizontalLineWithOpacity32(pt.x, endX, pt.y, bufInfo); + } + } + else + { + SysLog(NID_GRP, "_DrawUnitLineHorizontal: pFrmbuf32 is null!\n"); + + return GP_RESULT_FAIL; + } + } + else + { + // To do 16 bpp + SysLog(NID_GRP, "_DrawUnitLineHorizontal: not support 16 bpp!\n"); + + return GP_RESULT_FAIL; + } + + return GP_RESULT_SUCCESS; +} + +_GpResult +_CanvasLine::_DrawWideLineVertical(int x, int startY, int endY, const _GpBufferInfo& bufInfo) +{ + int halfLineW; + int posX; + + Point pt(x, startY); + + if (bufInfo.bitsPerPixel == 32) + { + unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels; + + if (pFrmbuf32) + { + if (startY > endY) + { + GP_SWAP(startY, endY); + pt.y = startY; + } + + halfLineW = __lineWidth >> 1; + + if (__lineWidth == 1) //is this part necessary? + { + if ((bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + while (pt.y < endY) + { + pFrmbuf32[bufInfo.pixelPerLine * pt.y + pt.x] = bufInfo.color32; + pt.y++; + } + } + else if ((bufInfo.color32 & 0xFF000000) > 0) + { + while (pt.y < endY) + { + __DrawHorizontalLineWithOpacity32(pt.x, pt.x, pt.y, bufInfo); + pt.y++; + } + } + } + else + { + int realEndX = x + halfLineW; + + if (__lineWidth % 2 == 0) + { + realEndX--; + } + + if (__lineWidth == 2 && pt.y >= 1) + { + pt.y--; + } + + posX = x - halfLineW; + + if (x == 0) + { + posX = x; + } + + for (; posX <= realEndX; posX++) + { + // draw vertical line + if ((bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + while (pt.y < endY) + { + pFrmbuf32[bufInfo.pixelPerLine * pt.y + posX] = bufInfo.color32; + pt.y++; + } + } + else if ((bufInfo.color32 & 0xFF000000) > 0) + { + while (pt.y < endY) + { + __DrawHorizontalLineWithOpacity32(posX, posX, pt.y, bufInfo); + pt.y++; + } + } + + pt.y = startY; + } + } + } + else + { + SysLog(NID_GRP, "_DrawWideLineVertical: pFrmbuf32 is invalid!\n"); + + return GP_RESULT_FAIL; + } + } + else + { + // To do 16 bpp + SysLog(NID_GRP, "_DrawWideLineVertical: not support 16 bpp!\n"); + + return GP_RESULT_FAIL; + } + + return GP_RESULT_SUCCESS; +} + +_GpResult +_CanvasLine::_DrawWideLineHorizontal(int startX, int endX, int y, const _GpBufferInfo& bufInfo) +{ + int halfLineW; + int posY; + + if (bufInfo.bitsPerPixel == 32) + { + unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels; + + if (pFrmbuf32) + { + Point pt(startX, y); + if (startX > endX) + { + GP_SWAP(startX, endX); + pt.x = startX; + } + + // Calculate half Width of Line + halfLineW = __lineWidth >> 1; + + if (__lineWidth == 1) // is this part necessary? + { + // draw primitive line + if ((bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + while (pt.x < endX) + { + pFrmbuf32[bufInfo.pixelPerLine * pt.y + pt.x] = bufInfo.color32; + pt.x++; + } + } + else if ((bufInfo.color32 & 0xFF000000) > 0) + { + __DrawHorizontalLineWithOpacity32(pt.x, endX, y, bufInfo); + } + } + else + { + int realEndY = y + halfLineW; + + if (__lineWidth % 2 == 0) + { + realEndY--; + } + + if (__lineWidth == 2 && pt.x >= 1) + { + pt.x--; + } + + posY = y - halfLineW; + + if (y == 0) + { + posY = y; + } + + for (; posY <= realEndY; posY++) + { + if ((bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + while (pt.x < endX) + { + pFrmbuf32[bufInfo.pixelPerLine * posY + pt.x] = bufInfo.color32; + pt.x++; + } + } + else if ((bufInfo.color32 & 0xFF000000) > 0) + { + __DrawHorizontalLineWithOpacity32(pt.x, endX, posY, bufInfo); + } + + pt.x = startX; + } + } + } + else + { + SysLog(NID_GRP, "_DrawWideLineHorizontal: pFrmbuf32 is invalid!\n"); + + return GP_RESULT_FAIL; + } + } + else + { + // To do 16 bpp + SysLog(NID_GRP, "_DrawWideLineHorizontal: not support 16 bpp!\n"); + + return GP_RESULT_FAIL; + } + + return GP_RESULT_SUCCESS; +} + +_GpResult +_CanvasLine::_DrawUnitLineSlant(const _GpPoint& point1, const _GpPoint& point2, const _GpBufferInfo& bufInfo) +{ + int deltaX; + int deltaY; + int deltaDiff; + int inc; + int errorInc; + int errorIncCount; + int absX; + int absY; + + if (bufInfo.bitsPerPixel == 32) + { + Point startPt(point1.x, point1.y); + Point endPt(point2.x, point2.y); + + absX = GP_ABS(endPt.x - startPt.x); + absY = GP_ABS(endPt.y - startPt.y); + + if (absX > absY) + { + if (startPt.x > endPt.x) + { + GP_SWAP(startPt.x, endPt.x); + GP_SWAP(startPt.y, endPt.y); + } + + inc = (endPt.y > startPt.y) ? 1 : -1; + deltaX = endPt.x - startPt.x; + deltaY = GP_ABS(endPt.y - startPt.y); + deltaDiff = (deltaY << 1) - deltaX; + errorInc = (deltaY << 1); + errorIncCount = (deltaY - deltaX) << 1; + + Point pt(startPt.x, startPt.y); + + (this->*pFuncSetPixel)(startPt.x, startPt.y, bufInfo); + + while (pt.x < endPt.x) + { + pt.x++; + + if (deltaDiff > 0) + { + pt.y += inc; + deltaDiff += errorIncCount; + } + else + { + deltaDiff += errorInc; + } + + (this->*pFuncSetPixel)(pt.x, pt.y, bufInfo); + } + } + else + { + if (startPt.y > endPt.y) + { + GP_SWAP(startPt.x, endPt.x); + GP_SWAP(startPt.y, endPt.y); + } + + inc = (endPt.x > startPt.x) ? 1 : -1; + deltaX = GP_ABS(endPt.x - startPt.x); + deltaY = endPt.y - startPt.y; + deltaDiff = (deltaX << 1) - deltaY; + errorInc = (deltaX << 1); + errorIncCount = (deltaX - deltaY) << 1; + + Point pt(startPt.x, startPt.y); + + (this->*pFuncSetPixel)(startPt.x, startPt.y, bufInfo); + + while (pt.y < endPt.y) + { + pt.y++; + + if (deltaDiff > 0) + { + pt.x += inc; + deltaDiff += errorIncCount; + } + else + { + deltaDiff += errorInc; + } + + (this->*pFuncSetPixel)(pt.x, pt.y, bufInfo); + } + } + } + else + { + // To do 16 bpp + return GP_RESULT_FAIL; + } + + return GP_RESULT_SUCCESS; +} + +_GpResult +_CanvasLine::_DrawPixel(int x, int y, const _GpBufferInfo& bufInfo) +{ + if (bufInfo.bitsPerPixel == 32) + { + unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels; + + if (pFrmbuf32) + { + if ((bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + pFrmbuf32[bufInfo.pixelPerLine * y + x] = bufInfo.color32; + } + else if ((bufInfo.color32 & 0xFF000000) > 0) + { + __DrawHorizontalLineWithOpacity32(x, x, y, bufInfo); + } + } + else + { + SysLog(NID_GRP, "_DrawPixel: pFrmbuf32 is null!\n"); + + return GP_RESULT_FAIL; + } + } + else + { + // To do 16 bpp + SysLog(NID_GRP, "_DrawPixel: not support 16 bpp!\n"); + + return GP_RESULT_FAIL; + } + + return GP_RESULT_SUCCESS; +} + +_GpResult +_CanvasLine::_DrawUnitLineVerticalWithClipping(int x, int startY, int endY, const _GpBufferInfo& bufInfo) +{ + Point pt(x, startY); + + if (bufInfo.bitsPerPixel == 32) + { + unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels; + + if (pFrmbuf32) + { + if (startY > endY) + { + GP_SWAP(startY, endY); + pt.y = startY; + } + + if (bufInfo.isClipBoundsSet) + { + if (pt.x < bufInfo.clipBounds.x || pt.x > bufInfo.clipBounds.x + bufInfo.clipBounds.width - 1) + { + return GP_RESULT_OUTOFBOUNDS; + } + + if (pt.y > bufInfo.clipBounds.y + bufInfo.clipBounds.height - 1 || endY < bufInfo.clipBounds.y) + { + return GP_RESULT_OUTOFBOUNDS; + } + + if (pt.y < bufInfo.clipBounds.y) + { + pt.y = bufInfo.clipBounds.y; + } + + if (endY > bufInfo.clipBounds.y + bufInfo.clipBounds.height - 1) + { + endY = bufInfo.clipBounds.y + bufInfo.clipBounds.height - 1; + } + } + else + { + if (pt.x < 0 || pt.x > bufInfo.width - 1) + { + return GP_RESULT_OUTOFBOUNDS; + } + + if (endY < 0 || pt.y > bufInfo.height - 1) + { + return GP_RESULT_OUTOFBOUNDS; + } + + if (pt.y < 0) + { + pt.y = 0; + } + + if (endY > bufInfo.height - 1) + { + endY = bufInfo.height - 1; + } + + if ((endY - pt.y) == 0) + { + return GP_RESULT_OUTOFBOUNDS; + } + + if (pt.x == bufInfo.width) + { + pt.x--; + } + } + + if ((bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + while (pt.y < endY) + { + pFrmbuf32[bufInfo.pixelPerLine * pt.y + pt.x] = bufInfo.color32; + pt.y++; + } + } + else if ((bufInfo.color32 & 0xFF000000) > 0) + { + while (pt.y < endY) + { + __DrawHorizontalLineWithOpacity32(pt.x, pt.x, pt.y, bufInfo); + pt.y++; + } + } + } + else + { + SysLog(NID_GRP, "_DrawUnitLineVerticalWithClipping: pFrmbuf32 is invalid!\n"); + + return GP_RESULT_FAIL; + } + } + else + { + // To do 16 bpp + SysLog(NID_GRP, "_DrawUnitLineVerticalWithClipping: not support 16 bpp!\n"); + + return GP_RESULT_FAIL; + } + + return GP_RESULT_SUCCESS; +} + +_GpResult +_CanvasLine::_DrawUnitLineHorizontalWithClipping(int startX, int endX, int y, const _GpBufferInfo& bufInfo) +{ + Point pt(startX, y); + + if (bufInfo.bitsPerPixel == 32) + { + unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels; + + if (pFrmbuf32) + { + if (startX > endX) + { + GP_SWAP(startX, endX); + pt.x = startX; + } + + if (bufInfo.isClipBoundsSet) + { + if (pt.y < bufInfo.clipBounds.y || pt.y > bufInfo.clipBounds.y + bufInfo.clipBounds.height - 1) + { + return GP_RESULT_OUTOFBOUNDS; + } + + if (pt.x > bufInfo.clipBounds.x + bufInfo.clipBounds.width - 1 || endX < bufInfo.clipBounds.x) + { + return GP_RESULT_OUTOFBOUNDS; + } + + if (pt.x < bufInfo.clipBounds.x) + { + pt.x = bufInfo.clipBounds.x; + } + + if (endX > bufInfo.clipBounds.x + bufInfo.clipBounds.width - 1) + { + endX = bufInfo.clipBounds.x + bufInfo.clipBounds.width - 1; + } + } + else + { + if (pt.y < 0 || pt.y > bufInfo.height - 1) + { + return GP_RESULT_OUTOFBOUNDS; + } + + if (endX < 0 || pt.x > bufInfo.width - 1) + { + return GP_RESULT_OUTOFBOUNDS; + } + + if (pt.x < 0) + { + pt.x = 0; + } + + if (endX > bufInfo.width - 1) + { + endX = bufInfo.width - 1; + } + + if ((endX - pt.x) == 0) + { + return GP_RESULT_OUTOFBOUNDS; + } + + if (pt.y == bufInfo.height) + { + pt.y--; + } + } + + if ((bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + while (pt.x <= endX) + { + pFrmbuf32[bufInfo.pixelPerLine * pt.y + pt.x] = bufInfo.color32; + pt.x++; + } + } + else if ((bufInfo.color32 & 0xFF000000) > 0) + { + __DrawHorizontalLineWithOpacity32(pt.x, endX, pt.y, bufInfo); + } + } + else + { + SysLog(NID_GRP, "_DrawUnitLineHorizontalWithClipping: pFrmbuf32 is null!\n"); + + return GP_RESULT_FAIL; + } + } + else + { + // To do 16 bpp + SysLog(NID_GRP, "_DrawUnitLineHorizontalWithClipping: not support 16 bpp!\n"); + + return GP_RESULT_FAIL; + } + + return GP_RESULT_SUCCESS; +} + +_GpResult +_CanvasLine::_DrawWideLineVerticalWithClipping(int x, int startY, int endY, const _GpBufferInfo& bufInfo) +{ + int halfLineW; + int posX; + + halfLineW = __lineWidth >> 1; + + if (__lineWidth == 1) + { + if (_DrawUnitLineVerticalWithClipping(x, startY, endY, bufInfo) == GP_RESULT_FAIL) + { + SysLog(NID_GRP, "_DrawUnitLineVerticalWithClipping: _DrawUnitLineVerticalWithClipping() is failed!\n"); + + return GP_RESULT_FAIL; + } + } + else + { + int realEndX = x + halfLineW; + + if (__lineWidth % 2 == 0) + { + realEndX--; + } + +/* bjcho : For fixing y coordinate when the line width is 2 pixel. + if (lineW == 2) + y1--; +*/ + + for (posX = x - halfLineW; posX <= realEndX; posX++) + { + if (_DrawUnitLineVerticalWithClipping(posX, startY, endY, bufInfo) == GP_RESULT_FAIL) + { + SysLog(NID_GRP, "_DrawUnitLineVerticalWithClipping: _DrawUnitLineVerticalWithClipping() is failed!\n"); + + return GP_RESULT_FAIL; + } + } + } + + return GP_RESULT_SUCCESS; +} + +_GpResult +_CanvasLine::_DrawWideLineHorizontalWithClipping(int startX, int endX, int y, const _GpBufferInfo& bufInfo) +{ + int halfLineW; + int posY; + + // Calculate half Width of Line + halfLineW = __lineWidth >> 1; + + // Insert Clipping + if (__lineWidth == 1) + { + if (_DrawUnitLineHorizontalWithClipping(startX, endX, y, bufInfo) == GP_RESULT_FAIL) + { + SysLog(NID_GRP, "_DrawUnitLineHorizontalWithClipping: _DrawUnitLineHorizontalWithClipping() is failed!\n"); + + return GP_RESULT_FAIL; + } + } + else + { + int realEndY = y + halfLineW; + + if (__lineWidth % 2 == 0) + { + realEndY--; + } + + + // if (lineW == 2) + // x1--; + + + for (posY = y - halfLineW; posY <= realEndY; posY++) + { + if (_DrawUnitLineHorizontalWithClipping(startX, endX, posY, bufInfo) == GP_RESULT_FAIL) + { + SysLog(NID_GRP, "_DrawUnitLineHorizontalWithClipping: _DrawUnitLineHorizontalWithClipping() is failed!\n"); + + return GP_RESULT_FAIL; + } + } + } + + return GP_RESULT_SUCCESS; +} + +_GpResult +_CanvasLine::_DrawPixelWithClipping(int x, int y, const _GpBufferInfo& bufInfo) +{ + if (bufInfo.bitsPerPixel == 32) + { + unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels; + + if (pFrmbuf32) + { + if (bufInfo.isClipBoundsSet) + { + if (x < bufInfo.clipBounds.x || x >= bufInfo.clipBounds.x + bufInfo.clipBounds.width) + { + return GP_RESULT_OUTOFBOUNDS; + } + + if (y < bufInfo.clipBounds.y || y >= bufInfo.clipBounds.y + bufInfo.clipBounds.height) + { + return GP_RESULT_OUTOFBOUNDS; + } + } + else + { + if (x < 0 || x >= bufInfo.width) + { + return GP_RESULT_OUTOFBOUNDS; + } + + if (y < 0 || y >= bufInfo.height) + { + return GP_RESULT_OUTOFBOUNDS; + } + } + + if ((bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + pFrmbuf32[bufInfo.pixelPerLine * y + x] = bufInfo.color32; + } + else if ((bufInfo.color32 & 0xFF000000) > 0) + { + __DrawHorizontalLineWithOpacity32(x, x, y, bufInfo); + } + } + else + { + SysLog(NID_GRP, "_DrawPixelWithClipping: pFrmbuf32 is null!\n"); + + return GP_RESULT_FAIL; + } + } + else + { + // To do 16 bpp + SysLog(NID_GRP, "_DrawPixelWithClipping: not support 16 bpp!\n"); + + return GP_RESULT_FAIL; + } + + return GP_RESULT_SUCCESS; +} + +bool +_CanvasLine::__DrawWideLine(const _GpPoint& startPt, const _GpPoint& endPt, const _GpBufferInfo& bufInfo) +{ + _GpResult result = GP_RESULT_FAIL; + bool ret = false; + int halfLineW = __lineWidth >> 1; + + if (startPt.x == endPt.x && startPt.y == endPt.y) + { + if (bufInfo.bitsPerPixel == 32) + { + _CanvasEllipse ellipse; + + ellipse.SetLineWidth(__lineWidth); + + if (ellipse.FillElliepse(startPt.x - halfLineW, startPt.y - halfLineW, __lineWidth, __lineWidth, bufInfo) == E_SUCCESS) + { + ret = true; + } + } + } + else + { + ret = __DrawWideLineWithOpacity32(startPt, endPt, bufInfo); + //ret = _DrawUnitLineSlant(startPt, endPt, bufInfo); // need to check if slantline drawing is slow.. + } + + return (result == GP_RESULT_FAIL && ret == false && E_SYSTEM ? false : true); +} + +bool +_CanvasLine::__DrawWideLineWithOpacity32(const _GpPoint& startPt, const _GpPoint& endPt, const _GpBufferInfo& bufInfo) +{ + bool ret = false; + _GpPoint points[2] = + { + { startPt.x, startPt.y }, + { endPt.x, endPt.y } + }; + + ret = __DrawThickContinuousPolyline(2, points, false, bufInfo); + + return ret; +} + +bool +_CanvasLine::__DrawThickContinuousPolyline(int listCount, _GpPoint* pPoints, bool isConnected, const _GpBufferInfo& bufInfo) +{ + int i; + int j; + float connectedX = 0.0f; + float connectedY = 0.0f; + float sox = 0; + float soy = 0; + _GpVertex* pVertex = null; + _GpPoint* pTempPoints = null; + bool ret = false; + + if (listCount < 2) + { + return false; + } + + _GpPolygon* pPolygon = new (std::nothrow) _GpPolygon; + + if (pPolygon == null) + { + return false; + } + + if (isConnected) + { + int plx; + int ply; + int prx; + int pry; + + _GetOrientationUnitVector(pPoints[listCount - 1], pPoints[0], &connectedX, &connectedY); + + sox = connectedX; + soy = connectedY; + + __GetBrushEndPoint(sox, soy, __lineWidth, &plx, &ply, &prx, &pry); + + if (!_AddPolygonVertex(pPolygon, pPoints[0].x + plx, pPoints[0].y + ply, 0)) + { + _FreePolygon(pPolygon); + + return false; + } + + if (!_AddPolygonVertex(pPolygon, pPoints[0].x + prx, pPoints[0].y + pry, 1)) + { + _FreePolygon(pPolygon); + + return false; + } + + } + + for (i = 1; i < listCount; i++) + { + j = i - 1; + + float ox; + float oy; + + _GetOrientationUnitVector(pPoints[j], pPoints[i], &ox, &oy); + + if (j == 0 && !isConnected) + { + if (!_PatchRoundCap(pPolygon, pPoints[0].x, pPoints[0].y, ox, oy, true)) + { + _FreePolygon(pPolygon); + + return false; + } + } + else + { + if (!_PatchJoint(pPolygon, pPoints[j].x, pPoints[j].y, connectedX, connectedY, ox, oy)) + { + _FreePolygon(pPolygon); + + return false; + } + } + + ret = _PatchThickContinuousLine(pPolygon, pPoints[j], pPoints[i], ox, oy, 0, 0); + + if (!ret) + { + _FreePolygon(pPolygon); + + return ret; + } + + connectedX = ox; + connectedY = oy; + } + + if (isConnected) + { + if (!_PatchJoint(pPolygon, pPoints[listCount - 1].x, pPoints[listCount - 1].y, connectedX, connectedY, sox, soy)) + { + _FreePolygon(pPolygon); + + return false; + } + + if (!_PatchThickContinuousLine(pPolygon, pPoints[listCount - 1], pPoints[0], sox, soy, 0, 0)) + { + _FreePolygon(pPolygon); + + return false; + } + } + else + { + //j = num - 1; + if (!_PatchRoundCap(pPolygon, pPoints[listCount - 1].x, pPoints[listCount - 1].y, connectedX, connectedY, false)) + { + _FreePolygon(pPolygon); + + return false; + } + } + + pTempPoints = new (std::nothrow) _GpPoint[pPolygon->n]; + + if (pTempPoints == null) + { + _FreePolygon(pPolygon); + + return ret; + } + + for (i = 0, pVertex = pPolygon->pFirst; pVertex != null; i++, pVertex = pVertex->pNext) + { + pTempPoints[i] = pVertex->point; + } + + _FillPolygon(pPolygon->n, pTempPoints, false, bufInfo); + + _FreePolygon(pPolygon); + + delete[] pTempPoints; + + return ret; +} + +result +_CanvasLine::DrawPolyLine(int ptCount, _GpPoint* pPoints, const _GpBufferInfo& bufInfo) +{ + bool ret = false; + + if (ptCount < 2) + { + return E_SYSTEM; + } + + ret = _DrawPolyLine(ptCount, pPoints, false, bufInfo); + + return (ret ? E_SUCCESS : E_SYSTEM); +} + +result +_CanvasLine::DrawPolygon(int ptCount, _GpPoint* pPoints, const _GpBufferInfo& bufInfo) +{ + bool ret = false; + + if (ptCount < 2) + { + return E_SYSTEM; + } + + ret = _DrawPolyLine(ptCount, pPoints, true, bufInfo); + + return (ret ? E_SUCCESS : E_SYSTEM); +} + +int +_CanvasLine::__CheckDupVertexForPolygon(int ptCount, _GpPoint* pPoints, bool isConnected) const +{ + int i = 0; + int j = 0; + + while (j < ptCount - 1) + { + if (pPoints[j].x == pPoints[j + 1].x && pPoints[j].y == pPoints[j + 1].y) + { + ++j; + continue; + } + + if (i < j) + { + pPoints[i] = pPoints[j]; + } + + ++i; + ++j; + } + + if (isConnected) + { + if (pPoints[ptCount - 1].x != pPoints[0].x || pPoints[ptCount - 1].y != pPoints[0].y) + { + pPoints[i] = pPoints[ptCount - 1]; + ++i; + } + } + else + { + pPoints[i] = pPoints[ptCount - 1]; + ++i; + } + + return i; +} + +void +_CanvasLine::_FreePolygon(_GpPolygon* pPolygon) const +{ + _GpVertex* pVertex = null; + _GpVertex* pNext = null; + + if (pPolygon == null) + { + SysLog(NID_GRP, "_FreePolygon: pPolygon is null !\n"); + + return; + } + + pVertex = pPolygon->pFirst; + + while (pVertex != null) + { + pNext = pVertex->pNext; + delete pVertex; + pVertex = pNext; + } + + delete pPolygon; + + return; +} + +bool +_CanvasLine::_FillPolygon(int ptCount, _GpPoint* pPoints, bool isEvenOdd, const _GpBufferInfo& bufInfo) +{ + _GpEdgeTable edgeTable; + _GpEdgeTableEntry anEdgeTableEntry; + _GpEdgeTableEntry* pPrevAet = null; + _GpEdgeTableEntry* pAet = null; + _GpEdgeTableEntry* pWete = null; + _GpScanLineListBlock scanLineListBlock; + _GpScanLineList* pScanLineList = null; + _GpEdgeTableEntry* pBufEte = null; + int y; + int stitch = 1; + int fixWAet = 0; + + if (pPoints == null) + { + SysLog(NID_GRP, "_FillPolygon: pPoints is null!\n"); + + return false; + } + + memset(&edgeTable, 0, sizeof(edgeTable)); + memset(&anEdgeTableEntry, 0, sizeof(anEdgeTableEntry)); + memset(&scanLineListBlock, 0, sizeof(scanLineListBlock)); + + pBufEte = new (std::nothrow) _GpEdgeTableEntry[ptCount]; + + if (pBufEte == null) + { + return false; + } + + if (!_CreateEtAndAet(ptCount, pPoints, &edgeTable, &anEdgeTableEntry, pBufEte, &scanLineListBlock)) + { + delete[] pBufEte; + + return false; + } + + pScanLineList = edgeTable.scanLines.pNext; + + if (isEvenOdd) + { + } + else + { + for (y = edgeTable.minY; y < edgeTable.maxY + stitch; y++) + { + if (pScanLineList != null && y == pScanLineList->scanLine) + { + _LoadAet(&anEdgeTableEntry, pScanLineList->pEdgeList); + _ComputeWaet(&anEdgeTableEntry); + pScanLineList = pScanLineList->pNext; + } + + pPrevAet = &anEdgeTableEntry; + pAet = anEdgeTableEntry.pNext; + pWete = pAet; + + while (pAet) + { + if (pWete == pAet) + { + if (_DrawUnitLineHorizontalWithClipping(pAet->minor, pAet->pWNext->minor + stitch - 1, y, bufInfo) == GP_RESULT_FAIL) + { + delete[] pBufEte; + _FreeSllb(scanLineListBlock.pNext); + + return false; + } + + pWete = pWete->pWNext; + while (pWete != pAet) + { + //SysAssert(pAet); + if (pAet == null) + { + break; + } + + // 1st + if (pAet->maxY == y) + { + pPrevAet->pNext = pAet->pNext; + pAet = pPrevAet->pNext; + fixWAet = 1; + + if (pAet) + { + pAet->pBack = pPrevAet; + } + } + else + { + if (pAet->gradient1 > 0) + { + if (pAet->direction > 0) + { + pAet->minor += pAet->gradient1; + pAet->direction += pAet->inc1; + } + else + { + pAet->minor += pAet->gradient; + pAet->direction += pAet->inc2; + } + } + else + { + if (pAet->direction >= 0) + { + pAet->minor += pAet->gradient1; + pAet->direction += pAet->inc1; + } + else + { + pAet->minor += pAet->gradient; + pAet->direction += pAet->inc2; + } + } + pPrevAet = pAet; + pAet = pAet->pNext; + } + } + pWete = pWete->pWNext; + } + + //SysAssert(pAet); + + if (pAet == null) + { + break; + } + + // 2nd + if (pAet->maxY == y) + { + pPrevAet->pNext = pAet->pNext; + pAet = pPrevAet->pNext; + fixWAet = 1; + if (pAet) + { + pAet->pBack = pPrevAet; + } + } + else + { + if (pAet->gradient1 > 0) + { + if (pAet->direction > 0) + { + pAet->minor += pAet->gradient1; + pAet->direction += pAet->inc1; + } + else + { + pAet->minor += pAet->gradient; + pAet->direction += pAet->inc2; + } + } + else + { + if (pAet->direction >= 0) + { + pAet->minor += pAet->gradient1; + pAet->direction += pAet->inc1; + } + else + { + pAet->minor += pAet->gradient; + pAet->direction += pAet->inc2; + } + } + pPrevAet = pAet; + pAet = pAet->pNext; + } + } + + if ((_InsertionSort(&anEdgeTableEntry)) || fixWAet) + { + _ComputeWaet(&anEdgeTableEntry); + fixWAet = 0; + } + } + } + + delete[] pBufEte; + _FreeSllb(scanLineListBlock.pNext); + + return true; +} + +bool +_CanvasLine::_GetOrientationUnitVector(_GpPoint& startPt, _GpPoint& endPt, float* pOx, float* pOy) const +{ + float len; + + if (pOx == null || pOy == null) + { + return false; + } + + *pOx = (float) (endPt.x - startPt.x); + *pOy = (float) (endPt.y - startPt.y); + + // need to check how to use the math func + len = (float) sqrt((*pOx) * (*pOx) + (*pOy) * (*pOy)); + + if (len < 1) + { + return false; + } + + *pOx = *pOx / len; + *pOy = *pOy / len; + + return true; +} + +bool +_CanvasLine::_PatchThickContinuousLine(_GpPolygon* pPolygon, _GpPoint& point1, _GpPoint& point2, float ox1, float oy1, float ox2, float oy2) const +{ + int plx; + int ply; + int prx; + int pry; + bool ret = false; + + if (pPolygon == null) + { + return false; + } + + __GetBrushEndPoint(ox1, oy1, __lineWidth, &plx, &ply, &prx, &pry); + + ret = _AddPolygonVertex(pPolygon, point1.x + plx, point1.y + ply, 0); + + if (!ret) + { + return ret; + } + + ret = _AddPolygonVertex(pPolygon, point1.x + prx, point1.y + pry, 1); + + if (!ret) + { + return ret; + } + + // if (ox2 != 0 || oy2 != 0) + if ((!_IsEqual(ox2, 0.0f)) || (!_IsEqual(oy2, 0.0f))) + { + __GetBrushEndPoint(ox2, oy2, __lineWidth, &plx, &ply, &prx, &pry); + } + + ret = _AddPolygonVertex(pPolygon, point2.x + plx, point2.y + ply, 0); + + if (!ret) + { + return ret; + } + + ret = _AddPolygonVertex(pPolygon, point2.x + prx, point2.y + pry, 1); + + if (!ret) + { + return ret; + } + + return true; +} + +bool +_CanvasLine::_AddPolygonVertex(_GpPolygon* pPolygon, int x, int y, int pos) const +{ + if (pPolygon == null) + { + return false; + } + + _GpVertex* pNewVertex = new (std::nothrow) _GpVertex; + + if (pNewVertex == null) + { + return false; + } + + pNewVertex->point.x = x; + pNewVertex->point.y = y; + + if (pPolygon->n == 0) + { + pNewVertex->pNext = null; + pPolygon->pFirst = pPolygon->pLast = pNewVertex; + pPolygon->n = 1; + + return true; + } + + if (pos == 0) + { + pNewVertex->pNext = pPolygon->pFirst; + pPolygon->pFirst = pNewVertex; + pPolygon->n++; + } + else + { + pNewVertex->pNext = null; + pPolygon->pLast->pNext = pNewVertex; + pPolygon->pLast = pNewVertex; + pPolygon->n++; + } + + return true; +} + + +void +_CanvasLine::__GetBrushEndPoint(float ox, float oy, int w, int* pLeftX, int* pLeftY, int* pRightX, int* pRightY) const +{ + float wl; + float wr; + + if (w % 2 == 1) + { + wl = wr = w / 2.f - 0.001f; + } + else + { + wl = wr = (w + 1) / 2.f - 0.001f; + wr -= 1.f; + } + + // if (oy == 0.0f && (ox == 1.0f || ox == -1.0f)) // Improve a line-width problem. + if (_IsEqual(oy, 0.0f) && (_IsEqual(ox, 1.0f) || _IsEqual(ox, -1.0f))) + { + wr += 1.0f; //!! + } + + *pLeftX = (int) (wl * oy); + *pLeftY = (int) (-wl * ox); + + *pRightX = (int) (-wr * oy); + *pRightY = (int) (wr * ox); + + return; +} + +bool +_CanvasLine::_CreateEtAndAet(int ptCount, _GpPoint* pPoints, _GpEdgeTable* pEdgeTable, _GpEdgeTableEntry* pEdgeTableEntry, _GpEdgeTableEntry* pEteBuffer, _GpScanLineListBlock* pSllb) const +{ + _GpPoint* pTop = null; + _GpPoint* pBottom = null; + _GpPoint* pPrevPoint = null; + _GpPoint* pCurrPoint = null; + int isllb = 0; + int dx; + int dy; + int i; + + if (ptCount < 2) + { + return true; + } + + pEdgeTableEntry->pNext = null; + pEdgeTableEntry->pBack = null; + pEdgeTableEntry->pWNext = null; + pEdgeTableEntry->minor = _MIN_INT; + + pEdgeTable->scanLines.pNext = null; + pEdgeTable->maxY = _MIN_INT; + pEdgeTable->minY = _MAX_INT; + pSllb->pNext = null; + + pPrevPoint = &pPoints[ptCount - 1]; + + for (i = 0; i < ptCount; i++) + { + if (pEdgeTable->maxY < pPoints[i].y) + { + pEdgeTable->maxY = pPoints[i].y; + } + if (pEdgeTable->minY > pPoints[i].y) + { + pEdgeTable->minY = pPoints[i].y; + } + } + + while (ptCount--) + { + pCurrPoint = pPoints++; + + if (pPrevPoint->y > pCurrPoint->y) + { + pBottom = pPrevPoint; + pTop = pCurrPoint; + pEteBuffer->clockWise = false; + } + else + { + pBottom = pCurrPoint; + pTop = pPrevPoint; + pEteBuffer->clockWise = true; + } + + if (pBottom->y != pTop->y) + { + pEteBuffer->maxY = pBottom->y; + + if (pEteBuffer->maxY <= pEdgeTable->maxY) + { + pEteBuffer->maxY--; // exclude the last scan line + } + + dy = pBottom->y - pTop->y; + pEteBuffer->minor = pTop->x; + dx = pBottom->x - pTop->x; + + if (dx < 0) + { + pEteBuffer->gradient = dx / dy; + pEteBuffer->gradient1 = pEteBuffer->gradient - 1; + pEteBuffer->inc1 = -2 * dx + 2 * dy * pEteBuffer->gradient1; + pEteBuffer->inc2 = -2 * dx + 2 * dy * pEteBuffer->gradient; + pEteBuffer->direction = 2 * pEteBuffer->gradient * dy - 2 * dx - dy; + } + else + { + pEteBuffer->gradient = dx / dy; + pEteBuffer->gradient1 = pEteBuffer->gradient + 1; + pEteBuffer->inc1 = 2 * dx - 2 * dy * pEteBuffer->gradient1; + pEteBuffer->inc2 = 2 * dx - 2 * dy * pEteBuffer->gradient; + pEteBuffer->direction = -2 * pEteBuffer->gradient * dy + 2 * dx - dy; + } + + if (!__InsertEdge(pEdgeTable, pEteBuffer, pTop->y, &pSllb, &isllb)) + { + return false; + } + + pEteBuffer++; + } + + pPrevPoint = pCurrPoint; + } + + return true; +} + +void +_CanvasLine::_FreeSllb(_GpScanLineListBlock* pScanLineListBlock) const +{ + _GpScanLineListBlock* pTempSlLb = null; + + while (pScanLineListBlock != null) + { + pTempSlLb = pScanLineListBlock->pNext; + delete pScanLineListBlock; + pScanLineListBlock = pTempSlLb; + } + + return; +} + +void +_CanvasLine::_LoadAet(_GpEdgeTableEntry* pAet, _GpEdgeTableEntry* pEte) const +{ + _GpEdgeTableEntry* pPrevAet = null; + _GpEdgeTableEntry* pTempEte = null; + + pPrevAet = pAet; + pAet = pAet->pNext; + + while (pEte) + { + while ((pAet) && (pAet->minor < pEte->minor)) + { + pPrevAet = pAet; + pAet = pAet->pNext; + } + + pTempEte = pEte->pNext; + pEte->pNext = pAet; + + if (pAet) + { + pAet->pBack = pEte; + } + + pEte->pBack = pPrevAet; + pPrevAet->pNext = pEte; + pPrevAet = pEte; + pEte = pTempEte; + } + + return; +} + +bool +_CanvasLine::_InsertionSort(_GpEdgeTableEntry* pAet) const +{ + _GpEdgeTableEntry* pEteChase = null; + _GpEdgeTableEntry* pEteInsert = null; + _GpEdgeTableEntry* pEteChaseBack = null; + bool isChanged = false; + + pAet = pAet->pNext; + + while (pAet) + { + pEteInsert = pAet; + pEteChase = pAet; + + while (pEteChase->pBack->minor > pAet->minor) + { + pEteChase = pEteChase->pBack; + } + + pAet = pAet->pNext; + + if (pEteChase != pEteInsert) + { + pEteChaseBack = pEteChase->pBack; + pEteInsert->pBack->pNext = pAet; + + if (pAet) + { + pAet->pBack = pEteInsert->pBack; + } + + pEteInsert->pNext = pEteChase; + pEteChase->pBack->pNext = pEteInsert; + pEteChase->pBack = pEteInsert; + pEteInsert->pBack = pEteChaseBack; + isChanged = true; + } + } + + return isChanged; +} + +void +_CanvasLine::_ComputeWaet(_GpEdgeTableEntry* pAet) const +{ + _GpEdgeTableEntry* pWete = null; + bool inside = true; + int isInside = 0; + + pAet->pWNext = null; + pWete = pAet; + pAet = pAet->pNext; + + while (pAet) + { + if (pAet->clockWise) + { + isInside++; + } + else + { + isInside--; + } + + if ((!inside && isInside == 0) || (inside && isInside)) + { + pWete->pWNext = pAet; + pWete = pAet; + inside = !inside; + } + + pAet = pAet->pNext; + } + + pWete->pWNext = null; + + return; +} + +bool +_CanvasLine::__InsertEdge(_GpEdgeTable* pEt, _GpEdgeTableEntry* pEte, int scanLine, _GpScanLineListBlock** pSllb, int* pIsllb) const +{ + _GpEdgeTableEntry* pStart = null; + _GpEdgeTableEntry* pPrev = null; + _GpScanLineList* pSll = null; + _GpScanLineList* pPresSll = null; + _GpScanLineListBlock* pTmpSllb = null; + + // Check parameter + if (pEt == null || pEte == null || pSllb == null || pIsllb == null) + { + return false; + } + + pPresSll = &pEt->scanLines; + pSll = pPresSll->pNext; + + while (pSll != null && (pSll->scanLine < scanLine)) + { + pPresSll = pSll; + pSll = pSll->pNext; + } + + if (pSll == null || pSll->scanLine > scanLine) + { + if (*pIsllb >= _MAX_SLL_BLOCK) + { + pTmpSllb = new (std::nothrow) _GpScanLineListBlock; + + if (pTmpSllb == null) + { + SysLog(NID_GRP, "__InsertEdge : pTmpSllb allcation is failed!\n"); + // SysSetLastError(WMERR_OUT_OF_MEMORY); + return false; + } + + (*pSllb)->pNext = pTmpSllb; + pTmpSllb->pNext = null; + *pSllb = pTmpSllb; + *pIsllb = 0; + } + + pSll = &((*pSllb)->scanLineList[(*pIsllb)]); + (*pIsllb)++; + pSll->pNext = pPresSll->pNext; + pSll->pEdgeList = null; + pPresSll->pNext = pSll; + } + + pSll->scanLine = scanLine; + + pPrev = null; + pStart = pSll->pEdgeList; + + while (pStart != null && pStart->minor < pEte->minor) + { + pPrev = pStart; + pStart = pStart->pNext; + } + + pEte->pNext = pStart; + + if (pPrev != null) + { + pPrev->pNext = pEte; + } + else + { + pSll->pEdgeList = pEte; + } + + return true; +} + +bool +_CanvasLine::_PatchJoint(_GpPolygon* pPolygon, int x, int y, float ox1, float oy1, float ox2, float oy2) const +{ + float cross; + int plx1; + int ply1; + int prx1; + int pry1; + + int plx2; + int ply2; + int prx2; + int pry2; + int degree0; + int degree1; + + cross = ox1 * oy2 - oy1 * ox2; + + if ((-0.0001f < cross) && (cross < 0.0001f)) + { + return true; + } + + __GetBrushEndPoint(ox1, oy1, __lineWidth, &plx1, &ply1, &prx1, &pry1); + __GetBrushEndPoint(ox2, oy2, __lineWidth, &plx2, &ply2, &prx2, &pry2); + + if (cross < 0) + { + degree0 = (int) (atan2((float) -pry1, (float) prx1) * (180 / _PI)); + degree1 = (int) (atan2((float) -pry2, (float) prx2) * (180 / _PI)); + } + else + { + degree0 = (int) (atan2((float) -ply2, (float) plx2) * (180 / _PI)); + degree1 = (int) (atan2((float) -ply1, (float) plx1) * (180 / _PI)); + } + + while (degree0 < 0) + { + degree0 += 360; + } + + while (degree0 > 360) + { + degree0 -= 360; + } + + while (degree1 > 360) + { + degree1 -= 360; + } + + while (degree1 < degree0) + { + degree1 += 360; + } + + if (cross < 0) + { + __PatchArc(pPolygon, (float) x, (float) y, (float) (__lineWidth / 2 - 1), (float) (__lineWidth / 2 - 1), degree0, degree1, 1); + } + else + { + __PatchArc(pPolygon, (float) x, (float) y, (float) (__lineWidth / 2 - 1), (float) (__lineWidth / 2 - 1), degree0, degree1, 0); + } + + return true; +} + +bool +_CanvasLine::_PatchRoundCap(_GpPolygon* pPolygon, int x, int y, float ox, float oy, bool isStart) const +{ + int degree0; + int degree1; + int d; + float rad; + float fx; + float fy; + + d = (int) (atan2(-oy, ox) * (180 / _PI)); + + if (isStart) + { + degree0 = d + 90; + degree1 = d - 90 + 360; + } + else + { + degree0 = d - 90; + degree1 = d + 90; + } + + rad = __lineWidth / 2.f - 0.5f; + + if (__lineWidth % 2 == 0) + { + fx = x + oy / 2; + fy = y - ox / 2; + } + else + { + fx = (float) x; + fy = (float) y; + } + + return __PatchArc(pPolygon, fx, fy, rad, rad, degree0, degree1, 1); +} + +bool +_CanvasLine::__PatchArc(_GpPolygon* pPolygon, float x, float y, float w, float h, int degree0, int degree1, int pos) const +{ + int n; + int i; + _GpFloatPoint* pEllipsePoint = null; + + if ((degree0 % 360 == degree1 % 360) && (degree1 - degree0 != 360)) + { + return true; + } + + // if (w == 0.f || h == 0.f) + if (_IsEqual(w, 0.0f) || _IsEqual(h, 0.0f)) + { + return true; + } + + n = _MakeEllipseArcPointArray(&pEllipsePoint, null, x, y, w, h, degree0, degree1, 0); + + if (pEllipsePoint == null) + { + return false; + } + + if (n < 2) + { + delete[] pEllipsePoint; + + return false; + } + + if (pos == 0) + { + for (i = n - 1; i >= 0; i--) + { + if (!_AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + 0.5f), (int) (pEllipsePoint[i].fy), 0)) + { + delete[] pEllipsePoint; + + return false; + } + } + } + else + { + for (i = 0; i < n; i++) + { + if (!_AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + 0.5f), (int) (pEllipsePoint[i].fy), 1)) + { + delete[] pEllipsePoint; + + return false; + } + } + } + + delete[] pEllipsePoint; + + return true; +} + +int +_CanvasLine::_MakeEllipseArcPointArray(_GpFloatPoint** pPoint, _GpFloatPoint** pNorm, float x, float y, float w, float h, int a1, int a2, int rot) const +{ + const float one_deg = 0.01745329251994329576f; + + int i; + int pointCount = 0; + float degree1; + float degree2; + float r; + float r1; + float r2; + float t1x; + float t1y; + float len; + float sinR; + float cosR; + float t2x; + float t2y; + bool isEnd; + + rot = ((-rot) % 360 + 360) % 360; + + degree1 = (float) a1; + degree2 = (float) a2; + + r1 = (float) atan2(w * sin(_GP_DEGREE2RADIAN(degree1)), h * cos(_GP_DEGREE2RADIAN(degree1))); + r2 = (float) atan2(w * sin(_GP_DEGREE2RADIAN(degree2)), h * cos(_GP_DEGREE2RADIAN(degree2))); + + while (r1 < 0) + { + r1 = r1 + 2 * _PI; + } + + while (r2 - 0.001f <= r1) + { + r2 = r2 + 2 * _PI; + } + + pointCount = (int) ((r2 - r1) / one_deg) + 2; + + *pPoint = new (std::nothrow) _GpFloatPoint[pointCount]; + + if (!*pPoint) + { + return 0; + } + + if (pNorm != null) + { + *pNorm = new (std::nothrow) _GpFloatPoint[pointCount]; + + if (!*pNorm) + { + delete[] *pPoint; + + return 0; + } + } + + for (r = r1, i = 0, isEnd = false; i < pointCount; r += one_deg, i++) + { + if (r > r2) + { + r = r2; + isEnd = true; + } + + sinR = (float) sin(r); + cosR = (float) cos(r); + + t1x = w * cosR; + t1y = -h * sinR; + + _Rotate2DPoint(t1x, t1y, rot, &t2x, &t2y); + + (*pPoint)[i].fx = x + t2x; + (*pPoint)[i].fy = y + t2y; + + if (pNorm != null) + { + t1x = h * cosR; + t1y = -w * sinR; + + len = (float) sqrt(t1x * t1x + t1y * t1y); + + if (_IsEqual(len, 0.0f)) + { + i--; + pointCount--; + continue; + } + + t1x = t1x / len; + t1y = t1y / len; + + _Rotate2DPoint(t1x, t1y, rot, &t2x, &t2y); + + (*pNorm)[i].fx = t2x; + (*pNorm)[i].fy = t2y; + } + + if (isEnd) + { + pointCount = i + 1; + break; + } + } + + return pointCount; +} + +void +_CanvasLine::_Rotate2DPoint(float x, float y, long rot, float* pRx, float* pRy) const +{ + float s; + float c; + + s = (float) sin(_GP_DEGREE2RADIAN(float(rot))); + c = (float) cos(_GP_DEGREE2RADIAN(float(rot))); + + *pRx = x * c - y * s; + *pRy = y * c + x * s; + + return; +} + +_GpResult +_CanvasLine::__DrawHorizontalLineWithOpacity32(int startX, int endX, int y, const _GpBufferInfo& bufInfo) +{ + register unsigned char dstA; + register unsigned char dstR; + register unsigned char dstG; + register unsigned char dstB; + + int frmbufP = bufInfo.pixelPerLine; + + // doesn't need to check the validity of bound.. maybe it's duplicate... + //if (startX > endX) + // return GP_RESULT_FAIL; + + //if (startX < 0 || startX >= frmbufW) + // return GP_RESULT_OUTOFBOUNDS; + + //if (endX < 0 || endX >= frmbufW) + // return GP_RESULT_OUTOFBOUNDS; + + //if (y < 0 || y >= frmbufH) + // return GP_RESULT_OUTOFBOUNDS; + + //if (frmbufW < 1 || frmbufH < 1) + // return GP_RESULT_FAIL;*/ + + unsigned long* pFrmbuf32 = (unsigned long*) bufInfo.pPixels; + + unsigned char srcA = (unsigned char) ((bufInfo.color32 & 0xFF000000) >> 24); + unsigned char srcR = (unsigned char) ((bufInfo.color32 & 0x00FF0000) >> 16); + unsigned char srcG = (unsigned char) ((bufInfo.color32 & 0x0000FF00) >> 8); + unsigned char srcB = (unsigned char) (bufInfo.color32 & 0x000000FF); + unsigned char oneMinusSrcA = 255 - srcA; + + { + register unsigned long* pOffset32 = (pFrmbuf32 + frmbufP * y + startX); + + for (int i = 0; i < endX - startX + 1; i++) + { + dstR = (unsigned char)(*pOffset32 >> 16); + dstG = (unsigned char)(*pOffset32 >> 8); + dstB = (unsigned char)(*pOffset32); + + dstR = (unsigned char) ((dstR * oneMinusSrcA + srcR * srcA + 255) >> 8); + dstG = (unsigned char) ((dstG * oneMinusSrcA + srcG * srcA + 255) >> 8); + dstB = (unsigned char) ((dstB * oneMinusSrcA + srcB * srcA + 255) >> 8); + dstA = (((unsigned char)(*pOffset32 >> 24) * oneMinusSrcA + 255) >> 8) + srcA; + + *pOffset32++ = (unsigned long)(((unsigned long)dstA << 24) | ((unsigned long)dstR << 16) | ((unsigned long)dstG << 8) | (unsigned long)(dstB)); + } + } + + return GP_RESULT_SUCCESS; +} + +bool +_CanvasLine::_IsInClipRect(int rectX, int rectY, int rectW, int rectH, const _GpBufferInfo& bufInfo) const +{ + if (rectW <= 0 || rectH <= 0) + { + return false; + } + + if (bufInfo.isClipBoundsSet) + { + if (rectX >= bufInfo.clipBounds.x && (rectX + rectW) <= (bufInfo.clipBounds.x + bufInfo.clipBounds.width) && + rectY >= bufInfo.clipBounds.y && (rectY + rectH) <= (bufInfo.clipBounds.y + bufInfo.clipBounds.height)) + { + return true; + } + } + else + { + if (rectX >= 0 && (rectX + rectW) <= bufInfo.width && rectY >= 0 && (rectY + rectH) <= bufInfo.height) + { + return true; + } + } + + return false; +} + +bool +_CanvasLine::_SetNotClipFunction(bool isWidelineSet) +{ + pFuncSetPixel = &_CanvasLine::_DrawPixel; + + if (__lineWidth == 1 || !isWidelineSet) + { + pFuncHorizontalLine = &_CanvasLine::_DrawUnitLineHorizontal; + pFuncVerticalLine = &_CanvasLine::_DrawUnitLineVertical; + } + else if (__lineWidth > 1) + { + pFuncHorizontalLine = &_CanvasLine::_DrawWideLineHorizontal; + pFuncVerticalLine = &_CanvasLine::_DrawWideLineVertical; + } + + return true; +} + +bool +_CanvasLine::_SetClipFunction(bool isWidelineSet) const +{ + pFuncSetPixel = &_CanvasLine::_DrawPixelWithClipping; + + if (__lineWidth == 1 || !isWidelineSet) + { + pFuncHorizontalLine = &_CanvasLine::_DrawUnitLineHorizontalWithClipping; + pFuncVerticalLine = &_CanvasLine::_DrawUnitLineVerticalWithClipping; + } + else if (__lineWidth > 1) + { + pFuncHorizontalLine = &_CanvasLine::_DrawUnitLineHorizontalWithClipping; + pFuncVerticalLine = &_CanvasLine::_DrawUnitLineVerticalWithClipping; + } + + return true; +} + +bool +_CanvasLine::_DrawPolyLine(int ptCount, _GpPoint* pPoints, bool isConnected, const _GpBufferInfo& bufInfo) +{ + int i = 0; + int j; + bool ret = false; + + ptCount = __CheckDupVertexForPolygon(ptCount, pPoints, isConnected); + + if (__lineWidth < 2 || (bufInfo.color32 & 0xFF000000) == 0xFF000000) + { + while (++i < ptCount) + { + j = i - 1; + + if (DrawLine(pPoints[j], pPoints[i], bufInfo) == E_SYSTEM) + { + SysLog(NID_GRP, "_DrawPolyLine: DrawLine is failed -1!\n"); + + return false; + } + } + + if (isConnected) + { + if (DrawLine(pPoints[i-1], pPoints[0], bufInfo) == E_SYSTEM) + { + SysLog(NID_GRP, "_DrawPolyLine: DrawLine is failed -2!\n"); + + return false; + } + } + + ret = true; + } + else + { + ret = __DrawThickContinuousPolyline(ptCount, pPoints, isConnected, bufInfo); + } + + return ret; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_CanvasGpPrimitive.h b/src/graphics/FGrp_CanvasGpPrimitive.h new file mode 100644 index 0000000..a1f1b01 --- /dev/null +++ b/src/graphics/FGrp_CanvasGpPrimitive.h @@ -0,0 +1,492 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasGpPrimitive.h + * @brief This is the header file for 2D Primitive classes. + * + */ + +#ifndef _FGRP_INTERNAL_CANVAS_GP_PRIMITIVE_H_ +#define _FGRP_INTERNAL_CANVAS_GP_PRIMITIVE_H_ + + +#include +#include + + +namespace Tizen { namespace Graphics +{ + +namespace // unnamed +{ + +const int _MAX_SLL_BLOCK = 25; +const int _MAX_INT = 0x7fffffff; +const int _MIN_INT = (-_MAX_INT - 1); +const float _PI = (3.14159265358979323846f); + +template +inline T GP_ABS(T value) +{ + return (value < 0) ? -value : value; +} + +template +inline void GP_SWAP(T& a, T& b) +{ + T tmp = a; + a = b; + b = tmp; +} + +template +inline T GP_MIN(T a, T b) +{ + return (a < b) ? a : b; +} + +template +inline T GP_MAX(T a, T b) +{ + return (a < b) ? b : a; +} + +inline int _GP_RADIAN2DEGREE(float radian) +{ + return int(radian * 180.0f / _PI + 0.5f); +} + +inline float _GP_DEGREE2RADIAN(float degree) +{ + return degree * _PI / 180.0f; +} + +} + +struct _GpPoint +{ + int x; + int y; +}; + +struct _GpRect +{ + int x; + int y; + int width; + int height; + + _GpRect() + : x(0) + , y(0) + , width(0) + , height(0) + { + } + + ~_GpRect() + { + } + + bool SetBounds(int rcX, int rcY, int rcW, int rcH) + { + x = rcX; + y = rcY; + width = rcW; + height = rcH; + + return true; + } +}; + +struct _GpVertex +{ + _GpPoint point; + _GpVertex* pNext; + + _GpVertex() + { + point.x = 0; + point.y = 0; + pNext = null; + } + + ~_GpVertex() + { + // if (pNext) + // delete next; + } + +}; + +struct _GpPolygon +{ + int n; + _GpVertex* pFirst; + _GpVertex* pLast; + + _GpPolygon() + : n(0) + , pFirst(null) + , pLast(null) + { + } + + ~_GpPolygon() + { + } +}; + +struct _GpEdgeTableEntry +{ + int maxY; + int minor; + int direction; + int gradient; + int gradient1; + int inc1; + int inc2; + _GpEdgeTableEntry* pNext; + _GpEdgeTableEntry* pBack; + _GpEdgeTableEntry* pWNext; + bool clockWise; +}; + +struct _GpScanLineList +{ + int scanLine; + _GpEdgeTableEntry* pEdgeList; + _GpScanLineList* pNext; +}; + +struct _GpEdgeTable +{ + int maxY; + int minY; + _GpScanLineList scanLines; +}; + +struct _GpScanLineListBlock +{ + _GpScanLineList scanLineList[_MAX_SLL_BLOCK]; + _GpScanLineListBlock* pNext; +}; + +struct _GpFloatPoint +{ + float fx; + float fy; +}; + +struct _GpBufferInfo +{ + int width; + int height; + int bitsPerPixel; + int pixelPerLine; + void* pPixels; + unsigned long color32; + unsigned short color16; + bool isClipBoundsSet; + _GpRect clipBounds; + + _GpBufferInfo() + : width(0) + , height(0) + , bitsPerPixel(0) + , pixelPerLine(0) + , pPixels(null) + , color32(0) + , color16(0) + , isClipBoundsSet(false) + { + } + +}; + +enum _GpResult +{ + GP_RESULT_SUCCESS = 0x00000001, + GP_RESULT_OUTOFBOUNDS = 0x00000002, + GP_RESULT_FAIL = 0x00000004 +}; + +inline bool +_IsEqual(float f1, float f2) +{ + return (((f1 > f2) ? f1 - f2 : f2 - f1) < 0.00001f); // epsilon is assumed to be 0.0001, not 1.192092896e-07f +} + +class _CanvasLine +{ +public: + // A Constructor + _CanvasLine(void) + : pFuncSetPixel(null) + , pFuncHorizontalLine(null) + , pFuncVerticalLine(null) + , __lineWidth(1) + { + _SetClipFunction(true); + } + // A Destructor + virtual ~_CanvasLine(void) { } + + // Sets the line width. + bool SetLineWidth(int lineWidth); + // Gets the line width. + int GetLineWidth(void) const; + // draws a line. + result DrawLine(const _GpPoint& startPt, const _GpPoint& endPt, const _GpBufferInfo& bufInfo); + // draws a PolyLine. + result DrawPolyLine(int pointCount, _GpPoint* pPoints, const _GpBufferInfo& bufInfo); + // draws a Polygon. + result DrawPolygon(int pointCount, _GpPoint* pPoints, const _GpBufferInfo& bufInfo); + +protected: + _GpResult _DrawUnitLineVertical(int x, int startY, int endY, const _GpBufferInfo& bufInfo); + _GpResult _DrawUnitLineHorizontal(int startX, int endX, int y, const _GpBufferInfo& bufInfo); + _GpResult _DrawWideLineVertical(int x, int startY, int endY, const _GpBufferInfo& bufInfo); + _GpResult _DrawWideLineHorizontal(int startX, int endX, int y, const _GpBufferInfo& bufInfo); + _GpResult _DrawUnitLineSlant(const _GpPoint& pt1, const _GpPoint& pt2, const _GpBufferInfo& bufInfo); + _GpResult _DrawPixel(int x, int y, const _GpBufferInfo& bufInfo); + + _GpResult _DrawUnitLineVerticalWithClipping(int x, int startY, int endY, const _GpBufferInfo& bufInfo); + _GpResult _DrawUnitLineHorizontalWithClipping(int startX, int endX, int y, const _GpBufferInfo& bufInfo); + _GpResult _DrawWideLineVerticalWithClipping(int x, int startY, int endY, const _GpBufferInfo& bufInfo); + _GpResult _DrawWideLineHorizontalWithClipping(int startX, int endX, int y, const _GpBufferInfo& bufInfo); + _GpResult _DrawPixelWithClipping(int x, int y, const _GpBufferInfo& bufInfo); + + bool _DrawPolyLine(int pointCount, _GpPoint* pPoints, bool isConnected, const _GpBufferInfo& bufInfo); + void _FreePolygon(_GpPolygon* pPolygon) const; + bool _FillPolygon(int pointCount, _GpPoint* pPoints, bool isEvenOdd, const _GpBufferInfo& bufInfo); + bool _GetOrientationUnitVector(_GpPoint& startPt, _GpPoint& endPt, float* pOx, float* pOy) const; + bool _PatchThickContinuousLine(_GpPolygon* pPolygon, _GpPoint& pt1, _GpPoint& pt2, float ox1, float oy1, float ox2, float oy2) const; + bool _AddPolygonVertex(_GpPolygon* pPolygon, int x, int y, int pos) const; + + bool _CreateEtAndAet(int pointCount, _GpPoint* pPoints, _GpEdgeTable* pEdgeTable, _GpEdgeTableEntry* pEdgeTableEntry, _GpEdgeTableEntry* pEteBuffer, _GpScanLineListBlock* pSllb) const; + void _FreeSllb(_GpScanLineListBlock* pScanLineListBlock) const; + void _LoadAet(_GpEdgeTableEntry* pAet, _GpEdgeTableEntry* pEte) const; + bool _InsertionSort(_GpEdgeTableEntry* pAet) const; + void _ComputeWaet(_GpEdgeTableEntry* pAet) const; + + bool _PatchJoint(_GpPolygon* pPolygon, int x, int y, float ox1, float oy1, float ox2, float oy2) const; + bool _PatchRoundCap(_GpPolygon* pPolygon, int x, int y, float ox, float oy, bool isStart) const; + + int _MakeEllipseArcPointArray(_GpFloatPoint** pPoint, _GpFloatPoint** pNorm, float x, float y, float w, float h, int a1, int a2, int rot) const; + + void _Rotate2DPoint(float x, float y, long rot, float* pRx, float* pRy) const; + + bool _IsInClipRect(int rectX, int rectY, int rectW, int rectH, const _GpBufferInfo& bufInfo) const; + bool _SetNotClipFunction(bool isWidelineSet); + bool _SetClipFunction(bool isWidelineSet) const; + +private: + bool __DrawWideLine(const _GpPoint& startPt, const _GpPoint& endPt, const _GpBufferInfo& bufInfo); + bool __DrawWideLineWithOpacity32(const _GpPoint& startPt, const _GpPoint& endPt, const _GpBufferInfo& bufInfo); + bool __DrawThickContinuousPolyline(int listCount, _GpPoint* pPoints, bool isConnected, const _GpBufferInfo& bufInfo); + _GpResult __DrawHorizontalLineWithOpacity32(int startX, int endX, int y, const _GpBufferInfo& bufInfo); + + int __CheckDupVertexForPolygon(int pointCount, _GpPoint* pPoints, bool isConnected) const; + void __GetBrushEndPoint(float ox, float oy, int w, int* plx, int* ply, int* prx, int* pry) const; + bool __InsertEdge(_GpEdgeTable* pEdgeTable, _GpEdgeTableEntry* pEdgeTableEntry, int scanLine, _GpScanLineListBlock** ppSllb, int* pIsLineListBlock) const; + + bool __PatchArc(_GpPolygon* pPolygon, float x, float y, float w, float h, int d0, int d1, int pos) const; + +public: + typedef _GpResult (_CanvasLine::* DrawPixelFunc)(int x, int y, const _GpBufferInfo& bufInfo); + typedef _GpResult (_CanvasLine::* DrawHorizontalLine)(int startX, int endX, int y, const _GpBufferInfo& bufInfo); + typedef _GpResult (_CanvasLine::* DrawVerticalLine)(int x, int startY, int endY, const _GpBufferInfo& bufInfo); + + mutable DrawPixelFunc pFuncSetPixel; + mutable DrawHorizontalLine pFuncHorizontalLine; + mutable DrawVerticalLine pFuncVerticalLine; + +private: + int __lineWidth; + + friend class _CanvasTriangle; + friend class _CanvasArc; + friend class _CanvasEllipse; + friend class _CanvasFillPolygon; + friend class _CanvasRoundRect; +}; + + +class _CanvasFillPolygon +{ +public: + // A Constructor + _CanvasFillPolygon(void) + { + __lineWidth = 1; + } + + // A Destructor + virtual ~_CanvasFillPolygon(void) { } + + // Sets the line width + bool SetLineWidth(int lineWidth); + // Gets the line width. + int GetLineWidth(void) const; + // draws the filled polygon. + result FillPolygon(int pointCount, _GpPoint* pPoints, const _GpBufferInfo& bufInfo); + +private: + int __lineWidth; + +}; + + +class _CanvasEllipse +{ +public: + // A Constructor + _CanvasEllipse(void) + { + __lineWidth = 1; + } + // A Destructor + virtual ~_CanvasEllipse(void) { } + // Sets the line width + bool SetLineWidth(int lineWidth); + // Gets the line width. + int GetLineWidth(void) const; + // Draws a ellipse. + result DrawEllipse(int rectX, int rectY, int rectW, int rectH, const _GpBufferInfo& bufInfo) const; +// bool __DrawEllipseWithWidth(int rectX, int rectY, int rectW, int rectH, _GpBufferInfo& bufInfo); + // Draws the filled ellipse. + result FillElliepse(int rectX, int rectY, int rectW, int rectH, const _GpBufferInfo& bufInfo) const; + +private: + bool __DrawEllipseWithWidth(int rectX, int rectY, int rectW, int rectH, const _GpBufferInfo& bufInfo) const; + +private: + int __lineWidth; + +}; + + +class _CanvasArc +{ +public: + enum GpArcDiffResult + { + DIFF_RESULT_EQUAL = 0, + DIFF_RESULT_GREAT, + DIFF_RESULT_LITTLE, + }; + + struct GpArcStack + { + int left; + int right; + }; + +public: + // A Constructor + _CanvasArc(void) + { + __lineWidth = 1; + } + // A Destructor + virtual ~_CanvasArc(void) { } + // Sets the line width + bool SetLineWidth(int lineWidth); + // Gets the line width. + int GetLineWidth(void) const; + // Draws a Arc. + result DrawArc(int rectX, int rectY, int rectW, int rectH, int startAngle, int endAngle, Tizen::Graphics::ArcStyle arcType, const _GpBufferInfo& bufInfo); + + void _CalcLeftRightWidth(float* pWidthLeft, float* pWidthRight) const; + +private: + bool __GetArcVertices(int radiusX, int radiusY, int theta, int* pX, int* pY) const; + float __Sine(int degree) const; + float __Cosine(int degree) const; + bool __SaveLine(int x1, int y1, int x2, int y2, _GpPoint* pPionts, int* pPixelCount) const; + bool __FillArcWithEvenOdd(_GpPoint* pPionts, int pixelCount, bool clip, const _GpBufferInfo& bufInfo) const; + void __QuickSort(_GpPoint* pPionts, int left, int right) const; + + bool __Draw32BitArc(int rectX, int rectY, int rectW, int rectH, int d0, int d1, Tizen::Graphics::ArcStyle arcType, const _GpBufferInfo& bufInfo); + bool __DrawThickContinuousArc(int cx, int cy, int halfW, int halfH, int d0, int d1, const _GpBufferInfo& bufInfo) const; + bool __DrawThickContinuousPie(int cx, int cy, int halfW, int halfH, int d0, int d1, const _GpBufferInfo& bufInfo) const; + bool __DrawThickContinuousChord(int cx, int cy, int halfW, int halfH, int d0, int d1, const _GpBufferInfo& bufInfo) const; + +private: + int __lineWidth; +}; + + +class _CanvasTriangle +{ +public: + // A Constructor + _CanvasTriangle(void) + { + __lineWidth = 1; + } + // A Destructor + virtual ~_CanvasTriangle(void) { } + // Sets the line width + bool SetLineWidth(int lineWidth); + // Gets the line width. + int GetLineWidth(void) const; + // Draws a triangle. + result DrawTriangle(const _GpPoint& pt1, const _GpPoint& pt2, const _GpPoint& pt3, const _GpBufferInfo& bufInfo); + // Draws the filled triangle. + result FillTriangle(int vertexX1, int vertexY1, int vertexX2, int vertexY2, int vertexX3, int vertexY3, const _GpBufferInfo& bufInfo) const; + +private: + bool __FillTriangleEx(int x1, int y1, int x2, int y2, int x3, int y3, const _GpBufferInfo& bufInfo) const; + +private: + int __lineWidth; +}; + + +class _CanvasRoundRect +{ +public: + // A Constructor + _CanvasRoundRect(void) + { + __lineWidth = 1; + } + // A Destructor + virtual ~_CanvasRoundRect(void) { } + // Sets the line width + bool SetLineWidth(int lineWidth); + // Gets the line width. + int GetLineWidth(void) const; + // Draws a roundRect. + result DrawRoundRect(int rectX, int rectY, int rectW, int rectH, int radiusX, int radiusY, const _GpBufferInfo& bufInfo); + // Draws the roundRect. + result FillRoundRectangle(int rectX, int rectY, int rectW, int rectH, int radiusX, int radiusY, const _GpBufferInfo& bufInfo) const; + +private: + bool __Draw32BitsRoundRect(int rectX, int rectY, int rectW, int rectH, int radiusX, int radiusY, const _GpBufferInfo& bufInfo); + int __MakeEllipseArcPointArrayForRoundRectN(_GpFloatPoint** pPoint, _GpFloatPoint** pNorm, float x, float y, float w, float h, int a1, int a2, int rot) const; + +private: + int __lineWidth; +}; + +}} // Tizen::Graphics + +#endif //_FGRP_INTERNAL_CANVAS_GP_PRIMITIVE_H_ diff --git a/src/graphics/FGrp_CanvasGpRoundRect.cpp b/src/graphics/FGrp_CanvasGpRoundRect.cpp new file mode 100644 index 0000000..1d5a08a --- /dev/null +++ b/src/graphics/FGrp_CanvasGpRoundRect.cpp @@ -0,0 +1,1097 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasGpRoundRect.cpp + * @brief This is the implementation file for _CanvasRoundRect class. + * + */ + +#include +#include + +#include + +#include + +#include "FGrp_CanvasGpPrimitive.h" +#include "FGrp_CanvasRasterOp.h" +#include "util/FGrp_UtilType.h" +#include "util/FGrp_UtilTemplate.h" + + +using namespace Tizen::Graphics; + +typedef unsigned long SystemPixel; + +namespace Tizen { namespace Graphics +{ + +void _FillRectangleWithClip32(_Util::ScratchPad* pScratchPad, SystemPixel color, const _Util::Rectangle& rect, const _Util::Rectangle& clip); + +}} // Tizen::Graphics + + +namespace Tizen { namespace Graphics +{ + +bool +_CanvasRoundRect::SetLineWidth(int lineWidth) +{ + __lineWidth = lineWidth; + return true; +} + +int +_CanvasRoundRect::GetLineWidth(void) const +{ + return __lineWidth; +} + +result +_CanvasRoundRect::DrawRoundRect(int rectX, int rectY, int rectW, int rectH, int radiusX, int radiusY, const _GpBufferInfo& bufInfo) +{ + int endX; + int endY; + int halfW; + int halfH; + int arcW; + int arcH; + int boxW; + int boxH; + + if (rectW < 1 || rectH < 1) + { + return E_SUCCESS; + } + + if (radiusX < 0 || radiusY < 0) + { + return E_SYSTEM; + } + + halfW = rectW >> 1; + halfH = rectH >> 1; + + if (radiusX > halfW) + { + radiusX = halfW; + } + + if (radiusY > halfH) + { + radiusY = halfH; + } + + endX = rectX + rectW - 1; + endY = rectY + rectH - 1; + + // Draw + if (!radiusX || !radiusY || rectW == 1 || rectH == 1) + { + if (bufInfo.bitsPerPixel == 32) + { + _Util::ScratchPad rect((unsigned long*) bufInfo.pPixels, bufInfo.width, bufInfo.height, bufInfo.pixelPerLine); + + rect.RegisterFillRect(_RasterOp::FnFillRectAlpha32Bit); + + { + rect.FillRect(rectX, rectY, rectW, rectH, bufInfo.color32); + } + + rect.RegisterFillRect(null); + } + else + { + // To do 16 bpp + return E_SYSTEM; + } + } + else + { + // Arc info + arcW = radiusX << 1; + arcH = radiusY << 1; + if (arcW <= 0) + { + arcW = 1; + } + + if (arcH <= 0) + { + arcH = 1; + } + + // Rectangle info + boxW = rectW - arcW; + boxH = rectH - arcH; + + if (boxW > 0 || boxH > 0) + { + __Draw32BitsRoundRect(rectX, rectY, rectW, rectH, radiusX, radiusY, bufInfo); + } + else + { + _CanvasEllipse ellipse; + + ellipse.SetLineWidth(__lineWidth); + ellipse.DrawEllipse(rectX, rectY, rectW, rectH, bufInfo); + } + } + + return E_SUCCESS; +} + +result +_CanvasRoundRect::FillRoundRectangle(int rectX, int rectY, int rectW, int rectH, int radiusX, int radiusY, const _GpBufferInfo& bufInfo) const +{ + int endX; + int endY; + int halfW; + int halfH; + int arcW; + int arcH; + + if (rectW < 1 || rectH < 1) + { + return E_SUCCESS; + } + + if (radiusX < 0 || radiusY < 0) + { + return E_SYSTEM; + } + + // Exception handling for radiusX and radiusY + halfW = rectW >> 1; + halfH = rectH >> 1; + + if (radiusX > halfW) + { + radiusX = halfW; + } + + if (radiusY > halfH) + { + radiusY = halfH; + } + + endX = rectX + rectW; + endY = rectY + rectH; + + // Fill + if (!radiusX || !radiusY || rectW == 1 || rectH == 1) + { + if (bufInfo.isClipBoundsSet) + { + int x1 = rectX; + int y1 = rectY; + int x2 = x1 + rectW; + int y2 = y1 + rectH; + + x1 = (x1 >= bufInfo.clipBounds.x) ? x1 : bufInfo.clipBounds.x; + y1 = (y1 >= bufInfo.clipBounds.y) ? y1 : bufInfo.clipBounds.y; + + x2 = (x2 <= bufInfo.clipBounds.x + bufInfo.clipBounds.width) ? x2 : bufInfo.clipBounds.x + bufInfo.clipBounds.width; + y2 = (y2 <= bufInfo.clipBounds.y + bufInfo.clipBounds.height) ? y2 : bufInfo.clipBounds.y + bufInfo.clipBounds.height; + + rectX = x1; + rectY = y1; + rectW = x2 - x1; + rectH = y2 - y1; + } + + if (rectW > 0 && rectH > 0) + { + if (bufInfo.bitsPerPixel == 32) + { + _Util::ScratchPad rect((unsigned long*) bufInfo.pPixels, bufInfo.width, bufInfo.height, bufInfo.pixelPerLine); + + rect.RegisterFillRect(_RasterOp::FnFillRectAlpha32Bit); + + { + rect.FillRect(rectX, rectY, rectW, rectH, bufInfo.color32); + } + + rect.RegisterFillRect(null); + } + else + { + // To do 16 bpp + return E_SYSTEM; + } + } + } + else + { + int boxW; + int boxH; + + // Arc info + arcW = radiusX << 1; + arcH = radiusY << 1; + + if (arcW <= 0) + { + arcW = 1; + } + + if (arcH <= 0) + { + arcH = 1; + } + + // Rectangle info + boxW = rectW - arcW; + boxH = rectH - arcH; + + if (boxW > 0 || boxH > 0) + { + if (boxW <= 0) + { + boxW = 0; + //boxW = 1; + } + + if (boxH <= 0) + { + boxH = 0; + //boxH = 1; + } + + if (bufInfo.bitsPerPixel == 32) + { + _Util::ScratchPad scratchPad((unsigned long*) bufInfo.pPixels, bufInfo.width, bufInfo.height, bufInfo.pixelPerLine); + + if (!bufInfo.isClipBoundsSet) + { + scratchPad.RegisterFillRect(_RasterOp::FnFillRectAlpha32Bit); + + { + scratchPad.FillRect(rectX + radiusX, rectY, boxW, rectH, bufInfo.color32); + scratchPad.FillRect(rectX, rectY + radiusY, radiusX, boxH, bufInfo.color32); + scratchPad.FillRect(rectX + rectW - radiusX, rectY + radiusY, radiusX, boxH, bufInfo.color32); + } + + scratchPad.RegisterFillRect(null); + } + else + { + _Util::Rectangle clip = { bufInfo.clipBounds.x, bufInfo.clipBounds.y, bufInfo.clipBounds.width, bufInfo.clipBounds.height }; + _Util::Rectangle rect1 = { rectX + radiusX, rectY, boxW, rectH }; + _Util::Rectangle rect2 = { rectX, rectY + radiusY, radiusX, boxH }; + _Util::Rectangle rect3 = { rectX + rectW - radiusX, rectY + radiusY, radiusX, boxH }; + + _FillRectangleWithClip32(&scratchPad, bufInfo.color32, rect1, clip); + _FillRectangleWithClip32(&scratchPad, bufInfo.color32, rect2, clip); + _FillRectangleWithClip32(&scratchPad, bufInfo.color32, rect3, clip); + } + + _CanvasArc arc; + arc.SetLineWidth(__lineWidth); + + arc.DrawArc(rectX, rectY, arcW + 1, arcH + 1, 89, 180, ARC_STYLE_FILLED_PIE, bufInfo); + arc.DrawArc(endX - arcW, rectY, arcW + 1, arcH + 1, 0, 91, ARC_STYLE_FILLED_PIE, bufInfo); + arc.DrawArc(rectX, endY - arcH, arcW + 1, arcH + 1, 180, 271, ARC_STYLE_FILLED_PIE, bufInfo); + arc.DrawArc(endX - arcW, endY - arcH, arcW + 1, arcH + 1, 269, 360, ARC_STYLE_FILLED_PIE, bufInfo); + } + else + { + // To do 16 bpp + return E_SYSTEM; + } + } + else + { + if (bufInfo.bitsPerPixel == 32) + { + _CanvasEllipse ellipse; + ellipse.SetLineWidth(__lineWidth); + ellipse.FillElliepse(rectX, rectY, rectW, rectH, bufInfo); + } + else + { + // To do 16 bpp + return E_SYSTEM; + } + } + } + + return E_SUCCESS; +} + +bool +_CanvasRoundRect::__Draw32BitsRoundRect(int rectX, int rectY, int rectW, int rectH, int radiusX, int radiusY, const _GpBufferInfo& bufInfo) +{ + int dx; + int dy; + float rx; + float ry; + float centerX; + float centerY; + int n; + int i; + + _GpFloatPoint* pEllipsePoint = null; + _GpFloatPoint* pEpNormal = null; + _CanvasLine line; + + line.SetLineWidth(__lineWidth); + + dx = (radiusX * 2 + 1) % 2; + dy = (radiusY * 2 + 1) % 2; + + rx = (float) (radiusX - dx); + ry = (float) (radiusY - dy); + + if (dx) + { + rx += 0.5f; + } + + if (dy) + { + ry += 0.5f; + } + + if (__lineWidth < 2) + { + _GpFloatPoint* pEllipsePoint1 = null; + _GpFloatPoint* pEllipsePoint2 = null; + _GpFloatPoint* pEllipsePoint3 = null; + _GpFloatPoint* pEllipsePoint4 = null; + _GpPoint* pPoints = null; + + int totalCount; + int n1; + int n2; + int n3; + int n4; + int index = 0; + + // left up corner + centerX = (float) (rectX) + rx; + centerY = (float) (rectY) + ry; + + n1 = __MakeEllipseArcPointArrayForRoundRectN(&pEllipsePoint1, null, centerX, centerY, rx, ry, 91, 180, 0); + + if (n1 < 2) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: __MakeEllipseArcPointArrayForRoundRectN is failed - 1!\n"); + + delete[] pEllipsePoint1; + + return false; + } + + // left bottom corner + centerX = (float) (rectX) + rx; + centerY = (float) (rectY + rectH - 1) - ry; + + n2 = __MakeEllipseArcPointArrayForRoundRectN(&pEllipsePoint2, null, centerX, centerY, rx, ry, 181, 270, 0); + + if (n2 < 2) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: __MakeEllipseArcPointArrayForRoundRectN is failed - 2!\n"); + + delete[] pEllipsePoint1; + delete[] pEllipsePoint2; + + return false; + } + + // right bottom corner + centerX = (float) (rectX + rectW - 1) - rx; + centerY = (float) (rectY + rectH - 1) - ry; + + n3 = __MakeEllipseArcPointArrayForRoundRectN(&pEllipsePoint3, null, centerX, centerY, rx, ry, 271, 360, 0); + + if (n3 < 2) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: __MakeEllipseArcPointArrayForRoundRectN is failed - 3!\n"); + + delete[] pEllipsePoint1; + delete[] pEllipsePoint2; + delete[] pEllipsePoint3; + + return false; + } + + // right up corner + centerX = (float) (rectX + rectW - 1) - rx; + centerY = (float) (rectY) + ry; + + n4 = __MakeEllipseArcPointArrayForRoundRectN(&pEllipsePoint4, null, centerX, centerY, rx, ry, 1, 90, 0); + + if (n4 < 2) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: __MakeEllipseArcPointArrayForRoundRectN is failed - 4!\n"); + + delete[] pEllipsePoint1; + delete[] pEllipsePoint2; + delete[] pEllipsePoint3; + delete[] pEllipsePoint4; + + return false; + } + + if (pEllipsePoint1 == null || pEllipsePoint2 == null || pEllipsePoint3 == null || pEllipsePoint4 == null) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: pEllipsePoint is invalid\n"); + + delete[] pEllipsePoint1; + delete[] pEllipsePoint2; + delete[] pEllipsePoint3; + delete[] pEllipsePoint4; + + return false; + } + + totalCount = n1 + n2 + n3 + n4; + pPoints = new (std::nothrow) _GpPoint[totalCount]; + + if (pPoints == null) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: Memory allocation is failed!\n"); + + delete[] pEllipsePoint1; + delete[] pEllipsePoint2; + delete[] pEllipsePoint3; + delete[] pEllipsePoint4; + + return false; + } + + for (i = 0; i < n1; i++) + { + pPoints[index].x = (int) pEllipsePoint1[i].fx; + pPoints[index].y = (int) pEllipsePoint1[i].fy; + index++; + } + + for (i = 0; i < n2; i++) + { + pPoints[index].x = (int) pEllipsePoint2[i].fx; + pPoints[index].y = (int) pEllipsePoint2[i].fy; + index++; + } + + for (i = 0; i < n3; i++) + { + pPoints[index].x = (int) pEllipsePoint3[i].fx; + pPoints[index].y = (int) pEllipsePoint3[i].fy; + index++; + } + + for (i = 0; i < n4; i++) + { + pPoints[index].x = (int) pEllipsePoint4[i].fx; + pPoints[index].y = (int) pEllipsePoint4[i].fy; + index++; + } + + line._DrawPolyLine(totalCount, pPoints, true, bufInfo); + + delete[] pEllipsePoint1; + delete[] pEllipsePoint2; + delete[] pEllipsePoint3; + delete[] pEllipsePoint4; + + delete[] pPoints; + } + else + { + bool result = false; + float wl; + float wr; + float ox; + float oy; + + _GpPolygon* pPolygon = null; + _GpPoint* pTempPoints = null; + _GpVertex* pVertex = null; + Point firstPoint; + Point lastPoint; + _GpFloatPoint firstNormal; + _GpFloatPoint lastNormal; + _CanvasArc arc; + + arc.SetLineWidth(__lineWidth); + + pPolygon = new (std::nothrow) _GpPolygon; + + if (pPolygon == null) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _GpPolygon Memory allocation is failed!\n"); + + return false; + } + + arc._CalcLeftRightWidth(&wl, &wr); + + // left up corner + centerX = (float) rectX + rx; + centerY = (float) rectY + ry; + + n = __MakeEllipseArcPointArrayForRoundRectN(&pEllipsePoint, &pEpNormal, centerX, centerY, rx, ry, 91, 180, 0); + + if (n < 2 || pEllipsePoint == null || pEpNormal == null) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _GpPolygon __MakeEllipseArcPointArrayForRoundRect is failed!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + for (i = 0; i < n; i++) + { + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx - (pEpNormal[i].fx * wl)), (int) (pEllipsePoint[i].fy - (pEpNormal[i].fy * wl)), 0); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _AddPolygonVertex is failed!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + (pEpNormal[i].fx * wr)), (int) (pEllipsePoint[i].fy + (pEpNormal[i].fy * wr)), 1); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _AddPolygonVertex is failed!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + } + + firstPoint.x = (int) pEllipsePoint[0].fx; + firstPoint.y = (int) pEllipsePoint[0].fy; + firstNormal.fx = pEpNormal[0].fx; + firstNormal.fy = pEpNormal[0].fy; + + lastPoint.x = (int) pEllipsePoint[n - 1].fx; + lastPoint.y = (int) pEllipsePoint[n - 1].fy; + lastNormal.fx = pEpNormal[n - 1].fx; + lastNormal.fy = pEpNormal[n - 1].fy; + + delete[] pEllipsePoint; + pEllipsePoint = null; + + delete[] pEpNormal; + pEpNormal = null; + + // left bottom corner + centerX = (float) rectX + rx; + centerY = (float) (rectY + rectH - 1) - ry; + + n = __MakeEllipseArcPointArrayForRoundRectN(&pEllipsePoint, &pEpNormal, centerX, centerY, rx, ry, 181, 270, 0); + + if (n < 2 || pEllipsePoint == null || pEpNormal == null) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect:__MakeEllipseArcPointArrayForRoundRect is failed!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + _GpPoint pt1 = { lastPoint.x, lastPoint.y }; + _GpPoint pt2 = { (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy }; + + line._GetOrientationUnitVector(pt1, pt2, &ox, &oy); + + result = line._PatchJoint(pPolygon, lastPoint.x, lastPoint.y, lastNormal.fy, -lastNormal.fx, ox, oy); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _PatchJoint is failed - 1!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._PatchJoint(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, ox, oy, pEpNormal[0].fy, -pEpNormal[0].fx); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _PatchJoint is failed - 2!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + for (i = 0; i < n; i++) + { + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx - (pEpNormal[i].fx * wl)), (int) (pEllipsePoint[i].fy - (pEpNormal[i].fy * wl)), 0); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _AddPolygonVertex is failed - 3!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + (pEpNormal[i].fx * wr)), (int) (pEllipsePoint[i].fy + (pEpNormal[i].fy * wr)), 1); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _AddPolygonVertex is failed - 4!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + } + + lastPoint.x = (int) pEllipsePoint[n - 1].fx; + lastPoint.y = (int) pEllipsePoint[n - 1].fy; + lastNormal.fx = pEpNormal[n - 1].fx; + lastNormal.fy = pEpNormal[n - 1].fy; + + delete[] pEllipsePoint; + pEllipsePoint = null; + + delete[] pEpNormal; + pEpNormal = null; + + // right bottom corner + centerX = (float) (rectX + rectW - 1) - rx; + centerY = (float) (rectY + rectH - 1) - ry; + + n = __MakeEllipseArcPointArrayForRoundRectN(&pEllipsePoint, &pEpNormal, centerX, centerY, rx, ry, 271, 360, 0); + + if (n < 2 || pEllipsePoint == null || pEpNormal == null) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: __MakeEllipseArcPointArrayForRoundRectN is failed!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + pt1.x = lastPoint.x; + pt1.y = lastPoint.y; + pt2.x = (int) pEllipsePoint[0].fx; + pt2.y = (int) pEllipsePoint[0].fy; + + line._GetOrientationUnitVector(pt1, pt2, &ox, &oy); + + result = line._PatchJoint(pPolygon, lastPoint.x, lastPoint.y, lastNormal.fy, -lastNormal.fx, ox, oy); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _PatchJoint is failed - 3!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._PatchJoint(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, ox, oy, pEpNormal[0].fy, -pEpNormal[0].fx); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _PatchJoint is failed - 4!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + for (i = 0; i < n; i++) + { + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx - (pEpNormal[i].fx * wl)), (int) (pEllipsePoint[i].fy - (pEpNormal[i].fy * wl)), 0); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _AddPolygonVertex is failed - 5!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + (pEpNormal[i].fx * wr)), (int) (pEllipsePoint[i].fy + (pEpNormal[i].fy * wr)), 1); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _AddPolygonVertex is failed - 6!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + } + + lastPoint.x = (int) pEllipsePoint[n - 1].fx; + lastPoint.y = (int) pEllipsePoint[n - 1].fy; + lastNormal.fx = pEpNormal[n - 1].fx; + lastNormal.fy = pEpNormal[n - 1].fy; + + delete[] pEllipsePoint; + pEllipsePoint = null; + + delete[] pEpNormal; + pEpNormal = null; + + // right up corner + centerX = (float) (rectX + rectW - 1) - rx; + centerY = (float) rectY + ry; + + n = __MakeEllipseArcPointArrayForRoundRectN(&pEllipsePoint, &pEpNormal, centerX, centerY, rx, ry, 1, 90, 0); + + if (n < 2 || pEllipsePoint == null || pEpNormal == null) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: __MakeEllipseArcPointArrayForRoundRectN is failed!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + pt1.x = lastPoint.x; + pt1.y = lastPoint.y; + pt2.x = (int) pEllipsePoint[0].fx; + pt2.y = (int) pEllipsePoint[0].fy; + + line._GetOrientationUnitVector(pt1, pt2, &ox, &oy); + + result = line._PatchJoint(pPolygon, lastPoint.x, lastPoint.y, lastNormal.fy, -lastNormal.fx, ox, oy); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _PatchJoint is failed - 5!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._PatchJoint(pPolygon, (int) pEllipsePoint[0].fx, (int) pEllipsePoint[0].fy, ox, oy, pEpNormal[0].fy, -pEpNormal[0].fx); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _PatchJoint is failed - 6!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + for (i = 0; i < n; i++) + { + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx - (pEpNormal[i].fx * wl)), (int) (pEllipsePoint[i].fy - (pEpNormal[i].fy * wl)), 0); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _AddPolygonVertex is failed - 7!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + + result = line._AddPolygonVertex(pPolygon, (int) (pEllipsePoint[i].fx + (pEpNormal[i].fx * wr)), (int) (pEllipsePoint[i].fy + (pEpNormal[i].fy * wr)), 1); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _AddPolygonVertex is failed - 8!\n"); + line._FreePolygon(pPolygon); + + delete[] pEllipsePoint; + delete[] pEpNormal; + + return false; + } + } + + lastPoint.x = (int) pEllipsePoint[n - 1].fx; + lastPoint.y = (int) pEllipsePoint[n - 1].fy; + lastNormal.fx = pEpNormal[n - 1].fx; + lastNormal.fy = pEpNormal[n - 1].fy; + + delete[] pEllipsePoint; + pEllipsePoint = null; + + delete[] pEpNormal; + pEpNormal = null; + + pt1.x = lastPoint.x; + pt1.y = lastPoint.y; + pt2.x = firstPoint.x; + pt2.y = firstPoint.y; + + line._GetOrientationUnitVector(pt1, pt2, &ox, &oy); + + result = line._PatchJoint(pPolygon, lastPoint.x, lastPoint.y, lastNormal.fy, -lastNormal.fx, ox, oy); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _PatchJoint is failed - 7!\n"); + line._FreePolygon(pPolygon); + + return false; + } + + result = line._PatchJoint(pPolygon, firstPoint.x, firstPoint.y, ox, oy, firstNormal.fy, -firstNormal.fx); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _PatchJoint is failed - 8!\n"); + line._FreePolygon(pPolygon); + + return false; + } + + // Add last vertices + result = line._AddPolygonVertex(pPolygon, (int) (firstPoint.x - (firstNormal.fx * wl)), (int) (firstPoint.y - (firstNormal.fy * wl)), 0); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _AddPolygonVertex is failed - 9!\n"); + line._FreePolygon(pPolygon); + + return false; + } + + result = line._AddPolygonVertex(pPolygon, (int) (firstPoint.x + (firstNormal.fx * wr)), (int) (firstPoint.y + (firstNormal.fy * wr)), 1); + + if (!result) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: _AddPolygonVertex is failed - 10!\n"); + line._FreePolygon(pPolygon); + + return false; + } + + pTempPoints = new (std::nothrow) _GpPoint[pPolygon->n]; + + if (pTempPoints == null) + { + SysLog(NID_GRP, "__Draw32BitsRoundRect: pTempPoints Memory allocation is failed!\n"); + line._FreePolygon(pPolygon); + + return false; + } + + for (i = 0, pVertex = pPolygon->pFirst; pVertex != null; i++, pVertex = pVertex->pNext) + { + pTempPoints[i].x = pVertex->point.x; + pTempPoints[i].y = pVertex->point.y; + } + + line._FillPolygon(pPolygon->n, pTempPoints, false, bufInfo); + + line._FreePolygon(pPolygon); + + delete[] pTempPoints; + } + + return true; +} + +int +_CanvasRoundRect::__MakeEllipseArcPointArrayForRoundRectN(_GpFloatPoint** pPoint, _GpFloatPoint** pNorm, float x, float y, float w, float h, int a1, int a2, int rot) const +{ + const float one_deg = 0.01745329251994329576f; + + int i; + int ptCount; + float degree1; + float degree2; + float r; + float r1; + float r2; + float t1x; + float t1y; + float len; + float sinR; + float cosR; + float t2x; + float t2y; + float r90; + float r180; + float r270; + bool isEnd; + _CanvasLine line; + + line.SetLineWidth(__lineWidth); + + rot = ((-rot) % 360 + 360) % 360; + + degree1 = (float) a1; + degree2 = (float) a2; + + r1 = (float) atan2(w * sin(_GP_DEGREE2RADIAN(degree1)), h * cos(_GP_DEGREE2RADIAN(degree1))); + r2 = (float) atan2(w * sin(_GP_DEGREE2RADIAN(degree2)), h * cos(_GP_DEGREE2RADIAN(degree2))); + + // removed a next line, in order to draw Circle + // if (r1 == r2) + // return 0; + + while (r1 < 0) + { + r1 = r1 + 2 * _PI; + } + + while (r2 - 0.001f <= r1) + { + r2 = r2 + 2 * _PI; + } + + ptCount = (int) ((r2 - r1) / one_deg) + 2; + + *pPoint = new (std::nothrow) _GpFloatPoint[ptCount]; + + if (!*pPoint) + { + SysLog(NID_GRP, "MakeEllipseArcPointArrayForRoundRect: Memory allocation is failed -1!\n"); + + return 0; + } + + if (pNorm != null) + { + *pNorm = new (std::nothrow) _GpFloatPoint[ptCount]; + + if (!*pNorm) + { + SysLog(NID_GRP, "MakeEllipseArcPointArrayForRoundRect: Memory allocation is failed - 2!\n"); + delete[] *pPoint; + + return 0; + } + } + + r90 = _GP_DEGREE2RADIAN(90.0f); + r180 = _GP_DEGREE2RADIAN(180.0f); + r270 = _GP_DEGREE2RADIAN(270.0f); + + for (r = r1, i = 0, isEnd = false; i < ptCount; r += one_deg, i++) + { + if (r > r2) + { + r = r2; + isEnd = true; + } + + sinR = (float) sin(r); + cosR = (float) cos(r); + + t1x = w * cosR; + t1y = -h * sinR; + + line._Rotate2DPoint(t1x, t1y, rot, &t2x, &t2y); + + if (r < r90) + { + (*pPoint)[i].fx = x + t2x - 0.5f; + (*pPoint)[i].fy = y + t2y + 0.5f; + } + else if (r < r180) + { + (*pPoint)[i].fx = x + t2x + 0.5f; + (*pPoint)[i].fy = y + t2y + 0.5f; + } + else if (r < r270) + { + (*pPoint)[i].fx = x + t2x + 0.5f; + (*pPoint)[i].fy = y + t2y - 0.5f; + } + else + { + (*pPoint)[i].fx = x + t2x - 0.5f; + (*pPoint)[i].fy = y + t2y - 0.5f; + } + + if (pNorm != null) + { + t1x = h * cosR; + t1y = -w * sinR; + + len = (float) sqrt(t1x * t1x + t1y * t1y); + + if (_IsEqual(len, 0.0f)) + { + i--; + ptCount--; + continue; + } + + t1x = t1x / len; + t1y = t1y / len; + + line._Rotate2DPoint(t1x, t1y, rot, &t2x, &t2y); + + (*pNorm)[i].fx = t2x; + (*pNorm)[i].fy = t2y; + } + + if (isEnd) + { + ptCount = i + 1; + break; + } + } + + return ptCount; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_CanvasGpTriangle.cpp b/src/graphics/FGrp_CanvasGpTriangle.cpp new file mode 100644 index 0000000..968de93 --- /dev/null +++ b/src/graphics/FGrp_CanvasGpTriangle.cpp @@ -0,0 +1,242 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasGpTriangle.cpp + * @brief This is the implementation file for _CanvasTriangle class. + * + */ + +#include + +#include "FGrp_CanvasGpPrimitive.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Graphics +{ + +namespace // unnamed +{ + +const int _TRIANGLE_MULTIFIER = 8; + +} + +bool +_CanvasTriangle::SetLineWidth(int lineWidth) +{ + __lineWidth = lineWidth; + + return true; +} + +int +_CanvasTriangle::GetLineWidth(void) const +{ + return __lineWidth; +} + +result +_CanvasTriangle::DrawTriangle(const _GpPoint& point1, const _GpPoint& point2, const _GpPoint& point3, const _GpBufferInfo& bufInfo) +{ + _CanvasLine line; + bool ret = false; + _GpPoint points[3]; + + points[0] = point1; + points[1] = point2; + points[2] = point3; + + ret = line._DrawPolyLine(3, points, true, bufInfo); + + return (ret ? E_SUCCESS : E_SYSTEM); +} + +result +_CanvasTriangle::FillTriangle(int vertexX1, int vertexY1, int vertexX2, int vertexY2, int vertexX3, int vertexY3, const _GpBufferInfo& bufInfo) const +{ + int xn; + int ratio; + + if (vertexY3 < vertexY1) + { + GP_SWAP(vertexY1, vertexY3); + GP_SWAP(vertexX1, vertexX3); + } + + if (vertexY2 < vertexY1) + { + GP_SWAP(vertexY1, vertexY2); + GP_SWAP(vertexX1, vertexX2); + } + + if (vertexY3 < vertexY2) + { + GP_SWAP(vertexY2, vertexY3); + GP_SWAP(vertexX2, vertexX3); + } + + if ((vertexY2 != vertexY1) && (vertexY3 != vertexY1) && (vertexY3 != vertexY2)) + { + ratio = ((vertexY2 - vertexY1) << _TRIANGLE_MULTIFIER) / (vertexY3 - vertexY1); + xn = (((vertexX3 - vertexX1) * ratio) >> _TRIANGLE_MULTIFIER) + vertexX1; + + if (xn < vertexX2) + { + if (!__FillTriangleEx(vertexX1, vertexY1, xn, vertexY2, vertexX2, vertexY2, bufInfo)) + { + SysLog(NID_GRP, "FilledTriangle: __FilledTriangleEX() is failed!\n"); + + return E_SYSTEM; + } + if (!__FillTriangleEx(vertexX3, vertexY3, vertexX2, vertexY2 + 1, xn, vertexY2 + 1, bufInfo)) + { + SysLog(NID_GRP, "FilledTriangle: __FilledTriangleEX() is failed!\n"); + + return E_SYSTEM; + } + } + else + { + if (!__FillTriangleEx(vertexX1, vertexY1, vertexX2, vertexY2, xn, vertexY2, bufInfo)) + { + SysLog(NID_GRP, "FilledTriangle: __FilledTriangleEX() is failed!\n"); + + return E_SYSTEM; + } + if (!__FillTriangleEx(vertexX3, vertexY3, vertexX2, vertexY2 + 1, xn, vertexY2 + 1, bufInfo)) + { + SysLog(NID_GRP, "FilledTriangle: __FilledTriangleEX() is failed!\n"); + + return E_SYSTEM; + } + } + } + else if (vertexY1 == vertexY2) + { + if (vertexX1 < vertexX2) + { + if (!__FillTriangleEx(vertexX3, vertexY3, vertexX2, vertexY2, vertexX1, vertexY2, bufInfo)) + { + SysLog(NID_GRP, "FilledTriangle: __FilledTriangleEX() is failed!\n"); + + return E_SYSTEM; + } + } + else + { + if (!__FillTriangleEx(vertexX3, vertexY3, vertexX1, vertexY2, vertexX2, vertexY2, bufInfo)) + { + SysLog(NID_GRP, "FilledTriangle: __FilledTriangleEX() is failed!\n"); + + return E_SYSTEM; + } + } + } + else // if (vertexY2 == vertexY3) // Condition "vertexY2 == vertexY3" always evaluates to true + { + if (vertexX2 < vertexX3) + { + if (!__FillTriangleEx(vertexX1, vertexY1, vertexX2, vertexY2, vertexX3, vertexY2, bufInfo)) + { + SysLog(NID_GRP, "FilledTriangle: __FilledTriangleEX() is failed!\n"); + + return E_SYSTEM; + } + } + else + { + if (!__FillTriangleEx(vertexX1, vertexY1, vertexX3, vertexY2, vertexX2, vertexY2, bufInfo)) + { + SysLog(NID_GRP, "FilledTriangle: __FilledTriangleEX() is failed!\n"); + + return E_SYSTEM; + } + } + } + + return E_SUCCESS; +} + +bool +_CanvasTriangle::__FillTriangleEx(int x1, int y1, int x2, int y2, int x3, int y3, const _GpBufferInfo& bufInfo) const +{ + int dxLeft; + int dxRight; + int curLeft; + int curRight; + int height = y2 - y1; + int y; + _CanvasLine line; + + // Check height + if (height == 0) + { + return true; + } + + line.SetLineWidth(__lineWidth); + + if (x2 > x3) + { + GP_SWAP(x2, x3); + } + + dxLeft = ((x2 - x1) << _TRIANGLE_MULTIFIER) / height; + dxRight = ((x3 - x1) << _TRIANGLE_MULTIFIER) / height; + + curLeft = curRight = (x1 << _TRIANGLE_MULTIFIER); + + if (y1 < y2) + { + for (y = y1; y <= y2; y++) + { + if (line._DrawUnitLineHorizontalWithClipping(curLeft >> _TRIANGLE_MULTIFIER, curRight >> _TRIANGLE_MULTIFIER, y, bufInfo) == GP_RESULT_FAIL) + { + SysLog(NID_GRP, "__FilledTriangleEX: _DrawUnitLineHorizontal() is failed!\n"); + + return false; + } + + curLeft += dxLeft; + curRight += dxRight; + } + } + else + { + for (y = y1; y >= y2; y--) + { + if (line._DrawUnitLineHorizontalWithClipping(curLeft >> _TRIANGLE_MULTIFIER, curRight >> _TRIANGLE_MULTIFIER, y, bufInfo) == GP_RESULT_FAIL) + { + SysLog(NID_GRP, "__FilledTriangleEX: _DrawUnitLineHorizontal() is failed!\n"); + + return false; + } + + curLeft -= dxLeft; + curRight -= dxRight; + } + } + + return true; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_CanvasImpl.cpp b/src/graphics/FGrp_CanvasImpl.cpp new file mode 100644 index 0000000..4570710 --- /dev/null +++ b/src/graphics/FGrp_CanvasImpl.cpp @@ -0,0 +1,2185 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasImpl.cpp + * @brief This is the implementation file for _CanvasImpl class. + * + */ + +#include +#include + +#include + +#include + +#include "FGrp_BufferInfoImpl.h" +#include "FGrp_Callback.h" +#include "FGrp_CanvasImpl.h" +#include "FGrp_BitmapUtil.h" +#include "FGrp_Bitmap.h" +#include "FGrp_CanvasCoordHolder.h" +#include "FGrp_Canvas.h" +#include "FGrp_CanvasImplPrivate.h" +#include "FGrp_FontUtil.h" +#include "FGrp_EnrichedTextImpl.h" +#include "util/FGrp_Util.h" +#include "FGrp_TextTextObject.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + + +#define EXTRACT_CANVASEX(pVar, canvas) Tizen::Graphics::_Canvas * pVar = canvas._pNativeCanvas +#define EXTRACT_BITMAPEX(pVar, bitmap) Tizen::Graphics::_Bitmap * pVar = Tizen::Graphics::GetBitmapEx(bitmap) +#define EXTRACT_FONTEX(pVar, font) Tizen::Graphics::_Font * pVar = Tizen::Graphics::GetFontEx(font) +#define EXTRACT_SCALED_BITMAPEX(pVar, bitmap) Tizen::Graphics::_Bitmap * pVar = Tizen::Graphics::GetScaledBitmapEx(bitmap) + +#define IsSucceeded(X) (!IsFailed(X)) + +#define INSTANCE_IS_VALID (this && (this->_pNativeCanvas && this->_pNativeCanvas->IsValid())) +#define CANVAS_IS_VALID(canvas) (&canvas && (canvas._pNativeCanvas && canvas._pNativeCanvas->IsValid())) + +#define BITMAP_IS_VALID(bitmap) (&bitmap && const_cast<_BitmapImpl*>(&bitmap)->__CheckValidity()) + + +namespace // unnamed +{ + +// retrieving bounds rectangle which has (0,0,w,h). +Tizen::Graphics::Rectangle +_GetBoundsRel(const Tizen::Graphics::_CanvasImpl& canvas) +{ + Tizen::Graphics::Rectangle rect = canvas.GetBounds(); + rect.x = 0; + rect.y = 0; + + return rect; +} + +template +void +_ExpandClippingAreaForLineWidth(Tizen::Graphics::Rectangle& rtCanvas, T lineWidth) +{ + int lineWidthHalf = (lineWidth + 1) / 2; + + rtCanvas.x -= lineWidthHalf; + rtCanvas.y -= lineWidthHalf; + rtCanvas.width += lineWidthHalf * 2; + rtCanvas.height += lineWidthHalf * 2; +} + +} + +namespace Tizen { namespace Graphics { namespace _Util +{ + +template <> +inline Tizen::Graphics::Point Convert(const Tizen::Graphics::FloatPoint& point) +{ + return Tizen::Graphics::Point(int(point.x), int(point.y)); +} + +template <> +inline Tizen::Graphics::Rectangle Convert(const Tizen::Graphics::FloatRectangle& rect) +{ + return Tizen::Graphics::Rectangle(int(rect.x), int(rect.y), int(rect.width), int(rect.height)); +} + +template <> +_Util::Point* Convert*>(const Tizen::Base::Collection::IList& points) +{ + int count = points.GetCount(); + + std::unique_ptr<_Util::Point[]> pPointArray(new (std::nothrow) _Util::Point[count]); + + SysTryReturn(NID_GRP, pPointArray, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + { + for (int i = 0; i < count; i++) + { + const Tizen::Graphics::Point* pPoint = dynamic_cast (points.GetAt(i)); + + if (pPoint) + { + pPointArray[i].x = double(pPoint->x); + pPointArray[i].y = double(pPoint->y); + } + else + { + const Tizen::Graphics::FloatPoint* pFloatPoint = dynamic_cast (points.GetAt(i)); + + if (pFloatPoint) + { + pPointArray[i].x = double(pFloatPoint->x); + pPointArray[i].y = double(pFloatPoint->y); + } + else + { + return null; + } + } + } + } + + return pPointArray.release(); +} + +} // Tizen::Graphics::_Util + +}} // Tizen::Graphics + +//////////////////////////////////////////////////////////////////////////////// +// + +namespace Tizen { namespace Graphics +{ + +_CanvasImpl::_CanvasImpl(void) + : _pNativeCanvas(0) + , _pCoordHolder(0) + , _pFont(0) + , _pPriorityFont(0) + , _dashOffset(0) +{ + _pNativeCanvas = new (std::nothrow) _Canvas; + _pCoordHolder = new (std::nothrow) _CanvasCoordHolder; + + if (_pNativeCanvas == null || _pCoordHolder == null) + { + delete _pCoordHolder; + delete _pNativeCanvas; + + _pCoordHolder = null; + _pNativeCanvas = null; + } +} + +_CanvasImpl::~_CanvasImpl(void) +{ + if (_pFont) + { + delete _pFont; + _pFont = 0; + } + + delete _pCoordHolder; + delete _pNativeCanvas; +} + +result +_CanvasImpl::Construct(void) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Fails to allocate memory."); + + if (_ResUtil::NeedToConvertCoord()) + { + result r = this->_pNativeCanvas->Construct(); + + if (IsSucceeded(r)) + { + Rectangle pcRect = this->_pNativeCanvas->GetBounds(); + Rectangle vcRect = _ResUtil::ConvertToVirCoord(pcRect); + this->_pCoordHolder->Init(vcRect); + } + + return r; + } + else + { + return this->_pNativeCanvas->Construct(); + } +} + +result +_CanvasImpl::Construct(const Rectangle& vcRect) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Fails to allocate memory."); + + SysTryReturnResult(NID_GRP, vcRect.width > 0 && vcRect.height > 0, E_OUT_OF_RANGE, + "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, + vcRect.height); + + if (_ResUtil::NeedToConvertCoord()) + { + Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + + pcRect.width = (pcRect.width > 0) ? pcRect.width : 1; + pcRect.height = (pcRect.height > 0) ? pcRect.height : 1; + + result r = this->_pNativeCanvas->Construct(pcRect); + + if (IsSucceeded(r)) + { + this->_pCoordHolder->Init(vcRect); + this->_pCoordHolder->canvasSize.phyCoord.w = pcRect.width; + this->_pCoordHolder->canvasSize.phyCoord.h = pcRect.height; + } + + return r; + } + else + { + return this->_pNativeCanvas->Construct(vcRect); + } +} + +result +_CanvasImpl::Construct(Handle windowHandle, const Rectangle& vcRect) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Fails to allocate memory."); + + SysTryReturnResult(NID_GRP, vcRect.width > 0 && vcRect.height > 0, E_OUT_OF_RANGE, + "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, + vcRect.height); + + if (_ResUtil::NeedToConvertCoord()) + { + Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + + pcRect.width = (pcRect.width > 0) ? pcRect.width : 1; + pcRect.height = (pcRect.height > 0) ? pcRect.height : 1; + + result r = this->_pNativeCanvas->Construct(windowHandle, pcRect); + + if (IsSucceeded(r)) + { + this->_pCoordHolder->Init(vcRect); + this->_pCoordHolder->canvasSize.phyCoord.w = pcRect.width; + this->_pCoordHolder->canvasSize.phyCoord.h = pcRect.height; + } + + return r; + } + else + { + return this->_pNativeCanvas->Construct(windowHandle, vcRect); + } +} + +result +_CanvasImpl::Construct(const BufferInfo& bufferInfo) +{ + SysTryReturnResult(NID_GRP, this, E_OUT_OF_MEMORY, "This instance is not allocated yet."); + + SysTryReturnResult(NID_GRP, this->_pNativeCanvas, E_OUT_OF_MEMORY, "Fails to allocate memory."); + + SysTryReturnResult(NID_GRP, (bufferInfo.width > 0) && (bufferInfo.height > 0) && (bufferInfo.pitch > 0) + , E_INVALID_ARG + , "Invalid argument (BufferInfo::width = %d, BufferInfo::height = %d, BufferInfo::pitch = %d)" + , bufferInfo.width, bufferInfo.height, bufferInfo.pitch); + + SysTryReturnResult(NID_GRP, bufferInfo.bitsPerPixel > 0 + , E_INVALID_ARG + , "Invalid argument (BufferInfo::bitsPerPixel = %d)" + , bufferInfo.bitsPerPixel); + + SysTryReturnResult(NID_GRP, (bufferInfo.pixelFormat > PIXEL_FORMAT_MIN) && (bufferInfo.pixelFormat < PIXEL_FORMAT_MAX) + , E_INVALID_ARG + , "Invalid argument (BufferInfo::pixelFormat = %d)" + , bufferInfo.pixelFormat); + + SysTryReturnResult(NID_GRP, bufferInfo.bitsPerPixel == 32 + , E_UNSUPPORTED_FORMAT + , "Unsupported format (BufferInfo::bitsPerPixel = %d)" + , bufferInfo.bitsPerPixel); + + SysTryReturnResult(NID_GRP, bufferInfo.pixelFormat == PIXEL_FORMAT_ARGB8888 + , E_UNSUPPORTED_FORMAT + , "Unsupported format (BufferInfo::pixelFormat = %d)" + , bufferInfo.pixelFormat); + + if (bufferInfo.pPixels == null) + { + const _BufferInfoImpl* pBufferInfoImpl = _BufferInfoImpl::GetInstance(bufferInfo); + + if (pBufferInfoImpl) + { + Handle handle = pBufferInfoImpl->GetHandle(_BufferInfoImpl::HANDLE_TYPE_VE_SURFACE); + + if (handle != 0) // not INVALID_HANDLE + { + result r = this->Construct(handle, Rectangle(0, 0, bufferInfo.width, bufferInfo.height)); + + // OUT_OF_RANGE does not occur + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; + } + } + + SysTryReturnResult(NID_GRP, false + , E_INVALID_ARG + , "Invalid argument (BufferInfo::pPixels = null)"); + } + else + { + result r = this->_pNativeCanvas->Construct(bufferInfo); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (_ResUtil::NeedToConvertCoord()) + { + Rectangle pcRect(0, 0, bufferInfo.width, bufferInfo.height); + Rectangle vcRect = _ResUtil::ConvertToVirCoord(pcRect); + + vcRect.width = (vcRect.width > 0) ? vcRect.width : 1; + vcRect.height = (vcRect.height > 0) ? vcRect.height : 1; + + this->_pCoordHolder->Init(vcRect); + this->_pCoordHolder->canvasSize.phyCoord.w = pcRect.width; + this->_pCoordHolder->canvasSize.phyCoord.h = pcRect.height; + } + + return E_SUCCESS; + } + + return E_SYSTEM; +} + +bool +_CanvasImpl::IsConstructed(void) const +{ + return (this->_pNativeCanvas != null) && this->_pNativeCanvas->IsValid(); +} + +result +_CanvasImpl::Clear(void) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return this->_pNativeCanvas->Clear(); +} + +result +_CanvasImpl::Clear(const Rectangle& vcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE, + "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, + vcRect.height); + + if ((vcRect.width == 0) || (vcRect.height == 0)) + { + return E_SUCCESS; + } + + Rectangle rtCanvas = _GetBoundsRel(*this); + + if (rtCanvas.IsEmpty()) + { + return E_SUCCESS; + } + + result r = _Util::Validate(vcRect, rtCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + if (_ResUtil::NeedToConvertCoord()) + { + Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + + return this->_pNativeCanvas->Clear(pcRect); + } + else + { + return this->_pNativeCanvas->Clear(vcRect); + } +} + +result +_CanvasImpl::Copy(const Point& vcDestPoint, const _CanvasImpl& canvas, const Rectangle& vcSrcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(canvas), E_INVALID_ARG, "The specified source canvas is invalid."); + + Rectangle srcRectCanvas = _GetBoundsRel(canvas); + + if (srcRectCanvas.IsEmpty()) + { + return E_SUCCESS; + } + + result r = _Util::Validate(vcSrcRect, srcRectCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + // check if destRect is in this canvas. + Rectangle destRect(vcDestPoint.x, vcDestPoint.y, vcSrcRect.width, vcSrcRect.height); + Rectangle destRectCanvas = _GetBoundsRel(*this); + + if (destRectCanvas.IsEmpty()) + { + return E_SUCCESS; + } + + r = _Util::Validate(destRect, destRectCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + EXTRACT_CANVASEX(_pNativeCanvas, canvas); + + + if (_ResUtil::NeedToConvertCoord()) + { + Point pcDestPoint = _ResUtil::ConvertToPhyCoord(vcDestPoint); + Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect); + + return this->_pNativeCanvas->Copy(pcDestPoint, *_pNativeCanvas, pcSrcRect); + } + else + { + return this->_pNativeCanvas->Copy(vcDestPoint, *_pNativeCanvas, vcSrcRect); + } +} + +result +_CanvasImpl::Copy(const Rectangle& vcDestRect, const _CanvasImpl& canvas, const Rectangle& vcSrcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(canvas), E_INVALID_ARG, "The specified source canvas is invalid."); + + // check if srcRect is in source canvas. + Rectangle srcRectCanvas = _GetBoundsRel(canvas); + + if (srcRectCanvas.IsEmpty()) + { + return E_SUCCESS; + } + + result r = _Util::Validate(vcSrcRect, srcRectCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + // check if destRect is in this canvas. + Rectangle destRectCanvas = _GetBoundsRel(*this); + + if (destRectCanvas.IsEmpty()) + { + return E_SUCCESS; + } + + r = _Util::Validate(vcDestRect, destRectCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + EXTRACT_CANVASEX(_pNativeCanvas, canvas); + + if (_ResUtil::NeedToConvertCoord()) + { + Rectangle pcDestRect = _ResUtil::ConvertToPhyCoord(vcDestRect); + Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect); + + return this->_pNativeCanvas->Copy(pcDestRect, *_pNativeCanvas, pcSrcRect); + } + else + { + return this->_pNativeCanvas->Copy(vcDestRect, *_pNativeCanvas, vcSrcRect); + } +} + +result +_CanvasImpl::Copy(const Point& vcDestPoint, const _CanvasImpl& canvas, const Rectangle& vcSrcRect, BlendingMode blendingMode) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(canvas), E_INVALID_ARG, "The specified source canvas is invalid."); + + switch (blendingMode) + { + case BLENDING_MODE_CLEAR: + case BLENDING_MODE_SRC: + case BLENDING_MODE_DST: + case BLENDING_MODE_SRC_OVER: + case BLENDING_MODE_DST_OVER: + case BLENDING_MODE_SRC_IN: + case BLENDING_MODE_DST_IN: + case BLENDING_MODE_SRC_OUT: + case BLENDING_MODE_DST_OUT: + case BLENDING_MODE_SRC_ATOP: + case BLENDING_MODE_DST_ATOP: + case BLENDING_MODE_DST_XOR: + case BLENDING_MODE_ADD: + case BLENDING_MODE_SATURATE: + case BLENDING_MODE_MULTIPLY: + case BLENDING_MODE_SCREEN: + case BLENDING_MODE_OVERLAY: + case BLENDING_MODE_DARKEN: + case BLENDING_MODE_LIGHTEN: + case BLENDING_MODE_COLOR_DODGE: + case BLENDING_MODE_COLOR_BURN: + case BLENDING_MODE_HARD_LIGHT: + case BLENDING_MODE_SOFT_LIGHT: + case BLENDING_MODE_DIFFERENCE: + case BLENDING_MODE_EXCLUSION: + break; + default: + SysTryReturnResult(NID_GRP, false, E_INVALID_ARG, "The specified blending mode is invalid."); + } + + Rectangle srcRectCanvas = _GetBoundsRel(canvas); + + if (srcRectCanvas.IsEmpty()) + { + return E_SUCCESS; + } + + result r = _Util::Validate(vcSrcRect, srcRectCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + // check if destRect is in this canvas. + Rectangle destRect(vcDestPoint.x, vcDestPoint.y, vcSrcRect.width, vcSrcRect.height); + Rectangle destRectCanvas = _GetBoundsRel(*this); + + if (destRectCanvas.IsEmpty()) + { + return E_SUCCESS; + } + + r = _Util::Validate(destRect, destRectCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + EXTRACT_CANVASEX(_pNativeCanvas, canvas); + + + if (_ResUtil::NeedToConvertCoord()) + { + Point pcDestPoint = _ResUtil::ConvertToPhyCoord(vcDestPoint); + Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect); + + return this->_pNativeCanvas->Copy(pcDestPoint, *_pNativeCanvas, pcSrcRect, blendingMode); + } + else + { + return this->_pNativeCanvas->Copy(vcDestPoint, *_pNativeCanvas, vcSrcRect, blendingMode); + } +} + +result +_CanvasImpl::CopyEx(const Point& vcDestPoint, const _CanvasImpl& srcCanvas, const Rectangle& vcSrcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + if (this != &srcCanvas) + { + return this->Copy(vcDestPoint, srcCanvas, vcSrcRect); + } + + // validity check as _CanvasImpl::Copy() + SysTryReturnResult(NID_GRP, CANVAS_IS_VALID(srcCanvas), E_INVALID_ARG, "The specified source canvas is invalid."); + + Rectangle srcRectCanvas = _GetBoundsRel(srcCanvas); + + if (srcRectCanvas.IsEmpty()) + { + return E_SUCCESS; + } + + result r = _Util::Validate(vcSrcRect, srcRectCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + // check if destRect is in this canvas. + Rectangle destRect(vcDestPoint.x, vcDestPoint.y, vcSrcRect.width, vcSrcRect.height); + Rectangle destRectCanvas = _GetBoundsRel(*this); + + if (destRectCanvas.IsEmpty()) + { + return E_SUCCESS; + } + + r = _Util::Validate(destRect, destRectCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + int pixelPerLine = 0; + + { + BufferInfo bufferInfo; + + result r = this->_pNativeCanvas->Lock(bufferInfo); + + //?? log + SysTryReturn(NID_GRP, r == E_SUCCESS, r, E_SYSTEM, "[] "); + + this->_pNativeCanvas->Unlock(); + + pixelPerLine = bufferInfo.pitch / (bufferInfo.bitsPerPixel / 8); + } + + //?? Auto-scaling should be applied to vc**** parameters later + int sourDistance = vcSrcRect.y * pixelPerLine + vcSrcRect.x; + int destDistance = vcDestPoint.y * pixelPerLine + vcDestPoint.x; + + typedef result (_Canvas::* FnCopy)(const Point&, const _Canvas&, const Rectangle&); + FnCopy fnCopy = (destDistance < sourDistance) ? FnCopy(&_Canvas::Copy) : FnCopy(&_Canvas::CopyReverse); + + if (fnCopy) + { + EXTRACT_CANVASEX(_pNativeCanvas, srcCanvas); + + if (_ResUtil::NeedToConvertCoord()) + { + Point pcDestPoint = _ResUtil::ConvertToPhyCoord(vcDestPoint); + Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect); + + return (this->_pNativeCanvas->*fnCopy)(pcDestPoint, *_pNativeCanvas, pcSrcRect); + } + else + { + return (this->_pNativeCanvas->*fnCopy)(vcDestPoint, *_pNativeCanvas, vcSrcRect); + } + } + + // never!! + return E_SYSTEM; +} + +result +_CanvasImpl::DrawArc(const FloatRectangle& vcBounds, float startAngle, float endAngle, ArcStyle arcStyle) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, ARC_STYLE_MIN < arcStyle && arcStyle < ARC_STYLE_MAX, E_INVALID_ARG, "The invalid arc type(%d) is given.", arcStyle); + SysTryReturnResult(NID_GRP, &vcBounds, E_INVALID_ARG, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcBounds.width >= 0) && (vcBounds.height >= 0), E_OUT_OF_RANGE, + "The given rectangle(width:%d,height:%d) is out of range.", vcBounds.width, vcBounds.height); + + return _CanvasImplPrivate::DrawArc(this, _Util::Convert >(vcBounds), double(startAngle), double(endAngle), arcStyle); +} + +result +_CanvasImpl::DrawArc(const Rectangle& vcBounds, int startAngle, int endAngle, ArcStyle arcStyle) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, ARC_STYLE_MIN < arcStyle && arcStyle < ARC_STYLE_MAX, E_INVALID_ARG, "The invalid arc type(%d) is given.", arcStyle); + SysTryReturnResult(NID_GRP, &vcBounds, E_INVALID_ARG, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcBounds.width >= 0) && (vcBounds.height >= 0), E_OUT_OF_RANGE, + "The given rectangle(width:%d,height:%d) is out of range.", vcBounds.width, vcBounds.height); + + return _CanvasImplPrivate::DrawArc(this, _Util::Convert >(vcBounds), double(startAngle), double(endAngle), arcStyle); +} + +result +_CanvasImpl::DrawBitmap(const Rectangle& vcRect, const _BitmapImpl& bitmap) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid."); + SysTryReturnResult(NID_GRP, &vcRect, E_INVALID_ARG, "The source rectangle is invalid."); + + if (vcRect.width == bitmap.GetWidth() && vcRect.height == bitmap.GetHeight()) + { + return this->DrawBitmap(Point(vcRect.x, vcRect.y), bitmap); + } + + // check if bimap can be drew in canvas area. + Rectangle rtCanvas = _GetBoundsRel(*this); + + if (rtCanvas.IsEmpty()) + { + return E_SUCCESS; + } + + result r = _Util::Validate(vcRect, rtCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + EXTRACT_BITMAPEX(pBitmapEx, bitmap); + + if (_ResUtil::NeedToConvertCoord()) + { + Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + + return this->_pNativeCanvas->DrawBitmap(pcRect, *pBitmapEx); + } + else + { + return this->_pNativeCanvas->DrawBitmap(vcRect, *pBitmapEx); + } +} + +result +_CanvasImpl::DrawBitmap(const FloatRectangle& vcRect, const _BitmapImpl& bitmap) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return this->DrawBitmap(_Util::Convert(vcRect), bitmap); +} + +result +_CanvasImpl::DrawBitmap(const Point& vcPoint, const _BitmapImpl& bitmap) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid."); + + Rectangle rtCanvas = _GetBoundsRel(*this); + + if (rtCanvas.IsEmpty()) + { + return E_SUCCESS; + } + + result r = _Util::Validate(Rectangle(vcPoint.x, vcPoint.y, bitmap.GetWidth(), bitmap.GetHeight()), rtCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + EXTRACT_BITMAPEX(pBitmapEx, bitmap); + + if (_ResUtil::NeedToConvertCoord()) + { + Tizen::Graphics::Dimension virSize; + Tizen::Graphics::Dimension phySize; + bool lazyScaling = Tizen::Graphics::IsLazyScalingBitmap(bitmap, virSize, phySize); + + Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint); + + Rectangle vcRect(vcPoint.x, vcPoint.y, bitmap.GetWidth(), bitmap.GetHeight()); + +#if 1 // Bitmap scaling is always uniform + if (lazyScaling) + { + EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap); + + return this->_pNativeCanvas->DrawBitmap(pcPoint, *pScaledBitmapEx); + } + else + { + return this->_pNativeCanvas->DrawBitmap(pcPoint, *pBitmapEx); + } +#else + int testSize = 2 * 3 * 5 * 7; + bool isUniform = _ResUtil::ConvertToPhyCoordWidth(testSize) == ConvertToPhyCoordHeight(testSize); + + Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + + isUniform = true; + + if (lazyScaling) + { + EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap); + + if (isUniform) + { + return this->_pNativeCanvas->DrawBitmap(pcPoint, *pScaledBitmapEx); + } + else + { + return this->_pNativeCanvas->DrawBitmap(pcRect, *pScaledBitmapEx); + } + } + else + { + if (isUniform) + { + return this->_pNativeCanvas->DrawBitmap(pcPoint, *pBitmapEx); + } + else + { + return this->_pNativeCanvas->DrawBitmap(pcRect, *pBitmapEx); + } + } +#endif + } + else + { + return this->_pNativeCanvas->DrawBitmap(vcPoint, *pBitmapEx); + } +} + +result +_CanvasImpl::DrawBitmap(const FloatPoint& vcPoint, const _BitmapImpl& bitmap) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return this->DrawBitmap(_Util::Convert(vcPoint), bitmap); +} + +result +_CanvasImpl::DrawBitmap(const Rectangle& vcDestRect, const _BitmapImpl& srcBitmap, const Rectangle& vcSrcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(srcBitmap), E_INVALID_ARG, "The source bitmap is invalid."); + + SysTryReturnResult(NID_GRP, (&vcSrcRect) && (&vcDestRect), E_INVALID_ARG, "The given rectangle is invalid."); + + SysTryReturnResult(NID_GRP, (vcSrcRect.width >= 0) && (vcSrcRect.height >= 0), E_OUT_OF_RANGE, "The given source rectangle(width:%d,height:%d) is out of range.", vcSrcRect.width, vcSrcRect.height); + SysTryReturnResult(NID_GRP, (vcDestRect.width >= 0) && (vcDestRect.height >= 0), E_OUT_OF_RANGE, "The given destination rectangle(width:%d,height:%d) is out of range.", vcDestRect.width, vcDestRect.height); + + if (vcSrcRect.width == 0 || vcSrcRect.height == 0) + { + return E_SUCCESS; + } + + if (vcDestRect.width == 0 || vcDestRect.height == 0) + { + return E_SUCCESS; + } + + if ((vcSrcRect.x < 0) || (vcSrcRect.y < 0) || (vcSrcRect.x + vcSrcRect.width > srcBitmap.GetWidth()) || (vcSrcRect.y + vcSrcRect.height > srcBitmap.GetHeight())) + { + SysTryReturnResult(NID_GRP, 0, E_OUT_OF_RANGE, "The specified region of source bitmap is out of range."); + } + + // check if srcRect is in bitmap's area. + result r = _Util::Validate(vcSrcRect, Rectangle(0, 0, srcBitmap.GetWidth(), srcBitmap.GetHeight())); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + // check if destRect is in this canvas. + Rectangle rtCanvas = _GetBoundsRel(*this); + + if (rtCanvas.IsEmpty()) + { + return E_SUCCESS; + } + + r = _Util::Validate(vcDestRect, rtCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + EXTRACT_BITMAPEX(pBitmapEx, srcBitmap); + + if (_ResUtil::NeedToConvertCoord()) + { + Tizen::Graphics::Dimension virSize; + Tizen::Graphics::Dimension phySize; + bool lazyScaling = Tizen::Graphics::IsLazyScalingBitmap(srcBitmap, virSize, phySize); + + Rectangle pcDestRect = _ResUtil::ConvertToPhyCoord(vcDestRect); + + if (lazyScaling) + { + return this->_pNativeCanvas->DrawBitmap(pcDestRect, *pBitmapEx, vcSrcRect); + } + else + { + Rectangle pcSrcRect = _ResUtil::ConvertToPhyCoord(vcSrcRect); + + return this->_pNativeCanvas->DrawBitmap(pcDestRect, *pBitmapEx, pcSrcRect); + } + } + else + { + return this->_pNativeCanvas->DrawBitmap(vcDestRect, *pBitmapEx, vcSrcRect); + } +} + +result +_CanvasImpl::DrawBitmap(const FloatRectangle& vcDestRect, const _BitmapImpl& srcBitmap, const FloatRectangle& vcSrcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return this->DrawBitmap(_Util::Convert(vcDestRect), srcBitmap, _Util::Convert(vcSrcRect)); +} + +result +_CanvasImpl::DrawBitmap(const Point& vcPoint, const _BitmapImpl& bitmap, FlipDirection dir) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid."); + + switch (dir) + { + case FLIP_DIRECTION_HORIZONTAL: + case FLIP_DIRECTION_VERTICAL: + break; + default: + SysTryReturnResult(NID_GRP, 0, E_INVALID_ARG, "FlipStyle(%d) is invalid.", dir); + break; + } + + EXTRACT_BITMAPEX(pBitmapEx, bitmap); + + if (_ResUtil::NeedToConvertCoord()) + { + Tizen::Graphics::Dimension virSize; + Tizen::Graphics::Dimension phySize; + bool lazyScaling = Tizen::Graphics::IsLazyScalingBitmap(bitmap, virSize, phySize); + + Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint); + + if (lazyScaling) + { + EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap); + + return this->_pNativeCanvas->DrawBitmap(pcPoint, *pScaledBitmapEx, dir); + } + else + { + return this->_pNativeCanvas->DrawBitmap(pcPoint, *pBitmapEx, dir); + } + } + else + { + return this->_pNativeCanvas->DrawBitmap(vcPoint, *pBitmapEx, dir); + } +} + +result +_CanvasImpl::DrawBitmap(const FloatPoint& vcPoint, const _BitmapImpl& bitmap, FlipDirection dir) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return this->DrawBitmap(_Util::Convert(vcPoint), bitmap, dir); +} + +result +_CanvasImpl::DrawBitmap(const Point& vcPoint, const _BitmapImpl& bitmap, const Point& vcPivot, int degree) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid."); + + EXTRACT_BITMAPEX(pBitmapEx, bitmap); + + if (_ResUtil::NeedToConvertCoord()) + { + Tizen::Graphics::Dimension virSize; + Tizen::Graphics::Dimension phySize; + bool lazyScaling = Tizen::Graphics::IsLazyScalingBitmap(bitmap, virSize, phySize); + + Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint); + Point pcPivot = _ResUtil::ConvertToPhyCoord(vcPivot); + + if (lazyScaling) + { + EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap); + + return this->_pNativeCanvas->DrawBitmap(pcPoint, *pScaledBitmapEx, pcPivot, degree); + } + else + { + return this->_pNativeCanvas->DrawBitmap(pcPoint, *pBitmapEx, pcPivot, degree); + } + } + else + { + return this->_pNativeCanvas->DrawBitmap(vcPoint, *pBitmapEx, vcPivot, degree); + } +} + +result +_CanvasImpl::DrawBitmap(const FloatPoint& vcPoint, const _BitmapImpl& bitmap, const FloatPoint& vcPivot, float degree) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return this->DrawBitmap(_Util::Convert(vcPoint), bitmap, _Util::Convert(vcPivot), int(degree)); +} + +result +_CanvasImpl::DrawNinePatchedBitmap(const Rectangle& vcRect, const _BitmapImpl& bitmap) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, BITMAP_IS_VALID(bitmap), E_INVALID_ARG, "The source bitmap is invalid."); + + SysTryReturnResult(NID_GRP, bitmap.IsNinePatchedBitmap(), E_INVALID_ARG, "The source bitmap is not a nine patched bitmap."); + + // check if bimap can be drew in canvas area. + Rectangle rtCanvas = _GetBoundsRel(*this); + + if (rtCanvas.IsEmpty()) + { + SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas."); + } + + result r = _Util::Validate(vcRect, rtCanvas); + + if (IsFailed(r)) + { + return E_SUCCESS; + } + + EXTRACT_BITMAPEX(pBitmapEx, bitmap); + + if (_ResUtil::NeedToConvertCoord()) + { + Tizen::Graphics::Dimension virSize; + Tizen::Graphics::Dimension phySize; + bool lazyScaling = Tizen::Graphics::IsLazyScalingBitmap(bitmap, virSize, phySize); + + Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + + if (lazyScaling) + { + EXTRACT_SCALED_BITMAPEX(pScaledBitmapEx, bitmap); + + return this->_pNativeCanvas->DrawNinePatchedBitmap(pcRect, *pScaledBitmapEx); + } + else + { + return this->_pNativeCanvas->DrawNinePatchedBitmap(pcRect, *pBitmapEx); + } + } + else + { + return this->_pNativeCanvas->DrawNinePatchedBitmap(vcRect, *pBitmapEx); + } +} + +result +_CanvasImpl::DrawNinePatchedBitmap(const FloatRectangle& vcRect, const _BitmapImpl& bitmap) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return this->DrawNinePatchedBitmap(_Util::Convert(vcRect), bitmap); +} + +result +_CanvasImpl::DrawEllipse(const Rectangle& vcBounds) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, &vcBounds, E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcBounds.width >= 0) && (vcBounds.height >= 0), E_OUT_OF_RANGE, + "The given rectangle(width:%d,height:%d) is out of range.", vcBounds.width, vcBounds.height); + + return _CanvasImplPrivate::DrawEllipse(this, _Util::Convert >(vcBounds)); +} + +result +_CanvasImpl::DrawEllipse(const FloatRectangle& vcBounds) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, &vcBounds, E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcBounds.width >= 0) && (vcBounds.height >= 0), E_OUT_OF_RANGE, + "The given rectangle(width:%d,height:%d) is out of range.", vcBounds.width, vcBounds.height); + + return _CanvasImplPrivate::DrawEllipse(this, _Util::Convert >(vcBounds)); +} + +result +_CanvasImpl::DrawLine(const Point& vcPoint1, const Point& vcPoint2) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return _CanvasImplPrivate::DrawLine(this, + _Util::Convert >(vcPoint1), + _Util::Convert >(vcPoint2)); +} + +result +_CanvasImpl::DrawLine(const FloatPoint& vcPoint1, const FloatPoint& vcPoint2) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return _CanvasImplPrivate::DrawLine(this, + _Util::Convert >(vcPoint1), + _Util::Convert >(vcPoint2)); +} + +result +_CanvasImpl::DrawPolygon(const Tizen::Base::Collection::IList& vcPoints) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + int numPoint = vcPoints.GetCount(); + + SysTryReturnResult(NID_GRP, numPoint >= 0, E_INVALID_ARG, "The number of points (%d) is not valid.", numPoint); + + if (numPoint < 2) // TBD. + { + return E_SUCCESS; + } + + std::unique_ptr<_Util::Point[]> doublePoint; + + { + _Util::Point* pDoublePoint = _Util::Convert*>(vcPoints); + + SysTryReturnResult(NID_GRP, pDoublePoint != null, E_INVALID_ARG, "The type of points is not valid."); + + doublePoint.reset(pDoublePoint); + } + + if (_ResUtil::NeedToConvertCoord()) + { + for (int i = 0; i < numPoint; i++) + { + doublePoint[i] = _ResUtil::ConvertToPhyCoord(doublePoint[i]); + } + + return this->_pNativeCanvas->DrawPolygon(doublePoint.get(), numPoint); + } + else + { + return this->_pNativeCanvas->DrawPolygon(doublePoint.get(), numPoint); + } +} + +result +_CanvasImpl::DrawPolyline(const Tizen::Base::Collection::IList& vcPoints) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + int numPoint = vcPoints.GetCount(); + + SysTryReturnResult(NID_GRP, numPoint >= 0, E_INVALID_ARG, "The number of points (%d) is not valid.", numPoint); + + if (numPoint < 2) + { + return E_SUCCESS; + } + + std::unique_ptr<_Util::Point[]> doublePoint; + + { + _Util::Point* pDoublePoint = _Util::Convert*>(vcPoints); + + SysTryReturnResult(NID_GRP, pDoublePoint != null, E_INVALID_ARG, "The type of points is not valid."); + + doublePoint.reset(pDoublePoint); + } + + if (_ResUtil::NeedToConvertCoord()) + { + for (int i = 0; i < numPoint; i++) + { + doublePoint[i] = _ResUtil::ConvertToPhyCoord(doublePoint[i]); + } + + return this->_pNativeCanvas->DrawPolyline(doublePoint.get(), numPoint); + } + else + { + return this->_pNativeCanvas->DrawPolyline(doublePoint.get(), numPoint); + } +} + +result +_CanvasImpl::DrawRectangle(const Rectangle& vcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height); + + return _CanvasImplPrivate::DrawRectangle(this, _Util::Convert >(vcRect)); +} + +result +_CanvasImpl::DrawRectangle(const FloatRectangle& vcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcRect.width >= 0.0f) && (vcRect.height >= 0.0f), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height); + + return _CanvasImplPrivate::DrawRectangle(this, _Util::Convert >(vcRect)); +} + +result +_CanvasImpl::DrawRoundRectangle(const Rectangle& vcRect, const Dimension& vcArcDim) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, (&vcRect) && (&vcArcDim), E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height); + SysTryReturnResult(NID_GRP, (vcArcDim.width >= 0) && (vcArcDim.height >= 0), E_OUT_OF_RANGE, "The given arc size(width:%d,height:%d) is out of range.", vcArcDim.width, vcArcDim.height); + + return _CanvasImplPrivate::DrawRoundRectangle(this, _Util::Convert >(vcRect), _Util::Convert >(vcArcDim)); +} + +result +_CanvasImpl::DrawRoundRectangle(const FloatRectangle& vcRect, const FloatDimension& vcArcDim) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, (&vcRect) && (&vcArcDim), E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcRect.width >= 0.0f) && (vcRect.height >= 0.0f), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height); + SysTryReturnResult(NID_GRP, (vcArcDim.width >= 0.0f) && (vcArcDim.height >= 0.0f), E_OUT_OF_RANGE, "The given arc size(width:%d,height:%d) is out of range.", vcArcDim.width, vcArcDim.height); + + return _CanvasImplPrivate::DrawRoundRectangle(this, _Util::Convert >(vcRect), _Util::Convert >(vcArcDim)); +} + +result +_CanvasImpl::DrawTriangle(const Point& vcPoint1, const Point& vcPoint2, const Point& vcPoint3) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return _CanvasImplPrivate::DrawTriangle(this, + _Util::Convert >(vcPoint1), + _Util::Convert >(vcPoint2), + _Util::Convert >(vcPoint3)); +} + +result +_CanvasImpl::DrawTriangle(const FloatPoint& vcPoint1, const FloatPoint& vcPoint2, const FloatPoint& vcPoint3) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return _CanvasImplPrivate::DrawTriangle(this, + _Util::Convert >(vcPoint1), + _Util::Convert >(vcPoint2), + _Util::Convert >(vcPoint3)); +} + +result +_CanvasImpl::FillEllipse(const Color& color, const Rectangle& vcBounds) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, &vcBounds, E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcBounds.width >= 0) && (vcBounds.height >= 0), E_OUT_OF_RANGE, + "The given rectangle(width:%d,height:%d) is out of range.", vcBounds.width, vcBounds.height); + + return _CanvasImplPrivate::FillEllipse(this, color, _Util::Convert >(vcBounds)); +} + +result +_CanvasImpl::FillEllipse(const Color& color, const FloatRectangle& vcBounds) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, &vcBounds, E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcBounds.width >= 0.0f) && (vcBounds.height >= 0.0f), E_OUT_OF_RANGE, + "The given rectangle(width:%d,height:%d) is out of range.", vcBounds.width, vcBounds.height); + + return _CanvasImplPrivate::FillEllipse(this, color, _Util::Convert >(vcBounds)); +} + +result +_CanvasImpl::FillPolygon(const Color& color, const Tizen::Base::Collection::IList& vcPoints) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, &vcPoints, E_INVALID_ARG, "The given rectangle is invalid."); + + int numPoint = vcPoints.GetCount(); + + SysTryReturnResult(NID_GRP, numPoint >= 0, E_INVALID_ARG, "The number of points (%d) is not valid.", numPoint); + + if (numPoint < 3) // TBD. + { + return E_SUCCESS; + } + + std::unique_ptr<_Util::Point[]> doublePoint; + + { + _Util::Point* pDoublePoint = _Util::Convert*>(vcPoints); + + SysTryReturnResult(NID_GRP, pDoublePoint != null, E_INVALID_ARG, "The type of points is not valid."); + + doublePoint.reset(pDoublePoint); + } + + if (_ResUtil::NeedToConvertCoord()) + { + for (int i = 0; i < numPoint; i++) + { + doublePoint[i] = _ResUtil::ConvertToPhyCoord(doublePoint[i]); + } + + return this->_pNativeCanvas->FillPolygon(color, doublePoint.get(), numPoint); + } + else + { + return this->_pNativeCanvas->FillPolygon(color, doublePoint.get(), numPoint); + } +} + +result +_CanvasImpl::FillRectangle(const Color& color, const Rectangle& vcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height); + + return _CanvasImplPrivate::FillRectangle(this, color, _Util::Convert >(vcRect)); +} + +result +_CanvasImpl::FillRectangle(const Color& color, const FloatRectangle& vcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcRect.width >= 0.0f) && (vcRect.height >= 0.0f), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height); + + return _CanvasImplPrivate::FillRectangle(this, color, _Util::Convert >(vcRect)); +} + +result +_CanvasImpl::FillRoundRectangle(const Color& color, const Rectangle& vcRect, const Dimension& vcArcDim) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, (&vcRect) && (&vcArcDim), E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height); + SysTryReturnResult(NID_GRP, (vcArcDim.width >= 0) && (vcArcDim.height >= 0), E_OUT_OF_RANGE, "The given arc size(width:%d,height:%d) is out of range.", vcArcDim.width, vcArcDim.height); + + return _CanvasImplPrivate::FillRoundRectangle(this, color, _Util::Convert >(vcRect), _Util::Convert >(vcArcDim)); +} + +result +_CanvasImpl::FillRoundRectangle(const Color& color, const FloatRectangle& vcRect, const FloatDimension& vcArcDim) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, (&vcRect) && (&vcArcDim), E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcRect.width >= 0.0f) && (vcRect.height >= 0.0f), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height); + SysTryReturnResult(NID_GRP, (vcArcDim.width >= 0.0f) && (vcArcDim.height >= 0.0f), E_OUT_OF_RANGE, "The given arc size(width:%d,height:%d) is out of range.", vcArcDim.width, vcArcDim.height); + + return _CanvasImplPrivate::FillRoundRectangle(this, color, _Util::Convert >(vcRect), _Util::Convert >(vcArcDim)); +} + +result +_CanvasImpl::FillTriangle(const Color& color, const FloatPoint& vcPoint1, const FloatPoint& vcPoint2, const FloatPoint& vcPoint3) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return _CanvasImplPrivate::FillTriangle(this, color, + _Util::Convert >(vcPoint1), + _Util::Convert >(vcPoint2), + _Util::Convert >(vcPoint3)); +} + +result +_CanvasImpl::FillTriangle(const Color& color, const Point& vcPoint1, const Point& vcPoint2, const Point& vcPoint3) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return _CanvasImplPrivate::FillTriangle(this, color, + _Util::Convert >(vcPoint1), + _Util::Convert >(vcPoint2), + _Util::Convert >(vcPoint3)); +} + +result +_CanvasImpl::DrawText(const Point& vcPoint, const Tizen::Base::String& text) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength()); + + if (_ResUtil::NeedToConvertCoord()) + { + Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint); + + return this->_pNativeCanvas->DrawText(pcPoint, text); + } + else + { + return this->_pNativeCanvas->DrawText(vcPoint, text); + } +} + +result +_CanvasImpl::DrawText(const Point& vcPoint, const Tizen::Base::String& text, int startIndex, int length) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength()); + SysTryReturnResult(NID_GRP, length >= 0 && startIndex >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE, "The value of the length (%d), startIndex(%d) are outside the valid range defined by the method.", length, startIndex); + + if (text.GetLength() == 0) + { + return E_SUCCESS; + } + + if (_ResUtil::NeedToConvertCoord()) + { + Point pcPt = _ResUtil::ConvertToPhyCoord(vcPoint); + + return this->_pNativeCanvas->DrawText(pcPt, text, startIndex, length); + } + else + { + return this->_pNativeCanvas->DrawText(vcPoint, text, startIndex, length); + } +} + +result +_CanvasImpl::DrawText(const Point& vcPoint, const Tizen::Base::String& text, int startIndex, const Color& outlineColor) +{ + const char* pNotConstructedYet = "[E_OPERATION_FAILED] This instance is not constructed yet."; + + SysTryReturn(NID_GRP, this, E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet); + SysTryReturn(NID_GRP, this->_pNativeCanvas, E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet); + SysTryReturn(NID_GRP, this->_pNativeCanvas->IsValid(), E_OPERATION_FAILED, E_OPERATION_FAILED, pNotConstructedYet); + + SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength()); + + return this->DrawText(vcPoint, text, startIndex, text.GetLength(), outlineColor); +} + +result +_CanvasImpl::DrawText(const Point& vcPoint, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, text.GetLength() >= 0, E_INVALID_ARG, "The text length (%d) is not valid.", text.GetLength()); + + SysTryReturnResult(NID_GRP, length >= 0, E_OUT_OF_RANGE, + "The value of the length (%d) is outside the valid range defined by the method.", + length); + + if (text.GetLength() == 0) + { + return E_SUCCESS; + } + + if (_ResUtil::NeedToConvertCoord()) + { + Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint); + + return this->_pNativeCanvas->DrawText(pcPoint, text, startIndex, length, outlineColor); + } + else + { + return this->_pNativeCanvas->DrawText(vcPoint, text, startIndex, length, outlineColor); + } +} + +result +_CanvasImpl::DrawText(const Point& vcPoint, const EnrichedText& etext) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + const _EnrichedTextImpl* pImpl = _EnrichedTextImpl::GetInstance(etext); + + if (pImpl == null) + { + return E_OPERATION_FAILED; + } + + Tizen::Graphics::_Text::TextObject* pTextObject = const_cast <_EnrichedTextImpl*>(pImpl)->GetTextObject(); + + if (pTextObject == null) + { + return E_OPERATION_FAILED; + } + + Rectangle bounds = pImpl->GetBounds(); + Rectangle rect(vcPoint.x, vcPoint.y, bounds.width, bounds.height); + pTextObject->SetBounds(rect); + pTextObject->Draw(*this); + + return E_SUCCESS; +} + +Rectangle +_CanvasImpl::GetBounds(void) const +{ + SysTryReturn(NID_GRP, INSTANCE_IS_VALID, Rectangle(), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + if (_ResUtil::NeedToConvertCoord()) + { + const _ResUtil::Pos& pos = this->_pCoordHolder->canvasPos.required; + const _ResUtil::Rect& bounds = this->_pCoordHolder->canvasSize.required; + const Rectangle boundsFromPi = this->_pNativeCanvas->GetBounds(); + + if ((bounds.w == 0 && boundsFromPi.width > 0) || (bounds.h == 0 && boundsFromPi.height > 0)) + { + _CanvasImpl* pThis = const_cast<_CanvasImpl*>(this); + + pThis->_pCoordHolder->canvasSize = _ResUtil::Rect(boundsFromPi.x, boundsFromPi.y, boundsFromPi.width, boundsFromPi.height); + + pThis->_pCoordHolder->canvasSize.phyCoord.x = boundsFromPi.x; + pThis->_pCoordHolder->canvasSize.phyCoord.y = boundsFromPi.y; + pThis->_pCoordHolder->canvasSize.phyCoord.w = boundsFromPi.width; + pThis->_pCoordHolder->canvasSize.phyCoord.h = boundsFromPi.height; + } + + // exception from the window canvas + if (boundsFromPi.x == 0 && boundsFromPi.y == 0) + { + return Rectangle(0, 0, bounds.w, bounds.h); + } + else + { + return Rectangle(pos.x, pos.y, bounds.w, bounds.h); + } + } + else + { + return this->_pNativeCanvas->GetBounds(); + } +} + +LineStyle +_CanvasImpl::GetLineStyle() const +{ + SysTryReturn(NID_GRP, INSTANCE_IS_VALID, LINE_STYLE_MAX, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + return this->_pNativeCanvas->GetLineStyle(); +} + +int +_CanvasImpl::GetLineWidth() const +{ + SysTryReturn(NID_GRP, INSTANCE_IS_VALID, -1, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + if (_ResUtil::NeedToConvertCoord()) + { + return this->_pCoordHolder->lineWidth.required; + } + else + { + return this->_pNativeCanvas->GetLineWidth(); + } +} + +result +_CanvasImpl::SetLineStyle(LineStyle style) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, LINE_STYLE_MIN < style && style < LINE_STYLE_MAX, E_INVALID_ARG, "The given line style(%d) is out of range.", style); + + return this->_pNativeCanvas->SetLineStyle(style); +} + +result +_CanvasImpl::SetLineWidth(int vcWidth) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, vcWidth > 0, E_OUT_OF_RANGE, "The given line width(%d) is out of range.", vcWidth); + + if (_ResUtil::NeedToConvertCoord()) + { + int pcWidth = _ResUtil::ConvertToPhyCoordSize(vcWidth); + float pcWidthFloat = _ResUtil::ConvertToPhyCoordSize(float(vcWidth)); + + result r = this->_pNativeCanvas->SetLineWidth(pcWidth, pcWidthFloat); + + if (IsSucceeded(r)) + { + this->_pCoordHolder->lineWidth = vcWidth; + } + + return r; + } + else + { + return this->_pNativeCanvas->SetLineWidth(vcWidth, float(vcWidth)); + } +} + +result +_CanvasImpl::GetDashPattern(Tizen::Base::Collection::IListT& pattern, int& offset) +{ + SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + pattern.RemoveAll(); + + result r = pattern.AddItems(this->_dashList); + + if (IsFailed(r)) + { + switch (r) + { + case E_INVALID_ARG: + case E_OPERATION_FAILED: + case E_OUT_OF_MEMORY: + SysTryReturn(NID_GRP, false, r, r, "[%s] Propagating.", GetErrorMessage(r)); + break; + default: + SysTryReturn(NID_GRP, false, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Tizen::Base::Collection::ArrayListT::AddItems() failed"); + break; + } + } + + offset = this->_dashOffset; + + return r; +} + +result +_CanvasImpl::SetDashPattern(const Tizen::Base::Collection::IListT& pattern, int offset) +{ + SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + result r = E_SUCCESS; + + // It is NOT the strong guarantee for an exception + this->_dashList.RemoveAll(); + + r = this->_dashList.AddItems(pattern); + + if (IsFailed(r)) + { + switch (r) + { + case E_INVALID_ARG: + case E_OPERATION_FAILED: + case E_OUT_OF_MEMORY: + SysTryReturn(NID_GRP, false, r, r, "[%s] Propagating.", GetErrorMessage(r)); + break; + default: + SysTryReturn(NID_GRP, false, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Tizen::Base::Collection::ArrayListT::AddItems() failed"); + break; + } + } + + { + int dashIntValue = 0; + Tizen::Graphics::_Util::AccumList dashValueList; + + for (int i = 0; i < pattern.GetCount(); i++) + { + pattern.GetAt(i, dashIntValue); + dashValueList.Push(double(dashIntValue)); + } + + r = this->_pNativeCanvas->SetDashPattern(dashValueList, double(offset)); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + this->_dashOffset = offset; + } + + return r; +} + +result +_CanvasImpl::SetDrawingQuality(BitmapDrawingQuality quality) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + switch (quality) + { + case BITMAP_DRAWING_QUALITY_LOW: + case BITMAP_DRAWING_QUALITY_MID: + case BITMAP_DRAWING_QUALITY_HIGH: + break; + default: + SysLogException(NID_GRP, E_INVALID_ARG, "The specified drawing quality(%d) is invalid.", quality); + return E_INVALID_ARG; + } + + this->_pNativeCanvas->SetDrawingQuality(quality); + + return E_SUCCESS; +} + +BitmapDrawingQuality +_CanvasImpl::GetDrawingQuality(void) const +{ + return (INSTANCE_IS_VALID) ? this->_pNativeCanvas->GetDrawingQuality() : BITMAP_DRAWING_QUALITY_LOW; +} + +result +_CanvasImpl::SetBlendingMode(BlendingMode blendingMode) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + switch (blendingMode) + { + case BLENDING_MODE_CLEAR: + case BLENDING_MODE_SRC: + case BLENDING_MODE_DST: + case BLENDING_MODE_SRC_OVER: + case BLENDING_MODE_DST_OVER: + case BLENDING_MODE_SRC_IN: + case BLENDING_MODE_DST_IN: + case BLENDING_MODE_SRC_OUT: + case BLENDING_MODE_DST_OUT: + case BLENDING_MODE_SRC_ATOP: + case BLENDING_MODE_DST_ATOP: + case BLENDING_MODE_DST_XOR: + case BLENDING_MODE_ADD: + case BLENDING_MODE_SATURATE: + case BLENDING_MODE_MULTIPLY: + case BLENDING_MODE_SCREEN: + case BLENDING_MODE_OVERLAY: + case BLENDING_MODE_DARKEN: + case BLENDING_MODE_LIGHTEN: + case BLENDING_MODE_COLOR_DODGE: + case BLENDING_MODE_COLOR_BURN: + case BLENDING_MODE_HARD_LIGHT: + case BLENDING_MODE_SOFT_LIGHT: + case BLENDING_MODE_DIFFERENCE: + case BLENDING_MODE_EXCLUSION: + break; + default: + SysLogException(NID_GRP, E_INVALID_ARG, "The specified blending mode(%d) is invalid.", blendingMode); + return E_INVALID_ARG; + } + + this->_pNativeCanvas->SetBlendingMode(blendingMode); + + return E_SUCCESS; +} + +BlendingMode +_CanvasImpl::GetBlendingMode(void) const +{ + return (INSTANCE_IS_VALID) ? this->_pNativeCanvas->GetBlendingMode() : BLENDING_MODE_SRC_OVER; +} + +result +_CanvasImpl::GetPixel(const Point& vcPoint, Color& color) const +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + Rectangle rtCanvas = _GetBoundsRel(*this); + + SysTryReturnResult(NID_GRP, !rtCanvas.IsEmpty(), E_OUT_OF_RANGE, "Cannot get the bounds of the canvas."); + + result r = _Util::Validate(vcPoint, rtCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + if (_ResUtil::NeedToConvertCoord()) + { + Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint); + + return this->_pNativeCanvas->GetPixel(pcPoint, color); + } + else + { + return this->_pNativeCanvas->GetPixel(vcPoint, color); + } +} + +result +_CanvasImpl::SetPixel(const FloatPoint& vcPoint) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return _CanvasImplPrivate::SetPixel(this, _Util::Convert >(vcPoint)); +} + +result +_CanvasImpl::SetPixel(const Point& vcPoint) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return _CanvasImplPrivate::SetPixel(this, _Util::Convert >(vcPoint)); +} + +result +_CanvasImpl::Show() +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + result r = E_SUCCESS; + Rectangle rect = this->GetBounds(); + + r = this->_pNativeCanvas->Show(); + + return r; +} + +result +_CanvasImpl::Show(const Rectangle& vcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE, + "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, + vcRect.height); + + result r = E_SUCCESS; + Rectangle rect = this->GetBounds(); + + if (_ResUtil::NeedToConvertCoord()) + { + Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + + r = this->_pNativeCanvas->Show(pcRect); + } + else + { + r = this->_pNativeCanvas->Show(vcRect); + } + + return r; +} + +result +_CanvasImpl::SetFont(const Font& font) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + SysTryReturnResult(NID_GRP, _FontImpl::GetInstance(font) && _FontImpl::GetInstance(font)->IsConstructed(), E_INVALID_ARG, "The given font is not constructed."); + SysTryReturnResult(NID_GRP, font.GetMaxHeight() > 0 && font.GetMaxWidth() > 0, E_INVALID_ARG, "The infomation of the given font is not valid. (maxWidth=%d,maxHeight=%d).", font.GetMaxWidth(), font.GetMaxHeight()); + + // should keep clone font + Font* pFont = _FontImpl::CloneN(font); + + if (pFont == null) + { + SysTryLog(NID_GRP, pFont, "[] Fails to allocate memory for font resource."); + + this->_pFont = null; + + // shkim, TODO. + // we failed to make cloned font. so, return what? E_SYSTEM which is not defined in header?? or use E_OPERATION_FAILED again for different meaning? + // or just setting defult font?! + return E_OPERATION_FAILED; + } + + EXTRACT_FONTEX(pFontEx, *pFont); + result r = this->_pNativeCanvas->SetFont(*pFontEx); + SysTryCatch(NID_GRP, E_SUCCESS == r, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Fails to set font."); + + // succeed making cloned font, then keep it and replace old one. + if (this->_pFont) + { + delete this->_pFont; + this->_pFont = null; + } + + this->_pFont = pFont; + + return r; + +CATCH: + delete pFont; + pFont = null; + + return r; +} + +Font* +_CanvasImpl::GetFontN(void) +{ + result r = E_SUCCESS; + Font* pFont = null; + + // clear last error + ClearLastResult(); + + SysTryCatch(NID_GRP, INSTANCE_IS_VALID, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + // we have the font user set + if (this->_pFont) + { + pFont = _FontImpl::CloneN(*(this->_pFont)); + SysTryCatch(NID_GRP, pFont, r = E_OUT_OF_MEMORY, E_OPERATION_FAILED, "[E_OUT_OF_MEMORY] Failed to create Font instance."); + } + else + { + // make font instance with the attribute of system default font + // shkim, TODO + } + + SetLastResult(r); + return pFont; + +CATCH: + if (pFont) + { + delete pFont; + } + + SetLastResult(r); + + return null; +} + +void +_CanvasImpl::SetTextOrigin(TextOrigin origin) +{ + if (INSTANCE_IS_VALID) + { + switch (origin) + { + case TEXT_ORIGIN_LEFT_TOP: + case TEXT_ORIGIN_BASELINE: + this->_pNativeCanvas->__textOrigin = origin; + break; + } + } +} + +result +_CanvasImpl::SetClipBounds(const Rectangle& vcRect) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, &vcRect, E_OUT_OF_RANGE, "The given rectangle is invalid."); + SysTryReturnResult(NID_GRP, (vcRect.width >= 0) && (vcRect.height >= 0), E_OUT_OF_RANGE, "The given rectangle(width:%d,height:%d) is out of range.", vcRect.width, vcRect.height); + + Rectangle rtCanvas = _GetBoundsRel(*this); + + result r = _Util::Validate(vcRect, rtCanvas); + + SysTryReturnResult(NID_GRP, !IsFailed(r), r, "Propagating."); + + Rectangle revisedVcRect; + + { + int x1 = vcRect.x; + int y1 = vcRect.y; + int x2 = vcRect.x + vcRect.width; + int y2 = vcRect.y + vcRect.height; + + x1 = (x1 > 0) ? x1 : 0; + y1 = (y1 > 0) ? y1 : 0; + x2 = (x2 < rtCanvas.width) ? x2 : rtCanvas.width; + y2 = (y2 < rtCanvas.height) ? y2 : rtCanvas.height; + + revisedVcRect.x = x1; + revisedVcRect.y = y1; + revisedVcRect.width = x2 - x1; + revisedVcRect.height = y2 - y1; + } + + if (_ResUtil::NeedToConvertCoord()) + { + Rectangle pcRect = _ResUtil::ConvertToPhyCoord(revisedVcRect); + + // special case + pcRect.width = (pcRect.width >= 0) ? pcRect.width : 1; + pcRect.height = (pcRect.height >= 0) ? pcRect.height : 1; + + result r = this->_pNativeCanvas->SetClipBounds(pcRect); + + if (IsSucceeded(r)) + { + this->_pCoordHolder->clipBounds = _ResUtil::Rect(revisedVcRect.x, revisedVcRect.y, revisedVcRect.width, + revisedVcRect.height); + } + + return r; + } + else + { + return this->_pNativeCanvas->SetClipBounds(revisedVcRect); + } +} + +Rectangle +_CanvasImpl::GetClipBounds(void) const +{ + Rectangle rect; + SysTryReturn(NID_GRP, INSTANCE_IS_VALID, rect, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + if (_ResUtil::NeedToConvertCoord()) + { + const _ResUtil::Rect& bounds = this->_pCoordHolder->clipBounds.required; + + return Rectangle(bounds.x, bounds.y, bounds.w, bounds.h); + } + else + { + return this->_pNativeCanvas->GetClipBounds(); + } +} + +result +_CanvasImpl::Lock(BufferInfo& info, long timeout) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + SysTryReturnResult(NID_GRP, (static_cast (timeout) == INFINITE) || (timeout >= 0), E_INVALID_ARG, + "'timeout(=%d)' is not valid.", + timeout); + + return this->_pNativeCanvas->Lock(info, timeout); +} + +result +_CanvasImpl::Unlock() +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return this->_pNativeCanvas->Unlock(); +} + +void +_CanvasImpl::SetForegroundColor(const Color& fgColor) +{ + SysTryReturnVoidResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + return this->_pNativeCanvas->SetForegroundColor(fgColor); +} + +Color +_CanvasImpl::GetForegroundColor(void) const +{ + SysTryReturn(NID_GRP, INSTANCE_IS_VALID, Color::GetColor(COLOR_ID_BLACK), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + return this->_pNativeCanvas->GetForegroundColor(); +} + +void +_CanvasImpl::SetBackgroundColor(const Color& bgColor) +{ + SysTryReturnVoidResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + return this->_pNativeCanvas->SetBackgroundColor(bgColor); +} + +Color +_CanvasImpl::GetBackgroundColor(void) const +{ + SysTryReturn(NID_GRP, INSTANCE_IS_VALID, Color::GetColor(COLOR_ID_BLACK), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + return this->_pNativeCanvas->GetBackgroundColor(); +} + +result +_CanvasImpl::SetPosition(const Point& vcPoint) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + return this->SetPosition(vcPoint.x, vcPoint.y); +} + +result +_CanvasImpl::SetPosition(int vcX, int vcY) +{ + SysTryReturnResult(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, "This instance is not constructed yet."); + + if (_ResUtil::NeedToConvertCoord()) + { + Point pcPoint = _ResUtil::ConvertToPhyCoord(Point(vcX, vcY)); + + result r = this->_pNativeCanvas->SetPosition(pcPoint.x, pcPoint.y); + + if (IsSucceeded(r)) + { + this->_pCoordHolder->canvasPos = _ResUtil::Pos(vcX, vcY); + } + + return r; + } + else + { + return this->_pNativeCanvas->SetPosition(vcX, vcY); + } +} + +Canvas* +_CanvasImpl::GetSubCanvasN(const Rectangle& subRegion) const +{ + SysTryReturn(NID_GRP, INSTANCE_IS_VALID, null, E_OPERATION_FAILED, "This instance is not constructed yet."); + + _Canvas* pSourceNativeCanvas = this->_pNativeCanvas; + + std::auto_ptr subCanvas(new (std::nothrow) Canvas); + + Canvas* pSubCanvas = subCanvas.get(); + + SysTryReturn(NID_GRP, pSubCanvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _CanvasImpl* pSubCanvasImpl = _CanvasImpl::GetInstance(*pSubCanvas); + + SysTryReturn(NID_GRP, pSubCanvasImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + if (_ResUtil::NeedToConvertCoord()) + { + Rectangle subRegionPC = _ResUtil::ConvertToPhyCoord(subRegion); + + subRegionPC.width = (subRegionPC.width > 0) ? subRegionPC.width : 1; + subRegionPC.height = (subRegionPC.height > 0) ? subRegionPC.height : 1; + + result r = pSubCanvasImpl->_pNativeCanvas->Construct(pSourceNativeCanvas, subRegionPC); + + SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pSubCanvasImpl->_pCoordHolder->Init(subRegion); + pSubCanvasImpl->_pCoordHolder->canvasSize.phyCoord.w = subRegionPC.width; + pSubCanvasImpl->_pCoordHolder->canvasSize.phyCoord.h = subRegionPC.height; + } + else + { + result r = pSubCanvasImpl->_pNativeCanvas->Construct(pSourceNativeCanvas, subRegion); + + SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (this->_pFont) + { + pSubCanvasImpl->SetFont(*this->_pFont); + } + + if (this->_pPriorityFont) + { + pSubCanvasImpl->SetPriorityFont(*this->_pPriorityFont); + } + + return subCanvas.release(); +} + +result +_CanvasImpl::SetPriorityFont(const Font& font) +{ + ClearLastResult(); + + // check input param + SysTryReturn(NID_GRP, INSTANCE_IS_VALID, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, font.GetMaxHeight() > 0 && font.GetMaxWidth() > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The infomation of the given font is not valid. (maxWidth=%d, maxHeight=%d).", font.GetMaxWidth(), font.GetMaxHeight()); + + Font* pFont = &(const_cast (font)); + + EXTRACT_FONTEX(pFontEx, *pFont); + result r = this->_pNativeCanvas->SetPriorityFont(*pFontEx); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + // overwrite existing priority font + this->_pPriorityFont = pFont; + + return E_SUCCESS; +} + +void +_CanvasImpl::ResetPriorityFont(void) +{ + if (INSTANCE_IS_VALID) + { + this->_pPriorityFont = null; + this->_pNativeCanvas->ResetPriorityFont(); + } +} + +void +_CanvasImpl::SetStableRenderer(bool isStable) +{ + if (INSTANCE_IS_VALID) + { + this->_pNativeCanvas->__useStableRenderer = isStable; + } +} + +void +_CanvasImpl::SetFrameInfoCallback(void* (*pGetDefaultFrameNativeHandle)(void), void* (*pGetDefaultFrameHandle)(void)) +{ + _GetDefaultFrameEcoreEvasHandle = (pGetDefaultFrameNativeHandle) ? pGetDefaultFrameNativeHandle : _GetNull; + _GetDefaultFrameEvasHandle = (pGetDefaultFrameHandle) ? pGetDefaultFrameHandle : _GetNull; +} + +void +_CanvasImpl::SetThemeInfoCallback(Color (*pGetDefaultForegroundColor)(void), Color (*pGetDefaultBackgroundColor)(void)) +{ + _GetDefaultForegroundColor = (pGetDefaultForegroundColor) ? pGetDefaultForegroundColor : _GetBlack; + _GetDefaultBackgroundColor = (pGetDefaultBackgroundColor) ? pGetDefaultBackgroundColor : _GetWhite; +} + +_CanvasImpl* +_CanvasImpl::GetInstance(Canvas& canvas) +{ + return (&canvas != null) ? canvas.__pImpl : null; +} + +const _CanvasImpl* +_CanvasImpl::GetInstance(const Canvas& canvas) +{ + return (&canvas != null) ? canvas.__pImpl : null; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_CanvasImplPrivate.h b/src/graphics/FGrp_CanvasImplPrivate.h new file mode 100644 index 0000000..2bb1e10 --- /dev/null +++ b/src/graphics/FGrp_CanvasImplPrivate.h @@ -0,0 +1,432 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasImplPrivate.h + * @brief This is the private header file for the _CanvasImpl class + * + */ + +#ifndef _FGRP_INTERNAL_CANVASIMPL_PRIVATE_H_ +#define _FGRP_INTERNAL_CANVASIMPL_PRIVATE_H_ + + +#include + +#include "FGrp_CanvasImpl.h" +#include "util/FGrp_UtilType.h" + + +namespace // unnamed +{ + +template +Tizen::Graphics::_Util::Rectangle +_GetBoundsRelT(const Tizen::Graphics::_CanvasImpl& canvas) +{ + Tizen::Graphics::Rectangle bounds = canvas.GetBounds(); + + Tizen::Graphics::_Util::Rectangle rect = + { + 0, + 0, + bounds.width, + bounds.height + }; + + return rect; +} + +template +void +_ExpandClippingAreaForLineWidth(Tizen::Graphics::_Util::Rectangle& rtCanvas, T lineWidth) +{ + typedef T Type; + + Type lineWidthHalf = (lineWidth + Type(1)) / Type(2); + + rtCanvas.x -= lineWidthHalf; + rtCanvas.y -= lineWidthHalf; + rtCanvas.w += lineWidthHalf * Type(2); + rtCanvas.h += lineWidthHalf * Type(2); +} + +} + +namespace Tizen { namespace Graphics +{ + +class _CanvasImplPrivate +{ + friend class _CanvasImpl; + + template + static result SetPixel(_CanvasImpl* pThis, const _Util::Point& vcPoint) + { + _Util::Rectangle rtCanvas = _GetBoundsRelT(*pThis); + + if (rtCanvas.w <= 0 || rtCanvas.h <= 0) + { + SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas."); + } + + result r = _Util::ValidateT(vcPoint, rtCanvas); + + if (IsFailed(r)) + { + SysTryReturn(NID_GRP, 0, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (_ResUtil::NeedToConvertCoord()) + { + _Util::Point pcPoint = _ResUtil::ConvertToPhyCoord(vcPoint); + + return pThis->_pNativeCanvas->SetPixel(pcPoint); + } + else + { + return pThis->_pNativeCanvas->SetPixel(vcPoint); + } + } + + template + static result DrawRectangle(_CanvasImpl* pThis, const _Util::Rectangle& vcRect) + { + typedef T Type; + + if ((vcRect.w == Type(0)) || (vcRect.h == Type(0))) + { + return E_SUCCESS; + } + + _Util::Rectangle rtCanvas = _GetBoundsRelT(*pThis); + + if (rtCanvas.w <= 0 || rtCanvas.h <= 0) + { + SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas."); + } + + _ExpandClippingAreaForLineWidth(rtCanvas, Type(pThis->GetLineWidth())); + + result r = _Util::ValidateT(vcRect, rtCanvas); + + if (IsFailed(r)) + { + SysTryReturn(NID_GRP, 0, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (_ResUtil::NeedToConvertCoord()) + { + _Util::Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + + return pThis->_pNativeCanvas->DrawRectangle(pcRect); + } + else + { + return pThis->_pNativeCanvas->DrawRectangle(vcRect); + } + } + + template + static result FillRectangle(_CanvasImpl* pThis, const Color& color, const _Util::Rectangle& vcRect) + { + typedef T Type; + + if ((vcRect.w == Type(0)) || (vcRect.h == Type(0))) + { + return E_SUCCESS; + } + + _Util::Rectangle rtCanvas = _GetBoundsRelT(*pThis); + + if (rtCanvas.w <= 0 || rtCanvas.h <= 0) + { + SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas."); + } + + result r = _Util::ValidateT(vcRect, rtCanvas); + + if (IsFailed(r)) + { + SysTryReturn(NID_GRP, 0, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (_ResUtil::NeedToConvertCoord()) + { + _Util::Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + + return pThis->_pNativeCanvas->FillRectangle(color, pcRect); + } + else + { + return pThis->_pNativeCanvas->FillRectangle(color, vcRect); + } + } + + template + static result DrawRoundRectangle(_CanvasImpl* pThis, const _Util::Rectangle& vcRect, const _Util::Dimension& vcArcDim) + { + typedef T Type; + + if ((vcRect.w == Type(0)) || (vcRect.h == Type(0))) + { + return E_SUCCESS; + } + + if ((vcArcDim.w == Type(0)) || (vcArcDim.h == Type(0))) + { + return _CanvasImplPrivate::DrawRectangle(pThis, vcRect); + } + + _Util::Rectangle rtCanvas = _GetBoundsRelT(*pThis); + + if (rtCanvas.w <= 0 || rtCanvas.h <= 0) + { + SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas."); + } + + _ExpandClippingAreaForLineWidth(rtCanvas, Type(pThis->GetLineWidth())); + + result r = _Util::ValidateT(vcRect, rtCanvas); + + if (IsFailed(r)) + { + SysTryReturn(NID_GRP, 0, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (_ResUtil::NeedToConvertCoord()) + { + _Util::Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + _Util::Dimension pcArcDim = _ResUtil::ConvertToPhyCoord(vcArcDim); + + return pThis->_pNativeCanvas->DrawRoundRectangle(pcRect, pcArcDim); + } + else + { + return pThis->_pNativeCanvas->DrawRoundRectangle(vcRect, vcArcDim); + } + } + + template + static result FillRoundRectangle(_CanvasImpl* pThis, const Color& color, const _Util::Rectangle& vcRect, const _Util::Dimension& vcArcDim) + { + typedef T Type; + + if ((vcRect.w == Type(0)) || (vcRect.h == Type(0))) + { + return E_SUCCESS; + } + + _Util::Rectangle rtCanvas = _GetBoundsRelT(*pThis); + + if (rtCanvas.w <= 0 || rtCanvas.h <= 0) + { + SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas."); + } + + result r = _Util::ValidateT(vcRect, rtCanvas); + + if (IsFailed(r)) + { + SysTryReturn(NID_GRP, 0, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (_ResUtil::NeedToConvertCoord()) + { + _Util::Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + _Util::Dimension pcArcDim = _ResUtil::ConvertToPhyCoord(vcArcDim); + + return pThis->_pNativeCanvas->FillRoundRectangle(color, pcRect, pcArcDim); + } + else + { + return pThis->_pNativeCanvas->FillRoundRectangle(color, vcRect, vcArcDim); + } + } + + template + static result DrawEllipse(_CanvasImpl* pThis, const _Util::Rectangle& vcRect) + { + typedef T Type; + + if ((vcRect.w == Type(0)) || (vcRect.h == Type(0))) + { + return E_SUCCESS; + } + + _Util::Rectangle rtCanvas = _GetBoundsRelT(*pThis); + + if (rtCanvas.w <= 0 || rtCanvas.h <= 0) + { + SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas."); + } + + _ExpandClippingAreaForLineWidth(rtCanvas, Type(pThis->GetLineWidth())); + + result r = _Util::ValidateT(vcRect, rtCanvas); + + if (IsFailed(r)) + { + SysTryReturn(NID_GRP, 0, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (_ResUtil::NeedToConvertCoord()) + { + _Util::Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + + return pThis->_pNativeCanvas->DrawEllipse(pcRect); + } + else + { + return pThis->_pNativeCanvas->DrawEllipse(vcRect); + } + } + + template + static result FillEllipse(_CanvasImpl* pThis, const Color& color, const _Util::Rectangle& vcRect) + { + typedef T Type; + + if ((vcRect.w == Type(0)) || (vcRect.h == Type(0))) + { + return E_SUCCESS; + } + + _Util::Rectangle rtCanvas = _GetBoundsRelT(*pThis); + + if (rtCanvas.w <= 0 || rtCanvas.h <= 0) + { + SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas."); + } + + result r = _Util::ValidateT(vcRect, rtCanvas); + + if (IsFailed(r)) + { + SysTryReturn(NID_GRP, 0, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (_ResUtil::NeedToConvertCoord()) + { + _Util::Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + + return pThis->_pNativeCanvas->FillEllipse(color, pcRect); + } + else + { + return pThis->_pNativeCanvas->FillEllipse(color, vcRect); + } + } + + template + static result DrawArc(_CanvasImpl* pThis, const _Util::Rectangle& vcRect, T startAngle, T endAngle, ArcStyle arcStyle) + { + typedef T Type; + + if ((vcRect.w == Type(0)) || (vcRect.h == Type(0))) + { + return E_SUCCESS; + } + + _Util::Rectangle rtCanvas = _GetBoundsRelT(*pThis); + + if (rtCanvas.w <= 0 || rtCanvas.h <= 0) + { + SysTryReturnResult(NID_GRP, 0, E_OPERATION_FAILED, "Cannot get the bounds of the canvas."); + } + + _ExpandClippingAreaForLineWidth(rtCanvas, Type(pThis->GetLineWidth())); + + result r = _Util::ValidateT(vcRect, rtCanvas); + + if (IsFailed(r)) + { + SysTryReturn(NID_GRP, 0, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (_ResUtil::NeedToConvertCoord()) + { + _Util::Rectangle pcRect = _ResUtil::ConvertToPhyCoord(vcRect); + + return pThis->_pNativeCanvas->DrawArc(pcRect, startAngle, endAngle, arcStyle); + } + else + { + return pThis->_pNativeCanvas->DrawArc(vcRect, startAngle, endAngle, arcStyle); + } + } + + template + static result DrawTriangle(_CanvasImpl* pThis, const _Util::Point& vcPoint1, const _Util::Point& vcPoint2, const _Util::Point& vcPoint3) + { + typedef T Type; + + if (_ResUtil::NeedToConvertCoord()) + { + _Util::Point pcPoint1 = _ResUtil::ConvertToPhyCoord(vcPoint1); + _Util::Point pcPoint2 = _ResUtil::ConvertToPhyCoord(vcPoint2); + _Util::Point pcPoint3 = _ResUtil::ConvertToPhyCoord(vcPoint3); + + return pThis->_pNativeCanvas->DrawTriangle(pcPoint1, pcPoint2, pcPoint3); + } + else + { + return pThis->_pNativeCanvas->DrawTriangle(vcPoint1, vcPoint2, vcPoint3); + } + } + + template + static result FillTriangle(_CanvasImpl* pThis, const Color& color, const _Util::Point& vcPoint1, const _Util::Point& vcPoint2, const _Util::Point& vcPoint3) + { + typedef T Type; + + if (_ResUtil::NeedToConvertCoord()) + { + _Util::Point pcPoint1 = _ResUtil::ConvertToPhyCoord(vcPoint1); + _Util::Point pcPoint2 = _ResUtil::ConvertToPhyCoord(vcPoint2); + _Util::Point pcPoint3 = _ResUtil::ConvertToPhyCoord(vcPoint3); + + return pThis->_pNativeCanvas->FillTriangle(color, pcPoint1, pcPoint2, pcPoint3); + } + else + { + return pThis->_pNativeCanvas->FillTriangle(color, vcPoint1, vcPoint2, vcPoint3); + } + } + + template + static result DrawLine(_CanvasImpl* pThis, const _Util::Point& vcPoint1, const _Util::Point& vcPoint2) + { + typedef T Type; + + if (_ResUtil::NeedToConvertCoord()) + { + _Util::Point pcPoint1 = _ResUtil::ConvertToPhyCoord(vcPoint1); + _Util::Point pcPoint2 = _ResUtil::ConvertToPhyCoord(vcPoint2); + + return pThis->_pNativeCanvas->DrawLine(pcPoint1, pcPoint2); + } + else + { + return pThis->_pNativeCanvas->DrawLine(vcPoint1, vcPoint2); + } + } +}; + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_CANVASIMPL_PRIVATE_H_ diff --git a/src/graphics/FGrp_CanvasPixman.cpp b/src/graphics/FGrp_CanvasPixman.cpp new file mode 100644 index 0000000..0f9181e --- /dev/null +++ b/src/graphics/FGrp_CanvasPixman.cpp @@ -0,0 +1,348 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasPixman.cpp + * @brief This is the implementation file for the pixman solution. + * + */ + +#include + +#include "FGrp_CanvasPixman.h" +#include "util/FGrp_UtilTemplate.h" + + +namespace Tizen { namespace Graphics +{ + +namespace _Util +{ + +template <> +AutoDeletor::~AutoDeletor(void) +{ + if (__pPtr) + { + pixman_image_unref(__pPtr); + } +} + +} // _Util + +namespace _Pixman +{ + +pixman_op_t GetRop(Tizen::Graphics::BlendingMode blendingMode) +{ + switch (blendingMode) + { + case BLENDING_MODE_CLEAR: + return PIXMAN_OP_CLEAR; + case BLENDING_MODE_SRC: + return PIXMAN_OP_SRC; + case BLENDING_MODE_DST: + return PIXMAN_OP_DST; + case BLENDING_MODE_SRC_OVER: + return PIXMAN_OP_OVER; + case BLENDING_MODE_DST_OVER: + return PIXMAN_OP_OVER_REVERSE; + case BLENDING_MODE_SRC_IN: + return PIXMAN_OP_IN; + case BLENDING_MODE_DST_IN: + return PIXMAN_OP_IN_REVERSE; + case BLENDING_MODE_SRC_OUT: + return PIXMAN_OP_OUT; + case BLENDING_MODE_DST_OUT: + return PIXMAN_OP_OUT_REVERSE; + case BLENDING_MODE_SRC_ATOP: + return PIXMAN_OP_ATOP; + case BLENDING_MODE_DST_ATOP: + return PIXMAN_OP_ATOP_REVERSE; + case BLENDING_MODE_DST_XOR: + return PIXMAN_OP_XOR; + case BLENDING_MODE_ADD: + return PIXMAN_OP_ADD; + case BLENDING_MODE_SATURATE: + return PIXMAN_OP_SATURATE; + case BLENDING_MODE_MULTIPLY: + return PIXMAN_OP_MULTIPLY; + case BLENDING_MODE_SCREEN: + return PIXMAN_OP_SCREEN; + case BLENDING_MODE_OVERLAY: + return PIXMAN_OP_OVERLAY; + case BLENDING_MODE_DARKEN: + return PIXMAN_OP_DARKEN; + case BLENDING_MODE_LIGHTEN: + return PIXMAN_OP_LIGHTEN; + case BLENDING_MODE_COLOR_DODGE: + return PIXMAN_OP_COLOR_DODGE; + case BLENDING_MODE_COLOR_BURN: + return PIXMAN_OP_COLOR_BURN; + case BLENDING_MODE_HARD_LIGHT: + return PIXMAN_OP_HARD_LIGHT; + case BLENDING_MODE_SOFT_LIGHT: + return PIXMAN_OP_SOFT_LIGHT; + case BLENDING_MODE_DIFFERENCE: + return PIXMAN_OP_DIFFERENCE; + case BLENDING_MODE_EXCLUSION: + return PIXMAN_OP_EXCLUSION; + default: + return PIXMAN_OP_SRC; + } +} + +pixman_filter_t GetFilter(BitmapDrawingQuality drawingQuality) +{ + switch (drawingQuality) + { + case Tizen::Graphics::BITMAP_DRAWING_QUALITY_HIGH: + return PIXMAN_FILTER_BEST; + case Tizen::Graphics::BITMAP_DRAWING_QUALITY_MID: + return PIXMAN_FILTER_GOOD; + default: + return PIXMAN_FILTER_FAST; + } +} + +pixman_filter_t GetFilter(BitmapScalingQuality scalingQuality) +{ + switch (scalingQuality) + { + case Tizen::Graphics::BITMAP_SCALING_QUALITY_HIGH: + return PIXMAN_FILTER_BEST; + case Tizen::Graphics::BITMAP_SCALING_QUALITY_MID: + return PIXMAN_FILTER_GOOD; + default: + return PIXMAN_FILTER_FAST; + } +} + +pixman_transform_t GetTransform(int xDest, int yDest, double degree, int xPivot, int yPivot) +{ + pixman_transform_t transform; + + double c = cos(degree * 3.141592 / 180.0); + double s = sin(degree * 3.141592 / 180.0); + + pixman_transform_init_identity(&transform); + + pixman_transform_translate(&transform, NULL, pixman_int_to_fixed(-xDest), pixman_int_to_fixed(-yDest)); + pixman_transform_rotate(&transform, NULL, pixman_double_to_fixed(c), pixman_double_to_fixed(s)); + pixman_transform_translate(&transform, NULL, pixman_int_to_fixed(xPivot), pixman_int_to_fixed(yPivot)); + + return transform; +} + +pixman_transform_t GetTransform(int srcWidth, int srcHeight, int dstWidth, int dstHeight) +{ + pixman_transform_t transform; + + pixman_transform_init_scale(&transform, 65536 * srcWidth / dstWidth, 65536 * srcHeight / dstHeight); + + return transform; +} + +bool ResizePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, pixman_filter_t filter) +{ + Tizen::Graphics::_Util::AutoDeletor pPixmanDst; + + switch (dstImage.depth) + { + case 16: + pPixmanDst.Bind(pixman_image_create_bits(PIXMAN_r5g6b5, dstImage.width, dstImage.height, (uint32_t*)dstImage.pBitmap, dstImage.bytesPerLine)); + break; + case 32: + pPixmanDst.Bind(pixman_image_create_bits(PIXMAN_a8r8g8b8, dstImage.width, dstImage.height, (uint32_t*)dstImage.pBitmap, dstImage.bytesPerLine)); + break; + default: + return false; + } + + if (pPixmanDst) + { + Tizen::Graphics::_Util::AutoDeletor pPixmanSrc; + + switch (srcImage.depth) + { + case 16: + // color key is not supporting + pPixmanSrc.Bind(pixman_image_create_bits(PIXMAN_r5g6b5, srcImage.width, srcImage.height, (uint32_t*)srcImage.pBitmap, srcImage.bytesPerLine)); + break; + case 32: + pPixmanSrc.Bind(pixman_image_create_bits(PIXMAN_a8r8g8b8, srcImage.width, srcImage.height, (uint32_t*)srcImage.pBitmap, srcImage.bytesPerLine)); + break; + default: + return false; + } + + if (pPixmanSrc) + { + pixman_transform_t transform = Tizen::Graphics::_Pixman::GetTransform(srcImage.width, srcImage.height, dstImage.width, dstImage.height); + + pixman_image_set_transform(pPixmanSrc, &transform); + + pixman_image_set_filter(pPixmanSrc, filter, NULL, 0); + + pixman_image_composite32(PIXMAN_OP_SRC, pPixmanSrc, 0, pPixmanDst, 0, 0, 0, 0, 0, 0, dstImage.width, dstImage.height); + + return true; + } + } + + return false; +} + +bool CompositePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, pixman_op_t rop, pixman_filter_t filter, pixman_transform_t transform, pixman_repeat_t repeatMethod) +{ + Tizen::Graphics::_Util::AutoDeletor pPixmanDst; + + switch (dstImage.depth) + { + case 16: + pPixmanDst.Bind(pixman_image_create_bits(PIXMAN_r5g6b5, dstImage.width, dstImage.height, (uint32_t*)dstImage.pBitmap, dstImage.bytesPerLine)); + break; + case 32: + pPixmanDst.Bind(pixman_image_create_bits(PIXMAN_a8r8g8b8, dstImage.width, dstImage.height, (uint32_t*)dstImage.pBitmap, dstImage.bytesPerLine)); + break; + default: + return false; + } + + if (pPixmanDst) + { + std::auto_ptr premultipliedSrcImage; + + Tizen::Graphics::_Util::AutoDeletor pPixmanMsk; + Tizen::Graphics::_Util::AutoDeletor pPixmanSrc; + + switch (srcImage.depth) + { + case 16: + // color key is not supporting + pPixmanSrc.Bind(pixman_image_create_bits(PIXMAN_r5g6b5, srcImage.width, srcImage.height, (uint32_t*)srcImage.pBitmap, srcImage.bytesPerLine)); + break; + case 32: + if (srcImage.isPremultiplied || rop == PIXMAN_OP_SRC) + { + pPixmanSrc.Bind(pixman_image_create_bits(PIXMAN_a8r8g8b8, srcImage.width, srcImage.height, (uint32_t*)srcImage.pBitmap, srcImage.bytesPerLine)); + } + else + { + premultipliedSrcImage.reset(srcImage.GetPremultipliedPixmap()); + + if (premultipliedSrcImage.get()) + { + pPixmanSrc.Bind(pixman_image_create_bits(PIXMAN_a8r8g8b8, premultipliedSrcImage->width, premultipliedSrcImage->height, (uint32_t*)premultipliedSrcImage->pBitmap, premultipliedSrcImage->bytesPerLine)); + } + else + { + // slow but it does not create additional buffer + pPixmanSrc.Bind(pixman_image_create_bits(PIXMAN_x8r8g8b8, srcImage.width, srcImage.height, (uint32_t*)srcImage.pBitmap, srcImage.bytesPerLine)); + pPixmanMsk.Bind(pixman_image_create_bits(PIXMAN_a8r8g8b8, srcImage.width, srcImage.height, (uint32_t*)srcImage.pBitmap, srcImage.bytesPerLine)); + + if (pPixmanMsk == null) + { + return false; + } + } + } + break; + default: + return false; + } + + if (pPixmanSrc) + { + pixman_image_set_transform(pPixmanSrc, &transform); + + if (pPixmanMsk) + { + pixman_image_set_transform(pPixmanMsk, &transform); + } + + pixman_image_set_filter(pPixmanSrc, filter, NULL, 0); + pixman_image_set_repeat(pPixmanSrc, repeatMethod); + + pixman_image_composite32(rop, pPixmanSrc, pPixmanMsk, pPixmanDst, 0, 0, 0, 0, 0, 0, dstImage.width, dstImage.height); + + return true; + } + } + + return false; +} + +bool ResizePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapScalingQuality scalingQuality) +{ + if (dstImage.width <= 0 || dstImage.height <= 0) + { + return true; + } + + pixman_filter_t filter = Tizen::Graphics::_Pixman::GetFilter(scalingQuality); + + return ResizePixmap(dstImage, srcImage, filter); +} + +bool CopyPixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapDrawingQuality drawingQuality, Tizen::Graphics::BlendingMode blendingMode) +{ + if (dstImage.width <= 0 || dstImage.height <= 0) + { + return true; + } + + pixman_op_t rop = Tizen::Graphics::_Pixman::GetRop(blendingMode); + + pixman_filter_t filter = Tizen::Graphics::_Pixman::GetFilter(drawingQuality); + + pixman_transform_t transform; + pixman_transform_init_identity(&transform); + + return CompositePixmap(dstImage, srcImage, rop, filter, transform, PIXMAN_REPEAT_NONE); +} + +bool ScalePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapDrawingQuality drawingQuality, Tizen::Graphics::BlendingMode blendingMode) +{ + if (dstImage.width <= 0 || dstImage.height <= 0) + { + return true; + } + + pixman_op_t rop = Tizen::Graphics::_Pixman::GetRop(blendingMode); + pixman_filter_t filter = Tizen::Graphics::_Pixman::GetFilter(drawingQuality); + pixman_transform_t transform = Tizen::Graphics::_Pixman::GetTransform(srcImage.width, srcImage.height, dstImage.width, dstImage.height); + + return CompositePixmap(dstImage, srcImage, rop, filter, transform, PIXMAN_REPEAT_NORMAL); +} + +bool RotatePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapDrawingQuality drawingQuality, int xDest, int yDest, double degree, int xPivot, int yPivot) +{ + if (dstImage.width <= 0 || dstImage.height <= 0) + { + return true; + } + + pixman_filter_t filter = Tizen::Graphics::_Pixman::GetFilter(drawingQuality); + pixman_transform_t transform = Tizen::Graphics::_Pixman::GetTransform(xDest, yDest, degree, xPivot, yPivot); + + return CompositePixmap(dstImage, srcImage, PIXMAN_OP_OVER, filter, transform, PIXMAN_REPEAT_NONE); +} + +} // _Pixman + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_CanvasPixman.h b/src/graphics/FGrp_CanvasPixman.h new file mode 100644 index 0000000..9005acb --- /dev/null +++ b/src/graphics/FGrp_CanvasPixman.h @@ -0,0 +1,56 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasPixman.h + * @brief This is the header file for the pixman solution. + * + */ + +#ifndef _FGRP_INTERNAL_CANVASPIXMAN_H_ +#define _FGRP_INTERNAL_CANVASPIXMAN_H_ + +#include + +#include "FGrp_CanvasImpl.h" +#include "FGrpBitmapCommon.h" +#include "util/FGrp_UtilPixmap.h" + + +namespace Tizen { namespace Graphics +{ + +namespace _Pixman +{ + +bool +CopyPixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapDrawingQuality drawingQuality, Tizen::Graphics::BlendingMode blendingMode); + +bool +ScalePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapDrawingQuality drawingQuality, Tizen::Graphics::BlendingMode blendingMode = BLENDING_MODE_SRC_OVER); + +bool +ResizePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapScalingQuality scalingQuality); + +bool +RotatePixmap(Tizen::Graphics::_Util::Pixmap& dstImage, const Tizen::Graphics::_Util::Pixmap& srcImage, Tizen::Graphics::BitmapDrawingQuality drawingQuality, int xDest, int yDest, double degree, int xPivot, int yPivot); + +} // Tizen::Graphics::_Pixman + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_CANVASPIXMAN_H_ diff --git a/src/graphics/FGrp_CanvasRasterOp.cpp b/src/graphics/FGrp_CanvasRasterOp.cpp new file mode 100644 index 0000000..f92364e --- /dev/null +++ b/src/graphics/FGrp_CanvasRasterOp.cpp @@ -0,0 +1,225 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasRasterOp.cpp + * @brief This is the implementation file for set of raster operation. + * + */ + +#include "FGrp_CanvasRasterOp.h" +#include "util/FGrp_UtilTemplate.h" + + +namespace Tizen { namespace Graphics +{ + +namespace _RasterOp +{ + +// 'Add' rule is more intuitive for 32-bit alpha +template +inline T +_BlendAlphaComponentAdd(T srcA, T dstA) +{ + return _Util::Min(srcA + dstA, 0xFF); +} + +template +inline T +_BlendAlphaComponentAddEx(T srcA, T dstA) +{ + return _Util::Min(srcA + dstA - ((srcA * dstA) >> 8), 0xFF); +} + +void +FnFillRectAlpha32Bit(unsigned long* pDest32, int w, int h, int pitch, unsigned long color, unsigned long opacity) +{ + typedef unsigned long Pixel; + + opacity += (opacity >> 7); + opacity = ((opacity * (color >> 24)) << 16) & 0xFF000000; + + color &= 0x00FFFFFF; + + if (opacity >= 0xFF000000) + { + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + *pDest32++ = Pixel((color & 0x00FFFFFF) | opacity); + } + + pDest32 += (pitch - w); + } + } + else if (opacity > 0) + { + Pixel srcA = opacity >> 24; + Pixel srcR = color & 0x00FF0000; + Pixel srcG = color & 0x0000FF00; + Pixel srcB = color & 0x000000FF; + + srcA += (srcA >> 7); + + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + Pixel dstA = (*pDest32 & 0xFF000000) >> 24; + Pixel dstR = *pDest32 & 0x00FF0000; + Pixel dstG = *pDest32 & 0x0000FF00; + Pixel dstB = *pDest32 & 0x000000FF; + + dstA = _BlendAlphaComponentAdd(srcA, dstA); + dstR = (dstR + (((srcR - dstR) * srcA) >> 8)) & 0x00FF0000; + dstG = (dstG + (((srcG - dstG) * srcA) >> 8)) & 0x0000FF00; + dstB = (dstB + (((srcB - dstB) * srcA) >> 8)) & 0x000000FF; + dstA = (dstA > 0xFF) ? 0xFF : dstA; + + *pDest32++ = (dstA << 24) | dstR | dstG | dstB; + } + + pDest32 += (pitch - w); + } + } +} + +void +FnFillRectFont32Bit(unsigned long* pDest32, int w, int h, int pitch, unsigned long color, unsigned long opacity) +{ + typedef unsigned long Pixel; + + Pixel srcR = (color >> 16) & 0xFF; + Pixel srcG = (color >> 8) & 0xFF; + Pixel srcB = (color) & 0xFF; + Pixel alpha = (color >> 24) & 0xFF; + + alpha += (alpha >> 7); + alpha = (alpha * opacity) >> 8; + alpha += (alpha >> 7); + + if (alpha > 0) + { + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + Pixel dstA = (*pDest32 >> 24) & 0xFF; + Pixel dstR = (*pDest32 >> 16) & 0xFF; + Pixel dstG = (*pDest32 >> 8) & 0xFF; + Pixel dstB = (*pDest32) & 0xFF; + + dstA = _BlendAlphaComponentAddEx(alpha, dstA); + dstR = (dstR + (((srcR - dstR) * alpha) >> 8)) & 0xFF; + dstG = (dstG + (((srcG - dstG) * alpha) >> 8)) & 0xFF; + dstB = (dstB + (((srcB - dstB) * alpha) >> 8)) & 0xFF; + + *pDest32++ = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + } + + pDest32 += (pitch - w); + } + } +} + +void +FnBitBltFont32Bit(unsigned long* pDest32, int w, int h, int pitch, unsigned long* pSour08, int imagePitch, unsigned long opacity, + _Util::ColorKey srcColorKey) +{ + typedef unsigned long TPixel; + + TPixel srcR; + TPixel srcG; + TPixel srcB; + TPixel alpha; + + TPixel dstR; + TPixel dstG; + TPixel dstB; + + srcR = (opacity >> 16) & 0xFF; + srcG = (opacity >> 8) & 0xFF; + srcB = (opacity) & 0xFF; + + { + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + alpha = *pSour08++; + + if (alpha) + { + dstR = (*pDest32 >> 16) & 0xFF; + dstG = (*pDest32 >> 8) & 0xFF; + dstB = (*pDest32) & 0xFF; + + dstR = (dstR + (((srcR - dstR) * alpha) >> 8)) & 0xFF; + dstG = (dstG + (((srcG - dstG) * alpha) >> 8)) & 0xFF; + dstB = (dstB + (((srcB - dstB) * alpha) >> 8)) & 0xFF; + + *pDest32++ = 0xFF000000 | (dstR << 16) | (dstG << 8) | dstB; + + continue; + } + + ++pDest32; + } + + pDest32 += (pitch - w); + pSour08 += (imagePitch - w); + } + } +} + +void +FnBitBlt32BitCopyReverse(unsigned long* pDest32, int w, int h, int pitch, unsigned long* pSour32, int imagePitch, + unsigned long opacity, + _Util::ColorKey srcColorKey) +{ + // opacity and srcColorKey should be ignored + + pSour32 += (imagePitch * h + w - 1); + pDest32 += (pitch * h + w - 1); + + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + *pDest32-- = *pSour32--; + } + + pDest32 -= (pitch - w); + pSour32 -= (imagePitch - w); + } +} + +} // _RasterOp + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_CanvasRasterOp.h b/src/graphics/FGrp_CanvasRasterOp.h new file mode 100644 index 0000000..89d40aa --- /dev/null +++ b/src/graphics/FGrp_CanvasRasterOp.h @@ -0,0 +1,44 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasRasterOp.h + * @brief This is the header file for the set of raster operation. + * + */ + +#ifndef _FGRP_INTERNAL_CANVASRASTEROP_H_ +#define _FGRP_INTERNAL_CANVASRASTEROP_H_ + +#include "util/FGrp_UtilScratchpad.h" + + +namespace Tizen { namespace Graphics +{ + +namespace _RasterOp +{ +void FnFillRectAlpha32Bit(unsigned long* pDest32, int w, int h, int pitch, unsigned long color, unsigned long opacity); +void FnFillRectFont32Bit(unsigned long* pDest32, int w, int h, int pitch, unsigned long color, unsigned long opacity); +void FnBitBltFont32Bit(unsigned long* pDest32, int w, int h, int pitch, unsigned long* pSour08, int imagePitch, unsigned long opacity, _Util::ColorKey srcColorKey); +void FnBitBlt32BitCopyReverse(unsigned long* pDest32, int w, int h, int pitch, unsigned long* pSour32, int imagePitch, unsigned long opacity, _Util::ColorKey srcColorKey); + +} // Tizen::Graphics::_RasterOp + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_CANVASRASTEROP_H_ diff --git a/src/graphics/FGrp_CanvasShow.cpp b/src/graphics/FGrp_CanvasShow.cpp new file mode 100644 index 0000000..955eca5 --- /dev/null +++ b/src/graphics/FGrp_CanvasShow.cpp @@ -0,0 +1,184 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasShow.cpp + * @brief This is the implementation file for internal Canvas class. + * + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "FGrp_Callback.h" + +#include + + +namespace Tizen { namespace Graphics +{ + +void +_FlushCanvas(void) +{ + Ecore_Evas* pEcoreEvas = static_cast(_GetDefaultFrameEcoreEvasHandle()); + + if (pEcoreEvas) + { + ecore_evas_manual_render(pEcoreEvas); + } +} + +bool +_CanvasShowFromMemory(int xDest, int yDest, int xSour, int ySour, int wSour, int hSour, void* pMemory, int width, int height, + int depth, + int bytesPerLine) +{ + // check input parameter + { + switch (depth) + { + case 32: + break; + case 16: + default: + return false; + } + // pBuffer should be NULL pointer + if (pMemory == null || width <= 0 || height <= 0) + { + return false; + } + } + + Ecore_Evas* pEcoreEvas = static_cast(_GetDefaultFrameEcoreEvasHandle()); + + if (pEcoreEvas == null) + { + return false; + } + + int xSrc = 0; + int ySrc = 0; + + Display* pHdisplay = XOpenDisplay(NULL); + int displayWidth = DisplayWidth(pHdisplay, DefaultScreen(pHdisplay)); + int displayHeight = DisplayHeight(pHdisplay, DefaultScreen(pHdisplay)); + + //Window root = RootWindow(pHdisplay, DefaultScreen(pHdisplay)); + Window root = (Window) ecore_evas_window_get(pEcoreEvas); + + XShmSegmentInfo shmInfo; + XImage* pXimage = XShmCreateImage(pHdisplay, DefaultVisualOfScreen(DefaultScreenOfDisplay(pHdisplay)), 24, ZPixmap, + NULL, &shmInfo, (unsigned int) displayWidth, (unsigned int) displayHeight); + if (pXimage == NULL) + { + goto CLEAN_UP; + } + + // EAPI void ecore_evas_comp_sync_set(Ecore_Evas *ee, Eina_Bool do_sync); + ecore_evas_comp_sync_set(pEcoreEvas, EINA_FALSE); + + shmInfo.shmid = shmget(IPC_PRIVATE, pXimage->bytes_per_line * pXimage->height, IPC_CREAT | 0777); + + pXimage->data = (char*) shmat(shmInfo.shmid, 0, 0); + shmInfo.shmaddr = pXimage->data; + shmInfo.readOnly = False; + + // copy to image buffer + { + typedef unsigned long Pixel; + + Pixel* pSrc = reinterpret_cast (pMemory); + Pixel* pDst = reinterpret_cast (pXimage->data); + int srcPitch = (bytesPerLine * 8 / depth); + int dstPitch = (pXimage->bytes_per_line * 8 / depth); + + for (int y = 0; y < height; y++) + { + memcpy(pDst, pSrc, width * sizeof(Pixel)); + pSrc += srcPitch; + pDst += dstPitch; + } + } + + if (!XShmAttach(pHdisplay, &shmInfo)) + { + goto CLEAN_UP; + } + + XShmPutImage(pHdisplay, root, DefaultGCOfScreen(DefaultScreenOfDisplay(pHdisplay)), + pXimage, + xSrc, ySrc, xDest, yDest, width, height, false); + + XSync(pHdisplay, False); + + ecore_evas_comp_sync_set(pEcoreEvas, EINA_TRUE); + + // release the captured buffer + { + XShmDetach(pHdisplay, &shmInfo); + shmdt(shmInfo.shmaddr); + shmctl(shmInfo.shmid, IPC_RMID, NULL); + + XDestroyImage(pXimage); + pXimage = NULL; + + XCloseDisplay(pHdisplay); + } + + // no effect yet + { + Evas* pEvas = static_cast(_GetDefaultFrameEvasHandle()); + + if (pEvas) + { + evas_object_image_pixels_dirty_set((Evas_Object*) pEvas, true); + evas_object_show((Evas_Object*) pEvas); + } + } + + return true; + +CLEAN_UP: + if (pXimage) + { + XShmDetach(pHdisplay, &shmInfo); + shmdt(shmInfo.shmaddr); + shmctl(shmInfo.shmid, IPC_RMID, NULL); + + XDestroyImage(pXimage); + pXimage = NULL; + } + + XCloseDisplay(pHdisplay); + + return false; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_CoordinateSystem.cpp b/src/graphics/FGrp_CoordinateSystem.cpp new file mode 100644 index 0000000..d9043db --- /dev/null +++ b/src/graphics/FGrp_CoordinateSystem.cpp @@ -0,0 +1,466 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CoordinateSystem.cpp + * @brief This is the implementation file for _CoordinateSystem class. + * + */ + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "FGrp_CoordinateSystem.h" +#include "FGrp_CoordinateSystemImpl.h" +#include "FGrp_Screen.h" + +using namespace Tizen::Base; + + +namespace Tizen { namespace Graphics +{ + +_CoordinateSystem _CoordinateSystem::__instance; +_CoordinateSystem* _CoordinateSystem::__pTheInstance = null; + + +void +_CoordinateSystem::__InitCoordinateSystem(void) +{ + if (__instance.__pImpl == null) + { + result r = __instance.__Initialize(_Screen::GetWidth(), BASE_SCREEN_SIZE_DEFAULT, Dimension(_Screen::GetWidth(), _Screen::GetHeight()), BASE_SCREEN_SIZE_DEFAULT); + + SysAssertf(!IsFailed(r), "[%s] Propagating.", GetErrorMessage(r)); + } + + __pTheInstance = &__instance; +} + +_CoordinateSystem* +_CoordinateSystem::GetInstance(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (__pTheInstance == null) + { + pthread_once(&once_block, __InitCoordinateSystem); + } + + return __pTheInstance; +} + +void +_CoordinateSystem::SetTransformEnabled(bool enabled) +{ + result r = E_SUCCESS; + + SysTryCatch(NID_GRP, __pImpl, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance has not been initialized yet."); + + __pImpl->SetTransformEnabled(enabled); + +CATCH: + SetLastResult(r); +} + +bool +_CoordinateSystem::IsTransformEnabled(void) const +{ + result r = E_SUCCESS; + + SysTryCatch(NID_GRP, __pImpl, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance has not been initialized yet."); + + return __pImpl->IsTransformEnabled(); + +CATCH: + SetLastResult(r); + + return false; +} + +_ICoordinateSystemTransformer* +_CoordinateSystem::GetTransformer(void) +{ + result r = E_SUCCESS; + + SysTryCatch(NID_GRP, __pImpl, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance has not been initialized yet."); + + return __pImpl->GetTransformer(); + +CATCH: + SetLastResult(r); + + return null; +} + +_ICoordinateSystemTransformer* +_CoordinateSystem::GetInverseTransformer(void) +{ + result r = E_SUCCESS; + SysTryCatch(NID_GRP, __pImpl, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance has not been initialized yet."); + + return __pImpl->GetInverseTransformer(); + +CATCH: + SetLastResult(r); + + return null; +} + +_ICoordinateSystemTransformer* +_CoordinateSystem::GetTransformerN(const Dimension& srcDim, const Dimension& trgDim) +{ + _ICoordinateSystemTransformer* pXformer = _CoordinateSystemImpl::GetTransformerN(srcDim, trgDim); + + if (pXformer == null) + { + result r = GetLastResult(); + + SysLog(NID_GRP, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pXformer; +} + +_ICoordinateSystemTransformer* +_CoordinateSystem::GetTransformerN(int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize) +{ + _ICoordinateSystemTransformer* pXformer = _CoordinateSystemImpl::GetTransformerN(srcResolution, srcBaseScreenSize, destResolution, destBaseScreenSize); + + if (pXformer == null) + { + result r = GetLastResult(); + + SysLog(NID_GRP, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pXformer; +} + + +_ICoordinateSystemTransformer* +_CoordinateSystem::GetTransformerN(_LogicalResolution logicalResolution, _PhysicalResolution physicalResolution) +{ + _ICoordinateSystemTransformer* pXformer = _CoordinateSystemImpl::GetTransformerN(logicalResolution, BASE_SCREEN_SIZE_NORMAL, physicalResolution, BASE_SCREEN_SIZE_NORMAL); + + if (pXformer == null) + { + result r = GetLastResult(); + + SysLog(NID_GRP, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pXformer; +} + +_ICoordinateSystemTransformer* +_CoordinateSystem::GetTransformerN(_LogicalResolution sourceLogicalResolution, _LogicalResolution destLogicalResolution) +{ + _PhysicalResolution physicalResolution = RESOLUTION_PHYSICAL_DEFAULT; + + switch (destLogicalResolution) + { + case RESOLUTION_LOGICAL_240: + physicalResolution = RESOLUTION_PHYSICAL_WQVGA; + break; + case RESOLUTION_LOGICAL_320: + physicalResolution = RESOLUTION_PHYSICAL_HVGA; + break; + case RESOLUTION_LOGICAL_480: + physicalResolution = RESOLUTION_PHYSICAL_WVGA; + break; + case RESOLUTION_LOGICAL_720: + physicalResolution = RESOLUTION_PHYSICAL_HD; + break; + case RESOLUTION_LOGICAL_800: + physicalResolution = RESOLUTION_PHYSICAL_WXGA; + break; + case RESOLUTION_LOGICAL_1080: + physicalResolution = RESOLUTION_PHYSICAL_HD1080; + break; + case RESOLUTION_LOGICAL_1600: + physicalResolution = RESOLUTION_PHYSICAL_WQXGA; + break; + default: + physicalResolution = RESOLUTION_PHYSICAL_NONE; + break; + } + + return _CoordinateSystem::GetTransformerN(sourceLogicalResolution, physicalResolution); +} + +_ICoordinateSystemTransformer* +_CoordinateSystem::GetTransformerN(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize, _PhysicalResolution physicalResolution, _BaseScreenSize physicalBaseScreenSize) +{ + _ICoordinateSystemTransformer* pXformer = _CoordinateSystemImpl::GetTransformerN(logicalResolution, logicalBaseScreenSize, physicalResolution, physicalBaseScreenSize); + + if (pXformer == null) + { + result r = GetLastResult(); + + SysLog(NID_GRP, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pXformer; +} + + +_CoordinateSystem::_CoordinateSystem(void) + : __pImpl(null) +{ +} + +_CoordinateSystem::~_CoordinateSystem(void) +{ + delete __pImpl; +} + +result +_CoordinateSystem::Initialize(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize) +{ + _CoordinateSystem* pInstance = _CoordinateSystem::GetInstance(); + + result r = pInstance->__Initialize(logicalResolution, logicalBaseScreenSize); + + SysTryReturn(NID_GRP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_CoordinateSystem::Initialize(int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize) +{ + _CoordinateSystem* pInstance = _CoordinateSystem::GetInstance(); + + result r = pInstance->__Initialize(srcResolution, srcBaseScreenSize, destResolution, destBaseScreenSize); + + SysTryReturn(NID_GRP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_CoordinateSystem::Reset(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize) +{ + result r = E_SUCCESS; + + std::auto_ptr<_CoordinateSystemImpl> pImpl(new _CoordinateSystemImpl()); + + SysTryReturnResult(NID_GRP, pImpl.get() != null, E_OUT_OF_MEMORY, "Insufficient memory."); + + r = pImpl->Initialize(logicalResolution, logicalBaseScreenSize); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pImpl; + __pImpl = pImpl.release(); + + return E_SUCCESS; +} + +result +_CoordinateSystem::Reset(int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize) +{ + result r = E_SUCCESS; + + std::auto_ptr<_CoordinateSystemImpl> pImpl(new _CoordinateSystemImpl()); + + SysTryReturnResult(NID_GRP, pImpl.get() != null, E_OUT_OF_MEMORY, "Insufficient memory."); + + r = pImpl->Initialize(srcResolution, srcBaseScreenSize, destResolution, destBaseScreenSize); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pImpl; + __pImpl = pImpl.release(); + + return E_SUCCESS; +} + +_LogicalResolution +_CoordinateSystem::GetNativeLogicalResolution(void) const +{ + result r = E_SUCCESS; + + SysTryCatch(NID_GRP, __pImpl, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance has not been initialized yet."); + + return __pImpl->GetNativeLogicalResolution(); + +CATCH: + SetLastResult(r); + + return RESOLUTION_LOGICAL_NONE; +} + +_BaseScreenSize +_CoordinateSystem::GetNativeLogicalBaseScreenSize(void) const +{ + result r = E_SUCCESS; + + SysTryCatch(NID_GRP, __pImpl, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance has not been initialized yet."); + + return __pImpl->GetNativeLogicalBaseScreenSize(); + +CATCH: + SetLastResult(r); + + return BASE_SCREEN_SIZE_NONE; +} + +_BaseScreenSize +_CoordinateSystem::GetLogicalBaseScreenSize(void) const +{ + result r = E_SUCCESS; + + SysTryCatch(NID_GRP, __pImpl, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance has not been initialized yet."); + + return __pImpl->GetLogicalBaseScreenSize(); + +CATCH: + SetLastResult(r); + + return BASE_SCREEN_SIZE_NONE; +} + +int +_CoordinateSystem::GetLogicalResolutionInt(void) const +{ + result r = E_SUCCESS; + + SysTryCatch(NID_GRP, __pImpl, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance has not been initialized yet."); + + return __pImpl->GetLogicalResolutionInt(); + +CATCH: + SetLastResult(r); + + return 0; +} + +_LogicalResolution +_CoordinateSystem::GetLogicalResolution(void) const +{ + result r = E_SUCCESS; + + SysTryCatch(NID_GRP, __pImpl, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance has not been initialized yet."); + + return __pImpl->GetLogicalResolution(); + +CATCH: + SetLastResult(r); + + return RESOLUTION_LOGICAL_NONE; +} + +_PhysicalResolution +_CoordinateSystem::GetPhysicalResolution(void) const +{ + result r = E_SUCCESS; + + SysTryCatch(NID_GRP, __pImpl, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance has not been initialized yet."); + + return __pImpl->GetPhysicalResolution(); + +CATCH: + SetLastResult(r); + + return RESOLUTION_PHYSICAL_NONE; +} + +Dimension +_CoordinateSystem::GetPhysicalResolutionDim(void) const +{ + result r = E_SUCCESS; + + SysTryCatch(NID_GRP, __pImpl, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance has not been initialized yet."); + + return __pImpl->GetPhysicalResolutionDim(); + +CATCH: + SetLastResult(r); + + return Dimension(0,0); +} + +_BaseScreenSize +_CoordinateSystem::GetPhysicalBaseScreenSize(void) const +{ + result r = E_SUCCESS; + + SysTryCatch(NID_GRP, __pImpl, r = E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance has not been initialized yet."); + + return __pImpl->GetPhysicalBaseScreenSize(); + +CATCH: + SetLastResult(r); + + return BASE_SCREEN_SIZE_NONE; +} + +result +_CoordinateSystem::__Initialize(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize) +{ + result r = Reset(logicalResolution, logicalBaseScreenSize); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_CoordinateSystem::__Initialize(int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize) +{ + result r = Reset(srcResolution, srcBaseScreenSize, destResolution, destBaseScreenSize); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +}} // Tizen::Graphics + +// temporary test code for tizen 2.0 +namespace Tizen { namespace Graphics +{ + +void +_SetLogicalRes480(void) +{ + _CoordinateSystem* pInstance = _CoordinateSystem::GetInstance(); + + pInstance->Reset(RESOLUTION_LOGICAL_480, BASE_SCREEN_SIZE_NORMAL); +} + +void +_SetLogicalRes720(void) +{ + _CoordinateSystem* pInstance = _CoordinateSystem::GetInstance(); + + pInstance->Reset(RESOLUTION_LOGICAL_720, BASE_SCREEN_SIZE_NORMAL); +} + +}} // Tizen::Graphics + + diff --git a/src/graphics/FGrp_CoordinateSystemDeviceSpec.cpp b/src/graphics/FGrp_CoordinateSystemDeviceSpec.cpp new file mode 100644 index 0000000..13116e3 --- /dev/null +++ b/src/graphics/FGrp_CoordinateSystemDeviceSpec.cpp @@ -0,0 +1,1683 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CoordinateSystemDeviceSpec.cpp + * @brief This is the implementation file for the internal class. + * + */ + +#include + +#include + +#include +#include +#include + +#include "FGrp_CoordinateSystem.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Graphics +{ + +namespace _Internal +{ + +template +struct Gcd +{ + enum + { + value = Gcd ::value + }; +}; + +template +struct Gcd +{ + enum + { + value = m + }; +}; + +template +struct SimpleScaler +{ + static int ScaleDisplacement(int srcVal); + static int ScaleLength(int srcVal); +}; + +template +struct Scaler +{ + enum + { + gcd = Gcd ::value, + simpleSrc = src / gcd, + simpleTrg = trg / gcd, + }; + + static int ScaleDisplacement(int srcVal) + { + return SimpleScaler ::ScaleDisplacement(srcVal); + } + + static int ScaleLength(int srcVal) + { + return SimpleScaler ::ScaleLength(srcVal); + } +}; + +template +struct Transformer + : public _ICoordinateSystemTransformer +{ + Transformer() + { + } + + virtual int TransformHorizontal(int width) const + { + return HScale::ScaleLength(width); + } + + virtual int TransformVertical(int height) const + { + return VScale::ScaleLength(height); + } + + virtual int Transform(int scalar) const + { + return VScale::ScaleLength(scalar); + } + + virtual float TransformHorizontal(float width) const + { + return GetHorizontalScaleFactor() * width; + } + + virtual float TransformVertical(float height) const + { + return GetVerticalScaleFactor() * height; + } + + virtual float Transform(float scalar) const + { + return GetVerticalScaleFactor() * scalar; + } + + virtual Point Transform(const Point& point) const + { + return Point(HScale::ScaleDisplacement(point.x), VScale::ScaleDisplacement(point.y)); + } + + virtual Dimension Transform(const Dimension& dim) const + { + return Dimension(HScale::ScaleLength(dim.width), VScale::ScaleLength(dim.height)); + } + + virtual Rectangle Transform(const Rectangle& rect) const + { + int x = HScale::ScaleDisplacement(rect.x); + int y = VScale::ScaleDisplacement(rect.y); + int w = HScale::ScaleLength(rect.width); + int h = VScale::ScaleLength(rect.height); + + if (Tizen::App::_AppInfo::GetApiVersion() <= _API_VERSION_1_2) + { + // From Osp API 2.0, 'Adjacent Algorithm' is not used any more. + w = HScale::ScaleDisplacement(rect.x + rect.width) - x; + h = VScale::ScaleDisplacement(rect.y + rect.height) - y; + } + + return Rectangle(x, y, w, h); + } + + virtual int TransformFloatToInt(float scalar) const + { + return VScale::ScaleLength(static_cast(scalar)); + } + + virtual int TransformHorizontalFloatToInt(float width) const + { + return HScale::ScaleLength(static_cast(width)); + } + + virtual int TransformVerticalFloatToInt(float height) const + { + return VScale::ScaleLength(static_cast(height)); + } + + virtual float GetHorizontalScaleFactor(void) const + { + const int TEST_VALUE = 1000000; + return float(HScale::ScaleLength(TEST_VALUE)) / float(TEST_VALUE); + } + + virtual float GetVerticalScaleFactor(void) const + { + const int TEST_VALUE = 1000000; + return float(VScale::ScaleLength(TEST_VALUE)) / float(TEST_VALUE); + } +}; + +template<> +struct SimpleScaler <1, 2> +{ + static int ScaleDisplacement(int srcVal) + { + return srcVal << 1; + } + + static int ScaleLength(int srcVal) + { + return srcVal << 1; + } +}; + +template<> +struct SimpleScaler <2, 1> +{ + static int ScaleDisplacement(int srcVal) + { + return srcVal >> 1; + } + + static int ScaleLength(int srcVal) + { + int isNotMinus = (srcVal >= 0); + + return (srcVal + 1 * isNotMinus) >> 1; + } +}; + +namespace // unnamed +{ + const long long MAX_INT = 0x7FFFFFFF; + const long long MIN_INT = -MAX_INT - 1; +} + +template<> +struct SimpleScaler <2, 3> +{ + static int ScaleDisplacement(int srcVal) + { + long long tempSrc = srcVal; + + if (tempSrc >= 0) + { + tempSrc = tempSrc * 3 / 2; + + return (tempSrc > MAX_INT) ? MAX_INT : int(tempSrc); + } + else + { + tempSrc = (tempSrc * 3 - 1) / 2; + + return (tempSrc < MIN_INT) ? MIN_INT : int(tempSrc); + } + } + + static int ScaleLength(int srcVal) + { + long long tempSrc = srcVal; + + if (tempSrc >= 0) + { + tempSrc = tempSrc * 3 / 2; + + return (tempSrc > MAX_INT) ? MAX_INT : int(tempSrc); + } + else + { + tempSrc = (tempSrc * 3 - 1) / 2; + + return (tempSrc < MIN_INT) ? MIN_INT : int(tempSrc); + } + } +}; + +template<> +struct SimpleScaler <3, 2> +{ + static int ScaleDisplacement(int srcVal) + { + long long tempSrc = srcVal; + + if (tempSrc > 0) + { + tempSrc = (tempSrc + 1) * 2 / 3; + + return (tempSrc > MAX_INT) ? MAX_INT : int(tempSrc); + } + else + { + tempSrc = tempSrc * 2 / 3; + + return (tempSrc < MIN_INT) ? MIN_INT : int(tempSrc); + } + } + + static int ScaleLength(int srcVal) + { + long long tempSrc = srcVal; + + if (tempSrc > 0) + { + tempSrc = (tempSrc + 1) * 2 / 3; + + return (tempSrc > 0x7FFFFFFF) ? 0x7FFFFFFF : int(tempSrc); + } + else + { + tempSrc = tempSrc * 2 / 3; + + return (tempSrc < MIN_INT) ? MIN_INT : int(tempSrc); + } + } +}; + +template<> +struct SimpleScaler <3, 4> +{ + static int ScaleDisplacement(int srcVal) + { + return (srcVal >= 0) ? (srcVal * 4 / 3) : ((srcVal * 4 - 1) / 3); + } + + static int ScaleLength(int srcVal) + { + return (srcVal >= 0) ? (srcVal * 4 / 3) : ((srcVal * 4 - 1) / 3); + } +}; + +template<> +struct SimpleScaler <4, 3> +{ + static int ScaleDisplacement(int srcVal) + { + return (srcVal > 0) ? ((srcVal + 1) * 3 / 4) : (srcVal * 3 / 4); + } + + static int ScaleLength(int srcVal) + { + return (srcVal > 0) ? ((srcVal + 1) * 3 / 4) : (srcVal * 3 / 4); + } +}; + +template<> +struct SimpleScaler <5, 6> +{ + static int ScaleDisplacement(int srcVal) + { + return (srcVal >= 0) ? (srcVal * 6 / 5) : ((srcVal * 6 - 1) / 5); + } + + static int ScaleLength(int srcVal) + { + return (srcVal >= 0) ? (srcVal * 6 / 5) : ((srcVal * 6 - 1) / 5); + } +}; + +template<> +struct SimpleScaler <6, 5> +{ + static int ScaleDisplacement(int srcVal) + { + return (srcVal > 0) ? ((srcVal + 1) * 5 / 6) : (srcVal * 5 / 6); + } + + static int ScaleLength(int srcVal) + { + return (srcVal > 0) ? ((srcVal + 1) * 5 / 6) : (srcVal * 5 / 6); + } +}; + +template<> +struct SimpleScaler <3, 5> +{ + static int ScaleDisplacement(int srcVal) + { + return (srcVal >= 0) ? (srcVal * 5 / 3) : ((srcVal * 5 - 1) / 3); + } + + static int ScaleLength(int srcVal) + { + return (srcVal >= 0) ? (srcVal * 5 / 3) : ((srcVal * 5 - 1) / 3); + } +}; + +template<> +struct SimpleScaler <5, 3> +{ + static int ScaleDisplacement(int srcVal) + { + return (srcVal > 0) ? ((srcVal + 1) * 3 / 5) : (srcVal * 3 / 5); + } + + static int ScaleLength(int srcVal) + { + return (srcVal > 0) ? ((srcVal + 1) * 3 / 5) : (srcVal * 3 / 5); + } +}; + +template<> +struct SimpleScaler <8, 9> +{ + static int ScaleDisplacement(int srcVal) + { + return (srcVal >= 0) ? (srcVal * 9 / 8) : ((srcVal * 9 - 1) / 8); + } + + static int ScaleLength(int srcVal) + { + return (srcVal >= 0) ? (srcVal * 9 / 8) : ((srcVal * 9 - 1) / 8); + } +}; + +template<> +struct SimpleScaler <9, 8> +{ + static int ScaleDisplacement(int srcVal) + { + return (srcVal > 0) ? ((srcVal + 1) * 8 / 9) : (srcVal * 8 / 9); + } + + static int ScaleLength(int srcVal) + { + return (srcVal > 0) ? ((srcVal + 1) * 8 / 9) : (srcVal * 8 / 9); + } +}; + +template<> +struct SimpleScaler <1, 3> +{ + static int ScaleDisplacement(int srcVal) + { + return (srcVal >= 0) ? (srcVal * 3 / 1) : ((srcVal * 3 - 1) / 1); + } + + static int ScaleLength(int srcVal) + { + return (srcVal >= 0) ? (srcVal * 3 / 1) : ((srcVal * 3 - 1) / 1); + } +}; + +template<> +struct SimpleScaler <3, 1> +{ + static int ScaleDisplacement(int srcVal) + { + return (srcVal > 0) ? ((srcVal + 1) * 1 / 3) : (srcVal * 1 / 3); + } + + static int ScaleLength(int srcVal) + { + return (srcVal > 0) ? ((srcVal + 1) * 1 / 3) : (srcVal * 1 / 3); + } +}; + +template<> +struct SimpleScaler <4, 9> +{ + static int ScaleDisplacement(int srcVal) + { + return (srcVal >= 0) ? (srcVal * 9 / 4) : ((srcVal * 9 - 1) / 4); + } + + static int ScaleLength(int srcVal) + { + return (srcVal >= 0) ? (srcVal * 9 / 4) : ((srcVal * 9 - 1) / 4); + } +}; + +template<> +struct SimpleScaler <9, 4> +{ + static int ScaleDisplacement(int srcVal) + { + return (srcVal > 0) ? ((srcVal + 1) * 4 / 9) : (srcVal * 4 / 9); + } + + static int ScaleLength(int srcVal) + { + return (srcVal > 0) ? ((srcVal + 1) * 4 / 9) : (srcVal * 4 / 9); + } +}; + +} // _Internal + + +result +_CreateCoordinateTransformer(_ICoordinateSystemTransformer*& pTransformer, const Dimension& srcDim, const Dimension& trgDim) +{ + if (srcDim.width == 0 || srcDim.height == 0) + { + return E_SYSTEM; + } + + struct _Scaler + { + _Scaler(int src_, int trg_) + : src(src_) + , trg(trg_) + { + } + + int ScaleDisplacement(int srcVal) const + { + if (src > trg) + { + return (srcVal > 0) ? ((srcVal + 1) * trg / src) : (srcVal * trg / src); + } + else if (src < trg) + { + return (srcVal >= 0) ? (srcVal * trg / src) : ((srcVal * trg - 1) / src); + } + + return srcVal; + } + + int ScaleLength(int srcVal) const + { + return ScaleDisplacement(srcVal); + } + + int src; + int trg; + }; + + class _Xformer + : public _ICoordinateSystemTransformer + { + public: + _Xformer(const Dimension& srcDim, const Dimension& trgDim) + : __scalerH(srcDim.width, trgDim.width) + , __scalerV(srcDim.height, trgDim.height) + , __scaleFactorH(trgDim.width * 1.0f / srcDim.width) + , __scaleFactorV(trgDim.height * 1.0f / srcDim.height) + { + } + + virtual int TransformHorizontal(int width) const + { + return __scalerH.ScaleLength(width); + } + + virtual int TransformVertical(int height) const + { + return __scalerV.ScaleLength(height); + } + + virtual int Transform(int scalar) const + { + return __scalerV.ScaleLength(scalar); + } + + virtual float TransformHorizontal(float width) const + { + return width * __scaleFactorH; + } + + virtual float TransformVertical(float height) const + { + return height * __scaleFactorV; + } + + virtual float Transform(float scalar) const + { + return scalar * __scaleFactorV;; + } + + virtual Point Transform(const Point& point) const + { + return Point(__scalerH.ScaleDisplacement(point.x), __scalerV.ScaleDisplacement(point.y)); + } + + virtual Dimension Transform(const Dimension& dim) const + { + return Dimension(__scalerH.ScaleLength(dim.width), __scalerV.ScaleLength(dim.height)); + } + + virtual Rectangle Transform(const Rectangle& rect) const + { + int x = __scalerH.ScaleDisplacement(rect.x); + int y = __scalerV.ScaleDisplacement(rect.y); + int w = __scalerH.ScaleLength(rect.width); + int h = __scalerV.ScaleLength(rect.height); + + return Rectangle(x, y, w, h); + } + + virtual int TransformFloatToInt(float scalar) const + { + return __scalerV.ScaleLength(static_cast(scalar)); + } + + virtual int TransformHorizontalFloatToInt(float width) const + { + return __scalerH.ScaleLength(static_cast(width)); + } + + virtual int TransformVerticalFloatToInt(float height) const + { + return __scalerV.ScaleLength(static_cast(height)); + } + + virtual float GetHorizontalScaleFactor(void) const + { + return __scaleFactorH; + } + + virtual float GetVerticalScaleFactor(void) const + { + return __scaleFactorV; + } + + private: + _Scaler __scalerH; + _Scaler __scalerV; + + float __scaleFactorH; + float __scaleFactorV; + + }; // _Xformer + + pTransformer = new (std::nothrow) _Xformer(srcDim, trgDim); + + return (pTransformer) ? E_SUCCESS : E_SYSTEM; +} + +}} // Tizen::Graphics + + +namespace Tizen { namespace Graphics +{ + +template<_LogicalResolution LogRes> +struct LogResTraits +{ +}; + +template<_PhysicalResolution PhyRes> +struct PhyResTraits +{ +}; + +template<_BaseScreenSize ScrRes> +struct ScrResTraits +{ +}; + +//_LogicalResolution +template<> +struct LogResTraits +{ + enum { WIDTH = 240 }; +}; + +template<> +struct LogResTraits +{ + enum { WIDTH = 320 }; +}; + +template<> +struct LogResTraits +{ + enum { WIDTH = 480 }; +}; + +template<> +struct LogResTraits +{ + enum { WIDTH = 720 }; +}; + +template<> +struct LogResTraits +{ + enum { WIDTH = 800 }; +}; + +template<> +struct LogResTraits +{ + enum { WIDTH = 1080 }; +}; + +template<> +struct LogResTraits +{ + enum { WIDTH = 1600 }; +}; + +//_PhysicalResolution +template<> +struct PhyResTraits +{ + enum { WIDTH = 480, HEIGHT = 800 }; +}; + +template<> +struct PhyResTraits +{ + enum { WIDTH = 240, HEIGHT = 400 }; +}; + +template<> +struct PhyResTraits +{ + enum { WIDTH = 320, HEIGHT = 480 }; +}; + +template<> +struct PhyResTraits +{ + enum { WIDTH = 720, HEIGHT = 1280 }; +}; + +//_BaseScreenSize +template<> +struct ScrResTraits +{ + enum { WIDTH = 720 }; +}; + +template<> +struct ScrResTraits +{ + enum { WIDTH = 1440 }; +}; + + +const char* +_GetStringResolution(_LogicalResolution res) +{ + switch (res) + { + case RESOLUTION_LOGICAL_DEFAULT: + return "DEFAULT"; + case RESOLUTION_LOGICAL_240: + return "240"; + case RESOLUTION_LOGICAL_320: + return "320"; + case RESOLUTION_LOGICAL_360: + return "360"; + case RESOLUTION_LOGICAL_480: + return "480"; + case RESOLUTION_LOGICAL_720: + return "720"; + case RESOLUTION_LOGICAL_800: + return "800"; + case RESOLUTION_LOGICAL_960: + return "960"; + case RESOLUTION_LOGICAL_1080: + return "1080"; + case RESOLUTION_LOGICAL_1440: + return "1440"; + case RESOLUTION_LOGICAL_1600: + return "1600"; + default: + return "Unknown resolution"; + } +} + +const char* +_GetStringResolution(_PhysicalResolution res) +{ + switch (res) + { + case RESOLUTION_PHYSICAL_DEFAULT: + return "DEFAULT"; + case RESOLUTION_PHYSICAL_WVGA: + return "WVGA"; + case RESOLUTION_PHYSICAL_WQVGA: + return "WQVGA"; + case RESOLUTION_PHYSICAL_HVGA: + return "HVGA"; + case RESOLUTION_PHYSICAL_HD: + return "HD"; + case RESOLUTION_PHYSICAL_HD1080: + return "HD1080"; + case RESOLUTION_PHYSICAL_WXGA: + return "WXGA"; + case RESOLUTION_PHYSICAL_WQXGA: + return "WQXGA"; + default: + return "Unknown resolution"; + } +} + + +const int +_GetIntegerResolution(_LogicalResolution res) +{ + switch (res) + { + case RESOLUTION_LOGICAL_240: + return 240; + case RESOLUTION_LOGICAL_320: + return 320; + case RESOLUTION_LOGICAL_360: + return 360; + case RESOLUTION_LOGICAL_480: + return 480; + case RESOLUTION_LOGICAL_720: + return 720; + case RESOLUTION_LOGICAL_800: + return 800; + case RESOLUTION_LOGICAL_960: + return 960; + case RESOLUTION_LOGICAL_1080: + return 1080; + case RESOLUTION_LOGICAL_1440: + return 1440; + case RESOLUTION_LOGICAL_1600: + return 1600; + default: + return -1; + } +} + +const int +_GetIntegerResolution(_PhysicalResolution res) +{ + switch (res) + { + case RESOLUTION_PHYSICAL_WVGA: + return 480; + case RESOLUTION_PHYSICAL_WQVGA: + return 240; + case RESOLUTION_PHYSICAL_HVGA: + return 320; + case RESOLUTION_PHYSICAL_HD: + return 720; + case RESOLUTION_PHYSICAL_HD1080: + return 1080; + case RESOLUTION_PHYSICAL_WXGA: + return 800; + case RESOLUTION_PHYSICAL_WQXGA: + return 1600; + default: + return -1; + } +} + +const int +_GetIntegerResolution(_BaseScreenSize res) +{ + switch (res) + { + case BASE_SCREEN_SIZE_NORMAL: + return 720; + case BASE_SCREEN_SIZE_LARGE: + return 1440; + default: + return -1; + } +} + +/***************************************************************************************** + * Supported transformations + + * - Normal_480 to Large_WQVGA Large * 480 : Normal * WQVGA + +**************************Normal to Normal(48)************************** + * - Normal_240 to Normal_WVGA 480 * 240 (1) : 480 * 480 (2) + * - Normal_WVGA to Normal_240 480 * 480 (2) : 480 * 240 (1) + * - Normal_240 to Normal_HVGA 480 * 240 (3) : 480 * 320 (4) + * - Normal_HVGA to Normal_240 480 * 320 (4) : 480 * 240 (3) + * - Normal_240 to Normal_HD 480 * 240 (1) : 480 * 720 (3) + * - Normal_HD to Normal_240 480 * 720 (3) : 480 * 240 (1) + + * - Normal_320 to Normal_WQVGA 480 * 320 (4) : 480 * 240 (3) + * - Normal_WQVGA to Normal_320 480 * 240 (3) : 480 * 320 (4) + * - Normal_320 to Normal_WVGA 480 * 320 (2) : 480 * 480 (3) + * - Normal_WVGA to Normal_320 480 * 480 (3) : 480 * 320 (2) + * - Normal_320 to Normal_HD 480 * 320 (4) : 480 * 720 (9) + * - Normal_HD to Normal_320 480 * 720 (9) : 480 * 320 (4) + + * - Normal_480 to Normal_WQVGA 480 * 480 (2) : 480 * 240 (1) + * - Normal_WQVGA to Normal_480 480 * 240 (1) : 480 * 480 (2) + * - Normal_480 to Normal_HVGA 480 * 480 (3) : 480 * 320 (2) + * - Normal_HVGA to Normal_480 480 * 320 (2) : 480 * 480 (3) + * - Normal_480 to Normal_HD 480 * 480 (2) : 480 * 720 (3) + * - Normal_HD to Normal_480 480 * 720 (3) : 480 * 480 (2) + + * - Normal_720 to Normal_WQVGA 480 * 720 (3) : 480 * 240 (1) + * - Normal_WQVGA to Normal_720 480 * 240 (1) : 480 * 720 (3) + * - Normal_720 to Normal_WVGA 480 * 720 (3) : 480 * 480 (2) + * - Normal_WVGA to Normal_720 480 * 480 (2) : 480 * 720 (3) + * - Normal_720 to Normal_HVGA 480 * 720 (9) : 480 * 320 (4) + * - Normal_HVGA to Normal_720 480 * 320 (4) : 480 * 720 (9) + + * - Normal_800 to Normal_WQVGA 480 * 800 (10) : 480 * 240 (3) + * - Normal_WQVGA to Normal_800 480 * 240 (3) : 480 * 800 (10) + * - Normal_800 to Normal_WVGA 480 * 800 (5) : 480 * 480 (3) + * - Normal_WVGA to Normal_800 480 * 480 (3) : 480 * 800 (5) + * - Normal_800 to Normal_HVGA 480 * 800 (5) : 480 * 320 (2) + * - Normal_HVGA to Normal_800 480 * 320 (2) : 480 * 800 (5) + * - Normal_800 to Normal_HD 480 * 800 (10) : 480 * 720 (9) + * - Normal_HD to Normal_800 480 * 720 (9) : 480 * 800 (10) + + * - Normal_1080 to Normal_WQVGA 480 * 1080 (27) : 480 * 240 (6) + * - Normal_WQVGA to Normal_1080 480 * 240 (6) : 480 * 1080 (27) + * - Normal_1080 to Normal_WVGA 480 * 1080 (27) : 480 * 480 (12) + * - Normal_WVGA to Normal_1080 480 * 480 (12) : 480 * 1080 (27) + * - Normal_1080 to Normal_HVGA 480 * 1080 (27) : 480 * 320 (8) + * - Normal_HVGA to Normal_1080 480 * 320 (8) : 480 * 1080 (27) + * - Normal_1080 to Normal_HD 480 * 1080 (27) : 480 * 720 (18) + * - Normal_HD to Normal_1080 480 * 720 (18) : 480 * 1080 (27) + + * - Normal_1600 to Normal_WQVGA 480 * 1600 (20) : 480 * 240 (3) + * - Normal_WQVGA to Normal_1600 480 * 240 (3) : 480 * 1600 (20) + * - Normal_1600 to Normal_WVGA 480 * 1600 (10) : 480 * 480 (3) + * - Normal_WVGA to Normal_1600 480 * 480 (3) : 480 * 1600 (10) + * - Normal_1600 to Normal_HVGA 480 * 1600 (5) : 480 * 320 (1) + * - Normal_HVGA to Normal_1600 480 * 320 (1) : 480 * 1600 (5) + * - Normal_1600 to Normal_HD 480 * 1600 (20) : 480 * 720 (9) + * - Normal_HD to Normal_1600 480 * 720 (9) : 480 * 1600 (20) + +**************************Large to Large(48)************************** + * - Large_240 to Large_WVGA 720 * 240 (1) : 720 * 480 (2) + * - Large_WVGA to Large_240 720 * 480 (2) : 720 * 240 (1) + * - Large_240 to Large_HVGA 720 * 240 (3) : 720 * 320 (4) + * - Large_HVGA to Large_240 720 * 320 (4) : 720 * 240 (3) + * - Large_240 to Large_HD 720 * 240 (1) : 720 * 720 (3) + * - Large_HD to Large_240 720 * 720 (3) : 720 * 240 (1) + + * - Large_320 to Large_WQVGA 720 * 320 (4) : 720 * 240 (3) + * - Large_WQVGA to Large_320 720 * 240 (3) : 720 * 320 (4) + * - Large_320 to Large_WVGA 720 * 320 (2) : 720 * 480 (3) + * - Large_WVGA to Large_320 720 * 480 (3) : 720 * 320 (2) + * - Large_320 to Large_HD 720 * 320 (4) : 720 * 720 (9) + * - Large_HD to Large_320 720 * 720 (9) : 720 * 320 (4) + + * - Large_480 to Large_WQVGA 720 * 480 (2) : 720 * 240 (1) + * - Large_WQVGA to Large_480 720 * 240 (1) : 720 * 480 (2) + * - Large_480 to Large_HVGA 720 * 480 (3) : 720 * 320 (2) + * - Large_HVGA to Large_480 720 * 320 (2) : 720 * 480 (3) + * - Large_480 to Large_HD 720 * 480 (2) : 720 * 720 (3) + * - Large_HD to Large_480 720 * 720 (3) : 720 * 480 (2) + + * - Large_720 to Large_WQVGA 720 * 720 (3) : 720 * 240 (1) + * - Large_WQVGA to Large_720 720 * 240 (1) : 720 * 720 (3) + * - Large_720 to Large_WVGA 720 * 720 (3) : 720 * 480 (2) + * - Large_WVGA to Large_720 720 * 480 (2) : 720 * 720 (3) + * - Large_720 to Large_HVGA 720 * 720 (9) : 720 * 320 (4) + * - Large_HVGA to Large_720 720 * 320 (4) : 720 * 720 (9) + + * - Large_800 to Large_WQVGA 720 * 800 (10) : 720 * 240 (3) + * - Large_WQVGA to Large_800 720 * 240 (3) : 720 * 800 (10) + * - Large_800 to Large_WVGA 720 * 800 (5) : 720 * 480 (3) + * - Large_WVGA to Large_800 720 * 480 (3) : 720 * 800 (5) + * - Large_800 to Large_HVGA 720 * 800 (5) : 720 * 320 (2) + * - Large_HVGA to Large_800 720 * 320 (2) : 720 * 800 (5) + * - Large_800 to Large_HD 720 * 800 (10) : 720 * 720 (9) + * - Large_HD to Large_800 720 * 720 (9) : 720 * 800 (10) + + * - Large_1080 to Large_WQVGA 720 * 1080 (27) : 720 * 240 (6) + * - Large_WQVGA to Large_1080 720 * 240 (6) : 720 * 1080 (27) + * - Large_1080 to Large_WVGA 720 * 1080 (27) : 720 * 480 (12) + * - Large_WVGA to Large_1080 720 * 480 (12) : 720 * 1080 (27) + * - Large_1080 to Large_HVGA 720 * 1080 (27) : 720 * 320 (8) + * - Large_HVGA to Large_1080 720 * 320 (8) : 720 * 1080 (27) + * - Large_1080 to Large_HD 720 * 1080 (27) : 720 * 720 (18) + * - Large_HD to Large_1080 720 * 720 (18) : 720 * 1080 (27) + + * - Large_1600 to Large_WQVGA 720 * 1600 (20) : 720 * 240 (3) + * - Large_WQVGA to Large_1600 720 * 240 (3) : 720 * 1600 (20) + * - Large_1600 to Large_WVGA 720 * 1600 (10) : 720 * 480 (3) + * - Large_WVGA to Large_1600 720 * 480 (3) : 720 * 1600 (10) + * - Large_1600 to Large_HVGA 720 * 1600 (5) : 720 * 320 (1) + * - Large_HVGA to Large_1600 720 * 320 (1) : 720 * 1600 (5) + * - Large_1600 to Large_HD 720 * 1600 (20) : 720 * 720 (9) + * - Large_HD to Large_1600 720 * 720 (9) : 720 * 1600 (20) + + **************************Normal to Large(48)************************** + * - Normal_240 to Large_WVGA 720 * 240 (3) : 480 * 480 (4) + * - Large_WVGA to Normal_240 480 * 480 (4) : 720 * 240 (3) + * - Normal_240 to Large_HVGA 720 * 240 (9) : 480 * 320 (8) + * - Large_HVGA to Normal_240 480 * 320 (8) : 720 * 240 (9) + * - Normal_240 to Large_HD 720 * 240 (1) : 480 * 720 (2) + * - Large_HD to Normal_240 480 * 720 (2) : 720 * 240 (1) + + * - Normal_320 to Large_WQVGA 720 * 320 (3) : 480 * 240 (1) + * - Large_WQVGA to Normal_320 480 * 240 (1) : 720 * 320 (3) + * - Normal_320 to Large_WVGA 720 * 320 (1) : 480 * 480 (1) + * - Large_WVGA to Normal_320 480 * 480 (1) : 720 * 320 (1) + * - Normal_320 to Large_HD 720 * 320 (2) : 480 * 720 (3) + * - Large_HD to Normal_320 480 * 720 (3) : 720 * 320 (2) + + * - Normal_480 to Large_WQVGA 720 * 480 (4) : 480 * 240 (3) + * - Large_WQVGA to Normal_480 480 * 240 (3) : 720 * 480 (4) + * - Normal_480 to Large_HVGA 720 * 480 (9) : 480 * 320 (4) + * - Large_HVGA to Normal_480 480 * 320 (4) : 720 * 480 (9) + * - Normal_480 to Large_HD 720 * 480 (1) : 480 * 720 (1) + * - Large_HD to Normal_480 480 * 720 (1) : 720 * 480 (1) + + * - Normal_720 to Large_WQVGA 720 * 720 (9) : 480 * 240 (2) + * - Large_WQVGA to Normal_720 480 * 240 (2) : 720 * 720 (9) + * - Normal_720 to Large_WVGA 720 * 720 (9) : 480 * 480 (4) + * - Large_WVGA to Normal_720 480 * 480 (4) : 720 * 720 (9) + * - Normal_720 to Large_HVGA 720 * 720 (27) : 480 * 320 (8) + * - Large_HVGA to Normal_720 480 * 320 (8) : 720 * 720 (27) + + * - Normal_800 to Large_WQVGA 720 * 800 (5) : 480 * 240 (1) + * - Large_WQVGA to Normal_800 480 * 240 (1) : 720 * 800 (5) + * - Normal_800 to Large_WVGA 720 * 800 (5) : 480 * 480 (2) + * - Large_WVGA to Normal_800 480 * 480 (2) : 720 * 800 (5) + * - Normal_800 to Large_HVGA 720 * 800 (15) : 480 * 320 (4) + * - Large_HVGA to Normal_800 480 * 320 (4) : 720 * 800 (15) + * - Normal_800 to Large_HD 720 * 800 (5) : 480 * 720 (3) + * - Large_HD to Normal_800 480 * 720 (3) : 720 * 800 (5) + + * - Normal_1080 to Large_WQVGA 720 * 1080 (27) : 480 * 240 (4) + * - Large_WQVGA to Normal_1080 480 * 240 (4) : 720 * 1080 (27) + * - Normal_1080 to Large_WVGA 720 * 1080 (27) : 480 * 480 (8) + * - Large_WVGA to Normal_1080 480 * 480 (8) : 720 * 1080 (27) + * - Normal_1080 to Large_HVGA 720 * 1080 (81) : 480 * 320 (16) + * - Large_HVGA to Normal_1080 480 * 320 (16) : 720 * 1080 (81) + * - Normal_1080 to Large_HD 720 * 1080 (9) : 480 * 720 (4) + * - Large_HD to Normal_1080 480 * 720 (4) : 720 * 1080 (9) + + * - Normal_1600 to Large_WQVGA 720 * 1600 (10) : 480 * 240 (1) + * - Large_WQVGA to Normal_1600 480 * 240 (1) : 720 * 1600 (10) + * - Normal_1600 to Large_WVGA 720 * 1600 (5) : 480 * 480 (1) + * - Large_WVGA to Normal_1600 480 * 480 (1) : 720 * 1600 (5) + * - Normal_1600 to Large_HVGA 720 * 1600 (15) : 480 * 320 (2) + * - Large_HVGA to Normal_1600 480 * 320 (2) : 720 * 1600 (15) + * - Normal_1600 to Large_HD 720 * 1600 (10) : 480 * 720 (3) + * - Large_HD to Normal_1600 480 * 720 (3) : 720 * 1600 (10) + + **************************Large to Normal(48)************************** + * - Large_240 to Normal_WVGA 480 * 240 (1) : 720 * 480 (3) + * - Normal_WVGA to Large_240 720 * 480 (3) : 480 * 240 (1) + * - Large_240 to Normal_HVGA 480 * 240 (1) : 720 * 320 (2) + * - Normal_HVGA to Large_240 720 * 320 (2) : 480 * 240 (1) + * - Large_240 to Normal_HD 480 * 240 (2) : 720 * 720 (9) + * - Normal_HD to Large_240 720 * 720 (9) : 480 * 240 (2) + + * - Large_320 to Normal_WQVGA 480 * 320 (8) : 720 * 240 (9) + * - Normal_WQVGA to Large_320 720 * 240 (9) : 480 * 320 (8) + * - Large_320 to Normal_WVGA 480 * 320 (4) : 720 * 480 (9) + * - Normal_WVGA to Large_320 720 * 480 (9) : 480 * 320 (4) + * - Large_320 to Normal_HD 480 * 320 (8) : 720 * 720 (27) + * - Normal_HD to Large_320 720 * 720 (27) : 480 * 320 (8) + + * - Large_480 to Normal_WQVGA 480 * 480 (4) : 720 * 240 (3) + * - Normal_WQVGA to Large_480 720 * 240 (3) : 480 * 480 (4) + * - Large_480 to Normal_HVGA 480 * 480 (1) : 720 * 320 (1) + * - Normal_HVGA to Large_480 720 * 320 (1) : 480 * 480 (1) + * - Large_480 to Normal_HD 480 * 480 (2) : 720 * 720 (3) + * - Normal_HD to Large_480 720 * 720 (3) : 480 * 480 (2) + + * - Large_720 to Normal_WQVGA 480 * 720 (2) : 720 * 240 (1) + * - Normal_WQVGA to Large_720 720 * 240 (1) : 480 * 720 (2) + * - Large_720 to Normal_WVGA 480 * 720 (1) : 720 * 480 (1) + * - Normal_WVGA to Large_720 720 * 480 (1) : 480 * 720 (1) + * - Large_720 to Normal_HVGA 480 * 720 (3) : 720 * 320 (2) + * - Normal_HVGA to Large_720 720 * 320 (2) : 480 * 720 (3) + + * - Large_800 to Normal_WQVGA 480 * 800 (20) : 720 * 240 (9) + * - Normal_WQVGA to Large_800 720 * 240 (9) : 480 * 800 (20) + * - Large_800 to Normal_WVGA 480 * 800 (10) : 720 * 480 (9) + * - Normal_WVGA to Large_800 720 * 480 (9) : 480 * 800 (10) + * - Large_800 to Normal_HVGA 480 * 800 (5) : 720 * 320 (3) + * - Normal_HVGA to Large_800 720 * 320 (3) : 480 * 800 (5) + * - Large_800 to Normal_HD 480 * 800 (9) : 720 * 720 (20) + * - Normal_HD to Large_800 720 * 720 (20) : 480 * 800 (9) + + * - Large_1080 to Normal_WQVGA 480 * 1080 (3) : 720 * 240 (1) + * - Normal_WQVGA to Large_1080 720 * 240 (1) : 480 * 1080 (3) + * - Large_1080 to Normal_WVGA 480 * 1080 (3) : 720 * 480 (2) + * - Normal_WVGA to Large_1080 720 * 480 (2) : 480 * 1080 (3) + * - Large_1080 to Normal_HVGA 480 * 1080 (9) : 720 * 320 (4) + * - Normal_HVGA to Large_1080 720 * 320 (4) : 480 * 1080 (9) + * - Large_1080 to Normal_HD 480 * 1080 (1) : 720 * 720 (10) + * - Normal_HD to Large_1080 720 * 720 (10) : 480 * 1080 (1) + + * - Large_1600 to Normal_WQVGA 480 * 1600 (40) : 720 * 240 (9) + * - Normal_WQVGA to Large_1600 720 * 240 (9) : 480 * 1600 (40) + * - Large_1600 to Normal_WVGA 480 * 1600 (20) : 720 * 480 (9) + * - Normal_WVGA to Large_1600 720 * 480 (9) : 480 * 1600 (20) + * - Large_1600 to Normal_HVGA 480 * 1600 (10) : 720 * 320 (3) + * - Normal_HVGA to Large_1600 720 * 320 (3) : 480 * 1600 (10) + * - Large_1600 to Normal_HD 480 * 1600 (40) : 720 * 720 (27) + * - Normal_HD to Large_1600 720 * 720 (27) : 480 * 1600 (40) + + *****************************************************************************************/ + +class TransformerNormal240ToNormalHvga + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormal240ToNormalHvga + +class TransformerNormalHvgaToNormal240 + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormalHvgaToNormal240 + +class TransformerNormal240ToNormalWvga + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormal240ToNormalWvga + +class TransformerNormalWvgaToNormal240 + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormalWvgaToNormal240 + +class TransformerNormal240ToNormalHd + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormal240ToNormalHd + +class TransformerNormalHdToNormal240 + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormalHdToNormal240 + +class TransformerNormal320ToNormalWqvga + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormal320ToNormalWqvga + +class TransformerNormalWqvgaToNormal320 + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormalWqvgaToNormal320 + +class TransformerNormal320ToNormalWvga + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormal320ToNormalWvga + +class TransformerNormalWvgaToNormal320 + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormalWvgaToNormal320 + +class TransformerNormal320ToNormalHd + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormal320ToNormalHd + +class TransformerNormalHdToNormal320 + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormalHdToNormal320 + +class TransformerNormal480ToNormalWqvga + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormal480ToNormalWqvga + +class TransformerNormalWqvgaToNormal480 + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormalWqvgaToNormal480 + +class TransformerNormal480ToNormalHvga + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormal480ToNormalHvga + +class TransformerNormalHvgaToNormal480 + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormalHvgaToNormal480 + +class TransformerNormal480ToNormalHd + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormal480ToNormalHd + +class TransformerNormalHdToNormal480 + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormalHdToNormal480 + +class TransformerNormal720ToNormalWqvga + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormal720ToNormalWqvga + +class TransformerNormalWqvgaToNormal720 + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormalWqvgaToNormal720 + +class TransformerNormal720ToNormalWvga + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormal720ToNormalWvga + +class TransformerNormalWvgaToNormal720 + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormalWvgaToNormalWvga + +class TransformerNormal720ToNormalHvga + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , PhyResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormal720ToNormalHvga + +class TransformerNormalHvgaToNormal720 + : public _Internal::Transformer + <_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> + ,_Internal::Scaler ::WIDTH * ScrResTraits ::WIDTH , LogResTraits ::WIDTH * ScrResTraits ::WIDTH> > +{ +}; // TransformerNormalHvgaToNormal720 + + +class TransformerGeneral + : public _ICoordinateSystemTransformer + { + public: + TransformerGeneral(const int srcScalar, const int dstScalar) + : __srcScalar(srcScalar) + , __dstScalar(dstScalar) + , __scaleFactor(dstScalar * 1.0f / srcScalar) + { + } + + virtual int TransformHorizontal(int width) const + { + return ScaleLength(width); + } + + virtual int TransformVertical(int height) const + { + return ScaleLength(height); + } + + virtual int Transform(int scalar) const + { + return ScaleLength(scalar); + } + + virtual float TransformHorizontal(float width) const + { + return ScaleLength(width); + } + + virtual float TransformVertical(float height) const + { + return ScaleLength(height); + } + + virtual float Transform(float scalar) const + { + return ScaleLength(scalar); + } + + virtual Point Transform(const Point& point) const + { + return Point(ScaleDisplacement(point.x), ScaleDisplacement(point.y)); + } + + virtual Dimension Transform(const Dimension& dim) const + { + return Dimension(ScaleLength(dim.width), ScaleLength(dim.height)); + } + + virtual Rectangle Transform(const Rectangle& rect) const + { + int x = ScaleDisplacement(rect.x); + int y = ScaleDisplacement(rect.y); + int w = ScaleLength(rect.width); + int h = ScaleLength(rect.height); + + return Rectangle(x, y, w, h); + } + + virtual int TransformFloatToInt(float scalar) const + { + return ScaleLength(static_cast(scalar)); + } + + virtual int TransformHorizontalFloatToInt(float width) const + { + return ScaleLength(static_cast(width)); + } + + virtual int TransformVerticalFloatToInt(float height) const + { + return ScaleLength(static_cast(height)); + } + + virtual float GetHorizontalScaleFactor(void) const + { + return __scaleFactor; + } + + virtual float GetVerticalScaleFactor(void) const + { + return __scaleFactor; + } + +private: + int ScaleDisplacement(int srcVal) const + { + long long tmpVal = srcVal; + tmpVal *= __dstScalar; + tmpVal /= __srcScalar; + + return static_cast(tmpVal); + } + + int ScaleLength(int srcVal) const + { + long long tmpVal = srcVal; + tmpVal *= __dstScalar; + tmpVal /= __srcScalar; + + return static_cast(tmpVal); + } + + float ScaleDisplacement(float srcVal) const + { + return srcVal * __scaleFactor; + } + + float ScaleLength(float srcVal) const + { + return srcVal * __scaleFactor; + } + +private: + int __srcScalar; + int __dstScalar; + + float __scaleFactor; + +}; // TransformerGeneral + +bool +_WillNotTransform(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize, _PhysicalResolution physicalResolution, _BaseScreenSize physicalBaseScreenSize) +{ + return ((logicalResolution == RESOLUTION_LOGICAL_240 && physicalResolution == RESOLUTION_PHYSICAL_WQVGA) || + (logicalResolution == RESOLUTION_LOGICAL_320 && physicalResolution == RESOLUTION_PHYSICAL_HVGA) || + (logicalResolution == RESOLUTION_LOGICAL_480 && physicalResolution == RESOLUTION_PHYSICAL_WVGA) || + (logicalResolution == RESOLUTION_LOGICAL_720 && physicalResolution == RESOLUTION_PHYSICAL_HD) || + (logicalResolution == RESOLUTION_LOGICAL_800 && physicalResolution == RESOLUTION_PHYSICAL_WXGA) || + (logicalResolution == RESOLUTION_LOGICAL_1080 && physicalResolution == RESOLUTION_PHYSICAL_HD1080) || + (logicalResolution == RESOLUTION_LOGICAL_1600 && physicalResolution == RESOLUTION_PHYSICAL_WQXGA)) && + (logicalBaseScreenSize == physicalBaseScreenSize); +} + +bool +_WillNotTransform(int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize) +{ + return ((srcResolution == destResolution.width) && (srcBaseScreenSize == destBaseScreenSize)); +} + +result +_CoordinateTransformerCore(_ICoordinateSystemTransformer*& pTransformer, _LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize, _PhysicalResolution physicalResolution, _BaseScreenSize physicalBaseScreenSize, bool isInverse = false) +{ + SysAssert(logicalResolution != RESOLUTION_LOGICAL_DEFAULT); + SysAssert(physicalResolution != RESOLUTION_PHYSICAL_DEFAULT); + SysAssert(logicalBaseScreenSize != BASE_SCREEN_SIZE_DEFAULT); + SysAssert(physicalBaseScreenSize != BASE_SCREEN_SIZE_DEFAULT); + + result r = E_SUCCESS; + pTransformer = null; + + if (_WillNotTransform(logicalResolution,logicalBaseScreenSize, physicalResolution,physicalBaseScreenSize)) + { + pTransformer = new (std::nothrow) _NullCoordinateSystemTransformer(); + + if (pTransformer == null) + { + SysLog(NID_GRP, "[E_OUT_OF_MEMORY] Fail to create a coordinate transformer."); + + return E_OUT_OF_MEMORY; + } + + return E_SUCCESS; + } + +#if 1 + if (isInverse) + { + if (logicalBaseScreenSize == physicalBaseScreenSize) + { + if (logicalResolution == RESOLUTION_LOGICAL_240 && physicalResolution == RESOLUTION_PHYSICAL_WVGA) + { + pTransformer = new (std::nothrow) TransformerNormalWvgaToNormal240; + } + else if (logicalResolution == RESOLUTION_LOGICAL_240 && physicalResolution == RESOLUTION_PHYSICAL_HVGA) + { + pTransformer = new (std::nothrow) TransformerNormalHvgaToNormal240; + } + else if (logicalResolution == RESOLUTION_LOGICAL_240 && physicalResolution == RESOLUTION_PHYSICAL_HD) + { + pTransformer = new (std::nothrow) TransformerNormalHdToNormal240; + } + else if (logicalResolution == RESOLUTION_LOGICAL_320 && physicalResolution == RESOLUTION_PHYSICAL_WQVGA) + { + pTransformer = new (std::nothrow) TransformerNormalWqvgaToNormal320; + } + else if (logicalResolution == RESOLUTION_LOGICAL_320 && physicalResolution == RESOLUTION_PHYSICAL_WVGA) + { + pTransformer = new (std::nothrow) TransformerNormalWvgaToNormal320; + } + else if (logicalResolution == RESOLUTION_LOGICAL_320 && physicalResolution == RESOLUTION_PHYSICAL_HD) + { + pTransformer = new (std::nothrow) TransformerNormalHdToNormal320; + } + else if (logicalResolution == RESOLUTION_LOGICAL_480 && physicalResolution == RESOLUTION_PHYSICAL_WQVGA) + { + pTransformer = new (std::nothrow) TransformerNormalWqvgaToNormal480; + } + else if (logicalResolution == RESOLUTION_LOGICAL_480 && physicalResolution == RESOLUTION_PHYSICAL_HVGA) + { + pTransformer = new (std::nothrow) TransformerNormalHvgaToNormal480; + } + else if (logicalResolution == RESOLUTION_LOGICAL_480 && physicalResolution == RESOLUTION_PHYSICAL_HD) + { + pTransformer = new (std::nothrow) TransformerNormalHdToNormal480; + } + else if (logicalResolution == RESOLUTION_LOGICAL_720 && physicalResolution == RESOLUTION_PHYSICAL_WQVGA) + { + pTransformer = new (std::nothrow) TransformerNormalWqvgaToNormal720; + } + else if (logicalResolution == RESOLUTION_LOGICAL_720 && physicalResolution == RESOLUTION_PHYSICAL_WVGA) + { + pTransformer = new (std::nothrow) TransformerNormalWvgaToNormal720; + } + else if (logicalResolution == RESOLUTION_LOGICAL_720 && physicalResolution == RESOLUTION_PHYSICAL_HVGA) + { + pTransformer = new (std::nothrow) TransformerNormalHvgaToNormal720; + } + else + { + //r = E_INVALID_ARG; + pTransformer = new (std::nothrow) TransformerGeneral(_GetIntegerResolution(physicalResolution), _GetIntegerResolution(logicalResolution)); + } + } + else + { + //r = E_INVALID_ARG; + pTransformer = new (std::nothrow) TransformerGeneral(_GetIntegerResolution(physicalResolution) * _GetIntegerResolution(logicalBaseScreenSize), _GetIntegerResolution(logicalResolution) * _GetIntegerResolution(physicalBaseScreenSize)); + } + } + else + { + if (logicalBaseScreenSize == physicalBaseScreenSize) + { + if (logicalResolution == RESOLUTION_LOGICAL_240 && physicalResolution == RESOLUTION_PHYSICAL_WVGA) + { + pTransformer = new (std::nothrow) TransformerNormal240ToNormalWvga; + } + else if (logicalResolution == RESOLUTION_LOGICAL_240 && physicalResolution == RESOLUTION_PHYSICAL_HVGA) + { + pTransformer = new (std::nothrow) TransformerNormal240ToNormalHvga; + } + else if (logicalResolution == RESOLUTION_LOGICAL_240 && physicalResolution == RESOLUTION_PHYSICAL_HD) + { + pTransformer = new (std::nothrow) TransformerNormal240ToNormalHd; + } + else if (logicalResolution == RESOLUTION_LOGICAL_320 && physicalResolution == RESOLUTION_PHYSICAL_WQVGA) + { + pTransformer = new (std::nothrow) TransformerNormal320ToNormalWqvga; + } + else if (logicalResolution == RESOLUTION_LOGICAL_320 && physicalResolution == RESOLUTION_PHYSICAL_WVGA) + { + pTransformer = new (std::nothrow) TransformerNormal320ToNormalWvga; + } + else if (logicalResolution == RESOLUTION_LOGICAL_320 && physicalResolution == RESOLUTION_PHYSICAL_HD) + { + pTransformer = new (std::nothrow) TransformerNormal320ToNormalHd; + } + else if (logicalResolution == RESOLUTION_LOGICAL_480 && physicalResolution == RESOLUTION_PHYSICAL_WQVGA) + { + pTransformer = new (std::nothrow) TransformerNormal480ToNormalWqvga; + } + else if (logicalResolution == RESOLUTION_LOGICAL_480 && physicalResolution == RESOLUTION_PHYSICAL_HVGA) + { + pTransformer = new (std::nothrow) TransformerNormal480ToNormalHvga; + } + else if (logicalResolution == RESOLUTION_LOGICAL_480 && physicalResolution == RESOLUTION_PHYSICAL_HD) + { + pTransformer = new (std::nothrow) TransformerNormal480ToNormalHd; + } + else if (logicalResolution == RESOLUTION_LOGICAL_720 && physicalResolution == RESOLUTION_PHYSICAL_WQVGA) + { + pTransformer = new (std::nothrow) TransformerNormal720ToNormalWqvga; + } + else if (logicalResolution == RESOLUTION_LOGICAL_720 && physicalResolution == RESOLUTION_PHYSICAL_WVGA) + { + pTransformer = new (std::nothrow) TransformerNormal720ToNormalWvga; + } + else if (logicalResolution == RESOLUTION_LOGICAL_720 && physicalResolution == RESOLUTION_PHYSICAL_HVGA) + { + pTransformer = new (std::nothrow) TransformerNormal720ToNormalHvga; + } + else + { + //r = E_INVALID_ARG; + pTransformer = new (std::nothrow) TransformerGeneral(_GetIntegerResolution(logicalResolution), _GetIntegerResolution(physicalResolution)); + } + } + else + { + //r = E_INVALID_ARG; + pTransformer = new (std::nothrow) TransformerGeneral(_GetIntegerResolution(logicalResolution) * _GetIntegerResolution(physicalBaseScreenSize), _GetIntegerResolution(physicalResolution) * _GetIntegerResolution(logicalBaseScreenSize)); + } + + } +#else + if (isInverse) + { + if (logicalBaseScreenSize == physicalBaseScreenSize) + { + pTransformer = new (std::nothrow) TransformerGeneral(_GetIntegerResolution(physicalResolution), _GetIntegerResolution(logicalResolution)); + } + else + { + pTransformer = new (std::nothrow) TransformerGeneral(_GetIntegerResolution(physicalResolution) * _GetIntegerResolution(logicalBaseScreenSize), _GetIntegerResolution(logicalResolution) * _GetIntegerResolution(physicalBaseScreenSize)); + } + } + else + { + if (logicalBaseScreenSize == physicalBaseScreenSize) + { + pTransformer = new (std::nothrow) TransformerGeneral(_GetIntegerResolution(logicalResolution), _GetIntegerResolution(physicalResolution)); + } + else + { + pTransformer = new (std::nothrow) TransformerGeneral(_GetIntegerResolution(logicalResolution) * _GetIntegerResolution(physicalBaseScreenSize), _GetIntegerResolution(physicalResolution) * _GetIntegerResolution(logicalBaseScreenSize)); + } + } +#endif + // Print the log message and return + if (pTransformer) + { + return E_SUCCESS; + } + else if (r == E_INVALID_ARG) + { + SysLog(NID_GRP, "[E_INVALID_ARG] The specified resolutions are invalid."); + + return E_INVALID_ARG; + } + else + { + SysLog(NID_GRP, "[E_OUT_OF_MEMORY] Fail to create a coordinate transformer."); + + return E_OUT_OF_MEMORY; + } +} + + +result +_CoordinateTransformerCore(_ICoordinateSystemTransformer*& pTransformer, int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize) +{ + SysAssert(srcResolution > 0); + SysAssert(destResolution.width > 0); + SysAssert(srcBaseScreenSize != BASE_SCREEN_SIZE_DEFAULT); + SysAssert(destBaseScreenSize != BASE_SCREEN_SIZE_DEFAULT); + + result r = E_SUCCESS; + pTransformer = null; + + if (_WillNotTransform(srcResolution, srcBaseScreenSize, destResolution, destBaseScreenSize)) + { + pTransformer = new (std::nothrow) _NullCoordinateSystemTransformer(); + + if (pTransformer == null) + { + SysLog(NID_GRP, "[E_OUT_OF_MEMORY] Fail to create a coordinate transformer."); + + return E_OUT_OF_MEMORY; + } + + return E_SUCCESS; + } + + pTransformer = new (std::nothrow) TransformerGeneral(srcResolution * _GetIntegerResolution(destBaseScreenSize), (destResolution.width < destResolution.height ? destResolution.width : destResolution.height) * _GetIntegerResolution(srcBaseScreenSize)); + + if (pTransformer) + { + return E_SUCCESS; + } + else if (r == E_INVALID_ARG) + { + SysLog(NID_GRP, "[E_INVALID_ARG] The specified resolutions are invalid."); + + return E_INVALID_ARG; + } + else + { + SysLog(NID_GRP, "[E_OUT_OF_MEMORY] Fail to create a coordinate transformer."); + + return E_OUT_OF_MEMORY; + } +} + + +result +_CreateCoordinateTransformer(_ICoordinateSystemTransformer*& pTransformer, int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize) +{ + return _CoordinateTransformerCore(pTransformer, srcResolution, srcBaseScreenSize, destResolution, destBaseScreenSize); +} + +result +_CreateCoordinateTransformer(_ICoordinateSystemTransformer*& pTransformer, _LogicalResolution sourceLogicalResolution, _BaseScreenSize sourceLogicalBaseScreenSize, _PhysicalResolution destPhysicalResolution, _BaseScreenSize destPhysicalBaseScreenSize) +{ + return _CoordinateTransformerCore(pTransformer, sourceLogicalResolution, sourceLogicalBaseScreenSize, destPhysicalResolution, destPhysicalBaseScreenSize, false); +} + +result +_CreateCoordinateTransformer(_ICoordinateSystemTransformer*& pTransformer, _PhysicalResolution sourcePhysicalResolution, _BaseScreenSize sourcePhysicalBaseScreenSize,_LogicalResolution destLogicalResolution, _BaseScreenSize destLogicalBaseScreenSize) +{ + return _CoordinateTransformerCore(pTransformer, destLogicalResolution, destLogicalBaseScreenSize, sourcePhysicalResolution, sourcePhysicalBaseScreenSize, true); +} + +result +_CreateCoordinateTransformer(_ICoordinateSystemTransformer*& pTransformer, _LogicalResolution sourceLogicalResolution, _BaseScreenSize sourceLogicalBaseScreenSize, _LogicalResolution destLogicalResolution, _BaseScreenSize destLogicalBaseScreenSize) +{ + _PhysicalResolution physicalResolution = RESOLUTION_PHYSICAL_DEFAULT; + + switch (destLogicalResolution) + { + case RESOLUTION_LOGICAL_240: + physicalResolution = RESOLUTION_PHYSICAL_WQVGA; + break; + case RESOLUTION_LOGICAL_320: + physicalResolution = RESOLUTION_PHYSICAL_HVGA; + break; + case RESOLUTION_LOGICAL_480: + physicalResolution = RESOLUTION_PHYSICAL_WVGA; + break; + case RESOLUTION_LOGICAL_720: + physicalResolution = RESOLUTION_PHYSICAL_HD; + break; + case RESOLUTION_LOGICAL_800: + physicalResolution = RESOLUTION_PHYSICAL_WXGA; + break; + case RESOLUTION_LOGICAL_1080: + physicalResolution = RESOLUTION_PHYSICAL_HD1080; + break; + case RESOLUTION_LOGICAL_1600: + physicalResolution = RESOLUTION_PHYSICAL_WQXGA; + break; + default: + physicalResolution = RESOLUTION_PHYSICAL_NONE; + break; + } + + return _CoordinateTransformerCore(pTransformer, sourceLogicalResolution, sourceLogicalBaseScreenSize, physicalResolution, destLogicalBaseScreenSize, false); +} + +}} // Tizen::Graphics + diff --git a/src/graphics/FGrp_CoordinateSystemImpl.cpp b/src/graphics/FGrp_CoordinateSystemImpl.cpp new file mode 100644 index 0000000..cd240e7 --- /dev/null +++ b/src/graphics/FGrp_CoordinateSystemImpl.cpp @@ -0,0 +1,698 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CoordinateSystemImpl.cpp + * @brief This is the implementation file for _CoordinateSystemImpl class. + * + */ + +#include + +#include +#include + +#include +#include +#include +#include + +#include "FGrp_Screen.h" +#include "FGrp_CoordinateSystemImpl.h" + + +using namespace Tizen::Base; + +//////////////////////////////////////////////////////////////////////////////// + +namespace Tizen { namespace Graphics +{ +result _CreateCoordinateTransformer(_ICoordinateSystemTransformer*& pTransformer, const Dimension& srcDim, const Dimension& trgDim); +result _CreateCoordinateTransformer(_ICoordinateSystemTransformer*& pTransformer, _LogicalResolution sourceLogicalResolution, _BaseScreenSize sourceLogicalBaseScreenSize, _PhysicalResolution destPhysicalResolution, _BaseScreenSize destPhysicalBaseScreenSize); +result _CreateCoordinateTransformer(_ICoordinateSystemTransformer*& pTransformer, _PhysicalResolution sourcePhysicalResolution, _BaseScreenSize sourcePhysicalBaseScreenSize, _LogicalResolution destLogicalResolution, _BaseScreenSize destLogicalBaseScreenSize); +result _CreateCoordinateTransformer(_ICoordinateSystemTransformer*& pTransformer, _LogicalResolution sourceLogicalResolution, _BaseScreenSize sourceLogicalBaseScreenSize, _LogicalResolution destLogicalResolution, _BaseScreenSize destLogicalBaseScreenSize); +result _CreateCoordinateTransformer(_ICoordinateSystemTransformer*& pTransformer, int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize); + +bool _WillNotTransform(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize, _PhysicalResolution physicalResolution, _BaseScreenSize physicalBaseScreenSize); +bool _WillNotTransform(int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize); +const char* _GetStringResolution(_LogicalResolution res); +const char* _GetStringResolution(_PhysicalResolution res); + +}} // Tizen::Graphics + +//////////////////////////////////////////////////////////////////////////////// + +namespace Tizen { namespace Graphics +{ + +class _CoordinateSystem::_CoordinateSystemImpl::__CoordinateTransformer + : public _ICoordinateSystemTransformer +{ +public: + __CoordinateTransformer(_ICoordinateSystemTransformer* pXformer) + : __enabled(true) + , __pXformer(pXformer) + , __defaultTransformer() + , __usingDefault(false) + { + if (__pXformer == null) + { + __pXformer = &__defaultTransformer; + __usingDefault = true; + } + } + + virtual ~__CoordinateTransformer() + { + if (!__usingDefault) + { + delete __pXformer; + } + } + + void SetEnabled(bool enabled) + { + __enabled = enabled; + } + + bool IsEnabled(void) const + { + return __enabled; + } + + virtual Rectangle Transform(const Rectangle& rect) const + { + return IsEnabled() ? __pXformer->Transform(rect) : rect; + } + + virtual Dimension Transform(const Dimension& dim) const + { + return IsEnabled() ? __pXformer->Transform(dim) : dim; + } + + virtual Point Transform(const Point& point) const + { + return IsEnabled() ? __pXformer->Transform(point) : point; + } + + virtual int Transform(int scalar) const + { + return IsEnabled() ? __pXformer->Transform(scalar) : scalar; + } + + virtual int TransformHorizontal(int scalar) const + { + return IsEnabled() ? __pXformer->TransformHorizontal(scalar) : scalar; + } + + virtual int TransformVertical(int scalar) const + { + return IsEnabled() ? __pXformer->TransformVertical(scalar) : scalar; + } + + virtual float Transform(float scalar) const + { + return IsEnabled() ? __pXformer->Transform(scalar) : scalar; + } + + virtual float TransformHorizontal(float scalar) const + { + return IsEnabled() ? __pXformer->TransformHorizontal(scalar) : scalar; + } + + virtual float TransformVertical(float scalar) const + { + return IsEnabled() ? __pXformer->TransformVertical(scalar) : scalar; + } + + virtual int TransformFloatToInt(float scalar) const + { + return IsEnabled() ? __pXformer->Transform(static_cast(scalar)) : static_cast(scalar); + } + + virtual int TransformHorizontalFloatToInt(float scalar) const + { + return IsEnabled() ? __pXformer->TransformHorizontal(static_cast(scalar)) : static_cast(scalar); + } + + virtual int TransformVerticalFloatToInt(float scalar) const + { + return IsEnabled() ? __pXformer->TransformVertical(static_cast(scalar)) : static_cast(scalar); + } + + virtual float GetHorizontalScaleFactor(void) const + { + return IsEnabled() ? __pXformer->GetHorizontalScaleFactor() : 1.0f; + } + + virtual float GetVerticalScaleFactor(void) const + { + return IsEnabled() ? __pXformer->GetVerticalScaleFactor() : 1.0f; + } + +private: + __CoordinateTransformer(const __CoordinateTransformer&); + __CoordinateTransformer& operator =(const __CoordinateTransformer&); + +private: + bool __enabled; + _ICoordinateSystemTransformer* __pXformer; + _NullCoordinateSystemTransformer __defaultTransformer; + bool __usingDefault; +}; // _CoordinateSystem + +_LogicalResolution +_CoordinateSystem::_CoordinateSystemImpl::GetNativeLogicalResolution(void) const +{ + return __nativeLogicalResolution; +} + +_BaseScreenSize +_CoordinateSystem::_CoordinateSystemImpl::GetNativeLogicalBaseScreenSize(void) const +{ + return __nativeLogicalBaseScreenSize; +} + +_BaseScreenSize +_CoordinateSystem::_CoordinateSystemImpl::GetLogicalBaseScreenSize(void) const +{ + return __logicalBaseScreenSize; +} + +int +_CoordinateSystem::_CoordinateSystemImpl::GetLogicalResolutionInt(void) const +{ + return __logicalResolutionInt; +} + +_LogicalResolution +_CoordinateSystem::_CoordinateSystemImpl::GetLogicalResolution(void) const +{ + return __logicalResolution; +} + +_PhysicalResolution +_CoordinateSystem::_CoordinateSystemImpl::GetPhysicalResolution(void) const +{ + if (__physicalResolution == RESOLUTION_PHYSICAL_NONE) + { + static Tizen::Graphics::_PhysicalResolution cachedResolution = RESOLUTION_PHYSICAL_NONE; + + if (cachedResolution == RESOLUTION_PHYSICAL_NONE) + { + int screenWidth = _Screen::GetWidth(); + int screenHeight = _Screen::GetHeight(); + + if ((screenWidth == 480 && screenHeight == 800) || (screenWidth == 800 && screenHeight == 480)) + { + cachedResolution = RESOLUTION_PHYSICAL_WVGA; + } + else if ((screenWidth == 240 && screenHeight == 400) || (screenWidth == 400 && screenHeight == 240)) + { + cachedResolution = RESOLUTION_PHYSICAL_WQVGA; + } + else if ((screenWidth == 320 && screenHeight == 480) || (screenWidth == 480 && screenHeight == 320)) + { + cachedResolution = RESOLUTION_PHYSICAL_HVGA; + } + else if ((screenWidth == 720 && screenHeight == 1280) || (screenWidth == 1280 && screenHeight == 720)) + { + cachedResolution = RESOLUTION_PHYSICAL_HD; + } + else if ((screenWidth == 1280 && screenHeight == 800) || (screenWidth == 800 && screenHeight == 1280)) + { + cachedResolution = RESOLUTION_PHYSICAL_WXGA; + } + else if ((screenWidth == 1080 && screenHeight == 1920) || (screenWidth == 1920 && screenHeight == 1080)) + { + cachedResolution = RESOLUTION_PHYSICAL_HD1080; + } + else if ((screenWidth == 1600 && screenHeight == 2560) || (screenWidth == 2560 && screenHeight == 1600)) + { + cachedResolution = RESOLUTION_PHYSICAL_WQXGA; + } + else + { + cachedResolution = RESOLUTION_PHYSICAL_NONE; + } + } + + return cachedResolution; + } + + return __physicalResolution; +} + +Dimension +_CoordinateSystem::_CoordinateSystemImpl::GetPhysicalResolutionDim(void) const +{ + return __physicalResolutionDim; +} + +_BaseScreenSize +_CoordinateSystem::_CoordinateSystemImpl::GetPhysicalBaseScreenSize(void) const +{ + if (__physicalBaseScreenSize == BASE_SCREEN_SIZE_NONE || __physicalBaseScreenSize == BASE_SCREEN_SIZE_DEFAULT) + { + static Tizen::Graphics::_BaseScreenSize physicalBaseScreenSize = BASE_SCREEN_SIZE_NONE; + + bool isLargeDeviceScreenSize = false; + + Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/screen.size.large", isLargeDeviceScreenSize); + + if (isLargeDeviceScreenSize) + { + physicalBaseScreenSize = BASE_SCREEN_SIZE_LARGE; + } + else + { + physicalBaseScreenSize = BASE_SCREEN_SIZE_NORMAL; + } + + return physicalBaseScreenSize; + } + + return __physicalBaseScreenSize; +} + +void +_CoordinateSystem::_CoordinateSystemImpl::SetTransformEnabled(bool enabled) +{ + __pTransformer->SetEnabled(enabled); + __pInverseTransformer->SetEnabled(enabled); +} + +bool +_CoordinateSystem::_CoordinateSystemImpl::IsTransformEnabled(void) const +{ + return __pTransformer->IsEnabled(); +} + + +_ICoordinateSystemTransformer* +_CoordinateSystem::_CoordinateSystemImpl::GetTransformer(void) +{ + return __pTransformer; +} + +_ICoordinateSystemTransformer* +_CoordinateSystem::_CoordinateSystemImpl::GetInverseTransformer(void) +{ + return __pInverseTransformer; +} + +_ICoordinateSystemTransformer* +_CoordinateSystem::_CoordinateSystemImpl::GetTransformerN(const Dimension& srcDim, const Dimension& trgDim) +{ + ClearLastResult(); + + _ICoordinateSystemTransformer* pXFormer = null; + + result r = _CreateCoordinateTransformer(pXFormer, srcDim, trgDim); + + if (IsFailed(r)) + { + SysLog(NID_GRP, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(r); + } + + return pXFormer; +} + +_ICoordinateSystemTransformer* +_CoordinateSystem::_CoordinateSystemImpl::GetTransformerN(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize, _PhysicalResolution physicalResolution, _BaseScreenSize physicalBaseScreenSize) +{ + ClearLastResult(); + + _ICoordinateSystemTransformer* pXFormer = null; + + result r = _CreateCoordinateTransformer(pXFormer, logicalResolution, logicalBaseScreenSize, physicalResolution, physicalBaseScreenSize); + + if (IsFailed(r)) + { + SysLog(NID_GRP, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(r); + } + + return pXFormer; +} + +_ICoordinateSystemTransformer* +_CoordinateSystem::_CoordinateSystemImpl::GetTransformerN(int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize) +{ + ClearLastResult(); + + _ICoordinateSystemTransformer* pXFormer = null; + + result r = _CreateCoordinateTransformer(pXFormer, srcResolution, srcBaseScreenSize, destResolution, destBaseScreenSize); + + if (IsFailed(r)) + { + SysLog(NID_GRP, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(r); + } + + return pXFormer; +} + +result +_CoordinateSystem::_CoordinateSystemImpl::Initialize(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize) +{ + SysAssert(__pTransformer == null && __pInverseTransformer == null); + + result r = E_SUCCESS; + + __physicalBaseScreenSize = GetPhysicalBaseScreenSize(); + + SysAssert(__physicalBaseScreenSize != BASE_SCREEN_SIZE_DEFAULT); + + __physicalResolution = GetPhysicalResolution(); + + SysAssert(__physicalResolution != RESOLUTION_PHYSICAL_DEFAULT); + + if (logicalResolution == RESOLUTION_LOGICAL_DEFAULT) + { + switch (__physicalResolution) + { + case RESOLUTION_PHYSICAL_WVGA: + logicalResolution = RESOLUTION_LOGICAL_480; + break; + case RESOLUTION_PHYSICAL_WQVGA: + logicalResolution = RESOLUTION_LOGICAL_240; + break; + case RESOLUTION_PHYSICAL_HVGA: + logicalResolution = RESOLUTION_LOGICAL_320; + break; + case RESOLUTION_PHYSICAL_HD: + logicalResolution = RESOLUTION_LOGICAL_720; + break; + case RESOLUTION_PHYSICAL_WXGA: + logicalResolution = RESOLUTION_LOGICAL_800; + break; + case RESOLUTION_PHYSICAL_HD1080: + logicalResolution = RESOLUTION_LOGICAL_1080; + break; + case RESOLUTION_PHYSICAL_WQXGA: + logicalResolution = RESOLUTION_LOGICAL_1600; + break; + default: + ; + break; + } + } + + __logicalResolution = logicalResolution; + + if (logicalBaseScreenSize == BASE_SCREEN_SIZE_DEFAULT) + { + logicalBaseScreenSize = BASE_SCREEN_SIZE_NORMAL; + } + + __logicalBaseScreenSize = logicalBaseScreenSize; + + _ICoordinateSystemTransformer* pXformer = null; + _ICoordinateSystemTransformer* pInvXFormer = null; + + r = _CreateCoordinateTransformer(pXformer, __logicalResolution, __logicalBaseScreenSize, __physicalResolution, __physicalBaseScreenSize); + + if (IsFailed(r)) + { + SysLog(NID_GRP, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + } + + __pTransformer = new (std::nothrow) __CoordinateTransformer(pXformer); + + if (__pTransformer == null) + { + delete pXformer; + r = E_OUT_OF_MEMORY; + SysLog(NID_GRP, "[%s] Failed to create a coordinate transformer.", GetErrorMessage(r)); + + goto CATCH; + } + + r = _CreateCoordinateTransformer(pInvXFormer, __physicalResolution, __physicalBaseScreenSize, __logicalResolution, __logicalBaseScreenSize); + + if (IsFailed(r)) + { + SysLog(NID_GRP, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + } + + __pInverseTransformer = new (std::nothrow) __CoordinateTransformer(pInvXFormer); + + if (__pInverseTransformer == null) + { + delete pInvXFormer; + r = E_OUT_OF_MEMORY; + SysLog(NID_GRP, "[%s] Failed to create an inverse coordinate transformer.", GetErrorMessage(r)); + + goto CATCH; + } + + SysAssert(__pTransformer && __pInverseTransformer); + SetTransformEnabled(!_WillNotTransform(__logicalResolution, __logicalBaseScreenSize, __physicalResolution, __physicalBaseScreenSize)); + +//temporary code + __nativeLogicalResolution = logicalResolution; + __nativeLogicalBaseScreenSize = logicalBaseScreenSize; + + if (__nativeLogicalBaseScreenSize != __physicalBaseScreenSize) + { + __nativeLogicalBaseScreenSize = __physicalBaseScreenSize; + + if (__nativeLogicalBaseScreenSize == BASE_SCREEN_SIZE_NORMAL) + { + switch (__nativeLogicalResolution) + { + case RESOLUTION_LOGICAL_1600: + __nativeLogicalResolution = RESOLUTION_LOGICAL_800; + break; + case RESOLUTION_LOGICAL_1440: + __nativeLogicalResolution = RESOLUTION_LOGICAL_720; + break; + case RESOLUTION_LOGICAL_960: + __nativeLogicalResolution = RESOLUTION_LOGICAL_480; + break; + case RESOLUTION_LOGICAL_720: + __nativeLogicalResolution = RESOLUTION_LOGICAL_360; + break; + case RESOLUTION_LOGICAL_480: + __nativeLogicalResolution = RESOLUTION_LOGICAL_240; + break; + default: + ; + break; + } + } + else if (__nativeLogicalBaseScreenSize == BASE_SCREEN_SIZE_LARGE) + { + switch (__nativeLogicalResolution) + { + case RESOLUTION_LOGICAL_800: + __nativeLogicalResolution = RESOLUTION_LOGICAL_1600; + break; + case RESOLUTION_LOGICAL_720: + __nativeLogicalResolution = RESOLUTION_LOGICAL_1440; + break; + case RESOLUTION_LOGICAL_480: + __nativeLogicalResolution = RESOLUTION_LOGICAL_960; + break; + case RESOLUTION_LOGICAL_360: + __nativeLogicalResolution = RESOLUTION_LOGICAL_720; + break; + case RESOLUTION_LOGICAL_240: + __nativeLogicalResolution = RESOLUTION_LOGICAL_480; + break; + default: + ; + break; + } + } + } + + return r; + +CATCH: + delete __pTransformer; + __pTransformer = null; + delete __pInverseTransformer; + __pInverseTransformer = null; + + return r; +} + +result +_CoordinateSystem::_CoordinateSystemImpl::Initialize(int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize) +{ + SysAssert(__pTransformer == null && __pInverseTransformer == null); + + result r = E_SUCCESS; + + if (srcBaseScreenSize == BASE_SCREEN_SIZE_DEFAULT) + { + srcBaseScreenSize = GetPhysicalBaseScreenSize(); + } + + __logicalBaseScreenSize = srcBaseScreenSize; + + __physicalResolutionDim = destResolution; + + if (srcResolution != 0) + { + __logicalResolutionInt = srcResolution; + } + else + { + __logicalResolutionInt = __physicalResolutionDim.width < __physicalResolutionDim.height ? __physicalResolutionDim.width : __physicalResolutionDim.height; + } + + SysAssert(__logicalResolutionInt > 0); + + if (destBaseScreenSize == BASE_SCREEN_SIZE_DEFAULT) + { + destBaseScreenSize = GetPhysicalBaseScreenSize(); + } + + __physicalBaseScreenSize = destBaseScreenSize; + + if (srcResolution == 480 || srcResolution == 720) + { + _LogicalResolution logicalResolution = RESOLUTION_LOGICAL_NONE; + + if (srcResolution == 480) + { + logicalResolution = RESOLUTION_LOGICAL_480; + } + else + { + logicalResolution = RESOLUTION_LOGICAL_720; + } + + Dimension wvgaDim1 = Dimension(480, 800); + Dimension wvgaDim2 = Dimension(800, 480); + Dimension hdDim1 = Dimension(720, 1280); + Dimension hdDim2 = Dimension(1280, 720); + + _PhysicalResolution physicalResolution = RESOLUTION_PHYSICAL_NONE; + + if (destResolution == wvgaDim1 || destResolution == wvgaDim2 || destResolution == hdDim1 || destResolution == hdDim2) + { + if (destResolution == wvgaDim1 || destResolution == wvgaDim2) + { + physicalResolution = RESOLUTION_PHYSICAL_WVGA; + } + else + { + physicalResolution = RESOLUTION_PHYSICAL_HD; + } + } + + if (physicalResolution == GetPhysicalResolution() && physicalResolution != RESOLUTION_PHYSICAL_NONE) + { + result r = Initialize(logicalResolution, srcBaseScreenSize); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + } + } + + _ICoordinateSystemTransformer* pXformer = null; + _ICoordinateSystemTransformer* pInvXFormer = null; + + r = _CreateCoordinateTransformer(pXformer, __logicalResolutionInt, __logicalBaseScreenSize, __physicalResolutionDim, __physicalBaseScreenSize); + + if (IsFailed(r)) + { + SysLog(NID_GRP, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + } + + __pTransformer = new (std::nothrow) __CoordinateTransformer(pXformer); + + if (__pTransformer == null) + { + delete pXformer; + r = E_OUT_OF_MEMORY; + SysLog(NID_GRP, "[%s] Failed to create a coordinate transformer.", GetErrorMessage(r)); + + goto CATCH; + } + + r = _CreateCoordinateTransformer(pInvXFormer, (__physicalResolutionDim.width < __physicalResolutionDim.height ? __physicalResolutionDim.width : __physicalResolutionDim.height), __physicalBaseScreenSize, Dimension(__logicalResolutionInt, __logicalResolutionInt), __logicalBaseScreenSize); + + if (IsFailed(r)) + { + SysLog(NID_GRP, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + } + + __pInverseTransformer = new (std::nothrow) __CoordinateTransformer(pInvXFormer); + + if (__pInverseTransformer == null) + { + delete pInvXFormer; + r = E_OUT_OF_MEMORY; + SysLog(NID_GRP, "[%s] Failed to create an inverse coordinate transformer.", GetErrorMessage(r)); + + goto CATCH; + } + + SysAssert(__pTransformer && __pInverseTransformer); + SetTransformEnabled(!_WillNotTransform(srcResolution, srcBaseScreenSize, destResolution, destBaseScreenSize)); + + return r; + +CATCH: + delete __pTransformer; + __pTransformer = null; + delete __pInverseTransformer; + __pInverseTransformer = null; + + return r; +} + +_CoordinateSystem::_CoordinateSystemImpl::_CoordinateSystemImpl(void) + : __pTransformer(null) + , __pInverseTransformer(null) + , __nativeLogicalResolution(RESOLUTION_LOGICAL_NONE) + , __nativeLogicalBaseScreenSize(BASE_SCREEN_SIZE_NONE) + , __logicalResolution(RESOLUTION_LOGICAL_NONE) + , __logicalBaseScreenSize(BASE_SCREEN_SIZE_NONE) + , __physicalResolution(RESOLUTION_PHYSICAL_NONE) + , __physicalBaseScreenSize(BASE_SCREEN_SIZE_NONE) + , __logicalResolutionInt(0) + , __physicalResolutionDim(0, 0) +{ +} + +_CoordinateSystem::_CoordinateSystemImpl::~_CoordinateSystemImpl(void) +{ + delete __pTransformer; + delete __pInverseTransformer; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_CoordinateSystemImpl.h b/src/graphics/FGrp_CoordinateSystemImpl.h new file mode 100644 index 0000000..dd33760 --- /dev/null +++ b/src/graphics/FGrp_CoordinateSystemImpl.h @@ -0,0 +1,90 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CoordinateSystemImpl.h + * @brief This is the header file for _CoordinateSystemImpl class. + * + */ + +#ifndef _FGRP_INTERNAL_COORDINATE_SYSTEMIMPL_H_ +#define _FGRP_INTERNAL_COORDINATE_SYSTEMIMPL_H_ + +#include "FGrp_CoordinateSystem.h" +#include "FGrp_CoordinateSystemImpl.h" + + +namespace Tizen { namespace Graphics +{ + +class _CoordinateSystem::_CoordinateSystemImpl +{ +public: + _CoordinateSystemImpl(void); + ~_CoordinateSystemImpl(void); + + _LogicalResolution GetNativeLogicalResolution(void) const; + _BaseScreenSize GetNativeLogicalBaseScreenSize(void) const; + + _LogicalResolution GetLogicalResolution(void) const; + int GetLogicalResolutionInt(void) const; + + _PhysicalResolution GetPhysicalResolution(void) const; + Dimension GetPhysicalResolutionDim(void) const; + + _BaseScreenSize GetLogicalBaseScreenSize(void) const; + _BaseScreenSize GetPhysicalBaseScreenSize(void) const; + + result Initialize(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize); + result Initialize(int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize); + + _ICoordinateSystemTransformer* GetTransformer(void); + _ICoordinateSystemTransformer* GetInverseTransformer(void); + + static _ICoordinateSystemTransformer* GetTransformerN(const Dimension& srcDim, const Dimension& trgDim); + static _ICoordinateSystemTransformer* GetTransformerN(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize, _PhysicalResolution physicalResolution, _BaseScreenSize physicalBaseScreenSize); + static _ICoordinateSystemTransformer* GetTransformerN(int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize); + + void SetTransformEnabled(bool enabled); + bool IsTransformEnabled(void) const; + +private: + _CoordinateSystemImpl(const _CoordinateSystemImpl&); + _CoordinateSystemImpl& operator =(const _CoordinateSystemImpl&); + +private: + class __CoordinateTransformer; + __CoordinateTransformer* __pTransformer; + __CoordinateTransformer* __pInverseTransformer; + + _LogicalResolution __nativeLogicalResolution; + _BaseScreenSize __nativeLogicalBaseScreenSize; + + _LogicalResolution __logicalResolution; + _BaseScreenSize __logicalBaseScreenSize; + + _PhysicalResolution __physicalResolution; + _BaseScreenSize __physicalBaseScreenSize; + + int __logicalResolutionInt; + Dimension __physicalResolutionDim; + +}; // _CoordinateSystemImpl + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_COORDINATE_SYSTEMIMPL_H_ diff --git a/src/graphics/FGrp_EnrichedTextImpl.cpp b/src/graphics/FGrp_EnrichedTextImpl.cpp new file mode 100644 index 0000000..59bdfd6 --- /dev/null +++ b/src/graphics/FGrp_EnrichedTextImpl.cpp @@ -0,0 +1,1494 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_EnrichedTextImpl.cpp + * @brief This is the cpp file for _EnrichedTextImpl class. + * + */ + +// Inlcudes +#include +#include "FGrp_EnrichedTextImpl.h" +#include "FGrp_TextElementImpl.h" +#include "FGrp_TextTextElement.h" +#include "FGrp_TextTextObject.h" +#include "util/FGrp_Util.h" + +// Usings +using namespace Tizen::Base; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Graphics +{ + +_EnrichedTextImpl::_EnrichedTextImpl(void) +{ + __width = 0; + __height = 0; + __lineSpace = 0; + __count = 0; + __verticalAlignment = TEXT_ALIGNMENT_VERTICAL_MIN; + __horizontalAlignment = TEXT_ALIGNMENT_HORIZONTAL_MIN; + __elementVerticalAlignment = TEXT_ALIGNMENT_VERTICAL_MIN; + __pLinkedListTextElementList = null; + __pTextElement = null; + __isCopiedEnrichedText = false; + __pLinkedListTextElementList = null; + __pTextElement = null; +} + +_EnrichedTextImpl::~_EnrichedTextImpl(void) +{ + if (GetTextElementCount() > 0) + { + RemoveAllTextElements(false); + } + + if (__pTextElement) + { + delete __pTextElement; + __pTextElement = null; + } + + if (__pLinkedListTextElementList) + { + delete __pLinkedListTextElementList; + __pLinkedListTextElementList = null; + } +} + +result +_EnrichedTextImpl::Construct(const Tizen::Graphics::Dimension& dim) +{ + SysTryReturn(NID_GRP, (dim.width > 0) && (dim.height > 0), E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The argument is invalid. (width = %d height = %d)", dim.width, dim.height); + + result r = E_SUCCESS; + + __width = dim.width; + __height = dim.height; + __lineSpace = 0; + + __pLinkedListTextElementList = new (std::nothrow) Tizen::Base::Collection::LinkedList; + SysTryCatch(NID_GRP + , __pLinkedListTextElementList + , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Fails to create a element list.", GetErrorMessage(r)); + + __pTextElement = new (std::nothrow) TextElement(); + SysTryCatch(NID_GRP + , __pTextElement + , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Fails to create a element.", GetErrorMessage(r)); + + __pTextObject.reset(new (std::nothrow)TextObject); + SysTryCatch(NID_GRP + , __pTextObject + , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Fails to create a TextObject.", GetErrorMessage(r)); + + __pTextObject->Construct(); + __pTextObject->SetBounds(Rectangle(0, 0, __width, __height)); + __pTextObject->SetCutLinkViewMode(true); + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT); + __pTextObject->HideFrontSpace(TEXT_OBJECT_SPACE_HIDE_TYPE_ONE); + + // this is only to manage user's bitmap + r = __elements.Construct(); + + return r; + +CATCH: + if (__pLinkedListTextElementList) + { + delete __pLinkedListTextElementList; + __pLinkedListTextElementList = null; + } + + if (__pTextElement) + { + delete __pTextElement; + __pTextElement = null; + } + + return r; +} + +result +_EnrichedTextImpl::InsertAt(int elementIndex, Tizen::Graphics::TextElement& element) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, elementIndex >= 0 && elementIndex <= GetTextElementCount() + , E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + int textLength = 0; + int count = 0; + _TextElementImpl* pTextElementImpl = _TextElementImpl::GetInstance(element); + if (pTextElementImpl == null) + { + return E_INVALID_ARG; + } + + if (pTextElementImpl->GetRegisteringEnrichedText() != null) + { + return E_INVALID_ARG; + } + pTextElementImpl->SetRegisteringEnrichedText(this); + + count = __pTextObject->GetElementCount(); + if (elementIndex > count) + { + return E_INVALID_ARG; + } + + for (int i = 0; i < elementIndex; i++) + { + _Text::TextElement* pTextComponent = __pTextObject->GetElementAtElementIndex(i); + if (pTextComponent != null) + { + textLength = textLength + pTextComponent->GetTextLength(); + } + } + + __pTextObject->InsertElementAt(textLength, *(pTextElementImpl->GetComponent())); + __pTextObject->Compose(); + + r = __pLinkedListTextElementList->InsertAt(element, elementIndex); + + if (__isCopiedEnrichedText == false) + { + if (__pTextElement) + { + __elements.InsertAt(*__pTextElement, elementIndex); + } + } + + return r; +} + +result +_EnrichedTextImpl::RemoveAt(int elementIndex, bool deallocate) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, elementIndex >= 0 && elementIndex <= GetTextElementCount() + , E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The argument is invalid."); + + if (__pTextObject.use_count() > 1) + { + return E_SUCCESS; + } + + result r = E_SUCCESS; + int count = GetTextElementCount(); + TextElement* pTextElement = null; + + if (count == 0) + { + return E_SUCCESS; + } + + pTextElement = dynamic_cast < TextElement* >(__pLinkedListTextElementList->GetAt(elementIndex)); + if (pTextElement == null) //Bitmap?? + { + __pTextObject->RemoveElementAt(elementIndex, deallocate); + __pLinkedListTextElementList->RemoveAt(elementIndex, true); + + if (__isCopiedEnrichedText == false) + { + __elements.RemoveAt(elementIndex, deallocate); + } + } + else + { + _TextElementImpl* pTextElementImpl = _TextElementImpl::GetInstance(*pTextElement); + pTextElementImpl->SetRegisteringEnrichedText(null); + _Text::TextElement* pTextComponent = pTextElementImpl->GetComponent(); + + __pTextObject->RemoveElement(*pTextComponent, false); + __pLinkedListTextElementList->RemoveAt(elementIndex, deallocate); + + if (__isCopiedEnrichedText == false) + { + __elements.RemoveAt(elementIndex, false); + } + } + + return r; +} + +result +_EnrichedTextImpl::Remove(Tizen::Graphics::TextElement& element, bool deallocate) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + if (__pTextObject.use_count() > 1) + { + return E_SUCCESS; + } + + int textElementIndex = 0; + result r = E_SUCCESS; + TextElement* pTextElement = null; + + r = __pLinkedListTextElementList->IndexOf(element, textElementIndex); + if (r != E_SUCCESS) + { + return E_INVALID_ARG; + } + + pTextElement = dynamic_cast < TextElement* >(__pLinkedListTextElementList->GetAt(textElementIndex)); + if (pTextElement) + { + _TextElementImpl* pTextElementImpl = _TextElementImpl::GetInstance(*pTextElement); + pTextElementImpl->SetRegisteringEnrichedText(null); + _Text::TextElement* pTextComponent = pTextElementImpl->GetComponent(); + + if (__pTextObject->RemoveElement(*pTextComponent, false) != E_SUCCESS) + { + return E_INVALID_ARG; + } + + __pLinkedListTextElementList->RemoveAt(textElementIndex, deallocate); + } + + return r; +} + +result +_EnrichedTextImpl::Add(Tizen::Graphics::TextElement& element) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + result r = E_SUCCESS; + + _TextElementImpl* pTextElementImpl = _TextElementImpl::GetInstance(element); + SysTryReturn(NID_GRP + , pTextElementImpl + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _Text::TextElement* pTextComponent = pTextElementImpl->GetComponent(); + SysTryReturn(NID_GRP + , pTextComponent + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + if (pTextElementImpl->GetRegisteringEnrichedText() != null) + { + return E_INVALID_ARG; + } + pTextElementImpl->SetRegisteringEnrichedText(this); + + __pTextObject->AppendElement(*pTextComponent); + __pTextObject->SetRange(0, __pTextObject->GetTextLength()); + __pTextObject->Compose(); + + __pLinkedListTextElementList->Add(element); + + if (__isCopiedEnrichedText == false) + { + if (__pTextElement) + { + __elements.Add(*__pTextElement); + } + } + + return r; +} + +result +_EnrichedTextImpl::RemoveAllTextElements(bool deallocate) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + result r = E_SUCCESS; + int elementCount = __pLinkedListTextElementList->GetCount(); + + for (int i = 0; i < elementCount; i++) + { + r = RemoveAt(0, deallocate); + r |= r; + } + + if (r != E_SUCCESS) + { + return E_SYSTEM; + } + + return r; +} + +result +_EnrichedTextImpl::RemoveAll(bool deallocate) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + result r = E_SUCCESS; + + int elementCount = __pLinkedListTextElementList->GetCount(); + + for (int i = 0; i < elementCount; i++) + { + r = RemoveAt(0, deallocate); + r |= r; + } + + if (r != E_SUCCESS) + { + return E_SYSTEM; + } + + return E_SUCCESS; +} + +TextElement* +_EnrichedTextImpl::GetTextElementAt(int elementIndex) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, null, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, elementIndex >= 0 && elementIndex < GetTextElementCount(), null, E_INVALID_ARG + , "[E_INVALID_ARG] The argument is invalid. elementIndex = %d total element count = %d", elementIndex, GetTextElementCount()); + + TextElement* pElement = null; + + ClearLastResult(); + + pElement = dynamic_cast < TextElement* >(__pLinkedListTextElementList->GetAt(elementIndex)); + + SetLastResult(E_SUCCESS); + return pElement; +} + +int +_EnrichedTextImpl::GetTextElementCount(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, 0, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + return __pLinkedListTextElementList->GetCount(); +} + +result +_EnrichedTextImpl::SetSize(const Tizen::Graphics::Dimension& size) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, (size.width > 0) && (size.height > 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE + , "[E_OUT_OF_RANGE] The given rectangle(width:%d,height:%d) is out of range.\n", size.width, size.height); + + Rectangle rect(0, 0, size.width, size.height); + + __pTextObject->SetBounds(rect); + __width = rect.width; + __height = rect.height; + + return E_SUCCESS; +} + +result +_EnrichedTextImpl::SetSize(int width, int height) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, (width > 0) && (height > 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE + , "[E_OUT_OF_RANGE] The given rectangle(width:%d,height:%d) is out of range.\n", width, height); + + Dimension dim(width, height); + + result r = SetSize(dim); + + return r; +} + +Tizen::Graphics::Dimension +_EnrichedTextImpl::GetSize(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, Dimension(0, 0), E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + Dimension dim; + + dim.width = __width; + dim.height = __height; + + return dim; +} + +void +_EnrichedTextImpl::GetSize(int& width, int& height) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, , E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + width = __width; + height = __height; +} + +int +_EnrichedTextImpl::GetWidth(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, 0, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + return __width; +} + +int +_EnrichedTextImpl::GetHeight(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, 0, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + return __height; +} + +result +_EnrichedTextImpl::SetVerticalAlignment(TextVerticalAlignment alignment) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + TextObjectAlignment verticalAlign = ConvertVAlignment(alignment); + if (verticalAlign == TEXT_OBJECT_ALIGNMENT_INVALID) + { + return E_INVALID_ARG; + } + + TextObjectAlignment align = static_cast < TextObjectAlignment >((static_cast < TextObjectAlignment >(__pTextObject->GetAlignment()) + & TEXT_HORIZONTAL_ALIGNMENT) | (verticalAlign & TEXT_VERTICAL_ALIGNMENT)); + + __pTextObject->SetAlignment(align); + __verticalAlignment = alignment; + + return E_SUCCESS; +} + +result +_EnrichedTextImpl::SetHorizontalAlignment(TextHorizontalAlignment alignment) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + TextObjectAlignment horizontalAalign = ConvertHAlignment(alignment); + if (horizontalAalign == TEXT_OBJECT_ALIGNMENT_INVALID) + { + return E_INVALID_ARG; + } + + TextObjectAlignment align = static_cast < TextObjectAlignment >((static_cast < TextObjectAlignment >(__pTextObject->GetAlignment()) + & TEXT_VERTICAL_ALIGNMENT) | (horizontalAalign & TEXT_HORIZONTAL_ALIGNMENT)); + + __pTextObject->SetAlignment(align); + __horizontalAlignment = alignment; + + return E_SUCCESS; +} + +TextVerticalAlignment +_EnrichedTextImpl::GetVerticalAlignment(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, TEXT_ALIGNMENT_VERTICAL_MIN, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + return __verticalAlignment; +} + +TextHorizontalAlignment +_EnrichedTextImpl::GetHorizontalAlignment(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, TEXT_ALIGNMENT_HORIZONTAL_MIN, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + return __horizontalAlignment; +} + +result +_EnrichedTextImpl::SetTextWrapStyle(TextWrap wrap) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + SysTryReturn(NID_GRP, (TEXT_WRAP_MIN < wrap) && (wrap < TEXT_WRAP_MAX), E_INVALID_ARG, E_INVALID_ARG + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + _TextWrapType textWrap = ConvertWrapType(wrap); + + if (__pTextObject->SetWrap(static_cast < TextObjectWrapType >(textWrap)) != E_SUCCESS) + { + return E_INVALID_ARG; + } + + return E_SUCCESS; +} + +TextWrap +_EnrichedTextImpl::GetTextWrapStyle(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, TEXT_WRAP_MIN, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + _TextWrapType textWrapType = static_cast < _TextWrapType >(__pTextObject->GetWrap()); + TextWrap textWrap = ConvertWrap(textWrapType); + + return textWrap; +} + +result +_EnrichedTextImpl::SetTextAbbreviationEnabled(bool enable) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + TextObjectActionType action = TEXT_OBJECT_ACTION_TYPE_NONE; + + if (enable) + { + action = TEXT_OBJECT_ACTION_TYPE_ABBREV; + } + + __pTextObject->SetAction(action); + + return E_SUCCESS; +} + +bool +_EnrichedTextImpl::IsTextAbbreviationEnabled(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, false, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + bool r = false; + TextObjectActionType action = __pTextObject->GetAction(); + + if (action & TEXT_OBJECT_ACTION_TYPE_ABBREV) + { + r = true; + } + + return r; +} + +result +_EnrichedTextImpl::SetLineSpace(int lineSpace) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, lineSpace > 0, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The argument is invalid."); + + __lineSpace = lineSpace; + __pTextObject->SetLineSpace(__lineSpace); + + return E_SUCCESS; +} + +int +_EnrichedTextImpl::GetLineSpace(void) const +{ + return __lineSpace; +} + +void +_EnrichedTextImpl::Refresh(void) +{ + SysTryReturn(NID_GRP, __pTextObject != null, , E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + __pTextObject->Compose(); +} + +int +_EnrichedTextImpl::GetTotalLineCount(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, 0, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + __pTextObject->Compose(); + + return __pTextObject->GetTotalLineCount(); +} + +int +_EnrichedTextImpl::GetTotalLineHeight(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, 0, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + int height = __pTextObject->GetTotalHeight(); + + __pTextObject->Compose(); + + return height; +} + +int +_EnrichedTextImpl::GetDisplayLineCount(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, 0, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + int count = __pTextObject->GetDisplayLineCount(); + + __pTextObject->Compose(); + + if (count == 0xFFFF) + { + return 0; + } + + return count; +} + +int +_EnrichedTextImpl::GetLineLength(int lineIndex) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, -1, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, GetTextElementCount() != 0, -1, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] It doesn't have TextElement."); + SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG + , "[E_INVALID_ARG] The invalid lineIndex(%d) is given.", lineIndex); + + int totalLineCount = __pTextObject->GetTotalLineCount(); + + if (lineIndex > totalLineCount) + { + return E_INVALID_ARG; + } + + int lineLength = -1; + + ClearLastResult(); + + __pTextObject->Compose(); + + lineLength = __pTextObject->GetTextLengthAt(lineIndex); + if (lineLength == -1) + { + SetLastResult(E_INVALID_ARG); + return -1; + } + else + { + SetLastResult(E_SUCCESS); + return lineLength; + } +} + +int +_EnrichedTextImpl::GetFirstTextIndex(int lineIndex) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, -1, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG + , "[E_INVALID_ARG] The invalid lineIndex(%d) is given.", lineIndex); + + ClearLastResult(); + __pTextObject->Compose(); + + int totalLineCount = __pTextObject->GetTotalLineCount(); + if (lineIndex >= totalLineCount) + { + SetLastResult(E_INVALID_ARG); + return -1; + } + + int textIndex = __pTextObject->GetFirstTextIndexAt(lineIndex); + if (textIndex == -1) + { + SetLastResult(E_INVALID_ARG); + return -1; + } + else + { + SetLastResult(E_SUCCESS); + return textIndex; + } +} + +int +_EnrichedTextImpl::GetLineIndex(int textIndex) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, -1, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, textIndex >= 0, -1, E_INVALID_ARG + , "[E_INVALID_ARG] The invalid lineIndex(%d) is given.", textIndex); + + ClearLastResult(); + __pTextObject->Compose(); + + int totalLineCount = __pTextObject->GetTotalLineCount(); + int lineIndex = __pTextObject->GetLineIndexAtTextIndex(textIndex); + + if ((lineIndex > totalLineCount) || (textIndex > totalLineCount) || (lineIndex == -1)) + { + SetLastResult(E_INVALID_ARG); + return -1; + } + else + { + SetLastResult(E_SUCCESS); + return lineIndex; + } +} + +int +_EnrichedTextImpl::GetLineHeight(int lineIndex) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, -1, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, lineIndex >= 0, -1, E_INVALID_ARG + , "[E_INVALID_ARG] The invalid lineIndex(%d) is given.\n", lineIndex); + + ClearLastResult(); + __pTextObject->Compose(); + + int totalLineCount = __pTextObject->GetTotalLineCount(); + if (lineIndex >= totalLineCount) + { + SetLastResult(E_INVALID_ARG); + return -1; + } + + int height = __pTextObject->GetLineHeightAt(lineIndex); + + SetLastResult(E_SUCCESS); + return height; +} + +int +_EnrichedTextImpl::GetTextLength(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, 0, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet."); + + if (GetTextElementCount() == 0) + { + return 0; + } + + __pTextObject->Compose(); + + return __pTextObject->GetTextLength(); +} + +result +_EnrichedTextImpl::GetTextExtent(int startTextIndex, int textLength, int& width, int& height, int& actualLength) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, textLength >= 0, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The given text length(%d) is invalid\n", textLength); + SysTryReturn(NID_GRP, startTextIndex <= GetTextLength(), E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] 'startTextIndex' is greater than or equal to the text length."); + + Dimension textSize; + + actualLength = 0; + + if (GetTextLength() == 0) + { + width = 0; + height = 0; + + return E_SUCCESS; + } + + if (startTextIndex + textLength <= 0) + { + width = 0; + height = 0; + + return E_SUCCESS; + } + + __pTextObject->Compose(); + textSize = __pTextObject->GetTextExtent(startTextIndex, textLength); + width = textSize.width; + height = textSize.height; + + if (GetTextLength() - startTextIndex > textLength) + { + actualLength = textLength; + } + else + { + actualLength = GetTextLength() - startTextIndex; + } + + return E_SUCCESS; +} + +result +_EnrichedTextImpl::GetTextExtent(int startTextIndex, int textLength, Tizen::Graphics::Dimension& size, int &actualLength) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + SysTryReturn(NID_GRP, textLength >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given text length(%d) is invalid\n", textLength); + SysTryReturn(NID_GRP, startTextIndex <= GetTextLength(), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] 'startTextIndex' is greater than or equal to the text length.\n"); + + actualLength = 0; + + if (GetTextLength() == 0) + { + size.width = 0; + size.height = 0; + + return E_SUCCESS; + } + + if (startTextIndex + textLength <= 0) + { + size.width = 0; + size.height = 0; + + return E_SUCCESS; + } + + __pTextObject->Compose(); + + size = __pTextObject->GetTextExtent(startTextIndex, textLength); + if (GetTextLength() - startTextIndex > textLength) + { + actualLength = textLength; + } + else + { + actualLength = GetTextLength() - startTextIndex; + } + + return E_SUCCESS; +} + +Tizen::Graphics::Dimension +_EnrichedTextImpl::GetTextExtent(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, Dimension(-1, -1), E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not constructed yet.\n"); + + Dimension size(0,0); + if (GetTextLength() == 0) + { + return size; + } + + __pTextObject->Compose(); + + Rectangle rtBound = __pTextObject->GetBounds(); + if (rtBound.width >= 0 && rtBound.height >= 0) + { + size.width = rtBound.width; + size.height = __pTextObject->GetTotalHeight(); + + return size; + } + else + { + size.width = -1; + size.height = -1; + + return size; + } +} + +result +_EnrichedTextImpl::Add(const Tizen::Graphics::Bitmap& bitmap) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, &bitmap, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The source bitmap is invalid."); + SysTryReturn(NID_GRP, _Util::CheckValidity(&bitmap), E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The source bitmap is invalid."); + + result r = E_SUCCESS; + + Bitmap* pBitmap = const_cast < Bitmap* >(&bitmap); + Bitmap* pNewBitmap = new (std::nothrow) Bitmap(); + if (pNewBitmap == null) + { + SysLog(NID_GRP, "[E_OUT_OF_MEMORY] Fail to create a bitmap."); + return E_OUT_OF_MEMORY; + } + + r = pNewBitmap->Construct(*pBitmap, Rectangle(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight())); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to append image.", GetErrorMessage(r)); + + __pTextObject->AppendElement(*pNewBitmap, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + __pTextObject->Compose(); + + r = __pLinkedListTextElementList->Add(*pNewBitmap); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to add image.", GetErrorMessage(r)); + + if (__isCopiedEnrichedText == false) + { + __elements.Add(bitmap); + } + + return E_SUCCESS; + +CATCH: + if (pNewBitmap) + { + delete pNewBitmap; + pNewBitmap = null; + } + return r; +} + +result +_EnrichedTextImpl::InsertAt(int elementIndex, const Tizen::Graphics::Bitmap& bitmap) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, &bitmap, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The source bitmap is invalid."); + SysTryReturn(NID_GRP, _Util::CheckValidity(&bitmap), E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The source bitmap is invalid."); + SysTryReturn(NID_GRP, elementIndex >= 0 && elementIndex <= GetTextElementCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE + , "[E_OUT_OF_RANGE] The given text index is invalid."); + + result r = E_SUCCESS; + _Text::TextElement* pTextComponent = null; + int textLength = 0; + int count = __pTextObject->GetElementCount(); + if (elementIndex > count) + { + return E_INVALID_ARG; + } + + Bitmap* pBitmap = const_cast < Bitmap* >(&bitmap); + Bitmap* pNewBitmap = new (std::nothrow) Bitmap(); + if (pNewBitmap == null) + { + SysLog(NID_GRP, "[E_OUT_OF_MEMORY] Fail to create a bitmap."); + return E_OUT_OF_MEMORY; + } + + r = pNewBitmap->Construct(*pBitmap, Rectangle(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight())); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to insert image.", GetErrorMessage(r)); + + for (int i = 0; i < elementIndex; i++) + { + pTextComponent = __pTextObject->GetElementAtElementIndex(i); + if (pTextComponent != null) + { + textLength = textLength + pTextComponent->GetTextLength(); + } + } + + __pTextObject->InsertElementAt(textLength, *pNewBitmap, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + __pTextObject->Compose(); + + r = __pLinkedListTextElementList->InsertAt(*pNewBitmap, elementIndex); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to insert image.", GetErrorMessage(r)); + + if (__isCopiedEnrichedText == false) + { + __elements.InsertAt(bitmap, elementIndex); + } + + return E_SUCCESS; + +CATCH: + if (pNewBitmap) + { + delete pNewBitmap; + pNewBitmap = null; + } + + return r; +} + +result +_EnrichedTextImpl::GetLinkInfoFromPosition(const Point& point, Tizen::Base::Utility::LinkInfo& linkInfo) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, GetTextElementCount() > 0, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND + , "[E_OBJ_NOT_FOUND] The TextElement does not exist."); + SysTryReturn(NID_GRP, point.x >= 0 && point.y >= 0, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The invalid position is given."); + SysTryReturn(NID_GRP, GetWidth() >= point.x && GetHeight() >= point.y, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The invalid position is given."); + + return GetLinkInfoFromPosition(point.x, point.y, linkInfo); +} + +result +_EnrichedTextImpl::GetLinkInfoFromPosition(int x, int y, Tizen::Base::Utility::LinkInfo& linkInfo) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + SysTryReturn(NID_GRP, GetTextElementCount() > 0, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND + , "[E_OBJ_NOT_FOUND] The TextElement does not exist."); + SysTryReturn(NID_GRP, x >= 0 && y >= 0, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The invalid position is given."); + SysTryReturn(NID_GRP, GetWidth() >= x && GetHeight() >= y, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The invalid position is given."); + + Point point(x, y); + + int textElementIndex = GetTextElementIndexFromPosition(point); + + TextElement* pTextElement = GetTextElementAt(textElementIndex); + if (pTextElement == null) + { + return E_OBJ_NOT_FOUND; + } + _TextElementImpl* pTextElementImpl = _TextElementImpl::GetInstance(*pTextElement); + if (pTextElementImpl != null) + { + linkInfo.SetLinkType(pTextElementImpl->GetLinkType()); + linkInfo.SetText(pTextElementImpl->GetText()); + linkInfo.SetLink(pTextElementImpl->GetLinkText()); + } + + return E_SUCCESS; +} + +TextVerticalAlignment +_EnrichedTextImpl::GetElementVerticalAlignment(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, TEXT_ALIGNMENT_VERTICAL_MIN, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + return __elementVerticalAlignment; +} + +result +_EnrichedTextImpl::SetElementVerticalAlignment(TextVerticalAlignment alignment) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + TextObjectAlignment elementAlign = ConvertVAlignment(alignment); + if (elementAlign == TEXT_OBJECT_ALIGNMENT_INVALID) + { + return E_INVALID_ARG; + } + + TextObjectAlignment align = + static_cast < TextObjectAlignment >((static_cast < TextObjectAlignment >(__pTextObject->GetAlignment()) + & TEXT_HORIZONTAL_ALIGNMENT) | (elementAlign & TEXT_VERTICAL_ALIGNMENT)); + + __pTextObject->SetElementVerticalAlignment(align); + __elementVerticalAlignment = alignment; + + return E_SUCCESS; +} + +Tizen::Graphics::Rectangle +_EnrichedTextImpl::GetBounds() const +{ + Rectangle rect(0, 0, __width, __height); + + return rect; +} + +result +_EnrichedTextImpl::IndexOfFromLinkedList(TextElement& textElement, int& index) +{ + return __pLinkedListTextElementList->IndexOf(textElement, index); +} + +int +_EnrichedTextImpl::GetTextElementIndexFromPosition(Tizen::Graphics::Point& point) const +{ + _TextElementImpl* pElement = null; + TextElementType type; + int length = 0; + int offset = 0; + int count = 0; + + offset = GetIndexFromTouchPosition(point.x, point.y); + + if (offset < 0 || offset > GetTextLength()) + { + return -1; + } + + count = GetTextElementCount(); + for (int i = 0; i < count; i++) + { + type = GetTypeFromIndex(i); + + if (type == TEXT_ELEMENT_TYPE_IMAGE) + { + length = length + 1; + } + else + { + pElement = _TextElementImpl::GetInstance(*GetTextElementAt(i)); + if (pElement) + { + if (pElement->IsAuto() == true) + { + length = length + pElement->GetLinkText().GetLength(); + } + else + { + String text = pElement->GetText(); + length = length + text.GetLength(); + } + } + } + if (offset <= length) + { + return i; + } + } + return -1; +} + +TextObject* +_EnrichedTextImpl::GetTextObject(void) const +{ + return __pTextObject.get(); +} + +TextElementType +_EnrichedTextImpl::GetTypeFromIndex(int textObjectIndex) const +{ + TextElementType type = TEXT_ELEMENT_TYPE_NONE; + + _Text::TextElement* pTextComponent = null; + + pTextComponent = __pTextObject->GetElementAtElementIndex(textObjectIndex); + + if (pTextComponent) + { + type = pTextComponent->GetType(); + } + else + { + return TEXT_ELEMENT_TYPE_NONE; + } + + return type; +} + +int +_EnrichedTextImpl::GetIndexFromTouchPosition(int posX, int posY) const +{ + return __pTextObject->GetTextIndexFromPosition(posX, posY, true); +} + +result +_EnrichedTextImpl::RemoveFromTextObject(_TextElementImpl* pTextElementImpl) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + _Text::TextElement* pTextComponent = pTextElementImpl->GetComponent(); + if (pTextComponent != null) + { + __pTextObject->RemoveElement(*pTextComponent, false); + } + + return E_SUCCESS; +} + +result +_EnrichedTextImpl::InsertAtFromTextObject(int index, _TextElementImpl* pTextElementImpl) +{ + SysTryReturn(NID_GRP, __pTextObject != null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + int textLength = 0; + int count = __pTextObject->GetElementCount(); + if (count > index) + { + return E_INVALID_ARG; + } + + _Text::TextElement* pInsertTextComponent = pTextElementImpl->GetComponent(); + if (pInsertTextComponent != null) + { + for (int i = 0; i < index; i++) + { + _Text::TextElement* pTextComponent = __pTextObject->GetElementAtElementIndex(i); + if (pTextComponent != null) + { + textLength = textLength + pTextComponent->GetTextLength(); + } + } + + __pTextObject->InsertElementAt(textLength, *pInsertTextComponent); + __pTextObject->Compose(); + } + + return E_SUCCESS; +} + +int +_EnrichedTextImpl::GetTextElementIndex(_TextElementImpl* pTextElementImpl) const +{ + _Text::TextElement* pTextComponent = pTextElementImpl->GetComponent(); + if (pTextComponent != null) + { + return __pTextObject->GetElementIndexOf(*pTextComponent); + } + + return -1; +} + +TextObjectAlignment +_EnrichedTextImpl::ConvertHAlignment(TextHorizontalAlignment halign) +{ + TextObjectAlignment align = TEXT_OBJECT_ALIGNMENT_LEFT; + + switch (halign) + { + case TEXT_ALIGNMENT_LEFT: + align = TEXT_OBJECT_ALIGNMENT_LEFT; + break; + + case TEXT_ALIGNMENT_CENTER: + align = TEXT_OBJECT_ALIGNMENT_CENTER; + break; + + case TEXT_ALIGNMENT_RIGHT: + align = TEXT_OBJECT_ALIGNMENT_RIGHT; + break; + + default: + align = TEXT_OBJECT_ALIGNMENT_INVALID; + break; + } + + return align; +} + +TextHorizontalAlignment +_EnrichedTextImpl::ConvertHAlignment(TextObjectAlignment halign) +{ + TextHorizontalAlignment align; + + switch (halign) + { + case TEXT_OBJECT_ALIGNMENT_RIGHT: + align = TEXT_ALIGNMENT_RIGHT; + break; + + case TEXT_OBJECT_ALIGNMENT_CENTER: + align = TEXT_ALIGNMENT_CENTER; + break; + + case TEXT_OBJECT_ALIGNMENT_LEFT: + // fall through + default: + align = TEXT_ALIGNMENT_LEFT; + break; + } + + return align; +} + +TextObjectAlignment +_EnrichedTextImpl::ConvertVAlignment(TextVerticalAlignment valign) +{ + TextObjectAlignment align; + + switch (valign) + { + case TEXT_ALIGNMENT_TOP: + align = TEXT_OBJECT_ALIGNMENT_TOP; + break; + + case TEXT_ALIGNMENT_MIDDLE: + align = TEXT_OBJECT_ALIGNMENT_MIDDLE; + break; + + case TEXT_ALIGNMENT_BOTTOM: + align = TEXT_OBJECT_ALIGNMENT_BOTTOM; + break; + + case TEXT_ALIGNMENT_BASELINE: + align = TEXT_OBJECT_ALIGNMENT_BASELINE; + break; + + default: + align = TEXT_OBJECT_ALIGNMENT_INVALID; + break; + } + + return align; +} + +TextVerticalAlignment +_EnrichedTextImpl::ConvertVAlignment(TextObjectAlignment valign) +{ + TextVerticalAlignment align = TEXT_ALIGNMENT_TOP; + + switch (valign) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + align = TEXT_ALIGNMENT_TOP; + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + align = TEXT_ALIGNMENT_MIDDLE; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + // fall through + default: + align = TEXT_ALIGNMENT_BOTTOM; + break; + } + + return align; +} + +_TextWrapType +_EnrichedTextImpl::ConvertWrapType(TextWrap warp) +{ + _TextWrapType twrap; + + switch (warp) + { + case TEXT_WRAP_CHARACTER_WRAP: + twrap = TEXT_WRAP_TYPE_WRAP; + break; + + case TEXT_WRAP_WORD_WRAP: + twrap = TEXT_WRAP_TYPE_WORDWRAP; + break; + + default: + twrap = TEXT_WRAP_TYPE_NONE; + break; + } + + return twrap; +} + +TextWrap +_EnrichedTextImpl::ConvertWrap(_TextWrapType warp) const +{ + TextWrap twrap; + + switch (warp) + { + case TEXT_WRAP_TYPE_WRAP: + twrap = TEXT_WRAP_CHARACTER_WRAP; + break; + + case TEXT_WRAP_TYPE_WORDWRAP: + twrap = TEXT_WRAP_WORD_WRAP; + break; + + default: + twrap = TEXT_WRAP_NONE; + break; + } + + return twrap; +} + +_EnrichedTextImpl* +_EnrichedTextImpl::GetCloneN(void) const +{ + SysTryReturn(NID_GRP, __pTextObject != null, null, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is not constructed yet."); + + result r = E_SUCCESS; + _EnrichedTextImpl* pNewEnrichedTextImpl = null; + + pNewEnrichedTextImpl = new (std::nothrow)_EnrichedTextImpl(*this); + r = GetLastResult(); + SysTryReturn(NID_GRP + , pNewEnrichedTextImpl + , null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pNewEnrichedTextImpl; +} + +_EnrichedTextImpl::_EnrichedTextImpl(const _EnrichedTextImpl& rhs) +{ + SysTryReturnVoidResult(NID_GRP, rhs.__pTextObject, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is not initialized."); + + result r = E_SUCCESS; + Dimension size = rhs.GetSize(); + + __width = size.width; + __height = size.height; + __lineSpace = GetLineSpace(); + __count = 0; + __verticalAlignment = rhs.GetVerticalAlignment(); + __horizontalAlignment = rhs.GetHorizontalAlignment(); + __elementVerticalAlignment = rhs.GetElementVerticalAlignment(); + __pLinkedListTextElementList = null; + __pTextElement = null; + __isCopiedEnrichedText = true; + __pTextObject = rhs.__pTextObject; + + __pLinkedListTextElementList = new (std::nothrow) Tizen::Base::Collection::LinkedList; + if (__pLinkedListTextElementList == null) + { + SetLastResult(E_OUT_OF_MEMORY); + SysLog(NID_GRP, "[E_OUT_OF_MEMORY] Fail to create element list."); + } + + __pTextElement = new (std::nothrow) TextElement(); + if (__pTextElement == null) + { + delete __pLinkedListTextElementList; + + SetLastResult(E_OUT_OF_MEMORY); + SysLog(NID_GRP, "[E_OUT_OF_MEMORY] Fail to create element."); + } + + r = __pTextElement->Construct(); + if (r != E_SUCCESS) + { + delete __pLinkedListTextElementList; + delete __pTextElement; + + SysLog(NID_GRP, "[%s] Fail to construct text element.", GetErrorMessage(r)); + } +} + +_EnrichedTextImpl* +_EnrichedTextImpl::GetInstance(EnrichedText& enrichedText) +{ + return (&enrichedText != null) ? enrichedText.__pImpl : null; +} + +const _EnrichedTextImpl* +_EnrichedTextImpl::GetInstance(const EnrichedText& enrichedText) +{ + return (&enrichedText != null) ? enrichedText.__pImpl : null; +} + +bool +_EnrichedTextImpl::IsConstructed(void) const +{ + return (this->__pTextObject != null); +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_Font.cpp b/src/graphics/FGrp_Font.cpp new file mode 100644 index 0000000..9767dd0 --- /dev/null +++ b/src/graphics/FGrp_Font.cpp @@ -0,0 +1,1945 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Font.cpp + * @brief This is the implementation file for _Font class. + * + */ + +#include "FGrp_Font.h" +#include "FGrp_FontFt2.h" + +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "FGrp_FontImpl.h" + +#include "FGrp_CanvasRasterOp.h" +#include "FGrp_FontRsrcManager.h" +#include "FGrp_FontBidiManager.h" + +#include "FGrp_Canvas.h" + +#include "util/FGrp_UtilTemplate.h" + +#define USE_EMOJI +#define SYNCHRONIZATION_2_0 +#define __pNativeFont __sharedFont.get() +#define CONVERT_INTEGER_TO_26_6_FIXED_POINT(value) (value * 64) +#define CONVERT_26_6_FIXED_POINT_TO_INTEGER(value) (value / 64) +#define IF_NOT_INITIALIZED(code) \ + if (__pNativeFont == null) \ + { \ + code; \ + } +#define GET_FONT_PROPERTY(prop, rtnValue) \ + { \ + bool rtn = __pNativeFont->GetFontProperty(prop); \ + SysTryReturn(NID_GRP, rtn, rtnValue, E_SYSTEM, "[E_SYSTEM] Failed to get font property"); \ + } +#define LOAD_GLYPH_DATA_CONST(character, pFontGlyphData, rtnValue) \ + { \ + _Font* pThis = const_cast <_Font*>(this); \ + bool rtn = pThis->LoadGlyph(character, &pFontGlyphData); \ + SysTryReturn(NID_GRP, rtn, rtnValue, E_SYSTEM, "[E_SYSTEM] Failed to load glyph data"); \ + } +#define UNLOAD_GLYPH_DATA_CONST(pFontGlyphData) \ + { \ + _Font* pThis = const_cast <_Font*>(this); \ + pThis->UnloadGlyph(&pFontGlyphData); \ + } +#define APPLY_ATTRIBUTE(rtnValue) \ + { \ + _Font* pFont = const_cast <_Font*>(this); \ + bool rtn = pFont->ApplyAttribute(); \ + SysTryReturn(NID_GRP, rtn, rtnValue, E_SYSTEM, "[E_SYSTEM] Failed to apply font attribute"); \ + } +#define SAMPLE_LANGUAGE_EMPTY "" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Io; +using namespace Tizen::System; + +namespace // unnamed +{ + +const int _SYSTEM_DEFAULT_FONT_SIZE = CONVERT_INTEGER_TO_26_6_FIXED_POINT(16); + +template +inline void +_ExpandBounds(Type curX, Type curY, Type& x1, Type& y1, Type& x2, Type& y2) +{ + if (curX > x2) + { + x2 = curX; + } + + if (curX < x1) + { + x1 = curX; + } + + if (curY > y2) + { + y2 = curY; + } + + if (curY < y1) + { + y1 = curY; + } +} + +result +_GetSystemFontList(Tizen::Base::Collection::IList& list) +{ + FcPattern* pPattern = null; + FcFontSet* pSet = null; + FcObjectSet* pObjectSet = null; + const char* pLang = null; + const char* fcStyle = "Regular"; + + // initialize fontconfig library + FcBool rtn = FcInit(); + SysTryCatch(NID_GRP, rtn, , E_SYSTEM, "[E_SYSTEM] Failed to init fontconfig"); + + pPattern = FcPatternCreate(); + SysTryCatch(NID_GRP, pPattern, , E_SYSTEM, "[E_SYSTEM] Failed to FcPatternCreate()"); + + // language and style + FcPatternAddString(pPattern, FC_STYLE, (FcChar8*)fcStyle); + + // RFC3066 formatted 2-level language identifier will be returned. + // e.g., en-NR, ar-SD, byn, tig etc. + // but, fontconfig only need 1-level language identifier having maximum 3 letters. + pLang = uloc_getDefault(); + + if (pLang != null) + { + char lang3Letters[4] = {0,}; + strncpy(lang3Letters, pLang, 3); + + for (int i = 0; i < 3; i++) + { + if (lang3Letters[i] == '-' || lang3Letters[i] == '_') + { + lang3Letters[i] = 0; + break; + } + } + + FcPatternAddString(pPattern, FC_LANG, (FcChar8*)lang3Letters); + } + + pObjectSet = FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_FILE, NULL); + SysTryCatch(NID_GRP, pObjectSet, , E_SYSTEM, "[E_SYSTEM] Failed to FcObjectSetBuild()"); + + pSet = FcFontList(NULL, pPattern, pObjectSet); + SysTryCatch(NID_GRP, pSet, , E_SYSTEM, "[E_SYSTEM] Failed to init fontconfig"); + + { + _FontRsrcManager& mgr = _FontRsrcManager::GetInstance(); + String defaultFontFaceName(mgr.GetDefaultSystemFont().GetFaceName()); + + bool defaultFontExists = false; + + list.RemoveAll(true); + FcChar8* pName = null; + + for (int i = 0; i < pSet->nfont; i++) + { + if (FcPatternGetString(pSet->fonts[i], FC_FILE, 0, &pName) == FcResultMatch) + { + String* pFamilyName = new (std::nothrow) String(Tizen::Graphics::_Font::GetFaceName(String((char*)pName))); + SysTryCatch(NID_GRP, pFamilyName, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocated memory"); + + list.Add(*pFamilyName); + + if (*pFamilyName == defaultFontFaceName) + { + defaultFontExists = true; + } + } + } + + if (defaultFontExists == false) + { + String* pDefaultFontName = new (std::nothrow) String(defaultFontFaceName); + SysTryCatch(NID_GRP, pDefaultFontName, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocated memory"); + + list.InsertAt(*pDefaultFontName, 0); + } + } + + // destroy + FcFontSetDestroy(pSet); + FcObjectSetDestroy(pObjectSet); + FcPatternDestroy(pPattern); + FcFini(); + + return E_SUCCESS; + +CATCH: + list.RemoveAll(true); + + // destroy, but before doing that check if those value has been created or not. + if (pSet) + { + FcFontSetDestroy(pSet); + } + + if (pObjectSet) + { + FcObjectSetDestroy(pObjectSet); + } + + if (pPattern) + { + FcPatternDestroy(pPattern); + } + + FcFini(); + + return GetLastResult(); +} + +typedef Tizen::Graphics::_Font::SystemPixel _SystemPixel; +typedef Tizen::Graphics::_Util::ScratchPad<_SystemPixel> _ScratchPad32; + + +unsigned long +_ComposeColor(unsigned long color32, int opacity) +{ + unsigned char alpha = (unsigned char) (((color32) >> 24)); + unsigned char red = (unsigned char) (((color32) >> 16)); + unsigned char green = (unsigned char) (((color32) >> 8)); + unsigned char blue = (unsigned char) ((color32)); + + alpha = (unsigned char) ((alpha * opacity + 255) >> 8); + red = (unsigned char) ((red * opacity + 255) >> 8); + green = (unsigned char) ((green * opacity + 255) >> 8); + blue = (unsigned char) ((blue * opacity + 255) >> 8); + + return (unsigned long) (((unsigned long) (alpha) << 24) | ((unsigned long) (red) << 16) | ((unsigned long) (green) << 8) | (unsigned long) (blue)); +} + +void +_SetColor(cairo_t* pCairo, unsigned long composedColor) +{ + double a = ((composedColor >> 24) & 0xFF) * 1.0 / 255.0; + double r = ((composedColor >> 16) & 0xFF) * 1.0 / 255.0; + double g = ((composedColor >> 8) & 0xFF) * 1.0 / 255.0; + double b = ((composedColor >> 0) & 0xFF) * 1.0 / 255.0; + + cairo_set_source_rgba(pCairo, r, g, b, a); +} + +template +inline T +_TempMin(T a, T b) +{ + return (a < b) ? a : b; +} +#define BLEND_ALPHA_COMPONEMT(srcA, dstA) (_TempMin ((srcA) + (dstA) - (((srcA) * (dstA)) >> 8), 0xFF)); + +struct _NativeGfxEngine +{ + cairo_t* pCairo; + cairo_surface_t* pCairoSurface; + + _NativeGfxEngine() + : pCairo(0) + , pCairoSurface(0) + { + } + ~_NativeGfxEngine() + { + if (pCairo) + { + cairo_destroy(pCairo); + } + + if (pCairoSurface) + { + cairo_surface_destroy(pCairoSurface); + } + + } +}; + +// ISO 15924 +const char* _SampleLanguages[] = +{ + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_COMMON + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_INHERITED + "ar", // G_UNICODE_SCRIPT_ARABIC + "hy", // G_UNICODE_SCRIPT_ARMENIAN + "bn", // G_UNICODE_SCRIPT_BENGALI + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_BOPOMOFO + "chr", // G_UNICODE_SCRIPT_CHEROKEE + "cop", // G_UNICODE_SCRIPT_COPTIC + "ru", // G_UNICODE_SCRIPT_CYRILLIC + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_DESERET + "hi", // G_UNICODE_SCRIPT_DEVANAGARI + "am", // G_UNICODE_SCRIPT_ETHIOPIC + "ka", // G_UNICODE_SCRIPT_GEORGIAN + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_GOTHIC + "el", // G_UNICODE_SCRIPT_GREEK + "gu", // G_UNICODE_SCRIPT_GUJARATI + "pa", // G_UNICODE_SCRIPT_GURMUKHI + "zh", // G_UNICODE_SCRIPT_HAN + "ko", // G_UNICODE_SCRIPT_HANGUL + "he", // G_UNICODE_SCRIPT_HEBREW + "ja", // G_UNICODE_SCRIPT_HIRAGANA + "kn", // G_UNICODE_SCRIPT_KANNADA + "ja", // G_UNICODE_SCRIPT_KATAKANA + "km", // G_UNICODE_SCRIPT_KHMER + "lo", // G_UNICODE_SCRIPT_LAO + "en", // G_UNICODE_SCRIPT_LATIN + "ml", // G_UNICODE_SCRIPT_MALAYALAM + "mn", // G_UNICODE_SCRIPT_MONGOLIAN + "my", // G_UNICODE_SCRIPT_MYANMAR + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_OGHAM + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_OLD_ITALIC + "or", // G_UNICODE_SCRIPT_ORIYA + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_RUNIC + "si", // G_UNICODE_SCRIPT_SINHALA + "syr", // G_UNICODE_SCRIPT_SYRIAC + "ta", // G_UNICODE_SCRIPT_TAMIL + "te", // G_UNICODE_SCRIPT_TELUGU + "dv", // G_UNICODE_SCRIPT_THAANA + "th", // G_UNICODE_SCRIPT_THAI + "bo", // G_UNICODE_SCRIPT_TIBETAN + "iu", // G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_YI + "tl", // G_UNICODE_SCRIPT_TAGALOG + "hnn", // G_UNICODE_SCRIPT_HANUNOO + "bku", // G_UNICODE_SCRIPT_BUHID + "tbw", // G_UNICODE_SCRIPT_TAGBANWA + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_BRAILLE + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_CYPRIOT + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_LIMBU + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_OSMANYA + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_SHAVIAN + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_LINEAR_B + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_TAI_LE + "uga", // G_UNICODE_SCRIPT_UGARITIC + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_NEW_TAI_LUE + "bug", // G_UNICODE_SCRIPT_BUGINESE + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_GLAGOLITIC + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_TIFINAGH + "syl", // G_UNICODE_SCRIPT_SYLOTI_NAGRI + "peo", // G_UNICODE_SCRIPT_OLD_PERSIAN + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_KHAROSHTHI + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_UNKNOWN + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_BALINESE + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_CUNEIFORM + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_PHOENICIAN + SAMPLE_LANGUAGE_EMPTY, // G_UNICODE_SCRIPT_PHAGS_PA + "nqo" // G_UNICODE_SCRIPT_NKO +}; + +const int _sampleLanguageCount = sizeof(_SampleLanguages) / sizeof(_SampleLanguages[0]); + +unsigned long +GetPredefinedColor(const wchar_t unicode, unsigned long fgColor) +{ +#ifdef USE_EMOJI + // + // Emoji Unicode List 176 + 76 + // + static const unsigned long _EMOJI_BLACK = 0xFF000000; + static const unsigned long _EMOJI_BLUE = 0xFF0000FF; + static const unsigned long _EMOJI_GREEN = 0xFF00FF00; + static const unsigned long _EMOJI_RED = 0xFFFF0000; + static const unsigned long _EMOJI_ORANGE = 0xFFFF6600; + static const unsigned long _EMOJI_PURPLE = 0xFF9370DB; + static const unsigned long _EMOJI_DEEP_PURPLE = 0xFF800080; + static const unsigned long _EMOJI_DARK_BLUE = 0xFF00008B; + static const unsigned long _EMOJI_BROWN = 0xFFA52A2A; + static const unsigned long _NOT_EMOJI = 0; + + static const long _MAX_EMOJI_UNICODE = 0xE757; + static const long _MIN_EMOJI_UNICODE = 0xE63E; + + static const unsigned long _emojiTable[] = + { + _EMOJI_RED, _EMOJI_BLUE, _EMOJI_BLUE, _EMOJI_BLUE, _EMOJI_ORANGE, _EMOJI_RED, _EMOJI_BLUE, _EMOJI_BLUE, _EMOJI_RED, _EMOJI_ORANGE, + _EMOJI_GREEN, _EMOJI_BLUE, _EMOJI_RED, _EMOJI_ORANGE, _EMOJI_GREEN, _EMOJI_BLUE, _EMOJI_RED, _EMOJI_ORANGE, _EMOJI_GREEN, _EMOJI_BLUE, + _EMOJI_PURPLE, _EMOJI_BLACK, _EMOJI_BLUE, _EMOJI_GREEN, _EMOJI_BLACK, _EMOJI_BLUE, _EMOJI_ORANGE, _EMOJI_BLACK, _EMOJI_PURPLE, _EMOJI_GREEN, + _EMOJI_ORANGE, _EMOJI_BLUE, _EMOJI_BLACK, _EMOJI_GREEN, _EMOJI_RED, _EMOJI_BLUE, _EMOJI_BLUE, _EMOJI_RED, _EMOJI_BLUE, _EMOJI_RED, + _EMOJI_BLACK, _EMOJI_PURPLE, _EMOJI_RED, _EMOJI_GREEN, _EMOJI_BLUE, _EMOJI_PURPLE, _EMOJI_BLUE, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, + _EMOJI_GREEN, _EMOJI_PURPLE, _EMOJI_ORANGE, _EMOJI_ORANGE, _EMOJI_RED, _EMOJI_BLUE, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_ORANGE, + _EMOJI_BLUE, _EMOJI_PURPLE, _EMOJI_BLACK, _EMOJI_RED, _EMOJI_ORANGE, _EMOJI_BLACK, _EMOJI_RED, _EMOJI_BLACK, _EMOJI_RED, _EMOJI_ORANGE, + _EMOJI_RED, _EMOJI_RED, _EMOJI_RED, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_ORANGE, _EMOJI_BLUE, _EMOJI_BLACK, _EMOJI_BLUE, _EMOJI_RED, + _EMOJI_BLACK, _EMOJI_RED, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_ORANGE, _EMOJI_ORANGE, _EMOJI_ORANGE, _EMOJI_ORANGE, _EMOJI_BLACK, _EMOJI_BLACK, + _EMOJI_ORANGE, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLUE, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_ORANGE, + _EMOJI_ORANGE, _EMOJI_BLUE, _EMOJI_GREEN, _EMOJI_BLACK, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, + _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _NOT_EMOJI, _NOT_EMOJI, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _NOT_EMOJI, _NOT_EMOJI, + _NOT_EMOJI, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, + _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, + _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _NOT_EMOJI, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_ORANGE, _EMOJI_ORANGE, _EMOJI_BLACK, + _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_RED, _EMOJI_RED, _EMOJI_RED, _EMOJI_RED, _EMOJI_RED, _EMOJI_RED, _EMOJI_BLUE, _EMOJI_RED, + _EMOJI_RED, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, + _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_RED, _EMOJI_RED, _EMOJI_RED, _EMOJI_RED, _EMOJI_PURPLE, _EMOJI_RED, + _EMOJI_BLUE, _EMOJI_GREEN, _EMOJI_BLUE, _EMOJI_RED, _EMOJI_RED, _EMOJI_RED, _EMOJI_PURPLE, _EMOJI_RED, _EMOJI_ORANGE, _EMOJI_ORANGE, + _EMOJI_BLACK, _EMOJI_RED, _EMOJI_BLACK, _EMOJI_RED, _EMOJI_BLUE, _EMOJI_BLUE, _EMOJI_RED, _EMOJI_PURPLE, _EMOJI_RED, _EMOJI_RED, + _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_RED, _EMOJI_ORANGE, _EMOJI_ORANGE, _EMOJI_BLUE, _EMOJI_BLACK, + _EMOJI_RED, _EMOJI_DARK_BLUE, _EMOJI_BLUE, _EMOJI_ORANGE, _EMOJI_BROWN, _EMOJI_BROWN, _EMOJI_BLACK, _EMOJI_RED, _EMOJI_BLACK, _EMOJI_GREEN, + _EMOJI_ORANGE, _EMOJI_PURPLE, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_GREEN, _EMOJI_BLACK, _EMOJI_GREEN, _EMOJI_PURPLE, _EMOJI_BLUE, _EMOJI_BLUE, + _EMOJI_RED, _EMOJI_DEEP_PURPLE, _EMOJI_PURPLE, _EMOJI_ORANGE, _EMOJI_RED, _EMOJI_PURPLE, _EMOJI_PURPLE, _EMOJI_DARK_BLUE, _EMOJI_ORANGE, _EMOJI_BLUE, + _EMOJI_BLUE, _EMOJI_RED, _EMOJI_BLUE, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_RED, _EMOJI_GREEN, _EMOJI_BLACK, _EMOJI_ORANGE, + _EMOJI_RED, _EMOJI_BLUE, _EMOJI_RED, _EMOJI_RED, _EMOJI_BLACK, _EMOJI_BLACK, _EMOJI_GREEN, _EMOJI_BLUE, _EMOJI_BLUE, _EMOJI_GREEN, + _EMOJI_RED, _EMOJI_RED, _EMOJI_ORANGE, _EMOJI_RED, _EMOJI_GREEN, _EMOJI_RED, _EMOJI_PURPLE, _EMOJI_BLACK, _EMOJI_RED, _EMOJI_BROWN, + _EMOJI_ORANGE, _EMOJI_BROWN, _EMOJI_BROWN, _EMOJI_ORANGE, _EMOJI_DARK_BLUE, _EMOJI_BLUE, _EMOJI_ORANGE, _EMOJI_ORANGE, _EMOJI_BROWN, _EMOJI_ORANGE, + _EMOJI_DEEP_PURPLE, _EMOJI_DEEP_PURPLE + }; + + if (unicode >= _MIN_EMOJI_UNICODE && unicode <= _MAX_EMOJI_UNICODE) + { + if (_emojiTable[unicode - _MIN_EMOJI_UNICODE] != _NOT_EMOJI) + { + fgColor = _emojiTable[unicode - _MIN_EMOJI_UNICODE]; + } + } +#endif + + return fgColor; +} + +} + + +namespace Tizen { namespace Graphics +{ + +_Font::_Font() +{ + __fontAttrib.Init(); + //__fallbackFontMap.Construct(1, 0, _fontHashCodeProvider, _fontComparer); +} + +_Font::_Font(const _Font& obj) +{ + this->__fontAttrib = obj.__fontAttrib; + this->__sharedFont = obj.__sharedFont; + + return; +} + +_Font::~_Font(void) +{ +} + +result +_Font::Construct(int style, int pcSize) +{ + _FontRsrcManager& mgr = _FontRsrcManager::GetInstance(); + + // use default system font + _FontRsrcManager::SharedFontResource out; + result r = mgr.GetFont(style, pcSize, out); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to get system default font", GetErrorMessage(r)); + + // assign it + __sharedFont = out; + __UpdateFontAttribute(style, pcSize); + + return E_SUCCESS; +} + +result +_Font::Construct(const Tizen::Base::String& fontName, int style, int pcSize, bool isPathEnabled) +{ + result r = E_SUCCESS; + + if (fontName.Compare(fontName, "TizenSans") == 0) + { + r = Construct(style,pcSize); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to get system font", GetErrorMessage(r)); + + return E_SUCCESS; + } + + bool systemFont = false; + String appFontPath = L""; + + _FontRsrcManager& mgr = _FontRsrcManager::GetInstance(); + _FontRsrcManager::SharedFontResource out; + + if (!Tizen::App::_AppInfo::IsOspCompat()) + { + appFontPath = mgr.FindAppFontName(fontName); + } + + // check if user want to use a app font + if (!appFontPath.IsEmpty()) + { + r = mgr.GetFont(appFontPath, style, pcSize, out); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to get app font", GetErrorMessage(r)); + } + else + { + IList* pList = GetSystemFontListN(); + int idx = 0; + + if (pList) + { + for (idx = 0; idx < pList->GetCount(); idx++) + { + String* pName = static_cast (pList->GetAt(idx)); + + if (pName == null) + { + continue; + } + + if (*pName == fontName) + { + systemFont = true; + break; + } + } + + pList->RemoveAll(true); + delete pList; + } + + if (systemFont) + { + r = mgr.GetSystemFont(fontName, style, pcSize, out); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to get system font", GetErrorMessage(r)); + } + else if (isPathEnabled) + { + r = mgr.GetFont(fontName, style, pcSize, out); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to get font", GetErrorMessage(r)); + } + } + + // assign it + __sharedFont = out; + __UpdateFontAttribute(style, pcSize); + + return E_SUCCESS; +} + +result +_Font::Construct(const Tizen::Base::ByteBuffer& fontData, int style, int pcSize) +{ + _FontRsrcManager& mgr = _FontRsrcManager::GetInstance(); + + const byte* pBuffer = fontData.GetPointer(); + int buffSize = fontData.GetLimit(); + + _FontRsrcManager::SharedFontResource out; + result r = mgr.GetFont(pBuffer, buffSize, style, pcSize, out); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to get system font", GetErrorMessage(r)); + + // assign it + __sharedFont = out; + __UpdateFontAttribute(style, pcSize); + + return E_SUCCESS; +} + +bool +_Font::IsConstructed(void) const +{ + return (__sharedFont.get() != null); +} + +int +_Font::GetMaxHeight(void) const +{ + IF_NOT_INITIALIZED(return -1); + + return __fontAttrib.maxHeight; +} + +int +_Font::GetMaxWidth(void) const +{ + IF_NOT_INITIALIZED(return -1); + + return __fontAttrib.maxWidth; +} + +int +_Font::GetAscender(void) const +{ + IF_NOT_INITIALIZED(return -1); + + return __fontAttrib.ascender; +} + +int +_Font::GetDescender(void) const +{ + IF_NOT_INITIALIZED(return -1); + + return __fontAttrib.descender; +} + +result +_Font::GetLeftBear(wchar_t character, int& leftBear) const +{ + IF_NOT_INITIALIZED(return E_OPERATION_FAILED); + + APPLY_ATTRIBUTE(-1); + + _IFont::Glyph* pFontGlyphData = null; + LOAD_GLYPH_DATA_CONST(character, pFontGlyphData, E_SYSTEM); + + // left bear is Glyph::xOffset, set it + leftBear = pFontGlyphData->xOffset; + + UNLOAD_GLYPH_DATA_CONST(pFontGlyphData); + + return E_SUCCESS; +} + +result +_Font::GetRightBear(wchar_t character, int& rightBear) const +{ + IF_NOT_INITIALIZED(return E_OPERATION_FAILED); + + APPLY_ATTRIBUTE(-1); + + _IFont::Glyph* pFontGlyphData = null; + LOAD_GLYPH_DATA_CONST(character, pFontGlyphData, E_SYSTEM); + + // right bear is Glyph::xOffset + GlyphBitmap::width, set it + rightBear = pFontGlyphData->xOffset + pFontGlyphData->image.width; + + UNLOAD_GLYPH_DATA_CONST(pFontGlyphData); + + return E_SUCCESS; +} + +result +_Font::GetTextExtent(const Tizen::Base::String& text, int length, Dimension& pcDim) const +{ + int x1 = 0x7FFFFFFF; + int y1 = 0x7FFFFFFF; + int x2 = -0x7FFFFFFF; + int y2 = -0x7FFFFFFF; + + int curX = 0; + int curY = 0; + + int italicSpace = 0; + int boldSpace = 0; + + long xVec = 0; + long yVec = 0; + int left = 0; + wchar_t leftChar = 0; + + _IFont::Glyph* pFontGlyphData = 0; + + IF_NOT_INITIALIZED(return E_OPERATION_FAILED); + + _Font* pThis = const_cast <_Font*>(this); + + const wchar_t* pText = text.GetPointer(); + SysTryCatch(NID_GRP, pText, pcDim.SetSize(0, 0), E_SYSTEM, "[E_SYSTEM] Failed to get string pointer"); + + APPLY_ATTRIBUTE(E_SYSTEM); + + { + _IFont::Property prop; + GET_FONT_PROPERTY(prop, E_SYSTEM); + + if (__fontAttrib.style & FONT_STYLE_ITALIC) + { + italicSpace = (prop.ascender * 2) >> 4; + } + } + + if (__fontAttrib.style & FONT_STYLE_BOLD) + { + _IFont::Attrib attr; + pThis->GetAttrib(attr); + boldSpace = (attr.boldWeight + 32) >> 6; + } + + while (*pText && --length >= 0) + { + _IFont* pFont = pThis->__GetFont(*pText); + + if (pFont != __pNativeFont) + { + _IFont::Attrib fontAttrib; + bool rtn = pFont->GetAttrib(fontAttrib); + + fontAttrib.size = __fontAttrib.size; + fontAttrib.style = _IFont::STYLE_NONE; + fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; + fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; + fontAttrib.style |= (__fontAttrib.underline) ? _IFont::STYLE_UNDERLINE : 0; + rtn = pFont->SetAttrib(fontAttrib); + } + + if (left > 0) + { + if (pFont->GetKerning(leftChar, *pText, xVec, yVec)) + { + curX += xVec; + } + } + + if (pFont->LoadGlyph(*pText++, &pFontGlyphData)) + { + int glyphBoundX1 = curX; + int glyphBoundY1 = curY - (pFontGlyphData->yOffset >> 10); + int glyphBoundX2 = glyphBoundX1 + (pFontGlyphData->xOffset >> 10) + pFontGlyphData->image.width; + int glyphBoundY2 = glyphBoundY1 + pFontGlyphData->image.height; + +#ifdef SYNCHRONIZATION_2_0 + // adjusting x bounds for synchronizing this operation with 2.0 + if (length == 0) + { + glyphBoundX2 = glyphBoundX1 + (pFontGlyphData->xAdvance >> 10) + italicSpace + boldSpace; + } +#endif // 2_0_SYNCHROMIZATION + + _ExpandBounds(glyphBoundX1, glyphBoundY1, x1, y1, x2, y2); + _ExpandBounds(glyphBoundX2, glyphBoundY1, x1, y1, x2, y2); + _ExpandBounds(glyphBoundX1, glyphBoundY2, x1, y1, x2, y2); + _ExpandBounds(glyphBoundX2, glyphBoundY2, x1, y1, x2, y2); + +#ifdef SYNCHRONIZATION_2_0 + curX += (pFontGlyphData->xAdvance >> 10) + __fontAttrib.charSpace + italicSpace + boldSpace; +#else + curX += (pFontGlyphData->xAdvance >> 10) + __fontAttrib.charSpace + boldSpace; +#endif + curY += (pFontGlyphData->yAdvance >> 10); + left++; + leftChar = *(pText - 1); + + pFont->UnloadGlyph(&pFontGlyphData); + } + } + + SysTryCatch(NID_GRP, x1 <= x2 && y1 <= y2, pcDim.SetSize(0, 0), E_SYSTEM, "[E_SYSTEM] Failed to calculate text extent"); + + pcDim.width = x2 - x1; +#ifdef SYNCHRONIZATION_2_0 + pcDim.height = CONVERT_26_6_FIXED_POINT_TO_INTEGER(__fontAttrib.size); +#else + pcDim.height = y2 - y1; +#endif // 2_0_SYNCHROMIZATION + + return E_SUCCESS; + +CATCH: + return E_SYSTEM; +} + +bool +_Font::IsBold(void) const +{ + IF_NOT_INITIALIZED(return false); + + return ((__fontAttrib.style & FONT_STYLE_BOLD) ? true : false); +} + +bool +_Font::IsItalic(void) const +{ + IF_NOT_INITIALIZED(return false); + + return ((__fontAttrib.style & FONT_STYLE_ITALIC) ? true : false); +} + +bool +_Font::IsPlain(void) const +{ + IF_NOT_INITIALIZED(return false); + + return ((__fontAttrib.style & FONT_STYLE_PLAIN) ? true : false); +} + +bool +_Font::IsStrikeOut(void) const +{ + IF_NOT_INITIALIZED(return false); + + return __fontAttrib.strikeout; +} + +bool +_Font::IsUnderlined(void) const +{ + IF_NOT_INITIALIZED(return false); + + return __fontAttrib.underline; +} + +bool +_Font::IsEmoji(void) const +{ + IF_NOT_INITIALIZED(return false); + + return (this->GetFaceName() == L"keitaiemoji"); +} + +int +_Font::GetSize(void) const +{ + IF_NOT_INITIALIZED(return -1); + + return CONVERT_26_6_FIXED_POINT_TO_INTEGER(__fontAttrib.size); +} + +void +_Font::SetStrikeOut(bool strikeout) +{ + IF_NOT_INITIALIZED(return); + + __fontAttrib.strikeout = strikeout; +} + +void +_Font::SetUnderline(bool underline) +{ + IF_NOT_INITIALIZED(return); + + __fontAttrib.underline = underline; +} + +void +_Font::SetCharSpace(int pc_space) +{ + IF_NOT_INITIALIZED(return); + + __fontAttrib.charSpace = pc_space; +} + +int +_Font::GetCharSpace(void) const +{ + IF_NOT_INITIALIZED(return -1); + + return __fontAttrib.charSpace; +} + +int +_Font::GetLineThickness(void) const +{ + IF_NOT_INITIALIZED(return -1); + + return __fontAttrib.lineThickness; +} + +Tizen::Base::String +_Font::GetFaceName(void) const +{ + IF_NOT_INITIALIZED(return String()); + + _IFont::Property prop; + GET_FONT_PROPERTY(prop, String()); + + return ((prop.pFamilyName) ? String(prop.pFamilyName) : String()); +} + +Tizen::Base::Collection::IList* +_Font::GetSystemFontListN(void) +{ + std::auto_ptr pList(new (std::nothrow) Tizen::Base::Collection::ArrayList); + SysTryReturn(NID_GRP, pList.get(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Fails to allocate memory"); + + result r = _GetSystemFontList(*pList); + SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pList.release(); + +} + +Tizen::Base::String +_Font::GetFaceName(const Tizen::Base::String& filePath) +{ + _FontRsrcManager& mgr = _FontRsrcManager::GetInstance(); + _FontRsrcManager::SharedFontResource out; + String faceName; + + result r = mgr.GetTempFont(filePath, FONT_STYLE_PLAIN, _SYSTEM_DEFAULT_FONT_SIZE, out); + SysTryReturn(NID_GRP, r == E_SUCCESS, faceName, r, "[%s] Failed to get font", GetErrorMessage(r)); + + if (r == E_SUCCESS) + { + _IFont* pTempFont = out.get(); + + _IFont::Property prop; + pTempFont->GetFontProperty(prop); + faceName = String(prop.pFamilyName); + } + + return faceName; +} + +_IFont* +_Font::GetNativeFont(void) const +{ + IF_NOT_INITIALIZED(return null); + + return __pNativeFont; +} + +_Font* +_Font::CloneN() +{ + // if it's not initialized, return null. + IF_NOT_INITIALIZED(return null); + + // make the clone + _Font* pNativeFont = new (std::nothrow) _Font(*this); + SysTryReturn(NID_GRP, pNativeFont, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocated memory"); + + // done + return pNativeFont; +} + +bool +_Font::ApplyAttribute() +{ + IF_NOT_INITIALIZED(return false); + + _IFont::Attrib fontAttrib; + bool rtn = __pNativeFont->GetAttrib(fontAttrib); + SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to get font attribute"); + + fontAttrib.size = __fontAttrib.size; + fontAttrib.style = _IFont::STYLE_NONE; + fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; + fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; + fontAttrib.style |= (__fontAttrib.underline) ? _IFont::STYLE_UNDERLINE : 0; + rtn = __pNativeFont->SetAttrib(fontAttrib); + SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to set font attribute"); + + return true; +} + + +result +_Font::GetTextExtent(int width, const Tizen::Base::String& text, int startIndex, int length, bool outline, int& count, Dimension& pcDim) const +{ + int preX1 = 0x7FFFFFFF; + int preY1 = 0x7FFFFFFF; + int preX2 = -0x7FFFFFFF; + int preY2 = -0x7FFFFFFF; + + int x1 = 0x7FFFFFFF; + int y1 = 0x7FFFFFFF; + int x2 = -0x7FFFFFFF; + int y2 = -0x7FFFFFFF; + + int curX = 0; + int curY = 0; + + int characters = 0; + int italicSpace = 0; + int boldSpace = 0; + + long xVec = 0; + long yVec = 0; + int left = 0; + wchar_t leftChar = 0; + + _IFont::Glyph* pFontGlyphData = 0; + + IF_NOT_INITIALIZED(return E_SYSTEM); + + if (length == 0) + { + count = 0; + pcDim.SetSize(0, 0); + return E_SUCCESS; + } + + _Font* pThis = const_cast <_Font*>(this); + + const wchar_t* pText = text.GetPointer() + startIndex; + SysTryCatch(NID_GRP, pText, pcDim.SetSize(0, 0), E_SYSTEM, "[E_SYSTEM] Failed to get string pointer"); + + APPLY_ATTRIBUTE(E_SYSTEM); + + { + _IFont::Property prop; + GET_FONT_PROPERTY(prop, E_SYSTEM); + + if (__fontAttrib.style & FONT_STYLE_ITALIC) + { + italicSpace = (prop.ascender * 2) >> 4; + } + } + + if (__fontAttrib.style & FONT_STYLE_BOLD) + { + _IFont::Attrib attr; + pThis->GetAttrib(attr); + boldSpace = (attr.boldWeight + 32) >> 6; + } + + while (*pText && --length >= 0) + { + // getting proper _Font instance for the specified text + _IFont* pFont = pThis->__GetFont(*pText); + + if (pFont != __pNativeFont) + { + _IFont::Attrib fontAttrib; + bool rtn = pFont->GetAttrib(fontAttrib); + //SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to get font attribute"); + + fontAttrib.size = __fontAttrib.size; + fontAttrib.style = _IFont::STYLE_NONE; + fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; + fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; + fontAttrib.style |= (__fontAttrib.underline) ? _IFont::STYLE_UNDERLINE : 0; + rtn = pFont->SetAttrib(fontAttrib); + //SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to set font attribute"); + } + + if (left > 0) + { + if (pFont->GetKerning(leftChar, *pText, xVec, yVec)) + { + curX += xVec; + } + } + + if (pFont->LoadGlyph(*pText++, &pFontGlyphData)) + { + int glyphBoundX1 = curX; + int glyphBoundY1 = curY - (pFontGlyphData->yOffset >> 10); + int glyphBoundX2 = glyphBoundX1 + + ((pFontGlyphData->image.width <= 0) ? (pFontGlyphData->xAdvance >> + 10) : ((pFontGlyphData->xOffset >> + 10) + pFontGlyphData->image.width)); + int glyphBoundY2 = glyphBoundY1 + pFontGlyphData->image.height; + +#ifdef SYNCHRONIZATION_2_0 + // adjusting x2 bounds for synchronizing fuctionality with 2.0 + glyphBoundX2 = glyphBoundX1 + (pFontGlyphData->xAdvance >> 10) + italicSpace + boldSpace; +#endif + + + if (outline) + { + glyphBoundX1 -= 1; + glyphBoundY1 -= 1; + glyphBoundX2 += 1; + glyphBoundY2 += 1; + } + + _ExpandBounds(glyphBoundX1, glyphBoundY1, x1, y1, x2, y2); + _ExpandBounds(glyphBoundX2, glyphBoundY1, x1, y1, x2, y2); + _ExpandBounds(glyphBoundX1, glyphBoundY2, x1, y1, x2, y2); + _ExpandBounds(glyphBoundX2, glyphBoundY2, x1, y1, x2, y2); + +#ifdef SYNCHRONIZATION_2_0 + curX += (pFontGlyphData->xAdvance >> 10) + __fontAttrib.charSpace + italicSpace + boldSpace; +#else + curX += (pFontGlyphData->xAdvance >> 10) + __fontAttrib.charSpace + boldSpace; +#endif + curY += (pFontGlyphData->yAdvance >> 10); + + pFont->UnloadGlyph(&pFontGlyphData); + + // check end condition + // TODO, shkim, BIDI need to be cared + if ((x2 - x1) > width) + { + break; + } + + preX1 = x1; + preY1 = y1; + preX2 = x2; + preY2 = y2; + characters++; + left++; + leftChar = *(pText - 1); + } + } + + if (characters == 0) + { + pcDim.SetSize(0, 0); + count = 0; + return E_SUCCESS; + } + + SysTryCatch(NID_GRP, preX1 <= preX2 && preY1 <= preY2, pcDim.SetSize(0, 0); count = 0, E_SYSTEM, "[E_SYSTEM] Failed to calculate text extent"); + + count = characters; + pcDim.width = preX2 - preX1; +#ifdef SYNCHRONIZATION_2_0 + pcDim.height = CONVERT_26_6_FIXED_POINT_TO_INTEGER(__fontAttrib.size); +#else + pcDim.height = preY2 - preY1; +#endif // SYNCHRONIZATION_2_0 + + return E_SUCCESS; + +CATCH: + return E_SYSTEM; +} + +result +_Font::GetTextExtent(int width, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, Dimension& dim) const +{ + IF_NOT_INITIALIZED(return E_OPERATION_FAILED); + + SysTryReturn(NID_GRP, startIndex >= 0 && length >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + const wchar_t* pBaseStringBegin = text.GetPointer(); + const wchar_t* pBaseStringEnd = pBaseStringBegin + text.GetLength(); + + const wchar_t* pTextBegin = pBaseStringBegin + startIndex; + const wchar_t* pTextEnd = pTextBegin + length; + + pTextEnd = (pTextEnd < pBaseStringEnd) ? pTextEnd : pBaseStringEnd; + + const wchar_t* pText = pTextBegin; + + while (pText < pTextEnd) + { + if (*pText == 0x0D || *pText == 0x0A) + { + pTextEnd = pText; + break; + } + + ++pText; + } + + return this->GetTextExtent(width, text, startIndex, pTextEnd - pTextBegin, outline, count, dim); +} + +result +_Font::SetSize(int pcSize) +{ + IF_NOT_INITIALIZED(return E_OPERATION_FAILED); + + __UpdateFontAttribute(__fontAttrib.style, pcSize); + + return E_SUCCESS; +} + +result +_Font::SetStyle(int style) +{ + IF_NOT_INITIALIZED(return E_OPERATION_FAILED); + + __fontAttrib.style = style; + + return E_SUCCESS; +} + +int +_Font::GetStyle(void) const +{ + IF_NOT_INITIALIZED(return FONT_STYLE_PLAIN); + + return __fontAttrib.style; +} + +int +_Font::GetLeading(void) const +{ + IF_NOT_INITIALIZED(return -1); + + return __fontAttrib.maxHeight; +} + +result +_Font::__DrawText(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length) +{ + SysTryReturnResult(NID_GRP, canvas.__pScratchPad != null, E_INVALID_ARG, "A canvas is invalid"); + + const wchar_t* pText = text.GetPointer() + startIndex; + + bool rtn = this->ApplyAttribute(); + SysTryReturn(NID_GRP, rtn, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fails to apply font attribute."); + + _Util::ScratchPad & scratchPad = *canvas.__pScratchPad; + scratchPad.RegisterFillRect(_RasterOp::FnFillRectFont32Bit); + + Rectangle clipBounds; + canvas.__GetClipBounds(clipBounds); + + int xDest = point.x; + int yDest = point.y; + int startX = point.x; + int charHeight = 0; + int italicSpace = 0; + int boldSpace = 0; + int clipX1 = clipBounds.x; + int clipY1 = clipBounds.y; + int clipX2 = clipX1 + clipBounds.width; + int clipY2 = clipY1 + clipBounds.height; + long xVec = 0; + long yVec = 0; + int left = 0; + wchar_t leftChar = 0; + _IFont::Glyph* pFontGlyphData = 0; + + // need to revise y value, because _IFont is based on the baseline + { + _IFont::Property prop; + bool rtn = this->GetFontProperty(prop); + SysTryReturn(NID_GRP, rtn, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get font property."); + + if (canvas.__textOrigin == TEXT_ORIGIN_LEFT_TOP) + { + yDest += prop.maxHeight + prop.descender; + } + + charHeight = prop.ascender - prop.descender; + + if (this->GetStyle() & FONT_STYLE_ITALIC) + { + italicSpace = (prop.ascender * 2) >> 4; + } + } + + if (this->GetStyle() & FONT_STYLE_BOLD) + { + _IFont::Attrib attr; + this->GetAttrib(attr); + boldSpace = (attr.boldWeight + 32) >> 6; + } + + unsigned long canvasFgColor = canvas.__fgColor; + + GUnicodeScript script = g_unichar_get_script(*pText); + // need to check if (script < 0 || script >= _sampleLanguageCount) ? + + // Temporary code for testing Arabic + if (script == G_UNICODE_SCRIPT_ARABIC) + { + _FontBidiProps bidiProps(pText, length); + + _IFont* pFont = this->__GetFont(*pText); + + if (pFont == null) + { + return E_SYSTEM; + } + + Tizen::Base::Collection::ArrayListT<_IFont::Glyph *> glyphList; + + pFont->GetGlyphList(_Util::String(text.GetPointer(), text.GetLength(), startIndex, length), glyphList, bidiProps.isRtl, script); + + int count = glyphList.GetCount(); + + for (int i = 0; i < count; i++) + { + typedef unsigned long TPixel; + _IFont::Glyph *pGlyph = 0; + + TPixel srcR, srcG, srcB, srcA; + TPixel dstR, dstG, dstB, dstA; + + srcA = (canvasFgColor >> 24) & 0xFF; + srcA += (srcA >> 7); + srcR = (canvasFgColor >> 16) & 0xFF; + srcG = (canvasFgColor >> 8) & 0xFF; + srcB = (canvasFgColor) & 0xFF; + + SystemPixel* pBufferStartAddr = null; + int bufferPitch; + + scratchPad.GetBuffer(pBufferStartAddr, bufferPitch); + + glyphList.GetAt(i, pGlyph); + + for (int h = 0; h < pGlyph->image.height; h++) + { + int y = yDest - pGlyph->yOffset + h; + + if (y < 0) + { + continue; + } + + if (y >= scratchPad.GetHeight()) + { + break; + } + + TPixel* pDest32 = pBufferStartAddr + y * bufferPitch + xDest + pGlyph->xOffset; + + for (int w = 0; w < pGlyph->image.width; w++) + { + int x = xDest + pGlyph->xOffset + w; + + if (x < 0) + { + ++pDest32; + continue; + } + + if (x >= scratchPad.GetWidth()) + { + break; + } + + unsigned long alpha = (unsigned long) (pGlyph->image.pBitmap[h * pGlyph->image.bytesPerLine + w]); + + if (alpha > 0) + { + // equivalent to scratchPad.FillRect(x, y, 1, 1, fgColor, alpha); + alpha = (alpha * srcA) >> 8; + alpha += (alpha >> 7); + + dstA = (*pDest32 >> 24) & 0xFF; + dstR = (*pDest32 >> 16) & 0xFF; + dstG = (*pDest32 >> 8) & 0xFF; + dstB = (*pDest32) & 0xFF; + + dstA = BLEND_ALPHA_COMPONEMT(alpha, dstA); + dstR = (dstR + (((srcR - dstR) * alpha) >> 8)) & 0xFF; + dstG = (dstG + (((srcG - dstG) * alpha) >> 8)) & 0xFF; + dstB = (dstB + (((srcB - dstB) * alpha) >> 8)) & 0xFF; + + *pDest32 = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + + } + ++pDest32; + } + } + + xDest += (pGlyph->xAdvance >> 10); + yDest += (pGlyph->yAdvance >> 10); + } + + scratchPad.RegisterFillRect(null); + + IEnumeratorT<_IFont::Glyph*>* pEnum = glyphList.GetEnumeratorN(); + + if (pEnum) + { + while (pEnum->MoveNext() == E_SUCCESS) + { + _IFont::Glyph* pGlyph; + + pEnum->GetCurrent(pGlyph); + delete pGlyph; + } + + delete pEnum; + } + } + else + { + while (*pText && --length >= 0) + { + // find out proper native font + _IFont* pFont = this->__GetFont(*pText); + + if (pFont == null) + { + continue; + } + + if (pFont != __pNativeFont) + { + _IFont::Attrib fontAttrib; + bool rtn = pFont->GetAttrib(fontAttrib); + //SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to get font attribute"); + + fontAttrib.size = __fontAttrib.size; + fontAttrib.style = _IFont::STYLE_NONE; + fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; + fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; + fontAttrib.style |= (__fontAttrib.underline) ? _IFont::STYLE_UNDERLINE : 0; + rtn = pFont->SetAttrib(fontAttrib); + //SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to set font attribute"); + } + + _IFont::Property prop; + pFont->GetFontProperty(prop); + + unsigned long fgColor = (canvas.__applyEmoji && (String(prop.pFamilyName) == L"keitaiemoji")) ? GetPredefinedColor(*pText, canvasFgColor) : canvasFgColor; + + if (left > 0) + { + if (pFont->GetKerning(leftChar, *pText, xVec, yVec)) + { + xDest += xVec; + } + } + + bool rtn = pFont->LoadGlyph(*pText++, &pFontGlyphData); + + if (!rtn) + { + continue; + } + + typedef unsigned long TPixel; + + TPixel srcA = (fgColor >> 24) & 0xFF; + srcA += (srcA >> 7); + + TPixel srcR = (fgColor >> 16) & 0xFF; + TPixel srcG = (fgColor >> 8) & 0xFF; + TPixel srcB = (fgColor) & 0xFF; + + SystemPixel* pBufferStartAddr = null; + int bufferPitch = 0; + + scratchPad.GetBuffer(pBufferStartAddr, bufferPitch); + + for (int h = 0; h < pFontGlyphData->image.height; h++) + { + int y = yDest - (pFontGlyphData->yOffset >> 10) + h; + + if (y < clipY1) + { + continue; + } + + if (y >= clipY2) + { + break; + } + + TPixel* pDest32 = pBufferStartAddr + y * bufferPitch + xDest + (pFontGlyphData->xOffset >> 10); + + for (int w = 0; w < pFontGlyphData->image.width; w++) + { + int x = xDest + (pFontGlyphData->xOffset >> 10) + w; + + if (x < clipX1) + { + ++pDest32; + continue; + } + + if (x >= clipX2) + { + break; + } + + unsigned long alpha = (unsigned long) (pFontGlyphData->image.pBitmap[h * pFontGlyphData->image.bytesPerLine + w]); + + if (alpha > 0) + { + // equivalent to scratchPad.FillRect(x, y, 1, 1, fgColor, alpha); + alpha = (alpha * srcA) >> 8; + alpha += (alpha >> 7); + + TPixel dstA = (*pDest32 >> 24) & 0xFF; + TPixel dstR = (*pDest32 >> 16) & 0xFF; + TPixel dstG = (*pDest32 >> 8) & 0xFF; + TPixel dstB = (*pDest32) & 0xFF; + + dstA = BLEND_ALPHA_COMPONEMT(alpha, dstA); + dstR = (dstR + (((srcR - dstR) * alpha) >> 8)) & 0xFF; + dstG = (dstG + (((srcG - dstG) * alpha) >> 8)) & 0xFF; + dstB = (dstB + (((srcB - dstB) * alpha) >> 8)) & 0xFF; + + *pDest32 = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + + } + ++pDest32; + } + } + + xDest += (pFontGlyphData->xAdvance >> 10) + __fontAttrib.charSpace + italicSpace + boldSpace; + yDest += (pFontGlyphData->yAdvance >> 10); + left++; + leftChar = *(pText - 1); + + pFont->UnloadGlyph(&pFontGlyphData); + + } + + if (this->IsUnderlined() || this->IsStrikeOut()) + { + int y = point.y + charHeight - 1; + int thick = this->GetLineThickness(); + + xDest -= this->GetCharSpace(); + + if (this->IsUnderlined()) + { + canvas.FillRectangle(canvasFgColor, Rectangle(startX, y - thick, xDest - startX, thick)); + } + + if (this->IsStrikeOut()) + { + y -= charHeight / 2; + canvas.FillRectangle(canvasFgColor, Rectangle(startX, y - thick, xDest - startX, thick)); + } + } + + scratchPad.RegisterFillRect(null); + } + + return E_SUCCESS; +} + +#undef BLEND_ALPHA_COMPONEMT + +result +_Font::__DrawText(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor) +{ + unsigned long textColor = canvas.__fgColor; + bool applyEmoji = canvas.__applyEmoji; + + //sunmi557.shin: draw border of font + canvas.__fgColor = outlineColor.GetRGB32(); + canvas.__applyEmoji = false; + + this->__DrawText(canvas, Point(point.x - 1, point.y), text, startIndex, length); + this->__DrawText(canvas, Point(point.x + 1, point.y), text, startIndex, length); + this->__DrawText(canvas, Point(point.x, point.y - 1), text, startIndex, length); + this->__DrawText(canvas, Point(point.x, point.y + 1), text, startIndex, length); + + //sunmi557.shin: draw original shape of font + canvas.__applyEmoji = applyEmoji; + canvas.__fgColor = textColor; + + this->__DrawText(canvas, point, text, startIndex, length); + + return E_SUCCESS; +} + +bool +_Font::SetAttrib(const _IFont::Attrib& fontAttrib) +{ + IF_NOT_INITIALIZED(return false); + + return __pNativeFont->SetAttrib(fontAttrib); +} + +bool +_Font::GetAttrib(_IFont::Attrib& fontAttrib) const +{ + IF_NOT_INITIALIZED(return false); + + return __pNativeFont->GetAttrib(fontAttrib); +} + +bool +_Font::GetKerning(unsigned long character1, unsigned long character2, long& xVector, long& yVector) const +{ + IF_NOT_INITIALIZED(return false); + + return __pNativeFont->GetKerning(character1, character2, xVector, yVector); +} + +bool +_Font::GetFontProperty(_IFont::Property& property) const +{ + IF_NOT_INITIALIZED(return false); + + return __pNativeFont->GetFontProperty(property); +} + +bool +_Font::LoadGlyph(unsigned long character, _IFont::Glyph** ppFontGlyphData) +{ + IF_NOT_INITIALIZED(return false); + + // note! we assume that the font attribute has been already applied on _IFont + bool rtn = false; + + // if not, loading glyph (character/size/style) and caching it + rtn = __pNativeFont->LoadGlyph(character, ppFontGlyphData); + SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to load glyph data"); + + // return cached glyph + return true; +} + +bool +_Font::UnloadGlyph(_IFont::Glyph** ppFontGlyphData) +{ + IF_NOT_INITIALIZED(return false); + + return __pNativeFont->UnloadGlyph(ppFontGlyphData); +} + +unsigned long +_Font::CheckGlyph(unsigned long character) +{ + IF_NOT_INITIALIZED(return false); + + return __pNativeFont->CheckGlyph(character); +} + +void +_Font::__UpdateFontAttribute(int style, int pcSize) +{ + IF_NOT_INITIALIZED(return); + + __fontAttrib.style = style; + __fontAttrib.size = pcSize; + __fontAttrib.lineThickness = ((CONVERT_26_6_FIXED_POINT_TO_INTEGER(pcSize) < 24) ? 1 : ((CONVERT_26_6_FIXED_POINT_TO_INTEGER(pcSize) < 48) ? 2 : 3)); + + _IFont::Property prop; + bool getProperty = false; + + if (this->ApplyAttribute()) + { + getProperty = __pNativeFont->GetFontProperty(prop); + } + + if (getProperty) + { + __fontAttrib.maxWidth = prop.maxWidth; + __fontAttrib.maxHeight = prop.maxHeight; + __fontAttrib.ascender = prop.ascender; + __fontAttrib.descender = prop.descender; + } + else + { + // if failed to get property above, each property should be remained as default: -1 + SysLog(NID_GRP, "[] Failed to get font attribute from native font"); + + __fontAttrib.maxWidth = -1; + __fontAttrib.maxHeight = -1; + __fontAttrib.ascender = -1; + __fontAttrib.descender = -1; + } +} + +result +_Font::__DrawTextLastFallback(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length) +{ + return E_SUCCESS; +} + +result +_Font::__DrawTextDefault(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length) +{ + _FontRsrcManager& mgr = _FontRsrcManager::GetInstance(); + result r = mgr.GetDefaultSystemFont().__DrawText(canvas, point, text, startIndex, length); + SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Failed to draw default system font", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + _Font::__DrawTextLastFallback(canvas, point, text, startIndex, length); + return r; +} + +result +_Font::__DrawTextDefault(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor) +{ + _FontRsrcManager& mgr = _FontRsrcManager::GetInstance(); + result r = mgr.GetDefaultSystemFont().__DrawText(canvas, point, text, startIndex, length, outlineColor); + SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Failed to draw default system font", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + _Font::__DrawTextLastFallback(canvas, point, text, startIndex, length); + return r; +} + + +result +_Font::DrawText(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length) +{ + if (canvas.__pPriorityFont) + { + return canvas.__pPriorityFont->__DrawText(canvas, point, text, startIndex, length); + } + else if (canvas.__pFont) + { + return canvas.__pFont->__DrawText(canvas, point, text, startIndex, length); + } + else + { + return _Font::__DrawTextDefault(canvas, point, text, startIndex, length); + } +} + +result +_Font::DrawText(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor) +{ + if (canvas.__pPriorityFont) + { + return canvas.__pPriorityFont->__DrawText(canvas, point, text, startIndex, length, outlineColor); + } + else if (canvas.__pFont) + { + return canvas.__pFont->__DrawText(canvas, point, text, startIndex, length, outlineColor); + } + else + { + return _Font::__DrawTextDefault(canvas, point, text, startIndex, length, outlineColor); + } + + return E_SUCCESS; +} + +_Font* +_Font::GetInstance(_FontImpl& font) +{ + return (&font != null) ? font._pNativeFont : null; +} + +const _Font* +_Font::GetInstance(const _FontImpl& font) +{ + return (&font != null) ? font._pNativeFont : null; +} + +_IFont* +_Font::__GetFont(wchar_t character) +{ + IF_NOT_INITIALIZED(return null); + + //------------------------------------------------------ + // + // 1. check if this font has a requested glyph + // + //------------------------------------------------------ + unsigned long idx = __pNativeFont->CheckGlyph(character); + + if (idx > 0) + { + return __pNativeFont; + } + + //------------------------------------------------------ + // + // 1-2. check if this glyph is in the fallback list. + // + //------------------------------------------------------ + _FontRsrcManager& mgr = _FontRsrcManager::GetInstance(); + Tizen::Base::Collection::HashMapT* fallbackFontMap = __pNativeFont->GetFallbackMap(); + std::auto_ptr > enumerator(fallbackFontMap->GetMapEnumeratorN()); + + while (enumerator->MoveNext() == E_SUCCESS) + { + _FontRsrcManager::SharedFontResource pTempFont; + + if (enumerator->GetValue(pTempFont) == E_SUCCESS) + { + String key; + result r = enumerator->GetKey(key); + + if (r == E_SUCCESS) + { + if (mgr.SearchFont(key)) + { + if (pTempFont.get()->CheckGlyph(character) > 0) + { + return pTempFont.get(); + } + } + else + { + fallbackFontMap->Remove(key); + } + } + } + } + + //------------------------------------------------------ + // + // 2. Get fallback font list via fontconfig + // + //------------------------------------------------------ + Tizen::Base::Collection::ArrayListT fileList; + bool rtn = __GetFallbackFontFileList(character, fileList); + if (!rtn) + { + // if failed find out fallback font, + // just use this instance for drawing something for unknown glyph + return __pNativeFont; + } + + //------------------------------------------------------ + // + // 3. try to find a font having a requested glyph + // + //------------------------------------------------------ + String fontName; + _IFont* pFallbackFont = null; + + _FontRsrcManager::SharedFontResource out; + + int count = fileList.GetCount(); + result r = E_FAILURE; + + for (int i = 0; i < count; i++) + { + fileList.GetAt(i, fontName); + + if (fontName.IsEmpty()) + { + continue; + } + + r = mgr.GetTempFont(fontName, __fontAttrib.style, __fontAttrib.size, out); + + if (r == E_SUCCESS) + { + unsigned long idx = out.get()->CheckGlyph(character); + + if (idx > 0) + { + // keep it + r = fallbackFontMap->Add(fontName, out); + SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = mgr.AddFont(fontName, out); + SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pFallbackFont = out.get(); + break; + } + } + } + + return (pFallbackFont != null) ? pFallbackFont : __pNativeFont; + +CATCH: + // if failed find out fallback font, + // just use this instance for drawing something for unknown glyph + return __pNativeFont; +} + +bool +_Font::__GetFallbackFontFileList(wchar_t character, Tizen::Base::Collection::IListT& out) +{ + GUnicodeScript script = g_unichar_get_script(character); + if (script < 0 || script >= _sampleLanguageCount) + { + return false; + } + + _IFont::Property prop; + const char* pFamilyName = null; + GET_FONT_PROPERTY(prop, false); + + pFamilyName = prop.pFamilyName; + + FcPattern* pPattern = null; + FcFontSet* pSet = null; + FcChar8* pName = null; + FcResult res = FcResultNoMatch; + const char* fcStyle = (__fontAttrib.style & FONT_STYLE_BOLD) ? "Bold" : "Regular"; + + // initialize fontconfig library + FcBool rtn = FcInit(); + SysTryCatch(NID_GRP, rtn, , E_SYSTEM, "[E_SYSTEM] Failed to init fontconfig"); + + // getting fallback font list + pPattern = FcPatternBuild(NULL, FC_STYLE, FcTypeString, (FcChar8*)fcStyle, NULL); + SysTryCatch(NID_GRP, pPattern, , E_SYSTEM, "[E_SYSTEM] Failed to FcPatternBuild()"); + + FcPatternAddString(pPattern, FC_FAMILY, (FcChar8*) pFamilyName); + + if (strncmp(SAMPLE_LANGUAGE_EMPTY, _SampleLanguages[script], strlen(SAMPLE_LANGUAGE_EMPTY) + 1) != 0) + { + FcPatternAddString(pPattern, FC_LANG, (FcChar8*)_SampleLanguages[script]); + } + + FcConfigSubstitute(NULL, pPattern, FcMatchPattern); + FcDefaultSubstitute(pPattern); + + // do matching + pSet = FcFontSort(NULL, pPattern, FcTrue, NULL, &res); + SysTryCatch(NID_GRP, pSet, , E_SYSTEM, "[E_SYSTEM] Failed to FcFontSort()"); + + out.RemoveAll(); + + for (int i = 0; i < pSet->nfont; i++) + { + if (FcPatternGetString(pSet->fonts[i], FC_FILE, 0, &pName) == FcResultMatch) + { + out.Add(String((char*)pName)); + } + } + + // destroy + FcFontSetDestroy(pSet); + FcPatternDestroy(pPattern); + FcFini(); + + return (out.GetCount() > 0) ? true : false; + +CATCH: + if (pSet != null) + { + FcFontSetDestroy(pSet); + } + + if (pPattern != null) + { + FcPatternDestroy(pPattern); + } + + FcFini(); + + return false; +} + +bool +_Font::UpdateDefaultFont(const String& key) +{ + if (!key.IsEmpty()) + { + SysLog(NID_GRP, "Request to change the default font"); + + _FontRsrcManager& mgr = _FontRsrcManager::GetInstance(); + + return mgr.ReloadDefaultSystemFont(); + } + + return false; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_Font.h b/src/graphics/FGrp_Font.h new file mode 100644 index 0000000..d873551 --- /dev/null +++ b/src/graphics/FGrp_Font.h @@ -0,0 +1,183 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Font.h + * @brief This is the header file for the _Font class. + * + * This header file contains the declarations of the %_Font class. + * + */ + +#ifndef _FGRP_INTERNAL_FONT_H_ +#define _FGRP_INTERNAL_FONT_H_ + +#include +#include + +#include +#include + +#include "FGrp_IFont.h" + +#include "util/FGrp_UtilTemplate.h" +#include "util/FGrp_UtilType.h" + +namespace Tizen { namespace Base +{ +class String; +class ByteBuffer; +}} // Tizen::Base + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +}}} // Tizen::Base::Collection + +namespace Tizen { namespace Graphics +{ +class Dimension; +class Color; +class Point; +class Rectangle; + +class _Canvas; +class _FontImpl; + +struct _FontAttribute +{ + int style; + int size; + int maxWidth; + int maxHeight; + int charSpace; + bool strikeout; + bool underline; + int lineThickness; + int ascender; + int descender; + + void Init() + { + style = FONT_STYLE_MIN; + size = -1; + maxWidth = -1; + maxHeight = -1; + charSpace = 0; + strikeout = false; + underline = false; + lineThickness = -1; + ascender = -1; + descender = -1; + } +}; + +class _Font + : public Tizen::Base::Object +{ +public: + typedef unsigned long SystemPixel; + +public: + _Font(void); + _Font(const _Font& obj); + virtual ~_Font(void); + + result Construct(int style, int size); + result Construct(const Tizen::Base::String& fontName, int style, int pcSize, bool isPathEnabled = true); + result Construct(const Tizen::Base::ByteBuffer& fontData, int style, int pcSize); + + bool IsConstructed(void) const; + + int GetMaxHeight(void) const; + int GetMaxWidth(void) const; + int GetAscender(void) const; + int GetDescender(void) const; + + result GetLeftBear(wchar_t character, int& leftBear) const; + result GetRightBear(wchar_t character, int& rightBear) const; + result GetTextExtent(const Tizen::Base::String& text, int length, Dimension& dim) const; + + bool IsBold(void) const; + bool IsItalic(void) const; + bool IsPlain(void) const; + bool IsStrikeOut(void) const; + bool IsUnderlined(void) const; + bool IsEmoji(void) const; + int GetSize(void) const; + void SetStrikeOut(bool strikeOut); + void SetUnderline(bool underline); + void SetCharSpace(int space); + int GetCharSpace(void) const; + int GetLineThickness(void) const; + Tizen::Base::String GetFaceName(void) const; + static Tizen::Base::Collection::IList* GetSystemFontListN(void); + static Tizen::Base::String GetFaceName(const Tizen::Base::String& filePath); + + _IFont* GetNativeFont(void) const; + _Font* CloneN(void); + bool ApplyAttribute(void); + + result GetTextExtent(int width, const Tizen::Base::String& text, int startIndex, int length, bool outline, int& count, Dimension& dim) const; + result GetTextExtent(int width, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, Dimension& dim) const; + + result SetSize(int pcSize); + result SetStyle(int style); + + int GetStyle(void) const; + int GetLeading(void) const; + + // native font interface + bool SetAttrib(const _IFont::Attrib& fontAttrib); + bool GetAttrib(_IFont::Attrib& fontAttrib) const; + bool GetKerning(unsigned long character1, unsigned long character2, long& xVector, long& yVector) const; + bool GetFontProperty(_IFont::Property& property) const; + bool LoadGlyph(unsigned long character, _IFont::Glyph** ppFontGlyphData); + bool UnloadGlyph(_IFont::Glyph** ppFontGlyphData); + unsigned long CheckGlyph(unsigned long character); + + static result DrawText(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length); + static result DrawText(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor); + + static _Font* GetInstance(_FontImpl& font); + static const _Font* GetInstance(const _FontImpl& font); + + static bool UpdateDefaultFont(const Tizen::Base::String& key); + +private: + _Font& operator =(const _Font& rhs); + void __UpdateFontAttribute(int style, int size); + + result __DrawText(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length); + result __DrawText(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor); + + static result __DrawTextLastFallback(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length); + static result __DrawTextDefault(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length); + static result __DrawTextDefault(_Canvas& canvas, const Point& point, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor); + + _IFont* __GetFont(wchar_t character); + bool __GetFallbackFontFileList(wchar_t character, Tizen::Base::Collection::IListT& out); + +private: + std::tr1::shared_ptr <_IFont> __sharedFont; + _FontAttribute __fontAttrib; + +}; // _Font + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_FONT_H_ diff --git a/src/graphics/FGrp_FontBidiManager.cpp b/src/graphics/FGrp_FontBidiManager.cpp new file mode 100644 index 0000000..957153b --- /dev/null +++ b/src/graphics/FGrp_FontBidiManager.cpp @@ -0,0 +1,393 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontBidiManager.cpp + * @brief This is the cpp file for _FontMemoryManager class. + * + */ + +#include +#include + +#include +#include + +#include "FGrp_FontBidiManager.h" + +namespace +{ +typedef wchar_t Eina_Unicode; + +typedef FriBidiCharType EvasBiDiCharType; +typedef FriBidiLevel EvasBiDiLevel; +typedef FriBidiParType EvasBiDiParType; + +#define EVAS_BIDI_PARAGRAPH_NEUTRAL FRIBIDI_PAR_ON +#define EVAS_BIDI_PARAGRAPH_LTR FRIBIDI_PAR_LTR +#define EVAS_BIDI_PARAGRAPH_RTL FRIBIDI_PAR_RTL +#define EVAS_BIDI_PARAGRAPH_WLTR FRIBIDI_PAR_WLTR +#define EVAS_BIDI_PARAGRAPH_WRTL FRIBIDI_PAR_WRTL + +#define EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL(x) \ + (((x) && \ + ((x->direction == EVAS_BIDI_PARAGRAPH_RTL) || \ + (x->direction == EVAS_BIDI_PARAGRAPH_WRTL))) ? \ + EINA_TRUE : EINA_FALSE) + +typedef struct _Evas_BiDi_Paragraph_Props { + EvasBiDiCharType *char_types; /* BiDi char types */ + EvasBiDiLevel *embedding_levels; /* BiDi embedding levels */ + int refcount; /* The number of references to this object */ + EvasBiDiParType direction; +} Evas_BiDi_Paragraph_Props; + +//////////////////////////////////////////////////////////////////////////////// + +typedef int Eina_Bool; + +#define EINA_TRUE 1 +#define EINA_FALSE 0 + +#define BIDILOCK() +#define BIDIUNLOCK() + +#define _SAFE_FREE(x) \ + do { \ + if (x) \ + { \ + free(x); \ + x = NULL; \ + } \ + } while(0) + +Eina_Bool +evas_bidi_is_rtl_str(const Eina_Unicode *str) +{ + EvasBiDiCharType type; + + if (!str) + return EINA_FALSE; + + for ( ; *str ; str++) + { + type = fribidi_get_bidi_type((FriBidiChar) *str); + if (FRIBIDI_IS_LETTER(type) && FRIBIDI_IS_RTL(type)) + { + return EINA_TRUE; + } + } + return EINA_FALSE; +} + +int +eina_unicode_strlen(const Eina_Unicode *str) +{ + if (str) + { + const Eina_Unicode* pEnd = str; + + while (*pEnd++) + ; + + return (pEnd - str - 1); + } + else + { + return 0; + } +} + +void +evas_bidi_paragraph_props_clean(Evas_BiDi_Paragraph_Props *bidi_props) +{ + _SAFE_FREE(bidi_props->embedding_levels); + _SAFE_FREE(bidi_props->char_types); +} + +Evas_BiDi_Paragraph_Props * +evas_bidi_paragraph_props_new(void) +{ + Evas_BiDi_Paragraph_Props *ret; + ret = (Evas_BiDi_Paragraph_Props *)calloc(1, sizeof(Evas_BiDi_Paragraph_Props)); + ret->direction = EVAS_BIDI_PARAGRAPH_NEUTRAL; + ret->refcount = 1; + + return ret; +} + +void +evas_bidi_paragraph_props_unref(Evas_BiDi_Paragraph_Props *bidi_props) +{ + if (!bidi_props) return; + BIDILOCK(); + + if (--bidi_props->refcount == 0) + { + evas_bidi_paragraph_props_clean(bidi_props); + free(bidi_props); + } + BIDIUNLOCK(); +} + +//////////////// + +Evas_BiDi_Paragraph_Props * +evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len, int *segment_idxs) +{ + Evas_BiDi_Paragraph_Props *bidi_props = NULL; + EvasBiDiCharType *char_types = NULL; + EvasBiDiLevel *embedding_levels = NULL; + const FriBidiChar *ustr; + FriBidiChar *base_ustr = NULL; + + if (!eina_ustr) + return NULL; + + + if (!evas_bidi_is_rtl_str(eina_ustr)) /* No need to handle bidi */ + { + len = -1; + goto cleanup; + } + + len = eina_unicode_strlen(eina_ustr); + /* The size of fribidichar s different than eina_unicode, convert */ +#ifdef EVAS_FRIBIDI_EINA_UNICODE_UNEQUAL + base_ustr = calloc(len + 1, sizeof(FriBidiChar)); + base_ustr = _evas_bidi_unicode_to_fribidichar(base_ustr, eina_ustr); + ustr = base_ustr; +#else + ustr = (const FriBidiChar *) eina_ustr; +#endif + + bidi_props = evas_bidi_paragraph_props_new(); + + /* Prep work for reordering */ + char_types = (EvasBiDiCharType *) malloc(sizeof(EvasBiDiCharType) * len); + if (!char_types) + { + len = -2; + goto cleanup; + } + fribidi_get_bidi_types(ustr, len, char_types); + + embedding_levels = (EvasBiDiLevel *)malloc(sizeof(EvasBiDiLevel) * len); + if (!embedding_levels) + { + len = -2; + goto cleanup; + } + + if (segment_idxs) + { + size_t pos = 0; + int *itr; + EvasBiDiLevel base_level = 0; + EvasBiDiParType direction; + + for (itr = segment_idxs ; *itr > 0 ; itr++) + { + direction = EVAS_BIDI_PARAGRAPH_NEUTRAL; + if (!fribidi_get_par_embedding_levels(char_types + pos, + *itr - pos, + &direction, + embedding_levels + pos)) + { + len = -2; + goto cleanup; + } + + /* Only on the first run */ + if (itr == segment_idxs) + { + bidi_props->direction = direction; + /* adjust base_level to be 1 for rtl paragraphs, and 0 for + * ltr paragraphs. */ + base_level = + EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL(bidi_props) ? 1 : 0; + } + + /* We want those chars at the override points to be on the base + * level and we also remove -2 cause we later increment them, + * just for simpler code paths */ + embedding_levels[*itr] = base_level - 2; + pos = *itr + 1; + } + + direction = EVAS_BIDI_PARAGRAPH_NEUTRAL; + if (!fribidi_get_par_embedding_levels(char_types + pos, + len - pos, + &direction, + embedding_levels + pos)) + { + len = -2; + goto cleanup; + } + + /* Increment all levels by 2 to emulate embedding. */ + { + EvasBiDiLevel *bitr = embedding_levels, *end; + end = bitr + len; + for ( ; bitr < end ; bitr++) + { + *bitr += 2; + } + } + } + else + { + if (!fribidi_get_par_embedding_levels(char_types, len, + &bidi_props->direction, embedding_levels)) + { + len = -2; + goto cleanup; + } + } + + + /* clean up */ + if (bidi_props->embedding_levels) + { + free(bidi_props->embedding_levels); + } + bidi_props->embedding_levels = embedding_levels; + + /* clean up */ + + if (bidi_props->char_types) + { + free(bidi_props->char_types); + } + bidi_props->char_types = char_types; + + if (base_ustr) free(base_ustr); + + + return bidi_props; + +/* Cleanup */ +cleanup: + if (char_types) free(char_types); + if (embedding_levels) free(embedding_levels); + if (base_ustr) free(base_ustr); + if (bidi_props) evas_bidi_paragraph_props_unref(bidi_props); /* Clean up the bidi props */ + return NULL; +} + +} // namespace + +namespace +{ + +//?? arbitrary +typedef int EvasBiDiStrIndex; + +Eina_Bool +evas_bidi_props_reorder_line(Eina_Unicode *eina_ustr, size_t start, size_t len, const Evas_BiDi_Paragraph_Props *props, EvasBiDiStrIndex **_v_to_l) +{ + EvasBiDiStrIndex *v_to_l = NULL; + FriBidiChar *ustr = NULL, *base_ustr = NULL; + + if (!props) + return EINA_FALSE; + + if (eina_ustr) + { + /* The size of fribidichar is different than eina_unicode, convert */ +#ifdef EVAS_FRIBIDI_EINA_UNICODE_UNEQUAL + base_ustr = ustr = calloc(len + 1, sizeof(FriBidiChar)); + ustr = _evas_bidi_unicode_to_fribidichar(ustr, eina_ustr); +#else + ustr = (FriBidiChar *) eina_ustr; +#endif + } + + + if (_v_to_l) { + size_t i; + v_to_l = *_v_to_l = (EvasBiDiStrIndex *) calloc(len, sizeof(EvasBiDiStrIndex)); + if (!v_to_l) + { + goto error; + } + /* init the array for fribidi */ + for (i = 0 ; i < len ; i++) + { + v_to_l[i] = i; + } + } + + { + EvasBiDiLevel *emb_lvl; + emb_lvl = (EvasBiDiLevel *) malloc((start + len) * sizeof(EvasBiDiLevel)); + memcpy(emb_lvl, props->embedding_levels, + (start + len) * sizeof(EvasBiDiLevel)); + /* We pass v_to_l - start, because fribidi assumes start is the offset + * from the start of v_to_l as well, not just the props. */ + if (!fribidi_reorder_line (FRIBIDI_FLAGS_DEFAULT, props->char_types, + len, start, props->direction, emb_lvl, ustr, v_to_l - start)) + { + free(emb_lvl); + goto error; + } + free(emb_lvl); + } + + + /* The size of fribidichar is different than eina_unicode, convert */ +#ifdef EVAS_FRIBIDI_EINA_UNICODE_UNEQUAL + _evas_bidi_fribidichar_to_unicode(eina_ustr, base_ustr); + free(base_ustr); +#endif + return EINA_FALSE; +/* ERROR HANDLING */ +error: + if (base_ustr) free(base_ustr); + _SAFE_FREE(v_to_l); + return EINA_TRUE; +} + +} + +//////////////////////////////////////////////////////////////////////////////// + +namespace Tizen { namespace Graphics +{ + +_FontBidiProps::_FontBidiProps(const wchar_t* pText, int length) + : pEventText(0) + , pCharType(0) + , pEmbeddingLevels(0) + , baseDirection(FRIBIDI_PAR_ON) + , isRtl(false) +{ + Evas_BiDi_Paragraph_Props* pEvasBidiProps = evas_bidi_paragraph_props_get(pText, length, 0); + + if (pEvasBidiProps) + { + this->pEventText = (FriBidiChar *)pText; + this->pCharType = pEvasBidiProps->char_types; + this->pEmbeddingLevels = pEvasBidiProps->embedding_levels; + this->baseDirection = pEvasBidiProps->direction; + this->isRtl = true; + + evas_bidi_paragraph_props_unref(pEvasBidiProps); + } +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_FontBidiManager.h b/src/graphics/FGrp_FontBidiManager.h new file mode 100644 index 0000000..2cf4efc --- /dev/null +++ b/src/graphics/FGrp_FontBidiManager.h @@ -0,0 +1,45 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontBidiManager.h + * @brief This is the header file for _FontBidiManager class. + * + */ +#ifndef _FGRP_INTERNAL_FONT_BIDI_MANAGER_H_ +#define _FGRP_INTERNAL_FONT_BIDI_MANAGER_H_ + +#include + +namespace Tizen { namespace Graphics +{ + +struct _FontBidiProps +{ + FriBidiChar* pEventText; + FriBidiCharType* pCharType; + FriBidiLevel* pEmbeddingLevels; + //FriBidiStrIndex* cmap; + FriBidiParType baseDirection; + bool isRtl; + + _FontBidiProps(const wchar_t* pText, int length); +}; + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_FONT_BIDI_MANAGER_H_ diff --git a/src/graphics/FGrp_FontCache.cpp b/src/graphics/FGrp_FontCache.cpp new file mode 100644 index 0000000..bd05b6a --- /dev/null +++ b/src/graphics/FGrp_FontCache.cpp @@ -0,0 +1,423 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontCache.cpp + * @brief This is the cpp file for _FontCache class. + * + */ + +#include +#include + +#include + +#include + +#include "FGrp_FontCache.h" +#include "FGrp_FontRsrcManager.h" + + +#define CONVERT_INTEGER_TO_26_6_FIXED_POINT(value) (value * 64) +#define __pBspCache ((_BspTree*)__pCache) + + +namespace // unnamed +{ + +const unsigned long _CACHE_MEMORY_SIZE = 3 * 1024 * 1024; +const unsigned long _MAX_CACHABLE_ITEM_SIZE = _CACHE_MEMORY_SIZE / 10; + +inline bool +_MakeId(unsigned long character, int size, int style, unsigned long& out) +{ + int fixedSize = size >> 5; + + if (((character >> 22) > 0) || ((fixedSize >> 8) > 0) || ((style >> 2) > 0)) + { + return false; + } + + out = (character << 10) | ((fixedSize & 0xFF) << 2) | (style & 0x3); + + return true; +} + +template +inline unsigned long _MakeIndex(Type id, int level); + +template <> +inline unsigned long +_MakeIndex(unsigned long id, int level) +{ + typedef unsigned long TBase; + + TBase index = (id & (0x80808080 >> level)) >> ((sizeof(TBase) * 2 - 1) - level); + + index |= (index >> 7); + index |= (index >> 14); + index |= (index >> 21); + + return (index & 0x0000000F); +} + +template +class _BspTree +{ + enum + { + MAX_CHILD = 16, + MAX_LEVEL = sizeof(TId) * 2 + }; + +public: + _BspTree(int level = 0) + : __level(level) + , __data(null) + { + for (int i = 0; i < MAX_CHILD; i++) + { + __child[i] = null; + } + } + + ~_BspTree(void) + { + __Destroy(); + } + + bool Add(TId id, TData data) + { + if (__IsEdge()) + { + // shkim, TODO. + // collision should not be occured. + __data = data; + return true; + } + + unsigned long index = __GetIndex(id); + + if (__child[index] == null) + { + __child[index] = new (std::nothrow) _BspTree(__level + 1); + if (__child[index] == null) + { + return false; + } + } + + return __child[index]->Add(id, data); + } + + TData Find(TId id) const + { + if (__data != null) + { + return __data; + } + + unsigned long index = __GetIndex(id); + + if (__child[index]) + { + return __child[index]->Find(id); + } + + return 0; + } + + TData Remove(TId id) + { + TData found = 0; + __Remove(id, found); + return found; + } + +private: + void __Destroy(void) + { + for (int i = 0; i < MAX_CHILD; i++) + { + delete __child[i]; + __child[i] = null; + } + + Tizen::Graphics::_FontRsrcManager::GetInstance().GetMemoryManager().Free(__data); + + __data = null; + } + + bool __IsEdge(void) const + { + return (__level >= MAX_LEVEL); + } + + inline unsigned long __GetIndex(TId id) const + { + return _MakeIndex(id, __level); + } + + bool __Remove(TId id, TData& found) + { + if (__data != null) + { + found = __data; + return true; + } + + unsigned long index = __GetIndex(id); + + if (__child[index]) + { + if (__child[index]->__Remove(id, found)) + { + delete __child[index]; + __child[index] = null; + + unsigned long check = 0; + + for (int i = 0; i < MAX_CHILD; i++) + { + check |= (unsigned long)__child[i]; + } + + return (check == 0); + } + } + + return false; + } + + int __level; + TData __data; + _BspTree* __child[MAX_CHILD]; +}; + +} + +namespace Tizen { namespace Graphics +{ + +class _FontCacheImpl +{ +public: + _FontCacheImpl(void) + { + } + + virtual ~_FontCacheImpl(void) + { + } + + void Add(unsigned long id) + { + __leastRecentlyUsedKeyList.push_back(id); + } + + void Remove(unsigned long id) + { + __leastRecentlyUsedKeyList.remove(id); + } + + void RemoveFirst(void) + { + __leastRecentlyUsedKeyList.pop_front(); + } + + void RemoveAll(void) + { + __leastRecentlyUsedKeyList.clear(); + } + + unsigned long GetFirst(void) + { + return __leastRecentlyUsedKeyList.front(); + } + + bool IsEmpty(void) + { + return __leastRecentlyUsedKeyList.empty(); + } + +private: + //_BspTree bspTree; + std::list __leastRecentlyUsedKeyList; +}; + +_FontCache::_FontCache(void) + : __pCache((void*) new (std::nothrow) _BspTree()) +{ + __pFontCacheImpl = new (std::nothrow) _FontCacheImpl; +} + +_FontCache::~_FontCache(void) +{ + delete reinterpret_cast<_BspTree*>(__pCache); + __pCache = null; + + delete __pFontCacheImpl; + __pFontCacheImpl = null; +} + +bool +_FontCache::IsValid(void) const +{ + return (this->__pCache && this->__pFontCacheImpl); +} + +bool +_FontCache::Find(unsigned long character, int size, int style, _IFont::Glyph** pOut) +{ + unsigned long id = 0; + bool rtn = _MakeId(character, size, style, id); + + if (!rtn) + { + return false; + } + + _IFont::Glyph* p = (_IFont::Glyph*)__pBspCache->Find(id); + + if (p != null) + { + *pOut = p; + return true; + } + else + { + return false; + } +} + +bool +_FontCache::Add(unsigned long character, int size, int style, _IFont::Glyph* pGlyph) +{ + unsigned long bufferSize = 0; + unsigned long id = 0; + bool rtn = _MakeId(character, size, style, id); + if (!rtn) + { + // Requested glyph is not cachable + return false; + } + + bufferSize = sizeof(_IFont::Glyph) + (pGlyph->image.bytesPerLine * pGlyph->image.height); + _IFont::Glyph* pGlyphCache = (_IFont::Glyph*) _FontRsrcManager::GetInstance().GetMemoryManager().Alloc(bufferSize); + if (pGlyphCache == null) + { + // secure memory + bool rtn = _FontRsrcManager::GetInstance().RemoveMemory(bufferSize); + + if (!rtn) + { + return false; + } + + pGlyphCache = (_IFont::Glyph*) _FontRsrcManager::GetInstance().GetMemoryManager().Alloc(bufferSize); + + if (pGlyphCache == null) + { + return false; + } + } + + memcpy(pGlyphCache, pGlyph, sizeof(_IFont::Glyph)); + pGlyphCache->image.pBitmap = (unsigned char*)((pGlyphCache) + 1); + memcpy(pGlyphCache->image.pBitmap, pGlyph->image.pBitmap, pGlyph->image.bytesPerLine * pGlyph->image.height); + + if (__pBspCache->Add(id, pGlyphCache)) + { + __pFontCacheImpl->Add(id); + return true; + } + else + { + return false; + } +} + +void +_FontCache::Remove(unsigned long character, int size, int style) +{ + unsigned long id = 0; + bool rtn = _MakeId(character, size, style, id); + if (!rtn) + { + return; + } + + __pBspCache->Remove(id); + __pFontCacheImpl->Remove(id); +} + +void +_FontCache::RemoveFirst(void) +{ + unsigned long id = 0; + + id = __pFontCacheImpl->GetFirst(); + + __pBspCache->Remove(id); + __pFontCacheImpl->RemoveFirst(); +} + +bool +_FontCache::IsEmpty(void) +{ + return __pFontCacheImpl->IsEmpty(); +} + +bool +_FontCache::Cleanup(void) +{ + _BspTree* p = reinterpret_cast<_BspTree*>(__pCache); + + p->~_BspTree(); + new (p) _BspTree(); + + __pFontCacheImpl->RemoveAll(); + + return true; +} + +bool +_FontCache::__DiscardVictim(unsigned long requestedSize) +{ + return true; +} + +bool +_FontCache::__RemoveId(unsigned long id) +{ + _IFont::Glyph* pCachedGlyph = null; + + pCachedGlyph = (_IFont::Glyph*)__pBspCache->Find(id); + + if (pCachedGlyph != null) + { + __pBspCache->Remove(id); + + return true; + } + else + { + return false; + } +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_FontCache.h b/src/graphics/FGrp_FontCache.h new file mode 100644 index 0000000..96e09f3 --- /dev/null +++ b/src/graphics/FGrp_FontCache.h @@ -0,0 +1,70 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontCache.h + * @brief This is the header file for _FontCache class. + * + */ + +#ifndef _FGRP_INTERNAL_FONT_CACHE_H_ +#define _FGRP_INTERNAL_FONT_CACHE_H_ + +#include + +#include + +#include "FGrp_IFont.h" + + +namespace Tizen { namespace Graphics +{ + +class _FontCache + : public Tizen::Base::Object +{ +public: + _FontCache(void); + virtual ~_FontCache(void); + + bool IsValid(void) const; + + bool Find(unsigned long character, int size, int style, _IFont::Glyph** pOut); + bool Add(unsigned long character, int size, int style, _IFont::Glyph* pGlyph); + void Remove(unsigned long character, int size, int style); + void RemoveFirst(void); + bool IsEmpty(void); + + bool Cleanup(void); + +private: + _FontCache(const _FontCache& obj); + _FontCache& operator =(const _FontCache& rhs); + _FontCache* operator &(void); + + bool __DiscardVictim(unsigned long requestedSize); + bool __RemoveId(unsigned long id); + + void* __pCache; + + friend class _FontCacheImpl; + class _FontCacheImpl* __pFontCacheImpl; +}; + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_FONT_CACHE_H_ diff --git a/src/graphics/FGrp_FontFt2.cpp b/src/graphics/FGrp_FontFt2.cpp new file mode 100644 index 0000000..7ab4f3c --- /dev/null +++ b/src/graphics/FGrp_FontFt2.cpp @@ -0,0 +1,1219 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontFt2.cpp + * @brief This is the implementation file for _FontFt2 class. + * + */ + +#include +#include + +#include + +#include +#include FT_FREETYPE_H +#include FT_OUTLINE_H + +#include + +#include +#include +#include + +#include "FGrp_FontFt2.h" +#include "FGrp_FontCache.h" +#include "util/FGrp_UtilTemplate.h" + +#include +#include +#include + +#define CHECK_NULL_PARAM(data) if (data == null) \ + { \ + return false; \ + } +#define CONVERT_INTEGER_TO_26_6_FIXED_POINT(value) (value * 64) +#define CONVERT_26_6_FIXED_POINT_TO_INTEGER(value) (value / 64) + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +namespace // unnamed +{ +const double _M_PI = 3.14159265358979323846; +const double _ITALIC_ANGLE = 10.619655; +const long _DEFAULT_FONT_SIZE = CONVERT_INTEGER_TO_26_6_FIXED_POINT(16); // 16 pixel size in 26.6 fixed point +const long _DEFAULT_RES = 72; +const long _FIXED_SHIFT = 10; // in fixed point number, the number of assigned bit below point. +const unsigned long _INDEX_FIRST = 32; // in first resource, the first chracter(space) +const unsigned long _INDEX_COUNT = 95; // first resource character count + +bool +_CompareFamilyForTitling(String& familyName) +{ + String _compNames[] = + { + L"TitlingGothicFB Comp", + L"TitlingGothicFB Cond", + L"TitlingGothicFB Narrow", + L"TitlingGothicFB Skyline" + }; + + for (unsigned int i = 0; i < sizeof(_compNames) / sizeof(_compNames[0]); i++) + { + if (familyName == _compNames[i]) + { + return true; + } + } + + return false; +} + +const hb_script_t _HarfbuzzScript[] = +{ + HB_SCRIPT_COMMON, + HB_SCRIPT_INHERITED, + HB_SCRIPT_ARABIC, + HB_SCRIPT_ARMENIAN, + HB_SCRIPT_BENGALI, + HB_SCRIPT_BOPOMOFO, + HB_SCRIPT_CHEROKEE, + HB_SCRIPT_COPTIC, + HB_SCRIPT_CYRILLIC, + HB_SCRIPT_DESERET, + HB_SCRIPT_DEVANAGARI, + HB_SCRIPT_ETHIOPIC, + HB_SCRIPT_GEORGIAN, + HB_SCRIPT_GOTHIC, + HB_SCRIPT_GREEK, + HB_SCRIPT_GUJARATI, + HB_SCRIPT_GURMUKHI, + HB_SCRIPT_HAN, + HB_SCRIPT_HANGUL, + HB_SCRIPT_HEBREW, + HB_SCRIPT_HIRAGANA, + HB_SCRIPT_KANNADA, + HB_SCRIPT_KATAKANA, + HB_SCRIPT_KHMER, + HB_SCRIPT_LAO, + HB_SCRIPT_LATIN, + HB_SCRIPT_MALAYALAM, + HB_SCRIPT_MONGOLIAN, + HB_SCRIPT_MYANMAR, + HB_SCRIPT_OGHAM, + HB_SCRIPT_OLD_ITALIC, + HB_SCRIPT_ORIYA, + HB_SCRIPT_RUNIC, + HB_SCRIPT_SINHALA, + HB_SCRIPT_SYRIAC, + HB_SCRIPT_TAMIL, + HB_SCRIPT_TELUGU, + HB_SCRIPT_THAANA, + HB_SCRIPT_THAI, + HB_SCRIPT_TIBETAN, + HB_SCRIPT_CANADIAN_ABORIGINAL, + HB_SCRIPT_YI, + HB_SCRIPT_TAGALOG, + HB_SCRIPT_HANUNOO, + HB_SCRIPT_BUHID, + HB_SCRIPT_TAGBANWA, + + /* Unicode-4.0 additions */ + HB_SCRIPT_BRAILLE, + HB_SCRIPT_CYPRIOT, + HB_SCRIPT_LIMBU, + HB_SCRIPT_OSMANYA, + HB_SCRIPT_SHAVIAN, + HB_SCRIPT_LINEAR_B, + HB_SCRIPT_TAI_LE, + HB_SCRIPT_UGARITIC, + + /* Unicode-4.1 additions */ + HB_SCRIPT_NEW_TAI_LUE, + HB_SCRIPT_BUGINESE, + HB_SCRIPT_GLAGOLITIC, + HB_SCRIPT_TIFINAGH, + HB_SCRIPT_SYLOTI_NAGRI, + HB_SCRIPT_OLD_PERSIAN, + HB_SCRIPT_KHAROSHTHI, + + /* Unicode-5.0 additions */ + HB_SCRIPT_UNKNOWN, + HB_SCRIPT_BALINESE, + HB_SCRIPT_CUNEIFORM, + HB_SCRIPT_PHOENICIAN, + HB_SCRIPT_PHAGS_PA, + HB_SCRIPT_NKO, + + /* Unicode-5.1 additions */ + HB_SCRIPT_KAYAH_LI, + HB_SCRIPT_LEPCHA, + HB_SCRIPT_REJANG, + HB_SCRIPT_SUNDANESE, + HB_SCRIPT_SAURASHTRA, + HB_SCRIPT_CHAM, + HB_SCRIPT_OL_CHIKI, + HB_SCRIPT_VAI, + HB_SCRIPT_CARIAN, + HB_SCRIPT_LYCIAN, + HB_SCRIPT_LYDIAN, + + /* Unicode-5.2 additions */ + HB_SCRIPT_AVESTAN, + HB_SCRIPT_BAMUM, + HB_SCRIPT_EGYPTIAN_HIEROGLYPHS, + HB_SCRIPT_IMPERIAL_ARAMAIC, + HB_SCRIPT_INSCRIPTIONAL_PAHLAVI, + HB_SCRIPT_INSCRIPTIONAL_PARTHIAN, + HB_SCRIPT_JAVANESE, + HB_SCRIPT_KAITHI, + HB_SCRIPT_TAI_THAM, + HB_SCRIPT_LISU, + HB_SCRIPT_MEETEI_MAYEK, + HB_SCRIPT_OLD_SOUTH_ARABIAN, + HB_SCRIPT_OLD_TURKIC, + HB_SCRIPT_SAMARITAN, + HB_SCRIPT_TAI_VIET, + + /* Unicode-6.0 additions */ + HB_SCRIPT_BATAK, + HB_SCRIPT_BRAHMI, + HB_SCRIPT_MANDAIC +}; + +template +class _FontHashCodeProvider + : public IHashCodeProviderT +{ +public: + _FontHashCodeProvider(void) + { + } + + virtual ~_FontHashCodeProvider(void) + { + } + + virtual int GetHashCode(const T& obj) const + { + return obj.GetHashCode(); + } +}; + +template +class _FontComparer + : public IComparerT +{ +public: + _FontComparer(void) + { + } + + virtual ~_FontComparer(void) + { + } + + virtual result Compare(const T& obj1, const T& obj2, int& cmp) const + { + String& objString1 = static_cast (const_cast (obj1)); + String& objString2 = static_cast (const_cast (obj2)); + + cmp = objString1.CompareTo(objString2); + + return E_SUCCESS; + } +}; + +const _FontHashCodeProvider _fontHashCodeProvider; +const _FontComparer _fontComparer; + +} // unnamed + +namespace Tizen { namespace Graphics +{ + +inline bool +_IsEqual(float f1, float f2) +{ + return (((f1 > f2) ? f1 - f2 : f2 - f1) < 0.00001f); // epsilon is assumed to be 0.0001, not 1.192092896e-07f +} + +_FontFt2::_FontFt2() + : __isValid(false) + , __isLoadGlyph(false) + , __pFontEngine(null) + , __pFontFace(null) + , __pFontBuffer(null) + , __isStaticBuffer(false) +{ + __fontAttrib.size = _DEFAULT_FONT_SIZE; + __fontAttrib.angle = 0.0f; + __fontAttrib.style = _IFont::STYLE_NONE; + __fontAttrib.quality = _IFont::QUALITY_HIGH; + __fontAttrib.xExpansion = 100; + __fontAttrib.boldWeight = 1 << 6; //5L<<14; + + __fallbackFontMap.Construct(1, 0, _fontHashCodeProvider, _fontComparer); + //create cache + + __fontCache.reset(new (std::nothrow) _FontCache()); +} + +_FontFt2::~_FontFt2() +{ + if (!__isValid) + { + return; + } + + __CleanUp(); + __isValid = false; + + __fallbackFontMap.RemoveAll(); +} + +bool +_FontFt2::Create(const void* pBuffer, long bufSize, long face) +{ + if (__isValid) + { + return false; + } + + int error = FT_Init_FreeType(static_cast((void*) &__pFontEngine)); + + if (error) + { + __CleanUp(); + + return false; + } + + // should keep the buffer + __pFontBuffer = new (std::nothrow) byte[bufSize]; + + if (!__pFontBuffer) + { + __CleanUp(); + + return false; + } + + memcpy(__pFontBuffer, pBuffer, bufSize); + + error = FT_New_Memory_Face(FT_Library(__pFontEngine), (const byte*) __pFontBuffer, bufSize, face, static_cast((void*) &__pFontFace)); + + if (error) + { + __CleanUp(); + + return false; + } + + FT_Face pFace = FT_Face(__pFontFace); + + if ((pFace->charmap == null) && (pFace->num_charmaps > 0)) + { + FT_Set_Charmap(pFace, pFace->charmaps[0]); + } + + __isValid = true; + + return true; +} + +bool +_FontFt2::Create(const char* pFilePath, long face) +{ + if (__isValid) + { + return false; + } + + int error = FT_Init_FreeType(static_cast((void*) &__pFontEngine)); + + if (error) + { + __CleanUp(); + + return false; + } + + error = FT_New_Face(FT_Library(__pFontEngine), pFilePath, face, static_cast((void*) &__pFontFace)); + + if (error) + { + __CleanUp(); + + return false; + } + + FT_Face pFace = FT_Face(__pFontFace); + + if ((pFace->charmap == null) && (pFace->num_charmaps > 0)) + { + FT_Set_Charmap(pFace, pFace->charmaps[0]); + } + + __isValid = true; + + return true; +} + +bool +_FontFt2::CreateStatic(const void* pBuffer, long bufSize, long face) +{ + if (__isValid) + { + return false; + } + + FT_Face pFace = null; + + int error = FT_Init_FreeType(static_cast((void*) &__pFontEngine)); + + if (error) + { + __CleanUp(); + + return false; + } + + __pFontBuffer = const_cast(pBuffer); + __isStaticBuffer = true; + + error = FT_New_Memory_Face(FT_Library(__pFontEngine), (const byte*) __pFontBuffer, bufSize, face, static_cast((void*) &__pFontFace)); + + if (error) + { + __CleanUp(); + + return false; + } + + pFace = FT_Face(__pFontFace); + + if ((pFace->charmap == null) && (pFace->num_charmaps > 0)) + { + FT_Set_Charmap(pFace, pFace->charmaps[0]); + } + + __isValid = true; + return true; +} + +bool +_FontFt2::Reload(const void* pBuffer, long bufSize, long face) +{ + if (!__isValid) + { + return false; + } + + std::unique_ptr pReloadBuffer(new (std::nothrow) byte[bufSize]); + + if (pReloadBuffer == null) + { + return false; + } + + memcpy(pReloadBuffer.get(), pBuffer, bufSize); + + void* pReloadFace = null; + + int error = FT_New_Memory_Face(FT_Library(__pFontEngine), (const byte*) pReloadBuffer.get(), bufSize, face, static_cast((void*) &pReloadFace)); + + if (error) + { + return false; + } + + //clean resource + if (__pFontFace) + { + FT_Done_Face(FT_Face(__pFontFace)); + __pFontFace = null; + } + + if (__pFontBuffer && !__isStaticBuffer) + { + delete[] static_cast(__pFontBuffer); + } + + // assign new resource + __pFontBuffer = pReloadBuffer.release(); + __pFontFace = pReloadFace; + __isStaticBuffer = false; + + FT_Face pFace = FT_Face(__pFontFace); + + if ((pFace->charmap == null) && (pFace->num_charmaps > 0)) + { + FT_Set_Charmap(pFace, pFace->charmaps[0]); + } + + __isValid = true; + + return true; +} + +bool +_FontFt2::Reload(const char* filePath, long face) +{ + if (!__isValid) + { + return false; + } + + void* pReloadFace = null; + + int error = FT_New_Face(FT_Library(__pFontEngine), filePath, face, static_cast((void*) &pReloadFace)); + + if (error) + { + return false; + } + + //clean resource + if (__pFontFace) + { + FT_Done_Face(FT_Face(__pFontFace)); + __pFontFace = null; + } + + // assign new resource + __pFontFace = pReloadFace; + __isStaticBuffer = false; + + FT_Face pFace = FT_Face(__pFontFace); + + if ((pFace->charmap == null) && (pFace->num_charmaps > 0)) + { + FT_Set_Charmap(pFace, pFace->charmaps[0]); + } + + __isValid = true; + + return true; +} + +void +_FontFt2::Destroy(void) +{ + if (!__isValid) + { + return; + } + + __CleanUp(); + __isValid = false; +} + +bool +_FontFt2::FindCache(unsigned long character, int size, int style, Glyph** pOut) +{ + return (__fontCache.get()) ? __fontCache->Find(character, __fontAttrib.size, __fontAttrib.style, pOut) : false; +} + +bool +_FontFt2::AddCache(unsigned long character, int size, int style, Glyph* pGlyph) +{ + return (__fontCache.get()) ? __fontCache->Add(character, size, style, pGlyph) : false; +} + +bool +_FontFt2::CleanCache() +{ + return (__fontCache.get()) ? __fontCache->Cleanup() : false; +} + +bool +_FontFt2::SetAttrib(const Attrib& fontAttrib) +{ + if (!__isValid) + { + return false; + } + + if (!(fontAttrib.size >= CONVERT_INTEGER_TO_26_6_FIXED_POINT(1)) || + !(fontAttrib.quality >= 0 && fontAttrib.quality <= 3) || + !(fontAttrib.xExpansion >= 1) || + !(CONVERT_26_6_FIXED_POINT_TO_INTEGER(fontAttrib.size) * fontAttrib.xExpansion >= _DEFAULT_RES) || + !(fontAttrib.boldWeight > 0)) + { + return false; + } + + if (FT_IS_SCALABLE(FT_Face(__pFontFace)) == 0) + { + return false; + } + + if (FT_Set_Char_Size(FT_Face(__pFontFace), fontAttrib.size * _DEFAULT_RES, fontAttrib.size * _DEFAULT_RES, 1, 1) > 0) + { + return false; + } + + // set + memcpy(&__fontAttrib, &fontAttrib, sizeof(fontAttrib)); + + return true; +} + +bool +_FontFt2::GetAttrib(Attrib& fontAttrib) const +{ + if (!__isValid) + { + return false; + } + + fontAttrib.angle = __fontAttrib.angle; + fontAttrib.quality = __fontAttrib.quality; + fontAttrib.size = __fontAttrib.size; + fontAttrib.style = __fontAttrib.style; + fontAttrib.xExpansion = __fontAttrib.xExpansion; + fontAttrib.boldWeight = __fontAttrib.boldWeight; + + return true; +} + +bool +_FontFt2::GetKerning(unsigned long character1, unsigned long character2, long& xVector, long& yVector) const +{ + if (!__isValid) + { + return false; + } + + bool isCharacter1InEnglish = false; + bool isCharacter2InEnglish = false; + FT_Face pFace = null; + unsigned long index1 = 0; + unsigned long index2 = 0; + + if (character1 >= _INDEX_FIRST && character1 < (_INDEX_FIRST + _INDEX_COUNT)) + { + isCharacter1InEnglish = true; + } + + if (character2 >= _INDEX_FIRST && character2 < (_INDEX_FIRST + _INDEX_COUNT)) + { + isCharacter2InEnglish = true; + } + + if (isCharacter1InEnglish != isCharacter2InEnglish) + { + xVector = 0; + yVector = 0; + return true; + } + + pFace = FT_Face(__pFontFace); + index1 = __GetCharIndex(character1); + index2 = __GetCharIndex(character2); + + bool hasKerning = false; + + hasKerning = (FT_HAS_KERNING(pFace) != 0); + + if (hasKerning) + { + FT_Vector delta; + + int isSuccess = FT_Get_Kerning(pFace, index1, index2, ft_kerning_default, &delta); + + if (isSuccess != 0) //0 means success. + { + return false; + } + + const int shiftBit = 6; + xVector = (delta.x >> shiftBit); + yVector = (delta.y >> shiftBit); + } + else + { + xVector = 0; + yVector = 0; + } + + return true; +} + +bool +_FontFt2::LoadGlyph(unsigned long character, Glyph** ppFontGlyphData) +{ + if (!__isValid) + { + return false; + } + + CHECK_NULL_PARAM(__pFontFace); + CHECK_NULL_PARAM(ppFontGlyphData); + + bool rtn = false; + rtn = FindCache(character, __fontAttrib.size, __fontAttrib.style, ppFontGlyphData); + if (rtn) + { + return true; + } + + *ppFontGlyphData = null; + + FT_Face pFace = null; + FT_UInt ixCurr = character; + + pFace = FT_Face(__pFontFace); + + // is it fixed size? + if (!FT_IS_SCALABLE(pFace)) + { + SysLog(NID_GRP, "[] FT_IS_SCALABLE has been failed"); + } + + // retrieve glyph index from character code + ixCurr = __GetCharIndex(character); + + // set transformation + FT_Matrix matrix; + FT_Vector pen = {0, 0}; + __SetTransMatrix(&matrix); + FT_Set_Transform(pFace, &matrix, &pen); + + if (__fontAttrib.quality == _IFont::QUALITY_MONO) + { + //TODO sunmi557.shin, will not support + FT_Error errCode = 1; + + errCode = FT_Load_Glyph(pFace, ixCurr, FT_LOAD_RENDER | FT_LOAD_MONOCHROME); + + if (errCode) + { + SysLogException(NID_GRP, E_SYSTEM, "[E_SYSTEM] FT_Load_Glyph_MONO(errCode = %#x)=", errCode); + + return false; + } + } + else if (__fontAttrib.quality == _IFont::QUALITY_LOW || + __fontAttrib.quality == _IFont::QUALITY_MEDIUM || + __fontAttrib.quality == _IFont::QUALITY_HIGH) + { + FT_Error errCode = 1; + + bool isSynthetic = (__fontAttrib.style & _IFont::STYLE_BOLD) && !(pFace->style_flags & FT_STYLE_FLAG_BOLD); + + if (isSynthetic) + { + errCode = FT_Load_Glyph(pFace, ixCurr, FT_LOAD_DEFAULT | FT_LOAD_NO_BITMAP); + } + else + { + //errCode = FT_Load_Glyph(pFace, ixCurr, FT_LOAD_RENDER); + errCode = FT_Load_Glyph(pFace, ixCurr, FT_LOAD_DEFAULT); + } + + if (errCode) // 0: success + { + SysLogException(NID_GRP, E_SYSTEM, "[E_SYSTEM] FT_Load_Glyph_HighQuality(errCode = %#x)=", errCode); + + return false; + } + + if (isSynthetic) + { + FT_Outline_Embolden(&pFace->glyph->outline, __fontAttrib.boldWeight); + } + + FT_Render_Glyph(pFace->glyph, FT_RENDER_MODE_NORMAL); + + } + else + { + SysLogException(NID_GRP, E_SYSTEM, "[E_SYSTEM] The quality of the FontFT2 is invalid!"); + + return false; + } + + __isLoadGlyph = __ConvertPrivateToImage(pFace->glyph, ppFontGlyphData); + + if (__isLoadGlyph) + { + rtn = AddCache(character, __fontAttrib.size, __fontAttrib.style, *ppFontGlyphData); + } + + if (*ppFontGlyphData != null) + { + (*ppFontGlyphData)->hasOwnerShip = (__isLoadGlyph) ? 1 : 0; + } + + return __isLoadGlyph; +} + +bool +_FontFt2::UnloadGlyph(Glyph** ppFontGlyphData) +{ + if (!__isValid) + { + return false; + } + + CHECK_NULL_PARAM(ppFontGlyphData); + + if ((*ppFontGlyphData) && ((*ppFontGlyphData)->hasOwnerShip == 0)) + { + return false; + } + + delete[] (char*) (*ppFontGlyphData); + + *ppFontGlyphData = null; + __isLoadGlyph = false; + + return false; +} + +unsigned long +_FontFt2::CheckGlyph(unsigned long character) +{ + return __GetCharIndex(character); +} + +bool +_FontFt2::GetFontProperty(Property& property) const +{ + if (!__isValid) + { + return false; + } + + FT_Face face = (FT_Face) __pFontFace; + + if (FT_IS_SCALABLE(face)) + { + const int shiftBit = 6; + + // validation check + if (face->size == null) + { + return false; + } + + // fill out + property.pFamilyName = face->family_name; + property.pStyleName = face->style_name; + property.maxWidth = face->size->metrics.max_advance >> shiftBit; + property.maxHeight = face->size->metrics.height >> shiftBit; + property.baseLine = (face->size->metrics.height + face->size->metrics.descender) >> shiftBit; + property.ascender = face->size->metrics.ascender >> shiftBit; + property.descender = face->size->metrics.descender >> shiftBit; // (-) + property.leading = (face->size->metrics.height - face->size->metrics.ascender + face->size->metrics.descender) >> shiftBit; + + String familyName = String(property.pFamilyName); + + if (_CompareFamilyForTitling(familyName))// temp + { + int min = (face->bbox.yMin * face->size->metrics.y_ppem) / face->units_per_EM; + int max = (face->bbox.yMax * face->size->metrics.y_ppem) / face->units_per_EM; + + if (property.ascender < max) + { + property.ascender = max; + } + + if (property.descender > min) + { + property.descender = min; + } + + property.maxHeight = property.ascender - property.descender; + property.baseLine = (property.maxHeight + property.descender) >> shiftBit; + property.leading = (property.maxHeight - property.ascender + property.descender) >> shiftBit; + } + + // shkim, TODO + // engine name and min/max size need to be verified + property.pEngineName = "FreeType2"; + property.minSize = 8; + property.maxSize = 540; + property.styleCaps = _IFont::STYLE_ITALIC | _IFont::STYLE_BOLD | _IFont::STYLE_BACKSLANT; + property.fontCaps = _IFont::CAPS_SCALABLE | _IFont::CAPS_ANGLE | _IFont::CAPS_X_EXPANSION | _IFont::CAPS_QUALITY_MONO | + _IFont::CAPS_QUALITY_LOW | _IFont::CAPS_QUALITY_MEDIUM | _IFont::CAPS_QUALITY_HIGH; + } + else + { + return false; + } + + return true; +} + +Tizen::Base::Collection::HashMapT* +_FontFt2::GetFallbackMap() +{ + return &__fallbackFontMap; +} + +bool +_FontFt2::GetGlyphList(const _Util::String& text, Tizen::Base::Collection::IListT<_IFont::Glyph *>& out, bool isRtl, int script) const +{ + //hb_font_funcs_t *ffuncs; + FT_Face face = null; + hb_buffer_t *hBuffer = null; + hb_glyph_position_t *positions = null; + hb_glyph_info_t *infos = null; + unsigned int slen; + + /*FriBidiChar *friText = new (std::nothrow) FriBidiChar[length]; + FriBidiCharType *ctypes = new (std::nothrow) FriBidiCharType[length]; + FriBidiLevel *emblevels = new (std::nothrow) FriBidiLevel[length]; + FriBidiJoiningType *join_types = new (std::nothrow) FriBidiJoiningType[length]; + FriBidiParType base_direction = FRIBIDI_PAR_ON; + FriBidiCharType type; + char *ouputChar = new (std::nothrow) char[length];*/ + + //int last_break = 0; + //bool bRTL = true; + +/* + ffuncs = hb_font_funcs_create (); + hb_font_funcs_set_glyph_h_advance_func (ffuncs, glyph_h_advance_func, NULL, NULL); + hb_font_funcs_set_glyph_func (ffuncs, glyph_func, NULL, NULL); + hb_font_funcs_set_glyph_h_kerning_func (ffuncs, glyph_h_kerning_func, NULL, NULL); + hb_font_set_funcs (hFont, ffuncs, NULL, NULL);*/ + + // if(hb_version_check(0, 9, 0))//0.9.0 + // { + // hBuffer = hb_buffer_create(); + // hb_buffer_set_unicode_funcs(hBuffer, hb_unicode_funcs_get_default()); + // hb_buffer_set_language(hBuffer, hb_language_from_string("th", -1)); + // } + //else// 0.7.0 + // { + face = FT_Face(__pFontFace); + + hb_font_t *hFont = hb_ft_font_create (face, NULL); + hb_font_t *hSubFont = hb_font_create_sub_font(hFont); + hb_font_destroy (hFont); + + hBuffer = hb_buffer_create(); + hb_buffer_set_unicode_funcs(hBuffer, hb_unicode_funcs_get_default()); + //hb_buffer_set_language(hBuffer, hb_language_from_string("th")); + + if (isRtl) + { + //hb_buffer_set_language(hBuffer, hb_language_from_string("ar", -1)); + hb_buffer_set_script(hBuffer, _HarfbuzzScript[script]); + hb_buffer_set_direction(hBuffer, HB_DIRECTION_RTL); + } + else + { + //hb_buffer_set_language(hBuffer, hb_language_from_string("en", -1)); + //hb_buffer_set_script(hBuffer, HB_SCRIPT_THAI); + //hb_buffer_set_direction(hBuffer, HB_DIRECTION_LTR); + hb_buffer_set_script(hBuffer, _HarfbuzzScript[script]); + hb_buffer_set_direction(hBuffer, HB_DIRECTION_LTR); + } + + if (sizeof(wchar_t) == sizeof(uint32_t)) + { + hb_buffer_add_utf32(hBuffer, (const uint32_t*)text.pStart, text.length, 0, text.length); + } + else + { + uint32_t* pDst = new (std::nothrow) uint32_t[text.length + 1]; + + if (pDst) + { + { + const wchar_t* pSrc = text.pStart; + + uint32_t* pDstBegin = pDst; + uint32_t* pDstEnd = pDstBegin + text.length; + + while (pDstBegin < pDstEnd) + { + *pDstBegin++ = *pSrc++; + } + + *pDstBegin = 0; + } + + hb_buffer_add_utf32(hBuffer, pDst, text.length, 0, text.length); + + delete[] pDst; + } + } + + /*{ + hb_font_funcs_t *font_funcs = hb_font_funcs_create(); + + hb_font_funcs_set_glyph_h_advance_func(font_funcs, _evas_common_font_ot_hb_get_glyph_advance, NULL, NULL); + hb_font_funcs_set_glyph_h_kerning_func(font_funcs, _evas_common_font_ot_hb_get_kerning, NULL, NULL); + + hb_font_set_funcs(hSubFont, font_funcs, fi, NULL); + }*/ + + hb_shape (hSubFont, hBuffer, NULL, 0); + + slen = hb_buffer_get_length (hBuffer); + positions = hb_buffer_get_glyph_positions (hBuffer, NULL); + infos = hb_buffer_get_glyph_infos (hBuffer, NULL); + + //_IFont::Glyph *pFontGlyphData = (_IFont::Glyph*) new (std::nothrow) char[sizeof(_IFont::Glyph) + (image.bytesPerLine * image.height)]; + + out.RemoveAll(); + + for(unsigned int i = 0; i < slen; i++) + { + FT_UInt glyph_index = infos->codepoint; + + _IFont::GlyphBitmap image; + + FT_Error error = FT_Load_Glyph(face, glyph_index, /*FT_LOAD_RENDER*/FT_LOAD_DEFAULT/* | FT_LOAD_NO_BITMAP*/); + if(error) + { + continue; + } + + error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL); + if(error) + { + continue; + } + + FT_GlyphSlot pSlot = FT_GlyphSlot(face->glyph); + + switch (pSlot->bitmap.pixel_mode) + { + case ft_pixel_mode_mono: + image.depth = 1; + break; + + case ft_pixel_mode_grays: + image.depth = 8; + break; + + default: + continue; + } + + image.width = pSlot->bitmap.width; + image.height = pSlot->bitmap.rows; + image.bytesPerLine = pSlot->bitmap.pitch; + image.pBitmap = pSlot->bitmap.buffer; + + _IFont::Glyph *pFontGlyphData = (_IFont::Glyph*) new (std::nothrow) char[sizeof(_IFont::Glyph) + (image.bytesPerLine * image.height)]; + + if (pFontGlyphData == null) + continue; + + pFontGlyphData->id = 0; + pFontGlyphData->xOffset = (positions->x_offset >> 6) + pSlot->bitmap_left; + pFontGlyphData->yOffset = (positions->y_offset >> 6) + pSlot->bitmap_top; + pFontGlyphData->xAdvance = pSlot->advance.x << (_FIXED_SHIFT - 6); + pFontGlyphData->yAdvance = -(pSlot->advance.y << (_FIXED_SHIFT - 6)); + //pFontGlyphData->xOffset = positions->x_offset; + //pFontGlyphData->yOffset = positions->y_offset; + //pFontGlyphData->xAdvance = positions->x_advance; + //pFontGlyphData->yAdvance = positions->y_advance; + pFontGlyphData->image = image; + + pFontGlyphData->image.pBitmap = (unsigned char*)(pFontGlyphData + 1); + memcpy(pFontGlyphData->image.pBitmap, image.pBitmap, image.bytesPerLine * image.height); + + out.Add(pFontGlyphData); + + infos++; + positions++; + } + + hb_font_destroy (hSubFont); + hb_buffer_destroy(hBuffer); + + return true; +} + +void +_FontFt2::__CleanUp() +{ + if (__pFontFace) + { + FT_Done_Face(FT_Face(__pFontFace)); + __pFontFace = null; + } + + if (__pFontEngine) + { + FT_Done_FreeType(FT_Library(__pFontEngine)); + __pFontEngine = null; + } + + if (__pFontBuffer && !__isStaticBuffer) + { + delete[] static_cast(__pFontBuffer); + } + + __pFontBuffer = null; + __isStaticBuffer = false; +} + +unsigned long +_FontFt2::__GetCharIndex(unsigned long character) const +{ + if (!__isValid) + { + return 0; + } + + FT_Face pFace = FT_Face(__pFontFace); + if (pFace == null) + { + return false; + } + + if (pFace->charmap) + { + unsigned long ixCurr = FT_Get_Char_Index(pFace, character); + + return ixCurr; + } + + return character; +} + +bool +_FontFt2::__ConvertPrivateToImage(void* pData1, _IFont::Glyph** ppFontGlyphData) +{ + if (!__isValid) + { + return false; + } + + FT_GlyphSlot pSlot = FT_GlyphSlot(pData1); + + _IFont::GlyphBitmap image; + + switch (pSlot->bitmap.pixel_mode) + { + case ft_pixel_mode_mono: + image.depth = 1; + break; + case ft_pixel_mode_grays: + image.depth = 8; + break; + default: + return false; + } + + image.width = pSlot->bitmap.width; + image.height = pSlot->bitmap.rows; + image.bytesPerLine = pSlot->bitmap.pitch; + image.pBitmap = pSlot->bitmap.buffer; + + *ppFontGlyphData = (_IFont::Glyph*) new (std::nothrow) char[sizeof(_IFont::Glyph) + (image.bytesPerLine * image.height)]; + + if (*ppFontGlyphData == null) + { + return false; + } + + (*ppFontGlyphData)->id = 0; + (*ppFontGlyphData)->xOffset = pSlot->bitmap_left << _FIXED_SHIFT; + (*ppFontGlyphData)->yOffset = pSlot->bitmap_top << _FIXED_SHIFT; + (*ppFontGlyphData)->xAdvance = pSlot->advance.x << (_FIXED_SHIFT - 6); + (*ppFontGlyphData)->yAdvance = -(pSlot->advance.y << (_FIXED_SHIFT - 6)); + (*ppFontGlyphData)->hasOwnerShip = 0; + (*ppFontGlyphData)->image = image; + + // shkim, set the memory address of bitmap to the allocated by ourself above + //(*pFontGlyphData)->image.bitmap = (unsigned char*)((*pFontGlyphData) + 1); + + if (image.width == 0 || image.height == 0) + { + return true; + } + + //memcpy((*ppFontGlyphData)->image.bitmap, image.bitmap, image.bytesPerLine * image.height); + + return true; +} + +bool +_FontFt2::__SetTransMatrix(void* pMatrix) +{ + if (!__isValid) + { + return false; + } + + if (pMatrix == null) + { + return true; + } + + FT_Matrix* pTrans = (FT_Matrix*) pMatrix; + + double radian = _M_PI / 180.0; + + if (_IsEqual(0.0f, __fontAttrib.angle)) + { + // apply font size + pTrans->xx = (FT_Fixed) (0x10000 * (__fontAttrib.xExpansion)) / 100; + pTrans->xy = (FT_Fixed) 0; + pTrans->yx = (FT_Fixed) 0; + pTrans->yy = (FT_Fixed) 0x10000; + + // apply italic style + if (__fontAttrib.style & _IFont::STYLE_ITALIC) + { + pTrans->xy = (FT_Fixed) (sin(_ITALIC_ANGLE * radian) * 0x10000); + } + else if (__fontAttrib.style & _IFont::STYLE_BACKSLANT) + { + pTrans->xy = (FT_Fixed) (sin(-_ITALIC_ANGLE * radian) * 0x10000); + } + } + else + { + double radAngle = __fontAttrib.angle * radian; + + pTrans->xx = (FT_Fixed) (cos(radAngle) * (__fontAttrib.xExpansion) * 0x10000) / 100; + pTrans->xy = (FT_Fixed) (-sin(radAngle) * 0x10000); + pTrans->yx = (FT_Fixed) (sin(radAngle) * (__fontAttrib.xExpansion) * 0x10000) / 100; + pTrans->yy = (FT_Fixed) (cos(radAngle) * 0x10000); + + // apply italic style + if (__fontAttrib.style & _IFont::STYLE_ITALIC) + { + pTrans->xy = (FT_Fixed) ((cos(radAngle) * tan(_ITALIC_ANGLE * radian) - sin(radAngle)) * 0x10000); + pTrans->yy = (FT_Fixed) ((sin(radAngle) * tan(_ITALIC_ANGLE * radian) + cos(radAngle)) * 0x10000); + } + else if (__fontAttrib.style & _IFont::STYLE_BACKSLANT) + { + pTrans->xy = (FT_Fixed) ((cos(radAngle) * tan(-_ITALIC_ANGLE * radian) - sin(radAngle)) * 0x10000); + pTrans->yy = (FT_Fixed) ((sin(radAngle) * tan(-_ITALIC_ANGLE * radian) + cos(radAngle)) * 0x10000); + } + } + + return true; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_FontFt2.h b/src/graphics/FGrp_FontFt2.h new file mode 100644 index 0000000..ac78b1b --- /dev/null +++ b/src/graphics/FGrp_FontFt2.h @@ -0,0 +1,102 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontFt2.h + * @brief This is the header file for FGrp_FontFt2 class. + * + */ + +#ifndef _FGRP_INTERNAL_FONT_FT2_H_ +#define _FGRP_INTERNAL_FONT_FT2_H_ + +#include "FGrp_IFont.h" + + +namespace Tizen { namespace Graphics +{ + +class _FontCache; + +class _FontFt2 + : public _IFont +{ +public: + _FontFt2(); + virtual ~_FontFt2(); + + virtual bool SetAttrib(const Attrib& fontAttrib); + virtual bool GetAttrib(Attrib& fontAttrib) const; + + virtual bool GetKerning(unsigned long character1, unsigned long character2, long& xVector, long& yVector) const; + + virtual bool LoadGlyph(unsigned long character, Glyph** ppFontGlyphData); + virtual bool UnloadGlyph(Glyph** ppFontGlyphData); + virtual unsigned long CheckGlyph(unsigned long character); + + virtual bool GetFontProperty(Property& property) const; + + virtual bool GetGlyphList(const _Util::String& text, Tizen::Base::Collection::IListT<_IFont::Glyph *>& out, bool isRtl, int script) const; + + virtual Tizen::Base::Collection::HashMapT* GetFallbackMap(void); + +protected: + virtual bool Create(const void* pBuffer, long bufSize, long face = 0); + virtual bool Create(const char* pFilePath, long face = 0); + virtual bool CreateStatic(const void* pBuffer, long bufSize, long face = 0); + virtual bool Reload(const void* pBuffer, long bufSize, long face = 0); + virtual bool Reload(const char* filePath, long face = 0); + virtual void Destroy(void); + virtual bool FindCache(unsigned long character, int size, int style, Glyph** pOut); + virtual bool AddCache(unsigned long character, int size, int style, Glyph* pGlyph); + virtual bool CleanCache(void); + +private: + _FontFt2(const _FontFt2& font); + _FontFt2& operator =(const _FontFt2& rhs); + + // cleaning up + void __CleanUp(); + + // return internal index for wide character + unsigned long __GetCharIndex(unsigned long character) const; + + // convert the glyph of FreeType2 to _IFont::Glyph information + bool __ConvertPrivateToImage(void* pData1, _IFont::Glyph** ppFontGlyphData); + + // set translate matrix + bool __SetTransMatrix(void* pMatrix); + +private: + bool __isValid; + bool __isLoadGlyph; + _IFont::Attrib __fontAttrib; + void* __pFontEngine; + void* __pFontFace; + void* __pFontBuffer; + bool __isStaticBuffer; + + //_FontCache fontCache; + std::auto_ptr<_FontCache> __fontCache; + // fallback font resources + Tizen::Base::Collection::HashMapT __fallbackFontMap; + +}; // _FontFt2 + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_FONT_FT2_H_ diff --git a/src/graphics/FGrp_FontImpl.cpp b/src/graphics/FGrp_FontImpl.cpp new file mode 100644 index 0000000..a792c1c --- /dev/null +++ b/src/graphics/FGrp_FontImpl.cpp @@ -0,0 +1,560 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontImpl.cpp + * @brief This is the implementation file for _FontImpl class. + * + */ + +#include +#include + +#include + +#include + +#include "FGrp_FontImpl.h" +#include "FGrp_Font.h" +#include "FGrp_ResUtil.h" + + +#define IF_NOT_INITIALIZED(code) if (this->_pNativeFont == null || this->_pCoordHolder == null) \ + { \ + code; \ + } +#define IF_NOT_CONSTRUCTED(code) if (this->_pNativeFont == null || (!this->_pNativeFont->IsConstructed())) \ + { \ + code; \ + } +#define IsSucceeded(X) (!IsFailed(X)) +#define CONVERT_INTEGER_TO_26_6_FIXED_POINT(value) (value * 64) + + +namespace Tizen { namespace Graphics +{ + +struct _FontCoordHolder +{ + _ResUtil::CoordHolder size; + _ResUtil::CoordHolder charSpace; + + _FontCoordHolder() + { + Reset(-1); + } + + void Reset(int _size) + { + size = _size; + charSpace = 0; + } +}; + + +_FontImpl::_FontImpl() + : _pCoordHolder(new (std::nothrow) _FontCoordHolder) + , _pNativeFont(new (std::nothrow) _Font) +{ + if (_pNativeFont == null || _pCoordHolder == null) + { + delete _pNativeFont; + delete _pCoordHolder; + + _pNativeFont = null; + _pCoordHolder = null; + } +} + +_FontImpl::_FontImpl(const _FontImpl& obj) + : _pCoordHolder(new (std::nothrow) _FontCoordHolder) + , _pNativeFont(0) +{ + if (_pCoordHolder) + { + *_pCoordHolder = *obj._pCoordHolder; + } + + _pNativeFont = obj._pNativeFont->CloneN(); + + if (_pNativeFont == null || _pCoordHolder == null) + { + delete _pNativeFont; + delete _pCoordHolder; + + _pNativeFont = null; + _pCoordHolder = null; + } +} + +_FontImpl::~_FontImpl() +{ + if (_pNativeFont) + { + delete _pNativeFont; + _pNativeFont = 0; + } + + if (_pCoordHolder) + { + delete _pCoordHolder; + _pCoordHolder = 0; + } +} + +result +_FontImpl::Construct(int style, int vcSize) +{ + IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY); + + // convert VC -> PC + int pcSize = _ResUtil::ConvertToPhyCoordHeight(CONVERT_INTEGER_TO_26_6_FIXED_POINT(vcSize)); + if (vcSize > 0 && pcSize <= CONVERT_INTEGER_TO_26_6_FIXED_POINT(1)) + { + pcSize = CONVERT_INTEGER_TO_26_6_FIXED_POINT(1); + } + + result r = _pNativeFont->Construct(style, pcSize); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to construct _Font", GetErrorMessage(r)); + + _pCoordHolder->Reset(vcSize); + + return E_SUCCESS; +} + +result +_FontImpl::Construct(const Tizen::Base::String& fontName, int style, int vcSize, bool isPathEnabled) +{ + IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY); + + // convert VC -> PC + int pcSize = _ResUtil::ConvertToPhyCoordHeight(CONVERT_INTEGER_TO_26_6_FIXED_POINT(vcSize)); + if (vcSize > 0 && pcSize <= CONVERT_INTEGER_TO_26_6_FIXED_POINT(1)) + { + pcSize = CONVERT_INTEGER_TO_26_6_FIXED_POINT(1); + } + + result r = _pNativeFont->Construct(fontName, style, pcSize, isPathEnabled); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to construct _Font", GetErrorMessage(r)); + + _pCoordHolder->Reset(vcSize); + + return E_SUCCESS; +} + +result +_FontImpl::Construct(const Tizen::Base::ByteBuffer& fontData, int style, int vcSize) +{ + IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY); + + // convert VC -> PC + int pcSize = _ResUtil::ConvertToPhyCoordHeight(CONVERT_INTEGER_TO_26_6_FIXED_POINT(vcSize)); + if (vcSize > 0 && pcSize <= CONVERT_INTEGER_TO_26_6_FIXED_POINT(1)) + { + pcSize = CONVERT_INTEGER_TO_26_6_FIXED_POINT(1); + } + + result r = _pNativeFont->Construct(fontData, style, pcSize); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to construct _Font", GetErrorMessage(r)); + + _pCoordHolder->Reset(vcSize); + + return E_SUCCESS; +} + +bool +_FontImpl::IsConstructed(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + return true; +} + +int +_FontImpl::GetMaxHeight(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + int pcMaxHeight = _pNativeFont->GetMaxHeight(); + int vcMaxHeight = _ResUtil::ConvertToVirCoordY(pcMaxHeight); + + return vcMaxHeight; +} + +int +_FontImpl::GetMaxWidth(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + int pcMaxWidth = _pNativeFont->GetMaxWidth(); + int vcMaxWidth = _ResUtil::ConvertToVirCoordX(pcMaxWidth); + + return vcMaxWidth; +} + +int +_FontImpl::GetAscender(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + int pcAscender = _pNativeFont->GetAscender(); + int vcAscender = _ResUtil::ConvertToVirCoordY(pcAscender); + + return vcAscender; +} + +int +_FontImpl::GetDescender(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + int pcDescender = _pNativeFont->GetDescender(); + int vcDescender = _ResUtil::ConvertToVirCoordY(pcDescender); + if (vcDescender < 0) + { + vcDescender *= -1; + } + + return vcDescender; +} + +result +_FontImpl::GetLeftBear(wchar_t character, int& vcLeftBear) const +{ + IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED); + + int pcLeftBear = 0; + result r = _pNativeFont->GetLeftBear(character, pcLeftBear); + + // set outparam + vcLeftBear = _ResUtil::ConvertToVirCoordX(pcLeftBear); + + return r; +} + +result +_FontImpl::GetRightBear(wchar_t character, int& vcRightBear) const +{ + IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED); + + int pcRightBear = 0; + result r = _pNativeFont->GetRightBear(character, pcRightBear); + + // set outparam + vcRightBear = _ResUtil::ConvertToVirCoordX(pcRightBear); + + return r; +} + +result +_FontImpl::GetTextExtent(const Tizen::Base::String& text, int length, Dimension& vcDim) const +{ + IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED); + + if (_ResUtil::NeedToConvertCoord()) + { + Dimension pcDim; + result r = _pNativeFont->GetTextExtent(text, length, pcDim); + + if (IsSucceeded(r)) + { + vcDim = _ResUtil::ConvertToVirCoord(pcDim); + } + + return r; + } + else + { + return _pNativeFont->GetTextExtent(text, length, vcDim); + } +} + +bool +_FontImpl::IsBold(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + return _pNativeFont->IsBold(); +} + +bool +_FontImpl::IsItalic(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + return _pNativeFont->IsItalic(); +} + +bool +_FontImpl::IsPlain(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + return _pNativeFont->IsPlain(); +} + +bool +_FontImpl::IsStrikeOut(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + return _pNativeFont->IsStrikeOut(); +} + +bool +_FontImpl::IsUnderlined(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + return _pNativeFont->IsUnderlined(); +} + +int +_FontImpl::GetSize(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + if (_ResUtil::NeedToConvertCoord()) + { + return _pCoordHolder->size.required; + } + else + { + return _pNativeFont->GetSize(); + } +} + +void +_FontImpl::SetStrikeOut(bool strikeOut) +{ + IF_NOT_CONSTRUCTED(return); + + return _pNativeFont->SetStrikeOut(strikeOut); +} + +void +_FontImpl::SetUnderline(bool underline) +{ + IF_NOT_CONSTRUCTED(return); + + return _pNativeFont->SetUnderline(underline); +} + +void +_FontImpl::SetCharSpace(int vcSpace) +{ + IF_NOT_CONSTRUCTED(return); + + // save it + _pCoordHolder->charSpace = vcSpace; + + // convert VC -> PC + int pcSpace = _ResUtil::ConvertToPhyCoordWidth(vcSpace); + + return _pNativeFont->SetCharSpace(pcSpace); +} + +int +_FontImpl::GetCharSpace(void) const +{ + IF_NOT_CONSTRUCTED(return 0); + + if (_ResUtil::NeedToConvertCoord()) + { + return _pCoordHolder->charSpace.required; + } + else + { + return _pNativeFont->GetCharSpace(); + } +} + +Tizen::Base::String +_FontImpl::GetFaceName(void) const +{ + IF_NOT_CONSTRUCTED(return ""); + + return _pNativeFont->GetFaceName(); +} + +Tizen::Base::Collection::IList* +_FontImpl::GetSystemFontListN(void) +{ + return _Font::GetSystemFontListN(); +} + +Tizen::Base::String +_FontImpl::GetFaceName(const Tizen::Base::String& filePath) +{ + return _Font::GetFaceName(filePath); +} + +_FontImpl* +_FontImpl::CloneN(void) +{ + IF_NOT_CONSTRUCTED(return null); + + std::auto_ptr<_FontImpl> pFontImpl(new (std::nothrow) _FontImpl(*this)); + + SysTryReturn(NID_GRP, pFontImpl.get(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocated memory"); + SysTryReturn(NID_GRP, pFontImpl->_pNativeFont, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] FontEx::CloneN() has been failed"); + + return pFontImpl.release(); +} + +Font* +_FontImpl::CloneN(const Font& font) +{ + // check the validation of input param + SysTryReturn(NID_GRP, font.__pImpl && font.__pImpl->IsConstructed(), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input param given"); + + // make sure if the copy construction is well done + std::auto_ptr pFont(new (std::nothrow) Font(font)); + + SysTryReturn(NID_GRP, pFont.get() && pFont->__pImpl && pFont->__pImpl->IsConstructed(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory"); + + return pFont.release(); +} + +result +_FontImpl::GetTextExtent(int vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, int& count, Dimension& vcDim) const +{ + IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED); + + SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE, + "The length(%d) & startIndex(%d) of the given text is out of range", length, startIndex); + + if (_ResUtil::NeedToConvertCoord()) + { + int pcWidth = _ResUtil::ToPhyCoordW(vcWidth); + Dimension pcDim; + result r = _pNativeFont->GetTextExtent(pcWidth, text, startIndex, length, outline, count, pcDim); + + if (IsSucceeded(r)) + { + vcDim = _ResUtil::ConvertToVirCoord(pcDim); + } + + return r; + } + else + { + return _pNativeFont->GetTextExtent(vcWidth, text, startIndex, length, outline, count, vcDim); + } +} + +result +_FontImpl::GetTextExtent(int vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, Dimension& vcDim) const +{ + IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED); + + SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE, + "The length(%d) & startIndex(%d) of the given text is out of range", length, startIndex); + + if (_ResUtil::NeedToConvertCoord()) + { + int pcWidth = _ResUtil::ToPhyCoordW(vcWidth); + Dimension pcDim; + result r = _pNativeFont->GetTextExtent(pcWidth, text, startIndex, length, outline, delimiter, count, pcDim); + + if (IsSucceeded(r)) + { + vcDim = _ResUtil::ConvertToVirCoord(pcDim); + } + + return r; + } + else + { + return _pNativeFont->GetTextExtent(vcWidth, text, startIndex, length, outline, delimiter, count, vcDim); + } +} + +result +_FontImpl::SetSize(int vcSize) +{ + IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED); + SysTryReturnResult(NID_GRP, vcSize > 0, E_INVALID_ARG, "font size should be greater than 0"); + + _pCoordHolder->Reset(vcSize); + + // convert VC -> PC + int pcSize = _ResUtil::ConvertToPhyCoordHeight(CONVERT_INTEGER_TO_26_6_FIXED_POINT(vcSize)); + if (vcSize > 0 && pcSize <= CONVERT_INTEGER_TO_26_6_FIXED_POINT(1)) + { + pcSize = CONVERT_INTEGER_TO_26_6_FIXED_POINT(1); + _pCoordHolder->size.phyCoord = pcSize; + _pCoordHolder->size.virCoord = vcSize; + } + + result r = _pNativeFont->SetSize(pcSize); + SysTryReturnResult(NID_GRP, r == E_SUCCESS, E_SYSTEM, "Failed to set the size of _Font"); + + return E_SUCCESS; +} + +result +_FontImpl::SetStyle(int style) +{ + IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED); + SysTryReturnResult(NID_GRP, style > FONT_STYLE_MIN && style <= (FONT_STYLE_PLAIN | FONT_STYLE_BOLD | FONT_STYLE_ITALIC), E_INVALID_ARG, + "Style(%d) is invalid", style); + + result r = _pNativeFont->SetStyle(style); + SysTryReturnResult(NID_GRP, r == E_SUCCESS, E_SYSTEM, "Failed to set the style of _Font"); + + return E_SUCCESS; +} + +int +_FontImpl::GetStyle(void) const +{ + IF_NOT_CONSTRUCTED(return FONT_STYLE_PLAIN); + + return _pNativeFont->GetStyle(); +} + +int +_FontImpl::GetLeading(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + int pcLeading = _pNativeFont->GetLeading(); + int vcLeading = _ResUtil::ConvertToVirCoordY(pcLeading); + + return vcLeading; +} + +_FontImpl* +_FontImpl::GetInstance(Font& font) +{ + return (&font != null) ? font.__pImpl : null; +} + +const _FontImpl* +_FontImpl::GetInstance(const Font& font) +{ + return (&font != null) ? font.__pImpl : null; +} + +bool +_FontImpl::UpdateDefaultFont(const Tizen::Base::String& key) +{ + return _Font::UpdateDefaultFont(key); +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_FontMemoryManager.cpp b/src/graphics/FGrp_FontMemoryManager.cpp new file mode 100644 index 0000000..adac645 --- /dev/null +++ b/src/graphics/FGrp_FontMemoryManager.cpp @@ -0,0 +1,232 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontMemoryManager.cpp + * @brief This is the cpp file for _FontMemoryManager class. + * + */ + +#include + +#include + +#include "FGrp_FontMemoryManager.h" + + +namespace Tizen { namespace Graphics +{ + +class CountBasedMemoryMgr + : public _FontMemoryManager::IMemoryAllocator +{ +public: + CountBasedMemoryMgr(unsigned long size) + : __maxCount(size) + , __currentCount(0) + { + } + + virtual ~CountBasedMemoryMgr(void) {} + + virtual void* Alloc(unsigned long size) + { + if (__currentCount >= __maxCount) + { + return null; + } + + __currentCount++; + + return new (std::nothrow) char[size]; + } + + virtual void Free(void* pMem) + { + if (__currentCount <= 0) + { + return; + } + + __currentCount--; + + delete [] (char*)(pMem); + } + + virtual unsigned long GetRemainedMemory() + { + return 0; + } + +private: + unsigned long __maxCount; + unsigned long __currentCount; +}; + +class SizeBasedMemoryMgr + : public _FontMemoryManager::IMemoryAllocator +{ + typedef unsigned long PtrDiffType; + +public: + SizeBasedMemoryMgr(unsigned long size) + : __maxMemory(size) + , __currentUsedMemory(0) + { + } + + virtual ~SizeBasedMemoryMgr(void) + { + } + + virtual void* Alloc(unsigned long size) + { + size += sizeof(PtrDiffType); + + if (__currentUsedMemory + size > __maxMemory) + { + return null; + } + + void* pMem = new (std::nothrow) char[size]; + if (pMem) + { + *((PtrDiffType*)pMem) = size; + pMem = (void*)((char*)pMem + sizeof(PtrDiffType)); + __currentUsedMemory += size; + } + + return pMem; + } + + virtual void Free(void* pMem) + { + if (__currentUsedMemory <= 0 || pMem == null) + { + return; + } + + pMem = (void*)((char*)pMem - sizeof(PtrDiffType)); + __currentUsedMemory -= *((PtrDiffType*)pMem); + + delete [] (char*)(pMem); + } + + virtual unsigned long GetRemainedMemory() + { + return __maxMemory - __currentUsedMemory; + } + +private: + unsigned long __maxMemory; + unsigned long __currentUsedMemory; +}; + +class FixedSizeMemoryMgr + : public _FontMemoryManager::IMemoryAllocator +{ +public: + FixedSizeMemoryMgr(unsigned long size) + { + } + + virtual ~FixedSizeMemoryMgr(void) {} + + virtual void* Alloc(unsigned long size) + { + return null; + } + + virtual void Free(void* pMem) + { + } + + virtual unsigned long GetRemainedMemory() + { + return 0; + } +}; + +_FontMemoryManager::_FontMemoryManager(_FontMemoryManager::Type type, int size) + : __pAllocator(null) +{ + IMemoryAllocator* p = null; + switch (type) + { + case _FontMemoryManager::TYPE_COUNT: + p = new (std::nothrow) CountBasedMemoryMgr(size); + break; + case _FontMemoryManager::TYPE_SIZE: + p = new (std::nothrow) SizeBasedMemoryMgr(size); + break; + case _FontMemoryManager::TYPE_FIXED_MEMORY: + p = new (std::nothrow) FixedSizeMemoryMgr(size); + break; + default: + break; + } + + __pAllocator = p; +} + +_FontMemoryManager::~_FontMemoryManager(void) +{ + if (__pAllocator) + { + delete __pAllocator; + } + __pAllocator = null; +} + +void* +_FontMemoryManager::Alloc(unsigned long size) +{ + if (__pAllocator == null) + { + return null; + } + + return __pAllocator->Alloc(size); +} + +void +_FontMemoryManager::Free(void* pMemory) +{ + if (__pAllocator) + { + return __pAllocator->Free(pMemory); + } +} + +unsigned long +_FontMemoryManager::GetRemainedMemory() +{ + if (__pAllocator) + { + return __pAllocator->GetRemainedMemory(); + } + + return 0; +} + +bool +_FontMemoryManager::IsValid() const +{ + return (__pAllocator != null); +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_FontMemoryManager.h b/src/graphics/FGrp_FontMemoryManager.h new file mode 100644 index 0000000..6bda2fd --- /dev/null +++ b/src/graphics/FGrp_FontMemoryManager.h @@ -0,0 +1,68 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontMemoryManager.h + * @brief This is the header file for _FontMemoryManager class. + * + */ + +#ifndef _FGRP_INTERNAL_FONT_MEMORY_MANAGER_H_ +#define _FGRP_INTERNAL_FONT_MEMORY_MANAGER_H_ + + +namespace Tizen { namespace Graphics +{ + +class _FontMemoryManager +{ +public: + enum Type + { + TYPE_COUNT = 0, + TYPE_SIZE, + TYPE_FIXED_MEMORY + }; + + class IMemoryAllocator + { + public: + virtual ~IMemoryAllocator(void) {} + virtual void* Alloc(unsigned long size) = 0; + virtual void Free(void* pMem) = 0; + virtual unsigned long GetRemainedMemory(void) = 0; + }; + + _FontMemoryManager(_FontMemoryManager::Type typetype, int size); + virtual ~_FontMemoryManager(void); + + void* Alloc(unsigned long size); + void Free(void* pMem); + unsigned long GetRemainedMemory(void); + bool IsValid(void) const; + +private: + _FontMemoryManager(const _FontMemoryManager& obj); + _FontMemoryManager& operator =(const _FontMemoryManager& rhs); + _FontMemoryManager* operator &(void); + + IMemoryAllocator* __pAllocator; +}; + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_FONT_MEMORY_MANAGER_H_ diff --git a/src/graphics/FGrp_FontRsrcManager.cpp b/src/graphics/FGrp_FontRsrcManager.cpp new file mode 100644 index 0000000..aec2e73 --- /dev/null +++ b/src/graphics/FGrp_FontRsrcManager.cpp @@ -0,0 +1,1223 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontRsrcManager.cpp + * @brief This is the cpp file for _FontRsrcManager class. + * + */ + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "FGrp_Font.h" +#include "FGrp_FontRsrcManager.h" +#include "FGrp_FontMemoryManager.h" +#include "FGrp_FontFt2.h" + +#define USE_REMOVE_ALL_CACHE +#define USE_MMAP + +#include "util/FGrp_UtilTemplate.h" + + +#define IF_NOT_INITIALIZED(code) if (_pImpl == null) \ + { \ + code; \ + } + +using namespace Tizen::App; +using namespace Tizen::Io; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::System; + + +namespace // unnamed +{ + +const int _DEFAULT_FONT_ENGINE = 0; +const int _DEFAULT_FONT_FACE = 0; +const char* _DEFAULT_SYSTEM_FONT = "DefaultSystemFont"; +const char* _DEFAULT_SYSTEM_BOLD_FONT = "DefaultSystemBoldFont"; +const int _SYSTEM_DEFAULT_FONT_SIZE = 16 * 64; + +class _FontNull + : public Tizen::Graphics::_IFont +{ +public: + virtual bool SetAttrib(const Attrib& fontAttrib) + { + return false; + } + + virtual bool GetAttrib(Attrib& fontAttrib) const + { + return false; + } + + virtual bool GetKerning(unsigned long character1, unsigned long character2, long& xVector, long& yVector) const + { + return false; + } + + virtual bool LoadGlyph(unsigned long character, Glyph** pFontGlyphData) + { + return false; + } + + virtual bool UnloadGlyph(Glyph** pFontGlyphData) + { + return false; + } + + virtual unsigned long CheckGlyph(unsigned long character) + { + return 0; + } + + virtual bool GetGlyphList(const _Util::String& text, Tizen::Base::Collection::IListT<_IFont::Glyph *>& out, bool isRtl, int script) const + { + return false; + } + + virtual bool GetFontProperty(Property& property) const + { + return false; + } + + virtual Tizen::Base::Collection::HashMapT* GetFallbackMap(void) + { + return null; + } + +protected: + virtual bool Create(const void* pBuffer, long bufSize, long face = 0) + { + return false; + } + + virtual bool Create(const char* pFilePath, long face = 0) + { + return false; + } + + virtual bool CreateStatic(const void* pBuffer, long bufSize, long face = 0) + { + return false; + } + + virtual bool Reload(const void* pBuffer, long bufSize, long face = 0) + { + return false; + } + + virtual bool Reload(const char* filePath, long face = 0) + { + return false; + } + + virtual void Destroy(void) {} + + virtual bool FindCache(unsigned long character, int size, int style, Glyph** pOut) + { + return false; + } + + virtual bool AddCache(unsigned long character, int size, int style, Glyph* pGlyph) + { + return false; + } + + virtual bool CleanCache(void) + { + return false; + } +}; // _FontNull + +template +class _FontHashCodeProvider + : public IHashCodeProviderT +{ +public: + virtual int GetHashCode(const T& obj) const + { + return obj.GetHashCode(); + } +}; // _FontHashCodeProvider + +template +class _FontComparer + : public IComparerT +{ +public: + virtual result Compare(const T& obj1, const T& obj2, int& cmp) const + { + String& objString1 = static_cast (const_cast (obj1)); + String& objString2 = static_cast (const_cast (obj2)); + + cmp = objString1.CompareTo(objString2); + + return E_SUCCESS; + } +}; // _FontComparer + +} + + +namespace Tizen { namespace Graphics +{ + +_FontRsrcManager* _FontRsrcManager::__pTheInstance = null; + +_FontRsrcManager::_FontRsrcManager() + : __isAppFontListInitialized(false) +{ + static _FontHashCodeProvider fontHashCodeProvider; + static _FontComparer fontComparer; + + // are you worry about failing to construct? + // but, HashMapT only can give E_SUCCESS/E_INVALID_ARG/E_OUT_OF_MEMORY. + // it means, if you have already verified input param, don't need to concern yourself. + // even though you have E_OUT_OF_MEMORY, it's already out of our control, + // and surely the other member function can give a error message. + __fontRsrcMap.Construct(0, 0, fontHashCodeProvider, fontComparer); + __appFontMap.Construct(0, 0, fontHashCodeProvider, fontComparer); + + __defaultSystemFontPath.Clear(); + __defaultSystemBoldFontPath.Clear(); + __pDefaultSystemFont = null; + + FcInit(); + + const unsigned long cacheMemorySize = 1 * 1024 * 1024; + std::unique_ptr<_FontMemoryManager> pMemoryMgr(new (std::nothrow) _FontMemoryManager(_FontMemoryManager::TYPE_SIZE, cacheMemorySize)); + + if (pMemoryMgr != null && pMemoryMgr->IsValid()) + { + __pFontMemoryManager = pMemoryMgr.release(); + } + + SysAssert(__pFontMemoryManager != null); +} + +_FontRsrcManager::~_FontRsrcManager() +{ + __fontRsrcMap.RemoveAll(); + __appFontMap.RemoveAll(); + + delete __pDefaultSystemFont; + delete __pFontMemoryManager; + + FcFini(); +} + +result +_FontRsrcManager::GetFont(const Tizen::Base::String& fontPath, int style, int size, SharedFontResource& out) +{ + SharedFontResource sharedFont; + _IFont* pFont = null; + + bool rtn = false; + + //-------------------------------------------------------------------------- + // validation check of input param + // + // in case input fontPath is indicating folder, + // we should return 'E_UNSUPPORTED_FORMAT' as bads 2.0 did. + //-------------------------------------------------------------------------- + { + FileAttributes attr; + result r = File::GetAttributes(fontPath, attr); + if (IsFailed(r)) + { + return E_FILE_NOT_FOUND; + } + else if (attr.IsDirectory()) + { + return E_UNSUPPORTED_FORMAT; + } + } + + //-------------------------------------------------------------------------- + // step 1 + // + // if we already have specified resoruce, + // return it with increasing reference count + //-------------------------------------------------------------------------- + rtn = __SearchFont(fontPath, sharedFont); + + if (rtn) + { + out = sharedFont; + + return E_SUCCESS; + } + + //-------------------------------------------------------------------------- + // step 2 + // + // create new font + //-------------------------------------------------------------------------- + { +#ifdef USE_MMAP + ByteBuffer* pBuffer = StringUtil::StringToUtf8N(fontPath); + if (pBuffer == null) + { + return false; + } + std::auto_ptr pathString(pBuffer); + + rtn = __CreateFont(_DEFAULT_FONT_ENGINE, (char*)pathString->GetPointer(), _DEFAULT_FONT_FACE, &pFont); +#else + int fileLength = 0; + int readLength = 0; + File file; + + result r = file.Construct(fontPath, L"rb"); + SysTryReturnResult(NID_GRP, r == E_SUCCESS, E_SYSTEM, "Failed to open file"); + + r = file.Seek(FILESEEKPOSITION_END, 0); + SysTryReturnResult(NID_GRP, r == E_SUCCESS, E_SYSTEM, "Failed to seek file"); + + fileLength = file.Tell(); + SysTryReturnResult(NID_GRP, fileLength > 0, E_SYSTEM, "The length of the file is not positive"); + + r = file.Seek(FILESEEKPOSITION_BEGIN, 0); + SysTryReturnResult(NID_GRP, r == E_SUCCESS, E_SYSTEM, "Failed to seek file"); + + std::unique_ptr buffer(new (std::nothrow) unsigned char[fileLength]); + SysTryReturnResult(NID_GRP, buffer, E_OUT_OF_MEMORY, "Failed to create font instance"); + + readLength = file.Read(buffer.get(), fileLength); + SysTryReturnResult(NID_GRP, readLength == fileLength, E_SYSTEM, "Failed to read file"); + + // create font + rtn = __CreateFont(_DEFAULT_FONT_ENGINE, buffer.get(), fileLength, _DEFAULT_FONT_FACE, &pFont); +#endif + std::auto_ptr<_IFont> autoPtrFont(pFont); + SysTryReturnResult(NID_GRP, rtn && autoPtrFont.get() != null, E_UNSUPPORTED_FORMAT, "Failed to create _IFont instance"); + + // make shared resource + sharedFont.reset(autoPtrFont.release()); + + _IFont::Attrib fontAttrib; + rtn = pFont->GetAttrib(fontAttrib); + SysTryReturnResult(NID_GRP, rtn, E_SYSTEM, "Failed to get font attribute"); + + fontAttrib.size = size; + fontAttrib.style = 0; + fontAttrib.style |= (style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; + fontAttrib.style |= (style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; + + rtn = pFont->SetAttrib(fontAttrib); + SysTryReturnResult(NID_GRP, rtn, E_SYSTEM, "Failed to set font attribute"); + } + + //-------------------------------------------------------------------------- + // step 3 + // + // add newly created font resource to rsrc manager + //-------------------------------------------------------------------------- + rtn = __AddFont(fontPath, sharedFont); + SysTryReturnResult(NID_GRP, rtn, E_SYSTEM, "Failed to add font resource into the shared container."); + + // set + out = sharedFont; + + //-------------------------------------------------------------------------- + // step 4 + // + // remove unused font + //-------------------------------------------------------------------------- + __RemoveUnusedFont(); + + return E_SUCCESS; +} + +result +_FontRsrcManager::GetTempFont(const Tizen::Base::String& fontPath, int style, int size, SharedFontResource& out) +{ + SharedFontResource sharedFont; + _IFont* pFont = null; + //_FontCache* pFontCache = null; + bool rtn = false; + //unsigned char* pBuffer = null; + + //-------------------------------------------------------------------------- + // validation check of input param + // + // in case input fontPath is indicating folder, + // we should return 'E_UNSUPPORTED_FORMAT' as bads 2.0 did. + //-------------------------------------------------------------------------- + { + FileAttributes attr; + result r = File::GetAttributes(fontPath, attr); + if (IsFailed(r)) + { + return E_FILE_NOT_FOUND; + } + else if (attr.IsDirectory()) + { + return E_UNSUPPORTED_FORMAT; + } + } + + //-------------------------------------------------------------------------- + // step 1 + // + // if we already have specified resoruce, + // return it with increasing reference count + //-------------------------------------------------------------------------- + rtn = __SearchFont(fontPath, sharedFont); + + if (rtn) + { + out = sharedFont; + + return E_SUCCESS; + } + + //-------------------------------------------------------------------------- + // step 2 + // + // create new font + //-------------------------------------------------------------------------- + { + ByteBuffer* pBuffer = StringUtil::StringToUtf8N(fontPath); + if (pBuffer == null) + { + return false; + } + std::auto_ptr pathString(pBuffer); + + rtn = __CreateFont(_DEFAULT_FONT_ENGINE, (char*)pathString->GetPointer(), _DEFAULT_FONT_FACE, &pFont); + + std::auto_ptr<_IFont> autoPtrFont(pFont); + SysTryReturnResult(NID_GRP, rtn && autoPtrFont.get() != null, E_UNSUPPORTED_FORMAT, "Failed to create _IFont instance"); + + // make shared resource + sharedFont.reset(autoPtrFont.release()); + + _IFont::Attrib fontAttrib; + rtn = pFont->GetAttrib(fontAttrib); + SysTryReturnResult(NID_GRP, rtn, E_SYSTEM, "Failed to get font attribute"); + + fontAttrib.size = size; + fontAttrib.style = 0; + fontAttrib.style |= (style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; + fontAttrib.style |= (style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; + + rtn = pFont->SetAttrib(fontAttrib); + SysTryReturnResult(NID_GRP, rtn, E_SYSTEM, "Failed to set font attribute"); + } + + // set + out = sharedFont; + + return E_SUCCESS; +} + +result +_FontRsrcManager::AddFont(const Tizen::Base::String& fontPath, SharedFontResource& out) +{ + bool rtn = false; + + rtn = __AddFont(fontPath, out); + SysTryReturnResult(NID_GRP, rtn, E_SYSTEM, "Failed to add font resource into the shared container."); + + return E_SUCCESS; +} + + +bool +_FontRsrcManager::SearchFont(const Tizen::Base::String& fontName) +{ + SharedFontResource sharedFont; + + return (__SearchFont(fontName, sharedFont) == true); +} + +result +_FontRsrcManager::GetFont(const byte* pFontData, int fontDataSize, int style, int size, SharedFontResource& out) +{ + const char* pUserMemoryFont = "UserMemoryFont"; + SharedFontResource sharedFont; + _IFont* pFont = null; + + //-------------------------------------------------------------------------- + // step 1 + // + // create new font with user resource. + //-------------------------------------------------------------------------- + bool rtn = __CreateFont(_DEFAULT_FONT_ENGINE, pFontData, fontDataSize, _DEFAULT_FONT_FACE, &pFont); + std::auto_ptr<_IFont> autoPtrFont(pFont); + SysTryReturnResult(NID_GRP, rtn && autoPtrFont.get() != null, E_UNSUPPORTED_FORMAT, "Failed to create _IFont"); + + // make shared resource + sharedFont.reset(autoPtrFont.release()); + + _IFont::Attrib fontAttrib; + rtn = pFont->GetAttrib(fontAttrib); + SysTryReturnResult(NID_GRP, rtn, E_SYSTEM, "Failed to get font attribute"); + + fontAttrib.size = size; + fontAttrib.style = 0; + fontAttrib.style |= (style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; + fontAttrib.style |= (style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; + + rtn = pFont->SetAttrib(fontAttrib); + SysTryReturnResult(NID_GRP, rtn, E_SYSTEM, "Failed to set font attribute"); + + //-------------------------------------------------------------------------- + // step 2 + // + // add newly created font resource to rsrc manager + //-------------------------------------------------------------------------- + static long long idx = 0; + String fontName(pUserMemoryFont); + fontName.Append(idx++); + rtn = __AddFont(fontName, sharedFont); + SysTryReturnResult(NID_GRP, rtn, E_SYSTEM, "Failed to add font resrouce into the shared container."); + + // set + out = sharedFont; + + //-------------------------------------------------------------------------- + // step 3 + // + // remove unused font + //-------------------------------------------------------------------------- + __RemoveUnusedFont(); + + return E_SUCCESS; +} + +result +_FontRsrcManager::GetFont(int style, int size, SharedFontResource& out) +{ + SharedFontResource sharedFont; + bool isBold = (style & FONT_STYLE_BOLD) ? true : false; + + String systemFontName = isBold ? _DEFAULT_SYSTEM_BOLD_FONT : _DEFAULT_SYSTEM_FONT; + + _IFont* pFont = null; + bool rtn = false; + + //-------------------------------------------------------------------------- + // step 1 + // + // if we already have specified resoruce, + // return it with increasing reference count + //-------------------------------------------------------------------------- + rtn = __SearchFont(systemFontName, sharedFont); + + if (rtn) + { + out = sharedFont; + + return E_SUCCESS; + } + + //-------------------------------------------------------------------------- + // step 2 + // + // create new font with default font resource. + //-------------------------------------------------------------------------- + + isBold ? __defaultSystemBoldFontPath.Clear() : __defaultSystemFontPath.Clear(); + + const String& defaultSystemFontPath = __GetDefaultSystemFontPath(isBold); + SysTryReturnResult(NID_GRP, defaultSystemFontPath.IsEmpty() == false, E_SYSTEM, "Failed to get default system font path"); + + { +#ifdef USE_MMAP + ByteBuffer* pBuffer = StringUtil::StringToUtf8N(defaultSystemFontPath); + if (pBuffer == null) + { + return false; + } + std::auto_ptr pathString(pBuffer); + + rtn = __CreateFont(_DEFAULT_FONT_ENGINE, (char*)pathString->GetPointer(), _DEFAULT_FONT_FACE, &pFont); +#else + int fileLength = 0; + File file; + + result r = file.Construct(defaultSystemFontPath, L"rb"); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to open file", GetErrorMessage(r)); + + r = file.Seek(FILESEEKPOSITION_END, 0); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to seek file", GetErrorMessage(r)); + + fileLength = file.Tell(); + SysTryReturn(NID_GRP, fileLength > 0, r, r, "[%s] The length of the file is not positive", GetErrorMessage(r)); + + r = file.Seek(FILESEEKPOSITION_BEGIN, 0); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to seek file", GetErrorMessage(r)); + + std::unique_ptr autoPtrBuffer(new (std::nothrow) unsigned char[fileLength]); + SysTryReturn(NID_GRP, autoPtrBuffer, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create buffer of the file length"); + + file.Read(autoPtrBuffer.get(), fileLength); + + rtn = __CreateFont(_DEFAULT_FONT_ENGINE, autoPtrBuffer.get(), fileLength, _DEFAULT_FONT_FACE, &pFont); +#endif + std::auto_ptr<_IFont> autoPtrFont(pFont); + SysTryReturnResult(NID_GRP, rtn && autoPtrFont.get() != null, E_UNSUPPORTED_FORMAT, "Failed to create _IFont instance"); + + // make shared resource + sharedFont.reset(autoPtrFont.release()); + + _IFont::Attrib fontAttrib; + rtn = pFont->GetAttrib(fontAttrib); + SysTryReturnResult(NID_GRP, rtn, E_SYSTEM, "Failed to get font attribute"); + + fontAttrib.size = size; + fontAttrib.style = 0; + fontAttrib.style |= (style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; + fontAttrib.style |= (style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; + + rtn = pFont->SetAttrib(fontAttrib); + SysTryReturnResult(NID_GRP, rtn, E_SYSTEM, "Failed to set font attribute"); + } + + //-------------------------------------------------------------------------- + // step 3 + // + // add newly created font resource to rsrc manager + //-------------------------------------------------------------------------- + rtn = __AddFont(systemFontName, sharedFont); + SysTryReturnResult(NID_GRP, rtn, E_SYSTEM, "Failed to add font resource into the shared container"); + + // set + out = sharedFont; + + //-------------------------------------------------------------------------- + // step 4 + // + // remove unused font + //-------------------------------------------------------------------------- + __RemoveUnusedFont(); + + return E_SUCCESS; +} + +result +_FontRsrcManager::GetSystemFont(const Tizen::Base::String& fontName, int style, int size, SharedFontResource& out) +{ + FcPattern *pFontPattern = null; + FcFontSet *pFontSet = null; + FcResult res = FcResultNoMatch; + FcChar8* pPath = null; + const char* fcStyle = (style & FONT_STYLE_BOLD) ? "Bold" : "Regular"; + result r = E_SYSTEM; + + ByteBuffer* pBuffer = StringUtil::StringToUtf8N(fontName); + if (pBuffer == null) + { + return E_SYSTEM; + } + std::auto_ptr utfString(pBuffer); + + FcBool rtn = FcInitReinitialize(); + SysTryCatch(NID_GRP, rtn != FcFalse, , r, "[E_SYSTEM] Failed to init fontconfig"); + + pFontPattern = FcPatternBuild(NULL, FC_STYLE, FcTypeString, (FcChar8*)fcStyle, NULL); + SysTryCatch(NID_GRP, pFontPattern, , r, "[E_SYSTEM] Failed to FcPatternBuild()"); + + FcPatternAddString(pFontPattern, FC_FAMILY, (FcChar8*)utfString->GetPointer()); + FcConfigSubstitute(NULL, pFontPattern, FcMatchPattern); + FcDefaultSubstitute(pFontPattern); + + pFontSet = FcFontSort(NULL, pFontPattern, FcTrue, NULL, &res); + SysTryCatch(NID_GRP, pFontSet, , r, "[E_SYSTEM] Failed to FcFontSort()"); + + res = FcPatternGetString(pFontSet->fonts[0], FC_FILE, 0, &pPath); + SysTryCatch(NID_GRP, res == FcResultMatch, , r, "[E_SYSTEM] Failed to get path of system font"); + + r = this->GetFont(String((char*)pPath), style, size, out); + SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Failed to get font", GetErrorMessage(r)); + + // destroy + FcPatternDestroy(pFontPattern); + FcFontSetDestroy(pFontSet); + //FcFini(); + + return E_SUCCESS; + +CATCH: + if (pFontSet) + { + FcFontSetDestroy(pFontSet); + } + + if (pFontPattern) + { + FcPatternDestroy(pFontPattern); + } + + //FcFini(); + + return r; +} + +void +_FontRsrcManager::__InitFontRsrcManager(void) +{ + static _FontRsrcManager instance; + __pTheInstance = &instance; +} + +_FontRsrcManager& +_FontRsrcManager::GetInstance(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (!__pTheInstance) + { + pthread_once(&once_block, __InitFontRsrcManager); + } + + return (*__pTheInstance); +} + +bool +_FontRsrcManager::__CreateFont(int fontEngine, const void* pBuffer, long bufSize, long face, _IFont** ppOut) +{ + // check input param + SysTryReturn(NID_GRP, ppOut, false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid out param is given"); + + std::auto_ptr<_IFont> autoPtrFont; + + switch (fontEngine) + { + case 0: + autoPtrFont.reset(new (std::nothrow) _FontFt2); + break; + + default: + autoPtrFont.reset(new (std::nothrow) _FontNull); + break; + } + + SysTryReturn(NID_GRP, autoPtrFont.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory"); + + bool rtn = autoPtrFont->Create(pBuffer, bufSize, face); + SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to create font resource"); + + // set out param + *ppOut = autoPtrFont.release(); + + return true; +} + +bool +_FontRsrcManager::__CreateFont(int fontEngine, const char* filePath, const long face, _IFont** ppOut) +{ + // check input param + SysTryReturn(NID_GRP, ppOut, false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid out param is given"); + + std::auto_ptr<_IFont> autoPtrFont; + + switch (fontEngine) + { + case 0: + autoPtrFont.reset(new (std::nothrow) _FontFt2); + break; + + default: + autoPtrFont.reset(new (std::nothrow) _FontNull); + break; + } + + SysTryReturn(NID_GRP, autoPtrFont.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory"); + + bool rtn = autoPtrFont->Create(filePath, face); + SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to create font resource"); + + // set out param + *ppOut = autoPtrFont.release(); + + return true; +} + +bool +_FontRsrcManager::__CreateStaticFont(int fontEngine, const void* pBuffer, long bufSize, long face, _IFont** ppOut) +{ + // check input param + SysTryReturn(NID_GRP, ppOut, false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid out param is given"); + + std::auto_ptr<_IFont> autoPtrFont; + + switch (fontEngine) + { + case 0: + autoPtrFont.reset(new (std::nothrow) _FontFt2); + break; + + default: + autoPtrFont.reset(new (std::nothrow) _FontNull); + break; + } + + SysTryReturn(NID_GRP, autoPtrFont.get() != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory"); + + bool rtn = autoPtrFont->CreateStatic(pBuffer, bufSize, face); + SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to create font resource"); + + // set out param + *ppOut = autoPtrFont.release(); + + return true; +} + +bool +_FontRsrcManager::__SearchFont(const String& fontPath, SharedFontResource& out) const +{ + // check input param + SysTryReturn(NID_GRP, out.get() == null, false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid out param is given"); + + return (__fontRsrcMap.GetValue(const_cast (fontPath), out) == E_SUCCESS); +} + +bool +_FontRsrcManager::__AddFont(const String& key, const SharedFontResource& font) +{ + // check input param + SysTryReturn(NID_GRP, font.get() != null, false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input param is given"); + + result r = __fontRsrcMap.Add(key, font); + SysTryReturn(NID_GRP, r == E_SUCCESS, false, false, "[%s] Failed to add font into resource pool", GetErrorMessage(r)); + + return true; +} + +void +_FontRsrcManager::__RemoveUnusedFont(void) +{ + ArrayListT keys; + String systemFontName(_DEFAULT_SYSTEM_FONT); + String systemBoldFontName(_DEFAULT_SYSTEM_BOLD_FONT); + + // find out unused font + { + std::auto_ptr > enumerator(__fontRsrcMap.GetMapEnumeratorN()); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_GRP, enumerator.get() != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + while (enumerator->MoveNext() == E_SUCCESS) + { + SharedFontResource font; + r = enumerator->GetValue(font); + + if (r == E_SUCCESS && font.use_count() == 2) + { + String key; + r = enumerator->GetKey(key); + + if (r == E_SUCCESS && (key != systemFontName && key != systemBoldFontName)) + { + keys.Add(key); + } + } + } + } + + // remove + if (keys.GetCount() > 0) + { + std::auto_ptr > enumerator(keys.GetEnumeratorN()); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_GRP, enumerator.get() != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + while (enumerator->MoveNext() == E_SUCCESS) + { + String key; + r = enumerator->GetCurrent(key); + + if (r == E_SUCCESS) + { + __fontRsrcMap.Remove(key); + } + } + } + + return; +} + +bool +_FontRsrcManager::__ReloadFont(String fontName, bool isBold) +{ + SharedFontResource sharedFont; + String systemFontName(fontName); + + _IFont* pFont = null; + bool rtn = false; + + // Check if there is default system font in font resource manager + // If there isn't default system font, we can't reload font resource + rtn = __SearchFont(systemFontName, sharedFont); + SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to search default system font"); + + // Get default system font interface instance + pFont = sharedFont.get(); + + // Reload system font resource in font interface + { +#ifdef USE_MMAP + isBold ? __defaultSystemBoldFontPath.Clear() : __defaultSystemFontPath.Clear(); + const String& fontPath = __GetDefaultSystemFontPath(isBold); + + ByteBuffer* pBuffer = StringUtil::StringToUtf8N(fontPath); + if (pBuffer == null) + { + return false; + } + std::auto_ptr pathString(pBuffer); + + rtn = pFont->Reload((char*)pathString->GetPointer(), _DEFAULT_FONT_FACE); + SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to reload font"); +#else + int fileLength = 0; + File file; + + isBold ? __defaultSystemBoldFontPath.Clear() : __defaultSystemFontPath.Clear(); + + result r = file.Construct(__GetDefaultSystemFontPath(isBold), L"rb"); + SysTryReturn(NID_GRP, r == E_SUCCESS, false, r, "[%s] Failed to open file", GetErrorMessage(r)); + + r = file.Seek(FILESEEKPOSITION_END, 0); + SysTryReturn(NID_GRP, r == E_SUCCESS, false, r, "[%s] Failed to seek file", GetErrorMessage(r)); + + fileLength = file.Tell(); + SysTryReturn(NID_GRP, fileLength > 0, false, r, "[%s] The length of the file is not positive", GetErrorMessage(r)); + + r = file.Seek(FILESEEKPOSITION_BEGIN, 0); + SysTryReturn(NID_GRP, r == E_SUCCESS, false, r, "[%s] Failed to seek file", GetErrorMessage(r)); + + std::unique_ptr autoPtrBuffer(new (std::nothrow) unsigned char[fileLength]); + SysTryReturn(NID_GRP, autoPtrBuffer, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create buffer of the file length"); + + file.Read(autoPtrBuffer.get(), fileLength); + rtn = pFont->Reload(autoPtrBuffer.get(), fileLength, _DEFAULT_FONT_FACE); + SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to reload font"); +#endif + + pFont->CleanCache(); + } + + return true; +} + +bool +_FontRsrcManager::ReloadDefaultSystemFont(void) +{ + String systemFontName; + + systemFontName = _DEFAULT_SYSTEM_FONT; + __ReloadFont(systemFontName, false); + + systemFontName = _DEFAULT_SYSTEM_BOLD_FONT; + __ReloadFont(systemFontName, true); + + return true; +} + +_FontMemoryManager& +_FontRsrcManager::GetMemoryManager(void) +{ + return *__pFontMemoryManager; +} + + +_Font& +_FontRsrcManager::GetDefaultSystemFont(void) +{ + if (__pDefaultSystemFont == null) + { + std::auto_ptr<_Font> font(new (std::nothrow) _Font); + + if (font.get()) + { + result r = font->Construct(FONT_STYLE_PLAIN, _SYSTEM_DEFAULT_FONT_SIZE); + + if (r == E_SUCCESS) + { + __pDefaultSystemFont = font.release(); + } + } + } + + SysAssert(__pDefaultSystemFont != null); + + return *__pDefaultSystemFont; +} + + +long +_FontRsrcManager::__GetMaxFontEngine(void) const +{ + return 1; +} + +String +_FontRsrcManager::__GetFontPath(bool isBold) +{ + String fontPath(L""); + + FcFontSet* pFontSet = null; + FcPattern* pFontPattern = null; + const char* fcStyle = isBold ? "Bold" : "Regular"; + // initialize fontconfig library + FcBool rtn = FcInitReinitialize(); + SysTryCatch(NID_GRP, rtn != FcFalse, , E_SYSTEM, "[E_SYSTEM] Failed to init fontconfig"); + + // create pattern + pFontPattern = FcPatternCreate(); + SysTryCatch(NID_GRP, pFontPattern, , E_SYSTEM, "[E_SYSTEM] Failed to create font pattern"); + + FcPatternAddString(pFontPattern, FC_FAMILY, (FcChar8*)"Tizen"); + FcPatternAddString(pFontPattern, FC_STYLE, (FcChar8*)fcStyle); + FcConfigSubstitute(0, pFontPattern, FcMatchPattern); + FcDefaultSubstitute(pFontPattern); + + // create fontset + pFontSet = FcFontSetCreate(); + SysTryCatch(NID_GRP, pFontSet, , E_SYSTEM, "[E_SYSTEM] Failed to create fontset"); + + { + FcPattern* pMatchedPattern = null; + FcResult result = FcResultNoMatch; + pMatchedPattern = FcFontMatch(NULL, pFontPattern, &result); + + if (/*result == FcResultMatch && */pMatchedPattern) + { + FcFontSetAdd(pFontSet, pMatchedPattern); + } + + // check if we have a system font info + SysTryCatch(NID_GRP, pFontSet->nfont >= 1, , E_SYSTEM, "[E_SYSTEM] Default system count is %d", pFontSet->nfont); + + FcChar8* pPath = null; + result = FcPatternGetString(pFontSet->fonts[0], FC_FILE, 0, &pPath); + SysTryCatch(NID_GRP, result == FcResultMatch, , E_SYSTEM, "[E_SYSTEM] Failed to create fontset"); + fontPath.Clear(); + fontPath.Append(String((char*)pPath)); + } + + // destroy + FcPatternDestroy(pFontPattern); + FcFontSetDestroy(pFontSet); + //FcFini(); + + return fontPath; + +CATCH: + if (pFontSet != null) + { + FcFontSetDestroy(pFontSet); + } + + if (pFontPattern != null) + { + FcPatternDestroy(pFontPattern); + } + + return fontPath; +} + +const String& +_FontRsrcManager::__GetDefaultSystemFontPath(bool isBold) +{ + String& defaultPath = (isBold) ? __defaultSystemBoldFontPath : __defaultSystemFontPath; + + if (!defaultPath.IsEmpty()) + { + return defaultPath; + } + else + { + String path = __GetFontPath(isBold); + + if (isBold) + { + if (path.IsEmpty()) + { + path = __GetFontPath(false); + // [ykahn] Is 'path' always not NULL ? + } + + __defaultSystemBoldFontPath.Clear(); + __defaultSystemBoldFontPath.Append(path); + + return __defaultSystemBoldFontPath; + } + else + { + __defaultSystemFontPath.Clear(); + __defaultSystemFontPath.Append(path); + + return __defaultSystemFontPath; + } + } +} + +bool +_FontRsrcManager::RemoveMemory(unsigned long requestedSize) +{ +#ifdef USE_REMOVE_ALL_CACHE + result r = E_SUCCESS; + std::auto_ptr > enumerator(__fontRsrcMap.GetMapEnumeratorN()); + + while (enumerator->MoveNext() == E_SUCCESS) + { + SharedFontResource fontRsrc; + r = enumerator->GetValue(fontRsrc); + + fontRsrc.get()->CleanCache(); + } + + return true; +#else + unsigned long remainedMemory = 0; + result r = E_SUCCESS; + bool isComplete = false; + + ArrayListT keys; + String systemFontName(_DEFAULT_SYSTEM_FONT); + + std::auto_ptr > enumerator(__fontRsrcMap.GetMapEnumeratorN()); + + while (enumerator->MoveNext() == E_SUCCESS) + { + if (isComplete) + { + break; + } + + String key; + r = enumerator->GetKey(key); + if (r == E_SUCCESS/* && key != systemFontName*/) + { + SharedFontResource fontRsrc; + r = enumerator->GetValue(fontRsrc); + + while (!fontRsrc.get()->second->IsEmpty()) + { + fontRsrc.get()->second->RemoveFirst(); + + remainedMemory = __pFontMemoryManager->GetRemainedMemory(); + + if (remainedMemory > requestedSize) + { + isComplete = true; + break; + } + } + } + } + + return isComplete; +#endif +} + +Tizen::Base::String +_FontRsrcManager::FindAppFontName(const Tizen::Base::String& fontName) +{ + Tizen::Base::String fontPath = L""; + + if (__isAppFontListInitialized) + { + __appFontMap.GetValue(const_cast (fontName), fontPath); + return fontPath; + } + else + { + String dirName; + Directory dir; + DirEnumerator* pDirEnum; + + //dirName = L"/usr/share/app_font"; + dirName = Tizen::App::App::GetInstance()->GetAppResourcePath() + L"font"; + + // Open the directory + if (IsFailed(dir.Construct(dirName))) + { + return fontPath; + } + + // Reads all the directory entries + pDirEnum = dir.ReadN(); + if (!pDirEnum) + { + return fontPath; + } + + // Loops through all the directory entries + while (pDirEnum->MoveNext() == E_SUCCESS) + { + SharedFontResource sharedFont; + String faceName; + String name; + String token; + DirEntry entry = pDirEnum->GetCurrentDirEntry(); + Tizen::Base::Utility::StringTokenizer formatTok(entry.GetName(), "."); + while (formatTok.GetTokenCount()) + { + formatTok.GetNextToken(token); + } + if (entry.IsDirectory() == false) + { + name.Append(dirName); + name.Append(L"/"); + name.Append(entry.GetName()); + + faceName = _Font::GetFaceName(name); + + __appFontMap.Add(faceName, name); + } + } + + delete pDirEnum; + pDirEnum = null; + + __isAppFontListInitialized = true; + + __appFontMap.GetValue(const_cast (fontName), fontPath); + return fontPath; + } +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_FontRsrcManager.h b/src/graphics/FGrp_FontRsrcManager.h new file mode 100644 index 0000000..5e01770 --- /dev/null +++ b/src/graphics/FGrp_FontRsrcManager.h @@ -0,0 +1,105 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontRsrcManager.h + * @brief This is the header file for FGrp_FontRsrcManager class. + * + */ + +#ifndef _FGRP_INTERNAL_FONT_RSRC_MANAGER_H_ +#define _FGRP_INTERNAL_FONT_RSRC_MANAGER_H_ + +#include +#include + +#include +#include +#include + +#include "FGrp_FontMemoryManager.h" +#include "util/FGrp_UtilTemplate.h" + + +namespace Tizen { namespace Graphics +{ + +class _Font; +struct _FontResource; + +class _FontRsrcManager + : public Tizen::Base::Object +{ +public: + typedef std::tr1::shared_ptr<_IFont> SharedFontResource; + + virtual ~_FontRsrcManager(void); + + result GetFont(const Tizen::Base::String& fontPath, int style, int size, SharedFontResource& out); + result GetFont(const byte* pFontData, int fontDataSize, int style, int size, SharedFontResource& out); + result GetFont(int style, int size, SharedFontResource& out); + + result GetSystemFont(const Tizen::Base::String& fontName, int style, int size, SharedFontResource& out); + + result GetTempFont(const Tizen::Base::String& fontPath, int style, int size, SharedFontResource& out); + result AddFont(const Tizen::Base::String& fontPath, SharedFontResource& out); + bool SearchFont(const Tizen::Base::String& fontName); + + bool ReloadDefaultSystemFont(void); + _FontMemoryManager& GetMemoryManager(void); + _Font& GetDefaultSystemFont(void); + bool RemoveMemory(unsigned long requestedSize); + + Tizen::Base::String FindAppFontName(const Tizen::Base::String& fontName); + + static _FontRsrcManager& GetInstance(void); + +private: + _FontRsrcManager(void); + _FontRsrcManager(const _FontRsrcManager& obj); + _FontRsrcManager& operator =(const _FontRsrcManager& rhs); + + bool __CreateFont(int fontEngine, const void* pBuffer, long bufSize, long face, _IFont** pOut); + bool __CreateFont(int fontEngine, const char* filePath, long face, _IFont** pOut); + bool __CreateStaticFont(int fontEngine, const void* pBuffer, long bufSize, long face, _IFont** pOut); + bool __SearchFont(const Tizen::Base::String& fontName, SharedFontResource& out) const; + bool __AddFont(const Tizen::Base::String& key, const SharedFontResource& font); + void __RemoveUnusedFont(void); + long __GetMaxFontEngine(void) const; + const Tizen::Base::String& __GetDefaultSystemFontPath(bool isBold); + Tizen::Base::String __GetFontPath(bool isBold); + bool __ReloadFont(Tizen::Base::String fontName, bool isBold); + + static void __InitFontRsrcManager(void); + +private: + Tizen::Base::Collection::HashMapT __fontRsrcMap; + Tizen::Base::Collection::HashMapT __appFontMap; + + Tizen::Base::String __defaultSystemFontPath; + Tizen::Base::String __defaultSystemBoldFontPath; + + _FontMemoryManager* __pFontMemoryManager; + _Font* __pDefaultSystemFont; + + static _FontRsrcManager* __pTheInstance; + bool __isAppFontListInitialized; +}; // _FontRsrcManager + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_FONT_RSRC_MANAGER_H_ diff --git a/src/graphics/FGrp_FontUtil.h b/src/graphics/FGrp_FontUtil.h new file mode 100644 index 0000000..cada4bd --- /dev/null +++ b/src/graphics/FGrp_FontUtil.h @@ -0,0 +1,62 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontUtil.h + * @brief This is the header file for _FontUtil class. + * + */ + +#ifndef _FGRP_INTERNAL_FONT_UTIL_H_ +#define _FGRP_INTERNAL_FONT_UTIL_H_ + + +#include + +#include "FGrp_FontImpl.h" + + +namespace Tizen { namespace Graphics +{ + +class _FontImplHack + : public _FontImpl +{ +public: + _Font* GetFontEx(void) const + { + return (this && this->_pNativeFont) ? this->_pNativeFont : 0; + } +}; + +inline _Font* +GetFontEx(const Tizen::Graphics::_FontImpl& font) +{ + const _FontImplHack* pFontImplHack = static_cast (&font); + return (pFontImplHack) ? pFontImplHack->GetFontEx() : null; +} + +inline _Font* +GetFontEx(const Tizen::Graphics::Font& font) +{ + const _FontImpl* pFontImpl = _FontImpl::GetInstance(font); + return (pFontImpl) ? GetFontEx(*pFontImpl) : null; +} + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_FONT_UTIL_H_ diff --git a/src/graphics/FGrp_IFont.h b/src/graphics/FGrp_IFont.h new file mode 100644 index 0000000..6d36556 --- /dev/null +++ b/src/graphics/FGrp_IFont.h @@ -0,0 +1,188 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_IFont.h + * @brief This is the header file for _IFont class. + * + */ + +#ifndef _FGRP_INTERNAL_IFONT_H_ +#define _FGRP_INTERNAL_IFONT_H_ + +#include +#include + +#include + +#include "util/FGrp_UtilType.h" + + +namespace Tizen { namespace Graphics +{ + +class _FontRsrcManager; + +class _IFont +{ +public: + //! Enumerated definition of the font style. + enum Style + { + STYLE_NONE = 0, //!< Basic style. + STYLE_ITALIC = 1, //!< Italic style. + STYLE_BOLD = 2, //!< Bold style. + STYLE_UNDERLINE = 4, //!< Underline style. + STYLE_BACKSLANT = 8 //!< Reverse italic style. + }; + + //! Enumerated definition of the font quality. + enum Quality + { + QUALITY_MONO = 0, //!< Glyph of 1-bit form. + QUALITY_LOW = 1, //!< Low quality of 8-bit form. + QUALITY_MEDIUM = 2, //!< Medium quality of 8-bit form. + QUALITY_HIGH = 3 //!< High quality of 8-bit form. + }; + + //! Enumerated definition of the font capabilities. + enum Capability + { + CAPS_SCALABLE = 0x0001, //!< Support of the scalable font. + CAPS_ANGLE = 0x0002, //!< Support of the angle. + CAPS_X_EXPANSION = 0x0004, //!< Support of the expansion of the font. + CAPS_BOLDWEIGHT = 0x0008, //!< Support of the bold weight of the font. + CAPS_QUALITY_MONO = 0x0010, //!< Support of the white & black font. + CAPS_QUALITY_LOW = 0x0020, //!< Support of the low quality in the gray map font. + CAPS_QUALITY_MEDIUM = 0x0040, //!< Support of the medium quality in the gray map font. + CAPS_QUALITY_HIGH = 0x0080 //!< Support of the high quality in the gray map font. + }; + + //! Attrib structure + struct Attrib + { + long size; //!< Size of the font. (26.6 fixed point unit) + unsigned int style; //!< Style of the font. (_IFont::Style) + int quality; //!< Quality of the font. (_IFont::Quality) + float angle; //!< Angle of the font. + long xExpansion; //!< Expansion of the font. + long boldWeight; //!< Bold weight of the font + }; + + //! GlyphBitmap structure + struct GlyphBitmap + { + long width; //!< Horizontal size of an image buffer. + long height; //!< Vertical size of an image buffer. + long bytesPerLine; //!< The number of bytes to represent one horizontal line in buffer. + unsigned long depth; //!< The number of bits to compose one pixel. + unsigned char* pBitmap; //!< Start address of an image buffer. + }; + + //! Glyph structure + struct Glyph + { + unsigned long id; //!< Internal identifier of the font. + long xOffset; //!< Starting point of displaying the font. + long yOffset; //!< Starting point of displaying the font. + long xAdvance; //!< Distance to move for displaying the next font. + long yAdvance; //!< Distance to move for displaying the next font. + long hasOwnerShip; + GlyphBitmap image; //!< Image information of a glyph. + void* ptrAux; //!< Internal data for each target. + }; + + //! Property structure + struct Property + { + int fontCaps; //!< Flag for the font capability. (_IFont::Capability) + int styleCaps; //!< Flag for the font style capability. (_IFont::Style) + unsigned long minSize; //!< Minimal size of the supportable font. + unsigned long maxSize; //!< Maximal size of the supportable font. + + const char* pEngineName; //!< Name of the font engine. + const char* pFamilyName; //!< Name of the font family. + const char* pStyleName; //!< Name of the font style. + long maxWidth; //!< Maximal width of this font data. + long maxHeight; //!< Maximal height of this font data. + long baseLine; //!< BaseLine of this font data. + long ascender; //!< Ascender of this font data. + long descender; //!< Descender of this font data. + long leading; //!< Leading of this font data. + }; + + virtual ~_IFont(void) {} + + typedef std::tr1::shared_ptr<_IFont> SharedFontResource; + + //! Changes the attribute using fontAttrib. + virtual bool SetAttrib(const Attrib& fontAttrib) = 0; + //! Gets current attribute and store it in fontAttrib. + virtual bool GetAttrib(Attrib& fontAttrib) const = 0; + + //! Gets the value of the interval correctness between two characters. + virtual bool GetKerning(unsigned long ch1, unsigned long ch2, long& xVector, long& yVector) const = 0; + + //! Loads the font glyph data for displaying font. + virtual bool LoadGlyph(unsigned long character, Glyph** pFontGlyphData) = 0; + //! Releases the resource of the font glyph data that is not needed any more. + virtual bool UnloadGlyph(Glyph** pFontGlyphData) = 0; + //! Check if specified glyph is included. + virtual unsigned long CheckGlyph(unsigned long character) = 0; + + //! Gets the support range and the property for this font engine. + virtual bool GetFontProperty(Property& property) const = 0; + + //! Harfbuzz test + virtual bool GetGlyphList(const _Util::String& text, Tizen::Base::Collection::IListT& out, bool isRtl, int script) const = 0; + + //! Gets the font fallback map. + virtual Tizen::Base::Collection::HashMapT* GetFallbackMap(void) = 0; + +protected: + //! Initializes a font instance with the font data on the memory buffer. + virtual bool Create(const void* pBuffer, long bufSize, long face = 0) = 0; + //! Initializes a font instance with the font file. + virtual bool Create(const char* pFilePath, long face = 0) = 0; + //! Initializes a font instance with the font data on the static memory buffer. + virtual bool CreateStatic(const void* pBuffer, long bufSize, long face = 0) = 0; + //! Reloads a font instance with the font data on the memory buffer. + virtual bool Reload(const void* pBuffer, long bufSize, long face = 0) = 0; + //! Reloads a font instance with the font file + virtual bool Reload(const char* filePath, long face = 0) = 0; + //! Destroys the instance. + virtual void Destroy(void) = 0; + //! Finds glyph in the cache + virtual bool FindCache(unsigned long character, int size, int style, Glyph** pOut) = 0; + //! Adds glyph in the cache + virtual bool AddCache(unsigned long character, int size, int style, Glyph* pGlyph) = 0; + //! Clean cache + virtual bool CleanCache(void) = 0; + +private: + friend class _FontRsrcManager; +}; // _IFont + +struct _FontResource +{ + std::auto_ptr<_IFont> first; + //std::auto_ptr<_FontCache> second; +}; + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_IFONT_H_ diff --git a/src/graphics/FGrp_NonScale.cpp b/src/graphics/FGrp_NonScale.cpp new file mode 100644 index 0000000..206cc59 --- /dev/null +++ b/src/graphics/FGrp_NonScale.cpp @@ -0,0 +1,200 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_NonScale.cpp + * @brief This is the header file for internal util class. + * + */ + +#include +#include + +#include + +#include "FGrp_NonScale.h" +#include "FGrp_BitmapImpl.h" +#include "FGrp_BitmapCoordHolder.h" +#include "FGrp_BitmapUtil.h" +#include "FGrp_Bitmap.h" +#include "util/FGrp_UtilTemplate.h" + + +namespace // unnamed +{ + +Tizen::Graphics::_BitmapCoordHolder* +_GetBitmapCoordHolder(const Tizen::Graphics::_BitmapImpl& bitmap) +{ + class BitmapHacked + : public Tizen::Graphics::_BitmapImpl + { +public: + inline Tizen::Graphics::_BitmapCoordHolder* GetBitmapCoordHolder(void) + { + return this->_sharedItem->coordHolder.get(); + } + }; + + return ((BitmapHacked*) &bitmap)->GetBitmapCoordHolder(); +} + +} + +namespace Tizen { namespace Graphics +{ + +_BitmapImpl* +_NonScale::CreateBitmapN(const Tizen::Base::ByteBuffer& buffer, const Dimension& rq_dim, BitmapPixelFormat pixelFormat) +{ + Dimension vc_dim = _ResUtil::ConvertToVirCoord(rq_dim); + + return _NonScale::CreateBitmapN(buffer, rq_dim, pixelFormat, vc_dim); +} + +_BitmapImpl* +_NonScale::CreateBitmapN(const Tizen::Base::ByteBuffer& buffer, const Dimension& rq_dim, BitmapPixelFormat pixelFormat, + const Dimension& logicalSize) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_GRP + , rq_dim.width > 0 && rq_dim.height > 0 + , null + , E_INVALID_ARG + , "[E_INVALID_ARG] The reqired size(%d, %d) is invalid.", rq_dim.width, rq_dim.height); + + SysTryReturn(NID_GRP + , BITMAP_PIXEL_FORMAT_MIN < pixelFormat && pixelFormat < BITMAP_PIXEL_FORMAT_MAX + , null + , E_INVALID_ARG + , "[E_INVALID_ARG] The given pixel format(%d) is invalid.", pixelFormat); + + { + int bytePerPixel = 0; + + switch (pixelFormat) + { + case Tizen::Graphics::BITMAP_PIXEL_FORMAT_RGB565: + bytePerPixel = 2; + break; + case Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888: + case Tizen::Graphics::BITMAP_PIXEL_FORMAT_R8G8B8A8: + bytePerPixel = 4; + break; + default: + SysLogException(NID_GRP, E_INVALID_ARG, "The given pixel format(%d) is not supported.", pixelFormat); + return null; + } + + SysTryReturn(NID_GRP + , bytePerPixel > 0 + , null + , E_UNSUPPORTED_FORMAT + , "[E_UNSUPPORTED_FORMAT] The given bytes-per-pixel(%d) is not supported.", bytePerPixel); + + int numOfBytes = buffer.GetLimit(); + int expectedBufferSize = rq_dim.width * rq_dim.height * bytePerPixel; + + SysTryReturn(NID_GRP + , expectedBufferSize <= numOfBytes + , null + , E_INVALID_ARG + , "[E_INVALID_ARG] The buffer size is too small. (expected: %d, actual: %d)", expectedBufferSize, numOfBytes); + } + + std::auto_ptr <_BitmapImpl> bitmap(new (std::nothrow) _BitmapImpl); + + SysTryReturn(NID_GRP + , bitmap.get() + , null + , E_OUT_OF_MEMORY + , "[E_OUT_OF_MEMORY] _BitmapImpl is not allocated."); + + _Bitmap* pBitmapEx = GetBitmapEx(*bitmap.get()); + + SysTryReturn(NID_GRP + , pBitmapEx + , null + , E_OUT_OF_MEMORY + , "[E_OUT_OF_MEMORY] _Bitmap is not allocated."); + + if (_ResUtil::NeedToConvertCoord()) + { + r = pBitmapEx->Construct(buffer, rq_dim, pixelFormat); + + SysTryReturn(NID_GRP + , !IsFailed(r) + , null + , r + , "[%s] _Bitmap::Construct() failed.", GetErrorMessage(r)); + + Dimension pc_dim = rq_dim; + Dimension vc_dim = logicalSize; + + _ResUtil::Rect vc_rect(0, 0, vc_dim.width, vc_dim.height); + _ResUtil::Rect pc_rect(0, 0, pc_dim.width, pc_dim.height); + + _BitmapCoordHolder* pBitmapCoordHolder = _GetBitmapCoordHolder(*bitmap.get()); + + if (pBitmapCoordHolder) + { + pBitmapCoordHolder->bitmapSize.required = vc_rect; + pBitmapCoordHolder->bitmapSize.phyCoord = pc_rect; + pBitmapCoordHolder->bitmapSize.virCoord = vc_rect; + } + } + else + { + r = pBitmapEx->Construct(buffer, rq_dim, pixelFormat); + + SysTryReturn(NID_GRP + , !IsFailed(r) + , null + , r + , "[%s] _Bitmap::Construct() failed.", GetErrorMessage(r)); + } + + return bitmap.release(); +} + +_BitmapImpl* +_NonScale::CreateBitmapN(const Dimension& rq_dim, BitmapPixelFormat pixelFormat) +{ + std::auto_ptr <_BitmapImpl> bitmap(new (std::nothrow) _BitmapImpl); + + SysTryReturn(NID_GRP + , bitmap.get() + , null + , E_OUT_OF_MEMORY + , "[E_OUT_OF_MEMORY] _BitmapImpl::Construct() failed."); + + Dimension pc_dim = rq_dim; + Dimension vc_dim = _ResUtil::ConvertToVirCoord(pc_dim); + + result r = bitmap->Construct(vc_dim, pixelFormat); + + SysTryReturn(NID_GRP + , !IsFailed(r) + , null + , r + , "[%s] _Bitmap::Construct() failed.", GetErrorMessage(r)); + + return bitmap.release(); +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_ResUtil.h b/src/graphics/FGrp_ResUtil.h new file mode 100644 index 0000000..f83f677 --- /dev/null +++ b/src/graphics/FGrp_ResUtil.h @@ -0,0 +1,1335 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_ResUtil.h + * @brief This is the header file for internal _ResUtil namespace. + * + */ + +#ifndef _FGRP_INTERNAL_RES_UTIL_H_ +#define _FGRP_INTERNAL_RES_UTIL_H_ + +#include + +#include +#include +#include + +#include "util/FGrp_UtilType.h" + + +#if 0 +#include "FGrp_CoordSystem.h" +//////////////////////////////////////////////////////////////////////////////// +// Coordinate conversion + +namespace Tizen { namespace Graphics +{ + +namespace _ResUtil +{ +struct Rect +{ + int x, y, w, h; + + Rect() + : x(0) + , y(0) + , w(0) + , h(0) + { + } + + Rect(int _x, int _y, int _w, int _h) + : x(_x) + , y(_y) + , w(_w) + , h(_h) + { + } +}; + +struct Pos +{ + int x, y; + + Pos() + : x(0) + , y(0) + { + } + + Pos(int _x, int _y) + : x(_x) + , y(_y) + { + } +}; + +struct Size +{ + int w, h; + + Size() + : w(0) + , h(0) + { + } + + Size(int _w, int _h) + : w(_w) + , h(_h) + { + } +}; + +// base template +template +struct ResConv1d +{ + inline static int ToVirCoord(int phy); + inline static int ToPhyCoord(int vir); + inline static int ToPhyCoord4Size(int vir); +}; + +// 2D base template +template +struct ResConv2d +{ + inline static int ToVirCoordX(int phyX) + { + return ResConv1d ::ToVirCoord(phyX); + } + + inline static int ToVirCoordY(int phyY) + { + return ResConv1d ::ToVirCoord(phyY); + } + + inline static int ToPhyCoordX(int virX) + { + return ResConv1d ::ToPhyCoord(virX); + } + + inline static int ToPhyCoordY(int virY) + { + return ResConv1d ::ToPhyCoord(virY); + } + + inline static int ToPhyCoord4Size(int vir) + { + return ResConv1d ::ToPhyCoord4Size(vir); + } +}; + +///////////////////// + +enum ResType +{ + RES_WVGA, + RES_WQVGA, + RES_HVGA, + RES_WVGA_COMPAT, + RES_QHD +}; + +template +struct ResTraits +{ +}; + +template +struct ResConv +{ + typedef ResConv2d ::ResWidth, ResTraits ::ResHeight, ResTraits ::ResWidth, + ResTraits ::ResHeight> CurrentResConv; + + template + inline static T ToPhyCoord(const T& sour) + { + return CurrentResConv::ToPhyCoordY(sour); + } + + template + inline static T ToVirCoord(const T& sour) + { + return CurrentResConv::ToVirCoordY(sour); + } + + inline static int ToPhyCoordSize(int sour) + { + return CurrentResConv::ToPhyCoord4Size(sour); + } + + inline static int ToPhyCoordX(int sour) + { + return CurrentResConv::ToPhyCoordX(sour); + } + + inline static int ToPhyCoordY(int sour) + { + return CurrentResConv::ToPhyCoordY(sour); + } + + inline static int ToPhyCoordW(int sour) + { + return CurrentResConv::ToPhyCoordX(sour); + } + + inline static int ToPhyCoordH(int sour) + { + return CurrentResConv::ToPhyCoordY(sour); + } + + inline static int ToVirCoordX(int sour) + { + return CurrentResConv::ToVirCoordX(sour); + } + + inline static int ToVirCoordY(int sour) + { + return CurrentResConv::ToVirCoordY(sour); + } + + inline static int ToVirCoordW(int sour) + { + return CurrentResConv::ToVirCoordX(sour); + } + + inline static int ToVirCoordH(int sour) + { + return CurrentResConv::ToVirCoordY(sour); + } + + inline static Rect ToPhyCoord(const Rect& sour) + { + int destX = CurrentResConv::ToPhyCoordX(sour.x); + int destY = CurrentResConv::ToPhyCoordY(sour.y); + + return Rect + ( + destX, + destY, + CurrentResConv::ToPhyCoordX(sour.x + sour.w) - destX, + CurrentResConv::ToPhyCoordY(sour.y + sour.h) - destY + ); + } + + inline static Pos ToPhyCoord(const Pos& sour) + { + return Pos + ( + CurrentResConv::ToPhyCoordX(sour.x), + CurrentResConv::ToPhyCoordY(sour.y) + ); + } + + inline static Size ToPhyCoord(const Size& sour) + { + return Size + ( + CurrentResConv::ToPhyCoordX(sour.w), + CurrentResConv::ToPhyCoordY(sour.h) + ); + } + + inline static Tizen::Graphics::Rectangle ToPhyCoord(const Tizen::Graphics::Rectangle& sour) + { + Tizen::Graphics::Rectangle dest; + + dest.x = CurrentResConv::ToPhyCoordX(sour.x); + dest.y = CurrentResConv::ToPhyCoordY(sour.y); + ; + dest.width = CurrentResConv::ToPhyCoordX(sour.x + sour.width) - dest.x; + dest.height = CurrentResConv::ToPhyCoordY(sour.y + sour.height) - dest.y; + + return dest; + } + + inline static Tizen::Graphics::Point ToPhyCoord(const Tizen::Graphics::Point& sour) + { + return Tizen::Graphics::Point(CurrentResConv::ToPhyCoordX(sour.x), CurrentResConv::ToPhyCoordY(sour.y)); + } + + inline static Tizen::Graphics::Dimension ToPhyCoord(const Tizen::Graphics::Dimension& sour) + { + return Tizen::Graphics::Dimension(CurrentResConv::ToPhyCoordX(sour.width), CurrentResConv::ToPhyCoordY(sour.height)); + } + + inline static Rect ToVirCoord(const Rect& sour) + { + int destX = CurrentResConv::ToVirCoordX(sour.x); + int destY = CurrentResConv::ToVirCoordY(sour.y); + + return Rect + ( + destX, + destY, + CurrentResConv::ToVirCoordX(sour.x + sour.w) - destX, + CurrentResConv::ToVirCoordY(sour.y + sour.h) - destY + ); + } + + inline static Pos ToVirCoord(const Pos& sour) + { + return Pos + ( + CurrentResConv::ToVirCoordX(sour.x), + CurrentResConv::ToVirCoordY(sour.y) + ); + } + + inline static Size ToVirCoord(const Size& sour) + { + return Size + ( + CurrentResConv::ToVirCoordX(sour.w), + CurrentResConv::ToVirCoordY(sour.h) + ); + } + + inline static Tizen::Graphics::Rectangle ToVirCoord(const Tizen::Graphics::Rectangle& sour) + { + Rect pc_rect = Rect(sour.x, sour.y, sour.width, sour.height); + Rect vc_rect = ResConv ::ToVirCoord(pc_rect); + + return Tizen::Graphics::Rectangle(vc_rect.x, vc_rect.y, vc_rect.w, vc_rect.h); + } + + inline static Tizen::Graphics::Point ToVirCoord(const Tizen::Graphics::Point& sour) + { + return Tizen::Graphics::Point(CurrentResConv::ToVirCoordX(sour.x), CurrentResConv::ToVirCoordY(sour.y)); + } + + inline static Tizen::Graphics::Dimension ToVirCoord(const Tizen::Graphics::Dimension& sour) + { + return Tizen::Graphics::Dimension(CurrentResConv::ToVirCoordX(sour.width), CurrentResConv::ToVirCoordY(sour.height)); + } +}; + +} // Tizen::Graphics::_ResUtil + +}} // Tizen::Graphics + +//////////////////////////////////////////////////////////////////////////////// +// Specialization + +namespace Tizen { namespace Graphics +{ + +namespace _ResUtil +{ +// (480x800) -> (240x400) +template<> +inline int +ResConv1d <480, 240>::ToVirCoord(int phy) +{ + return (phy << 1); +}; + +template<> +inline int +ResConv1d <480, 240>::ToPhyCoord(int vir) +{ + return (vir >> 1); +}; + +template<> +inline int +ResConv1d <480, 240>::ToPhyCoord4Size(int vir) +{ + return (vir >= 0) ? ((vir + 1) >> 1) : (vir >> 1); +}; + +template<> +inline int +ResConv1d <800, 400>::ToVirCoord(int phy) +{ + return (phy << 1); +}; + +template<> +inline int +ResConv1d <800, 400>::ToPhyCoord(int vir) +{ + return (vir >> 1); +}; + +template<> +inline int +ResConv1d <800, 400>::ToPhyCoord4Size(int vir) +{ + return (vir >= 0) ? ((vir + 1) >> 1) : (vir >> 1); +}; + +// (240x400) -> (480x800) +template<> +inline int +ResConv1d <240, 480>::ToVirCoord(int phy) +{ + return (phy >> 1); +}; + +template<> +inline int +ResConv1d <240, 480>::ToPhyCoord(int vir) +{ + return (vir << 1); +}; + +template<> +inline int +ResConv1d <240, 480>::ToPhyCoord4Size(int vir) +{ + return (vir << 1); +}; + +template<> +inline int +ResConv1d <400, 800>::ToVirCoord(int phy) +{ + return (phy >> 1); +}; + +template<> +inline int +ResConv1d <400, 800>::ToPhyCoord(int vir) +{ + return (vir << 1); +}; + +template<> +inline int +ResConv1d <400, 800>::ToPhyCoord4Size(int vir) +{ + return (vir << 1); +}; + +// (480x800) -> (320x480) +template<> +inline int +ResConv1d <480, 320>::ToVirCoord(int phy) +{ + return ((phy) >= 0) ? ((phy) * 3 / 2) : (((phy) * 3 - 1) / 2); +}; + +template<> +inline int +ResConv1d <480, 320>::ToPhyCoord(int vir) +{ + return ((vir) > 0) ? (((vir) + 1) * 2 / 3) : ((vir) * 2 / 3); +}; + +template<> +inline int +ResConv1d <480, 320>::ToPhyCoord4Size(int vir) +{ + return ((vir) > 0) ? (((vir) + 1) * 2 / 3) : ((vir) * 2 / 3); +}; + +template<> +inline int +ResConv1d <800, 480>::ToVirCoord(int phy) +{ + return ((phy) >= 0) ? ((phy) * 3 / 2) : (((phy) * 3 - 1) / 2); +}; + +template<> +inline int +ResConv1d <800, 480>::ToPhyCoord(int vir) +{ + return ((vir) > 0) ? (((vir) + 1) * 2 / 3) : ((vir) * 2 / 3); +}; + +template<> +inline int +ResConv1d <800, 480>::ToPhyCoord4Size(int vir) +{ + return ((vir) > 0) ? (((vir) + 1) * 2 / 3) : ((vir) * 2 / 3); +}; + +// (480x800) -> (320x480) compatibility +template<> +inline int +ResConv1d <801, 480>::ToVirCoord(int phy) +{ + return (phy * 5 / 3); +}; + +template<> +inline int +ResConv1d <801, 480>::ToPhyCoord(int vir) +{ + return (vir * 3 / 5); +}; + +template<> +inline int +ResConv1d <801, 480>::ToPhyCoord4Size(int vir) +{ + return (vir * 3 / 5); +}; + +// (240x400) -> (320x480) compatibility +template<> +inline int +ResConv1d <240, 320>::ToVirCoord(int phy) +{ + return (phy * 3 / 4); +}; + +template<> +inline int +ResConv1d <240, 320>::ToPhyCoord(int vir) +{ + return (vir * 4 / 3); +}; + +template<> +inline int +ResConv1d <240, 320>::ToPhyCoord4Size(int vir) +{ + return (vir * 4 / 3); +}; + +template<> +inline int +ResConv1d <400, 480>::ToVirCoord(int phy) +{ + return (phy * 5 / 6); +}; + +template<> +inline int +ResConv1d <400, 480>::ToPhyCoord(int vir) +{ + return (vir * 6 / 5); +}; + +template<> +inline int +ResConv1d <400, 480>::ToPhyCoord4Size(int vir) +{ + return (vir * 6 / 5); +}; + +// (480x800) -> (540x960) +template<> +inline int +ResConv1d <480, 540>::ToVirCoord(int phy) +{ + return (phy * 8 / 9); +}; + +template<> +inline int +ResConv1d <480, 540>::ToPhyCoord(int vir) +{ + return (vir * 9 / 8); +}; + +template<> +inline int +ResConv1d <480, 540>::ToPhyCoord4Size(int vir) +{ + return (vir >= 0) ? ((vir + 5) * 9 / 8) : (vir * 9 / 8); +}; + +template<> +inline int +ResConv1d <800, 960>::ToVirCoord(int phy) +{ + return (phy * 8 / 9); +}; + +template<> +inline int +ResConv1d <800, 960>::ToPhyCoord(int vir) +{ + return (vir * 9 / 8); +}; + +template<> +inline int +ResConv1d <800, 960>::ToPhyCoord4Size(int vir) +{ + return (vir >= 0) ? ((vir + 5) * 9 / 8) : (vir * 9 / 8); +}; + +//////////////////////////////////////////////////////////////////////////////// + +template<> +struct ResTraits +{ + enum + { + ResWidth = 480 + }; + enum + { + ResHeight = 800 + }; +}; + +template<> +struct ResTraits +{ + enum + { + ResWidth = 240 + }; + enum + { + ResHeight = 400 + }; +}; + +template<> +struct ResTraits +{ + enum + { + ResWidth = 320 + }; + enum + { + ResHeight = 480 + }; +}; + +template<> +struct ResTraits +{ + enum + { + ResWidth = 480 + }; + enum + { + ResHeight = (800 + 1) + }; +}; + +template<> +struct ResTraits +{ + enum + { + ResWidth = 540 + }; + enum + { + ResHeight = 960 + }; +}; + +} // Tizen::Graphics::_ResUtil + +}} // Tizen::Graphics + +//////////////////////////////////////////////////////////////////////////////// +// Macro + +namespace Tizen { namespace Graphics +{ + +namespace _ResUtil +{ + +inline bool +NEED_TO_CONVERT(void) +{ + _Resolution virRes = Tizen::Graphics::_CoordinateSystem::GetInstance()->GetInternalResolution(); + _Resolution PhyRes = Tizen::Graphics::_CoordinateSystem::GetInstance()->GetDeviceResolution(); + + return (virRes != PhyRes); +} + +typedef ResConv ResWQVGA2WVGA; +typedef ResConv ResWVGA2WQVGA; +typedef ResConv ResWVGA2HVGA; +typedef ResConv ResWQVGA2HVGA; +typedef ResConv ResWVGAcompat2HVGA; +typedef ResConv ResWVGA2QHD; + +#if defined(_MODEL_RES_WVGA) +// #error "Base resolution: 480 x 800" +typedef ResWQVGA2WVGA CurrentResConv; +#elif defined(_MODEL_RES_WQVGA) +// #error "Base resolution: 240 x 400" +typedef ResWVGA2WQVGA CurrentResConv; +#elif defined(_MODEL_RES_HVGA) +// #error "Base resolution: 320 x 480" +typedef ResWVGA2HVGA CurrentResConv; +#elif defined(_MODEL_RES_QHD) +// #error "Base resolution: 800 x 1280" +typedef ResWVGA2QHD CurrentResConv; +#else +//#error "Open CMakeLists.txt and define base resolution for new model" +typedef ResWVGA2WQVGA CurrentResConv; +#endif + + +#if 0 // defined(_MODEL_RES_HVGA) +#define NOT_FROM_WQVGA() (Tizen::Graphics::_CoordinateSystem::GetInstance()->GetInternalResolution() != \ + Tizen::Graphics::RESOLUTION_WQVGA) +#define NOT_FROM_WVGA_COMPAT() (Tizen::Graphics::_CoordinateSystem::GetInstance()->GetInternalResolution() != \ + Tizen::Graphics::RESOLUTION_WVGA_COMPAT) +#define TRANSFORM(func, sour) \ + ( \ + NEED_TO_CONVERT() \ + ? \ + ( \ + NOT_FROM_WQVGA() \ + ? \ + ( \ + NOT_FROM_WVGA_COMPAT() \ + ? \ + ( \ + CurrentResConv::func(sour) \ + ) \ + : \ + ( \ + ResWVGAcompat2HVGA::func(sour) \ + ) \ + ) \ + : \ + ( \ + ResWQVGA2HVGA::func(sour) \ + ) \ + ) \ + : \ + sour \ + ) + +template +inline T +TO_PHY_COORD(const T& sour) +{ + return TRANSFORM(ToPhyCoord, sour); +} + +template +inline T +TO_VIR_COORD(const T& sour) +{ + return TRANSFORM(ToVirCoord, sour); +} + +#define CONVERT_TO_P_COORD_X(sour) TRANSFORM(ToPhyCoordX, sour) +#define CONVERT_TO_P_COORD_Y(sour) TRANSFORM(ToPhyCoordY, sour) +#define CONVERT_TO_P_COORD_W(sour) TRANSFORM(ToPhyCoordW, sour) +#define CONVERT_TO_P_COORD_H(sour) TRANSFORM(ToPhyCoordH, sour) +#define CONVERT_TO_P_COORD_SIZE(sour) TRANSFORM(ToPhyCoordSize, sour) + +#define CONVERT_TO_V_COORD_X(sour) TRANSFORM(ToVirCoordX, sour) +#define CONVERT_TO_V_COORD_Y(sour) TRANSFORM(ToVirCoordY, sour) +#define CONVERT_TO_V_COORD_W(sour) TRANSFORM(ToVirCoordW, sour) +#define CONVERT_TO_V_COORD_H(sour) TRANSFORM(ToVirCoordH, sour) + +inline bool +CONVERT_TO_P_COORD_POINT_LIST(Tizen::Base::Collection::ArrayList& dest, const Tizen::Base::Collection::IList& sour) +{ + result r; + + if (NEED_TO_CONVERT()) + { + r = dest.Construct(); + + if (r == E_SUCCESS) + { + for (int i = 0; i < sour.GetCount(); i++) + { + Tizen::Graphics::Point* pSourPoint = + dynamic_cast (const_cast (sour.GetAt(i))); + + if (pSourPoint == null) + { + return false; + } + + Tizen::Graphics::Point* pDestPoint = new (std::nothrow) Tizen::Graphics::Point(pSourPoint->x, pSourPoint->y); + + if (pDestPoint == null) + { + return false; + } + + if (NOT_FROM_WQVGA()) + { + if (NOT_FROM_WVGA_COMPAT()) + { + *pDestPoint = CurrentResConv::ToPhyCoord(*pDestPoint); + } + else + { + *pDestPoint = ResWVGAcompat2HVGA::ToPhyCoord(*pDestPoint); + } + } + else + { + *pDestPoint = ResWQVGA2HVGA::ToPhyCoord(*pDestPoint); + } + + dest.Add(*pDestPoint); + } + } + } + else + { + r = dest.Construct(sour); + } + + return (r == E_SUCCESS); +} + +#else +template +inline T +TO_PHY_COORD(const T& sour) +{ + return _ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToPhyCoord(sour) : sour; +} + +template +inline T +TO_VIR_COORD(const T& sour) +{ + return NEED_TO_CONVERT() ? CurrentResConv::ToVirCoord(sour) : sour; +} + +inline bool +CONVERT_TO_P_COORD_POINT_LIST(Tizen::Base::Collection::ArrayList& dest, const Tizen::Base::Collection::IList& sour) +{ + result r; + + if (NEED_TO_CONVERT()) + { + r = dest.Construct(); + + if (r == E_SUCCESS) + { + for (int i = 0; i < sour.GetCount(); i++) + { + Tizen::Graphics::Point* pSourPoint = + dynamic_cast (const_cast (sour.GetAt(i))); + + if (pSourPoint == null) + { + return false; + } + + Tizen::Graphics::Point* pDestPoint = new (std::nothrow) Tizen::Graphics::Point(pSourPoint->x, pSourPoint->y); + + if (pDestPoint == null) + { + return false; + } + + *pDestPoint = CurrentResConv::ToPhyCoord(*pDestPoint); + + dest.Add(*pDestPoint); + } + } + } + else + { + r = dest.Construct(sour); + } + + return (r == E_SUCCESS); +} + +#define CONVERT_TO_P_COORD_X(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToPhyCoordX(sour) : sour) +#define CONVERT_TO_P_COORD_Y(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToPhyCoordY(sour) : sour) +#define CONVERT_TO_P_COORD_W(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToPhyCoordW(sour) : sour) +#define CONVERT_TO_P_COORD_H(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToPhyCoordH(sour) : sour) +#define CONVERT_TO_P_COORD_SIZE(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToPhyCoordSize(sour) : sour) + +#define CONVERT_TO_V_COORD_X(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToVirCoordX(sour) : sour) +#define CONVERT_TO_V_COORD_Y(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToVirCoordY(sour) : sour) +#define CONVERT_TO_V_COORD_W(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToVirCoordW(sour) : sour) +#define CONVERT_TO_V_COORD_H(sour) (_ResUtil::NEED_TO_CONVERT() ? _ResUtil::CurrentResConv::ToVirCoordH(sour) : sour) + +#endif // #if defined(_MODEL_RES_HVGA) + +} // Tizen::Graphics::_ResUtil + +}} // Tizen::Graphics + +//////////////////////////////////////////////////////////////////////////////// +// struct CoordHolder + +namespace Tizen { namespace Graphics +{ + +namespace _ResUtil +{ +template +struct CoordHolder +{ + T required; + T phyCoord; + T virCoord; + + void operator =(const T& in) + { + required = in; + phyCoord = TO_PHY_COORD(required); + virCoord = TO_VIR_COORD(phyCoord); + } +}; +} // Tizen::Graphics::_ResUtil + +}} // Tizen::Graphics + +#else + +#include "FGrp_CoordinateSystem.h" + +namespace Tizen { namespace Graphics +{ + +namespace _ResUtil +{ + +struct Rect +{ + int x; + int y; + int w; + int h; + + Rect() + : x(0) + , y(0) + , w(0) + , h(0) + { + } + + Rect(int _x, int _y, int _w, int _h) + : x(_x) + , y(_y) + , w(_w) + , h(_h) + { + } +}; + +struct Pos +{ + int x; + int y; + + Pos() + : x(0) + , y(0) + { + } + + Pos(int _x, int _y) + : x(_x) + , y(_y) + { + } +}; + +struct Size +{ + int w; + int h; + + Size() + : w(0) + , h(0) + { + } + + Size(int _w, int _h) + : w(_w) + , h(_h) + { + } +}; + +//////////////////////////////////////////////////////////////////////////////// + +namespace // unnamed +{ + +template +inline T +ToPhyCoord(const T& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer(); + return (pTransformer) ? pTransformer->Transform(sour) : sour; +} + +template +inline T +ToVirCoord(const T& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + return (pTransformer) ? pTransformer->Transform(sour) : sour; +} + +template<> +inline _Util::Point +ToPhyCoord(const _Util::Point& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer(); + + if (pTransformer == null) + { + return sour; + } + + _Util::Point dest = + { + pTransformer->TransformHorizontal(sour.x), + pTransformer->TransformVertical(sour.y) + }; + + return dest; +} + +template<> +inline _Util::Point +ToPhyCoord(const _Util::Point& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer(); + + if (pTransformer) + { + _Util::Point temp = + { + sour.x * double(pTransformer->GetHorizontalScaleFactor()), + sour.y * double(pTransformer->GetVerticalScaleFactor()) + }; + + return temp; + } + else + { + return sour; + } +} + +template<> +inline _Util::Dimension +ToPhyCoord(const _Util::Dimension& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer(); + + if (pTransformer) + { + _Util::Dimension temp = + { + sour.w * double(pTransformer->GetHorizontalScaleFactor()), + sour.h * double(pTransformer->GetVerticalScaleFactor()) + }; + + return temp; + } + else + { + return sour; + } +} + +template<> +inline _Util::Rectangle +ToPhyCoord(const _Util::Rectangle& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer(); + + if (pTransformer) + { + _Util::Rectangle temp = + { + sour.x * double(pTransformer->GetHorizontalScaleFactor()), + sour.y * double(pTransformer->GetVerticalScaleFactor()), + sour.w * double(pTransformer->GetHorizontalScaleFactor()), + sour.h * double(pTransformer->GetVerticalScaleFactor()) + }; + + return temp; + } + else + { + return sour; + } +} + +template<> +inline Rect +ToPhyCoord(const Rect& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer(); + + if (pTransformer == null) + { + return sour; + } + + Rectangle rect1(sour.x, sour.y, sour.w, sour.h); + Rectangle rect2 = pTransformer->Transform(rect1); + + return Rect(rect2.x, rect2.y, rect2.width, rect2.height); +} + +template<> +inline Rect +ToVirCoord(const Rect& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + + if (pTransformer == null) + { + return sour; + } + + Rectangle rect1(sour.x, sour.y, sour.w, sour.h); + Rectangle rect2 = pTransformer->Transform(rect1); + + return Rect(rect2.x, rect2.y, rect2.width, rect2.height); +} + +template<> +inline Pos +ToPhyCoord(const Pos& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer(); + + if (pTransformer == null) + { + return sour; + } + + Point point1(sour.x, sour.y); + Point point2 = pTransformer->Transform(point1); + + return Pos(point2.x, point2.y); +} + +template<> +inline Pos +ToVirCoord(const Pos& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + + if (pTransformer == null) + { + return sour; + } + + Point point1(sour.x, sour.y); + Point point2 = pTransformer->Transform(point1); + + return Pos(point2.x, point2.y); +} + +//////////////////////////////////////////////////////////////////////////////// + +template +inline T +ToVirCoordX(const T& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + return (pTransformer) ? pTransformer->TransformHorizontal(sour) : sour; +} + +template +inline T +ToVirCoordY(const T& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + return (pTransformer) ? pTransformer->TransformVertical(sour) : sour; +} + +template +inline T +ToPhyCoordW(const T& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer(); + return (pTransformer) ? pTransformer->TransformHorizontal(sour) : sour; +} + +template +inline T +ToVirCoordW(const T& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + return (pTransformer) ? pTransformer->TransformHorizontal(sour) : sour; +} + +template +inline T +ToPhyCoordH(const T& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer(); + return (pTransformer) ? pTransformer->TransformVertical(sour) : sour; +} + +template +inline T +ToVirCoordH(const T& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetInverseTransformer(); + return (pTransformer) ? pTransformer->TransformVertical(sour) : sour; +} + +template +inline T +ToPhyCoordSize(const T& sour) +{ + _ICoordinateSystemTransformer* pTransformer = _CoordinateSystem::GetInstance()->GetTransformer(); + return (pTransformer) ? pTransformer->TransformVertical(sour) : sour; +} + +} + +//////////////////////////////////////////////////////////////////////////////// + +inline bool +NeedToConvertCoord(void) +{ + _LogicalResolution logicalResolution = Tizen::Graphics::_CoordinateSystem::GetInstance()->GetLogicalResolution(); + _PhysicalResolution physicalResolution = Tizen::Graphics::_CoordinateSystem::GetInstance()->GetPhysicalResolution(); + + return !((logicalResolution == RESOLUTION_LOGICAL_480 && physicalResolution == RESOLUTION_PHYSICAL_WVGA) || (logicalResolution == RESOLUTION_LOGICAL_720 && physicalResolution == RESOLUTION_PHYSICAL_HD)); +} + +template +inline T +ConvertToPhyCoord(const T& sour) +{ + return NeedToConvertCoord() ? ToPhyCoord(sour) : sour; +} + +template +inline T +ConvertToVirCoord(const T& sour) +{ + return NeedToConvertCoord() ? ToVirCoord(sour) : sour; +} + +template +inline T +ConvertToPhyCoordWidth(const T& sour) +{ + return NeedToConvertCoord() ? ToPhyCoordW(sour) : sour; +} + +template +inline T +ConvertToPhyCoordHeight(const T& sour) +{ + return NeedToConvertCoord() ? ToPhyCoordH(sour) : sour; +} + +template +inline T +ConvertToPhyCoordSize(const T& sour) +{ + return NeedToConvertCoord() ? ToPhyCoordSize(sour) : sour; +} + +template +inline T +ConvertToVirCoordX(const T& sour) +{ + return NeedToConvertCoord() ? ToVirCoordX(sour) : sour; +} + +template +inline T +ConvertToVirCoordY(const T& sour) +{ + return NeedToConvertCoord() ? ToVirCoordY(sour) : sour; +} + +inline bool +ConvertToPhyCoordPointList(Tizen::Base::Collection::ArrayList& dest, const Tizen::Base::Collection::IList& sour) +{ + result r; + + if (NeedToConvertCoord()) + { + r = dest.Construct(); + + if (r == E_SUCCESS) + { + for (int i = 0; i < sour.GetCount(); i++) + { + Tizen::Graphics::Point* pSourPoint = + dynamic_cast (const_cast (sour.GetAt(i))); + + if (pSourPoint == null) + { + dest.RemoveAll(true); + return false; + } + + Tizen::Graphics::Point* pDestPoint = new (std::nothrow) Tizen::Graphics::Point(pSourPoint->x, pSourPoint->y); + + if (pDestPoint == null) + { + dest.RemoveAll(true); + return false; + } + + *pDestPoint = ToPhyCoord(*pDestPoint); + + dest.Add(*pDestPoint); + } + } + } + else + { + r = dest.Construct(sour); + } + + return (r == E_SUCCESS); +} + +//////////////////////////////////////////////////////////////////////////////// + +template +struct CoordHolder +{ + T required; + T phyCoord; + T virCoord; + + void operator =(const T& in) + { + required = in; + phyCoord = ConvertToPhyCoord(required); + virCoord = ConvertToVirCoord(phyCoord); + } +}; + +} // _ResUtil + +}} // Tizen::Graphics + +#endif + +#endif //_FGRP_INTERNAL_RES_UTIL_H_ diff --git a/src/graphics/FGrp_Screen.cpp b/src/graphics/FGrp_Screen.cpp new file mode 100644 index 0000000..2619a5c --- /dev/null +++ b/src/graphics/FGrp_Screen.cpp @@ -0,0 +1,92 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Screen.cpp + * @brief This is the header file for internal _Screen namespace. + * + */ + +#include +#include + +#include "FGrp_Screen.h" + + +namespace Tizen { namespace Graphics +{ + +int +_Screen::GetWidth(void) +{ + static int screenWidth = 0; + + if (screenWidth == 0) + { + result r = Tizen::System::_SystemInfoImpl::GetSysInfo(Tizen::Base::String(L"http://tizen.org/feature/screen.width"), screenWidth); + + if (r != E_SUCCESS) + { + screenWidth = 0; + } + } + + return screenWidth; +} + +int +_Screen::GetHeight(void) +{ + static int screenHeight = 0; + + if (screenHeight == 0) + { + result r = Tizen::System::_SystemInfoImpl::GetSysInfo(Tizen::Base::String(L"http://tizen.org/feature/screen.height"), screenHeight); + + if (r != E_SUCCESS) + { + screenHeight = 0; + } + } + + return screenHeight; +} + +int +_Screen::GetBytesPerPixel(void) +{ + static int screenBpp = 0; + + if (screenBpp == 0) + { + result r = Tizen::System::_SystemInfoImpl::GetSysInfo(Tizen::Base::String(L"http://tizen.org/feature/screen.bpp"), screenBpp); + + if (r != E_SUCCESS) + { + screenBpp = 0; + } + + if (screenBpp == 24) + { + screenBpp = 32; + } + } + + return screenBpp; +} + +}} // Tizen::Graphics diff --git a/src/graphics/FGrp_TextElementImpl.cpp b/src/graphics/FGrp_TextElementImpl.cpp new file mode 100644 index 0000000..40fc863 --- /dev/null +++ b/src/graphics/FGrp_TextElementImpl.cpp @@ -0,0 +1,1110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextElementImpl.cpp + * @brief This is the cpp file for _TextElementImpl class. + */ + +// Includes +#include + +#include "FGrp_TextElementImpl.h" +#include "FGrp_EnrichedTextImpl.h" +#include "FGrp_FontImpl.h" +#include "FGrp_ResUtil.h" +#include "FGrp_TextTextCutLinkParser.h" +#include "FGrp_TextTextUtility.h" +#include "FGrp_TextTextElement.h" +#include "FGrp_TextTextSimple.h" +#include "FGrp_TextTextCutLink.h" +#include "util/FGrp_Util.h" + +// Usings +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace // unnamed +{ + const int DEFAULT_FONT_SIZE = 42; +} + +namespace Tizen { namespace Graphics +{ + +_TextElementImpl::_TextElementImpl(void) +{ + __strText = null; + __linkText = null; + __linkType = LINK_TYPE_NONE; + __pFont = null; + __isAuto = false; + __bgColorEnable = false; + __outlineColorEnable = false; + __autoLink = false; + __pRegisteringEnrichedText = null; + __count = 0; + __linkOffset = 0; + __pTextComponent = null; +} + +_TextElementImpl::~_TextElementImpl(void) +{ + if (__pRegisteringEnrichedText) + { + int index = __pRegisteringEnrichedText->GetTextElementIndex(this); + int count = __pRegisteringEnrichedText->GetTextElementCount(); + + if (index >= 0 && index < count) + { + __pRegisteringEnrichedText->RemoveAt(index, false); + } + __pRegisteringEnrichedText = null; + } + + if (__pFont) + { + delete __pFont; + __pFont = null; + } + + if (__pTextComponent) + { + Destroy(); + } +} + +result +_TextElementImpl::Construct(const Tizen::Base::String& text) +{ + SysTryReturn(NID_GRP, __pTextComponent == null, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is already constructed."); + SysTryReturn(NID_GRP, text.IsEmpty() == false, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + Font* pFont = null; + __strText = text; + + r = Create(__strText, __strText.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to construct native text element.", GetErrorMessage(r)); + + __foregroundColor = GetTextColor(); + __backgroundColor = GetBackgroundColor(); + __outlineColor = GetOutlineColor(); + + pFont = new (std::nothrow) Font; + if (!pFont) + { + return E_OUT_OF_MEMORY; + } + + r = pFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to construct font.", GetErrorMessage(r)); + + r = SetTextObjectFont(*pFont); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to set font.", GetErrorMessage(r)); + + this->__pFont = pFont; + + return r; + +CATCH: + delete pFont; + pFont = null; + + return r; +} + +result +_TextElementImpl::Construct(const Tizen::Base::String& text, const Tizen::Graphics::Canvas& canvas) +{ + SysTryReturn(NID_GRP, __pTextComponent == null, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is already constructed."); + SysTryReturn(NID_GRP, text.IsEmpty() == false, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + SysTryReturn(NID_GRP, &canvas, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + + r = this->Construct(text); + + if (r != E_SUCCESS) + { + return r; + } + + Tizen::Graphics::Canvas& refCanvas = const_cast (canvas); + + Tizen::Graphics::Color color1 = refCanvas.GetForegroundColor(); + r = GetLastResult(); + SysTryReturn(NID_GRP, r == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + this->SetTextColor(color1); + + Tizen::Graphics::Color color2 = refCanvas.GetBackgroundColor(); + r = GetLastResult(); + SysTryReturn(NID_GRP, r == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + this->SetBackgroundColor(color2); + + return r; +} + +result +_TextElementImpl::Construct(void) +{ + SysTryReturn(NID_GRP, __pTextComponent == null, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is already constructed."); + + result r = E_SUCCESS; + __strText = ""; + Font* pFont = null; + + r = Create(__strText, __strText.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to construct native text element.", GetErrorMessage(r)); + + __foregroundColor = GetTextColor(); + __backgroundColor = GetBackgroundColor(); + __outlineColor = GetOutlineColor(); + + pFont = new (std::nothrow) Font; + if (!pFont) + { + return E_OUT_OF_MEMORY; + } + + r = pFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to construct font.", GetErrorMessage(r)); + + r = SetTextObjectFont(*pFont); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to set font.", GetErrorMessage(r)); + + this->__pFont = pFont; + + return r; + +CATCH: + delete pFont; + pFont = null; + + return r; +} + +result +_TextElementImpl::Construct(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link) +{ + SysTryReturn(NID_GRP, __pTextComponent == null, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is already constructed."); + SysTryReturn(NID_GRP, text.IsEmpty() == false, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + SysTryReturn(NID_GRP, LINK_TYPE_NONE != linkType, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The link type is invalid."); + + result r = E_SUCCESS; + Font* pFont = null; + _CutLinkType type = this->ConvertObjectLinkType(linkType); + FontStyle fontStyle = FONT_STYLE_MIN; + + __strText = text; + __linkText = link; + __linkType = linkType; + + r = CreateUserLink(__strText, type); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to create native text element.", GetErrorMessage(r)); + + __foregroundColor = GetTextColor(); + __backgroundColor = GetBackgroundColor(); + __outlineColor = GetOutlineColor(); + + pFont = new (std::nothrow) Font; + if (!pFont) + { + return E_OUT_OF_MEMORY; + } + + if (linkType == LINK_TYPE_URL || linkType == LINK_TYPE_EMAIL) + { + fontStyle = FONT_STYLE_ITALIC; + } + else if (linkType == LINK_TYPE_TEL_NUM) + { + fontStyle = FONT_STYLE_BOLD; + } + else + { + fontStyle = FONT_STYLE_PLAIN; + } + r = pFont->Construct(fontStyle, DEFAULT_FONT_SIZE); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to construct font.", GetErrorMessage(r)); + + SetTextColor(Color::GetColor(COLOR_ID_BLUE)); + pFont->SetUnderline(true); + r = SetTextObjectFont(*pFont); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to set font.", GetErrorMessage(r)); + + this->__pFont = pFont; + + return r; + +CATCH: + delete pFont; + pFont = null; + + return r; +} + +result +_TextElementImpl::Construct(const Tizen::Base::String& text, unsigned long autoLink) +{ + SysTryReturn(NID_GRP, __pTextComponent == null, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is already constructed."); + SysTryReturn(NID_GRP, text.IsEmpty() == false, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + SysTryReturn(NID_GRP, LINK_TYPE_NONE < autoLink && autoLink < LINK_TYPE_MAX, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The autolink mask is invalid."); + + result r = E_SUCCESS; + Tizen::Base::String link; + Font* pFont = null; + _CutLinkType type; + FontStyle fontStyle = FONT_STYLE_MIN; + + __strText = text; + __autoLink = autoLink; + __isAuto = true; + + r = CreateAutoLink(__strText, autoLink); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to create native text element.", GetErrorMessage(r)); + + __foregroundColor = GetTextColor(); + __backgroundColor = GetBackgroundColor(); + __outlineColor = GetOutlineColor(); + + type = GetCutLinkType(); + + pFont = new (std::nothrow) Font; + if (!pFont) + { + return E_OUT_OF_MEMORY; + } + + if (type != TEXT_CUTLINK_TYPE_INVALID) + { + int len = GetLength(); + + text.SubString((GetAutolinkSrcOffset()), len, link); + + __linkText = link; + __linkType = this->ConvertObjectLinkType(type); + + if (type == TEXT_CUTLINK_TYPE_URL || type == TEXT_CUTLINK_TYPE_EMAIL) + { + fontStyle = FONT_STYLE_ITALIC; + } + else if (type == TEXT_CUTLINK_TYPE_PHONE_NUMBER) + { + fontStyle = FONT_STYLE_BOLD; + } + else + { + fontStyle = FONT_STYLE_PLAIN; + } + + r = pFont->Construct(fontStyle, DEFAULT_FONT_SIZE); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to construct font.", GetErrorMessage(r)); + + SetTextColor(Color::GetColor(COLOR_ID_BLUE)); + pFont->SetUnderline(true); + r = SetTextObjectFont(*pFont); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to set font.", GetErrorMessage(r)); + + this->__pFont = pFont; + } + else + { + r = pFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to construct font.", GetErrorMessage(r)); + + r = SetTextObjectFont(*pFont); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fails to set font.", GetErrorMessage(r)); + + this->__pFont = pFont; + } + + return r; + +CATCH: + delete pFont; + pFont = null; + + return r; +} + +result +_TextElementImpl::Construct(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link, + const Tizen::Graphics::Canvas& canvas) +{ + SysTryReturn(NID_GRP, __pTextComponent == null, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] This instance is already constructed."); + SysTryReturn(NID_GRP, text.IsEmpty() == false, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The argument is invalid."); + SysTryReturn(NID_GRP, LINK_TYPE_NONE != linkType, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The link type is invalid."); + SysTryReturn(NID_GRP, &canvas, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + + r = this->Construct(text, linkType, link); + + if (r != E_SUCCESS) + { + return r; + } + + Tizen::Graphics::Canvas& refCanvas = const_cast (canvas); + + Tizen::Graphics::Color color1 = refCanvas.GetForegroundColor(); + r = GetLastResult(); + SysTryReturn(NID_GRP, r == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + this->SetTextColor(color1); + + Tizen::Graphics::Color color2 = refCanvas.GetBackgroundColor(); + r = GetLastResult(); + SysTryReturn(NID_GRP, r == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + this->SetBackgroundColor(color2); + + return r; +} + +result +_TextElementImpl::Construct(const Tizen::Base::String& text, unsigned long autoLink, const Tizen::Graphics::Canvas& canvas) +{ + SysTryReturn(NID_GRP, __pTextComponent == null, E_OPERATION_FAILED, E_OPERATION_FAILED + , "[E_OPERATION_FAILED] This instance is already constructed."); + SysTryReturn(NID_GRP, text.IsEmpty() == false, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The argument is invalid."); + SysTryReturn(NID_GRP, LINK_TYPE_NONE < autoLink && autoLink < LINK_TYPE_MAX, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The autolink mask is invalid."); + SysTryReturn(NID_GRP, &canvas, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + + r = this->Construct(text, autoLink); + if (r != E_SUCCESS) + { + return r; + } + + Tizen::Graphics::Canvas& refCanvas = const_cast (canvas); + + Tizen::Graphics::Color color1 = refCanvas.GetForegroundColor(); + r = GetLastResult(); + SysTryReturn(NID_GRP, r == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + this->SetTextColor(color1); + + Tizen::Graphics::Color color2 = refCanvas.GetBackgroundColor(); + r = GetLastResult(); + SysTryReturn(NID_GRP, r == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + this->SetBackgroundColor(color2); + + return r; +} + +Tizen::Base::String& +_TextElementImpl::GetLink(void) const +{ + return *(const_cast (&__linkText)); +} + +result +_TextElementImpl::SetText(const Tizen::Base::String& text) +{ + SysTryReturn(NID_GRP, text.IsEmpty() == false, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + SysTryReturn(NID_GRP, __pTextComponent, E_OPERATION_FAILED, E_OPERATION_FAILED, "E_OPERATION_FAILED] Not Construct yet"); + + result r = E_SUCCESS; + + int index = -1; + __strText = text; + + if (__pRegisteringEnrichedText) + { + index = __pRegisteringEnrichedText->GetTextElementIndex(this); + r = __pRegisteringEnrichedText->RemoveFromTextObject(this); + } + + if (__pTextComponent) + { + Destroy(); + } + + if ((__linkType == LINK_TYPE_NONE) && (__autoLink == 0)) + { + r = Create(__strText, __strText.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + + if (r == E_SUCCESS) + { + SetTextColor(__foregroundColor); + if (__bgColorEnable == true) + { + SetBackgroundColor(__backgroundColor); + } + if (__outlineColorEnable == true) + { + SetOutlineColor(__outlineColor); + } + if (__pFont) + { + r = SetTextObjectFont(*__pFont); + } + } + else + { + return r; + } + } + else + { + if (__isAuto == true) + { + r = CreateAutoLink(__strText, __autoLink); + + if (r == E_SUCCESS) + { + _CutLinkType type = GetCutLinkType(); + __linkType = ConvertObjectLinkType(type); + + int len = GetLength(); + Tizen::Base::String link; + __strText.SubString(GetAutolinkSrcOffset(), len, link); + __linkText = link; + + SetTextColor(__foregroundColor); + if (__bgColorEnable == true) + { + SetBackgroundColor(__backgroundColor); + } + if (__outlineColorEnable == true) + { + SetOutlineColor(__outlineColor); + } + if (__pFont) + { + r = SetTextObjectFont(*__pFont); + if (r != E_SUCCESS) + { + return r; + } + } + } + else + { + return r; + } + } + else + { + _CutLinkType type = ConvertObjectLinkType(__linkType); + r = CreateUserLink(__strText, type); + + if (r == E_SUCCESS) + { + SetTextColor(__foregroundColor); + if (__bgColorEnable == true) + { + SetBackgroundColor(__backgroundColor); + } + if (__outlineColorEnable == true) + { + SetOutlineColor(__outlineColor); + } + if (__pFont) + { + r = SetTextObjectFont(*__pFont); + if (r != E_SUCCESS) + { + return r; + } + } + } + else + { + return r; + } + } + } + + if (__pRegisteringEnrichedText) + { + r = __pRegisteringEnrichedText->InsertAtFromTextObject(index, this); + if (r != E_SUCCESS) + { + return r; + } + } + + return E_SUCCESS; +} + +result +_TextElementImpl::SetFont(const Tizen::Graphics::Font& font) +{ + SysTryReturn(NID_GRP, _Util::CheckValidity(&font), E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The infomation of the given font is invalid."); + SysTryReturn(NID_GRP, __pTextComponent, E_OPERATION_FAILED, E_OPERATION_FAILED, "E_OPERATION_FAILED] Not Construct yet"); + + result r = E_SUCCESS; + TextSimple* pTextElement = null; + + if (__pFont) + { + delete __pFont; + __pFont = null; + } + + __pFont = _FontImpl::CloneN(const_cast (font)); + + if (__pFont) + { + if (__pTextComponent->GetType() == TEXT_ELEMENT_TYPE_CUTLINK) + { + TextCutLink* pLinkTextElement = dynamic_cast < TextCutLink* >(__pTextComponent); + if (pLinkTextElement) + { + pLinkTextElement->SetEditModeEnable(true); + } + } + + pTextElement = dynamic_cast < TextSimple* >(__pTextComponent); + if (pTextElement) + { + pTextElement->SetFont(const_cast (__pFont)); + } + } + else + { + r = E_INVALID_ARG; + } + + return r; +} + +result +_TextElementImpl::SetTextColor(const Tizen::Graphics::Color& color) +{ + SysTryReturn(NID_GRP, __pTextComponent, E_OPERATION_FAILED, E_OPERATION_FAILED, "E_OPERATION_FAILED] Not Construct yet"); + + __foregroundColor = color; + + TextSimple* pTextElement = null; + + if (__pTextComponent->GetType() == TEXT_ELEMENT_TYPE_CUTLINK) + { + TextCutLink* pLinkTextElement = dynamic_cast < TextCutLink* >(__pTextComponent); + if (pLinkTextElement) + { + pLinkTextElement->SetEditModeEnable(true); + } + } + + pTextElement = dynamic_cast < TextSimple* >(__pTextComponent); + if (pTextElement) + { + pTextElement->SetForegroundColor(color); + } + + return E_SUCCESS; +} + +result +_TextElementImpl::SetBackgroundColor(const Tizen::Graphics::Color& color) +{ + SysTryReturn(NID_GRP, __pTextComponent, E_OPERATION_FAILED, E_OPERATION_FAILED, "E_OPERATION_FAILED] Not Construct yet"); + + __backgroundColor = color; + __bgColorEnable = true; + + TextSimple* pTextElement = null; + + if (__pTextComponent->GetType() == TEXT_ELEMENT_TYPE_CUTLINK) + { + TextCutLink* pLinkTextElement = dynamic_cast < TextCutLink* >(__pTextComponent); + if (pLinkTextElement) + { + pLinkTextElement->SetEditModeEnable(true); + } + } + + pTextElement = dynamic_cast < TextSimple* >(__pTextComponent); + if (pTextElement) + { + pTextElement->SetBackGroundDrawingModeEnabled(true); + pTextElement->SetBackgroundColor(color); + } + + return E_SUCCESS; +} + +result +_TextElementImpl::SetOutlineColor(const Tizen::Graphics::Color& color) +{ + SysTryReturn(NID_GRP, __pTextComponent, E_OPERATION_FAILED, E_OPERATION_FAILED, "E_OPERATION_FAILED] Not Construct yet"); + + __outlineColor = color; + __outlineColorEnable = true; + + TextSimple* pTextElement = null; + + if (__pTextComponent->GetType() == TEXT_ELEMENT_TYPE_CUTLINK) + { + TextCutLink* pLinkTextElement = dynamic_cast < TextCutLink* >(__pTextComponent); + if (pLinkTextElement) + { + pLinkTextElement->SetEditModeEnable(true); + } + } + + pTextElement = dynamic_cast < TextSimple* >(__pTextComponent); + if (pTextElement) + { + pTextElement->SetOutlineColor(color); + } + + return E_SUCCESS; +} + +Tizen::Base::String& +_TextElementImpl::GetText(void) const +{ + return *(const_cast (&__strText)); +} + +Tizen::Graphics::Color +_TextElementImpl::GetTextColor(void) const +{ + return __foregroundColor; +} + +Tizen::Graphics::Color +_TextElementImpl::GetBackgroundColor(void) const +{ + return __backgroundColor; +} + +Tizen::Graphics::Color +_TextElementImpl::GetOutlineColor(void) const +{ + return __outlineColor; +} + +_CutLinkType +_TextElementImpl::ConvertObjectLinkType(Tizen::Base::Utility::LinkType type) +{ + _CutLinkType cutLinkType; + + switch (type) + { + case LINK_TYPE_URL: + cutLinkType = TEXT_CUTLINK_TYPE_URL; + break; + + case LINK_TYPE_EMAIL: + cutLinkType = TEXT_CUTLINK_TYPE_EMAIL; + break; + + case LINK_TYPE_TEL_NUM: + cutLinkType = TEXT_CUTLINK_TYPE_PHONE_NUMBER; + break; + + default: + cutLinkType = TEXT_CUTLINK_TYPE_INVALID; + break; + } + return cutLinkType; +} + +Tizen::Base::Utility::LinkType +_TextElementImpl::ConvertObjectLinkType(_CutLinkType type) +{ + LinkType linkType; + + switch (type) + { + case TEXT_CUTLINK_TYPE_URL: + linkType = LINK_TYPE_URL; + break; + + case TEXT_CUTLINK_TYPE_EMAIL: + linkType = LINK_TYPE_EMAIL; + break; + + case TEXT_CUTLINK_TYPE_PHONE_NUMBER: + linkType = LINK_TYPE_TEL_NUM; + break; + + case TEXT_CUTLINK_TYPE_STREAMING_URL: + linkType = LINK_TYPE_URL; + break; + + default: + linkType = LINK_TYPE_NONE; + break; + } + return linkType; +} + +_EnrichedTextImpl* +_TextElementImpl::GetRegisteringEnrichedText(void) const +{ + return __pRegisteringEnrichedText; +} + +void +_TextElementImpl::SetRegisteringEnrichedText(_EnrichedTextImpl* pEnrichedTextImpl) +{ + __pRegisteringEnrichedText = pEnrichedTextImpl; +} + +const Tizen::Base::String& +_TextElementImpl::GetLinkText(void) const +{ + return __linkText; +} + +Tizen::Base::Utility::LinkType +_TextElementImpl::GetLinkType(void) const +{ + return __linkType; +} + +bool +_TextElementImpl::IsAuto(void) const +{ + return __isAuto; +} + +result +_TextElementImpl::Create(const Tizen::Base::String& text, int length, TextElementSourceType sourceType) +{ + TextSimple* pTextElement = null; + + pTextElement = new (std::nothrow) TextSimple((wchar_t*) text.GetPointer(), length, sourceType); + + if (pTextElement == null) + { + return E_OUT_OF_MEMORY; + } + + __pTextComponent = pTextElement; + + return E_SUCCESS; +} + +result +_TextElementImpl::CreateUserLink(const Tizen::Base::String& text, _CutLinkType linkType) +{ + LinkType cutLinkType = LINK_TYPE_NONE; + int len = text.GetLength(); + TextCutLink* pTextElement = null; + + switch (linkType) + { + case TEXT_CUTLINK_TYPE_URL: + cutLinkType = LINK_TYPE_URL; + break; + + case TEXT_CUTLINK_TYPE_EMAIL: + cutLinkType = LINK_TYPE_EMAIL; + break; + + case TEXT_CUTLINK_TYPE_PHONE_NUMBER: + cutLinkType = LINK_TYPE_TEL_NUM; + break; + + case TEXT_CUTLINK_TYPE_STREAMING_URL: + cutLinkType = LINK_TYPE_URL; + break; + + default: + cutLinkType = LINK_TYPE_NONE; + break; + } + + pTextElement = new (std::nothrow) TextCutLink(true, cutLinkType, (wchar_t*) text.GetPointer(), len, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + + if (pTextElement == null) + { + return E_OUT_OF_MEMORY; + } + + __pTextComponent = pTextElement; + + return E_SUCCESS; +} + +result +_TextElementImpl::CreateAutoLink(const Tizen::Base::String& text, unsigned long autoLink) +{ + result r = E_SUCCESS; + int len = text.GetLength(); + wchar_t* pText = (wchar_t*) text.GetPointer(); + + if (autoLink != 0) + { + TextLinkInfo* pTextLinkInfo = null; + TextCutLinkParser* pParser = null; + + pParser = new (std::nothrow) TextCutLinkParser; + if (!pParser) + { + return E_OUT_OF_MEMORY; + } + + pTextLinkInfo = pParser->Parse(pText, len, 0); + if (!pTextLinkInfo) + { + delete pParser; + pParser = null; + + return E_INVALID_ARG; + } + + __linkOffset = pTextLinkInfo->srcOffset; + + if ((ConvertLinkType(pTextLinkInfo->linkType) & autoLink) != 0) + { + TextCutLink* pTextElement = null; + + pTextElement = new (std::nothrow) TextCutLink(false, pTextLinkInfo->linkType, pText + pTextLinkInfo->srcOffset + , pTextLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + + if (pTextElement == null) + { + if (pParser) + { + delete pParser; + pParser = null; + } + return E_OUT_OF_MEMORY; + } + + __pTextComponent = pTextElement; + r = E_SUCCESS; + } + else + { + r = Create(text, len, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + } + + while (pTextLinkInfo) + { + TextLinkInfo* pCurrent = pTextLinkInfo; + pTextLinkInfo = pTextLinkInfo->pNextLinkInfo; + free(pCurrent); + } + + if (pParser) + { + delete pParser; + pParser = null; + } + } + else + { + r = Create(text, len, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + } + + return r; +} + +void +_TextElementImpl::Destroy(void) +{ + if (__pTextComponent) + { + delete __pTextComponent; + __pTextComponent = null; + } +} + +_CutLinkType +_TextElementImpl::ConvertLinkType(LinkType type) const +{ + _CutLinkType linkType = TEXT_CUTLINK_TYPE_INVALID; + + switch (type) + { + case LINK_TYPE_URL: + linkType = TEXT_CUTLINK_TYPE_URL; + break; + + case LINK_TYPE_EMAIL: + linkType = TEXT_CUTLINK_TYPE_EMAIL; + break; + + case LINK_TYPE_TEL_NUM: + linkType = TEXT_CUTLINK_TYPE_PHONE_NUMBER; + break; + + default: + linkType = TEXT_CUTLINK_TYPE_INVALID; + break; + } + + return linkType; +} + +_CutLinkType +_TextElementImpl::GetCutLinkType(void) const +{ + _CutLinkType linkType = TEXT_CUTLINK_TYPE_INVALID; + TextCutLink* pTextElement = null; + + if (__pTextComponent->GetType() != TEXT_ELEMENT_TYPE_CUTLINK) + { + return TEXT_CUTLINK_TYPE_INVALID; + } + + pTextElement = dynamic_cast < TextCutLink* >(__pTextComponent); + if (pTextElement) + { + linkType = ConvertLinkType(pTextElement->GetCutLinkType()); + } + + return linkType; +} + +int +_TextElementImpl::GetLength(void) const +{ + return __pTextComponent->GetTextLength(); +} + +int +_TextElementImpl::GetAutolinkSrcOffset(void) const +{ + return __linkOffset; +} + +result +_TextElementImpl::SetTextObjectFont(const Tizen::Graphics::Font& font) +{ + SysTryReturn(NID_GRP, &font, E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The infomation of the given font is invalid."); + + SysTryReturn(NID_GRP, _Util::CheckValidity(&font), E_INVALID_ARG, E_INVALID_ARG + , "[E_INVALID_ARG] The infomation of the given font is invalid."); + + result r = E_SUCCESS; + Font* pFont = null; + TextSimple* pTextElement = null; + + pFont = const_cast (&font); + if (!pFont) + { + return E_INVALID_ARG; + } + + if (__pTextComponent->GetType() == TEXT_ELEMENT_TYPE_CUTLINK) + { + TextCutLink* pLinkTextElement = dynamic_cast < TextCutLink* >(__pTextComponent); + if (pLinkTextElement) + { + pLinkTextElement->SetEditModeEnable(true); + } + } + + pTextElement = dynamic_cast < TextSimple* >(__pTextComponent); + if (pTextElement) + { + pTextElement->SetFont(pFont); + } + + return r; +} + +_Text::TextElement* +_TextElementImpl::GetComponent(void) const +{ + return __pTextComponent; +} + + +const Tizen::Graphics::Font* +_TextElementImpl::GetFont(void) const +{ + return __pFont; +} + +unsigned long +_TextElementImpl::GetAutoLink(void) const +{ + return __autoLink; +} + +bool +_TextElementImpl::IsBackgoundColorEnable(void) const +{ + return __bgColorEnable; +} + +bool +_TextElementImpl::IsOutlineColorEnable(void) const +{ + return __outlineColorEnable; +} + +_TextElementImpl* +_TextElementImpl::GetInstance(TextElement& element) +{ + return (&element != null) ? element.__pImpl : null; +} + +const _TextElementImpl* +_TextElementImpl::GetInstance(const TextElement& element) +{ + return (&element != null) ? element.__pImpl : null; +} + +bool +_TextElementImpl::IsConstructed(void) const +{ + return (this->__pTextComponent != null); +} + +}} // Tizen::Graphics diff --git a/src/graphics/effect/FGrp_Effect.h b/src/graphics/effect/FGrp_Effect.h new file mode 100644 index 0000000..f5a6814 --- /dev/null +++ b/src/graphics/effect/FGrp_Effect.h @@ -0,0 +1,83 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Effect.h + * @brief This is the header file for internal utility class. + * + */ + +#ifndef _FGRP_INTERNAL_EFFECT_H_ +#define _FGRP_INTERNAL_EFFECT_H_ + + +#include + +#include "../util/FGrp_UtilTemplate.h" +#include "../util/FGrp_UtilScratchpad.h" +#include "../util/FGrp_UtilPixmap.h" + + +namespace Tizen { namespace Graphics +{ + +namespace _Effect +{ + +enum Flip +{ + FLIP_VERTICAL, + FLIP_HORIZONTAL +}; + +enum Rop +{ + ROP_COPY, + ROP_ALPHABLEND +}; + +enum DefaultFilter +{ + DEFAULT_FILTER_GOOD, + DEFAULT_FILTER_BEST +}; + +struct RotateDesc +{ + int angle; + int xOffset; + int yOffset; +}; + +bool ScaleImage(Tizen::Graphics::_Util::Pixmap& dstImage, long xDest, long yDest, long wDest, long hDest, const Tizen::Graphics::_Util::Pixmap& srcImage, Rop rop = ROP_ALPHABLEND); +bool ScaleImageInterpolation(Tizen::Graphics::_Util::Pixmap& dstImage, long xDest, long yDest, long wDest, long hDest, const Tizen::Graphics::_Util::Pixmap& srcImage, DefaultFilter defaultFilter); + +bool RotateImage(Tizen::Graphics::_Util::Pixmap& dstImage, long xDest, long yDest, const Tizen::Graphics::_Util::Pixmap& srcImage, const RotateDesc& rotateDesc, long constantAlpha); + +bool DrawImageWithAlpha(Tizen::Graphics::_Util::Pixmap& dstImage, long xDest, long yDest, const Tizen::Graphics::_Util::Pixmap& srcImage, long constantAlpha); + +bool IsNinePatchedBitmap(const Tizen::Graphics::_Util::Pixmap& dstImage); + +bool IsOpaqueAllOver(const Tizen::Graphics::_Util::Pixmap& dstImage); + +Tizen::Graphics::_Util::Pixmap* GetFlippedImage(const Tizen::Graphics::_Util::Pixmap& srcImage, Flip flip); + +} // _Effect + +}} // Tizen::Graphics + +#endif // #ifndef _FGRP_INTERNAL_EFFECT_H_ diff --git a/src/graphics/effect/FGrp_EffectAlpha.cpp b/src/graphics/effect/FGrp_EffectAlpha.cpp new file mode 100644 index 0000000..1b0ee91 --- /dev/null +++ b/src/graphics/effect/FGrp_EffectAlpha.cpp @@ -0,0 +1,346 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_EffectAlpha.cpp + * @brief This is the header file for internal utility class. + * + */ + +#include "FGrp_EffectFunc.h" +#include "FGrp_Effect.h" +#include "../util/FGrp_Util.h" + +using namespace Tizen::Graphics; + + +//////////////////////////////////////////////////////////////////////////////// +// template _BltBlend() + +namespace // unnamed +{ + +template +inline void +_BltBlend(DestPixel* pDest, int w, int h, int pitch, SourPixel* pSour, int imagePitch, unsigned long opacity, + _Util::ColorKey srcColorKey) +{ + opacity += (opacity >> 7); + + if (!srcColorKey.isValid) + { + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + *pDest = _Effect::Func::AlphaBlending(*pDest, *pSour++, DestPixel(opacity)); + ++pDest; + } + + pDest += (pitch - w); + pSour += (imagePitch - w); + } + } + else + { + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + if (*pSour != srcColorKey.colorKey) + { + *pDest = _Effect::Func::AlphaBlending(*pDest, *pSour, DestPixel(opacity)); + } + + ++pSour; + ++pDest; + } + + pDest += (pitch - w); + pSour += (imagePitch - w); + } + } +} + +template +inline void +_BltCopy(DestPixel* pDest, int w, int h, int pitch, SourPixel* pSour, int imagePitch, _Util::ColorKey srcColorKey) +{ + if (!srcColorKey.isValid) + { + while (--h >= 0) + { + _Effect::Func::ConvertColorFormat(pDest, pSour, w); + + pDest += pitch; + pSour += imagePitch; + } + } + else + { + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + if (*pSour != srcColorKey.colorKey) + { + _Effect::Func::ConvertColorFormat(pDest, pSour, 1); + } + + ++pSour; + ++pDest; + } + + pDest += (pitch - w); + pSour += (imagePitch - w); + } + } +} + +//////////////////////////////////////////////////////////////////////////// +// static function (callback) + +void +_BitbltFast32bitFrom32bit(unsigned long* pDest32, int w, int h, int pitch, unsigned long* pSour32, int imagePitch, + unsigned long opacity, + _Util::ColorKey srcColorKey) +{ + _BltCopy(pDest32, w, h, pitch, pSour32, imagePitch, srcColorKey); +} + +void +_BitbltFast32bitFrom16bit(unsigned long* pDest32, int w, int h, int pitch, unsigned long* pSour32, int imagePitch, + unsigned long opacity, + _Util::ColorKey srcColorKey) +{ + unsigned short* pSour16 = (unsigned short*) pSour32; + + _BltCopy(pDest32, w, h, pitch, pSour16, imagePitch, srcColorKey); +} + +void +_BitbltFast16bitFrom32bit(unsigned short* pDest16, int w, int h, int pitch, unsigned short* pSour16, int imagePitch, + unsigned long opacity, + _Util::ColorKey srcColorKey) +{ + unsigned long* pSour32 = (unsigned long*) pSour16; + + _BltCopy(pDest16, w, h, pitch, pSour32, imagePitch, srcColorKey); +} + +void +_BitbltFast16bitFrom16bit(unsigned short* pDest16, int w, int h, int pitch, unsigned short* pSour16, int imagePitch, + unsigned long opacity, + _Util::ColorKey srcColorKey) +{ + _BltCopy(pDest16, w, h, pitch, pSour16, imagePitch, srcColorKey); +} + +/////// ------ + +void +_BitbltAlpha32bitFrom32bit(unsigned long* pDest32, int w, int h, int pitch, unsigned long* pSour32, int imagePitch, + unsigned long opacity, + _Util::ColorKey srcColorKey) +{ + _BltBlend(pDest32, w, h, pitch, pSour32, imagePitch, opacity, srcColorKey); +} + +void +_BitbltAlpha32bitFrom16bit(unsigned long* pDest32, int w, int h, int pitch, unsigned long* pSour32, int imagePitch, + unsigned long opacity, + _Util::ColorKey srcColorKey) +{ + unsigned short* pSour16 = (unsigned short*) pSour32; + + if (opacity >= 255) + { + _BltCopy(pDest32, w, h, pitch, pSour16, imagePitch, srcColorKey); + } + else + { + _BltBlend(pDest32, w, h, pitch, pSour16, imagePitch, opacity, srcColorKey); + } +} + +void +_BitbltAlpha16bitFrom32bit(unsigned short* pDest16, int w, int h, int pitch, unsigned short* pSour16, int imagePitch, + unsigned long opacity, + _Util::ColorKey srcColorKey) +{ + unsigned long* pSour32 = (unsigned long*) pSour16; + + _BltBlend(pDest16, w, h, pitch, pSour32, imagePitch, opacity, srcColorKey); +} + +void +_BitbltAlpha16bitFrom16bit(unsigned short* pDest16, int w, int h, int pitch, unsigned short* pSour16, int imagePitch, + unsigned long opacity, + _Util::ColorKey srcColorKey) +{ + _BltBlend(pDest16, w, h, pitch, pSour16, imagePitch, opacity, srcColorKey); +} + +//////////////////////////////////////////////////////////////////////////// +// static function + +bool +_DrawImageWithAlpha(const _Util::Pixmap& dstImage, long xDest, long yDest, const _Util::Pixmap& srcImage, long constantAlpha) +{ + _Util::ColorKey srcColorKey; + + if (srcImage.enableColorKey) + { + srcColorKey.isValid = true; + srcColorKey.colorKey = srcImage.colorKey; + } + + switch (dstImage.depth) + { + case 32: + { + typedef unsigned long Pixel; + + _Util::ScratchPad dstScratchPad((Pixel*) dstImage.pBitmap, dstImage.width, dstImage.height, + dstImage.bytesPerLine / sizeof(Pixel)); + _Util::ScratchPad srcScratchPad((Pixel*) srcImage.pBitmap, srcImage.width, srcImage.height, + srcImage.bytesPerLine / sizeof(Pixel), + srcColorKey); + + srcScratchPad.SetPitch(srcImage.depth, srcImage.bytesPerLine); + + if (srcImage.isOpaque && constantAlpha >= 255) + { + dstScratchPad.RegisterBitBlt((srcImage.depth == 32) ? _BitbltFast32bitFrom32bit : _BitbltFast32bitFrom16bit); + } + else + { + dstScratchPad.RegisterBitBlt((srcImage.depth == 32) ? _BitbltAlpha32bitFrom32bit : _BitbltAlpha32bitFrom16bit); + } + + dstScratchPad.BitBlt(xDest, yDest, &srcScratchPad, 0, 0, srcScratchPad.GetWidth(), + srcScratchPad.GetHeight(), constantAlpha); + } + break; + case 16: + { + typedef unsigned short Pixel; + + _Util::ScratchPad dstScratchPad((Pixel*) dstImage.pBitmap, dstImage.width, dstImage.height, + dstImage.bytesPerLine / sizeof(Pixel)); + _Util::ScratchPad srcScratchPad((Pixel*) srcImage.pBitmap, srcImage.width, srcImage.height, + srcImage.bytesPerLine / sizeof(Pixel), + srcColorKey); + + srcScratchPad.SetPitch(srcImage.depth, srcImage.bytesPerLine); + + if (srcImage.isOpaque && constantAlpha >= 255) + { + dstScratchPad.RegisterBitBlt((srcImage.depth == 32) ? _BitbltFast16bitFrom32bit : _BitbltFast16bitFrom16bit); + } + else + { + dstScratchPad.RegisterBitBlt((srcImage.depth == 32) ? _BitbltAlpha16bitFrom32bit : _BitbltAlpha16bitFrom16bit); + } + + dstScratchPad.BitBlt(xDest, yDest, &srcScratchPad, 0, 0, srcScratchPad.GetWidth(), + srcScratchPad.GetHeight(), constantAlpha); + } + break; + default: + // assert(false); + return false; + } + + return true; +} + +} + +//////////////////////////////////////////////////////////////////////////////// +// public + +bool +Tizen::Graphics::_Effect::DrawImageWithAlpha(_Util::Pixmap& dstImage, long xDest, long yDest, const _Util::Pixmap& srcImage, long constantAlpha) +{ + // ÁÖ¾îÁø ÆĶó¹ÌÅÍ°¡ À¯È¿ÇÑÁö È®ÀÎÀ» ÇÑ´Ù. + { + if ((srcImage.width < 0) || (srcImage.height < 0) || (srcImage.pBitmap == null)) + { + return false; + } + + if ((dstImage.width < 0) || (dstImage.height < 0) || (dstImage.pBitmap == null)) + { + return false; + } + + bool isSuitablePixelDepth = + ((srcImage.depth == 16 || srcImage.depth == 32) && (dstImage.depth == 16 || dstImage.depth == 32)); + + if (!isSuitablePixelDepth) + { + return false; + } + + if (constantAlpha <= 0) + { + return true; + } + + if (constantAlpha > 255) + { + constantAlpha = 255; + } + + if (srcImage.pBitmap == dstImage.pBitmap) + { + return false; + } + } + + { + if ((srcImage.width == 0) || (srcImage.height == 0)) + { + return true; + } + + if ((dstImage.width == 0) || (dstImage.height == 0)) + { + return true; + } + + { + _Util::Rectangle dstRect = { 0, 0, dstImage.width, dstImage.height }; + _Util::Rectangle tgtRect = { xDest, yDest, srcImage.width, srcImage.height }; + _Util::Rectangle outRect; + + if (!IntersectRect(outRect, tgtRect, dstRect)) + { + return true; + } + } + } + + return _DrawImageWithAlpha(dstImage, xDest, yDest, srcImage, constantAlpha); +} diff --git a/src/graphics/effect/FGrp_EffectFlip.cpp b/src/graphics/effect/FGrp_EffectFlip.cpp new file mode 100644 index 0000000..3f6e7b0 --- /dev/null +++ b/src/graphics/effect/FGrp_EffectFlip.cpp @@ -0,0 +1,117 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_EffectFlip.cpp + * @brief This is the header file for internal utility class. + * + */ + +#include +#include +#include + +#include + +#include "FGrp_Effect.h" + + +using namespace Tizen::Graphics; + + +template +_Util::Pixmap* +CreateFlippedImage(int width, int height, int pitch, Pixel* pSour, _Effect::Flip flip) +{ + std::auto_ptr <_Util::Pixmap> dstImage(new (std::nothrow) _Util::Pixmap(width, height, sizeof(Pixel) * 8)); + + SysTryReturn(NID_GRP, dstImage.get(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + Pixel* pDest = (Pixel*) dstImage->pBitmap; + + if (pDest == null) + { + return null; + } + + switch (flip) + { + case _Effect::FLIP_VERTICAL: + { + pSour += height * pitch; + + for (int y = 0; y < height; y++) + { + pSour -= pitch; + memcpy(pDest, pSour, width * sizeof(Pixel)); + pDest += width; + } + } + break; + + case _Effect::FLIP_HORIZONTAL: + { + pSour += (pitch - 1); + + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + *pDest++ = *pSour--; + } + + pSour += (pitch << 1); + } + } + break; + + default: + // assertion + return null; + } + + return dstImage.release(); +} + + +_Util::Pixmap* +Tizen::Graphics::_Effect::GetFlippedImage(const _Util::Pixmap& srcImage, Flip flip) +{ + { + if ((srcImage.width <= 0) || (srcImage.height <= 0) || (srcImage.pBitmap == null)) + { + return 0; + } + } + + if (srcImage.depth == 32) + { + return CreateFlippedImage(srcImage.width, srcImage.height, srcImage.bytesPerLine * 8 / srcImage.depth, + (unsigned long*) srcImage.pBitmap, + flip); + } + else if (srcImage.depth == 16) + { + return CreateFlippedImage(srcImage.width, srcImage.height, srcImage.bytesPerLine * 8 / srcImage.depth, + (unsigned short*) srcImage.pBitmap, + flip); + } + else + { + return 0; + } +} diff --git a/src/graphics/effect/FGrp_EffectFunc.h b/src/graphics/effect/FGrp_EffectFunc.h new file mode 100644 index 0000000..8b180df --- /dev/null +++ b/src/graphics/effect/FGrp_EffectFunc.h @@ -0,0 +1,377 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_EffectFunc.h + * @brief This is the header file for internal utility class. + * + */ + +#ifndef _FGRP_INTERNAL_EFFECT_FUNC_H_ +#define _FGRP_INTERNAL_EFFECT_FUNC_H_ + +namespace Tizen { namespace Graphics +{ + +namespace _Effect +{ + +//////////////////////////////////////////////////////////////////////////////// +// alpha blending rule + +template +inline T +_LocalMin(T a, T b) +{ + return (a < b) ? a : b; +} + +// 'Add' rule is more intuitive for 32-bit alpha +template +inline T +_BlendAlphaComponent(T srcA, T dstA) +{ + return _LocalMin((srcA) + (dstA), 0xFF); +} + +// general rule. The attenuation occurs for destination alpha +// Ad = As + Ad * (1-As) +template +inline T +_BlendAlphaComponent2(T srcA, T dstA) +{ + return ((srcA) + (((dstA) * (255 - (srcA))) >> 8)); +} + +template +inline T +_BlendAlphaComponent3(T srcA, T dstA) +{ + return (((dstA) + ((((srcA) - (dstA)) * (srcA)) >> 8)) & 0xFF); +} + + +namespace Func +{ + +//////////////////////////////////////////////////////////////////////////// +// template AlphaBlending() + +template +inline DestPixel +AlphaBlending(DestPixel dest, SourPixel sour, DestPixel ca) +{ + // assert(false); +} + +template<> +inline unsigned long AlphaBlending (unsigned long dest, unsigned long sour, unsigned long ca) +{ + typedef unsigned long DestPixel; + typedef unsigned long SourPixel; + + DestPixel srcA = ca * (sour >> 24) >> 8; + DestPixel srcR = sour & 0x00FF0000; + DestPixel srcG = sour & 0x0000FF00; + DestPixel srcB = sour & 0x000000FF; + + DestPixel dstA = (dest & 0xFF000000) >> 24; + DestPixel dstR = dest & 0x00FF0000; + DestPixel dstG = dest & 0x0000FF00; + DestPixel dstB = dest & 0x000000FF; + + dstA = _BlendAlphaComponent(srcA, dstA); + srcA += (srcA >> 7); + dstR = (dstR + (((srcR - dstR) * srcA) >> 8)) & 0x00FF0000; + dstG = (dstG + (((srcG - dstG) * srcA) >> 8)) & 0x0000FF00; + dstB = (dstB + (((srcB - dstB) * srcA) >> 8)) & 0x000000FF; + dstA = (dstA > 0xFF) ? 0xFF : dstA; + + return (dstA << 24) | dstR | dstG | dstB; +} + +template<> +inline unsigned long AlphaBlending (unsigned long dest, unsigned short sour, unsigned long srcA) +{ + typedef unsigned long DestPixel; + typedef unsigned short SourPixel; + + DestPixel srcR = sour & 0xF800; + srcR = (srcR << 8 | srcR << 3) & 0x00FF0000; + DestPixel srcG = sour & 0x07E0; + srcG = (srcG << 5 | srcG >> 1) & 0x0000FF00; + DestPixel srcB = sour & 0x001F; + srcB = (srcB << 3 | srcB >> 2) & 0x000000FF; + + DestPixel dstA = (dest & 0xFF000000) >> 24; + DestPixel dstR = dest & 0x00FF0000; + DestPixel dstG = dest & 0x0000FF00; + DestPixel dstB = dest & 0x000000FF; + + dstA = _BlendAlphaComponent(srcA, dstA); + dstR = (dstR + (((srcR - dstR) * srcA) >> 8)) & 0x00FF0000; + dstG = (dstG + (((srcG - dstG) * srcA) >> 8)) & 0x0000FF00; + dstB = (dstB + (((srcB - dstB) * srcA) >> 8)) & 0x000000FF; + dstA = (dstA > 0xFF) ? 0xFF : dstA; + + return (dstA << 24) | dstR | dstG | dstB; +} + +template<> +inline unsigned short AlphaBlending (unsigned short dest, unsigned short sour, unsigned short ca) +{ + typedef unsigned short DestPixel; + typedef unsigned short SourPixel; + + DestPixel srcR = (sour >> 11) & 0x001F; + DestPixel srcG = (sour >> 5) & 0x003F; + DestPixel srcB = (sour) & 0x001F; + + DestPixel dstR = (dest >> 11) & 0x001F; + DestPixel dstG = (dest >> 5) & 0x003F; + DestPixel dstB = (dest) & 0x001F; + + dstR = (dstR + (((srcR - dstR) * ca) >> 8)) & 0x001F; + dstG = (dstG + (((srcG - dstG) * ca) >> 8)) & 0x003F; + dstB = (dstB + (((srcB - dstB) * ca) >> 8)) & 0x001F; + + return DestPixel((dstR << 11) | (dstG << 5) | dstB); +} + +template<> +inline unsigned short AlphaBlending (unsigned short dest, unsigned long sour, unsigned short ca) +{ + typedef unsigned short DestPixel; + typedef unsigned long SourPixel; + + DestPixel srcA = DestPixel(ca * (sour >> 24) >> 8); + DestPixel srcR = DestPixel((sour & 0x00F80000) >> 19); + DestPixel srcG = DestPixel((sour & 0x0000FC00) >> 10); + DestPixel srcB = DestPixel((sour & 0x000000F8) >> 3); + + DestPixel dstR = (dest >> 11) & 0x001F; + DestPixel dstG = (dest >> 5) & 0x003F; + DestPixel dstB = (dest) & 0x001F; + + dstR = (dstR + (((srcR - dstR) * srcA) >> 8)) & 0x001F; + dstG = (dstG + (((srcG - dstG) * srcA) >> 8)) & 0x003F; + dstB = (dstB + (((srcB - dstB) * srcA) >> 8)) & 0x001F; + + return DestPixel((dstR << 11) | (dstG << 5) | dstB); +} + +//////////////////////////////////////////////////////////////////////////// +// template AlphaBlendingFast() + +template +inline DestPixel +AlphaBlendingFast(DestPixel dest, SourPixel sour) +{ + return (DestPixel) sour; +} + +template<> +inline unsigned long AlphaBlendingFast (unsigned long dest, unsigned long sour) +{ + typedef unsigned long DestPixel; + typedef unsigned long SourPixel; + + DestPixel srcA = sour >> 24; + DestPixel srcR = sour & 0x00FF0000; + DestPixel srcG = sour & 0x0000FF00; + DestPixel srcB = sour & 0x000000FF; + + DestPixel dstA = (dest & 0xFF000000) >> 24; + DestPixel dstR = dest & 0x00FF0000; + DestPixel dstG = dest & 0x0000FF00; + DestPixel dstB = dest & 0x000000FF; + + dstA = _BlendAlphaComponent(srcA, dstA); + srcA += (srcA >> 7); + dstR = (dstR + (((srcR - dstR) * srcA) >> 8)) & 0x00FF0000; + dstG = (dstG + (((srcG - dstG) * srcA) >> 8)) & 0x0000FF00; + dstB = (dstB + (((srcB - dstB) * srcA) >> 8)) & 0x000000FF; + dstA = (dstA > 0xFF) ? 0xFF : dstA; + + return (dstA << 24) | dstR | dstG | dstB; +} + +template<> +inline unsigned long AlphaBlendingFast (unsigned long dest, unsigned short sour) +{ + typedef unsigned short SourPixel; + typedef unsigned long DestPixel; + + { + DestPixel r = (sour & 0xF800) >> 8; + DestPixel g = (sour & 0x07E0) >> 3; + DestPixel b = (sour & 0x001F) << 3; + + r += (r >> 5); + g += (g >> 6); + b += (b >> 5); + + return (0xFF000000 | (r << 16) | (g << 8) | (b)); + } +} + +template<> +inline unsigned short AlphaBlendingFast (unsigned short dest, unsigned long sour) +{ + typedef unsigned short DestPixel; + typedef unsigned long SourPixel; + + DestPixel srcA = DestPixel((sour >> 24)); + DestPixel srcR = DestPixel((sour & 0x00F80000) >> 19); + DestPixel srcG = DestPixel((sour & 0x0000FC00) >> 10); + DestPixel srcB = DestPixel((sour & 0x000000F8) >> 3); + + DestPixel dstR = (dest >> 11) & 0x001F; + DestPixel dstG = (dest >> 5) & 0x003F; + DestPixel dstB = (dest) & 0x001F; + + srcA += (srcA >> 7); + + dstR = (dstR + (((srcR - dstR) * srcA) >> 8)) & 0x001F; + dstG = (dstG + (((srcG - dstG) * srcA) >> 8)) & 0x003F; + dstB = (dstB + (((srcB - dstB) * srcA) >> 8)) & 0x001F; + + return DestPixel((dstR << 11) | (dstG << 5) | dstB); +} + +//////////////////////////////////////////////////////////////////////////// +// template ConvertColorFormat() + +template +inline void +ConvertColorFormatFast(DestPixel* pDest, SourPixel* pSour) +{ + *pDest = *pSour; +} + +template<> +inline void +ConvertColorFormatFast(unsigned long* pDest, unsigned short* pSour) +{ + typedef unsigned short SourPixel; + typedef unsigned long DestPixel; + + { + DestPixel r = (*pSour & 0xF800) >> 8; + DestPixel g = (*pSour & 0x07E0) >> 3; + DestPixel b = (*pSour & 0x001F) << 3; + + r += (r >> 5); + g += (g >> 6); + b += (b >> 5); + + *pDest = 0xFF000000 | (r << 16) | (g << 8) | (b); + } +} + +template<> +inline void +ConvertColorFormatFast(unsigned short* pDest, unsigned long* pSour) +{ + typedef unsigned long SourPixel; + typedef unsigned short DestPixel; + + { + DestPixel r = (DestPixel) ((*pSour & 0xF80000) >> 8); + DestPixel g = (DestPixel) ((*pSour & 0x00FC00) >> 5); + DestPixel b = (DestPixel) ((*pSour & 0x0000F8) >> 3); + + *pDest = r | g | b; + } +} + +template +inline DestPixel* +ConvertColorFormat(DestPixel* pDest, SourPixel* pSour, int count) +{ + DestPixel* pDestEnd = pDest + count; + + while (pDest < pDestEnd) + { + *pDest++ = *pSour++; + } + + return pDestEnd; +} + +template<> +inline unsigned long* +ConvertColorFormat(unsigned long* pDest, unsigned short* pSour, int count) +{ + typedef unsigned short SourPixel; + typedef unsigned long DestPixel; + + DestPixel* pDestEnd = pDest + count; + + while (pDest < pDestEnd) + { + DestPixel r = (*pSour & 0xF800) >> 8; + DestPixel g = (*pSour & 0x07E0) >> 3; + DestPixel b = (*pSour & 0x001F) << 3; + + r += (r >> 5); + g += (g >> 6); + b += (b >> 5); + + *pDest++ = 0xFF000000 | (r << 16) | (g << 8) | (b); + ++pSour; + } + + return pDestEnd; +} + +template<> +inline unsigned short* +ConvertColorFormat(unsigned short* pDest, unsigned long* pSour, int count) +{ + typedef unsigned long SourPixel; + typedef unsigned short DestPixel; + + DestPixel* pDestEnd = pDest + count; + + while (pDest < pDestEnd) + { + DestPixel r = (DestPixel) ((*pSour & 0xF80000) >> 8); + DestPixel g = (DestPixel) ((*pSour & 0x00FC00) >> 5); + DestPixel b = (DestPixel) ((*pSour & 0x0000F8) >> 3); + + *pDest++ = r | g | b; + ++pSour; + } + + return pDestEnd; +} + +} // namespace Func + +} // _Effect + +}} // Tizen::Graphics + +#endif // #ifndef _FGRP_INTERNAL_EFFECT_FUNC_H_ diff --git a/src/graphics/effect/FGrp_EffectManip.cpp b/src/graphics/effect/FGrp_EffectManip.cpp new file mode 100644 index 0000000..abc4568 --- /dev/null +++ b/src/graphics/effect/FGrp_EffectManip.cpp @@ -0,0 +1,181 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_EffectManip.cpp + * @brief This is the header file for internal utility class. + * + */ + +#include "FGrp_EffectFunc.h" +#include "FGrp_Effect.h" + +using namespace Tizen::Graphics; + + +namespace // unnamed +{ + +template +struct _NinePatchedKey +{ +}; + +template<> +struct _NinePatchedKey +{ + enum + { + KEY = 0xFF000000 + }; +}; + +template<> +struct _NinePatchedKey +{ + enum + { + KEY = 0x0000 + }; +}; + +template +bool +_IsNinePatched(const _Util::Pixmap& dstImage, Pixel dummy) +{ + enum + { + KEY = _NinePatchedKey ::KEY + }; + + // assert(dstImage.depth == sizeof(Pixel)*8); + + if (dstImage.depth != sizeof(Pixel) * 8) + { + return false; + } + + // verify horizontal line + { + bool found = false; + + Pixel* pProbe = (Pixel*) (dstImage.pBitmap); + Pixel* pProbeEnd = pProbe + dstImage.width; + + while (!found && (pProbe < pProbeEnd)) + { + found = (*pProbe++ == KEY); + } + + if (!found) + { + return false; + } + } + + // verify vertical line + { + bool found = false; + + int pitch = dstImage.bytesPerLine / (dstImage.depth / 8); + + Pixel* pProbe = (Pixel*) (dstImage.pBitmap); + Pixel* pProbeEnd = pProbe + dstImage.height * pitch; + + while (!found && (pProbe < pProbeEnd)) + { + found = (*pProbe == KEY); + pProbe += pitch; + } + + if (!found) + { + return false; + } + } + + return true; +} + +} + + +bool +Tizen::Graphics::_Effect::IsNinePatchedBitmap(const _Util::Pixmap& dstImage) +{ + // verifiy the spcified parameters + { + if ((dstImage.width <= 0) || (dstImage.height <= 0) || (dstImage.pBitmap == null)) + { + return false; + } + } + + switch (dstImage.depth) + { + case 32: + return _IsNinePatched (dstImage, 0); + case 16: + return _IsNinePatched (dstImage, 0); + default: + return false; + } +} + +bool +Tizen::Graphics::_Effect::IsOpaqueAllOver(const _Util::Pixmap& dstImage) +{ + // it returns true as default + { + if ((dstImage.width <= 0) || (dstImage.height <= 0) || (dstImage.pBitmap == null)) + { + return true; + } + } + + switch (dstImage.depth) + { + case 32: + { + typedef unsigned long Pixel; + + bool found = false; + + for (int y = 0; y < dstImage.height; y++) + { + Pixel* pProbe = (Pixel*) (dstImage.pBitmap + dstImage.bytesPerLine * y); + Pixel* pProbeEnd = pProbe + dstImage.width; + + while (!found && (pProbe < pProbeEnd)) + { + found = (((*pProbe++) >> 24) < 0xFF); + } + + if (found) + { + return false; + } + } + + return true; + } + break; + case 16: + default: + return true; + } +} diff --git a/src/graphics/effect/FGrp_EffectRotate.cpp b/src/graphics/effect/FGrp_EffectRotate.cpp new file mode 100644 index 0000000..d72838c --- /dev/null +++ b/src/graphics/effect/FGrp_EffectRotate.cpp @@ -0,0 +1,909 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_EffectRotate.cpp + * @brief This is the header file for internal utility class. + * + */ + +#include +#include +#include + +#include + +#include + +#include "FGrp_EffectFunc.h" +#include "FGrp_Effect.h" +#include "../util/FGrp_UtilType.h" + +using namespace Tizen::Graphics; + +//////////////////////////////////////////////////////////////////////////////// +// data type + +#if 1 + // _RealDataType as a floating point + typedef float _RealDataType; +#else + // _RealDataType as a fixed point + typedef long _RealDataType; +#endif + +//////////////////////////////////////////////////////////////////////////////// +// definition + +namespace // unnamed +{ + +namespace _RealNumber +{ + +template +inline T +Assign(float f) +{ + // Empty statement +} + +template +inline T +AssignShift(int i) +{ + // Empty statement +} + +template +inline int +CastInt(T i) +{ + return int(i); +} + +template +inline T +MultiplySmall(T first, T second) +{ + // Empty statement +} + +template +inline T +MultiplyBig(T first, T second) +{ + // Empty statement +} + +template +inline T +DivideSmall(T first, T second) +{ + // Empty statement +} + +template +inline T +DivideBig(T first, T second) +{ + // Empty statement +} + +template +inline T +Divide3(T first, T second, T third) +{ + // Empty statement +} + +template +inline float +Dispatch(T i) +{ + return float(i); +} + +template +inline T +Sin(T degree) +{ + // Empty statement +} + +template +inline T +Cos(T degree) +{ + // Empty statement +} + +} // namespace _RealNumber + +// specialization for float type +namespace _RealNumber +{ +const float _FLOAT_PI = 3.141592f; + +template <> +inline float +Assign(float f) +{ + return f; +} + +template <> +inline float +AssignShift(int i) +{ + return float(i); +} + +template <> +inline int +CastInt(float i) +{ + return int((i > 0.0f) ? (i + 0.5f) : (i - 0.5f)); +} + +template <> +inline float +MultiplySmall(float first, float second) +{ + return first * second; +} + +template <> +inline float +MultiplyBig(float first, float second) +{ + return first * second; +} + +template <> +inline float +DivideSmall(float first, float second) +{ + return first / second; +} + +template <> +inline float +DivideBig(float first, float second) +{ + return first / second; +} + +template <> +inline float +Divide3(float first, float second, float third) +{ + return first / second / third; +} + +template <> +inline float +Dispatch(float i) +{ + return i; +} + +template <> +inline float +Sin(float degree) +{ + return float(sinf(degree * _FLOAT_PI / 180.0f)); +} + +template <> +inline float +Cos(float degree) +{ + return float(cosf(degree * _FLOAT_PI / 180.0f)); +} + +} // namespace _RealNumber + +// specialization for long type +namespace _RealNumber +{ +const int _FPFLOAT_SHIFT = 10; +const int _FPFLOAT_SHIFT_HIGH = 5; +const int _FPFLOAT_SHIFT_LOW = 5; +const int _FPFLOAT_MUL_VALUE = 1024; + +template <> +inline long +Assign(float f) +{ + return long((f) * _FPFLOAT_MUL_VALUE); +} + +template <> +inline long +AssignShift(int i) +{ + return long((i) << _FPFLOAT_SHIFT); +} + +template <> +inline int +CastInt(long i) +{ + return (i + (1 << (_FPFLOAT_SHIFT - 1))) >> _FPFLOAT_SHIFT; +} + +template <> +inline long +MultiplySmall(long first, long second) +{ + return (first * second) >> _FPFLOAT_SHIFT; +} + +template <> +inline long +MultiplyBig(long first, long second) +{ + return (first >> _FPFLOAT_SHIFT_HIGH) * (second >> _FPFLOAT_SHIFT_LOW); +} + +template <> +inline long +DivideSmall(long first, long second) +{ + return (first << _FPFLOAT_SHIFT) / second; +} + +template <> +inline long +DivideBig(long first, long second) +{ + return (first << _FPFLOAT_SHIFT_HIGH) / (second >> _FPFLOAT_SHIFT_LOW); +} + +template <> +inline long +Divide3(long first, long second, long third) +{ + return DivideSmall(DivideBig(first, second), third); +} + +template <> +inline float +Dispatch(long i) +{ + return float(i) / float(_FPFLOAT_MUL_VALUE); +} + +int SinX16(int degree); +int CosX16(int degree); + +template <> +inline long +Sin(long degree) +{ + // 16 was value that we shifted in a sine table + int n = _FPFLOAT_SHIFT - 16; + + return (n >= 0) ? (SinX16(CastInt(degree)) << n) : (SinX16(CastInt(degree)) >> (-n)); +} + +template <> +inline long +Cos(long degree) +{ + // 16 was value that we shifted in a sine table + int n = _RealNumber::_FPFLOAT_SHIFT - 16; + + return (n >= 0) ? (CosX16(CastInt(degree)) << n) : (CosX16(CastInt(degree)) >> (-n)); +} + +const int SIN_TABLE_X16[] = // 91 items +{ + 0, // 0.000000 + 1144, // 0.017452 + 2287, // 0.034899 + 3430, // 0.052336 + 4572, // 0.069756 + 5712, // 0.087156 + 6850, // 0.104528 + 7987, // 0.121869 + 9121, // 0.139173 + 10252, // 0.156434 + 11380, // 0.173648 + 12505, // 0.190809 + 13626, // 0.207912 + 14742, // 0.224951 + 15855, // 0.241922 + 16962, // 0.258819 + 18064, // 0.275637 + 19161, // 0.292372 + 20252, // 0.309017 + 21336, // 0.325568 + 22415, // 0.342020 + 23486, // 0.358368 + 24550, // 0.374607 + 25607, // 0.390731 + 26656, // 0.406737 + 27697, // 0.422618 + 28729, // 0.438371 + 29753, // 0.453990 + 30767, // 0.469472 + 31772, // 0.484810 + 32768, // 0.500000 + 33754, // 0.515038 + 34729, // 0.529919 + 35693, // 0.544639 + 36647, // 0.559193 + 37590, // 0.573576 + 38521, // 0.587785 + 39441, // 0.601815 + 40348, // 0.615661 + 41243, // 0.629320 + 42126, // 0.642788 + 42995, // 0.656059 + 43852, // 0.669131 + 44695, // 0.681998 + 45525, // 0.694658 + 46341, // 0.707107 + 47143, // 0.719340 + 47930, // 0.731354 + 48703, // 0.743145 + 49461, // 0.754710 + 50203, // 0.766044 + 50931, // 0.777146 + 51643, // 0.788011 + 52339, // 0.798636 + 53020, // 0.809017 + 53684, // 0.819152 + 54332, // 0.829038 + 54963, // 0.838671 + 55578, // 0.848048 + 56175, // 0.857167 + 56756, // 0.866025 + 57319, // 0.874620 + 57865, // 0.882948 + 58393, // 0.891007 + 58903, // 0.898794 + 59396, // 0.906308 + 59870, // 0.913545 + 60326, // 0.920505 + 60764, // 0.927184 + 61183, // 0.933580 + 61584, // 0.939693 + 61966, // 0.945519 + 62328, // 0.951057 + 62672, // 0.956305 + 62997, // 0.961262 + 63303, // 0.965926 + 63589, // 0.970296 + 63856, // 0.974370 + 64104, // 0.978148 + 64332, // 0.981627 + 64540, // 0.984808 + 64729, // 0.987688 + 64898, // 0.990268 + 65048, // 0.992546 + 65177, // 0.994522 + 65287, // 0.996195 + 65376, // 0.997564 + 65446, // 0.998630 + 65496, // 0.999391 + 65526, // 0.999848 + 65536 // 1.000000 +}; + +int +SinX16(int degree) +{ + if ((degree %= 360) < 0) + { + degree += 360; + } + + switch (degree / 90) + { + case 0: + return SIN_TABLE_X16[degree]; + case 1: + return SIN_TABLE_X16[180 - degree]; + case 2: + return -SIN_TABLE_X16[degree - 180]; + default: + return -SIN_TABLE_X16[360 - degree]; + } +} + +int +CosX16(int degree) +{ + return SinX16(degree + 90); +} + +} // namespace _RealNumber + + +template +inline T +_Abs(T a) +{ + return (a >= 0) ? a : -a; +} + +template +inline T +_Sign(T a) +{ + return (a >= 0) ? ((a > 0) ? 1 : 0) : -1; +} + +struct _Point +{ + int x; + int y; + + _Point() + : x(0) + , y(0) + { + } + + _Point(int _x, int _y) + : x(_x) + , y(_y) + { + } +}; + +void +_DrawVirtualLineToArray(int x1, int y1, int x2, int y2, long yLineArrayLeft[], long yLineArrayRight[], _Point minPos, + _Point maxPos) +{ + _Point delta(_Abs(x2 - x1), _Abs(y2 - y1)); + _Point increase(_Sign(x2 - x1), _Sign(y2 - y1)); + _Point pos(0, 0); + + int distance = _Util::Max(delta.x, delta.y); + + for (int i = 0; i <= distance; i++) + { + pos.x += delta.x; + pos.y += delta.y; + + if (pos.x > distance) + { + x1 += increase.x; + pos.x -= distance; + } + + if (pos.y > distance) + { + y1 += increase.y; + pos.y -= distance; + } + + if ((y1 < minPos.y) || (y1 > maxPos.y)) + { + continue; + } + + if (x1 < yLineArrayLeft[y1 - minPos.y]) + { + yLineArrayLeft[y1 - minPos.y] = (x1 < minPos.x) ? minPos.x : ((x1 > maxPos.x) ? maxPos.x : x1); + } + + if (x1 > yLineArrayRight[y1 - minPos.y]) + { + yLineArrayRight[y1 - minPos.y] = (x1 > maxPos.x) ? maxPos.x : ((x1 < minPos.x) ? minPos.x : x1); + } + } +} + +template +bool +_RotateImage(_Util::Pixmap& dstImage, long x, long y, const _Util::Pixmap& srcImage, long width, long height, + const _Effect::RotateDesc& rotateDesc, DestPixel opacity, + SourPixel dummy = 0) +{ + _Util::Bounds clipRect = { 0, 0, dstImage.width, dstImage.height }; + + long angle = rotateDesc.angle; + + // 'angle' will be between 1 and 360 + { + angle += 180; + + while (angle < 0) + { + angle += 360; + } + + while (angle >= 360) + { + angle -= 360; + } + + // convert to CCW + angle = 360 - angle; + } + + // the converted angle for the input angle becomes as follows + // + // 0 -> 180 + // 10 -> 170 + // 90 -> 90 + // 100 -> 80 + // 180 -> 360 + // 190 -> 350 + // 270 -> 270 + // 280 -> 260 + + // if (angle == 0) then draw bitmap normally, but... + + _RealDataType sinVal = _RealNumber::Sin(_RealNumber::AssignShift<_RealDataType>(angle)); + _RealDataType cosVal = _RealNumber::Cos(_RealNumber::AssignShift<_RealDataType>(angle)); + + _Point vertex[4]; + + // center -> (x,y) + { + _RealDataType wSinP = sinVal * (-rotateDesc.xOffset); + _RealDataType wCosP = cosVal * (-rotateDesc.xOffset); + _RealDataType hSinP = sinVal * (-rotateDesc.yOffset); + _RealDataType hCosP = cosVal * (-rotateDesc.yOffset); + _RealDataType wSinM = sinVal * (width - rotateDesc.xOffset); + _RealDataType wCosM = cosVal * (width - rotateDesc.xOffset); + _RealDataType hSinM = sinVal * (height - rotateDesc.yOffset); + _RealDataType hCosM = cosVal * (height - rotateDesc.yOffset); + + vertex[0].x = x - _RealNumber::CastInt((wCosM) - (hSinP)); + vertex[1].x = x - _RealNumber::CastInt((wCosP) - (hSinP)); + vertex[2].x = x - _RealNumber::CastInt((wCosM) - (hSinM)); + vertex[3].x = x - _RealNumber::CastInt((wCosP) - (hSinM)); + + vertex[0].y = y - _RealNumber::CastInt((wSinM) + (hCosP)); + vertex[1].y = y - _RealNumber::CastInt((wSinP) + (hCosP)); + vertex[2].y = y - _RealNumber::CastInt((wSinM) + (hCosM)); + vertex[3].y = y - _RealNumber::CastInt((wSinP) + (hCosM)); + + /* meaning of 'vertex', if 'angle' is 180 + + v[1] width v[0] + *---------------* + | | + | . | height + | (x,y) | + | | + *---------------* + v[3] v[2] + + + if 'xOffset' and 'yOffset' are 0, + + v[1] v[0] + *---------------* + |(x,y) | + | | + | | + | | + *---------------* + v[3] v[2] + */ + } + + // find a maximum value and minimum value of rotated image on y-axis + int left = 0; + int right = dstImage.width - 0; + int top = vertex[3].y; + int bottom = vertex[3].y; + + // find a maximum value and minimum value for all vertices + top = _Util::Min(top, vertex[2].y); + bottom = _Util::Max(bottom, vertex[2].y); + top = _Util::Min(top, vertex[1].y); + bottom = _Util::Max(bottom, vertex[1].y); + top = _Util::Min(top, vertex[0].y); + bottom = _Util::Max(bottom, vertex[0].y); + + // apply clipping + top = _Util::Max(top, clipRect.y1); + bottom = _Util::Min(bottom, clipRect.y2 - 0); + + // number of pixels for vertical region + int numVerticalPixel = bottom - top + 1; + + // no need to draw + if (numVerticalPixel <= 0) + { + return true; + } + + std::unique_ptr tempLeftVertices(new (std::nothrow) long[numVerticalPixel]); + std::unique_ptr tempRightVertices(new (std::nothrow) long[numVerticalPixel]); + + SysTryReturn(NID_GRP, tempLeftVertices && tempRightVertices, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + // left <- max value of 'x', right <- min value of 'x' + memset(tempRightVertices.get(), 0x80, numVerticalPixel * sizeof(long)); + memset(tempLeftVertices.get(), 0x7F, numVerticalPixel * sizeof(long)); + + // prepare to draw horizontal lines. 4 lines as input + _DrawVirtualLineToArray(vertex[0].x, vertex[0].y, vertex[1].x, vertex[1].y, tempLeftVertices.get(), + tempRightVertices.get(), _Point(left, top), _Point(right, bottom)); + _DrawVirtualLineToArray(vertex[0].x, vertex[0].y, vertex[2].x, vertex[2].y, tempLeftVertices.get(), + tempRightVertices.get(), _Point(left, top), _Point(right, bottom)); + _DrawVirtualLineToArray(vertex[1].x, vertex[1].y, vertex[3].x, vertex[3].y, tempLeftVertices.get(), + tempRightVertices.get(), _Point(left, top), _Point(right, bottom)); + _DrawVirtualLineToArray(vertex[3].x, vertex[3].y, vertex[2].x, vertex[2].y, tempLeftVertices.get(), + tempRightVertices.get(), _Point(left, top), _Point(right, bottom)); + + // memory buffer pointer & pitch of source + SourPixel* pSour = (SourPixel*) (srcImage.pBitmap); + int srcPitch = srcImage.bytesPerLine * 8 / srcImage.depth; + + // memory buffer pointer & pitch of destination + DestPixel* pDest = (DestPixel*) dstImage.pBitmap; + int dstPitch = dstImage.bytesPerLine * 8 / dstImage.depth; + + // scale + _RealDataType xScale = _RealNumber::DivideBig(_RealNumber::AssignShift<_RealDataType>(srcImage.width), _RealNumber::AssignShift<_RealDataType>(width)); + _RealDataType yScale = _RealNumber::DivideBig(_RealNumber::AssignShift<_RealDataType>(srcImage.height), _RealNumber::AssignShift<_RealDataType>(height)); + + // for clippping of source image + int maxSrcWidth = srcImage.width - 1; + int maxSrcHeight = srcImage.height - 1; + + // current position to the set of vertical vertices + long* pLeftVertices = tempLeftVertices.get(); + long* pRightVertices = tempRightVertices.get(); + + // draw horizontal linetop from top to bottom + for (long scanline = top; scanline < bottom; ++scanline) + { + // out-of-clip test of 'y' + if (scanline >= clipRect.y2) + { + break; + } + + // skipping of 'y' for out-of-clip + if (scanline < clipRect.y1) + { + ++pLeftVertices; + ++pRightVertices; + + continue; + } + + long leftVertex = *pLeftVertices++; + long rightVertex = *pRightVertices++; + long distVertex = rightVertex - leftVertex; + + int srcLeftVertexX = _RealNumber::CastInt(-(cosVal * (leftVertex - x)) - (sinVal * (scanline - y))); + int srcLeftVertexY = _RealNumber::CastInt((sinVal * (leftVertex - x)) - (cosVal * (scanline - y))); + + int srcRightVertexX = _RealNumber::CastInt(-(cosVal * (rightVertex - x)) - (sinVal * (scanline - y))); + int srcRightVertexY = _RealNumber::CastInt((sinVal * (rightVertex - x)) - (cosVal * (scanline - y))); + + _Point delta((srcRightVertexX - srcLeftVertexX), (srcRightVertexY - srcLeftVertexY)); + + if (distVertex > 0) + { + int rsx, rsy; + + _RealDataType rdx = delta.x * xScale / distVertex; + _RealDataType rdy = delta.y * yScale / distVertex; + + int pixel = leftVertex - 1; + int count = distVertex; // + 1; + + { + _RealDataType sx = srcLeftVertexX * xScale + _RealNumber::AssignShift<_RealDataType>(rotateDesc.xOffset); + _RealDataType sy = srcLeftVertexY * yScale + _RealNumber::AssignShift<_RealDataType>(rotateDesc.yOffset); + + sx -= rdx; + sy -= rdy; + + if (srcImage.enableColorKey) + { + SourPixel colorKey = (SourPixel) srcImage.colorKey; + + while (count--) + { + pixel++; + + sx += rdx; + sy += rdy; + + // round off + rsx = _RealNumber::CastInt(sx + _RealNumber::Assign<_RealDataType>(0.49f)); + rsy = _RealNumber::CastInt(sy + _RealNumber::Assign<_RealDataType>(0.49f)); + + rsx = _Util::Max(rsx, 0); + rsx = _Util::Min(rsx, maxSrcWidth); + + rsy = _Util::Max(rsy, 0); + rsy = _Util::Min(rsy, maxSrcHeight); + + if (clipRect.IsInsideX(pixel)) + { + if (colorKey != pSour[rsy * srcPitch + rsx]) + { + // pDest[scanline * dstPitch + pixel] = pSour[rsy * srcPitch + rsx]; + pDest[scanline * dstPitch + pixel] = + _Effect::Func::AlphaBlending + (pDest[scanline * dstPitch + pixel] + , pSour[rsy * srcPitch + rsx] + , DestPixel(opacity)); + } + } + } + } + else + { + while (count--) + { + pixel++; + + sx += rdx; + sy += rdy; + + // round off + rsx = _RealNumber::CastInt(sx + _RealNumber::Assign<_RealDataType>(0.49f)); + rsy = _RealNumber::CastInt(sy + _RealNumber::Assign<_RealDataType>(0.49f)); + + rsx = _Util::Max(rsx, 0); + rsx = _Util::Min(rsx, maxSrcWidth); + + rsy = _Util::Max(rsy, 0); + rsy = _Util::Min(rsy, maxSrcHeight); + + if (clipRect.IsInsideX(pixel)) + { + // pDest[scanline * dstPitch + pixel] = pSour[rsy * srcPitch + rsx]; + pDest[scanline * dstPitch + pixel] = + _Effect::Func::AlphaBlending + (pDest[scanline * dstPitch + pixel] + , pSour[rsy * srcPitch + rsx] + , DestPixel(opacity)); + } + } + } + } + } + } + + return true; +} + +//////////////////////////////////////////////////////////////////////////// +// inline wrapper function for VC++ 6.0 compatibility + +inline bool +_RotateImage16bitsFrom16bits(_Util::Pixmap& dstImage, long x, long y, const _Util::Pixmap& srcImage, long width, long height, + const _Effect::RotateDesc& rotateDesc, short constantAlpha) +{ + return _RotateImage (dstImage, x, y, srcImage, width, height, rotateDesc, constantAlpha, 0); +} + +inline bool +_RotateImage16bitsFrom32bits(_Util::Pixmap& dstImage, long x, long y, const _Util::Pixmap& srcImage, long width, long height, + const _Effect::RotateDesc& rotateDesc, short constantAlpha) +{ + return _RotateImage (dstImage, x, y, srcImage, width, height, rotateDesc, constantAlpha, 0); +} + +inline bool +_RotateImage32bitsFrom16bits(_Util::Pixmap& dstImage, long x, long y, const _Util::Pixmap& srcImage, long width, long height, + const _Effect::RotateDesc& rotateDesc, long constantAlpha) +{ + return _RotateImage (dstImage, x, y, srcImage, width, height, rotateDesc, constantAlpha, 0); +} + +inline bool +_RotateImage32bitsFrom32bits(_Util::Pixmap& dstImage, long x, long y, const _Util::Pixmap& srcImage, long width, long height, + const _Effect::RotateDesc& rotateDesc, long constantAlpha) +{ + return _RotateImage (dstImage, x, y, srcImage, width, height, rotateDesc, constantAlpha, 0); +} + +} // namespce + +//////////////////////////////////////////////////////////////////////////////// +// public + +bool +Tizen::Graphics::_Effect::RotateImage(_Util::Pixmap& dstImage, long xDest, long yDest, const _Util::Pixmap& srcImage, + const _Effect::RotateDesc& rotateDesc, + long constantAlpha) +{ + // verifiy the spcified parameters + { + if ((srcImage.width < 0) || (srcImage.height < 0) || (srcImage.pBitmap == null)) + { + return false; + } + + if ((dstImage.width < 0) || (dstImage.height < 0) || (dstImage.pBitmap == null)) + { + return false; + } + + switch (dstImage.depth) + { + case 16: + case 32: + break; + default: + return false; + } + + // no need to draw + if (constantAlpha <= 0) + { + return true; + } + + if (constantAlpha > 255) + { + constantAlpha = 255; + } + + if (srcImage.pBitmap == dstImage.pBitmap) + { + return false; + } + } + + // clipping test + { + if ((srcImage.width == 0) || (srcImage.height == 0)) + { + return true; + } + + if ((dstImage.width == 0) || (dstImage.height == 0)) + { + return true; + } + } + + if (dstImage.depth == 16 && srcImage.depth == 16) + { + return _RotateImage16bitsFrom16bits(dstImage, xDest, yDest, srcImage, srcImage.width, srcImage.height, rotateDesc, + short(constantAlpha)); + } + else if (dstImage.depth == 16 && srcImage.depth == 32) + { + return _RotateImage16bitsFrom32bits(dstImage, xDest, yDest, srcImage, srcImage.width, srcImage.height, rotateDesc, + short(constantAlpha)); + } + else if (dstImage.depth == 32 && srcImage.depth == 16) + { + return _RotateImage32bitsFrom16bits(dstImage, xDest, yDest, srcImage, srcImage.width, srcImage.height, rotateDesc, + constantAlpha); + } + else if (dstImage.depth == 32 && srcImage.depth == 32) + { + return _RotateImage32bitsFrom32bits(dstImage, xDest, yDest, srcImage, srcImage.width, srcImage.height, rotateDesc, + constantAlpha); + } + + // assert(false); + + return false; +} diff --git a/src/graphics/effect/FGrp_EffectScale.cpp b/src/graphics/effect/FGrp_EffectScale.cpp new file mode 100644 index 0000000..2d56618 --- /dev/null +++ b/src/graphics/effect/FGrp_EffectScale.cpp @@ -0,0 +1,533 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_EffectScale.cpp + * @brief This is the header file for internal utility class. + * + */ + +#include + +#include + +#include "FGrp_EffectFunc.h" +#include "FGrp_Effect.h" +#include "../util/FGrp_Util.h" + +using namespace Tizen::Graphics; + + +namespace // unnamed +{ + +template +class _GenericBufferPixmap + : public _Util::GenericBufferBase +{ +public: + inline _GenericBufferPixmap(const _Util::PixmapBase& buffer, const _Util::Rectangle* pRect) + : _Util::GenericBufferBase () + , __buffer(buffer) + { + this->_pBuffer = (Pixel*) __buffer.pBitmap; + this->_pitch = __buffer.bytesPerLine / sizeof(Pixel); + + if (pRect) + { + this->_padding = this->_pitch - pRect->w; + this->_pBuffer += (this->_pitch * pRect->y + pRect->x); + this->_rect.x = pRect->x; + this->_rect.y = pRect->y; + this->_rect.w = pRect->w; + this->_rect.h = pRect->h; + } + else + { + this->_padding = this->_pitch - __buffer.width; + this->_rect.x = 0; + this->_rect.y = 0; + this->_rect.w = __buffer.width; + this->_rect.h = __buffer.height; + } + } + + inline virtual ~_GenericBufferPixmap(void) + { + } + +private: + const _Util::PixmapBase& __buffer; +}; + +typedef unsigned long FIXED16x16; + +template +bool +_ScaleImageUnclipped(_Util::PixmapBase* pRetImage, _Util::PixmapBase* pSrcImage, Pixel dummy = 0) +{ + if (pRetImage == null || pSrcImage == null) + { + return false; + } + + if ((pSrcImage->width <= 0) || (pSrcImage->height <= 0) + || (pRetImage->width <= 0) || (pRetImage->height <= 0)) + { + return true; + } + + _Util::GenericBuffer srcBuffer(new (std::nothrow) _GenericBufferPixmap (*pSrcImage, null)); + _Util::GenericBuffer dstBuffer(new (std::nothrow) _GenericBufferPixmap (*pRetImage, null)); + + SysTryReturn(NID_GRP, srcBuffer.IsValid() && dstBuffer.IsValid(), false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + FIXED16x16 xSour = 0; + FIXED16x16 ySour = 0; + FIXED16x16 wScale = FIXED16x16(srcBuffer.GetWidth() * 0x10000 / dstBuffer.GetWidth()); + FIXED16x16 hScale = FIXED16x16(srcBuffer.GetHeight() * 0x10000 / dstBuffer.GetHeight()); + FIXED16x16 temp; + + Pixel* pSour; + Pixel* pDest = dstBuffer.GetBufferAddr(); + + int wCopy; + int hCopy = dstBuffer.GetHeight(); + + while (--hCopy >= 0) + { + xSour = 0; + pSour = srcBuffer.GetBufferAddr() + int(ySour >> 16) * srcBuffer.GetPitch(); + wCopy = dstBuffer.GetWidth(); + + while (--wCopy >= 0) + { + *pDest++ = *pSour; + + temp = xSour; + xSour += wScale; + pSour += (int(xSour >> 16) - int(temp >> 16)); + } + + pDest += dstBuffer.GetPadding(); + ySour += hScale; + } + + return true; +} + +template +bool +_ScaleImageCopyClipped(_Util::PixmapBase* pRetImage, _Util::PixmapBase* pSrcImage, const _Util::Rectangle& validRect, + DestPixel dummy1 = 0, + SourPixel dummy2 = 0) +{ + if (pRetImage == null || pSrcImage == null) + { + return false; + } + + if ((pSrcImage->width <= 0) || (pSrcImage->height <= 0) + || (pRetImage->width <= 0) || (pRetImage->height <= 0)) + { + return true; + } + + _Util::GenericBuffer srcBuffer(new (std::nothrow) _GenericBufferPixmap (*pSrcImage, null)); + _Util::GenericBuffer dstBuffer(new (std::nothrow) _GenericBufferPixmap (*pRetImage, null)); + + SysTryReturn(NID_GRP, srcBuffer.IsValid() && dstBuffer.IsValid(), false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + FIXED16x16 xSour = 0; + FIXED16x16 ySour = 0; + FIXED16x16 wScale = FIXED16x16(srcBuffer.GetWidth() * 0x10000 / dstBuffer.GetWidth()); + FIXED16x16 hScale = FIXED16x16(srcBuffer.GetHeight() * 0x10000 / dstBuffer.GetHeight()); + FIXED16x16 temp; + + SourPixel* pSour; + DestPixel* pDest = dstBuffer.GetBufferAddr(); + + int wCopy = validRect.x + validRect.w; + int hCopy = validRect.y + validRect.h; + + for (int yDest = 0; yDest < hCopy; ++yDest) + { + if (yDest < validRect.y) + { + int jump = (validRect.y - yDest); + + pDest += (dstBuffer.GetPitch() * jump); + ySour += (hScale * jump); + yDest = validRect.y; + } + + xSour = 0; + pSour = srcBuffer.GetBufferAddr() + int(ySour >> 16) * srcBuffer.GetPitch(); + + { + int jump = validRect.x; + + pDest += jump; + xSour += (wScale * jump); + pSour += (int(xSour >> 16)); + } + + if (!pSrcImage->enableColorKey) + { + for (int xDest = validRect.x; xDest < wCopy; xDest++) + { + _Effect::Func::ConvertColorFormatFast (pDest, pSour); + ++pDest; + + temp = xSour; + xSour += wScale; + pSour += (int(xSour >> 16) - int(temp >> 16)); + } + } + else + { + SourPixel colorKey = (SourPixel) pSrcImage->colorKey; + + for (int xDest = validRect.x; xDest < wCopy; xDest++) + { + if (*pSour != colorKey) + { + _Effect::Func::ConvertColorFormatFast (pDest, pSour); + } + + ++pDest; + + temp = xSour; + xSour += wScale; + pSour += (int(xSour >> 16) - int(temp >> 16)); + } + } + + pDest += (dstBuffer.GetWidth() - wCopy); + pDest += dstBuffer.GetPadding(); + + ySour += hScale; + } + + return true; +} + +template +bool +_ScaleImageClipped(_Util::PixmapBase* pRetImage, _Util::PixmapBase* pSrcImage, const _Util::Rectangle& validRect, + DestPixel dummy1 = 0, SourPixel dummy2 = 0) +{ + if (pRetImage == null || pSrcImage == null) + { + return false; + } + + if ((pSrcImage->width <= 0) || (pSrcImage->height <= 0) + || (pRetImage->width <= 0) || (pRetImage->height <= 0)) + { + return true; + } + + _Util::GenericBuffer srcBuffer(new (std::nothrow) _GenericBufferPixmap (*pSrcImage, null)); + _Util::GenericBuffer dstBuffer(new (std::nothrow) _GenericBufferPixmap (*pRetImage, null)); + + SysTryReturn(NID_GRP, srcBuffer.IsValid() && dstBuffer.IsValid(), false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + FIXED16x16 xSour = 0; + FIXED16x16 ySour = 0; + FIXED16x16 wScale = FIXED16x16(srcBuffer.GetWidth() * 0x10000 / dstBuffer.GetWidth()); + FIXED16x16 hScale = FIXED16x16(srcBuffer.GetHeight() * 0x10000 / dstBuffer.GetHeight()); + FIXED16x16 temp; + + SourPixel* pSour = 0; + DestPixel* pDest = dstBuffer.GetBufferAddr(); + + int wCopy = validRect.x + validRect.w; + int hCopy = validRect.y + validRect.h; + + for (int yDest = 0; yDest < hCopy; ++yDest) + { + if (yDest < validRect.y) + { + int jump = (validRect.y - yDest); + + pDest += (dstBuffer.GetPitch() * jump); + ySour += (hScale * jump); + yDest = validRect.y; + } + + xSour = 0; + pSour = srcBuffer.GetBufferAddr() + int(ySour >> 16) * srcBuffer.GetPitch(); + + { + int jump = validRect.x; + + pDest += jump; + xSour += (wScale * jump); + pSour += (int(xSour >> 16)); + } + + if (!pSrcImage->enableColorKey) + { + for (int xDest = validRect.x; xDest < wCopy; xDest++) + { + // _Effect::Func::ConvertColorFormatFast(pDest, pSour); + *pDest = _Effect::Func::AlphaBlendingFast (*pDest, *pSour); + ++pDest; + + temp = xSour; + xSour += wScale; + pSour += (int(xSour >> 16) - int(temp >> 16)); + } + } + else + { + SourPixel colorKey = (SourPixel) pSrcImage->colorKey; + + for (int xDest = validRect.x; xDest < wCopy; xDest++) + { + if (*pSour != colorKey) + { + *pDest = _Effect::Func::AlphaBlendingFast (*pDest, *pSour); + } + + ++pDest; + + temp = xSour; + xSour += wScale; + pSour += (int(xSour >> 16) - int(temp >> 16)); + } + } + + pDest += (dstBuffer.GetWidth() - wCopy); + pDest += dstBuffer.GetPadding(); + + ySour += hScale; + } + + return true; +} + +bool +_ScaleImage(const _Util::Pixmap& retImage, long xDest, long yDest, long wDest, long hDest, const _Util::Pixmap& srcImage, + _Effect::Rop rop) +{ + _Util::Rectangle outRect = {0, 0, -1, -1}; + + { + _Util::Rectangle dstRect = { 0, 0, retImage.width, retImage.height }; + _Util::Rectangle tgtRect = { xDest, yDest, wDest, hDest }; + +#if 0 + { + bool hasRegion = IntersectRect(outRect, tgtRect, dstRect); + + SM_ASSERT(hasRegion); + } +#else + IntersectRect(outRect, tgtRect, dstRect); +#endif + + // workaround 2010/3/6 + // variable: bool isUnclipped = false; + // isUnclipped = (tgtRect == outRect); + } + + { +#if 0 // isUnclipped is always false + if (isUnclipped) + { + _Util::PixmapBase dstImage = retImage.GetSubBitmap(xDest, yDest, wDest, hDest); + + switch (retImage.depth) + { + case 32: + return _ScaleImageUnclipped ((_Util::PixmapBase*) &dstImage, (_Util::PixmapBase*) &srcImage); + + case 16: + return _ScaleImageUnclipped ((_Util::PixmapBase*) &dstImage, (_Util::PixmapBase*) &srcImage); + + default: + return false; + } + } + else +#endif + { + _Util::PixmapBase dstImage = retImage.GetSubBitmapUnsafe(xDest, yDest, wDest, hDest); + _Util::Rectangle validRect = outRect; + + validRect.x -= xDest; + validRect.y -= yDest; + + switch (rop) + { + case Tizen::Graphics::_Effect::ROP_COPY: + switch (retImage.depth) + { + case 32: + if (srcImage.depth == 32) + { + return _ScaleImageCopyClipped ((_Util::PixmapBase*) &dstImage, + (_Util::PixmapBase*) &srcImage, validRect, + (unsigned long) 0, (unsigned long) 0); + } + else if (srcImage.depth == 16) + { + return _ScaleImageCopyClipped ((_Util::PixmapBase*) &dstImage, + (_Util::PixmapBase*) &srcImage, validRect, + (unsigned long) 0, (unsigned short) 0); + } + else + { + return false; + } + case 16: + if (srcImage.depth == 32) + { + return _ScaleImageCopyClipped ((_Util::PixmapBase*) &dstImage, + (_Util::PixmapBase*) &srcImage, validRect, + (unsigned short) 0, (unsigned long) 0); + } + else if (srcImage.depth == 16) + { + return _ScaleImageCopyClipped ((_Util::PixmapBase*) &dstImage, + (_Util::PixmapBase*) &srcImage, validRect, + (unsigned short) 0, (unsigned short) 0); + } + else + { + return false; + } + default: + return false; + } + break; + case Tizen::Graphics::_Effect::ROP_ALPHABLEND: + switch (retImage.depth) + { + case 32: + if (srcImage.depth == 32) + { + return _ScaleImageClipped ((_Util::PixmapBase*) &dstImage, + (_Util::PixmapBase*) &srcImage, validRect, + (unsigned long) 0, (unsigned long) 0); + } + else if (srcImage.depth == 16) + { + return _ScaleImageClipped ((_Util::PixmapBase*) &dstImage, + (_Util::PixmapBase*) &srcImage, validRect, + (unsigned long) 0, (unsigned short) 0); + } + else + { + return false; + } + case 16: + if (srcImage.depth == 32) + { + return _ScaleImageClipped ((_Util::PixmapBase*) &dstImage, + (_Util::PixmapBase*) &srcImage, validRect, + (unsigned short) 0, (unsigned long) 0); + } + else if (srcImage.depth == 16) + { + return _ScaleImageClipped ((_Util::PixmapBase*) &dstImage, + (_Util::PixmapBase*) &srcImage, validRect, + (unsigned short) 0, (unsigned short) 0); + } + else + { + return false; + } + default: + return false; + } + break; + default: + return false; + } + } + } +} + +} + + +bool +Tizen::Graphics::_Effect::ScaleImage(_Util::Pixmap& dstImage, long xDest, long yDest, long wDest, long hDest, + const _Util::Pixmap& srcImage, + Rop rop) +{ + // verifiy the spcified parameters + { + if ((srcImage.width < 0) || (srcImage.height < 0) || (srcImage.pBitmap == null)) + { + return false; + } + + if ((dstImage.width < 0) || (dstImage.height < 0) || (dstImage.pBitmap == null)) + { + return false; + } + + if ((wDest < 0) || (hDest < 0)) + { + return false; + } + + if (srcImage.pBitmap == dstImage.pBitmap) + { + return false; + } + + if (!(rop == ROP_COPY || rop == ROP_ALPHABLEND)) + { + return false; + } + } + + { + if ((srcImage.width == 0) || (srcImage.height == 0)) + { + return true; + } + + if ((dstImage.width == 0) || (dstImage.height == 0)) + { + return true; + } + + if ((wDest == 0) || (hDest == 0)) + { + return true; + } + + { + _Util::Rectangle dstRect = { 0, 0, dstImage.width, dstImage.height }; + _Util::Rectangle tgtRect = { xDest, yDest, wDest, hDest }; + _Util::Rectangle outRect; + + if (!IntersectRect(outRect, tgtRect, dstRect)) + { + return true; + } + } + } + + return _ScaleImage(dstImage, xDest, yDest, wDest, hDest, srcImage, rop); +} diff --git a/src/graphics/effect/FGrp_EffectScale2.cpp b/src/graphics/effect/FGrp_EffectScale2.cpp new file mode 100644 index 0000000..ae0aada --- /dev/null +++ b/src/graphics/effect/FGrp_EffectScale2.cpp @@ -0,0 +1,1268 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_EffectScale2.cpp + * @brief This is the header file for internal utility class. + * + */ + +#include + +#include "FGrp_Effect.h" + + +namespace // unnamed +{ + +int +_Ceil(float x) +{ + int ix = int(x); + + if (x >= 0) + { + return (x - float(ix)) > 0 ? ix + 1 : ix; + } + else + { + return ix; + } +} + +int +_Floor(float x) +{ + int ix = int(x); + + if (x >= 0) + { + return ix; + } + else + { + return (float(ix) - x) > 0 ? ix - 1 : ix; + } +} + +struct _Rectangle +{ + int x; + int y; + int w; + int h; +}; + +inline bool +operator ==(const _Rectangle& lhs, const _Rectangle& rhs) +{ + return (lhs.x == rhs.x) && (lhs.y == rhs.y) && (lhs.w == rhs.w) && (lhs.h == rhs.h); +} + +struct _BufferDesc +{ + int width; // width of image + int height; // height of image + int bytesPerLine; // bytes per line + int depth; // pixel depth of buffer + unsigned char* pBitmap; // start pointer to buffer + mutable long reserved; // do you have ownership? +}; + +struct BufferDescUtil + : public _BufferDesc +{ + BufferDescUtil(int width, int height, int depth, void* pBitmap, int bytesPerLine = 0) + { + this->width = width; + this->height = height; + this->depth = depth; + this->bytesPerLine = bytesPerLine, + this->pBitmap = (unsigned char*) pBitmap; + this->reserved = 0; + + if (bytesPerLine == 0) + { + this->bytesPerLine = width * depth / 8; + } + } + + ~BufferDescUtil(void) + { + // if 'reserved' is not 0, buffer is released automatically + if (reserved) + { + delete[] pBitmap; + } + } + + _BufferDesc GetSubBitmapUnsafe(long x, long y, long w, long h) const + { + _BufferDesc retImage((_BufferDesc&) *this); + ((_BufferDesc*) this)->reserved = retImage.reserved; + retImage.reserved = 0; + + retImage.pBitmap += retImage.bytesPerLine * y + x * depth / 8; + retImage.width = w; + retImage.height = h; + + return retImage; + } + +private: + BufferDescUtil(const BufferDescUtil& rhs); + BufferDescUtil& operator=(const BufferDescUtil& rhs); + +}; + +template +inline DstIter +_Copy(SrcIter pFirst, SrcIter pLast, DstIter pTarget) +{ + for ( ; pFirst != pLast; ++pTarget, ++pFirst) + { + *pTarget = *pFirst; + } + + return pTarget; +} + +template +class _SmartArray +{ +public: + explicit _SmartArray(unsigned char* pBuffer = 0) + : __hasOwnership(pBuffer != 0) + , __pPtr((BaseType*)pBuffer) + { + } + + ~_SmartArray() + { + if (__hasOwnership) + { + delete[] (unsigned char*) __pPtr; + } + } + + BaseType& operator [](unsigned int index) const + { + return __pPtr[index]; + } + + void Bind(unsigned char* pBuffer) + { + if (__pPtr == 0) + { + __hasOwnership = (pBuffer != 0); + __pPtr = (BaseType*) pBuffer; + } + } + + BaseType* Get() const + { + return __pPtr; + } + + BaseType* Release() const + { + ((_SmartArray *) this)->__hasOwnership = false; + + return __pPtr; + } + +private: + bool __hasOwnership; + BaseType* __pPtr; + +}; // _SmartArray + +} + + +namespace Tizen { namespace Graphics +{ + +namespace _Effect +{ + +namespace Interpolation +{ + +namespace // unnamed +{ + const float CONST_2_0 = 2.0f; + const float CONST_1_5 = 1.5f; + const float CONST_1_0 = 1.0f; + const float CONST_0_75 = 0.75f; + const float CONST_0_5 = 0.5f; + const float CONST_0_0 = 0.0f; + const float CONST_MINUS_0_5 = -0.5f; + const float CONST_MINUS_1_0 = -1.0f; + + inline static float + MakeConst(float i) + { + return float(i); + } + + // memory allocation as a byte array + static inline unsigned char* + AllocMem(size_t size) + { + return new (std::nothrow) unsigned char[size]; + } +} + +enum Filter +{ + FILTER_BOX, + FILTER_TRIANGLE, + FILTER_BICUBIC, + FILTER_BELL, + FILTER_BSPLINE, + FILTER_MITCHELL +}; + +const Filter FILTER_GOOD = FILTER_BICUBIC; +const Filter FILTER_BEST = FILTER_MITCHELL; + +// offset of the color component as the applied endian +enum +{ +#if defined(BIG_ENDIAN) + OFFSET_ALPHA = 0, + OFFSET_RED = 1, + OFFSET_GREEN = 2, + OFFSET_BLUE = 3, +#else + OFFSET_ALPHA = 3, + OFFSET_RED = 2, + OFFSET_GREEN = 1, + OFFSET_BLUE = 0, +#endif + OFFSET_STRIDE = 4 +}; + +//////////////////////////////////////////////////////////////////////////// +// ScaleImageDesc<> + +template +struct ScaleImageDesc +{ + ScaleImageDesc(long x, long y, long bytesPerLine, Pixel* pData); + inline unsigned char GetPixel(long x, long y) const; + inline void PutPixel(long x, long y, unsigned char pixel); + + long xSize; + long ySize; + unsigned char* pData; + long span; + long shift; +}; + +//////////////////////////////////////////////////////////////////////////// +// ScaleImageDesc + +// OFFSET_RED +template <> +ScaleImageDesc::ScaleImageDesc(long x, long y, long bytesPerLine, unsigned long* pData) + : xSize(x) + , ySize(y) + , pData((unsigned char*)pData + OFFSET_RED) + , span(bytesPerLine) + , shift(0) +{ +} + +template <> +inline unsigned char +ScaleImageDesc::GetPixel(long x, long y) const +{ + return pData[y * span + x * OFFSET_STRIDE]; +} + +template <> +inline void +ScaleImageDesc::PutPixel(long x, long y, unsigned char pixel) +{ + pData[y * span + x * OFFSET_STRIDE] = pixel; +} + +// OFFSET_GREEN +template <> +ScaleImageDesc::ScaleImageDesc(long x, long y, long bytesPerLine, unsigned long* pData) + : xSize(x) + , ySize(y) + , pData((unsigned char*)pData + OFFSET_GREEN) + , span(bytesPerLine) + , shift(0) +{ +} + +template <> +inline unsigned char +ScaleImageDesc::GetPixel(long x, long y) const +{ + return pData[y * span + x * OFFSET_STRIDE]; +} + +template <> +inline void +ScaleImageDesc::PutPixel(long x, long y, unsigned char pixel) +{ + pData[y * span + x * OFFSET_STRIDE] = pixel; +} + +// OFFSET_BLUE +template <> +ScaleImageDesc::ScaleImageDesc(long x, long y, long bytesPerLine, unsigned long* pData) + : xSize(x) + , ySize(y) + , pData((unsigned char*)pData + OFFSET_BLUE) + , span(bytesPerLine) + , shift(0) +{ +} + +template <> +inline unsigned char +ScaleImageDesc::GetPixel(long x, long y) const +{ + return pData[y * span + x * OFFSET_STRIDE]; +} + +template <> +inline void +ScaleImageDesc::PutPixel(long x, long y, unsigned char pixel) +{ + pData[y * span + x * OFFSET_STRIDE] = pixel; +} + +// OFFSET_ALPHA +template <> +ScaleImageDesc::ScaleImageDesc(long x, long y, long bytesPerLine, unsigned long* pData) + : xSize(x) + , ySize(y) + , pData((unsigned char*)pData + OFFSET_ALPHA) + , span(bytesPerLine) + , shift(0) +{ +} + +template <> +inline unsigned char +ScaleImageDesc::GetPixel(long x, long y) const +{ + return pData[y * span + x * OFFSET_STRIDE]; +} + +template <> +inline void +ScaleImageDesc::PutPixel(long x, long y, unsigned char pixel) +{ + pData[y * span + x * OFFSET_STRIDE] = pixel; +} + +//////////////////////////////////////////////////////////////////////////// +// ScaleImageDesc + +// OFFSET_RED +template <> +ScaleImageDesc::ScaleImageDesc(long x, long y, long bytesPerLine, unsigned short* pData) + : xSize(x) + , ySize(y) + , pData((unsigned char*)pData) + , span(bytesPerLine) + , shift(0) +{ +} + +template <> +inline unsigned char +ScaleImageDesc::GetPixel(long x, long y) const +{ + return (*((unsigned short*)&pData[y * span + x * 2]) >> 11) & 0x001F; +} + +template <> +inline void +ScaleImageDesc::PutPixel(long x, long y, unsigned char pixel) +{ + unsigned short* pBuf = (unsigned short*)&pData[y * span + x * 2]; + unsigned short color = (unsigned short)((pixel > 0x001F) ? 0x001F : pixel); + *pBuf = (*pBuf & ~0xF800) | ((color << 11) & 0xF800); +} + +// OFFSET_GREEN +template <> +ScaleImageDesc::ScaleImageDesc(long x, long y, long bytesPerLine, unsigned short* pData) + : xSize(x) + , ySize(y) + , pData((unsigned char*)pData) + , span(bytesPerLine) + , shift(0) +{ +} + +template <> +inline unsigned char +ScaleImageDesc::GetPixel(long x, long y) const +{ + return (*((unsigned short*)&pData[y * span + x * 2]) >> 5) & 0x003F; +} + +template <> +inline void +ScaleImageDesc::PutPixel(long x, long y, unsigned char pixel) +{ + unsigned short* pBuf = (unsigned short*)&pData[y * span + x * 2]; + unsigned short color = (unsigned short)((pixel > 0x003F) ? 0x003F : pixel); + *pBuf = (*pBuf & ~0x07E0) | ((color << 5) & 0x07E0); +} + +// OFFSET_BLUE +template <> +ScaleImageDesc::ScaleImageDesc(long x, long y, long bytesPerLine, unsigned short* pData) + : xSize(x) + , ySize(y) + , pData((unsigned char*)pData) + , span(bytesPerLine) + , shift(0) +{ +} + +template <> +inline unsigned char +ScaleImageDesc::GetPixel(long x, long y) const +{ + return (*((unsigned short*)&pData[y * span + x * 2])) & 0x001F; +} + +template <> +inline void +ScaleImageDesc::PutPixel(long x, long y, unsigned char pixel) +{ + unsigned short* pBuf = (unsigned short*)&pData[y * span + x * 2]; + unsigned short color = (unsigned short)((pixel > 0x001F) ? 0x001F : pixel); + *pBuf = (*pBuf & ~0x001F) | (color & 0x001F); +} + +// OFFSET_ALPHA +template <> +ScaleImageDesc::ScaleImageDesc(long x, long y, long bytesPerLine, unsigned short* pData) + : xSize(x) + , ySize(y) + , pData((unsigned char*)pData) + , span(bytesPerLine) + , shift(0) +{ +} + +template <> +inline unsigned char +ScaleImageDesc::GetPixel(long x, long y) const +{ + return 0; +} + +template <> +inline void +ScaleImageDesc::PutPixel(long x, long y, unsigned char pixel) +{ +} + +//////////////////////////////////////////////////////////////////////////// +// FilterDesc + +template +struct FilterDesc +{ + inline static float Apply(float t); + inline static float Width(void); +}; + +//////////////////////////////////// +// FilterDesc - FILTER_BOX + +// rectangle filter +template <> +struct FilterDesc +{ + inline static float Apply(float t) + { + return ((t > CONST_MINUS_0_5) && t <= CONST_0_5) ? CONST_1_0 : CONST_0_0; + } + + inline static float Width(void) + { + return CONST_0_5; + } +}; + +//////////////////////////////////// +// FilterDesc - FILTER_TRIANGLE + +// triangle filter +template <> +struct FilterDesc +{ + inline static float Apply(float t) + { + t = (t >= CONST_0_0) ? t : -t; + return (t < CONST_1_0) ? (float(CONST_1_0) - t) : CONST_0_0; + } + + inline static float Width(void) + { + return CONST_1_0; + } +}; + +//////////////////////////////////// +// FilterDesc - FILTER_BICUBIC + +// cubic curve +template <> +struct FilterDesc +{ + inline static float Apply(float t) + { + t = (t >= CONST_0_0) ? t : -t; + return (t < CONST_1_0) ? float((t * CONST_2_0 - MakeConst(3)) * t * t + CONST_1_0) : CONST_0_0; + } + + inline static float Width(void) + { + return CONST_1_0; + } +}; + +//////////////////////////////////// +// FilterDesc - FILTER_BELL + +// bell curve, normal curve alike +template <> +struct FilterDesc +{ + inline static float Apply(float t) + { + // box (*) box (*) box + t = (t >= CONST_0_0) ? t : -t; + + if (t < CONST_0_5) + { + return float(CONST_0_75 - (t * t)); + } + + if (t < CONST_1_5) + { + t -= CONST_1_5; + return float((t * t) * CONST_0_5); + } + + return CONST_0_0; + } + + inline static float Width(void) + { + return CONST_1_5; + } +}; + +//////////////////////////////////// +// FilterDesc - FILTER_BSPLINE + +// B-Spline interpolation, blurred +template <> +struct FilterDesc +{ + inline static float Apply(float t) + { + // box (*) box (*) box (*) box + t = (t >= CONST_0_0) ? t : -t; + + if (t < CONST_1_0) + { + float tt = t * t; + return float((tt * t * CONST_0_5) - tt + (float(CONST_2_0) / MakeConst(3))); + } + + if (t < CONST_2_0) + { + t = CONST_2_0 - t; + return float((float(CONST_1_0) / MakeConst(6)) * (t * t * t)); + } + + return CONST_0_0; + } + + inline static float Width(void) + { + return CONST_2_0; + } +}; + +//////////////////////////////////// +// FilterDesc - FILTER_MITCHELL + +// interpolation + high-pass filter +template <> +struct FilterDesc +{ + inline static float Apply(float t) + { + const float b = float(CONST_1_0) / float(MakeConst(3)); + const float c = float(CONST_1_0) / float(MakeConst(3)); + + float tt = t * t; + + t = (t >= CONST_0_0) ? t : -t; + + if (t < CONST_1_0) + { + t = float(((MakeConst(12) - b * MakeConst(9) - c * MakeConst(6)) * (t * tt))+((b * MakeConst(12) + c * MakeConst(6) - MakeConst(18)) * tt) + (MakeConst(6) - b * CONST_2_0)); + return float(t / MakeConst(6)); + } + + if (t < CONST_2_0) + { + t = float(((b * CONST_MINUS_1_0 - c * MakeConst(6)) * (t * tt)) + ((b * MakeConst(6) + c * MakeConst(30)) * tt) + ((b * MakeConst(-12) - c * MakeConst(48)) * t) + (b * MakeConst(8) + c * MakeConst(24))); + return float(t / MakeConst(6)); + } + + return CONST_0_0; + } + + inline static float Width(void) + { + return CONST_2_0; + } +}; + +//////////////////////////////////////////////////////////////////////////// +// struct ScaleArray + +// store pixel values and filtered weights +struct ScaleArray +{ + ScaleArray() + : pArray(0) + , total(0) + { + } + + struct Element + { + int pixel; + float weight; + }* pArray; + + int total; + + enum + { + ELEMENT_SIZE = sizeof(Element) + }; + + // store pixel value and weight + inline void Push(int x, int max, float weight) + { + if (x < 0) + { + x = -x - 1; + } + + pArray[total].pixel = (x < max) ? x : max - 1 - x % max; + pArray[total].weight = weight; + total++; + } + + // up-scaling + template + inline void FillToExpand(int center, int xSize) + { + total = 0; + + int left = (int)_Ceil(float(center) - FilterDesc::Width()); + int right = (int)_Floor(float(center) + FilterDesc::Width()); + + for (int j = left; j <= right; ++j) + { + Push(j, xSize, FilterDesc::Apply(float(center) - float(j))); + } + } + + // down-scaling + template + inline void FillToShrink(int center, int xSize, float Width, float scale) + { + total = 0; + + int left = (int)_Ceil(float(center) - Width); + int right = (int)_Floor(float(center) + Width); + + for (int j = left; j <= right; ++j) + { + Push(j, xSize, FilterDesc::Apply((float(center) - float(j)) / scale) / scale); + } + } +}; + +// normalize as interger(0~255) from thw weight as float +inline unsigned char +PixelOfWeight(float weight) +{ + if (weight <= CONST_0_0) + { + return 0; + } + + int p = (int)weight; + + if (weight - float(p) >= CONST_0_5) + { + p++; + } + + return (p >= 255) ? 255 : (unsigned char)p; +} + +template +bool +ScaleImage(_BufferDesc* pDstImage, long wDest, int hDest, _BufferDesc* pSrcImage, const _Rectangle& validRect) +{ + bool result = false; + + Pixel* pSrcBuffer = (Pixel*)pSrcImage->pBitmap; + Pixel* pDstBuffer = 0; + + long xSrcSize = pSrcImage->width; + long ySrcSize = pSrcImage->height; + + _SmartArray localArray; + _SmartArray arrayMem; + + // store pre-calculated pixel index and weight for all columns + _SmartArray ypwArrays(AllocMem(hDest * sizeof(ScaleArray))); + + if (ypwArrays.Get() == 0) + { + return false; + } + + ScaleArray* pYpwArraysEnd = ypwArrays.Get() + hDest; + + if (hDest < ySrcSize) + { + // in case of shrinking for the y axis + float width = float(ySrcSize) * FilterDesc::Width() / float(hDest); + float scalingRatio = float(ySrcSize) / float(hDest); + size_t pwaSize = (size_t)float(width * CONST_2_0 + CONST_1_0); + + localArray.Bind(AllocMem(pwaSize * ScaleArray::ELEMENT_SIZE * hDest)); + + if (localArray.Get() == 0) + { + return false; + } + + ScaleArray::Element* pArray = localArray.Get(); + + for (int yDst = 0; yDst < hDest; ++yDst) + { + ypwArrays[yDst].pArray = pArray; + pArray += pwaSize; + ypwArrays[yDst].FillToShrink(yDst * ySrcSize / hDest, ySrcSize, width, scalingRatio); + } + } + else + { + // in case of expanding for the y axis + size_t pwaSize = size_t(FilterDesc::Width() * CONST_2_0 + CONST_1_0); + + localArray.Bind(AllocMem(pwaSize * ScaleArray::ELEMENT_SIZE * hDest)); + + if (localArray.Get() == 0) + { + return false; + } + + ScaleArray::Element* pArray = localArray.Get(); + + for (int yDst = 0; yDst < hDest; ++yDst) + { + ypwArrays[yDst].pArray = pArray; + pArray += pwaSize; + ypwArrays[yDst].FillToExpand(yDst * ySrcSize / hDest, ySrcSize); + } + } + + // allocate the pixel weight array within the one row + ScaleArray xpwArray; + float width = float(xSrcSize) * FilterDesc::Width() / float(wDest); + float scalingRatio = float(xSrcSize) / float(wDest); + bool xShrink = (wDest < xSrcSize); + + if (xShrink) + { + // in case of shrinking for the x axis + arrayMem.Bind(AllocMem((size_t)(width * CONST_2_0 + CONST_1_0) * ScaleArray::ELEMENT_SIZE)); + } + else + { + // in case of expanding for the x axis + arrayMem.Bind(AllocMem((size_t)(FilterDesc::Width() * CONST_2_0 + CONST_1_0) * ScaleArray::ELEMENT_SIZE)); + } + + if (arrayMem.Get() == 0) + { + return false; + } + + xpwArray.pArray = arrayMem.Get(); + + // allocate memory for each color component + _SmartArray column(AllocMem(4 * ySrcSize * sizeof(unsigned char))); + + if (column.Get() == 0) + { + return false; + } + + unsigned char* pColumnA = column.Get(); + unsigned char* pColumnR = pColumnA + ySrcSize; + unsigned char* pColumnG = pColumnR + ySrcSize; + unsigned char* pColumnB = pColumnG + ySrcSize; + + // divide color components for the source + ScaleImageDesc aSrc(xSrcSize, ySrcSize, pSrcImage->bytesPerLine, pSrcBuffer); + ScaleImageDesc rSrc(xSrcSize, ySrcSize, pSrcImage->bytesPerLine, pSrcBuffer); + ScaleImageDesc gSrc(xSrcSize, ySrcSize, pSrcImage->bytesPerLine, pSrcBuffer); + ScaleImageDesc bSrc(xSrcSize, ySrcSize, pSrcImage->bytesPerLine, pSrcBuffer); + + { + pDstBuffer = (Pixel*)pDstImage->pBitmap; + + // divide color components for the destination + ScaleImageDesc aDst(wDest, hDest, pDstImage->bytesPerLine, pDstBuffer); + ScaleImageDesc rDst(wDest, hDest, pDstImage->bytesPerLine, pDstBuffer); + ScaleImageDesc gDst(wDest, hDest, pDstImage->bytesPerLine, pDstBuffer); + ScaleImageDesc bDst(wDest, hDest, pDstImage->bytesPerLine, pDstBuffer); + + // interpolation + for (int xDst = 0; xDst < wDest; ++xDst) + { + if ((xDst < validRect.x) || (xDst >= validRect.x + validRect.w)) + { + continue; + } + + // calculate weight for one color component column + if (xShrink) + { + xpwArray.FillToShrink(xDst * xSrcSize / wDest, xSrcSize, width, scalingRatio); + } + else + { + xpwArray.FillToExpand(xDst * xSrcSize / wDest, xSrcSize); + } + + ScaleArray::Element* pXaEnd = xpwArray.pArray + xpwArray.total; // total is known at this line + + int pixel; + float weight; + + // Apply horiz FilterDesc to make rDst column in pColumnR + for (int ySrc = 0; ySrc < ySrcSize; ++ySrc) + { + pixel = xpwArray.pArray->pixel; + weight = xpwArray.pArray->weight; + + bool aPixelsSame = true; + bool rPixelsSame = true; + bool gPixelsSame = true; + bool bPixelsSame = true; + + unsigned char a = aSrc.GetPixel(pixel, ySrc); + unsigned char r = rSrc.GetPixel(pixel, ySrc); + unsigned char g = gSrc.GetPixel(pixel, ySrc); + unsigned char b = bSrc.GetPixel(pixel, ySrc); + + float aWeight = float(a) * weight; + float rWeight = float(r) * weight; + float gWeight = float(g) * weight; + float bWeight = float(b) * weight; + + for (ScaleArray::Element* pXa = xpwArray.pArray + 1; pXa < pXaEnd; ++pXa) + { + pixel = pXa->pixel; + weight = pXa->weight; + + unsigned char a2 = aSrc.GetPixel(pixel, ySrc); + unsigned char r2 = rSrc.GetPixel(pixel, ySrc); + unsigned char g2 = gSrc.GetPixel(pixel, ySrc); + unsigned char b2 = bSrc.GetPixel(pixel, ySrc); + + aPixelsSame &= (a2 == a); + rPixelsSame &= (r2 == r); + gPixelsSame &= (g2 == g); + bPixelsSame &= (b2 == b); + + aWeight += float(a2) * weight; + rWeight += float(r2) * weight; + gWeight += float(g2) * weight; + bWeight += float(b2) * weight; + } + + pColumnA[ySrc] = aPixelsSame ? a : PixelOfWeight(aWeight); + pColumnR[ySrc] = rPixelsSame ? r : PixelOfWeight(rWeight); + pColumnG[ySrc] = gPixelsSame ? g : PixelOfWeight(gWeight); + pColumnB[ySrc] = bPixelsSame ? b : PixelOfWeight(bWeight); + } + + // The temp column has been built. Now stretch it vertically into xDst column + for (ScaleArray* pYpwArray = ypwArrays.Get(); pYpwArray < pYpwArraysEnd; ++pYpwArray) + { + int yDst = (int)(pYpwArray - ypwArrays.Get()); + + if ((yDst < validRect.y) || (yDst >= validRect.y + validRect.h)) + { + continue; + } + + ScaleArray::Element* pYa = pYpwArray->pArray; + ScaleArray::Element* pYaEnd = pYa + pYpwArray->total; + + pixel = pYa->pixel; + weight = pYa->weight; + + bool aPixelsSame = true; + bool rPixelsSame = true; + bool gPixelsSame = true; + bool bPixelsSame = true; + + unsigned char a = pColumnA[pixel]; + unsigned char r = pColumnR[pixel]; + unsigned char g = pColumnG[pixel]; + unsigned char b = pColumnB[pixel]; + + float aWeight = float(a) * weight; + float rWeight = float(r) * weight; + float gWeight = float(g) * weight; + float bWeight = float(b) * weight; + + ++pYa; + + for (; pYa < pYaEnd; ++pYa) + { + if ((weight = pYa->weight) > 0) + { + pixel = pYa->pixel; + + unsigned char a2 = pColumnA[pixel]; + unsigned char r2 = pColumnR[pixel]; + unsigned char g2 = pColumnG[pixel]; + unsigned char b2 = pColumnB[pixel]; + + aPixelsSame &= (a2 == a); + rPixelsSame &= (r2 == r); + gPixelsSame &= (g2 == g); + bPixelsSame &= (b2 == b); + + aWeight += float(a2) * weight; + rWeight += float(r2) * weight; + gWeight += float(g2) * weight; + bWeight += float(b2) * weight; + } + } + + { + aDst.PutPixel(xDst, yDst, aPixelsSame ? a : PixelOfWeight(aWeight)); + rDst.PutPixel(xDst, yDst, rPixelsSame ? r : PixelOfWeight(rWeight)); + gDst.PutPixel(xDst, yDst, gPixelsSame ? g : PixelOfWeight(gWeight)); + bDst.PutPixel(xDst, yDst, bPixelsSame ? b : PixelOfWeight(bWeight)); + } + } + } + + result = true; + } + + return result; +} + +} // Interpolation + + +namespace Interpolation +{ + +bool +IntersectRect(_Rectangle& outRect, const _Rectangle& srcRect1, const _Rectangle& srcRect2) +{ + struct LocalBound + { + int x1; + int y1; + int x2; + int y2; + + LocalBound(const _Rectangle& rect) + : x1(rect.x) + , y1(rect.y) + , x2(rect.x + rect.w) + , y2(rect.y + rect.h) + { + } + }; + + LocalBound srcBound1(srcRect1); + LocalBound srcBound2(srcRect2); + + if (((srcRect1.w > 0 && srcRect1.h > 0) && (srcRect2.w > 0 && srcRect2.h > 0)) + && ((srcBound2.x2 > srcBound1.x1) && (srcBound2.x1 < srcBound1.x2) && (srcBound2.y2 > srcBound1.y1) && (srcBound2.y1 < srcBound1.y2))) + { + outRect.x = (srcBound2.x1 <= srcBound1.x1) ? srcBound1.x1 : srcBound2.x1; + outRect.y = (srcBound2.y1 <= srcBound1.y1) ? srcBound1.y1 : srcBound2.y1; + outRect.w = ((srcBound2.x2 >= srcBound1.x2) ? srcBound1.x2 : srcBound2.x2) - outRect.x; + outRect.h = ((srcBound2.y2 >= srcBound1.y2) ? srcBound1.y2 : srcBound2.y2) - outRect.y; + + return true; + } + else + { + outRect.x = 0; + outRect.y = 0; + outRect.w = 0; + outRect.h = 0; + + return false; + } +}; + +bool +ScaleImage(const BufferDescUtil& retImage, long xDest, long yDest, long wDest, long hDest, const BufferDescUtil& srcImage, DefaultFilter defaultFilter) +{ + _Rectangle outRect; + + { + _Rectangle dstRect = { 0, 0, retImage.width, retImage.height }; + _Rectangle tgtRect = { xDest, yDest, wDest, hDest }; + + { + bool hasRegion = IntersectRect(outRect, tgtRect, dstRect); + if (!hasRegion) + { + return true; + } + } + } + + { + _BufferDesc dstImage = retImage.GetSubBitmapUnsafe(xDest, yDest, wDest, hDest); + _Rectangle validRect = outRect; + + validRect.x -= xDest; + validRect.y -= yDest; + + switch (defaultFilter) + { + case DEFAULT_FILTER_GOOD: + switch (retImage.depth) + { + case 32: + return _Effect::Interpolation::ScaleImage((_BufferDesc*)&dstImage, wDest, hDest, (_BufferDesc*)&srcImage, validRect); + case 16: + return _Effect::Interpolation::ScaleImage((_BufferDesc*)&dstImage, wDest, hDest, (_BufferDesc*)&srcImage, validRect); + default: + return false; + } + break; + case DEFAULT_FILTER_BEST: + default: + switch (retImage.depth) + { + case 32: + return _Effect::Interpolation::ScaleImage((_BufferDesc*)&dstImage, wDest, hDest, (_BufferDesc*)&srcImage, validRect); + case 16: + return _Effect::Interpolation::ScaleImage((_BufferDesc*)&dstImage, wDest, hDest, (_BufferDesc*)&srcImage, validRect); + default: + return false; + } + break; + } + } +} + +} // Interpolation + +} // _Effect + +}} // Tizen::Graphics + + +#include "../util/FGrp_Util.h" + +using namespace Tizen::Graphics; + +bool +Tizen::Graphics::_Effect::ScaleImageInterpolation(_Util::Pixmap& dstImage, long xDest, long yDest, long wDest, long hDest, + const _Util::Pixmap& srcImage, DefaultFilter defaultFilter) +{ + // verifiy the spcified parameters + { + if ((srcImage.width < 0) || (srcImage.height < 0) || (srcImage.pBitmap == null)) + { + return false; + } + + if ((dstImage.width < 0) || (dstImage.height < 0) || (dstImage.pBitmap == null)) + { + return false; + } + + if ((wDest < 0) || (hDest < 0)) + { + return false; + } + + if (srcImage.pBitmap == dstImage.pBitmap) + { + return false; + } + } + + { + if ((srcImage.width == 0) || (srcImage.height == 0)) + { + return true; + } + + if ((dstImage.width == 0) || (dstImage.height == 0)) + { + return true; + } + + if ((wDest == 0) || (hDest == 0)) + { + return true; + } + + { + _Util::Rectangle dstRect = + { + 0, + 0, + dstImage.width, + dstImage.height + }; + + _Util::Rectangle tgtRect = + { + xDest, + yDest, + wDest, + hDest + }; + + _Util::Rectangle outRect; + + if (!IntersectRect(outRect, tgtRect, dstRect)) + { + return true; + } + } + } + + BufferDescUtil srcBuffer(srcImage.width, srcImage.height, srcImage.depth, srcImage.pBitmap, srcImage.bytesPerLine); + BufferDescUtil dstBuffer(dstImage.width, dstImage.height, dstImage.depth, dstImage.pBitmap, dstImage.bytesPerLine); + + return _Effect::Interpolation::ScaleImage(dstBuffer, 0, 0, dstImage.width, dstImage.height, srcBuffer, defaultFilter); +} + +//////////////////////////////////////////////////////////////////////////////// +// API for test case + +#if 0 + +#include + +namespace Tizen { namespace Graphics +{ + +result _BitmapScale(Bitmap& dstBitmap, int scaleWidth, int scaleHeight) +{ + +#define CHECK_THROW(cond, rslt) if (!(cond)) { r = rslt; break; } + + result r = E_SUCCESS; + + do + { + _SmartArray srcBuffer; + + BufferInfo srcBufferInfo; + BufferInfo dstBufferInfo; + + result r = dstBitmap.Lock(srcBufferInfo); + + CHECK_THROW(r == E_SUCCESS, r); + + srcBuffer.Bind(new (std::nothrow) unsigned char[srcBufferInfo.pitch * srcBufferInfo.height]); + + CHECK_THROW(srcBuffer.Get() && srcBufferInfo.pPixels, E_OUT_OF_MEMORY); + + // same as memcpy(srcBuffer.Get(), srcBufferInfo.pPixels, srcBufferInfo.pitch * srcBufferInfo.height); + { + unsigned char* pBegin = static_cast(srcBufferInfo.pPixels); + unsigned char* pEnd = pBegin + srcBufferInfo.pitch * srcBufferInfo.height; + unsigned char* pTarget = srcBuffer.Get(); + + _Copy(pBegin, pEnd, pTarget); + } + + srcBufferInfo.pPixels = (void*)srcBuffer.Get(); + + dstBitmap.Unlock(); + + r = dstBitmap.Scale(Dimension(scaleWidth, scaleHeight)); + + CHECK_THROW(r == E_SUCCESS, r); + + r = dstBitmap.Lock(dstBufferInfo); + + CHECK_THROW(r == E_SUCCESS, r); + + BufferDescUtil srcImage(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + BufferDescUtil dstImage(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + + _Effect::Interpolation::ScaleImage(dstImage, 0, 0, dstBufferInfo.width, dstBufferInfo.height, srcImage); + + dstBitmap.Unlock(); + + } while (false); + + return r; + +#undef CHECK_THROW + +} + +}} // Tizen::Graphics + +#endif diff --git a/src/graphics/inc/FGrp_BitmapImpl.h b/src/graphics/inc/FGrp_BitmapImpl.h new file mode 100644 index 0000000..381e65c --- /dev/null +++ b/src/graphics/inc/FGrp_BitmapImpl.h @@ -0,0 +1,249 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_BitmapImpl.h + * @brief This is the header file for the _BitmapImpl class. + * + */ + +#ifndef _FGRP_INTERNAL_BITMAPIMPL_H_ +#define _FGRP_INTERNAL_BITMAPIMPL_H_ + + +#include +#include +#include + +#include +#include +#include + +#include "FGrp_CanvasImpl.h" + + +namespace Tizen { namespace Base +{ +class ByteBuffer; +}} // Tizen::Base + +namespace Tizen { namespace Graphics +{ +class Point; +class Dimension; +class Rectangle; +class Color; +class BufferInfo; +class Bitmap; + +class _Bitmap; + +class _OSP_EXPORT_ _BitmapImpl + : public Tizen::Base::Object +{ +public: + _BitmapImpl(void); + virtual ~_BitmapImpl(void); + + result Construct(const Rectangle& rect); + result Construct(const Dimension& dim, BitmapPixelFormat format); + result Construct(const _CanvasImpl& canvas, const Tizen::Graphics::Rectangle& rect); + result Construct(const _BitmapImpl& bitmap, const Tizen::Graphics::Rectangle& rect); + result Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat); + result Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat, BufferScaling bufferScaling); + result Construct(const BufferInfo& bufferInfo); + result Construct(const Tizen::Base::String& fileName, BitmapPixelFormat pixelFormat); + + bool IsConstructed(void) const; + const Tizen::Base::String& GetFileName(void) const; + + result Scale(const Dimension& dim); + result Merge(const Point& destPoint, const _BitmapImpl& srcBitmap, const Rectangle& srcRect); + + int GetHeight(void) const; + int GetWidth(void) const; + + int GetBitsPerPixel(void) const; + BitmapPixelFormat GetPixelColorFormat(void) const; + + result SetMaskingColor(const Color* pColor); + result GetMaskingColor(Color& color) const; + + void SetAlphaConstant(int opacity); + int GetAlphaConstant(void) const; + + result SetScalingQuality(BitmapScalingQuality quality); + BitmapScalingQuality GetScalingQuality(void) const; + + bool IsNinePatchedBitmap(void) const; + + void SetAsImmutable(void); + bool IsMutable(void); + + result Lock(BufferInfo& info, long timeout = INFINITE); + result Unlock(void); + + result LockFast(BufferInfo& info, long timeout = INFINITE); + result UnlockFast(void); + + /** + * This method is for internal use only. The Tizen C++ platform team is not + * responsible for any behavioral correctness, consistency, and + * security-related issues that might arise after using this method. + * + * Creates and returns a scaled bitmap from the specified nine-patched bitmap + * + * @since 2.0 + * @return The scaled bitmap @n + * @c null, if an exception occurs + * @param[in] ninePatchedBitmap The nine-patched bitmap + * @param[in] width The width of the returned bitmap. + * @param[in] height The height of the returned bitmap. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OUT_OF_MEMORY Insufficient memory. + * @exception E_UNSUPPORTED_FORMAT The specified format is not supported. + * @exception E_SYSTEM An unknown operating system error has occurred. + * + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static Bitmap* GetExpandedBitmapN(const Bitmap& ninePatchedBitmap, int width, int height); + + /** + * This method is for internal use only. The Tizen C++ platform team is not + * responsible for any behavioral correctness, consistency, and + * security-related issues that might arise after using this method. + * + * Creates and returns a scaled bitmap from the specified nine-patched bitmap + * + * @since 2.0 + * @return The converted bitmap @n + * @c null, if an exception occurs + * @param[in] bitmap The source bitmap + * @param[in] replacedColor The color replaced. + * @param[in] newColor The color replacing. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_SYSTEM An unknown operating system error has occurred. + * + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static Bitmap* GetColorReplacedBitmapN(const Bitmap& bitmap, const Color& replacedColor, const Color& newColor); + + /** + * This method is for internal use only. The Tizen C++ platform team is not + * responsible for any behavioral correctness, consistency, and + * security-related issues that might arise after using this method. + * + * Clones a bitmap managed with a reference count + * + * @since 2.0 + * @return The cloned bitmap @n + * @c null, if an exception occurs + * @param[in] bitmap The source bitmap + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_SYSTEM An unknown operating system error has occurred. + * + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static Bitmap* CloneN(const Bitmap& bitmap); + + static _BitmapImpl* GetNonScaledBitmapImplN(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat); + + /** + * This method is for internal use only. The Tizen C++ platform team is not + * responsible for any behavioral correctness, consistency, and + * security-related issues that might arise after using this method. + * + * Creates and returns a non scaled bitmap. + * + * @since 2.0 + * @return The non scaled bitmap @n + * @c null, if an exception occurs + * @param[in] buffer The buffer containing raw data + * @param[in] dim The dimensions of the bitmap @n + * The width and height must be greater than @c 0. + * @param[in] pixelFormat The pixel format of raw data + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_UNSUPPORTED_FORMAT The specified format is not supported. + * @exception E_OUT_OF_MEMORY Insufficient memory. + * + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static Bitmap* GetNonScaledBitmapN(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat); + + static _BitmapImpl* GetInstance(Bitmap& bitmap); + static const _BitmapImpl* GetInstance(const Bitmap& bitmap); + +protected: + bool _SetCallback(void (* DestroyCallback)(void*), void* pDestroyCallbackParam, + void (* LockCallback)(void*), void* pLockCallbackParam, + void (* UnlockCallback)(void*), void* pUnlockCallbackParam); + static _BitmapImpl*& _GetBitmapImpl(Bitmap* pBitmap); + +private: + _BitmapImpl(const _BitmapImpl& src); + _BitmapImpl& operator =(const _BitmapImpl& value); + + result Construct(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat, bool autoScaling); + result Construct(const byte* pBuffer, int bufferSize, const Dimension& dim, BitmapPixelFormat pixelFormat, bool autoScaling); + + bool __CheckValidity(bool canBufferExpand = true); + bool __RealizeBuffer(void); + +protected: + struct _SharedItem + { + std::auto_ptr<_Bitmap> nativeBitmap; + std::auto_ptr coordHolder; + long lazyScaling; + std::auto_ptr<_Bitmap> scaledNativeBitmap; // depend on lazyScaling flag + bool isMutable; + + void (* pDestroyCallbackFunc)(void*); + void* pDestroyCallbackParam; + void (* pLockCallbackFunc)(void*); + void* pLockCallbackParam; + void (* pUnlockCallbackFunc)(void*); + void* pUnlockCallbackParam; + + // removed a bit later + Tizen::Base::String associatedFileName; + + struct + { + Tizen::Base::String fileName; + BitmapPixelFormat pixelFormat; + } associated; + + void Move(_SharedItem& source); + }; + + std::tr1::shared_ptr<_SharedItem> _sharedItem; + + friend class Bitmap; + friend class _CanvasImpl; + +}; // _BitmapImpl + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_BITMAPIMPL_H_ diff --git a/src/graphics/inc/FGrp_BitmapTool.h b/src/graphics/inc/FGrp_BitmapTool.h new file mode 100644 index 0000000..6603a60 --- /dev/null +++ b/src/graphics/inc/FGrp_BitmapTool.h @@ -0,0 +1,55 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_BitmapTool.h + * @brief This is the header file for internal _BitmapTool namespace. + * + */ + +#ifndef _FGRP_INTERNAL_BITMAPTOOL_H_ +#define _FGRP_INTERNAL_BITMAPTOOL_H_ + +#include +#include + + +namespace Tizen { namespace Graphics +{ + +namespace _BitmapTool +{ + +// This function changes the buffer of the specified bitmap to the user defined buffer +// The user buffer size MUST be same as the original bitmap size +result +ChangeBuffer(Tizen::Graphics::Bitmap& srcBitmap, void* pBuffer, long bytesPerLine, void (* DestroyCallback)(void*), void* pCallbackParam); + +bool +SetCallback(Tizen::Graphics::Bitmap& bitmap, + void (* DestroyCallback)(void*), void* pCallbackParam, + void (* LockCallback)(void*), void* pLockParam, + void (* UnlockCallback)(void*), void* pUnlockParam); + +void +ResetCallback(Tizen::Graphics::Bitmap& bitmap); + +} // Tizen::Graphics::_BitmapTool + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_BITMAPTOOL_H_ diff --git a/src/graphics/inc/FGrp_BufferInfoImpl.h b/src/graphics/inc/FGrp_BufferInfoImpl.h new file mode 100644 index 0000000..8fccf1f --- /dev/null +++ b/src/graphics/inc/FGrp_BufferInfoImpl.h @@ -0,0 +1,156 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_BufferInfoImpl.h + * @brief This is the header file for the _BufferInfoImpl class. + * + * This header file contains the declarations of the %_BufferInfoImpl class. + * + */ + +#ifndef _FGRP_INTERNAL_BUFFERINFO_IMPL_H_ +#define _FGRP_INTERNAL_BUFFERINFO_IMPL_H_ + + +#include +#include + + +namespace Tizen { namespace Graphics +{ +class BufferInfo; + +class _OSP_EXPORT_ _BufferInfoImpl +{ +public: + enum + { + INVALID_BUFFER_HANDLE = 0 + }; + + enum Orientation + { + ORIENTATION_PORTRAIT, + ORIENTATION_LANDSCAPE, + ORIENTATION_PORTRAIT_REVERSE, + ORIENTATION_LANDSCAPE_REVERSE + }; + + enum HandleType + { + HANDLE_TYPE_NONE, + HANDLE_TYPE_OVERLAY_REGION, + HANDLE_TYPE_VE_SURFACE, + HANDLE_TYPE_CANVAS_TEXTURE + }; + + enum Rotation + { + ROTATION_0, + ROTATION_90, + ROTATION_180, + ROTATION_270 + }; + + /** + * This is the default constructor for this class. + */ + _BufferInfoImpl(); + + /** + * This is the destructor for this class. + */ + virtual ~_BufferInfoImpl(); + + /* + * Gets the handle of the current instance of _BufferInfoImpl. + * + * @return The runtime handle + * + */ + int GetHandle(HandleType handleType) const; + + /* + * Sets the handle of the current instance of _BufferInfoImpl. + * + */ + void SetHandle(HandleType handleType, int handle); + + /* + * Gets the orientation of the current instance of _BufferInfoImpl. + * + */ + Orientation GetOrientation(void) const; + + /* + * Sets the orientation of the current instance of _BufferInfoImpl. + * + */ + void SetOrientation(Orientation orientation); + + /* + * Gets the bounds of the current instance of _BufferInfoImpl. + * + */ + Rectangle GetBounds(void) const; + + /* + * Sets the bounds of the current instance of _BufferInfoImpl. + * + */ + void SetBounds(const Rectangle& rect); + + /* + * Gets the rotation of the current instance of _BufferInfoImpl. + * + */ + Rotation GetRotation(void) const; + + /* + * Sets the rotation of the current instance of _BufferInfoImpl. + * + */ + void SetRotation(Rotation rotation); + + static _BufferInfoImpl* GetInstance(BufferInfo& bufferInfo); + static const _BufferInfoImpl* GetInstance(const BufferInfo& bufferInfo); + +private: + /** + * This is the default copy constructor for this class. + */ + _BufferInfoImpl(const _BufferInfoImpl& src); + + /** + * This is the default assignment operator for this class. + */ + _BufferInfoImpl& operator =(const _BufferInfoImpl& rhs); + + friend class BufferInfo; + + HandleType __handleType; + int __handle; + Orientation __orientation; + Rectangle __bounds; + Rotation __rotation; + +}; // _BufferInfoImpl + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_BUFFERINFO_IMPL_H_ diff --git a/src/graphics/inc/FGrp_CanvasImpl.h b/src/graphics/inc/FGrp_CanvasImpl.h new file mode 100644 index 0000000..3bde208 --- /dev/null +++ b/src/graphics/inc/FGrp_CanvasImpl.h @@ -0,0 +1,280 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasImpl.h + * @brief This is the header file for the _CanvasImpl class. + * + * This header file contains the declarations of the %_CanvasImpl class. + * + */ + +#ifndef _FGRP_INTERNAL_CANVASIMPL_H_ +#define _FGRP_INTERNAL_CANVASIMPL_H_ + + +#include +#include +#include + + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +}}} // Tizen::Base::Collection + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElementCanvas; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Graphics +{ +class Point; +class Dimension; +class Rectangle; +class FloatPoint; +class FloatDimension; +class FloatRectangle; +class Color; +class BufferInfo; +class Bitmap; +class Canvas; +class Font; +class EnrichedText; + +class _BitmapImpl; +class _Canvas; + + +// * @enum BitmapDrawingQuality +// * +// * Defines the bitmap drawing quality. +// * +// * @since 2.0 + +enum BitmapDrawingQuality +{ + BITMAP_DRAWING_QUALITY_LOW, // The low-quality but high-performance + BITMAP_DRAWING_QUALITY_MID, // The mid-quality + BITMAP_DRAWING_QUALITY_HIGH // The high-quality but low-performance +}; + +enum TextOrigin +{ + TEXT_ORIGIN_LEFT_TOP, + TEXT_ORIGIN_BASELINE +}; + +/* For test, CR not approved */ +enum BlendingMode +{ + BLENDING_MODE_CLEAR, // [0, 0] + BLENDING_MODE_SRC, // [Sa, Sc] + BLENDING_MODE_DST, // [Da, Dc] + BLENDING_MODE_SRC_OVER, // [Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc] + BLENDING_MODE_DST_OVER, // [Sa + (1 - Sa)*Da, Rc = Dc + (1 - Da)*Sc] + BLENDING_MODE_SRC_IN, // [Sa * Da, Sc * Da] + BLENDING_MODE_DST_IN, // [Sa * Da, Sa * Dc] + BLENDING_MODE_SRC_OUT, // [Sa * (1 - Da), Sc * (1 - Da)] + BLENDING_MODE_DST_OUT, // [Da * (1 - Sa), Dc * (1 - Sa)] + BLENDING_MODE_SRC_ATOP, // [Da, Sc * Da + (1 - Sa) * Dc] + BLENDING_MODE_DST_ATOP, // [Sa, Sa * Dc + Sc * (1 - Da)] + BLENDING_MODE_DST_XOR, // [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc] + BLENDING_MODE_ADD, + BLENDING_MODE_SATURATE, // Saturate(S + D) + // Pixman extension 1 + BLENDING_MODE_MULTIPLY, // [Sa * Da, Sc * Dc] + BLENDING_MODE_SCREEN, // [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc] + BLENDING_MODE_OVERLAY, + BLENDING_MODE_DARKEN, // [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + min(Sc, Dc)] + BLENDING_MODE_LIGHTEN, // [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + max(Sc, Dc)] + // Pixman extension 2 + BLENDING_MODE_COLOR_DODGE, + BLENDING_MODE_COLOR_BURN, + BLENDING_MODE_HARD_LIGHT, + BLENDING_MODE_SOFT_LIGHT, + BLENDING_MODE_DIFFERENCE, + BLENDING_MODE_EXCLUSION +}; + +class _OSP_EXPORT_ _CanvasImpl + : public Tizen::Base::Object +{ +public: + _CanvasImpl(void); + virtual ~_CanvasImpl(void); + + result Construct(void); + result Construct(const Rectangle& rect); + result Construct(Handle windowHandle, const Rectangle& rect); + result Construct(const BufferInfo& bufferInfo); + + bool IsConstructed(void) const; + + result Clear(void); + result Clear(const Rectangle& rect); + + result Copy(const Point& destPoint, const _CanvasImpl& srcCanvas, const Rectangle& srcRect); + result Copy(const Rectangle& destRect, const _CanvasImpl& srcCanvas, const Rectangle& srcRect); + result Copy(const Point& destPoint, const _CanvasImpl& srcCanvas, const Rectangle& srcRect, BlendingMode blendingMode); + + result CopyEx(const Point& destPoint, const _CanvasImpl& srcCanvas, const Rectangle& srcRect); + + LineStyle GetLineStyle(void) const; + int GetLineWidth(void) const; + result SetLineStyle(LineStyle style); + result SetLineWidth(int width); + + result GetDashPattern(Tizen::Base::Collection::IListT& pattern, int& offset); + result SetDashPattern(const Tizen::Base::Collection::IListT& pattern, int offset); + + result SetDrawingQuality(BitmapDrawingQuality quality); + BitmapDrawingQuality GetDrawingQuality(void) const; + + result SetBlendingMode(BlendingMode blendingMode); + BlendingMode GetBlendingMode(void) const; + + result GetPixel(const Point& point, Color& color) const; + + result SetPixel(const Point& point); + result SetPixel(const FloatPoint& point); // floating-point version + + result DrawRectangle(const Rectangle& rect); + result DrawRectangle(const FloatRectangle& rect); // floating-point version + result FillRectangle(const Color& color, const Rectangle& rect); + result FillRectangle(const Color& color, const FloatRectangle& rect); // floating-point version + + result DrawRoundRectangle(const Rectangle& rect, const Dimension& arcDim); + result DrawRoundRectangle(const FloatRectangle& rect, const FloatDimension& arcDim); // floating-point version + result FillRoundRectangle(const Color& color, const Rectangle& rect, const Dimension& arcDim); + result FillRoundRectangle(const Color& color, const FloatRectangle& rect, const FloatDimension& arcDim); // floating-point version + + result DrawEllipse(const Rectangle& rect); + result DrawEllipse(const FloatRectangle& rect); // floating-point version + result FillEllipse(const Color& color, const Rectangle& rect); + result FillEllipse(const Color& color, const FloatRectangle& rect); // floating-point version + + result DrawArc(const Rectangle& rect, int startAngle, int endAngle, ArcStyle arcStyle); + result DrawArc(const FloatRectangle& rect, float startAngle, float endAngle, ArcStyle arcStyle); // floating-point version + + result DrawTriangle(const Point& point1, const Point& point2, const Point& point3); + result DrawTriangle(const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& point3); // floating-point version + result FillTriangle(const Color& color, const Point& point1, const Point& point2, const Point& point3); + result FillTriangle(const Color& color, const FloatPoint& point1, const FloatPoint& point2, const FloatPoint& point3); // floating-point version + + result DrawLine(const Point& point1, const Point& point2); + result DrawLine(const FloatPoint& point1, const FloatPoint& point2); // floating-point version + result DrawPolyline(const Tizen::Base::Collection::IList& points); + result DrawPolygon(const Tizen::Base::Collection::IList& points); + result FillPolygon(const Color& color, const Tizen::Base::Collection::IList& points); + + result SetFont(const Font& font); + Font* GetFontN(void); + + void SetTextOrigin(TextOrigin origin); + + result DrawText(const Point& point, const Tizen::Base::String& text); + result DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, int length); + result DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, const Color& outlineColor); + result DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, int length, const Color& outlineColor); + result DrawText(const Point& point, const EnrichedText& enrichedText); + + result DrawBitmap(const Point& point, const _BitmapImpl& bitmap); + result DrawBitmap(const FloatPoint& point, const _BitmapImpl& bitmap); // floating-point version + result DrawBitmap(const Rectangle& rect, const _BitmapImpl& bitmap); + result DrawBitmap(const FloatRectangle& rect, const _BitmapImpl& bitmap); // floating-point version + result DrawBitmap(const Rectangle& destRect, const _BitmapImpl& srcBitmap, const Rectangle& srcRect); + result DrawBitmap(const FloatRectangle& destRect, const _BitmapImpl& srcBitmap, const FloatRectangle& srcRect); // floating-point version + result DrawBitmap(const Point& point, const _BitmapImpl& bitmap, FlipDirection dir); + result DrawBitmap(const FloatPoint& point, const _BitmapImpl& bitmap, FlipDirection dir); // floating-point version + result DrawBitmap(const Point& point, const _BitmapImpl& bitmap, const Point& pivot, int degree); + result DrawBitmap(const FloatPoint& point, const _BitmapImpl& bitmap, const FloatPoint& pivot, float degree); // floating-point version + result DrawNinePatchedBitmap(const Rectangle& rect, const _BitmapImpl& bitmap); + result DrawNinePatchedBitmap(const FloatRectangle& rect, const _BitmapImpl& bitmap); // floating-point version + + result Show(void); + result Show(const Rectangle& rect); + + Rectangle GetBounds(void) const; + + result SetClipBounds(const Rectangle& rect); + Rectangle GetClipBounds(void) const; + + result Lock(BufferInfo& info, long timeout = INFINITE); + result Unlock(void); + + void SetForegroundColor(const Color& color); + Color GetForegroundColor(void) const; + void SetBackgroundColor(const Color& color); + Color GetBackgroundColor(void) const; + + result SetPosition(const Point& point); + result SetPosition(int x, int y); + + Canvas* GetSubCanvasN(const Rectangle& subRegion) const; + + /* + * Sets a priority font to the %_CanvasImpl. This font have priority at user font which is installed through _CanvasImpl::SetFont() + * + * @return An error code + * @param[in] pFont The font @n + * It should be constructed before being passed to this method. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OPERATION_FAILED This instance is in an invalid state. + */ + result SetPriorityFont(const Font& font); + + /* + * Resets a priority font + */ + void ResetPriorityFont(void); + + // for performance test + void SetStableRenderer(bool isStable); + + // for removing the Ui dependency + static void SetFrameInfoCallback(void* (*pGetDefaultFrameNativeHandle)(void), void* (*pGetDefaultFrameHandle)(void)); + static void SetThemeInfoCallback(Color (*pGetDefaultForegroundColor)(void), Color (*pGetDefaultBackgroundColor)(void)); + + static _CanvasImpl* GetInstance(Canvas& canvas); + static const _CanvasImpl* GetInstance(const Canvas& canvas); + +private: + _CanvasImpl(const _CanvasImpl& canvas); + _CanvasImpl& operator =(const _CanvasImpl& value); + +protected: + _Canvas* _pNativeCanvas; + struct _CanvasCoordHolder* _pCoordHolder; + Font* _pFont; + Font* _pPriorityFont; + Tizen::Base::Collection::ArrayListT _dashList; + int _dashOffset; + + friend class _Canvas; + friend class _CanvasImplPrivate; + friend class _BitmapImpl; + friend class TextElement; + friend class Tizen::Ui::Animations::_VisualElementCanvas; + +}; // _CanvasImpl + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_CANVASIMPL_H_ diff --git a/src/graphics/inc/FGrp_CanvasTextureImpl.h b/src/graphics/inc/FGrp_CanvasTextureImpl.h new file mode 100644 index 0000000..5cd78f1 --- /dev/null +++ b/src/graphics/inc/FGrp_CanvasTextureImpl.h @@ -0,0 +1,69 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasTextureImpl.h + * @brief This is the header file for the _CanvasTextureImpl class. + * + */ + +#ifndef _FGRP_CANVAS_TEXTUREIMPL_H_ +#define _FGRP_CANVAS_TEXTUREIMPL_H_ + +#include + +namespace Tizen { namespace Graphics { +class Bitmap; +class Canvas; +}} + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +class CanvasTexture; +class _CanvasTexture; + +class _OSP_EXPORT_ _CanvasTextureImpl + : public Tizen::Base::Object +{ +public: + _CanvasTextureImpl(void); + virtual ~_CanvasTextureImpl(void); + + result Construct(int textureId, int width, int height); + + Canvas* GetCanvasN(void) const; + + static bool IsSupported(void); + +public: + static _CanvasTextureImpl* GetInstance(CanvasTexture& canvasTexture); + static const _CanvasTextureImpl* GetInstance(const CanvasTexture& canvasTexture); + +private: + _CanvasTextureImpl(const _CanvasTextureImpl& rhs); + _CanvasTextureImpl& operator =(const _CanvasTextureImpl& rhs); + +private: + _CanvasTexture* __pNativeCanvasTexture; + + friend class CanvasTexture; +}; // CanvasTexture + +}}} // Tizen::Graphics::Opengl + +#endif //_FGRP_CANVAS_TEXTURE_H_ diff --git a/src/graphics/inc/FGrp_CoordinateSystem.h b/src/graphics/inc/FGrp_CoordinateSystem.h new file mode 100644 index 0000000..195aa0c --- /dev/null +++ b/src/graphics/inc/FGrp_CoordinateSystem.h @@ -0,0 +1,236 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CoordinateSystem.h + * @brief This is the header file for _CoordinateSystem class. + * + */ + +#ifndef _FGRP_INTERNAL_COORDINATE_SYSTEM_H_ +#define _FGRP_INTERNAL_COORDINATE_SYSTEM_H_ + + +#include +#include +#include + + +namespace Tizen { namespace Graphics +{ + +enum _LogicalResolution +{ + RESOLUTION_LOGICAL_NONE, + RESOLUTION_LOGICAL_DEFAULT, + + RESOLUTION_LOGICAL_240, + RESOLUTION_LOGICAL_320, + RESOLUTION_LOGICAL_360, + RESOLUTION_LOGICAL_480, + RESOLUTION_LOGICAL_720, + RESOLUTION_LOGICAL_800, + RESOLUTION_LOGICAL_960, + RESOLUTION_LOGICAL_1080, + RESOLUTION_LOGICAL_1440, + RESOLUTION_LOGICAL_1600 +}; + +enum _PhysicalResolution +{ + RESOLUTION_PHYSICAL_NONE, + RESOLUTION_PHYSICAL_DEFAULT, + + RESOLUTION_PHYSICAL_WVGA, + RESOLUTION_PHYSICAL_WQVGA, + RESOLUTION_PHYSICAL_HVGA, + //RESOLUTION_PHYSICAL_QHD, + RESOLUTION_PHYSICAL_HD, + RESOLUTION_PHYSICAL_WXGA, + RESOLUTION_PHYSICAL_HD1080, + RESOLUTION_PHYSICAL_WQXGA +}; + +enum _BaseScreenSize +{ + BASE_SCREEN_SIZE_NONE, + BASE_SCREEN_SIZE_DEFAULT, + + BASE_SCREEN_SIZE_NORMAL, + BASE_SCREEN_SIZE_LARGE +}; + +class _OSP_EXPORT_ _ICoordinateSystemTransformer +{ +public: + virtual ~_ICoordinateSystemTransformer(void) {} + + virtual Rectangle Transform(const Rectangle& rect) const = 0; + virtual Dimension Transform(const Dimension& dim) const = 0; + virtual Point Transform(const Point& point) const = 0; + + virtual int Transform(int scalar) const = 0; + virtual int TransformHorizontal(int scalar) const = 0; + virtual int TransformVertical(int scalar) const = 0; + + virtual float Transform(float scalar) const = 0; + virtual float TransformHorizontal(float scalar) const = 0; + virtual float TransformVertical(float scalar) const = 0; + + virtual float GetHorizontalScaleFactor(void) const = 0; + virtual float GetVerticalScaleFactor(void) const = 0; + +}; // _ICoordinateSystemTransformer + +class _OSP_EXPORT_ _NullCoordinateSystemTransformer + : public _ICoordinateSystemTransformer +{ +public: + + _NullCoordinateSystemTransformer(void) + { + } + + virtual Rectangle Transform(const Rectangle& rect) const + { + return rect; + } + + virtual Dimension Transform(const Dimension& dim) const + { + return dim; + } + + virtual Point Transform(const Point& point) const + { + return point; + } + + virtual int Transform(int scalar) const + { + return scalar; + } + + virtual int TransformHorizontal(int scalar) const + { + return scalar; + } + + virtual int TransformVertical(int scalar) const + { + return scalar; + } + + virtual float Transform(float scalar) const + { + return scalar; + } + + virtual float TransformHorizontal(float scalar) const + { + return scalar; + } + + virtual float TransformVertical(float scalar) const + { + return scalar; + } + + virtual int TransformFloatToInt(float scalar) const + { + return static_cast(scalar); + } + + virtual int TransformHorizontalFloatToInt(float scalar) const + { + return static_cast(scalar); + } + + virtual int TransformVerticalFloatToInt(float scalar) const + { + return static_cast(scalar); + } + + virtual float GetHorizontalScaleFactor(void) const + { + return 1.0f; + } + + virtual float GetVerticalScaleFactor(void) const + { + return 1.0f; + } +}; // _NullCoordinateSystemTransformer + +class _OSP_EXPORT_ _CoordinateSystem +{ +public: + static _CoordinateSystem* GetInstance(void); + + _LogicalResolution GetNativeLogicalResolution(void) const; + _BaseScreenSize GetNativeLogicalBaseScreenSize(void) const; + + _LogicalResolution GetLogicalResolution(void) const; + int GetLogicalResolutionInt(void) const; + + _PhysicalResolution GetPhysicalResolution(void) const; + Dimension GetPhysicalResolutionDim(void) const; + + _BaseScreenSize GetLogicalBaseScreenSize(void) const; + _BaseScreenSize GetPhysicalBaseScreenSize(void) const; + + static result Initialize(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize); + static result Initialize(int srcRes, _BaseScreenSize srcBaseScreenSize, Dimension destRes, _BaseScreenSize destBaseScreenSize); + result Reset(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize); + result Reset(int srcRes, _BaseScreenSize srcBaseScreenSize, Dimension destRes, _BaseScreenSize destBaseScreenSize); + + _ICoordinateSystemTransformer* GetTransformer(void); + _ICoordinateSystemTransformer* GetInverseTransformer(void); + + static _ICoordinateSystemTransformer* GetTransformerN(const Dimension& srcDim, const Dimension& trgDim); + static _ICoordinateSystemTransformer* GetTransformerN(_LogicalResolution logicalResolution, _PhysicalResolution physicalResolution); + static _ICoordinateSystemTransformer* GetTransformerN(_LogicalResolution sourceLogicalResolution, _LogicalResolution destLogicalResolution); + static _ICoordinateSystemTransformer* GetTransformerN(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize, _PhysicalResolution physicalResolution, _BaseScreenSize physicalBaseScreenSize); + static _ICoordinateSystemTransformer* GetTransformerN(int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize); + + void SetTransformEnabled(bool enabled); + bool IsTransformEnabled(void) const; + +private: + _CoordinateSystem(void); + ~_CoordinateSystem(void); + + _CoordinateSystem(const _CoordinateSystem&); + _CoordinateSystem& operator =(const _CoordinateSystem&); + + result __Initialize(_LogicalResolution logicalResolution, _BaseScreenSize logicalBaseScreenSize); + result __Initialize(int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize); + + static void __InitCoordinateSystem(void); + +private: + static _CoordinateSystem __instance; + static _CoordinateSystem* __pTheInstance; + + class _CoordinateSystemImpl; + _CoordinateSystemImpl* __pImpl; + +}; // _CoordinateSystem + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_COORDINATE_SYSTEM_H_ diff --git a/src/graphics/inc/FGrp_EnrichedTextImpl.h b/src/graphics/inc/FGrp_EnrichedTextImpl.h new file mode 100644 index 0000000..9260dd3 --- /dev/null +++ b/src/graphics/inc/FGrp_EnrichedTextImpl.h @@ -0,0 +1,168 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_EnrichedTextImpl.h + * @brief This is the header file for the _EnrichedTextImpl class. + * + * This header file contains the declarations of the %_EnrichedTextImpl class. + * + */ + +#ifndef _FGRP_INTERNAL_ENRICHED_TEXT_IMPL_H_ +#define _FGRP_INTERNAL_ENRICHED_TEXT_IMPL_H_ + + +#include +#include + +#include +#include +#include +#include + +#include +#include "FGrp_TextCommon.h" + +namespace Tizen { namespace Graphics { namespace _Text +{ +class TextObject; +}}} + +namespace Tizen { namespace Base { namespace Collection +{ +class LinkedList; +}}} // Tizen::Base::Collection + +namespace Tizen { namespace Base { namespace Utility +{ +class LinkInfo; +}}} // Tizen::Base::Utility + +namespace Tizen { namespace Graphics +{ +class TextElement; + +class _TextElementImpl; + +#define TEXT_HORIZONTAL_ALIGNMENT 0x0007 +#define TEXT_VERTICAL_ALIGNMENT 0x0f00 + +enum _TextWrapType +{ + //Wrap + TEXT_WRAP_TYPE_NONE, //default + TEXT_WRAP_TYPE_WRAP, + TEXT_WRAP_TYPE_WORDWRAP +}; + +class _EnrichedTextImpl +{ +public: + _EnrichedTextImpl(void); + virtual ~_EnrichedTextImpl(void); + + result Construct(const Tizen::Graphics::Dimension& dim); + result InsertAt(int elementIndex, TextElement& element); + result RemoveAt(int elementIndex, bool deallocate); + result Remove(TextElement& element, bool deallocate); + result Add(TextElement& element); + result RemoveAllTextElements(bool deallocate); + result RemoveAll(bool deallocate); + TextElement* GetTextElementAt(int elementIndex) const; + int GetTextElementCount(void) const; + result SetSize(const Tizen::Graphics::Dimension& size); + result SetSize(int width, int height); + Tizen::Graphics::Dimension GetSize(void) const; + void GetSize(int& width, int& height) const; + int GetWidth(void) const; + int GetHeight(void) const; + result SetVerticalAlignment(TextVerticalAlignment alignment); + result SetHorizontalAlignment(TextHorizontalAlignment alignment); + TextVerticalAlignment GetVerticalAlignment(void) const; + TextHorizontalAlignment GetHorizontalAlignment(void) const; + result SetTextWrapStyle(TextWrap wrap); + TextWrap GetTextWrapStyle(void) const; + result SetTextAbbreviationEnabled(bool enable); + bool IsTextAbbreviationEnabled(void) const; + result SetLineSpace(int lineSpace); + int GetLineSpace(void) const; + void Refresh(void); + int GetTotalLineCount(void) const; + int GetTotalLineHeight(void) const; + int GetDisplayLineCount(void) const; + int GetLineLength(int lineIndex) const; + int GetFirstTextIndex(int lineIndex) const; + int GetLineIndex(int textIndex) const; + int GetLineHeight(int lineIndex) const; + int GetTextLength(void) const; + result GetTextExtent(int startTextIndex, int textLength, int& width, int& height, int& actualLength) const; + result GetTextExtent(int startTextIndex, int textLength, Tizen::Graphics::Dimension& size, int &actualLength) const; + Tizen::Graphics::Dimension GetTextExtent(void) const; + result Add(const Tizen::Graphics::Bitmap& bitmap); + result InsertAt(int elementIndex, const Tizen::Graphics::Bitmap& bitmap); + result GetLinkInfoFromPosition(const Point& point, Tizen::Base::Utility::LinkInfo& linkInfo) const; + result GetLinkInfoFromPosition(int x, int y, Tizen::Base::Utility::LinkInfo& linkInfo) const; + TextVerticalAlignment GetElementVerticalAlignment(void) const; + result SetElementVerticalAlignment(TextVerticalAlignment alignment); + + Tizen::Graphics::Rectangle GetBounds(void) const; + result IndexOfFromLinkedList(TextElement& textElement, int& index); + int GetTextElementIndexFromPosition(Tizen::Graphics::Point& point) const; + Tizen::Graphics::_Text::TextObjectAlignment ConvertHAlignment(TextHorizontalAlignment halign); + TextHorizontalAlignment ConvertHAlignment(Tizen::Graphics::_Text::TextObjectAlignment halign); + Tizen::Graphics::_Text::TextObjectAlignment ConvertVAlignment(TextVerticalAlignment valign); + TextVerticalAlignment ConvertVAlignment(Tizen::Graphics::_Text::TextObjectAlignment valign); + _TextWrapType ConvertWrapType(TextWrap warp); + TextWrap ConvertWrap(_TextWrapType warp) const; + + Tizen::Graphics::_Text::TextObject* GetTextObject(void) const; + Tizen::Graphics::_Text::TextElementType GetTypeFromIndex(int textObjectIndex) const; + int GetIndexFromTouchPosition(int posX, int posY) const; + result RemoveFromTextObject(_TextElementImpl* pTextElementImpl); + result InsertAtFromTextObject(int index, _TextElementImpl* pTextElementImpl); + int GetTextElementIndex(_TextElementImpl* pTextElementImpl) const; + _EnrichedTextImpl* GetCloneN(void) const; + bool IsConstructed(void) const; + + static _EnrichedTextImpl* GetInstance(EnrichedText& enrichedText); + static const _EnrichedTextImpl* GetInstance(const EnrichedText& enrichedText); + +private: + int __width; + int __height; + int __lineSpace; + int __count; + TextVerticalAlignment __verticalAlignment; + TextHorizontalAlignment __horizontalAlignment; + TextVerticalAlignment __elementVerticalAlignment; + + std::tr1::shared_ptr __pTextObject; + Tizen::Base::Collection::LinkedList* __pLinkedListTextElementList; + Tizen::Base::Collection::ArrayList __elements; + TextElement* __pTextElement; + bool __isCopiedEnrichedText; + +private: + _EnrichedTextImpl(const _EnrichedTextImpl& enrichedTextImpl); + _EnrichedTextImpl& operator =(const _EnrichedTextImpl& rhs); + +}; // _EnrichedTextImpl + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_ENRICHED_TEXT_IMPL_H_ diff --git a/src/graphics/inc/FGrp_FontImpl.h b/src/graphics/inc/FGrp_FontImpl.h new file mode 100644 index 0000000..12e3214 --- /dev/null +++ b/src/graphics/inc/FGrp_FontImpl.h @@ -0,0 +1,187 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_FontImpl.h + * @brief This is the header file for the _FontImpl class. + * + * This header file contains the declarations of the %_FontImpl class. + * + */ + +#ifndef _FGRP_INTERNAL_FONT_IMPL_H_ +#define _FGRP_INTERNAL_FONT_IMPL_H_ + + +#include +#include + +namespace Tizen { namespace Base +{ +class String; +class ByteBuffer; +}} // Tizen::Base + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +}}} // Tizen::Base::Collection + +namespace Tizen { namespace Graphics +{ +class Dimension; +class Font; + +class _Font; + +class _OSP_EXPORT_ _FontImpl + : public Tizen::Base::Object +{ +public: + _FontImpl(void); + virtual ~_FontImpl(void); + + result Construct(int style, int size); + result Construct(const Tizen::Base::String& fontName, int style, int size, bool isPathEnabled = true); + result Construct(const Tizen::Base::ByteBuffer& fontData, int style, int size); + + bool IsConstructed(void) const; + + int GetMaxHeight(void) const; + int GetMaxWidth(void) const; + int GetAscender(void) const; + int GetDescender(void) const; + result GetLeftBear(wchar_t character, int& leftBear) const; + result GetRightBear(wchar_t character, int& rightBear) const; + result GetTextExtent(const Tizen::Base::String& text, int length, Dimension& dim) const; + bool IsBold(void) const; + bool IsItalic(void) const; + bool IsPlain(void) const; + bool IsStrikeOut(void) const; + bool IsUnderlined(void) const; + int GetSize(void) const; + void SetStrikeOut(bool strikeOut); + void SetUnderline(bool underline); + void SetCharSpace(int space); + int GetCharSpace(void) const; + Tizen::Base::String GetFaceName(void) const; + static Tizen::Base::Collection::IList* GetSystemFontListN(void); + static Tizen::Base::String GetFaceName(const Tizen::Base::String& filePath); + + _FontImpl* CloneN(void); + static Font* CloneN(const Font& font); + + /* + * Gets the count and dimension of characters which can be get in the given width. @n + * + * @return An error code + * @param[in] width The width for calculating how many characters can be get in there + * The width must be greater than or equal to @c 0 + * @param[in] text The string + * @param[in] startIndex The start index + * @param[in] length The length of @c text + * @param[in] outline The outline effect of @c text + * @param[out] count The count of characters + * @param[out] dim The width and height of the font of the @c text which get in given width + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of @c width is greater than or equal to @c 0. + * @exception E_OPERATION_FAILED This instance is in an invalid state. + * @exception E_SYSTEM The system error occurs. + */ + result GetTextExtent(int width, const Tizen::Base::String& text, int startIndex, int length, bool outline, int& count, Dimension& dim) const; + + /* + * Gets the count and dimension of characters which can be get in the given width. @n + * + * @return An error code + * @param[in] width The width for calculating how many characters can be get in there + * The width must be greater than or equal to @c 0 + * @param[in] text The string + * @param[in] startIndex The start index + * @param[in] length The length of @c text + * @param[in] outline The outline effect of @c text + * @param[in] delimiter The delimiter + * @param[out] count The count of characters + * @param[out] dim The width and height of the font of the @c text which get in given width + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The value of @c width is greater than or equal to @c 0. + * @exception E_OPERATION_FAILED This instance is in an invalid state. + * @exception E_SYSTEM The system error occurs. + */ + result GetTextExtent(int width, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, Dimension& dim) const; + + /* + * Sets the font size. + * + * @return An error code + * @param[in] size The font size in pixels @n + * The size must be greater than @c 0. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OPERATION_FAILED This instance is in an invalid state. + * @exception E_SYSTEM The system error occurs. + */ + result SetSize(int size); + + /* + * Sets the font style. + * + * @return An error code + * @param[in] style The font style @n + * For more information, see Tizen::Graphics::FontStyle. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OPERATION_FAILED This instance is in an invalid state. + * @exception E_SYSTEM The system error occurs. + */ + result SetStyle(int style); + + /* + * Gets the font style. + * + * @return the style of font + */ + int GetStyle(void) const; + + /* + * Gets the leading of the current instance of Font. + * + * @return the leading of the current instance of Font, @n + * else @c -1 if the method fails + */ + int GetLeading(void) const; + + static _FontImpl* GetInstance(Font& font); + static const _FontImpl* GetInstance(const Font& font); + + static bool UpdateDefaultFont(const Tizen::Base::String& key); + +protected: + struct _FontCoordHolder* _pCoordHolder; + Tizen::Graphics::_Font* _pNativeFont; + +private: + _FontImpl(const _FontImpl& obj); + _FontImpl& operator =(const _FontImpl& rhs); + + friend class _Font; + +}; // _FontImpl + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_FONT_IMPL_H_ diff --git a/src/graphics/inc/FGrp_GlPlayerImpl.h b/src/graphics/inc/FGrp_GlPlayerImpl.h new file mode 100644 index 0000000..2c582cd --- /dev/null +++ b/src/graphics/inc/FGrp_GlPlayerImpl.h @@ -0,0 +1,122 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_GlPlayerImpl.h + * @brief This is the header file for the _GlPlayerImpl class. + * + */ + +#ifndef _FGRP_GLPLAYERIMPL_H_ +#define _FGRP_GLPLAYERIMPL_H_ + +#include +#include +#include + +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +class IGlRenderer; +class GlPlayer; + +class _OSP_EXPORT_ _GlPlayerImpl + : public Tizen::Base::Object + , public Tizen::Base::Runtime::ITimerEventListener +{ +public: + _GlPlayerImpl(void); + virtual ~_GlPlayerImpl(void); + + result Construct(EglContextClientVersion version, Tizen::Ui::Control* pControl); + result Start(void); + result Pause(void); + result Resume(void); + result Stop(void); + + result Redraw(void); + + result SetFps(int fps); + result SetIGlRenderer(IGlRenderer* pRenderer); + + result SetEglAttributeList(const EGLint* pEglConfigList); + result SetEglAttributePreset(EglAttributesPreset preset); + result SetEglAttribute(EGLint key, EGLint value); + + bool IsValid(void) const; + + //// function for ITimerEventListener + void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + +public: + static _GlPlayerImpl* GetInstance(GlPlayer& plyaer); + static const _GlPlayerImpl* GetInstance(const GlPlayer& player); + +private: + _GlPlayerImpl(const _GlPlayerImpl& rhs); + _GlPlayerImpl& operator =(const _GlPlayerImpl& rhs); + + bool __CheckReadyToStart(void); + bool __DestroyGl(void); + + result __Terminate(void); + +private: + IGlRenderer* __pRenderer; + + Tizen::Base::Runtime::Timer* __pTimer; + Tizen::Ui::Control* __pTargetControl; + + EGLDisplay __eglDisplay; + EGLSurface __eglSurface; + EGLConfig __eglConfig; + EGLContext __eglContext; + + /* + * EGL frame buffer configuration attributes are, + * EGL_BUFFER_SIZE, EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE, EGL_ALPHA_SIZE, + * EGL_CONFIG_CAVEAT, EGL_CONFIG_ID, EGL_DEPTH_SIZE, EGL_LEVEL, EGL_NATIVE_RENDERABLE, + * EGL_NATIVE_VISUAL_TYPE, EGL_SAMPLE_BUFFERS, EGL_SAMPLES, EGL_STENCIL_SIZE, EGL_SURFACE_TYPE, + * EGL_TRANSPARENT_TYPE, EGL_TRANSPARENT_RED_VALUE, EGL_TRANSPARENT_GREEN_VALUE, EGL_TRANSPARENT_BLUE_VALUE + */ + EGLint __eglConfigList[40]; + + int __fps; + int __renderTimeInterval; // time interval between consecutive frames in microsecond units. + + EglContextClientVersion __eglContextClientVersion; + + enum + { + PLAYER_STATE_NOT_INITIALIZED = 0, + PLAYER_STATE_START = 1, + PLAYER_STATE_PAUSE = 2, + PLAYER_STATE_STOP = 3 + } __playerState; + +}; // _GlPlayerImpl + +}}} // Tizen::Graphics::Opengl + +#endif //_FGRP_GLPLAYERIMPL_H_ diff --git a/src/graphics/inc/FGrp_NonScale.h b/src/graphics/inc/FGrp_NonScale.h new file mode 100644 index 0000000..f8ef365 --- /dev/null +++ b/src/graphics/inc/FGrp_NonScale.h @@ -0,0 +1,68 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_NonScale.h + * @brief This is the header file for internal _NonScale namespace. + * + */ + +#ifndef _FGRP_INTERNAL_NONSCALE_H_ +#define _FGRP_INTERNAL_NONSCALE_H_ + + +#include + + +namespace Tizen { namespace Base +{ +class ByteBuffer; +}} // Tizen::Base + +namespace Tizen { namespace Graphics +{ +class Dimension; + +class _BitmapImpl; + +namespace _NonScale +{ +/* + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_UNSUPPORTED_FORMAT The specified format is not supported + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ +_OSP_EXPORT_ _BitmapImpl* CreateBitmapN(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat); +_OSP_EXPORT_ _BitmapImpl* CreateBitmapN(const Tizen::Base::ByteBuffer& buffer, const Dimension& dim, BitmapPixelFormat pixelFormat, const Dimension& logicalSize); + +/* + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by the method. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ +_OSP_EXPORT_ _BitmapImpl* CreateBitmapN(const Dimension& dim, BitmapPixelFormat pixelFormat); + +// _OSP_EXPORT_ _BitmapImpl* CreateBitmapN(const Rectangle& rect); +// _OSP_EXPORT_ _BitmapImpl* CreateBitmapN(const _Canvas& canvas, const Tizen::Graphics::Rectangle& rect); +// _OSP_EXPORT_ _BitmapImpl* CreateBitmapN(const _Bitmap& bitmap, const Tizen::Graphics::Rectangle& rect); +} // Tizen::Graphics::_NonScale + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_NONSCALE_H_ diff --git a/src/graphics/inc/FGrp_Screen.h b/src/graphics/inc/FGrp_Screen.h new file mode 100644 index 0000000..3e7a96d --- /dev/null +++ b/src/graphics/inc/FGrp_Screen.h @@ -0,0 +1,41 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Screen.h + * @brief This is the header file for internal _Screen namespace. + * + */ + +#ifndef _FGRP_INTERNAL_SCREEN_H_ +#define _FGRP_INTERNAL_SCREEN_H_ + + +namespace Tizen { namespace Graphics +{ + +namespace _Screen +{ +_OSP_EXPORT_ int GetWidth(void); +_OSP_EXPORT_ int GetHeight(void); +_OSP_EXPORT_ int GetBytesPerPixel(void); + +} // Tizen::Graphics::_Screen + +}} // Tizen::Graphics + +#endif // #ifndef _FGRP_INTERNAL_SCREEN_H_ diff --git a/src/graphics/inc/FGrp_TextCommon.h b/src/graphics/inc/FGrp_TextCommon.h new file mode 100644 index 0000000..7a2d924 --- /dev/null +++ b/src/graphics/inc/FGrp_TextCommon.h @@ -0,0 +1,208 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextCommon.h + * @brief This file contains the declarations of text properties. + * + */ + +#ifndef _FGRP_INTERNAL_TEXT_COMMON_H_ +#define _FGRP_INTERNAL_TEXT_COMMON_H_ + +// Includes +#include +#include +#include +#include +#include + +// Forward Declarations +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +enum TextLineReturnType +{ + TEXT_RETBY_NORMAL = 2, + TEXT_RETBY_LINEFEED, + TEXT_RETBY_LIMITWIDTH, + TEXT_RETBY_LIMITLENGTH, + TEXT_RETBY_OVERWIDTH, + TEXT_RETBY_LINEFEED_BIDI +}; + +enum TextElementType +{ + TEXT_ELEMENT_TYPE_NONE = 0, + TEXT_ELEMENT_TYPE_TEXT, + TEXT_ELEMENT_TYPE_IMAGE, + TEXT_ELEMENT_TYPE_CUTLINK, + TEXT_ELEMENT_TYPE_MAX +}; + +enum TextElementSourceType +{ + TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL = 0, + TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, + TEXT_ELEMENT_SOURCE_TYPE_MAX +}; + +enum TextObjectWrapType +{ + TEXT_OBJECT_WRAP_TYPE_NONE = 0, + TEXT_OBJECT_WRAP_TYPE_CHARACTER, + TEXT_OBJECT_WRAP_TYPE_WORD +}; + +enum TextObjectEllipsisType +{ + TEXT_OBJECT_ELLIPSIS_TYPE_INVALID = -1, + TEXT_OBJECT_ELLIPSIS_TYPE_TAIL, + TEXT_OBJECT_ELLIPSIS_TYPE_MIDDLE, + TEXT_OBJECT_ELLIPSIS_TYPE_HEAD, + TEXT_OBJECT_ELLIPSIS_TYPE_MAX +}; + +enum TextObjectLinkColorType +{ + TEXT_OBJECT_LINK_COLOR_TYPE_NONE = -1, + TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL, + TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT, + TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL, + TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT, + TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL, + TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT, + TEXT_OBJECT_LINK_COLOR_TYPE_MAX +}; + +enum TextObjectActionType +{ + TEXT_OBJECT_ACTION_TYPE_NONE = 0, + TEXT_OBJECT_ACTION_TYPE_ABBREV, + TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT, + TEXT_OBJECT_ACTION_TYPE_SLIDE_UP, + TEXT_OBJECT_ACTION_TYPE_MAX + +}; + +enum TextObjectSpaceHideType +{ + TEXT_OBJECT_SPACE_HIDE_TYPE_NONE = 0, + TEXT_OBJECT_SPACE_HIDE_TYPE_ONE, + TEXT_OBJECT_SPACE_HIDE_TYPE_ALL +}; + +enum TextComponentInfoValueType +{ + SET_FONT = 0, + SET_FONT_FGCOLOR, + SET_FONT_BGCOLOR, + SET_FONT_OUTLINECOLOR, + MAX_TEXTOBJECT_VALUE, + SET_IMAGE_RECT, + SET_IMAGE_ALIGN, + MAX_IMAGEOBJECT_VALUE, + COMMONOBJECT_VALUE_START, + SET_ALTERNATE_LOOK = COMMONOBJECT_VALUE_START, + SET_ALTERNATIVE_FGCOLOR, + MAX_COMMONOBJECT_VALUE, + SET_TEXT_OFFSET, + SET_CUTLINK_TYPE, + SET_CUTLINK_EDITABLE, + SET_CUTLINK_EDITING, + SET_ALLVALUE_CLONE = 0xFF +}; + +enum TextObjectAlignmentType +{ + TEXT_OBJECT_ALIGNMENT_LEFT = 0x0001, + TEXT_OBJECT_ALIGNMENT_CENTER = 0x0002, + TEXT_OBJECT_ALIGNMENT_RIGHT = 0x0004, + TEXT_OBJECT_ALIGNMENT_TOP = 0x0100, + TEXT_OBJECT_ALIGNMENT_MIDDLE = 0x0200, + TEXT_OBJECT_ALIGNMENT_BOTTOM = 0x0400, + TEXT_OBJECT_ALIGNMENT_BASELINE = 0x0800, + TEXT_OBJECT_ALIGNMENT_INVALID = 0X1000 +}; + +enum TextAlignMask +{ + TEXT_ALIGNMASK_HORIZ = 0x0007, + TEXT_ALIGNMASK_VERT = 0x0F00 +}; + +enum TextObjectSweepType +{ + TEXT_OBJECT_SWEEP_TYPE_NONE = 0, + TEXT_OBJECT_SWEEP_TYPE_FORWARD, + TEXT_OBJECT_SWEEP_TYPE_BACKWARD, + TEXT_OBJECT_SWEEP_TYPE_KEYINPUT, + TEXT_OBJECT_SWEEP_TYPE_REPLACE, + TEXT_OBJECT_SWEEP_TYPE_INVALID +}; + +enum TextObjectSweepEventType +{ + TEXT_OBJECT_SWEEP_EVENT_NONE = 0, + TEXT_OBJECT_SWEEP_EVENT_INSERT, + TEXT_OBJECT_SWEEP_EVENT_REMOVE +}; + +struct TextObjectSweepInfo +{ + bool isValid; + TextObjectSweepType sweepType; + TextObjectSweepEventType sweepEventType; + int anchorTextIndex; + int anchorLineIndex; + int prevAnchorLineIndex; + int sweepRegionStartLineIndex; + int sweepRegionLineCount; + int insertedLineCount; + int deletedLineCount; + int widthChanged; +}; + +struct TextObjectSweepComposeLineInfo +{ + bool isValid; + int prevLineTextOffset; + int prevLineTextLength; + int prevLineWidth; + int currentLineTextOffset; + int currentLineTextLength; + int currentLineWidth; +}; + +typedef int TextObjectAlignment; + +//special character definistion +static const unsigned short TEXT_OBJ_CHARACTER = 0xFFFC; +static const unsigned short TEXT_LINE_FEED = 0x0A; +static const unsigned short TEXT_CARRIAGE_RETURN = 0x0D; +static const unsigned short TEXT_ABBREV_CHARACTER = 0x2026; +static const unsigned short TEXT_LINE_SEPARATOR = 0x2028; +static const unsigned short TEXT_PARAGRAPH_SEPARATOR = 0x2029; +static const unsigned short TEXT_TAB_CHARACTER = 0x09; + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_COMMON_H_ + diff --git a/src/graphics/inc/FGrp_TextElementImpl.h b/src/graphics/inc/FGrp_TextElementImpl.h new file mode 100644 index 0000000..9a122c4 --- /dev/null +++ b/src/graphics/inc/FGrp_TextElementImpl.h @@ -0,0 +1,135 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextElementImpl.h + * @brief This is the header file for the _TextElementImpl class. + * + * This header file contains the declarations of the %_TextElementImpl class. + * + */ + +#ifndef _FGRP_INTERNAL_TEXT_ELEMENT_IMPL_H_ +#define _FGRP_INTERNAL_TEXT_ELEMENT_IMPL_H_ + +// Includes +#include +#include + +#include "FGrp_TextCommon.h" + +namespace Tizen { namespace Graphics { namespace _Text +{ +class TextElement; +}}} + +namespace Tizen { namespace Graphics +{ +class _EnrichedTextImpl; + +enum _CutLinkType +{ + TEXT_CUTLINK_TYPE_INVALID = 0x0000, + TEXT_CUTLINK_TYPE_URL = 0x0001, + TEXT_CUTLINK_TYPE_EMAIL = 0x0002, + TEXT_CUTLINK_TYPE_PHONE_NUMBER = 0x0004, + TEXT_CUTLINK_TYPE_STREAMING_URL = 0x0008, //Not use in OSP. + TEXT_CUTLINK_TYPE_MAX = 0x7FFF +}; + +class _TextElementImpl +{ +public: + _TextElementImpl(void); + virtual ~_TextElementImpl(void); + + result Construct(const Tizen::Base::String& text); + result Construct(const Tizen::Base::String& text, const Tizen::Graphics::Canvas& canvas); + result Construct(void); + result Construct(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link); + result Construct(const Tizen::Base::String& text, unsigned long autoLink); + result Construct(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link, const Tizen::Graphics::Canvas& canvas); + result Construct(const Tizen::Base::String& text, unsigned long autoLink, const Tizen::Graphics::Canvas& canvas); + Tizen::Base::String& GetLink(void) const; + result SetText(const Tizen::Base::String& text); + result SetFont(const Tizen::Graphics::Font& font); + result SetTextColor(const Tizen::Graphics::Color& color); + result SetBackgroundColor(const Tizen::Graphics::Color& color); + result SetOutlineColor(const Tizen::Graphics::Color& color); + Tizen::Base::String& GetText(void) const; + Tizen::Graphics::Color GetTextColor(void) const; + Tizen::Graphics::Color GetBackgroundColor(void) const; + Tizen::Graphics::Color GetOutlineColor(void) const; + + _CutLinkType ConvertObjectLinkType(Tizen::Base::Utility::LinkType type); + Tizen::Base::Utility::LinkType ConvertObjectLinkType(_CutLinkType type); + const Tizen::Base::String& GetLinkText(void) const; + Tizen::Base::Utility::LinkType GetLinkType(void) const; + bool IsAuto(void) const; + _EnrichedTextImpl* GetRegisteringEnrichedText(void) const; + void SetRegisteringEnrichedText(_EnrichedTextImpl* pEnrichedTextImpl); + + result Create(const Tizen::Base::String& text, int length, Tizen::Graphics::_Text::TextElementSourceType srcType); + result CreateUserLink(const Tizen::Base::String& text, _CutLinkType linkType); + result CreateAutoLink(const Tizen::Base::String& text, unsigned long autoLink); + void Destroy(void); + _CutLinkType ConvertLinkType(Tizen::Base::Utility::LinkType type) const; + _CutLinkType GetCutLinkType(void) const; + int GetLength(void) const; + int GetAutolinkSrcOffset(void) const; + result SetTextObjectFont(const Tizen::Graphics::Font& font); + Tizen::Graphics::_Text::TextElement* GetComponent(void) const; + + const Tizen::Graphics::Font* GetFont(void) const; + unsigned long GetAutoLink(void) const; + bool IsBackgoundColorEnable(void) const; + bool IsOutlineColorEnable(void) const; + bool IsConstructed(void) const; + + static _TextElementImpl* GetInstance(TextElement& element); + static const _TextElementImpl* GetInstance(const TextElement& element); + +private: + Tizen::Base::String __strText; + Tizen::Graphics::Color __foregroundColor; + Tizen::Graphics::Color __backgroundColor; + Tizen::Graphics::Color __outlineColor; + Tizen::Graphics::Color __disableFGColor; + + Tizen::Base::String __linkText; + Tizen::Base::Utility::LinkType __linkType; + const Tizen::Graphics::Font* __pFont; + bool __isAuto; + bool __bgColorEnable; + bool __outlineColorEnable; + unsigned long __autoLink; + + _EnrichedTextImpl* __pRegisteringEnrichedText; + + int __count; + int __linkOffset; + Tizen::Graphics::_Text::TextElement* __pTextComponent; + +private: + _TextElementImpl(const _TextElementImpl& textElementImpl); + _TextElementImpl& operator =(const _TextElementImpl& rhs); + +}; // _TextElementImpl + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_TEXT_ELEMENT_IMPL_H_ diff --git a/src/graphics/inc/FGrp_TextTextCutLink.h b/src/graphics/inc/FGrp_TextTextCutLink.h new file mode 100644 index 0000000..4086e4a --- /dev/null +++ b/src/graphics/inc/FGrp_TextTextCutLink.h @@ -0,0 +1,114 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextCutLink.h + * @brief This is the header file for the TextCutLink class. + * + * This header file contains the declarations of the %TextCutLink class. + */ + +#ifndef _FGRP_INTERNAL_TEXT_CUTLINK_H_ +#define _FGRP_INTERNAL_TEXT_CUTLINK_H_ + +// Includes +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextSimple.h" + +namespace Tizen { namespace Graphics +{ +class _CanvasImpl; + +namespace _Text +{ + +/** + * @class TextCutLink + * @brief + * @since 2.0 + */ +class _OSP_EXPORT_ TextCutLink + : public TextSimple +{ +public: + TextCutLink(bool isEditable, Tizen::Base::Utility::LinkType cutLinkType, const wchar_t* pText, int length, + TextElementSourceType sourceType = TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, Font* pFont = null, + const Color& foregroundColor = 0, const Color& backgroundColor = 0, const Color& outlineColor = 0); + + virtual ~TextCutLink(void); + +public: + virtual TextElement* CloneN(TextComponentInfoValueType type, unsigned int value); + + virtual TextElement* CopyN(int startTextIndex, int textLength); + + virtual result ChangeTextOffset(wchar_t* pText, int gap); + + virtual unsigned int GetValue(TextComponentInfoValueType type) const; + + virtual result SetValue(TextComponentInfoValueType type, unsigned int value); + + virtual result SetTextOffset(int offset); + + bool GetEditable(void) const; + + void SetEditModeEnable(bool enable); + + bool IsEditModeEnable(void) const; + + Tizen::Base::Utility::LinkType GetCutLinkType(void) const; + + void SetSelect(bool isSelected); + + bool GetSelect(void) const; + + void SetUserColor(const Color& color, const Color& colorInSelect); + + void ResetUserColor(void); + +private: + virtual result Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment align, + const TextObjectActionType action); + + virtual Font* GetCurrentFont(void) const; + + virtual Color GetCurrentForegroundColor(void) const; + + virtual Color GetCurrentBackgroundColor(void) const; + + virtual Color GetCurrentOutlineColor(void) const; + +private: + Tizen::Base::Utility::LinkType __linkType; + bool __isSelected; + Color __linkColor; + Color __linkSelectedColor; + bool __isColorDefined; + bool __isEditable; + bool __isEdited; + Font* __pLinkFont; + +private: + TextCutLink(const TextCutLink& other); // NOT IMPLMENTED + + TextCutLink& operator =(const TextCutLink& rhs); // NOT IMPLMENTED + +}; // TextCutLink + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_CUTLINK_H_ diff --git a/src/graphics/inc/FGrp_TextTextElement.h b/src/graphics/inc/FGrp_TextTextElement.h new file mode 100644 index 0000000..fbf221f --- /dev/null +++ b/src/graphics/inc/FGrp_TextTextElement.h @@ -0,0 +1,121 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextElement.h + * @brief This is the header file for the TextElement class. + * + * This header file contains the declarations of the %TextElement class. + */ + +#ifndef _FGRP_INTERNAL_TEXT_COMPONENT_H_ +#define _FGRP_INTERNAL_TEXT_COMPONENT_H_ + +// Includes +#include +#include "FGrp_TextCommon.h" + +namespace Tizen { namespace Graphics +{ +class _CanvasImpl; + +namespace _Text +{ + +class _OSP_EXPORT_ TextElement + : public Tizen::Base::Object +{ +public: + TextElement(void); + + virtual ~TextElement(void); + +public: + virtual int ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, + int& actualLength, int& width, int& height); + + virtual result Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, + int textLength, const TextObjectAlignment alignment, const TextObjectActionType action); + + virtual TextElement* CloneN(TextComponentInfoValueType type, unsigned int value); + + virtual TextElement* CopyN(int textStart, int textLength); + + virtual void CopyMembers(TextElement* pTargetTextElement); + + virtual result GetRegion(int textIndex, int textLength, int& width, int& height) const; + + virtual result GetBlockRegion(int textIndex, int textLength, int& width, int& height) const; + + virtual int GetHeight(void) const; + + virtual int GetTextLength(void) const; + + virtual void SetTextLength(int length); + + virtual unsigned int GetValue(TextComponentInfoValueType type) const; + + virtual result SetValue(TextComponentInfoValueType type, unsigned int value); + + virtual TextElementType GetType(void) const; + + virtual TextElementSourceType GetSourceType(void) const; + + virtual bool SetFocused(bool hasFocus); + + virtual bool GetFocused(void) const; + + virtual void SetAlternateLookEnabled(bool enable); + + virtual bool IsAlternateLookEnabled(void) const; + + virtual void SetAlternativeForegroundColor(const Color& foregroundColor); + + virtual Color GetAlternativeForegroundColor(void) const; + + virtual int GetBaseline(void) const; + + virtual void SetForegroundColor(const Color& color); + + virtual Color GetForegroundColor(void) const; + + virtual void SetBackgroundColor(const Color& color); + + virtual Color GetBackgroundColor(void) const; + + virtual void SetBackGroundDrawingModeEnabled(bool enable); + + virtual bool IsBackGroundDrawingModeEnable(void) const; + +protected: + TextElementType _type; + TextElementSourceType _sourceType; + Color _alternativeColor; + int _length; + bool _hasFocus; + bool _isAlternateLookEnabled; + +private: + TextElement(const TextElement& other); // NOT IMPLMENTED + + TextElement& operator =(const TextElement& rhs); // NOT IMPLMENTED + +}; // TextElement + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_COMPONENT_H_ diff --git a/src/graphics/inc/FGrp_TextTextImage.h b/src/graphics/inc/FGrp_TextTextImage.h new file mode 100644 index 0000000..1858931 --- /dev/null +++ b/src/graphics/inc/FGrp_TextTextImage.h @@ -0,0 +1,106 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextImage.h + * @brief This is the header file for the TextImage class. + * + * This header file contains the declarations of the %TextImage class. + */ + +#ifndef _FGRP_INTERNAL_TEXT_IMAGE_H_ +#define _FGRP_INTERNAL_TEXT_IMAGE_H_ + +// Includes +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextElement.h" + +namespace Tizen { namespace Graphics +{ +class Bitmap; + +class _CanvasImpl; + +namespace _Text +{ + +/** + * @class TextImage + * @brief + * @since 2.0 + */ +class _OSP_EXPORT_ TextImage + : public TextElement +{ +public: + TextImage(Bitmap& bitmap, TextElementSourceType sourceType = TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, Rectangle* pRect = null, + TextObjectAlignment align = TextObjectAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP)); + + virtual ~TextImage(void); + +public: + virtual int ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, + int& actualLength, int& width, int& height); + + virtual result Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, + const TextObjectAlignment align, const TextObjectActionType action); + + virtual TextElement* CloneN(TextComponentInfoValueType type, unsigned int value); + + virtual TextElement* CopyN(int textStart, int textLength); + + virtual result GetRegion(int textIndex, int startTextIndex, int& width, int& height) const; + + virtual result GetBlockRegion(int textIndex, int textLength, int& width, int& height) const; + + virtual int GetHeight(void) const; + + virtual result SetValue(TextComponentInfoValueType type, unsigned int value); + + virtual unsigned int GetValue(TextComponentInfoValueType type) const; + + virtual void SetTextLength(int length); + + virtual int GetBaseline(void) const; + + result SetBounds(const Rectangle& rect); + + Rectangle GetBounds(void) const; + + result SetAlignment(TextObjectAlignment alignment); + + TextObjectAlignment GetAlignment(void) const; + + const Bitmap* GetBitmap(void) const; + +private: + Bitmap* __pBitmap; + Rectangle __rect; + TextObjectAlignment __align; + +private: + TextImage(void); // NOT IMPLMENTED + + TextImage(const TextImage& other); // NOT IMPLMENTED + + TextImage& operator =(const TextImage& rhs); // NOT IMPLMENTED + +}; // TextImage + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_IMAGE_H_ diff --git a/src/graphics/inc/FGrp_TextTextObject.h b/src/graphics/inc/FGrp_TextTextObject.h new file mode 100644 index 0000000..f813d38 --- /dev/null +++ b/src/graphics/inc/FGrp_TextTextObject.h @@ -0,0 +1,332 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextObject.h + * @brief This is the header file for the TextObject class. + * + * This file contains the declarations of TextObject class. + */ + +#ifndef _FGRP_INTERNAL_TEXT_OBJECT_H_ +#define _FGRP_INTERNAL_TEXT_OBJECT_H_ + +// Includes +#include "FGrp_TextCommon.h" + +// Forward Declarations +namespace Tizen { namespace Graphics { + +class _CanvasImpl; +class Bitmap; +class Point; + +namespace _Text +{ +class TextElement; +class TextWidthManager; +class TextComposite; +class TextColumn; + +class _OSP_EXPORT_ TextObject +{ +public: + TextObject(void); + + virtual ~TextObject(void); + +public: + result Construct(void); + + result Construct(const Rectangle& rect); + + TextObject* CloneN(void); + + result Draw(_CanvasImpl& canvasImpl); + + result DrawLine(_CanvasImpl& canvasImpl, int lineIndex); + + result DrawWithOffset(_CanvasImpl& canvasImpl); + + bool IsChanged(void) const; + + result Compose(void); + + result GetChangedLineRange(int& startChangedLineIndex, int& endChangedLineIndex); + + int GetText(wchar_t* pCopiedText, int textLength) const; + + result RemoveAll(bool deallocate = true); + + result RemoveElement(TextElement& textElement, bool deallocate); + + result RemoveElementAt(int elementIndex, bool deallocate); + + result AppendElement(TextElement& textElement); + + result AppendElement(Bitmap& bitmap, TextElementSourceType sourceType); + + result InsertElementAt(int textIndex, TextElement& textElement); + + result InsertElementAt(int textIndex, Bitmap& bitmap, TextElementSourceType sourceType); + + int GetElementIndexOf(TextElement& textElement) const; + + int GetElementCount(void) const; + + TextElement* GetElementAtElementIndex(int elementIndex) const; + + TextElement* GetElementAtTextIndex(int textIndex) const; + + int GetTextIndexFromPosition(int lcX, int lcY, bool cursorMode = false) const; + + int GetTextIndexFromPositionAtLine(int lineIndex, int lcX, bool cursorMode = false) const; + + result ChangeTextOffset(wchar_t* pText, int textIndex, int gap); + + result NotifyTextChanged(wchar_t* pText, int textOffset, int textLength, int gap); + + int GetTotalLineCount(void) const; + + int GetLineIndexAtTextIndex(int textIndex) const; + + int GetTotalHeight(void) const; + + int GetLineHeightAt(int lineIndex) const; + + int GetLineWidthAt(int lineIndex) const; + + int GetDisplayLineCount(void) const; + + int GetLineIndexAtPositionY(int lcY) const; + + int GetFirstTextIndexAt(int lineIndex) const; + + int GetTextLengthAt(int lineIndex) const; + + int GetMaxLineHeight(void) const; + + int GetTextLength(void) const; + + Dimension GetTextExtent(int startTextIndex, int textLength) const; + + result SetAction(TextObjectActionType action); + + TextObjectActionType GetAction(void) const; + + result SetAlignment(TextObjectAlignment alignment); + + TextObjectAlignment GetAlignment(void) const; + + result SetElementVerticalAlignment(TextObjectAlignment alignment); + + TextObjectAlignment GetElementVerticalAlignment(void) const; + + result SetBounds(const Rectangle& lcRect); + + Rectangle GetBounds(void) const; + + result SetLineSpace(int lcLineSpacing); + + int GetLineSpace(void) const; + + result SetRange(int startTextIndex, int textLength); + + void GetRange(int& startTextIndex, int& textLength) const; + + result SetFont(Font* pFont, int startTextIndex, int textLength); + + const Font* GetFont(int textIndex) const; + + result SetForegroundColor(const Color& color, int startTextIndex, int textLength); + + Color GetForegroundColor(int textIndex) const; + + result SetBackgroundColor(const Color& color, int startTextIndex, int textLength); + + Color GetBackgroundColor(int textIndex) const; + + result SetOutlineColor(const Color& color, int startTextIndex, int textLength); + + Color GetOutlineColor(int textIndex) const; + + result SetWrap(TextObjectWrapType wrap); + + TextObjectWrapType GetWrap(void) const; + + result SetCursorIndex(int cursorIndex); + + int GetCursorIndex(void) const; + + result SetBlock(bool enable); + + bool GetBlock(void) const; + + result SetBlockRange(int startTextIndex, int textLength); + + void GetBlockRange(int& startTextIndex, int& textLength); + + result SetSlidingStep(int lcSlidingStep); + + int GetSlidingStep(void) const; + + result SetAlternateLookEnabled(bool enable); + + bool IsAlternateLookEnabled(void) const; + + result SetWidthManagerEnabled(bool widthManagerEnable); + + bool IsWidthManagerEnabled(void) const; + + result SetFirstDisplayLineIndexFromTextIndex(int textIndex); + + result SetFirstDisplayLineIndex(int lineIndex); + + int GetFirstDisplayLineIndex(void) const; + + result SetFirstDisplayPositionY(int lcY); + + int GetFirstDisplayPositionY(void) const; + + result SetPartialComposingModeEnabled(bool enable); + + bool IsPartialComposingModeEnabled(void) const; + + result SetTextObjectEllipsisType(TextObjectEllipsisType type); + + TextObjectEllipsisType GetTextObjectEllipsisType(void) const; + + result HideFrontSpace(TextObjectSpaceHideType mode); + + result HideRearSpace(TextObjectSpaceHideType mode); + + result SetAlternativeForegroundColor(const Color& color); + + result SetCutLinkViewMode(bool enable); + + int GetTotalCutLinkElementCount(void) const; + + int GetCutLinkIndexFromPositionData(int lcX, int lcY) const; + + TextElement* GetCutLinkElementAtCutLinkElementIndex(int linkIndex) const; + + result ChangeCutLinkState(int linkIndex, bool select); + + result ResetAllCutLinkElementsState(void); + + result SetCutLinkColor(Tizen::Base::Utility::LinkType linkType, const Color& color, const Color& colorInSelect); + + result ResetCutLinkColor(Tizen::Base::Utility::LinkType linkType); + + result GetCutLinkBounds(int cutLinkIndex, Point& startPoint, Point& endPoint) const; + + bool IsActionOn(void) const; + + bool IsDisplayedAtStartPosition(void) const; + + bool IsDisplayedAtEndPosition(void) const; + + result GetTextPositionInfoAt(int textIndex, int& width, int& height, int& absX, int& absY, int& logicalX, int& logicalY) const; + + TextObjectSweepInfo GetSweepInfo(void) const; + + result ResetSweepInfo(void); + + result GetSweepComposeLineInfo(int lineIndex, TextObjectSweepComposeLineInfo& textSweepComposeLineInfo) const; + + int GetTextOffsetAtLine(int lineIndex) const; + + int GetTextLengthAtLine(int lineIndex) const; + + Rectangle GetBoundsAtLine(int lineIndex) const; + + result SetBlockColor(const Color& color); + + Color GetBlockColor(void) const; + +private: + result DrawByLine(_CanvasImpl& canvasImpl, const Rectangle& displayRect); + + int GetTotalComposedHeight(void) const; + + result GetTextPositionInfoInWrapAt(int textIndex, int& width, int& height, int& absX, int& absY, + int& logicalX, int& logicalY) const; + + result GetTextPositionInfoInNoneWrapAt(int textIndex, int& width, int& height, int& absX, int& absY, + int& logicalX, int& logicalY) const; + + int GetTextIndexFromPositionInWrap(int pcX, int pcY, bool cursorMode = true) const; + + int GetTextIndexFromPositionInNoneWrap(int pcX, int pcY, bool cursorMode = true) const; + + result UpdateChangedInfo(int startTextIndex, int textLength = -1, bool initTextWidthManager = true); + + result NotifyTextAdded(int textIndex, int textLength); + + result NotifyTextDeleted(int textIndex, int textLength); + + result SetFirstDisplayLineIndexFromTextIndexInWrap(int textIndex); + + result SetFirstDisplayLineIndexFromTextIndexInNoneWrap(int textIndex); + + result ChangeText(int textIndex); + + result InputText(int textIndex); + + result RemoveText(int textIndex); + + Point GetDisplayPositionAtLine(int lineIndex, int textIndexFromLineOffset); + +// Attribute +private: + Rectangle __rect; + Rectangle __pcRect; + TextObjectActionType __action; + TextObjectAlignment __align; + TextObjectWrapType __wrap; + TextComposite* __pCompositeText; + TextColumn* __pTextColumn; + bool __isActionOn; + bool __isChanged; + bool __isAlternateLookEnabled; + Font* __pDefaultFont; + Color __defaultForegroundColor; + Color __defaultBackgroundColor; + Color __defaultOutlineColor; + int __slidingStep; + int __slidingGap; + TextObjectEllipsisType __textObjectEllipsisType; + bool __isFirstDisplayPositionYChanged; + bool __linkViewModeEnabled; + bool __isUrlLinkColorDefined; + bool __isEmailLinkColorDefined; + bool __isPhoneNumberLinkColorDefined; + Color __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_MAX]; + TextWidthManager* __pTextWidthManager; + + TextObjectSweepInfo __sweepInfo; + +private: + TextObject(const TextObject& other); // NOT IMPLMENTED + + TextObject& operator =(const TextObject& rhs); // NOT IMPLMENTED + +}; // TextObject + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_OBJECT_H_ diff --git a/src/graphics/inc/FGrp_TextTextSimple.h b/src/graphics/inc/FGrp_TextTextSimple.h new file mode 100644 index 0000000..ed63b49 --- /dev/null +++ b/src/graphics/inc/FGrp_TextTextSimple.h @@ -0,0 +1,166 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextSimple.h + * @brief This is the header file for the TextSimple class. + * + * This header file contains the declarations of the TextSimple class. + */ + +#ifndef _FGRP_INTERNAL_TEXT_SIMPLE_H_ +#define _FGRP_INTERNAL_TEXT_SIMPLE_H_ + +// Includes +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextElement.h" + +namespace Tizen { namespace Graphics +{ +class _CanvasImpl; + +namespace _Text +{ + +enum WordType +{ + WORD_ENTER = 0, + WORD_SPACE, + WORD_WORD, + WORD_ERROR +}; + +class _OSP_EXPORT_ TextSimple + : public TextElement +{ +public: + TextSimple(const wchar_t* pText, int length, TextElementSourceType sourceType = TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, Font* pFont = null, + const Color& foregroundColor = Color::GetColor(COLOR_ID_BLACK), const Color& backgroundColor = Color::GetColor(COLOR_ID_WHITE), + const Color& outlineColor = 0); + + virtual ~TextSimple(void); + +public: + virtual result Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, + const TextObjectAlignment alignment, const TextObjectActionType action); + + virtual int ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, + int& actualLength, int& width, int& height); + + virtual TextElement* CloneN(TextComponentInfoValueType type, unsigned int value); + + virtual TextElement* CopyN(int startTextIndex, int textLength); + + virtual result GetRegion(int textIndex, int textLength, int& width, int& height) const; + + virtual result GetBlockRegion(int textIndex, int textLength, int& width, int& height) const; + + virtual int GetHeight(void) const; + + virtual unsigned int GetValue(TextComponentInfoValueType type) const; + + virtual result SetValue(TextComponentInfoValueType type, unsigned int value); + + virtual result ChangeTextOffset(wchar_t* pText, int gap); + + virtual result SetTextOffset(int offset); + + virtual int GetBaseline(void) const; + + int GetTextOffset(void) const; + + result SetFont(const Font* pFont); + + const Font* GetFont(void) const; + + virtual void SetForegroundColor(const Color& color); + + virtual Color GetForegroundColor(void) const; + + virtual void SetBackgroundColor(const Color& color); + + virtual Color GetBackgroundColor(void) const; + + void SetOutlineColor(const Color& color); + + Color GetOutlineColor(void) const; + + virtual void SetBackGroundDrawingModeEnabled(bool enable); + + virtual bool IsBackGroundDrawingModeEnable(void) const; + + const wchar_t* GetTextSource(void) const; + + const wchar_t* GetText(void) const; + + bool IsSame(wchar_t* pText, Font* pFont, const Color& foregroundColor, + const Color& backgroundColor, const Color& outlineColor); + + void SetUserWrap(TextObjectWrapType userWrap); + + int GetWordLength(int textIndex, int& wordLength) const; + + result SetBitmap(const Bitmap& bitmap); + + const Bitmap* GetBitmap(void) const; + +private: + static int ConvertEnterToSpace(wchar_t* pDstText, const wchar_t* pSrcText, int textLength); + + bool IsKorean(const wchar_t* ch) const; + + bool IsChinese(const wchar_t* ch) const; + + int GetSentenceLength(const wchar_t* pText, int textLength, int& actualLength) const; + + int GetWordWrapLength(const wchar_t* pText, int textLength, int& actualLength) const; + + int GetWordWrapLengthEx(const wchar_t* pText, int textLength, int& actualLength) const; + +protected: + virtual Font* GetCurrentFont(void) const; + + virtual Color GetCurrentForegroundColor(void) const; + + virtual Color GetCurrentBackgroundColor(void) const; + + virtual Color GetCurrentOutlineColor(void) const; + +protected: + const wchar_t* _pText; + Font* _pFont; + TextObjectWrapType _userWrap; + Color _foregroundColor; + Color _backgroundColor; + Color _outlineColor; + bool _outline; + int _offset; + bool _isBackgroundDrawingModeEnabled; + +private: + const Bitmap* __pBitmap; + +private: + TextSimple(const TextSimple& other); // NOT IMPLMENTED + + TextSimple& operator =(const TextSimple& rhs); // NOT IMPLMENTED + +}; // TextSimple + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_SIMPLE_H_ diff --git a/src/graphics/inc/FGrp_VideoTextureImpl.h b/src/graphics/inc/FGrp_VideoTextureImpl.h new file mode 100644 index 0000000..4ce579b --- /dev/null +++ b/src/graphics/inc/FGrp_VideoTextureImpl.h @@ -0,0 +1,66 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_VideoTextureImpl.h + * @brief This is the header file for the _VideoTextureImpl class. + * + */ + +#ifndef _FGRP_VIDEO_TEXTUREIMPL_H_ +#define _FGRP_VIDEO_TEXTUREIMPL_H_ + +#include + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +class VideoTexture; +class _VideoTexture; +class IVideoTextureUpdateListener; + +class _OSP_EXPORT_ _VideoTextureImpl + : public Tizen::Base::Object +{ +public: + _VideoTextureImpl(void); + virtual ~_VideoTextureImpl(void); + + result Construct(int textureId, int width, int height); + result BindTexture(void); + void AddVideoTextureUpdateListener(IVideoTextureUpdateListener& listener, VideoTexture* pVideoTexture); + void RemoveVideoTextureUpdateListener(IVideoTextureUpdateListener& listener); + +public: + static _VideoTextureImpl* GetInstance(VideoTexture& videoTexture); + static const _VideoTextureImpl* GetInstance(const VideoTexture& videoTexture); + static unsigned int GetPixmap(void* pData); + +private: + + _VideoTextureImpl(const _VideoTextureImpl& rhs); + _VideoTextureImpl& operator =(const _VideoTextureImpl& rhs); + +private: + _VideoTexture* __pNativeVideoTexture; + + friend class VideoTexture; +}; // VideoTexture + +}}} // Tizen::Graphics + +#endif //_FGRP_VIDEO_TEXTUREIMPL_H_ diff --git a/src/graphics/opengl/CMakeLists.txt b/src/graphics/opengl/CMakeLists.txt new file mode 100755 index 0000000..d143fd1 --- /dev/null +++ b/src/graphics/opengl/CMakeLists.txt @@ -0,0 +1,40 @@ +SET (this_target opengl) + +INCLUDE_DIRECTORIES( + ${SLP_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/inc + ${CMAKE_SOURCE_DIR}/src/graphics/inc + ${CMAKE_SOURCE_DIR}/src/ui/inc + /usr/include/osp + /usr/include/osp/base + /usr/include/osp/ui +) + +SET (${this_target}_SOURCE_FILES + FGrpEgl.cpp + FGrpGles1.cpp + FGrpGles2.cpp + FGrpGlPlayer.cpp + FGrp_GlPlayerImpl.cpp + FGrpCanvasTexture.cpp + FGrp_CanvasTexture.cpp + FGrp_CanvasTextureImpl.cpp + FGrpVideoTexture.cpp + FGrp_VideoTexture.cpp + FGrp_VideoTextureImpl.cpp +) + +## Add Definitions +ADD_DEFINITIONS(${OSP_DEFINITIONS} -D_MODEL_RES_WVGA) + +## SET EXTRA COMPILER FLAGS +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC" ) + +## SET C COMPILER FLAGS +SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## SET CPP COMPILER FLAGS +SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## Create Library +ADD_LIBRARY (${this_target} STATIC ${${this_target}_SOURCE_FILES}) diff --git a/src/graphics/opengl/FGrpCanvasTexture.cpp b/src/graphics/opengl/FGrpCanvasTexture.cpp new file mode 100644 index 0000000..744ebad --- /dev/null +++ b/src/graphics/opengl/FGrpCanvasTexture.cpp @@ -0,0 +1,68 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpCanvasTexture.cpp + * @brief This is the implementation file for CanvasTexture class. + * + */ + +#include + +#include +#include +#include +#include + +#include "FGrp_CanvasTextureImpl.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +CanvasTexture::CanvasTexture(void) + : __pImpl(new (std::nothrow)_CanvasTextureImpl) +{ +} + +CanvasTexture::~CanvasTexture(void) +{ + delete this->__pImpl; +} + +result +CanvasTexture::Construct(int textureId, int width, int height) +{ + SysTryReturnResult(NID_GRP, this->__pImpl != null, E_OUT_OF_MEMORY, "Fails to allocate memory.\n"); + + result r = this->__pImpl->Construct(textureId, width, height); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Canvas* +CanvasTexture::GetCanvasN(void) const +{ + SysAssert(this->__pImpl != null); + + return this->__pImpl->GetCanvasN(); +} + +}}} // Tizen::Graphics::Opengl diff --git a/src/graphics/opengl/FGrpEgl.cpp b/src/graphics/opengl/FGrpEgl.cpp new file mode 100644 index 0000000..6c6f6d6 --- /dev/null +++ b/src/graphics/opengl/FGrpEgl.cpp @@ -0,0 +1,2315 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpEgl.cpp + * @brief This is the implementation file for egl. + * + */ + +#include +#include +#include + +#if defined(_OSP_EMUL_) +#define FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER +#else +#define FGRAPHICS_INTERNAL_USE_DRM +#endif + +#define FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING +#if defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING) +#include +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +#if defined(FGRAPHICS_INTERNAL_USE_DRM) +#include +#include +#include +#include +#endif + +typedef int _SglIndex; + +EGLSurface +_SglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* pAttribList); +EGLSurface _SglGetCurrentSurface(EGLint readDraw); +EGLNativePixmapType _CreateNativePixmap(_SglIndex sglIndex, Tizen::Graphics::Bitmap* pixmap); +EGLNativePixmapType _CreateNativePixmapEx(Tizen::Graphics::Bitmap* pBitmap, Tizen::Graphics::BufferInfo bufferInfo); + +#if defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING) +void _GlesInterfaceTerminate_1(); +void _GlesInterfaceTerminate_2(); +#endif + +using namespace Tizen::Ui::Controls; + +#define FGRAPHICS_INTERNAL_USE_FBO +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + +#include +bool _GlesFboInitialize_1(int& fboWidth, int& fboHeight, GLuint& frameBufferObject, GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer + , GLuint colorSize, GLuint depthSize, GLuint stencilSize, GLuint& textureId); +bool _GlesFboBinding_1(const GLuint frameBufferObject); +void _GlesFboSwapBuffers_1(const Frame* pFrame, int fboWidth, int fboHeight, const GLuint frameBufferObject, const GLuint textureId); +void _GlesFboTerminate_1(GLuint& frameBufferObject, GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer, GLuint& textureId); + +bool _GlesFboInitialize_2(const int fboWidth, const int fboHeight, GLuint& frameBufferObject, GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer + , GLuint colorSize, GLuint depthSize, GLuint stencilSize, GLuint& textureId, GLuint &program); +bool _GlesFboBinding_2(const GLuint frameBufferObject); +void _GlesFboSwapBuffers_2(const Frame* pFrame, const GLuint frameBufferObject, const GLuint textureId, const GLuint program); +void _GlesFboTerminate_2(GLuint& frameBufferObject, GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer + , GLuint& textureId, GLuint& program); +#endif + +#ifdef __cplusplus +} +#endif + +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui; +using namespace Tizen::Base; + +namespace Tizen { namespace Graphics +{ + +namespace Opengl +{ + +namespace // unnamed +{ + +#define FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) +void _PostRenderCallback(Ecore_Evas* ee); +void _SaveCurrentContext(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); +void _UnregisterRenderCallback(Evas_Object* pObject); +#endif + +#if !defined(_OSP_EMUL_) +#define FGRAPHICS_INTERNAL_USE_EVAS_NATIVE_SURFACE +#endif +bool isEvasNativeSetEnabled = false; + +void _OnBoundsChanged(void* pData); + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) +void _OnBoundsChangedFbo(void* pData); +EGLContext _fboContext = EGL_NO_CONTEXT; +#endif + +const int INVALID_SGL_INDEX = 0; +const int MAX_SGL_INDEX = 100; + +class _SglInfo +{ +public: + _SglInfo(void) + : sglIndex(INVALID_SGL_INDEX) + , display(EGL_NO_DISPLAY) + , surface(EGL_NO_SURFACE) + , context(EGL_NO_CONTEXT) + , config((EGLConfig)0) + , pBitmap(null) + , pObject(null) + , nativePixmap((EGLNativePixmapType)0) + , pVisualElementImpl(null) + , pControl(null) +#if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER) + , pEcoreImage(null) + , width(0) + , height(0) +#endif +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + , frameBufferObject(0) + , depthRenderBuffer(0) + , stencilRenderBuffer(0) + , colorSize(0) + , depthSize(0) + , stencilSize(0) + , isStencilEnabled(false) + , textureId(0) + , program(0) + , pFrame(null) + , glVersion(0) + , isFboAvailable(true) + , fboWidth(0) + , fboHeight(0) +#endif + { + } + + virtual ~_SglInfo(void) + { +#if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER) + if (this->pEcoreImage != null) + { + ecore_x_image_free(this->pEcoreImage); + } +#endif + if (pBitmap != null && pObject != null) + { + int objectWidth = 0; + int objectHeight = 0; + int objectBitsPerPixel = 0; + Evas_Colorspace colorSpace = EVAS_COLORSPACE_ARGB8888; + +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) + if (isEvasNativeSetEnabled) + { + _UnregisterRenderCallback(pObject); + } +#endif + evas_object_image_size_get(pObject, &objectWidth, &objectHeight); + colorSpace = evas_object_image_colorspace_get(pObject); + if (colorSpace == EVAS_COLORSPACE_ARGB8888) + { + objectBitsPerPixel = 32; + } + else if (colorSpace == EVAS_COLORSPACE_RGB565_A5P) + { + objectBitsPerPixel = 24; + } + else if (colorSpace == EVAS_COLORSPACE_GRY8) + { + objectBitsPerPixel = 8; + } + else + { + SysLog(NID_GRP, "Incompatible color space for Evas Object."); + objectBitsPerPixel = 0; + } + + int size = objectWidth * objectHeight * objectBitsPerPixel; + + if (size > 0) + { + void* pPtr = new (std::nothrow) int[size]; + if (pPtr == null) + { + SysLog(NID_GRP, "Fail to allocate memory for Evas Object."); + } + + evas_object_image_data_set(pObject, pPtr); + } + else + { + evas_object_image_data_set(pObject, NULL); + SysLog(NID_GRP, "Incompatible size for Evas object. w:%d h:%d bps:%d", objectWidth, objectHeight, objectBitsPerPixel); + } + + delete pBitmap; + } + } + +public: + _SglIndex sglIndex; + EGLDisplay display; + EGLSurface surface; + EGLContext context; + EGLConfig config; + Bitmap* pBitmap; + Evas_Object* pObject; + EGLNativePixmapType nativePixmap; + _VisualElementImpl* pVisualElementImpl; + Control* pControl; +#if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER) + Ecore_X_Image* pEcoreImage; + int width; + int height; +#endif +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + GLuint frameBufferObject; + GLuint depthRenderBuffer; + GLuint stencilRenderBuffer; + EGLint colorSize; + EGLint depthSize; + EGLint stencilSize; + bool isStencilEnabled; + GLuint textureId; + GLuint program; + Frame* pFrame; + int glVersion; + bool isFboAvailable; + int fboWidth; + int fboHeight; +#endif + +private: + _SglInfo(const _SglInfo& sglInfo); + _SglInfo& operator =(const _SglInfo& rhs); +}; + +class _PixmapInfo +{ +public: + _PixmapInfo(void) + : nativePixmap((Pixmap)0) +#if defined(FGRAPHICS_INTERNAL_USE_DRM) + , pDrmBufMgr(null) + , pDrmBufferObject(null) +#endif + { + } + + virtual ~_PixmapInfo(void) + { + Display* pDisplay = (Display*)ecore_x_display_get(); +#if defined(FGRAPHICS_INTERNAL_USE_DRM) + drm_slp_bo_unmap(this->pDrmBufferObject, DRM_SLP_DEVICE_CPU); + drm_slp_bo_unref(this->pDrmBufferObject); + if (this->pDrmBufMgr) + { + close(this->pDrmBufMgr->drm_fd); + } + drm_slp_bufmgr_destroy(this->pDrmBufMgr); + DRI2DestroyDrawable(pDisplay, this->nativePixmap); +#endif + XFreePixmap(pDisplay, this->nativePixmap); + } + +public: + Pixmap nativePixmap; +#if defined(FGRAPHICS_INTERNAL_USE_DRM) + drm_slp_bufmgr pDrmBufMgr; + drm_slp_bo pDrmBufferObject; +#endif +}; + +void _EvasObjectImageChange(_SglInfo* pSglInfo); + +void +_OnBoundsChanged(void* pData) +{ + _SglInfo* pSglInfo = (_SglInfo*)pData; + _SglIndex readSurface = 0; + _SglIndex drawSurface = 0; + bool needMakeCurrent = false; + EGLBoolean ret = EGL_FALSE; + int width = 0; + int height = 0; + VisualElementSurface* pVisualElementSurface = null; + _VisualElementSurfaceImpl* pVisualElementSurfaceImpl = null; + + result r = E_SUCCESS; + Tizen::Graphics::FloatRectangle rect; + + if (pSglInfo == null || pSglInfo->sglIndex <= INVALID_SGL_INDEX) + { + goto CATCH_01; + } + + readSurface = (_SglIndex)_SglGetCurrentSurface(EGL_READ); + drawSurface = (_SglIndex)_SglGetCurrentSurface(EGL_DRAW); + if (readSurface == pSglInfo->sglIndex || drawSurface == pSglInfo->sglIndex) + { + needMakeCurrent = true; + } + + ret = eglMakeCurrent(pSglInfo->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + if (ret == EGL_FALSE) + { + goto CATCH_01; + } + + ret = eglDestroySurface(pSglInfo->display, pSglInfo->surface); + if (ret == EGL_FALSE) + { + goto CATCH_02; + } + + if (pSglInfo->pVisualElementImpl == null) + { + goto CATCH_02; + } + + rect = pSglInfo->pVisualElementImpl->GetBounds(); + width = int(rect.width); + height = int(rect.height); + if (width <= 0 || height <=0) + { + goto CATCH_02; + } + + if (isEvasNativeSetEnabled) + { + if (pSglInfo->pControl == null) + { + goto CATCH_02; + } + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*pSglInfo->pControl); + if (pControlImpl == null) + { + goto CATCH_02; + } + + VisualElement* pVE = pControlImpl->GetCore().GetVisualElement(); + if (pVE == null) + { + goto CATCH_02; + } + + Control* pFrame = pSglInfo->pControl; + Control* pTemp = pFrame->GetParent(); + while(pTemp != null) + { + pFrame = pTemp; + pTemp = pTemp->GetParent(); + } + + Dimension size(width, height); + Tizen::Ui::Window* pWindow = dynamic_cast (pFrame); + if (pWindow == null) + { + goto CATCH_02; + } + + pVisualElementSurface = new (std::nothrow) VisualElementSurface(); + if (pVisualElementSurface == null) + { + goto CATCH_02; + } + + r = pVisualElementSurface->Construct(*pWindow->GetDisplayContext(), size); + pVE->SetSurface(pVisualElementSurface); + } + else + { + pVisualElementSurface = pSglInfo->pVisualElementImpl->GetSurfaceN(); + if (pVisualElementSurface == null) + { + goto CATCH_02; + } + } + + if (pSglInfo->pBitmap != null) + { + delete pSglInfo->pBitmap; + pSglInfo->pBitmap = null; + } + + pSglInfo->pBitmap = new (std::nothrow) Tizen::Graphics::Bitmap; + if (pSglInfo->pBitmap == null) + { + goto CATCH_03; + } + + r = pSglInfo->pBitmap->Construct(Tizen::Graphics::Rectangle(0, 0, width, height)); + if (r != E_SUCCESS) + { + goto CATCH_04; + } + + pSglInfo->nativePixmap = _CreateNativePixmap(pSglInfo->sglIndex, pSglInfo->pBitmap); + if (pSglInfo->nativePixmap == 0) + { + goto CATCH_04; + } + + pSglInfo->surface = eglCreatePixmapSurface(pSglInfo->display, pSglInfo->config, pSglInfo->nativePixmap, null); + if (pSglInfo->surface == EGL_NO_SURFACE) + { + goto CATCH_04; + } + + if (needMakeCurrent) + { + eglMakeCurrent(pSglInfo->display, pSglInfo->surface, pSglInfo->surface, pSglInfo->context); + eglWaitGL(); +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) + _SaveCurrentContext(pSglInfo->display, pSglInfo->surface, pSglInfo->surface, pSglInfo->context); +#endif + } + + pVisualElementSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pVisualElementSurface); + if (pVisualElementSurfaceImpl == null) + { + goto CATCH_04; + } + + pSglInfo->pObject = (Evas_Object*)pVisualElementSurfaceImpl->GetNativeHandle(); + if (pSglInfo->pObject == null) + { + goto CATCH_04; + } + + _EvasObjectImageChange(pSglInfo); + + return; + +CATCH_04: + delete pSglInfo->pBitmap; + pSglInfo->pBitmap = null; + //fall through + +CATCH_03: + delete pVisualElementSurface; + //fall through + +CATCH_02: + if (needMakeCurrent) + { + eglMakeCurrent(pSglInfo->display, pSglInfo->surface, pSglInfo->surface, pSglInfo->context); + eglWaitGL(); +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) + _SaveCurrentContext(pSglInfo->display, pSglInfo->surface, pSglInfo->surface, pSglInfo->context); +#endif + } + //fall through + +CATCH_01: + SysLog(NID_GRP, "_OnBoundsChanged failed!! pSglInfo:%#x", (unsigned int)pSglInfo); +} + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) +void +_OnBoundsChangedFbo(void* pData) +{ + _SglInfo* pSglInfo = (_SglInfo*)pData; + + if (pSglInfo == null || pSglInfo->pVisualElementImpl == null) + { + SysLog(NID_GRP, "FBO Invalid data"); + return; + } + + FloatRectangle rect = pSglInfo->pVisualElementImpl->GetBounds(); + pSglInfo->fboWidth = int(rect.width); + pSglInfo->fboHeight = int(rect.height); + + if (pSglInfo->glVersion == 1) + { + eglMakeCurrent(pSglInfo->display + , pSglInfo->surface + , pSglInfo->surface + , pSglInfo->context); + + _GlesFboTerminate_1(pSglInfo->frameBufferObject + , pSglInfo->depthRenderBuffer + , pSglInfo->stencilRenderBuffer + , pSglInfo->textureId + ); + + _GlesFboInitialize_1(pSglInfo->fboWidth + , pSglInfo->fboHeight + , pSglInfo->frameBufferObject + , pSglInfo->depthRenderBuffer + , pSglInfo->stencilRenderBuffer + , pSglInfo->colorSize + , pSglInfo->depthSize + , pSglInfo->stencilSize + , pSglInfo->textureId + ); + } + else if (pSglInfo->glVersion == 2) + { + eglMakeCurrent(pSglInfo->display + , pSglInfo->surface + , pSglInfo->surface + , pSglInfo->context); + + _GlesFboTerminate_2(pSglInfo->frameBufferObject + , pSglInfo->depthRenderBuffer + , pSglInfo->stencilRenderBuffer + , pSglInfo->textureId + , pSglInfo->program + ); + + _GlesFboInitialize_2(pSglInfo->fboWidth + , pSglInfo->fboHeight + , pSglInfo->frameBufferObject + , pSglInfo->depthRenderBuffer + , pSglInfo->stencilRenderBuffer + , pSglInfo->colorSize + , pSglInfo->depthSize + , pSglInfo->stencilSize + , pSglInfo->textureId + , pSglInfo->program + ); + } + else + { + SysLog(NID_GRP, "ambiguous gl Version %d", pSglInfo->glVersion); + } +} +#endif //#if defined(FGRAPHICS_INTERNAL_USE_FBO) + +class _SglInfoTableManipulator +{ +public: + _SglInfoTableManipulator() + { + result r = __SglMutex.Create(); + SysTryLog(NID_GRP, r == E_SUCCESS, "Failed to create mutex. [%s]", GetErrorMessage(r)); + __SglIndexLastUsed = INVALID_SGL_INDEX; + __SglInitialized = false; + } + + ~_SglInfoTableManipulator() + { + } + + _SglIndex + FindNextEmptySlotOfSglInfoTable() + { + if (!__SglInitialized) + { + if (CreateSglInfoTable() == false) + { + return INVALID_SGL_INDEX; + } + } + + _SglIndex sglIndex = INVALID_SGL_INDEX; + _SglIndex index = __SglIndexLastUsed; + { + __SglMutex.Acquire(); + for (int i = 1; i < MAX_SGL_INDEX; i++) + { + index++; + + if (index >= MAX_SGL_INDEX) + { + index = 1; + } + + if (__SglInfoTable[index] == null) + { + sglIndex = index; + __SglIndexLastUsed = index; + break; + } + } + __SglMutex.Release(); + } + + if (sglIndex <= INVALID_SGL_INDEX) + { + return INVALID_SGL_INDEX; + } + + return sglIndex; + } + + bool + CreateSglInfoTable() + { + bool ret = false; + + __SglMutex.Acquire(); + + for (int i = 0 ; i < MAX_SGL_INDEX; i++) + { + __SglInfoTable[i] = null; + } + + __SglInfoTable[0] = new (std::nothrow) _SglInfo; + if (__SglInfoTable[0] != null) + { + ret = true; + __SglInitialized = true; + } + + __SglMutex.Release(); + + return ret; + } + + void + DestroySglInfoTable() + { + __SglMutex.Acquire(); + + for (int i = 0 ; i < MAX_SGL_INDEX; i++) + { + if (__SglInfoTable[i] != null) + { + delete __SglInfoTable[i]; + __SglInfoTable[i] = null; + } + } + __SglInitialized = false; + + __SglMutex.Release(); + } + + _SglInfo* + LockSglInfoTable(_SglIndex index) + { + __SglMutex.Acquire(); + + if (index < INVALID_SGL_INDEX || index >= MAX_SGL_INDEX) + { + return null; + } + + return __SglInfoTable[index]; + } + + void + UnlockSglInfoTable() + { + __SglMutex.Release(); + } + + _SglIndex + CreateSglIndex(void) + { + _SglInfo* newSglInfo = new (std::nothrow) _SglInfo; + if (newSglInfo == null) + { + SysLog(NID_GRP, "CreateSglIndex fail to allocate _SglInfo!!"); + return INVALID_SGL_INDEX; + } + + int sglIndex = FindNextEmptySlotOfSglInfoTable(); + if (sglIndex == INVALID_SGL_INDEX) + { + delete newSglInfo; + + SysLog(NID_GRP, "CreateSglIndex failed!!"); + return INVALID_SGL_INDEX; + } + + __SglMutex.Acquire(); + __SglInfoTable[sglIndex] = newSglInfo; + __SglMutex.Release(); + + return sglIndex; + } + + bool + DestroySglIndex(_SglIndex sglIndex) + { + if (sglIndex < 1 || sglIndex >= MAX_SGL_INDEX) + { + SysLog(NID_GRP, "sglIndex:%#x is out of range.", (unsigned int)sglIndex); + return false; + } + + __SglMutex.Acquire(); + + if (sglIndex <= INVALID_SGL_INDEX || __SglInfoTable[sglIndex] == null) + { + __SglMutex.Release(); + + SysLog(NID_GRP, "DestroySglIndex failed!! sglIndex:%#x", (unsigned int)sglIndex); + return false; + } + + delete __SglInfoTable[sglIndex]; + __SglInfoTable[sglIndex] = null; + + __SglMutex.Release(); + + return true; + } + + _SglIndex + GetSglIndexForSurface(EGLSurface surface) + { + __SglMutex.Acquire(); + + int sglIndex = 0; + for (int i = 0; i < MAX_SGL_INDEX; i++) + { + if (__SglInfoTable[i] != null && __SglInfoTable[i]->surface == surface) + { + sglIndex = i; + break; + } + } + + __SglMutex.Release(); + + return sglIndex; + } + + static _SglInfoTableManipulator* GetInstance(void) + { + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (!__pTheInstance) + { + pthread_once(&once_block, __InitSglInfoTableManipulator); + } + + return __pTheInstance; + } + +private: + static void __InitSglInfoTableManipulator(void) + { + static _SglInfoTableManipulator instance; + __pTheInstance = &instance; + } + +private: + Runtime::Mutex __SglMutex; + _SglInfo* __SglInfoTable[MAX_SGL_INDEX]; + _SglIndex __SglIndexLastUsed; + bool __SglInitialized; + + static _SglInfoTableManipulator* __pTheInstance; +}; +_SglInfoTableManipulator* _SglInfoTableManipulator::__pTheInstance = null; + +void +_PixmapSurfaceDestroyCallback(void* pCallbackParam) +{ + delete (_PixmapInfo*)pCallbackParam; +} + +#if defined(FGRAPHICS_INTERNAL_USE_DRM) +void +_PixmapLockCallBack(void* pCallbackParam) +{ + drm_slp_bo_map((drm_slp_bo)pCallbackParam, DRM_SLP_DEVICE_CPU, DRM_SLP_OPTION_READ | DRM_SLP_OPTION_WRITE); +} + +void +_PixmapUnlockCallBack(void* pCallbackParam) +{ + drm_slp_bo_unmap((drm_slp_bo)pCallbackParam, DRM_SLP_DEVICE_CPU); +} +#endif + +bool +_IsEvasGlEnabled(void) +{ + const char* pString = elm_config_preferred_engine_get(); + String engineName(pString); + + if (engineName.Contains(String("opengl_x11"))) + { + SysLog(NID_GRP, "gl backend : %s", pString); + return true; + } + else if (engineName.Contains(String("software_x11"))) + { + SysLog(NID_GRP, "sw backend : %s", pString); + return false; + } + else + { + pString = elm_config_engine_get(); + String engineName(pString); + if (engineName.Contains(String("opengl_x11"))) + { + SysLog(NID_GRP, "system gl backend : %s", pString); + return true; + } + } + + SysLog(NID_GRP, "system sw backend : %s", pString); + return false; +} + +void +_EvasObjectImageChange(_SglInfo* pSglInfo) +{ + if (isEvasNativeSetEnabled) + { + Evas* pEvas = evas_object_evas_get(pSglInfo->pObject); + if (pEvas == null) + { + return; + } + + Evas_Engine_Info_GL_X11* pEvasInfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(pEvas); + if (pEvasInfo == null) + { + return; + } + Evas_Native_Surface nativeSurface = {0, }; + nativeSurface.type = EVAS_NATIVE_SURFACE_X11; + nativeSurface.version = EVAS_NATIVE_SURFACE_VERSION; + nativeSurface.data.x11.pixmap = (unsigned long)pSglInfo->nativePixmap; + nativeSurface.data.x11.visual = pEvasInfo->info.visual; + evas_object_image_native_surface_set(pSglInfo->pObject, &nativeSurface); + +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) + _PostRenderCallback(NULL); +#endif + } + else + { + Tizen::Graphics::BufferInfo bufferInfo; + pSglInfo->pBitmap->Lock(bufferInfo); + evas_object_image_data_set(pSglInfo->pObject, bufferInfo.pPixels); + pSglInfo->pBitmap->Unlock(); + } +} + +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) +int __registerCallbackCount = 0; +EGLDisplay __previousDisplay = EGL_NO_DISPLAY; +EGLSurface __previousDrawSurface = EGL_NO_SURFACE; +EGLSurface __previousReadSurface = EGL_NO_SURFACE; +EGLContext __previousContext = EGL_NO_CONTEXT; + +void +_PostRenderCallback(Ecore_Evas* ee) +{ + EGLBoolean ret = eglMakeCurrent(__previousDisplay, __previousDrawSurface, __previousReadSurface, __previousContext); + SysTryLog(NID_GRP, ret == EGL_TRUE, "fail to restore previous surface and context. %#x %#x %#x %#x egl error:%#x" + , (unsigned int)__previousDisplay + , (unsigned int)__previousDrawSurface + , (unsigned int)__previousReadSurface + , (unsigned int)__previousContext + , (unsigned int)eglGetError()); +} + +void +_SaveCurrentContext(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) +{ + __previousDisplay = dpy; + __previousDrawSurface = draw; + __previousReadSurface = read; + __previousContext = ctx; +} + +void +_RegisterRenderCallback(Evas_Object* pObject) +{ + if (__registerCallbackCount == 0) + { + Evas* pEvas = evas_object_evas_get(pObject); + if (pEvas == null) + { + return; + } + + Ecore_Evas* pEcoreEvas = ecore_evas_ecore_evas_get(pEvas); + if (pEcoreEvas == null) + { + return; + } + + ecore_evas_callback_post_render_set(pEcoreEvas, _PostRenderCallback); + } + __registerCallbackCount++; +} + +void +_UnregisterRenderCallback(Evas_Object* pObject) +{ + __registerCallbackCount--; + + if (__registerCallbackCount == 0) + { + Evas* pEvas = evas_object_evas_get(pObject); + if (pEvas == null) + { + return; + } + + Ecore_Evas* pEcoreEvas = ecore_evas_ecore_evas_get(pEvas); + if (pEcoreEvas == null) + { + return; + } + + ecore_evas_callback_post_render_set(pEcoreEvas, NULL); + } +} +#endif //#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) + +} + +#ifdef __cplusplus +extern "C" +{ +#endif + +EGLint +_SglGetError() +{ + return eglGetError(); +} + +EGLDisplay +_SglGetDisplay(EGLNativeDisplayType displayId) +{ + if (displayId == (EGLNativeDisplayType) EGL_DEFAULT_DISPLAY) + { + return eglGetDisplay((EGLNativeDisplayType) ecore_x_display_get()); + } + + return eglGetDisplay((EGLNativeDisplayType) displayId); +} + +EGLBoolean +_SglInitialize(EGLDisplay dpy, EGLint* pMajor, EGLint* pMinor) +{ + return eglInitialize(dpy, pMajor, pMinor); +} + +EGLBoolean +_SglTerminate(EGLDisplay dpy) +{ + _GlesInterfaceTerminate_1(); + _GlesInterfaceTerminate_2(); + + _SglInfoTableManipulator::GetInstance()->DestroySglInfoTable(); + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + if (_fboContext != EGL_NO_CONTEXT) + { + eglDestroyContext(dpy, _fboContext); + _fboContext = EGL_NO_CONTEXT; + } +#endif + + if (!_IsEvasGlEnabled()) + { + eglTerminate(dpy); + } + + return EGL_TRUE; +} + +const char* +_SglQueryString(EGLDisplay dpy, EGLint name) +{ + return eglQueryString(dpy, name); +} + +EGLBoolean +_SglGetConfigs(EGLDisplay dpy, EGLConfig* pConfigs, EGLint configSize, EGLint* pNumConfig) +{ + return eglGetConfigs(dpy, pConfigs, configSize, pNumConfig); +} + +EGLBoolean +_SglChooseConfig(EGLDisplay dpy, const EGLint* pAttribList, EGLConfig* pConfigs, EGLint configSize, EGLint* pNumConfig) +{ + return eglChooseConfig(dpy, pAttribList, pConfigs, configSize, pNumConfig); +} + +EGLBoolean +_SglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* pValue) +{ + return eglGetConfigAttrib(dpy, config, attribute, pValue); +} + +EGLSurface +_SglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* pAttribList) +{ + _SglIndex sglIndex = INVALID_SGL_INDEX; + Tizen::Graphics::Bitmap* pBitmap = null; + VisualElementSurface* pVisualElementSurface = null; + Object* pObj = (Object*)win; + VisualElement* pVE = dynamic_cast(pObj); + Tizen::Ui::Control* pControl = dynamic_cast(pObj); +#if !defined(_OSP_EMUL_) + Tizen::Ui::Controls::Frame* pFrame = dynamic_cast(pControl); +#endif + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + if (pControl == null && pVE == null) + { + goto CATCH_01; + } + +#if !defined(_OSP_EMUL_) + if (pFrame != null && !_IsEvasGlEnabled()) + { + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*pControl); + _WindowImpl* pWindowImpl = dynamic_cast<_WindowImpl*> (pControlImpl); + if (pWindowImpl == null) + { + goto CATCH_01; + } + + EGLNativeWindowType nativeWindow = (EGLNativeWindowType)pWindowImpl->GetNativeHandle(); + + sglIndex = pSglInfoTableManipulatorInstance->CreateSglIndex(); + if (sglIndex <= INVALID_SGL_INDEX) + { + goto CATCH_01; + } + + EGLSurface windowSurface = eglCreateWindowSurface(dpy, config, nativeWindow, pAttribList); + if (windowSurface == EGL_NO_SURFACE) + { + pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex); + sglIndex = 0; + } + else + { + _VisualElementImpl* visualElementImpl = _VisualElementImpl::GetInstance(*pControlImpl->GetCore().GetVisualElement()); + if (visualElementImpl == null) + { + pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex); + sglIndex = 0; + goto CATCH_01; + } + + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + pSglInfo->pFrame = pFrame; + eglGetConfigAttrib(dpy, config, EGL_BUFFER_SIZE, &pSglInfo->colorSize); + eglGetConfigAttrib(dpy, config, EGL_DEPTH_SIZE, &pSglInfo->depthSize); + eglGetConfigAttrib(dpy, config, EGL_STENCIL_SIZE, &pSglInfo->stencilSize); + + pSglInfo->display = dpy; + pSglInfo->pVisualElementImpl = visualElementImpl; + pSglInfo->pVisualElementImpl->SetBoundsChangedCallback(_OnBoundsChangedFbo, pSglInfo); +#endif + pSglInfo->surface = windowSurface; + + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + } + + return (EGLSurface)sglIndex; + } + else +#endif //#if !defined(_OSP_EMUL_) + { + _VisualElementImpl* pVisualElementImpl = null; + _VisualElementSurfaceImpl* pVisualElementSurfaceImpl = null; + int width = 0; + int height = 0; + result r = E_SUCCESS; + Tizen::Graphics::FloatRectangle rect; + _SglInfo* pSglInfo = null; + + if (pVE == null) + { + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*pControl); + if (pControlImpl == null) + { + goto CATCH_01; + } + pVE = pControlImpl->GetCore().GetVisualElement(); + } + + pVisualElementImpl = _VisualElementImpl::GetInstance(*pVE); + if (pVisualElementImpl == null) + { + goto CATCH_01; + } + + rect = pVisualElementImpl->GetBounds(); + width = int(rect.width); + height = int(rect.height); + if (width <= 0 || height <= 0) + { + goto CATCH_01; + } + +#if defined (FGRAPHICS_INTERNAL_USE_EVAS_NATIVE_SURFACE) + isEvasNativeSetEnabled = _IsEvasGlEnabled(); +#else + isEvasNativeSetEnabled = false; +#endif + + if (isEvasNativeSetEnabled) + { + Control* pFrame = pControl; + Control* pTemp = pFrame->GetParent(); + while(pTemp != null) + { + pFrame = pTemp; + pTemp = pTemp->GetParent(); + } + + Dimension size(width, height); + Tizen::Ui::Window* pWindow = dynamic_cast (pFrame); + if (pWindow == null) + { + goto CATCH_01; + } + + pVisualElementSurface = new (std::nothrow) VisualElementSurface(); + if (pVisualElementSurface == null) + { + goto CATCH_01; + } + + r = pVisualElementSurface->Construct(*pWindow->GetDisplayContext(), size); + pVE->SetSurface(pVisualElementSurface); + } + else + { + pVisualElementSurface = pVisualElementImpl->GetSurfaceN(); + if (pVisualElementSurface == null) + { + goto CATCH_01; + } + } + + pBitmap = new (std::nothrow) Tizen::Graphics::Bitmap; + if (pBitmap == null) + { + goto CATCH_02; + } + + r = pBitmap->Construct(Tizen::Graphics::Rectangle(0, 0, width, height)); + if (r != E_SUCCESS) + { + goto CATCH_03; + } + + sglIndex = (_SglIndex)_SglCreatePixmapSurface(dpy, config, (EGLNativePixmapType)pBitmap, null); + if (sglIndex <= INVALID_SGL_INDEX) + { + goto CATCH_03; + } + + pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + pSglInfo->sglIndex = sglIndex; + pSglInfo->display = dpy; + pSglInfo->config = config; + pSglInfo->pBitmap = pBitmap; + pSglInfo->pVisualElementImpl = pVisualElementImpl; + pSglInfo->pControl = pControl; + + pVisualElementImpl->SetBoundsChangedCallback(_OnBoundsChanged, pSglInfo); + + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + + pVisualElementSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pVisualElementSurface); + if (pVisualElementSurfaceImpl == null) + { + goto CATCH_03; + } + + pSglInfo->pObject = (Evas_Object*)pVisualElementSurfaceImpl->GetNativeHandle(); + if (pSglInfo->pObject == null) + { + goto CATCH_03; + } + + _EvasObjectImageChange(pSglInfo); + +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) + if (isEvasNativeSetEnabled) + { + _RegisterRenderCallback(pSglInfo->pObject); + } +#endif + + return (EGLSurface)sglIndex; + } + +CATCH_03: + delete pBitmap; + + pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex); + //fall through + +CATCH_02: + delete pVisualElementSurface; + //fall through + +CATCH_01: + SysLog(NID_GRP, "_SglCreateWindowSurface failed!! dpy:%#x config:%#x pControl:%#x pAttribList:%#x", + (unsigned int)dpy, (unsigned int)config, (unsigned int)pControl, (unsigned int)pAttribList); + return eglCreateWindowSurface(dpy, config, (EGLNativeWindowType) 0, pAttribList); +} + +EGLSurface +_SglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* pAttribList) +{ + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + _SglIndex sglIndex = INVALID_SGL_INDEX; + + sglIndex = pSglInfoTableManipulatorInstance->CreateSglIndex(); + if (sglIndex <= INVALID_SGL_INDEX) + { + SysLog(NID_GRP, "_SglCreatePbufferSurface failed!! dpy:%#x config:%#x pAttribList:%#x", + (unsigned int)dpy, (unsigned int)config, (unsigned int)pAttribList); + + return eglCreatePbufferSurface(EGL_NO_DISPLAY, config, pAttribList); + } + + EGLSurface pbufferSurface = eglCreatePbufferSurface(dpy, config, pAttribList); + if (pbufferSurface == EGL_NO_SURFACE) + { + pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex); + sglIndex = 0; + } + else + { + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + pSglInfo->surface = pbufferSurface; + + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + } + + return (EGLSurface)sglIndex; +} + +_OSP_LOCAL_ EGLNativePixmapType +_CreateNativePixmap(_SglIndex sglIndex, Tizen::Graphics::Bitmap* pBitmap) +{ + int width = 0; + int height = 0; + int bitsPerPixel = 0; + Display* pNativeDisplay = null; + Drawable nativeWindow = 0; + result r = E_FAILURE; + Tizen::Graphics::BufferInfo bufferInfo; + _PixmapInfo* pPixmapInfo = null; +#if defined(FGRAPHICS_INTERNAL_USE_DRM) + unsigned int attachments[] = { DRI2BufferFrontLeft }; + char* pDeviceName = null; + char* pDriverName = null; + DRI2Buffer* pDri2Buffer = null; + int dri2Width = 0; + int dri2Height = 0; + int dri2BufferCount = 0; + int drmFile = 0; + void* pData = null; + Bool ret = False; + drm_magic_t magic = 0; +#endif + _SglInfo* pSglInfo = null; + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + if (pBitmap == null || sglIndex <= INVALID_SGL_INDEX || pSglInfo == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + goto CATCH_01; + } + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + + r = pBitmap->Lock(bufferInfo); + if (r != E_SUCCESS) + { + goto CATCH_01; + } + + width = bufferInfo.width; + height = bufferInfo.height; + bitsPerPixel = bufferInfo.bitsPerPixel; + + r = pBitmap->Unlock(); + if (r != E_SUCCESS || width <= 0 || height <= 0 || bitsPerPixel <= 0) + { + goto CATCH_01; + } + + pNativeDisplay = (Display*) ecore_x_display_get(); + nativeWindow = DefaultRootWindow(pNativeDisplay); + + pPixmapInfo = new (std::nothrow) _PixmapInfo; + if (pPixmapInfo == null) + { + goto CATCH_01; + } + + pPixmapInfo->nativePixmap = XCreatePixmap(pNativeDisplay, nativeWindow, width, height, + ecore_x_default_depth_get(pNativeDisplay, ecore_x_default_screen_get())); + if (pPixmapInfo->nativePixmap == (Pixmap)0) + { + goto CATCH_02; + } + +#if defined(FGRAPHICS_INTERNAL_USE_DRM) + DRI2CreateDrawable(pNativeDisplay, pPixmapInfo->nativePixmap); + XSync(pNativeDisplay, False); + + ret = DRI2Connect(pNativeDisplay, nativeWindow, &pDriverName, &pDeviceName); + free(pDriverName); + if (!ret || pDeviceName == null) + { + goto CATCH_03; + } + + drmFile = open(pDeviceName, O_RDWR); + free(pDeviceName); + if (drmFile < 0) + { + goto CATCH_03; + } + + drmGetMagic(drmFile, &magic); + ret = DRI2Authenticate(pNativeDisplay, nativeWindow, (unsigned int)magic); + if (!ret) + { + goto CATCH_04; + } + + pPixmapInfo->pDrmBufMgr = drm_slp_bufmgr_init(drmFile, null); + if (pPixmapInfo->pDrmBufMgr == null) + { + goto CATCH_04; + } + + pDri2Buffer = DRI2GetBuffers(pNativeDisplay, pPixmapInfo->nativePixmap, &dri2Width, &dri2Height, attachments, 1, &dri2BufferCount); + if (pDri2Buffer == null) + { + goto CATCH_05; + } + + pPixmapInfo->pDrmBufferObject = drm_slp_bo_import(pPixmapInfo->pDrmBufMgr, pDri2Buffer->name); + free(pDri2Buffer); + if (pPixmapInfo->pDrmBufferObject == null) + { + goto CATCH_05; + } + + pData = (void*)drm_slp_bo_get_handle(pPixmapInfo->pDrmBufferObject, DRM_SLP_DEVICE_CPU); + if (pData == null) + { + goto CATCH_06; + } + + r = Tizen::Graphics::_BitmapTool::ChangeBuffer(*pBitmap, pData, width * bitsPerPixel / 8, + _PixmapSurfaceDestroyCallback, (void*)pPixmapInfo); + if (r != E_SUCCESS) + { + goto CATCH_06; + } + + if (!Tizen::Graphics::_BitmapTool::SetCallback(*pBitmap, _PixmapSurfaceDestroyCallback, pPixmapInfo, + _PixmapLockCallBack, pPixmapInfo->pDrmBufferObject,_PixmapUnlockCallBack, pPixmapInfo->pDrmBufferObject)) + { + goto CATCH_06; + } + +#else +#if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER) + { + pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + pSglInfo->pEcoreImage = ecore_x_image_new(width + , height + , ecore_x_default_visual_get(pNativeDisplay, ecore_x_default_screen_get()) + , ecore_x_default_depth_get(pNativeDisplay, ecore_x_default_screen_get())); + + if (pSglInfo->pEcoreImage == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + goto CATCH_06; + } + + ecore_x_image_get(pSglInfo->pEcoreImage + , pPixmapInfo->nativePixmap, 0, 0, 0, 0 + , width + , height); + + int bpl = 0; + int rows = 0; + int bpp = 0; + + void* pSource = ecore_x_image_data_get(pSglInfo->pEcoreImage, &bpl, &rows, &bpp); + + r = Tizen::Graphics::_BitmapTool::ChangeBuffer(*pBitmap, pSource, width * bitsPerPixel / 8, + _PixmapSurfaceDestroyCallback, (void*)pPixmapInfo); + if (r != E_SUCCESS) + { + ecore_x_image_free(pSglInfo->pEcoreImage); + pSglInfo->pEcoreImage = null; + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + + SysLog(NID_GRP, "change buffer failed! pSource %#x %d %d %d", (unsigned int)pSource, bpl, rows, bpp); + goto CATCH_06; + } + + pSglInfo->width = width; + pSglInfo->height = height; + + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + } +#endif //#if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER) +#endif //#if defined(FGRAPHICS_INTERNAL_USE_DRM) + + return (EGLNativePixmapType)pPixmapInfo->nativePixmap; + +CATCH_06: +#if defined(FGRAPHICS_INTERNAL_USE_DRM) + drm_slp_bo_unmap(pPixmapInfo->pDrmBufferObject, DRM_SLP_DEVICE_CPU); + drm_slp_bo_unref(pPixmapInfo->pDrmBufferObject); + //fall through + +CATCH_05: + drm_slp_bufmgr_destroy(pPixmapInfo->pDrmBufMgr); + //fall through + +CATCH_04: + close(drmFile); + //fall through + +CATCH_03: + DRI2DestroyDrawable(pNativeDisplay, pPixmapInfo->nativePixmap); +#endif + XFreePixmap(pNativeDisplay, pPixmapInfo->nativePixmap); + //fall through + +CATCH_02: + delete pPixmapInfo; + //fall through + +CATCH_01: + SysLog(NID_GRP, "_CreateNativePixmap failed!! pBitmap:%#x", (unsigned int)pBitmap); + return (EGLNativePixmapType)0; +} + +_OSP_LOCAL_ EGLNativePixmapType +_CreateNativePixmapEx(Tizen::Graphics::Bitmap* pBitmap, Tizen::Graphics::BufferInfo bufferInfo) +{ +#if defined(FGRAPHICS_INTERNAL_USE_DRM) + int width = 0; + int height = 0; + int bitsPerPixel = 0; + Display* pNativeDisplay = null; + Drawable nativeWindow = 0; + unsigned int attachments[] = { DRI2BufferFrontLeft }; + char* pDeviceName = null; + char* pDriverName = null; + DRI2Buffer* pDri2Buffer = null; + int dri2Width = 0; + int dri2Height = 0; + int dri2BufferCount = 0; + int drmFile = 0; + Bool ret = False; + result r = E_FAILURE; + Tizen::Graphics::_BitmapImpl* pBitmapImpl = null; + drm_magic_t magic = 0; + _PixmapInfo* pPixmapInfo = null; + + if (pBitmap == null) + { + goto CATCH_01; + } + + pBitmapImpl = Tizen::Graphics::_BitmapImpl::GetInstance(*pBitmap); + if (pBitmapImpl == null) + { + goto CATCH_01; + } + + width = bufferInfo.width; + height = bufferInfo.height; + bitsPerPixel = bufferInfo.bitsPerPixel; + + if (width <= 0 || height <= 0 || bitsPerPixel <= 0) + { + goto CATCH_01; + } + + pNativeDisplay = (Display*) ecore_x_display_get(); + nativeWindow = DefaultRootWindow(pNativeDisplay); + + pPixmapInfo = new (std::nothrow) _PixmapInfo; + if (pPixmapInfo == null) + { + goto CATCH_01; + } + + pPixmapInfo->nativePixmap = XCreatePixmap(pNativeDisplay, nativeWindow, width, height, bitsPerPixel); + if (pPixmapInfo->nativePixmap == (Pixmap)0) + { + goto CATCH_02; + } + DRI2CreateDrawable(pNativeDisplay, pPixmapInfo->nativePixmap); + XSync(pNativeDisplay, False); + + ret = DRI2Connect(pNativeDisplay, nativeWindow, &pDriverName, &pDeviceName); + free(pDriverName); + if (!ret || pDeviceName == null) + { + goto CATCH_03; + } + + drmFile = open(pDeviceName, O_RDWR); + free(pDeviceName); + if (drmFile < 0) + { + goto CATCH_03; + } + + drmGetMagic(drmFile, &magic); + ret = DRI2Authenticate(pNativeDisplay, nativeWindow, (unsigned int)magic); + if (!ret) + { + goto CATCH_04; + } + + pPixmapInfo->pDrmBufMgr = drm_slp_bufmgr_init(drmFile, null); + if (pPixmapInfo->pDrmBufMgr == null) + { + goto CATCH_04; + } + + pDri2Buffer = DRI2GetBuffers(pNativeDisplay, pPixmapInfo->nativePixmap, &dri2Width, &dri2Height, attachments, 1, &dri2BufferCount); + if (pDri2Buffer == null) + { + goto CATCH_05; + } + + pPixmapInfo->pDrmBufferObject = drm_slp_bo_import(pPixmapInfo->pDrmBufMgr, pDri2Buffer->name); + free(pDri2Buffer); + if (pPixmapInfo->pDrmBufferObject == null) + { + goto CATCH_05; + } + + bufferInfo.pPixels = (void*)drm_slp_bo_get_handle(pPixmapInfo->pDrmBufferObject, DRM_SLP_DEVICE_CPU); + if (bufferInfo.pPixels == null) + { + goto CATCH_06; + } + + bufferInfo.bitsPerPixel = 32; + bufferInfo.pixelFormat = PIXEL_FORMAT_ARGB8888; + bufferInfo.pitch = bufferInfo.width*bufferInfo.bitsPerPixel/4; + memset(bufferInfo.pPixels, 0, bufferInfo.width * bufferInfo.height * 4); + r = pBitmapImpl->Construct(bufferInfo); + if (r != E_SUCCESS) + { + goto CATCH_06; + } + + if (!Tizen::Graphics::_BitmapTool::SetCallback(*pBitmap, _PixmapSurfaceDestroyCallback, pPixmapInfo, + _PixmapLockCallBack, pPixmapInfo->pDrmBufferObject,_PixmapUnlockCallBack, pPixmapInfo->pDrmBufferObject)) + { + goto CATCH_06; + } + + return (EGLNativePixmapType)pPixmapInfo->nativePixmap; + +CATCH_06: + drm_slp_bo_unmap(pPixmapInfo->pDrmBufferObject, DRM_SLP_DEVICE_CPU); + drm_slp_bo_unref(pPixmapInfo->pDrmBufferObject); + //fall through + +CATCH_05: + drm_slp_bufmgr_destroy(pPixmapInfo->pDrmBufMgr); + //fall through + +CATCH_04: + close(drmFile); + //fall through + +CATCH_03: + DRI2DestroyDrawable(pNativeDisplay, pPixmapInfo->nativePixmap); + XFreePixmap(pNativeDisplay, pPixmapInfo->nativePixmap); + //fall through + +CATCH_02: + delete pPixmapInfo; + //fall through + +CATCH_01: + SysLog(NID_GRP, "_CreateNativePixmap failed!! pBitmap:%#x", (unsigned int)pBitmap); + return (EGLNativePixmapType)0; +#else + return (EGLNativePixmapType)0; +#endif //#if !defined(FGRAPHICS_INTERNAL_USE_DRM) +} + +EGLSurface +_SglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* pAttribList) +{ + _SglIndex sglIndex = INVALID_SGL_INDEX; + Tizen::Graphics::Bitmap* pBitmap = dynamic_cast((Tizen::Graphics::Bitmap*)pixmap); + EGLNativePixmapType eglNativePixmap = 0; + EGLSurface pixmapSurface = EGL_NO_SURFACE; + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + if (pBitmap == null) + { + goto CATCH_01; + } + + sglIndex = pSglInfoTableManipulatorInstance->CreateSglIndex(); + if (sglIndex <= INVALID_SGL_INDEX) + { + goto CATCH_01; + } + + eglNativePixmap = _CreateNativePixmap(sglIndex, pBitmap); + if (eglNativePixmap == 0) + { + goto CATCH_02; + } + + pixmapSurface = eglCreatePixmapSurface(dpy, config, eglNativePixmap, pAttribList); + if (pixmapSurface == EGL_NO_SURFACE) + { + pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex); + sglIndex = 0; + } + else + { + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + pSglInfo->nativePixmap = eglNativePixmap; + pSglInfo->surface = pixmapSurface; + + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + } + + return (EGLSurface)sglIndex; + +CATCH_02: + pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex); + //fall through + +CATCH_01: + SysLog(NID_GRP, "_SglCreatePixmapSurface failed!! dpy:%#x config:%#x pixmap:%#x pAttribList:%#x", + (unsigned int)dpy, (unsigned int)config, (unsigned int)pixmap, (unsigned int)pAttribList); + return eglCreatePixmapSurface(EGL_NO_DISPLAY, config, (EGLNativePixmapType) 0, pAttribList); +} + +EGLBoolean +_SglDestroySurface(EGLDisplay dpy, EGLSurface surface) +{ + EGLBoolean ret = EGL_FALSE; + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + _SglIndex sglIndex = (_SglIndex)surface; + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + SysLog(NID_GRP, "_SglDestroySurface failed!! dpy:%#x sglIndex:%#x", (unsigned int)dpy, (unsigned int)surface); + return eglDestroySurface(dpy, EGL_NO_SURFACE); + } + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + if (pSglInfo->isFboAvailable && pSglInfo->pFrame != null) + { + if (pSglInfo->glVersion == 1) + { + _GlesFboTerminate_1(pSglInfo->frameBufferObject + , pSglInfo->depthRenderBuffer + , pSglInfo->stencilRenderBuffer + , pSglInfo->textureId); + } + else if (pSglInfo->glVersion == 2) + { + _GlesFboTerminate_2(pSglInfo->frameBufferObject + , pSglInfo->depthRenderBuffer + , pSglInfo->stencilRenderBuffer + , pSglInfo->textureId + , pSglInfo->program); + } + else + { + SysLog(NID_GRP, "ambiguous gl Version %d", pSglInfo->glVersion); + } + } +#endif + ret = eglDestroySurface(dpy, pSglInfo->surface); + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + + pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex); + + return ret; +} + +EGLBoolean +_SglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* pValue) +{ + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + _SglIndex sglIndex = (_SglIndex)surface; + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + SysLog(NID_GRP, "_SglQuerySurface failed!! dpy:%#x sglIndex:%#x attribute:%#x pValue:%#x", + (unsigned int)dpy, (unsigned int)sglIndex, (unsigned int)attribute, (unsigned int)pValue); + return eglQuerySurface(dpy, EGL_NO_SURFACE, attribute, pValue); + } + + EGLBoolean ret = eglQuerySurface(dpy, pSglInfo->surface, attribute, pValue); + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + + return ret; +} + +EGLBoolean +_SglBindAPI(EGLenum api) +{ + return eglBindAPI(api); +} + +EGLenum +_SglQueryAPI() +{ + return eglQueryAPI(); +} + +EGLBoolean +_SglWaitClient() +{ + return eglWaitClient(); +} + +EGLBoolean +_SglReleaseThread(void) +{ + return eglReleaseThread(); +} + +EGLSurface +_SglCreatePbufferFromClientBuffer( + EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint* pAttribList) +{ + _SglIndex sglIndex = INVALID_SGL_INDEX; + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + sglIndex = pSglInfoTableManipulatorInstance->CreateSglIndex(); + if (sglIndex <= INVALID_SGL_INDEX) + { + SysLog(NID_GRP, "_SglCreatePbufferFromClientBuffer failed!!" + " dpy:%#x buftype:%#x buffer:%#x config:%#x pAttribList:%#x", + (unsigned int)dpy, (unsigned int)buftype, (unsigned int)buffer, (unsigned int)config, (unsigned int)pAttribList); + + return eglCreatePbufferFromClientBuffer(null, (EGLenum)0, null, null, null); + } + + EGLSurface pbufferFromClientBuffer = eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, pAttribList); + if (pbufferFromClientBuffer == EGL_NO_SURFACE) + { + pSglInfoTableManipulatorInstance->DestroySglIndex(sglIndex); + sglIndex = 0; + } + else + { + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + pSglInfo->surface = pbufferFromClientBuffer; + + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + } + + return (EGLSurface)sglIndex; +} + +EGLBoolean +_SglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) +{ + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + _SglIndex sglIndex = (_SglIndex)surface; + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + SysLog(NID_GRP, "_SglCreatePbufferFromClientBuffer failed!! " + "dpy:%#x surface:%#x attribute:%#x value:%#x", + (unsigned int)dpy, (unsigned int)surface, (unsigned int)attribute, (unsigned int)value); + + return eglSurfaceAttrib(dpy, EGL_NO_SURFACE, attribute, value); + } + + EGLBoolean ret = eglSurfaceAttrib(dpy, pSglInfo->surface, attribute, value); + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + + return ret; +} + +EGLBoolean +_SglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) +{ + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + _SglIndex sglIndex = (_SglIndex)surface; + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + SysLog(NID_GRP, "_SglBindTexImage failed!! dpy:%#x surface:%#x buffer:%#x", + (unsigned int)dpy, (unsigned int)surface, (unsigned int)buffer); + + return eglBindTexImage(dpy, EGL_NO_SURFACE, buffer); + } + + EGLBoolean ret = eglBindTexImage(dpy, pSglInfo->surface, buffer); + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + + return ret; +} + +EGLBoolean +_SglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) +{ + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + _SglIndex sglIndex = (_SglIndex)surface; + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + SysLog(NID_GRP, "_SglReleaseTexImage failed!! dpy:%#x surface:%#x buffer:%#x", + (unsigned int)dpy, (unsigned int)surface, (unsigned int)buffer); + + return eglReleaseTexImage(dpy, EGL_NO_SURFACE, buffer); + } + + EGLBoolean ret = eglReleaseTexImage(dpy, pSglInfo->surface, buffer); + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + + return ret; +} + +EGLBoolean +_SglSwapInterval(EGLDisplay dpy, EGLint interval) +{ + return eglSwapInterval(dpy, interval); +} + +EGLContext +_SglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareContext, const EGLint* pAttribList) +{ +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + EGLContext ret = EGL_NO_CONTEXT; + if (shareContext == EGL_NO_CONTEXT) + { + if (_fboContext == EGL_NO_CONTEXT) + { + _fboContext = eglCreateContext(dpy, config, EGL_NO_CONTEXT, pAttribList); + if (_fboContext == EGL_NO_CONTEXT) + { + return EGL_NO_CONTEXT; + } + } + + ret = eglCreateContext(dpy, config, _fboContext, pAttribList); + } + else + { + ret = eglCreateContext(dpy, config, shareContext, pAttribList); + } + return ret; +#else + return eglCreateContext(dpy, config, shareContext, pAttribList); +#endif +} + +EGLBoolean +_SglDestroyContext(EGLDisplay dpy, EGLContext ctx) +{ + return eglDestroyContext(dpy, ctx); +} + +EGLBoolean +_SglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) +{ + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + _SglIndex sglIndexDraw = (_SglIndex)draw; + _SglIndex sglIndexRead = (_SglIndex)read; + + EGLSurface sglInfoReadSurface; + { + _SglInfo* sglInfoRead = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndexRead); + + if (sglInfoRead == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + SysLog(NID_GRP, "_SglMakeCurrent failed!! dpy:%#x draw:%#x read:%#x ctx:%#x", + (unsigned int)dpy, (unsigned int)draw, (unsigned int)read, (unsigned int)ctx); + return eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx); + } + sglInfoReadSurface = sglInfoRead->surface; + + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + } + + _SglInfo* sglInfoDraw = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndexDraw); + if (sglInfoDraw == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + SysLog(NID_GRP, "_SglMakeCurrent failed!! dpy:%#x draw:%#x read:%#x ctx:%#x", + (unsigned int)dpy, (unsigned int)draw, (unsigned int)read, (unsigned int)ctx); + return eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx); + } + + sglInfoDraw->context = ctx; + + EGLBoolean ret = eglMakeCurrent(dpy, sglInfoDraw->surface, sglInfoReadSurface, ctx); + +#if defined(FGRAPHICS_INTERNAL_USE_RESTORE_CONTEXT) + _SaveCurrentContext(dpy, sglInfoDraw->surface, sglInfoReadSurface, ctx); +#endif + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + if (ret != EGL_TRUE || sglInfoDraw->surface == EGL_NO_SURFACE + || sglInfoReadSurface == EGL_NO_SURFACE + || ctx == EGL_NO_CONTEXT) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + return ret; + } + + if (sglInfoDraw->glVersion == 0) + { + eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &sglInfoDraw->glVersion); +#if defined(_OSP_EMUL_) //fixme + sglInfoDraw->isFboAvailable = false; +#endif + } + + if (sglInfoDraw->pFrame != null) + { + if (sglInfoDraw->isFboAvailable) + { + if (sglInfoDraw->frameBufferObject == 0) + { + int x = 0; + int y = 0; + int width = 0; + int height = 0; + sglInfoDraw->pFrame->GetBounds(x, y, width, height); + + sglInfoDraw->fboWidth = width; + sglInfoDraw->fboHeight = height; + + if (sglInfoDraw->glVersion == 1) + { + sglInfoDraw->isFboAvailable = _GlesFboInitialize_1(sglInfoDraw->fboWidth + , sglInfoDraw->fboHeight + , sglInfoDraw->frameBufferObject, sglInfoDraw->depthRenderBuffer + , sglInfoDraw->stencilRenderBuffer, sglInfoDraw->colorSize + , sglInfoDraw->depthSize, sglInfoDraw->stencilSize + , sglInfoDraw->textureId); + } + else if (sglInfoDraw->glVersion == 2) + { + sglInfoDraw->isFboAvailable = _GlesFboInitialize_2(sglInfoDraw->fboWidth + , sglInfoDraw->fboHeight + , sglInfoDraw->frameBufferObject, sglInfoDraw->depthRenderBuffer + , sglInfoDraw->stencilRenderBuffer, sglInfoDraw->colorSize + , sglInfoDraw->depthSize, sglInfoDraw->stencilSize + , sglInfoDraw->textureId, sglInfoDraw->program); + } + else + { + SysLog(NID_GRP, "ambiguous gl Version %d", sglInfoDraw->glVersion); + sglInfoDraw->isFboAvailable = false; + } + } + else + { + if (sglInfoDraw->glVersion == 1) + { + _GlesFboBinding_1(sglInfoDraw->frameBufferObject); + } + else if (sglInfoDraw->glVersion == 2) + { + _GlesFboBinding_2(sglInfoDraw->frameBufferObject); + } + else + { + SysLog(NID_GRP, "ambiguous gl Version %d", sglInfoDraw->glVersion); + } + } + } + } + else + { + if (sglInfoDraw->frameBufferObject != 0 && sglInfoDraw->isFboAvailable) + { + if (sglInfoDraw->glVersion == 1) + { + _GlesFboBinding_1(0); + } + else if (sglInfoDraw->glVersion == 2) + { + _GlesFboBinding_2(0); + } + else + { + SysLog(NID_GRP, "ambiguous gl Version %d", sglInfoDraw->glVersion); + } + } + } +#endif + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + + return ret; +} + +EGLContext +_SglGetCurrentContext() +{ + return eglGetCurrentContext(); +} + +EGLSurface +_SglGetCurrentSurface(EGLint readDraw) +{ + EGLSurface surface = EGL_NO_SURFACE; + _SglIndex sglIndex = INVALID_SGL_INDEX; + + surface = eglGetCurrentSurface(readDraw); + sglIndex = _SglInfoTableManipulator::GetInstance()->GetSglIndexForSurface(surface); + + if (sglIndex < INVALID_SGL_INDEX) + { + SysLog(NID_GRP, "_SglGetCurrentSurface failed!! readDraw:%#x", (unsigned int)readDraw); + return EGL_NO_SURFACE; + } + + return (EGLSurface)sglIndex; +} + +EGLDisplay +_SglGetCurrentDisplay(void) +{ + return eglGetCurrentDisplay(); +} + +EGLBoolean +_SglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* pValue) +{ + return eglQueryContext(dpy, ctx, attribute, pValue); +} + +EGLBoolean +_SglWaitGL(void) +{ + return eglWaitGL(); +} + +EGLBoolean +_SglWaitNative(EGLint engine) +{ + return eglWaitNative(engine); +} + +EGLBoolean _SglUpdateBufferOSP(EGLDisplay dpy, EGLSurface surface); + +EGLBoolean +_SglSwapBuffers(EGLDisplay dpy, EGLSurface surface) +{ + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + _SglIndex sglIndex = (_SglIndex)surface; + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + SysLog(NID_GRP, "_SglSwapBuffers failed!! dpy:%#x sglIndex:%#x", (unsigned int)dpy, (unsigned int)sglIndex); + + return eglSwapBuffers(dpy, EGL_NO_SURFACE); + } + + if (pSglInfo->pBitmap != null) + { +#if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER) + _SglUpdateBufferOSP(dpy, surface); +#else + if (!isEvasNativeSetEnabled) + { + eglWaitGL(); + } +#endif + + if (isEvasNativeSetEnabled) + { + evas_object_image_pixels_dirty_set(pSglInfo->pObject, EINA_TRUE); + } + else + { + if (pSglInfo->pVisualElementImpl != null) + { + pSglInfo->pVisualElementImpl->SetFlushNeeded(); + } + } + + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + return EGL_TRUE; + } + else + { +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + if (pSglInfo->pFrame != null) + { + if (pSglInfo->isFboAvailable) + { + if (pSglInfo->glVersion == 1) + { + _GlesFboSwapBuffers_1(pSglInfo->pFrame + , pSglInfo->fboWidth + , pSglInfo->fboHeight + , pSglInfo->frameBufferObject + , pSglInfo->textureId); + } + else if (pSglInfo->glVersion == 2) + { + _GlesFboSwapBuffers_2(pSglInfo->pFrame + , pSglInfo->frameBufferObject + , pSglInfo->textureId + , pSglInfo->program); + } + else + { + SysLog(NID_GRP, "ambiguous gl Version %d", pSglInfo->glVersion); + pSglInfo->isFboAvailable = false; + } + } + } +#endif + EGLBoolean ret = eglSwapBuffers(dpy, pSglInfo->surface); + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + + return ret; + } +} + +EGLBoolean +_SglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) +{ + Tizen::Graphics::Bitmap* pBitmap = (Tizen::Graphics::Bitmap*)target; + EGLNativePixmapType nativePixmap = _CreateNativePixmap((_SglIndex)surface, pBitmap); + return eglCopyBuffers(dpy, surface, nativePixmap); +} + +typedef void (*__EglMustCastToProperFunctionPointerType)(void); + +__EglMustCastToProperFunctionPointerType +_SglGetProcAddress(const char* pProcName) +{ + return eglGetProcAddress(pProcName); +} + +EGLBoolean +_SglUpdateBufferOSP(EGLDisplay dpy, EGLSurface surface) +{ +#if defined(FGRAPHICS_INTERNAL_USE_EGLCOPYBUFFER) + Tizen::Graphics::BufferInfo bufferInfo; + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + _SglIndex sglIndex = (_SglIndex)surface; + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + SysLog(NID_GRP, "_SglUpdateBufferOSP failed!!"); + return EGL_FALSE; + } + + eglCopyBuffers(dpy, pSglInfo->surface, pSglInfo->nativePixmap); + ecore_x_image_get(pSglInfo->pEcoreImage, pSglInfo->nativePixmap, + 0, 0, 0, 0, pSglInfo->width, pSglInfo->height); + + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); +#endif + return EGL_TRUE; +} + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) +_OSP_LOCAL_ GLuint +_GlesGetCurrentFbo(void) +{ + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + _SglIndex sglIndex = (_SglIndex)_SglGetCurrentSurface(EGL_DRAW); + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + SysLog(NID_GRP, "Fbo binding failed!!"); + return 0; + } + + GLuint ret = pSglInfo->frameBufferObject; + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + + return ret; +} + +_OSP_LOCAL_ bool +_GlesFboEnableStencil(GLuint& frameBufferObject, GLuint& renderBuffer) +{ + _SglInfoTableManipulator* pSglInfoTableManipulatorInstance = _SglInfoTableManipulator::GetInstance(); + + _SglIndex sglIndex = (_SglIndex)_SglGetCurrentSurface(EGL_DRAW); + _SglInfo* pSglInfo = pSglInfoTableManipulatorInstance->LockSglInfoTable(sglIndex); + + if (sglIndex <= INVALID_SGL_INDEX || pSglInfo == null) + { + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + return false; + } + + if (!pSglInfo->isStencilEnabled) + { + pSglInfo->isStencilEnabled = true; + frameBufferObject = pSglInfo->frameBufferObject; + renderBuffer = pSglInfo->stencilRenderBuffer; + + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + return true; + } + + pSglInfoTableManipulatorInstance->UnlockSglInfoTable(); + return false; +} + +#endif + +#ifdef __cplusplus +} +#endif + +} // Opengl + +}} // Tizen::Graphics diff --git a/src/graphics/opengl/FGrpGlPlayer.cpp b/src/graphics/opengl/FGrpGlPlayer.cpp new file mode 100644 index 0000000..c71d441 --- /dev/null +++ b/src/graphics/opengl/FGrpGlPlayer.cpp @@ -0,0 +1,180 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpGlPlayer.cpp + * @brief This is the implementation file for GlPlayer class. + * + */ + +#include + +#include + +#include +#include +#include + +#include "FGrp_GlPlayerImpl.h" + +#define CHECK_CONSTRUCTED \ + SysAssertf((this->__pImpl != null) && this->__pImpl->IsValid(), "Not yet constructed. Construct() should be called before use."); + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +GlPlayer::GlPlayer(void) + : __pImpl(new (std::nothrow)_GlPlayerImpl) +{ +} + +GlPlayer::~GlPlayer(void) +{ + delete this->__pImpl; +} + +result +GlPlayer::Construct(EglContextClientVersion version, Tizen::Ui::Control* pControl) +{ + ClearLastResult(); + SysTryReturnResult(NID_GRP, this->__pImpl != null, E_OUT_OF_MEMORY, "Fails to allocate memory.") + SysAssertf(this->__pImpl->IsValid() == false , "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class. "); + + result r = this->__pImpl->Construct(version, pControl); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +GlPlayer::Start(void) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Start(); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +GlPlayer::Pause(void) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Pause(); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +GlPlayer::Resume(void) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Resume(); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +GlPlayer::Stop(void) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Stop(); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +GlPlayer::Redraw(void) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->Redraw(); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +GlPlayer::SetFps(int fps) +{ + CHECK_CONSTRUCTED; + + this->__pImpl->SetFps(fps); +} + +result +GlPlayer::SetEglAttributeList(const EGLint* pEglConfigList) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetEglAttributeList(pEglConfigList); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +GlPlayer::SetEglAttributePreset(EglAttributesPreset preset) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetEglAttributePreset(preset); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +GlPlayer::SetEglAttribute(EGLint key, EGLint value) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetEglAttribute(key, value); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +GlPlayer::SetIGlRenderer(IGlRenderer* pRenderer) +{ + CHECK_CONSTRUCTED; + + result r = this->__pImpl->SetIGlRenderer(pRenderer); + + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +}}} // Tizen::Graphics::Opengl diff --git a/src/graphics/opengl/FGrpGles1.cpp b/src/graphics/opengl/FGrpGles1.cpp new file mode 100644 index 0000000..7677a15 --- /dev/null +++ b/src/graphics/opengl/FGrpGles1.cpp @@ -0,0 +1,3044 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpGles1.cpp + * @brief This is the implementation file for OpenGL ES 1.X. + * + */ + + +#define FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING +#if defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING) +#include +#include +#include +#include +#include +#include +#endif + +#include +#include + +#if defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING) +#include +#endif + +#define FGRAPHICS_INTERNAL_USE_FBO +#if defined(FGRAPHICS_INTERNAL_USE_FBO) +#include +#endif + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +namespace Tizen { namespace Graphics +{ + +namespace Opengl +{ + +#if !defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING) + +#ifdef __cplusplus +extern "C" +{ +#endif + +void +_GlAlphaFunc_1(GLenum func, GLclampf ref) +{ + glAlphaFunc(func, ref); +} + +void +_GlClearColor_1(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + glClearColor(red, green, blue, alpha); +} + +void +_GlClearDepthf_1(GLclampf depth) +{ + glClearDepthf(depth); +} + +void +_GlClipPlanef_1(GLenum plane, const GLfloat* pEquation) +{ + glClipPlanef(plane, pEquation); +} + +void +_GlColor4f_1(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + glColor4f(red, green, blue, alpha); +} + +void +_GlDepthRangef_1(GLclampf zNear, GLclampf zFar) +{ + glDepthRangef(zNear, zFar); +} + +void +_GlFogf_1(GLenum pname, GLfloat param) +{ + glFogf(pname, param); +} + +void +_GlFogfv_1(GLenum pname, const GLfloat* pParams) +{ + glFogfv(pname, pParams); +} + +void +_GlFrustumf_1(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + glFrustumf(left, right, bottom, top, zNear, zFar); +} + +void +_GlGetClipPlanef_1(GLenum pname, GLfloat eqn[4]) +{ + glGetClipPlanef(pname, eqn); +} + +void +_GlGetFloatv_1(GLenum pname, GLfloat* pParams) +{ + glGetFloatv(pname, pParams); +} + +void +_GlGetLightfv_1(GLenum light, GLenum pname, GLfloat* pParams) +{ + glGetLightfv(light, pname, pParams); +} + +void +_GlGetMaterialfv_1(GLenum face, GLenum pname, GLfloat* pParams) +{ + glGetMaterialfv(face, pname, pParams); +} + +void +_GlGetTexEnvfv_1(GLenum env, GLenum pname, GLfloat* pParams) +{ + glGetTexEnvfv(env, pname, pParams); +} + +void +_GlGetTexParameterfv_1(GLenum target, GLenum pname, GLfloat* pParams) +{ + glGetTexParameterfv(target, pname, pParams); +} + +void +_GlLightModelf_1(GLenum pname, GLfloat param) +{ + glLightModelf(pname, param); +} + +void +_GlLightModelfv_1(GLenum pname, const GLfloat* pParams) +{ + glLightModelfv(pname, pParams); +} + +void +_GlLightf_1(GLenum light, GLenum pname, GLfloat param) +{ + glLightf(light, pname, param); +} + +void +_GlLightfv_1(GLenum light, GLenum pname, const GLfloat* pParams) +{ + glLightfv(light, pname, pParams); +} + +void +_GlLineWidth_1(GLfloat width) +{ + glLineWidth(width); +} + +void +_GlLoadMatrixf_1(const GLfloat* pM) +{ + glLoadMatrixf(pM); +} + +void +_GlMaterialf_1(GLenum face, GLenum pname, GLfloat param) +{ + glMaterialf(face, pname, param); +} + +void +_GlMaterialfv_1(GLenum face, GLenum pname, const GLfloat* pParams) +{ + glMaterialfv(face, pname, pParams); +} + +void +_GlMultMatrixf_1(const GLfloat* pM) +{ + glMultMatrixf(pM); +} + +void +_GlMultiTexCoord4f_1(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +{ + glMultiTexCoord4f(target, s, t, r, q); +} + +void +_GlNormal3f_1(GLfloat nx, GLfloat ny, GLfloat nz) +{ + glNormal3f(nx, ny, nz); +} + +void +_GlOrthof_1(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + glOrthof(left, right, bottom, top, zNear, zFar); +} + +void +_GlPointParameterf_1(GLenum pname, GLfloat param) +{ + glPointParameterf(pname, param); +} + +void +_GlPointParameterfv_1(GLenum pname, const GLfloat* pParams) +{ + glPointParameterfv(pname, pParams); +} + +void +_GlPointSize_1(GLfloat size) +{ + glPointSize(size); +} + +void +_GlPolygonOffset_1(GLfloat factor, GLfloat units) +{ + glPolygonOffset(factor, units); +} + +void +_GlRotatef_1(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +{ + glRotatef(angle, x, y, z); +} + +void +_GlScalef_1(GLfloat x, GLfloat y, GLfloat z) +{ + glScalef(x, y, z); +} + +void +_GlTexEnvf_1(GLenum target, GLenum pname, GLfloat param) +{ + glTexEnvf(target, pname, param); +} + +void +_GlTexEnvfv_1(GLenum target, GLenum pname, const GLfloat* pParams) +{ + glTexEnvfv(target, pname, pParams); +} + +void +_GlTexParameterf_1(GLenum target, GLenum pname, GLfloat param) +{ + glTexParameterf(target, pname, param); +} + +void +_GlTexParameterfv_1(GLenum target, GLenum pname, const GLfloat* pParams) +{ + glTexParameterfv(target, pname, pParams); +} + +void +_GlTranslatef_1(GLfloat x, GLfloat y, GLfloat z) +{ + glTranslatef(x, y, z); +} + +void +_GlActiveTexture_1(GLenum texture) +{ + glActiveTexture(texture); +} + +void +_GlAlphaFuncx_1(GLenum func, GLclampx ref) +{ + glAlphaFuncx(func, ref); +} + +void +_GlBindBuffer_1(GLenum target, GLuint buffer) +{ + glBindBuffer(target, buffer); +} + +void +_GlBindTexture_1(GLenum target, GLuint texture) +{ + glBindTexture(target, texture); +} + +void +_GlBlendFunc_1(GLenum sfactor, GLenum dfactor) +{ + glBlendFunc(sfactor, dfactor); +} + +void +_GlBufferData_1(GLenum target, GLsizeiptr size, const GLvoid* pData, GLenum usage) +{ + glBufferData(target, size, pData, usage); +} + +void +_GlBufferSubData_1(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* pData) +{ + glBufferSubData(target, offset, size, pData); +} + +void +_GlClear_1(GLbitfield mask) +{ + glClear(mask); +} + +void +_GlClearColorx_1(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +{ + glClearColorx(red, green, blue, alpha); +} + +void +_GlClearDepthx_1(GLclampx depth) +{ + glClearDepthx(depth); +} + +void +_GlClearStencil_1(GLint s) +{ + glClearStencil(s); +} + +void +_GlClientActiveTexture_1(GLenum texture) +{ + glClientActiveTexture(texture); +} + +void +_GlClipPlanex_1(GLenum plane, const GLfixed* pEquation) +{ + glClipPlanex(plane, pEquation); +} + +void +_GlColor4ub_1(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) +{ + glColor4ub(red, green, blue, alpha); +} + +void +_GlColor4x_1(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +{ + glColor4x(red, green, blue, alpha); +} + +void +_GlColorMask_1(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ + glColorMask(red, green, blue, alpha); +} + +void +_GlColorPointer_1(GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + glColorPointer(size, type, stride, pPointer); +} + +void +_GlCompressedTexImage2D_1(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* pData) +{ + glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pData); +} + +void +_GlCompressedTexSubImage2D_1(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* pData) +{ + glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, pData); +} + +void +_GlCopyTexImage2D_1(GLenum target, GLint level, + GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ + glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); +} + +void +_GlCopyTexSubImage2D_1(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); +} + +void +_GlCullFace_1(GLenum mode) +{ + glCullFace(mode); +} + +void +_GlDeleteBuffers_1(GLsizei n, const GLuint* pBuffers) +{ + glDeleteBuffers(n, pBuffers); +} + +void +_GlDeleteTextures_1(GLsizei n, const GLuint* pTextures) +{ + glDeleteTextures(n, pTextures); +} + +void +_GlDepthFunc_1(GLenum func) +{ + glDepthFunc(func); +} + +void +_GlDepthMask_1(GLboolean flag) +{ + glDepthMask(flag); +} + +void +_GlDepthRangex_1(GLclampx zNear, GLclampx zFar) +{ + glDepthRangex(zNear, zFar); +} + +void +_GlDisable_1(GLenum cap) +{ + glDisable(cap); +} + +void +_GlDisableClientState_1(GLenum array) +{ + glDisableClientState(array); +} + +void +_GlDrawArrays_1(GLenum mode, GLint first, GLsizei count) +{ + glDrawArrays(mode, first, count); +} + +void +_GlDrawElements_1(GLenum mode, GLsizei count, GLenum type, const GLvoid* pIndices) +{ + glDrawElements(mode, count, type, pIndices); +} + +void +_GlEnable_1(GLenum cap) +{ + glEnable(cap); +} + +void +_GlEnableClientState_1(GLenum array) +{ + glEnableClientState(array); +} + +void +_GlFinish_1(void) +{ + glFinish(); +} + +void +_GlFlush_1(void) +{ + glFlush(); +} + +void +_GlFogx_1(GLenum pname, GLfixed param) +{ + glFogx(pname, param); +} + +void +_GlFogxv_1(GLenum pname, const GLfixed* pParams) +{ + glFogxv(pname, pParams); +} + +void +_GlFrontFace_1(GLenum mode) +{ + glFrontFace(mode); +} + +void +_GlFrustumx_1(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + glFrustumx(left, right, bottom, top, zNear, zFar); +} + +void +_GlGetBooleanv_1(GLenum pname, GLboolean* pParams) +{ + glGetBooleanv(pname, pParams); +} + +void +_GlGetBufferParameteriv_1(GLenum target, GLenum pname, GLint* pParams) +{ + glGetBufferParameteriv(target, pname, pParams); +} + +void +_GlGetClipPlanex_1(GLenum pname, GLfixed eqn[4]) +{ + glGetClipPlanex(pname, eqn); +} + +void +_GlGenBuffers_1(GLsizei n, GLuint* pBuffers) +{ + glGenBuffers(n, pBuffers); +} + +void +_GlGenTextures_1(GLsizei n, GLuint* pTextures) +{ + glGenTextures(n, pTextures); +} + +GLenum +_GlGetError_1(void) +{ + return glGetError(); +} + +void +_GlGetFixedv_1(GLenum pname, GLfixed* pParams) +{ + glGetFixedv(pname, pParams); +} + +void +_GlGetIntegerv_1(GLenum pname, GLint* pParams) +{ + glGetIntegerv(pname, pParams); +} + +void +_GlGetLightxv_1(GLenum light, GLenum pname, GLfixed* pParams) +{ + glGetLightxv(light, pname, pParams); +} + +void +_GlGetMaterialxv_1(GLenum face, GLenum pname, GLfixed* pParams) +{ + glGetMaterialxv(face, pname, pParams); +} + +void +_GlGetPointerv_1(GLenum pname, void** ppParams) +{ + glGetPointerv(pname, ppParams); +} + +const GLubyte* +_GlGetString_1(GLenum name) +{ + return glGetString(name); +} + +void +_GlGetTexEnviv_1(GLenum env, GLenum pname, GLint* pParams) +{ + glGetTexEnviv(env, pname, pParams); +} + +void +_GlGetTexEnvxv_1(GLenum env, GLenum pname, GLfixed* pParams) +{ + glGetTexEnvxv(env, pname, pParams); +} + +void +_GlGetTexParameteriv_1(GLenum target, GLenum pname, GLint* pParams) +{ + glGetTexParameteriv(target, pname, pParams); +} + +void +_GlGetTexParameterxv_1(GLenum target, GLenum pname, GLfixed* pParams) +{ + glGetTexParameterxv(target, pname, pParams); +} + +void +_GlHint_1(GLenum target, GLenum mode) +{ + glHint(target, mode); +} + +GLboolean +_GlIsBuffer_1(GLuint buffer) +{ + return glIsBuffer(buffer); +} + +GLboolean +_GlIsEnabled_1(GLenum cap) +{ + return glIsEnabled(cap); +} + +GLboolean +_GlIsTexture_1(GLuint texture) +{ + return glIsTexture(texture); +} + +void +_GlLightModelx_1(GLenum pname, GLfixed param) +{ + glLightModelx(pname, param); +} + +void +_GlLightModelxv_1(GLenum pname, const GLfixed* pParams) +{ + glLightModelxv(pname, pParams); +} + +void +_GlLightx_1(GLenum light, GLenum pname, GLfixed param) +{ + glLightx(light, pname, param); +} + +void +_GlLightxv_1(GLenum light, GLenum pname, const GLfixed* pParams) +{ + glLightxv(light, pname, pParams); +} + +void +_GlLineWidthx_1(GLfixed width) +{ + glLineWidthx(width); +} + +void +_GlLoadIdentity_1(void) +{ + glLoadIdentity(); +} + +void +_GlLoadMatrixx_1(const GLfixed* pM) +{ + glLoadMatrixx(pM); +} + +void +_GlLogicOp_1(GLenum opcode) +{ + glLogicOp(opcode); +} + +void +_GlMaterialx_1(GLenum face, GLenum pname, GLfixed param) +{ + glMaterialx(face, pname, param); +} + +void +_GlMaterialxv_1(GLenum face, GLenum pname, const GLfixed* pParams) +{ + glMaterialxv(face, pname, pParams); +} + +void +_GlMatrixMode_1(GLenum mode) +{ + glMatrixMode(mode); +} + +void +_GlMultMatrixx_1(const GLfixed* pM) +{ + glMultMatrixx(pM); +} + +void +_GlMultiTexCoord4x_1(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +{ + glMultiTexCoord4x(target, s, t, r, q); +} + +void +_GlNormal3x_1(GLfixed nx, GLfixed ny, GLfixed nz) +{ + glNormal3x(nx, ny, nz); +} + +void +_GlNormalPointer_1(GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + glNormalPointer(type, stride, pPointer); +} + +void +_GlOrthox_1(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + glOrthox(left, right, bottom, top, zNear, zFar); +} + +void +_GlPixelStorei_1(GLenum pname, GLint param) +{ + glPixelStorei(pname, param); +} + +void +_GlPointParameterx_1(GLenum pname, GLfixed param) +{ + glPointParameterx(pname, param); +} + +void +_GlPointParameterxv_1(GLenum pname, const GLfixed* pParams) +{ + glPointParameterxv(pname, pParams); +} + +void +_GlPointSizex_1(GLfixed size) +{ + glPointSizex(size); +} + +void +_GlPolygonOffsetx_1(GLfixed factor, GLfixed units) +{ + glPolygonOffsetx(factor, units); +} + +void +_GlPopMatrix_1(void) +{ + glPopMatrix(); +} + +void +_GlPushMatrix_1(void) +{ + glPushMatrix(); +} + +void +_GlReadPixels_1(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pPixels) +{ + glReadPixels(x, y, width, height, format, type, pPixels); +} + +void +_GlRotatex_1(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +{ + glRotatex(angle, x, y, z); +} + +void +_GlSampleCoverage_1(GLclampf value, GLboolean invert) +{ + glSampleCoverage(value, invert); +} + +void +_GlSampleCoveragex_1(GLclampx value, GLboolean invert) +{ + glSampleCoveragex(value, invert); +} + +void +_GlScalex_1(GLfixed x, GLfixed y, GLfixed z) +{ + glScalex(x, y, z); +} + +void +_GlScissor_1(GLint x, GLint y, GLsizei width, GLsizei height) +{ + glScissor(x, y, width, height); +} + +void +_GlShadeModel_1(GLenum mode) +{ + glShadeModel(mode); +} + +void +_GlStencilFunc_1(GLenum func, GLint ref, GLuint mask) +{ + glStencilFunc(func, ref, mask); +} + +void +_GlStencilMask_1(GLuint mask) +{ + glStencilMask(mask); +} + +void +_GlStencilOp_1(GLenum fail, GLenum zfail, GLenum zpass) +{ + glStencilOp(fail, zfail, zpass); +} + +void +_GlTexCoordPointer_1(GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + glTexCoordPointer(size, type, stride, pPointer); +} + +void +_GlTexEnvi_1(GLenum target, GLenum pname, GLint param) +{ + glTexEnvi(target, pname, param); +} + +void +_GlTexEnvx_1(GLenum target, GLenum pname, GLfixed param) +{ + glTexEnvx(target, pname, param); +} + +void +_GlTexEnviv_1(GLenum target, GLenum pname, const GLint* pParams) +{ + glTexEnviv(target, pname, pParams); +} + +void +_GlTexEnvxv_1(GLenum target, GLenum pname, const GLfixed* pParams) +{ + glTexEnvxv(target, pname, pParams); +} + +void +_GlTexImage2D_1(GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pPixels) +{ + glTexImage2D(target, level, internalformat, width, height, border, format, type, pPixels); +} + +void +_GlTexParameteri_1(GLenum target, GLenum pname, GLint param) +{ + glTexParameteri(target, pname, param); +} + +void +_GlTexParameterx_1(GLenum target, GLenum pname, GLfixed param) +{ + glTexParameterx(target, pname, param); +} + +void +_GlTexParameteriv_1(GLenum target, GLenum pname, const GLint* pParams) +{ + glTexParameteriv(target, pname, pParams); +} + +void +_GlTexParameterxv_1(GLenum target, GLenum pname, const GLfixed* pParams) +{ + glTexParameterxv(target, pname, pParams); +} + +void +_GlTexSubImage2D_1(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pPixels) +{ + glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pPixels); +} + +void +_GlTranslatex_1(GLfixed x, GLfixed y, GLfixed z) +{ + glTranslatex(x, y, z); +} + +void +_GlVertexPointer_1(GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + glVertexPointer(size, type, stride, pPointer); +} + +void +_GlViewport_1(GLint x, GLint y, GLsizei width, GLsizei height) +{ + glViewport(x, y, width, height); +} + +void +_GlPointSizePointerOES_1(GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + glPointSizePointerOES(type, stride, pPointer); +} + +void +_GlCurrentPaletteMatrixOES_1(GLuint matrixpaletteindex) +{ + //glCurrentPaletteMatrixOES(matrixpaletteindex); +} +void +_GlLoadPaletteFromModelViewMatrixOES_1(void) +{ + //glLoadPaletteFromModelViewMatrixOES(); +} +void +_GlMatrixIndexPointerOES_1(GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + //glMatrixIndexPointerOES(size, type, stride, pPointer); +} +void +_GlWeightPointerOES_1(GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + //glWeightPointerOES(size, type, stride, pPointer); +} + +// FBO is extension functions in OpenGL ES 1.1 +//Start of FBO Functions +GLboolean +_GlIsRenderbufferOES_1(GLuint renderbuffer) +{ + //return glIsRenderbufferOES(renderbuffer); + return false; +} +void +_GlBindRenderbufferOES_1(GLenum target, GLuint renderbuffer) +{ + //glBindRenderbufferOES(target, renderbuffer); +} +void +_GlDeleteRenderbuffersOES_1(GLsizei n, const GLuint* pRenderbuffers) +{ + //glDeleteRenderbuffersOES(n, pRenderbuffers); +} +void +_GlGenRenderbuffersOES_1(GLsizei n, GLuint* pRenderbuffers) +{ + //glGenRenderbuffersOES(n, pRenderbuffers); +} +void +_GlRenderbufferStorageOES_1(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + //glRenderbufferStorageOES(target, internalformat, width, height); +} +void +_GlGetRenderbufferParameterivOES_1(GLenum target, GLenum pname, GLint* pParams) +{ + //glGetRenderbufferParameterivOES(target, pname, pParams); +} +GLboolean +_GlIsFramebufferOES_1(GLuint framebuffer) +{ + //return glIsFramebufferOES(framebuffer); + return false; +} +void +_GlBindFramebufferOES_1(GLenum target, GLuint framebuffer) +{ + //glBindFramebufferOES(target, framebuffer); +} +void +_GlDeleteFramebuffersOES_1(GLsizei n, const GLuint* pFramebuffers) +{ + //glDeleteFramebuffersOES(n, pFramebuffers); +} +void +_GlGenFramebuffersOES_1(GLsizei n, GLuint* pFramebuffers) +{ + //glGenFramebuffersOES(n, pFramebuffers); +} +GLenum +_GlCheckFramebufferStatusOES_1(GLenum target) +{ + //return glCheckFramebufferStatusOES(target);; + return false; +} +void +_GlFramebufferRenderbufferOES_1(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + //glFramebufferRenderbufferOES(target, attachment, renderbuffertarget, renderbuffer); +} +void +_GlFramebufferTexture2DOES_1(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + //glFramebufferTexture2DOES(target, attachment, textarget, texture, level); +} +void +_GlGetFramebufferAttachmentParameterivOES_1(GLenum target, GLenum attachment, GLenum pname, GLint* pParams) +{ + //glGetFramebufferAttachmentParameterivOES(target, attachment, pname, pParams); +} +void +_GlGenerateMipmapOES_1(GLenum target) +{ + //glGenerateMipmapOES(target); +} +//End of FBO Functions + +#ifdef __cplusplus +} +#endif + +#else + +#define _GLES_CHECK_INTERFACE_VOID_1 if (!_GlesInterfaceInitialize_1()) \ + { \ + return; \ + } +#define _GLES_CHECK_INTERFACE_GLBOOLEAN_1 if (!_GlesInterfaceInitialize_1()) \ + { \ + return GL_FALSE; \ + } +#define _GLES_CHECK_INTERFACE_GLENUM_1 if (!_GlesInterfaceInitialize_1()) \ + { \ + return 0; \ + } +#define _GLES_CHECK_INTERFACE_CONST_GLUBYTEP_1 if (!_GlesInterfaceInitialize_1()) \ + { \ + return (const GLubyte*) 0; \ + } + +namespace // unnamed +{ + +struct _GlesInterface1 +{ + void (* glAlphaFunc)(GLenum func, GLclampf ref); + void (* glClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + void (* glClearDepthf)(GLclampf depth); + void (* glClipPlanef)(GLenum plane, const GLfloat* pEquation); + void (* glColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + void (* glDepthRangef)(GLclampf zNear, GLclampf zFar); + void (* glFogf)(GLenum pname, GLfloat param); + void (* glFogfv)(GLenum pname, const GLfloat* pParams); + void (* glFrustumf)(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); + void (* glGetClipPlanef)(GLenum pname, GLfloat eqn[4]); + void (* glGetFloatv)(GLenum pname, GLfloat* pParams); + void (* glGetLightfv)(GLenum light, GLenum pname, GLfloat* pParams); + void (* glGetMaterialfv)(GLenum face, GLenum pname, GLfloat* pParams); + void (* glGetTexEnvfv)(GLenum env, GLenum pname, GLfloat* pParams); + void (* glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat* pParams); + void (* glLightModelf)(GLenum pname, GLfloat param); + void (* glLightModelfv)(GLenum pname, const GLfloat* pParams); + void (* glLightf)(GLenum light, GLenum pname, GLfloat param); + void (* glLightfv)(GLenum light, GLenum pname, const GLfloat* pParams); + void (* glLineWidth)(GLfloat width); + void (* glLoadMatrixf)(const GLfloat* pM); + void (* glMaterialf)(GLenum face, GLenum pname, GLfloat param); + void (* glMaterialfv)(GLenum face, GLenum pname, const GLfloat* pParams); + void (* glMultMatrixf)(const GLfloat* pM); + void (* glMultiTexCoord4f)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); + void (* glNormal3f)(GLfloat nx, GLfloat ny, GLfloat nz); + void (* glOrthof)(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); + void (* glPointParameterf)(GLenum pname, GLfloat param); + void (* glPointParameterfv)(GLenum pname, const GLfloat* pParams); + void (* glPointSize)(GLfloat size); + void (* glPolygonOffset)(GLfloat factor, GLfloat units); + void (* glRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); + void (* glScalef)(GLfloat x, GLfloat y, GLfloat z); + void (* glTexEnvf)(GLenum target, GLenum pname, GLfloat param); + void (* glTexEnvfv)(GLenum target, GLenum pname, const GLfloat* pParams); + void (* glTexParameterf)(GLenum target, GLenum pname, GLfloat param); + void (* glTexParameterfv)(GLenum target, GLenum pname, const GLfloat* pParams); + void (* glTranslatef)(GLfloat x, GLfloat y, GLfloat z); + void (* glActiveTexture)(GLenum texture); + void (* glAlphaFuncx)(GLenum func, GLclampx ref); + void (* glBindBuffer)(GLenum target, GLuint buffer); + void (* glBindTexture)(GLenum target, GLuint texture); + void (* glBlendFunc)(GLenum sfactor, GLenum dfactor); + void (* glBufferData)(GLenum target, GLsizeiptr size, const GLvoid* pData, GLenum usage); + void (* glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* pData); + void (* glClear)(GLbitfield mask); + void (* glClearColorx)(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); + void (* glClearDepthx)(GLclampx depth); + void (* glClearStencil)(GLint s); + void (* glClientActiveTexture)(GLenum texture); + void (* glClipPlanex)(GLenum plane, const GLfixed* pEquation); + void (* glColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); + void (* glColor4x)(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); + void (* glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + void (* glColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer); + void (* glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* pData); + void (* glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* pData); + void (* glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + void (* glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + void (* glCullFace)(GLenum mode); + void (* glDeleteBuffers)(GLsizei n, const GLuint* pBuffers); + void (* glDeleteTextures)(GLsizei n, const GLuint* pTextures); + void (* glDepthFunc)(GLenum func); + void (* glDepthMask)(GLboolean flag); + void (* glDepthRangex)(GLclampx zNear, GLclampx zFar); + void (* glDisable)(GLenum cap); + void (* glDisableClientState)(GLenum array); + void (* glDrawArrays)(GLenum mode, GLint first, GLsizei count); + void (* glDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid* pIndices); + void (* glEnable)(GLenum cap); + void (* glEnableClientState)(GLenum array); + void (* glFinish)(void); + void (* glFlush)(void); + void (* glFogx)(GLenum pname, GLfixed param); + void (* glFogxv)(GLenum pname, const GLfixed* pParams); + void (* glFrontFace)(GLenum mode); + void (* glFrustumx)(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); + void (* glGetBooleanv)(GLenum pname, GLboolean* pParams); + void (* glGetBufferParameteriv)(GLenum target, GLenum pname, GLint* pParams); + void (* glGetClipPlanex)(GLenum pname, GLfixed eqn[4]); + void (* glGenBuffers)(GLsizei n, GLuint* pBuffers); + void (* glGenTextures)(GLsizei n, GLuint* pTextures); + GLenum (* glGetError)(void); + void (* glGetFixedv)(GLenum pname, GLfixed* pParams); + void (* glGetIntegerv)(GLenum pname, GLint* pParams); + void (* glGetLightxv)(GLenum light, GLenum pname, GLfixed* pParams); + void (* glGetMaterialxv)(GLenum face, GLenum pname, GLfixed* pParams); + void (* glGetPointerv)(GLenum pname, void** ppParams); + const GLubyte* (*glGetString)(GLenum name); + void (* glGetTexEnviv)(GLenum env, GLenum pname, GLint* pParams); + void (* glGetTexEnvxv)(GLenum env, GLenum pname, GLfixed* pParams); + void (* glGetTexParameteriv)(GLenum target, GLenum pname, GLint* pParams); + void (* glGetTexParameterxv)(GLenum target, GLenum pname, GLfixed* pParams); + void (* glHint)(GLenum target, GLenum mode); + GLboolean (* glIsBuffer)(GLuint buffer); + GLboolean (* glIsEnabled)(GLenum cap); + GLboolean (* glIsTexture)(GLuint texture); + void (* glLightModelx)(GLenum pname, GLfixed param); + void (* glLightModelxv)(GLenum pname, const GLfixed* pParams); + void (* glLightx)(GLenum light, GLenum pname, GLfixed param); + void (* glLightxv)(GLenum light, GLenum pname, const GLfixed* pParams); + void (* glLineWidthx)(GLfixed width); + void (* glLoadIdentity)(void); + void (* glLoadMatrixx)(const GLfixed* pM); + void (* glLogicOp)(GLenum opcode); + void (* glMaterialx)(GLenum face, GLenum pname, GLfixed param); + void (* glMaterialxv)(GLenum face, GLenum pname, const GLfixed* pParams); + void (* glMatrixMode)(GLenum mode); + void (* glMultMatrixx)(const GLfixed* pM); + void (* glMultiTexCoord4x)(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); + void (* glNormal3x)(GLfixed nx, GLfixed ny, GLfixed nz); + void (* glNormalPointer)(GLenum type, GLsizei stride, const GLvoid* pPointer); + void (* glOrthox)(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); + void (* glPixelStorei)(GLenum pname, GLint param); + void (* glPointParameterx)(GLenum pname, GLfixed param); + void (* glPointParameterxv)(GLenum pname, const GLfixed* pParams); + void (* glPointSizex)(GLfixed size); + void (* glPolygonOffsetx)(GLfixed factor, GLfixed units); + void (* glPopMatrix)(void); + void (* glPushMatrix)(void); + void (* glReadPixels)(GLint x, GLint y, + GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pPixels); + void (* glRotatex)(GLfixed angle, GLfixed x, GLfixed y, GLfixed z); + void (* glSampleCoverage)(GLclampf value, GLboolean invert); + void (* glSampleCoveragex)(GLclampx value, GLboolean invert); + void (* glScalex)(GLfixed x, GLfixed y, GLfixed z); + void (* glScissor)(GLint x, GLint y, GLsizei width, GLsizei height); + void (* glShadeModel)(GLenum mode); + void (* glStencilFunc)(GLenum func, GLint ref, GLuint mask); + void (* glStencilMask)(GLuint mask); + void (* glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass); + void (* glTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer); + void (* glTexEnvi)(GLenum target, GLenum pname, GLint param); + void (* glTexEnvx)(GLenum target, GLenum pname, GLfixed param); + void (* glTexEnviv)(GLenum target, GLenum pname, const GLint* pParams); + void (* glTexEnvxv)(GLenum target, GLenum pname, const GLfixed* pParams); + void (* glTexImage2D)(GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pPixels); + void (* glTexParameteri)(GLenum target, GLenum pname, GLint param); + void (* glTexParameterx)(GLenum target, GLenum pname, GLfixed param); + void (* glTexParameteriv)(GLenum target, GLenum pname, const GLint* pParams); + void (* glTexParameterxv)(GLenum target, GLenum pname, const GLfixed* pParams); + void (* glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pPixels); + void (* glTranslatex)(GLfixed x, GLfixed y, GLfixed z); + void (* glVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid* Pointer); + void (* glViewport)(GLint x, GLint y, GLsizei width, GLsizei height); + void (* glPointSizePointerOES)(GLenum type, GLsizei stride, const GLvoid* pPointer); + void (* glCurrentPaletteMatrixOES) (GLuint matrixpaletteindex); + void (* glLoadPaletteFromModelViewMatrixOES) (void); + void (* glMatrixIndexPointerOES) (GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer); + void (* glWeightPointerOES) (GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer); + GLboolean (* glIsRenderbufferOES) (GLuint renderbuffer); + void (* glBindRenderbufferOES) (GLenum target, GLuint renderbuffer); + void (* glDeleteRenderbuffersOES) (GLsizei n, const GLuint* pRenderbuffers); + void (* glGenRenderbuffersOES) (GLsizei n, GLuint* pRenderbuffers); + void (* glRenderbufferStorageOES) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + void (* glGetRenderbufferParameterivOES) (GLenum target, GLenum pname, GLint* pParams); + GLboolean (* glIsFramebufferOES) (GLuint framebuffer); + void (* glBindFramebufferOES) (GLenum target, GLuint framebuffer); + void (* glDeleteFramebuffersOES) (GLsizei n, const GLuint* pFramebuffers); + void (* glGenFramebuffersOES) (GLsizei n, GLuint* pFramebuffers); + GLenum (* glCheckFramebufferStatusOES) (GLenum target); + void (* glFramebufferRenderbufferOES) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + void (* glFramebufferTexture2DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + void (* glGetFramebufferAttachmentParameterivOES) (GLenum target, GLenum attachment, GLenum pname, GLint* pParams); + void (* glGenerateMipmapOES) (GLenum target); +}; + +void* _pGlesLib1 = NULL; +_GlesInterface1 _glesImpl1 = {0, }; + +const int _MAX_GLES_FUNCTION_1 = 164; //145 // extensions 164; +const char _glesStrings1[_MAX_GLES_FUNCTION_1][64] = +{ + "glAlphaFunc", + "glClearColor", + "glClearDepthf", + "glClipPlanef", + "glColor4f", + "glDepthRangef", + "glFogf", + "glFogfv", + "glFrustumf", + "glGetClipPlanef", + "glGetFloatv", //10 + "glGetLightfv", + "glGetMaterialfv", + "glGetTexEnvfv", + "glGetTexParameterfv", + "glLightModelf", + "glLightModelfv", + "glLightf", + "glLightfv", + "glLineWidth", + "glLoadMatrixf", //20 + "glMaterialf", + "glMaterialfv", + "glMultMatrixf", + "glMultiTexCoord4f", + "glNormal3f", + "glOrthof", + "glPointParameterf", + "glPointParameterfv", + "glPointSize", + "glPolygonOffset", //30 + "glRotatef", + "glScalef", + "glTexEnvf", + "glTexEnvfv", + "glTexParameterf", + "glTexParameterfv", + "glTranslatef", + "glActiveTexture", + "glAlphaFuncx", + "glBindBuffer", //40 + "glBindTexture", + "glBlendFunc", + "glBufferData", + "glBufferSubData", + "glClear", + "glClearColorx", + "glClearDepthx", + "glClearStencil", + "glClientActiveTexture", + "glClipPlanex", //50 + "glColor4ub", + "glColor4x", + "glColorMask", + "glColorPointer", + "glCompressedTexImage2D", + "glCompressedTexSubImage2D", + "glCopyTexImage2D", + "glCopyTexSubImage2D", + "glCullFace", + "glDeleteBuffers", //60 + "glDeleteTextures", + "glDepthFunc", + "glDepthMask", + "glDepthRangex", + "glDisable", + "glDisableClientState", + "glDrawArrays", + "glDrawElements", + "glEnable", + "glEnableClientState", //70 + "glFinish", + "glFlush", + "glFogx", + "glFogxv", + "glFrontFace", + "glFrustumx", + "glGetBooleanv", + "glGetBufferParameteriv", + "glGetClipPlanex", + "glGenBuffers", //80 + "glGenTextures", + "glGetError", + "glGetFixedv", + "glGetIntegerv", + "glGetLightxv", + "glGetMaterialxv", + "glGetPointerv", + "glGetString", + "glGetTexEnviv", + "glGetTexEnvxv", //90 + "glGetTexParameteriv", + "glGetTexParameterxv", + "glHint", + "glIsBuffer", + "glIsEnabled", + "glIsTexture", + "glLightModelx", + "glLightModelxv", + "glLightx", + "glLightxv", //100 + "glLineWidthx", + "glLoadIdentity", + "glLoadMatrixx", + "glLogicOp", + "glMaterialx", + "glMaterialxv", + "glMatrixMode", + "glMultMatrixx", + "glMultiTexCoord4x", + "glNormal3x", //110 + "glNormalPointer", + "glOrthox", + "glPixelStorei", + "glPointParameterx", + "glPointParameterxv", + "glPointSizex", + "glPolygonOffsetx", + "glPopMatrix", + "glPushMatrix", + "glReadPixels", //120 + "glRotatex", + "glSampleCoverage", + "glSampleCoveragex", + "glScalex", + "glScissor", + "glShadeModel", + "glStencilFunc", + "glStencilMask", + "glStencilOp", + "glTexCoordPointer", //130 + "glTexEnvi", + "glTexEnvx", + "glTexEnviv", + "glTexEnvxv", + "glTexImage2D", + "glTexParameteri", + "glTexParameterx", + "glTexParameteriv", + "glTexParameterxv", + "glTexSubImage2D", //140 + "glTranslatex", + "glVertexPointer", + "glViewport", + "glPointSizePointerOES", //144 + "glCurrentPaletteMatrixOES", + "glLoadPaletteFromModelViewMatrixOES", + "glMatrixIndexPointerOES", + "glWeightPointerOES", + "glIsRenderbufferOES", + "glBindRenderbufferOES", //150 + "glDeleteRenderbuffersOES", + "glGenRenderbuffersOES", + "glRenderbufferStorageOES", + "glGetRenderbufferParameterivOES", + "glIsFramebufferOES", + "glBindFramebufferOES", + "glDeleteFramebuffersOES", + "glGenFramebuffersOES", + "glCheckFramebufferStatusOES", + "glFramebufferRenderbufferOES", //160 + "glFramebufferTexture2DOES", + "glGetFramebufferAttachmentParameterivOES", + "glGenerateMipmapOES" //163 +}; + +bool +_GlesInterfaceInitialize_1(void) +{ + int count = 0; + + if (_pGlesLib1 == NULL) + { + ptrdiff_t** ppPtr = (ptrdiff_t**) (&_glesImpl1); + + _pGlesLib1 = dlopen("libGLESv1_CM.so", RTLD_LAZY | RTLD_GLOBAL); + if (_pGlesLib1 == NULL) + { + SysLog(NID_GRP, "gles1 dlopen failed! %s", dlerror()); + return false; + } + + for (count = 0; count < _MAX_GLES_FUNCTION_1; count++) + { + *ppPtr = (ptrdiff_t*) (dlsym(_pGlesLib1, _glesStrings1[count])); + + if (*ppPtr == NULL) + { + SysLog(NID_GRP, "dlsym failed! %s name : %s", dlerror(), _glesStrings1[count]); + } + ppPtr++; + } + } + + return true; +} + +} + +#ifdef __cplusplus +extern "C" +{ +#endif + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) +GLuint _GlesGetCurrentFbo(void); +bool _GlesFboEnableStencil(GLuint& frameBufferObject, GLuint& renderBuffer); +#endif + +_OSP_LOCAL_ void +_GlesInterfaceTerminate_1(void) +{ + if (_pGlesLib1 != NULL) + { + dlclose(_pGlesLib1); + _pGlesLib1 = NULL; + } +} + +void +_GlAlphaFunc_1(GLenum func, GLclampf ref) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glAlphaFunc(func, ref); +} + +void +_GlClearColor_1(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glClearColor(red, green, blue, alpha); +} + +void +_GlClearDepthf_1(GLclampf depth) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glClearDepthf(depth); +} + +void +_GlClipPlanef_1(GLenum plane, const GLfloat* pEquation) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glClipPlanef(plane, pEquation); +} + +void +_GlColor4f_1(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glColor4f(red, green, blue, alpha); +} + +void +_GlDepthRangef_1(GLclampf zNear, GLclampf zFar) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glDepthRangef(zNear, zFar); +} + +void +_GlFogf_1(GLenum pname, GLfloat param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glFogf(pname, param); +} + +void +_GlFogfv_1(GLenum pname, const GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glFogfv(pname, pParams); +} + +void +_GlFrustumf_1(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glFrustumf(left, right, bottom, top, zNear, zFar); +} + +void +_GlGetClipPlanef_1(GLenum pname, GLfloat eqn[4]) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetClipPlanef(pname, eqn); +} + +void +_GlGetFloatv_1(GLenum pname, GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetFloatv(pname, pParams); +} + +void +_GlGetLightfv_1(GLenum light, GLenum pname, GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetLightfv(light, pname, pParams); +} + +void +_GlGetMaterialfv_1(GLenum face, GLenum pname, GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetMaterialfv(face, pname, pParams); +} + +void +_GlGetTexEnvfv_1(GLenum env, GLenum pname, GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetTexEnvfv(env, pname, pParams); +} + +void +_GlGetTexParameterfv_1(GLenum target, GLenum pname, GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetTexParameterfv(target, pname, pParams); +} + +void +_GlLightModelf_1(GLenum pname, GLfloat param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLightModelf(pname, param); +} + +void +_GlLightModelfv_1(GLenum pname, const GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLightModelfv(pname, pParams); +} + +void +_GlLightf_1(GLenum light, GLenum pname, GLfloat param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLightf(light, pname, param); +} + +void +_GlLightfv_1(GLenum light, GLenum pname, const GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLightfv(light, pname, pParams); +} + +void +_GlLineWidth_1(GLfloat width) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLineWidth(width); +} + +void +_GlLoadMatrixf_1(const GLfloat* pM) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLoadMatrixf(pM); +} + +void +_GlMaterialf_1(GLenum face, GLenum pname, GLfloat param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glMaterialf(face, pname, param); +} + +void +_GlMaterialfv_1(GLenum face, GLenum pname, const GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glMaterialfv(face, pname, pParams); +} + +void +_GlMultMatrixf_1(const GLfloat* pM) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glMultMatrixf(pM); +} + +void +_GlMultiTexCoord4f_1(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glMultiTexCoord4f(target, s, t, r, q); +} + +void +_GlNormal3f_1(GLfloat nx, GLfloat ny, GLfloat nz) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glNormal3f(nx, ny, nz); +} + +void +_GlOrthof_1(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glOrthof(left, right, bottom, top, zNear, zFar); +} + +void +_GlPointParameterf_1(GLenum pname, GLfloat param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glPointParameterf(pname, param); +} + +void +_GlPointParameterfv_1(GLenum pname, const GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glPointParameterfv(pname, pParams); +} + +void +_GlPointSize_1(GLfloat size) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glPointSize(size); +} + +void +_GlPolygonOffset_1(GLfloat factor, GLfloat units) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glPolygonOffset(factor, units); +} + +void +_GlRotatef_1(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glRotatef(angle, x, y, z); +} + +void +_GlScalef_1(GLfloat x, GLfloat y, GLfloat z) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glScalef(x, y, z); +} + +void +_GlTexEnvf_1(GLenum target, GLenum pname, GLfloat param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexEnvf(target, pname, param); +} + +void +_GlTexEnvfv_1(GLenum target, GLenum pname, const GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexEnvfv(target, pname, pParams); +} + +void +_GlTexParameterf_1(GLenum target, GLenum pname, GLfloat param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexParameterf(target, pname, param); +} + +void +_GlTexParameterfv_1(GLenum target, GLenum pname, const GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexParameterfv(target, pname, pParams); +} + +void +_GlTranslatef_1(GLfloat x, GLfloat y, GLfloat z) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTranslatef(x, y, z); +} + +void +_GlActiveTexture_1(GLenum texture) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glActiveTexture(texture); +} + +void +_GlAlphaFuncx_1(GLenum func, GLclampx ref) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glAlphaFuncx(func, ref); +} + +void +_GlBindBuffer_1(GLenum target, GLuint buffer) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glBindBuffer(target, buffer); +} + +void +_GlBindTexture_1(GLenum target, GLuint texture) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glBindTexture(target, texture); +} + +void +_GlBlendFunc_1(GLenum sfactor, GLenum dfactor) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glBlendFunc(sfactor, dfactor); +} + +void +_GlBufferData_1(GLenum target, GLsizeiptr size, const GLvoid* pData, GLenum usage) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glBufferData(target, size, pData, usage); +} + +void +_GlBufferSubData_1(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* pData) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glBufferSubData(target, offset, size, pData); +} + +void +_GlClear_1(GLbitfield mask) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glClear(mask); +} + +void +_GlClearColorx_1(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glClearColorx(red, green, blue, alpha); +} + +void +_GlClearDepthx_1(GLclampx depth) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glClearDepthx(depth); +} + +void +_GlClearStencil_1(GLint s) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glClearStencil(s); +} + +void +_GlClientActiveTexture_1(GLenum texture) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glClientActiveTexture(texture); +} + +void +_GlClipPlanex_1(GLenum plane, const GLfixed* pEquation) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glClipPlanex(plane, pEquation); +} + +void +_GlColor4ub_1(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glColor4ub(red, green, blue, alpha); +} + +void +_GlColor4x_1(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glColor4x(red, green, blue, alpha); +} + +void +_GlColorMask_1(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glColorMask(red, green, blue, alpha); +} + +void +_GlColorPointer_1(GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glColorPointer(size, type, stride, pPointer); +} + +void +_GlCompressedTexImage2D_1(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* pData) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pData); +} + +void +_GlCompressedTexSubImage2D_1(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* pData) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, pData); +} + +void +_GlCopyTexImage2D_1(GLenum target, GLint level, + GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); +} + +void +_GlCopyTexSubImage2D_1(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); +} + +void +_GlCullFace_1(GLenum mode) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glCullFace(mode); +} + +void +_GlDeleteBuffers_1(GLsizei n, const GLuint* pBuffers) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glDeleteBuffers(n, pBuffers); +} + +void +_GlDeleteTextures_1(GLsizei n, const GLuint* pTextures) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glDeleteTextures(n, pTextures); +} + +void +_GlDepthFunc_1(GLenum func) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glDepthFunc(func); +} + +void +_GlDepthMask_1(GLboolean flag) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glDepthMask(flag); +} + +void +_GlDepthRangex_1(GLclampx zNear, GLclampx zFar) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glDepthRangex(zNear, zFar); +} + +void +_GlDisable_1(GLenum cap) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glDisable(cap); +} + +void +_GlDisableClientState_1(GLenum array) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glDisableClientState(array); +} + +void +_GlDrawArrays_1(GLenum mode, GLint first, GLsizei count) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glDrawArrays(mode, first, count); +} + +void +_GlDrawElements_1(GLenum mode, GLsizei count, GLenum type, const GLvoid* pIndices) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glDrawElements(mode, count, type, pIndices); +} + +void +_GlEnable_1(GLenum cap) +{ + _GLES_CHECK_INTERFACE_VOID_1 +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + if (cap == GL_STENCIL_TEST) + { + GLuint frameBufferObject = 0; + GLuint stencilRenderBuffer = 0; + + bool ret = _GlesFboEnableStencil(frameBufferObject, stencilRenderBuffer); + + if (ret) + { + _glesImpl1.glBindFramebufferOES(GL_FRAMEBUFFER_OES, frameBufferObject); + _glesImpl1.glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, stencilRenderBuffer); + } + } +#endif + _glesImpl1.glEnable(cap); +} + +void +_GlEnableClientState_1(GLenum array) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glEnableClientState(array); +} + +void +_GlFinish_1(void) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glFinish(); +} + +void +_GlFlush_1(void) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glFlush(); +} + +void +_GlFogx_1(GLenum pname, GLfixed param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glFogx(pname, param); +} + +void +_GlFogxv_1(GLenum pname, const GLfixed* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glFogxv(pname, pParams); +} + +void +_GlFrontFace_1(GLenum mode) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glFrontFace(mode); +} + +void +_GlFrustumx_1(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glFrustumx(left, right, bottom, top, zNear, zFar); +} + +void +_GlGetBooleanv_1(GLenum pname, GLboolean* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetBooleanv(pname, pParams); +} + +void +_GlGetBufferParameteriv_1(GLenum target, GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetBufferParameteriv(target, pname, pParams); +} + +void +_GlGetClipPlanex_1(GLenum pname, GLfixed eqn[4]) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetClipPlanex(pname, eqn); +} + +void +_GlGenBuffers_1(GLsizei n, GLuint* pBuffers) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGenBuffers(n, pBuffers); +} + +void +_GlGenTextures_1(GLsizei n, GLuint* pTextures) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGenTextures(n, pTextures); +} + +GLenum +_GlGetError_1(void) +{ + _GLES_CHECK_INTERFACE_GLENUM_1 + return _glesImpl1.glGetError(); +} + +void +_GlGetFixedv_1(GLenum pname, GLfixed* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetFixedv(pname, pParams); +} + +void +_GlGetIntegerv_1(GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetIntegerv(pname, pParams); +} + +void +_GlGetLightxv_1(GLenum light, GLenum pname, GLfixed* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetLightxv(light, pname, pParams); +} + +void +_GlGetMaterialxv_1(GLenum face, GLenum pname, GLfixed* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetMaterialxv(face, pname, pParams); +} + +void +_GlGetPointerv_1(GLenum pname, void** ppParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetPointerv(pname, ppParams); +} + +const GLubyte* +_GlGetString_1(GLenum name) +{ + _GLES_CHECK_INTERFACE_CONST_GLUBYTEP_1 + return _glesImpl1.glGetString(name); +} + +void +_GlGetTexEnviv_1(GLenum env, GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetTexEnviv(env, pname, pParams); +} + +void +_GlGetTexEnvxv_1(GLenum env, GLenum pname, GLfixed* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetTexEnvxv(env, pname, pParams); +} + +void +_GlGetTexParameteriv_1(GLenum target, GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetTexParameteriv(target, pname, pParams); +} + +void +_GlGetTexParameterxv_1(GLenum target, GLenum pname, GLfixed* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetTexParameterxv(target, pname, pParams); +} + +void +_GlHint_1(GLenum target, GLenum mode) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glHint(target, mode); +} + +GLboolean +_GlIsBuffer_1(GLuint buffer) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_1 + return _glesImpl1.glIsBuffer(buffer); +} + +GLboolean +_GlIsEnabled_1(GLenum cap) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_1 + return _glesImpl1.glIsEnabled(cap); +} + +GLboolean +_GlIsTexture_1(GLuint texture) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_1 + return _glesImpl1.glIsTexture(texture); +} + +void +_GlLightModelx_1(GLenum pname, GLfixed param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLightModelx(pname, param); +} + +void +_GlLightModelxv_1(GLenum pname, const GLfixed* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLightModelxv(pname, pParams); +} + +void +_GlLightx_1(GLenum light, GLenum pname, GLfixed param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLightx(light, pname, param); +} + +void +_GlLightxv_1(GLenum light, GLenum pname, const GLfixed* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLightxv(light, pname, pParams); +} + +void +_GlLineWidthx_1(GLfixed width) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLineWidthx(width); +} + +void +_GlLoadIdentity_1(void) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLoadIdentity(); +} + +void +_GlLoadMatrixx_1(const GLfixed* pM) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLoadMatrixx(pM); +} + +void +_GlLogicOp_1(GLenum opcode) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLogicOp(opcode); +} + +void +_GlMaterialx_1(GLenum face, GLenum pname, GLfixed param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glMaterialx(face, pname, param); +} + +void +_GlMaterialxv_1(GLenum face, GLenum pname, const GLfixed* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glMaterialxv(face, pname, pParams); +} + +void +_GlMatrixMode_1(GLenum mode) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glMatrixMode(mode); +} + +void +_GlMultMatrixx_1(const GLfixed* pM) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glMultMatrixx(pM); +} + +void +_GlMultiTexCoord4x_1(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glMultiTexCoord4x(target, s, t, r, q); +} + +void +_GlNormal3x_1(GLfixed nx, GLfixed ny, GLfixed nz) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glNormal3x(nx, ny, nz); +} + +void +_GlNormalPointer_1(GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glNormalPointer(type, stride, pPointer); +} + +void +_GlOrthox_1(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glOrthox(left, right, bottom, top, zNear, zFar); +} + +void +_GlPixelStorei_1(GLenum pname, GLint param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glPixelStorei(pname, param); +} + +void +_GlPointParameterx_1(GLenum pname, GLfixed param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glPointParameterx(pname, param); +} + +void +_GlPointParameterxv_1(GLenum pname, const GLfixed* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glPointParameterxv(pname, pParams); +} + +void +_GlPointSizex_1(GLfixed size) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glPointSizex(size); +} + +void +_GlPolygonOffsetx_1(GLfixed factor, GLfixed units) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glPolygonOffsetx(factor, units); +} + +void +_GlPopMatrix_1(void) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glPopMatrix(); +} + +void +_GlPushMatrix_1(void) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glPushMatrix(); +} + +void +_GlReadPixels_1(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pPixels) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glReadPixels(x, y, width, height, format, type, pPixels); +} + +void +_GlRotatex_1(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glRotatex(angle, x, y, z); +} + +void +_GlSampleCoverage_1(GLclampf value, GLboolean invert) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glSampleCoverage(value, invert); +} + +void +_GlSampleCoveragex_1(GLclampx value, GLboolean invert) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glSampleCoveragex(value, invert); +} + +void +_GlScalex_1(GLfixed x, GLfixed y, GLfixed z) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glScalex(x, y, z); +} + +void +_GlScissor_1(GLint x, GLint y, GLsizei width, GLsizei height) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glScissor(x, y, width, height); +} + +void +_GlShadeModel_1(GLenum mode) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glShadeModel(mode); +} + +void +_GlStencilFunc_1(GLenum func, GLint ref, GLuint mask) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glStencilFunc(func, ref, mask); +} + +void +_GlStencilMask_1(GLuint mask) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glStencilMask(mask); +} + +void +_GlStencilOp_1(GLenum fail, GLenum zfail, GLenum zpass) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glStencilOp(fail, zfail, zpass); +} + +void +_GlTexCoordPointer_1(GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexCoordPointer(size, type, stride, pPointer); +} + +void +_GlTexEnvi_1(GLenum target, GLenum pname, GLint param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexEnvi(target, pname, param); +} + +void +_GlTexEnvx_1(GLenum target, GLenum pname, GLfixed param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexEnvx(target, pname, param); +} + +void +_GlTexEnviv_1(GLenum target, GLenum pname, const GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexEnviv(target, pname, pParams); +} + +void +_GlTexEnvxv_1(GLenum target, GLenum pname, const GLfixed* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexEnvxv(target, pname, pParams); +} + +void +_GlTexImage2D_1(GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pPixels) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexImage2D(target, level, internalformat, width, height, border, format, type, pPixels); +} + +void +_GlTexParameteri_1(GLenum target, GLenum pname, GLint param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexParameteri(target, pname, param); +} + +void +_GlTexParameterx_1(GLenum target, GLenum pname, GLfixed param) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexParameterx(target, pname, param); +} + +void +_GlTexParameteriv_1(GLenum target, GLenum pname, const GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexParameteriv(target, pname, pParams); +} + +void +_GlTexParameterxv_1(GLenum target, GLenum pname, const GLfixed* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexParameterxv(target, pname, pParams); +} + +void +_GlTexSubImage2D_1(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pPixels) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pPixels); +} + +void +_GlTranslatex_1(GLfixed x, GLfixed y, GLfixed z) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glTranslatex(x, y, z); +} + +void +_GlVertexPointer_1(GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glVertexPointer(size, type, stride, pPointer); +} + +void +_GlViewport_1(GLint x, GLint y, GLsizei width, GLsizei height) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glViewport(x, y, width, height); +} + +void +_GlPointSizePointerOES_1(GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glPointSizePointerOES(type, stride, pPointer); +} + +void +_GlCurrentPaletteMatrixOES_1(GLuint matrixpaletteindex) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glCurrentPaletteMatrixOES(matrixpaletteindex); +} + +void +_GlLoadPaletteFromModelViewMatrixOES_1(void) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glLoadPaletteFromModelViewMatrixOES(); +} + +void +_GlMatrixIndexPointerOES_1(GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glMatrixIndexPointerOES(size, type, stride, pPointer); +} + +void +_GlWeightPointerOES_1(GLint size, GLenum type, GLsizei stride, const GLvoid* pPointer) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glWeightPointerOES(size, type, stride, pPointer); +} + +// FBO is extension functions in OpenGL ES 1.1 +//Start of FBO Functions +GLboolean +_GlIsRenderbufferOES_1(GLuint renderbuffer) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_1 + return _glesImpl1.glIsRenderbufferOES(renderbuffer); +} + +void +_GlBindRenderbufferOES_1(GLenum target, GLuint renderbuffer) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glBindRenderbufferOES(target, renderbuffer); +} + +void +_GlDeleteRenderbuffersOES_1(GLsizei n, const GLuint* pRenderbuffers) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glDeleteRenderbuffersOES(n, pRenderbuffers); +} + +void +_GlGenRenderbuffersOES_1(GLsizei n, GLuint* pRenderbuffers) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGenRenderbuffersOES(n, pRenderbuffers); +} + +void +_GlRenderbufferStorageOES_1(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glRenderbufferStorageOES(target, internalformat, width, height); +} + +void +_GlGetRenderbufferParameterivOES_1(GLenum target, GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetRenderbufferParameterivOES(target, pname, pParams); +} + +GLboolean +_GlIsFramebufferOES_1(GLuint framebuffer) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_1 + return _glesImpl1.glIsFramebufferOES(framebuffer); +} + +void +_GlBindFramebufferOES_1(GLenum target, GLuint framebuffer) +{ + _GLES_CHECK_INTERFACE_VOID_1 + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + if (framebuffer == 0) + { + framebuffer = _GlesGetCurrentFbo(); + } +#endif + + _glesImpl1.glBindFramebufferOES(target, framebuffer); +} + +void +_GlDeleteFramebuffersOES_1(GLsizei n, const GLuint* pFramebuffers) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glDeleteFramebuffersOES(n, pFramebuffers); +} + +void +_GlGenFramebuffersOES_1(GLsizei n, GLuint* pFramebuffers) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGenFramebuffersOES(n, pFramebuffers); +} + +GLenum +_GlCheckFramebufferStatusOES_1(GLenum target) +{ + _GLES_CHECK_INTERFACE_GLENUM_1 + return _glesImpl1.glCheckFramebufferStatusOES(target); +} + +void +_GlFramebufferRenderbufferOES_1(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glFramebufferRenderbufferOES(target, attachment, renderbuffertarget, renderbuffer); +} + +void +_GlFramebufferTexture2DOES_1(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glFramebufferTexture2DOES(target, attachment, textarget, texture, level); +} + +void +_GlGetFramebufferAttachmentParameterivOES_1(GLenum target, GLenum attachment, GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGetFramebufferAttachmentParameterivOES(target, attachment, pname, pParams); +} + +void +_GlGenerateMipmapOES_1(GLenum target) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glGenerateMipmapOES(target); +} +//End of FBO Functions + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) +_OSP_LOCAL_ int +_GlesFboGetPowerOf2(int value) +{ + int result = 1; + + while(result < value) + { + result <<= 1; + } + + return result; +} + +_OSP_LOCAL_ void +_GlesFboTerminate_1(GLuint& frameBufferObject, GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer, GLuint& textureId) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); + + if (frameBufferObject != 0) + { + _glesImpl1.glDeleteFramebuffersOES(1, &frameBufferObject); + frameBufferObject = 0; + } + + if (depthRenderBuffer != 0) + { + _glesImpl1.glDeleteRenderbuffersOES(1, &depthRenderBuffer); + depthRenderBuffer = 0; + } + + if (stencilRenderBuffer != 0) + { + _glesImpl1.glDeleteRenderbuffersOES(1, &stencilRenderBuffer); + stencilRenderBuffer = 0; + } + + if (textureId != 0) + { + _glesImpl1.glDeleteTextures(1, &textureId); + textureId = 0; + } +} + +_OSP_LOCAL_ bool +_GlesFboInitialize_1(int& fboWidth, int& fboHeight, GLuint& frameBufferObject, GLuint& depthRenderBuffer + , GLuint& stencilRenderBuffer, GLuint colorSize, GLuint depthSize, GLuint stencilSize, GLuint& textureId) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_1 + const char* pString = (const char*)_glesImpl1.glGetString(GL_EXTENSIONS); + String extensions(pString); + if (!extensions.Contains(L"GL_OES_framebuffer_object")) + { + SysLog(NID_GRP, "FBO not supported : %ls", extensions.GetPointer()); + return false; + } + + if (!extensions.Contains(L"GL_OES_texture_npot")) + { + fboWidth = _GlesFboGetPowerOf2(fboWidth); + fboHeight = _GlesFboGetPowerOf2(fboHeight); + } + + GLint maxSize = 0; + _glesImpl1.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_OES, &maxSize); + if (fboWidth > maxSize || fboHeight > maxSize) + { + SysLog(NID_GRP, "FBO Incompatible size"); + return false; + } + + _glesImpl1.glEnable(GL_TEXTURE_2D); + + _glesImpl1.glGenFramebuffersOES(1, &frameBufferObject); + _glesImpl1.glGenRenderbuffersOES(1, &depthRenderBuffer); + _glesImpl1.glGenRenderbuffersOES(1, &stencilRenderBuffer); + _glesImpl1.glGenTextures(1, &textureId); + if (frameBufferObject == 0 || depthRenderBuffer == 0 || stencilRenderBuffer == 0 || textureId == 0) + { + SysLog(NID_GRP, "FBO generating failed! fbo:%d depth:%d stencil:%d tex:%d" + , frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId); + _GlesFboTerminate_1(frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId); + } + + _glesImpl1.glBindTexture(GL_TEXTURE_2D, textureId); + if (colorSize > 16) + { + _glesImpl1.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fboWidth, fboHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + } + else + { + _glesImpl1.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, fboWidth, fboHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL); + } + _glesImpl1.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + _glesImpl1.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + _glesImpl1.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + _glesImpl1.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + if (depthSize > 0) + { + GLenum internalFormat = GL_DEPTH_COMPONENT16_OES; + + if (depthSize > 24) + { + if (extensions.Contains(L"GL_OES_depth32")) + { + internalFormat = GL_DEPTH_COMPONENT32_OES; + } + } + else if (depthSize > 16) + { + if (extensions.Contains(L"GL_OES_depth24")) + { + internalFormat = GL_DEPTH_COMPONENT24_OES; + } + } + + _glesImpl1.glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderBuffer); + _glesImpl1.glRenderbufferStorageOES(GL_RENDERBUFFER_OES, internalFormat, fboWidth, fboHeight); + } + + if (stencilSize > 0) + { + GLenum internalFormat = 0; + + if (extensions.Contains(L"GL_OES_stencil8")) + { + internalFormat = GL_STENCIL_INDEX8_OES; + } + + if (stencilSize == 1) + { + if (extensions.Contains(L"GL_OES_stencil1")) + { + internalFormat = GL_STENCIL_INDEX1_OES; + } + } + else if (stencilSize <= 4) + { + if (extensions.Contains(L"GL_OES_stencil4")) + { + internalFormat = GL_STENCIL_INDEX4_OES; + } + } + + if (internalFormat != 0) + { + _glesImpl1.glBindRenderbufferOES(GL_RENDERBUFFER_OES, stencilRenderBuffer); + _glesImpl1.glRenderbufferStorageOES(GL_RENDERBUFFER_OES, internalFormat, fboWidth, fboHeight); + } + } + + _glesImpl1.glBindFramebufferOES(GL_FRAMEBUFFER_OES, frameBufferObject); + _glesImpl1.glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, textureId, 0); + if (depthSize != 0) + { + _glesImpl1.glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES + , GL_RENDERBUFFER_OES, depthRenderBuffer); + } + + _glesImpl1.glBindTexture(GL_TEXTURE_2D, 0); + + GLenum ret = _glesImpl1.glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES); + if (ret != GL_FRAMEBUFFER_COMPLETE_OES) + { + _GlesFboTerminate_1(frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId); + SysLog(NID_GRP, "FBO glCheckFramebufferStatus failed! %#x", (unsigned int)ret); + return false; + } + + return true; +} + +_OSP_LOCAL_ void +_GlesFboBinding_1(const GLuint frameBufferObject) +{ + _GLES_CHECK_INTERFACE_VOID_1 + _glesImpl1.glBindFramebufferOES(GL_FRAMEBUFFER_OES, frameBufferObject); +} + +_OSP_LOCAL_ void +_GlesFboSwapBuffers_1(const Frame* pFrame, int fboWidth, int fboHeight, const GLuint frameBufferObject, const GLuint textureId) +{ + _GLES_CHECK_INTERFACE_VOID_1 + GLboolean isEnabledCullFace = GL_FALSE; + GLboolean isEnabledStencil = GL_FALSE; + GLboolean isEnabledDepth = GL_FALSE; + GLboolean isEnabledScissor = GL_FALSE; + GLboolean isEnabledBlend = GL_FALSE; + GLboolean isEnabledTexture = GL_FALSE; + GLboolean isEnabledVertexArray = GL_FALSE; + GLboolean isEnabledNormalArray = GL_FALSE; + GLboolean isEnabledColorArray = GL_FALSE; + GLboolean isEnabledTextureCoordArray = GL_FALSE; + + isEnabledCullFace = _glesImpl1.glIsEnabled(GL_CULL_FACE); + isEnabledStencil = _glesImpl1.glIsEnabled(GL_STENCIL_TEST); + isEnabledDepth = _glesImpl1.glIsEnabled(GL_DEPTH_TEST); + isEnabledScissor = _glesImpl1.glIsEnabled(GL_SCISSOR_TEST); + isEnabledBlend = _glesImpl1.glIsEnabled(GL_BLEND); + isEnabledNormalArray = _glesImpl1.glIsEnabled(GL_NORMAL_ARRAY); + isEnabledColorArray = _glesImpl1.glIsEnabled(GL_COLOR_ARRAY); + _glesImpl1.glDisable(GL_CULL_FACE); + _glesImpl1.glDisable(GL_STENCIL_TEST); + _glesImpl1.glDisable(GL_DEPTH_TEST); + _glesImpl1.glDisable(GL_SCISSOR_TEST); + _glesImpl1.glDisable(GL_BLEND); + _glesImpl1.glDisableClientState(GL_NORMAL_ARRAY); + _glesImpl1.glDisableClientState(GL_COLOR_ARRAY); + + isEnabledTexture = _glesImpl1.glIsEnabled(GL_TEXTURE_2D); + isEnabledVertexArray = _glesImpl1.glIsEnabled(GL_VERTEX_ARRAY); + isEnabledTextureCoordArray = _glesImpl1.glIsEnabled(GL_TEXTURE_COORD_ARRAY); + _glesImpl1.glEnable(GL_TEXTURE_2D); + _glesImpl1.glEnableClientState(GL_VERTEX_ARRAY); + _glesImpl1.glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + GLint previousTextureId = 0; + GLint previousMatrixMode = 0; + GLint previousArrayBuffer = 0; + GLint previousElementArrayBuffer = 0; + GLint previousViewport[4] = {0,}; + _glesImpl1.glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureId); + _glesImpl1.glGetIntegerv(GL_MATRIX_MODE, &previousMatrixMode); + _glesImpl1.glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &previousArrayBuffer); + _glesImpl1.glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &previousElementArrayBuffer); + _glesImpl1.glGetIntegerv(GL_VIEWPORT, previousViewport); + + GLfloat currentColor[4] = {0.0f, }; + GLfloat currentNormal[3] = {0.0f, }; + _glesImpl1.glGetFloatv(GL_CURRENT_COLOR, currentColor); + _glesImpl1.glGetFloatv(GL_CURRENT_NORMAL, currentNormal); + _glesImpl1.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + _glesImpl1.glNormal3f(0.0f, 0.0f, 1.0f); + + _glesImpl1.glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); + _glesImpl1.glBindTexture( GL_TEXTURE_2D, textureId); + + _glesImpl1.glMatrixMode(GL_PROJECTION); + _glesImpl1.glPushMatrix(); + _glesImpl1.glLoadIdentity(); + _glesImpl1.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f); + + _glesImpl1.glMatrixMode(GL_TEXTURE); + _glesImpl1.glPushMatrix(); + _glesImpl1.glLoadIdentity(); + + _glesImpl1.glMatrixMode(GL_MODELVIEW); + _glesImpl1.glPushMatrix(); + _glesImpl1.glLoadIdentity(); + + int x = 0; + int y = 0; + int width = 0; + int height = 0; + pFrame->GetBounds(x, y, width, height); + + GLfloat ratioX1 = 0.0f; + GLfloat ratioX2 = (GLfloat)width / fboWidth; + GLfloat ratioY1 = 0.0f; + GLfloat ratioY2 = (GLfloat)height / fboHeight; + + GLfloat texture[] = { + ratioX1, ratioY1, + ratioX2, ratioY1, + ratioX1, ratioY2, + ratioX2, ratioY2, + }; + + OrientationStatus orientationStatus = pFrame->GetOrientationStatus(); + switch(orientationStatus) + { + default: + case ORIENTATION_STATUS_NONE: + case ORIENTATION_STATUS_PORTRAIT: + _glesImpl1.glViewport(0, 0, width, height); + break; + + case ORIENTATION_STATUS_LANDSCAPE: + texture[0] = ratioX2; + texture[1] = ratioY1; + texture[2] = ratioX2; + texture[3] = ratioY2; + texture[4] = ratioX1; + texture[5] = ratioY1; + texture[6] = ratioX1; + texture[7] = ratioY2; + _glesImpl1.glViewport(0, 0, height, width); + break; + + case ORIENTATION_STATUS_PORTRAIT_REVERSE: + texture[0] = ratioX2; + texture[1] = ratioY2; + texture[2] = ratioX1; + texture[3] = ratioY2; + texture[4] = ratioX2; + texture[5] = ratioY1; + texture[6] = ratioX1; + texture[7] = ratioY1; + _glesImpl1.glViewport(0, 0, width, height); + break; + + case ORIENTATION_STATUS_LANDSCAPE_REVERSE: + texture[0] = ratioX1; + texture[1] = ratioY2; + texture[2] = ratioX1; + texture[3] = ratioY1; + texture[4] = ratioX2; + texture[5] = ratioY2; + texture[6] = ratioX2; + texture[7] = ratioY1; + _glesImpl1.glViewport(0, 0, height, width); + break; + } + + GLfloat vertex[] = { + -1.0f, -1.0f, + 1.0f, -1.0f, + -1.0f, 1.0f, + 1.0f, 1.0f, + }; + + _glesImpl1.glBindBuffer(GL_ARRAY_BUFFER, 0); + _glesImpl1.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + _glesImpl1.glVertexPointer(2, GL_FLOAT, 0, vertex); + _glesImpl1.glTexCoordPointer(2, GL_FLOAT, 0, texture); + + _glesImpl1.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + _glesImpl1.glPopMatrix(); + _glesImpl1.glMatrixMode(GL_TEXTURE); + _glesImpl1.glPopMatrix(); + _glesImpl1.glMatrixMode(GL_PROJECTION); + _glesImpl1.glPopMatrix(); + + _glesImpl1.glBindFramebufferOES(GL_FRAMEBUFFER_OES, frameBufferObject); + if (isEnabledCullFace) + { + _glesImpl1.glEnable(GL_CULL_FACE); + } + if (isEnabledStencil) + { + _glesImpl1.glEnable(GL_STENCIL_TEST); + } + if (isEnabledDepth) + { + _glesImpl1.glEnable(GL_DEPTH_TEST); + } + if (isEnabledScissor) + { + _glesImpl1.glEnable(GL_SCISSOR_TEST); + } + if (isEnabledBlend) + { + _glesImpl1.glEnable(GL_BLEND); + } + if (isEnabledNormalArray) + { + _glesImpl1.glIsEnabled(GL_NORMAL_ARRAY); + } + if (isEnabledColorArray) + { + _glesImpl1.glIsEnabled(GL_COLOR_ARRAY); + } + + if (!isEnabledTexture) + { + _glesImpl1.glDisable(GL_TEXTURE_2D); + } + if (!isEnabledVertexArray) + { + _glesImpl1.glDisableClientState(GL_VERTEX_ARRAY); + } + if (!isEnabledTextureCoordArray) + { + _glesImpl1.glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + + _glesImpl1.glBindTexture( GL_TEXTURE_2D, previousTextureId); + _glesImpl1.glMatrixMode(previousMatrixMode); + _glesImpl1.glBindBuffer(GL_ARRAY_BUFFER, previousArrayBuffer); + _glesImpl1.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, previousElementArrayBuffer); + _glesImpl1.glViewport(previousViewport[0], previousViewport[1], previousViewport[2], previousViewport[3]); + _glesImpl1.glColor4f(currentColor[0], currentColor[1], currentColor[2], currentColor[3]); + _glesImpl1.glNormal3f(currentNormal[0], currentNormal[1], currentNormal[2]); +} + +#endif //#if defined(FGRAPHICS_INTERNAL_USE_FBO) + +#ifdef __cplusplus +} +#endif + +#endif //#if !defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING) + +} // Opengl + +}} // Tizen::Graphics diff --git a/src/graphics/opengl/FGrpGles2.cpp b/src/graphics/opengl/FGrpGles2.cpp new file mode 100644 index 0000000..bddf4a9 --- /dev/null +++ b/src/graphics/opengl/FGrpGles2.cpp @@ -0,0 +1,2737 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpGles2.cpp + * @brief This is the implementation file for OpenGL ES 2.X. + * + */ + + +#define FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING +#if defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING) +#include +#include +#include +#include +#include +#include +#endif + +#include + +#include +#include + +#if defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING) +#include +#endif + +#define FGRAPHICS_INTERNAL_USE_FBO +#if defined(FGRAPHICS_INTERNAL_USE_FBO) +#include +#endif + +#include "../util/FGrp_UtilTemplate.h" +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +namespace Tizen { namespace Graphics +{ + +namespace Opengl +{ + +#if !defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING) + +#ifdef __cplusplus +extern "C" +{ +#endif + +void +_GlActiveTexture_2(GLenum texture) +{ + glActiveTexture(texture); +} + +void +_GlAttachShader_2(GLuint program, GLuint shader) +{ + glAttachShader(program, shader); +} + +void +_GlBindAttribLocation_2(GLuint program, GLuint index, const char* pName) +{ + glBindAttribLocation(program, index, pName); +} + +void +_GlBindBuffer_2(GLenum target, GLuint buffer) +{ + glBindBuffer(target, buffer); +} + +void +_GlBindFramebuffer_2(GLenum target, GLuint framebuffer) +{ + glBindFramebuffer(target, framebuffer); +} + +void +_GlBindRenderbuffer_2(GLenum target, GLuint renderbuffer) +{ + glBindRenderbuffer(target, renderbuffer); +} + +void +_GlBindTexture_2(GLenum target, GLuint texture) +{ + glBindTexture(target, texture); +} + +void +_GlBlendColor_2(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + glBlendColor(red, green, blue, alpha); +} + +void +_GlBlendEquation_2(GLenum mode) +{ + glBlendEquation(mode); +} + +void +_GlBlendEquationSeparate_2(GLenum modeRGB, GLenum modeAlpha) +{ + glBlendEquationSeparate(modeRGB, modeAlpha); +} + +void +_GlBlendFunc_2(GLenum sfactor, GLenum dfactor) +{ + glBlendFunc(sfactor, dfactor); +} + +void +_GlBlendFuncSeparate_2(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ + glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); +} + +void +_GlBufferData_2(GLenum target, GLsizeiptr size, const void* pData, GLenum usage) +{ + glBufferData(target, size, pData, usage); +} + +void +_GlBufferSubData_2(GLenum target, GLintptr offset, GLsizeiptr size, const void* pData) +{ + glBufferSubData(target, offset, size, pData); +} + +GLenum +_GlCheckFramebufferStatus_2(GLenum target) +{ + return glCheckFramebufferStatus(target); +} + +void +_GlClear_2(GLbitfield mask) +{ + glClear(mask); +} + +void +_GlClearColor_2(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + glClearColor(red, green, blue, alpha); +} + +void +_GlClearDepthf_2(GLclampf depth) +{ + glClearDepthf(depth); +} + +void +_GlClearStencil_2(GLint s) +{ + glClearStencil(s); +} + +void +_GlColorMask_2(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ + glColorMask(red, green, blue, alpha); +} + +void +_GlCompileShader_2(GLuint shader) +{ + glCompileShader(shader); +} + +void +_GlCompressedTexImage2D_2(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* pData) +{ + glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pData); +} + +void +_GlCompressedTexSubImage2D_2(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* pData) +{ + glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, pData); +} + +void +_GlCopyTexImage2D_2(GLenum target, GLint level, + GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ + glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); +} + +void +_GlCopyTexSubImage2D_2(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); +} + +GLuint +_GlCreateProgram_2(void) +{ + return glCreateProgram(); +} + +GLuint +_GlCreateShader_2(GLenum type) +{ + return glCreateShader(type); +} + +void +_GlCullFace_2(GLenum mode) +{ + glCullFace(mode); +} + +void +_GlDeleteBuffers_2(GLsizei n, const GLuint* pBuffers) +{ + glDeleteBuffers(n, pBuffers); +} + +void +_GlDeleteFramebuffers_2(GLsizei n, const GLuint* pFramebuffers) +{ + glDeleteFramebuffers(n, pFramebuffers); +} + +void +_GlDeleteProgram_2(GLuint program) +{ + glDeleteProgram(program); +} + +void +_GlDeleteRenderbuffers_2(GLsizei n, const GLuint* pRenderbuffers) +{ + glDeleteRenderbuffers(n, pRenderbuffers); +} + +void +_GlDeleteShader_2(GLuint shader) +{ + glDeleteShader(shader); +} + +void +_GlDeleteTextures_2(GLsizei n, const GLuint* pTextures) +{ + glDeleteTextures(n, pTextures); +} + +void +_GlDepthFunc_2(GLenum func) +{ + glDepthFunc(func); +} + +void +_GlDepthMask_2(GLboolean flag) +{ + glDepthMask(flag); +} + +void +_GlDepthRangef_2(GLclampf zNear, GLclampf zFar) +{ + glDepthRangef(zNear, zFar); +} + +void +_GlDetachShader_2(GLuint program, GLuint shader) +{ + glDetachShader(program, shader); +} + +void +_GlDisable_2(GLenum cap) +{ + glDisable(cap); +} + +void +_GlDisableVertexAttribArray_2(GLuint index) +{ + glDisableVertexAttribArray(index); +} + +void +_GlDrawArrays_2(GLenum mode, GLint first, GLsizei count) +{ + glDrawArrays(mode, first, count); +} + +void +_GlDrawElements_2(GLenum mode, GLsizei count, GLenum type, const void* pIndices) +{ + glDrawElements(mode, count, type, pIndices); +} + +void +_GlEnable_2(GLenum cap) +{ + glEnable(cap); +} + +void +_GlEnableVertexAttribArray_2(GLuint index) +{ + glEnableVertexAttribArray(index); +} + +void +_GlFinish_2(void) +{ + glFinish(); +} + +void +_GlFlush_2(void) +{ + glFlush(); +} + +void +_GlFramebufferRenderbuffer_2(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); +} + +void +_GlFramebufferTexture2D_2(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + glFramebufferTexture2D(target, attachment, textarget, texture, level); +} + +void +_GlFrontFace_2(GLenum mode) +{ + glFrontFace(mode); +} + +void +_GlGenBuffers_2(GLsizei n, GLuint* pBuffers) +{ + glGenBuffers(n, pBuffers); +} + +void +_GlGenerateMipmap_2(GLenum target) +{ + glGenerateMipmap(target); +} + +void +_GlGenFramebuffers_2(GLsizei n, GLuint* pFramebuffers) +{ + glGenFramebuffers(n, pFramebuffers); +} + +void +_GlGenRenderbuffers_2(GLsizei n, GLuint* pRenderbuffers) +{ + glGenRenderbuffers(n, pRenderbuffers); +} + +void +_GlGenTextures_2(GLsizei n, GLuint* pTextures) +{ + glGenTextures(n, pTextures); +} + +void +_GlGetActiveAttrib_2(GLuint program, GLuint index, GLsizei bufsize, + GLsizei* pLength, GLint* pSize, GLenum* pType, char* pName) +{ + glGetActiveAttrib(program, index, bufsize, pLength, pSize, pType, pName); +} + +void +_GlGetActiveUniform_2(GLuint program, GLuint index, GLsizei bufsize, + GLsizei* pLength, GLint* pSize, GLenum* pType, char* pName) +{ + glGetActiveUniform(program, index, bufsize, pLength, pSize, pType, pName); +} + +void +_GlGetAttachedShaders_2(GLuint program, GLsizei maxcount, GLsizei* pCount, GLuint* pShaders) +{ + glGetAttachedShaders(program, maxcount, pCount, pShaders); +} + +int +_GlGetAttribLocation_2(GLuint program, const char* pName) +{ + return glGetAttribLocation(program, pName); +} + +void +_GlGetBooleanv_2(GLenum pname, GLboolean* pParams) +{ + glGetBooleanv(pname, pParams); +} + +void +_GlGetBufferParameteriv_2(GLenum target, GLenum pname, GLint* pParams) +{ + glGetBufferParameteriv(target, pname, pParams); +} + +GLenum +_GlGetError_2(void) +{ + return glGetError(); +} + +void +_GlGetFloatv_2(GLenum pname, GLfloat* pParams) +{ + glGetFloatv(pname, pParams); +} + +void +_GlGetFramebufferAttachmentParameteriv_2(GLenum target, GLenum attachment, GLenum pname, GLint* pParams) +{ + glGetFramebufferAttachmentParameteriv(target, attachment, pname, pParams); +} + +void +_GlGetIntegerv_2(GLenum pname, GLint* pParams) +{ + glGetIntegerv(pname, pParams); +} + +void +_GlGetProgramiv_2(GLuint program, GLenum pname, GLint* pParams) +{ + glGetProgramiv(program, pname, pParams); +} + +void +_GlGetProgramInfoLog_2(GLuint program, GLsizei bufsize, GLsizei* pLength, char* pInfolog) +{ + glGetProgramInfoLog(program, bufsize, pLength, pInfolog); +} + +void +_GlGetRenderbufferParameteriv_2(GLenum target, GLenum pname, GLint* pParams) +{ + glGetRenderbufferParameteriv(target, pname, pParams); +} + +void +_GlGetShaderiv_2(GLuint shader, GLenum pname, GLint* pParams) +{ + glGetShaderiv(shader, pname, pParams); +} + +void +_GlGetShaderInfoLog_2(GLuint shader, GLsizei bufsize, GLsizei* pLength, char* pInfolog) +{ + glGetShaderInfoLog(shader, bufsize, pLength, pInfolog); +} + +void +_GlGetShaderPrecisionFormat_2(GLenum shadertype, GLenum precisiontype, GLint* pRange, GLint* pPrecision) +{ + glGetShaderPrecisionFormat(shadertype, precisiontype, pRange, pPrecision); +} + +void +_GlGetShaderSource_2(GLuint shader, GLsizei bufsize, GLsizei* pLength, char* pSource) +{ + glGetShaderSource(shader, bufsize, pLength, pSource); +} + +const GLubyte* +_GlGetString_2(GLenum name) +{ + return glGetString(name); +} + +void +_GlGetTexParameterfv_2(GLenum target, GLenum pname, GLfloat* pParams) +{ + glGetTexParameterfv(target, pname, pParams); +} + +void +_GlGetTexParameteriv_2(GLenum target, GLenum pname, GLint* pParams) +{ + glGetTexParameteriv(target, pname, pParams); +} + +void +_GlGetUniformfv_2(GLuint program, GLint location, GLfloat* pParams) +{ + glGetUniformfv(program, location, pParams); +} + +void +_GlGetUniformiv_2(GLuint program, GLint location, GLint* pParams) +{ + glGetUniformiv(program, location, pParams); +} + +int +_GlGetUniformLocation_2(GLuint program, const char* pName) +{ + return glGetUniformLocation(program, pName); +} + +void +_GlGetVertexAttribfv_2(GLuint index, GLenum pname, GLfloat* pParams) +{ + glGetVertexAttribfv(index, pname, pParams); +} + +void +_GlGetVertexAttribiv_2(GLuint index, GLenum pname, GLint* pParams) +{ + glGetVertexAttribiv(index, pname, pParams); +} + +void +_GlGetVertexAttribPointerv_2(GLuint index, GLenum pname, void** ppPointer) +{ + glGetVertexAttribPointerv(index, pname, ppPointer); +} + +void +_GlHint_2(GLenum target, GLenum mode) +{ + glHint(target, mode); +} + +GLboolean +_GlIsBuffer_2(GLuint buffer) +{ + return glIsBuffer(buffer); +} + +GLboolean +_GlIsEnabled_2(GLenum cap) +{ + return glIsEnabled(cap); +} + +GLboolean +_GlIsFramebuffer_2(GLuint framebuffer) +{ + return glIsFramebuffer(framebuffer); +} + +GLboolean +_GlIsProgram_2(GLuint program) +{ + return glIsProgram(program); +} + +GLboolean +_GlIsRenderbuffer_2(GLuint renderbuffer) +{ + return glIsRenderbuffer(renderbuffer); +} + +GLboolean +_GlIsShader_2(GLuint shader) +{ + return glIsShader(shader); +} + +GLboolean +_GlIsTexture_2(GLuint texture) +{ + return glIsTexture(texture); +} + +void +_GlLineWidth_2(GLfloat width) +{ + glLineWidth(width); +} + +void +_GlLinkProgram_2(GLuint program) +{ + glLinkProgram(program); +} + +void +_GlPixelStorei_2(GLenum pname, GLint param) +{ + glPixelStorei(pname, param); +} + +void +_GlPolygonOffset_2(GLfloat factor, GLfloat units) +{ + glPolygonOffset(factor, units); +} + +void +_GlReadPixels_2(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pPixels) +{ + glReadPixels(x, y, width, height, format, type, pPixels); +} + +void +_GlReleaseShaderCompiler_2(void) +{ + glReleaseShaderCompiler(); +} + +void +_GlRenderbufferStorage_2(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + glRenderbufferStorage(target, internalformat, width, height); +} + +void +_GlSampleCoverage_2(GLclampf value, GLboolean invert) +{ + glSampleCoverage(value, invert); +} + +void +_GlScissor_2(GLint x, GLint y, GLsizei width, GLsizei height) +{ + glScissor(x, y, width, height); +} + +void +_GlShaderBinary_2(GLint n, GLuint* pShaders, GLenum binaryformat, const void* pBinary, GLint length) +{ + glShaderBinary(n, pShaders, binaryformat, pBinary, length); +} + +void +_GlShaderSource_2(GLuint shader, GLsizei count, const char** pString, const GLint* pLength) +{ + glShaderSource(shader, count, pString, pLength); +} + +void +_GlStencilFunc_2(GLenum func, GLint ref, GLuint mask) +{ + glStencilFunc(func, ref, mask); +} + +void +_GlStencilFuncSeparate_2(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + glStencilFuncSeparate(face, func, ref, mask); +} + +void +_GlStencilMask_2(GLuint mask) +{ + glStencilMask(mask); +} + +void +_GlStencilMaskSeparate_2(GLenum face, GLuint mask) +{ + glStencilMaskSeparate(face, mask); +} + +void +_GlStencilOp_2(GLenum fail, GLenum zfail, GLenum zpass) +{ + glStencilOp(fail, zfail, zpass); +} + +void +_GlStencilOpSeparate_2(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + glStencilOpSeparate(face, fail, zfail, zpass); +} + +void +_GlTexImage2D_2(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pPixels) +{ + glTexImage2D(target, level, internalformat, width, height, border, format, type, pPixels); +} + +void +_GlTexParameterf_2(GLenum target, GLenum pname, GLfloat param) +{ + glTexParameterf(target, pname, param); +} + +void +_GlTexParameterfv_2(GLenum target, GLenum pname, const GLfloat* pParams) +{ + glTexParameterfv(target, pname, pParams); +} + +void +_GlTexParameteri_2(GLenum target, GLenum pname, GLint param) +{ + glTexParameteri(target, pname, param); +} + +void +_GlTexParameteriv_2(GLenum target, GLenum pname, const GLint* pParams) +{ + glTexParameteriv(target, pname, pParams); +} + +void +_GlTexSubImage2D_2(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pPixels) +{ + glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pPixels); +} + +void +_GlUniform1f_2(GLint location, GLfloat x) +{ + glUniform1f(location, x); +} + +void +_GlUniform1fv_2(GLint location, GLsizei count, const GLfloat* pV) +{ + glUniform1fv(location, count, pV); +} + +void +_GlUniform1i_2(GLint location, GLint x) +{ + glUniform1i(location, x); +} + +void +_GlUniform1iv_2(GLint location, GLsizei count, const GLint* pV) +{ + glUniform1iv(location, count, pV); +} + +void +_GlUniform2f_2(GLint location, GLfloat x, GLfloat y) +{ + glUniform2f(location, x, y); +} + +void +_GlUniform2fv_2(GLint location, GLsizei count, const GLfloat* pV) +{ + glUniform2fv(location, count, pV); +} + +void +_GlUniform2i_2(GLint location, GLint x, GLint y) +{ + glUniform2i(location, x, y); +} + +void +_GlUniform2iv_2(GLint location, GLsizei count, const GLint* pV) +{ + glUniform2iv(location, count, pV); +} + +void +_GlUniform3f_2(GLint location, GLfloat x, GLfloat y, GLfloat z) +{ + glUniform3f(location, x, y, z); +} + +void +_GlUniform3fv_2(GLint location, GLsizei count, const GLfloat* pV) +{ + glUniform3fv(location, count, pV); +} + +void +_GlUniform3i_2(GLint location, GLint x, GLint y, GLint z) +{ + glUniform3i(location, x, y, z); +} + +void +_GlUniform3iv_2(GLint location, GLsizei count, const GLint* pV) +{ + glUniform3iv(location, count, pV); +} + +void +_GlUniform4f_2(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + glUniform4f(location, x, y, z, w); +} + +void +_GlUniform4fv_2(GLint location, GLsizei count, const GLfloat* pV) +{ + glUniform4fv(location, count, pV); +} + +void +_GlUniform4i_2(GLint location, GLint x, GLint y, GLint z, GLint w) +{ + glUniform4i(location, x, y, z, w); +} + +void +_GlUniform4iv_2(GLint location, GLsizei count, const GLint* pV) +{ + glUniform4iv(location, count, pV); +} + +void +_GlUniformMatrix2fv_2(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue) +{ + glUniformMatrix2fv(location, count, transpose, pValue); +} + +void +_GlUniformMatrix3fv_2(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue) +{ + glUniformMatrix3fv(location, count, transpose, pValue); +} + +void +_GlUniformMatrix4fv_2(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue) +{ + glUniformMatrix4fv(location, count, transpose, pValue); +} + +void +_GlUseProgram_2(GLuint program) +{ + glUseProgram(program); +} + +void +_GlValidateProgram_2(GLuint program) +{ + glValidateProgram(program); +} + +void +_GlVertexAttrib1f_2(GLuint indx, GLfloat x) +{ + glVertexAttrib1f(indx, x); +} + +void +_GlVertexAttrib1fv_2(GLuint indx, const GLfloat* pValues) +{ + glVertexAttrib1fv(indx, pValues); +} + +void +_GlVertexAttrib2f_2(GLuint indx, GLfloat x, GLfloat y) +{ + glVertexAttrib2f(indx, x, y); +} + +void +_GlVertexAttrib2fv_2(GLuint indx, const GLfloat* pValues) +{ + glVertexAttrib2fv(indx, pValues); +} + +void +_GlVertexAttrib3f_2(GLuint indx, GLfloat x, GLfloat y, GLfloat z) +{ + glVertexAttrib3f(indx, x, y, z); +} + +void +_GlVertexAttrib3fv_2(GLuint indx, const GLfloat* pValues) +{ + glVertexAttrib3fv(indx, pValues); +} + +void +_GlVertexAttrib4f_2(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + glVertexAttrib4f(indx, x, y, z, w); +} + +void +_GlVertexAttrib4fv_2(GLuint indx, const GLfloat* pValues) +{ + glVertexAttrib4fv(indx, pValues); +} + +void +_GlVertexAttribPointer_2(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pPtr) +{ + glVertexAttribPointer(indx, size, type, normalized, stride, pPtr); +} + +void +_GlViewport_2(GLint x, GLint y, GLsizei width, GLsizei height) +{ + glViewport(x, y, width, height); +} + +#ifdef __cplusplus +} +#endif + +#else + +#define _GLES_CHECK_INTERFACE_VOID_2 if (!_GlesInterfaceInitialize_2()) \ + { \ + return; \ + } +#define _GLES_CHECK_INTERFACE_GLBOOLEAN_2 if (!_GlesInterfaceInitialize_2()) \ + { \ + return GL_FALSE; \ + } +#define _GLES_CHECK_INTERFACE_GLENUM_2 if (!_GlesInterfaceInitialize_2()) \ + { \ + return 0; \ + } +#define _GLES_CHECK_INTERFACE_CONSTGLUBYTEP_2 if (!_GlesInterfaceInitialize_2()) \ + { \ + return (const GLubyte*) 0; \ + } +#define _GLES_CHECK_INTERFACE_GLUINT_2 if (!_GlesInterfaceInitialize_2()) \ + { \ + return 0; \ + } +#define _GLES_CHECK_INTERFACE_INT_2 if (!_GlesInterfaceInitialize_2()) \ + { \ + return -1; \ + } + +namespace // unnamed +{ + +struct _GlesInterface2 +{ + void (* glActiveTexture)(GLenum texture); + void (* glAttachShader)(GLuint program, GLuint shader); + void (* glBindAttribLocation)(GLuint program, GLuint index, const char* pName); + void (* glBindBuffer)(GLenum target, GLuint buffer); + void (* glBindFramebuffer)(GLenum target, GLuint framebuffer); + void (* glBindRenderbuffer)(GLenum target, GLuint renderbuffer); + void (* glBindTexture)(GLenum target, GLuint texture); + void (* glBlendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + void (* glBlendEquation)(GLenum mode); + void (* glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha); + void (* glBlendFunc)(GLenum sfactor, GLenum dfactor); + void (* glBlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + void (* glBufferData)(GLenum target, GLsizeiptr size, const void* pData, GLenum usage); + void (* glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const void* pData); + GLenum (* glCheckFramebufferStatus)(GLenum target); + void (* glClear)(GLbitfield mask); + void (* glClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + void (* glClearDepthf)(GLclampf depth); + void (* glClearStencil)(GLint s); + void (* glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + void (* glCompileShader)(GLuint shader); + void (* glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* pData); + void (* glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* pData); + void (* glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, + GLsizei width, GLsizei height, GLint border); + void (* glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, + GLsizei width, GLsizei height); + GLuint (* glCreateProgram)(void); + GLuint (* glCreateShader)(GLenum type); + void (* glCullFace)(GLenum mode); + void (* glDeleteBuffers)(GLsizei n, const GLuint* pBuffers); + void (* glDeleteFramebuffers)(GLsizei n, const GLuint* pFramebuffers); + void (* glDeleteProgram)(GLuint program); + void (* glDeleteRenderbuffers)(GLsizei n, const GLuint* pRenderbuffers); + void (* glDeleteShader)(GLuint shader); + void (* glDeleteTextures)(GLsizei n, const GLuint* pTextures); + void (* glDepthFunc)(GLenum func); + void (* glDepthMask)(GLboolean flag); + void (* glDepthRangef)(GLclampf zNear, GLclampf zFar); + void (* glDetachShader)(GLuint program, GLuint shader); + void (* glDisable)(GLenum cap); + void (* glDisableVertexAttribArray)(GLuint index); + void (* glDrawArrays)(GLenum mode, GLint first, GLsizei count); + void (* glDrawElements)(GLenum mode, GLsizei count, GLenum type, const void* pIndices); + void (* glEnable)(GLenum cap); + void (* glEnableVertexAttribArray)(GLuint index); + void (* glFinish)(void); + void (* glFlush)(void); + void (* glFramebufferRenderbuffer)(GLenum target, GLenum attachment, + GLenum renderbuffertarget, GLuint renderbuffer); + void (* glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + void (* glFrontFace)(GLenum mode); + void (* glGenBuffers)(GLsizei n, GLuint* pBuffers); + void (* glGenerateMipmap)(GLenum target); + void (* glGenFramebuffers)(GLsizei n, GLuint* pFramebuffers); + void (* glGenRenderbuffers)(GLsizei n, GLuint* pRenderbuffers); + void (* glGenTextures)(GLsizei n, GLuint* pTextures); + void (* glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, + GLsizei* pLength, GLint* pSize, GLenum* pType, char* pName); + void (* glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* pLength, GLint* pSize, + GLenum* pType, char* pName); + void (* glGetAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* pCount, GLuint* pShaders); + int (* glGetAttribLocation)(GLuint program, const char* pName); + void (* glGetBooleanv)(GLenum pname, GLboolean* pParams); + void (* glGetBufferParameteriv)(GLenum target, GLenum pname, GLint* pParams); + GLenum (* glGetError)(void); + void (* glGetFloatv)(GLenum pname, GLfloat* pParams); + void (* glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint* pParams); + void (* glGetIntegerv)(GLenum pname, GLint* pParams); + void (* glGetProgramiv)(GLuint program, GLenum pname, GLint* pParams); + void (* glGetProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* pLength, char* pInfolog); + void (* glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* pParams); + void (* glGetShaderiv)(GLuint shader, GLenum pname, GLint* pParams); + void (* glGetShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* pLength, char* pInfolog); + void (* glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* pRange, GLint* pPrecision); + void (* glGetShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* pLength, char* pSource); + const GLubyte* (*glGetString)(GLenum name); + void (* glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat* pParams); + void (* glGetTexParameteriv)(GLenum target, GLenum pname, GLint* pParams); + void (* glGetUniformfv)(GLuint program, GLint location, GLfloat* pParams); + void (* glGetUniformiv)(GLuint program, GLint location, GLint* pParams); + int (* glGetUniformLocation)(GLuint program, const char* pName); + void (* glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* pParams); + void (* glGetVertexAttribiv)(GLuint index, GLenum pname, GLint* pParams); + void (* glGetVertexAttribPointerv)(GLuint index, GLenum pname, void** ppPointer); + void (* glHint)(GLenum target, GLenum mode); + GLboolean (* glIsBuffer)(GLuint buffer); + GLboolean (* glIsEnabled)(GLenum cap); + GLboolean (* glIsFramebuffer)(GLuint framebuffer); + GLboolean (* glIsProgram)(GLuint program); + GLboolean (* glIsRenderbuffer)(GLuint renderbuffer); + GLboolean (* glIsShader)(GLuint shader); + GLboolean (* glIsTexture)(GLuint texture); + void (* glLineWidth)(GLfloat width); + void (* glLinkProgram)(GLuint program); + void (* glPixelStorei)(GLenum pname, GLint param); + void (* glPolygonOffset)(GLfloat factor, GLfloat units); + void (* glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pPixels); + void (* glReleaseShaderCompiler)(void); + void (* glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + void (* glSampleCoverage)(GLclampf value, GLboolean invert); + void (* glScissor)(GLint x, GLint y, GLsizei width, GLsizei height); + void (* glShaderBinary)(GLint n, GLuint* pShaders, GLenum binaryformat, const void* pBinary, GLint length); + void (* glShaderSource)(GLuint shader, GLsizei count, const char** ppString, const GLint* pLength); + void (* glStencilFunc)(GLenum func, GLint ref, GLuint mask); + void (* glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask); + void (* glStencilMask)(GLuint mask); + void (* glStencilMaskSeparate)(GLenum face, GLuint mask); + void (* glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass); + void (* glStencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); + void (* glTexImage2D)(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pPixels); + void (* glTexParameterf)(GLenum target, GLenum pname, GLfloat param); + void (* glTexParameterfv)(GLenum target, GLenum pname, const GLfloat* pParams); + void (* glTexParameteri)(GLenum target, GLenum pname, GLint param); + void (* glTexParameteriv)(GLenum target, GLenum pname, const GLint* pParams); + void (* glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pPixels); + void (* glUniform1f)(GLint location, GLfloat x); + void (* glUniform1fv)(GLint location, GLsizei count, const GLfloat* pV); + void (* glUniform1i)(GLint location, GLint x); + void (* glUniform1iv)(GLint location, GLsizei count, const GLint* pV); + void (* glUniform2f)(GLint location, GLfloat x, GLfloat y); + void (* glUniform2fv)(GLint location, GLsizei count, const GLfloat* pV); + void (* glUniform2i)(GLint location, GLint x, GLint y); + void (* glUniform2iv)(GLint location, GLsizei count, const GLint* pV); + void (* glUniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z); + void (* glUniform3fv)(GLint location, GLsizei count, const GLfloat* pV); + void (* glUniform3i)(GLint location, GLint x, GLint y, GLint z); + void (* glUniform3iv)(GLint location, GLsizei count, const GLint* pV); + void (* glUniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + void (* glUniform4fv)(GLint location, GLsizei count, const GLfloat* pV); + void (* glUniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w); + void (* glUniform4iv)(GLint location, GLsizei count, const GLint* pV); + void (* glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue); + void (* glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue); + void (* glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue); + void (* glUseProgram)(GLuint program); + void (* glValidateProgram)(GLuint program); + void (* glVertexAttrib1f)(GLuint indx, GLfloat x); + void (* glVertexAttrib1fv)(GLuint indx, const GLfloat* pValues); + void (* glVertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y); + void (* glVertexAttrib2fv)(GLuint indx, const GLfloat* pValues); + void (* glVertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z); + void (* glVertexAttrib3fv)(GLuint indx, const GLfloat* pValues); + void (* glVertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + void (* glVertexAttrib4fv)(GLuint indx, const GLfloat* pValues); + void (* glVertexAttribPointer)(GLuint indx, GLint size, + GLenum type, GLboolean normalized, GLsizei stride, const void* pPtr); + void (* glViewport)(GLint x, GLint y, GLsizei width, GLsizei height); +}; + +void* _pGlesLib2 = NULL; +_GlesInterface2 _glesImpl2 = {0, }; + +const int _MAX_GLES_FUNCTION_2 = 142; +const char _glesStrings2[_MAX_GLES_FUNCTION_2][64] = +{ + "glActiveTexture", + "glAttachShader", + "glBindAttribLocation", + "glBindBuffer", + "glBindFramebuffer", + "glBindRenderbuffer", + "glBindTexture", + "glBlendColor", + "glBlendEquation", + "glBlendEquationSeparate", + "glBlendFunc", //10 + "glBlendFuncSeparate", + "glBufferData", + "glBufferSubData", + "glCheckFramebufferStatus", + "glClear", + "glClearColor", + "glClearDepthf", + "glClearStencil", + "glColorMask", + "glCompileShader", //20 + "glCompressedTexImage2D", + "glCompressedTexSubImage2D", + "glCopyTexImage2D", + "glCopyTexSubImage2D", + "glCreateProgram", + "glCreateShader", + "glCullFace", + "glDeleteBuffers", + "glDeleteFramebuffers", + "glDeleteProgram", //30 + "glDeleteRenderbuffers", + "glDeleteShader", + "glDeleteTextures", + "glDepthFunc", + "glDepthMask", + "glDepthRangef", + "glDetachShader", + "glDisable", + "glDisableVertexAttribArray", + "glDrawArrays", //40 + "glDrawElements", + "glEnable", + "glEnableVertexAttribArray", + "glFinish", + "glFlush", + "glFramebufferRenderbuffer", + "glFramebufferTexture2D", + "glFrontFace", + "glGenBuffers", + "glGenerateMipmap", //50 + "glGenFramebuffers", + "glGenRenderbuffers", + "glGenTextures", + "glGetActiveAttrib", + "glGetActiveUniform", + "glGetAttachedShaders", + "glGetAttribLocation", + "glGetBooleanv", + "glGetBufferParameteriv", + "glGetError", //60 + "glGetFloatv", + "glGetFramebufferAttachmentParameteriv", + "glGetIntegerv", + "glGetProgramiv", + "glGetProgramInfoLog", + "glGetRenderbufferParameteriv", + "glGetShaderiv", + "glGetShaderInfoLog", + "glGetShaderPrecisionFormat", + "glGetShaderSource", //70 + "glGetString", + "glGetTexParameterfv", + "glGetTexParameteriv", + "glGetUniformfv", + "glGetUniformiv", + "glGetUniformLocation", + "glGetVertexAttribfv", + "glGetVertexAttribiv", + "glGetVertexAttribPointerv", + "glHint", //80 + "glIsBuffer", + "glIsEnabled", + "glIsFramebuffer", + "glIsProgram", + "glIsRenderbuffer", + "glIsShader", + "glIsTexture", + "glLineWidth", + "glLinkProgram", + "glPixelStorei", //90 + "glPolygonOffset", + "glReadPixels", + "glReleaseShaderCompiler", + "glRenderbufferStorage", + "glSampleCoverage", + "glScissor", + "glShaderBinary", + "glShaderSource", + "glStencilFunc", + "glStencilFuncSeparate", //100 + "glStencilMask", + "glStencilMaskSeparate", + "glStencilOp", + "glStencilOpSeparate", + "glTexImage2D", + "glTexParameterf", + "glTexParameterfv", + "glTexParameteri", + "glTexParameteriv", + "glTexSubImage2D", //110 + "glUniform1f", + "glUniform1fv", + "glUniform1i", + "glUniform1iv", + "glUniform2f", + "glUniform2fv", + "glUniform2i", + "glUniform2iv", + "glUniform3f", + "glUniform3fv", //120 + "glUniform3i", + "glUniform3iv", + "glUniform4f", + "glUniform4fv", + "glUniform4i", + "glUniform4iv", + "glUniformMatrix2fv", + "glUniformMatrix3fv", + "glUniformMatrix4fv", + "glUseProgram", //130 + "glValidateProgram", + "glVertexAttrib1f", + "glVertexAttrib1fv", + "glVertexAttrib2f", + "glVertexAttrib2fv", + "glVertexAttrib3f", + "glVertexAttrib3fv", + "glVertexAttrib4f", + "glVertexAttrib4fv", + "glVertexAttribPointer", //140 + "glViewport" +}; + +bool +_GlesInterfaceInitialize_2(void) +{ + int count = 0; + + if (_pGlesLib2 == NULL) + { + ptrdiff_t** ppPtr = (ptrdiff_t**) (&_glesImpl2); + + _pGlesLib2 = dlopen("libGLESv2.so", RTLD_LAZY | RTLD_GLOBAL); + if (_pGlesLib2 == NULL) + { + SysLog(NID_GRP, "gles2 dlopen failed! %s", dlerror()); + return false; + } + + for (count = 0; count < _MAX_GLES_FUNCTION_2; count++) + { + *ppPtr = (ptrdiff_t*) (dlsym(_pGlesLib2, _glesStrings2[count])); + + if (*ppPtr == NULL) + { + SysLog(NID_GRP, "dlsym failed! %s name : %s", dlerror(), _glesStrings2[count]); + } + ppPtr++; + } + } + + return true; +} + +} + +#ifdef __cplusplus +extern "C" +{ +#endif + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) +GLuint _GlesGetCurrentFbo(void); +bool _GlesFboEnableStencil(GLuint& frameBufferObject, GLuint& renderBuffer); +#endif + +_OSP_LOCAL_ void +_GlesInterfaceTerminate_2(void) +{ + if (_pGlesLib2 != NULL) + { + dlclose(_pGlesLib2); + _pGlesLib2 = NULL; + } +} + +void +_GlActiveTexture_2(GLenum texture) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glActiveTexture(texture); +} + +void +_GlAttachShader_2(GLuint program, GLuint shader) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glAttachShader(program, shader); +} + +void +_GlBindAttribLocation_2(GLuint program, GLuint index, const char* pNname) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBindAttribLocation(program, index, pNname); +} + +void +_GlBindBuffer_2(GLenum target, GLuint buffer) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBindBuffer(target, buffer); +} + +void +_GlBindFramebuffer_2(GLenum target, GLuint framebuffer) +{ + _GLES_CHECK_INTERFACE_VOID_2 + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + if (framebuffer == 0) + { + framebuffer = _GlesGetCurrentFbo(); + } +#endif + + _glesImpl2.glBindFramebuffer(target, framebuffer); +} + +void +_GlBindRenderbuffer_2(GLenum target, GLuint renderbuffer) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBindRenderbuffer(target, renderbuffer); +} + +void +_GlBindTexture_2(GLenum target, GLuint texture) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBindTexture(target, texture); +} + +void +_GlBlendColor_2(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBlendColor(red, green, blue, alpha); +} + +void +_GlBlendEquation_2(GLenum mode) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBlendEquation(mode); +} + +void +_GlBlendEquationSeparate_2(GLenum modeRGB, GLenum modeAlpha) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBlendEquationSeparate(modeRGB, modeAlpha); +} + +void +_GlBlendFunc_2(GLenum sfactor, GLenum dfactor) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBlendFunc(sfactor, dfactor); +} + +void +_GlBlendFuncSeparate_2(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); +} + +void +_GlBufferData_2(GLenum target, GLsizeiptr size, const void* pData, GLenum usage) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBufferData(target, size, pData, usage); +} + +void +_GlBufferSubData_2(GLenum target, GLintptr offset, GLsizeiptr size, const void* pData) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBufferSubData(target, offset, size, pData); +} + +GLenum +_GlCheckFramebufferStatus_2(GLenum target) +{ + _GLES_CHECK_INTERFACE_GLENUM_2 + return _glesImpl2.glCheckFramebufferStatus(target); +} + +void +_GlClear_2(GLbitfield mask) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glClear(mask); +} + +void +_GlClearColor_2(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glClearColor(red, green, blue, alpha); +} + +void +_GlClearDepthf_2(GLclampf depth) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glClearDepthf(depth); +} + +void +_GlClearStencil_2(GLint s) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glClearStencil(s); +} + +void +_GlColorMask_2(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glColorMask(red, green, blue, alpha); +} + +void +_GlCompileShader_2(GLuint shader) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glCompileShader(shader); +} + +void +_GlCompressedTexImage2D_2(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* pData) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pData); +} + +void +_GlCompressedTexSubImage2D_2(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* pData) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, pData); +} + +void +_GlCopyTexImage2D_2(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, + GLsizei width, GLsizei height, GLint border) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); +} + +void +_GlCopyTexSubImage2D_2(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, + GLint y, GLsizei width, GLsizei height) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); +} + +GLuint +_GlCreateProgram_2(void) +{ + _GLES_CHECK_INTERFACE_GLUINT_2 + return _glesImpl2.glCreateProgram(); +} + +GLuint +_GlCreateShader_2(GLenum type) +{ + _GLES_CHECK_INTERFACE_GLUINT_2 + return _glesImpl2.glCreateShader(type); +} + +void +_GlCullFace_2(GLenum mode) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glCullFace(mode); +} + +void +_GlDeleteBuffers_2(GLsizei n, const GLuint* pBuffers) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDeleteBuffers(n, pBuffers); +} + +void +_GlDeleteFramebuffers_2(GLsizei n, const GLuint* pFramebuffers) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDeleteFramebuffers(n, pFramebuffers); +} + +void +_GlDeleteProgram_2(GLuint program) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDeleteProgram(program); +} + +void +_GlDeleteRenderbuffers_2(GLsizei n, const GLuint* pRenderbuffers) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDeleteRenderbuffers(n, pRenderbuffers); +} + +void +_GlDeleteShader_2(GLuint shader) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDeleteShader(shader); +} + +void +_GlDeleteTextures_2(GLsizei n, const GLuint* pTextures) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDeleteTextures(n, pTextures); +} + +void +_GlDepthFunc_2(GLenum func) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDepthFunc(func); +} + +void +_GlDepthMask_2(GLboolean flag) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDepthMask(flag); +} + +void +_GlDepthRangef_2(GLclampf zNear, GLclampf zFar) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDepthRangef(zNear, zFar); +} + +void +_GlDetachShader_2(GLuint program, GLuint shader) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDetachShader(program, shader); +} + +void +_GlDisable_2(GLenum cap) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDisable(cap); +} + +void +_GlDisableVertexAttribArray_2(GLuint index) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDisableVertexAttribArray(index); +} + +void +_GlDrawArrays_2(GLenum mode, GLint first, GLsizei count) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDrawArrays(mode, first, count); +} + +void +_GlDrawElements_2(GLenum mode, GLsizei count, GLenum type, const void* pIndices) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glDrawElements(mode, count, type, pIndices); +} + +void +_GlEnable_2(GLenum cap) +{ + _GLES_CHECK_INTERFACE_VOID_2 +#if defined(FGRAPHICS_INTERNAL_USE_FBO) + if (cap == GL_STENCIL_TEST) + { + GLuint frameBufferObject = 0; + GLuint stencilRenderBuffer = 0; + + bool ret = _GlesFboEnableStencil(frameBufferObject, stencilRenderBuffer); + + if (ret) + { + _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject); + _glesImpl2.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencilRenderBuffer); + } + } +#endif + _glesImpl2.glEnable(cap); +} + +void +_GlEnableVertexAttribArray_2(GLuint index) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glEnableVertexAttribArray(index); +} + +void +_GlFinish_2(void) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glFinish(); +} + +void +_GlFlush_2(void) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glFlush(); +} + +void +_GlFramebufferRenderbuffer_2(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); +} + +void +_GlFramebufferTexture2D_2(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glFramebufferTexture2D(target, attachment, textarget, texture, level); +} + +void +_GlFrontFace_2(GLenum mode) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glFrontFace(mode); +} + +void +_GlGenBuffers_2(GLsizei n, GLuint* pBuffers) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGenBuffers(n, pBuffers); +} + +void +_GlGenerateMipmap_2(GLenum target) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGenerateMipmap(target); +} + +void +_GlGenFramebuffers_2(GLsizei n, GLuint* pFramebuffers) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGenFramebuffers(n, pFramebuffers); +} + +void +_GlGenRenderbuffers_2(GLsizei n, GLuint* pRenderbuffers) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGenRenderbuffers(n, pRenderbuffers); +} + +void +_GlGenTextures_2(GLsizei n, GLuint* textures) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGenTextures(n, textures); +} + +void +_GlGetActiveAttrib_2(GLuint program, GLuint index, GLsizei bufsize, + GLsizei* pLength, GLint* pSize, GLenum* pType, char* pName) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetActiveAttrib(program, index, bufsize, pLength, pSize, pType, pName); +} + +void +_GlGetActiveUniform_2(GLuint program, GLuint index, GLsizei bufsize, + GLsizei* pLength, GLint* pSize, GLenum* pType, char* pName) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetActiveUniform(program, index, bufsize, pLength, pSize, pType, pName); +} + +void +_GlGetAttachedShaders_2(GLuint program, GLsizei maxcount, GLsizei* pCount, GLuint* pShaders) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetAttachedShaders(program, maxcount, pCount, pShaders); +} + +int +_GlGetAttribLocation_2(GLuint program, const char* pName) +{ + _GLES_CHECK_INTERFACE_INT_2 + return _glesImpl2.glGetAttribLocation(program, pName); +} + +void +_GlGetBooleanv_2(GLenum pname, GLboolean* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetBooleanv(pname, pParams); +} + +void +_GlGetBufferParameteriv_2(GLenum target, GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetBufferParameteriv(target, pname, pParams); +} + +GLenum +_GlGetError_2(void) +{ + _GLES_CHECK_INTERFACE_GLENUM_2 + return _glesImpl2.glGetError(); +} + +void +_GlGetFloatv_2(GLenum pname, GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetFloatv(pname, pParams); +} + +void +_GlGetFramebufferAttachmentParameteriv_2(GLenum target, GLenum attachment, GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetFramebufferAttachmentParameteriv(target, attachment, pname, pParams); +} + +void +_GlGetIntegerv_2(GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetIntegerv(pname, pParams); +} + +void +_GlGetProgramiv_2(GLuint program, GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetProgramiv(program, pname, pParams); +} + +void +_GlGetProgramInfoLog_2(GLuint program, GLsizei bufsize, GLsizei* pLength, char* pInfolog) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetProgramInfoLog(program, bufsize, pLength, pInfolog); +} + +void +_GlGetRenderbufferParameteriv_2(GLenum target, GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetRenderbufferParameteriv(target, pname, pParams); +} + +void +_GlGetShaderiv_2(GLuint shader, GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetShaderiv(shader, pname, pParams); +} + +void +_GlGetShaderInfoLog_2(GLuint shader, GLsizei bufsize, GLsizei* pLength, char* pInfolog) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetShaderInfoLog(shader, bufsize, pLength, pInfolog); +} + +void +_GlGetShaderPrecisionFormat_2(GLenum shadertype, GLenum precisiontype, GLint* pRange, GLint* pPrecision) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetShaderPrecisionFormat(shadertype, precisiontype, pRange, pPrecision); +} + +void +_GlGetShaderSource_2(GLuint shader, GLsizei bufsize, GLsizei* pLength, char* pSource) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetShaderSource(shader, bufsize, pLength, pSource); +} + +const GLubyte* +_GlGetString_2(GLenum name) +{ + _GLES_CHECK_INTERFACE_CONSTGLUBYTEP_2 + return _glesImpl2.glGetString(name); +} + +void +_GlGetTexParameterfv_2(GLenum target, GLenum pname, GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetTexParameterfv(target, pname, pParams); +} + +void +_GlGetTexParameteriv_2(GLenum target, GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetTexParameteriv(target, pname, pParams); +} + +void +_GlGetUniformfv_2(GLuint program, GLint location, GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetUniformfv(program, location, pParams); +} + +void +_GlGetUniformiv_2(GLuint program, GLint location, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetUniformiv(program, location, pParams); +} + +int +_GlGetUniformLocation_2(GLuint program, const char* pName) +{ + _GLES_CHECK_INTERFACE_INT_2 + return _glesImpl2.glGetUniformLocation(program, pName); +} + +void +_GlGetVertexAttribfv_2(GLuint index, GLenum pname, GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetVertexAttribfv(index, pname, pParams); +} + +void +_GlGetVertexAttribiv_2(GLuint index, GLenum pname, GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetVertexAttribiv(index, pname, pParams); +} + +void +_GlGetVertexAttribPointerv_2(GLuint index, GLenum pname, void** ppPointer) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glGetVertexAttribPointerv(index, pname, ppPointer); +} + +void +_GlHint_2(GLenum target, GLenum mode) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glHint(target, mode); +} + +GLboolean +_GlIsBuffer_2(GLuint buffer) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_2 + return _glesImpl2.glIsBuffer(buffer); +} + +GLboolean +_GlIsEnabled_2(GLenum cap) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_2 + return _glesImpl2.glIsEnabled(cap); +} + +GLboolean +_GlIsFramebuffer_2(GLuint framebuffer) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_2 + return _glesImpl2.glIsFramebuffer(framebuffer); +} + +GLboolean +_GlIsProgram_2(GLuint program) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_2 + return _glesImpl2.glIsProgram(program); +} + +GLboolean +_GlIsRenderbuffer_2(GLuint renderbuffer) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_2 + return _glesImpl2.glIsRenderbuffer(renderbuffer); +} + +GLboolean +_GlIsShader_2(GLuint shader) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_2 + return _glesImpl2.glIsShader(shader); +} + +GLboolean +_GlIsTexture_2(GLuint texture) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_2 + return _glesImpl2.glIsTexture(texture); +} + +void +_GlLineWidth_2(GLfloat width) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glLineWidth(width); +} + +void +_GlLinkProgram_2(GLuint program) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glLinkProgram(program); +} + +void +_GlPixelStorei_2(GLenum pname, GLint param) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glPixelStorei(pname, param); +} + +void +_GlPolygonOffset_2(GLfloat factor, GLfloat units) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glPolygonOffset(factor, units); +} + +void +_GlReadPixels_2(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pPixels) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glReadPixels(x, y, width, height, format, type, pPixels); +} + +void +_GlReleaseShaderCompiler_2(void) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glReleaseShaderCompiler(); +} + +void +_GlRenderbufferStorage_2(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glRenderbufferStorage(target, internalformat, width, height); +} + +void +_GlSampleCoverage_2(GLclampf value, GLboolean invert) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glSampleCoverage(value, invert); +} + +void +_GlScissor_2(GLint x, GLint y, GLsizei width, GLsizei height) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glScissor(x, y, width, height); +} + +void +_GlShaderBinary_2(GLint n, GLuint* shaders, GLenum binaryformat, const void* pBinary, GLint length) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glShaderBinary(n, shaders, binaryformat, pBinary, length); +} + +void +_GlShaderSource_2(GLuint shader, GLsizei count, const char** ppString, const GLint* pLength) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glShaderSource(shader, count, ppString, pLength); +} + +void +_GlStencilFunc_2(GLenum func, GLint ref, GLuint mask) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glStencilFunc(func, ref, mask); +} + +void +_GlStencilFuncSeparate_2(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glStencilFuncSeparate(face, func, ref, mask); +} + +void +_GlStencilMask_2(GLuint mask) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glStencilMask(mask); +} + +void +_GlStencilMaskSeparate_2(GLenum face, GLuint mask) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glStencilMaskSeparate(face, mask); +} + +void +_GlStencilOp_2(GLenum fail, GLenum zfail, GLenum zpass) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glStencilOp(fail, zfail, zpass); +} + +void +_GlStencilOpSeparate_2(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glStencilOpSeparate(face, fail, zfail, zpass); +} + +void +_GlTexImage2D_2(GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pPixels) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glTexImage2D(target, level, internalformat, width, height, border, format, type, pPixels); +} + +void +_GlTexParameterf_2(GLenum target, GLenum pname, GLfloat param) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glTexParameterf(target, pname, param); +} + +void +_GlTexParameterfv_2(GLenum target, GLenum pname, const GLfloat* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glTexParameterfv(target, pname, pParams); +} + +void +_GlTexParameteri_2(GLenum target, GLenum pname, GLint param) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glTexParameteri(target, pname, param); +} + +void +_GlTexParameteriv_2(GLenum target, GLenum pname, const GLint* pParams) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glTexParameteriv(target, pname, pParams); +} + +void +_GlTexSubImage2D_2(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pPixels) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pPixels); +} + +void +_GlUniform1f_2(GLint location, GLfloat x) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform1f(location, x); +} + +void +_GlUniform1fv_2(GLint location, GLsizei count, const GLfloat* pV) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform1fv(location, count, pV); +} + +void +_GlUniform1i_2(GLint location, GLint x) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform1i(location, x); +} + +void +_GlUniform1iv_2(GLint location, GLsizei count, const GLint* pV) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform1iv(location, count, pV); +} + +void +_GlUniform2f_2(GLint location, GLfloat x, GLfloat y) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform2f(location, x, y); +} + +void +_GlUniform2fv_2(GLint location, GLsizei count, const GLfloat* pV) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform2fv(location, count, pV); +} + +void +_GlUniform2i_2(GLint location, GLint x, GLint y) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform2i(location, x, y); +} + +void +_GlUniform2iv_2(GLint location, GLsizei count, const GLint* pV) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform2iv(location, count, pV); +} + +void +_GlUniform3f_2(GLint location, GLfloat x, GLfloat y, GLfloat z) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform3f(location, x, y, z); +} + +void +_GlUniform3fv_2(GLint location, GLsizei count, const GLfloat* pV) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform3fv(location, count, pV); +} + +void +_GlUniform3i_2(GLint location, GLint x, GLint y, GLint z) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform3i(location, x, y, z); +} + +void +_GlUniform3iv_2(GLint location, GLsizei count, const GLint* pV) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform3iv(location, count, pV); +} + +void +_GlUniform4f_2(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform4f(location, x, y, z, w); +} + +void +_GlUniform4fv_2(GLint location, GLsizei count, const GLfloat* pV) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform4fv(location, count, pV); +} + +void +_GlUniform4i_2(GLint location, GLint x, GLint y, GLint z, GLint w) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform4i(location, x, y, z, w); +} + +void +_GlUniform4iv_2(GLint location, GLsizei count, const GLint* v) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniform4iv(location, count, v); +} + +void +_GlUniformMatrix2fv_2(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniformMatrix2fv(location, count, transpose, pValue); +} + +void +_GlUniformMatrix3fv_2(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniformMatrix3fv(location, count, transpose, pValue); +} + +void +_GlUniformMatrix4fv_2(GLint location, GLsizei count, GLboolean transpose, const GLfloat* pValue) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUniformMatrix4fv(location, count, transpose, pValue); +} + +void +_GlUseProgram_2(GLuint program) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glUseProgram(program); +} + +void +_GlValidateProgram_2(GLuint program) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glValidateProgram(program); +} + +void +_GlVertexAttrib1f_2(GLuint indx, GLfloat x) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glVertexAttrib1f(indx, x); +} + +void +_GlVertexAttrib1fv_2(GLuint indx, const GLfloat* pValues) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glVertexAttrib1fv(indx, pValues); +} + +void +_GlVertexAttrib2f_2(GLuint indx, GLfloat x, GLfloat y) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glVertexAttrib2f(indx, x, y); +} + +void +_GlVertexAttrib2fv_2(GLuint indx, const GLfloat* pValues) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glVertexAttrib2fv(indx, pValues); +} + +void +_GlVertexAttrib3f_2(GLuint indx, GLfloat x, GLfloat y, GLfloat z) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glVertexAttrib3f(indx, x, y, z); +} + +void +_GlVertexAttrib3fv_2(GLuint indx, const GLfloat* pValues) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glVertexAttrib3fv(indx, pValues); +} + +void +_GlVertexAttrib4f_2(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glVertexAttrib4f(indx, x, y, z, w); +} + +void +_GlVertexAttrib4fv_2(GLuint indx, const GLfloat* pValues) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glVertexAttrib4fv(indx, pValues); +} + +void +_GlVertexAttribPointer_2(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pPtr) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glVertexAttribPointer(indx, size, type, normalized, stride, pPtr); +} + +void +_GlViewport_2(GLint x, GLint y, GLsizei width, GLsizei height) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glViewport(x, y, width, height); +} + +#if defined(FGRAPHICS_INTERNAL_USE_FBO) +_OSP_LOCAL_ bool +_CreateShader(GLuint& program) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_2 + const char* VERTEX_TEXT = + "attribute vec4 aPosition;\n" + "attribute vec2 aTextureCoord;\n" + "varying vec2 vTextureCoord;\n" + "\n" + "void main()\n" + "{\n" + " gl_Position = aPosition;\n" + " vTextureCoord = aTextureCoord;\n" + "}"; + + const char* FRAGMENT_TEXT = + "precision highp float;\n" + "uniform sampler2D uTexture;\n" + "varying vec2 vTextureCoord;\n" + "\n" + "void main (void)\n" + "{\n" + " gl_FragColor = texture2D(uTexture, vTextureCoord);\n" + "}"; + + GLint linked = GL_FALSE; + GLint bShaderCompiled = GL_FALSE; + GLuint fragShader = _glesImpl2.glCreateShader(GL_FRAGMENT_SHADER); + GLuint vertShader = _glesImpl2.glCreateShader(GL_VERTEX_SHADER); + + _glesImpl2.glShaderSource(fragShader, 1, (const char**)(&FRAGMENT_TEXT), NULL); + _glesImpl2.glCompileShader(fragShader); + _glesImpl2.glGetShaderiv(fragShader, GL_COMPILE_STATUS, &bShaderCompiled); + + _glesImpl2.glShaderSource(vertShader, 1, (const char**)&VERTEX_TEXT, NULL); + _glesImpl2.glCompileShader(vertShader); + _glesImpl2.glGetShaderiv(vertShader, GL_COMPILE_STATUS, &bShaderCompiled); + + program = _glesImpl2.glCreateProgram(); + + _glesImpl2.glAttachShader(program, fragShader); + _glesImpl2.glAttachShader(program, vertShader); + _glesImpl2.glLinkProgram(program); + _glesImpl2.glGetProgramiv(program, GL_LINK_STATUS, &linked); + + _glesImpl2.glDeleteShader(fragShader); + _glesImpl2.glDeleteShader(vertShader); + + if (linked == GL_FALSE) + { + GLint infoLen = 0; + _glesImpl2.glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLen); + if (infoLen > 1) + { + std::unique_ptr autoPtrInfoLog(new (std::nothrow) char[infoLen]); + _glesImpl2.glGetProgramInfoLog(program, infoLen, NULL, autoPtrInfoLog.get()); + SysLog(NID_GRP, "FBO Program Linking failed. log: %s", autoPtrInfoLog.get()); + } + return false; + } + + return true; +} + +_OSP_LOCAL_ void +_GlesFboTerminate_2(GLuint& frameBufferObject, GLuint& depthRenderBuffer + , GLuint& stencilRenderBuffer, GLuint& textureId, GLuint& program) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, 0); + + if (frameBufferObject != 0) + { + _glesImpl2.glDeleteFramebuffers(1, &frameBufferObject); + frameBufferObject = 0; + } + + if (depthRenderBuffer != 0) + { + _glesImpl2.glDeleteRenderbuffers(1, &depthRenderBuffer); + depthRenderBuffer = 0; + } + + if (stencilRenderBuffer != 0) + { + _glesImpl2.glDeleteRenderbuffers(1, &depthRenderBuffer); + depthRenderBuffer = 0; + } + + if (textureId != 0) + { + _glesImpl2.glDeleteTextures(1, &textureId); + textureId = 0; + } + + if (program != 0) + { + _glesImpl2.glDeleteProgram(program); + program = 0; + } +} + +_OSP_LOCAL_ bool +_GlesFboInitialize_2(const int fboWidth, const int fboHeight, GLuint& frameBufferObject + , GLuint& depthRenderBuffer, GLuint& stencilRenderBuffer, GLuint colorSize + , GLuint depthSize, GLuint stencilSize, GLuint& textureId, GLuint& program) +{ + _GLES_CHECK_INTERFACE_GLBOOLEAN_2 + if (!_CreateShader(program)) + { + return false; + } + + GLint maxSize = 0; + _glesImpl2.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &maxSize); + if (fboWidth > maxSize || fboHeight > maxSize) + { + SysLog(NID_GRP, "FBO Incompatible size"); + return false; + } + + _glesImpl2.glActiveTexture(GL_TEXTURE0); + + _glesImpl2.glGenFramebuffers(1, &frameBufferObject); + _glesImpl2.glGenRenderbuffers(1, &depthRenderBuffer); + _glesImpl2.glGenRenderbuffers(1, &stencilRenderBuffer); + _glesImpl2.glGenTextures(1, &textureId); + if (frameBufferObject == 0 || depthRenderBuffer == 0 || stencilRenderBuffer == 0 || textureId == 0) + { + SysLog(NID_GRP, "FBO generating failed! fbo:%d depth:%d stencil:%d tex:%d" + , frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId); + _GlesFboTerminate_2(frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId, program); + } + + _glesImpl2.glBindTexture(GL_TEXTURE_2D, textureId); + if (colorSize > 16) + { + _glesImpl2.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fboWidth, fboHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + } + else + { + _glesImpl2.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, fboWidth, fboHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL); + } + _glesImpl2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + _glesImpl2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + _glesImpl2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + _glesImpl2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + const char* pString = (const char*)_glesImpl2.glGetString(GL_EXTENSIONS); + String extensions(pString); + + if (depthSize > 0) + { + GLenum internalFormat = GL_DEPTH_COMPONENT16; + + if (depthSize > 24) + { + if (extensions.Contains(L"GL_OES_depth32")) + { + internalFormat = GL_DEPTH_COMPONENT32_OES; + } + } + else if (depthSize > 16) + { + if (extensions.Contains(L"GL_OES_depth24")) + { + internalFormat = GL_DEPTH_COMPONENT24_OES; + } + } + + _glesImpl2.glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBuffer); + _glesImpl2.glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, fboWidth, fboHeight); + } + + if (stencilSize > 0) + { + GLenum internalFormat = GL_STENCIL_INDEX8; + + if (stencilSize == 1) + { + if (extensions.Contains(L"GL_OES_stencil1")) + { + internalFormat = GL_STENCIL_INDEX1_OES; + } + } + else if (stencilSize <= 4) + { + if (extensions.Contains(L"GL_OES_stencil4")) + { + internalFormat = GL_STENCIL_INDEX4_OES; + } + } + + _glesImpl2.glBindRenderbuffer(GL_RENDERBUFFER, stencilRenderBuffer); + _glesImpl2.glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, fboWidth, fboHeight); + } + + _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject); + _glesImpl2.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureId, 0); + if (depthSize != 0) + { + _glesImpl2.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBuffer); + } + + _glesImpl2.glBindTexture(GL_TEXTURE_2D, 0); + + GLenum ret = _glesImpl2.glCheckFramebufferStatus(GL_FRAMEBUFFER); + if (ret != GL_FRAMEBUFFER_COMPLETE) + { + _GlesFboTerminate_2(frameBufferObject, depthRenderBuffer, stencilRenderBuffer, textureId, program); + SysLog(NID_GRP, "FBO glCheckFramebufferStatus failed! %#x", (unsigned int)ret); + return false; + } + + return true; +} + +_OSP_LOCAL_ void +_GlesFboBinding_2(const GLuint frameBufferObject) +{ + _GLES_CHECK_INTERFACE_VOID_2 + _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject); +} + +_OSP_LOCAL_ void +_GlesFboSwapBuffers_2(const Frame* pFrame, const GLuint frameBufferObject + , const GLuint textureId, const GLuint program) +{ + _GLES_CHECK_INTERFACE_VOID_2 + GLboolean isEnabledCullFace = GL_FALSE; + GLboolean isEnabledStencil = GL_FALSE; + GLboolean isEnabledDepth = GL_FALSE; + GLboolean isEnabledScissor = GL_FALSE; + GLboolean isEnabledBlend = GL_FALSE; + + isEnabledCullFace = _glesImpl2.glIsEnabled(GL_CULL_FACE); + isEnabledStencil = _glesImpl2.glIsEnabled(GL_STENCIL_TEST); + isEnabledDepth = _glesImpl2.glIsEnabled(GL_DEPTH_TEST); + isEnabledScissor = _glesImpl2.glIsEnabled(GL_SCISSOR_TEST); + isEnabledBlend = _glesImpl2.glIsEnabled(GL_BLEND); + _glesImpl2.glDisable(GL_CULL_FACE); + _glesImpl2.glDisable(GL_STENCIL_TEST); + _glesImpl2.glDisable(GL_DEPTH_TEST); + _glesImpl2.glDisable(GL_SCISSOR_TEST); + _glesImpl2.glDisable(GL_BLEND); + + GLint previousTextureId = 0; + GLint previousArrayBuffer = 0; + GLint previousElementArrayBuffer = 0; + GLint previousViewport[4] = {0,}; + GLint previousProgram = 0; + _glesImpl2.glGetIntegerv(GL_TEXTURE_BINDING_2D, &previousTextureId); + _glesImpl2.glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &previousArrayBuffer); + _glesImpl2.glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &previousElementArrayBuffer); + _glesImpl2.glGetIntegerv(GL_VIEWPORT, previousViewport); + _glesImpl2.glGetIntegerv(GL_CURRENT_PROGRAM, &previousProgram); + + _glesImpl2.glUseProgram(program); + int indexTexture = 0; + int indexAttribPosition = 0; + int indexAttribTextureCoord = 0; + indexTexture = _glesImpl2.glGetUniformLocation(program, "uTexture"); + indexAttribPosition = _glesImpl2.glGetAttribLocation(program, "aPosition"); + indexAttribTextureCoord = _glesImpl2.glGetAttribLocation(program, "aTextureCoord"); + + _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, 0); + _glesImpl2.glBindTexture( GL_TEXTURE_2D, textureId); + + int x = 0; + int y = 0; + int width = 0; + int height = 0; + pFrame->GetBounds(x, y, width, height); + + GLfloat ratioX1 = 0.0f; + GLfloat ratioX2 = 1.0f; + GLfloat ratioY1 = 0.0f; + GLfloat ratioY2 = 1.0f; + + GLfloat texture[] = { + ratioX1, ratioY1, + ratioX2, ratioY1, + ratioX1, ratioY2, + ratioX2, ratioY2, + }; + + OrientationStatus orientationStatus = pFrame->GetOrientationStatus(); + switch(orientationStatus) + { + default: + case ORIENTATION_STATUS_NONE: + case ORIENTATION_STATUS_PORTRAIT: + _glesImpl2.glViewport(0, 0, width, height); + break; + + case ORIENTATION_STATUS_LANDSCAPE: + texture[0] = ratioX2; + texture[1] = ratioY1; + texture[2] = ratioX2; + texture[3] = ratioY2; + texture[4] = ratioX1; + texture[5] = ratioY1; + texture[6] = ratioX1; + texture[7] = ratioY2; + _glesImpl2.glViewport(0, 0, height, width); + break; + + case ORIENTATION_STATUS_PORTRAIT_REVERSE: + texture[0] = ratioX2; + texture[1] = ratioY2; + texture[2] = ratioX1; + texture[3] = ratioY2; + texture[4] = ratioX2; + texture[5] = ratioY1; + texture[6] = ratioX1; + texture[7] = ratioY1; + _glesImpl2.glViewport(0, 0, width, height); + break; + + case ORIENTATION_STATUS_LANDSCAPE_REVERSE: + texture[0] = ratioX1; + texture[1] = ratioY2; + texture[2] = ratioX1; + texture[3] = ratioY1; + texture[4] = ratioX2; + texture[5] = ratioY2; + texture[6] = ratioX2; + texture[7] = ratioY1; + _glesImpl2.glViewport(0, 0, height, width); + break; + } + + _glesImpl2.glUniform1i(indexTexture, 0); + + _glesImpl2.glEnableVertexAttribArray(indexAttribPosition); + _glesImpl2.glEnableVertexAttribArray(indexAttribTextureCoord); + + GLfloat vertex[] = { + -1.0f, -1.0f, + 1.0f, -1.0f, + -1.0f, 1.0f, + 1.0f, 1.0f, + }; + + _glesImpl2.glBindBuffer(GL_ARRAY_BUFFER, 0); + _glesImpl2.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + + _glesImpl2.glVertexAttribPointer(indexAttribPosition, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), vertex); + _glesImpl2.glVertexAttribPointer(indexAttribTextureCoord, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), texture); + + _glesImpl2.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + _glesImpl2.glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject); + _glesImpl2.glUseProgram((GLuint)previousProgram); + if (isEnabledCullFace) + { + _glesImpl2.glEnable(GL_CULL_FACE); + } + if (isEnabledStencil) + { + _glesImpl2.glEnable(GL_STENCIL_TEST); + } + if (isEnabledDepth) + { + _glesImpl2.glEnable(GL_DEPTH_TEST); + } + if (isEnabledScissor) + { + _glesImpl2.glEnable(GL_SCISSOR_TEST); + } + if (isEnabledBlend) + { + _glesImpl2.glEnable(GL_BLEND); + } + + _glesImpl2.glBindTexture( GL_TEXTURE_2D, previousTextureId); + _glesImpl2.glBindBuffer(GL_ARRAY_BUFFER, previousArrayBuffer); + _glesImpl2.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, previousElementArrayBuffer); + _glesImpl2.glViewport(previousViewport[0], previousViewport[1], previousViewport[2], previousViewport[3]); +} + +#endif //#if defined(FGRAPHICS_INTERNAL_USE_FBO) + +#ifdef __cplusplus +} +#endif + +#endif //#if !defined(FGRAPHICS_INTERNAL_USE_DYNAMIC_LOADING) + +} // Opengl + +}} // Tizen::Graphics diff --git a/src/graphics/opengl/FGrpVideoTexture.cpp b/src/graphics/opengl/FGrpVideoTexture.cpp new file mode 100644 index 0000000..e2a5260 --- /dev/null +++ b/src/graphics/opengl/FGrpVideoTexture.cpp @@ -0,0 +1,76 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrpVideoTexture.cpp + * @brief This is the implementation file for VideoTexture class. + * + */ + +#include + +#include +#include + +#include "FGrp_VideoTextureImpl.h" + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +VideoTexture::VideoTexture(void) + : __pImpl(new (std::nothrow)_VideoTextureImpl) +{ +} + +VideoTexture::~VideoTexture(void) +{ + delete this->__pImpl; +} + +result +VideoTexture::Construct(int textureId, int width, int height) +{ + SysAssertf(this->__pImpl != null, "Not yet constructed. Construct() should be called before use."); + result r = this->__pImpl->Construct(textureId, width, height); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return E_SUCCESS; +} + +result +VideoTexture::BindTexture(void) +{ + SysAssertf(this->__pImpl != null, "Not yet constructed. Construct() should be called before use."); + result r = this->__pImpl->BindTexture(); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return E_SUCCESS; +} + +void +VideoTexture::AddVideoTextureUpdateListener(IVideoTextureUpdateListener& listener) +{ + SysAssertf(this->__pImpl != null, "Not yet constructed. Construct() should be called before use."); + this->__pImpl->AddVideoTextureUpdateListener(listener, this); +} + +void +VideoTexture::RemoveVideoTextureUpdateListener(IVideoTextureUpdateListener& listener) +{ + SysAssertf(this->__pImpl != null, "Not yet constructed. Construct() should be called before use."); + this->__pImpl->RemoveVideoTextureUpdateListener(listener); +} + +}}} // Tizen::Graphics diff --git a/src/graphics/opengl/FGrp_CanvasTexture.cpp b/src/graphics/opengl/FGrp_CanvasTexture.cpp new file mode 100644 index 0000000..503c7af --- /dev/null +++ b/src/graphics/opengl/FGrp_CanvasTexture.cpp @@ -0,0 +1,170 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasTexture.cpp + * @brief This is the implementation file for internal CanvasTexture class. + * + */ + +#include +#include + +#include + +#include + +#include +#include +#include +#include + +#include "FGrp_CanvasTexture.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +#ifdef __cplusplus +extern "C" +{ +#endif + +EGLNativePixmapType _CreateNativePixmapEx(Bitmap* pBitmap, BufferInfo& bufferInfo); + +#ifdef __cplusplus +} +#endif + +_CanvasTexture::_CanvasTexture(void) + : __nativePixmap((EGLNativePixmapType)0) + , __eglImage((EGLImageKHR)0) + , __pBitmap(null) +{ +} + +_CanvasTexture::~_CanvasTexture(void) +{ + __Release(); +} + +result +_CanvasTexture::Construct(const int textureId, const int width, const int height) +{ +#if !defined(_OSP_EMUL_) + EGLDisplay display = eglGetCurrentDisplay(); + GLint maxTextureSize = 0; + + SysTryReturnResult(NID_GRP, IsSupported(), E_SYSTEM, "CanvasTexture not supported on this device."); + + PFNEGLCREATEIMAGEKHRPROC funcEglCreateImageKhr = + (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); + PFNGLEGLIMAGETARGETTEXTURE2DOESPROC funcGlEglImageTargetTexture2dOes = + (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); + SysTryReturnResult(NID_GRP, (funcEglCreateImageKhr != null && funcGlEglImageTargetTexture2dOes != null), + E_UNSUPPORTED_OPERATION, "CanvasTexture not supported on this device"); + + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); + + SysTryReturnResult(NID_GRP, (width > 0 && height > 0 && width <= maxTextureSize && height <= maxTextureSize), + E_INVALID_ARG, "width(%d) or height(%d) not supported.", width, height); + + + std::auto_ptr bitmap(new (std::nothrow) Bitmap); + SysTryReturnResult(NID_GRP, bitmap.get() != null, E_OUT_OF_MEMORY, "The memory is insufficient."); + + BufferInfo bufferInfo; + bufferInfo.width = width; + bufferInfo.height = height; + bufferInfo.bitsPerPixel = ecore_x_default_depth_get(ecore_x_display_get(), ecore_x_default_screen_get()); + + this->__nativePixmap = _CreateNativePixmapEx(bitmap.get(), bufferInfo); + SysTryReturnResult(NID_GRP, this->__nativePixmap != (EGLNativePixmapType)0, E_OUT_OF_MEMORY, "Creating native pixmap failed."); + + this->__eglImage = funcEglCreateImageKhr(display, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, + (EGLClientBuffer)this->__nativePixmap, null); + SysTryReturnResult(NID_GRP, this->__eglImage != (EGLImageKHR)0, E_OUT_OF_MEMORY, "Creating ImageKHR failed."); + + glBindTexture(GL_TEXTURE_2D, textureId); + funcGlEglImageTargetTexture2dOes(GL_TEXTURE_2D, this->__eglImage); + + this->__pBitmap = bitmap.release(); + return E_SUCCESS; +#else + return E_UNSUPPORTED_OPERATION; +#endif +} + +Canvas* +_CanvasTexture::GetCanvasN(void) const +{ + SysTryReturn(NID_GRP, this->__IsValid(), null, E_OPERATION_FAILED, "This instance is not constructed yet.\n"); + + BufferInfo bufferInfo; + this->__pBitmap->Lock(bufferInfo); + this->__pBitmap->Unlock(); + + std::auto_ptr canvas(new (std::nothrow) Canvas); + SysTryReturn(NID_GRP, canvas.get() != null, null, E_OUT_OF_MEMORY, "The memory is insufficient."); + + result r = canvas.get()->Construct(bufferInfo); + SysTryReturn(NID_GRP, r == E_SUCCESS, null, E_OPERATION_FAILED, "[E_SYSTEM] Canvas construction failed."); + + return canvas.release(); +} + +bool +_CanvasTexture::IsSupported(void) +{ + const char* pString = (const char*)glGetString(GL_EXTENSIONS); + String extensions(pString); + + return extensions.Contains(Tizen::Base::String("GL_OES_EGL_image")); +} + +result +_CanvasTexture::__Release(void) +{ + if (this->__eglImage != (EGLImageKHR)0) + { + PFNEGLDESTROYIMAGEKHRPROC funcEglDestroyImageKhr = + (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); + SysTryReturnResult(NID_GRP, funcEglDestroyImageKhr != null, E_SYSTEM, "Destroy ImageKHR failed."); + + EGLDisplay display = eglGetCurrentDisplay(); + funcEglDestroyImageKhr(display, this->__eglImage); + this->__eglImage = (EGLImageKHR)0; + } + + delete this->__pBitmap; + this->__pBitmap = null; + this->__nativePixmap = (EGLNativePixmapType)0; + + return E_SUCCESS; +} + +bool +_CanvasTexture::__IsValid(void) const +{ + return (this->__nativePixmap != (EGLNativePixmapType)0 && + this->__eglImage != (EGLImageKHR)0 && + this->__pBitmap != null); +} + +}}} // Tizen::Graphics::Opengl diff --git a/src/graphics/opengl/FGrp_CanvasTexture.h b/src/graphics/opengl/FGrp_CanvasTexture.h new file mode 100644 index 0000000..e02b1fc --- /dev/null +++ b/src/graphics/opengl/FGrp_CanvasTexture.h @@ -0,0 +1,64 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasTexture.h + * @brief This is the header file for CanvasTexture class. + * + */ + +#ifndef _FGRP_INTERNAL_CANVAS_TEXTURE_H_ +#define _FGRP_INTERNAL_CANVAS_TEXTURE_H_ + +#include + +namespace Tizen { namespace Graphics { +class Bitmap; +class Canvas; +}} + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +class _CanvasTexture +{ +public: + _CanvasTexture(void); + virtual ~_CanvasTexture(void); + + result Construct(int textureId, int width, int height); + + Tizen::Graphics::Canvas* GetCanvasN(void) const; + + static bool IsSupported(void); + +private: + _CanvasTexture(const _CanvasTexture& rhs); + _CanvasTexture& operator =(const _CanvasTexture& rhs); + +private: + result __Release(void); + bool __IsValid(void) const; + + EGLNativePixmapType __nativePixmap; + EGLImageKHR __eglImage; + Bitmap* __pBitmap; +}; // _CanvasTexture + +}}} // Tizen::Graphics::Opengl + +#endif //_FGRP_CANVAS_TEXTURE_H_ diff --git a/src/graphics/opengl/FGrp_CanvasTextureImpl.cpp b/src/graphics/opengl/FGrp_CanvasTextureImpl.cpp new file mode 100644 index 0000000..6b57536 --- /dev/null +++ b/src/graphics/opengl/FGrp_CanvasTextureImpl.cpp @@ -0,0 +1,82 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_CanvasTextureImpl.cpp + * @brief This is the implementation file for internal CanvasTextureImpl class. + * + */ + +#include + +#include + +#include + +#include "FGrp_CanvasTextureImpl.h" +#include "FGrp_CanvasTexture.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +_CanvasTextureImpl::_CanvasTextureImpl(void) + : __pNativeCanvasTexture(new (std::nothrow)_CanvasTexture) +{ +} + +_CanvasTextureImpl::~_CanvasTextureImpl(void) +{ + delete this->__pNativeCanvasTexture; +} + +result +_CanvasTextureImpl::Construct(int textureId, int width, int height) +{ + SysTryReturnResult(NID_GRP, this->__pNativeCanvasTexture != null, E_OUT_OF_MEMORY, "Fails to allocate memory.\n"); + + return this->__pNativeCanvasTexture->Construct(textureId, width, height); +} + +Canvas* +_CanvasTextureImpl::GetCanvasN(void) const +{ + SysTryReturn(NID_GRP, this->__pNativeCanvasTexture != null, null, E_OUT_OF_MEMORY, "[Fails to allocate memory.\n"); + + return this->__pNativeCanvasTexture->GetCanvasN(); +} + +bool +_CanvasTextureImpl::IsSupported(void) +{ + return _CanvasTexture::IsSupported(); +} + +_CanvasTextureImpl* +_CanvasTextureImpl::GetInstance(CanvasTexture& canvasTexture) +{ + return (&canvasTexture != null) ? canvasTexture.__pImpl : null; +} + +const _CanvasTextureImpl* +_CanvasTextureImpl::GetInstance(const CanvasTexture& canvasTexture) +{ + return (&canvasTexture != null) ? canvasTexture.__pImpl : null; +} + +}}} // Tizen::Graphics::Opengl diff --git a/src/graphics/opengl/FGrp_GlPlayerImpl.cpp b/src/graphics/opengl/FGrp_GlPlayerImpl.cpp new file mode 100644 index 0000000..85e04c9 --- /dev/null +++ b/src/graphics/opengl/FGrp_GlPlayerImpl.cpp @@ -0,0 +1,474 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_GlPlayerImpl.cpp + * @brief This is the implementation file for _GlPlayerImpl class. + * + */ + +#include + +#include +#include +#include +#include + +#include + +#include "FGrp_GlPlayerImpl.h" + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +_GlPlayerImpl::_GlPlayerImpl(void) + : __pRenderer(null) + , __pTimer(null) + , __pTargetControl(null) + , __eglDisplay(EGL_NO_DISPLAY) + , __eglSurface(EGL_NO_SURFACE) + , __eglConfig(null) + , __eglContext(EGL_NO_CONTEXT) + , __fps(50) + , __renderTimeInterval(20) + , __eglContextClientVersion(EGL_CONTEXT_CLIENT_VERSION_2_X) + , __playerState(PLAYER_STATE_NOT_INITIALIZED) +{ + __eglConfigList[0] = EGL_NONE; +} + +_GlPlayerImpl::~_GlPlayerImpl(void) +{ + __DestroyGl(); + + if (__pTimer != null) + { + __pTimer->Cancel(); + delete __pTimer; + } +} + +bool +_GlPlayerImpl::__CheckReadyToStart(void) +{ + return (__pTargetControl == null) ? false : true; +} + +bool +_GlPlayerImpl::__DestroyGl(void) +{ + if (__eglDisplay == EGL_NO_DISPLAY) + { + return false; + } + + if (__pRenderer != null) + { + __pRenderer->TerminateGl(); + __pRenderer = null; + } + + eglMakeCurrent(__eglDisplay, null, null, null); + if (__eglContext != EGL_NO_CONTEXT) + { + eglDestroyContext(__eglDisplay, __eglContext); + __eglContext = EGL_NO_CONTEXT; + } + + if (__eglSurface != EGL_NO_SURFACE) + { + eglDestroySurface(__eglDisplay, __eglSurface); + __eglSurface = EGL_NO_SURFACE; + } + + eglTerminate(__eglDisplay); + __eglDisplay = EGL_NO_DISPLAY; + + return true; +} + +result +_GlPlayerImpl::Construct(EglContextClientVersion version, Tizen::Ui::Control* pControl) +{ + SysTryReturnResult(NID_GRP, version == EGL_CONTEXT_CLIENT_VERSION_1_X || + version == EGL_CONTEXT_CLIENT_VERSION_2_X, E_INVALID_ARG, "The input client version is invalid"); + + Tizen::Ui::Controls::Form* pForm = dynamic_cast (pControl); + Tizen::Ui::Controls::Frame* pFrame = dynamic_cast (pControl); + SysTryReturnResult(NID_GRP, pForm != null || pFrame != null, E_INVALID_ARG, + "The input target pControl is not allowable. Only Form/Frame are acceptable. "); + SysTryReturnResult(NID_GRP, __pTargetControl == null, E_INVALID_OPERATION, + "It is not allowable to call Construct() function, and the target pControl is not replacable."); + + std::auto_ptr timer(new (std::nothrow) Tizen::Base::Runtime::Timer); + SysTryReturnResult(NID_GRP, timer.get() != null, E_OUT_OF_MEMORY, "Fail to generate Timer. "); + SysTryReturnResult(NID_GRP, timer->Construct(*this) == E_SUCCESS, E_OUT_OF_MEMORY, "Fail to construct Timer. "); + + __eglContextClientVersion = version; + __pTargetControl = pControl; + __pTimer = timer.release(); + + return E_SUCCESS; +} + +bool +_GlPlayerImpl::IsValid(void) const +{ + return (this && this->__pTimer); +} + +result +_GlPlayerImpl::Start(void) +{ + EGLint numConfigs; + EGLint eglContextList[3] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; + + if (__playerState == PLAYER_STATE_START) + { + return E_SUCCESS; + } + + if (__playerState == PLAYER_STATE_PAUSE) + { + SysTryReturnResult(NID_GRP, false, E_INVALID_STATE, "Cannot start player when the player's state is paused."); + } + + SysTryReturnResult(NID_GRP, __CheckReadyToStart(), E_INVALID_STATE, "This instance is not ready to start yet."); + + eglBindAPI(EGL_OPENGL_ES_API); + if (__eglDisplay != EGL_NO_DISPLAY) + { + __DestroyGl(); + } + + __eglDisplay = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY); + SysTryReturnResult(NID_GRP, __eglDisplay != EGL_NO_DISPLAY, E_OPENGL_ERROR, "Fail to find EGL_DEFAULT_DISPLAY device with eglGetDisplay()."); + + if (eglInitialize(__eglDisplay, null, null) == EGL_FALSE || eglGetError() != EGL_SUCCESS) + { + __DestroyGl(); + SysTryReturnResult(NID_GRP, false, E_OPENGL_ERROR, "Fail to initialize egl with eglInitialize()."); + } + + if (eglChooseConfig(__eglDisplay, __eglConfigList, &__eglConfig, 1, &numConfigs) == EGL_FALSE || eglGetError() != EGL_SUCCESS) + { + __DestroyGl(); + SysTryReturnResult(NID_GRP, false, E_OPENGL_ERROR, "Fail to choose appropriate egl configurations with eglChooseConfig()."); + } + + if (numConfigs == 0) + { + __DestroyGl(); + SysTryReturnResult(NID_GRP, false, E_OPENGL_ERROR, "There is no matching configuration for the given condition."); + } + + __eglSurface = eglCreateWindowSurface(__eglDisplay, __eglConfig, (EGLNativeWindowType)__pTargetControl, null); + if (__eglSurface == EGL_NO_SURFACE || eglGetError() != EGL_SUCCESS) + { + __DestroyGl(); + SysTryReturnResult(NID_GRP, false, E_OPENGL_ERROR, "Fail to create window surface with eglCreateWindowSurface()."); + } + + switch (__eglContextClientVersion) + { + case EGL_CONTEXT_CLIENT_VERSION_1_X: + eglContextList[1] = 1; + break; + case EGL_CONTEXT_CLIENT_VERSION_2_X: + eglContextList[1] = 2; + break; + } + __eglContext = eglCreateContext(__eglDisplay, __eglConfig, EGL_NO_CONTEXT, eglContextList); + if (__eglContext == EGL_NO_CONTEXT || eglGetError() != EGL_SUCCESS) + { + __DestroyGl(); + SysTryReturnResult(NID_GRP, false, E_OPENGL_ERROR, "Fail to create egl context with eglCreateContext()."); + } + + if (eglMakeCurrent(__eglDisplay, __eglSurface, __eglSurface, __eglContext) == EGL_FALSE || eglGetError() != EGL_SUCCESS) + { + __DestroyGl(); + SysTryReturnResult(NID_GRP, false, E_OPENGL_ERROR, "Fail to active the current context with eglMakeCurrent()."); + } + + if (__fps > 0) + { + result r = __pTimer->Start(__renderTimeInterval); + SysTryReturnResult(NID_GRP, r == E_SUCCESS, r, "Fail to resume Timer."); + } + + __playerState = PLAYER_STATE_START; + + return E_SUCCESS; +} + +result +_GlPlayerImpl::Pause(void) +{ + if (__playerState == PLAYER_STATE_PAUSE || __playerState == PLAYER_STATE_STOP) + { + return E_SUCCESS; + } + + if (__playerState == PLAYER_STATE_NOT_INITIALIZED) + { + SysTryReturnResult(NID_GRP, false, E_INVALID_STATE, "Cannot pause player when the player is not started."); + } + + if (__pTimer != null) + { + result r = __pTimer->Cancel(); + SysTryReturnResult(NID_GRP, r == E_SUCCESS, r, "Fail to pause Timer."); + } + + if (__pRenderer != null) + { + SysTryReturnResult(NID_GRP, __pRenderer->Pause(), E_INVALID_OPERATION, "Fail to perform IGlRenderer::Pause() function ."); + } + + __playerState = PLAYER_STATE_PAUSE; + + return E_SUCCESS; +} + +result +_GlPlayerImpl::Resume(void) +{ + if (__playerState == PLAYER_STATE_START) + { + return E_SUCCESS; + } + + if (__playerState == PLAYER_STATE_NOT_INITIALIZED || __playerState == PLAYER_STATE_STOP) + { + SysTryReturnResult(NID_GRP, false, E_INVALID_STATE, "Cannot resume player when the player is not started."); + } + + if (__pRenderer != null) + { + SysTryReturnResult(NID_GRP, __pRenderer->Resume(), E_INVALID_OPERATION, "Fail to perform IGlRenderer::Resume() function ."); + } + if (__pTimer != null) + { + result r = __pTimer->Start(__renderTimeInterval); + SysTryReturnResult(NID_GRP, r == E_SUCCESS, r, "Fail to resume Timer."); + } + + __playerState = PLAYER_STATE_START; + + return E_SUCCESS; +} + +result +_GlPlayerImpl::Stop(void) +{ + if (__playerState == PLAYER_STATE_STOP || __playerState == PLAYER_STATE_NOT_INITIALIZED) + { + return E_SUCCESS; + } + + if (__playerState == PLAYER_STATE_PAUSE) + { + __DestroyGl(); + __playerState = PLAYER_STATE_STOP; + } + + if (__pTimer != null) + { + result r = __pTimer->Cancel(); + SysTryReturnResult(NID_GRP, r == E_SUCCESS, r, "Fail to pause Timer."); + } + + if (__pRenderer != null) + { + SysTryReturnResult(NID_GRP, __pRenderer->Pause(), E_INVALID_OPERATION, "Fail to perform IGlRenderer::Pause() function ."); + } + + __DestroyGl(); + __playerState = PLAYER_STATE_STOP; + + return E_SUCCESS; +} + +result +_GlPlayerImpl::Redraw(void) +{ + SysTryReturnResult(NID_GRP, eglMakeCurrent(__eglDisplay, __eglSurface, __eglSurface, __eglContext) != EGL_FALSE, E_OPENGL_ERROR, "eglMakeCurrent() has been failed."); + + if (__pRenderer != null) + { + __pRenderer->Draw(); + eglSwapBuffers(__eglDisplay, __eglSurface); + } + + return E_SUCCESS; +} + +result +_GlPlayerImpl::SetFps(int fps) +{ + __fps = fps; + if (fps > 0) + { + __renderTimeInterval = (int)((float)1000 / (float)fps + 0.5f); + } + else + { + __renderTimeInterval = -1; + } + + return E_SUCCESS; +} + +result +_GlPlayerImpl::SetEglAttributeList(const EGLint* pEglConfigList) +{ + int index = 0; + + SysTryReturnResult(NID_GRP, pEglConfigList != null, E_INVALID_ARG, "Input is invalid EGL attribute list. "); + + while (pEglConfigList[index] != EGL_NONE) + { + SysTryReturnResult(NID_GRP, index < 38, E_INVALID_ARG, "Input eglConfigList does not have terminal symbol 'EGL_NONE'. "); + + __eglConfigList[index] = pEglConfigList[index]; + __eglConfigList[index+1] = pEglConfigList[index+1]; + index += 2; + } + __eglConfigList[index] = EGL_NONE; + + return E_SUCCESS; +} + +result +_GlPlayerImpl::SetEglAttributePreset(EglAttributesPreset preset) +{ + int index = 0; + + switch (preset) + { + case EGL_ATTRIBUTES_PRESET_RGB565: + __eglConfigList[index++] = EGL_RED_SIZE; + __eglConfigList[index++] = 5; + __eglConfigList[index++] = EGL_GREEN_SIZE; + __eglConfigList[index++] = 6; + __eglConfigList[index++] = EGL_BLUE_SIZE; + __eglConfigList[index++] = 5; + break; + case EGL_ATTRIBUTES_PRESET_ARGB8888: + __eglConfigList[index++] = EGL_ALPHA_SIZE; + __eglConfigList[index++] = 8; + __eglConfigList[index++] = EGL_RED_SIZE; + __eglConfigList[index++] = 8; + __eglConfigList[index++] = EGL_GREEN_SIZE; + __eglConfigList[index++] = 8; + __eglConfigList[index++] = EGL_BLUE_SIZE; + __eglConfigList[index++] = 8; + break; + case EGL_ATTRIBUTES_PRESET_DONT_CARE: + break; + default: + SysTryReturnResult(NID_GRP, false, E_INVALID_ARG, "Input preset is invalid. "); + break; + } + __eglConfigList[index] = EGL_NONE; + + return E_SUCCESS; +} + +result +_GlPlayerImpl::SetEglAttribute(EGLint key, EGLint value) +{ + int index = 0; + + if (key != EGL_BUFFER_SIZE && key != EGL_RED_SIZE && key != EGL_GREEN_SIZE && key != EGL_BLUE_SIZE && key != EGL_ALPHA_SIZE && + key != EGL_CONFIG_CAVEAT && key != EGL_CONFIG_ID && key != EGL_DEPTH_SIZE && key != EGL_LEVEL && key != EGL_NATIVE_RENDERABLE && + key != EGL_NATIVE_VISUAL_TYPE && key != EGL_SAMPLE_BUFFERS && key != EGL_SAMPLES && key != EGL_STENCIL_SIZE && key != EGL_SURFACE_TYPE && + key != EGL_TRANSPARENT_TYPE && key != EGL_TRANSPARENT_RED_VALUE && key != EGL_TRANSPARENT_GREEN_VALUE && key != EGL_TRANSPARENT_BLUE_VALUE) + { + SysTryReturnResult(NID_GRP, false, E_INVALID_ARG, "Input key is invalid for EGL attributes"); + } + + while (__eglConfigList[index] != key && __eglConfigList[index] != EGL_NONE) + { + index += 2; + } + + if (__eglConfigList[index] == EGL_NONE) + { + __eglConfigList[index] = key; + __eglConfigList[index+2] = EGL_NONE; + } + __eglConfigList[index+1] = value; + + return E_SUCCESS; +} + +result +_GlPlayerImpl::SetIGlRenderer(IGlRenderer* pRenderer) +{ + if (pRenderer != null) + { + int x = 0; + int y = 0; + int width = 0; + int height = 0; + + __pTargetControl->GetBounds(x, y, width, height); + pRenderer->SetTargetControlWidth(width); + pRenderer->SetTargetControlHeight(height); + + SysTryReturnResult(NID_GRP, pRenderer->InitializeGl(), E_INVALID_OPERATION, "Fail to InitializeGl() for the given pRenderer. "); + } + if (__pRenderer != null) + { + __pRenderer->TerminateGl(); + } + + __pRenderer = pRenderer; + + return E_SUCCESS; +} + +void +_GlPlayerImpl::OnTimerExpired(Tizen::Base::Runtime::Timer& timer) +{ + if (__pTimer == null) + { + return; + } + __pTimer->Start(__renderTimeInterval); + + if (Redraw() != E_SUCCESS) + { + SysLog(NID_GRP, "Redraw() in OnTimerExpired() has failed. "); + } +} + +_GlPlayerImpl* +_GlPlayerImpl::GetInstance(GlPlayer& player) +{ + return (&player != null) ? player.__pImpl : null; +} + +const _GlPlayerImpl* +_GlPlayerImpl::GetInstance(const GlPlayer& player) +{ + return (&player != null) ? player.__pImpl : null; +} + +}}} // Tizen::Graphics::Opengl diff --git a/src/graphics/opengl/FGrp_VideoTexture.cpp b/src/graphics/opengl/FGrp_VideoTexture.cpp new file mode 100644 index 0000000..6925fa6 --- /dev/null +++ b/src/graphics/opengl/FGrp_VideoTexture.cpp @@ -0,0 +1,491 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_VideoTexture.cpp + * @brief This is the implementation file for internal VideoTexture class. + * + */ + +#include +#include + +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include "FGrp_VideoTexture.h" +#include "FGrp_BufferInfoImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::System; + +#define FGRAPHICS_INTERNAL_USE_THRESHOLD_EVENT_TIMER + +#ifdef __cplusplus +extern "C" +{ +#endif + +namespace Tizen { namespace Graphics { namespace Opengl +{ +EGLNativePixmapType _CreateNativePixmapEx(Bitmap* pBitmap, BufferInfo bufferInfo); +void _GlBindTexture_1(GLenum target, GLuint texture); +void _GlGetIntegerv_1(GLenum pname, GLint* params); +const GLubyte* _GlGetString_1(GLenum name); +}}} + +#ifdef __cplusplus +} +#endif + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +namespace //unnamed +{ +const long long _DEQUEUE_THRESHOLD_EVENT_TIME = 1000; +} + +_DamageEvent::_DamageEvent(void) + : __pDisplay(NULL) + , __eventBaseReturn(0) + , __pVideoTexture(null) +{ + for (int i = 0; i < _VIDEO_TEXTURE_BUFFER_MAX; i++) + { + __pixmap[i] = (Drawable)0; + __damage[i] = (Damage)0; + } +} + +_DamageEvent::~_DamageEvent(void) +{ + for (int i = 0; i < _VIDEO_TEXTURE_BUFFER_MAX; i++) + { + XDamageDestroy(__pDisplay, __damage[i]); + } + XCloseDisplay(__pDisplay); +} + +result +_DamageEvent::Construct(_VideoTexture* pVideoTexture) +{ + __pVideoTexture = pVideoTexture; + + int errorBaseReturn = 0; + __pDisplay = (Display*)XOpenDisplay(NULL); + + if (!XDamageQueryExtension(__pDisplay, &__eventBaseReturn, &errorBaseReturn)) + { + return E_SYSTEM; + } + + for (int i = 0; i < _VIDEO_TEXTURE_BUFFER_MAX; i++) + { + __pixmap[i] = (Drawable)__pVideoTexture->__pBuffer[i].__nativePixmap; + __damage[i] = XDamageCreate (__pDisplay, __pixmap[i], XDamageReportRawRectangles); + } + + return Thread::Construct(); +} + +Object* +_DamageEvent::Run(void) +{ + while(true) + { + XEvent ev = {0,}; + XNextEvent (__pDisplay, &ev); + + if (ev.type == __eventBaseReturn) + { + XDamageNotifyEvent* pDamageEvent = (XDamageNotifyEvent*)&ev; + + for (int i = 0; i < _VIDEO_TEXTURE_BUFFER_MAX; i++) + { + if (pDamageEvent != null && pDamageEvent->drawable == __pixmap[i]) + { + __pVideoTexture->__pBuffer[i].__bufferState = _BUFFER_STATE_ENQUEUE; + SystemTime::GetTicks(__pVideoTexture->__pBuffer[i].__timeStamp); + if (__pVideoTexture->pVideoTextureUpdateListener != null) + { + __pVideoTexture->pVideoTextureUpdateListener->OnTextureUpdated(__pVideoTexture->__pVideoTexture); + } + break; + } + } + + XDamageSubtract (__pDisplay, pDamageEvent->damage, None, None ); + } + } + + return null; +} + +_VideoTexture::_VideoTexture(void) + : pVideoTextureUpdateListener(null) + , __textureId(0) + , __isEglSyncAvailable(false) + , __glVersion(0) + , __eglDisplay(EGL_NO_DISPLAY) + , __funcEglCreateSyncKhr(null) + , __funcEglClientWaitSyncKhr(null) + , __funcEglDestroySyncKhr(null) + , __funcGlEglImageTargetTexture2dOes(null) + , __pDamageEvent(null) + , __pVideoTexture(null) + , __currentReadingBuffer(-1) +{ + for (int i = 0; i < _VIDEO_TEXTURE_BUFFER_MAX; i++) + { + __pBuffer[i].__pBitmap = null; + __pBuffer[i].__nativePixmap = (EGLNativePixmapType)0; + __pBuffer[i].__eglImage = (EGLImageKHR)0; + __pBuffer[i].__timeStamp = 0; + __pBuffer[i].__bufferState = _BUFFER_STATE_FREE; + __pBuffer[i].__eglSync = EGL_NO_SYNC_KHR; + } +} + +_VideoTexture::~_VideoTexture(void) +{ + Release(); +} + +result +_VideoTexture::Construct(const int textureId, const int width, const int height) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_GRP, textureId > 0 && width > 0 && height > 0 + , E_INVALID_ARG, "Invalid parameter. textureId:%d w:%d h:%d", textureId, width, height); + + __eglDisplay = eglGetCurrentDisplay(); + EGLContext eglContext = eglGetCurrentContext(); + eglQueryContext(__eglDisplay, eglContext, EGL_CONTEXT_CLIENT_VERSION, &__glVersion); + SysTryReturnResult(NID_GRP, __eglDisplay != EGL_NO_DISPLAY && eglContext != EGL_NO_CONTEXT + && (__glVersion == 1 || __glVersion == 2) + , E_INVALID_STATE, "Getting egl informations failed! eglDisplay:%#x eglContext:%#x glVersion:%d" + , (unsigned int)__eglDisplay, (unsigned int)eglContext, __glVersion); + + __funcGlEglImageTargetTexture2dOes = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); + PFNEGLCREATEIMAGEKHRPROC funcEglCreateImageKhr = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); + + SysTryReturnResult(NID_GRP, IsSupported(L"GL_OES_EGL_image") + && __funcGlEglImageTargetTexture2dOes != null && funcEglCreateImageKhr != null + , E_UNSUPPORTED_OPERATION, "Not supported on this device."); + + if (IsSupported(L"GL_OES_EGL_sync")) + { + __funcEglCreateSyncKhr = (PFNEGLCREATESYNCKHRPROC)eglGetProcAddress("eglCreateSyncKHR"); + __funcEglClientWaitSyncKhr = (PFNEGLCLIENTWAITSYNCKHRPROC)eglGetProcAddress("eglClientWaitSyncKHR"); + __funcEglDestroySyncKhr = (PFNEGLDESTROYSYNCKHRPROC)eglGetProcAddress("eglDestroySyncKHR"); + if (__funcEglCreateSyncKhr == null || __funcEglClientWaitSyncKhr == null || __funcEglDestroySyncKhr == null) + { + __isEglSyncAvailable = false; + SysLog(NID_GRP, "GL_OES_EGL_sync supported on this device, but function is not available! %#x %#x %#x" + , (unsigned int)__funcEglCreateSyncKhr + , (unsigned int)__funcEglClientWaitSyncKhr + , (unsigned int)__funcEglDestroySyncKhr); + } + else + { + __isEglSyncAvailable = true; + } + } + + __textureId = textureId; + + GLint maxTextureSize = 0; + if (__glVersion == 1) + { + _GlGetIntegerv_1(GL_MAX_TEXTURE_SIZE, &maxTextureSize); + } + else + { + _GlGetIntegerv_2(GL_MAX_TEXTURE_SIZE, &maxTextureSize); + } + + SysTryReturnResult(NID_GRP, width <= maxTextureSize && height <= maxTextureSize + , E_OUT_OF_RANGE, "w:%d h%d are bigger than GL_MAX_TEXTURE_SIZE:%d.", width, height, maxTextureSize); + + BufferInfo bufferInfo; + bufferInfo.width = width; + bufferInfo.height = height; + bufferInfo.bitsPerPixel = ecore_x_default_depth_get(ecore_x_display_get(), ecore_x_default_screen_get()); + + for (int i = 0; i < _VIDEO_TEXTURE_BUFFER_MAX; i++) + { + __pBuffer[i].__pBitmap = new (std::nothrow) Bitmap; + SysTryCatch(NID_GRP, __pBuffer[i].__pBitmap != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Fails to allocate memory."); + + __pBuffer[i].__nativePixmap = _CreateNativePixmapEx(__pBuffer[i].__pBitmap, bufferInfo); + __pBuffer[i].__eglImage = + funcEglCreateImageKhr(__eglDisplay, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, + (EGLClientBuffer)__pBuffer[i].__nativePixmap, null); + SysTryCatch(NID_GRP, __pBuffer[i].__nativePixmap != (EGLNativePixmapType)0 && __pBuffer[i].__eglImage != (EGLImageKHR)0 + , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Creating native pixmap failed."); + } + + __pDamageEvent = new (std::nothrow)_DamageEvent; + SysTryReturnResult(NID_GRP, __pDamageEvent != null, E_OUT_OF_MEMORY, "Fails to allocate memory."); + + r = __pDamageEvent->Construct(this); + SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pDamageEvent->Start(); + + return r; + +CATCH: + Release(); + + return r; +} + +result +_VideoTexture::BindTexture(void) +{ + int oldestReadableBuffer = -1; + long long timeStamp = 0; + int count = 0; + SystemTime::GetTicks(timeStamp); + + //find the oldest buffer. + for (int i = 0; i < _VIDEO_TEXTURE_BUFFER_MAX; i++) + { + if (__pBuffer[i].__bufferState == _BUFFER_STATE_ENQUEUE) + { + count++; + if (__pBuffer[i].__timeStamp < timeStamp) + { + oldestReadableBuffer = i; + timeStamp = __pBuffer[i].__timeStamp; + } + } + } + + if (count <= 0 || count > _VIDEO_TEXTURE_BUFFER_MAX) + { + if (__currentReadingBuffer < 0) + { + SysLog(NID_GRP, "A video frame is not ready."); + return E_INVALID_STATE; + } + else + { + oldestReadableBuffer = __currentReadingBuffer; + } + } + else + { + if (__isEglSyncAvailable) + { + if (__currentReadingBuffer != oldestReadableBuffer) + { + if (__pBuffer[__currentReadingBuffer].__eglSync == EGL_NO_SYNC_KHR) + { + __pBuffer[__currentReadingBuffer].__eglSync = __funcEglCreateSyncKhr(__eglDisplay, EGL_SYNC_FENCE_KHR, NULL);//EGL_SYNC_FENCE_KHR EGL_SYNC_REUSABLE_KHR + } + } + } + else + { + if (__currentReadingBuffer != oldestReadableBuffer) + { + eglWaitGL(); + } + } + } + + __currentReadingBuffer = oldestReadableBuffer; + __pBuffer[oldestReadableBuffer].__bufferState = _BUFFER_STATE_FREE; + SystemTime::GetTicks(__pBuffer[oldestReadableBuffer].__timeStamp); + + if (__glVersion == 1) + { + _GlBindTexture_1(GL_TEXTURE_2D, __textureId); + } + else + { + _GlBindTexture_2(GL_TEXTURE_2D, __textureId); + } + + __funcGlEglImageTargetTexture2dOes(GL_TEXTURE_2D, __pBuffer[oldestReadableBuffer].__eglImage); + + return E_SUCCESS; +} + +void +_VideoTexture::AddVideoTextureUpdateListener(IVideoTextureUpdateListener& listener, VideoTexture* pVideoTexture) +{ + __pVideoTexture = pVideoTexture; + pVideoTextureUpdateListener = dynamic_cast (&listener); + SysTryLog(NID_GRP, pVideoTextureUpdateListener != null, "The listener is null."); +} + +void +_VideoTexture::RemoveVideoTextureUpdateListener(IVideoTextureUpdateListener& listener) +{ + //fixme + IVideoTextureUpdateListener* pListener = dynamic_cast (&listener); + SysTryLog(NID_GRP, pListener != null, "The listener is null."); + __pVideoTexture = null; + pVideoTextureUpdateListener = null; +} + +int +_VideoTexture::FindFreeBuffer(void) +{ + int oldestFreedBuffer = -1; + long long timeStamp = 0; + int count = 0; + SystemTime::GetTicks(timeStamp); + + for (int i = 0; i < _VIDEO_TEXTURE_BUFFER_MAX; i++) + { + if (__pBuffer[i].__bufferState == _BUFFER_STATE_FREE) + { + count++; + if (__pBuffer[i].__timeStamp < timeStamp) + { + oldestFreedBuffer = i; + timeStamp = __pBuffer[i].__timeStamp; + } + } + } + +#if defined (FGRAPHICS_INTERNAL_USE_THRESHOLD_EVENT_TIMER) + if (count == 0 || oldestFreedBuffer == __currentReadingBuffer) + { + for (int i = 0; i < _VIDEO_TEXTURE_BUFFER_MAX; i++) + { + if (__pBuffer[i].__bufferState == _BUFFER_STATE_DEQUEUE) + { + SystemTime::GetTicks(timeStamp); + if (timeStamp - __pBuffer[i].__timeStamp > _DEQUEUE_THRESHOLD_EVENT_TIME) + { + count++; + oldestFreedBuffer = i; + timeStamp = __pBuffer[i].__timeStamp; + __pBuffer[i].__bufferState = _BUFFER_STATE_FREE; + break; + } + } + } + } +#endif + + if (count == 0) + { + return -1; + } + else + { + return oldestFreedBuffer; + } +} + +Pixmap +_VideoTexture::GetPixmap(void) +{ + int oldestFreedBuffer = FindFreeBuffer(); + + if (oldestFreedBuffer == -1 || oldestFreedBuffer == __currentReadingBuffer) + { + return 0; + } + + if (__pBuffer[oldestFreedBuffer].__eglSync != EGL_NO_SYNC_KHR) + { + EGLint ret = __funcEglClientWaitSyncKhr(__eglDisplay, __pBuffer[oldestFreedBuffer].__eglSync + , EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR); + SysTryLog(NID_GRP, ret == EGL_CONDITION_SATISFIED_KHR, "eglClientWaitSyncKhr is not working."); + + __funcEglDestroySyncKhr(__eglDisplay, __pBuffer[oldestFreedBuffer].__eglSync); + __pBuffer[oldestFreedBuffer].__eglSync = EGL_NO_SYNC_KHR; + } + + __pBuffer[oldestFreedBuffer].__bufferState = _BUFFER_STATE_DEQUEUE; + SystemTime::GetTicks(__pBuffer[oldestFreedBuffer].__timeStamp); + + return (unsigned int)__pBuffer[oldestFreedBuffer].__nativePixmap; +} + +bool +_VideoTexture::IsSupported(String string) +{ + char* pString = null; + if (__glVersion == 1) + { + pString = (char*)_GlGetString_1(GL_EXTENSIONS); + } + else + { + pString = (char*)_GlGetString_2(GL_EXTENSIONS); + } + String extensions(pString); + + return extensions.Contains(string); +} + +result +_VideoTexture::Release(void) +{ + delete __pDamageEvent; + + PFNEGLDESTROYIMAGEKHRPROC funcEglDestroyImageKhr = + (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); + + for (int i = 0; i < _VIDEO_TEXTURE_BUFFER_MAX; i++) + { + if (funcEglDestroyImageKhr != null && __pBuffer[i].__eglImage != EGL_NO_IMAGE_KHR) + { + funcEglDestroyImageKhr(__eglDisplay, __pBuffer[i].__eglImage); + __pBuffer[i].__eglImage = EGL_NO_IMAGE_KHR; + } + + if (__funcEglDestroySyncKhr != null && __pBuffer[i].__eglSync != EGL_NO_SYNC_KHR) + { + __funcEglDestroySyncKhr(__eglDisplay, __pBuffer[i].__eglSync); + __pBuffer[i].__eglSync = EGL_NO_SYNC_KHR; + } + + delete __pBuffer[i].__pBitmap; + __pBuffer[i].__pBitmap = null; + + __pBuffer[i].__nativePixmap = (EGLNativePixmapType)0; + __pBuffer[i].__timeStamp = 0; + __pBuffer[i].__bufferState = _BUFFER_STATE_FREE; + } + + return E_SUCCESS; +} + +}}} // Tizen::Graphics diff --git a/src/graphics/opengl/FGrp_VideoTexture.h b/src/graphics/opengl/FGrp_VideoTexture.h new file mode 100644 index 0000000..94752f7 --- /dev/null +++ b/src/graphics/opengl/FGrp_VideoTexture.h @@ -0,0 +1,127 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_VideoTexture.h + * @brief This is the header file for VideoTexture class. + * + */ + +#ifndef _FGRP_INTERNAL_VIDEO_TEXTURE_H_ +#define _FGRP_INTERNAL_VIDEO_TEXTURE_H_ + +#include +#include + +#include +#include +#include + +namespace Tizen { namespace Graphics { +class Bitmap; +}} + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +const int _VIDEO_TEXTURE_BUFFER_MAX = 4; + +class VideoTexture; +class _VideoTexture; + +enum _BufferState +{ + _BUFFER_STATE_FREE = 0, + _BUFFER_STATE_DEQUEUE, + _BUFFER_STATE_ENQUEUE, +}; + +struct _VideoTextureBuffer +{ + Tizen::Graphics::Bitmap* __pBitmap; + EGLNativePixmapType __nativePixmap; + EGLImageKHR __eglImage; + long long __timeStamp; + _BufferState __bufferState; + EGLSyncKHR __eglSync; +}; + +class _DamageEvent + : public Tizen::Base::Runtime::Thread +{ +public: + _DamageEvent(void); + virtual ~_DamageEvent(void); + result Construct(_VideoTexture* pVideoTexture); + Object* Run(void); + +private: + Drawable __pixmap[_VIDEO_TEXTURE_BUFFER_MAX]; + Damage __damage[_VIDEO_TEXTURE_BUFFER_MAX]; + Display* __pDisplay; + int __eventBaseReturn; + _VideoTexture* __pVideoTexture; + + friend class _VideoTexture; +}; + +class _VideoTexture +{ +public: + _VideoTexture(void); + virtual ~_VideoTexture(void); + + result Construct(int textureId, int width, int height); + + result BindTexture(void); + void AddVideoTextureUpdateListener(IVideoTextureUpdateListener& listener, VideoTexture* pVideoTexture); + void RemoveVideoTextureUpdateListener(IVideoTextureUpdateListener& listener); + + bool IsSupported(Tizen::Base::String string); + Pixmap GetPixmap(void); + + +private: + _VideoTexture(const _VideoTexture& rhs); + _VideoTexture& operator =(const _VideoTexture& rhs); + +public: + IVideoTextureUpdateListener* pVideoTextureUpdateListener; + +private: + result Release(void); + int FindFreeBuffer(void); + + _VideoTextureBuffer __pBuffer[_VIDEO_TEXTURE_BUFFER_MAX]; + int __textureId; + bool __isEglSyncAvailable; + int __glVersion; + EGLDisplay __eglDisplay; + PFNEGLCREATESYNCKHRPROC __funcEglCreateSyncKhr; + PFNEGLCLIENTWAITSYNCKHRPROC __funcEglClientWaitSyncKhr; + PFNEGLDESTROYSYNCKHRPROC __funcEglDestroySyncKhr; + PFNGLEGLIMAGETARGETTEXTURE2DOESPROC __funcGlEglImageTargetTexture2dOes; + _DamageEvent* __pDamageEvent; + VideoTexture* __pVideoTexture; + int __currentReadingBuffer; + + friend class _DamageEvent; +}; // _VideoTexture + +}}} // Tizen::Graphics + +#endif //_FGRP_INTERNAL_VIDEO_TEXTURE_H_ diff --git a/src/graphics/opengl/FGrp_VideoTextureImpl.cpp b/src/graphics/opengl/FGrp_VideoTextureImpl.cpp new file mode 100644 index 0000000..07b575b --- /dev/null +++ b/src/graphics/opengl/FGrp_VideoTextureImpl.cpp @@ -0,0 +1,95 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_VideoTextureImpl.cpp + * @brief This is the implementation file for internal VideoTextureImpl class. + * + */ + +#include + +#include +#include +#include "FGrp_VideoTextureImpl.h" +#include "FGrp_VideoTexture.h" + +namespace Tizen { namespace Graphics { namespace Opengl +{ + +_VideoTextureImpl::_VideoTextureImpl(void) + : __pNativeVideoTexture(new (std::nothrow)_VideoTexture) +{ +} + +_VideoTextureImpl::~_VideoTextureImpl(void) +{ + delete this->__pNativeVideoTexture; +} + +result +_VideoTextureImpl::Construct(int textureId, int width, int height) +{ + SysTryReturnResult(NID_GRP, this->__pNativeVideoTexture != null, E_OUT_OF_MEMORY, "Fails to allocate memory.\n"); + + return this->__pNativeVideoTexture->Construct(textureId, width, height); +} + +result +_VideoTextureImpl::BindTexture(void) +{ + return this->__pNativeVideoTexture->BindTexture(); +} + +void +_VideoTextureImpl::AddVideoTextureUpdateListener(IVideoTextureUpdateListener& listener, VideoTexture* pVideoTexture) +{ + this->__pNativeVideoTexture->AddVideoTextureUpdateListener(listener, pVideoTexture); +} + +void +_VideoTextureImpl::RemoveVideoTextureUpdateListener(IVideoTextureUpdateListener& listener) +{ + this->__pNativeVideoTexture->RemoveVideoTextureUpdateListener(listener); +} + +_VideoTextureImpl* +_VideoTextureImpl::GetInstance(VideoTexture& videoTexture) +{ + return (&videoTexture != null) ? videoTexture.__pImpl : null; +} + +const _VideoTextureImpl* +_VideoTextureImpl::GetInstance(const VideoTexture& videoTexture) +{ + return (&videoTexture != null) ? videoTexture.__pImpl : null; +} + +unsigned int +_VideoTextureImpl::GetPixmap(void* pData) +{ + _VideoTextureImpl* pVideoTextureImpl = dynamic_cast<_VideoTextureImpl*> ((_VideoTextureImpl*)pData); + if (pVideoTextureImpl == null) + { + SysLog(NID_GRP, "pData is null."); + return 0; + } + + return (unsigned int)pVideoTextureImpl->__pNativeVideoTexture->GetPixmap(); +} + +}}} // Tizen::Graphics diff --git a/src/graphics/text/FGrp_TextTextColumn.cpp b/src/graphics/text/FGrp_TextTextColumn.cpp new file mode 100644 index 0000000..7a86696 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextColumn.cpp @@ -0,0 +1,2190 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextColumn.cpp + * @brief This is the implementation file for TextColumn class. + */ + +#include +#include +#include "FGrp_CanvasImpl.h" +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextComposite.h" +#include "FGrp_TextTextLine.h" +#include "FGrp_TextTextColumn.h" +#include "FGrp_TextTextUtility.h" + +using namespace Tizen::Base::Utility; + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +struct ChangeActionEventInfo +{ + TextColumn::ChangeAction action; + int changedTextIndex; + int changedTextLength; +}; + +TextColumn::TextColumn(TextComposite* pCompositeText) +{ + __totalLineCount = 0; + __displayLineCount = 0; + __firstDisplayLineIndex = 0; + __firstDisplayPositionY = -1; + __displayHeight = -1; + __slidingPosition = 0; + __pCompositeText = pCompositeText; + __textChangeAction = TEXT_CHANGE_INSERT; + __setChangeAction = false; + __pCachedLineNode = null; + __cachedLineIndex = 0; + __cachedLinePositionY = 0; + __chagedStartTextIndex = 0; + __changedTextLength = 0; + __changedStartLineIndex = 0; + __changedLastLineIndex = 0; + __prevLineIndexBeforeChangedStartLine = 0; + __nextLineIndexAfterChangedLastLine = 0; + __textOffsetOfNextLineAfterChangedLine = 0; + __currentLineIndexToAddDuringCompose = 0; + __isComposeDone = false; + + __pLines = new (std::nothrow) SimpleList; + if (__pLines) + { + TextSimpleList::Init(__pLines); + } + + __pTextChangeActionList = new (std::nothrow) SimpleList; + if (__pTextChangeActionList) + { + TextSimpleList::Init(__pTextChangeActionList); + } + + __pKeepLines = new (std::nothrow) SimpleList; + if (__pKeepLines) + { + TextSimpleList::Init(__pKeepLines); + } + + __keepLineCount = 0; + __insertedLineCountDuringCompose = 0; +} + +TextColumn::~TextColumn(void) +{ + if (__pLines) + { + RemoveAllLines(); + delete __pLines; + __pLines = null; + } + + if (__pKeepLines) + { + RemoveAllKeepLines(); + delete __pKeepLines; + __pKeepLines = null; + } + + if (__pTextChangeActionList) + { + RemoveAllChangeActions(); + delete __pTextChangeActionList; + __pTextChangeActionList = null; + } +} + +result +TextColumn::GetRegion(int textIndex, int textLength, int& width, int& height) const +{ + result r = E_SUCCESS; + + width = 0; + height = 0; + + int totalLength = __pCompositeText->GetTextLength(); + + if (textIndex != 0 || textLength != totalLength) + { + return __pCompositeText->GetRegion(textIndex, textLength, width, height); + } + + Rectangle lineBounds; + SimpleNode* pTextLineNode = null; + TextLine* pTextLine = null; + + pTextLineNode = TextSimpleList::GetFirstNode(__pLines); + while (pTextLineNode) + { + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + SysTryReturn(NID_GRP + , pTextLine + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineBounds = pTextLine->GetBounds(); + + width = Math::Max(width, lineBounds.width); + height += lineBounds.height; + + pTextLineNode = pTextLineNode->pNext; + } + + return r; +} + +int +TextColumn::GetHeight(int textIndex) const +{ + if (textIndex < 0) + { + return GetTotalHeight(); + } + + return __pCompositeText->GetHeight(textIndex); +} + +result +TextColumn::Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, + const TextObjectAlignment alignment, const TextObjectActionType action) +{ + result r = E_SUCCESS; + TextLine* pTextLine = null; + SimpleNode* pTextLineNode = null; + TextObjectActionType lineAction = TEXT_OBJECT_ACTION_TYPE_NONE; + Rectangle lineBounds; + + __displayLineCount = 0; + __displayHeight = 0; + + pTextLineNode = TextSimpleList::GetNthNode(__pLines, __firstDisplayLineIndex); + if (pTextLineNode == null) + { + return E_SUCCESS; + } + + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + if (__pLines->nodeCount < pTextLine->GetIndex()) + { + return E_SUCCESS; + } + + lineBounds = pTextLine->GetBounds(); + + if (__firstDisplayPositionY != lineBounds.y) + { + displayRect.y -= __firstDisplayPositionY - lineBounds.y; + displayRect.height += __firstDisplayPositionY - lineBounds.y; + __displayHeight -= __firstDisplayPositionY - lineBounds.y; + } + + while (pTextLineNode != null && 0 <= displayRect.height) + { + if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV) + { + TextLine* pNextTextLine = null; + if (pTextLineNode->pNext == null) + { + pNextTextLine = null; + } + else + { + pNextTextLine = static_cast < TextLine* >(pTextLineNode->pNext->pObject); + } + + if (pNextTextLine == null) + { + if (pTextLine->GetTextOffset() + pTextLine->GetTextLength() < __pCompositeText->GetTextLength()) + { + lineAction = TEXT_OBJECT_ACTION_TYPE_ABBREV; + } + } + else + { + Rectangle nextLineBounds; + if (__pLines->nodeCount < pNextTextLine->GetIndex()) + { + return E_SUCCESS; + } + + nextLineBounds = pNextTextLine->GetBounds(); + if (displayRect.height < (lineBounds.height + nextLineBounds.height)) + { + lineAction = TEXT_OBJECT_ACTION_TYPE_ABBREV; + } + } + } + + int lineLength = pTextLine->GetTextLength(); + + TextObjectAlignment horizontalAlignment = (TextObjectAlignment)(alignment & TEXT_ALIGNMASK_HORIZ); + r = pTextLine->Draw(canvasImpl, displayRect, 0, lineLength, horizontalAlignment, lineAction); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __displayLineCount++; + + if (lineBounds.height <= displayRect.height) + { + displayRect.height -= lineBounds.height; + displayRect.y += lineBounds.height; + __displayHeight += lineBounds.height; + } + else + { + lineBounds.height += displayRect.height; + break; + } + + if (lineAction == TEXT_OBJECT_ACTION_TYPE_ABBREV) + { + break; + } + + pTextLineNode = pTextLineNode->pNext; + if (pTextLineNode == null) + { + break; + } + + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + if (__pLines->nodeCount < pTextLine->GetIndex()) + { + return E_SUCCESS; + } + + lineBounds = pTextLine->GetBounds(); + } + + return E_SUCCESS; +} + +int +TextColumn::GetTextLength(void) const +{ + return __pCompositeText->GetTextLength(); +} + +int +TextColumn::GetLineIndexAtTextIndex(int textIndex) const +{ + SimpleNode* pTextLineNode = null; + TextLine* pTextLine = null; + int lineIndex = 0; + int lineOffset = 0; + int lineLength = 0; + int lineEndType = TEXT_RETBY_NORMAL; + + pTextLineNode = TextSimpleList::GetFirstNode(__pLines); + if (textIndex == 0 && (pTextLineNode != null)) + { + return 0; + } + + while (pTextLineNode) + { + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineOffset = pTextLine->GetTextOffset(); + lineLength = pTextLine->GetTextLength(); + lineEndType = pTextLine->GetEndType(); + + if (lineOffset <= textIndex) + { + if (textIndex < lineOffset + lineLength) + { + return lineIndex; + } + } + + lineIndex++; + pTextLineNode = pTextLineNode->pNext; + } + + if (__pCompositeText->GetTextLength() == textIndex) + { + return lineIndex - 1; + } + + return -1; +} + +int +TextColumn::GetLineIndexAtPositionY(int y) +{ + SimpleNode* pTextLineNode = null; + TextLine* pTextLine = null; + + int lineIndex = 0; + Rectangle lineBounds; + + if (GetTotalLineCount() == 0) + { + return 0; + } + + if (__pCachedLineNode == null) + { + pTextLineNode = TextSimpleList::GetFirstNode(__pLines); + while (pTextLineNode) + { + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineBounds = pTextLine->GetBounds(); + + if (y >= lineBounds.y && y < lineBounds.y + lineBounds.height) + { + __pCachedLineNode = pTextLineNode; + __cachedLineIndex = lineIndex; + __cachedLinePositionY = lineBounds.y; + return lineIndex; + } + + lineIndex++; + pTextLineNode = pTextLineNode->pNext; + } + } + else + { + bool searchForward = true; + + if (__cachedLinePositionY < y) + { + searchForward = true; + } + else if (y < __cachedLinePositionY) + { + searchForward = false; + } + else + { + return __cachedLineIndex; + } + + pTextLineNode = __pCachedLineNode; + lineIndex = __cachedLineIndex; + while (pTextLineNode) + { + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineBounds = pTextLine->GetBounds(); + + if (y >= lineBounds.y && y < lineBounds.y + lineBounds.height) + { + __pCachedLineNode = pTextLineNode; + __cachedLineIndex = lineIndex; + __cachedLinePositionY = lineBounds.y; + + return lineIndex; + } + + if (searchForward) + { + lineIndex++; + pTextLineNode = pTextLineNode->pNext; + } + else + { + lineIndex--; + pTextLineNode = pTextLineNode->pPrev; + } + } + } + + return lineIndex; +} + +int +TextColumn::GetTotalHeight(void) const +{ + SimpleNode* pTextLineNode = null; + TextLine* pTextLine = null; + Rectangle lineBounds; + int height = 0; + + pTextLineNode = TextSimpleList::GetFirstNode(__pLines); + while (pTextLineNode) + { + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + SysTryReturn(NID_GRP + , pTextLine + , 0, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineBounds = pTextLine->GetBounds(); + + height += lineBounds.height; + pTextLineNode = pTextLineNode->pNext; + } + + return height; +} + +int +TextColumn::GetLineHeightAt(int index) const +{ + TextLine* pTextLine = null; + pTextLine = static_cast < TextLine* >(TextSimpleList::GetNthObject(__pLines, index)); + + SysTryReturn(NID_GRP + , pTextLine + , 0, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + Rectangle lineRect; + lineRect = pTextLine->GetBounds(); + + return lineRect.height; +} + +int +TextColumn::GetTextLengthAt(int lineIndex) const +{ + TextLine* pTextLine = null; + + pTextLine = static_cast < TextLine* >(TextSimpleList::GetNthObject(__pLines, lineIndex)); + SysTryReturn(NID_GRP + , pTextLine + , 0, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + return pTextLine->GetTextLength(); +} + +int +TextColumn::GetFirstTextIndexAt(int lineIndex) const +{ + TextLine* pTextLine = null; + + pTextLine = static_cast < TextLine* >(TextSimpleList::GetNthObject(__pLines, lineIndex)); + SysTryReturn(NID_GRP + , pTextLine + , 0, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + return pTextLine->GetTextOffset(); +} + +result +TextColumn::Append(TextLine* pTextLine) +{ + SysTryReturn(NID_GRP + , pTextLine + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + TextSimpleList::AppendObject(__pLines, pTextLine); + __totalLineCount++; + + return E_SUCCESS; +} + +result +TextColumn::RemoveAllLines(void) +{ + TextLine* pTextLine = null; + + while (1) + { + pTextLine = static_cast < TextLine* >(TextSimpleList::DeleteNthObject(__pLines, 0)); + if (pTextLine == null) + { + break; + } + + delete pTextLine; + pTextLine = null; + } + + __totalLineCount = 0; + + return E_SUCCESS; +} + +result +TextColumn::Remove(TextLine* pTextLine) +{ + SysTryReturn(NID_GRP + , pTextLine + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + int index = pTextLine->GetIndex(); + + SimpleNode* pNode = TextSimpleList::GetNthNode(__pLines, index); + SysTryReturn(NID_GRP + , pNode + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get node."); + + bool r = TextSimpleList::DeleteNode(__pLines, pNode); + if (r == true) + { + return E_SUCCESS; + } + else + { + return E_SYSTEM; + } +} + +TextLine* +TextColumn::GetTextLine(int lineIndex) const +{ + SysTryReturn(NID_GRP + , 0 <= lineIndex || lineIndex < __totalLineCount + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + TextLine* pTextLine = static_cast < TextLine* >(TextSimpleList::GetNthObject(__pLines, lineIndex)); + + return pTextLine; +} + +result +TextColumn::SetChangeAction(ChangeAction changeAction, int textIndex, int textLength) +{ + SysTryReturn(NID_GRP + , changeAction == TEXT_CHANGE_INSERT || changeAction == TEXT_CHANGE_REMOVE || changeAction == TEXT_CHANGE_UNKONWN + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SysTryReturn(NID_GRP + , 0 <= textIndex + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + int textIndexBeforeChanged = textIndex; + int textLengthBeforeChanged = textLength; + int textIndexAfterChanged = 0; + int textLengthAfterChanged = 0; + + ChangeActionEventInfo* pChangeActionEventInfo = null; + SimpleNode* pCurrentChangeActionEventInfoNode = null; + ChangeActionEventInfo* pCurrentChangeActionEventInfo = null; + int currentChangeActionEventInfoIndex = 0; + + pCurrentChangeActionEventInfoNode = TextSimpleList::GetFirstNode(__pTextChangeActionList); + if (pCurrentChangeActionEventInfoNode) + { + pCurrentChangeActionEventInfo = static_cast < ChangeActionEventInfo* >(pCurrentChangeActionEventInfoNode->pObject); + } + + while (pCurrentChangeActionEventInfo) + { + bool isLineInserted = false; + bool isActionCollapsed = false; + ActionProcessResult actionEventResult = DoProcessTextAction(changeAction, textIndexBeforeChanged, + textLengthBeforeChanged, pCurrentChangeActionEventInfo, textIndexAfterChanged, textLengthAfterChanged); + + switch (actionEventResult) + { + case BEFORE_ACTION: + isLineInserted = true; + break; + + case MERGE_AND_BEFORE_ACTION: + isLineInserted = true; + textLengthBeforeChanged = textLengthAfterChanged; + break; + + case AFTER_ACTION: + textIndexBeforeChanged = textIndexAfterChanged; + break; + + case MERGE_ACTION: + textLengthBeforeChanged = -1; + break; + + case MERGE_AND_AFTER_ACTION: + textIndexBeforeChanged = textIndexAfterChanged; + textLengthBeforeChanged = textLengthAfterChanged; + break; + + case COLLAPSE_ACTION: + isActionCollapsed = true; + textLengthBeforeChanged = textLengthAfterChanged; + break; + + case ERROR_ACTION: + return false; + } + + if (isActionCollapsed) + { + TextSimpleList::DeleteNthObject(__pTextChangeActionList, currentChangeActionEventInfoIndex); + delete pCurrentChangeActionEventInfo; + pCurrentChangeActionEventInfo = null; + + if (textLengthBeforeChanged == 0) + { + textLengthBeforeChanged = -1; + break; + } + + pCurrentChangeActionEventInfoNode = TextSimpleList::GetNthNode(__pTextChangeActionList, + currentChangeActionEventInfoIndex); + if (pCurrentChangeActionEventInfoNode) + { + pCurrentChangeActionEventInfo = static_cast < ChangeActionEventInfo* >(pCurrentChangeActionEventInfoNode->pObject); + } + + continue; + } + + if (isLineInserted) + { + pChangeActionEventInfo = new (std::nothrow)ChangeActionEventInfo; + SysTryReturn(NID_GRP + , pChangeActionEventInfo + , E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pChangeActionEventInfo->action = changeAction; + pChangeActionEventInfo->changedTextIndex = textIndexBeforeChanged; + pChangeActionEventInfo->changedTextLength = textLengthBeforeChanged; + TextSimpleList::InsertObject(__pTextChangeActionList, pChangeActionEventInfo, + currentChangeActionEventInfoIndex); + + textLengthBeforeChanged = -1; + break; + } + + if (textLengthBeforeChanged < 0) + { + break; + } + + pCurrentChangeActionEventInfo = null; + + currentChangeActionEventInfoIndex++; + pCurrentChangeActionEventInfoNode = pCurrentChangeActionEventInfoNode->pNext; + if (pCurrentChangeActionEventInfoNode) + { + pCurrentChangeActionEventInfo = static_cast < ChangeActionEventInfo* >(pCurrentChangeActionEventInfoNode->pObject); + } + } + + if (0 <= textLengthBeforeChanged) + { + pChangeActionEventInfo = new (std::nothrow)ChangeActionEventInfo; + SysTryReturn(NID_GRP + , pChangeActionEventInfo + , E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pChangeActionEventInfo->action = changeAction; + pChangeActionEventInfo->changedTextIndex = textIndexBeforeChanged; + pChangeActionEventInfo->changedTextLength = textLengthBeforeChanged; + TextSimpleList::AppendObject(__pTextChangeActionList, pChangeActionEventInfo); + } + + __setChangeAction = true; + + return E_SUCCESS; +} + +int +TextColumn::GetChangedStrStartIndex(void) const +{ + SysTryReturn(NID_GRP + , __setChangeAction + , -1, E_INVALID_STATE, "[E_INVALID_STATE] This instance is set change action list yet."); + + ChangeActionEventInfo* pChangeActionEventInfo = null; + pChangeActionEventInfo = static_cast < ChangeActionEventInfo* >(TextSimpleList::GetFirstObject(__pTextChangeActionList)); + + if (pChangeActionEventInfo == null) + { + return -1; + } + + return pChangeActionEventInfo->changedTextIndex; +} + +result +TextColumn::PrepareCompose(void) +{ + __isComposeDone = false; + __pCachedLineNode = null; + + if (!__setChangeAction) + { + RemoveAllLines(); + __currentLineIndexToAddDuringCompose = 0; + __textOffsetOfNextLineAfterChangedLine = -1; + + return E_SUCCESS; + } + + result r = E_SUCCESS; + int textChangedStartIndex = 0; + int textChangedEndIndex = 0; + int textChangedLength = 0; + bool hasETCAction = false; + + r = GetTextChangedInfo(textChangedStartIndex, textChangedEndIndex, textChangedLength, hasETCAction); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = UpdateCompositionInfo(textChangedStartIndex, textChangedEndIndex, textChangedLength, hasETCAction); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__changedLastLineIndex != -1) + { + SysTryReturn(NID_GRP + , __changedStartLineIndex != -1 + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to update information."); + + int count = __changedLastLineIndex - __changedStartLineIndex + 1; + + KeepLines( __changedStartLineIndex, count); + RemoveLines(__changedStartLineIndex, count); + } + else + { + if (__changedStartLineIndex == -1) + { + RemoveAllLines(); + __currentLineIndexToAddDuringCompose = 0; + } + else + { + KeepLines( __prevLineIndexBeforeChangedStartLine, __totalLineCount - __prevLineIndexBeforeChangedStartLine); + + RemoveLinesFrom(__changedStartLineIndex); + __changedLastLineIndex = __changedStartLineIndex; + } + } + + if (__prevLineIndexBeforeChangedStartLine >= 0) + { + __currentLineIndexToAddDuringCompose = __prevLineIndexBeforeChangedStartLine + 1; + } + else + { + __currentLineIndexToAddDuringCompose = 0; + } + + return E_SUCCESS; + +CATCH: + RemoveAllLines(); + __currentLineIndexToAddDuringCompose = 0; + __textOffsetOfNextLineAfterChangedLine = -1; + __nextLineIndexAfterChangedLastLine = -1; + + return r; +} + +result +TextColumn::AddLineDuringCompose(TextLine* pTextLine) +{ + SysTryReturn(NID_GRP + , pTextLine + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + if (!__setChangeAction) + { + SimpleNode* pTextLineNode = TextSimpleList::InsertObject(__pLines, pTextLine, __currentLineIndexToAddDuringCompose); + if (pTextLineNode == null) + { + delete pTextLine; + pTextLine = null; + + return E_SYSTEM; + } + + pTextLine->SetIndex(__currentLineIndexToAddDuringCompose); + __currentLineIndexToAddDuringCompose++; + __totalLineCount++; + + return E_SUCCESS; + } + + TextSimpleList::InsertObject(__pLines, pTextLine, __currentLineIndexToAddDuringCompose); + + pTextLine->SetIndex(__currentLineIndexToAddDuringCompose); + __currentLineIndexToAddDuringCompose++; + __insertedLineCountDuringCompose++; + __totalLineCount++; + + if (__textOffsetOfNextLineAfterChangedLine == -1) + { + return E_SUCCESS; + } + + int lineOffset = pTextLine->GetTextOffset(); + int lineLength = pTextLine->GetTextLength(); + int lineEndType = pTextLine->GetEndType(); + + if (lineOffset + lineLength == __textOffsetOfNextLineAfterChangedLine) + { + TextElementType nextObjectType = __pCompositeText->GetObjectType(__textOffsetOfNextLineAfterChangedLine); + + if (nextObjectType == TEXT_ELEMENT_TYPE_TEXT || nextObjectType == TEXT_ELEMENT_TYPE_CUTLINK || + nextObjectType == TEXT_ELEMENT_TYPE_NONE) + { + if (lineEndType == TEXT_RETBY_LINEFEED) + { + __isComposeDone = true; + } + } + else + { + if (lineEndType == TEXT_RETBY_LINEFEED) + { + if (lineLength == 0) + { + __isComposeDone = true; + } + } + else + { + __isComposeDone = true; + } + } + } + + return E_SUCCESS; +} + +bool +TextColumn::IsComposeDone(void) +{ + return __isComposeDone; +} + +result +TextColumn::FinishCompose(bool isUpdateSweepInfo) +{ + __setChangeAction = false; + __isComposeDone = true; + + RemoveAllChangeActions(); + + if (__nextLineIndexAfterChangedLastLine < 0) + { + if (isUpdateSweepInfo) + { + UpdateSweepInfo(); + } + + RemoveAllKeepLines(); + __insertedLineCountDuringCompose = 0; + + return E_SUCCESS; + } + + int changedTextLength = __changedTextLength; + + SimpleNode* pTextLineNode = null; + TextLine* pTextLine = null; + Rectangle lineBounds; + + if (__currentLineIndexToAddDuringCompose == 0) + { + if (isUpdateSweepInfo) + { + UpdateSweepInfo(); + } + + RemoveAllKeepLines(); + __insertedLineCountDuringCompose = 0; + + return E_SUCCESS; + } + + pTextLineNode = TextSimpleList::GetNthNode(__pLines, __currentLineIndexToAddDuringCompose - 1); + SysTryReturn(NID_GRP + , pTextLineNode + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line node."); + + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineBounds = pTextLine->GetBounds(); + int nextLineY = lineBounds.y + lineBounds.height; + + pTextLineNode = TextSimpleList::GetNthNode(__pLines, __currentLineIndexToAddDuringCompose); + + while (pTextLineNode != null) + { + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + int lineOffset = pTextLine->GetTextOffset(); + lineOffset += changedTextLength; + lineBounds = pTextLine->GetBounds(); + lineBounds.y = nextLineY; + nextLineY += lineBounds.height; + + pTextLine->SetTextOffset(lineOffset); + pTextLine->SetBounds(lineBounds); + pTextLine->SetIndex(__currentLineIndexToAddDuringCompose); + __currentLineIndexToAddDuringCompose++; + + pTextLineNode = pTextLineNode->pNext; + } + + if (isUpdateSweepInfo) + { + UpdateSweepInfo(); + } + + RemoveAllKeepLines(); + __insertedLineCountDuringCompose = 0; + + return E_SUCCESS; +} + +TextLine* +TextColumn::GetPrevLineChangedStartLine(void) const +{ + SysTryReturn(NID_GRP + , __setChangeAction + , null, E_INVALID_STATE, "[E_INVALID_STATE] This instance is set change action list yet."); + + if (__prevLineIndexBeforeChangedStartLine < 0) + { + return null; + } + + TextLine* pTextLine = GetTextLine(__prevLineIndexBeforeChangedStartLine); + SysTryReturn(NID_GRP + , pTextLine + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + SetLastResult(E_SUCCESS); + + return pTextLine; +} + +result +TextColumn::RemoveLines(int lineIndex, int lineCount) +{ + SysTryReturn(NID_GRP + , 0 <= lineIndex || lineCount <= __totalLineCount + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pNextTextLineNode = null; + SimpleNode* pTextLineNode = null; + TextLine* pTextLine = null; + int count = 0; + + pTextLineNode = TextSimpleList::GetNthNode(__pLines, lineIndex); + + while ((pTextLineNode != null) && (count < lineCount)) + { + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + pNextTextLineNode = pTextLineNode->pNext; + + TextSimpleList::DeleteNode(__pLines, pTextLineNode); + + if (pTextLine != null) + { + delete pTextLine; + pTextLine = null; + } + + count++; + pTextLineNode = pNextTextLineNode; + } + + __totalLineCount -= count; + + return E_SUCCESS; +} + +int +TextColumn::GetChangeActionEventCount(void) const +{ + return __pTextChangeActionList->nodeCount; +} + +result +TextColumn::RemoveLinesFrom(int lineIndex) +{ + SysTryReturn(NID_GRP + , 0 <= lineIndex + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + TextLine* pTextLine = null; + int count = 0; + + pTextLine = static_cast < TextLine* >(TextSimpleList::DeleteNthObject(__pLines, lineIndex)); + while (pTextLine) + { + delete pTextLine; + pTextLine = static_cast < TextLine* >(TextSimpleList::DeleteNthObject(__pLines, lineIndex)); + count++; + } + + __totalLineCount -= count; + + return E_SUCCESS; +} + +void +TextColumn::RemoveAllChangeActions(void) +{ + ChangeActionEventInfo* pChangeActionEventInfo = null; + + pChangeActionEventInfo = static_cast < ChangeActionEventInfo* >(TextSimpleList::DeleteNthObject(__pTextChangeActionList, 0)); + while (pChangeActionEventInfo) + { + delete pChangeActionEventInfo; + pChangeActionEventInfo = static_cast < ChangeActionEventInfo* >(TextSimpleList::DeleteNthObject(__pTextChangeActionList, 0)); + } +} + +result +TextColumn::GetTextChangedInfo(int& changedStartTextIndex, int& changedEndTextIndex, int& changedTextLength, + bool& existUnkownAction) const +{ + SimpleNode* pChangeActionEventNode = null; + ChangeActionEventInfo* pChangeActionEventInfo = null; + + pChangeActionEventNode = TextSimpleList::GetFirstNode(__pTextChangeActionList); + SysTryReturn(NID_GRP + , pChangeActionEventNode + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get change action event information node."); + + pChangeActionEventInfo = static_cast < ChangeActionEventInfo* >(pChangeActionEventNode->pObject); + SysTryReturn(NID_GRP + , pChangeActionEventInfo + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get change action event information."); + + changedTextLength = 0; + changedStartTextIndex = -1; + changedEndTextIndex = -1; + existUnkownAction = false; + + while (pChangeActionEventInfo) + { + switch (pChangeActionEventInfo->action) + { + case TEXT_CHANGE_INSERT: + if (changedStartTextIndex == -1) + { + changedStartTextIndex = pChangeActionEventInfo->changedTextIndex; + } + changedTextLength += pChangeActionEventInfo->changedTextLength; + changedEndTextIndex = pChangeActionEventInfo->changedTextIndex; + break; + + case TEXT_CHANGE_REMOVE: + if (changedStartTextIndex == -1) + { + changedStartTextIndex = pChangeActionEventInfo->changedTextIndex; + } + changedTextLength -= pChangeActionEventInfo->changedTextLength; + changedEndTextIndex = pChangeActionEventInfo->changedTextIndex + pChangeActionEventInfo->changedTextLength; + break; + + case TEXT_CHANGE_UNKONWN: + existUnkownAction = true; + if (changedStartTextIndex == -1) + { + changedStartTextIndex = pChangeActionEventInfo->changedTextIndex; + } + break; + + default: + // fall through + return E_SYSTEM; + } + + pChangeActionEventNode = pChangeActionEventNode->pNext; + if (pChangeActionEventNode == null) + { + break; + } + + pChangeActionEventInfo = static_cast < ChangeActionEventInfo* >(pChangeActionEventNode->pObject); + } + + return E_SUCCESS; +} + +result +TextColumn::UpdateCompositionInfo(int changedStartTextIndex, int changedEndTextIndex, int changedTextLength, + bool existUnkownAction) +{ + __chagedStartTextIndex = changedStartTextIndex; + __changedTextLength = changedTextLength; + + int firstChangedLineIndex = GetLineIndexAtTextIndex(__chagedStartTextIndex); + if (firstChangedLineIndex == -1) + { + if (__chagedStartTextIndex + __changedTextLength >= __pCompositeText->GetTextLength()) + { + firstChangedLineIndex = __totalLineCount - 1; + } + else + { + firstChangedLineIndex = -1; + } + } + + __changedStartLineIndex = firstChangedLineIndex; + + if (__changedStartLineIndex == -1) + { + __nextLineIndexAfterChangedLastLine = -1; + __textOffsetOfNextLineAfterChangedLine = -1; + __changedLastLineIndex = -1; + __prevLineIndexBeforeChangedStartLine = -1; + return E_SUCCESS; + } + + __prevLineIndexBeforeChangedStartLine = __changedStartLineIndex - 1; + + if (__changedStartLineIndex == __totalLineCount - 1) + { + __nextLineIndexAfterChangedLastLine = -1; + __textOffsetOfNextLineAfterChangedLine = -1; + __changedLastLineIndex = -1; + return E_SUCCESS; + } + + if (existUnkownAction) + { + __changedLastLineIndex = __totalLineCount - 1; + __nextLineIndexAfterChangedLastLine = -1; + __textOffsetOfNextLineAfterChangedLine = -1; + return E_SUCCESS; + } + + int lastChangedLineIndex = GetLineIndexAtTextIndex(changedEndTextIndex); + if (lastChangedLineIndex == -1) + { + __changedLastLineIndex = __totalLineCount - 1; + __nextLineIndexAfterChangedLastLine = -1; + __textOffsetOfNextLineAfterChangedLine = -1; + return E_SUCCESS; + } + + int nextLineIndexAfterChangedLineCandidate = lastChangedLineIndex; + + __nextLineIndexAfterChangedLastLine = -1; + + SimpleNode* pTextLineNode = null; + TextLine* pTextLine = null; + + pTextLineNode = TextSimpleList::GetNthNode(__pLines, nextLineIndexAfterChangedLineCandidate); + while (pTextLineNode) + { + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + int lineEndType = pTextLine->GetEndType(); + if ((lineEndType == TEXT_RETBY_LINEFEED) && (pTextLine->GetTextLength() != 0)) + { + pTextLineNode = pTextLineNode->pNext; + if (pTextLineNode == null) + { + break; + } + + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + __nextLineIndexAfterChangedLastLine = nextLineIndexAfterChangedLineCandidate + 1; + break; + } + + pTextLineNode = pTextLineNode->pNext; + nextLineIndexAfterChangedLineCandidate++; + } + + if (__nextLineIndexAfterChangedLastLine > 0) + { + __textOffsetOfNextLineAfterChangedLine = pTextLine->GetTextOffset(); + __textOffsetOfNextLineAfterChangedLine += __changedTextLength; + __changedLastLineIndex = __nextLineIndexAfterChangedLastLine - 1; + } + else + { + __textOffsetOfNextLineAfterChangedLine = -1; + __changedLastLineIndex = __totalLineCount - 1; + } + + return E_SUCCESS; +} + +TextColumn::ActionProcessResult +TextColumn::DoProcessTextAction(ChangeAction inputAction, int textIndex, int textLength, + ChangeActionEventInfo* pCurrentStrActionEventInfo, int& changedStartTextIndex, + int& strOutputChangedNum) +{ + switch (inputAction) + { + case TextColumn::TEXT_CHANGE_INSERT: + { + switch (pCurrentStrActionEventInfo->action) + { + case TextColumn::TEXT_CHANGE_INSERT: + return DoProcessInsertThroughInsert(textIndex, textLength, pCurrentStrActionEventInfo, + changedStartTextIndex); + + case TextColumn::TEXT_CHANGE_REMOVE: + return DoProcessInsertThroughRemove(textIndex, pCurrentStrActionEventInfo, changedStartTextIndex); + + case TextColumn::TEXT_CHANGE_UNKONWN: + changedStartTextIndex = textIndex; + return DoProcessInsertThroughUnkown(textIndex, pCurrentStrActionEventInfo); + + default: + break; + } + } + break; + + case TextColumn::TEXT_CHANGE_REMOVE: + { + switch (pCurrentStrActionEventInfo->action) + { + case TextColumn::TEXT_CHANGE_INSERT: + return DoProcessRemoveThroughInsert(textIndex, textLength, pCurrentStrActionEventInfo, + changedStartTextIndex, strOutputChangedNum); + + case TextColumn::TEXT_CHANGE_REMOVE: + return DoProcessRemoveThroughRemove(textIndex, pCurrentStrActionEventInfo, changedStartTextIndex); + + case TextColumn::TEXT_CHANGE_UNKONWN: + changedStartTextIndex = textIndex; + return DoProcessRemoveThroughUnkown(textIndex, pCurrentStrActionEventInfo); + + default: + break; + } + } + break; + + case TextColumn::TEXT_CHANGE_UNKONWN: + { + switch (pCurrentStrActionEventInfo->action) + { + case TextColumn::TEXT_CHANGE_INSERT: + return DoProcessUnkownThroughInsert(textIndex, pCurrentStrActionEventInfo, changedStartTextIndex); + + case TextColumn::TEXT_CHANGE_REMOVE: + return DoProcessUnkownThroughRemove(textIndex, pCurrentStrActionEventInfo, changedStartTextIndex); + + case TextColumn::TEXT_CHANGE_UNKONWN: + changedStartTextIndex = textIndex; + return DoProcessUnknownThroughUnknown(textIndex, pCurrentStrActionEventInfo); + + default: + break; + } + } + break; + + default: + break; + } + + return ERROR_ACTION; +} + +TextColumn::ActionProcessResult +TextColumn::DoProcessUnknownThroughUnknown(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo) +{ + if (textIndex < pCurrentActionEventInfo->changedTextIndex) + { + return BEFORE_ACTION; + } + else if (textIndex == pCurrentActionEventInfo->changedTextIndex) + { + return MERGE_ACTION; + } + else + { + return AFTER_ACTION; + } +} + +TextColumn::ActionProcessResult +TextColumn::DoProcessUnkownThroughInsert(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo, + int& changedStartTextIndex) +{ + if (textIndex < pCurrentActionEventInfo->changedTextIndex) + { + changedStartTextIndex = textIndex; + return BEFORE_ACTION; + } + + if (textIndex < pCurrentActionEventInfo->changedTextIndex + pCurrentActionEventInfo->changedTextLength) + { + changedStartTextIndex = pCurrentActionEventInfo->changedTextIndex; + return BEFORE_ACTION; + } + + changedStartTextIndex = textIndex - pCurrentActionEventInfo->changedTextLength; + return AFTER_ACTION; +} + +TextColumn::ActionProcessResult +TextColumn::DoProcessUnkownThroughRemove(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo, + int& changedStartTextIndex) +{ + if (textIndex < pCurrentActionEventInfo->changedTextIndex) + { + changedStartTextIndex = textIndex; + return BEFORE_ACTION; + } + + changedStartTextIndex = textIndex + pCurrentActionEventInfo->changedTextLength; + return AFTER_ACTION; +} + +TextColumn::ActionProcessResult +TextColumn::DoProcessInsertThroughUnkown(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo) +{ + if (textIndex < pCurrentActionEventInfo->changedTextIndex) + { + return BEFORE_ACTION; + } + + return AFTER_ACTION; +} + +TextColumn::ActionProcessResult +TextColumn::DoProcessInsertThroughInsert(int textIndex, int textLength, ChangeActionEventInfo* pCurrentActionEventInfo, + int& changedStartTextIndex) +{ + if (textIndex < pCurrentActionEventInfo->changedTextIndex) + { + return BEFORE_ACTION; + } + + if (textIndex <= pCurrentActionEventInfo->changedTextIndex + pCurrentActionEventInfo->changedTextLength) + { + pCurrentActionEventInfo->changedTextLength += textLength; + return MERGE_ACTION; + } + + changedStartTextIndex = textIndex - pCurrentActionEventInfo->changedTextLength; + return AFTER_ACTION; +} + +TextColumn::ActionProcessResult +TextColumn::DoProcessInsertThroughRemove(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo, + int& changedStartTextIndex) +{ + if (textIndex < pCurrentActionEventInfo->changedTextIndex) + { + return BEFORE_ACTION; + } + + changedStartTextIndex = textIndex + pCurrentActionEventInfo->changedTextLength; + return AFTER_ACTION; +} + +TextColumn::ActionProcessResult +TextColumn::DoProcessRemoveThroughUnkown(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo) +{ + if (textIndex < pCurrentActionEventInfo->changedTextIndex) + { + return BEFORE_ACTION; + } + + return AFTER_ACTION; +} + +TextColumn::ActionProcessResult +TextColumn::DoProcessRemoveThroughInsert(int textIndex, int textLength, + ChangeActionEventInfo* pCurrentActionEventInfo, int& changedStartTextIndex, + int& strOutputChangedNum) +{ + if (textIndex + textLength <= pCurrentActionEventInfo->changedTextIndex) + { + return BEFORE_ACTION; + } + + if (textIndex >= pCurrentActionEventInfo->changedTextIndex + pCurrentActionEventInfo->changedTextLength) + { + changedStartTextIndex = textIndex - pCurrentActionEventInfo->changedTextLength; + + return AFTER_ACTION; + } + + if ((textIndex <= pCurrentActionEventInfo->changedTextIndex) && + (textIndex + textLength >= pCurrentActionEventInfo->changedTextIndex + + pCurrentActionEventInfo->changedTextLength)) + { + changedStartTextIndex = textIndex; + strOutputChangedNum = textLength - pCurrentActionEventInfo->changedTextLength; + + return COLLAPSE_ACTION; + } + + if ((textIndex >= pCurrentActionEventInfo->changedTextIndex) && + (textIndex + textLength <= pCurrentActionEventInfo->changedTextIndex + + pCurrentActionEventInfo->changedTextLength)) + { + pCurrentActionEventInfo->changedTextLength -= textLength; + return MERGE_ACTION; + } + + if ((textIndex < pCurrentActionEventInfo->changedTextIndex) && + (textIndex + textLength > pCurrentActionEventInfo->changedTextIndex)) + { + int mergedLength = textIndex + textLength - pCurrentActionEventInfo->changedTextIndex; + pCurrentActionEventInfo->changedTextLength -= mergedLength; + strOutputChangedNum -= mergedLength; + return MERGE_AND_BEFORE_ACTION; + } + + if ((textIndex >= pCurrentActionEventInfo->changedTextIndex) && + (textIndex < pCurrentActionEventInfo->changedTextIndex + pCurrentActionEventInfo->changedTextLength)) + { + int mergedLength = pCurrentActionEventInfo->changedTextIndex + pCurrentActionEventInfo->changedTextLength + - textIndex; + pCurrentActionEventInfo->changedTextLength -= mergedLength; + changedStartTextIndex = textIndex + 1; + strOutputChangedNum -= mergedLength; + return MERGE_AND_AFTER_ACTION; + } + + return ERROR_ACTION; +} + +TextColumn::ActionProcessResult +TextColumn::DoProcessRemoveThroughRemove(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo, + int& changedStartTextIndex) +{ + if (textIndex < pCurrentActionEventInfo->changedTextIndex) + { + return BEFORE_ACTION; + } + + changedStartTextIndex += pCurrentActionEventInfo->changedTextLength; + return AFTER_ACTION; +} + +int +TextColumn::GetTotalLineCount(void) const +{ + return __totalLineCount; +} + +int +TextColumn::GetDisplayLineCount(void) const +{ + return __displayLineCount; +} + +void +TextColumn::SetDisplayLineCount(int displayLineCount) +{ + __displayLineCount = displayLineCount; +} + +void +TextColumn::SetFirstDisplayLineIndex(int lineIndex) +{ + __firstDisplayLineIndex = lineIndex; +} + +int +TextColumn::GetFirstDisplayLineIndex(void) const +{ + return __firstDisplayLineIndex; +} + +void +TextColumn::SetFirstDisplayPositionY(int y) +{ + __firstDisplayPositionY = y; +} + +int +TextColumn::GetFirstDisplayPositionY(void) const +{ + return __firstDisplayPositionY; +} + +void +TextColumn::SetDisplayHeight(int height) +{ + __displayHeight = height; +} + +int +TextColumn::GetDisplayHeight(void) const +{ + return __displayHeight; +} + +SimpleNode* +TextColumn::GetTextLineNode(int lineIndex) const +{ + return TextSimpleList::GetNthNode(__pLines, lineIndex); +} + +result +TextColumn::SetSlidingDimension(Dimension& slidingDimension) +{ + SysTryReturn(NID_GRP + , slidingDimension.width >= 0 && slidingDimension.height >=0 + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + __slidingDimension = slidingDimension; + + return E_SUCCESS; +} + +Dimension +TextColumn::GetSlidingDimension(void) const +{ + return __slidingDimension; +} + +void +TextColumn::SetSlidingPosition(int slidingPosition) +{ + __slidingPosition = slidingPosition; +} + +int +TextColumn::GetSlidingPosition(void) const +{ + return __slidingPosition; +} + +void +TextColumn::SetChangedStartLineIndex(int changedStartLineIndex) +{ + __changedStartLineIndex = changedStartLineIndex; +} + +int +TextColumn::GetChangedStartLineIndex(void) const +{ + return __changedStartLineIndex; +} + +void +TextColumn::SetChangedLastLineIndex(int changedLastLineIndex) +{ + __changedLastLineIndex = changedLastLineIndex; +} + +int +TextColumn::GetChangedLastLineIndex(void) const +{ + return __changedLastLineIndex; +} + +int +TextColumn::ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, + int& actualLength, int& width, int& height) +{ + return -1; +} + +result +TextColumn::RemoveAllKeepLines(void) +{ + SysTryReturn(NID_GRP + , __pKeepLines + , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet."); + + TextLine* pTextLine = null; + + while (1) + { + pTextLine = static_cast < TextLine* >(TextSimpleList::DeleteNthObject(__pKeepLines, 0)); + if (pTextLine == null) + { + break; + } + + delete pTextLine; + pTextLine = null; + } + + __keepLineCount = 0; + + return E_SUCCESS; +} + +result +TextColumn::UpdateSweepInfoFirstLine(void) +{ + TextObjectSweepInfo textSweepInfo; + __pCompositeText->GetTextSweepInfo(textSweepInfo); + + Dimension lineSize; + int width = 0; + SimpleNode* pTextLineNode = null; + TextLine* pTextLine; + int sweepLineCount = 0; + int insertedLineCount = 0; + + pTextLineNode = TextSimpleList::GetFirstNode(__pLines); + + while (pTextLineNode != null) + { + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + pTextLine->GetRegion(0, pTextLine->GetTextLength(), lineSize.width, lineSize.height); + width += lineSize.width; + sweepLineCount++; + insertedLineCount++; + + pTextLineNode = pTextLineNode->pNext; + } + + textSweepInfo.isValid = true; + textSweepInfo.sweepType = ((1 < sweepLineCount) ? TEXT_OBJECT_SWEEP_TYPE_FORWARD : TEXT_OBJECT_SWEEP_TYPE_KEYINPUT); + textSweepInfo.anchorLineIndex = 0; + textSweepInfo.sweepRegionStartLineIndex = 0; + textSweepInfo.sweepRegionLineCount = sweepLineCount; + textSweepInfo.widthChanged = width; + textSweepInfo.insertedLineCount = insertedLineCount; + textSweepInfo.deletedLineCount = 0; + + __pCompositeText->UpdateTextSweepInfo(&textSweepInfo); + + return true; +} + +result +TextColumn::UpdateSweepInfo(void) +{ + if (TextSimpleList::IsEmpty(__pKeepLines)) + { + return UpdateSweepInfoFirstLine(); + } + + TextObjectSweepInfo textSweepInfo; + __pCompositeText->GetTextSweepInfo(textSweepInfo); + + SimpleNode* pOldTextLineNode = null; + SimpleNode* pNewTextLineNode = null; + TextLine* pOldTextLine = null; + TextLine* pNewTextLine = null; + Dimension oldLineSize; + Dimension newLineSize; + int oldLineWidth = 0; + int newLineWidth = 0; + int sweepLineCount = 0; + int changedStartLineIndex = 0; + int insertedLineCount = 0; + int deleteLineCount = 0; + + int anchorLineIndex = GetLineIndexAtTextIndex(textSweepInfo.anchorTextIndex); + if (anchorLineIndex == -1) + { + anchorLineIndex = GetTotalLineCount() - 1; + } + + int widthChanged = 0; + TextObjectSweepType sweepType = TEXT_OBJECT_SWEEP_TYPE_INVALID; + + pOldTextLineNode = TextSimpleList::GetFirstNode(__pKeepLines); + if (pOldTextLineNode == null) + { + return E_SUCCESS; + } + + pOldTextLine = static_cast < TextLine* >(pOldTextLineNode->pObject); + changedStartLineIndex = pOldTextLine->GetIndex(); + pNewTextLineNode = TextSimpleList::GetNthNode(__pLines, changedStartLineIndex); + + while (pOldTextLineNode || pNewTextLineNode) + { + TextObjectSweepComposeLineInfo textSweepComposeLineInfo; + + if (pOldTextLineNode == null) + { + pNewTextLine = static_cast < TextLine* >(pNewTextLineNode->pObject); + + if (pNewTextLine->GetIndex() >= changedStartLineIndex + __insertedLineCountDuringCompose) + { + break; + } + + pNewTextLine->GetRegion(0, pNewTextLine->GetTextLength(), newLineSize.width, newLineSize.height); + + newLineWidth += newLineSize.width; + sweepLineCount++; + insertedLineCount++; + + textSweepComposeLineInfo.isValid = true; + textSweepComposeLineInfo.prevLineTextOffset = 0; + textSweepComposeLineInfo.prevLineTextLength = 0; + textSweepComposeLineInfo.prevLineWidth = 0; + textSweepComposeLineInfo.currentLineTextOffset = pNewTextLine->GetTextOffset(); + textSweepComposeLineInfo.currentLineTextLength = pNewTextLine->GetTextLength(); + textSweepComposeLineInfo.currentLineWidth = newLineSize.width; + + pNewTextLine->SetSweepComposeInfo(textSweepComposeLineInfo); + + sweepType = TEXT_OBJECT_SWEEP_TYPE_FORWARD; + + pNewTextLineNode = pNewTextLineNode->pNext; + } + else if (pNewTextLineNode == null) + { + pOldTextLine = static_cast < TextLine* >(pOldTextLineNode->pObject); + pOldTextLine->GetRegion(0, pOldTextLine->GetTextLength(), oldLineSize.width, oldLineSize.height); + + oldLineWidth += oldLineSize.width; + sweepLineCount++; + deleteLineCount++; + sweepType = TEXT_OBJECT_SWEEP_TYPE_BACKWARD; + + pOldTextLineNode = pOldTextLineNode->pNext; + } + else + { + pOldTextLine = static_cast < TextLine* >(pOldTextLineNode->pObject); + pNewTextLine = static_cast < TextLine* >(pNewTextLineNode->pObject); + + if (pNewTextLine->GetIndex() > changedStartLineIndex + __insertedLineCountDuringCompose) + { + pOldTextLine->GetRegion(0, pOldTextLine->GetTextLength(), oldLineSize.width, oldLineSize.height); + + oldLineWidth += oldLineSize.width; + sweepLineCount++; + + sweepType = TEXT_OBJECT_SWEEP_TYPE_BACKWARD; + + pOldTextLineNode = pOldTextLineNode->pNext; + pNewTextLineNode = pNewTextLineNode->pNext; + + continue; + } + + pOldTextLine->GetRegion(0, pOldTextLine->GetTextLength(), oldLineSize.width, oldLineSize.height); + pNewTextLine->GetRegion(0, pNewTextLine->GetTextLength(), newLineSize.width, newLineSize.height); + + if ((oldLineSize.width == newLineSize.width) && (pOldTextLine->GetTextLength() == pNewTextLine->GetTextLength())) + { + if (pNewTextLine->GetIndex() == changedStartLineIndex) + { + changedStartLineIndex++; + } + else + { + break; + } + } + else + { + oldLineWidth += oldLineSize.width; + newLineWidth += newLineSize.width; + sweepLineCount++; + + textSweepComposeLineInfo.isValid = true; + textSweepComposeLineInfo.prevLineTextOffset = pOldTextLine->GetTextOffset(); + textSweepComposeLineInfo.prevLineTextLength = pOldTextLine->GetTextLength(); + textSweepComposeLineInfo.prevLineWidth = oldLineSize.width; + textSweepComposeLineInfo.currentLineTextOffset = pNewTextLine->GetTextOffset(); + textSweepComposeLineInfo.currentLineTextLength = pNewTextLine->GetTextLength(); + textSweepComposeLineInfo.currentLineWidth = newLineSize.width; + pNewTextLine->SetSweepComposeInfo(textSweepComposeLineInfo); + } + + pOldTextLineNode = pOldTextLineNode->pNext; + pNewTextLineNode = pNewTextLineNode->pNext; + } + } + + widthChanged = newLineWidth - oldLineWidth; + + if (sweepLineCount == 1) + { + sweepType = TEXT_OBJECT_SWEEP_TYPE_KEYINPUT; + } + + if (sweepType == TEXT_OBJECT_SWEEP_TYPE_INVALID) + { + sweepType = ((oldLineSize.width < newLineSize.width) ? TEXT_OBJECT_SWEEP_TYPE_FORWARD : TEXT_OBJECT_SWEEP_TYPE_BACKWARD); + } + + if (anchorLineIndex == -1) + { + anchorLineIndex = pNewTextLine->GetIndex(); + } + + textSweepInfo.isValid = true; + textSweepInfo.sweepType = sweepType; + textSweepInfo.anchorLineIndex = anchorLineIndex; + textSweepInfo.sweepRegionStartLineIndex = changedStartLineIndex; + textSweepInfo.sweepRegionLineCount = sweepLineCount; + textSweepInfo.widthChanged = widthChanged; + textSweepInfo.insertedLineCount = insertedLineCount; + textSweepInfo.deletedLineCount = deleteLineCount; + + __pCompositeText->UpdateTextSweepInfo(&textSweepInfo); + + return true; +} + +result +TextColumn::KeepLines(int lineIndex, int lineCount) +{ + SimpleNode* pTextLineNode = null; + SimpleNode* pNextTextLineNode = null; + TextLine* pTextLine = null; + TextLine* pKeepTextLine = null; + int deletedLineCount = 0; + + if (lineIndex < 0) + { + lineIndex = 0; + lineCount--; + } + + pTextLineNode = TextSimpleList::GetNthNode(__pLines, lineIndex); + + while ((pTextLineNode != null) && (deletedLineCount < lineCount)) + { + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + pKeepTextLine = pTextLine->CopyN(); + + pNextTextLineNode = pTextLineNode->pNext; + + TextSimpleList::AppendObject(__pKeepLines, pKeepTextLine); + + deletedLineCount++; + + pTextLineNode = pNextTextLineNode; + } + + __keepLineCount += deletedLineCount; + + return E_SUCCESS; +} + +result +TextColumn::SetKeyInputLine(int changedStartlineIndex, int lineCount) +{ + int keyInputTextIndex = 0; + int keyInputTextLength = 0; + + SimpleNode* pTextLineNode = null; + TextLine* pTextLine = null; + int changedLineCount = lineCount; + + __pCompositeText->GetRange(keyInputTextIndex, keyInputTextLength); + + pTextLineNode = TextSimpleList::GetNthNode(__pLines, changedStartlineIndex); + while (pTextLineNode != null && changedLineCount) + { + pTextLine = static_cast < TextLine* >(pTextLineNode->pObject); + + if (pTextLine->GetTextOffset() <= keyInputTextIndex && keyInputTextIndex < pTextLine->GetTextOffset() + pTextLine->GetTextLength()) + { + pTextLine->NotifyLineChanged(true); + pTextLine->SetKeyInputOffset(keyInputTextIndex - pTextLine->GetTextOffset()); + pTextLine->SetKeyInputLength(keyInputTextLength); + + break; + } + + changedLineCount--; + + pTextLineNode = pTextLineNode->pNext; + } + + return E_SUCCESS; +} + +result +TextColumn::CompareDeletedLine(void) +{ + result r = E_SUCCESS; + + SimpleNode* pOldTextLineNode = null; + SimpleNode* pNewTextLineNode = null; + TextLine* pOldTextLine = null; + TextLine* pNewTextLine = null; + + Dimension newLineSize; + Dimension oldLineSize; + int sweepResult = 0; + int sweepIn = 0; + int sweepOut = 0; + int prevLineSweepIn = 0; + int prevLineSweepOut = 0; + int changedStartLineIndex = 0; + int keyInputWidth = 0; + + if (TextSimpleList::GetCount(__pKeepLines) == 0) + { + return E_SUCCESS; // E_SUCCESS right?? + } + + keyInputWidth = __pCompositeText->GetWorkWidth(); + pOldTextLineNode = TextSimpleList::GetFirstNode(__pKeepLines); + SysTryReturn(NID_GRP + , pOldTextLineNode + , E_SYSTEM, E_SYSTEM + , "[E_SYSTEM] Fail to get text line node."); + + pOldTextLine = static_cast < TextLine* >(pOldTextLineNode->pObject); + changedStartLineIndex = pOldTextLine->GetIndex(); + pNewTextLineNode = TextSimpleList::GetNthNode(__pLines, changedStartLineIndex); + SysTryReturn(NID_GRP + , pNewTextLineNode + , E_INVALID_STATE, E_INVALID_STATE + , "[E_INVALID_STATE] This instance is not constructed yet. changedStartLineIndex = %d", changedStartLineIndex); + + r = SetKeyInputLine(changedStartLineIndex, TextSimpleList::GetCount(__pLines) - changedStartLineIndex); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pOldTextLine = static_cast < TextLine* >(pOldTextLineNode->pObject); + pNewTextLine = static_cast < TextLine* >(pNewTextLineNode->pObject); + + pOldTextLine->GetRegion(0, pOldTextLine->GetTextLength(), oldLineSize.width, oldLineSize.height); + pNewTextLine->GetRegion(0, pNewTextLine->GetTextLength(), newLineSize.width, newLineSize.height); + + + if (oldLineSize.width == newLineSize.width) + { + sweepResult = NOT_CHANGED; + + pNewTextLine->SetKeyInputResult(sweepResult); + pNewTextLine->SetSweepIn(0); + pNewTextLine->SetSweepOut(0); + + pOldTextLineNode = pOldTextLineNode->pNext; + pNewTextLineNode = pNewTextLineNode->pNext; + + if (pOldTextLineNode && pNewTextLineNode) + { + + pOldTextLine = static_cast < TextLine* >(pOldTextLineNode->pObject); + pNewTextLine = static_cast < TextLine* >(pNewTextLineNode->pObject); + + pOldTextLine->GetRegion(0, pOldTextLine->GetTextLength(), oldLineSize.width, oldLineSize.height); + pNewTextLine->GetRegion(0, pNewTextLine->GetTextLength(), newLineSize.width, newLineSize.height); + + if (0 < keyInputWidth) + { + sweepResult = FORWARD_SWEEP; + + sweepIn = 0; + sweepOut = oldLineSize.width - newLineSize.width; + if (pNewTextLine->isChanged()) + { + sweepOut += keyInputWidth; + } + + pNewTextLine->SetKeyInputResult(sweepResult); + pNewTextLine->SetSweepIn(sweepIn); + pNewTextLine->SetSweepOut(sweepOut); + } + else + { + sweepResult = BACKWARD_SWEEP; + + sweepIn = newLineSize.width - oldLineSize.width; + sweepOut = 0; + if (pNewTextLine->isChanged()) + { + sweepIn -= keyInputWidth; + } + + pNewTextLine->SetKeyInputResult(sweepResult); + pNewTextLine->SetSweepIn(sweepIn); + pNewTextLine->SetSweepOut(sweepOut); + } + } + } + else if (oldLineSize.width < newLineSize.width) + { + sweepResult = BACKWARD_SWEEP; + + sweepIn = newLineSize.width - oldLineSize.width; + sweepOut = 0; + if (pNewTextLine->isChanged()) + { + sweepIn -= keyInputWidth; + } + + pNewTextLine->SetKeyInputResult(sweepResult); + pNewTextLine->SetSweepIn(sweepIn); + pNewTextLine->SetSweepOut(sweepOut); + } + else + { + sweepResult = FORWARD_SWEEP; + + sweepIn = 0; + sweepOut = oldLineSize.width - newLineSize.width; + if (pNewTextLine->isChanged()) + { + sweepOut += keyInputWidth; + } + + pNewTextLine->SetKeyInputResult(sweepResult); + pNewTextLine->SetSweepIn(sweepIn); + pNewTextLine->SetSweepOut(sweepOut); + } + + pOldTextLineNode = TextSimpleList::GetFirstNode(__pKeepLines); + SysTryReturn(NID_GRP + , pOldTextLineNode + , E_SYSTEM, E_SYSTEM + , "[E_SYSTEM] Fail to get text line node."); + + pNewTextLineNode = TextSimpleList::GetNthNode(__pLines, changedStartLineIndex); + SysTryReturn(NID_GRP + , pNewTextLineNode + , E_SYSTEM, E_SYSTEM + , "[E_SYSTEM] Fail to get text line node."); + + prevLineSweepIn = pNewTextLine->GetSweepIn(); + prevLineSweepOut = pNewTextLine->GetSweepOut(); + + pOldTextLineNode = pOldTextLineNode->pNext; + pNewTextLineNode = pNewTextLineNode->pNext; + + switch (sweepResult) + { + case BACKWARD_SWEEP: + while (pOldTextLineNode != null && pNewTextLineNode != null) + { + pOldTextLine = static_cast < TextLine* >(pOldTextLineNode->pObject); + pNewTextLine = static_cast < TextLine* >(pNewTextLineNode->pObject); + + pOldTextLine->GetRegion(0, pOldTextLine->GetTextLength(), oldLineSize.width, oldLineSize.height); + pNewTextLine->GetRegion(0, pNewTextLine->GetTextLength(), newLineSize.width, newLineSize.height); + + if (oldLineSize.width == newLineSize.width) + { + if (pOldTextLine->GetTextLength() == pNewTextLine->GetTextLength()) + { + pNewTextLine->SetKeyInputResult(NOT_CHANGED); + pNewTextLine->SetSweepIn(0); + pNewTextLine->SetSweepOut(0); + + break; + } + } + + sweepIn = newLineSize.width - oldLineSize.width + prevLineSweepIn; + sweepOut = prevLineSweepIn; + + if (pNewTextLine->isChanged()) + { + sweepIn -= keyInputWidth; + } + + pNewTextLine->SetKeyInputResult(BACKWARD_SWEEP); + pNewTextLine->SetSweepIn(sweepIn); + pNewTextLine->SetSweepOut(sweepOut); + + prevLineSweepIn = pNewTextLine->GetSweepIn(); + pOldTextLineNode = pOldTextLineNode->pNext; + pNewTextLineNode = pNewTextLineNode->pNext; + } + + break; + + case FORWARD_SWEEP: + while (pNewTextLineNode != null) + { + if (pOldTextLineNode == null) + { + pNewTextLine = static_cast < TextLine* >(pNewTextLineNode->pObject); + + pNewTextLine->SetKeyInputResult(FORWARD_SWEEP); + pNewTextLine->SetSweepIn(prevLineSweepOut); + pNewTextLine->SetSweepOut(0); + + break; + } + + pOldTextLine = static_cast < TextLine* >(pOldTextLineNode->pObject); + pNewTextLine = static_cast < TextLine* >(pNewTextLineNode->pObject); + + pOldTextLine->GetRegion(0, pOldTextLine->GetTextLength(), oldLineSize.width, oldLineSize.height); + pNewTextLine->GetRegion(0, pNewTextLine->GetTextLength(), newLineSize.width, newLineSize.height); + + if (oldLineSize.width == newLineSize.width) + { + if (pOldTextLine->GetTextLength() == pNewTextLine->GetTextLength()) + { + pNewTextLine->SetKeyInputResult(NOT_CHANGED); + pNewTextLine->SetSweepIn(0); + pNewTextLine->SetSweepOut(0); + + break; + } + } + + sweepIn = prevLineSweepOut; + sweepOut = oldLineSize.width - newLineSize.width + prevLineSweepOut; + + if (pNewTextLine->isChanged()) + { + sweepOut += keyInputWidth; + } + + pNewTextLine->SetKeyInputResult(FORWARD_SWEEP); + pNewTextLine->SetSweepIn(sweepIn); + pNewTextLine->SetSweepOut(sweepOut); + + prevLineSweepOut = pNewTextLine->GetSweepOut(); + pOldTextLineNode = pOldTextLineNode->pNext; + pNewTextLineNode = pNewTextLineNode->pNext; + } + + break; + + case NOT_CHANGED: + default: + break; + } + + return E_SUCCESS; +} + + +}}} // Tizen::Graphics::Text diff --git a/src/graphics/text/FGrp_TextTextColumn.h b/src/graphics/text/FGrp_TextTextColumn.h new file mode 100644 index 0000000..db58d4a --- /dev/null +++ b/src/graphics/text/FGrp_TextTextColumn.h @@ -0,0 +1,251 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextColumn.h + * @brief This file contains the declarations of TextColumn class. +*/ + +#ifndef _FGRP_INTERNAL_TEXT_COLUMN_H_ +#define _FGRP_INTERNAL_TEXT_COLUMN_H_ + +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextSimpleList.h" + +namespace Tizen { namespace Graphics +{ +class _CanvasImpl; + +namespace _Text +{ +class TextComposite; +class TextLine; +struct ChangeActionEventInfo; + +class TextColumn +{ +public: + enum ChangeAction + { + TEXT_CHANGE_INSERT = 0, + TEXT_CHANGE_REMOVE, + TEXT_CHANGE_REPLACE, + TEXT_CHANGE_UNKONWN + }; + + enum ActionProcessResult + { + BEFORE_ACTION = 0, + AFTER_ACTION, + MERGE_ACTION, + MERGE_AND_BEFORE_ACTION, + MERGE_AND_AFTER_ACTION, + COLLAPSE_ACTION, + ERROR_ACTION + }; + + enum KeyInputResult + { + NOT_CHANGED = 0, + FORWARD_SWEEP, + BACKWARD_SWEEP + }; + +public: + TextColumn(TextComposite* pCompositeText = null); + + virtual ~TextColumn(void); + +public: + virtual result Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, + int textLength, const TextObjectAlignment alignment, const TextObjectActionType action); + + virtual result GetRegion(int textIndex, int textLength, int& width, int& height) const; + + virtual int GetHeight(int textIndex) const; + + virtual int GetTextLength(void) const; + + virtual int ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, + int& actualLength, int& width, int& height); + + result Append(TextLine* pTextLine); + + result AddLineDuringCompose(TextLine* pTextLine); + + result Remove(TextLine* pTextLine); + + result RemoveAllLines(void); + + result PrepareCompose(void); + + result FinishCompose(bool isUpdateSweepInfo = true); + + bool IsComposeDone(void); + + int GetTotalHeight(void) const; + + int GetLineHeightAt(int index) const; + + int GetTotalLineCount(void) const; + + int GetLineIndexAtTextIndex(int textIndex) const; + + int GetLineIndexAtPositionY(int y); + + TextLine* GetTextLine(int lineIndex) const; + + SimpleNode* GetTextLineNode(int lineIndex) const; + + void SetFirstDisplayLineIndex(int lineIndex); + + int GetFirstDisplayLineIndex(void) const; + + void SetDisplayLineCount(int displayLineCount); + + int GetDisplayLineCount(void) const; + + void SetDisplayHeight(int height); + + int GetDisplayHeight(void) const; + + void SetFirstDisplayPositionY(int y); + + int GetFirstDisplayPositionY(void) const; + + int GetTextLengthAt(int lineIndex) const; + + int GetFirstTextIndexAt(int lineIndex) const; + + result SetSlidingDimension(Tizen::Graphics::Dimension& slidingDimension); + + Tizen::Graphics::Dimension GetSlidingDimension(void) const; + + void SetSlidingPosition(int slidingPosition); + + int GetSlidingPosition(void) const; + + TextLine* GetPrevLineChangedStartLine(void) const; + + int GetChangeActionEventCount(void) const; + + void SetChangedStartLineIndex(int changedStartLineIndex); + + int GetChangedStartLineIndex(void) const; + + void SetChangedLastLineIndex(int changedLastLineIndex); + + int GetChangedLastLineIndex(void) const; + + int GetChangedStrStartIndex(void) const; + + result SetChangeAction(ChangeAction changeAction, int textIndex, int textLength); + + result RemoveAllKeepLines(void); + + TextObjectSweepType GetTextSweepType(void); + + result UpdateSweepInfo(void); + + result UpdateSweepInfoFirstLine(void); + + result SetKeyInputLine(int changedStartlineIndex, int lineCount); + + result CompareDeletedLine(void); + +private: + result RemoveLines(int lineIndex, int lineCount); + + result RemoveLinesFrom(int lineIndex); + + void RemoveAllChangeActions(void); + + result UpdateCompositionInfo(int changedStartTextIndex, int changedEndTextIndex, int changedTextLength, bool existUnkownAction); + + result GetTextChangedInfo(int& changedStartTextIndex, int& changedEndTextIndex, int& changedTextLength, bool& existUnkownAction) const; + + ActionProcessResult DoProcessTextAction(ChangeAction inputAction, int textIndex, int textLength, + ChangeActionEventInfo* pCurrentStrActionEventInfo, int& changedStartTextIndex, + int& strOutputChangedNum); + + ActionProcessResult DoProcessUnknownThroughUnknown(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo); + + ActionProcessResult DoProcessUnkownThroughInsert(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo, + int& strOutputStartIndex); + + ActionProcessResult DoProcessUnkownThroughRemove(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo, + int& changedStartTextIndex); + + ActionProcessResult DoProcessInsertThroughUnkown(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo); + + ActionProcessResult DoProcessInsertThroughInsert(int textIndex, int textLength, + ChangeActionEventInfo* pCurrentActionEventInfo, int& changedStartTextIndex); + + ActionProcessResult DoProcessInsertThroughRemove(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo, + int& changedStartTextIndex); + + ActionProcessResult DoProcessRemoveThroughUnkown(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo); + + ActionProcessResult DoProcessRemoveThroughInsert(int textIndex, int textLength, + ChangeActionEventInfo* pCurrentActionEventInfo, int& changedStartTextIndex, + int& strOutputChangedNum); + + ActionProcessResult DoProcessRemoveThroughRemove(int textIndex, ChangeActionEventInfo* pCurrentActionEventInfo, + int& changedStartTextIndex); + + result KeepLines(int lineIndex, int lineCount); + +private: + TextComposite* __pCompositeText; + SimpleList* __pLines; + SimpleList* __pTextChangeActionList; + int __totalLineCount; + int __firstDisplayLineIndex; + int __firstDisplayPositionY; + int __displayLineCount; + int __displayHeight; + Tizen::Graphics::Dimension __slidingDimension; + int __slidingPosition; + bool __setChangeAction; + ChangeAction __textChangeAction; + int __chagedStartTextIndex; + int __changedTextLength; + int __changedStartLineIndex; + int __changedLastLineIndex; + int __prevLineIndexBeforeChangedStartLine; + int __nextLineIndexAfterChangedLastLine; + int __textOffsetOfNextLineAfterChangedLine; + int __currentLineIndexToAddDuringCompose; + bool __isComposeDone; + SimpleNode* __pCachedLineNode; + int __cachedLineIndex; + int __cachedLinePositionY; + + SimpleList* __pKeepLines; + int __keepLineCount; + int __insertedLineCountDuringCompose; + +private: + TextColumn(const TextColumn& other); // NOT IMPLMENTED + + TextColumn& operator =(const TextColumn& rhs); // NOT IMPLMENTED + +}; // TextColumn + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_COLUMN_H_ diff --git a/src/graphics/text/FGrp_TextTextComposite.cpp b/src/graphics/text/FGrp_TextTextComposite.cpp new file mode 100644 index 0000000..8f78eb7 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextComposite.cpp @@ -0,0 +1,4951 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextComposite.cpp + * @brief This is the implementation file for TextComposite class. + */ + +// Includes +#include +#include +#include +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextElement.h" +#include "FGrp_TextTextSimple.h" +#include "FGrp_TextTextCutLink.h" +#include "FGrp_TextTextLine.h" +#include "FGrp_TextTextColumn.h" +#include "FGrp_TextTextCutLinkListInfo.h" +#include "FGrp_TextTextComposite.h" +#include "FGrp_TextTextUtility.h" +#include "FGrp_CanvasImpl.h" +#include "FGrp_TextTextWidthManager.h" +#include "../FGrp_Canvas.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Utility; +using namespace Tizen::Base::Collection; + +#define Release(x) \ + if (x) \ + { \ + delete x; \ + x = null; \ + } + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +struct NoneWrapComposeInfo +{ + int prevTextOffset; + int prevTextLength; + int prevWidth; + int prevHeight; + int prevEndType; +}; + +TextComposite::TextComposite(TextElement* pTextElement) +{ + __pTextElementList = new (std::nothrow) LinkedList; + SysTryReturn(NID_GRP + , __pTextElementList + , , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + __wrap = TEXT_OBJECT_WRAP_TYPE_WORD; + __workStart = 0; + __workLength = 0; + __workWidth = 0; + __length = 0; + __displayBlock = false; + __defaultBlockColor = Color(183, 212, 247); + __cursorIndex = -1; + + __ignoreRearBlank = true; + __ignoreFrontBlank = false; + + __rearSpaceHideMode = TEXT_OBJECT_SPACE_HIDE_TYPE_ONE; + __frontSpaceHideMode = TEXT_OBJECT_SPACE_HIDE_TYPE_ONE; + + __lineSpacing = 0; + __elementVertialAlignment = TEXT_OBJECT_ALIGNMENT_BOTTOM; + __pCurrentTextColumn = null; + __pCutLinkListInfo = new (std::nothrow)TextCutLinkListInfo; + + { + wchar_t abbrevText[2]; + abbrevText[0] = TEXT_ABBREV_CHARACTER; + abbrevText[1] = 0; + + __pAbbrevTextElement = new (std::nothrow)TextSimple(abbrevText, 1, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, null, + Color::GetColor(COLOR_ID_BLACK), Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE)); + } + + if (pTextElement != null) + { + AppendElement(*pTextElement); + } + __drawAbbrevText = false; + __drawTextEllipsis = false; + __TextObjectEllipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_TAIL; + + __partialComposingModeEnabled = false; + __lineIndexCompositeDone = 0; + __totalComposedHeight = 0; + __composePartialLimitHeight = 0; + + __headEllipsisTextLength = 0; + __headEllipsisWidth = 0; + __middleEllipsisHeadWidth = 0; + __middleEllipsisTextLengthInHead = 0; + __middleEllipsisTextLengthInTail = 0; + __middleEllipsisWidth = 0; + __isChanged = false; + __pTextWidthManager = null; + __widthManagerEnabled = false; + + __pSweepInfo = null; +} + +TextComposite::~TextComposite(void) +{ + if (__pCutLinkListInfo) + { + delete __pCutLinkListInfo; + __pCutLinkListInfo = null; + } + + if (__pTextElementList) + { + RemoveAllElements(true); + delete __pTextElementList; + __pTextElementList = null; + } + + if (__pAbbrevTextElement) + { + delete __pAbbrevTextElement; + __pAbbrevTextElement = null; + } +} + +int +TextComposite::ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, int& actualLength, + int& width, int& height) +{ + SysTryReturn(NID_GRP + , 0 <= startTextIndex && startTextIndex < __length + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. startTextIndex(%d)", startTextIndex); + + SysTryReturn(NID_GRP + , textLength <= __length + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. textLength(%d)", textLength); + + result r = E_SUCCESS; + + Dimension textSize; + int elementTextOffset = 0; + int elementIndex = 0; + int textIndexFromElementOffset = 0; + int remainingWidth = 0; + int remainingLength = 0; + int textCount = 0; + int currentLength = 0; + int ret = TEXT_RETBY_NORMAL; + + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + + bool isFirstWord = true; + Dimension tempTextSize; + int tempTextCount = 0; + actualLength = 0; + width = 0; + height = 0; + + pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + SysTryReturn(NID_GRP + , pTextElement + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + textCount = 0; + remainingWidth = maxWidth; + remainingLength = textLength; + currentLength = Math::Min(remainingLength, currentLength); + + pEnum = __pTextElementList->GetEnumeratorN(); + for (int i = 0; i <= elementIndex; i++) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to move next element.", GetErrorMessage(r)); + } + + while ((remainingWidth != 0) && (remainingLength != 0)) + { + ret = pTextElement->ForwardAnalyze(textIndexFromElementOffset, currentLength, remainingWidth, + __wrap, textCount, textSize.width, textSize.height); + + textSize.height += __lineSpacing; + + remainingWidth -= textSize.width; + remainingLength -= textCount; + currentLength -= textCount; + + if (textCount != 0) + { + actualLength += textCount; + width += textSize.width; + height = Math::Max(textSize.height, height); + } + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD && ret != TEXT_RETBY_LIMITWIDTH) + { + tempTextCount = actualLength; + tempTextSize.width = width; + tempTextSize.height = height; + } + + if (ret == TEXT_RETBY_OVERWIDTH || ret == TEXT_RETBY_LINEFEED) + { + break; + } + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD) + { + if (ret == TEXT_RETBY_LIMITWIDTH) + { + if (isFirstWord == false) + { + actualLength = tempTextCount; + width = tempTextSize.width; + height = tempTextSize.height; + + ret = TEXT_RETBY_NORMAL; + } + break; + } + + isFirstWord = false; + + if (0 < currentLength) + { + textIndexFromElementOffset += textCount; + continue; + } + } + else + { + if (ret == TEXT_RETBY_LIMITWIDTH) + { + break; + } + } + + if (pEnum->MoveNext() != E_SUCCESS) + { + break; + } + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + break; + } + + isFirstWord = true; + textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = Math::Min(pTextElement->GetTextLength(), remainingLength); + } + + if (ret == TEXT_RETBY_LIMITLENGTH) + { + ret = TEXT_RETBY_NORMAL; + } + + SetLastResult(E_SUCCESS); + Release(pEnum); + return ret; + +CATCH: + Release(pEnum); + return -1; +} + +int +TextComposite::ForwardAnalyzeWithBaseline(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, int& actualLength, + int& width, int& height, int& baseline) +{ + SysTryReturn(NID_GRP + , 0 <= startTextIndex && startTextIndex < __length + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. startTextIndex(%d)", startTextIndex); + + SysTryReturn(NID_GRP + , textLength <= __length + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. textLength(%d)", textLength); + + result r = E_SUCCESS; + + Dimension textSize; + int elementTextOffset = 0; + int elementIndex = 0; + int textIndexFromElementOffset = 0; + int remainingWidth = 0; + int remainingLength = 0; + int textCount = 0; + int currentLength = 0; + int ret = TEXT_RETBY_NORMAL; + bool isMaxHeightImage = false; + + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + + bool isFirstWord = true; + Dimension tempTextSize; + int tempTextCount = 0; + actualLength = 0; + width = 0; + height = 0; + + pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + SysTryReturn(NID_GRP + , pTextElement + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + textCount = 0; + remainingWidth = maxWidth; + remainingLength = textLength; + currentLength = Math::Min(remainingLength, currentLength); + baseline = pTextElement->GetBaseline(); + + pEnum = __pTextElementList->GetEnumeratorN(); + for (int i = 0; i <= elementIndex; i++) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to move next element.", GetErrorMessage(r)); + } + + while (remainingLength != 0) + { + ret = pTextElement->ForwardAnalyze(textIndexFromElementOffset, currentLength, remainingWidth, + __wrap, textCount, textSize.width, textSize.height); + + textSize.height += __lineSpacing; + remainingWidth -= textSize.width; + remainingLength -= textCount; + currentLength -= textCount; + + if (textCount != 0) + { + actualLength += textCount; + width += textSize.width; + baseline = Math::Max(pTextElement->GetBaseline(), baseline); + + // height = Math::Max(textSize.height, height); + if (height < textSize.height) + { + height = textSize.height; + + (pTextElement->GetType() == TEXT_ELEMENT_TYPE_IMAGE) ? isMaxHeightImage = true : isMaxHeightImage = false; + } + } + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD && ret != TEXT_RETBY_LIMITWIDTH) + { + tempTextCount = actualLength; + tempTextSize.width = width; + tempTextSize.height = height; + } + + if (ret == TEXT_RETBY_OVERWIDTH || ret == TEXT_RETBY_LINEFEED) + { + break; + } + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD) + { + if (ret == TEXT_RETBY_LIMITWIDTH) + { + if (isFirstWord == false) + { + actualLength = tempTextCount; + width = tempTextSize.width; + height = tempTextSize.height; + + ret = TEXT_RETBY_NORMAL; + } + break; + } + + isFirstWord = false; + + if (0 < currentLength) + { + textIndexFromElementOffset += textCount; + continue; + } + } + else + { + if (ret == TEXT_RETBY_LIMITWIDTH) + { + break; + } + } + + if (pEnum->MoveNext() != E_SUCCESS) + { + break; + } + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + break; + } + + isFirstWord = true; + textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = Math::Min(pTextElement->GetTextLength(), remainingLength); + } + + if (ret == TEXT_RETBY_LIMITLENGTH) + { + ret = TEXT_RETBY_NORMAL; + } + + if (isMaxHeightImage) + { + height += baseline; + } + + SetLastResult(E_SUCCESS); + Release(pEnum); + return ret; + +CATCH: + Release(pEnum); + return -1; +} + +result +TextComposite::GetRegion(int textIndex, int textLength, int& width, int& height) const +{ + SysTryReturn(NID_GRP + , 0 <= textIndex && textIndex < __length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. textIndex(%d) __length(%d)" + , textIndex, __length); + + SysTryReturn(NID_GRP + , textLength <= __length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. textIndex(%d) __length(%d)" + , textIndex, __length); + + result r = E_SUCCESS; + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + Dimension textSize; + int currentLength = 0; + int elementTextOffset = 0; + int elementIndex = 0; + int textIndexFromElementOffset = 0; + + width = 0; + height = 0; + + pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + SysTryReturn(NID_GRP + , pTextElement + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + pEnum = __pTextElementList->GetEnumeratorN(); + for (int i = 0; i <= elementIndex; i++) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to move next element.", GetErrorMessage(r)); + } + + currentLength = Math::Min(currentLength, textLength); + + while (textLength != 0) + { + pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height); + + width += textSize.width; + height = Math::Max(height, textSize.height); + textLength -= currentLength; + + if (pEnum->MoveNext() != E_SUCCESS) + { + break; + } + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + break; + } + + textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = Math::Min(textLength, pTextElement->GetTextLength()); + } + + Release(pEnum); + return r; + +CATCH: + width = 0; + height = 0; + + Release(pEnum); + return r; +} + +int +TextComposite::GetHeight(int textIndex) const +{ + if (__length == 0) + { + return 0; + } + + SysTryReturn(NID_GRP + , 0 <= textIndex && textIndex < __length + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + TextElement* pTextElement = null; + int currentLength = 0; + int elementTextOffset = 0; + int elementIndex = 0; + int textIndexFromElementOffset = 0; + + pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + SysTryCatch(NID_GRP + , pTextElement + , , E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + return pTextElement->GetHeight(); + +CATCH: + return -1; +} + +result +TextComposite::Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment, + const TextObjectActionType action) +{ + if (textLength == 0) + { + return E_SUCCESS; + } + + SysTryReturn(NID_GRP + , 0 <= startTextIndex && startTextIndex < __length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SysTryReturn(NID_GRP + , textLength <= __length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + + Dimension textSize; + Dimension spaceCharDim; + Dimension abbrevTextDim; + Rectangle adjustedRect = displayRect; + int currentLength = 0; + int elementTextOffset = 0; + int elementIndex = 0; + int textIndexFromElementOffset = 0; + int blockStartTextIndex = 0; + int blockEndTextIndex = 0; + bool drawAbbrevText = false; + bool isAlternateLookEnabled = false; + + _Canvas* pCanvas = _Canvas::GetInstance(canvasImpl); + SysTryReturn(NID_GRP + , pCanvas + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native canvas instance."); + + pTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + + if (pTextElement && __ignoreRearBlank && __rearSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE) + { + const TextSimple* pSimpleText = dynamic_cast (pTextElement); + if (pSimpleText != null) + { + int length = startTextIndex + textLength - elementTextOffset - 1; + const wchar_t* pText = pSimpleText->GetText(); + SysTryReturn(NID_GRP + , pText + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text."); + + SysTryReturn(NID_GRP + , length >= 0 && length < pSimpleText->GetTextLength() + , E_OUT_OF_RANGE, E_OUT_OF_RANGE + , "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",length, pSimpleText->GetTextLength()); + + if (pText[length] == (wchar_t)L' ') + { + GetRegion(length + elementTextOffset, 1, spaceCharDim.width, spaceCharDim.height); + textLength--; + } + } + } + + pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + SysTryCatch(NID_GRP + , pTextElement + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element."); + + if (__ignoreFrontBlank && __frontSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE) + { + const TextSimple* pSimpleText = dynamic_cast (pTextElement); + if (pSimpleText != null) + { + int index = startTextIndex - elementTextOffset; + const wchar_t* pText = pSimpleText->GetText(); + SysTryReturn(NID_GRP + , pText + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text."); + + SysTryReturn(NID_GRP + , index >= 0 && index < pSimpleText->GetTextLength() + , E_OUT_OF_RANGE, E_OUT_OF_RANGE + , "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",index, pSimpleText->GetTextLength()); + + if (pText[index] == (wchar_t)L' ') + { + GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height); + textLength--; + currentLength--; + startTextIndex++; + textIndexFromElementOffset++; + } + } + } + + switch (alignment & TEXT_ALIGNMASK_HORIZ) + { + case TEXT_OBJECT_ALIGNMENT_LEFT: + // fall through + default: + break; + + case TEXT_OBJECT_ALIGNMENT_CENTER: + GetRegion(startTextIndex, textLength, textSize.width, textSize.height); + if (textSize.width < adjustedRect.width) + { + adjustedRect.x += (adjustedRect.width - textSize.width) / 2; + } + break; + + case TEXT_OBJECT_ALIGNMENT_RIGHT: + GetRegion(startTextIndex, textLength, textSize.width, textSize.height); + if (textSize.width < adjustedRect.width) + { + adjustedRect.x += adjustedRect.width - textSize.width; + } + break; + } + + pEnum = __pTextElementList->GetEnumeratorN(); + for (int i = 0; i <= elementIndex; i++) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to move next element.", GetErrorMessage(r)); + } + + currentLength = Math::Min(textLength, currentLength); + + while (textLength > 0) + { + textLength -= currentLength; + + pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height); + + if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV && (pTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT)) + { + TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement); + SysTryCatch(NID_GRP + , pSimpleText + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to cast text element."); + + SetAbbrevObjectFontInfo(pSimpleText); + + int textCount = 0; + __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height); + + if (adjustedRect.width < textSize.width + abbrevTextDim.width || textLength <= 0) + { + int endType = TEXT_RETBY_NORMAL; + + if (adjustedRect.width > abbrevTextDim.width) + { + int remainingLength = pSimpleText->GetTextLength() - textIndexFromElementOffset; + endType = pSimpleText->ForwardAnalyze(textIndexFromElementOffset, remainingLength, adjustedRect.width - abbrevTextDim.width, + TEXT_OBJECT_WRAP_TYPE_NONE, textCount, textSize.width, textSize.height); + + if (endType == TEXT_RETBY_OVERWIDTH) + { + textSize.width = 0; + textSize.height = 0; + textCount = 0; + } + } + else + { + textSize.width = 0; + textCount = 0; + textSize.height = pSimpleText->GetHeight(); + } + + currentLength = textCount; + drawAbbrevText = true; + + switch (alignment & TEXT_ALIGNMASK_HORIZ) + { + case TEXT_OBJECT_ALIGNMENT_CENTER: + if (textSize.width + abbrevTextDim.width < adjustedRect.width) + { + adjustedRect.x = displayRect.x + (adjustedRect.width - (textSize.width + abbrevTextDim.width)) / 2; + } + break; + + case TEXT_OBJECT_ALIGNMENT_RIGHT: + if (textSize.width + abbrevTextDim.width < adjustedRect.width) + { + adjustedRect.x = displayRect.x + adjustedRect.width - (textSize.width + abbrevTextDim.width); + } + break; + + case TEXT_OBJECT_ALIGNMENT_LEFT: + // fall through + default: + break; + } + } + } + + switch (alignment & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + // fall through + default: + adjustedRect.y = displayRect.y; + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + adjustedRect.y = displayRect.y + (displayRect.height - textSize.height) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + adjustedRect.y = displayRect.y + (displayRect.height - textSize.height); + break; + } + + if (pTextElement->IsBackGroundDrawingModeEnable()) + { + Dimension blockSize; + r = pTextElement->GetRegion(textIndexFromElementOffset, currentLength, blockSize.width, blockSize.height); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->FillRectangle(pTextElement->GetBackgroundColor(), Rectangle(adjustedRect.x, displayRect.y, blockSize.width, displayRect.height)); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + isAlternateLookEnabled = (bool)pTextElement->GetValue(SET_ALTERNATE_LOOK); + if (__displayBlock && isAlternateLookEnabled == false) + { + Dimension tempTextSize; + int adjustedX = 0; + + blockStartTextIndex = Math::Max(__workStart, startTextIndex); + blockEndTextIndex = Math::Min(__workStart + __workLength, startTextIndex + currentLength); + + if (blockStartTextIndex < blockEndTextIndex) + { + blockStartTextIndex = textIndexFromElementOffset + (blockStartTextIndex - startTextIndex); + blockEndTextIndex = textIndexFromElementOffset + (blockEndTextIndex - startTextIndex); + adjustedX = adjustedRect.x; + + if (textIndexFromElementOffset < blockStartTextIndex) + { + //[TODO] yunji19.park : to change api -> _Font::GetPosition() + pTextElement->GetRegion(textIndexFromElementOffset, blockStartTextIndex - textIndexFromElementOffset, tempTextSize.width, tempTextSize.height); + adjustedX += tempTextSize.width; + } + + Rectangle blockRect = adjustedRect; + blockRect.x = adjustedX; + + Dimension blockSize; + int blockLength = blockEndTextIndex - blockStartTextIndex; + r = pTextElement->GetBlockRegion(blockStartTextIndex, blockLength, blockSize.width, blockSize.height); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->FillRectangle(__defaultBlockColor, Rectangle(blockRect.x, displayRect.y, blockSize.width, displayRect.height)); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action); + + adjustedRect.x += textSize.width; + adjustedRect.width -= textSize.width; + + if (drawAbbrevText) + { + if (pTextElement->IsBackGroundDrawingModeEnable()) + { + r = pCanvas->FillRectangle(pTextElement->GetBackgroundColor(), Rectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height)); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action); + + adjustedRect.x += abbrevTextDim.width; + adjustedRect.width -= abbrevTextDim.width; + + break; + } + + if (!textLength || adjustedRect.width <= 0) + { + break; + } + + startTextIndex += currentLength; + + if (pEnum->MoveNext() != E_SUCCESS) + { + break; + } + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + break; + } + + textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = Math::Min(textLength, pTextElement->GetTextLength()); + + if (currentLength == 0) + { + break; + } + } + + Release(pEnum); + return E_SUCCESS; + +CATCH: + Release(pEnum); + return r; +} + +result +TextComposite::DrawWithBaseline(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment, + const TextObjectActionType action, int baseline) +{ + if (textLength == 0) + { + return E_SUCCESS; + } + + SysTryReturn(NID_GRP + , 0 <= startTextIndex && startTextIndex < __length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SysTryReturn(NID_GRP + , textLength <= __length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + + Dimension textSize; + Dimension spaceCharDim; + Dimension abbrevTextDim; + Rectangle adjustedRect = displayRect; + int currentLength = 0; + int elementTextOffset = 0; + int elementIndex = 0; + int textIndexFromElementOffset = 0; + int blockStartTextIndex = 0; + int blockEndTextIndex = 0; + bool drawAbbrevText = false; + bool isAlternateLookEnabled = false; + + _Canvas* pCanvas = _Canvas::GetInstance(canvasImpl); + SysTryReturn(NID_GRP + , pCanvas + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native canvas instance."); + + pTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + + if (pTextElement && __ignoreRearBlank && __rearSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE) + { + const TextSimple* pSimpleText = dynamic_cast (pTextElement); + if (pSimpleText != null) + { + int length = startTextIndex + textLength - elementTextOffset - 1; + const wchar_t* pText = pSimpleText->GetText(); + SysTryReturn(NID_GRP + , pText + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text."); + + SysTryReturn(NID_GRP + , length >= 0 && length < pSimpleText->GetTextLength() + , E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",length, pSimpleText->GetTextLength()); + + if (pText[length] == (wchar_t)L' ') + { + GetRegion(length + elementTextOffset, 1, spaceCharDim.width, spaceCharDim.height); + textLength--; + } + } + } + + pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + SysTryCatch(NID_GRP + , pTextElement + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element."); + + if (__ignoreFrontBlank && __frontSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE) + { + const TextSimple* pSimpleText = dynamic_cast (pTextElement); + if (pSimpleText != null) + { + int index = startTextIndex - elementTextOffset; + const wchar_t* pText = pSimpleText->GetText(); + SysTryReturn(NID_GRP + , pText + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text."); + + SysTryReturn(NID_GRP + , index >= 0 && index < pSimpleText->GetTextLength() + , E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",index, pSimpleText->GetTextLength()); + + if (pText[index] == (wchar_t)L' ') + { + GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height); + textLength--; + startTextIndex++; + textIndexFromElementOffset++; + } + } + } + + switch (alignment & TEXT_ALIGNMASK_HORIZ) + { + case TEXT_OBJECT_ALIGNMENT_LEFT: + // fall through + default: + break; + + case TEXT_OBJECT_ALIGNMENT_CENTER: + GetRegion(startTextIndex, textLength, textSize.width, textSize.height); + if (textSize.width < adjustedRect.width) + { + adjustedRect.x += (adjustedRect.width - textSize.width) / 2; + } + break; + + case TEXT_OBJECT_ALIGNMENT_RIGHT: + GetRegion(startTextIndex, textLength, textSize.width, textSize.height); + if (textSize.width < adjustedRect.width) + { + adjustedRect.x += adjustedRect.width - textSize.width; + } + break; + } + + pEnum = __pTextElementList->GetEnumeratorN(); + for (int i = 0; i <= elementIndex; i++) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to move next element.", GetErrorMessage(r)); + } + + adjustedRect.y = displayRect.y + displayRect.height - baseline; + canvasImpl.SetTextOrigin(TEXT_ORIGIN_BASELINE); + + currentLength = Math::Min(textLength, currentLength); + + while (textLength > 0) + { + textLength -= currentLength; + + pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height); + + if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV && (pTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT)) + { + TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement); + SysTryCatch(NID_GRP + , pSimpleText + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to cast text element."); + + SetAbbrevObjectFontInfo(pSimpleText); + + int textCount = 0; + __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height); + + if (adjustedRect.width < textSize.width + abbrevTextDim.width || textLength <= 0) + { + int endType = TEXT_RETBY_NORMAL; + + if (adjustedRect.width > abbrevTextDim.width) + { + int remainingLength = pSimpleText->GetTextLength() - textIndexFromElementOffset; + endType = pSimpleText->ForwardAnalyze(textIndexFromElementOffset, remainingLength, adjustedRect.width - abbrevTextDim.width, + TEXT_OBJECT_WRAP_TYPE_NONE, textCount, textSize.width, textSize.height); + + if (endType == TEXT_RETBY_OVERWIDTH) + { + textSize.width = 0; + textSize.height = 0; + textCount = 0; + } + } + else + { + textSize.width = 0; + textCount = 0; + textSize.height = pSimpleText->GetHeight(); + } + + currentLength = textCount; + drawAbbrevText = true; + + switch (alignment & TEXT_ALIGNMASK_HORIZ) + { + case TEXT_OBJECT_ALIGNMENT_CENTER: + if (textSize.width + abbrevTextDim.width < adjustedRect.width) + { + adjustedRect.x = displayRect.x + (adjustedRect.width - (textSize.width + abbrevTextDim.width)) / 2; + } + break; + + case TEXT_OBJECT_ALIGNMENT_RIGHT: + if (textSize.width + abbrevTextDim.width < adjustedRect.width) + { + adjustedRect.x = displayRect.x + adjustedRect.width - (textSize.width + abbrevTextDim.width); + } + break; + + case TEXT_OBJECT_ALIGNMENT_LEFT: + // fall through + default: + break; + } + } + } + + if (pTextElement->IsBackGroundDrawingModeEnable()) + { + Dimension blockSize; + r = pTextElement->GetRegion(textIndexFromElementOffset, currentLength, blockSize.width, blockSize.height); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->FillRectangle(pTextElement->GetBackgroundColor(), Rectangle(adjustedRect.x, displayRect.y, blockSize.width, displayRect.height)); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + isAlternateLookEnabled = (bool)pTextElement->GetValue(SET_ALTERNATE_LOOK); + if (__displayBlock && isAlternateLookEnabled == false) + { + Dimension tempTextSize; + int adjustedX = 0; + + blockStartTextIndex = Math::Max(__workStart, startTextIndex); + blockEndTextIndex = Math::Min(__workStart + __workLength, startTextIndex + currentLength); + if (blockStartTextIndex < blockEndTextIndex) + { + blockStartTextIndex = textIndexFromElementOffset + (blockStartTextIndex - startTextIndex); + blockEndTextIndex = textIndexFromElementOffset + (blockEndTextIndex - startTextIndex); + adjustedX = adjustedRect.x; + + if (textIndexFromElementOffset < blockStartTextIndex) + { + pTextElement->GetRegion(textIndexFromElementOffset, blockStartTextIndex - textIndexFromElementOffset, tempTextSize.width, tempTextSize.height); + adjustedX += tempTextSize.width; + } + + Rectangle block_rect = adjustedRect; + block_rect.x = adjustedX; + } + } + + Rectangle imageRect = adjustedRect; + imageRect.y -= textSize.height; + TextElementType objectType = pTextElement->GetType(); + if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT) + { + pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action); + } + else + { + pTextElement->Draw(canvasImpl, imageRect, textIndexFromElementOffset, currentLength, alignment, action); + } + + adjustedRect.x += textSize.width; + adjustedRect.width -= textSize.width; + + if (drawAbbrevText) + { + if (pTextElement->IsBackGroundDrawingModeEnable()) + { + r = pCanvas->FillRectangle(pTextElement->GetBackgroundColor(), Rectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height)); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action); + + adjustedRect.x += abbrevTextDim.width; + adjustedRect.width -= abbrevTextDim.width; + + break; + } + + if (!textLength || adjustedRect.width <= 0) + { + break; + } + + startTextIndex += currentLength; + + if (pEnum->MoveNext() != E_SUCCESS) + { + break; + } + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + break; + } + + textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = Math::Min(textLength, pTextElement->GetTextLength()); + + if (currentLength == 0) + { + break; + } + } + + canvasImpl.SetTextOrigin(TEXT_ORIGIN_LEFT_TOP); + + Release(pEnum); + return E_SUCCESS; + +CATCH: + canvasImpl.SetTextOrigin(TEXT_ORIGIN_LEFT_TOP); + + Release(pEnum); + return r; +} + +result +TextComposite::DrawLine(_CanvasImpl& canvasImpl, TextLine* pTextLine, const Rectangle& displayRect, + const TextObjectAlignment align, const TextObjectActionType action) +{ + SysTryReturn(NID_GRP + , pTextLine + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + int lineOffset = 0; + int lineLength = 0; + + Rectangle adjustedRect; + Rectangle lineBounds; + Dimension lineTextSize; + + lineLength = pTextLine->GetTextLength(); + lineOffset = pTextLine->GetTextOffset(); + + lineBounds = pTextLine->GetBounds(); + pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height); + + adjustedRect = displayRect; + adjustedRect.width = lineBounds.width; + adjustedRect.height = lineBounds.height; + + if (__elementVertialAlignment & TEXT_OBJECT_ALIGNMENT_BASELINE) + { + return DrawWithBaseline(canvasImpl, adjustedRect, lineOffset, lineLength, (TextObjectAlignment)((TEXT_ALIGNMASK_HORIZ & align) | TEXT_OBJECT_ALIGNMENT_BASELINE), action, pTextLine->GetBaseline()); + } + else + { + return Draw(canvasImpl, adjustedRect, lineOffset, lineLength, (TextObjectAlignment)((TEXT_ALIGNMASK_HORIZ & align) | __elementVertialAlignment), action); + } +} + +result +TextComposite::GetValue(TextElement* pTextElement, TextComponentInfoValueType type, unsigned int* value) const +{ + SysTryReturn(NID_GRP + , pTextElement + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + TextElementType objectType = TextUtility::GetObjectTypeFromValueType(type); + + SysTryReturn(NID_GRP + , pTextElement->GetType() == objectType + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get type."); + + *value = pTextElement->GetValue(type); + + return E_SUCCESS; +} + +result +TextComposite::InsertElementAt(TextElement& textElement, int textIndex) +{ + SysTryReturn(NID_GRP + , 0 <= textIndex && textIndex <= __length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + + TextElement* pCurrentTextElement = null; + TextElement* pNewTextElement = null; + + int currentLength = 0; + int elementTextOffset = 0; + int elementIndex = 0; + int textIndexFromElementOffset = 0; + + pCurrentTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, + currentLength, textIndexFromElementOffset); + + if (pCurrentTextElement != null) + { + if (textIndex == elementTextOffset) + { + r = __pTextElementList->InsertAt(textElement, elementIndex); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Fail to insert element.", GetErrorMessage(r)); + } + else + { + pCurrentTextElement->SetTextLength(pCurrentTextElement->GetTextLength() - currentLength); + + r = __pTextElementList->InsertAt(textElement, ++elementIndex); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Fail to insert element.", GetErrorMessage(r)); + + pNewTextElement = pCurrentTextElement->CloneN(SET_ALLVALUE_CLONE, 0); + SysTryReturn(NID_GRP + , pNewTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to clone text element."); + + pNewTextElement->SetTextLength(currentLength); + + if (textIndexFromElementOffset != 0) + { + pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset); + } + + r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Fail to insert element.", GetErrorMessage(r)); + } + } + else + { + if (textIndex == __length) + { + r = __pTextElementList->Add(textElement); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Fail to add element.", GetErrorMessage(r)); + } + else + { + return E_SYSTEM; + } + } + + int elementTextLength = textElement.GetTextLength(); + + __workStart = textIndex; + __workLength = elementTextLength; + __length += elementTextLength; + __isChanged = true; + + TextElementType objectType = textElement.GetType(); + if (objectType == TEXT_ELEMENT_TYPE_CUTLINK) + { + TextCutLink* pLinkElement = dynamic_cast < TextCutLink* >(&textElement); + __pCutLinkListInfo->InsertCutLinkElementInfo(textIndex, *pLinkElement, elementTextLength); + } + else + { + __pCutLinkListInfo->InsertText(textIndex, elementTextLength); + } + + if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT) + { + TextSimple* pSimpleText = dynamic_cast < TextSimple* >(&textElement); + if (pSimpleText != null) + { + pSimpleText->SetUserWrap(__wrap); + } + } + + return r; +} + +result +TextComposite::AppendElement(TextElement& textElement) +{ + result r = E_SUCCESS; + int elementTextLength = textElement.GetTextLength(); + + r = __pTextElementList->Add(textElement); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Fail to add element.", GetErrorMessage(r)); + + __workStart = __length; + __workLength = elementTextLength; + __length += elementTextLength; + __isChanged = true; + + TextElementType objectType = textElement.GetType(); + if (objectType == TEXT_ELEMENT_TYPE_CUTLINK) + { + TextCutLink* pLinkElement = dynamic_cast < TextCutLink* >(&textElement); + __pCutLinkListInfo->InsertCutLinkElementInfo(__workStart, *pLinkElement, elementTextLength); + } + else + { + __pCutLinkListInfo->InsertText(__workStart, elementTextLength); + } + + if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT) + { + TextSimple* pSimpleText = dynamic_cast < TextSimple* >(&textElement); + if (pSimpleText != null) + { + pSimpleText->SetUserWrap(__wrap); + } + } + + return r; +} + +result +TextComposite::RemoveElementAt(int elementIndex, bool deallocate) +{ + SysTryReturn(NID_GRP + , elementIndex >= 0 && elementIndex < __pTextElementList->GetCount() + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + TextElement* pTextElement = null; + + pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(elementIndex)); + if (pTextElement != null) + { + int elementTextLength = pTextElement->GetTextLength(); + int elementTextOffset = GetFirstTextIndexAt(elementIndex); + + r = __pTextElementList->RemoveAt(elementIndex); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Fail to remove element.", GetErrorMessage(r)); + + if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK) + { + __pCutLinkListInfo->RemoveCutLinkElementInfo(dynamic_cast < TextCutLink* >(pTextElement)); + } + else + { + __pCutLinkListInfo->RemoveText(elementTextOffset, elementTextLength); + } + + __length -= elementTextLength; + + if (deallocate) + { + delete pTextElement; + pTextElement = null; + } + } + + return r; +} + +result +TextComposite::RemoveAllElements(bool deallocate) +{ + result r = E_SUCCESS; + + if (__pCutLinkListInfo) + { + __pCutLinkListInfo->RemoveAllCutLinkElementInfos(); + } + + __pTextElementList->RemoveAll(deallocate); + + SysTryCatch(NID_GRP + , __pTextElementList->GetCount() == 0 + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to remove all elements."); + + __workStart = 0; + __workLength = 0; + __length = 0; + __displayBlock = false; + __ignoreRearBlank = false; + __ignoreFrontBlank = false; + __cursorIndex = -1; + __rearSpaceHideMode = TEXT_OBJECT_SPACE_HIDE_TYPE_NONE; + __frontSpaceHideMode = TEXT_OBJECT_SPACE_HIDE_TYPE_NONE; + + return E_SUCCESS; + +CATCH: + __workStart = 0; + __workLength = 0; + __length = 0; + __cursorIndex = -1; + + return r; +} + +TextElement* +TextComposite::SearchTextElement(TextElementType type, int textIndex, int& elementTextOffset) const +{ + SysTryReturn(NID_GRP + , 0 <= textIndex && textIndex < __length + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + + int elementIndex = 0; + int currentLength = 0; + int textIndexFromElementOffset = 0; + + pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + SysTryReturn(NID_GRP + , pTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + if (pTextElement->GetType() == type) + { + return pTextElement; + } + + elementTextOffset += pTextElement->GetTextLength(); + + pEnum = __pTextElementList->GetEnumeratorN(); + for (int i = 0; i < elementIndex; i++) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to move next element.", GetErrorMessage(r)); + } + + while (pEnum->MoveNext() == E_SUCCESS) + { + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + continue; + } + + if (pTextElement->GetType() == type) + { + Release(pEnum); + SetLastResult(E_SUCCESS); + return pTextElement; + } + + elementTextOffset += pTextElement->GetTextLength(); + } + + Release(pEnum); + SetLastResult(E_SUCCESS); + return null; + +CATCH: + Release(pEnum); + return null; +} + +result +TextComposite::GetText(TextComposite* pTargetCompsiteText, int textIndex, int textLength) +{ + SysTryReturn(NID_GRP + , pTargetCompsiteText + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SysTryReturn(NID_GRP + , 0 < textLength + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + TextElement* pNewTextElement = null; + + int currentLength = 0; + int elementTextOffset = 0; + int elementIndex = 0; + int textIndexFromElementOffset = 0; + + if (textIndex == -1 || textIndex < 0) + { + textIndex = 0; + } + + pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + SysTryReturn(NID_GRP + , pTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element."); + + textIndexFromElementOffset = textIndex - elementTextOffset; + + pEnum = __pTextElementList->GetEnumeratorN(); + for (int i = 0; i < elementIndex; i++) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to move next element.", GetErrorMessage(r)); + } + + while (pEnum->MoveNext() == E_SUCCESS) + { + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + continue; + } + + textIndexFromElementOffset = 0; + currentLength = Math::Min(pTextElement->GetTextLength(), textLength); + + pNewTextElement = pTextElement->CopyN(textIndexFromElementOffset, currentLength); + if (pNewTextElement != null) + { + pTargetCompsiteText->AppendElement(*pNewTextElement); + } + + textLength -= currentLength; + } + + Release(pEnum); + return E_SUCCESS; + +CATCH : + Release(pEnum); + return r; +} + +int +TextComposite::Compose(Rectangle& rect, TextColumn* pTextColumn) +{ + SysTryReturn(NID_GRP + , pTextColumn + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + __pCurrentTextColumn = pTextColumn; + + int lineCount = 0; + + if (__pTextElementList->GetCount() == 0 || __length == 0) + { + pTextColumn->RemoveAllLines(); + + return -1; + } + + switch (__wrap) + { + case TEXT_OBJECT_WRAP_TYPE_NONE: + { + if (__drawAbbrevText) + { + __pCurrentTextColumn->PrepareCompose(); + + __drawTextEllipsis = false; + if (__TextObjectEllipsisType == TEXT_OBJECT_ELLIPSIS_TYPE_TAIL) + { + lineCount = ComposeInNoneWrap(rect); + } + else if (__TextObjectEllipsisType == TEXT_OBJECT_ELLIPSIS_TYPE_MIDDLE) + { + lineCount = ComposeInNoneWrapMiddleEllipsis(rect); + } + else + { + lineCount = ComposeInNoneWrapHeadEllipsis(rect); + } + } + else + { + bool setNoneWrapComposeInfo = false; + NoneWrapComposeInfo noneWrapComposeInfo; + + TextLine* pTextLine = __pCurrentTextColumn->GetTextLine(0); + if (pTextLine != null) + { + + noneWrapComposeInfo.prevTextOffset = pTextLine->GetTextOffset(); + noneWrapComposeInfo.prevTextLength = pTextLine->GetTextLength(); + pTextLine->GetRegion(0, noneWrapComposeInfo.prevTextLength, + noneWrapComposeInfo.prevWidth, noneWrapComposeInfo.prevHeight); + noneWrapComposeInfo.prevEndType = pTextLine->GetEndType(); + setNoneWrapComposeInfo = true; + } + + __pCurrentTextColumn->PrepareCompose(); + __drawTextEllipsis = false; + if (setNoneWrapComposeInfo) + { + lineCount = ComposeInNoneWrap(rect, &noneWrapComposeInfo); + } + else + { + lineCount = ComposeInNoneWrap(rect); + } + } + + __pCurrentTextColumn->FinishCompose(); + break; + } + + case TEXT_OBJECT_WRAP_TYPE_CHARACTER: + { + __pCurrentTextColumn->PrepareCompose(); + lineCount = ComposeInNormalWrap(rect); + __pCurrentTextColumn->FinishCompose(); + break; + } + + case TEXT_OBJECT_WRAP_TYPE_WORD: + { + if (IsPartialComposingModeEnabled()) + { + if (__pCurrentTextColumn->GetTotalLineCount() == 0) + { + __pCurrentTextColumn->PrepareCompose(); + } + lineCount = ComposeInPartialMode(rect); + } + else + { + __pCurrentTextColumn->PrepareCompose(); + lineCount = ComposeInWordWrap(rect); + __pCurrentTextColumn->CompareDeletedLine(); + __pCurrentTextColumn->FinishCompose(); + } + + break; + } + } + + return lineCount; +} + +result +TextComposite::SetRange(int textStartIndex, int textLength) +{ + SysTryReturn(NID_GRP + , 0 <= textStartIndex && textStartIndex <= __length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + __workStart = textStartIndex; + __workLength = textLength; + + return E_SUCCESS; +} + +void +TextComposite::GetRange(int& startTextIndex, int& textLength) const +{ + startTextIndex = __workStart; + textLength = __workLength; +} + +result +TextComposite::SetFont(Font* pFont) +{ + return SetValueToAllTextElements(SET_FONT, (unsigned int)pFont); +} + +Font* +TextComposite::GetFont(int textIndex) const +{ + unsigned int value = 0; + + GetValue(textIndex, SET_FONT, &value); + Font* pFont = static_cast < Font* >((void*)value); + + SetLastResult(E_SUCCESS); + + return pFont; +} + +result +TextComposite::SetForegroundColor(const Color& color) +{ + return SetValueToAllTextElements(SET_FONT_FGCOLOR, (unsigned int)color.GetRGB32()); +} + +Color +TextComposite::GetForegroundColor(int textIndex) const +{ + result r = E_SUCCESS; + unsigned int value = 0; + + r = GetValue(textIndex, SET_FONT_FGCOLOR, &value); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , Color::GetColor(COLOR_ID_BLACK), r, "[%s] Propagating.", GetErrorMessage(r)); + + return Color(value); +} + +result +TextComposite::SetBackgroundColor(const Color& color) +{ + return SetValueToAllTextElements(SET_FONT_BGCOLOR, (unsigned int)color.GetRGB32()); +} + +Color +TextComposite::GetBackgroundColor(int textIndex) const +{ + result r = E_SUCCESS; + unsigned int value = 0; + + r = GetValue(textIndex, SET_FONT_BGCOLOR, &value); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , Color::GetColor(COLOR_ID_BLACK), r, "[%s] Propagating.", GetErrorMessage(r)); + + return Color(value); +} + +result +TextComposite::SetOutlineColor(const Color& color) +{ + return SetValueToAllTextElements(SET_FONT_OUTLINECOLOR, (unsigned int)color.GetRGB32()); +} + +Color +TextComposite::GetOutlineColor(int textIndex) const +{ + result r = E_SUCCESS; + unsigned int value = 0; + + r = GetValue(textIndex, SET_FONT_OUTLINECOLOR, &value); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , Color::GetColor(COLOR_ID_BLACK), r, "[%s] Propagating.", GetErrorMessage(r)); + + return Color(value); +} + +Color +TextComposite::GetAlternativeForegroundColor(int textIndex) const +{ + SysTryReturn(NID_GRP + , 0 <= textIndex && textIndex < __length + , Color::GetColor(COLOR_ID_BLACK), E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + unsigned int value = 0; + + r = GetValue(textIndex, SET_ALTERNATIVE_FGCOLOR, &value); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , Color::GetColor(COLOR_ID_BLACK), r, "[%s] Propagating.", GetErrorMessage(r)); + + return Color(value); +} + +result +TextComposite::SetAlternateLookEnabled(bool enable) +{ + return SetValueToAllTextElements(SET_ALTERNATE_LOOK, (unsigned int)enable); +} + +int +TextComposite::GetMaxLineHeight(void) const +{ + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + int height = 0; + int maxHeight = 0; + + pEnum = __pTextElementList->GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + continue; + } + + height = pTextElement->GetHeight(); + maxHeight = Math::Max(maxHeight, height); + } + + Release(pEnum); + return maxHeight; +} + +TextElement* +TextComposite::GetElementAtTextIndex(int textIndex, int& elementTextOffset, int& elementIndex, int& elementTextLength, + int& textIndexFromElementOffset) const +{ + result r = E_SUCCESS; + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + int offset = 0; + int currentElementLength = 0; + + elementTextOffset = 0; + elementIndex = 0; + elementTextLength = 0; + textIndexFromElementOffset = 0; + + if (__pTextElementList->GetCount() == 0) + { + return null; + } + + pEnum = __pTextElementList->GetEnumeratorN(); + r = pEnum->MoveNext(); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , null, r, "[%s] Fail to move next element. Now Elements count is (%d)", GetErrorMessage(r), __pTextElementList->GetCount()); + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + SysTryReturn(NID_GRP + , pTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + while (1) + { + currentElementLength = pTextElement->GetTextLength(); + if (textIndex < elementTextOffset + currentElementLength) + { + offset = pTextElement->GetValue(SET_TEXT_OFFSET); + textIndexFromElementOffset = offset + (textIndex - elementTextOffset); + break; + } + else + { + if (currentElementLength == 0 && textIndex == elementTextOffset) + { + offset = pTextElement->GetValue(SET_TEXT_OFFSET); + textIndexFromElementOffset = offset + (textIndex - elementTextOffset); + break; + } + } + + pTextElement = null; + if (pEnum->MoveNext() != E_SUCCESS) + { + break; + } + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + break; + } + + elementTextOffset += currentElementLength; + elementIndex++; + } + + if (pTextElement != null) + { + elementTextLength = elementTextOffset + currentElementLength - textIndex; + } + + Release(pEnum); + return pTextElement; +} + +TextElement* +TextComposite::GetElementAtTextIndex(int textIndex) const +{ + result r = E_SUCCESS; + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + int currentElementLength = 0; + int elementTextOffset = 0; + + if (__pTextElementList->GetCount() == 0) + { + return null; + } + + pEnum = __pTextElementList->GetEnumeratorN(); + r = pEnum->MoveNext(); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , null, r, "[%s] Fail to move next element. Now Elements count is (%d)", GetErrorMessage(r), __pTextElementList->GetCount()); + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + SysTryReturn(NID_GRP + , pTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + while (1) + { + currentElementLength = pTextElement->GetTextLength(); + if (textIndex < elementTextOffset + currentElementLength) + { + break; + } + else + { + if (currentElementLength == 0 && textIndex == elementTextOffset) + { + break; + } + } + + pTextElement = null; + if (pEnum->MoveNext() != E_SUCCESS) + { + break; + } + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + break; + } + + elementTextOffset += currentElementLength; + } + + Release(pEnum); + return pTextElement; +} + +result +TextComposite::SetWrap(TextObjectWrapType wrap) +{ + if (__wrap == wrap) + { + return E_SUCCESS; + } + + __wrap = wrap; + + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + + pEnum = __pTextElementList->GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + continue; + } + + TextElementType objectType = pTextElement->GetType(); + if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK) + { + TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement); + if (pSimpleText != null) + { + pSimpleText->SetUserWrap(__wrap); + } + } + } + + Release(pEnum); + return E_SUCCESS; +} + +result +TextComposite::Optimize(int startElementIndex, int endElementIndex) +{ + int elementCount = 0; + int nodeIndex = 0; + + TextElement* pStartTextElement = null; + TextElement* pEndTextElement = null; + TextElement* pCurrentTextElement = null; + TextElement* pNextTextElement = null; + + elementCount = __pTextElementList->GetCount(); + if (elementCount == 0) + { + return E_SUCCESS; + } + + if (startElementIndex == -1 || startElementIndex < 0) + { + startElementIndex = 0; + } + + if (endElementIndex == -1 || endElementIndex < 0 || endElementIndex > elementCount - 1) + { + endElementIndex = elementCount - 1; + } + + if (0 < startElementIndex) + { + startElementIndex--; + } + + if (endElementIndex < elementCount - 1) + { + endElementIndex++; + } + + if (endElementIndex - startElementIndex < 1) + { + return E_SUCCESS; + } + + pStartTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(startElementIndex)); + SysTryReturn(NID_GRP + , pStartTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + pEndTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(endElementIndex)); + SysTryReturn(NID_GRP + , pEndTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + do + { + pCurrentTextElement = pStartTextElement; + + nodeIndex = startElementIndex + 1; + + pNextTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(nodeIndex)); + if (pNextTextElement == null) + { + break; + } + + if (TextUtility::CanMerge(pCurrentTextElement, pNextTextElement)) + { + pCurrentTextElement->SetTextLength(pCurrentTextElement->GetTextLength() + pNextTextElement->GetTextLength()); + __pTextElementList->Remove(*pNextTextElement, true); + } + else + { + pStartTextElement = pNextTextElement; + } + + startElementIndex++; + pStartTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(startElementIndex)); + } + while (startElementIndex != endElementIndex); + + return E_SUCCESS; +} + +result +TextComposite::ChangeTextOffset(wchar_t* pText, int elementIndex, int gap) +{ + SysTryReturn(NID_GRP + , 0 <= elementIndex + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SysTryReturn(NID_GRP + , gap != 0 + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + + pEnum = __pTextElementList->GetEnumeratorN(); + for (int i = 0; i < elementIndex; i++) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to move next element.", GetErrorMessage(r)); + } + + while (pEnum->MoveNext() == E_SUCCESS) + { + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + continue; + } + + TextElementType objectType = pTextElement->GetType(); + if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK) + { + TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement); + if (pSimpleText != null) + { + pSimpleText->ChangeTextOffset(pText, gap); + } + } + } + + Release(pEnum); + return E_SUCCESS; + +CATCH: + Release(pEnum); + return r; +} + +result +TextComposite::NotifyTextChanged(wchar_t* pText, int startTextIndex, int textLength, int gap, Font* pFont, + const Color& fgColor, const Color& bgColor, const Color& outlineColor) +{ + if (gap == 0) + { + return E_SUCCESS; + } + + result r = E_SUCCESS; + TextElement* pTextElement = null; + TextElement* pNextTextElement = null; + + int currentLength = 0; + int elementTextOffset = 0; + int elementIndex = 0; + int textIndexFromElementOffset = 0; + bool isOptimized = false; + + SetWorkWidth(pFont, pText, __workStart, textLength); + + if (gap > 0) + { + bool checkNextElement = false; + + if (__workStart == startTextIndex) + { + pTextElement = GetElementAtTextIndex(__workStart, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + } + else + { + pTextElement = GetElementAtTextIndex(__workStart - 1, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + checkNextElement = true; + } + + if (pTextElement == null) + { + TextSimple* pSimpleText = null; + pSimpleText = new (std::nothrow)TextSimple(pText, gap, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, pFont, fgColor, bgColor, + outlineColor); + SysTryReturn(NID_GRP + , pSimpleText + , E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pSimpleText->SetTextOffset(__workStart - startTextIndex); + InsertElementAt(*pSimpleText, __workStart); + + return E_SUCCESS; + } + else + { + TextSimple* pSimpleText = null; + bool canMerge = false; + + TextElementType objectType = pTextElement->GetType(); + if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK) + { + pSimpleText = dynamic_cast < TextSimple* >(pTextElement); + if (pSimpleText != null) + { + if (pSimpleText->IsSame(pText, pFont, fgColor, bgColor, outlineColor)) + { + canMerge = true; + } + else + { + pTextElement = null; + } + } + } + else + { + pTextElement = null; + } + + if (!canMerge && checkNextElement) + { + pTextElement = null; + + if (currentLength == 1) + { + pNextTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(elementIndex+1)); + if (pNextTextElement != null) + { + objectType = pNextTextElement->GetType(); + if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK) + { + pSimpleText = dynamic_cast < TextSimple* >(pNextTextElement); + if (pSimpleText != null) + { + if (pSimpleText->IsSame(pText, pFont, fgColor, bgColor, outlineColor)) + { + elementIndex++; + pTextElement = pNextTextElement; + } + else + { + pTextElement = null; + } + } + } + else + { + pTextElement = null; + } + } + else + { + pTextElement = null; + } + } + } + + if (pTextElement == null) + { + TextSimple* pSimpleText = null; + pSimpleText = new (std::nothrow)TextSimple(pText, gap, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, pFont, fgColor, bgColor, + outlineColor); + SysTryReturn(NID_GRP + , pSimpleText + , E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pSimpleText->SetTextOffset(__workStart - startTextIndex); + InsertElementAt(*pSimpleText, __workStart); + + isOptimized = true; + r = __pTextElementList->IndexOf(*pSimpleText, elementIndex); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Fail to get element index.", GetErrorMessage(r)); + } + else + { + __pCutLinkListInfo->InsertText(startTextIndex, gap); + __length += gap; + pTextElement->SetTextLength(pTextElement->GetTextLength() + gap); + } + } + } + else if (gap < 0) + { + int remainingGap = -gap; + int currentGap = 0; + int textIndex = 0; + int currentelementIndex = 0; + + textIndex = __workStart + remainingGap; + pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + if (pTextElement == null || elementTextOffset == textIndex) + { + pTextElement = GetElementAtTextIndex(textIndex - 1, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + } + + SysTryReturn(NID_GRP + , pTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + currentelementIndex = elementIndex; + currentGap = Math::Min(remainingGap, textIndex - elementTextOffset); + if (currentGap == pTextElement->GetTextLength()) + { + RemoveElementAt(currentelementIndex); + elementIndex--; + isOptimized = true; + } + else + { + pTextElement->SetTextLength(pTextElement->GetTextLength() - currentGap); + __length -= currentGap; + if (currentGap < remainingGap) + { + TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement); + if (pSimpleText != null) + { + int offset = pSimpleText->GetTextOffset(); + offset -= (remainingGap - currentGap); + pSimpleText->SetTextOffset(offset); + } + } + } + + remainingGap -= currentGap; + while (remainingGap > 0) + { + pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(--currentelementIndex)); + SysTryReturn(NID_GRP + , pTextElement + , r, r, "[%s] Fail to get element.", GetErrorMessage(r)); + + int elementTextLength = pTextElement->GetTextLength(); + currentGap = Math::Min(elementTextLength, remainingGap); + + if (currentGap == elementTextLength) + { + RemoveElementAt(currentelementIndex); + elementIndex--; + isOptimized = true; + } + else + { + __pCutLinkListInfo->RemoveText(__workStart, currentGap); + pTextElement->SetTextLength(elementTextLength - currentGap); + __length -= currentGap; + } + + remainingGap -= currentGap; + } + } + + ChangeTextOffset(pText, elementIndex + 1, gap); + + if (isOptimized) + { + Optimize(elementIndex, elementIndex); + } + + return E_SUCCESS; +} + +int +TextComposite::ForwardAnalyzeWithFocusedObjectType(int textIndex, int textLength, int maxWidth, + int& cursorIndex, TextElementType& type) +{ + result r = E_SUCCESS; + Dimension textSize; + int currentLength = 0; + int elementTextOffset = 0; + int elementIndex = 0; + int textIndexFromElementOffset = 0; + int textCount = 0; + int remainingWidth = 0; + int remainingLength = 0; + int ret = TEXT_RETBY_NORMAL; + + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + + bool isFirstWord = true; + int index = 0; + + cursorIndex = 0; + type = TEXT_ELEMENT_TYPE_MAX; + + pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + SysTryReturn(NID_GRP + , pTextElement + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + remainingWidth = maxWidth; + remainingLength = textLength; + + pEnum = __pTextElementList->GetEnumeratorN(); + for (int i = 0; i <= elementIndex; i++) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to move next element.", GetErrorMessage(r)); + } + + currentLength = Math::Min(remainingLength, currentLength); + + while (remainingWidth > 0 || remainingLength > 0) + { + ret = pTextElement->ForwardAnalyze(textIndexFromElementOffset, currentLength, remainingWidth, __wrap, textCount , textSize.width, textSize.height); + TextElementType objectType = pTextElement->GetType(); + + if ((objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK) && (ret == TEXT_RETBY_LIMITWIDTH)) + { + Dimension tempTextSize; + r = pTextElement->GetRegion(textIndexFromElementOffset, textCount + 1, tempTextSize.width, tempTextSize.height); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if ((remainingWidth - textSize.width) > (tempTextSize.width - remainingWidth)) + { + textSize.width = tempTextSize.width; + textCount++; + } + } + + remainingWidth -= textSize.width; + if (remainingWidth < 0) + { + remainingWidth = 0; + } + + remainingLength -= textCount; + currentLength -= textCount ; + cursorIndex += textCount ; + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD && ret != TEXT_RETBY_LIMITWIDTH) + { + index = cursorIndex; + } + + if (remainingLength <= currentLength) + { + break; + } + + if (ret == TEXT_RETBY_OVERWIDTH || ret == TEXT_RETBY_LINEFEED) + { + break; + } + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD) + { + if (ret == TEXT_RETBY_LIMITWIDTH) + { + if (isFirstWord == false) + { + cursorIndex = index; + ret = TEXT_RETBY_NORMAL; + } + break; + } + + isFirstWord = false; + + if (currentLength > 0) + { + textIndexFromElementOffset += textCount ; + continue; + } + } + else + { + if (ret == TEXT_RETBY_LIMITWIDTH) + { + break; + } + } + + if (pEnum->MoveNext() != E_SUCCESS) + { + break; + } + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + break; + } + + textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = Math::Min(pTextElement->GetTextLength(), remainingLength); + } + + if (ret == TEXT_RETBY_LIMITLENGTH) + { + ret = TEXT_RETBY_NORMAL; + } + + SetLastResult(E_SUCCESS); + Release(pEnum); + return ret; + +CATCH: + Release(pEnum); + return -1; +} + +void +TextComposite::HideFrontSpace(TextObjectSpaceHideType mode) +{ + __ignoreFrontBlank = true; + __frontSpaceHideMode = mode; +} + +void +TextComposite::HideRearSpace(TextObjectSpaceHideType mode) +{ + __ignoreRearBlank = true; + __rearSpaceHideMode = mode; +} + +int +TextComposite::ForwardAnalyzeInNoneCursorMode(int startTextIndex, int textLength, int maxWidth, int& textIndex) +{ + result r = E_SUCCESS; + Dimension textSize; + int currentLength = 0; + int elementTextOffset = 0; + int elementIndex = 0; + int textIndexFromElementOffset = 0; + int textCount = 0; + int remainingWidth = 0; + int remainingLength = 0; + int ret = TEXT_RETBY_NORMAL; + + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + + bool isFirstWord = true; + int index = 0; + textIndex = 0; + + pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + SysTryReturn(NID_GRP + , pTextElement + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + textCount = 0; + remainingWidth = maxWidth; + remainingLength = textLength; + + pEnum = __pTextElementList->GetEnumeratorN(); + for (int i = 0; i <= elementIndex; i++) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to move next element.", GetErrorMessage(r)); + } + + currentLength = Math::Min(remainingLength, currentLength); + + while (remainingWidth > 0 || remainingLength > 0) + { + ret = pTextElement->ForwardAnalyze(textIndexFromElementOffset, currentLength, remainingWidth, + __wrap, textCount, textSize.width, textSize.width); + + TextElementType objectType = pTextElement->GetType(); + + if ((objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK) && (ret == TEXT_RETBY_LIMITWIDTH)) + { + Dimension tempTextSize; + r = pTextElement->GetRegion(textIndexFromElementOffset, textCount + 1, tempTextSize.width, tempTextSize.height); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + textSize.width = tempTextSize.width; + textCount++; + } + + remainingWidth -= textSize.width; + if (remainingWidth < 0) + { + remainingWidth = 0; + } + + remainingLength -= textCount; + currentLength -= textCount; + textIndex += textCount; + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD && ret != TEXT_RETBY_LIMITWIDTH) + { + index = textIndex; + } + + if (remainingLength <= currentLength) + { + break; + } + + if (ret == TEXT_RETBY_OVERWIDTH || ret == TEXT_RETBY_LINEFEED) + { + break; + } + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD) + { + if (ret == TEXT_RETBY_LIMITWIDTH) + { + if (isFirstWord == false) + { + textIndex = index; + ret = TEXT_RETBY_NORMAL; + } + break; + } + + isFirstWord = false; + + if (currentLength > 0) + { + textIndexFromElementOffset += textCount; + continue; + } + } + else + { + if (ret == TEXT_RETBY_LIMITWIDTH) + { + break; + } + } + + if (pEnum->MoveNext() != E_SUCCESS) + { + break; + } + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + break; + } + + textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = Math::Min(pTextElement->GetTextLength(), remainingLength); + } + + if (ret == TEXT_RETBY_LIMITLENGTH) + { + ret = TEXT_RETBY_NORMAL; + } + + SetLastResult(E_SUCCESS); + Release(pEnum); + return ret; + +CATCH: + Release(pEnum); + return ret; +} + +int +TextComposite::GetCutLinkElementCount(void) const +{ + return __pCutLinkListInfo->GetCutLinkElementCount(); +} + +int +TextComposite::GetCutLinkElementIndexAt(int textIndex) const +{ + return __pCutLinkListInfo->GetCutLinkElementIndexAt(textIndex); +} + +TextCutLink* +TextComposite::GetCutLinkElementAtCutLinkElementIndex(int index) const +{ + return __pCutLinkListInfo->GetCutLinkElementAtCutLinkElementIndex(index); +} + +result +TextComposite::ResetAllCutLinkElementsState(void) +{ + return __pCutLinkListInfo->ResetAllCutLinkElementsState(); +} + +result +TextComposite::ChangeCutLinkState(int linkIndex, bool select) +{ + return __pCutLinkListInfo->ChangeCutLinkState(linkIndex, select); +} + +result +TextComposite::SetValueToAllTextElements(TextComponentInfoValueType type, unsigned int value) +{ + result r = E_SUCCESS; + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + TextElement* pNewTextElement = null; + + int startelementIndex = -1; + int endelementIndex = -1; + int textIndex = 0; + int textLength = 0; + int elementTextOffset = 0; + int elementIndex = 0; + int currentLength = 0; + int textIndexFromElementOffset = 0; + int found = false; + + textIndex = __workStart; + textLength = __workLength; + + if (textLength == 0) + { + return E_SUCCESS; + } + + while (0 < textLength) + { + pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + SysTryReturn(NID_GRP + , pTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + SysTryReturn(NID_GRP + , 0 < currentLength + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element node."); + + TextElementType objectType = pTextElement->GetType(); + TextElementType objectTypeFromValueType = TextUtility::GetObjectTypeFromValueType(type); + + unsigned int objectValue = pTextElement->GetValue(type); + if ((objectType == objectTypeFromValueType) && (value != objectValue)) + { + found = true; + startelementIndex = elementIndex; + break; + } + else if ((COMMONOBJECT_VALUE_START <= type && type < MAX_COMMONOBJECT_VALUE) && (value != objectValue)) + { + found = true; + startelementIndex = elementIndex; + break; + } + textIndex += currentLength; + textLength -= currentLength; + } + + if (found == false) + { + return E_SUCCESS; + } + + if (elementTextOffset == textIndex && textLength == currentLength) + { + pTextElement->SetValue(type, value); + goto TRUE_CATCH; + } + else if ((elementTextOffset < textIndex) && (textLength < currentLength)) + { + pTextElement->SetTextLength(pTextElement->GetTextLength() - currentLength); + + pNewTextElement = pTextElement->CloneN(type, value); + SysTryReturn(NID_GRP + , pNewTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to clone text element."); + + pNewTextElement->SetTextLength(textLength); + pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset); + + r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to insert element.", GetErrorMessage(r)); + + pNewTextElement = pTextElement->CloneN(SET_ALLVALUE_CLONE, 0); + SysTryReturn(NID_GRP + , pNewTextElement + , r, r, "[E_SYSTEM] Fail to clone text element."); + + pNewTextElement->SetTextLength(currentLength - textLength); + pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset + textLength); + + r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to insert element.", GetErrorMessage(r)); + + endelementIndex = elementIndex; + goto TRUE_CATCH; + } + else if (elementTextOffset < textIndex) + { + pTextElement->SetTextLength(pTextElement->GetTextLength() - currentLength); + + pNewTextElement = pTextElement->CloneN(type, value); + SysTryReturn(NID_GRP + , pNewTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to clone text element."); + + pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset); + pNewTextElement->SetTextLength(currentLength); + + r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to insert element.", GetErrorMessage(r)); + + textIndex += currentLength; + textLength -= currentLength; + if (textLength > 0) + { + pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, + textIndexFromElementOffset); + if (pTextElement == null) + { + goto TRUE_CATCH; + } + } + else + { + endelementIndex = elementIndex; + goto TRUE_CATCH; + } + } + + pEnum = __pTextElementList->GetEnumeratorN(); + for (int i = 0; i <= elementIndex; i++) + { + r = pEnum->MoveNext(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to move next element.", GetErrorMessage(r)); + } + + while (textLength > 0) + { + TextElementType objectType = pTextElement->GetType(); + TextElementType objectTypeFromValueType = TextUtility::GetObjectTypeFromValueType(type); + + if (objectType == objectTypeFromValueType) + { + if (value != objectTypeFromValueType) + { + if (textLength < currentLength) + { + pNewTextElement = pTextElement->CloneN(SET_ALLVALUE_CLONE, 0); + SysTryReturn(NID_GRP + , pNewTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to clone text element."); + + pNewTextElement->SetTextLength(currentLength - textLength); + pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset + textLength); + + pTextElement->SetValue(type, value); + pTextElement->SetTextLength(textLength); + + r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to insert element.", GetErrorMessage(r)); + + break; + } + else + { + pTextElement->SetValue(type, value); + } + + endelementIndex = elementIndex; + } + } + + elementTextOffset += currentLength; + textLength -= currentLength; + elementIndex++; + + if (pEnum->MoveNext() != E_SUCCESS) + { + break; + } + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + break; + } + + currentLength = pTextElement->GetTextLength(); + textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET); + } + +TRUE_CATCH: + Optimize(startelementIndex, endelementIndex); + Release(pEnum); + return E_SUCCESS; + +CATCH: + if (pNewTextElement != null) + { + delete pNewTextElement; + pNewTextElement = null; + } + + Release(pEnum); + return r; +} + +bool +TextComposite::SetAbbrevObjectFontInfo(TextSimple* pSimpleText) +{ + SysTryReturn(NID_GRP + , __pAbbrevTextElement + , false, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet."); + + __pAbbrevTextElement->SetFont(pSimpleText->GetFont()); + __pAbbrevTextElement->SetForegroundColor(pSimpleText->GetForegroundColor()); + __pAbbrevTextElement->SetBackgroundColor(pSimpleText->GetBackgroundColor()); + __pAbbrevTextElement->SetOutlineColor(pSimpleText->GetOutlineColor()); + __pAbbrevTextElement->SetAlternativeForegroundColor(pSimpleText->GetAlternativeForegroundColor()); + __pAbbrevTextElement->SetAlternateLookEnabled(pSimpleText->IsAlternateLookEnabled()); + + return true; +} + +int +TextComposite::ComposeInNoneWrap(Rectangle& rect, NoneWrapComposeInfo* pNoneWrapComposeInfo) +{ + SysTryReturn(NID_GRP + , __pCurrentTextColumn + , -1, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet."); + + TextLine* pTextLine = null; + Rectangle lineBounds; + Dimension textSize; + int lineOffset = 0; + int lineLength = 0; + int endType = TEXT_RETBY_NORMAL; + bool isChanged = false; + bool forwardSearch = true; + int textIndex = __workStart; + int baseline = 0; + + if (textIndex < 0) + { + textIndex = 0; + } + + if (textIndex > __length) + { + textIndex = __length; + } + + if (textIndex == __length) + { + forwardSearch = false; + } + + if (__pCurrentTextColumn->GetTotalLineCount() > 0) + { + pTextLine = __pCurrentTextColumn->GetTextLine(0); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineBounds = pTextLine->GetBounds(); + endType = pTextLine->GetEndType(); + + if (lineBounds.width != rect.width) + { + isChanged = true; + } + + lineOffset = pTextLine->GetTextOffset(); + lineLength = pTextLine->GetTextLength(); + + if (lineOffset <= textIndex && textIndex < lineOffset + lineLength) + { + isChanged = true; + } + } + else + { + pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + if (forwardSearch) + { + if (pNoneWrapComposeInfo != null) + { + lineOffset = pNoneWrapComposeInfo->prevTextOffset; + } + else + { + lineOffset = 0; + } + } + else + { + lineOffset = __length - 1; + } + + lineLength = 0; + lineBounds.width = rect.width; + lineBounds.x = 0; + lineBounds.y = 0; + lineBounds.height = 0; + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + + isChanged = true; + } + + if (isChanged) + { + lineBounds.width = rect.width; + lineBounds.x = 0; + lineBounds.y = 0; + + if (forwardSearch) + { +// endType = ForwardAnalyze(lineOffset, __length - lineOffset, lineBounds.width, __wrap, +// lineLength, textSize.width, textSize.height); + endType = ForwardAnalyzeWithBaseline(lineOffset, __length - lineOffset, lineBounds.width, __wrap, + lineLength, textSize.width, textSize.height, baseline); + + lineBounds.height = textSize.height; + pTextLine->SetBounds(lineBounds); + pTextLine->SetTextOffset(lineOffset); + pTextLine->SetTextLength(lineLength); + pTextLine->SetRegion(textSize.width, textSize.height); + pTextLine->SetEndType(endType); + pTextLine->SetBaseline(baseline); + } + else + { + int textCount = 0; + + BackwardAnalyze(lineOffset, lineBounds.width, &textCount, &textSize.width, &textSize.height); + + lineBounds.height = textSize.height; + lineOffset -= (textCount - 1); + lineLength = textCount; + if (lineOffset == 0) + { + endType = TEXT_RETBY_NORMAL; + } + else + { + endType = TEXT_RETBY_LIMITWIDTH; + } + + pTextLine->SetBounds(lineBounds); + pTextLine->SetTextOffset(lineOffset); + pTextLine->SetTextLength(lineLength); + pTextLine->SetRegion(textSize.width, textSize.height); + pTextLine->SetEndType(endType); + pTextLine->SetBaseline(baseline); + } + } + + if (__length == 0) + { + pTextLine->SetEndType(TEXT_RETBY_NORMAL); + return 1; + } + + rect.height = lineBounds.height; + + if (textIndex < lineOffset) + { + lineOffset = textIndex; + endType = ForwardAnalyze(lineOffset, __length - lineOffset, lineBounds.width, __wrap, + lineLength, textSize.width, textSize.height); + + lineBounds.height = textSize.height; + } + else if (forwardSearch && textIndex >= lineOffset + lineLength) + { + Dimension needDim; + GetRegion(lineOffset + lineLength, textIndex - (lineOffset + lineLength) + 1, + needDim.width, needDim.height); + + int index = 0; + int remainingWidth = needDim.width - (lineBounds.width - textSize.width); + + Dimension charDim; + textSize.width += needDim.width; + lineLength += textIndex - (lineOffset + lineLength) + 1; + + while (1) + { + GetRegion(lineOffset, 1, charDim.width, charDim.height); + lineOffset++; + index++; + remainingWidth -= charDim.width; + textSize.width -= charDim.width; + + if (remainingWidth <= 0) + { + break; + } + } + + lineLength -= index; + } + else if (endType != TEXT_RETBY_LIMITWIDTH && lineLength != __length) + { + if (lineOffset > 0) + { + Dimension lineTextSize; + int textCount = 0; + int remainingWidth = 0; + + pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height); + remainingWidth = lineBounds.width - lineTextSize.width; + BackwardAnalyze(lineOffset - 1, remainingWidth, &textCount, &textSize.width, &textSize.height); + + if (textSize.width > 0) + { + lineOffset -= textCount; + lineLength += textCount; + textSize.width += lineTextSize.width; + lineBounds.height = textSize.height; + endType = TEXT_RETBY_LIMITLENGTH; + } + else + { + return 1; + } + } + else + { + return 1; + } + } + else + { + return 1; + } + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(textSize.width, textSize.height); + pTextLine->SetTextLength(lineLength); + pTextLine->SetTextOffset(lineOffset); + pTextLine->SetEndType(endType); + pTextLine->SetBaseline(baseline); + + return 1; +} + +int +TextComposite::ComposeInWrap(Rectangle& rect) +{ + SysTryReturn(NID_GRP + , __pCurrentTextColumn + , -1, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet."); + + int textCount = 0; + int lineCount = 0; + int textIndex = 0; + int remainingLength = 0; + int remainingWidth = 0; + int remainingHeight = 0; + int offsetY = 0; + bool hasPrevLine = false; + Dimension textSize; + TextLine* pTextLine = null; + int ret = 0; + int endType = TEXT_RETBY_NORMAL; + Rectangle lineBounds; + Dimension lineTextSize; + int lineOffset = 0; + int lineLength = 0; + int displayLineCount = 0; + int displayHeight = 0; + int baseline = 0; + int lineBaseline = 0; + + pTextLine = __pCurrentTextColumn->GetPrevLineChangedStartLine(); + if (pTextLine != null) + { + endType = pTextLine->GetEndType(); + lineOffset = pTextLine->GetTextOffset(); + lineLength = pTextLine->GetTextLength(); + lineBounds = pTextLine->GetBounds(); + lineBaseline = pTextLine->GetBaseline(); + pTextLine->GetRegion(0, pTextLine->GetTextLength(), lineTextSize.width, lineTextSize.height); + + if (endType != TEXT_RETBY_LINEFEED) + { + textIndex = lineOffset + lineLength; + remainingLength = __length - textIndex; + remainingWidth = lineBounds.width - lineTextSize.width; + hasPrevLine = true; + + if (remainingLength == 0) + { + return -1; + } + } + else + { + textIndex = lineOffset + lineLength; + remainingLength = __length - textIndex; + remainingWidth = rect.width; + offsetY = lineBounds.y + lineBounds.height; + + if (remainingLength == 0) + { + int nextY = offsetY; + lineTextSize.height = lineBounds.height; + + pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + lineBounds.y = nextY; + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(0, lineTextSize.height); + pTextLine->SetTextLength(0); + pTextLine->SetTextOffset(textIndex); + pTextLine->SetEndType(TEXT_RETBY_LINEFEED); + pTextLine->SetBaseline(0); + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + + if (lineBounds.y + lineBounds.height <= rect.height) + { + __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount); + displayHeight += lineBounds.height; + __pCurrentTextColumn->SetDisplayHeight(displayHeight); + } + + return 1; + } + } + } + else + { + textIndex = 0; + remainingLength = __length; + remainingWidth = rect.width; + + __pCurrentTextColumn->SetChangedStartLineIndex(0); + } + + if (!hasPrevLine) + { + pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + lineBounds.x = rect.x; + lineBounds.width = rect.width; + lineBounds.y = offsetY; + lineTextSize.height = 0; + + if (remainingLength == 0) + { + lineTextSize.height = GetHeight(0); + lineBounds.height = lineTextSize.height; + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(0, lineTextSize.height); + pTextLine->SetTextLength(0); + pTextLine->SetTextOffset(textIndex); + pTextLine->SetEndType(TEXT_RETBY_NORMAL); + pTextLine->SetBaseline(0); + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + + if (lineBounds.y + lineBounds.height <= rect.height) + { + __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount); + displayHeight += lineBounds.height; + __pCurrentTextColumn->SetDisplayHeight(displayHeight); + } + + return 1; + } + } + + remainingHeight = rect.height; + + while (remainingLength != 0) + { + ret = ForwardAnalyzeWithBaseline(textIndex, remainingLength, remainingWidth, __wrap, textCount, textSize.width, textSize.height, baseline); + + if (ret == -1) + { + delete pTextLine; + pTextLine = null; + break; + } + + if (!hasPrevLine) + { + if (textCount == 0) + { + textCount = 1; + } + + lineOffset = textIndex; + lineLength = textCount; + lineTextSize.width = textSize.width; + lineTextSize.height = textSize.height; + lineBounds.height = textSize.height; + endType = ret; + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(lineTextSize.width, lineTextSize.height); + pTextLine->SetTextLength(lineLength); + pTextLine->SetTextOffset(lineOffset); + pTextLine->SetEndType(ret); + pTextLine->SetBaseline(baseline); + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + lineCount++; + + if (lineBounds.y + lineBounds.height <= rect.height) + { + __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount); + displayHeight += lineBounds.height; + __pCurrentTextColumn->SetDisplayHeight(displayHeight); + } + } + else + { + if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD) + { + if (ret != TEXT_RETBY_LIMITWIDTH) + { + lineLength += textCount; + lineTextSize.width += textSize.width; + lineBounds.height = Math::Max(lineBounds.height, textSize.height); + lineTextSize.height = lineBounds.height; + endType = ret; + baseline = Math::Min(lineBaseline, baseline); + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(lineTextSize.width, lineTextSize.height); + pTextLine->SetTextLength(lineLength); + pTextLine->SetEndType(endType); + pTextLine->SetBaseline(baseline); + } + else + { + textCount = 0; + } + } + else + { + lineLength += textCount; + lineTextSize.width += textSize.width; + lineBounds.height = Math::Max(lineBounds.height, textSize.height); + lineTextSize.height = lineBounds.height; + endType = ret; + baseline = Math::Min(lineBaseline, baseline); + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(lineTextSize.width, lineTextSize.height); + pTextLine->SetTextLength(lineLength); + pTextLine->SetEndType(endType); + pTextLine->SetBaseline(baseline); + } + + if (textCount > 0) + { + __pCurrentTextColumn->SetChangedStartLineIndex(pTextLine->GetIndex()); + } + + hasPrevLine = false; + } + + if (__pCurrentTextColumn->IsComposeDone()) + { + break; + } + + textIndex += textCount; + remainingLength -= textCount; + + remainingHeight -= lineTextSize.height; + + if (remainingLength > 0) + { + int nextY = lineBounds.y + lineBounds.height; + + pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + lineBounds.x = rect.x; + lineBounds.y = nextY; + lineBounds.width = rect.width; + lineTextSize.height = 0; + + remainingWidth = rect.width; + } + else + { + if (endType == TEXT_RETBY_LINEFEED) + { + int nextY = lineBounds.y + lineBounds.height; + lineTextSize.height = lineBounds.height; + + pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + lineBounds.x = rect.x; + lineBounds.y = nextY; + lineBounds.width = rect.width; + lineBounds.height = lineTextSize.height; + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(0, lineTextSize.height); + pTextLine->SetTextLength(0); + pTextLine->SetTextOffset(textIndex); + pTextLine->SetEndType(TEXT_RETBY_LINEFEED); + pTextLine->SetBaseline(0); + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + lineCount++; + + if (lineBounds.y + lineBounds.height <= rect.height) + { + __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount); + displayHeight += lineBounds.height; + __pCurrentTextColumn->SetDisplayHeight(displayHeight); + } + + pTextLine = null; + break; + } + } + } + + Dimension columnTextSize; + __pCurrentTextColumn->GetRegion(0, __length, columnTextSize.width, columnTextSize.height); + rect.height = columnTextSize.height; + + if (pTextLine) + { + __pCurrentTextColumn->SetChangedLastLineIndex(pTextLine->GetIndex()); + } + + if (Tizen::App::_AppInfo::IsOspCompat()) + { + __pCurrentTextColumn->SetDisplayLineCount(0); + __pCurrentTextColumn->SetDisplayHeight(0); + } + + return lineCount; +} + +int +TextComposite::ComposeInPartialMode(Rectangle& rect) +{ + SysTryReturn(NID_GRP + , __pCurrentTextColumn + , -1, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet."); + + int textCount = 0; + int lineCount = 0; + int textIndex = 0; + int remainingLength = 0; + int remainingWidth = 0; + int remainingHeight = 0; + int lineOffset = 0; + int lineLength = 0; + int offsetY = 0; + int ret = 0; + Dimension textSize; + Dimension lineTextSize; + Rectangle lineBounds; + bool hasPrevLine = false; + int displayLineCount = 0; + int displayHeight = 0; + int baseline = 0; + int lineBaseline = 0; + + TextLine* pTextLine = null; + int endType = TEXT_RETBY_NORMAL; + + if (__lineIndexCompositeDone != 0) + { + pTextLine = __pCurrentTextColumn->GetTextLine(__lineIndexCompositeDone - 1); + lineCount = __lineIndexCompositeDone; + } + + if (pTextLine != null) + { + endType = pTextLine->GetEndType(); + lineOffset = pTextLine->GetTextOffset(); + lineLength = pTextLine->GetTextLength(); + lineBounds = pTextLine->GetBounds(); + lineBaseline = pTextLine->GetBaseline(); + pTextLine->GetRegion(0, pTextLine->GetTextLength(), lineTextSize.width, lineTextSize.height); + + if (endType != TEXT_RETBY_LINEFEED) + { + textIndex = lineOffset + lineLength; + remainingLength = __length - textIndex; + remainingWidth = lineBounds.width - lineTextSize.width; + hasPrevLine = true; + + if (remainingLength == 0) + { + return -1; + } + } + else + { + textIndex = lineOffset + lineLength; + remainingLength = __length - textIndex; + remainingWidth = rect.width; + offsetY = lineBounds.y + lineBounds.height; + + if (remainingLength == 0) + { + int nextY = offsetY; + lineTextSize.height = lineBounds.height; + + pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + lineBounds.y = nextY; + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(0, lineTextSize.height); + pTextLine->SetTextLength(0); + pTextLine->SetTextOffset(textIndex); + pTextLine->SetEndType(TEXT_RETBY_LINEFEED); + pTextLine->SetBaseline(0); + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + + if (lineBounds.y + lineBounds.height <= rect.height) + { + __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount); + displayHeight += lineBounds.height; + __pCurrentTextColumn->SetDisplayHeight(displayHeight); + } + + return 1; + } + } + } + else + { + textIndex = 0; + remainingLength = __length; + remainingWidth = rect.width; + + __pCurrentTextColumn->SetChangedStartLineIndex(0); + } + + if (!hasPrevLine) + { + pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + lineBounds.x = rect.x; + lineBounds.width = rect.width; + lineBounds.y = offsetY; + lineTextSize.height = 0; + + if (remainingLength == 0) + { + lineTextSize.height = GetHeight(0); + lineBounds.height = lineTextSize.height; + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(0, lineTextSize.height); + pTextLine->SetTextLength(0); + pTextLine->SetTextOffset(textIndex); + pTextLine->SetEndType(TEXT_RETBY_NORMAL); + pTextLine->SetBaseline(0); + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + + if (lineBounds.y + lineBounds.height <= rect.height) + { + __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount); + displayHeight += lineBounds.height; + __pCurrentTextColumn->SetDisplayHeight(displayHeight); + } + + return 1; + } + } + + remainingHeight = GetComposePartialLimitHeight(); + if (remainingHeight == 0) + { + remainingHeight = rect.height; + } + if (remainingHeight < lineBounds.height && remainingLength > 0) + { + remainingHeight = lineBounds.height; + } + + while (remainingLength != 0) + { + //ret = ForwardAnalyze(textIndex, remainingLength, remainingWidth, __wrap, textCount, textSize.width, textSize.height); + ret = ForwardAnalyzeWithBaseline(textIndex, remainingLength, remainingWidth, __wrap, textCount, textSize.width, textSize.height, baseline); + + if (ret == -1) + { + delete pTextLine; + pTextLine = null; + break; + } + + if (!hasPrevLine) + { + if (textCount == 0) + { + textCount = 1; + } + + lineOffset = textIndex; + lineLength = textCount; + lineTextSize.width = textSize.width; + lineTextSize.height = textSize.height; + lineBounds.height = textSize.height; + endType = ret; + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(lineTextSize.width, lineTextSize.height); + pTextLine->SetTextLength(lineLength); + pTextLine->SetTextOffset(lineOffset); + pTextLine->SetEndType(endType); + pTextLine->SetBaseline(baseline); + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + + if (lineBounds.y + lineBounds.height <= rect.height) + { + __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount); + displayHeight += lineBounds.height; + __pCurrentTextColumn->SetDisplayHeight(displayHeight); + } + + lineCount++; + __lineIndexCompositeDone++; + __totalComposedHeight += lineTextSize.height; + } + else + { + if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD) + { + if (ret != TEXT_RETBY_LIMITWIDTH) + { + lineLength += textCount; + lineTextSize.width += textSize.width; + lineBounds.height = Math::Max(lineBounds.height, textSize.height); + lineTextSize.height = lineBounds.height; + endType = ret; + baseline = Math::Min(lineBaseline, baseline); + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(lineTextSize.width, lineTextSize.height); + pTextLine->SetTextLength(lineLength); + pTextLine->SetEndType(endType); + pTextLine->SetBaseline(baseline); + } + else + { + textCount = 0; + } + } + else + { + lineLength += textCount; + lineTextSize.width += textSize.width; + lineBounds.height = Math::Max(lineBounds.height, textSize.height); + lineTextSize.height = lineBounds.height; + endType = ret; + baseline = Math::Min(lineBaseline, baseline); + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(lineTextSize.width, lineTextSize.height); + pTextLine->SetTextLength(lineLength); + pTextLine->SetEndType(endType); + pTextLine->SetBaseline(baseline); + } + + if (textCount > 0) + { + __pCurrentTextColumn->SetChangedStartLineIndex(pTextLine->GetIndex()); + } + + hasPrevLine = false; + } + + if (__pCurrentTextColumn->IsComposeDone()) + { + break; + } + + textIndex += textCount; + remainingLength -= textCount; + remainingHeight -= lineTextSize.height; + + if (remainingHeight < 0) + { + return lineCount; + } + + if (remainingLength > 0) + { + int nextY = lineBounds.y + lineBounds.height; + + pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + lineBounds.x = rect.x; + lineBounds.y = nextY; + lineBounds.width = rect.width; + lineTextSize.height = 0; + + remainingWidth = rect.width; + } + else + { + if (endType == TEXT_RETBY_LINEFEED) + { + int nextY = lineBounds.y + lineBounds.height; + lineTextSize.height = lineBounds.height; + + pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + lineBounds.x = rect.x; + lineBounds.y = nextY; + lineBounds.width = rect.width; + lineBounds.height = lineTextSize.height; + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(0, lineTextSize.height); + pTextLine->SetTextLength(0); + pTextLine->SetTextOffset(textIndex); + pTextLine->SetEndType(TEXT_RETBY_LINEFEED); + pTextLine->SetBaseline(0); + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + + lineCount++; + + if (lineBounds.y + lineBounds.height <= rect.height) + { + __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount); + displayHeight += lineBounds.height; + __pCurrentTextColumn->SetDisplayHeight(displayHeight); + } + + __lineIndexCompositeDone++; + __totalComposedHeight += lineTextSize.height; + __pCurrentTextColumn->FinishCompose(); + + pTextLine = null; + break; + } + else + { + __pCurrentTextColumn->FinishCompose(); + } + } + } + + rect.height = __totalComposedHeight; + + if (pTextLine) + { + __pCurrentTextColumn->SetChangedLastLineIndex(pTextLine->GetIndex()); + } + + if (Tizen::App::_AppInfo::IsOspCompat()) + { + __pCurrentTextColumn->SetDisplayLineCount(0); + __pCurrentTextColumn->SetDisplayHeight(0); + } + + return lineCount; +} + +int +TextComposite::ComposeInNormalWrap(Rectangle& rect) +{ + return ComposeInWrap(rect); +} + +int +TextComposite::ComposeInWordWrap(Rectangle& rect) +{ + if (IsWidthManagerEnabled()) + { + return ComposeInWrapByTextWidth(rect); + } + else + { + return ComposeInWrap(rect); + } +} + +int +TextComposite::ComposeInNoneWrapMiddleEllipsis(Rectangle& rect) +{ + int endType = TEXT_RETBY_NORMAL; + Rectangle lineBounds; + Dimension abbrevTextDim; + Dimension textSize; + int length = 0; + int maxHeight = 0; + int baseline = 0; + + lineBounds.width = rect.width; + lineBounds.x = 0; + lineBounds.y = 0; + lineBounds.height = rect.height; + endType = ForwardAnalyzeWithBaseline(0, __length, lineBounds.width, __wrap, length, textSize.width, textSize.height, baseline); + + if (endType != TEXT_RETBY_LIMITWIDTH) + { + __drawTextEllipsis = false; + return ComposeInNoneWrap(rect); + } + + __drawTextEllipsis = true; + + TextElement* pTextElement = null; + TextSimple* pSimpleText = null; + + pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(0)); + SysTryReturn(NID_GRP + , pTextElement + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + TextElementType objectType = pTextElement->GetType(); + SysTryReturn(NID_GRP + , objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + pSimpleText = dynamic_cast < TextSimple* >(pTextElement); + if (pSimpleText != null) + { + SetAbbrevObjectFontInfo(pSimpleText); + } + + __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height); + __middleEllipsisWidth = abbrevTextDim.width; + + ForwardAnalyze(0, __length, ((lineBounds.width - __middleEllipsisWidth + 10) >> 1), __wrap, length, textSize.width, textSize.height); + __middleEllipsisTextLengthInHead = length; + __middleEllipsisHeadWidth = textSize.width; + + maxHeight = textSize.height; + + ForwardAnalyze(__middleEllipsisTextLengthInHead, __length - __middleEllipsisTextLengthInHead, lineBounds.width - __middleEllipsisWidth - + __middleEllipsisHeadWidth, __wrap, length, textSize.width, textSize.height); + __middleEllipsisTextLengthInTail = length; + + if (maxHeight < textSize.height) + { + maxHeight = textSize.height; + } + + TextLine* pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(lineBounds.width, maxHeight); + pTextLine->SetTextLength(__length); + pTextLine->SetTextOffset(0); + pTextLine->SetEndType(TEXT_RETBY_NORMAL); + pTextLine->SetBaseline(baseline); + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + + lineBounds.height = maxHeight; + + return 1; +} + +int +TextComposite::ComposeInNoneWrapHeadEllipsis(Rectangle& rect) +{ + SysTryReturn(NID_GRP + , __pCurrentTextColumn + , -1, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet."); + + int endType = TEXT_RETBY_NORMAL; + Rectangle lineBounds; + Dimension abbrevTextDim; + Dimension textSize; + int length = 0; + int maxHeight = 0; + int baseline = 0; + + lineBounds.width = rect.width; + lineBounds.x = 0; + lineBounds.y = 0; + lineBounds.height = rect.height; + endType = ForwardAnalyzeWithBaseline(0, __length, lineBounds.width, __wrap, length, textSize.width, textSize.height, baseline); + + if (endType != TEXT_RETBY_LIMITWIDTH) + { + __drawTextEllipsis = false; + return ComposeInNoneWrap(rect); + } + + __drawTextEllipsis = true; + TextElement* pTextElement = null; + TextSimple* pSimpleText = null; + + pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(0)); + SysTryReturn(NID_GRP + , pTextElement + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + TextElementType objectType = pTextElement->GetType(); + SysTryReturn(NID_GRP + , objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + pSimpleText = dynamic_cast < TextSimple* >(pTextElement); + if (pSimpleText != null) + { + SetAbbrevObjectFontInfo(pSimpleText); + } + + __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height); + __headEllipsisWidth = abbrevTextDim.width; + + BackwardAnalyze(__length - 1, lineBounds.width - abbrevTextDim.width, &__headEllipsisTextLength, &textSize.width, &textSize.height); + maxHeight = textSize.height; + + TextLine* pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(lineBounds.width, maxHeight); + pTextLine->SetTextLength(__length); + pTextLine->SetTextOffset(0); + pTextLine->SetEndType(TEXT_RETBY_NORMAL); + pTextLine->SetBaseline(baseline); + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + + lineBounds.height = maxHeight; + + return 1; +} + +result +TextComposite::DrawAbbrev(_CanvasImpl& canvasImpl, const Rectangle& displayRect, const TextObjectAlignment align) +{ + if (__TextObjectEllipsisType == TEXT_OBJECT_ELLIPSIS_TYPE_MIDDLE) + { + return DrawAbbrevInMiddleEllipsis(canvasImpl, displayRect, align); + } + else if (__TextObjectEllipsisType == TEXT_OBJECT_ELLIPSIS_TYPE_HEAD) + { + return DrawAbbrevInHeadEllipsis(canvasImpl, displayRect, align); + } + + return E_SYSTEM; +} + +result +TextComposite::GetValue(int textIndex, TextComponentInfoValueType type, unsigned int* value) const +{ + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + int offset = 0; + int elementTextLength = 0; + + pEnum = __pTextElementList->GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + continue; + } + + elementTextLength = pTextElement->GetTextLength(); + + if (textIndex < offset + elementTextLength) + { + TextElementType objectType = pTextElement->GetType(); + + if (objectType != TextUtility::GetObjectTypeFromValueType(type) && objectType != TEXT_ELEMENT_TYPE_CUTLINK) + { + Release(pEnum); + return E_INVALID_ARG; + } + + *value = pTextElement->GetValue(type); + Release(pEnum); + return E_SUCCESS; + } + + offset += elementTextLength; + } + + Release(pEnum); + return E_INVALID_ARG; +} + +bool +TextComposite::BackwardAnalyze(int startTextIndex, int maxWidth, int* actualLength, int* width, int* height) +{ + int remainingWidth = 0; + int length = 0; + Dimension textSize; + + *actualLength = 0; + *width = 0; + *height = 0; + + remainingWidth = maxWidth; + length = 1; + + while (startTextIndex >= 0 && textSize.width < remainingWidth) + { + GetRegion(startTextIndex, length, textSize.width, textSize.height); + + if (textSize.width <= remainingWidth) + { + *actualLength = length; + *width = textSize.width; + *height = textSize.height; + } + + startTextIndex--; + length++; + } + + return true; +} + +int +TextComposite::GetFirstTextIndexAt(int elementIndex) const +{ + SysTryReturn(NID_GRP + , elementIndex >= 0 && elementIndex < __pTextElementList->GetCount() + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + + int index = 0; + int elementTextOffset = 0; + + if (elementIndex == 0) + { + return 0; + } + + pEnum = __pTextElementList->GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + if (pTextElement == null) + { + continue; + } + + if (index == elementIndex) + { + break; + } + + elementTextOffset += pTextElement->GetTextLength(); + + pTextElement = null; + index++; + } + + Release(pEnum); + + if (pTextElement != null) + { + return elementTextOffset; + } + + return -1; +} + +result +TextComposite::DrawAbbrevInMiddleEllipsis(_CanvasImpl& canvasImpl, const Rectangle& displayRect, const TextObjectAlignment alignment) +{ + TextLine* pTextLine = __pCurrentTextColumn->GetTextLine(0); + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + Dimension textSize; + Rectangle adjustedRect; + + pTextLine->GetRegion(0, __length, textSize.width, textSize.height); + adjustedRect.x = displayRect.x; + adjustedRect.width = displayRect.width; + + switch (alignment & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + // fall through + default: + adjustedRect.y = displayRect.y; + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + adjustedRect.y = displayRect.y + (displayRect.height - textSize.height) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + adjustedRect.y = displayRect.y + (displayRect.height - textSize.height); + break; + } + adjustedRect.height = displayRect.height - (displayRect.y - adjustedRect.y); + + TextElement* pTextElement = null; + TextSimple* pSimpleText = null; + + pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(0)); + SysTryReturn(NID_GRP + , pTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + TextElementType objectType = pTextElement->GetType(); + SysTryReturn(NID_GRP + , objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to draw to symbol object."); + + pSimpleText = dynamic_cast < TextSimple* >(pTextElement); + if (pSimpleText != null) + { + SetAbbrevObjectFontInfo(pSimpleText); + } + + DrawPartial(canvasImpl, adjustedRect, 0, __middleEllipsisTextLengthInHead); + + adjustedRect.x += __middleEllipsisHeadWidth; + __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), TEXT_OBJECT_ACTION_TYPE_NONE); + + adjustedRect.x += __middleEllipsisWidth; + DrawPartial(canvasImpl, adjustedRect, __length - __middleEllipsisTextLengthInTail, __middleEllipsisTextLengthInTail); + + return E_SUCCESS; +} + +result +TextComposite::DrawAbbrevInHeadEllipsis(_CanvasImpl& canvasImpl, const Rectangle& displayRect, const TextObjectAlignment alignment) +{ + TextLine* pTextLine = __pCurrentTextColumn->GetTextLine(0); + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + result r = E_SUCCESS; + Dimension textSize; + Rectangle adjustedRect; + + pTextLine->GetRegion(0, __length, textSize.width, textSize.height); + adjustedRect.x = displayRect.x; + adjustedRect.width = displayRect.width; + + switch (alignment & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + // fall through + default: + adjustedRect.y = displayRect.y; + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + adjustedRect.y = displayRect.y + (displayRect.height - textSize.height) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + adjustedRect.y = displayRect.y + (displayRect.height - textSize.height); + break; + } + adjustedRect.height = displayRect.height - (displayRect.y - adjustedRect.y); + + TextElement* pTextElement = null; + TextSimple* pSimpleText = null; + + pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(0)); + r = GetLastResult(); + SysTryReturn(NID_GRP + , pTextElement + , r, r, "[%s] Fail to get element.", GetErrorMessage(r)); + + TextElementType objectType = pTextElement->GetType(); + SysTryReturn(NID_GRP + , objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to draw to symbol object."); + + pSimpleText = dynamic_cast < TextSimple* >(pTextElement); + if (pSimpleText != null) + { + SetAbbrevObjectFontInfo(pSimpleText); + } + + __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), TEXT_OBJECT_ACTION_TYPE_NONE); + + adjustedRect.x += __headEllipsisWidth; + DrawPartial(canvasImpl, adjustedRect, __length - __headEllipsisTextLength, __headEllipsisTextLength); + + return E_SUCCESS; +} + +result +TextComposite::DrawPartial(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength) +{ + SysTryReturn(NID_GRP + , 0 <= startTextIndex && startTextIndex < __length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SysTryReturn(NID_GRP + , textLength <= __length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + IEnumerator* pEnum = null; + TextElement* pTextElement = null; + + Dimension textSize; + int currentLength = 0; + int textIndexFromElementOffset = 0; + int nodeIndex = 0; + int elementTextOffset = 0; + Rectangle adjustedRect = displayRect; + int blockStartTextIndex = 0; + int blockEndTextIndex = 0; + bool isAlternateLookEnabled = false; + int textIndex = startTextIndex; + + _Canvas* pCanvas = _Canvas::GetInstance(canvasImpl); + SysTryReturn(NID_GRP + , pCanvas + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native canvas instance."); + + pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, nodeIndex, currentLength, + textIndexFromElementOffset); + SysTryReturn(NID_GRP + , pTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + currentLength = Math::Min(textLength, currentLength); + + pEnum = __pTextElementList->GetEnumeratorN(); + while (textLength > 0) + { + textLength -= currentLength; + + pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height); + + if (pTextElement->IsBackGroundDrawingModeEnable()) + { + r = pCanvas->FillRectangle(pTextElement->GetBackgroundColor(), Rectangle(adjustedRect.x, displayRect.y, textSize.width, displayRect.height)); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + isAlternateLookEnabled = pTextElement->GetValue(SET_ALTERNATE_LOOK); + if ((__displayBlock) && (isAlternateLookEnabled == false)) + { + Dimension tempTextSize; + int adjustedX = 0; + + blockStartTextIndex = Math::Max(__workStart, textIndex); + blockEndTextIndex = Math::Min(__workStart + __workLength, textIndex + currentLength); + if (blockStartTextIndex < blockEndTextIndex) + { + blockStartTextIndex = textIndexFromElementOffset + (blockStartTextIndex - textIndex); + blockEndTextIndex = textIndexFromElementOffset + (blockEndTextIndex - textIndex); + adjustedX = adjustedRect.x; + + if (textIndexFromElementOffset < blockStartTextIndex) + { + pTextElement->GetRegion(textIndexFromElementOffset, blockStartTextIndex - textIndexFromElementOffset, + tempTextSize.width, tempTextSize.height); + adjustedX += tempTextSize.width; + } + + Rectangle blockRect = adjustedRect; + blockRect.x = adjustedX; + } + } + + pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), + TEXT_OBJECT_ACTION_TYPE_NONE); + + adjustedRect.x += textSize.width; + adjustedRect.width -= textSize.width; + + if (!textLength || adjustedRect.width <= 0) + { + break; + } + + textIndex += currentLength; + + if (pEnum->MoveNext() != E_SUCCESS) + { + break; + } + + pTextElement = static_cast < TextElement* >(pEnum->GetCurrent()); + + textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = Math::Min(textLength, pTextElement->GetTextLength()); + + if (currentLength == 0) + { + break; + } + } + + Release(pEnum); + return E_SUCCESS; +} + +void +TextComposite::SetPartialComposingModeEnabled(bool enable) +{ + __partialComposingModeEnabled = enable; +} + +bool +TextComposite::IsPartialComposingModeEnabled(void) const +{ + return __partialComposingModeEnabled; +} + +bool +TextComposite::InitPartialComposeMode(void) +{ + __lineIndexCompositeDone = 0; + __totalComposedHeight = 0; + __composePartialLimitHeight = 0; + + SysTryReturn(NID_GRP + , __pCurrentTextColumn + , false, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet."); + + __pCurrentTextColumn->SetFirstDisplayLineIndex(0); + __pCurrentTextColumn->SetFirstDisplayPositionY(0); + __pCurrentTextColumn->PrepareCompose(); + + return true; +} + +bool +TextComposite::IsComposeDone() const +{ + SysTryReturn(NID_GRP + , __pCurrentTextColumn + , false, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet."); + + return __pCurrentTextColumn->IsComposeDone(); +} + +int +TextComposite::ComposeInWrapByTextWidth(Rectangle& rect) +{ + SysTryReturn(NID_GRP + , __pCurrentTextColumn + , false, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet."); + + Rectangle lineBounds; + int lineCount = 0; + int textIndex = 0; + int remainingLength = 0; + int remainingWidth = 0; + int remainingHeight = 0; + int offsetY = 0; + bool hasPrevLine = false; + int endType = TEXT_RETBY_NORMAL; + Dimension lineTextSize; + int lineOffset = 0; + int lineLength = 0; + TextLine* pTextLine = null; + + pTextLine = __pCurrentTextColumn->GetPrevLineChangedStartLine(); + if (pTextLine != null) + { + endType = pTextLine->GetEndType(); + lineOffset = pTextLine->GetTextOffset(); + lineLength = pTextLine->GetTextLength(); + lineBounds = pTextLine->GetBounds(); + pTextLine->GetRegion(0, pTextLine->GetTextLength(), lineTextSize.width, lineTextSize.height); + + if (endType != TEXT_RETBY_LINEFEED) + { + textIndex = lineOffset; + remainingLength = __length - textIndex; + remainingWidth = rect.width; + hasPrevLine = true; + + if (remainingLength == 0) + { + return -1; + } + } + else + { + textIndex = lineOffset + lineLength; + remainingLength = __length - textIndex; + remainingWidth = rect.width; + offsetY = lineBounds.y + lineBounds.height; + lineBounds.y = offsetY; + + if (remainingLength == 0) + { + lineTextSize.height = lineBounds.height; + + pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(0, lineTextSize.height); + pTextLine->SetTextLength(0); + pTextLine->SetTextOffset(textIndex); + pTextLine->SetEndType(TEXT_RETBY_LINEFEED); + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + + return 1; + } + } + } + else + { + textIndex = 0; + remainingLength = __length; + remainingWidth = rect.width; + lineBounds.x = rect.x; + lineBounds.y = 0; + lineBounds.width = rect.width; + } + + remainingHeight = rect.height; + + __pTextWidthManager->StartCompose(textIndex); + + TextLineComposeInfo composeInfo; + composeInfo.height = 0; + composeInfo.width = 0; + composeInfo.length = 0; + composeInfo.endType = TEXT_RETBY_NORMAL; + + while (remainingLength != 0) + { + __pTextWidthManager->GetCurrentLineInfo(remainingWidth, composeInfo); + composeInfo.height += __lineSpacing; + + if (hasPrevLine) + { + lineBounds.height = composeInfo.height; + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(composeInfo.width, composeInfo.height); + pTextLine->SetTextLength(composeInfo.length); + pTextLine->SetEndType(composeInfo.endType); + hasPrevLine = false; + } + else + { + if (composeInfo.length == 0) + { + composeInfo.length = 1; + } + + pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + lineBounds.height = composeInfo.height; + + pTextLine->SetBounds(lineBounds); + pTextLine->SetTextOffset(textIndex); + pTextLine->SetRegion(composeInfo.width, composeInfo.height); + pTextLine->SetTextLength(composeInfo.length); + pTextLine->SetEndType(composeInfo.endType); + + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + lineCount++; + } + + if (__pCurrentTextColumn->IsComposeDone()) + { + break; + } + + textIndex += composeInfo.length; + remainingLength -= composeInfo.length; + remainingHeight -= composeInfo.height; + + if (remainingLength > 0) + { + int nextY = lineBounds.y + lineBounds.height; + + lineBounds.x = rect.x; + lineBounds.y = nextY; + lineBounds.width = rect.width; + lineTextSize.height = 0; + remainingWidth = rect.width; + } + else + { + if (composeInfo.endType == TEXT_RETBY_LINEFEED) + { + int nextY = lineBounds.y + lineBounds.height; + lineTextSize.height = lineBounds.height; + + pTextLine = new (std::nothrow)TextLine(this); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + lineBounds.x = rect.x; + lineBounds.y = nextY; + lineBounds.width = rect.width; + lineBounds.height = lineTextSize.height; + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(0, lineTextSize.height); + pTextLine->SetTextLength(0); + pTextLine->SetTextOffset(textIndex); + pTextLine->SetEndType(TEXT_RETBY_LINEFEED); + __pCurrentTextColumn->AddLineDuringCompose(pTextLine); + + lineCount++; + + pTextLine = null; + break; + } + else + { + pTextLine = null; + } + } + } + + __pTextWidthManager->EndCompose(); + + Dimension columnSize; + __pCurrentTextColumn->GetRegion(0, __length, columnSize.width, columnSize.height); + rect.height = columnSize.height; + + return lineCount; +} + +result +TextComposite::GetCutLinkObjectInfo(int cutLinkIndex, int& textStartIndex, int& textLength) const +{ + return __pCutLinkListInfo->GetCutLinkObjectInfo(cutLinkIndex, textStartIndex, textLength); +} + +int +TextComposite::GetTotalComposedHeight(void) const +{ + return __totalComposedHeight; +} + +int +TextComposite::GetAnalysedTotalHeight(void) const +{ + TextLine* pTextLine = null; + pTextLine = __pCurrentTextColumn->GetTextLine(__lineIndexCompositeDone - 1); + + if (!pTextLine) + { + return 0; + } + + int lineOffset = pTextLine->GetTextOffset(); + int lineLength = pTextLine->GetTextLength(); + + int composedLength = lineOffset + lineLength; + if (composedLength == 0) + { + return 0; + } + + return (int)(GetTotalComposedHeight() * __length / composedLength); +} + +void +TextComposite::SetComposePartialLimitHeight(int limitHeight) +{ + __composePartialLimitHeight = limitHeight; +} + +int +TextComposite::GetComposePartialLimitHeight(void) const +{ + return __composePartialLimitHeight; + +} + +TextElementType +TextComposite::GetObjectType(int textIndex) const +{ + TextElement* pTextElement = null; + + int currentLength = 0; + int elementIndex = 0; + int textIndexFromElementOffset = 0; + int elementTextOffset = 0; + + pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset + , elementIndex, currentLength, textIndexFromElementOffset); + if (pTextElement == null) + { + return TEXT_ELEMENT_TYPE_NONE; + } + else + { + return pTextElement->GetType(); + } +} + +int +TextComposite::GetElementIndexOf(TextElement& textElement) const +{ + int index = 0; + + result r = E_SUCCESS; + + r = __pTextElementList->IndexOf(textElement, index); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , false, r, "[%s] Fail to add element.", GetErrorMessage(r)); + + return index; +} + +TextElement* +TextComposite::GetElementAtElementIndex(int nodeIndex) const +{ + result r = E_SUCCESS; + + TextElement* pTextElement = null; + pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(nodeIndex)); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , null, r, "[%s] Fail to add element.", GetErrorMessage(r)); + + return pTextElement; +} + +int +TextComposite::GetTextLength(void) const +{ + return __length; +} + +int +TextComposite::GetElementCount(void) const +{ + return __pTextElementList->GetCount(); +} + +void +TextComposite::SetBlock(bool enable) +{ + __displayBlock = enable; +} + +result +TextComposite::SetImageAlign(TextObjectAlignment align) +{ + return SetValueToAllTextElements(SET_IMAGE_ALIGN, (unsigned int)align); +} + +TextObjectWrapType +TextComposite::GetWrap(void) const +{ + return __wrap; +} + +void +TextComposite::SetLineSpace(int gap) +{ + __lineSpacing = gap; +} + +int +TextComposite::GetLineSpace(void) const +{ + return __lineSpacing; +} + +void +TextComposite::SetElementVerticalAlignment(TextObjectAlignment alignment) +{ + __elementVertialAlignment = alignment; +} + +TextObjectAlignment +TextComposite::GetElementVerticalAlignment(void) const +{ + return __elementVertialAlignment; +} + +void +TextComposite::SetCursorIndex(int cursorIndex) +{ + __cursorIndex = cursorIndex; +} + +int +TextComposite::GetCursorIndex(void) const +{ + return __cursorIndex; +} + +void +TextComposite::SetTextObjectEllipsisType(TextObjectEllipsisType type) +{ + __TextObjectEllipsisType = type; +} + +TextObjectEllipsisType +TextComposite::GetTextObjectEllipsisType(void) const +{ + return __TextObjectEllipsisType; +} + +void +TextComposite::SetTextAbbreviationEnabled(bool enable) +{ + __drawAbbrevText = enable; +} + +bool +TextComposite::IsTextAbbreviationEnabled(void) const +{ + if (__drawAbbrevText && __drawTextEllipsis) + { + return true; + } + + return false; +} + +bool +TextComposite::GetBlock(void) const +{ + return __displayBlock; +} + +int +TextComposite::GetWorkStart(void) const +{ + return __workStart; +} + +int +TextComposite::GetWorkLength(void) const +{ + return __workLength; +} + +TextObjectAlignment +TextComposite::GetImageAlign(int textIndex) const +{ + result r = E_SUCCESS; + unsigned int value = 0; + + r = GetValue(textIndex, SET_IMAGE_ALIGN, &value); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , TEXT_OBJECT_ALIGNMENT_INVALID, r, "[%s] Propagating.", GetErrorMessage(r)); + + return (TextObjectAlignment)value; +} + +bool +TextComposite::IsChanged(void) const +{ + return __isChanged; +} + +void +TextComposite::SetBlockColor(const Color& color) +{ + __defaultBlockColor = color; +} + +Color +TextComposite::GetBlockColor(void) const +{ + return __defaultBlockColor; +} + +void +TextComposite::SetTextWidthManager(TextWidthManager* pTextWidthManager) +{ + __pTextWidthManager = pTextWidthManager; +} + +void +TextComposite::SetWidthManagerEnabled(bool widthManagerEnable) +{ + __widthManagerEnabled = widthManagerEnable; +} + +bool +TextComposite::IsWidthManagerEnabled(void) const +{ + return __widthManagerEnabled; +} + +result +TextComposite::SetWorkWidth(Font* pFont, wchar_t* pText, int workStart, int textLength) +{ + result r = E_SUCCESS; + int width = 0; + int height = 0; + int workLength = 0; + const wchar_t* pSrc = &pText[workStart]; + + workLength = Math::Abs(textLength); + + r = TextUtility::GetTextExtent(pFont, pSrc, workLength, false, width, height); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (textLength < 0) + { + __workWidth = -width; + } + else + { + __workWidth = width; + } + + return E_SUCCESS; +} + +int +TextComposite::GetWorkWidth(void) +{ + return __workWidth; +} + +void +TextComposite::SetTextSweepInfo(TextObjectSweepInfo* pTextSweepInfo) +{ + __pSweepInfo = pTextSweepInfo; +} + +void +TextComposite::GetTextSweepInfo(TextObjectSweepInfo& textSweepInfo) +{ + textSweepInfo.isValid = __pSweepInfo->isValid; + textSweepInfo.sweepType = __pSweepInfo->sweepType; + textSweepInfo.sweepEventType = __pSweepInfo->sweepEventType; + textSweepInfo.anchorTextIndex = __pSweepInfo->anchorTextIndex; + textSweepInfo.anchorLineIndex = __pSweepInfo->anchorLineIndex; + textSweepInfo.sweepRegionStartLineIndex = __pSweepInfo->sweepRegionStartLineIndex; + textSweepInfo.sweepRegionLineCount = __pSweepInfo->sweepRegionLineCount; + textSweepInfo.insertedLineCount = __pSweepInfo->insertedLineCount; + textSweepInfo.deletedLineCount = __pSweepInfo->deletedLineCount; + textSweepInfo.widthChanged = __pSweepInfo->widthChanged; +} + +void +TextComposite::UpdateTextSweepInfo(TextObjectSweepInfo* pTextSweepInfo) +{ + __pSweepInfo->isValid = pTextSweepInfo->isValid; + __pSweepInfo->sweepType = pTextSweepInfo->sweepType; + __pSweepInfo->sweepEventType = pTextSweepInfo->sweepEventType; + __pSweepInfo->anchorTextIndex = pTextSweepInfo->anchorTextIndex; + __pSweepInfo->anchorLineIndex = pTextSweepInfo->anchorLineIndex; + __pSweepInfo->sweepRegionStartLineIndex = pTextSweepInfo->sweepRegionStartLineIndex; + __pSweepInfo->sweepRegionLineCount = pTextSweepInfo->sweepRegionLineCount; + __pSweepInfo->insertedLineCount = pTextSweepInfo->insertedLineCount; + __pSweepInfo->deletedLineCount = pTextSweepInfo->deletedLineCount; + __pSweepInfo->widthChanged = pTextSweepInfo->widthChanged; +} + +}}} // Tizen::Graphics::_Text diff --git a/src/graphics/text/FGrp_TextTextComposite.h b/src/graphics/text/FGrp_TextTextComposite.h new file mode 100644 index 0000000..b4f5121 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextComposite.h @@ -0,0 +1,312 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextComposite.h + * @brief This file contains the declarations of TextComposite class. + */ + +#ifndef _FGRP_INTERNAL_TEXT_COMPOSITE_H_ +#define _FGRP_INTERNAL_TEXT_COMPOSITE_H_ + +#include +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextElement.h" + +namespace Tizen { namespace Graphics +{ +class _CanvasImpl; + +namespace _Text +{ + +class TextSimple; +class TextCutLink; +class TextLine; +class TextColumn; +class TextCutLinkListInfo; +class TextWidthManager; +struct NoneWrapComposeInfo; + +class TextComposite +{ +public: + TextComposite(TextElement* pTextElement = null); + + virtual ~TextComposite(void); + +public: + virtual int ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, + int& actualLength, int& width, int& height); + + virtual int ForwardAnalyzeWithBaseline(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, + int& actualLength, int& width, int& height, int& baseline); + + virtual int ForwardAnalyzeWithFocusedObjectType(int textIndex, int textLength, int maxWidth, + int& cursorIndex, TextElementType& type); + + virtual result Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment, + const TextObjectActionType action); + + virtual result GetRegion(int textIndex, int textLength, int& width, int& height) const; + + virtual int GetHeight(int textIndex) const; + + virtual int GetTextLength(void) const; + + virtual int Compose(Rectangle& rect, TextColumn* pTextColumn); + + result DrawWithBaseline(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment, + const TextObjectActionType action, int baseline); + + result InsertElementAt(TextElement& textElement, int textIndex); + + result AppendElement(TextElement& textElement); + + result RemoveElementAt(int elementIndex, bool deallocate = true); + + result RemoveAllElements(bool deallocate = true); + + result DrawLine(_CanvasImpl& canvasImpl, TextLine* pTextLine, const Rectangle& displayRect, const TextObjectAlignment align, const TextObjectActionType action); + + result DrawPartial(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength); + + result DrawAbbrev(_CanvasImpl& canvasImpl, const Rectangle& displayRect, const TextObjectAlignment align); + + result GetText(TextComposite* pTargetCompsiteText, int textIndex, int textLength); + + result Optimize(int startElementIndex, int endElementIndex); + + bool IsComposeDone(void) const; + + result ChangeTextOffset(wchar_t* pText, int elementIndex, int gap); + + result NotifyTextChanged(wchar_t* pText, int startTextIndex, int textLength, int gap, Font* pFont, + const Color& fgColor, const Color& bgColor, const Color& outlineColor); + + void HideFrontSpace(TextObjectSpaceHideType mode); + + void HideRearSpace(TextObjectSpaceHideType mode); + + result GetValue(TextElement* pTextElement, TextComponentInfoValueType type, unsigned int* value) const; + + int GetElementCount(void) const; + + int GetElementIndexOf(TextElement& textElement) const; + + TextElement* GetElementAtElementIndex(int elementIndex) const; + + TextElement* GetElementAtTextIndex(int textIndex, int& elementTextOffset, int& elementIndex, int& elementTextLength, + int& textIndexFromElementOffset) const; + + TextElement* GetElementAtTextIndex(int textIndex) const; + + result SetFont(Font* pFont); + + Font* GetFont(int textIndex) const; + + result SetForegroundColor(const Color& color); + + Color GetForegroundColor(int textIndex) const; + + result SetBackgroundColor(const Color& color); + + Color GetBackgroundColor(int textIndex) const; + + result SetOutlineColor(const Color& color); + + Color GetOutlineColor(int textIndex) const; + + Color GetAlternativeForegroundColor(int textIndex) const; + + result SetRange(int textStartIndex, int textLength); + + void GetRange(int& startTextIndex, int& textLength) const; + + void SetLineSpace(int gap); + + int GetLineSpace(void) const; + + void SetElementVerticalAlignment(TextObjectAlignment alignment); + + TextObjectAlignment GetElementVerticalAlignment(void) const; + + result SetWrap(TextObjectWrapType wrap); + + TextObjectWrapType GetWrap(void) const; + + void SetBlock(bool enable); + + bool GetBlock(void) const; + + result SetImageAlign(TextObjectAlignment align); + + TextObjectAlignment GetImageAlign(int textIndex) const; + + void SetCursorIndex(int cursorIndex); + + int GetCursorIndex(void) const; + + void SetTextAbbreviationEnabled(bool enable); + + bool IsTextAbbreviationEnabled(void) const; + + void SetPartialComposingModeEnabled(bool enable); + + bool IsPartialComposingModeEnabled(void) const; + + void SetComposePartialLimitHeight(int limitHeight); + + int GetComposePartialLimitHeight(void) const; + + void SetWidthManagerEnabled(bool widthManagerEnable); + + bool IsWidthManagerEnabled(void) const; + + void SetTextObjectEllipsisType(TextObjectEllipsisType type); + + TextObjectEllipsisType GetTextObjectEllipsisType(void) const; + + int ForwardAnalyzeInNoneCursorMode(int startTextIndex, int textLength, int maxWidth, int& textIndex); + + int GetTotalComposedHeight(void) const; + + int GetAnalysedTotalHeight(void) const; + + bool IsChanged(void) const; + + result ChangeCutLinkState(int linkIndex, bool select); + + result ResetAllCutLinkElementsState(void); + + int GetCutLinkElementCount(void) const; + + int GetCutLinkElementIndexAt(int textIndex) const; + + TextCutLink* GetCutLinkElementAtCutLinkElementIndex(int index) const; + + result GetCutLinkObjectInfo(int cutLinkIndex, int& textStartIndex, int& textLength) const; + + bool InitPartialComposeMode(void); + + void SetTextWidthManager(TextWidthManager* pTextWidthManager); + + TextElement* SearchTextElement(TextElementType type, int textIndex, int& elementTextOffset) const; + + TextElementType GetObjectType(int textIndex) const; + + int GetMaxLineHeight(void) const; + + int GetWorkStart(void) const; + + int GetWorkLength(void) const; + + result SetAlternateLookEnabled(bool enable); + + result SetWorkWidth(Font* pFont, wchar_t* pText, int workStart, int textLength); + + int GetWorkWidth(void); + + void SetTextSweepInfo(TextObjectSweepInfo* pTextSweepInfo); + + void GetTextSweepInfo(TextObjectSweepInfo& textSweepInfo); + + void UpdateTextSweepInfo(TextObjectSweepInfo* pTextSweepInfo); + + void SetBlockColor(const Color& color); + + Color GetBlockColor(void) const; + +private: + int ComposeInNoneWrap(Rectangle& rect, NoneWrapComposeInfo* pNoneWrapComposeInfo = null); + + int ComposeInNormalWrap(Rectangle& rect); + + int ComposeInWordWrap(Rectangle& rect); + + int ComposeInWrap(Rectangle& rect); + + int ComposeInWrapByTextWidth(Rectangle& rect); + + int ComposeInNoneWrapMiddleEllipsis(Rectangle& rect); + + int ComposeInNoneWrapHeadEllipsis(Rectangle& rect); + + int ComposeInPartialMode(Rectangle& rect); + + bool BackwardAnalyze(int startTextIndex, int maxWidth, int* actualLength, int* width, int* height); + + result DrawAbbrevInMiddleEllipsis(_CanvasImpl& canvasImpl, const Rectangle& displayRect, const TextObjectAlignment alignment); + + result DrawAbbrevInHeadEllipsis(_CanvasImpl& canvasImpl, const Rectangle& displayRect, const TextObjectAlignment alignmen); + + result SetValueToAllTextElements(TextComponentInfoValueType type, unsigned int value); + + bool SetAbbrevObjectFontInfo(TextSimple* pSimpleTextElement); + + result GetValue(int textIndex, TextComponentInfoValueType type, unsigned int* value) const; + + int GetFirstTextIndexAt(int elementIndex) const; + +private: + bool __isChanged; + TextObjectWrapType __wrap; + int __length; + Tizen::Base::Collection::LinkedList* __pTextElementList; + Color __defaultBlockColor; + bool __displayBlock; + int __workStart; + int __workLength; + int __workWidth; + int __cursorIndex; + bool __ignoreRearBlank; + bool __ignoreFrontBlank; + TextObjectSpaceHideType __rearSpaceHideMode; + TextObjectSpaceHideType __frontSpaceHideMode; + int __lineSpacing; + TextObjectAlignment __elementVertialAlignment; + TextColumn* __pCurrentTextColumn; + TextSimple* __pAbbrevTextElement; + bool __partialComposingModeEnabled; + int __lineIndexCompositeDone; + int __totalComposedHeight; + int __composePartialLimitHeight; + TextCutLinkListInfo* __pCutLinkListInfo; + TextObjectEllipsisType __TextObjectEllipsisType; + bool __drawAbbrevText; + bool __drawTextEllipsis; + int __middleEllipsisTextLengthInHead; + int __middleEllipsisHeadWidth; + int __middleEllipsisWidth; + int __middleEllipsisTextLengthInTail; + int __headEllipsisWidth; + int __headEllipsisTextLength; + TextWidthManager* __pTextWidthManager; + bool __widthManagerEnabled; + + TextObjectSweepInfo* __pSweepInfo; + +private: + TextComposite(const TextComposite&); // NOT IMPLMENTED + + TextComposite& operator =(const TextComposite&); // NOT IMPLMENTED + +}; // TextComposite + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_COMPOSITE_H_ diff --git a/src/graphics/text/FGrp_TextTextCutLink.cpp b/src/graphics/text/FGrp_TextTextCutLink.cpp new file mode 100644 index 0000000..41d90dc --- /dev/null +++ b/src/graphics/text/FGrp_TextTextCutLink.cpp @@ -0,0 +1,328 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextCutLink.cpp + * @brief This is the implementation file for TextCutLink class. + */ + +#include +#include +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextUtility.h" +#include "FGrp_TextTextElement.h" +#include "FGrp_TextTextSimple.h" +#include "FGrp_TextTextCutLink.h" +#include "FGrp_CanvasImpl.h" + +using namespace Tizen::Base::Utility; + +namespace // unnamed +{ + const int DEFAULT_FONT_SIZE = 42; +} + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +TextCutLink::TextCutLink(bool isEditable, LinkType cutLinkType, const wchar_t* pText, int length, TextElementSourceType sourceType, + Font* pFont, const Color& foregroundColor, const Color& backgroundColor, const Color& + outlineColor) + : TextSimple(pText, length, sourceType, pFont, foregroundColor, backgroundColor, outlineColor) +{ + __linkType = cutLinkType; + __isEditable = isEditable; + __isEdited = false; + __isSelected = false; + _type = TEXT_ELEMENT_TYPE_CUTLINK; + __isColorDefined = false; + __linkColor = Color::GetColor(COLOR_ID_BLUE); + __linkSelectedColor = Color::GetColor(COLOR_ID_BLUE); + + __pLinkFont = new (std::nothrow) Font(); + __pLinkFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE); +} + +TextCutLink::~TextCutLink(void) +{ + if (__pLinkFont) + { + delete __pLinkFont; + __pLinkFont = null; + } +} + +result +TextCutLink::Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment align, + const TextObjectActionType action) +{ + SysTryReturn(NID_GRP + , displayRect.x >= 0 && displayRect.y >= 0 + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return TextSimple::Draw(canvasImpl, displayRect, startTextIndex, textLength, align, action); +} + +TextElement* +TextCutLink::CloneN(TextComponentInfoValueType type, unsigned int value) +{ + TextCutLink* pLinkElement = null; + + pLinkElement = new (std::nothrow) TextCutLink(__isEditable, __linkType, _pText, _length, + TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, _pFont, _foregroundColor, _backgroundColor, _outlineColor); + + SysTryReturn(NID_GRP + , pLinkElement + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + TextElement::CopyMembers(pLinkElement); + + pLinkElement->__isEdited = __isEdited; + pLinkElement->SetValue(type, value); + + return pLinkElement; +} + +TextElement* +TextCutLink::CopyN(int textStartIndex, int textLength) +{ + const wchar_t* pText = null; + + TextCutLink* pLinkElement = null; + + SysTryReturn(NID_GRP + , textStartIndex < _length + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + if (textStartIndex + textLength > _length) + { + textLength = _length - textStartIndex; + } + + SysTryReturn(NID_GRP + , textLength >= 0 + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + pText = &_pText[_offset + textStartIndex]; + + pLinkElement = new (std::nothrow) TextCutLink(__isEditable, __linkType, pText, textLength, _sourceType, + _pFont, _foregroundColor, _backgroundColor, _outlineColor); + + SysTryReturn(NID_GRP + , pLinkElement + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pLinkElement->_isBackgroundDrawingModeEnabled = _isBackgroundDrawingModeEnabled; + pLinkElement->__isEdited = __isEdited; + + return pLinkElement; +} + +result +TextCutLink::SetValue(TextComponentInfoValueType type, unsigned int value) +{ + switch (type) + { + case SET_CUTLINK_TYPE: + // fall through + return E_INVALID_ARG; + + case SET_CUTLINK_EDITABLE: + // fall through + return E_INVALID_ARG; + + case SET_CUTLINK_EDITING: + if (__isEditable) + { + __isEdited = (bool) value; + return E_SUCCESS; + } + return E_INVALID_ARG; + + default: + break; + } + + if (!__isEdited && type == SET_TEXT_OFFSET) + { + return E_INVALID_ARG; + } + + return TextSimple::SetValue(type, value); +} + +unsigned int +TextCutLink::GetValue(TextComponentInfoValueType type) const +{ + switch (type) + { + case SET_CUTLINK_TYPE: + // fall through + return (unsigned int) __linkType; + + case SET_CUTLINK_EDITABLE: + // fall through + return (unsigned int) __isEditable; + + case SET_CUTLINK_EDITING: + // fall through + return (unsigned int) __isEdited; + + default: + // fall through + return TextSimple::GetValue(type); + } +} + +void +TextCutLink::SetSelect(bool isSelected) +{ + __isSelected = isSelected; +} + +bool +TextCutLink::GetSelect(void) const +{ + return __isSelected; +} + +void +TextCutLink::SetUserColor(const Color& color, const Color& colorInSelect) +{ + __isColorDefined = true; + __linkColor = color; + __linkSelectedColor = colorInSelect; +} + +void +TextCutLink::ResetUserColor(void) +{ + __isColorDefined = false; +} + +result +TextCutLink::SetTextOffset(int offset) +{ + SysTryReturn(NID_GRP + , __isEdited == true + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return TextSimple::SetTextOffset(offset); +} + +result +TextCutLink::ChangeTextOffset(wchar_t* pText, int gap) +{ + SysTryReturn(NID_GRP + , __isEdited == true + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return TextSimple::ChangeTextOffset(pText, gap); +} + +Font* +TextCutLink::GetCurrentFont(void) const +{ + if (__isEdited) + { + return TextSimple::GetCurrentFont(); + } + + return __pLinkFont; +} + +Color +TextCutLink::GetCurrentForegroundColor(void) const +{ + if (__isEdited) + { + return TextSimple::GetCurrentForegroundColor(); + } + + if (__isColorDefined) + { + if (__isSelected) + { + return __linkSelectedColor; + } + + return __linkColor; + } + + if (__isSelected) + { + return Color::GetColor(COLOR_ID_BLUE); + } + + return Color::GetColor(COLOR_ID_BLUE); +} + +Color +TextCutLink::GetCurrentBackgroundColor(void) const +{ + if (__isEdited) + { + return TextSimple::GetCurrentBackgroundColor(); + } + + if (__isSelected) + { + return Color::GetColor(COLOR_ID_WHITE); + } + + return Color::GetColor(COLOR_ID_WHITE); +} + +Color +TextCutLink::GetCurrentOutlineColor(void) const +{ + if (__isEdited) + { + return TextSimple::GetCurrentOutlineColor(); + } + + return Color::GetColor(COLOR_ID_WHITE); +} + +bool +TextCutLink::GetEditable(void) const +{ + return __isEditable; +} + +void +TextCutLink::SetEditModeEnable(bool enable) +{ + __isEdited = enable; +} + +bool +TextCutLink::IsEditModeEnable(void) const +{ + return __isEdited; +} + +Tizen::Base::Utility::LinkType +TextCutLink::GetCutLinkType(void) const +{ + return __linkType; +} + +}}} // Tizen::Graphics::_Text diff --git a/src/graphics/text/FGrp_TextTextCutLinkListInfo.cpp b/src/graphics/text/FGrp_TextTextCutLinkListInfo.cpp new file mode 100644 index 0000000..f4423a7 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextCutLinkListInfo.cpp @@ -0,0 +1,579 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextCutLinkListInfo.cpp + * @brief This is the implementation file for TextCutLinkListInfo class. + */ + +#include +#include +#include "FGrp_TextTextCutLink.h" +#include "FGrp_TextTextCutLinkListInfo.h" + +using namespace Tizen::Base::Collection; + +#define Release(x) \ + if (x) \ + { \ + delete x; \ + x = null; \ + } + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +TextCutLinkListInfo::TextCutLinkListInfo(void) +{ + __totalTextLength = 0; + __pCutLinkTextElementInfoList = new (std::nothrow) LinkedListT ; +} + +TextCutLinkListInfo::~TextCutLinkListInfo(void) +{ + if (__pCutLinkTextElementInfoList) + { + RemoveAllCutLinkElementInfos(); + + delete __pCutLinkTextElementInfoList; + __pCutLinkTextElementInfoList = null; + } +} + +int +TextCutLinkListInfo::GetCutLinkElementCount(void) const +{ + return __pCutLinkTextElementInfoList->GetCount(); +} + +result +TextCutLinkListInfo::InsertCutLinkElementInfo(int textIndex, TextCutLink& linkTextElement, int textLength) +{ + result r = E_SUCCESS; + + IEnumeratorT* pEnum = null; + CutLinkTextElementInfo* pCurrentCutlinkTextElementInfo = null; + int currentCutlinkTextElementIndex = 0; + int index = 0; + + CutLinkTextElementInfo* pCutlinkTextElementInfo = new (std::nothrow) CutLinkTextElementInfo; + SysTryCatch(NID_GRP + , pCutlinkTextElementInfo + , r = E_INVALID_ARG, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pEnum = __pCutLinkTextElementInfoList->GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + pEnum->GetCurrent(pCurrentCutlinkTextElementInfo); + if (!pCurrentCutlinkTextElementInfo) + { + continue; + } + + if (textIndex <= pCurrentCutlinkTextElementInfo->startTextIndex) + { + break; + } + + pCurrentCutlinkTextElementInfo = null; + currentCutlinkTextElementIndex++; + } + + pCutlinkTextElementInfo->startTextIndex = textIndex; + pCutlinkTextElementInfo->textLength = textLength; + pCutlinkTextElementInfo->pCutLinkTextElement = &linkTextElement; + + r = __pCutLinkTextElementInfoList->InsertAt(pCutlinkTextElementInfo, currentCutlinkTextElementIndex); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to insert element.", GetErrorMessage(r)); + + __totalTextLength += textLength; + pCurrentCutlinkTextElementInfo = null; + index = currentCutlinkTextElementIndex + 1; + + __pCutLinkTextElementInfoList->GetAt(index, pCurrentCutlinkTextElementInfo); + while (pCurrentCutlinkTextElementInfo) + { + pCurrentCutlinkTextElementInfo->startTextIndex += textLength; + index++; + + pCurrentCutlinkTextElementInfo = null; + __pCutLinkTextElementInfoList->GetAt(index, pCurrentCutlinkTextElementInfo); + } + + Release(pEnum); + return E_SUCCESS; + +CATCH: + Release(pEnum); + return r; +} + +result +TextCutLinkListInfo::RemoveCutLinkElementInfo(TextCutLink* pCutLinkTextElement) +{ + SysTryReturn(NID_GRP + , pCutLinkTextElement + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + + IEnumeratorT* pEnum = null; + CutLinkTextElementInfo* pCurrentCutlinkTextElementInfo = null; + int currentCutlinkTextElementIndex = 0; + int index = 0; + int cutlinkTextElementLength = 0; + + pEnum = __pCutLinkTextElementInfoList->GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + pEnum->GetCurrent(pCurrentCutlinkTextElementInfo); + if (!pCurrentCutlinkTextElementInfo) + { + continue; + } + + if (pCurrentCutlinkTextElementInfo->pCutLinkTextElement == pCutLinkTextElement) + { + break; + } + + currentCutlinkTextElementIndex++; + pCurrentCutlinkTextElementInfo = null; + } + + SysTryCatch(NID_GRP + , pCurrentCutlinkTextElementInfo + , , E_SYSTEM, "[E_SYSTEM] Fail to search CutLink element."); + + cutlinkTextElementLength = pCurrentCutlinkTextElementInfo->textLength; + + r = __pCutLinkTextElementInfoList->RemoveAt(currentCutlinkTextElementIndex); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to add element.", GetErrorMessage(r)); + + __totalTextLength -= pCurrentCutlinkTextElementInfo->textLength; + + delete pCurrentCutlinkTextElementInfo; + pCurrentCutlinkTextElementInfo = null; + + index = currentCutlinkTextElementIndex; + __pCutLinkTextElementInfoList->GetAt(index, pCurrentCutlinkTextElementInfo); + while (pCurrentCutlinkTextElementInfo) + { + pCurrentCutlinkTextElementInfo->startTextIndex -= cutlinkTextElementLength; + index++; + + pCurrentCutlinkTextElementInfo = null; + __pCutLinkTextElementInfoList->GetAt(index, pCurrentCutlinkTextElementInfo); + } + + Release(pEnum); + return E_SUCCESS; + +CATCH: + Release(pEnum); + return r; +} + +result +TextCutLinkListInfo::InsertText(int textIndex, int textLength) +{ + IEnumeratorT* pEnum = null; + CutLinkTextElementInfo* pCurrentCutlinkTextElementInfo = null; + int index = 0; + + pEnum = __pCutLinkTextElementInfoList->GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + pEnum->GetCurrent(pCurrentCutlinkTextElementInfo); + if (!pCurrentCutlinkTextElementInfo) + { + continue; + } + + if (textIndex < pCurrentCutlinkTextElementInfo->startTextIndex) + { + break; + } + + if (pCurrentCutlinkTextElementInfo->startTextIndex + pCurrentCutlinkTextElementInfo->textLength > textIndex) + { + pCurrentCutlinkTextElementInfo->textLength += textLength; + } + + index++; + pCurrentCutlinkTextElementInfo = null; + } + + if (__pCutLinkTextElementInfoList->GetCount() > 0) + { + __pCutLinkTextElementInfoList->GetAt(index, pCurrentCutlinkTextElementInfo); + while (pCurrentCutlinkTextElementInfo) + { + pCurrentCutlinkTextElementInfo->startTextIndex += textLength; + index++; + + pCurrentCutlinkTextElementInfo = null; + __pCutLinkTextElementInfoList->GetAt(index, pCurrentCutlinkTextElementInfo); + } + } + + __totalTextLength += textLength; + + Release(pEnum); + return E_SUCCESS; +} + +result +TextCutLinkListInfo::RemoveText(int textIndex, int textLength) +{ + result r = E_SUCCESS; + + IEnumeratorT* pEnum = null; + CutLinkTextElementInfo* pCurrentCutlinkTextElementInfo = null; + + int currentCutlinkTextElementIndex = 0; + int firstChangedCutlinkTextElementInfoIndex = -1; + int firstChangedTextLength = 0; + int lastChangedCutlinkTextElementInfoIndex = -1; + int lastChangedTextLength = 0; + int lastChangedTextIndex = textIndex + textLength - 1; + int index = 0; + + pEnum = __pCutLinkTextElementInfoList->GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + pEnum->GetCurrent(pCurrentCutlinkTextElementInfo); + if (!pCurrentCutlinkTextElementInfo) + { + continue; + } + + if (pCurrentCutlinkTextElementInfo->startTextIndex + pCurrentCutlinkTextElementInfo->textLength < textIndex) + { + if (pCurrentCutlinkTextElementInfo->startTextIndex < textIndex) + { + firstChangedCutlinkTextElementInfoIndex = currentCutlinkTextElementIndex; + firstChangedTextLength = textIndex - pCurrentCutlinkTextElementInfo->startTextIndex + 1; + } + else + { + firstChangedCutlinkTextElementInfoIndex = currentCutlinkTextElementIndex; + firstChangedTextLength = pCurrentCutlinkTextElementInfo->textLength; + } + } + + if (pCurrentCutlinkTextElementInfo->startTextIndex + pCurrentCutlinkTextElementInfo->textLength > lastChangedTextIndex) + { + if (pCurrentCutlinkTextElementInfo->startTextIndex <= lastChangedTextIndex) + { + lastChangedCutlinkTextElementInfoIndex = currentCutlinkTextElementIndex; + lastChangedTextLength = lastChangedTextIndex - pCurrentCutlinkTextElementInfo->startTextIndex + 1; + break; + } + else + { + lastChangedCutlinkTextElementInfoIndex = currentCutlinkTextElementIndex; + lastChangedTextLength = 0; + break; + } + } + + pCurrentCutlinkTextElementInfo = null; + } + + if (firstChangedCutlinkTextElementInfoIndex == -1) + { + Release(pEnum); + return false; + } + + if (lastChangedCutlinkTextElementInfoIndex == -1) + { + lastChangedCutlinkTextElementInfoIndex = __pCutLinkTextElementInfoList->GetCount(); + } + + int deletedCutlinkTextElementCount = 0; + + for (int i = firstChangedCutlinkTextElementInfoIndex; i <= lastChangedCutlinkTextElementInfoIndex; i++) + { + if (i == firstChangedCutlinkTextElementInfoIndex) + { + __pCutLinkTextElementInfoList->GetAt(i - deletedCutlinkTextElementCount, pCurrentCutlinkTextElementInfo); + if (pCurrentCutlinkTextElementInfo == null) + { + break; + } + + if (pCurrentCutlinkTextElementInfo->textLength == firstChangedTextLength) + { + r = __pCutLinkTextElementInfoList->RemoveAt(i - deletedCutlinkTextElementCount); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to add element.", GetErrorMessage(r)); + + delete pCurrentCutlinkTextElementInfo; + pCurrentCutlinkTextElementInfo = null; + + deletedCutlinkTextElementCount++; + } + else + { + pCurrentCutlinkTextElementInfo->textLength -= firstChangedTextLength; + } + } + else if (i == lastChangedCutlinkTextElementInfoIndex) + { + __pCutLinkTextElementInfoList->GetAt(i - deletedCutlinkTextElementCount, pCurrentCutlinkTextElementInfo); + if (pCurrentCutlinkTextElementInfo == null) + { + break; + } + + if (pCurrentCutlinkTextElementInfo->textLength == lastChangedTextLength) + { + r = __pCutLinkTextElementInfoList->RemoveAt(i - deletedCutlinkTextElementCount); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to remove element.", GetErrorMessage(r)); + + delete pCurrentCutlinkTextElementInfo; + pCurrentCutlinkTextElementInfo = null; + + deletedCutlinkTextElementCount++; + } + else + { + pCurrentCutlinkTextElementInfo->startTextIndex -= textLength; + pCurrentCutlinkTextElementInfo->textLength -= lastChangedTextLength; + } + } + else + { + __pCutLinkTextElementInfoList->GetAt(i - deletedCutlinkTextElementCount, pCurrentCutlinkTextElementInfo); + if (pCurrentCutlinkTextElementInfo == null) + { + break; + } + + r = __pCutLinkTextElementInfoList->RemoveAt(i - deletedCutlinkTextElementCount); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Fail to remove element.", GetErrorMessage(r)); + + delete pCurrentCutlinkTextElementInfo; + pCurrentCutlinkTextElementInfo = null; + + deletedCutlinkTextElementCount++; + } + } + + index = lastChangedCutlinkTextElementInfoIndex + 1 - deletedCutlinkTextElementCount; + __pCutLinkTextElementInfoList->GetAt(index, pCurrentCutlinkTextElementInfo); + while (pCurrentCutlinkTextElementInfo) + { + pCurrentCutlinkTextElementInfo->startTextIndex -= textLength; + index++; + + pCurrentCutlinkTextElementInfo = null; + __pCutLinkTextElementInfoList->GetAt(index, pCurrentCutlinkTextElementInfo); + } + + __totalTextLength -= textLength; + + Release(pEnum); + return E_SUCCESS; + +CATCH: + Release(pEnum); + return r; +} + +int +TextCutLinkListInfo::GetCutLinkElementIndexAt(int textIndex) const +{ + IEnumeratorT* pEnum = null; + CutLinkTextElementInfo* pCurrentCutlinkTextElementInfo = null; + int currentCutlinkTextElementInfoIndex = 0; + + pEnum = __pCutLinkTextElementInfoList->GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + pEnum->GetCurrent(pCurrentCutlinkTextElementInfo); + if (!pCurrentCutlinkTextElementInfo) + { + continue; + } + + if (pCurrentCutlinkTextElementInfo->startTextIndex <= textIndex && + pCurrentCutlinkTextElementInfo->startTextIndex + pCurrentCutlinkTextElementInfo->textLength > textIndex) + { + Release(pEnum); + return currentCutlinkTextElementInfoIndex; + } + + if (textIndex < pCurrentCutlinkTextElementInfo->startTextIndex) + { + break; + } + + currentCutlinkTextElementInfoIndex++; + + pCurrentCutlinkTextElementInfo = null; + } + + Release(pEnum); + return -1; +} + +TextCutLink* +TextCutLinkListInfo::GetCutLinkElementAtTextIndex(int textIndex) const +{ + CutLinkTextElementInfo* pCurrentCutlinkTextElementInfo = null; + int cutlinkTextTextIndex = GetCutLinkElementIndexAt(textIndex); + + SysTryReturn(NID_GRP + , cutlinkTextTextIndex != -1 + , null, E_INVALID_ARG, "[E_SYSTEM] Fail to get cutlink text."); + + __pCutLinkTextElementInfoList->GetAt(cutlinkTextTextIndex, pCurrentCutlinkTextElementInfo); + SysTryReturn(NID_GRP + , pCurrentCutlinkTextElementInfo + , null, E_INVALID_ARG, "[E_SYSTEM] Fail to get cutlink text element."); + + return pCurrentCutlinkTextElementInfo->pCutLinkTextElement; +} + +TextCutLink* +TextCutLinkListInfo::GetCutLinkElementAtCutLinkElementIndex(int index) const +{ + CutLinkTextElementInfo* pCurrentCutlinkTextElementInfo = null; + + __pCutLinkTextElementInfoList->GetAt(index, pCurrentCutlinkTextElementInfo); + SysTryReturn(NID_GRP + , pCurrentCutlinkTextElementInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get element."); + + return pCurrentCutlinkTextElementInfo->pCutLinkTextElement; +} + +result +TextCutLinkListInfo::RemoveAllCutLinkElementInfos(void) +{ + result r = E_SUCCESS; + CutLinkTextElementInfo* pCurrentCutlinkTextElementInfo = null; + + for (int i = 0; i < __pCutLinkTextElementInfoList->GetCount(); i++ ) + { + __pCutLinkTextElementInfoList->GetAt(i, pCurrentCutlinkTextElementInfo); + SysTryReturn(NID_GRP + , pCurrentCutlinkTextElementInfo + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element."); + + r = __pCutLinkTextElementInfoList->RemoveAt(i); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , E_SYSTEM, E_SYSTEM, "[%s] Fail to add element.", GetErrorMessage(r)); + + delete pCurrentCutlinkTextElementInfo; + pCurrentCutlinkTextElementInfo = null; + } + + __totalTextLength = 0; + + return E_SUCCESS; +} + +result +TextCutLinkListInfo::ResetAllCutLinkElementsState(void) +{ + result r = E_SUCCESS; + IEnumeratorT* pEnum = null; + CutLinkTextElementInfo* pCurrentCutlinkTextElementInfo = null; + TextCutLink* pCutlinkTextElement = null; + + pEnum = __pCutLinkTextElementInfoList->GetEnumeratorN(); + while (pEnum->MoveNext() == E_SUCCESS) + { + pEnum->GetCurrent(pCurrentCutlinkTextElementInfo); + if (!pCurrentCutlinkTextElementInfo) + { + continue; + } + + pCutlinkTextElement = pCurrentCutlinkTextElementInfo->pCutLinkTextElement; + SysTryCatch(NID_GRP + , pCutlinkTextElement + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get cutlink text element."); + + pCutlinkTextElement->SetSelect(false); + + pCurrentCutlinkTextElementInfo = null; + } + + Release(pEnum); + return E_SUCCESS; + +CATCH: + Release(pEnum); + return r; +} + +result +TextCutLinkListInfo::ChangeCutLinkState(int linkIndex, bool select) +{ + CutLinkTextElementInfo* pCurrentCutlinkTextElementInfo = null; + TextCutLink* pCutlinkTextElement = null; + + __pCutLinkTextElementInfoList->GetAt(linkIndex, pCurrentCutlinkTextElementInfo); + SysTryReturn(NID_GRP + , pCurrentCutlinkTextElementInfo + , E_INVALID_ARG, E_INVALID_ARG, "[E_SYSTEM] Fail to get current cutlink element information."); + + pCutlinkTextElement = pCurrentCutlinkTextElementInfo->pCutLinkTextElement; + SysTryReturn(NID_GRP + , pCutlinkTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get cutlink element."); + + pCutlinkTextElement->SetSelect(select); + + return E_SUCCESS; +} + +result +TextCutLinkListInfo::GetCutLinkObjectInfo(int index, int& startTextIndex, int& textLength) const +{ + CutLinkTextElementInfo* pCurrentCutlinkTextElementInfo = null; + + __pCutLinkTextElementInfoList->GetAt(index, pCurrentCutlinkTextElementInfo); + SysTryReturn(NID_GRP + , pCurrentCutlinkTextElementInfo + , E_INVALID_ARG, E_INVALID_ARG, "[E_SYSTEM] Fail to get current cutlink text element."); + + startTextIndex = pCurrentCutlinkTextElementInfo->startTextIndex; + textLength = pCurrentCutlinkTextElementInfo->textLength; + + return E_SUCCESS; +} + +}}} // Tizen::Graphics::_Text diff --git a/src/graphics/text/FGrp_TextTextCutLinkListInfo.h b/src/graphics/text/FGrp_TextTextCutLinkListInfo.h new file mode 100644 index 0000000..9007436 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextCutLinkListInfo.h @@ -0,0 +1,92 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextCutLinkListInfo.h + * @brief This is the header file for the TextCutLinkListInfo class. + * + * This header file contains the declarations of the %TextCutLinkListInfo class. + */ + +#ifndef _FGRP_INTERNAL_TEXT_CUTLINK_LIST_INFO_H_ +#define _FGRP_INTERNAL_TEXT_CUTLINK_LIST_INFO_H_ + +#include +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextElement.h" + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +class TextCutLink; + +struct CutLinkTextElementInfo +{ + int startTextIndex; + int textLength; + TextCutLink* pCutLinkTextElement; +}; + +class TextCutLinkListInfo +{ +public: + TextCutLinkListInfo(void); + + virtual ~TextCutLinkListInfo(void); + +public: + result InsertCutLinkElementInfo(int textIndex, TextCutLink& linkTextElement, int textLength); + + result RemoveCutLinkElementInfo(TextCutLink* pCutLinkTextElement); + + result InsertText(int textIndex, int textLength); + + result RemoveText(int textIndex, int textLength); + + result RemoveAllCutLinkElementInfos(void); + + int GetCutLinkElementCount(void) const; + + int GetCutLinkElementIndexAt(int textIndex) const; + + TextCutLink* GetCutLinkElementAtTextIndex(int textIndex) const; + + TextCutLink* GetCutLinkElementAtCutLinkElementIndex(int index) const; + + result GetCutLinkObjectInfo(int index, int& startTextIndex, int& textLength) const; + + result ResetAllCutLinkElementsState(void); + + result ChangeCutLinkState(int linkIndex, bool select); + +private: + Tizen::Base::Collection::LinkedListT * __pCutLinkTextElementInfoList; + int __totalTextLength; + +private: + TextCutLinkListInfo(const TextCutLinkListInfo& other); // NOT IMPLMENTED + + TextCutLinkListInfo& operator =(const TextCutLinkListInfo& rhs); // NOT IMPLMENTED + +}; // TextCutLinkListInfo + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_CUTLINK_LIST_INFO_H_ diff --git a/src/graphics/text/FGrp_TextTextCutLinkParser.cpp b/src/graphics/text/FGrp_TextTextCutLinkParser.cpp new file mode 100644 index 0000000..b9ea72a --- /dev/null +++ b/src/graphics/text/FGrp_TextTextCutLinkParser.cpp @@ -0,0 +1,814 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextCutLinkParser.cpp + * @brief This is the implementation file for TextCutLinkParser class. + */ + +#include +#include +#include +#include "FGrp_TextTextCutLinkParser.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; + +static const int _MIN_TEXT_LENGTH = 5; +static const int _MIN_PHONE_NUMBER_LENGTH = 4; + +static ArrayListT * gpDomainNames = null; +static ArrayListT * gpUrlPrefixes = null; + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +static bool +IsGenericCharacter(wchar_t ch) +{ + if ((ch >= L'a' && ch <= L'z') || (ch >= L'0' && ch <= L'9') || + (ch >= L'A' && ch <= L'Z') || ch == L'.' || ch == L'/' || + ch == L'=' || ch == L'&' || ch == L'%' || ch == L'-' || + ch == L'?' || ch == L':' || ch == L'@' || ch == L'_' || + ch == L'$' || ch == L';' || ch == L'+' || ch == L'!' || + ch == L'*' || ch == L'\'' || ch == L'(' || ch == L')' || + ch == L',') + { + return true; + } + else + { + return false; + } +} + +static bool +IsEmailCharacter(wchar_t ch) +{ + if ((ch >= L'a' && ch <= L'z') || (ch >= L'0' && ch <= L'9') || + (ch >= L'A' && ch <= L'Z') || ch == L'.' || + ch == L'-' || ch == L'_' || ch == L'+') + { + return true; + } + else + { + return false; + } +} + +static bool +IsUrlCharacter(wchar_t ch) +{ + if (ch == L'h' || ch == L'H' || ch == L'w' || ch == L'W') + { + return true; + } + else + { + return false; + } +} + +static bool +IsPhoneNumCharacter(wchar_t ch) +{ + if (Character::IsDigit(ch)) + { + return true; + } + else if (ch == L'*' || ch == L'#' || ch == L'+') + { + return true; + } + else + { + return false; + } +} + +static bool +IsUrlAddress(const String& text, int index, int& linkLength) +{ + ClearLastResult(); + SysTryReturn(NID_GRP, index >= 0, false, E_INVALID_ARG, + "[E_INVALID_ARG] Index must be greater than or equal to 0."); + + result r = E_SUCCESS; + bool dotFound = false; + bool validTextAfterDot = false; + int linkOffset = 0; + int totalLength = text.GetLength(); + int length = 0; + + String prefix(L""); + String subString(L""); + for (int i = 0; i < gpUrlPrefixes->GetCount(); i++) + { + if (gpUrlPrefixes->GetAt(i, prefix) == E_SUCCESS) + { + length = prefix.GetLength(); + if (length <= 0) + { + continue; + } + + if (totalLength < index + length) + { + break; + } + + r = text.SubString(index, length, subString); + SysTryReturn( + NID_GRP, r == E_SUCCESS, false, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] SubString offset(%d) must greater than 0 and length(%d) must be less than total string length(%d).", + index, prefix.GetLength(), totalLength); + if (prefix.CompareTo(subString) == 0) + { + linkOffset = index; + while (index < totalLength && IsGenericCharacter(text[index])) + { + if (dotFound == false && text[index] == '.') + { + dotFound = true; + } + + if (validTextAfterDot == false && dotFound == true && text[index] != '.') + { + validTextAfterDot = true; + } + + index++; + } + + if (dotFound == true && validTextAfterDot != true) + { + return false; + } + + if (dotFound == true) + { + while (text[index - 1] == L'.' || text[index - 1] == L',') + { + index--; + } + } + linkLength = index - linkOffset; + + return true; + } + } + } + + return false; +} + +static bool +GetUrlLink(const String& text, int index, int lastLinkEndIndex, int domainLength, int& linkStartIndex, int& linkLength) +{ + ClearLastResult(); + SysTryReturn(NID_GRP, index >= 0, false, E_INVALID_ARG, + "[E_INVALID_ARG] Index must be greater than or equal to 0."); + + bool dotFound = false; + bool validTextBeforeDot = false; + int linkOffset = index; + + while (lastLinkEndIndex <= linkOffset) + { + if (!IsGenericCharacter(text[linkOffset]) || text[linkOffset] == L'(' || text[linkOffset] == L'[') + { + linkOffset++; + break; + } + + if (dotFound == false && text[linkOffset] == L'.') + { + dotFound = true; + } + + if (validTextBeforeDot == false && dotFound == true && text[linkOffset] != L'.') + { + validTextBeforeDot = true; + } + + linkOffset--; + } + + if (dotFound == true && validTextBeforeDot != true) + { + return false; + } + + if (dotFound == true) + { + while (text[linkOffset] == L'.' || text[linkOffset] == L',') + { + linkOffset++; + } + } + + index += domainLength; + if (text[index] == L'/') + { + while (index > 0) + { + if (!IsGenericCharacter(text[index]) && text[index] != L')' && text[index] != L']') + { + break; + } + + index++; + } + } + else if (text[index] != null && text[index] != L' ' && text[index] != L')' && + text[index] != L']' && text[index] != 0xFFFC && + text[index] != 0x000A && text[index] != 0x000D) + { + return false; + } + + linkStartIndex = linkOffset; + linkLength = index - linkStartIndex; + + return true; +} + +static bool +IsDomainAddress(const String& text, int index, int lastLinkEndIndex, int& linkStartIndex, int& linkLength) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_GRP, index >= 0, false, E_INVALID_ARG, + "[E_INVALID_ARG] Index must be greater than or equal to 0."); + + int domainLength = 0; + int length = 0; + int textLength = text.GetLength(); + + String subString(L""); + String domainAddress(L""); + for (int i = 0; i < gpDomainNames->GetCount(); i++) + { + if (gpDomainNames->GetAt(i, domainAddress) == E_SUCCESS) + { + length = domainAddress.GetLength(); + if (length <= 0) + { + continue; + } + + if (textLength < index + length) + { + break; + } + + r = text.SubString(index, length, subString); + SysTryReturn(NID_GRP, r == E_SUCCESS, false, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] SubString offset(%d) must greater than 0 and length(%d) must be less than total string length(%d).", + index, domainAddress.GetLength(), text.GetLength()); + if (domainAddress.CompareTo(subString) == 0) + { + domainLength = domainAddress.GetLength(); + if (GetUrlLink(text, index, lastLinkEndIndex, domainLength, linkStartIndex, linkLength)) + { + return true; + } + } + } + } + + return false; +} + +static bool +IsEmailAddress(const String& text, int index, int lastLinkEndIndex, int& linkStartIndex, int& linkLength) +{ + ClearLastResult(); + SysTryReturn(NID_GRP, index >= 0, false, E_INVALID_ARG, + "[E_INVALID_ARG] Index must be greater than or equal to 0."); + + bool validTextAfterAt = false; + bool hasDot = false; + int atIndex = 0; + int totalLength = text.GetLength(); + int linkOffset = index; + + if (text[index + 1] == L'@') + { + return false; + } + + linkOffset--; + + if (index > lastLinkEndIndex) + { + while (IsEmailCharacter(text[linkOffset]) && lastLinkEndIndex <= linkOffset) + { + linkOffset--; + } + + if (linkOffset == index - 1) + { + return false; + } + + linkOffset++; + + atIndex = index; + index++; + while (IsEmailCharacter(text[index]) && index < totalLength) + { + if (validTextAfterAt == false) + { + validTextAfterAt = true; + } + + if (text[index] == '.') + { + if (text[index + 1] == '.') + { + break; + } + + if (hasDot == false) + { + hasDot = true; + } + } + + index++; + } + + if (validTextAfterAt == false || hasDot == false) + { + return false; + } + + while (text[index - 1] == L'.') + { + index--; + } + + linkStartIndex = linkOffset; + linkLength = index - linkOffset; + return true; + } + + return false; +} + +static bool +IsPhoneNumber(const String& text, int index, int& linkLength) +{ + ClearLastResult(); + + int j = 1; + int k = 1; + bool isPhoneNumber = true; + int oneHyphen = false; + int oneDot = false; + int linkOffset = 0; + int blankCount = 0; + + int totalLength = text.GetLength(); + if (text[index] == L'+') + { + k = 0; + if (!Character::IsDigit(text[index + 1])) + { + return false; + } + } + + while (k < _MIN_PHONE_NUMBER_LENGTH) + { + if (Character::IsDigit(text[index + j]) || text[index + j] == L'*' || text[index + j] == L'#') + { + k++; + oneHyphen = false; + oneDot = false; + } + else if (oneHyphen == false && text[index + j] == L'-') + { + oneHyphen = true; + } + else if (oneDot == false && text[index + j] == L'.') + { + oneDot = true; + } + else if (text[index + j] == L' ' || text[index + j] == L'(' || text[index + j] == L')') + { + // empty statement + } + else + { + isPhoneNumber = false; + break; + } + + j++; + } + + if (isPhoneNumber) + { + linkOffset = index; + + while (index < totalLength && + (Character::IsDigit(text[index]) || (text[index] == L'*') || + (text[index] == L'#') || (text[index] == L'-') || + (text[index] == L' ') || (text[index] == L'+') || + (text[index] == L'.') || (text[index] == L'(') || + (text[index] == L')') || (index == linkOffset && (text[linkOffset] == L'+')))) + { + index++; + + if (blankCount == 0 && text[index] == L' ') + { + blankCount++; + } + else if (blankCount == 1 && text[index] == L' ') + { + blankCount++; + break; + } + else if (Character::IsDigit(text[index]) || text[index] == L'*' || text[index] == L'#') + { + blankCount = 0; + } + else if (text[index] == L'-' && text[index + 1] == L'-') + { + break; + } + else if (text[index] == L'(' || text[index] == L')') + { + break; + } + else if ((text[index] == L'.' && + text[index + 1] == L'.') || (text[index] == L'.' && !Character::IsDigit(text[index + 1]))) + { + break; + } + else + { + blankCount = 0; + } + } + + if (text[index - 1] == L' ') + { + index -= 1; + while (text[index] == L' ') + { + index--; + } + + index++; + } + + linkLength = index - linkOffset; + return true; + } + + return false; +} + +TextCutLinkParser::TextCutLinkParser(void) +{ + ClearLastResult(); + result r = E_SUCCESS; + + __linkMask = LINK_TYPE_URL | LINK_TYPE_EMAIL | LINK_TYPE_TEL_NUM; + + if (!gpUrlPrefixes) + { + gpUrlPrefixes = new (std::nothrow) ArrayListT ; + SysTryCatch(NID_GRP + , gpUrlPrefixes != null + , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + r = gpUrlPrefixes->Construct(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagated.", GetErrorMessage(r)); + + gpUrlPrefixes->Add(L"www."); + gpUrlPrefixes->Add(L"http://"); + gpUrlPrefixes->Add(L"https://"); + gpUrlPrefixes->Add(L"wap."); + gpUrlPrefixes->Add(L"wap2."); + } + + if (!gpDomainNames) + { + gpDomainNames = new (std::nothrow) ArrayListT ; + SysTryCatch(NID_GRP + , gpDomainNames != null + , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = gpDomainNames->Construct(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagated.", GetErrorMessage(r)); + + gpDomainNames->Add(L".com"); + gpDomainNames->Add(L".net"); + gpDomainNames->Add(L".kr"); + gpDomainNames->Add(L".be"); + gpDomainNames->Add(L".gr"); + gpDomainNames->Add(L".pt"); + gpDomainNames->Add(L".at"); + gpDomainNames->Add(L".gs"); + gpDomainNames->Add(L".ro"); + gpDomainNames->Add(L".edu"); + gpDomainNames->Add(L".as"); + gpDomainNames->Add(L".hk"); + gpDomainNames->Add(L".se"); + gpDomainNames->Add(L".org"); + gpDomainNames->Add(L".az"); + gpDomainNames->Add(L".il"); + gpDomainNames->Add(L".sg"); + gpDomainNames->Add(L".info"); + gpDomainNames->Add(L".bt"); + gpDomainNames->Add(L".in"); + gpDomainNames->Add(L".sh"); + gpDomainNames->Add(L".us"); + gpDomainNames->Add(L".cn"); + gpDomainNames->Add(L".io"); + gpDomainNames->Add(L".sk"); + gpDomainNames->Add(L".biz"); + gpDomainNames->Add(L".ac"); + gpDomainNames->Add(L".is"); + gpDomainNames->Add(L".so"); + gpDomainNames->Add(L".to"); + gpDomainNames->Add(L".af"); + gpDomainNames->Add(L".st"); + gpDomainNames->Add(L".ch"); + gpDomainNames->Add(L".al"); + gpDomainNames->Add(L".kz"); + gpDomainNames->Add(L".tc"); + gpDomainNames->Add(L".fr"); + gpDomainNames->Add(L".am"); + gpDomainNames->Add(L".li"); + gpDomainNames->Add(L".tf"); + gpDomainNames->Add(L".jp"); + gpDomainNames->Add(L".cx"); + gpDomainNames->Add(L".lu"); + gpDomainNames->Add(L".th"); + gpDomainNames->Add(L".de"); + gpDomainNames->Add(L".cz"); + gpDomainNames->Add(L".ly"); + gpDomainNames->Add(L".tj"); + gpDomainNames->Add(L".ru"); + gpDomainNames->Add(L".dz"); + gpDomainNames->Add(L".mc"); + gpDomainNames->Add(L".tm"); + gpDomainNames->Add(L".it"); + gpDomainNames->Add(L".ec"); + gpDomainNames->Add(L".mm"); + gpDomainNames->Add(L".asia"); + gpDomainNames->Add(L".mil"); + gpDomainNames->Add(L".ee"); + gpDomainNames->Add(L".ms"); + gpDomainNames->Add(L".me"); + gpDomainNames->Add(L".gov"); + gpDomainNames->Add(L".eg"); + gpDomainNames->Add(L".mx"); + gpDomainNames->Add(L".tel"); + gpDomainNames->Add(L".au"); + gpDomainNames->Add(L".es"); + gpDomainNames->Add(L".nl"); + gpDomainNames->Add(L".eu"); + gpDomainNames->Add(L".cc"); + gpDomainNames->Add(L".fo"); + gpDomainNames->Add(L".no"); + gpDomainNames->Add(L".tv"); + gpDomainNames->Add(L".ca"); + gpDomainNames->Add(L".ga"); + gpDomainNames->Add(L".nu"); + gpDomainNames->Add(L".name"); + gpDomainNames->Add(L".coop"); + gpDomainNames->Add(L".gf"); + gpDomainNames->Add(L".nz"); + gpDomainNames->Add(L".mobi"); + gpDomainNames->Add(L".dk"); + gpDomainNames->Add(L".gl"); + gpDomainNames->Add(L".pl"); + gpDomainNames->Add(L".tw"); + } + + return; +CATCH: + if (gpUrlPrefixes) + { + delete gpUrlPrefixes; + gpUrlPrefixes = null; + } + if (gpDomainNames) + { + delete gpDomainNames; + gpDomainNames = null; + } +} + +TextCutLinkParser::~TextCutLinkParser(void) +{ + +} + +TextLinkInfo* +TextCutLinkParser::Parse(const wchar_t* pText, int textLength, int startPosition) +{ + ClearLastResult(); + result r = E_SUCCESS; + + if (__linkMask == LINK_TYPE_NONE) + { + return null; + } + + while (0 < startPosition) + { + pText++; + startPosition--; + } + + String text(pText); + int linkStartIndex = 0; + int linkLength = 0; + int lastLinkEndIndex = 0; + bool linkParsed = false; + int totalLength = text.GetLength(); + TextLinkInfo* pTextLink = null; + LinkType linkType = LINK_TYPE_NONE; + + if (totalLength < _MIN_TEXT_LENGTH) + { + return null; + } + + pTextLink = CreateTextLinkInfo(0, 0, LINK_TYPE_NONE); + SysTryCatch(NID_GRP + , pTextLink != null + , , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pTextLink->index = -1; + + for (int i = 0; i < totalLength; ) + { + linkLength = 0; + wchar_t checkLetter = 0; + text.GetCharAt(i, checkLetter); + + if ((__linkMask & LINK_TYPE_URL) + && IsUrlCharacter(checkLetter) && IsUrlAddress(text, i, linkLength)) + { + linkParsed = true; + linkStartIndex = i; + linkType = LINK_TYPE_URL; + } + else if ((__linkMask & LINK_TYPE_URL) + && (checkLetter == '.') && IsDomainAddress(text, i, lastLinkEndIndex, linkStartIndex, linkLength)) + { + i = linkStartIndex; + linkParsed = true; + linkType = LINK_TYPE_URL; + } + else if ((__linkMask & LINK_TYPE_EMAIL) + && (checkLetter == '@') && IsEmailAddress(text, i, lastLinkEndIndex, linkStartIndex, linkLength)) + { + linkParsed = true; + i = linkStartIndex; + linkType = LINK_TYPE_EMAIL; + } + else if ((__linkMask & LINK_TYPE_TEL_NUM) + && IsPhoneNumCharacter(checkLetter) && IsPhoneNumber(text, i, linkLength)) + { + linkParsed = true; + linkStartIndex = i; + linkType = LINK_TYPE_TEL_NUM; + } + + if (linkParsed) + { + if (pTextLink->index == -1) + { + pTextLink->index = 0; + pTextLink->srcOffset = linkStartIndex; + pTextLink->length = linkLength; + pTextLink->linkType = linkType; + } + else + { + TextLinkInfo* pNextLink = CreateTextLinkInfo(linkStartIndex, linkLength, linkType); + SysTryCatch(NID_GRP + , pNextLink != null, + r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient"); + AppendTextLinkInfo(pTextLink, pNextLink); + } + + i += linkLength; + lastLinkEndIndex = i; + linkParsed = false; + } + else + { + i++; + } + } + + if (pTextLink->index == -1) + { + goto CATCH; + } + else + { + return pTextLink; + } + +CATCH: + if (pTextLink != null) + { + delete pTextLink; + pTextLink = null; + } + + return null; +} + +result +TextCutLinkParser::SetCutLinkMask(int mask) +{ + SysTryReturn(NID_GRP + , LINK_TYPE_NONE <= mask && mask < LINK_TYPE_MAX + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + __linkMask = mask; + + return E_SUCCESS; +} + +int +TextCutLinkParser::GetCutLinkMask(void) const +{ + return __linkMask; +} + +bool +TextCutLinkParser::AppendTextLinkInfo(TextLinkInfo* pLinkInfo, TextLinkInfo* pNewLinkInfo) +{ + TextLinkInfo* pTempLinkInfo = pLinkInfo; + + while (1) + { + if (pTempLinkInfo->pNextLinkInfo == null) + { + break; + } + pTempLinkInfo = pTempLinkInfo->pNextLinkInfo; + } + + pTempLinkInfo->index = pTempLinkInfo->index + 1; + pTempLinkInfo->pNextLinkInfo = pNewLinkInfo; + + return true; +} + +TextLinkInfo* +TextCutLinkParser::CreateTextLinkInfo(int offset, int length, LinkType linkType) +{ + TextLinkInfo* pTextLinkInfo = new (std::nothrow) TextLinkInfo; + SysTryReturn(NID_GRP + , pTextLinkInfo != null + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient"); + + pTextLinkInfo->index = 0; + pTextLinkInfo->srcOffset = offset; + pTextLinkInfo->length = length; + pTextLinkInfo->linkType = linkType; + + pTextLinkInfo->pNextLinkInfo = null; + + return pTextLinkInfo; +} + +}}} // Tizen::Graphics::_Text diff --git a/src/graphics/text/FGrp_TextTextCutLinkParser.h b/src/graphics/text/FGrp_TextTextCutLinkParser.h new file mode 100644 index 0000000..012eab5 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextCutLinkParser.h @@ -0,0 +1,81 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextCutLinkParser.h + * @brief This file contains the declarations of TextCutLinkParser class. + */ + +#ifndef _FGRP_INTERNAL_TEXT_CUTLINK_PARSER_H_ +#define _FGRP_INTERNAL_TEXT_CUTLINK_PARSER_H_ + +#include +#include +#include +#include +#include +#include + +struct TextLinkInfo +{ + int index; + int srcOffset; + int length; + Tizen::Base::Utility::LinkType linkType; + + struct TextLinkInfo* pNextLinkInfo; +}; + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +class TextCutLinkParser + : public Tizen::Base::Object +{ +public: + TextCutLinkParser(void); + + virtual ~TextCutLinkParser(void); + +public: + TextLinkInfo* Parse(const wchar_t* pText, int textLength, int textStartIndex); + + result SetCutLinkMask(int mask); + + int GetCutLinkMask(void) const; + +private: + bool AppendTextLinkInfo(TextLinkInfo* pLinkInfo, TextLinkInfo* pNewLinkInfo); + + TextLinkInfo* CreateTextLinkInfo(int offset, int length, Tizen::Base::Utility::LinkType linkType); + +private: + int __linkMask; + +private: + TextCutLinkParser(const TextCutLinkParser& other); // NOT IMPLEMENTED + + TextCutLinkParser& operator =(const TextCutLinkParser& rhs); // NOT IMPLEMENTED + +}; // _TextLinkParser + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_CUTLINK_PARSER_H_ diff --git a/src/graphics/text/FGrp_TextTextElement.cpp b/src/graphics/text/FGrp_TextTextElement.cpp new file mode 100644 index 0000000..f1a9797 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextElement.cpp @@ -0,0 +1,218 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextElement.cpp + * @brief This is the implementation file for TextElement class. + */ + +#include +#include +#include "FGrp_TextTextElement.h" + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +TextElement::TextElement(void) +{ + _type = TEXT_ELEMENT_TYPE_NONE; + _sourceType = TEXT_ELEMENT_SOURCE_TYPE_INTERNAL; + _length = 0; + _hasFocus = false; + _isAlternateLookEnabled = false; + _alternativeColor = Color::GetColor(COLOR_ID_GREY); +} + +TextElement::~TextElement(void) +{ + +} + +void +TextElement::CopyMembers(TextElement* pTargetTextElement) +{ + SysTryReturn(NID_GRP + , pTargetTextElement + , , E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + pTargetTextElement->SetFocused(_hasFocus); + pTargetTextElement->SetAlternateLookEnabled(_isAlternateLookEnabled); + pTargetTextElement->SetAlternativeForegroundColor(_alternativeColor); +} + +void +TextElement::SetTextLength(int length) +{ + _length = length; +} + +int +TextElement::ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, + int& actualLength, int& width, int& height) +{ + return -1; +} + +result +TextElement::Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, + int textLength, const TextObjectAlignment alignment, const TextObjectActionType action) +{ + return E_SYSTEM; +} + +TextElement* +TextElement::CloneN(TextComponentInfoValueType type, unsigned int value) +{ + return null; +} + +TextElement* +TextElement::CopyN(int textStart, int textLength) +{ + return null; +} + +result +TextElement::GetRegion(int textIndex, int textLength, int& width, int& height) const +{ + return E_SYSTEM; +} + +result +TextElement::GetBlockRegion(int textIndex, int textLength, int& width, int& height) const +{ + return E_SYSTEM; +} + +int +TextElement::GetHeight(void) const +{ + return -1; +} + +int +TextElement::GetTextLength(void) const +{ + return _length; +} + +unsigned int +TextElement::GetValue(TextComponentInfoValueType type) const +{ + return 0; +} + +result +TextElement::SetValue(TextComponentInfoValueType type, unsigned int value) +{ + return E_SYSTEM; +} + +TextElementType +TextElement::GetType(void) const +{ + return _type; +} + +TextElementSourceType +TextElement::GetSourceType(void) const +{ + return _sourceType; +} + +bool +TextElement::SetFocused(bool hasFocus) +{ + _hasFocus = hasFocus; + return true; +} + +bool +TextElement::GetFocused(void) const +{ + return _hasFocus; +} + +void +TextElement::SetAlternateLookEnabled(bool enable) +{ + _isAlternateLookEnabled = enable; +} + +bool +TextElement::IsAlternateLookEnabled(void) const +{ + return _isAlternateLookEnabled; +} + +void +TextElement::SetAlternativeForegroundColor(const Color& foregroundColor) +{ + _alternativeColor = foregroundColor; +} + +Color +TextElement::GetAlternativeForegroundColor(void) const +{ + return _alternativeColor; +} + +int +TextElement::GetBaseline(void) const +{ + return -1; +} +void +TextElement::SetForegroundColor(const Color& color) +{ + return; +} + +Color +TextElement::GetForegroundColor(void) const +{ + return Color::GetColor(COLOR_ID_BLACK); +} + +void +TextElement::SetBackgroundColor(const Color& color) +{ + return; +} + +Color +TextElement::GetBackgroundColor(void) const +{ + return Color::GetColor(COLOR_ID_WHITE); +} + +void +TextElement::SetBackGroundDrawingModeEnabled(bool enable) +{ + return; +} + +bool +TextElement::IsBackGroundDrawingModeEnable(void) const +{ + return false; +} + +}}} // Tizen::Graphics::_Text diff --git a/src/graphics/text/FGrp_TextTextImage.cpp b/src/graphics/text/FGrp_TextTextImage.cpp new file mode 100644 index 0000000..98b920c --- /dev/null +++ b/src/graphics/text/FGrp_TextTextImage.cpp @@ -0,0 +1,415 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextImage.cpp + * @brief This is the implementation file for TextImage class. + */ + +#include +#include +#include +#include "FGrp_BitmapImpl.h" +#include "FGrp_CanvasImpl.h" +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextElement.h" +#include "FGrp_TextTextImage.h" +#include "../FGrp_BitmapUtil.h" +#include "../FGrp_Canvas.h" + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +TextImage::TextImage(Bitmap& bitmap, TextElementSourceType sourceType, Rectangle* pRect, TextObjectAlignment align) + : TextElement() +{ + result r = E_SUCCESS; + _type = TEXT_ELEMENT_TYPE_IMAGE; + _sourceType = sourceType; + _length = 1; + _hasFocus = false; + _isAlternateLookEnabled = false; + __align = align; + __pBitmap = null; + + if (sourceType == TEXT_ELEMENT_SOURCE_TYPE_INTERNAL) + { + __pBitmap = new (std::nothrow) Bitmap(); + SysTryCatch(NID_GRP + , __pBitmap + , , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pBitmap->Construct(bitmap, Rectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight())); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pBitmap = &bitmap; + } + + if (pRect == null) + { + __rect.x = 0; + __rect.y = 0; + __rect.width = __pBitmap->GetWidth(); + __rect.height = __pBitmap->GetHeight(); + } + else + { + __rect = *pRect; + } + return; + +CATCH: + if (__pBitmap) + { + delete __pBitmap; + __pBitmap = null; + } +} + +TextImage::~TextImage(void) +{ + if (_sourceType == TEXT_ELEMENT_SOURCE_TYPE_INTERNAL) + { + if (__pBitmap) + { + delete __pBitmap; + __pBitmap = null; + } + } +} + +int +TextImage::ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, int& actualLength, + int& width, int& height) +{ + SysTryReturn(NID_GRP + , 0 <= startTextIndex && startTextIndex < _length + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SysTryReturn(NID_GRP + , textLength <= _length + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + actualLength = 0; + width = 0; + height = 0; + + if (textLength == 0) + { + return TEXT_RETBY_NORMAL; + } + + if (maxWidth < __rect.width) + { + return TEXT_RETBY_OVERWIDTH; + } + else + { + actualLength = 1; + width = __rect.width; + height = __rect.height; + } + + return TEXT_RETBY_NORMAL; +} + +result +TextImage::GetRegion(int textIndex, int textLength, int& width, int& height) const +{ + SysTryReturn(NID_GRP + , 0 <= textIndex && textIndex < _length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SysTryReturn(NID_GRP + , textLength <= _length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + if (textLength == 0) + { + width = 0; + height = 0; + return E_SUCCESS; + } + + width = __rect.width; + height = __rect.height; + + return E_SUCCESS; +} + +result +TextImage::GetBlockRegion(int textIndex, int textLength, int& width, int& height) const +{ + return GetRegion(textIndex, textLength, width, height); +} + +int +TextImage::GetHeight(void) const +{ + return __rect.height; +} + +result +TextImage::Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment align, const TextObjectActionType action) +{ + SysTryReturn(NID_GRP + , __pBitmap + , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet."); + + result r = E_SUCCESS; + if (textLength == 0) + { + return E_SUCCESS; + } + + _Canvas* pCanvas = _Canvas::GetInstance(canvasImpl); + SysTryReturn(NID_GRP + , pCanvas + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native canvas instance."); + + + Rectangle bitmapRect = displayRect; + + if (bitmapRect.width <= 0) + { + bitmapRect.width = __rect.width; + } + if (bitmapRect.height <= 0) + { + bitmapRect.height = __rect.height; + } + + if (bitmapRect.width > __rect.width) + { + bitmapRect.width = __rect.width; + } + if (bitmapRect.height > __rect.height) + { + bitmapRect.height = __rect.height; + } + + switch (__align & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + // fall through + default: + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + bitmapRect.y = (bitmapRect.height - __pBitmap->GetHeight()) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + bitmapRect.y = (bitmapRect.height - __pBitmap->GetHeight()); + break; + } + + switch (__align & TEXT_ALIGNMASK_HORIZ) + { + case TEXT_OBJECT_ALIGNMENT_LEFT: + // fall through + default: + break; + + case TEXT_OBJECT_ALIGNMENT_CENTER: + bitmapRect.x = (bitmapRect.width - __pBitmap->GetWidth()) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_RIGHT: + bitmapRect.x = (bitmapRect.width - __pBitmap->GetWidth()); + break; + } + + r = pCanvas->DrawBitmap(bitmapRect, *GetBitmapEx(*_BitmapImpl::GetInstance(*__pBitmap))); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (_hasFocus) + { + r = pCanvas->DrawRectangle(_Util::Convert >(bitmapRect)); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; +} + +TextElement* +TextImage::CloneN(TextComponentInfoValueType type, unsigned int value) +{ + SysTryReturn(NID_GRP, __pBitmap, null, E_SYSTEM, "[E_SYSTEM] Failed to clone image."); + + TextImage* pImageText = null; + + pImageText = new (std::nothrow) TextImage(*__pBitmap, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, &__rect, __align); + SysTryReturn(NID_GRP + , pImageText + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + TextElement::CopyMembers(pImageText); + + pImageText->SetValue(type, value); + + return pImageText; +} + +TextElement* +TextImage::CopyN(int startTextIndex, int textLength) +{ + SysTryReturn(NID_GRP, __pBitmap, null, E_SYSTEM, "[E_SYSTEM] Failed to copy image."); + + if (startTextIndex != 0) + { + return null; + } + + if (textLength != 1) + { + textLength = 1; + } + + TextImage* pImageText = null; + + pImageText = new (std::nothrow) TextImage(*__pBitmap, _sourceType, &__rect, __align); + SysTryReturn(NID_GRP + , pImageText + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + return pImageText; +} + +unsigned int +TextImage::GetValue(TextComponentInfoValueType type) const +{ + switch (type) + { + case SET_IMAGE_ALIGN: + // fall through + return (unsigned int) __align; + + case SET_IMAGE_RECT: + // fall through + return (unsigned int) &__rect; + + case SET_ALTERNATE_LOOK: + // fall through + return (unsigned int) _isAlternateLookEnabled; + + case SET_TEXT_OFFSET: + break; + + case SET_ALTERNATIVE_FGCOLOR: + break; + + default: + break; + } + + return 0; +} + +result +TextImage::SetValue(TextComponentInfoValueType type, unsigned int value) +{ + switch (type) + { + case SET_IMAGE_ALIGN: + __align = (TextObjectAlignment) value; + break; + + case SET_IMAGE_RECT: + break; + + case SET_TEXT_OFFSET: + break; + + case SET_ALTERNATE_LOOK: + _isAlternateLookEnabled = (bool) value; + break; + + case SET_ALTERNATIVE_FGCOLOR: + break; + + default: + break; + } + + return E_SUCCESS; +} + +result +TextImage::SetBounds(const Rectangle& rect) +{ + __rect = rect; + __rect.x = 0; + __rect.y = 0; + + return E_SUCCESS; +} + +result +TextImage::SetAlignment(TextObjectAlignment alignment) +{ + SysTryReturn(NID_GRP + , TEXT_OBJECT_ALIGNMENT_LEFT <= alignment && alignment <= TEXT_OBJECT_ALIGNMENT_BOTTOM + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + __align = alignment; + + return E_SUCCESS; +} + +Rectangle +TextImage::GetBounds(void) const +{ + return __rect; +} + +TextObjectAlignment +TextImage::GetAlignment(void) const +{ + return __align; +} + +const Bitmap* +TextImage::GetBitmap(void) const +{ + return __pBitmap; +} + +void +TextImage::SetTextLength(int length) +{ + return; +} + +int +TextImage::GetBaseline(void) const +{ + return 0; +} + +}}} // Tizen::Graphics::_Text diff --git a/src/graphics/text/FGrp_TextTextLine.cpp b/src/graphics/text/FGrp_TextTextLine.cpp new file mode 100644 index 0000000..371cd92 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextLine.cpp @@ -0,0 +1,352 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextLine.cpp + * @brief This is the implementation file for TextLine class. + */ + +#include +#include +#include "FGrp_CanvasImpl.h" +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextComposite.h" +#include "FGrp_TextTextLine.h" + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +TextLine::TextLine(TextComposite* pCompositeText) +{ + __index = -1; + __textOffset = -1; + __textLength = -1; + __width = -1; + __height = -1; + __endType = -1; + __rect.x = 0; + __rect.y = 0; + __rect.height = 0; + __rect.width = 0; + __baseline = 0; + __pCompositeText = pCompositeText; + + // For Sweep Info + __sweepComposeLineInfo.isValid = false; + __sweepComposeLineInfo.prevLineTextOffset = 0; + __sweepComposeLineInfo.prevLineTextLength = 0; + __sweepComposeLineInfo.prevLineWidth = 0; + __sweepComposeLineInfo.currentLineTextOffset = 0; + __sweepComposeLineInfo.currentLineTextLength = 0; + __sweepComposeLineInfo.currentLineWidth = 0; + + __sweepIn = 0; + __sweepOut = 0; + __sweepType = 0; + __isKeyInputChanged = false; + __keyInputTextIndex = 0; + __keyInputTextLength = 0; +} + +TextLine::~TextLine(void) +{ + +} + +result +TextLine::GetRegion(int textIndex, int textLength, int& width, int& height) const +{ + if (textIndex != 0 || textLength != __textLength) + { + return __pCompositeText->GetRegion(textIndex + __textOffset, textIndex + textLength + __textOffset, width, height); + + } + + width = __width; + height = __height; + + return E_SUCCESS; +} + +int +TextLine::GetHeight(int textIndex) const +{ + if (textIndex == -1) + { + return __height; + } + else if (textIndex >= 0 && textIndex < __textLength) + { + return __pCompositeText->GetHeight(textIndex + __textOffset); + } + else + { + return -1; + } +} + +result +TextLine::Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment align, + const TextObjectActionType action) +{ + SysTryReturn(NID_GRP + , startTextIndex == 0 && textLength == __textLength && __pCompositeText != null + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return __pCompositeText->DrawLine(canvasImpl, this, displayRect, align, action); +} + +result +TextLine::DrawPartial(_CanvasImpl& canvasImpl, int startTextIndex, int textLength, Rectangle& displayRect) +{ + SysTryReturn(NID_GRP + , __pCompositeText != null + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + int textIndexAtLine = GetTextOffset() + startTextIndex; + + return __pCompositeText->DrawPartial(canvasImpl, displayRect, textIndexAtLine, textLength); +} + +TextLine* +TextLine::CopyN(void) +{ + TextLine* pTextLine = null; + + pTextLine = new (std::nothrow) TextLine(__pCompositeText); + + SysTryReturn(NID_GRP + , pTextLine + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pTextLine->__index = __index; + pTextLine->__textOffset = __textOffset; + pTextLine->__textLength = __textLength; + pTextLine->__width = __width; + pTextLine->__height = __height; + pTextLine->__endType = __endType; + pTextLine->__rect.x = __rect.x; + pTextLine->__rect.y = __rect.y; + pTextLine->__rect.height = __rect.height; + pTextLine->__rect.width = __rect.width; + + return pTextLine; +} + +Rectangle +TextLine::GetBounds(void) const +{ + return __rect; +} + + +int +TextLine::GetTextLength(void) const +{ + return __textLength; +} + +void +TextLine::SetTextLength(int length) +{ + __textLength = length; +} + +void +TextLine::SetIndex(int index) +{ + __index = index; +} + +int +TextLine::GetIndex(void) const +{ + return __index; +} + +result +TextLine::SetTextOffset(int textOffset) +{ + __textOffset = textOffset; + + return E_SUCCESS; +} + +int +TextLine::GetTextOffset(void) const +{ + return __textOffset; +} + +result +TextLine::SetBounds(const Rectangle& rect) +{ + __rect = rect; + + return E_SUCCESS; +} + +void +TextLine::SetEndType(int endType) +{ + __endType = endType; +} + +int +TextLine::GetEndType(void) const +{ + return __endType; +} + +void +TextLine::SetRegion(int width, int height) +{ + __width = width; + __height = height; +} + +void +TextLine::SetBaseline(int baseline) +{ + __baseline = baseline; +} + +int +TextLine::GetBaseline(void) const +{ + return __baseline; +} + +int +TextLine::ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, + int& actualLength, int& width, int& height) +{ + return -1; +} + +result +TextLine::ResetSweepInfo(void) +{ + __sweepComposeLineInfo.isValid = false; + + return E_SUCCESS; +} + +void +TextLine::SetSweepComposeInfo(TextObjectSweepComposeLineInfo& textSweepComposeLineInfo) +{ + __sweepComposeLineInfo.isValid = textSweepComposeLineInfo.isValid; + __sweepComposeLineInfo.prevLineTextOffset = textSweepComposeLineInfo.prevLineTextOffset; + __sweepComposeLineInfo.prevLineTextLength = textSweepComposeLineInfo.prevLineTextLength; + __sweepComposeLineInfo.prevLineWidth = textSweepComposeLineInfo.prevLineWidth; + __sweepComposeLineInfo.currentLineTextOffset = textSweepComposeLineInfo.currentLineTextOffset; + __sweepComposeLineInfo.currentLineTextLength = textSweepComposeLineInfo.currentLineTextLength; + __sweepComposeLineInfo.currentLineWidth = textSweepComposeLineInfo.currentLineWidth; +} + +TextObjectSweepComposeLineInfo +TextLine::GetSweepComposeInfo(void) const +{ + TextObjectSweepComposeLineInfo textSweepComposeLineInfo; + + textSweepComposeLineInfo.isValid = __sweepComposeLineInfo.isValid; + textSweepComposeLineInfo.prevLineTextOffset = __sweepComposeLineInfo.prevLineTextOffset; + textSweepComposeLineInfo.prevLineTextLength = __sweepComposeLineInfo.prevLineTextLength; + textSweepComposeLineInfo.prevLineWidth = __sweepComposeLineInfo.prevLineWidth; + textSweepComposeLineInfo.currentLineTextOffset = __sweepComposeLineInfo.currentLineTextOffset; + textSweepComposeLineInfo.currentLineTextLength = __sweepComposeLineInfo.currentLineTextLength; + textSweepComposeLineInfo.currentLineWidth = __sweepComposeLineInfo.currentLineWidth; + + return textSweepComposeLineInfo; +} + +void +TextLine::SetSweepIn(int sweepIn) +{ + __sweepIn = sweepIn; +} + +int +TextLine::GetSweepIn(void) const +{ + return __sweepIn; +} + +void +TextLine::SetSweepOut(int sweepOut) +{ + __sweepOut = sweepOut; +} + +int +TextLine::GetSweepOut(void) const +{ + return __sweepOut; +} + +void +TextLine::SetKeyInputResult(int keyInputResult) +{ + __sweepType = keyInputResult; +} + +int +TextLine::GetKeyInputResult(void) const +{ + return __sweepType; +} + +void +TextLine::NotifyLineChanged(bool isChanged) +{ + __isKeyInputChanged = isChanged; +} + +bool +TextLine::isChanged(void) const +{ + return __isKeyInputChanged; +} + +void +TextLine::SetKeyInputOffset(int keyInputTextIndex) +{ + __keyInputTextIndex = keyInputTextIndex; +} + +int +TextLine::GetKeyInputOffset(void) const +{ + return __keyInputTextIndex; +} + +void +TextLine::SetKeyInputLength(int keyInputTextLength) +{ + __keyInputTextLength = keyInputTextLength; +} + +int +TextLine::GetKeyInputLength(void) +{ + return __keyInputTextLength; +} + +}}} // Tizen::Graphics::_Text diff --git a/src/graphics/text/FGrp_TextTextLine.h b/src/graphics/text/FGrp_TextTextLine.h new file mode 100644 index 0000000..f03eeb7 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextLine.h @@ -0,0 +1,146 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextLine.h + * @brief This is the header file for the TextLine class. + * + * This header file contains the declarations of the %TextLine class. + */ + +#ifndef _FGRP_INTERNAL_TEXT_LINE_H_ +#define _FGRP_INTERNAL_TEXT_LINE_H_ + +#include "FGrp_TextCommon.h" + +namespace Tizen { namespace Graphics +{ + +class _CanvasImpl; + +namespace _Text +{ + +class TextComposite; + +class TextLine +{ +public: + TextLine(TextComposite* pCompositeText = null); + + virtual ~TextLine(void); + +public: + virtual result Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, + const TextObjectAlignment align, const TextObjectActionType action); + + virtual result DrawPartial(_CanvasImpl& canvasImpl, int startTextIndex, int textLength, Rectangle& displayRect); + + virtual int ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, + int& actualLength, int& width, int& height); + + virtual result GetRegion(int textIndex, int textLength, int& width, int& height) const; + + virtual int GetHeight(int textIndex) const; + + virtual int GetTextLength(void) const; + + virtual void SetTextLength(int length); + + void SetIndex(int index); + + int GetIndex(void) const; + + result SetTextOffset(int textOffset); + + int GetTextOffset(void) const; + + result SetBounds(const Rectangle& rect); + + Rectangle GetBounds(void) const; + + void SetEndType(int endType); + + int GetEndType(void) const; + + void SetRegion(int width, int height); + + TextLine* CopyN(void); + + void SetBaseline(int baseline); + + int GetBaseline(void) const; + + result ResetSweepInfo(void); + + void SetSweepComposeInfo(TextObjectSweepComposeLineInfo& textSweepComposeLineInfo); + + TextObjectSweepComposeLineInfo GetSweepComposeInfo(void) const; + + void SetSweepIn(int sweepIn); + + int GetSweepIn(void) const; + + void SetSweepOut(int sweepOut); + + int GetSweepOut(void) const; + + void SetKeyInputResult(int keyInputResult); + + int GetKeyInputResult(void) const; + + void NotifyLineChanged(bool isChanged); + + bool isChanged(void) const; + + void SetKeyInputOffset(int keyInputTextIndex); + + int GetKeyInputOffset(void) const; + + void SetKeyInputLength(int keyInputTextLength); + + int GetKeyInputLength(void); + +// Attribute +private: + TextComposite* __pCompositeText; + Rectangle __rect; + int __endType; + int __index; + int __textOffset; + int __textLength; + int __width; + int __height; + int __baseline; + TextObjectSweepComposeLineInfo __sweepComposeLineInfo; + int __sweepIn; + int __sweepOut; + int __sweepType; + bool __isKeyInputChanged; + int __keyInputTextIndex; + int __keyInputTextLength; + +private: + TextLine(const TextLine& other); // NOT IMPLMENTED + + TextLine& operator =(const TextLine& rhs); // NOT IMPLMENTED + +}; // TextLine + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_LINE_H_ diff --git a/src/graphics/text/FGrp_TextTextObject.cpp b/src/graphics/text/FGrp_TextTextObject.cpp new file mode 100644 index 0000000..dc5e991 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextObject.cpp @@ -0,0 +1,3882 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextObject.cpp + * @brief This is the implementation file for TextObject class. + */ + +#include +#include +#include +#include "FGrp_FontImpl.h" +#include "../FGrp_Font.h" +#include "../FGrp_Canvas.h" +#include "../FGrp_ResUtil.h" +#include "FGrp_TextTextObject.h" +#include "FGrp_TextTextElement.h" +#include "FGrp_TextTextSimple.h" +#include "FGrp_TextTextImage.h" +#include "FGrp_TextTextCutLink.h" +#include "FGrp_TextTextComposite.h" +#include "FGrp_TextTextLine.h" +#include "FGrp_TextTextColumn.h" +#include "FGrp_TextTextUtility.h" +#include "FGrp_TextTextWidthManager.h" +#include "FGrp_Screen.h" + +#define IF_NOT_CONSTRUCTED(code) if (this->__pCompositeText == null || this->__pTextColumn == null) \ + { \ + code; \ + } + +using namespace Tizen::Base::Utility; +using namespace Tizen::Base; + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +TextObject::TextObject(void) +{ + __action = TEXT_OBJECT_ACTION_TYPE_NONE; + __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP); + __wrap = TEXT_OBJECT_WRAP_TYPE_NONE; + __isActionOn = false; + __isChanged = false; + __pCompositeText = null; + __pDefaultFont = null; + __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK); + __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE); + __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE); + __isAlternateLookEnabled = false; + __pTextColumn = null; + __textObjectEllipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_TAIL; + __isFirstDisplayPositionYChanged = false; + __rect.x = 0; + __rect.y = 0; + __rect.width = 0; + __rect.height = 0; + __pcRect.x = 0; + __pcRect.y = 0; + __pcRect.width = 0; + __pcRect.height = 0; + __slidingGap = 30; + __slidingStep = 2; + __pTextWidthManager = null; + __linkViewModeEnabled = false; + __isUrlLinkColorDefined = false; + __isEmailLinkColorDefined = false; + __isPhoneNumberLinkColorDefined = false; + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL] = Color::GetColor(COLOR_ID_BLUE); + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT] = Color::GetColor(COLOR_ID_BLUE); + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL] = Color::GetColor(COLOR_ID_BLUE); + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT] = Color::GetColor(COLOR_ID_BLUE); + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL] = Color::GetColor(COLOR_ID_BLUE); + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT] = Color::GetColor(COLOR_ID_BLUE); + + __sweepInfo.isValid = false; + __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_NONE; + __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_INSERT; + __sweepInfo.anchorTextIndex = 0; + __sweepInfo.anchorLineIndex = 0; + __sweepInfo.prevAnchorLineIndex = 0; + __sweepInfo.sweepRegionStartLineIndex = 0; + __sweepInfo.sweepRegionLineCount = 0; + __sweepInfo.insertedLineCount = 0; + __sweepInfo.deletedLineCount = 0; + __sweepInfo.widthChanged = 0; +} + +TextObject::~TextObject(void) +{ + if (__pCompositeText) + { + delete __pCompositeText; + __pCompositeText = null; + } + + if (__pTextColumn) + { + delete __pTextColumn; + __pTextColumn = null; + } + + if (__pTextWidthManager) + { + delete __pTextWidthManager; + __pTextWidthManager = null; + } + + if (__pDefaultFont) + { + delete __pDefaultFont; + __pDefaultFont = null; + } +} + +result +TextObject::Construct(void) +{ + result r = E_SUCCESS; + + __action = TEXT_OBJECT_ACTION_TYPE_NONE; + __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP); + __wrap = TEXT_OBJECT_WRAP_TYPE_WORD; + __isActionOn = false; + __isChanged = false; + __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK); + __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE); + __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE); + __slidingStep = 2; + __isAlternateLookEnabled = false; + __linkViewModeEnabled = false; + __pTextWidthManager = null; + + __pCompositeText = new (std::nothrow)TextComposite(); + SysTryCatch(NID_GRP + , __pCompositeText + , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + __pTextColumn = new (std::nothrow)TextColumn(__pCompositeText); + SysTryCatch(NID_GRP + , __pTextColumn + , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + __pDefaultFont = new (std::nothrow)Font(); + SysTryCatch(NID_GRP + , __pTextColumn + , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + r = __pDefaultFont->Construct(FONT_STYLE_PLAIN, 20); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , E_SYSTEM, "[E_SYSTEM] Fail to set font."); + + __pCompositeText->SetWrap(__wrap); + __pCompositeText->SetTextSweepInfo(&__sweepInfo); + + return E_SUCCESS; + +CATCH: + if (__pDefaultFont) + { + delete __pDefaultFont; + __pDefaultFont = null; + } + + if (__pCompositeText) + { + delete __pCompositeText; + __pCompositeText = null; + } + + if (__pTextColumn) + { + delete __pTextColumn; + __pTextColumn = null; + } + + if (__pTextWidthManager) + { + delete __pTextWidthManager; + __pTextWidthManager = null; + } + + return r; +} + +result +TextObject::Construct(const Rectangle& rect) +{ + result r = E_SUCCESS; + + __action = TEXT_OBJECT_ACTION_TYPE_NONE; + __align = (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP); + __wrap = TEXT_OBJECT_WRAP_TYPE_WORD; + __isActionOn = false; + __isChanged = false; + __defaultForegroundColor = Color::GetColor(COLOR_ID_BLACK); + __defaultBackgroundColor = Color::GetColor(COLOR_ID_WHITE); + __defaultOutlineColor = Color::GetColor(COLOR_ID_WHITE); + __slidingStep = 2; + __isAlternateLookEnabled = false; + __linkViewModeEnabled = false; + __pTextWidthManager = null; + __rect = rect; + __pcRect.x = _ResUtil::ConvertToPhyCoord(rect.x); + __pcRect.y = _ResUtil::ConvertToPhyCoord(rect.y); + __pcRect.width = _ResUtil::ConvertToPhyCoordWidth(rect.width); + __pcRect.height = _ResUtil::ConvertToPhyCoordHeight(rect.height); + + __pCompositeText = new (std::nothrow)TextComposite(); + SysTryCatch(NID_GRP + , __pCompositeText + , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + __pTextColumn = new (std::nothrow)TextColumn(__pCompositeText); + SysTryCatch(NID_GRP + , __pTextColumn + , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + __pDefaultFont = new (std::nothrow)Font(); + SysTryCatch(NID_GRP + , __pTextColumn + , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + r = __pDefaultFont->Construct(FONT_STYLE_PLAIN, 20); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , E_SYSTEM, "[E_SYSTEM] Fail to set font."); + + __pCompositeText->SetWrap(__wrap); + __pCompositeText->SetTextSweepInfo(&__sweepInfo); + + return E_SUCCESS; + +CATCH: + if (__pDefaultFont) + { + delete __pDefaultFont; + __pDefaultFont = null; + } + + if (__pCompositeText) + { + delete __pCompositeText; + __pCompositeText = null; + } + + if (__pTextColumn) + { + delete __pTextColumn; + __pTextColumn = null; + } + + if (__pTextWidthManager) + { + delete __pTextWidthManager; + __pTextWidthManager = null; + } + + return r; +} + +TextObject* +TextObject::CloneN(void) +{ + IF_NOT_CONSTRUCTED(return null); + + result r = E_SUCCESS; + TextObject* pTextObject = null; + TextElement* pTextElement = null; + TextElement* pCloneTextElement = null; + int count = __pCompositeText->GetElementCount(); + + pTextObject = new (std::nothrow)TextObject(); + SysTryReturn(NID_GRP + , pTextObject + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + r = pTextObject->Construct(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + + for (int i=0; i < count; i++) + { + pTextElement = __pCompositeText->GetElementAtElementIndex(i); + SysTryCatch(NID_GRP + , pTextElement + , , E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + pCloneTextElement = pTextElement->CloneN(SET_ALLVALUE_CLONE,0); + pTextObject->AppendElement(*pCloneTextElement); + } + + SetLastResult(E_SUCCESS); + + return pTextObject; + +CATCH: + delete pTextObject; + pTextObject = null; + + return null; +} + +result +TextObject::Draw(_CanvasImpl& canvasImpl) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + if (__pcRect.width == 0 || __pcRect.height == 0) + { + return E_SUCCESS; + } + + result r = E_SUCCESS; + TextLine* pTextLine = null; + Rectangle clipRect; + Rectangle lineBounds; + Rectangle targetBounds; + int totalHeight = 0; + int slidingWidth = 0; + + SysTryReturn(NID_GRP + , __pcRect.width > 0 && __pcRect.height > 0 + , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet. (width = %d, height = %d)", __pcRect.width, __pcRect.height); + + _Canvas* pCanvas = _Canvas::GetInstance(canvasImpl); + SysTryReturn(NID_GRP + , pCanvas + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + r = Compose(); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pTextColumn->GetTotalLineCount() <= 1) + { + __pTextColumn->SetFirstDisplayLineIndex(0); + __pTextColumn->SetFirstDisplayPositionY(0); + } + + targetBounds = __pcRect; + + if (__action == TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT) + { + if (__pTextColumn->GetTotalLineCount() == 0) + { + return E_SUCCESS; + } + + totalHeight = TextUtility::GetFontMaxHeight(__pDefaultFont); + } + else + { + totalHeight = __pTextColumn->GetTotalHeight(); + } + + if (totalHeight == 0) + { + return E_SUCCESS; + } + + if (totalHeight < targetBounds.height) + { + switch (__align & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + // fall through + default: + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + targetBounds.y += (targetBounds.height - totalHeight) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + targetBounds.y += targetBounds.height - totalHeight; + break; + } + } + else + { + if (targetBounds.height < totalHeight) + { + if (__action == TEXT_OBJECT_ACTION_TYPE_ABBREV) + { + int i = 0; + int lineCount = __pTextColumn->GetTotalLineCount(); + + if (lineCount == 1) + { + totalHeight = targetBounds.height; + } + else + { + int lineHeight = __pTextColumn->GetLineHeightAt(0); + + if (targetBounds.height < lineHeight) + { + totalHeight = targetBounds.height; + } + else + { + lineHeight = 0; + + for (i = 0; i < lineCount; i++) + { + lineHeight += __pTextColumn->GetLineHeightAt(i); + if (targetBounds.height < lineHeight) + { + lineHeight -= __pTextColumn->GetLineHeightAt(i); + break; + } + } + totalHeight = lineHeight; + } + } + } + else + { + goto CONTINUE_PROC; + } + } + else + { + goto CONTINUE_PROC; + } + + switch (__align & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + // fall through + default: + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + targetBounds.y += (targetBounds.height - totalHeight) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + targetBounds.y += targetBounds.height - totalHeight; + break; + } + targetBounds.height = totalHeight; + } + +CONTINUE_PROC: + Rectangle finalClipRect; + clipRect = pCanvas->GetClipBounds(); + + finalClipRect.x = Math::Max(clipRect.x, targetBounds.x); + finalClipRect.y = Math::Max(clipRect.y, targetBounds.y); + finalClipRect.width = Math::Min(clipRect.x + clipRect.width, targetBounds.x + targetBounds.width) - finalClipRect.x; + finalClipRect.height = Math::Min(clipRect.y + clipRect.height, targetBounds.y + targetBounds.height) - finalClipRect.y; + + SysTryReturn(NID_GRP + , 0 <= finalClipRect.width && 0 <= finalClipRect.height + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get clip rectangle."); + + pCanvas->SetClipBounds(finalClipRect); + + switch (__action) + { + case TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT: + pTextLine = __pTextColumn->GetTextLine(0); + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineBounds = pTextLine->GetBounds(); + __pTextColumn->SetDisplayLineCount(1); + __pTextColumn->SetDisplayHeight(lineBounds.height); + + slidingWidth = Math::Max(__pTextColumn->GetSlidingDimension().width, __pcRect.width); + + if (__isActionOn) + { + Rectangle slidingRect; + + targetBounds.width = lineBounds.width; + targetBounds.height = lineBounds.height; + + pCanvas->SetClipBounds(targetBounds); + + slidingRect = targetBounds; + + slidingRect.x += __pTextColumn->GetSlidingPosition(); + Dimension slidingDim = __pTextColumn->GetSlidingDimension(); + slidingRect.width = slidingDim.width; + slidingRect.height = slidingDim.height; + + __pCompositeText->Draw(canvasImpl, slidingRect, 0, __pCompositeText->GetTextLength(), + (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE); + + slidingRect.x += slidingDim.width + __slidingGap; + if (slidingRect.x < targetBounds.x + targetBounds.width) + { + slidingRect.width = targetBounds.x + targetBounds.width - slidingRect.x; + + __pCompositeText->Draw(canvasImpl, slidingRect, 0, __pCompositeText->GetTextLength(), + (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE); + } + } + else + { + pTextLine->Draw(canvasImpl, targetBounds, 0, pTextLine->GetTextLength(), + (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE); + } + break; + + case TEXT_OBJECT_ACTION_TYPE_SLIDE_UP: + { + Rectangle slidingRect = targetBounds; + slidingRect.y += __pTextColumn->GetSlidingPosition(); + + int lineCount = __pTextColumn->GetTotalLineCount(); + for (int i = 0; i < lineCount; i++) + { + pTextLine = __pTextColumn->GetTextLine(i); + if (pTextLine != null) + { + lineBounds = pTextLine->GetBounds(); + slidingRect.height = lineBounds.height; + if ((slidingRect.y + slidingRect.height >= targetBounds.y) && + (slidingRect.y < targetBounds.y + targetBounds.height)) + { + pTextLine->Draw(canvasImpl, slidingRect, 0, pTextLine->GetTextLength(), + (TextObjectAlignment)(__align & TEXT_ALIGNMASK_HORIZ), TEXT_OBJECT_ACTION_TYPE_NONE); + } + } + slidingRect.y += slidingRect.height; + } + } + break; + + case TEXT_OBJECT_ACTION_TYPE_ABBREV: + if (__pCompositeText->IsTextAbbreviationEnabled()) + { + __pCompositeText->DrawAbbrev(canvasImpl, targetBounds, __align); + } + else + { + DrawByLine(canvasImpl, targetBounds); + } + break; + + case TEXT_OBJECT_ACTION_TYPE_NONE: + // fall through + default: + DrawByLine(canvasImpl, targetBounds); + break; + } + + pCanvas->SetClipBounds(clipRect); + + return E_SUCCESS; +} + +result +TextObject::GetChangedLineRange(int& startChangedLineIndex, int& endChangedLineIndex) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + + r = Compose(); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + startChangedLineIndex = __sweepInfo.sweepRegionStartLineIndex; + endChangedLineIndex = __sweepInfo.sweepRegionStartLineIndex + __sweepInfo.sweepRegionLineCount - 1; + + return E_SUCCESS; +} + +result +TextObject::DrawLine(_CanvasImpl& canvasImpl, int lineIndex) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , lineIndex >= 0 + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex); + + result r = E_SUCCESS; + TextLine* pTextLine = null; + Rectangle lineBounds; + int firstDisplayY = __pTextColumn->GetFirstDisplayPositionY(); + + r = Compose(); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pTextLine = __pTextColumn->GetTextLine(lineIndex); + if (pTextLine == null) + { + SysLog(NID_GRP, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d, total line count = %d)" + , lineIndex, __pTextColumn->GetTotalLineCount()); + + return E_INVALID_ARG; + } + + lineBounds = pTextLine->GetBounds(); + lineBounds.y = lineBounds.y - firstDisplayY + __rect.y; + + int length = pTextLine->GetTextLength(); + pTextLine->Draw(canvasImpl, lineBounds, 0, length, __align, TEXT_OBJECT_ACTION_TYPE_NONE); + + return E_SUCCESS; +} + +result +TextObject::DrawWithOffset(_CanvasImpl& canvasImpl) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , __isActionOn + , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Action is off."); + + int slidingStartIndex = __pTextColumn->GetSlidingPosition(); + Dimension slidingDim = __pTextColumn->GetSlidingDimension(); + + switch (__action) + { + case TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT: + if (__pcRect.width < slidingDim.width) + { + slidingDim.width = Math::Max(slidingDim.width, __pcRect.width); + + if (__slidingStep < slidingStartIndex + slidingDim.width + __slidingGap) + { + slidingStartIndex -= __slidingStep; + } + else + { + slidingStartIndex += slidingDim.width + __slidingGap; + } + } + else + { + if (0 < slidingStartIndex + slidingDim.width) + { + slidingStartIndex -= __slidingStep; + } + else + { + slidingStartIndex = __pcRect.width + __slidingGap + slidingStartIndex; + } + } + __pTextColumn->SetSlidingPosition(slidingStartIndex); + break; + + case TEXT_OBJECT_ACTION_TYPE_SLIDE_UP: + if (slidingStartIndex + slidingDim.height >= 0) + { + slidingStartIndex -= __slidingStep; + } + else + { + slidingStartIndex = __pcRect.height; + } + __pTextColumn->SetSlidingPosition(slidingStartIndex); + break; + + case TEXT_OBJECT_ACTION_TYPE_ABBREV: + // fall through + case TEXT_OBJECT_ACTION_TYPE_NONE: + // fall through + default: + break; + } + + return Draw(canvasImpl); +} + +result +TextObject::UpdateChangedInfo(int startTextIndex, int textLength, bool initTextWidthManager) +{ + result r = E_SUCCESS; + + if (startTextIndex >= 0) + { + r = __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_UNKONWN, startTextIndex, 0); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pCompositeText->IsWidthManagerEnabled() && __pTextWidthManager && initTextWidthManager) + { + __pTextWidthManager->Finalize(); + if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD) + { + __pTextWidthManager->Initialize(__pCompositeText->GetTextLength()); + } + } + } + + __isChanged = true; + + if (IsPartialComposingModeEnabled()) + { + __pCompositeText->InitPartialComposeMode(); + } + + return E_SUCCESS; +} + +bool +TextObject::IsChanged(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + return __isChanged; +} + +result +TextObject::SetPartialComposingModeEnabled(bool enable) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + __pCompositeText->SetPartialComposingModeEnabled(enable); + + return E_SUCCESS; +} + +bool +TextObject::IsPartialComposingModeEnabled(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + return __pCompositeText->IsPartialComposingModeEnabled(); +} + +result +TextObject::Compose(void) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + int lineCount = 0; + Rectangle rect; + Rectangle lineBounds; + + SysTryReturn(NID_GRP + , __pcRect.width >= 0 && __pcRect.height >= 0 + , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet."); + + rect = __pcRect; + + if (__pCompositeText->IsPartialComposingModeEnabled()) + { + if (__pCompositeText->IsComposeDone() || !__isFirstDisplayPositionYChanged) + { + if (GetTotalLineCount() != 0) + { + return E_SUCCESS; + } + } + } + else + { + if (!__isChanged || __pTextColumn->GetChangeActionEventCount() == 0) + { + return E_SUCCESS; + } + } + + __isActionOn = false; + + if (__pTextColumn->GetTotalLineCount() == 0) + { + __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_UNKONWN, 0, 0); + __pTextColumn->SetFirstDisplayLineIndex(0); + __pTextColumn->SetFirstDisplayPositionY(0); + } + + ResetSweepInfo(); + lineCount = __pCompositeText->Compose(rect, __pTextColumn); + + switch (__action) + { + case TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT: + { + TextLine* pTextLine = __pTextColumn->GetTextLine(0); + if (pTextLine != null) + { + int lineLength = pTextLine->GetTextLength(); + int totalLength = __pCompositeText->GetTextLength(); + + if (lineLength < totalLength) + { + __isActionOn = true; + __pTextColumn->SetSlidingPosition(0); + + Dimension slidingDim; + Dimension lineTextSize; + + __pCompositeText->GetRegion(0, totalLength, slidingDim.width, slidingDim.height); + pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height); + lineBounds = pTextLine->GetBounds(); + + __pTextColumn->SetSlidingDimension(slidingDim); + + lineBounds.height = slidingDim.height; + lineTextSize.width = lineBounds.width; + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(lineTextSize.width, lineTextSize.height); + } + } + } + break; + + case TEXT_OBJECT_ACTION_TYPE_SLIDE_UP: + { + __pTextColumn->SetSlidingPosition(0); + + int totalHeight = __pTextColumn->GetTotalHeight(); + Dimension slidingDim; + slidingDim.width = __pcRect.width; + slidingDim.height = totalHeight; + + __pTextColumn->SetSlidingDimension(slidingDim); + + if (__pcRect.height < totalHeight) + { + __isActionOn = true; + } + } + break; + + case TEXT_OBJECT_ACTION_TYPE_ABBREV: + // fall through + case TEXT_OBJECT_ACTION_TYPE_NONE: + // fall through + default: + break; + } + + __isChanged = false; + + return E_SUCCESS; +} + +int +TextObject::GetText(wchar_t* pCopiedText, int textLength) const +{ + IF_NOT_CONSTRUCTED(return -1); + + SysTryReturn(NID_GRP + , pCopiedText + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SysTryReturn(NID_GRP + , textLength > 0 + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + int textElementCount = 0; + int totalLength = 0; + int outLength = textLength; + int copiedLength = 0; + TextElement* pTextElement = null; + wchar_t* pSrcText = null; + wchar_t* pDstText = null; + + textElementCount = __pCompositeText->GetElementCount(); + pDstText = pCopiedText; + + for (int i = 0; i < textElementCount && totalLength < outLength; i++) + { + pTextElement = __pCompositeText->GetElementAtElementIndex(i); + if (pTextElement == null) + { + return totalLength; + } + + TextElementType objectType = pTextElement->GetType(); + if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK) + { + int elementTextLength = pTextElement->GetTextLength(); + TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement); + if (pSimpleText != null) + { + copiedLength = (elementTextLength > outLength - totalLength) ? outLength - totalLength : elementTextLength; + SysTryReturn(NID_GRP + , 0 <= copiedLength + , -1, E_SYSTEM, "[E_SYSTEM] Fail to string copy."); + + pSrcText = (wchar_t*)pSimpleText->GetText(); + + result r = TextUtility::CopyText(pDstText, pSrcText, copiedLength); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + pDstText += copiedLength; + totalLength += copiedLength; + } + } + } + + SetLastResult(E_SUCCESS); + + return totalLength; +} + +result +TextObject::SetFirstDisplayLineIndex(int lineIndex) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + Rectangle lineBounds; + TextLine* pTextLine = null; + int firstDisplayPositionY = 0; + int rollbackFirstDisplayPositionY = 0; + int rollbackFirstDisplayLineIndex = 0; + + rollbackFirstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionY(); + rollbackFirstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex(); + + __pTextColumn->SetFirstDisplayLineIndex(lineIndex); + + pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryCatch(NID_GRP + , pTextLine + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + lineBounds = pTextLine->GetBounds(); + firstDisplayPositionY = lineBounds.y; + + __pTextColumn->SetFirstDisplayPositionY(firstDisplayPositionY); + + return E_SUCCESS; + +CATCH: + __pTextColumn->SetFirstDisplayLineIndex(rollbackFirstDisplayLineIndex); + __pTextColumn->SetFirstDisplayPositionY(rollbackFirstDisplayPositionY); + + return r; +} + +result +TextObject::SetFirstDisplayPositionY(int lcY) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + + int pcY = _ResUtil::ConvertToPhyCoord(lcY); + if (IsPartialComposingModeEnabled()) + { + __isFirstDisplayPositionYChanged = true; + + if (__pCompositeText->GetTotalComposedHeight() <= (pcY + __pcRect.height)) + { + __pCompositeText->SetComposePartialLimitHeight(pcY + __pcRect.height - GetTotalComposedHeight()); + + r = Compose(); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + __isFirstDisplayPositionYChanged = false; + __pTextColumn->SetFirstDisplayPositionY(pcY); + + return E_SUCCESS; + +CATCH: + __isFirstDisplayPositionYChanged = false; + return r; +} + +int +TextObject::GetMaxLineHeight(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + int pcMaxHeight = __pCompositeText->GetMaxLineHeight(); + pcMaxHeight = Math::Max(pcMaxHeight, TextUtility::GetFontMaxHeight(__pDefaultFont)); + int lcMaxHeight = _ResUtil::ConvertToVirCoord(pcMaxHeight); + + return lcMaxHeight; +} + +bool +TextObject::IsDisplayedAtStartPosition(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + int firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionY(); + if (firstDisplayPositionY == 0) + { + return true; + } + else + { + return false; + } +} + +bool +TextObject::IsDisplayedAtEndPosition(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + int totalHeight = 0; + int firstDisplayPositionY = 0; + + firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionY(); + totalHeight = __pTextColumn->GetTotalHeight(); + + if ((totalHeight - firstDisplayPositionY) <= __pcRect.height) + { + return true; + } + else + { + return false; + } +} + +result +TextObject::SetAction(TextObjectActionType action) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , TEXT_OBJECT_ACTION_TYPE_NONE <= action && action < TEXT_OBJECT_ACTION_TYPE_MAX + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + if (__action != action) + { + if ((__action == TEXT_OBJECT_ACTION_TYPE_NONE && action == TEXT_OBJECT_ACTION_TYPE_ABBREV) || + (__action == TEXT_OBJECT_ACTION_TYPE_ABBREV && action == TEXT_OBJECT_ACTION_TYPE_NONE)) + { + __action = action; + UpdateChangedInfo(0, 0); + } + else + { + __action = action; + UpdateChangedInfo(0, 0); + } + } + if (__action == TEXT_OBJECT_ACTION_TYPE_ABBREV) + { + __pCompositeText->SetTextAbbreviationEnabled(true); + } + else + { + __pCompositeText->SetTextAbbreviationEnabled(false); + } + + return E_SUCCESS; +} + +result +TextObject::SetAlignment(TextObjectAlignment alignment) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , TEXT_OBJECT_ALIGNMENT_LEFT <= alignment && alignment < TEXT_OBJECT_ALIGNMENT_INVALID + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. alignment(%d)", alignment); + + if (__align != alignment) + { + __align = alignment; + UpdateChangedInfo(0, 0); + } + + return E_SUCCESS; +} + +result +TextObject::SetBounds(const Rectangle& lcRect) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , (lcRect.width >= 0) && (lcRect.height >= 0) + , E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The given rectangle(width:%d,height:%d) is out of range.\n", lcRect.width, lcRect.height); + + if (__rect.width != lcRect.width) + { + UpdateChangedInfo(0, 0, false); + } + + __rect = lcRect; + + if (_ResUtil::NeedToConvertCoord()) + { + __pcRect.x = _ResUtil::ConvertToPhyCoord(__rect.x); + __pcRect.y = _ResUtil::ConvertToPhyCoord(__rect.y); + __pcRect.width = _ResUtil::ConvertToPhyCoordWidth(__rect.width); + + // temporary code for tizen 2.0 + if (_Screen::GetWidth() == 600) + { + __pcRect.width++; + } + + __pcRect.height = _ResUtil::ConvertToPhyCoordHeight(__rect.height); + } + else + { + __pcRect = __rect; + } + + return E_SUCCESS; +} + +result +TextObject::SetLineSpace(int lcLineSpacing) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , lcLineSpacing >= 0 + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + int pcLineSpacing = _ResUtil::ConvertToPhyCoord(lcLineSpacing); + + if (__pCompositeText->GetLineSpace() != pcLineSpacing) + { + __pCompositeText->SetLineSpace(pcLineSpacing); + __isChanged = true; + } + + return E_SUCCESS; +} + +result +TextObject::SetElementVerticalAlignment(TextObjectAlignment alignment) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , (alignment & TEXT_OBJECT_ALIGNMENT_TOP) || (alignment & TEXT_OBJECT_ALIGNMENT_MIDDLE) || (alignment & TEXT_OBJECT_ALIGNMENT_BOTTOM) || (alignment & TEXT_OBJECT_ALIGNMENT_BASELINE) + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. alignment(%d)", alignment); + + if (__pCompositeText->GetElementVerticalAlignment() == alignment) + { + return E_SUCCESS; + } + + __pCompositeText->SetElementVerticalAlignment(alignment); + __isChanged = true; + + return E_SUCCESS; +} + +Dimension +TextObject::GetTextExtent(int startTextIndex, int textLength) const +{ + IF_NOT_CONSTRUCTED(return Dimension(-1, -1)); + + Dimension pcTextSize; + result r = __pCompositeText->GetRegion(startTextIndex, textLength, pcTextSize.width, pcTextSize.height); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , Dimension(-1, -1), r, "[%s] Propagating.", GetErrorMessage(r)); + + Dimension lcTextSize; + lcTextSize.width = _ResUtil::ConvertToVirCoord(pcTextSize.width); + lcTextSize.height = _ResUtil::ConvertToVirCoord(pcTextSize.height); + + SetLastResult(E_SUCCESS); + + return lcTextSize; +} + +result +TextObject::AppendElement(TextElement& textElement) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + TextElementType objecType = textElement.GetType(); + if (objecType == TEXT_ELEMENT_TYPE_CUTLINK) + { + TextCutLink* pLinkText = dynamic_cast < TextCutLink* >(&textElement); + if (pLinkText != null) + { + switch (pLinkText->GetCutLinkType()) + { + case LINK_TYPE_URL: + if (__isUrlLinkColorDefined) + { + pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL], __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT]); + } + break; + + case LINK_TYPE_EMAIL: + if (__isEmailLinkColorDefined) + { + pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL], __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT]); + } + break; + + case LINK_TYPE_TEL_NUM: + if (__isPhoneNumberLinkColorDefined) + { + pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL], + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT]); + } + break; + + default: + break; + } + } + } + + int textIndex = __pCompositeText->GetTextLength(); + int elementTextLength = textElement.GetTextLength(); + + r = __pCompositeText->AppendElement(textElement); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int elementCount = __pCompositeText->GetElementCount(); + if (elementCount > 0) + { + __pCompositeText->Optimize(elementCount-1, elementCount-1); + } + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) + { + UpdateChangedInfo(0, 0); + } + else + { + NotifyTextAdded(textIndex, elementTextLength); + } + + return r; +} + +result +TextObject::InsertElementAt(int textIndex, TextElement& textElement) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + TextElementType objecType = textElement.GetType(); + + if (objecType == TEXT_ELEMENT_TYPE_CUTLINK) + { + TextCutLink* pLinkText = dynamic_cast < TextCutLink* >(&textElement); + if (pLinkText != null) + { + switch (pLinkText->GetCutLinkType()) + { + case LINK_TYPE_URL: + if (__isUrlLinkColorDefined) + { + pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL], + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT]); + } + break; + + case LINK_TYPE_EMAIL: + if (__isEmailLinkColorDefined) + { + pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL], + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT]); + } + break; + + case LINK_TYPE_TEL_NUM: + if (__isPhoneNumberLinkColorDefined) + { + pLinkText->SetUserColor(__linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL], + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT]); + } + break; + + default: + break; + } + } + } + + r = __pCompositeText->InsertElementAt(textElement, textIndex); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Fail to insert element.", GetErrorMessage(r)); + + int elementIndex = __pCompositeText->GetElementIndexOf(textElement); + if (elementIndex != -1) + { + __pCompositeText->Optimize(elementIndex, elementIndex); + } + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) + { + UpdateChangedInfo(0, 0); + } + else + { + NotifyTextAdded(textIndex, textElement.GetTextLength()); + } + + return r; +} + +result +TextObject::RemoveAll(bool deallocate) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = __pTextColumn->RemoveAllLines(); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pCompositeText->RemoveAllElements(deallocate); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + UpdateChangedInfo(0); + + __isActionOn = false; + + return r; +} + +result +TextObject::RemoveElement(TextElement& textElement, bool deallocate) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + int elementIndex = 0; + int textIndex = 0; + int elementTextLength = 0; + TextElement* pCurrentTextElement = null; + + elementIndex = __pCompositeText->GetElementIndexOf(textElement); + SysTryReturn(NID_GRP + , 0 <= elementIndex + , E_INVALID_ARG, E_INVALID_ARG, "[E_SYSTEM] The argument is invalid."); + + for (int i = 0; i < elementIndex; i++) + { + pCurrentTextElement = __pCompositeText->GetElementAtElementIndex(i); + if (pCurrentTextElement != null) + { + textIndex += pCurrentTextElement->GetTextLength(); + } + } + + elementTextLength = textElement.GetTextLength(); + + r = __pCompositeText->RemoveElementAt(elementIndex, deallocate); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + NotifyTextDeleted(textIndex, elementTextLength); + + if (__pCompositeText->GetElementCount() == 0 || GetTextLength() == 0) + { + __pTextColumn->RemoveAllLines(); + } + + return r; +} + +TextElement* +TextObject::GetElementAtTextIndex(int textIndex) const +{ + IF_NOT_CONSTRUCTED(return null); + + TextElement* pTextElement = null; + int elementTextLength = 0; + int textIndexFromElementOffset = 0; + int elementIndex = 0; + int elementOffset = 0; + + pTextElement = __pCompositeText->GetElementAtTextIndex(textIndex, elementOffset, elementIndex, elementTextLength, + textIndexFromElementOffset); + SysTryCatch(NID_GRP + , pTextElement + , , E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + SetLastResult(E_SUCCESS); + return pTextElement; + +CATCH: + elementOffset = 0; + elementIndex = 0; + return null; +} + +result +TextObject::SetFont(Font* pFont, int startTextIndex, int textLength) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , pFont + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SysTryReturn(NID_GRP + , startTextIndex >= 0 + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + Font* pTmpFont = null; + + pTmpFont = _FontImpl::CloneN(const_cast < Font& >(*pFont)); + r = GetLastResult(); + SysTryReturn(NID_GRP + , pTmpFont + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pDefaultFont) + { + delete __pDefaultFont; + __pDefaultFont = null; + } + __pDefaultFont = pTmpFont; + + __pCompositeText->SetRange(startTextIndex, textLength); + r = __pCompositeText->SetFont(pFont); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + UpdateChangedInfo(__pCompositeText->GetWorkStart(), 0); + + return E_SUCCESS; +} + +const Font* +TextObject::GetFont(int textIndex) const +{ + IF_NOT_CONSTRUCTED(return null); + + Font* pFont = __pCompositeText->GetFont(textIndex); + if (pFont == null) + { + pFont = __pDefaultFont; + } + + SetLastResult(E_SUCCESS); + return pFont; +} + +result +TextObject::SetForegroundColor(const Color& color, int startTextIndex, int textLength) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , startTextIndex >= 0 + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + __defaultForegroundColor = color; + + __pCompositeText->SetRange(startTextIndex, textLength); + __pCompositeText->SetForegroundColor(color); + + return E_SUCCESS; +} + +Color +TextObject::GetForegroundColor(int textIndex) const +{ + IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK)); + + SysTryReturn(NID_GRP + , textIndex >= 0 + , __defaultForegroundColor, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return __pCompositeText->GetForegroundColor(textIndex); +} + +result +TextObject::SetBackgroundColor(const Color& color, int startTextIndex, int textLength) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , startTextIndex >= 0 + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + __defaultBackgroundColor = color; + + __pCompositeText->SetRange(startTextIndex, textLength); + __pCompositeText->SetBackgroundColor(color); + + return E_SUCCESS; +} + +Color +TextObject::GetBackgroundColor(int textIndex) const +{ + IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK)); + + SysTryReturn(NID_GRP + , textIndex >= 0 + , __defaultBackgroundColor, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return __pCompositeText->GetBackgroundColor(textIndex); +} + +result +TextObject::SetOutlineColor(const Color& color, int startTextIndex, int textLength) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , startTextIndex >= 0 + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + __defaultOutlineColor = color; + + __pCompositeText->SetRange(startTextIndex, textLength); + __pCompositeText->SetOutlineColor(color); + + return E_SUCCESS; +} + +Color +TextObject::GetOutlineColor(int textIndex) const +{ + IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK)); + + SysTryReturn(NID_GRP + , textIndex >= 0 + , __defaultOutlineColor, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return __pCompositeText->GetOutlineColor(textIndex); +} + +result +TextObject::SetBlockColor(const Color& color) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + __pCompositeText->SetBlockColor(color); + + return E_SUCCESS; +} + +Color +TextObject::GetBlockColor(void) const +{ + IF_NOT_CONSTRUCTED(return Color::GetColor(COLOR_ID_BLACK)); + + return __pCompositeText->GetBlockColor(); +} + +result +TextObject::SetWrap(TextObjectWrapType wrap) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + + if (__wrap == wrap) + { + return E_SUCCESS; + } + + r = __pCompositeText->SetWrap(wrap); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __wrap = wrap; + UpdateChangedInfo(0, 0); + + return E_SUCCESS; +} + +result +TextObject::InsertElementAt(int textIndex, Bitmap& bitmap, TextElementSourceType sourceType) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + TextImage* pImageText = null; + int addedTextLength = 0; + int startTextIndex = 0; + + pImageText = new (std::nothrow)TextImage(bitmap, sourceType, null, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP)); + SysTryReturn(NID_GRP + , pImageText + , E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + addedTextLength = pImageText->GetTextLength(); + __pCompositeText->InsertElementAt(*pImageText, textIndex); + startTextIndex = __pCompositeText->GetWorkStart(); + NotifyTextAdded(startTextIndex, addedTextLength); + + return E_SUCCESS; +} + +result +TextObject::AppendElement(Bitmap& bitmap, TextElementSourceType sourceType) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + TextImage* pImageText = null; + + pImageText = new (std::nothrow)TextImage(bitmap, sourceType, null, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP)); + SysTryReturn(NID_GRP + , pImageText + , E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + r = __pCompositeText->AppendElement(*pImageText); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int startTextIndex = __pCompositeText->GetWorkStart(); + int elementTextLength = pImageText->GetTextLength(); + + NotifyTextAdded(startTextIndex, elementTextLength); + + return E_SUCCESS; +} + +result +TextObject::SetAlternateLookEnabled(bool enable) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + int elementCount = 0; + TextElement* pTextElement = null; + + __isAlternateLookEnabled = enable; + elementCount = __pCompositeText->GetElementCount(); + + for (int i = 0; i < elementCount; i++) + { + pTextElement = __pCompositeText->GetElementAtElementIndex(i); + if (pTextElement != null) + { + pTextElement->SetAlternateLookEnabled(enable); + } + } + + return E_SUCCESS; +} + +result +TextObject::SetAlternativeForegroundColor(const Color& color) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + int elementCount = 0; + TextElement* pTextElement = null; + + elementCount = __pCompositeText->GetElementCount(); + + for (int i = 0; i < elementCount; i++) + { + pTextElement = __pCompositeText->GetElementAtElementIndex(i); + SysTryReturn(NID_GRP + , pTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + pTextElement->SetAlternativeForegroundColor(color); + } + + return E_SUCCESS; +} + +result +TextObject::ChangeTextOffset(wchar_t* pText, int textIndex, int gap) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + int elementStartTextIndex = 0; + int elementIndex = 0; + int elementTextLength = 0; + int textIndexFromElementOffset = 0; + + TextElement* pTextElement = __pCompositeText->GetElementAtTextIndex(textIndex, elementStartTextIndex, + elementIndex, elementTextLength, textIndexFromElementOffset); + + SysTryReturn(NID_GRP + , pTextElement + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + r = __pCompositeText->ChangeTextOffset(pText, elementIndex, gap); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +TextObject::NotifyTextChanged(wchar_t* pText, int textOffset, int textLength, int gap) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + int startTextIndex = 0; + + r = __pCompositeText->NotifyTextChanged(pText, textOffset, textLength, gap, __pDefaultFont, + __defaultForegroundColor, __defaultBackgroundColor, __defaultOutlineColor); + + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , E_SYSTEM, "[E_SYSTEM] Fail to update change information."); + + startTextIndex = __pCompositeText->GetWorkStart(); + + if (__wrap != TEXT_OBJECT_WRAP_TYPE_NONE) + { + if (gap > 0) + { + NotifyTextAdded(startTextIndex, gap); + if (gap == 1) + { + InputText(startTextIndex); + } + } + else if (gap < 0) + { + NotifyTextDeleted(startTextIndex, -gap); + + if (gap == -1) + { + RemoveText(startTextIndex); + } + } + else + { + UpdateChangedInfo(startTextIndex, 0); + + ChangeText(startTextIndex); + } + } + else + { + UpdateChangedInfo(startTextIndex, 0); + } + + return E_SUCCESS; + +CATCH: + if (__pCompositeText->GetElementCount() == 0) + { + RemoveAll(); + TextSimple* pSimpleText = new (std::nothrow)TextSimple(pText, textLength, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + AppendElement(*pSimpleText); + + SetCursorIndex(0); + UpdateChangedInfo(0, 0); + } + + return E_SUCCESS; +} + +int +TextObject::GetTextIndexFromPosition(int lcX, int lcY, bool cursorMode) const +{ + IF_NOT_CONSTRUCTED(return -1); + + int lineCount = __pTextColumn->GetTotalLineCount(); + if (lineCount <= 0) + { + return -1; + } + + int pcX = _ResUtil::ConvertToPhyCoord(lcX); + int pcY = _ResUtil::ConvertToPhyCoord(lcY); + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) + { + return GetTextIndexFromPositionInNoneWrap(pcX, pcY, !cursorMode); + } + else + { + return GetTextIndexFromPositionInWrap(pcX, pcY, !cursorMode); + } +} + +int +TextObject::GetTextIndexFromPositionAtLine(int lineIndex, int lcX, bool cursorMode) const +{ + IF_NOT_CONSTRUCTED(return -1); + + SysTryReturn(NID_GRP + , lineIndex >= 0 + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex); + + TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + int pcX = _ResUtil::ConvertToPhyCoord(lcX); + int lineOffset = pTextLine->GetTextOffset(); + int lineLength = pTextLine->GetTextLength(); + int length = 0; + TextElementType objectType; + Rectangle lineBounds = pTextLine->GetBounds(); + Dimension lineTextSize; + pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height); + + switch (__align & TEXT_ALIGNMASK_HORIZ) + { + case TEXT_OBJECT_ALIGNMENT_LEFT: + break; + + case TEXT_OBJECT_ALIGNMENT_CENTER: + pcX -= (lineBounds.width - lineTextSize.width) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_RIGHT: + pcX -= (lineBounds.width - lineTextSize.width); + break; + } + + if (pcX < 0) + { + pcX = 0; + } + + __pCompositeText->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + + int endType = 0; + + if (cursorMode) + { + __pCompositeText->ForwardAnalyzeWithFocusedObjectType(lineOffset, lineLength, pcX, length, objectType); + } + else + { + endType = __pCompositeText->ForwardAnalyzeInNoneCursorMode(lineOffset, lineLength, pcX, length); + } + + __pCompositeText->SetWrap(__wrap); + + if (!cursorMode) + { + if (endType == -1) + { + return -1; + } + } + + int index = pTextLine->GetTextOffset() + length; + if (pTextLine->GetEndType() == TEXT_RETBY_LINEFEED && lineLength == length && pTextLine->GetTextOffset() < index) + { + index--; + } + + if (index != GetTextLength() && index == lineOffset + lineLength) + { + TextElement* pTextElement = GetElementAtTextIndex(index-1); + if (pTextElement != null) + { + const TextSimple* pSimpleText = dynamic_cast (pTextElement); + if (pSimpleText != null) + { + const wchar_t* pText = pSimpleText->GetText(); + SysTryReturn(NID_GRP + , pText + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text."); + + int i = index - 1 - pSimpleText->GetTextOffset(); + SysTryReturn(NID_GRP + , i >= 0 && i < pSimpleText->GetTextLength() + , -1, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",i, pSimpleText->GetTextLength()); + + if (pText[i] == L' ') + { + index--; + } + } + } + } + + SetLastResult(E_SUCCESS); + + return index; +} + +result +TextObject::SetFirstDisplayLineIndexFromTextIndex(int textIndex) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) + { + return SetFirstDisplayLineIndexFromTextIndexInNoneWrap(textIndex); + } + else + { + return SetFirstDisplayLineIndexFromTextIndexInWrap(textIndex); + } +} + +result +TextObject::SetCutLinkViewMode(bool enable) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + if (__linkViewModeEnabled == enable) + { + return E_SUCCESS; + } + + __linkViewModeEnabled = enable; + return E_SUCCESS; +} + +int +TextObject::GetCutLinkIndexFromPositionData(int lcX, int lcY) const +{ + IF_NOT_CONSTRUCTED(return -1); + + result r = E_SUCCESS; + int lineCount = __pTextColumn->GetTotalLineCount(); + if (lineCount <= 0) + { + return -1; + } + + int textIndex = 0; + int pcX = _ResUtil::ConvertToPhyCoord(lcX); + int pcY = _ResUtil::ConvertToPhyCoord(lcY); + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) + { + textIndex = GetTextIndexFromPositionInNoneWrap(pcX, pcY, false); + } + else + { + textIndex = GetTextIndexFromPositionInWrap(pcX, pcY, false); + } + + if (textIndex < 0) + { + return -1; + } + + int width = 0; + int height = 0; + Point absPoint; + Point relPoint; + if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) + { + r = GetTextPositionInfoInNoneWrapAt(textIndex, width, height, absPoint.x, absPoint.y, relPoint.x, relPoint.y); + } + else + { + r = GetTextPositionInfoInWrapAt(textIndex, width, height, absPoint.x, absPoint.y, relPoint.x, relPoint.y); + } + SysTryReturn(NID_GRP + , r == E_SUCCESS + , -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + SysTryReturn(NID_GRP + , pcY + __pcRect.y >= relPoint.y + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text position information"); + + return __pCompositeText->GetCutLinkElementIndexAt(textIndex); +} + +TextElement* +TextObject::GetCutLinkElementAtCutLinkElementIndex(int linkIndex) const +{ + IF_NOT_CONSTRUCTED(return null); + + return __pCompositeText->GetCutLinkElementAtCutLinkElementIndex(linkIndex); +} + +result +TextObject::SetCutLinkColor(LinkType linkType, const Color& color, const Color& colorInSelect) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , LINK_TYPE_NONE < linkType && linkType < LINK_TYPE_MAX + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + switch (linkType) + { + case LINK_TYPE_URL: + __isUrlLinkColorDefined = true; + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_NORMAL] = color; + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_URL_SELECT] = colorInSelect; + break; + + case LINK_TYPE_EMAIL: + __isEmailLinkColorDefined = true; + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_NORMAL] = color; + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_EMAIL_SELECT] = colorInSelect; + break; + + case LINK_TYPE_TEL_NUM: + __isPhoneNumberLinkColorDefined = true; + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL] = color; + __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT] = colorInSelect; + break; + + default: + break; + } + + int totalCutlinkTextCount = __pCompositeText->GetCutLinkElementCount(); + for (int i = 0; i < totalCutlinkTextCount; i++) + { + TextCutLink* pCutlinkText = dynamic_cast < TextCutLink* >(__pCompositeText->GetCutLinkElementAtCutLinkElementIndex(i)); + SysTryReturn(NID_GRP + , pCutlinkText + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to convert to cutlink element."); + + if (pCutlinkText->GetCutLinkType() == linkType) + { + pCutlinkText->SetUserColor(color, colorInSelect); + } + } + + return E_SUCCESS; +} + +result +TextObject::ResetCutLinkColor(LinkType linkType) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , LINK_TYPE_NONE < linkType && linkType < LINK_TYPE_MAX + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + switch (linkType) + { + case LINK_TYPE_URL: + __isUrlLinkColorDefined = false; + break; + + case LINK_TYPE_EMAIL: + __isEmailLinkColorDefined = false; + break; + + case LINK_TYPE_TEL_NUM: + __isPhoneNumberLinkColorDefined = false; + break; + + default: + break; + } + + int totalCutlinkTextCount = __pCompositeText->GetCutLinkElementCount(); + for (int i = 0; i < totalCutlinkTextCount; i++) + { + TextCutLink* pCutlinkText = dynamic_cast < TextCutLink* >(__pCompositeText->GetCutLinkElementAtCutLinkElementIndex(i)); + SysTryReturn(NID_GRP + , pCutlinkText + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to convert to cutlink element."); + + if (pCutlinkText->GetCutLinkType() == linkType) + { + pCutlinkText->ResetUserColor(); + } + } + + return E_SUCCESS; +} + +result +TextObject::GetCutLinkBounds(int cutLinkIndex, Point& startPoint, Point& endPoint) const +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + int textIndex = 0; + int textLength = 0; + int width = 0; + int heigth = 0; + Point tempPoint; + + r = __pCompositeText->GetCutLinkObjectInfo(cutLinkIndex, textIndex, textLength); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) + { + r = GetTextPositionInfoInNoneWrapAt(textIndex, width, heigth, tempPoint.x, tempPoint.y, startPoint.x, startPoint.y); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetTextPositionInfoInNoneWrapAt(textIndex + textLength - 1, width, heigth, tempPoint.x, tempPoint.y, endPoint.x, endPoint.y); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = GetTextPositionInfoInWrapAt(textIndex, width, heigth, tempPoint.x, tempPoint.y, startPoint.x, startPoint.y); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetTextPositionInfoInWrapAt(textIndex + textLength - 1, width, heigth, tempPoint.x, tempPoint.y, endPoint.x, endPoint.y); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + endPoint.x = endPoint.x + width; + endPoint.y = endPoint.y + heigth; + + if (_ResUtil::NeedToConvertCoord()) + { + startPoint.x = _ResUtil::ConvertToVirCoord(startPoint.x); + startPoint.y = _ResUtil::ConvertToVirCoord(startPoint.y); + endPoint.x = _ResUtil::ConvertToVirCoord(endPoint.x); + endPoint.y = _ResUtil::ConvertToVirCoord(endPoint.y); + } + + return E_SUCCESS; + +CATCH: + startPoint.x = -1; + startPoint.y = -1; + endPoint.x = -1; + endPoint.y = -1; + + return r; +} + +result +TextObject::GetTextPositionInfoAt(int textIndex, int& width, int& height, int& absX, int& absY, int& logicalX, int& logicalY) const +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + int lineCount = __pTextColumn->GetTotalLineCount(); + + if (lineCount < 1) + { + _Font* pFont = _Font::GetInstance(*_FontImpl::GetInstance(*__pDefaultFont)); + SysTryReturn(NID_GRP + , pFont + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance."); + int maxHeight = TextUtility::GetFontMaxHeight(pFont); + + int posX = 0; + int posY = 0; + absX = 0; + absY = 0; + + if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) + { + switch (__align & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + posY += (__pcRect.height - maxHeight) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + posY += (__pcRect.height - maxHeight); + break; + } + logicalY = __pcRect.y + posY; + + switch (__align & TEXT_ALIGNMASK_HORIZ) + { + case TEXT_OBJECT_ALIGNMENT_LEFT: + break; + + case TEXT_OBJECT_ALIGNMENT_CENTER: + posX += __pcRect.width / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_RIGHT: + posX += __pcRect.width; + break; + } + logicalX = __pcRect.x + posX; + } + else + { + int lineHeight = maxHeight + __pCompositeText->GetLineSpace(); + TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment(); + switch (alignment & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + // fall through + default: + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + posY += (lineHeight - maxHeight) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + posY += lineHeight - maxHeight; + break; + } + + logicalX = __pcRect.x; + logicalY = posY + __pcRect.y; + } + + width = 0; + height = maxHeight; + absX = posX; + absY = posY; + } + else + { + if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE) + { + r = GetTextPositionInfoInNoneWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY); + } + else + { + r = GetTextPositionInfoInWrapAt(textIndex, width, height, absX, absY, logicalX, logicalY); + } + + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (_ResUtil::NeedToConvertCoord()) + { + width = _ResUtil::ConvertToVirCoord(width); + height = _ResUtil::ConvertToVirCoord(height); + absX = _ResUtil::ConvertToVirCoord(absX); + absY = _ResUtil::ConvertToVirCoord(absY); + logicalX = _ResUtil::ConvertToVirCoord(logicalX); + logicalY = _ResUtil::ConvertToVirCoord(logicalY); + } + + return E_SUCCESS; +} + +result +TextObject::SetTextObjectEllipsisType(TextObjectEllipsisType type) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , TEXT_OBJECT_ELLIPSIS_TYPE_INVALID < type && type < TEXT_OBJECT_ELLIPSIS_TYPE_MAX + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + __textObjectEllipsisType = type; + __pCompositeText->SetTextObjectEllipsisType(type); + + return E_SUCCESS; +} + +result +TextObject::NotifyTextAdded(int textIndex, int textLength) +{ + result r = E_SUCCESS; + + r = __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_INSERT, textIndex, textLength); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if ((__pCompositeText->IsWidthManagerEnabled() == true) && (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD)) + { + __pTextWidthManager->InformTextInsert(textIndex, textLength); + } + + __isChanged = true; + + return E_SUCCESS; +} + +result +TextObject::NotifyTextDeleted(int textIndex, int textLength) +{ + result r = E_SUCCESS; + + r = __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_REMOVE, textIndex, textLength); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if ((__pCompositeText->IsWidthManagerEnabled() == true) && (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD)) + { + if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD) + { + __pTextWidthManager->InformTextRemove(textIndex, textLength); + } + } + __isChanged = true; + + return E_SUCCESS; +} + +result +TextObject::DrawByLine(_CanvasImpl& canvasImpl, const Rectangle& displayRect) +{ + Rectangle targetBounds = displayRect; + + return __pTextColumn->Draw(canvasImpl, targetBounds, 0, __pTextColumn->GetTextLength(), __align, __action); +} + +int +TextObject::GetTextIndexFromPositionInWrap(int pcX, int pcY, bool cursorMode) const +{ + TextLine* pTextLine = null; + Rectangle lineBounds; + int firstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex(); + int firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionY(); + int lineCount = __pTextColumn->GetTotalLineCount(); + int lineIndex = 0; + TextElementType objectType; + + int totalHeight = __pTextColumn->GetTotalHeight(); + + switch (__align & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + pcY -= (__pcRect.height - totalHeight) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + pcY -= (__pcRect.height - totalHeight); + break; + } + + for (lineIndex = firstDisplayLineIndex; lineIndex < lineCount; lineIndex++) + { + pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineBounds = pTextLine->GetBounds(); + + if (lineIndex == firstDisplayLineIndex) + { + if (pcY < lineBounds.y - firstDisplayPositionY) + { + return -1; + } + } + + if ((lineBounds.y - firstDisplayPositionY <= pcY) && (pcY < lineBounds.y + lineBounds.height - firstDisplayPositionY)) + { + break; + } + + if (lineIndex == lineCount - 1) + { + if (cursorMode) + { + return pTextLine->GetTextLength() + pTextLine->GetTextOffset(); + } + else + { + return -1; + } + } + } + + SysTryReturn(NID_GRP + , pTextLine + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + int lineOffset = pTextLine->GetTextOffset(); + int lineLength = pTextLine->GetTextLength(); + int length = 0; + Dimension lineTextSize; + pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height); + + switch (__align & TEXT_ALIGNMASK_HORIZ) + { + case TEXT_OBJECT_ALIGNMENT_LEFT: + break; + + case TEXT_OBJECT_ALIGNMENT_CENTER: + pcX -= (lineBounds.width - lineTextSize.width) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_RIGHT: + pcX -= (lineBounds.width - lineTextSize.width); + break; + } + + if (pcX < 0) + { + pcX = 0; + } + + __pCompositeText->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + + int endType = 0; + + if (cursorMode) + { + __pCompositeText->ForwardAnalyzeWithFocusedObjectType(lineOffset, lineLength, pcX, length, objectType); + } + else + { + endType = __pCompositeText->ForwardAnalyzeInNoneCursorMode(lineOffset, lineLength, pcX, length); + } + + __pCompositeText->SetWrap(__wrap); + + if (!cursorMode) + { + if (endType == -1) + { + return -1; + } + } + + int index = pTextLine->GetTextOffset() + length; + if (pTextLine->GetEndType() == TEXT_RETBY_LINEFEED && lineLength == length && pTextLine->GetTextOffset() < index) + { + index--; + } + + if (index != GetTextLength() && index == lineOffset + lineLength) + { + TextElement* pTextElement = GetElementAtTextIndex(index-1); + if (pTextElement != null) + { + const TextSimple* pSimpleText = dynamic_cast (pTextElement); + if (pSimpleText != null) + { + const wchar_t* pText = pSimpleText->GetText(); + SysTryReturn(NID_GRP + , pText + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text."); + + int i = index - 1 - pSimpleText->GetTextOffset(); + SysTryReturn(NID_GRP + , i >= 0 && i < pSimpleText->GetTextLength() + , -1, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",i, pSimpleText->GetTextLength()); + + if (pText[i] == L' ') + { + index--; + } + } + } + } + + SetLastResult(E_SUCCESS); + + return index; +} + +int +TextObject::GetTextIndexFromPositionInNoneWrap(int x, int y, bool cursorMode) const +{ + Dimension lineTextSize; + Rectangle lineBounds; + int lineOffset = 0; + int lineLength = 0; + TextLine* pTextLine = null; + + pTextLine = __pTextColumn->GetTextLine(0); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineOffset = pTextLine->GetTextOffset(); + lineLength = pTextLine->GetTextLength(); + lineBounds = pTextLine->GetBounds(); + pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height); + + switch (__align & TEXT_ALIGNMASK_HORIZ) + { + case TEXT_OBJECT_ALIGNMENT_LEFT: + break; + + case TEXT_OBJECT_ALIGNMENT_CENTER: + x -= (lineBounds.width - lineTextSize.width) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_RIGHT: + x -= (lineBounds.width - lineTextSize.width); + break; + } + + switch (__align & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + y -= (__pcRect.height - lineTextSize.height) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + y -= (__pcRect.height - lineTextSize.height); + break; + } + + if (x < 0) + { + x = 0; + } + + int length = 0; + TextElementType objectType = TEXT_ELEMENT_TYPE_TEXT; + + int endType = 0; + + if (cursorMode) + { + __pCompositeText->ForwardAnalyzeWithFocusedObjectType(lineOffset, lineLength, x, length, objectType); + } + else + { + endType = __pCompositeText->ForwardAnalyzeInNoneCursorMode(lineOffset, lineLength, x, length); + } + + if (!cursorMode) + { + if (endType == -1) + { + return -1; + } + } + + lineOffset = length + pTextLine->GetTextOffset(); + + SetLastResult(E_SUCCESS); + return lineOffset; +} + +result +TextObject::SetFirstDisplayLineIndexFromTextIndexInWrap(int textIndex) +{ + result r = E_SUCCESS; + Rectangle lineBounds; + int firstDisplayPositionY = 0; + int currentTextIndex = textIndex; + int firstDisplayLineIndex = 0; + int lineIndex = 0; + int lineCount = 0; + int remainingHeight = 0; + TextLine* pTextLine = null; + bool isChanged = false; + + lineCount = __pTextColumn->GetTotalLineCount(); + lineIndex = __pTextColumn->GetLineIndexAtTextIndex(currentTextIndex); + firstDisplayLineIndex = __pTextColumn->GetFirstDisplayLineIndex(); + + if (lineIndex == -1 && 0 < currentTextIndex && currentTextIndex == __pCompositeText->GetTextLength()) + { + currentTextIndex--; + lineIndex = __pTextColumn->GetLineIndexAtTextIndex(currentTextIndex); + } + + pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryReturn(NID_GRP + , pTextLine + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineBounds = pTextLine->GetBounds(); + + if (firstDisplayLineIndex < lineIndex) + { + TextLine* pTextLine = null; + int currentLineIndex = 0; + int displayLineCount = 0; + + currentLineIndex = firstDisplayLineIndex; + pTextLine = __pTextColumn->GetTextLine(currentLineIndex); + SysTryReturn(NID_GRP + , pTextLine + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + remainingHeight = __pcRect.height; + + while ((remainingHeight != 0) && firstDisplayLineIndex < lineCount) + { + if (remainingHeight < 0) + { + break; + } + + lineBounds = pTextLine->GetBounds(); + + remainingHeight -= lineBounds.height; + + displayLineCount++; + currentLineIndex++; + + pTextLine = __pTextColumn->GetTextLine(currentLineIndex); + if (pTextLine == null) + { + break; + } + } + + if (lineIndex < firstDisplayLineIndex + displayLineCount) + { + if (0 < remainingHeight && 0 < firstDisplayLineIndex) + { + pTextLine = __pTextColumn->GetTextLine(firstDisplayLineIndex - 1); + SysTryReturn(NID_GRP + , pTextLine + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + while (remainingHeight && pTextLine) + { + lineBounds = pTextLine->GetBounds(); + remainingHeight -= lineBounds.height; + + if (remainingHeight < 0) + { + firstDisplayPositionY = lineBounds.y + remainingHeight; + displayLineCount++; + firstDisplayLineIndex--; + break; + } + else + { + firstDisplayPositionY = lineBounds.y; + } + + displayLineCount++; + firstDisplayLineIndex--; + + pTextLine = __pTextColumn->GetTextLine(firstDisplayLineIndex - 1); + } + + isChanged = true; + } + else if (remainingHeight < 0 && (lineIndex == firstDisplayLineIndex + displayLineCount - 1)) + { + pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryReturn(NID_GRP + , pTextLine + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineBounds = pTextLine->GetBounds(); + remainingHeight = __pcRect.height; + + firstDisplayLineIndex = lineIndex; + firstDisplayPositionY = lineBounds.y; + remainingHeight -= lineBounds.height; + + int currentLineIndex = lineIndex - 1; + pTextLine = __pTextColumn->GetTextLine(currentLineIndex); + + while ((pTextLine != null) && 0 < firstDisplayLineIndex && 0 < remainingHeight) + { + lineBounds = pTextLine->GetBounds(); + + if (remainingHeight < lineBounds.height) + { + firstDisplayLineIndex--; + firstDisplayPositionY = lineBounds.y + (lineBounds.height - remainingHeight); + break; + } + else + { + remainingHeight -= lineBounds.height; + firstDisplayLineIndex--; + firstDisplayPositionY = lineBounds.y; + currentLineIndex--; + pTextLine = __pTextColumn->GetTextLine(currentLineIndex); + } + } + isChanged = true; + } + } + else + { + pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryReturn(NID_GRP + , pTextLine + , r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineBounds = pTextLine->GetBounds(); + + remainingHeight = __pcRect.height; + + firstDisplayLineIndex = lineIndex; + firstDisplayPositionY = lineBounds.y; + remainingHeight -= lineBounds.height; + + int currentLineIndex = lineIndex - 1; + pTextLine = __pTextColumn->GetTextLine(currentLineIndex); + + while (pTextLine && 0 < firstDisplayLineIndex && 0 < remainingHeight) + { + lineBounds = pTextLine->GetBounds(); + + if (remainingHeight < lineBounds.height) + { + firstDisplayLineIndex--; + firstDisplayPositionY = lineBounds.y + (lineBounds.height - remainingHeight); + break; + } + else + { + remainingHeight -= lineBounds.height; + firstDisplayLineIndex--; + firstDisplayPositionY = lineBounds.y; + currentLineIndex--; + pTextLine = __pTextColumn->GetTextLine(currentLineIndex); + } + } + isChanged = true; + } + } + else + { + lineBounds = pTextLine->GetBounds(); + firstDisplayLineIndex = lineIndex; + firstDisplayPositionY = lineBounds.y; + isChanged = true; + } + + if (isChanged == true) + { + __pTextColumn->SetFirstDisplayLineIndex(firstDisplayLineIndex); + __pTextColumn->SetFirstDisplayPositionY(firstDisplayPositionY); + } + + return E_SUCCESS; +} + +result +TextObject::SetFirstDisplayLineIndexFromTextIndexInNoneWrap(int textIndex) +{ + result r = E_SUCCESS; + int currentTextIndex = textIndex; + int lineOffset = 0; + int lineEndIndex = 0; + int lineLength = 0; + Rectangle lineBounds; + Dimension lineTextSize; + + _Font* pFont = _Font::GetInstance(*_FontImpl::GetInstance(*__pDefaultFont)); + SysTryReturn(NID_GRP + , pFont + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance."); + + TextLine* pTextLine = __pTextColumn->GetTextLine(0); + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineOffset = pTextLine->GetTextOffset(); + lineLength = pTextLine->GetTextLength(); + lineEndIndex = pTextLine->GetTextOffset() + pTextLine->GetTextLength(); + + lineBounds = pTextLine->GetBounds(); + pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height); + + if (currentTextIndex < pTextLine->GetTextOffset() + 1) + { + lineOffset = currentTextIndex; + pTextLine->SetTextOffset(lineOffset); + lineOffset = pTextLine->GetTextOffset(); + if (lineOffset > 0) + { + lineOffset--; + pTextLine->SetTextOffset(lineOffset); + } + + __pCompositeText->ForwardAnalyze(lineOffset, __pCompositeText->GetTextLength() - lineOffset, lineBounds.width, + __wrap, lineLength, lineTextSize.width, lineTextSize.height); + + lineBounds.height = Math::Max(lineBounds.height, lineTextSize.height); + if (lineBounds.height == 0) + { + lineBounds.height = TextUtility::GetFontMaxHeight(pFont); + } + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(lineTextSize.width, lineTextSize.height); + pTextLine->SetTextLength(lineLength); + + } + else if (lineEndIndex <= currentTextIndex) + { + int gapWidth = 0; + int gapHeight = 0; + int textCount = 0; + int tempWidth = 0; + + r = __pCompositeText->GetRegion(lineEndIndex, currentTextIndex - lineEndIndex, gapWidth, gapHeight); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + gapWidth -= lineBounds.width - lineTextSize.width; + + __pCompositeText->ForwardAnalyze(lineOffset, __pCompositeText->GetTextLength() - lineOffset, gapWidth, __wrap, + textCount, tempWidth, gapHeight); + + if (tempWidth < gapWidth) + { + lineOffset += (textCount + 1); + } + else + { + lineOffset += textCount; + } + + __pCompositeText->ForwardAnalyze(lineOffset, __pCompositeText->GetTextLength() - lineOffset, lineBounds.width, + __wrap, lineLength, lineTextSize.width, lineTextSize.height); + + lineBounds.height = Math::Max(lineBounds.height, lineTextSize.height); + if (lineBounds.height == 0) + { + lineBounds.height = TextUtility::GetFontMaxHeight(pFont); + } + + pTextLine->SetBounds(lineBounds); + pTextLine->SetRegion(lineTextSize.width, lineTextSize.height); + pTextLine->SetTextOffset(lineOffset); + pTextLine->SetTextLength(lineLength); + } + + __pTextColumn->SetFirstDisplayLineIndex(0); + __pTextColumn->SetFirstDisplayPositionY(0); + + return E_SUCCESS; +} + +result +TextObject::GetTextPositionInfoInWrapAt(int textIndex, int& width, int& height, int& absX, int& absY, + int& logicalX, int& logicalY) const +{ + TextLine* pTextLine = null; + Rectangle lineBounds; + + int firstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionY(); + int lineCount = __pTextColumn->GetTotalLineCount(); + int lineIndex = 0; + int lineOffset = 0; + int lineLength = 0; + int textIndexFromLineOffset = 0; + int lineY = 0; + int posX = 0; + int posY = 0; + + _Font* pFont = _Font::GetInstance(*_FontImpl::GetInstance(*__pDefaultFont)); + SysTryReturn(NID_GRP + , pFont + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance."); + + for (lineIndex = 0; lineIndex < lineCount; lineIndex++) + { + pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineBounds = pTextLine->GetBounds(); + lineOffset = pTextLine->GetTextOffset(); + lineLength = pTextLine->GetTextLength(); + + if (lineOffset <= textIndex && textIndex < lineOffset + lineLength) + { + break; + } + + if (lineIndex + 1 < lineCount) + { + lineY += lineBounds.height; + } + } + + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + if (lineIndex == lineCount) + { + textIndexFromLineOffset = lineLength; + } + else + { + textIndexFromLineOffset = textIndex - lineOffset; + } + + Dimension lineTextSize; + pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height); + + if (lineTextSize.height == 0) + { + lineTextSize.height = TextUtility::GetFontMaxHeight(pFont); + } + + switch (__align & TEXT_ALIGNMASK_HORIZ) + { + case TEXT_OBJECT_ALIGNMENT_LEFT: + break; + + case TEXT_OBJECT_ALIGNMENT_CENTER: + posX += (lineBounds.width - lineTextSize.width) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_RIGHT: + posX += (lineBounds.width - lineTextSize.width); + break; + } + + switch (__align & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + posY += (__pcRect.height - __pTextColumn->GetDisplayHeight()) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + posY += (__pcRect.height - __pTextColumn->GetDisplayHeight()); + break; + } + + if (posX < 0) + { + posX = 0; + } + + if (posY < 0) + { + posY = 0; + } + + int length = 0; + int tempWidth = 0; + int tempHeight = 0; + + __pCompositeText->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + + if (0 < textIndexFromLineOffset) + { + __pCompositeText->ForwardAnalyze(lineOffset, textIndexFromLineOffset, lineTextSize.width, TEXT_OBJECT_WRAP_TYPE_NONE, + length, tempWidth, tempHeight); + + posX += tempWidth; + } + + if (textIndex >= 1) + { + Font* pTextFont = __pCompositeText->GetFont(textIndex - 1); + tempHeight = TextUtility::GetFontMaxHeight(pTextFont); + } + + if (lineIndex == lineCount) + { + tempWidth = 0; + } + + __pCompositeText->SetWrap(__wrap); + + if (tempHeight == 0) + { + tempHeight = TextUtility::GetFontMaxHeight(pFont); + } + + TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment(); + switch (alignment & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + // fall through + default: + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + lineY = lineY + (lineBounds.height - tempHeight) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + lineY = lineY + (lineBounds.height - tempHeight); + break; + } + + width = tempWidth; + height = tempHeight; + absX = posX; + absY = lineY; + logicalY = lineY - firstDisplayPositionY + __pcRect.y + posY; + logicalX = posX + __pcRect.x; + + return E_SUCCESS; +} + +result +TextObject::GetTextPositionInfoInNoneWrapAt(int textIndex, int& width, int& height, int& absX, int& absY, + int& logicalX, int& logicalY) const +{ + TextLine* pTextLine = null; + pTextLine = __pTextColumn->GetTextLine(0); + SysTryReturn(NID_GRP + , pTextLine + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + int lineOffset = pTextLine->GetTextOffset(); + int lineLength = pTextLine->GetTextLength(); + int posX = 0; + int posY = 0; + int displaposYX = 0; + int length = 0; + int tempWidth = 0; + int tempHeight = 0; + + _Font* pFont = _Font::GetInstance(*_FontImpl::GetInstance(*__pDefaultFont)); + SysTryReturn(NID_GRP + , pFont + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance."); + + Dimension lineTextSize; + Rectangle lineBounds; + lineBounds = pTextLine->GetBounds(); + pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height); + + if (lineTextSize.height == 0 || pTextLine->GetTextLength() == 0) + { + lineTextSize.height = TextUtility::GetFontMaxHeight(pFont); + } + + switch (__align & TEXT_ALIGNMASK_HORIZ) + { + case TEXT_OBJECT_ALIGNMENT_LEFT: + break; + + case TEXT_OBJECT_ALIGNMENT_CENTER: + posX += (lineBounds.width - lineTextSize.width) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_RIGHT: + posX += (lineBounds.width - lineTextSize.width); + break; + } + + switch (__align & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + posY += (__pcRect.height - lineTextSize.height) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + posY += (__pcRect.height - lineTextSize.height); + break; + } + + if (posX < 0) + { + posX = 0; + } + if (posY < 0) + { + posY = 0; + } + + if (lineOffset > 0) + { + int tempHeight = 0; + __pCompositeText->ForwardAnalyze(0, lineOffset, Integer::VALUE_MAX, __wrap, length, displaposYX, tempHeight); + } + else + { + displaposYX = 0; + } + + if (textIndex >= __pCompositeText->GetTextLength()) + { + __pCompositeText->ForwardAnalyze(0, __pCompositeText->GetTextLength(), 0x00ffffff, __wrap, length, tempWidth, tempHeight); + + absX = tempWidth; + logicalX = tempWidth - displaposYX + __pcRect.x + posX; + + __pCompositeText->ForwardAnalyze(textIndex - 1, 1, 0x00ffffff, __wrap, length, tempWidth, tempHeight); + + TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment(); + switch (alignment & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + // fall through + default: + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + posY = posY + (lineBounds.height - tempHeight) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + posY = posY + (lineBounds.height - tempHeight); + break; + } + + width = 0; + height = tempHeight; + absY = posY; + logicalY = __pcRect.y + posY; + } + else + { + __pCompositeText->ForwardAnalyze(0, textIndex, 0x00ffffff, __wrap, length, tempWidth, tempHeight); + + absX = tempWidth; + absY = posY; + logicalX = tempWidth - displaposYX + __pcRect.x + posX; + + __pCompositeText->ForwardAnalyze(textIndex - 1, 1, 0x00ffffff, __wrap, length, tempWidth, tempHeight); + + if (textIndex == __pCompositeText->GetTextLength()) + { + tempWidth = 0; + } + + if (tempHeight == 0) + { + tempHeight = TextUtility::GetFontMaxHeight(pFont); + } + + TextObjectAlignment alignment = __pCompositeText->GetElementVerticalAlignment(); + switch (alignment & TEXT_ALIGNMASK_VERT) + { + case TEXT_OBJECT_ALIGNMENT_TOP: + // fall through + default: + break; + + case TEXT_OBJECT_ALIGNMENT_MIDDLE: + posY = posY + (lineBounds.height - tempHeight) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_BOTTOM: + posY = posY + (lineBounds.height - tempHeight); + break; + } + + logicalY = __pcRect.y + posY; + width = tempWidth; + height = tempHeight; + } + + return E_SUCCESS; +} + +int +TextObject::GetTotalComposedHeight(void) const +{ + return __pCompositeText->GetTotalComposedHeight(); +} + +int +TextObject::GetLineWidthAt(int lineIndex) const +{ + IF_NOT_CONSTRUCTED(return -1); + + result r = E_SUCCESS; + TextLine* pTextLine = null; + Dimension lineTextSize; + int lineLength = 0; + int pcWidth = 0; + int lcWidth = 0; + + pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryCatch(NID_GRP + , pTextLine + , , E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + lineLength = pTextLine->GetTextLength(); + r = pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pcWidth = lineTextSize.width; + lcWidth = _ResUtil::ConvertToVirCoord(pcWidth); + + SetLastResult(E_SUCCESS); + return lcWidth; + +CATCH: + return -1; +} + +int +TextObject::GetTotalHeight(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + int pcHeight = 0; + if (IsPartialComposingModeEnabled()) + { + pcHeight = __pCompositeText->GetAnalysedTotalHeight(); + } + else + { + pcHeight = __pTextColumn->GetTotalHeight(); + } + + int lcHeight = _ResUtil::ConvertToVirCoord(pcHeight); + + return lcHeight; +} + +int +TextObject::GetElementIndexOf(TextElement& textElement) const +{ + IF_NOT_CONSTRUCTED(return -1); + + return __pCompositeText->GetElementIndexOf(textElement); +} + +result +TextObject::RemoveElementAt(int elementIndex, bool deallocate) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + return __pCompositeText->RemoveElementAt(elementIndex, deallocate); +} + +result +TextObject::HideFrontSpace(TextObjectSpaceHideType mode) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + __pCompositeText->HideFrontSpace(mode); + + return E_SUCCESS; +} + +result +TextObject::HideRearSpace(TextObjectSpaceHideType mode) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + __pCompositeText->HideRearSpace(mode); + + return E_SUCCESS; +} + +int +TextObject::GetSlidingStep(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + int lcSlidingStep = _ResUtil::ConvertToVirCoord(__slidingStep); + + return lcSlidingStep; +} + +result +TextObject::SetSlidingStep(int lcSlidingStep) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + int pcSlidingStep = _ResUtil::ConvertToPhyCoord(lcSlidingStep); + + __slidingStep = pcSlidingStep; + + return E_SUCCESS; +} + +int +TextObject::GetTotalLineCount(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + return __pTextColumn->GetTotalLineCount(); +} + +int +TextObject::GetLineIndexAtTextIndex(int textIndex) const +{ + IF_NOT_CONSTRUCTED(return -1); + + return __pTextColumn->GetLineIndexAtTextIndex(textIndex); +} + +int +TextObject::GetLineHeightAt(int lineIndex) const +{ + IF_NOT_CONSTRUCTED(return -1); + + SysTryReturn(NID_GRP + , lineIndex >= 0 + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex); + + int pcHeight = __pTextColumn->GetLineHeightAt(lineIndex); + int lcHeight = _ResUtil::ConvertToVirCoord(pcHeight); + + return lcHeight; +} + +int +TextObject::GetDisplayLineCount(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + return __pTextColumn->GetDisplayLineCount(); +} + +int +TextObject::GetFirstDisplayLineIndex(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + return __pTextColumn->GetFirstDisplayLineIndex(); +} + +int +TextObject::GetFirstDisplayPositionY(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + int pcFirstDisplayPositionY = __pTextColumn->GetFirstDisplayPositionY(); + int lcFirstDisplayPositionY = _ResUtil::ConvertToVirCoord(pcFirstDisplayPositionY); + + return lcFirstDisplayPositionY; +} + +int +TextObject::GetLineIndexAtPositionY(int lcY) const +{ + IF_NOT_CONSTRUCTED(return -1); + + int pcY = _ResUtil::ConvertToPhyCoord(lcY); + + return __pTextColumn->GetLineIndexAtPositionY(pcY); +} + +int +TextObject::GetFirstTextIndexAt(int lineIndex) const +{ + IF_NOT_CONSTRUCTED(return -1); + + SysTryReturn(NID_GRP + , lineIndex >= 0 + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex); + + return __pTextColumn->GetFirstTextIndexAt(lineIndex); +} + +int +TextObject::GetTextLengthAt(int lineIndex) const +{ + IF_NOT_CONSTRUCTED(return -1); + + SysTryReturn(NID_GRP + , lineIndex >= 0 + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex); + + return __pTextColumn->GetTextLengthAt(lineIndex); +} + +Rectangle +TextObject::GetBounds(void) const +{ + IF_NOT_CONSTRUCTED(return Rectangle(0,0,0,0)); + + return __rect; +} + +int +TextObject::GetLineSpace(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + int pcLineSpacing = __pCompositeText->GetLineSpace(); + int lcLineSpacing = _ResUtil::ConvertToVirCoord(pcLineSpacing); + + return lcLineSpacing; +} + +int +TextObject::GetTextLength(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + return __pCompositeText->GetTextLength(); +} + +TextObjectAlignment +TextObject::GetElementVerticalAlignment(void) const +{ + IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ALIGNMENT_INVALID); + + return __pCompositeText->GetElementVerticalAlignment(); +} + +TextObjectActionType +TextObject::GetAction(void) const +{ + IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ACTION_TYPE_NONE); + + return __action; +} + +TextObjectAlignment +TextObject::GetAlignment(void) const +{ + IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ALIGNMENT_INVALID); + + return __align; +} + +int +TextObject::GetElementCount(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + return __pCompositeText->GetElementCount(); +} + +TextElement* +TextObject::GetElementAtElementIndex(int elementIndex) const +{ + IF_NOT_CONSTRUCTED(return null); + + return __pCompositeText->GetElementAtElementIndex(elementIndex); +} + +result +TextObject::SetRange(int startTextIndex, int textLength) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + return __pCompositeText->SetRange(startTextIndex, textLength); +} + +void +TextObject::GetRange(int& startTextIndex, int& textLength) const +{ + IF_NOT_CONSTRUCTED(return); + + return __pCompositeText->GetRange(startTextIndex, textLength); +} + +TextObjectWrapType +TextObject::GetWrap(void) const +{ + IF_NOT_CONSTRUCTED(return TEXT_OBJECT_WRAP_TYPE_NONE); + + return __wrap; +} + +result +TextObject::SetCursorIndex(int cursorIndex) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , cursorIndex >= 0 + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + __pCompositeText->SetCursorIndex(cursorIndex); + + return E_SUCCESS; +} + +int +TextObject::GetCursorIndex(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + return __pCompositeText->GetCursorIndex(); +} + +result +TextObject::SetBlock(bool enable) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + __pCompositeText->SetBlock(enable); + + return E_SUCCESS; +} + +bool +TextObject::GetBlock(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + return __pCompositeText->GetBlock(); +} + +result +TextObject::SetBlockRange(int startTextIndex, int textLength) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + result r = E_SUCCESS; + r = __pCompositeText->SetRange(startTextIndex, textLength); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +TextObject::GetBlockRange(int& startTextIndex, int& textLength) +{ + IF_NOT_CONSTRUCTED(return); + + __pCompositeText->GetRange(startTextIndex, textLength); +} + +bool +TextObject::IsAlternateLookEnabled(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + return __isAlternateLookEnabled; +} + +int +TextObject::GetTotalCutLinkElementCount(void) const +{ + IF_NOT_CONSTRUCTED(return -1); + + return __pCompositeText->GetCutLinkElementCount(); +} + +result +TextObject::ChangeCutLinkState(int linkIndex, bool select) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + return __pCompositeText->ChangeCutLinkState(linkIndex, select); +} + +result +TextObject::ResetAllCutLinkElementsState(void) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + return __pCompositeText->ResetAllCutLinkElementsState(); +} + +bool +TextObject::IsActionOn(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + return __isActionOn; +} + +TextObjectEllipsisType +TextObject::GetTextObjectEllipsisType(void) const +{ + IF_NOT_CONSTRUCTED(return TEXT_OBJECT_ELLIPSIS_TYPE_INVALID); + + return __textObjectEllipsisType; +} + +result +TextObject::SetWidthManagerEnabled(bool enable) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + if (__pCompositeText->IsWidthManagerEnabled() == enable) + { + return E_SUCCESS; + } + + if (enable) + { + __pTextWidthManager = new (std::nothrow)TextWidthManager(__pCompositeText); + SysTryReturn(NID_GRP + , __pTextWidthManager + , E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + __pCompositeText->SetTextWidthManager(__pTextWidthManager); + __pTextWidthManager->Initialize(__pCompositeText->GetTextLength()); + } + else + { + if (__pTextWidthManager) + { + delete __pTextWidthManager; + __pTextWidthManager = null; + } + } + + __pCompositeText->SetWidthManagerEnabled(enable); + + return E_SUCCESS; +} + +bool +TextObject::IsWidthManagerEnabled(void) const +{ + IF_NOT_CONSTRUCTED(return false); + + return __pCompositeText->IsWidthManagerEnabled(); +} + +result +TextObject::ChangeText(int textIndex) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + if (__sweepInfo.isValid) + { + __sweepInfo.isValid = false; + return E_INVALID_STATE; + } + + __sweepInfo.isValid = true; + __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_REPLACE; + __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_INSERT; + __sweepInfo.anchorTextIndex = textIndex; + __sweepInfo.sweepRegionStartLineIndex = GetLineIndexAtTextIndex(textIndex); + __sweepInfo.sweepRegionLineCount = 1; + __sweepInfo.anchorLineIndex = __sweepInfo.sweepRegionStartLineIndex; + __sweepInfo.widthChanged = 0; + + __pCompositeText->SetTextSweepInfo(&__sweepInfo); + + return E_SUCCESS; +} + +result +TextObject::InputText(int textIndex) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + if (__sweepInfo.isValid == true) + { + __sweepInfo.isValid = false; + return E_INVALID_STATE; + } + + __sweepInfo.isValid = true; + __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_KEYINPUT; + __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_INSERT; + __sweepInfo.anchorTextIndex = textIndex; + __sweepInfo.prevAnchorLineIndex = GetLineIndexAtTextIndex(textIndex); + + if (__sweepInfo.prevAnchorLineIndex == -1) + { + __sweepInfo.prevAnchorLineIndex = __pTextColumn->GetTotalLineCount()-1; + } + + __pCompositeText->SetTextSweepInfo(&__sweepInfo); + + return E_SUCCESS; +} + +result +TextObject::RemoveText(int textIndex) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + if (__sweepInfo.isValid == true) + { + __sweepInfo.isValid = false; + return E_INVALID_STATE; + } + + __sweepInfo.isValid = true; + __sweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_REMOVE; + __sweepInfo.anchorTextIndex = textIndex; + __sweepInfo.prevAnchorLineIndex = GetLineIndexAtTextIndex(textIndex); + + if (__sweepInfo.prevAnchorLineIndex == -1) + { + __sweepInfo.prevAnchorLineIndex = __pTextColumn->GetTotalLineCount()-1; + } + + __pCompositeText->SetTextSweepInfo(&__sweepInfo); + + return E_SUCCESS; +} + +result +TextObject::ResetSweepInfo(void) +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + __sweepInfo.isValid = false; + + return E_SUCCESS; +} + +TextObjectSweepInfo +TextObject::GetSweepInfo(void) const +{ + TextObjectSweepInfo textSweepInfo; + textSweepInfo.isValid = false; + textSweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_NONE; + textSweepInfo.sweepEventType = TEXT_OBJECT_SWEEP_EVENT_NONE; + textSweepInfo.anchorTextIndex = -1; + textSweepInfo.anchorLineIndex = -1; + textSweepInfo.prevAnchorLineIndex = -1; + textSweepInfo.sweepRegionStartLineIndex = -1; + textSweepInfo.sweepRegionLineCount = -1; + textSweepInfo.insertedLineCount = -1; + textSweepInfo.deletedLineCount = -1; + textSweepInfo.widthChanged = -1; + + IF_NOT_CONSTRUCTED(return textSweepInfo); + + textSweepInfo.isValid = __sweepInfo.isValid; + textSweepInfo.sweepType = __sweepInfo.sweepType; + textSweepInfo.sweepEventType = __sweepInfo.sweepEventType; + textSweepInfo.anchorTextIndex = __sweepInfo.anchorTextIndex; + textSweepInfo.anchorLineIndex = __sweepInfo.anchorLineIndex; + textSweepInfo.prevAnchorLineIndex = __sweepInfo.prevAnchorLineIndex; + textSweepInfo.sweepRegionStartLineIndex = __sweepInfo.sweepRegionStartLineIndex; + textSweepInfo.sweepRegionLineCount = __sweepInfo.sweepRegionLineCount; + textSweepInfo.insertedLineCount = __sweepInfo.insertedLineCount; + textSweepInfo.deletedLineCount = __sweepInfo.deletedLineCount; + textSweepInfo.widthChanged = __sweepInfo.widthChanged; + + return textSweepInfo; +} + +result +TextObject::GetSweepComposeLineInfo(int lineIndex, TextObjectSweepComposeLineInfo& textSweepComposeLineInfo) const +{ + IF_NOT_CONSTRUCTED(return E_INVALID_STATE); + + SysTryReturn(NID_GRP + , lineIndex >= 0 + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex); + + TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryReturn(NID_GRP + , pTextLine + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex); + + textSweepComposeLineInfo = pTextLine->GetSweepComposeInfo(); + + return E_SUCCESS; +} + +int +TextObject::GetTextOffsetAtLine(int lineIndex) const +{ + IF_NOT_CONSTRUCTED(return -1); + + SysTryReturn(NID_GRP + , lineIndex >= 0 + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex); + + TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + return pTextLine->GetTextOffset(); +} + +int +TextObject::GetTextLengthAtLine(int lineIndex) const +{ + IF_NOT_CONSTRUCTED(return -1); + + SysTryReturn(NID_GRP + , lineIndex >= 0 + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex); + + TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryReturn(NID_GRP + , pTextLine + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + return pTextLine->GetTextLength(); +} + +Rectangle +TextObject::GetBoundsAtLine(int lineIndex) const +{ + IF_NOT_CONSTRUCTED(return Rectangle(-1, -1, -1, -1)); + + SysTryReturn(NID_GRP + , lineIndex >= 0 + , Rectangle(-1, -1, -1, -1), E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex); + + TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryReturn(NID_GRP + , pTextLine + , Rectangle(-1, -1, -1, -1), E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + Rectangle lineBounds = pTextLine->GetBounds(); + + return lineBounds; +} + +Point +TextObject::GetDisplayPositionAtLine(int lineIndex, int textIndexFromLineOffset) +{ + IF_NOT_CONSTRUCTED(return Point(-1, -1)); + + SysTryReturn(NID_GRP + , lineIndex >= 0 + , Point(-1, -1), E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lineIndex = %d)", lineIndex); + + TextLine* pTextLine = __pTextColumn->GetTextLine(lineIndex); + SysTryReturn(NID_GRP + , pTextLine + , Point(-1, -1), E_SYSTEM, "[E_SYSTEM] Fail to get text line."); + + int lineOffset = pTextLine->GetTextOffset(); + int lineLength = pTextLine->GetTextLength(); + Dimension lineTextSize; + Dimension extentDim; + int textCount = 0; + Rectangle lineBounds; + + pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height); + lineBounds = pTextLine->GetBounds(); + + __pCompositeText->ForwardAnalyze(lineOffset, textIndexFromLineOffset, lineTextSize.width, + __wrap, textCount, extentDim.width, extentDim.height); + + switch (__align & TEXT_ALIGNMASK_HORIZ) + { + case TEXT_OBJECT_ALIGNMENT_LEFT: + break; + + case TEXT_OBJECT_ALIGNMENT_CENTER: + extentDim.width += (lineBounds.width - lineTextSize.width) / 2; + break; + + case TEXT_OBJECT_ALIGNMENT_RIGHT: + extentDim.width += (lineBounds.width - lineTextSize.width); + break; + } + + if (extentDim.width < 0) + { + extentDim.width = 0; + } + + return Point(extentDim.width + __rect.x, lineBounds.y - __pTextColumn->GetFirstDisplayPositionY() + __rect.y); +} + +}}} // Tizen::Graphics::_Text + diff --git a/src/graphics/text/FGrp_TextTextSimple.cpp b/src/graphics/text/FGrp_TextTextSimple.cpp new file mode 100644 index 0000000..a097c99 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextSimple.cpp @@ -0,0 +1,1345 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextSimple.cpp + * @brief This is the implementation file for TextSimple class. + */ + +#include +#include +#include +#include "FGrp_CanvasImpl.h" +#include "FGrp_BitmapImpl.h" +#include "FGrp_TextTextSimple.h" +#include "FGrp_TextTextUtility.h" +#include "FGrp_FontImpl.h" +#include "../FGrp_BitmapUtil.h" +#include "../FGrp_Font.h" +#include "../FGrp_Canvas.h" + +namespace // unnamed +{ + const int DEFAULT_FONT_SIZE = 42; + const int LINE_FEED_WIDTH = 8; +} + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +TextSimple::TextSimple(const wchar_t* pText, int length, TextElementSourceType sourceType, Font* pFont, + const Color& foregroundColor, const Color& backgroundColor, const Color& outlineColor) + : TextElement() +{ + _type = TEXT_ELEMENT_TYPE_TEXT; + _sourceType = sourceType; + _hasFocus = false; + _isAlternateLookEnabled = false; + + if (pFont != null) + { + _pFont = _FontImpl::CloneN(const_cast (*pFont)); + } + else + { + _pFont = new (std::nothrow) Font(); + _pFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE); + } + + _foregroundColor = foregroundColor; + _backgroundColor = backgroundColor; + _outlineColor = outlineColor; + _outline = false; + + if (sourceType == TEXT_ELEMENT_SOURCE_TYPE_INTERNAL) + { + wchar_t* pTempText = new (std::nothrow) wchar_t[length + 1]; + if (pTempText) + { + int test = (int) _pText; + test = test & 0x03; + + TextUtility::CopyText(pTempText, pText, length); + pTempText[length] = 0; + + _pText = pTempText; + } + } + else + { + _pText = pText; + } + + _offset = 0; + _length = length; + _isBackgroundDrawingModeEnabled = false; + _userWrap = TEXT_OBJECT_WRAP_TYPE_WORD; + __pBitmap = null; +} + +TextSimple::~TextSimple(void) +{ + if (_sourceType == TEXT_ELEMENT_SOURCE_TYPE_INTERNAL) + { + if (_pText) + { + delete[] _pText; + _pText = null; + } + } + + if (__pBitmap) + { + delete __pBitmap; + __pBitmap = null; + } + + if (_pFont) + { + delete _pFont; + _pFont = null; + } +} + +int +TextSimple::ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, int& actualLength, + int& width, int& height) +{ + int charCount = 0; + int r = TEXT_RETBY_NORMAL; + + if (textLength > _length) + { + textLength = _length; + } + + if (textLength == 0) + { + actualLength = textLength; + width = 0; + height = 0; + + return TEXT_RETBY_NORMAL; + } + + if (__pBitmap) + { + int bitmapWidth = __pBitmap->GetWidth(); + int bitmapHeight = __pBitmap->GetHeight(); + + if (maxWidth < bitmapWidth) + { + actualLength = 0; + width = 0; + height = 0; + + return TEXT_RETBY_OVERWIDTH; + } + else + { + actualLength = _length; + width = bitmapWidth; + height = bitmapHeight; + + return TEXT_RETBY_NORMAL; + } + } + + Font* pCurrentFont = GetCurrentFont(); + _Font* pFont = _Font::GetInstance(*_FontImpl::GetInstance(*pCurrentFont)); + SysTryReturn(NID_GRP + , pFont + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance."); + + const wchar_t* pText = &_pText[startTextIndex]; + + switch (wrap) + { + case TEXT_OBJECT_WRAP_TYPE_NONE: + { + if (_userWrap == TEXT_OBJECT_WRAP_TYPE_NONE) + { + wchar_t* pModifiedText = new (std::nothrow) wchar_t[textLength + 1]; + SysTryReturn(NID_GRP + , pModifiedText + , -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + int length = ConvertEnterToSpace(pModifiedText, pText, textLength); + pModifiedText[length] = 0; + + actualLength = TextUtility::GetCharCountInWidth(pFont, pModifiedText, length, maxWidth, _outline, width, height); + + charCount = textLength; + r = TEXT_RETBY_NORMAL; + + delete[] pModifiedText; + pModifiedText = null; + } + else + { + actualLength = TextUtility::GetCharCountInWidth(pFont, pText, textLength, maxWidth, _outline, width, height); + charCount = textLength; + r = TEXT_RETBY_NORMAL; + } + } + break; + + case TEXT_OBJECT_WRAP_TYPE_CHARACTER: + r = GetSentenceLength(pText, textLength, charCount); + actualLength = TextUtility::GetCharCountInWidth(pFont, pText, charCount, maxWidth, _outline, width, height); + if (_pText[startTextIndex + actualLength] == TEXT_LINE_FEED || + _pText[startTextIndex + actualLength] == TEXT_CARRIAGE_RETURN) + { + (actualLength)++; + r = TEXT_RETBY_LINEFEED; + } + break; + + case TEXT_OBJECT_WRAP_TYPE_WORD: + actualLength = TextUtility::GetCharCountInWidth(pFont, pText, textLength, maxWidth, _outline, width, height); + int widthcheck = width; + + if (_pText[startTextIndex + actualLength] == TEXT_LINE_FEED || _pText[startTextIndex + actualLength] == TEXT_CARRIAGE_RETURN) + { + actualLength++; + r = TEXT_RETBY_LINEFEED; + } + else if (textLength == actualLength) + { + r = TEXT_RETBY_LIMITLENGTH; + } + else if (actualLength == 0) + { + charCount = 0; + r = TEXT_RETBY_LIMITWIDTH; + } + else + { + r = GetWordWrapLengthEx(pText, actualLength, charCount); + + if (charCount < actualLength) + { + if (charCount == 0) + { + r = TEXT_RETBY_LIMITWIDTH; + } + else + { + r = TEXT_RETBY_NORMAL; + } + } + + if (charCount != 0) + { + if (charCount > (actualLength / 2)) + { + const wchar_t* pExtraText = &_pText[startTextIndex + charCount]; + int overCharCount = TextUtility::GetCharCountInWidth(pFont, pExtraText, actualLength - charCount, maxWidth, _outline, width, height); + actualLength = actualLength - overCharCount; + width = widthcheck - width; + } + else + { + actualLength = TextUtility::GetCharCountInWidth(pFont, pText, charCount, maxWidth, _outline, width, height); + } + + actualLength = charCount; + } + } + + break; + } + + if (height == 0 && (textLength > 0)) + { + height = pFont->GetLeading(); + } + + if (actualLength < charCount) + { + r = TEXT_RETBY_LIMITWIDTH; + } + + return r; +} + +bool +TextSimple::IsKorean(const wchar_t* ch) const +{ + if (0xAC00 <= *ch && *ch <= 0xD7A3) + { + return true; + } + + if (0x3130 <= *ch && *ch <= 0x318F) + { + return true; + } + + if (0x1100 <= *ch && *ch <= 0x11FF) + { + return true; + } + + return false; +} + +bool +TextSimple::IsChinese(const wchar_t* ch) const +{ + if (0X2E80 <= *ch && *ch <= 0x2FFF) + { + return true; + } + + else if (0x3220 <= *ch && *ch <= 0x3243) + { + return true; + } + + else if (0x3280 <= *ch && *ch <= 0x32CB) + { + return true; + } + + else if (0x3400 <= *ch && *ch <= 0x4DBF) + { + return true; + } + + else if (0x4E00 <= *ch && *ch <= 0x9FFF) + { + return true; + } + + else if (0xF900 <= *ch && *ch <= 0xFAFF) + { + return true; + } + + return false; +} + +result +TextSimple::GetRegion(int textIndex, int textLength, int& width, int& height) const +{ + const wchar_t* pText = null; + Font* pCurrentFont = GetCurrentFont(); + SysTryReturn(NID_GRP + , pCurrentFont + , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not line wrapped yet."); + + _Font* pFont = _Font::GetInstance(*_FontImpl::GetInstance(*pCurrentFont)); + SysTryReturn(NID_GRP + , pFont + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance."); + + if (textLength > _length) + { + textLength = _length; + } + + if (textLength == 0) + { + width = 0; + height = 0; + + return E_SUCCESS; + } + + if (__pBitmap) + { + width = __pBitmap->GetWidth(); + height = __pBitmap->GetHeight(); + + return E_SUCCESS; + } + + pText = &_pText[textIndex]; + + switch (_userWrap) + { + case TEXT_OBJECT_WRAP_TYPE_NONE: + { + wchar_t* pModifiedText = new (std::nothrow) wchar_t[textLength + 1]; + SysTryReturn(NID_GRP + , pModifiedText + , E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + int length = ConvertEnterToSpace(pModifiedText, pText, textLength); + pModifiedText[textLength] = 0; + + TextUtility::GetTextExtent(pFont, pModifiedText, length, _outline, width, height); + + delete[] pModifiedText; + pModifiedText = null; + } + break; + + case TEXT_OBJECT_WRAP_TYPE_CHARACTER: + // fall through + case TEXT_OBJECT_WRAP_TYPE_WORD: + TextUtility::GetTextExtent(pFont, pText, textLength, _outline, width, height); + break; + } + + if (height == 0 && (textLength > 0)) + { + height = pFont->GetLeading(); + } + + return E_SUCCESS; +} + +result +TextSimple::GetBlockRegion(int textIndex, int textLength, int& width, int& height) const +{ + const wchar_t* pText = null; + Font* pCurrentFont = GetCurrentFont(); + SysTryReturn(NID_GRP + , pCurrentFont + , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not line wrapped yet."); + + _Font* pFont = _Font::GetInstance(*_FontImpl::GetInstance(*pCurrentFont)); + SysTryReturn(NID_GRP + , pFont + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance."); + + if (textLength > _length) + { + textLength = _length; + } + + if (textLength == 0) + { + width = 0; + height = 0; + + return E_SUCCESS; + } + + if (__pBitmap) + { + width = __pBitmap->GetWidth(); + height = __pBitmap->GetHeight(); + + return E_SUCCESS; + } + + pText = &_pText[textIndex]; + + switch (_userWrap) + { + case TEXT_OBJECT_WRAP_TYPE_NONE: + { + wchar_t* pModifiedText = new (std::nothrow) wchar_t[textLength + 1]; + SysTryReturn(NID_GRP + , pModifiedText + , E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + int length = ConvertEnterToSpace(pModifiedText, pText, textLength); + pModifiedText[textLength] = 0; + + TextUtility::GetTextExtent(pFont, pModifiedText, length, _outline, width, height); + + delete[] pModifiedText; + pModifiedText = null; + } + break; + + case TEXT_OBJECT_WRAP_TYPE_CHARACTER: + // fall through + case TEXT_OBJECT_WRAP_TYPE_WORD: + TextUtility::GetTextExtent(pFont, pText, textLength, _outline, width, height); + + if (pText[textLength-1] == TEXT_LINE_FEED || pText[textLength-1] == TEXT_CARRIAGE_RETURN) + { + width += LINE_FEED_WIDTH; + } + break; + } + + if (height == 0 && (textLength > 0)) + { + height = pFont->GetLeading(); + } + + return E_SUCCESS; +} + +int +TextSimple::GetHeight(void) const +{ + Font* pFont = GetCurrentFont(); + SysTryReturn(NID_GRP + , pFont + , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not line wrapped yet."); + + int maxHeight = 0; + + if (__pBitmap) + { + maxHeight = __pBitmap->GetHeight(); + } + else + { + maxHeight = TextUtility::GetFontMaxHeight(pFont); + } + + return maxHeight; +} + +result +TextSimple::Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, + const TextObjectAlignment align, const TextObjectActionType action) +{ + SysTryReturn(NID_GRP + , textLength <= _length + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + if (textLength == 0) + { + return E_SUCCESS; + } + + result r = E_SUCCESS; + _Canvas* pCanvas = _Canvas::GetInstance(canvasImpl); + SysTryReturn(NID_GRP + , pCanvas + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native canvas instance."); + + if (__pBitmap) + { + r = pCanvas->DrawBitmap(Point(displayRect.x, displayRect.y), *GetBitmapEx(*_BitmapImpl::GetInstance(*__pBitmap))); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; + } + + Color foregroundColor = GetCurrentForegroundColor(); + pCanvas->SetForegroundColor(foregroundColor); + + Color backgroundColor = GetCurrentBackgroundColor(); + pCanvas->SetBackgroundColor(backgroundColor); + + Color outlineColor = GetCurrentOutlineColor(); + + Font* pCurrentFont = GetCurrentFont(); + SysTryReturn(NID_GRP + , pCurrentFont + , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not line wrapped yet."); + + _Font* pFont = _Font::GetInstance(*_FontImpl::GetInstance(*pCurrentFont)); + SysTryReturn(NID_GRP + , pFont + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance."); + + r = pCanvas->SetPriorityFont(*pFont); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (_userWrap != TEXT_OBJECT_WRAP_TYPE_NONE) + { + if (_outline) + { + return TextUtility::DrawOutlineText(*pCanvas, displayRect.x, displayRect.y, &_pText[startTextIndex], textLength, outlineColor); + } + else + { + return TextUtility::DrawText(*pCanvas, displayRect.x, displayRect.y, &_pText[startTextIndex], textLength); + } + } + else + { + wchar_t* pModifiedText = new (std::nothrow) wchar_t[textLength + 1]; + SysTryReturn(NID_GRP + , pModifiedText + , E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + int length = ConvertEnterToSpace(pModifiedText, &_pText[startTextIndex], textLength); + pModifiedText[length] = 0; + + if (_outline) + { + TextUtility::DrawOutlineText(*pCanvas, displayRect.x, displayRect.y, pModifiedText, length, outlineColor); + } + else + { + TextUtility::DrawText(*pCanvas, displayRect.x, displayRect.y, pModifiedText, length); + } + + delete[] pModifiedText; + pModifiedText = null; + + return E_SUCCESS; + } + + return E_SUCCESS; +} + +TextElement* +TextSimple::CloneN(TextComponentInfoValueType type, unsigned int value) +{ + TextSimple* pSimpleTextElement = null; + + pSimpleTextElement = new (std::nothrow) TextSimple(_pText, _length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, _pFont, + _foregroundColor, _backgroundColor, _outlineColor); + + SysTryReturn(NID_GRP + , pSimpleTextElement + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + TextElement::CopyMembers(pSimpleTextElement); + + pSimpleTextElement->SetValue(SET_TEXT_OFFSET, _offset); + pSimpleTextElement->SetValue(SET_ALTERNATE_LOOK, _isAlternateLookEnabled); + pSimpleTextElement->SetValue(type, value); + pSimpleTextElement->SetUserWrap(_userWrap); + + return pSimpleTextElement; +} + +TextElement* +TextSimple::CopyN(int startTextIndex, int textLength) +{ + const wchar_t* pText = null; + + TextSimple* pSimpleTextElement = null; + + if (startTextIndex >= _length) + { + return null; + } + + if (startTextIndex + textLength > _length) + { + textLength = _length - startTextIndex; + } + + if (textLength <= 0) + { + return null; + } + + pText = &_pText[_offset + startTextIndex]; + + pSimpleTextElement = new (std::nothrow) TextSimple(pText, textLength, _sourceType, _pFont, + _foregroundColor, _backgroundColor, _outlineColor); + + SysTryReturn(NID_GRP + , pSimpleTextElement + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pSimpleTextElement->_isBackgroundDrawingModeEnabled = _isBackgroundDrawingModeEnabled; + + return pSimpleTextElement; +} + +unsigned int +TextSimple::GetValue(TextComponentInfoValueType type) const +{ + switch (type) + { + case SET_FONT: + // fall through + return (unsigned int) _pFont; + + case SET_FONT_FGCOLOR: + // fall through + return (unsigned int) _foregroundColor.GetRGB32(); + + case SET_FONT_BGCOLOR: + // fall through + return (unsigned int) _backgroundColor.GetRGB32(); + + case SET_FONT_OUTLINECOLOR: + // fall through + return (unsigned int) _outlineColor.GetRGB32(); + + case SET_TEXT_OFFSET: + // fall through + return (unsigned int) _offset; + + case SET_ALTERNATE_LOOK: + // fall through + return (unsigned int) _isAlternateLookEnabled; + + case SET_ALTERNATIVE_FGCOLOR: + // fall through + return (unsigned int) GetAlternativeForegroundColor().GetRGB32(); + + default: + // fall through + return -1; + } + + return 0; +} + +result +TextSimple::SetValue(TextComponentInfoValueType type, unsigned int value) +{ + result r = E_SUCCESS; + Font* pFont = null; + + switch (type) + { + case SET_FONT: + { + if (!(Font*) value) + { + return E_INVALID_ARG; + } + + pFont = _FontImpl::CloneN(const_cast (*(Font*) value)); + r = GetLastResult(); + SysTryReturn(NID_GRP + , pFont + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (_pFont) + { + delete _pFont; + _pFont = null; + } + _pFont = pFont; + } + break; + + case SET_FONT_FGCOLOR: + _foregroundColor = Color(value); + break; + + case SET_FONT_BGCOLOR: + _backgroundColor = Color(value); + break; + + case SET_FONT_OUTLINECOLOR: + _outlineColor = Color(value); + break; + + case SET_TEXT_OFFSET: + _offset = (int) value; + break; + + case SET_ALLVALUE_CLONE: + break; + + case SET_ALTERNATE_LOOK: + _isAlternateLookEnabled = (bool) value; + break; + + case SET_ALTERNATIVE_FGCOLOR: + SetAlternativeForegroundColor(Color(value)); + break; + + default: + break; + } + + return E_SUCCESS; +} + +result +TextSimple::SetFont(const Font* pFont) +{ + SysTryReturn(NID_GRP + , pFont + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + Font* pTmpFont = null; + + pTmpFont = _FontImpl::CloneN(const_cast (*pFont)); + r = GetLastResult(); + SysTryReturn(NID_GRP + , pTmpFont + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (_pFont) + { + delete _pFont; + _pFont = null; + } + _pFont = pTmpFont; + + return E_SUCCESS; +} + +void +TextSimple::SetForegroundColor(const Color& color) +{ + _foregroundColor = color; +} + +void +TextSimple::SetBackgroundColor(const Color& color) +{ + _backgroundColor = color; +} + +void +TextSimple::SetOutlineColor(const Color& color) +{ + _outlineColor = color; + _outline = true; +} + +const Font* +TextSimple::GetFont(void) const +{ + return _pFont; +} + +Color +TextSimple::GetForegroundColor(void) const +{ + return _foregroundColor; +} + +Color +TextSimple::GetBackgroundColor(void) const +{ + return _backgroundColor; +} + +Color +TextSimple::GetOutlineColor(void) const +{ + return _outlineColor; +} + +result +TextSimple::SetTextOffset(int offset) +{ + SysTryReturn(NID_GRP + , offset >= 0 + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _offset = offset; + + return E_SUCCESS; +} + +int +TextSimple::GetTextOffset(void) const +{ + return _offset; +} + +const wchar_t* +TextSimple::GetTextSource(void) const +{ + return _pText; +} + +const wchar_t* +TextSimple::GetText(void) const +{ + return &_pText[_offset]; +} + +bool +TextSimple::IsSame(wchar_t* pText, Font* pFont, const Color& fgColor, + const Color& bgColor, const Color& outlineColor) +{ + if (_pText != pText) + { + return false; + } + + if (!TextUtility::IsSameFontAttribute(_pFont, pFont)) + { + return false; + } + + if (_foregroundColor != fgColor) + { + return false; + } + + if (_backgroundColor != bgColor) + { + return false; + } + + if (_outlineColor != outlineColor) + { + return false; + } + + return true; +} + +result +TextSimple::ChangeTextOffset(wchar_t* pText, int gap) +{ + SysTryReturn(NID_GRP + , _pText == pText + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _offset += gap; + + return E_SUCCESS; +} + +int +TextSimple::GetSentenceLength(const wchar_t* pText, int textLength, int& actualLength) const +{ + int length = 0; + + actualLength = 0; + length = textLength; + + if (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN) + { + wchar_t mch = *pText; + pText--; + + if (mch != *pText && (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN)) + { + actualLength++; + length++; + pText++; + } + + return TEXT_RETBY_LINEFEED; + } + else + { + while (length && (*pText != 0)) + { + actualLength++; + pText++; + length--; + + if (*pText == TEXT_LINE_FEED || *pText == TEXT_PARAGRAPH_SEPARATOR) + { + actualLength++; + pText++; + length--; + + if (*pText == TEXT_CARRIAGE_RETURN) + { + actualLength++; + pText++; + length--; + } + + return TEXT_RETBY_LINEFEED; + } + } + } + + if (length == 0) + { + return TEXT_RETBY_LIMITLENGTH; + } + + return TEXT_RETBY_NORMAL; +} + +int +TextSimple::GetWordWrapLength(const wchar_t* pText, int textLength, int& actualLength) const +{ + int length = textLength; + actualLength = 0; + + if (*pText == (wchar_t)L' ' || *pText == TEXT_OBJ_CHARACTER) + { + actualLength++; + return TEXT_RETBY_NORMAL; + } + else if (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN + || *pText == TEXT_PARAGRAPH_SEPARATOR) + { + wchar_t mch = *pText; + + actualLength++; + length--; + pText++; + + if (mch != *pText && (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN)) + { + actualLength++; + length--; + } + + return TEXT_RETBY_LINEFEED; + } + else + { + while (length && (*pText != 0)) + { + actualLength++; + length--; + pText++; + + if (*pText == (wchar_t)L' ' || *pText == TEXT_OBJ_CHARACTER) + { + return TEXT_RETBY_NORMAL; + } + else if (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN || *pText == TEXT_PARAGRAPH_SEPARATOR) + { + wchar_t mch = *pText; + + actualLength++; + length--; + pText++; + + if (mch != *pText && (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN)) + { + actualLength++; + length--; + } + + return TEXT_RETBY_LINEFEED; + } + } + } + + if (length == 0) + { + return TEXT_RETBY_LIMITLENGTH; + } + + return TEXT_RETBY_NORMAL; +} + +int +TextSimple::GetWordWrapLengthEx(const wchar_t* pText, int textLength, int& actualLength) const +{ + for (int i = 0; i < textLength; i++) + { + pText++; + } + + int length = textLength; + actualLength = textLength; + + const wchar_t* pLastCharacter = pText - 1; + if (*pLastCharacter == TEXT_LINE_FEED || *pLastCharacter == TEXT_CARRIAGE_RETURN) + { + return TEXT_RETBY_LINEFEED; + } + else if (*pLastCharacter == (wchar_t)L' ' || *pLastCharacter == TEXT_OBJ_CHARACTER) + { + return TEXT_RETBY_NORMAL; + } + + if (*pText == TEXT_OBJ_CHARACTER) + { + return TEXT_RETBY_NORMAL; + } + else if (*pText == (wchar_t)L' ') + { + actualLength--; + length--; + pText--; + } + else if (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN) + { + wchar_t mch = *pText; + pText--; + + if (mch != *pText && (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN)) + { + actualLength++; + length++; + pText++; + } + + return TEXT_RETBY_LINEFEED; + } + else if (IsChinese(pText)) + { + return TEXT_RETBY_NORMAL; + } + + while ((length >= 0) && (*pText != 0)) + { + if (*pText == (wchar_t)L' ' || *pText == TEXT_OBJ_CHARACTER) + { + actualLength++; + length++; + pText++; + + return TEXT_RETBY_NORMAL; + } + else if (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN) + { + wchar_t mch = *pText; + + actualLength++; + length++; + pText++; + + if (mch != *pText && (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN)) + { + actualLength++; + length++; + pText++; + } + + return TEXT_RETBY_LINEFEED; + } + + actualLength--; + length--; + pText--; + } + + if (actualLength < 0) + { + actualLength = 0; + } + + if (actualLength == 0) + { + return TEXT_RETBY_LIMITLENGTH; + } + + return TEXT_RETBY_NORMAL; +} + +Font* +TextSimple::GetCurrentFont(void) const +{ + return _pFont; +} + +Color +TextSimple::GetCurrentForegroundColor(void) const +{ + const TextSimple* pSimpleTextElement = null; + pSimpleTextElement = this; + + if (_isAlternateLookEnabled) + { + return pSimpleTextElement->GetAlternativeForegroundColor(); + } + else + { + return _foregroundColor; + } +} + +void +TextSimple::SetBackGroundDrawingModeEnabled(bool enable) +{ + _isBackgroundDrawingModeEnabled = enable; +} + +bool +TextSimple::IsBackGroundDrawingModeEnable(void) const +{ + return _isBackgroundDrawingModeEnabled; +} + +int +TextSimple::ConvertEnterToSpace(wchar_t* pDstText, const wchar_t* pSrcText, int textLength) +{ + int length = 0; + int i = 0; + + for (i = 0; i < textLength; ) + { + if (*pSrcText == TEXT_LINE_FEED) + { + *pDstText = (wchar_t)L' '; + length++; + pDstText++; + pSrcText++; + i++; + } + else if (*pSrcText == TEXT_CARRIAGE_RETURN) + { + if (*(pSrcText + 1) == TEXT_LINE_FEED) + { + *pDstText = (wchar_t)L' '; + length++; + pDstText++; + pSrcText += 2; + i += 2; + } + else + { + *pDstText = (wchar_t)L' '; + length++; + pDstText++; + pSrcText++; + i++; + } + } + else + { + *pDstText = *pSrcText; + length++; + + pDstText++; + pSrcText++; + i++; + } + } + + return length; +} + +void +TextSimple::SetUserWrap(TextObjectWrapType userWrap) +{ + _userWrap = userWrap; +} + +Color +TextSimple::GetCurrentBackgroundColor(void) const +{ + return _backgroundColor; +} + +Color +TextSimple::GetCurrentOutlineColor(void) const +{ + return _outlineColor; +} + +int +TextSimple::GetWordLength(int textIndex, int& wordLength) const +{ + int length = 0; + const wchar_t* pText = &_pText[textIndex]; + + length = GetTextOffset() + _length - textIndex; + if (length == 0) + { + return WORD_ERROR; + } + + if (*pText == (wchar_t)L' ') + { + wordLength = 1; + return WORD_SPACE; + } + else if (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN + || *pText == TEXT_PARAGRAPH_SEPARATOR) + { + if (length == 1) + { + wordLength = 1; + return WORD_ENTER; + } + + wchar_t mch = *pText; + pText++; + + if (mch != *pText && (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN)) + { + wordLength = 2; + return WORD_ENTER; + } + + wordLength = 1; + return WORD_ENTER; + } + else + { + wordLength = 1; + length--; + pText++; + + while (length && (*pText != 0)) + { + if (*pText == (wchar_t)L' ') + { + return WORD_WORD; + } + else if (*pText == TEXT_LINE_FEED || *pText == TEXT_CARRIAGE_RETURN + || *pText == TEXT_PARAGRAPH_SEPARATOR) + { + return WORD_WORD; + } + + length--; + pText++; + wordLength++; + } + + return WORD_WORD; + } + + return WORD_ERROR; +} + +result +TextSimple::SetBitmap(const Bitmap& bitmap) +{ + result r = E_SUCCESS; + + Bitmap* pBitmap = new (std::nothrow) Bitmap(); + SysTryReturn(NID_GRP + , pBitmap + , E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = pBitmap->Construct(bitmap, Rectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight())); + if (r != E_SUCCESS) + { + delete pBitmap; + SysLog(NID_GRP, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + } + + if (__pBitmap) + { + delete __pBitmap; + __pBitmap = null; + } + + __pBitmap = pBitmap; + + return E_SUCCESS; +} + +const Bitmap* +TextSimple::GetBitmap(void) const +{ + return __pBitmap; +} + +int +TextSimple::GetBaseline(void) const +{ + Font* pCurrentFont = GetCurrentFont(); + SysTryReturn(NID_GRP + , pCurrentFont + , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not line wrapped yet."); + + _Font* pFont = _Font::GetInstance(*_FontImpl::GetInstance(*pCurrentFont)); + SysTryReturn(NID_GRP + , pFont + , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance."); + + return (-1) * pFont->GetDescender(); +} + +}}} // Tizen::Graphics::_Text diff --git a/src/graphics/text/FGrp_TextTextSimpleList.cpp b/src/graphics/text/FGrp_TextTextSimpleList.cpp new file mode 100644 index 0000000..edcffa1 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextSimpleList.cpp @@ -0,0 +1,562 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextSimpleList.cpp + * @brief This is the implementation file for TextSimpleList class. + */ + +#include +#include +#include "FGrp_TextTextSimpleList.h" +#include "FGrp_TextCommon.h" + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ +SimpleList* +TextSimpleList::Create(void) +{ + SimpleList* pSimpleList = null; + + pSimpleList = new (std::nothrow) SimpleList; + + return pSimpleList; +} + +bool +TextSimpleList::Destory(SimpleList* pSimpleList) +{ + DeleteAllObject(pSimpleList); + + delete pSimpleList; + pSimpleList = null; + + return true; +} + +bool +TextSimpleList::Init(SimpleList* pSimpleList) +{ + SysTryReturn(NID_GRP + , pSimpleList + , false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + pSimpleList->pHeaderNode = null; + pSimpleList->pTailNode = null; + pSimpleList->nodeCount = 0; + + return true; +} + +SimpleNode* +TextSimpleList::InsertObject(SimpleList* pSimpleList, void* pObject, int index) +{ + SysTryReturn(NID_GRP + , pSimpleList + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pNode = null; + SimpleNode* pNextNode = null; + + if (index < 1) + { + return AddObject(pSimpleList, pObject); + } + + if (index >= pSimpleList->nodeCount) + { + return AppendObject(pSimpleList, pObject); + } + + pNode = new (std::nothrow) SimpleNode; + if (pNode == null) + { + return null; + } + + pNode->pObject = pObject; + + SimpleNode* pPrevNode = GetNthNode(pSimpleList, index - 1); + SysTryCatch(NID_GRP + , pPrevNode + , , E_SYSTEM, "[E_SYSTEM] Fail to get node."); + + pNextNode = pPrevNode->pNext; + SysTryCatch(NID_GRP + , pNextNode + , , E_SYSTEM, "[E_SYSTEM] Fail to get node."); + + pNode->pNext = pNextNode; + pPrevNode->pNext = pNode; + + pNode->pPrev = pPrevNode; + pNextNode->pPrev = pNode; + + pSimpleList->nodeCount++; + + return pNode; + +CATCH: + delete pNode; + pNode = null; + + return null; +} + +bool +TextSimpleList::IsEmpty(SimpleList* pSimpleList) +{ + SysTryReturn(NID_GRP + , pSimpleList + , false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + bool r = false; + + if (pSimpleList->nodeCount == 0) + { + r = true; + } + + return r; +} + +int +TextSimpleList::GetCount(SimpleList* pSimpleList) +{ + SysTryReturn(NID_GRP + , pSimpleList + , false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return pSimpleList->nodeCount; +} + +SimpleNode* +TextSimpleList::AddObject(SimpleList* pSimpleList, void* pObject) +{ + SysTryReturn(NID_GRP + , pSimpleList + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pNode = null; + pNode = new (std::nothrow) SimpleNode; + if (pNode == null) + { + return null; + } + + pNode->pObject = pObject; + + if (pSimpleList->pHeaderNode != null) + { + pNode->pNext = pSimpleList->pHeaderNode; + pNode->pPrev = null; + pSimpleList->pHeaderNode->pPrev = pNode; + pSimpleList->pHeaderNode = pNode; + } + else + { + pSimpleList->pHeaderNode = pNode; + pSimpleList->pTailNode = pNode; + pNode->pNext = null; + pNode->pPrev = null; + } + + pSimpleList->nodeCount++; + + return pNode; +} + +SimpleNode* +TextSimpleList::AppendObject(SimpleList* pSimpleList, void* pObject) +{ + SysTryReturn(NID_GRP + , pSimpleList + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pNode = null; + pNode = new (std::nothrow) SimpleNode; + if (pNode == null) + { + return null; + } + + pNode->pObject = pObject; + + if (pSimpleList->pHeaderNode != null) + { + SimpleNode* pPrevNode = pSimpleList->pTailNode; + + pPrevNode->pNext = pNode; + pNode->pNext = null; + pNode->pPrev = pPrevNode; + pSimpleList->pTailNode = pNode; + } + else + { + pSimpleList->pHeaderNode = pNode; + pSimpleList->pTailNode = pNode; + pNode->pNext = null; + pNode->pPrev = null; + } + + pSimpleList->nodeCount++; + + return pNode; +} + +SimpleNode* +TextSimpleList::GetFirstNode(SimpleList* pSimpleList) +{ + SysTryReturn(NID_GRP + , pSimpleList + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return pSimpleList->pHeaderNode; +} + +SimpleNode* +TextSimpleList::GetLastNode(SimpleList* pSimpleList) +{ + SysTryReturn(NID_GRP + , pSimpleList + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return pSimpleList->pTailNode; +} + +bool +TextSimpleList::DeleteNode(SimpleList* pSimpleList, SimpleNode* pNode) +{ + SysTryReturn(NID_GRP + , pSimpleList + , false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pPrevNode = null; + + if (pSimpleList->pHeaderNode == pNode) + { + if (pSimpleList->pTailNode == pNode) + { + pSimpleList->pHeaderNode = null; + pSimpleList->pTailNode = null; + } + else + { + pSimpleList->pHeaderNode = pSimpleList->pHeaderNode->pNext; + if (pSimpleList->pHeaderNode != null) + { + pSimpleList->pHeaderNode->pPrev = null; + } + } + } + else if (pSimpleList->pTailNode == pNode) + { + pSimpleList->pTailNode = pSimpleList->pTailNode->pPrev; + pSimpleList->pTailNode->pNext = null; + } + else + { + pPrevNode = pSimpleList->pHeaderNode; + while (pPrevNode && pPrevNode->pNext != pNode) + { + pPrevNode = pPrevNode->pNext; + } + + if (!pPrevNode) + { + return false; + } + + pPrevNode->pNext = pNode->pNext; + + if (pPrevNode->pNext != null) + { + pPrevNode->pNext->pPrev = pPrevNode; + } + } + + delete pNode; + pNode = null; + pSimpleList->nodeCount--; + + return true; +} + +SimpleNode* +TextSimpleList::GetNthNode(SimpleList* pSimpleList, int index) +{ + SysTryReturn(NID_GRP + , pSimpleList + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pNode = null; + int n = 0; + + if (index < 0) + { + return null; + } + + pNode = pSimpleList->pHeaderNode; + while (pNode && n < index) + { + pNode = pNode->pNext; + n++; + } + + return pNode; +} + +void* +TextSimpleList::DeleteNthObject(SimpleList* pSimpleList, int index) +{ + SysTryReturn(NID_GRP + , pSimpleList + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pNode = null; + void* pObject = null; + + if (pSimpleList->nodeCount == 0) + { + return null; + } + + pNode = GetNthNode(pSimpleList, index); + if (!pNode) + { + return null; + } + + pObject = pNode->pObject; + + if (pSimpleList->pHeaderNode == pNode) + { + if (pSimpleList->pTailNode == pNode) + { + pSimpleList->pHeaderNode = null; + pSimpleList->pTailNode = null; + } + else + { + pSimpleList->pHeaderNode = pSimpleList->pHeaderNode->pNext; + if (pSimpleList->pHeaderNode != null) + { + pSimpleList->pHeaderNode->pPrev = null; + } + } + } + else if (pSimpleList->pTailNode == pNode) + { + pSimpleList->pTailNode = pSimpleList->pTailNode->pPrev; + pSimpleList->pTailNode->pNext = null; + } + else + { + SimpleNode* pPrevNode = null; + + pPrevNode = pNode->pPrev; + pPrevNode->pNext = pNode->pNext; + if (pPrevNode->pNext != null) + { + pPrevNode->pNext->pPrev = pPrevNode; + } + } + + delete pNode; + pNode = null; + pSimpleList->nodeCount--; + + return pObject; +} + +bool +TextSimpleList::DeleteAllObject(SimpleList* pSimpleList) +{ + SysTryReturn(NID_GRP + , pSimpleList + , false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pNode = null; + SimpleNode* pNextNode = null; + void* pObject = null; + + if (pSimpleList->nodeCount <= 0) + { + return false; + } + + pNode = pSimpleList->pHeaderNode; + + while (pNode != null) + { + pNextNode = pNode->pNext; + pObject = pNode->pObject; + free(pObject); + delete pNode; + pNode = null; + + pNode = pNextNode; + } + + pSimpleList->nodeCount = 0; + pSimpleList->pHeaderNode = null; + pSimpleList->pTailNode = null; + + return true; +} + +void* +TextSimpleList::GetFirstObject(SimpleList* pSimpleList) +{ + SysTryReturn(NID_GRP + , pSimpleList + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pNode = null; + + pNode = GetFirstNode(pSimpleList); + + SysTryReturn(NID_GRP + , pNode + , false, E_SYSTEM, "[E_SYSTEM] Fail to get first node."); + + return pNode->pObject; +} + +void* +TextSimpleList::GetNthObject(SimpleList* pSimpleList, int index) +{ + if (pSimpleList->nodeCount == 0) + { + return null; + } + + SysTryReturn(NID_GRP + , pSimpleList && index >= 0 && index < pSimpleList->nodeCount + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pNode = null; + + pNode = GetNthNode(pSimpleList, index); + + SysTryReturn(NID_GRP + , pNode + , false, E_SYSTEM, "[E_SYSTEM] Fail to get Nth Node."); + + return pNode->pObject; +} + +int +TextSimpleList::GetObjectIndex(SimpleList* pSimpleList, void* pObject) +{ + SysTryReturn(NID_GRP + , pSimpleList + , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pNode = null; + int index = 0; + + pNode = pSimpleList->pHeaderNode; + while (pNode) + { + if (pNode->pObject == pObject) + { + return index; + } + + index++; + pNode = pNode->pNext; + } + + return -1; +} + +SimpleNode* +TextSimpleList::InsertObjectAfterNode(SimpleList* pSimpleList, SimpleNode* pSimpleNode, void* pObject) +{ + SysTryReturn(NID_GRP + , pSimpleList + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pNode = null; + pNode = new (std::nothrow) SimpleNode; + if (pNode == null) + { + return null; + } + + pNode->pObject = pObject; + + pNode->pNext = pSimpleNode->pNext; + if (pSimpleNode->pNext != null) + { + pSimpleNode->pNext->pPrev = pNode; + } + + pSimpleNode->pNext = pNode; + pNode->pPrev = pSimpleNode; + + if (pSimpleList->pTailNode == pSimpleNode) + { + pSimpleList->pTailNode = pNode; + } + + pSimpleList->nodeCount++; + + return pNode; +} + +SimpleNode* +TextSimpleList::InsertObjectBeforeNode(SimpleList* pSimpleList, SimpleNode* pSimpleNode, void* pObject) +{ + SysTryReturn(NID_GRP + , pSimpleList + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SimpleNode* pNode = null; + pNode = new (std::nothrow) SimpleNode; + if (pNode == null) + { + return null; + } + + pNode->pObject = pObject; + + if (pSimpleNode->pPrev == null) + { + pNode->pPrev = null; + pNode->pNext = pSimpleNode; + pSimpleNode->pPrev = pNode; + pSimpleList->pHeaderNode = pNode; + } + else + { + pNode->pNext = pSimpleNode; + pSimpleNode->pPrev->pNext = pNode; + pNode->pPrev = pSimpleNode->pPrev; + pSimpleNode->pPrev = pNode; + } + + pSimpleList->nodeCount++; + return pNode; +} + +}}} // Tizen::Graphics::_Text diff --git a/src/graphics/text/FGrp_TextTextSimpleList.h b/src/graphics/text/FGrp_TextTextSimpleList.h new file mode 100644 index 0000000..760514f --- /dev/null +++ b/src/graphics/text/FGrp_TextTextSimpleList.h @@ -0,0 +1,92 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextSimpleList.h + * @brief This is the header file for the TextSimpleList class. + * + * This header file contains the declarations of the %TextSimpleList class. + */ + +#ifndef _FGRP_INTERNAL_TEXT_SIMPLE_LIST_H_ +#define _FGRP_INTERNAL_TEXT_SIMPLE_LIST_H_ + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ +struct SimpleNode +{ + struct SimpleNode* pNext; + struct SimpleNode* pPrev; + void* pObject; +}; + +struct SimpleList +{ + SimpleNode* pHeaderNode; + SimpleNode* pTailNode; + int nodeCount; +}; + +class TextSimpleList +{ +public: + static SimpleList* Create(void); + + static bool Destory(SimpleList* pSimpleList); + + static bool Init(SimpleList* pSimpleList); + + static SimpleNode* InsertObject(SimpleList* pSimpleList, void* pObject, int index); + + static SimpleNode* AddObject(SimpleList* pSimpleList, void* pObject); + + static SimpleNode* AppendObject(SimpleList* pSimpleList, void* pObject); + + static bool DeleteNode(SimpleList* pSimpleList, SimpleNode* pNode); + + static void* DeleteNthObject(SimpleList* pSimpleList, int index); + + static bool DeleteAllObject(SimpleList* pSimpleList); + + static SimpleNode* InsertObjectAfterNode(SimpleList* pSimpleList, SimpleNode* pSimpleNode, void* pObject); + + static SimpleNode* InsertObjectBeforeNode(SimpleList* pSimpleList, SimpleNode* pSimpleNode, void* pObject); + + static int GetCount(SimpleList* pSimpleList); + + static SimpleNode* GetFirstNode(SimpleList* pSimpleList); + + static SimpleNode* GetLastNode(SimpleList* pSimpleList); + + static SimpleNode* GetNthNode(SimpleList* pSimpleList, int index); + + static void* GetFirstObject(SimpleList* pSimpleList); + + static void* GetNthObject(SimpleList* pSimpleList, int index); + + static int GetObjectIndex(SimpleList* pSimpleList, void* pObject); + + static bool IsEmpty(SimpleList* pSimpleList); + +}; // SimpleList + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_SIMPLE_LIST_H_ diff --git a/src/graphics/text/FGrp_TextTextUtility.cpp b/src/graphics/text/FGrp_TextTextUtility.cpp new file mode 100644 index 0000000..8823733 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextUtility.cpp @@ -0,0 +1,377 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextUtility.cpp + * @brief This is the implementation file for TextUtility class. + */ + +#include +#include +#include "../FGrp_Canvas.h" +#include "FGrp_FontImpl.h" +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextSimple.h" +#include "FGrp_TextTextUtility.h" + +using namespace Tizen::Base::Utility; +using namespace Tizen::Base; + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ +TextElementType +TextUtility::GetObjectTypeFromValueType(TextComponentInfoValueType type) +{ + if (type < MAX_TEXTOBJECT_VALUE) + { + return TEXT_ELEMENT_TYPE_TEXT; + } + else if (type < MAX_IMAGEOBJECT_VALUE) + { + return TEXT_ELEMENT_TYPE_IMAGE; + } + + return TEXT_ELEMENT_TYPE_MAX; +} + +bool +TextUtility::CanMerge(TextElement* pCurrentTextElement, TextElement* pNextTextElement) +{ + SysTryReturn(NID_GRP + , pCurrentTextElement && pCurrentTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT + , false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SysTryReturn(NID_GRP + , pNextTextElement && pNextTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT + , false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + TextSimple* pCurrentSimpleText = dynamic_cast < TextSimple* >(pCurrentTextElement); + TextSimple* pNextSimpleText = dynamic_cast < TextSimple* >(pNextTextElement); + if (pCurrentSimpleText == null || pNextSimpleText == null) + { + return false; + } + + if (pCurrentSimpleText->GetTextSource() != pNextSimpleText->GetTextSource()) + { + return false; + } + + if (!IsSameFontAttribute(pCurrentSimpleText->GetFont(), pNextSimpleText->GetFont())) + { + return false; + } + + if (pCurrentSimpleText->GetForegroundColor() != pNextSimpleText->GetForegroundColor()) + { + return false; + } + + if (pCurrentSimpleText->GetBackgroundColor() != pNextSimpleText->GetBackgroundColor()) + { + return false; + } + + if (pCurrentSimpleText->GetBitmap() != null || pNextSimpleText->GetBitmap() != null) + { + return false; + } + + return true; +} + +bool +TextUtility::IsSameFontAttribute(const Font* pFontSrc, const Font* pFontTarget) +{ + if (pFontSrc->GetSize() != pFontTarget->GetSize()) + { + return false; + } + + if (pFontSrc->IsBold() != pFontTarget->IsBold()) + { + return false; + } + + if (pFontSrc->IsItalic() != pFontTarget->IsItalic()) + { + return false; + } + + if (pFontSrc->IsPlain() != pFontTarget->IsPlain()) + { + return false; + } + + if (pFontSrc->IsStrikeOut() != pFontTarget->IsStrikeOut()) + { + return false; + } + + if (pFontSrc->IsUnderlined() != pFontTarget->IsUnderlined()) + { + return false; + } + + return true; +} + +int +TextUtility::GetFontMaxHeight(Font* pFont) +{ + if (!pFont) + { + return 0; + } + + _Font* pNativeFont = _Font::GetInstance(*_FontImpl::GetInstance(*pFont)); + SysTryReturn(NID_GRP + , pNativeFont + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance."); + + return pNativeFont->GetLeading(); +} + +int +TextUtility::GetFontMaxHeight(_Font* pFont) +{ + if (!pFont) + { + return 0; + } + + return pFont->GetLeading(); +} + +int +TextUtility::GetTextLength(const wchar_t* pText) +{ + int count = 0; + + while (*(pText + count) != 0) + { + count++; + } + + return count; +} + +int +TextUtility::GetCharCountInWidth(_Font* pFont, const wchar_t* pText, int textLength, int maxWidth, bool outline, int& width, int& height) +{ + if (!pFont) + { + return 0; + } + + result r = E_SUCCESS; + int count = 0; + Dimension lineDimension; + Tizen::Base::String text(pText); + + r = pFont->GetTextExtent(maxWidth, text, 0, textLength, outline, L"", count, lineDimension); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + + width = lineDimension.width; + height = pFont->GetLeading(); + + SetLastResult(E_SUCCESS); + + return count; + +CATCH: + width = 0; + height = 0; + return 0; +} + +result +TextUtility::CopyText(wchar_t* pDstText, const wchar_t* pSrcText, int textLength) +{ + SysTryReturn(NID_GRP + , pDstText && pSrcText + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + int srcTextLength = 0; + wchar_t ch = 0; + + srcTextLength = GetTextLength(pSrcText); + if (srcTextLength < textLength) + { + textLength = srcTextLength; + } + + if (textLength == 0) + { + *pDstText = 0; + return E_SUCCESS; + } + + do + { + ch = *pSrcText++; + *pDstText++ = ch; + if (--textLength == 0) + { + if (ch != 0) + { + *pDstText++ = 0; + } + return E_SUCCESS; + } + } + while (ch != 0); + + do + { + *pDstText++ = 0; + } + while (0 < --textLength); + + return E_SUCCESS; +} + +result +TextUtility::CopyText(wchar_t* pDstText, const wchar_t* pSrcText) +{ + SysTryReturn(NID_GRP + , pDstText && pSrcText + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + int i = 0; + wchar_t ch = 0; + + do + { + ch = pSrcText[i]; + pDstText[i] = ch; + i++; + } + while (ch != 0); + + return E_SUCCESS; +} + +result +TextUtility::DrawText(_Canvas& canvas, int x, int y, const wchar_t* pText, int textLength) +{ + result r = E_SUCCESS; + Point point(x, y); + + Tizen::Base::String text(pText); + + if (pText[textLength - 1] == TEXT_LINE_FEED || pText[textLength - 1] == TEXT_CARRIAGE_RETURN) + { + textLength--; + } + + r = canvas.DrawText(point, text, 0, textLength); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +TextUtility::DrawOutlineText(_Canvas& canvas, int x, int y, const wchar_t* pText, int textLength, Color outlineColor) +{ + result r = E_SUCCESS; + Point point(x, y); + + Tizen::Base::String text(pText); + + if (pText[textLength - 1] == TEXT_LINE_FEED || pText[textLength - 1] == TEXT_CARRIAGE_RETURN) + { + textLength--; + } + + r = canvas.DrawText(point, text, 0, textLength, outlineColor); + SysTryReturn(NID_GRP + , r == E_SUCCESS + , r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +TextUtility::GetTextExtent(_Font* pFont, const wchar_t* pText, int textLength, bool outline, int& width, int& height) +{ + SysTryReturn(NID_GRP + , pFont && pText + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + Dimension lineDimension; + Tizen::Base::String text(pText); + + r = pFont->GetTextExtent(text, textLength, lineDimension); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + + width = lineDimension.width; + height = pFont->GetLeading(); + + return E_SUCCESS; + +CATCH: + width = 0; + height = 0; + return r; +} + +result +TextUtility::GetTextExtent(Font* pFont, const wchar_t* pText, int textLength, bool outline, int& width, int& height) +{ + SysTryReturn(NID_GRP + , pFont && pText + , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + int count = 0; + Dimension lineDimension; + Tizen::Base::String text(pText); + + _Font* pNativeFont = _Font::GetInstance(*_FontImpl::GetInstance(*pFont)); + SysTryReturn(NID_GRP + , pNativeFont + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance."); + + r = pNativeFont->GetTextExtent((Integer::VALUE_MAX >> 1) - 1, text, 0, textLength, outline, L"", count, lineDimension); + SysTryCatch(NID_GRP + , r == E_SUCCESS + , , r, "[%s] Propagating.", GetErrorMessage(r)); + + width = lineDimension.width; + height = pNativeFont->GetLeading(); + + return E_SUCCESS; + +CATCH: + width = 0; + height = 0; + return r; +} + +}}} // Tizen::Graphics::_Text + diff --git a/src/graphics/text/FGrp_TextTextUtility.h b/src/graphics/text/FGrp_TextTextUtility.h new file mode 100644 index 0000000..f9061e3 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextUtility.h @@ -0,0 +1,71 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextUtility.h + * @brief This file contains the declarations of TextUtility class. + */ + +#ifndef _FGRP_INTERNAL_TEXT_UTILITY_H_ +#define _FGRP_INTERNAL_TEXT_UTILITY_H_ + +#include "../FGrp_Font.h" +#include "FGrp_TextCommon.h" + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +class TextElement; +class TextSimple; + +class TextUtility +{ +public: + static TextElementType GetObjectTypeFromValueType(TextComponentInfoValueType type); + + static bool CanMerge(TextElement* pCurrentTextElement, TextElement* pNextTextElement); + + static bool IsSameFontAttribute(const Font* pFontSrc, const Font* pFontTarget); + + static int GetFontMaxHeight(Font* pFont); + + static int GetFontMaxHeight(_Font* pFont); + + static int GetTextLength(const wchar_t* pText); + + static int GetCharCountInWidth(_Font* pFont, const wchar_t* pText, int textLength, int maxWidth, bool outline, int& width, int& height); + + static result GetTextExtent(_Font* pFont, const wchar_t* pText, int textLength, bool outline, int& width, int& height); + + static result GetTextExtent(Font* pFont, const wchar_t* pText, int textLength, bool outline, int& width, int& height); + + static result CopyText(wchar_t* pDstText, const wchar_t* pSrcText, int textLength); + + static result CopyText(wchar_t* pDstText, const wchar_t* pSrcText); + + static result DrawText(_Canvas& canvas, int x, int y, const wchar_t* pText, int textLength); + + static result DrawOutlineText(_Canvas& canvas, int x, int y, const wchar_t* pText, int textLength, Color outlineColor); + +}; // TextUtility + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_UTILITY_H_ diff --git a/src/graphics/text/FGrp_TextTextWidthManager.cpp b/src/graphics/text/FGrp_TextTextWidthManager.cpp new file mode 100644 index 0000000..24fafbe --- /dev/null +++ b/src/graphics/text/FGrp_TextTextWidthManager.cpp @@ -0,0 +1,2352 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextWidthManager.cpp + * @brief This is the implementation file for TextWidthManager class. + */ + +#include +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextElement.h" +#include "FGrp_TextTextSimple.h" +#include "FGrp_TextTextCutLink.h" +#include "FGrp_TextTextComposite.h" +#include "FGrp_TextTextSimpleList.h" +#include "FGrp_TextTextWidthManager.h" + +using namespace Tizen::Base::Utility; + +namespace +{ + const int MAX_TEXT_WIDTH_INFO_MERGE_LENGTH = 10; +} + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +enum TextWidthInfoType +{ + TEXT_WIDTH_INFO_UNKNOWN = 0, + TEXT_WIDTH_INFO_WORD, + TEXT_WIDTH_INFO_SPACE, + TEXT_WIDTH_INFO_ENTER, + TEXT_WIDTH_INFO_SYMBOL +}; + +struct TextWidthCommonInfo +{ + TextWidthInfoType type; +}; + +struct UnknownTextWidthInfo : public TextWidthCommonInfo +{ + int length; +}; + +struct WordTextWidthInfo : public TextWidthCommonInfo +{ + int length; + int width; + int maxHeight; +}; + +struct SpaceTextWidthInfo : public TextWidthCommonInfo +{ + int width; + int maxHeight; +}; + +struct EnterTextWidthInfo : public TextWidthCommonInfo +{ + int length; + int maxHeight; +}; + +struct SymbolTextWidthInfo : public TextWidthCommonInfo +{ + int width; + int maxHeight; +}; + +TextWidthManager::TextWidthManager(TextComposite* pCompositeText) +{ + __isComposing = false; + __isInitialized = false; + __pCompositeText = pCompositeText; + __pTextWidthInfoList = null; + __pCurrentComposeTextElement = null; + __pCurrentWordWidthInfoNode = null; + __pCachedWordWidthInfoNode = null; + __currentTextElementLength = 0; + __currentTextElementType = TEXT_ELEMENT_TYPE_NONE; + __textOffsetOfCachedWidthInfo = 0; + __currentTextIndex = 0; + __strCurrentRelIndex = 0; + __textOffsetOfCurrentWidthInfo = 0; + __length = 0; + __currentComposeTextElementIndex = 0; +} + +TextWidthManager::~TextWidthManager(void) +{ + if (__isInitialized) + { + Finalize(); + } +} + +bool +TextWidthManager::Initialize(int textLength) +{ + if (__isInitialized) + { + Finalize(); + } + + __pTextWidthInfoList = TextSimpleList::Create(); + SysTryReturn(NID_GRP + , __pTextWidthInfoList + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + TextSimpleList::Init(__pTextWidthInfoList); + + __length = 0; + __isComposing = false; + __isInitialized = true; + __pCurrentComposeTextElement = null; + __pCachedWordWidthInfoNode = null; + __currentComposeTextElementIndex = 0; + + if (textLength > 0) + { + InformTextInsert(0, textLength); + } + + return true; +} + +bool +TextWidthManager::Finalize(void) +{ + if (!__isInitialized) + { + return false; + } + + if (__pTextWidthInfoList) + { + TextWidthCommonInfo* pTextWidthCommonInfo = null; + + pTextWidthCommonInfo = static_cast < TextWidthCommonInfo* >(TextSimpleList::DeleteNthObject(__pTextWidthInfoList, 0)); + while (pTextWidthCommonInfo) + { + delete pTextWidthCommonInfo; + pTextWidthCommonInfo = static_cast < TextWidthCommonInfo* >(TextSimpleList::DeleteNthObject(__pTextWidthInfoList, 0)); + } + + if (__pTextWidthInfoList->nodeCount != 0) + { + TextSimpleList::Init(__pTextWidthInfoList); + } + + TextSimpleList::Destory(__pTextWidthInfoList); + __pTextWidthInfoList = null; + } + + __isInitialized = false; + __isComposing = false; + __length = 0; + __pCurrentComposeTextElement = null; + __pCachedWordWidthInfoNode = null; + + return true; +} + +bool +TextWidthManager::StartCompose(int textIndex) +{ + if (!__isInitialized) + { + return false; + } + + if (__length <= textIndex) + { + return false; + } + + SimpleNode* pCurrentTextWidthInfoNode = null; + int currentWidthInfoTextOffset = 0; + TextWidthCommonInfo* pCurrentTextWidthInfo = null; + + pCurrentTextWidthInfoNode = SearchTextWidthInfo(textIndex, currentWidthInfoTextOffset); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfoNode + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width node."); + + pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + __pCurrentWordWidthInfoNode = pCurrentTextWidthInfoNode; + __textOffsetOfCurrentWidthInfo = textIndex - currentWidthInfoTextOffset; + + int elementIndex = 0; + int elementTextOffset = 0; + __currentTextIndex = textIndex; + __pCurrentComposeTextElement = __pCompositeText->GetElementAtTextIndex(textIndex, elementTextOffset, + elementIndex, __currentTextElementLength, __strCurrentRelIndex); + SysTryReturn(NID_GRP + , __pCurrentComposeTextElement + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + __currentComposeTextElementIndex = elementIndex; + __currentTextElementType = __pCurrentComposeTextElement->GetType(); + __isComposing = true; + + return true; +} + +bool +TextWidthManager::GetCurrentLineInfo(int lineWidth, TextLineComposeInfo& textLineComposeInfo) +{ + if (!__isComposing) + { + return false; + } + + if (__length <= __currentTextIndex) + { + return false; + } + + TextWidthCommonInfo* pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + if (__textOffsetOfCurrentWidthInfo != 0) + { + UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo; + SysTryReturn(NID_GRP + , pUnknownTextWidthInfo + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN; + pUnknownTextWidthInfo->length = GetTextWidthInfoLength(pCurrentTextWidthInfo) - __textOffsetOfCurrentWidthInfo; + + __pCurrentWordWidthInfoNode = SplitWidthInfo(__pCurrentWordWidthInfoNode, __textOffsetOfCurrentWidthInfo, + pUnknownTextWidthInfo); + + SysTryReturn(NID_GRP + , __pCurrentWordWidthInfoNode + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width node."); + + __textOffsetOfCurrentWidthInfo = 0; + + pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + } + + int maxHeight = 0; + int remainingWidth = lineWidth; + int type = 0; + int textCount = 0; + int endType = TEXT_RETBY_NORMAL; + bool composeDone = false; + bool wordMeet = false; + bool enterMeet = false; + bool spaceMeetAfterWord = false; + bool cutLinkMeetAfterWord = false; + + while (!composeDone) + { + type = pCurrentTextWidthInfo->type; + + switch (type) + { + case TEXT_WIDTH_INFO_UNKNOWN: + { + AnalyzeCurrentUnKnownTextWidthInfo(remainingWidth); + } + break; + + case TEXT_WIDTH_INFO_WORD: + { + if (remainingWidth <= 0) + { + break; + } + + WordTextWidthInfo* pWordTtextWidthInfo = static_cast < WordTextWidthInfo* >(pCurrentTextWidthInfo); + SysTryReturn(NID_GRP + , pWordTtextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information."); + + if (pWordTtextWidthInfo->width <= remainingWidth) + { + bool iswordoverWidth = false; + int widthAnalyzed = 0; + int strLengthAnalyzed = 0; + int heightAnalzyed = 0; + bool nextKorean = false; + bool includeCutLink = false; + + AnalyzeNextTextWidthInfo(remainingWidth - pWordTtextWidthInfo->width, iswordoverWidth, + widthAnalyzed, strLengthAnalyzed, heightAnalzyed, nextKorean, includeCutLink); + + if (iswordoverWidth) + { + if ((nextKorean || !spaceMeetAfterWord) && !cutLinkMeetAfterWord) + { + remainingWidth -= (widthAnalyzed + pWordTtextWidthInfo->width); + if (maxHeight < pWordTtextWidthInfo->maxHeight) + { + maxHeight = pWordTtextWidthInfo->maxHeight; + } + + if (maxHeight < heightAnalzyed) + { + maxHeight = heightAnalzyed; + } + + textCount += (pWordTtextWidthInfo->length + strLengthAnalyzed); + Seek(pWordTtextWidthInfo->length + strLengthAnalyzed); + + } + endType = TEXT_RETBY_LIMITWIDTH; + composeDone = true; + } + else + { + remainingWidth -= (pWordTtextWidthInfo->width + widthAnalyzed); + if (maxHeight < pWordTtextWidthInfo->maxHeight) + { + maxHeight = pWordTtextWidthInfo->maxHeight; + } + if (maxHeight < heightAnalzyed) + { + maxHeight = heightAnalzyed; + } + + textCount += (pWordTtextWidthInfo->length + strLengthAnalyzed); + Seek(pWordTtextWidthInfo->length + strLengthAnalyzed); + + wordMeet = true; + cutLinkMeetAfterWord = includeCutLink; + } + } + else + { + SysTryReturn(NID_GRP + , __pCurrentWordWidthInfoNode + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width node."); + + bool nextKorean = false; + int textLengthBeforeSplit = GetTextWidthInfoLength(static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject)); + pWordTtextWidthInfo = SplitCurrentWordWidthInfo(remainingWidth, nextKorean); + SysTryReturn(NID_GRP + , pWordTtextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + if (textLengthBeforeSplit != pWordTtextWidthInfo->length) + { + if ((nextKorean || !spaceMeetAfterWord) && !cutLinkMeetAfterWord) + { + remainingWidth -= pWordTtextWidthInfo->width; + if (pWordTtextWidthInfo->maxHeight > maxHeight) + { + maxHeight = pWordTtextWidthInfo->maxHeight; + } + textCount += pWordTtextWidthInfo->length; + Seek(pWordTtextWidthInfo->length); + } + } + + endType = TEXT_RETBY_LIMITWIDTH; + composeDone = true; + } + } + break; + + case TEXT_WIDTH_INFO_SPACE: + { + SpaceTextWidthInfo* pSpaceTextWidthInfo = static_cast < SpaceTextWidthInfo* >(pCurrentTextWidthInfo); + SysTryReturn(NID_GRP + , pSpaceTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information."); + + if (remainingWidth >= pSpaceTextWidthInfo->width) + { + remainingWidth -= pSpaceTextWidthInfo->width; + if (maxHeight < pSpaceTextWidthInfo->maxHeight) + { + maxHeight = pSpaceTextWidthInfo->maxHeight; + } + + textCount++; + + Seek(1); + + if (wordMeet) + { + spaceMeetAfterWord = true; + } + + cutLinkMeetAfterWord = false; + } + else + { + endType = TEXT_RETBY_LIMITWIDTH; + composeDone = true; + } + } + break; + + case TEXT_WIDTH_INFO_ENTER: + { + endType = TEXT_RETBY_LINEFEED; + composeDone = true; + EnterTextWidthInfo* pEnterTextWidthInfo = static_cast < EnterTextWidthInfo* >(pCurrentTextWidthInfo); + SysTryReturn(NID_GRP + , pEnterTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information."); + + maxHeight = pEnterTextWidthInfo->maxHeight; + textCount += pEnterTextWidthInfo->length; + Seek(pEnterTextWidthInfo->length); + + enterMeet = true; + } + break; + + case TEXT_WIDTH_INFO_SYMBOL: + { + if (textCount == 0) + { + SymbolTextWidthInfo* pSymbolTextWidthInfo = static_cast < SymbolTextWidthInfo* >(pCurrentTextWidthInfo); + SysTryReturn(NID_GRP + , pSymbolTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information."); + + remainingWidth -= pSymbolTextWidthInfo->width; + maxHeight = pSymbolTextWidthInfo->maxHeight; + textCount++; + Seek(1); + } + else + { + endType = TEXT_RETBY_NORMAL; + composeDone = true; + } + } + break; + } + + if (remainingWidth <= 0) + { + break; + } + + if (!enterMeet && (__length <= __currentTextIndex)) + { + endType = TEXT_RETBY_NORMAL; + composeDone = true; + } + + if (!composeDone) + { + SysTryReturn(NID_GRP + , __pCurrentWordWidthInfoNode + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width node."); + + pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + } + } + + textLineComposeInfo.length = textCount; + textLineComposeInfo.width = lineWidth - remainingWidth; + textLineComposeInfo.height = maxHeight; + textLineComposeInfo.endType = endType; + + return true; +} + +bool +TextWidthManager::EndCompose(void) +{ + __isComposing = false; + __pCurrentComposeTextElement = null; + __pCurrentWordWidthInfoNode = null; + + return true; +} + +bool +TextWidthManager::InformTextInsert(int textIndex, int textLength) +{ + SimpleNode* pCurrentTextWidthInfoNode = null; + if (!__isInitialized) + { + return false; + } + + if (__isComposing) + { + return false; + } + + if (__length < textIndex) + { + return false; + } + + if (textIndex == __length) + { + SimpleNode* pLastNode = TextSimpleList::GetLastNode(__pTextWidthInfoList); + int strLastTextWidthInfo = 0; + TextWidthCommonInfo* pLastTextWidthInfo = null; + + if (pLastNode != null) + { + pLastTextWidthInfo = static_cast < TextWidthCommonInfo* >(pLastNode->pObject); + strLastTextWidthInfo = GetTextWidthInfoLength(pLastTextWidthInfo); + SysTryReturn(NID_GRP + , strLastTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text element node."); + } + + if ((pLastNode == null) || (strLastTextWidthInfo + textLength > MAX_TEXT_WIDTH_INFO_MERGE_LENGTH)) + { + UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo; + SysTryReturn(NID_GRP + , pUnknownTextWidthInfo + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN; + pUnknownTextWidthInfo->length = 0; + + pCurrentTextWidthInfoNode = TextSimpleList::AppendObject(__pTextWidthInfoList, pUnknownTextWidthInfo); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfoNode + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text element node."); + + UpdateCachedTextWidhtInfo(__length, pCurrentTextWidthInfoNode); + pUnknownTextWidthInfo->length = textLength; + } + else + { + UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo; + SysTryReturn(NID_GRP + , pUnknownTextWidthInfo + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN; + pUnknownTextWidthInfo->length = strLastTextWidthInfo; + + delete static_cast < TextWidthCommonInfo* >(pLastNode->pObject); + pLastNode->pObject = pUnknownTextWidthInfo; + + UpdateCachedTextWidhtInfo(__length - strLastTextWidthInfo, pLastNode); + pUnknownTextWidthInfo->length += textLength; + } + + __length += textLength; + + return true; + } + + int currentWidthInfoTextOffset = 0; + TextWidthCommonInfo* pCurrentTextWidthInfo = null; + + pCurrentTextWidthInfoNode = SearchTextWidthInfo(textIndex, currentWidthInfoTextOffset); + if (pCurrentTextWidthInfoNode == null) + { + return false; + } + pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + int textIndexFromCurrentWidthInfoTextOffset = textIndex - currentWidthInfoTextOffset; + int widthinfoType = pCurrentTextWidthInfo->type; + + switch (widthinfoType) + { + case TEXT_WIDTH_INFO_UNKNOWN: + { + UpdateCachedTextWidhtInfo(currentWidthInfoTextOffset, pCurrentTextWidthInfoNode); + + UnknownTextWidthInfo* pUnknownTextWidthInfo = static_cast < UnknownTextWidthInfo* >(pCurrentTextWidthInfo); + SysTryReturn(NID_GRP + , pUnknownTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + pUnknownTextWidthInfo->length += textLength; + __length += textLength; + } + break; + + case TEXT_WIDTH_INFO_WORD: + { + WordTextWidthInfo* pCurrentWordTextWidthInfo = static_cast < WordTextWidthInfo* >(pCurrentTextWidthInfo); + SysTryReturn(NID_GRP + , pCurrentWordTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information."); + + if ((textIndexFromCurrentWidthInfoTextOffset == 0) && + (pCurrentWordTextWidthInfo->length + textLength > MAX_TEXT_WIDTH_INFO_MERGE_LENGTH)) + { + UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo; + SysTryReturn(NID_GRP + , pUnknownTextWidthInfo + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN; + pUnknownTextWidthInfo->length = 0; + + pCurrentTextWidthInfoNode = TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentTextWidthInfoNode, + pUnknownTextWidthInfo); + UpdateCachedTextWidhtInfo(textIndex, pCurrentTextWidthInfoNode); + pUnknownTextWidthInfo->length = textLength; + } + else + { + UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo; + SysTryReturn(NID_GRP + , pUnknownTextWidthInfo + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN; + pUnknownTextWidthInfo->length = pCurrentWordTextWidthInfo->length; + delete static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject); + pCurrentTextWidthInfoNode->pObject = pUnknownTextWidthInfo; + + UpdateCachedTextWidhtInfo(currentWidthInfoTextOffset, pCurrentTextWidthInfoNode); + pUnknownTextWidthInfo->length += textLength; + } + + __length += textLength; + } + break; + + case TEXT_WIDTH_INFO_SPACE: + // fall through + case TEXT_WIDTH_INFO_ENTER: + // fall through + case TEXT_WIDTH_INFO_SYMBOL: + { + UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo; + SysTryReturn(NID_GRP + , pUnknownTextWidthInfo + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN; + pUnknownTextWidthInfo->length = GetTextWidthInfoLength(pCurrentTextWidthInfo); + delete static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject); + pCurrentTextWidthInfoNode->pObject = pUnknownTextWidthInfo; + + UpdateCachedTextWidhtInfo(currentWidthInfoTextOffset, pCurrentTextWidthInfoNode); + pUnknownTextWidthInfo->length += textLength; + __length += textLength; + } + break; + } + + return true; +} + +bool +TextWidthManager::InformTextRemove(int textIndex, int textLength) +{ + if (!__isInitialized) + { + return false; + } + + if (__isComposing) + { + return false; + } + + if (__length <= textIndex) + { + return false; + } + + if (__length < textIndex + textLength) + { + textLength = __length - textIndex; + } + + int strLengthRemove = textLength; + SimpleNode* pCurrentTextWidthInfoNode = null; + int currentWidthInfoTextOffset = 0; + TextWidthCommonInfo* pCurrentTextWidthInfo = null; + + pCurrentTextWidthInfoNode = SearchTextWidthInfo(textIndex, currentWidthInfoTextOffset); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfoNode + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text text width node."); + + pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + int textIndexFromCurrentWidthInfoTextOffset = textIndex - currentWidthInfoTextOffset; + int currentWidthInfoTextLength = GetTextWidthInfoLength(pCurrentTextWidthInfo); + bool cachedUpdated = false; + + if ((textIndexFromCurrentWidthInfoTextOffset != 0) || (currentWidthInfoTextLength > textLength)) + { + int strCurrrentRemoveLength = 0; + if (textIndexFromCurrentWidthInfoTextOffset == 0) + { + strCurrrentRemoveLength = textLength; + } + else + { + if (textLength + textIndexFromCurrentWidthInfoTextOffset >= currentWidthInfoTextLength) + { + strCurrrentRemoveLength = currentWidthInfoTextLength - textIndexFromCurrentWidthInfoTextOffset; + } + else + { + strCurrrentRemoveLength = textLength; + } + } + + UpdateCachedTextWidhtInfo(currentWidthInfoTextOffset, pCurrentTextWidthInfoNode); + cachedUpdated = true; + + UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo; + SysTryReturn(NID_GRP + , pUnknownTextWidthInfo + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN; + pUnknownTextWidthInfo->length = currentWidthInfoTextLength - strCurrrentRemoveLength; + delete static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject); + pCurrentTextWidthInfoNode->pObject = pUnknownTextWidthInfo; + + pCurrentTextWidthInfoNode = pCurrentTextWidthInfoNode->pNext; + + textLength -= strCurrrentRemoveLength; + } + + while (textLength) + { + SimpleNode* pNextTextWidthInfoNode = null; + + SysTryReturn(NID_GRP + , pCurrentTextWidthInfoNode + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element node."); + + pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + currentWidthInfoTextLength = GetTextWidthInfoLength(pCurrentTextWidthInfo); + + if (textLength < currentWidthInfoTextLength) + { + break; + } + + pNextTextWidthInfoNode = pCurrentTextWidthInfoNode->pNext; + + TextSimpleList::DeleteNode(__pTextWidthInfoList, pCurrentTextWidthInfoNode); + + pCurrentTextWidthInfoNode = pNextTextWidthInfoNode; + + textLength -= currentWidthInfoTextLength; + } + + if (textLength > 0) + { + UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo; + SysTryReturn(NID_GRP + , pUnknownTextWidthInfo + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN; + pUnknownTextWidthInfo->length = currentWidthInfoTextLength - textLength; + delete static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject); + pCurrentTextWidthInfoNode->pObject = pUnknownTextWidthInfo; + } + + if (!cachedUpdated) + { + UpdateCachedTextWidhtInfo(textIndex, pCurrentTextWidthInfoNode); + } + + __length -= strLengthRemove; + + return true; +} + +int +TextWidthManager::GetTextWidthInfoLength(TextWidthCommonInfo* pTextWidthCommonInfo) +{ + int type = pTextWidthCommonInfo->type; + + switch (type) + { + case TEXT_WIDTH_INFO_UNKNOWN: + { + UnknownTextWidthInfo* pUnknownTextWidthInfo = static_cast < UnknownTextWidthInfo* >(pTextWidthCommonInfo); + SysTryReturn(NID_GRP + , pUnknownTextWidthInfo + , -1, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information."); + + return pUnknownTextWidthInfo->length; + } + + case TEXT_WIDTH_INFO_WORD: + { + WordTextWidthInfo* pWordWidthInfo = static_cast < WordTextWidthInfo* >(pTextWidthCommonInfo); + SysTryReturn(NID_GRP + , pWordWidthInfo + , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + return pWordWidthInfo->length; + } + + case TEXT_WIDTH_INFO_SPACE: + return 1; + + case TEXT_WIDTH_INFO_ENTER: + { + EnterTextWidthInfo* pEnterWidthInfo = static_cast < EnterTextWidthInfo* >(pTextWidthCommonInfo); + SysTryReturn(NID_GRP + , pEnterWidthInfo + , -1, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information."); + + return pEnterWidthInfo->length; + } + + case TEXT_WIDTH_INFO_SYMBOL: + return 1; + } + + return -1; +} + +SimpleNode* +TextWidthManager::SplitWidthInfo(SimpleNode* pOrginalTextWidthInfoNode, int splitStartIndex, + TextWidthCommonInfo* pTextWidthInfo) +{ + TextWidthCommonInfo* pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pOrginalTextWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + int type = pCurrentTextWidthInfo->type; + + if (type == TEXT_WIDTH_INFO_UNKNOWN) + { + UnknownTextWidthInfo* pUnknownTextWidthInfo = static_cast < UnknownTextWidthInfo* >(pCurrentTextWidthInfo); + SysTryReturn(NID_GRP + , pUnknownTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information."); + + pUnknownTextWidthInfo->length = splitStartIndex; + } + else if (type == TEXT_WIDTH_INFO_WORD) + { + UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo; + SysTryReturn(NID_GRP + , pUnknownTextWidthInfo + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN; + pUnknownTextWidthInfo->length = splitStartIndex; + delete static_cast < TextWidthCommonInfo* >(pOrginalTextWidthInfoNode->pObject); + pOrginalTextWidthInfoNode->pObject = pUnknownTextWidthInfo; + } + + SimpleNode* pNode = TextSimpleList::InsertObjectAfterNode(__pTextWidthInfoList, pOrginalTextWidthInfoNode, pTextWidthInfo); + return pNode; +} + +WordTextWidthInfo* +TextWidthManager::SplitCurrentWordWidthInfo(int limitWidth, bool& isNextKoreanStart) +{ + TextWidthCommonInfo* pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + WordTextWidthInfo* pWordWidthInfo = static_cast < WordTextWidthInfo* >(pCurrentTextWidthInfo); + SysTryReturn(NID_GRP + , pWordWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + int currentWordWidth = pWordWidthInfo->width; + int currentWordLength = pWordWidthInfo->length; + + if ((currentWordWidth - limitWidth) >= (currentWordWidth >> 2)) + { + TextElement* pTextElement = __pCurrentComposeTextElement; + int textElementIndex = __currentComposeTextElementIndex; + int strSrcRelIndex = __strCurrentRelIndex; + int currentLength = Math::Min(__currentTextElementLength, currentWordLength); + int stringLength = currentWordLength; + int endType = TEXT_RETBY_NORMAL; + int remainWidth = limitWidth; + int charCount = 0; + int width = 0; + int height = 0; + int maxHeight = 0; + int textIndex = 0; + + while (stringLength != 0) + { + endType = pTextElement->ForwardAnalyze(strSrcRelIndex, currentLength, remainWidth, + TEXT_OBJECT_WRAP_TYPE_NONE, charCount, width, height); + + if (endType == TEXT_RETBY_LIMITWIDTH) + { + textIndex += charCount; + strSrcRelIndex += charCount; + remainWidth -= width; + if (height > maxHeight) + { + maxHeight = height; + } + break; + } + else if (endType != TEXT_RETBY_LIMITLENGTH) + { + ; //SysAssert(false); + } + + textElementIndex++; + pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex); + if (pTextElement == null) + { + break; + } + + remainWidth -= width; + if (height > maxHeight) + { + height = maxHeight; + } + + strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + stringLength -= currentLength; + textIndex += currentLength; + currentLength = Math::Min(stringLength, pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex); + } + + SysTryReturn(NID_GRP + , pTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + TextSimple* pSimpleTextElement = dynamic_cast < TextSimple* >(pTextElement); + SysTryReturn(NID_GRP + , pSimpleTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text element."); + + wchar_t* pText = (wchar_t*)pSimpleTextElement->GetText(); + isNextKoreanStart = IsKorean(pText[0]); + + if (textIndex > 0) + { + WordTextWidthInfo* pNewWordWidthInfo = new (std::nothrow) WordTextWidthInfo; + SysTryReturn(NID_GRP + , pNewWordWidthInfo + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pNewWordWidthInfo->type = TEXT_WIDTH_INFO_WORD; + pNewWordWidthInfo->length = textIndex; + pNewWordWidthInfo->maxHeight = height; + pNewWordWidthInfo->width = limitWidth - remainWidth; + + bool isCacheChanged = false; + + if (__pCurrentWordWidthInfoNode == __pCachedWordWidthInfoNode) + { + isCacheChanged = true; + } + + __pCurrentWordWidthInfoNode = TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, __pCurrentWordWidthInfoNode, + pNewWordWidthInfo); + + if (isCacheChanged) + { + __pCachedWordWidthInfoNode = __pCurrentWordWidthInfoNode; + } + + pWordWidthInfo->length -= textIndex; + pWordWidthInfo->width -= pNewWordWidthInfo->width; + return pNewWordWidthInfo; + } + else + { + return pWordWidthInfo; + } + } + else + { + int remainingWidth = currentWordWidth - limitWidth; + + TextElement* pTextElement = __pCurrentComposeTextElement; + int textElementIndex = __currentComposeTextElementIndex; + int strSrcRelIndex = __strCurrentRelIndex; + int textLength = currentWordLength; + int currentLength = __currentTextElementLength; + TextElement* pTextElementStack[10]; + int textElementStackIndex = 0; + + pTextElementStack[0] = pTextElement; + + while (textLength > 0) + { + if (textLength <= currentLength) + { + strSrcRelIndex += (textLength - 1); + break; + } + + textLength -= currentLength; + + textElementIndex++; + pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex); + if (pTextElement == null) + { + break; + } + + strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex; + + textElementStackIndex++; + pTextElementStack[textElementStackIndex] = pTextElement; + } + + SysTryReturn(NID_GRP + , pTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + int width = 0; + int height = 0; + int strSrcStartRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + int widthBackward = 0; + int stringLengthBackward = 0; + int maxHeight = 0; + + while (0 < remainingWidth) + { + pTextElement->GetRegion(strSrcRelIndex, 1, width, height); + if (remainingWidth <= width) + { + widthBackward += width; + stringLengthBackward++; + if (height > maxHeight) + { + maxHeight = height; + } + break; + } + + widthBackward += width; + stringLengthBackward++; + remainingWidth -= width; + + if (height > maxHeight) + { + maxHeight = height; + } + + if (strSrcStartRelIndex < strSrcRelIndex) + { + strSrcRelIndex--; + } + else + { + textElementStackIndex--; + SysTryReturn(NID_GRP + , textElementStackIndex >= 0 + , null, E_SYSTEM, "[E_SYSTEM] Index must be greater than or equal to 0."); + + pTextElement = pTextElementStack[textElementStackIndex]; + SysTryReturn(NID_GRP + , pTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + strSrcStartRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - 1; + } + } + + TextSimple* pSimpleTextElement = dynamic_cast < TextSimple* >(pTextElement); + SysTryReturn(NID_GRP + , pSimpleTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text element."); + + wchar_t* pText = (wchar_t*)pSimpleTextElement->GetText(); + isNextKoreanStart = IsKorean(pText[0]); + + if ((stringLengthBackward > 0) && (stringLengthBackward < pWordWidthInfo->length)) + { + WordTextWidthInfo* pNewWordWidthInfo = new (std::nothrow) WordTextWidthInfo; + SysTryReturn(NID_GRP + , pNewWordWidthInfo + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pNewWordWidthInfo->type = TEXT_WIDTH_INFO_WORD; + pNewWordWidthInfo->length = stringLengthBackward; + pNewWordWidthInfo->maxHeight = height; + pNewWordWidthInfo->width = widthBackward; + + TextSimpleList::InsertObjectAfterNode(__pTextWidthInfoList, __pCurrentWordWidthInfoNode, pNewWordWidthInfo); + + pWordWidthInfo->length -= stringLengthBackward; + pWordWidthInfo->width -= widthBackward; + } + else + { + return pWordWidthInfo; + } + + return pWordWidthInfo; + } + + return null; +} + +WordTextWidthInfo* +TextWidthManager::SplitWordWidthInfo(SimpleNode* pCurrentWordWidthInfoNode, TextElement* pCurrentTextElement, + int strCurrentRelIndex, int strCurrentLength, int limitWidth, bool& isNextKoreanStart) +{ + WordTextWidthInfo* pWordWidthInfo = static_cast < WordTextWidthInfo* >(pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pWordWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + int currentWordWidth = pWordWidthInfo->width; + int currentWordLength = pWordWidthInfo->length; + + if ((currentWordWidth - limitWidth) >= (currentWordWidth >> 2)) + { + TextElement* pTextElement = pCurrentTextElement; + int strSrcRelIndex = strCurrentRelIndex; + int currentLength = Math::Min(__currentTextElementLength, currentWordLength); + int stringLength = currentWordLength; + int endType = TEXT_RETBY_NORMAL; + int remainWidth = limitWidth; + int charCount = 0; + int width = 0; + int height = 0; + int maxHeight = 0; + int stringIndex = 0; + int textElementIndex = __pCompositeText->GetElementIndexOf(*pCurrentTextElement); + SysTryReturn(NID_GRP + , textElementIndex >= 0 + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + while (stringLength != 0) + { + endType = pTextElement->ForwardAnalyze(strSrcRelIndex, currentLength, remainWidth, + TEXT_OBJECT_WRAP_TYPE_NONE, charCount, width, height); + + if (endType == TEXT_RETBY_LIMITWIDTH) + { + stringIndex += charCount; + strSrcRelIndex += charCount; + remainWidth -= width; + if (height > maxHeight) + { + maxHeight = height; + } + break; + } + else if (endType != TEXT_RETBY_LIMITLENGTH) + { + ; //SysAssert(false); + } + + textElementIndex++; + pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex); + if (pTextElement == null) + { + break; + } + + remainWidth -= width; + + if (height > maxHeight) + { + height = maxHeight; + } + + strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + stringLength -= currentLength; + stringIndex += currentLength; + currentLength = Math::Min(stringLength, pTextElement->GetValue( + SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex); + } + + SysTryReturn(NID_GRP + , pTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + TextSimple* pSimpleTextElement = dynamic_cast < TextSimple* >(pTextElement); + SysTryReturn(NID_GRP + , pSimpleTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text element."); + + wchar_t* pText = (wchar_t*)pSimpleTextElement->GetText(); + isNextKoreanStart = IsKorean(pText[0]); + + if (stringIndex > 0) + { + WordTextWidthInfo* pNewWordWidthInfo = new (std::nothrow) WordTextWidthInfo; + SysTryReturn(NID_GRP + , pNewWordWidthInfo + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pNewWordWidthInfo->type = TEXT_WIDTH_INFO_WORD; + pNewWordWidthInfo->length = stringIndex; + pNewWordWidthInfo->maxHeight = height; + pNewWordWidthInfo->width = limitWidth - remainWidth; + + if (pCurrentWordWidthInfoNode == __pCachedWordWidthInfoNode) + { + __pCachedWordWidthInfoNode = TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, + pCurrentWordWidthInfoNode, pNewWordWidthInfo); + } + else + { + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, pNewWordWidthInfo); + } + + pWordWidthInfo->length -= stringIndex; + pWordWidthInfo->width -= pNewWordWidthInfo->width; + return pNewWordWidthInfo; + } + else + { + return pWordWidthInfo; + } + } + else + { + int remainingWidth = currentWordWidth - limitWidth; + + TextElement* pTextElement = __pCurrentComposeTextElement; + int textElementIndex = __currentComposeTextElementIndex; + int strSrcRelIndex = strCurrentRelIndex; + int textLength = currentWordLength; + int currentLength = __currentTextElementLength; + TextElement* pTextElementStack[10]; + int textElementStackIndex = 0; + + pTextElementStack[0] = pTextElement; + + while (textLength > 0) + { + if (currentLength >= textLength) + { + strSrcRelIndex += (textLength - 1); + break; + } + + textLength -= currentLength; + textElementIndex++; + + pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex); + if (pTextElement == null) + { + break; + } + + strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex; + + textElementStackIndex++; + pTextElementStack[textElementStackIndex] = pTextElement; + } + + SysTryReturn(NID_GRP + , pTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + int width = 0; + int height = 0; + int strSrcStartRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + int widthBackward = 0; + int stringLengthBackward = 0; + int maxHeight = 0; + while (remainingWidth > 0) + { + pTextElement->GetRegion(strSrcRelIndex, 1, width, height); + if (remainingWidth <= width) + { + widthBackward += width; + stringLengthBackward++; + if (height > maxHeight) + { + maxHeight = height; + } + break; + } + + widthBackward += width; + stringLengthBackward++; + remainingWidth -= width; + + if (height > maxHeight) + { + maxHeight = height; + } + + if (strSrcStartRelIndex < strSrcRelIndex) + { + strSrcRelIndex--; + } + else + { + textElementStackIndex--; + SysTryReturn(NID_GRP + , textElementStackIndex >= 0 + , null, E_SYSTEM, "[E_SYSTEM] Index must be greater than or equal to 0."); + + pTextElement = pTextElementStack[textElementStackIndex]; + SysTryReturn(NID_GRP + , pTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + strSrcStartRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - 1; + } + } + + TextSimple* pSimpleTextElement = dynamic_cast < TextSimple* >(pTextElement); + SysTryReturn(NID_GRP + , pSimpleTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text element."); + + wchar_t* pText = (wchar_t*)pSimpleTextElement->GetText(); + isNextKoreanStart = IsKorean(pText[0]); + + if ((stringLengthBackward > 0) && (stringLengthBackward < pWordWidthInfo->length)) + { + WordTextWidthInfo* pNewWordWidthInfo = new (std::nothrow) WordTextWidthInfo; + SysTryReturn(NID_GRP + , pNewWordWidthInfo + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pNewWordWidthInfo->type = TEXT_WIDTH_INFO_WORD; + pNewWordWidthInfo->length = stringLengthBackward; + pNewWordWidthInfo->maxHeight = height; + pNewWordWidthInfo->width = widthBackward; + + TextSimpleList::InsertObjectAfterNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, pNewWordWidthInfo); + + pWordWidthInfo->length -= stringLengthBackward; + pWordWidthInfo->width -= widthBackward; + } + else + { + return pWordWidthInfo; + } + + return pWordWidthInfo; + } + + return null; +} + +bool +TextWidthManager::Seek(int textLength) +{ + if (__currentTextIndex + textLength > __length) + { + return false; + } + + if (__currentTextIndex + textLength == __length) + { + __pCurrentWordWidthInfoNode = null; + __pCurrentComposeTextElement = null; + __currentTextIndex += textLength; + return true; + } + + if (textLength == 0) + { + return false; + } + + TextWidthCommonInfo* pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + int strCurrentTextWidthInfoLength = GetTextWidthInfoLength(pCurrentTextWidthInfo); + + if (__textOffsetOfCurrentWidthInfo != 0) + { + return false; + } + + int length = textLength; + + while (length > 0) + { + length -= strCurrentTextWidthInfoLength; + + __pCurrentWordWidthInfoNode = __pCurrentWordWidthInfoNode->pNext; + pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + strCurrentTextWidthInfoLength = GetTextWidthInfoLength(pCurrentTextWidthInfo); + } + + length = textLength; + TextElement* pTextElement = __pCurrentComposeTextElement; + int textElementIndex = __currentComposeTextElementIndex; + int strSrcRelIndex = __strCurrentRelIndex; + int currentLength = __currentTextElementLength; + + while (length > 0) + { + if (currentLength > length) + { + strSrcRelIndex += length; + break; + } + + length -= currentLength; + + textElementIndex++; + pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex); + if (pTextElement == null) + { + break; + } + + strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex; + } + + SysTryReturn(NID_GRP + , pTextElement + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + __pCurrentComposeTextElement = pTextElement; + __strCurrentRelIndex = strSrcRelIndex; + __currentTextElementLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex; + __currentTextIndex += textLength; + + return true; +} + +bool +TextWidthManager::AnalyzeCurrentUnKnownTextWidthInfo(int limitWidth) +{ + SimpleNode* pCurrentWordWidthInfoNode = __pCurrentWordWidthInfoNode; + UnknownTextWidthInfo* pCurrentUnknowTextWidthInfo = static_cast < UnknownTextWidthInfo* >(__pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentUnknowTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + int strCurrentTextWidthInfoLength = pCurrentUnknowTextWidthInfo->length; + + TextElement* pTextElement = __pCurrentComposeTextElement; + int textElementIndex = __currentComposeTextElementIndex; + int strSrcRelIndex = __strCurrentRelIndex; + int currentLength = __currentTextElementLength; + int textLength = strCurrentTextWidthInfoLength; + int width = 0; + int height = 0; + + TextElementType objectType; + + bool getDone = false; + + while (textLength > 0) + { + objectType = pTextElement->GetType(); + + switch (objectType) + { + case TEXT_ELEMENT_TYPE_TEXT: + // fall through + case TEXT_ELEMENT_TYPE_CUTLINK: + { + TextSimple* pSimpleTextElement = dynamic_cast < TextSimple* >(pTextElement); + SysTryReturn(NID_GRP + , pSimpleTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text element."); + + int wordType = 0; + int currentTextLength = 0; + + wordType = pSimpleTextElement->GetWordLength(strSrcRelIndex, currentTextLength); + if (wordType == WORD_ENTER) + { + pCurrentUnknowTextWidthInfo->length -= currentTextLength; + + pTextElement->GetRegion(strSrcRelIndex, 1, width, height); + + EnterTextWidthInfo* pNewEnterTextWidthInfo = new (std::nothrow) EnterTextWidthInfo; + SysTryReturn(NID_GRP + , pNewEnterTextWidthInfo + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pNewEnterTextWidthInfo->type = TEXT_WIDTH_INFO_ENTER; + pNewEnterTextWidthInfo->length = currentTextLength; + pNewEnterTextWidthInfo->maxHeight = height; + + if (pCurrentWordWidthInfoNode == __pCurrentWordWidthInfoNode) + { + bool changecachedInfo = false; + + if (__pCurrentWordWidthInfoNode == __pCachedWordWidthInfoNode) + { + changecachedInfo = true; + } + + __pCurrentWordWidthInfoNode = + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewEnterTextWidthInfo); + + if (changecachedInfo) + { + __pCachedWordWidthInfoNode = __pCurrentWordWidthInfoNode; + } + } + else + { + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewEnterTextWidthInfo); + } + + getDone = true; + } + else if (wordType == WORD_SPACE) + { + pCurrentUnknowTextWidthInfo->length--; + + pTextElement->GetRegion(strSrcRelIndex, 1, width, height); + + SpaceTextWidthInfo* pNewSpaceTextWidthInfo = new (std::nothrow) SpaceTextWidthInfo; + SysTryReturn(NID_GRP + , pNewSpaceTextWidthInfo + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pNewSpaceTextWidthInfo->type = TEXT_WIDTH_INFO_SPACE; + pNewSpaceTextWidthInfo->width = width; + pNewSpaceTextWidthInfo->maxHeight = height; + + if (pCurrentWordWidthInfoNode == __pCurrentWordWidthInfoNode) + { + bool changecachedInfo = false; + + if (__pCurrentWordWidthInfoNode == __pCachedWordWidthInfoNode) + { + changecachedInfo = true; + } + + __pCurrentWordWidthInfoNode = + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewSpaceTextWidthInfo); + + if (changecachedInfo) + { + __pCachedWordWidthInfoNode = __pCurrentWordWidthInfoNode; + } + } + else + { + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewSpaceTextWidthInfo); + } + + currentLength--; + strSrcRelIndex++; + limitWidth -= width; + textLength--; + } + else + { + if (currentTextLength > textLength) + { + currentTextLength = textLength; + } + pCurrentUnknowTextWidthInfo->length -= currentTextLength; + + pTextElement->GetRegion(strSrcRelIndex, currentTextLength, width, height); + + WordTextWidthInfo* pNewWordTextWidthInfo = new (std::nothrow) WordTextWidthInfo; + SysTryReturn(NID_GRP + , pNewWordTextWidthInfo + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pNewWordTextWidthInfo->type = TEXT_WIDTH_INFO_WORD; + pNewWordTextWidthInfo->length = currentTextLength; + pNewWordTextWidthInfo->width = width; + pNewWordTextWidthInfo->maxHeight = height; + + if (pCurrentWordWidthInfoNode == __pCurrentWordWidthInfoNode) + { + bool changecachedInfo = false; + + if (__pCurrentWordWidthInfoNode == __pCachedWordWidthInfoNode) + { + changecachedInfo = true; + } + + __pCurrentWordWidthInfoNode = + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewWordTextWidthInfo); + + if (changecachedInfo) + { + __pCachedWordWidthInfoNode = __pCurrentWordWidthInfoNode; + } + } + else + { + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewWordTextWidthInfo); + } + + currentLength -= currentTextLength; + strSrcRelIndex += currentTextLength; + limitWidth -= width; + textLength -= currentTextLength; + } + } + break; + + case TEXT_ELEMENT_TYPE_IMAGE: + { + pTextElement->GetRegion(0, 1, width, height); + + pCurrentUnknowTextWidthInfo->length--; + + SymbolTextWidthInfo* pNewSymbolTextWidthInfo = new (std::nothrow) SymbolTextWidthInfo; + SysTryReturn(NID_GRP + , pNewSymbolTextWidthInfo + , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pNewSymbolTextWidthInfo->type = TEXT_WIDTH_INFO_SYMBOL; + pNewSymbolTextWidthInfo->width = width; + pNewSymbolTextWidthInfo->maxHeight = height; + + if (pCurrentWordWidthInfoNode == __pCurrentWordWidthInfoNode) + { + bool changecachedInfo = false; + + if (__pCurrentWordWidthInfoNode == __pCachedWordWidthInfoNode) + { + changecachedInfo = true; + } + + __pCurrentWordWidthInfoNode = + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewSymbolTextWidthInfo); + + if (changecachedInfo) + { + __pCachedWordWidthInfoNode = __pCurrentWordWidthInfoNode; + } + } + else + { + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewSymbolTextWidthInfo); + } + + getDone = true; + } + break; + + default: + return false; + } + + if (limitWidth <= 0) + { + break; + } + + if (getDone) + { + break; + } + + if (currentLength <= 0) + { + textElementIndex++; + pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex); + if (pTextElement == null) + { + break; + } + + strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex; + } + } + + if (pCurrentUnknowTextWidthInfo->length == 0) + { + TextSimpleList::DeleteNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode); + } + + return true; +} + +SimpleNode* +TextWidthManager::AnalyzeUnKnownTextWidthInfo(SimpleNode* pCurrentWordWidthInfoNode, TextElement* pCurrentTextElement, + int strCurrentRelIndex, int strCurrentLength, int limitWidth) +{ + SimpleNode* pReturnWordWidthInfoNode = null; + SimpleNode* p_current_word_width_info_node = pCurrentWordWidthInfoNode; + int strCurrentTextWidthInfoLength = 0; + + UnknownTextWidthInfo* pCurrentUnknowTextWidthInfo = static_cast < UnknownTextWidthInfo* >(pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentUnknowTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + strCurrentTextWidthInfoLength = pCurrentUnknowTextWidthInfo->length; + + TextElement* pTextElement = pCurrentTextElement; + SysTryReturn(NID_GRP + , pTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + int textElementIndex = __pCompositeText->GetElementIndexOf(*pCurrentTextElement); + SysTryReturn(NID_GRP + , textElementIndex >= 0 + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + int strSrcRelIndex = strCurrentRelIndex; + int currentLength = strCurrentLength; + int textLength = strCurrentTextWidthInfoLength; + TextElementType objectType; + bool getDone = false; + int width = 0; + int height = 0; + + while (textLength > 0) + { + objectType = pTextElement->GetType(); + + switch (objectType) + { + case TEXT_ELEMENT_TYPE_TEXT: + // fall through + case TEXT_ELEMENT_TYPE_CUTLINK: + { + TextSimple* pSimpleTextElement = dynamic_cast < TextSimple* >(pTextElement); + SysTryReturn(NID_GRP + , pSimpleTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text element."); + + int wordType = 0; + int currentTextLength = 0; + + wordType = pSimpleTextElement->GetWordLength(strSrcRelIndex, currentTextLength); + if (wordType == WORD_ENTER) + { + pCurrentUnknowTextWidthInfo->length -= currentTextLength; + + pTextElement->GetRegion(strSrcRelIndex, 1, width, height); + + EnterTextWidthInfo* pNewEnterTextWidthInfo = new (std::nothrow) EnterTextWidthInfo; + SysTryReturn(NID_GRP + , pNewEnterTextWidthInfo + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pNewEnterTextWidthInfo->type = TEXT_WIDTH_INFO_ENTER; + pNewEnterTextWidthInfo->length = currentTextLength; + pNewEnterTextWidthInfo->maxHeight = height; + + if (pReturnWordWidthInfoNode == null) + { + bool changecachedInfo = false; + + if (p_current_word_width_info_node == __pCachedWordWidthInfoNode) + { + changecachedInfo = true; + } + + pReturnWordWidthInfoNode = + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewEnterTextWidthInfo); + + if (changecachedInfo) + { + __pCachedWordWidthInfoNode = pReturnWordWidthInfoNode; + } + } + else + { + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewEnterTextWidthInfo); + } + + getDone = true; + } + else if (wordType == WORD_SPACE) + { + pCurrentUnknowTextWidthInfo->length--; + + pTextElement->GetRegion(strSrcRelIndex, 1, width, height); + + SpaceTextWidthInfo* pNewSpaceTextWidthInfo = new (std::nothrow) SpaceTextWidthInfo; + SysTryReturn(NID_GRP + , pNewSpaceTextWidthInfo + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pNewSpaceTextWidthInfo->type = TEXT_WIDTH_INFO_SPACE; + pNewSpaceTextWidthInfo->width = width; + pNewSpaceTextWidthInfo->maxHeight = height; + + if (pReturnWordWidthInfoNode == null) + { + bool changecachedInfo = false; + + if (p_current_word_width_info_node == __pCachedWordWidthInfoNode) + { + changecachedInfo = true; + } + + pReturnWordWidthInfoNode = TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewSpaceTextWidthInfo); + + if (changecachedInfo) + { + __pCachedWordWidthInfoNode = pReturnWordWidthInfoNode; + } + } + else + { + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewSpaceTextWidthInfo); + } + + currentLength--; + strSrcRelIndex++; + limitWidth -= width; + textLength--; + } + else + { + if (textLength < currentTextLength) + { + currentTextLength = textLength; + } + pCurrentUnknowTextWidthInfo->length -= currentTextLength; + + pTextElement->GetRegion(strSrcRelIndex, currentTextLength, width, height); + + WordTextWidthInfo* pNewWordTextWidthInfo = new (std::nothrow) WordTextWidthInfo; + SysTryReturn(NID_GRP + , pNewWordTextWidthInfo + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pNewWordTextWidthInfo->type = TEXT_WIDTH_INFO_WORD; + pNewWordTextWidthInfo->length = currentTextLength; + pNewWordTextWidthInfo->width = width; + pNewWordTextWidthInfo->maxHeight = height; + + if (pReturnWordWidthInfoNode == null) + { + bool changecachedInfo = false; + + if (p_current_word_width_info_node == __pCachedWordWidthInfoNode) + { + changecachedInfo = true; + } + + pReturnWordWidthInfoNode = + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewWordTextWidthInfo); + + if (changecachedInfo) + { + __pCachedWordWidthInfoNode = pReturnWordWidthInfoNode; + } + } + else + { + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewWordTextWidthInfo); + } + + currentLength -= currentTextLength; + strSrcRelIndex += currentTextLength; + limitWidth -= width; + textLength -= currentTextLength; + } + } + break; + + case TEXT_ELEMENT_TYPE_IMAGE: + { + pTextElement->GetRegion(0, 1, width, height); + + pCurrentUnknowTextWidthInfo->length--; + + SymbolTextWidthInfo* pNewSymbolTextWidthInfo = new (std::nothrow) SymbolTextWidthInfo; + SysTryReturn(NID_GRP + , pNewSymbolTextWidthInfo + , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + pNewSymbolTextWidthInfo->type = TEXT_WIDTH_INFO_SYMBOL; + pNewSymbolTextWidthInfo->width = width; + pNewSymbolTextWidthInfo->maxHeight = height; + + if (pReturnWordWidthInfoNode == null) + { + bool changecachedInfo = false; + + if (p_current_word_width_info_node == __pCachedWordWidthInfoNode) + { + changecachedInfo = true; + } + + pReturnWordWidthInfoNode = TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewSymbolTextWidthInfo); + + if (changecachedInfo) + { + __pCachedWordWidthInfoNode = pReturnWordWidthInfoNode; + } + } + else + { + TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, + pNewSymbolTextWidthInfo); + } + + getDone = true; + } + break; + + default: + return false; + } + + if (limitWidth <= 0) + { + break; + } + + if (getDone) + { + break; + } + + if (currentLength <= 0) + { + textElementIndex++; + pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex); + if (pTextElement == null) + { + break; + } + + strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + currentLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex; + } + } + + if (pCurrentUnknowTextWidthInfo->length == 0) + { + TextSimpleList::DeleteNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode); + } + + return pReturnWordWidthInfoNode; +} + +bool +TextWidthManager::AnalyzeNextTextWidthInfo(int limitWidth, bool& wordoverWidth, int& widthAnlyzed, int& strLengthAalyzed, + int& heightAnalzyed, bool& isnextKorean, bool& meetCutlink) +{ + widthAnlyzed = 0; + strLengthAalyzed = 0; + heightAnalzyed = 0; + wordoverWidth = false; + isnextKorean = false; + + TextWidthCommonInfo* pCurrentCommonTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentCommonTextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + int strCurrentTextWidthInfoLength = GetTextWidthInfoLength(pCurrentCommonTextWidthInfo); + + SimpleNode* pCurrentWordWidthInfoNode = __pCurrentWordWidthInfoNode->pNext; + if (pCurrentWordWidthInfoNode == null) + { + return false; + } + + pCurrentCommonTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentCommonTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + TextElement* pTextElement = __pCurrentComposeTextElement; + int textElementIndex = __currentComposeTextElementIndex; + int strSrcRelIndex = __strCurrentRelIndex; + int strTextElementLength = __currentTextElementLength; + + int seekLength = strCurrentTextWidthInfoLength; + + while (seekLength > 0) + { + if (seekLength < strTextElementLength) + { + strSrcRelIndex += seekLength; + strTextElementLength -= seekLength; + break; + } + + seekLength -= strTextElementLength; + + if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK) + { + meetCutlink = true; + + textElementIndex++; + pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex); + if (pTextElement == null) + { + break; + } + + break; + } + + textElementIndex++; + pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex); + if (pTextElement == null) + { + break; + } + + strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + strTextElementLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex; + + if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK) + { + meetCutlink = true; + break; + } + } + + int widthAnalyzed = 0; + int maxHeight = 0; + int stringAnalzyed = 0; + int widthLeft = limitWidth; + + int type = pCurrentCommonTextWidthInfo->type; + + while (((type == TEXT_WIDTH_INFO_WORD) || (type == TEXT_WIDTH_INFO_UNKNOWN)) && !meetCutlink) + { + SysTryReturn(NID_GRP + , pTextElement + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + int stringtoGo = 0; + if (type == TEXT_WIDTH_INFO_WORD) + { + WordTextWidthInfo* pWordTtextWidthInfo = static_cast < WordTextWidthInfo* >(pCurrentCommonTextWidthInfo); + SysTryReturn(NID_GRP + , pWordTtextWidthInfo + , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + if (widthLeft < pWordTtextWidthInfo->width) + { + if ((widthLeft <= 0) || (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)) + { + wordoverWidth = true; + break; + } + + int textLengthBeforeSplit = GetTextWidthInfoLength(static_cast < TextWidthCommonInfo* >(pCurrentWordWidthInfoNode->pObject)); + pWordTtextWidthInfo = SplitWordWidthInfo(pCurrentWordWidthInfoNode, pTextElement, strSrcRelIndex, + strTextElementLength, widthLeft, isnextKorean); + + if (textLengthBeforeSplit != pWordTtextWidthInfo->length) + { + widthAnalyzed += pWordTtextWidthInfo->width; + stringAnalzyed += pWordTtextWidthInfo->length; + if (pWordTtextWidthInfo->maxHeight > maxHeight) + { + maxHeight = pWordTtextWidthInfo->maxHeight; + } + } + + wordoverWidth = true; + break; + } + else + { + widthAnalyzed += pWordTtextWidthInfo->width; + widthLeft -= pWordTtextWidthInfo->width; + stringAnalzyed += pWordTtextWidthInfo->length; + if (pWordTtextWidthInfo->maxHeight > maxHeight) + { + maxHeight = pWordTtextWidthInfo->maxHeight; + } + + stringtoGo = pWordTtextWidthInfo->length; + } + } + else + { + SimpleNode* pNewSimpleNode = AnalyzeUnKnownTextWidthInfo(pCurrentWordWidthInfoNode, pTextElement, + strSrcRelIndex, strTextElementLength, widthLeft); + + SysTryReturn(NID_GRP + , pNewSimpleNode + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element node."); + + pCurrentWordWidthInfoNode = pNewSimpleNode; + pCurrentCommonTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentCommonTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + type = pCurrentCommonTextWidthInfo->type; + } + + if (stringtoGo > 0) + { + pCurrentWordWidthInfoNode = pCurrentWordWidthInfoNode->pNext; + if (pCurrentWordWidthInfoNode == null) + { + break; + } + + pCurrentCommonTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentWordWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentCommonTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element node."); + + type = pCurrentCommonTextWidthInfo->type; + + seekLength = stringtoGo; + + while (seekLength > 0) + { + if (seekLength < strTextElementLength) + { + strSrcRelIndex += seekLength; + strTextElementLength -= seekLength; + break; + } + + seekLength -= strTextElementLength; + + if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK) + { + textElementIndex++; + pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex); + if (pTextElement == null) + { + break; + } + + meetCutlink = true; + break; + } + + textElementIndex++; + pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex); + SysTryReturn(NID_GRP + , pTextElement + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element."); + + strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET); + strTextElementLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex; + + if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK) + { + meetCutlink = true; + break; + } + } + } + } + + widthAnlyzed = widthAnalyzed; + strLengthAalyzed = stringAnalzyed; + heightAnalzyed = maxHeight; + + return true; +} + +bool +TextWidthManager::UpdateCachedTextWidhtInfo(int textOffset, SimpleNode* pTextWidthInfoNode) +{ + __pCachedWordWidthInfoNode = pTextWidthInfoNode; + __textOffsetOfCachedWidthInfo = textOffset; + + return true; +} + +SimpleNode* +TextWidthManager::SearchTextWidthInfo(int textIndex, int& widthInfoTextOffset) +{ + SimpleNode* pCurrentTextWidthInfoNode = __pCachedWordWidthInfoNode; + int currentWidthInfoTextOffset = __textOffsetOfCachedWidthInfo; + + if (pCurrentTextWidthInfoNode == null) + { + pCurrentTextWidthInfoNode = TextSimpleList::GetNthNode(__pTextWidthInfoList, 0); + currentWidthInfoTextOffset = 0; + } + + if (pCurrentTextWidthInfoNode == null) + { + widthInfoTextOffset = 0; + return null; + } + + TextWidthCommonInfo* pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + if (currentWidthInfoTextOffset < textIndex) + { + int currentWidthInfoTextLength = GetTextWidthInfoLength(pCurrentTextWidthInfo); + + while (currentWidthInfoTextOffset + currentWidthInfoTextLength <= textIndex) + { + pCurrentTextWidthInfoNode = pCurrentTextWidthInfoNode->pNext; + SysTryReturn(NID_GRP + , pCurrentTextWidthInfoNode + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width."); + + currentWidthInfoTextOffset += currentWidthInfoTextLength; + pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information."); + + currentWidthInfoTextLength = GetTextWidthInfoLength(pCurrentTextWidthInfo); + } + } + else if (textIndex < currentWidthInfoTextOffset) + { + pCurrentTextWidthInfoNode = pCurrentTextWidthInfoNode->pPrev; + + SysTryReturn(NID_GRP + , pCurrentTextWidthInfoNode + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width."); + + pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width."); + + currentWidthInfoTextOffset -= GetTextWidthInfoLength(pCurrentTextWidthInfo); + + while (textIndex < currentWidthInfoTextOffset) + { + pCurrentTextWidthInfoNode = pCurrentTextWidthInfoNode->pPrev; + + SysTryReturn(NID_GRP + , pCurrentTextWidthInfoNode + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width."); + + pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject); + SysTryReturn(NID_GRP + , pCurrentTextWidthInfo + , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width."); + + currentWidthInfoTextOffset -= GetTextWidthInfoLength(pCurrentTextWidthInfo); + } + } + + widthInfoTextOffset = currentWidthInfoTextOffset; + + return pCurrentTextWidthInfoNode; +} + +bool +TextWidthManager::IsKorean(wchar_t ch) +{ + bool r = false; + + if (0xAC00 <= ch && ch <= 0xD7A3) + { + r = true; + } + else if (0x3130 <= ch && ch <= 0x318F) + { + r = true; + } + else if (0x1100 <= ch && ch <= 0x11FF) + { + r = true; + } + else if (0X2E80 <= ch && ch <= 0x2FFF) + { + r = true; + } + else if (0x3220 <= ch && ch <= 0x3243) + { + r = true; + } + else if (0x3280 <= ch && ch <= 0x32CB) + { + r = true; + } + else if (0x3400 <= ch && ch <= 0x4DBF) + { + r = true; + } + else if (0x4E00 <= ch && ch <= 0x9FFF) + { + r = true; + } + else if (0xF900 <= ch && ch <= 0xFAFF) + { + r = true; + } + + return r; +} + +}}} // Tizen::Graphics::_Text diff --git a/src/graphics/text/FGrp_TextTextWidthManager.h b/src/graphics/text/FGrp_TextTextWidthManager.h new file mode 100644 index 0000000..84298f6 --- /dev/null +++ b/src/graphics/text/FGrp_TextTextWidthManager.h @@ -0,0 +1,120 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_TextTextWidthManager.h + * @brief This is the header file for the TextWidthManager class. + * + * This header file contains the declarations of the %TextWidthManager class. + */ + +#ifndef _FGRP_INTERNAL_TEXT_WIDTH_MANAGER_H_ +#define _FGRP_INTERNAL_TEXT_WIDTH_MANAGER_H_ + +#include "FGrp_TextCommon.h" +#include "FGrp_TextTextElement.h" +#include "FGrp_TextTextSimpleList.h" + +namespace Tizen { namespace Graphics +{ + +namespace _Text +{ + +struct TextWidthCommonInfo; +struct WordTextWidthInfo; + +struct TextLineComposeInfo +{ + int length; + int width; + int height; + int endType; +}; + +class TextWidthManager +{ +public: + TextWidthManager(TextComposite* pCompositeText); + + virtual ~TextWidthManager(void); + +public: + bool Initialize(int textLength); + + bool Finalize(void); + + bool StartCompose(int textIndex); + + bool GetCurrentLineInfo(int lineWidth, TextLineComposeInfo& textLineComposeInfo); + + bool EndCompose(void); + + bool InformTextInsert(int textIndex, int textLength); + + bool InformTextRemove(int textIndex, int textLength); + +private: + SimpleNode* SplitWidthInfo(SimpleNode* pOrginalTextWidhtInfoNode, int splitStartIndex, TextWidthCommonInfo* pTextWidthInfo); + + WordTextWidthInfo* SplitCurrentWordWidthInfo(int limitWidth, bool& isNextKoreanStart); + + WordTextWidthInfo* SplitWordWidthInfo(SimpleNode* pCurrentWordWidthInfoNode, TextElement* pCurrentTextElement, int strCurrentRelIndex, int strCurrentLength, int limitWidth, bool& isNextKoreanStart); + + bool Seek(int textLength); + + bool AnalyzeCurrentUnKnownTextWidthInfo(int limitWidth); + + SimpleNode* AnalyzeUnKnownTextWidthInfo(SimpleNode* pCurrentWordWidthInfoNode, TextElement* pCurrentTextElement, int strCurrentRelIndex, int strCurrentLength, int limitWidth); + + bool AnalyzeNextTextWidthInfo(int limitWidth, bool& wordoverWidth, int& widthAnlyzed, int& strLengthAalyzed, int& heightAnalzyed, bool& isnextKorean, bool& meetCutlink); + + bool UpdateCachedTextWidhtInfo(int widthInfoTextOffset, SimpleNode* pTextWidthInfoNode); + + SimpleNode* SearchTextWidthInfo(int textIndex, int& widthInfoTextOffset); + + bool IsKorean(wchar_t strChar); + + int GetTextWidthInfoLength(TextWidthCommonInfo* pTextWidthCommonInfo); + +private: + TextComposite* __pCompositeText; + TextElement* __pCurrentComposeTextElement; + TextElementType __currentTextElementType; + int __currentComposeTextElementIndex; + SimpleNode* __pCurrentWordWidthInfoNode; + SimpleNode* __pCachedWordWidthInfoNode; + SimpleList* __pTextWidthInfoList; + bool __isInitialized; + bool __isComposing; + int __length; + int __currentTextIndex; + int __strCurrentRelIndex; + int __currentTextElementLength; + int __textOffsetOfCurrentWidthInfo; + int __textOffsetOfCachedWidthInfo; + +private: + TextWidthManager(const TextWidthManager& other); // NOT IMPLMENTED + + TextWidthManager& operator =(const TextWidthManager& rhs); // NOT IMPLMENTED + +}; // TextWidthManager + +}}} // Tizen::Graphics::_Text + +#endif // _FGRP_INTERNAL_TEXT_WIDTH_MANAGER_H_ diff --git a/src/graphics/util/FGrp_Util.cpp b/src/graphics/util/FGrp_Util.cpp new file mode 100644 index 0000000..336115b --- /dev/null +++ b/src/graphics/util/FGrp_Util.cpp @@ -0,0 +1,515 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Util.cpp + * @brief This is the implementation file for internal util class. + * + */ + +#include + +#include + +#include "FGrp_BitmapImpl.h" +#include "../FGrp_Canvas.h" +#include "../FGrp_Bitmap.h" +#include "FGrp_Util.h" +#include "../effect/FGrp_Effect.h" + + +using namespace Tizen::Base; + +namespace Tizen { namespace Graphics +{ + +namespace _Util +{ + +template +bool +IntersectGeneralRect(Rectangle& outRect, const Rectangle& srcRect1, const Rectangle& srcRect2) +{ + typedef T Type; + + struct TBound + { + Type x1, y1, x2, y2; + TBound(const Rectangle& rect) + : x1(rect.x) + , y1(rect.y) + , x2(rect.x + rect.w) + , y2(rect.y + rect.h) {} + }; + + TBound srcBound1(srcRect1); + TBound srcBound2(srcRect2); + + if (((srcRect1.w > 0 && srcRect1.h > 0) && (srcRect2.w > 0 && srcRect2.h > 0)) + && ((srcBound2.x2 > srcBound1.x1) && (srcBound2.x1 < srcBound1.x2) && (srcBound2.y2 > srcBound1.y1) && + (srcBound2.y1 < srcBound1.y2))) + { + outRect.x = (srcBound2.x1 <= srcBound1.x1) ? srcBound1.x1 : srcBound2.x1; + outRect.y = (srcBound2.y1 <= srcBound1.y1) ? srcBound1.y1 : srcBound2.y1; + outRect.w = ((srcBound2.x2 >= srcBound1.x2) ? srcBound1.x2 : srcBound2.x2) - outRect.x; + outRect.h = ((srcBound2.y2 >= srcBound1.y2) ? srcBound1.y2 : srcBound2.y2) - outRect.y; + + return true; + } + else + { + outRect.x = 0; + outRect.y = 0; + outRect.w = 0; + outRect.h = 0; + + return false; + } +} + +} // _Util + +result +_Util::Validate(const ::Tizen::Graphics::Rectangle& rtSrc, const ::Tizen::Graphics::Rectangle& rtDest) +{ + // check 1. is width/height less or equal than 0? + if (rtSrc.width <= 0 || rtSrc.height <= 0 || rtDest.width <= 0 || rtDest.height <= 0) + { + SysTryReturnResult(NID_GRP, 0, E_OUT_OF_RANGE, "The argument is out of range. (src(w:%d,h:%d), dst(w:%d,h:%d)).\n", + rtSrc.width, rtSrc.height, rtDest.width, + rtDest.height); + } + + // check 2. is src exiting outside of dest entirely? + if (rtSrc.x > rtDest.x + rtDest.width - 1 || + rtSrc.x + rtSrc.width - 1 < rtDest.x) + { + SysTryReturnResult(NID_GRP, 0, E_OUT_OF_RANGE, + "The argument is out of range. (src(x:%d,y:%d,w:%d,h:%d), dst(x:%d,y:%d,w:%d,h:%d)).\n", + rtSrc.x, + rtSrc.y, rtSrc.width, rtSrc.height, rtDest.x, rtDest.y, rtDest.width, + rtDest.height); + } + + if (rtSrc.y > rtDest.y + rtDest.height - 1 || + rtSrc.y + rtSrc.height - 1 < rtDest.y) + { + SysTryReturnResult(NID_GRP, 0, E_OUT_OF_RANGE, + "The argument is out of range. (src(x:%d,y:%d,w:%d,h:%d), dst(x:%d,y:%d,w:%d,h:%d)).\n", + rtSrc.x, + rtSrc.y, rtSrc.width, rtSrc.height, rtDest.x, rtDest.y, rtDest.width, + rtDest.height); + } + + return E_SUCCESS; +} + +result +_Util::Validate(const ::Tizen::Graphics::Point& ptSrc, const ::Tizen::Graphics::Rectangle& rtDest) +{ + SysTryReturnResult(NID_GRP, rtDest.x <= ptSrc.x && + ptSrc.x < rtDest.x + rtDest.width && + rtDest.y <= ptSrc.y && + ptSrc.y < rtDest.y + rtDest.height, + E_OUT_OF_RANGE, "The argument is out of range. (src(x:%d,y:%d), dst(x:%d,y:%d,w:%d,h:%d)).\n", + ptSrc.x, ptSrc.y, rtDest.x, rtDest.y, rtDest.width, + rtDest.height); + + return E_SUCCESS; +} + +bool +_Util::IntersectRect(Rectangle& outRect, const Rectangle& srcRect1, const Rectangle& srcRect2) +{ + return _Util::IntersectGeneralRect(outRect, srcRect1, srcRect2); +} + +bool +_Util::IntersectRect(Rectangle& outRect, const Rectangle& srcRect1, const Rectangle& srcRect2) +{ + return _Util::IntersectGeneralRect(outRect, srcRect1, srcRect2); +} + +//////////////////////////////////////////////////////////////////////////////// +// LockManager class + +_Util::LockManager::LockManager(const _Bitmap& bitmap) + : __pBitmap(const_cast <_Bitmap*>(&bitmap)) + , __pCanvas(null) + , __pBitmapImpl(null) + , __pCanvasImpl(null) +{ + if ((__result = __pBitmap->Lock(__bufferInfo)) != E_SUCCESS) + { + __pBitmap = null; + } +} + +_Util::LockManager::LockManager(const _Canvas& canvas) + : __pBitmap(null) + , __pCanvas(const_cast <_Canvas*>(&canvas)) + , __pBitmapImpl(null) + , __pCanvasImpl(null) +{ + if ((__result = __pCanvas->Lock(__bufferInfo)) != E_SUCCESS) + { + __pCanvas = null; + } +} + +_Util::LockManager::LockManager(const class _BitmapImpl& bitmapImpl) + : __pBitmap(null) + , __pCanvas(null) + , __pBitmapImpl(const_cast <_BitmapImpl*>(&bitmapImpl)) + , __pCanvasImpl(null) +{ + if ((__result = __pBitmapImpl->Lock(__bufferInfo)) != E_SUCCESS) + { + __pBitmapImpl = null; + } +} + +_Util::LockManager::LockManager(const class _CanvasImpl& canvasImpl) + : __pBitmap(null) + , __pCanvas(null) + , __pBitmapImpl(null) + , __pCanvasImpl(const_cast <_CanvasImpl*>(&canvasImpl)) +{ + if ((__result = __pCanvasImpl->Lock(__bufferInfo)) != E_SUCCESS) + { + __pCanvasImpl = null; + } +} + +_Util::LockManager::~LockManager() +{ + if (__pBitmapImpl) + { + __pBitmapImpl->Unlock(); + } + + if (__pCanvasImpl) + { + __pCanvasImpl->Unlock(); + } + + if (__pBitmap) + { + __pBitmap->Unlock(); + } + + if (__pCanvas) + { + __pCanvas->Unlock(); + } +} + +bool +_Util::LockManager::IsValid(void) const +{ + return (__pBitmap || __pCanvas || __pBitmapImpl || __pCanvasImpl); +} + +result +_Util::LockManager::GetResult(void) const +{ + return __result; +} + +const BufferInfo& +_Util::LockManager::GetBufferInfo(void) const +{ + return __bufferInfo; +} + +//////////////////////////////////////////////////////////////////////////////// +// GetPatchList() function + +namespace // unnamed +{ + +template +struct _NinePatchedKey +{ +}; + +template<> +struct _NinePatchedKey +{ + enum + { + KEY = 0xFF000000 + }; +}; + +template<> +struct _NinePatchedKey +{ + enum + { + KEY = 0x0000 + }; +}; + +template +int +_FindWidthOfSubregions(const _Util::Pixmap& dstImage, int pRegionWidthes[], bool pWidthStretchable[]) +{ + enum + { + KEY = _NinePatchedKey ::KEY + }; + + if (dstImage.depth != sizeof(Pixel) * 8) + { + return 0; + } + + // find a set of width + int index = 0; + Pixel* pProbe = (Pixel*) (dstImage.pBitmap) + 1; + Pixel* pProbeNext = pProbe + 1; + Pixel* pProbeEnd = pProbe + dstImage.width - 1; + + while (pProbeNext < pProbeEnd) + { + pRegionWidthes[index]++; + + if (((*pProbe == KEY) && (*pProbeNext != KEY)) || ((*pProbe != KEY) && (*pProbeNext == KEY))) + { + pWidthStretchable[index] = (*pProbe == KEY) ? true : false; + index++; + } + + pProbe++; + pProbeNext++; + } +// pRegionWidthes[index]++; + + return (index + 1); +} + +template +int +_FindHeightOfSubregions(const _Util::Pixmap& dstImage, int pRegionHeights[], bool pHeightStretchable[]) +{ + enum + { + KEY = _NinePatchedKey ::KEY + }; + + if (dstImage.depth != sizeof(Pixel) * 8) + { + return 0; + } + + // find a set of height + int index = 0; + int pitch = dstImage.bytesPerLine / (dstImage.depth / 8); + Pixel* pProbe = (Pixel*) (dstImage.pBitmap) + pitch; + Pixel* pProbeNext = pProbe + pitch; + Pixel* pProbeEnd = pProbe + (dstImage.height - 1) * pitch; + + while (pProbeNext < pProbeEnd) + { + pRegionHeights[index]++; + + if (((*pProbe == KEY) && (*pProbeNext != KEY)) || ((*pProbe != KEY) && (*pProbeNext == KEY))) + { + pHeightStretchable[index] = (*pProbe == KEY) ? true : false; + index++; + } + + pProbe += pitch; + pProbeNext += pitch; + } +// pRegionHeights[index]++; + + return (index + 1); +} + +} + +result +_Util::GetPatchList(_Util::AccumList <_Util::Pair <_Util::Rectangle, _Util::Rectangle > >& outList, const ::Tizen::Graphics::Rectangle& rect, const _Bitmap& bitmap) +{ + // 1. Find withes and heights of stretchable/unstretchable regions. + _Util::LockManager srcLock(bitmap); + SysTryReturnResult(NID_GRP, srcLock.IsValid(), E_OPERATION_FAILED, "The source bitmap cannot be locked.\n"); + + const BufferInfo& srcBufferInfo = srcLock.GetBufferInfo(); + _Util::Pixmap srcImage(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, + srcBufferInfo.pitch); + // APPLY_SRC_BITMAP_ATTRIB(srcImage, bitmap); + + std::unique_ptr pRegionWidthes(new (std::nothrow) int[srcImage.width]); + SysTryReturnResult(NID_GRP, pRegionWidthes, E_OUT_OF_MEMORY, "Fails to allocate memory.\n"); + + std::unique_ptr pWidthStretchable(new (std::nothrow) bool[srcImage.width]); + SysTryReturnResult(NID_GRP, pWidthStretchable, E_OUT_OF_MEMORY, "Fails to allocate memory.\n"); + + memset(pRegionWidthes.get(), 0, sizeof(int) * srcImage.width); + memset(pWidthStretchable.get(), 0, sizeof(bool) * srcImage.width); + + std::unique_ptr pRegionHeights(new (std::nothrow) int[srcImage.height]); + SysTryReturnResult(NID_GRP, pRegionHeights, E_OUT_OF_MEMORY, "Fails to allocate memory.\n"); + + std::unique_ptr pHeightStretchable(new (std::nothrow) bool[srcImage.height]); + SysTryReturnResult(NID_GRP, pHeightStretchable, E_OUT_OF_MEMORY, "Fails to allocate memory.\n"); + + memset(pRegionHeights.get(), 0, sizeof(int) * srcImage.height); + memset(pHeightStretchable.get(), 0, sizeof(bool) * srcImage.height); + + int numWidth = 0; + int numHeight = 0; + + switch (srcImage.depth) + { + case 32: + numWidth = _FindWidthOfSubregions (srcImage, pRegionWidthes.get(), pWidthStretchable.get()); + numHeight = _FindHeightOfSubregions (srcImage, pRegionHeights.get(), pHeightStretchable.get()); + break; + + case 16: + numWidth = _FindWidthOfSubregions (srcImage, pRegionWidthes.get(), pWidthStretchable.get()); + numHeight = _FindHeightOfSubregions (srcImage, pRegionHeights.get(), pHeightStretchable.get()); + break; + } + SysTryReturnResult(NID_GRP, numWidth > 0 && numHeight > 0, E_OPERATION_FAILED, + "The source bitmap is not allowable for NintPatchedBitmap.\n"); + + // 2. Split source image into separate stretchable/unstretchable regions. + std::unique_ptr< ::Tizen::Graphics::Rectangle[]> pSrcRectLists(new (std::nothrow) ::Tizen::Graphics::Rectangle[numWidth * numHeight]); + SysTryReturnResult(NID_GRP, pSrcRectLists, E_OUT_OF_MEMORY, "Fails to allocate memory.\n"); + + int vertical = 0; + int horizontal = 0; + int index = 0; + + for (horizontal = 0; horizontal < numHeight; horizontal++) + { + pSrcRectLists[index].x = 1; + pSrcRectLists[index].y = + (horizontal == 0) ? 1 : pSrcRectLists[index - numWidth].y + pSrcRectLists[index - numWidth].height; + pSrcRectLists[index].width = pRegionWidthes[0]; + pSrcRectLists[index].height = pRegionHeights[horizontal]; + index++; + + for (vertical = 1; vertical < numWidth; vertical++) + { + pSrcRectLists[index].x = pSrcRectLists[index - 1].x + pSrcRectLists[index - 1].width; + pSrcRectLists[index].y = pSrcRectLists[index - 1].y; + pSrcRectLists[index].width = pRegionWidthes[vertical]; + pSrcRectLists[index].height = pSrcRectLists[index - 1].height; + index++; + } + } + + // 3. Calculate stretchable/unstretchable regions of the target size. + int sumWidthSrcStretchableRegions = 0; + int sumHeightSrcStretchableRegions = 0; + + for (vertical = 0; vertical < numWidth; vertical++) + { + if (pWidthStretchable[vertical]) + { + sumWidthSrcStretchableRegions += pRegionWidthes[vertical]; + } + } + + for (horizontal = 0; horizontal < numHeight; horizontal++) + { + if (pHeightStretchable[horizontal]) + { + sumHeightSrcStretchableRegions += pRegionHeights[horizontal]; + } + } + + int sumWidthDstStretchableRegions = rect.width - ((srcImage.width - 2) - sumWidthSrcStretchableRegions); + int sumHeightDstStretchableRegions = rect.height - ((srcImage.height - 2) - sumHeightSrcStretchableRegions); + + for (vertical = 0; vertical < numWidth; vertical++) + { + if (pWidthStretchable[vertical]) + { + pRegionWidthes[vertical] = + int(float(sumWidthDstStretchableRegions) * float(pRegionWidthes[vertical]) / + float(sumWidthSrcStretchableRegions) + 0.5f); + } + } + + for (horizontal = 0; horizontal < numHeight; horizontal++) + { + if (pHeightStretchable[horizontal]) + { + pRegionHeights[horizontal] = + int(float(sumHeightDstStretchableRegions) * float(pRegionHeights[horizontal]) / + float(sumHeightSrcStretchableRegions) + 0.5f); + } + } + + std::unique_ptr< ::Tizen::Graphics::Rectangle[]> pDstRectLists(new (std::nothrow) ::Tizen::Graphics::Rectangle[numWidth * numHeight]); + SysTryReturnResult(NID_GRP, pDstRectLists, E_OUT_OF_MEMORY, "Fails to allocate memory.\n"); + + index = 0; + + for (horizontal = 0; horizontal < numHeight; horizontal++) + { + pDstRectLists[index].x = rect.x; + pDstRectLists[index].y = (horizontal == 0) ? rect.y : pDstRectLists[index - numWidth].y + pDstRectLists[index - numWidth].height; + pDstRectLists[index].width = pRegionWidthes[0]; + pDstRectLists[index].height = pRegionHeights[horizontal]; + index++; + + for (vertical = 1; vertical < numWidth; vertical++) + { + pDstRectLists[index].x = pDstRectLists[index - 1].x + pDstRectLists[index - 1].width; + pDstRectLists[index].y = pDstRectLists[index - 1].y; + pDstRectLists[index].width = pRegionWidthes[vertical]; + pDstRectLists[index].height = pDstRectLists[index - 1].height; + index++; + } + } + + // 4. Record stretchable/unstretchable regions of bitmap to list. + outList.Clear(); + + for (index = 0; index < numWidth * numHeight; index++) + { + _Util::Rectangle destRect = + { + pDstRectLists[index].x, + pDstRectLists[index].y, + pDstRectLists[index].width, + pDstRectLists[index].height + }; + + _Util::Rectangle sourRect = + { + pSrcRectLists[index].x, + pSrcRectLists[index].y, + pSrcRectLists[index].width, + pSrcRectLists[index].height + }; + + outList.Push(_Util::MakePair(destRect, sourRect)); + } + + return E_SUCCESS; +} + +}} // Tizen::Graphics diff --git a/src/graphics/util/FGrp_Util.h b/src/graphics/util/FGrp_Util.h new file mode 100644 index 0000000..747b0c5 --- /dev/null +++ b/src/graphics/util/FGrp_Util.h @@ -0,0 +1,338 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_Util.h + * @brief This is the header file for internal _Util namespace. + * + */ + +#ifndef _FGRP_INTERNAL_UTIL_H_ +#define _FGRP_INTERNAL_UTIL_H_ + +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "FGrp_BitmapImpl.h" +#include "FGrp_CanvasImpl.h" +#include "FGrp_FontImpl.h" +#include "FGrp_EnrichedTextImpl.h" + +#include "FGrp_UtilTemplate.h" +#include "FGrp_UtilType.h" + + +namespace Tizen { namespace Graphics +{ +class Point; + +class _Bitmap; +class _Canvas; + +namespace _Util +{ + +result Validate(const ::Tizen::Graphics::Rectangle& rtSrc, const ::Tizen::Graphics::Rectangle& rtDest); +result Validate(const ::Tizen::Graphics::Point& ptSrc, const ::Tizen::Graphics::Rectangle& rtDest); + +template +result ValidateT(const Rectangle& rtSrc, const Rectangle& rtDest) +{ + // check 1. is width/height less or equal than 0? + if (rtSrc.w <= 0 || rtSrc.h <= 0 || rtDest.w <= 0 || rtDest.h <= 0) + { + SysTryReturnResult(NID_GRP, 0, E_OUT_OF_RANGE, "The argument is out of range. (src(w:%d,h:%d), dst(w:%d,h:%d)).", + rtSrc.w, rtSrc.h, rtDest.w, rtDest.h); + } + + // check 2. is src exiting outside of dest entirely? + if (rtSrc.x > rtDest.x + rtDest.w - 1 || rtSrc.x + rtSrc.w - 1 < rtDest.x) + { + SysTryReturnResult(NID_GRP, 0, E_OUT_OF_RANGE, + "The argument is out of range. (src(x:%d,y:%d,w:%d,h:%d), dst(x:%d,y:%d,w:%d,h:%d)).", + rtSrc.x, rtSrc.y, rtSrc.w, rtSrc.h, rtDest.x, rtDest.y, rtDest.w, rtDest.h); + } + + if (rtSrc.y > rtDest.y + rtDest.h - 1 || rtSrc.y + rtSrc.h - 1 < rtDest.y) + { + SysTryReturnResult(NID_GRP, 0, E_OUT_OF_RANGE, + "The argument is out of range. (src(x:%d,y:%d,w:%d,h:%d), dst(x:%d,y:%d,w:%d,h:%d)).", + rtSrc.x, rtSrc.y, rtSrc.w, rtSrc.h, rtDest.x, rtDest.y, rtDest.w, rtDest.h); + } + + return E_SUCCESS; +} + +template +result ValidateT(const Point& ptSrc, const Rectangle& rtDest) +{ + SysTryReturnResult(NID_GRP, rtDest.x <= ptSrc.x && + ptSrc.x < rtDest.x + rtDest.w && + rtDest.y <= ptSrc.y && + ptSrc.y < rtDest.y + rtDest.h, + E_OUT_OF_RANGE, "The argument is out of range. (src(x:%d,y:%d), dst(x:%d,y:%d,w:%d,h:%d)).\n", + ptSrc.x, ptSrc.y, rtDest.x, rtDest.y, rtDest.w, rtDest.h); + + return E_SUCCESS; +} + +bool IntersectRect(Rectangle& outRect, const Rectangle& srcRect1, const Rectangle& srcRect2); +bool IntersectRect(Rectangle& outRect, const Rectangle& srcRect1, const Rectangle& srcRect2); + +//////////////////////////////////////////////////////////////////////////// +// LockManager class + +class LockManager +{ +public: + LockManager(const class _Bitmap& bitmap); + LockManager(const class _Canvas& canvas); + LockManager(const class _BitmapImpl& bitmapImpl); + LockManager(const class _CanvasImpl& canvasImpl); + ~LockManager(); + + bool IsValid(void) const; + result GetResult(void) const; + const BufferInfo& GetBufferInfo(void) const; + +private: + result __result; + + _Bitmap* __pBitmap; + _Canvas* __pCanvas; + _BitmapImpl* __pBitmapImpl; + _CanvasImpl* __pCanvasImpl; + BufferInfo __bufferInfo; +}; // LockManager + +//////////////////////////////////////////////////////////////////////////// +// ScalarHolder structure + +struct ScalarHolder +{ + enum + { + AS_INTEGER, + AS_DOUBLE, + } applied; + + int asInteger; + double asDouble; + + ScalarHolder(int initValue) + : applied(AS_INTEGER) + , asInteger(initValue) + , asDouble(double(initValue)) + { + } + + ScalarHolder(double initValue) + : applied(AS_DOUBLE) + , asInteger(int(initValue + 0.5)) + , asDouble(initValue) + { + } + + int operator=(int value) + { + applied = AS_INTEGER; + asInteger = value; + asDouble = double(value); + + return value; + } + + double operator=(double value) + { + applied = AS_DOUBLE; + asInteger = int(value + 0.5); + asDouble = value; + + return value; + } +}; // ScalarHolder + +//////////////////////////////////////////////////////////////////////////// +// Utility function + +result GetPatchList(AccumList , Rectangle > >& outList, const ::Tizen::Graphics::Rectangle& rect, const _Bitmap& bitmap); + +//////////////////////////////////////////////////////////////////////////// +// Validity check + +template +inline bool +CheckValidity(T* pInstance) +{ + return (pInstance != null); +} + +template<> +inline bool +CheckValidity(const Bitmap* pInstance) +{ + return (pInstance && _BitmapImpl::GetInstance(*pInstance)); +} + +template<> +inline bool +CheckValidity(Bitmap* pInstance) +{ + return (pInstance && _BitmapImpl::GetInstance(*pInstance)); +} + +template<> +inline bool +CheckValidity(const Canvas* pInstance) +{ + return (pInstance && _CanvasImpl::GetInstance(*pInstance)); +} + +template<> +inline bool +CheckValidity(Canvas* pInstance) +{ + return (pInstance && _CanvasImpl::GetInstance(*pInstance)); +} + +template<> +inline bool +CheckValidity(const Font* pInstance) +{ + return (pInstance && _FontImpl::GetInstance(*pInstance)); +} + +template<> +inline bool +CheckValidity(Font* pInstance) +{ + return (pInstance && _FontImpl::GetInstance(*pInstance)); +} + +template<> +inline bool +CheckValidity(const EnrichedText* pInstance) +{ + return (pInstance && _EnrichedTextImpl::GetInstance(*pInstance)); +} + +template<> +inline bool +CheckValidity(EnrichedText* pInstance) +{ + return (pInstance && _EnrichedTextImpl::GetInstance(*pInstance)); +} + +//////////////////////////////////////////////////////////////////////////// +// Convertor + +template +inline T2 Convert(const T1&); + +template <> +inline _Util::Point Convert >(const Tizen::Graphics::Point& pos) +{ + _Util::Point temp = + { + pos.x, + pos.y + }; + + return temp; +} + +template <> +inline _Util::Point Convert >(const Tizen::Graphics::Point& pos) +{ + _Util::Point temp = + { + static_cast(pos.x), + static_cast(pos.y) + }; + + return temp; +} + +template <> +inline _Util::Point Convert >(const Tizen::Graphics::FloatPoint& pos) +{ + _Util::Point temp = { pos.x, pos.y }; + + return temp; +} + +template <> +inline _Util::Dimension Convert >(const Tizen::Graphics::Dimension& dim) +{ + _Util::Dimension temp = + { + static_cast(dim.width), + static_cast(dim.height) + }; + + return temp; +} + +template <> +inline _Util::Dimension Convert >(const Tizen::Graphics::FloatDimension& dim) +{ + _Util::Dimension temp = { dim.width, dim.height }; + + return temp; +} + +template <> +inline _Util::Rectangle Convert >(const Tizen::Graphics::Rectangle& rect) +{ + _Util::Rectangle temp = + { + static_cast(rect.x), + static_cast(rect.y), + static_cast(rect.width), + static_cast(rect.height) + }; + + return temp; +} + +template <> +inline _Util::Rectangle Convert >(const Tizen::Graphics::FloatRectangle& rect) +{ + _Util::Rectangle temp = { rect.x, rect.y, rect.width, rect.height }; + + return temp; +} + +} // Tizen::Graphics::_Util + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_UTIL_H_ diff --git a/src/graphics/util/FGrp_UtilPixmap.cpp b/src/graphics/util/FGrp_UtilPixmap.cpp new file mode 100644 index 0000000..c086cb1 --- /dev/null +++ b/src/graphics/util/FGrp_UtilPixmap.cpp @@ -0,0 +1,449 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_UtilPixmap.cpp + * @brief This is the implementation file for internal util class. + * + */ + +#include +#include +#include + +#include + +#include +#include + +#include "FGrp_UtilTemplate.h" +#include "FGrp_UtilPixmap.h" + +using namespace Tizen::Graphics; + +//////////////////////////////////////////////////////////////////////////////// +// image manipulation + +_Util::Pixmap::Pixmap() +{ + type = 0; + width = 0; + height = 0; + depth = 0; + bytesPerLine = 0, + enableColorKey = false; + colorKey = 0; + enableReplaceColor = false; + replaceColor = 0; + isOpaque = 0; + isPremultiplied = 0; + pBitmap = 0; + reserved = 0; +} + +_Util::Pixmap::Pixmap(int _width, int _height, int _depth, int _bytesPerLine) +{ + type = 0; + width = _width; + height = _height; + depth = _depth; + bytesPerLine = _bytesPerLine, + enableColorKey = false; + colorKey = 0; + enableReplaceColor = false; + replaceColor = 0; + isOpaque = 0; + isPremultiplied = 0; + pBitmap = 0; + reserved = 0; + + if (bytesPerLine == 0) + { + bytesPerLine = width * depth / 8; + } + + pBitmap = new (std::nothrow) unsigned char[bytesPerLine * height]; + + SysTryReturnVoidResult(NID_GRP, pBitmap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + // ¸ðµç °ÍÀÌ ¼º°øÇßÀ» ¶§¸¸ 1ÀÇ °ªÀ» °¡Áö°Ô µÈ´Ù. + reserved = 1; +} + +_Util::Pixmap::Pixmap(int _width, int _height, int _depth, void* _pBitmap, int _bytesPerLine) +{ + type = 0; + width = _width; + height = _height; + depth = _depth; + bytesPerLine = _bytesPerLine, + enableColorKey = false; + colorKey = 0; + enableReplaceColor = false; + replaceColor = 0; + isOpaque = 0; + isPremultiplied = 0; + pBitmap = (unsigned char*) _pBitmap; + reserved = 0; + + if (bytesPerLine == 0) + { + bytesPerLine = width * depth / 8; + } +} + +_Util::Pixmap::Pixmap(PixmapBase& refImage) +{ + memcpy(this, &refImage, sizeof(*this)); + refImage.reserved = 0; +} + +_Util::Pixmap::Pixmap(const PixmapBase& refImage) +{ + memcpy(this, &refImage, sizeof(*this)); + this->reserved = 0; +} + +_Util::Pixmap::Pixmap(const Pixmap& refImage) +{ + memcpy(this, &refImage, sizeof(*this)); + this->reserved = 0; +} + +_Util::Pixmap::~Pixmap() +{ + if (reserved) + { + delete[] pBitmap; + } +} + +_Util::Pixmap& +_Util::Pixmap::operator =(const Pixmap& refImage) +{ + if (this == &refImage) + { + return *this; + } + + PixmapBase::operator =(refImage); + + refImage.reserved = 0; + + return *this; +} + +_Util::PixmapBase +_Util::Pixmap::GetSubBitmap(long x, long y, long w, long h) const +{ + int x1 = x; + int y1 = y; + int x2 = x + w; + int y2 = y + h; + + x1 = (x1 < 0) ? 0 : x1; + y1 = (y1 < 0) ? 0 : y1; + x2 = (x2 > width) ? width : x2; + y2 = (y2 > height) ? height : y2; + + PixmapBase retImage((PixmapBase &) * this); + ((PixmapBase*) this)->reserved = retImage.reserved; + retImage.reserved = 0; + + retImage.pBitmap += retImage.bytesPerLine * y1 + x1 * depth / 8; + retImage.width = x2 - x1; + retImage.height = y2 - y1; + + return retImage; +} + +_Util::PixmapBase +_Util::Pixmap::GetSubBitmapUnsafe(long x, long y, long w, long h) const +{ + PixmapBase retImage((PixmapBase &) * this); + ((PixmapBase*) this)->reserved = retImage.reserved; + retImage.reserved = 0; + + retImage.pBitmap += retImage.bytesPerLine * y + x * depth / 8; + retImage.width = w; + retImage.height = h; + + return retImage; +} + +namespace // unnamed +{ + +template +inline DestPixel* +_ConvertColorFormat(DestPixel* pDest, SourPixel* pSour, int count) +{ + DestPixel* pDestEnd = pDest + count; + + while (pDest < pDestEnd) + { + *pDest++ = *pSour++; + } + + return pDestEnd; +} + +template<> +inline unsigned long* +_ConvertColorFormat(unsigned long* pDest, unsigned short* pSour, int count) +{ + typedef unsigned short SourPixel; + typedef unsigned long DestPixel; + + DestPixel* pDestEnd = pDest + count; + + while (pDest < pDestEnd) + { + DestPixel r = (*pSour & 0xF800) >> 8; + DestPixel g = (*pSour & 0x07E0) >> 3; + DestPixel b = (*pSour & 0x001F) << 3; + + r += (r >> 5); + g += (g >> 6); + b += (b >> 5); + + *pDest++ = 0xFF000000 | (r << 16) | (g << 8) | (b); + ++pSour; + } + + return pDestEnd; +} + +template<> +inline unsigned short* +_ConvertColorFormat(unsigned short* pDest, unsigned long* pSour, int count) +{ + typedef unsigned long SourPixel; + typedef unsigned short DestPixel; + + DestPixel* pDestEnd = pDest + count; + + while (pDest < pDestEnd) + { + DestPixel r = (DestPixel) ((*pSour & 0xF80000) >> 8); + DestPixel g = (DestPixel) ((*pSour & 0x00FC00) >> 5); + DestPixel b = (DestPixel) ((*pSour & 0x0000F8) >> 3); + + *pDest++ = r | g | b; + ++pSour; + } + + return pDestEnd; +} + +template +DestPixel* +ConvertBitmap(const _Util::Pixmap& srcBitmap) +{ + std::unique_ptr buffer(new (std::nothrow) DestPixel[srcBitmap.width * srcBitmap.height]); + + SysTryReturn(NID_GRP, buffer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + DestPixel* pDest = (DestPixel*) buffer.get(); + SourPixel* pSour = (SourPixel*) srcBitmap.pBitmap; + long pitch = (srcBitmap.bytesPerLine / sizeof(SourPixel)); + + for (int y = 0; y < srcBitmap.height; y++) + { + pDest = _ConvertColorFormat(pDest, pSour, srcBitmap.width); + pSour += pitch; + } + + return buffer.release(); +} + +unsigned char* +_CreatePremultipliedBuffer(const _Util::Pixmap& srcImage) +{ + typedef unsigned long DestPixel; + + if (srcImage.depth != 32) + return null; + + std::unique_ptr destBuffer(new (std::nothrow) unsigned char[srcImage.width * srcImage.height * sizeof(DestPixel)]); + + DestPixel* pDestBuffer = reinterpret_cast(destBuffer.get()); + + if (pDestBuffer) + { + if (srcImage.bytesPerLine == int(srcImage.width * sizeof(DestPixel))) + { + memcpy(pDestBuffer, srcImage.pBitmap, srcImage.bytesPerLine * srcImage.height); + } + else + { + DestPixel* pSrc = (DestPixel*)srcImage.pBitmap; + DestPixel* pDst = (DestPixel*)pDestBuffer; + + long srcPitch = (srcImage.bytesPerLine * 8 / srcImage.depth); + long dstPitch = srcImage.width; + + for (int y = 0; y < srcImage.height; y++) + { + memcpy(pDst, pSrc, srcImage.width * sizeof(DestPixel)); + pSrc += srcPitch; + pDst += dstPitch; + } + } + + DestPixel* p = (DestPixel*)pDestBuffer; + long padding = 0; + + for (int y = 0; y < srcImage.height; y++) + { + for (int x = 0; x < srcImage.width; x++) + { + DestPixel a = (*p) & 0xFF000000; + DestPixel r = (*p >> 8) & 0x0000FF00; + DestPixel g = (*p >> 8) & 0x000000FF; + DestPixel b = (*p) & 0x000000FF; + + DestPixel mul = (a >> 24) + (a >> 31); + + r = (r * mul) & 0x00FF0000; + g = (g * mul) & 0x0000FF00; + b = (b * mul) & 0x0000FF00; + + *p++ = a | r | g | (b >> 8); + } + + p += padding; + } + } + + return destBuffer.release(); +} + +} + +_Util::Pixmap* +_Util::Pixmap::GetClone(unsigned long depth) const +{ + { + if ((this->pBitmap == null) || (this->width <= 0) || (this->height <= 0)) + { + return null; + } + } + + void* pConvertedBuffer = null; + + if (depth == 32 && this->depth == 32) + { + pConvertedBuffer = (void*) ConvertBitmap (*this); + } + else if (depth == 32 && this->depth == 16) + { + pConvertedBuffer = (void*) ConvertBitmap (*this); + } + else if (depth == 16 && this->depth == 32) + { + pConvertedBuffer = (void*) ConvertBitmap (*this); + } + else if (depth == 16 && this->depth == 16) + { + pConvertedBuffer = (void*) ConvertBitmap (*this); + } + + if (pConvertedBuffer == null) + { + return null; + } + + _Util::Pixmap* pImageEx = new (std::nothrow) _Util::Pixmap(this->width, this->height, depth, pConvertedBuffer, this->width * depth / 8); + + SysTryReturn(NID_GRP, pImageEx, pImageEx, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pImageEx->reserved = 1; + + return pImageEx; +} + +_Util::Pixmap* +_Util::Pixmap::GetPremultipliedPixmap(void) const +{ + { + if ((this->pBitmap == null) || (this->width <= 0) || (this->height <= 0)) + { + return null; + } + } + + if (this->depth == 32) + { + std::auto_ptr<_Util::Pixmap> temp(new (std::nothrow) _Util::Pixmap(*this)); + std::unique_ptr buffer(_CreatePremultipliedBuffer(*this)); + + if (temp.get() && buffer.get()) + { + temp->pBitmap = buffer.release(); + temp->bytesPerLine = temp->width * temp->depth / 8; + temp->reserved = 1; + + return temp.release(); + } + else + { + return null; + } + } + else + { + return GetClone(this->depth); + } +} + +void +_Util::Pixmap::ConvertPremultiplied(void) +{ + if (this->pBitmap == null || this->depth != 32) + return; + + if (this->isPremultiplied) + return; + + typedef unsigned long DestPixel; + + DestPixel* p = reinterpret_cast(this->pBitmap); + long paddingBytes = this->bytesPerLine - this->width * this->depth / 8; + + for (int y = 0; y < this->height; y++) + { + for (int x = 0; x < this->width; x++) + { + DestPixel a = (*p) & 0xFF000000; + DestPixel r = (*p >> 8) & 0x0000FF00; + DestPixel g = (*p >> 8) & 0x000000FF; + DestPixel b = (*p) & 0x000000FF; + + DestPixel mul = (a >> 24) + (a >> 31); + + r = (r * mul) & 0x00FF0000; + g = (g * mul) & 0x0000FF00; + b = (b * mul) & 0x0000FF00; + + *p++ = a | r | g | (b >> 8); + } + + p = reinterpret_cast(reinterpret_cast(p) + paddingBytes); + } +} diff --git a/src/graphics/util/FGrp_UtilPixmap.h b/src/graphics/util/FGrp_UtilPixmap.h new file mode 100644 index 0000000..6564f19 --- /dev/null +++ b/src/graphics/util/FGrp_UtilPixmap.h @@ -0,0 +1,201 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_UtilPixmap.h + * @brief This is the header file for internal _Util Pixmap class. + * + */ + +#ifndef _FGRP_INTERNAL_UTIL_PIXMAP_H_ +#define _FGRP_INTERNAL_UTIL_PIXMAP_H_ + + +namespace Tizen { namespace Graphics +{ + +namespace _Util +{ +//////////////////////////////////////////////////////////////////////////////// +// image manipulation + +struct PixmapBase +{ + long type; // image buffer type. this value is always 0 + long width; // width of image + long height; // height of image + long bytesPerLine; // bytes per line + long depth; // pixel depth of buffer + long enableColorKey; // is color key available? + unsigned long colorKey; // color key + long enableReplaceColor; // is replacement color available? + unsigned long replaceColor; // replacement color + long isOpaque; // it is opaque if TRUE + long isPremultiplied; // it has premultiplied alpha if TRUE + unsigned char* pBitmap; // start pointer to buffer + mutable long reserved; // do you have ownership? +}; + +// if 'reserved' is not 0, buffer is released automatically +struct Pixmap + : public PixmapBase +{ + Pixmap(); + Pixmap(int width, int height, int depth, int bytesPerLine = 0); + Pixmap(int width, int height, int depth, void* pBitmap, int bytesPerLine = 0); + Pixmap(PixmapBase& refImage); + Pixmap(const PixmapBase& refImage); + Pixmap(const Pixmap& refImage); + ~Pixmap(); + + Pixmap& operator =(const Pixmap& refImage); + + PixmapBase GetSubBitmap(long x, long y, long w, long h) const; + PixmapBase GetSubBitmapUnsafe(long x, long y, long w, long h) const; + Pixmap* GetClone(unsigned long depth) const; + Pixmap* GetPremultipliedPixmap(void) const; + void ConvertPremultiplied(void); +}; + +//////////////////////////////////////////////////////////////////////////////// +// buffer manipulation + +template +class GenericBufferBase +{ +public: + GenericBufferBase() + : _pBuffer(0) + , _pitch(0) + , _padding(0) + , _pHandle(0) + { + _rect.x = 0; + _rect.y = 0; + _rect.w = 0; + _rect.h = 0; + } + + virtual ~GenericBufferBase(void) + { + } + + inline Pixel* GetBufferAddr(void) const + { + return _pBuffer; + } + + inline int GetPitch(void) const + { + return _pitch; + } + + inline int GetPadding(void) const + { + return _padding; + } + + inline int GetWidth(void) const + { + return _rect.w; + } + + inline int GetHeight(void) const + { + return _rect.h; + } + + inline void* GetHandle(void) const + { + return _pHandle; + } + +protected: + Pixel* _pBuffer; + int _pitch; + int _padding; + + struct + { + int x; + int y; + int w; + int h; + } + _rect; + + void* _pHandle; +}; // GenericBufferBase + +template +class GenericBuffer +{ +public: + GenericBuffer(const GenericBufferBase * pInst) + { + __pInst = pInst; + } + + virtual ~GenericBuffer(void) + { + delete __pInst; + } + + inline bool IsValid(void) const + { + return (__pInst != 0); + } + + inline Pixel* GetBufferAddr(void) const + { + return __pInst->GetBufferAddr(); + } + + inline int GetPitch(void) const + { + return __pInst->GetPitch(); + } + + inline int GetPadding(void) const + { + return __pInst->GetPadding(); + } + + inline int GetWidth(void) const + { + return __pInst->GetWidth(); + } + + inline int GetHeight(void) const + { + return __pInst->GetHeight(); + } + + inline void* GetHandle(void) const + { + return __pInst->GetHandle(); + } + +private: + const GenericBufferBase * __pInst; +}; // GenericBuffer + +} // Tizen::Graphics::_Util + +}} // Tizen::Graphics + +#endif // #ifndef _FGRP_INTERNAL_UTIL_PIXMAP_H_ diff --git a/src/graphics/util/FGrp_UtilScratchpad.cpp b/src/graphics/util/FGrp_UtilScratchpad.cpp new file mode 100644 index 0000000..99a8fa6 --- /dev/null +++ b/src/graphics/util/FGrp_UtilScratchpad.cpp @@ -0,0 +1,228 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_UtilScratchpad.cpp + * @brief This is the header file for internal utility class. + * + */ + +#include "FGrp_UtilScratchpad.h" + + +namespace Tizen { namespace Graphics +{ + +namespace _Util +{ + +template<> +void +ScratchPad ::__FillRect(unsigned long* pDest32, int w, int h, int pitch, unsigned long color, + unsigned long opacity) +{ + typedef unsigned long Pixel; + + opacity += (opacity >> 7); + opacity = ((opacity * (color >> 24)) << 16) & 0xFF000000; + color &= 0x00FFFFFF; + + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + *pDest32++ = Pixel((color & 0x00FFFFFF) | opacity); + } + + pDest32 += (pitch - w); + } +} + +template<> +void +ScratchPad ::__BitBlt(unsigned long* pDest32, int w, int h, int pitch, unsigned long* pSour32, int imagePitch, + unsigned long opacity, + ColorKey srcColorKey) +{ + typedef unsigned long Pixel; + + opacity += (opacity >> 7); + opacity <<= 16; + + Pixel alpha = 0xFF000000; + + if (!srcColorKey.isValid) + { + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + alpha = Pixel(opacity * (*pSour32 >> 24)); + *pDest32++ = (*pSour32++ & 0x00FFFFFF) | (alpha & 0xFF000000); + } + + pDest32 += (pitch - w); + pSour32 += (imagePitch - w); + } + } + else + { + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + if (*pSour32 != srcColorKey.colorKey) + { + alpha = Pixel(opacity * (*pSour32 >> 24)); + *pDest32++ = (*pSour32++ & 0x00FFFFFF) | (alpha & 0xFF000000); + continue; + } + + ++pSour32; + ++pDest32; + } + + pDest32 += (pitch - w); + pSour32 += (imagePitch - w); + } + } +} + +//////////////////////////////////////// +// implementation (unsined short) + +template<> +void +ScratchPad ::__FillRect(unsigned short* pDest16, int w, int h, int pitch, unsigned long color, + unsigned long opacity) +{ + typedef unsigned short Pixel; + + Pixel color16bit = (Pixel) color; + + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + *pDest16++ = color16bit; + } + + pDest16 += (pitch - w); + } +} + +template<> +void +ScratchPad ::__BitBlt(unsigned short* pDest16, int w, int h, int pitch, unsigned short* pSour16, int imagePitch, + unsigned long opacity, + ColorKey srcColorKey) +{ + typedef unsigned short Pixel; + + if (!srcColorKey.isValid) + { + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + *pDest16++ = *pSour16++; + } + + pDest16 += (pitch - w); + pSour16 += (imagePitch - w); + } + } + else + { + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + if (*pSour16 != srcColorKey.colorKey) + { + *pDest16++ = *pSour16++; + continue; + } + + ++pSour16; + ++pDest16; + } + + pDest16 += (pitch - w); + pSour16 += (imagePitch - w); + } + } +} + +//////////////////////////////////////// +// implementation (unsined char) + +template<> +void +ScratchPad ::__FillRect(unsigned char* pDest08, int w, int h, int pitch, unsigned long color, + unsigned long opacity) +{ + unsigned char color08bit = (unsigned char) color; + + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + *pDest08++ = color08bit; + } + + pDest08 += (pitch - w); + } +} + +template<> +void +ScratchPad ::__BitBlt(unsigned char* pDest08, int w, int h, int pitch, unsigned char* pSour08, int imagePitch, + unsigned long opacity, + ColorKey srcColorKey) +{ + while (--h >= 0) + { + int copy = w; + + while (--copy >= 0) + { + *pDest08++ = *pSour08++; + } + + pDest08 += (pitch - w); + pSour08 += (imagePitch - w); + } +} + +} // _Util + +}} // Tizen::Graphics::_Util diff --git a/src/graphics/util/FGrp_UtilScratchpad.h b/src/graphics/util/FGrp_UtilScratchpad.h new file mode 100644 index 0000000..61ea482 --- /dev/null +++ b/src/graphics/util/FGrp_UtilScratchpad.h @@ -0,0 +1,261 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_UtilScratchpad.h + * @brief This is the header file for internal ScratchPad class. + * + */ + +#ifndef _FGRP_INTERNAL_UTIL_SCRATCHPAD_H_ +#define _FGRP_INTERNAL_UTIL_SCRATCHPAD_H_ + + +namespace Tizen { namespace Graphics +{ + +namespace _Util +{ +struct ColorKey +{ + ColorKey() + : isValid(false) + , colorKey(0) + { + } + + explicit ColorKey(unsigned long _colorKey) + : isValid(true) + , colorKey(_colorKey) + { + } + + explicit ColorKey(unsigned long _a, unsigned long _r, unsigned long _g, unsigned long _b) + : isValid(true) + { + if (_a > 255) + { + _a = 255; + } + + if (_r > 255) + { + _r = 255; + } + + if (_g > 255) + { + _g = 255; + } + + if (_b > 255) + { + _b = 255; + } + + colorKey = (_a << 24) | (_r << 16) | (_g << 8) | (_b << 0); + } + + bool isValid; + unsigned long colorKey; +}; + +// external buffer manipulation tool +template +class ScratchPad +{ +public: + enum + { + SCRATCH_PAD_VER_1_2 + }; + + typedef void (*FillRectFunc)(Pixel* pDest32, int w, int h, int pitch, unsigned long color, unsigned long opacity); + typedef void (*BitBltFunc)(Pixel* pDest32, int w, int h, int pitch, Pixel* pSour32, int imagePitch, unsigned long opacity, + ColorKey colorKey); + + ScratchPad(Pixel* pBuffer, int width, int height, int pitch, ColorKey colorKey = ColorKey()) + : __pBuffer(pBuffer) + , __width(width) + , __height(height) + , __xPitch(sizeof(Pixel)) + , __yPitch(pitch) + , __colorKey(colorKey) + , __fnFillRect(__FillRect) + , __fnBitBlt(__BitBlt) + { + __depth = sizeof(Pixel) * 8; + __bytesPerLine = pitch * sizeof(Pixel); + } + + void DrawPoint(int x, int y, Pixel color) + { + if (!__IsInRegion(x, y)) + { + return; + } + + *__GetAddress(x, y) = color; + } + + void FillRect(int x, int y, int w, int h, Pixel color, unsigned long opacity = 255) + { + if (!__FitToRegion(x, y, w, h)) + { + return; + } + + __fnFillRect(__GetAddress(x, y), w, h, __yPitch, color, opacity); + } + + void BitBlt(int xDest, int yDest, ScratchPad* pImage, int xSour, int ySour, int wSour, int hSour, unsigned long opacity = 255) + { + if (pImage == 0) + { + return; + } + + { + int x = xSour; + int y = ySour; + + if (!pImage->__FitToRegion(xSour, ySour, wSour, hSour)) + { + return; + } + + xDest += (xSour - x); + yDest += (ySour - y); + } + + { + int x = xDest; + int y = yDest; + + if (!__FitToRegion(xDest, yDest, wSour, hSour)) + { + return; + } + + xSour += (xDest - x); + ySour += (yDest - y); + } + + int srcPitch = pImage->__bytesPerLine / (pImage->__depth / 8); + + __fnBitBlt(__GetAddress(xDest, yDest), wSour, hSour, __yPitch, pImage->__GetAddress(xSour, + ySour), srcPitch, opacity, + pImage->__colorKey); + } + + int GetWidth(void) const + { + return __width; + } + + int GetHeight(void) const + { + return __height; + } + + void RegisterFillRect(FillRectFunc fnFillRect) + { + __fnFillRect = (fnFillRect) ? fnFillRect : __FillRect; + } + + void RegisterBitBlt(BitBltFunc fnBitBlt) + { + __fnBitBlt = (fnBitBlt) ? fnBitBlt : __BitBlt; + } + + // for internal purposes + void GetBuffer(Pixel*& pAddr, int& pitch) const + { + pAddr = __pBuffer; + pitch = __yPitch; + } + + // for internal purposes + ColorKey GetColorKey(void) const + { + return __colorKey; + } + + // for internal purposes + void SetColorKey(ColorKey colorKey) + { + __colorKey = colorKey; + } + + // for internal purposes + void SetPitch(int depth, int bytesPerLine) + { + __depth = depth; + __xPitch = depth / 8; + __bytesPerLine = bytesPerLine; + } + +private: + bool __IsInRegion(int x, int y) + { + return (x >= 0 && x < __width && y >= 0 && y < __height); + } + + bool __FitToRegion(int& x1, int& y1, int& w, int& h) + { + int x2 = x1 + w; + int y2 = y1 + h; + + x1 = (x1 < 0) ? 0 : x1; + y1 = (y1 < 0) ? 0 : y1; + x2 = (x2 > __width) ? __width : x2; + y2 = (y2 > __height) ? __height : y2; + + w = x2 - x1; + h = y2 - y1; + + return (w >= 0) && (h >= 0); + } + + Pixel* __GetAddress(int x, int y) + { + unsigned char* pBuffer = (unsigned char*) (__pBuffer) + y * __bytesPerLine; + return (Pixel*) (pBuffer + (x * __xPitch)); + } + + static void __FillRect(Pixel* pDest, int w, int h, int pitch, unsigned long color, unsigned long opacity); + static void __BitBlt(Pixel* pDest, int w, int h, int pitch, Pixel* pSour, int imagePitch, unsigned long opacity, ColorKey srcColorKey); + +private: + Pixel* __pBuffer; + int __width; + int __height; + int __xPitch; + int __yPitch; + int __bytesPerLine; + int __depth; + ColorKey __colorKey; + + FillRectFunc __fnFillRect; + BitBltFunc __fnBitBlt; +}; // ScratchPad + +} // Tizen::Graphics::_Util + +}} // Tizen::Graphics + +#endif // #ifndef _FGRP_INTERNAL_UTIL_SCRATCHPAD_H_ diff --git a/src/graphics/util/FGrp_UtilTemplate.h b/src/graphics/util/FGrp_UtilTemplate.h new file mode 100644 index 0000000..83a6096 --- /dev/null +++ b/src/graphics/util/FGrp_UtilTemplate.h @@ -0,0 +1,560 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_UtilTemplate.h + * @brief This is the header file for internal _Util namespace. + * + */ + +#ifndef _FGRP_INTERNAL_UTIL_TEMPLATE_H_ +#define _FGRP_INTERNAL_UTIL_TEMPLATE_H_ + + +#include +#include + + +namespace Tizen { namespace Graphics +{ + +namespace _Util +{ + +template +inline T +Min(T a, T b) +{ + return (a < b) ? a : b; +} + +template +inline T +Max(T a, T b) +{ + return (a > b) ? a : b; +} + +template +struct Pair +{ + Pair() + : first(T1()) + , second(T2()) + {} + + Pair(const T1& val1, const T2& val2) + : first(val1) + , second(val2) + {} + + template Pair(const Pair & ref) + : first(ref.first) + , second(ref.second) + {} + + T1 first; + T2 second; +}; + +template +inline Pair +MakePair(const T1& val1, const T2& val2) +{ + return (Pair (val1, val2)); +} + + +template +class AccumList +{ +public: + typedef AccumList MyAccumList; + typedef size_t SizeType; + typedef DataType* Iterator; + typedef const DataType* ConstIterator; + + explicit AccumList(void) + : __first(0) + , __last(0) + , __end(0) + { + } + + ~AccumList(void) + { + __Cleanup(); + } + + Iterator Begin(void) + { + return (__first); + } + + ConstIterator Begin(void) const + { + return ((ConstIterator) __first); + } + + Iterator End(void) + { + return (__last); + } + + ConstIterator End(void) const + { + return ((ConstIterator) __last); + } + + SizeType Size(void) const + { + return (__first) ? __last - __first : 0; + } + + void Push(const DataType& data) + { + if (__last + 1 > __end) + { + SizeType originalSize = Size(); + SizeType numAlloc = (originalSize > 0) ? originalSize << 1 : 1; + + Iterator dest = ((DataType*) operator new(numAlloc * sizeof(DataType), std::nothrow)); + + if (dest) + { + { + Iterator destEnd = __Copy(__first, __last, dest); + new ((void*) destEnd)DataType(data); + } + + __Cleanup(); + + __end = dest + numAlloc; + __last = dest + originalSize + 1; + __first = dest; + } + } + else + { + new ((void*) __last++)DataType(data); + } + } + + void Clear(void) + { + __Cleanup(); + } + + void Swap(MyAccumList& target) + { + if (this != &target) + { + MyAccumList temp = *this; + *this = target; + target = temp; + + temp.__first = 0; + temp.__last = 0; + } + } + +private: + void __Cleanup(void) + { + Iterator first = __first; + + for (; first != __last; ++first) + { + (first)->~DataType(); + } + + operator delete(__first); + + __first = 0; + __last = 0; + __end = 0; + } + + Iterator __Copy(Iterator first, Iterator last, Iterator dest) + { + for (; first != last; ++dest, ++first) + { + new (dest) DataType(*first); + } + + return dest; + } + + Iterator __first; + Iterator __last; + Iterator __end; + +}; // AccumList + + +template +class SharedPtr +{ +public: + SharedPtr() + : _pInstance(0) + , _pUseCount(0) + { + } + + explicit SharedPtr(BaseType* pInstance) + : _pInstance(pInstance) + , _pUseCount(new (std::nothrow) unsigned int (1)) + { + } + + SharedPtr(const SharedPtr& refInstance) + : _pInstance(0) + , _pUseCount(0) + { + _pInstance = refInstance._pInstance; + _pUseCount = refInstance._pUseCount; + + if (_pUseCount) + { + ++(*_pUseCount); + } + } + + virtual ~SharedPtr() + { + _Release(); + } + + SharedPtr& operator =(const SharedPtr& refInstance) + { + if (_pInstance == refInstance._pInstance) + { + return *this; + } + + _Release(); + + { + _pInstance = refInstance._pInstance; + _pUseCount = refInstance._pUseCount; + + if (_pUseCount) + { + ++(*_pUseCount); + } + } + + return *this; + } + + inline BaseType& operator *() const + { + // assert(_pInstance); + return *_pInstance; + } + + inline BaseType* operator ->() const + { + return _pInstance; + } + + inline BaseType* Get() const + { + return _pInstance; + } + + void Bind(BaseType* rep) + { + if (!_pInstance && !_pUseCount) + { + _pUseCount = new (std::nothrow) unsigned int(1); + _pInstance = rep; + } + } + + inline bool Unique() const + { + return (_pUseCount) ? (*_pUseCount == 1) : true; + } + + inline unsigned int UseCount() const + { + return (_pUseCount) ? *_pUseCount : 0; + } + + inline unsigned int* UseCountPointer() const + { + return _pUseCount; + } + + inline bool IsNull(void) const + { + return (_pInstance == 0); + } + + inline bool IsNotNull(void) const + { + return (_pInstance != 0); + } + + inline void SetNull(void) + { + if (_pInstance) + { + _Release(); + _pInstance = 0; + _pUseCount = 0; + } + } + +protected: + inline void _Release(void) + { + if (_pUseCount) + { + if (--(*_pUseCount) == 0) + { + _Destroy(); + } + } + } + + virtual void _Destroy(void) + { + delete _pInstance; + delete _pUseCount; + } + +protected: + BaseType* _pInstance; + unsigned int* _pUseCount; + +}; // SharedPtr + +template inline bool +operator ==(SharedPtr const& a, SharedPtr const& b) +{ + return a.Get() == b.Get(); +} + +template inline bool +operator !=(SharedPtr const& a, SharedPtr const& b) +{ + return a.Get() != b.Get(); +} + + +template +class AutoPtr +{ +public: + explicit AutoPtr(BaseType* pPtr = 0) + : __hasOwnership(pPtr != 0) + , __pPtr((BaseType*)pPtr) + { + } + + ~AutoPtr() + { + if (__hasOwnership) + { + delete (BaseType*) __pPtr; + } + } + + inline void Bind(BaseType* pPtr) + { + if (__pPtr == 0) + { + __hasOwnership = (pPtr != 0); + __pPtr = (BaseType*) pPtr; + } + } + + inline void Reset(BaseType* pPtr) + { + if (__pPtr == pPtr) + { + return; + } + + if (__hasOwnership) + { + delete (BaseType*) __pPtr; + } + + __hasOwnership = (pPtr != 0); + __pPtr = (BaseType*) pPtr; + } + + inline bool IsNull(void) const + { + return (__pPtr == 0); + } + + inline bool IsNotNull(void) const + { + return (__pPtr != 0); + } + + inline BaseType* operator ->() const + { + return __pPtr; + } + + inline BaseType* Get() const + { + return __pPtr; + } + + inline BaseType* Release() const + { + ((AutoPtr *) this)->__hasOwnership = false; + return __pPtr; + } + +private: + bool __hasOwnership; + BaseType* __pPtr; + +}; // AutoPtr + + +template +class AutoArray +{ +public: + explicit AutoArray(BaseType* ptr = 0) + : __hasOwnership(ptr != 0) + , __pPtr((BaseType*)ptr) + { + } + + ~AutoArray() + { + if (__hasOwnership) + { + delete[] (BaseType*) __pPtr; + } + } + + inline BaseType& operator [](unsigned int index) const + { + return __pPtr[index]; + } + + inline void Bind(BaseType* pPtr) + { + if (__pPtr == 0) + { + __hasOwnership = (pPtr != 0); + __pPtr = (BaseType*) pPtr; + } + } + + inline void Reset(BaseType* pPtr) + { + if (__pPtr == pPtr) + { + return; + } + + if (__hasOwnership) + { + delete[] (BaseType*) __pPtr; + } + + __hasOwnership = (pPtr != 0); + __pPtr = (BaseType*) pPtr; + } + + inline bool IsNull(void) const + { + return (__pPtr == 0); + } + + inline bool IsNotNull(void) const + { + return (__pPtr != 0); + } + + inline BaseType* Get() const + { + return __pPtr; + } + + inline BaseType* Release() const + { + ((AutoArray *) this)->__hasOwnership = false; + + return __pPtr; + } + +private: + bool __hasOwnership; + BaseType* __pPtr; + +}; // AutoArray + +template +class AutoDeletor +{ +public: + explicit AutoDeletor(BaseType* pPtr = 0) + : __pPtr((BaseType*)pPtr) + { + } + + ~AutoDeletor(void) + { + delete __pPtr; + } + + inline void Bind(BaseType* pPtr) + { + if (__pPtr == 0) + { + __pPtr = (BaseType*) pPtr; + } + } + + BaseType* operator->(void) const + { + return __pPtr; + } + + operator BaseType*(void) const + { + return __pPtr; + } + + bool IsValid(void) const + { + return (__pPtr != 0); + } + +private: + BaseType* __pPtr; + +}; // AutoDeletor + +} // Tizen::Graphics::_Util + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_UTIL_TEMPLATE_H_ diff --git a/src/graphics/util/FGrp_UtilType.h b/src/graphics/util/FGrp_UtilType.h new file mode 100644 index 0000000..fb87a29 --- /dev/null +++ b/src/graphics/util/FGrp_UtilType.h @@ -0,0 +1,143 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* + * @file FGrp_UtilType.h + * @brief This is the header file for internal _Util namespace. + * + */ + +#ifndef _FGRP_INTERNAL_UTIL_TYPE_H_ +#define _FGRP_INTERNAL_UTIL_TYPE_H_ + + +namespace Tizen { namespace Graphics +{ + +namespace _Util +{ + +template +struct Point +{ + T x; + T y; +}; + +template +struct Dimension +{ + T w; + T h; +}; + +template +struct Rectangle +{ + T x; + T y; + T w; + T h; +}; + +template +inline bool +operator ==(const Rectangle& lhs, const Rectangle& rhs) +{ + return (lhs.x == rhs.x) && (lhs.y == rhs.y) && (lhs.w == rhs.w) && (lhs.h == rhs.h); +} + +template +inline bool +operator !=(const Rectangle& lhs, const Rectangle& rhs) +{ + return !(operator ==(lhs, rhs)); +} + +template +struct Bounds +{ + T x1; + T y1; + T x2; + T y2; + + bool IsInside(T x, T y) + { + return ((x >= x1) && (x < x2) && (y >= y1) && (y < y2)); + } + + bool IsInsideX(T x) + { + return ((x >= x1) && (x < x2)); + } +}; + +//////////////////////////////////////////////////////////////////////////////// +// String + +struct String +{ + const wchar_t* pStart; + int length; + + String(void) + : pStart(L"") + , length(0) + { + } + + String(const wchar_t* pInputString, int inputStringLength) + : pStart(pInputString) + , length(inputStringLength) + { + } + + String(const wchar_t* pInputString, int inputStringLength, int offset, int clippedLength) + { + const wchar_t* pInputStart = pInputString; + const wchar_t* pInputEnd = pInputStart + inputStringLength; + + const wchar_t* pRevisedStart = pInputString + offset; + const wchar_t* pRevisedEnd = pRevisedStart + clippedLength; + + const wchar_t* pClippedStart = (pInputStart > pRevisedStart) ? pInputStart : pRevisedStart; + const wchar_t* pClippedEnd = (pInputEnd < pRevisedEnd) ? pInputEnd : pRevisedEnd; + + if (pClippedEnd - pClippedStart > 0) + { + this->pStart = pClippedStart; + this->length = pClippedEnd - pClippedStart; + } + else + { + this->pStart = L""; + this->length = 0; + } + } + + operator const wchar_t*(void) + { + return pStart; + } +}; + +} // Tizen::Graphics::_Util + +}} // Tizen::Graphics + +#endif // _FGRP_INTERNAL_UTIL_TYPE_H_ diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt new file mode 100644 index 0000000..f6e2b6c --- /dev/null +++ b/src/ui/CMakeLists.txt @@ -0,0 +1,717 @@ +SET (this_target ui) + +INCLUDE_DIRECTORIES( + ${SLP_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/inc + ${CMAKE_SOURCE_DIR}/src/graphics + ${CMAKE_SOURCE_DIR}/src/graphics/inc + ${CMAKE_SOURCE_DIR}/src/graphics/text + ${CMAKE_SOURCE_DIR}/src/graphics/effect + . + ./inc + ./controls + ./layout + ./resource + ./animations/inc + ./animations + ./scenes + ./effects/inc + ./effects + /usr/include/osp + /usr/include/osp/app + /usr/include/osp/base + /usr/include/osp/io + /usr/include/osp/media + /usr/include/osp/security + /usr/include/osp/system + /usr/include/osp/uix + ) + +SET (${this_target}_SOURCE_FILES + animations/FUiAnim_VariantEx.cpp + animations/FUiAnim_TransformMatrix3Df.cpp + animations/FUiAnim_ControlVisualElement.cpp + animations/FUiAnim_Debug.cpp + animations/FUiAnim_DisplayManager.cpp + animations/FUiAnim_DisplayContextImpl.cpp + animations/FUiAnimDisplayContext.cpp + animations/FUiAnim_INativeNode.cpp + animations/FUiAnim_NativeLayer.cpp + animations/FUiAnim_RootVisualElement.cpp + animations/FUiAnim_AnimationManager.cpp + animations/FUiAnim_TransactionNode.cpp + animations/FUiAnim_VisualElement.cpp + animations/FUiAnim_VisualElementEnvironment.cpp + animations/FUiAnim_VisualElementAnimationGroupImpl.cpp + animations/FUiAnim_VisualElementAnimationImpl.cpp + animations/FUiAnim_VisualElementValueAnimationImpl.cpp + animations/FUiAnim_VisualElementPropertyAnimationImpl.cpp + animations/FUiAnim_VisualElementAnimationKeyFrame.cpp + animations/FUiAnim_VisualElementAnimationTiming.cpp + animations/FUiAnim_VisualElementAnimationVariantInterpolator.cpp + animations/FUiAnim_VisualElementImpl.cpp + animations/FUiAnim_VisualElementCoordinateSystem.cpp + animations/FUiAnim_VisualElementCanvas.cpp + animations/FUiAnim_VisualElementSharedData.cpp + animations/FUiAnimVisualElementSurface.cpp + animations/FUiAnim_VisualElementSurfaceImpl.cpp + animations/FUiAnim_EflNode.cpp + animations/FUiAnim_EflLayer.cpp + animations/FUiAnim_EflVisualElementSurfaceImpl.cpp + animations/FUiAnim_MatrixUtil.cpp + animations/FUiAnimAnimationBase.cpp + animations/FUiAnim_AnimationBaseImpl.cpp + animations/FUiAnim_AnimationGroupImpl.cpp + animations/FUiAnim_FloatAnimationImpl.cpp + animations/FUiAnim_DimensionAnimationImpl.cpp + animations/FUiAnim_IntegerAnimationImpl.cpp + animations/FUiAnim_PointAnimationImpl.cpp + animations/FUiAnim_RectangleAnimationImpl.cpp + animations/FUiAnim_RotateAnimationImpl.cpp + animations/FUiAnimFloatAnimation.cpp + animations/FUiAnimIntegerAnimation.cpp + animations/FUiAnimDimensionAnimation.cpp + animations/FUiAnimPointAnimation.cpp + animations/FUiAnimRectangleAnimation.cpp + animations/FUiAnimRotateAnimation.cpp + animations/FUiAnimSequentialAnimationGroup.cpp + animations/FUiAnimParallelAnimationGroup.cpp + animations/FUiAnimAnimationGroup.cpp + animations/FUiAnimControlAnimator.cpp + animations/FUiAnim_ControlAnimatorImpl.cpp + animations/FUiAnimFrameAnimator.cpp + animations/FUiAnim_FrameAnimatorImpl.cpp + animations/FUiAnimAnimationTransaction.cpp + animations/FUiAnimIVisualElementAnimationStatusEventListener.cpp + animations/FUiAnimIVisualElementAnimationTickEventListener.cpp + animations/FUiAnimIVisualElementAnimationTimingFunction.cpp + animations/FUiAnimIVisualElementAnimationValueInterpolator.cpp + animations/FUiAnimBezierTimingFunction.cpp + animations/FUiAnimDiscreteTimingFunction.cpp + animations/FUiAnimEaseElasticInTimingFunction.cpp + animations/FUiAnimEaseElasticOutTimingFunction.cpp + animations/FUiAnimEaseInOutTimingFunction.cpp + animations/FUiAnimEaseInTimingFunction.cpp + animations/FUiAnimEaseOutInTimingFunction.cpp + animations/FUiAnimEaseOutTimingFunction.cpp + animations/FUiAnimExpInTimingFunction.cpp + animations/FUiAnimExpOutTimingFunction.cpp + animations/FUiAnimLinearTimingFunction.cpp + animations/FUiAnimVisualElementAnimation.cpp + animations/FUiAnimVisualElementAnimationGroup.cpp + animations/FUiAnimVisualElementPropertyAnimation.cpp + animations/FUiAnimVisualElementValueAnimation.cpp + animations/FUiAnimVisualElement.cpp + animations/FUiAnimVisualElementAnimationProvider.cpp + animations/FUiAnimVisualElementContentProvider.cpp + FUiAccessibilityContainer.cpp + FUiAccessibilityElement.cpp + FUi_AccessibilityContainer.cpp + FUi_AccessibilityContainerImpl.cpp + FUi_AccessibilityElement.cpp + FUi_AccessibilityElementImpl.cpp + FUi_AccessibilityGesture.cpp + FUi_AccessibilityManager.cpp + FUi_AccessibilitySystemSettingLoader.cpp + FUi_AccessibilityTtsPlayer.cpp + FUi_ErrorMessages.cpp + FUiContainer.cpp + FUiControl.cpp + FUiUiConfiguration.cpp + FUiCustomControlBase.cpp + FUiWindow.cpp + FUi_Control.cpp + FUi_Window.cpp + FUi_ControlImpl.cpp + FUi_ContainerImpl.cpp + FUi_CoordinateSystemUtils.cpp + FUi_WindowImpl.cpp + FUi_ControlManager.cpp + FUi_ControlImplManager.cpp + FUi_ModalLoopManager.cpp + FUi_OrientationAgent.cpp + FUiClipboard.cpp + FUi_ClipboardImpl.cpp + FUi_Clipboard.cpp + FUiClipboardItem.cpp + FUi_ClipboardItemImpl.cpp + FUi_ClipboardItem.cpp + FUi_CustomControlBaseImpl.cpp + FUiDataBindingContext.cpp + FUi_DataBinding.cpp + FUi_DataBindingContext.cpp + FUi_DataBindingContextImpl.cpp + FUi_ResourceManager.cpp + FUi_UiBuilder.cpp + FUi_UiBuilderControl.cpp + FUi_UiBuilderControlElement.cpp + FUi_UiBuilderControlItem.cpp + FUi_UiBuilderControlMaker.cpp + FUi_UiBuilderControlTable.cpp + FUi_UiBuilderControlLayout.cpp + FUi_UiBuilderXmlHandler.cpp +# FUi_CustomItemEvent.cpp +# FUi_CustomItemEventArg.cpp + FUi_DragDropEvent.cpp + FUi_DragDropEventArg.cpp + FUiFocusManager.cpp + FUi_FocusManagerImpl.cpp + FUiKeyboardMap.cpp + FUi_PublicOrientationEvent.cpp + FUi_ActiveWindowEvent.cpp + FUiTouch.cpp + FUiTouchEventInfo.cpp + FUi_TouchEventInfoImpl.cpp + FUiVariant.cpp + FUi_TouchEventArg.cpp + FUi_EflUiEventManager.cpp + FUi_EcoreEvas.cpp + FUi_EcoreEvasMgr.cpp + FUi_EflWindow.cpp + FUi_UiEvent.cpp + FUi_UiEventManager.cpp + FUi_UiFocusEvent.cpp + FUi_UiKeyEvent.cpp + FUi_UiNotificationEvent.cpp + FUi_UiTouchEvent.cpp + FUi_FingerInfo.cpp + FUi_TouchManager.cpp + FUi_PropertyBase.cpp + FUi_PropertyUtils.cpp + FUiTouchGestureDetector.cpp + FUiTouchTapGestureDetector.cpp + FUiTouchLongPressGestureDetector.cpp + FUiTouchFlickGestureDetector.cpp + FUiTouchPinchGestureDetector.cpp + FUiTouchRotationGestureDetector.cpp + FUiTouchPanningGestureDetector.cpp + FUi_TouchGestureDetectorImpl.cpp + FUi_TouchTapGestureDetectorImpl.cpp + FUi_TouchLongPressGestureDetectorImpl.cpp + FUi_TouchFlickGestureDetectorImpl.cpp + FUi_TouchPinchGestureDetectorImpl.cpp + FUi_TouchRotationGestureDetectorImpl.cpp + FUi_TouchPanningGestureDetectorImpl.cpp + FUi_TouchGestureDetector.cpp + FUi_TouchGestureTimerManager.cpp + FUi_TouchTapGestureDetector.cpp + FUi_TouchLongPressGestureDetector.cpp + FUi_TouchFlickGestureDetector.cpp + FUi_TouchPinchGestureDetector.cpp + FUi_TouchRotationGestureDetector.cpp + FUi_TouchPanningGestureDetector.cpp + FUiKeyEventManager.cpp + FUi_KeyEventManagerImpl.cpp + FUi_KeyEventManager.cpp + FUi_VariantImpl.cpp + FUiGridLayout.cpp + FUiHorizontalBoxLayout.cpp + FUiLayout.cpp + FUiRelativeLayout.cpp + FUiVerticalBoxLayout.cpp + FUiCardLayout.cpp + FUi_LayoutImpl.cpp + FUi_GridLayoutImpl.cpp + FUi_RelativeLayoutImpl.cpp + FUi_HorizontalBoxLayoutImpl.cpp + FUi_VerticalBoxLayoutImpl.cpp + FUi_CardLayoutImpl.cpp + FUiInputConnection.cpp + FUi_InputConnectionImpl.cpp + FUi_Matrix3Df.cpp + FUi_TouchEventManagerImpl.cpp + FUiTouchEventManager.cpp + FUiSystemUtil.cpp + controls/FUiCtrlAnimation.cpp + controls/FUiCtrlAnimationFrame.cpp + controls/FUiCtrlButton.cpp + controls/FUiCtrlButtonItem.cpp + controls/FUiCtrlCheckButton.cpp + controls/FUiCtrlColorPicker.cpp + controls/FUiCtrlContextMenu.cpp + controls/FUiCtrlDatePicker.cpp + controls/FUiCtrlTimePicker.cpp + controls/FUiCtrlDateTimePicker.cpp + controls/FUiCtrlEditDate.cpp + controls/FUiCtrlEditField.cpp + controls/FUiCtrlEditTime.cpp + controls/FUiCtrlExpandableEditArea.cpp + controls/FUiCtrlEditArea.cpp + controls/FUiCtrlKeypad.cpp + controls/FUiCtrlFrame.cpp + controls/FUiCtrlHeader.cpp + controls/FUiCtrlHeaderItem.cpp + controls/FUiCtrlFooter.cpp + controls/FUiCtrlFooterItem.cpp + controls/FUiCtrl_PublicFrameEvent.cpp + controls/FUiCtrl_FrameEvent.cpp + controls/FUiCtrlLabel.cpp + controls/FUiCtrlForm.cpp + controls/FUiCtrlMessageBox.cpp + controls/FUiCtrlIconList.cpp + controls/FUiCtrlIconListView.cpp + controls/FUiCtrlIconListViewItem.cpp + controls/FUiCtrl_IconListViewItemEvent.cpp + controls/FUiCtrl_IconListViewItemEventArg.cpp + controls/FUiCtrlGallery.cpp + controls/FUiCtrlGalleryItem.cpp + controls/FUiCtrlOptionMenu.cpp + controls/FUiCtrlPanel.cpp + controls/FUiCtrlProgress.cpp + controls/FUiCtrlRadioGroup.cpp + controls/FUiCtrlOverlayPanel.cpp + controls/FUiCtrlOverlayRegion.cpp + controls/FUiCtrlPopup.cpp + controls/FUiCtrlSearchBar.cpp + controls/FUiCtrl_ScrollEvent.cpp + controls/FUiCtrl_ScrollEventArg.cpp + controls/FUiCtrlScrollPanel.cpp + controls/FUiCtrl_ScrollPanelImpl.cpp + controls/FUiCtrlSlider.cpp + controls/FUiCtrlSplitPanel.cpp + controls/FUiCtrlTab.cpp + controls/FUiCtrlTabBar.cpp + controls/FUiCtrlTabBarItem.cpp + controls/FUiCtrl_TabBarItemImpl.cpp + controls/FUiCtrlTextBox.cpp + controls/FUiCtrl_ActionEvent.cpp + controls/FUiCtrl_PublicClipboardPopupEvent.cpp + controls/FUiCtrl_AdjustmentEvent.cpp + controls/FUiCtrl_AnimationEvent.cpp + controls/FUiCtrl_ColorChangeEvent.cpp + controls/FUiCtrl_SliderEvent.cpp + controls/FUiCtrl_TextEvent.cpp + controls/FUiCtrl_ExpandableEditAreaEvent.cpp + controls/FUiCtrl_ScrollPanelEvent.cpp + controls/FUiCtrl_SearchBarEvent.cpp + controls/FUiCtrl_SplitPanelEvent.cpp + controls/FUiCtrl_KeypadEvent.cpp + controls/FUiCtrl_LinkEvent.cpp + controls/FUiCtrl_TextBlockEvent.cpp + controls/FUiCtrl_LanguageEvent.cpp + controls/FUiCtrl_PublicActionEvent.cpp + controls/FUiCtrl_PublicAdjustmentEvent.cpp + controls/FUiCtrl_PublicAnimationEvent.cpp + controls/FUiCtrl_PublicColorChangeEvent.cpp + controls/FUiCtrl_PublicSliderEvent.cpp + controls/FUiCtrl_PublicLanguageEvent.cpp + controls/FUiCtrl_DateTimeChangeEvent.cpp + controls/FUiCtrl_PublicDateTimeChangeEvent.cpp + controls/FUiCtrl_PublicTextEvent.cpp + controls/FUiCtrl_PublicExpandableEditAreaEvent.cpp + controls/FUiCtrl_PublicScrollPanelEvent.cpp + controls/FUiCtrl_PublicSearchBarEvent.cpp + controls/FUiCtrl_PublicSplitPanelEvent.cpp + controls/FUiCtrl_PublicKeypadEvent.cpp + controls/FUiCtrl_PublicLinkEvent.cpp + controls/FUiCtrl_PublicTextBlockEvent.cpp + controls/FUiCtrl_Animation.cpp + controls/FUiCtrl_AnimationPresenter.cpp + controls/FUiCtrl_AnimationModel.cpp + controls/FUiCtrl_Button.cpp + controls/FUiCtrl_ButtonPresenter.cpp + controls/FUiCtrl_ButtonModel.cpp + controls/FUiCtrl_ColorPicker.cpp + controls/FUiCtrl_ColorPickerPresenter.cpp + controls/FUiCtrl_ColorPickerModel.cpp + controls/FUiCtrl_CheckButton.cpp + controls/FUiCtrl_CheckButtonPresenter.cpp + controls/FUiCtrl_CheckButtonModel.cpp + controls/FUiCtrl_DatePickerImpl.cpp + controls/FUiCtrl_TimePickerImpl.cpp + controls/FUiCtrl_DateTimeBar.cpp + controls/FUiCtrl_DateTimeBarPresenter.cpp + controls/FUiCtrl_DateTimeBarModel.cpp + controls/FUiCtrl_DateTimeBarItem.cpp + controls/FUiCtrl_ContextMenu.cpp + controls/FUiCtrl_ContextMenuListPresenter.cpp + controls/FUiCtrl_ContextMenuGridPresenter.cpp + controls/FUiCtrl_ContextMenuModel.cpp + controls/FUiCtrl_ContextMenuItem.cpp +# controls/FUiCtrl_ContextMenuItemProviderAdaptor.cpp + controls/FUiCtrl_DateTimePickerImpl.cpp + controls/FUiCtrl_DateTimeModel.cpp + controls/FUiCtrl_DateTimeUtils.cpp + controls/FUiCtrl_DateTimePicker.cpp + controls/FUiCtrl_DateTimePresenter.cpp + controls/FUiCtrl_DateTimeDisplayBox.cpp + controls/FUiCtrl_Edit.cpp + controls/FUiCtrl_EditAreaImpl.cpp + controls/FUiCtrl_EditCopyPasteManager.cpp + controls/FUiCtrl_EditCopyPasteEvent.cpp + controls/FUiCtrl_EditDate.cpp + controls/FUiCtrl_EditDatePresenter.cpp + controls/FUiCtrl_EditModel.cpp + controls/FUiCtrl_EditTime.cpp + controls/FUiCtrl_EditTimePresenter.cpp + controls/FUiCtrl_EditPresenter.cpp + controls/FUiCtrl_ExpandableEditAreaImpl.cpp + controls/FUiCtrl_Keypad.cpp + controls/FUiCtrl_KeypadImpl.cpp + controls/FUiCtrl_Form.cpp + controls/FUiCtrl_FormModel.cpp + controls/FUiCtrl_FormPresenter.cpp + controls/FUiCtrl_Frame.cpp + controls/FUiCtrl_FrameModel.cpp + controls/FUiCtrl_FramePresenter.cpp + controls/FUiCtrl_IconListImpl.cpp + controls/FUiCtrl_IconListData.cpp + controls/FUiCtrl_IconListItemProvider.cpp + controls/FUiCtrl_IconListItem.cpp + controls/FUiCtrl_IconListItemDrawingProperty.cpp + controls/FUiCtrl_IconListItemProviderAdaptor.cpp + controls/FUiCtrl_IconListPresenter.cpp + controls/FUiCtrl_IconListUtils.cpp + controls/FUiCtrl_IconListView.cpp + controls/FUiCtrl_Indicator.cpp + controls/FUiCtrl_IndicatorManager.cpp + controls/FUiCtrl_InputPad.cpp + controls/FUiCtrl_InputPadPresenter.cpp + controls/FUiCtrl_Label.cpp + controls/FUiCtrl_LabelModel.cpp + controls/FUiCtrl_LabelPresenter.cpp + controls/FUiCtrl_MessageBox.cpp + controls/FUiCtrl_MessageBoxPresenter.cpp + controls/FUiCtrl_OptionMenu.cpp + controls/FUiCtrl_OptionMenuModel.cpp + controls/FUiCtrl_OptionMenuPresenter.cpp + controls/FUiCtrl_OptionMenuItem.cpp + controls/FUiCtrl_Panel.cpp + controls/FUiCtrl_PanelPresenter.cpp + controls/FUiCtrl_Popup.cpp + controls/FUiCtrl_PopupPresenter.cpp + controls/FUiCtrl_Progress.cpp + controls/FUiCtrl_ProgressPresenter.cpp + controls/FUiCtrl_ProgressModel.cpp + controls/FUiCtrl_RadioGroup.cpp + controls/FUiCtrl_RadioGroupPresenter.cpp + controls/FUiCtrl_RadioGroupModel.cpp + controls/FUiCtrl_ScrollPanel.cpp + controls/FUiCtrl_ScrollPanelModel.cpp + controls/FUiCtrl_ScrollPanelPresenter.cpp + controls/FUiCtrl_SearchBar.cpp + controls/FUiCtrl_SearchBarModel.cpp + controls/FUiCtrl_SearchBarPresenter.cpp + controls/FUiCtrl_Slider.cpp + controls/FUiCtrl_SliderModel.cpp + controls/FUiCtrl_SliderOverlay.cpp + controls/FUiCtrl_SliderPresenter.cpp + controls/FUiCtrl_SplitPanel.cpp + controls/FUiCtrl_SplitPanelModel.cpp + controls/FUiCtrl_SplitPanelPresenter.cpp + controls/FUiCtrl_Tab.cpp + controls/FUiCtrl_TabImpl.cpp + controls/FUiCtrl_TabItem.cpp + controls/FUiCtrl_TabPresenter.cpp + controls/FUiCtrl_TabModel.cpp + controls/FUiCtrl_TabBar.cpp + controls/FUiCtrl_TabBarItem.cpp + controls/FUiCtrl_TabBarModel.cpp + controls/FUiCtrl_TabBarPresenter.cpp + controls/FUiCtrl_Toolbar.cpp + controls/FUiCtrl_ToolbarModel.cpp + controls/FUiCtrl_ToolbarPresenter.cpp + controls/FUiCtrl_TokenEdit.cpp + controls/FUiCtrl_TokenEditPresenter.cpp + controls/FUiCtrl_TokenEditModel.cpp + controls/FUiCtrl_UiIconListItemEvent.cpp + controls/FUiCtrl_AnimationImpl.cpp + controls/FUiCtrl_AnimationFrameImpl.cpp + controls/FUiCtrl_ButtonImpl.cpp + controls/FUiCtrl_ButtonItemImpl.cpp + controls/FUiCtrl_CheckButtonImpl.cpp + controls/FUiCtrl_ContextMenuImpl.cpp + controls/FUiCtrl_ColorPickerImpl.cpp + controls/FUiCtrl_EditDateImpl.cpp + controls/FUiCtrl_EditFieldImpl.cpp + controls/FUiCtrl_EditTimeImpl.cpp + controls/FUiCtrl_FooterImpl.cpp + controls/FUiCtrl_FooterItemImpl.cpp + controls/FUiCtrl_FormImpl.cpp + controls/FUiCtrl_FrameImpl.cpp + controls/FUiCtrl_HeaderImpl.cpp + controls/FUiCtrl_HeaderItemImpl.cpp + controls/FUiCtrl_LabelImpl.cpp + controls/FUiCtrl_MessageBoxImpl.cpp + controls/FUiCtrl_IconListViewImpl.cpp + controls/FUiCtrl_IconListViewItemImpl.cpp + controls/FUiCtrl_OptionMenuImpl.cpp + controls/FUiCtrl_PanelImpl.cpp + controls/FUiCtrl_PopupImpl.cpp + controls/FUiCtrl_ProgressImpl.cpp + controls/FUiCtrl_RadioGroupImpl.cpp + controls/FUiCtrl_OverlayAgent.cpp + controls/FUiCtrl_OverlayPanel.cpp + controls/FUiCtrl_OverlayPanelImpl.cpp + controls/FUiCtrl_OverlayRegionImpl.cpp + controls/FUiCtrl_SearchBarImpl.cpp + controls/FUiCtrl_SliderImpl.cpp + controls/FUiCtrl_SplitPanelImpl.cpp + controls/FUiCtrl_TextBoxImpl.cpp + controls/FUiCtrl_Scroll.cpp + controls/FUiCtrl_ScrollPresenter.cpp + controls/FUiCtrl_UiScrollEvent.cpp + controls/FUiCtrl_UiScrollEventArg.cpp + controls/FUiCtrl_FastScroll.cpp + controls/FUiCtrl_FastScrollPresenter.cpp + controls/FUiCtrl_FastScrollModel.cpp + controls/FUiCtrl_FastScrollIndex.cpp + controls/FUiCtrl_FastScrollIndexNode.cpp + controls/FUiCtrl_FastScrollEvent.cpp + controls/FUiCtrl_FastScrollEventArg.cpp + controls/FUiCtrl_UiFastScrollEvent.cpp + controls/FUiCtrl_UiFastScrollEventArg.cpp + controls/FUiCtrl_TabBarImpl.cpp + controls/FUiCtrl_DimmingLayer.cpp + controls/FUiCtrl_Gallery.cpp + controls/FUiCtrl_GalleryBitmap.cpp + controls/FUiCtrl_GalleryCanvas.cpp + controls/FUiCtrl_GalleryCanvasManager.cpp + controls/FUiCtrl_GalleryCoreEvent.cpp + controls/FUiCtrl_GalleryCoreEventArg.cpp + controls/FUiCtrl_GalleryCoreEventListener.cpp + controls/FUiCtrl_GalleryImageReader.cpp + controls/FUiCtrl_GalleryImpl.cpp + controls/FUiCtrl_GalleryImplEvent.cpp + controls/FUiCtrl_GalleryImplEventArg.cpp + controls/FUiCtrl_GalleryItem.cpp + controls/FUiCtrl_GalleryItemImpl.cpp + controls/FUiCtrl_GalleryItemProvider.cpp + controls/FUiCtrl_GalleryItemProviderAdaptor.cpp + controls/FUiCtrl_GalleryItemProviderAdaptorImpl.cpp + controls/FUiCtrl_GalleryModel.cpp + controls/FUiCtrl_GalleryPresenter.cpp + controls/FUiCtrl_GalleryRenderer.cpp + controls/FUiCtrl_GalleryRendererNotifier.cpp + controls/FUiCtrl_GalleryViewEvent.cpp + controls/FUiCtrl_GalleryViewEventInfo.cpp + controls/FUiCtrl_GalleryViewEventHandler.cpp +# ProgressPopup + controls/FUiCtrlProgressPopup.cpp + controls/FUiCtrl_ProgressPopupImpl.cpp + controls/FUiCtrl_ProgressPopup.cpp + controls/FUiCtrl_ProgressPopupPresenter.cpp + controls/FUiCtrl_PublicProgressPopupEvent.cpp + controls/FUiCtrl_ProgressPopupEvent.cpp +# End of ProgressPopup +# 1.x Lists + controls/FUiCtrlCustomListItem.cpp + controls/FUiCtrlCustomListItemFormat.cpp + controls/FUiCtrl_CustomListItemImpl.cpp + controls/FUiCtrl_CustomListItemFormatImpl.cpp + controls/FUiCtrlCustomList.cpp + controls/FUiCtrl_CustomListImpl.cpp + controls/FUiCtrlExpandableList.cpp + controls/FUiCtrl_ExpandableListImpl.cpp + controls/FUiCtrlList.cpp + controls/FUiCtrl_ListImpl.cpp + controls/FUiCtrlGroupedList.cpp + controls/FUiCtrl_GroupedListImpl.cpp + controls/FUiCtrlSlidableList.cpp + controls/FUiCtrl_SlidableListImpl.cpp + controls/FUiCtrlSlidableGroupedList.cpp + controls/FUiCtrl_SlidableGroupedListImpl.cpp + controls/FUiCtrl_ListBaseImpl.cpp + controls/FUiCtrl_CustomListElements.cpp + resource/FUi_ResourceListConfig.cpp +# End of 1.x Lists +# ListView + controls/FUiCtrlCustomItem.cpp + controls/FUiCtrlGroupedListView.cpp + controls/FUiCtrlGroupItem.cpp + controls/FUiCtrlIGroupedListViewItemEventListener.cpp + controls/FUiCtrlIGroupedListViewItemProvider.cpp + controls/FUiCtrlIListViewItemEventListener.cpp + controls/FUiCtrlListContextItem.cpp + controls/FUiCtrlListItemBase.cpp + controls/FUiCtrlListView.cpp + controls/FUiCtrlSimpleItem.cpp + controls/FUiCtrl_CustomElement.cpp + controls/FUiCtrl_CustomItemImpl.cpp + controls/FUiCtrl_GroupedListViewImpl.cpp + controls/FUiCtrl_GroupedListViewItemProviderAdaptor.cpp + controls/FUiCtrl_GroupItemImpl.cpp + controls/FUiCtrl_ListContextItemImpl.cpp + controls/FUiCtrl_ListItemBaseImpl.cpp + controls/FUiCtrl_ListItemCommon.cpp + controls/FUiCtrl_ListItemEvent.cpp + controls/FUiCtrl_ListItemEventArg.cpp + controls/FUiCtrl_ListViewContextItem.cpp + controls/FUiCtrl_ListViewImpl.cpp + controls/FUiCtrl_ListViewItem.cpp + controls/FUiCtrl_ListViewItemProviderAdaptor.cpp + controls/FUiCtrl_ListViewModel.cpp + controls/FUiCtrl_SimpleItemImpl.cpp + controls/FUiCtrl_UiListViewItemEvent.cpp + controls/FUiCtrl_UiListViewItemEventArg.cpp + controls/FUiCtrl_FlickAnimation.cpp +# End of ListView +# TableView related + controls/FUiCtrlTableView.cpp + controls/FUiCtrlGroupedTableView.cpp + controls/FUiCtrlSectionTableView.cpp + controls/FUiCtrlTableViewItemBase.cpp + controls/FUiCtrlTableViewItem.cpp + controls/FUiCtrlTableViewSimpleItem.cpp + controls/FUiCtrlTableViewGroupItem.cpp + controls/FUiCtrlTableViewSimpleGroupItem.cpp + controls/FUiCtrlTableViewContextItem.cpp + controls/FUiCtrl_UiTableViewItemEvent.cpp + controls/FUiCtrl_TableView.cpp + controls/FUiCtrl_TableViewImpl.cpp + controls/FUiCtrl_TableViewItem.cpp + controls/FUiCtrl_TableViewItemImpl.cpp + controls/FUiCtrl_TableViewItemEvent.cpp + controls/FUiCtrl_TableViewItemEventArg.cpp + controls/FUiCtrl_TableViewItemProvider.cpp + controls/FUiCtrl_TableViewItemProviderAdaptor.cpp + controls/FUiCtrl_TableViewPresenter.cpp +# end of TableView related + layout/FUi_LayoutLayout.cpp + layout/FUi_LayoutLayoutItem.cpp + layout/FUi_LayoutLayoutItemInfo.cpp + layout/FUi_LayoutLayoutItemProxy.cpp + layout/FUi_LayoutLayoutContainer.cpp + layout/FUi_LayoutLayoutList.cpp + layout/FUi_LayoutLayoutListNode.cpp + layout/FUi_LayoutLinkedList.cpp + layout/FUi_LayoutLinkedListNode.cpp + layout/FUi_LayoutProxyList.cpp + layout/FUi_LayoutProxyListNode.cpp + layout/FUi_LayoutAbsoluteLayout.cpp + layout/FUi_LayoutRelativeLayout.cpp + layout/FUi_LayoutLinearLayout.cpp + layout/FUi_LayoutTableLayout.cpp + scenes/FUiScenesBackwardSceneTransition.cpp + scenes/FUiScenesForwardSceneTransition.cpp + scenes/FUiScenesScene.cpp + scenes/FUiScenesSceneManager.cpp + scenes/FUiScenesSceneTransition.cpp + scenes/FUiScenes_SceneTransitionImpl.cpp + scenes/FUiScenes_SceneImpl.cpp + scenes/FUiScenes_SceneManagerImpl.cpp + scenes/FUiScenes_SceneControlEventArg.cpp + scenes/FUiScenes_SceneControlEvent.cpp + resource/FUi_ResourceAccessibilityConfig.cpp + resource/FUi_ResourcePopupConfig.cpp + resource/FUi_ResourceMessageBoxConfig.cpp + resource/FUi_ResourceButtonConfig.cpp + resource/FUi_ResourceCheckButtonConfig.cpp + resource/FUi_ResourceContextMenuConfig.cpp + resource/FUi_ResourceDateTimePickerConfig.cpp + resource/FUi_ResourceFooterConfig.cpp + resource/FUi_ResourceFormConfig.cpp + resource/FUi_ResourceHeaderConfig.cpp + resource/FUi_ResourceIconListConfig.cpp + resource/FUi_ResourceInputPadConfig.cpp + resource/FUi_ResourceLabelConfig.cpp + resource/FUi_ResourceListViewConfig.cpp + resource/FUi_ResourceRadioGroupConfig.cpp + resource/FUi_ResourceSplitPanelConfig.cpp + resource/FUi_ResourceTabBarConfig.cpp + resource/FUi_ResourceTableViewConfig.cpp + resource/FUi_ResourceTabConfig.cpp + resource/FUi_ResourceMapContainer.cpp + resource/FUi_ResourcePanelConfig.cpp + resource/FUi_ResourceColorPickerConfig.cpp + resource/FUi_ResourceDateTimeBarConfig.cpp + resource/FUi_ResourceEditConfig.cpp + resource/FUi_ResourceEditDateConfig.cpp + resource/FUi_ResourceEditTimeConfig.cpp + resource/FUi_ResourceFastScrollConfig.cpp + resource/FUi_ResourceOverlayPanelConfig.cpp + resource/FUi_ResourceScrollConfig.cpp + resource/FUi_ResourceSearchBarConfig.cpp + resource/FUi_ResourceSliderConfig.cpp + resource/FUi_ResourceTokenEditConfig.cpp + resource/FUi_ResourceOptionMenuConfig.cpp + resource/FUi_ResourceGalleryConfig.cpp + resource/FUi_ResourceSizeInfo.cpp + resource/FUi_ResourceStringLoader.cpp + resource/FUi_ResourceConfigLoader.cpp + resource/FUi_ResourceConfigParser.cpp + ## EFFECTS + effects/FUiEffects_EffectErrorMessages.cpp + effects/FUiEffects_EffectManagerImpl.cpp + effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderCache.cpp + effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderBufferCache.cpp + effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderStateCache.cpp + effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderTextureCache.cpp + effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderDrawableCache.cpp + effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRender.cpp + effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderRenderTargetCache.cpp + effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderShaderCache.cpp + effects/renderer/FUiEffects_RendererMemoryTexture2DProperty.cpp + effects/renderer/FUiEffects_RendererEffectShader.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelMaterial.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelNode.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelRenderTargetExternalRender.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelFloatArrayProperty.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelBuffer.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelTextureAttachment.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelPropertyHolderMaterial.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelVector3fPropertyHolder.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelMatrix4fPropertyHolder.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelShaderHolderProgramProperty.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelStringShaderProperty.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelAlphaBlendProperty.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DAttachmentProperty.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelVector2fPropertyHolder.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DProperty.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelVector4fPropertyHolder.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelDrawable.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelProperty.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelGeometry.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelTextureProperty.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelCache.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelGroup.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelRenderTarget.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelFloatPropertyHolder.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelStubAttachment.cpp + effects/renderer/engine-model/FUiEffects_RendererEngineModelCamera.cpp + effects/renderer/system/FUiEffects_RendererSystemData.cpp + effects/renderer/system/FUiEffects_RendererSystemException.cpp + effects/renderer/system/FUiEffects_RendererSystemPlatformDefine.cpp + effects/renderer/FUiEffects_RendererRendererGeometry.cpp + effects/renderer/FUiEffects_RendererLog.cpp + effects/renderer/FUiEffects_RendererEffectRenderer.cpp + effects/parser/FUiEffects_ParserEffectParser.cpp + effects/parser/FUiEffects_ParserXMLParser.cpp + effects/FUiEffectsEffect.cpp + effects/FUiEffectsEffectManager.cpp + effects/FUiEffects_EffectImpl.cpp + effects/runtime/lua-cpp-binding/tolua.cpp + effects/runtime/FUiEffects_RuntimeGraphicalSurface.cpp + effects/runtime/FUiEffects_RuntimePointLight.cpp + effects/runtime/FUiEffects_RuntimeDirectionalLight.cpp + effects/runtime/FUiEffects_RuntimeModelSurface.cpp + effects/runtime/FUiEffects_RuntimeSpotLight.cpp + effects/runtime/FUiEffects_RuntimeEffectModelScript.cpp + effects/runtime/FUiEffects_RuntimeLuaProcessing.cpp + effects/runtime/FUiEffects_RuntimeGraphicalSurfaceNurbs.cpp + effects/runtime/FUiEffects_RuntimeRenderDataScene.cpp + effects/runtime/FUiEffects_RuntimeEffectModel.cpp + effects/runtime/FUiEffects_RuntimeUnitLight.cpp + effects/FUiEffectsEffectTouchInfo.cpp + effects/physics-engine/FUiEffects_PeRodSurface.cpp + effects/physics-engine/FUiEffects_PeElementSurface.cpp + effects/physics-engine/FUiEffects_PePointSurfaceNURBS.cpp + effects/physics-engine/FUiEffects_PeSpringSurface.cpp + effects/physics-engine/FUiEffects_PeRodSurfaceNURBS.cpp + effects/physics-engine/FUiEffects_PePointSurface.cpp +) + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") + +## SET EXTRA COMPILER FLAGS +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC" ) + +## SET C COMPILER FLAGS +SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## SET CPP COMPILER FLAGS +SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## Create Library +ADD_LIBRARY (${this_target} STATIC ${${this_target}_SOURCE_FILES}) + diff --git a/src/ui/FUiAccessibilityContainer.cpp b/src/ui/FUiAccessibilityContainer.cpp new file mode 100644 index 0000000..15ff576 --- /dev/null +++ b/src/ui/FUiAccessibilityContainer.cpp @@ -0,0 +1,134 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiAccessibilityContainer.cpp +* @brief This is the implementation for the AccessibilityContainer class. +*/ + +#include +#include +#include +#include +#include +#include "FUi_AccessibilityElementImpl.h" +#include "FUi_AccessibilityContainerImpl.h" +#include "FUi_ControlImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui { +AccessibilityContainer::AccessibilityContainer(void) +:__pAccessibilityContainerImpl(null) +{ +} + +AccessibilityContainer::~AccessibilityContainer(void) +{ +} + +const Control* +AccessibilityContainer::GetOwner(void) const +{ + SysAssertf(__pAccessibilityContainerImpl != null, "Not constructed properly by platform."); + return &(__pAccessibilityContainerImpl->GetOwner().GetPublic()); +} + +Control* +AccessibilityContainer::GetOwner(void) +{ + SysAssertf(__pAccessibilityContainerImpl != null, "Not constructed properly by platform."); + return &(__pAccessibilityContainerImpl->GetOwner().GetPublic()); +} + +result +AccessibilityContainer::AddAccessibilityListener(IAccessibilityListener& listener) +{ + SysAssertf(__pAccessibilityContainerImpl != null, "Not constructed properly by platform."); + result r = __pAccessibilityContainerImpl->AddAccessibilityListener(listener); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Failed to add a listener. ",GetErrorMessage(r)); + return r; +} + +result +AccessibilityContainer::RemoveAccessibilityListener(IAccessibilityListener& listener) +{ + SysAssertf(__pAccessibilityContainerImpl != null, "Not constructed properly by platform."); + result r = __pAccessibilityContainerImpl->RemoveAccessibilityListener(listener); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Failed to Remove a listener. ",GetErrorMessage(r)); + return r; + +} + +AccessibilityElement* +AccessibilityContainer::GetElement(const String& name) const +{ + SysAssertf(__pAccessibilityContainerImpl != null, "Not constructed properly by platform."); + ClearLastResult(); + AccessibilityElement* pElement = __pAccessibilityContainerImpl->GetChildElement(name); + SysTryReturn(NID_UI, pElement, null, E_SYSTEM, "[E_SYSTEM] Getting a child by name is failed.."); + return pElement; +} + +result +AccessibilityContainer::AddElement(AccessibilityElement& element) +{ + SysAssertf(__pAccessibilityContainerImpl != null, "Not constructed properly by platform."); + ClearLastResult(); + return __pAccessibilityContainerImpl->AddElement(*_AccessibilityElementImpl::GetInstance(element)); +} + +//result +//AccessibilityContainer::InsertElement(AccessibilityElement* pPreviousElement, AccessibilityElement& element) +//{ +// ClearLastResult(); +// return __pAccessibilityContainerImpl->MoveElement(_AccessibilityElementImpl::GetInstance(*pPreviousElement) +// , *(_AccessibilityElementImpl::GetInstance(element))); +//} + +IList* +AccessibilityContainer::GetElementsN(void) const +{ + SysAssertf(__pAccessibilityContainerImpl != null, "Not constructed properly by platform."); + return __pAccessibilityContainerImpl->GetElementsN(); +} + +result +AccessibilityContainer::RemoveElement(AccessibilityElement& element) +{ + SysAssertf(__pAccessibilityContainerImpl != null, "Not constructed properly by platform."); + ClearLastResult(); + return __pAccessibilityContainerImpl->RemoveElement(*_AccessibilityElementImpl::GetInstance(element)); +} + +void +AccessibilityContainer::RemoveAllElements(void) +{ + SysAssertf(__pAccessibilityContainerImpl != null, "Not constructed properly by platform."); + __pAccessibilityContainerImpl->RemoveAllElement(); +} + +//result +//AccessibilityContainer::MoveElement(AccessibilityElement* pPreviousElement, AccessibilityElement& element) +//{ +// ClearLastResult(); +// return __pAccessibilityContainerImpl->MoveElement(_AccessibilityElementImpl::GetInstance(*pPreviousElement) +// , *(_AccessibilityElementImpl::GetInstance(element))); +//} + +}} //Tizen::Ui + diff --git a/src/ui/FUiAccessibilityElement.cpp b/src/ui/FUiAccessibilityElement.cpp new file mode 100644 index 0000000..675c945 --- /dev/null +++ b/src/ui/FUiAccessibilityElement.cpp @@ -0,0 +1,117 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include +#include "FUi_AccessibilityElementImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { +AccessibilityElement::AccessibilityElement(void) + :__pAccessibilityElementImpl(null) +{ +} +AccessibilityElement::~AccessibilityElement(void) +{ + delete __pAccessibilityElementImpl; + __pAccessibilityElementImpl = null; +} +result +AccessibilityElement::Construct(const Rectangle& bounds, const String& name) +{ + ClearLastResult(); + SysAssertf(__pAccessibilityElementImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + __pAccessibilityElementImpl = new (std::nothrow) _AccessibilityElementImpl(*this); + SysTryReturn(NID_UI, __pAccessibilityElementImpl, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + return __pAccessibilityElementImpl->Construct(name, bounds); +} + +void +AccessibilityElement::SetBounds(const Rectangle& bounds) +{ + SysAssertf(__pAccessibilityElementImpl != null, "Not yet constructed. Construct() should be called before use."); + ClearLastResult(); + return __pAccessibilityElementImpl->SetBounds(bounds); +} +void +AccessibilityElement::SetLabel(const String& label) +{ + SysAssertf(__pAccessibilityElementImpl != null, "Not yet constructed. Construct() should be called before use."); + ClearLastResult(); + return __pAccessibilityElementImpl->SetLabel(label); +} +void +AccessibilityElement::SetHint(const String& hint) +{ + SysAssertf(__pAccessibilityElementImpl != null, "Not yet constructed. Construct() should be called before use."); + ClearLastResult(); + return __pAccessibilityElementImpl->SetHint(hint); +} +void +AccessibilityElement::SetTrait(const String& trait) +{ + SysAssertf(__pAccessibilityElementImpl != null, "Not yet constructed. Construct() should be called before use."); + return __pAccessibilityElementImpl->SetTrait(trait); +} +void +AccessibilityElement::SetValue(const Tizen::Base::String& value) +{ + SysAssertf(__pAccessibilityElementImpl != null, "Not yet constructed. Construct() should be called before use."); + return __pAccessibilityElementImpl->SetValue(value); +} +String +AccessibilityElement::GetName(void) const +{ + SysAssertf(__pAccessibilityElementImpl != null, "Not yet constructed. Construct() should be called before use."); + return __pAccessibilityElementImpl->GetName(); +} +Rectangle +AccessibilityElement::GetBounds(void) const +{ + SysAssertf(__pAccessibilityElementImpl != null, "Not yet constructed. Construct() should be called before use."); + return __pAccessibilityElementImpl->GetBounds(); +} +String +AccessibilityElement::GetLabel(void) const +{ + SysAssertf(__pAccessibilityElementImpl != null, "Not yet constructed. Construct() should be called before use."); + return __pAccessibilityElementImpl->GetLabel(); +} +String +AccessibilityElement::GetHint(void) const +{ + SysAssertf(__pAccessibilityElementImpl != null, "Not yet constructed. Construct() should be called before use."); + return __pAccessibilityElementImpl->GetHint(); +} +String +AccessibilityElement::GetTrait(void) const +{ + SysAssertf(__pAccessibilityElementImpl != null, "Not yet constructed. Construct() should be called before use."); + return __pAccessibilityElementImpl->GetTraitString(); +} +Tizen::Base::String +AccessibilityElement::GetValue(void) const +{ + SysAssertf(__pAccessibilityElementImpl != null, "Not yet constructed. Construct() should be called before use."); + return __pAccessibilityElementImpl->GetValue(); +} + +}} //Tizen::Ui diff --git a/src/ui/FUiCardLayout.cpp b/src/ui/FUiCardLayout.cpp new file mode 100644 index 0000000..7e9e7ca --- /dev/null +++ b/src/ui/FUiCardLayout.cpp @@ -0,0 +1,62 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCardLayout.cpp + * @brief This is the implementation file for CardLayout class. + * + * This file contains the implementation of CardLayout class. + */ + +#include +#include +#include "FUi_CardLayoutImpl.h" + +namespace Tizen { namespace Ui +{ + +CardLayout::CardLayout(void) +{ +} + +CardLayout::~CardLayout(void) +{ +} + +result +CardLayout::Construct(void) +{ + ClearLastResult(); + + _CardLayoutImpl* pCardLayoutImpl = _CardLayoutImpl::GetInstance(*this); + SysAssertf(pCardLayoutImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pCardLayoutImpl = _CardLayoutImpl::CreateCardLayoutImplN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _LayoutImpl::SetLayoutImpl(this, pCardLayoutImpl); + + return E_SUCCESS; +} + +Tizen::Ui::LayoutType +CardLayout::GetLayoutType(void) const +{ + return LAYOUT_CARD; +} + +}} // Tizen::Ui diff --git a/src/ui/FUiClipboard.cpp b/src/ui/FUiClipboard.cpp new file mode 100644 index 0000000..2f50bec --- /dev/null +++ b/src/ui/FUiClipboard.cpp @@ -0,0 +1,149 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiClipboard.cpp + * @brief This is the implementation file for Clipboard class. + * @version 1.0 + * + * This file contains the implementation of Header class. + */ +#include +#include +#include +#include "FUi_ClipboardImpl.h" +#include "FUi_ClipboardItemImpl.h" + +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui +{ + +result +Clipboard::CopyItem(const ClipboardItem& item) +{ + SysAssertf((__pClipboardImpl != null), "Clipboard wasn't initialized."); + + const _ClipboardItemImpl* pItemImpl = _ClipboardItemImpl::GetInstance(item); + SysTryReturn(NID_UI, pItemImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + + result r = __pClipboardImpl->CopyItem(*pItemImpl); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +IList* +Clipboard::RetrieveItemsN(unsigned long dataTypes) +{ + SysAssertf((__pClipboardImpl != null), "Clipboard wasn't initialized."); + + IList* pList = __pClipboardImpl->RetrieveItemsN(dataTypes); + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pList; + +CATCH: + if (pList) + { + pList->RemoveAll(true); + delete pList; + } + + return null; +} + +ClipboardItem* +Clipboard::RetrieveLatestItemN(unsigned long dataTypes) +{ + SysAssertf((__pClipboardImpl != null), "Clipboard wasn't initialized."); + + _ClipboardItemImpl* pItemImpl = __pClipboardImpl->RetrieveLatestItemN(dataTypes); + result r = GetLastResult(); + SysTryReturn(NID_UI, pItemImpl, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return &(pItemImpl->GetPublic()); +} + +result +Clipboard::ShowPopup(unsigned long dataTypes, const Tizen::Ui::IClipboardPopupEventListener& listener) +{ + Clipboard* pClipboard = GetInstance(); + SysAssertf((pClipboard != null), "Clipboard wasn't initialized."); + + _ClipboardImpl* pClipboardImpl = _ClipboardImpl::GetInstance(*pClipboard); + SysAssertf((pClipboardImpl != null), "Clipboard wasn't initialized."); + + result r = pClipboardImpl->ShowPopup(dataTypes, listener); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +Clipboard::HidePopup(void) +{ + Clipboard* pClipboard = GetInstance(); + SysAssertf((pClipboard != null), "Clipboard wasn't initialized."); + + _ClipboardImpl* pClipboardImpl = _ClipboardImpl::GetInstance(*pClipboard); + SysAssertf((pClipboardImpl != null), "Clipboard wasn't initialized."); + + result r = pClipboardImpl->HidePopup(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +bool +Clipboard::IsPopupVisible(void) +{ + Clipboard* pClipboard = GetInstance(); + SysAssertf((pClipboard != null), "Clipboard wasn't initialized."); + + _ClipboardImpl* pClipboardImpl = _ClipboardImpl::GetInstance(*pClipboard); + SysAssertf((pClipboardImpl != null), "Clipboard wasn't initialized."); + + return pClipboardImpl->IsPopupVisible(); +} + +Clipboard* +Clipboard::GetInstance(void) +{ + static Clipboard instance; + + return (&instance); +} + +Clipboard::Clipboard(void) + : __pClipboardImpl(null) +{ + __pClipboardImpl = _ClipboardImpl::CreateInstanceN(); +} + +Clipboard::~Clipboard(void) +{ + delete __pClipboardImpl; + __pClipboardImpl = null; +} + +}} //Tizen::Ui diff --git a/src/ui/FUiClipboardItem.cpp b/src/ui/FUiClipboardItem.cpp new file mode 100644 index 0000000..721669a --- /dev/null +++ b/src/ui/FUiClipboardItem.cpp @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiClipboardItem.cpp + * @brief This is the implementation file for ClipboardItem class. + * @version 1.0 + * + * This file contains the implementation of ClipboardItem class. + */ +#include +#include +#include +#include "FUi_ClipboardItemImpl.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui +{ + +ClipboardItem::ClipboardItem(void) + : __pImpl(null) +{ +} + +ClipboardItem::~ClipboardItem(void) +{ + delete __pImpl; +} + +result +ClipboardItem::Construct(ClipboardDataType dataType, const Object& data) +{ + SysAssertf((__pImpl == null), + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + __pImpl = _ClipboardItemImpl::CreateInstanceN(this, dataType, data); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +ClipboardDataType +ClipboardItem::GetDataType(void) const +{ + if (!__pImpl) + { + return CLIPBOARD_DATA_TYPE_NONE; + } + + return __pImpl->GetDataType(); +} + +Object* +ClipboardItem::GetData(void) const +{ + if (!__pImpl) + { + return null; + } + + return __pImpl->GetData(); +} + +}} // Tizen::Ui diff --git a/src/ui/FUiContainer.cpp b/src/ui/FUiContainer.cpp new file mode 100644 index 0000000..4888580 --- /dev/null +++ b/src/ui/FUiContainer.cpp @@ -0,0 +1,369 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiContainer.cpp + * @brief This is the implementation file for Container class. + */ + +#include +#include +#include "FUi_ContainerImpl.h" +#include "FUi_ErrorMessages.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { + +Container::Container(void) +{ +} + +Container::~Container(void) +{ +} + +result +Container::Construct(void) +{ + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _ContainerImpl* pImpl = _ContainerImpl::CreateContainerImplN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return E_SUCCESS; +} + +result +Container::Construct(const Rectangle& rect, bool resizable, bool movable) +{ + result r = E_SUCCESS; + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + _ContainerImpl* pImpl = _ContainerImpl::CreateContainerImplN(this, rect, null, null, resizable, movable); + r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return E_SUCCESS; +} + +result +Container::Construct(const Layout& layout, const Rectangle& rect, bool resizable, bool movable) +{ + return Construct(layout, layout, rect, resizable, movable); +} + +result +Container::Construct(const Layout& portraitLayout, const Layout& landscapeLayout, + const Rectangle& rect, bool resizable, bool movable) +{ + result r = E_SUCCESS; + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _ContainerImpl* pImpl = + _ContainerImpl::CreateContainerImplN(this, rect, &portraitLayout, &landscapeLayout, resizable, movable); + + r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + + _pControlImpl = pImpl; + + return E_SUCCESS; +} + +result +Container::AddControl(const Control& control) +{ + _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddChild(const_cast <_ControlImpl*>(_ControlImpl::GetInstance(control))); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +Container::RemoveAllControls(void) +{ + _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveAllChildren(false); +} + +result +Container::RemoveControl(const Control& control) +{ + _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveChild(const_cast <_ControlImpl*>(_ControlImpl::GetInstance(control))); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Container::RemoveControl(int index) +{ + _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveChild(index); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Container::SetControlAt(const Control& control, int index) +{ + _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetChildAt(_ControlImpl::GetInstance(control), index); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Container::GetControlAt(const Control& control, int& index) const +{ + const _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + int childIndex = pImpl->GetChildIndex(const_cast <_ControlImpl*>(_ControlImpl::GetInstance(control))); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + index = childIndex; + + return E_SUCCESS; +} + +int +Container::GetControlCount(void) const +{ + const _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetChildCount(); +} + +Control* +Container::GetControl(int index) const +{ + const _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pChildImpl = pImpl->GetChild(index); + result r = GetLastResult(); + SysTryReturn(NID_UI, pChildImpl, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return &pChildImpl->GetPublic(); +} + +Control* +Container::GetControl(const Tizen::Base::String& name, bool recursive) const +{ + const _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pChildImpl = pImpl->SearchControlByName(name, recursive); + if (pChildImpl == null) + { + return null; + } + + return &pChildImpl->GetPublic(); +} + +IList* +Container::GetControls(void) const +{ + const _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + IList* pChildren = pImpl->GetChildrenPublic(); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pChildren; +} + +bool +Container::IsAncestorOf(const Control& control) const +{ + const _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + bool ancestorOf = pImpl->IsAncestorOf(_ControlImpl::GetInstance(control)); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + return ancestorOf; +} + +void +Container::OnClearBackground(void) +{ + const _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + if (pImpl->GetCore().IsCalledGetCanvasN()) + { + Canvas* pCanvas = GetCanvasN(); + if (pCanvas) + { + pCanvas->SetBackgroundColor(pImpl->GetBackgroundColor()); + pCanvas->Clear(); + delete pCanvas; + } + } +} + +result +Container::OnDraw(void) +{ + _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->CallOnDraw(); + return E_SUCCESS; +} + +result +Container::OnBoundsChanging(const Rectangle& oldRect, const Rectangle& newRect) +{ + return E_SUCCESS; +} + +void +Container::OnEvaluateSize(Tizen::Graphics::Dimension& evaluatedSize) +{ + +} + +void +Container::OnBoundsChanged(const Rectangle& oldRect, const Rectangle& newRect) +{ + +} + +void +Container::OnShowStateChanging(bool showState) +{ + +} + +void +Container::OnShowStateChanged(bool showState) +{ + +} + +Layout* +Container::GetPortraitLayoutN(void) const +{ + const _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + Layout* pLayout = pImpl->GetPublicPortraitLayoutN(); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pLayout; +} + +Layout* +Container::GetLandscapeLayoutN(void) const +{ + const _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + Layout* pLayout = pImpl->GetPublicLandscapeLayoutN(); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pLayout; +} + +Layout* +Container::GetLayoutN(void) const +{ + const _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + Layout* pLayout = pImpl->GetPublicLayoutN(); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pLayout; +} + +result +Container::SetControlAlwaysOnTop(Control& control, bool alwaysOnTop) +{ + _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetControlAlwaysOnTop(control, alwaysOnTop); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Container::SetControlAlwaysAtBottom(Control& control, bool alwaysAtBottom) +{ + _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetControlAlwaysAtBottom(control, alwaysAtBottom); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +bool +Container::IsControlAlwaysAtBottom(const Control& control) const +{ + const _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsControlAlwaysAtBottom(control); +} + +bool +Container::IsControlAlwaysOnTop(const Control& control) const +{ + const _ContainerImpl* pImpl = _ContainerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsControlAlwaysOnTop(control); +} + +}} //Tizen::Ui diff --git a/src/ui/FUiControl.cpp b/src/ui/FUiControl.cpp new file mode 100644 index 0000000..c2d1e7e --- /dev/null +++ b/src/ui/FUiControl.cpp @@ -0,0 +1,1177 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiControl.cpp + * @brief This is the implementation file for the Control class. + */ + +#include +#include +#include +#include +#include +#include "FUi_ControlImpl.h" +#include "FUi_ContainerImpl.h" +#include "FUi_ErrorMessages.h" +#include "FUiAnimVisualElement.h" +#include "FUiAnimVisualElementSurface.h" +#include "FUiAnim_VisualElementSurfaceImpl.h" + +// for sto +#include +#include "FUiAnim_EflNode.h" +#include "FUiAnim_EflLayer.h" +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_DisplayContextImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; + +extern "C" _OSP_EXPORT_ void* +STO_GetNativeHandle(void* pControl) +{ + Handle nativeHandle = 0; + Tizen::Ui::Control* pControlPointer = (Tizen::Ui::Control*)pControl; + + if (pControlPointer) + { + Tizen::Ui::_ControlImpl* pControlImpl = Tizen::Ui::_ControlImpl::GetInstance(*pControlPointer); + + if (pControlImpl) + { + VisualElement *pVisualElement = pControlImpl->GetVisualElement(); + + if (pVisualElement) + { + VisualElementSurface* pSurface = pVisualElement->GetSurfaceN(); + + if (pSurface) + { + _VisualElementSurfaceImpl* pSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pSurface); + if (pSurfaceImpl) + nativeHandle = pSurfaceImpl->GetNativeHandle(); + + delete pSurface; + } + } + } + } + + return (void*)nativeHandle; +} + +extern "C" _OSP_EXPORT_ void +STO_NativeHandleSetShowState(void* pNative, bool show) +{ + if(show) + evas_object_show((Evas_Object*)pNative); + else + evas_object_hide((Evas_Object*)pNative); +} + +extern "C" _OSP_EXPORT_ void* +STO_GetVisualElement(void* pControl) +{ + Tizen::Ui::Control* pControlPointer = (Tizen::Ui::Control*)pControl; + Tizen::Ui::_ControlImpl* pControlImpl = Tizen::Ui::_ControlImpl::GetInstance(*pControlPointer); + + return (void *)pControlImpl->GetVisualElement(); +} + +extern "C" _OSP_EXPORT_ +void STO_NativeHandleDataSet(void* pEvasObject, void* pData, int width, int height) +{ + evas_object_image_size_set((Evas_Object*)pEvasObject, width, height); + evas_object_image_data_set((Evas_Object*)pEvasObject, pData); +} + + + +extern "C" _OSP_EXPORT_ void +STO_SetVisualElementNativeObject(void* pVisualElement, void* pNativeObject) +{ + VisualElement* pVE = (VisualElement* )pVisualElement; + Evas_Object* pEO = (Evas_Object*)pNativeObject; + + _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE); + + _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode(); + pNode->AddNativeSmartObject(*pVE, pEO); + + int imageWidth = 0; + int imageHeight = 0; + + evas_object_image_size_get(pEO, &imageWidth, &imageHeight); + evas_object_image_data_update_add(pEO, 0, 0, imageWidth, imageHeight); +} + +extern "C" _OSP_EXPORT_ +void* STO_CreateNativeImageObject(void* pDisplayContext, int width, int height) +{ + + if(!pDisplayContext) + { + return null; + } + + _DisplayContextImpl* pDispImpl = _DisplayContextImpl::GetInstance(*(DisplayContext*)pDisplayContext); + + if(!pDispImpl->GetNativeLayer()) + { + return null; + } + Evas* pEvas = ((_EflLayer*)pDispImpl->GetNativeLayer())->GetEvas(); + + if(!pEvas) + { + return null; + } + + Evas_Object* pImage = evas_object_image_filled_add(pEvas); + evas_object_resize(pImage, width, height); + evas_object_move(pImage, 0, 0); +// evas_object_show(pImage); + + return pImage; + +} + +extern "C" _OSP_EXPORT_ void +STO_Destroy(void* pVisualElement, void* pEvasObject) +{ + VisualElement* pVE = (VisualElement* )pVisualElement; + + _VisualElementImpl* pVEImpl = _VisualElementImpl::GetInstance(*pVE); + + _EflNode* pNode = (_EflNode*)pVEImpl->GetNativeNode(); + pNode->AddNativeSmartObject(*pVE, null); + + evas_object_del((Evas_Object*)pEvasObject); +} + + +namespace Tizen { namespace Ui { + +Control::Control(void) + : _pControlImpl(null) +{ +} + +Control::~Control(void) +{ + Dispose(); +} + +void +Control::Dispose(void) +{ + delete _pControlImpl; + _pControlImpl = null; +} + +result +Control::Construct(void) +{ + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _ControlImpl* pImpl = _ControlImpl::CreateControlImplN(*this); + result r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return E_SUCCESS; +} + +result +Control::Draw(void) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before used."); + + result r = pControlImpl->Draw(true); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Control::Draw(bool recursive) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->Draw(recursive); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +Control::Invalidate(bool recursive) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + pControlImpl->Invalidate(recursive); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Control::InvalidateBounds(const Tizen::Graphics::Rectangle& bounds) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before used."); + + pControlImpl->Invalidate(bounds); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +Canvas* +Control::GetCanvasN(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + Canvas* pCanvas = pControlImpl->GetCanvasN(); + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pCanvas; + +CATCH: + delete pCanvas; + return null; +} + +Canvas* +Control::GetCanvasN(int x, int y, int w, int h) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + Canvas* pCanvas = pControlImpl->GetCanvasN(Rectangle(x, y, w, h)); + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pCanvas; + +CATCH: + delete pCanvas; + return null; +} + +Canvas* +Control::GetCanvasN(const Rectangle& bounds) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + Canvas* pCanvas = pControlImpl->GetCanvasN(bounds); + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pCanvas; + +CATCH: + delete pCanvas; + return null; +} + +result +Control::SetEnabled(bool enable) +{ + //versioning + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + + if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat()) + { + SysTryReturn(NID_UI, + pControlImpl, E_UNSUPPORTED_OPERATION, + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This control is not constructed."); + } + else + { + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + } + + pControlImpl->SetEnableState(enable); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Control::Show(void) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->Show(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +Control::GetBounds(int& x, int& y, int& w, int& h) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + Rectangle bounds = pControlImpl->GetBounds(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + x = bounds.x; + y = bounds.y; + w = bounds.width; + h = bounds.height; +} + +Rectangle +Control::GetBounds(void) const +{ + const Rectangle errorBounds = _ControlImpl::GetErrorBounds(); + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + Rectangle bounds = pControlImpl->GetBounds(); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, errorBounds, r, "[%s] Propagating.", GetErrorMessage(r)); + + return bounds; +} + +Dimension +Control::GetSize(void) const +{ + const Rectangle errorBounds = _ControlImpl::GetErrorBounds(); + const Dimension errorSize(errorBounds.width, errorBounds.height); + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + Dimension size = pControlImpl->GetSize(); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, errorSize, r, "[%s] Propagating.", GetErrorMessage(r)); + + return size; +} + +void +Control::GetSize(int& w, int& h) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + Dimension size = pControlImpl->GetSize(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + w = size.width; + h = size.height; +} + +Point +Control::GetPosition(void) const +{ + const Rectangle errorBounds = _ControlImpl::GetErrorBounds(); + const Point errorPosition(errorBounds.x, errorBounds.y); + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + Point position = pControlImpl->GetPosition(); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, errorPosition, r, "[%s] Propagating.", GetErrorMessage(r)); + + return position; +} + +void +Control::GetPosition(int& x, int& y) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + Point position = pControlImpl->GetPosition(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + x = position.x; + y = position.y; +} + +int +Control::GetX(void) const +{ + const Rectangle errorBounds = _ControlImpl::GetErrorBounds(); + const int errorX = errorBounds.x; + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + int x = pControlImpl->GetPosition().x; + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, errorX, r, "[%s] Propagating.", GetErrorMessage(r)); + + return x; +} + +int +Control::GetY(void) const +{ + const Rectangle errorBounds = _ControlImpl::GetErrorBounds(); + const int errorY = errorBounds.y; + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + int y = pControlImpl->GetPosition().y; + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, errorY, r, "[%s] Propagating.", GetErrorMessage(r)); + + return y; +} + +int +Control::GetWidth(void) const +{ + const Rectangle errorBounds = _ControlImpl::GetErrorBounds(); + const int errorWidth = errorBounds.width; + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + int width = pControlImpl->GetSize().width; + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, errorWidth, r, "[%s] Propagating.", GetErrorMessage(r)); + + return width; +} + +int +Control::GetHeight(void) const +{ + const Rectangle errorBounds = _ControlImpl::GetErrorBounds(); + const int errorHeight = errorBounds.height; + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + int height = pControlImpl->GetSize().height; + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, errorHeight, r, "[%s] Propagating.", GetErrorMessage(r)); + + return height; +} + +Container* +Control::GetParent(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ContainerImpl* pParentImpl = pControlImpl->GetParent(); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pParentImpl ? &pParentImpl->GetPublic() : null; +} + +String +Control::GetFont(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->GetFont(); +} + +result +Control::SetBounds(int x, int y, int w, int h) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetBounds(Rectangle(x, y, w, h)); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Control::SetBounds(const Rectangle& bounds) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetBounds(bounds); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Control::SetSize(int w, int h) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetSize(Dimension(w, h)); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Control::SetSize(const Dimension& size) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetSize(size); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Control::SetPosition(int x, int y) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetPosition(Point(x, y)); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Control::SetPosition(const Point& position) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetPosition(position); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Control::SetFont(const String& fontName) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetFont(fontName); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return E_SUCCESS; +} + +bool +Control::IsEnabled(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->IsEnabled(); +} + +bool +Control::IsVisible(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->IsVisible(); +} + +result +Control::SetFocus() +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + pControlImpl->SetFocused(); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Control::SetShowState(bool state) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetVisibleState(state); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Tizen::Ui::Animations::VisualElement* +Control::GetVisualElement(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->GetVisualElement(); + //return pControlImpl->GetCustomVisualElement(); +} + +bool +Control::Contains(int x, int y) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->Contains(Point(x, y)); +} + +bool +Control::Contains(const Point& point) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->Contains(point); +} + +bool +Control::HasFocus(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->IsFocused(); +} + +bool +Control::GetShowState(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->GetVisibleState(); +} + +String +Control::GetName(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->GetName(); +} + +void +Control::SetName(const String& name) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + pControlImpl->SetName(name); +} + +void +Control::AddFocusEventListener(IFocusEventListener& listener) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->AddFocusEventListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Control::RemoveFocusEventListener(IFocusEventListener& listener) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->RemoveFocusEventListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Control::AddKeyEventListener(IKeyEventListener& listener) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->AddKeyEventListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Control::RemoveKeyEventListener(IKeyEventListener& listener) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->RemoveKeyEventListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Control::AddTouchEventListener(ITouchEventListener& listener) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->AddTouchEventListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Control::RemoveTouchEventListener(ITouchEventListener& listener) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->RemoveTouchEventListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Control::AddDragDropEventListener(IDragDropEventListener& listener) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->AddDragDropEventListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Control::RemoveDragDropEventListener(IDragDropEventListener& listener) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->RemoveDragDropEventListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Control::AddTouchModeChangedEventListener(ITouchModeChangedEventListener& listener) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->AddTouchModeChangedEventListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Control::RemoveTouchModeChangedEventListener(ITouchModeChangedEventListener& listener) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->RemoveTouchModeChangedEventListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Control::SetDragEnabled(bool enabled) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + pControlImpl->SetDragEnabled(enabled); +} + +void +Control::SetDropEnabled(bool enabled) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + pControlImpl->SetDropEnabled(enabled); +} + +void +Control::RequestRedraw(bool show) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + pControlImpl->RequestRedraw(show); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +Control::OnInitializing(void) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysTryReturn(NID_UI, pControlImpl, E_FAILURE, E_FAILURE, "[E_FAILURE] This callback returns failure."); + + return E_SUCCESS; +} + +result +Control::OnTerminating(void) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysTryReturn(NID_UI, pControlImpl, E_FAILURE, E_FAILURE, "[E_FAILURE] This callback returns failure."); + + return E_SUCCESS; +} + +void +Control::OnUserEventReceivedN(RequestId requestId, IList* pArgs) +{ +} + +void +Control::SendUserEvent(RequestId requestId, const IList* pArgs) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + pControlImpl->SendUserEvent(requestId, pArgs); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +Control::SetFocusable(bool focusable) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetFocusable(focusable); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +bool +Control::IsFocusable(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->IsFocusable(); +} + +bool +Control::IsInTouchMode(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->IsInTouchMode(); +} + + +result +Control::SetCompositeMode(Tizen::Ui::CompositeMode compositeMode) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetCompositeMode(compositeMode); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +CompositeMode +Control::GetCompositeMode(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->GetCompositeMode(); +} + +result +Control::SetChromaKeyColor(Color chromaKeyColor) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetChromaKeyColor(chromaKeyColor); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Color +Control::GetChromaKeyColor(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->GetChromaKeyColor(); +} + +result +Control::ConsumeInputEvent(void) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + pControlImpl->ConsumeInputEvent(); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +IKeyEventListener* +Control::GetDefaultkeyEventListener(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->GetDefaultKeyEventListener(); +} + +result +Control::SetDefaultKeyEventListener(IKeyEventListener* pDefaultListener) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + pControlImpl->SetDefaultKeyEventListener(pDefaultListener); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +ITouchEventListener* +Control::GetDefaultTouchEventListener(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->GetDefaultTouchEventListener(); +} + +result +Control::SetDefaultTouchEventListener(ITouchEventListener* pDefaultListener) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + pControlImpl->SetDefaultTouchEventListener(pDefaultListener); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +bool +Control::IsMovable(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->IsMovable(); +} + +bool +Control::IsResizable(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->IsResizable(); +} + +result +Control::SetMinimumSize(const Dimension& minSize) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetMinimumSize(minSize); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Control::SetMaximumSize(const Dimension& maxSize) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->SetMaximumSize(maxSize); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Point +Control::ConvertToControlPosition(const Point& screenPosition) const +{ + const Rectangle errorBounds = _ControlImpl::GetErrorBounds(); + const Point errorPosition(errorBounds.x, errorBounds.y); + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before used."); + + Point point = pControlImpl->ConvertToControlPosition(screenPosition); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, errorPosition, r, "[%s] Propagating.", GetErrorMessage(r)); + + return point; +} + +Point +Control::ConvertToScreenPosition(const Point& controlPosition) const +{ + const Rectangle errorBounds = _ControlImpl::GetErrorBounds(); + const Point errorPosition(errorBounds.x, errorBounds.y); + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before used."); + + Point point = pControlImpl->ConvertToScreenPosition(controlPosition); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, errorPosition, r, "[%s] Propagating.", GetErrorMessage(r)); + + return point; +} + +Dimension +Control::GetMinimumSize(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->GetMinimumSize(); +} + +Dimension +Control::GetMaximumSize(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->GetMaximumSize(); +} + +ControlAnimator* +Control::GetControlAnimator(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->GetControlAnimator(); +} + +result +Control::AddGestureDetector(const TouchGestureDetector& gestureDetector) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->AddGestureDetector(gestureDetector); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +Control::RemoveGestureDetector(const TouchGestureDetector& gestureDetector) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pControlImpl->RemoveGestureDetector(gestureDetector); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Bitmap* +Control::GetCapturedBitmapN(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pControlImpl->GetCapturedBitmapN(); +} + +Rectangle +Control::GetInvalidatedBounds(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pControlImpl->GetInvalidatedBounds(); +} + +void +Control::SetMultipointTouchEnabled(bool enable) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + if (pControlImpl) + { + pControlImpl->SetMultiTouchEnabled(enable); + } +} + +bool +Control::IsMultipointTouchEnabled(void) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + if (pControlImpl) + { + return pControlImpl->IsMultiTouchEnabled(); + } + + return false; +} + +const AccessibilityContainer* +Control::GetAccessibilityContainer(void) const +{ + _ControlImpl* pControlImpl = const_cast<_ControlImpl*>(_ControlImpl::GetInstance(*this)); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pControlImpl->GetAccessibilityContainer(); +} +AccessibilityContainer* +Control::GetAccessibilityContainer(void) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*this); + SysAssertf(pControlImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pControlImpl->GetAccessibilityContainer(); +} +}} // Tizen::Ui diff --git a/src/ui/FUiCustomControlBase.cpp b/src/ui/FUiCustomControlBase.cpp new file mode 100644 index 0000000..9b991b1 --- /dev/null +++ b/src/ui/FUiCustomControlBase.cpp @@ -0,0 +1,92 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCustomControlBase.cpp + * @brief This is the implementation for the CustomControlBase class. + */ + +#include +#include +#include +#include "FUi_CustomControlBaseImpl.h" +#include "FUi_ErrorMessages.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { + +CustomControlBase::CustomControlBase() +{ +} + +CustomControlBase::~CustomControlBase() +{ +} + +result +CustomControlBase::Construct(const Rectangle& rect, bool resizable, bool movable) +{ + result r = E_SUCCESS; + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _CustomControlBaseImpl* pImpl = _CustomControlBaseImpl::CreateCustomControlBaseImplN(this, rect, null, null, resizable, movable); + r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return E_SUCCESS; +} + +result +CustomControlBase::Construct(const Layout& layout, const Rectangle& rect, bool resizable, bool movable) +{ + return Construct(layout, layout, rect, resizable, movable); +} + +result +CustomControlBase::Construct(const Layout& portraitLayout, const Layout& landscapeLayout, + const Rectangle& rect, bool resizable, bool movable) +{ + result r = E_SUCCESS; + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _CustomControlBaseImpl* pImpl = + _CustomControlBaseImpl::CreateCustomControlBaseImplN(this, rect, &portraitLayout, &landscapeLayout, resizable, movable); + + r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + + _pControlImpl = pImpl; + + return E_SUCCESS; +} + +result +CustomControlBase::PrepareBoundsChange(const Rectangle& oldRect, const Rectangle& newRect) +{ + return E_SUCCESS; +} + +bool +CustomControlBase::EvaluateSize(int& width, int& height) +{ + return true; +} + +}} // Tizen::Ui diff --git a/src/ui/FUiDataBindingContext.cpp b/src/ui/FUiDataBindingContext.cpp new file mode 100644 index 0000000..5be5263 --- /dev/null +++ b/src/ui/FUiDataBindingContext.cpp @@ -0,0 +1,115 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiDataBindingContext.cpp + * @brief This is the implementation for the DataBindingContext class. + */ + +#include +#include +#include +#include +#include "FUi_ControlImpl.h" +#include "FUi_ContainerImpl.h" +#include "FUi_DataBindingContextImpl.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui +{ + +DataBindingContext::DataBindingContext(const Control& contextOwner) + : __pDataBindingContextImpl(null) +{ + const Container* pContainer = &dynamic_cast(contextOwner); + SysTryReturnVoidResult(NID_UI, pContainer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] DataBindingContext creation is failed."); + __pDataBindingContextImpl = new (std::nothrow) _DataBindingContextImpl(*_ContainerImpl::GetInstance(*pContainer)); + SysTryCatch(NID_UI, GetLastResult() == E_SUCCESS && __pDataBindingContextImpl, , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] DataBindingContext creation is failed."); + return; +CATCH: + delete __pDataBindingContextImpl; + __pDataBindingContextImpl = null; +} +DataBindingContext::~DataBindingContext(void) +{ + delete __pDataBindingContextImpl; + __pDataBindingContextImpl = null; +} +Control* +DataBindingContext::GetContextOwner(void) const +{ + SysAssertf(__pDataBindingContextImpl != null, "Not constructed properly by platform."); + ClearLastResult(); + return &(__pDataBindingContextImpl->GetContextOwner()->GetPublic()); +} + +result +DataBindingContext::Bind(const String& bindingId, const String& controlName, const String& propertyName + , Object& dataSource, DataBindingDataType sourceType, DataBindingFlow flow + , DataBindingTrigger trigger, const IDataBindingListener* pListener + , const IDataBindingDataValidator* pValidator + , const IDataBindingDataTransformer* pTransformer) +{ + SysAssertf(__pDataBindingContextImpl != null, "Not constructed properly by platform."); + ClearLastResult(); + return __pDataBindingContextImpl->Bind(bindingId, controlName, propertyName, dataSource, sourceType, flow, trigger, + pListener, pValidator, + pTransformer); +} + +result +DataBindingContext::SetDataBindingEventListener(const String& bindingId, IDataBindingListener* pListener) +{ + SysAssertf(__pDataBindingContextImpl != null, "Not constructed properly by platform."); + ClearLastResult(); + return __pDataBindingContextImpl->SetDataBindingEventListener(bindingId, pListener); +} + +result +DataBindingContext::UnbindAll(void) +{ + SysAssertf(__pDataBindingContextImpl != null, "Not constructed properly by platform."); + ClearLastResult(); + return __pDataBindingContextImpl->UnbindAll(); +} + +result +DataBindingContext::Unbind(const String& bindingId) +{ + SysAssertf(__pDataBindingContextImpl != null, "Not constructed properly by platform."); + ClearLastResult(); + return __pDataBindingContextImpl->Unbind(bindingId); +} + +result +DataBindingContext::UpdateAllBindings(DataBindingDestinationType destType) +{ + SysAssertf(__pDataBindingContextImpl != null, "Not constructed properly by platform."); + ClearLastResult(); + return __pDataBindingContextImpl->UpdateAllBindings(destType); +} + +result +DataBindingContext::UpdateBinding(const String& bindingId, DataBindingDestinationType destType) +{ + SysAssertf(__pDataBindingContextImpl != null, "Not constructed properly by platform."); + ClearLastResult(); + return __pDataBindingContextImpl->UpdateBinding(bindingId, destType); +} + +}}// Tizen::Ui diff --git a/src/ui/FUiFocusManager.cpp b/src/ui/FUiFocusManager.cpp new file mode 100644 index 0000000..fd8a12f --- /dev/null +++ b/src/ui/FUiFocusManager.cpp @@ -0,0 +1,80 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiFocusManager.cpp +* @brief This is the implementation file for FocusManager class. +* @version 2.0 +* +*/ + +#include +#include "FUi_FocusManagerImpl.h" +#include "FUi_ControlImpl.h" +#include "FUi_WindowImpl.h" + +namespace Tizen { namespace Ui +{ +//////////////////////////////////////////////////////////////////////////////// +/// FocusManager class Lifecycle + +FocusManager::FocusManager(void) +{ + //NOHING +} + +FocusManager::~FocusManager(void) +{ + // NOTHING +} + +FocusManager* +FocusManager::GetInstance(void) +{ + static FocusManager instance; + + return &instance; + +} + +//////////////////////////////////////////////////////////////////////////////// +/// FocusManager class Operation + +Control* +FocusManager::GetCurrentFocusOwner(void) const +{ + _ControlImpl* pControlImpl = _FocusManagerImpl::GetInstance()->GetCurrentFocusOwner(); + if(pControlImpl == null) + { + return null; + } + + return &pControlImpl->GetPublic(); +} + +Window* +FocusManager::GetCurrentFocusedWindow(void) const +{ + _WindowImpl* pWindowImpl = _FocusManagerImpl::GetInstance()->GetCurrentFocusedWindow(); + if(pWindowImpl == null) + { + return null; + } + + return &pWindowImpl->GetPublic(); +} + +} } //Tizen::Ui diff --git a/src/ui/FUiGridLayout.cpp b/src/ui/FUiGridLayout.cpp new file mode 100644 index 0000000..01830af --- /dev/null +++ b/src/ui/FUiGridLayout.cpp @@ -0,0 +1,324 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiGridLayout.cpp + * @brief This is the implementation file for GridLayout class. + * + * This file contains the implementation of GridLayout class. + */ + +#include +#include +#include "FUi_GridLayoutImpl.h" + +namespace Tizen { namespace Ui +{ + +GridLayout::GridLayout() +{ +} + +GridLayout::~GridLayout() +{ +} + +result +GridLayout::Construct(int maxRow, int maxColumn) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, (maxRow - 1 >= 0) && (maxColumn - 1 >= 0), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pGridLayoutImpl = _GridLayoutImpl::CreateGridLayoutImplN(this, maxRow, maxColumn); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _LayoutImpl::SetLayoutImpl(this, pGridLayoutImpl); + + return E_SUCCESS; +} + +Tizen::Ui::LayoutType +GridLayout::GetLayoutType(void) const +{ + return LAYOUT_GRID; +} + +int +GridLayout::GetRowCount() const +{ + ClearLastResult(); + + const _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pGridLayoutImpl->GetRowCount(); +} + +int +GridLayout::GetColumnCount() const +{ + ClearLastResult(); + + const _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pGridLayoutImpl->GetColumnCount(); +} + +result +GridLayout::SetColumnStretchable(int columnIndex, bool stretchable) +{ + ClearLastResult(); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI, (columnIndex >= 0) && (columnIndex <= GetColumnCount() - 1), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The given parameter is out of range."); + + result r = pGridLayoutImpl->SetColumnStretchable(columnIndex, stretchable); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetColumnShrinkable(int columnIndex, bool shrinkable) +{ + ClearLastResult(); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI, (columnIndex >= 0) && (columnIndex <= GetColumnCount() - 1), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The given parameter is out of range."); + + result r = pGridLayoutImpl->SetColumnShrinkable(columnIndex, shrinkable); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetColumnCollapsed(int columnIndex, bool collapsed) +{ + ClearLastResult(); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI, (columnIndex >= 0) && (columnIndex <= GetColumnCount() - 1), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The given parameter is out of range."); + + result r = pGridLayoutImpl->SetColumnCollapsed(columnIndex, collapsed); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetAllColumnsStretchable(bool stretchable) +{ + ClearLastResult(); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGridLayoutImpl->SetAllColumnsStretchable(stretchable); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetAllColumnsShrinkable(bool shrinkable) +{ + ClearLastResult(); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGridLayoutImpl->SetAllColumnsShrinkable(shrinkable); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetColumnSpacing(int columnIndex, int space) +{ + ClearLastResult(); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI, (columnIndex >= 0) && (columnIndex <= GetColumnCount() - 1), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The given parameter is out of range."); + SysTryReturn(NID_UI, space >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + result r = pGridLayoutImpl->SetColumnSpacing(columnIndex, space); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetRowStretchable(int rowIndex, bool stretchable) +{ + ClearLastResult(); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI, (rowIndex >= 0) && (rowIndex <= GetRowCount() - 1), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The given parameter is out of range."); + + result r = pGridLayoutImpl->SetRowStretchable(rowIndex, stretchable); + SysTryReturn(NID_UI, GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetRowShrinkable(int rowIndex, bool shrinkable) +{ + ClearLastResult(); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI, (rowIndex >= 0) && (rowIndex <= GetRowCount() - 1), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The given parameter is out of range."); + + result r = pGridLayoutImpl->SetRowShrinkable(rowIndex, shrinkable); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetRowCollapsed(int rowIndex, bool collapsed) +{ + ClearLastResult(); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI, (rowIndex >= 0) && (rowIndex <= GetRowCount() - 1), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The given parameter is out of range."); + + result r = pGridLayoutImpl->SetRowCollapsed(rowIndex, collapsed); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetAllRowsStretchable(bool stretchable) +{ + ClearLastResult(); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGridLayoutImpl->SetAllRowsStretchable(stretchable); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetAllRowsShrinkable(bool shrinkable) +{ + ClearLastResult(); + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGridLayoutImpl->SetAllRowsShrinkable(shrinkable); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetRowSpacing(int rowIndex, int space) +{ + ClearLastResult(); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI, (rowIndex >= 0) && (rowIndex <= GetRowCount() - 1), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The given parameter is out of range."); + SysTryReturn(NID_UI, space >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + result r = pGridLayoutImpl->SetRowSpacing(rowIndex, space); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetPosition(Control& childControl, int rowStartIndex, int columnStartIndex, int rowSpan, int columnSpan) +{ + ClearLastResult(); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGridLayoutImpl->SetPosition(*pControlImpl, rowStartIndex, columnStartIndex, rowSpan, columnSpan); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetAlignment(Control& childControl, LayoutHorizontalAlignment horAlign, LayoutVerticalAlignment vertAlign) +{ + ClearLastResult(); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pGridLayoutImpl->SetAlignment(*pControlImpl, horAlign, vertAlign); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GridLayout::SetMargin(Control& childControl, int left, int right, int top, int bottom) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, (left >= 0) && (right >= 0) && (top >= 0) && (bottom >= 0), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + _GridLayoutImpl* pGridLayoutImpl = _GridLayoutImpl::GetInstance(*this); + SysAssertf(pGridLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pGridLayoutImpl->SetMargin(*pControlImpl, left, right, top, bottom); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +}} // Tizen::Ui diff --git a/src/ui/FUiHorizontalBoxLayout.cpp b/src/ui/FUiHorizontalBoxLayout.cpp new file mode 100644 index 0000000..5107f59 --- /dev/null +++ b/src/ui/FUiHorizontalBoxLayout.cpp @@ -0,0 +1,238 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiHorizontalBoxLayout.cpp + * @brief This is the implementation file for HorizontalBoxLayout class. + * + * This file contains the implementation of HorizontalBoxLayout class. + */ + +#include +#include +#include +#include "FUi_HorizontalBoxLayoutImpl.h" + +namespace Tizen { namespace Ui +{ + +namespace +{ +#define GET_CONTROL_IMPL(control) \ + _ControlImpl * pControlImpl = null; \ + pControlImpl = _ControlImpl::GetInstance(control); \ + SysTryReturn(NID_UI, pControlImpl, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pControlImpl is not allocated yet.\n") +} + +HorizontalBoxLayout::HorizontalBoxLayout() +{ +} + +HorizontalBoxLayout::~HorizontalBoxLayout() +{ +} + +result +HorizontalBoxLayout::Construct(HorizontalDirection direction) +{ + ClearLastResult(); + + _HorizontalBoxLayoutImpl* pHorizontalBoxLayoutImpl = _HorizontalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pHorizontalBoxLayoutImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pHorizontalBoxLayoutImpl = _HorizontalBoxLayoutImpl::CreateHorizontalBoxLayoutImplN(this, direction); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _LayoutImpl::SetLayoutImpl(this, pHorizontalBoxLayoutImpl); + + return E_SUCCESS; +} + +Tizen::Ui::LayoutType +HorizontalBoxLayout::GetLayoutType(void) const +{ + return LAYOUT_HORIZONTAL_BOX; +} + +result +HorizontalBoxLayout::GetDirection(HorizontalDirection& direction) const +{ + ClearLastResult(); + + const _HorizontalBoxLayoutImpl* pHorizontalBoxLayoutImpl = _HorizontalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pHorizontalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pHorizontalBoxLayoutImpl->GetDirection(direction); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +HorizontalBoxLayout::SetVerticalAlignment(Control& childControl, LayoutVerticalAlignment alignment) +{ + ClearLastResult(); + + _HorizontalBoxLayoutImpl* pHorizontalBoxLayoutImpl = _HorizontalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pHorizontalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pHorizontalBoxLayoutImpl->SetVerticalAlignment(*pControlImpl, alignment); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +HorizontalBoxLayout::SetSpacing(Control& childControl, int space) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, space >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + _HorizontalBoxLayoutImpl* pHorizontalBoxLayoutImpl = _HorizontalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pHorizontalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pHorizontalBoxLayoutImpl->SetSpacing(*pControlImpl, space); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +HorizontalBoxLayout::SetVerticalMargin(Control& childControl, int top, int bottom) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, (top >= 0) && (bottom >= 0), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + _HorizontalBoxLayoutImpl* pHorizontalBoxLayoutImpl = _HorizontalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pHorizontalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pHorizontalBoxLayoutImpl->SetVerticalMargin(*pControlImpl, top, bottom); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +HorizontalBoxLayout::SetWidth(Control& childControl, int width) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, width >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + _HorizontalBoxLayoutImpl* pHorizontalBoxLayoutImpl = _HorizontalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pHorizontalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pHorizontalBoxLayoutImpl->SetWidth(*pControlImpl, width); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +HorizontalBoxLayout::SetHorizontalFitPolicy(Control& childControl, FitPolicy policy) +{ + ClearLastResult(); + + _HorizontalBoxLayoutImpl* pHorizontalBoxLayoutImpl = _HorizontalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pHorizontalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + if (!Tizen::App::_AppInfo::IsOspCompat()) + { + if (policy == FIT_POLICY_PARENT) + { + return E_SUCCESS; + } + + } + + result r = pHorizontalBoxLayoutImpl->SetItemHorizontalFitPolicy(*pControlImpl, policy); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +HorizontalBoxLayout::SetHeight(Control& childControl, int height) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, height >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + _HorizontalBoxLayoutImpl* pHorizontalBoxLayoutImpl = _HorizontalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pHorizontalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pHorizontalBoxLayoutImpl->SetHeight(*pControlImpl, height); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +HorizontalBoxLayout::SetVerticalFitPolicy(Control& childControl, FitPolicy policy) +{ + ClearLastResult(); + + _HorizontalBoxLayoutImpl* pHorizontalBoxLayoutImpl = _HorizontalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pHorizontalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pHorizontalBoxLayoutImpl->SetItemVerticalFitPolicy(*pControlImpl, policy); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +HorizontalBoxLayout::SetWeight(Control& childControl, float weight) +{ + ClearLastResult(); + + _HorizontalBoxLayoutImpl* pHorizontalBoxLayoutImpl = _HorizontalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pHorizontalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pHorizontalBoxLayoutImpl->SetWeight(*pControlImpl, weight); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +}} // Tizen::Ui diff --git a/src/ui/FUiInputConnection.cpp b/src/ui/FUiInputConnection.cpp new file mode 100644 index 0000000..c5ace55 --- /dev/null +++ b/src/ui/FUiInputConnection.cpp @@ -0,0 +1,232 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiInputConnection.cpp +* @brief This is the implementation file for InputConnection class. +*/ + +#include +#include +#include +#include +#include "FUi_ControlImpl.h" +#include "FUi_InputConnectionImpl.h" + + +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::Security; + +namespace Tizen { namespace Ui { + +InputConnection::InputConnection(void) +:__pInputConnectionImpl(null) +{ + +} + +InputConnection::~InputConnection(void) +{ + if (__pInputConnectionImpl) + { + delete __pInputConnectionImpl; + __pInputConnectionImpl = null; + } +} + +result +InputConnection::Construct(const Control* pControl, IInputConnectionEventListener& listener, IInputConnectionProvider& provider) +{ + SysTryReturnResult(NID_UI, pControl, E_INVALID_ARG, "The argument is invalid."); + + __pInputConnectionImpl = _InputConnectionImpl::CreateInputConnectionImplN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI, __pInputConnectionImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pInputConnectionImpl->Initialize(_ControlImpl::GetInstance(*pControl)->GetCore(), listener, provider); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete __pInputConnectionImpl; + __pInputConnectionImpl = null; + return r; +} + +result +InputConnection::BindInputMethod(void) +{ + result r = E_SUCCESS; + + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + r = __pInputConnectionImpl->BindInputMethod(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +InputConnection::UnbindInputMethod(void) +{ + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + __pInputConnectionImpl->UnbindInputMethod(); + + return; +} + +result +InputConnection::ShowInputPanel(void) +{ + result r = E_SUCCESS; + + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + r = __pInputConnectionImpl->ShowInputPanel(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +InputConnection::HideInputPanel(void) +{ + result r = E_SUCCESS; + + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + r = __pInputConnectionImpl->HideInputPanel(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +InputConnection::SetInputPanelStyle(InputPanelStyle style) +{ + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + __pInputConnectionImpl->SetInputPanelStyle(style); + + return; +} + +void +InputConnection::SetAutoCapitalizationMode(AutoCapitalizationMode autoCapitalizationMode) +{ + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + __pInputConnectionImpl->SetAutoCapitalizationMode(autoCapitalizationMode); + + return; +} + +result +InputConnection::FinishTextComposition(void) +{ + result r = E_SUCCESS; + + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + r = __pInputConnectionImpl->FinishTextComposition(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +InputConnection::SetInputPanelAction(InputPanelAction inputPanelAction) +{ + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + __pInputConnectionImpl->SetInputPanelAction(inputPanelAction); + + return; +} + +void +InputConnection::SetInputPanelActionEnabled(bool enable) +{ + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + __pInputConnectionImpl->SetInputPanelActionEnabled(enable); + + return; +} + +result +InputConnection::SetInputPanelLanguage(LanguageCode languageCode) +{ + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + return __pInputConnectionImpl->SetInputPanelLanguage(languageCode); +} + +result +InputConnection::SetCursorPosition(int position) +{ + result r = E_SUCCESS; + + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + r = __pInputConnectionImpl->SetCursorPosition(position); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +InputConnection::SetCursorBounds(const Rectangle& rect) +{ + result r = E_SUCCESS; + + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + r = __pInputConnectionImpl->SetCursorBounds(rect); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Rectangle +InputConnection::GetInputPanelBounds(void) const +{ + result r = E_SUCCESS; + + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + Rectangle bounds = __pInputConnectionImpl->GetInputPanelBounds(); + r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, Rectangle(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r)); + + return bounds; +} + +void +InputConnection::SetTextPredictionEnabled(bool enable) +{ + SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use."); + + __pInputConnectionImpl->SetTextPredictionEnabled(enable); + + return; +} + +}} //Tizen::Ui diff --git a/src/ui/FUiKeyEventManager.cpp b/src/ui/FUiKeyEventManager.cpp new file mode 100644 index 0000000..41b6a8c --- /dev/null +++ b/src/ui/FUiKeyEventManager.cpp @@ -0,0 +1,100 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiKeyEventManager.cpp +* @brief This is the implementation file for KeyEventManager class. +* @version 2.0 +* @see Tizen::Ui::KeyEventManager +* +*/ + +// includes +#include +#include +#include +#include "FUi_KeyEventManagerImpl.h" +#include "FUi_ControlImpl.h" + +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui +{ +KeyEventManager* pKeyEventManagerInstance = null; + +//////////////////////////////////////////////////////////////////////////////// +/// KeyEventManager class Lifecycle + +KeyEventManager::KeyEventManager(void) +{ +} + +KeyEventManager::~KeyEventManager(void) +{ +} + +result +KeyEventManager::Construct(void) +{ + return E_SUCCESS; +} + +KeyEventManager* +KeyEventManager::GetInstance(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + pthread_once(&once_block, InitializeInstance); + + _KeyEventManagerImpl* pEventImpl = _KeyEventManagerImpl::GetInstance(); + if (!pEventImpl) + { + return null; + } + + return pKeyEventManagerInstance; +} + +void +KeyEventManager::InitializeInstance(void) + { + static KeyEventManager instance; + pKeyEventManagerInstance = &instance; + +} + +//////////////////////////////////////////////////////////////////////////////// +/// KeyEventManager class Operation + +void +KeyEventManager::AddKeyEventListener(IKeyEventListener& listener) +{ + _KeyEventManagerImpl* pEventImpl = _KeyEventManagerImpl::GetInstance(); + SysAssertf(pEventImpl != null, "Not yet constructed. Construct() should be called before use."); + + pEventImpl->AddKeyEventListener(listener); +} + +void +KeyEventManager::RemoveKeyEventListener(IKeyEventListener& listener) +{ + _KeyEventManagerImpl* pEventImpl = _KeyEventManagerImpl::GetInstance(); + SysAssertf(pEventImpl != null, "Not yet constructed. Construct() should be called before use."); + + pEventImpl->RemoveKeyEventListener(listener); +} + +} } //Tizen::Ui diff --git a/src/ui/FUiKeyboardMap.cpp b/src/ui/FUiKeyboardMap.cpp new file mode 100644 index 0000000..f72ab5b --- /dev/null +++ b/src/ui/FUiKeyboardMap.cpp @@ -0,0 +1,2158 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiKeyboardMap.cpp +* @brief This is the implementation for the KeyboardMap class. +* @version 2.0 +*/ +// includes +#include +#include +#include +#include + +// using namespace +using namespace Tizen::Base; + +namespace Tizen { namespace Ui +{ + +enum KeyboardMapType +{ + KEYBOARD_MAP_NONE, // Default + KEYBOARD_MAP_GLB, // Global + KEYBOARD_MAP_EUR, // Europe + KEYBOARD_MAP_ARB, // Arabic + KEYBOARD_MAP_CHN, // China + KEYBOARD_MAP_ESP, // Spain + KEYBOARD_MAP_DEU, // Germany + KEYBOARD_MAP_FRA, // France + KEYBOARD_MAP_ZAF, // Africa + KEYBOARD_MAP_GRC, // Greece + KEYBOARD_MAP_IRN, // Iran + KEYBOARD_MAP_ITA, // Italy + KEYBOARD_MAP_NOR, // Nordic + KEYBOARD_MAP_PAK, // Pakistan + KEYBOARD_MAP_PRT, // Portugal + KEYBOARD_MAP_RUS, // Russia + KEYBOARD_MAP_SGP, // Singapore + KEYBOARD_MAP_THA, // Thailand + KEYBOARD_MAP_VNM, // Vietnam + KEYBOARD_MAP_MAX +}; +/* +static const wchar_t KEYBOARD_MAP_NONE_NAME[] = L"NONE"; +static const wchar_t KEYBOARD_MAP_GLB_NAME[] = L"QWERTY_11x4_GLOBAL"; +static const wchar_t KEYBOARD_MAP_EUR_NAME[] = L"QWERTY_11x4_EUROPE"; +static const wchar_t KEYBOARD_MAP_ARB_NAME[] = L"QWERTY_11x4_ARAB"; +static const wchar_t KEYBOARD_MAP_CHN_NAME[] = L"QWERTY_11x4_CHINA"; +static const wchar_t KEYBOARD_MAP_ESP_NAME[] = L"QWERTY_11x4_SPAIN"; +static const wchar_t KEYBOARD_MAP_DEU_NAME[] = L"QWERTY_11x4_GERMAN"; +static const wchar_t KEYBOARD_MAP_FRA_NAME[] = L"QWERTY_11x4_FRENCH"; +static const wchar_t KEYBOARD_MAP_GRC_NAME[] = L"QWERTY_11x4_GREECE"; +static const wchar_t KEYBOARD_MAP_IRN_NAME[] = L"QWERTY_11x4_IRAN"; +static const wchar_t KEYBOARD_MAP_ITA_NAME[] = L"QWERTY_11x4_ITALY"; +static const wchar_t KEYBOARD_MAP_NOR_NAME[] = L"QWERTY_11x4_NORDIC"; +static const wchar_t KEYBOARD_MAP_PAK_NAME[] = L"QWERTY_11x4_PAKISTAN"; +static const wchar_t KEYBOARD_MAP_PRT_NAME[] = L"QWERTY_11x4_PORTUGUESE"; +static const wchar_t KEYBOARD_MAP_RUS_NAME[] = L"QWERTY_11x4_RUSSIAN"; +static const wchar_t KEYBOARD_MAP_SGP_NAME[] = L"QWERTY_11x4_SINGAPORE"; +static const wchar_t KEYBOARD_MAP_THA_NAME[] = L"QWERTY_11x4_THAILAND"; +static const wchar_t KEYBOARD_MAP_VNM_NAME[] = L"QWERTY_11x4_VIETNAM"; + +typedef struct +{ + wchar_t country[20]; + KeyboardMapType type; +} KeyboardMapFileEntry; + + +static const int KEYBOARD_MAP_TYPE_MAX = 74; + +static KeyboardMapFileEntry gKeyboardMapTypes[KEYBOARD_MAP_TYPE_MAX] = +{ + { L"UK", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_UK, + { L"CHINA", KEYBOARD_MAP_CHN }, //NV_OPERATOR_COUNTRY_CHINA, + { L"FRANCE", KEYBOARD_MAP_FRA }, //NV_OPERATOR_COUNTRY_FRANCE + { L"BELGIUM", KEYBOARD_MAP_FRA }, //NV_OPERATOR_COUNTRY_BELGIUM + { L"GERMANY", KEYBOARD_MAP_DEU }, //NV_OPERATOR_COUNTRY_GERMANY, + { L"AUSTRIA", KEYBOARD_MAP_DEU }, //NV_OPERATOR_COUNTRY_AUSTRIA + { L"GREECE", KEYBOARD_MAP_GRC }, //NV_OPERATOR_COUNTRY_GREECE, + { L"HUNGARY", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_HUNGARY + { L"ITALY", KEYBOARD_MAP_ITA }, //NV_OPERATOR_COUNTRY_ITALY + { L"PORTUGAL", KEYBOARD_MAP_PRT }, //NV_OPERATOR_COUNTRY_PORTUGAL, + { L"SPAIN", KEYBOARD_MAP_ESP }, //NV_OPERATOR_COUNTRY_SPAIN, + { L"ROMANIA", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_ROMANIA, + { L"RUSSIA", KEYBOARD_MAP_RUS }, //NV_OPERATOR_COUNTRY_RUSSIA, // Russia + { L"UKRAINE", KEYBOARD_MAP_RUS }, //NV_OPERATOR_COUNTRY_UKRAINE, // Russia + { L"KAZAKHSTAN", KEYBOARD_MAP_RUS }, //NV_OPERATOR_COUNTRY_KAZAKHSTAN, // Russia + { L"LATVIA", KEYBOARD_MAP_RUS }, //NV_OPERATOR_COUNTRY_LATVIA, // Russia + { L"ESTONIA", KEYBOARD_MAP_RUS }, //NV_OPERATOR_COUNTRY_ESTONIA, // Russia + { L"LITHUANIA", KEYBOARD_MAP_RUS }, //NV_OPERATOR_COUNTRY_LITHUANIA, // Russia + { L"ARMENIA", KEYBOARD_MAP_RUS }, //NV_OPERATOR_COUNTRY_ARMENIA, // Russia + { L"MOLDOVA", KEYBOARD_MAP_RUS }, //NV_OPERATOR_COUNTRY_MOLDOVA, // Russia + { L"UZBEKISTAN", KEYBOARD_MAP_RUS }, //NV_OPERATOR_COUNTRY_UZBEKISTAN, // Russia + { L"TURKEY", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_TURKEY, }, + { L"FINLAND", KEYBOARD_MAP_NOR }, //NV_OPERATOR_COUNTRY_FINLAND, // nordic + { L"SWEDEN", KEYBOARD_MAP_NOR }, //NV_OPERATOR_COUNTRY_SWEDEN, // nordic + { L"DENMARK", KEYBOARD_MAP_NOR }, //NV_OPERATOR_COUNTRY_DENMARK, // nordic + { L"NORWAY", KEYBOARD_MAP_NOR }, //NV_OPERATOR_COUNTRY_NORWAY, // nordic + { L"VIETNAM", KEYBOARD_MAP_VNM }, //NV_OPERATOR_COUNTRY_VIETNAM, + { L"THAILAND", KEYBOARD_MAP_THA }, //NV_OPERATOR_COUNTRY_THAILAND, + { L"SINGAPORE", KEYBOARD_MAP_SGP }, //NV_OPERATOR_COUNTRY_SINGAPORE, + { L"PAKISTAN", KEYBOARD_MAP_PAK }, //NV_OPERATOR_COUNTRY_PAKISTAN, + { L"ARAB", KEYBOARD_MAP_ARB }, //NV_OPERATOR_COUNTRY_ARAB, + { L"IRAN", KEYBOARD_MAP_IRN }, //NV_OPERATOR_COUNTRY_IRAN, + { L"AUSTRALIA", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_AUSTRALIA + { L"CROATIA", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_CROATIA, + { L"CZECHO", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_CZECHO, + { L"IRELANDS", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_IRELANDS, + { L"ISRAEL", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_ISRAEL, + { L"JAPAN", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_JAPAN, + { L"KOREA", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_KOREA, for simulator + { L"MALTA", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_MALTA, + { L"NETHERLANDS", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_NETHERLANDS, + { L"NEWZEALAND", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_NEWZEALAND, + { L"POLAND", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_POLAND, + { L"SLOVENIA", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_SLOVENIA, + { L"SOUTHAFRICA", KEYBOARD_MAP_ZAF }, //NV_OPERATOR_COUNTRY_SOUTHAFRICA, + { L"SWISS", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_SWISS, + { L"US", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_US, + { L"SERBIA", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_SERBIA, + { L"ALBANIA", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_ALBANIA, + { L"SLOVAKIA", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_SLOVAKIA, + { L"MACEDONIA", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_MACEDONIA, + { L"BULGARIA", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_BULGARIA, + { L"BALTIC", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_BALTIC, + { L"MALAYSIA", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_MALAYSIA, + { L"ICELAND", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_ICELAND, + { L"CYPRUS", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_CYPRUS, + { L"QATAR", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_QATAR, + { L"PHILIPPINES", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_PHILIPPINES + { L"HONGKONG", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_HONGKONG, + { L"TAIWAN", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_TAIWAN, + { L"INDIA", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_INDIA, + { L"LEBANON", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_LEBANON, + { L"OMAN", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_OMAN, + { L"MAURITIUS", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_MAURITIUS, + { L"KUWAIT", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_KUWAIT, + { L"SYRIA", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_SYRIA, + { L"MOROCCO", KEYBOARD_MAP_ZAF }, //NV_OPERATOR_COUNTRY_MOROCCO, + { L"LUXEMBOURG", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_LUXEMBOURG, + { L"MONTENEGRO", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_MONTENEGRO, + { L"ALGERIA", KEYBOARD_MAP_ZAF }, //NV_OPERATOR_COUNTRY_ALGERIA, + { L"BOSNIA", KEYBOARD_MAP_EUR }, //NV_OPERATOR_COUNTRY_BOSNIA, + { L"INDONESIA", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_INDONESIA, + { L"EGYPT", KEYBOARD_MAP_GLB }, //NV_OPERATOR_COUNTRY_EGYPT + { L"TUNISIA", KEYBOARD_MAP_ZAF } //NV_OPERATOR_COUNTRY_TUNISIA, +}; + +static const int KEYBOARD_TEXT_LEN_MAX = 10; + +typedef struct +{ + int keyCode; + int systemKeyCode; + bool available; + wchar_t label1[KEYBOARD_TEXT_LEN_MAX + 1]; // including null character + wchar_t label2[KEYBOARD_TEXT_LEN_MAX + 1]; // including null character + wchar_t label3[KEYBOARD_TEXT_LEN_MAX + 1]; // including null character + wchar_t label4[KEYBOARD_TEXT_LEN_MAX + 1]; // including null character +} KeyboardMapEntry; + + +static KeyboardMapEntry gKeyboardMapNONE [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, false, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, false, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, false, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, false, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, false, L"A", L"", L"", L"" }, + { KEY_B, VK_HP_B, false, L"B", L"", L"", L"" }, + { KEY_C, VK_HP_C, false, L"C", L"", L"", L"" }, + { KEY_D, VK_HP_SHARP, false, L"D", L"", L"", L"" }, + { KEY_E, VK_HP_3, false, L"E", L"", L"", L"" }, + { KEY_F, VK_HP_F, false, L"F", L"", L"", L"" }, + { KEY_G, VK_HP_G, false, L"G", L"", L"", L"" }, + { KEY_H, VK_HP_H, false, L"H", L"", L"", L"" }, + { KEY_I, VK_HP_8, false, L"I", L"", L"", L"" }, + { KEY_J, VK_HP_J, false, L"J", L"", L"", L"" }, + { KEY_K, VK_HP_ASTERISK, false, L"K", L"", L"", L"" }, + { KEY_L, VK_HP_L, false, L"L", L"", L"", L"" }, + { KEY_M, VK_HP_M, false, L"M", L"", L"", L"" }, + { KEY_N, VK_HP_N, false, L"N", L"", L"", L"" }, + { KEY_O, VK_HP_9, false, L"O", L"", L"", L"" }, + { KEY_P, VK_HP_0, false, L"P", L"", L"", L"" }, + { KEY_Q, VK_HP_1, false, L"Q", L"", L"", L"" }, + { KEY_R, VK_HP_4, false, L"R", L"", L"", L"" }, + { KEY_S, VK_HP_S, false, L"S", L"", L"", L"" }, + { KEY_T, VK_HP_5, false, L"T", L"", L"", L"" }, + { KEY_U, VK_HP_7, false, L"U", L"", L"", L"" }, + { KEY_V, VK_HP_V, false, L"V", L"", L"", L"" }, + { KEY_W, VK_HP_2, false, L"W", L"", L"", L"" }, + { KEY_Y, VK_HP_6, false, L"Y", L"", L"", L"" }, + { KEY_X, VK_HP_X, false, L"X", L"", L"", L"" }, + { KEY_Z, VK_HP_PLUS, false, L"Z", L"", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, false, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_COMMA, false, L",", L"", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, false, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, false, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, false, L"?", L"", L"", L"" }, + { KEY_ALT, VK_HP_FN, false, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, false, L"", L"", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, false, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, false, L".", L"", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QWERTY_SYM1, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry gKeyboardMapGLB [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"$", L"", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"%", L"", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"^", L"", L"" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"", L"" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"", L"" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"", L"" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"", L"" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"", L"" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"", L"" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"", L"" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_COMMA, true, L",", L")", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, true, L"?", L"\"", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L".com", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QWERTY_SYM1, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + + +static KeyboardMapEntry gKeyboardMapEUR [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"\u00A3", L"", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"$", L"", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"\u20AC", L"", L"" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"", L"" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"", L"" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"", L"" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"", L"" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"", L"" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"", L"" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"", L"" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_COMMA, true, L",", L")", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, true, L"?", L"\"", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L".com", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QWERTY_SYM1, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry gKeyboardMapCHN [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"$", L"", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"\u00A5", L"", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"^", L"", L"" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"", L"" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"", L"" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"", L"" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"", L"" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"", L"" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"", L"" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"", L"" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_COMMA, true, L",", L")", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, true, L"?", L"\"", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L".com", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QWERTY_SYM1, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry gKeyboardMapESP [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"\u20AC", L"", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"$", L"", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"\00A1", L"", L"" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"\u00BF", L"", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"", L"" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"", L"" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"", L"" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"", L"" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"", L"" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"", L"" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"", L"" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, true, L"?", L"\"", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L",", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_COMMA, true, L"\00D1", L")", L"\00E7", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry gKeyboardMapDEU [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"\u20AC", L"", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"$", L"", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"%", L"", L"" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"", L"" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"", L"" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"", L"" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"", L"" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"", L"" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"", L"" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"", L"" }, + { KEY_Y, VK_HP_PLUS, true, L"Y", L"+", L"", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"", L"" }, + { KEY_Z, VK_HP_6, true, L"Z", L"6", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, true, L"?", L"\"", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L",", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_COMMA, true, L"\u00DF", L")", L"", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry gKeyboardMapFRA [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_1, true, L"A", L"1", L"", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"\u20AC", L"", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"$", L"", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"%", L"", L"" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"", L"" }, + { KEY_M, VK_HP_COMMA, true, L"M", L")", L"", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"", L"" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"", L"" }, + { KEY_Q, VK_HP_A, true, L"Q", L"!", L"", L"" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"", L"" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"", L"" }, + { KEY_W, VK_HP_PLUS, true, L"W", L"+", L"", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"", L"" }, + { KEY_Z, VK_HP_2, true, L"Z", L"2", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_M, true, L",", L"'", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, true, L"?", L"\"", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L".com", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QWERTY_SYM1, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry gKeyboardMapZAF [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_1, true, L"A", L"1", L"", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"$", L"", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"%", L"", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"^", L"", L"" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"", L"" }, + { KEY_M, VK_HP_COMMA, true, L"M", L")", L"", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"", L"" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"", L"" }, + { KEY_Q, VK_HP_A, true, L"Q", L"!", L"", L"" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"", L"" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"", L"" }, + { KEY_W, VK_HP_PLUS, true, L"W", L"+", L"", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"", L"" }, + { KEY_Z, VK_HP_2, true, L"Z", L"2", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_M, true, L",", L"'", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, true, L"?", L"\"", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L".com", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QWERTY_SYM1, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry gKeyboardMapGRC [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"\u03C8", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"\u0394", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"\u20AC", L"\u03A6", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"%", L"\u0393", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"^", L"", L"" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"\u039E", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"\u039B", L"" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"", L"" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"\u03A0", L"" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"", L"" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"\u03A1", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"\u03A3", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"", L"" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"\u0398", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"", L"" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"\u03C2", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"", L"" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_COMMA, true, L",", L")", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, true, L"?", L"\"", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L".com", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QWERTY_SYM1, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry gKeyboardMapEUR_2 [KEY_HARDWARE_MAX + 1] = // ITALY/PORTUGAL +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"$", L"", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"\u20AC", L"", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"%", L"", L"" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"", L"" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"", L"" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"", L"" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"", L"" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"", L"" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"", L"" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"", L"" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_COMMA, true, L",", L")", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, true, L"?", L"\"", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L".com", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QWERTY_SYM1, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry gKeyboardMapRUS [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"\u0424", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"\u0418", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"\u0421", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"\u0412", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"\u0423", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"$", L"\u0410", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"%", L"\u041F", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"/", L"\u0420", L"" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"\u0428", L"\u0429" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"\u041E", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"\u041B", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"\u0414", L"" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"\u042C", L"\u0411"}, + { KEY_N, VK_HP_N, true, L"N", L":", L"\u0422", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"\u0417", L"" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"\u0425", L"\u042A"}, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"\u0419", L"" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"\u041A", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"\u042B", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"\u0415", L"\u0401" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"\u0413", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"\u041C", L"" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"\u0426", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"\u041D", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"\u0427", L"" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"\u042F", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L",", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_COMMA, true, L"\u0416", L")", L"\u042D", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QUESTION, true, L"\u042E", L"?", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry gKeyboardMapNOR [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"$", L"", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"\u20AC", L"", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"%", L"", L"" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"", L"" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"", L"" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"", L"" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"", L"" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"", L"" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"", L"" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"", L"" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, true, L"?", L",", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L".com", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_COMMA, true, L"\u00D6", L")", L"", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM1, true, L"\u00C4", L"\"", L"\u00C5", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + +}; + + +static KeyboardMapEntry gKeyboardMapARB [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"\u0634", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"\uFEFB", L"\uFEF5" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"\u0624", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"\u064A", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"\u062B", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"$", L"\u0628", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"%", L"\u0644", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"^", L"\u0627", L"\u0623" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"\u0647", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"\u062A", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"\u0646", L"\u0643" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"\u0645", L"\u0637" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"\u0629", L"\u0632" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"\u0649", L"\u0622" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"\u062E", L"\u062C" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"\u062D", L"\u062F" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"\u0630", L"\u0636" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"\u0642", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"\u0633", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"\u0641", L"\uFEF9" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"\u0639", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"\u0631", L"" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"\u0635", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"\u063A", L"\u0625" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"\u0621", L"" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"\u0626", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_COMMA, true, L"\u061F", L")", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L",", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QUESTION, true, L"\u0648", L"\"", L"\u0638", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + +}; + + +static KeyboardMapEntry gKeyboardMapIRN [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"\u0634", L"" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"\u062F", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"\u0631", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"\u0649", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"\u0642", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"$", L"\u0628", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"%", L"\u0644", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"^", L"\u0627", L"\u0622" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"\u062D", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"\u062A", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"\u0646", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"\u0645", L"" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"\u06A9", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"\u0648", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"\u062C", L"\u0686" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"\u067E", L"" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"\u0635", L"\u0636" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"\u0641", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"\u0633", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"\u0639", L"\u063A" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"\u062E", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"\u0630", L"" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"\u062B", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"\u0647", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"\u0632", L"\u0698" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"\u0637", L"\u0638" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_COMMA, true, L"\u061F", L")", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L",", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QUESTION, true, L"\u06AF", L"\"", L"\u0621", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry gKeyboardMapPAK [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"\u0627", L"\u0622" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"\u0628", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"\u0686", L"\u062B" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"\u062F", L"\u0688" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"\u0639", L"\u0651" }, + { KEY_F, VK_HP_F, true, L"F", L"$", L"\u0641", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"%", L"\u06AF", L"\u063A" }, + { KEY_H, VK_HP_H, true, L"H", L"^", L"\u0647", L"\u062D" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"\u0649", L"\u064A" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"\u062C", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"\u06A9", L"\u062E" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"\u0644", L"" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"\u0645", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"\u0646", L"\u06BA" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"\u06D5", L"\u0629" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"\u067F", L"\u064E" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"\u0642", L"\u0643" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"\u0631", L"\u0691" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"\u0633", L"\u0634" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"\u062A", L"\u0679" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"\u0626", L"\u0621" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"\u0637", L"\u0638" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"\u0648", L"\u0676" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"\u06D2", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"\u0635", L"\u0636" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"\u0632", L"\u0630" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_COMMA, true, L"\u061F", L")", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L",", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QUESTION, true, L"\u0698", L"\"", L"", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry gKeyboardMapTHA [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"\u0E1F", L"\u0E2B" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"\u0E37", L"\u0E4C" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"\u0E2D", L"\u0E09" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"\u0E40", L"\u0E42" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"\u0E1E", L"\u0E46" }, + { KEY_F, VK_HP_F, true, L"F", L"$", L"\u0E49", L"\u0E47" }, + { KEY_G, VK_HP_G, true, L"G", L"\u0E3F", L"\u0E48", L"\u0E4B" }, + { KEY_H, VK_HP_H, true, L"H", L"%", L"\u0E32", L"\u0E4A" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"\u0E19", L"\u0E08" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"\u0E2A", L"\u0E29" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"\u0E27", L"\u0E28" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"\u0E07", L"\u0E0B" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"\u0E43", L"\u0E2C" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"\u0E21", L"\u0E17" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"\u0E22", L"\u0E02" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"\u0E1A", L"\u0E0A" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"\u0E44", L"\u0E46" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"\u0E30", L"\u0E38" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"\u0E01", L"\u0E14" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"\u0E31", L"\u0E36" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"\u0E23", L"\u0E15" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"\u0E34", L"\u0E2E" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"\u0E33", L"\u0E11" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"\u0E04", L"\u0E35" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"", L"" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_COMMA, true, L",", L")", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, true, L"?", L"\"", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L".com", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QWERTY_SYM1, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + + +static KeyboardMapEntry gKeyboardMapVNM [KEY_HARDWARE_MAX + 1] = +{ + { KEY_INVALID, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_SIDE_UP, VK_HP_SIDEUP, true, L"", L"", L"", L"" }, + { KEY_SIDE_DOWN, VK_HP_SIDEDOWN, true, L"", L"", L"", L"" }, + { KEY_OK, VK_HP_OK, true, L"OK", L"", L"", L"" }, + { KEY_CLEAR, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA, VK_HP_CAMERA, true, L"", L"", L"", L"" }, + { KEY_SWITCH, VK_HP_SWITCH, true, L"", L"", L"", L"" }, + { KEY_0, VK_HP_INVALID, false, L"0", L"", L"", L"" }, + { KEY_1, VK_HP_INVALID, false, L"1", L"", L"", L"" }, + { KEY_2, VK_HP_INVALID, false, L"2", L"", L"", L"" }, + { KEY_3, VK_HP_INVALID, false, L"3", L"", L"", L"" }, + { KEY_4, VK_HP_INVALID, false, L"4", L"", L"", L"" }, + { KEY_5, VK_HP_INVALID, false, L"5", L"", L"", L"" }, + { KEY_6, VK_HP_INVALID, false, L"6", L"", L"", L"" }, + { KEY_7, VK_HP_INVALID, false, L"7", L"", L"", L"" }, + { KEY_8, VK_HP_INVALID, false, L"8", L"", L"", L"" }, + { KEY_9, VK_HP_INVALID, false, L"9", L"", L"", L"" }, + { KEY_ASTERISK, VK_HP_INVALID, false, L"*", L"", L"", L"" }, + { KEY_SHARP, VK_HP_INVALID, false, L"#", L"", L"", L"" }, + { KEY_LEFT, VK_HP_LEFT, true, L"", L"", L"", L"" }, + { KEY_UP, VK_HP_UP, true, L"", L"", L"", L"" }, + { KEY_DOWN, VK_HP_DOWN, true, L"", L"", L"", L"" }, + { KEY_RIGHT, VK_HP_RIGHT, true, L"", L"", L"", L"" }, + { KEY_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_A, VK_HP_A, true, L"A", L"!", L"\u0103", L"\u00E2" }, + { KEY_B, VK_HP_B, true, L"B", L";", L"", L"" }, + { KEY_C, VK_HP_C, true, L"C", L"_", L"", L"" }, + { KEY_D, VK_HP_SHARP, true, L"D", L"#", L"\u0111", L"" }, + { KEY_E, VK_HP_3, true, L"E", L"3", L"\u00EA", L"" }, + { KEY_F, VK_HP_F, true, L"F", L"$", L"", L"" }, + { KEY_G, VK_HP_G, true, L"G", L"%", L"", L"" }, + { KEY_H, VK_HP_H, true, L"H", L"^", L"", L"" }, + { KEY_I, VK_HP_8, true, L"I", L"8", L"", L"" }, + { KEY_J, VK_HP_J, true, L"J", L"&", L"", L"" }, + { KEY_K, VK_HP_ASTERISK, true, L"K", L"*", L"", L"" }, + { KEY_L, VK_HP_L, true, L"L", L"(", L"", L"" }, + { KEY_M, VK_HP_M, true, L"M", L"'", L"", L"" }, + { KEY_N, VK_HP_N, true, L"N", L":", L"", L"" }, + { KEY_O, VK_HP_9, true, L"O", L"9", L"\u00F4", L"\u01A1" }, + { KEY_P, VK_HP_0, true, L"P", L"0", L"", L"" }, + { KEY_Q, VK_HP_1, true, L"Q", L"1", L"", L"" }, + { KEY_R, VK_HP_4, true, L"R", L"4", L"", L"" }, + { KEY_S, VK_HP_S, true, L"S", L"@", L"", L"" }, + { KEY_T, VK_HP_5, true, L"T", L"5", L"", L"" }, + { KEY_U, VK_HP_7, true, L"U", L"7", L"\u01B0", L"" }, + { KEY_V, VK_HP_V, true, L"V", L"/", L"", L"" }, + { KEY_W, VK_HP_2, true, L"W", L"2", L"", L"" }, + { KEY_Y, VK_HP_6, true, L"Y", L"6", L"", L"" }, + { KEY_X, VK_HP_X, true, L"X", L"-", L"", L"" }, + { KEY_Z, VK_HP_PLUS, true, L"Z", L"+", L"", L"" }, + { KEY_BACKSPACE, VK_HP_CLEAR, true, L"", L"", L"", L"" }, + { KEY_COMMA, VK_HP_COMMA, true, L",", L")", L"", L"" }, + { KEY_ENTER, VK_HP_ENTER, true, L"", L"", L"", L"" }, + { KEY_CAPSLOCK, VK_HP_CAPSLOCK, true, L"", L"", L"", L"" }, + { KEY_QUESTION, VK_HP_QUESTION, true, L"?", L"\"", L"", L"" }, + { KEY_ALT, VK_HP_FN, true, L"", L"", L"", L"" }, + { KEY_SYM, VK_HP_SYM, true, L"sym", L":)", L"", L"" }, + { KEY_SETTING, VK_HP_INVALID, false, L"", L"", L"", L"" }, // for wave37 which does not diefine VK_HP_SETTING + { KEY_SPACE, VK_HP_SPACE, true, L" ", L"", L"", L"" }, + { KEY_DOT, VK_HP_POINT, true, L".", L".com", L"", L"" }, + { KEY_FN, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_CAMERA_HALF_SHUTTER, VK_HP_CAMERA_HALF_SHUTTER, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_1, VK_HP_QWERTY_TONE, true, L"\u0301", L"\u0300", L"\u0309", L"\u02DC" }, + { KEY_CHAR_SYM_2, VK_HP_QWERTY_SYM2, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_3, VK_HP_QWERTY_SYM3, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_4, VK_HP_QWERTY_SYM4, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_5, VK_HP_QWERTY_SYM5, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_6, VK_HP_QWERTY_SYM6, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_7, VK_HP_QWERTY_SYM7, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_8, VK_HP_QWERTY_SYM8, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_9, VK_HP_QWERTY_SYM9, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_A, VK_HP_QWERTY_SYMA, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_B, VK_HP_QWERTY_SYMB, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_C, VK_HP_QWERTY_SYMC, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_D, VK_HP_QWERTY_SYMD, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_E, VK_HP_QWERTY_SYME, false, L"", L"", L"", L"" }, + { KEY_CHAR_SYM_F, VK_HP_QWERTY_SYMF, false, L"", L"", L"", L"" }, + { KEY_FN_1, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_2, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_3, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_4, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_FN_5, VK_HP_INVALID, false, L"", L"", L"", L"" }, + { KEY_HARDWARE_MAX, VK_HP_INVALID, false, L"", L"", L"", L"" }, +}; + +static KeyboardMapEntry* gKeyboardMap = null; +static wchar_t* gKeyBoardTypeName = null; +*/ + +KeyboardMap* pKeyboardMapInstance = null; + +// forward declarations +result LoadKeyboardMap(void); + +//////////////////////////////////////////////////////////////////////////////// +/// KeyboardMap class Lifecycle + +KeyboardMap::KeyboardMap(void) +{ + // NOTHING +} + + +KeyboardMap::~KeyboardMap(void) +{ + // NOTHING +} + + +result +KeyboardMap::Construct(void) +{ + LoadKeyboardMap(); + return (E_SUCCESS); +} + +KeyboardMap* +KeyboardMap::GetInstance(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + pthread_once(&once_block, InitializeInstance); + + static bool constructed = false; + + if (!constructed) + { + pKeyboardMapInstance->Construct(); + constructed = true; + } + + return pKeyboardMapInstance; +} + +void +KeyboardMap::InitializeInstance(void) +{ + static KeyboardMap instance; + pKeyboardMapInstance = &instance; + +} + +//////////////////////////////////////////////////////////////////////////////// +/// KeyboardMap class Operations + + +KeyCode +KeyboardMap::GetKeyCode(int systemKeyCode) const +{ +/* + if (VK_HP_INVALID == systemKeyCode) + return KEY_INVALID; + + if (gKeyboardMap == null) + return KEY_INVALID; + + for (int i = 0; i < KEY_HARDWARE_MAX; i++) + { + if (gKeyboardMap[i].systemKeyCode == systemKeyCode) + return KeyCode(gKeyboardMap[i].keyCode); + } +*/ + + return KEY_INVALID; +} + + +bool +KeyboardMap::IsPrintingKey(KeyCode keyCode) const +{ +/* + if (gKeyboardMap == null) + return false; + + if (gKeyboardMap[keyCode].label1[0] != L'n') + return true; + return false; +*/ + + return false; +} + + +String +KeyboardMap::GetDisplayableLabel(KeyCode keyCode, KeyboardKeyLabelType type) const +{ +/* + String label = L""; + + if (gKeyboardMap == null) + return label; + + switch (type) + { + case KEYBOARD_KEY_LABEL_1: + if (gKeyboardMap[keyCode].label1[0] == L'n' && // L'n' means no label + gKeyboardMap[keyCode].label1[1] == 0) + { + label = L""; + } + else + { + // check for space 's' character + if (gKeyboardMap[keyCode].label1[0] == L's') + label = L" "; //space + else + label = gKeyboardMap[keyCode].label1; + } + break; + case KEYBOARD_KEY_LABEL_2: + if (gKeyboardMap[keyCode].label2[0] == L'n' && // L'n' means no label + gKeyboardMap[keyCode].label2[1] == 0) + { + label = L""; + } + else + { + // check for space 's' character + if (gKeyboardMap[keyCode].label2[0] == L's') + label = L" "; //space + else + label = gKeyboardMap[keyCode].label2; + } + break; + case KEYBOARD_KEY_LABEL_3: + if (gKeyboardMap[keyCode].label3[0] == L'n' && // L'n' means no label + gKeyboardMap[keyCode].label3[1] == 0) + { + label = L""; + } + else + { + // check for space 's' character + if (gKeyboardMap[keyCode].label3[0] == L's') + label = L" "; //space + else + label = gKeyboardMap[keyCode].label3; + } + break; + case KEYBOARD_KEY_LABEL_4: + if (gKeyboardMap[keyCode].label4[0] == L'n' && + gKeyboardMap[keyCode].label4[1] == 0) + { + label = L""; + } + else + { + if (gKeyboardMap[keyCode].label4[0] == L's') + label = L" "; //space + else + label = gKeyboardMap[keyCode].label4; + } + break; + default: + break; + } + return label; +*/ + + return String(L""); +} + + +bool +KeyboardMap::IsKeyAvailable(KeyCode keyCode) const +{ +/* + if (gKeyboardMap == null) + return false; + return gKeyboardMap[keyCode].available; +*/ + + return false; +} + + +String +KeyboardMap::GetKeyboardType(void) const +{ +/* + String type(L""); + if (gKeyBoardTypeName == null) + return type; + type = (const wchar_t*) gKeyBoardTypeName; + return type; +*/ + return String(L""); +} + + +result +KeyboardMap::LoadKeyboarMapFromFile(void) +{ + return E_SUCCESS; +} + + +KeyboardMapType +GetKeyboardMapType(void) +{ +/* + KeyboardMapType type = KEYBOARD_MAP_NONE; + + // get keyboard type + String keyboardTypeKey(L"KeyboardType"); + String keyboardType; + String country; + String operatorCountryKey(L"OperatorCountry"); + int operatorCountry = 0; + + result r = _SystemInfoImpl::GetSysInfo(keyboardTypeKey, keyboardType); + if (r != E_SUCCESS) + { + SysLogExceptionxception("[E_SYSTEM] Unable to get keyboard type."); + goto CATCH; + } + + + if (keyboardType == L"QWERTY") + { + // get operator country + type = KEYBOARD_MAP_GLB; + r =_SystemInfoImpl::GetSysInfo(operatorCountryKey, country); + if (r != E_SUCCESS) + { + SysLogExceptionxception("[E_SYSTEM] Unable to get operator country."); + goto CATCH; + } + +#if !defined( _WIN32 ) + // search table + for (int i = 0; i < KEYBOARD_MAP_TYPE_MAX; i++) + { + if (country == gKeyboardMapTypes[i].country) + { + type = gKeyboardMapTypes[i].type; + break; + } + } +#else + operatorCountry = NvGetInt( NV_SI_OPERATOR_COUNTRY ); + switch (operatorCountry) + { + case NV_OPERATOR_COUNTRY_FRANCE: + { + type = KEYBOARD_MAP_FRA; + } + break; + case NV_OPERATOR_COUNTRY_GERMANY: + { + type = KEYBOARD_MAP_DEU; + } + break; + case NV_OPERATOR_COUNTRY_SPAIN: + { + type = KEYBOARD_MAP_ESP; + } + break; + case NV_OPERATOR_COUNTRY_ITALY: + { + type = KEYBOARD_MAP_ITA; + } + break; + case NV_OPERATOR_COUNTRY_PORTUGAL: + { + type = KEYBOARD_MAP_PRT; + } + break; + case NV_OPERATOR_COUNTRY_GREECE: + { + type = KEYBOARD_MAP_GRC; + } + break; + case NV_OPERATOR_COUNTRY_RUSSIA: + { + type = KEYBOARD_MAP_RUS; + } + break; + case NV_OPERATOR_COUNTRY_FINLAND: // nordic + { + type = KEYBOARD_MAP_NOR; + } + break; + case NV_OPERATOR_COUNTRY_SINGAPORE: + { + type = KEYBOARD_MAP_SGP; + } + break; + case NV_OPERATOR_COUNTRY_THAILAND: + { + type = KEYBOARD_MAP_THA; + } + break; + case NV_OPERATOR_COUNTRY_VIETNAM: // L2 singapore + { + type = KEYBOARD_MAP_VNM; + } + break; + case NV_OPERATOR_COUNTRY_SOUTHAFRICA: + { + type = KEYBOARD_MAP_ZAF; + } + break; + case NV_OPERATOR_COUNTRY_PAKISTAN: + { + type = KEYBOARD_MAP_PAK; + } + break; + case NV_OPERATOR_COUNTRY_IRAN: + { + type = KEYBOARD_MAP_IRN; + } + break; + case NV_OPERATOR_COUNTRY_ARAB: + { + type = KEYBOARD_MAP_ARB; + } + break; + case NV_OPERATOR_COUNTRY_CHINA: + { + type = KEYBOARD_MAP_CHN; + } + break; + default: + { + type = KEYBOARD_MAP_EUR; + } + break; + } +#endif + } + else + { + // if NOT QWERTY load default keyboardmap + type = KEYBOARD_MAP_NONE; + } + return type; + +CATCH: + return KEYBOARD_MAP_NONE; +*/ + return KEYBOARD_MAP_NONE; +} + +result +LoadKeyboardMap(void) +{ +/* + KeyboardMapType type = GetKeyboardMapType(); + switch (type) + { + case KEYBOARD_MAP_NONE: + { + gKeyboardMap = gKeyboardMapNONE; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_NONE_NAME; + } + break; + case KEYBOARD_MAP_GLB: + { + gKeyboardMap = gKeyboardMapGLB; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_GLB_NAME; + + } + break; + case KEYBOARD_MAP_EUR: + { + gKeyboardMap = gKeyboardMapEUR; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_EUR_NAME; + } + break; + case KEYBOARD_MAP_ARB: + { + gKeyboardMap = gKeyboardMapARB; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_ARB_NAME; + } + break; + case KEYBOARD_MAP_CHN: + { + gKeyboardMap = gKeyboardMapCHN; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_CHN_NAME; + } + break; + case KEYBOARD_MAP_ESP: + { + gKeyboardMap = gKeyboardMapESP; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_ESP_NAME; + } + break; + case KEYBOARD_MAP_DEU: + { + gKeyboardMap = gKeyboardMapDEU; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_DEU_NAME; + } + break; + case KEYBOARD_MAP_FRA: + { + gKeyboardMap = gKeyboardMapFRA; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_FRA_NAME; + + } + break; + case KEYBOARD_MAP_ZAF: + { + gKeyboardMap = gKeyboardMapZAF; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_FRA_NAME; + + } + break; + case KEYBOARD_MAP_GRC: + { + gKeyboardMap = gKeyboardMapGRC; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_GRC_NAME; + } + break; + case KEYBOARD_MAP_IRN: + { + gKeyboardMap = gKeyboardMapIRN; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_IRN_NAME; + } + break; + case KEYBOARD_MAP_ITA: + { + gKeyboardMap = gKeyboardMapEUR_2; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_ITA_NAME; + } + break; + case KEYBOARD_MAP_PRT: + { + gKeyboardMap = gKeyboardMapEUR_2; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_PRT_NAME; + } + break; + case KEYBOARD_MAP_NOR: + { + gKeyboardMap = gKeyboardMapNOR; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_NOR_NAME; + } + break; + case KEYBOARD_MAP_PAK: + { + gKeyboardMap = gKeyboardMapPAK; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_PAK_NAME; + } + break; + case KEYBOARD_MAP_RUS: + { + gKeyboardMap = gKeyboardMapRUS; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_RUS_NAME; + } + break; + case KEYBOARD_MAP_SGP: + { + gKeyboardMap = gKeyboardMapGLB; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_SGP_NAME; + } + break; + case KEYBOARD_MAP_THA: + { + gKeyboardMap = gKeyboardMapTHA; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_THA_NAME; + } + break; + case KEYBOARD_MAP_VNM: + { + gKeyboardMap = gKeyboardMapVNM; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_VNM_NAME; + } + break; + default: + { + gKeyboardMap = gKeyboardMapNONE; + gKeyBoardTypeName = (wchar_t*) KEYBOARD_MAP_NONE_NAME; + } + break; + } + return (E_SUCCESS); +*/ + return E_SUCCESS; +} + +}} // Tizen::Ui diff --git a/src/ui/FUiLayout.cpp b/src/ui/FUiLayout.cpp new file mode 100644 index 0000000..2e5a26f --- /dev/null +++ b/src/ui/FUiLayout.cpp @@ -0,0 +1,60 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiLayout.cpp + * @brief This is the implementation file for Layout class. + * + * This file contains the implementation of Layout class. + */ + +#include +#include +#include +#include "FUi_LayoutImpl.h" + +namespace Tizen { namespace Ui +{ + +Layout::Layout(void) +{ + LayoutImplHolder* pHolder = new (std::nothrow) LayoutImplHolder(); + SysAssert(pHolder != null); + _pImpl = pHolder; +} + +Layout::~Layout(void) +{ + LayoutImplHolder* pHolder = static_cast (_pImpl); + SysAssert(pHolder != null); + + delete pHolder; + _pImpl = null; +} + +result +Layout::Update(void) +{ + LayoutImplHolder* pHolder = static_cast (_pImpl); + SysAssert(pHolder != null); + + _LayoutImpl* pImpl = pHolder->layoutImpl.Get(); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->UpdateLayout(); +} + +}} // Tizen::Ui diff --git a/src/ui/FUiRelativeLayout.cpp b/src/ui/FUiRelativeLayout.cpp new file mode 100644 index 0000000..609174f --- /dev/null +++ b/src/ui/FUiRelativeLayout.cpp @@ -0,0 +1,220 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiRelativeLayout.cpp + * @brief This is the implementation file for RelativeLayout class. + * + * This file contains the implementation of RelativeLayout class. + */ + +#include +#include +#include "FUi_RelativeLayoutImpl.h" + +namespace Tizen { namespace Ui +{ + +RelativeLayout::RelativeLayout() +{ +} + +RelativeLayout::~RelativeLayout() +{ +} + +result +RelativeLayout::Construct(void) +{ + ClearLastResult(); + + _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this); + SysAssertf(pRelativeLayoutImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pRelativeLayoutImpl = _RelativeLayoutImpl::CreateRelativeLayoutImplN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _LayoutImpl::SetLayoutImpl(this, pRelativeLayoutImpl); + + return E_SUCCESS; +} + +Tizen::Ui::LayoutType +RelativeLayout::GetLayoutType(void) const +{ + return LAYOUT_RELATIVE; +} + +result +RelativeLayout::SetRelation(Control& childControl, const Control& targetControl, RectangleEdgeRelation edgeRelation) +{ + ClearLastResult(); + + _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this); + SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + _ControlImpl* pTargetControlImpl = const_cast<_ControlImpl*>(_ControlImpl::GetInstance(targetControl)); + SysTryReturn(NID_UI, pTargetControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = E_SUCCESS; + + r = pRelativeLayoutImpl->SetRelation(*pControlImpl, *pTargetControlImpl, edgeRelation); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +RelativeLayout::ResetRelation(Control& childControl, RectangleEdgeType edgeType) +{ + ClearLastResult(); + + _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this); + SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pRelativeLayoutImpl->ResetRelation(*pControlImpl, edgeType); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +RelativeLayout::SetCenterAligned(Control& childControl, CenterAlignmentType alignment) +{ + ClearLastResult(); + + _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this); + SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pRelativeLayoutImpl->SetCenterAligned(*pControlImpl, alignment); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +RelativeLayout::ResetCenterAligned(Control& childControl, CenterAlignmentType alignment) +{ + ClearLastResult(); + + _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this); + SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pRelativeLayoutImpl->ResetCenterAligned(*pControlImpl, alignment); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +RelativeLayout::SetMargin(Control& childControl, int left, int right, int top, int bottom) +{ + ClearLastResult(); + + _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this); + SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pRelativeLayoutImpl->SetItemMargin(*pControlImpl, left, right, top, bottom); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +RelativeLayout::SetWidth(Control& childControl, int width) +{ + ClearLastResult(); + + _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this); + SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pRelativeLayoutImpl->SetWidth(*pControlImpl, width); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +RelativeLayout::SetHeight(Control& childControl, int height) +{ + ClearLastResult(); + + _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this); + SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pRelativeLayoutImpl->SetHeight(*pControlImpl, height); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +RelativeLayout::SetHorizontalFitPolicy(Control& childControl, FitPolicy policy) +{ + ClearLastResult(); + + _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this); + SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pRelativeLayoutImpl->SetItemHorizontalFitPolicy(*pControlImpl, policy); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +RelativeLayout::SetVerticalFitPolicy(Control& childControl, FitPolicy policy) +{ + ClearLastResult(); + + _RelativeLayoutImpl* pRelativeLayoutImpl = _RelativeLayoutImpl::GetInstance(*this); + SysAssertf(pRelativeLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pRelativeLayoutImpl->SetItemVerticalFitPolicy(*pControlImpl, policy); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +}} // Tizen::Ui diff --git a/src/ui/FUiSystemUtil.cpp b/src/ui/FUiSystemUtil.cpp new file mode 100644 index 0000000..937de6e --- /dev/null +++ b/src/ui/FUiSystemUtil.cpp @@ -0,0 +1,297 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include + +//to avoid camera key code definition +#ifdef KEY_CAMERA +#undef KEY_CAMERA +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include "FSec_AccessController.h" +#include "FApp_AppInfo.h" + +using namespace Tizen::Security; +using namespace Tizen::Graphics; +using namespace Tizen::Base; + +namespace Tizen { namespace Ui +{ + +struct ConvertKeys +{ + KeyCode code; + const char* pName; +}; + +const ConvertKeys KeyCodeMap[] = { + { KEY_INVALID, "" }, + { KEY_SIDE_UP, "XF86AudioRaiseVolume" }, + { KEY_SIDE_DOWN, "XF86AudioLowerVolume" }, + { KEY_OK, "XF86Phone" }, + { KEY_CLEAR, "" }, + { KEY_CAMERA, "" }, + { KEY_SWITCH, "" }, + { KEY_0, "0" }, + { KEY_1, "1" }, + { KEY_2, "2" }, + { KEY_3, "3" }, + { KEY_4, "4" }, + { KEY_5, "5" }, + { KEY_6, "6" }, + { KEY_7, "7" }, + { KEY_8, "8" }, + { KEY_9, "9" }, + { KEY_ASTERISK, "" }, + { KEY_SHARP, "" }, + { KEY_LEFT, "KP_Left" }, + { KEY_UP, "KP_Up" }, + { KEY_DOWN, "KP_Down" }, + { KEY_RIGHT, "KP_Right" }, + { KEY_MAX, "" }, + { KEY_A, "a" }, + { KEY_B, "b" }, + { KEY_C, "c" }, + { KEY_D, "d" }, + { KEY_E, "e" }, + { KEY_F, "f" }, + { KEY_G, "g" }, + { KEY_H, "h" }, + { KEY_I, "i" }, + { KEY_J, "j" }, + { KEY_K, "k" }, + { KEY_L, "l" }, + { KEY_M, "m" }, + { KEY_N, "n" }, + { KEY_O, "o" }, + { KEY_P, "p" }, + { KEY_Q, "q" }, + { KEY_R, "r" }, + { KEY_S, "s" }, + { KEY_T, "t" }, + { KEY_U, "u" }, + { KEY_V, "v" }, + { KEY_W, "w" }, + { KEY_Y, "y" }, + { KEY_X, "x" }, + { KEY_Z, "z" }, + { KEY_BACKSPACE, "BackSpace" }, + { KEY_COMMA, "comma" }, + { KEY_ENTER, "" }, + { KEY_CAPSLOCK, "Caps_Lock" }, + { KEY_QUESTION, "" }, + { KEY_ALT, "Alt_L" }, + { KEY_SYM, "" }, + { KEY_SETTING, "" }, + { KEY_SPACE, "space" }, + { KEY_DOT, "" }, + { KEY_FN, "" }, + { KEY_CAMERA_HALF_SHUTTER, "" }, + { KEY_CHAR_SYM_1, "" }, + { KEY_CHAR_SYM_2, "" }, + { KEY_CHAR_SYM_3, "" }, + { KEY_CHAR_SYM_4, "" }, + { KEY_CHAR_SYM_5, "" }, + { KEY_CHAR_SYM_6, "" }, + { KEY_CHAR_SYM_7, "" }, + { KEY_CHAR_SYM_8, "" }, + { KEY_CHAR_SYM_9, "" }, + { KEY_CHAR_SYM_A, "" }, + { KEY_CHAR_SYM_B, "" }, + { KEY_CHAR_SYM_C, "" }, + { KEY_CHAR_SYM_D, "" }, + { KEY_CHAR_SYM_E, "" }, + { KEY_CHAR_SYM_F, "" }, + { KEY_FN_1, "" }, + { KEY_FN_2, "" }, + { KEY_FN_3, "" }, + { KEY_FN_4, "" }, + { KEY_FN_5, "" }, + { KEY_POWER_HOLD, "XF86PowerOff" }, + { KEY_DELETE, "" }, + { KEY_HARDWARE_MAX, "" }, +}; + +struct _DisplayDeleter +{ + void operator()(Display* pDisplay) + { + XCloseDisplay(pDisplay); + } +}; + +SystemUtil::SystemUtil(void) +{ +} + +SystemUtil::~SystemUtil(void) +{ +} + +result +SystemUtil::GenerateKeyEvent(KeyEventType KeyEvent, KeyCode keyCode) +{ + result r = E_SUCCESS; + + const String& appId = Tizen::App::_AppInfo::GetAppId(); + + r = _AccessController::CheckSystemPrivilege(appId, _PRV_INPUTMANAGER); + + SysTryReturn(NID_UI, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.")); + + Display* pDisplay = (Display*)ecore_x_display_get(); + SysTryReturnResult(NID_UI, pDisplay != null, E_SYSTEM, "[E_SYSTEM] pDisplay is invalid. something wrong!"); + + std::unique_ptr pDpy(XOpenDisplay(NULL)); + SysTryReturnResult(NID_UI, pDpy.get() != null, E_SYSTEM, "[E_SYSTEM] pDpy is invalid. something wrong!"); + + int key = -1; + + for (unsigned int idx = 0; idx < sizeof(KeyCodeMap) / sizeof(ConvertKeys); ++idx) + { + if (KeyCodeMap[idx].code == keyCode) + { + KeySym keySym = XStringToKeysym(KeyCodeMap[idx].pName); + key = (int) XKeysymToKeycode(pDpy.get(), keySym); + break; + } + } + + if (key == -1) + { + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] Unsupported KeyCode argument."); + return E_INVALID_ARG; + } + + switch (KeyEvent) + { + case KEY_EVENT_TYPE_PRESSED: + XTestFakeKeyEvent(pDisplay, key, true, CurrentTime); + break; + + case KEY_EVENT_TYPE_RELEASED: + XTestFakeKeyEvent(pDisplay, key, false, CurrentTime); + break; + + default: + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] Invalid KeyEventType argument."); + return E_INVALID_ARG; + } + + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +SystemUtil::GenerateTouchEvent(TouchEventType touchEvent, const Tizen::Graphics::Point& point) +{ + result r = E_SUCCESS; + const String& appId = Tizen::App::_AppInfo::GetAppId(); + + r = _AccessController::CheckSystemPrivilege(appId, _PRV_INPUTMANAGER); + + SysTryReturn(NID_UI, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.")); + + Display* pDisplay = (Display*)ecore_x_display_get(); + SysTryReturnResult(NID_UI, pDisplay != null, E_SYSTEM, "[E_SYSTEM] pDisplay is invalid. something wrong!"); + + std::unique_ptr pDpy(XOpenDisplay(NULL)); + SysTryReturnResult(NID_UI, pDpy.get() != null, E_SYSTEM, "[E_SYSTEM] pDpy is invalid. something wrong!"); + + int width = DisplayWidth(pDpy.get(), DefaultScreen(pDpy.get())); + int height = DisplayHeight(pDpy.get(), DefaultScreen(pDpy.get())); + + if (( point.x<0 || point.x>width) || (point.y<0 || point.y>height)) + { + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] Out of bounds x, y argument."); + return E_INVALID_ARG; + } + + int screenNumber = 0; //main screen + int button = 1; //left button + + switch (touchEvent) + { + case TOUCH_EVENT_TYPE_PRESSED: + XWarpPointer(pDisplay, None, XRootWindow(pDisplay, 0), 0, 0, 0, 0, point.x, point.y); + XTestFakeButtonEvent(pDisplay, button, true, CurrentTime); + break; + + case TOUCH_EVENT_TYPE_RELEASED: + XWarpPointer(pDisplay, None, XRootWindow(pDisplay, 0), 0, 0, 0, 0, point.x, point.y); + XTestFakeButtonEvent(pDisplay, button, false, CurrentTime); + break; + + case TOUCH_EVENT_TYPE_MOVED: + XTestFakeMotionEvent(pDisplay, screenNumber, point.x, point.y, CurrentTime); + break; + + default: + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] Invalid TouchEventType argument."); + return E_INVALID_ARG; + } + + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); //fix me + return r; +} + +Tizen::Graphics::Bitmap* +SystemUtil::CaptureScreenN(void) +{ + result r = E_SUCCESS; + const String& appId = Tizen::App::_AppInfo::GetAppId(); + + r = _AccessController::CheckSystemPrivilege(appId, _PRV_INPUTMANAGER); + + SysTryReturn(NID_UI, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."); + std::unique_ptr pDpy(XOpenDisplay(NULL)); + SysTryReturn(NID_UI, pDpy, null, E_SYSTEM, "[E_SYSTEM] pDpy is invalid. something wrong!"); + + int width = DisplayWidth(pDpy.get(), DefaultScreen(pDpy.get())); + int height = DisplayHeight(pDpy.get(), DefaultScreen(pDpy.get())); + + void* pDump = utilx_create_screen_shot(pDpy.get(), width, height); + SysTryReturn(NID_UI, pDump, null, E_SYSTEM, "[E_SYSTEM] pDump is invalid. something wrong!"); + + std::unique_ptr pBuffer(new (std::nothrow) ByteBuffer()); + SysTryReturn(NID_UI, pBuffer != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failure."); + + r = pBuffer->Construct(static_cast(pDump), 0, width*height*4, width*height*4); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + Tizen::Graphics::Dimension dim(width, height); + std::unique_ptr pBitmap(new (std::nothrow) Bitmap()); + SysTryReturn(NID_UI, pBitmap != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failure."); + + r = pBitmap->Construct(*pBuffer, dim, BITMAP_PIXEL_FORMAT_ARGB8888); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + utilx_release_screen_shot(); + + return pBitmap.release(); +} + +}} //Tizen::Ui diff --git a/src/ui/FUiTouch.cpp b/src/ui/FUiTouch.cpp new file mode 100644 index 0000000..66d494c --- /dev/null +++ b/src/ui/FUiTouch.cpp @@ -0,0 +1,253 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiTouch.cpp + * @brief This is the implementation file for Touch class + * @version 2.0 + * + * This file contains the implementation of Touch class. + * + */ + +#include +#include +#include +#include +#include "FUi_CoordinateSystemUtils.h" +#include "FUi_TouchManager.h" +#include "FUi_ControlImpl.h" +#include "FUi_TouchEventArg.h" +#include "FUi_UiTouchEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace { + +IList* +GetMultiFingerInfoListN(const Control* pControl) +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, null, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + Point controlPos(0, 0); + if (pControl != null) + { + const _ControlImpl* pImpl = _ControlImpl::GetInstance(*pControl); + if (pImpl != null) + { + controlPos.x = pImpl->GetAbsoluteBounds().x; + controlPos.y = pImpl->GetAbsoluteBounds().y; + } + } + + LinkedList* pReturnList = new (std::nothrow) LinkedList; + SysTryReturn(NID_UI, pReturnList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::Collection::IListT<_FingerInfo*>* pFingerInfoList = pTouchManager->GetMultiFingerInfoListN(); + SysTryCatch(NID_UI, pFingerInfoList, , E_SYSTEM, "[E_SYSTEM] System error occurred."); + + for (int i = 0; i < pFingerInfoList->GetCount(); i++) + { + _FingerInfo* pFingerInfo = null; + pFingerInfoList->GetAt(i, pFingerInfo); + + if (pFingerInfo == null) + { + continue; + } + + TouchInfo* pTouchInfo = new (std::nothrow) TouchInfo; + SysTryCatch(NID_UI, pTouchInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (pFingerInfo->GetStatus() == _TOUCH_PRESSED ||pFingerInfo->GetStatus() == _TOUCH_MOVED ) + { + pTouchInfo->id = pFingerInfo->GetPointId(); + pTouchInfo->position.x = pFingerInfo->GetScreenPoint().x - controlPos.x; + pTouchInfo->position.y = pFingerInfo->GetScreenPoint().y - controlPos.y; + pTouchInfo->status = TOUCH_PRESSED; + + pReturnList->Add(*pTouchInfo); + } + } + + delete pFingerInfoList; + pFingerInfoList = null; + + return pReturnList; + +CATCH: + if (pReturnList) + { + pReturnList->RemoveAll(true); + delete pReturnList; + pReturnList = null; + } + + if (pFingerInfoList) + { + delete pFingerInfoList; + pFingerInfoList = null; + } + + return null; +} +} + +namespace Tizen { namespace Ui +{ + +Touch::Touch(void) +{ +} + +Touch::~Touch(void) +{ +} + +Point +Touch::GetPosition(void) const +{ + Point errorPoint(-1, -1); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, errorPoint, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return pTouchManager->GetScreenPoint(pTouchManager->GetCurrentPointId()); +} + +Point +Touch::GetPosition(unsigned long id) const +{ + Point errorPoint(-1, -1); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, errorPoint, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return pTouchManager->GetScreenPoint(id); +} + +Point +Touch::GetPosition(const Control& control) const +{ + Point errorPoint(-1, -1); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, errorPoint, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(control); + if (!pControlImpl) + { + return errorPoint; + } + + Point controlPos(pControlImpl->GetAbsoluteBounds().x, pControlImpl->GetAbsoluteBounds().y); + Point point(pTouchManager->GetScreenPoint(pTouchManager->GetCurrentPointId()).x, pTouchManager->GetScreenPoint(pTouchManager->GetCurrentPointId()).y); + + point.x -= controlPos.x; + point.y -= controlPos.y; + + return point; +} + +Point +Touch::GetPosition(const Control& control, unsigned long id) const +{ + Point errorPoint(-1, -1); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, errorPoint, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(control); + if (!pControlImpl) + { + return errorPoint; + } + + Point controlPos(pControlImpl->GetAbsoluteBounds().x, pControlImpl->GetAbsoluteBounds().y); + Point point(pTouchManager->GetScreenPoint(id).x, pTouchManager->GetScreenPoint(id).y); + + point.x -= controlPos.x; + point.y -= controlPos.y; + + return point; +} + +result +Touch::SetMultipointEnabled(const Control& control, bool enable) +{ + _ControlImpl* pControlImpl = const_cast<_ControlImpl*>(_ControlImpl::GetInstance(control)); + SysTryReturnResult(NID_UI, pControlImpl, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + pControlImpl->SetMultiTouchEnabled(enable); + + return E_SUCCESS; +} + + +bool +Touch::IsMultipointEnabled(const Control& control) const +{ + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(control); + SysTryReturn(NID_UI, pControlImpl, false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return pControlImpl->IsMultiTouchEnabled(); +} + + +TouchStatus +Touch::GetTouchStatus(unsigned long id) const +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, TOUCH_PRESSED, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return pTouchManager->GetTouchStatus(id); +} + +IList* +Touch::GetTouchInfoListN(void) const +{ + return GetMultiFingerInfoListN(null); +} + +IList* +Touch::GetTouchInfoListN(const Control& control) const +{ + return GetMultiFingerInfoListN(&control); +} + +int +Touch::GetPointCount(void) const +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, 0, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return pTouchManager->GetPointCount(); +} + +unsigned long +Touch::GetPointId(int index) const +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, 0, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return pTouchManager->GetPointId(index); +} + +} } // Tizen::Ui diff --git a/src/ui/FUiTouchEventInfo.cpp b/src/ui/FUiTouchEventInfo.cpp new file mode 100644 index 0000000..8253d43 --- /dev/null +++ b/src/ui/FUiTouchEventInfo.cpp @@ -0,0 +1,145 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiTouchEventInfo.cpp + * @brief This is the implementation file for TouchEventInfo class + * @version 2.0 + * + * This file contains the implementation of TouchEventInfo class. + * + */ + +#include +#include +#include "FUi_TouchEventInfoImpl.h" +#include "FUi_TouchEventArg.h" +#include "FUi_TouchManager.h" + +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +TouchEventInfo::TouchEventInfo(void) + : __pTouchEventInfoImpl(null) +{ +} + +TouchEventInfo::~TouchEventInfo(void) +{ + delete __pTouchEventInfoImpl; + __pTouchEventInfoImpl = null; +} + +result +TouchEventInfo::Construct(const IEventArg& eventArg) +{ + SysAssertf(__pTouchEventInfoImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + const _TouchEventArg* pTouchArg = dynamic_cast (&eventArg); + SysTryReturnResult(NID_UI, pTouchArg, E_INVALID_ARG, "[E_INVALID_ARG] pTouchArg is invalid."); + + _TouchEventInfoImpl* pImpl = _TouchEventInfoImpl::CreateInstanceN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTouchEventInfoImpl = pImpl; + + _TouchInfo touchInfo(pTouchArg->GetPointId(), pTouchArg->GetTouchStatus(), pTouchArg->GetCurrentPosition(), pTouchArg->IsFlicked(), 0); + Point startPosition = pTouchArg->GetStartPosition(); + + __pTouchEventInfoImpl->SetTouchEventInfo(touchInfo, startPosition); + + return E_SUCCESS; +} + +unsigned long +TouchEventInfo::GetPointId(void) const +{ + SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchEventInfoImpl->GetPointId(); +} + + +Point +TouchEventInfo::GetStartPosition(void) const +{ + SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchEventInfoImpl->GetStartPosition(); +} + +Point +TouchEventInfo::GetCurrentPosition(void) const +{ + SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchEventInfoImpl->GetCurrentPosition(); +} + + +TouchStatus +TouchEventInfo::GetTouchStatus(void) const +{ + SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used."); + + TouchStatus status = TOUCH_PRESSED; + + switch (__pTouchEventInfoImpl->GetTouchStatus()) + { + case _TOUCH_PRESSED: + status = TOUCH_PRESSED; + break; + case _TOUCH_LONG_PRESSED: + status = TOUCH_LONG_PRESSED; + break; + case _TOUCH_RELEASED: + status = TOUCH_RELEASED; + break; + case _TOUCH_MOVED: + status = TOUCH_MOVED; + break; + case _TOUCH_DOUBLE_PRESSED: + status = TOUCH_DOUBLE_PRESSED; + break; + case _TOUCH_FOCUS_IN: + status = TOUCH_FOCUS_IN; + break; + case _TOUCH_FOCUS_OUT: + status = TOUCH_FOCUS_OUT; + break; + case _TOUCH_CANCELED: + status = TOUCH_CANCELED; + break; + default: + break; + } + + return status; +} + +bool +TouchEventInfo::IsFlicked(void) const +{ + SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchEventInfoImpl->IsFlicked(); +} + +}} //Tizen::Ui diff --git a/src/ui/FUiTouchEventManager.cpp b/src/ui/FUiTouchEventManager.cpp new file mode 100644 index 0000000..343f9a8 --- /dev/null +++ b/src/ui/FUiTouchEventManager.cpp @@ -0,0 +1,70 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiTouchEventManager.cpp + * @brief This is the implementation file for %TouchEventManager class + * @version 2.0 + * + * This file contains the implementation of %TouchEventManager class. + * + */ + +#include +#include +#include +#include "FUi_TouchEventManagerImpl.h" + +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui +{ +namespace { TouchEventManager* __pTouchEventManager = null; } + +TouchEventManager::TouchEventManager(void) + : __pTouchEventManagerImpl(null) +{ + __pTouchEventManagerImpl = new _TouchEventManagerImpl; + SysTryReturnVoidResult(NID_UI, __pTouchEventManagerImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); +} + +TouchEventManager::~TouchEventManager(void) +{ + delete __pTouchEventManagerImpl; + __pTouchEventManagerImpl = null; +} + +TouchEventManager* +TouchEventManager::GetInstance(void) +{ + if (__pTouchEventManager == null) + { + __pTouchEventManager = new TouchEventManager; + SysTryReturn(NID_UI, __pTouchEventManager, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + } + + return __pTouchEventManager; +} + +IListT* +TouchEventManager::GetTouchInfoListN(void) const +{ + SysAssertf(__pTouchEventManagerImpl, "Not yet constructed. GetInstance() should be called before use."); + + return __pTouchEventManagerImpl->GetTouchInfoListN(); +} + +}} //Tizen::Ui diff --git a/src/ui/FUiTouchFlickGestureDetector.cpp b/src/ui/FUiTouchFlickGestureDetector.cpp new file mode 100644 index 0000000..9ffdd52 --- /dev/null +++ b/src/ui/FUiTouchFlickGestureDetector.cpp @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiTouchFlickGestureDetector.cpp + * @brief This is the implementation file for %TouchFlickGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %TouchFlickGestureDetector class. + * + */ + +#include +#include +#include "FUi_TouchFlickGestureDetectorImpl.h" + +namespace Tizen { namespace Ui +{ +TouchFlickGestureDetector::TouchFlickGestureDetector(void) +{ +} + +TouchFlickGestureDetector::~TouchFlickGestureDetector(void) +{ +} + +result +TouchFlickGestureDetector::Construct(void) +{ + SysAssertf(__pTouchGestureDetectorImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _TouchGestureDetectorImpl* pImpl = _TouchFlickGestureDetectorImpl::CreateInstanceN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTouchGestureDetectorImpl = pImpl; + + return E_SUCCESS; +} + +result +TouchFlickGestureDetector::AddFlickGestureEventListener(ITouchFlickGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + result r = __pTouchGestureDetectorImpl->AddGestureEventListener(listener); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +TouchFlickGestureDetector::RemoveFlickGestureEventListener(ITouchFlickGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + result r = __pTouchGestureDetectorImpl->RemoveGestureEventListener(listener); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +TouchFlickGestureDetector::GetDistance(int& xDistance, int& yDistance) const +{ + const _TouchFlickGestureDetectorImpl* pTouchFlickGestureDetectorImpl = _TouchFlickGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchFlickGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchFlickGestureDetectorImpl->GetDistance(xDistance, yDistance); +} + +int +TouchFlickGestureDetector::GetDuration(void) const +{ + const _TouchFlickGestureDetectorImpl* pTouchFlickGestureDetectorImpl = _TouchFlickGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchFlickGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchFlickGestureDetectorImpl->GetDuration(); +} + +FlickDirection +TouchFlickGestureDetector::GetDirection(void) const +{ + const _TouchFlickGestureDetectorImpl* pTouchFlickGestureDetectorImpl = _TouchFlickGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchFlickGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchFlickGestureDetectorImpl->GetDirection(); +} + +}} //Tizen::Ui diff --git a/src/ui/FUiTouchGestureDetector.cpp b/src/ui/FUiTouchGestureDetector.cpp new file mode 100644 index 0000000..4675bb8 --- /dev/null +++ b/src/ui/FUiTouchGestureDetector.cpp @@ -0,0 +1,175 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiTouchGestureDetector.cpp + * @brief This is the implementation file for TouchGestureDetector class + * @version 2.0 + * + * This file contains the implementation of TouchGestureDetector class. + * + */ + +#include +#include +#include "FUi_TouchGestureDetectorImpl.h" + +namespace Tizen { namespace Ui +{ +TouchGestureDetector::TouchGestureDetector(void) + : __pTouchGestureDetectorImpl(null) +{ + +} + +TouchGestureDetector::~TouchGestureDetector(void) +{ + delete __pTouchGestureDetectorImpl; + __pTouchGestureDetectorImpl = null; +} + +result +TouchGestureDetector::Construct(void) +{ + SysAssertf(__pTouchGestureDetectorImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _TouchGestureDetectorImpl* pImpl = _TouchGestureDetectorImpl::CreateInstanceN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTouchGestureDetectorImpl = pImpl; + return r; +} + +result +TouchGestureDetector::AddGestureEventListener(Tizen::Ui::ITouchGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + result r = __pTouchGestureDetectorImpl->AddGestureEventListener(listener); + SysTryLog(NID_UI, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +TouchGestureDetector::RemoveGestureEventListener(Tizen::Ui::ITouchGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + result r = __pTouchGestureDetectorImpl->RemoveGestureEventListener(listener); + SysTryLog(NID_UI, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +TouchGestureDetector::SetDetectorState(Tizen::Ui::TouchGestureDetectorState state) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + result r = __pTouchGestureDetectorImpl->SetDetectorState(state); + SysTryLog(NID_UI, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Tizen::Ui::TouchGestureDetectorState +TouchGestureDetector::GetDetectorState(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchGestureDetectorImpl->GetDetectorState(); +} + +Control* +TouchGestureDetector::GetControl(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchGestureDetectorImpl->GetControl(); +} + +result +TouchGestureDetector::SetDelayTouchEventEnabled(bool enable) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + result r = __pTouchGestureDetectorImpl->SetDelayTouchEventEnabled(enable); + SysTryLog(NID_UI, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +bool +TouchGestureDetector::IsDelayTouchEventEnabled(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchGestureDetectorImpl->IsDelayTouchEventEnabled(); +} + +result +TouchGestureDetector::SetCancelTouchEventOnSuccessEnabled(bool enable) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + result r = __pTouchGestureDetectorImpl->SetCancelTouchEventOnSuccessEnabled(enable); + SysTryLog(NID_UI, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +bool +TouchGestureDetector::IsCancelTouchEventOnSuccessEnabled(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchGestureDetectorImpl->IsCancelTouchEventOnSuccessEnabled(); +} + +result +TouchGestureDetector::StartOnFailureOf(const TouchGestureDetector& gesture) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + result r = __pTouchGestureDetectorImpl->StartOnFailureOf(gesture); + SysTryLog(NID_UI, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +TouchGestureDetector::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchInfo) +{ +} + +void +TouchGestureDetector::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchInfo) +{ +} + +void +TouchGestureDetector::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchInfo) +{ +} + +void +TouchGestureDetector::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchInfo) +{ +} + +}} //Tizen::Ui diff --git a/src/ui/FUiTouchLongPressGestureDetector.cpp b/src/ui/FUiTouchLongPressGestureDetector.cpp new file mode 100644 index 0000000..a22d305 --- /dev/null +++ b/src/ui/FUiTouchLongPressGestureDetector.cpp @@ -0,0 +1,137 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiTouchLongPressGestureDetector.cpp + * @brief This is the implementation file for %TouchLongPressGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %TouchLongPressGestureDetector class. + * + */ + +#include +#include +#include +#include "FUi_TouchLongPressGestureDetectorImpl.h" + +namespace Tizen { namespace Ui +{ +TouchLongPressGestureDetector::TouchLongPressGestureDetector(void) +{ +} + +TouchLongPressGestureDetector::~TouchLongPressGestureDetector(void) +{ +} + +result +TouchLongPressGestureDetector::Construct(void) +{ + SysAssertf(__pTouchGestureDetectorImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _TouchGestureDetectorImpl* pImpl = _TouchLongPressGestureDetectorImpl::CreateInstanceN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTouchGestureDetectorImpl = pImpl; + + return E_SUCCESS; +} + +result +TouchLongPressGestureDetector::AddLongPressGestureEventListener(ITouchLongPressGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchGestureDetectorImpl->AddGestureEventListener(listener); +} + +result +TouchLongPressGestureDetector::RemoveLongPressGestureEventListener(ITouchLongPressGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchGestureDetectorImpl->RemoveGestureEventListener(listener); +} + +result +TouchLongPressGestureDetector::SetDuration(int duration) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchLongPressGestureDetectorImpl->SetDuration(duration); +} + +int +TouchLongPressGestureDetector::GetDuration(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchLongPressGestureDetectorImpl->GetDuration(); +} + +result +TouchLongPressGestureDetector::SetMoveAllowance(int allowance) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchLongPressGestureDetectorImpl->SetMoveAllowance(allowance); +} + +int +TouchLongPressGestureDetector::GetMoveAllowance(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchLongPressGestureDetectorImpl->GetMoveAllowance(); +} + +result +TouchLongPressGestureDetector::SetTouchCount(int count) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchLongPressGestureDetectorImpl->SetTouchCount(count); +} + +int +TouchLongPressGestureDetector::GetTouchCount(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchLongPressGestureDetectorImpl->GetTouchCount(); +} + +}} // Tizen::Ui diff --git a/src/ui/FUiTouchPanningGestureDetector.cpp b/src/ui/FUiTouchPanningGestureDetector.cpp new file mode 100644 index 0000000..122d8e4 --- /dev/null +++ b/src/ui/FUiTouchPanningGestureDetector.cpp @@ -0,0 +1,105 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiTouchPanningGestureDetector.cpp + * @brief This is the implementation file for %TouchPanningGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %TouchPanningGestureDetector class. + * + */ + +#include +#include +#include "FUi_TouchPanningGestureDetectorImpl.h" + +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui +{ +TouchPanningGestureDetector::TouchPanningGestureDetector(void) +{ +} + +TouchPanningGestureDetector::~TouchPanningGestureDetector(void) +{ +} + +result +TouchPanningGestureDetector::Construct(void) +{ + SysAssertf(__pTouchGestureDetectorImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _TouchGestureDetectorImpl* pImpl = _TouchPanningGestureDetectorImpl::CreateInstanceN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagatin.", GetErrorMessage(r)); + + __pTouchGestureDetectorImpl = pImpl; + + return E_SUCCESS; +} + +result +TouchPanningGestureDetector::AddPanningGestureEventListener(ITouchPanningGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchGestureDetectorImpl->AddGestureEventListener(listener); +} + +result +TouchPanningGestureDetector::RemovePanningGestureEventListener(ITouchPanningGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchGestureDetectorImpl->RemoveGestureEventListener(listener); +} + +IList* +TouchPanningGestureDetector::GetTouchInfoListN(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchPanningGestureDetectorImpl* pTouchPanningGestureDetectorImpl = _TouchPanningGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchPanningGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchPanningGestureDetectorImpl->GetTouchInfoListN(); +} + +result +TouchPanningGestureDetector::SetTouchCount(int count) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + _TouchPanningGestureDetectorImpl* pTouchPanningGestureDetectorImpl = _TouchPanningGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchPanningGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchPanningGestureDetectorImpl->SetTouchCount(count); +} + +int +TouchPanningGestureDetector::GetTouchCount(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchPanningGestureDetectorImpl* pTouchPanningGestureDetectorImpl = _TouchPanningGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchPanningGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchPanningGestureDetectorImpl->GetTouchCount(); +} + +}} //Tizen::Ui diff --git a/src/ui/FUiTouchPinchGestureDetector.cpp b/src/ui/FUiTouchPinchGestureDetector.cpp new file mode 100644 index 0000000..27fc4d2 --- /dev/null +++ b/src/ui/FUiTouchPinchGestureDetector.cpp @@ -0,0 +1,92 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiTouchPinchGestureDetector.cpp + * @brief This is the implementation file for %TouchPinchGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %TouchPinchGestureDetector class. + * + */ + +#include +#include +#include "FUi_TouchPinchGestureDetectorImpl.h" + +namespace Tizen { namespace Ui +{ +TouchPinchGestureDetector::TouchPinchGestureDetector(void) +{ +} + +TouchPinchGestureDetector::~TouchPinchGestureDetector(void) +{ +} + +result +TouchPinchGestureDetector::Construct(void) +{ + SysAssertf(__pTouchGestureDetectorImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _TouchGestureDetectorImpl* pImpl = _TouchPinchGestureDetectorImpl::CreateInstanceN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTouchGestureDetectorImpl = pImpl; + + return E_SUCCESS; +} + +result +TouchPinchGestureDetector::AddPinchGestureEventListener(ITouchPinchGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchGestureDetectorImpl->AddGestureEventListener(listener); +} + +result +TouchPinchGestureDetector::RemovePinchGestureEventListener(ITouchPinchGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchGestureDetectorImpl->RemoveGestureEventListener(listener); +} + +Tizen::Graphics::Point +TouchPinchGestureDetector::GetCenterPoint(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchPinchGestureDetectorImpl* pTouchPinchGestureDetectorImpl = _TouchPinchGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchPinchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchPinchGestureDetectorImpl->GetCenterPoint(); +} + +int +TouchPinchGestureDetector::GetScale(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchPinchGestureDetectorImpl* pTouchPinchGestureDetectorImpl = _TouchPinchGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchPinchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchPinchGestureDetectorImpl->GetScale(); +} + +} } //Tizen::Ui diff --git a/src/ui/FUiTouchRotationGestureDetector.cpp b/src/ui/FUiTouchRotationGestureDetector.cpp new file mode 100644 index 0000000..992b8bf --- /dev/null +++ b/src/ui/FUiTouchRotationGestureDetector.cpp @@ -0,0 +1,98 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiTouchRotationGestureDetector.cpp + * @brief This is the implementation file for %TouchRotationGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %TouchRotationGestureDetector class. + * + */ + +#include +#include +#include "FUi_TouchRotationGestureDetectorImpl.h" + +namespace Tizen { namespace Ui +{ +TouchRotationGestureDetector::TouchRotationGestureDetector(void) +{ +} + +TouchRotationGestureDetector::~TouchRotationGestureDetector(void) +{ +} + +result +TouchRotationGestureDetector::Construct(void) +{ + SysAssertf(__pTouchGestureDetectorImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _TouchGestureDetectorImpl* pImpl = _TouchRotationGestureDetectorImpl::CreateInstanceN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTouchGestureDetectorImpl = pImpl; + + return E_SUCCESS; +} + +result +TouchRotationGestureDetector::AddRotationGestureEventListener(ITouchRotationGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + result r = __pTouchGestureDetectorImpl->AddGestureEventListener(listener); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +TouchRotationGestureDetector::RemoveRotationGestureEventListener(ITouchRotationGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + result r = __pTouchGestureDetectorImpl->RemoveGestureEventListener(listener); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +float +TouchRotationGestureDetector::GetAngle(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchRotationGestureDetectorImpl* pRotationGestureDetectorImpl = _TouchRotationGestureDetectorImpl::GetInstance(*this); + SysAssertf(pRotationGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pRotationGestureDetectorImpl->GetAngle(); +} + +int +TouchRotationGestureDetector::GetDistance(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchRotationGestureDetectorImpl* pRotationGestureDetectorImpl = _TouchRotationGestureDetectorImpl::GetInstance(*this); + SysAssertf(pRotationGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pRotationGestureDetectorImpl->GetDistance(); +} + +}} //Tizen::Ui diff --git a/src/ui/FUiTouchTapGestureDetector.cpp b/src/ui/FUiTouchTapGestureDetector.cpp new file mode 100644 index 0000000..c2a30d4 --- /dev/null +++ b/src/ui/FUiTouchTapGestureDetector.cpp @@ -0,0 +1,158 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiTouchTapGestureDetector.cpp + * @brief This is the implementation file for %TouchTapGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %TouchTapGestureDetector class. + * + */ + +#include +#include +#include "FUi_TouchTapGestureDetectorImpl.h" + +namespace Tizen { namespace Ui +{ +TouchTapGestureDetector::TouchTapGestureDetector(void) +{ +} + +TouchTapGestureDetector::~TouchTapGestureDetector(void) +{ +} + +result +TouchTapGestureDetector::Construct(void) +{ + SysAssertf(__pTouchGestureDetectorImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _TouchGestureDetectorImpl* pImpl = _TouchTapGestureDetectorImpl::CreateInstanceN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTouchGestureDetectorImpl = pImpl; + + return E_SUCCESS; +} + +result +TouchTapGestureDetector::AddTapGestureEventListener(ITouchTapGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchGestureDetectorImpl->AddGestureEventListener(listener); +} + +result +TouchTapGestureDetector::RemoveTapGestureEventListener(ITouchTapGestureEventListener& listener) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return __pTouchGestureDetectorImpl->RemoveGestureEventListener(listener); +} + +result +TouchTapGestureDetector::SetTapCount(int count) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + _TouchTapGestureDetectorImpl* pTouchTapGestureDetectorImpl = _TouchTapGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchTapGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchTapGestureDetectorImpl->SetTapCount(count); +} + +int +TouchTapGestureDetector::GetTapCount(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchTapGestureDetectorImpl* pTouchTapGestureDetectorImpl = _TouchTapGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchTapGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchTapGestureDetectorImpl->GetTapCount(); +} + +result +TouchTapGestureDetector::SetTapInterval(int intarval) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + _TouchTapGestureDetectorImpl* pTouchTapGestureDetectorImpl = _TouchTapGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchTapGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchTapGestureDetectorImpl->SetTapInterval(intarval); +} + +int +TouchTapGestureDetector::GetTapInterval(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchTapGestureDetectorImpl* pTouchTapGestureDetectorImpl = _TouchTapGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchTapGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchTapGestureDetectorImpl->GetTapInterval(); +} + +result +TouchTapGestureDetector::SetMoveAllowance(int allowance) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + _TouchTapGestureDetectorImpl* pTouchTapGestureDetectorImpl = _TouchTapGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchTapGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchTapGestureDetectorImpl->SetMoveAllowance(allowance); +} + +int +TouchTapGestureDetector::GetMoveAllowance(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchTapGestureDetectorImpl* pTouchTapGestureDetectorImpl = _TouchTapGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchTapGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchTapGestureDetectorImpl->GetMoveAllowance(); +} + +result +TouchTapGestureDetector::SetTouchCount(int count) +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + _TouchTapGestureDetectorImpl* pTouchTapGestureDetectorImpl = _TouchTapGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchTapGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchTapGestureDetectorImpl->SetTouchCount(count); +} + +int +TouchTapGestureDetector::GetTouchCount(void) const +{ + SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + const _TouchTapGestureDetectorImpl* pTouchTapGestureDetectorImpl = _TouchTapGestureDetectorImpl::GetInstance(*this); + SysAssertf(pTouchTapGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used."); + + return pTouchTapGestureDetectorImpl->GetTouchCount(); +} + +}} //Tizen::Ui diff --git a/src/ui/FUiUiConfiguration.cpp b/src/ui/FUiUiConfiguration.cpp new file mode 100644 index 0000000..66eb130 --- /dev/null +++ b/src/ui/FUiUiConfiguration.cpp @@ -0,0 +1,56 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiUiConfiguration.cpp + * @brief This is the implementation file for the UiConfiguration class. + */ + +#include +#include +#include +#include "FUi_ControlManager.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { + +UiConfiguration::UiConfiguration(void) +{ +} + +UiConfiguration::~UiConfiguration(void) +{ + +} + +String +UiConfiguration::GetDefaultFont(void) +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + return pControlManager->GetDefaultFont(); +} + +result +UiConfiguration::SetDefaultFont(const String& fontName) +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + result r = pControlManager->SetDefaultFont(fontName); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return E_SUCCESS; +} + +}} // Tizen::Ui diff --git a/src/ui/FUiVariant.cpp b/src/ui/FUiVariant.cpp new file mode 100644 index 0000000..74e3a9c --- /dev/null +++ b/src/ui/FUiVariant.cpp @@ -0,0 +1,1385 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiVariant.cpp + * @brief This is the implementation file for Variant class. + */ + +// Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_VariantImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +const Variant Variant::NULL_VARIANT; + +Variant::Variant(void) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } +} + +Variant::~Variant(void) +{ + if (__pVariantImpl) + { + __pVariantImpl->Release(); + } + + __pVariantImpl = null; +} + +Variant::Variant(const Variant& value) + : __pVariantImpl(null) +{ + SysAssertf(value.__pVariantImpl, "No data in rhs for copy ctor"); + __pVariantImpl = value.__pVariantImpl; + __pVariantImpl->AddRef(); +} + +Variant::Variant(int value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_INT; + __pVariantImpl->__data.valueInt = 0; + __pVariantImpl->__data.valueInt = value; + } +} + +Variant::Variant(unsigned int value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_UINT; + __pVariantImpl->__data.valueUInt = 0; + __pVariantImpl->__data.valueUInt = value; + } +} + +Variant::Variant(bool value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_BOOL; + __pVariantImpl->__data.valueBool = true; + __pVariantImpl->__data.valueBool = value; + } +} + +Variant::Variant(float value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_FLOAT; + __pVariantImpl->__data.valueFloat = 0; + __pVariantImpl->__data.valueFloat = value; + } +} + +Variant::Variant(double value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_DOUBLE; + __pVariantImpl->__data.valueDouble = 0; + __pVariantImpl->__data.valueDouble = value; + } +} + +Variant::Variant(long value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_LONG; + __pVariantImpl->__data.valueLong = 0; + __pVariantImpl->__data.valueLong = value; + } +} + +Variant::Variant(unsigned long value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_ULONG; + __pVariantImpl->__data.valueULong = 0; + __pVariantImpl->__data.valueULong = value; + } +} + +Variant::Variant(long long value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_LONGLONG; + __pVariantImpl->__data.valueLongLong = 0; + __pVariantImpl->__data.valueLongLong = value; + } +} + +Variant::Variant(unsigned long long value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_ULONGLONG; + __pVariantImpl->__data.valueULongLong = 0; + __pVariantImpl->__data.valueULongLong = value; + } +} + +Variant::Variant(const char* pValue) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_STRING; + __pVariantImpl->__data.pString = null; + __pVariantImpl->__data.pString = new (std::nothrow) String(pValue); + } +} + +Variant::Variant(const wchar_t* pValue) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_STRING; + __pVariantImpl->__data.pString = null; + __pVariantImpl->__data.pString = new (std::nothrow) String(pValue); + } +} + +Variant::Variant(const String& value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_STRING; + __pVariantImpl->__data.pString = null; + __pVariantImpl->__data.pString = new (std::nothrow) String(value); + } +} + +Variant::Variant(const DateTime& value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_DATETIME; + __pVariantImpl->__data.pDateTime = null; + __pVariantImpl->__data.pDateTime = new (std::nothrow) DateTime(value); + } +} + +Variant::Variant(const Color& value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_COLOR; + __pVariantImpl->__data.pColor = null; + __pVariantImpl->__data.pColor = new (std::nothrow) Color(value); + } +} + +Variant::Variant(const Point& value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_POINT; + __pVariantImpl->__data.pPoint = null; + __pVariantImpl->__data.pPoint = new (std::nothrow) Point(value); + } +} + +Variant::Variant(const FloatPoint& value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_FLOAT_POINT; + __pVariantImpl->__data.pFloatPoint = null; + __pVariantImpl->__data.pFloatPoint = new (std::nothrow) FloatPoint(value); + } +} + +Variant::Variant(const Rectangle& value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_RECTANGLE; + __pVariantImpl->__data.pRect = null; + __pVariantImpl->__data.pRect = new (std::nothrow) Rectangle(value); + } +} + +Variant::Variant(const FloatRectangle& value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_FLOAT_RECTANGLE; + __pVariantImpl->__data.pRectf = null; + __pVariantImpl->__data.pRectf = new (std::nothrow) FloatRectangle(value); + } +} + +Variant::Variant(const Dimension& value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_DIMENSION; + __pVariantImpl->__data.pDimension = null; + __pVariantImpl->__data.pDimension = new (std::nothrow) Dimension(value); + } +} + +Variant::Variant(const FloatDimension& value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_FLOAT_DIMENSION; + __pVariantImpl->__data.pFloatDimension = null; + __pVariantImpl->__data.pFloatDimension = new (std::nothrow) FloatDimension(value); + } +} + +Variant::Variant(const FloatMatrix4& value) + : __pVariantImpl(null) +{ + __pVariantImpl = new (std::nothrow) _VariantImpl; + if (__pVariantImpl == null) + { + SysLogException(NID_UI, E_SYSTEM, "[E_OUT_OF_MEMORY] pImpl is null."); + } + else + { + __pVariantImpl->__type = VARIANT_TYPE_FLOAT_MATRIX4; + __pVariantImpl->__data.pFloatMatrix4 = null; + __pVariantImpl->__data.pFloatMatrix4 = new (std::nothrow) FloatMatrix4(value); + } +} + +// Assignment Operators +Variant& +Variant::operator =(const Variant& rhs) +{ + if (&rhs != this) + { + if (__pVariantImpl && rhs.__pVariantImpl && __pVariantImpl != rhs.__pVariantImpl) + { + __pVariantImpl->Release(); + __pVariantImpl = rhs.__pVariantImpl; + __pVariantImpl->AddRef(); + } + } + return (*this); +} + +#define CREATE_VARIANT_IMPL(type, member, value) \ + do { \ + if (!__pVariantImpl || __pVariantImpl->__type != type) \ + { \ + _VariantImpl* pImpl = new (std::nothrow) _VariantImpl; \ + if (likely(pImpl)) \ + { \ + pImpl->__type = type; \ + pImpl->__data.member = value; \ + delete __pVariantImpl; \ + __pVariantImpl = pImpl; \ + } \ + } \ + else \ + { \ + /* __pVariantImpl != null && __pVariantImpl->__type == type */ \ + __pVariantImpl->__data.member = value; \ + } \ + } while (0); + +Variant& +Variant::operator =(int rhs) +{ + CREATE_VARIANT_IMPL(VARIANT_TYPE_INT, valueInt, rhs); + + return (*this); +} + +Variant& +Variant::operator =(unsigned int rhs) +{ + CREATE_VARIANT_IMPL(VARIANT_TYPE_UINT, valueUInt, rhs); + + return (*this); +} + +Variant& +Variant::operator =(bool rhs) +{ + CREATE_VARIANT_IMPL(VARIANT_TYPE_BOOL, valueBool, rhs); + + return (*this); +} + +Variant& +Variant::operator =(float rhs) +{ + CREATE_VARIANT_IMPL(VARIANT_TYPE_FLOAT, valueFloat, rhs); + + return (*this); +} + +Variant& +Variant::operator =(double rhs) +{ + CREATE_VARIANT_IMPL(VARIANT_TYPE_DOUBLE, valueDouble, rhs); + + return (*this); +} + +Variant& +Variant::operator =(long rhs) +{ + CREATE_VARIANT_IMPL(VARIANT_TYPE_LONG, valueLong, rhs); + + return (*this); +} + +Variant& +Variant::operator =(unsigned long rhs) +{ + CREATE_VARIANT_IMPL(VARIANT_TYPE_ULONG, valueULong, rhs); + + return (*this); +} + +Variant& +Variant::operator =(long long rhs) +{ + CREATE_VARIANT_IMPL(VARIANT_TYPE_LONGLONG, valueLongLong, rhs); + + return (*this); +} + +Variant& +Variant::operator =(unsigned long long rhs) +{ + CREATE_VARIANT_IMPL(VARIANT_TYPE_ULONGLONG, valueLongLong, rhs); + + return (*this); +} + +Variant& +Variant::operator =(const char* pRhs) +{ + String* pString = new (std::nothrow) String(pRhs); + CREATE_VARIANT_IMPL(VARIANT_TYPE_STRING, pString, pString); + + return (*this); +} + +Variant& +Variant::operator =(const wchar_t* pRhs) +{ + String* pString = new (std::nothrow) String(pRhs); + CREATE_VARIANT_IMPL(VARIANT_TYPE_STRING, pString, pString); + + return (*this); +} + +Variant& +Variant::operator =(const String& rhs) +{ + String* pString = new (std::nothrow) String(rhs); + CREATE_VARIANT_IMPL(VARIANT_TYPE_STRING, pString, pString); + + return (*this); +} + +Variant& +Variant::operator =(const DateTime& rhs) +{ + DateTime* pDateTime = new (std::nothrow) DateTime(rhs); + CREATE_VARIANT_IMPL(VARIANT_TYPE_DATETIME, pDateTime, pDateTime); + + return (*this); +} + +Variant& +Variant::operator =(const Color& rhs) +{ + Color* pColor = new (std::nothrow) Color(rhs); + CREATE_VARIANT_IMPL(VARIANT_TYPE_COLOR, pColor, pColor); + + return (*this); +} + +Variant& +Variant::operator =(const Point& rhs) +{ + Point* pPoint = new (std::nothrow) Point(rhs); + CREATE_VARIANT_IMPL(VARIANT_TYPE_POINT, pPoint, pPoint); + + return (*this); +} + +Variant& +Variant::operator =(const FloatPoint& rhs) +{ + + FloatPoint* pFloatPoint = new (std::nothrow) FloatPoint(rhs); + CREATE_VARIANT_IMPL(VARIANT_TYPE_FLOAT_POINT, pFloatPoint, pFloatPoint); + + return (*this); +} + +Variant& +Variant::operator =(const Rectangle& rhs) +{ + Rectangle* pRectangle = new (std::nothrow) Rectangle(rhs); + CREATE_VARIANT_IMPL(VARIANT_TYPE_RECTANGLE, pRect, pRectangle); + + return (*this); +} + +Variant& +Variant::operator =(const FloatRectangle& rhs) +{ + FloatRectangle* pFloatRectangle = new (std::nothrow) FloatRectangle(rhs); + CREATE_VARIANT_IMPL(VARIANT_TYPE_FLOAT_RECTANGLE, pRectf, pFloatRectangle); + + return (*this); +} + +Variant& +Variant::operator =(const Dimension& rhs) +{ + + Dimension* pDimension = new (std::nothrow) Dimension(rhs); + CREATE_VARIANT_IMPL(VARIANT_TYPE_DIMENSION, pDimension, pDimension); + + return (*this); +} + +Variant& +Variant::operator =(const FloatDimension& rhs) +{ + FloatDimension* pFloatDimension = new (std::nothrow) FloatDimension(rhs); + CREATE_VARIANT_IMPL(VARIANT_TYPE_FLOAT_DIMENSION, pFloatDimension, pFloatDimension); + + return (*this); +} + +Variant& +Variant::operator =(const FloatMatrix4& rhs) +{ + FloatMatrix4* pFloatMatrix4 = new (std::nothrow) FloatMatrix4(rhs); + CREATE_VARIANT_IMPL(VARIANT_TYPE_FLOAT_MATRIX4, pFloatMatrix4, pFloatMatrix4); + + return (*this); +} + +bool +operator ==(const Variant& lhs, const Variant& rhs) +{ + const _VariantImpl* pLhsImpl = lhs.GetVariantImpl(); + const _VariantImpl* pRhsImpl = rhs.GetVariantImpl(); + + if (pLhsImpl == null || pRhsImpl == null) + { + return false; + } + + if (pLhsImpl == pRhsImpl) + { + return true; + } + + if (pLhsImpl->__type != pRhsImpl->__type) + { + return false; + } + + switch (pLhsImpl->__type) + { + case VARIANT_TYPE_INT: + return pLhsImpl->__data.valueInt == pRhsImpl->__data.valueInt; + + case VARIANT_TYPE_UINT: + return pLhsImpl->__data.valueUInt == pRhsImpl->__data.valueUInt; + + case VARIANT_TYPE_BOOL: + return pLhsImpl->__data.valueBool == pRhsImpl->__data.valueBool; + + case VARIANT_TYPE_FLOAT: + return pLhsImpl->__data.valueFloat == pRhsImpl->__data.valueFloat; + + case VARIANT_TYPE_DOUBLE: + return pLhsImpl->__data.valueDouble == pRhsImpl->__data.valueDouble; + + case VARIANT_TYPE_LONG: + return pLhsImpl->__data.valueLong == pRhsImpl->__data.valueLong; + + case VARIANT_TYPE_ULONG: + return pLhsImpl->__data.valueULong == pRhsImpl->__data.valueULong; + + case VARIANT_TYPE_LONGLONG: + return pLhsImpl->__data.valueLongLong == pRhsImpl->__data.valueLongLong; + + case VARIANT_TYPE_ULONGLONG: + return pLhsImpl->__data.valueULongLong == pRhsImpl->__data.valueULongLong; + + case VARIANT_TYPE_STRING: + { + if (pLhsImpl->__data.pString) + { + return (*pLhsImpl->__data.pString == *pRhsImpl->__data.pString); + } + else + { + return false; + } + } + + case VARIANT_TYPE_DATETIME: + { + if (pLhsImpl->__data.pDateTime) + { + return *pLhsImpl->__data.pDateTime == *pRhsImpl->__data.pDateTime; + } + else + { + return false; + } + } + + case VARIANT_TYPE_COLOR: + { + if (pLhsImpl->__data.pColor) + { + return *pLhsImpl->__data.pColor == *pRhsImpl->__data.pColor; + } + else + { + return false; + } + } + + case VARIANT_TYPE_POINT: + { + if (pLhsImpl->__data.pPoint) + { + return *pLhsImpl->__data.pPoint == *pRhsImpl->__data.pPoint; + } + else + { + return false; + } + } + + case VARIANT_TYPE_FLOAT_POINT: + { + if (pLhsImpl->__data.pFloatPoint) + { + return *pLhsImpl->__data.pFloatPoint == *pRhsImpl->__data.pFloatPoint; + } + else + { + return false; + } + } + + case VARIANT_TYPE_RECTANGLE: + { + if (pLhsImpl->__data.pRect) + { + return *pLhsImpl->__data.pRect == *pRhsImpl->__data.pRect; + } + else + { + return false; + } + } + + case VARIANT_TYPE_FLOAT_RECTANGLE: + { + if (pLhsImpl->__data.pRectf) + { + return *pLhsImpl->__data.pRectf == *pRhsImpl->__data.pRectf; + } + else + { + return false; + } + } + + case VARIANT_TYPE_DIMENSION: + { + if (pLhsImpl->__data.pDimension) + { + return *pLhsImpl->__data.pDimension == *pRhsImpl->__data.pDimension; + } + else + { + return false; + } + } + + case VARIANT_TYPE_FLOAT_DIMENSION: + { + if (pLhsImpl->__data.pFloatDimension) + { + return *pLhsImpl->__data.pFloatDimension == *pRhsImpl->__data.pFloatDimension; + } + else + { + return false; + } + } + + case VARIANT_TYPE_FLOAT_MATRIX4: + { + if (pLhsImpl->__data.pFloatMatrix4) + { + return *pLhsImpl->__data.pFloatMatrix4 == *pRhsImpl->__data.pFloatMatrix4; + } + else + { + return false; + } + } + + case VARIANT_TYPE_NONE: + return pLhsImpl->__type == pRhsImpl->__type; + + default: + return false; + } + + return false; +} + +bool +operator !=(const Variant& lhs, const Variant& rhs) +{ + return !(lhs == rhs); +} + +int +Variant::ToInt(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_INT)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_INT."); + } + else + { + return pImpl->__data.valueInt; + } + } + + return 0; +} + +unsigned int +Variant::ToUInt(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_UINT)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_UINT."); + } + else + { + return pImpl->__data.valueUInt; + } + } + return 0; +} + +bool +Variant::ToBool(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_BOOL)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_BOOL."); + } + else + { + return pImpl->__data.valueBool; + } + } + + return false; +} + +float +Variant::ToFloat(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_FLOAT)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_FLOAT."); + } + else + { + return pImpl->__data.valueFloat; + } + } + + return 0; +} + +double +Variant::ToDouble(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_DOUBLE)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_DOUBLE."); + } + else + { + return pImpl->__data.valueDouble; + } + } + + return 0; +} + +long +Variant::ToLong(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_LONG)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_LONG."); + } + else + { + return pImpl->__data.valueLong; + } + } + + return 0; +} + +unsigned long +Variant::ToULong(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_ULONG)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_ULONG."); + } + else + { + return pImpl->__data.valueULong; + } + } + + return 0; +} + +long long +Variant::ToLongLong(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_LONGLONG)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_LONGLONG."); + } + else + { + return pImpl->__data.valueLongLong; + } + } + + return 0; +} + +unsigned long long +Variant::ToULongLong(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_ULONGLONG)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_ULONGLONG."); + } + else + { + return pImpl->__data.valueULongLong; + } + } + + return 0; +} + +String +Variant::ToString(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_STRING)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_STRING."); + } + else + { + return *pImpl->__data.pString; + } + } + + return String(""); +} + +DateTime +Variant::ToDateTime(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_DATETIME)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_DATETIME."); + } + else + { + return *pImpl->__data.pDateTime; + } + } + + return DateTime(); +} + +Color +Variant::ToColor(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_COLOR)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_COLOR."); + } + else + { + return *pImpl->__data.pColor; + } + } + + return Color(); +} + +Point +Variant::ToPoint(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_POINT)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_POINT."); + } + else + { + return *pImpl->__data.pPoint; + } + } + + return Point(); +} + +FloatPoint +Variant::ToFloatPoint(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_FLOAT_POINT)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_FLOATPOINT."); + } + else + { + return *pImpl->__data.pFloatPoint; + } + } + + return FloatPoint(); +} + +Rectangle +Variant::ToRectangle(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_RECTANGLE)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_RECTANGLE."); + } + else + { + return *pImpl->__data.pRect; + } + } + + return Rectangle(); +} + +FloatRectangle +Variant::ToFloatRectangle(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_FLOAT_RECTANGLE)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_FLOAT_RECTANGLE."); + } + else + { + return *pImpl->__data.pRectf; + } + } + + return FloatRectangle(); +} + +Dimension +Variant::ToDimension(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_DIMENSION)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_DIMENSION."); + } + else + { + return *pImpl->__data.pDimension; + } + } + + return Dimension(); +} + +FloatDimension +Variant::ToFloatDimension(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_FLOAT_DIMENSION)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_FLOAT_DIMENSION."); + } + else + { + return *pImpl->__data.pFloatDimension; + } + } + + return FloatDimension(); +} + +FloatMatrix4 +Variant::ToFloatMatrix4(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + if (!pImpl->IsSameType(VARIANT_TYPE_FLOAT_MATRIX4)) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current variant type is not VARIANT_TYPE_FLOAT_MATRIX4."); + } + else + { + return *pImpl->__data.pFloatMatrix4; + } + } + + return FloatMatrix4(); +} + +bool +Variant::IsEmpty(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + return pImpl->__type == VARIANT_TYPE_NONE; + } + + return false; +} + +VariantType +Variant::GetType() const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + if (pImpl) + { + return pImpl->__type; + } + + return VARIANT_TYPE_NONE; +} + +bool +Variant::Equals(const Object& obj) const +{ + const Variant* pOther = dynamic_cast (&obj); + if (pOther == null) + { + return (false); + } + + return (*this == *pOther); +} + +int +Variant::GetHashCode(void) const +{ + const _VariantImpl* pImpl = GetVariantImpl(); + + switch (pImpl->__type) + { + case VARIANT_TYPE_INT: + return (int) pImpl->__data.valueInt; + + case VARIANT_TYPE_UINT: + return (int) pImpl->__data.valueUInt; + + case VARIANT_TYPE_BOOL: + return (int) pImpl->__data.valueBool; + + case VARIANT_TYPE_FLOAT: + return (int) pImpl->__data.valueFloat; + + case VARIANT_TYPE_DOUBLE: + return (int) pImpl->__data.valueDouble; + + case VARIANT_TYPE_LONG: + return (int) pImpl->__data.valueLong; + + case VARIANT_TYPE_ULONG: + return (int) pImpl->__data.valueULong; + + case VARIANT_TYPE_LONGLONG: + return (int) pImpl->__data.valueLongLong; + + case VARIANT_TYPE_ULONGLONG: + return (int) pImpl->__data.valueULongLong; + + case VARIANT_TYPE_STRING: + { + if (pImpl->__data.pString) + { + return pImpl->__data.pString->GetHashCode(); + } + else + { + break; + } + } + + case VARIANT_TYPE_DATETIME: + { + if (pImpl->__data.pDateTime) + { + return (pImpl->__data.pDateTime)->GetHashCode(); + } + else + { + break; + } + } + + case VARIANT_TYPE_COLOR: + { + if (pImpl->__data.pPoint) + { + return (pImpl->__data.pColor)->GetHashCode(); + } + else + { + break; + } + } + + case VARIANT_TYPE_POINT: + { + if (pImpl->__data.pPoint) + { + return (pImpl->__data.pPoint)->GetHashCode(); + } + else + { + break; + } + } + + case VARIANT_TYPE_FLOAT_POINT: + { + if (pImpl->__data.pFloatPoint) + { + return (pImpl->__data.pFloatPoint)->GetHashCode(); + } + else + { + break; + } + } + + case VARIANT_TYPE_RECTANGLE: + { + if (pImpl->__data.pRect) + { + return (pImpl->__data.pRect)->GetHashCode(); + } + else + { + break; + } + } + + case VARIANT_TYPE_FLOAT_RECTANGLE: + { + if (pImpl->__data.pRectf) + { + return (pImpl->__data.pRectf)->GetHashCode(); + } + else + { + break; + } + } + + case VARIANT_TYPE_DIMENSION: + { + if (pImpl->__data.pDimension) + { + return (pImpl->__data.pDimension)->GetHashCode(); + } + else + { + break; + } + } + + case VARIANT_TYPE_FLOAT_DIMENSION: + { + if (pImpl->__data.pFloatDimension) + { + return (pImpl->__data.pFloatDimension)->GetHashCode(); + } + else + { + break; + } + } + + case VARIANT_TYPE_FLOAT_MATRIX4: + { + if (pImpl->__data.pFloatMatrix4) + { + return (pImpl->__data.pFloatMatrix4)->GetHashCode(); + } + else + { + break; + } + } + + case VARIANT_TYPE_NONE: + default: + break; + } + + return 0; +} + +const _VariantImpl* +Variant::GetVariantImpl(void) const +{ + return static_cast (__pVariantImpl); +} + +_VariantImpl* +Variant::GetVariantImpl(void) +{ + return __pVariantImpl; +} + +} } //Tizen::Ui diff --git a/src/ui/FUiVerticalBoxLayout.cpp b/src/ui/FUiVerticalBoxLayout.cpp new file mode 100644 index 0000000..67bcf90 --- /dev/null +++ b/src/ui/FUiVerticalBoxLayout.cpp @@ -0,0 +1,231 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiVerticalBoxLayout.cpp + * @brief This is the implementation file for VerticalBoxLayout class. + * + * This file contains the implementation of VerticalBoxLayout class. + */ + +#include +#include +#include +#include "FUi_VerticalBoxLayoutImpl.h" + +namespace Tizen { namespace Ui +{ + +VerticalBoxLayout::VerticalBoxLayout() +{ +} + +VerticalBoxLayout::~VerticalBoxLayout() +{ +} + +result +VerticalBoxLayout::Construct(VerticalDirection direction) +{ + ClearLastResult(); + + _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pVerticalBoxLayoutImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::CreateVerticalBoxLayoutImplN(this, direction); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _LayoutImpl::SetLayoutImpl(this, pVerticalBoxLayoutImpl); + + return E_SUCCESS; +} + +Tizen::Ui::LayoutType +VerticalBoxLayout::GetLayoutType(void) const +{ + return LAYOUT_VERTICAL_BOX; +} + +result +VerticalBoxLayout::GetDirection(VerticalDirection& direction) const +{ + ClearLastResult(); + + const _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pVerticalBoxLayoutImpl->GetDirection(direction); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +VerticalBoxLayout::SetHorizontalAlignment(Control& childControl, LayoutHorizontalAlignment alignment) +{ + ClearLastResult(); + + _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pVerticalBoxLayoutImpl->SetHorizontalAlignment(*pControlImpl, alignment); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +VerticalBoxLayout::SetSpacing(Control& childControl, int space) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, space >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pVerticalBoxLayoutImpl->SetSpacing(*pControlImpl, space); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +VerticalBoxLayout::SetHorizontalMargin(Control& childControl, int left, int right) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, (left >= 0) && (right >= 0), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pVerticalBoxLayoutImpl->SetHorizontalMargin(*pControlImpl, left, right); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +VerticalBoxLayout::SetWidth(Control& childControl, int width) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, width >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pVerticalBoxLayoutImpl->SetWidth(*pControlImpl, width); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +VerticalBoxLayout::SetHorizontalFitPolicy(Control& childControl, FitPolicy policy) +{ + ClearLastResult(); + + _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pVerticalBoxLayoutImpl->SetItemHorizontalFitPolicy(*pControlImpl, policy); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +VerticalBoxLayout::SetHeight(Control& childControl, int height) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, height >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + result r = pVerticalBoxLayoutImpl->SetHeight(*pControlImpl, height); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +VerticalBoxLayout::SetVerticalFitPolicy(Control& childControl, FitPolicy policy) +{ + ClearLastResult(); + + _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + if (!Tizen::App::_AppInfo::IsOspCompat()) + { + if (policy == FIT_POLICY_PARENT) + { + return E_SUCCESS; + } + } + + result r = pVerticalBoxLayoutImpl->SetItemVerticalFitPolicy(*pControlImpl, policy); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +VerticalBoxLayout::SetWeight(Control& childControl, float weight) +{ + ClearLastResult(); + + _VerticalBoxLayoutImpl* pVerticalBoxLayoutImpl = _VerticalBoxLayoutImpl::GetInstance(*this); + SysAssertf(pVerticalBoxLayoutImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(childControl); + SysTryReturn(NID_UI, pControlImpl, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This instance is not constructed."); + + SysTryReturn(NID_UI, weight >= 0.0f, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid.\n") + + result r = pVerticalBoxLayoutImpl->SetWeight(*pControlImpl, weight); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +}} // Tizen::Ui diff --git a/src/ui/FUiWindow.cpp b/src/ui/FUiWindow.cpp new file mode 100644 index 0000000..5475836 --- /dev/null +++ b/src/ui/FUiWindow.cpp @@ -0,0 +1,156 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiWindow.cpp + * @brief This is the implementation file for Window class. + */ + +#include +#include +#include +#include +#include "FUi_WindowImpl.h" +#include "FUi_ErrorMessages.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Security; + +namespace Tizen { namespace Ui { + +Window::Window() +{ +} + +Window::~Window(void) +{ +} + +result +Window::Construct(const Rectangle& rect, bool resizable, bool movable) +{ + result r = E_SUCCESS; + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + _WindowImpl* pImpl = _WindowImpl::CreateWindowImplN(this, rect, null, null, resizable, movable); + r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return E_SUCCESS; +} + +result +Window::Construct(const Layout& layout, const Rectangle& rect, bool resizable, bool movable) +{ + return Construct(layout, layout, rect, resizable, movable); +} + +result +Window::Construct(const Layout& portraitLayout, const Layout& landscapeLayout, + const Rectangle& rect, bool resizable, bool movable) +{ + result r = E_SUCCESS; + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _WindowImpl* pImpl = + _WindowImpl::CreateWindowImplN(this, rect, &portraitLayout, &landscapeLayout, resizable, movable); + + r = GetLastResult(); + SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + + _pControlImpl = pImpl; + + return E_SUCCESS; +} + +result +Window::Show(void) +{ + result r = E_SUCCESS; + + _WindowImpl* pImpl = _WindowImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + r = pImpl->Open(); + + return r; +} + +WindowState +Window::GetWindowState(void) const +{ + const _WindowImpl* pImpl = _WindowImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetWindowState(); +} + +DisplayContext* +Window::GetDisplayContext(void) const +{ + const _WindowImpl* pImpl = _WindowImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetDisplayContext(); +} + +result +Window::SetZOrderGroup(WindowZOrderGroup windowZOrderGroup) +{ + result r = _AccessController::CheckUserPrivilege(_PRV_UIMANAGER); + SysTryReturnResult(NID_LOC, r == E_SUCCESS, E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method."); + + _WindowImpl* pImpl = _WindowImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetZOrderGroup(windowZOrderGroup); +} + +void +Window::SetOwner(Tizen::Ui::Control *pControl) +{ + _WindowImpl* pImpl = _WindowImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetOwner(pControl); +} + +void +Window::AddWindowEventListener(IWindowEventListener& listener) +{ + _WindowImpl* pImpl = _WindowImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddWindowEventListener(listener); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Window::RemoveWindowEventListener(IWindowEventListener& listener) +{ + _WindowImpl* pImpl = _WindowImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveWindowEventListener(listener); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_AccessibilityContainer.cpp b/src/ui/FUi_AccessibilityContainer.cpp new file mode 100644 index 0000000..86b3d2c --- /dev/null +++ b/src/ui/FUi_AccessibilityContainer.cpp @@ -0,0 +1,654 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include "FUi_Control.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityElementImpl.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityManager.h" +#include "FUi_IAccessibilityListener.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +template +class _AccessibilityItemComparer + : public Tizen::Base::Collection::IComparerT +{ +public: + _AccessibilityItemComparer(void) + { + } + virtual ~_AccessibilityItemComparer(void) + { + } + virtual result Compare(const T& obj1, const T& obj2, int& cmp) const + { + Tizen::Graphics::Rectangle rect1= obj1->GetAbsoluteBounds(); + Tizen::Graphics::Rectangle rect2= obj2->GetAbsoluteBounds(); + + if(rect1.y > rect2.y) + { + cmp = 1; + return E_SUCCESS; + } + else if(rect1.y < rect2.y) + { + cmp = -1; + return E_SUCCESS; + } + else + { + if(rect1.x > rect2.x) + { + cmp = 1; + return E_SUCCESS; + } + else if(rect1.x < rect2.x) + { + cmp = -1; + return E_SUCCESS; + } + else + { + cmp = 0; + return E_SUCCESS; + } + } + } +}; //class _AccessibilityComparer + +_AccessibilityContainer::_AccessibilityContainer(const _Control& owner) + : __pOwner(null) + , __pParent(null) + , __currentElementIndex(-1) + , __level(ACCESSIBILITY_PRIORTY_NORMAL) + , __activated(false) + , __pListener(null) + , __enableState(true) + , __focusManaged(false) +{ + __pOwner = &(const_cast<_Control&>(owner)); + __handle = _AccessibilityManager::GetInstance()->Register(this); +} + +_AccessibilityContainer::~_AccessibilityContainer(void) +{ + RemoveAllElement(); + _AccessibilityManager::GetInstance()->RemoveContainer(*this); + if(__handle.IsValid()) + { + _AccessibilityManager::GetInstance()->Unregister(__handle); + } +} + +_Control& +_AccessibilityContainer::GetOwner(void) +{ + return *__pOwner; +} + +const _Control& +_AccessibilityContainer::GetOwner(void) const +{ + return *__pOwner; +} + +result +_AccessibilityContainer::AddChildContainer(const _AccessibilityContainer& child) +{ + if(child.GetParent() == this) + { + return E_SUCCESS; + } + + result r = E_SYSTEM; + _AccessibilityContainer* _child = &const_cast<_AccessibilityContainer&>(child); + _child->SetParent(*this); + __childContainerList.Add(_child); + return r; +} + +result +_AccessibilityContainer::RemoveChildContainer(const _AccessibilityContainer& child) +{ + return __childContainerList.Remove(&const_cast<_AccessibilityContainer&>(child)); +} + +const LinkedListT<_AccessibilityContainer*>* +_AccessibilityContainer::GetChildContainerList(void) const +{ + return &__childContainerList; +} + +result +_AccessibilityContainer::AddElement(const _AccessibilityElement& element) +{ + const_cast<_AccessibilityElement&>(element).SetParent(*this); + if(__elementList.Contains(&const_cast<_AccessibilityElement&>(element))) + { + return E_SUCCESS; + } + return __elementList.Add(&const_cast<_AccessibilityElement&>(element)); +} + +result +_AccessibilityContainer::AddElements(const IListT<_AccessibilityElement*>& elementList) +{ + _AccessibilityElement* pElement = null; + int count = elementList.GetCount(); + for (int i = 0; i < count ; i++) + { + if(elementList.GetAt(i, pElement) == E_SUCCESS) + { + pElement->SetParent(*this); + } + } + return __elementList.AddItems(elementList); +} + +result +_AccessibilityContainer::InsertElement(const _AccessibilityElement& element, int index) +{ + const_cast<_AccessibilityElement&>(element).SetParent(*this); + return __elementList.InsertAt(&const_cast<_AccessibilityElement&>(element), index); +} + +result +_AccessibilityContainer::RemoveElement(const _AccessibilityElement& element) +{ + _AccessibilityElement* pElement = &const_cast<_AccessibilityElement&>(element); + result r = __elementList.Remove(pElement); + if (r == E_SUCCESS) + { + delete pElement; + } + return r; +} + +result +_AccessibilityContainer::RemoveAllElement() +{ + result r = E_SUCCESS; + _AccessibilityElement* pElement = null; + int count = __elementList.GetCount(); + for (int i = 0; i < count ;i++) + { + r = __elementList.GetAt(i, pElement); + if (r == E_SUCCESS) + { + delete pElement; + pElement = null; + } + } + __elementList.RemoveAll(); + return E_SUCCESS; +} + +void +_AccessibilityContainer::SortElements(void) +{ + _AccessibilityItemComparer<_AccessibilityElement*> comparer; + __elementList.Sort(comparer); +} + +_AccessibilityElement* +_AccessibilityContainer::GetChildElement(const String& name) const +{ + int count = __elementList.GetCount(); + _AccessibilityElement* pElement = null; + result r = E_SUCCESS; + for (int i = count -1 ; i >= 0 ; i--) + { + r = __elementList.GetAt(i, pElement); + if (r == E_SUCCESS && pElement->GetName() == name) + { + return pElement; + } + } + if (__childContainerList.GetCount() > 0) + { + IEnumeratorT<_AccessibilityContainer*>* pEnumerator = __childContainerList.GetEnumeratorN(); + while (pEnumerator->MoveNext() == E_SUCCESS) + { + _AccessibilityContainer* pContainer = null; + pEnumerator->GetCurrent(pContainer); + _AccessibilityElement* pElement = pContainer->GetChildElement(name); + if (pElement != null) + { + return pElement; + } + } + } + return null; +} + +void +_AccessibilityContainer::GetElements(IListT<_AccessibilityElement*>& list) const +{ + int count = __elementList.GetCount(); + result r = E_SUCCESS; + _AccessibilityElement* pElement = null; + + for (int i = 0; i < count; i++) + { + r = __elementList.GetAt(i, pElement); + SysTryReturn(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System Error."); + SysTryReturn(NID_UI, pElement, , E_SYSTEM, "[E_SYSTEM] System Error."); + + list.Add(pElement); + } +} + +IListT <_AccessibilityElement*>* +_AccessibilityContainer::GetElementsN(void) const +{ + if (__elementList.GetCount() > 0) + { + return __elementList.GetItemsN(0, __elementList.GetCount()); + } + else + { + return null; + } +} + +_AccessibilityElement* +_AccessibilityContainer::Hit(const Point& point) const +{ + if (!__activated) + { + return null; + } + + _AccessibilityElement* pElement = null; + int count = __elementList.GetCount(); + result r = E_SUCCESS; + + for (int i = count -1 ; i >= 0 ; i--) + { + r = __elementList.GetAt(i, pElement); + SysTryReturn(NID_UI, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] System Error."); + SysTryReturn(NID_UI, pElement, null, E_SYSTEM, "[E_SYSTEM] System Error."); + + if (!(pElement->IsActivated())) + continue; + + Rectangle rect = pElement->GetAbsoluteBounds(); + + if (rect.x < point.x && rect.y < point.y + && rect.x + rect.width > point.x + && rect.y + rect.height > point.y) + { + return pElement; + } + } + return null; +} + +result +_AccessibilityContainer::MoveElement(const _AccessibilityElement* pPreviousElement, const _AccessibilityElement& element) +{ + _AccessibilityElement* pElement = GetChildElement(element.GetName()); + if (pElement == null) + { + return E_OBJ_NOT_FOUND; + } + + if (pPreviousElement == null) + { + __elementList.Remove(pElement); + __elementList.InsertAt(pElement, 0); + } + else + { + _AccessibilityElement* _pPreviousElement = GetChildElement(pPreviousElement->GetName()); + if (_pPreviousElement == null) + { + return E_OBJ_NOT_FOUND; + } + __elementList.Remove(pElement); + int indexOfPreviousItem = 0; + __elementList.IndexOf(_pPreviousElement, indexOfPreviousItem); + __elementList.InsertAt(pElement, indexOfPreviousItem+1); + } +// SortElements(); + return E_SUCCESS; +} +void +_AccessibilityContainer::ManageFocus(bool set) +{ + __focusManaged = set; +} +bool +_AccessibilityContainer::IsFocusManaged(void) +{ + return __focusManaged; +} +bool +_AccessibilityContainer::MoveFocus(_AccessibilityFocusDirection direction) +{ + if(!__focusManaged) + { + return false; + } + int count = __elementList.GetCount(); + bool returnValue = false; + if (!__activated || count < 1) + { + return false; + } + + if (__currentElementIndex >= 0) + { + if (__currentElementIndex + direction < count + && __currentElementIndex + direction >= 0) + { + _AccessibilityElement* pElement = null; + if (__listenerList.GetCount() > 0) + { + for (int i = 0;i<__listenerList.GetCount();i++) + { + _IAccessibilityListener* pListener = null; + if (__listenerList.GetAt(i,pListener) == E_SUCCESS) + { + _AccessibilityElement* pElement = null; + if (__elementList.GetAt(__currentElementIndex, pElement) == E_SUCCESS) + { + pListener->OnAccessibilityFocusOut(*this,*pElement); + } + } + } + } + __currentElementIndex += direction; + if (__elementList.GetAt(__currentElementIndex, pElement) == E_SUCCESS) + { + if (__listenerList.GetCount() > 0) + { + for (int i = 0;i<__listenerList.GetCount();i++) + { + _IAccessibilityListener* pListener = null; + if (__listenerList.GetAt(i,pListener) == E_SUCCESS) + { + if (__elementList.GetAt(__currentElementIndex, pElement) == E_SUCCESS) + { + pListener->OnAccessibilityFocusIn(*this,*pElement); + if (direction == _ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS) + { + pListener->OnAccessibilityFocusMovedPrevious(*this, *pElement); + } + else if (direction == _ACCESSIBILITY_FOCUS_DIRECTION_NEXT) + { + pListener->OnAccessibilityFocusMovedNext(*this, *pElement); + } + } + } + } + } + } + returnValue = true; + } + else + { + __currentElementIndex = -1; + returnValue = false; + } + } + else + { + if (direction == _ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS) + { + _AccessibilityElement* pElement = null; + __currentElementIndex = count - 1; + if (__elementList.GetAt(__currentElementIndex, pElement) == E_SUCCESS&& __listenerList.GetCount() > 0) + { + for (int i = 0;i<__listenerList.GetCount();i++) + { + _IAccessibilityListener* pListener = null; + if (__listenerList.GetAt(i,pListener) == E_SUCCESS) + { + if (__elementList.GetAt(__currentElementIndex, pElement) == E_SUCCESS) + { + pListener->OnAccessibilityFocusIn(*this,*pElement); + pListener->OnAccessibilityFocusMovedPrevious(*this, *pElement); + } + } + } + } + } + else + { + _AccessibilityElement* pElement = null; + __currentElementIndex = 0; + if (__elementList.GetAt(__currentElementIndex, pElement) == E_SUCCESS && __listenerList.GetCount() > 0) + { + for (int i = 0;i<__listenerList.GetCount();i++) + { + _IAccessibilityListener* pListener = null; + if (__listenerList.GetAt(i,pListener) == E_SUCCESS) + { + if (__elementList.GetAt(__currentElementIndex, pElement) == E_SUCCESS) + { + pListener->OnAccessibilityFocusIn(*this,*pElement); + pListener->OnAccessibilityFocusMovedNext(*this, *pElement); + } + } + } + } + } + returnValue = true; + } + return returnValue; +} + +bool +_AccessibilityContainer::MoveFocus(const Tizen::Graphics::Point& point) +{ + _AccessibilityElement* pElement = Hit(point); + if(pElement == null) + { + return false; + } + + int index = -1; + if (__elementList.IndexOf(pElement, index) != E_SUCCESS) + { + return false; + } + else + { + __currentElementIndex = index; + } + return true; +} + +void +_AccessibilityContainer::ResetFocus(void) +{ + __currentElementIndex = -1; +} + +void +_AccessibilityContainer::SetPriority(int level) +{ + __level = level; +} + +int +_AccessibilityContainer::GetPriority(void) +{ + return __level; +} + +bool +_AccessibilityContainer::SetParent(const _AccessibilityContainer& parent) +{ + if (__pParent == null) + { + __pParent = &const_cast<_AccessibilityContainer&>(parent); + return true; + } + else + { + return false; + } +} + +_AccessibilityContainer* +_AccessibilityContainer::GetParent(void) const +{ + return __pParent; +} + +void +_AccessibilityContainer::SetCurrentFocusedElement(_AccessibilityElement*pElement) +{ + if (pElement == null) + { + __currentElementIndex = -1; + return; + } + + int index = 0; + result r = __elementList.IndexOf(pElement, 0, index); + if (r == E_SUCCESS) + { + __currentElementIndex = index; + } + else + { + __currentElementIndex = -1; + } +} +_AccessibilityElement* +_AccessibilityContainer::GetCurrentFocusedElement(void) const +{ + if (__currentElementIndex < 0) + { + return null; + } + + _AccessibilityElement* pElement = null; + result r = E_SUCCESS; + r = __elementList.GetAt(__currentElementIndex,pElement); + if (r == E_SUCCESS) + { + return pElement; + } + else + { + return null; + } +} + +void +_AccessibilityContainer::AddListener(const _IAccessibilityListener& listener) +{ + __listenerList.Add(&const_cast<_IAccessibilityListener&>(listener)); +} + +Tizen::Base::Collection::IListT<_IAccessibilityListener*>* +_AccessibilityContainer::GetListenerListN(void) const +{ + return __listenerList.GetItemsN(0,__listenerList.GetCount()); +} + +void +_AccessibilityContainer::RemoveListener(const _IAccessibilityListener& listener) +{ + __listenerList.Remove(&const_cast<_IAccessibilityListener&>(listener)); +} +void +_AccessibilityContainer::SetEnableState(bool enabledState) +{ + __enableState = enabledState; +} +bool +_AccessibilityContainer::GetEnableState(void) +{ + return __enableState; +} +void +_AccessibilityContainer::Activate(bool enable) +{ + if (enable) + { + _AccessibilityManager::GetInstance()->AddContainer(*this); + } + else + { + _AccessibilityManager::GetInstance()->RemoveContainer(*this); + } + __activated = enable; +} + +bool +_AccessibilityContainer::IsActivated(void) const +{ + return __activated; +} + +Rectangle +_AccessibilityContainer::GetAbsoluteBounds(void) const +{ + return __pOwner->GetAbsoluteBounds(); +} + +void +_AccessibilityContainer::ReadingAll(void) +{ + _AccessibilityElement* pElement = null; + int count = __elementList.GetCount(); + result r = E_SUCCESS; + + for (int i = count -1 ; i >= 0 ; i--) + { + r = __elementList.GetAt(i, pElement); + SysTryReturn(NID_UI, r == E_SUCCESS && pElement, , E_SYSTEM, "[E_SYSTEM] System Error."); + + if (!(pElement->IsActivated())) + continue; + + _AccessibilityManager::GetInstance()->ReadElement(*pElement); + } +} + +String +_AccessibilityContainer::GetCurrentGrammar(void) const +{ + //todo// + return L""; +} + +AccessibilityScreenReaderStatus +_AccessibilityContainer::GetStatus(void) const +{ + //todo// + return ACCESSIBILITY_SCREEN_READER_STATUS_ERROR; +} +Tizen::Base::_HandleT <_AccessibilityContainer> +_AccessibilityContainer::GetHandle(void) const +{ + return __handle; +} +}} //Tizen::Ui diff --git a/src/ui/FUi_AccessibilityContainerImpl.cpp b/src/ui/FUi_AccessibilityContainerImpl.cpp new file mode 100644 index 0000000..07d96ce --- /dev/null +++ b/src/ui/FUi_AccessibilityContainerImpl.cpp @@ -0,0 +1,339 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include +#include "FUi_ControlImpl.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityElementImpl.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityContainerImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { +_AccessibilityContainerImpl::_AccessibilityContainerImpl(const _ControlImpl& controlImpl, const AccessibilityContainer& publicInstance, const _AccessibilityContainer& coreInstance) + : __pControlImpl(null) + , __pPublic(null) + , __pCore(null) +{ + __pControlImpl = &const_cast<_ControlImpl&>(controlImpl); + __pPublic = &const_cast(publicInstance); + __pCore = &const_cast<_AccessibilityContainer&>(coreInstance); + __coreHandle = controlImpl.GetCore().GetHandle(); +} +AccessibilityContainer* +_AccessibilityContainerImpl::CreateAccessibilityContainerN(const _ControlImpl& controlImpl) +{ + _ControlImpl* pControlImpl = const_cast <_ControlImpl*>(&controlImpl); + _AccessibilityContainer* pCore = pControlImpl->GetCore().GetAccessibilityContainer(); + SysTryReturn(NID_UI, pCore && pCore->IsActivated(), null, E_SYSTEM, "[E_SYSTEM] This instance has not constructed."); + + AccessibilityContainer* pPublic = new (std::nothrow) AccessibilityContainer(); + SysTryReturn(NID_UI, pPublic, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + + _AccessibilityContainerImpl* pImpl = new (std::nothrow) _AccessibilityContainerImpl(controlImpl, *pPublic, *pCore); + SysTryCatch(NID_UI, pImpl,,E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + pPublic->__pAccessibilityContainerImpl = pImpl; + return pPublic; + +CATCH: + delete pPublic; + return null; +} +_AccessibilityContainerImpl::~_AccessibilityContainerImpl(void) +{ + AccessibilityElement* pElement = null; + int count = __elementList.GetCount(); + result r = E_SUCCESS; + for ( int i = 0 ; i < count ; i++) + { + r = __elementList.GetAt(i, pElement); + if (r == E_SUCCESS) + { + delete pElement; + pElement = null; + } + } + __elementList.RemoveAll(); + delete __pPublic; + __pPublic = null; + __listenerList.RemoveAll(); +} +_ControlImpl& +_AccessibilityContainerImpl::GetOwner(void) +{ + return *__pControlImpl; +} + +AccessibilityContainer& +_AccessibilityContainerImpl::GetPublic(void) +{ + return *__pPublic; +} + +AccessibilityElement* +_AccessibilityContainerImpl::GetChildElement(const String& name) +{ + SysTryReturn(NID_UI, ControlCoreExists(__coreHandle), null, E_SYSTEM,"[E_SYSTEM] A core of control is invalid."); + _AccessibilityElementImpl* pNewElementImpl = null; + _AccessibilityElement* pElement = __pCore->GetChildElement(name); + SysTryReturn(NID_UI, pElement, null, E_SYSTEM,"[E_SYSTEM]"); + if(pElement->GetUserData() == null) + { + pNewElementImpl = new (std::nothrow) _AccessibilityElementImpl(*pElement); + SysTryReturn(NID_UI, pNewElementImpl, null, E_OUT_OF_MEMORY,"[E_OUT_OF_MEMORY] Memory allocation is failed"); + pElement->SetUserData(pNewElementImpl); + __elementList.Add(&(pNewElementImpl->GetPublic())); + return &(pNewElementImpl->GetPublic()); + } + return &(static_cast<_AccessibilityElementImpl*>(pElement->GetUserData())->GetPublic()); +} + +result +_AccessibilityContainerImpl::AddAccessibilityListener(const IAccessibilityListener& listener) +{ + SysTryReturn(NID_UI, ControlCoreExists(__coreHandle), E_SYSTEM, E_SYSTEM,"[E_SYSTEM] A core of control is invalid."); + result r = E_OBJ_ALREADY_EXIST; + __pCore->AddListener(*this); + int index = 0; + IAccessibilityListener* pListener = &const_cast(listener); + SysTryReturn(NID_UI,pListener && __listenerList.IndexOf(pListener,index) != E_SUCCESS, E_OBJ_ALREADY_EXIST, E_OBJ_ALREADY_EXIST,"[E_OBJ_ALREADY_EXIST] The listener is already exist."); + r = __listenerList.Add(pListener); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r,"[%s]",GetErrorMessage(r)); + + return r; +} + +result +_AccessibilityContainerImpl::RemoveAccessibilityListener(const IAccessibilityListener& listener) +{ + SysTryReturn(NID_UI, ControlCoreExists(__coreHandle), E_SYSTEM, E_SYSTEM,"[E_SYSTEM] A core of control is invalid."); + result r = E_OBJ_NOT_FOUND; + SysTryReturn(NID_UI, __listenerList.GetCount() > 0, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,"[E_OBJ_NOT_FOUND] the listener has been not added."); + + int index = 0; + IAccessibilityListener* pListener = &const_cast(listener); + SysTryReturn(NID_UI,pListener && __listenerList.IndexOf(pListener,index) == E_SUCCESS, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,"[E_OBJ_NOT_FOUND] the listener has been not added."); + r = __listenerList.Remove(pListener); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r,"[%s]",GetErrorMessage(r)); + + if(__listenerList.GetCount() < 1) + { + __pCore->RemoveListener(*this); + } + return r; +} + +result +_AccessibilityContainerImpl::AddElement(const _AccessibilityElementImpl& element) +{ + SysTryReturn(NID_UI, ControlCoreExists(__coreHandle), E_SYSTEM, E_SYSTEM,"[E_SYSTEM] A core of control is invalid."); + __elementList.Add(&(const_cast<_AccessibilityElementImpl&>(element).GetPublic())); + return __pCore->AddElement(element.GetCore()); +} + +result +_AccessibilityContainerImpl::AddElements(const IList& elementList) +{ + return E_SYSTEM; +} + +IList* +_AccessibilityContainerImpl::GetElementsN(void) +{ + SysTryReturn(NID_UI, ControlCoreExists(__coreHandle), null, E_SYSTEM,"[E_SYSTEM] A core of control is invalid."); + LinkedList* _pList = new (std::nothrow) LinkedList; + SysTryReturn(NID_UI, _pList, null, E_OUT_OF_MEMORY,"[E_OUT_OF_MEMORY] Memory allocation is failed"); + int count = 0; + result r = E_SUCCESS; + _AccessibilityElement* pItem = null; + IListT<_AccessibilityElement*>* pList = __pCore->GetElementsN(); + SysTryCatch(NID_UI, pList, , E_SYSTEM,"[E_SYSTEM]"); + count = pList->GetCount(); + SysTryCatch(NID_UI, count >= 1, , E_SYSTEM,"[E_SYSTEM]"); + + for (int i = 0;i < count; i++) + { + _AccessibilityElementImpl* pNewElementImpl = null; + r = pList->GetAt(i,pItem); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM,"[E_SYSTEM]"); + + if(pItem->GetUserData() == null) + { + pNewElementImpl = new (std::nothrow) _AccessibilityElementImpl(*pItem); + SysTryCatch(NID_UI, pNewElementImpl, , E_OUT_OF_MEMORY,"[E_OUT_OF_MEMORY] Memory allocation is failed"); + pItem->SetUserData(pNewElementImpl); + AddSystemElement(pNewElementImpl->GetPublic()); + } + else + { + pNewElementImpl = static_cast<_AccessibilityElementImpl*>(pItem->GetUserData()); + } + _pList->Add(pNewElementImpl->GetPublic()); + } + delete pList; + return _pList; +CATCH: + delete pList; + delete _pList; + return null; +} + +result +_AccessibilityContainerImpl::RemoveElement(const _AccessibilityElementImpl& element) +{ + SysTryReturn(NID_UI, ControlCoreExists(__coreHandle), E_SYSTEM, E_SYSTEM,"[E_SYSTEM] A core of control is invalid."); + result r = __pCore->RemoveElement(element.GetCore()); + AccessibilityElement* pElement = const_cast(&(element.GetPublic())); + __elementList.Remove(pElement); + delete pElement; + return r; +} + +result +_AccessibilityContainerImpl::RemoveAllElement(void) +{ + SysTryReturn(NID_UI, ControlCoreExists(__coreHandle), E_SYSTEM, E_SYSTEM,"[E_SYSTEM] A core of control is invalid."); + result r = __pCore->RemoveAllElement(); + if (r == E_SUCCESS) + { + int count = __elementList.GetCount(); + AccessibilityElement* pElement = null; + for (int i = 0; i < count; i++) + { + if (__elementList.GetAt(i, pElement) == E_SUCCESS) + { + delete pElement; + pElement = null; + } + } + __elementList.RemoveAll(); + } + return r; +} + +String +_AccessibilityContainerImpl::GetCurrentGrammar(void) const +{ + SysTryReturn(NID_UI, ControlCoreExists(__coreHandle), L"", E_SYSTEM,"[E_SYSTEM] A core of control is invalid."); + return __pCore->GetCurrentGrammar(); +} + +AccessibilityScreenReaderStatus +_AccessibilityContainerImpl::GetStatus(void) const +{ + SysTryReturn(NID_UI, ControlCoreExists(__coreHandle), ACCESSIBILITY_SCREEN_READER_STATUS__NONE, E_SYSTEM,"[E_SYSTEM] A core of control is invalid."); + return __pCore->GetStatus(); +} + +void +_AccessibilityContainerImpl::ReadingAll(void) +{ + SysTryReturn(NID_UI, ControlCoreExists(__coreHandle), , E_SYSTEM,"[E_SYSTEM] A core of control is invalid."); + return __pCore->ReadingAll(); +} + +_AccessibilityContainerImpl* +_AccessibilityContainerImpl::GetInstance(AccessibilityContainer& container) +{ + return static_cast<_AccessibilityContainerImpl*> (container.__pAccessibilityContainerImpl); +} + +const _AccessibilityContainerImpl* +_AccessibilityContainerImpl::GetInstance(const AccessibilityContainer& container) +{ + return static_cast<_AccessibilityContainerImpl*> (container.__pAccessibilityContainerImpl); +} + +bool +_AccessibilityContainerImpl::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return true; +} +bool +_AccessibilityContainerImpl::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return true; +} +bool +_AccessibilityContainerImpl::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return true; +} +bool +_AccessibilityContainerImpl::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return true; +} +bool +_AccessibilityContainerImpl::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return true; +} +bool +_AccessibilityContainerImpl::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return true; +} +bool +_AccessibilityContainerImpl::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return true; +} +bool +_AccessibilityContainerImpl::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return true; +} +bool +_AccessibilityContainerImpl::ControlCoreExists(_ControlHandle handle) const +{ + _Control* p_Control = null; + _ControlManager* pManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, !(handle.IsNull()), false, E_SYSTEM, "[E_SYSTEM] System Error."); + SysTryReturn(NID_UI, pManager, false, E_SYSTEM, "[E_SYSTEM] System Error."); + + p_Control = pManager->GetObject(handle); + SysTryReturn(NID_UI, + p_Control && p_Control->GetHandle() == __pControlImpl->GetCore().GetHandle(), false, E_SYSTEM, + "[E_SYSTEM] System Error."); + + SetLastResult(E_SUCCESS); + return true; +} + +result +_AccessibilityContainerImpl::MoveElement(const _AccessibilityElementImpl* pPreviousElement, const _AccessibilityElementImpl& element) +{ + _AccessibilityElement* pPreviousCore = null; + if (pPreviousElement != null) + { + pPreviousCore = &const_cast<_AccessibilityElement&>(pPreviousElement->GetCore()); + } + return __pCore->MoveElement(pPreviousCore, element.GetCore()); +} + +void +_AccessibilityContainerImpl::AddSystemElement(const AccessibilityElement& element) +{ +} +}} //Tizen::Ui diff --git a/src/ui/FUi_AccessibilityElement.cpp b/src/ui/FUi_AccessibilityElement.cpp new file mode 100644 index 0000000..bab21c5 --- /dev/null +++ b/src/ui/FUi_AccessibilityElement.cpp @@ -0,0 +1,293 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElementImpl.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityManager.h" +#include "FUi_Control.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { + +const wchar_t* _traitString[] = +{ + L"",//ACCESSIBILITY_TRAITS_NONE, + L"TITLE",//ACCESSIBILITY_TRAITS_TITLE, + L"OPTION HEADER",//ACCESSIBILITY_TRAITS_OPTION_HEADER, + L"PICTURE",//ACCESSIBILITY_TRAITS_PICTURE, + L"STATUS BAR",//ACCESSIBILITY_TRAITS_STATUS_BAR, + L"TEXT FIELD",//ACCESSIBILITY_TRAITS_TEXT_FIELD, + L"RATING",//ACCESSIBILITY_TRAITS_RATING, + L"ACTION BAR",//ACCESSIBILITY_TRAITS_ACTION_BAR, + L"ACTION BAR MENU",//ACCESSIBILITY_TRAITS_ACTION_BAR_MENU, + L"BACK BUTTON",//ACCESSIBILITY_TRAITS_BUTTON, + L"BUTTON",//ACCESSIBILITY_TRAITS_BUTTON, + L"LABEL",//ACCESSIBILITY_TRAITS_LABEL, + L"LIST",//ACCESSIBILITY_TRAITS_LIST, + L"SELECTOR",//ACCESSIBILITY_TRAITS_DATA_SELECTOR, + L"SCROLL",//ACCESSIBILITY_TRAITS_DRAG_SCROLL, + L"EXPAND BUTTON",//ACCESSIBILITY_TRAITS_EXPAND_BUTTON, + L"FUNCTION PANEL",//ACCESSIBILITY_TRAITS_FUNCTION_PANEL, + L"IN DEPTH BUTTON",//ACCESSIBILITY_TRAITS_IN_DEPTH_BUTTON, + L"INDEX SCROLL",//ACCESSIBILITY_TRAITS_INDEX_SCROLL, + L"IMAGE",//ACCESSIBILITY_TRAITS_IMAGE + L"INDICATOR",//ACCESSIBILITY_TRAITS_INDICATOR, + L"NOTIFICATION",//ACCESSIBILITY_TRAITS_NOTIFICATION, + L"RADIO BUTTON",//ACCESSIBILITY_TRAITS_RADIO_BUTTON, + L"SCROLL BAR",//ACCESSIBILITY_TRAITS_SCROLL_BAR, + L"SEARCH FIELD",//ACCESSIBILITY_TRAITS_SEARCH_FIELD, + L"SEGMENT",//ACCESSIBILITY_TRAITS_SEGMENT, + L"SLIDER",//ACCESSIBILITY_TRAITS_SLIDER, + L"SOFT KEY",//ACCESSIBILITY_TRAITS_SOFT_KEY, + L"SUB MENU TITLE",//ACCESSIBILITY_TRAITS_SUB_MENU_TITLE, + L"TAB",//ACCESSIBILITY_TRAITS_TAB, + L"TICK BOX",//ACCESSIBILITY_TRAITS_TICKBOX, + L"TIME SELECTOR",//ACCESSIBILITY_TRAITS_TIME_SELECTOR, + L"VOLUME SLIDER",//ACCESSIBILITY_TRAITS_VOLUME_SLIDER, + L"HOUR",//ACCESSIBILITY_TRAITS_HOUR, + L"MINUTE",//ACCESSIBILITY_TRAITS_MINUTE, + L"SECOND",//ACCESSIBILITY_TRAITS_SECOND, + L"YEAR",//ACCESSIBILITY_TRAITS_YEAR, + L"MONTH",//ACCESSIBILITY_TRAITS_MONTH, + L"DAY",//ACCESSIBILITY_TRAITS_DAY, + L"END",//ACCESSIBILITY_TRAITS_END = 0xff +}; + + +_AccessibilityElement::_AccessibilityElement(bool systemElement) + : __name(L"") + , __bounds(0,0,0,0) + , __absBounds(0,0,0,0) + , __label(L"") + , __hint(L"") + , __status(L"") + , __traitString(L"") + , __trait(ACCESSIBILITY_TRAITS_NONE) + , __value(L"") + , __pParent(null) + , __pUserData(null) + , __systemElement(systemElement) + , __activated(true) + , __supportOperatingGesture(true) +{ +} +_AccessibilityElement::~_AccessibilityElement(void) +{ + if (__pUserData) + { + static_cast<_AccessibilityElementImpl*>(__pUserData)->SetCore(null); + __pUserData = null; + } +} +result +_AccessibilityElement::Construct(const String& name, const Rectangle& bounds) +{ + __name = name; + __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height); + return E_SUCCESS; +} +void +_AccessibilityElement::SetName(const String& name) +{ + __name = name; +} +void +_AccessibilityElement::SetLabel(const String& label) +{ + __label = label; +} +void +_AccessibilityElement::SetHint(const String& hint) +{ + __hint = hint; +} +void +_AccessibilityElement::SetStatus(const String& status) +{ + __status = status; +} +void +_AccessibilityElement::SetTrait(AccessibilityTraits trait) +{ + __trait = trait; + __traitString = (_traitString[__trait]); +} +void +_AccessibilityElement::SetTrait(const Tizen::Base::String& trait) +{ + __traitString = trait; +} +void +_AccessibilityElement::SetParent(const _AccessibilityContainer& parent) +{ + __pParent = &const_cast<_AccessibilityContainer&>(parent); +} +void +_AccessibilityElement::SetValue(const String& value) +{ + __value = value; +} +_AccessibilityContainer* +_AccessibilityElement::GetParent(void) const +{ + return __pParent; +} +String +_AccessibilityElement::GetName(void) const +{ + return __name; +} +Rectangle +_AccessibilityElement::GetBounds(void) const +{ + return __bounds; +} +String +_AccessibilityElement::GetLabel(void) const +{ + return __label; +} +String +_AccessibilityElement::GetHint(void) const +{ + return __hint; +} +String +_AccessibilityElement::GetStatus(void) const +{ + return __status; +} +AccessibilityTraits +_AccessibilityElement::GetTrait(void) const +{ + return __trait; +} +String +_AccessibilityElement::GetTraitString(void) const +{ + return __traitString; +} +String +_AccessibilityElement::GetValue(void) const +{ + return __value; +} +void +_AccessibilityElement::Activate(bool enable) +{ + __activated = enable; + if(!enable) + { + //__pParent->RemoveElement(*this); + __pUserData = null; + } +} +bool +_AccessibilityElement::IsActivated(void) const +{ + return __activated; +} +String +_AccessibilityElement::GetReadingContents(void) const +{ + String out = L""; + if(__label.GetLength() > 0) + { + out += __label; + } + + if(__traitString.GetLength() > 0) + { + out += L", "; + out += __traitString; + } + + if(__value.GetLength() > 0) + { + out += L", "; + out += __value; + } + if(__status.GetLength() > 0) + { + out += L", "; + out += __status; + } + if(__hint.GetLength() > 0) + { + out += L", "; + out += __hint; + } + if( __pParent->GetEnableState() == false) + { + out += L", "; + out += L"unavailable"; + } + + return out; +} +void +_AccessibilityElement::SetBounds(const Rectangle& bounds) +{ + __bounds.SetBounds(bounds.x,bounds.y,bounds.width,bounds.height); + if(__pParent && this == __pParent->GetCurrentFocusedElement()) + { + _AccessibilityManager::GetInstance()->RequestToDrawFocusUi(); + } +} +Rectangle +_AccessibilityElement::GetAbsoluteBounds(void) const +{ + Rectangle controlAbsBounds = GetParent()->GetOwner().GetAbsoluteBounds(); + Rectangle rect(controlAbsBounds.x+__bounds.x, controlAbsBounds.y+__bounds.y, __bounds.width, __bounds.height); + const_cast(__absBounds).SetBounds(controlAbsBounds.x+__bounds.x, controlAbsBounds.y+__bounds.y, __bounds.width, __bounds.height); + return rect; +} +void +_AccessibilityElement::SetSupportOperatingGesture(bool set) +{ + __supportOperatingGesture = set; +} +bool +_AccessibilityElement::GetSupportOperatingGesture(void) +{ + return __supportOperatingGesture; +} +void* +_AccessibilityElement::GetUserData(void) const +{ + return __pUserData; +} + +void +_AccessibilityElement::SetUserData(void* pUserData) +{ + __pUserData = pUserData; +} +bool +_AccessibilityElement::IsSystemElement(void) +{ + return __systemElement; +} +}} diff --git a/src/ui/FUi_AccessibilityElementImpl.cpp b/src/ui/FUi_AccessibilityElementImpl.cpp new file mode 100644 index 0000000..dfb6b3f --- /dev/null +++ b/src/ui/FUi_AccessibilityElementImpl.cpp @@ -0,0 +1,202 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include +#include "FUi_AccessibilityElementImpl.h" +#include "FUi_AccessibilityElement.h" + +namespace Tizen { namespace Ui +{ +_AccessibilityElementImpl::_AccessibilityElementImpl(const AccessibilityElement& element) + : __pPublic(null) + , __pCore(null) +{ + __pPublic = &const_cast(element); + __pCore = new (std::nothrow) _AccessibilityElement(); + SysTryReturn(NID_UI, __pCore, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + __pCore->SetUserData(this); +} +_AccessibilityElementImpl::_AccessibilityElementImpl(const _AccessibilityElement& element) + : __pPublic(null) + , __pCore(null) +{ + __pPublic = new (std::nothrow) AccessibilityElement(); + SysTryReturn(NID_UI, __pPublic, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + __pPublic->__pAccessibilityElementImpl = this; + __pCore = &const_cast<_AccessibilityElement&>(element); + __pCore->SetUserData(this); +} +_AccessibilityElementImpl::~_AccessibilityElementImpl(void) +{ + if (__pCore) + { + if(__pCore->GetParent() == null) + { + delete __pCore; + __pCore = null; + } + else + { + __pCore->Activate(false); + __pCore->SetUserData(null); + __pCore = null; + } + } +} + +result +_AccessibilityElementImpl::Construct(const Tizen::Base::String& name, const Tizen::Graphics::Rectangle& bounds) +{ + SysTryReturn(NID_UI, __pCore, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->Construct(name, bounds); +} +void +_AccessibilityElementImpl::SetBounds(const Tizen::Graphics::Rectangle& bounds) +{ + SysTryReturn(NID_UI, __pCore, , E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->SetBounds(bounds); +} +void +_AccessibilityElementImpl::SetName(const Tizen::Base::String& name) +{ + SysTryReturn(NID_UI, __pCore, , E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->SetName(name); +} +void +_AccessibilityElementImpl::SetLabel(const Tizen::Base::String& label) +{ + SysTryReturn(NID_UI, __pCore, , E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->SetLabel(label); +} +void +_AccessibilityElementImpl::SetHint(const Tizen::Base::String& hint) +{ + SysTryReturn(NID_UI, __pCore, , E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->SetHint(hint); +} +void +_AccessibilityElementImpl::SetStatus(const Tizen::Base::String& status) +{ + SysTryReturn(NID_UI, __pCore, , E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->SetStatus(status); +} +void +_AccessibilityElementImpl::SetTrait(AccessibilityTraits trait) +{ + SysTryReturn(NID_UI, __pCore, , E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->SetTrait(trait); +} +void +_AccessibilityElementImpl::SetTrait(const Tizen::Base::String& trait) +{ + SysTryReturn(NID_UI, __pCore, , E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->SetTrait(trait); +} +void +_AccessibilityElementImpl::SetValue(const Tizen::Base::String& value) +{ + SysTryReturn(NID_UI, __pCore, , E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->SetValue(value); +} +void +_AccessibilityElementImpl::SetCore(_AccessibilityElement* pCore) +{ + __pCore = pCore; +} +_AccessibilityElement& +_AccessibilityElementImpl::GetCore() +{ + return *__pCore; +} +const _AccessibilityElement& +_AccessibilityElementImpl::GetCore() const +{ + return *__pCore; +} +AccessibilityElement& +_AccessibilityElementImpl::GetPublic() +{ + return *__pPublic; +} +const AccessibilityElement& +_AccessibilityElementImpl::GetPublic() const +{ + return *__pPublic; +} +Tizen::Base::String +_AccessibilityElementImpl::GetName(void) const +{ + SysTryReturn(NID_UI, __pCore, L"", E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->GetName(); +} +Tizen::Graphics::Rectangle +_AccessibilityElementImpl::GetBounds(void) const +{ + SysTryReturn(NID_UI, __pCore, Tizen::Graphics::Rectangle(0, 0, 0, 0), E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->GetBounds(); +} +Tizen::Base::String +_AccessibilityElementImpl::GetLabel(void) const +{ + SysTryReturn(NID_UI, __pCore, L"", E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->GetLabel(); +} +Tizen::Base::String +_AccessibilityElementImpl::GetHint(void) const +{ + SysTryReturn(NID_UI, __pCore, L"", E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->GetHint(); +} +Tizen::Base::String +_AccessibilityElementImpl::GetStatus(void) const +{ + SysTryReturn(NID_UI, __pCore, L"", E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->GetStatus(); +} +AccessibilityTraits +_AccessibilityElementImpl::GetTrait(void) const +{ + SysTryReturn(NID_UI, __pCore, ACCESSIBILITY_TRAITS_NONE, E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->GetTrait(); +} +Tizen::Base::String +_AccessibilityElementImpl::GetTraitString(void) const +{ + SysTryReturn(NID_UI, __pCore, L"", E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->GetTraitString(); +} +Tizen::Base::String +_AccessibilityElementImpl::GetValue(void) const +{ + SysTryReturn(NID_UI, __pCore, -1, E_SYSTEM, "[E_SYSTEM] System Error."); + return __pCore->GetValue(); +} +_AccessibilityElementImpl* +_AccessibilityElementImpl::GetInstance(AccessibilityElement& element) +{ + return static_cast<_AccessibilityElementImpl*> (element.__pAccessibilityElementImpl); +} +const _AccessibilityElementImpl* +_AccessibilityElementImpl::GetInstance(const AccessibilityElement& element) +{ + return static_cast<_AccessibilityElementImpl*> (element.__pAccessibilityElementImpl); +} + +}}//Tizen::Ui diff --git a/src/ui/FUi_AccessibilityGesture.cpp b/src/ui/FUi_AccessibilityGesture.cpp new file mode 100644 index 0000000..b1b25a2 --- /dev/null +++ b/src/ui/FUi_AccessibilityGesture.cpp @@ -0,0 +1,81 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include +#include +#include +#include +#include "FUi_AccessibilityGesture.h" +#include "FUi_AccessibilityManager.h" +#include "FUi_ControlManager.h" + +using namespace Tizen::App; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +namespace +{ + void ConvertTouchPosition(int &x, int&y) + { + Frame* pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame(); + Form* pForm= pFrame->GetCurrentForm(); + Dimension screen = Tizen::Ui::_ControlManager::GetInstance()->GetScreenSize(); + int _x = x; + int _y = y; + switch(pForm->GetOrientationStatus()) + { + case Tizen::Ui::ORIENTATION_STATUS_PORTRAIT: + break; + case Tizen::Ui::ORIENTATION_STATUS_LANDSCAPE: + x = screen.height - _y; + y= _x; + break; + case Tizen::Ui::ORIENTATION_STATUS_PORTRAIT_REVERSE: + y = screen.height - _y; + break; + case Tizen::Ui::ORIENTATION_STATUS_LANDSCAPE_REVERSE: + x = _y; + y = screen.width - _x; + break; + default: + break; + } + } +} + +namespace Tizen { namespace Ui { +_AccessibilityGesture::_AccessibilityGesture(_AccessibilityManager& manager) +: __pManager(&manager) +{ +} + +_AccessibilityGesture::~_AccessibilityGesture(void) +{ +} + +bool +_AccessibilityGesture::ProcessGesture(_AccessibilityGestureType type, int x, int y) +{ + ConvertTouchPosition(x,y); + _AccessibilityManager::GetInstance()->ProcessGesture(type,Tizen::Graphics::Point(CoordinateSystem::ConvertToLogicalX(x),CoordinateSystem::ConvertToLogicalY(y)), null); + return true; +} +}} //Tizen::Ui + diff --git a/src/ui/FUi_AccessibilityManager.cpp b/src/ui/FUi_AccessibilityManager.cpp new file mode 100644 index 0000000..0ab267b --- /dev/null +++ b/src/ui/FUi_AccessibilityManager.cpp @@ -0,0 +1,1994 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_AccessibilityGesture.h" +#include "FUi_AccessibilitySystemSettingLoader.h" +#include "FUi_AccessibilityTtsPlayer.h" +#include "FUi_AccessibilityManager.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_IAccessibilityListener.h" +#include "FUi_ControlManager.h" +#include "FUi_TouchManager.h" +#include "FUi_UiEventManager.h" +#include "FUiAnim_VisualElementImpl.h" +#include "FUiCtrl_FrameImpl.h" +#include "FUiCtrl_ScrollPanel.h" +#include "FUiCtrl_IconListView.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Controls; + +namespace +{ +class GuidePopupTimer + : public ITimerEventListener +{ +public: + GuidePopupTimer(void) + : __pElement(null) + { + timer.Construct(*this); + } + virtual ~GuidePopupTimer(void) {} + void SetElement(VisualElement* pElement) + { + if (__pElement != null) + { + timer.Cancel(); + } + __pElement = pElement; + timer.Start(3000); + + } + void Stop(void) + { + timer.Cancel(); + } + virtual void OnTimerExpired(Timer& timer) + { + if (__pElement) + { + __pElement->SetShowState(false); + } + __pElement = null; + } + VisualElement* __pElement; + Timer timer; +}; + +class AutoReadingTimer + : public ITimerEventListener +{ +public: + AutoReadingTimer(Tizen::Ui::_AccessibilityManager* pManager) + : __pAccessibilityManager(pManager) + { + + timer.Construct(*this); + } + virtual ~AutoReadingTimer(void) {} + void Start(void) + { + timer.Start(500); + } + void Stop(void) + { + timer.Cancel(); + } + virtual void OnTimerExpired(Timer& timer) + { + __pAccessibilityManager->ReadElement(0); + } + Tizen::Ui::_AccessibilityManager* __pAccessibilityManager; + Timer timer; +}; + +GuidePopupTimer* pGuidePopupTimer; +AutoReadingTimer* pAutoReadingTimer; +} +namespace Tizen { namespace Ui { + +template +class _AccessibilityItemComparer + : public Tizen::Base::Collection::IComparerT +{ +public: + _AccessibilityItemComparer(void) + { + } + virtual ~_AccessibilityItemComparer(void) + { + } + virtual result Compare(const T& obj1, const T& obj2, int& cmp) const + { + Tizen::Graphics::Rectangle rect1= obj1->GetAbsoluteBounds(); + Tizen::Graphics::Rectangle rect2= obj2->GetAbsoluteBounds(); + + if(rect1.y > rect2.y) + { + cmp = 1; + return E_SUCCESS; + } + else if(rect1.y < rect2.y) + { + cmp = -1; + return E_SUCCESS; + } + else + { + if(rect1.x > rect2.x) + { + cmp = 1; + return E_SUCCESS; + } + else if(rect1.x < rect2.x) + { + cmp = -1; + return E_SUCCESS; + } + else + { + cmp = 0; + return E_SUCCESS; + } + } + } +}; //class _AccessibilityComparer + +template +class _ElementComparer + : public Tizen::Base::Collection::IComparerT +{ +public: + _ElementComparer(void) + { + } + virtual ~_ElementComparer(void) + { + } + virtual result Compare(const T& obj1, const T& obj2, int& cmp) const + { + if(obj1->GetParent()->GetPriority() > obj2->GetParent()->GetPriority()) + { + cmp = -1; + return E_SUCCESS; + } + else if(obj1->GetParent()->GetPriority() < obj2->GetParent()->GetPriority()) + { + cmp = 1; + return E_SUCCESS; + } + else + { + Tizen::Graphics::Rectangle rect1= obj1->GetAbsoluteBounds(); + Tizen::Graphics::Rectangle rect2= obj2->GetAbsoluteBounds(); + + if(rect1.y > rect2.y) + { + cmp = 1; + return E_SUCCESS; + } + else if(rect1.y < rect2.y) + { + cmp = -1; + return E_SUCCESS; + } + else + { + if(rect1.x > rect2.x) + { + cmp = 1; + return E_SUCCESS; + } + else if(rect1.x < rect2.x) + { + cmp = -1; + return E_SUCCESS; + } + else + { + cmp = 0; + return E_SUCCESS; + } + } + } + } +}; + +static _AccessibilityManager* pAccManager = null; +bool _AccessibilityManager::__screenReaderIsEnabled = false; +_AccessibilityManager::_AccessibilityManager(void) + : __pAccGesture(null) + , __pPlayer(null) + , __pSettingLoader(null) + , __pTargetContainer(null) + , __pTargetElement(null) + , __pTitleElement(null) + , __containerList() + , __candidateList() + , __mode(MODE_NONE) + , __pReadingVe(null) + , __pFocusVe(null) + , __pPanningControl(null) +{ + Initialize(); +} +_AccessibilityManager::~_AccessibilityManager(void) +{ + delete __pAccGesture; + __pAccGesture = null; + delete __pPlayer; + __pPlayer = null; + delete __pSettingLoader; + __pSettingLoader = null; + if (__pReadingVe) + { + __pReadingVe->Destroy(); + __pReadingVe = null; + } + if (__pFocusVe) + { + __pFocusVe->Destroy(); + __pFocusVe = null; + } + delete pGuidePopupTimer; + pGuidePopupTimer = null; + delete pAutoReadingTimer; + pAutoReadingTimer = null; +} + +_AccessibilityManager* +_AccessibilityManager::GetInstance(void) +{ + return pAccManager; +} + +void +_AccessibilityManager::CreateInstance(void) +{ + static pthread_once_t onceBlock = PTHREAD_ONCE_INIT; + + if (pAccManager == null) + { + pthread_once(&onceBlock, InitializeInstance); + } +} + +void +_AccessibilityManager::InitializeInstance(void) +{ + pAccManager = new (std::nothrow) _AccessibilityManager; +} +void +_AccessibilityManager::ReleaseInstance(void) +{ + delete pAccManager; + pAccManager = null; +} +void +_AccessibilityManager::Initialize(void) +{ + __pAccGesture = new (std::nothrow) _AccessibilityGesture(*this); + SysTryReturn(NID_UI, __pAccGesture, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + __pPlayer = new (std::nothrow) _AccessibilityTtsPlayer(*this); + SysTryCatch(NID_UI, __pPlayer, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + __pSettingLoader = new (std::nothrow) _AccessibilitySystemSettingLoader(*this); + SysTryCatch(NID_UI, __pSettingLoader, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + + if (IsScreenReaderActivated()) + { + __pPlayer->Activate(); + } + + pGuidePopupTimer = new (std::nothrow) GuidePopupTimer; + SysTryCatch(NID_UI, pGuidePopupTimer, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + pAutoReadingTimer = new (std::nothrow) AutoReadingTimer(this); + SysTryCatch(NID_UI, pAutoReadingTimer, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + return; + +CATCH: + delete __pAccGesture; + __pAccGesture = null; + delete __pPlayer; + __pPlayer = null; + delete __pSettingLoader; + __pSettingLoader = null; + delete pGuidePopupTimer; + pGuidePopupTimer = null; + delete pAutoReadingTimer; + pAutoReadingTimer = null; +} +AccessibilityScreenReaderStatus +_AccessibilityManager::GetReadingtatus(void) +{ + if (__pPlayer) + { + return __pPlayer->GetStatus(); + } + return ACCESSIBILITY_SCREEN_READER_STATUS_ERROR; +} +result +_AccessibilityManager::ReadContent(const Tizen::Base::String& content) +{ + if (__pPlayer) + { + ShowPopup(content); + __pPlayer->ReadGrammar(content); + } + return E_SUCCESS; +} +void +_AccessibilityManager::ReadElement(int index) +{ + MakeList(); + int count = __candidateList.GetCount(); + if (count < 1 || index > count -1) + { + return; + } + _AccessibilityElement* pElement = null; + result r = __candidateList.GetAt(index, pElement); + if (r != E_SUCCESS) + { + return; + } + if (pElement == null || __pTitleElement == pElement) + { + return; + } + __pTitleElement = pElement; + pElement->GetParent()->SetCurrentFocusedElement(pElement); + DrawFocusUi(*(pElement->GetParent())); + __pTargetContainer = pElement->GetParent(); + __pTargetElement = pElement; + __targetControlHandle = __pTargetContainer->GetOwner().GetHandle(); + ReadElement(*pElement); +} + +result +_AccessibilityManager::ReadElement(const _AccessibilityElement& element) +{ + if (__pPlayer) + { + LinkedListT<_IAccessibilityListener*>* pList = static_cast*>(__pTargetContainer->GetListenerListN()); + if (pList != null) + { + for (int i = 0;iGetCount();i++) + { + _IAccessibilityListener* pListener = null; + if (pList->GetAt(i, pListener) == E_SUCCESS) + { + pListener->OnAccessibilityReadElement(*__pTargetContainer, element); + } + } + delete pList; + pList = null; + } + ShowPopup(); + __pPlayer->ReadGrammar(element.GetReadingContents()); + } + return E_SUCCESS; +} +result +_AccessibilityManager::ReadingStop(void) +{ + return E_SUCCESS; +} +result +_AccessibilityManager::ReadingPause(void) +{ + return E_SUCCESS; +} +result +_AccessibilityManager::ReadingResume(void) +{ + return E_SUCCESS; +} + +void +_AccessibilityManager::OnStartReading(const Tizen::Base::String& grammar) +{ +} +void +_AccessibilityManager::HidePopup(void) +{ + if (__pReadingVe) + { + __pReadingVe->Destroy(); + __pReadingVe = null; + } + pGuidePopupTimer->Stop(); +} +void +_AccessibilityManager::ShowPopup(const String& content) +{ + if (content.IsEmpty()) + { + return; + } + utsname sysInfo; + uname(&sysInfo); + if (String("i686_emulated") != sysInfo.machine) + { + return; + } + Canvas* pCanvas = null; + Bitmap* pBgBitmap = null; + EnrichedText* pEnrichedTitleText = null; + EnrichedText* pText = null; + Frame* pFrame = null; + + if (__pReadingVe == null) + { + pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame(); + + if (pFrame != null) + { + int accesibilityVisualElementLevel = 3000; + result r = E_SUCCESS; +#if!defined(MULTI_WINDOW) + VisualElement* pRootVe = _ControlManager::GetInstance()->GetRoot().GetVisualElement(); +#else + VisualElement* pRootVe = _ControlManager::GetInstance()->GetTopVisibleWindow()->GetVisualElement(); +#endif + + __pReadingVe = new (std::nothrow) VisualElement(); + SysTryCatch(NID_UI, __pReadingVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + + r = __pReadingVe->Construct(); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error"); + __pReadingVe->SetName("Accessibility reading popup"); + _VisualElementImpl::GetInstance(*__pReadingVe)->SetZOrderGroup(accesibilityVisualElementLevel); + pRootVe->AttachChild(*__pReadingVe); + } + } + if (__pReadingVe) + { + result r = E_SUCCESS; + + int titleFontSize = 0; + int textFontSize = 0; + int popupWidth = 0; + int topMargin = 0; + int bottomMargin = 0; + int sideMargin = 0; + int titleHeight = 0; + int textTopMargin = 0; + int textHeight = 0; + + Color titleTextColor; + Color pointTextColor; + Color textColor; + TextElement* pElement = null; + + r = GET_SHAPE_CONFIG(ACCESSIBILITY::TITLE_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, titleFontSize); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::TEXT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, textFontSize); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::POPUP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, popupWidth); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, topMargin); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::BOTTON_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, bottomMargin); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::SIDE_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sideMargin); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::TITLE_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, titleHeight); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::TEXT_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, textTopMargin); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::TEXT_HEGIHT, _CONTROL_ORIENTATION_PORTRAIT, textHeight); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_COLOR_CONFIG(ACCESSIBILITY::TITLE_TEXT, titleTextColor); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_COLOR_CONFIG(ACCESSIBILITY::POINT_TEXT, pointTextColor); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_COLOR_CONFIG(ACCESSIBILITY::TEXT, textColor); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_BITMAP_CONFIG_N(ACCESSIBILITY::POPUP_BG, BITMAP_PIXEL_FORMAT_ARGB8888, pBgBitmap); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + Font titleFont; + r = titleFont.Construct(FONT_STYLE_PLAIN, titleFontSize); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + Font textFont; + r = textFont.Construct(FONT_STYLE_PLAIN, textFontSize); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pEnrichedTitleText = new (std::nothrow) EnrichedText; + SysTryCatch(NID_UI, pEnrichedTitleText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + pEnrichedTitleText->Construct(Dimension(popupWidth-sideMargin*2, titleHeight)); + + pText = new (std::nothrow) EnrichedText; + SysTryCatch(NID_UI, pText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + pText->Construct(Dimension(popupWidth-sideMargin*2, textHeight)); + + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(L"Screen reading..."); + if (r != E_SUCCESS) + { + delete pElement; + goto CATCH; + } + pElement->SetTextColor(titleTextColor); + pElement->SetFont(titleFont); + r = pEnrichedTitleText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + pEnrichedTitleText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT); + pEnrichedTitleText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP); + pEnrichedTitleText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP); + pEnrichedTitleText->SetTextAbbreviationEnabled(true); + + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(content); + if (r != E_SUCCESS) + { + delete pElement; + goto CATCH; + } + pElement->SetTextColor(textColor); + pElement->SetFont(textFont); + r = pText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + pText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT); + pText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP); + pText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP); + pText->SetTextAbbreviationEnabled(true); + + int x = 40; + int y = 200; + int popupHeight = topMargin + bottomMargin + titleHeight + textTopMargin + textHeight; + + Dimension screen = Tizen::Ui::_ControlManager::GetInstance()->GetScreenSize(); + __pReadingVe->SetBounds(FloatRectangle(x, y, popupWidth, popupHeight)); + pCanvas = __pReadingVe->GetCanvasN(); + SysTryCatch(NID_UI, pCanvas != null, , E_SYSTEM, "System error for accessibility popup"); + pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, popupWidth, popupHeight), *pBgBitmap); + int drawingTextY = topMargin; + pCanvas->DrawText(Point(sideMargin, drawingTextY), *pEnrichedTitleText); + drawingTextY += textTopMargin + titleHeight; + pCanvas->DrawText(Point(sideMargin, drawingTextY), *pText); + __pReadingVe->SetShowState(true); + __pReadingVe->SetFlushNeeded(); + pGuidePopupTimer->SetElement(__pReadingVe); + + } +CATCH: + delete pCanvas; + pCanvas = null; + delete pBgBitmap; + pBgBitmap = null; + if (pEnrichedTitleText) + { + pEnrichedTitleText->RemoveAll(true); + delete pEnrichedTitleText; + } + if (pText) + { + pText->RemoveAll(true); + delete pText; + } + + return; + +} +void +_AccessibilityManager::ShowPopup() +{ + if (__pTargetElement == null) + { + return; + } + utsname sysInfo; + uname(&sysInfo); + Frame* pFrame = null; + Canvas* pCanvas = null; + Bitmap* pBgBitmap = null; + EnrichedText* pEnrichedTitleText = null; + EnrichedText* pEnrichedNameText = null; + EnrichedText* pEnrichedLableText = null; + EnrichedText* pEnrichedTraitText = null; + EnrichedText* pEnrichedStatusText = null; + EnrichedText* pEnrichedHintText = null; + EnrichedText* pEnrichedValueText = null; + EnrichedText* pEnrichedBoundsText = null; + EnrichedText* pEnrichedAbsBoundsText = null; + TextElement* pElement = null; + Dimension screen; + + if (String("i686_emulated") != sysInfo.machine) + { + return; + } + + if (__pReadingVe == null) + { + pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame(); + + if (pFrame != null) + { + int accesibilityVisualElementLevel = 3000; + result r = E_SUCCESS; +#if!defined(MULTI_WINDOW) + VisualElement* pRootVe = _ControlManager::GetInstance()->GetRoot().GetVisualElement(); +#else + VisualElement* pRootVe = _ControlManager::GetInstance()->GetTopVisibleWindow()->GetVisualElement(); +#endif + + __pReadingVe = new (std::nothrow) VisualElement(); + SysTryCatch(NID_UI, __pReadingVe, , E_SYSTEM, "[E_SYSTEM] System error"); + + r = __pReadingVe->Construct(); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error"); + __pReadingVe->SetName("Accessibility reading popup"); + _VisualElementImpl::GetInstance(*__pReadingVe)->SetZOrderGroup(accesibilityVisualElementLevel); + pRootVe->AttachChild(*__pReadingVe); + } + } + + screen = _ControlManager::GetInstance()->GetScreenSize(); + if (__pReadingVe) + { + result r = E_SUCCESS; + + int titleFontSize = 0; + int textFontSize = 0; + int popupWidth = 0; + int topMargin = 0; + int bottomMargin = 0; + int sideMargin = 0; + int titleHeight = 0; + int textTopMargin = 0; + int textHeight = 0; + + Color titleTextColor; + Color pointTextColor; + Color textColor; + + r = GET_SHAPE_CONFIG(ACCESSIBILITY::TITLE_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, titleFontSize); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::TEXT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, textFontSize); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::POPUP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, popupWidth); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, topMargin); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::BOTTON_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, bottomMargin); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::SIDE_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sideMargin); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::TITLE_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, titleHeight); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::TEXT_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, textTopMargin); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_SHAPE_CONFIG(ACCESSIBILITY::TEXT_HEGIHT, _CONTROL_ORIENTATION_PORTRAIT, textHeight); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_COLOR_CONFIG(ACCESSIBILITY::TITLE_TEXT, titleTextColor); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_COLOR_CONFIG(ACCESSIBILITY::POINT_TEXT, pointTextColor); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_COLOR_CONFIG(ACCESSIBILITY::TEXT, textColor); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + r = GET_BITMAP_CONFIG_N(ACCESSIBILITY::POPUP_BG, BITMAP_PIXEL_FORMAT_ARGB8888, pBgBitmap); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + Font titleFont; + r = titleFont.Construct(FONT_STYLE_PLAIN, titleFontSize); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + Font textFont; + r = textFont.Construct(FONT_STYLE_PLAIN, textFontSize); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pEnrichedTitleText = new (std::nothrow) EnrichedText; + SysTryCatch(NID_UI, pEnrichedTitleText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + pEnrichedTitleText->Construct(Dimension(popupWidth-sideMargin*2, titleHeight)); + + pEnrichedNameText = new (std::nothrow) EnrichedText; + SysTryCatch(NID_UI, pEnrichedNameText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + pEnrichedNameText->Construct(Dimension(popupWidth-sideMargin*2, textHeight)); + + pEnrichedLableText = new (std::nothrow) EnrichedText; + SysTryCatch(NID_UI, pEnrichedLableText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + pEnrichedLableText->Construct(Dimension(popupWidth-sideMargin*2, textHeight)); + + pEnrichedTraitText = new (std::nothrow) EnrichedText; + SysTryCatch(NID_UI, pEnrichedTraitText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pEnrichedTraitText->Construct(Dimension(popupWidth-sideMargin*2, textHeight)); + + pEnrichedStatusText = new (std::nothrow) EnrichedText; + SysTryCatch(NID_UI, pEnrichedStatusText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pEnrichedStatusText->Construct(Dimension(popupWidth-sideMargin*2, textHeight)); + + pEnrichedHintText = new (std::nothrow) EnrichedText; + SysTryCatch(NID_UI, pEnrichedHintText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pEnrichedHintText->Construct(Dimension(popupWidth-sideMargin*2, textHeight)); + + pEnrichedValueText = new (std::nothrow) EnrichedText; + SysTryCatch(NID_UI, pEnrichedValueText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pEnrichedValueText->Construct(Dimension(popupWidth-sideMargin*2, textHeight)); + + pEnrichedBoundsText = new (std::nothrow) EnrichedText; + SysTryCatch(NID_UI, pEnrichedBoundsText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pEnrichedBoundsText->Construct(Dimension(popupWidth-sideMargin*2, textHeight)); + + pEnrichedAbsBoundsText = new (std::nothrow) EnrichedText; + SysTryCatch(NID_UI, pEnrichedAbsBoundsText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pEnrichedAbsBoundsText->Construct(Dimension(popupWidth-sideMargin*2, textHeight)); + + pElement = new (std::nothrow) TextElement; + r = pElement->Construct(L"Screen reading..."); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + pElement->SetTextColor(titleTextColor); + pElement->SetFont(titleFont); + r = pEnrichedTitleText->Add(*pElement); + + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + pEnrichedTitleText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT); + pEnrichedTitleText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP); + pEnrichedTitleText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP); + pEnrichedTitleText->SetTextAbbreviationEnabled(true); + + pElement = new (std::nothrow) TextElement; + r = pElement->Construct(L"Name: "); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(pointTextColor); + pElement->SetFont(textFont); + r = pEnrichedNameText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + if (!(__pTargetElement->GetName().IsEmpty())) + { + pElement = new (std::nothrow) TextElement; + r = pElement->Construct(__pTargetElement->GetName()); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(textColor); + pElement->SetFont(textFont); + r = pEnrichedNameText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + SysLog(NID_UI, " Name :::::: %s", _StringConverter::CopyToCharArrayN(__pTargetElement->GetName())); + } + pEnrichedNameText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT); + pEnrichedNameText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP); + pEnrichedNameText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP); + pEnrichedNameText->SetTextAbbreviationEnabled(true); + + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(L"Label: "); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(pointTextColor); + pElement->SetFont(textFont); + r = pEnrichedLableText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + if (!(__pTargetElement->GetLabel().IsEmpty())) + { + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(__pTargetElement->GetLabel()); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(textColor); + pElement->SetFont(textFont); + r = pEnrichedLableText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + SysLog(NID_UI, " Label :::::: %s", _StringConverter::CopyToCharArrayN(__pTargetElement->GetLabel())); + } + pEnrichedLableText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT); + pEnrichedLableText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP); + pEnrichedLableText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP); + pEnrichedLableText->SetTextAbbreviationEnabled(true); + + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(L"Trait: "); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(pointTextColor); + pElement->SetFont(textFont); + r = pEnrichedTraitText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + if (!(__pTargetElement->GetTraitString().IsEmpty())) + { + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(__pTargetElement->GetTraitString()); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(textColor); + pElement->SetFont(textFont); + r = pEnrichedTraitText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + } + pEnrichedTraitText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT); + pEnrichedTraitText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP); + pEnrichedTraitText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP); + pEnrichedTraitText->SetTextAbbreviationEnabled(true); + + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(L"Status: "); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(pointTextColor); + pElement->SetFont(textFont); + r = pEnrichedStatusText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + if (!(__pTargetElement->GetStatus().IsEmpty())) + { + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(__pTargetElement->GetStatus()); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(textColor); + pElement->SetFont(textFont); + r = pEnrichedStatusText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + } + pEnrichedStatusText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT); + pEnrichedStatusText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP); + pEnrichedStatusText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP); + pEnrichedStatusText->SetTextAbbreviationEnabled(true); + + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(L"Hint: "); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(pointTextColor); + pElement->SetFont(textFont); + r = pEnrichedHintText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + if (!(__pTargetElement->GetHint().IsEmpty())) + { + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(__pTargetElement->GetHint()); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(textColor); + pElement->SetFont(textFont); + r = pEnrichedHintText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + } + pEnrichedHintText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT); + pEnrichedHintText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP); + pEnrichedHintText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP); + pEnrichedHintText->SetTextAbbreviationEnabled(true); + + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(L"Value: "); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(pointTextColor); + pElement->SetFont(textFont); + r = pEnrichedValueText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + if (!(__pTargetElement->GetValue().IsEmpty())) + { + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(__pTargetElement->GetValue()); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(textColor); + pElement->SetFont(textFont); + r = pEnrichedValueText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + } + pEnrichedValueText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT); + pEnrichedValueText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP); + pEnrichedValueText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP); + pEnrichedValueText->SetTextAbbreviationEnabled(true); + + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(L"Bound: "); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(pointTextColor); + pElement->SetFont(textFont); + r = pEnrichedBoundsText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + Rectangle rect = __pTargetElement->GetBounds(); + String rectString; + rectString.Format(40, L"x:%d, y:%d, w:%d, h:%d", rect.x, rect.y, rect.width, rect.height); + r = pElement->Construct(rectString); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(textColor); + pElement->SetFont(textFont); + r = pEnrichedBoundsText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + pEnrichedBoundsText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT); + pEnrichedBoundsText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP); + pEnrichedBoundsText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP); + pEnrichedBoundsText->SetTextAbbreviationEnabled(true); + + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = pElement->Construct(L"AbsBound: "); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(pointTextColor); + pElement->SetFont(textFont); + r = pEnrichedAbsBoundsText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement = new (std::nothrow) TextElement; + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + rect = __pTargetElement->GetAbsoluteBounds(); + rectString.Clear(); + rectString.Format(40, L"x:%d, y:%d, w:%d, h:%d", rect.x, rect.y, rect.width, rect.height); + r = pElement->Construct(rectString); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + + pElement->SetTextColor(textColor); + pElement->SetFont(textFont); + r = pEnrichedAbsBoundsText->Add(*pElement); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "System error for accessibility popup"); + pEnrichedAbsBoundsText->SetHorizontalAlignment(TEXT_ALIGNMENT_LEFT); + pEnrichedAbsBoundsText->SetVerticalAlignment(TEXT_ALIGNMENT_TOP); + pEnrichedAbsBoundsText->SetTextWrapStyle(TEXT_WRAP_CHARACTER_WRAP); + pEnrichedAbsBoundsText->SetTextAbbreviationEnabled(true); + + int x = 0; + int y = 0; + int popupHeight = topMargin + bottomMargin + titleHeight + textTopMargin + textHeight * 8; + + Frame* pFrame = UiApp::GetInstance()->GetAppFrame()->GetFrame(); + Form* pForm = pFrame->GetCurrentForm(); + Dimension screen = Tizen::Ui::_ControlManager::GetInstance()->GetScreenSize(); + + if (pForm->GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT + || pForm->GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE) + { + x = (screen.width-popupWidth) / 2; + if (rect.y < screen.height/2) + { + y = (screen.height/2 - popupHeight) /2 + screen.height/2; + } + else + { + y = (screen.height/2 - popupHeight) /2; + } + } + else + { + y = (screen.width-popupHeight) / 2; + if (rect.x < screen.height/2) + { + x = (screen.height/2 - popupWidth) /2 + screen.height/2; + } + else + { + x = (screen.height/2 - popupWidth) /2; + } + } + + __pReadingVe->SetBounds(FloatRectangle(x, y, popupWidth, popupHeight)); + pCanvas = __pReadingVe->GetCanvasN(); + SysTryCatch(NID_UI, pCanvas != null, , E_SYSTEM, "System error for accessibility popup"); + pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, popupWidth, popupHeight), *pBgBitmap); + int drawingTextY = topMargin; + pCanvas->DrawText(Point(sideMargin, drawingTextY), *pEnrichedTitleText); + drawingTextY += textTopMargin + titleHeight; + pCanvas->DrawText(Point(sideMargin, drawingTextY), *pEnrichedNameText); + drawingTextY += textHeight; + pCanvas->DrawText(Point(sideMargin, drawingTextY), *pEnrichedLableText); + drawingTextY += textHeight; + pCanvas->DrawText(Point(sideMargin, drawingTextY), *pEnrichedTraitText); + drawingTextY += textHeight; + pCanvas->DrawText(Point(sideMargin, drawingTextY), *pEnrichedStatusText); + drawingTextY += textHeight; + pCanvas->DrawText(Point(sideMargin, drawingTextY), *pEnrichedHintText); + drawingTextY += textHeight; + pCanvas->DrawText(Point(sideMargin, drawingTextY), *pEnrichedValueText); + drawingTextY += textHeight; + pCanvas->DrawText(Point(sideMargin, drawingTextY), *pEnrichedBoundsText); + drawingTextY += textHeight; + pCanvas->DrawText(Point(sideMargin, drawingTextY), *pEnrichedAbsBoundsText); + __pReadingVe->SetShowState(true); + __pReadingVe->SetFlushNeeded(); + pGuidePopupTimer->SetElement(__pReadingVe); + + } + //go through +CATCH: + delete pCanvas; + pCanvas = null; + delete pBgBitmap; + pBgBitmap = null; + if(pEnrichedTitleText) + { + pEnrichedTitleText->RemoveAll(true); + delete pEnrichedTitleText; + } + if(pEnrichedNameText) + { + pEnrichedNameText->RemoveAll(true); + delete pEnrichedNameText; + } + if(pEnrichedLableText) + { + pEnrichedLableText->RemoveAll(true); + delete pEnrichedLableText; + } + if(pEnrichedTraitText) + { + pEnrichedTraitText->RemoveAll(true); + delete pEnrichedTraitText; + } + if(pEnrichedStatusText) + { + pEnrichedStatusText->RemoveAll(true); + delete pEnrichedStatusText; + } + if(pEnrichedHintText) + { + pEnrichedHintText->RemoveAll(true); + delete pEnrichedHintText; + } + if(pEnrichedValueText) + { + pEnrichedValueText->RemoveAll(true); + delete pEnrichedValueText; + } + if(pEnrichedBoundsText) + { + pEnrichedBoundsText->RemoveAll(true); + delete pEnrichedBoundsText; + } + if(pEnrichedAbsBoundsText) + { + pEnrichedAbsBoundsText->RemoveAll(true); + delete pEnrichedAbsBoundsText; + } + + return; +} + +void +_AccessibilityManager::OnFinishReading(const Tizen::Base::String& grammar) +{ + if (__pReadingVe) + { + __pReadingVe->SetShowState(false); + } + return; +} + +String +_AccessibilityManager::GetCurrentGrammar(void) +{ + return L""; +} +void +_AccessibilityManager::AddContainer(const _AccessibilityContainer& container) +{ + __containerList.Add(&const_cast<_AccessibilityContainer&>(container)); + SetGestureMode(MODE_TAP); + return; +} +void +_AccessibilityManager::RemoveContainer(const _AccessibilityContainer& container) +{ + __containerList.Remove(&const_cast<_AccessibilityContainer&>(container)); + SetGestureMode(MODE_TAP); + if (__pTargetContainer == &container) + { + __pTargetContainer = null; + __pTargetElement = null; + } + return; +} + +void +_AccessibilityManager::MakeList(void) +{ + struct DownVisitor + { + DownVisitor(_Control& control, LinkedListT<_Control*>& list) + { + LinkedListT<_Control*> _list; + int count = control.GetChildCount(); + _Control* pControl = null; + for(int i = 0; i < count ; i++) + { + pControl = control.GetChild(i); + if(pControl) + { + _list.Add(pControl); + } + } + _AccessibilityItemComparer<_Control*> comparer; + _list.Sort(comparer); + int index = 0; + list.IndexOf(&control, index); + list.InsertItemsFrom(_list,index+1); + for(int i = 0; i < count ; i++) + { + pControl = control.GetChild(i); + DownVisitor(*pControl, list); + } + } + }; + if(GetGestureMode() == MODE_FOCUS_MOVE) + { + return; + } + result r = E_SUCCESS; + int count = 0; + _Control* pControl = null; + _AccessibilityContainer* pContainer = null; + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + LinkedListT<_Control*> controlList; + LinkedListT<_AccessibilityElement*> elementPositionList; + LinkedListT<_AccessibilityElement*> elementPositionByControlList; + __candidateList.RemoveAll(); + + if (pTouchManager) + { + pControl = pTouchManager->GetCapturedControl(); + if (pControl) + { + controlList.Add(pControl); + } + } + + if (pControl == null) + { + pControl = static_cast<_Control*>(_ControlManager::GetInstance()->GetWindow(_ControlManager::GetInstance()->GetWindowCount() - 1)); + controlList.Add(pControl); + } + DownVisitor(*pControl, controlList); + + for (int i = 0; i < controlList.GetCount() ; i++) + { + if (controlList.GetAt(i, pControl) == E_SUCCESS) + { + pContainer = pControl->GetAccessibilityContainer(); + if (pContainer == null) + { + continue; + } + if(IsContainerValid(pContainer)) + { + pContainer->SortElements(); + pContainer->GetElements(elementPositionList); + pContainer->GetElements(elementPositionByControlList); + } + } + } + bool done = false; + _ElementComparer<_AccessibilityElement*> comparer; + elementPositionList.Sort(comparer); + count = elementPositionList.GetCount(); + int index = 0; + _AccessibilityElement* pPositionListElement = null; + _AccessibilityElement* pPositionByControlListElement = null; + while (!done && index < count && index < count) + { + Rectangle rect; + r = elementPositionList.GetAt(index, pPositionListElement); + if (r != E_SUCCESS) + { + index++; + continue; + } + + r = elementPositionByControlList.GetAt(index, pPositionByControlListElement); + if (r != E_SUCCESS) + { + index++; + continue; + } + + if (pPositionListElement == pPositionByControlListElement) + { + __candidateList.Add(pPositionByControlListElement); + index++; + continue; + } + + if(pPositionListElement->GetParent()->GetPriority() > pPositionByControlListElement->GetParent()->GetPriority()) + { + elementPositionByControlList.Remove(pPositionListElement); + elementPositionByControlList.InsertAt(pPositionListElement, index > 2 ? index - 2 : 0); + __candidateList.Add(pPositionListElement); + index++; + continue; + } + else if(pPositionListElement->GetParent()->GetPriority() < pPositionByControlListElement->GetParent()->GetPriority()) + { + elementPositionList.Remove(pPositionByControlListElement); + elementPositionList.InsertAt(pPositionByControlListElement, index > 2 ? index - 2 : 0); + __candidateList.Add(pPositionByControlListElement); + index++; + continue; + } + + if (pPositionListElement->GetAbsoluteBounds().y > pPositionByControlListElement->GetAbsoluteBounds().y) + { + elementPositionList.Remove(pPositionByControlListElement); + elementPositionList.InsertAt(pPositionByControlListElement, index > 2 ? index - 2 : 0); + __candidateList.Add(pPositionByControlListElement); + index++; + continue; + } + else if (pPositionListElement->GetAbsoluteBounds().y < pPositionByControlListElement->GetAbsoluteBounds().y) + { + pControl = &(pPositionByControlListElement->GetParent()->GetOwner()); + while (pControl) + { + rect = pControl->GetAbsoluteBounds(); + if (rect.y >0) + { + break; + } + } + controlList.RemoveAll(); + controlList.Add(pControl); + DownVisitor(*pControl, controlList); + int _count = controlList.GetCount(); + LinkedListT<_AccessibilityElement*> _elementPositionList; + for (int i = 0; i < _count ; i++) + { + if (controlList.GetAt(i, pControl) == E_SUCCESS) + { + pContainer = pControl->GetAccessibilityContainer(); + if (pContainer == null) + { + continue; + } + if(IsContainerValid(pContainer)) + { + pContainer->GetElements(_elementPositionList); + } + } + } + _elementPositionList.Sort(comparer); + _count = _elementPositionList.GetCount(); + _AccessibilityElement* pElement = null; + for (int i = 0 ; i < _count ; i++) + { + r = _elementPositionList.GetAt(i, pElement); + if (r != E_SUCCESS) + { + continue; + } + __candidateList.Add(pElement); + elementPositionByControlList.Remove(pElement); + elementPositionByControlList.InsertAt(pElement, index ); + elementPositionList.Remove(pElement); + elementPositionList.InsertAt(pElement, index); + index++; + } + } + else + { + elementPositionList.Remove(pPositionByControlListElement); + elementPositionList.InsertAt(pPositionByControlListElement, index > 2 ? index - 2 : 0); + __candidateList.Add(pPositionByControlListElement); + index++; + continue; + } + } + + count = __candidateList.GetCount(); + if (count < 1) + { + return; + } + + _AccessibilityElement* pElement = null; + int fastScrollIndex = -1; + int listItemStartIndex = -1; + int listItemEndIndex = -1; + for (int i = 0 ; i < count ; i++) + { + r = __candidateList.GetAt(i, pElement); + if (r != E_SUCCESS) + { + continue; + } + if (pElement->GetName() == "HeaderTitleText") + { + __candidateList.Remove(pElement); + __candidateList.InsertAt(pElement, 0); + } + if(pElement->GetName() == L"ListViewItemText" ||pElement->GetName() == L"TableViewItem") + { + listItemEndIndex = i; + } + if (listItemStartIndex == -1 && (pElement->GetName() == L"ListViewItemText" ||pElement->GetName() == L"TableViewItem")) + { + listItemStartIndex = i; + } + if(fastScrollIndex == -1 && pElement->GetName() == L"FastScroll") + { + fastScrollIndex = i; + } + } + + if(listItemStartIndex != -1 && fastScrollIndex != -1) + { + if (fastScrollIndex > listItemStartIndex) + { + result r = __candidateList.GetAt(fastScrollIndex, pElement); + if (r == E_SUCCESS) + { + __candidateList.Remove(pElement); + __candidateList.InsertAt(pElement, listItemStartIndex); + } + } + } + + return; +} +void +_AccessibilityManager::MakeList(_AccessibilityContainer* pContainer) +{ + if (pContainer->GetOwner().IsVisible() && pContainer->IsActivated()) + { + pContainer->GetElements(__candidateList); + } + _Control* pControl = &(pContainer->GetOwner()); + int count = pControl->GetChildCount(); + for (int i = 0 ; iGetChild(i); + if (pChildControl) + { + MakeList(pChildControl->GetAccessibilityContainer()); + } + } + return; +} +bool +_AccessibilityManager::MoveFocus(_AccessibilityFocusDirection direction) +{ + if (direction == _ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS + || direction == _ACCESSIBILITY_FOCUS_DIRECTION_NEXT) + { + MakeList(); + } + else + { + return false; + } + + int count = __candidateList.GetCount(); + if (count <= 0) + { + return false; + } + result r = E_SUCCESS; + int index = 0; + _AccessibilityElement* pElement = null; + _AccessibilityContainer* pContainer = null; + bool eventFired = false; + if (IsContainerValid(__pTargetContainer)) + { + r = __candidateList.IndexOf(__pTargetElement, 0, index); + if (r != E_SUCCESS) + { + pElement = null; + __pTargetElement = null; + __pTargetContainer = null; + } + else + { + if ((__pTargetContainer->MoveFocus(direction))) + { + pElement = __pTargetContainer->GetCurrentFocusedElement(); + eventFired = true; + } + else + { + index += direction; + if (index < 0) + { + index = count - 1; + } + if (index > count - 1) + { + index = 0; + } + __candidateList.GetAt(index, pElement); + } + } + } + else + { + SysTryReturn(NID_UI, __candidateList.GetAt(0, pElement) == E_SUCCESS, false, E_SUCCESS, "[E_SUCCESS] Candidates are not exist."); + } + if (pElement) + { + if (__pTargetContainer) + { + __pTargetContainer->SetCurrentFocusedElement(null); + } + pContainer = pElement->GetParent(); + pContainer->SetCurrentFocusedElement(pElement); + if (!eventFired) + { + IListT<_IAccessibilityListener*>* pListenerList = pContainer->GetListenerListN(); + if (pListenerList) + { + int listenerCount = pListenerList->GetCount(); + if (listenerCount > 0) + { + for (int i = 0;iGetAt(i, pListener) == E_SUCCESS) + { + pListener->OnAccessibilityFocusOut(*__pTargetContainer, *__pTargetElement); + } + } + } + } + } + DrawFocusUi(*pContainer); + __pTargetElement = pElement; + __pTargetContainer = pContainer; + __targetControlHandle = pContainer->GetOwner().GetHandle(); + ReadElement(*pElement); + if (!eventFired) + { + IListT<_IAccessibilityListener*>* pListenerList = pContainer->GetListenerListN(); + if (pListenerList) + { + int listenerCount = pListenerList->GetCount(); + if (listenerCount > 0) + { + for (int i = 0;iGetAt(i, pListener) == E_SUCCESS) + { + pListener->OnAccessibilityFocusIn(*__pTargetContainer, *__pTargetElement); + if (direction == _ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS) + { + pListener->OnAccessibilityFocusMovedPrevious(*__pTargetContainer, *__pTargetElement); + } + else if (direction == _ACCESSIBILITY_FOCUS_DIRECTION_NEXT) + { + pListener->OnAccessibilityFocusMovedNext(*__pTargetContainer, *__pTargetElement); + } + } + } + } + } + } + return true; + } + return false; +} +void +_AccessibilityManager::RequestToDrawFocusUi() +{ + if (__pTargetContainer) + { + HidePopup(); + DrawFocusUi(*__pTargetContainer); + } +} + +void +_AccessibilityManager::RequestAutoReading(void) +{ + pAutoReadingTimer->Start(); +} + +void +_AccessibilityManager::DrawFocusUi(const _AccessibilityContainer& container) +{ + _AccessibilityElement* pElement = const_cast<_AccessibilityContainer&>(container).GetCurrentFocusedElement(); + if (pElement == null) + { + return; + } + + Rectangle rectangle = pElement->GetBounds(); + Canvas* pCanvas = null; + + if (!(__targetControlHandle.IsValid())) + { + __pFocusVe = null; + } + + if (&container != __pTargetContainer) + { + if (__pFocusVe) + { + __pFocusVe->Destroy(); + __pFocusVe = null; + } + result r = E_SUCCESS; + _Control* pControl = &const_cast<_Control&>(container.GetOwner()); + _VisualElement* pControlVe = pControl->GetVisualElement(); + + __pFocusVe = new (std::nothrow) VisualElement(); + SysTryCatch(NID_UI, pElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + SysTryReturn(NID_UI, __pFocusVe, , E_SYSTEM, "[E_SYSTEM] System error"); + r = __pFocusVe->Construct(); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error"); + + __pFocusVe->SetName("Accessibility focus ui"); + __pFocusVe->SetImplicitAnimationEnabled(false); + __pFocusVe->SetShowState(true); + pControlVe->AttachChild(*__pFocusVe); + } + + if (__pFocusVe) + { + __pFocusVe->SetBounds(FloatRectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height)); + pCanvas = __pFocusVe->GetCanvasN(); + SysTryCatch(NID_UI, pCanvas, , E_SYSTEM, "[E_SYSTEM] System error"); + pCanvas->SetBackgroundColor(0x55555555); + pCanvas->Clear(); + Bitmap* pBitmap = null; + result r = GET_BITMAP_CONFIG_N(ACCESSIBILITY::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + if (r == E_SUCCESS) + { + if (pBitmap->IsNinePatchedBitmap()) + { + r = pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, rectangle.width, rectangle.height), *pBitmap); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error"); + } + else + { + r = pCanvas->DrawBitmap(Rectangle(0, 0, rectangle.width, rectangle.height), *pBitmap); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error"); + } + } + __pFocusVe->SetShowState(true); + delete pCanvas; + } + + return; +CATCH: + delete pCanvas; + if (__pFocusVe) + { + __pFocusVe->Destroy(); + __pFocusVe = null; + } + return; +} +bool +_AccessibilityManager::ProcessGesture(_AccessibilityGestureType type, const Point& point, const _TouchGestureDetector* pDetector) +{ + switch(type) + { + case _ACCESSIBILITY_GESTURE_TYPE_FLICK_UP: + case _ACCESSIBILITY_GESTURE_TYPE_FLICK_LEFT: + if (MoveFocus(_ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS)) + { + SetGestureMode(MODE_FOCUS_MOVE); + } + break; + case _ACCESSIBILITY_GESTURE_TYPE_FLICK_DOWN: + case _ACCESSIBILITY_GESTURE_TYPE_FLICK_RIGHT: + if (MoveFocus(_ACCESSIBILITY_FOCUS_DIRECTION_NEXT)) + { + SetGestureMode(MODE_FOCUS_MOVE); + } + break; + case _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_ONE_TAP: + { + if (GetGestureMode() == MODE_FOCUS_MOVE) + { + SetGestureMode(MODE_TAP); + __candidateList.RemoveAll(); + } + _Control* pControl = _ControlManager::GetInstance()->GetTopmostTouchedControl(point); + if (pControl == null) + { + return false; + } + _AccessibilityContainer* pAccContainer = pControl->GetAccessibilityContainer(); + while(!(pAccContainer->IsActivated())) + { + _Control* _pControl = pAccContainer->GetOwner().GetParent(); + if (_pControl == null) + { + return false; + } + pAccContainer = _pControl->GetAccessibilityContainer(); + if (pAccContainer == null) + { + return false; + } + } + _AccessibilityElement* pElement = pAccContainer->Hit(point); + if (pElement == null) + { + return false; + } + + if (__pTargetElement == pElement) + { + if (__pPlayer) + { + AccessibilityScreenReaderStatus status = __pPlayer->GetStatus(); + if (status == ACCESSIBILITY_SCREEN_READER_STATUS_PLAYING) + { + return true; + } + } + } + else + { + if (IsContainerValid(__pTargetContainer)) + { + __pTargetContainer->ResetFocus(); + __pTargetContainer->GetOwner().Invalidate(); + } + if (!(pAccContainer->MoveFocus(point))) + { + return false; + } + DrawFocusUi(*pAccContainer); + __pTargetContainer = pAccContainer; + __targetControlHandle = pAccContainer->GetOwner().GetHandle(); + __pTargetElement = pElement; + } + + if (pElement != null) + { + ReadElement(*pElement); + } + } + break; + case _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_DOUBLE_TAP: + { + if (GetGestureMode() == MODE_FOCUS_MOVE) + { + SetGestureMode(MODE_TAP); + __candidateList.RemoveAll(); + } + if (__pTargetElement == null) + { + return true; + } + _TouchManager* pTouchMgr = _TouchManager::GetInstance(); + _Control* _pControl = null; + if (pTouchMgr == null) + { + return false; + } + if (IsContainerValid(__pTargetContainer)) + { + _pControl = &(__pTargetContainer->GetOwner()); + } + else + { + return false; + } + if (_pControl == null) + { + return false; + } + if (_pControl->GetEnableState() == false) + { + ReadContent(L"Unavailable"); + return true; + } + + if(__pTargetElement->GetSupportOperatingGesture()) + { + Rectangle rect = __pTargetElement->GetAbsoluteBounds(); + Point _point(rect.x + rect.width/2, rect.y + rect.height/2); + _UiTouchEvent pressedEvent(_pControl->GetHandle(), _TouchInfo(0, _TOUCH_PRESSED, _point, false, 0)); + _UiTouchEvent releasedEvent(_pControl->GetHandle(), _TouchInfo(0, _TOUCH_RELEASED, _point, false, 0)); + pressedEvent.SetAccessibilityEvent(true); + releasedEvent.SetAccessibilityEvent(true); + + unsigned int pointId = 0; + pointId = pTouchMgr->GeneratePointId(0); + SysLog(NID_UI, "Accessibility manager generated touch pressed event. id: %d", pointId); + _UiEventManager::GetInstance()->SendEvent(pressedEvent); + pointId = pTouchMgr->GetPointId(0); + SysLog(NID_UI, "Accessibility manager generated touch released event. id: %d", pointId); + _UiEventManager::GetInstance()->SendEvent(releasedEvent); + if (!IsContainerValid(__pTargetContainer)) + { + return false; + } + LinkedListT<_IAccessibilityListener*>* pList = static_cast*>(__pTargetContainer->GetListenerListN()); + if (pList != null) + { + int count = pList->GetCount(); + for (int i = 0;iGetAt(i, pListener) == E_SUCCESS) + { + pListener->OnAccessibilityActionPerformed(*__pTargetContainer, *__pTargetElement); + } + } + delete pList; + } + } + } + break; + + case _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_LONGPRESS: + SetGestureMode(MODE_TAP); + break; + case _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_PANNING_STARTED: + case _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_PANNING_CHANGED: + case _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_PANNING_FINISHED: + SetGestureMode(MODE_TAP); + break; + case _ACCESSIBILITY_GESTURE_TYPE_VALUE_INCREASED: + { + if (!IsContainerValid(__pTargetContainer)) + { + return false; + } + LinkedListT<_IAccessibilityListener*>* pList = static_cast*>(__pTargetContainer->GetListenerListN()); + if (pList != null) + { + int count = pList->GetCount(); + for (int i = 0;iGetAt(i, pListener) == E_SUCCESS) + { + pListener->OnAccessibilityValueIncreased(*__pTargetContainer, *(__pTargetContainer->GetCurrentFocusedElement())); + } + } + delete pList; + } + } + break; + case _ACCESSIBILITY_GESTURE_TYPE_VALUE_DECREASED: + { + if (!IsContainerValid(__pTargetContainer)) + { + return false; + } + LinkedListT<_IAccessibilityListener*>* pList = static_cast*>(__pTargetContainer->GetListenerListN()); + if (pList != null) + { + int count = pList->GetCount(); + for (int i = 0;iGetAt(i, pListener) == E_SUCCESS) + { + pListener->OnAccessibilityValueDecreased(*__pTargetContainer, *(__pTargetContainer->GetCurrentFocusedElement())); + } + } + delete pList; + } + } + break; + case _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_STARTED: + { + _Control* pControl = _ControlManager::GetInstance()->GetTopmostTouchedControl(point); + if (pControl == null) + { + return false; + } + + _UiTouchEvent pressedEvent(pControl->GetHandle(), _TouchInfo(0, _TOUCH_PRESSED, point, false, 0)); + pressedEvent.SetAccessibilityEvent(true); + _UiEventManager::GetInstance()->SendEvent(pressedEvent); + __pPanningControl = pControl; + SetGestureMode(MODE_PANNING); + } + break; + case _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_CHANGED: + { + if (__pPanningControl == null || GetGestureMode() != MODE_PANNING) + { + return false; + } + _UiTouchEvent movedEvent(__pPanningControl->GetHandle(), _TouchInfo(0, _TOUCH_MOVED, point, false, 0)); + movedEvent.SetAccessibilityEvent(true); + _UiEventManager::GetInstance()->SendEvent(movedEvent); + } + break; + case _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_FINISHED: + { + if (__pPanningControl == null || GetGestureMode() != MODE_PANNING) + { + return false; + } + _UiTouchEvent releasedEvent(__pPanningControl->GetHandle(), _TouchInfo(0, _TOUCH_RELEASED, point, false, 0)); + releasedEvent.SetAccessibilityEvent(true); + _UiEventManager::GetInstance()->SendEvent(releasedEvent); + __pPanningControl = null; + SetGestureMode(MODE_TAP); + } + break; + default: + SetGestureMode(MODE_TAP); + break; + } + return true; +} + +Tizen::Base::_HandleT<_AccessibilityContainer> +_AccessibilityManager::Register(_AccessibilityContainer* pObject) +{ + if (pObject == null) + { + return Tizen::Base::_HandleT<_AccessibilityContainer>(); + } + + return __objectManager.Register(*pObject); +} +void +_AccessibilityManager::Unregister(Tizen::Base::_HandleT <_AccessibilityContainer> handle) +{ + __objectManager.Unregister(handle); + return; +} + +void +_AccessibilityManager::OnAccessibilityScreenReaderIsActivated(bool set) +{ + if(__screenReaderIsEnabled == set) + { + return; + } + else + { + __screenReaderIsEnabled = set; + if(__screenReaderIsEnabled) + { + __pPlayer->Activate(); + } + else + { + __pPlayer->Deactivate(); + } + } +} +bool +_AccessibilityManager::IsAccessibilityActivated(void) +{ + return __pSettingLoader->IsAccessibilityActivated(); +} +bool +_AccessibilityManager::IsScreenReaderActivated(void) +{ + __screenReaderIsEnabled = __pSettingLoader->IsScreenReaderActivated(); + return __screenReaderIsEnabled; +} +int +_AccessibilityManager::GetLargeFontSize(void) +{ + return __pSettingLoader->GetLargeFontSize(); +} + +bool +_AccessibilityManager::IsActivated() +{ + return __screenReaderIsEnabled; +} + +bool +_AccessibilityManager::IsContainerValid(_AccessibilityContainer* pContainer) +{ + if (pContainer == null) + { + return false; + } + if (!(pContainer->IsActivated())) + { + return false; + } + if (!(pContainer->GetHandle().IsValid())) + { + return false; + } + if (!(pContainer->GetOwner().GetHandle().IsValid())) + { + return false; + } + if (!(pContainer->GetOwner().IsVisible())) + { + return false; + } + if (!IsVisible(pContainer)) + { + return false; + } + return true; +} +bool +_AccessibilityManager::IsTargetContainerValid(void) +{ + + if (__pTargetContainer && __targetControlHandle.IsValid() && __pTargetContainer->GetOwner().IsVisible() && __pTargetContainer->GetOwner().GetRootWindow() && IsVisible(__pTargetContainer)) + { + return true; + } + return false; +} +bool +_AccessibilityManager::IsVisible(_AccessibilityElement* pElement) +{ + return IsVisible(pElement->GetParent()); +} +bool +_AccessibilityManager::IsVisible(_AccessibilityContainer* pContainer) +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + int count = pControlManager->GetWindowCount(); + if (count < 1) + { + return false; + } + _Window* pTopWindow = pControlManager->GetWindow(count - 1); + if (pTopWindow != pContainer->GetOwner().GetRootWindow()) + { + return false; + } + return true; +} +void +_AccessibilityManager::SetGestureMode(GestureMode mode) +{ + __mode = mode; +} +_AccessibilityManager::GestureMode +_AccessibilityManager::GetGestureMode(void) +{ + return __mode; +} + +}} //Tizen::Ui + diff --git a/src/ui/FUi_AccessibilitySystemSettingLoader.cpp b/src/ui/FUi_AccessibilitySystemSettingLoader.cpp new file mode 100644 index 0000000..9241d22 --- /dev/null +++ b/src/ui/FUi_AccessibilitySystemSettingLoader.cpp @@ -0,0 +1,74 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include "FUi_AccessibilitySystemSettingLoader.h" +#include "FUi_AccessibilityManager.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EcoreEvas.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { + +bool _activated = false; +bool _screenReaderActivated = false; + +_AccessibilitySystemSettingLoader::_AccessibilitySystemSettingLoader(_AccessibilityManager& manager) + : __pManager(&manager) +{ + _screenReaderActivated = IsScreenReaderActivated(); + _activated = _screenReaderActivated; +} +_AccessibilitySystemSettingLoader::~_AccessibilitySystemSettingLoader(void) +{ +} +void +_AccessibilitySystemSettingLoader::OnSettingChanged(String& key) +{ +} + +bool +_AccessibilitySystemSettingLoader::IsAccessibilityActivated(void) +{ + return _activated; +} +bool +_AccessibilitySystemSettingLoader::IsScreenReaderActivated(void) +{ + return GetEcoreEvasMgr()->GetEcoreEvas()->IsAccessibilityScreenReaderActivated(); +} +int +_AccessibilitySystemSettingLoader::GetLargeFontSize(void) +{ + return -1; +} +void +_AccessibilitySystemSettingLoader::SetSystemSetting(const Tizen::Base::String key, bool value) +{ + if (key == L"AccessibilityActivationStatus") + { + _activated = value; + } + else if (key == L"ScreenReaderActivationStatus") + { + _screenReaderActivated = value; + _AccessibilityManager::GetInstance()->OnAccessibilityScreenReaderIsActivated(value); + } +} + +}} + diff --git a/src/ui/FUi_AccessibilityTtsPlayer.cpp b/src/ui/FUi_AccessibilityTtsPlayer.cpp new file mode 100644 index 0000000..11a8084 --- /dev/null +++ b/src/ui/FUi_AccessibilityTtsPlayer.cpp @@ -0,0 +1,161 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include +#include "FUi_AccessibilityTtsPlayer.h" +#include "FUi_AccessibilityManager.h" + +using namespace Tizen::Uix::Speech; + +namespace Tizen { namespace Ui { + +_AccessibilityTtsPlayer::_AccessibilityTtsPlayer(_AccessibilityManager& manager) + : __pTts(null) + ,__grammar(L"") + ,__localeIdx(-1) + ,__status(ACCESSIBILITY_SCREEN_READER_STATUS_ERROR) + ,__pManager(&manager) +{ +} +_AccessibilityTtsPlayer::~_AccessibilityTtsPlayer(void) +{ + delete __pTts; + __pTts = null; +} +result +_AccessibilityTtsPlayer::ReadGrammar(const Tizen::Base::String& grammar, bool bInit) +{ + if(grammar.GetLength() == 0) + { + return E_SUCCESS; + } + if(bInit && GetStatus() == ACCESSIBILITY_SCREEN_READER_STATUS_PLAYING) + { + StopReading(); + } + SetStatus(ACCESSIBILITY_SCREEN_READER_STATUS_PLAYING); + __grammar = grammar; + if (__pTts) + { + __pTts->Speak(grammar, TEXT_TO_SPEECH_REQUEST_MODE_REPLACE); + } + return E_SUCCESS; +} +result +_AccessibilityTtsPlayer::StopReading(void) +{ + if (__pTts) + { + __pTts->Stop(); + } + + return E_SUCCESS; +} +AccessibilityScreenReaderStatus +_AccessibilityTtsPlayer::GetStatus(void) +{ + return __status; +} +Tizen::Base::String +_AccessibilityTtsPlayer::GetCurrentGrammar(void) +{ + return __grammar; +} +result +_AccessibilityTtsPlayer::Activate(void) +{ + result r = E_FAILURE; + if (__pTts) + { + return E_SUCCESS; + } + __pTts = new (std::nothrow) TextToSpeech; + SysTryReturn(NID_UI, __pTts != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed"); + r = __pTts->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error"); + __pTts->Initialize(); + + return E_SUCCESS; + +CATCH: + delete __pTts; + __pTts = null; + return E_SYSTEM; +} +result +_AccessibilityTtsPlayer::Deactivate(void) +{ + StopReading(); + delete __pTts; + __pTts = null; + return E_SUCCESS; +} +void +_AccessibilityTtsPlayer::OnTextToSpeechInitialized(void) +{ + result r = E_SUCCESS; + Tizen::Locales::Locale locale(Tizen::Locales::LANGUAGE_ENG,Tizen::Locales::COUNTRY_US); + if (__pTts) + { + r=__pTts->SetLocale(locale); + SysTryReturn(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error"); + } +} + +void +_AccessibilityTtsPlayer::OnTextToSpeechCompleted(void) +{ + SetStatus(ACCESSIBILITY_SCREEN_READER_STATUS_READY); + __pManager->OnFinishReading(__grammar); +} + +void +_AccessibilityTtsPlayer::OnTextToSpeechErrorOccurred (TextToSpeechError error) +{ + Deactivate(); + Activate(); +} +void +_AccessibilityTtsPlayer::OnTextToSpeechStatusChanged (TextToSpeechStatus status) +{ + switch(status) + { + case TEXT_TO_SPEECH_STATUS_SYNTHESIZING: + SetStatus(ACCESSIBILITY_SCREEN_READER_STATUS_PLAYING); + __pManager->OnStartReading(__grammar); + break; + case TEXT_TO_SPEECH_STATUS_PLAYING: + SetStatus(ACCESSIBILITY_SCREEN_READER_STATUS_PLAYING); + break; + case TEXT_TO_SPEECH_STATUS_PAUSED: + break; + default: + break; + + } +} +void +_AccessibilityTtsPlayer::SetStatus(AccessibilityScreenReaderStatus status) +{ + __status = status; +} + +}} + diff --git a/src/ui/FUi_ActiveWindowEvent.cpp b/src/ui/FUi_ActiveWindowEvent.cpp new file mode 100644 index 0000000..1688f19 --- /dev/null +++ b/src/ui/FUi_ActiveWindowEvent.cpp @@ -0,0 +1,141 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ActiveWindowEvent.cpp + * @brief This is the implementation for the _ActiveWindowEvent class. + * @since 2.0 + */ +#include +#include +#include +#include "FUi_ActiveWindowEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::App; + +namespace Tizen { namespace Ui +{ + +class _ActiveWindowEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +public: + _ActiveWindowEventArg(unsigned int xid, int pid, char* pAppName); + + virtual ~_ActiveWindowEventArg(void); + + unsigned int GetWindowId(void) const; + int GetProcessId(void) const; + char* GetAppName(void) const; + +private: + _ActiveWindowEventArg(const _ActiveWindowEventArg& rhs); + _ActiveWindowEventArg& operator =(const _ActiveWindowEventArg& rhs); + +private: + unsigned int __xid; + int __pid; + char* __pAppName; +}; // _ActiveWindowEventArg + +_ActiveWindowEventArg::_ActiveWindowEventArg(unsigned int xid, int pid, char* pAppName) + : __xid(xid) + , __pid(pid) + , __pAppName(pAppName) +{ +} + +_ActiveWindowEventArg::~_ActiveWindowEventArg(void) +{ +} + +unsigned int +_ActiveWindowEventArg::GetWindowId(void) const +{ + return __xid; +} + +int +_ActiveWindowEventArg::GetProcessId(void) const +{ + return __pid; +} + +char* +_ActiveWindowEventArg::GetAppName(void) const +{ + return __pAppName; +} + +_ActiveWindowEvent* +_ActiveWindowEvent::CreateInstanceN(void) +{ + _ActiveWindowEvent* pActiveWindowEvent = new (std::nothrow) _ActiveWindowEvent(); + SysTryReturn(NID_UI, pActiveWindowEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pActiveWindowEvent; + +CATCH: + delete pActiveWindowEvent; + return null; +} + +IEventArg* +_ActiveWindowEvent::CreateActiveWindowEventArgN(unsigned int xid, int pid, char* pAppName) +{ + _ActiveWindowEventArg* pEventArg = new (std::nothrow) _ActiveWindowEventArg(xid, pid, pAppName); + SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + SetLastResult(E_SUCCESS); + + return pEventArg; +} + +_ActiveWindowEvent::~_ActiveWindowEvent(void) +{ +} + +void +_ActiveWindowEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _IActiveWindowEventListener* pEventListener = dynamic_cast <_IActiveWindowEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI, pEventListener, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + + const _ActiveWindowEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI, pArg, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + + pEventListener->OnActiveWindowChanged(pArg->GetWindowId(), pArg->GetProcessId(), pArg->GetAppName()); + + SetLastResult(E_SUCCESS); +} + +_ActiveWindowEvent::_ActiveWindowEvent(void) +{ + result r = _Event::Initialize(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_ActiveWindowEvent.h b/src/ui/FUi_ActiveWindowEvent.h new file mode 100644 index 0000000..4e1075f --- /dev/null +++ b/src/ui/FUi_ActiveWindowEvent.h @@ -0,0 +1,52 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ActiveWindowEvent.h + * @brief This is the header file for _ActiveWindowEvent class. + * @since 2.0 + * + */ +#ifndef _FUI_INTERNAL_ACTIVE_WINDOW_EVENT_H_ +#define _FUI_INTERNAL_ACTIVE_WINDOW_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class _ActiveWindowEvent + : public Tizen::Base::Runtime::_Event +{ +public: + static _ActiveWindowEvent* CreateInstanceN(void); + static Tizen::Base::Runtime::IEventArg* CreateActiveWindowEventArgN(unsigned int xid, int pid, char* pAppName); + + virtual ~_ActiveWindowEvent(void); + +private: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + + _ActiveWindowEvent(void); + + _ActiveWindowEvent(const _ActiveWindowEvent& rhs); + _ActiveWindowEvent& operator =(const _ActiveWindowEvent& rhs); +}; // _ActiveWindowEvent + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_ACTIVE_WINDOW_EVENT_H_ diff --git a/src/ui/FUi_CardLayoutImpl.cpp b/src/ui/FUi_CardLayoutImpl.cpp new file mode 100644 index 0000000..5ffa3fa --- /dev/null +++ b/src/ui/FUi_CardLayoutImpl.cpp @@ -0,0 +1,107 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_CardLayoutImpl.cpp + * @brief This is the implementation file for _CardLayoutImpl class. + * + * This file contains the implementation of _CardLayoutImpl class. + */ + +#include "FUi_CardLayoutImpl.h" + +namespace Tizen { namespace Ui +{ + +// _CardLayoutImpl implementation +_CardLayoutImpl::_CardLayoutImpl(CardLayout* pPublicLayout, _Layout::AbsoluteLayout* pCoreLayout) + : _LayoutImpl(pPublicLayout, pCoreLayout) +{ +} + +_CardLayoutImpl::~_CardLayoutImpl(void) +{ +} + +Tizen::Ui::LayoutType +_CardLayoutImpl::GetLayoutType(void) const +{ + return LAYOUT_CARD; +} + +_CardLayoutImpl* +_CardLayoutImpl::CreateCardLayoutImplN(CardLayout* pPublicLayout) +{ + ClearLastResult(); + + _Layout::AbsoluteLayout* pCoreLayout = null; + _CardLayoutImpl* pImplLayout = null; + result r = E_SUCCESS; + + pCoreLayout = _Layout::AbsoluteLayout::CreateAbsoluteLayoutN(true); + r = GetLastResult(); + SysTryReturn(NID_UI, pCoreLayout != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImplLayout = new (std::nothrow) _CardLayoutImpl(pPublicLayout, pCoreLayout); + r = CheckConstruction(pCoreLayout, pImplLayout); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImplLayout; +} + +const char* +_CardLayoutImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::CardLayout"; +} + +const CardLayout& +_CardLayoutImpl::GetPublic(void) const +{ + return static_cast (_LayoutImpl::GetPublic()); +} + +CardLayout& +_CardLayoutImpl::GetPublic(void) +{ + return static_cast (_LayoutImpl::GetPublic()); +} + +const _Layout::AbsoluteLayout& +_CardLayoutImpl::GetCore(void) const +{ + return static_cast (_LayoutImpl::GetCore()); +} + +_Layout::AbsoluteLayout& +_CardLayoutImpl::GetCore(void) +{ + return static_cast <_Layout::AbsoluteLayout&>(_LayoutImpl::GetCore()); +} + +const _CardLayoutImpl* +_CardLayoutImpl::GetInstance(const CardLayout& layout) +{ + return static_cast(_LayoutImpl::GetInstance(layout)); +} + +_CardLayoutImpl* +_CardLayoutImpl::GetInstance(CardLayout& layout) +{ + return static_cast<_CardLayoutImpl*>(_LayoutImpl::GetInstance(layout)); +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_CardLayoutImpl.h b/src/ui/FUi_CardLayoutImpl.h new file mode 100644 index 0000000..9f7a86b --- /dev/null +++ b/src/ui/FUi_CardLayoutImpl.h @@ -0,0 +1,135 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_CardLayoutImpl.h + * @brief This is the header file for _CardLayoutImpl class. + * + * This header file contains the declaration of _CardLayoutImpl class. + */ + +#ifndef _FUI_INTERNAL_CARD_LAYOUT_IMPL_H +#define _FUI_INTERNAL_CARD_LAYOUT_IMPL_H + +#include +#include "FUi_LayoutImpl.h" +#include "FUi_LayoutAbsoluteLayout.h" + +namespace Tizen { namespace Ui +{ + +class CardLayout; + +class _CardLayoutImpl + : public _LayoutImpl +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_CardLayoutImpl(void); + + /** + * Creates the instance of _CardLayoutImpl. + * + * @since 2.0 + * @return The instance of _CardLayoutImpl. + * @param[in] pPublicLayout The public class of relative layout. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + static _CardLayoutImpl* CreateCardLayoutImplN(CardLayout* pPublicLayout); + + /** + * Gets the name of public class. + * + * @since 2.0 + * @return The name of public class. + */ + virtual const char* GetPublicClassName(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual const CardLayout& GetPublic(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual CardLayout& GetPublic(void); + + /** + * Gets the core class. + * + * @since 2.0 + * @return The core class. + */ + virtual const _Layout::AbsoluteLayout& GetCore(void) const; + + /** + * Gets the core class. + * + * @since 2.0 + * @return The core class. + */ + virtual _Layout::AbsoluteLayout& GetCore(void); + + /** + * Gets the _CardLayoutImpl instance for the CardLayout. + * + * @since 2.0 + * @return The _CardLayoutImpl instance. + * @param[in] pLayout The CardLayout instance. + */ + static const _CardLayoutImpl* GetInstance(const CardLayout& layout); + + /** + * Gets the _CardLayoutImpl instance for the CardLayout. + * + * @since 2.0 + * @return The _CardLayoutImpl instance. + * @param[in] pLayout The CardLayout instance. + */ + static _CardLayoutImpl* GetInstance(CardLayout& layout); + + /** + * Gets the type of the layout. + * + * @since 2.0 + * @return The layout type + */ + virtual LayoutType GetLayoutType(void) const; + +protected: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _CardLayoutImpl(CardLayout* pPublicLayout, _Layout::AbsoluteLayout* pCoreLayout); +}; // _CardLayoutImpl + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_CARD_LAYOUT_IMPL_H diff --git a/src/ui/FUi_Clipboard.cpp b/src/ui/FUi_Clipboard.cpp new file mode 100644 index 0000000..0f0d3da --- /dev/null +++ b/src/ui/FUi_Clipboard.cpp @@ -0,0 +1,985 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_Clipboard.cpp + * @brief This is the implementation file for the _Clipboard class. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_Clipboard.h" +#include "FUi_ClipboardItem.h" +#include "FUi_ControlManager.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUiCtrl_PublicClipboardPopupEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Io; +using namespace Tizen::Media; +using namespace Tizen::Text; +using namespace Tizen::Ui::Controls; + +namespace +{ +const int _CLIPBOARD_ITEM_MAX = 12; +const int _CBHM_ITEM_MAX = 12; +const String _CLIPBOARD_DEFAULT_PATH = L"/tmp/clipboard_"; +const String _CLIPBOARD_DEFAULT_EXTENSION = L".png"; +} // Anonymous + +namespace Tizen { namespace Ui +{ +_Clipboard* _Clipboard::__pInstance = null; + +_Clipboard* +_Clipboard::GetInstance(void) +{ + if (__pInstance) + { + return __pInstance; + } + + if (_ControlManager::GetInstance()) + { + __pInstance = new (std::nothrow) _Clipboard; + SysAssert(__pInstance); + + return __pInstance; + } + + return null; +} + +void +_Clipboard::ReleaseInstance(void) +{ + if (__pInstance) + { + delete __pInstance; + __pInstance = null; + } +} + +_Clipboard::~_Clipboard(void) +{ + HidePopup(); + + if (__pPublicEvent) + { + delete __pPublicEvent; + __pPublicEvent = null; + } +} + +result +_Clipboard::CopyItem(const _ClipboardItem& item) +{ + SysTryReturn(NID_UI, IsValidDataType(item.GetDataType()), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The data type is invalid."); + + _ClipFormat format = ConvertToClipFormat(item.GetDataType()); + SysTryReturn(NID_UI, format != _CLIP_FORMAT_NONE, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The data type is invalid."); + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + char* pChar = null; + if (format == _CLIP_FORMAT_IMAGE) + { + const Bitmap* pBitmap = dynamic_cast (item.GetData()); + SysTryReturn(NID_UI, pBitmap, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The data is invalid."); + + pChar = CreateImageFileN(*pBitmap); + } + else + { + const String* pString = dynamic_cast (item.GetData()); + SysTryReturn(NID_UI, pString, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The data is invalid."); + + pChar = EncodeToCharN(*pString); + } + + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pEcoreEvas->CopyClip(format, pChar); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SysLog(NID_UI, "[Clipboard] Clip : format = [%d], char = [%s] is copied.", format, pChar); + + // fall through + +CATCH: + if (pChar) + { + free(pChar); + } + + return r; +} + +IList* +_Clipboard::RetrieveItemsN(unsigned long dataTypes) +{ + SysTryReturn(NID_UI, IsValidDataType(dataTypes), null, E_INVALID_ARG, + "[E_INVALID_ARG] The data type is invalid."); + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + int count = pEcoreEvas->GetClipCount(); + SysTryReturn(NID_UI, count > 0, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The item of the specified data types is not found."); + + LinkedList* pList = new (std::nothrow) LinkedList; + SysTryReturn(NID_UI, pList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + // Add items. + int format = _CLIP_FORMAT_NONE; + char* pData = null; + ClipboardDataType type = CLIPBOARD_DATA_TYPE_NONE; + for (int i = 0; i < count; i++) + { + // Get the clip with index. + bool ret = pEcoreEvas->RetrieveClipN(i, &format, &pData); + + if (ret == false) + { + SysLog(NID_UI, "It's failed to get the clip from _EcoreEvas."); + continue; + } + + //if (!pData) // prevent -> SLP CBHM + //{ + // SysLog(NID_UI, "It's failed to get the clip from _EcoreEvas."); + // continue; + //} + + type = ConvertToDataType(format, pData); + + if (!IsValidDataType(type)) + { + SysLog(NID_UI, "The type of a clip to be get form _EcoreEvas is invalid."); + free(pData); + continue; + } + + // If the clip to be get from _EcoreEvas is in agreement with dataTypes. + if (dataTypes & type) + { + result r = E_SUCCESS; + _ClipboardItem* pItem = null; + + if (type == CLIPBOARD_DATA_TYPE_IMAGE) + { + const Bitmap* pBitmap = LoadBitmapN(String(pData)); + r = GetLastResult(); + + if (!pBitmap || (r != E_SUCCESS)) + { + SysLog(NID_UI, "It's failed to load a bitmap."); + free(pData); + continue; + } + + pItem = _ClipboardItem::CreateInstanceN(type, *pBitmap); + if (!pItem) + { + SysLog(NID_UI, "It's failed to create a image item."); + } + + delete pBitmap; + free(pData); + } + else + { + pItem = _ClipboardItem::CreateInstanceN(type, String(pData)); + if (!pItem) + { + SysLog(NID_UI, "It's failed to create a clipboard item."); + } + + free(pData); + } + + if (pItem) + { + r = pList->Add(*pItem); + if (r != E_SUCCESS) + { + delete pItem; + SysLog(NID_UI, "It's failed to add a item into a list."); + } + + } + } + // [ToDo] + /* + else + { + free(pData); + } + */ + } + + SysTryCatch(NID_UI, pList->GetCount() > 0, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The item of the specified data types is not found."); + + SetLastResult(E_SUCCESS); + + return pList; + +CATCH: + delete pList; + return null; +} + +const _ClipboardItem* +_Clipboard::RetrieveLatestItemN(unsigned long dataTypes) +{ + SysTryReturn(NID_UI, IsValidDataType(dataTypes), null, E_INVALID_ARG, + "[E_INVALID_ARG] The data type is invalid."); + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + int count = pEcoreEvas->GetClipCount(); + SysTryReturn(NID_UI, count > 0, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The item of the specified data types is not found."); + + // Find the item with dataTypes. + int format = _CLIP_FORMAT_NONE; + char* pData = null; + ClipboardDataType type = CLIPBOARD_DATA_TYPE_NONE; + bool found = false; + for (int i = 0; i < count; i++) + { + // Get the clip with index. + bool ret = pEcoreEvas->RetrieveClipN(i, &format, &pData); + + if (ret == false) + { + SysLog(NID_UI, "It's failed to get the clip from _EcoreEvas."); + continue; + } + + //if (!pData) // prevent -> SLP CBHM + //{ + // SysLog(NID_UI, "It's failed to get the clip from _EcoreEvas."); + // continue; + //} + + type = ConvertToDataType(format, pData); + + if (!IsValidDataType(type)) + { + SysLog(NID_UI, "The type of a clip to be get form _EcoreEvas is invalid."); + free(pData); + continue; + } + + // If the clip to be get from _EcoreEvas is in agreement with dataTypes. + if (dataTypes & type) + { + found = true; + break; + } + else + { + free(pData); + } + } + + SysTryReturn(NID_UI, found == true, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The item of the specified data types is not found."); + + SysLog(NID_UI, "[Clipboard] Clip : format = [%d], char = [%s] is retrieved.", format, pData); + + result r = E_SUCCESS; + _ClipboardItem* pItem = null; + if (type == CLIPBOARD_DATA_TYPE_IMAGE) + { + const Bitmap* pBitmap = LoadBitmapN(String(pData)); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pItem = _ClipboardItem::CreateInstanceN(type, *pBitmap); + r = GetLastResult(); + + delete pBitmap; + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + pItem = _ClipboardItem::CreateInstanceN(type, String(pData)); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + free(pData); + + SetLastResult(E_SUCCESS); + + return pItem; + +CATCH: + if (pItem) + { + delete pItem; + } + + free(pData); + return null; +} + +result +_Clipboard::ShowPopup(unsigned long dataTypes, const IClipboardPopupEventListener &listener) +{ + SysTryReturn(NID_UI, IsPopupVisible() == false, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The popup is already shown."); + + result r = E_SUCCESS; + + if (__pPublicEvent == null) + { + __pPublicEvent = _PublicClipboardPopupEvent::CreateInstanceN(); + r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pPublicEvent->AddListener(listener); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + unsigned long clipFormats = _CLIP_FORMAT_NONE; + if (CLIPBOARD_DATA_TYPE_IMAGE & dataTypes) + { + clipFormats = _CLIP_FORMAT_IMAGE; + } + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + + pEcoreEvas->OpenClipboard(clipFormats); + + return r; +} + +result +_Clipboard::HidePopup(void) +{ + SysTryReturn(NID_UI, IsPopupVisible() == true, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The popup is not shown."); + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + pEcoreEvas->CloseClipboard(); + + if (__pPublicEvent) + { + delete __pPublicEvent; + __pPublicEvent = null; + } + + return E_SUCCESS; +} + +bool +_Clipboard::IsPopupVisible(void) +{ + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + + bool opened = pEcoreEvas->IsClipboardOpened(); + + SetLastResult(E_SUCCESS); + return opened; +} + +void +_Clipboard::FireEvent(int format, char* pData) +{ + if (!__pPublicEvent) + { + SysLog(NID_UI, "__pPublicEvent is null."); + + HidePopup(); + return; + } + + result r = E_SUCCESS; + _ClipboardItem* pItemCore = null; + ClipboardItem* pItem = null; + + if (pData) + { + ClipboardDataType type = ConvertToDataType(format, pData); + if (!IsValidDataType(type)) + { + SysLog(NID_UI, "The type of a clip to be get form _EcoreEvas is invalid."); + free(pData); + + HidePopup(); + return; + } + + if (type == CLIPBOARD_DATA_TYPE_IMAGE) + { + const Bitmap* pBitmap = LoadBitmapN(String(pData)); + r = GetLastResult(); + + if (!pBitmap || (r != E_SUCCESS)) + { + SysLog(NID_UI, "It's failed to load a bitmap."); + + if (pBitmap) + { + delete pBitmap; + } + free(pData); + + HidePopup(); + return; + } + + pItemCore = _ClipboardItem::CreateInstanceN(type, *pBitmap); + if (!pItemCore) + { + SysLog(NID_UI, "It's failed to create a image item."); + } + + delete pBitmap; + free(pData); + } + else + { + pItemCore = _ClipboardItem::CreateInstanceN(type, String(pData)); + if (!pItemCore) + { + SysLog(NID_UI, "It's failed to create a clipboard item."); + } + + free(pData); + } + + if (!pItemCore) + { + SysLog(NID_UI, "pItemCore is null."); + + HidePopup(); + return; + } + + pItem = new (std::nothrow) ClipboardItem; + pItem->Construct(pItemCore->GetDataType(), *(pItemCore->GetData())); + + delete pItemCore; + } + + IEventArg* pArg = _PublicClipboardPopupEvent::CreateClipboardPopupEventArgN(pItem); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, pArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicEvent->Fire(*pArg); + HidePopup(); + + SetLastResult(E_SUCCESS); +} + +_ClipFormat +_Clipboard::ConvertToClipFormat(ClipboardDataType type) +{ + _ClipFormat format = _CLIP_FORMAT_NONE; + switch (type) + { + case CLIPBOARD_DATA_TYPE_TEXT: + // fall through + case CLIPBOARD_DATA_TYPE_VIDEO: + // fall through + case CLIPBOARD_DATA_TYPE_AUDIO: + format = _CLIP_FORMAT_TEXT; + break; + case CLIPBOARD_DATA_TYPE_HTML: + format = _CLIP_FORMAT_HTML; + break; + case CLIPBOARD_DATA_TYPE_IMAGE: + format = _CLIP_FORMAT_IMAGE; + break; + default: + break; + } + + return format; +} + +ClipboardDataType +_Clipboard::ConvertToDataType(int format, const char* pData) +{ + ClipboardDataType type = CLIPBOARD_DATA_TYPE_NONE; + switch (format) + { + case _CLIP_FORMAT_TEXT: + if (IsVideoDataType(pData)) + { + type = CLIPBOARD_DATA_TYPE_VIDEO; + } + else if (IsAudioDataType(pData)) + { + type = CLIPBOARD_DATA_TYPE_AUDIO; + } + else + { + type = CLIPBOARD_DATA_TYPE_TEXT; + } + break; + case _CLIP_FORMAT_HTML: + type = CLIPBOARD_DATA_TYPE_HTML; + break; + case _CLIP_FORMAT_IMAGE: + type = CLIPBOARD_DATA_TYPE_IMAGE; + break; + default: + break; + } + + return type; +} + +char* +_Clipboard::EncodeToCharN(const String& string) +{ + Utf8Encoding encoder; + ByteBuffer* pByteBuffer = encoder.GetBytesN(string); + + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + char* pChar = strdup((char*)pByteBuffer->GetPointer()); + SysTryCatch(NID_UI, pChar, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + SetLastResult(E_SUCCESS); + + // fall through + +CATCH: + delete pByteBuffer; + return pChar; +} + +char* +_Clipboard::CreateImageFileN(const Bitmap& bitmap) +{ + // Obtain the buffer information from the bitmap. + Bitmap& tmpBitmap = const_cast(bitmap); + BufferInfo bufferInfo; + + result r = tmpBitmap.Lock(bufferInfo); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Create a source buffer. + ByteBuffer* pSrcBuf = new (std::nothrow) ByteBuffer; + SysTryReturn(NID_UI, pSrcBuf, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + int outLength = bufferInfo.width * bufferInfo.height * bufferInfo.bitsPerPixel / 8; + + BitmapPixelFormat bmpPixelFormat = bitmap.GetPixelColorFormat(); + MediaPixelFormat mediaPixelFormat = MEDIA_PIXEL_FORMAT_NONE; + ImageFormat imageFormat = IMG_FORMAT_PNG; + + ByteBuffer* pImageBuffer = null; + File file; + char* pChar = null; + String filePath; + bool existFile = false; + + r = pSrcBuf->Construct(outLength); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pSrcBuf->SetArray((const byte*)bufferInfo.pPixels, 0, outLength); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pSrcBuf->Flip(); + + // Decide formats. + switch (bmpPixelFormat) + { + case BITMAP_PIXEL_FORMAT_RGB565: + mediaPixelFormat = MEDIA_PIXEL_FORMAT_RGB565LE; + break; + case BITMAP_PIXEL_FORMAT_ARGB8888: + // fall through + case BITMAP_PIXEL_FORMAT_R8G8B8A8: + mediaPixelFormat = MEDIA_PIXEL_FORMAT_BGRA8888; + break; + default: + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + goto CATCH; + } + + // Encode for getting a image buffer. + pImageBuffer = _ImageEncoder::EncodeToBufferN(*pSrcBuf, bufferInfo.width, bufferInfo.height, mediaPixelFormat, imageFormat); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pSrcBuf; + pSrcBuf = null; + + // Create a image file. + filePath = CreateImageFilePath(); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = file.Construct(filePath, L"w+"); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + existFile = true; + + r = file.Write(*pImageBuffer); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pImageBuffer; + pImageBuffer = null; + + pChar = EncodeToCharN(filePath); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pChar; + +CATCH: + if (pSrcBuf) + { + delete pSrcBuf; + } + + if (pImageBuffer) + { + delete pImageBuffer; + } + + if (existFile) + { + File::Remove(filePath); + } + + if (pChar) + { + free(pChar); + } + + return null; +} + +String +_Clipboard::CreateImageFilePath(void) +{ + result r = RemoveUnnecessaryImageFiles(); + SysTryReturn(NID_UI, r == E_SUCCESS, String(""), r, "[%s] Propagating.", GetErrorMessage(r)); + + String filePath; + String extension(_CLIPBOARD_DEFAULT_EXTENSION); + + bool find = false; + for (int i = 0; i < _CLIPBOARD_ITEM_MAX; i++) + { + filePath = _CLIPBOARD_DEFAULT_PATH; + + r = filePath.Append(i); + SysTryReturn(NID_UI, r == E_SUCCESS, String(""), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = filePath.Append(extension); + SysTryReturn(NID_UI, r == E_SUCCESS, String(""), r, "[%s] Propagating.", GetErrorMessage(r)); + + if (File::IsFileExist(filePath) == false) + { + find = true; + break; + } + } + + SysTryReturn(NID_UI, find == true, String(""), E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + SetLastResult(E_SUCCESS); + + return filePath; +} + +result +_Clipboard::RemoveUnnecessaryImageFiles(void) +{ + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + result r = E_SUCCESS; + + int clipCount = pEcoreEvas->GetClipCount(); + if (clipCount < 1) + { + r = RemoveAllImageFiles(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + } + + ArrayList imageClipList; + + r = imageClipList.Construct(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int format = _CLIP_FORMAT_NONE; + char* pData = null; + for (int i = 0; i < clipCount; i++) + { + bool ret = pEcoreEvas->RetrieveClipN(i, &format, &pData); + + if (ret == false) + { + SysLog(NID_UI, "It's failed to get the clip from _EcoreEvas."); + continue; + } + + //if (!pData) // prevent -> SLP CBHM + //{ + // SysLog(NID_UI, "It's failed to get the clip from _EcoreEvas."); + // continue; + //} + + if (format == _CLIP_FORMAT_IMAGE) + { + String temp(pData); + int length = temp.GetLength(); + int defaultLength = _CLIPBOARD_DEFAULT_PATH.GetLength(); + + if (length < defaultLength) + { + free(pData); + continue; + } + + temp.Remove(defaultLength, length - defaultLength); + + int compare = temp.CompareTo(_CLIPBOARD_DEFAULT_PATH); + + if (compare == 0) + { + String* pString = new (std::nothrow) String(pData); + imageClipList.Add(*pString); + } + } + + free(pData); + } + + String filePath; + IEnumerator* pEnumerator = null; + + int imageClipCount = imageClipList.GetCount(); + + if (imageClipCount < 1) + { + r = RemoveAllImageFiles(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + } + else if (imageClipCount == _CBHM_ITEM_MAX) + { + String* plastImageClip = dynamic_cast(imageClipList.GetAt(_CBHM_ITEM_MAX - 1)); + SysTryCatch(NID_UI, plastImageClip, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + if (File::IsFileExist(*plastImageClip)) + { + r = File::Remove(*plastImageClip); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + pEnumerator = imageClipList.GetEnumeratorN(); + SysTryCatch(NID_UI, pEnumerator, , r, "[%s] Propagating.", GetErrorMessage(r)); + + for (int i = 0; i < _CLIPBOARD_ITEM_MAX; i++) + { + filePath = _CLIPBOARD_DEFAULT_PATH; + + r = filePath.Append(i); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = filePath.Append(_CLIPBOARD_DEFAULT_EXTENSION); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + bool equal = false; + while (pEnumerator->MoveNext() == E_SUCCESS) + { + String* pImageClip = dynamic_cast(pEnumerator->GetCurrent()); + SysTryCatch(NID_UI, pImageClip, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + equal = filePath.Equals(*pImageClip); + if (equal == true) + { + break; + } + } + + r = pEnumerator->Reset(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (equal == false) + { + if (File::IsFileExist(filePath)) + { + r = File::Remove(filePath); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + } + + // fall through + +CATCH: + imageClipList.RemoveAll(true); + + if (pEnumerator) + { + delete pEnumerator; + } + + return r; +} + +result +_Clipboard::RemoveAllImageFiles(void) +{ + String filePath; + result r = E_SUCCESS; + + for (int i = 0; i < _CLIPBOARD_ITEM_MAX; i++) + { + filePath = _CLIPBOARD_DEFAULT_PATH; + + r = filePath.Append(i); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = filePath.Append(_CLIPBOARD_DEFAULT_EXTENSION); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (File::IsFileExist(filePath)) + { + r = File::Remove(filePath); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + return r; +} + +Bitmap* +_Clipboard::LoadBitmapN(const String& path) +{ + result r = E_SUCCESS; + + String* pStr = const_cast(&path); + + int index = 0; + r = pStr->IndexOf(L"file://", 0, index); + + if (r != E_OBJ_NOT_FOUND) + { + pStr->Remove(0, 7); + } + + bool hasAlpha = _ImageUtil::HasAlphaChannel(*pStr); + + r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + BitmapPixelFormat bmpPixelFormat = BITMAP_PIXEL_FORMAT_RGB565; + MediaPixelFormat mediaPixelFormat = MEDIA_PIXEL_FORMAT_RGB565LE; + + if (hasAlpha == true) + { + bmpPixelFormat = BITMAP_PIXEL_FORMAT_ARGB8888; + mediaPixelFormat = MEDIA_PIXEL_FORMAT_BGRA8888; + } + + int bmpWidth = 0; + int bmpHeight = 0; + + // Decode. + ByteBuffer* pBuffer = _ImageDecoder::DecodeToBufferN(*pStr, mediaPixelFormat, bmpWidth, bmpHeight); + r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Create a bitmap. + Bitmap* pBitmap = _BitmapImpl::GetNonScaledBitmapN(*pBuffer, Dimension(bmpWidth, bmpHeight), bmpPixelFormat); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pBuffer; + + SetLastResult(E_SUCCESS); + + return pBitmap; + +CATCH: + delete pBuffer; + + if (pBitmap) + { + delete pBitmap; + } + + return null; +} + +bool +_Clipboard::IsValidDataType(unsigned long dataTypes) +{ + return ((CLIPBOARD_DATA_TYPE_TEXT & dataTypes) || + (CLIPBOARD_DATA_TYPE_HTML & dataTypes) || + (CLIPBOARD_DATA_TYPE_IMAGE & dataTypes) || + (CLIPBOARD_DATA_TYPE_VIDEO & dataTypes) || + (CLIPBOARD_DATA_TYPE_AUDIO & dataTypes)); +} + +bool +_Clipboard::IsVideoDataType(const char* pChar) +{ + // [ToDo] + return (strstr(pChar, ".mp4") != null); +} + +bool +_Clipboard::IsAudioDataType(const char* pChar) +{ + // [ToDo] + return (strstr(pChar, ".mp3") != null); +} + +_Clipboard::_Clipboard(void) + : __pPublicEvent(null) +{ +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_Clipboard.h b/src/ui/FUi_Clipboard.h new file mode 100644 index 0000000..6b5ce6a --- /dev/null +++ b/src/ui/FUi_Clipboard.h @@ -0,0 +1,97 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_Clipboard.h + * @brief This is the header file for the _Clipboard class. + * + * This header file contains the declarations of the %_Clipboard class. + */ +#ifndef _FUI_INTERNAL_CLIPBOARD_H_ +#define _FUI_INTERNAL_CLIPBOARD_H_ + +#include +#include +#include "FUi_Types.h" +#include "FUi_EcoreEvas.h" + +namespace Tizen { namespace Base { namespace Collection { +class IList; +}}} // Tizen::Base::Collection + +namespace Tizen { namespace Ui { namespace Controls { +class _PublicClipboardPopupEvent; +}}} // Tizen::Ui::Controls + +namespace Tizen { namespace Graphics { +class Bitmap; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui +{ +class _ClipboardItem; +class IClipboardPopupEventListener; + +class _Clipboard + : public Tizen::Base::Object +{ +public: + static _Clipboard* GetInstance(void); + static void ReleaseInstance(void); + + result CopyItem(const _ClipboardItem& item); + + Tizen::Base::Collection::IList* RetrieveItemsN(unsigned long dataTypes); + const _ClipboardItem* RetrieveLatestItemN(unsigned long dataTypes); + + result ShowPopup(unsigned long dataTypes, const IClipboardPopupEventListener &listener); + result HidePopup(void); + bool IsPopupVisible(void); + + void FireEvent(int format, char* pData); + +private: + _ClipFormat ConvertToClipFormat(ClipboardDataType type); + ClipboardDataType ConvertToDataType(int format, const char* pData); + + char* EncodeToCharN(const Tizen::Base::String& string); + + char* CreateImageFileN(const Tizen::Graphics::Bitmap& bitmap); + Tizen::Graphics::Bitmap* LoadBitmapN(const Tizen::Base::String& path); + + Tizen::Base::String CreateImageFilePath(void); + result RemoveUnnecessaryImageFiles(void); + result RemoveAllImageFiles(void); + + bool IsValidDataType(unsigned long dataTypes); + bool IsVideoDataType(const char* pChar); + bool IsAudioDataType(const char* pChar); + + _Clipboard(void); + virtual ~_Clipboard(void); + + _Clipboard(const _Clipboard& rhs); + _Clipboard& operator =(const _Clipboard& rhs); + +private: + Tizen::Ui::Controls::_PublicClipboardPopupEvent* __pPublicEvent; + + static _Clipboard* __pInstance; +}; // _Clipboard + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_CLIPBOARD_H_ diff --git a/src/ui/FUi_ClipboardImpl.cpp b/src/ui/FUi_ClipboardImpl.cpp new file mode 100644 index 0000000..60263bd --- /dev/null +++ b/src/ui/FUi_ClipboardImpl.cpp @@ -0,0 +1,297 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ClipboardImpl.cpp + * @brief This is the implementation file for the _ClipboardImpl class. + */ +#include +#include +#include +#include +#include +#include +#include "FUi_ClipboardImpl.h" +#include "FUi_Clipboard.h" +#include "FUi_ClipboardItemImpl.h" +#include "FUi_ClipboardItem.h" + +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui +{ + +_ClipboardImpl* +_ClipboardImpl::CreateInstanceN(void) +{ + _ClipboardImpl* pClipboardImpl = new (std::nothrow) _ClipboardImpl; + SysTryReturn(NID_UI, pClipboardImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + SetLastResult(E_SUCCESS); + + return pClipboardImpl; +} + +_ClipboardImpl::~_ClipboardImpl(void) +{ +} + +_Clipboard* +_ClipboardImpl::GetCore(void) +{ + return _Clipboard::GetInstance(); +} + +const _Clipboard* +_ClipboardImpl::GetCore(void) const +{ + return _Clipboard::GetInstance(); +} + +result +_ClipboardImpl::CopyItem(const _ClipboardItemImpl& item) +{ + SysAssert(GetCore()); + + result r = GetCore()->CopyItem(item.GetCore()); + + if ((r == E_INVALID_ARG) || (r == E_SYSTEM)) + { + SysLogException(NID_UI, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (r != E_SUCCESS) + { + r = E_SYSTEM; + SysLogException(NID_UI, r, "[E_SYSTEM] A system error occurred."); + } + + return r; +} + +Tizen::Base::Collection::IList* +_ClipboardImpl::RetrieveItemsN(unsigned long dataTypes) +{ + SysTryReturn(NID_UI, IsValidDataType(dataTypes), null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The item of the specified data types is not found."); + SysAssert(GetCore()); + + // Get items from _Clipboard. + IList* pRetrievedList = GetCore()->RetrieveItemsN(dataTypes); + result r = GetLastResult(); + + if ((r == E_OBJ_NOT_FOUND) || (r == E_OUT_OF_MEMORY) || (r == E_SYSTEM)) + { + SysLogException(NID_UI, r, "[%s] Propagating.", GetErrorMessage(r)); + return null; + } + + SysTryReturn(NID_UI, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + IEnumerator* pEnumerator = null; + _ClipboardItem* pItemCore = null; + ClipboardItem* pItem = null; + + // Make lists. + LinkedList* pList = new (std::nothrow) LinkedList; + SysTryCatch(NID_UI, pList, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pEnumerator = pRetrievedList->GetEnumeratorN(); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + // [ToDo] Use a template list. + pItemCore = dynamic_cast<_ClipboardItem*>(pEnumerator->GetCurrent()); + if (pItemCore) + { + pItem = new (std::nothrow) ClipboardItem; + SysTryCatch(NID_UI, pItem, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = pItem->Construct(pItemCore->GetDataType(), *(pItemCore->GetData())); + if (r != E_SUCCESS) + { + delete pItem; + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + goto CATCH; + } + + r = pList->Add(*pItem); + if (r != E_SUCCESS) + { + delete pItem; + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + goto CATCH; + } + } + } + + delete pEnumerator; + + pRetrievedList->RemoveAll(true); + delete pRetrievedList; + + SetLastResult(E_SUCCESS); + + return pList; + +CATCH: + pRetrievedList->RemoveAll(true); + delete pRetrievedList; + + if (pList) + { + pList->RemoveAll(true); + delete pList; + } + + if (pEnumerator) + { + delete pEnumerator; + } + + return null; +} + +_ClipboardItemImpl* +_ClipboardImpl::RetrieveLatestItemN(unsigned long dataTypes) +{ + SysTryReturn(NID_UI, IsValidDataType(dataTypes), null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The item of the specified data types is not found."); + SysAssert(GetCore()); + + const _ClipboardItem* pItemCore = GetCore()->RetrieveLatestItemN(dataTypes); + result r = GetLastResult(); + + ClipboardItem* pItem = null; + _ClipboardItemImpl* pItemImpl = null; + + if ((r == E_OBJ_NOT_FOUND) || (r == E_OUT_OF_MEMORY) || (r == E_SYSTEM)) + { + SysLogException(NID_UI, r, "[%s] Propagating.", GetErrorMessage(r)); + goto CATCH; + } + else if (r != E_SUCCESS) + { + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + goto CATCH; + } + + pItem = new (std::nothrow) ClipboardItem; + SysTryCatch(NID_UI, pItem, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = pItem->Construct(pItemCore->GetDataType(), *(pItemCore->GetData())); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + delete pItemCore; + + pItemImpl = _ClipboardItemImpl::GetInstance(*pItem); + + SetLastResult(E_SUCCESS); + + return pItemImpl; + +CATCH: + if (pItemCore) + { + delete pItemCore; + } + + if (pItem) + { + delete pItem; + } + + return null; +} + +result +_ClipboardImpl::ShowPopup(unsigned long dataTypes, const IClipboardPopupEventListener& listener) +{ + SysTryReturn(NID_UI, IsValidDataType(dataTypes), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + SysTryReturn(NID_UI, GetCore(), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + result r = GetCore()->ShowPopup(dataTypes, listener); + + if ((r == E_INVALID_OPERATION) || (r == E_SYSTEM)) + { + SysLogException(NID_UI, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (r != E_SUCCESS) + { + r = E_SYSTEM; + SysLogException(NID_UI, r, "[E_SYSTEM] A system error occurred."); + } + + return r; +} + +result +_ClipboardImpl::HidePopup(void) +{ + SysTryReturn(NID_UI, GetCore(), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + result r = GetCore()->HidePopup(); + + if ((r == E_INVALID_OPERATION) || (r == E_SYSTEM)) + { + SysLogException(NID_UI, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (r != E_SUCCESS) + { + r = E_SYSTEM; + SysLogException(NID_UI, r, "[E_SYSTEM] A system error occurred."); + } + + return r; +} + +bool +_ClipboardImpl::IsPopupVisible(void) +{ + if (GetCore() == null) + { + return false; + } + + return GetCore()->IsPopupVisible(); +} + +_ClipboardImpl* +_ClipboardImpl::GetInstance(Clipboard& clipboard) +{ + return clipboard.__pClipboardImpl; +} + +const _ClipboardImpl* +_ClipboardImpl::GetInstance(const Clipboard& clipboard) +{ + return clipboard.__pClipboardImpl; +} + +bool +_ClipboardImpl::IsValidDataType(unsigned long dataTypes) +{ + return ((CLIPBOARD_DATA_TYPE_TEXT & dataTypes) || + (CLIPBOARD_DATA_TYPE_HTML & dataTypes) || + (CLIPBOARD_DATA_TYPE_IMAGE & dataTypes) || + (CLIPBOARD_DATA_TYPE_VIDEO & dataTypes) || + (CLIPBOARD_DATA_TYPE_AUDIO & dataTypes)); +} + +_ClipboardImpl::_ClipboardImpl(void) +{ +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_ClipboardImpl.h b/src/ui/FUi_ClipboardImpl.h new file mode 100644 index 0000000..509ccd3 --- /dev/null +++ b/src/ui/FUi_ClipboardImpl.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ClipboardImpl.h + * @brief This is the header file for the _ClipboardImpl class. + * + * This header file contains the declarations of the %_ClipboardImpl class. + */ +#ifndef _FUI_INTERNAL_CLIPBOARD_IMPL_H_ +#define _FUI_INTERNAL_CLIPBOARD_IMPL_H_ + +#include + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +}}} // Tizen::Base::Collection + +namespace Tizen { namespace Ui +{ +class Clipboard; +class _ClipboardItemImpl; +class _Clipboard; +class IClipboardPopupEventListener; + +class _ClipboardImpl + : public Tizen::Base::Object +{ +public: + static _ClipboardImpl* CreateInstanceN(void); + virtual ~_ClipboardImpl(void); + + result CopyItem(const _ClipboardItemImpl& item); + + Tizen::Base::Collection::IList* RetrieveItemsN(unsigned long dataTypes); + _ClipboardItemImpl* RetrieveLatestItemN(unsigned long dataTypes); + + result ShowPopup(unsigned long dataTypes, const IClipboardPopupEventListener& listener); + result HidePopup(void); + bool IsPopupVisible(void); + + static _ClipboardImpl* GetInstance(Clipboard& clipboard); + static const _ClipboardImpl* GetInstance(const Clipboard& clipboard); + +private: + bool IsValidDataType(unsigned long dataTypes); + + _Clipboard* GetCore(void); + const _Clipboard* GetCore(void) const; + + _ClipboardImpl(void); + + _ClipboardImpl(const _ClipboardImpl& rhs); + _ClipboardImpl& operator =(const _ClipboardImpl& rhs); +}; // _ClipboardImpl + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_CLIPBOARD_IMPL_H_ diff --git a/src/ui/FUi_ClipboardItem.cpp b/src/ui/FUi_ClipboardItem.cpp new file mode 100644 index 0000000..584f2b7 --- /dev/null +++ b/src/ui/FUi_ClipboardItem.cpp @@ -0,0 +1,127 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ClipboardItem.cpp + * @brief This is the implementation file for the _ClipboardItem class. + */ +#include +#include +#include +#include +#include +#include "FUi_ClipboardItem.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ +_ClipboardItem* +_ClipboardItem::CreateInstanceN(ClipboardDataType type, const Object& data) +{ + _ClipboardItem* pItem = new (std::nothrow) _ClipboardItem(type, data); + SysTryReturn(NID_UI, pItem, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pItem; + +CATCH: + delete pItem; + return null; +} + +_ClipboardItem::~_ClipboardItem(void) +{ + if (__pString) + { + delete __pString; + __pString = null; + } + + if (__pBitmap) + { + delete __pBitmap; + __pBitmap = null; + } +} + +ClipboardDataType +_ClipboardItem::GetDataType(void) const +{ + return __type; +} + +const Object* +_ClipboardItem::GetData(void) const +{ + if (__type == CLIPBOARD_DATA_TYPE_IMAGE) + { + return __pBitmap; + } + else + { + return __pString; + } +} + +_ClipboardItem::_ClipboardItem(ClipboardDataType type, const Object& data) + : __type(type) + , __pString(null) + , __pBitmap(null) +{ + SysTryReturnVoidResult(NID_UI, + (CLIPBOARD_DATA_TYPE_TEXT & type) || + (CLIPBOARD_DATA_TYPE_HTML & type) || + (CLIPBOARD_DATA_TYPE_IMAGE & type) || + (CLIPBOARD_DATA_TYPE_VIDEO & type) || + (CLIPBOARD_DATA_TYPE_AUDIO & type) + , E_INVALID_ARG, "[E_INVALID_ARG] The data type is invalid."); + + if (type == CLIPBOARD_DATA_TYPE_IMAGE) + { + const Bitmap* pBitmap = dynamic_cast(&data); + SysTryReturnVoidResult(NID_UI, pBitmap, E_INVALID_ARG, "[E_INVALID_ARG] The data is invalid."); + + __pBitmap = new (std::nothrow) Bitmap; + SysTryReturnVoidResult(NID_UI, __pBitmap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = __pBitmap->Construct(*pBitmap, Rectangle(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight())); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + const String* pString = dynamic_cast(&data); + SysTryReturnVoidResult(NID_UI, pString, E_INVALID_ARG, "[E_INVALID_ARG] The data is invalid."); + + __pString = new (std::nothrow) String(*pString); + SysTryReturnVoidResult(NID_UI, __pString, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + } + + SetLastResult(E_SUCCESS); + + return; + +CATCH: + delete __pBitmap; + __pBitmap = null; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_ClipboardItem.h b/src/ui/FUi_ClipboardItem.h new file mode 100644 index 0000000..87e5bfa --- /dev/null +++ b/src/ui/FUi_ClipboardItem.h @@ -0,0 +1,61 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ClipboardItem.h + * @brief This is the header file for the _ClipboardItem class. + * + * This header file contains the declarations of the %_ClipboardItem class. + */ +#ifndef _FUI_INTERNAL_CLIPBOARD_ITEM_H_ +#define _FUI_INTERNAL_CLIPBOARD_ITEM_H_ + +#include +#include + +namespace Tizen { namespace Graphics { +class Bitmap; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui +{ +class _ClipboardItem + : public Tizen::Base::Object +{ +public: + static _ClipboardItem* CreateInstanceN(ClipboardDataType type, const Tizen::Base::Object& data); + + virtual ~_ClipboardItem(void); + + ClipboardDataType GetDataType(void) const; + const Tizen::Base::Object* GetData(void) const; + +private: + _ClipboardItem(ClipboardDataType type, const Tizen::Base::Object& data); + + _ClipboardItem(const _ClipboardItem& rhs); + _ClipboardItem& operator =(const _ClipboardItem& rhs); + +private: + ClipboardDataType __type; + + Tizen::Base::String* __pString; + Tizen::Graphics::Bitmap* __pBitmap; +}; // _ClipboardItem + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_CLIPBOARD_ITEM_H_ diff --git a/src/ui/FUi_ClipboardItemImpl.cpp b/src/ui/FUi_ClipboardItemImpl.cpp new file mode 100644 index 0000000..4628021 --- /dev/null +++ b/src/ui/FUi_ClipboardItemImpl.cpp @@ -0,0 +1,131 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ClipboardItemImpl.cpp + * @brief This is the implementation file for the _ClipboardItemImpl class. + */ +#include +#include +#include +#include +#include "FUi_ClipboardItemImpl.h" +#include "FUi_ClipboardItem.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui +{ + +_ClipboardItemImpl* +_ClipboardItemImpl::CreateInstanceN(ClipboardItem* pPublic, ClipboardDataType type, const Object& data) +{ + _ClipboardItem* pItemCore = _ClipboardItem::CreateInstanceN(type, data); + + _ClipboardItemImpl* pItemImpl = null; + + result r = GetLastResult(); + if ((r == E_OUT_OF_MEMORY) || (r == E_INVALID_ARG) || (r == E_SYSTEM)) + { + SysLogException(NID_UI, r, "[%s] Propagating.", GetErrorMessage(r)); + goto CATCH; + } + else if (r != E_SUCCESS) + { + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + goto CATCH; + } + + pItemImpl = new (std::nothrow) _ClipboardItemImpl(pPublic, pItemCore); + SysTryCatch(NID_UI, pItemImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + SetLastResult(E_SUCCESS); + + return pItemImpl; + +CATCH: + if (pItemCore) + { + delete pItemCore; + } + + return null; +} + +ClipboardDataType +_ClipboardItemImpl::GetDataType(void) const +{ + return GetCore().GetDataType(); +} + +Object* +_ClipboardItemImpl::GetData(void) const +{ + return const_cast(GetCore().GetData()); +} + +const ClipboardItem& +_ClipboardItemImpl::GetPublic(void) const +{ + return *__pPublic; +} + +ClipboardItem& +_ClipboardItemImpl::GetPublic(void) +{ + return *__pPublic; +} + +const _ClipboardItem& +_ClipboardItemImpl::GetCore(void) const +{ + return *__pCore; +} + +_ClipboardItem& +_ClipboardItemImpl::GetCore(void) +{ + return *__pCore; +} + +_ClipboardItemImpl* +_ClipboardItemImpl::GetInstance(ClipboardItem& clipboardItem) +{ + return clipboardItem.__pImpl; +} + +const _ClipboardItemImpl* +_ClipboardItemImpl::GetInstance(const ClipboardItem& clipboardItem) +{ + return static_cast (clipboardItem.__pImpl); +} + +_ClipboardItemImpl::_ClipboardItemImpl(ClipboardItem* pPublic, _ClipboardItem* pCore) + : __pPublic(pPublic) + , __pCore(pCore) +{ +} + +_ClipboardItemImpl::~_ClipboardItemImpl(void) +{ + if (__pCore) + { + delete __pCore; + __pCore = null; + } +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_ClipboardItemImpl.h b/src/ui/FUi_ClipboardItemImpl.h new file mode 100644 index 0000000..6742aff --- /dev/null +++ b/src/ui/FUi_ClipboardItemImpl.h @@ -0,0 +1,66 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ClipboardItemImpl.h + * @brief This is the header file for the _ClipboardItemImpl class. + * + * This header file contains the declarations of the %_ClipboardItemImpl class. + */ +#ifndef _FUI_INTERNAL_CLIPBOARD_ITEM_IMPL_H_ +#define _FUI_INTERNAL_CLIPBOARD_ITEM_IMPL_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class ClipboardItem; +class _ClipboardItem; + +class _ClipboardItemImpl + : public Tizen::Base::Object +{ +public: + static _ClipboardItemImpl* CreateInstanceN(ClipboardItem* pPublic, ClipboardDataType type, const Tizen::Base::Object& data); + + virtual ~_ClipboardItemImpl(void); + + ClipboardDataType GetDataType(void) const; + Tizen::Base::Object* GetData(void) const; + + static _ClipboardItemImpl* GetInstance(ClipboardItem& clipboardItem); + static const _ClipboardItemImpl* GetInstance(const ClipboardItem& clipboardItem); + + const ClipboardItem& GetPublic(void) const; + ClipboardItem& GetPublic(void); + const _ClipboardItem& GetCore(void) const; + _ClipboardItem& GetCore(void); + +private: + _ClipboardItemImpl(ClipboardItem* pPublic, _ClipboardItem* pCore); + + _ClipboardItemImpl(const _ClipboardItemImpl& rhs); + _ClipboardItemImpl& operator =(const _ClipboardItemImpl& rhs); + +private: + ClipboardItem* __pPublic; + _ClipboardItem* __pCore; +}; // _ClipboardItemImpl + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_CLIPBOARD_ITEM_IMPL_H_ diff --git a/src/ui/FUi_ContainerImpl.cpp b/src/ui/FUi_ContainerImpl.cpp new file mode 100644 index 0000000..e9c7bf8 --- /dev/null +++ b/src/ui/FUi_ContainerImpl.cpp @@ -0,0 +1,737 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ContainerImpl.cpp + * @brief This is the implementation file for _ContainerImpl class. + */ + +#include +#include +#include +#include "FUi_ContainerImpl.h" +#include "FUi_WindowImpl.h" +#include "FUi_Control.h" +#include "FUi_LayoutImpl.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { + +_ContainerImpl* +_ContainerImpl::CreateContainerImplN(Container* pPublic) +{ + ClearLastResult(); + + _Control* pCore = _Control::CreateControlN(); + result r = GetLastResult(); + SysTryReturn(NID_UI, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _ContainerImpl* pImpl = new (std::nothrow) _ContainerImpl(pPublic, pCore); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; +} + +_ContainerImpl* +_ContainerImpl::CreateContainerImplN(Container* pPublic, const Rectangle& bounds, + const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, + bool resizable, bool movable) +{ + result r = E_SUCCESS; + + _Control* pCore = _Control::CreateControlN(); + SysTryReturn(NID_UI, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + _ContainerImpl* pImpl = + new (std::nothrow) _ContainerImpl(pPublic, pCore, bounds, + pPublicPortraitLayout, pPublicLandscapeLayout, + resizable, movable); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + ClearLastResult(); + + return pImpl; +} + + +_ContainerImpl* +_ContainerImpl::GetInstance(Container& container) +{ + return static_cast <_ContainerImpl*> (container._pControlImpl); +} + +const _ContainerImpl* +_ContainerImpl::GetInstance(const Container& container) +{ + return static_cast (container._pControlImpl); +} + +_ContainerImpl::~_ContainerImpl(void) +{ + if (!HasCore()) + { + return; + } + + RemoveAllChildren(); +} + +const char* +_ContainerImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Container"; +} + +const Container& +_ContainerImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +Container& +_ContainerImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +// E_INVALID_ARG, E_OUT_OF_MEMORY +result +_ContainerImpl::AddChild(_ControlImpl* pChild, bool transferOwnership) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_UI, + pChild != null, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The specified child is not constructed."); + + SysTryReturn(NID_UI, + IsChildAttachable(*pChild), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] %s cannot be a child of %s.", + pChild->GetPublicClassName(), GetPublicClassName()); + + _ContainerImpl* pOldParent = pChild->GetParent(); + + SysTryReturn(NID_UI, + (pOldParent != this), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The child control is already attached to this container."); + + SysTryReturn(NID_UI, + pOldParent == null, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Unable to add the child which already has another parent."); + + r = __controlPublics.Add(pChild->GetPublic()); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_MEMORY); // I can't beleve Tizen::Base. + SysLogException(NID_UI, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + return E_OUT_OF_MEMORY; + } + + r = GetCore().AttachChild(pChild->GetCore()); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] propagated.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +// E_INVALID_ARG, E_OBJ_NOT_FOUND +result +_ContainerImpl::RemoveChild(_ControlImpl* pChild, bool deallocate) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_UI, + pChild != null, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The specified child is not constructed."); + + if (pChild->GetCore().GetArea() == _CONTROL_AREA_SYSTEM) + { + return E_SUCCESS; + } + + GetChildIndex(pChild); + r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetCore().DetachChild(pChild->GetCore()); + SysAssert(r == E_SUCCESS); + + r = __controlPublics.Remove(pChild->GetPublic(), deallocate); + SysAssert(r == E_SUCCESS); + + return E_SUCCESS; +} + +result +_ContainerImpl::RemoveChild(int index) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _ControlImpl* pChild = GetChild(index); // Find child control. + r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SysAssert(pChild); + SysTryReturn(NID_UI, pChild, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The child to remove is null."); + + GetCore().DetachChild(pChild->GetCore()); + SysAssert(GetLastResult() == E_SUCCESS); + + r = __controlPublics.Remove(pChild->GetPublic(), true); + SysAssert(r == E_SUCCESS); + + return E_SUCCESS; +} + +void +_ContainerImpl::RemoveAllChildren(bool detachSystemChild) +{ + ClearLastResult(); + result r = E_SUCCESS; + + GetCore().DetachAllChildren(detachSystemChild); + SysAssert(GetLastResult() == E_SUCCESS); + + if (detachSystemChild) + { + __controlPublics.RemoveAll(true); + } + else + { + int childCount = __controlPublics.GetCount(); + int itemIndex = 0; + + while (childCount--) + { + _ControlImpl* pControl = GetChild(itemIndex); + if (pControl->GetCore().GetArea() == _CONTROL_AREA_SYSTEM) + { + itemIndex++; + continue; + } + + r = __controlPublics.Remove(pControl->GetPublic(), true); + SysAssert(r == E_SUCCESS); + } + } +} + +result +_ContainerImpl::MoveChildToTop(const _ControlImpl& child) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_UI, + child.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Not my child."); + + r = GetCore().MoveChildToTop(child.GetCore()); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __controlPublics.Remove(child.GetPublic()); + SysAssert(r == E_SUCCESS); + + r = __controlPublics.Add(child.GetPublic()); + SysAssert(r == E_SUCCESS); + + return E_SUCCESS; +} + +result +_ContainerImpl::MoveChildBefore(const _ControlImpl& targetChild, const _ControlImpl& child) +{ + ClearLastResult(); + result r = E_SUCCESS; + int index = -1; + + SysTryReturn(NID_UI, + targetChild.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Not my targetChild."); + + SysTryReturn(NID_UI, + child.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Not my child."); + + r = GetCore().MoveChildBefore(targetChild.GetCore(), child.GetCore()); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __controlPublics.Remove(child.GetPublic()); + SysAssert(r == E_SUCCESS); + + r = __controlPublics.IndexOf(targetChild.GetPublic(), index); + SysAssert(r == E_SUCCESS); + + r = __controlPublics.InsertAt(child.GetPublic(), index); + SysAssert(r == E_SUCCESS); + + return E_SUCCESS; +} + +Tizen::Base::Collection::IList* +_ContainerImpl::GetChildrenPublic(void) const +{ + ClearLastResult(); + return const_cast (&__controlPublics); +} + +// E_OUT_OF_RANGE +_ControlImpl* +_ContainerImpl::GetChild(int index) const +{ + ClearLastResult(); + + const Control* pControl = static_cast (__controlPublics.GetAt(index)); + result r = GetLastResult(); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_RANGE); // I can't beleve Tizen::Base. + SysLogException(NID_UI, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range (index = %d, count = %d.)", + index, GetChildCount()); + + return null; + } + + SysAssert(pControl); + + return const_cast <_ControlImpl*>(_ControlImpl::GetInstance(*pControl)); +} + +_ControlImpl* +_ContainerImpl::SearchControlByName(const Tizen::Base::String& name, bool recursive, bool searchMyself) const +{ + ClearLastResult(); + + if (searchMyself == true || (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())) + { + if (name.CompareTo(GetName()) == 0) + { + return const_cast <_ContainerImpl*>(this); + } + } + + _ControlImpl* pChildFound = null; + for (int i = 0; i < __controlPublics.GetCount(); ++i) + { + _ControlImpl* pChild = GetChild(i); + + SysAssert(pChild); + if (pChild == null) + { + continue; + } + + _ContainerImpl* pChildAsContainer = dynamic_cast <_ContainerImpl*>(pChild); + if (pChildAsContainer && recursive) + { + pChildFound = pChildAsContainer->SearchControlByName(name, true, true); + if (pChildFound != null) + { + break; + } + } + else if (name.CompareTo(pChild->GetName()) == 0) + { + pChildFound = pChild; + break; + } + } + + return pChildFound; +} + +// [ToDo] Check if the public Container leaves the out-param index as it is. +int +_ContainerImpl::GetChildIndex(const _ControlImpl* pChild) const +{ + int index = -1; + + result r = __controlPublics.IndexOf(pChild->GetPublic(), index); + if (IsFailed(r)) + { + SysAssert(r == E_OBJ_NOT_FOUND); // I can't beleve Tizen::Base. + SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The control is not a child of this container."); + return -1; + } + + return index; +} + +int +_ContainerImpl::GetChildCount(void) const +{ + ClearLastResult(); + return __controlPublics.GetCount(); +} + +Layout* +_ContainerImpl::GetPublicPortraitLayoutN(void) const +{ + ClearLastResult(); + + Layout* pLayout = _LayoutImpl::CreatePublicLayoutN(__portraitLayout); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pLayout; +} + +Layout* +_ContainerImpl::GetPublicLandscapeLayoutN(void) const +{ + ClearLastResult(); + + Layout* pLayout = _LayoutImpl::CreatePublicLayoutN(__landscapeLayout); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pLayout; +} + +Layout* +_ContainerImpl::GetPublicLayoutN(void) const +{ + return (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE) ? + GetPublicLandscapeLayoutN() : GetPublicPortraitLayoutN(); +} + +result +_ContainerImpl::SetChildAt(const _ControlImpl* pChild, int index) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_UI, + pChild, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The specified child is not constructed."); + + // In API 2.0, (0 <= index) was not checked but checked at the ArrayList::SetAt(). + // So, I check the case here. No problem. + SysTryReturn(NID_UI, + (0 <= index && index < GetCore().GetChildCount()), E_OUT_OF_RANGE, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range (index = %d, count = %d)", + index, GetCore().GetChildCount()); + + // [ToDo] 2.0 bug: The error should be E_INVALID_ARG. + // And I think this must be checked before the range check. + _ContainerImpl* pParent = pChild->GetParent(); + SysTryReturn(NID_UI, + pParent == this, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] The container is not the parent of the specified control."); + + int oldIndex = GetCore().GetChildIndex(pChild->GetCore()); + SysAssert(GetLastResult() == E_SUCCESS); + + if (index == oldIndex) + { + return E_SUCCESS; + } + + r = __controlPublics.SetAt(*pChild, index); + SysAssert(r == E_SUCCESS); + + _Control* pTargetChild = GetCore().GetChild(index); + SysAssert(pTargetChild); + + r = GetCore().MoveChildBefore(*pTargetChild, pChild->GetCore()); + SysAssert(r == E_SUCCESS); + + return E_SUCCESS; +} + +bool +_ContainerImpl::IsAncestorOf(const _ControlImpl* pChild) const +{ + SysTryReturn(NID_UI, pChild, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified child is not constructed."); + return GetCore().IsAncestorOf(pChild->GetCore()); +} + +void +_ContainerImpl::OnDraw(void) +{ + GetPublic().OnClearBackground(); + + if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + GetCore().OnDraw(); + } + + GetPublic().OnDraw(); +} + +void +_ContainerImpl::OnChangeLayout(_ControlOrientation orientation) +{ + result r = E_SUCCESS; + _ControlImpl::OnChangeLayout(orientation); + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT && !__portraitLayout.IsNull()) + { + r = GetCore().SetCurrentLayout(__portraitLayout->GetCore()); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to set up the current layout as portrait"); + } + else if (orientation == _CONTROL_ORIENTATION_LANDSCAPE && !__landscapeLayout.IsNull()) + { + r = GetCore().SetCurrentLayout(__landscapeLayout->GetCore()); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to set up the current layout as landscape."); + } +} + +void +_ContainerImpl::OnVisibleStateChanging(void) +{ + GetPublic().OnShowStateChanging(GetVisibleState()); + _ControlImpl::OnVisibleStateChanging(); +} + +void +_ContainerImpl::OnVisibleStateChanged(void) +{ + GetPublic().OnShowStateChanged(GetVisibleState()); + _ControlImpl::OnVisibleStateChanged(); +} + +result +_ContainerImpl::OnBoundsChanging(const Rectangle& bounds) +{ + GetPublic().OnBoundsChanging(__oldBounds, bounds); + return _ControlImpl::OnBoundsChanging(bounds); +} + +void +_ContainerImpl::OnBoundsChanged(void) +{ + GetPublic().OnBoundsChanged(__oldBounds, GetBounds()); + _ControlImpl::OnBoundsChanged(); +} + +void +_ContainerImpl::OnEvaluateSize(Dimension& evaluatedSize) +{ + GetPublic().OnEvaluateSize(evaluatedSize); + _ControlImpl::OnEvaluateSize(evaluatedSize); +} + +void +_ContainerImpl::CallOnDraw(void) +{ + if (!_AppInfo::IsOspCompat()) + { + GetCore().OnDraw(); + } +} + +void +_ContainerImpl::Initialize(Control* pPublic, _Control* pCore, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout) +{ + result r = GetLastResult(); + if (IsFailed(r)) + { + return; + } + + _SharedPtr spPortraitLayout; + _SharedPtr spLandscapeLayout; + + // Check if all or none + SysAssert( + (pPublicPortraitLayout && pPublicLandscapeLayout) || + (!pPublicPortraitLayout && !pPublicLandscapeLayout) + ); + + if (pPublicPortraitLayout) + { + r = SetLayout(*pCore, _CONTROL_ORIENTATION_PORTRAIT, pPublicPortraitLayout); + if (IsFailed(r)) + { + return; + } + + r = pCore->SetCurrentLayout(__portraitLayout->GetCore()); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to set up the current layout."); + } + + if (pPublicLandscapeLayout) + { + r = SetLayout(*pCore, _CONTROL_ORIENTATION_LANDSCAPE, pPublicLandscapeLayout); + if (IsFailed(r)) + { + return; + } + } +} + +_ContainerImpl::_ContainerImpl(Control* pPublic, _Control* pCore, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout) + : _ControlImpl(pPublic, pCore) +{ + Initialize(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout); +} + +_ContainerImpl::_ContainerImpl(Control* pPublic, _Control* pCore, const Rectangle& bounds, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, bool resizable, bool movable) + : _ControlImpl(pPublic, pCore) +{ + result r = E_SUCCESS; + + Initialize(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout); + + r = GetLastResult(); + if (IsFailed(r)) + { + return; + } + + bool allOrNone = (pPublicPortraitLayout && pPublicLandscapeLayout) || (!pPublicPortraitLayout && !pPublicLandscapeLayout); + SysAssert(allOrNone); + + r = SetBounds(bounds); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCore->SetResizable(resizable); + pCore->SetMovable(movable); +} + +result +_ContainerImpl::SetLayout(_Control& core, _ControlOrientation orientation, const Layout* pPublicLayout) +{ + SysAssert(pPublicLayout); + + result r = E_SUCCESS; + + const char* orientationStatus = (orientation == _CONTROL_ORIENTATION_PORTRAIT) ? + "portrait" : "landscape"; + + _SharedPtr & spLayout = (orientation == _CONTROL_ORIENTATION_PORTRAIT) ? + __portraitLayout : __landscapeLayout; + + spLayout = _LayoutImpl::GetLayoutImpl(const_cast (pPublicLayout)); + SysTryReturn(NID_UI, + !spLayout.IsNull(), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The %s layout is invalid object", orientationStatus); + + r = core.AddLayout(spLayout->GetCore()); + if (IsFailed(r)) + { + switch (r) + { + case E_INVALID_ARG: + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] The %s layout is already used.", orientationStatus); + break; + default: + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Failed to add the %s layout.", orientationStatus); + } + + return r; + } + + return E_SUCCESS; +} + +bool +_ContainerImpl::IsChildAttachable(_ControlImpl& child) const +{ + if (dynamic_cast <_WindowImpl*>(&child) != null) + { + return false; + } + + return true; +} + + +result +_ContainerImpl::SetControlAlwaysOnTop(Control& control, bool alwaysOnTop) +{ + _ControlImpl* pChild = _ControlImpl::GetInstance(control); + SysTryReturn(NID_UI, + pChild, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The specified chlid control is not constructed."); + + _Control& childCore = pChild->GetCore(); + const bool atBottom = childCore.GetLayer() == _CONTROL_LAYER_CLIENT_BOTTOM; + + if (atBottom && !alwaysOnTop) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The bottom child cannot be reset."); + return E_INVALID_OPERATION; + } + + return alwaysOnTop ? + GetCore().SetChildAlwaysOnTop(childCore) : + GetCore().ResetChildLayer(childCore); +} + +result +_ContainerImpl::SetControlAlwaysAtBottom(Control& control, bool alwaysAtBottom) +{ + _ControlImpl* pChild = _ControlImpl::GetInstance(control); + SysTryReturn(NID_UI, + pChild, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The specified chlid control is not constructed."); + + _Control& childCore = pChild->GetCore(); + const bool onTop = childCore.GetLayer() == _CONTROL_LAYER_CLIENT_TOP; + + if (onTop && !alwaysAtBottom) + { + SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The top child cannot be reset."); + return E_INVALID_OPERATION; + } + + return alwaysAtBottom ? + GetCore().SetChildAlwaysAtBottom(childCore) : + GetCore().ResetChildLayer(childCore); +} + +bool +_ContainerImpl::IsControlAlwaysAtBottom(const Control& control) const +{ + const _ControlImpl* pChild = _ControlImpl::GetInstance(control); + SysTryReturn(NID_UI, + pChild, false, + E_INVALID_ARG, "[E_INVALID_ARG] The specified chlid control is not constructed."); + + SysTryReturn(NID_UI, + pChild->GetParent() == this, false, + E_INVALID_ARG, "[E_INVALID_ARG] The specified chlid control is not a child of this container."); + + return pChild->GetCore().GetLayer() == _CONTROL_LAYER_CLIENT_BOTTOM; +} + +bool +_ContainerImpl::IsControlAlwaysOnTop(const Control& control) const +{ + const _ControlImpl* pChild = _ControlImpl::GetInstance(control); + SysTryReturn(NID_UI, + pChild, false, + E_INVALID_ARG, "[E_INVALID_ARG] The specified chlid control is not constructed."); + + SysTryReturn(NID_UI, + pChild->GetParent() == this, false, + E_INVALID_ARG, "[E_INVALID_ARG] The specified chlid control is not a child of this container."); + + return pChild->GetCore().GetLayer() == _CONTROL_LAYER_CLIENT_TOP; +} + +}} //Tizen::Ui diff --git a/src/ui/FUi_Control.cpp b/src/ui/FUi_Control.cpp new file mode 100644 index 0000000..e8be5e7 --- /dev/null +++ b/src/ui/FUi_Control.cpp @@ -0,0 +1,4309 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_Control.cpp + * @brief This is the implementation file for the _Control class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_Control.h" +#include "FUi_ControlManager.h" +#include "FUi_Window.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EcoreEvas.h" +#include "FUi_LayoutLayoutContainer.h" +#include "FUi_LayoutAbsoluteLayout.h" +#include "FUi_LayoutILayoutItemHandler.h" +#include "FUi_TouchManager.h" +#include "FUi_DataBindingContext.h" +#include "FUi_TouchLongPressGestureDetector.h" +#include "FUi_TouchTapGestureDetector.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiAnim_ControlVisualElement.h" +#include "FUiAnim_VisualElementImpl.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Frame.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace { + +int +GetZOrderGroupOfVisualElement(_ControlLayer layer) +{ + switch (layer) + { + case _CONTROL_LAYER_OVERLAY: + return _ControlVisualElement::Z_ORDER_GROUP_CONTROL - 1; + case _CONTROL_LAYER_CLIENT_BOTTOM: + return _ControlVisualElement::Z_ORDER_GROUP_CONTROL; + case _CONTROL_LAYER_NONE: + // fall through + case _CONTROL_LAYER_CLIENT_MIDDLE: + return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 1; + case _CONTROL_LAYER_CLIENT_TOP: + return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 2; + case _CONTROL_LAYER_SYSTEM: + return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 3; + default: + SysAssert(false); + return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 1; + } +} + +inline bool +AdjustSizeToRange(int& width, int& height, const Dimension& minDim, const Dimension& maxDim) +{ + bool changed = false; + if (width < minDim.width) + { + width = minDim.width; + changed = true; + } + if (height < minDim.height) + { + height = minDim.height; + changed = true; + } + + if (width > maxDim.width) + { + width = maxDim.width; + changed = true; + } + if (height > maxDim.height) + { + height = maxDim.height; + changed = true; + } + + return changed; +} + +inline bool +AdjustSizeToRange(Dimension& dim, const Dimension& minDim, const Dimension& maxDim) +{ + return AdjustSizeToRange(dim.width, dim.height, minDim, maxDim); +} + +// E_OUT_OF_MEMORY +// E_SYSTEM +_ControlVisualElement* +CreateVisualElementN(void) +{ + ClearLastResult(); + + _ControlVisualElement* pVisualElement = new (std::nothrow) _ControlVisualElement; + SysTryReturn(NID_UI, pVisualElement, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + SysTryCatch(NID_UI, + pVisualElement->ConstructControlVisualElement() == E_SUCCESS, , + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + pVisualElement->SetImplicitAnimationEnabled(false); + pVisualElement->SetShowState(true); + pVisualElement->SetBackBufferEnabled(true); + pVisualElement->SetRedrawOnResizeEnabled(true); + pVisualElement->SetSurfaceOpaque(false); + + return pVisualElement; + +CATCH: + //delete pVisualElement; + pVisualElement->Destroy(); + return null; +} + +_Control::GestureMap* +CreateGestureMapN(void) +{ + ClearLastResult(); + + _Control::GestureMap* pGestureMap = new (std::nothrow) _Control::GestureMap; + SysTryReturn(NID_UI, pGestureMap, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + SysTryCatch(NID_UI, + pGestureMap->Construct() == E_SUCCESS, , + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return pGestureMap; + +CATCH: + delete pGestureMap; + return null; +} + +// E_OUT_OF_MEMORY +_Control::ControlList* +CreateControlListN(void) +{ + ClearLastResult(); + + _Control::ControlList* pControlList = new (std::nothrow) _Control::ControlList; + SysTryReturn(NID_UI, pControlList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pControlList; +} + +// E_OUT_OF_MEMORY +_Control::WindowList* +CreateWindowListN(void) +{ + ClearLastResult(); + + _Control::WindowList* pWindowList = new (std::nothrow) _Control::WindowList; + SysTryReturn(NID_UI, pWindowList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pWindowList; +} + +// E_OUT_OF_MEMORY +// E_SYSTEM +_Layout::LayoutContainer* +CreateLayoutContainerN(_Layout::ILayoutItemHandler* pLayoutItemHandler) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _Layout::LayoutContainer* pLayoutContainer = null; + _Layout::AbsoluteLayout* pAbsLayout = null; + + pLayoutContainer = new (std::nothrow) _Layout::LayoutContainer(); + SysTryReturn(NID_UI, pLayoutContainer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage"); + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + pAbsLayout = new (std::nothrow) _Layout::AbsoluteLayout(); + SysTryCatch(NID_UI, pAbsLayout, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + pLayoutContainer->SetItemHandler(pLayoutItemHandler); + + r = pLayoutContainer->SetDefaultLayout(*pAbsLayout); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return pLayoutContainer; + +CATCH: + delete pAbsLayout; + delete pLayoutContainer; + + return null; +} + +} // Anonymous namespace + +namespace Tizen { namespace Ui +{ + +IMPLEMENT_PROPERTY(_Control); + +class _Control::ControlVisualElementContentProvider + : public VisualElementContentProvider +{ + +private: + _Control& __control; + +public: + ControlVisualElementContentProvider(_Control& control) + : __control(control) + { + } + + virtual ~ControlVisualElementContentProvider(void) + { + } + + virtual bool PrepareDraw(VisualElement& target) + { + _ControlVisualElement* pCVE = dynamic_cast <_ControlVisualElement*>(&target); + if (!pCVE) + { + return false; + } + + Color bgColor = __control.GetBackgroundColor(); + + pCVE->SetBackgroundColor( + _Colorf( + (float) bgColor.GetRed() / 255.0f, + (float) bgColor.GetGreen() / 255.0f, + (float) bgColor.GetBlue() / 255.0f, + (float) bgColor.GetAlpha() / 255.0f + ) + ); + + __control.GetControlDelegate().OnDraw(); + + target.SetFlushNeeded(); + + return false; + } + + virtual HitTestResult HitTest(VisualElement& target, const FloatPoint& point) + { + return __control.GetControlDelegate().HitTest(point); + } + +private: + ControlVisualElementContentProvider(const ControlVisualElementContentProvider& rhs); + ControlVisualElementContentProvider& operator =(const ControlVisualElementContentProvider& rhs); +}; + +class _Control::ControlVisualElementEventListener + : public IVisualElementEventListener +{ +public: + ControlVisualElementEventListener(_Control& control) + : __control(control) + { + } + + virtual ~ControlVisualElementEventListener(void) + { + } + +public: + virtual void OnChildAttached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& child) + { + } + + virtual void OnChildDetached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& child) + { + } + + virtual void OnAttached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& parent) + { + } + + virtual void OnDetached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& parent) + { + } + + virtual result OnTransformChanging(Tizen::Ui::Animations::VisualElement& source, FloatMatrix4& newTransform) + { + return E_SUCCESS; + } + + virtual void OnTransformChanged(Tizen::Ui::Animations::VisualElement& source, const FloatMatrix4& previousTransform) + { + } + + virtual result OnChildrenTransformChanging(Tizen::Ui::Animations::VisualElement& source, FloatMatrix4& newTransform) + { + for (int i = 0; i < __control.GetChildCount(); ++i) + { + _Control* pChild = __control.GetChild(i); + if (!pChild) + { + continue; + } + + if (pChild->GetArea() == _CONTROL_AREA_SYSTEM) + { + _VisualElement* pVisualElement = pChild->GetVisualElement(); + if (pVisualElement) + { + FloatMatrix4 inverseMatrix(newTransform); + inverseMatrix.Invert(); + + result r = pVisualElement->SetTransformMatrix(inverseMatrix); + if (r != E_SUCCESS) + { + continue; + } + } + } + } + + return E_SUCCESS; + } + + virtual void OnChildrenTransformChanged(Tizen::Ui::Animations::VisualElement& source, const FloatMatrix4& previousTransform) + { + } + + virtual result OnBoundsChanging(Tizen::Ui::Animations::VisualElement& source, FloatRectangle& newBounds) + { + return E_SUCCESS; + } + + virtual void OnBoundsChanged(Tizen::Ui::Animations::VisualElement& source, const FloatRectangle& previousBounds) + { + } + + virtual void OnShowStateChanged(Tizen::Ui::Animations::VisualElement& source, bool previousShowState) + { + } + +private: + ControlVisualElementEventListener(const ControlVisualElementEventListener& rhs); + ControlVisualElementEventListener& operator =(const ControlVisualElementEventListener& rhs); + +private: + _Control& __control; +}; // ControlVisualElementEventListener + +// Layout Item Handler +class _Control::LayoutItemHandler + : public _Layout::ILayoutItemHandler +{ +public: + LayoutItemHandler(_Control* pControl) + : __pControl(pControl) + { + SysAssert(__pControl); + } + + void SetItemVisibleState(bool visible) + { + __pControl->SetVisibleState(visible); + } + + result SetItemBounds(const Rectangle& rect) + { + SysAssert(__pControl->IsInSizeRange(Dimension(rect.width, rect.height))); + FloatRectangle floatBounds(rect.x, rect.y, rect.width, rect.height); + return __pControl->SetBoundsFinal(floatBounds, false, true); + } + + Rectangle GetItemBounds(void) const + { + return __pControl->GetBounds(); + } + + Rectangle GetItemClientBoundsFromSize(const Dimension& size) const + { + return __pControl->GetClientBounds(size); + } + + Dimension GetItemContentSize(void) const + { + return __pControl->GetControlDelegate().GetContentSize(); + } + + Dimension GetItemMinimumSize(void) const + { + return __pControl->GetMinimumSize(); + } + + Dimension GetItemMaximumSize(void) const + { + return __pControl->GetMaximumSize(); + } + + result OnItemMeasure(int& width, int& height) + { + Dimension evaluatedSize(width, height); + __pControl->GetControlDelegate().OnEvaluateSize(evaluatedSize); + + width = evaluatedSize.width; + height = evaluatedSize.height; + + return E_SUCCESS; + } + +private: + LayoutItemHandler(const LayoutItemHandler& rhs); + LayoutItemHandler& operator =(const LayoutItemHandler& rhs); + +private: + _Control* __pControl; +}; // LayoutItemHandler + +// E_OUT_OF_MEMORY +// E_SYSTEM +_Control* +_Control::CreateControlN(void) +{ + _Control* pControl = new (std::nothrow) _Control; + SysTryReturn(NID_UI, pControl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + pControl->AcquireHandle(); + + SysAssert(GetLastResult() == E_SUCCESS); + return pControl; + +CATCH: + delete pControl; + return null; +} + +void +_Control::ResetEventListeners(void) +{ + __pFocusEventListener = this; + __pNotificationEventListener = this; +} + +void +_Control::SetControlDelegate(_IControlDelegate& delegate) +{ + __pControlDelegate = &delegate; +} + +void +_Control::ResetControlDelegate(void) +{ + __pControlDelegate = this; +} + +_IControlDelegate& +_Control::GetControlDelegate(void) const +{ + if (__destroying) + { + return const_cast<_Control&>(*this); + } + + SysAssert(__pControlDelegate); + return *__pControlDelegate; +} + +void +_Control::SetPropagatedTouchEventListener(_IPropagatedTouchEventListener* pListener) +{ + __pPropagatedTouchEventListener = pListener; +} + +_IPropagatedTouchEventListener* +_Control::GetPropagatedTouchEventListener(void) const +{ + if (__destroying) + { + return const_cast<_Control*>(this); + } + + SysAssert(__pPropagatedTouchEventListener); + return __pPropagatedTouchEventListener; +} + +void +_Control::SetPropagatedKeyEventListener(_IPropagatedKeyEventListener* pListener) +{ + __pPropagatedKeyEventListener = pListener; +} + +_IPropagatedKeyEventListener* +_Control::GetPropagatedKeyEventListener(void) const +{ + if (__destroying) + { + return const_cast<_Control*>(this); + } + + SysAssert(__pPropagatedKeyEventListener); + return __pPropagatedKeyEventListener; +} + +bool +_Control::OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo) +{ + return false; +} + +bool +_Control::OnPreviewKeyReleased(const _Control& source, const _KeyInfo& keyInfo) +{ + return false; +} + +bool +_Control::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) +{ + //SysLog(NID_UI, ">>> [core] OnKeyPressed(%d, %d)", keyInfo.GetKeyCode(), keyInfo.GetKeyModifier()); + return false; +} + +bool +_Control::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) +{ + //SysLog(NID_UI, ">>> [core] OnKeyReleased(%d, %d)", keyInfo.GetKeyCode(), keyInfo.GetKeyModifier()); + return false; +} + +bool +_Control::TranslateKeyEventInfo(const _Control& source, _KeyInfo& keyInfo) +{ + return false; +} + +_UiTouchEventDelivery +_Control::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return _UI_TOUCH_EVENT_DELIVERY_YES; +} + +_UiTouchEventDelivery +_Control::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return _UI_TOUCH_EVENT_DELIVERY_YES; +} + +_UiTouchEventDelivery +_Control::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return _UI_TOUCH_EVENT_DELIVERY_YES; +} + +_UiTouchEventDelivery +_Control::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return _UI_TOUCH_EVENT_DELIVERY_YES; +} + +bool +_Control::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_Control::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_Control::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_Control::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_Control::OnFocusGained(const _Control& source) +{ + return false; +} + +bool +_Control::OnFocusLost(const _Control& source) +{ + return false; +} + +bool +_Control::OnPreviewNotifiedN(const _Control& source, IList* pArgs) +{ + return false; +} + +bool +_Control::OnNotifiedN(const _Control& source, IList* pArgs) +{ + return false; +} + +bool +_Control::IsMovable(void) const +{ + ClearLastResult(); + return __movable; +} + +bool +_Control::IsResizable(void) const +{ + ClearLastResult(); + return __resizable; +} + +Dimension +_Control::GetContentSize(void) const +{ + ClearLastResult(); + return GetSize(); +} + +HitTestResult +_Control::HitTest(const FloatPoint& point) +{ + _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*__pVisualElement); + + if (pVisualElementImpl) + { + if (pVisualElementImpl->HitTestI(point) == _VisualElementImpl::HITTEST_MATCH) + { + return HIT_TEST_MATCH; + } + } + + return HIT_TEST_NOWHERE; +} + +int +_Control::GetVerticalScrollPosition(void) const +{ + return 0; +} + +int +_Control::GetHorizontalScrollPosition(void) const +{ + return 0; +} + +_ControlOrientation +_Control::GetOrientation(void) const +{ + ClearLastResult(); + return __orientation; +} + +void +_Control::OnDraw(void) +{ +} + +Canvas* +_Control::OnCanvasRequestedN(const Dimension& size) +{ + + return null; +} + +Bitmap* +_Control::OnCapturedBitmapRequestedN(void) +{ + + return null; +} + +result +_Control::OnAttaching(const _Control* pParent) +{ + return E_SUCCESS; +} + +result +_Control::OnAttached(void) +{ + return E_SUCCESS; +} + +result +_Control::OnAttachingToMainTree(const _Control* pParent) +{ + return E_SUCCESS; +} + +result +_Control::OnAttachedToMainTree(void) +{ + return E_SUCCESS; +} + +result +_Control::OnDetachingFromMainTree(void) +{ + return E_SUCCESS; +} + +void +_Control::OnAttachingFailed(const _Control& parent) +{ +} + +result +_Control::OnDetaching(void) +{ + return E_SUCCESS; +} + +result +_Control::OnBoundsChanging(const Rectangle& bounds) +{ + return E_SUCCESS; +} + +void +_Control::OnBoundsChanged(void) +{ + +} + +void +_Control::OnEvaluateSize(Dimension& evaluatedSize) +{ +} + +void +_Control::OnParentBoundsChanged(const _Control& parent) +{ +} + + +void +_Control::OnChildAttached(const _Control& child) +{ +} + +void +_Control::OnChildDetaching(const _Control& child) +{ +} + +void +_Control::OnChildDetached(const _Control& child) +{ +} + +void +_Control::OnChildBoundsChanged(const _Control& child) +{ +} + +void +_Control::OnChildVisibleStateChanged(const _Control& child) +{ +} + +void +_Control::OnChangeLayout(_ControlOrientation orientation) +{ +} + +void +_Control::OnZOrderChanging(_ControlZOrderUpdate zOrderUpdate) +{ +} + +void +_Control::OnVisibleStateChanging(void) +{ +} + +void +_Control::OnVisibleStateChanged(void) +{ +} + +void +_Control::OnAncestorVisibleStateChanged(const _Control& control) +{ +} + +void +_Control::OnAncestorEnableStateChanged(const _Control& control) +{ +} + +void +_Control::OnTouchPressHandled(const _Control& control) +{ +} + +void +_Control::OnTouchReleaseHandled(const _Control& control) +{ +} + +void +_Control::OnTouchMoveHandled(const _Control& control) +{ +} + +void +_Control::OnFontChanged(Tizen::Graphics::Font* pFont) +{ +} + +void +_Control::OnFontInfoRequested(unsigned long& style, int& size) +{ +} + +void +_Control::OnTouchCancelHandled(const _Control& control) +{ +} + +void +_Control::Accept(Visitor& visitor) +{ + ClearLastResult(); + + VisitType visitType = visitor.Visit(*this); + + switch (visitType) + { + case VISIT_STOP: + break; + + case VISIT_DOWNWARD: + for (int i = 0; i < GetChildCount(); ++i) // [Postpone] Keep handle list before iternation. + { + _Control* pChild = GetChild(i); + if (pChild) + { + pChild->Accept(visitor); + } + } + break; + + case VISIT_UPWARD: + { + _Control* pParent = GetParent(); + if (pParent) + { + pParent->Accept(visitor); + } + } + break; + + default: + break; + } +} + +void +_Control::Accept(Visitor& visitor) const +{ + const_cast <_Control*>(this)->Accept(visitor); +} + +void +_Control::Draw(bool recursive) +{ + ClearLastResult(); + + Invalidate(recursive); + GetVisualElement()->Draw(); +} + +void +_Control::Show(void) +{ + GetVisualElement()->Flush(); + ClearLastResult(); + + SysAssert(GetLastResult() == E_SUCCESS); +} + +void +_Control::ChangeLayout(_ControlOrientation orientation) +{ + ClearLastResult(); + + struct _Visitor + : public Visitor + { + _Visitor(_ControlOrientation orientation) + : __orientation(orientation){} + + virtual VisitType Visit(_Control& control) + { + if (control.__orientation != __orientation) + { + control.__orientation = __orientation; + control.GetControlDelegate().OnChangeLayout(__orientation); + ClearLastResult(); + } + + return VISIT_DOWNWARD; + } + +private: + _ControlOrientation __orientation; + }; + + _Visitor visitor(orientation); + Accept(visitor); + + SysAssert(GetLastResult() == E_SUCCESS); +} + +bool +_Control::IsLayoutChangable(void) const +{ + return true; +} + +bool +_Control::IsOrientationRoot(void) const +{ + return false; +} + +void +_Control::Invalidate(void) +{ + ClearLastResult(); + GetVisualElement()->InvalidateRectangle(null); +} + +void +_Control::Invalidate(bool recursive) +{ + ClearLastResult(); + + struct _Visitor + : public Visitor + { + virtual VisitType Visit(_Control& control) + { + if (control.GetVisibleState() == false) + { + return VISIT_STOP; + } + + control.Invalidate(); + + // Ownee + int owneeCount = control.GetOwneeCount(); + for (int i = 0; i < owneeCount; ++i) + { + _Window* pOwnee = control.GetOwnee(i); + if (pOwnee) + { + pOwnee->Invalidate(true); + } + } + + return VISIT_DOWNWARD; + } + }; + + // Update layout + _Layout::Layout* pLayout = GetLayout(); + if (pLayout) + { + pLayout->UpdateLayout(); + } + + if (recursive == false) + { + Invalidate(); + } + else + { + _Visitor visitor; + Accept(visitor); + } +} + +void +_Control::Invalidate(const Rectangle& rect) +{ + ClearLastResult(); + FloatRectangle rectf(rect.x, rect.y, rect.width, rect.height); + GetVisualElement()->InvalidateRectangle(&rectf); + + __invalidatedBounds = rect; +} + +bool +_Control::Contains(const Point& point) const +{ + ClearLastResult(); + + Rectangle bounds = GetBounds(); + bounds.x = bounds.y = 0; + return bounds.Contains(point); +} + +void +_Control::PartialUpdateLayout(void) +{ + ClearLastResult(); + + _Layout::Layout* pLayout = GetLayout(); + if (pLayout) + { + pLayout->PartialUpdateLayout(); + } +} + +void +_Control::UpdateLayout(void) +{ + ClearLastResult(); + + _Layout::Layout* pLayout = GetLayout(); + if (pLayout) + { + pLayout->UpdateLayout(); + } +} + +result +_Control::SetChildAlwaysOnTop(_Control& child) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, + child.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Not my child."); + + SysTryReturn(NID_UI, + child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] The child is not in the client area."); + + if (child.GetLayer() == _CONTROL_LAYER_CLIENT_TOP) + { + return E_SUCCESS; + } + + child.SetLayer(_CONTROL_LAYER_CLIENT_TOP); + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +result +_Control::SetChildAlwaysAtBottom(_Control& child) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, + child.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Not my child."); + + SysTryReturn(NID_UI, + child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] The child is not in the client area."); + + if (child.GetLayer() == _CONTROL_LAYER_CLIENT_BOTTOM) + { + return E_SUCCESS; + } + + child.SetLayer(_CONTROL_LAYER_CLIENT_BOTTOM); + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +result +_Control::ResetChildLayer(_Control& child) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, + child.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Not my child."); + + SysTryReturn(NID_UI, + child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] The child is not in the client area."); + + if (child.GetLayer() == _CONTROL_LAYER_CLIENT_MIDDLE) + { + return E_SUCCESS; + } + + child.SetLayer(_CONTROL_LAYER_CLIENT_MIDDLE); + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + + +result +_Control::AttachSystemChild(_Control& child) +{ + ClearLastResult(); + result r = E_SUCCESS; + + r = StartAttaching(child, _CONTROL_AREA_SYSTEM); + if (IsFailed(r)) + { + return r; + } + + ControlList& children = GetChildList(); + r = children.Add(&child); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + r = GetVisualElement()->AttachChild(*child.GetVisualElement()); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + r = EndAttaching(child); + if (IsFailed(r)) + { + return r; + } + + SysAssert(GetLastResult() == E_SUCCESS); + + return E_SUCCESS; +} + +result +_Control::DetachSystemChild(_Control& child) +{ + return DetachChild(child); +} + +bool +_Control::HasParent(void) const +{ + return __pParent != null; +} + +_ControlArea +_Control::GetArea(void) const +{ + ClearLastResult(); + return __area; +} + +_ControlLayer +_Control::GetLayer(void) const +{ + ClearLastResult(); + return __layer; +} + +void +_Control::SetLayer(_ControlLayer layer) +{ + ClearLastResult(); + _VisualElementImpl* pImpl = _VisualElementImpl::GetInstance(*GetVisualElement()); + + result r = pImpl->SetZOrderGroup(::GetZOrderGroupOfVisualElement(layer)); + __layer = layer; + + SysAssert(r == E_SUCCESS); + ClearLastResult(); // [Temp] Will be removed. + + SysAssert(r == E_SUCCESS); +} + +const _Control::ControlList& +_Control::GetChildList() const +{ + return const_cast <_Control*>(this)->GetChildList(); +} + +_Control::ControlList& +_Control::GetChildList() +{ + return *__pChildren; +} + +bool +_Control::IsCalledCallAttachingToMainTree(void) +{ + return __isCalledCallOnAttachingToMainTree; +} + +void +_Control::SetCalledCallAttachingToMainTree(bool isAttaching) +{ + __isCalledCallOnAttachingToMainTree = isAttaching; +} + +bool +_Control::IsCalledCallAttachedToMainTree(void) +{ + return __isCalledCallOnAttachedToMainTree; +} + +void +_Control::SetCalledCallAttachedToMainTree(bool isAttached) +{ + __isCalledCallOnAttachedToMainTree = isAttached; +} + +result +_Control::CallOnAttachingToMainTree(_Control& control) +{ + result r = E_SUCCESS; + + ControlList& children = control.GetChildList(); + _Control* pChild = null; + + int childrenCount = children.GetCount(); + + for (int index = 0; index < childrenCount; index++) + { + r = children.GetAt(index, pChild); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_RANGE); + SysTryReturn(NID_UI, + (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range."); + } + if (!pChild->IsCalledCallAttachingToMainTree()) + { + r = CallOnAttachingToMainTree(*pChild); + pChild->SetCalledCallAttachingToMainTree(true); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + if (!control.IsCalledCallAttachingToMainTree()) + { + r = control.GetControlDelegate().OnAttachingToMainTree(this); + control.SetCalledCallAttachingToMainTree(true); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_Control::CallOnAttachedToMainTree(_Control& control) +{ + result r = E_SUCCESS; + + ControlList& children = control.GetChildList(); + _Control* pChild = null; + + int childrenCount = children.GetCount(); + + for (int index = 0; index < childrenCount; index++) + { + r = children.GetAt(index, pChild); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_RANGE); + SysTryReturn(NID_UI, + (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range."); + } + + if (!pChild->IsCalledCallAttachedToMainTree()) + { + r = CallOnAttachedToMainTree(*pChild); + pChild->SetCalledCallAttachedToMainTree(true); + } + } + + if (!control.IsCalledCallAttachedToMainTree()) + { + r = control.GetControlDelegate().OnAttachedToMainTree(); + control.SetCalledCallAttachedToMainTree(true); + } + + return r; +} +result +_Control::CallOnDetachingFromMainTree(_Control& control) +{ + result r = E_SUCCESS; + + ControlList& children = control.GetChildList(); + _Control* pChild = null; + + if (!__isPostOrderTraversal) + { + r = control.GetControlDelegate().OnDetachingFromMainTree(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + int childrenCount = children.GetCount(); + + for (int index = 0; index < childrenCount; index++) + { + r = children.GetAt(index, pChild); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_RANGE); + SysTryReturn(NID_UI, + (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range."); + } + r = CallOnDetachingFromMainTree(*pChild); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (__isPostOrderTraversal) + { + r = control.GetControlDelegate().OnDetachingFromMainTree(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +void +_Control::CallOnAncestorVisibleStateChanged(void) +{ + struct _Visitor + : public Visitor + { + _Visitor(_Control& parent) + : __parent(parent){} + + virtual VisitType Visit(_Control& control) + { + control.GetControlDelegate().OnAncestorVisibleStateChanged(__parent); + return VISIT_DOWNWARD; + } + + _Control& __parent; + }; + + _Visitor visitor(*this); + Accept(visitor); +} + +void +_Control::CallOnAncestorEnableStateChanged(void) +{ + struct _Visitor + : public Visitor + { + _Visitor(_Control& parent) + : __parent(parent){} + + virtual VisitType Visit(_Control& control) + { + control.GetControlDelegate().OnAncestorEnableStateChanged(__parent); + return VISIT_DOWNWARD; + } + + _Control& __parent; + }; + + _Visitor visitor(*this); + Accept(visitor); +} + +// E_INVALID_ARG +// E_SYSTEM +// [ToDo] Rollback is difficult. +result +_Control::StartAttaching(_Control& child, _ControlArea area) +{ + result r = E_SUCCESS; + + _Control* pOldParent = child.GetParent(); + + SysTryReturn(NID_UI, + (pOldParent != this), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The child control is already attached to this container."); + + SysTryReturn(NID_UI, + pOldParent == null, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Unable to add the child which already has another parent."); + + r = child.GetControlDelegate().OnAttaching(this); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (IsAttachedToMainTree()) + { + r = CallOnAttachingToMainTree(child); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + // [ToDo] Add control to layout + // What should we do about non-layoutable controls? + if (area == _CONTROL_AREA_CLIENT) + { + _ControlManager* pMgr = _ControlManager::GetInstance(); + r = GetLastResult(); + SysTryReturn(NID_UI, pMgr, r, r, "[%s] Propagating.", GetErrorMessage(r)); + +#if !defined(MULTI_WINDOW) + if (this != &(pMgr->GetRoot())) +#endif + { + r = __pLayoutContainer->AddItem(child.GetLayoutContainer()); + } + + if (IsFailed(r)) + { + child.GetControlDelegate().OnAttachingFailed(*this); + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Failed to apply layout."); + return E_SYSTEM; + } + } + + if (IsAttachedToMainTree()) + { +#if defined(MULTI_WINDOW) + if (!(IsOrientationRoot() && child.IsOrientationRoot())) +#else + if (IsLayoutChangable() && child.IsLayoutChangable()) +#endif + { + child.ChangeLayout(_ControlManager::GetInstance()->GetOrientation()); + } + } + + child.__area = area; + + if (area == _CONTROL_AREA_CLIENT) + { + if (child.GetLayer() != _CONTROL_LAYER_CLIENT_TOP && child.GetLayer() != _CONTROL_LAYER_CLIENT_BOTTOM) + { + child.SetLayer(_CONTROL_LAYER_CLIENT_MIDDLE); + } + } + else + { + child.SetLayer(_CONTROL_LAYER_SYSTEM); + } + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +result +_Control::EndAttaching(_Control& child) +{ + child.SetParent(this); + + FloatRectangle floatBounds(child.GetBounds().x, child.GetBounds().y, child.GetBounds().width, child.GetBounds().height); + + result r = E_SUCCESS; + if (child.IsLayoutChangable() == false) + { + r = child.UpdateBoundsOfVisualElement(FloatRectangle(0, 0, floatBounds.width, floatBounds.height)); + } + else + { + r = child.UpdateBoundsOfVisualElement(floatBounds); + } + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + r = child.GetControlDelegate().OnAttached(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (IsAttachedToMainTree()) + { + r = CallOnAttachedToMainTree(child); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + ClearLastResult(); + + GetControlDelegate().OnChildAttached(child); + ClearLastResult(); + + return E_SUCCESS; +} + +// E_INVALID_ARG +// E_OUT_OF_MEMORY +// E_SYSTEM +result +_Control::AttachChild(_Control& child) +{ + ClearLastResult(); + result r = E_SUCCESS; + + r = StartAttaching(child, _CONTROL_AREA_CLIENT); + if (IsFailed(r)) + { + return r; + } + + ControlList& children = GetChildList(); + r = children.Add(&child); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + r = GetVisualElement()->AttachChild(*child.GetVisualElement()); + + r = EndAttaching(child); + if (IsFailed(r)) + { + return r; + } + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +// E_INVALID_ARG +// E_OUT_OF_MEMORY +// E_SYSTEM +result +_Control::InsertChildToBottom(_Control& child) +{ + ClearLastResult(); + result r = E_SUCCESS; + + r = StartAttaching(child, _CONTROL_AREA_CLIENT); + if (IsFailed(r)) + { + return r; + } + + ControlList& children = GetChildList(); + r = children.InsertAt(&child, 0); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + GetVisualElement()->InsertChild(*child.GetVisualElement(), null, false); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + r = EndAttaching(child); + if (IsFailed(r)) + { + return r; + } + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +// E_INVALID_ARG +// E_OUT_OF_MEMORY +// E_SYSTEM +result +_Control::InsertChildAfter(const _Control& targetChild, _Control& child) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_UI, + targetChild.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The target is not my child."); + + r = StartAttaching(child, _CONTROL_AREA_CLIENT); + if (IsFailed(r)) + { + return r; + } + + int targetIndex = GetChildIndex(targetChild); + SysAssert(targetIndex != -1); + + ControlList& children = GetChildList(); + r = children.InsertAt(&child, targetIndex + 1); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + GetVisualElement()->InsertChild(*child.GetVisualElement(), targetChild.GetVisualElement(), true); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + r = EndAttaching(child); + if (IsFailed(r)) + { + return r; + } + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +// E_INVALID_ARG +// E_OUT_OF_MEMORY +// E_SYSTEM +result +_Control::InsertChildBefore(const _Control& targetChild, _Control& child) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_UI, + targetChild.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The target is not my child."); + + r = StartAttaching(child, _CONTROL_AREA_CLIENT); + if (IsFailed(r)) + { + return r; + } + + int targetIndex = GetChildIndex(targetChild); + SysAssert(targetIndex != -1); + + ControlList& children = GetChildList(); + r = children.InsertAt(&child, targetIndex); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + GetVisualElement()->InsertChild(*child.GetVisualElement(), targetChild.GetVisualElement(), false); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + r = EndAttaching(child); + if (IsFailed(r)) + { + return r; + } + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +// E_SYSTEM +result +_Control::DetachChild(_Control& child) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_UI, + child.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Not my child."); + + if (IsAttachedToMainTree()) + { + r = CallOnDetachingFromMainTree(child); + SysTryReturn(NID_UI, + r == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] The child cannot detached from parent."); + + SysTryReturn(NID_UI, + child.GetControlDelegate().OnDetaching() == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] The child cannot detached from parent."); + } + + GetControlDelegate().OnChildDetaching(child); + ClearLastResult(); + + r = GetVisualElement()->DetachChild(*child.GetVisualElement()); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + ControlList& children = GetChildList(); + r = children.Remove(&child); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + // Remove control to layout + if (child.__area == _CONTROL_AREA_CLIENT) + { + _ControlManager* pMgr = _ControlManager::GetInstance(); + r = GetLastResult(); + SysTryReturn(NID_UI, pMgr, r, r, "[%s] Propagating.", GetErrorMessage(r)); + +#if !defined(MULTI_WINDOW) + if (this != &(pMgr->GetRoot())) +#endif + { + r = __pLayoutContainer->RemoveItem(child.GetLayoutContainer()); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + } + } + + child.SetParent(null); + child.__area = _CONTROL_AREA_NONE; + child.__layer = _CONTROL_LAYER_NONE; + + GetControlDelegate().OnChildDetached(child); + ClearLastResult(); + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +// Always success +void +_Control::DetachAllChildren(bool detachSystemChild) +{ + ClearLastResult(); + result r = E_SUCCESS; + + int notDetachedChildCount = 0; + + int childCount = GetChildCount(); + int itemIndex = 0; + + while (childCount--) + { + _Control* pChild = GetChild(itemIndex); + if (pChild == null) + { + continue; + } + + if (!detachSystemChild && (pChild->GetArea() == _CONTROL_AREA_SYSTEM)) + { + itemIndex++; + continue; + } + r = DetachChild(*pChild); + + if (IsFailed(r)) + { + ++notDetachedChildCount; + } + } + + SysLog(NID_UI, "%d children are not detached from this container.", notDetachedChildCount); + ClearLastResult(); +} + +// E_INVALID_ARG +result +_Control::MoveChildToTop(const _Control& child) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_UI, + child.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Not my child."); + + // If already on top, + ControlList& children = GetChildList(); + if (GetChildIndex(child) == children.GetCount() - 1) + { + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; + } + + _Control* pChild = const_cast <_Control*>(&child); + + r = children.Remove(pChild); + SysAssert(r == E_SUCCESS); + + r = children.Add(pChild); + SysAssert(r == E_SUCCESS); + + r = child.GetVisualElement()->SetZOrder(null, true); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +// E_INVALID_ARG +result +_Control::MoveChildToBottom(const _Control& child) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_UI, + child.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Not my child."); + + ControlList& children = GetChildList(); + + if (GetChildIndex(child) == 0) + { + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; + } + + _Control* pChild = const_cast <_Control*>(&child); + + r = children.Remove(pChild); + SysAssert(r == E_SUCCESS); + + r = children.InsertAt(pChild, 0); + SysAssert(r == E_SUCCESS); + + r = child.GetVisualElement()->SetZOrder(null, false); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +// E_INVALID_ARG +result +_Control::MoveChildAfter(const _Control& targetChild, const _Control& child) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_UI, + targetChild.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Target is not my child."); + + SysTryReturn(NID_UI, + child.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Not my child."); + + SysTryReturn(NID_UI, + &targetChild != &child, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Cannot move after self."); + + ControlList& children = GetChildList(); + + int targetIndex = GetChildIndex(targetChild); + SysAssert(targetIndex != -1); + + if (targetIndex + 1 == GetChildIndex(child)) + { + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; + } + + _Control* pChild = const_cast <_Control*>(&child); + + r = children.Remove(pChild); + SysAssert(r == E_SUCCESS); + + r = children.InsertAt(pChild, targetIndex + 1); + SysAssert(r == E_SUCCESS); + + r = child.GetVisualElement()->SetZOrder(targetChild.GetVisualElement(), true); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +// E_INVALID_ARG +result +_Control::MoveChildBefore(const _Control& targetChild, const _Control& child) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_UI, + targetChild.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Target is not my child."); + + SysTryReturn(NID_UI, + child.GetParent() == this, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Not my child."); + + SysTryReturn(NID_UI, + &targetChild != &child, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Cannot move before self."); + + ControlList& children = GetChildList(); + + int targetIndex = GetChildIndex(targetChild); + SysAssert(targetIndex != -1); + + if (targetIndex - 1 == GetChildIndex(child)) + { + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; + } + + _Control* pChild = const_cast <_Control*>(&child); + + r = children.Remove(pChild); + SysAssert(r == E_SUCCESS); + + r = children.InsertAt(pChild, targetIndex); + SysAssert(r == E_SUCCESS); + + r = child.GetVisualElement()->SetZOrder(targetChild.GetVisualElement(), false); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +// E_INVALID_ARG +// E_OBJ_NOT_FOUND +int +_Control::GetChildIndex(const _Control& child) const +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturn(NID_UI, + child.GetParent() == this, -1, + E_INVALID_ARG, "[E_INVALID_ARG] Not my child."); + + const ControlList& children = GetChildList(); + + int index = -1; + r = children.IndexOf(const_cast<_Control*>(&child), index); + if (IsFailed(r)) + { + SysAssert(r == E_OBJ_NOT_FOUND); + SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Unable to find the specified child."); + return -1; + } + + SysAssert(GetLastResult() == E_SUCCESS); + return index; +} + +// E_OUT_OF_RANGE +_Control* +_Control::GetChild(int index) const +{ + ClearLastResult(); + result r = E_SUCCESS; + + const ControlList& children = GetChildList(); + + _Control* pChild = null; + r = children.GetAt(index, pChild); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_RANGE); + SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range."); + return null; + } + + SysAssert(GetLastResult() == E_SUCCESS); + return pChild; +} + +int +_Control::GetChildCount(void) const +{ + ClearLastResult(); + return GetChildList().GetCount(); +} + +_ControlHandle +_Control::GetHandle(void) const +{ + return __controlHandle; +} + +void* +_Control::GetUserData(void) const +{ + return __pUserData; +} + +void +_Control::SetUserData(void* pUserData) +{ + __pUserData = pUserData; +} + +Variant +_Control::GetPropertyName(void) const +{ + ClearLastResult(); + return Tizen::Ui::Variant(__name); +} + +String +_Control::GetName(void) const +{ + Variant name = GetProperty("Name"); + + return name.ToString(); +} + +result +_Control::SetPropertyName(const Variant& name) +{ + ClearLastResult(); + __name = name.ToString(); + + return E_SUCCESS; +} + +void +_Control::SetName(const String& name) +{ + SetProperty("Name", Variant(name)); +} + +_Control* +_Control::GetParent(void) const +{ + return __pParent; +} + +Canvas* +_Control::GetCanvasN(void) const +{ + return GetCanvasN(Rectangle(0, 0, __bounds.width, __bounds.height)); +} + +Canvas* +_Control::GetCanvasN(const Rectangle& bounds) const +{ + ClearLastResult(); + Canvas *pCanvas = GetControlDelegate().OnCanvasRequestedN(Dimension(bounds.width, bounds.height)); + if (pCanvas == null) + { + GetVisualElement()->SetFlushNeeded(); + pCanvas = GetVisualElement()->GetCanvasN(bounds); + if (IsFailed(GetLastResult())) + { + SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult())); + } + + if (pCanvas && !__isCalledGetCanvasN) + { + pCanvas->SetBackgroundColor(GetBackgroundColor()); + pCanvas->Clear(); + const_cast <_Control*>(this)->__isCalledGetCanvasN = true; + } + } + return pCanvas; +} + +bool +_Control::IsCalledGetCanvasN(void) const +{ + return __isCalledGetCanvasN; +} + +Canvas* +_Control::GetClientCanvasN(void) const +{ + return GetCanvasN(GetClientBounds()); +} + +bool +_Control::IsAncestorOf(const _Control& control) const +{ + ClearLastResult(); + + const _Control* pParent = control.GetParent(); + if (!pParent) + { + return false; + } + + struct _Visitor + : public Visitor + { +private: + const _Control& __ancestor; + +public: + bool yes; + + _Visitor(const _Control& ancestor) + : __ancestor(ancestor) + , yes(false){} + + virtual VisitType Visit(_Control& control) + { + if (&__ancestor == &control) + { + yes = true; + return VISIT_STOP; + } + else + { + return VISIT_UPWARD; + } + } + }; + + _Visitor visitor(*this); + pParent->Accept(visitor); + + SysAssert(GetLastResult() == E_SUCCESS); + return visitor.yes; +} + +_Window* +_Control::GetRootWindow(void) const +{ + ClearLastResult(); + + struct _Visitor + : public Visitor + { + _Window* pRoot; + + _Visitor(void) + : pRoot(null){} + + virtual VisitType Visit(_Control& control) + { + pRoot = dynamic_cast <_Window*>(&control); + if (pRoot != null) + { + return VISIT_STOP; + } + + return VISIT_UPWARD; + } + }; + + _Visitor visitor; + Accept(visitor); + + SysAssert(GetLastResult() == E_SUCCESS); + return visitor.pRoot; +} + +bool +_Control::IsAttachedToMainTree(void) const +{ + ClearLastResult(); + + _ControlManager* pMgr = _ControlManager::GetInstance(); + if (pMgr == null) + { + return false; + } + +#if !defined(MULTI_WINDOW) + if (this == &(pMgr->GetRoot())) + { + return true; + } +#endif + + _Window* pRootWindow = GetRootWindow(); + if (pRootWindow == null) + { + return false; + } + + return pRootWindow->IsAttached(); +} + +bool +_Control::IsFocusable(void) const +{ + ClearLastResult(); + return __focusable; +} + +void +_Control::SetFocusable(bool focusable) +{ + ClearLastResult(); + __focusable = focusable; +} + +bool +_Control::IsNativeObjectFocusable(void) const +{ + ClearLastResult(); + return __nativeObjectFocusable; +} + +void +_Control::SetNativeObjectFocusable(bool focusable) +{ + ClearLastResult(); + __nativeObjectFocusable = focusable; +} + +bool +_Control::IsFocused(void) const +{ + ClearLastResult(); + + if (!__focusSet) + { + return false; + } + + for (int i = 0; i < GetChildCount(); ++i) + { + _Control* pChild = GetChild(i); + + SysAssert(pChild); + if (pChild == null) + { + continue; + } + + if (pChild->__focusSet) + { + return false; + } + } + + return true; +} + +_Control* +_Control::GetFocused(void) const +{ + for (int i = GetChildCount() - 1; i >= 0; --i) + { + _Control* pChild = GetChild(i); + + SysAssert(pChild); + if (pChild == null) + { + continue; + } + + if (pChild->__focusSet == true) + { + return pChild->GetFocused(); + } + } + + if (__focusSet == true) + { + return const_cast <_Control*>(this); + } + else + { + return null; + } + +} + +result +_Control::SetFocused(void) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, + IsAttachedToMainTree(), E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control should have a parent or be attached to the main tree."); + + SysTryReturn(NID_UI, + IsFocusable(), E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This Control isn't focusable control."); + + _Window* pTop = GetRootWindow(); + SysAssert(pTop); + + pTop->SetFocusOff(this); + SetFocusOn(); + + _ControlManager* pControlMgr = _ControlManager::GetInstance(); + SysAssert(pControlMgr); + + if (pTop->IsActivated() && pTop->IsFocusableDescendant(this)) + { + pControlMgr->SetFocusedControl(*this); // Dangerous if _Control::Manager::SetFocusedControl() is called by User. + } + + if (IsFailed(GetLastResult())) + { + SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult())); + } + + return E_SUCCESS; +} + + +// [ToDo] Assume the control is attached to the main tree. +void +_Control::SetFocusOn(void) +{ + ClearLastResult(); + + __focusSet = true; + _Control* pParent = GetParent(); + if (pParent) + { + pParent->SetFocusOn(); + } +} + +// [ToDo] Find the focused descendent and clear flags upwards. +void +_Control::SetFocusOff(_Control* pFocus) +{ + ClearLastResult(); + + __focusSet = false; + for (int i = 0; i < GetChildCount(); ++i) + { + _Control* pChild = GetChild(i); + + SysAssert(pChild); + if (pChild == null) + { + continue; + } + + if (pChild->__focusSet == true) + { + pChild->SetFocusOff(pFocus); + return; + } + } +} + +result +_Control::SetFont(const String& fontName) +{ + result r = E_SUCCESS; + + if (__fontName.Equals(fontName)) + { + return E_SUCCESS; + } + + __isControlFontChanged = true; + __fontName = fontName; + + Font* pFont = GetFallbackFont(); + + if (pFont == null) + { + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + return E_SUCCESS; +} + +Font* +_Control::GetFallbackFont(void) +{ + unsigned long style; + int textSize; + result r = E_SUCCESS; + _IControlDelegate& delegate = GetControlDelegate(); + delegate.OnFontInfoRequested(style, textSize); + _ControlManager* pControlManager = _ControlManager::GetInstance(); + + if (!(__isControlFontChanged || pControlManager->IsDefaultFontChanged()) && __pFont != null && __pFont->GetSize() == textSize) + { + return __pFont; + } + unique_ptrpTempFont(new(std::nothrow)Font()); + SysTryReturn(NID_UI , pTempFont , null , E_OUT_OF_MEMORY, "[%s] Fails to create a __pFont.", GetErrorMessage(r)); + + if (!__fontName.IsEmpty()) + { + __isControlFontChanged = false; + _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont); + SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed."); + + r = pFontImpl->Construct(__fontName, style, textSize, false); + SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r)); + SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r)); + } + else if (!pControlManager->GetDefaultFont().IsEmpty()) + { + _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont); + SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed."); + + r = pFontImpl->Construct(pControlManager->GetDefaultFont(), style, textSize, false); + SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r)); + SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r)); + } + else + { + r = pTempFont->Construct(style, textSize); + SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r)); + SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r)); + } + + if (__pFont) + { + delete __pFont; + __pFont = null; + } + __pFont = pTempFont.release(); + delegate.OnFontChanged(__pFont); + return __pFont; +} + +String +_Control::GetFont(void) const +{ + return __fontName; +} + +bool +_Control::IsEnabled(void) const +{ + ClearLastResult(); + + struct _Visitor + : public Visitor + { + bool enabled; + + _Visitor(void) + : enabled(true){} + + virtual VisitType Visit(_Control& control) + { + if (!control.GetEnableState()) + { + enabled = false; + return VISIT_STOP; + } + + return VISIT_UPWARD; + } + }; + + _Visitor visitor; + Accept(visitor); + return visitor.enabled; +} + +bool +_Control::GetEnableState(void) const +{ + ClearLastResult(); + return __enabledState; +} + +void +_Control::SetEnableState(bool enabledState) +{ + ClearLastResult(); + const bool changed = (__enabledState != enabledState); + __enabledState = enabledState; + if (changed) + { + CallOnAncestorEnableStateChanged(); + } + __pAccessibilityContainer->SetEnableState(enabledState); +} + +bool +_Control::IsInputEnabled(void) const +{ + ClearLastResult(); + + struct _Visitor + : public Visitor + { + bool inputEnabled; + + _Visitor(void) + : inputEnabled(true){} + + virtual VisitType Visit(_Control& control) + { + if (!control.GetInputEnableState()) + { + inputEnabled = false; + return VISIT_STOP; + } + + return VISIT_UPWARD; + } + }; + + _Visitor visitor; + Accept(visitor); + return visitor.inputEnabled; +} + +bool +_Control::GetInputEnableState(void) const +{ + ClearLastResult(); + return __inputEnabledState; +} + +void +_Control::SetInputEnableState(bool inputEnabledState) +{ + ClearLastResult(); + __inputEnabledState = inputEnabledState; +} + +bool +_Control::IsVisible(void) const +{ + ClearLastResult(); + + SysTryReturn(NID_UI, IsAttachedToMainTree(), false, E_SYSTEM, "[E_SYSTEM] This control should be attached to the main tree."); + + struct _Visitor + : public Visitor + { + bool visible; + + _Visitor(void) + : visible(true){} + + virtual VisitType Visit(_Control& control) + { + if (!control.GetVisibleState()) + { + visible = false; + return VISIT_STOP; + } + + return VISIT_UPWARD; + } + }; + + _Visitor visitor; + Accept(visitor); + + SysAssert(GetLastResult() == E_SUCCESS); + return visitor.visible; +} + +bool +_Control::GetVisibleState(void) const +{ + ClearLastResult(); + return __visibleState; +} + +void +_Control::SetVisibleState(bool visibleState) +{ + ClearLastResult(); + + const bool changed = (__visibleState != visibleState) || !__initVisibleState; + + if (changed) + { + GetControlDelegate().OnVisibleStateChanging(); + } + + __visibleState = visibleState; + GetVisualElement()->SetShowState(visibleState); + + if (visibleState == false) + { + int owneeCount = GetOwneeCount(); + for (int i = 0; i < owneeCount; ++i) + { + _Window* pWindow = GetOwnee(i); + if (pWindow) + { + pWindow->SetVisibleState(visibleState); + } + } + } + + if (changed) + { + GetControlDelegate().OnVisibleStateChanged(); + CallOnAncestorVisibleStateChanged(); + + _Control* pParent = GetParent(); + if (pParent) + { + pParent->GetControlDelegate().OnChildVisibleStateChanged(*this); + } + + ClearLastResult(); + } + + __initVisibleState = true; +} + +bool +_Control::IsLayoutable(void) const +{ + ClearLastResult(); + return IsMovable(); +} + +bool +_Control::IsClipToParent(void) const +{ + ClearLastResult(); +// SysAssert(GetVisualElement()->IsClipToParent() == __clipToParent); + return __clipToParent; +} + +result +_Control::SetClipToParent(bool clipToParent) +{ + ClearLastResult(); + result r = E_SUCCESS; + + __clipToParent = clipToParent; + r = GetVisualElement()->SetClipToParent(clipToParent); + SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +result +_Control::SetClipChildrenEnabled(bool clipChildren) +{ + ClearLastResult(); + //result r = E_SUCCESS; + + GetVisualElement()->SetClipChildrenEnabled(clipChildren); + //SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +Rectangle +_Control::GetBounds(void) const +{ + ClearLastResult(); + return __bounds; +} + +Point +_Control::GetPosition(void) const +{ + ClearLastResult(); + return Point(__bounds.x, __bounds.y); +} + +Dimension +_Control::GetSize(void) const +{ + ClearLastResult(); + return Dimension(__bounds.width, __bounds.height); +} + +// E_SYSTEM +result +_Control::UpdateBoundsOfVisualElement(const FloatRectangle& controlBounds) +{ + FloatRectangle rect(controlBounds.x, controlBounds.y, controlBounds.width, controlBounds.height); + + _Control* pParent = GetParent(); + if (__area == _CONTROL_AREA_CLIENT && pParent) + { + const Rectangle clientBounds = pParent->GetClientBounds(); + rect.x += (float)clientBounds.x; + rect.y += (float)clientBounds.y; + } + + GetVisualElement()->SetBounds(rect); + + return E_SUCCESS; +} + +bool +_Control::IsInSizeRange(const Dimension& size) +{ + return (__minSize.width <= size.width) && (size.width <= __maxSize.width) && + (__minSize.height <= size.height) && (size.height <= __maxSize.height); +} + +// Custom Exception: ex) Location::Map +result +_Control::SetBoundsFinal(const FloatRectangle& newBounds, bool changeLayoutBaseRect, bool callBoundsChangeCallbacks) +{ + result r = E_SUCCESS; + + Rectangle bounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height); + + _IControlDelegate& delegate = GetControlDelegate(); + + const bool moved = (__bounds.x != bounds.x) || (__bounds.y != bounds.y); + const bool resized = (__bounds.width != bounds.width) || (__bounds.height != bounds.height); + + if ((moved || resized) && callBoundsChangeCallbacks) + { + r = delegate.OnBoundsChanging(bounds); + if (IsFailed(r)) + { + SysLogException(NID_UI, r, "[%s] Callback returns exception.", GetErrorMessage(r)); + return r; // Relay the result; + } + } + + if (moved || resized) + { + const FloatRectangle fbounds(bounds.x, bounds.y, bounds.width, bounds.height); + if (IsLayoutChangable() == false) + { + r = UpdateBoundsOfVisualElement(FloatRectangle(0, 0, fbounds.width, fbounds.height)); + } + else + { + r = UpdateBoundsOfVisualElement(fbounds); + } + } + + SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback. + + __bounds = bounds; + + if (changeLayoutBaseRect) + { + __pLayoutContainer->OnChangeBaseRect(); + } + + if ((moved || resized) && callBoundsChangeCallbacks) + { + if (IsMovable() && IsResizable()) + { + SetClientBounds(Rectangle(0, 0, GetSize().width, GetSize().height)); + } + delegate.OnBoundsChanged(); + + _Control* pParent = GetParent(); + if (pParent) + { + pParent->GetControlDelegate().OnChildBoundsChanged(*this); + } + + ControlList& children = GetChildList(); + _Control* pChild = null; + int childrenCount = children.GetCount(); + + for (int index = 0; index < childrenCount; index++) + { + r = children.GetAt(index, pChild); + if (!IsFailed(r)) + { + pChild->GetControlDelegate().OnParentBoundsChanged(*this); + } + } + } + + ClearLastResult(); + return E_SUCCESS; +} + +// Custom Exception: ex) Location::Map +result +_Control::AdjustSizeToRange(void) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysAssert(IsResizable()); + + Dimension size = GetSize(); + bool changed = ::AdjustSizeToRange(size, __minSize, __maxSize); + if (!changed) + { + return E_SUCCESS; + } + + FloatRectangle newBounds(__bounds.x, __bounds.y, size.width, size.height); + r = SetBoundsFinal(newBounds, true, true); + if (IsFailed(r)) + { + return r; + } + + return E_SUCCESS; +} + +// Custom Exception: ex) Location::Map +// E_INVALID_ARG +result +_Control::SetBoundsInternal(const FloatRectangle& bounds, bool callBoundsChangeCallbacks) +{ + SysTryReturn(NID_UI, + IsInSizeRange(Dimension(bounds.width, bounds.height)), E_INVALID_ARG, + E_INVALID_ARG, + "[E_INVALID_ARG] The specified size(%f, %f) is out of range from min size(%d, %d) to max size(%d, %d).", + bounds.width, bounds.height, __minSize.width, __minSize.height, __maxSize.width, __maxSize.height); + + SetUpdateLayoutState(true); + + return SetBoundsFinal(bounds, true, callBoundsChangeCallbacks); +} + +// Custom Exception: ex) Location::Map +// E_INVALID_ARG +// E_UNSUPPORTED_OPERATION +result +_Control::SetBounds(const Rectangle& bounds, bool callBoundsChangeCallbacks) +{ + ClearLastResult(); + + if (callBoundsChangeCallbacks) + { + SysTryReturn(NID_UI, + IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION, + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable."); + } + FloatRectangle floatBounds(bounds.x, bounds.y, bounds.width, bounds.height); + + return SetBoundsInternal(floatBounds, callBoundsChangeCallbacks); +} + +// Custom Exception: ex) Location::Map +// E_INVALID_ARG +// E_UNSUPPORTED_OPERATION +result +_Control::SetBounds(const FloatRectangle& bounds, bool callBoundsChangeCallbacks) +{ + ClearLastResult(); + + if (callBoundsChangeCallbacks) + { + SysTryReturn(NID_UI, + IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION, + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable."); + } + + return SetBoundsInternal(bounds, callBoundsChangeCallbacks); +} + +// A custom Exception can occur. ex) Location::Map +// E_INVALID_ARG +// E_UNSUPPORTED_OPERATION +result +_Control::SetPosition(const Point& position) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, + IsMovable(), E_UNSUPPORTED_OPERATION, + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable."); + + return SetBoundsInternal(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height), true); +} + +// Custom Exception: ex) Location::Map +// E_INVALID_ARG +// E_UNSUPPORTED_OPERATION +result +_Control::SetSize(const Dimension& size) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, + IsResizable(), E_UNSUPPORTED_OPERATION, + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable."); + + return SetBoundsInternal(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height), true); +} + +Dimension +_Control::GetMinimumSize(void) const +{ + ClearLastResult(); + + return __minSize; +} + +Dimension +_Control::GetMaximumSize(void) const +{ + ClearLastResult(); + + return __maxSize; +} + +// Custom Exception: ex) Location::Map +// E_UNSUPPORTED_OPERATION +// E_INVALID_ARG +result +_Control::SetMinimumSize(const Dimension& newMinSize) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, + IsResizable(), E_UNSUPPORTED_OPERATION, + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable."); + + SysTryReturn(NID_UI, + (newMinSize.width >= 0 && newMinSize.height >= 0), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0."); + + SysTryReturn(NID_UI, + (newMinSize.width <= MAX_LENGTH && newMinSize.height <= MAX_LENGTH), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH); + + if (__maxSize.width < newMinSize.width) + { + __maxSize.width = newMinSize.width; + } + if (__maxSize.height < newMinSize.height) + { + __maxSize.height = newMinSize.height; + } + + __minSize = newMinSize; + return AdjustSizeToRange(); +} + +// Custom Exception: ex) Location::Map +// E_UNSUPPORTED_OPERATION +// E_INVALID_ARG +result +_Control::SetMaximumSize(const Dimension& newMaxSize) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, + IsResizable(), E_UNSUPPORTED_OPERATION, + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable."); + + SysTryReturn(NID_UI, + (newMaxSize.width >= 0 && newMaxSize.height >= 0), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0."); + + SysTryReturn(NID_UI, + (newMaxSize.width <= MAX_LENGTH && newMaxSize.height <= MAX_LENGTH), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH); + + if (newMaxSize.width < __minSize.width) + { + __minSize.width = newMaxSize.width; + } + if (newMaxSize.height < __minSize.height) + { + __minSize.height = newMaxSize.height; + } + + __maxSize = newMaxSize; + return AdjustSizeToRange(); +} + +Point +_Control::ConvertToControlPosition(const Point& screenPosition) const +{ + Point controlPosition; + Rectangle absoluteBounds = GetAbsoluteBounds(); + + controlPosition.x = screenPosition.x - absoluteBounds.x; + controlPosition.y = screenPosition.y - absoluteBounds.y; + + return controlPosition; +} + +Point +_Control::ConvertToScreenPosition(const Point& controlPosition) const +{ + Point screenPosition; + Rectangle absoluteBounds = GetAbsoluteBounds(); + + screenPosition.x = controlPosition.x + absoluteBounds.x; + screenPosition.y = controlPosition.y + absoluteBounds.y; + + return screenPosition; +} + +Rectangle +_Control::GetClientBounds(void) const +{ + if (!__isSetClientBounds) + { + return Rectangle(0, 0, __bounds.width, __bounds.height); + } + + return __clientBounds; +} + +Rectangle +_Control::GetClientBounds(const Dimension& size) const +{ + if (!__isSetClientBounds) + { + return Rectangle(0, 0, size.width, size.height); + } + + return __clientBounds; +} + +Rectangle +_Control::GetAbsoluteBounds(void) const +{ +#if !defined(MULTI_WINDOW) + Point accumPoint; + Rectangle absoluteBounds; + Rectangle clientBounds; + + const _Control* pSelf = this; + const _Control* pParent = GetParent(); + if (!pParent) + { + accumPoint += pSelf->GetPosition(); + } + + while (pParent) + { + if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT) && pParent) + { + clientBounds = pParent->GetClientBounds(); + accumPoint += Point(clientBounds.x, clientBounds.y); + accumPoint.x -= pParent->GetHorizontalScrollPosition(); + accumPoint.y -= pParent->GetVerticalScrollPosition(); + } + + accumPoint += pSelf->GetPosition(); + pSelf = pParent; + pParent = pParent->GetParent(); + } + + absoluteBounds.x = accumPoint.x; + absoluteBounds.y = accumPoint.y; + absoluteBounds.width = __bounds.width; + absoluteBounds.height = __bounds.height; + + return absoluteBounds; +#else + Point accumPoint; + Rectangle absoluteBounds; + Rectangle clientBounds; + + const _Control* pSelf = this; + const _Control* pParent = GetParent(); + + while (pParent) + { + if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT) && pParent) + { + clientBounds = pParent->GetClientBounds(); + accumPoint += Point(clientBounds.x, clientBounds.y); + accumPoint.x -= pParent->GetHorizontalScrollPosition(); + accumPoint.y -= pParent->GetVerticalScrollPosition(); + } + + accumPoint += pSelf->GetPosition(); + pSelf = pParent; + pParent = pParent->GetParent(); + } + + _Window* pWindow = GetRootWindow(); + + if (pWindow) + { + Point winPoint = pWindow->GetPosition(); + + accumPoint.x += winPoint.x; + accumPoint.y += winPoint.y; + } + + absoluteBounds.x = accumPoint.x; + absoluteBounds.y = accumPoint.y; + absoluteBounds.width = __bounds.width; + absoluteBounds.height = __bounds.height; + + return absoluteBounds; +#endif +} + +result +_Control::SetClientBounds(const Rectangle& bounds) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, + IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION, + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable."); + __clientBounds = bounds; + __isSetClientBounds = true; + + SetUpdateLayoutState(true); + + return E_SUCCESS; +} + +bool +_Control::IsCalledSetClientBounds(void) +{ + return __isSetClientBounds; +} + +Color +_Control::GetBackgroundColor(void) const +{ + ClearLastResult(); + return __backgroundColor; +} + +void +_Control::SetBackgroundColor(const Color& color) +{ + ClearLastResult(); + __backgroundColor = color; + + _ControlVisualElement* pCVE = dynamic_cast <_ControlVisualElement*>(GetVisualElement()); + if (pCVE) + { + pCVE->SetBackgroundColor( + _Colorf( + (float)color.GetRed() / 255.0f, + (float)color.GetGreen() / 255.0f, + (float)color.GetBlue() / 255.0f, + (float)color.GetAlpha() / 255.0f + ) + ); + } +} + +_Control::~_Control(void) +{ + __destroying = true; + + DetachAllChildren(); + DetachAllOwnees(); + _ControlManager::GetInstance()->TakeFocusFromControl(*this); + DisposeControl(); + ReleaseHandle(); + + if (__pFont) + { + delete __pFont; + __pFont = null; + } + +// Dangerous: it clears last result and log in catch block. +// ClearLastResult(); +} + +void +_Control::DisposeControl(void) +{ + __pControlDelegate = null; + + delete __pLayoutItemHandler; + __pLayoutItemHandler = null; + + delete __pLayoutContainer; + __pLayoutContainer = null; + + delete __pChildren; + __pChildren = null; + + delete __pOwnees; + __pOwnees = null; + + if (__pVisualElement) + { + __pVisualElement->Destroy(); + } + __pVisualElement = null; + + delete __pVisualElementContentProvider; + __pVisualElementContentProvider = null; + + delete __pVisualElementEventListener; + __pVisualElementEventListener = null; + + delete __pCoreGestureDetectors; + __pCoreGestureDetectors = null; + + delete __pDataBindingContext; + __pDataBindingContext = null; + + ClearStartedGestureDetectorList(); + delete __pDetectStartedGestureMap; + __pDetectStartedGestureMap = null; + + delete __pDelayedTouchInfoList; + __pDelayedTouchInfoList = null; + + delete __pAccessibilityContainer; + __pAccessibilityContainer = null; +} + +// E_OUT_OF_MEMORY +// E_SYSTEM +_Control::_Control(void) + : __name(L"") + , __pParent(null) + , __pChildren(null) + , __pOwnees(null) + , __bounds(0, 0, 0, 0) + , __clientBounds(0, 0, 0, 0) + , __absoluteBounds(0, 0, 0, 0) + , __invalidatedBounds(0, 0, 0, 0) + , __minSize(Dimension(0, 0)) + , __maxSize(Dimension(MAX_LENGTH, MAX_LENGTH)) + , __backgroundColor(Color::GetColor(COLOR_ID_BLACK)) + , __movable(true) + , __resizable(true) + , __focusable(true) + , __nativeObjectFocusable(true) + , __enabledState(true) + , __inputEnabledState(true) + , __visibleState(true) + , __initVisibleState(false) + , __clipToParent(true) + , __focusSet(false) + , __multiTouchEnabled(false) + , __dragEnabled(false) + , __dropEnabled(false) + , __drawWhenVisible(true) + , __isPostOrderTraversal(false) + , __isCalledCallOnAttachingToMainTree(false) + , __isCalledCallOnAttachedToMainTree(false) + , __isSetClientBounds(false) + , __isCalledGetCanvasN(false) + , __pVisualElementContentProvider(null) + , __pVisualElement(null) + , __pVisualElementEventListener(null) + , __pLayoutItemHandler(null) + , __pPortraitLayout(null) + , __pLandscapeLayout(null) + , __pLayoutContainer(null) + , __area(_CONTROL_AREA_NONE) + , __layer(_CONTROL_LAYER_NONE) + , __orientation(_CONTROL_ORIENTATION_PORTRAIT) + , __pTouchEventPreviewer(null) + , __pKeyEventPreviewer(null) + , __pNotificationEventPreviewer(null) + , __pKeyEventListener(null) + , __pFocusEventListener(null) + , __pNotificationEventListener(null) + , __pCoreGestureDetectors(null) + , __pDetectStartedGestureMap(null) + , __pDelayedTouchInfoList(null) + ,__touchMoveAllowance(TOUCH_MOVE_ALLOWANCE_SENSITIVE) + , __isSentDelayedEvent(false) + , __isSendingDelayedEvent(false) + , __isChangingEventTarget(false) + , __pDataBindingContext(null) + , __pControlDelegate(null) + , __pUserData(null) + , __destroying(false) + , __isEventReceivable(true) + , __isControlFontChanged(false) + , __pFont(null) + , __fontName(L"") +{ + ClearLastResult(); + + SetControlDelegate(*this); + __pAccessibilityContainer = new (std::nothrow) _AccessibilityContainer(*this); + + __pLayoutItemHandler = new (std::nothrow) LayoutItemHandler(this); + if (!__pLayoutItemHandler) + { + goto CATCH; + } + + __pLayoutContainer = CreateLayoutContainerN(__pLayoutItemHandler); + if (!__pLayoutContainer) + { + goto CATCH; + } + + __pChildren = ::CreateControlListN(); + if (!__pChildren) + { + goto CATCH; + } + + __pOwnees = ::CreateWindowListN(); + if (!__pOwnees) + { + goto CATCH; + } + + __pVisualElement = ::CreateVisualElementN(); + if (!__pVisualElement) + { + goto CATCH; + } + + __pVisualElement->SetUserData(this); + __pVisualElement->SetClipChildrenEnabled(true); + __pVisualElement->SetRedrawOnResizeEnabled(true); + + __pVisualElementContentProvider = new (std::nothrow) ControlVisualElementContentProvider(*this); + SysTryCatch(NID_UI, __pVisualElementContentProvider, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + GetVisualElement()->SetContentProvider(__pVisualElementContentProvider); + + __pVisualElementEventListener = new (std::nothrow) ControlVisualElementEventListener(*this); + SysTryCatch(NID_UI, __pVisualElementEventListener, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + GetVisualElement()->SetVisualElementEventListener(__pVisualElementEventListener); + + __pDetectStartedGestureMap = ::CreateGestureMapN(); + if (!__pDetectStartedGestureMap) + { + goto CATCH; + } + + __pCoreGestureDetectors = new (std::nothrow) LinkedListT<_TouchGestureDetector*>; + if (!__pCoreGestureDetectors) + { + goto CATCH; + } + + __pDelayedTouchInfoList = new (std::nothrow) LinkedListT<_TouchInfo*>; + if (!__pDelayedTouchInfoList) + { + goto CATCH; + } + + SetEventPreviewer<_UI_EVENT_TOUCH>(this); + SetEventPreviewer<_UI_EVENT_KEY>(this); + SetEventPreviewer<_UI_EVENT_NOTIFICAITON>(this); + + SetEventListener<_UI_EVENT_NOTIFICAITON>(this); + SetEventListener<_UI_EVENT_FOCUS>(this); + + SetPropagatedTouchEventListener(this); + SetPropagatedKeyEventListener(this); + _ResourceManager::GetInstance()->GetColor(L"DEFAULTCOLORTABLE::background", __backgroundColor); + + if (IsFailed(GetLastResult())) + { + SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult())); + } + + return; + +CATCH: + DisposeControl(); + return; +} + +void +_Control::AcquireHandle(void) +{ + __controlHandle = _ControlManager::GetInstance()->Register(this); // [ToDo] exception? +} + +void +_Control::ReleaseHandle(void) +{ + _ControlManager::GetInstance()->Release(__controlHandle); // [ToDo] exception? +} + +void +_Control::SetDrawWhenVisible(bool draw) +{ + __drawWhenVisible = draw; +} + +bool +_Control::IsDrawWhenVisible(void) +{ + return __drawWhenVisible; +} + +void +_Control::SetTerminatingOrder(bool postOrderTraversal) +{ + __isPostOrderTraversal = postOrderTraversal; +} + +void +_Control::SetParent(_Control* pParent) +{ + ClearLastResult(); + __pParent = pParent; +} + +// E_OUT_OF_MEMORY +// Only called by _Window::SetOwner(pOwner) +result +_Control::AttachOwnee(_Window& window) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _Control* pOldOwner = window.GetOwner(); + if (pOldOwner) + { + pOldOwner->DetachOwnee(window); + } + + r = __pOwnees->Add(&window); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_MEMORY); + SysLogException(NID_UI, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + return E_OUT_OF_MEMORY; + } + + return E_SUCCESS; +} + +int +_Control::GetOwneeCount(void) const +{ + ClearLastResult(); + return __pOwnees->GetCount(); +} + +// E_OUT_OF_RANGE +_Window* +_Control::GetOwnee(int index) const +{ + ClearLastResult(); + result r = E_SUCCESS; + + _Window* pOwnee = null; + r = __pOwnees->GetAt(index, pOwnee); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_RANGE); + SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range."); + return null; + } + + return pOwnee; +} + +// Called by _Window::SetOwner(null) +void +_Control::DetachOwnee(_Window& ownee) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _Control* pOwner = ownee.GetOwner(); + if (pOwner != this) + { + return; + } + + r = __pOwnees->Remove(&ownee); + SysAssert(r == E_SUCCESS); +} + +void +_Control::DetachAllOwnees(void) +{ + ClearLastResult(); + + int owneeCount = GetOwneeCount(); + while (owneeCount--) + { + _Window* pOwnee = GetOwnee(0); + + SysAssert(pOwnee); + if (pOwnee == null) + { + continue; + } + + pOwnee->SetOwner(null); + } +} + +_Layout::LayoutContainer& +_Control::GetLayoutContainer() const +{ + return *__pLayoutContainer; +} + +void +_Control::SetMultiTouchEnabled(bool enabled) +{ + ClearLastResult(); + __multiTouchEnabled = enabled; +} + +bool +_Control::IsMultiTouchEnabled(void) const +{ + ClearLastResult(); + return __multiTouchEnabled; +} + +void +_Control::SetMovable(bool movable) +{ + ClearLastResult(); + __movable = movable; +} + +void +_Control::SetResizable(bool resizable) +{ + ClearLastResult(); + + if (!resizable) + { + __minSize = __maxSize = GetSize(); + } + + if (!__resizable && resizable) + { + __minSize = Dimension(0, 0); + __maxSize = Dimension(MAX_LENGTH, MAX_LENGTH); + } + + __resizable = resizable; +} + +_Layout::Layout* +_Control::GetLayout(void) const +{ + ClearLastResult(); + _Layout::Layout* pLayout = __pLayoutContainer->GetLayout(); + + SysAssert(GetLastResult() == E_SUCCESS); + return pLayout; +} + +result +_Control::SetCurrentLayout(_Layout::Layout& layout) +{ + ClearLastResult(); + return __pLayoutContainer->SetCurrentLayout(layout); +} + +result +_Control::AddLayout(_Layout::Layout& layout) +{ + ClearLastResult(); + return __pLayoutContainer->AddLayout(layout); +} + +void +_Control::SetUpdateLayoutState(bool state) +{ + _Layout::Layout* pLayout = GetLayout(); + if (pLayout) + { + pLayout->SetUpdateState(state); + } +} + +_DataBindingContext* +_Control::GetDataBindingContext(void) +{ + return __pDataBindingContext; +} +_AccessibilityContainer* +_Control::GetAccessibilityContainer(void) +{ + return __pAccessibilityContainer; +} +void +_Control::SetDataBindingContext(_DataBindingContext* pDataBindingContext) +{ + __pDataBindingContext = pDataBindingContext; +} + +Tizen::Base::String +_Control::GetDescription(void) const +{ + return String(L""); +} + +void +_Control::SetTouchCapture(bool allowOutOfBounds) +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pTouchManager != null, E_SYSTEM, "[E_SYSTEM] TouchManager Instance is null"); + + pTouchManager->SetCapturedControl(this, allowOutOfBounds); +} + +void +_Control::ReleaseTouchCapture(void) +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pTouchManager != null, E_SYSTEM, "[E_SYSTEM] TouchManager Instance is null"); + + pTouchManager->SetCapturedControl(null, false); +} + +_Control* +_Control::GetTopmostChildAt(const Point& point) const +{ + _Control* pTouchedControl = null; + FloatPoint ptf((float) point.x, (float) point.y); + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist."); + +#if !defined(MULTI_WINDOW) + _ControlVisualElement* pRootControlElement = + dynamic_cast <_ControlVisualElement*>(pControlManager->GetRoot().GetVisualElement()); +#else + _Window* pRootWindow = GetRootWindow(); + SysTryReturn(NID_UI, pRootWindow, null, E_SYSTEM, "[E_SYSTEM] GetRootWindow() is null, this control is detached from the main trree"); + + _ControlVisualElement* pRootControlElement = + dynamic_cast <_ControlVisualElement*>(pRootWindow->GetVisualElement()); +#endif + + SysTryReturn(NID_UI, pRootControlElement, null, E_SYSTEM, "[E_SYSTEM] pRootControlElement is null."); + + _ControlVisualElement* pHitTestElm = pRootControlElement->GetControlChildAtPoint(ptf); + SysTryReturn(NID_UI, pHitTestElm, null, E_SYSTEM, "[E_SYSTEM] pHitTestElm is null."); + + pTouchedControl = static_cast <_Control*>(pHitTestElm->GetUserData()); + + return pTouchedControl; +} + +Bitmap* +_Control::GetCapturedBitmapN(bool includeChildren) const +{ + result r = E_SUCCESS; + + Canvas* pCanvas = null; + Bitmap* pBitmap = null; + + pBitmap = GetControlDelegate().OnCapturedBitmapRequestedN(); + if (pBitmap == null) + { + FloatRectangle rect; + + Rectangle boundsInCanvas = GetBounds(); + boundsInCanvas.x = boundsInCanvas.y = 0; + + pCanvas = new (std::nothrow) Canvas; + SysTryReturn(NID_UI, pCanvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + r = pCanvas->Construct(boundsInCanvas); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r)); + + GetVisualElement()->Draw(); + ClearLastResult(); // [ToDo] Temp. + + rect.SetBounds(boundsInCanvas.x, boundsInCanvas.y, boundsInCanvas.width, boundsInCanvas.height); + + r = GetVisualElement()->Capture(*pCanvas, rect, includeChildren); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r)); + + pBitmap = new (std::nothrow) Bitmap; + SysTryCatch(NID_UI, pBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + r = pBitmap->Construct(*pCanvas, boundsInCanvas); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_MEMORY); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + } + + SysLog(NID_UI, "Bitmap (width:%d, height:%d)", pBitmap->GetWidth(), pBitmap->GetHeight()); + + delete pCanvas; + } + + return pBitmap; + +CATCH: + delete pCanvas; + delete pBitmap; + SetLastResult(r); + + return null; +} + +Tizen::Graphics::Rectangle +_Control::GetInvalidatedBounds(void) const +{ + return __invalidatedBounds; +} + +result +_Control::AddGestureDetector(const _TouchGestureDetector& gestureDetector) +{ + ClearLastResult(); + + bool exist = __pCoreGestureDetectors->Contains(const_cast<_TouchGestureDetector*>(&gestureDetector)); + SysTryReturnResult(NID_UI, exist == false, E_OBJ_ALREADY_EXIST, "[E_OBJ_ALREADY_EXIST]__pCoreGestureDetectors has gesture already"); + + result r = __pCoreGestureDetectors->Add(const_cast<_TouchGestureDetector*>(&gestureDetector)); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = const_cast<_TouchGestureDetector&>(gestureDetector).SetControl(*this); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "Control handle is not valid."); + + return r; +} + +result +_Control::RemoveGestureDetector(const _TouchGestureDetector& gestureDetector) +{ + ClearLastResult(); + + result r = __pCoreGestureDetectors->Remove(&(const_cast<_TouchGestureDetector&>(gestureDetector))); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +IListT <_TouchGestureDetector*>* +_Control::GetGestureDetectorList(void) const +{ + return __pCoreGestureDetectors; +} + +IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* +_Control::GetStartedGestureDetectorEnumeratorN(void) const +{ + return __pDetectStartedGestureMap->GetMapEnumeratorN(); +} + +result +_Control::AddStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + bool exist = false; + __pDetectStartedGestureMap->ContainsKey(const_cast<_TouchGestureDetector*>(&gestureDetector), exist); + + if (exist == false) + { + r = __pDetectStartedGestureMap->Add(const_cast<_TouchGestureDetector*>(&gestureDetector), state); + } + + return r; +} + +result +_Control::SetStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + bool exist = false; + __pDetectStartedGestureMap->ContainsKey(const_cast<_TouchGestureDetector*>(&gestureDetector), exist); + + if (exist == true) + { + r = __pDetectStartedGestureMap->SetValue(const_cast<_TouchGestureDetector*>(&gestureDetector), state); + } + + return r; +} + +result +_Control::ClearStartedGestureDetectorList(void) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + IListT<_TouchGestureDetector*>* pList = __pDetectStartedGestureMap->GetKeysN(); + if (pList) + { + IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGestureDetector = null; + pEnumerator->GetCurrent(pGestureDetector); + + if (pGestureDetector == null) + { + continue; + } + + __pDetectStartedGestureMap->Remove(pGestureDetector); + } + delete pEnumerator; + } + delete pList; + } + + IEnumeratorT<_TouchInfo*>* pEnumerator = __pDelayedTouchInfoList->GetEnumeratorN(); + if(pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchInfo* pTouchInfo = null; + pEnumerator->GetCurrent(pTouchInfo); + if (pTouchInfo == null) + { + continue; + } + + delete pTouchInfo; + } + + __pDelayedTouchInfoList->RemoveAll(); + delete pEnumerator; + } + + __isSentDelayedEvent = false; + __isSendingDelayedEvent = false; + + return r; +} + +bool +_Control::IsDelayedTouchEventEnabled(void) const +{ + bool existDelayTouchEventGesture = false; + + IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN(); + if (pMapEnumerator) + { + while(pMapEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGestureDetector = null; + pMapEnumerator->GetKey(pGestureDetector); + + if (pGestureDetector == null) + { + continue; + } + + _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY; + pMapEnumerator->GetValue(state); + + if (pGestureDetector->IsDelayTouchEventEnabled()) + { + existDelayTouchEventGesture = true; + } + } + delete pMapEnumerator; + } + + bool delayTouchEvent = false; + if (existDelayTouchEventGesture) + { + pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN(); + if (pMapEnumerator) + { + while(pMapEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGestureDetector = null; + pMapEnumerator->GetKey(pGestureDetector); + + if (pGestureDetector == null) + { + continue; + } + + _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY; + pMapEnumerator->GetValue(state); + + if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED) + { + delayTouchEvent = true; + break; + } + } + delete pMapEnumerator; + } + + return delayTouchEvent; + } + else + { + return false; + } +} + +bool +_Control::IsPossibleToSendDelayedTouchEvent(void) const +{ + bool existDelayTouchEventGesture = false; + + IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN(); + if (pMapEnumerator) + { + while(pMapEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGestureDetector = null; + pMapEnumerator->GetKey(pGestureDetector); + + if (pGestureDetector == null) + { + continue; + } + + _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY; + pMapEnumerator->GetValue(state); + + if (pGestureDetector->IsDelayTouchEventEnabled()) + { + existDelayTouchEventGesture = true; + } + } + delete pMapEnumerator; + } + + bool allFailed = true; + if (existDelayTouchEventGesture) + { + pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN(); + if (pMapEnumerator) + { + while(pMapEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGestureDetector = null; + pMapEnumerator->GetKey(pGestureDetector); + + if (pGestureDetector == null) + { + continue; + } + + _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY; + pMapEnumerator->GetValue(state); + + if (state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS) + { + allFailed = false; + break; + } + } + delete pMapEnumerator; + } + + return allFailed; + } + else + { + return false; + } +} + +bool +_Control::IsCancelOnGestureSuccess(void) const +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysAssert(pTouchManager != null); + + IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN(); + if (pMapEnumerator) + { + while(pMapEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGestureDetector = null; + pMapEnumerator->GetKey(pGestureDetector); + + if (pGestureDetector == null) + { + continue; + } + + _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY; + pMapEnumerator->GetValue(state); + + if (pGestureDetector->IsCancelTouchEventOnSuccessEnabled() && state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS && !pTouchManager->IsTouchCanceledOnGestureSuccess()) + { + delete pMapEnumerator; + return true; + } + } + delete pMapEnumerator; + } + + return false; +} + +bool +_Control::IsSentDelayedEvent(void) const +{ + return __isSentDelayedEvent; +} + +void +_Control::SetSentDelayedEvent(bool sent) +{ + __isSentDelayedEvent = sent; +} + +void +_Control::SetSendingDelayedEvent(bool sending) +{ + __isSendingDelayedEvent = sending; +} + +bool +_Control::IsSendingDelayedEvent(void) const +{ + return __isSendingDelayedEvent; +} + +void +_Control::AddTouchInfo(const _TouchInfo& touchInfo) +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist."); + + _TouchInfo* pTouchInfo = new (std::nothrow) _TouchInfo; + SysTryReturnVoidResult(NID_UI, pTouchInfo, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Point screenPoint = pTouchManager->GetScreenPoint(touchInfo.GetPointId()); + pTouchInfo->SetTouchInfo(touchInfo.GetPointId(), touchInfo.GetTouchStatus(), screenPoint, false, 0); + __pDelayedTouchInfoList->Add(pTouchInfo); +} + +IListT<_TouchInfo*>* +_Control::GetTouchInfoList(void) +{ + return __pDelayedTouchInfoList; +} + +_VisualElement* +_Control::GetVisualElement(void) const +{ + SysAssert(__pVisualElement); + return __pVisualElement; +} + +void +_Control::PrintDescription(bool printChildren) +{ + int count = PrintDescription(printChildren, 0); + + SysLog(NID_UI, "%d controls were printed.", count); +} + +int +_Control::PrintDescription(bool printChildren, int depth) +{ + String indent(L""); + String format(L""); + + format.Format(LOG_LEN_MAX, L"%d", depth); + + for (int i = 0; i < depth; i++) + { + indent.Append(L" "); + } + + indent.Append(format); + + String delimiter(L"-------------------------------------------------------------------------------------------"); + SysLog(NID_UI, "%ls", delimiter.GetPointer()); + + // Public + String publicDescription = GetControlDelegate().GetDescription(); + if (!publicDescription.IsEmpty()) + { + SysLog(NID_UI, "%ls %ls", indent.GetPointer(), publicDescription.GetPointer()); + } + + // Core + SysLog(NID_UI, "%ls 0x%x(%d %ls) enable(%d) enableState(%d) visible(%d) visibleState(%d) focusable(%d) clip(%d) movable(%d) resizable(%d)", + indent.GetPointer(), this, __controlHandle.ToInt(), GetName().GetPointer(), IsEnabled(), GetEnableState(), IsVisible(), GetVisibleState(), + IsFocusable(), IsClipToParent(), IsMovable(), IsResizable()); + + Rectangle bounds = GetBounds(); + Dimension min = GetMinimumSize(); + Dimension max = GetMaximumSize(); + Rectangle clientBounds = GetClientBounds(); + Rectangle absoluteBounds = GetAbsoluteBounds(); + + SysLog(NID_UI, "%ls bounds(%d %d %d %d) min(%d %d) max(%d %d) scrollPos(%d %d) cbounds(%d %d %d %d) abounds(%d %d %d %d)", + indent.GetPointer(), bounds.x, bounds.y, bounds.width, bounds.height, + min.width, min.height, max.width, max.height, + GetVerticalScrollPosition(), GetHorizontalScrollPosition(), + clientBounds.x, clientBounds.y, clientBounds.width, clientBounds.height, + absoluteBounds.x, absoluteBounds.y, absoluteBounds.width, absoluteBounds.height); + + SysLog(NID_UI, "%ls bgColor(0x%x) layoutable(%d) orientation(%d) drag(%d) drop(%d) area(%d) layer(%d)", + indent.GetPointer(), __backgroundColor.GetRGB32(), IsLayoutable(), GetOrientation(), IsDragEnabled(), IsDropEnabled(), GetArea(), GetLayer()); + + Canvas* pCanvas = GetCanvasN(); + if (pCanvas) + { + Rectangle canvasBounds = pCanvas->GetBounds(); + Color canvasBackgroundColor = pCanvas->GetBackgroundColor(); + Color canvasForegroundColor = pCanvas->GetForegroundColor(); + + SysLog(NID_UI, "%ls canvas.bounds(%d %d %d %d) canvas.bgColor(0x%x) canvas.fgColor(0x%x)", + indent.GetPointer(), canvasBounds.x, canvasBounds.y, canvasBounds.width, canvasBounds.height, canvasBackgroundColor.GetRGB32(), canvasForegroundColor.GetRGB32()); + + delete pCanvas; + } + + SysLog(NID_UI, "%ls DataBindingContext(0x%x) ControlDelegate(0x%x) UserData(0x%x) destroying(%d)", + indent.GetPointer(), __pDataBindingContext, __pControlDelegate, __pUserData, __destroying); + + // Ownees + String ownees(L""); + + for (int i = 0; i < GetOwneeCount(); ++i) + { + String ownee(L""); + _Window* pOwnee = GetOwnee(i); + if (pOwnee) + { + ownee.Format(LOG_LEN_MAX, L"0x%x ", pOwnee); + ownees.Append(ownee); + } + } + + if (!ownees.IsEmpty()) + { + SysLog(NID_UI, "%ls Ownees(%ls)", indent.GetPointer(), ownees.GetPointer()); + } + + SysLog(NID_UI, "%ls VisualElement(0x%x) VisualElementContentProvider(0x%x) VisualElementEventListener(0x%x)", + indent.GetPointer(), GetVisualElement(), __pVisualElementContentProvider, __pVisualElementEventListener); + + // Layout + SysLog(NID_UI, "%ls LayoutItemHandler(0x%x) PortraitLayout(0x%x) LandscapeLayout(0x%x) LayoutContainer(0x%x)", + indent.GetPointer(), __pLayoutItemHandler, __pPortraitLayout, __pLandscapeLayout, __pLayoutContainer); + + // Derived class + String description = GetDescription(); + if (!description.IsEmpty()) + { + SysLog(NID_UI, "%ls %ls", indent.GetPointer(), description.GetPointer()); + } + + // Print Gesture List + IListT<_TouchGestureDetector*>* pGestureList = GetGestureDetectorList(); + SysTryReturn(NID_UI, pGestureList, 0, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pGestureList->GetEnumeratorN(); + SysTryReturn(NID_UI, pEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGestureDetector = null; + pEnumerator->GetCurrent(pGestureDetector); + if (pGestureDetector) + { + SysLog(NID_UI, "%ls %ls", indent.GetPointer(), pGestureDetector->GetDescription().GetPointer()); + } + } + + delete pEnumerator; + + + static int totalCount = 0; + + if (depth == 0) + { + totalCount = 0; + } + + if (printChildren) + { + depth ++; + + int count = GetChildCount(); + totalCount += count; + + for (int i = count - 1; i >= 0; --i) + { + _Control* pChild = GetChild(i); + if (pChild) + { + pChild->PrintDescription(printChildren, depth); + } + } + } + + return totalCount; +} + +_ITouchEventPreviewer* +_Control::GetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>) const +{ + return __pTouchEventPreviewer; +} + +_IKeyEventPreviewer* +_Control::GetEventPreviewer(_IntToType<_UI_EVENT_KEY>) const +{ + return __pKeyEventPreviewer; +} + +_INotificationEventPreviewer* +_Control::GetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>) const +{ + return __pNotificationEventPreviewer; +} + +_IKeyEventListener* +_Control::GetEventListener(_IntToType<_UI_EVENT_KEY>) const +{ + return __pKeyEventListener; +} + +_IFocusEventListener* +_Control::GetEventListener(_IntToType<_UI_EVENT_FOCUS>) const +{ + return __pFocusEventListener; +} + +_INotificationEventListener* +_Control::GetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>) const +{ + return __pNotificationEventListener; +} + +void +_Control::SetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>, _ITouchEventPreviewer* pPreviewer) +{ + __pTouchEventPreviewer = pPreviewer; +} + +void +_Control::SetEventPreviewer(_IntToType<_UI_EVENT_KEY>, _IKeyEventPreviewer* pPreviewer) +{ + __pKeyEventPreviewer = pPreviewer; +} + +void +_Control::SetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventPreviewer* pPreviewer) +{ + __pNotificationEventPreviewer = pPreviewer; +} + +void +_Control::SetEventListener(_IntToType<_UI_EVENT_FOCUS>, _IFocusEventListener* pListener) +{ + __pFocusEventListener = pListener; +} + +void +_Control::SetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventListener* pListener) +{ + __pNotificationEventListener = pListener; +} + +bool +_Control::IsDragEnabled(void) const +{ + return __dragEnabled; +} + +bool +_Control::IsDropEnabled(void) const +{ + return __dropEnabled; +} + +void +_Control::SetDragEnabled(bool enabled) +{ + __dragEnabled = enabled; +} + +void +_Control::SetDropEnabled(bool enabled) +{ + __dropEnabled = enabled; +} + +void +_Control::SetTouchMoveAllowance(_TouchMoveAllowance touchMoveAllowanceType) +{ + __touchMoveAllowance = touchMoveAllowanceType; +} + +_TouchMoveAllowance +_Control::GetTouchMoveAllowance(void) const +{ + return __touchMoveAllowance; +} + +void +_Control::SetChangingEventTarget(bool isChangingEventTarget) +{ + __isChangingEventTarget = isChangingEventTarget; +} + +bool +_Control::GetChangingEventTarget(void) const +{ + return __isChangingEventTarget; +} + +void +_Control::SetEventReceivable(bool receivable) +{ + __isEventReceivable = receivable; +} + +bool +_Control::IsEventReceivable(void) const +{ + return __isEventReceivable; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_ControlImpl.cpp b/src/ui/FUi_ControlImpl.cpp new file mode 100755 index 0000000..08eea3b --- /dev/null +++ b/src/ui/FUi_ControlImpl.cpp @@ -0,0 +1,3545 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ControlImpl.cpp + * @brief This is the implementation file for _ControlImpl class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_ControlImpl.h" +#include "FUi_ContainerImpl.h" +#include "FUi_Control.h" +#include "FUi_ControlManager.h" +#include "FUi_ControlImplManager.h" +#include "FUi_UiEventManager.h" +#include "FUi_UiNotificationEvent.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_TouchManager.h" +#include "FUi_TouchEventArg.h" +#include "FUi_ITouchLongPressGestureEventListener.h" +#include "FUi_TouchFlickGestureDetector.h" +#include "FUi_TouchGestureDetectorImpl.h" +#include "FUi_AccessibilityContainerImpl.h" +#include "FUi_ResourceManager.h" +#if defined(MULTI_WINDOW) +#include "FUi_WindowImpl.h" +#endif +#include "FUiAnim_VisualElement.h" +#include "FUiAnim_VisualElementImpl.h" + +//#define _TC_PASS + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::App; +using namespace Tizen::Base::Utility; + +namespace Tizen { namespace Ui { + +_ControlImpl::SizeInfo::~SizeInfo(void) +{ +} + +Dimension +_ControlImpl::SizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + return Dimension(0, 0); +} + +Dimension +_ControlImpl::SizeInfo::GetDefaultMaximumSize(_ControlOrientation orientation) const +{ + return Dimension(_Control::MAX_LENGTH, _Control::MAX_LENGTH); +} + +Dimension +_ControlImpl::SizeInfo::GetMinimumSizeLimit(_ControlOrientation orientation) const +{ + return Dimension(0, 0); +} + +Dimension +_ControlImpl::SizeInfo::GetMaximumSizeLimit(_ControlOrientation orientation) const +{ + return Dimension(_Control::MAX_LENGTH, _Control::MAX_LENGTH); +} + +result +_ControlImpl::SizeInfo::CheckInitialSizeValid(const Dimension& size, _ControlOrientation orientation) const +{ + ClearLastResult(); + + const Dimension minSize = GetDefaultMinimumSize(orientation); + const Dimension maxSize = GetDefaultMaximumSize(orientation); + + SysTryReturn(NID_UI, + (minSize.width <= size.width) && (size.width <= maxSize.width), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The width %d is out of width range(%d ~ %d).", + size.width, minSize.width, maxSize.width); + + SysTryReturn(NID_UI, + (minSize.height <= size.height) && (size.height <= maxSize.height), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The height %d is out of height range(%d ~ %d).", + size.height, minSize.height, maxSize.height); + + return E_SUCCESS; +} + +const _ControlImpl::SizeInfo& +_ControlImpl::GetFullScreenSizeInfo(void) +{ + class FullScreenSizeInfo : public _ControlImpl::SizeInfo + { + public: + virtual Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const + { + return GetScreenSize(); + } + + virtual Dimension GetDefaultMaximumSize(_ControlOrientation orientation) const + { + return GetScreenSize(); + } + + virtual Dimension GetMinimumSizeLimit(_ControlOrientation orientation) const + { + return GetScreenSize(); + } + + virtual Dimension GetMaximumSizeLimit(_ControlOrientation orientation) const + { + return GetScreenSize(); + } + + private: + Dimension GetScreenSize(void) const + { + _ControlManager* pMgr = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pMgr, Dimension(0, 0), E_SYSTEM, "[E_SYSTEM] Failed to get control manager."); + return pMgr->GetScreenSize(); + } + }; + + static FullScreenSizeInfo sizeInfo; + return sizeInfo; +} + +// [ToDo] How to turn-off callback while initializing: Reset/Set delegate? +result +_ControlImpl::InitializeBoundsProperties(const SizeInfo& sizeInfo, _ControlOrientation orientation) +{ + result r = E_SUCCESS; + + bool resizable = IsResizable(); + SetResizable(true); + + r = SetMinimumSize(sizeInfo.GetDefaultMinimumSize(orientation)); + SysTryReturn(NID_UI, + r == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] Failed to initialize default minimum size."); + + r = SetMaximumSize(sizeInfo.GetDefaultMaximumSize(orientation)); + SysTryReturn(NID_UI, + r == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] Failed to initialize default maximum size."); + + SetResizable(resizable); + + return E_SUCCESS; +} + +result +_ControlImpl::InitializeBoundsProperties(const SizeInfo& sizeInfo, const Tizen::Graphics::Rectangle& bounds, _ControlOrientation orientation) +{ + result r = InitializeBoundsProperties(sizeInfo, orientation); + if (IsFailed(r)) + { + return r; + } + + bool movable = IsMovable(); + bool resizable = IsResizable(); + SetMovable(true); + SetResizable(true); + + r = SetBounds(bounds); + + SetMovable(movable); + SetResizable(resizable); + + return r; +} + +result +_ControlImpl::InitializeBoundsProperties(const SizeInfo& sizeInfo, const Tizen::Graphics::Dimension& size, _ControlOrientation orientation) +{ + return InitializeBoundsProperties(sizeInfo, Rectangle(0, 0, size.width, size.height), orientation); +} + +_ControlImpl* +_ControlImpl::CreateControlImplN(Control& control) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _Control* pCore = _Control::CreateControlN(); + r = GetLastResult(); + SysTryReturn(NID_UI, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _ControlImpl* pImpl = new (std::nothrow) _ControlImpl(&control, pCore); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; +} + +_ControlImpl* +_ControlImpl::GetInstance(Control& control) +{ + return static_cast <_ControlImpl*> (control._pControlImpl); +} + +const _ControlImpl* +_ControlImpl::GetInstance(const Control& control) +{ + return static_cast (control._pControlImpl); +} + +result +_ControlImpl::CheckConstruction(_Control* pCore, _ControlImpl* pImpl) +{ + if (pImpl == null) + { + delete pCore; + pCore = null; + SysLogException(NID_UI, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + return E_OUT_OF_MEMORY; + } + + result r = GetLastResult(); + if (IsFailed(r)) + { + delete pImpl; + pImpl = null; + SysLogException(NID_UI, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + + return E_SUCCESS; +} + +const Tizen::Base::String _USER_EVENT = L"UserEvent"; +const Tizen::Base::String _REQUEST_REDRAW_EVENT = L"RequestRedrawEvent"; +const Tizen::Base::String _KEYBOARD_INSERTED_EVENT = L"KeyboardInsertedEvent"; +const int keyPressTimer = 500; +const int doublePressTime = 330; +const int doublePressMoveAllowance = 10; + +class _UserEventInfo + : public Tizen::Base::Object +{ +public: + _UserEventInfo(RequestId requestId, const IList* pArgs) + : __requestId(requestId) + , __pArgs(const_cast (pArgs)) + { + } + virtual ~_UserEventInfo(void) {} + + RequestId GetRequestId(void) const + { + return __requestId; + } + + IList* GetArgs(void) + { + return __pArgs; + } + +private: + _UserEventInfo(const _UserEventInfo& rhs); + _UserEventInfo& operator =(const _UserEventInfo& rhs); + +private: + RequestId __requestId; + IList* __pArgs; +}; + +class _ControlImpl::CoreKeyEvent +{ +public: + CoreKeyEvent(_ControlImpl& impl) + : __impl(impl) + , __core(impl.GetCore()) + , __public(impl.GetPublic()) + { + } + + ~CoreKeyEvent(void) + { + } + +private: + bool IsPublicKey(_KeyCode keyCode) + { + bool isPublicKey = false; + + if (keyCode <= _KEY_HARDWARE_MAX) + { + isPublicKey = true; + } + + return isPublicKey; + } + + result FirePublicListener(IKeyEventListener& listener, KeyState keyState, KeyCode keyCode) + { + result r = E_SUCCESS; + + switch (keyState) + { + case KEY_PRESSED: + listener.OnKeyPressed(__public, keyCode); + break; + case KEY_RELEASED: + listener.OnKeyReleased(__public, keyCode); + break; + case KEY_LONGPRESSED: + listener.OnKeyLongPressed(__public, keyCode); + break; + default: + SysAssert(0); + r = E_SYSTEM; + break; + } + + return r; + } + +public: + bool ProcessListener(KeyState keyState, _KeyCode keyCode) + { + bool filterd = false; + + // 1. Public + if (IsPublicKey(keyCode)) + { + IEnumeratorT * pEnumerator = __impl.__pPublicKeyEventListeners->GetEnumeratorN(); + if (pEnumerator) + { + while (pEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + + IKeyEventListener* pKeyEventListener = dynamic_cast (pListener); + if (pKeyEventListener) + { + FirePublicListener(*pKeyEventListener, keyState, (KeyCode)keyCode); + } + } + delete pEnumerator; + } + } + + if (__impl.IsInputEventConsumed()) + { + __impl.ResetInputEventConsumed(); + + filterd = true; + return filterd; + } + + // 2. Default + if (IsPublicKey(keyCode)) + { + IKeyEventListener* pDefaultListener = __impl.GetDefaultKeyEventListener(); + if (pDefaultListener) + { + FirePublicListener(*pDefaultListener, keyState, (KeyCode)keyCode); + + if (__impl.IsInputEventConsumed()) + { + __impl.ResetInputEventConsumed(); + + filterd = true; + return filterd; + } + } + } + + return filterd; + } + +private: + CoreKeyEvent(const CoreKeyEvent& rhs); + CoreKeyEvent& operator =(const CoreKeyEvent& rhs); + +private: + _ControlImpl& __impl; + _Control& __core; + Control& __public; +}; + +class _ControlImpl::CoreTouchEvent +{ +public: + CoreTouchEvent(_ControlImpl& impl) + : __impl(impl) + , __core(impl.GetCore()) + , __public(impl.GetPublic()) + , __oldPreviousPressedTime(0) + , __previousPressedTime(0) + , __currentPressedTime(0) + , __previousPressedPoint(0, 0) + , __currentPressedPoint(0, 0) + + { + __pTouchManager = _TouchManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, __pTouchManager, E_SYSTEM, "[E_SYSTEM] System error occurred."); + } + + ~CoreTouchEvent(void) + { + } + + +private: + _TouchEventArg* GetTouchEventArgN(const _TouchInfo& touchInfo) + { + _TouchEventArg* pEventArg = new (std::nothrow) _TouchEventArg(__public, touchInfo.GetTouchStatus()); + SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + Point startPoint(__pTouchManager->GetStartPoint(touchInfo.GetPointId()).x - __core.GetAbsoluteBounds().x, + __pTouchManager->GetStartPoint(touchInfo.GetPointId()).y - __core.GetAbsoluteBounds().y); + + pEventArg->SetTouchPosition(touchInfo.GetPointId(), startPoint.x, startPoint.y, + touchInfo.GetCurrentPosition().x, touchInfo.GetCurrentPosition().y); + + int xDistance = 0; + int yDistance = 0; + __impl.__pFlickGestureDetector->GetDistance(xDistance, yDistance); + + if (xDistance != 0 || yDistance != 0) + { + pEventArg->SetFlickedStatus(true); + } + else + { + pEventArg->SetFlickedStatus(false); + } + + return pEventArg; + } + + result FirePublicListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo) + { + result r = E_SUCCESS; + + switch (touchEventInfo.GetTouchStatus()) + { + case TOUCH_PRESSED: + listener.OnTouchPressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_LONG_PRESSED: + listener.OnTouchLongPressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_RELEASED: + listener.OnTouchReleased(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_MOVED: + listener.OnTouchMoved(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_DOUBLE_PRESSED: + listener.OnTouchDoublePressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_FOCUS_IN: + listener.OnTouchFocusIn(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_FOCUS_OUT: + listener.OnTouchFocusOut(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_CANCELED: + listener.OnTouchCanceled(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + default: + SysAssert(0); + r = E_SYSTEM; + break; + } + + return r; + } + + result FireFocusListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo) + { + result r = E_SUCCESS; + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + Point screenPoint(pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).x, pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).y); + + _Control* pTouchedControl = pControlManager->GetTopmostTouchedControl(screenPoint); + SysTryReturn(NID_UI, pTouchedControl, E_INVALID_CONDITION, E_INVALID_CONDITION, "[E_INVALID_CONDITION] pTouchedControl is null."); + + if (__pTouchManager->GetFocusedControlSource() != pTouchedControl) + { + if (&(__core) != pTouchedControl) + { + if (__pTouchManager->GetFocusedControlSource() == &(__core)) + { + listener.OnTouchFocusOut(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo); + } + } + else + { + listener.OnTouchFocusIn(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo); + } + + __pTouchManager->SetFocusedControlSource(*pTouchedControl); + } + + return r; + } + +public: + result ProcessDragListener(const _TouchInfo& touchInfo) + { + if (!__core.IsDragEnabled()) + { + return E_INVALID_CONDITION; + } + + result r = E_SUCCESS; + + IEnumeratorT * pDragEnumerator = __impl.__pPublicDragDropEventListeners->GetEnumeratorN(); + if (pDragEnumerator) + { + while (pDragEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pDragListener = null; + pDragEnumerator->GetCurrent(pDragListener); + + if (pDragListener != null) + { + IDragDropEventListener* pDragDropEventListener = dynamic_cast (pDragListener); + if (pDragDropEventListener != null) + { + pDragDropEventListener->OnTouchDragged(__public, touchInfo.GetCurrentPosition(), touchInfo.GetCurrentPosition()); + } + } + } + delete pDragEnumerator; + } + + return r; + } + + result ProcessDropListener(const _TouchInfo& touchInfo) + { + if (!__core.IsDropEnabled()) + { + return E_INVALID_CONDITION; + } + + result r = E_SUCCESS; + + _Control* pDraggedControl = __pTouchManager->GetTouchControlSource(); + if (pDraggedControl != null) + { + IEnumeratorT* pDropEnumerator = __impl.__pPublicDragDropEventListeners->GetEnumeratorN(); + if (pDropEnumerator) + { + while (pDropEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pDropListener = null; + pDropEnumerator->GetCurrent(pDropListener); + + if (pDropListener != null) + { + IDragDropEventListener* pDropEventListener = dynamic_cast (pDropListener); + if (pDropEventListener != null) + { + pDropEventListener->OnTouchDropped(__public, __pTouchManager->GetStartPoint(touchInfo.GetPointId()), touchInfo.GetCurrentPosition()); + } + } + } + + delete pDropEnumerator; + } + } + + return r; + } + + result ProcessDropListenerToTopControl(const _TouchInfo& touchInfo) + { + result r = E_SUCCESS; + Point pt(__pTouchManager->GetScreenPoint(touchInfo.GetPointId()).x, __pTouchManager->GetScreenPoint(touchInfo.GetPointId()).y); + + _Control* pCapturedControl = __pTouchManager->GetCapturedControl(); + _Control* pDraggedControl = __pTouchManager->GetTouchControlSource(); + if (!pDraggedControl || pCapturedControl) + { + r = E_SUCCESS; + return r; + } + + _Control* pTopmostTouchedSource = __core.GetTopmostChildAt(pt); + if (!pTopmostTouchedSource) + { + r = E_SUCCESS; + return r; + } + + if (!pTopmostTouchedSource->IsDragEnabled()) + { + return E_INVALID_CONDITION; + } + + TouchEventInfo publicTouchInfo; + + _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo); + SysTryReturn(NID_UI, pEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + publicTouchInfo.Construct(*pEventArg); + + if (pTopmostTouchedSource != pDraggedControl) + { + _ControlImpl* pTopmostTouchedTarget = static_cast <_ControlImpl*>(pTopmostTouchedSource->GetUserData()); + SysTryCatch(NID_UI, pTopmostTouchedTarget, , E_SYSTEM, "[E_SYSTEM] System error occurred."); + + IEnumeratorT * pDropEnumerator = + pTopmostTouchedTarget->GetDragDropEventListener()->GetEnumeratorN(); + + if (pDropEnumerator) + { + while (pDropEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pDropListener = null; + pDropEnumerator->GetCurrent(pDropListener); + + if (pDropListener != null) + { + IDragDropEventListener* pDropEventListener = dynamic_cast (pDropListener); + if (pDropEventListener != null) + { + pDropEventListener->OnTouchDropped(pTopmostTouchedTarget->GetPublic(), + publicTouchInfo.GetStartPosition(), touchInfo.GetCurrentPosition()); + } + } + } + delete pDropEnumerator; + } + + IEnumeratorT * pEnumerator = + pTopmostTouchedTarget->GetTouchEventListener()->GetEnumeratorN(); + + if (pEnumerator) + { + while (pEnumerator->MoveNext() == E_SUCCESS) + { + Runtime::IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + + if (pListener != null) + { + ITouchEventListener* pPublicListener = dynamic_cast (pListener); + SysAssert(pPublicListener); + + pPublicListener->OnTouchReleased(pTopmostTouchedTarget->GetPublic(), touchInfo.GetCurrentPosition(), publicTouchInfo); + } + } + delete pEnumerator; + } + + if (pTopmostTouchedTarget->IsInputEventConsumed()) + { + pTopmostTouchedTarget->ResetInputEventConsumed(); + } + + // 2. Default + ITouchEventListener* pDefaultListener = pTopmostTouchedTarget->GetDefaultTouchEventListener(); + if (pDefaultListener) + { + pDefaultListener->OnTouchReleased(pTopmostTouchedTarget->GetPublic(), touchInfo.GetCurrentPosition(), publicTouchInfo); + + if (pTopmostTouchedTarget->IsInputEventConsumed()) + { + pTopmostTouchedTarget->ResetInputEventConsumed(); + } + } + + // 3. Impl + if (pTopmostTouchedTarget->OnTouchReleased(*pTopmostTouchedTarget, touchInfo)) + { + if (pEventArg) + { + delete pEventArg; + pEventArg = null; + } + + return r; + } + + // 4. Core + pTopmostTouchedSource->OnTouchReleased(*pTopmostTouchedSource, touchInfo); + } + + if (pEventArg) + { + delete pEventArg; + pEventArg = null; + } + + return r; + + CATCH: + if (pEventArg) + { + delete pEventArg; + pEventArg = null; + } + + return r; + } + + bool ProcessListener(const _TouchInfo& touchInfo) + { + bool filterd = false; + + TouchEventInfo publicTouchInfo; + + _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo); + SysTryReturn(NID_UI, pEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + publicTouchInfo.Construct(*pEventArg); + + _Control* pDraggedControl = __pTouchManager->GetTouchControlSource(); + + // 1. Public + IEnumeratorT* pEnumerator = __impl.__pPublicTouchEventListeners->GetEnumeratorN(); + if (pEnumerator) + { + while (pEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + + ITouchEventListener* pTouchEventListener = dynamic_cast (pListener); + if (pTouchEventListener) + { + FirePublicListener(*pTouchEventListener, publicTouchInfo); + + if (touchInfo.GetTouchStatus() == _TOUCH_RELEASED) + { + if (pDraggedControl == null) //if exist dragged control, don't send focus event + { + FireFocusListener(*pTouchEventListener, publicTouchInfo); + } + } + else if (touchInfo.GetTouchStatus() == _TOUCH_MOVED) + { + FireFocusListener(*pTouchEventListener, publicTouchInfo); + } + } + else + { + SysAssert(pTouchEventListener); + } + } + delete pEnumerator; + } + + if (__impl.IsInputEventConsumed()) + { + __impl.ResetInputEventConsumed(); + + if (pEventArg) + { + delete pEventArg; + pEventArg = null; + } + + filterd = true; + return filterd; + } + + // 2. Default + ITouchEventListener* pDefaultListener = __impl.GetDefaultTouchEventListener(); + if (pDefaultListener) + { + FirePublicListener(*pDefaultListener, publicTouchInfo); + + if (__impl.IsInputEventConsumed()) + { + __impl.ResetInputEventConsumed(); + + if (pEventArg) + { + delete pEventArg; + pEventArg = null; + } + + filterd = true; + return filterd; + } + } + + delete pEventArg; + + return filterd; + } + + bool ProcessDoublePress(const _TouchInfo& touchinfo, bool& isFiltered) + { + if (__pTouchManager->GetPointCount() == 1) + { + __oldPreviousPressedTime = __previousPressedTime; + __previousPressedTime = __currentPressedTime; + __currentPressedTime = touchinfo.GetTimeStamp(); + __previousPressedPoint.x = __currentPressedPoint.x; + __previousPressedPoint.y = __currentPressedPoint.y; + __currentPressedPoint.x = touchinfo.GetCurrentPosition().x; + __currentPressedPoint.y = touchinfo.GetCurrentPosition().y; + + if (Math::Abs(__previousPressedTime - __currentPressedTime) < doublePressTime) + { + if (Math::Abs(__previousPressedTime - __oldPreviousPressedTime) > doublePressTime) + { + if (Math::Abs(__previousPressedPoint.x - __currentPressedPoint.x) < doublePressMoveAllowance + && Math::Abs(__previousPressedPoint.y - __currentPressedPoint.y) < doublePressMoveAllowance ) + { + _TouchInfo touchInfo(0, _TOUCH_DOUBLE_PRESSED, __pTouchManager->GetPosition(0), false, 0); + + SysTryReturn(NID_UI, __impl.__pCoreTouchEvent, false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + isFiltered = __impl.__pCoreTouchEvent->ProcessListener(touchInfo); + + return true; + } + } + } + } + + return false; + } + +private: + CoreTouchEvent(const CoreTouchEvent& rhs); + CoreTouchEvent& operator =(const CoreTouchEvent& rhs); + +private: + _ControlImpl& __impl; + _Control& __core; + Control& __public; + _TouchManager* __pTouchManager; + unsigned int __oldPreviousPressedTime; + unsigned int __previousPressedTime; + unsigned int __currentPressedTime; + Point __previousPressedPoint; + Point __currentPressedPoint; +}; + +class _ControlImpl::CoreFocusEvent +{ +public: + CoreFocusEvent(_ControlImpl& impl) + : __impl(impl) + , __core(impl.GetCore()) + , __public(impl.GetPublic()) + { + } + + ~CoreFocusEvent(void) + { + } + +private: + result FirePublicListener(IFocusEventListener& listener, FocusStatus focusState) + { + result r = E_SUCCESS; + + switch (focusState) + { + case FOCUS_GAINED: + listener.OnFocusGained(__public); + break; + case FOCUS_LOST: + listener.OnFocusLost(__public); + break; + default: + SysAssert(0); + r = E_SYSTEM; + break; + } + + return r; + } + +public: + bool ProcessListener(FocusStatus focusState) + { + bool filterd = false; + + // 1. Public + IEnumeratorT * pEnumerator = __impl.__pPublicFocusEventListeners->GetEnumeratorN(); + if (pEnumerator) + { + while (pEnumerator->MoveNext() == E_SUCCESS) + { + Runtime::IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + IFocusEventListener* pFocusEventListener = dynamic_cast (pListener); + if (pFocusEventListener) + { + FirePublicListener(*pFocusEventListener, focusState); + } + } + + delete pEnumerator; + } + + return filterd; + } + +private: + CoreFocusEvent(const CoreFocusEvent& rhs); + CoreFocusEvent& operator =(const CoreFocusEvent& rhs); + +private: + _ControlImpl& __impl; + _Control& __core; + Control& __public; +}; + +class _ControlImpl::CoreGestureEvent +{ +public: + CoreGestureEvent(_ControlImpl& impl) + : __impl(impl) + , __core(impl.GetCore()) + , __public(impl.GetPublic()) + { + } + + ~CoreGestureEvent(void) + { + } + +public: + bool ProcessListener(_TouchGestureDetectorType gestureType) + { + bool filterd = false; + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + switch (gestureType) + { + case _TOUCH_GESTURE_DETECTOR_TYPE_TAP: + { + _TouchInfo touchInfo(0, _TOUCH_DOUBLE_PRESSED, pTouchManager->GetPosition(0), false, 0); + + SysTryReturn(NID_UI, __impl.__pCoreTouchEvent, false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + filterd = __impl.__pCoreTouchEvent->ProcessListener(touchInfo); + } + break; + case _TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS: + { + _TouchInfo touchInfo(0, _TOUCH_LONG_PRESSED, pTouchManager->GetPosition(0), false, 0); + + SysTryReturn(NID_UI, __impl.__pCoreTouchEvent, false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + filterd = __impl.__pCoreTouchEvent->ProcessListener(touchInfo); + } + break; + default: + SysAssert(0); + break; + } + + return filterd; + } + +private: + CoreGestureEvent(const CoreGestureEvent& rhs); + CoreGestureEvent& operator =(const CoreGestureEvent& rhs); + +private: + _ControlImpl& __impl; + _Control& __core; + Control& __public; +}; + +class _ControlImpl::CoreEventListener + : public _IFocusEventListener + , public _INotificationEventListener + , public _ITouchLongPressGestureEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _ITouchGestureEventListener +{ +public: + CoreEventListener(_ControlImpl& impl) + : __impl(impl) + , __core(impl.GetCore()) + , __public(impl.GetPublic()) + , __isKeyPressed(false) + , __pKeyInfo(null) + { + __pTouchManager = _TouchManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, __pTouchManager, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return; + } + + virtual ~CoreEventListener(void) + { + } + + virtual bool OnFocusGained(const _Control& source) + { + SysTryReturn(NID_UI, __impl.__pCoreFocusEvent, false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + bool isFiltered = false; + + isFiltered = __impl.__pCoreFocusEvent->ProcessListener(FOCUS_GAINED); + if (isFiltered) + { + return true; + } + + // 2. Impl + isFiltered = __impl.OnFocusGained(__impl); + if (isFiltered) + { + return true; + } + + // 3. Core + isFiltered = __core.OnFocusGained(source); + + return isFiltered; + } + + virtual bool OnFocusLost(const _Control& source) + { + SysTryReturn(NID_UI, __impl.__pCoreFocusEvent, false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + bool isFiltered = false; + + isFiltered = __impl.__pCoreFocusEvent->ProcessListener(FOCUS_LOST); + if (isFiltered) + { + return true; + } + + // 2. Impl + isFiltered = __impl.OnFocusLost(__impl); + if (isFiltered) + { + return true; + } + + // 3. Core + isFiltered = __core.OnFocusLost(source); + + return isFiltered; + } + + virtual bool OnNotifiedN(const _Control& source, Tizen::Base::Collection::IList* pArgs) + { + if (__impl.SendNotification(__impl, pArgs)) + { + return true; + } + + if (&source == &__core) + { + if (ProcessTouchModeChangedListener(source, pArgs)) + { + pArgs->RemoveAll(true); + delete pArgs; + return true; + } + } + + // 1. Impl + if (__impl.OnNotifiedN(__impl, pArgs)) + { + return true; + } + + // 2. Core + return __core.OnNotifiedN(source, pArgs); + } + + virtual bool OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture) + { + SysTryReturn(NID_UI, __impl.__pCoreGestureEvent, false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + bool isFiltered = false; + + isFiltered = __impl.__pCoreGestureEvent->ProcessListener(_TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS); + + return isFiltered; + } + + virtual bool OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture) + { + return false; + } + + bool ProcessTouchModeChangedListener(const _Control& source, Tizen::Base::Collection::IList* pArgs) + { + IEnumeratorT* pEnumerator = __impl.__pPublicTouchModeChangedEventListeners->GetEnumeratorN(); + bool isFiltered = false; + + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pEventListener = null; + pEnumerator->GetCurrent(pEventListener); + + if (!pEventListener) + { + continue; + } + + String* pString = dynamic_cast(pArgs->GetAt(0)); + if (pString && (*pString == _KEYBOARD_INSERTED_EVENT)) + { + Boolean* pIsTouchMode = dynamic_cast(pArgs->GetAt(1)); + ITouchModeChangedEventListener* pTouchModeListener = dynamic_cast(pEventListener); + if (pTouchModeListener && pIsTouchMode) + { + pTouchModeListener->OnTouchModeChanged(__impl.GetPublic(), pIsTouchMode->ToBool()) ; + isFiltered = true; + } + } + } + delete pEnumerator; + } + + return isFiltered; + } + +private: + CoreEventListener(const CoreEventListener& rhs); + CoreEventListener& operator =(const CoreEventListener& rhs); + +private: + _ControlImpl& __impl; + _Control& __core; + Control& __public; + _TouchManager* __pTouchManager; + bool __isKeyPressed; + _KeyInfo* __pKeyInfo; +}; + +class _ControlImpl::_PropagatedTouchEventListener + : public _IPropagatedTouchEventListener +{ +public: + _PropagatedTouchEventListener(_ControlImpl& impl) + : __impl(impl) + , __core(impl.GetCore()) + , __public(impl.GetPublic()) + { + } + + virtual ~_PropagatedTouchEventListener() + { + } + + _TouchEventArg* GetTouchEventArgN(const _TouchInfo& touchInfo) + { + _TouchEventArg* pEventArg = new (std::nothrow) _TouchEventArg(__public, touchInfo.GetTouchStatus()); + SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + _TouchManager* __pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, __pTouchManager, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] __pTouchManager == null."); + + Point startPoint(__pTouchManager->GetStartPoint(touchInfo.GetPointId()).x - __core.GetAbsoluteBounds().x, + __pTouchManager->GetStartPoint(touchInfo.GetPointId()).y - __core.GetAbsoluteBounds().y); + + pEventArg->SetTouchPosition(touchInfo.GetPointId(), startPoint.x, startPoint.y, + touchInfo.GetCurrentPosition().x, touchInfo.GetCurrentPosition().y); + + int xDistance = 0; + int yDistance = 0; + __impl.__pFlickGestureDetector->GetDistance(xDistance, yDistance); + + if (xDistance != 0 || yDistance != 0) + { + pEventArg->SetFlickedStatus(true); + } + else + { + pEventArg->SetFlickedStatus(false); + } + + return pEventArg; + } + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) + { + return __impl.CallOnTouchPressed(source, touchInfo); + } + + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) + { + return __impl.CallOnTouchReleased(source, touchInfo); + } + + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) + { + return __impl.CallOnTouchMoved(source, touchInfo); + } + + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo) + { + return __impl.CallOnTouchCanceled(source, touchInfo); + } + + virtual void OnTouchPressHandled(const _Control& source) + { + __impl.OnTouchPressHandled(source); + } + + virtual void OnTouchReleaseHandled(const _Control& source) + { + __impl.OnTouchReleaseHandled(source); + } + + virtual void OnTouchMoveHandled(const _Control& source) + { + __impl.OnTouchMoveHandled(source); + } + + virtual void OnTouchCancelHandled(const _Control& source) + { + __impl.OnTouchCancelHandled(source); + } + +private: + _ControlImpl& __impl; + _Control& __core; + Control& __public; +}; + +class _ControlImpl::_PropagatedKeyEventListener + : public _IPropagatedKeyEventListener + , public ITimerEventListener +{ +public: + _PropagatedKeyEventListener(_ControlImpl& impl) + : __impl(impl) + , __core(impl.GetCore()) + , __public(impl.GetPublic()) + , __pTimer(null) + , __isKeyPressed(false) + , __pKeyInfo(null) + { + } + + virtual ~_PropagatedKeyEventListener() + { + if (__pTimer != null) + { + __pTimer->Cancel(); + + delete __pTimer; + __pTimer = null; + } + } + + void OnTimerExpired(Timer& timer) + { + if (__isKeyPressed) + { + SysTryReturnVoidResult(NID_UI, __impl.__pCoreKeyEvent, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + __impl.__pCoreKeyEvent->ProcessListener(KEY_LONGPRESSED, __pKeyInfo->GetKeyCode()); + } + } + + virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) + { + SysTryReturn(NID_UI, __impl.__pCoreKeyEvent, false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + bool isFiltered = false; + + if (&source == &__core) + { + if (!__isKeyPressed) + { + __pTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI, __pTimer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = __pTimer->Construct(*this); + SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + r = __pTimer->Start(keyPressTimer); + if (r == E_SUCCESS) + { + __isKeyPressed = true; + __pKeyInfo = const_cast<_KeyInfo*>(&keyInfo); + } + } + + isFiltered = __impl.__pCoreKeyEvent->ProcessListener(KEY_PRESSED, keyInfo.GetKeyCode()); + if (isFiltered) + { + return true; + } + } + + // 3. Impl + isFiltered = __impl.OnKeyPressed(__impl, keyInfo); + if (isFiltered) + { + return true; + } + + // 4. Core + isFiltered = __core.OnKeyPressed(source, keyInfo); + + return isFiltered; + } + + virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) + { + SysTryReturn(NID_UI, __impl.__pCoreKeyEvent, false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + bool isFiltered = false; + + if (&source == &__core) + { + __isKeyPressed = false; + __pKeyInfo = null; + + if (__pTimer != null) + { + __pTimer->Cancel(); + + delete __pTimer; + __pTimer = null; + } + + isFiltered = __impl.__pCoreKeyEvent->ProcessListener(KEY_RELEASED, keyInfo.GetKeyCode()); + if (isFiltered) + { + return true; + } + } + + // 3. Impl + isFiltered = __impl.OnKeyReleased(__impl, keyInfo); + if (isFiltered) + { + return true; + } + + // 4. Core + isFiltered = __core.OnKeyReleased(source, keyInfo); + + return isFiltered; + } + +private: + _ControlImpl& __impl; + _Control& __core; + Control& __public; + + Tizen::Base::Runtime::Timer* __pTimer; + bool __isKeyPressed; + _KeyInfo* __pKeyInfo; +}; + +Rectangle +_ControlImpl::GetErrorBounds(void) +{ + return Rectangle(0, 0, -1, -1); +} + +CompositeMode +_ControlImpl::GetErrorCompositeMode(void) +{ + return COMPOSITE_MODE_ALPHA_BLENDING; +} + +Color +_ControlImpl::GetErrorChromaKeyColor(void) +{ + return Color::GetColor(COLOR_ID_MAGENTA); +} + +Dimension +_ControlImpl::GetErrorMinimumSize(void) +{ + return Dimension(-1, -1); +} + +Dimension +_ControlImpl::GetErrorMaximumSize(void) +{ + return Dimension(-1, -1); +} + +const char* +_ControlImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Control"; +} + +const Control& +_ControlImpl::GetPublic(void) const +{ + return *__pControlPublic; +} + +Control& +_ControlImpl::GetPublic(void) +{ + return *__pControlPublic; +} + +const _Control& +_ControlImpl::GetCore(void) const +{ + return *__pControlCore; +} + +_Control& +_ControlImpl::GetCore(void) +{ + return *__pControlCore; +} + +result +_ControlImpl::AddFocusEventListener(IFocusEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI, + __pPublicFocusEventListeners->Add(const_cast (&listener)) == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +result +_ControlImpl::AddKeyEventListener(IKeyEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI, + __pPublicKeyEventListeners->Add(const_cast (&listener)) == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +result +_ControlImpl::AddTouchEventListener(ITouchEventListener& listener) +{ + SysAssert(__pControlCore && __pCoreEventListener && __pLongPressGestureDetector && __pFlickGestureDetector); + + ClearLastResult(); + SysTryReturn(NID_UI, + __pPublicTouchEventListeners->Add(const_cast (&listener)) == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + // Firt time, enable gesture. + if (__pPublicTouchEventListeners->GetCount() == 1) + { + result r = E_SUCCESS; + + r = __pControlCore->AddGestureDetector(*__pLongPressGestureDetector); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pLongPressGestureDetector->AddGestureListener(*__pCoreEventListener); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pControlCore->AddGestureDetector(*__pFlickGestureDetector); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pFlickGestureDetector->AddGestureListener(*__pCoreEventListener); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; +} + +Tizen::Base::Collection::LinkedListT * +_ControlImpl::GetTouchEventListener(void) const +{ + return __pPublicTouchEventListeners; +} + +result +_ControlImpl::AddDragDropEventListener(IDragDropEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI, + __pPublicDragDropEventListeners->Add(const_cast (&listener)) == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +Tizen::Base::Collection::LinkedListT * +_ControlImpl::GetDragDropEventListener(void) const +{ + return __pPublicDragDropEventListeners; +} + +result +_ControlImpl::AddTouchModeChangedEventListener(ITouchModeChangedEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI, + __pPublicTouchModeChangedEventListeners->Add( + const_cast (&listener)) == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +result +_ControlImpl::RemoveFocusEventListener(IFocusEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI, + __pPublicFocusEventListeners->Remove(&listener) == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +result +_ControlImpl::RemoveKeyEventListener(IKeyEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI, + __pPublicKeyEventListeners->Remove(&listener) == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +result +_ControlImpl::RemoveTouchEventListener(ITouchEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI, + __pPublicTouchEventListeners->Remove(&listener) == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + // [ToDo] if the number of touch event listers becomes 0, disable gesture recognition. + + return E_SUCCESS; +} + +result +_ControlImpl::RemoveDragDropEventListener(IDragDropEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI, + __pPublicDragDropEventListeners->Remove(&listener) == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +result +_ControlImpl::RemoveTouchModeChangedEventListener(ITouchModeChangedEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI, + __pPublicTouchModeChangedEventListeners->Remove(&listener) == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +result +_ControlImpl::AddGestureDetector(const TouchGestureDetector& gestureDetector) +{ + SysTryReturn(NID_UI, + __pPublicGestureDetectors->Add( + const_cast (&gestureDetector)) == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + const _TouchGestureDetectorImpl* pImpl = _TouchGestureDetectorImpl::GetInstance(gestureDetector); + SysTryReturn(NID_UI, pImpl, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + result r = GetCore().AddGestureDetector(pImpl->GetCore()); + SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +result +_ControlImpl::RemoveGestureDetector(const TouchGestureDetector& gestureDetector) +{ + SysTryReturn(NID_UI, + __pPublicGestureDetectors->Remove( + const_cast (&gestureDetector)) == E_SUCCESS, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + + const _TouchGestureDetectorImpl* pImpl = _TouchGestureDetectorImpl::GetInstance(gestureDetector); + SysTryReturn(NID_UI, pImpl, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + result r = GetCore().RemoveGestureDetector(pImpl->GetCore()); + SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return r; +} + +IListT* +_ControlImpl::GetGestureDetectorList(void) const +{ + return __pPublicGestureDetectors; +} + +bool +_ControlImpl::IsMovable(void) const +{ + return GetCore().IsMovable(); +} + +bool +_ControlImpl::IsResizable(void) const +{ + return GetCore().IsResizable(); +} + +Dimension +_ControlImpl::GetContentSize(void) const +{ + return GetCore().GetContentSize(); +} + +HitTestResult +_ControlImpl::HitTest(const Tizen::Graphics::FloatPoint& point) +{ + return GetCore().HitTest(point); +} + +String +_ControlImpl::GetDescription(void) const +{ + String description(L""); + + description.Format(LOG_LEN_MAX, L"0x%x(0x%x, %s) fgColor(0x%x) fontSize(%d) ", this, __pControlPublic, GetPublicClassName(), __foregroundColor.GetRGB32(), __fontSize); + + if (__pControlAnimator) + { + description.Append(L"ControlAnimator("); + description.Append((int)__pControlAnimator); + description.Append(L") "); + } + + if (__pCustomVisualElement) + { + description.Append(L"CustomVisualElement("); + description.Append((int)__pCustomVisualElement); + description.Append(L") "); + } + + if (__pBuilderPortraitBounds) + { + description.Append(L"PortraitBounds("); + description.Append(__pBuilderPortraitBounds->x); + description.Append(L" "); + description.Append(__pBuilderPortraitBounds->y); + description.Append(L" "); + description.Append(__pBuilderPortraitBounds->width); + description.Append(L" "); + description.Append(__pBuilderPortraitBounds->height); + description.Append(L") "); + } + + if (__pBuilderLandscapeBounds) + { + description.Append(L"LandscapeBounds("); + description.Append(__pBuilderLandscapeBounds->x); + description.Append(L" "); + description.Append(__pBuilderLandscapeBounds->y); + description.Append(L" "); + description.Append(__pBuilderLandscapeBounds->width); + description.Append(L" "); + description.Append(__pBuilderLandscapeBounds->height); + description.Append(L") "); + } + + if (__pPublicGestureDetectors->GetCount() > 0 ) + { + IEnumeratorT* pEnumerator = __pPublicGestureDetectors->GetEnumeratorN(); + if (pEnumerator) + { + description.Append(L"TouchGestureDetector("); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + TouchGestureDetector* pTouchGestureDetector = null; + pEnumerator->GetCurrent(pTouchGestureDetector); + if (pTouchGestureDetector) + { + description.Append((int)pTouchGestureDetector); + description.Append(L" "); + } + } + + description.Append(L") "); + + delete pEnumerator; + } + } + + if (__pPublicFocusEventListeners->GetCount() > 0 ) + { + IEnumeratorT* pEnumerator = __pPublicFocusEventListeners->GetEnumeratorN(); + if (pEnumerator) + { + description.Append(L"FocusListener("); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + if (pListener) + { + description.Append((int)pListener); + description.Append(L" "); + } + } + + description.Append(L") "); + + delete pEnumerator; + } + } + + if (__pPublicKeyEventListeners->GetCount() > 0 ) + { + IEnumeratorT* pEnumerator = __pPublicKeyEventListeners->GetEnumeratorN(); + if (pEnumerator) + { + description.Append(L"KeyListener("); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + if (pListener) + { + description.Append((int)pListener); + description.Append(L" "); + } + } + + description.Append(L") "); + + delete pEnumerator; + } + } + + if (__pPublicTouchEventListeners->GetCount() > 0 ) + { + IEnumeratorT* pEnumerator = __pPublicTouchEventListeners->GetEnumeratorN(); + if (pEnumerator) + { + description.Append(L"TouchListener("); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + if (pListener) + { + description.Append((int)pListener); + description.Append(L" "); + } + } + + description.Append(L") "); + + delete pEnumerator; + } + } + + if (__pPublicDragDropEventListeners->GetCount() > 0 ) + { + IEnumeratorT* pEnumerator = __pPublicDragDropEventListeners->GetEnumeratorN(); + if (pEnumerator) + { + description.Append(L"DragDropListener("); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + if (pListener) + { + description.Append((int)pListener); + description.Append(L" "); + } + } + + description.Append(L") "); + + delete pEnumerator; + } + } + + if (__pPublicTouchModeChangedEventListeners->GetCount() > 0 ) + { + IEnumeratorT* pEnumerator = __pPublicTouchModeChangedEventListeners->GetEnumeratorN(); + if (pEnumerator) + { + description.Append(L"TouchModeListener("); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + if (pListener) + { + description.Append((int)pListener); + description.Append(L" "); + } + } + + description.Append(L") "); + + delete pEnumerator; + } + } + + return description; +} + +void +_ControlImpl::OnDraw(void) +{ + GetCore().OnDraw(); +} + +Tizen::Graphics::Canvas* +_ControlImpl::OnCanvasRequestedN(const Tizen::Graphics::Dimension& size) +{ + return GetCore().OnCanvasRequestedN(size); +} + +Tizen::Graphics::Bitmap* +_ControlImpl::OnCapturedBitmapRequestedN(void) +{ + + return GetCore().OnCapturedBitmapRequestedN(); +} + +result +_ControlImpl::OnAttaching(const _Control* pParent) +{ + return GetCore().OnAttaching(pParent); +} + +result +_ControlImpl::OnAttached(void) +{ + return GetCore().OnAttached(); +} + +result +_ControlImpl::OnAttachingToMainTree(const _Control* pParent) +{ + return GetCore().OnAttachingToMainTree(pParent); +} + +result +_ControlImpl::OnAttachedToMainTree(void) +{ + result r = E_SUCCESS; + result returnResultPublic = E_SUCCESS; + result returnResultCore = E_SUCCESS; + + if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + GetCore().SetDrawWhenVisible(false); + GetCore().SetTerminatingOrder(true); + } + + returnResultPublic = GetPublic().OnInitializing(); + returnResultCore = GetCore().OnAttachedToMainTree(); + + if (IsFailed(returnResultPublic) || IsFailed(returnResultCore)) + { + _ContainerImpl* pParent = GetParent(); + SysTryReturn(NID_UI, pParent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + r = pParent->RemoveChild(this, false); + SysAssert(r == E_SUCCESS); + + SysTryReturn(NID_UI, returnResultPublic == E_SUCCESS, returnResultPublic, returnResultPublic, "[%s] propagated.", GetErrorMessage(returnResultPublic)); + SysTryReturn(NID_UI, returnResultCore == E_SUCCESS, returnResultCore, returnResultCore, "[%s] propagated.", GetErrorMessage(returnResultCore)); + } + + return returnResultPublic; +} + +result +_ControlImpl::OnDetachingFromMainTree(void) +{ + GetPublic().OnTerminating(); + return GetCore().OnDetachingFromMainTree(); +} + +void +_ControlImpl::OnAttachingFailed(const _Control& parent) +{ + GetCore().OnAttachingFailed(parent); +} + +result +_ControlImpl::OnDetaching(void) +{ + return E_SUCCESS; +} + +result +_ControlImpl::OnBoundsChanging(const Rectangle& bounds) +{ + __oldBounds = GetBounds(); + + return GetCore().OnBoundsChanging(bounds); +} + +void +_ControlImpl::OnBoundsChanged(void) +{ + GetCore().OnBoundsChanged(); +} + +void +_ControlImpl::OnEvaluateSize(Dimension& evaluatedSize) +{ + GetCore().OnEvaluateSize(evaluatedSize); +} + +void +_ControlImpl::OnParentBoundsChanged(const _Control& parent) +{ + GetCore().OnParentBoundsChanged(parent); +} + +void +_ControlImpl::OnChildAttached(const _Control& child) +{ + GetCore().OnChildAttached(child); +} + +void +_ControlImpl::OnChildDetaching(const _Control& child) +{ + GetCore().OnChildDetaching(child); +} + +void +_ControlImpl::OnChildDetached(const _Control& child) +{ + GetCore().OnChildDetached(child); +} + +void +_ControlImpl::OnChildBoundsChanged(const _Control& child) +{ + GetCore().OnChildBoundsChanged(child); +} + +void +_ControlImpl::OnChildVisibleStateChanged(const _Control& child) +{ + GetCore().OnChildVisibleStateChanged(child); +} + +void +_ControlImpl::OnChangeLayout(_ControlOrientation orientation) +{ + result r = E_SUCCESS; + + if (IsAttachedToMainTree()) + { + Rectangle builderBounds; + bool exist = GetBuilderBounds(orientation, builderBounds); + if (exist) + { + bool movable = IsMovable(); + bool resizable = IsResizable(); + + SetMovable(true); + SetResizable(true); + + r = SetBounds(builderBounds); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to set bounds of %s.", GetPublicClassName()); + builderBounds.x = 0; + builderBounds.y = 0; + SetClientBounds(builderBounds); + + SetMovable(movable); + SetResizable(resizable); + + } + } + + GetCore().OnChangeLayout(orientation); +} + +void +_ControlImpl::OnZOrderChanging(_ControlZOrderUpdate zOrderUpdate) +{ + GetCore().OnZOrderChanging(zOrderUpdate); +} + +void +_ControlImpl::OnVisibleStateChanging(void) +{ + GetCore().OnVisibleStateChanging(); +} + +void +_ControlImpl::OnVisibleStateChanged(void) +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + if (pTouchManager) + { + if ((_TouchManager::GetInstance()->IsTouchAllowed() == true) && (GetPublic().GetShowState() == false)) + { + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist."); + + bool gestureDetecting = false; + + IListT<_TouchGestureDetector*>* pGestureList = GetCore().GetGestureDetectorList(); + if (pGestureList) + { + IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pGestureList->GetEnumeratorN(); + SysTryReturnVoidResult(NID_UI, pEnumerator, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGestureDetector = null; + pEnumerator->GetCurrent(pGestureDetector); + if (pGestureDetector) + { + gestureDetecting = true; + break; + } + } + + delete pEnumerator; + } + + if (!gestureDetecting) + { + pTouchManager->SetTouchCanceled(true); + } + } + } + + GetCore().OnVisibleStateChanged(); +} + +void +_ControlImpl::OnAncestorVisibleStateChanged(const _Control& control) +{ + GetCore().OnAncestorVisibleStateChanged(control); +} + +void +_ControlImpl::OnAncestorEnableStateChanged(const _Control& control) +{ + GetCore().OnAncestorEnableStateChanged(control); +} + +void +_ControlImpl::OnTouchPressHandled(const _Control& control) +{ + GetCore().OnTouchPressHandled(control); +} + +void +_ControlImpl::OnTouchReleaseHandled(const _Control& control) +{ + GetCore().OnTouchReleaseHandled(control); +} + +void +_ControlImpl::OnTouchMoveHandled(const _Control& control) +{ + GetCore().OnTouchMoveHandled(control); +} + +void +_ControlImpl::OnFontChanged(Font* pFont) +{ + GetCore().OnFontChanged(pFont); +} + +void +_ControlImpl::OnFontInfoRequested(unsigned long& style, int& size) +{ + GetCore().OnFontInfoRequested(style, size); +} +void +_ControlImpl::OnTouchCancelHandled(const _Control& control) +{ + GetCore().OnTouchCancelHandled(control); +} + +bool +_ControlImpl::OnKeyPressed(const _ControlImpl& source, const _KeyInfo& keyInfo) +{ + return false; +} + +bool +_ControlImpl::OnKeyReleased(const _ControlImpl& source, const _KeyInfo& keyInfo) +{ + return false; +} + +bool +_ControlImpl::CallOnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + bool isFiltered = false; + + if (source.IsDelayedTouchEventEnabled()) + { + if (&source == &GetCore()) + { + const_cast<_Control&>(source).AddTouchInfo(touchinfo); + } + + return false; + } + + GetCore().SetEventReceivable(true); + + LinkedListT * pList = GetTouchEventListener(); + if (pList && pList->GetCount() > 0) + { + bool returnValue = __pCoreTouchEvent->ProcessDoublePress(touchinfo, isFiltered); + if (returnValue) + { + return false; + } + } + + if (&source == &GetCore()) + { + isFiltered = __pCoreTouchEvent->ProcessListener(touchinfo); + if (isFiltered) + { + return true; + } + + __pCoreTouchEvent->ProcessDragListener(touchinfo); + } + + _TouchManager* __pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, __pTouchManager, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] __pTouchManager == null."); + + if (!GetCore().IsEventReceivable()) + { + __pTouchManager->ResetTouchInfo(); + isFiltered = true; + return true; + } + + if (!__pTouchManager->IsTouchAllowed()) + { + return true; + } + + // 3. Impl + isFiltered = OnTouchPressed(*this, touchinfo); + if (isFiltered) + { + return true; + } + + // 4. Core + isFiltered = GetCore().OnTouchPressed(source, touchinfo); + + return isFiltered; + +} + +bool +_ControlImpl::CallOnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + bool isFiltered = false; + + if (source.IsDelayedTouchEventEnabled()) + { + if (&source == &GetCore()) + { + const_cast<_Control&>(source).AddTouchInfo(touchinfo); + } + + return false; + } + + if (&source == &GetCore()) + { + isFiltered = __pCoreTouchEvent->ProcessListener(touchinfo); + if (isFiltered) + { + return true; + } + + __pCoreTouchEvent->ProcessDropListener(touchinfo); + } + + _TouchManager* __pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, __pTouchManager, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] __pTouchManager == null."); + + if (!__pTouchManager->IsTouchAllowed()) + { + return true; + } + + // 3. Impl + isFiltered = OnTouchReleased(*this, touchinfo); + if (isFiltered) + { + return true; + } + + //send drop event to topmost touched control + __pCoreTouchEvent->ProcessDropListenerToTopControl(touchinfo); + + // 4. Core + isFiltered = GetCore().OnTouchReleased(source, touchinfo); + + return isFiltered; +} + +bool +_ControlImpl::CallOnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + bool isFiltered = false; + + if (source.IsDelayedTouchEventEnabled()) + { + if (&source == &GetCore()) + { + const_cast<_Control&>(source).AddTouchInfo(touchinfo); + } + + return false; + } + + if (&source == &GetCore()) + { + isFiltered = __pCoreTouchEvent->ProcessListener(touchinfo); + if (isFiltered) + { + return true; + } + } + + _TouchManager* __pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, __pTouchManager, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] __pTouchManager == null."); + + if (!__pTouchManager->IsTouchAllowed()) + { + return true; + } + + // 3. Impl + isFiltered = OnTouchMoved(*this, touchinfo); + if (isFiltered) + { + return true; + } + + // 4. Core + isFiltered = GetCore().OnTouchMoved(source, touchinfo); + + return isFiltered; +} + +bool +_ControlImpl::CallOnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + bool isFiltered = false; + + __pCoreTouchEvent->ProcessDropListener(touchinfo); + __pCoreTouchEvent->ProcessDropListenerToTopControl(touchinfo); + + if (&source == &GetCore()) + { + isFiltered = __pCoreTouchEvent->ProcessListener(touchinfo); + if (isFiltered) + { + return true; + } + } + + // 3. Impl + isFiltered = OnTouchCanceled(*this, touchinfo); + if (isFiltered) + { + return true; + } + + // 4. Core + isFiltered = GetCore().OnTouchCanceled(source, touchinfo); + + return isFiltered; +} + +bool +_ControlImpl::OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_ControlImpl::OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_ControlImpl::OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_ControlImpl::OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_ControlImpl::OnFocusGained(const _ControlImpl& source) +{ + return false; +} + +bool +_ControlImpl::OnFocusLost(const _ControlImpl& source) +{ + return false; +} + +bool +_ControlImpl::OnNotifiedN(const _ControlImpl& source, Tizen::Base::Collection::IList* pArgs) +{ + return false; +} + +void +_ControlImpl::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs) +{ + GetPublic().OnUserEventReceivedN(requestId, pArgs); +} + +bool +_ControlImpl::SendNotification(const _ControlImpl& source, Tizen::Base::Collection::IList* pArgs) +{ + _ControlImpl& impl = const_cast <_ControlImpl&>(source); + + Tizen::Base::String* pString = dynamic_cast (pArgs->GetAt(0)); + if (pString) + { + if (*pString == _USER_EVENT) + { + _UserEventInfo* pUserEventInfo = dynamic_cast <_UserEventInfo*>(pArgs->GetAt(1)); + if (pUserEventInfo) + { + impl.OnUserEventReceivedN(pUserEventInfo->GetRequestId(), pUserEventInfo->GetArgs()); + } + pArgs->RemoveAll(true); + delete pArgs; + + return true; + } + else if (*pString == _REQUEST_REDRAW_EVENT) + { + impl.Draw(); + + Boolean* pBoolean = dynamic_cast (pArgs->GetAt(1)); + if (pBoolean && pBoolean->ToBool()) + { + impl.Show(); + } + pArgs->RemoveAll(true); + delete pArgs; + + return true; + } + } + + return false; +} + +result +_ControlImpl::Draw(bool recursive) +{ + SysTryReturn(NID_UI, + IsAttachedToMainTree(), E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] The control should be attached to the main tree."); + + GetCore().Draw(recursive); + + return E_SUCCESS; +} + +result +_ControlImpl::Show(void) +{ + SysTryReturn(NID_UI, + GetParent() || IsAttachedToMainTree(), E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control should have a parent or be attached to the main tree."); + + GetCore().Show(); + + return E_SUCCESS; +} + +void +_ControlImpl::Invalidate(bool recursive) +{ + SysTryReturnVoidResult(NID_UI, + IsAttachedToMainTree(), + E_INVALID_OPERATION, "[E_INVALID_OPERATION] The control should be attached to the main tree."); + + GetCore().Invalidate(recursive); +} + +void +_ControlImpl::Invalidate(const Rectangle& rect) +{ + SysTryReturnVoidResult(NID_UI, + IsAttachedToMainTree(), + E_INVALID_OPERATION, "[E_INVALID_OPERATION] The control should be attached to the main tree."); + + GetCore().Invalidate(rect); +} + +void +_ControlImpl::RequestRedraw(bool show) const +{ + ClearLastResult(); + + ArrayList* pEventArgs = new (std::nothrow) ArrayList; + SysTryReturnVoidResult(NID_UI, pEventArgs, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + pEventArgs->Construct(); + + Tizen::Base::String* pString = new (std::nothrow) Tizen::Base::String(_REQUEST_REDRAW_EVENT); + SysTryReturnVoidResult(NID_UI, pString, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + // Index 0 : Type + pEventArgs->Add(*pString); + + Boolean* pBoolean = new (std::nothrow) Boolean(show); + SysTryReturnVoidResult(NID_UI, pBoolean, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + // Index 1 : User Data + pEventArgs->Add(*pBoolean); + + _UiEventManager* pEventManager = _UiEventManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pEventManager, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _UiNotificationEvent event(GetCore().GetHandle(), pEventArgs); + + result r = pEventManager->PostEvent(event); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] System error occurred."); +} + +void +_ControlImpl::SendUserEvent(RequestId requestId, const IList* pArgs) const +{ + ClearLastResult(); + + ArrayList* pEventArgs = new (std::nothrow) ArrayList; + SysTryReturnVoidResult(NID_UI, pEventArgs, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + pEventArgs->Construct(); + + Tizen::Base::String* pString = new (std::nothrow) Tizen::Base::String(_USER_EVENT); + SysTryReturnVoidResult(NID_UI, pString, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + // Index 0 : Type + pEventArgs->Add(*pString); + + _UserEventInfo* pUserEventInfo = new (std::nothrow) _UserEventInfo(requestId, pArgs); + SysTryReturnVoidResult(NID_UI, pUserEventInfo, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + // Index 1 : User Data + pEventArgs->Add(*pUserEventInfo); + + _UiEventManager* pEventManager = _UiEventManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pEventManager, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _UiNotificationEvent event(GetCore().GetHandle(), pEventArgs); + + result r = pEventManager->PostEvent(event); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] System error occurred."); +} + +bool +_ControlImpl::Contains(const Point& point) const +{ + return GetCore().Contains(point); +} + +void +_ControlImpl::ConsumeInputEvent(void) +{ + ClearLastResult(); + __inputEventConsumed = true; +} + +bool +_ControlImpl::IsInputEventConsumed(void) const +{ + ClearLastResult(); + return __inputEventConsumed; +} + +void +_ControlImpl::ResetInputEventConsumed(void) +{ + ClearLastResult(); + __inputEventConsumed = false; +} + +Tizen::Base::String +_ControlImpl::GetName(void) const +{ + return GetCore().GetName(); +} + +void +_ControlImpl::SetName(const Tizen::Base::String& name) +{ + GetCore().SetName(name); +} + +_ContainerImpl* +_ControlImpl::GetParent(void) const +{ + ClearLastResult(); + + _Control* pParent = GetCore().GetParent(); + if (pParent == null) + { + return null; + } + + void* pData = pParent->GetUserData(); + if (pData == null) + { + return null; // This is for the _ControlManager::__pRoot. + } + + _ContainerImpl* pParentImpl = static_cast <_ContainerImpl*>(pData); + return pParentImpl; +} + +Canvas* +_ControlImpl::GetCanvasN(void) const +{ + SysTryReturn(NID_UI, + GetParent() || IsAttachedToMainTree(), null, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control should have a parent or be attached to the main tree."); + + Canvas* pCanvas = GetCore().GetCanvasN(); + result r = GetLastResult(); + if (IsFailed(r)) + { + if (r == E_OPERATION_FAILED) + { + SetLastResult(E_INVALID_OPERATION); + } + SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult())); + } + else + { + if (pCanvas) + { + pCanvas->SetBackgroundColor(GetBackgroundColor()); + pCanvas->SetForegroundColor(GetForegroundColor()); + } + } + + return pCanvas; +} + +Canvas* +_ControlImpl::GetCanvasN(const Rectangle& bounds) const +{ + SysTryReturn(NID_UI, + GetParent() || IsAttachedToMainTree(), null, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control should have a parent or be attached to the main tree."); + + Canvas* pCanvas = GetCore().GetCanvasN(bounds); + result r = GetLastResult(); + if (IsFailed(r)) + { + if (r == E_OPERATION_FAILED) + { + SetLastResult(E_INVALID_OPERATION); + } + SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult())); + } + else + { + if (pCanvas) + { + pCanvas->SetBackgroundColor(GetBackgroundColor()); + pCanvas->SetForegroundColor(GetForegroundColor()); + } + } + + return pCanvas; +} + +Canvas* +_ControlImpl::GetClientCanvasN(void) const +{ + SysTryReturn(NID_UI, + GetParent() || IsAttachedToMainTree(), null, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control should have a parent or be attached to the main tree."); + + Canvas* pCanvas = GetCore().GetClientCanvasN(); + result r = GetLastResult(); + if (IsFailed(r)) + { + if (r == E_OPERATION_FAILED) + { + SetLastResult(E_INVALID_OPERATION); + } + SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult())); + } + else + { + if (pCanvas) + { + pCanvas->SetBackgroundColor(GetBackgroundColor()); + pCanvas->SetForegroundColor(GetForegroundColor()); + } + } + + return pCanvas; +} + +bool +_ControlImpl::IsAttachedToMainTree(void) const +{ + return GetCore().IsAttachedToMainTree(); +} + +bool +_ControlImpl::IsInTouchMode(void) const +{ + ClearLastResult(); + // [ToDo] + return true; +} + +bool +_ControlImpl::IsFocusable(void) const +{ + return GetCore().IsFocusable(); +} + +result +_ControlImpl::SetFocusable(bool focusable) +{ + // [ToDo] Focusable is simple flag. Make this method do not check belows. + SysTryReturn(NID_UI, + __focusableChangable, E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] The control can't chage it's focusable property."); + + SysTryReturn(NID_UI, + IsAttachedToMainTree(), E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] This control should be attached to the main tree."); + + SysTryReturn(NID_UI, + focusable || GetCore().GetFocused() != &this->GetCore(), E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This already focused control cannot be unfocusable."); + + GetCore().SetFocusable(focusable); + return E_SUCCESS; +} + +bool +_ControlImpl::IsFocused(void) const +{ + return GetCore().IsFocused(); +} + +result +_ControlImpl::SetFocused(void) +{ + return GetCore().SetFocused(); +} + +void +_ControlImpl::SetFocusableChangable(bool focusableChangable) +{ + __focusableChangable = focusableChangable; +} + +result +_ControlImpl::SetFont(const String& fontName) +{ + result r = GetCore().SetFont(fontName); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return E_SUCCESS; +} + +Tizen::Base::String +_ControlImpl::GetFont(void) const +{ + return GetCore().GetFont(); +} + +bool +_ControlImpl::IsEnabled(void) const +{ + return GetCore().IsEnabled(); +} + +bool +_ControlImpl::GetEnableState(void) const +{ + return GetCore().GetEnableState(); +} + +void +_ControlImpl::SetEnableState(bool enableState) +{ + GetCore().SetEnableState(enableState); +} + +bool +_ControlImpl::IsInputEnabled(void) const +{ + return GetCore().IsInputEnabled(); +} + +bool +_ControlImpl::GetInputEnableState(void) const +{ + return GetCore().GetInputEnableState(); +} + +void +_ControlImpl::SetInputEnableState(bool inputEnableState) +{ + GetCore().SetInputEnableState(inputEnableState); +} + +bool +_ControlImpl::IsVisible(void) const +{ + // [ToDo] Change the default visible state to false and test. + return GetCore().IsVisible(); +} + +bool +_ControlImpl::GetVisibleState(void) const +{ + return GetCore().GetVisibleState(); +} + +result +_ControlImpl::SetVisibleState(bool visibleState) +{ +#ifdef _TC_PASS + SysTryReturn(NID_UI, + GetParent() || IsAttachedToMainTree(), E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control should have a parent or be attached to the main tree."); +#endif + GetCore().SetVisibleState(visibleState); + + return E_SUCCESS; +} + +bool +_ControlImpl::IsLayoutable(void) const +{ + return GetCore().IsLayoutable(); +} + +bool +_ControlImpl::IsClipToParent(void) const +{ + return GetCore().IsClipToParent(); +} + +result +_ControlImpl::SetClipToParent(bool clipToParent) +{ + result r = GetCore().SetClipToParent(clipToParent); + SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +bool +_ControlImpl::IsDragEnabled(void) const +{ + return GetCore().IsDragEnabled(); +} + +bool +_ControlImpl::IsDropEnabled(void) const +{ + return GetCore().IsDropEnabled(); +} + +void +_ControlImpl::SetDragEnabled(bool enabled) +{ + ClearLastResult(); + GetCore().SetDragEnabled(enabled); +} + +void +_ControlImpl::SetDropEnabled(bool enabled) +{ + ClearLastResult(); + GetCore().SetDropEnabled(enabled); +} + +Rectangle +_ControlImpl::GetBounds(void) const +{ + return GetCore().GetBounds(); +} + +Point +_ControlImpl::GetPosition(void) const +{ + return GetCore().GetPosition(); +} + +Dimension +_ControlImpl::GetSize(void) const +{ + return GetCore().GetSize(); +} + +result +_ControlImpl::SetBounds(const Rectangle& bounds, bool callBoundsChangeCallbacks) +{ + Rectangle builderBounds; + _ControlOrientation controlOrientation = _CONTROL_ORIENTATION_PORTRAIT; + bool exist = GetBuilderBounds(controlOrientation, builderBounds); + if (exist) + { + if (IsAttachedToMainTree()) + { + _ControlImplManager* pControlImplManager = _ControlImplManager::GetInstance(); + OrientationStatus orientation = pControlImplManager->GetFormOrientationStatus(this); + + if (orientation == ORIENTATION_STATUS_LANDSCAPE + || orientation == ORIENTATION_STATUS_LANDSCAPE_REVERSE) + { + SetBuilderBounds(_CONTROL_ORIENTATION_LANDSCAPE, bounds); + } + else + { + SetBuilderBounds(_CONTROL_ORIENTATION_PORTRAIT, bounds); + } + } + else + { + SetBuilderBounds(_CONTROL_ORIENTATION_PORTRAIT, bounds); + SetBuilderBounds(_CONTROL_ORIENTATION_LANDSCAPE, bounds); + } + } + return GetCore().SetBounds(bounds, callBoundsChangeCallbacks); +} + +result +_ControlImpl::SetBoundsAndUpdateLayout(const Tizen::Graphics::Rectangle& bounds) +{ + result r = E_SUCCESS; + r = GetCore().SetBounds(bounds); + + GetCore().UpdateLayout(); + + return r; +} + +result +_ControlImpl::SetPosition(const Point& position) +{ + return GetCore().SetPosition(position); +} + +result +_ControlImpl::SetSize(const Dimension& size) +{ + return GetCore().SetSize(size); +} + +Dimension +_ControlImpl::GetMinimumSize(void) const +{ + return GetCore().GetMinimumSize(); +} + +Dimension +_ControlImpl::GetMaximumSize(void) const +{ + return GetCore().GetMaximumSize(); +} + +result +_ControlImpl::SetMinimumSize(const Dimension& newMinSize) +{ + return GetCore().SetMinimumSize(newMinSize); +} + +result +_ControlImpl::SetMaximumSize(const Dimension& newMaxSize) +{ + return GetCore().SetMaximumSize(newMaxSize); +} + +Point +_ControlImpl::ConvertToControlPosition(const Point& screenPosition) const +{ + return GetCore().ConvertToControlPosition(screenPosition); +} + +Point +_ControlImpl::ConvertToScreenPosition(const Point& controlPosition) const +{ + return GetCore().ConvertToScreenPosition(controlPosition); +} + +// [ToDo] Must provide a static method. +Dimension +_ControlImpl::GetMinimumSizeLimit(void) const +{ + ClearLastResult(); + return Dimension(0, 0); +} + +// [ToDo] Must provide a static method. +Dimension +_ControlImpl::GetMaximumSizeLimit(void) const +{ + ClearLastResult(); + return Dimension(_Control::MAX_LENGTH, _Control::MAX_LENGTH); +} + +Rectangle +_ControlImpl::GetClientBounds(void) const +{ + return GetCore().GetClientBounds(); +} + +Rectangle +_ControlImpl::GetAbsoluteBounds(void) const +{ + return GetCore().GetAbsoluteBounds(); +} + +result +_ControlImpl::SetClientBounds(const Rectangle& bounds) +{ + return GetCore().SetClientBounds(bounds); +} + +Color +_ControlImpl::GetBackgroundColor(void) const +{ + return GetCore().GetBackgroundColor(); +} + +bool +_ControlImpl::IsOpaque(void) const +{ + return false; +} + +void +_ControlImpl::SetBackgroundColor(const Color& color) +{ + if (!IsOpaque()) + { + GetCore().SetBackgroundColor(color); + } + else + { + byte r, g, b, a; + color.GetColorComponents(r, g, b, a); + GetCore().SetBackgroundColor(Color(r*a/ 255, g*a/255, b*a/ 255, 255)); + } +} + +Color +_ControlImpl::GetForegroundColor(void) const +{ + ClearLastResult(); + return __foregroundColor; +} + +void +_ControlImpl::SetForegroundColor(const Color& color) +{ + ClearLastResult(); + __foregroundColor = color; +} + +int +_ControlImpl::GetFontSize(void) const +{ + ClearLastResult(); + return __fontSize; +} + +void +_ControlImpl::SetFontSize(int fontSize) +{ + ClearLastResult(); + __fontSize = fontSize; +} + +ITouchEventListener* +_ControlImpl::GetDefaultTouchEventListener(void) const +{ + ClearLastResult(); + return __pDefaultTouchEventListener; +} + +IKeyEventListener* +_ControlImpl::GetDefaultKeyEventListener(void) const +{ + ClearLastResult(); + return __pDefaultKeyEventListener; +} + +void +_ControlImpl::SetDefaultKeyEventListener(IKeyEventListener* pDefaultListener) +{ + ClearLastResult(); + __pDefaultKeyEventListener = pDefaultListener; +} + +void +_ControlImpl::SetDefaultTouchEventListener(ITouchEventListener* pDefaultListener) +{ + ClearLastResult(); + __pDefaultTouchEventListener = pDefaultListener; +} + +CompositeMode +_ControlImpl::GetCompositeMode(void) const +{ + ClearLastResult(); + return COMPOSITE_MODE_ALPHA_BLENDING; +} + +result +_ControlImpl::SetCompositeMode(CompositeMode compositeMode) +{ + ClearLastResult(); + + if (compositeMode == COMPOSITE_MODE_ALPHA_BLENDING) + { + return E_SUCCESS; + } + + SysLogException(NID_UI, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported."); + return E_UNSUPPORTED_OPERATION; +} + +result +_ControlImpl::SetChromaKeyColor(Color chromaKeyColor) +{ + SysLogException(NID_UI, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported."); + return E_UNSUPPORTED_OPERATION; +} + +Color +_ControlImpl::GetChromaKeyColor(void) const +{ + static const Color errorColor(0, 0, 0, 0); + SysLogException(NID_UI, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported."); + return errorColor; +} + +Animations::ControlAnimator* +_ControlImpl::GetControlAnimator(void) const +{ + ClearLastResult(); + + if ((IsMovable() == false) && (IsResizable() == false)) + { + SysLog(NID_UI, "Control is not animatable.\n"); + return null; + } + + if (__pControlAnimator == null) + { + ControlAnimator* pControlAnimator = new (std::nothrow) ControlAnimator(); + SysTryReturn(NID_UI, (pControlAnimator != null), null, E_OUT_OF_MEMORY, "Unable to create ControlAnimator instance.\n"); + + // [ToDo] Check if the Open API can return E_SYSTEM. + result r = pControlAnimator->Construct(*__pControlPublic); + if (IsFailed(r)) + { + delete pControlAnimator; + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Failed to create control animator."); + return null; + } + + (const_cast <_ControlImpl*>(this))->__pControlAnimator = pControlAnimator; + } + + return __pControlAnimator; +} + +VisualElement* +_ControlImpl::GetVisualElement(void) const +{ + return GetCore().GetVisualElement(); +} + +void +_ControlImpl::SetMultiTouchEnabled(bool enabled) +{ + GetCore().SetMultiTouchEnabled(enabled); +} + +bool +_ControlImpl::IsMultiTouchEnabled(void) const +{ + return GetCore().IsMultiTouchEnabled(); +} + +_ControlImpl::PublicEventListenerList* +_ControlImpl::CreatePublicEventListenerListN(void) const +{ + PublicEventListenerList* pListenerList = new (std::nothrow) PublicEventListenerList; + SysTryReturn(NID_UI, pListenerList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pListenerList; +} + +bool +_ControlImpl::HasCore(void) const +{ + return __pControlCore != null; +} + +result +_ControlImpl::SetCore(_Control& core) +{ + result r = E_SUCCESS; + + __pControlCore = &core; + __pControlCore->SetControlDelegate(*this); + __pControlCore->SetUserData(this); + + __pCoreEventListener = new (std::nothrow) CoreEventListener(*this); + SysTryCatch(NID_UI, __pCoreEventListener, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pControlCore->SetEventListener<_UI_EVENT_FOCUS>(__pCoreEventListener); + __pControlCore->SetEventListener<_UI_EVENT_NOTIFICAITON>(__pCoreEventListener); + + __pPropagatedTouchEventListener = new (std::nothrow) _PropagatedTouchEventListener(*this); + SysTryCatch(NID_UI, __pPropagatedTouchEventListener, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pControlCore->SetPropagatedTouchEventListener(__pPropagatedTouchEventListener); + + __pPropagatedKeyEventListener = new (std::nothrow) _PropagatedKeyEventListener(*this); + SysTryCatch(NID_UI, __pPropagatedKeyEventListener, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pControlCore->SetPropagatedKeyEventListener(__pPropagatedKeyEventListener); + + return E_SUCCESS; + +CATCH: + ResetCore(); + SysLogException(NID_UI, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +void +_ControlImpl::ResetCore(bool deallocate) +{ + if (__pControlCore == null) + { + return; + } + + __pControlCore->ResetEventListeners(); + __pControlCore->SetUserData(null); + __pControlCore->ResetControlDelegate(); + + __pFlickGestureDetector->RemoveGestureListener(*__pCoreEventListener); + __pControlCore->RemoveGestureDetector(*__pFlickGestureDetector); + + __pLongPressGestureDetector->RemoveGestureListener(*__pCoreEventListener); + __pControlCore->RemoveGestureDetector(*__pLongPressGestureDetector); + + __pControlCore->SetPropagatedTouchEventListener(null); + __pControlCore->SetPropagatedKeyEventListener(null); + + if (deallocate) + { + delete __pControlCore; + } + __pControlCore = null; + + delete __pCoreEventListener; + __pCoreEventListener = null; + + delete __pPropagatedTouchEventListener; + __pPropagatedTouchEventListener = null; + + delete __pPropagatedKeyEventListener; + __pPropagatedKeyEventListener = null; +} + +void +_ControlImpl::Dispose(bool deallocateCore) +{ + if(GetVisualElement() && __pCustomVisualElement) + { + GetVisualElement()->DetachChild( *__pCustomVisualElement); + } + __pCustomVisualElement = null; + // Reset core + ResetCore(deallocateCore); + + // Release core events + delete __pCoreKeyEvent; + __pCoreKeyEvent = null; + delete __pCoreTouchEvent; + __pCoreTouchEvent = null; + delete __pCoreFocusEvent; + __pCoreFocusEvent = null; + delete __pCoreGestureEvent; + __pCoreGestureEvent = null; + + // Relese public event listeners + delete __pPublicFocusEventListeners; + __pPublicFocusEventListeners = null; + delete __pPublicKeyEventListeners; + __pPublicKeyEventListeners = null; + delete __pPublicTouchEventListeners; + __pPublicTouchEventListeners = null; + delete __pPublicDragDropEventListeners; + __pPublicDragDropEventListeners = null; + delete __pPublicTouchModeChangedEventListeners; + __pPublicTouchModeChangedEventListeners = null; + + // Release builder bounds + delete __pBuilderPortraitBounds; + __pBuilderPortraitBounds = null; + delete __pBuilderLandscapeBounds; + __pBuilderLandscapeBounds = null; + + // Release aninator + delete __pControlAnimator; + __pControlAnimator = null; + + delete __pPublicGestureDetectors; + __pPublicGestureDetectors = null; + + delete __pFlickGestureDetector; + __pFlickGestureDetector = null; + + delete __pLongPressGestureDetector; + __pLongPressGestureDetector = null; + + delete __pAccessibilityContainerImpl; + __pAccessibilityContainerImpl = null; +} + +_ControlImpl::~_ControlImpl(void) +{ + Dispose(true); +} + +_ControlImpl::_ControlImpl(Control* pPublic, _Control* pCore) + : __pControlPublic(pPublic) + , __pControlCore(null) + , __pControlAnimator(null) + , __pCustomVisualElement(null) + , __pPublicFocusEventListeners(null) + , __pPublicKeyEventListeners(null) + , __pPublicTouchEventListeners(null) + , __pPublicDragDropEventListeners(null) + , __pPublicTouchModeChangedEventListeners(null) + , __pDefaultKeyEventListener(null) + , __pDefaultTouchEventListener(null) + , __foregroundColor(Color(0, 0, 0, 0)) + , __fontSize(0) + , __inputEventConsumed(false) + , __focusableChangable(true) + , __pCoreEventListener(null) + , __pCoreKeyEvent(null) + , __pCoreTouchEvent(null) + , __pCoreFocusEvent(null) + , __pCoreGestureEvent(null) + , __pBuilderPortraitBounds(null) + , __pBuilderLandscapeBounds(null) + , __pFlickGestureDetector(null) + , __pLongPressGestureDetector(null) + , __pPublicGestureDetectors(null) + , __pAccessibilityContainerImpl(null) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysAssert(__pControlPublic); + SysAssert(pCore); + + // Set core + r = SetCore(*pCore); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Core event listeners: [ToDo: mklove.kang] Check exceptions because the constructors can fail. + __pCoreKeyEvent = new (std::nothrow) CoreKeyEvent(*this); + SysTryCatch(NID_UI, __pCoreKeyEvent, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pCoreTouchEvent = new (std::nothrow) CoreTouchEvent(*this); + SysTryCatch(NID_UI, __pCoreTouchEvent, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pCoreFocusEvent = new (std::nothrow) CoreFocusEvent(*this); + SysTryCatch(NID_UI, __pCoreFocusEvent, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pCoreGestureEvent = new (std::nothrow) CoreGestureEvent(*this); + SysTryCatch(NID_UI, __pCoreGestureEvent, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pFlickGestureDetector = new (std::nothrow) _TouchFlickGestureDetector; + SysTryCatch(NID_UI, __pFlickGestureDetector, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pLongPressGestureDetector = new (std::nothrow) _TouchLongPressGestureDetector; + SysTryCatch(NID_UI, __pLongPressGestureDetector, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + // Public listeners + __pPublicFocusEventListeners = CreatePublicEventListenerListN(); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeyEventListeners = CreatePublicEventListenerListN(); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTouchEventListeners = CreatePublicEventListenerListN(); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicDragDropEventListeners = CreatePublicEventListenerListN(); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTouchModeChangedEventListeners = CreatePublicEventListenerListN(); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicGestureDetectors = new (std::nothrow) LinkedListT; + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = _ResourceManager::GetInstance()->GetColor(L"DEFAULTCOLORTABLE::foreground", __foregroundColor); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Check + SysAssert(r == E_SUCCESS); + + return; + +CATCH: + Dispose(true); // [ToDo] Is it OK? +} + +_Layout::LayoutContainer& +_ControlImpl::GetLayoutContainer(void) const +{ + return GetCore().GetLayoutContainer(); +} + +result +_ControlImpl::SetBuilderBounds(_ControlOrientation orientation, const Rectangle& bounds) +{ + ClearLastResult(); + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + if (__pBuilderPortraitBounds == null) + { + __pBuilderPortraitBounds = new (std::nothrow) Rectangle(0, 0, 0, 0); + + SysTryReturn(NID_UI, + __pBuilderPortraitBounds, E_OUT_OF_MEMORY, + E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + } + + *__pBuilderPortraitBounds = bounds; + return E_SUCCESS; + } + else if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + if (__pBuilderLandscapeBounds == null) + { + __pBuilderLandscapeBounds = new (std::nothrow) Rectangle(0, 0, 0, 0); + + SysTryReturn(NID_UI, + __pBuilderLandscapeBounds, E_OUT_OF_MEMORY, + E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + } + + *__pBuilderLandscapeBounds = bounds; + return E_SUCCESS; + } + + SysAssert(false); + return E_SYSTEM; +} + +bool +_ControlImpl::GetBuilderBounds(_ControlOrientation orientation, Rectangle& bounds) const +{ + ClearLastResult(); + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT && __pBuilderPortraitBounds) + { + bounds = *__pBuilderPortraitBounds; + return true; + } + else if (orientation == _CONTROL_ORIENTATION_LANDSCAPE && __pBuilderLandscapeBounds) + { + bounds = *__pBuilderLandscapeBounds; + return true; + } + + return false; +} + +Bitmap* +_ControlImpl::GetCapturedBitmapN(void) const +{ + return GetCore().GetCapturedBitmapN(true); +} + +Rectangle +_ControlImpl::GetInvalidatedBounds(void) const +{ + return GetCore().GetInvalidatedBounds(); +} + +result +_ControlImpl::GenerateKeyEvent(KeyState keyState, _KeyCode keyCode) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI, keyState == KEY_LONGPRESSED, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] keyState is invalid.\n"); + + SysTryReturn(NID_UI, __pCoreKeyEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + __pCoreKeyEvent->ProcessListener(keyState, keyCode); + + return r; +} + +result +_ControlImpl::GenerateTouchEvent(const _TouchInfo& touchInfo) +{ + result r = E_SUCCESS; + + _TouchStatus touchStatus = touchInfo.GetTouchStatus(); + + SysTryReturn(NID_UI, (touchStatus == _TOUCH_LONG_PRESSED) || (touchStatus == _TOUCH_DOUBLE_PRESSED), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] touchStatus is invalid.\n"); + + SysTryReturn(NID_UI, __pCoreTouchEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + __pCoreTouchEvent->ProcessListener(touchInfo); + + return r; +} + +void +_ControlImpl::SetMovable(bool movable) +{ + GetCore().SetMovable(movable); +} + +void +_ControlImpl::SetResizable(bool resizable) +{ + GetCore().SetResizable(resizable); +} + +AccessibilityContainer* +_ControlImpl::GetAccessibilityContainer(void) +{ + if(__pAccessibilityContainerImpl == null) + { + AccessibilityContainer* pContainer = _AccessibilityContainerImpl::CreateAccessibilityContainerN(*this); + if(pContainer) + { + __pAccessibilityContainerImpl = _AccessibilityContainerImpl::GetInstance(*pContainer); + return pContainer; + } + else + return null; + } + else + { + return &(__pAccessibilityContainerImpl->GetPublic()); + } +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_ControlImplManager.cpp b/src/ui/FUi_ControlImplManager.cpp new file mode 100644 index 0000000..167da4c --- /dev/null +++ b/src/ui/FUi_ControlImplManager.cpp @@ -0,0 +1,365 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ControlImplManager.cpp + * @brief This is the implementation file for the _ControlImplManager class. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include "FUi_ControlImplManager.h" +#include "FUi_ControlManager.h" +#include "FUi_WindowImpl.h" +#include "FUi_KeyEventManagerImpl.h" +#include "FUi_FocusManagerImpl.h" + +#include "FUiCtrl_FrameImpl.h" +#include "FUiCtrl_FormImpl.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Io; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Animations; + +namespace // unnamed +{ + +OrientationStatus +Convert(_ControlRotation rotate, bool allowReverse) +{ + OrientationStatus status = ORIENTATION_STATUS_NONE; + + if (allowReverse == true) + { + switch (rotate) + { + case _CONTROL_ROTATION_0: + status = ORIENTATION_STATUS_PORTRAIT; + break; + case _CONTROL_ROTATION_270: + status = ORIENTATION_STATUS_LANDSCAPE; + break; + case _CONTROL_ROTATION_180: + status = ORIENTATION_STATUS_PORTRAIT_REVERSE; + break; + case _CONTROL_ROTATION_90: + status = ORIENTATION_STATUS_LANDSCAPE_REVERSE; + break; + } + } + else + { + switch (rotate) + { + case _CONTROL_ROTATION_0: + // fall through + case _CONTROL_ROTATION_180: + status = ORIENTATION_STATUS_PORTRAIT; + break; + case _CONTROL_ROTATION_90: + status = ORIENTATION_STATUS_LANDSCAPE_REVERSE; + break; + case _CONTROL_ROTATION_270: + status = ORIENTATION_STATUS_LANDSCAPE; + break; + } + } + + return status; +} + +_ControlRotation +Convert(OrientationStatus orientationStatus) +{ + switch (orientationStatus) + { + case ORIENTATION_STATUS_PORTRAIT: + return _CONTROL_ROTATION_0; + case ORIENTATION_STATUS_LANDSCAPE: + return _CONTROL_ROTATION_270; + case ORIENTATION_STATUS_PORTRAIT_REVERSE: + return _CONTROL_ROTATION_180; + case ORIENTATION_STATUS_LANDSCAPE_REVERSE: + return _CONTROL_ROTATION_90; + default: + return _CONTROL_ROTATION_0; + } +} + +} // unnamed namespace + +result +InitializeTestbuddyManager(void) +{ + result r = E_FAILURE; + void* pHandle = null; + + SysLog(NID_UI,"TestbuddyManager is starting."); + + result (*pfnInitialize_TestBuddyManager)(void) = null; + + pHandle = dlopen ("libtestbuddy.so", RTLD_LAZY); + if (!pHandle) + { + SysLog(NID_UI, "[%s] Failed to dlopen libtestbuddy.so", dlerror()); + return E_LIBRARY_NOT_FOUND; + } + + pfnInitialize_TestBuddyManager = reinterpret_cast(dlsym(pHandle, "_Initialize_TestBuddyManager")); + if (pfnInitialize_TestBuddyManager == null) + { + SysLog(NID_UI, "[%s] Failed to dlsym _Initialize_TestBuddyManager", dlerror()); + dlclose(pHandle); + return E_SYMBOL_NOT_FOUND; + } + + r = pfnInitialize_TestBuddyManager(); + SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] pfnInitialize_TestBuddyManager() is invaild."); + + return r; +} + +result +InitializeUiFramework(void) +{ + _ControlImplManager::Initialize(); + + // TODO : After completing InitializeTestbuddyManager( ) + //return GetLastResult(); + return E_SUCCESS; +} + +void +FinalizeUiFramework(void) +{ + _ControlImplManager::Release(); +} + + +namespace Tizen { namespace Ui { + +_ControlImplManager* _ControlImplManager::__pInstance(null); + +// Explicitly initialize just before the Form is created. +void +_ControlImplManager::Initialize(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (!__pInstance) + { + pthread_once(&once_block, InitInstance); + } + + _ControlManager::Initialize(); + + result r = InitializeTestbuddyManager(); + SetLastResult(r); +} + +void +_ControlImplManager::Release(void) +{ + _ControlManager::Release(); + + delete __pInstance; + __pInstance = null; +} + +_ControlImplManager* +_ControlImplManager::GetInstance(void) +{ + return __pInstance; +} + +void +_ControlImplManager::InitInstance(void) +{ + if (__pInstance != null) + { + return; + } + + __pInstance = new (std::nothrow) _ControlImplManager; + SysAssert(__pInstance); +} + +_ControlImplManager::_ControlImplManager(void) + : __pFrameImpl(null) +{ + _KeyEventManagerImpl::Initialize(); + _FocusManagerImpl::Initialize(); +} + +_ControlImplManager::~_ControlImplManager(void) +{ + _FocusManagerImpl::ReleaseInstance(); + _KeyEventManagerImpl::ReleaseInstance(); +} + +_WindowImpl* +_ControlImplManager::GetCurrentFrame(void) const +{ + _Window* pFrame = _ControlManager::GetInstance()->GetCurrentFrame(); + if (pFrame == null) + { + return null; + } + + _WindowImpl* pImpl = static_cast <_WindowImpl*>(pFrame->GetUserData()); + return pImpl; +} + +void +_ControlImplManager::OnScreenRotated(int rotation) +{ + _ControlManager* pCore = _ControlManager::GetInstance(); + SysAssert(pCore); + + pCore->OnScreenRotated(rotation); + +#if !defined(MULTI_WINDOW) + Controls::_FrameImpl* pFrameImpl = dynamic_cast(GetCurrentFrame()); + if (pFrameImpl == null) + { + return; + } + + Controls::_FormImpl* pCurrentFormImpl = pFrameImpl->GetCurrentForm(); + + if (pCurrentFormImpl != null) + { + pCurrentFormImpl->UpdateOrientationStatus(true); + } + else + { + pFrameImpl->UpdateOrientationStatus(); + } +#endif +} + +void +_ControlImplManager::SetOrientationStatus(OrientationStatus orientationStatus) +{ + _ControlManager* pCore = _ControlManager::GetInstance(); + SysAssert(pCore); + + pCore->SetOrientationStatus(::Convert(orientationStatus)); +} + +#if !defined(MULTI_WINDOW) +void +_ControlImplManager::RotateScreen(OrientationStatus orientationStatus) +{ + _ControlManager* pCore = _ControlManager::GetInstance(); + SysAssert(pCore); + + pCore->RotateScreen(::Convert(orientationStatus)); +} +#else +void +_ControlImplManager::RotateScreen(_ControlImpl* pControlImpl, OrientationStatus orientationStatus) +{ + _ControlManager* pCore = _ControlManager::GetInstance(); + SysAssert(pCore); + + pCore->RotateScreen(pControlImpl->GetCore(), ::Convert(orientationStatus)); +} +#endif + +OrientationStatus +_ControlImplManager::GetOrientationStatus(Orientation mode) const +{ + _ControlManager* pCore = _ControlManager::GetInstance(); + SysAssert(pCore); + + const _ControlRotation screenRotation = pCore->GetScreenRotation(); + + if (mode == ORIENTATION_AUTOMATIC_FOUR_DIRECTION) + { + return ::Convert(screenRotation, true); + } + + if (mode == ORIENTATION_AUTOMATIC) + { + return ::Convert(screenRotation, false); + } + + OrientationStatus status = ORIENTATION_STATUS_NONE; + switch (mode) + { + case ORIENTATION_PORTRAIT: + status = ORIENTATION_STATUS_PORTRAIT; + break; + case ORIENTATION_LANDSCAPE: + status = ORIENTATION_STATUS_LANDSCAPE; + break; + case ORIENTATION_PORTRAIT_REVERSE: + status = ORIENTATION_STATUS_PORTRAIT_REVERSE; + break; + case ORIENTATION_LANDSCAPE_REVERSE: + status = ORIENTATION_STATUS_LANDSCAPE_REVERSE; + break; + default: + SysAssert(false); + } + + return status; +} + +OrientationStatus +_ControlImplManager::GetFormOrientationStatus(_ControlImpl *pControlImpl) +{ + _FormImpl* pParentImpl = null; + OrientationStatus orientation = ORIENTATION_STATUS_NONE; + while(pControlImpl) + { + pParentImpl = dynamic_cast<_FormImpl*>(pControlImpl->GetParent()); + + if (pParentImpl != null) + { + break; + } + else + { + pControlImpl = pControlImpl->GetParent(); + } + } + + if (pParentImpl) + { + orientation = pParentImpl->GetOrientationStatus(); + } + + return orientation; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_ControlManager.cpp b/src/ui/FUi_ControlManager.cpp new file mode 100755 index 0000000..240574d --- /dev/null +++ b/src/ui/FUi_ControlManager.cpp @@ -0,0 +1,1684 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ControlManager.cpp + * @brief This is the implementation file for the _ControlManager class. + */ + +#include +#include +#include +#if defined(MULTI_WINDOW) +#include +#include +#endif +#include +#include +#if defined(MULTI_WINDOW) +#include +#endif +#include +#include +#include +#include +#include +#include "FUi_ControlManager.h" +#include "FUi_Control.h" +#include "FUi_Window.h" +#include "FUi_WindowImpl.h" +#include "FUi_EcoreEvas.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EflWindow.h" +#include "FUi_ResourceManager.h" +#include "FUi_Clipboard.h" +#include "FUi_UiFocusEvent.h" +#include "FUi_UiEventManager.h" +#include "FUi_TouchManager.h" +#include "FUi_TouchLongPressGestureDetector.h" +#include "FUi_TouchTapGestureDetector.h" +#include "FUi_KeyEventManager.h" +#include "FUi_CoordinateSystemUtils.h" +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_AnimationManager.h" +#include "FUiAnim_DisplayManager.h" +#include "FUi_AccessibilityManager.h" +#if defined(MULTI_WINDOW) +#include "FUiAnim_VisualElement.h" +#include "FUiAnim_EflLayer.h" +#include "FUiCtrl_FrameImpl.h" +#include "FUiCtrl_FormImpl.h" +#endif +#include "FUiCtrl_Frame.h" +// #include "FUiCtrl_NotificationFrame.h" +// #include "FUiCtrl_NotificationFrameImpl.h" +#include "FUiCtrl_IndicatorManager.h" + +using namespace Tizen::App; +using namespace Tizen::App::Package; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Controls; +using namespace Tizen::System; + +namespace { + +_ControlRotation Convert(int rotationDegree) +{ + switch (rotationDegree) + { + case 0: + return _CONTROL_ROTATION_0; + case 90: + return _CONTROL_ROTATION_90; + case 180: + return _CONTROL_ROTATION_180; + case 270: + return _CONTROL_ROTATION_270; + default: + return _CONTROL_ROTATION_0; + } +} + +int Convert(_ControlRotation rotation) +{ + switch (rotation) + { + case _CONTROL_ROTATION_0: + return 0; + case _CONTROL_ROTATION_90: + return 90; + case _CONTROL_ROTATION_180: + return 180; + case _CONTROL_ROTATION_270: + return 270; + } +} + +} // Anonymous + +namespace Tizen { namespace Ui +{ + +class _UiDebug +{ +public: + static void PrintControl(const _Control& control, bool printChildren = true); + static void PrintTree(void); +}; + +void +_UiDebug::PrintControl(const _Control& control, bool printChildren) +{ + const_cast<_Control&>(control).PrintDescription(printChildren); +} + +void +_UiDebug::PrintTree(void) +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] System error occurred."); + +#if !defined(MULTI_WINDOW) + PrintControl(pControlManager->GetRoot(), true); +#else + if (pControlManager->GetWindowCount() == 0) + { + SysLog(NID_UI, "There is no window."); + return; + } + + int count = pControlManager->GetWindowCount(); + for (int i = 0; i < count; i++) + { + _Window* pWindow = pControlManager->GetWindow((count-1) - i); + PrintControl(*pWindow, true); + } +#endif +} + +_ControlManager* _ControlManager::__pInstance = null; + +void +_ControlManager::Initialize(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (!__pInstance) + { + pthread_once(&once_block, InitInstance); + } + + result r = _SettingInfoImpl::AddSettingEventListenerForInternal(*__pInstance); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + // [ToDo] Is it OK to directly get the device orientation? + int degree = app_get_device_orientation(); + SysLog(NID_UI, "The initial value of device orientation is %d.", degree); + + __pInstance->__screenRotation = ::Convert(degree); +} + +void +_ControlManager::Release(void) +{ + result r = _SettingInfoImpl::RemoveSettingEventListenerForInternal(*__pInstance); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pInstance; + __pInstance = null; +} + +_ControlManager* +_ControlManager::GetInstance(void) +{ + return __pInstance; +} + +void +_ControlManager::InitInstance(void) +{ + if (__pInstance) + { + return; + } + + __pInstance = new (std::nothrow) _ControlManager; + SysAssert(__pInstance); +} + +_ControlHandle +_ControlManager::Register(_Control* pObject) +{ + if (pObject) + { + SysLog(NID_UI, "A _Control Registered()"); + } + + if (pObject == null) + { + return _ControlHandle(); + } + + return __objectManager.Register(*pObject); +} + +_Control* +_ControlManager::Release(const _ControlHandle& handle) +{ + _Control* pObject = GetObject(handle); + if (pObject) + { + SysLog(NID_UI, "A _Control Released()"); + } + + return __objectManager.Unregister(handle); +} + +_Control* +_ControlManager::GetObject(const _ControlHandle& handle) +{ + return __objectManager.GetObject(handle); +} + +const _Control* +_ControlManager::GetObject(const _ControlHandle& handle) const +{ + return __objectManager.GetObject(handle); +} + +int +_ControlManager::GetUsedHandleCount(void) const +{ + return __objectManager.GetObjectCount(); +} + +result +_ControlManager::GetAppCoordinateSystem(bool& isCoordinateSystemLogical, int& logicalCoordinateSystemInt, _BaseScreenSize& logicalBaseScreenSize) +{ + _PackageInfoImpl infoImpl; + { + String subAppId(_AppInfo::GetAppId()); + + result r = infoImpl.Construct(subAppId); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + String baseScreenSize(null); + String coordinateSystem(null); + String logicalCoordinate(null); + + result r = infoImpl.GetUiScalabilityInfo(baseScreenSize, coordinateSystem, logicalCoordinate); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (coordinateSystem.Equals(L"Physical", false)) + { + isCoordinateSystemLogical = false; + logicalCoordinateSystemInt = 0; + logicalBaseScreenSize = BASE_SCREEN_SIZE_DEFAULT; + + return E_SUCCESS; + } + + //Logical Resolution + r = Integer::Parse(logicalCoordinate, logicalCoordinateSystemInt); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // BaseScreenSize + if (baseScreenSize.Equals(L"Large", false)) + { + logicalBaseScreenSize = BASE_SCREEN_SIZE_LARGE; + } + else // temp + { + logicalBaseScreenSize = BASE_SCREEN_SIZE_NORMAL; + } + + return r; +} + +bool +_ControlManager::IsCoordinateSystemLogical(void) const +{ + return __isCoordinateSystemLogical; +} + +int +_ControlManager::GetCoordinateSystem(void) const +{ + return __logicalCoordinateSystem; +} + +_BaseScreenSize +_ControlManager::GetLogicalBaseScreenSize(void) const +{ + return __logicalBaseScreenSize; +} + +_ControlManager::_ControlManager(void) // [ToDo] exception check. +#if !defined(MULTI_WINDOW) + : __pRoot(null) +#else + : __pWindowList(null) +#endif + , __isCoordinateSystemLogical(true) + , __logicalCoordinateSystem(0) + , __logicalBaseScreenSize(BASE_SCREEN_SIZE_NONE) + , __pSystemWindowList(null) + , __pFocusedControl(null) + , __screenRotation(_CONTROL_ROTATION_0) + , __orientationStatus(_CONTROL_ROTATION_0) + , __orientation(_CONTROL_ORIENTATION_PORTRAIT) +#if !defined(MULTI_WINDOW) + , __pWindowPi(null) +#endif + , __pCurrentFrame(null) + , __pGestureList(null) + , __gestureMaxDuration(0) +#if defined(MULTI_WINDOW) + , __touchedWindow(0) +#endif + , __isDefaultFontChanged(false) + , __defaultFontName(L"") +{ + result r = GetAppCoordinateSystem(__isCoordinateSystemLogical, __logicalCoordinateSystem, __logicalBaseScreenSize); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + Dimension deviceResolution = CoordinateSystem::GetPhysicalResolution(); + _BaseScreenSize deviceBaseScreenSize = _CoordinateSystem::GetInstance()->GetPhysicalBaseScreenSize(); + + r = _CoordinateSystem::Initialize(__logicalCoordinateSystem, __logicalBaseScreenSize, deviceResolution, deviceBaseScreenSize); + SysAssert(r == E_SUCCESS); + +#if !defined(MULTI_WINDOW) + _RootVisualElement* pVisualElementRoot = null; + _EflWindow* pWindowPi = null; + _Control* pRoot = null; + _ControlHandle rootHandle; + + // Initialize _UiEventManager + _UiEventManager::Initialize(); + + // Initialize _TouchManager + _TouchManager::Initialize(); + + _KeyEventManager::Initialize(); + + _AccessibilityManager::CreateInstance(); + + r = _AnimationManager::CreateInstance(); + SysAssertf(r == E_SUCCESS, "Failed to create animation manager!"); + + r = _DisplayManager::CreateInstance(); + SysAssertf(r == E_SUCCESS, "Failed to create display manager!"); + + pWindowPi = _EflWindow::CreateInstanceN(); + SysTryReturnVoidResult(NID_UI, pWindowPi, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + pRoot = new (std::nothrow) _Control; // The children of pRoot are set not to be clipped to the parent. + SysTryCatch(NID_UI, pRoot, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error occurred."); + + pVisualElementRoot = pWindowPi->GetRootVisualElement(); + SysTryCatch(NID_UI, pVisualElementRoot, , E_SYSTEM, "[E_SYSTEM] System error occurred."); + pVisualElementRoot->SetName(L"Root"); + + r = pVisualElementRoot->AttachChild(*pRoot->GetVisualElement()); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error occurred."); + pRoot->GetVisualElement()->SetClipChildrenEnabled(false); + pRoot->GetVisualElement()->SetName(L"RootControl"); + + __pSystemWindowList = new (std::nothrow)LinkedListT<_Window*>; + SysTryCatch(NID_UI, __pSystemWindowList, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pGestureList = new (std::nothrow)LinkedListT<_TouchGestureDetector*>; + SysTryCatch(NID_UI, __pGestureList, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + rootHandle = Register(pRoot); // [review] exception + SysAssert(rootHandle.IsValid()); + + __pWindowPi = pWindowPi; + __pRoot = pRoot; + + pWindowPi->SetFrame(*pRoot); + + return; + +CATCH: + delete pWindowPi; + pWindowPi = null; + + delete pRoot; + pRoot = null; + + delete __pGestureList; + __pGestureList = null; + + delete __pSystemWindowList; + __pSystemWindowList = null; + +#else + r = _AnimationManager::CreateInstance(); + SysAssertf(r == E_SUCCESS, "Failed to create animation manager!"); + + r = _DisplayManager::CreateInstance(); + SysAssertf(r == E_SUCCESS, "Failed to create display manager!"); + + _EcoreEvas::CreateInstanceN(); + + __pWindowList = new (std::nothrow)LinkedListT<_Window*>; + SysTryCatch(NID_UI, __pWindowList, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pGestureList = new (std::nothrow)LinkedListT<_TouchGestureDetector*>; + SysTryCatch(NID_UI, __pGestureList, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + _UiEventManager::Initialize(); + _TouchManager::Initialize(); + _KeyEventManager::Initialize(); + _IndicatorManager::InitializeInstance(); + _AccessibilityManager::CreateInstance(); + + SetLastResult(E_SUCCESS); + + return; + +CATCH: + _AnimationManager::ReleaseInstance(); + + if (__pWindowList) + { + delete __pWindowList; + __pWindowList = null; + } + + if (__pGestureList) + { + delete __pGestureList; + __pGestureList = null; + } +#endif +} + +_ControlManager::~_ControlManager(void) +{ +#if !defined(MULTI_WINDOW) + _EflWindow* pWindowPi = static_cast<_EflWindow*>(__pWindowPi); + + // Release frame window + if(pWindowPi) + { + _RootVisualElement* pRootVE = pWindowPi->GetRootVisualElement(); + _VisualElement* pControlRootVE = __pRoot->GetVisualElement(); + if (pRootVE && pControlRootVE) + { + pRootVE->DetachChild(*pControlRootVE); + } + } + + // Release clip board + _Clipboard::ReleaseInstance(); + + // Relese others + delete __pRoot; + delete __pWindowPi; + delete __pGestureList; + delete __pSystemWindowList; + + _AnimationManager::ReleaseInstance(); + + // Release ecore evas manager + DestroyEcoreEvasMgr(); + + // Check control handle count + if (GetUsedHandleCount() != 0) + { + SysLog(NID_UI, "[Control Manager] The number of unreleased controls: %d", GetUsedHandleCount()); + } + + _DisplayManager::ReleaseInstance(); +#else + _Clipboard::ReleaseInstance(); + + if (__pWindowList) + { + delete __pWindowList; + __pWindowList = null; + } + + if (__pGestureList) + { + delete __pGestureList; + __pGestureList = null; + } + + DestroyEcoreEvasMgr(); + + if (GetUsedHandleCount() != 0) + { + SysLog(NID_UI, "[Control Manager] The number of unreleased controls: %d", GetUsedHandleCount()); + } + + _DisplayManager::ReleaseInstance(); + + _AnimationManager::ReleaseInstance(); +#endif + _AccessibilityManager::ReleaseInstance(); + + _IndicatorManager::ReleaseInstance(); + + _KeyEventManager::ReleaseInstance(); + _TouchManager::ReleaseInstance(); + + _UiEventManager::Release(); +} + +#if !defined(MULTI_WINDOW) +const _Control& +_ControlManager::GetRoot(void) const +{ + SysAssert(__pRoot); + return *__pRoot; +} + +_Control& +_ControlManager::GetRoot(void) +{ + SysAssert(__pRoot); + return *__pRoot; +} +#endif + +_Window* +_ControlManager::GetTopWindow(void) const +{ + ClearLastResult(); + + if (GetWindowCount() == 0) + { + return null; + } + + return GetWindow(GetWindowCount() - 1); +} + +#if defined(MULTI_WINDOW) +_Window* +_ControlManager::GetTopVisibleWindow(void) const +{ + ClearLastResult(); + + if (GetWindowCount() == 0) + { + return null; + } + + int count = GetWindowCount(); + for (int i = 0; i < count; i++) + { + _Window* pWindow = GetWindow((count-1) - i); + + if (pWindow->GetVisibleState() == true) + { + return pWindow; + } + } + + return null; +} + +_Window* +_ControlManager::GetTopVisibleWindowAt(const Point& point) const +{ + ClearLastResult(); + + if (GetWindowCount() == 0) + { + return null; + } + + int count = GetWindowCount(); + for (int i = 0; i < count; i++) + { + _Window* pWindow = GetWindow((count-1) - i); + + if (pWindow->GetVisibleState() == false) + { + continue; + } + + Rectangle winBounds = pWindow->GetBounds(); + if (winBounds.Contains(point)) + { + return pWindow; + } + } + + return null; +} +#endif + +bool +_ControlManager::IsWindowOnTop(const _Window& window) const +{ + return GetTopWindow() == &window; +} + +bool +_ControlManager::IsWindowAttached(const _Window& window) const +{ +#if !defined(MULTI_WINDOW) + if (window.IsSystemWindow()) + { + return __pSystemWindowList->Contains(const_cast<_Window*>(&window)); + } + + return window.GetParent() == __pRoot; +#else + return __pWindowList->Contains(const_cast<_Window*>(&window)); +#endif +} + +// Open a window and bring it to top. +result +_ControlManager::OpenWindow(_Window& window, bool invalidate) +{ +#if !defined(MULTI_WINDOW) + // [Temp] + if (dynamic_cast <_Frame*>(&window) != null) + { + __pWindowPi->SetFrame(window); + } +#endif + + if (dynamic_cast <_Frame*>(&window) != null) + { + __pCurrentFrame = &window; + } + + result r = ActivateWindow(window); + SysTryReturn(NID_UI, r != E_INVALID_OPERATION, r, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + if (invalidate) + { + window.Invalidate(true); + } + + return E_SUCCESS; +} + +result +_ControlManager::ActivateWindow(_Window& window) +{ + ClearLastResult(); + result r = E_SUCCESS; + +#if !defined(MULTI_WINDOW) + // if (dynamic_cast<_NotificationFrame*>(&window)) + if (window.IsSystemWindow()) + { + r = window.GetControlDelegate().OnAttaching(null); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = CallOnAttachingToMainTree(window); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + window.Activate(); + + r = window.GetControlDelegate().OnAttached(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = CallOnAttachedToMainTree(window); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + if (IsWindowOnTop(window)) + { + return E_SUCCESS; + } + + if (window.IsActivatedOnOpen()) + { + _Window* pTopWindow = GetTopWindow(); + if (pTopWindow) + { + pTopWindow->Deactivate(); + } + } + + if (IsWindowAttached(window)) + { + r = MoveWindowToTop(window); // [ToDo] excpetion + SysAssert(r == E_SUCCESS); + + return E_SUCCESS; + } + + r = AttachWindow(window); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (window.IsActivatedOnOpen()) + { + window.Activate(); + } + else + { + window.SetWindowState(WINDOW_STATE_DEACTIVATED); + } + } +#else + if (IsWindowOnTop(window)) + { + return E_SUCCESS; + } + + if (window.IsActivationEnabled()) + { + _Window* pTopWindow = GetTopWindow(); + if (pTopWindow) + { + pTopWindow->Deactivate(); + } + } + + if (IsWindowAttached(window)) + { + r = MoveWindowToTop(window); // [ToDo] excpetion + SysAssert(r == E_SUCCESS); + + return E_SUCCESS; + } + + r = window.GetControlDelegate().OnAttaching(null); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = CallOnAttachingToMainTree(window); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = AttachWindow(window); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (window.IsActivationEnabled()) + { + window.Activate(); + } + + if (window.IsOrientationRoot() == false) + { + window.ChangeLayout(GetOrientation()); + + _EcoreEvas* pEcoreEvas = ::GetEcoreEvasMgr()->GetEcoreEvas(); + if (pEcoreEvas) + { + pEcoreEvas->RotateWindow(window, ::Convert(__orientationStatus)); + } + } + + r = window.GetControlDelegate().OnAttached(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = CallOnAttachedToMainTree(window); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); +#endif + + return E_SUCCESS; +} + +result +_ControlManager::CallOnAttachingToMainTree(_Control& control) +{ + result r = E_SUCCESS; + + r = control.GetControlDelegate().OnAttachingToMainTree(null); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Control::ControlList& children = control.GetChildList(); + _Control* pChild = null; + + for (int index = 0; index < children.GetCount(); index++) + { + r = children.GetAt(index, pChild); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_RANGE); + SysTryReturn(NID_UI, + (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range."); + } + r = CallOnAttachingToMainTree(*pChild); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_ControlManager::CallOnAttachedToMainTree(_Control& control) +{ + result r = E_SUCCESS; + + _Control* pChild = null; + _Control::ControlList* pControlList = new (std::nothrow) _Control::ControlList; + pControlList->Construct(control.GetChildList()); + + r = control.GetControlDelegate().OnAttachedToMainTree(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + for (int index = 0; index < pControlList->GetCount(); index++) + { + r = pControlList->GetAt(index, pChild); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_RANGE); + SysTryReturn(NID_UI, + (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range."); + } + r = control.CallOnAttachedToMainTree(*pChild); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + delete pControlList; + + return r; +} + +result +_ControlManager::CallOnDetachingFromMainTree(_Control& control) +{ + result r = E_SUCCESS; + + _Control* pChild = null; + _Control::ControlList& children = control.GetChildList(); + + r = control.GetControlDelegate().OnDetachingFromMainTree(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + for (int index = 0; index < children.GetCount(); index++) + { + r = children.GetAt(index, pChild); + if (IsFailed(r)) + { + SysAssert(r == E_OUT_OF_RANGE); + SysTryReturn(NID_UI, + (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range."); + } + r = CallOnDetachingFromMainTree(*pChild); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_ControlManager::CloseWindow(_Window& window) // [ToDo] exception check. +{ + ClearLastResult(); + result r = E_SUCCESS; + +#if !defined(MULTI_WINDOW) + // if (dynamic_cast<_NotificationFrame*>(&window)) + if (window.IsSystemWindow()) + { + r = CallOnDetachingFromMainTree(window); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + window.GetControlDelegate().OnDetaching(); + + window.Deactivate(); + } + else + { + if (IsWindowAttached(window) == false) + { + return E_SUCCESS; + } + + bool wasWindowOnTop = IsWindowOnTop(window); + + window.Deactivate(); + + r = DetachWindow(window); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (wasWindowOnTop) + { + _Window* pNewTopWindow = GetTopWindow(); + if (pNewTopWindow && pNewTopWindow->IsActivatedOnOpen()) + { + pNewTopWindow->Activate(); + } + } + + if (dynamic_cast <_Frame*>(&window) != null) + { + // __pWindowPi->SetFrame(null); // ? + __pCurrentFrame = null; + } + } +#else + if (IsWindowAttached(window) == false) + { + return E_SUCCESS; + } + + bool wasWindowOnTop = IsWindowOnTop(window); + + r = CallOnDetachingFromMainTree(window); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + window.GetControlDelegate().OnDetaching(); + + window.Deactivate(); + + r = DetachWindow(window); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (wasWindowOnTop) + { + _Window* pNewTopWindow = GetTopWindow(); + if (pNewTopWindow && pNewTopWindow->IsActivationEnabled()) + { + pNewTopWindow->Activate(); + } + + if (dynamic_cast <_Frame*>(pNewTopWindow) != null) + { + __pCurrentFrame = pNewTopWindow; + } + } +#endif + + return E_SUCCESS; +} + +_Window* +_ControlManager::GetWindow(int index) const +{ +#if !defined(MULTI_WINDOW) + return dynamic_cast <_Window*>(GetRoot().GetChild(index)); +#else + _Window* pWindow; + __pWindowList->GetAt(index, pWindow); + + return pWindow; +#endif +} + +int +_ControlManager::GetWindowCount(void) const +{ +#if !defined(MULTI_WINDOW) + return GetRoot().GetChildCount(); +#else + return __pWindowList->GetCount(); +#endif +} + +result +_ControlManager::AttachWindow(_Window& window) +{ + _IndicatorManager::GetInstance()->AddWindow(&window); + +#if !defined(MULTI_WINDOW) + return GetRoot().AttachChild(window); +#else + return __pWindowList->Add(&window); +#endif +} + +result +_ControlManager::InsertWindowToBottom(_Window& window) +{ +#if !defined(MULTI_WINDOW) + return GetRoot().InsertChildToBottom(window); +#else + return __pWindowList->InsertAt(&window, 0); +#endif +} + +result +_ControlManager::InsertWindowAfter(const _Window& targetWindow, _Window& window) +{ +#if !defined(MULTI_WINDOW) + return GetRoot().InsertChildAfter(targetWindow, window); +#else + int index = 0; + + result r = __pWindowList->IndexOf(const_cast<_Window*>(&targetWindow), index); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pWindowList->InsertAt(&window, index+1); +#endif +} + +result +_ControlManager::InsertWindowBefore(const _Window& targetWindow, _Window& window) +{ +#if !defined(MULTI_WINDOW) + return GetRoot().InsertChildBefore(targetWindow, window); +#else + int index = 0; + + result r = __pWindowList->IndexOf(const_cast<_Window*>(&targetWindow), index); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pWindowList->InsertAt(&window, index); +#endif +} + +result +_ControlManager::DetachWindow(_Window& window) +{ + _IndicatorManager::GetInstance()->DeleteWindow(&window); + +#if !defined(MULTI_WINDOW) + return GetRoot().DetachChild(window); +#else + return __pWindowList->Remove(&window); +#endif +} + +void +_ControlManager::DetachAllWindows(void) +{ +#if !defined(MULTI_WINDOW) + GetRoot().DetachAllChildren(); +#else + __pWindowList->RemoveAll(); +#endif +} + +result +_ControlManager::MoveWindowToTop(const _Window& window) +{ +#if !defined(MULTI_WINDOW) + return GetRoot().MoveChildToTop(window); +#else + result r = __pWindowList->Remove(const_cast<_Window*>(&window)); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pWindowList->Add(const_cast<_Window*>(&window)); +#endif +} + +result +_ControlManager::MoveWindowToBottom(const _Window& window) +{ +#if !defined(MULTI_WINDOW) + return GetRoot().MoveChildToBottom(window); +#else + result r = __pWindowList->Remove(const_cast<_Window*>(&window)); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pWindowList->InsertAt(const_cast<_Window*>(&window), 0); +#endif +} + +result +_ControlManager::MoveWindowAfter(const _Window& targetWindow, const _Window& window) +{ +#if !defined(MULTI_WINDOW) + return GetRoot().MoveChildAfter(targetWindow, window); +#else + result r = __pWindowList->Remove(const_cast<_Window*>(&window)); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int index = 0; + + r = __pWindowList->IndexOf(const_cast<_Window*>(&targetWindow), index); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pWindowList->InsertAt(const_cast<_Window*>(&window), index+1); +#endif +} + +result +_ControlManager::MoveWindowBefore(const _Window& targetWindow, const _Window& window) +{ +#if !defined(MULTI_WINDOW) + return GetRoot().MoveChildBefore(targetWindow, window); +#else + result r = __pWindowList->Remove(const_cast<_Window*>(&window)); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int index = 0; + + r = __pWindowList->IndexOf(const_cast<_Window*>(&targetWindow), index); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pWindowList->InsertAt(const_cast<_Window*>(&window), index); +#endif +} + +_ControlOrientation +_ControlManager::GetOrientation(void) const +{ + return __orientation; +} + +void +_ControlManager::SetOrientation(_ControlOrientation orientation) +{ + __orientation = orientation; +} + +_ControlRotation +_ControlManager::GetScreenRotation(void) const +{ + bool autoRotate = true; + int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, &autoRotate); + + if (ret == RUNTIME_INFO_ERROR_NONE) + { + SysLog(NID_UI, "The flag of auto-rotate is %d.", autoRotate); + } + else + { + SysLog(NID_UI, "It's failed to get the flag of auto-rotate."); + } + + if (autoRotate == false) + { + return _CONTROL_ROTATION_0; + } + else + { + return __screenRotation; + } +} + +void +_ControlManager::OnScreenRotated(int rotation) +{ + SysLog(NID_UI, "The angle of Emul or Target is %d.", rotation); + __screenRotation = ::Convert(rotation); + +#if defined(MULTI_WINDOW) + int count = GetWindowCount(); + + for (int i = 0; i < count; i++) + { + _Window* pWindow = GetWindow((count-1) - i); + + _Frame* pFrame = dynamic_cast<_Frame*>(pWindow); + + if (pFrame) + { + Controls::_FrameImpl* pFrameImpl = static_cast(pFrame->GetUserData()); + if (pFrameImpl == null) + { + continue; + } + + Controls::_FormImpl* pCurrentFormImpl = pFrameImpl->GetCurrentForm(); + if (pCurrentFormImpl) + { + pCurrentFormImpl->UpdateOrientationStatus(true); + } + else + { + pFrameImpl->UpdateOrientationStatus(); + } + } + } +#endif +} + +#if defined(MULTI_WINDOW) +void +_ControlManager::SetTouchedWindow(unsigned int window) +{ + __touchedWindow = window; +} + +_Window* +_ControlManager::GetTouchedWindow(void) const +{ + ClearLastResult(); + + if (GetWindowCount() == 0) + { + return null; + } + + int count = GetWindowCount(); + for (int i = 0; i < count; i++) + { + _Window* pWindow = GetWindow((count-1) - i); + + _RootVisualElement* pRootVE = pWindow->GetRootVisualElement(); + _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer()); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + + if (win == __touchedWindow) + { + return pWindow; + } + } + + return null; +} +#endif + +void +_ControlManager::SetOrientationStatus(_ControlRotation orientationStatus) +{ + __orientationStatus = orientationStatus; +} + +void +_ControlManager::RotateScreen(_ControlRotation screenRotation) +{ + _EcoreEvas* pEcoreEvas = ::GetEcoreEvasMgr()->GetEcoreEvas(); + SysAssert(pEcoreEvas); + if (pEcoreEvas == null) + { + return; + } + + pEcoreEvas->RotateWindow(::Convert(screenRotation)); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + if (pTouchManager) + { + pTouchManager->SetTouchCanceled(true); + } +} + +void +_ControlManager::RotateScreen(const _Control& control, _ControlRotation screenRotation) +{ + _EcoreEvas* pEcoreEvas = ::GetEcoreEvasMgr()->GetEcoreEvas(); + SysAssert(pEcoreEvas); + if (pEcoreEvas == null) + { + return; + } + + // Rotate root window. + _Window* pRootWindow = control.GetRootWindow(); + if (pRootWindow) + { + pEcoreEvas->RotateWindow(*pRootWindow, ::Convert(screenRotation)); + } + +#if defined(MULTI_WINDOW) + // Rotate Ownees. + int owneeCount = control.GetOwneeCount(); + for (int i = 0; i < owneeCount; i++) + { + _Window* pOwnee = control.GetOwnee(i); + if (pOwnee) + { + pEcoreEvas->RotateWindow(*pOwnee, ::Convert(screenRotation)); + } + } +#endif + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + if (pTouchManager) + { + pTouchManager->SetTouchCanceled(true); + } +} + +void +_ControlManager::OnWindowRotated(int rotation) +{ +#if !defined(MULTI_WINDOW) + IEnumeratorT<_Window*>* pEnumerator = __pSystemWindowList->GetEnumeratorN(); + SysTryReturnVoidResult(NID_UI, pEnumerator, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + _Window* pWindow = null; + pEnumerator->GetCurrent(pWindow); + if (pWindow) + { + _WindowImpl* pWindowImpl = static_cast<_WindowImpl*>(pWindow->GetUserData()); + if (pWindowImpl) + { + pWindowImpl->Rotate(Convert(rotation)); + } + } + } +#else + // For non-ownees + IEnumeratorT<_Window*>* pEnumerator = __pWindowList->GetEnumeratorN(); + SysTryReturnVoidResult(NID_UI, pEnumerator, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + _Window* pWindow = null; + pEnumerator->GetCurrent(pWindow); + + if (pWindow->GetOwner() == null) + { + void* pUserData = pWindow->GetUserData(); + if (pUserData) + { + _WindowImpl* pWindowImpl = static_cast<_WindowImpl*>(pUserData); + pWindowImpl->OnRotated(Convert(rotation)); + } + } + } +#endif + + delete pEnumerator; +} + +void +_ControlManager::SetFocusedControl(const _Control& control) +{ + if (__pFocusedControl == &control) + { + return; + } + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _Control *pPreviousFocusedControl = __pFocusedControl; + __pFocusedControl = const_cast<_Control*>(&control); + + if (pPreviousFocusedControl) + { + // [review] make SetFocus() return result and use the returned result here. + pEcoreEvas->SetFocus(*pPreviousFocusedControl, false); + if (GetLastResult() == E_SUCCESS) + { + if (pPreviousFocusedControl) + { + pPreviousFocusedControl->SetFocusOff(pPreviousFocusedControl); + } + _UiFocusEvent event(pPreviousFocusedControl->GetHandle(), FOCUS_LOST); + _UiEventManager::GetInstance()->SendEvent(event); + } + } + + // [review] make SetFocus() return result and use the returned result here. + if (control.IsNativeObjectFocusable()) + { + pEcoreEvas->SetFocus(control, true); + } + + if (GetLastResult() == E_SUCCESS) + { + _UiFocusEvent event(control.GetHandle(), FOCUS_GAINED); + _UiEventManager::GetInstance()->SendEvent(event); + const_cast<_Control*>(&control)->SetFocusOn(); + } +} + +// [review] called in ~_Control and virtual OnFocusLost is called. +// _Control::Release() instead of ~_Control. +bool +_ControlManager::TakeFocusFromControl(const _Control& control) +{ + if (__pFocusedControl == &control) + { + _UiFocusEvent event(__pFocusedControl->GetHandle(), FOCUS_LOST); + _UiEventManager::GetInstance()->SendEvent(event); + __pFocusedControl = null; + return true; + } + + return false; +} + +_Control* +_ControlManager::GetFocusedControl(void) const +{ + return __pFocusedControl; +} + +_Control* +_ControlManager::GetTopmostTouchedControl(const Point& point) +{ + _Control* pControl = null; + _Window* pTopWindow = null; + +#if !defined(MULTI_WINDOW) + pTopWindow = GetTopWindow(); +#else + int count = GetWindowCount(); + + if (count != 0) + { + for (int i = 0; i < count; i++) + { + _Window* pWindow = GetWindow((count-1) - i); + + if (pWindow->GetVisibleState() == false) + { + continue; + } + + _RootVisualElement* pRootVE = pWindow->GetRootVisualElement(); + _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer()); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + Ecore_X_Window win = (Ecore_X_Window)ecore_evas_window_get(pEcoreEvas); + + Rectangle winDeviceBounds(0, 0, 0, 0); + ecore_x_window_geometry_get(win, &winDeviceBounds.x, &winDeviceBounds.y, &winDeviceBounds.width, &winDeviceBounds.height); + + Point winDevicePoint = _CoordinateSystemUtils::Transform(pWindow->GetPosition()); + + Point devicePoint = _CoordinateSystemUtils::Transform(point); + int x = devicePoint.x; + int y = devicePoint.y; + + int rootW = 0; + int rootH = 0; + ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH); + + int rotation = ecore_evas_rotation_get(pEcoreEvas); + switch (rotation) + { + case 270: + devicePoint.x = rootW - y; + devicePoint.y = x; + winDeviceBounds.x = rootW - winDevicePoint.y - winDeviceBounds.width; + winDeviceBounds.y = winDevicePoint.x; + break; + case 180: + devicePoint.x = rootW - x; + devicePoint.y = rootH - y; + winDeviceBounds.x = rootW - winDevicePoint.x - winDeviceBounds.width; + winDeviceBounds.y = rootH - winDevicePoint.y - winDeviceBounds.height; + break; + case 90: + devicePoint.x = y; + devicePoint.y = rootH - x; + winDeviceBounds.x = winDevicePoint.y; + winDeviceBounds.y = rootH - winDevicePoint.x - winDeviceBounds.height; + break; + default: + devicePoint.x = x; + devicePoint.y = y; + winDeviceBounds.x = winDevicePoint.x; + winDeviceBounds.y = winDevicePoint.y; + break; + } + + if (winDeviceBounds.Contains(devicePoint)) + { + pTopWindow = pWindow; + break; + } + } + } +#endif + + if (pTopWindow != null) + { + Point winPos(0, 0); + +#if !defined(MULTI_WINDOW) + _Frame* pFrame = dynamic_cast<_Frame*>(pTopWindow); + if (pFrame) + { + winPos = pFrame->GetPosition(); + } + + Point relPos(point.x - winPos.x, point.y - winPos.y); + pControl = GetRoot().GetTopmostChildAt(relPos); +#else + winPos = pTopWindow->GetPosition(); + + Point relPos(point.x - winPos.x, point.y - winPos.y); + pControl = pTopWindow->GetTopmostChildAt(relPos); +#endif + if (pControl != null) + { + if (pControl->GetRootWindow() == pTopWindow) + { + return pControl; + } + } + } + + return null; +} + +// [review] rename __InvXformer +Dimension +_ControlManager::GetScreenSize(void) const +{ + return _CoordinateSystemUtils::InverseTransform(Dimension(_Screen::GetWidth(), _Screen::GetHeight())); +} + +_Window* +_ControlManager::GetCurrentFrame(void) const +{ + return __pCurrentFrame; +} + +result +_ControlManager::SetDefaultFont(const String& appFontName) +{ + + if(appFontName.Equals(__defaultFontName)) + { + return E_SUCCESS; + } + + __isDefaultFontChanged = true; + __defaultFontName = appFontName; + + struct _Visitor + : public _Control::Visitor + { + virtual _Control::VisitType Visit(_Control& control) + { + if (control.__fontName.IsEmpty()) + { + control.GetFallbackFont(); + _IControlDelegate& delegate = control.GetControlDelegate(); + delegate.OnFontChanged(control.__pFont); + } + return _Control::VISIT_DOWNWARD; + } + }; + + _Visitor visitor; + +#if !defined(MULTI_WINDOW) + _Control& control = GetRoot(); + control.Accept(visitor); +#else + int count = GetWindowCount(); + + for (int j = 0; j < count; j++) + { + _Window* pWindow = GetWindow((count-1) - j); + pWindow->Accept(visitor); + } +#endif + + SetDefaultFontChangeState(false); + + return E_SUCCESS; +} + +Tizen::Base::String +_ControlManager::GetDefaultFont(void) +{ + return __defaultFontName; +} + +bool +_ControlManager::IsDefaultFontChanged(void) +{ + return __isDefaultFontChanged; +} + +void +_ControlManager::SetDefaultFontChangeState(bool isDefaultFontChanged) +{ + __isDefaultFontChanged = isDefaultFontChanged; +} + +bool +_ControlManager::IsFrameActivated(void) const +{ + _Frame* pFrame = dynamic_cast<_Frame*>(__pCurrentFrame); + SysTryReturn(NID_UI, pFrame, false, E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + return pFrame->IsActivated(); +} + +// [review] refactoring +result +_ControlManager::AddGestureDetector(const _TouchGestureDetector& gesture) +{ + ClearLastResult(); + + SysTryReturn(NID_UI, __pGestureList != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + bool exist = __pGestureList->Contains(const_cast<_TouchGestureDetector*>(&gesture)); + SysTryReturnResult(NID_UI, exist == false, E_OBJ_ALREADY_EXIST, "[E_OBJ_ALREADY_EXIST]__pGestureList has gesture already"); + + result r = __pGestureList->Add(const_cast<_TouchGestureDetector*>(&gesture)); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + switch (gesture.GetDetectorType()) + { + case _TOUCH_GESTURE_DETECTOR_TYPE_TAP: + { + _TouchTapGestureDetector* pGestureTap = dynamic_cast<_TouchTapGestureDetector*>(const_cast<_TouchGestureDetector*>(&gesture)); + SysTryReturnResult(NID_UI, pGestureTap, E_SYSTEM, "[E_SYSTEM]system error occurred."); + + if (pGestureTap->GetTapInterval() > __gestureMaxDuration) + { + __gestureMaxDuration = pGestureTap->GetTapInterval(); + } + } + break; + case _TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS: + { + _TouchLongPressGestureDetector* pGestureLongPress= dynamic_cast<_TouchLongPressGestureDetector*>(const_cast<_TouchGestureDetector*>(&gesture)); + SysTryReturnResult(NID_UI, pGestureLongPress, E_SYSTEM, "[E_SYSTEM]system error occurred."); + + if (pGestureLongPress->GetDuration() > __gestureMaxDuration) + { + __gestureMaxDuration = pGestureLongPress->GetDuration(); + } + } + break; + default: + break; + } + + return E_SUCCESS; +} + +result +_ControlManager::RemoveGestureDetector(const _TouchGestureDetector& gesture) +{ + ClearLastResult(); + + result r = __pGestureList->Remove(&(const_cast<_TouchGestureDetector&>(gesture))); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +IListT <_TouchGestureDetector*>* +_ControlManager::GetGestureDetectorList(void) const +{ + return __pGestureList; +} + +int +_ControlManager::GetGestureMaxTimeDuration(void) const +{ + return __gestureMaxDuration; +} + +void +_ControlManager::OnSettingChanged(Tizen::Base::String& key) +{ + const wchar_t* FONT_TYPE = L"http://tizen.org/setting/font.type"; + const wchar_t* LOCALE_COUNTRY = L"http://tizen.org/setting/locale.country"; + const wchar_t* LOCALE_LANGUAGE = L"http://tizen.org/setting/locale.language"; + + if (key == FONT_TYPE || key == LOCALE_COUNTRY || key == LOCALE_LANGUAGE) + { + _FontImpl::UpdateDefaultFont(key); + + int count = GetWindowCount(); + + for(int index = 0; index < count ; index++) + { + _Window* pWindow = GetWindow(index); + pWindow->Invalidate(true); + } + } +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_CoordinateSystemUtils.cpp b/src/ui/FUi_CoordinateSystemUtils.cpp new file mode 100644 index 0000000..da02022 --- /dev/null +++ b/src/ui/FUi_CoordinateSystemUtils.cpp @@ -0,0 +1,141 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_CoordinateSystemUtils.cpp + * @brief This file contains implementation of _CoordinateSystemUtils class + * + * This file contains implementation _CoordinateSystemUtils class. + */ + +#include +#include +#include "FUi_CoordinateSystemUtils.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { + +_CoordinateSystem* _CoordinateSystemUtils::__pCoordinateSystemInstance = null; + +_ICoordinateSystemTransformer* +_CoordinateSystemUtils::GetTransformer(void) +{ + if (__pCoordinateSystemInstance == null) + { + __pCoordinateSystemInstance = _CoordinateSystem::GetInstance(); + SysTryReturn(NID_UI, __pCoordinateSystemInstance, null, E_SYSTEM, "[E_SYSTEM] Coordinate system instance must not be null."); + } + + _ICoordinateSystemTransformer* pTransform = __pCoordinateSystemInstance->GetTransformer(); + SysTryReturn(NID_UI, pTransform, null, E_SYSTEM, "[E_SYSTEM] The valid coordinate transformer does not exist."); + + return pTransform; +} + +_ICoordinateSystemTransformer* +_CoordinateSystemUtils::GetInverseTransformer(void) +{ + if (__pCoordinateSystemInstance == null) + { + __pCoordinateSystemInstance = _CoordinateSystem::GetInstance(); + SysTryReturn(NID_UI, __pCoordinateSystemInstance, null, E_SYSTEM, "[E_SYSTEM] Coordinate system instance must not be null."); + } + + _ICoordinateSystemTransformer* pInverseTransform= __pCoordinateSystemInstance->GetInverseTransformer(); + SysTryReturn(NID_UI, pInverseTransform, null, E_SYSTEM, "[E_SYSTEM] The valid coordinate inverse transformer does not exist."); + + return pInverseTransform; +} + + +// Transform Utilities +Rectangle +_CoordinateSystemUtils::Transform(const Rectangle& rect) +{ + return GetTransformer()->Transform(rect); +} + +Rectangle +_CoordinateSystemUtils::Transform(const Point& point, const Dimension& dim) +{ + return GetTransformer()->Transform(Rectangle(point, dim)); +} + +Dimension +_CoordinateSystemUtils::Transform(const Dimension& dim) +{ + return GetTransformer()->Transform(dim); +} + +Point +_CoordinateSystemUtils::Transform(const Point& point) +{ + return GetTransformer()->Transform(point); +} + +int +_CoordinateSystemUtils::HorizontalTransform(int scalar) +{ + return GetTransformer()->TransformHorizontal(scalar); +} + +int +_CoordinateSystemUtils::VerticalTransform(int scalar) +{ + return GetTransformer()->TransformVertical(scalar); +} + + +// InverseTransform Utilities +Rectangle +_CoordinateSystemUtils::InverseTransform(const Rectangle& rect) +{ + return GetInverseTransformer()->Transform(rect); +} + +Rectangle +_CoordinateSystemUtils::InverseTransform(const Point& point, const Dimension& dim) +{ + return GetInverseTransformer()->Transform(Rectangle(point, dim)); +} + +Dimension +_CoordinateSystemUtils::InverseTransform(const Dimension& dim) +{ + return GetInverseTransformer()->Transform(dim); +} + +Point +_CoordinateSystemUtils::InverseTransform(const Point& point) +{ + return GetInverseTransformer()->Transform(point); +} + +int +_CoordinateSystemUtils::InverseHorizontalTransform(int scalar) +{ + return GetInverseTransformer()->TransformHorizontal(scalar); +} + +int +_CoordinateSystemUtils::InverseVerticalTransform(int scalar) +{ + return GetInverseTransformer()->TransformVertical(scalar); +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_CustomControlBaseImpl.cpp b/src/ui/FUi_CustomControlBaseImpl.cpp new file mode 100644 index 0000000..23d6c5a --- /dev/null +++ b/src/ui/FUi_CustomControlBaseImpl.cpp @@ -0,0 +1,132 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_CustomControlBaseImpl.cpp + * @brief This is the implementation for the _CustomControlBaseImpl class and default transformer. + */ + +#include +#include "FUi_LayoutImpl.h" +#include "FUi_CustomControlBaseImpl.h" +#include "FUi_Control.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +_CustomControlBaseImpl::~_CustomControlBaseImpl(void) +{ +} + +_CustomControlBaseImpl* +_CustomControlBaseImpl::CreateCustomControlBaseImplN(CustomControlBase* pPublic, const Rectangle& bounds, + const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, + bool resizable, bool movable) +{ + result r = E_SUCCESS; + + _Control* pCore = _Control::CreateControlN(); + SysTryReturn(NID_UI, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + _CustomControlBaseImpl* pImpl = + new (std::nothrow) _CustomControlBaseImpl(pPublic, pCore, bounds, + pPublicPortraitLayout, pPublicLandscapeLayout, + resizable, movable); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + ClearLastResult(); + + return pImpl; +} + +_CustomControlBaseImpl::_CustomControlBaseImpl(CustomControlBase* pCustomControlBase, _Control* pCore, const Rectangle& bounds, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, bool resizable, bool movable) + : _ContainerImpl(pCustomControlBase, pCore, pPublicPortraitLayout, pPublicLandscapeLayout) +{ + result r = E_SUCCESS; + + r = GetLastResult(); + if (IsFailed(r)) + { + return; + } + + bool allOrNone = (pPublicPortraitLayout && pPublicLandscapeLayout) || (!pPublicPortraitLayout && !pPublicLandscapeLayout); + SysAssert(allOrNone); + + r = SetBounds(bounds); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCore->SetResizable(resizable); + pCore->SetMovable(movable); +} + +const char* +_CustomControlBaseImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::CustomControlBase"; +} + +const CustomControlBase& +_CustomControlBaseImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +CustomControlBase& +_CustomControlBaseImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +_CustomControlBaseImpl* +_CustomControlBaseImpl::GetInstance(CustomControlBase& pCustomControlBase) +{ + return static_cast<_CustomControlBaseImpl*>(pCustomControlBase._pControlImpl); +} + +const _CustomControlBaseImpl* +_CustomControlBaseImpl::GetInstance(const CustomControlBase& pCustomControlBase) +{ + return static_cast(pCustomControlBase._pControlImpl); + +} + + +result +_CustomControlBaseImpl::OnBoundsChanging(const Rectangle& bounds) +{ + __oldBounds = GetBounds(); + return GetPublic().PrepareBoundsChange(__oldBounds, bounds); +} + +void +_CustomControlBaseImpl::OnBoundsChanged(void) +{ + GetPublic().OnBoundsChanged(__oldBounds, GetBounds()); +} + +void +_CustomControlBaseImpl::OnEvaluateSize(Dimension& evaluatedSize) +{ + GetPublic().EvaluateSize(evaluatedSize.width, evaluatedSize.height); +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_DataBinding.cpp b/src/ui/FUi_DataBinding.cpp new file mode 100644 index 0000000..0c6760f --- /dev/null +++ b/src/ui/FUi_DataBinding.cpp @@ -0,0 +1,1442 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_DataBinding.cpp + * @brief This is the implementation for the _DataBinding class and default transformer. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_Control.h" +#include "FUi_IPropertyChangeEventListener.h" +#include "FUi_PropertyBase.h" +#include "FUi_DataBinding.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace +{ +using namespace Tizen::Ui; + +class _DefaultTransformer + : public Object + , public IDataBindingDataTransformer +{ +public: + virtual ~_DefaultTransformer(void); +public: + virtual bool TransformSourceToTarget(const Tizen::Base::String& bindingId, DataBindingDataType sourceType, const Tizen::Base::Object& sourceData, DataBindingDataType targetType, Tizen::Base::Object& targetData); + virtual bool TransformTargetToSource(const Tizen::Base::String& bindingId, DataBindingDataType targetType, const Tizen::Base::Object& targetData, DataBindingDataType sourceType, Tizen::Base::Object& sourceData); + virtual bool IsSourceToTargetTransformable(const Tizen::Base::String& bindingId, DataBindingDataType sourceType, DataBindingDataType targetType); + virtual bool IsTargetToSourceTransformable(const Tizen::Base::String& bindingId, DataBindingDataType targetType, DataBindingDataType sourceType); +private: + bool Transform(DataBindingDataType sourceType, const Tizen::Base::Object& sourceData, DataBindingDataType targetType, Tizen::Base::Object& destinationData); + bool IsTransformable(DataBindingDataType destinationType, DataBindingDataType sourceType); +}; + +_DefaultTransformer::~_DefaultTransformer(void) +{ +} +bool +_DefaultTransformer::TransformSourceToTarget(const Tizen::Base::String& bindingId, DataBindingDataType sourceType, const Tizen::Base::Object& sourceData, DataBindingDataType targetType, Tizen::Base::Object& targetData) +{ + return Transform(sourceType, sourceData, targetType, targetData); +} +bool +_DefaultTransformer::TransformTargetToSource(const Tizen::Base::String& bindingId, DataBindingDataType targetType, const Tizen::Base::Object& targetData, DataBindingDataType sourceType, Tizen::Base::Object& sourceData) +{ + return Transform(targetType, targetData, sourceType, sourceData); +} +bool +_DefaultTransformer::IsSourceToTargetTransformable(const Tizen::Base::String& bindingId, DataBindingDataType sourceType, DataBindingDataType targetType) +{ + return IsTransformable(sourceType, targetType); +} +bool +_DefaultTransformer::IsTargetToSourceTransformable(const Tizen::Base::String& bindingId, DataBindingDataType targetType, DataBindingDataType sourceType) +{ + return IsTransformable(targetType, sourceType); +} + +bool +_DefaultTransformer::Transform(DataBindingDataType sourceType, const Tizen::Base::Object& sourceData, DataBindingDataType destinationType, Tizen::Base::Object& destinationData) +{ + result r = E_SUCCESS; + + switch (destinationType) + { + case DATA_BINDING_DATA_TYPE_INTEGER: + switch (sourceType) // INTEGER from BOOLEAN, DOUBLE, FLOAT, INTEGER, LONG, STRING + { + case DATA_BINDING_DATA_TYPE_BOOLEAN: + { + Tizen::Base::Integer* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToBool()?1:0; + return true; + } + + case DATA_BINDING_DATA_TYPE_FLOAT: + { + Tizen::Base::Integer* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToInt(); + return true; + } + case DATA_BINDING_DATA_TYPE_INTEGER: + { + Tizen::Base::Integer* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToInt(); + return true; + } + + case DATA_BINDING_DATA_TYPE_LONG: + { + Tizen::Base::Integer* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToInt(); + return true; + } + + case DATA_BINDING_DATA_TYPE_COLOR: + { + Tizen::Base::Integer* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).GetRGB32(); + return true; + } + + default: + return false; + } + + case DATA_BINDING_DATA_TYPE_FLOAT: + switch (sourceType) // FLOAT from DOUBLE, FLOAT, INTEGER, LONG, STRING + { + case DATA_BINDING_DATA_TYPE_BOOLEAN: + { + Tizen::Base::Float* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToBool() ? 1.0 : 0.0; + return true; + } + case DATA_BINDING_DATA_TYPE_FLOAT: + { + Tizen::Base::Float* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToFloat(); + return true; + } + + case DATA_BINDING_DATA_TYPE_INTEGER: + { + Tizen::Base::Float* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToFloat(); + return true; + } + case DATA_BINDING_DATA_TYPE_LONG: + { + Tizen::Base::Float* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToFloat(); + return true; + } + default: + return false; + } + + case DATA_BINDING_DATA_TYPE_DOUBLE: + switch (sourceType) // DOUBLE from DOUBLE, FLOAT, INTEGER, LONG, STRING + { + case DATA_BINDING_DATA_TYPE_DOUBLE: + { + Tizen::Base::Double* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToDouble(); + return true; + } + case DATA_BINDING_DATA_TYPE_FLOAT: + { + Tizen::Base::Double* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToDouble(); + return true; + } + case DATA_BINDING_DATA_TYPE_INTEGER: + { + Tizen::Base::Double* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToDouble(); + return true; + } + case DATA_BINDING_DATA_TYPE_LONG: + { + Tizen::Base::Double* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToDouble(); + return true; + } + case DATA_BINDING_DATA_TYPE_BOOLEAN: + { + Tizen::Base::Double* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToBool() ? 1.0 : 0.0; + return true; + } + default: + return false; + } + + case DATA_BINDING_DATA_TYPE_LONG: + switch (sourceType) // LONG from DOUBLE, FLOAT, INTEGER, LONG, STRING + { + case DATA_BINDING_DATA_TYPE_FLOAT: + { + Tizen::Base::Long* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToLong(); + return true; + } + case DATA_BINDING_DATA_TYPE_INTEGER: + { + Tizen::Base::Long* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToLong(); + return true; + } + case DATA_BINDING_DATA_TYPE_LONG: + { + Tizen::Base::Long* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToLong(); + return true; + } + case DATA_BINDING_DATA_TYPE_BOOLEAN: + { + Tizen::Base::Long* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->value = static_cast(const_cast(sourceData)).ToBool() ? 1 : 0; + return true; + } + default: + return false; + } + + case DATA_BINDING_DATA_TYPE_STRING: + switch (sourceType) // STRING from DOUBLE, FLOAT, INTEGER, LONG, STRING + { + case DATA_BINDING_DATA_TYPE_DOUBLE: + { + Tizen::Base::String* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + *pTarget = static_cast(const_cast(sourceData)).ToString(); + return true; + } + + case DATA_BINDING_DATA_TYPE_FLOAT: + { + Tizen::Base::String* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + *pTarget = static_cast(const_cast(sourceData)).ToString(); + return true; + } + + case DATA_BINDING_DATA_TYPE_INTEGER: + { + Tizen::Base::String* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + *pTarget = static_cast(const_cast(sourceData)).ToString(); + return true; + } + + case DATA_BINDING_DATA_TYPE_LONG: + { + Tizen::Base::String* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + *pTarget = static_cast(const_cast(sourceData)).ToString(); + return true; + } + + case DATA_BINDING_DATA_TYPE_STRING: + { + Tizen::Base::String* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + *pTarget = static_cast(const_cast(sourceData)); + return true; + } + case DATA_BINDING_DATA_TYPE_BOOLEAN: + { + Tizen::Base::String* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + *pTarget = static_cast(const_cast(sourceData)).ToString(); + return true; + } + + case DATA_BINDING_DATA_TYPE_COLOR: + { + Tizen::Base::String* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->Clear(); + r= pTarget->Append(L"#"); + if(r != E_SUCCESS) + { + return false; + } + wchar_t tempString[] = L"XXXXXXXX"; + swprintf(tempString, (sizeof(tempString) / sizeof(wchar_t)), L"%X",static_cast(const_cast(sourceData)).GetRGB32()); + r= pTarget->Append(tempString); + if(r != E_SUCCESS) + { + return false; + } + return true; + } + + case DATA_BINDING_DATA_TYPE_DIMENSION: + { + Tizen::Base::String* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->Clear(); + + String* pString = new (std::nothrow) String(L""); + SysTryReturn(NID_UI, pString, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + + Dimension* pDimension = &static_cast(const_cast(sourceData)); + r = pString->Append(L"width:"); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + r = pString->Append(pDimension->width); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + r = pString->Append(L", height:"); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + r = pString->Append(pDimension->height); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + *pTarget = *pString; + delete pString; + return true; + } + + case DATA_BINDING_DATA_TYPE_POINT: + { + Tizen::Base::String* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->Clear(); + + String* pString = new (std::nothrow) String(L""); + SysTryReturn(NID_UI, pString, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + + Point* pPoint = &static_cast(const_cast(sourceData)); + r = pString->Append(L"x:"); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + r = pString->Append(pPoint->x); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + r = pString->Append(L", y:"); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + r = pString->Append(pPoint->y); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + *pTarget = *pString; + delete pString; + return true; + } + + case DATA_BINDING_DATA_TYPE_RECTANGLE: + { + Tizen::Base::String* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->Clear(); + + String* pString = new (std::nothrow) String(L""); + SysTryReturn(NID_UI, pString, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + + Rectangle* pRectangle = &static_cast(const_cast(sourceData)); + r = pString->Append(L"x:"); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + r = pString->Append(pRectangle->x); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + r = pString->Append(L", y:"); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + r = pString->Append(pRectangle->y); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + + r = pString->Append(L", width:"); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + r = pString->Append(pRectangle->width); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + + r = pString->Append(L", height:"); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + r = pString->Append(pRectangle->height); + if(r != E_SUCCESS) + { + delete pString; + return false; + } + *pTarget = *pString; + delete pString; + return true; + } + default: + return false; + } + + case DATA_BINDING_DATA_TYPE_COLOR: + if (sourceType == DATA_BINDING_DATA_TYPE_COLOR) + { + Color* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + *pTarget = static_cast(const_cast(sourceData)); + return true; + } + else if (sourceType == DATA_BINDING_DATA_TYPE_INTEGER) + { + Color* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + *pTarget = static_cast(const_cast(sourceData)).ToInt(); + return true; + } + else + { + return false; + } + + case DATA_BINDING_DATA_TYPE_POINT: + if (sourceType == DATA_BINDING_DATA_TYPE_POINT) + { + Point* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->SetPosition(static_cast(const_cast(sourceData)).x, static_cast(const_cast(sourceData)).y); + return true; + } + else if (sourceType == DATA_BINDING_DATA_TYPE_RECTANGLE) + { + Point* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->SetPosition(static_cast(const_cast(sourceData)).x, static_cast(const_cast(sourceData)).y); + return true; + } + else + { + return false; + } + + case DATA_BINDING_DATA_TYPE_RECTANGLE: + if (sourceType == DATA_BINDING_DATA_TYPE_RECTANGLE) + { + Rectangle* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->SetBounds(static_cast(const_cast(sourceData)).x, static_cast(const_cast(sourceData)).y, static_cast(const_cast(sourceData)).width, static_cast(const_cast(sourceData)).height); + return true; + } + else + { + return false; + } + + case DATA_BINDING_DATA_TYPE_DIMENSION: + if (sourceType == DATA_BINDING_DATA_TYPE_DIMENSION) + { + Dimension* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->SetSize(static_cast(const_cast(sourceData)).width, static_cast(const_cast(sourceData)).height); + return true; + } + else if (sourceType == DATA_BINDING_DATA_TYPE_RECTANGLE) + { + Dimension* pTarget = dynamic_cast(&destinationData); + if(!pTarget) + { + return false; + } + pTarget->SetSize(static_cast(const_cast(sourceData)).width, static_cast(const_cast(sourceData)).height); + return true; + } + else + { + return false; + } + + default: + return false; + } +} +bool +_DefaultTransformer::IsTransformable(DataBindingDataType sourceType, DataBindingDataType destinationType) +{ + bool returnValue = false; + + switch (destinationType) + { + case DATA_BINDING_DATA_TYPE_INTEGER: + switch (sourceType) // INTEGER from BOOLEAN, DOUBLE, FLOAT, INTEGER, LONG, STRING + { + case DATA_BINDING_DATA_TYPE_BOOLEAN: + //fall through + case DATA_BINDING_DATA_TYPE_FLOAT: + //fall through + case DATA_BINDING_DATA_TYPE_INTEGER: + //fall through + case DATA_BINDING_DATA_TYPE_LONG: + //fall through + case DATA_BINDING_DATA_TYPE_COLOR: + returnValue = true; + break; + default: + break; + } + break; + + case DATA_BINDING_DATA_TYPE_FLOAT: + switch (sourceType) // FLOAT from DOUBLE, FLOAT, INTEGER, LONG, STRING + { + case DATA_BINDING_DATA_TYPE_BOOLEAN: + //fall through + case DATA_BINDING_DATA_TYPE_FLOAT: + //fall through + case DATA_BINDING_DATA_TYPE_INTEGER: + //fall through + case DATA_BINDING_DATA_TYPE_LONG: + returnValue = true; + break; + default: + break; + } + break; + + case DATA_BINDING_DATA_TYPE_DOUBLE: + switch (sourceType) // DOUBLE from DOUBLE, FLOAT, INTEGER, LONG, STRING + { + case DATA_BINDING_DATA_TYPE_DOUBLE: + //fall through + case DATA_BINDING_DATA_TYPE_FLOAT: + //fall through + case DATA_BINDING_DATA_TYPE_INTEGER: + //fall through + case DATA_BINDING_DATA_TYPE_LONG: + //fall through + case DATA_BINDING_DATA_TYPE_BOOLEAN: + returnValue = true; + break; + default: + break; + } + break; + + case DATA_BINDING_DATA_TYPE_LONG: + switch (sourceType) // LONG from DOUBLE, FLOAT, INTEGER, LONG, STRING + { + case DATA_BINDING_DATA_TYPE_BOOLEAN: + //fall through + case DATA_BINDING_DATA_TYPE_FLOAT: + //fall through + case DATA_BINDING_DATA_TYPE_INTEGER: + //fall through + case DATA_BINDING_DATA_TYPE_LONG: + returnValue = true; + break; + default: + break; + } + break; + + case DATA_BINDING_DATA_TYPE_STRING: + switch (sourceType) // STRING from all type + { + case DATA_BINDING_DATA_TYPE_BOOLEAN: + //fall through + case DATA_BINDING_DATA_TYPE_COLOR: + //fall through + case DATA_BINDING_DATA_TYPE_DIMENSION: + //fall through + case DATA_BINDING_DATA_TYPE_DOUBLE: + //fall through + case DATA_BINDING_DATA_TYPE_FLOAT: + //fall through + case DATA_BINDING_DATA_TYPE_INTEGER: + //fall through + case DATA_BINDING_DATA_TYPE_LONG: + //fall through + case DATA_BINDING_DATA_TYPE_POINT: + //fall through + case DATA_BINDING_DATA_TYPE_RECTANGLE: + //fall through + case DATA_BINDING_DATA_TYPE_STRING: + returnValue = true; + break; + default: + break; + } + break; + + case DATA_BINDING_DATA_TYPE_COLOR: + switch (sourceType) // COLOR from INTEGER, COLOR + { + case DATA_BINDING_DATA_TYPE_COLOR: + //fall through + case DATA_BINDING_DATA_TYPE_INTEGER: + returnValue = true; + break; + default: + break; + } + break; + + case DATA_BINDING_DATA_TYPE_POINT: + switch (sourceType) // POINT from POINT, RECTANGLE + { + case DATA_BINDING_DATA_TYPE_POINT: + //fall through + case DATA_BINDING_DATA_TYPE_RECTANGLE: + returnValue = true; + break; + + default: + break; + } + break; + + case DATA_BINDING_DATA_TYPE_RECTANGLE: + if (sourceType == DATA_BINDING_DATA_TYPE_RECTANGLE) + returnValue = true; + break; + case DATA_BINDING_DATA_TYPE_DIMENSION: + switch (sourceType) // POINT from POINT, RECTANGLE + { + case DATA_BINDING_DATA_TYPE_DIMENSION: + //fall through + case DATA_BINDING_DATA_TYPE_RECTANGLE: + returnValue = true; + break; + default: + break; + } + break; + default: + break; + } + return returnValue; +} + + +bool +IsTypeSupported(VariantType variantType) +{ + bool returnValue = false; + + switch (variantType) + { + case VARIANT_TYPE_INT: + //fall through + case VARIANT_TYPE_BOOL: + //fall through + case VARIANT_TYPE_FLOAT: + //fall through + case VARIANT_TYPE_DOUBLE: + //fall through + case VARIANT_TYPE_LONG: + //fall through + case VARIANT_TYPE_STRING: + //fall through + case VARIANT_TYPE_COLOR: + //fall through + case VARIANT_TYPE_POINT: + //fall through + case VARIANT_TYPE_RECTANGLE: + //fall through + case VARIANT_TYPE_DIMENSION: + returnValue = true; + break; + default: + break; + } + return returnValue; +} +DataBindingDataType +ConvertVariantTypeToDataBindingDataType(VariantType variantType) +{ + DataBindingDataType dataType = DATA_BINDING_DATA_TYPE_BOOLEAN; + + switch (variantType) + { + case VARIANT_TYPE_INT: + dataType = DATA_BINDING_DATA_TYPE_INTEGER; + break; + + case VARIANT_TYPE_BOOL: + dataType = DATA_BINDING_DATA_TYPE_BOOLEAN; + break; + + case VARIANT_TYPE_FLOAT: + dataType = DATA_BINDING_DATA_TYPE_FLOAT; + break; + + case VARIANT_TYPE_DOUBLE: + dataType = DATA_BINDING_DATA_TYPE_DOUBLE; + break; + + case VARIANT_TYPE_LONG: + dataType = DATA_BINDING_DATA_TYPE_LONG; + break; + + case VARIANT_TYPE_STRING: + dataType = DATA_BINDING_DATA_TYPE_STRING; + break; + + case VARIANT_TYPE_COLOR: + dataType = DATA_BINDING_DATA_TYPE_COLOR; + break; + + case VARIANT_TYPE_POINT: + dataType = DATA_BINDING_DATA_TYPE_POINT; + break; + + case VARIANT_TYPE_RECTANGLE: + dataType = DATA_BINDING_DATA_TYPE_RECTANGLE; + break; + + case VARIANT_TYPE_DIMENSION: + dataType = DATA_BINDING_DATA_TYPE_DIMENSION; + break; + default: + SysAssertf(0, "Not Support Type"); + break; + } + return dataType; +} + +VariantType +ConvertDataBindingDataTypeToVariantType(DataBindingDataType dataType) +{ + VariantType variantType = VARIANT_TYPE_NONE; + switch (dataType) + { + case DATA_BINDING_DATA_TYPE_BOOLEAN: + variantType = VARIANT_TYPE_BOOL; + break; + + case DATA_BINDING_DATA_TYPE_COLOR: + variantType = VARIANT_TYPE_COLOR; + break; + + case DATA_BINDING_DATA_TYPE_DIMENSION: + variantType = VARIANT_TYPE_DIMENSION; + break; + + case DATA_BINDING_DATA_TYPE_DOUBLE: + variantType = VARIANT_TYPE_DOUBLE; + break; + + case DATA_BINDING_DATA_TYPE_FLOAT: + variantType = VARIANT_TYPE_FLOAT; + break; + + case DATA_BINDING_DATA_TYPE_INTEGER: + variantType = VARIANT_TYPE_INT; + break; + + case DATA_BINDING_DATA_TYPE_LONG: + variantType = VARIANT_TYPE_LONG; + break; + + case DATA_BINDING_DATA_TYPE_POINT: + variantType = VARIANT_TYPE_POINT; + break; + + case DATA_BINDING_DATA_TYPE_RECTANGLE: + variantType = VARIANT_TYPE_RECTANGLE; + break; + + case DATA_BINDING_DATA_TYPE_STRING: + variantType = VARIANT_TYPE_STRING; + break; + + default: + break; + } + return variantType; +} + + +class _DataBindingPropertyChangeEventListner + : public _IPropertyChangeEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + _DataBindingPropertyChangeEventListner(const _DataBinding& dataBinding) + { + __pDataBinding = &const_cast<_DataBinding&>(dataBinding); + }; + virtual ~_DataBindingPropertyChangeEventListner(void){}; + virtual void OnPropertyChanging(_PropertyBase& source, const String& name, const Variant& oldValue, const Variant& newValue){}; + virtual void OnPropertyChanged(_PropertyBase& source, const String& name, const Variant& oldValue, const Variant& newValue) + { + const Variant variant = source.GetProperty(name); + if (variant.IsEmpty() || oldValue == newValue) + { + return; + } + if (name == __pDataBinding->GetPropertyName()) + { + __pDataBinding->Update(DATA_BINDING_DESTINATION_TYPE_SOURCE); + } + }; +private: + _DataBinding* __pDataBinding; +}; //class _DataBindingPropertyChangeEventListner + +_DefaultTransformer defaultTransformer; +} +namespace Tizen { namespace Ui +{ +_DataBinding::_DataBinding(void) + : __controlHandle() + , __bindingId(L"") + , __propertyName(L"") + , __pDataSource(null) + , __sourceType(DATA_BINDING_DATA_TYPE_BOOLEAN) + , __targetType(DATA_BINDING_DATA_TYPE_BOOLEAN) + , __flow(DATA_BINDING_FLOW_ONE_WAY) + , __trigger(DATA_BINDING_TRIGGER_EXPLICIT) + , __pListener(null) + , __pValidator(null) + , __pTransformer(null) + , __pPropertyChangeEventListener(null) +{ +} +_DataBinding::~_DataBinding(void) +{ + delete __pPropertyChangeEventListener; + __pPropertyChangeEventListener = null; +} + +result +_DataBinding::Construct(const _Control& control, const String& bindingId, const String& propertyName + , Object& dataSource, DataBindingDataType sourceType, DataBindingFlow flow, DataBindingTrigger trigger + , const IDataBindingListener* pListener, const IDataBindingDataValidator* pValidator, const IDataBindingDataTransformer* pTransformer) +{ + __controlHandle = control.GetHandle(); + _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle); + SysTryReturn(NID_UI, pControl, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The control that was binded is gone."); + __propertyName = propertyName; + __pDataSource = &dataSource; + __sourceType = sourceType; + __flow = flow; + __trigger = trigger; + __pListener = const_cast(pListener); + __pValidator = const_cast(pValidator); + + if (pTransformer != null) + __pTransformer = const_cast(pTransformer); + else + __pTransformer = &::defaultTransformer; + + Variant variant = pControl->GetProperty(propertyName); + + SysTryReturn(NID_UI, GetLastResult() != E_KEY_NOT_FOUND, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Property is not found."); + + SysTryReturn(NID_UI, ::IsTypeSupported(variant.GetType()), E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT + , "[E_UNSUPPORTED_FORMAT] Property type is unsupported type."); + + __targetType = ::ConvertVariantTypeToDataBindingDataType(variant.GetType()); + + switch(__flow) + { + case DATA_BINDING_FLOW_ONE_WAY: + SysTryReturn(NID_UI, __pTransformer->IsSourceToTargetTransformable(bindingId, __sourceType, __targetType) + , E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] transformer can not transform source type to target type."); + break; + case DATA_BINDING_FLOW_ONE_WAY_TO_SOURCE: + SysTryReturn(NID_UI, __pTransformer->IsTargetToSourceTransformable(bindingId, __targetType, __sourceType) + , E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] transformer can not transform target type to source type."); + break; + case DATA_BINDING_FLOW_TWO_WAY: + SysTryReturn(NID_UI, __pTransformer->IsSourceToTargetTransformable(bindingId, __sourceType, __targetType) + && __pTransformer->IsTargetToSourceTransformable(bindingId, __targetType, __sourceType) + , E_UNSUPPORTED_FORMAT, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] transformer can not transform both target type and source type."); + break; + default: + SysAssert(0); + } + + if (trigger == DATA_BINDING_TRIGGER_IMMEDIATE) + { + __pPropertyChangeEventListener = new (std::nothrow) ::_DataBindingPropertyChangeEventListner(*this); + SysTryReturn(NID_UI, __pPropertyChangeEventListener, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pControl->AddPropertyChangeEventListener(*__pPropertyChangeEventListener); + } + return E_SUCCESS; +} + +result +_DataBinding::Update(DataBindingDestinationType destinationType) +{ + bool valid = true; + Object* pTransformedObject = null; + result r = E_SYSTEM; + Object* pOriginObject = null; + _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle); + SysTryCatch(NID_UI, pControl, , E_SYSTEM, "[E_SYSTEM] The control that was binded is gone."); + + if (destinationType == DATA_BINDING_DESTINATION_TYPE_SOURCE) + { + DataBindingDataType originType = __targetType; + Variant variant = pControl->GetProperty(__propertyName); + DataBindingDataType transformedType = __sourceType; + + switch (variant.GetType()) + { + case VARIANT_TYPE_INT: + pOriginObject = new (std::nothrow) Integer(variant.ToInt()); + SysTryReturn(NID_UI, pOriginObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + + case VARIANT_TYPE_BOOL: + pOriginObject = new (std::nothrow) Boolean(variant.ToBool()); + SysTryReturn(NID_UI, pOriginObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + + case VARIANT_TYPE_FLOAT: + pOriginObject = new (std::nothrow) Float(variant.ToFloat()); + SysTryReturn(NID_UI, pOriginObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + + case VARIANT_TYPE_DOUBLE: + pOriginObject = new (std::nothrow) Double(variant.ToDouble()); + SysTryReturn(NID_UI, pOriginObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + + case VARIANT_TYPE_LONG: + pOriginObject = new (std::nothrow) Long(variant.ToLong()); + SysTryReturn(NID_UI, pOriginObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + + case VARIANT_TYPE_STRING: + pOriginObject = new (std::nothrow) String(variant.ToString()); + SysTryReturn(NID_UI, pOriginObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + + case VARIANT_TYPE_COLOR: + pOriginObject = new (std::nothrow) Color(variant.ToColor()); + SysTryReturn(NID_UI, pOriginObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + + case VARIANT_TYPE_POINT: + pOriginObject = new (std::nothrow) Point(variant.ToPoint().x, variant.ToPoint().y); + SysTryReturn(NID_UI, pOriginObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + + case VARIANT_TYPE_RECTANGLE: + pOriginObject = new (std::nothrow) Rectangle(variant.ToRectangle().x, variant.ToRectangle().y, variant.ToRectangle().width, variant.ToRectangle().height); + SysTryReturn(NID_UI, pOriginObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + + case VARIANT_TYPE_DIMENSION: + pOriginObject = new (std::nothrow) Dimension(variant.ToDimension().width, variant.ToDimension().height); + SysTryReturn(NID_UI, pOriginObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + default: + SysTryCatch(NID_UI, pControl, , E_SYSTEM, "[E_SYSTEM] The control that was binded is gone."); + } + + switch(__sourceType) + { + case DATA_BINDING_DATA_TYPE_BOOLEAN: + { + pTransformedObject = new (std::nothrow) Boolean(false); + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_COLOR: + { + pTransformedObject = new (std::nothrow) Color; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_DIMENSION: + { + pTransformedObject = new (std::nothrow) Dimension; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_DOUBLE: + { + pTransformedObject = new (std::nothrow) Double; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_FLOAT: + { + pTransformedObject = new (std::nothrow) Float; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_INTEGER: + { + pTransformedObject = new (std::nothrow) Integer; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_LONG: + { + pTransformedObject = new (std::nothrow) Long; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_POINT: + { + pTransformedObject = new (std::nothrow) Point; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_RECTANGLE: + { + pTransformedObject = new (std::nothrow) Rectangle; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_STRING: + { + pTransformedObject = new (std::nothrow) String; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + default: + SysTryCatch(NID_UI, false, , E_SYSTEM, "[E_SYSTEM] System Error"); + } + SysTryCatch(NID_UI, pTransformedObject, , E_SYSTEM, "[E_SYSTEM] data transfer is failed by memory shortage."); + SysTryCatch(NID_UI, __pTransformer->TransformTargetToSource(__bindingId, originType, *pOriginObject, transformedType, *pTransformedObject) == true, , E_SYSTEM, "[E_SYSTEM] data transfer is failed by transformer."); + + if (__pValidator != null) + { + valid = __pValidator->ValidateDataToSource(__bindingId, *pTransformedObject); + } + if (valid == false) + { + if (__pListener != null) + { + __pListener->OnDataBindingValidationFailed(__bindingId, pControl->GetName(), __propertyName, destinationType); + } + SysTryCatch(NID_UI, 0, , E_SYSTEM, "[E_SYSTEM] data transfer is failed by validator."); + } + + switch (variant.GetType()) + { + + case VARIANT_TYPE_INT: + static_cast(*__pDataSource) = static_cast(pTransformedObject)->ToInt(); + break; + + case VARIANT_TYPE_BOOL: + static_cast(*__pDataSource) = static_cast(pTransformedObject)->ToBool(); + break; + + case VARIANT_TYPE_FLOAT: + static_cast(*__pDataSource) = static_cast(pTransformedObject)->ToFloat(); + break; + + case VARIANT_TYPE_DOUBLE: + static_cast(*__pDataSource) = static_cast(pTransformedObject)->ToDouble(); + break; + + case VARIANT_TYPE_LONG: + static_cast(*__pDataSource) = static_cast(pTransformedObject)->ToLong(); + break; + + case VARIANT_TYPE_STRING: + static_cast(*__pDataSource) = static_cast(*pTransformedObject); + break; + + case VARIANT_TYPE_COLOR: + static_cast(*__pDataSource) = static_cast(*pTransformedObject); + break; + + case VARIANT_TYPE_POINT: + static_cast(__pDataSource)->SetPosition(static_cast(*pTransformedObject)); + break; + + case VARIANT_TYPE_RECTANGLE: + static_cast(__pDataSource)->SetBounds(static_cast(*pTransformedObject).x, static_cast(*pTransformedObject).y, static_cast(*pTransformedObject).width, static_cast(*pTransformedObject).height); + break; + + case VARIANT_TYPE_DIMENSION: + static_cast(__pDataSource)->SetSize(static_cast(*pTransformedObject).width, static_cast(*pTransformedObject).height); + break; + default: + break; + } + + if (__pListener != null) + { + __pListener->OnDataBindingSourceUpdated(__bindingId, pControl->GetName(), __propertyName); + } + r = E_SUCCESS; + } + else // DATA_BINDING_DESTINATION_TYPE_TARGET + { + DataBindingDataType originType = __sourceType; + Object* pOriginObject = __pDataSource; + DataBindingDataType transformedType = __targetType; + + switch(__targetType) + { + case DATA_BINDING_DATA_TYPE_BOOLEAN: + { + pTransformedObject = new (std::nothrow) Boolean(false); + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_COLOR: + { + pTransformedObject = new (std::nothrow) Color; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_DIMENSION: + { + pTransformedObject = new (std::nothrow) Dimension; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_DOUBLE: + { + pTransformedObject = new (std::nothrow) Double; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_FLOAT: + { + pTransformedObject = new (std::nothrow) Float; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_INTEGER: + { + pTransformedObject = new (std::nothrow) Integer; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_LONG: + { + pTransformedObject = new (std::nothrow) Long; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_POINT: + { + pTransformedObject = new (std::nothrow) Point; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_RECTANGLE: + { + pTransformedObject = new (std::nothrow) Rectangle; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + case DATA_BINDING_DATA_TYPE_STRING: + { + pTransformedObject = new (std::nothrow) String; + SysTryReturn(NID_UI, pTransformedObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + break; + } + default: + SysTryCatch(NID_UI, false, , E_SYSTEM, "[E_SYSTEM] System Error"); + } + SysTryCatch(NID_UI, pTransformedObject, , E_SYSTEM, "[E_SYSTEM] data transfer is failed by memory shortage."); + SysTryCatch(NID_UI, __pTransformer->TransformSourceToTarget(__bindingId, originType, *pOriginObject, transformedType, *pTransformedObject) == true, , E_SYSTEM, "[E_SYSTEM] data transfer is failed by transformer."); + + if (__pValidator != null) + { + valid = __pValidator->ValidateDataToTarget(__bindingId, *pTransformedObject); + } + if (valid == false) + { + if (__pListener != null) + { + __pListener->OnDataBindingValidationFailed(__bindingId, pControl->GetName(), __propertyName, destinationType); + } + SysTryCatch(NID_UI, 0, , E_SYSTEM, "[E_SYSTEM] data transfer is failed by validator."); + } + else + { + Variant variant; + switch (transformedType) + { + case DATA_BINDING_DATA_TYPE_BOOLEAN: + variant = static_cast(pTransformedObject)->ToBool(); + break; + + case DATA_BINDING_DATA_TYPE_COLOR: + variant = *static_cast(pTransformedObject); + break; + + case DATA_BINDING_DATA_TYPE_DIMENSION: + variant = *static_cast(pTransformedObject); + break; + + case DATA_BINDING_DATA_TYPE_DOUBLE: + variant = static_cast( pTransformedObject)->ToDouble(); + break; + + case DATA_BINDING_DATA_TYPE_FLOAT: + variant = static_cast(pTransformedObject)->ToFloat(); + break; + + case DATA_BINDING_DATA_TYPE_INTEGER: + variant = static_cast(pTransformedObject)->ToInt(); + break; + + case DATA_BINDING_DATA_TYPE_LONG: + variant = static_cast(pTransformedObject)->ToLong(); + break; + + case DATA_BINDING_DATA_TYPE_POINT: + variant = *static_cast(pTransformedObject); + break; + + case DATA_BINDING_DATA_TYPE_RECTANGLE: + variant = *static_cast(pTransformedObject); + break; + + case DATA_BINDING_DATA_TYPE_STRING: + variant = *static_cast(pTransformedObject); + break; + + default: + goto CATCH; + } + pControl->SetProperty(__propertyName, variant); + if (__pListener != null) + { + __pListener->OnDataBindingTargetUpdated(__bindingId, pControl->GetName(), __propertyName); + } + } + r = E_SUCCESS; + } +CATCH: + delete pOriginObject; + delete pTransformedObject; + return r; +} +result +_DataBinding::SetDataBindingListener(const IDataBindingListener* pListener) +{ + __pListener = const_cast(pListener); + return E_SUCCESS; +} +_ControlHandle +_DataBinding::Get_ControlHandle(void) const +{ + return __controlHandle; +} +String +_DataBinding::GetPropertyName(void) const +{ + return __propertyName; +} +DataBindingDataType +_DataBinding::GetSourceDataType(void) const +{ + return __sourceType; +} +DataBindingDataType +_DataBinding::GetTargetDataType(void) const +{ + return __targetType; +} +DataBindingFlow +_DataBinding::GetDataFlow(void) const +{ + return __flow; +} +DataBindingTrigger +_DataBinding::GetTrigger(void) const +{ + return __trigger; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_DataBinding.h b/src/ui/FUi_DataBinding.h new file mode 100644 index 0000000..5d3271a --- /dev/null +++ b/src/ui/FUi_DataBinding.h @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_DataBinding.h + * @brief This is the header file for the _DataBinding class. + * + * This header file contains the declarations of the _DataBinding class. + */ +#ifndef _FUI_INTERNAL_DATA_BINDING_H_ +#define _FUI_INTERNAL_DATA_BINDING_H_ + +#include +#include +#include "FUi_ControlManager.h" + +namespace Tizen { namespace Ui +{ + +class Variant; +class IDataBindingListener; +class IDataBindingDataValidator; +class IDataBindingDataTransformer; +class _Control; +class _IPropertyChangeEventListener; + +class _DataBinding +{ +public: +// Lifecycle + ~_DataBinding(void); + result Construct(const _Control& control, const Tizen::Base::String& bindingId, const Tizen::Base::String& propertyName + , Tizen::Base::Object& dataSource, DataBindingDataType sourceType, DataBindingFlow flow, DataBindingTrigger trigger + , const IDataBindingListener* pListener, const IDataBindingDataValidator* pValidator, const IDataBindingDataTransformer* pTransformer); + +// Operations + result Update(DataBindingDestinationType destType); + result SetDataBindingListener(const IDataBindingListener* pListener); + +// Accessor + _ControlHandle Get_ControlHandle(void) const; + Tizen::Base::String GetPropertyName(void) const; + DataBindingDataType GetSourceDataType(void) const; + DataBindingDataType GetTargetDataType(void) const; + DataBindingFlow GetDataFlow(void) const; + DataBindingTrigger GetTrigger(void) const; + +// Lifecycle +private: + _DataBinding(void); + _DataBinding(const _DataBinding& rhs); + _DataBinding& operator =(const _DataBinding& rhs); + +// Attributes +private: + _ControlHandle __controlHandle; + Tizen::Base::String __bindingId; + Tizen::Base::String __propertyName; + Tizen::Base::Object* __pDataSource; + DataBindingDataType __sourceType; + DataBindingDataType __targetType; + DataBindingFlow __flow; + DataBindingTrigger __trigger; + IDataBindingListener* __pListener; + IDataBindingDataValidator* __pValidator; + IDataBindingDataTransformer* __pTransformer; + _IPropertyChangeEventListener* __pPropertyChangeEventListener; + +// Friend Class Declaration + friend class _DataBindingContext; +}; //class _DataBinding + +}} //Tizen::Ui + +#endif // _FUI_INTERNAL_DATA_BINDING_H_ diff --git a/src/ui/FUi_DataBindingContext.cpp b/src/ui/FUi_DataBindingContext.cpp new file mode 100644 index 0000000..eb47b53 --- /dev/null +++ b/src/ui/FUi_DataBindingContext.cpp @@ -0,0 +1,241 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_DataBindingContext.cpp + * @brief This is the implementation for the _DataBindingContext class. + */ + +#include +#include +#include +#include +#include "FUi_Control.h" +#include "FUi_DataBindingContext.h" +#include "FUi_DataBinding.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +namespace { +class _DataBindingHashCodeProvider + : public IHashCodeProviderT +{ +public: + _DataBindingHashCodeProvider(void) {} + virtual ~_DataBindingHashCodeProvider(void) {} + + virtual int GetHashCode(const String& obj) const + { + return obj.GetHashCode(); + } +}; + +class _DataBindingComparer + : public IComparerT +{ +public: + _DataBindingComparer(void) {} + virtual ~_DataBindingComparer(void) {} + virtual result Compare(const String& obj1, const String& obj2, int& cmp) const + { + if (obj1 == obj2) + { + cmp = 0; + return E_SUCCESS; + } + else + { + cmp = -1; + return E_INVALID_ARG; + } + } +}; +} + +namespace Tizen { namespace Ui +{ + +_DataBindingContext::_DataBindingContext(const _Control& control) + : __pControl(null) + , __pProvider(null) + , __pComparer(null) + , __map() +{ + result r = E_SYSTEM; + __pControl = const_cast <_Control*>(&control); + __pProvider = new _DataBindingHashCodeProvider; + SysTryReturnVoidResult(NID_UI, __pProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation for _DataBinding is failed."); + + __pComparer = new _DataBindingComparer; + SysTryReturnVoidResult(NID_UI, __pComparer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation for _DataBinding is failed."); + + r = __map.Construct(0, 0.0, *__pProvider, *__pComparer); + SetLastResult(r); +} + +_DataBindingContext::~_DataBindingContext(void) +{ + UnbindAll(); + + delete __pProvider; + __pProvider = null; + delete __pComparer; + __pComparer = null; +} + +_Control* +_DataBindingContext::GetContextOwner(void) const +{ + return __pControl; +} +result +_DataBindingContext::Bind(_Control& control, const String& bindingId, const String& controlName, + const String& propertyName, Object& dataSource, + DataBindingDataType sourceType, DataBindingFlow flow, + DataBindingTrigger trigger, const IDataBindingListener* pListener, + const IDataBindingDataValidator* pValidator, + const IDataBindingDataTransformer* pTransformer) +{ + SysTryReturn(NID_UI, + propertyName.GetLength() > 0, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, + "[E_OBJ_NOT_FOUND] propertyName is too short(=0)."); + SysTryReturn(NID_UI, !((flow == DATA_BINDING_FLOW_ONE_WAY || + flow == DATA_BINDING_FLOW_TWO_WAY) && + trigger == DATA_BINDING_TRIGGER_IMMEDIATE), + E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Flow %d and trigger %d is not supported.", + flow, trigger); + + result r = E_SUCCESS; + + _DataBinding* pDataBinding = new (std::nothrow) _DataBinding; + SysTryReturn(NID_UI, pDataBinding, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation for _DataBinding is failed."); + + r = pDataBinding->Construct(control, bindingId, propertyName, dataSource, sourceType, flow, trigger, pListener, pValidator, + pTransformer); + SysTryCatch(NID_UI, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] adding data binding is failed."); + + r = __map.Add(bindingId, pDataBinding); + SysTryCatch(NID_UI, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] adding data binding is failed."); + + return E_SUCCESS; + +CATCH: + delete pDataBinding; + return r; + +} +result +_DataBindingContext::SetDataBindingEventListener(const String& bindingId, const IDataBindingListener* pListener) +{ + result r = E_SUCCESS; + _DataBinding* pDataBinding = null; + r = __map.GetValue(const_cast(bindingId), pDataBinding); + SysTryReturn(NID_UI, r == E_SUCCESS, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The given binding ID is not registered."); + + return pDataBinding->SetDataBindingListener(pListener); +} +result +_DataBindingContext::UnbindAll(void) +{ + result r = E_SUCCESS; + MapEntryT currentEntry; + IEnumeratorT >* pMapEnumerator = __map.GetMapEnumeratorN(); + + SysTryReturn(NID_UI, pMapEnumerator, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting enumerator is failed."); + + while ((pMapEnumerator->MoveNext() == E_SUCCESS)) + { + r = pMapEnumerator->GetCurrent(currentEntry); + SysTryCatch(NID_UI, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] removing data binding is failed."); + + _DataBinding* pBinding = currentEntry.GetValue(); + SysTryCatch(NID_UI, pBinding, r = E_SYSTEM, r, "[E_SYSTEM] UpdateAllBindings is failed."); + delete pBinding; + } + delete pMapEnumerator; + __map.RemoveAll(); + return r; +CATCH: + delete pMapEnumerator; + return r; +} +result +_DataBindingContext::Unbind(const String& bindingId) +{ + result r = E_SYSTEM; + _DataBinding* pDataBinding = null; + r = __map.GetValue(const_cast(bindingId), pDataBinding); + SysTryReturn(NID_UI, r == E_SUCCESS && pDataBinding, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The given binding ID is not registered."); + delete pDataBinding; + __map.Remove(const_cast(bindingId)); + return r; +} +result +_DataBindingContext::UpdateAllBindings(DataBindingDestinationType destinationType) +{ + result r = E_SUCCESS; + IEnumeratorT >* pMapEnumerator = __map.GetMapEnumeratorN(); + SysTryReturn(NID_UI, pMapEnumerator, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Getting enumerator is failed."); + MapEntryT currentEntry; + + while (pMapEnumerator->MoveNext() == E_SUCCESS) + { + r = pMapEnumerator->GetCurrent(currentEntry); + SysTryCatch(NID_UI, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] UpdateAllBindings is failed."); + _DataBinding* pBinding = currentEntry.GetValue(); + SysTryCatch(NID_UI, pBinding, r = E_SYSTEM, r, "[E_SYSTEM] UpdateAllBindings is failed."); + DataBindingFlow flow = pBinding->GetDataFlow(); + if ((destinationType == DATA_BINDING_DESTINATION_TYPE_SOURCE && + ( flow == DATA_BINDING_FLOW_ONE_WAY_TO_SOURCE || + flow == DATA_BINDING_FLOW_TWO_WAY)) || + (destinationType == DATA_BINDING_DESTINATION_TYPE_TARGET && + (flow == DATA_BINDING_FLOW_ONE_WAY || flow == DATA_BINDING_FLOW_TWO_WAY))) + { + r = pBinding->Update(destinationType); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] System Error", GetErrorMessage(r)); + } + } + delete pMapEnumerator; + return r; +CATCH: + delete pMapEnumerator; + return r; +} +result +_DataBindingContext::UpdateBinding(const String& bindingId, DataBindingDestinationType destinationType) +{ + result r = E_SUCCESS; + _DataBinding* pDataBinding = null; + r = __map.GetValue(const_cast(bindingId), pDataBinding); + SysTryReturn(NID_UI, r == E_SUCCESS, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, + "[E_OBJ_NOT_FOUND] The given binding ID is not registered."); + DataBindingFlow flow = pDataBinding->GetDataFlow(); + DataBindingTrigger trigger = pDataBinding->GetTrigger(); + SysTryReturn(NID_UI, trigger != DATA_BINDING_TRIGGER_IMMEDIATE, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The given binding's trigger is not 'explicit' type."); + SysTryReturn(NID_UI, (flow == DATA_BINDING_FLOW_TWO_WAY) || + (flow == DATA_BINDING_FLOW_ONE_WAY && destinationType == DATA_BINDING_DESTINATION_TYPE_TARGET) || + (flow == DATA_BINDING_FLOW_ONE_WAY_TO_SOURCE && destinationType == DATA_BINDING_DESTINATION_TYPE_SOURCE), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] destinationType is not supported in binding ID."); + + r = pDataBinding->Update(destinationType); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] binding update is failed.", GetErrorMessage(r)); + + return r; +} + +}}//Tizen::Ui diff --git a/src/ui/FUi_DataBindingContext.h b/src/ui/FUi_DataBindingContext.h new file mode 100644 index 0000000..3027e15 --- /dev/null +++ b/src/ui/FUi_DataBindingContext.h @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_DataBindingContext.h + * @brief This is the header file for the _DataBindingContext class. + * + * This header file contains the declarations of the _DataBindingContext class. + */ +#ifndef _FUI_INTERNAL_DATA_BINDING_CONTEXT_H_ +#define _FUI_INTERNAL_DATA_BINDING_CONTEXT_H_ + +#include +#include + +namespace Tizen { namespace Base +{ + class String; +}} + +namespace Tizen { namespace Ui +{ + +class IDataBindingListener; +class IDataBindingDataValidator; +class IDataBindingDataTransformer; +class _Control; +class _DataBinding; + +class _DataBindingContext +{ +public: +// Life Cycle + _DataBindingContext(const _Control& control); + ~_DataBindingContext(void); + +// Accessor + _Control* GetContextOwner(void) const; + +// Operations + result Bind(_Control& control, const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName, Tizen::Base::Object& dataSource, DataBindingDataType sourceType, DataBindingFlow flow, DataBindingTrigger trigger, const IDataBindingListener* pListener, const IDataBindingDataValidator* pValidator, const IDataBindingDataTransformer* pTransformer); + + result SetDataBindingEventListener(const Tizen::Base::String& bindingId, const IDataBindingListener* pListener); + + result UnbindAll(void); + + result Unbind(const Tizen::Base::String& bindingId); + + result UpdateAllBindings(DataBindingDestinationType destinationType); + + result UpdateBinding(const Tizen::Base::String& bindingId, DataBindingDestinationType destinationType); +private: + _DataBindingContext(const _DataBindingContext& rhs); + _DataBindingContext& operator =(const _DataBindingContext& rhs); +private: +// Attributes + _Control* __pControl; + Tizen::Base::Collection::IHashCodeProviderT* __pProvider; + Tizen::Base::Collection::IComparerT* __pComparer; + Tizen::Base::Collection::HashMapT __map; +}; //class _DataBindingContext + +}} //Tizen::Ui +#endif // _FUI_INTERNAL_DATA_BINDING_CONTEXT_H_ diff --git a/src/ui/FUi_DataBindingContextImpl.cpp b/src/ui/FUi_DataBindingContextImpl.cpp new file mode 100644 index 0000000..fcd4a4f --- /dev/null +++ b/src/ui/FUi_DataBindingContextImpl.cpp @@ -0,0 +1,167 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_DataBindingContextImpl.cpp + * @brief This is the implementation for the _DataBindingContextImpl class. + */ +#include +#include "FUi_ControlImpl.h" +#include "FUi_ContainerImpl.h" +#include "FUi_DataBindingContextImpl.h" +#include "FUi_DataBindingContext.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui +{ +_DataBindingContextImpl::_DataBindingContextImpl(const _ContainerImpl& controlImpl) + : __pContainerImpl(null) +{ + __pContainerImpl = const_cast <_ContainerImpl*>(&controlImpl); + __controlHandle = __pContainerImpl->GetCore().GetHandle(); + result r = E_SYSTEM; + if(!ControlCoreExists(__controlHandle)) + { + r = E_SYSTEM; + } + if(!__pContainerImpl->GetCore().GetDataBindingContext()) + { + r = E_SYSTEM; + } + else + { + r = E_SUCCESS; + } + SetLastResult(r); +} + +_DataBindingContextImpl::~_DataBindingContextImpl(void) +{ +} + +_ContainerImpl* +_DataBindingContextImpl::GetContextOwner(void) const +{ + return __pContainerImpl; +} +DataBindingContext* +_DataBindingContextImpl::GetDataBindingContextN(const _ContainerImpl& controlImpl) +{ + DataBindingContext* pContext = new (std::nothrow) DataBindingContext(controlImpl.GetPublic()); + SysTryReturn(NID_UI, pContext, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation for _DataBinding is failed."); + + SetLastResult(E_SUCCESS); + return pContext; +} +result +_DataBindingContextImpl::Bind(const String& bindingId, const String& controlName, + const String& propertyName + , Object& dataSource, DataBindingDataType sourceType, DataBindingFlow flow, + DataBindingTrigger trigger + , const IDataBindingListener* pListener, const IDataBindingDataValidator* pValidator, + const IDataBindingDataTransformer* pTransformer) +{ + SysTryReturn(NID_UI, ControlCoreExists(__controlHandle) && __pContainerImpl, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + _ControlImpl* pControlImpl = __pContainerImpl->SearchControlByName(controlName, true); + SysTryReturn(NID_UI, pControlImpl, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, + "[E_OBJ_NOT_FOUND] a control named as \"%s\" is not found.", + controlName.GetPointer()); + _DataBindingContext* pContext = __pContainerImpl->GetCore().GetDataBindingContext(); + SysTryReturn(NID_UI, pContext, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + return pContext->Bind( pControlImpl->GetCore(), bindingId, controlName, propertyName, + dataSource, sourceType, flow, trigger, pListener, pValidator, pTransformer); +} +result +_DataBindingContextImpl::SetDataBindingEventListener(const String& bindingId, IDataBindingListener* pListener) +{ + + SysTryReturn(NID_UI, ControlCoreExists(__controlHandle), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + _DataBindingContext* pContext = __pContainerImpl->GetCore().GetDataBindingContext(); + SysTryReturn(NID_UI, pContext, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + return pContext->SetDataBindingEventListener(bindingId, pListener); +} +result +_DataBindingContextImpl::UnbindAll(void) +{ + SysTryReturn(NID_UI, ControlCoreExists(__controlHandle), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + _DataBindingContext* pContext = __pContainerImpl->GetCore().GetDataBindingContext(); + SysTryReturn(NID_UI, pContext, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + return pContext->UnbindAll(); +} + +result +_DataBindingContextImpl::Unbind(const String& bindingId) +{ + SysTryReturn(NID_UI, ControlCoreExists(__controlHandle), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + _DataBindingContext* pContext = __pContainerImpl->GetCore().GetDataBindingContext(); + SysTryReturn(NID_UI, pContext, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + return pContext->Unbind(bindingId); +} + +result +_DataBindingContextImpl::UpdateAllBindings(DataBindingDestinationType destType) +{ + SysTryReturn(NID_UI, ControlCoreExists(__controlHandle), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + _DataBindingContext* pContext = __pContainerImpl->GetCore().GetDataBindingContext(); + SysTryReturn(NID_UI, pContext, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + return pContext->UpdateAllBindings(destType); +} + +result +_DataBindingContextImpl::UpdateBinding(const String& bindingId, DataBindingDestinationType destType) +{ + SysTryReturn(NID_UI, ControlCoreExists(__controlHandle), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + _DataBindingContext* pContext = __pContainerImpl->GetCore().GetDataBindingContext(); + SysTryReturn(NID_UI, pContext, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + return pContext->UpdateBinding(bindingId, destType); +} +_DataBindingContextImpl* +_DataBindingContextImpl::GetDataBindingContextInstance(DataBindingContext* pDataBindingContext) +{ + return pDataBindingContext ? pDataBindingContext->__pDataBindingContextImpl : null; +} +const _DataBindingContextImpl* +_DataBindingContextImpl::GetDataBindingContextInstance(const DataBindingContext* pDataBindingContext) +{ + return pDataBindingContext ? pDataBindingContext->__pDataBindingContextImpl : null; +} +bool +_DataBindingContextImpl::ControlCoreExists(_ControlHandle controlHandle) +{ + _Control* pControlCore = null; //review : coding idiom + _ControlManager* pManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, !(controlHandle.IsNull()), false, E_SYSTEM, "[E_SYSTEM] System Error."); + SysTryReturn(NID_UI, pManager, false, E_SYSTEM, "[E_SYSTEM] System Error."); + + pControlCore = pManager->GetObject(controlHandle); + SysTryReturn(NID_UI, pControlCore, false, E_SYSTEM, "[E_SYSTEM] System Error."); + return true; +} + +} } //Tizen::Ui diff --git a/src/ui/FUi_DataBindingContextImpl.h b/src/ui/FUi_DataBindingContextImpl.h new file mode 100644 index 0000000..1351f3f --- /dev/null +++ b/src/ui/FUi_DataBindingContextImpl.h @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_DataBindingContextImpl.h + * @brief This is the header file for the _DataBindingContextImpl class. + * + * This header file contains the declarations of the _DataBindingContextImpl class. + */ +#ifndef _FUI_INTERNAL_DATA_BINDING_CONTEXT_IMPL_H_ +#define _FUI_INTERNAL_DATA_BINDING_CONTEXT_IMPL_H_ + +#include +#include +#include "FUi_ControlManager.h" + +namespace Tizen { namespace Ui { + +class _ControlImpl; +class _ContainerImpl; +class DataBindingContext; +class IDataBindingListener; +class IDataBindingDataValidator; +class IDataBindingDataTransformer; +class _DataBindingContext; + +class _DataBindingContextImpl + : public Tizen::Base::Object +{ +// Life Cycle +public: + _DataBindingContextImpl(const _ContainerImpl& containerImpl); + virtual ~_DataBindingContextImpl(void); + static DataBindingContext* GetDataBindingContextN(const _ContainerImpl& containerImpl); + +// Accessors +public: + _ContainerImpl* GetContextOwner(void) const; + +// Operations + result Bind(const Tizen::Base::String& bindingId, const Tizen::Base::String& controlName, const Tizen::Base::String& propertyName, Tizen::Base::Object& dataSource, DataBindingDataType sourceType, DataBindingFlow flow, DataBindingTrigger trigger, const IDataBindingListener* pListener, const IDataBindingDataValidator* pValidator, const IDataBindingDataTransformer* pTransformer); + + result SetDataBindingEventListener(const Tizen::Base::String& bindingId, IDataBindingListener* pListener); + + result UnbindAll(void); + + result Unbind(const Tizen::Base::String& bindingId); + + result UpdateAllBindings(DataBindingDestinationType destinationType); + + result UpdateBinding(const Tizen::Base::String& bindingId, DataBindingDestinationType destinationType); + + static _DataBindingContextImpl* GetDataBindingContextInstance(DataBindingContext* pDataBindingContext); + static const _DataBindingContextImpl* GetDataBindingContextInstance(const DataBindingContext* pDataBindingContext); + +private: +// Queries + bool ControlCoreExists(_ControlHandle controlHandle); + +// Coding idiom + _DataBindingContextImpl(const _DataBindingContextImpl& rhs); + _DataBindingContextImpl& operator =(const _DataBindingContextImpl& rhs); + +private: +// Attributes + _ControlHandle __controlHandle; + _ContainerImpl* __pContainerImpl; +}; //class _DataBindingContextImpl + +}} //Tizen::Ui +#endif // _FUI_INTERNAL_DATA_BINDING_CONTEXT_IMPL_H_ diff --git a/src/ui/FUi_DragDropEvent.cpp b/src/ui/FUi_DragDropEvent.cpp new file mode 100644 index 0000000..e236491 --- /dev/null +++ b/src/ui/FUi_DragDropEvent.cpp @@ -0,0 +1,155 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_DragDropEvent.cpp + * @brief This is the implementation file for _DragDropEvent class + * @since 2.0 + * + * This file contains the implementation of %_DragDropEvent class. + * + */ + +#include +#include +#include +#include +#include "FUi_DragDropEvent.h" +#include "FUi_DragDropEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui +{ +_DragDropEvent::_DragDropEvent() + : __pSource(null) +{ + // NOTHING +} + +_DragDropEvent::~_DragDropEvent() +{ + // NOTHING +} + + +result +_DragDropEvent::Construct(const Control& source) +{ + result r = E_SUCCESS; + r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = const_cast (&source); + } + + return (r); + +} + + + +bool +_DragDropEvent::Filter(const Tizen::Base::Runtime::IEventArg& eventArg) +{ + return false; +} + +result +_DragDropEvent::AddListener(const Tizen::Base::Runtime::IEventListener& listener, + const Tizen::Base::Runtime::_EventDispatcher* pEventDispatcher) +{ + result r = E_SUCCESS; + return r; +} + +result +_DragDropEvent::Wait(void) +{ + result r = E_SUCCESS; + return r; +} + +result +_DragDropEvent::FireImpl(IEventListener* pListener, const IEventArg& arg) +{ + SysTryReturnResult(NID_UI, pListener, E_INVALID_ARG, "The Invalid argument is given."); + + IDragDropEventListener* pDragDropListener = dynamic_cast (pListener); + SysTryReturnResult(NID_UI, pDragDropListener, E_INVALID_ARG, "The Invalid argument is given."); + + const _DragDropEventArg* pArg = dynamic_cast (&arg); + SysTryReturnResult(NID_UI, pArg, E_INVALID_ARG, "The invalid Event Argument is given."); + + switch (pArg->GetDragDropStatus()) + { + case DRAG_DROP_INDICATED: + break; + + case DRAG_DROP_PRESSED: + break; + + case DRAG_DROP_LONG_PRESSED: + break; + + case DRAG_DROP_RELEASED: + break; + + case DRAG_DROP_MOVED: + break; + + case DRAG_DROP_DOUBLE_PRESSED: + break; + + case DRAG_DROP_FOCUS_IN: + break; + + case DRAG_DROP_FOCUS_OUT: + break; + + case DRAG_DROP_FLICKED: + break; + + case DRAG_DROP_FLICK_HELD: + break; + + case DRAG_DROP_DRAGGED: + pDragDropListener->OnTouchDragged(*pArg->GetSource(), pArg->GetStartPosition(), pArg->GetCurrentPosition()); + break; + + case DRAG_DROP_DROPPED: + pDragDropListener->OnTouchDropped(*pArg->GetSource(), pArg->GetStartPosition(), pArg->GetCurrentPosition()); + break; + + default: + return E_SYSTEM; + } + return E_SUCCESS; +} + +const Tizen::Ui::Control* +_DragDropEvent::GetSource(void) const +{ + return (__pSource); +} + +}; +}; // Tizen::Ui diff --git a/src/ui/FUi_DragDropEventArg.cpp b/src/ui/FUi_DragDropEventArg.cpp new file mode 100644 index 0000000..c1ed52c --- /dev/null +++ b/src/ui/FUi_DragDropEventArg.cpp @@ -0,0 +1,98 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_DragDropEventArg.cpp + * @brief This is the implementation file for _DragDropEventArg class + * @version 2.1 + * + * This file contains the implementation of %_DragDropEventArg class. + * + */ + +#include "FUi_DragDropEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui +{ +_DragDropEventArg::_DragDropEventArg(const Control& source, DragDropStatus status) + : __pSource(const_cast (&source)) + , __pDraggedControl(null) + , __dragDropStatus(status) + , __startPosition(-1, -1) + , __currentPosition(-1, -1) +{ + // NOTHING +} + +_DragDropEventArg::~_DragDropEventArg(void) +{ + // NOTHING +} + +DragDropStatus +_DragDropEventArg::GetDragDropStatus(void) const +{ + return (__dragDropStatus); +} + + +const Tizen::Ui::Control* +_DragDropEventArg::GetSource(void) const +{ + return (__pSource); +} + + +const Tizen::Graphics::Point +_DragDropEventArg::GetStartPosition(void) const +{ + return __startPosition; +} + +const Tizen::Graphics::Point +_DragDropEventArg::GetCurrentPosition(void) const +{ + return __currentPosition; +} + +result +_DragDropEventArg::SetDraggedControl(const Tizen::Ui::Control* pDraggedControl) +{ + __pDraggedControl = (Tizen::Ui::Control*) pDraggedControl; +// if( pDragedControl == null) return E_FAILURE; + return E_SUCCESS; +} + +const Tizen::Ui::Control* +_DragDropEventArg::GetDraggedControl(void) const +{ + return (const Tizen::Ui::Control*) __pDraggedControl; +} + +result +_DragDropEventArg::SetTouchPosition(int startX, int startY, int currentX, int currentY) +{ + __startPosition = Tizen::Graphics::Point(startX, startY); + __currentPosition = Tizen::Graphics::Point(currentX, currentY); + + return E_SUCCESS; +} + +}; +}; // Tizen::Ui diff --git a/src/ui/FUi_EcoreEvas.cpp b/src/ui/FUi_EcoreEvas.cpp new file mode 100644 index 0000000..98e2f63 --- /dev/null +++ b/src/ui/FUi_EcoreEvas.cpp @@ -0,0 +1,3407 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_EcoreEvas.cpp + * @brief This is the implementation file for the _EcoreEvas class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_CoordinateSystemUtils.h" +#include "FUi_EcoreEvas.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_Control.h" +#include +#include "FUi_UiNotificationEvent.h" +#include "FUi_UiEventManager.h" +#include "FUi_Window.h" +#include "FUiAnim_EflLayer.h" +#include "FUiAnim_EflNode.h" +#include "FUiAnim_VisualElement.h" +#include "FUi_AccessibilityGesture.h" +#include "FUi_AccessibilitySystemSettingLoader.h" +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_DisplayManager.h" +#include "FUiCtrl_Frame.h" +// #include "FUiCtrl_NotificationFrame.h" +#include "FUi_Clipboard.h" +#include "FUi_TouchManager.h" +#include "FUi_ControlManager.h" +#include "FUi_ActiveWindowEvent.h" +#include "FUi_ControlImplManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::App; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Controls; + +#define ATOM_CBHM_WINDOW_NAME "CBHM_XWIN" +#define ATOM_CBHM_MSG "CBHM_MSG" +#define ATOM_CBHM_COUNT_GET "CBHM_cCOUNT" +#define ATOM_CBHM_SERIAL_NUMBER "CBHM_SERIAL_NUMBER" +#define ATOM_CBHM_ERROR "CBHM_ERROR" +#define ATOM_CBHM_ITEM "CBHM_ITEM" +#define ATOM_CBHM_SET_ITEM "SET_ITEM" +#define ATOM_CBHM_CLIPBOARD_SHOW_ALL "show1" +#define ATOM_CBHM_CLIPBOARD_SHOW "show0" +#define ATOM_CBHM_CLIPBOARD_HIDE "cbhm_hide" +#define ATOM_CBHM_SELECTED_ITEM "CBHM_SELECTED_ITEM" + +namespace Tizen { namespace Ui +{ +static _EcoreEvas* _pEvas = null; +}} // Tizen::Ui + +namespace +{ + +Ecore_X_Atom __atomRotateRootAngle = 0; +Ecore_X_Atom __atomAccessibility = 0; + +void +OnWindowDeleted(void* pData, Evas* pE, Evas_Object* pObj, void* pEventInfo) +{ +} + +Eina_Bool +OnPropertyChanged(void* pData, int type, void* pEvent) +{ + SysLog(NID_UI, "This callback is called."); + + if (!pData) + { + SysLog(NID_UI, "The data is not valid."); + return EINA_FALSE; + } + + if (!pEvent) + { + SysLog(NID_UI, "The event is not valid."); + return EINA_FALSE; + } + + Ecore_X_Event_Window_Property* pE = (Ecore_X_Event_Window_Property*) pEvent; + + Ecore_X_Atom atom = pE->atom; + Ecore_X_Atom activeAtom = ecore_x_atom_get("_NET_ACTIVE_WINDOW"); + + if (atom != activeAtom) + { + return ECORE_CALLBACK_PASS_ON; + } + + Ecore_X_Window win = pE->win; + + Ecore_X_Window activeWin = 0; + ecore_x_window_prop_window_get(win, activeAtom, &activeWin, 1); + + int pid = 0; + Eina_Bool ret = ecore_x_netwm_pid_get(activeWin, &pid); + if (ret != EINA_TRUE) + { + return ECORE_CALLBACK_PASS_ON; + } + + char* pAppName = null; + ecore_x_netwm_name_get(activeWin, &pAppName); + + _EcoreEvas* pEcoreEvas = static_cast<_EcoreEvas*>(pData); + pEcoreEvas->FireActiveWindowEvent(activeWin, pid, pAppName); + + if (pAppName) + { + free(pAppName); + } + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool +OnVisibilityChanged(void* pData, int type, void* pEvent) +{ + SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pEvent, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + +#if !defined(MULTI_WINDOW) + _EcoreEvas* pEcoreEvas = static_cast<_EcoreEvas*>(pData); + Ecore_Evas* pEcore_Evas = pEcoreEvas->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcore_Evas, EINA_FALSE, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pEcore_Evas); + + Ecore_X_Event_Window_Visibility_Change* pE = (Ecore_X_Event_Window_Visibility_Change*) pEvent; + + Tizen::Base::Collection::ArrayList* pArgs = null; + String* pType = null; + Integer* pObscured = null; + + if (window == pE->win) + { + const _Control* pDestination = pEcoreEvas->GetFrame(); + SysTryReturn(NID_UI, pDestination, EINA_FALSE, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pArgs = new (std::nothrow) Tizen::Base::Collection::ArrayList; + SysTryReturn(NID_UI, pArgs, EINA_FALSE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = pArgs->Construct(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pType = new (std::nothrow) String(L"VisibilityEvent"); + r = pArgs->Add(*pType); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pObscured = new (std::nothrow) Integer(pE->fully_obscured); + r = pArgs->Add(*pObscured); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + _UiNotificationEvent event(pDestination->GetHandle(), pArgs); + + r = _UiEventManager::GetInstance()->SendEvent(event); + } +#else + Ecore_X_Event_Window_Visibility_Change* pE = (Ecore_X_Event_Window_Visibility_Change*) pEvent; + _ControlManager* pControlManager = _ControlManager::GetInstance(); + + int count = pControlManager->GetWindowCount(); + + _Window* pWindow = null; + Ecore_X_Window window = 0; + bool found = false; + + for (int i = 0; i < count; i++) + { + pWindow = pControlManager->GetWindow(i); + if (!pWindow) + { + SysLog(NID_UI, "The efl layer is null."); + continue; + } + + _RootVisualElement* pRootVE = pWindow->GetRootVisualElement(); + if (!pRootVE) + { + SysLog(NID_UI, "The efl layer is null."); + continue; + } + + _EflLayer* pEflLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer()); + if (!pEflLayer) + { + SysLog(NID_UI, "The efl layer is null."); + continue; + } + + window = (Ecore_X_Window)ecore_evas_window_get(pEflLayer->GetEcoreEvas()); + + if (window == pE->win) + { + found = true; + break; + } + } + + Tizen::Base::Collection::ArrayList* pArgs = null; + String* pType = null; + Integer* pObscured = null; + + if (found == true) + { + const _Control* pDestination = pWindow; + + pArgs = new (std::nothrow) Tizen::Base::Collection::ArrayList; + SysTryReturn(NID_UI, pArgs, EINA_FALSE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = pArgs->Construct(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pType = new (std::nothrow) String(L"VisibilityEvent"); + r = pArgs->Add(*pType); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pObscured = new (std::nothrow) Integer(pE->fully_obscured); + r = pArgs->Add(*pObscured); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + _UiNotificationEvent event(pDestination->GetHandle(), pArgs); + + r = _UiEventManager::GetInstance()->SendEvent(event); + } +#endif + + return ECORE_CALLBACK_RENEW; + +CATCH: + pArgs->RemoveAll(true); + delete pArgs; + + if (pType) + { + delete pType; + } + + if (pObscured) + { + delete pObscured; + } + + return EINA_FALSE; +} + +void +OnAutoRotationChanged(runtime_info_key_e key, void* pUserData) +{ + if (key != RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED) + { + return; + } + + bool autoRotationLock = false; + int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED, &autoRotationLock); + + if (ret != RUNTIME_INFO_ERROR_NONE) + { + SysLog(NID_UI, "It's failed to get the flag of auto-rotation."); + return; + } + + int angle = 0; + + if (autoRotationLock == false) + { + angle = app_get_device_orientation(); + } + + _ControlImplManager* pControlImplManager = _ControlImplManager::GetInstance(); + if (pControlImplManager) + { + pControlImplManager->OnScreenRotated(angle); + } +} +Eina_Bool +OnAccessibilitySettingMessageReceived(void* pData, int type, void* pEvent) +{ + Ecore_X_Event_Client_Message* pClientEvent = static_cast(pEvent); + if (pClientEvent->message_type == __atomAccessibility) + { + if((Eina_Bool)pClientEvent->data.l[0]) + { + _AccessibilitySystemSettingLoader::SetSystemSetting(L"AccessibilityActivationStatus", true); + _AccessibilitySystemSettingLoader::SetSystemSetting(L"AccessibilityActivationStatus", true); + SysLog(NID_UI, "Accessibility Screen reader is activated."); + + } + else + { + _AccessibilitySystemSettingLoader::SetSystemSetting(L"AccessibilityActivationStatus", false); + _AccessibilitySystemSettingLoader::SetSystemSetting(L"AccessibilityActivationStatus", false); + SysLog(NID_UI, "Accessibility Screen reader is deactivated."); + } + } + return ECORE_CALLBACK_PASS_ON; +} + +// [Accessibility] +Eina_Bool +OnClientMessageReceived(void* pData, int type, void* pEvent) +{ + Ecore_X_Event_Client_Message* pClientEvent = static_cast(pEvent); + SysTryReturn(NID_UI, pClientEvent, ECORE_CALLBACK_RENEW, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + if (pClientEvent->message_type == __atomRotateRootAngle) + { + int angle = pClientEvent->data.l[0]; + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, ECORE_CALLBACK_RENEW, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pControlManager->OnWindowRotated(angle); + } + + if (pClientEvent->message_type == ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL) + { + int x = 0; + int y = 0; + if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_NEXT) + { + SysLog(NID_UI, "Accessibility action : Move next"); + _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_FLICK_DOWN); + } + else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_PREV) + { + SysLog(NID_UI, "Accessibility action : Move previous"); + _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_FLICK_UP); + } + else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE) + { + SysLog(NID_UI, "Accessibility action : Activate"); + _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_DOUBLE_TAP); + } + else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ) + { + x = (Evas_Coord)pClientEvent->data.l[2]; + y = (Evas_Coord)pClientEvent->data.l[3]; + SysLog(NID_UI, "Accessibility action : Read"); + _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_ONE_TAP, x, y); + } + else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_UP) + { + SysLog(NID_UI, "Accessibility action : value increased"); + _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_VALUE_INCREASED); + } + else if ((unsigned int)pClientEvent->data.l[1] == ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DOWN) + { + SysLog(NID_UI, "Accessibility action : value decreased"); + _AccessibilityGesture::ProcessGesture(_ACCESSIBILITY_GESTURE_TYPE_VALUE_DECREASED); + } + } + + return ECORE_CALLBACK_RENEW; +} + +} // Anonymous + +// For Clipboard +namespace +{ +#define __UNUSED__ + +enum _ClipType +{ + _CLIP_TYPE_PRIMARY, + _CLIP_TYPE_SECONDARY, + _CLIP_TYPE_CLIPBOARD, + _CLIP_TYPE_XDND, + _CLIP_TYPE_MAX, +}; + +struct _Clip +{ + Ecore_X_Selection selection; + Eina_Bool (* set)(Ecore_X_Window window, const void* pData, int size); + Eina_Bool (* clear)(void); + void (* request)(Ecore_X_Window window, const char* pTarget); + + bool active; + _ClipFormat format; + char* pBuffer; + + _ClipFormat requestedFormat; + char* pRetrievedBuffer; + int bufferLength; + bool completed; +}; + +typedef Eina_Bool (*ClipConverter)(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize); +typedef int (*ClipResponseHandler)(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify); +typedef int (*ClipNotifyHandler)(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify); + +enum +{ + _ATOM_TARGETS = 0, + _ATOM_ATOM, + _ATOM_LISTING_ATOMS = _ATOM_ATOM, + _ATOM_TEXT_URI, + _ATOM_TEXT_URILIST, + _ATOM_TEXT_X_VCARD, + _ATOM_IMAGE_PNG, + _ATOM_IMAGE_JPEG, + _ATOM_IMAGE_BMP, + _ATOM_IMAGE_GIF, + _ATOM_IMAGE_TIFF, + _ATOM_IMAGE_SVG, + _ATOM_IMAGE_XPM, + _ATOM_IMAGE_TGA, + _ATOM_IMAGE_PPM, + _ATOM_XELM, + _ATOM_TEXT_HTML_UTF8, + _ATOM_TEXT_HTML, + _ATOM_STRING_UTF8, + _ATOM_STRING, + _ATOM_TEXT, + _ATOM_TEXT_PLAIN_UTF8, + _ATOM_TEXT_PLAIN, + _ATOM_MAX, +}; + +struct _Atom +{ + const char* pName; + _ClipFormat formats; + ClipConverter convert; + ClipResponseHandler response; + ClipNotifyHandler notify; + Ecore_X_Atom atom; +}; + +Eina_Bool ClearClip(void* pData __UNUSED__, int type, void* pEvent); +Eina_Bool NotifyClip(void* pData __UNUSED__, int type, void* pEvent); + +Eina_Bool ConvertClipIntoTarget(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize); +Eina_Bool ConvertClipIntoText(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize); +Eina_Bool ConvertClipIntoHtml(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize); +Eina_Bool ConvertClipIntoEdje(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize); +Eina_Bool ConvertClipIntoUri(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize); +Eina_Bool ConvertClipIntoImage(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize); +Eina_Bool ConvertClipIntoVCard(char* pTarget, void* pData, int size, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize); + +int NotifyTarget(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify); +int NotifyText(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify); +int NotifyImage(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify); +int NotifyUri(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify); +int NotifyEdje(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify); +int NotifyHtml(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify); + +int RequestClip(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify); + +_Atom __atomList[_ATOM_MAX]; +_Clip __clipList[_CLIP_TYPE_MAX]; + +Eina_Bool +ClearClip(void* pData __UNUSED__, int type __UNUSED__, void* pEvent) +{ + SysTryReturn(NID_UI, pEvent, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + Ecore_X_Event_Selection_Clear* pE = (Ecore_X_Event_Selection_Clear*) pEvent; + Ecore_X_Window window = pE->win; + + _ClipType clipType = _CLIP_TYPE_SECONDARY; + __clipList[clipType].requestedFormat = (_ClipFormat)(_CLIP_FORMAT_TEXT|_CLIP_FORMAT_IMAGE); + + ecore_x_selection_secondary_request(window, ECORE_X_SELECTION_TARGET_TARGETS); + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool +ConvertClipIntoTarget(char* pTarget __UNUSED__, void* pData, int size__UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType, int* pTypeSize) +{ + return EINA_TRUE; + + /* + SysTryReturn(NID_UI, outData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, outSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pType, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pTypeSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + int index = *((int*) pData); + SysTryReturn(NID_UI, index < _CLIP_TYPE_MAX, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + int count = 0; + for (int i = 0; i < _ATOM_MAX; i++) + { + if (__clipList[index].format & __atomList[i].formats) + count++; + } + + // Make the atom list to be possible to return data. + Ecore_X_Atom* pAtoms = null; + if (count > 0) + { + pAtoms = (Ecore_X_Atom*) malloc(sizeof(Ecore_X_Atom) * count); + SysTryReturn(NID_UI, pAtoms, EINA_FALSE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + for (int i = 0, count = 0; i < _ATOM_MAX; i++) + { + if (__clipList[index].format & __atomList[i].formats) + pAtoms[count++] = __atomList[i].atom; + } + } + + *outData = pAtoms; + *outSize = count; + *pTypeSize = 32; + *pType = ECORE_X_ATOM_ATOM; + + return EINA_TRUE; + */ +} + +Eina_Bool +ConvertClipIntoText(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__) +{ + SysTryReturn(NID_UI, outData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, outSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + int index = *((int*) pData); + SysTryReturn(NID_UI, index < _CLIP_TYPE_MAX, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, __clipList[index].active, EINA_FALSE, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + if (__clipList[index].format & _CLIP_FORMAT_TEXT) + { + *outData = strdup(__clipList[index].pBuffer); + *outSize = strlen(__clipList[index].pBuffer); + } + + return EINA_TRUE; +} + +Eina_Bool +ConvertClipIntoHtml(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__) +{ + SysTryReturn(NID_UI, outData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, outSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + int index = *((int*) pData); + SysTryReturn(NID_UI, index < _CLIP_TYPE_MAX, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, __clipList[index].active, EINA_FALSE, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + if (__clipList[index].format & _CLIP_FORMAT_HTML) + { + *outData = strdup(__clipList[index].pBuffer); + *outSize = strlen(__clipList[index].pBuffer); + } + + return EINA_TRUE; +} + +Eina_Bool +ConvertClipIntoEdje(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__) +{ + return EINA_TRUE; +} + +Eina_Bool +ConvertClipIntoUri(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData, int* outSize, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__) +{ + SysTryReturn(NID_UI, outData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, outSize, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pData, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + int index = *((int*) pData); + SysTryReturn(NID_UI, index < _CLIP_TYPE_MAX, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, __clipList[index].active, EINA_FALSE, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + if (__clipList[index].format & _CLIP_FORMAT_IMAGE) + { + *outData = strdup(__clipList[index].pBuffer); + *outSize = strlen(__clipList[index].pBuffer); + } + + return EINA_TRUE; +} + +Eina_Bool +ConvertClipIntoImage(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData __UNUSED__, int* outSize __UNUSED__, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__) +{ + return EINA_TRUE; +} + +Eina_Bool +ConvertClipIntoVCard(char* pTarget __UNUSED__, void* pData, int size __UNUSED__, void** outData __UNUSED__, int* outSize __UNUSED__, Ecore_X_Atom* pType __UNUSED__, int* pTypeSize __UNUSED__) +{ + return EINA_TRUE; +} + +int +RequestClip(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify) +{ + return 0; +} + +Eina_Bool +OnClipboardClosed(void* pData __UNUSED__, int type, void* pEvent) +{ + SysTryReturn(NID_UI, pEvent, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + _Clipboard* pClipboard = _Clipboard::GetInstance(); + if (pClipboard) + { + bool visible = pClipboard->IsPopupVisible(); + + if (visible == true) + { + pClipboard->FireEvent(0, null); + } + } + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool +NotifyClip(void* pData __UNUSED__, int type, void* pEvent) +{ + SysTryReturn(NID_UI, pEvent, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + Ecore_X_Event_Selection_Notify* pE = (Ecore_X_Event_Selection_Notify*) pEvent; + + int i = 0; + for (i = 0; i < _CLIP_TYPE_MAX; i++) + { + if (__clipList[i].selection == pE->selection) + { + break; + } + } + + SysTryReturn(NID_UI, i < _CLIP_TYPE_MAX, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _Clip* pClip = __clipList + i; + for (i = 0; i < _ATOM_MAX; i++) + { + if (!strcmp(pE->target, __atomList[i].pName)) + { + if (__atomList[i].notify) + { + __atomList[i].notify(pClip, pE); + } + } + } + + return ECORE_CALLBACK_PASS_ON; +} + +int +NotifyTarget(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify) +{ + SysTryReturn(NID_UI, pClip, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pNotify, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + +#if !defined(MULTI_WINDOW) + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas->GetEcoreEvas()); +#else + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _Window* pWindow = pControlManager->GetCurrentFrame(); + SysTryReturn(NID_UI, pWindow, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _RootVisualElement* pRootVE = pWindow->GetRootVisualElement(); + SysTryReturn(NID_UI, pRootVE, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer()); + SysTryReturn(NID_UI, pLayer, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_Evas* pEE = pLayer->GetEcoreEvas(); + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pEE); +#endif + + Ecore_X_Atom dataType = 0; + char* pBuffer = null; + + if (pEcoreEvas->GetSelectedCbhmItem(&dataType, &pBuffer)) + { + free(pBuffer); + + const char* pHtmlAtomName = "text/html;charset=utf-8"; + Ecore_X_Atom htmlType = ecore_x_atom_get(pHtmlAtomName); + + if (dataType == htmlType) + { + pClip->request(window, pHtmlAtomName); + return ECORE_CALLBACK_PASS_ON; + } + } + + Ecore_X_Selection_Data_Targets* pTargets = (Ecore_X_Selection_Data_Targets*) (pNotify->data); + Ecore_X_Atom* pAtomList = (Ecore_X_Atom*) (pTargets->data.data); + + int i, j = 0; + for (j = (_ATOM_LISTING_ATOMS+1); j < _ATOM_MAX; j++) + { + SysLog(NID_UI, "[Clipboard] __atomList[%d].atom = %d", j, __atomList[j].atom); + + if (!(__atomList[j].formats & pClip->requestedFormat)) + { + continue; + } + + for (i = 0; i < pTargets->data.length; i++) + { + SysLog(NID_UI, "[Clipboard] pAtomList[%d] = %d", i, pAtomList[i]); + + if ((__atomList[j].atom == pAtomList[i]) && (__atomList[j].notify)) + { + if ((j == _ATOM_XELM) && (!(pClip->requestedFormat & _CLIP_FORMAT_MARKUP))) + { + continue; + } + + SysLog(NID_UI, "[Clipboard] go to __atomList[%d].atom = %d", j, __atomList[j].atom); + goto FOUND; + } + } + } + + return ECORE_CALLBACK_PASS_ON; + +FOUND: + pClip->request(window, __atomList[j].pName); + return ECORE_CALLBACK_PASS_ON; +} + +int +NotifyText(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify) +{ + SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data; + SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + pClip->bufferLength = (int) pData->length; + + char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1)); + if (pStr) + { + strncpy(pStr, (char*)pData->data, pClip->bufferLength); + pStr[pClip->bufferLength] = '\0'; + } + else + { + SysLog(NID_UI, "[Clipboard] pStr is null."); + return 0; + } + + pClip->pRetrievedBuffer = pStr; + + _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_TEXT, pClip->pRetrievedBuffer); + + return 0; +} + +int +NotifyImage(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify) +{ + SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data; + SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + pClip->bufferLength = (int) pData->length; + + char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1)); + if (pStr) + { + strncpy(pStr, (char*)pData->data, pClip->bufferLength); + pStr[pClip->bufferLength] = '\0'; + } + else + { + SysLog(NID_UI, "[Clipboard] pStr is null."); + return 0; + } + + pClip->pRetrievedBuffer = pStr; + + _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_IMAGE, pClip->pRetrievedBuffer); + + return 0; +} + +int +NotifyUri(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify) +{ + SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data; + SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + pClip->bufferLength = (int) pData->length; + + char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1)); + if (pStr) + { + strncpy(pStr, (char*)pData->data, pClip->bufferLength); + pStr[pClip->bufferLength] = '\0'; + } + else + { + SysLog(NID_UI, "[Clipboard] pStr is null."); + return 0; + } + + pClip->pRetrievedBuffer = pStr; + + _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_IMAGE, pClip->pRetrievedBuffer); + + return 0; +} + +int +NotifyEdje(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify) +{ + SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data; + SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + pClip->bufferLength = (int) pData->length; + + char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1)); + if (pStr) + { + strncpy(pStr, (char*)pData->data, pClip->bufferLength); + pStr[pClip->bufferLength] = '\0'; + } + else + { + SysLog(NID_UI, "[Clipboard] pStr is null."); + return 0; + } + + pClip->pRetrievedBuffer = pStr; + + _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_TEXT, pClip->pRetrievedBuffer); + + return 0; +} + +int +NotifyHtml(_Clip* pClip, Ecore_X_Event_Selection_Notify* pNotify) +{ + SysTryReturn(NID_UI, pClip, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + SysTryReturn(NID_UI, pNotify, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + Ecore_X_Selection_Data* pData = (Ecore_X_Selection_Data*) pNotify->data; + SysTryReturn(NID_UI, pData->data, 0, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + + pClip->bufferLength = (int) pData->length; + + char* pStr = (char*)malloc(sizeof(char) * (pClip->bufferLength + 1)); + if (pStr) + { + strncpy(pStr, (char*)pData->data, pClip->bufferLength); + pStr[pClip->bufferLength] = '\0'; + } + else + { + SysLog(NID_UI, "[Clipboard] pStr is null."); + return 0; + } + + pClip->pRetrievedBuffer = pStr; + + _Clipboard::GetInstance()->FireEvent(_CLIP_FORMAT_HTML, pClip->pRetrievedBuffer); + + return 0; +} +} // Anonymous + +namespace Tizen { namespace Ui +{ + +_EcoreEvas* +_EcoreEvas::CreateInstanceN(void) +{ + _EcoreEvas* pEcoreEvas = new (std::nothrow) _EcoreEvas; + SysTryReturn(NID_UI, pEcoreEvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pEcoreEvas; + +CATCH: + delete pEcoreEvas; + return null; +} + +_EcoreEvas::_EcoreEvas(void) + : __pEvas(null) + , __pForegroundWindow(null) + , __pFrame(null) + , __pXWindowVisibility(null) + , __pClientMessageHandler(null) + , __pClearClip(null) + , __pNotifyClip(null) + , __pClipboardClosed(null) + , __pWindowPropertyChanged(null) + , __pActiveWindowEvent(null) + , __count(0) + , __pRootVE(null) + , __pLayer(null) + , __changeBounds(true) + , __openClipboard(false) +{ +#if !defined(MULTI_WINDOW) + CreateWindow(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, __pForegroundWindow, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Auto-Rotation + //int ret = 0; + + r = SetIndicatorShowState(true); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + evas_object_event_callback_add(__pForegroundWindow, EVAS_CALLBACK_DEL, OnWindowDeleted, NULL); + SysTryCatch(NID_UI, evas_alloc_error() == EVAS_ALLOC_ERROR_NONE, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + __pXWindowVisibility = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, OnVisibilityChanged, (void*) this); + SysTryCatch(NID_UI, __pXWindowVisibility, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, OnClientMessageReceived, NULL); + + ecore_x_event_mask_set(ecore_x_window_root_first_get(), ECORE_X_EVENT_MASK_WINDOW_CONFIGURE); + ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, OnAccessibilitySettingMessageReceived, NULL); + ecore_x_event_mask_set(ecore_x_window_root_first_get(), ECORE_X_EVENT_MASK_WINDOW_PROPERTY); + + _pEvas = this; + + GetEcoreEvasMgr()->SetEcoreEvas(*this); + + r = InitializeAtomList(); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + // Auto-Rotation + //ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED, OnAutoRotationChanged, NULL); + //SysTryCatch(NID_UI, ret == 0, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + SetLastResult(E_SUCCESS); + + return; + +CATCH: + evas_object_del(__pForegroundWindow); + __pForegroundWindow = null; + + if (__pXWindowVisibility) + { + ecore_event_handler_del(__pXWindowVisibility); + __pXWindowVisibility = null; + } + + if (__pClientMessageHandler) + { + ecore_event_handler_del(__pClientMessageHandler); + __pClientMessageHandler = null; + } +#else + __pXWindowVisibility = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, OnVisibilityChanged, (void*) this); + SysTryReturnVoidResult(NID_UI, __pXWindowVisibility, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, OnClientMessageReceived, NULL); + + ecore_x_event_mask_set(ecore_x_window_root_first_get(), ECORE_X_EVENT_MASK_WINDOW_CONFIGURE); + ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, OnAccessibilitySettingMessageReceived, NULL); + ecore_x_event_mask_set(ecore_x_window_root_first_get(), ECORE_X_EVENT_MASK_WINDOW_PROPERTY); + + _pEvas = this; + + GetEcoreEvasMgr()->SetEcoreEvas(*this); + + // Auto-Rotation + //int ret = 0; + + result r = InitializeAtomList(); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + // Auto-Rotation + //ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED, OnAutoRotationChanged, NULL); + //SysTryCatch(NID_UI, ret == 0, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + SetLastResult(E_SUCCESS); + + return; + +CATCH: + if (__pXWindowVisibility) + { + ecore_event_handler_del(__pXWindowVisibility); + __pXWindowVisibility = null; + } +#endif +} + +_EcoreEvas::~_EcoreEvas(void) +{ + if (__pXWindowVisibility) + { + ecore_event_handler_del(__pXWindowVisibility); + __pXWindowVisibility = null; + } + + if (__pClientMessageHandler) + { + ecore_event_handler_del(__pClientMessageHandler); + __pClientMessageHandler = null; + } + + for (int i = 0; i < _ATOM_MAX; i++) + { + if (__atomList[i].atom) + { + ecore_x_selection_converter_atom_del(__atomList[i].atom); + } + } + + if (__pClearClip) + { + ecore_event_handler_del(__pClearClip); + __pClearClip = null; + } + + if (__pNotifyClip) + { + ecore_event_handler_del(__pNotifyClip); + __pNotifyClip = null; + } + + if (__pClipboardClosed) + { + ecore_event_handler_del(__pClipboardClosed); + __pClipboardClosed = null; + } + + if (__pWindowPropertyChanged) + { + ecore_event_handler_del(__pWindowPropertyChanged); + __pWindowPropertyChanged = null; + } + + if (__pActiveWindowEvent) + { + delete __pActiveWindowEvent; + __pActiveWindowEvent = null; + } + + if(__pLayer) + { + delete __pLayer; + __pLayer = null; + } + __pRootVE = null; + + // Auto-Rotation + //runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED); +} + +void +_EcoreEvas::RotateWindow(int orientation) +{ + bool rotatePartial = false; + + if (GetFloatingMode() == true) + { + rotatePartial = true; + } + + _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>(GetFrame())); + if (pFrame) + { + FrameShowMode showMode = pFrame->GetShowMode(); + if (showMode != FRAME_SHOW_MODE_FULL_SCREEN) + { + rotatePartial = true; + } + } + + int rootW = 0; + int rootH = 0; + ecore_x_window_size_get(ecore_x_window_root_get(GetXWindow()), &rootW, &rootH); + + if (rotatePartial == false) + { + ecore_evas_rotation_with_resize_set(GetEcoreEvas(), orientation); + + evas_object_move(__pForegroundWindow, 0, 0); + + if ((orientation == 0) || (orientation == 180)) + { + evas_object_resize(__pForegroundWindow, rootW, rootH); + } + else + { + evas_object_resize(__pForegroundWindow, rootH, rootW); + } + } + else + { + ecore_evas_rotation_set(GetEcoreEvas(), orientation); + + if (!pFrame) + { + return; + } + + Rectangle frameBounds = _CoordinateSystemUtils::Transform(pFrame->GetBounds()); + int rotate = ecore_evas_rotation_get(GetEcoreEvas()); + + int winX = frameBounds.x; + int winY = frameBounds.y; + + switch (rotate) + { + case 270: + winX = rootW - frameBounds.y - frameBounds.height; + winY = frameBounds.x; + break; + case 90: + winX = frameBounds.y; + winY = rootH - frameBounds.x - frameBounds.width; + break; + case 180: + winX = rootW - frameBounds.x - frameBounds.width; + winY = rootH - frameBounds.y - frameBounds.height; + break; + default: + break; + } + + evas_object_move(__pForegroundWindow, winX, winY); + evas_object_resize(__pForegroundWindow, frameBounds.width, frameBounds.height); + + SysLog(NID_UI, "The window is moved to (%d, %d) and is resized to (%d, %d) with %d degree by rotating screen." , winX, winY, frameBounds.width, frameBounds.height, rotate); + } +} + +void +_EcoreEvas::RotateWindow(const _Window& window, int orientation) +{ + _EflLayer* pLayer = GetEflLayer(window); + + if (!pLayer) + { + return; + } + + bool rotatePartial = true; + + _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Window*>(&window)); + if (pFrame) + { + FrameShowMode showMode = pFrame->GetShowMode(); + if (showMode == FRAME_SHOW_MODE_FULL_SCREEN) + { + rotatePartial = false; + } + } + +#if defined(MULTI_WINDOW) + _Window* pWindow = const_cast<_Window*>(&window); + if (pWindow->IsLayoutChangable() == true) + { + rotatePartial = false; + } +#endif + + Evas_Object* pWinObj = pLayer->GetElmWin(); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + + int rootW = 0; + int rootH = 0; + ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH); + + if (rotatePartial == false) + { + ecore_evas_rotation_with_resize_set(pEcoreEvas, orientation); + + evas_object_move(pWinObj, 0, 0); + + if ((orientation == 0) || (orientation == 180)) + { + evas_object_resize(pWinObj, rootW, rootH); + } + else + { + evas_object_resize(pWinObj, rootH, rootW); + } + } + else + { + ecore_evas_rotation_set(pEcoreEvas, orientation); + + Rectangle winBounds = _CoordinateSystemUtils::Transform(window.GetBounds()); + int rotate = ecore_evas_rotation_get(pEcoreEvas); + + int winX = winBounds.x; + int winY = winBounds.y; + + switch (rotate) + { + case 270: + winX = rootW - winBounds.y - winBounds.height; + winY = winBounds.x; + break; + case 90: + winX = winBounds.y; + winY = rootH - winBounds.x - winBounds.width; + break; + case 180: + winX = rootW - winBounds.x - winBounds.width; + winY = rootH - winBounds.y - winBounds.height; + break; + default: + break; + } + + evas_object_move(pWinObj, winX, winY); + evas_object_resize(pWinObj, winBounds.width, winBounds.height); + } +} + +_EflLayer* +_EcoreEvas::GetEflLayer(const _Window& window) const +{ + _RootVisualElement* pRootVisualElement = null; + +#if !defined(MULTI_WINDOW) + if (!window.IsSystemWindow()) + { + return null; + } + + pRootVisualElement = (&window)->GetRootVisualElement(); + SysTryReturn(NID_UI, pRootVisualElement, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); +#else + pRootVisualElement = window.GetRootVisualElement(); + if (!pRootVisualElement) + { + SysLog(NID_UI, "The root visual element is null."); + return null; + } +#endif + + _EflLayer* pEflLayer = static_cast<_EflLayer*>(pRootVisualElement->GetNativeLayer()); + if (!pEflLayer) + { + SysLog(NID_UI, "The efl layer is null."); + return null; + } + + return pEflLayer; +} + +bool +_EcoreEvas::GetFloatingMode(void) const +{ + SysTryReturn(NID_UI, __pForegroundWindow, false, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Eina_Bool ret = elm_win_floating_mode_get(__pForegroundWindow); + + SetLastResult(E_SUCCESS); + + return (ret ? true : false); +} + +bool +_EcoreEvas::GetFloatingMode(const _Window& window) const +{ + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Evas_Object* pWinObj = pLayer->GetElmWin(); + SysTryReturn(NID_UI, pWinObj, false, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Eina_Bool ret = elm_win_floating_mode_get(pWinObj); + + SetLastResult(E_SUCCESS); + + return (ret ? true : false); +} + +void +_EcoreEvas::AddActiveWindowEventListener(const _IActiveWindowEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pActiveWindowEvent == null) + { + __pActiveWindowEvent = _ActiveWindowEvent::CreateInstanceN(); + + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pActiveWindowEvent->AddListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __count++; + + Ecore_X_Window* pRoots = null; + int num = 0; + + pRoots = ecore_x_window_root_list(&num); + + for (int i = 0; i < num; i++) + { + Display* pDisplay = XOpenDisplay(NULL); + XSelectInput(pDisplay, pRoots[i], PropertyChangeMask); + } + + if (!__pWindowPropertyChanged) + { + __pWindowPropertyChanged = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, OnPropertyChanged, (void*) this); + SysTryReturnVoidResult(NID_UI, __pWindowPropertyChanged, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + } + + SetLastResult(E_SUCCESS); +} + +void +_EcoreEvas::RemoveActiveWindowEventListener(const _IActiveWindowEventListener& listener) +{ + SysTryReturnVoidResult(NID_UI, __pActiveWindowEvent, E_OBJ_NOT_FOUND, "The specified listener doesn't exist in the event listener list."); + + result r = __pActiveWindowEvent->RemoveListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __count--; + + if (__count == 0) + { + ecore_event_handler_del(__pWindowPropertyChanged); + __pWindowPropertyChanged = null; + } + + SetLastResult(E_SUCCESS); +} + +void +_EcoreEvas::FireActiveWindowEvent(unsigned int xid, int pid, char* pAppName) +{ + if (!__pActiveWindowEvent) + { + return; + } + + IEventArg* pArg = _ActiveWindowEvent::CreateActiveWindowEventArgN(xid, pid, pAppName); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, pArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pActiveWindowEvent->Fire(*pArg); +} + +unsigned int +_EcoreEvas::GetActiveWindow(void) +{ + Ecore_X_Window* pRoots = null; + int num = 0; + + pRoots = ecore_x_window_root_list(&num); + Ecore_X_Atom activeAtom = ecore_x_atom_get("_NET_ACTIVE_WINDOW"); + + Ecore_X_Window activeWin = 0; + ecore_x_window_prop_window_get(pRoots[0], activeAtom, &activeWin, 1); + + free(pRoots); + + return activeWin; +} + +int +_EcoreEvas::GetProcessId(unsigned int window) +{ + int pid = 0; + Eina_Bool ret = ecore_x_netwm_pid_get(window, &pid); + + if (ret != EINA_TRUE) + { + return 0; + } + + return pid; +} + +void +_EcoreEvas::SetOwner(NativeWindowHandle ownee, NativeWindowHandle owner) +{ + ecore_x_icccm_transient_for_unset(ownee); + ecore_x_icccm_transient_for_set(ownee, owner); +} + +void +_EcoreEvas::ActivateWindow(const _Window& window) +{ +#if !defined(MULTI_WINDOW) + Ecore_Evas* pEcoreEvas = GetEcoreEvas(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, pEcoreEvas, r, "[%s] Propagating.", GetErrorMessage(r)); +#else + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred."); +#endif + + ecore_evas_activate(pEcoreEvas); +} + +void +_EcoreEvas::SetRenderBackend(_RenderBackend backend) +{ +#if defined(MULTI_WINDOW) + switch (backend) + { + case _RENDER_BACKEND_SW: + elm_config_preferred_engine_set("software_x11"); + break; + case _RENDER_BACKEND_GL: + elm_config_preferred_engine_set("opengl_x11"); + break; + case _RENDER_BACKEND_DEFAULT: + // fall through + default: + elm_config_preferred_engine_set(NULL); + break; + } +#endif +} + +_RenderBackend +_EcoreEvas::GetRenderBackend(void) +{ + _RenderBackend backend = _RENDER_BACKEND_DEFAULT; + + const char* pEngine = elm_config_preferred_engine_get(); + + if (pEngine == NULL) + { + backend = _RENDER_BACKEND_DEFAULT; + } + else if (strcmp(pEngine, "software_x11") == 0) + { + backend = _RENDER_BACKEND_SW; + } + else if (strcmp(pEngine, "opengl_x11") == 0) + { + backend = _RENDER_BACKEND_GL; + } + + return backend; +} + +#if !defined(MULTI_WINDOW) +result +_EcoreEvas::CopyClip(_ClipFormat format, const char* pChar) +{ + SysTryReturn(NID_UI, IsValidClipFormat(format), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The data type is invalid."); + SysTryReturn(NID_UI, pChar, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The data is invalid."); + + Ecore_X_Atom dataType = 0; + + switch (format) + { + case _CLIP_FORMAT_TEXT: + dataType = ecore_x_atom_get("UTF8_STRING"); + break; + case _CLIP_FORMAT_IMAGE: + dataType = ecore_x_atom_get("text/uri"); + break; + case _CLIP_FORMAT_HTML: + dataType = ecore_x_atom_get("text/html;charset=utf-8"); + break; + default: + break; + } + + SetCbhmItem(GetXWindow(), dataType, (char*)pChar); + + return E_SUCCESS; +} + +bool +_EcoreEvas::RetrieveClipN(int index, int* format, char** pData) +{ + Ecore_X_Atom dataType = 0; + + GetCbhmItem(index, &dataType, pData); + + if ((dataType == ecore_x_atom_get("UTF8_STRING")) || (dataType == ecore_x_atom_get("application/x-elementary-markup"))) + { + *format = _CLIP_FORMAT_TEXT; + } + else if (dataType == ecore_x_atom_get("text/uri")) + { + *format = _CLIP_FORMAT_IMAGE; + } + else if (dataType == ecore_x_atom_get("text/html;charset=utf-8")) + { + *format = _CLIP_FORMAT_HTML; + } + + if (*pData == null) + { + return false; + } + + return true; +} + +int +_EcoreEvas::GetClipCount(void) const +{ + int count = GetCbhmItemCount(); + + return count; +} + +void +_EcoreEvas::OpenClipboard(unsigned long clipFormats) +{ + Ecore_X_Window window = GetXWindow(); + SysLog(NID_UI, "[Clipboard] window = 0x%x", window); + + ecore_x_selection_secondary_set(window, "", 1); + + if (_CLIP_FORMAT_IMAGE & clipFormats) + { + SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_SHOW_ALL); + } + else + { + SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_SHOW); + } + + __openClipboard = true; +} + +void +_EcoreEvas::CloseClipboard(void) +{ + __openClipboard = false; + SendCbhmMessage(GetXWindow(), ATOM_CBHM_CLIPBOARD_HIDE); +} + +bool +_EcoreEvas::IsClipboardOpened(void) +{ + return __openClipboard; +} + +result +_EcoreEvas::SetEventPropagation(const _Control& control, bool enable) +{ + // Get _EflNode of a control. + _EflNode* pEflNode = dynamic_cast<_EflNode*>(control.GetVisualElement()->GetNativeNode()); + SysTryReturn(NID_UI, pEflNode, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + // Get a evas object. + Evas_Object* pEvasObject = (Evas_Object*) pEflNode->GetGroupContainer(); + SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + // Set the propagation. + evas_object_propagate_events_set(pEvasObject, (enable ? EINA_TRUE : EINA_FALSE)); + + return E_SUCCESS; +} + +result +_EcoreEvas::SetFocus(const _Control& control, bool focus) +{ + // Get _EflNode of a control. + _EflNode* pEflNode = dynamic_cast<_EflNode*>(control.GetVisualElement()->GetNativeNode()); + SysTryReturn(NID_UI, pEflNode, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + // Get a evas object. + Evas_Object* pEvasObject = (Evas_Object*) pEflNode->GetGroupContainer(); + SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + // Set the focus. + evas_object_focus_set(pEvasObject, (focus ? EINA_TRUE : EINA_FALSE)); + + return E_SUCCESS; +} + +result +_EcoreEvas::SetIndicatorShowState(bool showState) +{ + Ecore_Evas* pEcoreEvas = GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + + if (showState) + { + Ecore_X_Illume_Indicator_State state = ecore_x_e_illume_indicator_state_get(window); + + bool showState = true; + if (state == ECORE_X_ILLUME_INDICATOR_STATE_OFF) + { + showState = false; + } + + ecore_x_e_illume_indicator_state_set(window, ECORE_X_ILLUME_INDICATOR_STATE_ON); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + if (pTouchManager && showState == false) + { + pTouchManager->ResetTouchInfo(); + } + } + else + { + ecore_x_e_illume_indicator_state_set(window, ECORE_X_ILLUME_INDICATOR_STATE_OFF); + } + + return E_SUCCESS; +} + +void +_EcoreEvas::SetFrame(const _Control& control) +{ + __pFrame = const_cast<_Control*>(&control); +} + +bool +_EcoreEvas::GetIndicatorShowState(void) const +{ + Ecore_Evas* pEcoreEvas = GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, false, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + + // Get the state. + Ecore_X_Illume_Indicator_State state = ecore_x_e_illume_indicator_state_get(window); + + // Convert. + bool showState = true; + if (state == ECORE_X_ILLUME_INDICATOR_STATE_ON) + { + showState = true; + } + else if (state == ECORE_X_ILLUME_INDICATOR_STATE_OFF) + { + showState = false; + } + + return showState; +} + +Rectangle +_EcoreEvas::GetIndicatorBounds(void) const +{ + Ecore_Evas* pEcoreEvas = GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, Rectangle(0, 0, 0, 0), E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + // Get a root window. + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + Ecore_X_Window rootWindow = (Ecore_X_Window) ecore_x_window_root_get(window); + + // Get the bounds of a indicator. + int x = 0; + int y = 0; + int width = 0; + int height = 0; + bool ret = false; + ret = ecore_x_e_illume_indicator_geometry_get(rootWindow, &x, &y, &width, &height); + SysTryReturn(NID_UI, ret == true, Rectangle(0, 0, 0, 0), E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + SetLastResult(E_SUCCESS); + + return Rectangle(x, y, width, height); +} + +result +_EcoreEvas::SetIndicatorOpacity(_IndicatorOpacity opacity) +{ + Ecore_Evas* pEcoreEvas = GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + + // Convert. + Ecore_X_Illume_Indicator_Opacity_Mode mode = ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN; + switch (opacity) + { + case _INDICATOR_OPACITY_UNKNOWN: + mode = ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN; + break; + case _INDICATOR_OPACITY_OPAQUE: + mode = ECORE_X_ILLUME_INDICATOR_OPAQUE; + break; + case _INDICATOR_OPACITY_TRANSLUCENT: + mode = ECORE_X_ILLUME_INDICATOR_TRANSLUCENT; + break; + case _INDICATOR_OPACITY_TRANSPARENT: + mode = ECORE_X_ILLUME_INDICATOR_TRANSPARENT; + break; + default: + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + return E_INVALID_ARG; + } + + // Set the opacity of a indicator. + ecore_x_e_illume_indicator_opacity_set(window, mode); + + return E_SUCCESS; +} + +_IndicatorOpacity +_EcoreEvas::GetIndicatorOpacity(void) const +{ + Ecore_Evas* pEcoreEvas = GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, _INDICATOR_OPACITY_UNKNOWN, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + // Get the opacity of a indicator. + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + Ecore_X_Illume_Indicator_Opacity_Mode mode = ecore_x_e_illume_indicator_opacity_get(window); + + // Convert. + _IndicatorOpacity opacity = _INDICATOR_OPACITY_UNKNOWN; + switch (mode) + { + case ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN: + opacity = _INDICATOR_OPACITY_UNKNOWN; + break; + case ECORE_X_ILLUME_INDICATOR_OPAQUE: + opacity = _INDICATOR_OPACITY_OPAQUE; + break; + case ECORE_X_ILLUME_INDICATOR_TRANSLUCENT: + opacity = _INDICATOR_OPACITY_TRANSLUCENT; + break; + case ECORE_X_ILLUME_INDICATOR_TRANSPARENT: + opacity = _INDICATOR_OPACITY_TRANSPARENT; + break; + default: + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + return _INDICATOR_OPACITY_UNKNOWN; + } + + SetLastResult(E_SUCCESS); + + return opacity; +} + +result +_EcoreEvas::SetFloatingMode(bool enable) +{ + SysTryReturn(NID_UI, __pForegroundWindow, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + elm_win_floating_mode_set(__pForegroundWindow, (enable ? EINA_TRUE : EINA_FALSE)); + + return E_SUCCESS; +} + +Evas* +_EcoreEvas::GetEvas(void) const +{ + return __pEvas; +} + +Ecore_Evas* +_EcoreEvas::GetEcoreEvas(void) const +{ + Ecore_Evas* pEcoreEvas = ecore_evas_ecore_evas_get(__pEvas); + SysTryReturn(NID_UI, pEcoreEvas, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + SetLastResult(E_SUCCESS); + + return pEcoreEvas; +} + +Evas_Object* +_EcoreEvas::GetWindowObject(void) const +{ + return __pForegroundWindow; +} + +Ecore_X_Window +_EcoreEvas::GetXWindow(void) const +{ + Ecore_Evas* pEcore_Evas = GetEcoreEvas(); + result r = GetLastResult(); + SysTryReturn(NID_UI, pEcore_Evas, 0, r, "[%s] Propagating.", GetErrorMessage(r)); + + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pEcore_Evas); + + SetLastResult(E_SUCCESS); + + return window; +} + +void +_EcoreEvas::AllowSetWindowBounds(bool allow) +{ + __changeBounds = allow; +} + +void +_EcoreEvas::SetWindowLevel(_WindowLevel level) +{ + Ecore_X_Window window = GetXWindow(); + SysTryReturnVoidResult(NID_UI, window != 0, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + if (level == _WINDOW_LEVEL_NORMAL) + { + ecore_x_netwm_window_type_set(window, ECORE_X_WINDOW_TYPE_NORMAL); + } + else if (level == _WINDOW_LEVEL_NOTIFICATION_HIGH) + { + ecore_x_netwm_window_type_set(window, ECORE_X_WINDOW_TYPE_NOTIFICATION); + utilx_set_system_notification_level((Display*)ecore_x_display_get(), window, UTILX_NOTIFICATION_LEVEL_HIGH); + } + else if (level == _WINDOW_LEVEL_NOTIFICATION_MIDDLE) + { + ecore_x_netwm_window_type_set(window, ECORE_X_WINDOW_TYPE_NOTIFICATION); + utilx_set_system_notification_level((Display*)ecore_x_display_get(), window, UTILX_NOTIFICATION_LEVEL_NORMAL); + } + + SetLastResult(E_SUCCESS); +} + +_WindowLevel +_EcoreEvas::GetWindowLevel(void) const +{ + Ecore_X_Window window = GetXWindow(); + SysTryReturn(NID_UI, window != 0, _WINDOW_LEVEL_UNKNOWN, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window_Type type = ECORE_X_WINDOW_TYPE_UNKNOWN; + ecore_x_netwm_window_type_get(window, &type); + + _WindowLevel winLevel = _WINDOW_LEVEL_UNKNOWN; + if (type == ECORE_X_WINDOW_TYPE_NORMAL) + { + winLevel = _WINDOW_LEVEL_NORMAL; + } + else if (type == ECORE_X_WINDOW_TYPE_NOTIFICATION) + { + Utilx_Notification_Level notificationLevel = utilx_get_system_notification_level((Display*)ecore_x_display_get(), window); + + if (notificationLevel == UTILX_NOTIFICATION_LEVEL_HIGH) + { + winLevel = _WINDOW_LEVEL_NOTIFICATION_HIGH; + } + else if (notificationLevel == UTILX_NOTIFICATION_LEVEL_NORMAL) + { + winLevel = _WINDOW_LEVEL_NOTIFICATION_MIDDLE; + } + } + + SetLastResult(E_SUCCESS); + + return winLevel; +} + +void +_EcoreEvas::SetWindowAlwaysOnTop(bool alwaysOnTop) +{ + Ecore_Evas* pEcoreEvas = GetEcoreEvas(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, pEcoreEvas, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (alwaysOnTop == true) + { + ecore_evas_layer_set(pEcoreEvas, 5); + } + else + { + ecore_evas_layer_set(pEcoreEvas, 4); + } +} + +void +_EcoreEvas::SetWindowAlwaysAtBottom(bool alwaysAtBottom) +{ + Ecore_Evas* pEcoreEvas = GetEcoreEvas(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, pEcoreEvas, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (alwaysAtBottom == true) + { + ecore_evas_layer_set(pEcoreEvas, 3); + } + else + { + ecore_evas_layer_set(pEcoreEvas, 4); + } +} + +void +_EcoreEvas::SetWindowBounds(const Rectangle& bounds) +{ + if (__changeBounds == false) + { + return; + } + + // Decide between full and partial. + bool partialScreen = false; + + if (GetFloatingMode() == true) + { + partialScreen = true; + } + + _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>(GetFrame())); + if (pFrame) + { + FrameShowMode showMode = pFrame->GetShowMode(); + if (showMode != FRAME_SHOW_MODE_FULL_SCREEN) + { + partialScreen = true; + } + } + + int rootW = 0; + int rootH = 0; + ecore_x_window_size_get(ecore_x_window_root_get(GetXWindow()), &rootW, &rootH); + + int rotate = ecore_evas_rotation_get(GetEcoreEvas()); + + if (partialScreen == false) + { + // Resize full screen. + evas_object_move(__pForegroundWindow, 0, 0); + + if ((rotate == 0) || (rotate == 180)) + { + evas_object_resize(__pForegroundWindow, rootW, rootH); + } + else + { + evas_object_resize(__pForegroundWindow, rootH, rootW); + } + } + else + { + // Resize partial screen. + Evas_Object* pWinObject = GetWindowObject(); + SysTryReturnVoidResult(NID_UI, pWinObject, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Rectangle winBounds = _CoordinateSystemUtils::Transform(bounds); + + int winX = winBounds.x; + int winY = winBounds.y; + + switch (rotate) + { + case 270: + winX = rootW - winBounds.y - winBounds.height; + winY = winBounds.x; + break; + case 90: + winX = winBounds.y; + winY = rootH - winBounds.x - winBounds.width; + break; + case 180: + winX = rootW - winBounds.x - winBounds.width; + winY = rootH - winBounds.y - winBounds.height; + break; + default: + break; + } + + evas_object_move(pWinObject, winX, winY); + evas_object_resize(pWinObject, winBounds.width, winBounds.height); + + //SysLog(NID_UI, "The window is moved to (%d, %d) and is resized to (%d, %d) with %d degree by setting bounds." , winX, winY, winBounds.width, winBounds.height, rotate); + } + + // [SLP] + Rectangle rectangle = GetIndicatorBounds(); + + SetLastResult(E_SUCCESS); +} + +void +_EcoreEvas::SetWindowVisibleState(bool visibleState) +{ + Evas_Object* pWindowObject = GetWindowObject(); + SysTryReturnVoidResult(NID_UI, pWindowObject, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + if (visibleState) + { + evas_object_show(pWindowObject); + } + else + { + evas_object_hide(pWindowObject); + } + + SetLastResult(E_SUCCESS); +} + +const _Control* +_EcoreEvas::GetFrame(void) const +{ + return __pFrame; +} + +_RootVisualElement* +_EcoreEvas::GetRootVisualElement(void)const +{ + return __pRootVE; +} +#else +result +_EcoreEvas::CopyClip(_ClipFormat format, const char* pChar) +{ + SysTryReturn(NID_UI, IsValidClipFormat(format), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The data type is invalid."); + SysTryReturn(NID_UI, pChar, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The data is invalid."); + + Ecore_X_Atom dataType = 0; + + switch (format) + { + case _CLIP_FORMAT_TEXT: + dataType = ecore_x_atom_get("UTF8_STRING"); + break; + case _CLIP_FORMAT_IMAGE: + dataType = ecore_x_atom_get("text/uri"); + break; + case _CLIP_FORMAT_HTML: + dataType = ecore_x_atom_get("text/html;charset=utf-8"); + break; + default: + break; + } + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + + _Window* pWindow = pControlManager->GetCurrentFrame(); + if (!pWindow) + { + return E_SUCCESS; + } + + _EflLayer* pLayer = GetEflLayer(*pWindow); + if (!pLayer) + { + return E_SUCCESS; + } + + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas()); + SysAssert(window); + + SetCbhmItem(window, dataType, (char*)pChar); + + return E_SUCCESS; +} + +bool +_EcoreEvas::RetrieveClipN(int index, int* format, char** pData) +{ + Ecore_X_Atom dataType = 0; + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + + _Window* pWindow = pControlManager->GetCurrentFrame(); + if (!pWindow) + { + return false; + } + + _EflLayer* pLayer = GetEflLayer(*pWindow); + if (!pLayer) + { + return false; + } + + GetCbhmItem(index, &dataType, pData); + + if ((dataType == ecore_x_atom_get("UTF8_STRING")) + ||(dataType == ecore_x_atom_get("application/x-elementary-markup"))) + { + *format = _CLIP_FORMAT_TEXT; + } + else if (dataType == ecore_x_atom_get("text/uri")) + { + *format = _CLIP_FORMAT_IMAGE; + } + else if (dataType == ecore_x_atom_get("text/html;charset=utf-8")) + { + *format = _CLIP_FORMAT_HTML; + } + + if (*pData == null) + { + return false; + } + + return true; +} + +int +_EcoreEvas::GetClipCount(void) const +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + + _Window* pWindow = pControlManager->GetCurrentFrame(); + if (!pWindow) + { + return 0; + } + + _EflLayer* pLayer = GetEflLayer(*pWindow); + if (!pLayer) + { + return 0; + } + + int count = GetCbhmItemCount(); + + return count; +} + +void +_EcoreEvas::OpenClipboard(unsigned long clipFormats) +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + + _Window* pWindow = pControlManager->GetCurrentFrame(); + if (!pWindow) + { + return; + } + + _EflLayer* pLayer = GetEflLayer(*pWindow); + if (!pLayer) + { + return; + } + + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas()); + SysAssert(window); + + ecore_x_selection_secondary_set(window, "", 1); + + if (_CLIP_FORMAT_IMAGE & clipFormats) + { + SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_SHOW_ALL); + } + else + { + SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_SHOW); + } + + __openClipboard = true; +} + +void +_EcoreEvas::CloseClipboard(void) +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + + _Window* pWindow = pControlManager->GetCurrentFrame(); + if (!pWindow) + { + return; + } + + _EflLayer* pLayer = GetEflLayer(*pWindow); + if (!pLayer) + { + return; + } + + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas()); + SysAssert(window); + + __openClipboard = false; + SendCbhmMessage(window, ATOM_CBHM_CLIPBOARD_HIDE); +} + +bool +_EcoreEvas::IsClipboardOpened(void) +{ + return __openClipboard; +} + +result +_EcoreEvas::SetEventPropagation(const _Control& control, bool enable) +{ + _EflNode* pEflNode = dynamic_cast<_EflNode*>(control.GetVisualElement()->GetNativeNode()); + SysTryReturn(NID_UI, pEflNode, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Evas_Object* pEvasObject = (Evas_Object*) pEflNode->GetGroupContainer(); + SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + evas_object_propagate_events_set(pEvasObject, (enable ? EINA_TRUE : EINA_FALSE)); + + return E_SUCCESS; +} + +result +_EcoreEvas::SetFocus(const _Control& control, bool focus) +{ + _EflNode* pEflNode = dynamic_cast<_EflNode*>(control.GetVisualElement()->GetNativeNode()); + SysTryReturn(NID_UI, pEflNode, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Evas_Object* pEvasObject = (Evas_Object*) pEflNode->GetGroupContainer(); + SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + evas_object_focus_set(pEvasObject, (focus ? EINA_TRUE : EINA_FALSE)); + + return E_SUCCESS; +} + +result +_EcoreEvas::SetIndicatorShowState(const _Window& window, bool showState) +{ + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturn(NID_UI, pLayer, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + + if (showState) + { + ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_ON); + } + else + { + ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_OFF); + } + + return E_SUCCESS; +} + +bool +_EcoreEvas::GetIndicatorShowState(const _Window& window) const +{ + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturn(NID_UI, pLayer, false, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, false, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + Ecore_X_Illume_Indicator_State state = ecore_x_e_illume_indicator_state_get(win); + + bool showState = true; + if (state == ECORE_X_ILLUME_INDICATOR_STATE_ON) + { + showState = true; + } + else if (state == ECORE_X_ILLUME_INDICATOR_STATE_OFF) + { + showState = false; + } + + return showState; +} + +Rectangle +_EcoreEvas::GetIndicatorBounds(const _Window& window) const +{ + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturn(NID_UI, pLayer, Rectangle(0, 0, 0, 0), E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, Rectangle(0, 0, 0, 0), E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + Ecore_X_Window rootWin = (Ecore_X_Window) ecore_x_window_root_get(win); + + int x = 0; + int y = 0; + int width = 0; + int height = 0; + + bool ret = false; + ret = ecore_x_e_illume_indicator_geometry_get(rootWin, &x, &y, &width, &height); + SysTryReturn(NID_UI, ret == true, Rectangle(0, 0, 0, 0), E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + SetLastResult(E_SUCCESS); + + return Rectangle(x, y, width, height); +} + +result +_EcoreEvas::SetIndicatorOpacity(const _Window& window, _IndicatorOpacity opacity) +{ + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturn(NID_UI, pLayer, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + + Ecore_X_Illume_Indicator_Opacity_Mode mode = ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN; + switch (opacity) + { + case _INDICATOR_OPACITY_UNKNOWN: + mode = ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN; + break; + case _INDICATOR_OPACITY_OPAQUE: + mode = ECORE_X_ILLUME_INDICATOR_OPAQUE; + break; + case _INDICATOR_OPACITY_TRANSLUCENT: + mode = ECORE_X_ILLUME_INDICATOR_TRANSLUCENT; + break; + case _INDICATOR_OPACITY_TRANSPARENT: + mode = ECORE_X_ILLUME_INDICATOR_TRANSPARENT; + break; + default: + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] The specified data is not valid."); + return E_INVALID_ARG; + } + + ecore_x_e_illume_indicator_opacity_set(win, mode); + + return E_SUCCESS; +} + +_IndicatorOpacity +_EcoreEvas::GetIndicatorOpacity(const _Window& window) const +{ + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturn(NID_UI, pLayer, _INDICATOR_OPACITY_UNKNOWN, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, _INDICATOR_OPACITY_UNKNOWN, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + Ecore_X_Illume_Indicator_Opacity_Mode mode = ecore_x_e_illume_indicator_opacity_get(win); + + _IndicatorOpacity opacity = _INDICATOR_OPACITY_UNKNOWN; + switch (mode) + { + case ECORE_X_ILLUME_INDICATOR_OPACITY_UNKNOWN: + opacity = _INDICATOR_OPACITY_UNKNOWN; + break; + case ECORE_X_ILLUME_INDICATOR_OPAQUE: + opacity = _INDICATOR_OPACITY_OPAQUE; + break; + case ECORE_X_ILLUME_INDICATOR_TRANSLUCENT: + opacity = _INDICATOR_OPACITY_TRANSLUCENT; + break; + case ECORE_X_ILLUME_INDICATOR_TRANSPARENT: + opacity = _INDICATOR_OPACITY_TRANSPARENT; + break; + default: + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + return _INDICATOR_OPACITY_UNKNOWN; + } + + SetLastResult(E_SUCCESS); + + return opacity; +} + +void +_EcoreEvas::SetWindowActivationEnabled(const _Window& window, bool enable) +{ + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + + Eina_Bool acceptsFocus; + Ecore_X_Window_State_Hint initialState; + Ecore_X_Pixmap iconPixmap; + Ecore_X_Pixmap iconMask; + Ecore_X_Window iconWindow; + Ecore_X_Window windowGroup; + Eina_Bool isUrgent; + + ecore_x_icccm_hints_get(win, &acceptsFocus, &initialState, &iconPixmap, &iconMask, &iconWindow, &windowGroup, &isUrgent); + ecore_x_icccm_hints_set(win, (enable ? EINA_TRUE : EINA_FALSE), initialState, iconPixmap, iconMask, iconWindow, windowGroup, isUrgent); +} + +bool +_EcoreEvas::IsWindowActivationEnabled(const _Window& window) +{ + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturn(NID_UI, pLayer, true, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, true, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + + Eina_Bool acceptsFocus; + Ecore_X_Window_State_Hint initialState; + Ecore_X_Pixmap iconPixmap; + Ecore_X_Pixmap iconMask; + Ecore_X_Window iconWindow; + Ecore_X_Window windowGroup; + Eina_Bool isUrgent; + + ecore_x_icccm_hints_get(win, &acceptsFocus, &initialState, &iconPixmap, &iconMask, &iconWindow, &windowGroup, &isUrgent); + + return (acceptsFocus ? true : false); +} + +result +_EcoreEvas::SetFloatingMode(const _Window& window, bool enable) +{ + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturn(NID_UI, pLayer, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Evas_Object* pWinObj = pLayer->GetElmWin(); + SysTryReturn(NID_UI, pWinObj, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + elm_win_floating_mode_set(pWinObj, (enable ? EINA_TRUE : EINA_FALSE)); + + return E_SUCCESS; +} + +Evas* +_EcoreEvas::GetEvas(void) const +{ + SysLog(NID_UI, "Do not use."); + _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame(); + if (!pWindow) + { + return null; + } + + _EflLayer* pLayer = GetEflLayer(*pWindow); + if (!pLayer) + { + return null; + } + + return pLayer->GetEvas(); +} + +Ecore_Evas* +_EcoreEvas::GetEcoreEvas(void) const +{ + SysLog(NID_UI, "Do not use."); + _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame(); + if (!pWindow) + { + return null; + } + + _EflLayer* pLayer = GetEflLayer(*pWindow); + if (!pLayer) + { + return null; + } + + return pLayer->GetEcoreEvas(); +} + +Evas_Object* +_EcoreEvas::GetWindowObject(void) const +{ + SysLog(NID_UI, "Do not use."); + _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame(); + if (!pWindow) + { + return null; + } + + _EflLayer* pLayer = GetEflLayer(*pWindow); + if (!pLayer) + { + return null; + } + + return pLayer->GetElmWin(); +} + +Ecore_X_Window +_EcoreEvas::GetXWindow(void) const +{ + SysLog(NID_UI, "Do not use."); + _Window* pWindow = _ControlManager::GetInstance()->GetCurrentFrame(); + if (!pWindow) + { + return 0; + } + + _EflLayer* pLayer = GetEflLayer(*pWindow); + if (!pLayer) + { + return 0; + } + + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas()); + + return win; +} + +void +_EcoreEvas::AllowSetWindowBounds(bool allow) +{ + __changeBounds = allow; +} + +void +_EcoreEvas::SetWindowLevel(const _Window& window, _WindowLevel level) +{ + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + + if (level == _WINDOW_LEVEL_NORMAL) + { + ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL); + } + else if (level == _WINDOW_LEVEL_NOTIFICATION_HIGH) + { + ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NOTIFICATION); + utilx_set_system_notification_level((Display*)ecore_x_display_get(), win, UTILX_NOTIFICATION_LEVEL_HIGH); + } + else if (level == _WINDOW_LEVEL_NOTIFICATION_MIDDLE) + { + ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NOTIFICATION); + utilx_set_system_notification_level((Display*)ecore_x_display_get(), win, UTILX_NOTIFICATION_LEVEL_NORMAL); + } + + SetLastResult(E_SUCCESS); +} + +_WindowLevel +_EcoreEvas::GetWindowLevel(const _Window& window) const +{ + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturn(NID_UI, pLayer, _WINDOW_LEVEL_UNKNOWN, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, _WINDOW_LEVEL_UNKNOWN, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + + Ecore_X_Window_Type type = ECORE_X_WINDOW_TYPE_UNKNOWN; + ecore_x_netwm_window_type_get(win, &type); + + _WindowLevel winLevel = _WINDOW_LEVEL_UNKNOWN; + if (type == ECORE_X_WINDOW_TYPE_NORMAL) + { + winLevel = _WINDOW_LEVEL_NORMAL; + } + else if (type == ECORE_X_WINDOW_TYPE_NOTIFICATION) + { + Utilx_Notification_Level notificationLevel = utilx_get_system_notification_level((Display*)ecore_x_display_get(), win); + + if (notificationLevel == UTILX_NOTIFICATION_LEVEL_HIGH) + { + winLevel = _WINDOW_LEVEL_NOTIFICATION_HIGH; + } + else if (notificationLevel == UTILX_NOTIFICATION_LEVEL_NORMAL) + { + winLevel = _WINDOW_LEVEL_NOTIFICATION_MIDDLE; + } + } + + SetLastResult(E_SUCCESS); + + return winLevel; +} + +void +_EcoreEvas::SetWindowBounds(const _Window& window, const Rectangle& bounds) +{ + if (__changeBounds == false) + { + return; + } + + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + + Evas_Object* pWinObject = pLayer->GetElmWin(); + SysTryReturnVoidResult(NID_UI, pWinObject, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Rectangle winBounds = _CoordinateSystemUtils::Transform(bounds); + + int winX = winBounds.x; + int winY = winBounds.y; + + int rootW = 0; + int rootH = 0; + ecore_x_window_size_get(ecore_x_window_root_get(win), &rootW, &rootH); + + int rotate = ecore_evas_rotation_get(pEcoreEvas); + switch (rotate) + { + case 270: + winX = rootW - winBounds.y - winBounds.height; + winY = winBounds.x; + break; + case 90: + winX = winBounds.y; + winY = rootH - winBounds.x - winBounds.width; + break; + case 180: + winX = rootW - winBounds.x - winBounds.width; + winY = rootH - winBounds.y - winBounds.height; + break; + default: + break; + } + + evas_object_move(pWinObject, winX, winY); + evas_object_resize(pWinObject, winBounds.width, winBounds.height); + + SysLog(NID_UI, "The window is moved to (%d, %d) and is resized to (%d, %d) with %d degree by setting bounds." , winX, winY, winBounds.width, winBounds.height, rotate); + + // [SLP] + Rectangle rectangle = GetIndicatorBounds(window); + + SetLastResult(E_SUCCESS); +} + +void +_EcoreEvas::SetWindowVisibleState(const _Window& window, bool visibleState) +{ + _EflLayer* pLayer = GetEflLayer(window); + SysTryReturnVoidResult(NID_UI, pLayer, E_INVALID_ARG, "[E_INVALID_ARG] The window doesn't have a elf layer."); + + Evas_Object* pWinObj = pLayer->GetElmWin(); + SysTryReturnVoidResult(NID_UI, pWinObj, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pLayer->SetShowState(visibleState); + +// if (visibleState) +// { +// evas_object_show(pWinObj); +// } +// else +// { +// evas_object_hide(pWinObj); +// } + + SetLastResult(E_SUCCESS); +} + +void +_EcoreEvas::SetOwner(const _Window& ownee, const _Control& owner) +{ + _EflLayer* pOwneeLayer = GetEflLayer(ownee); + SysTryReturnVoidResult(NID_UI, pOwneeLayer, E_INVALID_ARG, "[E_INVALID_ARG] The ownee doesn't have a elf layer."); + + _Window* pOwnerWindow = owner.GetRootWindow(); + SysTryReturnVoidResult(NID_UI, pOwnerWindow, E_INVALID_ARG, "[E_INVALID_ARG] The owner doesn't have a root window."); + + _EflLayer* pOwnerLayer = GetEflLayer(*pOwnerWindow); + SysTryReturnVoidResult(NID_UI, pOwnerLayer, E_INVALID_ARG, "[E_INVALID_ARG] The owner doesn't have a elf layer."); + + Ecore_X_Window owneeWin = (Ecore_X_Window) ecore_evas_window_get(pOwneeLayer->GetEcoreEvas()); + Ecore_X_Window ownerWin = (Ecore_X_Window) ecore_evas_window_get(pOwnerLayer->GetEcoreEvas()); + + ecore_x_icccm_transient_for_unset(owneeWin); + ecore_x_icccm_transient_for_set(owneeWin, ownerWin); + + int rotation = GetWindowRotation(*pOwnerWindow); + RotateWindow(ownee, rotation); + + SetLastResult(E_SUCCESS); +} + +int +_EcoreEvas::GetWindowRotation(const _Window& window) +{ + _EflLayer* pLayer = GetEflLayer(window); + if (!pLayer) + { + return 0; + } + + int rotation = ecore_evas_rotation_get(pLayer->GetEcoreEvas()); + return rotation; +} + +const _Control* +_EcoreEvas::GetFrame(void) const +{ + SysLog(NID_UI, "Do not use."); + return __pFrame; +} + +_RootVisualElement* +_EcoreEvas::GetRootVisualElement(void)const +{ + SysLog(NID_UI, "Do not use."); + return __pRootVE; +} + +void +_EcoreEvas::SetFrame(const _Control& control) +{ + SysLog(NID_UI, "Do not use."); + __pFrame = const_cast<_Control*>(&control); +} +#endif + +bool +_EcoreEvas::GetSelectedCbhmItem(Ecore_X_Atom* pDataType, char** pBuffer) const +{ + Ecore_X_Window cbhmWin = GetCbhmWindow(); + Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(ATOM_CBHM_SELECTED_ITEM); + Ecore_X_Atom atomItemType = 0; + + char* pRet = (char*)GetCbhmReply(cbhmWin, atomCbhmItem, &atomItemType, NULL); + if (pRet) + { + Ecore_X_Atom x_atom_cbhm_error = ecore_x_atom_get(ATOM_CBHM_ERROR); + if (atomItemType == x_atom_cbhm_error) + { + free(pRet); + return false; + } + + if (pBuffer) + { + *pBuffer = pRet; + } + else + { + free(pRet); + } + + if (pDataType) + { + *pDataType = atomItemType; + } + + return true; + } + + return false; +} +bool +_EcoreEvas::IsAccessibilityScreenReaderActivated(void) +{ + Eina_Bool acc = elm_config_access_get(); + return acc; +} + +void* _GetEcoreEvasHandle(void) +{ + _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr(); + if (pEcoreEvasMgr == null) + { + return null; + } + + _EcoreEvas* pUiEcoreEvas = pEcoreEvasMgr->GetEcoreEvas(); + if (pUiEcoreEvas == null) + { + return null; + } + + return (void*)pUiEcoreEvas->GetEcoreEvas(); +} + +void* _GetEvasHandle(void) +{ + _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr(); + if (pEcoreEvasMgr == null) + { + return null; + } + + _EcoreEvas* pUiEcoreEvas = pEcoreEvasMgr->GetEcoreEvas(); + if (pUiEcoreEvas == null) + { + return null; + } + + return (void*)pUiEcoreEvas->GetEvas(); +} + +result +_EcoreEvas::CreateWindow(void) +{ + // Create a win object. + _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); + SysTryReturn(NID_UI, pDisplayManager, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + __pLayer = _NativeLayer::CreateInstanceN(); + SysTryReturn(NID_UI, __pLayer, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + __pRootVE = __pLayer->GetRootVisualElement(); + + SysTryReturn(NID_UI, __pRootVE, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _EflLayer* pLayer = static_cast<_EflLayer*>(__pRootVE->GetNativeLayer()); + SysTryReturn(NID_UI, pLayer, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + __pForegroundWindow = pLayer->GetElmWin(); + + int width = 0; + int height = 0; + Ecore_Evas* pEcoreEvas = null; + Ecore_X_Window window = 0; + + // Get the evas. + Evas* pEvas = pLayer->GetEvas(); + SysTryCatch(NID_UI, pEvas, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + // Get the ecore evas. + pEcoreEvas = pLayer->GetEcoreEvas(); + SysTryCatch(NID_UI, pEcoreEvas, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + window = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); + SysTryCatch(NID_UI, window != 0, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + __pEvas = pEvas; + + // Set properties. + ecore_x_window_size_get(ecore_x_window_root_get(window), &width, &height); + + pLayer->SetBounds(FloatRectangle(0.0f, 0.0f, (float)width, (float)height)); + __pRootVE->SetBounds(FloatRectangle(0.0f, 0.0f, (float)width, (float)height)); + + _CanvasImpl::SetFrameInfoCallback(_GetEcoreEvasHandle, _GetEvasHandle); + + SetLastResult(E_SUCCESS); + + return E_SUCCESS; + +CATCH: + evas_object_del(__pForegroundWindow); + + return E_SYSTEM; +} + +result +_EcoreEvas::InitializeAtomList(void) +{ + __atomList[_ATOM_TARGETS].pName = "TARGETS"; + __atomList[_ATOM_TARGETS].formats = _CLIP_FORMAT_TARGETS; + __atomList[_ATOM_TARGETS].convert = ConvertClipIntoTarget; + __atomList[_ATOM_TARGETS].response = RequestClip; + __atomList[_ATOM_TARGETS].notify = NotifyTarget; + __atomList[_ATOM_TARGETS].atom = 0; + + __atomList[_ATOM_ATOM].pName = "ATOM"; + __atomList[_ATOM_ATOM].formats = _CLIP_FORMAT_TARGETS; + __atomList[_ATOM_ATOM].convert = ConvertClipIntoTarget; + __atomList[_ATOM_ATOM].response = RequestClip; + __atomList[_ATOM_ATOM].notify = NotifyTarget; + __atomList[_ATOM_ATOM].atom = 0; + + __atomList[_ATOM_XELM].pName = "application/x-elementary-markup"; + __atomList[_ATOM_XELM].formats = _CLIP_FORMAT_MARKUP; + __atomList[_ATOM_XELM].convert = ConvertClipIntoEdje; + __atomList[_ATOM_XELM].response = null; + __atomList[_ATOM_XELM].notify = NotifyEdje; + __atomList[_ATOM_XELM].atom = 0; + + __atomList[_ATOM_TEXT_URI].pName = "text/uri"; + __atomList[_ATOM_TEXT_URI].formats = _CLIP_FORMAT_IMAGE; + __atomList[_ATOM_TEXT_URI].convert = ConvertClipIntoUri; + __atomList[_ATOM_TEXT_URI].response = null; + __atomList[_ATOM_TEXT_URI].notify = NotifyUri; + __atomList[_ATOM_TEXT_URI].atom = 0; + + __atomList[_ATOM_TEXT_URILIST].pName = "text/uri-list"; + __atomList[_ATOM_TEXT_URILIST].formats = _CLIP_FORMAT_IMAGE; + __atomList[_ATOM_TEXT_URILIST].convert = ConvertClipIntoUri; + __atomList[_ATOM_TEXT_URILIST].response = null; + __atomList[_ATOM_TEXT_URILIST].notify = NotifyUri; + __atomList[_ATOM_TEXT_URILIST].atom = 0; + + __atomList[_ATOM_TEXT_X_VCARD].pName = "text/x-vcard"; + __atomList[_ATOM_TEXT_X_VCARD].formats = _CLIP_FORMAT_VCARD; + __atomList[_ATOM_TEXT_X_VCARD].convert = null; + __atomList[_ATOM_TEXT_X_VCARD].response = null; + __atomList[_ATOM_TEXT_X_VCARD].notify = null; + __atomList[_ATOM_TEXT_X_VCARD].atom = 0; + + __atomList[_ATOM_IMAGE_PNG].pName = "image/png"; + __atomList[_ATOM_IMAGE_PNG].formats = _CLIP_FORMAT_IMAGE; + __atomList[_ATOM_IMAGE_PNG].convert = ConvertClipIntoImage; + __atomList[_ATOM_IMAGE_PNG].response = null; + __atomList[_ATOM_IMAGE_PNG].notify = NotifyImage; + __atomList[_ATOM_IMAGE_PNG].atom = 0; + + __atomList[_ATOM_IMAGE_JPEG].pName = "image/jpeg"; + __atomList[_ATOM_IMAGE_JPEG].formats = _CLIP_FORMAT_IMAGE; + __atomList[_ATOM_IMAGE_JPEG].convert = ConvertClipIntoImage; + __atomList[_ATOM_IMAGE_JPEG].response = null; + __atomList[_ATOM_IMAGE_JPEG].notify = NotifyImage; + __atomList[_ATOM_IMAGE_JPEG].atom = 0; + + __atomList[_ATOM_IMAGE_BMP].pName = "image/x-ms-bmp"; + __atomList[_ATOM_IMAGE_BMP].formats = _CLIP_FORMAT_IMAGE; + __atomList[_ATOM_IMAGE_BMP].convert = ConvertClipIntoImage; + __atomList[_ATOM_IMAGE_BMP].response = null; + __atomList[_ATOM_IMAGE_BMP].notify = NotifyImage; + __atomList[_ATOM_IMAGE_BMP].atom = 0; + + __atomList[_ATOM_IMAGE_GIF].pName = "image/gif"; + __atomList[_ATOM_IMAGE_GIF].formats = _CLIP_FORMAT_IMAGE; + __atomList[_ATOM_IMAGE_GIF].convert = ConvertClipIntoImage; + __atomList[_ATOM_IMAGE_GIF].response = null; + __atomList[_ATOM_IMAGE_GIF].notify = NotifyImage; + __atomList[_ATOM_IMAGE_GIF].atom = 0; + + __atomList[_ATOM_IMAGE_TIFF].pName = "image/tiff"; + __atomList[_ATOM_IMAGE_TIFF].formats = _CLIP_FORMAT_IMAGE; + __atomList[_ATOM_IMAGE_TIFF].convert = ConvertClipIntoImage; + __atomList[_ATOM_IMAGE_TIFF].response = null; + __atomList[_ATOM_IMAGE_TIFF].notify = NotifyImage; + __atomList[_ATOM_IMAGE_TIFF].atom = 0; + + __atomList[_ATOM_IMAGE_SVG].pName = "image/svg+xml"; + __atomList[_ATOM_IMAGE_SVG].formats = _CLIP_FORMAT_IMAGE; + __atomList[_ATOM_IMAGE_SVG].convert = ConvertClipIntoImage; + __atomList[_ATOM_IMAGE_SVG].response = null; + __atomList[_ATOM_IMAGE_SVG].notify = NotifyImage; + __atomList[_ATOM_IMAGE_SVG].atom = 0; + + __atomList[_ATOM_IMAGE_XPM].pName = "image/x-xpixmap"; + __atomList[_ATOM_IMAGE_XPM].formats = _CLIP_FORMAT_IMAGE; + __atomList[_ATOM_IMAGE_XPM].convert = ConvertClipIntoImage; + __atomList[_ATOM_IMAGE_XPM].response = null; + __atomList[_ATOM_IMAGE_XPM].notify = NotifyImage; + __atomList[_ATOM_IMAGE_XPM].atom = 0; + + __atomList[_ATOM_IMAGE_TGA].pName = "image/x-tga"; + __atomList[_ATOM_IMAGE_TGA].formats = _CLIP_FORMAT_IMAGE; + __atomList[_ATOM_IMAGE_TGA].convert = ConvertClipIntoImage; + __atomList[_ATOM_IMAGE_TGA].response = null; + __atomList[_ATOM_IMAGE_TGA].notify = NotifyImage; + __atomList[_ATOM_IMAGE_TGA].atom = 0; + + __atomList[_ATOM_IMAGE_PPM].pName = "image/x-portable-pixmap"; + __atomList[_ATOM_IMAGE_PPM].formats = _CLIP_FORMAT_IMAGE; + __atomList[_ATOM_IMAGE_PPM].convert = ConvertClipIntoImage; + __atomList[_ATOM_IMAGE_PPM].response = null; + __atomList[_ATOM_IMAGE_PPM].notify = NotifyImage; + __atomList[_ATOM_IMAGE_PPM].atom = 0; + + __atomList[_ATOM_TEXT_HTML_UTF8].pName = "text/html;charset=utf-8"; + __atomList[_ATOM_TEXT_HTML_UTF8].formats = _CLIP_FORMAT_HTML; + __atomList[_ATOM_TEXT_HTML_UTF8].convert = ConvertClipIntoHtml; + __atomList[_ATOM_TEXT_HTML_UTF8].response = null; + __atomList[_ATOM_TEXT_HTML_UTF8].notify = NotifyHtml; + __atomList[_ATOM_TEXT_HTML_UTF8].atom = 0; + + __atomList[_ATOM_TEXT_HTML].pName = "text/html"; + __atomList[_ATOM_TEXT_HTML].formats = _CLIP_FORMAT_HTML; + __atomList[_ATOM_TEXT_HTML].convert = ConvertClipIntoHtml; + __atomList[_ATOM_TEXT_HTML].response = null; + __atomList[_ATOM_TEXT_HTML].notify = NotifyHtml; + __atomList[_ATOM_TEXT_HTML].atom = 0; + + __atomList[_ATOM_STRING_UTF8].pName = "UTF8_STRING"; + __atomList[_ATOM_STRING_UTF8].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML); + __atomList[_ATOM_STRING_UTF8].convert = ConvertClipIntoText; + __atomList[_ATOM_STRING_UTF8].response = null; + __atomList[_ATOM_STRING_UTF8].notify = NotifyText; + __atomList[_ATOM_STRING_UTF8].atom = 0; + + __atomList[_ATOM_STRING].pName = "STRING"; + __atomList[_ATOM_STRING].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML); + __atomList[_ATOM_STRING].convert = ConvertClipIntoText; + __atomList[_ATOM_STRING].response = null; + __atomList[_ATOM_STRING].notify = NotifyText; + __atomList[_ATOM_STRING].atom = 0; + + __atomList[_ATOM_TEXT].pName = "TEXT"; + __atomList[_ATOM_TEXT].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML); + __atomList[_ATOM_TEXT].convert = ConvertClipIntoText; + __atomList[_ATOM_TEXT].response = null; + __atomList[_ATOM_TEXT].notify = null; + __atomList[_ATOM_TEXT].atom = 0; + + __atomList[_ATOM_TEXT_PLAIN_UTF8].pName = "text/plain;charset=utf-8"; + __atomList[_ATOM_TEXT_PLAIN_UTF8].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML); + __atomList[_ATOM_TEXT_PLAIN_UTF8].convert = ConvertClipIntoText; + __atomList[_ATOM_TEXT_PLAIN_UTF8].response = null; + __atomList[_ATOM_TEXT_PLAIN_UTF8].notify = null; + __atomList[_ATOM_TEXT_PLAIN_UTF8].atom = 0; + + __atomList[_ATOM_TEXT_PLAIN].pName = "text/plain"; + __atomList[_ATOM_TEXT_PLAIN].formats = (_ClipFormat) (_CLIP_FORMAT_TEXT | _CLIP_FORMAT_MARKUP | _CLIP_FORMAT_HTML); + __atomList[_ATOM_TEXT_PLAIN].convert = ConvertClipIntoText; + __atomList[_ATOM_TEXT_PLAIN].response = null; + __atomList[_ATOM_TEXT_PLAIN].notify = null; + __atomList[_ATOM_TEXT_PLAIN].atom = 0; + + __clipList[_CLIP_TYPE_PRIMARY].selection = ECORE_X_SELECTION_PRIMARY; + __clipList[_CLIP_TYPE_PRIMARY].set = ecore_x_selection_primary_set; + __clipList[_CLIP_TYPE_PRIMARY].clear = ecore_x_selection_primary_clear; + __clipList[_CLIP_TYPE_PRIMARY].request = ecore_x_selection_primary_request; + __clipList[_CLIP_TYPE_PRIMARY].active = false; + __clipList[_CLIP_TYPE_PRIMARY].pBuffer = null; + __clipList[_CLIP_TYPE_PRIMARY].pRetrievedBuffer = null; + __clipList[_CLIP_TYPE_PRIMARY].bufferLength = 0; + __clipList[_CLIP_TYPE_PRIMARY].completed = false; + + __clipList[_CLIP_TYPE_SECONDARY].selection = ECORE_X_SELECTION_SECONDARY; + __clipList[_CLIP_TYPE_SECONDARY].set = ecore_x_selection_secondary_set; + __clipList[_CLIP_TYPE_SECONDARY].clear = ecore_x_selection_secondary_clear; + __clipList[_CLIP_TYPE_SECONDARY].request = ecore_x_selection_secondary_request; + __clipList[_CLIP_TYPE_SECONDARY].active = false; + __clipList[_CLIP_TYPE_SECONDARY].pBuffer = null; + __clipList[_CLIP_TYPE_SECONDARY].pRetrievedBuffer = null; + __clipList[_CLIP_TYPE_SECONDARY].bufferLength = 0; + __clipList[_CLIP_TYPE_SECONDARY].completed = false; + + __clipList[_CLIP_TYPE_CLIPBOARD].selection = ECORE_X_SELECTION_CLIPBOARD; + __clipList[_CLIP_TYPE_CLIPBOARD].set = ecore_x_selection_clipboard_set; + __clipList[_CLIP_TYPE_CLIPBOARD].clear = ecore_x_selection_clipboard_clear; + __clipList[_CLIP_TYPE_CLIPBOARD].request = ecore_x_selection_clipboard_request; + __clipList[_CLIP_TYPE_CLIPBOARD].active = false; + __clipList[_CLIP_TYPE_CLIPBOARD].pBuffer = null; + __clipList[_CLIP_TYPE_CLIPBOARD].pRetrievedBuffer = null; + __clipList[_CLIP_TYPE_CLIPBOARD].bufferLength = 0; + __clipList[_CLIP_TYPE_CLIPBOARD].completed = false; + + __clipList[_CLIP_TYPE_XDND].selection = ECORE_X_SELECTION_XDND; + __clipList[_CLIP_TYPE_XDND].request = ecore_x_selection_xdnd_request; + __clipList[_CLIP_TYPE_XDND].active = false; + __clipList[_CLIP_TYPE_XDND].pBuffer = null; + __clipList[_CLIP_TYPE_XDND].pRetrievedBuffer = null; + __clipList[_CLIP_TYPE_XDND].bufferLength = 0; + __clipList[_CLIP_TYPE_XDND].completed = false; + + for (int i = 0; i < _ATOM_MAX; i++) + { + __atomList[i].atom = ecore_x_atom_get(__atomList[i].pName); + //ecore_x_selection_converter_atom_add(__atomList[i].atom, __atomList[i].convert); + + SysLog(NID_UI, "[Clipboard] __atomList[%d] : pName = %s, atom = %d", i, __atomList[i].pName, __atomList[i].atom); + } + + result r = E_SUCCESS; + + __pClearClip = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR, ClearClip, NULL); + SysTryCatch(NID_UI, __pClearClip, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + __pNotifyClip = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, NotifyClip, NULL); + SysTryCatch(NID_UI, __pNotifyClip, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + __pClipboardClosed = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, OnClipboardClosed, null); + SysTryCatch(NID_UI, __pClipboardClosed, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + __atomRotateRootAngle = ecore_x_atom_get("_E_ILLUME_ROTATE_ROOT_ANGLE"); + __atomAccessibility = ecore_x_atom_get("_E_MOD_ACC_SCR_READER_"); + + return r; + +CATCH: + for (int i = 0; i < _ATOM_MAX; i++) + { + if (__atomList[i].atom) + { + ecore_x_selection_converter_atom_del(__atomList[i].atom); + } + } + + if (__pClearClip) + { + ecore_event_handler_del(__pClearClip); + __pClearClip = null; + } + + if (__pNotifyClip) + { + ecore_event_handler_del(__pNotifyClip); + __pNotifyClip = null; + } + + if (__pClipboardClosed) + { + ecore_event_handler_del(__pClipboardClosed); + __pClipboardClosed = null; + } + + return r; +} + +bool +_EcoreEvas::IsValidClipFormat(_ClipFormat clipFormat) +{ + return ((_CLIP_FORMAT_TEXT & clipFormat) || + (_CLIP_FORMAT_MARKUP & clipFormat) || + (_CLIP_FORMAT_IMAGE & clipFormat) || + (_CLIP_FORMAT_VCARD & clipFormat) || + (_CLIP_FORMAT_HTML & clipFormat)); +} + +Ecore_X_Window +_EcoreEvas::GetCbhmWindow(void) const +{ + Ecore_X_Atom atomCbhm = ecore_x_atom_get(ATOM_CBHM_WINDOW_NAME); + Ecore_X_Window cbhmWin = 0; + + unsigned char* pBuf = NULL; + int num = 0; + int ret = ecore_x_window_prop_property_get(0, atomCbhm, XA_WINDOW, 0, &pBuf, &num); + + if (ret && num) + { + memcpy(&cbhmWin, pBuf, sizeof(Ecore_X_Window)); + } + + if (pBuf) + { + free(pBuf); + } + + return cbhmWin; +} + +bool +_EcoreEvas::SendCbhmMessage(Ecore_X_Window xwin, const char* pMsg) +{ + Ecore_X_Window cbhmWin = GetCbhmWindow(); + Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get(ATOM_CBHM_MSG); + + if (!cbhmWin || !atomCbhmMsg) + { + return false; + } + + XClientMessageEvent m; + memset(&m, 0, sizeof(m)); + m.type = ClientMessage; + m.display = (Display*)ecore_x_display_get(); + m.window = xwin; + m.message_type = atomCbhmMsg; + m.format = 8; + snprintf(m.data.b, 20, "%s", pMsg); + + XSendEvent((Display*)ecore_x_display_get(), cbhmWin, False, NoEventMask, (XEvent*)&m); + + ecore_x_sync(); + + // [SLP] + Thread::Sleep(100); + + return true; +} + +bool +_EcoreEvas::SetCbhmItem(Ecore_X_Window xwin, Ecore_X_Atom dataType, char* pItemData) +{ + Ecore_X_Window cbhmWin = GetCbhmWindow(); + Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(ATOM_CBHM_ITEM); + + ecore_x_sync(); + ecore_x_window_prop_property_set(cbhmWin, atomCbhmItem, dataType, 8, pItemData, strlen(pItemData) + 1); + ecore_x_sync(); + + if (SendCbhmMessage(xwin, ATOM_CBHM_SET_ITEM)) + { + return true; + } + + return false; +} + +void* +_EcoreEvas::GetCbhmReply(Ecore_X_Window xwin, Ecore_X_Atom property, Ecore_X_Atom* pDataType, int* pNum) const +{ + unsigned char* pData = null; + + if (pDataType) + { + *pDataType = 0; + } + + if (!property) + { + return null; + } + + ecore_x_sync(); + + if (pNum) + { + *pNum = 0; + } + + long unsigned int numRet = 0; + long unsigned int bytes = 0; + int ret = 0; + int sizeRet = 0; + unsigned int i = 0; + unsigned char* pPropRet = null; + Ecore_X_Atom typeRet; + + ret = XGetWindowProperty((Display*)ecore_x_display_get(), xwin, property, 0, LONG_MAX, False, + ecore_x_window_prop_any_type(), (Atom*)&typeRet, &sizeRet, &numRet, &bytes, &pPropRet); + if (ret != Success) + { + return null; + } + + if (!numRet) + { + XFree(pPropRet); + return null; + } + + if (!(pData = (unsigned char*)malloc(numRet * sizeRet / 8))) + { + XFree(pPropRet); + return null; + } + + switch (sizeRet) + { + case 8: + for (i = 0; i < numRet; i++) + (pData)[i] = pPropRet[i]; + break; + case 16: + for (i = 0; i < numRet; i++) + ((unsigned short *)pData)[i] = ((unsigned short *)pPropRet)[i]; + break; + case 32: + for (i = 0; i < numRet; i++) + ((unsigned int *)pData)[i] = ((unsigned long *)pPropRet)[i]; + break; + } + + XFree(pPropRet); + + // [SLP] + Thread::Sleep(100); + + if (pNum) + { + *pNum = numRet; + } + + if (pDataType) + { + *pDataType = typeRet; + } + + return pData; +} + +int +_EcoreEvas::GetCbhmItemCount(void) const +{ + char* pRet = null; + int count = null; + + Ecore_X_Atom atomCbhmCountGet = ecore_x_atom_get(ATOM_CBHM_COUNT_GET); + Ecore_X_Window cbhmWin = GetCbhmWindow(); + + pRet = (char*)GetCbhmReply(cbhmWin, atomCbhmCountGet, null, null); + if (pRet) + { + count = atoi(pRet); + free(pRet); + return count; + } + + return -1; +} + +bool +_EcoreEvas::GetCbhmItem(int index, Ecore_X_Atom* pDataType, char** pBuffer) const +{ + if (pBuffer) + { + *pBuffer = null; + } + + if (pDataType) + { + *(int*)pDataType = 0; + } + + Ecore_X_Window cbhmWin = GetCbhmWindow(); + char sendBuf[20]; + char* pRet; + + snprintf(sendBuf, 20, "CBHM_ITEM%d", index); + Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(sendBuf); + Ecore_X_Atom atomItemType = 0; + + pRet = (char*)GetCbhmReply(cbhmWin, atomCbhmItem, &atomItemType, NULL); + if (pRet) + { + if (pBuffer) + { + *pBuffer = pRet; + } + else + { + free(pRet); + } + + if (pDataType) + { + *pDataType = atomItemType; + } + + Ecore_X_Atom x_atom_cbhm_error = ecore_x_atom_get(ATOM_CBHM_ERROR); + if (atomItemType == x_atom_cbhm_error) + { + return false; + } + + return true; + } + + return false; +} + +}} // Tizen::Ui + +#ifdef __cplusplus +extern "C" +{ +#endif + +_OSP_EXPORT_ void +_AddActiveWindowEventListener(const _IActiveWindowEventListener& listener) +{ + GetEcoreEvasMgr()->GetEcoreEvas()->AddActiveWindowEventListener(listener); +} + +_OSP_EXPORT_ void +_RemoveActiveWindowEventListener(const _IActiveWindowEventListener& listener) +{ + GetEcoreEvasMgr()->GetEcoreEvas()->RemoveActiveWindowEventListener(listener); +} + +_OSP_EXPORT_ unsigned int +_GetActiveWindow(void) +{ + return GetEcoreEvasMgr()->GetEcoreEvas()->GetActiveWindow(); +} + +_OSP_EXPORT_ int +_GetProcessId(unsigned int window) +{ + return GetEcoreEvasMgr()->GetEcoreEvas()->GetProcessId(window); +} + +#ifdef __cplusplus +} +#endif + diff --git a/src/ui/FUi_EcoreEvasMgr.cpp b/src/ui/FUi_EcoreEvasMgr.cpp new file mode 100644 index 0000000..83ad130 --- /dev/null +++ b/src/ui/FUi_EcoreEvasMgr.cpp @@ -0,0 +1,113 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_EcoreEvasMgr.cpp + * @brief This is the implementation file for the _EcoreEvasMgr class. + */ +#include +#include +#include +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EcoreEvas.h" + +using namespace Tizen::Ui; + +namespace +{ +_EcoreEvasMgr* __pEcoreEvasMgr = null; +} // Anonymous + +namespace Tizen { namespace Ui +{ + +_EcoreEvasMgr::_EcoreEvasMgr(void) + : __pEcoreEvas(null) +{ +} + +_EcoreEvasMgr::~_EcoreEvasMgr(void) +{ +} + +void +_EcoreEvasMgr::SetEcoreEvas(const _EcoreEvas& ecoreEvas) +{ + __pEcoreEvas = &ecoreEvas; +} + +_EcoreEvas* +_EcoreEvasMgr::GetEcoreEvas(void) const +{ + return const_cast<_EcoreEvas*>(__pEcoreEvas); +} + +void +_EcoreEvasMgr::BeginMainLoop(void) +{ + ecore_main_loop_begin(); +} + +void +_EcoreEvasMgr::EndMainLoop(void) +{ + ecore_main_loop_quit(); +} + +void +_EcoreEvasMgr::SetRenderBackend(int backend) +{ + GetEcoreEvas()->SetRenderBackend((_RenderBackend)backend); +} + +int +_EcoreEvasMgr::GetRenderBackend(void) +{ + return GetEcoreEvas()->GetRenderBackend(); +} + +void +DestroyEcoreEvasMgr(void) +{ + _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr(); + + if (pEcoreEvasMgr) + { + _EcoreEvas* pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas(); + if (pEcoreEvas) + { + delete pEcoreEvas; + } + } + + delete __pEcoreEvasMgr; + __pEcoreEvasMgr = null; +} + +_EcoreEvasMgr* +GetEcoreEvasMgr(void) +{ + if (__pEcoreEvasMgr) + { + return __pEcoreEvasMgr; + } + + __pEcoreEvasMgr = new (std::nothrow) _EcoreEvasMgr; + + return __pEcoreEvasMgr; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_EflUiEventManager.cpp b/src/ui/FUi_EflUiEventManager.cpp new file mode 100644 index 0000000..c03dc81 --- /dev/null +++ b/src/ui/FUi_EflUiEventManager.cpp @@ -0,0 +1,1302 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_EflUiEventManager.cpp + * @brief This is the implementation file for _EflUiEventManager class. + */ +#include +#include +#include +#ifdef KEY_CAMERA +#undef KEY_CAMERA +#endif +#include +#include +#include +#include +#include "FUi_CoordinateSystemUtils.h" +#include "FUi_Control.h" +#include "FUi_ControlManager.h" +#include "FUi_KeyEventManager.h" +#include "FUi_Window.h" +#include "FUi_UiEventManager.h" +#include "FUi_EflUiEventManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_UiNotificationEvent.h" +#include "FUi_UiKeyEvent.h" +#include "FUi_UiFocusEvent.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EcoreEvas.h" +#include "FUi_TouchManager.h" +#include "FUiAnim_EflNode.h" +#include "FUiAnim_ControlVisualElement.h" +#if defined(MULTI_WINDOW) +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_EflLayer.h" +#endif + +using namespace std; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base; + +namespace +{ +#define __UNUSED__ + +bool isPressed = false; +Ecore_X_Atom keyboardExist = 0; +const wchar_t* KEYBOARD_INSERTED_EVENT = L"KEYBOARD_INSERTED"; + +Evas_Object* +GetEvasObject(const _Control& control) +{ + _VisualElement* pVisualElement = control.GetVisualElement(); + SysTryReturn(NID_UI, pVisualElement, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _EflNode* pEflNode = dynamic_cast<_EflNode*>(pVisualElement->GetNativeNode()); + SysTryReturn(NID_UI, pEflNode, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return (Evas_Object*)pEflNode->GetGroupContainer(); +} + +Evas* +GetEvas(const _Control& control) +{ + Evas* pEvas = null; + Evas_Object* pEvasObject = GetEvasObject(control); + if (pEvasObject) + { + pEvas = evas_object_evas_get(pEvasObject); + SysTryReturn(NID_UI, pEvas, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + } + + return pEvas; +} + +class _Event +{ +public: + _Event(void) + : _pEventManager(null) + { + _pEventManager = _UiEventManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, _pEventManager, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + SetLastResult(E_SUCCESS); + } + + virtual ~_Event(void) + { + } + +private: + _Event(const _Event& rhs); + _Event& operator =(const _Event& rhs); + + virtual result SendImpl(void) = 0; + +public: + result Send(void) + { + return SendImpl(); + } + +protected: + _UiEventManager* _pEventManager; +}; // _Event + +struct _EvasConvertKeys +{ + _KeyCode code; + const char* pName; +}; + +const _EvasConvertKeys keyTable[] = +{ + { _KEY_SIDE_UP, "XF86AudioRaiseVolume" }, + { _KEY_SIDE_DOWN, "XF86AudioLowerVolume" }, + { _KEY_END, "XF86Stop" }, + { _KEY_ENTER, "Return" }, + { _KEY_BACKSPACE, "BackSpace" }, + { _KEY_NUM_LEFT, "KP_Left"}, + { _KEY_NUM_UP, "KP_Up"}, + { _KEY_NUM_DOWN, "KP_Down"}, + { _KEY_NUM_RIGHT, "KP_Right"}, + { _KEY_LEFT, "Left" }, + { _KEY_UP, "Up"}, + { _KEY_DOWN, "Down"}, + { _KEY_RIGHT, "Right"}, + { _KEY_0, "0"}, + { _KEY_1, "1"}, + { _KEY_2, "2"}, + { _KEY_3, "3"}, + { _KEY_4, "4"}, + { _KEY_5, "5"}, + { _KEY_6, "6"}, + { _KEY_7, "7"}, + { _KEY_8, "8"}, + { _KEY_9, "9"}, + { _KEY_A, "a"}, + { _KEY_B, "b"}, + { _KEY_C, "c"}, + { _KEY_D, "d"}, + { _KEY_E, "e"}, + { _KEY_F, "f"}, + { _KEY_G, "g"}, + { _KEY_H, "h"}, + { _KEY_I, "i"}, + { _KEY_J, "j"}, + { _KEY_K, "k"}, + { _KEY_L, "l"}, + { _KEY_M, "m"}, + { _KEY_N, "n"}, + { _KEY_O, "o"}, + { _KEY_P, "p"}, + { _KEY_Q, "q"}, + { _KEY_R, "r"}, + { _KEY_S, "s"}, + { _KEY_T, "t"}, + { _KEY_U, "u"}, + { _KEY_V, "v"}, + { _KEY_W, "w"}, + { _KEY_X, "x"}, + { _KEY_Y, "y"}, + { _KEY_Z, "z"}, + { _KEY_COMMA, "comma"}, + { _KEY_CAPSLOCK, "Caps_Lock"}, + { _KEY_ALT, "Alt_L"}, + { _KEY_ALT, "Alt_R"}, + { _KEY_SPACE, "space"}, + { _KEY_FN_1, "F1"}, + { _KEY_FN_2, "F2"}, + { _KEY_FN_3, "F3"}, + { _KEY_FN_4, "F4"}, + { _KEY_FN_5, "F5"}, + { _KEY_CLEAR, "BackSpace"}, + { _KEY_POWER_HOLD, "XF86PowerOff"}, + { _KEY_DELETE, "Delete"}, + { _KEY_DELETE, "KP_Delete"}, + { _KEY_CTRL_L, "XK_Control_L"}, + { _KEY_CTRL_L, "Control_L"}, + { _KEY_CTRL_R, "XK_Control_R"}, + { _KEY_CTRL_R, "Control_R"}, + { _KEY_SHIFT_L, "XK_Shift_L"}, + { _KEY_SHIFT_L, "Shift_L"}, + { _KEY_SHIFT_R, "XK_Shift_R"}, + { _KEY_SHIFT_R, "Shift_R"}, +}; + +class _KeyEvent + : public _Event +{ +public: + _KeyEvent(KeyState keyState, _KeyCode keyCode, int keyModifier, void* pUserData) + : __pTarget(null) + , __keyInfo(keyState, keyCode, keyModifier, pUserData) + { + __pTarget = GetTarget(keyCode); + } + + virtual ~_KeyEvent(void) + { + } + + static _KeyCode GetKeyCode(const char* pKeyName) + { + ClearLastResult(); + + SysTryReturn(NID_UI, pKeyName, _KEY_INVALID, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + for (unsigned int i = 0; i < sizeof(keyTable) / sizeof(_EvasConvertKeys); ++i) + { + if (strcmp(keyTable[i].pName, pKeyName) == 0) + { + return keyTable[i].code; + } + } + + return _KEY_INVALID; + } + + static int GetKeyModifier(const int keyModifier) + { + ClearLastResult(); + unsigned int modifier = _KEY_MODIFIER_NONE; + + if(ECORE_EVENT_MODIFIER_SHIFT & keyModifier) + { + modifier |= _KEY_MODIFIER_SHIFT; + } + if(ECORE_EVENT_MODIFIER_CTRL & keyModifier) + { + modifier |= _KEY_MODIFIER_CTRL; + } + if(ECORE_EVENT_MODIFIER_ALT & keyModifier) + { + modifier |= _KEY_MODIFIER_ALT; + } + if(ECORE_EVENT_MODIFIER_WIN & keyModifier) + { + modifier |= _KEY_MODIFIER_WIN; + } + if(ECORE_EVENT_MODIFIER_SCROLL & keyModifier) + { + modifier |= _KEY_MODIFIER_SCROLL; + } + if(ECORE_EVENT_MODIFIER_NUM & keyModifier) + { + modifier |= _KEY_MODIFIER_NUM; + } + if(ECORE_EVENT_MODIFIER_CAPS & keyModifier) + { + modifier |= _KEY_MODIFIER_CAPS; + } + if(ECORE_EVENT_LOCK_SCROLL & keyModifier) + { + modifier |= _KEY_LOCK_SCROLL; + } + if(ECORE_EVENT_LOCK_NUM & keyModifier) + { + modifier |= _KEY_LOCK_NUM; + } + if(ECORE_EVENT_LOCK_CAPS & keyModifier) + { + modifier |= _KEY_LOCK_CAPS; + } + if(ECORE_EVENT_LOCK_SHIFT & keyModifier) + { + modifier |= _KEY_LOCK_SHIFT; + } + if(ECORE_EVENT_MODIFIER_ALTGR & keyModifier) + { + modifier |= _KEY_MODIFIER_ALTGR; + } + + return modifier; + } + +private: + _KeyEvent(const _KeyEvent& rhs); + _KeyEvent& operator =(const _KeyEvent& rhs); + + virtual result SendImpl(void) + { + SysTryReturn(NID_UI, __pTarget, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _UiKeyEvent event(__pTarget->GetHandle(), __keyInfo); + + return _pEventManager->SendEvent(event); + } + + _Control* GetTarget(_KeyCode keyCode) const + { + _KeyEventManager* pKeyEventManager = _KeyEventManager::GetInstance(); + SysTryReturn(NID_UI, pKeyEventManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _Control* pControl = pKeyEventManager->GetCapturingControl(keyCode); + + if (pControl == null) + { + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pControl = pControlManager->GetFocusedControl(); + + if (!pControl) + { + pControl = pControlManager->GetCurrentFrame(); + } + SysTryReturn(NID_UI, pControl, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + } + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pControl = pControlManager->GetFocusedControl(); + if (!pControl) + { + pControl = pControlManager->GetCurrentFrame(); + } + SysTryReturn(NID_UI, pControl, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + SetLastResult(E_SUCCESS); + + return pControl; + } + +private: + _Control* __pTarget; + _KeyInfo __keyInfo; +}; // _KeyEvent + +class _TouchEventManager +{ +public: + static _TouchEventManager* GetInstance(void) + { + if (__pInstance == null) + { + __pInstance = new (std::nothrow) _TouchEventManager; + SysTryReturn(NID_UI, __pInstance, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + } + + SetLastResult(E_SUCCESS); + + return __pInstance; + } + + result AddControl(int pointId, const _ControlHandle& controlHandle) + { + bool exist = false; + result r = E_SUCCESS; + + __pTargetMap->ContainsKey(pointId, exist); + + if (exist) + { + r = __pTargetMap->Remove(pointId); + SysTryReturnResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + } + + r = __pTargetMap->Add(pointId, controlHandle); + SysTryReturnResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return r; + } + + _Control* GetControl(int pointId) + { + SysTryReturn(NID_UI, __pTargetMap, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _ControlHandle controlHandle; + + __pTargetMap->GetValue(pointId, controlHandle); + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + result r = GetLastResult(); + SysTryReturn(NID_UI, pControlManager, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pControlManager->GetObject(controlHandle); + } + +private: + _TouchEventManager(void) + { + unique_ptr > pTargetMap(new (std::nothrow) HashMapT); + SysTryReturnVoidResult(NID_UI, pTargetMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = pTargetMap->Construct(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTargetMap = move(pTargetMap); + + SetLastResult(E_SUCCESS); + } + + ~_TouchEventManager(void) + { + } + + _TouchEventManager(const _TouchEventManager& rhs); + _TouchEventManager& operator =(const _TouchEventManager& rhs); + +private: + static _TouchEventManager* __pInstance; + unique_ptr > __pTargetMap; +}; + +_TouchEventManager* _TouchEventManager::__pInstance = null; + +class _TouchEvent + : public _Event +{ +public: + _TouchEvent(int deviceId, _TouchStatus status, int x, int y, unsigned int timeStamp, const _Control* pRootControl) + : __pTouchEventManager(null) + { + __pTouchEventManager = _TouchEventManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, __pTouchEventManager, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + result r = E_SUCCESS; + Tizen::Graphics::Point current(x, y); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + unsigned int pointId = 0; + + if (status == _TOUCH_PRESSED) + { + IListT<_FingerInfo*>* pFingerInfoList = pTouchManager->GetMultiFingerInfoListN(); + SysTryReturnVoidResult(NID_UI, pFingerInfoList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + const int count = pFingerInfoList->GetCount(); + + for (int i = 0; i < count; i++) + { + _FingerInfo* pFingerInfo = null; + pFingerInfoList->GetAt(i, pFingerInfo); + if (pFingerInfo == null) + { + continue; + } + + if (pFingerInfo->GetDeviceId() == deviceId && pFingerInfo->GetStatus() == _TOUCH_PRESSED) + { + pTouchManager->ResetTouchInfo(); + SysLog(NID_UI, "ResetTouchInfo x(%d), y(%d), deviceID(%d), pointID(%d)", current.x, current.y, deviceId, pFingerInfo->GetPointId()); + break; + } + } + delete pFingerInfoList; + + pointId = pTouchManager->GeneratePointId(deviceId); + } + else + { + pointId = pTouchManager->GetPointId(deviceId); + } + + SysTryReturnVoidResult(NID_UI, pointId != INVALID_POINT_ID, E_INVALID_CONDITION, "[E_INVALID_CONDITION] pointId is invalid."); + + if (!pRootControl) + { + r = GetPosition(status, x, y, current); +#if defined(MULTI_WINDOW) + SysTryReturnVoidResult(NID_UI, r != E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A system error occurred."); +#endif + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + } + else + { + current = _CoordinateSystemUtils::InverseTransform(current); + } + + __touchInfo.SetTouchInfo(pointId, status, current, false, timeStamp); + + if (status == _TOUCH_PRESSED) + { + _Control* pControl = GetTarget(current.x, current.y, pRootControl); + + if (pControl == null) + { + pTouchManager->ResetTouchInfo(); + SysLog(NID_UI, "ResetTouchInfo x(%d), y(%d), deviceID(%d), pointID(%d)", current.x, current.y, deviceId, pointId); + ClearLastResult(); + } + else + { + r = __pTouchEventManager->AddControl(pointId, pControl->GetHandle()); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + } + } + else + { + _Control* pControl = GetTarget(current.x, current.y, pRootControl); + if (pControl == null) + { + ClearLastResult(); + } + else + { + if (pControl != null && pControl->GetChangingEventTarget() == true) + { + r = __pTouchEventManager->AddControl(pointId, pControl->GetHandle()); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + } + } + } + } + + virtual ~_TouchEvent(void) + { + } + +private: + virtual result SendImpl(void) + { + _Control* pTarget = __pTouchEventManager->GetControl(__touchInfo.GetPointId()); + if (pTarget == null) + { + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + pTouchManager->ResetTouchInfo(); + + SysLog(NID_UI, "ResetTouchInfo"); + return E_SUCCESS; + } + + _UiTouchEvent event(pTarget->GetHandle(), __touchInfo); + + return _pEventManager->SendEvent(event); + } + +private: + _TouchEvent(const _TouchEvent& rhs); + _TouchEvent& operator =(const _TouchEvent& rhs); + + _Control* GetTarget(int x, int y, const _Control* pRootControl) const + { + ClearLastResult(); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _Control* pCapturedControl = pTouchManager->GetCapturedControl(); + _Control* pControl = null; + + if (pCapturedControl) + { + if (pTouchManager->IsCaptureAllowedOutOfBounds()) + { + pControl = pCapturedControl; + } + else + { + Tizen::Graphics::Rectangle rc(pCapturedControl->GetAbsoluteBounds()); + + if ((x < rc.x) || (x > (rc.x + rc.width)) || (y < rc.y) || (y > (rc.y + rc.height))) + { + pControl = pCapturedControl; + } + } + + if (pControl != null) + { + return pControl; + } + } + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Tizen::Graphics::FloatPoint ptf(static_cast(x), static_cast(y)); + + _ControlVisualElement* pRootControlElement = null; + if (pRootControl) + { + pRootControlElement = dynamic_cast<_ControlVisualElement*>(pRootControl->GetVisualElement()); + } + else + { + _Window* pWindow = null; +#if !defined(MULTI_WINDOW) + pWindow = pControlManager->GetCurrentFrame(); +#else + pWindow = pControlManager->GetTouchedWindow(); +#endif + SysTryReturn(NID_UI, pWindow, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Rectangle winBounds = pWindow->GetBounds(); + + ptf.x = static_cast(x - winBounds.x); + ptf.y = static_cast(y - winBounds.y); + +#if !defined(MULTI_WINDOW) + pRootControlElement = dynamic_cast <_ControlVisualElement*>(pControlManager->GetRoot().GetVisualElement()); +#else + pRootControlElement = dynamic_cast <_ControlVisualElement*>(pWindow->GetVisualElement()); +#endif + } + + SysTryReturn(NID_UI, pRootControlElement, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _ControlVisualElement* pControlVisualElement = pRootControlElement->GetControlChildAtPoint(ptf); + SysTryReturn(NID_UI, pControlVisualElement, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pControl = static_cast <_Control*>(pControlVisualElement->GetUserData()); + SysTryReturn(NID_UI, pControl, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return pControl; + } + + result GetPosition(_TouchStatus status, int x, int y, Point& point) const + { + result r = E_SUCCESS; + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + +#if !defined(MULTI_WINDOW) + _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr(); + SysTryReturn(NID_UI, pEcoreEvasMgr, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _EcoreEvas* pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_Evas* pEE = pEcoreEvas->GetEcoreEvas(); + SysTryReturn(NID_UI, pEE, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); +#else + _Window* pWindow = pControlManager->GetTouchedWindow(); + SysTryReturn(NID_UI, pWindow, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] A system error occurred."); + + _RootVisualElement* pRootVE = pWindow->GetRootVisualElement(); + SysTryReturn(NID_UI, pRootVE, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer()); + SysTryReturn(NID_UI, pLayer, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_Evas* pEE = pLayer->GetEcoreEvas(); + SysTryReturn(NID_UI, pEE, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); +#endif + + const int PORTRAIT = 0; + const int LANDSCAPE = 270; + const int PORTRAIT_REVERSE = 180; + const int LANDSCAPE_REVERSE = 90; + + Dimension dimension = pControlManager->GetScreenSize(); + Point output(_CoordinateSystemUtils::InverseTransform(point)); + int rotation = ecore_evas_rotation_get(pEE); + + switch (rotation) + { + case PORTRAIT: + point.x = output.x; + point.y = output.y; + break; + + case LANDSCAPE: + point.x = output.y; + point.y = dimension.width - output.x; + break; + + case PORTRAIT_REVERSE: + point.x = dimension.width - output.x; + point.y = dimension.height - output.y; + break; + + case LANDSCAPE_REVERSE: + point.x = dimension.height - output.y; + point.y = output.x; + break; + + default: + SysAssertf(0, "[E_SYSTEM][%d]", rotation); + r = E_SYSTEM; + break; + } + + return r; + } + +private: + _TouchInfo __touchInfo; + _TouchEventManager* __pTouchEventManager; +}; // _TouchEvent + +Eina_Bool +OnNotified(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo) +{ + if (pEventInfo) + { + _UiEvent* pUiEvent = static_cast <_UiEvent*>(pEventInfo); + SysTryReturn(NID_UI, pUiEvent, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _UiEventManager* pEventManager = _UiEventManager::GetInstance(); + SysTryReturn(NID_UI, pEventManager, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + result r = pEventManager->SendEvent(*pUiEvent); + SysTryReturn(NID_UI, r == E_SUCCESS, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + } + + SetLastResult(E_SUCCESS); + + return ECORE_CALLBACK_PASS_ON; +} + +void +FreeEvent(void* pData __UNUSED__, void* pEventInfo) +{ + _UiEvent* pUiEvent = static_cast <_UiEvent*>(pEventInfo); + if (pUiEvent) + { + delete pUiEvent; + } +} + +Eina_Bool +OnKeyPressed(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo) +{ + Ecore_Event_Key* pEv = static_cast (pEventInfo); + SysTryReturn(NID_UI, pEv, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + //SysLog(NID_UI, "OnKeyPressed(%s, %d)", pEv->keyname, pEv->modifiers); + _KeyEvent event(KEY_PRESSED, _KeyEvent::GetKeyCode(pEv->keyname), _KeyEvent::GetKeyModifier(pEv->modifiers), pEv); + event.Send(); + + SetLastResult(E_SUCCESS); + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool +OnKeyReleased(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo) +{ + Ecore_Event_Key* pEv = static_cast (pEventInfo); + SysTryReturn(NID_UI, pEv, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + //SysLog(NID_UI, "OnKeyReleased(%s, %d)", pEv->keyname, pEv->modifiers); + _KeyEvent event(KEY_RELEASED, _KeyEvent::GetKeyCode(pEv->keyname), _KeyEvent::GetKeyModifier(pEv->modifiers), pEv); + event.Send(); + + SetLastResult(E_SUCCESS); + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool +OnTouchPressed(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo) +{ + Ecore_Event_Mouse_Button* pEv = static_cast (pEventInfo); + SysTryReturn(NID_UI, pEv, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + +#if defined(MULTI_WINDOW) + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pControlManager->SetTouchedWindow((unsigned int)pEv->window); +#endif + + isPressed = true; + + SysLog(NID_UI, "OnTouchPressed - x(%d), y(%d), deviceId(%d)", pEv->root.x, pEv->root.y, pEv->multi.device); + _TouchEvent event(pEv->multi.device, _TOUCH_PRESSED, pEv->root.x, pEv->root.y, pEv->timestamp, null); + + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, ECORE_CALLBACK_PASS_ON, r, "[%s] Propagating.", GetErrorMessage(r)); + + event.Send(); + + SetLastResult(E_SUCCESS); + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool +OnTouchReleased(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo) +{ + Ecore_Event_Mouse_Button* pEv = static_cast (pEventInfo); + SysTryReturn(NID_UI, pEv, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + isPressed = false; + + SysLog(NID_UI, "OnTouchReleased - x(%d), y(%d), deviceId(%d)", pEv->root.x, pEv->root.y, pEv->multi.device); + _TouchEvent event(pEv->multi.device, _TOUCH_RELEASED, pEv->root.x, pEv->root.y, pEv->timestamp, null); + + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + event.Send(); + + SetLastResult(E_SUCCESS); + + return ECORE_CALLBACK_PASS_ON; + +CATCH: + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + if (pTouchManager) + { + SysLogException(NID_UI, E_SUCCESS, "ResetTouchInfo"); + pTouchManager->SetTouchAllowed(false); + pTouchManager->ResetTouchInfo(); + } + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool +OnTouchMoved(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo) +{ + Ecore_Event_Mouse_Move* pEv = static_cast (pEventInfo); + SysTryReturn(NID_UI, pEv, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + //SysLog(NID_UI, "OnTouchMoved - x(%d), y(%d), deviceId(%d)", pEv->root.x, pEv->root.y, pEv->multi.device); + _TouchEvent event(pEv->multi.device, _TOUCH_MOVED, pEv->root.x, pEv->root.y, pEv->timestamp, null); + + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, ECORE_CALLBACK_PASS_ON, r, "[%s] Propagating.", GetErrorMessage(r)); + + event.Send(); + + SetLastResult(E_SUCCESS); + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool +OnKeyboardInserted(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo) +{ + Ecore_X_Event_Window_Property *pEv = static_cast (pEventInfo); + if ( pEv->atom != keyboardExist) + { +// SysLog(NID_UI, "OnKeyboardInserted - atom of event(%d), keyboardExist(%d)", pEv->atom, keyboardExist); + return ECORE_CALLBACK_PASS_ON; + } + + ArrayList* pArgs = null; + result r = E_SUCCESS; + Boolean* pIsKeyboardOn = null; + _UiEventManager* pEventManager = _UiEventManager::GetInstance(); + SysTryReturn(NID_UI, pEventManager, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _Control* pControl = _ControlManager::GetInstance()->GetFocusedControl(); + SysTryReturn(NID_UI, pControl, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + bool isKeyboardOn = false; + unsigned int value = 0; + int returnResult = -1; + + returnResult = ecore_x_window_prop_card32_get(pEv->win, keyboardExist, &value, 1); + if (returnResult) + { + if (value > 0) + { + isKeyboardOn = true; + } + + pArgs = new (std::nothrow) ArrayList; + SysTryReturn(NID_UI, pArgs, ECORE_CALLBACK_PASS_ON, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pArgs->Construct(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + String* pString = new (std::nothrow) String(KEYBOARD_INSERTED_EVENT); + r = pArgs->Add(*pString); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pIsKeyboardOn = new (std::nothrow) Boolean(isKeyboardOn); + r = pArgs->Add(*pIsKeyboardOn); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + _UiNotificationEvent event(pControl->GetHandle(), pArgs); + r = pEventManager->SendEvent(event); +// SysLog(NID_UI, "OnKeyboardInserted - sent keyboard inserted noti"); + } + + SetLastResult(r); + + return ECORE_CALLBACK_PASS_ON; + +CATCH: + if (pArgs) + { + delete pArgs; + } + + if (pIsKeyboardOn) + { + delete pIsKeyboardOn; + } + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool +OnWindowFocusIn(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo) +{ + SysLog(NID_UI, "Enter"); + + Ecore_X_Event_Window_Focus_In* pEv = static_cast(pEventInfo); + SysTryReturn(NID_UI, pEv, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + int count = pControlManager->GetWindowCount(); + + _Control* pFocusedControl = null; + for (int i = count - 1; i >= 0; --i) + { + _Window* pWindow = pControlManager->GetWindow(i); + if (pWindow) + { +#if !defined(MULTI_WINDOW) + pFocusedControl = pWindow->GetFocused(); + if (pFocusedControl) + { + pFocusedControl->SetFocused(); + break; + } +#else + NativeWindowHandle nativeWindowHandle = pWindow->GetNativeHandle(); + if (pEv->win == nativeWindowHandle) + { + pFocusedControl = pWindow->GetFocused(); + if (pFocusedControl) + { + pFocusedControl->SetFocused(); + break; + } + } +#endif + } + } + + return ECORE_CALLBACK_PASS_ON; +} + +Eina_Bool +OnWindowFocusOut(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo) +{ + SysLog(NID_UI, "Enter"); + + Ecore_X_Event_Window_Focus_Out* pEv = static_cast(pEventInfo); + SysTryReturn(NID_UI, pEv, ECORE_CALLBACK_PASS_ON, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + +#if !defined(MULTI_WINDOW) + _Control* pFocusedControl = pControlManager->GetFocusedControl(); + if (pFocusedControl) + { + pControlManager->TakeFocusFromControl(*pFocusedControl); + } +#else + _Control* pFocusedControl = pControlManager->GetFocusedControl(); + if (pFocusedControl) + { + _Window* pRootWindow = pFocusedControl->GetRootWindow(); + if (pRootWindow) + { + NativeWindowHandle nativeWindowHandle = pRootWindow->GetNativeHandle(); + if (pEv->win == nativeWindowHandle) + { + pControlManager->TakeFocusFromControl(*pFocusedControl); + } + } + } +#endif + + return ECORE_CALLBACK_PASS_ON; +} + +// Evas Callbacks +void +OnEvasKeyPressed(void* pData, Evas* pEvas, Evas_Object* pEvasObject, void* pEventInfo) +{ + Evas_Event_Key_Down* pEv = static_cast (pEventInfo); + SysTryReturnVoidResult(NID_UI, pEv, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SetLastResult(E_SUCCESS); +} + +void +OnEvasKeyReleased(void* pData, Evas* pEvas, Evas_Object* pEvasObject, void* pEventInfo) +{ + Evas_Event_Key_Up* pEv = static_cast (pEventInfo); + SysTryReturnVoidResult(NID_UI, pEv, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SetLastResult(E_SUCCESS); +} + +void +OnEvasTouchPressed(void* pData, Evas* pEvas, Evas_Object* pEvasObject, void* pEventInfo) +{ + Evas_Event_Mouse_Down* pEv = static_cast (pEventInfo); + SysTryReturnVoidResult(NID_UI, pEv, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _Control* pControl = static_cast<_Control*>(pData); + SysTryReturnVoidResult(NID_UI, pControl, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _TouchEvent event(0, _TOUCH_PRESSED, pEv->canvas.x, pEv->canvas.y, pEv->timestamp, pControl); + + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + event.Send(); + + SetLastResult(E_SUCCESS); +} + +void +OnEvasTouchReleased(void* pData, Evas* pEvas, Evas_Object* pEvasObject, void* pEventInfo) +{ + Evas_Event_Mouse_Up* pEv = static_cast (pEventInfo); + SysTryReturnVoidResult(NID_UI, pEv, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _Control* pControl = static_cast<_Control*>(pData); + SysTryReturnVoidResult(NID_UI, pControl, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _TouchEvent event(0, _TOUCH_RELEASED, pEv->canvas.x, pEv->canvas.y, pEv->timestamp, pControl); + + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + event.Send(); + + SetLastResult(E_SUCCESS); +} + +void +OnEvasTouchMoved(void* pData, Evas* pEvas, Evas_Object* pEvasObject, void* pEventInfo) +{ + Evas_Event_Mouse_Move* pEv = static_cast (pEventInfo); + SysTryReturnVoidResult(NID_UI, pEv, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _Control* pControl = static_cast<_Control*>(pData); + SysTryReturnVoidResult(NID_UI, pControl, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _TouchEvent event(0, _TOUCH_MOVED, pEv->cur.canvas.x, pEv->cur.canvas.y, pEv->timestamp, pControl); + + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + event.Send(); + + SetLastResult(E_SUCCESS); +} + +void +OnEvasMultiTouchPressed(void* pData, Evas* pEvas, Evas_Object* pEvasObject, void* pEventInfo) +{ + Evas_Event_Multi_Down* pEv = static_cast (pEventInfo); + SysTryReturnVoidResult(NID_UI, pEv, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SetLastResult(E_SUCCESS); +} + +void +OnEvasMultiTouchReleased(void* pData, Evas* pEvas, Evas_Object* pEvasObject, void* pEventInfo) +{ + Evas_Event_Multi_Up* pEv = static_cast (pEventInfo); + SysTryReturnVoidResult(NID_UI, pEv, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SetLastResult(E_SUCCESS); +} + +void +OnEvasMultiTouchMoved(void* pData, Evas* pEvas, Evas_Object* pEvasObject, void* pEventInfo) +{ + Evas_Event_Multi_Move* pEv = static_cast (pEventInfo); + SysTryReturnVoidResult(NID_UI, pEv, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + SetLastResult(E_SUCCESS); +} + +}; // Anonymous + +namespace Tizen { namespace Ui +{ + +_EflUiEventManager::_EflUiEventManager(void) + : __notificaitonEventType(-1) +{ + unique_ptr > pEventHandlers(new (std::nothrow) LinkedListT); + SysTryReturnVoidResult(NID_UI, pEventHandlers, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + // Noti + __notificaitonEventType = ecore_event_type_new(); + SysTryReturnVoidResult(NID_UI, __notificaitonEventType >= 1, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_Event_Handler* pEventHandler = ecore_event_handler_add(__notificaitonEventType, OnNotified, null); + SysTryReturnVoidResult(NID_UI, pEventHandler, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pEventHandlers->Add(pEventHandler); + + // Key + pEventHandler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, OnKeyPressed, null); + SysTryReturnVoidResult(NID_UI, pEventHandler, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pEventHandlers->Add(pEventHandler); + + pEventHandler = ecore_event_handler_add(ECORE_EVENT_KEY_UP, OnKeyReleased, null); + SysTryReturnVoidResult(NID_UI, pEventHandler, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pEventHandlers->Add(pEventHandler); + + // Touch + pEventHandler = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, OnTouchPressed, null); + SysTryReturnVoidResult(NID_UI, pEventHandler, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pEventHandlers->Add(pEventHandler); + + pEventHandler = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, OnTouchReleased, null); + SysTryReturnVoidResult(NID_UI, pEventHandler, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pEventHandlers->Add(pEventHandler); + + pEventHandler = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, OnTouchMoved, null); + SysTryReturnVoidResult(NID_UI, pEventHandler, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pEventHandlers->Add(pEventHandler); + + // WIndow property + pEventHandler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, OnKeyboardInserted, null); + SysTryReturnVoidResult(NID_UI, pEventHandler, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pEventHandlers->Add(pEventHandler); + + // WIndo focus + pEventHandler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, OnWindowFocusIn, null); + SysTryReturnVoidResult(NID_UI, pEventHandler, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pEventHandlers->Add(pEventHandler); + + pEventHandler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, OnWindowFocusOut, null); + SysTryReturnVoidResult(NID_UI, pEventHandler, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pEventHandlers->Add(pEventHandler); + + __pEventHandlers = move(pEventHandlers); + + keyboardExist = XInternAtom(static_cast(ecore_x_display_get()), "X External Keyboard Exist", 0); + + SetLastResult(E_SUCCESS); +} + +_EflUiEventManager::~_EflUiEventManager(void) +{ + Tizen::Base::Collection::IEnumeratorT* pEnumerator = __pEventHandlers->GetEnumeratorN(); + SysTryReturnVoidResult(NID_UI, pEnumerator, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + Ecore_Event_Handler* pEventHandler = null; + pEnumerator->GetCurrent(pEventHandler); + if (pEventHandler) + { + ecore_event_handler_del(pEventHandler); + } + } + + delete pEnumerator; +} + +result +_EflUiEventManager::RegisterKeyEventHandler(const _Control& control) +{ + result r = E_SUCCESS; + + Evas_Object* pEvasObject = GetEvasObject(control); + SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + evas_object_event_callback_add(pEvasObject, EVAS_CALLBACK_KEY_UP, OnEvasKeyReleased, &control); + evas_object_event_callback_add(pEvasObject, EVAS_CALLBACK_KEY_DOWN, OnEvasKeyPressed, &control); + + return r; +} + +result +_EflUiEventManager::RegisterTouchEventHandler(const _Control& control) +{ + result r = E_SUCCESS; + + Evas_Object* pEvasObject = GetEvasObject(control); + SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + evas_object_event_callback_add(pEvasObject, EVAS_CALLBACK_MOUSE_UP, OnEvasTouchReleased, &control); + evas_object_event_callback_add(pEvasObject, EVAS_CALLBACK_MOUSE_DOWN, OnEvasTouchPressed, &control); + evas_object_event_callback_add(pEvasObject, EVAS_CALLBACK_MOUSE_MOVE, OnEvasTouchMoved, &control); + + evas_object_event_callback_add(pEvasObject, EVAS_CALLBACK_MULTI_UP, OnEvasMultiTouchReleased, &control); + evas_object_event_callback_add(pEvasObject, EVAS_CALLBACK_MULTI_DOWN, OnEvasMultiTouchPressed, &control); + evas_object_event_callback_add(pEvasObject, EVAS_CALLBACK_MULTI_MOVE, OnEvasMultiTouchMoved, &control); + + return r; +} + +result +_EflUiEventManager::UnregisterKeyEventHandler(const _Control& control) +{ + result r = E_SUCCESS; + + Evas_Object* pEvasObject = GetEvasObject(control); + SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + evas_object_event_callback_del(pEvasObject, EVAS_CALLBACK_KEY_UP, OnEvasKeyReleased); + evas_object_event_callback_del(pEvasObject, EVAS_CALLBACK_KEY_DOWN, OnEvasKeyPressed); + + return r; +} + +result +_EflUiEventManager::UnregisterTouchEventHandler(const _Control& control) +{ + result r = E_SUCCESS; + + Evas_Object* pEvasObject = GetEvasObject(control); + SysTryReturn(NID_UI, pEvasObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + evas_object_event_callback_del(pEvasObject, EVAS_CALLBACK_MOUSE_UP, OnEvasTouchReleased); + evas_object_event_callback_del(pEvasObject, EVAS_CALLBACK_MOUSE_DOWN, OnEvasTouchPressed); + evas_object_event_callback_del(pEvasObject, EVAS_CALLBACK_MOUSE_MOVE, OnEvasTouchMoved); + + evas_object_event_callback_del(pEvasObject, EVAS_CALLBACK_MULTI_UP, OnEvasMultiTouchReleased); + evas_object_event_callback_del(pEvasObject, EVAS_CALLBACK_MULTI_DOWN, OnEvasMultiTouchPressed); + evas_object_event_callback_del(pEvasObject, EVAS_CALLBACK_MULTI_MOVE, OnEvasMultiTouchMoved); + + return r; +} + +result +_EflUiEventManager::PostEvent(const _UiEvent& event) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + _UiEvent* pEvent = event.CloneN(); + SysTryReturn(NID_UI, pEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_Event* pEcoreEvent = ecore_event_add(__notificaitonEventType, pEvent, FreeEvent, null); + SysTryReturn(NID_UI, pEcoreEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return r; +} + +void +_EflUiEventManager::SetKeyCapture(const _Control& control, _KeyCode keyCode) +{ + Ecore_X_Window win = ecore_evas_software_x11_window_get(ecore_evas_ecore_evas_get(evas_object_evas_get(GetEvasObject(control)))); + + for (unsigned int i = 0; i < sizeof(keyTable) / sizeof(_EvasConvertKeys); ++i) + { + if (keyTable[i].code == keyCode) + { + if (keyTable[i].pName) + { + utilx_grab_key((Display*)ecore_x_display_get(), win, keyTable[i].pName, TOP_POSITION_GRAB); + break; + } + } + } +} + +void +_EflUiEventManager::ReleaseKeyCapture(const _Control& control, _KeyCode keyCode) +{ + Ecore_X_Window win = ecore_evas_software_x11_window_get(ecore_evas_ecore_evas_get(evas_object_evas_get(GetEvasObject(control)))); + + for (unsigned int i = 0; i < sizeof(keyTable) / sizeof(_EvasConvertKeys); ++i) + { + if (keyTable[i].code == keyCode) + { + if (keyTable[i].pName) + { + utilx_ungrab_key((Display*)ecore_x_display_get(), win, keyTable[i].pName); + break; + } + } + } +} +} + +} // Tizen::Ui diff --git a/src/ui/FUi_EflUiEventManager.h b/src/ui/FUi_EflUiEventManager.h new file mode 100644 index 0000000..9d56af7 --- /dev/null +++ b/src/ui/FUi_EflUiEventManager.h @@ -0,0 +1,75 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_EflUiEventManager.h + * @brief This is the header file for the _EflUiEventManager class. + * + * This header file contains the declarations of the _EflUiEventManager class. @n + */ +#ifndef _FUI_INTERNAL_EFL_UI_EVENT_MANAGER_H_ +#define _FUI_INTERNAL_EFL_UI_EVENT_MANAGER_H_ + +#include +#include +#include "FUi_IUiEventManager.h" + +namespace Tizen { namespace Ui +{ + +/** + * This is internal. If used in an application, the application can get rejected during the certification process. + * @class FUi_EflUiEventManager + * @brief This class impliments _EflUiEventManager and + * fire the Window Event object of a Ui Control. + */ +class _EflUiEventManager + : public _IUiEventManager +{ +public: + /** + * This is the default class constructor. + * + */ + _EflUiEventManager(void); + + /** + * This is the default class destructor. + * + */ + virtual ~_EflUiEventManager(void); + +private: + _EflUiEventManager(const _EflUiEventManager& rhs); + _EflUiEventManager& operator =(const _EflUiEventManager& rhs); + + virtual result RegisterKeyEventHandler(const _Control& control); + virtual result RegisterTouchEventHandler(const _Control& control); + virtual result UnregisterKeyEventHandler(const _Control& control); + virtual result UnregisterTouchEventHandler(const _Control& control); + virtual result PostEvent(const _UiEvent& event); + + virtual void SetKeyCapture(const _Control& control, _KeyCode keyCode); + virtual void ReleaseKeyCapture(const _Control& control, _KeyCode keyCode); + +private: + int __notificaitonEventType; + std::unique_ptr > __pEventHandlers; +}; // _EflUiEventManager + +}} // Tizen::Ui + +#endif //_FUI_INTERNAL_EFL_UI_EVENT_MANAGER_H_ diff --git a/src/ui/FUi_EflWindow.cpp b/src/ui/FUi_EflWindow.cpp new file mode 100644 index 0000000..1d6c858 --- /dev/null +++ b/src/ui/FUi_EflWindow.cpp @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_EflWindow.cpp + * @brief This is the implementation file for the _EflWindow class. + */ +#include +#include +#include "FUi_EflWindow.h" +#include "FUiAnim_RootVisualElement.h" +#include "FUi_EcoreEvas.h" +#include "FUi_Control.h" + +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui +{ + +_EflWindow* +_EflWindow::CreateInstanceN(void) +{ + _EflWindow* pEflWindow = new (std::nothrow) _EflWindow; + SysTryReturn(NID_UI, pEflWindow, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pEflWindow; + +CATCH: + delete pEflWindow; + return null; +} + +_EflWindow::~_EflWindow(void) +{ + if (__pEcoreEvas) + { + delete __pEcoreEvas; + __pEcoreEvas = null; + } +} + +void +_EflWindow::SetFrame(const _Control& control) +{ + __pEcoreEvas->SetFrame(control); +} + +_EflWindow::_EflWindow(void) + : __pEcoreEvas(null) +{ + __pEcoreEvas = _EcoreEvas::CreateInstanceN(); + + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, __pEcoreEvas, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} +_RootVisualElement* +_EflWindow::GetRootVisualElement(void) +{ + if(__pEcoreEvas) + { + return __pEcoreEvas->GetRootVisualElement(); + } + return null; + +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_EflWindow.h b/src/ui/FUi_EflWindow.h new file mode 100644 index 0000000..fe618f2 --- /dev/null +++ b/src/ui/FUi_EflWindow.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_EflWindow.h + * @brief This is the header file for the _EflWindow class. + * + * This header file contains the declarations of the %_EflWindow class. + */ +#ifndef _FUI_INTERNAL_EFL_WINDOW_H_ +#define _FUI_INTERNAL_EFL_WINDOW_H_ + +#include +#include "FUi_IWindow.h" + +namespace Tizen { namespace Ui { namespace Animations +{ +class _RootVisualElement; +}}} + +namespace Tizen { namespace Ui +{ +class _EcoreEvas; +class _Control; + +class _EflWindow + : public _IWindow +{ +public: + static _EflWindow* CreateInstanceN(void); + + virtual ~_EflWindow(void); + + virtual void SetFrame(const _Control& control); + + Tizen::Ui::Animations::_RootVisualElement* GetRootVisualElement(void); + +private: + _EflWindow(void); + + _EflWindow(const _EflWindow& rhs); + _EflWindow& operator =(const _EflWindow& rhs); + +private: + _EcoreEvas* __pEcoreEvas; +}; // _EflWindow + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_EFL_WINDOW_H_ diff --git a/src/ui/FUi_ErrorMessages.cpp b/src/ui/FUi_ErrorMessages.cpp new file mode 100644 index 0000000..70698e8 --- /dev/null +++ b/src/ui/FUi_ErrorMessages.cpp @@ -0,0 +1,25 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include "FUi_ErrorMessages.h" + +namespace Tizen { namespace Ui { + +const char* _UiError::OUT_OF_MEMORY = "[E_OUT_OF_MEMORY] Insufficient memory."; +const char* _UiError::SYSTEM = "[E_SYSTEM] System error occurred."; + +}} // Tizen::Ui diff --git a/src/ui/FUi_FingerInfo.cpp b/src/ui/FUi_FingerInfo.cpp new file mode 100644 index 0000000..6afc611 --- /dev/null +++ b/src/ui/FUi_FingerInfo.cpp @@ -0,0 +1,126 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_FingerInfo.cpp + * @brief This is the implementation file for _FingerInfo class. + */ + +// Includes +#include +#include "FUi_FingerInfo.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +_FingerInfo::_FingerInfo(void) + : __deviceId(INVALID_POINT_ID) + , __pointId(INVALID_POINT_ID) + , __status(_TOUCH_FOCUS_OUT) + , __point(0, 0) + , __startPoint(0, 0) + , __screenPoint(0, 0) + ,__touchMoveReady(false) +{ +} + +_FingerInfo::~_FingerInfo(void) +{ +} + +void +_FingerInfo::SetDeviceId(unsigned long deviceId) +{ + __deviceId = deviceId; +} + +unsigned long +_FingerInfo::GetDeviceId(void) const +{ + return __deviceId; +} + +void +_FingerInfo::SetPointId(unsigned long pointId) +{ + __pointId = pointId; +} + +void +_FingerInfo::SetPoint(const Point& screenPoint, const Point& point) +{ + __screenPoint = screenPoint; + __point = point; +} + +unsigned long +_FingerInfo::GetPointId(void) const +{ + return __pointId; +} + +Point +_FingerInfo::GetPoint(void) const +{ + return __point; +} + +Point +_FingerInfo::GetScreenPoint(void) const +{ + return __screenPoint; +} + +void +_FingerInfo::SetStatus(const _TouchStatus status) +{ + __status = status; +} + +_TouchStatus +_FingerInfo::GetStatus(void) const +{ + return __status; +} + +void +_FingerInfo::SetStartPoint(const Point& point) +{ + __startPoint = point; +} + +Point +_FingerInfo::GetStartPoint(void) const +{ + return __startPoint; +} + +void +_FingerInfo::SetMoveReady(bool moveReady) +{ + __touchMoveReady = moveReady; +} + +bool +_FingerInfo::GetMoveReady(void) const +{ + return __touchMoveReady; +} + +} } //Tizen::Ui diff --git a/src/ui/FUi_FocusManagerImpl.cpp b/src/ui/FUi_FocusManagerImpl.cpp new file mode 100644 index 0000000..f548a47 --- /dev/null +++ b/src/ui/FUi_FocusManagerImpl.cpp @@ -0,0 +1,122 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_FocusManagerImpl.cpp +* @brief This is the implementation file for _FocusManagerImpl class. +* @version 2.0 +* +*/ + +#include "FUi_FocusManagerImpl.h" +#include "FUi_ControlImpl.h" +#include "FUi_WindowImpl.h" +#include "FUi_ControlManager.h" + + +namespace Tizen { namespace Ui +{ +//////////////////////////////////////////////////////////////////////////////// +/// _FocusManagerImpl class Lifecycle +_FocusManagerImpl* _FocusManagerImpl::__pInstance = null; + +_FocusManagerImpl::_FocusManagerImpl(void) +{ + //NOHING +} + + +_FocusManagerImpl::~_FocusManagerImpl(void) +{ + // NOTHING +} + +void +_FocusManagerImpl::Initialize(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (__pInstance == null) + { + pthread_once(&once_block, InitializeInstance); + } +} + +_FocusManagerImpl* +_FocusManagerImpl::GetInstance(void) +{ + return __pInstance; +} + +void +_FocusManagerImpl::InitializeInstance(void) +{ + ClearLastResult(); + + if (__pInstance == null) + { + __pInstance = new (std::nothrow) _FocusManagerImpl; + SysTryReturnVoidResult(NID_UI, __pInstance != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + } +} + +void +_FocusManagerImpl::ReleaseInstance(void) +{ + if (__pInstance) + { + delete __pInstance; + __pInstance = null; + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// _FocusManagerImpl class Operation + +_ControlImpl* +_FocusManagerImpl::GetCurrentFocusOwner(void) const +{ + _Control* pFocus = _ControlManager::GetInstance()->GetFocusedControl(); + if(pFocus == null) + { + return null; + } + + _ControlImpl* pFocusImpl = static_cast <_ControlImpl*>(pFocus->GetUserData()); + SysAssert(pFocusImpl); + + return pFocusImpl; +} + + +_WindowImpl* +_FocusManagerImpl::GetCurrentFocusedWindow(void) const +{ + _Control* pFocus = _ControlManager::GetInstance()->GetFocusedControl(); + if(pFocus == null) + { + return null; + } + _Window* pWindow = pFocus->GetRootWindow(); + SysAssert(pWindow); + + _WindowImpl* pWindowImpl = static_cast <_WindowImpl*>(static_cast <_ControlImpl*>(pWindow->GetUserData())); + SysAssert(pWindowImpl); + + return pWindowImpl; +} + +} } //Tizen::Ui diff --git a/src/ui/FUi_GridLayoutImpl.cpp b/src/ui/FUi_GridLayoutImpl.cpp new file mode 100644 index 0000000..d081c95 --- /dev/null +++ b/src/ui/FUi_GridLayoutImpl.cpp @@ -0,0 +1,456 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_GridLayoutImpl.cpp + * @brief This is the implementation file for _GridLayoutImpl class. + * + * This file contains the implementation of _GridLayoutImpl class. + */ + +#include "FUi_GridLayoutImpl.h" + +namespace Tizen { namespace Ui +{ + +// _GridLayoutImpl implementation +_GridLayoutImpl::_GridLayoutImpl(GridLayout* pPublicLayout, _Layout::TableLayout* pCoreLayout) + : _LayoutImpl(pPublicLayout, pCoreLayout) + , __maxRow(0) + , __maxColumn(0) +{ +} + +_GridLayoutImpl::~_GridLayoutImpl() +{ +} + +Tizen::Ui::LayoutType +_GridLayoutImpl::GetLayoutType(void) const +{ + return LAYOUT_GRID; +} + +_GridLayoutImpl* +_GridLayoutImpl::CreateGridLayoutImplN(GridLayout* pPublicLayout, int maxRow, int maxColumn) +{ + ClearLastResult(); + + _Layout::TableLayout* pCoreLayout = null; + _GridLayoutImpl* pImplLayout = null; + result r = E_SUCCESS; + + pCoreLayout = _Layout::TableLayout::CreateTableLayoutN(); + r = GetLastResult(); + SysTryReturn(NID_UI, pCoreLayout != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImplLayout = new (std::nothrow) _GridLayoutImpl(pPublicLayout, pCoreLayout); + r = CheckConstruction(pCoreLayout, pImplLayout); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImplLayout->Construct(maxRow, maxColumn); + if (r != E_SUCCESS) + { + delete pImplLayout; + SysTryReturn(NID_UI, false, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pImplLayout; +} + +const char* +_GridLayoutImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::GridLayout"; +} + +const GridLayout& +_GridLayoutImpl::GetPublic(void) const +{ + return static_cast (_LayoutImpl::GetPublic()); +} + +GridLayout& +_GridLayoutImpl::GetPublic(void) +{ + return static_cast (_LayoutImpl::GetPublic()); +} + +const _Layout::TableLayout& +_GridLayoutImpl::GetCore(void) const +{ + return static_cast (_LayoutImpl::GetCore()); +} + +_Layout::TableLayout& +_GridLayoutImpl::GetCore(void) +{ + return static_cast <_Layout::TableLayout&>(_LayoutImpl::GetCore()); +} + +const _GridLayoutImpl* +_GridLayoutImpl::GetInstance(const GridLayout& layout) +{ + return static_cast(_LayoutImpl::GetInstance(layout)); +} + +_GridLayoutImpl* +_GridLayoutImpl::GetInstance(GridLayout& layout) +{ + return static_cast<_GridLayoutImpl*>(_LayoutImpl::GetInstance(layout)); +} + +result +_GridLayoutImpl::Construct(int maxRow, int maxColumn) +{ + ClearLastResult(); + + result r = GetCore().CreateTable(maxRow, maxColumn); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __maxRow = maxRow; + __maxColumn = maxColumn; + + return E_SUCCESS; +} + +result +_GridLayoutImpl::SetColumnStretchable(int columnIndex, bool stretchable) +{ + ClearLastResult(); + + return GetCore().SetColumnStretchable(columnIndex, stretchable); +} + +result +_GridLayoutImpl::SetColumnShrinkable(int columnIndex, bool shrinkable) +{ + ClearLastResult(); + + return GetCore().SetColumnShrinkable(columnIndex, shrinkable); +} + +result +_GridLayoutImpl::SetColumnCollapsed(int columnIndex, bool collapsed) +{ + ClearLastResult(); + + return GetCore().SetColumnCollapsed(columnIndex, collapsed); +} + +result +_GridLayoutImpl::SetAllColumnsStretchable(bool stretchable) +{ + ClearLastResult(); + + result r = E_SUCCESS; + bool* pOldStretchable = new (std::nothrow) bool[__maxColumn]; + SysTryReturn(NID_UI, pOldStretchable != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + memset(pOldStretchable, 0, sizeof(bool) * __maxColumn); + + int col = 0; + for (col = 0; col < __maxColumn; col++) + { + pOldStretchable[col] = GetCore().GetColumnStretchable(col); + r = GetLastResult(); + if (r != E_SUCCESS) + { + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] max column is invalid value."); + goto CATCH; + } + + r = GetCore().SetColumnStretchable(col, stretchable); + if (r != E_SUCCESS) + { + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] max column is invalid value."); + goto CATCH; + } + } + + delete[] pOldStretchable; + + return r; + +CATCH: + for (int colIndex = 0; colIndex < col; colIndex++) + { + GetCore().SetColumnStretchable(colIndex, pOldStretchable[colIndex]); + } + + delete[] pOldStretchable; + + return r; +} + +result +_GridLayoutImpl::SetAllColumnsShrinkable(bool shrinkable) +{ + ClearLastResult(); + + result r = E_SUCCESS; + bool* pOldShrinkable = new (std::nothrow) bool[__maxColumn]; + SysTryReturn(NID_UI, pOldShrinkable != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + memset(pOldShrinkable, 0, sizeof(bool) * __maxColumn); + + int col = 0; + for (col = 0; col < __maxColumn; col++) + { + pOldShrinkable[col] = GetCore().GetColumnShrinkable(col); + r = GetLastResult(); + if (r != E_SUCCESS) + { + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] max column is invalid value."); + goto CATCH; + } + + r = GetCore().SetColumnShrinkable(col, shrinkable); + if (r != E_SUCCESS) + { + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] max column is invalid value."); + goto CATCH; + } + } + + delete[] pOldShrinkable; + + return r; + +CATCH: + for (int colIndex = 0; colIndex < col; colIndex++) + { + GetCore().SetColumnShrinkable(colIndex, pOldShrinkable[colIndex]); + } + + delete[] pOldShrinkable; + + return r; +} + +result +_GridLayoutImpl::SetColumnSpacing(int columnIndex, int space) +{ + ClearLastResult(); + + return GetCore().SetColumnSpacing(columnIndex, space); +} + +result +_GridLayoutImpl::SetRowStretchable(int rowIndex, bool stretchable) +{ + ClearLastResult(); + + return GetCore().SetRowStretchable(rowIndex, stretchable); +} + +result +_GridLayoutImpl::SetRowShrinkable(int rowIndex, bool shrinkable) +{ + ClearLastResult(); + + return GetCore().SetRowShrinkable(rowIndex, shrinkable); +} + +result +_GridLayoutImpl::SetRowCollapsed(int rowIndex, bool collapsed) +{ + ClearLastResult(); + + return GetCore().SetRowCollapsed(rowIndex, collapsed); +} + +result +_GridLayoutImpl::SetAllRowsStretchable(bool stretchable) +{ + ClearLastResult(); + + result r = E_SUCCESS; + bool* pOldStretchable = new (std::nothrow) bool[__maxRow]; + SysTryReturn(NID_UI, pOldStretchable != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + memset(pOldStretchable, 0, sizeof(bool) * __maxRow); + + + int row = 0; + for (row = 0; row < __maxRow; row++) + { + pOldStretchable[row] = GetCore().GetRowStretchable(row); + r = GetLastResult(); + if (r != E_SUCCESS) + { + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] max row is invalid value."); + goto CATCH; + } + + r = GetCore().SetRowStretchable(row, stretchable); + if (r != E_SUCCESS) + { + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] max row is invalid value."); + goto CATCH; + } + } + + delete[] pOldStretchable; + + return r; + +CATCH: + for (int rowIndex = 0; rowIndex < row; rowIndex++) + { + GetCore().SetRowStretchable(rowIndex, pOldStretchable[rowIndex]); + } + + delete[] pOldStretchable; + + return r; +} + +result +_GridLayoutImpl::SetAllRowsShrinkable(bool shrinkable) +{ + ClearLastResult(); + + result r = E_SUCCESS; + bool* pOldShrinkable = new (std::nothrow) bool[__maxRow]; + SysTryReturn(NID_UI, pOldShrinkable != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + memset(pOldShrinkable, 0, sizeof(bool) * __maxRow); + + int row = 0; + for (row = 0; row < __maxRow; row++) + { + pOldShrinkable[row] = GetCore().GetRowShrinkable(row); + r = GetLastResult(); + if (r != E_SUCCESS) + { + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] max row is invalid value."); + goto CATCH; + } + + r = GetCore().SetRowShrinkable(row, shrinkable); + if (r != E_SUCCESS) + { + SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] max row is invalid value."); + goto CATCH; + } + } + + delete[] pOldShrinkable; + + return r; + +CATCH: + for (int rowIndex = 0; rowIndex < row; rowIndex++) + { + GetCore().SetRowShrinkable(rowIndex, pOldShrinkable[rowIndex]); + } + delete[] pOldShrinkable; + + return r; +} + +result +_GridLayoutImpl::SetRowSpacing(int rowIndex, int space) +{ + ClearLastResult(); + + return GetCore().SetRowSpacing(rowIndex, space); +} + +result +_GridLayoutImpl::SetPosition(_ControlImpl& control, int row, int column, int rowSpan, int columnSpan) +{ + ClearLastResult(); + + _Layout::LayoutItem& layoutItem = control.GetLayoutContainer(); + + result r = E_SUCCESS; + int rowSize = 1; + int colSize = 1; + + SysTryReturn(NID_UI, GetCore().ItemExists(layoutItem), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The control is not belong to layout"); + + SysTryReturn(NID_UI, row >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : row(%d)", row); + SysTryReturn(NID_UI, row < __maxRow, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument row over the max row : row(%d), maxRow(%d)", row, __maxRow); + SysTryReturn(NID_UI, column >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : column(%d)", column); + SysTryReturn(NID_UI, column < __maxColumn, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument column over the max column : column(%d), maxColumn(%d)", column, __maxColumn); + + SysTryReturn(NID_UI, rowSpan >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The row span is negative value."); + SysTryReturn(NID_UI, columnSpan >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The column span is negative value."); + + SysTryReturn(NID_UI, (row + rowSpan - 1) < __maxRow, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Out of range."); + SysTryReturn(NID_UI, (column + columnSpan - 1) < __maxColumn, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Out of range."); + + r = GetCore().GetMergeSize(row, column, rowSize, colSize); + SysTryReturn(NID_UI, (r == E_SUCCESS), r, r, + "The specified span tries to include a cell which is already included in another span."); + + _Layout::LayoutItem* prevItem = GetCore().GetItem(row, column); + if (prevItem) + { + if (prevItem != &layoutItem) + { + r = GetCore().SwapItemPosition(layoutItem, *prevItem); + } + } + else + { + r = GetCore().SetItemPosition(layoutItem, row, column); + } + GetCore().SetFillCell(row, column, false, false); + + if (r != E_SUCCESS) + { + return r; + } + + if (rowSpan != rowSize || columnSpan != colSize) + { + for (int y = 0; y < rowSpan; y++) + { + for (int x = 0; x < columnSpan; x++) + { + r = GetCore().Unmerge(row + y, column + x); + if (r == E_SYSTEM) + { + return r; + } + } + } + + r = GetCore().Merge(row, column, row + rowSpan - 1, column + columnSpan - 1); + GetCore().SetFillCell(row, column, true, true); + } + + return r; +} + +int +_GridLayoutImpl::GetRowCount() const +{ + return __maxRow; +} + +int +_GridLayoutImpl::GetColumnCount() const +{ + return __maxColumn; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_GridLayoutImpl.h b/src/ui/FUi_GridLayoutImpl.h new file mode 100644 index 0000000..c55d4ca --- /dev/null +++ b/src/ui/FUi_GridLayoutImpl.h @@ -0,0 +1,364 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_GridLayoutImpl.h + * @brief This is the header file for _GridLayoutImpl class. + * + * This header file contains the declaration of _GridLayoutImpl class. + */ + +#ifndef _FUI_INTERNAL_GRID_LAYOUT_IMPL_H +#define _FUI_INTERNAL_GRID_LAYOUT_IMPL_H + +#include +#include "FUi_LayoutImpl.h" +#include "FUi_LayoutTableLayout.h" + +namespace Tizen { namespace Ui +{ + +class GridLayout; + +class _GridLayoutImpl + : public _LayoutImpl +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_GridLayoutImpl(void); + + /** + * Creates the instance of _GridLayoutImpl. + * + * @since 2.0 + * @return The instance of _GridLayoutImpl. + * @param[in] pPublicLayout The public class of grid layout. + * @param[in] maxRow The max number of row. + * @param[in] maxColumn The max number of column. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + static _GridLayoutImpl* CreateGridLayoutImplN(GridLayout* pPublicLayout, int maxRow, int maxColumn); + + /** + * Gets the name of public class. + * + * @since 2.0 + * @return The name of public class. + */ + virtual const char* GetPublicClassName(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual const GridLayout& GetPublic(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual GridLayout& GetPublic(void); + + /** + * Gets the core class. + * + * @since 2.0 + * @return The core class. + */ + virtual const _Layout::TableLayout& GetCore(void) const; + + /** + * Gets the core class. + * + * @since 2.0 + * @return The core class. + */ + virtual _Layout::TableLayout& GetCore(void); + + /** + * Gets the _GridLayoutImpl instance for the GridLayout. + * + * @since 2.0 + * @return The _GridLayoutImpl instance. + * @param[in] pLayout The GridLayout instance. + */ + static const _GridLayoutImpl* GetInstance(const GridLayout& layout); + + /** + * Gets the _GridLayoutImpl instance for the GridLayout. + * + * @since 2.0 + * @return The _GridLayoutImpl instance. + * @param[in] pLayout The GridLayout instance. + */ + static _GridLayoutImpl* GetInstance(GridLayout& layout); + + /** + * Sets the stretching ability of the specified column. + * + * @since 2.0 + * @return An error code + * @param[in] columnIndex The column index + * @param[in] stretchable Set to @c true to make the column as stretchable @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetColumnStretchable(int columnIndex, bool stretchable); + + /** + * Sets the shrinking ability of the specified column. + * + * @since 2.0 + * @return An error code + * @param[in] columnIndex The column index + * @param[in] shrinkable Set to @c true to make the column as shrinkable @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetColumnShrinkable(int columnIndex, bool shrinkable); + + /** + * Sets the collapsibility of a column. + * + * @since 2.0 + * @return An error code + * @param[in] columnIndex The column index + * @param[in] collapsed Set to @c true to make the column as collapsible @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetColumnCollapsed(int columnIndex, bool collapsed); + + /** + * Sets the stretching ability of all columns. + * + * @since 2.0 + * @return An error code + * @param[in] stretchable Set to @c true to set all columns as stretchable @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + result SetAllColumnsStretchable(bool stretchable); + + /** + * Sets the shrinking ability of all columns. + * + * @since 2.0 + * @return An error code + * @param[in] shrinkable Set to @c true to set all columns as shrinkable @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + result SetAllColumnsShrinkable(bool shrinkable); + + /** + * Sets the space before the specified column index. + * + * @since 2.0 + * @return An error code + * @param[in] columnIndex The column index + * @param[in] space The space + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetColumnSpacing(int columnIndex, int space); + + /** + * Sets the stretching ability of the specified row. + * + * @since 2.0 + * @return An error code + * @param[in] rowIndex The row index + * @param[in] stretchable Set to @c true to make the row as stretchable @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetRowStretchable(int rowIndex, bool stretchable); + + /** + * Sets the shrinking ability of the specified row. + * + * @since 2.0 + * @return An error code + * @param[in] rowIndex The row index + * @param[in] shrinkable Set to @c true to make the row as shrinkable @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetRowShrinkable(int rowIndex, bool shrinkable); + + /** + * Sets the collapsibility of the specified row. + * + * @since 2.0 + * @return An error code + * @param[in] rowIndex The row index + * @param[in] collapsed Set to @c true to make the row as collapsible @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetRowCollapsed(int rowIndex, bool collapsed); + + /** + * Sets the stretching ability of all rows. + * + * @since 2.0 + * @return An error code + * @param[in] stretchable Set to @c true to set all rows as stretchable @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + result SetAllRowsStretchable(bool stretchable); + + /** + * Sets the shrinking ability of all rows. + * + * @since 2.0 + * @return An error code + * @param[in] shrinkable Set to @c true to set all rows as shrinkable @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + result SetAllRowsShrinkable(bool shrinkable); + + /** + * Sets the space before the specified column index. + * + * @since 2.0 + * @return An error code + * @param[in] rowIndex The row index + * @param[in] space The space + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetRowSpacing(int rowIndex, int space); + + /** + * Adds the control at the specified position. + * Sets the position and span of the control. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the position is set + * @param[in] row The row index + * @param[in] column The column index + * @param[in] rowSpan The row span specifies how many cells in the row should be merged into a cell. + * @param[in] columnSpan The column span specifies how many cells in the column should be merged into a cell. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + * @exception E_SYSTEM A system error occurred. + */ + result SetPosition(_ControlImpl& control, int row, int column, int rowSpan, int columnSpan); + + /** + * Gets the type of the layout. + * + * @since 2.0 + * @return The layout type + */ + virtual LayoutType GetLayoutType(void) const; + +protected: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _GridLayoutImpl(GridLayout* pPublicLayout, _Layout::TableLayout* pCoreLayout); + + /** + * Gets the number of rows in a grid layout. + * + * @since 2.0 + * @return The number of rows + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + int GetRowCount(void) const; + + /** + * Gets the number of columns in a grid layout. + * + * @since 2.0 + * @return The number of columns + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + int GetColumnCount(void) const; + +private: + /** + * This is the copy constructor for this class. + * + * @since 2.0 + */ + _GridLayoutImpl(const _GridLayoutImpl&); + + /** + * This is the substitution operator for this class. + * + * @since 2.0 + */ + _GridLayoutImpl& operator =(const _GridLayoutImpl&); + + /** + * Initializes this instance of _GridLayoutImpl with the specified parameters. + * + * @since 2.0 + * @return An error code + * @param[in] maxRow The max number of rows + * @param[in] maxColumn The max number of columns + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result Construct(int maxRow, int maxColumn); + +private: + int __maxRow; + int __maxColumn; + + friend class GridLayout; +}; // _GridLayoutImpl + +}} // Tizen::Ui + +#endif // #ifndef _FUI_INTERNAL_GRID_LAYOUT_IMPL_H diff --git a/src/ui/FUi_HorizontalBoxLayoutImpl.cpp b/src/ui/FUi_HorizontalBoxLayoutImpl.cpp new file mode 100644 index 0000000..7a87288 --- /dev/null +++ b/src/ui/FUi_HorizontalBoxLayoutImpl.cpp @@ -0,0 +1,273 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_HorizontalBoxLayoutImpl.cpp + * @brief This is the implementation file for _HorizontalBoxLayoutImpl class. + * + * This file contains the implementation of _HorizontalBoxLayoutImpl class. + */ + +#include "FUi_HorizontalBoxLayoutImpl.h" + +namespace Tizen { namespace Ui +{ + +namespace +{ +static const int CONVERT_ERROR_CODE = -1; + +_Layout::LinearLayoutDirection +ConvertEnum(HorizontalDirection val) +{ + switch (val) + { + case HORIZONTAL_DIRECTION_RIGHTWARD: + return _Layout::LINEAR_LEFT_TO_RIGHT; + + case HORIZONTAL_DIRECTION_LEFTWARD: + return _Layout::LINEAR_RIGHT_TO_LEFT; + + default: + return _Layout::LINEAR_NONE_DIRECTION; + } +} + +HorizontalDirection +ConvertEnum(_Layout::LinearLayoutDirection val) +{ + switch (val) + { + case _Layout::LINEAR_LEFT_TO_RIGHT: + return HORIZONTAL_DIRECTION_RIGHTWARD; + + case _Layout::LINEAR_RIGHT_TO_LEFT: + return HORIZONTAL_DIRECTION_LEFTWARD; + + default: + return static_cast (CONVERT_ERROR_CODE); + } +} +} + +// _HorizontalBoxLayoutImpl implementation +_HorizontalBoxLayoutImpl::_HorizontalBoxLayoutImpl(HorizontalBoxLayout* pPublicLayout, _Layout::LinearLayout* pCoreLayout) + : _LayoutImpl(pPublicLayout, pCoreLayout) +{ +} + +_HorizontalBoxLayoutImpl::~_HorizontalBoxLayoutImpl() +{ +} + +Tizen::Ui::LayoutType +_HorizontalBoxLayoutImpl::GetLayoutType(void) const +{ + return LAYOUT_HORIZONTAL_BOX; +} + +result +_HorizontalBoxLayoutImpl::Construct(HorizontalDirection direction) +{ + ClearLastResult(); + + _Layout::LinearLayoutDirection linearDirection = ConvertEnum(direction); + SysTryReturn(NID_UI, linearDirection != _Layout::LINEAR_NONE_DIRECTION, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid data."); + + result r = GetCore().Initialize(_Layout::LINEAR_HORIZONTAL, linearDirection); + + return r; +} + +result +_HorizontalBoxLayoutImpl::GetDirection(HorizontalDirection& direction) const +{ + ClearLastResult(); + + _Layout::LinearLayoutDirection internalDirection; + result r = E_SUCCESS; + + r = GetCore().GetDirection(internalDirection); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + direction = ConvertEnum(internalDirection); + + return r; +} + +result +_HorizontalBoxLayoutImpl::SetVerticalAlignment(_ControlImpl& control, LayoutVerticalAlignment vertAlign) +{ + result r = SetAlignment(control, LAYOUT_HORIZONTAL_ALIGN_LEFT, vertAlign); + + return r; +} + +result +_HorizontalBoxLayoutImpl::SetSpacing(_ControlImpl& control, int space) +{ + ClearLastResult(); + + _Layout::LayoutItem& layoutItem = control.GetLayoutContainer(); + + result r = GetCore().SetItemSpacing(layoutItem, space); + + return r; +} + +result +_HorizontalBoxLayoutImpl::SetVerticalMargin(_ControlImpl& control, int top, int bottom) +{ + result r = SetMargin(control, 0, 0, top, bottom); + + return r; +} + +result +_HorizontalBoxLayoutImpl::SetWidth(_ControlImpl& control, int width) +{ + ClearLastResult(); + + result r = SetHorizontalFitPolicy(control, FIT_POLICY_FIXED); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Layout::LayoutRect rect; + r = GetItemBaseRect(control, rect); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + rect.w = width; + r = SetItemBaseRect(control, rect); + + return r; +} + +result +_HorizontalBoxLayoutImpl::SetItemHorizontalFitPolicy(_ControlImpl& control, FitPolicy policy) +{ + result r = SetHorizontalFitPolicy(control, policy); + + return r; +} + +result +_HorizontalBoxLayoutImpl::SetHeight(_ControlImpl& control, int height) +{ + ClearLastResult(); + + result r = SetVerticalFitPolicy(control, FIT_POLICY_FIXED); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Layout::LayoutRect rect; + r = GetItemBaseRect(control, rect); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + rect.h = height; + r = SetItemBaseRect(control, rect); + + return r; +} + +result +_HorizontalBoxLayoutImpl::SetItemVerticalFitPolicy(_ControlImpl& control, FitPolicy policy) +{ + result r = SetVerticalFitPolicy(control, policy); + + return r; +} + +result +_HorizontalBoxLayoutImpl::SetWeight(_ControlImpl& control, float weight) +{ + ClearLastResult(); + + _Layout::LayoutItem& layoutItem = control.GetLayoutContainer(); + + result r = GetCore().SetItemWeight(layoutItem, weight); + + return r; +} + +_HorizontalBoxLayoutImpl* +_HorizontalBoxLayoutImpl::CreateHorizontalBoxLayoutImplN(HorizontalBoxLayout* pPublicLayout, HorizontalDirection direction) +{ + ClearLastResult(); + + _Layout::LinearLayout* pCoreLayout = null; + _HorizontalBoxLayoutImpl* pImplLayout = null; + result r = E_SUCCESS; + + pCoreLayout = _Layout::LinearLayout::CreateLinearLayoutN(); + r = GetLastResult(); + SysTryReturn(NID_UI, pCoreLayout != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImplLayout = new (std::nothrow) _HorizontalBoxLayoutImpl(pPublicLayout, pCoreLayout); + r = CheckConstruction(pCoreLayout, pImplLayout); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImplLayout->Construct(direction); + if (r != E_SUCCESS) + { + delete pImplLayout; + SysTryReturn(NID_UI, false, null, E_INVALID_ARG, "[E_INVALID_ARG] The Direction is invalid."); + } + + return pImplLayout; +} + +const char* +_HorizontalBoxLayoutImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::HorizontalBoxLayout"; +} + +const HorizontalBoxLayout& +_HorizontalBoxLayoutImpl::GetPublic(void) const +{ + return static_cast (_LayoutImpl::GetPublic()); +} + +HorizontalBoxLayout& +_HorizontalBoxLayoutImpl::GetPublic(void) +{ + return static_cast (_LayoutImpl::GetPublic()); +} + +const _Layout::LinearLayout& +_HorizontalBoxLayoutImpl::GetCore(void) const +{ + return static_cast (_LayoutImpl::GetCore()); +} + +_Layout::LinearLayout& +_HorizontalBoxLayoutImpl::GetCore(void) +{ + return static_cast <_Layout::LinearLayout&>(_LayoutImpl::GetCore()); +} + +const _HorizontalBoxLayoutImpl* +_HorizontalBoxLayoutImpl::GetInstance(const HorizontalBoxLayout& layout) +{ + return static_cast(_LayoutImpl::GetInstance(layout)); +} + +_HorizontalBoxLayoutImpl* +_HorizontalBoxLayoutImpl::GetInstance(HorizontalBoxLayout& layout) +{ + return static_cast<_HorizontalBoxLayoutImpl*>(_LayoutImpl::GetInstance(layout)); +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_HorizontalBoxLayoutImpl.h b/src/ui/FUi_HorizontalBoxLayoutImpl.h new file mode 100644 index 0000000..9bafec5 --- /dev/null +++ b/src/ui/FUi_HorizontalBoxLayoutImpl.h @@ -0,0 +1,278 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_HorizontalBoxLayoutImpl.h + * @brief This is the header file for _HorizontalBoxLayoutImpl class. + * + * This header file contains the declaration of _HorizontalBoxLayoutImpl class. + */ + +#ifndef _FUI_INTERNAL_HORIZONTAL_BOX_LAYOUT_IMPL_H +#define _FUI_INTERNAL_HORIZONTAL_BOX_LAYOUT_IMPL_H + +#include +#include "FUi_LayoutImpl.h" +#include "FUi_LayoutLinearLayout.h" + +namespace Tizen { namespace Ui +{ + +class HorizontalBoxLayout; + +class _HorizontalBoxLayoutImpl + : public _LayoutImpl +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_HorizontalBoxLayoutImpl(void); + + /** + * Creates the instance of _HorizontalBoxLayoutImpl. + * + * @since 2.0 + * @return The instance of _HorizontalBoxLayoutImpl. + * @param[in] pPublicLayout The public class of horizontal box layout. + * @param[in] direction The direction of horizontal box layout. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + static _HorizontalBoxLayoutImpl* CreateHorizontalBoxLayoutImplN(HorizontalBoxLayout* pPublicLayout, HorizontalDirection direction = HORIZONTAL_DIRECTION_RIGHTWARD); + + /** + * Gets the name of public class. + * + * @since 2.0 + * @return The name of public class. + */ + virtual const char* GetPublicClassName(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual const HorizontalBoxLayout& GetPublic(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual HorizontalBoxLayout& GetPublic(void); + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual const _Layout::LinearLayout& GetCore(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual _Layout::LinearLayout& GetCore(void); + + /** + * Gets the _HorizontalBoxLayoutImpl instance for the HorizontalBoxLayout. + * + * @since 2.0 + * @return The _HorizontalBoxLayoutImpl instance. + * @param[in] pLayout The HorizontalBoxLayout instance. + */ + static const _HorizontalBoxLayoutImpl* GetInstance(const HorizontalBoxLayout& layout); + + /** + * Gets the _HorizontalBoxLayoutImpl instance for the HorizontalBoxLayout. + * + * @since 2.0 + * @return The _HorizontalBoxLayoutImpl instance. + * @param[in] pLayout The HorizontalBoxLayout instance. + */ + static _HorizontalBoxLayoutImpl* GetInstance(HorizontalBoxLayout& layout); + + /** + * Gets the direction of the HorizontalBoxLayout. + * + * @since 2.0 + * @return An error code + * @param[out] direction The direction in which the children are attached + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result GetDirection(HorizontalDirection& direction) const; + + /** + * Sets the vertical alignment of the specified control. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the alignment is set + * @param[in] alignment The vertical alignment + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The alignment parameter is invalid. + */ + result SetVerticalAlignment(_ControlImpl& control, LayoutVerticalAlignment vertAlign); + + /** + * Sets the space between the specified control and its predecessor. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the space is set + * @param[in] space The space + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetSpacing(_ControlImpl& control, int space); + + /** + * Sets the vertical margins of the specified control. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the margins are set + * @param[in] top The top margin + * @param[in] bottom The bottom margin + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetVerticalMargin(_ControlImpl& control, int top, int bottom); + + /** + * Sets the width of the specified control with the fixed length. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the width is set + * @param[in] virWidth This is not used. + * @param[in] phyWidth The value of the width + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetWidth(_ControlImpl& control, int width); + + /** + * Sets the width of the specified control with the fitting policy. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the width is set + * @param[in] policy The fitting policy for the width + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetItemVerticalFitPolicy(_ControlImpl& control, FitPolicy policy); + + /** + * Sets the height of the specified control with fixed length. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the height is set + * @param[in] virHeight This is not used. + * @param[in] phyHeight The value of the height + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetHeight(_ControlImpl& control, int height); + + /** + * Sets the height of the specified control with the fitting policy. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the height is set + * @param[in] policy The fitting policy for the height + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetItemHorizontalFitPolicy(_ControlImpl& control, FitPolicy policy); + + /** + * Sets the weight of the specified control. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the weight is set + * @param[in] weight The weight that indicates how much extra space the control occupies + * in proportion to it, in the HorizontalBoxLayout. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetWeight(_ControlImpl& control, float weight); + + /** + * Gets the type of the layout. + * + * @since 2.0 + * @return The layout type + */ + virtual LayoutType GetLayoutType(void) const; + +protected: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _HorizontalBoxLayoutImpl(HorizontalBoxLayout* pPublicLayout, _Layout::LinearLayout* pCoreLayout); + +private: + /** + * This is the copy constructor for this class. + * + * @since 2.0 + */ + _HorizontalBoxLayoutImpl(const _HorizontalBoxLayoutImpl&); + + /** + * This is the substitution operator for this class. + * + * @since 2.0 + */ + _HorizontalBoxLayoutImpl& operator =(const _HorizontalBoxLayoutImpl&); + + /** + * Initializes this instance of _HorizontalBoxLayoutImpl with the specified parameters. + * + * @since 2.0 + * @return An error code + * @param[in] direction The direction of horizontal box layout. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result Construct(HorizontalDirection direction); +}; // _HorizontalBoxLayoutImpl + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_HORIZONTAL_BOX_LAYOUT_IMPL_H diff --git a/src/ui/FUi_InputConnectionImpl.cpp b/src/ui/FUi_InputConnectionImpl.cpp new file mode 100644 index 0000000..e3a4d3a --- /dev/null +++ b/src/ui/FUi_InputConnectionImpl.cpp @@ -0,0 +1,1341 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_InputConnectionImpl.cpp + * @brief This is the implementation file for the _InputConnectionImpl class. + */ + +#include +#include +#include +#include +#include +#include "FUi_Control.h" +#include "FUi_ControlImpl.h" +#include "FUi_ControlManager.h" +#include "FUi_CoordinateSystemUtils.h" +#include "FUi_EcoreEvas.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_InputConnectionImpl.h" +#include "FUi_UiEventManager.h" +#include "FUiAnim_EflNode.h" +#include "FUiAnim_VisualElement.h" +#if defined(MULTI_WINDOW) +#include "FUi_Window.h" +#include "FUiAnim_EflLayer.h" +#include "FUiAnim_RootVisualElement.h" +#endif + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace { + +const int LANGUAGE_CODE_START = 0; +const int LANGUAGE_CODE_MAX = 2; + +void +OnInputPanelShowStateEvent(void* pData, Ecore_IMF_Context* pContext, int value) +{ + SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelShowStateEvent pData is null "); + SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelShowStateEvent pContext is null "); + + SysLog(NID_UI_CTRL, "[InputConnection] OnInputPanelShowStateEvent is called.[ctx=0x%x, showState=%d]\n", pContext, value); + + _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData); + IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener(); + InputConnection* pInputConnection = pImpl->GetInputConnection(); + + result r = E_SUCCESS; + + Ecore_IMF_Input_Panel_State ecoreInputPanelShowState = static_cast(value); + InputPanelShowState inputPanelState = INPUT_PANEL_SHOW_STATE_HIDE; + + switch (ecoreInputPanelShowState) + { + case ECORE_IMF_INPUT_PANEL_STATE_SHOW: + inputPanelState = INPUT_PANEL_SHOW_STATE_SHOW; + break; + case ECORE_IMF_INPUT_PANEL_STATE_HIDE: + inputPanelState = INPUT_PANEL_SHOW_STATE_HIDE; + break; + case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW: + return; + default: + break; + } + + r = pImpl->SetInputPanelShowState(inputPanelState); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] This instance is not constructed."); + + pListener->OnInputConnectionPanelShowStateChanged(*pInputConnection, inputPanelState); + + SetLastResult(E_SUCCESS); + + return; +} + +void +OnInputPanelLanguageEvent(void* pData, Ecore_IMF_Context* pContext, int value) +{ + SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelLanguageEvent pData is null "); + SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelLanguageEvent pContext is null "); + + _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData); + IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener(); + InputConnection* pInputConnection = pImpl->GetInputConnection(); + + char* pLocale = null; + ecore_imf_context_input_panel_language_locale_get(pContext, &pLocale); + String tempBuffer(pLocale); + String language; + tempBuffer.SubString(LANGUAGE_CODE_START, LANGUAGE_CODE_MAX, language); + LanguageCode newLanguageCode = Locale::TwoLetterLanguageCodeStringToLanguageCode(language); + + pListener->OnInputConnectionPanelLanguageChanged(*pInputConnection, newLanguageCode); + + if (pLocale) + { + free(pLocale); + } + + SetLastResult(E_SUCCESS); + + return; +} + +void +OnInputPanelSizeChangedEvent(void* pData, Ecore_IMF_Context* pContext, int value) +{ + SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelSizeChangedEvent pData is null "); + SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelSizeChangedEvent pContext is null "); + + _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData); + IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener(); + InputConnection* pInputConnection = pImpl->GetInputConnection(); + + Rectangle bounds = pImpl->GetInputPanelBounds(); + + SysLog(NID_UI_CTRL, "[InputConnection] OnInputPanelSizeChangedEvent is called.[ctx=0x%x][x = %d, y = %d, width = %d, height = %d]\n", pContext, bounds.x, bounds.y, bounds.width, bounds.height); + + pListener->OnInputConnectionPanelBoundsChanged(*pInputConnection, bounds); + + SetLastResult(E_SUCCESS); + + return; +} + +void +OnInputPanelPredictionModeEvent(void* pData, Ecore_IMF_Context* pContext, int value) +{ + SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelPredictionModeEvent pData is null "); + SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelPredictionModeEvent pContext is null "); + + _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData); + IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener(); + InputConnection* pInputConnection = pImpl->GetInputConnection(); + + pListener->OnInputConnectionTextPredictionShowStateChanged(*pInputConnection, static_cast(value)); + + SetLastResult(E_SUCCESS); + + return; +} + +void +OnInputPanelPredictionSizeChangedEvent(void* pData, Ecore_IMF_Context* pContext, int value) +{ + SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelPredictionSizeChangedEvent pData is null "); + SysTryReturnVoidResult(NID_UI, pContext != null, E_INVALID_ARG, "[E_INVALID_ARG] OnInputPanelPredictionSizeChangedEvent pContext is null "); + + _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData); + IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener(); + InputConnection* pInputConnection = pImpl->GetInputConnection(); + + Rectangle bounds = pImpl->GetPredictionBounds(); + + pListener->OnInputConnectionTextPredictionBoundsChanged(*pInputConnection, bounds); + + SetLastResult(E_SUCCESS); + + return; +} + +Eina_Bool +OnRetrieveSurrounding(void* pData, Ecore_IMF_Context* pContext, char** pText, int* pCursorPostion) +{ + SysTryReturn(NID_UI, pData != null, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] OnRetrieveSurrounding pData == null."); + SysTryReturn(NID_UI, pContext != null, EINA_FALSE, E_INVALID_ARG, "[E_INVALID_ARG] OnRetrieveSurrounding pContext is null "); + + _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData); + IInputConnectionProvider* pProvider = pImpl->GetInputConnectionProvider(); + + InputConnection* pInputConnection = pImpl->GetInputConnection(); + + char* pSurroundingText = null; + String string; + + pProvider->GetPreviousText(*pInputConnection, string, *pCursorPostion); + + int len = wcstombs(0, static_cast(string.GetPointer()), 0); + //SysTryReturn(NID_BASE, len != -1, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid string."); + + if (pText == null) + { + return ECORE_CALLBACK_PASS_ON; + } + + if (len < 0) + { + *pText = null; + return ECORE_CALLBACK_DONE; + } + //This memory will be released by ECORE IMF + pSurroundingText = (char*)malloc(len+1); + SysTryReturn(NID_UI, pSurroundingText, EINA_FALSE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] OnRetrieveSurrounding pSurroundingText == null."); + + len = wcstombs(pSurroundingText, static_cast(string.GetPointer()), len); + pSurroundingText[len] = null; + *pText = pSurroundingText; + + SetLastResult(E_SUCCESS); + + return ECORE_CALLBACK_PASS_ON; +} + +void +OnCommitTextEcoreEvent(void* pData, Ecore_IMF_Context* pContext, void* pEventInfo) +{ + SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnCommitTextEcoreEvent pData is null "); + SysTryReturnVoidResult(NID_UI, pEventInfo != null, E_INVALID_ARG, "[E_INVALID_ARG] OnCommitTextEcoreEvent pEventInfo is null "); + + _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData); + IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener(); + + String commitText(static_cast(pEventInfo)); + InputConnection* pInputConnection = pImpl->GetInputConnection(); + pListener->OnInputConnectionTextCommitted(*pInputConnection, commitText); + + SetLastResult(E_SUCCESS); + + return; +} + +void +OnComposeTextEcoreEvent(void* pData, Ecore_IMF_Context* pContext, void* pEventInfo) +{ + SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnComposeTextEcoreEvent pData is null "); + //SysTryReturnVoidResult(NID_UI, pEventInfo != null, E_INVALID_ARG, "[E_INVALID_ARG] OnComposeTextEcoreEvent pEventInfo is null "); + + _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData); + IInputConnectionEventListener* pListener = pImpl->GetInputConnectionListener(); + + int cursorPosition = 0; + char* pText = null; + ecore_imf_context_preedit_string_get(pContext, &pText, &cursorPosition); + String composingText(pText); + if (pText) + { + free(pText); + } + + InputConnection* pInputConnection = pImpl->GetInputConnection(); + pListener->OnInputConnectionComposingTextChanged(*pInputConnection, composingText, cursorPosition); + + SetLastResult(E_SUCCESS); + + return; +} + +void +OnDeleteSurroundingTextEcoreEvent(void* pData, Ecore_IMF_Context* pContext, void* pEventInfo) +{ + SysTryReturnVoidResult(NID_UI, pData != null, E_INVALID_ARG, "[E_INVALID_ARG] OnDeleteSurroundingTextEcoreEvent pData is null "); + SysTryReturnVoidResult(NID_UI, pEventInfo != null, E_INVALID_ARG, "[E_INVALID_ARG] OnDeleteSurroundingTextEcoreEvent pEventInfo is null "); + + _InputConnectionImpl* pImpl = static_cast<_InputConnectionImpl*>(pData); + IInputConnectionProvider* pProvider = pImpl->GetInputConnectionProvider(); + Ecore_IMF_Event_Delete_Surrounding* pEvent = static_cast(pEventInfo); + + InputConnection* pInputConnection = pImpl->GetInputConnection(); + pProvider->DeleteSurroundingText(*pInputConnection, pEvent->offset, pEvent->n_chars); + + SetLastResult(E_SUCCESS); + + return; +} + +/* +Eina_Bool +OnUSBKeyboardEcoreEvent(void* pData, int eventType, void* pEventInfo) +{ + return ECORE_CALLBACK_PASS_ON; +} +*/ + +} // Anonymous + +namespace Tizen { namespace Ui { + +_InputConnectionImpl::_InputConnectionImpl(InputConnection* pInputConnection) + : __pContext(null) + , __controlHandle() + , __IsBounded(false) + , __pListener(null) + , __pProvider(null) + , __pInputConnection(pInputConnection) + , __inputPanelAction(INPUT_PANEL_ACTION_ENTER) + , __inputPanelState(INPUT_PANEL_SHOW_STATE_HIDE) + , __inputPanelStyle(INPUT_PANEL_STYLE_NORMAL) + , __pUSBEventHandler(null) + , __IsKeyEventSkipped(false) +{ + +} + +_InputConnectionImpl::~_InputConnectionImpl(void) +{ + __pInputConnection = null; + __pListener = null; + __pProvider = null; + if (__pContext) + { + RemoveInputPanelCallback(); + RemoveEcoreEventCallback(); + RemoveEvasObjectEventCallback(); + ecore_imf_context_focus_out(__pContext); + ecore_imf_context_del(__pContext); + ecore_imf_shutdown(); + __pContext = null; + } +} + +_InputConnectionImpl* +_InputConnectionImpl::CreateInputConnectionImplN(InputConnection* pInputConnection) +{ + ClearLastResult(); + + _InputConnectionImpl* pImpl = new (std::nothrow) _InputConnectionImpl(pInputConnection); + SysTryReturn(NID_UI, pImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + return pImpl; + +} + +result +_InputConnectionImpl::Initialize(const _Control& control, const IInputConnectionEventListener& listener, const IInputConnectionProvider& provider) +{ + result r = E_SUCCESS; + + __controlHandle = control.GetHandle(); + + __pListener = const_cast(&listener); + __pProvider = const_cast(&provider); + + ecore_imf_init(); + const char* pId = ecore_imf_context_default_id_get(); + SysTryReturnResult(NID_UI, pId != null, E_SYSTEM, "A system error occurred."); + + + __pContext = (Ecore_IMF_Context*)ecore_imf_context_add(pId); + SysTryReturnResult(NID_UI, __pContext, E_SYSTEM, "A system error occurred."); + +#if !defined(MULTI_WINDOW) + if (GetEcoreEvasMgr()->GetEcoreEvas()) + { + ecore_imf_context_client_window_set(__pContext, (void*)ecore_evas_window_get(GetEcoreEvasMgr()->GetEcoreEvas()->GetEcoreEvas())); + ecore_imf_context_client_canvas_set(__pContext, GetEcoreEvasMgr()->GetEcoreEvas()->GetEvas()); + ecore_imf_context_input_panel_enabled_set(__pContext, EINA_FALSE); + } +#endif + + AddInputPanelCallback(); + AddEcoreEventCallback(); + AddEvasObjectEventCallback(); + + return r; + +} + +result +_InputConnectionImpl::BindInputMethod(void) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + +#if defined(MULTI_WINDOW) + _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle); + + _Window* pWindow = pControl->GetRootWindow(); + if (pWindow) + { + _RootVisualElement* pRootVE = pWindow->GetRootVisualElement(); + _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer()); + + if (pLayer) + { + ecore_imf_context_client_window_set(__pContext, (void*)ecore_evas_window_get(pLayer->GetEcoreEvas())); + ecore_imf_context_client_canvas_set(__pContext, pLayer->GetEvas()); + ecore_imf_context_input_panel_enabled_set(__pContext, EINA_FALSE); + } + } +#endif + + ecore_imf_context_focus_in(__pContext); + __IsBounded = true; + + SysLog(NID_UI_CTRL, "[InputConnection] BindInputMethod is called.[ctx=0x%x]\n", __pContext); + + return r; +} + +result +_InputConnectionImpl::UnbindInputMethod(void) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + ecore_imf_context_focus_out(__pContext); + + SysLog(NID_UI_CTRL, "[InputConnection] UnbindInputMethod is called.[ctx=0x%x]\n", __pContext); + + __IsBounded = false; + + return r; +} + +result +_InputConnectionImpl::ShowInputPanel(void) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state"); + + ecore_imf_context_input_panel_show(__pContext); + __inputPanelState = INPUT_PANEL_SHOW_STATE_SHOW; + + SysLog(NID_UI_CTRL, "[InputConnection] ShowInputPanel is called.[ctx=0x%x]\n", __pContext); + + return r; +} + +result +_InputConnectionImpl::HideInputPanel(void) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state"); + + ecore_imf_context_input_panel_hide(__pContext); + __inputPanelState = INPUT_PANEL_SHOW_STATE_HIDE; + + SysLog(NID_UI_CTRL, "[InputConnection] HideInputPanel is called.[ctx=0x%x]\n", __pContext); + + return r; +} + +result +_InputConnectionImpl::SetInputPanelStyle(InputPanelStyle style) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + __inputPanelStyle = style; + + Ecore_IMF_Input_Panel_Layout ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL; + + switch (style) + { + case INPUT_PANEL_STYLE_NORMAL: + ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL; + break; + case INPUT_PANEL_STYLE_NUMBER: + ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER; + break; + case INPUT_PANEL_STYLE_EMAIL: + ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL; + break; + case INPUT_PANEL_STYLE_URL: + ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_URL; + break; + case INPUT_PANEL_STYLE_PHONE_NUMBER: + ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER; + break; + case INPUT_PANEL_STYLE_IP: + ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_IP; + break; + case INPUT_PANEL_STYLE_NUMBER_ONLY: + ecorePanelLayout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY; + break; + default: + break; + } + + ecore_imf_context_input_panel_layout_set(__pContext, ecorePanelLayout); + return r; +} + +InputPanelStyle +_InputConnectionImpl::GetInputPanelStyle(void) const +{ + ClearLastResult(); + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + Ecore_IMF_Input_Panel_Layout ecorePanelLayout = ecore_imf_context_input_panel_layout_get(__pContext); + InputPanelStyle inputPanelStyle = INPUT_PANEL_STYLE_NORMAL; + + switch (ecorePanelLayout) + { + case ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL: + inputPanelStyle = INPUT_PANEL_STYLE_NORMAL; + break; + case ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER: + inputPanelStyle = INPUT_PANEL_STYLE_NUMBER; + break; + case ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL: + inputPanelStyle = INPUT_PANEL_STYLE_EMAIL; + break; + case ECORE_IMF_INPUT_PANEL_LAYOUT_URL: + inputPanelStyle = INPUT_PANEL_STYLE_URL; + break; + case ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER: + inputPanelStyle = INPUT_PANEL_STYLE_PHONE_NUMBER; + break; + case ECORE_IMF_INPUT_PANEL_LAYOUT_IP: + inputPanelStyle = INPUT_PANEL_STYLE_IP; + break; + case ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY: + inputPanelStyle = INPUT_PANEL_STYLE_NUMBER_ONLY; + break; + default: + break; + } + + return inputPanelStyle; +} + +result +_InputConnectionImpl::SetAutoCapitalizationMode(AutoCapitalizationMode autoCapitalizationMode) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + Ecore_IMF_Autocapital_Type ecoreAutoCapitalization = ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE; + + switch (autoCapitalizationMode) + { + case AUTO_CAPITALIZATION_MODE_NONE: + ecoreAutoCapitalization = ECORE_IMF_AUTOCAPITAL_TYPE_NONE; + break; + case AUTO_CAPITALIZATION_MODE_WORD: + ecoreAutoCapitalization = ECORE_IMF_AUTOCAPITAL_TYPE_WORD; + break; + case AUTO_CAPITALIZATION_MODE_SENTENCE: + ecoreAutoCapitalization = ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE; + break; + case AUTO_CAPITALIZATION_MODE_ALL: + ecoreAutoCapitalization =ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER; + break; + default: + break; + } + + ecore_imf_context_autocapital_type_set(__pContext, ecoreAutoCapitalization); + return r; +} + +AutoCapitalizationMode +_InputConnectionImpl::GetAutoCapitalizationMode(void) const +{ + ClearLastResult(); + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + Ecore_IMF_Autocapital_Type ecoreAutoCapitalization = ecore_imf_context_autocapital_type_get(__pContext); + AutoCapitalizationMode autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_SENTENCE; + + switch (ecoreAutoCapitalization) + { + case ECORE_IMF_AUTOCAPITAL_TYPE_NONE: + autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_NONE; + break; + case ECORE_IMF_AUTOCAPITAL_TYPE_WORD: + autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_WORD; + break; + case ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE: + autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_SENTENCE; + break; + case ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER: + autoCapitalizationMode = AUTO_CAPITALIZATION_MODE_ALL; + break; + default: + break; + } + + return autoCapitalizationMode; +} + +InputPanelShowState +_InputConnectionImpl::GetInputPanelShowState(void) const +{ + ClearLastResult(); + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + return __inputPanelState; +} + +result +_InputConnectionImpl::SetInputPanelShowState(InputPanelShowState state) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + __inputPanelState = state; + return r; +} + +result +_InputConnectionImpl::FinishTextComposition(void) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state"); + + ecore_imf_context_reset(__pContext); + return r; +} + +result +_InputConnectionImpl::SetInputPanelAction(InputPanelAction inputPanelAction) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + __inputPanelAction = inputPanelAction; + Ecore_IMF_Input_Panel_Return_Key_Type ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + + switch (inputPanelAction) + { + case INPUT_PANEL_ACTION_GO: + ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO; + break; + case INPUT_PANEL_ACTION_NEXT: + ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT; + break; + case INPUT_PANEL_ACTION_SEND: + ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND; + break; + case INPUT_PANEL_ACTION_SEARCH: + ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH; + break; + case INPUT_PANEL_ACTION_LOGIN: + ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN; + break; + case INPUT_PANEL_ACTION_SIGN_IN: + ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN; + break; + case INPUT_PANEL_ACTION_JOIN: + ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN; + break; + case INPUT_PANEL_ACTION_DONE: + ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE; + break; + case INPUT_PANEL_ACTION_ENTER: + ecorePanelAction = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; + break; + default: + break; + } + + ecore_imf_context_input_panel_return_key_type_set(__pContext, ecorePanelAction); + + return r; +} + +InputPanelAction +_InputConnectionImpl::GetInputPanelAction(void) const +{ + ClearLastResult(); + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + Ecore_IMF_Input_Panel_Return_Key_Type ecorePanelAction = ecore_imf_context_input_panel_return_key_type_get(__pContext); + InputPanelAction inputPanelAction = INPUT_PANEL_ACTION_ENTER; + + switch (ecorePanelAction) + { + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO: + inputPanelAction = INPUT_PANEL_ACTION_GO; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT: + inputPanelAction = INPUT_PANEL_ACTION_NEXT; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND: + inputPanelAction = INPUT_PANEL_ACTION_SEND; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH: + inputPanelAction = INPUT_PANEL_ACTION_SEARCH; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN: + inputPanelAction = INPUT_PANEL_ACTION_LOGIN; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN: + inputPanelAction = INPUT_PANEL_ACTION_SIGN_IN; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN: + inputPanelAction = INPUT_PANEL_ACTION_JOIN; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE: + inputPanelAction = INPUT_PANEL_ACTION_DONE; + break; + case ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT: + inputPanelAction = INPUT_PANEL_ACTION_ENTER; + break; + default: + break; + } + + return inputPanelAction; +} + +result +_InputConnectionImpl::SetInputPanelActionEnabled(bool enable) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + ecore_imf_context_input_panel_return_key_disabled_set(__pContext, (!enable ? EINA_TRUE : EINA_FALSE)); + return r; +} + +bool +_InputConnectionImpl::IsInputPanelActionEnabled(void) const +{ + ClearLastResult(); + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + Eina_Bool enabled = ecore_imf_context_input_panel_return_key_disabled_get(__pContext); + + return static_cast(!enabled); +} + +result +_InputConnectionImpl::SetCursorPosition(int position) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + SysTryReturnResult(NID_UI, position >= 0, E_INVALID_ARG, "The input parameter is invalid."); + SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state"); + + ecore_imf_context_cursor_position_set(__pContext, position); + return r; +} + +result +_InputConnectionImpl::SetCursorBounds(const Rectangle& rect) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturnResult(NID_UI, (rect.width > 0)&&(rect.height > 0), E_INVALID_ARG, "The input parameter is invalid."); + SysTryReturnResult(NID_UI, __IsBounded, E_INVALID_STATE, "This is not a bind state"); + + + Rectangle cursorRectangle; + cursorRectangle = rect; + + const _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle); + + if (pControl) + { + Rectangle absoluteControlRectangle; + absoluteControlRectangle = pControl->GetAbsoluteBounds(); + cursorRectangle.x += absoluteControlRectangle.x; + cursorRectangle.y += absoluteControlRectangle.y; + } + + Rectangle physicalRect = _CoordinateSystemUtils::Transform(cursorRectangle); + + ecore_imf_context_cursor_location_set(__pContext, physicalRect.x, physicalRect.y, physicalRect.width, physicalRect.height); + return r; +} + +Rectangle +_InputConnectionImpl::GetInputPanelBounds(void) const +{ + ClearLastResult(); + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + int x = 0; + int y = 0; + int w = 0; + int h = 0; + + ecore_imf_context_input_panel_geometry_get(__pContext, &x, &y, &w, &h); + return Rectangle(x, y, w, h); +} + +Rectangle +_InputConnectionImpl::GetPredictionBounds(void) const +{ + ClearLastResult(); + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + int x = 0; + int y = 0; + int w = 0; + int h = 0; + + ecore_imf_context_candidate_panel_geometry_get(__pContext, &x, &y, &w, &h); + return Rectangle(x, y, w, h); +} + +result +_InputConnectionImpl::SetTextPredictionEnabled(bool enable) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + ecore_imf_context_prediction_allow_set(__pContext, (enable ? EINA_TRUE : EINA_FALSE)); + + return r; +} + +bool +_InputConnectionImpl::IsTextPredictionEnabled(void) const +{ + ClearLastResult(); + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + Eina_Bool enabled = ecore_imf_context_prediction_allow_get(__pContext); + + return static_cast(enabled); +} + +result +_InputConnectionImpl::SetCapsLockEnabled(bool enable) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + ecore_imf_context_input_panel_caps_lock_mode_set(__pContext, (enable ? EINA_TRUE : EINA_FALSE)); + + return r; +} + +bool +_InputConnectionImpl::IsCapsLockEnabled(void) const +{ + ClearLastResult(); + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + Eina_Bool enabled = ecore_imf_context_input_panel_caps_lock_mode_get(__pContext); + + return static_cast(enabled); +} + +result +_InputConnectionImpl::SetInputPanelLanguage(LanguageCode languageCode) +{ + result r = E_SUCCESS; + + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + char* pLanguage = null; + int length = 0; + String code = Locale::LanguageCodeToTwoLetterLanguageCodeString(languageCode); + r = code.Insert("LANG:", 0); + SysTryReturnResult(NID_UI, r == E_SUCCESS, E_OUT_OF_MEMORY, "A system error occurred."); + + length = wcstombs(0, static_cast(code.GetPointer()), 0); + SysTryReturnResult(NID_UI, length != -1, E_OUT_OF_MEMORY, "A system error occurred."); + + pLanguage = (char*)malloc(length+1); + SysTryReturn(NID_UI, pLanguage, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + length = wcstombs(pLanguage, static_cast(code.GetPointer()), length); + pLanguage[length] = null; + + ecore_imf_context_input_panel_imdata_set(__pContext, pLanguage, length); + + free(pLanguage); + + return E_SUCCESS; +} + +LanguageCode +_InputConnectionImpl::GetInputPanelLanguage(void) const +{ + SysAssertf(__pContext != null, "Not yet constructed. Construct() should be called before use."); + + ClearLastResult(); + + char* pLocale = null; + + ecore_imf_context_input_panel_language_locale_get(__pContext, &pLocale); + + String tempBuffer(pLocale); + String language; + tempBuffer.SubString(LANGUAGE_CODE_START, LANGUAGE_CODE_MAX, language); + + if (pLocale) + { + free(pLocale); + } + + return Locale::TwoLetterLanguageCodeStringToLanguageCode(language); +} + +InputConnection* +_InputConnectionImpl::GetInputConnection(void) const +{ + return __pInputConnection; +} + +IInputConnectionEventListener* +_InputConnectionImpl::GetInputConnectionListener(void) const +{ + return __pListener; +} + +IInputConnectionProvider* +_InputConnectionImpl::GetInputConnectionProvider(void) const +{ + return __pProvider; +} + +bool +_InputConnectionImpl::CheckContextEvent(Ecore_IMF_Event_Type type, void* pEventInfo) +{ + ClearLastResult(); + + if (type == ECORE_IMF_EVENT_KEY_DOWN) + { + Evas_Event_Key_Down* pDownEvent = static_cast(pEventInfo); + SysTryReturn(NID_UI, pDownEvent != null, false, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + Ecore_IMF_Event_Key_Down ecoreEvent; + ecore_imf_evas_event_key_down_wrap(pDownEvent, &ecoreEvent); + if (ecore_imf_context_filter_event(__pContext, type, (Ecore_IMF_Event*)&ecoreEvent) == EINA_TRUE) + { + return true; + } + } + else if (type == ECORE_IMF_EVENT_KEY_UP) + { + Evas_Event_Key_Up* pUpEvent = static_cast(pEventInfo); + SysTryReturn(NID_UI, pUpEvent != null, false, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + Ecore_IMF_Event_Key_Up ecoreEvent; + ecore_imf_evas_event_key_up_wrap(pUpEvent, &ecoreEvent); + if (ecore_imf_context_filter_event(__pContext, type, (Ecore_IMF_Event*)&ecoreEvent) == EINA_TRUE) + { + return true; + } + } + return false; +} + +bool +_InputConnectionImpl::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) +{ + if (__IsKeyEventSkipped) + { + return false; + } + + Ecore_Event_Key* pEvent = static_cast(keyInfo.GetUserData()); + SysTryReturn(NID_UI, pEvent, false, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_IMF_Event_Key_Down* pKeyDown = (Ecore_IMF_Event_Key_Down*)malloc(sizeof(Ecore_IMF_Event_Key_Down)); + SysTryReturn(NID_UI, pKeyDown, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pKeyDown->keyname = pEvent->keyname; + + //need to check with SLP + int modifiers = ECORE_IMF_KEYBOARD_MODIFIER_NONE; + + if (pEvent->modifiers & ECORE_EVENT_MODIFIER_SHIFT) + { + modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; + } + if (pEvent->modifiers & ECORE_EVENT_MODIFIER_CTRL) + { + modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL; + } + if (pEvent->modifiers & ECORE_EVENT_MODIFIER_ALT) + { + modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_ALT; + } + if (pEvent->modifiers & ECORE_EVENT_MODIFIER_WIN) + { + modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_WIN; + } + pKeyDown->modifiers = static_cast(modifiers); + + int locks = ECORE_IMF_KEYBOARD_LOCK_NONE; + if (pEvent->modifiers & ECORE_EVENT_LOCK_SCROLL) + { + locks |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; + } + if (pEvent->modifiers & ECORE_EVENT_LOCK_NUM) + { + locks |= ECORE_IMF_KEYBOARD_LOCK_NUM; + } + if (pEvent->modifiers & ECORE_EVENT_LOCK_CAPS) + { + locks |= ECORE_IMF_KEYBOARD_LOCK_CAPS; + } + pKeyDown->locks = static_cast(locks); + + pKeyDown->key = pEvent->key; + pKeyDown->string = pEvent->string; + pKeyDown->compose = pEvent->compose; + pKeyDown->timestamp = pEvent->timestamp; + + if(CheckUSBKeyboardStatus() && pKeyDown->string)//usb keyboard exist + { + int key = (int)*pKeyDown->string; + if(IsFilteredKeyOnUSBMode(GetInputPanelStyle(), key)) + { + free(pKeyDown); + return false; + } + } + + const _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle); + + if (&source == pControl) + { + if (ecore_imf_context_filter_event(__pContext, ECORE_IMF_EVENT_KEY_DOWN, (Ecore_IMF_Event*)pKeyDown) == EINA_TRUE) + { + free(pKeyDown); + + return false; + } + else + { + if ((pEvent->modifiers & ECORE_EVENT_MODIFIER_CTRL) || (pEvent->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_ALT) || (pEvent->modifiers & ECORE_IMF_KEYBOARD_MODIFIER_WIN)) + { + return false; + } + + if (!pEvent->compose) + { + return false; + } + + InputConnection* pInputConnection = GetInputConnection(); + String commitText(pEvent->compose); + wchar_t commitChar= '\0'; + commitText.GetCharAt(0, commitChar); + + if (Character::IsAlphaNumeric(commitChar)) + { + __pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText); + } + if (commitText == L" " || commitText == L"\t") + { + __pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText); + } + if (commitText == L"\n" || commitText == L"\r") + { + __pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText); + } + if ( (commitChar >= 0x21 && commitChar <= 0x2F) || (commitChar >= 0x3A && commitChar <= 0x40) || + (commitChar >= 0x5B && commitChar <= 0x60) || (commitChar >= 0x7B && commitChar<= 0x7E) ) + { + __pListener->OnInputConnectionTextCommitted( *pInputConnection, commitText); + } + + free(pKeyDown); + + return false; + } + } + + free(pKeyDown); + + SetLastResult(E_SUCCESS); + + return false; +} + +bool +_InputConnectionImpl::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) +{ + if (__IsKeyEventSkipped) + { + return false; + } + + Ecore_Event_Key* pEvent = static_cast(keyInfo.GetUserData()); + SysTryReturn(NID_UI, pEvent, false, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + Ecore_IMF_Event_Key_Up* pKeyUp = (Ecore_IMF_Event_Key_Up*)malloc(sizeof(Ecore_IMF_Event_Key_Up)); + SysTryReturn(NID_UI, pKeyUp, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pKeyUp->keyname = pEvent->keyname; + + //need to check with SLP + int modifiers = ECORE_IMF_KEYBOARD_MODIFIER_NONE; + + if (pEvent->modifiers & ECORE_EVENT_MODIFIER_SHIFT) + { + modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; + } + if (pEvent->modifiers & ECORE_EVENT_MODIFIER_CTRL) + { + modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL; + } + if (pEvent->modifiers & ECORE_EVENT_MODIFIER_ALT) + { + modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_ALT; + } + if (pEvent->modifiers & ECORE_EVENT_MODIFIER_WIN) + { + modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_WIN; + } + pKeyUp->modifiers = static_cast(modifiers); + + int locks = ECORE_IMF_KEYBOARD_LOCK_NONE; + if (pEvent->modifiers & ECORE_EVENT_LOCK_SCROLL) + { + locks |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; + } + if (pEvent->modifiers & ECORE_EVENT_LOCK_NUM) + { + locks |= ECORE_IMF_KEYBOARD_LOCK_NUM; + } + if (pEvent->modifiers & ECORE_EVENT_LOCK_CAPS) + { + locks |= ECORE_IMF_KEYBOARD_LOCK_CAPS; + } + pKeyUp->locks = static_cast(locks); + + pKeyUp->key = pEvent->key; + pKeyUp->string = pEvent->string; + pKeyUp->compose = pEvent->compose; + pKeyUp->timestamp = pEvent->timestamp; + + if(CheckUSBKeyboardStatus() && pKeyUp->string)//usb keyboard exist + { + int key = (int)*pKeyUp->string; + if(IsFilteredKeyOnUSBMode(GetInputPanelStyle(), key)) + { + free(pKeyUp); + return false; + } + } + + const _Control* pControl = _ControlManager::GetInstance()->GetObject(__controlHandle); + + if (&source == pControl) + { + if (ecore_imf_context_filter_event(__pContext, ECORE_IMF_EVENT_KEY_UP, (Ecore_IMF_Event*)pKeyUp) == EINA_TRUE) + { + free(pKeyUp); + + return false; + } + } + + free(pKeyUp); + + SetLastResult(E_SUCCESS); + + return false; +} + +void +_InputConnectionImpl::AddInputPanelCallback(void) +{ + ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, OnInputPanelShowStateEvent, this); + ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, OnInputPanelLanguageEvent, this); + ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, OnInputPanelSizeChangedEvent, this); + ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, OnInputPanelPredictionModeEvent, this); + ecore_imf_context_input_panel_event_callback_add(__pContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, OnInputPanelPredictionSizeChangedEvent, this); + ecore_imf_context_retrieve_surrounding_callback_set(__pContext, OnRetrieveSurrounding, this); + + return; +} + +void +_InputConnectionImpl::AddEcoreEventCallback(void) +{ + ecore_imf_context_event_callback_add(__pContext, ECORE_IMF_CALLBACK_COMMIT, OnCommitTextEcoreEvent, this); + ecore_imf_context_event_callback_add(__pContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, OnComposeTextEcoreEvent, this); + ecore_imf_context_event_callback_add(__pContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, OnDeleteSurroundingTextEcoreEvent, this); + +/* + //Internal USB Check + Ecore_X_Window rootWindow = ecore_x_window_root_first_get(); + ecore_x_event_mask_set(rootWindow, ECORE_X_EVENT_MASK_WINDOW_PROPERTY); + __pUSBEventHandler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, OnUSBKeyboardEcoreEvent, this); + */ + return; +} + +void +_InputConnectionImpl::AddEvasObjectEventCallback(void) +{ + result r = _UiEventManager::GetInstance()->AddPostKeyEventListener(*this); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +_InputConnectionImpl::RemoveInputPanelCallback(void) +{ + ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, OnInputPanelShowStateEvent); + ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, OnInputPanelLanguageEvent); + ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, OnInputPanelSizeChangedEvent); + ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_CANDIDATE_PANEL_STATE_EVENT, OnInputPanelPredictionModeEvent); + ecore_imf_context_input_panel_event_callback_del(__pContext, ECORE_IMF_CANDIDATE_PANEL_GEOMETRY_EVENT, OnInputPanelPredictionSizeChangedEvent); + + return; +} + +void +_InputConnectionImpl::RemoveEcoreEventCallback(void) +{ + ecore_imf_context_event_callback_del(__pContext, ECORE_IMF_CALLBACK_COMMIT, OnCommitTextEcoreEvent); + ecore_imf_context_event_callback_del(__pContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, OnComposeTextEcoreEvent); + ecore_imf_context_event_callback_del(__pContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, OnDeleteSurroundingTextEcoreEvent); + +/* + //Internal USB Check Release + if (__pUSBEventHandler) + { + ecore_event_handler_del(__pUSBEventHandler); + __pUSBEventHandler = null; + } + */ + return; +} + +void +_InputConnectionImpl::RemoveEvasObjectEventCallback(void) +{ + result r = _UiEventManager::GetInstance()->RemovePostKeyEventListener(*this); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +_InputConnectionImpl* +_InputConnectionImpl::GetInstance(InputConnection& inputConnection) +{ + return inputConnection.__pInputConnectionImpl; +} +const _InputConnectionImpl* +_InputConnectionImpl::GetInstance(const InputConnection& inputConnection) +{ + return inputConnection.__pInputConnectionImpl; +} + +int +_InputConnectionImpl::CheckUSBKeyboardStatus(void) +{ + Ecore_X_Window rootWindow = ecore_x_window_root_first_get(); + Ecore_X_Atom keyboardExist = 0; + unsigned int keyboardNumber = 0; + int ret = 0; + + if (!keyboardExist) + { + keyboardExist = ecore_x_atom_get("X External Keyboard Exist"); + } + ret = ecore_x_window_prop_card32_get(rootWindow, keyboardExist, &keyboardNumber, 1); + + return keyboardNumber; +} + +bool +_InputConnectionImpl::IsFilteredKeyOnUSBMode(InputPanelStyle style, int key) +{ + if(!(style == INPUT_PANEL_STYLE_NUMBER_ONLY || style == INPUT_PANEL_STYLE_PHONE_NUMBER || style == INPUT_PANEL_STYLE_IP)) + return false; + + int TempKey[20] = {0,}; + const int keyOnNumOnlyStyle[10] = { 0x30/*0*/, 0x31/*1*/, 0x32/*2*/, 0x33/*3*/, 0x34/*4*/, 0x35/*5*/, 0x36/*6*/, 0x37/*7*/, 0x38/*8*/, 0x39/*9*/}; + const int keyOnPhoneNumStyle[13] = { 0x30/*0*/, 0x31/*1*/, 0x32/*2*/, 0x33/*3*/, 0x34/*4*/, 0x35/*5*/, 0x36/*6*/, 0x37/*7*/, 0x38/*8*/, 0x39/*9*/, + 0x2a/***/, 0x2b/*+*/, 0x23/*#*/}; + const int keyOnIPStyle[18] = { 0x30/*0*/, 0x31/*1*/, 0x32/*2*/, 0x33/*3*/, 0x34/*4*/, 0x35/*5*/, 0x36/*6*/, 0x37/*7*/, 0x38/*8*/, 0x39/*9*/, + 0x3a/*:*/, 0x2e/*.*/, 0x61/*a*/, 0x62/*b*/, 0x63/*c*/, 0x64/*d*/, 0x65/*e*/, 0x66/*f*/}; + bool isExist = false; + int keyCount = 0; + + if(style == INPUT_PANEL_STYLE_NUMBER_ONLY) + { + keyCount = 10; + memcpy(TempKey, keyOnNumOnlyStyle, keyCount*sizeof(int)); + } + else if(style == INPUT_PANEL_STYLE_PHONE_NUMBER) + { + keyCount = 13; + memcpy(TempKey, keyOnPhoneNumStyle, keyCount*sizeof(int)); + } + else if(style == INPUT_PANEL_STYLE_IP) + { + keyCount = 18; + memcpy(TempKey, keyOnIPStyle, keyCount*sizeof(int)); + } + + if(!keyCount) + return false; + + for(int i = 0; i < keyCount ; i++) + { + if(TempKey[i] == key) + isExist = true; + } + + return !isExist; +} + +void +_InputConnectionImpl::SetKeyEventSkipped(bool enabled) +{ + __IsKeyEventSkipped = enabled; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_InputConnectionImpl.h b/src/ui/FUi_InputConnectionImpl.h new file mode 100644 index 0000000..fcb7507 --- /dev/null +++ b/src/ui/FUi_InputConnectionImpl.h @@ -0,0 +1,127 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_InputConnectionImpl.h +* @brief This is the implementation file for the _InputConnectionImpl class. +*/ + +#ifndef _FUI_INTERNAL_INPUT_CONNECTION_IMPL_H_ +#define _FUI_INTERNAL_INPUT_CONNECTION_IMPL_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Ui { + +class InputConnection; + +/** +* @class _InputConnectionImpl +* @brief This class is a based input method implements the behavior +* @since 2.0 +* +*/ +class _InputConnectionImpl + : public Tizen::Base::Object + , public _IKeyEventListener +{ +public: + virtual ~_InputConnectionImpl(void); + static _InputConnectionImpl* CreateInputConnectionImplN(InputConnection* pInputConnection); + + result Initialize(const Tizen::Ui::_Control& control, const IInputConnectionEventListener& listener, const IInputConnectionProvider& provider); + result BindInputMethod(void); + result UnbindInputMethod(void); + result ShowInputPanel(void); + result HideInputPanel(void); + result SetInputPanelStyle(InputPanelStyle style); + InputPanelStyle GetInputPanelStyle(void) const; + result SetAutoCapitalizationMode(AutoCapitalizationMode autoCapitalizationMode); + AutoCapitalizationMode GetAutoCapitalizationMode(void) const; + InputPanelShowState GetInputPanelShowState(void) const; + result SetInputPanelShowState(InputPanelShowState showState); + result FinishTextComposition(void); + result SetInputPanelAction(InputPanelAction inputPanelAction); + InputPanelAction GetInputPanelAction(void) const; + result SetInputPanelActionEnabled(bool enabled); + bool IsInputPanelActionEnabled(void) const; + result SetCursorPosition(int position); + result SetCursorBounds(const Tizen::Graphics::Rectangle& rect); + Tizen::Graphics::Rectangle GetInputPanelBounds(void) const; + Tizen::Graphics::Rectangle GetPredictionBounds(void) const; + result SetTextPredictionEnabled(bool enable); + bool IsTextPredictionEnabled(void) const; + result SetCapsLockEnabled(bool enable); + bool IsCapsLockEnabled(void) const; + + result SetInputPanelLanguage(Tizen::Locales::LanguageCode languageCode); + Tizen::Locales::LanguageCode GetInputPanelLanguage(void) const; + InputConnection* GetInputConnection(void) const; + IInputConnectionEventListener* GetInputConnectionListener(void) const; + IInputConnectionProvider* GetInputConnectionProvider(void) const; + bool CheckContextEvent(Ecore_IMF_Event_Type type, void* pEventInfo); + int CheckUSBKeyboardStatus(void); + + static _InputConnectionImpl* GetInstance(InputConnection& inputConnection); + static const _InputConnectionImpl* GetInstance(const InputConnection& inputConnection); + + virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo); + virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo); + +//Internal + void SetKeyEventSkipped(bool enabled); + +private: + _InputConnectionImpl(InputConnection* pInputConnection); + _InputConnectionImpl(const _InputConnectionImpl& rhs); + _InputConnectionImpl& operator=(const _InputConnectionImpl& rhs); + + void AddInputPanelCallback(void); + void AddEcoreEventCallback(void); + void AddEvasObjectEventCallback(void); + void RemoveInputPanelCallback(void); + void RemoveEcoreEventCallback(void); + void RemoveEvasObjectEventCallback(void); + + bool IsFilteredKeyOnUSBMode(InputPanelStyle style, int key); + +private: + Ecore_IMF_Context* __pContext; + _ControlHandle __controlHandle; + bool __IsBounded; + IInputConnectionEventListener* __pListener; + IInputConnectionProvider* __pProvider; + InputConnection* __pInputConnection; + InputPanelAction __inputPanelAction; + InputPanelShowState __inputPanelState; + InputPanelStyle __inputPanelStyle; + Ecore_Event_Handler* __pUSBEventHandler; + bool __IsKeyEventSkipped; + +}; // _InputConnectionImpl + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_INPUT_CONNECTION_IMPL_H_ + + diff --git a/src/ui/FUi_KeyEventManager.cpp b/src/ui/FUi_KeyEventManager.cpp new file mode 100644 index 0000000..48c1d96 --- /dev/null +++ b/src/ui/FUi_KeyEventManager.cpp @@ -0,0 +1,299 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_KeyEventManager.cpp +* @brief This is the implementation file for _KeyEventManager class. +* @version 2.0 +* @see Tizen::Ui::_KeyEventManager +* +*/ + +// includes +#include +#include +#include +#include +#include +#include +#include "FUi_KeyEventManager.h" +#include "FUi_KeyEventManagerImpl.h" +#include "FUi_Control.h" +#include "FUi_ControlImpl.h" +#include "FUi_ControlManager.h" +#include "FUi_IKeyEventListener.h" +#include "FUi_UiEventManager.h" +#include "FUi_UiKeyEvent.h" + +// using namespaces +using namespace Tizen::Ui; +using namespace Tizen::Base::Collection; + +namespace +{ +class _KeyEventListener + : public _IKeyEventListener + , virtual public _IUiEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + _KeyEventListener(void) + { + } + + virtual ~_KeyEventListener(void) + { + } + + virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) + { + _KeyEventManager* pKeyManager = _KeyEventManager::GetInstance(); + SysTryReturn(NID_UI, pKeyManager, false, E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + LinkedListT* pList = pKeyManager->GetKeyEventListener(); + + bool isFiltered = false; + + if (pList) + { + IEnumeratorT<_IKeyEventListener*>* pEnumerator = pList->GetEnumeratorN(); + + if (pEnumerator) + { + while (pEnumerator->MoveNext() == E_SUCCESS) + { + _IKeyEventListener* pKeyEventListener = null; + pEnumerator->GetCurrent(pKeyEventListener); + + if (pKeyEventListener != null) + { + isFiltered = pKeyEventListener->OnKeyPressed(source, keyInfo); + } + + //only call first key listener + if (keyInfo.GetKeyCode() == _KEY_END) + { + break; + } + } + + delete pEnumerator; + } + } + + return isFiltered; + } + + virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) + { + _KeyEventManager* pKeyManager = _KeyEventManager::GetInstance(); + SysTryReturn(NID_UI, pKeyManager, false, E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + LinkedListT* pList = pKeyManager->GetKeyEventListener(); + bool isFiltered = false; + + if (pList) + { + IEnumeratorT<_IKeyEventListener*>* pEnumerator = pList->GetEnumeratorN(); + + if (pEnumerator) + { + while (pEnumerator->MoveNext() == E_SUCCESS) + { + _IKeyEventListener* pKeyEventListener = null; + pEnumerator->GetCurrent(pKeyEventListener); + + if (pKeyEventListener != null) + { + isFiltered = pKeyEventListener->OnKeyReleased(source, keyInfo); + } + + //only call first key listener + if (keyInfo.GetKeyCode() == _KEY_END) + { + break; + } + } + + delete pEnumerator; + } + } + + return isFiltered; + } +}; +} + + +namespace Tizen { namespace Ui +{ + +_KeyEventManager* _KeyEventManager::__pInstance = null; + +_KeyEventManager::_KeyEventManager(void) + : __pKeyEventListeners(null) + , __pKeyEventListener(null) + , __pKeyCapturingMap(null) +{ + _UiEventManager* pEventManager = _UiEventManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pEventManager, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + __pKeyEventListener = new (std::nothrow)_KeyEventListener; + SysTryReturnVoidResult(NID_UI, __pKeyEventListener, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pKeyCapturingMap = new (std::nothrow) HashMapT<_KeyCode, _ControlHandle>; + SysTryCatch(NID_UI, __pKeyCapturingMap, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + SysTryCatch(NID_UI, __pKeyCapturingMap->Construct() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pKeyEventListeners = new (std::nothrow) LinkedListT; + SysTryCatch(NID_UI, __pKeyEventListeners, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pEventManager->AddKeyEventListener(*__pKeyEventListener); + + return; + +CATCH: + if (__pKeyEventListener) + { + delete __pKeyEventListener; + __pKeyEventListener = null; + } + + if (__pKeyCapturingMap) + { + delete __pKeyCapturingMap; + __pKeyCapturingMap = null; + } +} + +_KeyEventManager::~_KeyEventManager(void) +{ + if (__pKeyEventListeners) + { + delete __pKeyEventListeners; + __pKeyEventListeners = null; + } + + if (__pKeyEventListener) + { + _UiEventManager* pEventManager = _UiEventManager::GetInstance(); + if (pEventManager) + { + pEventManager->RemoveKeyEventListener(*__pKeyEventListener); + } + + delete __pKeyEventListener; + __pKeyEventListener = null; + } + + if (__pKeyCapturingMap) + { + delete __pKeyCapturingMap; + __pKeyCapturingMap = null; + } +} + +void +_KeyEventManager::Initialize(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (__pInstance == null) + { + pthread_once(&once_block, InitializeInstance); + } + } + +_KeyEventManager* +_KeyEventManager::GetInstance(void) +{ + return __pInstance; +} + +void +_KeyEventManager::InitializeInstance(void) +{ + ClearLastResult(); + + if (__pInstance == null) + { + __pInstance = new (std::nothrow) _KeyEventManager; + SysTryReturnVoidResult(NID_UI, __pInstance != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); +} +} + +void +_KeyEventManager::ReleaseInstance(void) +{ + if (__pInstance) + { + delete __pInstance; + __pInstance = null; + } +} + +void +_KeyEventManager::AddKeyEventListener(const _IKeyEventListener& listener) +{ + __pKeyEventListeners->Add(const_cast<_IKeyEventListener*>(&listener)); +} + + +void +_KeyEventManager::RemoveKeyEventListener(const _IKeyEventListener& listener) +{ + __pKeyEventListeners->Remove(const_cast<_IKeyEventListener*>(&listener)); +} + +LinkedListT* +_KeyEventManager::GetKeyEventListener(void) const +{ + return __pKeyEventListeners; +} + +_Control* +_KeyEventManager::GetCapturingControl(_KeyCode keyCode) const +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysAssert(pControlManager != null); + + _ControlHandle handle; + __pKeyCapturingMap->GetValue(keyCode, handle); + return pControlManager->GetObject(handle); +} + +void +_KeyEventManager::SetCapturingControl(const _Control& control, _KeyCode keyCode, bool captureAllowed) +{ + if (captureAllowed) + { + bool exist = false; + __pKeyCapturingMap->ContainsKey(keyCode, exist); + + if (exist) + { + __pKeyCapturingMap->Remove(keyCode); + } + + __pKeyCapturingMap->Add(keyCode, control.GetHandle()); + } + else + { + __pKeyCapturingMap->Add(keyCode, _ControlHandle()); + } +} + +} } //Tizen::Ui diff --git a/src/ui/FUi_KeyEventManagerImpl.cpp b/src/ui/FUi_KeyEventManagerImpl.cpp new file mode 100644 index 0000000..c852a5a --- /dev/null +++ b/src/ui/FUi_KeyEventManagerImpl.cpp @@ -0,0 +1,237 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_KeyEventManagerImpl.cpp +* @brief This is the implementation file for _KeyEventManagerImpl class. +* @version 2.0 +* @see Tizen::Ui::_KeyEventManagerImpl +* +*/ + +// includes +#include +#include +#include +#include +#include +#include +#include "FUi_KeyEventManagerImpl.h" +#include "FUi_ControlImpl.h" +#include "FUi_Control.h" +#include "FUi_KeyEventManager.h" + +// using namespaces +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui +{ + +//////////////////////////////////////////////////////////////////////////////// +/// _KeyEventManagerImpl class Lifecycle + +class _KeyEventManagerImpl::PublicEventListener + : public _IKeyEventListener + , virtual public _IUiEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + PublicEventListener(_KeyEventManagerImpl& mgrImpl) + : __keyMgrImpl(mgrImpl) + { + } + + virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) + { + if (keyInfo.GetKeyCode() > _KEY_HARDWARE_MAX) + { + return false; + } + + Tizen::Base::Collection::IEnumeratorT* pEnum = __keyMgrImpl.__pPublicKeyEventListeners->GetEnumeratorN(); + _ControlImpl* pImpl = static_cast<_ControlImpl*>(source.GetUserData()); + SysTryCatch(NID_UI, pImpl != null, , E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + if (pEnum) + { + while (pEnum->MoveNext() == E_SUCCESS) + { + IKeyEventListener* pKeyEventListener = null; + pEnum->GetCurrent(pKeyEventListener); + + if (pKeyEventListener != null) + { + pKeyEventListener->OnKeyPressed(pImpl->GetPublic(), static_cast(keyInfo.GetKeyCode())); + } + } + } + + delete pEnum; + return true; + +CATCH: + delete pEnum; + return false; + }; + + virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) + { + if (keyInfo.GetKeyCode() > _KEY_HARDWARE_MAX) + { + return false; + } + + Tizen::Base::Collection::IEnumeratorT* pEnum = __keyMgrImpl.__pPublicKeyEventListeners->GetEnumeratorN(); + _ControlImpl* pImpl = static_cast<_ControlImpl*>(source.GetUserData()); + SysTryCatch(NID_UI, pImpl != null, , E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + if (pEnum) + { + while (pEnum->MoveNext() == E_SUCCESS) + { + IKeyEventListener* pKeyEventListener = null; + pEnum->GetCurrent(pKeyEventListener); + + if (pKeyEventListener != null) + { + pKeyEventListener->OnKeyReleased(pImpl->GetPublic(), static_cast(keyInfo.GetKeyCode())); + } + } + } + + delete pEnum; + return true; + +CATCH: + delete pEnum; + return false; + }; + +private: + PublicEventListener(const PublicEventListener&); + PublicEventListener& operator =(const PublicEventListener&); + +private: + _KeyEventManagerImpl& __keyMgrImpl; +}; + + +_KeyEventManagerImpl* _KeyEventManagerImpl::__pInstance = null; + +_KeyEventManagerImpl::_KeyEventManagerImpl(void) +{ + __pPublicKeyEventListeners = new (std::nothrow) Tizen::Base::Collection::LinkedListT ; + SysTryReturnVoidResult(NID_UI, __pPublicKeyEventListeners, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pKeyEventListeners = new (std::nothrow) PublicEventListener(*this); + SysTryReturnVoidResult(NID_UI, __pKeyEventListeners, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + _KeyEventManager* pKeyMgr = _KeyEventManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pKeyMgr, E_SYSTEM, + "[E_SYSTEM] pKeyMgr == null"); + + pKeyMgr->AddKeyEventListener(*__pKeyEventListeners); +} + +_KeyEventManagerImpl::~_KeyEventManagerImpl(void) +{ + if (__pPublicKeyEventListeners) + { + delete __pPublicKeyEventListeners; + __pPublicKeyEventListeners = null; + } + + if (__pKeyEventListeners) + { + delete __pKeyEventListeners; + __pKeyEventListeners = null; + } +} + +void +_KeyEventManagerImpl::Initialize(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (__pInstance == null) + { + pthread_once(&once_block, InitializeInstance); + } +} + +_KeyEventManagerImpl* +_KeyEventManagerImpl::GetInstance(void) +{ + return __pInstance; +} + +void +_KeyEventManagerImpl::InitializeInstance(void) +{ + ClearLastResult(); + + if (__pInstance == null) + { + __pInstance = new (std::nothrow) _KeyEventManagerImpl; + SysTryReturnVoidResult(NID_UI, __pInstance != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + } + } + +void +_KeyEventManagerImpl::ReleaseInstance(void) +{ + if (__pInstance) + { + delete __pInstance; + __pInstance = null; + } +} + +//////////////////////////////////////////////////////////////////////////////// +/// KeyEventManager class Operation + +void +_KeyEventManagerImpl::AddKeyEventListener(IKeyEventListener& listener) +{ + __pPublicKeyEventListeners->Add(&listener); +} + + +void +_KeyEventManagerImpl::RemoveKeyEventListener(IKeyEventListener& listener) +{ + __pPublicKeyEventListeners->Remove(&listener); +} + +_ControlImpl* +_KeyEventManagerImpl::GetKeyCapturingControl(KeyCode keyCode) const +{ + _KeyEventManager* pKeyEventManager = _KeyEventManager::GetInstance(); + SysAssert(pKeyEventManager != null); + + _Control* pCapturedControl = pKeyEventManager->GetCapturingControl(static_cast<_KeyCode>(keyCode)); + if (pCapturedControl) + { + _ControlImpl* pControlImpl = static_cast<_ControlImpl*>(pCapturedControl->GetUserData()); + return pControlImpl; + } + + return null; +} + +} } //Tizen::Ui diff --git a/src/ui/FUi_LayoutImpl.cpp b/src/ui/FUi_LayoutImpl.cpp new file mode 100644 index 0000000..8c3b470 --- /dev/null +++ b/src/ui/FUi_LayoutImpl.cpp @@ -0,0 +1,541 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutImpl.cpp + * @brief This is the implementation file for _Layout class. + * + * This file contains the implementation of _Layout class. + */ + +#include +#include +#include +#include +#include +#include +#include "FUi_LayoutImpl.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui +{ + +namespace +{ +static const int CONVERT_ERROR_CODE = -1; + +_Layout::HorizontalAlign +ConvertEnum(const LayoutHorizontalAlignment val) +{ + switch (val) + { + case LAYOUT_HORIZONTAL_ALIGN_LEFT: + return _Layout::ITEM_HORIZONTAL_ALIGN_LEFT; + + case LAYOUT_HORIZONTAL_ALIGN_RIGHT: + return _Layout::ITEM_HORIZONTAL_ALIGN_RIGHT; + + case LAYOUT_HORIZONTAL_ALIGN_CENTER: + return _Layout::ITEM_HORIZONTAL_ALIGN_CENTER; + + default: + return static_cast <_Layout::HorizontalAlign>(CONVERT_ERROR_CODE); + } +} + +LayoutHorizontalAlignment +ConvertEnum(const _Layout::HorizontalAlign val) +{ + switch (val) + { + case _Layout::ITEM_HORIZONTAL_ALIGN_LEFT: + return LAYOUT_HORIZONTAL_ALIGN_LEFT; + + case _Layout::ITEM_HORIZONTAL_ALIGN_RIGHT: + return LAYOUT_HORIZONTAL_ALIGN_RIGHT; + + case _Layout::ITEM_HORIZONTAL_ALIGN_CENTER: + return LAYOUT_HORIZONTAL_ALIGN_CENTER; + + default: + return static_cast (CONVERT_ERROR_CODE); + } +} + +_Layout::VerticalAlign +ConvertEnum(const LayoutVerticalAlignment val) +{ + switch (val) + { + case LAYOUT_VERTICAL_ALIGN_TOP: + return _Layout::ITEM_VERTICAL_ALIGN_TOP; + + case LAYOUT_VERTICAL_ALIGN_BOTTOM: + return _Layout::ITEM_VERTICAL_ALIGN_BOTTOM; + + case LAYOUT_VERTICAL_ALIGN_MIDDLE: + return _Layout::ITEM_VERTICAL_ALIGN_MIDDLE; + + default: + return static_cast <_Layout::VerticalAlign>(CONVERT_ERROR_CODE); + } +} + +LayoutVerticalAlignment +ConvertEnum(const _Layout::VerticalAlign val) +{ + switch (val) + { + case _Layout::ITEM_VERTICAL_ALIGN_TOP: + return LAYOUT_VERTICAL_ALIGN_TOP; + + case _Layout::ITEM_VERTICAL_ALIGN_BOTTOM: + return LAYOUT_VERTICAL_ALIGN_BOTTOM; + + case _Layout::ITEM_VERTICAL_ALIGN_MIDDLE: + return LAYOUT_VERTICAL_ALIGN_MIDDLE; + + default: + return static_cast (CONVERT_ERROR_CODE); + } +} + +_Layout::LayoutMatchMode +ConvertEnum(FitPolicy val) +{ + switch (val) + { + case FIT_POLICY_FIXED: + return _Layout::NONE_MODE; + + case FIT_POLICY_CONTENT: + return _Layout::WRAP_CONTENT; + + case FIT_POLICY_PARENT: + return _Layout::MATCH_PARENT; + + default: + return static_cast <_Layout::LayoutMatchMode>(CONVERT_ERROR_CODE); + } +} + +FitPolicy +ConvertEnum(_Layout::LayoutMatchMode val) +{ + switch (val) + { + case _Layout::NONE_MODE: + return FIT_POLICY_FIXED; + + case _Layout::WRAP_CONTENT: + return FIT_POLICY_CONTENT; + + case _Layout::MATCH_PARENT: + return FIT_POLICY_PARENT; + + default: + return static_cast (CONVERT_ERROR_CODE); + } +} +} + +// _LayoutImpl implementation +_LayoutImpl::_LayoutImpl(Layout* pPublicLayout, _Layout::Layout* pCoreLayout) + : _pPublicLayout(pPublicLayout) + , _pCoreLayout(pCoreLayout) +{ +} + +_LayoutImpl::~_LayoutImpl() +{ + delete _pCoreLayout; +} + +result +_LayoutImpl::CheckConstruction(_Layout::Layout* pCoreLayout, _LayoutImpl* pImplLayout) +{ + if (pImplLayout == null) + { + delete pCoreLayout; + SysLogException(NID_UI, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + return E_OUT_OF_MEMORY; + } + + result r = GetLastResult(); + + if (IsFailed(r)) + { + delete pImplLayout; + pImplLayout = null; + + SysLogException(NID_UI, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + + return E_SUCCESS; +} + +_SharedPtr <_LayoutImpl> +_LayoutImpl::GetLayoutImpl(Layout* pPublicLayout) +{ + LayoutImplHolder* pHolder = static_cast (pPublicLayout->_pImpl); + SysAssert(pHolder != null); + + return pHolder->layoutImpl; +} + +void +_LayoutImpl::SetLayoutImpl(Layout* pPublicLayout, _LayoutImpl* pImplLayout) +{ + LayoutImplHolder* pHolder = static_cast (pPublicLayout->_pImpl); + SysAssert(pHolder != null); + + pHolder->layoutImpl.SetNull(); + pHolder->layoutImpl.Bind(pImplLayout); +} + +const char* +_LayoutImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Layout"; +} + +const Layout& +_LayoutImpl::GetPublic(void) const +{ + return *_pPublicLayout; +} + +Layout& +_LayoutImpl::GetPublic(void) +{ + return *_pPublicLayout; +} + +const _Layout::Layout& +_LayoutImpl::GetCore(void) const +{ + return *_pCoreLayout; +} + +_Layout::Layout& +_LayoutImpl::GetCore(void) +{ + return *_pCoreLayout; +} + +const _LayoutImpl* +_LayoutImpl::GetInstance(const Layout& layout) +{ + LayoutImplHolder* pHolder = static_cast (layout._pImpl); + SysAssert(pHolder != null); + + const _LayoutImpl* pImpl = pHolder->layoutImpl.Get(); + + return pImpl; +} + +_LayoutImpl* +_LayoutImpl::GetInstance(Layout& layout) +{ + LayoutImplHolder* pHolder = static_cast (layout._pImpl); + SysAssert(pHolder != null); + + _LayoutImpl* pImpl = pHolder->layoutImpl.Get(); + + return pImpl; +} + +result +_LayoutImpl::SetAlignment(const _ControlImpl& item, const LayoutHorizontalAlignment horizontalAlign, const LayoutVerticalAlignment verticalAlign) +{ + ClearLastResult(); + + _Layout::LayoutItem& layoutItem = item.GetLayoutContainer(); + + _Layout::ItemAlign itemAlign; + itemAlign.HAlign = ConvertEnum(horizontalAlign); + SysTryReturn(NID_UI, itemAlign.HAlign != (_Layout::HorizontalAlign) CONVERT_ERROR_CODE, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + itemAlign.VAlign = ConvertEnum(verticalAlign); + SysTryReturn(NID_UI, itemAlign.VAlign != (_Layout::VerticalAlign) CONVERT_ERROR_CODE, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + return _pCoreLayout->SetItemAlignment(layoutItem, itemAlign); +} + +result +_LayoutImpl::GetAlignment(const _ControlImpl& item, LayoutHorizontalAlignment& horizontalAlign, LayoutVerticalAlignment& verticalAlign) const +{ + _Layout::LayoutItem& layoutItem = item.GetLayoutContainer(); + + result r = E_SUCCESS; + _Layout::ItemAlign itemAlign; + + r = _pCoreLayout->GetItemAlignment(layoutItem, itemAlign); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + horizontalAlign = ConvertEnum(itemAlign.HAlign); + verticalAlign = ConvertEnum(itemAlign.VAlign); + + return E_SUCCESS; +} + +result +_LayoutImpl::SetMargin(const _ControlImpl& item, int left, int right, int top, int bottom) +{ + SysTryReturn(NID_UI, left >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The left margin is negative."); + SysTryReturn(NID_UI, right >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The right margin is negative."); + SysTryReturn(NID_UI, top >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The top margin is negative."); + SysTryReturn(NID_UI, bottom >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The bottom margin is negative."); + + _Layout::LayoutItem& layoutItem = item.GetLayoutContainer(); + + _Layout::ItemMargin itemMargin; + + itemMargin.left = left; + itemMargin.right = right; + itemMargin.top = top; + itemMargin.bottom = bottom; + + result r = _pCoreLayout->SetItemMargin(layoutItem, itemMargin); + + return r; +} + +result +_LayoutImpl::GetMargin(const _ControlImpl& item, int& left, int& right, int& top, int& bottom) const +{ + _Layout::LayoutItem& layoutItem = item.GetLayoutContainer(); + + _Layout::ItemMargin itemMargin; + + result r = _pCoreLayout->GetItemMargin(layoutItem, itemMargin); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + left = itemMargin.left; + right = itemMargin.right; + top = itemMargin.top; + bottom = itemMargin.bottom; + + return r; +} + +result +_LayoutImpl::SetHorizontalFitPolicy(const _ControlImpl& item, const FitPolicy policy) +{ + _Layout::LayoutItem& layoutItem = item.GetLayoutContainer(); + + _Layout::LayoutMatchMode matchMode; + + matchMode = ConvertEnum(policy); + + SysTryReturn(NID_UI, matchMode != (_Layout::LayoutMatchMode) CONVERT_ERROR_CODE, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + result r = _pCoreLayout->SetItemWidthMatchMode(layoutItem, matchMode); + + return r; +} + +result +_LayoutImpl::GetHorizontalFitPolicy(const _ControlImpl& item, FitPolicy& policy) const +{ + _Layout::LayoutItem& layoutItem = item.GetLayoutContainer(); + + _Layout::LayoutMatchMode matchMode; + + result r = _pCoreLayout->GetItemWidthMatchMode(layoutItem, matchMode); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + policy = ConvertEnum(matchMode); + + return r; +} + +result +_LayoutImpl::SetVerticalFitPolicy(const _ControlImpl& item, const FitPolicy matchMode) +{ + _Layout::LayoutItem& layoutItem = item.GetLayoutContainer(); + + _Layout::LayoutMatchMode layoutMatchMode; + + layoutMatchMode = ConvertEnum(matchMode); + + SysTryReturn(NID_UI, layoutMatchMode != (_Layout::LayoutMatchMode) CONVERT_ERROR_CODE, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid."); + + result r = _pCoreLayout->SetItemHeightMatchMode(layoutItem, layoutMatchMode); + + return r; +} + +result +_LayoutImpl::GetVerticalFitPolicy(const _ControlImpl& item, FitPolicy& policy) const +{ + _Layout::LayoutItem& layoutItem = item.GetLayoutContainer(); + + _Layout::LayoutMatchMode matchMode; + + result r = _pCoreLayout->GetItemHeightMatchMode(layoutItem, matchMode); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + policy = ConvertEnum(matchMode); + + return r; +} + +result +_LayoutImpl::UpdateLayout(void) +{ + result r = _pCoreLayout->UpdateLayout(); + + return r; +} + +result +_LayoutImpl::AddItem(_ControlImpl& addItem) +{ + _Layout::LayoutItem& layoutItem = addItem.GetLayoutContainer(); + + result r = _pCoreLayout->AddItem(layoutItem); + + return r; +} + +result +_LayoutImpl::RemoveItem(const _ControlImpl& removeItem) +{ + _Layout::LayoutItem& layoutItem = removeItem.GetLayoutContainer(); + + result r = _pCoreLayout->RemoveItem(layoutItem); + + return r; +} + +result +_LayoutImpl::OnChangeViewPos(int viewPosX, int viewPosY) +{ + result r = _pCoreLayout->OnChangeViewPosition(viewPosX, viewPosY); + + return r; +} + +result +_LayoutImpl::SetItemBaseRect(const _ControlImpl& item, const _Layout::LayoutRect baseRect) +{ + SysTryReturn(NID_UI, baseRect.x >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] X position is negative."); + SysTryReturn(NID_UI, baseRect.y >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Y position is negative."); + SysTryReturn(NID_UI, baseRect.w >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Width is negative."); + SysTryReturn(NID_UI, baseRect.h >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Height is negative."); + + _Layout::LayoutItem& layoutItem = item.GetLayoutContainer(); + + result r = _pCoreLayout->SetItemBaseRect(layoutItem, baseRect); + + return r; +} + +result +_LayoutImpl::GetItemBaseRect(const _ControlImpl& item, _Layout::LayoutRect& baseRect) const +{ + _Layout::LayoutItem& layoutItem = item.GetLayoutContainer(); + + result r = _pCoreLayout->GetItemBaseRect(layoutItem, baseRect); + + return r; +} + +void +_LayoutImpl::AllocateLayoutImpl(Layout* pPublicLayout, _SharedPtr layoutImpl) +{ + LayoutImplHolder* pHolder = static_cast (pPublicLayout->_pImpl); + SysAssert(pHolder != null); + + pHolder->layoutImpl = layoutImpl; +} + +Layout* +_LayoutImpl::CreatePublicLayoutN(_SharedPtr layoutImpl) +{ + _LayoutImpl* pLayoutImpl = layoutImpl.Get(); + if (pLayoutImpl == null) + { + return null; + } + + switch (pLayoutImpl->GetLayoutType()) + { + case LAYOUT_RELATIVE: + { + RelativeLayout* pPublicLayout = new (std::nothrow) RelativeLayout; + SysTryReturn(NID_UI, pPublicLayout != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + _LayoutImpl::AllocateLayoutImpl(pPublicLayout, layoutImpl); + + return pPublicLayout; + } + + case LAYOUT_VERTICAL_BOX: + { + VerticalBoxLayout* pPublicLayout = new (std::nothrow) VerticalBoxLayout; + SysTryReturn(NID_UI, pPublicLayout != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + _LayoutImpl::AllocateLayoutImpl(pPublicLayout, layoutImpl); + + return pPublicLayout; + } + + case LAYOUT_HORIZONTAL_BOX: + { + HorizontalBoxLayout* pPublicLayout = new (std::nothrow) HorizontalBoxLayout; + SysTryReturn(NID_UI, pPublicLayout != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + _LayoutImpl::AllocateLayoutImpl(pPublicLayout, layoutImpl); + + return pPublicLayout; + } + + case LAYOUT_GRID: + { + GridLayout* pPublicLayout = new (std::nothrow) GridLayout; + SysTryReturn(NID_UI, pPublicLayout != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + _LayoutImpl::AllocateLayoutImpl(pPublicLayout, layoutImpl); + + return pPublicLayout; + } + + case LAYOUT_CARD: + { + CardLayout* pPublicLayout = new (std::nothrow) CardLayout; + SysTryReturn(NID_UI, pPublicLayout != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + _LayoutImpl::AllocateLayoutImpl(pPublicLayout, layoutImpl); + + return pPublicLayout; + } + + default: + SysAssert(false); + return null; + } + return null; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_LayoutImpl.h b/src/ui/FUi_LayoutImpl.h new file mode 100644 index 0000000..d22649b --- /dev/null +++ b/src/ui/FUi_LayoutImpl.h @@ -0,0 +1,309 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutImpl.h + * @brief This is the header file for _LayoutImpl class. + * + * This header file contains the declaration of _LayoutImpl class. + */ + +#ifndef _FUI_LAYOUT_IMPL_H_ +#define _FUI_LAYOUT_IMPL_H_ + +#include +#include +#include "FUi_ControlImpl.h" +#include "FUi_LayoutLayout.h" +#include "FUi_SharedPtr.h" + +namespace Tizen { namespace Ui +{ + +class Layout; + +class _LayoutImpl + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _LayoutImpl(const _LayoutImpl&); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_LayoutImpl(void); + + /** + * Gets the name of public class. + * + * @since 2.0 + * @return The name of public class. + */ + virtual const char* GetPublicClassName(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual const Layout& GetPublic(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual Layout& GetPublic(void); + + /** + * Gets the core class. + * + * @since 2.0 + * @return The core class. + */ + virtual const _Layout::Layout& GetCore(void) const; + + /** + * Gets the core class. + * + * @since 2.0 + * @return The core class. + */ + virtual _Layout::Layout& GetCore(void); + + /** + * Gets the _LayoutImpl instance for the Layout. + * + * @since 2.0 + * @return The _LayoutImpl instance. + * @param[in] pLayout The Layout instance. + */ + static const _LayoutImpl* GetInstance(const Layout& layout); + + /** + * Gets the _LayoutImpl instance for the Layout. + * + * @since 2.0 + * @return The _LayoutImpl instance. + * @param[in] pLayout The Layout instance. + */ + static _LayoutImpl* GetInstance(Layout& layout); + + /** + * Gets the type of the layout. + * + * @since 2.0 + * @return The layout type + */ + virtual LayoutType GetLayoutType(void) const = 0; + + /** + * + * + * @return An error code + * @exception + * @since 2.0 + */ + result UpdateLayout(void); + + static _SharedPtr <_LayoutImpl> GetLayoutImpl(Layout* pLayout); + static Layout* CreatePublicLayoutN(_SharedPtr <_LayoutImpl> layoutImpl); + static void SetLayoutImpl(Layout* pPublicLayout, _LayoutImpl* pImplLayout); + +protected: + _LayoutImpl(Layout* pPublicLayout, _Layout::Layout* _pCoreLayout); + static result CheckConstruction(_Layout::Layout* pCoreLayout, _LayoutImpl* pImplLayout); + + /** + * Sets the alignment of the specified item. + * + * @return An error code + * @param[in] item The item for which the alignment is set + * @param[in] align The alignment + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The alignment parameter is invalid. + * @since 2.0 + */ + result SetAlignment(const _ControlImpl& item, const LayoutHorizontalAlignment horizontalAlign, const LayoutVerticalAlignment verticalAlign); + + /** + * Gets the alignment of the specified item. + * + * @return An error code + * @param[in] item The item to get the alignment + * @param[out] align The alignment + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result GetAlignment(const _ControlImpl& item, LayoutHorizontalAlignment& horizontalAlign, LayoutVerticalAlignment& verticalAlign) const; + + /** + * Sets the margin of the specified item. + * + * @return An error code + * @param[in] item The item for which the margin is set + * @param[in] margin The margin + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result SetMargin(const _ControlImpl& item, int left, int right, int top, int bottom); + + /** + * Gets the margin of the specified item. + * + * @return An error code + * @param[in] item The item to get the margin + * @param[out] margin The margin + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result GetMargin(const _ControlImpl& item, int& left, int& right, int& top, int& bottom) const; + + /** + * Sets the width of the specified item with the match policy. + * + * @return An error code + * @param[in] item The item for which the width is set + * @patam[in] matchMode The match policy + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result SetHorizontalFitPolicy(const _ControlImpl& item, const FitPolicy policy); + + /** + * Gets the width of the specified item with the match policy. + * + * @return An error code + * @param[in] item The item to get the match policy of the width + * @patam[out] matchMode The match policy + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result GetHorizontalFitPolicy(const _ControlImpl& item, FitPolicy& policy) const; + + /** + * Sets the height of the specified item with the match policy. + * + * @return An error code + * @param[in] item The item for which the height is set + * @patam[in] matchMode The match policy + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result SetVerticalFitPolicy(const _ControlImpl& item, const FitPolicy matchMode); + + /** + * Gets the height of the specified item with the match policy. + * + * @return An error code + * @param[in] item The item to get the match policy of the height + * @patam[out] matchMode The match policy + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result GetVerticalFitPolicy(const _ControlImpl& item, FitPolicy& matchMode) const; + + /** + * Adds the item at the end of the list maintained by the layout + * + * @return An error code + * @param[in] addItem + * @exception + * @since 2.0 + */ + result AddItem(_ControlImpl& addItem); + + /** + * + * + * @return An error code + * @param[in] removeItem + * @exception + * @since 2.0 + */ + result RemoveItem(const _ControlImpl& removeItem); + + /** + * + * + * @return An error code + * @param[in] viewPosX The x coordinate + * @param[in] viewPosY The y coordinate + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE The layout have a item instance that is in an invalid state. + * @since 2.0 + */ + result OnChangeViewPos(int viewPosX, int viewPosY); + + /** + * Sets the base location and dimension of the specified item. + * + * @return An error code + * @param[in] item The item for which the base location and dimension are set + * @patam[in] baseRect The rectangle value with the location and dimension + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result SetItemBaseRect(const _ControlImpl& item, const _Layout::LayoutRect baseRect); + + /** + * Gets the base location and dimension of the specified item. + * + * @return An error code + * @param[in] item The item to get the base location and dimension + * @patam[out] baseRect The rectangle value with the location and dimension + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result GetItemBaseRect(const _ControlImpl& item, _Layout::LayoutRect& baseRect) const; + +private: + _LayoutImpl& operator =(const _LayoutImpl&); + static void AllocateLayoutImpl(Layout* pPublicLayout, _SharedPtr layoutImpl); + +protected: + Layout* _pPublicLayout; + _Layout::Layout* _pCoreLayout; + +}; // _LayoutImpl + +struct LayoutImplHolder +{ + _SharedPtr layoutImpl; +}; + +}} // Tizen::Ui + +#endif // _FUI_LAYOUT_IMPL_H_ diff --git a/src/ui/FUi_Matrix3Df.cpp b/src/ui/FUi_Matrix3Df.cpp new file mode 100644 index 0000000..cd66966 --- /dev/null +++ b/src/ui/FUi_Matrix3Df.cpp @@ -0,0 +1,854 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_Matrix3Df.cpp + * @brief Header file of _Matrix3Df class + * + * This file contains declarations _Matrix3Df class. + */ + +#include +#include "FUi_Math.h" +#include "FUi_Matrix3Df.h" + +#define PI 3.141592653f + +namespace +{ + +float identityTransform[4][4] = +{ + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f } +}; + +}; + +namespace Tizen { namespace Ui { namespace Animations +{ + +_Matrix3Df::_Matrix3Df(void) +{ + LoadIdentity(); +} + +_Matrix3Df::_Matrix3Df(const float* pValues) +{ + memcpy(__m, pValues, sizeof(__m)); + __complexity = GenericMatrix; +} + +_Matrix3Df& +_Matrix3Df::Assign(const _Matrix3Df& rhs) +{ + memcpy(__m, rhs.__m, sizeof(__m)); + __complexity = rhs.__complexity; + + return *this; +} + +_Matrix3Df& +_Matrix3Df::operator =(const _Matrix3Df& rhs) +{ + if (&rhs != this) + return Assign(rhs); + + return *this; +} + +bool +_Matrix3Df::operator ==(const _Matrix3Df& rhs) const +{ + return (__m[0][0] == rhs.__m[0][0] && + __m[0][1] == rhs.__m[0][1] && + __m[0][2] == rhs.__m[0][2] && + __m[0][3] == rhs.__m[0][3] && + __m[1][0] == rhs.__m[1][0] && + __m[1][1] == rhs.__m[1][1] && + __m[1][2] == rhs.__m[1][2] && + __m[1][3] == rhs.__m[1][3] && + __m[2][0] == rhs.__m[2][0] && + __m[2][1] == rhs.__m[2][1] && + __m[2][2] == rhs.__m[2][2] && + __m[2][3] == rhs.__m[2][3] && + __m[3][0] == rhs.__m[3][0] && + __m[3][1] == rhs.__m[3][1] && + __m[3][2] == rhs.__m[3][2] && + __m[3][3] == rhs.__m[3][3]); +} + +bool +_Matrix3Df::operator !=(const _Matrix3Df& rhs) const +{ + return (__m[0][0] != rhs.__m[0][0] || + __m[0][1] != rhs.__m[0][1] || + __m[0][2] != rhs.__m[0][2] || + __m[0][3] != rhs.__m[0][3] || + __m[1][0] != rhs.__m[1][0] || + __m[1][1] != rhs.__m[1][1] || + __m[1][2] != rhs.__m[1][2] || + __m[1][3] != rhs.__m[1][3] || + __m[2][0] != rhs.__m[2][0] || + __m[2][1] != rhs.__m[2][1] || + __m[2][2] != rhs.__m[2][2] || + __m[2][3] != rhs.__m[2][3] || + __m[3][0] != rhs.__m[3][0] || + __m[3][1] != rhs.__m[3][1] || + __m[3][2] != rhs.__m[3][2] || + __m[3][3] != rhs.__m[3][3]); +} + +void +_Matrix3Df::Optimize(void) +{ + if (__m[3][3] != 1.0f) + { + __complexity = GenericMatrix; + return; + } + + if (__m[1][0] != 0.0f || __m[2][0] != 0.0f || __m[2][1] != 0.0f) + { + __complexity = GenericMatrix; + return; + } + + if (__m[0][1] != 0.0f || __m[0][2] != 0.0f || __m[0][3] != 0.0f || + __m[1][2] != 0.0f || __m[1][3] != 0.0f || __m[2][3] != 0.0f) + { + __complexity = GenericMatrix; + return; + } + + bool isTranslate = (__m[3][0] != 0.0f || __m[3][1] != 0.0f || __m[3][2] != 0.0f); + bool isDiagonal = (__m[0][0] == 1.0f && __m[1][1] == 1.0f && __m[2][2] == 1.0f); + + if (isTranslate && isDiagonal) + __complexity = TranslationMatrix; + else if (isTranslate) + __complexity = GenericMatrix; + else if (isDiagonal) + __complexity = IdentityMatrix; + else + __complexity = ScaleMatrix; +} + +_Matrix3Df& +_Matrix3Df::operator *=(const _Matrix3Df& rhs) +{ + if (__complexity == IdentityMatrix) + { + *this = rhs; + } + else if (rhs.__complexity == IdentityMatrix) + { + // nothing... + } + else + { + *this = *this * rhs; + } + + return *this; +} + +_Matrix3Df& +_Matrix3Df::MultiplyMatrix(const _Matrix3Df& matrix) +{ + *this = *this * matrix; + + return *this; +} + +_Matrix3Df& +_Matrix3Df::Concatenate(const _Matrix3Df* matrix) +{ + return Concatenate(*matrix); +} + +_Matrix3Df& +_Matrix3Df::Concatenate(const _Matrix3Df& matrix) +{ + *this = matrix * *this; + + return *this; +} + +float +_Matrix3Df::GetDeterminant(void) const +{ + float a0, a1, a2, a3, a4, a5; + float b0, b1, b2, b3, b4, b5; + float det; + + a0 = __m[0][0] * __m[1][1] - __m[0][1] * __m[1][0]; + a1 = __m[0][0] * __m[1][2] - __m[0][2] * __m[1][0]; + a2 = __m[0][0] * __m[1][3] - __m[0][3] * __m[1][0]; + a3 = __m[0][1] * __m[1][2] - __m[0][2] * __m[1][1]; + a4 = __m[0][1] * __m[1][3] - __m[0][3] * __m[1][1]; + a5 = __m[0][2] * __m[1][3] - __m[0][3] * __m[1][2]; + + b0 = __m[2][0] * __m[3][1] - __m[2][1] * __m[3][0]; + b1 = __m[2][0] * __m[3][2] - __m[2][2] * __m[3][0]; + b2 = __m[2][0] * __m[3][3] - __m[2][3] * __m[3][0]; + b3 = __m[2][1] * __m[3][2] - __m[2][2] * __m[3][1]; + b4 = __m[2][1] * __m[3][3] - __m[2][3] * __m[3][1]; + b5 = __m[2][2] * __m[3][3] - __m[2][3] * __m[3][2]; + + det = a0 * b5 - a1 * b4 + a2 * b3 + a3 * b2 - a4 * b1 + a5 * b0; + + return det; +} + +bool +_Matrix3Df::IsInvertible(void) const +{ + if (__complexity == IdentityMatrix) + return true; + + if (__complexity == TranslationMatrix) + return true; + + return !_FloatHardCompare(GetDeterminant(), 0.0f); +} + +bool +_Matrix3Df::Invert(void) +{ + // TODO: + // Optimize using NEON + float a0, a1, a2, a3, a4, a5; + float b0, b1, b2, b3, b4, b5; + float det; + + if (__complexity == IdentityMatrix) + return true; + + if (__complexity == TranslationMatrix) + { + __m[3][0] = -__m[3][0]; + __m[3][1] = -__m[3][1]; + __m[3][2] = -__m[3][2]; + return true; + } + + + a0 = __m[0][0] * __m[1][1] - __m[0][1] * __m[1][0]; + a1 = __m[0][0] * __m[1][2] - __m[0][2] * __m[1][0]; + a2 = __m[0][0] * __m[1][3] - __m[0][3] * __m[1][0]; + a3 = __m[0][1] * __m[1][2] - __m[0][2] * __m[1][1]; + a4 = __m[0][1] * __m[1][3] - __m[0][3] * __m[1][1]; + a5 = __m[0][2] * __m[1][3] - __m[0][3] * __m[1][2]; + + b0 = __m[2][0] * __m[3][1] - __m[2][1] * __m[3][0]; + b1 = __m[2][0] * __m[3][2] - __m[2][2] * __m[3][0]; + b2 = __m[2][0] * __m[3][3] - __m[2][3] * __m[3][0]; + b3 = __m[2][1] * __m[3][2] - __m[2][2] * __m[3][1]; + b4 = __m[2][1] * __m[3][3] - __m[2][3] * __m[3][1]; + b5 = __m[2][2] * __m[3][3] - __m[2][3] * __m[3][2]; + + det = a0 * b5 - a1 * b4 + a2 * b3 + a3 * b2 - a4 * b1 + a5 * b0; + if (_FloatHardCompare(det, 0.0f)) + return false; + + + float inverse_m[4][4]; + + inverse_m[0][0] = +__m[1][1] * b5 - __m[1][2] * b4 + __m[1][3] * b3; + inverse_m[1][0] = -__m[1][0] * b5 + __m[1][2] * b2 + __m[1][3] * b1; + inverse_m[2][0] = +__m[1][0] * b4 - __m[1][1] * b2 + __m[1][3] * b0; + inverse_m[3][0] = -__m[1][0] * b3 + __m[1][1] * b1 - __m[1][2] * b0; + inverse_m[0][1] = -__m[0][1] * b5 + __m[0][2] * b4 - __m[0][3] * b3; + inverse_m[1][1] = +__m[0][0] * b5 - __m[0][2] * b2 + __m[0][3] * b1; + inverse_m[2][1] = -__m[0][0] * b4 + __m[0][1] * b2 - __m[0][3] * b0; + inverse_m[3][1] = +__m[0][0] * b3 - __m[0][1] * b1 + __m[0][2] * b0; + inverse_m[0][2] = +__m[3][1] * a5 - __m[3][2] * a4 + __m[3][3] * a3; + inverse_m[1][2] = -__m[3][0] * a5 + __m[3][2] * a2 - __m[3][3] * a1; + inverse_m[2][2] = +__m[3][0] * a4 - __m[3][1] * a2 + __m[3][3] * a0; + inverse_m[3][2] = -__m[3][0] * a3 + __m[3][1] * a1 - __m[3][2] * a0; + inverse_m[0][3] = -__m[2][1] * a5 + __m[2][2] * a4 - __m[2][3] * a3; + inverse_m[1][3] = +__m[2][0] * a5 - __m[2][2] * a2 + __m[2][3] * a1; + inverse_m[2][3] = -__m[2][0] * a4 + __m[2][1] * a2 - __m[2][3] * a0; + inverse_m[3][3] = +__m[2][0] * a3 - __m[2][1] * a1 + __m[2][2] * a0; + + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 4; j++) + inverse_m[j][i] /= det; + } + + memcpy(__m, inverse_m, sizeof(__m)); + __complexity = GenericMatrix; + + return true; +} + +void +_Matrix3Df::LoadIdentity(void) +{ + memcpy(__m, identityTransform, sizeof(__m)); + __complexity = IdentityMatrix; +} + +void +_Matrix3Df::Transpose(void) +{ + int i, j; + float tmp; + + for (i = 0; i < 4; i++) + { + for (j = i + 1; j < 4; j++) + { + tmp = __m[i][j]; + __m[i][j] = __m[j][i]; + __m[j][i] = tmp; + } + } + + __complexity = GenericMatrix; +} + +void +_Matrix3Df::Translate(float tx, float ty, float tz) +{ + if (__complexity == IdentityMatrix) + { + __m[3][0] = tx; + __m[3][1] = ty; + __m[3][2] = tz; + __complexity = TranslationMatrix; + } + else if (__complexity == TranslationMatrix) + { + __m[3][0] += tx; + __m[3][1] += ty; + __m[3][2] += tz; + } + else if (__complexity == ScaleMatrix) + { + __m[3][0] = __m[0][0] * tx; + __m[3][1] = __m[1][1] * ty; + __m[3][2] = __m[1][2] * tz; + __complexity = GenericMatrix; + } + else + { +#ifndef GEM_SIMD + __m[3][0] += (__m[0][0] * tx + __m[1][0] * ty + __m[2][0] * tz); + __m[3][1] += (__m[0][1] * tx + __m[1][1] * ty + __m[2][1] * tz); + __m[3][2] += (__m[0][2] * tx + __m[1][2] * ty + __m[2][2] * tz); + __m[3][3] += (__m[0][3] * tx + __m[1][3] * ty + __m[2][3] * tz); + __complexity = GenericMatrix; +#else + float32x4_t f4Dest; + + f4Dest = vld1q_f32(m_mtx.m[3]); + f4Dest = vmlaq_n_f32(f4Dest, vld1q_f32(m_mtx.m[0]), tx); + f4Dest = vmlaq_n_f32(f4Dest, vld1q_f32(m_mtx.m[1]), ty); + f4Dest = vmlaq_n_f32(f4Dest, vld1q_f32(m_mtx.m[2]), tz); + + vst1q_f32(m_mtx.m[3], f4Dest); +#endif + } +} + +void +_Matrix3Df::Scale(float sx, float sy, float sz) +{ +#ifndef GEM_SIMD + if (sx != 1.0f) + { + __m[0][0] *= sx; + __m[0][1] *= sx; + __m[0][2] *= sx; + __m[0][3] *= sx; + } + + if (sy != 1.0f) + { + __m[1][0] *= sy; + __m[1][1] *= sy; + __m[1][2] *= sy; + __m[1][3] *= sy; + } + + if (sz != 1.0f) + { + __m[2][0] *= sz; + __m[2][1] *= sz; + __m[2][2] *= sz; + __m[2][3] *= sz; + } + + if (__complexity == IdentityMatrix) + __complexity = ScaleMatrix; + else + __complexity = GenericMatrix; + +#else + vst1q_f32(m_mtx.m[0], vmulq_n_f32(vld1q_f32(m_mtx.m[0]), sx)); + vst1q_f32(m_mtx.m[1], vmulq_n_f32(vld1q_f32(m_mtx.m[1]), sy)); + vst1q_f32(m_mtx.m[2], vmulq_n_f32(vld1q_f32(m_mtx.m[2]), sz)); +#endif +} + +void +_Matrix3Df::Shear(float xy, float yz, float zx, float yx, float zy, float xz) +{ + _Matrix3Df ShearMatrix; + + // refer: http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q43 + + if (xy == 0.0f && yz == 0.0f && zx == 0.0f && + yx == 0.0f && zy == 0.0f && xz == 0.0f) + return; + + + memcpy(ShearMatrix.__m, identityTransform, sizeof(ShearMatrix.__m)); + + ShearMatrix.__m[0][1] = xy; + ShearMatrix.__m[0][2] = xz; + + ShearMatrix.__m[1][0] = yx; + ShearMatrix.__m[1][2] = yz; + + ShearMatrix.__m[2][0] = zx; + ShearMatrix.__m[2][1] = zy; + + ShearMatrix.__complexity = GenericMatrix; + + *this = *this * ShearMatrix; +} + +void +_Matrix3Df::Rotate(float angle, float x, float y, float z) +{ +#if 1 + if (angle == 0.0f) + return; + + // Rotation using quaternion + + angle = angle * M_PI / 180.0f; + + angle /= 2.0f; + float sinA = sinf(angle); + float cosA = cosf(angle); + float sinA2 = sinA * sinA; + + // normalize + float length = sqrtf(x * x + y * y + z * z); + if (length == 0.0f) + { + // bad vector, just use something reasonable +#if 0 + x = 0.0f; + y = 0.0f; + z = 1.0f; +#else + return; +#endif + } + else if (length != 1.0f) + { + x /= length; + y /= length; + z /= length; + } + + + float mat[4][4] = { {0.0f, }, }; + + // optimize case where axis is along major axis + if (x == 1.0f && y == 0.0f && z == 0.0f) + { + mat[0][0] = 1.0f; + mat[0][1] = 0.0f; + mat[0][2] = 0.0f; + mat[1][0] = 0.0f; + mat[1][1] = 1.0f - 2.0f * sinA2; + mat[1][2] = 2.0f * sinA * cosA; + mat[2][0] = 0.0f; + mat[2][1] = -2.0f * sinA * cosA; + mat[2][2] = 1.0f - 2.0f * sinA2; + mat[0][3] = mat[1][3] = mat[2][3] = 0.0f; + mat[3][0] = mat[3][1] = mat[3][2] = 0.0f; + mat[3][3] = 1.0f; + } + else if (x == 0.0f && y == 1.0f && z == 0.0f) + { + mat[0][0] = 1.0f - 2.0f * sinA2; + mat[0][1] = 0.0f; + mat[0][2] = -2.0f * sinA * cosA; + mat[1][0] = 0.0f; + mat[1][1] = 1.0f; + mat[1][2] = 0.0f; + mat[2][0] = 2.0f * sinA * cosA; + mat[2][1] = 0.0f; + mat[2][2] = 1.0f - 2.0f * sinA2; + mat[0][3] = mat[1][3] = mat[2][3] = 0.0f; + mat[3][0] = mat[3][1] = mat[3][2] = 0.0f; + mat[3][3] = 1.0f; + } + else if (x == 0.0f && y == 0.0f && z == 1.0f) + { + mat[0][0] = 1.0f - 2.0f * sinA2; + mat[0][1] = 2.0f * sinA * cosA; + mat[0][2] = 0.0f; + mat[1][0] = -2.0f * sinA * cosA; + mat[1][1] = 1.0f - 2.0f * sinA2; + mat[1][2] = 0.0f; + mat[2][0] = 0.0f; + mat[2][1] = 0.0f; + mat[2][2] = 1.0f; + mat[0][3] = mat[1][3] = mat[2][3] = 0.0f; + mat[3][0] = mat[3][1] = mat[3][2] = 0.0f; + mat[3][3] = 1.0f; + } + else + { + float x2 = x * x; + float y2 = y * y; + float z2 = z * z; + + mat[0][0] = 1.0f - 2.0f * (y2 + z2) * sinA2; + mat[0][1] = 2.0f * (x * y * sinA2 + z * sinA * cosA); + mat[0][2] = 2.0f * (x * z * sinA2 - y * sinA * cosA); + mat[1][0] = 2.0f * (y * x * sinA2 - z * sinA * cosA); + mat[1][1] = 1.0f - 2.0f * (z2 + x2) * sinA2; + mat[1][2] = 2.0f * (y * z * sinA2 + x * sinA * cosA); + mat[2][0] = 2.0f * (z * x * sinA2 + y * sinA * cosA); + mat[2][1] = 2.0f * (z * y * sinA2 - x * sinA * cosA); + mat[2][2] = 1.0f - 2.0f * (x2 + y2) * sinA2; + mat[0][3] = mat[1][3] = mat[2][3] = 0.0f; + mat[3][0] = mat[3][1] = mat[3][2] = 0.0f; + mat[3][3] = 1.0f; + } + + *this *= _Matrix3Df((const float*)mat); +#else + _Matrix3Df rotMat; + float sinAngle, cosAngle; + float mag; + + if (angle == 0.0f) + return; + + mag = sqrtf(x * x + y * y + z * z); + sinAngle = sinf(angle * PI / 180.0f); + cosAngle = cosf(angle * PI / 180.0f); + + if (mag > 0.0f) + { + float xx, yy, zz, xy, yz, zx, xs, ys, zs; + float oneMinusCos; + + x /= mag; + y /= mag; + z /= mag; + + xx = x * x; + yy = y * y; + zz = z * z; + xy = x * y; + yz = y * z; + zx = z * x; + xs = x * sinAngle; + ys = y * sinAngle; + zs = z * sinAngle; + oneMinusCos = 1.0f - cosAngle; + + rotMat.__m[0][0] = (oneMinusCos * xx) + cosAngle; + rotMat.__m[1][0] = (oneMinusCos * xy) - zs; + rotMat.__m[2][0] = (oneMinusCos * zx) + ys; + rotMat.__m[3][0] = 0.0f; + + rotMat.__m[0][1] = (oneMinusCos * xy) + zs; + rotMat.__m[1][1] = (oneMinusCos * yy) + cosAngle; + rotMat.__m[2][1] = (oneMinusCos * yz) - xs; + rotMat.__m[3][1] = 0.0f; + + rotMat.__m[0][2] = (oneMinusCos * zx) - ys; + rotMat.__m[1][2] = (oneMinusCos * yz) + xs; + rotMat.__m[2][2] = (oneMinusCos * zz) + cosAngle; + rotMat.__m[3][2] = 0.0f; + + rotMat.__m[0][3] = 0.0f; + rotMat.__m[1][3] = 0.0f; + rotMat.__m[2][3] = 0.0f; + rotMat.__m[3][3] = 1.0f; + + rotMat.__complexity = GenericMatrix; + + *this = *this * rotMat; + } +#endif +} + +void +_Matrix3Df::MakeOrthogonal(float left, float right, float bottom, float top, float n, float f) +{ + _Matrix3Df mat; + float w, h, d; + + memcpy(mat.__m, identityTransform, sizeof(mat.__m)); + + w = right - left; + h = top - bottom; + d = f - n; + + // CHECKME: + if (w == 0.0f) + w = ALMOST_ZERO_FLOAT; + if (h == 0.0f) + h = ALMOST_ZERO_FLOAT; + if (d == 0.0f) + d = ALMOST_ZERO_FLOAT; + + mat.__m[0][0] = 2.0f / w; + mat.__m[1][1] = 2.0f / h; + mat.__m[2][2] = -2.0f / d; + + mat.__m[3][0] = -(right + left) / w; + mat.__m[3][1] = -(bottom + top) / h; + mat.__m[3][2] = -(n + f) / d; + mat.__m[3][3] = 1.0f; + + mat.__complexity = GenericMatrix; + + *this *= mat; +} + +void +_Matrix3Df::MakeFrustum(float left, float right, float bottom, float top, float nearZ, float farZ) +{ + _Matrix3Df mat; + float w, h, d; + + memcpy(mat.__m, identityTransform, sizeof(mat.__m)); + + w = right - left; + h = top - bottom; + d = farZ - nearZ; + + // CHECKME: + if (w == 0.0f) + w = ALMOST_ZERO_FLOAT; + if (h == 0.0f) + h = ALMOST_ZERO_FLOAT; + if (d == 0.0f) + d = ALMOST_ZERO_FLOAT; + + mat.__m[0][0] = 2.0f * nearZ / w; + mat.__m[1][1] = 2.0f * nearZ / h; + mat.__m[2][0] = (right + left) / w; + mat.__m[2][1] = (top + bottom) / h; + mat.__m[2][2] = -(farZ + nearZ) / d; + mat.__m[2][3] = -1.0f; + mat.__m[3][2] = -2.0f * farZ * nearZ / d; + mat.__m[3][3] = 0.0f; + + mat.__complexity = GenericMatrix; + + *this *= mat; +} + +void +_Matrix3Df::MakePerspective(float fovy, float aspect, float nearZ, float farZ) +{ + float frustumW, frustumH; + + frustumH = tanf(fovy / 360.0f * PI) * nearZ; + frustumW = frustumH * aspect; + + MakeFrustum(-frustumW, frustumW, -frustumH, frustumH, nearZ, farZ); +} + +void +_Matrix3Df::MakeLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) +{ + _Matrix3Df mat; + float x[3], y[3], z[3]; + float mag; + + // Make rotation matrix + // Z vector + z[0] = eyeX - centerX; + z[1] = eyeY - centerY; + z[2] = eyeZ - centerZ; + + mag = sqrtf(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]); + if (mag) + { + // mpichler, 19950515 + z[0] /= mag; + z[1] /= mag; + z[2] /= mag; + } + + // Y vector + y[0] = upX; + y[1] = upY; + y[2] = upZ; + + // X vector = Y cross Z + x[0] = y[1] * z[2] - y[2] * z[1]; + x[1] = -y[0] * z[2] + y[2] * z[0]; + x[2] = y[0] * z[1] - y[1] * z[0]; + + // Recompute Y = Z cross X + y[0] = z[1] * x[2] - z[2] * x[1]; + y[1] = -z[0] * x[2] + z[2] * x[0]; + y[2] = z[0] * x[1] - z[1] * x[0]; + + // mpichler, 19950515 + // cross product gives area of parallelogram, which is < 1.0 for + // non-perpendicular unit-length vectors; so normalize x, y here + mag = sqrtf(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]); + if (mag) + { + x[0] /= mag; + x[1] /= mag; + x[2] /= mag; + } + + mag = sqrtf(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]); + if (mag) + { + y[0] /= mag; + y[1] /= mag; + y[2] /= mag; + } + + mat.__m[0][0] = x[0]; + mat.__m[1][0] = x[1]; + mat.__m[2][0] = x[2]; + mat.__m[3][0] = 0.0f; + mat.__m[0][1] = y[0]; + mat.__m[1][1] = y[1]; + mat.__m[2][1] = y[2]; + mat.__m[3][1] = 0.0f; + mat.__m[0][2] = z[0]; + mat.__m[1][2] = z[1]; + mat.__m[2][2] = z[2]; + mat.__m[3][2] = 0.0f; + + mat.__complexity = GenericMatrix; + + *this *= mat; + + // Translate Eye to Origin + Translate(-eyeX, -eyeY, -eyeZ); +} + +_Matrix3Df& +_Matrix3Df::MakeTransformAtAnchor(float x, float y, float z) +{ + *this = _Matrix3DfTr(x, y, z) * (*this) * _Matrix3DfTr(-x, -y, -z); + + return *this; +} + +float +_Matrix3Df::Normalize(void) +{ + float w; + + w = __m[3][3]; + if (w == 1.0f || w == 0.0f) + return w; + + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 4; j++) + __m[i][j] /= w; + } + + __complexity = GenericMatrix; + + return w; +} + +void +_Matrix3Df::Transform(float* pX, float* pY, float* pZ) const +{ +#ifndef GEM_SIMD + float x, y, z, w; + + x = *pX; + y = *pY; + z = *pZ; + + if (__complexity == IdentityMatrix) + { + return; + } + else if (__complexity == TranslationMatrix) + { + *pX += __m[3][0]; + *pY += __m[3][1]; + *pZ += __m[3][2]; + } + else if (__complexity == ScaleMatrix) + { + *pX = __m[0][0] * x; + *pY = __m[1][1] * y; + *pZ = __m[2][2] * z; + } + else + { + *pX = (__m[0][0] * x) + (__m[1][0] * y) + (__m[2][0] * z) + (__m[3][0]); + *pY = (__m[0][1] * x) + (__m[1][1] * y) + (__m[2][1] * z) + (__m[3][1]); + *pZ = (__m[0][2] * x) + (__m[1][2] * y) + (__m[2][2] * z) + (__m[3][2]); + w = (__m[0][3] * x) + (__m[1][3] * y) + (__m[2][3] * z) + (__m[3][3]); + + // TODO: what if w == 0 ???? + + if (w != 1.0f) + { + *pX /= w; + *pY /= w; + *pZ /= w; + } + } +#else + float pVector[4]; + float32x4_t f4Dest; + + f4Dest = vmulq_n_f32(vld1q_f32(m_mtx.m[0]), *pX); + f4Dest = vmlaq_n_f32(f4Dest, vld1q_f32(m_mtx.m[1]), *pY); + f4Dest = vmlaq_n_f32(f4Dest, vld1q_f32(m_mtx.m[2]), *pZ); + f4Dest = vmlaq_n_f32(f4Dest, vld1q_f32(m_mtx.m[3]), 1.0f); + + vst1q_f32(pVector, f4Dest); + + *pX = pVector[0] / pVector[3]; + *pY = pVector[1] / pVector[3]; + *pZ = pVector[2] / pVector[3]; +#endif + + + // CHECKME: + // Needless to check 4th row ?? +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/FUi_ModalLoopManager.cpp b/src/ui/FUi_ModalLoopManager.cpp new file mode 100644 index 0000000..1b0a9a3 --- /dev/null +++ b/src/ui/FUi_ModalLoopManager.cpp @@ -0,0 +1,245 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ModalLoopManager.cpp + * @brief This is the implementation file for the _ModalLoopManager class. + */ + +#include +#include +#include +#include +#include "FUi_ModalLoopManager.h" +#include "FUi_EcoreEvasMgr.h" + +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui +{ + +_ModalLoopManager::_ModalLoopManager(void) + : __pTimerInfoList(null) + , __nestedMainLoop(0) + , __lastExitCode(-1) +{ + __pTimerInfoList = new (std::nothrow) TimerInfoList; + SysAssert(__pTimerInfoList); + __pTimerInfoList->Construct(); +} + +_ModalLoopManager::~_ModalLoopManager(void) +{ + if (__pTimerInfoList) + { + _TimerInfo timerInfo; + const int count = __pTimerInfoList->GetCount(); + for (int i = 0; i < count; i++) + { + timerInfo.pTimer = null; + __pTimerInfoList->GetAt(i, timerInfo); + if (timerInfo.pTimer) + { + delete timerInfo.pTimer; + } + } + __pTimerInfoList->RemoveAll(); + delete __pTimerInfoList; + __pTimerInfoList = null; + } + + if (__nestedMainLoop > 0) + { + SysLog(NID_UI, "[ModalLoopManager] The count of nested main loops is: %d", __nestedMainLoop); + } +} + +int +_ModalLoopManager::BeginMainLoop(void) +{ + __nestedMainLoop++; + ::GetEcoreEvasMgr()->BeginMainLoop(); + + return __nestedMainLoop; +} + +int +_ModalLoopManager::BeginMainLoop(unsigned long timeOut, int exitCode) +{ + result r = E_SUCCESS; + Timer* pTimer = null; + + if (timeOut > 0l) + { + pTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI, pTimer != null, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create Timer."); + + r = pTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTimer->Start(timeOut); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + _TimerInfo timerInfo; + timerInfo.loopId = __nestedMainLoop + 1; + timerInfo.pTimer = pTimer; + timerInfo.exitCode = exitCode; + timerInfo.expired = false; + r = __pTimerInfoList->Add(timerInfo); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return BeginMainLoop(); + +CATCH: + delete pTimer; + return -1; +} + +int +_ModalLoopManager::EndMainLoop(int exitCode, bool endAllLoops) +{ + if (__nestedMainLoop == 0) + { + return __nestedMainLoop; + } + + __lastExitCode = exitCode; + + _TimerInfo timerInfo; + int timerCount = 0; + int loopCount = endAllLoops ? __nestedMainLoop : 1; + while (loopCount--) + { + timerCount = __pTimerInfoList->GetCount(); + if (timerCount > 0) + { + __pTimerInfoList->GetAt(timerCount - 1, timerInfo); + if (timerInfo.loopId == __nestedMainLoop) + { + timerInfo.pTimer->Cancel(); + delete timerInfo.pTimer; + __pTimerInfoList->RemoveAt(timerCount - 1); + } + } + timerCount = __pTimerInfoList->GetCount(); + if (timerCount > 0) + { + __pTimerInfoList->GetAt(timerCount - 1, timerInfo); + if ((timerInfo.loopId == __nestedMainLoop - 1) && (timerInfo.expired == true)) + { + __lastExitCode = -2; + } + } + ::GetEcoreEvasMgr()->EndMainLoop(); + __nestedMainLoop--; + } + + return __nestedMainLoop; +} + +int +_ModalLoopManager::GetLastExitCode(void) +{ + return __lastExitCode; +} + +void +_ModalLoopManager::OnTimerExpired(Timer& timer) +{ + const int count = __pTimerInfoList->GetCount(); + int pos = -1; + int i = count -1; + _TimerInfo timerInfo; + + while (i >= 0) + { + __pTimerInfoList->GetAt(i, timerInfo); + + if (timerInfo.pTimer == &timer) + { + pos = timerInfo.loopId; + timerInfo.expired = true; + __pTimerInfoList->SetAt(timerInfo, i); + break; + } + i--; + } + + if (pos == __nestedMainLoop) + { + _ModalLoopManager::GetInstance()->EndMainLoop(timerInfo.exitCode, false); + } +} + +_ModalLoopManager* _ModalLoopManager::__pInstance = null; + +void +_ModalLoopManager::Initialize(void) +{ + static _ModalLoopManager instance; + __pInstance = &instance; +} + +_ModalLoopManager* +_ModalLoopManager::GetInstance(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (!__pInstance) + { + pthread_once(&once_block, Initialize); + } + + return __pInstance; +} + +_ModalLoopManager::_TimerInfo::_TimerInfo(void) + : loopId(-1) + , pTimer(null) + , exitCode(-1) + , expired(false) +{ +} + +_ModalLoopManager::_TimerInfo::~_TimerInfo(void) +{ +} + +bool +_ModalLoopManager::_TimerInfo::operator==(const _ModalLoopManager::_TimerInfo& rhs) const +{ + return ((loopId == rhs.loopId) && (pTimer == rhs.pTimer) && (exitCode == rhs.exitCode) && (expired == rhs.expired)); +} + +bool _ModalLoopManager::_TimerInfo::operator!=(const _ModalLoopManager::_TimerInfo& rhs) const +{ + return ((loopId != rhs.loopId) || (pTimer != rhs.pTimer) || (exitCode != rhs.exitCode) || (expired != rhs.expired)); +} + +_ModalLoopManager::_TimerInfo& +_ModalLoopManager::_TimerInfo::operator=(const _ModalLoopManager::_TimerInfo& rhs) +{ + loopId = rhs.loopId; + pTimer = rhs.pTimer; + exitCode = rhs.exitCode; + expired = rhs.expired; + + return *this; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_OrientationAgent.cpp b/src/ui/FUi_OrientationAgent.cpp new file mode 100644 index 0000000..3a979c2 --- /dev/null +++ b/src/ui/FUi_OrientationAgent.cpp @@ -0,0 +1,260 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_OrientationAgent.cpp + * @brief This is the implementation file for the _OrientationAgent class. + */ +#include +#include "FUi_OrientationAgent.h" +#include "FUi_ControlManager.h" +#include "FUi_ControlImplManager.h" +#include "FUi_PublicOrientationEvent.h" +#include "FUi_ControlImpl.h" +#include "FUi_Window.h" +#include "FUiCtrl_FormImpl.h" +#include "FUiCtrl_FrameImpl.h" +#include "FUiCtrl_Frame.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EcoreEvas.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { + +_OrientationAgent* +_OrientationAgent::CreateInstanceN(Control& publicControl) +{ + _OrientationAgent* pAgent = new (std::nothrow) _OrientationAgent(publicControl); + SysTryReturn(NID_UI, pAgent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pAgent; + +CATCH: + delete pAgent; + return null; +} + +_OrientationAgent::_OrientationAgent(Control& publicControl) + : __publicControl(publicControl) + , __pPublicEvent(null) + , __mode(ORIENTATION_PORTRAIT) + , __status(ORIENTATION_STATUS_PORTRAIT) + , __firePublicEvent(false) + , __statusChanged(false) + , __updateStatus(true) +{ + _PublicOrientationEvent* pPublicEvent = _PublicOrientationEvent::CreateInstanceN(publicControl); + + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, pPublicEvent, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicEvent = pPublicEvent; + + SetLastResult(E_SUCCESS); +} + +_OrientationAgent::~_OrientationAgent(void) +{ + if (__pPublicEvent) + { + delete __pPublicEvent; + __pPublicEvent = null; + } +} + +void +_OrientationAgent::AddListener(IOrientationEventListener& listener) +{ + result r = __pPublicEvent->AddListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} + +void +_OrientationAgent::RemoveListener(IOrientationEventListener& listener) +{ + result r = __pPublicEvent->RemoveListener(listener); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} + +Orientation +_OrientationAgent::GetMode(void) const +{ + return __mode; +} + +OrientationStatus +_OrientationAgent::GetStatus(void) const +{ + return __status; +} + +void +_OrientationAgent::SetMode(Orientation mode) +{ + SysTryReturnVoidResult(NID_UI, mode != ORIENTATION_NONE, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + + SetLastResult(E_SUCCESS); + + if (__mode == mode) + { + return; + } + + __mode = mode; + Update(); +} + +void +_OrientationAgent::Update(bool draw) +{ + _ControlImplManager* pImplManager = _ControlImplManager::GetInstance(); + SysAssert(pImplManager); + + _ControlImpl* pImpl = _ControlImpl::GetInstance(__publicControl); + if (!pImpl) + { + return; + } + + OrientationStatus status = pImplManager->GetOrientationStatus(__mode); + + if (__updateStatus == true) + { + __statusChanged = false; + if (__status != status) + { + __statusChanged = true; + __updateStatus = false; + } + } + + __status = status; + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + if (!pEcoreEvas) + { + return; + } + + pEcoreEvas->AllowSetWindowBounds(false); + FireEvent(status); + pEcoreEvas->AllowSetWindowBounds(true); + + // For the form to be made by Ui-Builder + if ((draw == true) && (__statusChanged == true)) + { + _ControlOrientation coreOrientation = + (status == ORIENTATION_STATUS_PORTRAIT || status == ORIENTATION_STATUS_PORTRAIT_REVERSE) ? + _CONTROL_ORIENTATION_PORTRAIT : _CONTROL_ORIENTATION_LANDSCAPE; + + Rectangle temp; + bool exist = pImpl->GetBuilderBounds(coreOrientation, temp); + if (exist) + { + pImpl->Invalidate(true); + } + } + + // Despite not changing status, it needs to rotate screen. +#if !defined(MULTI_WINDOW) + pImplManager->RotateScreen(status); +#else + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(__publicControl); + pImplManager->RotateScreen(pControlImpl, status); +#endif +} + +void +_OrientationAgent::FireOrientationEvent(void) +{ + if (__firePublicEvent) + { + return; + } + + __firePublicEvent = true; + + if (__statusChanged) + { + IEventArg* pArg = _PublicOrientationEvent::CreateOrientationEventArgN(*__pPublicEvent->GetSource(), __status); + __pPublicEvent->Fire(*pArg); + + __updateStatus = true; + } +} + +void +_OrientationAgent::FireEvent(OrientationStatus status) +{ + ClearLastResult(); + + _ControlManager* pCoreManager = _ControlManager::GetInstance(); + SysAssert(pCoreManager); + + _ControlImpl* pImpl = _ControlImpl::GetInstance(__publicControl); + if (!pImpl) + { + return; + } + + _ControlOrientation coreOrientation = + (status == ORIENTATION_STATUS_PORTRAIT || status == ORIENTATION_STATUS_PORTRAIT_REVERSE) ? + _CONTROL_ORIENTATION_PORTRAIT : _CONTROL_ORIENTATION_LANDSCAPE; + + _ControlImplManager* pImplManager = _ControlImplManager::GetInstance(); + SysAssert(pImplManager); + + // Core + pCoreManager->SetOrientation(coreOrientation); + pImplManager->SetOrientationStatus(status); + pImpl->GetCore().ChangeLayout(coreOrientation); + + // Ownee + int owneeCount = pImpl->GetCore().GetOwneeCount(); + for (int i = 0; i < owneeCount; i++) + { + _Window* pOwnee = pImpl->GetCore().GetOwnee(i); + + if (pOwnee) + { + pOwnee->ChangeLayout(coreOrientation); + } + } + + // Public + if (__firePublicEvent && __statusChanged) + { + IEventArg* pArg = _PublicOrientationEvent::CreateOrientationEventArgN(*__pPublicEvent->GetSource(), status); + __pPublicEvent->Fire(*pArg); + + __updateStatus = true; + } +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_OrientationAgent.h b/src/ui/FUi_OrientationAgent.h new file mode 100644 index 0000000..0917e89 --- /dev/null +++ b/src/ui/FUi_OrientationAgent.h @@ -0,0 +1,70 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_OrientationAgent.h + * @brief This is the header file for the _OrientationAgent class. + * + * This header file contains the declarations of the %_OrientationAgent class. + */ +#ifndef _FUI_INTERNAL_ORIENTATION_AGENT_H_ +#define _FUI_INTERNAL_ORIENTATION_AGENT_H_ + +#include +#include "FUi_Types.h" + +namespace Tizen { namespace Ui { + +class _PublicOrientationEvent; + +class _OrientationAgent +{ +public: + static _OrientationAgent* CreateInstanceN(Control& publicControl); + ~_OrientationAgent(void); + + void AddListener(IOrientationEventListener& listener); + void RemoveListener(IOrientationEventListener& listener); + + Orientation GetMode(void) const; + OrientationStatus GetStatus(void) const; + + void SetMode(Orientation orientation); + void Update(bool draw = false); + + void FireOrientationEvent(void); + +private: + void FireEvent(OrientationStatus status); + + _OrientationAgent(Control& publicControl); + + _OrientationAgent(const _OrientationAgent& rhs); + _OrientationAgent& operator =(const _OrientationAgent& rhs); + +private: + Control& __publicControl; + _PublicOrientationEvent* __pPublicEvent; + Orientation __mode; + OrientationStatus __status; + bool __firePublicEvent; + bool __statusChanged; + bool __updateStatus; +}; // _OrientationAgent + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_ORIENTATION_AGENT_H_ \ No newline at end of file diff --git a/src/ui/FUi_PropertyBase.cpp b/src/ui/FUi_PropertyBase.cpp new file mode 100644 index 0000000..9473b9c --- /dev/null +++ b/src/ui/FUi_PropertyBase.cpp @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_PropertyBase.cpp + * @brief This is the implementation file for _PropertyBase class. + */ + +#include +#include +#include "FUi_PropertyBase.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui +{ + +// PropertyBase class +_PropertyBase::_PropertyBase(void) + : __pPropertyChangeEventListener(null) +{ +} + +_PropertyBase::~_PropertyBase(void) +{ + __pPropertyChangeEventListener = null; +} + +result +_PropertyBase::SetProperty(const String& name, const Variant& value) +{ + SetLastResult(E_OBJ_NOT_FOUND); + return E_KEY_NOT_FOUND; +} + +Variant +_PropertyBase::GetProperty(const String& name) const +{ + SetLastResult(E_KEY_NOT_FOUND); + return Variant::NULL_VARIANT; +} + +bool +_PropertyBase::IsPropertyChangeEventListenerAdded(void) const +{ + return (__pPropertyChangeEventListener != null); +} + +result +_PropertyBase::AddPropertyChangeEventListener(const Tizen::Ui::_IPropertyChangeEventListener& listener) +{ + return SetPropertyChangeEventListener(&listener); +} + +result +_PropertyBase::RemovePropertyChangeEventListener(const Tizen::Ui::_IPropertyChangeEventListener& listener) +{ + ClearLastResult(); + __pPropertyChangeEventListener = null; + + return E_SUCCESS; +} + +result +_PropertyBase::SetPropertyChangeEventListener(const Tizen::Ui::_IPropertyChangeEventListener* pListener) +{ + ClearLastResult(); + + __pPropertyChangeEventListener = const_cast<_IPropertyChangeEventListener*>(pListener); + + return E_SUCCESS; +} + +bool +_PropertyBase::FirePropertyEvent(const Tizen::Ui::_PropertyBase& source, const String& name, const Variant& oldValue, const Variant& newValue, bool isChangedEvent) +{ + ClearLastResult(); + + if (!__pPropertyChangeEventListener) + { + return true; + } + + if (isChangedEvent) + { + __pPropertyChangeEventListener->OnPropertyChanged(const_cast<_PropertyBase&>(source), name, oldValue, newValue); + } + else + { + __pPropertyChangeEventListener->OnPropertyChanging(const_cast<_PropertyBase&>(source), name, oldValue, newValue); + } + + return true; +} + +} } //Tizen::Ui + diff --git a/src/ui/FUi_PropertyUtils.cpp b/src/ui/FUi_PropertyUtils.cpp new file mode 100644 index 0000000..73951d8 --- /dev/null +++ b/src/ui/FUi_PropertyUtils.cpp @@ -0,0 +1,172 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_PropertyUtils.cpp + * @brief This is the implementation file for _PropertyUtils class. + */ + +#include +#include +#include +#include "FUi_PropertyUtils.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui +{ + +/** + * @class _StringComparer + * @brief We implemented new custom string-comparer for performance. + * @since 2.0 + * + */ + +// _StringComparer class +_StringComparer::_StringComparer(void) +{ + +} + +_StringComparer::~_StringComparer(void) +{ + +} + +result +_StringComparer::Compare(const Object& obj1, const Object& obj2, int& cmp) const +{ + const String* pString1 = static_cast(&obj1); + const String* pString2 = static_cast(&obj2); + + // dirty optimization. HaspMap do not care of the sign. It is interested only in zero or not. + if (*pString1 == *pString2) + { + cmp = 0; + } + else + { + cmp = -1; + } + + return E_SUCCESS; +} + +// _StringHashProvider class +_StringHashProvider::_StringHashProvider(void) +{ + +} + +_StringHashProvider::~_StringHashProvider(void) +{ + +} + +int +_StringHashProvider::GetHashCode(const Object& obj) const +{ + return obj.GetHashCode(); +} + +// _PropertyUtils class +_PropertyUtils::_PropertyUtils(void) + : __pStringComparer(null) + , __pStringHashProvider(null) +{ + +} + +_PropertyUtils::~_PropertyUtils(void) +{ + if (__pStringComparer) + { + delete __pStringComparer; + } + + if (__pStringHashProvider) + { + delete __pStringHashProvider; + } +} + +_PropertyUtils* +_PropertyUtils::GetInstance(void) +{ +#if 0 + static _PropertyUtils* pPropertyUtils = null; + result r = E_SUCCESS; + if (pPropertyUtils == null) + { + pPropertyUtils = new (std::nothrow) _PropertyUtils; + SysTryReturn(NID_UI, pPropertyUtils != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create pPropertyUtils."); + + r = pPropertyUtils->Construct(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to construct pPropertyUtils."); + } + + return pPropertyUtils; +#else + static _PropertyUtils propertyUtils; + static bool initialized = false; + + if (!initialized) + { + result r = propertyUtils.Construct(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to construct pPropertyUtils."); + + initialized = true; + } + + return &propertyUtils; +#endif +} + +const _StringComparer* +_PropertyUtils::GetStringComparer() const +{ + return __pStringComparer; +} + +const _StringHashProvider* +_PropertyUtils::GetStringHashProvider() const +{ + return __pStringHashProvider; +} + +result +_PropertyUtils::Construct(void) +{ + result r = E_SUCCESS; + + if (!__pStringComparer) + { + __pStringComparer = new (std::nothrow) _StringComparer; + } + SysTryReturn(NID_UI, __pStringComparer != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _StringComparer."); + + if (!__pStringHashProvider) + { + __pStringHashProvider = new (std::nothrow) _StringHashProvider; + } + SysTryReturn(NID_UI, __pStringHashProvider != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _StringHashProvider."); + + return r; +} + +} } //Tizen::Ui + diff --git a/src/ui/FUi_PublicOrientationEvent.cpp b/src/ui/FUi_PublicOrientationEvent.cpp new file mode 100644 index 0000000..3cecfa2 --- /dev/null +++ b/src/ui/FUi_PublicOrientationEvent.cpp @@ -0,0 +1,149 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_PublicOrientationEvent.cpp + * @brief This is the implementation for the _PublicOrientationEvent class. + * @version 1.0 + */ +#include +#include +#include +#include "FUi_PublicOrientationEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui +{ +/** + * @class _PublicOrientationEventArg + * @brief This class is used as the argument to orientation event listener. + * + * This class is used as the argument to orientation event listener. When an orientation event is generated + * (such as when a button is pressed) the OrientationEvent calls OrientationEventListener's OnOrientationPerformed + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the orientation ID. + */ +class _PublicOrientationEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +public: + _PublicOrientationEventArg(const Control& source, OrientationStatus orientationStatus); + + virtual ~_PublicOrientationEventArg(void); + + const Control* GetSource(void) const; + int GetOrientationStatus(void) const; + +private: + _PublicOrientationEventArg(const _PublicOrientationEventArg& rhs); + _PublicOrientationEventArg& operator =(const _PublicOrientationEventArg& rhs); + +private: + Control* __pSource; + OrientationStatus __orientationStatus; +}; // _PublicOrientationEventArg + +_PublicOrientationEventArg::_PublicOrientationEventArg(const Control& source, OrientationStatus orientationStatus) + : __pSource(const_cast (&source)) + , __orientationStatus(orientationStatus) +{ +} + +_PublicOrientationEventArg::~_PublicOrientationEventArg(void) +{ +} + +const Control* +_PublicOrientationEventArg::GetSource(void) const +{ + return __pSource; +} + +int +_PublicOrientationEventArg::GetOrientationStatus(void) const +{ + return __orientationStatus; +} + +_PublicOrientationEvent* +_PublicOrientationEvent::CreateInstanceN(const Control& source) +{ + _PublicOrientationEvent* pPublicOrientationEvent = new (std::nothrow) _PublicOrientationEvent(source); + SysTryReturn(NID_UI, pPublicOrientationEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pPublicOrientationEvent; + +CATCH: + delete pPublicOrientationEvent; + return null; +} + +IEventArg* +_PublicOrientationEvent::CreateOrientationEventArgN(const Control& source, OrientationStatus orientationStatus) +{ + _PublicOrientationEventArg* pEventArg = new (std::nothrow) _PublicOrientationEventArg(source, orientationStatus); + SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + SetLastResult(E_SUCCESS); + + return pEventArg; +} + +_PublicOrientationEvent::~_PublicOrientationEvent(void) +{ +} + +const Control* +_PublicOrientationEvent::GetSource(void) const +{ + return __pSource; +} + +void +_PublicOrientationEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + IOrientationEventListener* pEventListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI, pEventListener, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + + const _PublicOrientationEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI, pArg, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + + pEventListener->OnOrientationChanged(*__pSource, (OrientationStatus)(pArg->GetOrientationStatus())); + + SetLastResult(E_SUCCESS); +} + +_PublicOrientationEvent::_PublicOrientationEvent(const Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSource = &source; + + SetLastResult(E_SUCCESS); +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_RelativeLayoutImpl.cpp b/src/ui/FUi_RelativeLayoutImpl.cpp new file mode 100644 index 0000000..67d4f9e --- /dev/null +++ b/src/ui/FUi_RelativeLayoutImpl.cpp @@ -0,0 +1,324 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_RelativeLayoutImpl.cpp + * @brief This is the implementation file for _RelativeLayoutImpl class. + * + * This file contains the implementation of _RelativeLayoutImpl class. + */ + +#include "FUi_RelativeLayoutImpl.h" + +namespace Tizen { namespace Ui +{ + +namespace +{ + +_Layout::RelativeLayoutEdge +ConvertEnum(CenterAlignmentType var) +{ + switch (var) + { + case CENTER_ALIGN_HORIZONTAL: + return _Layout::EDGE_HCENTER; + + case CENTER_ALIGN_VERTICAL: + return _Layout::EDGE_VCENTER; + + default: + return _Layout::EDGE_NONE; + } +} + +_Layout::RelativeLayoutEdge +ConvertEnum(RectangleEdgeType var) +{ + switch (var) + { + case RECT_EDGE_LEFT: + return _Layout::EDGE_LEFT; + + case RECT_EDGE_RIGHT: + return _Layout::EDGE_RIGHT; + + case RECT_EDGE_TOP: + return _Layout::EDGE_TOP; + + case RECT_EDGE_BOTTOM: + return _Layout::EDGE_BOTTOM; + + default: + return _Layout::EDGE_NONE; + } +} + +} + +// _RelativelayoutImpl implementation +_RelativeLayoutImpl::_RelativeLayoutImpl(RelativeLayout* pPublicLayout, _Layout::RelativeLayout* pCoreLayout) + : _LayoutImpl(pPublicLayout, pCoreLayout) +{ +} + +_RelativeLayoutImpl::~_RelativeLayoutImpl(void) +{ +} + +Tizen::Ui::LayoutType +_RelativeLayoutImpl::GetLayoutType(void) const +{ + return LAYOUT_RELATIVE; +} + +_RelativeLayoutImpl* +_RelativeLayoutImpl::CreateRelativeLayoutImplN(RelativeLayout* pPublicLayout) +{ + ClearLastResult(); + + _Layout::RelativeLayout* pCoreLayout = null; + _RelativeLayoutImpl* pImplLayout = null; + result r = E_SUCCESS; + + pCoreLayout = _Layout::RelativeLayout::CreateRelativeLayoutN(); + r = GetLastResult(); + SysTryReturn(NID_UI, pCoreLayout != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImplLayout = new (std::nothrow) _RelativeLayoutImpl(pPublicLayout, pCoreLayout); + r = CheckConstruction(pCoreLayout, pImplLayout); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImplLayout; +} + +const char* +_RelativeLayoutImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::RelativeLayout"; +} + +const RelativeLayout& +_RelativeLayoutImpl::GetPublic(void) const +{ + return static_cast (_LayoutImpl::GetPublic()); +} + +RelativeLayout& +_RelativeLayoutImpl::GetPublic(void) +{ + return static_cast (_LayoutImpl::GetPublic()); +} + +const _Layout::RelativeLayout& +_RelativeLayoutImpl::GetCore(void) const +{ + return static_cast (_LayoutImpl::GetCore()); +} + +_Layout::RelativeLayout& +_RelativeLayoutImpl::GetCore(void) +{ + return static_cast <_Layout::RelativeLayout&>(_LayoutImpl::GetCore()); +} + +const _RelativeLayoutImpl* +_RelativeLayoutImpl::GetInstance(const RelativeLayout& layout) +{ + return static_cast(_LayoutImpl::GetInstance(layout)); +} + +_RelativeLayoutImpl* +_RelativeLayoutImpl::GetInstance(RelativeLayout& layout) +{ + return static_cast<_RelativeLayoutImpl*>(_LayoutImpl::GetInstance(layout)); +} + +result +_RelativeLayoutImpl::SetCenterAligned(_ControlImpl& control, CenterAlignmentType alignment) +{ + ClearLastResult(); + + _Layout::LayoutItem& layoutItem = control.GetLayoutContainer(); + + _Layout::RelativeLayoutEdge edge = ConvertEnum(alignment); + SysTryReturn(NID_UI, edge != _Layout::EDGE_NONE, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The rectangle edge is invalid argument."); + + result r = GetCore().SetRelation(layoutItem, edge); + + return r; +} + +result +_RelativeLayoutImpl::SetRelation(_ControlImpl& childControl, _ControlImpl& targetControl, RectangleEdgeRelation edgeRelation) +{ + ClearLastResult(); + + _Layout::LayoutItem& childItem = childControl.GetLayoutContainer(); + _Layout::LayoutItem& targetItem = targetControl.GetLayoutContainer(); + + result r = E_SUCCESS; + _Layout::RelativeLayoutEdge sourceEdge; + _Layout::RelativeLayoutEdge targetEdge; + switch (edgeRelation) + { + case RECT_EDGE_RELATION_LEFT_TO_LEFT: + sourceEdge = _Layout::EDGE_LEFT; + targetEdge = _Layout::EDGE_LEFT; + break; + + case RECT_EDGE_RELATION_LEFT_TO_RIGHT: + sourceEdge = _Layout::EDGE_LEFT; + targetEdge = _Layout::EDGE_RIGHT; + break; + + case RECT_EDGE_RELATION_RIGHT_TO_RIGHT: + sourceEdge = _Layout::EDGE_RIGHT; + targetEdge = _Layout::EDGE_RIGHT; + break; + + case RECT_EDGE_RELATION_RIGHT_TO_LEFT: + sourceEdge = _Layout::EDGE_RIGHT; + targetEdge = _Layout::EDGE_LEFT; + break; + + case RECT_EDGE_RELATION_TOP_TO_TOP: + sourceEdge = _Layout::EDGE_TOP; + targetEdge = _Layout::EDGE_TOP; + break; + + case RECT_EDGE_RELATION_TOP_TO_BOTTOM: + sourceEdge = _Layout::EDGE_TOP; + targetEdge = _Layout::EDGE_BOTTOM; + break; + + case RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM: + sourceEdge = _Layout::EDGE_BOTTOM; + targetEdge = _Layout::EDGE_BOTTOM; + break; + + case RECT_EDGE_RELATION_BOTTOM_TO_TOP: + sourceEdge = _Layout::EDGE_BOTTOM; + targetEdge = _Layout::EDGE_TOP; + break; + + default: + //SysAssert(false); + SysTryReturn(NID_UI, false, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The rectangle edge is invalid argument."); + break; + } + + r = GetCore().SetRelation(childItem, sourceEdge, &targetItem, targetEdge); + + return r; +} + +result +_RelativeLayoutImpl::ResetCenterAligned(_ControlImpl& control, CenterAlignmentType alignment) +{ + ClearLastResult(); + + _Layout::LayoutItem& layoutItem = control.GetLayoutContainer(); + + _Layout::RelativeLayoutEdge edge = ConvertEnum(alignment); + SysTryReturn(NID_UI, edge != _Layout::EDGE_NONE, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The rectangle edge is invalid argument."); + + result r = GetCore().UnsetRelation(layoutItem, edge); + + return r; +} + +result +_RelativeLayoutImpl::ResetRelation(_ControlImpl& control, RectangleEdgeType edgeType) +{ + ClearLastResult(); + + _Layout::LayoutItem& layoutItem = control.GetLayoutContainer(); + + _Layout::RelativeLayoutEdge edge = ConvertEnum(edgeType); + SysTryReturn(NID_UI, edge != _Layout::EDGE_NONE, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The rectangle edge is invalid argument."); + + result r = GetCore().UnsetRelation(layoutItem, edge); + + return r; +} + +result +_RelativeLayoutImpl::SetHeight(_ControlImpl& control, int height) +{ + ClearLastResult(); + + result r = SetVerticalFitPolicy(control, FIT_POLICY_FIXED); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Layout::LayoutRect rect; + r = GetItemBaseRect(control, rect); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + rect.h = height; + r = SetItemBaseRect(control, rect); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_RelativeLayoutImpl::SetWidth(_ControlImpl& control, int width) +{ + ClearLastResult(); + + result r = SetHorizontalFitPolicy(control, FIT_POLICY_FIXED); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Layout::LayoutRect rect; + r = GetItemBaseRect(control, rect); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + rect.w = width; + r = SetItemBaseRect(control, rect); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_RelativeLayoutImpl::SetItemMargin(const _ControlImpl& item, int left, int right, int top, int bottom) +{ + return _LayoutImpl::SetMargin(item, left, right, top, bottom); +} + +result +_RelativeLayoutImpl::GetItemMargin(const _ControlImpl& item, int& left, int& right, int& top, int& bottom) +{ + return _LayoutImpl::GetMargin(item, left, right, top, bottom); +} + +result +_RelativeLayoutImpl::SetItemHorizontalFitPolicy(const _ControlImpl& item, const FitPolicy policy) +{ + return _LayoutImpl::SetHorizontalFitPolicy(item, policy); +} + +result +_RelativeLayoutImpl::SetItemVerticalFitPolicy(const _ControlImpl& item, FitPolicy policy) +{ + return _LayoutImpl::SetVerticalFitPolicy(item, policy); +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_RelativeLayoutImpl.h b/src/ui/FUi_RelativeLayoutImpl.h new file mode 100644 index 0000000..fc47be3 --- /dev/null +++ b/src/ui/FUi_RelativeLayoutImpl.h @@ -0,0 +1,271 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_RelativeLayoutImpl.h + * @brief This is the header file for _RelativeLayoutImpl class. + * + * This header file contains the declaration of _RelativeLayoutImpl class. + */ + +#ifndef _FUI_INTERNAL_RELATIVE_LAYOUT_IMPL_H +#define _FUI_INTERNAL_RELATIVE_LAYOUT_IMPL_H + +#include +#include "FUi_LayoutImpl.h" +#include "FUi_LayoutRelativeLayout.h" + +namespace Tizen { namespace Ui +{ + +class RelativeLayout; + +class _RelativeLayoutImpl + : public _LayoutImpl +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_RelativeLayoutImpl(void); + + /** + * Creates the instance of _RelativeLayoutImpl. + * + * @since 2.0 + * @return The instance of _RelativeLayoutImpl. + * @param[in] pPublicLayout The public class of relative layout. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + static _RelativeLayoutImpl* CreateRelativeLayoutImplN(RelativeLayout* pPublicLayout); + + /** + * Gets the name of public class. + * + * @since 2.0 + * @return The name of public class. + */ + virtual const char* GetPublicClassName(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual const RelativeLayout& GetPublic(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual RelativeLayout& GetPublic(void); + + /** + * Gets the core class. + * + * @since 2.0 + * @return The core class. + */ + virtual const _Layout::RelativeLayout& GetCore(void) const; + + /** + * Gets the core class. + * + * @since 2.0 + * @return The core class. + */ + virtual _Layout::RelativeLayout& GetCore(void); + + /** + * Gets the _RelativeLayoutImpl instance for the RelativeLayout. + * + * @since 2.0 + * @return The _RelativeLayoutImpl instance. + * @param[in] pLayout The RelativeLayout instance. + */ + static const _RelativeLayoutImpl* GetInstance(const RelativeLayout& layout); + + /** + * Gets the _RelativeLayoutImpl instance for the RelativeLayout. + * + * @since 2.0 + * @return The _RelativeLayoutImpl instance. + * @param[in] pLayout The RelativeLayout instance. + */ + static _RelativeLayoutImpl* GetInstance(RelativeLayout& layout); + + /** + * Sets the specified control at the center of the parent control. + * + * @since 2.0 + * @return An error code + * @param[in] control The control to be center aligned + * @param[in] alignment The center alignment for a control either vertically or horizontally + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result SetCenterAligned(_ControlImpl& control, CenterAlignmentType alignment); + + /** + * Sets the relation of the specified child control for the edge with other control. + * + * @since 2.0 + * @return An error code + * @param[in] childControl The control for which the relation is set + * @param[in] targetControl The target control @n + * It should be a parent or sibling. + * @param[in] edgeRelation The edge of the specified control to be aligned with the edge of the target control + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result SetRelation(_ControlImpl& childControl, _ControlImpl& targetControl, RectangleEdgeRelation edgeRelation); + + /** + * Resets the center position of the specified control. + * + * @since 2.0 + * @return An error code + * @param[in] childControl The control to be center aligned + * @param[in] alignment The center alignment for a control either vertically or horizontally + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result ResetCenterAligned(_ControlImpl& control, CenterAlignmentType alignment); + + /** + * Resets the relation of the specified control for the vertical edge. + * + * @since 2.0 + * @return An error code + * @param[in] childControl The control for which the relation is reset + * @param[in] edgeType The edge type of the specified control + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result ResetRelation(_ControlImpl& control, RectangleEdgeType edgeType); + + /** + * Sets the height of the specified control to the fixed size. + * + * @since 2.0 + * @return An error code + * @param[in] childControl The control for which the height is set + * @param[in] height The value of the height + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetHeight(_ControlImpl& control, int height); + + /** + * Sets the width of the specified control to the fixed size. + * + * @since 2.0 + * @return An error code + * @param[in] childControl The control for which the width is set + * @param[in] width The value of the width + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetWidth(_ControlImpl& control, int width); + + /** + * Sets the margins of the specified control. + * + * @since 2.0 + * @return An error code + * @param[in] item The control for which the margins are set + * @param[in] left The left margin + * @param[in] right The right margin + * @param[in] top The top margin + * @param[in] bottom The bottom margin + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetItemMargin(const _ControlImpl& item, int left, int right, int top, int bottom); + + /** + * Gets the margins of the specified control. + * + * @since 2.0 + * @return An error code + * @param[in] item The control for which the margins are set + * @param[out] left The left margin + * @param[out] right The right margin + * @param[out] top The top margin + * @param[out] bottom The bottom margin + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result GetItemMargin(const _ControlImpl& item, int& left, int& right, int& top, int& bottom); + + /** + * Sets the width of the specified control as per the fitting policy. + * + * @since 2.0 + * @return An error code + * @param[in] item The control for which the width is set + * @param[in] policy The fitting policy for the width + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetItemHorizontalFitPolicy(const _ControlImpl& item, const FitPolicy policy); + + /** + * Sets the height of the specified control as per the fitting policy. + * + * @since 2.0 + * @return An error code + * @param[in] childControl The control for which the height is set + * @param[in] policy The fitting policy for the height + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetItemVerticalFitPolicy(const _ControlImpl& item, const FitPolicy policy); + + /** + * Gets the type of the layout. + * + * @since 2.0 + * @return The layout type + */ + virtual LayoutType GetLayoutType(void) const; + +protected: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _RelativeLayoutImpl(RelativeLayout* pPublicLayout, _Layout::RelativeLayout* pCoreLayout); +}; // _RelativeLayoutImpl + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_RELATIVE_LAYOUT_IMPL_H diff --git a/src/ui/FUi_ResourceManager.cpp b/src/ui/FUi_ResourceManager.cpp new file mode 100644 index 0000000..3b3874b --- /dev/null +++ b/src/ui/FUi_ResourceManager.cpp @@ -0,0 +1,1111 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_ControlManager.h" +#include "FUi_ResourceManager.h" +#include "FUi_ResourceStringLoader.h" +#include "FUi_ResourceConfigLoader.h" +#include "FUi_ResourceConfigParser.h" +#include "FUi_ResourceMapContainer.h" + +using namespace Tizen::App; +using namespace Tizen::App::Package; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui::_Resource; + +namespace +{ +const int DEFAULT_SCREEN_WIDTH = 720; +const int DEFAULT_SCREEN_HEIGHT = 1280; + +const int DPI_FOR_XHIGH = 290; +const int DPI_FOR_HIGH = 200; +const int DPI_FOR_MIDDLE = 150; +const int DPI_FOR_LOW = 0; + +template class ResourceFallbackItemComparer + : public IComparerT +{ +public: + ResourceFallbackItemComparer(void) {} + virtual ~ResourceFallbackItemComparer(void) {} + virtual result Compare(const T& obj1, const T& obj2, int& cmp) const + { + if (obj1->scaleFactor > obj2->scaleFactor) + { + cmp = 1; + return E_SUCCESS; + } + else if (obj1->scaleFactor < obj2->scaleFactor) + { + cmp = -1; + return E_SUCCESS; + } + else + { + cmp = 0; + return E_SUCCESS; + } + } +}; + +MediaPixelFormat ConvertBitmapPixelFormatToMediaPixelFormat(BitmapPixelFormat format) +{ + MediaPixelFormat out = MEDIA_PIXEL_FORMAT_NONE; + switch(format) + { + case BITMAP_PIXEL_FORMAT_RGB565: + out = MEDIA_PIXEL_FORMAT_RGB565LE; + break; + case BITMAP_PIXEL_FORMAT_ARGB8888: + out = MEDIA_PIXEL_FORMAT_BGRA8888; + break; + case BITMAP_PIXEL_FORMAT_R8G8B8A8: + out = MEDIA_PIXEL_FORMAT_RGBA8888; + break; + default: + break; + } + return out; +} +} + +namespace Tizen { namespace Graphics +{ +result +_CreateCoordinateTransformer(_ICoordinateSystemTransformer*& pTransformer, int srcResolution, _BaseScreenSize srcBaseScreenSize, Dimension destResolution, _BaseScreenSize destBaseScreenSize); +}} + +namespace Tizen { namespace Ui +{ + +Color _GetDefaultBackgroundColor(void) +{ + Color color; + _ResourceManager::GetInstance()->GetColor(L"DEFAULTCOLORTABLE::background", color); + return color; +} +Color _GetDefaultForegroundColor(void) +{ + Color color; + _ResourceManager::GetInstance()->GetColor(L"DEFAULTCOLORTABLE::foreground", color); + return color; +} + +_ResourceManager* pRsrcMgr = null; + +_ResourceManager* +_ResourceManager::GetInstance(void) +{ + static pthread_once_t onceBlock = PTHREAD_ONCE_INIT; + + if (pRsrcMgr == null) + { + pthread_once(&onceBlock, CreateInstance); + } + return pRsrcMgr; +} +void +_ResourceManager::CreateInstance(void) +{ + static _ResourceManager pManager; + pRsrcMgr = &pManager; + _CanvasImpl::SetThemeInfoCallback(_GetDefaultForegroundColor, _GetDefaultBackgroundColor); +} + +_ResourceManager::_ResourceManager(void) + : __pStringLoader(null) + , __pTransformer(null) + , __appBasePortraitMode("") + , __appBaseLandscapeMode("") + , __targetPortraitMode("") + , __targetLandscapeMode("") + , __defaultPortraitMode(L"720x1280") + , __defaultLandscapeMode(L"1280x720") + , __systemTheme(L"") + , __userTheme(L"") + , __appliedUserTheme(false) + , __appBaseWidth(-1) + , __appBaseHeight(-1) + , __targetWidth(0) + , __targetHeight(0) + , __deviceDPI(0) + , __pFallbackList(null) +{ + __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT] = null; + __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE] = null; + __pMapContainer[MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT] = null; + __pMapContainer[MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE] = null; + + int appBaseWidth = DEFAULT_SCREEN_WIDTH; + int appBaseHeight = DEFAULT_SCREEN_HEIGHT; + + result r = E_SUCCESS; + + int appLogicalResolution = _CoordinateSystem::GetInstance()->GetLogicalResolutionInt(); + + if (_CreateCoordinateTransformer(__pTransformer,DEFAULT_SCREEN_WIDTH, BASE_SCREEN_SIZE_NORMAL, Dimension(appLogicalResolution, appLogicalResolution), BASE_SCREEN_SIZE_NORMAL) != E_SUCCESS) + { + + SysAssert(0); + } + + r = Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/screen.dpi", __deviceDPI); + SysTryReturn(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] system error occurred"); + + switch(appLogicalResolution) + { + case 240: + appBaseWidth = 240; + appBaseHeight = 400; + break; + case 320: + appBaseWidth = 320; + appBaseHeight = 480; + break; + case 480: + appBaseWidth = 480; + appBaseHeight = 800; + break; + case 720: + appBaseWidth = 720; + appBaseHeight = 1280; + break; + default: + r = Tizen::System::_SystemInfoImpl::GetSysInfo("http://tizen.org/feature/screen.width", appBaseWidth); + SysTryReturn(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] system error occurred"); + r = Tizen::System::_SystemInfoImpl::GetSysInfo("http://tizen.org/feature/screen.height", appBaseHeight); + SysTryReturn(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] system error occurred"); + break; + } + __appBaseWidth = appBaseWidth; + __appBaseHeight = appBaseHeight; + + __appBasePortraitMode.Append(appBaseWidth); + __appBasePortraitMode.Append(L"x"); + __appBasePortraitMode.Append(appBaseHeight); + + __appBaseLandscapeMode.Append(appBaseHeight); + __appBaseLandscapeMode.Append(L"x"); + __appBaseLandscapeMode.Append(appBaseWidth); + + int _width = 0; + int _height = 0; + r = Tizen::System::_SystemInfoImpl::GetSysInfo("http://tizen.org/feature/screen.width", _width); + SysTryReturn(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] system error occurred"); + r = Tizen::System::_SystemInfoImpl::GetSysInfo("http://tizen.org/feature/screen.height", _height); + SysTryReturn(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] system error occurred"); + + __targetWidth = _width; + __targetHeight = _height; + __targetPortraitMode.Append(_width); + __targetPortraitMode.Append(L"x"); + __targetPortraitMode.Append(_height); + + __targetLandscapeMode.Append(_height); + __targetLandscapeMode.Append(L"x"); + __targetLandscapeMode.Append(_width); + + LoadThemeInformation(__systemTheme, __userTheme); + + // theme 2.0 + __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT] = new (std::nothrow) MapContainer(); + SysTryReturnVoidResult(NID_UI, __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT], E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT]->SetResolution(__appBasePortraitMode); + if (!(InitializeTheme(*__pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT]))) + { + SysAssert(0); + } + + __pStringLoader = new (std::nothrow) StringLoader(); + SysTryReturnVoidResult(NID_UI, __pStringLoader, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + SetSystemColor(); +} + +bool +_ResourceManager::InitializeTheme(MapContainer& mapContainer) +{ + bool r = false; + String themeFile(L""); + + mapContainer.CreateMap(RESOURCE_TYPE_SHAPE); + mapContainer.CreateMap(RESOURCE_TYPE_FIXED_VALUE); + mapContainer.CreateMap(RESOURCE_TYPE_DIMENSION); + mapContainer.CreateMap(RESOURCE_TYPE_IMAGE); + mapContainer.CreateMap(RESOURCE_TYPE_COLOR); + mapContainer.SetResolution(__appBasePortraitMode); + themeFile = String(L"/usr/share/osp/themes/"+__systemTheme + ".xml"); + ConfigParser* pParser = new (std::nothrow) ConfigParser(); + SysTryReturn(NID_UI, pParser, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + r = pParser->Parse(themeFile, mapContainer); + LoadConfig(__appBasePortraitMode, mapContainer); + + if (__userTheme.GetLength() > 0) + { + themeFile = String(_AppInfo::GetAppRootPath()+L"res/themes/" +__userTheme + L"/" +__userTheme + ".xml"); + r = pParser->Parse(themeFile, mapContainer); + } + + delete pParser; + return r; +} + +void +_ResourceManager::LoadConfig(const String& resolution, MapContainer& mapContainer) +{ + int count = ConfigLoader::GetInstance()->GetInitFuncCount(); + for (int i = 0; i < count; i++) + { + _Init_Func func = null; + ConfigLoader::GetInstance()->GetInitFunc(i, func); + if (func) + { + func(mapContainer, resolution); + } + } +} +MapContainer* +_ResourceManager::GetMapContainer(MapContainerType type) +{ + MapContainer* pContainer = null; + switch (type) + { + case MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT: + pContainer = __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT]; + break; + case MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE: + if (__pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE]) + { + pContainer = __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE]; + } + else + { + pContainer = new (std::nothrow) MapContainer(); + SysTryReturn(NID_UI, pContainer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pContainer->SetResolution(__appBaseLandscapeMode); + pContainer->CreateMap(RESOURCE_TYPE_SHAPE); + pContainer->CreateMap(RESOURCE_TYPE_DIMENSION); + pContainer->CreateMap(RESOURCE_TYPE_FIXED_VALUE); + LoadConfig(__appBaseLandscapeMode, *pContainer); + __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE] = pContainer; + } + break; + case MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT: + if (__pMapContainer[MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT]) + { + pContainer = __pMapContainer[MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT]; + } + else + { + pContainer = new (std::nothrow) MapContainer(); + SysTryReturn(NID_UI, pContainer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pContainer->SetResolution(__defaultPortraitMode); + pContainer->CreateMap(RESOURCE_TYPE_SHAPE); + pContainer->CreateMap(RESOURCE_TYPE_DIMENSION); + pContainer->CreateMap(RESOURCE_TYPE_FIXED_VALUE); + LoadConfig(__defaultPortraitMode, *pContainer); + __pMapContainer[MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT] = pContainer; + } + break; + case MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE: + if (__pMapContainer[MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE]) + { + pContainer = __pMapContainer[MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE]; + } + else + { + pContainer = new (std::nothrow) MapContainer(); + SysTryReturn(NID_UI, pContainer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pContainer->SetResolution(__defaultLandscapeMode); + pContainer->CreateMap(RESOURCE_TYPE_SHAPE); + pContainer->CreateMap(RESOURCE_TYPE_DIMENSION); + pContainer->CreateMap(RESOURCE_TYPE_FIXED_VALUE); + LoadConfig(__defaultLandscapeMode, *pContainer); + __pMapContainer[MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE] = pContainer; + } + break; + default: + break; + } + return pContainer; +} + +_ResourceManager::~_ResourceManager(void) +{ + delete __pStringLoader; + __pStringLoader = null; + delete __pTransformer; + __pTransformer = null; + delete __pFallbackList; + __pFallbackList = null; + delete __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT]; + __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT] = null; + delete __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE]; + __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE] = null; + delete __pMapContainer[MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT]; + __pMapContainer[MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT] = null; + delete __pMapContainer[MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE]; + __pMapContainer[MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE] = null; +} +void +_ResourceManager::ReloadTheme(Tizen::Base::String& themeName, bool userdefine) +{ + if(userdefine) + { + __userTheme = themeName; + } + else + { + __systemTheme = themeName; + } +} + +result +_ResourceManager::GetBitmapInternalN(const String& fileName, BitmapPixelFormat pixelFormat, _ControlOrientation orientation, Bitmap*& pBitmap) +{ + result r = E_SYSTEM; + Bitmap* pTempBitmap = null; + pTempBitmap = new (std::nothrow) Bitmap; + SysTryReturn(NID_UI, pTempBitmap, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(r)); + + r = _BitmapImpl::GetInstance(*pTempBitmap)->Construct(fileName, pixelFormat); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + pBitmap = pTempBitmap; + return r; + +CATCH: + delete pTempBitmap; + return r; +} + +result +_ResourceManager::GetBitmapN(const String& bitmapId, BitmapPixelFormat pixelFormat, _ControlOrientation orientation, Bitmap*& pBitmap) +{ + result r = E_SYSTEM; + String* pFileName = null; + r = __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT]->GetImageMap()->GetValue(bitmapId, pFileName); + if (r == E_SUCCESS) + { + int foundFolderWidth = 0; + String fullName = FindImagePath(*pFileName, foundFolderWidth); + if(foundFolderWidth == __targetWidth) + { + r = GetBitmapInternalN(fullName, pixelFormat, orientation, pBitmap); + } + else + { + ByteBuffer* pImageBuffer = null; + Bitmap* pTempBitmap = null; + int imageWidth = 0; + int imageHeight = 0; + MediaPixelFormat format = ConvertBitmapPixelFormatToMediaPixelFormat(pixelFormat); + pImageBuffer = _ImageDecoder::DecodeToBufferN(fullName, format, imageWidth, imageHeight); + if (pImageBuffer) + { + pTempBitmap = _BitmapImpl::GetNonScaledBitmapN(*pImageBuffer, Dimension(imageWidth, imageHeight), pixelFormat); + delete pImageBuffer; + } + if(pTempBitmap != null) + { + if(pTempBitmap->IsNinePatchedBitmap()) + { + pBitmap = pTempBitmap; + r = E_SUCCESS; + } + else + { + float scaleFactor = (float)((float)__targetWidth/(float)foundFolderWidth); + + r = pTempBitmap->Scale(Dimension(imageWidth*scaleFactor, imageHeight*scaleFactor)); + if (r == E_SUCCESS) + { + pBitmap = pTempBitmap; + } + else + { + delete pTempBitmap; + } + } + } + } + } + return r; +} + +result +_ResourceManager::GetString(const String& stringId, String& string) +{ + return __pStringLoader->GetString(stringId, string); +} + +result +_ResourceManager::GetColor(const String& colorId, Color& color) +{ + result r = E_SYSTEM; + Color* pColor = null; + r = __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT]->GetColorMap()->GetValue(colorId, pColor); + if(r == E_SUCCESS) + { + color = *pColor; + } + return r; +} + +result +_ResourceManager::GetDimension(const String& dimensionId, _ControlOrientation orientation, Dimension& dimension) +{ + result r = E_SUCCESS; + Dimension dim(0, 0); + + Dimension* pDimension = null; + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT)->GetDimensionMap()->GetValue(dimensionId, pDimension); + if (r != E_SUCCESS) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE)->GetDimensionMap()->GetValue(dimensionId, pDimension); + } + } + else + { + r = GetMapContainer(MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE)->GetDimensionMap()->GetValue(dimensionId, pDimension); + if (r != E_SUCCESS) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT)->GetDimensionMap()->GetValue(dimensionId, pDimension); + } + } + if (r == E_SUCCESS) + { + dim = *pDimension; + } + + if (r != E_SUCCESS) + { + r = GetDefaultShapeWithScaling(dimensionId, orientation, dim); + } + + if (r == E_SUCCESS) + { + dimension = dim; + } + else + { + return E_SYSTEM; + } + + return r; +} + +result +_ResourceManager::GetShape(const String& shapeId, _ControlOrientation orientation, int& value) +{ + result r = E_SUCCESS; + Integer integer(-1); + + Integer* pInteger = null; + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + r = __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT]->GetShapeMap()->GetValue(shapeId, pInteger); + if (r != E_SUCCESS) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE)->GetShapeMap()->GetValue(shapeId, pInteger); + } + } + else + { + r = GetMapContainer(MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE)->GetShapeMap()->GetValue(shapeId, pInteger); + if (r != E_SUCCESS) + { + r = __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT]->GetShapeMap()->GetValue(shapeId, pInteger); + } + } + + if (r == E_SUCCESS) + { + integer = *pInteger; + } + + if (r != E_SUCCESS) + { + r = GetDefaultShapeWithScaling(shapeId, orientation, integer); + } + + if (r == E_SUCCESS) + { + value = integer.ToInt(); + } + else + { + return E_SYSTEM; + } + + return r; +} + +result +_ResourceManager::GetFixedValue(const String& fixedValueId, _ControlOrientation orientation, int& value) +{ + result r = E_SUCCESS; + Integer integer(-1); + Integer* pInteger = null; + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT)->GetFixedValueMap()->GetValue(fixedValueId, pInteger); + if (r != E_SUCCESS) + { + + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE)->GetFixedValueMap()->GetValue(fixedValueId, pInteger); + } + } + else + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE)->GetFixedValueMap()->GetValue(fixedValueId, pInteger); + if (r != E_SUCCESS) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT)->GetFixedValueMap()->GetValue(fixedValueId, pInteger); + } + } + + if (r != E_SUCCESS) + { + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT)->GetShapeMap()->GetValue(fixedValueId, pInteger); + if (r != E_SUCCESS) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE)->GetShapeMap()->GetValue(fixedValueId, pInteger); + } + } + else + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE)->GetShapeMap()->GetValue(fixedValueId, pInteger); + if (r != E_SUCCESS) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT)->GetShapeMap()->GetValue(fixedValueId, pInteger); + } + } + } + + if (r == E_SUCCESS) + { + integer = *pInteger; + } + + if (r == E_SUCCESS) + { + value = integer.ToInt(); + } + else + { + return E_SYSTEM; + } + + return r; +} + +bool +_ResourceManager::IsCustomColor(const Tizen::Base::String& colorId) +{ + return __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT]->GetColorMap()->IsUserThemeItem(colorId); +} +bool +_ResourceManager::IsCustomBitmap(const Tizen::Base::String& bitmapId) +{ + return __pMapContainer[MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT]->GetImageMap()->IsUserThemeItem(bitmapId); +} + +result +_ResourceManager::GetDefaultShapeWithScaling(const String& shapeId, _ControlOrientation orientation, Integer& integer) +{ + result r = E_SUCCESS; + Integer* pInteger = null; + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT)->GetShapeMap()->GetValue(shapeId, pInteger); + if (r != E_SUCCESS) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE)->GetShapeMap()->GetValue(shapeId, pInteger); + } + } + else + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE)->GetShapeMap()->GetValue(shapeId, pInteger); + if (r != E_SUCCESS) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT)->GetShapeMap()->GetValue(shapeId, pInteger); + } + } + if (r == E_SUCCESS) + { + integer = *pInteger; + } + + if (r == E_SUCCESS) + { + int temp = __pTransformer->Transform(integer.ToInt()); + if (temp == 0 && integer.ToInt() > 0) + { + integer = 1; + } + else + { + integer = temp; + } + } + return r; +} + +result +_ResourceManager::GetDefaultShapeWithScaling(const String& shapeId, _ControlOrientation orientation, Dimension& dimension) +{ + result r = E_SUCCESS; + Dimension dim(0,0); + Dimension* pDimension = null; + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT)->GetDimensionMap()->GetValue(shapeId, pDimension); + if (r != E_SUCCESS) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE)->GetDimensionMap()->GetValue(shapeId, pDimension); + } + } + else + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE)->GetDimensionMap()->GetValue(shapeId, pDimension); + if (r != E_SUCCESS) + { + r = GetMapContainer(MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT)->GetDimensionMap()->GetValue(shapeId, pDimension); + } + } + if (r == E_SUCCESS) + { + dim = *pDimension; + } + + if (r == E_SUCCESS) + { + Dimension temp = __pTransformer->Transform(dim); + if (temp.width == 0 && dim.width > 0) + { + temp.width = 1; + } + if (temp.height == 0 && dim.height > 0) + { + temp.height = 1; + } + dimension = temp; + } + return r; +} + +result +_ResourceManager::LoadThemeInformation(String& systemTheme, String& userTheme) +{ + AppId appId = _AppInfo::GetAppId(); + IMap* pList = null; + pList = _PackageManagerImpl::GetInstance()->GetUiThemeListN(appId); + + if (pList) + { + IMapEnumerator* pMapEnum = pList->GetMapEnumeratorN(); + while (pMapEnum->MoveNext() == E_SUCCESS) + { + String* pKey = static_cast (pMapEnum->GetKey()); + String* pValue = static_cast (pMapEnum->GetValue()); + String key(*pKey); + key.ToLowerCase(); + if (key == L"systemtheme") + { + systemTheme = *pValue; + systemTheme.ToLowerCase(); + } + if (key == L"userdefinedtheme") + { + userTheme = *pValue; + } + } + delete pMapEnum; + + pList->RemoveAll(true); + delete pList; + } + if (systemTheme.GetLength() < 1) + { + systemTheme = L"black"; + } + return E_SUCCESS; +} + +void +_ResourceManager::GetThemeName(String& systemTheme, String& userTheme) const +{ + systemTheme = __systemTheme; + userTheme = __userTheme; +} + +void +_ResourceManager::SetSystemColor(void) +{ + void* handle =null; + Color* pColor = null; + Color* (*GetSystemColor)(const String&) = null; + + handle = dlopen ("libosp-compat.so", RTLD_LAZY); + if (!handle) + { + return; + } + GetSystemColor = reinterpret_cast(dlsym(handle, "_GetSystemColor")); + if (dlerror() != NULL) + { + goto CATCH; + } + + pColor = GetSystemColor(L"TITLE_TEXT"); + if (pColor != null) + { + GetColor("HEADER::TITLE_TEXT_NORMAL", *pColor); + } + + pColor = GetSystemColor(L"BODY_TEXT"); + if (pColor != null) + { + GetColor("BUTTON::TEXT_NORMAL", *pColor); + } + + pColor = GetSystemColor(L"FOREGROUND"); + if (pColor != null) + { + GetColor("foreground", *pColor); + } + + pColor = GetSystemColor(L"BACKGROUND"); + if (pColor != null) + { + GetColor("background", *pColor); + } + + pColor = GetSystemColor(L"LIST_BACKGROUND"); + if (pColor != null) + { + GetColor("FORM::BG_NORMAL", *pColor); + } + + pColor = GetSystemColor(L"FORM_BACKGROUND"); + if (pColor != null) + { + GetColor("FORM::BG_NORMAL", *pColor); + } + + pColor = GetSystemColor(L"FORM_GROUP_BACKGROUND"); + if (pColor != null) + { + GetColor("DEFAULTCOLORTABLE::form_group_list_bg", *pColor); + } + + pColor = GetSystemColor(L"POPUP_BACKGROUND"); + if (pColor != null) + { + GetColor("POPUP::BG_NORMAL", *pColor); + } + + pColor = GetSystemColor(L"GROUP_ITEM_TEXT"); + if (pColor != null) + { + GetColor("CHECKBUTTON::TEXT_NORMAL", *pColor); + } + + pColor = GetSystemColor(L"LIST_ITEM_TEXT"); + if (pColor != null) + { + GetColor("LISTVIEW::ITEM_TEXT_NORMAL", *pColor); + } + + pColor = GetSystemColor(L"LIST_ITEM_PRESSED_TEXT"); + if (pColor != null) + { + GetColor("LISTVIEW::ITEM_TEXT_PRESSED", *pColor); + } + + pColor = GetSystemColor(L"LIST_ITEM_HIGHLIGHTED_TEXT"); + if (pColor != null) + { + GetColor("LISTVIEW::ITEM_TEXT_HIGHLIGHTED", *pColor); + } + + //fall through +CATCH: + dlclose(handle); + return; +} +bool +_ResourceManager::GetDensityDirectory(String directoryName, float scaleFactor) +{ + int denominator = 0; + int numerator = 0; + if(!(directoryName.StartsWith(L"screen-density",0))) + { + return false; + } + + if (__deviceDPI >= DPI_FOR_XHIGH) + { + numerator = 9; + } + else if (__deviceDPI >= DPI_FOR_HIGH) + { + numerator = 6; + } + else if (__deviceDPI >= DPI_FOR_MIDDLE) + { + numerator = 4; + } + else if (__deviceDPI < DPI_FOR_MIDDLE && __deviceDPI > DPI_FOR_LOW) + { + numerator = 3; + } + else + { + return false; + } + + if(directoryName.Contains(L"xhigh")) + { + denominator = 9; + } + else if(directoryName.Contains(L"high")) + { + denominator = 6; + } + else if(directoryName.Contains(L"middle")) + { + denominator = 4; + } + else if(directoryName.Contains(L"low")) + { + denominator = 3; + } + else + { + return false; + } + + scaleFactor = (float)((float)numerator / (float)denominator); + return true; +} + +bool +_ResourceManager::GetResolutionDirectory(String directoryName, float scaleFactor) +{ + if(!(directoryName.Contains(L"0"))) + { + return false; + } + + int index = 0; + if(directoryName.IndexOf(L"x", 0, index) != E_SUCCESS) + { + return false; + } + String width = 0; + + if(directoryName.SubString(0, index - 1, width)) + { + int denominator = 0; + int numerator = 0; + if(Integer::Parse(width, denominator) == E_SUCCESS) + { + numerator = __targetWidth; + scaleFactor = (float)((float)numerator / (float)denominator); + return true; + } + } + return false; +} + +String +_ResourceManager::FindImagePath(const String& fileName, int& foundFolderWidth) +{ + bool find = false; + String fullName(L""); + ResourceFallbackItem* pItem = null; + + if(__userTheme.GetLength() > 0) + { + String resDirectory = _AppInfo::GetAppRootPath() + L"res/theme/res"; + if(__pFallbackList == null) + { + __pFallbackList = new (std::nothrow) ArrayListT; + SysTryReturn(NID_UI, __pFallbackList, L"", E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + Directory dir; + result r = dir.Construct(resDirectory); + if (r == E_SUCCESS) + { + DirEnumerator* pDirEnum = dir.ReadN(); + if (pDirEnum != null) + { + while (pDirEnum->MoveNext() == E_SUCCESS) + { + DirEntry entry = pDirEnum->GetCurrentDirEntry(); + if(entry.IsDirectory()) + { + float scaleFactor = 0; + String directoryName = entry.GetName(); + if(GetDensityDirectory(directoryName, scaleFactor)) + { + pItem = new (std::nothrow) ResourceFallbackItem; + SysTryCatch(NID_UI, pItem, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pItem->scaleFactor = scaleFactor; + pItem->directoryName = directoryName; + __pFallbackList->Add(pItem); + } + else if(GetResolutionDirectory(directoryName, scaleFactor)) + { + pItem = new (std::nothrow) ResourceFallbackItem; + SysTryCatch(NID_UI, pItem, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pItem->scaleFactor = scaleFactor; + pItem->directoryName = directoryName; + __pFallbackList->Add(pItem); + } + } + } + ResourceFallbackItemComparer comparer; + __pFallbackList->Sort(comparer); + delete pDirEnum; + } + for(int i = 0 ; i < __pFallbackList->GetCount() ; i++) + { + ResourceFallbackItem* pItem; + if(__pFallbackList->GetAt(i,pItem) == E_SUCCESS) + { + if(pItem->scaleFactor < 1.001 && pItem->scaleFactor > 0.999) + { + __pFallbackList->RemoveAt(i); + __pFallbackList->InsertAt(pItem,0); + if(pItem->directoryName.Contains(L"0")) + { + break; + } + } + } + } + } + } + for(int i = 0 ; i <__pFallbackList->GetCount() ; i++) + { + ResourceFallbackItem* pItem; + __pFallbackList->GetAt(i,pItem); + fullName = resDirectory + L"/" + pItem->directoryName + L"/" + fileName; + if (File::IsFileExist(fullName)) + { + find = true; + foundFolderWidth = __targetWidth / pItem->scaleFactor; + if(foundFolderWidth > __targetWidth) + { + if( foundFolderWidth < __targetWidth + 3) + { + foundFolderWidth = __targetWidth; + } + } + else + { + if( foundFolderWidth >__targetWidth - 3) + { + foundFolderWidth = __targetWidth; + } + } + break; + } + } + } + if(!find) + { + fullName = String(L"/usr/share/osp/bitmaps/" + __targetPortraitMode+ "/" + __systemTheme + L"/" + fileName); + if (File::IsFileExist(fullName)) + { + find = true; + foundFolderWidth = __targetWidth; + } + else + { + fullName = String(L"/usr/share/osp/bitmaps/" + __defaultPortraitMode+ "/" + __systemTheme + L"/" + fileName); + if (File::IsFileExist(fullName)) + { + find = true; + foundFolderWidth = DEFAULT_SCREEN_WIDTH; + } + } + } + + if(!find) + { + fullName = String(L"/usr/share/osp/bitmaps/" + __targetPortraitMode + "/" + fileName); + if (File::IsFileExist(fullName)) + { + find = true; + foundFolderWidth = __targetWidth; + } + else + { + fullName = String(L"/usr/share/osp/bitmaps/" + __defaultPortraitMode+ "/" + fileName); + if (File::IsFileExist(fullName)) + { + find = true; + foundFolderWidth = DEFAULT_SCREEN_WIDTH; + } + } + } + + if(!find) + { + return L""; + } + else + { + return fullName; + } +CATCH: + delete __pFallbackList; + __pFallbackList = null; + return L""; +} + +}}//Tizen::Ui diff --git a/src/ui/FUi_TouchEventArg.cpp b/src/ui/FUi_TouchEventArg.cpp new file mode 100644 index 0000000..acff3bd --- /dev/null +++ b/src/ui/FUi_TouchEventArg.cpp @@ -0,0 +1,97 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchEventArg.cpp + * @brief This is the implementation file for the _TouchEventArg class. + */ + +#include "FUi_TouchEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +_TouchEventArg::_TouchEventArg(const Tizen::Ui::Control& source, _TouchStatus status) + : __PointId(0) + , __pSource(const_cast (&source)) + , __touchStatus(status) + , __startPosition(-1, -1) + , __currentPosition(-1, -1) + , __isFlicked(false) +{ + +} + +_TouchEventArg::~_TouchEventArg(void) +{ + // NOTHING +} + +_TouchStatus +_TouchEventArg::GetTouchStatus(void) const +{ + return (__touchStatus); +} + +const Tizen::Ui::Control* +_TouchEventArg::GetSource(void) const +{ + return (__pSource); +} + +void +_TouchEventArg::SetTouchPosition(unsigned long PointId, int startX, int startY, int currentX, int currentY) +{ + __PointId = PointId; + __startPosition = Tizen::Graphics::Point(startX, startY); + __currentPosition = Tizen::Graphics::Point(currentX, currentY); +} + +unsigned long +_TouchEventArg::GetPointId(void) const +{ + return __PointId; +} + +const Point +_TouchEventArg::GetStartPosition(void) const +{ + return __startPosition; +} + +const Point +_TouchEventArg::GetCurrentPosition(void) const +{ + return __currentPosition; +} + +void +_TouchEventArg::SetFlickedStatus(bool isFlicked) +{ + __isFlicked = isFlicked; +} + +bool +_TouchEventArg::IsFlicked(void) const +{ + return __isFlicked; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_TouchEventInfoImpl.cpp b/src/ui/FUi_TouchEventInfoImpl.cpp new file mode 100644 index 0000000..24da2fb --- /dev/null +++ b/src/ui/FUi_TouchEventInfoImpl.cpp @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_TouchEventInfoImpl.cpp +* @brief This is the implementation for the _TouchEventInfoImpl class. +* @version 2.0 +*/ + +// includes +#include +#include +#include +#include +#include "FUi_TouchEventInfoImpl.h" +#include "FUi_UiTouchEvent.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +_TouchEventInfoImpl* +_TouchEventInfoImpl::CreateInstanceN(TouchEventInfo* pPublic) +{ + ClearLastResult(); + + _TouchEventInfoImpl* pImpl = new (std::nothrow) _TouchEventInfoImpl(pPublic); + SysTryReturn(NID_UI, pImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pImpl; +} + +_TouchEventInfoImpl::_TouchEventInfoImpl(TouchEventInfo* pPublic) + : __pPublic(pPublic) + , __pointId(0) + , __touchStatus(_TOUCH_PRESSED) + , __startPosition(0, 0) + , __currentPosition(0, 0) + , __isFlicked(false) +{ +} + +_TouchEventInfoImpl::~_TouchEventInfoImpl(void) +{ +} + +void +_TouchEventInfoImpl::SetTouchEventInfo(const _TouchInfo& touchInfo, const Point startPosition) +{ + __pointId = touchInfo.GetPointId(); + __startPosition.x = startPosition.x; + __startPosition.y = startPosition.y; + __currentPosition.x = touchInfo.GetCurrentPosition().x; + __currentPosition.y = touchInfo.GetCurrentPosition().y; + __isFlicked = touchInfo.IsFlicked(); + __touchStatus = touchInfo.GetTouchStatus(); +} + +unsigned long +_TouchEventInfoImpl::GetPointId(void) const +{ + return __pointId; +} + +Point +_TouchEventInfoImpl::GetStartPosition(void) const +{ + return __startPosition; +} + +Point +_TouchEventInfoImpl::GetCurrentPosition(void) const +{ + return __currentPosition; +} + +_TouchStatus +_TouchEventInfoImpl::GetTouchStatus(void) const +{ + return __touchStatus; +} + +bool +_TouchEventInfoImpl::IsFlicked(void) const +{ + return __isFlicked; +} + +} } // Tizen::Ui diff --git a/src/ui/FUi_TouchEventManagerImpl.cpp b/src/ui/FUi_TouchEventManagerImpl.cpp new file mode 100644 index 0000000..f31dce9 --- /dev/null +++ b/src/ui/FUi_TouchEventManagerImpl.cpp @@ -0,0 +1,131 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchEventManagerImpl.cpp + * @brief This is the implementation file for %_TouchEventManagerImpl class + * @version 2.0 + * + * This file contains the implementation of %_TouchEventManagerImpl class. + * + */ + +#include +#include +#include "FUi_TouchEventArg.h" +#include "FUi_TouchEventManagerImpl.h" +#include "FUi_TouchManager.h" + +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui +{ + +_TouchEventManagerImpl::_TouchEventManagerImpl(void) +{ +} + +_TouchEventManagerImpl::~_TouchEventManagerImpl(void) +{ +} + +IListT* +_TouchEventManagerImpl::GetTouchInfoListN(void) const +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, null, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + LinkedListT* pTouchEventInfoList = new (std::nothrow) LinkedListT; + SysTryReturn(NID_UI, pTouchEventInfoList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::Collection::IListT<_FingerInfo*>* pFingerInfoList = pTouchManager->GetMultiFingerInfoListN(); + SysTryCatch(NID_UI, pFingerInfoList, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + for (int i = 0; i < pFingerInfoList->GetCount(); i++) + { + _FingerInfo* pFingerInfo = null; + pFingerInfoList->GetAt(i, pFingerInfo); + + if (pFingerInfo == null) + { + continue; + } + + if (pFingerInfo->GetStatus() == _TOUCH_PRESSED || pFingerInfo->GetStatus() == _TOUCH_MOVED || pFingerInfo->GetStatus() == _TOUCH_CANCELED) + { + TouchEventInfo* pTouchEventInfo = new (std::nothrow) TouchEventInfo; + SysTryCatch(NID_UI, pTouchEventInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + _Control* pControl = pTouchManager->GetTouchControlSource(); + if (pControl) + { + _ControlImpl* pImpl = static_cast<_ControlImpl*>(pControl->GetUserData()); + + _TouchStatus touchStatus = pFingerInfo->GetStatus(); + if (pFingerInfo->GetStatus() != _TOUCH_CANCELED) + { + touchStatus = _TOUCH_PRESSED; + } + + _TouchEventArg touchEventArg(pImpl->GetPublic(), touchStatus); + touchEventArg.SetTouchPosition(pFingerInfo->GetPointId(), pFingerInfo->GetStartPoint().x, pFingerInfo->GetStartPoint().y, pFingerInfo->GetPoint().x, pFingerInfo->GetPoint().y); + pTouchEventInfo->Construct(touchEventArg); + + pTouchEventInfoList->Add(pTouchEventInfo); + } + } + } + + delete pFingerInfoList; + pFingerInfoList = null; + + return pTouchEventInfoList; + +CATCH: + if (pTouchEventInfoList) + { + IEnumeratorT* pEnumerator = pTouchEventInfoList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + TouchEventInfo* pTouchEventInfo = null; + pEnumerator->GetCurrent(pTouchEventInfo); + if (!pTouchEventInfo) + { + continue; + } + + delete pTouchEventInfo; + } + delete pEnumerator; + } + + pTouchEventInfoList->RemoveAll();; + delete pTouchEventInfoList; + pTouchEventInfoList = null; + } + + if (pFingerInfoList) + { + delete pFingerInfoList; + pFingerInfoList = null; + } + + return null; +} + +}} //Tizen::Ui diff --git a/src/ui/FUi_TouchFlickGestureDetector.cpp b/src/ui/FUi_TouchFlickGestureDetector.cpp new file mode 100644 index 0000000..0aab8ac --- /dev/null +++ b/src/ui/FUi_TouchFlickGestureDetector.cpp @@ -0,0 +1,569 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchFlickGestureDetector.cpp + * @brief This is the implementation file for %_TouchFlickGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %_TouchFlickGestureDetector class. + * + */ + +#include +#include +#include +#include "FUi_TouchManager.h" +#include "FUi_TouchFlickGestureDetector.h" +#include "FUi_ITouchFlickGestureEventListener.h" +#include "FUi_TouchFlickGestureDetectorImpl.h" + +using namespace Tizen::Base::Utility; +using namespace Tizen::System; +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui +{ + +namespace{ +const int MAX_VALUE = -10000; +const int MIN_VALUE = 10000; +const int IGNORE_OVERSHOOT_TIME = 80; +const int IGNORE_OVERSHOOT_MM = 5; +const int DIRECT_MOVE_TIME = 80;; +const int DIRECT_MOVE_MM = 3; +const int MAX_TIME_WND = 200; +const int MIN_TIME_WND = 30; +const int FIRST_MOVE_BOUND_MM = 2; +const int MM_H = 72; +const int RES_H = 800; +const int IGNORE_OVERSHOOT_PXL = IGNORE_OVERSHOOT_MM * RES_H / MM_H; +const int DIRECT_MOVE_PXL = DIRECT_MOVE_MM * RES_H / MM_H; +const int MIN_MOVE_PXL = FIRST_MOVE_BOUND_MM * RES_H / MM_H; +const unsigned int FIRST_POINT_ID = 0; +} + +/* lcd size 480x800 DEVICE_SIZE_VERTICAL 72 + * lcd size 240x400 DEVICE_SIZE_VERTICAL 66 + * lcd size 320x480 DEVICE_SIZE_VERTICAL 66 + * + * RES_H = lcd size(height) + * */ +_TouchFlickGestureDetector::_TouchFlickGestureDetector(void) + : __xDistance(0) + , __yDistance(0) + , __duration(0) + , __direction(_FLICK_DIRECTION_NONE) + , __maxMoveX(MAX_VALUE) + , __minMoveX(MIN_VALUE) + , __maxMoveY(MAX_VALUE) + , __minMoveY(MIN_VALUE) + , __pFlickInfoList(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, GetErrorMessage(r)); + + SetDetectorType(_TOUCH_GESTURE_DETECTOR_TYPE_FLICK); + + __pFlickInfoList = new (std::nothrow) ArrayListT<_FlickInfo*>; + SysTryReturnVoidResult(NID_UI, __pFlickInfoList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return; +} + +_TouchFlickGestureDetector::~_TouchFlickGestureDetector(void) +{ + ClearVariables(); + + delete __pFlickInfoList; + __pFlickInfoList = null; +} + +void +_TouchFlickGestureDetector::CheckMoveMinMax(const int x, const int y) +{ + if (x > __maxMoveX) + { + __maxMoveX = x; + } + + if (x < __minMoveX) + { + __minMoveX = x; + } + + if (y > __maxMoveY) + { + __maxMoveY = y; + } + + if (y < __minMoveY) + { + __minMoveY = y; + } +} + +void +_TouchFlickGestureDetector::ClearVariables(void) +{ + __maxMoveX = -10000; + __minMoveX = 10000; + __maxMoveY = -10000; + __minMoveY = 10000; + + for (int i = 0; i < __pFlickInfoList->GetCount(); i++) + { + _FlickInfo* pFlickInfo = null; + __pFlickInfoList->GetAt(i, pFlickInfo); + + if (pFlickInfo) + { + delete pFlickInfo; + } + } + + __pFlickInfoList->RemoveAll(); +} + +bool +_TouchFlickGestureDetector::FindFlickWindow(const ArrayListT<_FlickInfo*>* pList, const _FlickInfo* pFlickInfo, int* pStartIndex, int* pEndIndex) +{ + int pointCount = pList->GetCount(); + int endIdx = pointCount - 1; + + enum + { + FD_NONE = 0, FD_RIGHT = 0x1, FD_UP = 0x2, FD_LEFT = 0x4, FD_DOWN = 0x8 + }; + + int dirOpp = FD_NONE; + int dir = FD_NONE; + int deltaX = 0, deltaY = 0; + + int i = 0; + for (i = endIdx - 1; i > 0; i--) + { + bool isDirChanged = false; + int distanceX = 0; + int distanceY = 0; + _FlickInfo* pVecPoints = null; + _FlickInfo* pPrevVecPoints = null; + + pList->GetAt(i, pVecPoints); + pList->GetAt(i - 1, pPrevVecPoints); + + if (pVecPoints && pPrevVecPoints) + { + distanceX = pVecPoints->x - pPrevVecPoints->x; + distanceY = pVecPoints->y - pPrevVecPoints->y; + } + + if (distanceX == 0 && distanceY == 0) + { + continue; + } + else if (distanceX > 0 && distanceX > Math::Abs(distanceY)) // Right + { + dirOpp |= FD_LEFT; + + if (dirOpp & FD_RIGHT) + { + isDirChanged = true; + } + else + { + dir = FD_RIGHT; + } + } + else if (distanceX < 0 && distanceX < -Math::Abs(distanceY)) // Left + { + dirOpp |= FD_RIGHT; + + if (dirOpp & FD_LEFT) + { + isDirChanged = true; + } + else + { + dir = FD_LEFT; + } + } + else if (distanceY > 0 && distanceY >= Math::Abs(distanceX)) // Down + { + dirOpp |= FD_UP; + + if (dirOpp & FD_DOWN) + { + isDirChanged = true; + } + else + { + dir = FD_DOWN; + } + } + else if (distanceY < 0 && distanceY <= -Math::Abs(distanceX)) // Up + { + dirOpp |= FD_DOWN; + + if (dirOpp & FD_UP) + { + isDirChanged = true; + } + else + { + dir = FD_UP; + } + } + + if (isDirChanged) + { + if (pFlickInfo->time - pVecPoints->time < IGNORE_OVERSHOOT_TIME + && Math::Abs(deltaX) < IGNORE_OVERSHOOT_PXL && Math::Abs(deltaY) < IGNORE_OVERSHOOT_PXL) + { + endIdx = i; + dirOpp = FD_NONE; + dir = FD_NONE; + deltaX = distanceX; + deltaY = distanceY; + continue; + } + break; + } + else + { + deltaX += distanceX; + deltaY += distanceY; + } + + if (pFlickInfo->time - pPrevVecPoints->time > DIRECT_MOVE_TIME + && Math::Abs(deltaX) < DIRECT_MOVE_PXL && Math::Abs(deltaY) < DIRECT_MOVE_PXL) + { + --i; + *pStartIndex = i; + *pEndIndex = endIdx; + return false; + } + + if (pFlickInfo->time - pVecPoints->time > MAX_TIME_WND) + { + break; + } + } + + *pStartIndex = i; + *pEndIndex = endIdx; + + switch(dir) + { + case FD_NONE: + __direction = _FLICK_DIRECTION_NONE; + break; + + case FD_RIGHT: + __direction = _FLICK_DIRECTION_RIGHT; + break; + + case FD_LEFT: + __direction = _FLICK_DIRECTION_LEFT; + break; + + case FD_UP: + __direction = _FLICK_DIRECTION_UP; + break; + + case FD_DOWN: + __direction = _FLICK_DIRECTION_DOWN; + break; + + default: + break; + } + return true; +} + +bool +_TouchFlickGestureDetector::CalculateFlick(const ArrayListT<_FlickInfo*>* pList, const _FlickInfo* pFlickInfo, _FlickInfo* pReturnFlick) +{ + enum + { + ITEM_EXECUTION, DIRECT_MOVE, FLICK_START + } + + flickStatus = FLICK_START; + + if ((__maxMoveX - __minMoveX) < MIN_MOVE_PXL + && (__maxMoveY - __minMoveY) < MIN_MOVE_PXL) + { + flickStatus = ITEM_EXECUTION; + + pReturnFlick->x = pReturnFlick->y = 0; + pReturnFlick->time = MIN_TIME_WND; + ClearVariables(); + return (flickStatus != ITEM_EXECUTION); + } + + int startIdx = 0; + int endIdx = 0; + int endPosX = 0; + int endPosY = 0; + int endTime = 0; + int startPosX = 0; + int startPosY = 0; + int startTime = 0; + int distanceX = 0; + int distanceY = 0; + int time = 0; + + if (!FindFlickWindow(pList, pFlickInfo, &startIdx, &endIdx)) + { + flickStatus = DIRECT_MOVE; + } + + _FlickInfo* pEndVecPoint = null; + _FlickInfo* pStartVecPoint = null; + + pList->GetAt(endIdx, pEndVecPoint); + pList->GetAt(startIdx, pStartVecPoint); + + if (pEndVecPoint) + { + endPosX = pEndVecPoint->x; + endPosY = pEndVecPoint->y; + } + endTime = pFlickInfo->time; + + if (pStartVecPoint) + { + startPosX = pStartVecPoint->x; + startPosY = pStartVecPoint->y; + startTime = pStartVecPoint->time; + } + + distanceX = endPosX - startPosX; + distanceY = endPosY - startPosY; + time = endTime - startTime; + + if (time < MIN_TIME_WND) + { + time = MIN_TIME_WND; + } + + pReturnFlick->x = distanceX; + pReturnFlick->y = distanceY; + pReturnFlick->time = time; + + if (flickStatus == DIRECT_MOVE) + { + pReturnFlick->x = pReturnFlick->y = 0; + } + + ClearVariables(); + return true; +} + +result +_TouchFlickGestureDetector::OnTouchDown(ArrayListT<_FlickInfo*>* pList, const _FlickInfo* pFlickInfo) +{ + result r = pList->Add(const_cast<_FlickInfo*>(pFlickInfo)); + SysTryReturnResult(NID_UI, r == E_SUCCESS, r, "%s", GetErrorMessage(r)); + + CheckMoveMinMax(pFlickInfo->x, pFlickInfo->y); + + return E_SUCCESS; +} + +result +_TouchFlickGestureDetector::OnTouchMove(ArrayListT<_FlickInfo*>* pList, const _FlickInfo* pFlickInfo) +{ + result r = pList->Add(const_cast<_FlickInfo*>(pFlickInfo)); + SysTryReturnResult(NID_UI, r == E_SUCCESS, r, "%s", GetErrorMessage(r)); + + CheckMoveMinMax(pFlickInfo->x, pFlickInfo->y); + + return E_SUCCESS; +} + +result +_TouchFlickGestureDetector::OnTouchUp(ArrayListT<_FlickInfo*>* pList, const _FlickInfo* pFlickInfo, _FlickInfo* pReturnFlick, bool& isFlicked) +{ + result r = pList->Add(const_cast<_FlickInfo*>(pFlickInfo)); + SysTryReturnResult(NID_UI, r == E_SUCCESS, r, "%s", GetErrorMessage(r)); + + CheckMoveMinMax(pFlickInfo->x, pFlickInfo->y); + + _FlickInfo* pTempVecPoint = null; + bool flickEnable = false; + + int count = pList->GetCount(); + for(int i=0; i < count; i++) + { + pList->GetAt(i, pTempVecPoint); + if(pTempVecPoint->touchStatus == _TOUCH_MOVED) + { + flickEnable = true; + break; + } + } + + isFlicked = flickEnable?(CalculateFlick(pList, pFlickInfo, pReturnFlick)):false; + + return E_SUCCESS; +} + +bool +_TouchFlickGestureDetector::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (touchinfo.GetPointId() != FIRST_POINT_ID) + { + return false; + } + + _FlickInfo* pFlickInfo = new (std::nothrow) _FlickInfo; + SysTryReturn(NID_UI, pFlickInfo, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pFlickInfo->time = touchinfo.GetTimeStamp(); + pFlickInfo->x = touchinfo.GetCurrentPosition().x; + pFlickInfo->y = touchinfo.GetCurrentPosition().y; + pFlickInfo->touchStatus = touchinfo.GetTouchStatus(); + + __xDistance = 0; + __yDistance = 0; + __duration = 0; + __direction = _FLICK_DIRECTION_NONE; + + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_READY); + SetGestureStart(true); + + result r = OnTouchDown(__pFlickInfoList, pFlickInfo); + if (r != E_SUCCESS) + { + delete pFlickInfo; + } + + return false; +} + +bool +_TouchFlickGestureDetector::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (touchinfo.GetPointId() != FIRST_POINT_ID) + { + return false; + } + + _FlickInfo* pFlickInfo = new (std::nothrow) _FlickInfo; + SysTryReturn(NID_UI, pFlickInfo, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pFlickInfo->time = touchinfo.GetTimeStamp(); + pFlickInfo->x = touchinfo.GetCurrentPosition().x; + pFlickInfo->y = touchinfo.GetCurrentPosition().y; + pFlickInfo->touchStatus = touchinfo.GetTouchStatus(); + + result r = OnTouchMove(__pFlickInfoList, pFlickInfo); + if (r != E_SUCCESS) + { + delete pFlickInfo; + } + + return false; +} + +bool +_TouchFlickGestureDetector::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (touchinfo.GetPointId() != FIRST_POINT_ID) + { + return false; + } + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, false, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist."); + + _FlickInfo returnedFlickInfo = {0, }; + + _FlickInfo* pFlickInfo = new (std::nothrow) _FlickInfo; + SysTryReturn(NID_UI, pFlickInfo, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pFlickInfo->time = touchinfo.GetTimeStamp(); + pFlickInfo->x = touchinfo.GetCurrentPosition().x; + pFlickInfo->y = touchinfo.GetCurrentPosition().y; + pFlickInfo->touchStatus = touchinfo.GetTouchStatus(); + + bool isFlicked = false; + + if (pTouchManager->GetPointCount() > 1) //supports only one finger count + { + delete pFlickInfo; + ClearVariables(); + } + else + { + result r = OnTouchUp(__pFlickInfoList, pFlickInfo, &returnedFlickInfo, isFlicked); + if (r != E_SUCCESS) + { + delete pFlickInfo; + } + } + + SetGestureStart(false); + if (isFlicked && (returnedFlickInfo.x != 0 || returnedFlickInfo.y != 0)) + { + __xDistance = returnedFlickInfo.x; + __yDistance = returnedFlickInfo.y; + __duration = returnedFlickInfo.time; + + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_SUCCESS); + } + else + { + __xDistance = 0; + __yDistance = 0; + __duration = 0; + + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_FAILED); + } + + return false; +} + +bool +_TouchFlickGestureDetector::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearVariables(); + + return false; +} + +void +_TouchFlickGestureDetector::GetDistance(int& x, int &y) const +{ + x = __xDistance; + y = __yDistance; +} + +int +_TouchFlickGestureDetector::GetDuration(void) const +{ + return __duration; +} + +_FlickDirection +_TouchFlickGestureDetector::GetDirection(void) const +{ + return __direction; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_TouchFlickGestureDetectorImpl.cpp b/src/ui/FUi_TouchFlickGestureDetectorImpl.cpp new file mode 100644 index 0000000..575a140 --- /dev/null +++ b/src/ui/FUi_TouchFlickGestureDetectorImpl.cpp @@ -0,0 +1,112 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchFlickGestureDetectorImpl.cpp + * @brief This is the implementation file for %_TouchFlickGestureDetectorImpl class + * @version 2.0 + * + * This file contains the implementation of %_TouchFlickGestureDetectorImpl class. + * + */ + +#include +#include "FUi_TouchFlickGestureDetectorImpl.h" +#include "FUi_TouchFlickGestureDetector.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +_TouchFlickGestureDetectorImpl::_TouchFlickGestureDetectorImpl(TouchFlickGestureDetector* pPublic, _TouchFlickGestureDetector* pCore) + : _TouchGestureDetectorImpl(pPublic, pCore) +{ +} + +_TouchFlickGestureDetectorImpl::~_TouchFlickGestureDetectorImpl(void) +{ +} + +_TouchFlickGestureDetectorImpl* +_TouchFlickGestureDetectorImpl::CreateInstanceN(TouchFlickGestureDetector* pPublic) +{ + ClearLastResult(); + + _TouchFlickGestureDetector* pCore = null; + pCore = new (std::nothrow) _TouchFlickGestureDetector; + SysTryReturn(NID_UI, pCore, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is shortage."); + + _TouchFlickGestureDetectorImpl* pImpl = new (std::nothrow) _TouchFlickGestureDetectorImpl(pPublic, pCore); + SysTryCatch(NID_UI, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is shortage."); + + return pImpl; + +CATCH: + delete pCore; + + return null; +} + +_TouchFlickGestureDetectorImpl* +_TouchFlickGestureDetectorImpl::GetInstance(TouchFlickGestureDetector& gestureDetector) +{ + return static_cast<_TouchFlickGestureDetectorImpl*> (gestureDetector.__pTouchGestureDetectorImpl); +} + +const _TouchFlickGestureDetectorImpl* +_TouchFlickGestureDetectorImpl::GetInstance(const TouchFlickGestureDetector& gestureDetector) +{ + return static_cast (gestureDetector.__pTouchGestureDetectorImpl); +} + +const _TouchFlickGestureDetector& +_TouchFlickGestureDetectorImpl::GetCore(void) const +{ + return static_cast(_TouchGestureDetectorImpl::GetCore()); +} + +_TouchFlickGestureDetector& +_TouchFlickGestureDetectorImpl::GetCore(void) +{ + return static_cast<_TouchFlickGestureDetector&>(_TouchGestureDetectorImpl::GetCore()); +} + +result +_TouchFlickGestureDetectorImpl::GetDistance(int &x, int &y) const +{ + GetCore().GetDistance(x, y); + + return E_SUCCESS; +} + +int +_TouchFlickGestureDetectorImpl::GetDuration(void) const +{ + ClearLastResult(); + + return GetCore().GetDuration(); +} + +FlickDirection +_TouchFlickGestureDetectorImpl::GetDirection(void) const +{ + ClearLastResult(); + + return static_cast(GetCore().GetDirection()); +} + +}} //Tizen::Ui diff --git a/src/ui/FUi_TouchGestureDetector.cpp b/src/ui/FUi_TouchGestureDetector.cpp new file mode 100644 index 0000000..da4d81e --- /dev/null +++ b/src/ui/FUi_TouchGestureDetector.cpp @@ -0,0 +1,1175 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchGestureDetector.cpp + * @brief This is the implementation file for %_TouchGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %_TouchGestureDetector class. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_TouchManager.h" +#include "FUi_ITouchFlickGestureEventListener.h" +#include "FUi_ITouchLongPressGestureEventListener.h" +#include "FUi_ITouchTapGestureEventListener.h" +#include "FUi_ITouchPinchGestureEventListener.h" +#include "FUi_ITouchPanningGestureEventListener.h" +#include "FUi_ITouchRotationGestureEventListener.h" +#include "FUi_ITouchCustomGestureEventListener.h" +#include "FUi_TouchFlickGestureDetectorImpl.h" +#include "FUi_TouchLongPressGestureDetectorImpl.h" +#include "FUi_TouchTapGestureDetectorImpl.h" +#include "FUi_TouchPinchGestureDetectorImpl.h" +#include "FUi_TouchPanningGestureDetectorImpl.h" +#include "FUi_TouchRotationGestureDetectorImpl.h" +#include "FUi_ControlManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +_TouchGestureDetector::_TouchGestureDetector(void) + : __isTouchEventDelayed(false) + , __isTouchCanceledOnSuccess(false) + , __isDetectionStarted(false) + , __currentState(_TOUCH_GESTURE_DETECTOR_STATE_READY) + , __type(_TOUCH_GESTURE_DETECTOR_TYPE_CUSTOM) + , __pUserData(null) + , __pDelegator(null) + , __pWantToFailList(null) + , __pCurrentWantToFailList(null) + , __pEventListenerList(null) +{ + ClearLastResult(); + + __pEventListenerList = new (std::nothrow) LinkedListT<_ITouchGestureEventListener*>; + SysTryReturnVoidResult(NID_UI, __pEventListenerList, + E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pWantToFailList = new (std::nothrow) LinkedListT<_TouchGestureDetector*>; + SysTryCatch(NID_UI, __pWantToFailList, , + E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pCurrentWantToFailList = new (std::nothrow) LinkedListT<_TouchGestureDetector*>; + SysTryCatch(NID_UI, __pCurrentWantToFailList, , + E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pDelegator = this; + + return; + +CATCH: + if (__pEventListenerList) + { + delete __pEventListenerList; + __pEventListenerList = null; + } + + if (__pWantToFailList) + { + delete __pWantToFailList; + __pWantToFailList = null; + } + + if (__pCurrentWantToFailList) + { + delete __pCurrentWantToFailList; + __pCurrentWantToFailList = null; + } +} + +_TouchGestureDetector::~_TouchGestureDetector(void) +{ + delete __pEventListenerList; + __pEventListenerList = null; + + delete __pWantToFailList; + __pWantToFailList = null; + + delete __pCurrentWantToFailList; + __pCurrentWantToFailList = null; + + __pDelegator = null; +} + +result +_TouchGestureDetector::AddGestureListener(const _ITouchGestureEventListener& listener) +{ + bool exist = __pEventListenerList->Contains(const_cast <_ITouchGestureEventListener*>(&listener)); + if (!exist) + { + SysTryReturnResult(NID_UI, + __pEventListenerList->Add(const_cast <_ITouchGestureEventListener*>(&listener)) == E_SUCCESS, E_SYSTEM, + "[E_SYSTEM] System error occurred."); + } + + return E_SUCCESS; +} + +result +_TouchGestureDetector::RemoveGestureListener(const _ITouchGestureEventListener& listener) +{ + if (__pEventListenerList->GetCount() == 0) + { + return E_INVALID_CONDITION; + } + + SysTryReturnResult(NID_UI, + __pEventListenerList->Remove(const_cast <_ITouchGestureEventListener*>(&listener)) == E_SUCCESS, E_SYSTEM, + "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; +} + +IListT <_ITouchGestureEventListener*>* +_TouchGestureDetector::GetGestureListenerList(void) const +{ + return __pEventListenerList; +} + +void +_TouchGestureDetector::SetDelegate(const _ITouchGestureDelegate& delegator) +{ + __pDelegator = const_cast<_ITouchGestureDelegate*>(&delegator); +} + +_ITouchGestureDelegate* +_TouchGestureDetector::GetDelegate(void) const +{ + return __pDelegator; +} + +result +_TouchGestureDetector::SetControl(const _Control& control) +{ + __gestureContol = control.GetHandle(); + + return E_SUCCESS; +} + +_Control* +_TouchGestureDetector::GetControl(void) const +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist."); + + return pControlManager->GetObject(__gestureContol); +} + +_TouchGestureDetectorState +_TouchGestureDetector::GetDetectorState(void) const +{ + return __currentState; +} + +void +_TouchGestureDetector::SetDetectorType(_TouchGestureDetectorType type) +{ + __type = type; +} + +_TouchGestureDetectorType +_TouchGestureDetector::GetDetectorType(void) const +{ + return __type; +} + +void +_TouchGestureDetector::SetDelayTouchEventEnabled(bool enabled) +{ + __isTouchEventDelayed = enabled; +} + +bool +_TouchGestureDetector::IsDelayTouchEventEnabled(void) const +{ + return __isTouchEventDelayed; +} + +void +_TouchGestureDetector::SetCancelTouchEventOnSuccessEnabled(bool enabled) +{ + __isTouchCanceledOnSuccess = enabled; +} + +bool +_TouchGestureDetector::IsCancelTouchEventOnSuccessEnabled(void) const +{ + return __isTouchCanceledOnSuccess; +} + +void +_TouchGestureDetector::SetUserData(void* pUserData) +{ + __pUserData = pUserData; +} + +void* +_TouchGestureDetector::GetUserData(void) const +{ + return __pUserData; +} + +bool +_TouchGestureDetector::ExistWaitingList(void) const +{ + bool exist = false; + + if (__pCurrentWantToFailList && (__pCurrentWantToFailList->GetCount() > 0)) + { + exist = true; + } + + return exist; +} + +result +_TouchGestureDetector::StartOnFailureOf(const _TouchGestureDetector& gesture) +{ + SysTryReturnResult(NID_UI, IsPossibleToAddFailList(gesture), E_SYSTEM, "[E_SYSTEM] param gesture also waits you to fail."); + + _TouchGestureDetector* pGesture = const_cast < _TouchGestureDetector* >(&gesture); + bool exist = __pWantToFailList->Contains(pGesture); + if (!exist) + { + SysTryReturnResult(NID_UI, __pWantToFailList->Add(pGesture) == E_SUCCESS, + E_SYSTEM, "[E_SYSTEM] System error occurred."); + } + + return E_SUCCESS; +} + +bool +_TouchGestureDetector::IsPossibleToAddFailList(const _TouchGestureDetector& gesture) +{ + IListT<_TouchGestureDetector*>* pList = gesture.GetWantToFailList(); + if (pList == null) + { + return true; + } + + IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGesture = null; + pEnumerator->GetCurrent(pGesture); + if (pGesture == null) + { + continue; + } + + if (pGesture == this) + { + delete pEnumerator; + return false; + } + } + delete pEnumerator; + } + return true; +} + +void +_TouchGestureDetector::SetDetectorState(_TouchGestureDetectorState state) +{ + __currentState = state; + + if (state == _TOUCH_GESTURE_DETECTOR_STATE_READY) + { + IEnumeratorT<_TouchGestureDetector*>* pEnumerator = __pWantToFailList->GetEnumeratorN(); + + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGesture = null; + pEnumerator->GetCurrent(pGesture); + if (pGesture == null) + { + continue; + } + + bool exist = __pCurrentWantToFailList->Contains(pGesture); + if (!exist) + { + __pCurrentWantToFailList->Add(pGesture); + } + } + delete pEnumerator; + } + } + + if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED || state == _TOUCH_GESTURE_DETECTOR_STATE_CHANGED || state == _TOUCH_GESTURE_DETECTOR_STATE_FINISHED) + { + if (ExistWaitingList()) + { + __isDetectionStarted = true; + __currentState = _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS_AND_WAIT; + return; + } + + _Control* pControl = GetControl(); + if (pControl) + { + IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = pControl->GetStartedGestureDetectorEnumeratorN(); + if (pMapEnumerator) + { + while(pMapEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pStartedGestureDetector = null; + pMapEnumerator->GetKey(pStartedGestureDetector); + + if (pStartedGestureDetector && (pStartedGestureDetector == this)) + { + _TouchGestureDetectorEventType eventType = pStartedGestureDetector->GetGestureDetectorEventType(); + if (eventType == _TOUCH_GESTURE_DETECTOR_EVENT_TYPE_DISCRETE || + (eventType == _TOUCH_GESTURE_DETECTOR_EVENT_TYPE_CONTINUOUS && state == _TOUCH_GESTURE_DETECTOR_STATE_FINISHED)) + { + pControl->SetStartedGestureDetector(*this, _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS); + } + } + } + delete pMapEnumerator; + } + } + + ProcessPublicListener(*this); + ProcessCoreListener(*this); + NotifyStateChanged(); + } + else if (state == _TOUCH_GESTURE_DETECTOR_STATE_FAILED) + { + _Control* pControl = GetControl(); + if (pControl) + { + IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = pControl->GetStartedGestureDetectorEnumeratorN(); + if (pMapEnumerator) + { + while(pMapEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pStartedGestureDetector = null; + pMapEnumerator->GetKey(pStartedGestureDetector); + + if (pStartedGestureDetector && (pStartedGestureDetector == this)) + { + pControl->SetStartedGestureDetector(*this, _TOUCH_GESTURE_DETECTOR_STATE_FAILED); + } + } + delete pMapEnumerator; + } + } + + NotifyStateChanged(); + } + else if (state == _TOUCH_GESTURE_DETECTOR_STATE_CANCELED) + { + if (!IsGestureStarted()) + { + SetToDefaultState(); + } + + SetGestureStart(false); + } + + _TouchGestureDetectorState currentState = GetDetectorState(); + if (( !__isDetectionStarted && currentState == _TOUCH_GESTURE_DETECTOR_STATE_FINISHED) || currentState == _TOUCH_GESTURE_DETECTOR_STATE_FAILED || currentState == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS) + { + SetToDefaultState(); + } +} + +void +_TouchGestureDetector::SetToDefaultState(void) +{ + __pCurrentWantToFailList->RemoveAll(); + __isDetectionStarted = false; + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_READY); +} + +_TouchGestureDetectorEventType +_TouchGestureDetector::GetGestureDetectorEventType(void) +{ + _TouchGestureDetectorType type = GetDetectorType(); + + if (type == _TOUCH_GESTURE_DETECTOR_TYPE_PINCH ||type == _TOUCH_GESTURE_DETECTOR_TYPE_CUSTOM + ||type == _TOUCH_GESTURE_DETECTOR_TYPE_ROTATION || type == _TOUCH_GESTURE_DETECTOR_TYPE_PANNING) + { + return _TOUCH_GESTURE_DETECTOR_EVENT_TYPE_CONTINUOUS; + } + else + { + return _TOUCH_GESTURE_DETECTOR_EVENT_TYPE_DISCRETE; + } +} + +String +_TouchGestureDetector::GetDescription(void) +{ + String type(L""); + + switch (GetDetectorType()) + { + case _TOUCH_GESTURE_DETECTOR_TYPE_CUSTOM: + type = L"_TOUCH_GESTURE_DETECTOR_TYPE_CUSTOM"; + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_TAP: + type = L"_TOUCH_GESTURE_DETECTOR_TYPE_TAP"; + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS: + type = L"_TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS"; + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_PINCH: + type = L"_TOUCH_GESTURE_DETECTOR_TYPE_PINCH"; + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_FLICK: + type = L"_TOUCH_GESTURE_DETECTOR_TYPE_FLICK"; + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_ROTATION: + type = L"_TOUCH_GESTURE_DETECTOR_TYPE_ROTATION"; + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_PANNING: + type = L"_TOUCH_GESTURE_DETECTOR_TYPE_PANNING"; + break; + + default: + break; + } + + String description(L""); + + description.Format(LOG_LEN_MAX, L"%ls state(%d) delay(%d) cancelonSuccess(%d)", + type.GetPointer(), GetDetectorState(), + IsDelayTouchEventEnabled(), IsCancelTouchEventOnSuccessEnabled()); + + return description; +} + +IListT <_TouchGestureDetector*>* +_TouchGestureDetector::GetWantToFailList(void) const +{ + return __pWantToFailList; +} + +void +_TouchGestureDetector::ProcessPublicListener(_TouchGestureDetector& gesture) +{ + _TouchGestureDetectorImpl* pImpl = static_cast<_TouchGestureDetectorImpl*>(gesture.GetUserData()); + if (!pImpl) + { + return; + } + + IListT* pPublicList = pImpl->GetGestureEventListenerList(); + if (!pPublicList) + { + return; + } + + IEnumeratorT* pEnumerator = pPublicList->GetEnumeratorN(); + SysTryReturnVoidResult(NID_UI, pEnumerator, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + while(pEnumerator->MoveNext() == E_SUCCESS) + { + ITouchGestureEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + + if (pListener == null) + { + continue; + } + + switch(gesture.GetDetectorType()) + { + case _TOUCH_GESTURE_DETECTOR_TYPE_TAP: + { + ITouchTapGestureEventListener* pPublicListener = dynamic_cast(pListener); + TouchTapGestureDetector* pPublicGestureDetector = dynamic_cast(dynamic_cast(&pImpl->GetPublic())); + + if (pPublicListener && pPublicGestureDetector) + { + if (gesture.GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_CANCELED) + { + pPublicListener->OnTapGestureCanceled(*pPublicGestureDetector); + gesture.SetToDefaultState(); + } + else if (gesture.GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS) + { + pPublicListener->OnTapGestureDetected(*pPublicGestureDetector); + } + } + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS: + { + ITouchLongPressGestureEventListener* pPublicListener = dynamic_cast(pListener); + TouchLongPressGestureDetector* pPublicGestureDetector = dynamic_cast(dynamic_cast(&pImpl->GetPublic())); + + if (pPublicListener && pPublicGestureDetector) + { + if (gesture.GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_CANCELED) + { + pPublicListener->OnLongPressGestureCanceled(*pPublicGestureDetector); + gesture.SetToDefaultState(); + } + else if (gesture.GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS) + { + pPublicListener->OnLongPressGestureDetected(*pPublicGestureDetector); + } + } + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_PINCH: + { + ITouchPinchGestureEventListener* pPublicListener = dynamic_cast(pListener); + TouchPinchGestureDetector* pPublicGestureDetector = dynamic_cast(dynamic_cast(&pImpl->GetPublic())); + + if (pPublicListener && pPublicGestureDetector) + { + switch(gesture.GetDetectorState()) + { + case _TOUCH_GESTURE_DETECTOR_STATE_STARTED: + pPublicListener->OnPinchGestureStarted(*pPublicGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CHANGED: + pPublicListener->OnPinchGestureChanged(*pPublicGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_FINISHED: + pPublicListener->OnPinchGestureFinished(*pPublicGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CANCELED: + pPublicListener->OnPinchGestureCanceled(*pPublicGestureDetector); + gesture.SetToDefaultState(); + break; + + default: + break; + } + } + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_FLICK: + { + ITouchFlickGestureEventListener* pPublicListener = dynamic_cast(pListener); + TouchFlickGestureDetector* pPublicGestureDetector = dynamic_cast(dynamic_cast(&pImpl->GetPublic())); + + if (pPublicListener && pPublicGestureDetector) + { + if (gesture.GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_CANCELED) + { + pPublicListener->OnFlickGestureCanceled(*pPublicGestureDetector); + gesture.SetToDefaultState(); + } + else if (gesture.GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS) + { + pPublicListener->OnFlickGestureDetected(*pPublicGestureDetector); + } + } + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_ROTATION: + { + ITouchRotationGestureEventListener* pPublicListener = dynamic_cast(pListener); + TouchRotationGestureDetector* pPublicGestureDetector = dynamic_cast(dynamic_cast(&pImpl->GetPublic())); + + if (pPublicListener && pPublicGestureDetector) + { + switch(gesture.GetDetectorState()) + { + case _TOUCH_GESTURE_DETECTOR_STATE_STARTED: + pPublicListener->OnRotationGestureStarted(*pPublicGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CHANGED: + pPublicListener->OnRotationGestureChanged(*pPublicGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_FINISHED: + pPublicListener->OnRotationGestureFinished(*pPublicGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CANCELED: + pPublicListener->OnRotationGestureCanceled(*pPublicGestureDetector); + gesture.SetToDefaultState(); + break; + + default: + break; + } + } + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_PANNING: + { + ITouchPanningGestureEventListener* pPublicListener = dynamic_cast(pListener); + TouchPanningGestureDetector* pPublicGestureDetector = dynamic_cast(dynamic_cast(&pImpl->GetPublic())); + + if (pPublicListener && pPublicGestureDetector) + { + switch(gesture.GetDetectorState()) + { + case _TOUCH_GESTURE_DETECTOR_STATE_STARTED: + pPublicListener->OnPanningGestureStarted(*pPublicGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CHANGED: + pPublicListener->OnPanningGestureChanged(*pPublicGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_FINISHED: + pPublicListener->OnPanningGestureFinished(*pPublicGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CANCELED: + pPublicListener->OnPanningGestureCanceled(*pPublicGestureDetector); + gesture.SetToDefaultState(); + break; + + default: + break; + } + } + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_CUSTOM: + default: + { + ITouchCustomGestureEventListener* pPublicListener = dynamic_cast(pListener); + + if (pPublicListener) + { + switch(gesture.GetDetectorState()) + { + case _TOUCH_GESTURE_DETECTOR_STATE_STARTED: + pPublicListener->OnCustomGestureStarted(pImpl->GetPublic()); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CHANGED: + pPublicListener->OnCustomGestureChanged(pImpl->GetPublic()); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS: + pPublicListener->OnCustomGestureFinished(pImpl->GetPublic()); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CANCELED: + pPublicListener->OnCustomGestureCanceled(pImpl->GetPublic()); + gesture.SetToDefaultState(); + break; + + default: + break; + } + } + } + break; + } + } + delete pEnumerator; +} + +void +_TouchGestureDetector::ProcessCoreListener(_TouchGestureDetector& gesture) +{ + IListT <_ITouchGestureEventListener*>* pList = gesture.GetGestureListenerList(); + if (!pList) + { + return; + } + + IEnumeratorT<_ITouchGestureEventListener*>* pEnumerator = pList->GetEnumeratorN(); + SysTryReturnVoidResult(NID_UI, pEnumerator, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _ITouchGestureEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + + if (pListener == null) + { + continue; + } + + switch(gesture.GetDetectorType()) + { + case _TOUCH_GESTURE_DETECTOR_TYPE_TAP: + { + _ITouchTapGestureEventListener* pCoreListener = dynamic_cast<_ITouchTapGestureEventListener*>(pListener); + _TouchTapGestureDetector* pCoreGestureDetector = dynamic_cast<_TouchTapGestureDetector*>(&gesture); + + if (pCoreListener && pCoreGestureDetector) + { + if (pCoreGestureDetector->GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_CANCELED) + { + pCoreListener->OnTapGestureCanceled(*pCoreGestureDetector); + pCoreGestureDetector->SetToDefaultState(); + } + else if (pCoreGestureDetector->GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS) + { + pCoreListener->OnTapGestureDetected(*pCoreGestureDetector); + } + } + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS: + { + _ITouchLongPressGestureEventListener* pCoreListener = dynamic_cast<_ITouchLongPressGestureEventListener*>(pListener); + _TouchLongPressGestureDetector* pCoreGestureDetector = dynamic_cast<_TouchLongPressGestureDetector*>(&gesture); + + if (pCoreListener && pCoreGestureDetector) + { + if (pCoreGestureDetector->GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_CANCELED) + { + pCoreListener->OnLongPressGestureCanceled(*pCoreGestureDetector); + pCoreGestureDetector->SetToDefaultState(); + } + else if (pCoreGestureDetector->GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS) + { + pCoreListener->OnLongPressGestureDetected(*pCoreGestureDetector); + } + } + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_PINCH: + { + _ITouchPinchGestureEventListener* pCoreListener = dynamic_cast<_ITouchPinchGestureEventListener*>(pListener); + _TouchPinchGestureDetector* pCoreGestureDetector = dynamic_cast<_TouchPinchGestureDetector*>(&gesture); + + if (pCoreListener && pCoreGestureDetector) + { + switch(GetDetectorState()) + { + case _TOUCH_GESTURE_DETECTOR_STATE_STARTED: + pCoreListener->OnPinchGestureStarted(*pCoreGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CHANGED: + pCoreListener->OnPinchGestureChanged(*pCoreGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_FINISHED: + pCoreListener->OnPinchGestureFinished(*pCoreGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CANCELED: + pCoreListener->OnPinchGestureCanceled(*pCoreGestureDetector); + pCoreGestureDetector->SetToDefaultState(); + break; + + default: + break; + } + } + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_FLICK: + { + _ITouchFlickGestureEventListener* pCoreListener = dynamic_cast<_ITouchFlickGestureEventListener*>(pListener); + _TouchFlickGestureDetector* pCoreGestureDetector = dynamic_cast<_TouchFlickGestureDetector*>(&gesture); + + if (pCoreListener && pCoreGestureDetector) + { + if (pCoreGestureDetector->GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_CANCELED) + { + pCoreListener->OnFlickGestureCanceled(*pCoreGestureDetector); + pCoreGestureDetector->SetToDefaultState(); + } + else if (pCoreGestureDetector->GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS) + { + pCoreListener->OnFlickGestureDetected(*pCoreGestureDetector); + } + } + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_ROTATION: + { + _ITouchRotationGestureEventListener* pCoreListener = dynamic_cast<_ITouchRotationGestureEventListener*>(pListener); + _TouchRotationGestureDetector* pCoreGestureDetector = dynamic_cast<_TouchRotationGestureDetector*>(&gesture); + + if (pCoreListener && pCoreGestureDetector) + { + switch(GetDetectorState()) + { + case _TOUCH_GESTURE_DETECTOR_STATE_STARTED: + pCoreListener->OnRotationGestureStarted(*pCoreGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CHANGED: + pCoreListener->OnRotationGestureChanged(*pCoreGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_FINISHED: + pCoreListener->OnRotationGestureFinished(*pCoreGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CANCELED: + pCoreListener->OnRotationGestureCanceled(*pCoreGestureDetector); + pCoreGestureDetector->SetToDefaultState(); + break; + + default: + break; + } + } + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_PANNING: + { + _ITouchPanningGestureEventListener* pCoreListener = dynamic_cast<_ITouchPanningGestureEventListener*>(pListener); + _TouchPanningGestureDetector* pCoreGestureDetector = dynamic_cast<_TouchPanningGestureDetector*>(&gesture); + + if (pCoreListener && pCoreGestureDetector) + { + switch(GetDetectorState()) + { + case _TOUCH_GESTURE_DETECTOR_STATE_STARTED: + pCoreListener->OnPanningGestureStarted(*pCoreGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CHANGED: + pCoreListener->OnPanningGestureChanged(*pCoreGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_FINISHED: + pCoreListener->OnPanningGestureFinished(*pCoreGestureDetector); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CANCELED: + pCoreListener->OnPanningGestureCanceled(*pCoreGestureDetector); + pCoreGestureDetector->SetToDefaultState(); + break; + + default: + break; + } + } + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_CUSTOM: + default: + { + _ITouchCustomGestureEventListener* pCoreListener = dynamic_cast<_ITouchCustomGestureEventListener*>(pListener); + + if (pCoreListener) + { + switch(GetDetectorState()) + { + case _TOUCH_GESTURE_DETECTOR_STATE_STARTED: + pCoreListener->OnCustomGestureStarted(gesture); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CHANGED: + pCoreListener->OnCustomGestureChanged(gesture); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS: + pCoreListener->OnCustomGestureFinished(gesture); + break; + + case _TOUCH_GESTURE_DETECTOR_STATE_CANCELED: + pCoreListener->OnCustomGestureCanceled(gesture); + gesture.SetToDefaultState(); + break; + + default: + break; + } + } + } + break; + } + } + delete pEnumerator; +} + +void +_TouchGestureDetector::NotifyStateChanged(void) +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist."); + + _Control* pControl = GetControl(); + SysTryReturnVoidResult(NID_UI, pControl, E_INVALID_CONDITION, "[E_INVALID_CONDITION] invalid GestureDetectorControl()"); + + IListT<_TouchGestureDetector*>* pGestureList = pControlManager->GetGestureDetectorList(); + if (!pGestureList || (pGestureList && pGestureList->GetCount() == 0)) + { + pGestureList = pControl->GetGestureDetectorList(); + } + + if (pGestureList) + { + IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pGestureList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGestureDetector = null; + pEnumerator->GetCurrent(pGestureDetector); + if (pGestureDetector == null || !pGestureDetector->ExistWaitingList()) + { + continue; + } + + IListT<_TouchGestureDetector*>* pWaitingList = pGestureDetector->GetWantToFailList(); + if (pWaitingList) + { + IEnumeratorT<_TouchGestureDetector*>* pWaitingEnumerator = pWaitingList->GetEnumeratorN(); + if (pWaitingEnumerator) + { + while(pWaitingEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pWaitingGestureDetector = null; + pWaitingEnumerator->GetCurrent(pWaitingGestureDetector); + if (pWaitingGestureDetector == null) + { + continue; + } + + if (pWaitingGestureDetector == this) + { + pGestureDetector->OnGestureDetectorStateChanged(*this); + } + } + delete pWaitingEnumerator; + } + } + } + delete pEnumerator; + } + } + + ProcessGestureCondition(); +} + +void +_TouchGestureDetector::ProcessGestureCondition(void) +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist."); + + _Control* pControl = GetControl(); + SysTryReturnVoidResult(NID_UI, pControl, E_INVALID_CONDITION, "[E_INVALID_CONDITION] invalid GestureDetectorControl()"); + + //send delayed touch event when all gestures set delayed touch events decided its state(success or failed) and all failed. + if (!pControl->IsDelayedTouchEventEnabled() && pControl->IsPossibleToSendDelayedTouchEvent() && !pControl->IsSentDelayedEvent()) + { + SendDelayedTouchEvent(pControl); + } + + if (pControl->IsCancelOnGestureSuccess()) + { + pTouchManager->SetTouchCanceled(true, true); + pTouchManager->SetTouchCanceledOnGestureSuccess(true); + } + + bool allDetected = true; + IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = pControl->GetStartedGestureDetectorEnumeratorN(); + if (pMapEnumerator) + { + while(pMapEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY; + pMapEnumerator->GetValue(state); + + if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED) + { + allDetected = false; + break; + } + } + delete pMapEnumerator; + } + + if (allDetected) + { + pControl->ClearStartedGestureDetectorList(); + } +} + +void +_TouchGestureDetector::SendDelayedTouchEvent(_Control* pControl) +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist."); + + //send delayed event if all started gesture are failed. + IListT<_TouchInfo*>* pList = pControl->GetTouchInfoList(); + if (pList) + { + IEnumeratorT<_TouchInfo*>* pEnumerator = pList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchInfo* pTouchInfo = null; + pEnumerator->GetCurrent(pTouchInfo); + if (pTouchInfo == null) + { + continue; + } + + pControl->SetSendingDelayedEvent(true); + pTouchManager->SendEvent(pControl, *pTouchInfo); + } + delete pEnumerator; + pControl->SetSendingDelayedEvent(false); + pControl->SetSentDelayedEvent(true); + } + } +} + +IListT<_TouchGestureDetector*>* +_TouchGestureDetector::GetCurrentWantToFailList(void) const +{ + return __pCurrentWantToFailList; +} + +void +_TouchGestureDetector::OnGestureDetectorStateChanged(const _TouchGestureDetector& gestureDetector) +{ + if (GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS_AND_WAIT) + { + _TouchGestureDetectorState state = gestureDetector.GetDetectorState(); + if (state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_FAILED); + } + else if (state == _TOUCH_GESTURE_DETECTOR_STATE_FAILED) + { + IListT<_TouchGestureDetector*>* pWaitingList = GetCurrentWantToFailList(); + if (pWaitingList) + { + bool exist = pWaitingList->Contains(const_cast<_TouchGestureDetector*>(&gestureDetector)); + if (exist) + { + _TouchGestureDetector* pGestureDetector = const_cast<_TouchGestureDetector*>(&gestureDetector); + pWaitingList->Remove(pGestureDetector); + } + } + _TouchGestureDetectorType type = GetDetectorType(); + if (type != _TOUCH_GESTURE_DETECTOR_TYPE_PINCH && type != _TOUCH_GESTURE_DETECTOR_TYPE_ROTATION && type != _TOUCH_GESTURE_DETECTOR_TYPE_PANNING) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_SUCCESS); + } + } + } + else if (GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_READY) + { + _TouchGestureDetectorState state = gestureDetector.GetDetectorState(); + + if (state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_FAILED); + } + else if (state == _TOUCH_GESTURE_DETECTOR_STATE_FAILED) + { + IListT<_TouchGestureDetector*>* pWaitingList = GetCurrentWantToFailList(); + if (pWaitingList) + { + bool exist = pWaitingList->Contains(const_cast<_TouchGestureDetector*>(&gestureDetector)); + if (exist) + { + _TouchGestureDetector* pGestureDetector = const_cast<_TouchGestureDetector*>(&gestureDetector); + pWaitingList->Remove(pGestureDetector); + } + } + } + } +} + +void +_TouchGestureDetector::SetGestureStart(bool start) +{ + __isDetectionStarted = start; + + if (start == true) + { + _Control* pControl = GetControl(); + if (pControl) + { + pControl->AddStartedGestureDetector(*this, _TOUCH_GESTURE_DETECTOR_STATE_STARTED); + } + } +} + +bool +_TouchGestureDetector::IsGestureStarted(void) const +{ + return __isDetectionStarted; +} + +bool +_TouchGestureDetector::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_TouchGestureDetector::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_TouchGestureDetector::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_TouchGestureDetector::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return false; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_TouchGestureDetectorImpl.cpp b/src/ui/FUi_TouchGestureDetectorImpl.cpp new file mode 100644 index 0000000..0cb4054 --- /dev/null +++ b/src/ui/FUi_TouchGestureDetectorImpl.cpp @@ -0,0 +1,358 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchGestureDetectorImpl.cpp + * @brief This is the implementation file for %_TouchGestureDetectorImpl class + * @version 2.0 + * + * This file contains the implementation of %_TouchGestureDetectorImpl class. + * + */ + +#include +#include +#include "FUi_TouchGestureDetectorImpl.h" +#include "FUi_ITouchEventListener.h" +#include "FUi_TouchEventArg.h" +#include "FUi_TouchManager.h" + +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui +{ + +_TouchGestureDetectorImpl::_TouchGestureDetectorImpl(TouchGestureDetector* pPublic, _TouchGestureDetector* pCore) + : __pPublicGestureEventListenerList(null) +{ + __pPublicGestureDetector = pPublic; + __pCoreGestureDetector = pCore; + + __pPublicGestureEventListenerList = new (std::nothrow) LinkedListT; + SysTryReturnVoidResult(NID_UI, __pPublicGestureEventListenerList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pCore->SetUserData(this); + pCore->SetDelegate(*this); + + ClearLastResult(); +} + +_TouchGestureDetectorImpl* +_TouchGestureDetectorImpl::CreateInstanceN(TouchGestureDetector* pPublic) +{ + ClearLastResult(); + + _TouchGestureDetector* pCore = null; + pCore = new (std::nothrow) _TouchGestureDetector; + SysTryReturn(NID_UI, pCore, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + _TouchGestureDetectorImpl* pImpl = new (std::nothrow) _TouchGestureDetectorImpl(pPublic, pCore); + SysTryCatch(NID_UI, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + ClearLastResult(); + + return pImpl; + +CATCH: + delete pCore; + + return null; +} + +_TouchGestureDetectorImpl::~_TouchGestureDetectorImpl(void) +{ + delete __pPublicGestureEventListenerList; + __pPublicGestureEventListenerList = null; + + delete __pCoreGestureDetector; + __pCoreGestureDetector = null; + + ClearLastResult(); +} + +const _TouchGestureDetector& +_TouchGestureDetectorImpl::GetCore(void) const +{ + return *__pCoreGestureDetector; +} + +_TouchGestureDetector& +_TouchGestureDetectorImpl::GetCore(void) +{ + return *__pCoreGestureDetector; +} + +const TouchGestureDetector& +_TouchGestureDetectorImpl::GetPublic(void) const +{ + return *__pPublicGestureDetector; +} + +TouchGestureDetector& +_TouchGestureDetectorImpl::GetPublic(void) +{ + return *__pPublicGestureDetector; +} + +_TouchGestureDetectorImpl* +_TouchGestureDetectorImpl::GetInstance(TouchGestureDetector& gestureDetector) +{ + return gestureDetector.__pTouchGestureDetectorImpl; +} + +const _TouchGestureDetectorImpl* +_TouchGestureDetectorImpl::GetInstance(const TouchGestureDetector& gestureDetector) +{ + return gestureDetector.__pTouchGestureDetectorImpl; +} + +result +_TouchGestureDetectorImpl::AddGestureEventListener(ITouchGestureEventListener& listener) +{ + bool exist = __pPublicGestureEventListenerList->Contains(const_cast(&listener)); + if (exist) + { + return E_OBJ_ALREADY_EXIST; + } + + result r = __pPublicGestureEventListenerList->Add(&listener); + SysTryReturnResult(NID_UI, r == E_SUCCESS, r, "%s Propagating", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_TouchGestureDetectorImpl::RemoveGestureEventListener(ITouchGestureEventListener& listener) +{ + result r = __pPublicGestureEventListenerList->Remove(&listener); + SysTryReturnResult(NID_UI, r == E_SUCCESS, r, "%s Propagating", GetErrorMessage(r)); + + return E_SUCCESS; +} + +IListT * +_TouchGestureDetectorImpl::GetGestureEventListenerList(void) const +{ + return __pPublicGestureEventListenerList; +} + +result +_TouchGestureDetectorImpl::SetDetectorState(TouchGestureDetectorState state) +{ + GetCore().SetDetectorState(static_cast<_TouchGestureDetectorState>(state)); + + return E_SUCCESS; +} + +TouchGestureDetectorState +_TouchGestureDetectorImpl::GetDetectorState(void) const +{ + ClearLastResult(); + + return static_cast(GetCore().GetDetectorState()); +} + +Control* +_TouchGestureDetectorImpl::GetControl(void) const +{ + _Control* pControl = GetCore().GetControl(); + SysTryReturn(NID_UI, pControl, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + ClearLastResult(); + + _ControlImpl* pControlImpl = static_cast<_ControlImpl*>(pControl->GetUserData()); + return &(pControlImpl->GetPublic()); +} + +result +_TouchGestureDetectorImpl::SetDelayTouchEventEnabled(bool enable) +{ + GetCore().SetDelayTouchEventEnabled(enable); + + return E_SUCCESS; +} + +bool +_TouchGestureDetectorImpl::IsDelayTouchEventEnabled(void) const +{ + ClearLastResult(); + + return GetCore().IsDelayTouchEventEnabled(); +} + +result +_TouchGestureDetectorImpl::SetCancelTouchEventOnSuccessEnabled(bool enable) +{ + GetCore().SetCancelTouchEventOnSuccessEnabled(enable); + + return E_SUCCESS; +} + +bool +_TouchGestureDetectorImpl::IsCancelTouchEventOnSuccessEnabled(void) const +{ + ClearLastResult(); + + return GetCore().IsCancelTouchEventOnSuccessEnabled(); +} + +result +_TouchGestureDetectorImpl::StartOnFailureOf(const TouchGestureDetector& gesture) +{ + const _TouchGestureDetectorImpl* pImpl = GetInstance(gesture); + SysTryReturnResult(NID_UI, pImpl, E_INVALID_ARG, "[E_INVALID_ARG] This instance is invalid."); + + result r = GetCore().StartOnFailureOf(pImpl->GetCore()); + SysTryLog(NID_UI, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +bool +_TouchGestureDetectorImpl::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + //public + TouchGestureDetector& publicDetector = GetPublic(); + Control* pControl = static_cast(source.GetUserData()); + _TouchEventArg* pEventArg = null; + + if (pControl) + { + TouchEventInfo publicTouchInfo; + + pEventArg = GetTouchEventArgN(*pControl, touchinfo); + SysTryReturn(NID_UI, pEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + publicTouchInfo.Construct(*pEventArg); + + publicDetector.OnTouchPressed(*pControl, publicTouchInfo); + } + + //core + _TouchGestureDetector& coreDetector = GetCore(); + + coreDetector.OnTouchPressed(source, touchinfo); + + delete pEventArg; + return false; +} + +bool +_TouchGestureDetectorImpl::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + //public + TouchGestureDetector& publicDetector = GetPublic(); + Control* pControl = static_cast(source.GetUserData()); + _TouchEventArg* pEventArg = null; + + if (pControl) + { + TouchEventInfo publicTouchInfo; + + pEventArg = GetTouchEventArgN(*pControl, touchinfo); + SysTryReturn(NID_UI, pEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + publicTouchInfo.Construct(*pEventArg); + + publicDetector.OnTouchMoved(*pControl, publicTouchInfo); + } + + //core + _TouchGestureDetector& coreDetector = GetCore(); + + coreDetector.OnTouchMoved(source, touchinfo); + + delete pEventArg; + return false; +} + +bool +_TouchGestureDetectorImpl::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + //public + TouchGestureDetector& publicDetector = GetPublic(); + Control* pControl = static_cast(source.GetUserData()); + _TouchEventArg* pEventArg = null; + + if (pControl) + { + TouchEventInfo publicTouchInfo; + + pEventArg = GetTouchEventArgN(*pControl, touchinfo); + SysTryReturn(NID_UI, pEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + publicTouchInfo.Construct(*pEventArg); + + publicDetector.OnTouchReleased(*pControl, publicTouchInfo); + } + + //core + _TouchGestureDetector& coreDetector = GetCore(); + + coreDetector.OnTouchReleased(source, touchinfo); + + delete pEventArg; + return false; +} + +bool +_TouchGestureDetectorImpl::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + //public + TouchGestureDetector& publicDetector = GetPublic(); + Control* pControl = static_cast(source.GetUserData()); + _TouchEventArg* pEventArg = null; + + if (pControl) + { + TouchEventInfo publicTouchInfo; + + pEventArg = GetTouchEventArgN(*pControl, touchinfo); + SysTryReturn(NID_UI, pEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + publicTouchInfo.Construct(*pEventArg); + + publicDetector.OnTouchCanceled(*pControl, publicTouchInfo); + } + + //core + _TouchGestureDetector& coreDetector = GetCore(); + coreDetector.OnTouchCanceled(source, touchinfo); + + delete pEventArg; + return false; +} + + +_TouchEventArg* +_TouchGestureDetectorImpl::GetTouchEventArgN(const Control& source, const _TouchInfo& touchInfo) +{ + ClearLastResult(); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, null, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist."); + + _TouchEventArg* pEventArg = new (std::nothrow) _TouchEventArg(source, touchInfo.GetTouchStatus()); + SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + pEventArg->SetTouchPosition(touchInfo.GetPointId(), pTouchManager->GetStartPoint(touchInfo.GetPointId()).x, + pTouchManager->GetStartPoint(touchInfo.GetPointId()).y, + touchInfo.GetCurrentPosition().x, touchInfo.GetCurrentPosition().y); + + return pEventArg; +} + +} } //Tizen::Ui diff --git a/src/ui/FUi_TouchGestureTimerManager.cpp b/src/ui/FUi_TouchGestureTimerManager.cpp new file mode 100644 index 0000000..604b8ac --- /dev/null +++ b/src/ui/FUi_TouchGestureTimerManager.cpp @@ -0,0 +1,237 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchGestureTimerManager.cpp + * @brief This is the implementation file for %_TouchGestureTimerManager class + * @version 2.0 + * + * This file contains the implementation of %_TouchGestureTimerManager class. + * + */ + +// includes +#include "FUi_ControlManager.h" +#include "FUi_TouchGestureTimerManager.h" +#include "FUi_TouchTapGestureDetector.h" +#include "FUi_TouchLongPressGestureDetector.h" +#include "FUi_Control.h" + +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ +class _TouchGestureTimerManager::_TouchGestureTimerListener + : public ITimerEventListener +{ +public: + _TouchGestureTimerListener(_TouchGestureTimerManager& mgr) + : __pManager(&mgr) + { + } + + virtual void OnTimerExpired(Timer& timer) + { + if (!__pManager) + { + return; + } + __pManager->SetTimerState(false); + _TouchGestureDetector* pGestureDetector = __pManager->GetGestureDetector(); + + if (pGestureDetector) + { + switch(pGestureDetector->GetDetectorType()) + { + case _TOUCH_GESTURE_DETECTOR_TYPE_TAP: + { + _TouchTapGestureDetector* pTapGesture = dynamic_cast<_TouchTapGestureDetector*>(pGestureDetector); + + if (pTapGesture && pTapGesture->IsGestureStarted()) + { + pTapGesture->SetGestureStart(false); + + if (pTapGesture->IsAllTapped() && pTapGesture->IsInBounds()) + { + pTapGesture->SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_SUCCESS); + } + else + { + pTapGesture->SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_FAILED); + } + } + + pTapGesture->ClearTapInfoList(); + } + break; + + case _TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS: + { + _TouchLongPressGestureDetector* pLongPressGesture = dynamic_cast<_TouchLongPressGestureDetector*>(pGestureDetector); + + if (pLongPressGesture && pLongPressGesture->IsGestureStarted()) + { + pLongPressGesture->SetGestureStart(false); + + if (pLongPressGesture->IsPressed()) + { + pLongPressGesture->SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_SUCCESS); + } + else + { + pLongPressGesture->SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_FAILED); + } + } + + pLongPressGesture->ClearLongPressInfoList(); + } + break; + + default: + break; + } + } + + if (__pManager) + { + __pManager->SetTimerExpiredState(true); + } + } + + void SetTouchGestureTimerManager(_TouchGestureTimerManager* pManager) + { + __pManager = pManager; + } + +private: + _TouchGestureTimerManager* __pManager; +}; + +_TouchGestureTimerManager::_TouchGestureTimerManager(const _TouchGestureDetector& gestureDetector) + : __isTimerExpired(false) + , __isTimerStarted(false) + , __pTimer(null) + , __pTimerListener(null) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + __pGestureDetector = const_cast<_TouchGestureDetector*>(&gestureDetector); + __pTimerListener = new (std::nothrow) _TouchGestureTimerListener(*this); + SysTryReturnVoidResult(NID_UI, __pTimerListener, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. "); + + __pTimer = new (std::nothrow) Timer; + SysTryCatch(NID_UI, __pTimer, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pTimer->Construct(*__pTimerListener); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return; + +CATCH: + if (__pTimerListener) + { + __pTimerListener->SetTouchGestureTimerManager(null); + delete __pTimerListener; + __pTimerListener = null; + } + + if (__pTimer) + { + delete __pTimer; + __pTimer = null; + } +} + +_TouchGestureTimerManager::~_TouchGestureTimerManager(void) +{ + if (__pTimer) + { + __pTimer->Cancel(); + + delete __pTimer; + __pTimer = null; + } + + if (__pTimerListener) + { + __pTimerListener->SetTouchGestureTimerManager(null); + delete __pTimerListener; + __pTimerListener = null; + } +} + +_TouchGestureDetector* +_TouchGestureTimerManager::GetGestureDetector(void) const +{ + return __pGestureDetector; +} + +bool +_TouchGestureTimerManager::IsTimerStarted(void) +{ + return __isTimerStarted; +} + +void +_TouchGestureTimerManager::SetTimerState(bool started) +{ + __isTimerStarted = started; +} + +void +_TouchGestureTimerManager::SetTimerExpiredState(bool expired) +{ + __isTimerExpired = expired; +} + +result +_TouchGestureTimerManager::StartTimer(int time) +{ + SysTryReturnResult(NID_UI, __pTimer != null, E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + result r = __pTimer->Start(time); + SysTryReturnResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating", GetErrorMessage(r)); + + __isTimerStarted = true; + __isTimerExpired = false; + + return E_SUCCESS; +} + +bool +_TouchGestureTimerManager::IsTimerExpired(void) +{ + return __isTimerExpired; +} + +result +_TouchGestureTimerManager::CancelTimer(void) +{ + result r = __pTimer->Cancel(); + SysTryReturnResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating", GetErrorMessage(r)); + + __isTimerStarted = false; + __isTimerExpired = true; + + return E_SUCCESS; +} + +}} // Tizen::Ui + diff --git a/src/ui/FUi_TouchGestureTimerManager.h b/src/ui/FUi_TouchGestureTimerManager.h new file mode 100644 index 0000000..81e5d1b --- /dev/null +++ b/src/ui/FUi_TouchGestureTimerManager.h @@ -0,0 +1,68 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchGestureTimerManager.h + * @brief This is the header file for the %_TouchGestureTimerManager class. + * + * This header file contains the declarations of the %_TouchGestureTimerManager class. + */ +#ifndef _FUI_INTERNAL_TOUCH_GESTURE_TIMER_MANAGER_H_ +#define _FUI_INTERNAL_TOUCH_GESTURE_TIMER_MANAGER_H_ + +#include +#include "FUi_Types.h" +#include "FUi_UiTouchEvent.h" + +namespace Tizen { namespace Ui +{ +class _TouchGestureTimerManager + : public Tizen::Base::Object +{ +public: + _TouchGestureTimerManager(const _TouchGestureDetector& gestureDetector); + virtual ~_TouchGestureTimerManager(void); + + result StartTimer(int time); + bool IsTimerStarted(void); + + bool IsTimerExpired(void); + result CancelTimer(void); + + _TouchGestureDetector* GetGestureDetector(void) const; + +private: + _TouchGestureTimerManager(const _TouchGestureTimerManager&); + _TouchGestureTimerManager& operator =(const _TouchGestureTimerManager&); + + void SetTimerExpiredState(bool expired); + void SetTimerState(bool started); + +private: + bool __isTimerExpired; + bool __isTimerStarted; + Tizen::Base::Runtime::Timer* __pTimer; + Tizen::Graphics::Point __startPosition; + + class _TouchGestureTimerListener; + _TouchGestureTimerListener* __pTimerListener; + + _TouchGestureDetector* __pGestureDetector; + static _TouchGestureTimerManager* __pInstance; +}; // _TouchGestureTimerManager +}} //Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_GESTURE_TIMER_MANAGER_H_ diff --git a/src/ui/FUi_TouchLongPressGestureDetector.cpp b/src/ui/FUi_TouchLongPressGestureDetector.cpp new file mode 100644 index 0000000..53f96dc --- /dev/null +++ b/src/ui/FUi_TouchLongPressGestureDetector.cpp @@ -0,0 +1,384 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchLongPressGestureDetector.cpp + * @brief This is the implementation file for %_TouchLongPressGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %_TouchLongPressGestureDetector class. + * + */ +#include +#include +#include +#include "FUi_TouchLongPressGestureDetector.h" +#include "FUi_ITouchLongPressGestureEventListener.h" +#include "FUi_TouchManager.h" +#include "FUi_TouchLongPressGestureDetectorImpl.h" +#include "FUi_TouchGestureTimerManager.h" + +using namespace Tizen::Base::Utility; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ +const int DEFAULT_DURATION = 500; +const int DEFAULT_MOVE_ALLOWANCE = 10; +const int DEFAULT_TOUCH_COUNT = 1; +const int MAX_TOUCH_COUNT = 10; + +class _TouchLongPressGestureDetector::_LongPressInfo +{ +public: + bool __isPressed; + bool __isInBounds; + int __touchCount; +}; + +_TouchLongPressGestureDetector::_TouchLongPressGestureDetector(void) + : __duration(DEFAULT_DURATION) + , __moveAllowance(DEFAULT_MOVE_ALLOWANCE) + , __touchCount(DEFAULT_TOUCH_COUNT) + , __maxPointId(DEFAULT_TOUCH_COUNT-1) + , __pGestureTimerManager(null) + , __pLongPressInfoList(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, GetErrorMessage(r)); + + __pLongPressInfoList = new (std::nothrow) ArrayListT<_LongPressInfo*>; + SysTryReturnVoidResult(NID_UI, __pLongPressInfoList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + for(int i=0; i < MAX_TOUCH_COUNT; i++) + { + _LongPressInfo* pLongPressInfo = new (std::nothrow) _LongPressInfo; + SysTryCatch(NID_UI, pLongPressInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pLongPressInfo->__isPressed = false; + pLongPressInfo->__isInBounds = false; + pLongPressInfo->__touchCount = 0; + + __pLongPressInfoList->Add(pLongPressInfo); + } + + SetDetectorType(_TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS); + return; + +CATCH: + if (__pLongPressInfoList) + { + RemoveLongPressInfoList(); + delete __pLongPressInfoList; + __pLongPressInfoList = null; + } +} + +_TouchLongPressGestureDetector::~_TouchLongPressGestureDetector(void) +{ + RemoveLongPressInfoList(); + __pLongPressInfoList->RemoveAll(); + + delete __pLongPressInfoList; + __pLongPressInfoList = null; + + if (__pGestureTimerManager != null) + { + __pGestureTimerManager->CancelTimer(); + + delete __pGestureTimerManager; + __pGestureTimerManager = null; + } +} + +void +_TouchLongPressGestureDetector::RemoveLongPressInfoList(void) +{ + IEnumeratorT<_LongPressInfo*>* pEnumerator = __pLongPressInfoList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _LongPressInfo* pLongPressInfo = null; + pEnumerator->GetCurrent(pLongPressInfo); + if (!pLongPressInfo) + { + continue; + } + delete pLongPressInfo; + } + delete pEnumerator; + } +} + +result +_TouchLongPressGestureDetector::SetDuration(int duration) +{ + SysTryReturnResult(NID_UI, duration > 0, E_INVALID_ARG, "[E_INVALID_ARG] Argument is less than 0"); + + __duration = duration; + return E_SUCCESS; +} + +int +_TouchLongPressGestureDetector::GetDuration(void) const +{ + return __duration; +} + +result +_TouchLongPressGestureDetector::SetMoveAllowance(int allowance) +{ + SysTryReturnResult(NID_UI, allowance > 0, E_INVALID_ARG, "[E_INVALID_ARG] Argument is less than 0"); + + __moveAllowance = allowance; + return E_SUCCESS; +} + +int +_TouchLongPressGestureDetector::GetMoveAllowance(void) const +{ + return __moveAllowance; +} + +result +_TouchLongPressGestureDetector::SetTouchCount(int count) +{ + SysTryReturnResult(NID_UI, count > 0, E_INVALID_ARG, "[E_INVALID_ARG] Argument is less than 0"); + + __touchCount = count; + __maxPointId = __touchCount-1; + + if (__touchCount > DEFAULT_TOUCH_COUNT) + { + _Control* pControl = GetControl(); + if (pControl && !pControl->IsMultiTouchEnabled()) + { + pControl->SetMultiTouchEnabled(true); + } + } + + return E_SUCCESS; +} + +int +_TouchLongPressGestureDetector::GetTouchCount(void) const +{ + return __touchCount; +} + +bool +_TouchLongPressGestureDetector::IsPressed(void) +{ + bool allPressed = false; + for(int i=0; i<__touchCount; i++) + { + _LongPressInfo* pLongPressInfo = null; + __pLongPressInfoList->GetAt(i, pLongPressInfo); + if (pLongPressInfo) + { + if (pLongPressInfo->__isPressed && pLongPressInfo->__isInBounds + && (pLongPressInfo->__touchCount == DEFAULT_TOUCH_COUNT)) + { + allPressed = true; + } + else + { + allPressed = false; + } + } + } + + return allPressed; +} + +bool +_TouchLongPressGestureDetector::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (touchinfo.GetPointId() > __maxPointId || GetDetectorState() != _TOUCH_GESTURE_DETECTOR_STATE_READY ) + { + return false; + } + + _LongPressInfo* pLongPressInfo = null; + __pLongPressInfoList->GetAt(touchinfo.GetPointId(), pLongPressInfo); + SysTryReturn(NID_UI, pLongPressInfo, false, E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + pLongPressInfo->__isPressed = true; + pLongPressInfo->__isInBounds = true; + pLongPressInfo->__touchCount++; + SysTryReturn(NID_UI, __pLongPressInfoList->SetAt(pLongPressInfo, touchinfo.GetPointId()) == E_SUCCESS, + false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + bool allTouched = false; + for(int i=0; i<__touchCount; i++) + { + _LongPressInfo* pLongPressInfo = null; + __pLongPressInfoList->GetAt(i, pLongPressInfo); + if (pLongPressInfo) + { + if (pLongPressInfo->__isPressed) + { + allTouched = true; + } + else + { + allTouched = false; + } + } + } + + if (allTouched) + { + SetGestureStart(true); + + __pGestureTimerManager = new (std::nothrow) _TouchGestureTimerManager(*this); + SysTryReturn(NID_UI, __pGestureTimerManager, null, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + if (__pGestureTimerManager->IsTimerStarted() == false) + { + _Control* pControl = GetControl(); + if (!pControl) + { + SetControl(source); + } + + if (__pGestureTimerManager->StartTimer(__duration) != E_SUCCESS) + { + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] LongPress timer is not started."); + } + } + } + + return false; +} + +bool +_TouchLongPressGestureDetector::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (touchinfo.GetPointId() > __maxPointId || GetDetectorState() != _TOUCH_GESTURE_DETECTOR_STATE_READY ) + { + return false; + } + + _LongPressInfo* pLongPressInfo = null; + __pLongPressInfoList->GetAt(touchinfo.GetPointId(), pLongPressInfo); + SysTryReturn(NID_UI, pLongPressInfo, false, E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + if (!pLongPressInfo->__isInBounds) + { + return false; + } + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, false, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist."); + + Point startPoint(pTouchManager->GetStartPoint(touchinfo.GetPointId()).x, pTouchManager->GetStartPoint(touchinfo.GetPointId()).y); + _Control* pControl = GetControl(); + if (pControl) + { + startPoint.x -= pControl->GetAbsoluteBounds().x; + startPoint.y -= pControl->GetAbsoluteBounds().y; + } + + if (Math::Abs(startPoint.x- touchinfo.GetCurrentPosition().x) > __moveAllowance + || Math::Abs(startPoint.y - touchinfo.GetCurrentPosition().y) > __moveAllowance) + { + pLongPressInfo->__isInBounds = false; + } + else + { + pLongPressInfo->__isInBounds = true; + } + + SysTryReturn(NID_UI, __pLongPressInfoList->SetAt(pLongPressInfo, touchinfo.GetPointId()) == E_SUCCESS, + false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return false; +} + +bool +_TouchLongPressGestureDetector::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (touchinfo.GetPointId() > __maxPointId || GetDetectorState() != _TOUCH_GESTURE_DETECTOR_STATE_READY ) + { + return false; + } + + _LongPressInfo* pLongPressInfo = null; + __pLongPressInfoList->GetAt(touchinfo.GetPointId(), pLongPressInfo); + SysTryReturn(NID_UI, pLongPressInfo, false, E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + pLongPressInfo->__isPressed = false; + pLongPressInfo->__isInBounds = false; + + SysTryReturn(NID_UI, __pLongPressInfoList->SetAt(pLongPressInfo, touchinfo.GetPointId()) == E_SUCCESS, + false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + //when touch is released not expired timer -> failed + if (IsGestureStarted() && __pGestureTimerManager != null && !__pGestureTimerManager->IsTimerExpired()) + { + __pGestureTimerManager->CancelTimer(); + + delete __pGestureTimerManager; + __pGestureTimerManager = null; + + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_FAILED); + ClearLongPressInfoList(); + } + + return false; +} + +bool +_TouchLongPressGestureDetector::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLongPressInfoList(); + + if (__pGestureTimerManager != null && __pGestureTimerManager->IsTimerExpired() == false) + { + __pGestureTimerManager->CancelTimer(); + + delete __pGestureTimerManager; + __pGestureTimerManager = null; + } + + return false; +} + +void +_TouchLongPressGestureDetector::ClearLongPressInfoList(void) +{ + for(int i=0; i < MAX_TOUCH_COUNT; i++) + { + _LongPressInfo* pLongPressInfo = null; + __pLongPressInfoList->GetAt(i, pLongPressInfo); + if (!pLongPressInfo) + { + continue; + } + + pLongPressInfo->__isPressed = false; + pLongPressInfo->__touchCount = 0; + pLongPressInfo->__isInBounds = false; + + __pLongPressInfoList->SetAt(pLongPressInfo, i); + } +} + +} } // Tizen::Ui + diff --git a/src/ui/FUi_TouchLongPressGestureDetectorImpl.cpp b/src/ui/FUi_TouchLongPressGestureDetectorImpl.cpp new file mode 100644 index 0000000..f7dafe6 --- /dev/null +++ b/src/ui/FUi_TouchLongPressGestureDetectorImpl.cpp @@ -0,0 +1,128 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchLongPressGestureDetectorImpl.cpp + * @brief This is the implementation file for %_TouchLongPressGestureDetectorImpl class + * @version 2.0 + * + * This file contains the implementation of %_TouchLongPressGestureDetectorImpl class. + * + */ + +#include +#include "FUi_TouchLongPressGestureDetectorImpl.h" +#include "FUi_TouchLongPressGestureDetector.h" + +namespace Tizen { namespace Ui +{ + +_TouchLongPressGestureDetectorImpl::_TouchLongPressGestureDetectorImpl(TouchLongPressGestureDetector* pPublic, _TouchLongPressGestureDetector* pCore) + : _TouchGestureDetectorImpl(pPublic, pCore) +{ +} + +_TouchLongPressGestureDetectorImpl::~_TouchLongPressGestureDetectorImpl(void) +{ +} + +_TouchLongPressGestureDetectorImpl* +_TouchLongPressGestureDetectorImpl::CreateInstanceN(TouchLongPressGestureDetector* pPublic) +{ + ClearLastResult(); + + _TouchLongPressGestureDetector* pCore = null; + pCore = new (std::nothrow) _TouchLongPressGestureDetector; + SysTryReturn(NID_UI, pCore, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + _TouchLongPressGestureDetectorImpl* pImpl = new (std::nothrow) _TouchLongPressGestureDetectorImpl(pPublic, pCore); + SysTryCatch(NID_UI, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pImpl; + +CATCH: + delete pCore; + + return null; +} + +const _TouchLongPressGestureDetector& +_TouchLongPressGestureDetectorImpl::GetCore(void) const +{ + return static_cast(_TouchGestureDetectorImpl::GetCore()); +} + +_TouchLongPressGestureDetector& +_TouchLongPressGestureDetectorImpl::GetCore(void) +{ + return static_cast<_TouchLongPressGestureDetector&>(_TouchGestureDetectorImpl::GetCore()); +} + +_TouchLongPressGestureDetectorImpl* +_TouchLongPressGestureDetectorImpl::GetInstance(TouchLongPressGestureDetector& gestureDetector) +{ + return static_cast<_TouchLongPressGestureDetectorImpl*> (gestureDetector.__pTouchGestureDetectorImpl); +} + +const _TouchLongPressGestureDetectorImpl* +_TouchLongPressGestureDetectorImpl::GetInstance(const TouchLongPressGestureDetector& gestureDetector) +{ + return static_cast (gestureDetector.__pTouchGestureDetectorImpl); +} + +result +_TouchLongPressGestureDetectorImpl::SetDuration(int duration) +{ + return GetCore().SetDuration(duration); +} + +int +_TouchLongPressGestureDetectorImpl::GetDuration(void) const +{ + ClearLastResult(); + + return GetCore().GetDuration(); +} + +result +_TouchLongPressGestureDetectorImpl::SetMoveAllowance(int allowance) +{ + return GetCore().SetMoveAllowance(allowance); +} + +int +_TouchLongPressGestureDetectorImpl::GetMoveAllowance(void) const +{ + ClearLastResult(); + + return GetCore().GetMoveAllowance(); +} + +result +_TouchLongPressGestureDetectorImpl::SetTouchCount(int count) +{ + return GetCore().SetTouchCount(count); +} + +int +_TouchLongPressGestureDetectorImpl::GetTouchCount(void) const +{ + ClearLastResult(); + + return GetCore().GetTouchCount(); +} + +} } // Tizen::Ui diff --git a/src/ui/FUi_TouchManager.cpp b/src/ui/FUi_TouchManager.cpp new file mode 100644 index 0000000..8389f70 --- /dev/null +++ b/src/ui/FUi_TouchManager.cpp @@ -0,0 +1,992 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_TouchManager.cpp + * @brief This is the implementation file for _TouchManager class. + */ + +#include +#include +#include +#include +#include "FUi_UiTouchEvent.h" +#include "FUi_UiEventManager.h" +#include "FUi_ITouchEventListener.h" +#include "FUi_TouchGestureDetector.h" +#include "FUi_ControlManager.h" +#include "FUi_Control.h" +#include "FUi_TouchManager.h" +#include "FUi_ControlImpl.h" + +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace +{ +class _TouchEventListener + : public _ITouchEventListener + , virtual public _IUiEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + _TouchEventListener(void) + { + } + + virtual ~_TouchEventListener(void) + { + } + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) + { + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, false, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist."); + + if (touchinfo.GetPointId() == SINGLE_POINT_ID) + { + pTouchManager->SetTouchAllowed(true); + pTouchManager->SetTouchCanceledOnGestureSuccess(false); + pTouchManager->SetTouchControlSource(source); + pTouchManager->SetFocusedControlSource(source); + } + else + { + _Control* pTouchedControl = pTouchManager->GetTouchControlSource(); + if (pTouchedControl == null) + { + pTouchManager->SetTouchAllowed(true); + pTouchManager->SetTouchControlSource(source); + pTouchManager->SetFocusedControlSource(source); + } + } + + if (!pTouchManager->IsSendingDelayedEvent()) + { + return false; + } + + result r = pTouchManager->AddPoint(touchinfo.GetPointId(), touchinfo.GetCurrentPosition(), _TOUCH_PRESSED); + SysTryReturn(NID_UI, r == E_SUCCESS, true, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return false; + } + + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) + { + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, false, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist."); + + if (!pTouchManager->IsTouchAllowed()) + { + return true; + } + + if (!pTouchManager->IsSendingDelayedEvent()) + { + return false; + } + + result r = pTouchManager->AddPoint(touchinfo.GetPointId(), touchinfo.GetCurrentPosition(), _TOUCH_RELEASED); + SysTryReturn(NID_UI, r == E_SUCCESS, true, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return false; + } + + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) + { + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, false, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist."); + + if (!pTouchManager->IsTouchAllowed()) + { + return true; + } + + if(!pTouchManager->IsInTouchMoveAllowanceBounds(source, touchinfo)) + { + return true; + } + + if (!pTouchManager->IsSendingDelayedEvent()) + { + return false; + } + + result r = pTouchManager->AddPoint(touchinfo.GetPointId(), touchinfo.GetCurrentPosition(), _TOUCH_MOVED); + if (r != E_SUCCESS) + { + return true; + } + + return false; + } + + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) + { + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, false, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist."); + + if (pTouchManager->IsTouchCanceledOnGestureSuccess() == false) + { + CancelGesture(source, touchinfo); + } + + _ITouchEventListener* pTouchedControlEventListener = source.GetPropagatedTouchEventListener(); + + if (pTouchedControlEventListener != null) + { + pTouchManager->SetTouchAllowed(false); + pTouchManager->ResetTouchInfo(); + } + + return false; + } + +private: + void CancelGesture(const _Control& source, const _TouchInfo& touchinfo) + { + IListT <_TouchGestureDetector*>* pGestureList = source.GetGestureDetectorList(); + + if (pGestureList) + { + IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pGestureList->GetEnumeratorN(); + + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGestureDetector = null; + pEnumerator->GetCurrent(pGestureDetector); + + if (pGestureDetector == null) + { + continue; + } + + if (pGestureDetector->IsGestureStarted()) + { + pGestureDetector->SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_CANCELED); + pGestureDetector->ProcessPublicListener(*pGestureDetector); + pGestureDetector->ProcessCoreListener(*pGestureDetector); + } + else + { + pGestureDetector->SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_CANCELED); + } + + pGestureDetector->OnTouchCanceled(source, touchinfo); + } + delete pEnumerator; + } + } + } +}; +} + +namespace Tizen { namespace Ui +{ + +_MultiFingerInfo::_MultiFingerInfo(void) + : __currentPointId(0) + , __generatedPointId(0) + , __pointCount(0) + , __pFingerInfoMap(null) +{ + __pFingerInfoMap = new (std::nothrow) HashMapT; + SysTryReturnVoidResult(NID_UI, __pFingerInfoMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + SysTryCatch(NID_UI, __pFingerInfoMap->Construct() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error occurred."); + return; + +CATCH: + delete __pFingerInfoMap; + __pFingerInfoMap = null; + return; +} + +_MultiFingerInfo::~_MultiFingerInfo(void) +{ + RemoveFingerInfoList(); +} + +void +_MultiFingerInfo::RemoveFingerInfoList(void) +{ + IMapEnumeratorT* pEnumerator = __pFingerInfoMap->GetMapEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _FingerInfo* pFingerInfo = null; + pEnumerator->GetValue(pFingerInfo); + + if (pFingerInfo) + { + delete pFingerInfo; + } + + } + delete pEnumerator; + } + + __pFingerInfoMap->RemoveAll(); + delete __pFingerInfoMap; + __pFingerInfoMap = null; +} + +unsigned long +_MultiFingerInfo::GeneratePointId(unsigned long deviceId) +{ + if (__pointCount == 0) + { + InitializeFingerInfo(); + } + + _FingerInfo* pFingerInfo = null; + __pFingerInfoMap->GetValue(deviceId, pFingerInfo); + + unsigned int pointId = 0; + pointId = __generatedPointId; + + if (pFingerInfo == null) + { + pFingerInfo = new (std::nothrow) _FingerInfo; + SysTryReturn(NID_UI, pFingerInfo, INVALID_POINT_ID, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] GeneratePointId - Memory allocation failed."); + + pFingerInfo->SetDeviceId(deviceId); + pFingerInfo->SetPointId(pointId); + __pFingerInfoMap->Add(deviceId, pFingerInfo); + } + else + { + pFingerInfo->SetDeviceId(deviceId); + pFingerInfo->SetPointId(pointId); + __pFingerInfoMap->SetValue(deviceId, pFingerInfo); + } + + __currentPointId = pointId; + __generatedPointId++; + return pointId; + +} + +unsigned long +_MultiFingerInfo::GetPointId(unsigned long deviceId) const +{ + _FingerInfo* pFingerInfo = null; + __pFingerInfoMap->GetValue(deviceId, pFingerInfo); + SysTryReturn(NID_UI, pFingerInfo, INVALID_POINT_ID, E_SYSTEM, "[E_SYTSTEM] pFingerInfo is null."); + + return pFingerInfo->GetPointId(); +} + +unsigned long +_MultiFingerInfo::GetCurrentPointId(void) const +{ + return __currentPointId; +} + +Point +_MultiFingerInfo::GetPosition(unsigned long id) const +{ + Point errorPoint(-1, -1); + + IListT<_FingerInfo*>* pFingerList = __pFingerInfoMap->GetValuesN(); + if (pFingerList) + { + IEnumeratorT<_FingerInfo*>* pEnumerator = pFingerList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _FingerInfo* pFingerInfo = null; + pEnumerator->GetCurrent(pFingerInfo); + + if (pFingerInfo == null) + { + continue; + } + + if (pFingerInfo->GetPointId() == id) + { + delete pEnumerator; + delete pFingerList; + return pFingerInfo->GetPoint(); + } + } + delete pEnumerator; + } + delete pFingerList; + } + + return errorPoint; +} + +Point +_MultiFingerInfo::GetScreenPoint(unsigned long id) const +{ + Point errorPoint(-1, -1); + + IListT<_FingerInfo*>* pFingerList = __pFingerInfoMap->GetValuesN(); + if (pFingerList) + { + IEnumeratorT<_FingerInfo*>* pEnumerator = pFingerList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _FingerInfo* pFingerInfo = null; + pEnumerator->GetCurrent(pFingerInfo); + + if (pFingerInfo == null) + { + continue; + } + + if (pFingerInfo->GetPointId() == id) + { + delete pEnumerator; + delete pFingerList; + return pFingerInfo->GetScreenPoint(); + } + } + delete pEnumerator; + } + delete pFingerList; + } + + return errorPoint; +} + +Point +_MultiFingerInfo::GetStartPoint(unsigned long id) const +{ + Point errorPoint(-1, -1); + + IListT<_FingerInfo*>* pFingerList = __pFingerInfoMap->GetValuesN(); + if (pFingerList) + { + IEnumeratorT<_FingerInfo*>* pEnumerator = pFingerList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _FingerInfo* pFingerInfo = null; + pEnumerator->GetCurrent(pFingerInfo); + + if (pFingerInfo == null) + { + continue; + } + + if (pFingerInfo->GetPointId() == id) + { + delete pEnumerator; + delete pFingerList; + return pFingerInfo->GetStartPoint(); + } + } + delete pEnumerator; + } + delete pFingerList; + } + + return errorPoint; +} + +_TouchStatus +_MultiFingerInfo::GetStatus(unsigned long id) const +{ + IListT<_FingerInfo*>* pFingerList = __pFingerInfoMap->GetValuesN(); + if (pFingerList) + { + IEnumeratorT<_FingerInfo*>* pEnumerator = pFingerList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _FingerInfo* pFingerInfo = null; + pEnumerator->GetCurrent(pFingerInfo); + + if (pFingerInfo == null) + { + continue; + } + + if (pFingerInfo->GetPointId() == id) + { + delete pEnumerator; + delete pFingerList; + return pFingerInfo->GetStatus(); + } + } + delete pEnumerator; + } + delete pFingerList; + } + + return _TOUCH_PRESSED; +} + +int +_MultiFingerInfo::GetPointCount(void) const +{ + return __pointCount; +} + +IListT<_FingerInfo*>* +_MultiFingerInfo::GetMultiFingerListN(void) const +{ + IListT<_FingerInfo*>* pFingerInfoMapList = __pFingerInfoMap->GetValuesN(); + SysTryReturn(NID_UI, pFingerInfoMapList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pFingerInfoMapList; +} + +void +_MultiFingerInfo::ResetFingerInfo(void) +{ + __pointCount = 0; + __currentPointId = 0; + __generatedPointId = 0; +} + +void +_MultiFingerInfo::InitializeFingerInfo(void) +{ + IListT<_FingerInfo*>* pFingerList = __pFingerInfoMap->GetValuesN(); + + if (pFingerList) + { + IEnumeratorT<_FingerInfo*>* pEnumerator = pFingerList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _FingerInfo* pFingerInfo = null; + pEnumerator->GetCurrent(pFingerInfo); + + if (pFingerInfo == null) + { + continue; + } + + pFingerInfo->SetStatus(_TOUCH_FOCUS_OUT); + pFingerInfo->SetPointId(INVALID_POINT_ID); + __pFingerInfoMap->SetValue(pFingerInfo->GetDeviceId(), pFingerInfo); + } + delete pEnumerator; + } + delete pFingerList; + } +} + +result +_MultiFingerInfo::SetFingerInfo(unsigned long pointId, const Point& point, const Point& screenPoint, const _TouchStatus status) +{ + _FingerInfo* pFingerInfo = null; + + IListT<_FingerInfo*>* pFingerList = __pFingerInfoMap->GetValuesN(); + if (pFingerList) + { + IEnumeratorT<_FingerInfo*>* pEnumerator = pFingerList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + pEnumerator->GetCurrent(pFingerInfo); + if (pFingerInfo == null) + { + continue; + } + + if (pFingerInfo->GetPointId() == pointId) + { + break; + } + pFingerInfo = null; + } + delete pEnumerator; + } + delete pFingerList; + } + + SysTryReturnResult(NID_UI, pFingerInfo, E_INVALID_CONDITION, "[E_INVALID_CONDITION] pFingerInfo is null"); + + switch (status) + { + case _TOUCH_PRESSED: + pFingerInfo->SetStartPoint(screenPoint); + pFingerInfo->SetPoint(screenPoint, point); + pFingerInfo->SetStatus(_TOUCH_PRESSED); + pFingerInfo->SetMoveReady(false); + __pointCount++; + break; + + case _TOUCH_MOVED: + if (pFingerInfo->GetStatus() == _TOUCH_RELEASED || pFingerInfo->GetStatus() == _TOUCH_FOCUS_OUT || pFingerInfo->GetPoint() == point) + { + return E_INVALID_CONDITION; + } + + pFingerInfo->SetPoint(screenPoint, point); + pFingerInfo->SetStatus(_TOUCH_MOVED); + break; + + case _TOUCH_RELEASED: + if (pFingerInfo->GetStatus() == _TOUCH_RELEASED || pFingerInfo->GetStatus() == _TOUCH_FOCUS_OUT) + { + SysLog(NID_UI,"OnTouchReleased without OnTouchPressed"); + ResetFingerInfo(); + return E_INVALID_CONDITION; + } + + pFingerInfo->SetPoint(screenPoint, point); + pFingerInfo->SetStatus(_TOUCH_RELEASED); + pFingerInfo->SetMoveReady(false); + __pointCount--; + + if (__pointCount == 0 ) + { + __currentPointId = 0; + __generatedPointId = 0; + } + break; + + default: + break; + } + + __pFingerInfoMap->SetValue(pFingerInfo->GetDeviceId(), pFingerInfo); + return E_SUCCESS; +} + +_TouchManager* _TouchManager::__pInstance = null; + +_TouchManager::_TouchManager(void) + : __pMultiFingerInfo(null) + , __touchCanceled(false) + , __touchAllowed(true) + , __pTouchEventListener(null) + , __captureAllowOutOfBounds(false) + , __isSendingDelayedEvent(true) + , __touchCanceledOnGestureSuccess(false) +{ + ClearLastResult(); + + result r = E_SUCCESS; + _UiEventManager* pEventManager = null; + + __pMultiFingerInfo = new (std::nothrow) _MultiFingerInfo; + SysTryReturnVoidResult(NID_UI, __pMultiFingerInfo, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTouchEventListener = new (std::nothrow) _TouchEventListener; + SysTryCatch(NID_UI, __pTouchEventListener, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pEventManager = _UiEventManager::GetInstance(); + SysTryCatch(NID_UI, pEventManager, , E_SYSTEM, "[E_SYSTEM] _UiEventManager does not exist."); + + r = pEventManager->AddTouchEventListener(*__pTouchEventListener); + SysTryCatch(NID_UI, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return; + +CATCH: + delete __pMultiFingerInfo; + __pMultiFingerInfo = null; + + if (__pTouchEventListener) + { + delete __pTouchEventListener; + __pTouchEventListener = null; + } +} + +_TouchManager::~_TouchManager(void) +{ + delete __pMultiFingerInfo; + __pMultiFingerInfo = null; + + _UiEventManager* pEventManager = _UiEventManager::GetInstance(); + if (pEventManager) + { + pEventManager->RemoveTouchEventListener(*__pTouchEventListener); + } + + delete __pTouchEventListener; + __pTouchEventListener = null; +} + +void +_TouchManager::Initialize(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (__pInstance == null) + { + pthread_once(&once_block, InitializeInstance); + } + +} + +_TouchManager* +_TouchManager::GetInstance(void) +{ + return __pInstance; +} + +void +_TouchManager::InitializeInstance(void) +{ + ClearLastResult(); + + if (__pInstance == null) +{ + __pInstance = new (std::nothrow) _TouchManager; + SysTryReturnVoidResult(NID_UI, __pInstance != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); +} +} + +void +_TouchManager::ReleaseInstance(void) +{ + if (__pInstance) + { + delete __pInstance; + __pInstance = null; + } +} + +result +_TouchManager::AddPoint(unsigned long pointId, const Point& point, _TouchStatus status) +{ + Point screenPos(point.x, point.y); + Point controlPos(0, 0); + + _Control* pControl = GetTouchControlSource(); + if (pControl) + { + controlPos.x = pControl->GetAbsoluteBounds().x; + controlPos.y = pControl->GetAbsoluteBounds().y; + + screenPos.x += controlPos.x; + screenPos.y += controlPos.y; + } + + return __pMultiFingerInfo->SetFingerInfo(pointId, point, screenPos, status); +} + +unsigned long +_TouchManager::GetPointId(unsigned long deviceId) const +{ + return __pMultiFingerInfo->GetPointId(deviceId); +} + +Tizen::Graphics::Point +_TouchManager::GetStartPoint(unsigned long pointId) const +{ + return __pMultiFingerInfo->GetStartPoint(pointId); +} + +unsigned long +_TouchManager::GetCurrentPointId(void) const +{ + return __pMultiFingerInfo->GetCurrentPointId(); +} + +unsigned long +_TouchManager::GeneratePointId(const unsigned long deviceId) const +{ + return __pMultiFingerInfo->GeneratePointId(deviceId); +} + +Point +_TouchManager::GetPosition(unsigned long id) const +{ + return __pMultiFingerInfo->GetPosition(id); +} + +Point +_TouchManager::GetScreenPoint(unsigned long id) const +{ + return __pMultiFingerInfo->GetScreenPoint(id); +} + +TouchStatus +_TouchManager::GetTouchStatus(const unsigned long id) const +{ + return (static_cast (__pMultiFingerInfo->GetStatus(id))); +} + + int + _TouchManager::GetPointCount(void) const + { + return __pMultiFingerInfo->GetPointCount(); + } + +void +_TouchManager::SetTouchControlSource(const _Control& source) +{ + __touchControlHandle = source.GetHandle(); +} + +_Control* +_TouchManager::GetTouchControlSource(void) const +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist."); + + return pControlManager->GetObject(__touchControlHandle); +} + +void +_TouchManager::SetFocusedControlSource(const _Control& source) +{ + __focusedControlHandle = source.GetHandle(); +} + +_Control* +_TouchManager::GetFocusedControlSource(void) const +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist."); + + return pControlManager->GetObject(__focusedControlHandle); +} + +result +_TouchManager::SendEvent(_Control* pControl, const _TouchInfo& touchInfo) +{ + SysTryReturnResult(NID_UI, pControl, E_INVALID_ARG, "[E_INVALID_ARG] pControl is null."); + + _UiTouchEvent event(pControl->GetHandle(), touchInfo, _UI_EVENT_ROUTE_DIRECT); + + _Control* pTouchedControl = GetTouchControlSource(); + if (pTouchedControl) + { + event.SetOriginalDestination(*pTouchedControl); + } + + _UiEventManager* pEventManager = _UiEventManager::GetInstance(); + SysTryReturnResult(NID_UI, pEventManager, E_SYSTEM, "[E_SYSTEM] _UiEventManager does not exist."); + + __isSendingDelayedEvent = false; + result r = pEventManager->SendEvent(event); + __isSendingDelayedEvent = true; + + return r; +} + +void +_TouchManager::SetTouchCanceled(bool canceled, bool onlyTouchEvent) +{ + __touchCanceledOnGestureSuccess = onlyTouchEvent; + + if (canceled) + { + if (GetTouchControlSource() && GetTouchControlSource()->IsAttachedToMainTree()) + { + Point currentPoint(0, 0); + _TouchInfo touchInfo; + + if (GetTouchControlSource()->IsMultiTouchEnabled()) + { + currentPoint.x = GetScreenPoint(GetCurrentPointId()).x; + currentPoint.y = GetScreenPoint(GetCurrentPointId()).y; + + _TouchInfo multiTouchInfo(GetCurrentPointId(), _TOUCH_CANCELED, currentPoint, false, 0); + touchInfo = multiTouchInfo; + } + else + { + currentPoint.x = GetScreenPoint(SINGLE_POINT_ID).x; + currentPoint.y = GetScreenPoint(SINGLE_POINT_ID).y; + + _TouchInfo singleTouchInfo(SINGLE_POINT_ID, _TOUCH_CANCELED, currentPoint, false, 0); + touchInfo = singleTouchInfo; + } + + _UiTouchEvent event(GetTouchControlSource()->GetHandle(), touchInfo); + + _UiEventManager* pEventManager = _UiEventManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pEventManager, E_SYSTEM, "[E_SYSTEM] _UiEventManager does not exist."); + + pEventManager->SendEvent(event); + } + SetLastResult(E_SUCCESS); + } +} + +bool +_TouchManager::IsTouchCanceledOnGestureSuccess(void) const +{ + return __touchCanceledOnGestureSuccess; +} + +void +_TouchManager::SetTouchCanceledOnGestureSuccess(bool cancel) +{ + __touchCanceledOnGestureSuccess = cancel; +} + +void +_TouchManager::SetTouchAllowed(bool allowed) +{ + __touchAllowed = allowed; +} + +bool +_TouchManager::IsTouchAllowed(void) +{ + return __touchAllowed; +} + +bool +_TouchManager::IsInTouchMoveAllowanceBounds(const _Control& source, const _TouchInfo& touchInfo) +{ + IListT<_FingerInfo*>* pFingerInfoList = GetMultiFingerInfoListN(); + SysTryReturn(NID_UI, pFingerInfoList, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + const int count = pFingerInfoList->GetCount(); + + for (int i = 0; i < count; i++) + { + _FingerInfo* pFingerInfo = null; + pFingerInfoList->GetAt(i, pFingerInfo); + if (pFingerInfo == null) + { + continue; + } + + if (pFingerInfo->GetPointId() == touchInfo.GetPointId()) + { + if (pFingerInfo->GetMoveReady() == true) + { + delete pFingerInfoList; + pFingerInfoList = null; + return true; + } + + Point tmpPoint = GetStartPoint(touchInfo.GetPointId()); + Rectangle absBounds = source.GetAbsoluteBounds(); + + Point startPoint(tmpPoint.x - absBounds.x, tmpPoint.y - absBounds.y); + Point currentPoint = touchInfo.GetCurrentPosition(); + + //SysLog(NID_UI, "[Touch Test] tmpPoint(%d, %d) absBounds(%d, %d) startPoint(%d, %d) currentPoint(%d, %d)", + // tmpPoint.x, tmpPoint.y, absBounds.x, absBounds.y, startPoint.x, startPoint.y, currentPoint.x, currentPoint.y); + + int distance = int(hypot(abs(startPoint.x-currentPoint.x), abs(startPoint.y-currentPoint.y))); + int touchMoveAllowanceBounds = 0; + + int allowanceBoundsValue[] = {3, 25, 50}; + touchMoveAllowanceBounds = allowanceBoundsValue[source.GetTouchMoveAllowance()]; + + if (distance >= touchMoveAllowanceBounds) + { + pFingerInfo->SetMoveReady(true); + + delete pFingerInfoList; + return true; + } + } + } + + delete pFingerInfoList; + return false; +} + +void +_TouchManager::SetCapturedControl(const _Control* pControl, bool allowOutOfBounds) +{ + if (pControl) + { + __capturedControlHandle = pControl->GetHandle(); + } + else + { + __capturedControlHandle = _ControlHandle(); + } + + __captureAllowOutOfBounds = allowOutOfBounds; +} + +_Control* +_TouchManager::GetCapturedControl(void) const +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist."); + + return pControlManager->GetObject(__capturedControlHandle); +} + +bool +_TouchManager::IsCaptureAllowedOutOfBounds(void) const +{ + return __captureAllowOutOfBounds; +} + +void +_TouchManager::ResetTouchInfo(void) +{ + __pMultiFingerInfo->ResetFingerInfo(); + + _Control* pControl = GetTouchControlSource(); + if (pControl) + { + IListT <_TouchGestureDetector*>* pGestureList = pControl->GetGestureDetectorList(); + + if (pGestureList) + { + IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pGestureList->GetEnumeratorN(); + + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGestureDetector = null; + pEnumerator->GetCurrent(pGestureDetector); + + if (pGestureDetector == null) + { + continue; + } + + pGestureDetector->SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_CANCELED); + pGestureDetector->ProcessCoreListener(*pGestureDetector); + } + delete pEnumerator; + } + } + } + + __touchAllowed = false; +} + +IListT<_FingerInfo*>* +_TouchManager::GetMultiFingerInfoListN(void) const +{ + return __pMultiFingerInfo->GetMultiFingerListN(); +} + +bool +_TouchManager::IsSendingDelayedEvent(void) const +{ + return __isSendingDelayedEvent; +} +} } //Tizen::Ui diff --git a/src/ui/FUi_TouchPanningGestureDetector.cpp b/src/ui/FUi_TouchPanningGestureDetector.cpp new file mode 100644 index 0000000..74b489a --- /dev/null +++ b/src/ui/FUi_TouchPanningGestureDetector.cpp @@ -0,0 +1,374 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchPanningGestureDetector.cpp + * @brief This is the implementation file for %_TouchPanningGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %_TouchPanningGestureDetector class. + * + */ +#include +#include +#include +#include "FUi_TouchPanningGestureDetector.h" +#include "FUi_ITouchPanningGestureEventListener.h" +#include "FUi_TouchManager.h" +#include "FUi_TouchPanningGestureDetectorImpl.h" + +using namespace Tizen::Base::Utility; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; + +namespace +{ +const int DEFAULT_TOUCH_COUNT = 1; +const int MIN_MOVEALLOWANCE = 20; +const int POLLING_PANNING = 16; +} + +namespace Tizen { namespace Ui +{ +_TouchPanningGestureDetector::_TouchPanningGestureDetector(void) + : __touchCount(DEFAULT_TOUCH_COUNT) + , __fingerCount(0) + , __maxPointId(DEFAULT_TOUCH_COUNT-1) + , __pTimer(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, GetErrorMessage(r)); + + __pTimer = new (std::nothrow)Timer; + SysTryReturnVoidResult(NID_UI, __pTimer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetDetectorType(_TOUCH_GESTURE_DETECTOR_TYPE_PANNING); + return; + +CATCH: + delete __pTimer; + __pTimer = null; +} + +_TouchPanningGestureDetector::~_TouchPanningGestureDetector(void) +{ + delete __pTimer; + __pTimer = null; +} + +result +_TouchPanningGestureDetector::SetTouchCount(int count) +{ + SysTryReturnResult(NID_UI, count > 0, E_INVALID_ARG, "[E_INVALID_ARG] Argument is less than 0"); + + __touchCount = count; + __maxPointId = __touchCount-1; + + if (__touchCount > DEFAULT_TOUCH_COUNT) + { + _Control* pControl = GetControl(); + if (pControl && !pControl->IsMultiTouchEnabled()) + { + pControl->SetMultiTouchEnabled(true); + } + } + + return E_SUCCESS; +} + +int +_TouchPanningGestureDetector::GetTouchCount(void) const +{ + return __touchCount; +} + +IListT<_TouchInfo*>* +_TouchPanningGestureDetector::GetTouchInfoListN(const _Control* pControl) const +{ + if (GetDetectorState() != _TOUCH_GESTURE_DETECTOR_STATE_STARTED + && GetDetectorState() != _TOUCH_GESTURE_DETECTOR_STATE_CHANGED + && GetDetectorState() != _TOUCH_GESTURE_DETECTOR_STATE_FINISHED) + { + return null; + } + + Point controlPos(0, 0); + if (pControl != null) + { + controlPos.x = pControl->GetAbsoluteBounds().x; + controlPos.y = pControl->GetAbsoluteBounds().y; + } + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager != null, null, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist."); + + IListT<_FingerInfo*>* pFingerInfoList = pTouchManager->GetMultiFingerInfoListN(); + SysTryReturn(NID_UI, pFingerInfoList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + LinkedListT<_TouchInfo*>* pReturnList = new (std::nothrow) LinkedListT<_TouchInfo*>; + SysTryCatch(NID_UI, pReturnList, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + for (int i = 0; i < pFingerInfoList->GetCount(); i++) + { + _FingerInfo* pFingerInfo = null; + pFingerInfoList->GetAt(i, pFingerInfo); + + if (pFingerInfo == null) + { + continue; + } + + if (pFingerInfo->GetStatus() != _TOUCH_FOCUS_OUT) + { + _TouchInfo* pTouchInfo = new (std::nothrow) _TouchInfo; + SysTryCatch(NID_UI, pTouchInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.\n"); + Point point(pFingerInfo->GetScreenPoint().x - controlPos.x, pFingerInfo->GetScreenPoint().y - controlPos.y); + + pTouchInfo->SetTouchInfo(pFingerInfo->GetPointId(), pFingerInfo->GetStatus(), point, false, 0); + pReturnList->Add(pTouchInfo); + + if (pReturnList->GetCount() == __touchCount) + { + break; + } + } + } + + delete pFingerInfoList; + + return pReturnList; + +CATCH: + if (pReturnList) + { + IEnumeratorT<_TouchInfo*>* pEnumerator = pReturnList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchInfo* pTouchInfo = null; + pEnumerator->GetCurrent(pTouchInfo); + if (pTouchInfo == null) + { + continue; + } + + delete pTouchInfo; + } + delete pEnumerator; + } + pReturnList->RemoveAll(); + delete pReturnList; + pReturnList = null; + } + if (pFingerInfoList) + { + delete pFingerInfoList; + pFingerInfoList = null; + } + + return null; +} + +bool +_TouchPanningGestureDetector::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (touchinfo.GetPointId() > __maxPointId) + { + return false; + } + + if (__fingerCount < 0) + { + __fingerCount = 0; + } + + __fingerCount++; + if ( __fingerCount < __touchCount) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_READY); + } + else if (__touchCount == __fingerCount) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_READY); + SetGestureStart(true); + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_STARTED); + __pTimer->Start(POLLING_PANNING); + } + + return false; +} + +bool +_TouchPanningGestureDetector::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (touchinfo.GetPointId() > __maxPointId) + { + return false; + } + + _TouchGestureDetectorState state = GetDetectorState(); + if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED || state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS_AND_WAIT || state == _TOUCH_GESTURE_DETECTOR_STATE_CHANGED) + { + if (__touchCount > DEFAULT_TOUCH_COUNT) + { + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager != null, null, E_SYSTEM, "[E_SYSTEM] _TouchManager does not found."); + + IListT<_FingerInfo*>* pFingerInfoList = pTouchManager->GetMultiFingerInfoListN(); + bool movedAll = false; + enum moveDirection + { + NONE = 0x0, RIGHT = 0x1, UP = 0x2, LEFT = 0x4, DOWN = 0x8 + }; + + int directionList[__touchCount]; + + if (pFingerInfoList) + { + for(int i=0; i < __touchCount; i++) + { + _FingerInfo* pFingerInfo = null; + pFingerInfoList->GetAt(i, pFingerInfo); + directionList[i] = NONE; + + if (pFingerInfo) + { + Point currentPoint = pFingerInfo->GetPoint(); + Point controlPosition(0,0); + _Control* pControl = GetControl(); + if (pControl) + { + controlPosition.x = pControl->GetAbsoluteBounds().x; + controlPosition.y = pControl->GetAbsoluteBounds().y; + } + Point startPoint = pFingerInfo->GetStartPoint(); + startPoint.x = startPoint.x - controlPosition.x; + startPoint.y = startPoint.y - controlPosition.y; + + if (Math::Abs(startPoint.x - currentPoint.x) >= MIN_MOVEALLOWANCE || Math::Abs(startPoint.y - currentPoint.y) >= MIN_MOVEALLOWANCE) + { + movedAll = true; + + if (currentPoint.x - startPoint.x > 0) + { + directionList[i] |= RIGHT; + } + else if (currentPoint.x - startPoint.x < 0) + { + directionList[i] |= LEFT; + } + + if (currentPoint.y - startPoint.y > 0) + { + directionList[i] |= DOWN; + } + else if (currentPoint.y - startPoint.y < 0) + { + directionList[i] |= UP; + } + } + else + { + movedAll = false; + } + } + } + delete pFingerInfoList; + } + + if (movedAll) + { + bool sameDirection = true; + for(int i=0; i<__touchCount-1; i++) + { + if (directionList[i] != directionList[i+1]) + { + sameDirection = false; + break; + } + } + + if (sameDirection) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_CHANGED); + __pTimer->Start(POLLING_PANNING); + } + } + } + else + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_CHANGED); + __pTimer->Start(POLLING_PANNING); + } + } + return false; +} + +void +_TouchPanningGestureDetector::OnTimerExpired(Timer& timer) +{ + SetDetectorStateChanged(); + + __pTimer->Start(POLLING_PANNING); +} + +void +_TouchPanningGestureDetector::SetDetectorStateChanged(void) +{ + if ( GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_CHANGED ) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_CHANGED); + } +} + +bool +_TouchPanningGestureDetector::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (touchinfo.GetPointId() > __maxPointId) + { + return false; + } + + __fingerCount--; + _TouchGestureDetectorState state = GetDetectorState(); + __pTimer->Cancel(); + + if (IsGestureStarted()) + { + SetGestureStart(false); + if ( state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED || state == _TOUCH_GESTURE_DETECTOR_STATE_CHANGED || state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS_AND_WAIT) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_FINISHED); + } + } + + return false; +} + +bool +_TouchPanningGestureDetector::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + __fingerCount = 0; + + return false; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_TouchPanningGestureDetectorImpl.cpp b/src/ui/FUi_TouchPanningGestureDetectorImpl.cpp new file mode 100644 index 0000000..c9a3251 --- /dev/null +++ b/src/ui/FUi_TouchPanningGestureDetectorImpl.cpp @@ -0,0 +1,195 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchPanningGestureDetectorImpl.cpp + * @brief This is the implementation file for %_TouchPanningGestureDetectorImpl class + * @version 2.0 + * + * This file contains the implementation of %_TouchPanningGestureDetectorImpl class. + * + */ + +#include +#include "FUi_TouchPanningGestureDetectorImpl.h" +#include "FUi_TouchPanningGestureDetector.h" + +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +_TouchPanningGestureDetectorImpl::_TouchPanningGestureDetectorImpl(TouchPanningGestureDetector* pPublic, _TouchPanningGestureDetector* pCore) + : _TouchGestureDetectorImpl(pPublic, pCore) +{ +} + +_TouchPanningGestureDetectorImpl::~_TouchPanningGestureDetectorImpl(void) +{ +} + +_TouchPanningGestureDetectorImpl* +_TouchPanningGestureDetectorImpl::CreateInstanceN(TouchPanningGestureDetector* pPublic) +{ + ClearLastResult(); + + _TouchPanningGestureDetector* pCore = null; + pCore = new (std::nothrow) _TouchPanningGestureDetector; + SysTryReturn(NID_UI, pCore, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is shortage."); + + _TouchPanningGestureDetectorImpl* pImpl = new (std::nothrow) _TouchPanningGestureDetectorImpl(pPublic, pCore); + SysTryCatch(NID_UI, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is shortage."); + + return pImpl; + +CATCH: + delete pCore; + + return null; +} + +const _TouchPanningGestureDetector& +_TouchPanningGestureDetectorImpl::GetCore(void) const +{ + return static_cast(_TouchGestureDetectorImpl::GetCore()); +} + +_TouchPanningGestureDetector& +_TouchPanningGestureDetectorImpl::GetCore(void) +{ + return static_cast<_TouchPanningGestureDetector&>(_TouchGestureDetectorImpl::GetCore()); +} + +_TouchPanningGestureDetectorImpl* +_TouchPanningGestureDetectorImpl::GetInstance(TouchPanningGestureDetector& gestureDetector) +{ + return static_cast<_TouchPanningGestureDetectorImpl*> (gestureDetector.__pTouchGestureDetectorImpl); +} + +const _TouchPanningGestureDetectorImpl* +_TouchPanningGestureDetectorImpl::GetInstance(const TouchPanningGestureDetector& gestureDetector) +{ + return static_cast (gestureDetector.__pTouchGestureDetectorImpl); +} + +result +_TouchPanningGestureDetectorImpl::SetTouchCount(int count) +{ + return GetCore().SetTouchCount(count); +} + +int +_TouchPanningGestureDetectorImpl::GetTouchCount(void) const +{ + ClearLastResult(); + + return GetCore().GetTouchCount(); +} + +IList* +_TouchPanningGestureDetectorImpl::GetTouchInfoListN(void) const +{ + IListT<_TouchInfo*>* pTouchInfoList = GetCore().GetTouchInfoListN(GetCore().GetControl()); + SysTryReturn(NID_UI, pTouchInfoList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + IEnumeratorT<_TouchInfo*>* pEnumerator = null; + LinkedList* pReturnList = new (std::nothrow) LinkedList; + SysTryCatch(NID_UI, pReturnList,, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + for (int i = 0; i < pTouchInfoList->GetCount(); i++) + { + _TouchInfo* pFingerInfo = null; + pTouchInfoList->GetAt(i, pFingerInfo); + + if (pFingerInfo == null) + { + continue; + } + + TouchInfo* pTouchInfo = new (std::nothrow) TouchInfo; + SysTryCatch(NID_UI, pTouchInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (pFingerInfo->GetTouchStatus() == _TOUCH_PRESSED ||pFingerInfo->GetTouchStatus() == _TOUCH_MOVED ) + { + pTouchInfo->id = pFingerInfo->GetPointId(); + pTouchInfo->position.x = pFingerInfo->GetCurrentPosition().x; + pTouchInfo->position.y = pFingerInfo->GetCurrentPosition().y; + pTouchInfo->status = TOUCH_PRESSED; + + pReturnList->Add(*pTouchInfo); + } + } + + pEnumerator = pTouchInfoList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchInfo* pTouchInfo = null; + pEnumerator->GetCurrent(pTouchInfo); + if (pTouchInfo == null) + { + continue; + } + + delete pTouchInfo; + } + delete pEnumerator; + } + pTouchInfoList->RemoveAll(); + delete pTouchInfoList; + pTouchInfoList = null; + + ClearLastResult(); + + return pReturnList; + +CATCH: + if (pTouchInfoList) + { + IEnumeratorT<_TouchInfo*>* pEnumerator = pTouchInfoList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchInfo* pTouchInfo = null; + pEnumerator->GetCurrent(pTouchInfo); + if (pTouchInfo == null) + { + continue; + } + + delete pTouchInfo; + } + delete pEnumerator; + } + pTouchInfoList->RemoveAll(); + delete pTouchInfoList; + pTouchInfoList = null; + } + + if (pReturnList) + { + pReturnList->RemoveAll(true); + delete pReturnList; + pReturnList = null; + } + + return null; +} + +} } // Tizen::Ui diff --git a/src/ui/FUi_TouchPinchGestureDetector.cpp b/src/ui/FUi_TouchPinchGestureDetector.cpp new file mode 100644 index 0000000..9e18aeb --- /dev/null +++ b/src/ui/FUi_TouchPinchGestureDetector.cpp @@ -0,0 +1,267 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchPinchGestureDetector.cpp + * @brief This is the implementation file for %_TouchPinchGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %_TouchPinchGestureDetector class. + * + */ + +#include +#include +#include +#include "FUi_TouchPinchGestureDetector.h" +#include "FUi_ITouchPinchGestureEventListener.h" +#include "FUi_TouchManager.h" +#include "FUi_TouchPinchGestureDetectorImpl.h" + +// namespace +using namespace Tizen::Graphics; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; + +namespace +{ +const int DEFAULT_TOUCH_COUNT = 2; +const int POLLING_PINCH = 16; +const int PINCH_THRESHOLD = 10; +} + +namespace Tizen { namespace Ui +{ +_TouchPinchGestureDetector::_TouchPinchGestureDetector(void) + : __MinimumPoint(0, 0) + , __MaximumPoint(0, 0) + , __centerPosition(0, 0) + , __pTimer(null) + , __threshold(PINCH_THRESHOLD) + , __scale(0) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, GetErrorMessage(r)); + + __pTimer = new (std::nothrow)Timer; + SysTryReturnVoidResult(NID_UI, __pTimer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetDetectorType(_TOUCH_GESTURE_DETECTOR_TYPE_PINCH); + return; + +CATCH: + delete __pTimer; + __pTimer = null; +} + +_TouchPinchGestureDetector::~_TouchPinchGestureDetector(void) +{ + delete __pTimer; + __pTimer = null; +} + +bool +_TouchPinchGestureDetector::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + //SysLog(NID_UI, "pressId = %d, pressX = %d, pressY = %d", touchinfo.GetPointId(), touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y); + + if (MeasureArea() > __threshold) + { + SetGestureStart(true); + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_STARTED); + + _Control* pControl = GetControl(); + if (pControl && !pControl->IsMultiTouchEnabled()) + { + pControl->SetMultiTouchEnabled(true); + } + } + + return false; +} + +bool +_TouchPinchGestureDetector::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + _TouchGestureDetectorState state = GetDetectorState(); + //SysLog(NID_UI, "moveId = %d, moveX = %d, moveY = %d", touchinfo.GetPointId(), touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y); + + if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED || state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS_AND_WAIT + || state == _TOUCH_GESTURE_DETECTOR_STATE_CHANGED) + { + //SysLog(NID_UI, "enter state ok"); + if (MeasureArea() > __threshold) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_CHANGED); + } + } + + return false; +} + +void +_TouchPinchGestureDetector::OnTimerExpired(Timer& timer) +{ + SetDetectorStateChanged(); + + __pTimer->Start(POLLING_PINCH); +} + +void +_TouchPinchGestureDetector::SetDetectorStateChanged(void) +{ + _TouchGestureDetectorState state = GetDetectorState(); + + if ( state == _TOUCH_GESTURE_DETECTOR_STATE_CHANGED ) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_CHANGED); + } +} + +bool +_TouchPinchGestureDetector::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + //SysLog(NID_UI, "releaseId = %d, releaseX = %d, releaseY = %d", touchinfo.GetPointId(), touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y); + + if (MeasureArea() > __threshold) + { + return false; + } + + __pTimer->Cancel(); + + _TouchGestureDetectorState state = GetDetectorState(); + + if (IsGestureStarted()) + { + SetGestureStart(false); + if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED || state == _TOUCH_GESTURE_DETECTOR_STATE_CHANGED || state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS_AND_WAIT) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_FINISHED); + } + } + + return false; +} + +bool +_TouchPinchGestureDetector::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + __pTimer->Cancel(); + __centerPosition.x = 0; + __centerPosition.y = 0; + __scale = 0; + __MinimumPoint.x = 0; + __MinimumPoint.y = 0; + __MaximumPoint.x = 0; + __MaximumPoint.y = 0; + + return false; +} + +Point +_TouchPinchGestureDetector::GetCenterPoint(void) const +{ + return __centerPosition; +} + +int +_TouchPinchGestureDetector::GetScale(void) const +{ + return __scale; +} + +int +_TouchPinchGestureDetector::MeasureArea(void) +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager != null, null, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist."); + + IListT<_FingerInfo*>* pFingerInfoList = pTouchManager->GetMultiFingerInfoListN(); + SysTryReturn(NID_UI, pFingerInfoList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + //SysLog(NID_UI, "GetCount = %d, minX = %d, minY = %d, maxX = %d, maxY = %d", pFingerInfoList->GetCount(), __MinimumPoint.x, __MinimumPoint.y, __MaximumPoint.x, __MaximumPoint.y); + + bool initialized = false; + + __MinimumPoint.x = 0; + __MinimumPoint.y = 0; + __MaximumPoint.x = 0; + __MaximumPoint.y = 0; + + for (int i = 0; i < pFingerInfoList->GetCount(); i++) + { + _FingerInfo* pFingerInfo = null; + pFingerInfoList->GetAt(i, pFingerInfo); + + if (pFingerInfo == null || pFingerInfo->GetPointId() == INVALID_POINT_ID || + pFingerInfo->GetStatus() == _TOUCH_RELEASED || pFingerInfo->GetStatus() == _TOUCH_CANCELED) + { + continue; + } + + //SysLog(NID_UI, "pointId = %d, x = %d, y = %d", pFingerInfo->GetPointId(), pFingerInfo->GetPoint().x, pFingerInfo->GetPoint().y); + + Tizen::Graphics::Point point = pFingerInfo->GetPoint(); + + if (initialized) + { + if (__MinimumPoint.x > point.x) + { + __MinimumPoint.x = point.x; + } + if (__MinimumPoint.y > point.y) + { + __MinimumPoint.y = point.y; + } + if (__MaximumPoint.x < point.x) + { + __MaximumPoint.x = point.x; + } + if (__MaximumPoint.y < point.y) + { + __MaximumPoint.y = point.y; + } + } + else + { + __MinimumPoint.x = point.x; + __MinimumPoint.y = point.y; + __MaximumPoint.x = point.x; + __MaximumPoint.y = point.y; + + initialized = true; + } + } + + delete pFingerInfoList; + pFingerInfoList = null; + + __centerPosition.x = (__MinimumPoint.x+__MaximumPoint.x)/2; + __centerPosition.y = (__MinimumPoint.y+__MaximumPoint.y)/2; + + __scale = int(sqrt(abs(__MaximumPoint.x-__MinimumPoint.x) * abs(__MaximumPoint.y-__MinimumPoint.y))); + + initialized = false; + //SysLog(NID_UI, "centerX = %d, centerY = %d, area = %d", __centerPosition.x, __centerPosition.y, __scale); + + return __scale; +} + +} } // Tizen::Ui diff --git a/src/ui/FUi_TouchPinchGestureDetectorImpl.cpp b/src/ui/FUi_TouchPinchGestureDetectorImpl.cpp new file mode 100644 index 0000000..cee9490 --- /dev/null +++ b/src/ui/FUi_TouchPinchGestureDetectorImpl.cpp @@ -0,0 +1,104 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchPinchGestureDetectorImpl.cpp + * @brief This is the implementation file for %_TouchPinchGestureDetectorImpl class + * @version 2.0 + * + * This file contains the implementation of %_TouchPinchGestureDetectorImpl class. + * + */ + +#include +#include "FUi_TouchPinchGestureDetectorImpl.h" +#include "FUi_TouchPinchGestureDetector.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +_TouchPinchGestureDetectorImpl::_TouchPinchGestureDetectorImpl(TouchPinchGestureDetector* pPublic, _TouchPinchGestureDetector* pCore) + : _TouchGestureDetectorImpl(pPublic, pCore) +{ +} + +_TouchPinchGestureDetectorImpl::~_TouchPinchGestureDetectorImpl(void) +{ +} + +_TouchPinchGestureDetectorImpl* +_TouchPinchGestureDetectorImpl::CreateInstanceN(TouchPinchGestureDetector* pPublic) +{ + ClearLastResult(); + + _TouchPinchGestureDetector* pCore = null; + pCore = new (std::nothrow) _TouchPinchGestureDetector; + SysTryReturn(NID_UI, pCore, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + _TouchPinchGestureDetectorImpl* pImpl = new (std::nothrow) _TouchPinchGestureDetectorImpl(pPublic, pCore); + SysTryCatch(NID_UI, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pImpl; + +CATCH: + delete pCore; + + return null; +} + +const _TouchPinchGestureDetector& +_TouchPinchGestureDetectorImpl::GetCore(void) const +{ + return static_cast(_TouchGestureDetectorImpl::GetCore()); +} + +_TouchPinchGestureDetector& +_TouchPinchGestureDetectorImpl::GetCore(void) +{ + return static_cast<_TouchPinchGestureDetector&>(_TouchGestureDetectorImpl::GetCore()); +} + +_TouchPinchGestureDetectorImpl* +_TouchPinchGestureDetectorImpl::GetInstance(TouchPinchGestureDetector& gestureDetector) +{ + return static_cast<_TouchPinchGestureDetectorImpl*> (gestureDetector.__pTouchGestureDetectorImpl); +} + +const _TouchPinchGestureDetectorImpl* +_TouchPinchGestureDetectorImpl::GetInstance(const TouchPinchGestureDetector& gestureDetector) +{ + return static_cast (gestureDetector.__pTouchGestureDetectorImpl); +} + +Point +_TouchPinchGestureDetectorImpl::GetCenterPoint(void) const +{ + ClearLastResult(); + + return GetCore().GetCenterPoint(); +} + +int +_TouchPinchGestureDetectorImpl::GetScale(void) const +{ + ClearLastResult(); + + return GetCore().GetScale(); +} + +} } //Tizen::Ui diff --git a/src/ui/FUi_TouchRotationGestureDetector.cpp b/src/ui/FUi_TouchRotationGestureDetector.cpp new file mode 100644 index 0000000..fa9a42a --- /dev/null +++ b/src/ui/FUi_TouchRotationGestureDetector.cpp @@ -0,0 +1,396 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchRotationGestureDetector.cpp + * @brief This is the implementation file for %_TouchRotationGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %_TouchRotationGestureDetector class. + * + */ +#include +#include +#include +#include +#include "FUi_TouchRotationGestureDetector.h" +#include "FUi_ITouchRotationGestureEventListener.h" +#include "FUi_TouchRotationGestureDetectorImpl.h" +#include "FUi_Control.h" +#include "FUi_FingerInfo.h" + +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; + +namespace +{ +const float PI = 3.14159265; +const float RAD_90DEGREE = PI / 2; +const float RAD_180DEGREE = PI; +const float RAD_270DEGREE = RAD_90DEGREE * 3; +const float RAD_360DEGREE = RAD_180DEGREE * 2; +const int DEFAULT_TOUCH_COUNT = 2; +const int MIN_ANGLE = 15; +const float DEGREE_360 = 360.0; +const int DEGREE_180 = 180; +const int DEGREE_90 = 90; +const int MIN_MOVEALLOWANCE = 20; +const int POLLING_ROTATION = 16; +const unsigned int SECOND_POINT_ID = 1; +} + +namespace Tizen { namespace Ui +{ +_TouchRotationGestureDetector::_TouchRotationGestureDetector(void) + : __distance(0) + , __angle(0) + , __fingerCount(0) + , __firstPoint(0, 0) + , __secondPoint(0, 0) + , __firstPrevPoint(0, 0) + , __secondPrevPoint(0, 0) + , __firstMovedDirection(0) + , __secondMovedDirection(0) + , __pTimer(null) + , __firstPointId(INVALID_POINT_ID) + , __secondPointId(INVALID_POINT_ID) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, GetErrorMessage(r)); + + __pTimer = new (std::nothrow) Timer; + SysTryReturnVoidResult(NID_UI, __pTimer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetDetectorType(_TOUCH_GESTURE_DETECTOR_TYPE_ROTATION); + return; + +CATCH: + delete __pTimer; + __pTimer = null; +} + +_TouchRotationGestureDetector::~_TouchRotationGestureDetector(void) +{ + delete __pTimer; + __pTimer = null; +} + +double +_TouchRotationGestureDetector::GetAngle(int x1, int y1, int x2, int y2) const +{ + int tempX = 0; + int tempY = 0; + float angle = 0; + + tempX= -y1; + tempY = x1; + + angle = acos( (tempX * x2 + tempY * y2) / + (sqrt( tempX * tempX + tempY * tempY ) * + sqrt(x2 * x2 + y2 * y2) ) )* DEGREE_180 / PI; + + if (angle > DEGREE_90) + { + angle = DEGREE_360 - acos( (x1 * x2 + y1 * y2) / + (sqrt( x1 * x1 + y1 * y1 ) * + sqrt(x2 * x2 + y2 * y2) ) )* DEGREE_180 / PI; + } + else + { + angle = acos( (x1 * x2 + y1 * y2) / + (sqrt( x1 * x1 + y1 * y1 ) * + sqrt(x2 * x2 + y2 * y2) ) )* DEGREE_180 / PI; + } + + return angle; +} + +float +_TouchRotationGestureDetector::GetAngle(void) const +{ + return __angle; +} + +int +_TouchRotationGestureDetector::GetDistance(void) const +{ + return __distance; +} + +bool +_TouchRotationGestureDetector::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + __fingerCount++; + + switch(__fingerCount) + { + case 1: + { + __firstPrevPoint.x = touchinfo.GetCurrentPosition().x; + __firstPrevPoint.y = touchinfo.GetCurrentPosition().y; + __firstPoint.x = touchinfo.GetCurrentPosition().x; + __firstPoint.y = touchinfo.GetCurrentPosition().y; + __distance = 0; + __angle = 0; + __firstPointId = touchinfo.GetPointId(); + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_READY); + } + break; + + case 2: + { + __secondPrevPoint.x = touchinfo.GetCurrentPosition().x; + __secondPrevPoint.y = touchinfo.GetCurrentPosition().y; + __secondPoint.x = touchinfo.GetCurrentPosition().x; + __secondPoint.y = touchinfo.GetCurrentPosition().y; + __distance = Distance(__firstPrevPoint.x, __firstPrevPoint.y, __secondPrevPoint.x, __secondPrevPoint.y); + __angle = 0; + __secondPointId = touchinfo.GetPointId(); + __firstMovedDirection = 0; + __secondMovedDirection = 0; + SetGestureStart(true); + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_STARTED); + + _Control* pControl = GetControl(); + if (pControl && !pControl->IsMultiTouchEnabled()) + { + pControl->SetMultiTouchEnabled(true); + } + } + break; + + default: + break; + } + + return false; +} + +bool +_TouchRotationGestureDetector::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (touchinfo.GetPointId() == __firstPointId || touchinfo.GetPointId() == __secondPointId) + { + float angle = 0; + _TouchGestureDetectorState state = GetDetectorState(); + + if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED || state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS_AND_WAIT || state == _TOUCH_GESTURE_DETECTOR_STATE_CHANGED) + { + if (touchinfo.GetPointId() == __firstPointId) + { + if (state == _TOUCH_GESTURE_DETECTOR_STATE_CHANGED) + { + __firstPrevPoint.x = __firstPoint.x; + __firstPrevPoint.y = __firstPoint.y; + } + + __firstPoint.x = touchinfo.GetCurrentPosition().x; + __firstPoint.y = touchinfo.GetCurrentPosition().y; + angle = GetAngle(__secondPoint.x - __firstPrevPoint.x, __secondPoint.y - __firstPrevPoint.y, __secondPoint.x - __firstPoint.x, __secondPoint.y - __firstPoint.y); + } + else + { + if (state == _TOUCH_GESTURE_DETECTOR_STATE_CHANGED) + { + __secondPrevPoint.x = __secondPoint.x; + __secondPrevPoint.y = __secondPoint.y; + } + + __secondPoint.x = touchinfo.GetCurrentPosition().x; + __secondPoint.y = touchinfo.GetCurrentPosition().y; + angle = GetAngle(__firstPoint.x-__secondPrevPoint.x, __firstPoint.y - __secondPrevPoint.y, __firstPoint.x - __secondPoint.x, __firstPoint.y - __secondPoint.y); + } + + __distance = Distance(__firstPoint.x, __firstPoint.y, __secondPoint.x, __secondPoint.y); + + if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED) + { + if (Math::Abs(__firstPrevPoint.x - __firstPoint.x) >= MIN_MOVEALLOWANCE + || Math::Abs(__firstPrevPoint.y - __firstPoint.y) >= MIN_MOVEALLOWANCE + || Math::Abs(__secondPrevPoint.x - __secondPoint.x) >= MIN_MOVEALLOWANCE + || Math::Abs(__secondPrevPoint.y - __secondPoint.y) >= MIN_MOVEALLOWANCE) + { + enum moveDirection + { + NONE = 0x0, RIGHT = 0x1, UP = 0x2, LEFT = 0x4, DOWN = 0x8 + }; + + if (__firstPrevPoint.y - __firstPoint.y > 0) + { + if (__firstMovedDirection & DOWN) + { + __firstMovedDirection ^= DOWN; + } + + __firstMovedDirection |= UP; + } + else if (__firstPrevPoint.y - __firstPoint.y < 0) + { + if (__firstMovedDirection & UP) + { + __firstMovedDirection ^= UP; + } + + __firstMovedDirection |= DOWN; + } + + if (__secondPrevPoint.y - __secondPoint.y > 0) + { + if (__secondMovedDirection & DOWN) + { + __secondMovedDirection ^= DOWN; + } + + __secondMovedDirection |= UP; + + } + else if (__secondPrevPoint.y - __secondPoint.y < 0) + { + if (__secondMovedDirection & UP) + { + __secondMovedDirection ^= UP; + } + + __secondMovedDirection |= DOWN; + } + +// Do not check same direction during rotation gesture. +// If not check the direction, it dooesn't display any result until. +/* + if (__firstMovedDirection & __secondMovedDirection) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_FINISHED); + return false; + } +*/ + } + + if (angle >= DEGREE_360 - (MIN_ANGLE*2)) + { + if (angle <= DEGREE_360 - MIN_ANGLE) + { + __angle = -(DEGREE_360 - angle); + +/* if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED) + { + __pTimer->Start(POLLING_ROTATION); + }*/ + + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_CHANGED); + } + } + else + { + if (angle >= MIN_ANGLE) + { + __angle = angle; + + /* if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED) + { + __pTimer->Start(POLLING_ROTATION); + }*/ + + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_CHANGED); + } + } + } + else + { + if (angle >= DEGREE_360 - MIN_ANGLE) + { + __angle = -(DEGREE_360 - angle); + } + else + { + __angle = angle; + } + + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_CHANGED); + } + } + } + + return false; +} + +void +_TouchRotationGestureDetector::OnTimerExpired(Timer& timer) +{ + SetDetectorStateChanged(); + + __pTimer->Start(POLLING_ROTATION); +} + +void +_TouchRotationGestureDetector::SetDetectorStateChanged(void) +{ + if (GetDetectorState() == _TOUCH_GESTURE_DETECTOR_STATE_CHANGED) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_CHANGED); + } +} + +bool +_TouchRotationGestureDetector::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + __fingerCount--; + + if (touchinfo.GetPointId() == __firstPointId || touchinfo.GetPointId() == __secondPointId) + { + __pTimer->Cancel(); + + if (touchinfo.GetPointId() == __firstPointId) + { + __firstPointId = INVALID_POINT_ID; + } + else + { + __secondPointId = INVALID_POINT_ID; + } + + _TouchGestureDetectorState state = GetDetectorState(); + + if (IsGestureStarted()) + { + SetGestureStart(false); + if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED || state == _TOUCH_GESTURE_DETECTOR_STATE_CHANGED || state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS_AND_WAIT) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_FINISHED); + } + } + } + + return false; +} + +bool +_TouchRotationGestureDetector::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + __firstMovedDirection = 0; + __secondMovedDirection = 0; + __fingerCount = 0; + __firstPointId = INVALID_POINT_ID; + __secondPointId = INVALID_POINT_ID; + __pTimer->Cancel(); + + return false; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_TouchRotationGestureDetectorImpl.cpp b/src/ui/FUi_TouchRotationGestureDetectorImpl.cpp new file mode 100644 index 0000000..63a8a31 --- /dev/null +++ b/src/ui/FUi_TouchRotationGestureDetectorImpl.cpp @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchRotationGestureDetectorImpl.cpp + * @brief This is the implementation file for %_TouchRotationGestureDetectorImpl class + * @version 2.0 + * + * This file contains the implementation of %_TouchRotationGestureDetectorImpl class. + * + */ + +// includes +#include +#include "FUi_TouchRotationGestureDetector.h" +#include "FUi_TouchRotationGestureDetectorImpl.h" + +namespace Tizen { namespace Ui +{ + +_TouchRotationGestureDetectorImpl::_TouchRotationGestureDetectorImpl(TouchRotationGestureDetector* pPublic, _TouchRotationGestureDetector* pCore) + : _TouchGestureDetectorImpl(pPublic, pCore) +{ +} + +_TouchRotationGestureDetectorImpl::~_TouchRotationGestureDetectorImpl(void) +{ +} + +_TouchRotationGestureDetectorImpl* +_TouchRotationGestureDetectorImpl::CreateInstanceN(TouchRotationGestureDetector* pPublic) +{ + ClearLastResult(); + + _TouchRotationGestureDetector* pCore = null; + pCore = new (std::nothrow) _TouchRotationGestureDetector; + SysTryReturn(NID_UI, pCore, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is shortage."); + + _TouchRotationGestureDetectorImpl* pImpl = new (std::nothrow) _TouchRotationGestureDetectorImpl(pPublic, pCore); + SysTryCatch(NID_UI, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is shortage."); + + return pImpl; + +CATCH: + delete pCore; + + return null; +} + +const _TouchRotationGestureDetector& +_TouchRotationGestureDetectorImpl::GetCore(void) const +{ + return static_cast(_TouchGestureDetectorImpl::GetCore()); +} + +_TouchRotationGestureDetector& +_TouchRotationGestureDetectorImpl::GetCore(void) +{ + return static_cast<_TouchRotationGestureDetector&>(_TouchGestureDetectorImpl::GetCore()); +} + +_TouchRotationGestureDetectorImpl* +_TouchRotationGestureDetectorImpl::GetInstance(TouchRotationGestureDetector& gestureDetector) +{ + return static_cast<_TouchRotationGestureDetectorImpl*> (gestureDetector.__pTouchGestureDetectorImpl); +} + +const _TouchRotationGestureDetectorImpl* +_TouchRotationGestureDetectorImpl::GetInstance(const TouchRotationGestureDetector& gestureDetector) +{ + return static_cast (gestureDetector.__pTouchGestureDetectorImpl); +} + +float +_TouchRotationGestureDetectorImpl::GetAngle(void) const +{ + ClearLastResult(); + + return GetCore().GetAngle(); +} + +int +_TouchRotationGestureDetectorImpl::GetDistance(void) const +{ + ClearLastResult(); + + return GetCore().GetDistance(); +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_TouchTapGestureDetector.cpp b/src/ui/FUi_TouchTapGestureDetector.cpp new file mode 100644 index 0000000..03b0277 --- /dev/null +++ b/src/ui/FUi_TouchTapGestureDetector.cpp @@ -0,0 +1,437 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchTapGestureDetector.cpp + * @brief This is the implementation file for %_TouchTapGestureDetector class + * @version 2.0 + * + * This file contains the implementation of %_TouchTapGestureDetector class. + * + */ +#include +#include +#include +#include +#include "FUi_TouchTapGestureDetector.h" +#include "FUi_TouchManager.h" +#include "FUi_ITouchTapGestureEventListener.h" +#include "FUi_TouchTapGestureDetectorImpl.h" +#include "FUi_FingerInfo.h" +#include "FUi_TouchGestureTimerManager.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base::Utility; +using namespace Tizen::Base::Collection; + +namespace +{ +const int DEFAULT_INTERNAL = 330; +const int DEFAULT_TAP_COUNT = 2; +const int DEFAULT_MOVE_ALLOWANCE = 10; +const int DEFAULT_TOUCH_COUNT = 1; +const int MAX_TOUCH_COUNT = 10; +const int INIT_TAP_COUNT = 1; +const int INVALID_POINT_ID = 9999; +} + +namespace Tizen { namespace Ui +{ + +class _TouchTapGestureDetector::_TapInfo +{ +public: + bool __isPressed; + int __tappedCount; +}; + +_TouchTapGestureDetector::_TouchTapGestureDetector(void) + : __tapCount(DEFAULT_TAP_COUNT) + , __interval(DEFAULT_INTERNAL) + , __touchCount(DEFAULT_TOUCH_COUNT) + , __oneTapMoveAllowance(DEFAULT_MOVE_ALLOWANCE) + , __oneTapIsInBounds(true) + , __maxPointId(DEFAULT_TOUCH_COUNT-1) + , __oneTapStartPoint(0, 0) + , __pGestureTimerManager(null) + , __pTapInfoList(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, GetErrorMessage(r)); + + __pGestureTimerManager = new (std::nothrow) _TouchGestureTimerManager(*this); + SysTryReturnVoidResult(NID_UI, __pGestureTimerManager, E_SYSTEM, "[E_SYSTEM] System error occurred.."); + + __pTapInfoList = new (std::nothrow) ArrayListT<_TapInfo*>; + SysTryReturnVoidResult(NID_UI, __pTapInfoList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + for(int i=0; i < MAX_TOUCH_COUNT; i++) + { + _TapInfo* pTapInfo = new (std::nothrow) _TapInfo; + SysTryCatch(NID_UI, pTapInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pTapInfo->__isPressed = false; + pTapInfo->__tappedCount = 0; + + __pTapInfoList->Add(pTapInfo); + } + + SetDetectorType(_TOUCH_GESTURE_DETECTOR_TYPE_TAP); + return; + +CATCH: + if (__pGestureTimerManager) + { + delete __pGestureTimerManager; + __pGestureTimerManager = null; + } + + if (__pTapInfoList) + { + RemoveTapInfoList(); + delete __pTapInfoList; + __pTapInfoList = null; + } +} + +_TouchTapGestureDetector::~_TouchTapGestureDetector(void) +{ + RemoveTapInfoList(); + __pTapInfoList->RemoveAll(); + + delete __pTapInfoList; + __pTapInfoList = null; + + delete __pGestureTimerManager; + __pGestureTimerManager = null; +} + +void +_TouchTapGestureDetector::RemoveTapInfoList(void) +{ + IEnumeratorT<_TapInfo*>* pEnumerator = __pTapInfoList->GetEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + _TapInfo* pTapInfo = null; + pEnumerator->GetCurrent(pTapInfo); + if (!pTapInfo) + { + continue; + } + delete pTapInfo; + } + delete pEnumerator; + } +} + +result +_TouchTapGestureDetector::SetTapCount(int count) +{ + SysTryReturnResult(NID_UI, count > 0, E_INVALID_ARG, "[E_INVALID_ARG] Argument is less than 0"); + + __tapCount = count; + return E_SUCCESS; +} + +int +_TouchTapGestureDetector::GetTapCount(void) const +{ + return __tapCount; +} + +result +_TouchTapGestureDetector::SetTapInterval(long intarval) +{ + SysTryReturnResult(NID_UI, intarval > 0, E_INVALID_ARG, "[E_INVALID_ARG] Argument is less than 0"); + + __interval = intarval; + return E_SUCCESS; +} + +long +_TouchTapGestureDetector::GetTapInterval(void) const +{ + return __interval; +} + +result +_TouchTapGestureDetector::SetTouchCount(int count) +{ + SysTryReturnResult(NID_UI, count > 0, E_INVALID_ARG, "[E_INVALID_ARG] Argument is less than 0"); + + __touchCount = count; + __maxPointId = __touchCount - 1; + + if (__touchCount > DEFAULT_TOUCH_COUNT) + { + _Control* pControl = GetControl(); + if (pControl && !pControl->IsMultiTouchEnabled()) + { + pControl->SetMultiTouchEnabled(true); + } + } + return E_SUCCESS; +} + +int +_TouchTapGestureDetector::GetTouchCount(void) const +{ + return __touchCount; +} + +result +_TouchTapGestureDetector::SetMoveAllowance(int allowance) +{ + SysTryReturnResult(NID_UI, allowance >= 0, E_INVALID_ARG, "[E_INVALID_ARG] Argument is less than 0"); + SysTryReturnResult(NID_UI, __touchCount == DEFAULT_TOUCH_COUNT, E_INVALID_CONDITION, "[E_INVALID_CONDITION] move allowance applies only for default(1) touch count."); + + __oneTapMoveAllowance = allowance; + + return E_SUCCESS; +} + +int +_TouchTapGestureDetector::GetMoveAllowance(void) const +{ + return __oneTapMoveAllowance; +} + +bool +_TouchTapGestureDetector::IsInBounds(void) +{ + return __oneTapIsInBounds; +} + +bool +_TouchTapGestureDetector::IsAllTapped(void) +{ + bool allTapped = true; + + for(int i=0; i<__touchCount; i++) + { + _TapInfo* pTapInfo = null; + __pTapInfoList->GetAt(i, pTapInfo); + if (!pTapInfo) + { + continue; + } + + if (pTapInfo->__isPressed && pTapInfo->__tappedCount >= __tapCount) + { + allTapped = true; + } + else + { + allTapped = false; + } + } + + return allTapped; +} + +bool +_TouchTapGestureDetector::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (touchinfo.GetPointId() > __maxPointId || GetDetectorState() != _TOUCH_GESTURE_DETECTOR_STATE_READY) + { + return false; + } + + _TapInfo* pTapInfo = null; + __pTapInfoList->GetAt(touchinfo.GetPointId(), pTapInfo); + SysTryReturn(NID_UI, pTapInfo, false, E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + if (__touchCount == DEFAULT_TOUCH_COUNT) + { + if (pTapInfo->__tappedCount == 0) + { + __oneTapStartPoint.x = touchinfo.GetCurrentPosition().x; + __oneTapStartPoint.y = touchinfo.GetCurrentPosition().y; + } + + if (Math::Abs(touchinfo.GetCurrentPosition().x - __oneTapStartPoint.x) > __oneTapMoveAllowance + || Math::Abs(touchinfo.GetCurrentPosition().y - __oneTapStartPoint.y) > __oneTapMoveAllowance) + { + __oneTapIsInBounds = false; + } + else + { + __oneTapIsInBounds = true; + } + } + else + { + __oneTapIsInBounds = true; + } + + pTapInfo->__isPressed = true; + + SysTryReturn(NID_UI, __pTapInfoList->SetAt(pTapInfo, touchinfo.GetPointId()) == E_SUCCESS, + false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + bool allTouched = false; + + for(int i=0; i<__touchCount; i++) + { + _TapInfo* pAllTapInfo = null; + __pTapInfoList->GetAt(i, pAllTapInfo); + if (pAllTapInfo) + { + if (pAllTapInfo->__isPressed) + { + allTouched = true; + } + else + { + allTouched = false; + } + } + } + + if (allTouched && !IsGestureStarted()) + { + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_READY); + SetGestureStart(true); + + if (__pGestureTimerManager->IsTimerStarted() == false) + { + _Control* pControl = GetControl(); + if (!pControl) + { + SetControl(source); + } + + if (__pGestureTimerManager->StartTimer(__interval) != E_SUCCESS) + { + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Tapping timer is not started."); + } + } + } + + return false; +} + +bool +_TouchTapGestureDetector::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if ((touchinfo.GetPointId() > __maxPointId) || (GetDetectorState() != _TOUCH_GESTURE_DETECTOR_STATE_READY)) + { + return false; + } + + if (__touchCount == DEFAULT_TOUCH_COUNT) + { + if (Math::Abs(touchinfo.GetCurrentPosition().x - __oneTapStartPoint.x) > __oneTapMoveAllowance + || Math::Abs(touchinfo.GetCurrentPosition().y - __oneTapStartPoint.y) > __oneTapMoveAllowance) + { + __oneTapIsInBounds = false; + __pGestureTimerManager->CancelTimer(); + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_FAILED); + ClearTapInfoList(); + } + } + + return false; +} + +bool +_TouchTapGestureDetector::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if ((touchinfo.GetPointId() > __maxPointId) || (GetDetectorState() != _TOUCH_GESTURE_DETECTOR_STATE_READY)) + { + return false; + } + + _TapInfo* pTapInfo = null; + __pTapInfoList->GetAt(touchinfo.GetPointId(), pTapInfo); + SysTryReturn(NID_UI, pTapInfo, false, E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + if (pTapInfo->__isPressed) + { + pTapInfo->__tappedCount++; + SysTryReturn(NID_UI, __pTapInfoList->SetAt(pTapInfo, touchinfo.GetPointId()) == E_SUCCESS, + false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + if (__touchCount == DEFAULT_TOUCH_COUNT) + { + if (Math::Abs(touchinfo.GetCurrentPosition().x - __oneTapStartPoint.x) > __oneTapMoveAllowance + || Math::Abs(touchinfo.GetCurrentPosition().y - __oneTapStartPoint.y) > __oneTapMoveAllowance) + { + __oneTapIsInBounds = false; + } + } + } + + if (IsGestureStarted() && !__pGestureTimerManager->IsTimerExpired()) + { + if (IsAllTapped() && IsInBounds()) + { + __pGestureTimerManager->CancelTimer(); + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_SUCCESS); + ClearTapInfoList(); + } + } + else + { + if (!IsAllTapped() && !IsGestureStarted()) + { + if (!__pGestureTimerManager->IsTimerExpired()) + { + __pGestureTimerManager->CancelTimer(); + } + SetDetectorState(_TOUCH_GESTURE_DETECTOR_STATE_FAILED); + ClearTapInfoList(); + } + } + + return false; +} + +bool +_TouchTapGestureDetector::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearTapInfoList(); + + if (__pGestureTimerManager->IsTimerExpired() == false) + { + __pGestureTimerManager->CancelTimer(); + } + + return false; +} + +void +_TouchTapGestureDetector::ClearTapInfoList(void) +{ + for(int i=0; i < MAX_TOUCH_COUNT; i++) + { + _TapInfo* pTapInfo = null; + __pTapInfoList->GetAt(i, pTapInfo); + if (!pTapInfo) + { + continue; + } + + pTapInfo->__isPressed = false; + pTapInfo->__tappedCount = 0; + + __pTapInfoList->SetAt(pTapInfo, i); + } +} + +}} //Tizen::Ui diff --git a/src/ui/FUi_TouchTapGestureDetectorImpl.cpp b/src/ui/FUi_TouchTapGestureDetectorImpl.cpp new file mode 100644 index 0000000..1c0a93e --- /dev/null +++ b/src/ui/FUi_TouchTapGestureDetectorImpl.cpp @@ -0,0 +1,138 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchTapGestureDetectorImpl.cpp + * @brief This is the implementation file for %_TouchTapGestureDetectorImpl class + * @version 2.0 + * + * This file contains the implementation of% _TouchTapGestureDetectorImpl class. + * + */ + +#include "FUi_TouchTapGestureDetectorImpl.h" + +namespace Tizen { namespace Ui +{ + +_TouchTapGestureDetectorImpl::_TouchTapGestureDetectorImpl(TouchTapGestureDetector* pPublic, _TouchTapGestureDetector* pCore) + : _TouchGestureDetectorImpl(pPublic, pCore) +{ +} + +_TouchTapGestureDetectorImpl::~_TouchTapGestureDetectorImpl(void) +{ +} + +_TouchTapGestureDetectorImpl* +_TouchTapGestureDetectorImpl::CreateInstanceN(TouchTapGestureDetector* pPublic) +{ + ClearLastResult(); + + _TouchTapGestureDetector* pCore = null; + pCore = new (std::nothrow) _TouchTapGestureDetector; + SysTryReturn(NID_UI, pCore, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + _TouchTapGestureDetectorImpl* pImpl = new (std::nothrow) _TouchTapGestureDetectorImpl(pPublic, pCore); + SysTryCatch(NID_UI, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pImpl; + +CATCH: + delete pCore; + + return null; +} + +const _TouchTapGestureDetector& +_TouchTapGestureDetectorImpl::GetCore(void) const +{ + return static_cast(_TouchGestureDetectorImpl::GetCore()); +} + +_TouchTapGestureDetector& +_TouchTapGestureDetectorImpl::GetCore(void) +{ + return static_cast<_TouchTapGestureDetector&>(_TouchGestureDetectorImpl::GetCore()); +} + +_TouchTapGestureDetectorImpl* +_TouchTapGestureDetectorImpl::GetInstance(TouchTapGestureDetector& gestureDetector) +{ + return static_cast<_TouchTapGestureDetectorImpl*> (gestureDetector.__pTouchGestureDetectorImpl); +} + +const _TouchTapGestureDetectorImpl* +_TouchTapGestureDetectorImpl::GetInstance(const TouchTapGestureDetector& gestureDetector) +{ + return static_cast (gestureDetector.__pTouchGestureDetectorImpl); +} + +result +_TouchTapGestureDetectorImpl::SetTapCount(int count) +{ + return GetCore().SetTapCount(count); +} + +int +_TouchTapGestureDetectorImpl::GetTapCount(void) const +{ + ClearLastResult(); + + return GetCore().GetTapCount(); +} + +result +_TouchTapGestureDetectorImpl::SetTapInterval(long intarval) +{ + return GetCore().SetTapInterval(intarval); +} + +long +_TouchTapGestureDetectorImpl::GetTapInterval(void) const +{ + ClearLastResult(); + + return GetCore().GetTapInterval(); +} + +result +_TouchTapGestureDetectorImpl::SetMoveAllowance(int allowance) +{ + return GetCore().SetMoveAllowance(allowance); +} + +int +_TouchTapGestureDetectorImpl::GetMoveAllowance(void) const +{ + return GetCore().GetMoveAllowance(); +} + +result +_TouchTapGestureDetectorImpl::SetTouchCount(int count) +{ + return GetCore().SetTouchCount(count); +} + +int +_TouchTapGestureDetectorImpl::GetTouchCount(void) const +{ + ClearLastResult(); + + return GetCore().GetTouchCount(); +} + +} } //Tizen::Ui diff --git a/src/ui/FUi_UiBuilder.cpp b/src/ui/FUi_UiBuilder.cpp new file mode 100644 index 0000000..1e2b56b --- /dev/null +++ b/src/ui/FUi_UiBuilder.cpp @@ -0,0 +1,466 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUi_UiBuilder.cpp +* @brief This is the implementation file for _UiBuilder class. +*/ + +#include +#include +#include +#include +#include +#include "FUiCtrl_FrameImpl.h" +#include "FUi_UiBuilder.h" +#include "FUi_UiBuilderXmlHandler.h" +#include "FUi_ControlManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Media; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ +_UiBuilder::_UiBuilder(void) + : __version(0) + , __lastIndex(0) + , __logicalResolution(0) + , __pUiBuilderControlList(null) + , __pContainer(null) + , __rotate(UIBUIDER_SCREEN_NONE) + , __pTransform(null) + , __xmlFile(L"") +{ +} + +_UiBuilder::~_UiBuilder(void) +{ + if (__pUiBuilderControlList) + { + _UiBuilderControl* pUiBuilderControl = null; + int controlCount = __pUiBuilderControlList->GetCount(); + for (int i = 0; i < controlCount; i++) + { + __pUiBuilderControlList->GetAt(i, pUiBuilderControl); + delete pUiBuilderControl; + } + __pUiBuilderControlList->RemoveAll(); + delete __pUiBuilderControlList; + __pUiBuilderControlList = null; + } +} + +_UiBuilderControl* +_UiBuilder::GetControl(int index) const +{ + SysTryReturn(NID_UI, index >= 0 && index < UIBUILDER_CONTROL_MAX_COUNT, null, E_INVALID_ARG, + "[E_INVALID_ARG] Index is over than max control count"); + + _UiBuilderControl* pUiBuilderControl = null; + __pUiBuilderControlList->GetAt(index, pUiBuilderControl); + if (pUiBuilderControl == null) + { + SysLogException(NID_UI, GetLastResult(), "Failed to GetControl()"); + return null; + } + + return pUiBuilderControl; +} + +_UiBuilderControl* +_UiBuilder::GetControl(const Tizen::Base::String& id) const +{ + IEnumeratorT<_UiBuilderControl*>* pEnum = __pUiBuilderControlList->GetEnumeratorN(); + SysTryReturn(NID_UI, pEnum != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to get IEnumeratorT."); + _UiBuilderControl* pUiBuilderControl = null; + + while (pEnum->MoveNext() == E_SUCCESS) + { + pEnum->GetCurrent(pUiBuilderControl); + String controlId = pUiBuilderControl->GetId(); + + if (controlId.Equals(id, false)) + { + delete pEnum; + return pUiBuilderControl; + } + } + delete pEnum; + return null; + +} + +void +_UiBuilder::SetVersion(int xmlVersion) +{ + __version = xmlVersion; +} + +int +_UiBuilder::GetVersion(void) const +{ + return __version; +} + +result +_UiBuilder::Construct(const String& xmlFile, Container* pContainer) +{ + result r = E_SUCCESS; + + __pContainer = pContainer; + __xmlFile = xmlFile; + __pUiBuilderControlList = new (std::nothrow) ArrayListT<_UiBuilderControl*>; + SysTryCatch(NID_UI, __pUiBuilderControlList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create __pUiBuilderControlList."); + + return r; + + CATCH: + + delete __pUiBuilderControlList; + return r; +} + +result +_UiBuilder::MakeUI(_UiBuilderControl* pControl) +{ + result r = E_SUCCESS; + + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + if(pUiBuilderControlTableManager == null) + { + return E_OUT_OF_MEMORY; + } + + for (int i = 0; i < UIBUILDER_CONTROL_MAX_COUNT; i++) + { + if (pUiBuilderControlTableManager->GetName(i).IsEmpty()) + { + break; + } + + if (pControl->GetType().Equals(pUiBuilderControlTableManager->GetName(i), false)) + { + _UiBuilderControlMakerFunctionPointer pControlMakerFunctionPointer = pUiBuilderControlTableManager->GetControlMaker(i); + if (pControlMakerFunctionPointer != null) + { + _UiBuilderControlMaker* pMaker = pControlMakerFunctionPointer(this); + r = pMaker->MakeControl(pControl); + + delete pMaker; + return r; + } + } + + } + + return E_OPERATION_FAILED; +} + +result +_UiBuilder::Parse(void) +{ + File file; + ByteBuffer buffer; + FileAttributes attrib; + int readCount = 0; + byte* pXmlContents = null; + result r = E_SUCCESS; + bool findPath = false; + int size = 0; + String xmlFilePath(L""); + String temp; + String homePath; + + __logicalResolution = _CoordinateSystem::GetInstance()->GetLogicalResolutionInt(); + + xmlFilePath.Append(__xmlFile); + xmlFilePath.Append(L".xml"); + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager != null, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Unable to get the control manager"); + + Dimension screenSize = pControlManager->GetScreenSize(); + + // find xml file with device deviceResolution + + temp = xmlFilePath; + r = temp.Insert("/", 0); + SysTryReturn(NID_UI, r == E_SUCCESS, E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Propagated.", GetErrorMessage(r)); + r = temp.Insert(screenSize.height, 0); + SysTryReturn(NID_UI, r == E_SUCCESS, E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Propagated.", GetErrorMessage(r)); + r = temp.Insert("x", 0); + SysTryReturn(NID_UI, r == E_SUCCESS, E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Propagated.", GetErrorMessage(r)); + r = temp.Insert(screenSize.width, 0); + SysTryReturn(NID_UI, r == E_SUCCESS, E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Propagated.", GetErrorMessage(r)); + r = temp.Insert("res/", 0); + SysTryReturn(NID_UI, r == E_SUCCESS, E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Propagated.", GetErrorMessage(r)); + + homePath = Tizen::App::App::GetInstance()->GetAppRootPath(); + r = temp.Insert(homePath, 0); + SysTryReturn(NID_UI, r == E_SUCCESS, E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Propagated.", GetErrorMessage(r)); + SysLog(NID_IO, "[UiBuilder] ui builder res path: %ls", temp.GetPointer()); + + // find device deviceResolution directory + if (!File::IsFileExist(temp)) + { + temp = xmlFilePath; + r = temp.Insert("res/screen-size-normal/", 0); + SysTryReturn(NID_UI, r == E_SUCCESS, E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Propagated.", GetErrorMessage(r)); + + homePath = Tizen::App::App::GetInstance()->GetAppRootPath(); + r = temp.Insert(homePath, 0); + SysTryReturn(NID_UI, r == E_SUCCESS, E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Propagated.", GetErrorMessage(r)); + SysLog(NID_IO, "[UiBuilder] ui builder home path: %ls, res path: %ls", homePath.GetPointer(), temp.GetPointer()); + + if (!pControlManager->IsCoordinateSystemLogical() || !File::IsFileExist(temp)) // if autoscale on, find ScreenSize normal + { + findPath = false; + SysLogException(NID_UI, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] Parse failed -- %ls file not found.", temp.GetPointer()); + return E_FILE_NOT_FOUND; + } + } + + findPath = true; + xmlFilePath = temp; + r = file.Construct(xmlFilePath, L"r"); + if (IsFailed(r)) + { + SysLogException(NID_UI, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Parse Failed -- XML file Construct."); + return E_OPERATION_FAILED; + } + + r = Tizen::Io::File::GetAttributes(xmlFilePath, attrib); + if (IsFailed(r)) + { + SysLogException(NID_UI, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Parse Failed -- XML file GetAttributes."); + return E_OPERATION_FAILED; + } + size = (int) attrib.GetFileSize(); + + r = buffer.Construct(size); + if (IsFailed(r)) + { + SysLogException(NID_UI, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Parse Failed - Buffer Construct Failed."); + return E_OPERATION_FAILED; + } + + r = file.Read(buffer); + if (IsFailed(r)) + { + SysLogException(NID_UI, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Parse Failed -- can't read the file."); + return E_OPERATION_FAILED; + } + + readCount = buffer.GetPosition(); + pXmlContents = new (std::nothrow) byte[readCount]; + SysTryReturn(NID_UI, pXmlContents != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create XmlContents."); + buffer.Flip(); + + r = buffer.GetArray(pXmlContents, 0, readCount); + if (IsFailed(r)) + { + SysLogException(NID_UI, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Parse Failed -- buffer.GetArray is Failed."); + delete[] pXmlContents; + return E_OPERATION_FAILED; + } + + _UiBuilderXmlHandler xmlHandler; + bool returnValue = false; + char* pXmlBuffer = (char*) pXmlContents; + + + returnValue = xmlHandler.Construct(this); + SysTryReturn(NID_UI, returnValue == true, E_OPERATION_FAILED, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Parse Failed - xmlHandler Construct Failed."); + + r = xmlHandler.ParseXml(pXmlBuffer, readCount); + if (r != E_SUCCESS) + { + SysLogException(NID_UI, r, "[%s] Propagation.", GetErrorMessage(r)); + return r; + } + + if (__pTransform != null) + { + _UiBuilderControl* pUiBuilderControl; + for (int i = 0; i < UIBUILDER_CONTROL_MAX_COUNT; i++) + { + pUiBuilderControl = GetControl(i); + if (pUiBuilderControl != null) + { + _UiBuilderControlLayout* pUiBuilderControlLayoutPortrait; + _UiBuilderControlLayout* pUiBuilderControlLayoutLandscape; + + pUiBuilderControlLayoutPortrait = pUiBuilderControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT); + Rectangle rect = pUiBuilderControlLayoutPortrait->GetRect(); + Rectangle realBounds = __pTransform->Transform(rect); + pUiBuilderControlLayoutPortrait->SetRect(realBounds.x, realBounds.y, realBounds.width, realBounds.height); + + pUiBuilderControlLayoutLandscape = pUiBuilderControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE); + rect = pUiBuilderControlLayoutLandscape->GetRect(); + realBounds = __pTransform->Transform(rect); + pUiBuilderControlLayoutLandscape->SetRect(realBounds.x, realBounds.y, realBounds.width, realBounds.height); + } + else + { + break; + } + } + + } + + //Make UiControls with UiBuilderControls + IEnumeratorT<_UiBuilderControl*>* pEnum = __pUiBuilderControlList->GetEnumeratorN(); + SysTryCatch(NID_UI, pEnum != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to get IEnumeratorT."); + + while (pEnum->MoveNext() == E_SUCCESS) + { + _UiBuilderControl* pUiBuilderControl = null; + pEnum->GetCurrent(pUiBuilderControl); + if (pUiBuilderControl != null) + { + r = MakeUI(pUiBuilderControl); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[UiBuilder] Failed to create control %ls", pUiBuilderControl->GetType().GetPointer()); + delete pUiBuilderControl; + } + } + + if (__pUiBuilderControlList) + { + __pUiBuilderControlList->RemoveAll(); + delete __pUiBuilderControlList; + __pUiBuilderControlList = null; + } + + if (__pTransform) + { + delete __pTransform; + __pTransform = null; + } + delete[] pXmlContents; + delete pEnum; + return E_SUCCESS; + + CATCH: + if (__pTransform) + { + delete __pTransform; + __pTransform = null; + } + delete[] pXmlContents; + delete pEnum; + return r; + +} + +_UiBuilderControl* +_UiBuilder::CreateControl(void) +{ + if (__pUiBuilderControlList == null) + { + __pUiBuilderControlList = new (std::nothrow) ArrayListT<_UiBuilderControl*>; + SysTryReturn(NID_UI, __pUiBuilderControlList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create __pUiBuilderControlList."); + } + + _UiBuilderControl* pUiBuilderControl = null; + pUiBuilderControl = new (std::nothrow) _UiBuilderControl; + if (pUiBuilderControl != null) + { + __pUiBuilderControlList->Add(pUiBuilderControl); + } + else + { + SysLogException(NID_UI, E_OUT_OF_MEMORY, "Failed to CreateControl()"); + return null; + } + + return pUiBuilderControl; +} + +Tizen::Ui::Container* +_UiBuilder::GetContainer() const +{ + return __pContainer; +} + +void +_UiBuilder::SetUiBuilderRotateState(_UiBuilderScreenRotate rotate) +{ + __rotate = rotate; +} + +_UiBuilderScreenRotate +_UiBuilder::GetUiBuilderRotateState() const +{ + return __rotate; +} + +result +_UiBuilder::SetFormXmlResolution(_LogicalResolution formXmlResoluton) +{ + result r = E_SUCCESS; + + if (__pTransform == null) + { + if (formXmlResoluton == RESOLUTION_LOGICAL_720 && __logicalResolution == 480) + { + __pTransform = _CoordinateSystem::GetTransformerN(RESOLUTION_LOGICAL_720, RESOLUTION_LOGICAL_480); + SysTryReturn(NID_UI, __pTransform != null, null, GetLastResult(), + "Failed to get Transformer"); + } + if (formXmlResoluton == RESOLUTION_LOGICAL_480 && __logicalResolution == 720) + { + __pTransform = _CoordinateSystem::GetTransformerN(RESOLUTION_LOGICAL_480, RESOLUTION_LOGICAL_720); + SysTryReturn(NID_UI, __pTransform != null, GetLastResult(), GetLastResult(), + "Failed to get Transformer"); + } + } + else + { + SysLog(NID_UI, "__pTransform is already exists"); + r = E_SYSTEM; + } + return r; +} + +void +_UiBuilder::SetLayoutOrientation(_UiBuilderControl* pUiBuilderControl, Tizen::Ui::Control* pControl) +{ + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*pControl); + _UiBuilderControlLayout* pLayout = null; + Rectangle rect; + + pLayout = pUiBuilderControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT); + rect = pLayout->GetRect(); + pControlImpl->SetBuilderBounds(_CONTROL_ORIENTATION_PORTRAIT, rect); + + pLayout = pUiBuilderControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE); + rect = pLayout->GetRect(); + pControlImpl->SetBuilderBounds(_CONTROL_ORIENTATION_LANDSCAPE, rect); +} + +_ICoordinateSystemTransformer* +_UiBuilder::GetTransformer() const +{ + return __pTransform; +} + +} } // Tizen::Ui diff --git a/src/ui/FUi_UiBuilderControl.cpp b/src/ui/FUi_UiBuilderControl.cpp new file mode 100644 index 0000000..8941761 --- /dev/null +++ b/src/ui/FUi_UiBuilderControl.cpp @@ -0,0 +1,429 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUi_UiBuilderControl.cpp +* @brief This is the implementation file for _UiBuilderControl class. +*/ + +#include +#include +#include +#include +#include +#include +#include "FUi_UiBuilder.h" +#include "FUi_UiBuilderControl.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui +{ +_UiBuilderControl::_UiBuilderControl(void) + : __itemCount(0) + , __pHandle(null) + , __type(L"") + , __id(L"") + , __parentId(L"") + , __pUiBuilderControlElementList(null) + , __pUiBuilderControlItemList(null) +{ +} +_UiBuilderControl::~_UiBuilderControl(void) +{ + if (__pUiBuilderControlElementList) + { + _UiBuilderControlElement* pUiBuilderControlElement = null; + int controlCount = __pUiBuilderControlElementList->GetCount(); + for (int i = 0; i < controlCount; i++) + { + __pUiBuilderControlElementList->GetAt(i, pUiBuilderControlElement); + delete pUiBuilderControlElement; + } + __pUiBuilderControlElementList->RemoveAll(); + delete __pUiBuilderControlElementList; + __pUiBuilderControlElementList = null; + } + + if (__pUiBuilderControlItemList) + { + _UiBuilderControlItem* pUiBuilderControlItem = null; + int controlCount = __pUiBuilderControlItemList->GetCount(); + for (int i = 0; i < controlCount; i++) + { + __pUiBuilderControlItemList->GetAt(i, pUiBuilderControlItem); + delete pUiBuilderControlItem; + } + __pUiBuilderControlItemList->RemoveAll(); + delete __pUiBuilderControlItemList; + __pUiBuilderControlItemList = null; + } +} + +void +_UiBuilderControl::Construct(const Tizen::Base::String& type) +{ + if (__pUiBuilderControlElementList == null) + { + __pUiBuilderControlElementList = new (std::nothrow) ArrayListT<_UiBuilderControlElement*>; + } + if (__pUiBuilderControlItemList == null) + { + __pUiBuilderControlItemList = new (std::nothrow) ArrayListT<_UiBuilderControlItem*>; + } + + if (type.Equals(L"Map", false)) + { + return; + } + + if (type.Equals(L"Web", false)) + { + __pHandle = dlopen("libosp-web.so", RTLD_LAZY | RTLD_GLOBAL); + if (__pHandle == null) + { + SysLog(NID_UI, "Failed to libosp-web.so"); + } + } + SetType(type); +} + +void +_UiBuilderControl::SetId(const Tizen::Base::String& id) +{ + __id = id; +} + +void +_UiBuilderControl::SetType(const Tizen::Base::String& type) +{ + __type = type; +} + +void +_UiBuilderControl::SetParentWin(const Tizen::Base::String& parent) +{ + __parentId = parent; +} + +void +_UiBuilderControl::SetElement(int index, const Tizen::Base::String& elementName, const Tizen::Base::String& elementValue) +{ + _UiBuilderControlElement* pUiBuilderControlElement = null; + pUiBuilderControlElement = new (std::nothrow) _UiBuilderControlElement; + if (pUiBuilderControlElement != null) + { + pUiBuilderControlElement->SetName(elementName); + pUiBuilderControlElement->SetValue(elementValue); + __pUiBuilderControlElementList->Add(pUiBuilderControlElement); + } + else + { + SysLogException(NID_UI, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _UiBuilderControlElement."); + } +} + +void +_UiBuilderControl::SetItemName(const Tizen::Base::String& name) +{ + _UiBuilderControlItem* pUiBuilderControlItem = null; + __pUiBuilderControlItemList->GetAt(__itemCount, pUiBuilderControlItem); + SysTryReturnVoidResult(NID_UI, pUiBuilderControlItem != null, GetLastResult(), "Failed to get _UiBuilderControlItem"); + + pUiBuilderControlItem->SetItemName(name); + __itemCount++; +} + +void +_UiBuilderControl::SetItemElement(int index, const Tizen::Base::String& name, const Tizen::Base::String& value) +{ + + _UiBuilderControlItem* pUiBuilderControlItem = null; + if (index == 0) + { + pUiBuilderControlItem = new (std::nothrow) _UiBuilderControlItem; + pUiBuilderControlItem->SetItemElement(index, name, value); + __pUiBuilderControlItemList->Add(pUiBuilderControlItem); + } + else + { + __pUiBuilderControlItemList->GetAt(__itemCount, pUiBuilderControlItem); + SysTryReturnVoidResult(NID_UI, pUiBuilderControlItem != null, GetLastResult(), "Failed to get _UiBuilderControlItem"); + pUiBuilderControlItem->SetItemElement(index, name, value); + } +} + +bool +_UiBuilderControl::GetItemElement(int index, const Tizen::Base::String& elementName, Tizen::Base::String& elementOutValue) +{ + bool findElement = false; + + _UiBuilderControlItem* pUiBuilderControlItem = null; + __pUiBuilderControlItemList->GetAt(index, pUiBuilderControlItem); + if (pUiBuilderControlItem == null) + { + SysLogException(NID_UI, GetLastResult(), "Failed to get _UiBuilderControlItem"); + return null; + } + + + Tizen::Base::Collection::ArrayListT<_UiBuilderControlElement*>* pItemPropertyList = pUiBuilderControlItem->GetItemProperty(); + + IEnumeratorT<_UiBuilderControlElement*>* pEnum = pItemPropertyList->GetEnumeratorN(); + SysTryReturn(NID_UI, pEnum != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to get IEnumerator."); + _UiBuilderControlElement* pUiBuilderControlElement = null; + + while (pEnum->MoveNext() == E_SUCCESS) + { + pEnum->GetCurrent(pUiBuilderControlElement); + if (pUiBuilderControlElement->GetName().Equals(elementName, false) && pUiBuilderControlElement->GetValue().IsEmpty() == false) + { + elementOutValue = pUiBuilderControlElement->GetValue(); + findElement = true; + break; + } + } + delete pEnum; + + if (!findElement) + { + return false; + } + else + { + // < & > check + if (IsSpecialChar(elementOutValue)) + { + ConvertSpecialChar(elementOutValue); + } + } + if (elementOutValue[0] == ':' && elementOutValue[1] == ':') + { + result r = E_SUCCESS; + AppResource* pAppResource = AppResource::GetInstance(); + if (pAppResource == null) + { + return false; + } + String subStr; + String getStringValue; + elementOutValue.SubString(2, elementOutValue.GetLength() - 2, subStr); + elementOutValue = subStr; + r = pAppResource->GetString(elementOutValue, getStringValue); + elementOutValue = getStringValue; + } + + return true; +} + +bool +_UiBuilderControl::GetElement(const Tizen::Base::String& elementName, Tizen::Base::String& elementOutValue) +{ + bool findElement = false; + IEnumeratorT<_UiBuilderControlElement*>* pEnum = __pUiBuilderControlElementList->GetEnumeratorN(); + SysTryReturn(NID_UI, pEnum != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to get IEnumerator."); + _UiBuilderControlElement* pUiBuilderControlElement = null; + + while (pEnum->MoveNext() == E_SUCCESS) + { + pEnum->GetCurrent(pUiBuilderControlElement); + if (pUiBuilderControlElement->GetName().Equals(elementName, false) && pUiBuilderControlElement->GetValue().IsEmpty() == false) + { + elementOutValue = pUiBuilderControlElement->GetValue(); + findElement = true; + break; + } + } + delete pEnum; + + if (findElement == false) + { + return false; + } + else + { + // < & > check + if (IsSpecialChar(elementOutValue)) + { + ConvertSpecialChar(elementOutValue); + } + } + + if (elementOutValue[0] == ':' && elementOutValue[1] == ':') + { + result r = E_SUCCESS; + AppResource* pAppResource = AppResource::GetInstance(); + if (pAppResource == null) + { + return false; + } + String subStr; + String getStringValue; + elementOutValue.SubString(2, elementOutValue.GetLength() - 2, subStr); + elementOutValue = subStr; + + r = pAppResource->GetString(elementOutValue, getStringValue); + elementOutValue = getStringValue; + } + + return true; + +} + +int +_UiBuilderControl::GetItemCount(void) const +{ + return __itemCount; +} + +String +_UiBuilderControl::GetId(void) const +{ + return __id; +} + +String +_UiBuilderControl::GetType(void) const +{ + return __type; +} + +String +_UiBuilderControl::GetParentWin(void) const +{ + return __parentId; +} + +String +_UiBuilderControl::GetItemName(int index) const +{ + _UiBuilderControlItem* pUiBuilderControlItem = null; + __pUiBuilderControlItemList->GetAt(index, pUiBuilderControlItem); + SysTryReturn(NID_UI, pUiBuilderControlItem != null, L"", GetLastResult(), "Failed to get _UiBuilderControlItem"); + + return pUiBuilderControlItem->GetItemName(); +} + +_UiBuilderControlLayout* +_UiBuilderControl::GetAttribute(int mode) const +{ + return const_cast<_UiBuilderControlLayout*>(&__layout[mode]); +} + +bool +_UiBuilderControl::IsSpecialChar(const Tizen::Base::String& string) const +{ + if (string.IsEmpty()) + { + return false; + } + if (string.Contains(L"<") ||string.Contains(L"&") + || string.Contains(L">") || string.Contains(L"'") + || string.Contains(L""") || string.Contains(L"\\")) + { + return true; + } + else + { + return false; + } +} + +void +_UiBuilderControl::ConvertSpecialChar(Tizen::Base::String& string) const +{ + int len = string.GetLength(); + wchar_t* stringPointer = const_cast(string.GetPointer()); + int i = 0; + int j = 0; + + while (i < len) + { + if (stringPointer[i] == '\\') + { + if (stringPointer[i + 1] == 'n') + { + stringPointer[j] = '\n'; + i += 2; + j++; + } + else if (stringPointer[i + 1] == 't') + { + stringPointer[j] = '\t'; + i += 2; + j++; + } + else + { + stringPointer[j] = '\\'; + + j++; + i++; + } + } + else if ((stringPointer[i] == '&') && (stringPointer[i + 1] == 'l') && (stringPointer[i + 2] == 't') && (stringPointer[i + 3] == ';')) + { + stringPointer[j] = '<'; + i += 4; + j++; + } + else if ((stringPointer[i] == '&') && (stringPointer[i + 1] == 'g') && (stringPointer[i + 2] == 't') && (stringPointer[i + 3] == ';')) + { + stringPointer[j] = '>'; + i += 4; + j++; + } + else if ((stringPointer[i] == '&') && (stringPointer[i + 1] == 'a') && (stringPointer[i + 2] == 'm') && (stringPointer[i + 3] == 'p') && (stringPointer[i + 4] == ';')) + { + stringPointer[j] = '&'; + i += 5; + j++; + } + else if ((stringPointer[i] == '&') && (stringPointer[i + 1] == 'a') && (stringPointer[i + 2] == 'p') && (stringPointer[i + 3] == 'o') && (stringPointer[i + 4] == 's') && + (stringPointer[i + 5] == ';')) + { + stringPointer[j] = 39; // ' + i += 6; + j++; + } + else if ((stringPointer[i] == '&') && (stringPointer[i + 1] == 'q') && (stringPointer[i + 2] == 'u') && (stringPointer[i + 3] == 'o') && (stringPointer[i + 4] == 't') && + (stringPointer[i + 5] == ';')) + { + stringPointer[j] = 34; // " + i += 6; + j++; + } + else + { + stringPointer[j] = stringPointer[i]; + i++; + j++; + } + } + if (j != i) + { + for (; j <= i; j++) + stringPointer[j] = '\0'; + } + + +} + +} } // Tizen::Ui diff --git a/src/ui/FUi_UiBuilderControlElement.cpp b/src/ui/FUi_UiBuilderControlElement.cpp new file mode 100644 index 0000000..e0c4c1e --- /dev/null +++ b/src/ui/FUi_UiBuilderControlElement.cpp @@ -0,0 +1,66 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUi_UiBuilderControlElement.cpp +* @brief This is the implementation file for Control class. +*/ + +#include +#include +#include "FUi_UiBuilder.h" +#include "FUi_UiBuilderControlElement.h" + +using namespace Tizen::Ui; +using namespace Tizen::Base; +namespace Tizen { namespace Ui +{ +_UiBuilderControlElement::_UiBuilderControlElement(void) + : __elementName(L"") + , __elementValue(L"") + +{ +} + +_UiBuilderControlElement::~_UiBuilderControlElement(void) +{ +} + +void +_UiBuilderControlElement::SetName(const Tizen::Base::String& name) +{ + __elementName= name; +} + +void +_UiBuilderControlElement::SetValue(const Tizen::Base::String& value) +{ + __elementValue = value; +} + +String +_UiBuilderControlElement::GetName(void) const +{ + return __elementName; +} +String +_UiBuilderControlElement::GetValue(void) const +{ + return __elementValue; +} + +} } // Tizen::Ui diff --git a/src/ui/FUi_UiBuilderControlItem.cpp b/src/ui/FUi_UiBuilderControlItem.cpp new file mode 100644 index 0000000..de0ed8d --- /dev/null +++ b/src/ui/FUi_UiBuilderControlItem.cpp @@ -0,0 +1,95 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUi_UiBuilderControlItem.cpp +* @brief This is the implementation file for _UiBuilderControlItem class. +*/ + +// includes +#include +#include +#include "FUi_UiBuilder.h" +#include "FUi_UiBuilderControlItem.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui +{ +_UiBuilderControlItem::_UiBuilderControlItem(void) + : _itemName(L"") + ,__pUiBuilderControlElementList(null) +{ + if (__pUiBuilderControlElementList == null) + { + __pUiBuilderControlElementList = new (std::nothrow) ArrayListT<_UiBuilderControlElement*>; + } +} + +_UiBuilderControlItem::~_UiBuilderControlItem(void) +{ + if (__pUiBuilderControlElementList) + { + _UiBuilderControlElement* pUiBuilderControlElement = null; + int controlCount = __pUiBuilderControlElementList->GetCount(); + for (int i = 0; i < controlCount; i++) + { + __pUiBuilderControlElementList->GetAt(i, pUiBuilderControlElement); + delete pUiBuilderControlElement; + } + __pUiBuilderControlElementList->RemoveAll(); + delete __pUiBuilderControlElementList; + __pUiBuilderControlElementList = null; + } +} + +void +_UiBuilderControlItem::SetItemName(const Tizen::Base::String& name) +{ + _itemName = name; +} + +String +_UiBuilderControlItem::GetItemName(void) const +{ + return _itemName; +} + +void +_UiBuilderControlItem::SetItemElement(int index, const Tizen::Base::String& name, const Tizen::Base::String& value) +{ + _UiBuilderControlElement* pUiBuilderControlElement = null; + pUiBuilderControlElement = new (std::nothrow) _UiBuilderControlElement; + if (pUiBuilderControlElement != null) + { + pUiBuilderControlElement->SetName(name); + pUiBuilderControlElement->SetValue(value); + __pUiBuilderControlElementList->Add(pUiBuilderControlElement); + } + + +} +ArrayListT<_UiBuilderControlElement*>* +_UiBuilderControlItem::GetItemProperty(void) +{ + return __pUiBuilderControlElementList; +} + + +} } // Tizen::Ui diff --git a/src/ui/FUi_UiBuilderControlLayout.cpp b/src/ui/FUi_UiBuilderControlLayout.cpp new file mode 100644 index 0000000..b9a6358 --- /dev/null +++ b/src/ui/FUi_UiBuilderControlLayout.cpp @@ -0,0 +1,138 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_UiBuilderControlLayout.cpp +* @brief This is the implementation file for _UiBuilderControlLayout class. +*/ + +#include +#include +#include +#include "FUi_UiBuilder.h" +#include "FUi_UiBuilderControlLayout.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui +{ +_UiBuilderControlLayout::_UiBuilderControlLayout(void) + : _styleInformation(L"") +{ +} + +_UiBuilderControlLayout::~_UiBuilderControlLayout(void) +{ +} + +void +_UiBuilderControlLayout::SetStyle(const Tizen::Base::String& style) +{ + _styleInformation = style; +} + +void +_UiBuilderControlLayout::SetRect(const Tizen::Base::String& x, const Tizen::Base::String& y, Tizen::Base::String& width, Tizen::Base::String& height) +{ + int intX = 0, intY = 0, intWidth = 0, intHeight = 0; + + if (x.IsEmpty() == false) + { + Base::Integer::Parse(x, intX); + } + if (y.IsEmpty() == false) + { + Base::Integer::Parse(y, intY); + } + if (width.IsEmpty() == false) + { + Base::Integer::Parse(width, intWidth); + } + if (height.IsEmpty() == false) + { + Base::Integer::Parse(height, intHeight); + } + + _rect.x = intX; + _rect.y = intY; + _rect.width = intWidth; + _rect.height = intHeight; +} + +void +_UiBuilderControlLayout::SetRect(const int x, const int y, const int width, const int height) +{ + _rect.x = x; + _rect.y = y; + _rect.width = width; + _rect.height = height; +} + +String +_UiBuilderControlLayout::GetStyle(void) const +{ + return _styleInformation; +} + +Rectangle& +_UiBuilderControlLayout::GetRect(void) const +{ + return const_cast(_rect); +} + +void +_UiBuilderControlLayout::SetLayoutElement(int index, const Tizen::Base::String& name, const Tizen::Base::String& value) +{ + if (index >= UIBUILDER_CONTROL_ELEMENT_NUMBER) + { + return; + } + + _layoutElement[index].SetName(name); + _layoutElement[index].SetValue(value); + +} + +bool +_UiBuilderControlLayout::GetLayoutElement(const Tizen::Base::String& layoutElementName, Tizen::Base::String& outValue) const +{ + int index = 0; + while (layoutElementName.IsEmpty() == false && index < UIBUILDER_CONTROL_ELEMENT_NUMBER) + { + if (layoutElementName.Equals(_layoutElement[index].GetName(), false)) + { + if (_layoutElement[index].GetValue().IsEmpty() == false) + { + outValue = _layoutElement[index].GetValue(); + return true; + } + else + { + return false; + } + } + else + { + index++; + } + } + + return false; +} + +} } // Tizen::Ui diff --git a/src/ui/FUi_UiBuilderControlMaker.cpp b/src/ui/FUi_UiBuilderControlMaker.cpp new file mode 100755 index 0000000..cc1e8f5 --- /dev/null +++ b/src/ui/FUi_UiBuilderControlMaker.cpp @@ -0,0 +1,1832 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUi_UiBuilderControlMaker.cpp +* @brief This is the implementation file for _UiBuilderControlMaker class. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_UiBuilderControlMaker.h" +#include "FUi_UiBuilder.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::App; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ +_UiBuilderControlMaker::_UiBuilderControlMaker(_UiBuilder* pUibuilder) + : __pUiBuilder(null) +{ + __pUiBuilder = pUibuilder; +} +_UiBuilderControlMaker::_UiBuilderControlMaker(void) + : __pUiBuilder(null) +{ +} +_UiBuilderControlMaker::~_UiBuilderControlMaker(void) +{ +} + +result +_UiBuilderControlMaker::MakeControl(_UiBuilderControl* pUiBuilderControl) +{ + Tizen::Ui::Control* pControl = null; + + if (pUiBuilderControl != null) + { + pControl = Make(pUiBuilderControl); + if ((pUiBuilderControl->GetType()).Equals(L"Header", false) || (pUiBuilderControl->GetType()).Equals(L"Footer", false)) + { + return E_SUCCESS; + } + if (pControl != null) + { + pControl->SetName(pUiBuilderControl->GetId()); + SetLayoutOrientation(pUiBuilderControl, pControl); + if (!(pUiBuilderControl->GetType().Equals(L"Form", false) || pUiBuilderControl->GetType().Equals(L"Popup", false))) + { + if (pUiBuilderControl->GetType().Equals(L"Panel", false) || pUiBuilderControl->GetType().Equals(L"ScrollPanel", false)) + { + if (pUiBuilderControl->GetParentWin().IsEmpty()) + { + return E_SUCCESS; + } + + } + AddControl(pUiBuilderControl, pControl); + SetLayoutProperty(pUiBuilderControl, pControl); + + } + return E_SUCCESS; + } + } + + return E_OPERATION_FAILED; +} + +void +_UiBuilderControlMaker::ConvertStringToColor(const Tizen::Base::String& colorString, Color& color) +{ + int index = 0; + int len = 0; + int gap = 0; + const wchar_t* colorStringPointer = colorString.GetPointer(); + char ch; + unsigned long temp = 0; + + len = colorString.GetLength(); + + if (len < 1) + { + return; + } + color = 0; + + for (index = 0; index < len + 1; index++) + { + ch = colorStringPointer[index]; + if ((ch >= '0') && (ch <= '9')) + { + temp = temp << 4; + gap = ch - '0'; + temp |= gap; + + } + else if ((ch >= 'A') && (ch <= 'F')) + { + temp = temp << 4; + gap = ch - 'A' + 10; + temp |= gap; + + } + else if ((ch >= 'a') && (ch <= 'f')) + { + temp = temp << 4; + gap = ch - 'a' + 10; + temp |= gap; + } + } + color.SetRGB32(temp, false); +} + +void +_UiBuilderControlMaker::ConvertStringToColor32(const Tizen::Base::String& colorString, int opacity, Color& color) +{ + int index = 0; + int len = 0; + int gap = 0; + int alpha = 0; + const wchar_t* colorStringPointer = colorString.GetPointer(); + char ch; + unsigned long temp = 0; + + len = colorString.GetLength(); + + if (len < 1) + { + SysLog(NID_UI, "String is empty"); + return; + } + + color = 0; + + for (index = 0; index < len + 1; index++) + { + ch = colorStringPointer[index]; + if ((ch >= '0') && (ch <= '9')) + { + temp = temp << 4; + gap = ch - '0'; + temp |= gap; + + } + else if ((ch >= 'A') && (ch <= 'F')) + { + temp = temp << 4; + gap = ch - 'A' + 10; + temp |= gap; + + } + else if ((ch >= 'a') && (ch <= 'f')) + { + temp = temp << 4; + gap = ch - 'a' + 10; + temp |= gap; + } + } + + color.SetRGB32(temp, true); + alpha = ConvertOpacity100to255(opacity); + color.SetAlpha(alpha); +} + +int +_UiBuilderControlMaker::ConvertOpacity100to255(int opacity) +{ + return 255 * opacity / 100; +} + +bool +_UiBuilderControlMaker::ConvertHAlignToHorizontalAlignment(const Tizen::Base::String& align, HorizontalAlignment& alignment) +{ + if (align.Equals(L"ALIGN_LEFT", false)) + { + alignment = ALIGNMENT_LEFT; + } + else if (align.Equals(L"ALIGN_CENTER", false)) + { + alignment = ALIGNMENT_CENTER; + } + else if (align.Equals(L"ALIGN_RIGHT", false)) + { + alignment = ALIGNMENT_RIGHT; + } + else + { + return false; + } + + return true; +} + +bool +_UiBuilderControlMaker::ConvertVAlignToVerticalAlignment(const Tizen::Base::String& align, VerticalAlignment& alignment) +{ + if (align.Equals(L"ALIGN_TOP", false)) + { + alignment = ALIGNMENT_TOP; + } + else if (align.Equals(L"ALIGN_MIDDLE", false)) + { + alignment = ALIGNMENT_MIDDLE; + } + else if (align.Equals(L"ALIGN_BOTTOM", false)) + { + alignment = ALIGNMENT_BOTTOM; + } + else + { + return false; + } + + return true; +} + +bool +_UiBuilderControlMaker::ConvertSlideShowAnimation(const Tizen::Base::String& animationType, GalleryAnimation& animation) +{ + if (animationType.Equals(L"GALLERY_ANIMATION_PAGE", false)) + { + animation = GALLERY_ANIMATION_PAGE; + } + else if (animationType.Equals(L"GALLERY_ANIMATION_DISSOLVE", false)) + { + animation = GALLERY_ANIMATION_DISSOLVE; + } + else if (animationType.Equals(L"GALLERY_ANIMATION_ZOOM", false)) + { + animation = GALLERY_ANIMATION_ZOOM; + } + else + { + return false; + } + + return true; +} + +Tizen::Graphics::Bitmap* +_UiBuilderControlMaker::LoadBitmapN(const Tizen::Base::String& imagePath) +{ + UiApp* pUiApp = UiApp::GetInstance(); + if (pUiApp != null) + { + AppResource* pAppResource = UiApp::GetInstance()->GetAppResource(); + if (pAppResource != null) + { + Tizen::Graphics::Bitmap* pBitmap = pAppResource->GetBitmapN(imagePath); + return pBitmap; + } + } + + return null; +} +void +_UiBuilderControlMaker::GetProperty(_UiBuilderControl* pControl, _UiBuilderControlLayout** pControlProperty) const +{ + // Form's orientation mode is AUTOMATIC + if (__pUiBuilder->GetUiBuilderRotateState() == UIBUIDER_SCREEN_NONE) + { + // Get device orientation + + bool autoRotateLock = false; + int ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, &autoRotateLock); + + if (ret == RUNTIME_INFO_ERROR_NONE) + { + SysLog(NID_UI, "The flag of auto-rotate lock is %d.", autoRotateLock); + } + else + { + autoRotateLock = false; + SysLog(NID_UI, "It's failed to get the flag of auto-rotate."); + } + + app_device_orientation_e deviceOrientation = app_get_device_orientation(); + bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270); + + if (isHorizontal && autoRotateLock == true) + { + __pUiBuilder->SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL); + } + else + { + __pUiBuilder->SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL); + } + } + + if (__pUiBuilder->GetUiBuilderRotateState() == UIBUIDER_SCREEN_HORIZONTAL) + { + *pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE); + } + else + { + *pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT); + } + + return; +} + +bool +_UiBuilderControlMaker::GetLayoutType(_UiBuilderControlLayout* pControlProperty, _UiBuilderLayoutType& returnType) const +{ + if (pControlProperty == null) + { + return false; + } + + Tizen::Base::String layoutType(L""); + + if (pControlProperty->GetLayoutElement( L"type", layoutType)) + { + + if (layoutType.Equals(L"NONE", false)) + { + returnType = UIBUILDER_LAYOUT_NONE; + } + else if (layoutType.Equals(L"LAYOUT_GRID", false)) + { + returnType = UIBUILDER_LAYOUT_GRID; + } + else if (layoutType.Equals(L"LAYOUT_HORIZONTAL_BOX", false)) + { + returnType = UIBUILDER_LAYOUT_HORIZONTAL_BOX; + } + else if (layoutType.Equals(L"LAYOUT_VERTICAL_BOX", false)) + { + returnType = UIBUILDER_LAYOUT_VERTICAL_BOX; + } + else if (layoutType.Equals(L"LAYOUT_RELATIVE", false)) + { + returnType = UIBUILDER_LAYOUT_RELATIVE; + } + else + { + returnType = UIBUILDER_LAYOUT_NONE; + return false; + } + } + else + { + returnType = UIBUILDER_LAYOUT_NONE; + } + + return true; +} + +bool +_UiBuilderControlMaker::GetParentLayoutType(_UiBuilderControlLayout* pControlProperty, _UiBuilderLayoutType& returnType) const +{ + if (pControlProperty == null) + { + return false; + } + Tizen::Base::String parentLayoutType(L""); + + if (pControlProperty->GetLayoutElement(L"parentType", parentLayoutType)) + { + if (parentLayoutType.Equals(L"NONE", false)) + { + returnType = UIBUILDER_LAYOUT_NONE; + } + else if (parentLayoutType.Equals(L"LAYOUT_GRID", false)) + { + returnType = UIBUILDER_LAYOUT_GRID; + } + else if (parentLayoutType.Equals(L"LAYOUT_HORIZONTAL_BOX", false)) + { + returnType = UIBUILDER_LAYOUT_HORIZONTAL_BOX; + } + else if (parentLayoutType.Equals(L"LAYOUT_VERTICAL_BOX", false)) + { + returnType = UIBUILDER_LAYOUT_VERTICAL_BOX; + } + else if (parentLayoutType.Equals(L"LAYOUT_RELATIVE", false)) + { + returnType = UIBUILDER_LAYOUT_RELATIVE; + } + else + { + returnType = UIBUILDER_LAYOUT_NONE; + return false; + } + } + else + { + returnType = UIBUILDER_LAYOUT_NONE; + } + return true; +} + +result +_UiBuilderControlMaker::GetGridLayoutN(_UiBuilderControlLayout* pControlProperty, Layout*& pLayout) const +{ + if (pControlProperty == null) + { + return E_SYSTEM; + } + + result r = E_SUCCESS; + Tizen::Base::String gridLayoutValue(L""); + GridLayout* pGridLayout = null; + int maxColumn = 0; + int maxRow = 0; + + pGridLayout = new (std::nothrow) GridLayout; + if (!pGridLayout) + { + SysLog(NID_UI, "Unable to create layout"); + r = E_SYSTEM; + goto CATCH; + } + if (pControlProperty->GetLayoutElement(L"maxColumn", gridLayoutValue)) + { + Integer::Parse(gridLayoutValue, maxColumn); + } + + if (pControlProperty->GetLayoutElement(L"maxRow", gridLayoutValue)) + { + Integer::Parse(gridLayoutValue, maxRow); + } + + r = pGridLayout->Construct(maxRow, maxColumn); + if (E_SUCCESS != r) + { + SysLog(NID_UI, "[%s] Propagated.", GetErrorMessage(r)); + delete pGridLayout; + pGridLayout = null; + } + +CATCH: + pLayout = pGridLayout; + + return r; +} + +result +_UiBuilderControlMaker::GetHorizontalBoxLayoutN(_UiBuilderControlLayout* pControlProperty, Layout*& pLayout) const +{ + if (pControlProperty == null) + { + return E_SYSTEM; + } + result r = E_SUCCESS; + + Tizen::Base::String horizontalBoxLayoutValue(L""); + + HorizontalBoxLayout* pHboxLayout = null; + HorizontalDirection direction; + + pHboxLayout = new (std::nothrow) HorizontalBoxLayout; + if (!pHboxLayout) + { + SysLog(NID_UI, "[E_SYSTEM] Unable to create layout"); + r = E_SYSTEM; + goto CATCH; + } + + if (pControlProperty->GetLayoutElement(L"horizontalDirection", horizontalBoxLayoutValue)) + { + if (horizontalBoxLayoutValue.Equals(L"HORIZONTAL_DIRECTION_LEFTWARD", false)) + { + direction = HORIZONTAL_DIRECTION_LEFTWARD; + } + else + { + direction = HORIZONTAL_DIRECTION_RIGHTWARD; + } + } + else + { + direction = HORIZONTAL_DIRECTION_RIGHTWARD; + } + + r = pHboxLayout->Construct(direction); + if (E_SUCCESS != r) + { + SysLog(NID_UI, "[%s] Propagated.", GetErrorMessage(r)); + delete pHboxLayout; + pHboxLayout = null; + } + +CATCH: + pLayout = pHboxLayout; + + return r; +} + +result +_UiBuilderControlMaker::GetVerticalBoxLayoutN(_UiBuilderControlLayout* pControlProperty, Layout*& pLayout) const +{ + if (pControlProperty == null) + { + return E_SYSTEM; + } + result r = E_SUCCESS; + +Tizen::Base::String verticalBoxLayoutValue(L""); + + VerticalBoxLayout* pVboxLayout = null; + VerticalDirection direction; + + pVboxLayout = new (std::nothrow) VerticalBoxLayout; + if (!pVboxLayout) + { + SysLog(NID_UI, "[E_SYSTEM] Unable to create layout"); + r = E_SYSTEM; + goto CATCH; + } + + if (pControlProperty->GetLayoutElement(L"verticalDirection", verticalBoxLayoutValue)) + { + if (verticalBoxLayoutValue.Equals(L"VERTICAL_DIRECTION_UPWARD", false)) + { + direction = VERTICAL_DIRECTION_UPWARD; + } + else + { + direction = VERTICAL_DIRECTION_DOWNWARD; + } + } + else + { + direction = VERTICAL_DIRECTION_DOWNWARD; + } + + r = pVboxLayout->Construct(direction); + if (E_SUCCESS != r) + { + SysLog(NID_UI, "[%s] Propagated.", GetErrorMessage(r)); + delete pVboxLayout; + pVboxLayout = null; + } + +CATCH: + pLayout = pVboxLayout; + + return r; +} + +result +_UiBuilderControlMaker::GetRelativeLayoutN(_UiBuilderControlLayout* pControlProperty, Layout*& pLayout) const +{ + if (pControlProperty == null) + { + return E_SYSTEM; + } + result r = E_SUCCESS; + + RelativeLayout* pRelLayout = null; + + pRelLayout = new (std::nothrow) RelativeLayout; + if (!pRelLayout) + { + SysLog(NID_UI, "Unable to create layout"); + r = E_SYSTEM; + goto CATCH; + } + + if (E_SUCCESS != pRelLayout->Construct()) + { + SysLog(NID_UI, "[%s] Propagated.", GetErrorMessage(r)); + delete pRelLayout; + pRelLayout = null; + } +CATCH: + pLayout = pRelLayout; + + return r; +} + +result +_UiBuilderControlMaker::GetLayoutN(_UiBuilderControl* pUiBuilderControl, Layout*& pPortraitLayout, Layout*& pLandscapeLayout) const +{ + result r = E_SUCCESS; + + _UiBuilderControlLayout* pControlProperty = null; + + Layout* pLayout = null; + Layout* pLayoutPortrait = null; + Layout* pLayoutLandscape = null; + + for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++) + { + _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE; + pControlProperty = pUiBuilderControl->GetAttribute(i); + if (pControlProperty == null) + { + SysLog(NID_UI, "Unable to set layout property"); + return E_SYSTEM; + } + if (GetLayoutType(pControlProperty, layoutType) == false) + { + return E_SYSTEM; + } + + switch (layoutType) + { + case UIBUILDER_LAYOUT_GRID: + r = GetGridLayoutN(pControlProperty, pLayout); + break; + + case UIBUILDER_LAYOUT_HORIZONTAL_BOX: + r = GetHorizontalBoxLayoutN(pControlProperty, pLayout); + break; + + case UIBUILDER_LAYOUT_VERTICAL_BOX: + r = GetVerticalBoxLayoutN(pControlProperty, pLayout); + break; + + case UIBUILDER_LAYOUT_RELATIVE: + r = GetRelativeLayoutN(pControlProperty, pLayout); + break; + + default: + SysLog(NID_UI, "Unknown Layout type = %d", layoutType); + break; + } + if (r != E_SUCCESS) + { + SysLog(NID_UI, "[%s] Propagated.", GetErrorMessage(r)); + return r; + } + if (UIBUILDER_ATTRIBUTE_PORTRAIT == i) + { + pLayoutPortrait = pLayout; + } + else if (UIBUILDER_ATTRIBUTE_LANDSCAPE == i) + { + pLayoutLandscape = pLayout; + } + } + if ((pLayoutPortrait == null) && (pLayoutLandscape != null)) + { + pLayoutPortrait = pLayoutLandscape; + } + else if ((pLayoutPortrait != null) && (pLayoutLandscape == null)) + { + pLayoutLandscape = pLayoutPortrait; + } + + pPortraitLayout = pLayoutPortrait; + pLandscapeLayout = pLayoutLandscape; + + return r; +} + +result +_UiBuilderControlMaker::SetGridLayoutContainerProperty(GridLayout* pLayout, _UiBuilderControlLayout* pControlProperty) const +{ + result r = E_SUCCESS; + + if ((null == pLayout) || (null == pControlProperty)) + { + return E_SYSTEM; + } + + GridLayout& layout = *pLayout; + UiBuilderGridLayoutContainer layoutParam; + Tizen::Base::String gridLayoutContainerPropertyValue(L""); + + layoutParam.maxColumn = 0; + layoutParam.maxRow = 0; + if (pControlProperty->GetLayoutElement(L"maxColumn", gridLayoutContainerPropertyValue)) + { + Integer::Parse(gridLayoutContainerPropertyValue, layoutParam.maxColumn); + } + + if (pControlProperty->GetLayoutElement(L"maxRow", gridLayoutContainerPropertyValue)) + { + Integer::Parse(gridLayoutContainerPropertyValue, layoutParam.maxRow); + } + + String headerColumn = "column"; + String headerRow = "row"; + String tempString; + + for (int i = 1; i <= layoutParam.maxColumn; i++) + { + tempString = headerColumn; + tempString.Append(i); + tempString.Append("Collapsed"); + + if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue)) + { + if (gridLayoutContainerPropertyValue.Equals(L"true", false)) + { + layoutParam.columnCollapsed = true; + } + else + { + layoutParam.columnCollapsed = false; + } + r = layout.SetColumnCollapsed(i - 1, layoutParam.columnCollapsed); + if (IsFailed(r)) + { + goto CATCH; + } + } + + tempString = headerColumn; + tempString.Append(i); + tempString.Append("Shrinkable"); + + if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue)) + { + if (gridLayoutContainerPropertyValue.Equals(L"true", false)) + { + layoutParam.columnShrinkable = true; + } + else + { + layoutParam.columnShrinkable = false; + } + r = layout.SetColumnShrinkable(i - 1, layoutParam.columnShrinkable); + if (IsFailed(r)) + { + goto CATCH; + } + } + + tempString = headerColumn; + tempString.Append(i); + tempString.Append("Stretchable"); + + if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue)) + { + if (gridLayoutContainerPropertyValue.Equals(L"true", false)) + { + layoutParam.columnStretchable = true; + } + else + { + layoutParam.columnStretchable = false; + } + r = layout.SetColumnStretchable(i - 1, layoutParam.columnStretchable); + if (IsFailed(r)) + { + goto CATCH; + } + } + + tempString = headerColumn; + tempString.Append(i); + tempString.Append("Spacing"); + + if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue)) + { + Integer::Parse(gridLayoutContainerPropertyValue, layoutParam.columnSpacing); + r = layout.SetColumnSpacing(i - 1, layoutParam.columnSpacing); + if (IsFailed(r)) + { + goto CATCH; + } + } + + } + for (int i = 1; i <= layoutParam.maxRow; i++) + { + + tempString = headerRow; + tempString.Append(i); + tempString.Append("Collapsed"); + + if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue)) + { + if (gridLayoutContainerPropertyValue.Equals(L"true", false)) + { + layoutParam.rowCollapsed = true; + } + else + { + layoutParam.rowCollapsed = false; + } + r = layout.SetRowCollapsed(i - 1, layoutParam.rowCollapsed); + if (IsFailed(r)) + { + goto CATCH; + } + } + + tempString = headerRow; + tempString.Append(i); + tempString.Append("Shrinkable"); + + if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue)) + { + if (gridLayoutContainerPropertyValue.Equals(L"true", false)) + { + layoutParam.rowShrinkable = true; + } + else + { + layoutParam.rowShrinkable = false; + } + r = layout.SetRowShrinkable(i - 1, layoutParam.rowShrinkable); + if (IsFailed(r)) + { + goto CATCH; + } + } + + tempString = headerRow; + tempString.Append(i); + tempString.Append("Stretchable"); + + if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue)) + { + if (gridLayoutContainerPropertyValue.Equals(L"true", false)) + { + layoutParam.rowStretchable = true; + } + else + { + layoutParam.rowStretchable = false; + } + r = layout.SetRowStretchable(i - 1, layoutParam.rowStretchable); + if (IsFailed(r)) + { + goto CATCH; + } + } + + tempString = headerRow; + tempString.Append(i); + tempString.Append("Spacing"); + + if (pControlProperty->GetLayoutElement(tempString, gridLayoutContainerPropertyValue)) + { + Integer::Parse(gridLayoutContainerPropertyValue, layoutParam.rowSpacing); + r = layout.SetRowSpacing(i - 1, layoutParam.rowSpacing); + if (IsFailed(r)) + { + goto CATCH; + } + } + + } +CATCH: + + return r; +} + +void +_UiBuilderControlMaker::SetGridLayoutControlProperty(GridLayout* pLayout, _UiBuilderControlLayout* pControlProperty, Control* pControl) +{ + if ((null == pLayout) || (null == pControlProperty) || (null == pControlProperty) || (null == pControl)) + { + return ; + } + + GridLayout& layout = *pLayout; + Control& control = *pControl; + UiBuilderGridLayoutControl layoutParam; + Tizen::Base::String gridLayoutValue(L""); + bool alignmentSet = false; + + if (pControlProperty->GetLayoutElement(L"horizontalAlignment", gridLayoutValue)) + { + alignmentSet = true; + if (gridLayoutValue.Equals(L"LAYOUT_HORIZONTAL_ALIGN_CENTER", false)) + { + layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_CENTER; + } + else if (gridLayoutValue.Equals(L"LAYOUT_HORIZONTAL_ALIGN_RIGHT", false)) + { + layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_RIGHT; + } + else + { + layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_LEFT; + } + } + else + { + layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_LEFT; + } + + if (pControlProperty->GetLayoutElement(L"verticalAlignment", gridLayoutValue)) + { + alignmentSet = true; + if (gridLayoutValue.Equals(L"LAYOUT_VERTICAL_ALIGN_MIDDLE", false)) + { + layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_MIDDLE; + } + else if (gridLayoutValue.Equals(L"LAYOUT_VERTICAL_ALIGN_BOTTOM", false)) + { + layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_BOTTOM; + } + else + { + layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_TOP; + } + } + else + { + layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_TOP; + } + if (alignmentSet) + { + layout.SetAlignment(control, layoutParam.horizontalAlignment, layoutParam.verticalAlignment); + } + + _ICoordinateSystemTransformer* pTransform = GetTransformer(); + bool marginSet = false; + layoutParam.marginLeft = 0; + layoutParam.marginRight = 0; + layoutParam.marginTop = 0; + layoutParam.marginBottom = 0; + if (pControlProperty->GetLayoutElement(L"marginLeft", gridLayoutValue)) + { + marginSet = true; + Integer::Parse(gridLayoutValue, layoutParam.marginLeft); + if (pTransform) + { + + layoutParam.marginLeft = pTransform->Transform(layoutParam.marginLeft); + } + } + if (pControlProperty->GetLayoutElement(L"marginRight", gridLayoutValue)) + { + marginSet = true; + Integer::Parse(gridLayoutValue, layoutParam.marginRight); + if (pTransform) + { + + layoutParam.marginRight = pTransform->Transform(layoutParam.marginRight); + } + } + if (pControlProperty->GetLayoutElement(L"marginTop", gridLayoutValue)) + { + marginSet = true; + Integer::Parse(gridLayoutValue, layoutParam.marginTop); + if (pTransform) + { + + layoutParam.marginTop = pTransform->Transform(layoutParam.marginTop); + } + } + if (pControlProperty->GetLayoutElement(L"marginBottom", gridLayoutValue)) + { + marginSet = true; + Integer::Parse(gridLayoutValue, layoutParam.marginBottom); + if (pTransform) + { + + layoutParam.marginBottom = pTransform->Transform(layoutParam.marginBottom); + } + } + if (marginSet) + { + layout.SetMargin(control, layoutParam.marginLeft, layoutParam.marginRight, layoutParam.marginTop, layoutParam.marginBottom); + } + + bool positionSet = false; + layoutParam.positionRow = 0; + layoutParam.positionColumn = 0; + layoutParam.positionRowSpan = 0; + layoutParam.positionColumnSpan = 0; + if (pControlProperty->GetLayoutElement(L"positionRow", gridLayoutValue)) + { + positionSet = true; + Integer::Parse(gridLayoutValue, layoutParam.positionRow); + } + if (pControlProperty->GetLayoutElement(L"positionColumn", gridLayoutValue)) + { + positionSet = true; + Integer::Parse(gridLayoutValue, layoutParam.positionColumn); + } + if (pControlProperty->GetLayoutElement(L"positionRowSpan", gridLayoutValue)) + { + positionSet = true; + Integer::Parse(gridLayoutValue, layoutParam.positionRowSpan); + } + if (pControlProperty->GetLayoutElement(L"positionColumnSpan", gridLayoutValue)) + { + positionSet = true; + Integer::Parse(gridLayoutValue, layoutParam.positionColumnSpan); + } + if (positionSet) + { + layout.SetPosition(control, layoutParam.positionRow, layoutParam.positionColumn, layoutParam.positionRowSpan, layoutParam.positionColumnSpan); + } +} + +void +_UiBuilderControlMaker::SetHorizontalBoxLayoutProperty(HorizontalBoxLayout* pLayout, _UiBuilderControlLayout* pControlProperty, Control* pControl) +{ + if ((null == pLayout) || (null == pControlProperty) || (null == pControlProperty) || (null == pControl)) + { + return ; + } + + HorizontalBoxLayout& layout = *pLayout; + Control& control = *pControl; + UiBuilderHorizontalBoxLayoutControl layoutParam; + Tizen::Base::String horizontalBoxLayoutValue(L""); + _ICoordinateSystemTransformer* pTransform = GetTransformer(); + + if (pControlProperty->GetLayoutElement(L"height", horizontalBoxLayoutValue)) + { + Integer::Parse(horizontalBoxLayoutValue, layoutParam.height); + if (pTransform) + { + + layoutParam.height = pTransform->Transform(layoutParam.height); + } + layout.SetHeight(control, layoutParam.height); + } + else + { + layoutParam.height = 0; + } + + if (pControlProperty->GetLayoutElement(L"verticalFitPolicy", horizontalBoxLayoutValue)) + { + if (horizontalBoxLayoutValue.Equals(L"FIT_POLICY_CONTENT", false)) + { + layoutParam.verticalFitPolicy = FIT_POLICY_CONTENT; + } + else if (horizontalBoxLayoutValue.Equals(L"FIT_POLICY_PARENT", false)) + { + layoutParam.verticalFitPolicy = FIT_POLICY_PARENT; + } + else + { + layoutParam.verticalFitPolicy = FIT_POLICY_FIXED; + } + layout.SetVerticalFitPolicy(control, layoutParam.verticalFitPolicy); + } + else + { + layoutParam.verticalFitPolicy = FIT_POLICY_CONTENT; + } + + if (pControlProperty->GetLayoutElement(L"verticalAlignment", horizontalBoxLayoutValue)) + { + if (horizontalBoxLayoutValue.Equals(L"LAYOUT_VERTICAL_ALIGN_MIDDLE", false)) + { + layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_MIDDLE; + } + else if (horizontalBoxLayoutValue.Equals(L"LAYOUT_VERTICAL_ALIGN_BOTTOM", false)) + { + layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_BOTTOM; + } + else + { + layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_TOP; + } + + layout.SetVerticalAlignment(control, layoutParam.verticalAlignment); + } + else + { + layoutParam.verticalAlignment = LAYOUT_VERTICAL_ALIGN_TOP; + } + + bool marginSet = false; + layoutParam.verticalTopMargin = 0; + layoutParam.verticalBottomMargin = 0; + if (pControlProperty->GetLayoutElement(L"verticalTopMargin", horizontalBoxLayoutValue)) + { + marginSet = true; + Integer::Parse(horizontalBoxLayoutValue, layoutParam.verticalTopMargin); + if (pTransform) + { + + layoutParam.verticalTopMargin = pTransform->Transform(layoutParam.verticalTopMargin); + } + } + if (pControlProperty->GetLayoutElement(L"verticalBottomMargin", horizontalBoxLayoutValue)) + { + marginSet = true; + Integer::Parse(horizontalBoxLayoutValue, layoutParam.verticalBottomMargin); + if (pTransform) + { + + layoutParam.verticalBottomMargin = pTransform->Transform(layoutParam.verticalBottomMargin); + } + } + if (marginSet) + { + layout.SetVerticalMargin(control, layoutParam.verticalTopMargin, layoutParam.verticalBottomMargin); + } + + if (pControlProperty->GetLayoutElement(L"spacing", horizontalBoxLayoutValue)) + { + Integer::Parse(horizontalBoxLayoutValue, layoutParam.spacing); + if (pTransform) + { + + layoutParam.spacing = pTransform->Transform(layoutParam.spacing); + } + layout.SetSpacing(control, layoutParam.spacing); + } + else + { + layoutParam.spacing = 0; + } + + if (pControlProperty->GetLayoutElement(L"weight", horizontalBoxLayoutValue)) + { + Float::Parse(horizontalBoxLayoutValue, layoutParam.weight); + layout.SetWeight(control, layoutParam.weight); + } + else + { + layoutParam.weight = 0; + } + + if (pControlProperty->GetLayoutElement(L"width", horizontalBoxLayoutValue)) + { + Integer::Parse(horizontalBoxLayoutValue, layoutParam.width); + if (pTransform) + { + + layoutParam.width = pTransform->Transform(layoutParam.width); + } + layout.SetWidth(control, layoutParam.width); + } + else + { + layoutParam.width = 0; + } + + if (pControlProperty->GetLayoutElement(L"horizontalFitPolicy", horizontalBoxLayoutValue)) + { + if (horizontalBoxLayoutValue.Equals(L"FIT_POLICY_CONTENT", false)) + { + layoutParam.horizontalFitPolicy = FIT_POLICY_CONTENT; + } + else if (horizontalBoxLayoutValue.Equals(L"FIT_POLICY_PARENT", false)) + { + layoutParam.horizontalFitPolicy = FIT_POLICY_PARENT; + } + else + { + layoutParam.horizontalFitPolicy = FIT_POLICY_FIXED; + } + layout.SetHorizontalFitPolicy(control, layoutParam.horizontalFitPolicy); + } + else + { + layoutParam.horizontalFitPolicy = FIT_POLICY_CONTENT; + } +} + +void +_UiBuilderControlMaker::SetVerticalBoxLayoutProperty(VerticalBoxLayout* pLayout, _UiBuilderControlLayout* pControlProperty, Control* pControl) +{ + if ((null == pLayout) || (null == pControlProperty) || (null == pControlProperty) || (null == pControl)) + { + return ; + } + + VerticalBoxLayout& layout = *pLayout; + Control& control = *pControl; + UiBuilderVerticalBoxLayoutControl layoutParam; + Tizen::Base::String verticalBoxLayoutValue(L""); + _ICoordinateSystemTransformer* pTransform = GetTransformer(); + + if (pControlProperty->GetLayoutElement(L"height", verticalBoxLayoutValue)) + { + Integer::Parse(verticalBoxLayoutValue, layoutParam.height); + if (pTransform) + { + + layoutParam.height = pTransform->Transform(layoutParam.height); + } + layout.SetHeight(control, layoutParam.height); + } + else + { + layoutParam.height = 0; + } + + if (pControlProperty->GetLayoutElement(L"verticalFitPolicy", verticalBoxLayoutValue)) + { + if (verticalBoxLayoutValue.Equals(L"FIT_POLICY_CONTENT", false)) + { + layoutParam.verticalFitPolicy = FIT_POLICY_CONTENT; + } + else if (verticalBoxLayoutValue.Equals(L"FIT_POLICY_PARENT", false)) + { + layoutParam.verticalFitPolicy = FIT_POLICY_PARENT; + } + else + { + layoutParam.verticalFitPolicy = FIT_POLICY_FIXED; + } + layout.SetVerticalFitPolicy(control, layoutParam.verticalFitPolicy); + } + else + { + layoutParam.verticalFitPolicy = FIT_POLICY_CONTENT; + } + + if (pControlProperty->GetLayoutElement(L"horizontalAlignment", verticalBoxLayoutValue)) + { + if (verticalBoxLayoutValue.Equals(L"LAYOUT_HORIZONTAL_ALIGN_CENTER", false)) + { + layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_CENTER; + } + else if (verticalBoxLayoutValue.Equals(L"LAYOUT_HORIZONTAL_ALIGN_RIGHT", false)) + { + layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_RIGHT; + } + else + { + layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_LEFT; + } + + layout.SetHorizontalAlignment(control, layoutParam.horizontalAlignment); + } + else + { + layoutParam.horizontalAlignment = LAYOUT_HORIZONTAL_ALIGN_LEFT; + } + + bool marginSet = false; + layoutParam.horizontalLeftMargin = 0; + layoutParam.horizontalRightMargin = 0; + if (pControlProperty->GetLayoutElement(L"horizontalLeftMargin", verticalBoxLayoutValue)) + { + marginSet = true; + Integer::Parse(verticalBoxLayoutValue, layoutParam.horizontalLeftMargin); + if (pTransform) + { + layoutParam.horizontalLeftMargin = pTransform->Transform(layoutParam.horizontalLeftMargin); + } + } + if (pControlProperty->GetLayoutElement(L"horizontalRightMargin", verticalBoxLayoutValue)) + { + marginSet = true; + Integer::Parse(verticalBoxLayoutValue, layoutParam.horizontalRightMargin); + if (pTransform) + { + layoutParam.horizontalRightMargin = pTransform->Transform(layoutParam.horizontalRightMargin); + } + } + if (marginSet) + { + layout.SetHorizontalMargin(control, layoutParam.horizontalLeftMargin, layoutParam.horizontalRightMargin); + } + + if (pControlProperty->GetLayoutElement(L"spacing", verticalBoxLayoutValue)) + { + Integer::Parse(verticalBoxLayoutValue, layoutParam.spacing); + if (pTransform) + { + layoutParam.spacing = pTransform->Transform(layoutParam.spacing); + + } + layout.SetSpacing(control, layoutParam.spacing); + } + else + { + layoutParam.spacing = 0; + } + + if (pControlProperty->GetLayoutElement(L"weight", verticalBoxLayoutValue)) + { + Float::Parse(verticalBoxLayoutValue, layoutParam.weight); + layout.SetWeight(control, layoutParam.weight); + } + else + { + layoutParam.weight = 0; + } + + if (pControlProperty->GetLayoutElement(L"width", verticalBoxLayoutValue)) + { + Integer::Parse(verticalBoxLayoutValue, layoutParam.width); + if (pTransform) + { + layoutParam.width = pTransform->Transform(layoutParam.width); + + } + layout.SetWidth(control, layoutParam.width); + } + else + { + layoutParam.width = 0; + } + + if (pControlProperty->GetLayoutElement(L"horizontalFitPolicy", verticalBoxLayoutValue)) + { + if (verticalBoxLayoutValue.Equals(L"FIT_POLICY_CONTENT", false)) + { + layoutParam.horizontalFitPolicy = FIT_POLICY_CONTENT; + } + else if (verticalBoxLayoutValue.Equals(L"FIT_POLICY_PARENT", false)) + { + layoutParam.horizontalFitPolicy = FIT_POLICY_PARENT; + } + else + { + layoutParam.horizontalFitPolicy = FIT_POLICY_FIXED; + } + + layout.SetHorizontalFitPolicy(control, layoutParam.horizontalFitPolicy); + } + else + { + layoutParam.horizontalFitPolicy = FIT_POLICY_FIXED; + } +} + +void +_UiBuilderControlMaker::SetRelativeLayoutProperty(RelativeLayout* pLayout, _UiBuilderControlLayout* pControlProperty, Control* pControl) +{ + if ((null == pLayout) || (null == pControlProperty) || (null == pControlProperty) || (null == pControl)) + { + return; + } + + RelativeLayout& layout = *pLayout; + Control& control = *pControl; + UiBuilderRelativeLayout layoutParam; + Tizen::Base::String relativeLayoutValue(L""); + Tizen::Graphics::Rectangle rect = pControlProperty->GetRect(); + + if (pControlProperty->GetLayoutElement(L"bottomRelation", relativeLayoutValue)) + { + if (GetContainer()->GetName().Equals(relativeLayoutValue)) + { + layoutParam.pBottomRelation = GetContainer(); + } + else + { + layoutParam.pBottomRelation = GetContainer()->GetControl(relativeLayoutValue, true); + } + } + else + { + layoutParam.pBottomRelation = null; + } + + if (layoutParam.pBottomRelation) + { + if (pControlProperty->GetLayoutElement(L"bottomRelationType", relativeLayoutValue)) + { + if (relativeLayoutValue.Equals(L"RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM", false)) + { + layoutParam.bottomRelationType = RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM; + } + else + { + layoutParam.bottomRelationType = RECT_EDGE_RELATION_BOTTOM_TO_TOP; + } + layout.SetRelation(control, *(layoutParam.pBottomRelation), layoutParam.bottomRelationType); + } + else + { + layoutParam.bottomRelationType = RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM; + } + } + + if (pControlProperty->GetLayoutElement(L"leftRelation", relativeLayoutValue)) + { + if (GetContainer()->GetName().Equals(relativeLayoutValue)) + { + layoutParam.pLeftRelation = GetContainer(); + } + else + { + layoutParam.pLeftRelation = GetContainer()->GetControl(relativeLayoutValue, true); + } + } + else + { + layoutParam.pLeftRelation = null; + } + + if (layoutParam.pLeftRelation) + { + if (pControlProperty->GetLayoutElement(L"leftRelationType", relativeLayoutValue)) + { + if (relativeLayoutValue.Equals(L"RECT_EDGE_RELATION_LEFT_TO_LEFT", false)) + { + layoutParam.leftRelationType = RECT_EDGE_RELATION_LEFT_TO_LEFT; + } + else + { + layoutParam.leftRelationType = RECT_EDGE_RELATION_LEFT_TO_RIGHT; + } + layout.SetRelation(control, *(layoutParam.pLeftRelation), layoutParam.leftRelationType); + } + else + { + layoutParam.leftRelationType = RECT_EDGE_RELATION_LEFT_TO_LEFT; + } + } + + if (pControlProperty->GetLayoutElement(L"rightRelation", relativeLayoutValue)) + { + if (GetContainer()->GetName().Equals(relativeLayoutValue)) + { + layoutParam.pRightRelation = GetContainer(); + } + else + { + layoutParam.pRightRelation = GetContainer()->GetControl(relativeLayoutValue, true); + } + } + else + { + layoutParam.pRightRelation = null; + } + + if (layoutParam.pRightRelation) + { + if (pControlProperty->GetLayoutElement(L"rightRelationType", relativeLayoutValue)) + { + if (relativeLayoutValue.Equals(L"RECT_EDGE_RELATION_RIGHT_TO_RIGHT", false)) + { + layoutParam.rightRelationType = RECT_EDGE_RELATION_RIGHT_TO_RIGHT; + } + else + { + layoutParam.rightRelationType = RECT_EDGE_RELATION_RIGHT_TO_LEFT; + } + layout.SetRelation(control, *(layoutParam.pRightRelation), layoutParam.rightRelationType); + } + else + { + layoutParam.rightRelationType = RECT_EDGE_RELATION_RIGHT_TO_RIGHT; + } + } + + if (pControlProperty->GetLayoutElement(L"topRelation", relativeLayoutValue)) + { + if (GetContainer()->GetName().Equals(relativeLayoutValue)) + { + layoutParam.pTopRelation = GetContainer(); + } + else + { + layoutParam.pTopRelation = GetContainer()->GetControl(relativeLayoutValue, true); + } + } + else + { + layoutParam.pTopRelation = null; + } + + if (layoutParam.pTopRelation) + { + if (pControlProperty->GetLayoutElement(L"topRelationType", relativeLayoutValue)) + { + if (relativeLayoutValue.Equals(L"RECT_EDGE_RELATION_TOP_TO_TOP", false)) + { + layoutParam.topRelationType = RECT_EDGE_RELATION_TOP_TO_TOP; + } + else + { + layoutParam.topRelationType = RECT_EDGE_RELATION_TOP_TO_BOTTOM; + } + layout.SetRelation(control, *(layoutParam.pTopRelation), layoutParam.topRelationType); + } + else + { + layoutParam.topRelationType = RECT_EDGE_RELATION_TOP_TO_TOP; + } + } + + if (pControlProperty->GetLayoutElement(L"centerHorizontal", relativeLayoutValue)) + { + if (relativeLayoutValue.Equals(L"true", false)) + { + layoutParam.centerHorizontal = true; + layout.SetCenterAligned(control, CENTER_ALIGN_HORIZONTAL); + } + else + { + layoutParam.centerHorizontal = false; + } + } + else + { + layoutParam.centerHorizontal = false; + } + + if (pControlProperty->GetLayoutElement(L"centerVertical", relativeLayoutValue)) + { + if (relativeLayoutValue.Equals(L"true", false)) + { + layoutParam.centerVertical = true; + layout.SetCenterAligned(control, CENTER_ALIGN_VERTICAL); + } + else + { + layoutParam.centerVertical = false; + } + } + else + { + layoutParam.centerVertical = false; + } + + + if (pControlProperty->GetLayoutElement(L"height", relativeLayoutValue)) + { + layoutParam.height = rect.height; + layout.SetHeight(control, layoutParam.height); + } + else + { + layoutParam.height = 0; + } + + if (pControlProperty->GetLayoutElement(L"verticalFitPolicy", relativeLayoutValue)) + { + if (relativeLayoutValue.Equals(L"FIT_POLICY_CONTENT", false)) + { + layoutParam.verticalFitPolicy = FIT_POLICY_CONTENT; + } + else if (relativeLayoutValue.Equals(L"FIT_POLICY_PARENT", false)) + { + layoutParam.verticalFitPolicy = FIT_POLICY_PARENT; + } + else + { + layoutParam.verticalFitPolicy = FIT_POLICY_FIXED; + } + layout.SetVerticalFitPolicy(control, layoutParam.verticalFitPolicy); + } + else + { + layoutParam.verticalFitPolicy = FIT_POLICY_CONTENT; + } + + if (pControlProperty->GetLayoutElement(L"width", relativeLayoutValue)) + { + layoutParam.width = rect.width; + layout.SetWidth(control, layoutParam.width); + } + else + { + layoutParam.width = 0; + } + + if (pControlProperty->GetLayoutElement(L"horizontalFitPolicy", relativeLayoutValue)) + { + if (relativeLayoutValue.Equals(L"FIT_POLICY_CONTENT", false)) + { + layoutParam.horizontalFitPolicy = FIT_POLICY_CONTENT; + } + else if (relativeLayoutValue.Equals(L"FIT_POLICY_PARENT", false)) + { + layoutParam.horizontalFitPolicy = FIT_POLICY_PARENT; + } + else + { + layoutParam.horizontalFitPolicy = FIT_POLICY_FIXED; + } + layout.SetHorizontalFitPolicy(control, layoutParam.horizontalFitPolicy); + } + else + { + layoutParam.horizontalFitPolicy = FIT_POLICY_CONTENT; + } + + bool marginSet = false; + layoutParam.marginLeft = 0; + layoutParam.marginRight = 0; + layoutParam.marginTop = 0; + layoutParam.marginBottom = 0; + + Tizen::Graphics::_ICoordinateSystemTransformer* pTransform = GetTransformer(); + + if (pControlProperty->GetLayoutElement(L"marginLeft", relativeLayoutValue)) + { + marginSet = true; + Integer::Parse(relativeLayoutValue, layoutParam.marginLeft); + if (pTransform) + { + + layoutParam.marginLeft = pTransform->Transform(layoutParam.marginLeft); + } + } + if (pControlProperty->GetLayoutElement(L"marginRight", relativeLayoutValue)) + { + marginSet = true; + Integer::Parse(relativeLayoutValue, layoutParam.marginRight); + if (pTransform) + { + + layoutParam.marginRight = pTransform->Transform(layoutParam.marginRight); + } + } + if (pControlProperty->GetLayoutElement(L"marginTop", relativeLayoutValue)) + { + marginSet = true; + Integer::Parse(relativeLayoutValue, layoutParam.marginTop); + if (pTransform) + { + + layoutParam.marginTop = pTransform->Transform(layoutParam.marginTop); + } + } + if (pControlProperty->GetLayoutElement(L"marginBottom", relativeLayoutValue)) + { + marginSet = true; + Integer::Parse(relativeLayoutValue, layoutParam.marginBottom); + if (pTransform) + { + + layoutParam.marginBottom = pTransform->Transform(layoutParam.marginBottom); + } + } + if (marginSet) + { + layout.SetMargin(control, layoutParam.marginLeft, layoutParam.marginRight, layoutParam.marginTop, layoutParam.marginBottom); + } +} + +void +_UiBuilderControlMaker::SetLayoutProperty(_UiBuilderControl* pUiBuilderControl, Control* pControl) +{ + int i = 0; + _UiBuilderControlLayout* pControlProperty = null; + + Container* pContainer = null; + if (GetContainer()->GetName().Equals(Tizen::Base::String(pUiBuilderControl->GetParentWin()))) + { + pContainer = static_cast(GetContainer()); + } + else + { + pContainer = dynamic_cast(static_cast(GetContainer())->GetControl(pUiBuilderControl->GetParentWin(), true)); + } + + SysTryReturnVoidResult(NID_UI, pContainer != null, GetLastResult(), "Failed to get Container"); + + for (i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++) + { + _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE; + pControlProperty = pUiBuilderControl->GetAttribute(i); + GetParentLayoutType(pControlProperty, layoutType); + switch (layoutType) + { + case UIBUILDER_LAYOUT_NONE: + break; + + case UIBUILDER_LAYOUT_GRID: + { + GridLayout* pLayout = null; + if (UIBUILDER_ATTRIBUTE_PORTRAIT == i) + { + pLayout = dynamic_cast(pContainer->GetPortraitLayoutN()); + } + else if (UIBUILDER_ATTRIBUTE_LANDSCAPE == i) + { + pLayout = dynamic_cast(pContainer->GetLandscapeLayoutN()); + } + + if (pLayout) + { + SetGridLayoutControlProperty(pLayout, pControlProperty, pControl); + delete pLayout; + } + break; + } + + case UIBUILDER_LAYOUT_HORIZONTAL_BOX: + { + HorizontalBoxLayout* pLayout = null; + if (UIBUILDER_ATTRIBUTE_PORTRAIT == i) + { + pLayout = dynamic_cast(pContainer->GetPortraitLayoutN()); + } + else if (UIBUILDER_ATTRIBUTE_LANDSCAPE == i) + { + pLayout = dynamic_cast(pContainer->GetLandscapeLayoutN()); + } + if (pLayout) + { + SetHorizontalBoxLayoutProperty(pLayout, pControlProperty, pControl); + delete pLayout; + } + break; + } + + case UIBUILDER_LAYOUT_VERTICAL_BOX: + { + VerticalBoxLayout* pLayout = null; + if (UIBUILDER_ATTRIBUTE_PORTRAIT == i) + { + pLayout = dynamic_cast(pContainer->GetPortraitLayoutN()); + } + else if (UIBUILDER_ATTRIBUTE_LANDSCAPE == i) + { + pLayout = dynamic_cast(pContainer->GetLandscapeLayoutN()); + } + if (pLayout) + { + SetVerticalBoxLayoutProperty(pLayout, pControlProperty, pControl); + delete pLayout; + } + break; + } + + case UIBUILDER_LAYOUT_RELATIVE: + { + RelativeLayout* pLayout = null; + if (UIBUILDER_ATTRIBUTE_PORTRAIT == i) + { + pLayout = dynamic_cast(pContainer->GetPortraitLayoutN()); + } + else if (UIBUILDER_ATTRIBUTE_LANDSCAPE == i) + { + pLayout = dynamic_cast(pContainer->GetLandscapeLayoutN()); + } + if (pLayout) + { + SetRelativeLayoutProperty(pLayout, pControlProperty, pControl); + delete pLayout; + } + break; + } + + default: + SysLog(NID_UI, "Unknown Layout type = %d", layoutType); + break; + } + + } +} + +void +_UiBuilderControlMaker::AddControl(_UiBuilderControl* pUiBuilderControl, Tizen::Ui::Control* pControl) +{ + Tizen::Base::String panePosition; + Tizen::Ui::Container* pContainer = GetContainer(); + Tizen::Ui::Control* pFindControl = null; + + + //Find Container + if (pContainer->GetName().Equals(pUiBuilderControl->GetParentWin())) + { + pFindControl = pContainer; + } + else + { + pFindControl = pContainer->GetControl(Tizen::Base::String(pUiBuilderControl->GetParentWin()), true); + } + + + //Add SplitPanel child + if (pUiBuilderControl->GetElement(L"controlPosition", panePosition)) + { + + Tizen::Ui::Controls::SplitPanel *pSplitPanel = dynamic_cast(pFindControl); + if (pSplitPanel) + { + if(panePosition.Equals(L"first", false)) + { + pSplitPanel->SetPane(pControl, SPLIT_PANEL_PANE_ORDER_FIRST); + } + else + { + pSplitPanel->SetPane(pControl, SPLIT_PANEL_PANE_ORDER_SECOND); + } + } + } + + //Add Container chid + Tizen::Ui::Container* pParent = dynamic_cast(pFindControl); + + if (pParent != null) + { + pParent->AddControl(*pControl); + } +} + +Tizen::Ui::Container* +_UiBuilderControlMaker::GetContainer(void) const +{ + return __pUiBuilder->GetContainer(); +} + +void +_UiBuilderControlMaker::SetLayoutOrientation(_UiBuilderControl* pUiBuilderCOntrol, Tizen::Ui::Control* pControl) +{ + __pUiBuilder->SetLayoutOrientation(pUiBuilderCOntrol, pControl); +} + +void +_UiBuilderControlMaker::SetUiBuilderRotateState(_UiBuilderScreenRotate rotate) +{ + return __pUiBuilder->SetUiBuilderRotateState(rotate); +} + +_UiBuilderScreenRotate +_UiBuilderControlMaker::GetUiBuilderRotateState(void) +{ + return __pUiBuilder->GetUiBuilderRotateState(); +} + +Tizen::Graphics::_ICoordinateSystemTransformer* +_UiBuilderControlMaker::GetTransformer(void) const +{ + return __pUiBuilder->GetTransformer(); +} + +} } // Tizen::Ui diff --git a/src/ui/FUi_UiBuilderControlTable.cpp b/src/ui/FUi_UiBuilderControlTable.cpp new file mode 100644 index 0000000..4971e78 --- /dev/null +++ b/src/ui/FUi_UiBuilderControlTable.cpp @@ -0,0 +1,201 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUi_UiBuilderControlTable.cpp +* @brief This is the implementation file for _UiBuilderControlTable class. +*/ + +#include +#include +#include +#include +#include +#include "FUi_UiBuilderControlTable.h" +#include "FUi_UiBuilder.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui +{ +_UiBuilderControlTable::_UiBuilderControlTable(void) + : __pUiBuilderControlTableInFomationList(null) +{ + if (__pUiBuilderControlTableInFomationList == null) + { + __pUiBuilderControlTableInFomationList = new (std::nothrow) ArrayListT<_UiBuilderControlTableInFomation*>; + } +} + +_UiBuilderControlTable::~_UiBuilderControlTable(void) +{ + if (__pUiBuilderControlTableInFomationList) + { + _UiBuilderControlTableInFomation* pUiBuilderControlTableInFomation = null; + int controlCount = __pUiBuilderControlTableInFomationList->GetCount(); + for (int i = 0; i < controlCount; i++) + { + __pUiBuilderControlTableInFomationList->GetAt(i, pUiBuilderControlTableInFomation); + delete pUiBuilderControlTableInFomation; + } + __pUiBuilderControlTableInFomationList->RemoveAll(); + delete __pUiBuilderControlTableInFomationList; + __pUiBuilderControlTableInFomationList = null; + } +} + +_UiBuilderControlTableManager::_UiBuilderControlTableManager(void) +: __pControlTable(null) +{ + +} + +_UiBuilderControlTableManager::~_UiBuilderControlTableManager(void) +{ + +} + +result +_UiBuilderControlTableManager::Construct(void) +{ + if (__pControlTable == null) + { + __pControlTable = new (std::nothrow) _UiBuilderControlTable; + SysTryReturn(NID_UI, __pControlTable != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _UiBuilderControlTable."); + } + + return E_SUCCESS; +} + +_UiBuilderControlTableManager* +_UiBuilderControlTableManager::GetInstance() +{ + result r = E_SUCCESS; + static _UiBuilderControlTableManager* pUiBuilderControlTable = null; + + if (pUiBuilderControlTable == null) + { + pUiBuilderControlTable = new (std::nothrow) _UiBuilderControlTableManager; + SysTryReturn(NID_UI, pUiBuilderControlTable != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _pUiBuilder."); + + r = pUiBuilderControlTable->Construct(); + SysTryReturn(NID_UI, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to construct _pUiBuilder."); + } + + return pUiBuilderControlTable; +} +_UiBuilderControlTable* +_UiBuilderControlTableManager::GetControlTable() const +{ + return __pControlTable; +} + +void +_UiBuilderControlTableManager::RegisterControl(const Tizen::Base::String& controlMakerName, _UiBuilderControlMakerFunctionPointer pControlMakerFunctionPointer) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = GetInstance(); + _UiBuilderControlTable* pUiBuilderControlTable = null; + if(pUiBuilderControlTableManager != null && pControlMakerFunctionPointer != null) + { + pUiBuilderControlTable = pUiBuilderControlTableManager->GetControlTable(); + } + else + { + return; + } + + _UiBuilderControlTableInFomation* pUiBuilderControlTableInFomation = null; + pUiBuilderControlTableInFomation = new (std::nothrow) _UiBuilderControlTableInFomation; + if (pUiBuilderControlTableInFomation != null) + { + pUiBuilderControlTableInFomation->__controlMakerName = controlMakerName; + pUiBuilderControlTableInFomation->__pContolMakerFunctionPointer = pControlMakerFunctionPointer; + pUiBuilderControlTable->__pUiBuilderControlTableInFomationList->Add(pUiBuilderControlTableInFomation); + } + else + { + SysLogException(NID_UI, E_OUT_OF_MEMORY, "[kongp]Failed to CreateControl()"); + } + + SysLog(NID_UI, "[UiBuilder]Register success [%ls]", pUiBuilderControlTableInFomation->__controlMakerName.GetPointer()); +} + +void +_UiBuilderControlTableManager::UnregisterControl(const Tizen::Base::String& controlMakerName) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = GetInstance(); + _UiBuilderControlTable* pUiBuilderControlTable = null; + if(controlMakerName.IsEmpty() == false) + { + pUiBuilderControlTable = pUiBuilderControlTableManager->GetControlTable(); + } + else + { + return; + } + + IEnumeratorT<_UiBuilderControlTableInFomation*>* pEnum = pUiBuilderControlTable->__pUiBuilderControlTableInFomationList->GetEnumeratorN(); + _UiBuilderControlTableInFomation* pUiBuilderControlTableInFomation = null; + + while (pEnum->MoveNext() == E_SUCCESS) + { + pEnum->GetCurrent(pUiBuilderControlTableInFomation); + if (pUiBuilderControlTableInFomation->__controlMakerName.Equals(controlMakerName, false)) + { + pUiBuilderControlTableInFomation->__pContolMakerFunctionPointer = null; + break; + } + } + delete pEnum; + +} + +String +_UiBuilderControlTableManager::GetName(int index) const +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = GetInstance(); + SysTryReturn(NID_UI, pUiBuilderControlTableManager != null, null, E_SYSTEM, + "[E_SYSTEM] IUnable to get the UiBuilderControlTableManager"); + + _UiBuilderControlTable* pUiBuilderControlTable = pUiBuilderControlTableManager->GetControlTable(); + + _UiBuilderControlTableInFomation* pUiBuilderControlTableInFomation = null; + pUiBuilderControlTable->__pUiBuilderControlTableInFomationList->GetAt(index, pUiBuilderControlTableInFomation); + SysTryReturn(NID_UI, pUiBuilderControlTableInFomation != null, L"", GetLastResult(), "Failed to GetControl()"); + + return (const Tizen::Base::String) pUiBuilderControlTableInFomation->__controlMakerName; +} + +_UiBuilderControlMakerFunctionPointer +_UiBuilderControlTableManager::GetControlMaker(int index) const +{ + + _UiBuilderControlTableManager* pUiBuilderControlTableManager = GetInstance(); + SysTryReturn(NID_UI, pUiBuilderControlTableManager != null, null, E_SYSTEM, + "[E_SYSTEM] IUnable to get the UiBuilderControlTableManager"); + + _UiBuilderControlTable* pUiBuilderControlTable = pUiBuilderControlTableManager->GetControlTable(); + _UiBuilderControlTableInFomation* pUiBuilderControlTableInFomation = null; + pUiBuilderControlTable->__pUiBuilderControlTableInFomationList->GetAt(index, pUiBuilderControlTableInFomation); + SysTryReturn(NID_UI, pUiBuilderControlTableInFomation != null, null, GetLastResult(), "Failed to GetControl()"); + + return pUiBuilderControlTableInFomation->__pContolMakerFunctionPointer; +} + +} } // Tizen::Ui diff --git a/src/ui/FUi_UiBuilderXmlHandler.cpp b/src/ui/FUi_UiBuilderXmlHandler.cpp new file mode 100755 index 0000000..fc0a856 --- /dev/null +++ b/src/ui/FUi_UiBuilderXmlHandler.cpp @@ -0,0 +1,409 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_UiBuilderXmlHandler.cpp +* @brief This is the implementation file for _UiBuilderXmlHandler class. +*/ + +#include +#include +#include +#include "FUi_UiBuilderXmlHandler.h" +#include "FUi_UiBuilderControlElement.h" + +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui +{ +void StartElementSaxFunc(void* pCtx, const xmlChar* pName, const xmlChar** pAttributes); +void ParseCharactersSaxFunc(void *ctx, const xmlChar *ch, int len); +xmlSAXHandler mySaxHandler = { +null, null, null, null, null, null, null, null, null, null, null, null, null, null, +StartElementSaxFunc, +null, null, ParseCharactersSaxFunc, null, null, null, null, null, null, null, null, null, null, null, null, null, null +}; + +_UiBuilderXmlHandler* XMLHandler = null; + +_UiBuilderXmlHandler::_UiBuilderXmlHandler(void) + : __pGenerator(null) + , __pControl(null) + , __formXmlResolutionExists(false) + , __errorLog("") + , __errorResult(E_SUCCESS) + , __layoutMode(UIBUILDER_ATTRIBUTE_PORTRAIT) + , __xPosition(L"") + , __yPosition(L"") + , __width(L"") + , __height(L"") + , __pProperty(null) + +{ +} + +_UiBuilderXmlHandler::~_UiBuilderXmlHandler(void) +{ +} + +bool +_UiBuilderXmlHandler::Construct(_UiBuilder* pGenerator) +{ + if (pGenerator) + { + XMLHandler = this; + __pGenerator = pGenerator; + return true; + } + return false; +} + +result +_UiBuilderXmlHandler::ParseXml(char* pXmlBuffer, int size) +{ + xmlSAXHandlerPtr pMySaxhandler = &mySaxHandler; + xmlSubstituteEntitiesDefault(1); + xmlSAXUserParseMemory(pMySaxhandler, null, pXmlBuffer, size); + xmlCleanupMemory(); + + if (__errorResult != E_SUCCESS) + { + SysLogException(NID_UI, E_INVALID_FORMAT, "[E_INVALID_FORMAT][UiBuilder] %ls", XMLHandler->__errorLog.GetPointer()); + return __errorResult; + } + return E_SUCCESS; + +} + +void +ParseCharactersSaxFunc(void*ctx, const xmlChar*ch, int len) +{ + if (XMLHandler->__formXmlResolutionExists == true) + { + Tizen::Graphics::_LogicalResolution formXmlResolution; + if (xmlStrncmp( ch, (xmlChar*)"720", len) == 0) + { + formXmlResolution = Tizen::Graphics::RESOLUTION_LOGICAL_720; + XMLHandler->__errorResult = XMLHandler->__pGenerator->SetFormXmlResolution(formXmlResolution); + } + else + { + formXmlResolution = Tizen::Graphics::RESOLUTION_LOGICAL_480; + XMLHandler->__errorResult = XMLHandler->__pGenerator->SetFormXmlResolution(formXmlResolution); + } + XMLHandler->__formXmlResolutionExists = false; + } +} + +void +StartElementSaxFunc(void* pCtx, const xmlChar* pName, const xmlChar** pAttributes) +{ + if (XMLHandler->__errorResult != E_SUCCESS) + { + xmlStopParser((xmlParserCtxt*)pCtx); + } + + if (xmlStrcasecmp(pName, (xmlChar*) "Layout") == 0) + { + XMLHandler->SetAttribute(pAttributes); + } + else if (xmlStrcasecmp(pName, (xmlChar*) "Property") == 0) + { + XMLHandler->SetProperty(pAttributes); + } + else if (xmlStrcasecmp(pName, (xmlChar*) "Scene") == 0 || xmlStrcasecmp(pName, (xmlChar*) "ScenePanel") == 0 || xmlStrcasecmp(pName, (xmlChar*) "ScenePopup") == 0 || xmlStrcasecmp(pName, (xmlChar*) "SceneQuickPanelFrame") == 0) + { + XMLHandler->SetXmlVersion(pAttributes); + } + else if (xmlStrcasecmp(pName, (xmlChar*) "panelLayout") == 0) + { + // empty statement + } + else if (xmlStrcasecmp(pName, (xmlChar*) "itemSet") == 0) + { + // empty statement + } + else if (xmlStrcasecmp(pName, (xmlChar*) "LogicalCoordinate") == 0 || xmlStrcasecmp(pName, (xmlChar*) "BaseResolution") == 0) + { + XMLHandler->__formXmlResolutionExists = true; + } + else if (xmlStrcasecmp(pName, (xmlChar*) "headerItem") == 0) + { + XMLHandler->SetItem(pName, pAttributes); + + } + else if (xmlStrcasecmp(pName, (xmlChar*) "buttonItem") == 0) + { + XMLHandler->SetItem(pName, pAttributes); + + } + else if (xmlStrcasecmp(pName, (xmlChar*) "footerItem") == 0) + { + XMLHandler->SetItem(pName, pAttributes); + + } + else if (xmlStrcasecmp(pName, (xmlChar*) "backButton") == 0) + { + XMLHandler->SetItem(pName, pAttributes); + + } + else if (xmlStrcasecmp(pName, (xmlChar*) "item") == 0) + { + XMLHandler->SetItem(pName, pAttributes); + + } + else + { + XMLHandler->__pControl = XMLHandler->__pGenerator->CreateControl(); + if (XMLHandler->__pControl == null) + { + XMLHandler->__errorLog = "Failed to create UiBuilderControl"; + XMLHandler->__errorResult = E_INVALID_FORMAT; + } + + XMLHandler->__pControl->Construct((char*) pName); + + if (pAttributes != null) + { + for (int i = 0; (pAttributes[i] != null); i++) + { + if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "id") == 0) + { + if (pAttributes[++i] != null) + { + XMLHandler->__pControl->SetId((char*) pAttributes[i]); + } + } + else if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "parent") == 0) + { + if (pAttributes[++i] != null) + { + XMLHandler->__pControl->SetParentWin((char*) pAttributes[i]); + } + } + } + } + } +} + +void +_UiBuilderXmlHandler::ParseAttribute(const xmlChar** pAttributes, int index, const Tizen::Base::String& name) +{ + bool findAttribute = false; + + if (index == LAYOUT_SETTING) + { + index = 0; + const Tizen::Base::String parentWindow = __pControl->GetParentWin(); + _UiBuilderControl* pParentControl = XMLHandler->__pGenerator->GetControl(parentWindow); + if (parentWindow.GetLength() != 0) + { + Tizen::Base::String layoutType(L""); + _UiBuilderControlLayout* pParentProperty = pParentControl->GetAttribute(__layoutMode); + if (pParentProperty->GetLayoutElement(L"type", layoutType)) + { + __pProperty->SetLayoutElement(index, L"parentType", layoutType); + index++; + } + } + + for (int i = 0; pAttributes[i] != null; i++) + { + if (pAttributes[++i] != null) + { + if (__pProperty != null) + { + __pProperty->SetLayoutElement(index, (char*) pAttributes[i - 1], (char*) pAttributes[i]); + index++; + } + } + } + } + else if (name.Equals(L"mode", false) && pAttributes[index] != null) + { + if (xmlStrcasecmp(pAttributes[index], (xmlChar*) "Portrait") == 0) + { + __pProperty = XMLHandler->__pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT); + __layoutMode = UIBUILDER_ATTRIBUTE_PORTRAIT; + findAttribute = true; + } + else if (xmlStrcasecmp(pAttributes[index], (xmlChar*) "Landscape") == 0) + { + __pProperty = XMLHandler->__pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE); + __layoutMode = UIBUILDER_ATTRIBUTE_LANDSCAPE; + findAttribute = true; + } + if (findAttribute == false) + { + __pProperty = XMLHandler->__pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT); + } + } + else if (name.Equals(L"style", false) && pAttributes[index] != null) + { + __pProperty->SetStyle((char*) pAttributes[index]); + } + else if (name.Equals(L"x", false) && pAttributes[index] != null) + { + __xPosition = (char*) pAttributes[index]; + } + else if (name.Equals(L"y", false) && pAttributes[index] != null) + { + __yPosition = (char*) pAttributes[index]; + } + else if (name.Equals(L"width", false) && pAttributes[index] != null) + { + __width = (char*) pAttributes[index]; + } + else if (name.Equals(L"height", false) && pAttributes[index] != null) + { + __height = (char*) pAttributes[index]; + } + else + { + __errorLog = L"Failed to ExecAttribute"; + __errorResult = E_INVALID_FORMAT; + + } + +} + +void +_UiBuilderXmlHandler::SetAttribute(const xmlChar** pAttributes) +{ + if (pAttributes != null) + { + for (int i = 0; (pAttributes[i] != null); i++) + { + if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "mode") == 0) + { + ParseAttribute(pAttributes, ++i, L"mode"); + } + else if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "style") == 0) + { + ParseAttribute(pAttributes, ++i, L"style"); + } + else if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "x") == 0) + { + ParseAttribute(pAttributes, ++i, L"x"); + } + else if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "y") == 0) + { + ParseAttribute(pAttributes, ++i, L"y"); + } + else if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "width") == 0) + { + ParseAttribute(pAttributes, ++i, L"width"); + } + else if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "height") == 0) + { + ParseAttribute(pAttributes, ++i, L"height"); + } + } + } + else + { + __errorLog = L"Failed to SetAttribute"; + __errorResult = E_INVALID_FORMAT; + } + + __pProperty = XMLHandler->__pControl->GetAttribute(__layoutMode); + __pProperty->SetRect(__xPosition, __yPosition, __width, __height); + + //layout setting + if (pAttributes != null) + { + ParseAttribute(pAttributes, LAYOUT_SETTING, (char*) "layout"); + } + else + { + __errorLog = L"Failed to layout setting"; + __errorResult = E_INVALID_FORMAT; + } + +} + +void +_UiBuilderXmlHandler::SetProperty(const xmlChar** pAttributes) +{ + int index = 0; + if (pAttributes != null) + { + for (int i = 0; (pAttributes[i] != null); i++) + { + if (pAttributes[++i] != null) + { + XMLHandler->__pControl->SetElement(index, (char*) pAttributes[i - 1], (char*) pAttributes[i]); + } + index++; + } + } + else + { + __errorLog = L"Failed to SetProperty"; + __errorResult = E_INVALID_FORMAT; + + } +} + +void +_UiBuilderXmlHandler::SetItem(const xmlChar* name, const xmlChar** pAttributes) +{ + int index = 0; + int controlIndex = 0; + + while (pAttributes[index] != null) + { + if (pAttributes[++index] != null) + { + XMLHandler->__pControl->SetItemElement(controlIndex, (char*) pAttributes[index - 1], (char*) pAttributes[index]); + index++; + controlIndex++; + } + else + { + __errorLog = L"Failed to SetItem"; + __errorResult = E_INVALID_FORMAT; + + return; + } + } + XMLHandler->__pControl->SetItemName((char*) name); +} + +void +_UiBuilderXmlHandler::SetXmlVersion(const xmlChar** pAttributes) +{ + if (pAttributes != null) + { + for (int i = 0; (pAttributes[i] != null); i++) + { + if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "Dversion") == 0) + { + if (pAttributes[++i] != null) + { + int ver = atoi((char*) pAttributes[i]); + XMLHandler->__pGenerator->SetVersion(ver); + } + } + } + } + else + { + __errorLog = "Failed to SetXmlVersion"; + __errorResult = E_INVALID_FORMAT; + } +} +} } // Tizen::Ui diff --git a/src/ui/FUi_UiEvent.cpp b/src/ui/FUi_UiEvent.cpp new file mode 100644 index 0000000..42d25e6 --- /dev/null +++ b/src/ui/FUi_UiEvent.cpp @@ -0,0 +1,192 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiEvent.cpp + * @brief This is the implementation file for the _UiEvent class. + */ + +#include +#include +#include +#include "FUi_UiEvent.h" +#include "FUi_Control.h" +#include "FUi_ControlManager.h" + +using namespace Tizen::Base; +using namespace Tizen::App; + +namespace Tizen { namespace Ui +{ +_UiEvent::_UiEvent(const _UiObjectHandle& destination, const _UiObjectHandle& source, _UiEventRouteType routeType) + : __destination(destination) + , __source(source) + , __originalDestination(destination) + , __routeType(routeType) + , __accessibilityEvent(false) +{ +} + +_UiEvent::~_UiEvent(void) +{ +} + +_UiEvent::_UiEvent(const _UiEvent& rhs) + : __destination(rhs.__destination) + , __source(rhs.__source) + , __originalDestination(rhs.__originalDestination) + , __routeType(rhs.__routeType) + , __accessibilityEvent(rhs.__accessibilityEvent) +{ +} + +_UiEvent& +_UiEvent::operator =(const _UiEvent& rhs) +{ + if (this != &rhs) + { + __destination = rhs.__destination; + __source = rhs.__source; + __originalDestination = rhs.__originalDestination; + __routeType = rhs.__routeType; + } + + return *this; +} + +_UiObjectHandle +_UiEvent::GetDestination(void) const +{ + return __destination; +} + +_UiObjectHandle +_UiEvent::GetSource(void) const +{ + return __source; +} + +void +_UiEvent::SetOriginalDestination(const _Control& control) +{ + __originalDestination = control.GetHandle(); +} + +_UiObjectHandle +_UiEvent::GetOriginalDestination(void) const +{ + return __originalDestination; +} + +void +_UiEvent::SetRouteType(_UiEventRouteType routeType) +{ + __routeType = routeType; +} + +_UiEventRouteType +_UiEvent::GetRouteType(void) const +{ + return __routeType; +} + +result +_UiEvent::ProcessPreviewEvent(const _Control& control, bool& isFiltered) +{ + if (!IsEventReceivable(control)) + { + return E_SUCCESS; + } + + return OnPreviewEventProcessing(control, isFiltered); +} + +result +_UiEvent::ProcessEvent(const _Control& control, bool& isFiltered) +{ + if (!IsEventReceivable(control)) + { + return E_SUCCESS; + } + + bool isInputFiltered = isFiltered; + result r = OnEventProcessing(control, isFiltered); + SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + if (!isInputFiltered && isFiltered) + { + const _Control* pTarget = GetControl(GetDestination()); + SysTryReturn(NID_UI, pTarget, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + if (IsEventReceivable(*pTarget) && (pTarget != &control)) + { + r = OnEventHandled(control); + } + } + + return r; +} + +result +_UiEvent::ProcessListener(const _IUiEventListener& listener, bool& isFiltered) +{ + return OnListenerProcessing(listener, isFiltered); +} + +const _Control* +_UiEvent::GetControl(const _UiObjectHandle& handle) const +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return pControlManager->GetObject(handle); +} + +bool +_UiEvent::IsEventReceivable(const _Control& control) const +{ + if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + return true; + } + + if (!control.IsEnabled()) + { + return false; + } + + return true; +} + +result +_UiEvent::OnEventHandled(const _Control& control) +{ + return E_SUCCESS; +} + +void +_UiEvent::SetAccessibilityEvent(bool set) +{ + __accessibilityEvent = set; +} + +bool +_UiEvent::GetAccessibilityEvent(void) const +{ + return __accessibilityEvent; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_UiEventManager.cpp b/src/ui/FUi_UiEventManager.cpp new file mode 100644 index 0000000..45869e8 --- /dev/null +++ b/src/ui/FUi_UiEventManager.cpp @@ -0,0 +1,763 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiEventManager.cpp + * @brief This is the implementation file for the _UiEventManager class. + */ + +#include +#include +#include +#include +#include +#include "FUi_UiEventManager.h" +#include "FUi_UiEvent.h" +#include "FUi_INotificationEventListener.h" +#include "FUi_IKeyEventListener.h" +#include "FUi_ITouchEventListener.h" +#include "FUi_IFocusEventListener.h" +#include "FUi_EflUiEventManager.h" +#include "FUi_Control.h" +#include "FUi_ControlManager.h" +#include "FUi_TouchManager.h" +#include "FUi_TouchGestureDetector.h" +#include "FUiAnim_ControlVisualElement.h" +#include "FUi_UiKeyEvent.h" +#include "FUi_KeyEventManager.h" +#if defined(MULTI_WINDOW) +#include "FUi_Window.h" +#endif + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui +{ + +_UiEventManager* _UiEventManager::__pInstance = null; + +void +_UiEventManager::Initialize(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (!__pInstance) + { + pthread_once(&once_block, InitInstance); + } +} + +void +_UiEventManager::Release(void) +{ + delete __pInstance; + __pInstance = null; +} + +_UiEventManager* +_UiEventManager::GetInstance(void) +{ + return __pInstance; +} + +void +_UiEventManager::InitInstance(void) +{ + if (!__pInstance) + { + __pInstance = new (std::nothrow) _UiEventManager; + SysAssert(__pInstance); + } +} + +result +_UiEventManager::AddTouchEventListener(const _ITouchEventListener& listener) +{ + return AddEventListener(_UI_EVENT_TOUCH, false, listener); +} + +result +_UiEventManager::AddKeyEventListener(const _IKeyEventListener& listener) +{ + return AddEventListener(_UI_EVENT_KEY, false, listener); +} + +result +_UiEventManager::AddFocusEventListener(const _IFocusEventListener& listener) +{ + return AddEventListener(_UI_EVENT_FOCUS, false, listener); +} + +result +_UiEventManager::AddNotificationEventListener(const _INotificationEventListener& listener) +{ + return AddEventListener(_UI_EVENT_NOTIFICAITON, false, listener); +} + +result +_UiEventManager::RemoveTouchEventListener(const _ITouchEventListener& listener) +{ + return RemoveEventListener(_UI_EVENT_TOUCH, false, listener); +} + +result +_UiEventManager::RemoveKeyEventListener(const _IKeyEventListener& listener) +{ + return RemoveEventListener(_UI_EVENT_KEY, false, listener); +} + +result +_UiEventManager::RemoveFocusEventListener(const _IFocusEventListener& listener) +{ + return RemoveEventListener(_UI_EVENT_FOCUS, false, listener); +} + +result +_UiEventManager::RemoveNotificationEventListener(const _INotificationEventListener& listener) +{ + return RemoveEventListener(_UI_EVENT_NOTIFICAITON, false, listener); +} + +result +_UiEventManager::AddPostKeyEventListener(const _IKeyEventListener& listener) +{ + return AddEventListener(_UI_EVENT_KEY, true, listener); +} + +result +_UiEventManager::RemovePostKeyEventListener(const _IKeyEventListener& listener) +{ + return RemoveEventListener(_UI_EVENT_KEY, true, listener); +} + +result +_UiEventManager::SendEvent(const _UiEvent& event) +{ + result r = E_SUCCESS; + + r = Fire(event); + + return r; +} + +result +_UiEventManager::PostEvent(const _UiEvent& event) +{ + return __pEventManager->PostEvent(event); +} + +result +_UiEventManager::GenerateKeyEvent(KeyState keyState, _KeyCode keyCode, _KeyModifier keyModifier, bool async) +{ + result r = E_SUCCESS; + + _UiObjectHandle uiObjectHandle = GetTarget(); + if (uiObjectHandle.IsNull()) + { + return r; + } + + _UiEventRouteType routeType = (keyState == KEY_LONGPRESSED) ? _UI_EVENT_ROUTE_DIRECT : _UI_EVENT_ROUTE_TUNNEL_BUBBLE; + + _KeyInfo keyInfo(keyState, keyCode, keyModifier, null); + + _UiKeyEvent event(uiObjectHandle, keyInfo, routeType); + + if (async) + { + r = PostEvent(event); + } + else + { + r = SendEvent(event); + } + + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_UiEventManager::GenerateTouchEvent(_TouchStatus touchStatus, int x, int y, bool async) +{ + result r = E_SUCCESS; + + _UiObjectHandle uiObjectHandle = GetTarget(x, y); + if (uiObjectHandle.IsNull()) + { + return r; + } + + const unsigned long DEVICE_ID = 0; + + Point current(x, y); + unsigned int pointId = 0; + _UiEventRouteType routeType = _UI_EVENT_ROUTE_TUNNEL_BUBBLE; + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + switch (touchStatus) + { + case _TOUCH_PRESSED: + pointId = pTouchManager->GeneratePointId(DEVICE_ID); + break; + + case _TOUCH_LONG_PRESSED: + // fall through + case _TOUCH_DOUBLE_PRESSED: + routeType = _UI_EVENT_ROUTE_DIRECT; + pointId = pTouchManager->GetPointId(DEVICE_ID); + break; + + default: + pointId = pTouchManager->GetPointId(DEVICE_ID); + break; + } + + _TouchInfo touchInfo(pointId, touchStatus, current, false, 0); + _UiTouchEvent event(uiObjectHandle, touchInfo, routeType); + + if (async) + { + r = PostEvent(event); + } + else + { + r = SendEvent(event); + } + + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +_IUiEventManager* +_UiEventManager::GetEventManager(void) const +{ + return __pEventManager.get(); +} + +result +_UiEventManager::AddEventListener(_UiEventType eventType, bool postListener, const _IUiEventListener& listener) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI, !IsListenerRegistered(eventType, postListener, listener), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + LinkedListT <_IUiEventListener*>* pEventListeners = GetEventListeners(eventType, postListener); + if (pEventListeners) + { + pEventListeners->Add(const_cast <_IUiEventListener*>(&listener)); + } + + return r; +} + +result +_UiEventManager::RemoveEventListener(_UiEventType eventType, bool postListener, const _IUiEventListener& listener) +{ + result r = E_SUCCESS; + + LinkedListT <_IUiEventListener*>* pEventListeners = GetEventListeners(eventType, postListener); + if (pEventListeners) + { + pEventListeners->Remove(const_cast <_IUiEventListener*>(&listener)); + } + + return r; +} + +bool +_UiEventManager::IsListenerRegistered(_UiEventType eventType, bool postListener, const _IUiEventListener& listener) +{ + bool isRegistered = false; + + LinkedListT <_IUiEventListener*>* pEventListeners = GetEventListeners(eventType, postListener); + if (pEventListeners) + { + Tizen::Base::Collection::IEnumeratorT <_IUiEventListener*>* pEnumerator = pEventListeners->GetEnumeratorN(); + SysTryReturn(NID_UI, pEnumerator, false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + _IUiEventListener* pEventListener = null; + pEnumerator->GetCurrent(pEventListener); + if (!pEventListener) + { + continue; + } + + if (pEventListener == &listener) + { + isRegistered = true; + break; + } + } + + delete pEnumerator; + } + + return isRegistered; +} + +result +_UiEventManager::Fire(const _UiEvent& event) +{ + result r = E_SUCCESS; + + bool isFiltered = false; + + r = ProcessListener(event, isFiltered); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (!isFiltered) + { + r = ProcessGlobalGesture(event, isFiltered); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (event.GetEventType() == _UI_EVENT_TOUCH) + { + r = ProcessEvent(event, isFiltered); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (!isFiltered) + { + r = ProcessEvent(event, isFiltered); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +LinkedListT <_IUiEventListener*>* +_UiEventManager::GetEventListeners(_UiEventType eventType, bool postListener) const +{ + LinkedListT <_IUiEventListener*>* pEventListeners = null; + + if (postListener) + { + __pPostEventListenerMap->GetValue(eventType, pEventListeners); + } + else + { + result r = E_SUCCESS; + + r = __pEventListenerMap->GetValue(eventType, pEventListeners); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pEventListeners; +} + +result +_UiEventManager::ProcessListener(const _UiEvent& event, bool& isFiltered) +{ + return ProcessListener(event, false, isFiltered); +} + +result +_UiEventManager::ProcessPostListener(const _UiEvent& event, bool& isFiltered) +{ + return ProcessListener(event, true, isFiltered); +} + +result +_UiEventManager::ProcessListener(const _UiEvent& event, bool postListener, bool& isFiltered) +{ + result r = E_SUCCESS; + + LinkedListT <_IUiEventListener*>* pEventListeners = GetEventListeners(event.GetEventType(), postListener); + if (pEventListeners) + { + Tizen::Base::Collection::IEnumeratorT <_IUiEventListener*>* pEnumerator = pEventListeners->GetEnumeratorN(); + SysTryReturn(NID_UI, pEnumerator, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + _IUiEventListener* pEventListener = null; + + pEnumerator->GetCurrent(pEventListener); + if (!pEventListener) + { + continue; + } + + r = const_cast<_UiEvent&>(event).ProcessListener(*pEventListener, isFiltered); + if (isFiltered) + { + break; + } + } + + delete pEnumerator; + } + + return r; +} + +result +_UiEventManager::ProcessEvent(const _UiEvent& event, bool& isFiltered) +{ + result r = E_SUCCESS; + + switch (event.GetRouteType()) + { + case _UI_EVENT_ROUTE_TUNNEL_BUBBLE: + { + LinkedListT <_UiObjectHandle> tunnelingPath; + LinkedListT <_UiObjectHandle> bubblingPath; + + r = MakeRoutingPath(tunnelingPath, bubblingPath, event); + + if (r == E_SUCCESS) + { + ProcessTunnelingEvent(tunnelingPath, event, isFiltered); + + if (event.GetEventType() == _UI_EVENT_TOUCH) + { + ProcessBubblingEvent(bubblingPath, event, isFiltered); + } + else if (!isFiltered) + { + ProcessBubblingEvent(bubblingPath, event, isFiltered); + } + } + } + break; + + case _UI_EVENT_ROUTE_DIRECT: + { + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + const _Control* pTarget = pControlManager->GetObject(event.GetDestination()); + if (pTarget) + { + r = const_cast<_UiEvent&>(event).ProcessEvent(*pTarget, isFiltered); + } + } + break; + + default: + break; + } + + return r; +} + +result +_UiEventManager::ProcessGlobalGesture(const _UiEvent& event, bool& isFiltered) +{ + if (event.GetEventType() != _UI_EVENT_TOUCH) + { + return E_SUCCESS; + } + + if (event.GetAccessibilityEvent()) + { + return E_SUCCESS; + } + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturn(NID_UI, pTouchManager, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + Tizen::Base::Collection::IListT<_TouchGestureDetector*>* pGestureList = pControlManager->GetGestureDetectorList(); + if (!pGestureList || (pGestureList && (pGestureList->GetCount() <= 0))) + { + return E_SUCCESS; + } + + result r = E_SUCCESS; + + Tizen::Base::Collection::IEnumeratorT <_TouchGestureDetector*>* pEnumerator = pGestureList->GetEnumeratorN(); + SysTryReturn(NID_UI, pEnumerator, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _TouchGestureDetector* pGestureDetector = null; + while (pEnumerator->MoveNext() == E_SUCCESS) + { + pEnumerator->GetCurrent(pGestureDetector); + + if (!pGestureDetector) + { + continue; + } + + r = const_cast<_UiEvent&>(event).ProcessListener(*pGestureDetector, isFiltered); + if (isFiltered) + { + break; + } + } + + delete pEnumerator; + + return r; +} + +result +_UiEventManager::MakeRoutingPath(Tizen::Base::Collection::LinkedListT <_UiObjectHandle>& tunnelingPath, Tizen::Base::Collection::LinkedListT <_UiObjectHandle>& bubblingPath, const _UiEvent& event) +{ + result r = E_SUCCESS; + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _Control* pControl = pControlManager->GetObject(event.GetDestination()); + SysTryReturn(NID_UI, pControl, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + // Bubbling path + _Control* pBubblingTarget = pControl; + while (pBubblingTarget) + { + bubblingPath.Add(pBubblingTarget->GetHandle()); + pBubblingTarget = pBubblingTarget->GetParent(); + } + + // Tunneling path + for (int i = bubblingPath.GetCount() - 1; i > 0; i--) + { + _UiObjectHandle uiObjectHandle; + + r = bubblingPath.GetAt(i, uiObjectHandle); + if (r == E_SUCCESS) + { + tunnelingPath.Add(uiObjectHandle); + } + } + + return r; +} + +result +_UiEventManager::ProcessTunnelingEvent(const Tizen::Base::Collection::LinkedListT <_UiObjectHandle>& routingPath, const _UiEvent& event, bool& isFiltered) +{ + result r = E_SUCCESS; + + Tizen::Base::Collection::IEnumeratorT <_UiObjectHandle>* pEnumerator = routingPath.GetEnumeratorN(); + SysTryReturn(NID_UI, pEnumerator, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _UiObjectHandle uiObjectHandle; + while (pEnumerator->MoveNext() == E_SUCCESS) + { + pEnumerator->GetCurrent(uiObjectHandle); + if (uiObjectHandle.IsNull()) + { + continue; + } + + const _Control* pControl = event.GetControl(uiObjectHandle); + if (!pControl) + { + continue; + } + + r = const_cast<_UiEvent&>(event).ProcessPreviewEvent(*pControl, isFiltered); + if (isFiltered) + { + r = E_SUCCESS; + break; + } + } + + delete pEnumerator; + + return r; +} + +result +_UiEventManager::ProcessBubblingEvent(const Tizen::Base::Collection::LinkedListT <_UiObjectHandle>& routingPath, const _UiEvent& event, bool& isFiltered) +{ + result r = E_SUCCESS; + + Tizen::Base::Collection::IEnumeratorT <_UiObjectHandle>* pEnumerator = routingPath.GetEnumeratorN(); + SysTryReturn(NID_UI, pEnumerator, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _UiObjectHandle uiObjectHandle; + while (pEnumerator->MoveNext() == E_SUCCESS) + { + pEnumerator->GetCurrent(uiObjectHandle); + if (uiObjectHandle.IsNull()) + { + continue; + } + + const _Control* pControl = event.GetControl(uiObjectHandle); + if (!pControl) + { + continue; + } + + r = const_cast<_UiEvent&>(event).ProcessEvent(*pControl, isFiltered); + + if (!isFiltered && (event.GetDestination() == uiObjectHandle)) + { + ProcessPostListener(event, isFiltered); + } + } + + delete pEnumerator; + + return r; +} + +_UiObjectHandle +_UiEventManager::GetTarget(void) const +{ + _Control* pControl = _ControlManager::GetInstance()->GetFocusedControl(); + SysTryReturn(NID_UI, pControl, _UiObjectHandle(), E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return pControl->GetHandle(); +} + +_UiObjectHandle +_UiEventManager::GetTarget(int x, int y) const +{ + Tizen::Graphics::FloatPoint ptf((float) x, (float) y); + +#if !defined(MULTI_WINDOW) + _ControlVisualElement* pRootControlElement = + dynamic_cast <_ControlVisualElement*>(_ControlManager::GetInstance()->GetRoot().GetVisualElement()); +#else + _ControlVisualElement* pRootControlElement = + dynamic_cast <_ControlVisualElement*>(_ControlManager::GetInstance()->GetTopVisibleWindowAt(Point(x, y))->GetVisualElement()); +#endif + SysTryReturn(NID_UI, pRootControlElement, _UiObjectHandle(), E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _ControlVisualElement* pControlVisualElement = pRootControlElement->GetControlChildAtPoint(ptf); + SysTryReturn(NID_UI, pControlVisualElement, _UiObjectHandle(), E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _Control* pControl = static_cast <_Control*>(pControlVisualElement->GetUserData()); + SysTryReturn(NID_UI, pControl, _UiObjectHandle(), E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return pControl->GetHandle(); +} + +void +_UiEventManager::SetKeyCapture(const _Control& control, _KeyCode keyCode) +{ + __pEventManager->SetKeyCapture(control, keyCode); + + _KeyEventManager* pKeyEventManager = _KeyEventManager::GetInstance(); + SysAssert(pKeyEventManager != null); + + pKeyEventManager->SetCapturingControl(control, keyCode, true); +} + +void +_UiEventManager::ReleaseKeyCapture(const _Control& control, _KeyCode keyCode) +{ + __pEventManager->ReleaseKeyCapture(control, keyCode); + + _KeyEventManager* pKeyEventManager = _KeyEventManager::GetInstance(); + SysAssert(pKeyEventManager != null); + + pKeyEventManager->SetCapturingControl(control, keyCode, false); +} + +void +_UiEventManager::RemoveAllEventListenerList(Tizen::Base::Collection::HashMapT<_UiEventType, Tizen::Base::Collection::LinkedListT<_IUiEventListener*>*>* pMap) +{ + Tizen::Base::Collection::IMapEnumeratorT<_UiEventType, Tizen::Base::Collection::LinkedListT<_IUiEventListener*>*>* pMapEnumerator = pMap->GetMapEnumeratorN(); + SysTryReturnVoidResult(NID_UI, pMapEnumerator, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + while (pMapEnumerator->MoveNext() == E_SUCCESS) + { + Tizen::Base::Collection::LinkedListT<_IUiEventListener*>* pListeners = null; + pMapEnumerator->GetValue(pListeners); + + if (!pListeners) + { + continue; + } + + delete pListeners; + } + + delete pMapEnumerator; +} + +_UiEventManager::_UiEventManager(void) + : __pEventManager(new (std::nothrow) _EflUiEventManager) +{ + unique_ptr*> > pEventListenerMap(new (std::nothrow) HashMapT<_UiEventType, LinkedListT<_IUiEventListener*>*>); + SysTryReturnVoidResult(NID_UI, pEventListenerMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = pEventListenerMap->Construct(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Touch + LinkedListT<_IUiEventListener*>* pTouchEventListeners = new (std::nothrow) LinkedListT<_IUiEventListener*>; + SysTryReturnVoidResult(NID_UI, pTouchEventListeners, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = pEventListenerMap->Add(_UI_EVENT_TOUCH, pTouchEventListeners); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Key + LinkedListT<_IUiEventListener*>* pKeyEventListeners = new (std::nothrow) LinkedListT<_IUiEventListener*>; + SysTryReturnVoidResult(NID_UI, pKeyEventListeners, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = pEventListenerMap->Add(_UI_EVENT_KEY, pKeyEventListeners); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Focus + LinkedListT<_IUiEventListener*>* pFocusEventListeners = new (std::nothrow) LinkedListT<_IUiEventListener*>; + SysTryReturnVoidResult(NID_UI, pFocusEventListeners, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = pEventListenerMap->Add(_UI_EVENT_FOCUS, pFocusEventListeners); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Notification + LinkedListT <_IUiEventListener*>* pNotificationEventListeners = new (std::nothrow) LinkedListT<_IUiEventListener*>; + SysTryReturnVoidResult(NID_UI, pNotificationEventListeners, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = pEventListenerMap->Add(_UI_EVENT_NOTIFICAITON, pNotificationEventListeners); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + // post + unique_ptr*> > pPostEventListenerMap(new (std::nothrow) HashMapT<_UiEventType, LinkedListT<_IUiEventListener*>*>); + SysTryReturnVoidResult(NID_UI, pPostEventListenerMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = pPostEventListenerMap->Construct(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Key + LinkedListT<_IUiEventListener*>* pPostKeyEventListeners = new (std::nothrow) LinkedListT<_IUiEventListener*>; + SysTryReturnVoidResult(NID_UI, pPostKeyEventListeners, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = pPostEventListenerMap->Add(_UI_EVENT_KEY, pPostKeyEventListeners); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + // move pointer + __pEventListenerMap = move(pEventListenerMap); + __pPostEventListenerMap = move(pPostEventListenerMap); +} + +_UiEventManager::~_UiEventManager(void) +{ + RemoveAllEventListenerList(__pEventListenerMap.get()); + RemoveAllEventListenerList(__pPostEventListenerMap.get()); +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_UiFocusEvent.cpp b/src/ui/FUi_UiFocusEvent.cpp new file mode 100644 index 0000000..275da4f --- /dev/null +++ b/src/ui/FUi_UiFocusEvent.cpp @@ -0,0 +1,139 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiFocusEvent.cpp + * @brief This is the implementation file for _UiFocusEvent class. + */ + +#include +#include +#include "FUi_UiFocusEvent.h" +#include "FUi_IFocusEventListener.h" +#include "FUi_Control.h" + +namespace Tizen { namespace Ui +{ + +_UiFocusEvent::_UiFocusEvent(const _UiObjectHandle& destination, FocusStatus focusState, _UiEventRouteType routeType, const _UiObjectHandle& source) + : _UiEvent(destination, source, routeType) + , __focusState(focusState) +{ +} + +_UiFocusEvent::~_UiFocusEvent(void) +{ +} + +_UiFocusEvent::_UiFocusEvent(const _UiFocusEvent& rhs) + : _UiEvent(rhs) + , __focusState(rhs.__focusState) +{ +} + +_UiFocusEvent& +_UiFocusEvent::operator =(const _UiFocusEvent& rhs) +{ + _UiEvent::operator =(rhs); + + if (this != &rhs) + { + __focusState = rhs.__focusState; + } + + return *this; +} + +FocusStatus +_UiFocusEvent::GetFocusState(void) const +{ + return __focusState; +} + +_UiFocusEvent* +_UiFocusEvent::CloneN(void) const +{ + return new (std::nothrow) _UiFocusEvent(*this); +} + +_UiEventType +_UiFocusEvent::GetEventType(void) const +{ + return _UI_EVENT_FOCUS; +} + +result +_UiFocusEvent::OnPreviewEventProcessing(const _Control& control, bool& isFiltered) +{ + return E_SUCCESS; +} + +result +_UiFocusEvent::OnEventProcessing(const _Control& control, bool& isFiltered) +{ + _IFocusEventListener* pFocusListener = control.GetEventListener<_UI_EVENT_FOCUS, _IFocusEventListener*>(); + SysTryReturn(NID_UI, pFocusListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return FireListener(pFocusListener, isFiltered); +} + +result +_UiFocusEvent::OnListenerProcessing(const _IUiEventListener& listener, bool& isFiltered) +{ + if (isFiltered) + { + return E_SUCCESS; + } + + _IFocusEventListener* pFocusListener = dynamic_cast <_IFocusEventListener*>(const_cast <_IUiEventListener*>(&listener)); + SysTryReturn(NID_UI, pFocusListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return FireListener(pFocusListener, isFiltered); +} + +result +_UiFocusEvent::FireListener(const _IFocusEventListener* pListener, bool& isFiltered) +{ + SysTryReturn(NID_UI, pListener, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + result r = E_SUCCESS; + + _IFocusEventListener* pFocusListener = const_cast <_IFocusEventListener*>(pListener); + SysTryReturn(NID_UI, pFocusListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + const _Control* pTarget = GetControl(GetDestination()); + SysTryReturn(NID_UI, pTarget, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + // call a listener method by the key state + switch (GetFocusState()) + { + case FOCUS_GAINED: + isFiltered = pFocusListener->OnFocusGained(*pTarget); + break; + + case FOCUS_LOST: + isFiltered = pFocusListener->OnFocusLost(*pTarget); + break; + + default: + //SysLogI(NID_UI, "unable to determine the key event type."); + r = E_SYSTEM; + break; + } + + return r; +} +}}//Tizen::Ui diff --git a/src/ui/FUi_UiKeyEvent.cpp b/src/ui/FUi_UiKeyEvent.cpp new file mode 100644 index 0000000..bf81c4d --- /dev/null +++ b/src/ui/FUi_UiKeyEvent.cpp @@ -0,0 +1,303 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiKeyEvent.cpp + * @brief This is the implementation file for the _UiKeyEvent class. + */ + +#include +#include +#include "FUi_UiKeyEvent.h" +#include "FUi_IKeyEventListener.h" +#include "FUi_IKeyEventPreviewer.h" +#include "FUi_Control.h" +#include "FUi_ControlImpl.h" + +namespace Tizen { namespace Ui +{ + +_KeyInfo::_KeyInfo(KeyState keyState, _KeyCode keyCode, int keyModifier, void* pUserData) + : __keyState(keyState) + , __keyCode(keyCode) + , __keyModifier(keyModifier) + , __pUserData(pUserData) +{ +} + +_KeyInfo::_KeyInfo(const _KeyInfo& rhs) + : __keyState(rhs.__keyState) + , __keyCode(rhs.__keyCode) + , __keyModifier(rhs.__keyModifier) + , __pUserData(rhs.__pUserData) +{ +} + +_KeyInfo& +_KeyInfo::operator =(const _KeyInfo& rhs) +{ + if (this != &rhs) + { + __keyState = rhs.__keyState; + __keyCode = rhs.__keyCode; + __keyModifier = rhs.__keyModifier; + __pUserData = rhs.__pUserData; + } + + return *this; +} + +_KeyInfo::~_KeyInfo(void) +{ +} + +void +_KeyInfo::SetKeyState(KeyState keyState) +{ + __keyState = keyState; +} + +KeyState +_KeyInfo::GetKeyState(void) const +{ + return __keyState; +} + +void +_KeyInfo::SetKeyCode(_KeyCode keyCode) +{ + __keyCode = keyCode; +} + +_KeyCode +_KeyInfo::GetKeyCode(void) const +{ + return __keyCode; +} + +void +_KeyInfo::SetKeyModifier(int keyModifier) +{ + __keyModifier = keyModifier; +} + +int +_KeyInfo::GetKeyModifier(void) const +{ + return __keyModifier; +} + +void +_KeyInfo::SetUserData(void* pUserData) +{ + __pUserData = pUserData; +} + +void* +_KeyInfo::GetUserData(void) const +{ + return __pUserData; +} + +_UiKeyEvent::_UiKeyEvent(const _UiObjectHandle& destination, const _KeyInfo& keyInfo, _UiEventRouteType routeType, const _UiObjectHandle& source) + : _UiEvent(destination, source, routeType) + , __keyInfo(keyInfo) +{ +} + +_UiKeyEvent::~_UiKeyEvent(void) +{ +} + +_UiKeyEvent::_UiKeyEvent(const _UiKeyEvent& rhs) + : _UiEvent(rhs) + , __keyInfo(rhs.__keyInfo) +{ +} + +_UiKeyEvent& +_UiKeyEvent::operator =(const _UiKeyEvent& rhs) +{ + _UiEvent::operator =(rhs); + + if (this != &rhs) + { + __keyInfo = rhs.__keyInfo; + } + + return *this; +} + +const _KeyInfo* +_UiKeyEvent::GetKeyInfo(void) const +{ + return &__keyInfo; +} + +_UiKeyEvent* +_UiKeyEvent::CloneN(void) const +{ + return new (std::nothrow) _UiKeyEvent(*this); +} + +_UiEventType +_UiKeyEvent::GetEventType(void) const +{ + return _UI_EVENT_KEY; +} + +void +_UiKeyEvent::SetKeyState(const KeyState keyState) +{ + __keyInfo.SetKeyState(keyState); +} + +KeyState +_UiKeyEvent::GetKeyState(void) const +{ + return __keyInfo.GetKeyState(); +} + +void +_UiKeyEvent::SetKeyCode(const _KeyCode keyCode) +{ + __keyInfo.SetKeyCode(keyCode); +} + +_KeyCode +_UiKeyEvent::GetKeyCode(void) const +{ + return __keyInfo.GetKeyCode(); +} + +void +_UiKeyEvent::SetKeyModifier(int keyModifier) +{ + __keyInfo.SetKeyModifier(keyModifier); +} + +int +_UiKeyEvent::GetKeyModifier(void) const +{ + return __keyInfo.GetKeyModifier(); +} + +result +_UiKeyEvent::OnPreviewEventProcessing(const _Control& control, bool& isFiltered) +{ + result r = E_SUCCESS; + + if (!control.IsInputEnabled()) + { + return E_SUCCESS; + } + + _IKeyEventPreviewer* pKeyEventPreviewer = control.GetEventPreviewer<_UI_EVENT_KEY, _IKeyEventPreviewer*>(); + SysTryReturn(NID_UI, pKeyEventPreviewer, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + const _Control* pTarget = GetControl(GetDestination()); + SysTryReturn(NID_UI, pTarget, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + // call a listener method by the key state + switch (GetKeyState()) + { + case KEY_PRESSED: + { + isFiltered = pKeyEventPreviewer->OnPreviewKeyPressed(*pTarget, __keyInfo); + } + break; + + case KEY_RELEASED: + { + isFiltered = pKeyEventPreviewer->OnPreviewKeyReleased(*pTarget, __keyInfo); + } + break; + + default: + //SysLogI(NID_UI, "unable to determine the key event type."); + r = E_SYSTEM; + break; + } + + return r; +} + +result +_UiKeyEvent::OnEventProcessing(const _Control& control, bool& isFiltered) +{ + if (isFiltered) + { + return E_SUCCESS; + } + + _IKeyEventListener* pKeyEventListener = control.GetPropagatedKeyEventListener(); + SysTryReturn(NID_UI, pKeyEventListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return FireListener(pKeyEventListener, isFiltered); +} + +result +_UiKeyEvent::OnListenerProcessing(const _IUiEventListener& listener, bool& isFiltered) +{ + _IKeyEventListener* pKeyEventListener = dynamic_cast <_IKeyEventListener*>(const_cast <_IUiEventListener*>(&listener)); + SysTryReturn(NID_UI, pKeyEventListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return FireListener(pKeyEventListener, isFiltered); +} + +result +_UiKeyEvent::FireListener(const _IKeyEventListener* pListener, bool& isFiltered) +{ + _IKeyEventListener* pKeyEventListener = const_cast <_IKeyEventListener*>(pListener); + SysTryReturn(NID_UI, pKeyEventListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + result r = E_SUCCESS; + + const _Control* pTarget = GetControl(GetDestination()); + SysTryReturn(NID_UI, pTarget, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + // call a listener method by the key state + switch (GetKeyState()) + { + case KEY_PRESSED: + isFiltered = pKeyEventListener->OnKeyPressed(*pTarget, __keyInfo); + break; + + case KEY_RELEASED: + isFiltered = pKeyEventListener->OnKeyReleased(*pTarget, __keyInfo); + break; + + // 2.0 compatibility for key simulate + case KEY_LONGPRESSED: + { + _ControlImpl* pTargetImpl = static_cast<_ControlImpl*>(pTarget->GetUserData()); + if (pTargetImpl) + { + pTargetImpl->GenerateKeyEvent(KEY_LONGPRESSED, GetKeyCode()); + } + } + break; + + default: + //SysLogI(NID_UI, "unable to determine the key event type."); + r = E_SYSTEM; + break; + } + + return r; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_UiNotificationEvent.cpp b/src/ui/FUi_UiNotificationEvent.cpp new file mode 100644 index 0000000..b24c3e4 --- /dev/null +++ b/src/ui/FUi_UiNotificationEvent.cpp @@ -0,0 +1,140 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiNotificationEvent.cpp + * @brief This is the implementation file for the _UiNotificationEvent class. + */ + +#include +#include +#include "FUi_UiNotificationEvent.h" +#include "FUi_INotificationEventListener.h" +#include "FUi_INotificationEventPreviewer.h" +#include "FUi_Control.h" + +namespace Tizen { namespace Ui +{ + +_UiNotificationEvent::_UiNotificationEvent(const _UiObjectHandle& destination, Tizen::Base::Collection::IList* pArgs, _UiEventRouteType routeType, const _UiObjectHandle& source) + : _UiEvent(destination, source, routeType) + , __pArgs(pArgs) +{ +} + +_UiNotificationEvent::~_UiNotificationEvent(void) +{ +} + +_UiNotificationEvent::_UiNotificationEvent(const _UiNotificationEvent& rhs) + : _UiEvent(rhs) + , __pArgs(rhs.__pArgs) +{ +} + +_UiNotificationEvent& +_UiNotificationEvent::operator =(const _UiNotificationEvent& rhs) +{ + _UiEvent::operator =(rhs); + + if (this != &rhs) + { + __pArgs = rhs.__pArgs; + } + + return *this; +} + +Tizen::Base::Collection::IList* +_UiNotificationEvent::GetArgs(void) const +{ + return __pArgs; +} + +_UiNotificationEvent* +_UiNotificationEvent::CloneN(void) const +{ + return new (std::nothrow) _UiNotificationEvent(*this); +} + +_UiEventType +_UiNotificationEvent::GetEventType(void) const +{ + return _UI_EVENT_NOTIFICAITON; +} + +bool +_UiNotificationEvent::IsEventReceivable(const _Control& control) const +{ + return true; +} + +result +_UiNotificationEvent::OnPreviewEventProcessing(const _Control& control, bool& isFiltered) +{ + result r = E_SUCCESS; + + _INotificationEventPreviewer* pNotificationPreviewer = control.GetEventPreviewer<_UI_EVENT_NOTIFICAITON, _INotificationEventPreviewer*>(); + SysTryReturn(NID_UI, pNotificationPreviewer, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + const _Control* pTarget = GetControl(GetDestination()); + SysTryReturn(NID_UI, pTarget, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + isFiltered = pNotificationPreviewer->OnPreviewNotifiedN(*pTarget, GetArgs()); + + return r; +} + +result +_UiNotificationEvent::OnEventProcessing(const _Control& control, bool& isFiltered) +{ + if (isFiltered) + { + return E_SUCCESS; + } + + _INotificationEventListener* pNotificationListener = control.GetEventListener<_UI_EVENT_NOTIFICAITON, _INotificationEventListener*>(); + SysTryReturn(NID_UI, pNotificationListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return FireListener(pNotificationListener, isFiltered); +} + +result +_UiNotificationEvent::OnListenerProcessing(const _IUiEventListener& listener, bool& isFiltered) +{ + _INotificationEventListener* pNotificationListener = dynamic_cast <_INotificationEventListener*>(const_cast <_IUiEventListener*>(&listener)); + SysTryReturn(NID_UI, pNotificationListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return FireListener(pNotificationListener, isFiltered); +} + +result +_UiNotificationEvent::FireListener(const _INotificationEventListener* pListener, bool& isFiltered) +{ + result r = E_SUCCESS; + + _INotificationEventListener* pNotificationListener = const_cast <_INotificationEventListener*>(pListener); + SysTryReturn(NID_UI, pNotificationListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + const _Control* pTarget = GetControl(GetDestination()); + SysTryReturn(NID_UI, pTarget, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + isFiltered = pNotificationListener->OnNotifiedN(*pTarget, GetArgs()); + + return r; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_UiTouchEvent.cpp b/src/ui/FUi_UiTouchEvent.cpp new file mode 100644 index 0000000..70153f5 --- /dev/null +++ b/src/ui/FUi_UiTouchEvent.cpp @@ -0,0 +1,541 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiTouchEvent.cpp + * @brief This is the implementation file for the _UiTouchEvent class. + */ + +#include +#include +#include +#include "FUi_UiTouchEvent.h" +#include "FUi_ITouchEventListener.h" +#include "FUi_ITouchEventPreviewer.h" +#include "FUi_Control.h" +#include "FUi_ControlManager.h" +#include "FUi_TouchGestureDetector.h" +#include "FUi_TouchManager.h" +#include "FUi_ITouchGestureDelegate.h" +#include "FUi_ControlImpl.h" +#include "FUi_TouchEventArg.h" + +using namespace std::tr1; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ +_TouchInfo::_TouchInfo(void) + : __pointId(0) + , __touchStatus(_TOUCH_PRESSED) + , __currentPosition(0, 0) + , __isFlicked(false) + , __timeStamp(0) +{ +} + +_TouchInfo::_TouchInfo(unsigned long pointId, _TouchStatus status, const Tizen::Graphics::Point& current, const bool isFlick, long long timeStamp) + : __pointId(pointId) + , __touchStatus(status) + , __currentPosition(current) + , __isFlicked(isFlick) + , __timeStamp(timeStamp) +{ +} + +_TouchInfo::_TouchInfo(const _TouchInfo& rhs) + : __pointId(rhs.__pointId) + , __touchStatus(rhs.__touchStatus) + , __currentPosition(rhs.__currentPosition) + , __isFlicked(rhs.__isFlicked) + , __timeStamp(rhs.__timeStamp) +{ +} + +_TouchInfo& +_TouchInfo::operator =(const _TouchInfo& rhs) +{ + if (this != &rhs) + { + __pointId = rhs.__pointId; + __touchStatus = rhs.__touchStatus; + __currentPosition = rhs.__currentPosition; + __isFlicked = rhs.__isFlicked; + __timeStamp = rhs.__timeStamp; + } + + return *this; +} + +_TouchInfo::~_TouchInfo(void) +{ +} + +_TouchStatus +_TouchInfo::GetTouchStatus(void) const +{ + return __touchStatus; +} + +Tizen::Graphics::Point +_TouchInfo::GetCurrentPosition(void) const +{ + return __currentPosition; +} + +unsigned long +_TouchInfo::GetPointId(void) const +{ + return __pointId; +} + +bool +_TouchInfo::IsFlicked(void) const +{ + return __isFlicked; +} + +long long +_TouchInfo::GetTimeStamp(void) const +{ + return __timeStamp; +} + +void +_TouchInfo::SetTouchInfo(unsigned long pointId, _TouchStatus status, Tizen::Graphics::Point& current, bool isFlick, long long timeStamp) +{ + __pointId = pointId; + __touchStatus = status; + __currentPosition = current; + __isFlicked = isFlick; + __timeStamp = timeStamp; +} + +_UiTouchEvent::_UiTouchEvent(const _UiObjectHandle& destination, const _TouchInfo& touchInfo, _UiEventRouteType routeType, const _UiObjectHandle& source) + : _UiEvent(destination, source, routeType) + , __touchInfo(touchInfo) + , __pForcedGestureList(new (std::nothrow) LinkedListT<_Control*>) +{ +} + +_UiTouchEvent::~_UiTouchEvent(void) +{ +} + +_UiTouchEvent::_UiTouchEvent(const _UiTouchEvent& rhs) + : _UiEvent(rhs) + , __touchInfo(rhs.__touchInfo) + , __pForcedGestureList(rhs.__pForcedGestureList) +{ +} + +_UiTouchEvent& +_UiTouchEvent::operator =(const _UiTouchEvent& rhs) +{ + _UiEvent::operator =(rhs); + + if (this != &rhs) + { + __touchInfo = rhs.__touchInfo; + __pForcedGestureList = rhs.__pForcedGestureList; + } + + return *this; +} + +const _TouchInfo* +_UiTouchEvent::GetTouchInfo(void) const +{ + return &__touchInfo; +} + +_UiTouchEvent* +_UiTouchEvent::CloneN(void) const +{ + return new (std::nothrow) _UiTouchEvent(*this); +} + +_UiEventType +_UiTouchEvent::GetEventType(void) const +{ + return _UI_EVENT_TOUCH; +} + +result +_UiTouchEvent::OnPreviewEventProcessing(const _Control& control, bool& isFiltered) +{ + result r = E_SUCCESS; + + const _TouchInfo* pTouchInfo = GetTouchInfo(); + SysTryReturn(NID_UI, pTouchInfo, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + if (!control.IsInputEnabled() && pTouchInfo->GetTouchStatus() != _TOUCH_CANCELED) + { + return E_SUCCESS; + } + + if ((!ExistGlobalGesture() || GetAccessibilityEvent()) && !isFiltered) + { + _ITouchEventPreviewer* pTouchEventPreviewer = control.GetEventPreviewer<_UI_EVENT_TOUCH, _ITouchEventPreviewer*>(); + SysTryReturn(NID_UI, pTouchEventPreviewer, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + r = FirePreviewListener(pTouchEventPreviewer, &control, isFiltered); + } + + return r; +} + +result +_UiTouchEvent::OnEventProcessing(const _Control& control, bool& isFiltered) +{ + result r = E_SUCCESS; + + bool doesControlExist = false; + + const _TouchInfo* pTouchInfo = GetTouchInfo(); + SysTryReturn(NID_UI, pTouchInfo, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + if (!control.IsInputEnabled() && pTouchInfo->GetTouchStatus() != _TOUCH_CANCELED) + { + return E_SUCCESS; + } + + if ((!ExistGlobalGesture() || GetAccessibilityEvent()) && !isFiltered) + { + ProcessGesture(control, isFiltered); + } + else if (isFiltered) + { + doesControlExist = __pForcedGestureList->Contains(const_cast<_Control*>(&control)); + + if (doesControlExist) + { + bool isForcedFiltered = false; + ProcessGesture(control, isForcedFiltered); + + if (isForcedFiltered) + { + isFiltered = true; + } + } + } + + if ((!ExistGlobalGesture() || GetAccessibilityEvent()) && !isFiltered) + { + _ITouchEventListener* pTouchEventListener = control.GetPropagatedTouchEventListener(); + SysTryReturn(NID_UI, pTouchEventListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + r = FireListener(pTouchEventListener, &control, true, isFiltered); + } + + return r; +} + +result +_UiTouchEvent::OnListenerProcessing(const _IUiEventListener& listener, bool& isFiltered) +{ + _ITouchEventListener* pTouchEventListener = dynamic_cast <_ITouchEventListener*>(const_cast <_IUiEventListener*>(&listener)); + SysTryReturn(NID_UI, pTouchEventListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + return FireListener(pTouchEventListener, null, true, isFiltered); +} + +result +_UiTouchEvent::OnEventHandled(const _Control& control) +{ + _Control* pTarget = const_cast<_Control*>(GetControl(GetDestination())); + SysTryReturn(NID_UI, pTarget, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + const _TouchInfo* pTouchInfo = GetTouchInfo(); + SysTryReturn(NID_UI, pTouchInfo, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + result r = E_SUCCESS; + + switch (pTouchInfo->GetTouchStatus()) + { + case _TOUCH_PRESSED: + pTarget->GetPropagatedTouchEventListener()->OnTouchPressHandled(control); + break; + + case _TOUCH_MOVED: + pTarget->GetPropagatedTouchEventListener()->OnTouchMoveHandled(control); + break; + + case _TOUCH_RELEASED: + pTarget->GetPropagatedTouchEventListener()->OnTouchReleaseHandled(control); + break; + + case _TOUCH_CANCELED: + pTarget->GetPropagatedTouchEventListener()->OnTouchCancelHandled(control); + break; + + default: + r = E_SYSTEM; + break; + } + + return r; +} + +result +_UiTouchEvent::FireListener(const _ITouchEventListener* pListener, const _Control* pControl, bool isTouchEvent, bool& isFiltered) +{ + _ITouchEventListener* pTouchEventListener = const_cast <_ITouchEventListener*>(pListener); + SysTryReturn(NID_UI, pTouchEventListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + result r = E_SUCCESS; + + const _TouchInfo* pTouchInfo = GetTouchInfo(); + SysTryReturn(NID_UI, pTouchInfo, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + const _Control* pTarget = GetControl(GetOriginalDestination()); + if (pTarget == null) + { + SysLog(NID_UI, "pTarget == null, Call ResetTouchInfo."); + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + pTouchManager->ResetTouchInfo(); + + return E_SUCCESS; + +} + + if (ResetTouchInfo(pTarget, *pTouchInfo) == E_SUCCESS) + { + isFiltered = true; + return E_SYSTEM; + } + + Point point(0, 0); + + if (pControl) + { + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysAssert(pTouchManager != null) + + point = GetRelativePoint(*pControl, pTouchInfo->GetCurrentPosition()); + + if (isTouchEvent && (pTouchInfo->GetTouchStatus() != _TOUCH_CANCELED)) + { + if (!pTouchManager->IsTouchAllowed() || (pTouchManager->IsTouchAllowed() && pTouchManager->IsTouchCanceledOnGestureSuccess()) + || (!pControl->IsMultiTouchEnabled() && pTouchInfo->GetPointId() > 0)) + { + isFiltered = true; + return E_SUCCESS; + } + } + } + else + { + point = GetRelativePoint(*pTarget, pTouchInfo->GetCurrentPosition()); + } + + _TouchInfo touchInfo(pTouchInfo->GetPointId(), pTouchInfo->GetTouchStatus(), point, false, pTouchInfo->GetTimeStamp()); + + switch (touchInfo.GetTouchStatus()) + { + case _TOUCH_PRESSED: + isFiltered = pTouchEventListener->OnTouchPressed(*pTarget, touchInfo); + break; + + case _TOUCH_RELEASED: + isFiltered = pTouchEventListener->OnTouchReleased(*pTarget, touchInfo); + break; + + case _TOUCH_MOVED: + isFiltered = pTouchEventListener->OnTouchMoved(*pTarget, touchInfo); + break; + + // 2.0 compatibility for touch simulate + case _TOUCH_LONG_PRESSED: + // fall through + case _TOUCH_DOUBLE_PRESSED: + { + void* pData = pTarget->GetUserData(); + if (pData) + { + _ControlImpl* pTargetImpl = static_cast<_ControlImpl*>(pData); + if (pTargetImpl) + { + pTargetImpl->GenerateTouchEvent(touchInfo); + } + } + } + break; + + case _TOUCH_CANCELED: + isFiltered = pTouchEventListener->OnTouchCanceled(*pTarget, touchInfo); + break; + + default: + r = E_SYSTEM; + } + + return r; +} + +result +_UiTouchEvent::FirePreviewListener(const _ITouchEventPreviewer* pListener, const _Control* pControl, bool& isFiltered) +{ + _ITouchEventPreviewer* pTouchEventPreviewer = const_cast <_ITouchEventPreviewer*>(pListener); + SysTryReturn(NID_UI, pTouchEventPreviewer, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + result r = E_SUCCESS; + + const _TouchInfo* pTouchInfo = GetTouchInfo(); + SysTryReturn(NID_UI, pTouchInfo, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + const _Control* pTarget = GetControl(GetDestination()); + + Point point = GetRelativePoint(*pControl, pTouchInfo->GetCurrentPosition()); + + _TouchInfo touchInfo(pTouchInfo->GetPointId(), pTouchInfo->GetTouchStatus(), point, false, pTouchInfo->GetTimeStamp()); + + _UiTouchEventDelivery eventDelivery = _UI_TOUCH_EVENT_DELIVERY_NO; + + //condition 1) if target is not enabled multi touch, point id should be 0 + //2) target is enabled multi touch + switch (touchInfo.GetTouchStatus()) + { + case _TOUCH_PRESSED: + eventDelivery = pTouchEventPreviewer->OnPreviewTouchPressed(*pTarget, touchInfo); + + break; + + case _TOUCH_RELEASED: + eventDelivery = pTouchEventPreviewer->OnPreviewTouchReleased(*pTarget, touchInfo); + + break; + + case _TOUCH_MOVED: + eventDelivery = pTouchEventPreviewer->OnPreviewTouchMoved(*pTarget, touchInfo); + + break; + + case _TOUCH_CANCELED: + eventDelivery = pTouchEventPreviewer->OnPreviewTouchCanceled(*pTarget, touchInfo); + break; + + default: + r = E_SYSTEM; + break; + } + + if (eventDelivery != _UI_TOUCH_EVENT_DELIVERY_NO) + { + // isFiltered = (eventDelivery == _UI_TOUCH_EVENT_DELIVERY_FORCED_YES); + + // if (isFiltered) + if (eventDelivery == _UI_TOUCH_EVENT_DELIVERY_FORCED_YES) + { + __pForcedGestureList->Add(const_cast<_Control*>(pControl)); + } + } + else + { + isFiltered = true; + } + + return r; +} + +result +_UiTouchEvent::ProcessGesture(const _Control& control, bool& isFiltered) +{ + if (control.IsSendingDelayedEvent()) + { + return E_SUCCESS; + } + + IListT<_TouchGestureDetector*>* pGestureList = control.GetGestureDetectorList(); + if (!pGestureList || (pGestureList && (pGestureList->GetCount() <= 0))) + { + return E_SUCCESS; + } + + IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pGestureList->GetEnumeratorN(); + SysTryReturn(NID_UI, pEnumerator, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + while (pEnumerator->MoveNext() == E_SUCCESS) + { + _TouchGestureDetector* pGestureDetector = null; + pEnumerator->GetCurrent(pGestureDetector); + + if (!pGestureDetector) + { + continue; + } + + _ITouchGestureDelegate* pDelegator = pGestureDetector->GetDelegate(); + if (pDelegator) + { + FireListener(pDelegator, &control, false, isFiltered); + } + } + + delete pEnumerator; + return E_SUCCESS; +} + +Point +_UiTouchEvent::GetRelativePoint(const _Control& control, const Point& point) const +{ + Point relativePoint(point); + Rectangle absRect = control.GetAbsoluteBounds(); + + relativePoint.x -= absRect.x; + relativePoint.y -= absRect.y; + + return relativePoint; +} + +result +_UiTouchEvent::ResetTouchInfo(const _Control* pControl, const _TouchInfo& touchInfo) +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturnResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] System error occurred. "); + + if (pControl == null) + { + if (touchInfo.GetTouchStatus() == _TOUCH_RELEASED) + { + pTouchManager->ResetTouchInfo(); + } + + return E_SUCCESS; + } + + return E_INVALID_CONDITION; +} + +bool +_UiTouchEvent::ExistGlobalGesture(void) +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI, pControlManager, false, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + bool exist = false; + + IListT<_TouchGestureDetector*>* pGestureList = pControlManager->GetGestureDetectorList(); + if (pGestureList && (pGestureList->GetCount() > 0)) + { + exist = true; + } + + return exist; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_VariantImpl.cpp b/src/ui/FUi_VariantImpl.cpp new file mode 100644 index 0000000..323dbc3 --- /dev/null +++ b/src/ui/FUi_VariantImpl.cpp @@ -0,0 +1,308 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_VariantImpl.cpp + * @brief This is the implementation file for _VariantImpl class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_VariantImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui +{ + +_VariantImpl::_VariantImpl(void) + : __refCount(1) + , __type(VARIANT_TYPE_NONE) +{ + __data.valueLongLong = 0; +} + +_VariantImpl::~_VariantImpl(void) +{ + Clear(); +} + +void +_VariantImpl::AddRef(void) +{ + __refCount++; +} + +void +_VariantImpl::Release(void) +{ + if (__refCount >= 1) + { + __refCount--; + if (__refCount == 0) + { + delete this; + } + } +} + +void +_VariantImpl::Clear(void) +{ + if (unlikely(__type == VARIANT_TYPE_NONE)) + { + __data.valueDouble = 0; + return; + } + + switch (__type) + { + case VARIANT_TYPE_NONE: + return; + + case VARIANT_TYPE_INT: + __data.valueInt = 0; + break; + + case VARIANT_TYPE_UINT: + __data.valueUInt = 0; + break; + + case VARIANT_TYPE_BOOL: + __data.valueBool = false; + break; + + case VARIANT_TYPE_FLOAT: + __data.valueFloat = 0; + break; + + case VARIANT_TYPE_DOUBLE: + __data.valueDouble = 0; + break; + + case VARIANT_TYPE_LONG: + __data.valueLong = 0; + break; + + case VARIANT_TYPE_ULONG: + __data.valueULong = 0; + break; + + case VARIANT_TYPE_LONGLONG: + __data.valueLongLong = 0; + break; + + case VARIANT_TYPE_ULONGLONG: + __data.valueULongLong = 0; + break; + + case VARIANT_TYPE_STRING: + { + delete __data.pString; + __data.pString = null; + break; + } + + case VARIANT_TYPE_DATETIME: + { + delete __data.pDateTime; + __data.pDateTime = null; + break; + } + + case VARIANT_TYPE_COLOR: + { + delete __data.pColor; + __data.pColor = null; + break; + } + + case VARIANT_TYPE_POINT: + { + delete __data.pPoint; + __data.pPoint = null; + break; + } + + case VARIANT_TYPE_FLOAT_POINT: + { + delete __data.pFloatPoint; + __data.pFloatPoint = null; + break; + } + + case VARIANT_TYPE_RECTANGLE: + { + delete __data.pRect; + __data.pRect = null; + break; + } + + case VARIANT_TYPE_FLOAT_RECTANGLE: + { + delete __data.pRectf; + __data.pRectf = null; + break; + } + + case VARIANT_TYPE_DIMENSION: + { + delete __data.pDimension; + __data.pDimension = null; + break; + } + + case VARIANT_TYPE_FLOAT_DIMENSION: + { + delete __data.pFloatDimension; + __data.pFloatDimension = null; + break; + } + + case VARIANT_TYPE_FLOAT_MATRIX4: + { + delete __data.pFloatMatrix4; + __data.pFloatMatrix4 = null; + break; + } + + default: + break; + } + + __type = VARIANT_TYPE_NONE; +} + +void +_VariantImpl::Copy(const Variant& rhs) +{ + const _VariantImpl* pImpl = rhs.GetVariantImpl(); + __type = pImpl->__type; + + switch (pImpl->__type) + { + case VARIANT_TYPE_NONE: + break; + + case VARIANT_TYPE_INT: + __data.valueInt = pImpl->__data.valueInt; + break; + + case VARIANT_TYPE_UINT: + __data.valueUInt = pImpl->__data.valueUInt; + break; + + case VARIANT_TYPE_BOOL: + __data.valueBool = pImpl->__data.valueBool; + break; + + case VARIANT_TYPE_FLOAT: + __data.valueFloat = pImpl->__data.valueFloat; + break; + + case VARIANT_TYPE_DOUBLE: + __data.valueDouble = pImpl->__data.valueDouble; + break; + + case VARIANT_TYPE_LONG: + __data.valueLong = pImpl->__data.valueLong; + break; + + case VARIANT_TYPE_ULONG: + __data.valueULong = pImpl->__data.valueULong; + break; + + case VARIANT_TYPE_LONGLONG: + __data.valueLongLong = pImpl->__data.valueLongLong; + break; + + case VARIANT_TYPE_ULONGLONG: + __data.valueULongLong = pImpl->__data.valueULongLong; + break; + + case VARIANT_TYPE_STRING: + __data.pString = new (std::nothrow) String(*pImpl->__data.pString); + break; + + case VARIANT_TYPE_DATETIME: + __data.pDateTime = new (std::nothrow) DateTime(*pImpl->__data.pDateTime); + break; + + case VARIANT_TYPE_COLOR: + __data.pColor = new (std::nothrow) Color(*pImpl->__data.pColor); + break; + + case VARIANT_TYPE_POINT: + __data.pPoint = new (std::nothrow) Point(*pImpl->__data.pPoint); + break; + + case VARIANT_TYPE_FLOAT_POINT: + __data.pFloatPoint = new (std::nothrow) FloatPoint(*pImpl->__data.pFloatPoint); + break; + + case VARIANT_TYPE_RECTANGLE: + __data.pRect = new (std::nothrow) Rectangle(*pImpl->__data.pRect); + break; + + case VARIANT_TYPE_FLOAT_RECTANGLE: + __data.pRectf = new (std::nothrow) FloatRectangle(*pImpl->__data.pRectf); + break; + + case VARIANT_TYPE_DIMENSION: + __data.pDimension = new (std::nothrow) Dimension(*pImpl->__data.pDimension); + break; + + case VARIANT_TYPE_FLOAT_DIMENSION: + __data.pFloatDimension = new (std::nothrow) FloatDimension(*pImpl->__data.pFloatDimension); + break; + + case VARIANT_TYPE_FLOAT_MATRIX4: + __data.pFloatMatrix4 = new (std::nothrow) FloatMatrix4(*pImpl->__data.pFloatMatrix4); + break; + + default: + break; + } +} + +void +_VariantImpl::SetVariantType(VariantType type) +{ + if (__type != type) + { + __type = type; + } +} + +bool +_VariantImpl::IsSameType(VariantType type) const +{ + return(__type == type); +} + +} } // Tizen::Ui diff --git a/src/ui/FUi_VerticalBoxLayoutImpl.cpp b/src/ui/FUi_VerticalBoxLayoutImpl.cpp new file mode 100644 index 0000000..1d2885a --- /dev/null +++ b/src/ui/FUi_VerticalBoxLayoutImpl.cpp @@ -0,0 +1,274 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_VerticalBoxLayoutImpl.cpp + * @brief This is the implementation file for _VerticalBoxLayoutImpl class. + * + * This file contains the implementation of _VerticalBoxLayoutImpl class. + */ + +#include "FUi_VerticalBoxLayoutImpl.h" + +namespace Tizen { namespace Ui +{ + +namespace +{ +static const int CONVERT_ERROR_CODE = -1; + +_Layout::LinearLayoutDirection +ConvertEnum(VerticalDirection val) +{ + switch (val) + { + case VERTICAL_DIRECTION_DOWNWARD: + return _Layout::LINEAR_TOP_TO_BOTTOM; + + case VERTICAL_DIRECTION_UPWARD: + return _Layout::LINEAR_BOTTOM_TO_TOP; + + default: + return _Layout::LINEAR_NONE_DIRECTION; + } +} + +VerticalDirection +ConvertEnum(_Layout::LinearLayoutDirection val) +{ + switch (val) + { + case _Layout::LINEAR_TOP_TO_BOTTOM: + return VERTICAL_DIRECTION_DOWNWARD; + + case _Layout::LINEAR_BOTTOM_TO_TOP: + return VERTICAL_DIRECTION_UPWARD; + + default: + return static_cast (CONVERT_ERROR_CODE); + } +} +} + +// _VerticalBoxLayoutImpl implementation +_VerticalBoxLayoutImpl::_VerticalBoxLayoutImpl(VerticalBoxLayout* pPublicLayout, _Layout::LinearLayout* pCoreLayout) + : _LayoutImpl(pPublicLayout, pCoreLayout) +{ +} + +_VerticalBoxLayoutImpl::~_VerticalBoxLayoutImpl() +{ +} + +Tizen::Ui::LayoutType +_VerticalBoxLayoutImpl::GetLayoutType(void) const +{ + return LAYOUT_VERTICAL_BOX; +} + +result +_VerticalBoxLayoutImpl::Construct(VerticalDirection direction) +{ + ClearLastResult(); + + _Layout::LinearLayoutDirection linearDirection = ConvertEnum(direction); + SysTryReturn(NID_UI, linearDirection != _Layout::LINEAR_NONE_DIRECTION, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid data."); + + result r = GetCore().Initialize(_Layout::LINEAR_VERTICAL, linearDirection); + + return r; +} + +result +_VerticalBoxLayoutImpl::GetDirection(VerticalDirection& direction) const +{ + ClearLastResult(); + + _Layout::LinearLayoutDirection internalDirection; + result r = E_SUCCESS; + + r = GetCore().GetDirection(internalDirection); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + direction = ConvertEnum(internalDirection); + + return r; +} + +result +_VerticalBoxLayoutImpl::SetHorizontalAlignment(_ControlImpl& control, LayoutHorizontalAlignment horAlign) +{ + result r = SetAlignment(control, horAlign, LAYOUT_VERTICAL_ALIGN_TOP); + + return r; +} + +result +_VerticalBoxLayoutImpl::SetSpacing(_ControlImpl& control, int space) +{ + ClearLastResult(); + + _Layout::LayoutItem& layoutItem = control.GetLayoutContainer(); + + result r = GetCore().SetItemSpacing(layoutItem, space); + + return r; +} + +result +_VerticalBoxLayoutImpl::SetHorizontalMargin(_ControlImpl& control, int left, int right) +{ + result r = SetMargin(control, left, right, 0, 0); + + return r; +} + +result +_VerticalBoxLayoutImpl::SetWidth(_ControlImpl& control, int width) +{ + ClearLastResult(); + + result r = SetHorizontalFitPolicy(control, FIT_POLICY_FIXED); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Layout::LayoutRect rect; + r = GetItemBaseRect(control, rect); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + rect.w = width; + r = SetItemBaseRect(control, rect); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_VerticalBoxLayoutImpl::SetItemHorizontalFitPolicy(_ControlImpl& control, FitPolicy policy) +{ + result r = SetHorizontalFitPolicy(control, policy); + + return r; +} + +result +_VerticalBoxLayoutImpl::SetHeight(_ControlImpl& control, int height) +{ + ClearLastResult(); + + result r = SetVerticalFitPolicy(control, FIT_POLICY_FIXED); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Layout::LayoutRect rect; + r = GetItemBaseRect(control, rect); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + rect.h = height; + r = SetItemBaseRect(control, rect); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_VerticalBoxLayoutImpl::SetItemVerticalFitPolicy(_ControlImpl& control, FitPolicy policy) +{ + result r = SetVerticalFitPolicy(control, policy); + + return r; +} + +result +_VerticalBoxLayoutImpl::SetWeight(_ControlImpl& control, float weight) +{ + ClearLastResult(); + + _Layout::LayoutItem& layoutItem = control.GetLayoutContainer(); + + result r = GetCore().SetItemWeight(layoutItem, weight); + + return r; +} + +_VerticalBoxLayoutImpl* +_VerticalBoxLayoutImpl::CreateVerticalBoxLayoutImplN(VerticalBoxLayout* pPublicLayout, VerticalDirection direction) +{ + ClearLastResult(); + + _Layout::LinearLayout* pCoreLayout = null; + _VerticalBoxLayoutImpl* pImplLayout = null; + result r = E_SUCCESS; + + pCoreLayout = _Layout::LinearLayout::CreateLinearLayoutN(); + r = GetLastResult(); + SysTryReturn(NID_UI, pCoreLayout != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImplLayout = new (std::nothrow) _VerticalBoxLayoutImpl(pPublicLayout, pCoreLayout); + r = CheckConstruction(pCoreLayout, pImplLayout); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImplLayout->Construct(direction); + if (r != E_SUCCESS) + { + delete pImplLayout; + SysTryReturn(NID_UI, false, null, E_INVALID_ARG, "[E_INVALID_ARG] The Direction is invalid."); + } + + return pImplLayout; +} + +const char* +_VerticalBoxLayoutImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::VerticalBoxLayout"; +} + +const VerticalBoxLayout& +_VerticalBoxLayoutImpl::GetPublic(void) const +{ + return static_cast (_LayoutImpl::GetPublic()); +} + +VerticalBoxLayout& +_VerticalBoxLayoutImpl::GetPublic(void) +{ + return static_cast (_LayoutImpl::GetPublic()); +} + +const _Layout::LinearLayout& +_VerticalBoxLayoutImpl::GetCore(void) const +{ + return static_cast (_LayoutImpl::GetCore()); +} + +_Layout::LinearLayout& +_VerticalBoxLayoutImpl::GetCore(void) +{ + return static_cast <_Layout::LinearLayout&>(_LayoutImpl::GetCore()); +} + +const _VerticalBoxLayoutImpl* +_VerticalBoxLayoutImpl::GetInstance(const VerticalBoxLayout& layout) +{ + return static_cast(_LayoutImpl::GetInstance(layout)); +} + +_VerticalBoxLayoutImpl* +_VerticalBoxLayoutImpl::GetInstance(VerticalBoxLayout& layout) +{ + return static_cast<_VerticalBoxLayoutImpl*>(_LayoutImpl::GetInstance(layout)); +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_VerticalBoxLayoutImpl.h b/src/ui/FUi_VerticalBoxLayoutImpl.h new file mode 100644 index 0000000..de016c5 --- /dev/null +++ b/src/ui/FUi_VerticalBoxLayoutImpl.h @@ -0,0 +1,278 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_VerticalBoxLayoutImpl.h + * @brief This is the header file for _VerticalBoxLayoutImpl class. + * + * This header file contains the declaration of _VerticalBoxLayoutImpl class. + */ + +#ifndef _FUI_INTERNAL_VERTICAL_BOX_LAYOUT_IMPL_H +#define _FUI_INTERNAL_VERTICAL_BOX_LAYOUT_IMPL_H + +#include +#include "FUi_LayoutImpl.h" +#include "FUi_LayoutLinearLayout.h" + +namespace Tizen { namespace Ui +{ + +class VerticalBoxLayout; + +class _VerticalBoxLayoutImpl + : public _LayoutImpl +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_VerticalBoxLayoutImpl(void); + + /** + * Creates the instance of _VerticalBoxLayoutImpl. + * + * @since 2.0 + * @return The instance of _VerticalBoxLayoutImpl. + * @param[in] pPublicLayout The public class of vertical box layout. + * @param[in] direction The direction of vertical box layout. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + static _VerticalBoxLayoutImpl* CreateVerticalBoxLayoutImplN(VerticalBoxLayout* pPublicLayout, VerticalDirection direction = VERTICAL_DIRECTION_DOWNWARD); + + /** + * Gets the name of public class. + * + * @since 2.0 + * @return The name of public class. + */ + virtual const char* GetPublicClassName(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual const VerticalBoxLayout& GetPublic(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual VerticalBoxLayout& GetPublic(void); + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual const _Layout::LinearLayout& GetCore(void) const; + + /** + * Gets the public class. + * + * @since 2.0 + * @return The public class. + */ + virtual _Layout::LinearLayout& GetCore(void); + + /** + * Gets the _VerticalBoxLayoutImpl instance for the VerticalBoxLayout. + * + * @since 2.0 + * @return The _VerticalBoxLayoutImpl instance. + * @param[in] pLayout The VerticalBoxLayout instance. + */ + static const _VerticalBoxLayoutImpl* GetInstance(const VerticalBoxLayout& layout); + + /** + * Gets the _VerticalBoxLayoutImpl instance for the VerticalBoxLayout. + * + * @since 2.0 + * @return The _VerticalBoxLayoutImpl instance. + * @param[in] pLayout The VerticalBoxLayout instance. + */ + static _VerticalBoxLayoutImpl* GetInstance(VerticalBoxLayout& layout); + + /** + * Gets the direction of the VerticalBoxLayout. + * + * @since 2.0 + * @return An error code + * @param[out] direction The direction in which the children are attached + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result GetDirection(VerticalDirection& direction) const; + + /** + * Sets the horizontal alignment of the specified control. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the alignment is set + * @param[in] alignment The horizontal alignment + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The alignment parameter is invalid. + */ + result SetHorizontalAlignment(_ControlImpl& control, LayoutHorizontalAlignment horAlign); + + /** + * Sets the space between the specified control and its predecessor. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the space is set + * @param[in] space The space + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetSpacing(_ControlImpl& control, int space); + + /** + * Sets the horizontal margins of the specified control. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the margins are set + * @param[in] top The top margin + * @param[in] bottom The bottom margin + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetHorizontalMargin(_ControlImpl& control, int left, int right); + + /** + * Sets the width of the specified control with the fixed length. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the width is set + * @param[in] virWidth This is not used. + * @param[in] phyWidth The value of the width + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetWidth(_ControlImpl& control, int width); + + /** + * Sets the width of the specified control with the fitting policy. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the width is set + * @param[in] policy The fitting policy for the width + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetItemHorizontalFitPolicy(_ControlImpl& control, FitPolicy policy); + + /** + * Sets the height of the specified control with fixed length. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the height is set + * @param[in] virHeight This is not used. + * @param[in] phyHeight The value of the height + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetHeight(_ControlImpl& control, int height); + + /** + * Sets the height of the specified control with the fitting policy. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the height is set + * @param[in] policy The fitting policy for the height + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetItemVerticalFitPolicy(_ControlImpl& control, FitPolicy policy); + + /** + * Sets the weight of the specified control. + * + * @since 2.0 + * @return An error code + * @param[in] control The control for which the weight is set + * @param[in] weight The weight that indicates how much extra space the control occupies + * in proportion to it, in the HorizontalBoxLayout. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetWeight(_ControlImpl& control, float weight); + + /** + * Gets the type of the layout. + * + * @since 2.0 + * @return The layout type + */ + virtual LayoutType GetLayoutType(void) const; + +protected: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _VerticalBoxLayoutImpl(VerticalBoxLayout* pPublicLayout, _Layout::LinearLayout* pCoreLayout); + +private: + /** + * This is the copy constructor for this class. + * + * @since 2.0 + */ + _VerticalBoxLayoutImpl(const _VerticalBoxLayoutImpl&); + + /** + * This is the substitution operator for this class. + * + * @since 2.0 + */ + _VerticalBoxLayoutImpl& operator =(const _VerticalBoxLayoutImpl&); + + /** + * Initializes this instance of _VerticalBoxLayoutImpl with the specified parameters. + * + * @since 2.0 + * @return An error code + * @param[in] direction The direction of vertical box layout. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result Construct(VerticalDirection direction); +}; // _VerticalBoxLayoutImpl + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_VERTICAL_BOX_LAYOUT_IMPL_H diff --git a/src/ui/FUi_Window.cpp b/src/ui/FUi_Window.cpp new file mode 100644 index 0000000..bd482ee --- /dev/null +++ b/src/ui/FUi_Window.cpp @@ -0,0 +1,636 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_Window.cpp + * @brief This is the implementation file for the _Window class. + */ + +#include +#include +#include +#include +#include "FUi_Window.h" +#include "FUi_ControlManager.h" +#include "FUi_TouchManager.h" +#include "FUiAnim_DisplayContextImpl.h" +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_VisualElement.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EcoreEvas.h" +#if defined(MULTI_WINDOW) +#include "FUiAnim_DisplayManager.h" +#include "FUiAnim_EflLayer.h" +#endif + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui +{ + +_Window* +_Window::CreateWindowN(void) +{ + _Window* pWindow = new (std::nothrow) _Window; + SysTryReturn(NID_UI, pWindow, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + +#if defined(MULTI_WINDOW) + result r = E_SUCCESS; +#endif + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + +#if defined(MULTI_WINDOW) + r = pWindow->CreateRootVisualElement(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); +#endif + + pWindow->AcquireHandle(); + + return pWindow; + +CATCH: + delete pWindow; + return null; +} + +_Window::~_Window(void) +{ + __destroying = true; + Close(); + SetOwner(null); + + if (__pDisplayContext) + { + _DisplayContextImpl::DestroyPublicInstance(*__pDisplayContext); + __pDisplayContext = null; + } + +#if defined(MULTI_WINDOW) + + if(__pLayer) + { +// Detach. + if(__pRootVisualElement) + { + __pRootVisualElement->DetachChild(*GetVisualElement()); + } + delete __pLayer; + __pLayer = NULL; + } + __pRootVisualElement =NULL; + + +#endif +} + +_IWindowDelegate& +_Window::GetWindowDelegate(void) const +{ + if (__destroying) + { + return const_cast<_Window&>(*this); + } + + SysAssert(__pWindowDelegate); + return *__pWindowDelegate; +} + +String +_Window::GetDescription(void) const +{ + String description = _Control::GetDescription(); + String descriptionTemp(L""); + + descriptionTemp.Format(LOG_LEN_MAX, L"_Window: owner(0x%x) delegate(0x%x) activated(%d) destroying(%d) displayContext(0x%x)", + __pOwner, __pWindowDelegate, __activated, __destroying, __pDisplayContext); + + description.Append(descriptionTemp); + + return description; +} + +#if defined(MULTI_WINDOW) +void +_Window::SetRootVisualElement(const Tizen::Ui::Animations::_RootVisualElement& rootVisualElement) +{ + _RootVisualElement* pRootVE = const_cast<_RootVisualElement*>(&rootVisualElement); + + __pRootVisualElement = pRootVE; +} +#endif + +bool +_Window::IsActivatedOnOpen(void) const +{ + return true; +} + +bool +_Window::IsActivated(void) const +{ + return __activated; +} + +void +_Window::SetWindowDelegate(_IWindowDelegate& delegate) +{ + ClearLastResult(); + __pWindowDelegate = &delegate; +} + +void +_Window::ResetWindowDelegate(void) +{ + ClearLastResult(); + __pWindowDelegate = this; +} + +bool +_Window::IsAttached(void) const +{ + return _ControlManager::GetInstance()->IsWindowAttached(*this); +} + +result +_Window::Open(bool drawAndShow) +{ + bool visibleState = GetVisibleState(); + if (!__isOpened && visibleState) + { + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + pEcoreEvas->SetWindowVisibleState(*GetRootWindow(), visibleState); + __isOpened = true; + __isInitialized = true; + return _ControlManager::GetInstance()->OpenWindow(*this, drawAndShow); + } + + return E_SUCCESS; +} + +void +_Window::Close(void) +{ + if (__isOpened) + { + bool visibleState = GetVisibleState(); + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + pEcoreEvas->SetWindowVisibleState(*GetRootWindow(), visibleState); + + _ControlManager::GetInstance()->CloseWindow(*this); + __isOpened = false; + } +} + +_Control* +_Window::GetOwner(void) const +{ + ClearLastResult(); + return __pOwner; +} + +void +_Window::SetOwner(_Control* pOwner) +{ + ClearLastResult(); + + if (pOwner == __pOwner) + { + return; + } + + if (__pOwner) + { + __pOwner->DetachOwnee(*this); + __pOwner = null; + } + + if (pOwner) + { + pOwner->AttachOwnee(*this); + __pOwner = pOwner; + +#if defined(MULTI_WINDOW) + GetEcoreEvasMgr()->GetEcoreEvas()->SetOwner(*this, *pOwner); +#endif + } +} + +#if defined(MULTI_WINDOW) +result +_Window::CreateRootVisualElement(void) +{ + result r = CreateLayer(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLayer = GetRootVisualElement()->GetNativeLayer(); + + // Get visual element. + _VisualElement* pVisualElement = GetVisualElement(); + SysAssert(pVisualElement); + + pVisualElement->SetName(L"Window"); + pVisualElement->SetClipChildrenEnabled(false); + pVisualElement->SetRenderOperation(_VisualElement::RENDER_OPERATION_COPY); + + // Attach visual element to root visual element. + __pRootVisualElement->AttachChild(*GetVisualElement()); + + return E_SUCCESS; +} + +result +_Window::CreateLayer(void) +{ + _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); + SysAssert(pDisplayManager); + + __pLayer = _NativeLayer::CreateInstanceN(); + SysAssert(__pLayer); + __pRootVisualElement = __pLayer->GetRootVisualElement(); + + _EflLayer* pLayer = static_cast<_EflLayer*>(__pLayer); + SysAssert(pLayer); + + int rootWindowW = 0; + int rootWindowH = 0; + ecore_x_window_size_get(ecore_x_window_root_get((Ecore_X_Window)ecore_evas_window_get(pLayer->GetEcoreEvas())), &rootWindowW, &rootWindowH); + + pLayer->SetBounds(FloatRectangle(0.0f, 0.0f, (float)rootWindowW, (float)rootWindowH)); + pLayer->SetOpacity(0); + + __pRootVisualElement->SetName(L"Root"); + + return E_SUCCESS; +} +#endif + +bool +_Window::IsFocusableDescendant(const _Control* pFocus) const +{ + return true; +} + +#if defined(MULTI_WINDOW) +void +_Window::SetActivationEnabled(bool enable) +{ + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pEcoreEvas->SetWindowActivationEnabled(*GetRootWindow(), enable); + + SetLastResult(E_SUCCESS); +} + +bool +_Window::IsActivationEnabled(void) +{ + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, true, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + bool enable = pEcoreEvas->IsWindowActivationEnabled(*GetRootWindow()); + + SetLastResult(E_SUCCESS); + + return enable; +} + +_RootVisualElement* +_Window::GetRootVisualElement(void) const +{ + return __pRootVisualElement; +} +#else +_RootVisualElement* +_Window::GetRootVisualElement(void) const +{ + return __pRootVisualElement; +} +#endif + +NativeWindowHandle +_Window::GetNativeHandle(void) const +{ +#if defined(MULTI_WINDOW) + _RootVisualElement* pRootVE = GetRootVisualElement(); + SysAssert(pRootVE); + + _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer()); + SysAssert(pLayer); + + Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas(); + Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas); +#else + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysAssert(pEcoreEvas); + + Ecore_X_Window win = pEcoreEvas->GetXWindow(); +#endif + + return win; +} + +void +_Window::OnActivated(void) +{ + bool isFrameActivated = _ControlManager::GetInstance()->IsFrameActivated(); + SysLog(NID_UI, "frameActivated(%d)", isFrameActivated); + + if (!isFrameActivated) + { + return; + } + + _Control* pFocus = GetFocused(); + if (pFocus) + { + pFocus->SetFocused(); + } + else + { + SetFocused(); + } + + _TouchManager* pTouchMgr = _TouchManager::GetInstance(); + if (pTouchMgr) + { + pTouchMgr->SetTouchCanceled(true); + } +} + +void +_Window::OnNativeWindowActivated(void) +{ + +} + +bool +_Window::OnNotifiedN(const _Control& source, IList* pArgs) +{ + SysTryReturn(NID_UI_CTRL, pArgs, false, E_SYSTEM, "[E_SYSTEM] pArgs is null.") + + String* pType = dynamic_cast (pArgs->GetAt(0)); + SysTryReturn(NID_UI_CTRL, pType, false, E_SYSTEM, "[E_SYSTEM] pType is null.") + + if (*pType == L"VisibilityEvent") + { + int obscured = 0; + + Integer* pObscured = dynamic_cast(pArgs->GetAt(1)); + if (pObscured == null) + { + pArgs->RemoveAll(true); + delete pArgs; + + return true; + } + + obscured = pObscured->ToInt(); + if (obscured == 0) + { + GetWindowDelegate().OnNativeWindowActivated(); + } + + pArgs->RemoveAll(true); + delete pArgs; + + return true; + } + + return false; +} + +void +_Window::OnDeactivated(void) +{ + bool isFrameActivated = _ControlManager::GetInstance()->IsFrameActivated(); + SysLog(NID_UI, "frameActivated(%d)", isFrameActivated); +} + +#if !defined(MULTI_WINDOW) + +void +_Window::OnVisibleStateChanged(void) +{ + bool visibleState = GetVisibleState(); + if (visibleState == true) + { + Open(false); + } + else + { + Close(); + } +} + +#endif + +#if defined(MULTI_WINDOW) +result +_Window::OnBoundsChanging(const Rectangle& bounds) +{ + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds); + result r = GetLastResult(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +_Window::OnVisibleStateChanged(void) +{ + ClearLastResult(); + + bool visibleState = GetVisibleState(); + if (visibleState == false) + { + Close(); + } + + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} + +result +_Window::OnAttachingToMainTree(const _Control* pParent) +{ + _EflLayer* pLayer = static_cast<_EflLayer*>(__pRootVisualElement->GetNativeLayer()); + SysAssert(pLayer); + SetVisibleState(true); + pLayer->SetShowState(true); + + return E_SUCCESS; +} + +result +_Window::OnDetachingFromMainTree(void) +{ + _EflLayer* pLayer = static_cast<_EflLayer*>(__pRootVisualElement->GetNativeLayer()); + SysAssert(pLayer); + pLayer->SetShowState(false); + + return E_SUCCESS; +} + +bool +_Window::IsLayoutChangable(void) const +{ + return false; +} +#endif + +void +_Window::OnChangeLayout(_ControlOrientation orientation) +{ + SysLog(NID_UI, "[Test] _Window::OnChangeLayout()"); + + // if window, change its size specially for full-screen(Form, Frame, etc.). + _Control::OnChangeLayout(orientation); // if called, layout will be changed. +} + +WindowState +_Window::GetWindowState(void) const +{ + ClearLastResult(); + return __windowState; +} + +void +_Window::SetWindowState(WindowState windowState) +{ + __windowState = windowState; +} + +DisplayContext* +_Window::GetDisplayContext(void) const +{ + if (!__pDisplayContext) + { + SysTryReturn(NID_UI, __pLayer, null, E_SYSTEM, "[E_SYSTEM] Cannot gain the DisplayContext. This window is not completed."); + + __pDisplayContext = _DisplayContextImpl::CreatePublicInstance(*__pLayer); + } + + result r = GetLastResult(); + SysTryReturn(NID_UI, __pDisplayContext, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pDisplayContext; +} + +result +_Window::SetZOrderGroup(int windowZOrderGroup) +{ + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysAssert(pEcoreEvas); + + _WindowLevel windowLevel = _WINDOW_LEVEL_NORMAL; + switch (windowZOrderGroup) + { + case WINDOW_Z_ORDER_GROUP_HIGHEST: + windowLevel = _WINDOW_LEVEL_NOTIFICATION_HIGH; + break; + case WINDOW_Z_ORDER_GROUP_HIGH: + windowLevel = _WINDOW_LEVEL_NOTIFICATION_MIDDLE; + break; + default: + break; + } + +#if !defined(MULTI_WINDOW) + pEcoreEvas->SetWindowLevel(windowLevel); +#else + pEcoreEvas->SetWindowLevel(*GetRootWindow(), windowLevel); +#endif + + return E_SUCCESS; +} + +_Window::_Window() + : __windowState(WINDOW_STATE_INITIALIZED) + , __pOwner(null) + , __pWindowDelegate(null) + , __activated(false) + , __destroying(false) + , __pRootVisualElement(null) + , __pLayer(null) + , __pDisplayContext(null) + , __systemWindow(false) + , __isOpened(false) + , __isInitialized(false) +{ + SetControlDelegate(*this); + SetWindowDelegate(*this); + SetClipToParent(false); // [ToDo] exception check. +#if !defined(MULTI_WINDOW) + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysAssert(pEcoreEvas); + __pRootVisualElement = pEcoreEvas->GetRootVisualElement(); + SysAssert(__pRootVisualElement); + __pLayer = __pRootVisualElement->GetNativeLayer(); + SysAssert(__pLayer); +#endif +} + +void +_Window::Activate(void) +{ + if (__activated) + { + return; + } + + __activated = true; + GetWindowDelegate().OnActivated(); +} + +void +_Window::Deactivate(void) +{ + __activated = false; + + if (__destroying == false) + { + GetWindowDelegate().OnDeactivated(); + } +} + +void +_Window::SetSystemWindow(bool systemWindow) +{ + __systemWindow = systemWindow; +} + +bool +_Window::IsSystemWindow(void) const +{ + return __systemWindow; +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_WindowImpl.cpp b/src/ui/FUi_WindowImpl.cpp new file mode 100644 index 0000000..7570237 --- /dev/null +++ b/src/ui/FUi_WindowImpl.cpp @@ -0,0 +1,387 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_WindowImpl.cpp + * @brief This is the implementation file for the _WindowImpl class. + */ + +#include +#include +#include +#include "FUi_WindowImpl.h" +#include "FUi_Window.h" +#include "FUi_ErrorMessages.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; + + +namespace Tizen { namespace Ui +{ + +class _WindowImpl::WindowImplDelegate + : public _IWindowDelegate +{ +public: + WindowImplDelegate(_WindowImpl& impl) + : __impl(impl) + , __core(impl.GetCore()) + , __public(impl.GetPublic()) + { + } + + virtual void OnActivated(void) + { + IEnumeratorT * pEnumerator = __impl.__pPublicWindowEventListeners->GetEnumeratorN(); + // 1. public + while (pEnumerator->MoveNext() == E_SUCCESS) + { + Runtime::IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + IWindowEventListener* pWindowEventListener = dynamic_cast (pListener); + if (!pWindowEventListener) + { + continue; + } + + pWindowEventListener->OnWindowActivated(__public); + } + delete pEnumerator; + + // 2. self + __impl.SetWindowState(WINDOW_STATE_ACTIVATED); + + // 3. Impl + __impl.OnActivated(); + + // 4. Core + __core.OnActivated(); + } + + virtual void OnNativeWindowActivated(void) + { + __impl.OnNativeWindowActivated(); + __core.OnNativeWindowActivated(); + } + + virtual void OnDeactivated(void) + { + IEnumeratorT * pEnumerator = __impl.__pPublicWindowEventListeners->GetEnumeratorN(); + + // 1. public + while (pEnumerator->MoveNext() == E_SUCCESS) + { + Runtime::IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + IWindowEventListener* pWindowEventListener = dynamic_cast (pListener); + if (!pWindowEventListener) + { + continue; + } + + pWindowEventListener->OnWindowDeactivated(__public); + } + delete pEnumerator; + + // 2. self + __impl.SetWindowState(WINDOW_STATE_DEACTIVATED); + + // 3. Impl + __impl.OnDeactivated(); + + // 4. Core + __core.OnDeactivated(); + } + +private: + WindowImplDelegate(const WindowImplDelegate& rhs); + WindowImplDelegate& operator =(const WindowImplDelegate& rhs); + +private: + _WindowImpl& __impl; + _Window& __core; + Window& __public; +}; // WindowImplDelegate + + +WindowState +_WindowImpl::GetErrorWindowState(void) +{ + return WINDOW_STATE_INITIALIZED; // [ToDo] Not good choice. But no option. +} + +_WindowImpl* +_WindowImpl::GetInstance(Window& window) +{ + return static_cast <_WindowImpl*> (window._pControlImpl); +} + +const _WindowImpl* +_WindowImpl::GetInstance(const Window& window) +{ + return static_cast (window._pControlImpl); +} + +_WindowImpl* +_WindowImpl::CreateWindowImplN(Window* pPublic, const Rectangle& bounds, + const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, + bool resizable, bool movable) +{ + result r = E_SUCCESS; + + _Window* pCore = _Window::CreateWindowN(); + SysTryReturn(NID_UI, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + _WindowImpl* pImpl = + new (std::nothrow) _WindowImpl(pPublic, pCore, bounds, + pPublicPortraitLayout, pPublicLandscapeLayout, + resizable, movable); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + ClearLastResult(); + + return pImpl; +} + +_WindowImpl::~_WindowImpl(void) +{ + _WindowImpl::GetCore().ResetWindowDelegate(); + + delete __pImplDelegate; + __pImplDelegate = null; + + Close(); + + delete __pPublicWindowEventListeners; + __pPublicWindowEventListeners = null; +} + +const char* +_WindowImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Window"; +} + +const Window& +_WindowImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +Window& +_WindowImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Window& +_WindowImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Window& +_WindowImpl::GetCore(void) +{ + return static_cast <_Window&>(_ControlImpl::GetCore()); +} + +void +_WindowImpl::AddWindowEventListener(Tizen::Ui::IWindowEventListener& listener) +{ + ClearLastResult(); + SysTryReturnVoidResult(NID_UI, + __pPublicWindowEventListeners->Add(&listener) == E_SUCCESS, + E_SYSTEM, _UiError::SYSTEM); +} + +void +_WindowImpl::RemoveWindowEventListener(Tizen::Ui::IWindowEventListener& listener) +{ + ClearLastResult(); + SysTryReturnVoidResult(NID_UI, + __pPublicWindowEventListeners->Remove(&listener) == E_SUCCESS, + E_SYSTEM, _UiError::SYSTEM); +} + +void +_WindowImpl::OnActivated(void) +{ + +} + +void +_WindowImpl::OnNativeWindowActivated(void) +{ + +} + +void +_WindowImpl::OnDeactivated(void) +{ + +} + +#if !defined(MULTI_WINDOW) +void +_WindowImpl::Rotate(_ControlRotation rotation) +{ + +} + +#else +result +_WindowImpl::OnBoundsChanging(const Rectangle& bounds) +{ + result r = E_SUCCESS; + r = _ControlImpl::OnBoundsChanging(bounds); + + /* + if (_WindowImpl::GetInstance(GetPublic()) == null) + { + r = CallOnBoundsChanging(bounds); + } + */ + + return r; +} + +void +_WindowImpl::OnRotated(_ControlRotation rotation) +{ + +} +#endif + +result +_WindowImpl::Open(bool drawAndShow) +{ + return GetCore().Open(drawAndShow); +} + +void +_WindowImpl::Close(void) +{ + GetCore().Close(); +} + +WindowState +_WindowImpl::GetWindowState(void) const +{ + ClearLastResult(); + return GetCore().GetWindowState(); +} + +void +_WindowImpl::SetWindowState(WindowState windowState) +{ + GetCore().SetWindowState(windowState); +} + +DisplayContext* +_WindowImpl::GetDisplayContext(void) const +{ + return GetCore().GetDisplayContext(); +} + +result +_WindowImpl::SetZOrderGroup(WindowZOrderGroup windowZOrderGroup) +{ + return GetCore().SetZOrderGroup(windowZOrderGroup); +} + +_Control* +_WindowImpl::GetOwner(void) const +{ + return GetCore().GetOwner(); +} + +void +_WindowImpl::SetOwner(Tizen::Ui::Control *pControl) +{ + _ControlImpl* pImpl = _ControlImpl::GetInstance(*pControl); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + GetCore().SetOwner(&pImpl->GetCore()); +} + +NativeWindowHandle +_WindowImpl::GetNativeHandle(void) const +{ + return GetCore().GetNativeHandle(); +} + +void +_WindowImpl::Initialize(Window* pPublic, _Window* pCore, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout) +{ + SysAssert(pPublic); + SysAssert(pCore); + + // Creation + __pImplDelegate = new (std::nothrow) WindowImplDelegate(*this); + SysTryReturnVoidResult(NID_UI, __pImplDelegate, E_OUT_OF_MEMORY, _UiError::OUT_OF_MEMORY); + + __pPublicWindowEventListeners = CreatePublicEventListenerListN(); + result r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCore->SetWindowDelegate(*__pImplDelegate); + r = GetLastResult(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return; + +CATCH: + delete __pPublicWindowEventListeners; + __pPublicWindowEventListeners = null; +} + +_WindowImpl::_WindowImpl(Window* pPublic, _Window* pCore, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout) + : _ContainerImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout) + , __pPublicWindowEventListeners(null) + , __pImplDelegate(null) +{ + Initialize(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout); +} + +_WindowImpl::_WindowImpl(Window* pPublic, _Window* pCore, const Rectangle& bounds, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, bool resizable, bool movable) + : _ContainerImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout) +{ + result r = E_SUCCESS; + + Initialize(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout); + + r = GetLastResult(); + if (IsFailed(r)) + { + return; + } + + bool allOrNone = (pPublicPortraitLayout && pPublicLandscapeLayout) || (!pPublicPortraitLayout && !pPublicLandscapeLayout); + SysAssert(allOrNone); + + r = SetBounds(bounds); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCore->SetResizable(resizable); + pCore->SetMovable(movable); +} + +}} //Tizen::Ui diff --git a/src/ui/animations/FUiAnimAnimationBase.cpp b/src/ui/animations/FUiAnimAnimationBase.cpp new file mode 100644 index 0000000..d29385c --- /dev/null +++ b/src/ui/animations/FUiAnimAnimationBase.cpp @@ -0,0 +1,334 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimAnimationBase.cpp + * @brief This file contains implementation of AnimationBase class + * + * This file contains implementation of AnimationBase class. + */ + + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "FUiAnim_AnimationBaseImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +AnimationBase::AnimationBase(void) + : _pAnimationBaseImpl(null) +{ +} + +AnimationBase::~AnimationBase(void) +{ + if (_pAnimationBaseImpl != null) + { + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + } +} + +AnimationBase::AnimationBase(const AnimationBase& animationBase) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + _pAnimationBaseImpl = new (std::nothrow) _AnimationBaseImpl(this); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = _pAnimationBaseImpl->Construct(); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, r, "[%s] Failed to construct _AnimationBaseImpl instance.", GetErrorMessage(r)); + + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + + return; + } + + SetInterpolatorType(animationBase.GetInterpolatorType()); + SetBezierControlPoints(animationBase._pAnimationBaseImpl->controlPointTime1, + animationBase._pAnimationBaseImpl->controlPointValue1, + animationBase._pAnimationBaseImpl->controlPointTime2, + animationBase._pAnimationBaseImpl->controlPointValue2); + SetDuration(animationBase.GetDuration()); + SetDelay(animationBase.GetDelay()); + SetOffset(animationBase.GetOffset()); + SetRepeatCount(animationBase.GetRepeatCount()); + SetAutoReverseEnabled(animationBase.IsAutoReverseEnabled()); + SetScaleRatio(animationBase.GetScaleRatio()); + SetHoldEndEnabled(animationBase.IsHoldEndEnabled()); + SetName(animationBase.GetName()); +} + +AnimationBase::AnimationBase(long duration, AnimationInterpolatorType interpolator) + : _pAnimationBaseImpl(null) +{ + ClearLastResult(); + + SysTryReturnVoidResult(NID_UI_ANIM, (duration >= 0), E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. duration = %ld", duration); + SysTryReturnVoidResult(NID_UI_ANIM, (interpolator >= ANIMATION_INTERPOLATOR_LINEAR && interpolator <= ANIMATION_INTERPOLATOR_BEZIER), + E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. interpolator is invalid."); + + result r = E_SUCCESS; + + _pAnimationBaseImpl = new (std::nothrow) _AnimationBaseImpl(this); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = _pAnimationBaseImpl->Construct(); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + + return; + } + + _pAnimationBaseImpl->duration = duration; + _pAnimationBaseImpl->interpolator = interpolator; +} + +AnimationBase& +AnimationBase::operator =(const AnimationBase& rhs) +{ + if ((&rhs) != this) + { + SetInterpolatorType(rhs.GetInterpolatorType()); + SetBezierControlPoints(rhs._pAnimationBaseImpl->controlPointTime1, rhs._pAnimationBaseImpl->controlPointValue1, + rhs._pAnimationBaseImpl->controlPointTime2, rhs._pAnimationBaseImpl->controlPointValue2); + SetDuration(rhs.GetDuration()); + SetDelay(rhs.GetDelay()); + SetOffset(rhs.GetOffset()); + SetRepeatCount(rhs.GetRepeatCount()); + SetAutoReverseEnabled(rhs.IsAutoReverseEnabled()); + SetScaleRatio(rhs.GetScaleRatio()); + SetHoldEndEnabled(rhs.IsHoldEndEnabled()); + SetName(rhs.GetName()); + } + + return *this; +} + +void +AnimationBase::SetInterpolatorType(AnimationInterpolatorType interpolator) +{ + _pAnimationBaseImpl->interpolator = interpolator; +} + +AnimationInterpolatorType +AnimationBase::GetInterpolatorType(void) const +{ + return _pAnimationBaseImpl->interpolator; +} + +result +AnimationBase::SetBezierControlPoints(float controlPointTime1, float controlPointValue1, float controlPointTime2, float controlPointValue2) +{ + SysTryReturnResult(NID_UI_ANIM, (controlPointTime1 >= 0.0f && controlPointTime1 <= 1.0f), E_INVALID_ARG, "Invalid argument(s) is used. controlPointTime1 = %f", controlPointTime1); + SysTryReturnResult(NID_UI_ANIM, (controlPointValue1 >= 0.0f && controlPointValue1 <= 1.0f), E_INVALID_ARG, "Invalid argument(s) is used. controlPointValue1 = %f", controlPointValue1); + SysTryReturnResult(NID_UI_ANIM, (controlPointTime2 >= 0.0f && controlPointTime2 <= 1.0f), E_INVALID_ARG, "Invalid argument(s) is used. controlPointTime2 = %f", controlPointTime2); + SysTryReturnResult(NID_UI_ANIM, (controlPointValue2 >= 0.0f && controlPointValue2 <= 1.0f), E_INVALID_ARG, "Invalid argument(s) is used. controlPointValue2 = %f", controlPointValue2); + + if (_pAnimationBaseImpl->interpolator != ANIMATION_INTERPOLATOR_BEZIER) + { + return E_INVALID_OPERATION; + } + + _pAnimationBaseImpl->controlPointTime1 = controlPointTime1; + _pAnimationBaseImpl->controlPointValue1 = controlPointValue1; + _pAnimationBaseImpl->controlPointTime2 = controlPointTime2; + _pAnimationBaseImpl->controlPointValue2 = controlPointValue2; + + return E_SUCCESS; +} + +result +AnimationBase::GetBezierControlPoints(float& controlPointTime1, float& controlPointValue1, float& controlPointTime2, float& controlPointValue2) const +{ + if (_pAnimationBaseImpl->interpolator != ANIMATION_INTERPOLATOR_BEZIER) + { + return E_INVALID_OPERATION; + } + + controlPointTime1 = _pAnimationBaseImpl->controlPointTime1; + controlPointValue1 = _pAnimationBaseImpl->controlPointValue1; + controlPointTime2 = _pAnimationBaseImpl->controlPointTime2; + controlPointValue2 = _pAnimationBaseImpl->controlPointValue2; + + return E_SUCCESS; +} + +int +AnimationBase::GetKeyFrameCount(void) const +{ + return _pAnimationBaseImpl->keyFrameList.GetCount(); +} + +void +AnimationBase::SetName(const String& name) +{ + _pAnimationBaseImpl->animName = name; + +} + +String +AnimationBase::GetName(void) const +{ + return _pAnimationBaseImpl->animName; +} + +result +AnimationBase::SetDuration(long milliSeconds) +{ + SysTryReturnResult(NID_UI_ANIM, (milliSeconds >= 0), E_INVALID_ARG, "Invalid argument(s) is used. milliSeconds = %ld", milliSeconds); + + _pAnimationBaseImpl->duration = milliSeconds; + + return E_SUCCESS; +} + +result +AnimationBase::SetOffset(long milliSeconds) +{ + SysTryReturnResult(NID_UI_ANIM, (milliSeconds >= 0 && milliSeconds <= _pAnimationBaseImpl->duration), E_INVALID_ARG, + "Invalid argument(s) is used. milliSeconds = %ld", milliSeconds); + + _pAnimationBaseImpl->offset = milliSeconds; + + return E_SUCCESS; +} + +result +AnimationBase::SetDelay(long milliSeconds) +{ + SysTryReturnResult(NID_UI_ANIM, (milliSeconds >= 0), E_INVALID_ARG, "Invalid argument(s) is used. milliSeconds = %ld", milliSeconds); + + _pAnimationBaseImpl->delay = milliSeconds; + + return E_SUCCESS; +} + +result +AnimationBase::SetRepeatCount(long count) +{ + SysTryReturnResult(NID_UI_ANIM, (count >= 1), E_INVALID_ARG, "Invalid argument(s) is used. count = %ld", count); + + _pAnimationBaseImpl->repeatCount = count; + + return E_SUCCESS; +} + +void +AnimationBase::SetAutoReverseEnabled(bool autoReverse) +{ + _pAnimationBaseImpl->autoReverse = autoReverse; +} + +result +AnimationBase::SetScaleRatio(float scaleRatio) +{ + SysTryReturnResult(NID_UI_ANIM, (scaleRatio >= 0), E_INVALID_ARG, "Invalid argument(s) is used. scaleRatio = %f", scaleRatio); + + _pAnimationBaseImpl->scaleRatio = scaleRatio; + return E_SUCCESS; +} + +void +AnimationBase::SetHoldEndEnabled(bool holdEnd) +{ + _pAnimationBaseImpl->holdEnd = holdEnd; +} + +long +AnimationBase::GetDuration(void) const +{ + return _pAnimationBaseImpl->duration; +} + +long +AnimationBase::GetOffset(void) const +{ + return _pAnimationBaseImpl->offset; +} + +long +AnimationBase::GetDelay(void) const +{ + return _pAnimationBaseImpl->delay; +} + +long +AnimationBase::GetRepeatCount(void) const +{ + return _pAnimationBaseImpl->repeatCount; +} + +bool +AnimationBase::IsAutoReverseEnabled(void) const +{ + return _pAnimationBaseImpl->autoReverse; +} + +float +AnimationBase::GetScaleRatio(void) const +{ + return _pAnimationBaseImpl->scaleRatio; +} + +bool +AnimationBase::IsHoldEndEnabled(void) const +{ + return _pAnimationBaseImpl->holdEnd; +} + +void +AnimationBase::AnimationBase_Reserved1(void) +{ +} + +void +AnimationBase::AnimationBase_Reserved2(void) +{ +} + +void +AnimationBase::AnimationBase_Reserved3(void) +{ +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimAnimationGroup.cpp b/src/ui/animations/FUiAnimAnimationGroup.cpp new file mode 100644 index 0000000..4a71b4c --- /dev/null +++ b/src/ui/animations/FUiAnimAnimationGroup.cpp @@ -0,0 +1,95 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimAnimationGroup.cpp + * @brief This file contains implementation of Animation Group class + * + * This file contains implementation of Animation Group class. + */ + + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "FUiAnim_AnimationGroupImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +AnimationGroup::AnimationGroup(void) + : _pAnimationGroupImpl(null) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + _pAnimationGroupImpl = new (std::nothrow) _AnimationGroupImpl(this); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationGroupImpl != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = _pAnimationGroupImpl->Construct(); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] Failed to construct _AnimationGroupImpl instance."); + delete _pAnimationGroupImpl; + _pAnimationGroupImpl = null; + } +} + +AnimationGroup::~AnimationGroup(void) +{ + delete _pAnimationGroupImpl; + _pAnimationGroupImpl = null; +} + +AnimationGroup::AnimationGroup(const AnimationGroup& animationGroup) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + _pAnimationGroupImpl = new (std::nothrow) _AnimationGroupImpl(this); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationGroupImpl != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = _pAnimationGroupImpl->Construct(); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, r, "[%s] Failed to construct _AnimationGroupImpl instance.", GetErrorMessage(r)); + + delete _pAnimationGroupImpl; + _pAnimationGroupImpl = null; + } +} + +}}} // Tizen::Ui::Animations diff --git a/src/ui/animations/FUiAnimAnimationTransaction.cpp b/src/ui/animations/FUiAnimAnimationTransaction.cpp new file mode 100644 index 0000000..8f9cf63 --- /dev/null +++ b/src/ui/animations/FUiAnimAnimationTransaction.cpp @@ -0,0 +1,309 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimAnimationTransaction.cpp + * @brief This file contains implementation of AnimationTransaction class + * + * This file contains implementation of AnimationTransaction class. + */ + +#include +#include + +#include + +#include "FUiAnim_TransactionNode.h" +#include "FUiAnim_AnimationManager.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +AnimationTransaction::~AnimationTransaction(void) +{ + +} + +result +AnimationTransaction::Begin(void) +{ + int transactionId = _AnimationManager::GetInstance()->BeginTransaction(); + SysTryReturnResult(NID_UI_ANIM, (transactionId != -1), E_OUT_OF_MEMORY, "Propagating."); + + return E_SUCCESS; +} + +result +AnimationTransaction::Begin(int& transactionId) +{ + transactionId = _AnimationManager::GetInstance()->BeginTransaction(); + SysTryReturnResult(NID_UI_ANIM, (transactionId != -1), E_OUT_OF_MEMORY, "Propagating."); + + return E_SUCCESS; +} + +result +AnimationTransaction::Commit(void) +{ + result r = _AnimationManager::GetInstance()->CommitTransaction(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + return r; +} + +result +AnimationTransaction::Stop(int transactionId) +{ + SysTryReturnResult(NID_UI_ANIM, (transactionId > 0), E_INVALID_ARG, "Invalid argument(s) is used. transactionId = %d", transactionId); + + result r = _AnimationManager::GetInstance()->StopTransaction(transactionId); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + return r; +} + +result +AnimationTransaction::Discard(void) +{ + result r = _AnimationManager::GetInstance()->DiscardTransaction(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + return r; +} + +AnimationTransactionStatus +AnimationTransaction::GetStatus(int transactionId) +{ + SysTryReturn(NID_UI_ANIM, (transactionId > 0), ANIMATION_TRANSACTION_STATUS_STOPPED, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. transactionId = %d.", transactionId); + + if (_AnimationManager::GetInstance()->IsTransactionRunning(transactionId)) + { + return ANIMATION_TRANSACTION_STATUS_PLAYING; + } + + return ANIMATION_TRANSACTION_STATUS_STOPPED; +} + +result +AnimationTransaction::SetTransactionEventListener(IAnimationTransactionEventListener* pListener) +{ + _AnimationManager::GetInstance()->SetTransactionEventListener(pListener); + + return E_SUCCESS; +} + +result +AnimationTransaction::SetCurrentTransactionEventListener(IAnimationTransactionEventListener* pListener) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturnResult(NID_UI_ANIM, (pNode != null), E_INVALID_OPERATION, "Transaction isn't opened."); + + result r = pNode->SetEventListener(pListener); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + return r; +} + +result +AnimationTransaction::SetVisualElementImplicitAnimationEnabled(bool enable) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturnResult(NID_UI_ANIM, (pNode != null), E_INVALID_OPERATION, "Transaction isn't opened."); + + result r = pNode->SetImplicitAnimationEnabled(enable); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + return r; +} + +result +AnimationTransaction::SetVisualElementAnimationStatusEventListener(IVisualElementAnimationStatusEventListener* pListener) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturnResult(NID_UI_ANIM, (pNode != null), E_INVALID_OPERATION, "Transaction isn't opened."); + + pNode->SetStatusEventListener(pListener); + + return E_SUCCESS; +} + +result +AnimationTransaction::SetVisualElementAnimationTimingFunction(const IVisualElementAnimationTimingFunction* pTimingFunction) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturnResult(NID_UI_ANIM, (pNode != null), E_INVALID_OPERATION, "Transaction isn't opened."); + + pNode->SetTimingFunction(pTimingFunction); + + return E_SUCCESS; +} + +result +AnimationTransaction::SetVisualElementAnimationValueInterpolator(const IVisualElementAnimationValueInterpolator* pValueInterpolator) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturnResult(NID_UI_ANIM, (pNode != null), E_INVALID_OPERATION, "Transaction isn't opened."); + + pNode->SetValueInterpolator(pValueInterpolator); + + return E_SUCCESS; +} + +result +AnimationTransaction::SetVisualElementAnimationDuration(long milliseconds) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturnResult(NID_UI_ANIM, (pNode != null), E_INVALID_OPERATION, "Transaction isn't opened."); + SysTryReturnResult(NID_UI_ANIM, (milliseconds >= 0 && milliseconds >= pNode->GetOffset()), + E_INVALID_ARG, "Invalid argument(s) is used. milliseconds = %ld", milliseconds); + + pNode->SetDuration(milliseconds); + + return E_SUCCESS; +} + +long +AnimationTransaction::GetVisualElementAnimationDuration(void) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturn(NID_UI_ANIM, (pNode != null), -1, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Transaction isn't opened."); + + return pNode->GetDuration(); +} + +result +AnimationTransaction::SetVisualElementAnimationOffset(long milliseconds) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturnResult(NID_UI_ANIM, (pNode != null), E_INVALID_OPERATION, "Transaction isn't opened."); + SysTryReturnResult(NID_UI_ANIM, (milliseconds >= 0 && milliseconds <= pNode->GetDuration()), + E_INVALID_ARG, "Invalid argument(s) is used. milliseconds = %ld", milliseconds); + + pNode->SetOffset(milliseconds); + + return E_SUCCESS; +} + +long +AnimationTransaction::GetVisualElementAnimationOffset(void) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturn(NID_UI_ANIM, (pNode != null), -1, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Transaction isn't opened."); + + return pNode->GetOffset(); +} + +result +AnimationTransaction::SetVisualElementAnimationDelay(long milliseconds) +{ + SysTryReturnResult(NID_UI_ANIM, (milliseconds >= 0), E_INVALID_ARG, "Invalid argument(s) is used. milliseconds = %ld", milliseconds); + + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturnResult(NID_UI_ANIM, (pNode != null), E_INVALID_OPERATION, "Transaction isn't opened."); + + pNode->SetDelay(milliseconds); + + return E_SUCCESS; +} + +long +AnimationTransaction::GetVisualElementAnimationDelay(void) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturn(NID_UI_ANIM, (pNode != null), -1, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Transaction isn't opened."); + + return pNode->GetDelay(); +} + +result +AnimationTransaction::SetVisualElementAnimationRepeatCount(long count) +{ + SysTryReturnResult(NID_UI_ANIM, (count >= 0), E_INVALID_ARG, "Invalid argument(s) is used. count = %ld", count); + + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturnResult(NID_UI_ANIM, (pNode != null), E_INVALID_OPERATION, "Transaction isn't opened."); + + pNode->SetRepeatCount(count); + + return E_SUCCESS; +} + +long +AnimationTransaction::GetVisualElementAnimationRepeatCount(void) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturn(NID_UI_ANIM, (pNode != null), -1, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Transaction isn't opened."); + + return pNode->GetRepeatCount(); +} + +result +AnimationTransaction::SetVisualElementAnimationAutoReverseEnabled(bool autoReverse) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturnResult(NID_UI_ANIM, (pNode != null), E_INVALID_OPERATION, "Transaction isn't opened."); + + pNode->SetAutoReverseEnabled(autoReverse); + + return E_SUCCESS; +} + +bool +AnimationTransaction::IsVisualElementAnimationAutoReverseEnabled(void) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturn(NID_UI_ANIM, (pNode != null), false, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Transaction isn't opened."); + + bool autoReverse = pNode->IsAutoReverseEnabled(); + + result r = GetLastResult(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + return autoReverse; +} + +result +AnimationTransaction::SetVisualElementAnimationScaleRatio(float scaleRatio) +{ + SysTryReturnResult(NID_UI_ANIM, (scaleRatio > 0.f), E_INVALID_ARG, "Invalid argument(s) is used. scaleRatio = %f", scaleRatio); + + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturnResult(NID_UI_ANIM, (pNode != null), E_INVALID_OPERATION, "Transaction isn't opened."); + + pNode->SetScaleRatio(scaleRatio); + + return E_SUCCESS; +} + +float +AnimationTransaction::GetVisualElementAnimationScaleRatio(void) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(); + SysTryReturn(NID_UI_ANIM, (pNode != null), 0.0f, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Transaction isn't opened."); + + return pNode->GetScaleRatio(); +} + +} } } // Tizen::Ui::Animations diff --git a/src/ui/animations/FUiAnimBezierTimingFunction.cpp b/src/ui/animations/FUiAnimBezierTimingFunction.cpp new file mode 100644 index 0000000..524bdea --- /dev/null +++ b/src/ui/animations/FUiAnimBezierTimingFunction.cpp @@ -0,0 +1,219 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimBezierTimingFunction.cpp + * @brief This file contains implementation of BezierTimingFunction class + * + * This file contains implementation BezierTimingFunction class. + */ + +#include + +#include +#include + +#include + +#include "FUi_Math.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +#define THIRD 0.33333333333333f +#define ROOTTHREE 1.73205080756888f + +float +CubeRoot(float x) +{ + if (x < 0.0f) + { + return -powf(-x, THIRD); + } + + return powf(x, THIRD); +} + + +BezierTimingFunction::BezierTimingFunction(void) + : __timeProgress1(0.0f) + , __progress1(0.0f) + , __timeProgress2(0.0f) + , __progress2(0.0f) + , __coefficientA(0.0f) + , __coefficientB(0.0f) + , __coefficientC(0.0f) +{ + SetControlPoints(0.33f, 0.8f, 0.66f, 0.2f); +} + +BezierTimingFunction::~BezierTimingFunction(void) +{ + +} + +result +BezierTimingFunction::SetControlPoints(float timeProgress1, float progress1, float timeProgress2, float progress2) +{ + SysTryReturnResult(NID_UI_ANIM, (timeProgress1 >= 0.f && timeProgress1 <= 1.0f), E_INVALID_ARG, "Invalid argument(s) is used. timeProgress1 is invalid."); + SysTryReturnResult(NID_UI_ANIM, (progress1 >= 0.f && progress1 <= 1.0f), E_INVALID_ARG, "Invalid argument(s) is used. progress1 is invalid."); + SysTryReturnResult(NID_UI_ANIM, (timeProgress2 >= 0.f && timeProgress2 <= 1.0f), E_INVALID_ARG, "Invalid argument(s) is used. timeProgress2 is invalid."); + SysTryReturnResult(NID_UI_ANIM, (progress2 >= 0.f && progress2 <= 1.0f), E_INVALID_ARG, "Invalid argument(s) is used. progress2 is invalid."); + + __timeProgress1 = timeProgress1; + __progress1 = progress1; + + __timeProgress2 = timeProgress2; + __progress2 = progress2; + + // Bezier curve + // + // B(t) = (1-t)^3 * P0 + 3t(1-t)^2*P1 + 3t^2(1-t)*P2 + t^3*P3 + // = (P3 - P0 + 3P1 - 3P2) * t^3 + (3P0 - 6P1 + 3P2) * t^2 + (3P1 - 3P0) * t + P0 + // + // Now, P0 = (0, 0), P3 = (1, 1) + // + // (1 + 3P1 - 3P2) * t^3 + (3P2 - 6P1) * t^2 + 3P1 * t - timeProgress = 0 + + // ax^3 + bx^2 + cx + d = 0 + + __coefficientA = 1.0f + 3.0f * __timeProgress1 - 3.0f * __timeProgress2; + __coefficientB = 3.0f * __timeProgress2 - 6.0f * __timeProgress1; + __coefficientC = 3.0f * __timeProgress1; + + return E_SUCCESS; +} + +result +BezierTimingFunction::GetControlPoints(float& timeProgress1, float& progress1, float& timeProgress2, float& progress2) const +{ + timeProgress1 = __timeProgress1; + progress1 = __progress1; + + timeProgress2 = __timeProgress2; + progress2 = __progress2; + + return E_SUCCESS; +} + +float +BezierTimingFunction::CalculateProgress(float timeProgress) const +{ + float t = 0.0f; + float d = -timeProgress; + + // 1. Cardano's method + // http://www.wolframalpha.com + // http://www.dreamincode.net/code/snippet2915.htm + + SysTryReturn(NID_UI_ANIM, (__coefficientA <-ALMOST_ZERO_FLOAT || __coefficientA> ALMOST_ZERO_FLOAT), 0.0f, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] Invalid control points."); + + // find the discriminant + float f = (3.0f * __coefficientC / __coefficientA - __coefficientB * __coefficientB / (__coefficientA * __coefficientA)) / 3.0f; + float g = (2.0f * powf(__coefficientB, 3) / powf(__coefficientA, 3) - 9.0f * __coefficientB * __coefficientC / (__coefficientA * __coefficientA) + 27.0f * d / __coefficientA) / 27.0f; + float h = g * g / 4.0f + powf(f, 3) / 27.0f; + + // evaluate discriminat + if (f >= -ALMOST_ZERO_FLOAT && f <= ALMOST_ZERO_FLOAT && g >= -ALMOST_ZERO_FLOAT && g <= ALMOST_ZERO_FLOAT && h >= + -ALMOST_ZERO_FLOAT && h <= ALMOST_ZERO_FLOAT) + { + // 3 equal roots + // when f, g and h all equal 0 the roots can be found by the following line + t = -CubeRoot(d / __coefficientA); + } + else if (h <= 0.0f) + { + // 3 real roots + // complicated maths making use of the method + float i = powf(g * g / 4.0f - h, 0.5f); + float j = CubeRoot(i); + float k = acosf(-(g / (2.0f * i))); + float m = cosf(k / 3.0f); + float n = ROOTTHREE * sinf(k / 3.0f); + float p = -(__coefficientB / (3.0f * __coefficientA)); + + float t1 = 2.0f * j * m + p; + float t2 = -j * (m + n) + p; + float t3 = -j * (m - n) + p; + + // find the proper t + if (t1 >= 0.0f && t1 <= 1.0f) + { + t = t1; + } + else if (t2 >= 0.0f && t2 <= 1.0f) + { + t = t2; + } + else if (t3 >= 0.0f && t3 <= 1.0f) + { + t = t3; + } + else + { + SysLogException(NID_UI_ANIM, E_INVALID_OPERATION, "[E_INVALID_OPERATION] control points are invalid."); + return 0.0f; + } + } + else // if (h > 0.0f) + { + // 1 real root and 2 complex roots + // complicated maths making use of the method + float r = -(g / 2.0f) + powf(h, 0.5f); + float s = CubeRoot(r); + float u = -(g / 2.0f) - powf(h, 0.5f); + float v = CubeRoot(u); + float p = -(__coefficientB / (3.0f * __coefficientA)); + + t = s + v + p; + } + + // calculate progress from t + // progress = (1 + 3P1 - 3P2) * t^3 + (3P2 - 6P1) * t^2 + 3P1 * t + return (1.0f + 3.0f * __progress1 - 3.0f * __progress2) * t * t * t + (3.0f * __progress2 - 6.0f * __progress1) * t * t + 3.0f * __progress1 * t; + +#if 0 + // 2. Newton-Raphson's method + // + // f(x) = ax^3 + bx^2 + cx + d + // f'(x) = 3ax^2 + 2bx + c + // + // x_n+1 = x_n - f(x_n) / f'(x_n) + + float t = 0.5f; + float t1 = 0.5f; + int iteration = 0; + + do + { + t = t1; + t1 = t - (a * t * t * t + b * t * t + c * t + d) / (3.0f * a * t * t + 2.0f * b * t + c); + iteration++; + } + while ((t - t1 > ALMOST_ZERO_FLOAT || t - t1 < -ALMOST_ZERO_FLOAT) && iteration < 10); + + // calculate progress from t + // progress = (1 + 3P1 - 3P2) * t^3 + (3P2 - 6P1) * t^2 + 3P1 * t + return (1.0f + 3.0f * __y1 - 3.0f * __y2) * t1 * t1 * t1 + (3.0f * __y2 - 6.0f * __y1) * t1 * t1 + 3.0f * __y1 * t1; +#endif +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimControlAnimator.cpp b/src/ui/animations/FUiAnimControlAnimator.cpp new file mode 100644 index 0000000..e132866 --- /dev/null +++ b/src/ui/animations/FUiAnimControlAnimator.cpp @@ -0,0 +1,1255 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimControlAnimator.cpp + * @brief This file contains implementation of ControlAnimator class + * + * This file contains implementation of ControlAnimator class. + */ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FUiAnim_ControlAnimatorImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +///INIT_SYSCLASSTYPE(ControlAnimator); + +ControlAnimator::ControlAnimator(void) + : _pControlAnimatorImpl(null) +{ + +} + +ControlAnimator::~ControlAnimator(void) +{ + delete _pControlAnimatorImpl; + _pControlAnimatorImpl = null; +} + +result +ControlAnimator::Construct(const Control& source) +{ + SysAssertf((_pControlAnimatorImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + result r = E_SUCCESS; + + _pControlAnimatorImpl = new (std::nothrow) _ControlAnimatorImpl(this); + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl), E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = _pControlAnimatorImpl->Construct(source); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to construct _ControlAnimatorImpl instance."); + + return r; + +CATCH: + delete _pControlAnimatorImpl; + _pControlAnimatorImpl = null; + + return r; + +} + +result +ControlAnimator::StartUserAnimation(AnimationTargetType animTarget, const AnimationBase& animationBase) +{ + SysTryReturnResult(NID_UI_ANIM, (animTarget > ANIMATION_TARGET_NONE && animTarget < ANIMATION_TARGET_MAX), E_INVALID_ARG, + "Invalid argument(s) is used. AnimationTargetType argument is invalid."); + + SysTryReturnResult(NID_UI_ANIM, !(_pControlAnimatorImpl->IsAnimationTargetAnimating(animTarget)), E_INVALID_OPERATION, + "Same AnimationTargetType is being animated."); + + result r = E_SUCCESS; + int activeAnimationCount = _pControlAnimatorImpl->GetActiveAnimationListCount(); + + AnimationBase* pAnimBase = const_cast< AnimationBase* >(&animationBase); + SysTryReturnResult(NID_UI_ANIM, (pAnimBase != null), E_INVALID_ARG, "Invalid argument(s) is used. AnimationBase argument is invalid."); + + Rectangle rect(0, 0, 0, 0); + + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimatable(animTarget, rect, pAnimBase)), E_INVALID_ARG, + "Invalid argument(s) is used. AnimationBase argument is invalid."); + + if (_pControlAnimatorImpl->IsAnimationSupported() == false) + { + r = _pControlAnimatorImpl->SetControlProperty(animTarget, *pAnimBase); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to set control property."); + + return E_SUCCESS; + } + + AnimationBase* pAnimationBase = null; + pAnimationBase = _pControlAnimatorImpl->CloneAnimation(animTarget, *pAnimBase); + SysTryReturnResult(NID_UI_ANIM, (pAnimationBase), E_SYSTEM, "A system error has been occurred. Failed to clone animation."); + + if (animTarget == ANIMATION_TARGET_POSITION || animTarget == ANIMATION_TARGET_SIZE) + { + _pControlAnimatorImpl->SetLogicalBounds(_pControlAnimatorImpl->GetControl().GetBounds()); + } + else if (animTarget == ANIMATION_TARGET_ALPHA) + { + _pControlAnimatorImpl->SetShowState(_pControlAnimatorImpl->GetControl().GetShowState()); + } + + if (animTarget == ANIMATION_TARGET_POSITION || animTarget == ANIMATION_TARGET_SIZE) + { + _pControlAnimatorImpl->SetControlLogicalBounds(animTarget, *pAnimationBase); + + bool disable = false; + bool propagation = false; + + result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable implicit animation."); + + r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable visual element propagation."); + + r = _pControlAnimatorImpl->GetControl().SetBounds(_pControlAnimatorImpl->GetLogicalBounds()); + + if (propagation) + { + _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + } + if (disable) + { + _pControlAnimatorImpl->DisableImplicitAnimation(disable); + } + + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds."); + + } + else if (animTarget == ANIMATION_TARGET_ALPHA) + { + _pControlAnimatorImpl->SetControlShowState(animTarget, *pAnimationBase); + + bool disable = false; + bool propagation = false; + + result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to enable/disable implicit animation."); + + r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to enable/disable visual element propagation."); + + r = _pControlAnimatorImpl->GetControl().SetShowState((_pControlAnimatorImpl->GetShowState())); + if (propagation) + { + _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + } + if (disable) + { + _pControlAnimatorImpl->DisableImplicitAnimation(disable); + } + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set show state."); + } + + //Create and play the Animation + r = _pControlAnimatorImpl->SetAnimation(animTarget, *pAnimationBase); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlAnimatorImpl->SetAnimationTargetAnimating(animTarget, true); + + return r; + +CATCH: + if (_pControlAnimatorImpl->DestroyAnimation(activeAnimationCount) != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to destroy animation."); + return E_SYSTEM; + } + return r; +} + +result +ControlAnimator::StartUserAnimation(const AnimationGroup& animGroup) +{ + result r = E_SUCCESS; + bool isAnimating = false; + + ParallelAnimationGroup* pParallelAnimGrp = null; + SequentialAnimationGroup* pSequentialAnimGrp = null; + + pParallelAnimGrp = dynamic_cast< ParallelAnimationGroup* >(const_cast< AnimationGroup* >(&animGroup)); + pSequentialAnimGrp = dynamic_cast< SequentialAnimationGroup* >(const_cast< AnimationGroup* >(&animGroup)); + SysTryReturnResult(NID_UI_ANIM, ((pParallelAnimGrp) || (pSequentialAnimGrp)), E_INVALID_ARG, "Invalid argument(s) is used. AnimationGroup argument is invalid."); + + if (pParallelAnimGrp) + { + SysTryReturnResult(NID_UI_ANIM, (pParallelAnimGrp->GetAnimationCount() > 0), E_INVALID_ARG, "Invalid argument(s) is used. No animation found in AnimationGroup."); + + for (int animType = (static_cast< int >(ANIMATION_TARGET_NONE) + 1); animType < (static_cast< int >(ANIMATION_TARGET_MAX)); animType++) + { + AnimationTargetType animTarget = static_cast< AnimationTargetType >(animType); + AnimationBase* pAnimationBase = null; + pAnimationBase = pParallelAnimGrp->GetAnimationN(animTarget); + if (pAnimationBase != null) + { + isAnimating = _pControlAnimatorImpl->IsAnimationTargetAnimating(animTarget); + + Rectangle rect(0, 0, 0, 0); + + bool animatable = _pControlAnimatorImpl->IsAnimatable(animTarget, rect, pAnimationBase); + + delete pAnimationBase; + + SysTryReturnResult(NID_UI_ANIM, (animatable), E_INVALID_ARG, "Invalid argument(s) is used. AnimationGroup argument is invalid."); + //The below check was removed for 2.0 + SysTryReturnResult(NID_UI_ANIM, !(isAnimating), E_INVALID_OPERATION, "Same AnimationTargetType is being animated."); + } + } + + r = _pControlAnimatorImpl->SetGroupAnimation(pParallelAnimGrp); + } + else //if (pSequentialAnimGrp) + { + SysTryReturnResult(NID_UI_ANIM, (pSequentialAnimGrp->GetAnimationCount() > 0), E_INVALID_ARG, "Invalid argument(s) is used. No animation found in AnimationGroup."); + + for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++) + { + AnimationTargetType animTarget = ANIMATION_TARGET_MAX; + AnimationBase* pAnimationBase = null; + pAnimationBase = pSequentialAnimGrp->GetAnimationAtN(index); + animTarget = pSequentialAnimGrp->GetAnimationTargetTypeAt(index); + + if (pAnimationBase != null) + { + isAnimating = _pControlAnimatorImpl->IsAnimationTargetAnimating(animTarget); + + Rectangle rect(0, 0, 0, 0); + + bool animatable = _pControlAnimatorImpl->IsAnimatable(animTarget, rect, pAnimationBase); + + delete pAnimationBase; + + SysTryReturnResult(NID_UI_ANIM, (animatable), E_INVALID_ARG, "Invalid argument(s) is used. AnimationGroup argument is invalid."); + //The below check should be removed for 2.0 + SysTryReturnResult(NID_UI_ANIM, !(isAnimating), E_INVALID_OPERATION, "Same AnimationTargetType is being animated."); + } + else + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. An animation in sequential group is null."); + return E_SYSTEM; + } + } + + r = _pControlAnimatorImpl->SetGroupAnimation(pSequentialAnimGrp); + } + + return r; +} + +result +ControlAnimator::StopAllAnimations(void) +{ + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->GetActiveAnimationListCount() > 0), E_SUCCESS, "No Active Animation."); + + return _pControlAnimatorImpl->StopAllAnimations(); +} + +result +ControlAnimator::StopAnimation(ControlAnimatorTriggerType animTrigger) +{ + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl), E_SYSTEM, "A system error has been occurred. Control animator is not constructed properly."); + SysTryReturnResult(NID_UI_ANIM, (animTrigger >= ANIMATION_TRIGGER_USER && animTrigger <= ANIMATION_TRIGGER_SHOW_STATE_CHANGE), + E_INVALID_ARG, "Invalid argument(s) is used. ControlAnimatorTriggerType argument is invalid."); + + return _pControlAnimatorImpl->StopAnimation(animTrigger); +} + +AnimatorStatus +ControlAnimator::GetStatus(void) const +{ + if (_pControlAnimatorImpl->IsAnimationSupported()) + { + _pControlAnimatorImpl->SetAnimatorStatus(ANIMATOR_STATUS_STOPPED); + + for (int animType = ((int) ANIMATION_TARGET_NONE + 1); animType < ((int) ANIMATION_TARGET_MAX); animType++) + { + if (_pControlAnimatorImpl->IsAnimationTargetAnimating(animType) == true) + { + _pControlAnimatorImpl->SetAnimatorStatus(ANIMATOR_STATUS_PLAYING); + break; + } + } + return _pControlAnimatorImpl->GetAnimatorStatus(); + } + else + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation support is unavailable."); + return ANIMATOR_STATUS_STOPPED; + } +} + +AnimatorStatus +ControlAnimator::GetStatus(AnimationTargetType animTarget) const +{ + SysTryReturn(NID_UI_ANIM, (animTarget > ANIMATION_TARGET_NONE && animTarget < ANIMATION_TARGET_MAX), ANIMATOR_STATUS_STOPPED, E_INVALID_ARG, + "Invalid argument(s) is used. AnimationTargetType argument is invalid."); + + if (_pControlAnimatorImpl->IsAnimationSupported()) + { + if (_pControlAnimatorImpl->IsAnimationTargetAnimating(animTarget) == true) + { + return ANIMATOR_STATUS_PLAYING; + } + + return ANIMATOR_STATUS_STOPPED; + } + else + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation support is unavailable."); + return ANIMATOR_STATUS_STOPPED; + } +} + +result +ControlAnimator::AddControlAnimatorEventListener(IControlAnimatorEventListener& listener) +{ + SysTryReturnResult(NID_UI_ANIM, _pControlAnimatorImpl->IsAnimationSupported(), E_UNSUPPORTED_OPERATION, "Animation is unsupported."); + + return _pControlAnimatorImpl->AddControlAnimatorEventListener(listener); +} + +result +ControlAnimator::RemoveControlAnimatorEventListener(IControlAnimatorEventListener& listener) +{ + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationSupported()), E_UNSUPPORTED_OPERATION, "Animation is unsupported."); + + return _pControlAnimatorImpl->RemoveControlAnimatorEventListener(listener); +} + +result +ControlAnimator::AddControlAnimatorDetailedEventListener(IControlAnimatorDetailedEventListener& listener) +{ + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationSupported()), E_UNSUPPORTED_OPERATION, "Animation is unsupported."); + + return _pControlAnimatorImpl->AddControlAnimatorDetailedEventListener(listener); +} + +result +ControlAnimator::RemoveControlAnimatorDetailedEventListener(IControlAnimatorDetailedEventListener& listener) +{ + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationSupported()), E_UNSUPPORTED_OPERATION, "Animation is unsupported."); + + return _pControlAnimatorImpl->RemoveControlAnimatorDetailedEventListener(listener); +} + +result +ControlAnimator::SetAnimation(ControlAnimatorTriggerType animTrigger, const AnimationGroup* pAnimationGroup) +{ + SysTryReturnResult(NID_UI_ANIM, ((animTrigger >= ANIMATION_TRIGGER_POSITION_CHANGE) && (animTrigger <= ANIMATION_TRIGGER_SHOW_STATE_CHANGE)), + E_INVALID_ARG, "Invalid argument(s) is used. ControlAnimatorTriggerType argument is invalid."); + + if (pAnimationGroup == null) + { + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(animTrigger - 1) != + PROPERTY_ANIMATION_GROUP_TYPE_NONE), E_SUCCESS, "No custom implicit animation is set yet."); + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1)), E_SUCCESS, + "No custom implicit animation is set yet against this ControlAnimatorTriggerType."); + + _pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1)->RemoveAllAnimations(); + + delete _pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1); + _pControlAnimatorImpl->SetPropertyGroupList(animTrigger - 1, null); + _pControlAnimatorImpl->SetStoredPropertyAnimationGroupType(animTrigger - 1, PROPERTY_ANIMATION_GROUP_TYPE_NONE); + + return E_SUCCESS; + } + + SequentialAnimationGroup* pSequentialAnimGrp = null; + ParallelAnimationGroup* pParallelAnimGrp = null; + AnimationTargetType associatedAnimTarget = ANIMATION_TARGET_NONE; + + pSequentialAnimGrp = dynamic_cast< SequentialAnimationGroup* >(const_cast< AnimationGroup* >(pAnimationGroup)); + pParallelAnimGrp = dynamic_cast< ParallelAnimationGroup* >(const_cast< AnimationGroup* >(pAnimationGroup)); + SysTryReturnResult(NID_UI_ANIM, ((pSequentialAnimGrp) || (pParallelAnimGrp)), E_INVALID_ARG, "Invalid argument(s) is used. AnimationGroup argument is invalid."); + SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup->GetAnimationCount() > 0), E_INVALID_ARG, "Invalid argument(s) is used. No animations added to AnimationGroup."); + + if (animTrigger == ANIMATION_TRIGGER_POSITION_CHANGE) + { + associatedAnimTarget = ANIMATION_TARGET_POSITION; + } + else if (animTrigger == ANIMATION_TRIGGER_SIZE_CHANGE) + { + associatedAnimTarget = ANIMATION_TARGET_SIZE; + } + else if (animTrigger == ANIMATION_TRIGGER_SHOW_STATE_CHANGE) + { + associatedAnimTarget = ANIMATION_TARGET_ALPHA; + } + + if (pSequentialAnimGrp) + { + int targetCount = 0; + for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++) + { + AnimationTargetType animTarget = ANIMATION_TARGET_NONE; + animTarget = pSequentialAnimGrp->GetAnimationTargetTypeAt(index); + SysTryReturnResult(NID_UI_ANIM, ((animTarget > ANIMATION_TARGET_NONE) && (animTarget < ANIMATION_TARGET_MAX)), E_INVALID_ARG, + "Invalid argument(s) is used. AnimationTargetType argument is invalid."); + + if (associatedAnimTarget == animTarget) + { + targetCount++; + } + } + SysTryReturnResult(NID_UI_ANIM, (targetCount >= 1), E_INVALID_ARG, + "Invalid argument(s) is used. AnimationGroup should have at-least one animation of equivalent AnimationTargetType."); + + //Check for IsAnimatable() of all AnimationBase objects + for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++) + { + AnimationTargetType animTarget = ANIMATION_TARGET_NONE; + AnimationBase* pAnimationBase = null; + pAnimationBase = pSequentialAnimGrp->GetAnimationAtN(index); + animTarget = pSequentialAnimGrp->GetAnimationTargetTypeAt(index); + + bool animatable = false; + if (pAnimationBase) + { + if (associatedAnimTarget != animTarget) + { + Rectangle rect(0, 0, 0, 0); + + animatable = _pControlAnimatorImpl->IsAnimatable(animTarget, rect, pAnimationBase); + } + + delete pAnimationBase; + + if ((associatedAnimTarget != animTarget) && (!animatable)) + { + SysLogException(NID_UI_ANIM, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Control is not animable. Animations cannot be set to control."); + return E_UNSUPPORTED_OPERATION; + } + } + else + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. An animation in sequential group animation is null."); + return E_SYSTEM; + } + } + + SequentialAnimationGroup* pSequentialAnimationGroup = null; + pSequentialAnimationGroup = new (std::nothrow) SequentialAnimationGroup(*pSequentialAnimGrp); + SysTryReturnResult(NID_UI_ANIM, (pSequentialAnimationGroup), E_OUT_OF_MEMORY, "Memory allocation failed."); + + if (pSequentialAnimationGroup->GetAnimationCount() != pSequentialAnimGrp->GetAnimationCount()) + { + if (pSequentialAnimationGroup->GetAnimationCount() > 0) + { + pSequentialAnimationGroup->RemoveAllAnimations(); + } + + delete pSequentialAnimationGroup; + + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to clone sequential group animation."); + return E_SYSTEM; + } + + if (_pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1)) + { + _pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1)->RemoveAllAnimations(); + delete _pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1); + _pControlAnimatorImpl->SetPropertyGroupList(animTrigger - 1, null); + _pControlAnimatorImpl->SetStoredPropertyAnimationGroupType(animTrigger - 1, PROPERTY_ANIMATION_GROUP_TYPE_NONE); + } + _pControlAnimatorImpl->SetPropertyGroupList(animTrigger - 1, pSequentialAnimationGroup); + _pControlAnimatorImpl->SetStoredPropertyAnimationGroupType(animTrigger - 1, PROPERTY_ANIMATION_GROUP_TYPE_SEQUENTIAL); + + return E_SUCCESS; + } + else //if (pParallelAnimGrp) + { + bool isPresent = false; + + if (animTrigger == ANIMATION_TRIGGER_POSITION_CHANGE) + { + isPresent = pParallelAnimGrp->IsAnimationAdded(ANIMATION_TARGET_POSITION); + } + else if (animTrigger == ANIMATION_TRIGGER_SIZE_CHANGE) + { + isPresent = pParallelAnimGrp->IsAnimationAdded(ANIMATION_TARGET_SIZE); + } + else if (animTrigger == ANIMATION_TRIGGER_SHOW_STATE_CHANGE) + { + isPresent = pParallelAnimGrp->IsAnimationAdded(ANIMATION_TARGET_ALPHA); + } + + SysTryReturnResult(NID_UI_ANIM, (isPresent), E_INVALID_ARG, + "Invalid argument(s) is used. AnimationGroup should have one animation of equivalent AnimationTargetType."); + + //Check for IsAnimatable() of all AnimationBase objects + for (int animType = ((int) ANIMATION_TARGET_NONE + 1); animType < ((int) ANIMATION_TARGET_MAX); animType++) + { + AnimationTargetType animTarget = static_cast< AnimationTargetType >(animType); + if (pParallelAnimGrp->IsAnimationAdded(animTarget) == false) + { + continue; + } + AnimationBase* pAnimationBase = null; + bool animatable = false; + + pAnimationBase = pParallelAnimGrp->GetAnimationN(animTarget); + if (pAnimationBase) + { + if (associatedAnimTarget != animTarget) + { + Rectangle rect(0, 0, 0, 0); + + animatable = _pControlAnimatorImpl->IsAnimatable(animTarget, rect, pAnimationBase); + } + + delete pAnimationBase; + + SysTryReturnResult(NID_UI_ANIM, !((associatedAnimTarget != animTarget) && (!animatable)), E_UNSUPPORTED_OPERATION, + "Animations cannot be set to control."); + + } + else + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. An animation in parallel group animation is null."); + return E_SYSTEM; + } + } + + ParallelAnimationGroup* pParallelAnimationGroup = null; + pParallelAnimationGroup = new (std::nothrow) ParallelAnimationGroup(*pParallelAnimGrp); + SysTryReturnResult(NID_UI_ANIM, (pParallelAnimationGroup), E_OUT_OF_MEMORY, "Memory allocation failed."); + + if (pParallelAnimationGroup->GetAnimationCount() != pParallelAnimGrp->GetAnimationCount()) + { + if (pParallelAnimationGroup->GetAnimationCount() > 0) + { + pParallelAnimationGroup->RemoveAllAnimations(); + } + + delete pParallelAnimationGroup; + + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to clone ParallelAnimationGroup instance."); + return E_SYSTEM; + } + + if (_pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1)) + { + _pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1)->RemoveAllAnimations(); + delete _pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1); + _pControlAnimatorImpl->SetPropertyGroupList(animTrigger - 1, null); + _pControlAnimatorImpl->SetStoredPropertyAnimationGroupType(animTrigger - 1, PROPERTY_ANIMATION_GROUP_TYPE_NONE); + } + _pControlAnimatorImpl->SetPropertyGroupList(animTrigger - 1, pParallelAnimationGroup); + _pControlAnimatorImpl->SetStoredPropertyAnimationGroupType(animTrigger - 1, PROPERTY_ANIMATION_GROUP_TYPE_PARALLEL); + + return E_SUCCESS; + } +} + +AnimationGroup* +ControlAnimator::GetAnimationN(ControlAnimatorTriggerType animTrigger) const +{ + SysTryReturn(NID_UI_ANIM, ((animTrigger >= ANIMATION_TRIGGER_POSITION_CHANGE) && (animTrigger <= ANIMATION_TRIGGER_SHOW_STATE_CHANGE)), + null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. animTrigger is invalid."); + SysTryReturn(NID_UI_ANIM, (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(animTrigger - 1) != PROPERTY_ANIMATION_GROUP_TYPE_NONE), + null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. No implicit animations set to control."); + + if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(animTrigger - 1) == PROPERTY_ANIMATION_GROUP_TYPE_PARALLEL) + { + ParallelAnimationGroup* pTempParallelAnimGroup = dynamic_cast< ParallelAnimationGroup* >(_pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1)); + SysTryReturn(NID_UI_ANIM, (pTempParallelAnimGroup), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get ParallelAnimationGroup instance."); + + ParallelAnimationGroup* pParallelAnimationGroup = new (std::nothrow) ParallelAnimationGroup(*pTempParallelAnimGroup); + SysTryReturn(NID_UI_ANIM, (pParallelAnimationGroup), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + SysTryReturn(NID_UI_ANIM, (pParallelAnimationGroup->GetAnimationCount() > 0), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to create ParallelAnimationGroup."); + + return pParallelAnimationGroup; + } + else if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(animTrigger - 1) == PROPERTY_ANIMATION_GROUP_TYPE_SEQUENTIAL) + { + SequentialAnimationGroup* pTempSequentialAnimGroup = dynamic_cast< SequentialAnimationGroup* >(_pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1)); + SysTryReturn(NID_UI_ANIM, (pTempSequentialAnimGroup), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to clone SequentialAnimationGroup."); + + SequentialAnimationGroup* pSequentialAnimationGroup = new (std::nothrow) SequentialAnimationGroup(*pTempSequentialAnimGroup); + SysTryReturn(NID_UI_ANIM, (pSequentialAnimationGroup), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + SysTryReturn(NID_UI_ANIM, (pSequentialAnimationGroup->GetAnimationCount() > 0), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to create SequentialAnimationGroup instance."); + + return pSequentialAnimationGroup; + } + else + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid property animation group type provided."); + return null; + } +} + +result +ControlAnimator::SetPosition(int x, int y) +{ + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationTargetAnimating(ANIMATION_TARGET_POSITION) == false), E_INVALID_OPERATION, "Same AnimationTargetType is already being animated."); + + result r = E_SUCCESS; + + Control& controlRef = _pControlAnimatorImpl->GetControl(); + Rectangle controlBounds = controlRef.GetBounds(); + Point newPosition = Point(x, y); + Point currentPosition = controlRef.GetPosition(); + + SysTryReturnResult(NID_UI_ANIM, (controlRef.IsMovable()), E_UNSUPPORTED_OPERATION, "Bounds cannot be modified."); + + //CustomControl s Condition check + CustomControlBase* pControlBase = dynamic_cast< CustomControlBase* >(&controlRef); + + if (pControlBase) + { + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(_pControlAnimatorImpl->GetControl()); + pControlImpl->OnBoundsChanging(Rectangle(x, y, controlRef.GetWidth(), controlRef.GetHeight())); + } + + int activeAnimationCount = _pControlAnimatorImpl->GetActiveAnimationListCount(); + AnimationBase* pAnimationBase = null; + + if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_POSITION_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE) + { + if (currentPosition == newPosition) + { + return E_SUCCESS; + } + + PointAnimation* pPointAnim = new (std::nothrow) PointAnimation(currentPosition, newPosition, 400, ANIMATION_INTERPOLATOR_LINEAR); + SysTryReturnResult(NID_UI_ANIM, (pPointAnim), E_OUT_OF_MEMORY, "Memory allocation failed."); + + pAnimationBase = pPointAnim; + + Rectangle rect(x, y, 0, 0); + + if (!(_pControlAnimatorImpl->IsAnimatable(ANIMATION_TARGET_POSITION, rect, pAnimationBase, ANIMATION_TRIGGER_POSITION_CHANGE))) + { + delete pAnimationBase; + + SysLogException(NID_UI_ANIM, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation type or position is invalid."); + return E_INVALID_ARG; + } + if (_pControlAnimatorImpl->IsAnimationSupported() == false) + { + r = _pControlAnimatorImpl->SetControlProperty(ANIMATION_TARGET_POSITION, *pAnimationBase); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set control property."); + r = E_SYSTEM; + } + + delete pAnimationBase; + + return r; + } + else + { + _pControlAnimatorImpl->SetLogicalBounds(controlRef.GetBounds()); + _pControlAnimatorImpl->SetControlLogicalBounds(ANIMATION_TARGET_POSITION, *pAnimationBase); + + bool disable = false; + bool propagation = false; + + result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation."); + + r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation."); + + r = controlRef.SetBounds(_pControlAnimatorImpl->GetLogicalBounds()); + + if (propagation) + { + _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + } + if (disable) + { + _pControlAnimatorImpl->DisableImplicitAnimation(disable); + } + + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds."); + r = _pControlAnimatorImpl->SetAnimation(ANIMATION_TARGET_POSITION, *pAnimationBase, ANIMATION_TRIGGER_POSITION_CHANGE); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + } + else + { + Rectangle logicalBounds(x, y, controlBounds.width, controlBounds.height); + + _pControlAnimatorImpl->SetLogicalBounds(logicalBounds); + + //Need to call control bounds inside StartCustomImplicitAnimation + r = _pControlAnimatorImpl->StartCustomImplicitAnimation(ANIMATION_TRIGGER_POSITION_CHANGE, x, y, controlBounds.width, + controlBounds.height, + false); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set logical bounds."); + } + + //When Control's property is set with End Bounds in Custom Implicit animation params, it should return from here without animation + if (_pControlAnimatorImpl->IsAnimationSupported() == false) + { + return E_SUCCESS; + } + + _pControlAnimatorImpl->SetAnimationTargetStatus(ANIMATION_TRIGGER_POSITION_CHANGE); + + return r; + +CATCH: + if (pAnimationBase) + { + if (_pControlAnimatorImpl->DestroyAnimation(*pAnimationBase, ANIMATION_TARGET_POSITION) == E_SUCCESS) + { + pAnimationBase = null; + } + else + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to destroy animation."); + r = E_SYSTEM; + } + } + + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->DestroyAnimation(activeAnimationCount) == E_SUCCESS), + E_SYSTEM, "A system error has been occurred. Failed to destroy animation."); + + return r; +} + +result +ControlAnimator::SetPosition(const Point& Position) +{ + return SetPosition(Position.x, Position.y); +} + +result +ControlAnimator::SetSize(int width, int height) +{ + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationTargetAnimating(ANIMATION_TARGET_SIZE) == false), E_INVALID_OPERATION, "Same AnimationTargetType is being animated."); + SysTryReturnResult(NID_UI_ANIM, ((width > 0) && (height > 0)), E_INVALID_ARG, "Invalid argument(s) is used. width = %d, height = %d", width, height); + + result r = E_SUCCESS; + Control& controlRef = _pControlAnimatorImpl->GetControl(); + Rectangle controlBounds = controlRef.GetBounds(); + Dimension newSize = Dimension(width, height); + Dimension currentSize = controlRef.GetSize(); + + SysTryReturnResult(NID_UI_ANIM, (controlRef.IsResizable()), E_UNSUPPORTED_OPERATION, "Bounds cannot be modified."); + + //CustomControl Bounds Condition check + CustomControlBase* pControlBase = dynamic_cast< CustomControlBase* >(&controlRef); + if (pControlBase) + { + Dimension dim(width, height); + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(_pControlAnimatorImpl->GetControl()); + pControlImpl->OnEvaluateSize(dim); + } + else + { + SysTryReturnResult(NID_UI_ANIM, !((width < controlRef.GetMinimumSize().width) || + (height < controlRef.GetMinimumSize().height) || + (width > controlRef.GetMaximumSize().width) || + (height > controlRef.GetMaximumSize().height)), E_UNSUPPORTED_OPERATION, "Bounds cannot be modified."); + } + + int activeAnimationCount = _pControlAnimatorImpl->GetActiveAnimationListCount(); + AnimationBase* pAnimationBase = null; + + if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_SIZE_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE) + { + if (currentSize == newSize) + { + return E_SUCCESS; + } + + DimensionAnimation* pDimensionAnim = new (std::nothrow) DimensionAnimation(currentSize, newSize, 400, ANIMATION_INTERPOLATOR_LINEAR); + SysTryReturnResult(NID_UI_ANIM, (pDimensionAnim), E_OUT_OF_MEMORY, "Memory allocation failed."); + + pAnimationBase = pDimensionAnim; + + Rectangle rect(0, 0, width, height); + + if (!(_pControlAnimatorImpl->IsAnimatable(ANIMATION_TARGET_SIZE, rect, pAnimationBase, ANIMATION_TRIGGER_SIZE_CHANGE))) + { + delete pAnimationBase; + + SysLogException(NID_UI_ANIM, E_INVALID_ARG, "Invalid argument(s) is used. Animation type or size is invalid."); + return E_INVALID_ARG; + } + + if (_pControlAnimatorImpl->IsAnimationSupported() == false) + { + r = _pControlAnimatorImpl->SetControlProperty(ANIMATION_TARGET_SIZE, *pAnimationBase); + + if (E_SUCCESS != r) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Control property is not set."); + r = E_SYSTEM; + } + + delete pAnimationBase; + + return r; + } + else + { + _pControlAnimatorImpl->SetLogicalBounds(controlRef.GetBounds()); + _pControlAnimatorImpl->SetControlLogicalBounds(ANIMATION_TARGET_SIZE, *pAnimationBase); + + bool disable = false; + bool propagation = false; + + result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation."); + + r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation."); + + r = controlRef.SetBounds(_pControlAnimatorImpl->GetLogicalBounds()); + + if (propagation) + { + _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + } + if (disable) + { + _pControlAnimatorImpl->DisableImplicitAnimation(disable); + } + + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds."); + + //Play the animation + r = _pControlAnimatorImpl->SetAnimation(ANIMATION_TARGET_SIZE, *pAnimationBase, ANIMATION_TRIGGER_SIZE_CHANGE); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + Rectangle logicalBounds(controlBounds.x, controlBounds.y, width, height); + _pControlAnimatorImpl->SetLogicalBounds(logicalBounds); + //Call control set bounds inside StartCustomImplicitAnimation + //start custom Implicit animation + r = _pControlAnimatorImpl->StartCustomImplicitAnimation(ANIMATION_TRIGGER_SIZE_CHANGE, controlBounds.x, controlBounds.y, width, height, false); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start custom implicit animation."); + } + //When Control's property is set with End Bounds in Custom Implicit animation params, it should return from here without animation + if (_pControlAnimatorImpl->IsAnimationSupported() == false) + { + return E_SUCCESS; + } + + _pControlAnimatorImpl->SetAnimationTargetStatus(ANIMATION_TRIGGER_SIZE_CHANGE); + + return r; + +CATCH: + if (pAnimationBase) + { + if (_pControlAnimatorImpl->DestroyAnimation(*pAnimationBase, ANIMATION_TARGET_SIZE) != E_SUCCESS) + { + pAnimationBase = null; + } + else + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to destroy animation."); + r = E_SYSTEM; + } + } + + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->DestroyAnimation(activeAnimationCount) == E_SUCCESS), + E_SYSTEM, "A system error has been occurred. Failed to destroy animation."); + + return r; +} + +result +ControlAnimator::SetSize(const Dimension& size) +{ + return SetSize(size.width, size.height); +} + +result +ControlAnimator::SetBounds(int x, int y, int width, int height) +{ + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationTargetAnimating(ANIMATION_TARGET_POSITION) == false), E_INVALID_OPERATION, "Same AnimationTargetType being animated."); + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationTargetAnimating(ANIMATION_TARGET_SIZE) == false), E_INVALID_OPERATION, "Same AnimationTargetType being animated."); + SysTryReturnResult(NID_UI_ANIM, (width >= 0 && height >= 0), E_INVALID_ARG, "Invalid argument(s) is used. width = %d, height = %d", width, height); + + result r = E_SUCCESS; + Control& controlRef = _pControlAnimatorImpl->GetControl(); + Rectangle newBounds = Rectangle(x, y, width, height); + Rectangle currentBounds = controlRef.GetBounds(); + + SysTryReturnResult(NID_UI_ANIM, !((controlRef.IsMovable() == false) || (controlRef.IsResizable() == false)), E_UNSUPPORTED_OPERATION, "Bounds cannot be modified."); + + if (controlRef.IsResizable() == true) + { + //CustomControl Bounds Condition check + CustomControlBase* pControlBase = dynamic_cast< CustomControlBase* >(&controlRef); + + if (pControlBase) + { + Rectangle rect(x, y, width, height); + _ControlImpl* pControlImpl = _ControlImpl::GetInstance(_pControlAnimatorImpl->GetControl()); + pControlImpl->OnBoundsChanging(rect); + } + else + { + SysTryReturnResult(NID_UI_ANIM, !((width < controlRef.GetMinimumSize().width) || + (height < controlRef.GetMinimumSize().height) || + (width > controlRef.GetMaximumSize().width) || + (height > controlRef.GetMaximumSize().height)), E_UNSUPPORTED_OPERATION, "Bounds cannot be modified."); + } + } + + Point newPosition = Point(x, y); + Point currentPosition = controlRef.GetPosition(); + Dimension newSize = Dimension(width, height); + Dimension currentSize = controlRef.GetSize(); + int activeAnimationCount = _pControlAnimatorImpl->GetActiveAnimationListCount(); + AnimationBase* pPointAnimationBase = null; + AnimationBase* pDimensionAnimationBase = null; + Rectangle logicalBounds(x, y, width, height); + _pControlAnimatorImpl->SetLogicalBounds(logicalBounds); + + if ((_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_POSITION_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE) && + (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_SIZE_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE)) + { + if (currentBounds == newBounds) + { + return E_SUCCESS; + } + } + + //Position Animation + if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_POSITION_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE) + { + pPointAnimationBase = new (std::nothrow) PointAnimation(currentPosition, newPosition, 400, ANIMATION_INTERPOLATOR_LINEAR); + SysTryReturnResult(NID_UI_ANIM, (pPointAnimationBase), E_OUT_OF_MEMORY, "Memory allocation failed."); + + if (_pControlAnimatorImpl->IsAnimationSupported() == false) + { + r = _pControlAnimatorImpl->SetControlProperty(ANIMATION_TARGET_POSITION, *pPointAnimationBase); + + delete pPointAnimationBase; + pPointAnimationBase = null; + + //Do not return if success, set size Bounds and then return. + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Control property is not set."); + } + else + { + //Create and set the animation to the layer + _pControlAnimatorImpl->SetControlLogicalBounds(ANIMATION_TARGET_POSITION, *pPointAnimationBase); + + bool disable = false; + bool propagation = false; + + result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation."); + + r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation."); + + r = controlRef.SetBounds(_pControlAnimatorImpl->GetLogicalBounds()); + + if (propagation) + { + _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + } + if (disable) + { + _pControlAnimatorImpl->DisableImplicitAnimation(disable); + } + + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds."); + + r = _pControlAnimatorImpl->SetAnimation(ANIMATION_TARGET_POSITION, *pPointAnimationBase, ANIMATION_TRIGGER_POSITION_CHANGE); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + //call control Setbounds API inside StartCustomImplicitAnimation + r = _pControlAnimatorImpl->StartCustomImplicitAnimation(ANIMATION_TRIGGER_POSITION_CHANGE, x, y, width, height, false); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start custom implicit animation."); + } + + //Size Animation + if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_SIZE_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE) + { + DimensionAnimation* pDimensionAnim = new (std::nothrow) DimensionAnimation(currentSize, newSize, 400, ANIMATION_INTERPOLATOR_LINEAR); + SysTryReturnResult(NID_UI_ANIM, (pDimensionAnim), E_OUT_OF_MEMORY, "Memory allocation failed."); + pDimensionAnimationBase = pDimensionAnim; + + if (_pControlAnimatorImpl->IsAnimationSupported() == false) + { + r = _pControlAnimatorImpl->SetControlProperty(ANIMATION_TARGET_SIZE, *pDimensionAnimationBase); + if (E_SUCCESS != r) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Control property is not set."); + r = E_SYSTEM; + } + + delete pDimensionAnimationBase; + + return r; + } + else + { + _pControlAnimatorImpl->SetControlLogicalBounds(ANIMATION_TARGET_SIZE, *pDimensionAnimationBase); + + bool disable = false; + bool propagation = false; + + result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation."); + + r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation."); + + r = controlRef.SetBounds(_pControlAnimatorImpl->GetLogicalBounds()); + + if (propagation) + { + _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + } + if (disable) + { + _pControlAnimatorImpl->DisableImplicitAnimation(disable); + } + + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds."); + + r = _pControlAnimatorImpl->SetAnimation(ANIMATION_TARGET_SIZE, *pDimensionAnimationBase, ANIMATION_TRIGGER_SIZE_CHANGE); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + //call control setbounds inside StartCustomImplicitAnimation + r = _pControlAnimatorImpl->StartCustomImplicitAnimation(ANIMATION_TRIGGER_SIZE_CHANGE, x, y, width, height, false); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start custom implicit animation."); + } + + //When Control's property is set with End Bounds in Custom Implicit animation params, it should return from here without animation + if (_pControlAnimatorImpl->IsAnimationSupported() == false) + { + return E_SUCCESS; + } + + _pControlAnimatorImpl->SetAnimationTargetStatus(ANIMATION_TRIGGER_POSITION_CHANGE); + _pControlAnimatorImpl->SetAnimationTargetStatus(ANIMATION_TRIGGER_SIZE_CHANGE); + + return r; + +CATCH: + if (pPointAnimationBase) + { + if (_pControlAnimatorImpl->DestroyAnimation(*pPointAnimationBase, ANIMATION_TARGET_POSITION) != E_SUCCESS) + { + pPointAnimationBase = null; + } + else + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to destroy animation."); + r = E_SYSTEM; + } + } + if (pDimensionAnimationBase) + { + if (_pControlAnimatorImpl->DestroyAnimation(*pDimensionAnimationBase, ANIMATION_TARGET_SIZE) != E_SUCCESS) + { + pDimensionAnimationBase = null; + } + else + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to destroy animation."); + r = E_SYSTEM; + } + } + + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->DestroyAnimation(activeAnimationCount) == E_SUCCESS), + E_SYSTEM, "A system error has been occurred. Failed to destroy animation."); + + return r; +} + +result +ControlAnimator::SetBounds(const Rectangle& rect) +{ + return SetBounds(rect.x, rect.y, rect.width, rect.height); +} + +result +ControlAnimator::SetShowState(bool show) +{ + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationTargetAnimating(ANIMATION_TARGET_ALPHA) == false), E_INVALID_OPERATION, "Same AnimationTargetType being animated."); + + result r = E_SUCCESS; + Control& controlRef = _pControlAnimatorImpl->GetControl(); + int activeAnimationCount = _pControlAnimatorImpl->GetActiveAnimationListCount(); + bool currentShowState = controlRef.GetShowState(); + bool newShowState = show; + FloatAnimation* pFloatAnim = null; + AnimationBase* pAnimationBase = null; + + if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_SHOW_STATE_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE) + { + SysTryReturnResult(NID_UI_ANIM, (currentShowState != newShowState), E_SUCCESS, "Current show state of control is same as new show state."); + + pFloatAnim = new (std::nothrow) FloatAnimation(((newShowState) ? (0.0f) : (1.0f)), ((newShowState) ? (1.0f) : (0.0f)), 400, ANIMATION_INTERPOLATOR_LINEAR); + SysTryReturnResult(NID_UI_ANIM, (pFloatAnim), E_OUT_OF_MEMORY, "Memory allocation failed."); + pAnimationBase = pFloatAnim; + + Rectangle rect(0, 0, 0, 0); + + if (!(_pControlAnimatorImpl->IsAnimatable(ANIMATION_TARGET_ALPHA, rect, pAnimationBase, ANIMATION_TRIGGER_SHOW_STATE_CHANGE))) + { + delete pAnimationBase; + + SysLogException(NID_UI_ANIM, E_INVALID_ARG, "Invalid argument(s) is used. Custom implicit animation parameters are wrong."); + return E_INVALID_ARG; + } + if (_pControlAnimatorImpl->IsAnimationSupported() == false) + { + r = _pControlAnimatorImpl->SetControlProperty(ANIMATION_TARGET_ALPHA, *pAnimationBase); + if (E_SUCCESS != r) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Control property is not set."); + r = E_SYSTEM; + } + + delete pAnimationBase; + + return r; + } + else + { + _pControlAnimatorImpl->SetControlShowState(ANIMATION_TARGET_ALPHA, *pAnimationBase); + + + bool disable = false; + bool propagation = false; + + result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation."); + + r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation."); + + r = _pControlAnimatorImpl->GetControl().SetShowState((_pControlAnimatorImpl->GetShowState())); + + if (propagation) + { + _pControlAnimatorImpl->DisableVisualElementPropagation(propagation); + } + if (disable) + { + _pControlAnimatorImpl->DisableImplicitAnimation(disable); + } + + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set show state."); + + r = _pControlAnimatorImpl->SetAnimation(ANIMATION_TARGET_ALPHA, *pAnimationBase, ANIMATION_TRIGGER_SHOW_STATE_CHANGE); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + _pControlAnimatorImpl->SetShowState(newShowState); + //Call control set show state inside StartCustomImplicitAnimation + r = _pControlAnimatorImpl->StartCustomImplicitAnimation(ANIMATION_TRIGGER_SHOW_STATE_CHANGE, 0, 0, 0, 0, newShowState); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start custom implicit animation."); + } + //When Control's property is set with End ShowState in Custom Implicit animation params, it should return from here without animation + if (_pControlAnimatorImpl->IsAnimationSupported() == false) + { + return E_SUCCESS; + } + + _pControlAnimatorImpl->SetAnimationTargetStatus(ANIMATION_TRIGGER_SHOW_STATE_CHANGE); + + return r; + +CATCH: + if (pAnimationBase) + { + if (_pControlAnimatorImpl->DestroyAnimation(*pAnimationBase, ANIMATION_TARGET_ALPHA) != E_SUCCESS) + { + pAnimationBase = null; + } + else + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to deallocate memory."); + r = E_SYSTEM; + } + } + + if (_pControlAnimatorImpl->DestroyAnimation(activeAnimationCount) != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to deallocate memory."); + r = E_SYSTEM; + } + SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->DestroyAnimation(activeAnimationCount) == E_SUCCESS), + E_SYSTEM, "A system error has been occurred. Failed to destroy animation."); + return r; +} + +bool +ControlAnimator::IsAnimationSupported(AnimationTargetType animTarget) const +{ + switch (animTarget) + { + case ANIMATION_TARGET_POSITION: + return _pControlAnimatorImpl->GetControl().IsMovable(); + + case ANIMATION_TARGET_SIZE: + return _pControlAnimatorImpl->GetControl().IsResizable(); + + case ANIMATION_TARGET_ALPHA: + return true; + + case ANIMATION_TARGET_ROTATION: + return true; + + default: + return false; + } +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimDimensionAnimation.cpp b/src/ui/animations/FUiAnimDimensionAnimation.cpp new file mode 100644 index 0000000..0459dd9 --- /dev/null +++ b/src/ui/animations/FUiAnimDimensionAnimation.cpp @@ -0,0 +1,431 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimDimensionAnimation.cpp + * @brief This file contains implementation of DimensionAnimation class + * + * This file contains implementation of DimensionAnimation class. + */ + +#include + +#include +#include +#include + +#include "FUiAnim_DimensionAnimationImpl.h" +#include "FUiAnim_AnimationBaseImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base::Collection; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +DimensionAnimation::DimensionAnimation(void) + : _pDimensionAnimationImpl(null) +{ +} + +DimensionAnimation::DimensionAnimation(const Dimension& startValue, const Dimension& endValue, long duration, AnimationInterpolatorType interpolator) + : AnimationBase(duration, interpolator) + , _pDimensionAnimationImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + SysTryReturnVoidResult(NID_UI_ANIM, (startValue.height >= 0 && startValue.width >= 0 && endValue.height >= 0 && endValue.width >= 0), + E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. startValue = (%d, %d), endValue = (%d, %d)", startValue.width, startValue.height, endValue.width, endValue.height); + + _pDimensionAnimationImpl = new (std::nothrow) _DimensionAnimationImpl(this); + if (_pDimensionAnimationImpl == null) + { + SysLogException(NID_UI_ANIM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory Allocation failed."); + + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + + return; + } + + _pDimensionAnimationImpl->startValue = startValue; + _pDimensionAnimationImpl->endValue = endValue; +} + +DimensionAnimation::~DimensionAnimation(void) +{ + delete _pDimensionAnimationImpl; + _pDimensionAnimationImpl = null; +} + +DimensionAnimation::DimensionAnimation(const DimensionAnimation& dimensionAnimation) + : AnimationBase(dimensionAnimation) + , _pDimensionAnimationImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + _pDimensionAnimationImpl = new (std::nothrow) _DimensionAnimationImpl(this); + SysTryCatch(NID_UI_ANIM, (_pDimensionAnimationImpl != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + dimensionAnimation.GetAnchor(_pDimensionAnimationImpl->anchorX, _pDimensionAnimationImpl->anchorY); + + r = _pDimensionAnimationImpl->CopyDimensionAnimationValue(dimensionAnimation); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to copy dimension animation."); + + return; + +CATCH: + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + delete _pDimensionAnimationImpl; + _pDimensionAnimationImpl = null; +} + +DimensionAnimation& +DimensionAnimation::operator =(const DimensionAnimation& rhs) +{ + ClearLastResult(); + + if ((&rhs) != this) + { + result r = E_SUCCESS; + + AnimationBase::operator =(rhs); + + rhs.GetAnchor(_pDimensionAnimationImpl->anchorX, _pDimensionAnimationImpl->anchorY); + + r = _pDimensionAnimationImpl->CopyDimensionAnimationValue(rhs); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to copy dimension animation."); + } + + return *this; +} + +bool +DimensionAnimation::operator ==(const DimensionAnimation& dimensionAnimation) const +{ + result r = E_SUCCESS; + + if (_pAnimationBaseImpl->keyFrameList.GetCount() != dimensionAnimation._pAnimationBaseImpl->keyFrameList.GetCount()) + { + return false; + } + + ArrayListT< long >* pKeyList1 = null; + ArrayListT< long >* pKeyList2 = null; + ICollectionT< long >* pKeyN = _pAnimationBaseImpl->keyFrameList.GetKeysN(); + ICollectionT< long >* pKeyN1 = dimensionAnimation._pAnimationBaseImpl->keyFrameList.GetKeysN(); + + if (_pAnimationBaseImpl->keyFrameList.GetCount() != 0) + { + pKeyList1 = new (std::nothrow) ArrayListT< long >; + SysTryCatch(NID_UI_ANIM, (!(pKeyList1 == null || pKeyN == null)), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList1->Construct(*pKeyN); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + + pKeyList2 = new (std::nothrow) ArrayListT< long >; + SysTryCatch(NID_UI_ANIM, !(pKeyList2 == null || pKeyN1 == null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList2->Construct(*pKeyN1); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + + ComparerT< long > comparer; + + r = pKeyList1->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = pKeyList2->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + long time1 = 0; + long time2 = 0; + Object* pObjValue1 = null; + Object* pObjValue2 = null; + + for (int index = 0; index < _pAnimationBaseImpl->keyFrameList.GetCount(); index++) + { + pKeyList1->GetAt(index, time1); + pKeyList2->GetAt(index, time2); + if (time1 != time2) + { + goto CATCH; + } + _pAnimationBaseImpl->keyFrameList.GetValue(time1, pObjValue1); + dimensionAnimation._pAnimationBaseImpl->keyFrameList.GetValue(time2, pObjValue2); + if ((!pObjValue1) && (!pObjValue2)) + { + continue; + } + else if ((!pObjValue1) || (!pObjValue2)) + { + goto CATCH; + } + Dimension* pDimValue1 = dynamic_cast< Dimension* >(pObjValue1); + if (pDimValue1 == null) + { + goto CATCH; + } + + Dimension* pDimValue2 = dynamic_cast< Dimension* >(pObjValue2); + if (pDimValue2 == null) + { + goto CATCH; + } + if (!(pDimValue1->Equals(*pDimValue2))) + { + goto CATCH; + } + + } + + delete pKeyList1; + delete pKeyList2; + } + + delete pKeyN; + delete pKeyN1; + + if (!((_pDimensionAnimationImpl->startValue).Equals(dimensionAnimation._pDimensionAnimationImpl->startValue)) || + !((_pDimensionAnimationImpl->endValue).Equals(dimensionAnimation._pDimensionAnimationImpl->endValue))) + { + return false; + } + + if (((Float::Compare(_pDimensionAnimationImpl->anchorX, dimensionAnimation._pDimensionAnimationImpl->anchorX)) != 0) && + ((Float::Compare(_pDimensionAnimationImpl->anchorY, dimensionAnimation._pDimensionAnimationImpl->anchorY)) != 0)) + { + return false; + } + + return _pAnimationBaseImpl->CompareTimingValues(dimensionAnimation); + +CATCH: + delete pKeyN; + delete pKeyN1; + delete pKeyList1; + delete pKeyList2; + + return false; +} + +bool +DimensionAnimation::operator !=(const DimensionAnimation& rhs) const +{ + return !(*this == rhs); +} + +bool +DimensionAnimation::Equals(const Object& obj) const +{ + const DimensionAnimation* pDimAnim = dynamic_cast< const DimensionAnimation* >(&obj); + if (pDimAnim == null) + { + return false; + } + + return (*this == *pDimAnim); +} + +int +DimensionAnimation::GetHashCode(void) const +{ + return (((int) GetRepeatCount()) + ((int) GetOffset()) + ((int) GetDuration()) + ((int) GetDelay())); +} + +result +DimensionAnimation::SetAnchor(float anchorX, float anchorY) +{ + SysTryReturnResult(NID_UI_ANIM, (anchorX >= 0.0 && anchorX <= 1.0 && anchorY >= 0.0 && anchorY <= 1.0), E_INVALID_ARG, "Invalid argument(s) is used. anchorX = %f, anchorY = %f.", anchorX, anchorY); + + _pDimensionAnimationImpl->anchorX = anchorX; + _pDimensionAnimationImpl->anchorY = anchorY; + + return E_SUCCESS; +} + +void +DimensionAnimation::GetAnchor(float& anchorX, float& anchorY) const +{ + anchorX = _pDimensionAnimationImpl->anchorX; + anchorY = _pDimensionAnimationImpl->anchorY; + + return; +} + +result +DimensionAnimation::GetAnimatedValue(long currentTime, Dimension& animatedValue) const +{ + SysTryReturnResult(NID_UI_ANIM, (currentTime >= 0 && currentTime <= GetDuration()), E_INVALID_ARG, "Invalid argument(s) is used. currentTime = %ld", currentTime); + + float actualProgress = _pAnimationBaseImpl->GetActualProgressValue(currentTime); + SysTryReturnResult(NID_UI_ANIM, (actualProgress >= 0.0f && actualProgress <= 1.0f), E_SYSTEM, "A system error has been occurred. Failed to calculate progress."); + + return _pDimensionAnimationImpl->GetAnimatedValue(actualProgress, animatedValue); +} + +result +DimensionAnimation::AddKeyFrame(long time, const Dimension& value) +{ + SysTryReturnResult(NID_UI_ANIM, (time > 0 && time != _pAnimationBaseImpl->duration), E_INVALID_ARG, "Invalid argument(s) is used. time = %ld", time); + + result r = E_SUCCESS; + Dimension* pDimObj = null; + + if (time > _pAnimationBaseImpl->duration) + { + pDimObj = new (std::nothrow) Dimension(_pDimensionAnimationImpl->endValue); + SysTryReturnResult(NID_UI_ANIM, (pDimObj), E_OUT_OF_MEMORY, "Memory allocation failed."); + r = _pAnimationBaseImpl->keyFrameList.Add(_pAnimationBaseImpl->duration, dynamic_cast< Object* >(pDimObj)); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add to key frame list."); + + _pAnimationBaseImpl->duration = time; + _pDimensionAnimationImpl->endValue = value; + } + else + { + pDimObj = new (std::nothrow) Dimension(value); + SysTryReturnResult(NID_UI_ANIM, (pDimObj), E_OUT_OF_MEMORY, "Memory allocation failed."); + Object* pKeyValue = null; + _pAnimationBaseImpl->keyFrameList.GetValue(time, pKeyValue); + if (pKeyValue) + { + _pAnimationBaseImpl->keyFrameList.Remove(time); //If a key-value pair with the current key already exists, then remove the already existing entry + delete pKeyValue; + pKeyValue = null; + } + r = _pAnimationBaseImpl->keyFrameList.Add(time, dynamic_cast< Object* >(pDimObj)); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add to key frame list."); + } + + return r; +CATCH: + delete pDimObj; + pDimObj = null; + return r; +} + +result +DimensionAnimation::GetKeyFrameAt(int index, long& time, Dimension& value) const +{ + SysTryReturnResult(NID_UI_ANIM, (index >= 0 && index < _pAnimationBaseImpl->keyFrameList.GetCount()), + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index (%d) is out of range.", index); + + result r = E_SUCCESS; + Object* pObjValue = null; + Dimension* pDimValue = null; + ComparerT< long > comparer; + + ArrayListT< long >* pKeyList = new (std::nothrow) ArrayListT< long >; + ICollectionT< long >* pKeyN = _pAnimationBaseImpl->keyFrameList.GetKeysN(); + + SysTryCatch(NID_UI_ANIM, (pKeyList != null && pKeyN != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList->Construct(*pKeyN); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + SysTryCatch(NID_UI_ANIM, !(pKeyList->GetCount() <= 0), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Key list count is invalid."); + + r = pKeyList->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = pKeyList->GetAt(index, time); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get the time from list."); + + r = _pAnimationBaseImpl->keyFrameList.GetValue(time, pObjValue); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get key value."); + SysTryCatch(NID_UI_ANIM, (pObjValue != null), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get key frame."); + + pDimValue = dynamic_cast< Dimension* >(pObjValue); + if (pDimValue) + { + value = *pDimValue; + } + + //fall through + +CATCH: + delete pKeyN; + delete pKeyList; + + return r; +} + +result +DimensionAnimation::RemoveKeyFrame(long time) +{ + return _pAnimationBaseImpl->RemoveKeyFrame(time); +} + +result +DimensionAnimation::RemoveKeyFrameAt(int index) +{ + return _pAnimationBaseImpl->RemoveKeyFrameAt(index); +} + +result +DimensionAnimation::RemoveAllKeyFrames(void) +{ + return _pAnimationBaseImpl->RemoveAllKeyFrames(); +} + +result +DimensionAnimation::SetStartValue(const Dimension& startValue) +{ + SysTryReturnResult(NID_UI_ANIM, (startValue.width >= 0 && startValue.height >= 0), E_INVALID_ARG, "Invalid argument(s) is used. startValue = (%d, %d)", startValue.width, startValue.height); + + _pDimensionAnimationImpl->startValue = startValue; + + return E_SUCCESS; +} + +result +DimensionAnimation::SetEndValue(const Dimension& endValue) +{ + SysTryReturnResult(NID_UI_ANIM, (endValue.width >= 0 && endValue.height >= 0), E_INVALID_ARG, "Invalid argument(s) is used. endValue = (%d, %d)", endValue.width, endValue.height); + + _pDimensionAnimationImpl->endValue = endValue; + + return E_SUCCESS; +} + +Dimension +DimensionAnimation::GetStartValue(void) const +{ + return _pDimensionAnimationImpl->startValue; +} + +Dimension +DimensionAnimation::GetEndValue(void) const +{ + return _pDimensionAnimationImpl->endValue; +} + +AnimationType +DimensionAnimation::GetType(void) const +{ + return ANIMATION_TYPE_DIMENSION_ANIMATION; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimDiscreteTimingFunction.cpp b/src/ui/animations/FUiAnimDiscreteTimingFunction.cpp new file mode 100644 index 0000000..084fd71 --- /dev/null +++ b/src/ui/animations/FUiAnimDiscreteTimingFunction.cpp @@ -0,0 +1,75 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimDiscreteTimingFunction.cpp + * @brief This file contains implementation of DiscreteTimingFunction class + * + * This file contains implementation DiscreteTimingFunction class. + */ + +#include +#include + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +DiscreteTimingFunction::DiscreteTimingFunction(void) + : __triggerTimeProgress(1.0f) +{ + +} + +DiscreteTimingFunction::~DiscreteTimingFunction(void) +{ + +} + +float +DiscreteTimingFunction::CalculateProgress(float timeProgress) const +{ + if (timeProgress >= __triggerTimeProgress) + { + return 1.0f; + } + + return 0.0f; +} + +result +DiscreteTimingFunction::SetTriggerTimeProgress(float timeProgress) +{ + SysTryReturnResult(NID_UI_ANIM, (timeProgress >= 0.f && timeProgress <= 1.0f), E_INVALID_ARG, "Invalid argument(s) is used. timeProgress is invalid."); + + __triggerTimeProgress = timeProgress; + + return E_SUCCESS; +} + +float +DiscreteTimingFunction::GetTriggerTimeProgress(void) const +{ + return __triggerTimeProgress; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimDisplayContext.cpp b/src/ui/animations/FUiAnimDisplayContext.cpp new file mode 100644 index 0000000..a7cec95 --- /dev/null +++ b/src/ui/animations/FUiAnimDisplayContext.cpp @@ -0,0 +1,49 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimDisplayContext.cpp + * @brief This is the implementation file for DisplayContext class. + * + * This file contains implementation DisplayContext class. + */ + +#include "FUiAnimDisplayContext.h" +#include "FUiAnim_DisplayContextImpl.h" + +using namespace Tizen::Base; + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +DisplayContext::DisplayContext(void) + : _pDisplayContextImpl(null) +{ +} +DisplayContext::~DisplayContext(void) +{ + if(_pDisplayContextImpl) + { + delete _pDisplayContextImpl; + _pDisplayContextImpl = null; + } +} + +}}} + diff --git a/src/ui/animations/FUiAnimEaseElasticInTimingFunction.cpp b/src/ui/animations/FUiAnimEaseElasticInTimingFunction.cpp new file mode 100644 index 0000000..e388f2b --- /dev/null +++ b/src/ui/animations/FUiAnimEaseElasticInTimingFunction.cpp @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimEaseElasticInTimingFunction.cpp + * @brief This file contains implementation of EaseElasticInTimingFunction class + * + * This file contains implementation EaseElasticInTimingFunction class. + */ + +#include + +#include +#include + +#include + +#include "FUi_Math.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +EaseElasticInTimingFunction::EaseElasticInTimingFunction(void) + : __period(0.4f) +{ +} + +EaseElasticInTimingFunction::~EaseElasticInTimingFunction(void) +{ +} + +result +EaseElasticInTimingFunction::SetPeriod(float period) +{ + SysTryReturnResult(NID_UI_ANIM, (period > 0.f && period < 1.0f), E_INVALID_ARG, "Invalid argument(s) is used. period is invalid."); + + __period = period; + + return E_SUCCESS; +} +float +EaseElasticInTimingFunction::GetPeriod(void) const +{ + return __period; +} + +float +EaseElasticInTimingFunction::CalculateProgress(float timeProgress) const +{ + if (_FloatCompare(timeProgress, 0.0f) || _FloatCompare(timeProgress, 1.0f)) + { + return timeProgress; + } + + float s = __period / 4.0f; + timeProgress -= 1.0f; + + return -powf(2.0f, 10.0f * timeProgress) * sinf((timeProgress - s) * static_cast< float >(M_PI) * 2.0f / __period); +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimEaseElasticOutTimingFunction.cpp b/src/ui/animations/FUiAnimEaseElasticOutTimingFunction.cpp new file mode 100644 index 0000000..86b9271 --- /dev/null +++ b/src/ui/animations/FUiAnimEaseElasticOutTimingFunction.cpp @@ -0,0 +1,78 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimEaseElasticOutTimingFunction.cpp + * @brief This file contains implementation of EaseElasticOutTimingFunction class + * + * This file contains implementation EaseElasticOutTimingFunction class. + */ + +#include + +#include +#include + +#include + +#include "FUi_Math.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +EaseElasticOutTimingFunction::EaseElasticOutTimingFunction(void) + : __period(0.4f) +{ +} + +EaseElasticOutTimingFunction::~EaseElasticOutTimingFunction(void) +{ +} + +result +EaseElasticOutTimingFunction::SetPeriod(float period) +{ + SysTryReturnResult(NID_UI_ANIM, (period > 0.f && period < 1.0f), E_INVALID_ARG, "Invalid argument(s) is used. period is invalid."); + + __period = period; + + return E_SUCCESS; +} + +float +EaseElasticOutTimingFunction::GetPeriod(void) const +{ + return __period; +} + +float +EaseElasticOutTimingFunction::CalculateProgress(float timeProgress) const +{ + if (_FloatCompare(timeProgress, 0.0f) || _FloatCompare(timeProgress, 1.0f)) + { + return timeProgress; + } + + float s = __period / 4.0f; + + return powf(2.0f, -10.0f * timeProgress) * sinf((timeProgress - s) * static_cast< float >(M_PI) * 2.0f / __period) + 1.0f; +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimEaseInOutTimingFunction.cpp b/src/ui/animations/FUiAnimEaseInOutTimingFunction.cpp new file mode 100644 index 0000000..1c2fa3a --- /dev/null +++ b/src/ui/animations/FUiAnimEaseInOutTimingFunction.cpp @@ -0,0 +1,58 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimEaseInOutTimingFunction.cpp + * @brief This file contains implementation of EaseInOutTimingFunction class + * + * This file contains implementation EaseInOutTimingFunction class. + */ + +#include + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +EaseInOutTimingFunction::EaseInOutTimingFunction(void) +{ + +} + +EaseInOutTimingFunction::~EaseInOutTimingFunction(void) +{ + +} + +float +EaseInOutTimingFunction::CalculateProgress(float timeProgress) const +{ + // using cubic algorithm + if (timeProgress < 0.5f) + { + return 0.5f * powf(2.0f * timeProgress, 3); + } + + return 0.5f * powf(2.0f * (timeProgress - 1.0f), 3) + 1.0f; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimEaseInTimingFunction.cpp b/src/ui/animations/FUiAnimEaseInTimingFunction.cpp new file mode 100644 index 0000000..ee96f0b --- /dev/null +++ b/src/ui/animations/FUiAnimEaseInTimingFunction.cpp @@ -0,0 +1,53 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimEaseInTimingFunction.cpp + * @brief This file contains implementation of EaseInTimingFunction class + * + * This file contains implementation EaseInTimingFunction class. + */ + +#include + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +EaseInTimingFunction::EaseInTimingFunction(void) +{ + +} + +EaseInTimingFunction::~EaseInTimingFunction(void) +{ + +} + +float +EaseInTimingFunction::CalculateProgress(float timeProgress) const +{ + // using cubic algorithm + return powf(timeProgress, 3); +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimEaseOutInTimingFunction.cpp b/src/ui/animations/FUiAnimEaseOutInTimingFunction.cpp new file mode 100644 index 0000000..7886cac --- /dev/null +++ b/src/ui/animations/FUiAnimEaseOutInTimingFunction.cpp @@ -0,0 +1,53 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimEaseOutInTimingFunction.cpp + * @brief This file contains implementation of EaseOutInTimingFunction class + * + * This file contains implementation EaseOutInTimingFunction class. + */ + +#include + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +EaseOutInTimingFunction::EaseOutInTimingFunction(void) +{ + +} + +EaseOutInTimingFunction::~EaseOutInTimingFunction(void) +{ + +} + +float +EaseOutInTimingFunction::CalculateProgress(float timeProgress) const +{ + // using cubic algorithm + return 0.5f * powf(2.0f * timeProgress - 1.0f, 3) + 0.5f; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimEaseOutTimingFunction.cpp b/src/ui/animations/FUiAnimEaseOutTimingFunction.cpp new file mode 100644 index 0000000..4348f92 --- /dev/null +++ b/src/ui/animations/FUiAnimEaseOutTimingFunction.cpp @@ -0,0 +1,53 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimEaseOutTimingFunction.cpp + * @brief This file contains implementation of EaseOutTimingFunction class + * + * This file contains implementation EaseOutTimingFunction class. + */ + +#include + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +EaseOutTimingFunction::EaseOutTimingFunction(void) +{ + +} + +EaseOutTimingFunction::~EaseOutTimingFunction(void) +{ + +} + +float +EaseOutTimingFunction::CalculateProgress(float timeProgress) const +{ + // using cubic algorithm + return powf(timeProgress - 1.0f, 3) + 1.0f; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimExpInTimingFunction.cpp b/src/ui/animations/FUiAnimExpInTimingFunction.cpp new file mode 100644 index 0000000..e1bda93 --- /dev/null +++ b/src/ui/animations/FUiAnimExpInTimingFunction.cpp @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimExpInTimingFunction.cpp + * @brief This file contains implementation of ExpInTimingFunction class + * + * This file contains implementation ExpInTimingFunction class. + */ + +#include + +#include +#include + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +ExpInTimingFunction::ExpInTimingFunction(void) + : __scale(0.0f) + , __divisor(0.0f) +{ + SetScaleValue(5.0f); +} + +ExpInTimingFunction::~ExpInTimingFunction(void) +{ + +} + +result +ExpInTimingFunction::SetScaleValue(float scale) +{ + SysTryReturnResult(NID_UI_ANIM, (scale > 0.f), E_INVALID_ARG, "Invalid argument(s) is used. scale = %f", scale); + + __scale = scale; + __divisor = expf(__scale) - 1.0f; + + return E_SUCCESS; +} +float +ExpInTimingFunction::GetScaleValue(void) const +{ + return __scale; +} + +float +ExpInTimingFunction::CalculateProgress(float timeProgress) const +{ + return (expf(__scale * timeProgress) - 1.0f) / __divisor; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimExpOutTimingFunction.cpp b/src/ui/animations/FUiAnimExpOutTimingFunction.cpp new file mode 100644 index 0000000..9baa36d --- /dev/null +++ b/src/ui/animations/FUiAnimExpOutTimingFunction.cpp @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimExpOutTimingFunction.cpp + * @brief This file contains implementation of ExpOutTimingFunction class + * + * This file contains implementation ExpOutTimingFunction class. + */ + +#include + +#include +#include + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +ExpOutTimingFunction::ExpOutTimingFunction(void) + : __scale(0.0f) + , __divisor(0.0f) +{ + SetScaleValue(5.0f); +} + +ExpOutTimingFunction::~ExpOutTimingFunction(void) +{ + +} + +result +ExpOutTimingFunction::SetScaleValue(float scale) +{ + SysTryReturnResult(NID_UI_ANIM, (scale > 0.f), E_INVALID_ARG, "Invalid argument(s) is used. scale = %f", scale); + + __scale = -scale; + __divisor = expf(__scale) - 1.0f; + + return E_SUCCESS; +} +float +ExpOutTimingFunction::GetScaleValue(void) const +{ + return -__scale; +} + +float +ExpOutTimingFunction::CalculateProgress(float timeProgress) const +{ + return (expf(__scale * timeProgress) - 1.0f) / __divisor; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimFloatAnimation.cpp b/src/ui/animations/FUiAnimFloatAnimation.cpp new file mode 100644 index 0000000..e0e4845 --- /dev/null +++ b/src/ui/animations/FUiAnimFloatAnimation.cpp @@ -0,0 +1,396 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimFloatAnimation.cpp + * @brief This file contains implementation of FloatAnimation class + * + * This file contains implementation of FloatAnimation class. + */ + +#include + +#include +#include + +#include + +#include "FUiAnim_AnimationBaseImpl.h" +#include "FUiAnim_FloatAnimationImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base::Collection; + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +FloatAnimation::FloatAnimation(void) + : _pFloatAnimationImpl(null) +{ +} + +FloatAnimation::FloatAnimation(float startValue, float endValue, long duration, AnimationInterpolatorType interpolator) + : AnimationBase(duration, interpolator) + , _pFloatAnimationImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + _pFloatAnimationImpl = new (std::nothrow) _FloatAnimationImpl(this); + if (_pFloatAnimationImpl == null) + { + SysLogException(NID_UI_ANIM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + + return; + } + + _pFloatAnimationImpl->startValue = startValue; + _pFloatAnimationImpl->endValue = endValue; +} + +FloatAnimation::~FloatAnimation(void) +{ + delete _pFloatAnimationImpl; + _pFloatAnimationImpl = null; +} + +FloatAnimation::FloatAnimation(const FloatAnimation& floatAnimation) + : AnimationBase(floatAnimation) + , _pFloatAnimationImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + _pFloatAnimationImpl = new (std::nothrow) _FloatAnimationImpl(this); + SysTryCatch(NID_UI_ANIM, (_pFloatAnimationImpl != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = _pFloatAnimationImpl->CopyFloatAnimationValue(floatAnimation); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to copy float animation value."); + + return; + +CATCH: + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + delete _pFloatAnimationImpl; + _pFloatAnimationImpl = null; +} + +FloatAnimation& +FloatAnimation::operator =(const FloatAnimation& floatAnimation) +{ + ClearLastResult(); + + if ((&floatAnimation) != this) + { + result r = E_SUCCESS; + + AnimationBase::operator =(floatAnimation); + + r = _pFloatAnimationImpl->CopyFloatAnimationValue(floatAnimation); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to copy float animation value."); + } + + return *this; +} + +bool +FloatAnimation::operator ==(const FloatAnimation& rhs) const +{ + result r = E_SUCCESS; + + if (_pAnimationBaseImpl->keyFrameList.GetCount() != rhs._pAnimationBaseImpl->keyFrameList.GetCount()) + { + return false; + } + + ArrayListT< long >* pKeyList1 = null; + ArrayListT< long >* pKeyList2 = null; + ICollectionT< long >* pKeyN = _pAnimationBaseImpl->keyFrameList.GetKeysN(); + ICollectionT< long >* pKeyN1 = rhs._pAnimationBaseImpl->keyFrameList.GetKeysN(); + + if (_pAnimationBaseImpl->keyFrameList.GetCount() != 0) + { + pKeyList1 = new (std::nothrow) ArrayListT< long >; + SysTryCatch(NID_UI_ANIM, (pKeyList1 && pKeyN), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList1->Construct(*pKeyN); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + + pKeyList2 = new (std::nothrow) ArrayListT< long >; + SysTryCatch(NID_UI_ANIM, (pKeyList2 && pKeyN1), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList2->Construct(*pKeyN1); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + + ComparerT< long > comparer; + + r = pKeyList1->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = pKeyList2->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + long time1 = 0; + long time2 = 0; + Object* pObjValue1 = null; + Object* pObjValue2 = null; + + for (int index = 0; index < _pAnimationBaseImpl->keyFrameList.GetCount(); index++) + { + pKeyList1->GetAt(index, time1); + pKeyList2->GetAt(index, time2); + if (time1 != time2) + { + goto CATCH; + } + _pAnimationBaseImpl->keyFrameList.GetValue(time1, pObjValue1); + rhs._pAnimationBaseImpl->keyFrameList.GetValue(time2, pObjValue2); + if ((!pObjValue1) && (!pObjValue2)) + { + continue; + } + else if ((!pObjValue1) || (!pObjValue2)) + { + goto CATCH; + } + + Float* pFlValue1 = dynamic_cast< Float* >(pObjValue1); + if (pFlValue1 == null) + { + goto CATCH; + } + + Float* pFlValue2 = dynamic_cast< Float* >(pObjValue2); + if (pFlValue2 == null) + { + goto CATCH; + } + if (!(pFlValue1->Equals(*pFlValue2))) + { + goto CATCH; + } + } + delete pKeyList1; + delete pKeyList2; + } + + delete pKeyN; + delete pKeyN1; + + if (!((_pFloatAnimationImpl->startValue).Equals(rhs._pFloatAnimationImpl->startValue)) + || !((_pFloatAnimationImpl->endValue).Equals(rhs._pFloatAnimationImpl->endValue))) + { + return false; + } + + return _pAnimationBaseImpl->CompareTimingValues(rhs); + +CATCH: + delete pKeyN; + delete pKeyN1; + delete pKeyList1; + delete pKeyList2; + + return false; +} + +bool +FloatAnimation::operator !=(const FloatAnimation& rhs) const +{ + return !(*this == rhs); +} + +bool +FloatAnimation::Equals(const Object& obj) const +{ + const FloatAnimation* pFloatAnim = dynamic_cast< const FloatAnimation* >(&obj); + + if (pFloatAnim == null) + { + return false; + } + + return (*this == *pFloatAnim); +} + +int +FloatAnimation::GetHashCode(void) const +{ + return (((int) GetRepeatCount()) + ((int) GetOffset()) + ((int) GetDuration()) + ((int) GetDelay())); +} + +result +FloatAnimation::GetAnimatedValue(long currentTime, float& animatedValue) const +{ + SysTryReturnResult(NID_UI_ANIM, (currentTime >= 0 && currentTime <= GetDuration()), E_INVALID_ARG, "Invalid argument(s) is used. currentTime = %ld", currentTime); + + float actualProgress = _pAnimationBaseImpl->GetActualProgressValue(currentTime); + SysTryReturnResult(NID_UI_ANIM, (actualProgress >= 0.0f && actualProgress <= 1.0f), E_SYSTEM, "A system error has been occurred. Failed to calculate progress."); + + return _pFloatAnimationImpl->GetAnimatedValue(actualProgress, animatedValue); +} + +result +FloatAnimation::AddKeyFrame(long time, float value) +{ + SysTryReturnResult(NID_UI_ANIM, (time > 0 && time != _pAnimationBaseImpl->duration), E_INVALID_ARG, "Invalid argument(s) is used. time = %ld", time); + + result r = E_SUCCESS; + Float* pFloatObj = null; + + if (time > _pAnimationBaseImpl->duration) + { + pFloatObj = new (std::nothrow) Float(_pFloatAnimationImpl->endValue); + SysTryReturnResult(NID_UI_ANIM, (pFloatObj), E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = _pAnimationBaseImpl->keyFrameList.Add(_pAnimationBaseImpl->duration, dynamic_cast< Object* >(pFloatObj)); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add to key frame list."); + + _pAnimationBaseImpl->duration = time; + _pFloatAnimationImpl->endValue = value; + } + else + { + pFloatObj = new (std::nothrow) Float(value); + SysTryReturnResult(NID_UI_ANIM, (pFloatObj), E_OUT_OF_MEMORY, "Memory allocation failed."); + + Object* pKeyValue = null; + _pAnimationBaseImpl->keyFrameList.GetValue(time, pKeyValue); + if (pKeyValue) + { + _pAnimationBaseImpl->keyFrameList.Remove(time); + + delete pKeyValue; + } + + r = _pAnimationBaseImpl->keyFrameList.Add(time, dynamic_cast< Object* >(pFloatObj)); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add to key frame list."); + } + + return r; + +CATCH: + delete pFloatObj; + return r; +} + +result +FloatAnimation::GetKeyFrameAt(int index, long& time, float& value) const +{ + SysTryReturnResult(NID_UI_ANIM, (index >= 0 && index < _pAnimationBaseImpl->keyFrameList.GetCount()), + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index (%d) is out of range.", index); + + result r = E_SUCCESS; + Object* pObjValue = null; + ComparerT< long > comparer; + Float* pFloatValue = null; + + ArrayListT< long >* pKeyList = new (std::nothrow) ArrayListT< long >; + ICollectionT< long >* pKeyN = _pAnimationBaseImpl->keyFrameList.GetKeysN(); + + SysTryCatch(NID_UI_ANIM, (pKeyList && pKeyN), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList->Construct(*pKeyN); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + SysTryCatch(NID_UI_ANIM, (pKeyList->GetCount() > 0), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Key list count is invalid."); + + r = pKeyList->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = pKeyList->GetAt(index, time); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = _pAnimationBaseImpl->keyFrameList.GetValue(time, pObjValue); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get key value."); + SysTryCatch(NID_UI_ANIM, (pObjValue != null), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get key frame."); + + pFloatValue = dynamic_cast< Float* >(pObjValue); + if (pFloatValue) + { + value = pFloatValue->ToFloat(); + } + + //fall through + +CATCH: + delete pKeyN; + delete pKeyList; + return r; +} + +result +FloatAnimation::RemoveKeyFrame(long time) +{ + return _pAnimationBaseImpl->RemoveKeyFrame(time); +} + +result +FloatAnimation::RemoveKeyFrameAt(int index) +{ + return _pAnimationBaseImpl->RemoveKeyFrameAt(index); +} + +result +FloatAnimation::RemoveAllKeyFrames(void) +{ + return _pAnimationBaseImpl->RemoveAllKeyFrames(); +} + +result +FloatAnimation::SetStartValue(float startValue) +{ + _pFloatAnimationImpl->startValue = startValue; + + return E_SUCCESS; + +} + +result +FloatAnimation::SetEndValue(float endValue) +{ + _pFloatAnimationImpl->endValue = endValue; + + return E_SUCCESS; +} + +float +FloatAnimation::GetStartValue(void) const +{ + return _pFloatAnimationImpl->startValue.ToFloat(); +} + +float +FloatAnimation::GetEndValue(void) const +{ + return _pFloatAnimationImpl->endValue.ToFloat(); +} + +AnimationType +FloatAnimation::GetType(void) const +{ + return ANIMATION_TYPE_FLOAT_ANIMATION; +} + +}}} // Tizen::Ui::Animations diff --git a/src/ui/animations/FUiAnimFrameAnimator.cpp b/src/ui/animations/FUiAnimFrameAnimator.cpp new file mode 100644 index 0000000..2e14065 --- /dev/null +++ b/src/ui/animations/FUiAnimFrameAnimator.cpp @@ -0,0 +1,200 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimFrameAnimator.cpp + * @brief This file contains implementation of FrameAnimator class + * + * This file contains implementation of FrameAnimator class. + */ + +#include + +#include + +#include +#include + +#include "FUiAnim_FrameAnimatorImpl.h" + +using namespace Tizen::Ui::Controls; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +///INIT_SYSCLASSTYPE(FrameAnimator); + +FrameAnimator::FrameAnimator(void) + : _pFrameAnimatorImpl(null) +{ +} + +FrameAnimator::~FrameAnimator(void) +{ + delete _pFrameAnimatorImpl; + _pFrameAnimatorImpl = null; +} + +result +FrameAnimator::Construct(const Frame& source) +{ + SysAssertf((_pFrameAnimatorImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + result r = E_SUCCESS; + + _pFrameAnimatorImpl = new (std::nothrow) _FrameAnimatorImpl(this); + SysTryReturnResult(NID_UI_ANIM, (_pFrameAnimatorImpl), E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = _pFrameAnimatorImpl->Construct(source); + + if (r != E_SUCCESS) + { + delete _pFrameAnimatorImpl; + _pFrameAnimatorImpl = null; + + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] Failed to construct _FrameAnimatorImpl instance."); + return E_SYSTEM; + } + + return E_SUCCESS; +} + +result +FrameAnimator::AddFrameAnimatorEventListener(IFrameAnimatorEventListener& listener) +{ + SysTryReturnResult(NID_UI_ANIM, _pFrameAnimatorImpl->IsAnimationSupported(), E_UNSUPPORTED_OPERATION, "Failed to add IFrameAnimatorEventListener instance as animation is unsupported."); + + result r = E_SUCCESS; + + r = _pFrameAnimatorImpl->AddFrameAnimatorEventListener(listener); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add IFrameAnimatorEventListener instance."); + + return r; +} + +result +FrameAnimator::RemoveFrameAnimatorEventListener(IFrameAnimatorEventListener& listener) +{ + SysTryReturnResult(NID_UI_ANIM, _pFrameAnimatorImpl->IsAnimationSupported(), E_UNSUPPORTED_OPERATION, "The animation is unsupported."); + + result r = E_SUCCESS; + + r = _pFrameAnimatorImpl->RemoveFrameAnimatorEventListener(listener); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to remove IFrameAnimatorEventListener instance."); + + return r; +} + +AnimatorStatus +FrameAnimator::GetStatus(void) const +{ + if (_pFrameAnimatorImpl->IsAnimationSupported()) + { + return _pFrameAnimatorImpl->GetFrameAnimatorStatus(); + } + + return ANIMATOR_STATUS_STOPPED; +} + +result +FrameAnimator::SetCurrentForm(const Form& form) +{ + SysTryReturnResult(NID_UI_ANIM, _pFrameAnimatorImpl->GetFrameAnimatorStatus() == ANIMATOR_STATUS_STOPPED, E_INVALID_OPERATION, "Frame animator is already animating."); + + result r = _pFrameAnimatorImpl->SetCurrentForm(form); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "Propagating."); + + return r; +} + +void +FrameAnimator::SetFormTransitionAnimation(FrameAnimatorFormTransitionAnimation animation, long duration, AnimationInterpolatorType interpolator) +{ + if (duration > 0 && duration <= 1000) + { + _pFrameAnimatorImpl->SetDuration(duration); + } + else + { + SysLog(NID_UI_ANIM, "[E_INVALID_ARG] Invalid argument(s) is used. duration =%d", duration); + } + + if (animation >= FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_LEFT + && animation < FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_MAX) + { + _pFrameAnimatorImpl->SetAnimationEffectType(animation); + } + else + { + SysLog(NID_UI_ANIM, "[E_INVALID_ARG] Invalid argument(s) is used. Effect type is invalid."); + } + + if (interpolator >= ANIMATION_INTERPOLATOR_LINEAR + && interpolator <= ANIMATION_INTERPOLATOR_BEZIER) + { + _pFrameAnimatorImpl->SetAnimInterpolatorType(interpolator); + } + else + { + SysLog(NID_UI_ANIM, "[E_INVALID_ARG] Invalid argument(s) is used. Interpolator type is invalid."); + } +} + +void +FrameAnimator::GetFormTransitionAnimation(FrameAnimatorFormTransitionAnimation& animation, long& duration, AnimationInterpolatorType& interpolator) const +{ + animation = _pFrameAnimatorImpl->GetAnimationEffectType(); + duration = _pFrameAnimatorImpl->GetDuration(); + interpolator = _pFrameAnimatorImpl->GetAnimInterpolatorType(); +} + +result +FrameAnimator::SetFormTransitionBezierControlPoints(float time1, float value1, float time2, float value2) +{ + SysTryReturnResult(NID_UI_ANIM, _pFrameAnimatorImpl->GetAnimInterpolatorType() == ANIMATION_INTERPOLATOR_BEZIER + , E_INVALID_OPERATION, "Interpolation type is non-bezier."); + SysTryReturnResult(NID_UI_ANIM, ((time1 >= 0.0f) && (time1 <= 1.0f)), E_INVALID_ARG, "Invalid argument(s) is used. time1 = %f", time1); + SysTryReturnResult(NID_UI_ANIM, ((value1 >= 0.0f) && (value1 <= 1.0f)), E_INVALID_ARG, "Invalid argument(s) is used. value1 = %f", value1); + SysTryReturnResult(NID_UI_ANIM, ((time2 >= 0.0f) && (time2 <= 1.0f)), E_INVALID_ARG, "Invalid argument(s) is used. time2 = %f", time2); + SysTryReturnResult(NID_UI_ANIM, ((value2 >= 0.0f) && (value2 <= 1.0f)), E_INVALID_ARG, "Invalid argument(s) is used. value2 = %f", value2); + + _pFrameAnimatorImpl->SetFormTransitionBezierControlPoints(time1, value1, time2, value2); + + return E_SUCCESS; +} + +result +FrameAnimator::GetFormTransitionBezierControlPoints(float& time1, float& value1, float& time2, float& value2) const +{ + SysTryReturnResult(NID_UI_ANIM, _pFrameAnimatorImpl->GetAnimInterpolatorType() == ANIMATION_INTERPOLATOR_BEZIER + , E_INVALID_OPERATION, "Interpolation type is non-bezier."); + + _pFrameAnimatorImpl->GetFormTransitionBezierControlPoints(time1, value1, time2, value2); + + return E_SUCCESS; +} + +result +FrameAnimator::StopAllAnimations(void) +{ + return _pFrameAnimatorImpl->StopAllAnimations(); +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimIVisualElementAnimationStatusEventListener.cpp b/src/ui/animations/FUiAnimIVisualElementAnimationStatusEventListener.cpp new file mode 100644 index 0000000..16925ba --- /dev/null +++ b/src/ui/animations/FUiAnimIVisualElementAnimationStatusEventListener.cpp @@ -0,0 +1,35 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIVisualElementAnimationStatusEventListener.cpp + * @brief This file contains implementation of IVisualElementAnimationStatusEventListener class + * + * This file contains implementation IVisualElementAnimationStatusEventListener class. + */ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +IVisualElementAnimationStatusEventListener::~IVisualElementAnimationStatusEventListener(void) +{ +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimIVisualElementAnimationTickEventListener.cpp b/src/ui/animations/FUiAnimIVisualElementAnimationTickEventListener.cpp new file mode 100644 index 0000000..df43d68 --- /dev/null +++ b/src/ui/animations/FUiAnimIVisualElementAnimationTickEventListener.cpp @@ -0,0 +1,36 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIVisualElementAnimationTickEventListener.cpp + * @brief This file contains implementation of IVisualElementAnimationTickEventListener class + * + * This file contains implementation IVisualElementAnimationTickEventListener class. + */ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +IVisualElementAnimationTickEventListener::~IVisualElementAnimationTickEventListener(void) +{ + +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimIVisualElementAnimationTimingFunction.cpp b/src/ui/animations/FUiAnimIVisualElementAnimationTimingFunction.cpp new file mode 100644 index 0000000..e84385e --- /dev/null +++ b/src/ui/animations/FUiAnimIVisualElementAnimationTimingFunction.cpp @@ -0,0 +1,42 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIVisualElementAnimationTimingFunction.cpp + * @brief This file contains implementation of IVisualElementAnimationTimingFunction class + * + * This file contains implementation IVisualElementAnimationTimingFunction class. + */ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +IVisualElementAnimationTimingFunction::IVisualElementAnimationTimingFunction(void) +{ + +} + +IVisualElementAnimationTimingFunction::~IVisualElementAnimationTimingFunction(void) +{ + +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimIVisualElementAnimationValueInterpolator.cpp b/src/ui/animations/FUiAnimIVisualElementAnimationValueInterpolator.cpp new file mode 100644 index 0000000..23a5f21 --- /dev/null +++ b/src/ui/animations/FUiAnimIVisualElementAnimationValueInterpolator.cpp @@ -0,0 +1,42 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIVisualElementAnimationValueInterpolator.cpp + * @brief This file contains implementation of IVisualElementAnimationValueInterpolator class + * + * This file contains implementation IVisualElementAnimationValueInterpolator class. + */ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + + +IVisualElementAnimationValueInterpolator::IVisualElementAnimationValueInterpolator(void) +{ + +} + +IVisualElementAnimationValueInterpolator::~IVisualElementAnimationValueInterpolator(void) +{ + +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimIntegerAnimation.cpp b/src/ui/animations/FUiAnimIntegerAnimation.cpp new file mode 100644 index 0000000..e042b93 --- /dev/null +++ b/src/ui/animations/FUiAnimIntegerAnimation.cpp @@ -0,0 +1,396 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimIntegerAnimation.cpp + * @brief This file contains implementation of IntegerAnimation.cpp class + * This file contains implementation of IntegerAnimation.cpp class. + */ + +#include + +#include +#include + +#include + +#include "FUiAnim_IntegerAnimationImpl.h" +#include "FUiAnim_AnimationBaseImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base::Collection; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +IntegerAnimation::IntegerAnimation(void) + : _pIntegerAnimationImpl(null) +{ +} + +IntegerAnimation::IntegerAnimation(int startValue, int endValue, long duration, AnimationInterpolatorType interpolator) + : AnimationBase(duration, interpolator) + , _pIntegerAnimationImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + _pIntegerAnimationImpl = new (std::nothrow) _IntegerAnimationImpl(this); + if (_pIntegerAnimationImpl == null) + { + SysLogException(NID_UI_ANIM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + + return; + } + + _pIntegerAnimationImpl->startValue = startValue; + _pIntegerAnimationImpl->endValue = endValue; +} + +IntegerAnimation::~IntegerAnimation(void) +{ + delete _pIntegerAnimationImpl; + _pIntegerAnimationImpl = null; +} + + +IntegerAnimation::IntegerAnimation(const IntegerAnimation& integerAnimation) + : AnimationBase(integerAnimation) + , _pIntegerAnimationImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + _pIntegerAnimationImpl = new (std::nothrow) _IntegerAnimationImpl(this); + SysTryCatch(NID_UI_ANIM, (_pIntegerAnimationImpl != null), , E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = _pIntegerAnimationImpl->CopyIntegerAnimationValue(integerAnimation); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to copy integer animation value."); + + return; + +CATCH: + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + delete _pIntegerAnimationImpl; + _pIntegerAnimationImpl = null; +} + +IntegerAnimation& +IntegerAnimation::operator =(const IntegerAnimation& rhs) +{ + ClearLastResult(); + + if ((&rhs) != this) + { + result r = E_SUCCESS; + + AnimationBase::operator =(rhs); + + r = _pIntegerAnimationImpl->CopyIntegerAnimationValue(rhs); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to copy integer animation."); + } + + return *this; +} + +bool +IntegerAnimation::operator ==(const IntegerAnimation& rhs) const +{ + result r = E_SUCCESS; + + if (_pAnimationBaseImpl->keyFrameList.GetCount() != rhs._pAnimationBaseImpl->keyFrameList.GetCount()) + { + return false; + } + + ArrayListT< long >* pKeyList1 = null; + ArrayListT< long >* pKeyList2 = null; + ICollectionT< long >* pKeyN = _pAnimationBaseImpl->keyFrameList.GetKeysN(); + ICollectionT< long >* pKeyN1 = rhs._pAnimationBaseImpl->keyFrameList.GetKeysN(); + + if (_pAnimationBaseImpl->keyFrameList.GetCount() != 0) + { + pKeyList1 = new (std::nothrow) ArrayListT< long >; + SysTryCatch(NID_UI_ANIM, (!(pKeyList1 == null || pKeyN == null)), , E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = pKeyList1->Construct(*pKeyN); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + + pKeyList2 = new (std::nothrow) ArrayListT< long >; + SysTryCatch(NID_UI_ANIM, !(pKeyList2 == null || pKeyN1 == null), , E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = pKeyList2->Construct(*pKeyN1); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + + ComparerT< long > comparer; + + r = pKeyList1->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = pKeyList2->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + long time1 = 0; + long time2 = 0; + Object* pObjValue1 = null; + Object* pObjValue2 = null; + for (int index = 0; index < _pAnimationBaseImpl->keyFrameList.GetCount(); index++) + { + pKeyList1->GetAt(index, time1); + pKeyList2->GetAt(index, time2); + if (time1 != time2) + { + goto CATCH; + } + + _pAnimationBaseImpl->keyFrameList.GetValue(time1, pObjValue1); + rhs._pAnimationBaseImpl->keyFrameList.GetValue(time2, pObjValue2); + if ((!pObjValue1) && (!pObjValue2)) + { + continue; + } + else if ((!pObjValue1) || (!pObjValue2)) + { + goto CATCH; + } + + Integer* pIntValue1 = dynamic_cast< Integer* >(pObjValue1); + if (pIntValue1 == null) + { + goto CATCH; + } + Integer* pIntValue2 = dynamic_cast< Integer* >(pObjValue2); + if (pIntValue2 == null) + { + goto CATCH; + } + if (!(pIntValue1->Equals(*pIntValue2))) + { + goto CATCH; + } + + } + + delete pKeyList1; + delete pKeyList2; + } + + delete pKeyN; + delete pKeyN1; + + if (!((_pIntegerAnimationImpl->startValue).Equals(rhs._pIntegerAnimationImpl->startValue)) || + !((_pIntegerAnimationImpl->endValue).Equals(rhs._pIntegerAnimationImpl->endValue))) + { + return false; + } + + return _pAnimationBaseImpl->CompareTimingValues(rhs); + +CATCH: + delete pKeyN; + delete pKeyN1; + delete pKeyList1; + delete pKeyList2; + return false; +} + +bool +IntegerAnimation::operator !=(const IntegerAnimation& rhs) const +{ + return !(*this == rhs); +} + +bool +IntegerAnimation::Equals(const Object& rhs) const +{ + const IntegerAnimation* pIntAnim = dynamic_cast< const IntegerAnimation* >(&rhs); + + if (pIntAnim == null) + { + return false; + } + + return (*this == *pIntAnim); +} + +int +IntegerAnimation::GetHashCode(void) const +{ + return (((int) GetRepeatCount()) + ((int) GetOffset()) + ((int) GetDuration()) + ((int) GetDelay())); +} + +result +IntegerAnimation::GetAnimatedValue(long currentTime, int& animatedValue) const +{ + SysTryReturnResult(NID_UI_ANIM, (currentTime >= 0 && currentTime <= GetDuration()), E_INVALID_ARG, "Invalid argument(s) is used. currentTime = %ld", currentTime); + + float actualProgress = _pAnimationBaseImpl->GetActualProgressValue(currentTime); + SysTryReturnResult(NID_UI_ANIM, (actualProgress >= 0.0f && actualProgress <= 1.0f), E_SYSTEM, "A system error has been occurred. Failed to calculate progress."); + + return _pIntegerAnimationImpl->GetAnimatedValue(actualProgress, animatedValue); +} + +result +IntegerAnimation::AddKeyFrame(long time, int value) +{ + SysTryReturnResult(NID_UI_ANIM, (time > 0 && time != _pAnimationBaseImpl->duration), E_INVALID_ARG, "Invalid argument(s) is used. time = %ld", time); + + result r = E_SUCCESS; + Integer* pIntObj = null; + + if (time > _pAnimationBaseImpl->duration) + { + pIntObj = new (std::nothrow) Integer(_pIntegerAnimationImpl->endValue); + SysTryReturnResult(NID_UI_ANIM, (pIntObj), E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = _pAnimationBaseImpl->keyFrameList.Add(_pAnimationBaseImpl->duration, dynamic_cast< Object* >(pIntObj)); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add to key frame list."); + + _pAnimationBaseImpl->duration = time; + _pIntegerAnimationImpl->endValue = value; + } + else + { + pIntObj = new (std::nothrow) Integer(value); + SysTryReturnResult(NID_UI_ANIM, (pIntObj), E_OUT_OF_MEMORY, "Memory allocation failed."); + Object* pKeyValue = null; + _pAnimationBaseImpl->keyFrameList.GetValue(time, pKeyValue); + if (pKeyValue) + { + _pAnimationBaseImpl->keyFrameList.Remove(time); + delete pKeyValue; + } + + r = _pAnimationBaseImpl->keyFrameList.Add(time, dynamic_cast< Object* >(pIntObj)); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add to key frame list."); + } + + return r; + +CATCH: + delete pIntObj; + return r; +} + +result +IntegerAnimation::GetKeyFrameAt(int index, long& time, int& value) const +{ + SysTryReturnResult(NID_UI_ANIM, (index >= 0 && index < _pAnimationBaseImpl->keyFrameList.GetCount()), + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index (%d) is out of range.", index); + + result r = E_SUCCESS; + Object* pObjValue = null; + Integer* pIntValue = null; + ComparerT< long > comparer; + + ArrayListT< long >* pKeyList = new (std::nothrow) ArrayListT< long >; + ICollectionT< long >* pKeyN = _pAnimationBaseImpl->keyFrameList.GetKeysN(); + + SysTryCatch(NID_UI_ANIM, (pKeyList != null && pKeyN != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList->Construct(*pKeyN); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + + SysTryCatch(NID_UI_ANIM, !(pKeyList->GetCount() <= 0), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Key list count is invalid."); + + r = pKeyList->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = pKeyList->GetAt(index, time); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = _pAnimationBaseImpl->keyFrameList.GetValue(time, pObjValue); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get key value."); + SysTryCatch(NID_UI_ANIM, (pObjValue != null), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get key frame."); + + pIntValue = dynamic_cast< Integer* >(pObjValue); + if (pIntValue) + { + value = pIntValue->ToInt(); + } + + //fall through + +CATCH: + delete pKeyN; + delete pKeyList; + + return r; +} + +result +IntegerAnimation::RemoveKeyFrame(long time) +{ + return _pAnimationBaseImpl->RemoveKeyFrame(time); +} + +result +IntegerAnimation::RemoveKeyFrameAt(int index) +{ + return _pAnimationBaseImpl->RemoveKeyFrameAt(index); +} + +result +IntegerAnimation::RemoveAllKeyFrames(void) +{ + return _pAnimationBaseImpl->RemoveAllKeyFrames(); +} + +result +IntegerAnimation::SetStartValue(int startValue) +{ + _pIntegerAnimationImpl->startValue = startValue; + + return E_SUCCESS; +} + +result +IntegerAnimation::SetEndValue(int endValue) +{ + _pIntegerAnimationImpl->endValue = endValue; + + return E_SUCCESS; +} + +int +IntegerAnimation::GetStartValue(void) const +{ + return _pIntegerAnimationImpl->startValue.ToInt(); +} + +int +IntegerAnimation::GetEndValue(void) const +{ + return _pIntegerAnimationImpl->endValue.ToInt(); +} + +AnimationType +IntegerAnimation::GetType(void) const +{ + return ANIMATION_TYPE_INTEGER_ANIMATION; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimLinearTimingFunction.cpp b/src/ui/animations/FUiAnimLinearTimingFunction.cpp new file mode 100644 index 0000000..56f5ab2 --- /dev/null +++ b/src/ui/animations/FUiAnimLinearTimingFunction.cpp @@ -0,0 +1,50 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimLinearTimingFunction.cpp + * @brief This file contains implementation of LinearTimingFunction class + * + * This file contains implementation LinearTimingFunction class. + */ + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +LinearTimingFunction::LinearTimingFunction(void) +{ + +} + +LinearTimingFunction::~LinearTimingFunction(void) +{ + +} + +float +LinearTimingFunction::CalculateProgress(float timeProgress) const +{ + return timeProgress; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimParallelAnimationGroup.cpp b/src/ui/animations/FUiAnimParallelAnimationGroup.cpp new file mode 100644 index 0000000..a686601 --- /dev/null +++ b/src/ui/animations/FUiAnimParallelAnimationGroup.cpp @@ -0,0 +1,342 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimParallelAnimationGroup.cpp + * @brief This file contains implementation of ParallelAnimationGroup class + * + * This file contains implementation of ParallelAnimationGroup class. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "FUiAnim_AnimationGroupImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +ParallelAnimationGroup::ParallelAnimationGroup(void) + : AnimationGroup() + , _pParallelAnimationGroupImpl(null) +{ +} + +ParallelAnimationGroup::~ParallelAnimationGroup(void) +{ +} + +ParallelAnimationGroup::ParallelAnimationGroup(const ParallelAnimationGroup& animationGroup) + : AnimationGroup(animationGroup) + , _pParallelAnimationGroupImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationGroupImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + int animationCount = animationGroup._pAnimationGroupImpl->animationList.GetCount(); + + _AnimationGroupImpl::AnimationStore animStore; + + for (int index = 0; index < animationCount; index++) + { + animationGroup._pAnimationGroupImpl->animationList.GetAt(index, animStore); + + r = AddAnimation(animStore.animTarget, *(animStore.pAnimationBase)); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete _pAnimationGroupImpl; + _pAnimationGroupImpl = null; + + return; + } + } +} + +ParallelAnimationGroup& +ParallelAnimationGroup::operator =(const ParallelAnimationGroup& rhs) +{ + ClearLastResult(); + + if ((&rhs) != this) + { + result r = E_SUCCESS; + + // Deleting the contents + if (_pAnimationGroupImpl->animationList.GetCount() > 0) + { + int index = _pAnimationGroupImpl->animationList.GetCount(); + + while (index > 0) + { + _AnimationGroupImpl::AnimationStore animStore; + + _pAnimationGroupImpl->animationList.GetAt(index - 1, animStore); + + if (animStore.pAnimationBase) + { + delete animStore.pAnimationBase; + animStore.pAnimationBase = null; + } + + index--; + } + + _pAnimationGroupImpl->animationList.RemoveAll(); + } + + // Copying the contents + int animationCount = rhs._pAnimationGroupImpl->animationList.GetCount(); + + for (int index = 0; index < animationCount; index++) + { + _AnimationGroupImpl::AnimationStore animStore; + + rhs._pAnimationGroupImpl->animationList.GetAt(index, animStore); + + _AnimationGroupImpl::AnimationStore animStoreNew; + animStoreNew.animTarget = animStore.animTarget; + + animStoreNew.pAnimationBase = _pAnimationGroupImpl->CloneAnimation(animStore.animTarget, *(animStore.pAnimationBase), r); + SysTryReturn(NID_UI_ANIM, (animStoreNew.pAnimationBase), *this, r, "[%s] Failed to clone animation.", GetErrorMessage(r)); + + r = _pAnimationGroupImpl->animationList.Add(animStoreNew); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + return *this; +} + +bool +ParallelAnimationGroup::operator ==(const ParallelAnimationGroup& rhs) const +{ + if (_pAnimationGroupImpl->animationList.GetCount() != rhs._pAnimationGroupImpl->animationList.GetCount()) + { + return false; + } + + int animationCount = rhs._pAnimationGroupImpl->animationList.GetCount(); + + for (int index = 0; index < animationCount; index++) + { + _AnimationGroupImpl::AnimationStore animStore; + + _pAnimationGroupImpl->animationList.GetAt(index, animStore); + + if (!(rhs._pAnimationGroupImpl->animationList.Contains(animStore))) + { + return false; + } + } + + return true; +} + +bool +ParallelAnimationGroup::operator !=(const ParallelAnimationGroup& rhs) const +{ + return !(*this == rhs); +} + +bool +ParallelAnimationGroup::Equals(const Object& obj) const +{ + const ParallelAnimationGroup* pParallelGrp = dynamic_cast< const ParallelAnimationGroup* >(&obj); + if (pParallelGrp == null) + { + return false; + } + + return (*this == *pParallelGrp); +} + +int +ParallelAnimationGroup::GetHashCode(void) const +{ + return GetAnimationCount(); +} + +void +ParallelAnimationGroup::RemoveAllAnimations(void) +{ + int index = _pAnimationGroupImpl->animationList.GetCount() - 1; + + while (index >= 0) + { + _AnimationGroupImpl::AnimationStore animStore; + + _pAnimationGroupImpl->animationList.GetAt(index, animStore); + + delete animStore.pAnimationBase; + animStore.pAnimationBase = null; + + index--; + } + + _pAnimationGroupImpl->animationList.RemoveAll(); +} + +int +ParallelAnimationGroup::GetAnimationCount(void) const +{ + return _pAnimationGroupImpl->animationList.GetCount(); +} + +result +ParallelAnimationGroup::AddAnimation(AnimationTargetType animTarget, const AnimationBase& animation) +{ + SysTryReturnResult(NID_UI_ANIM, (animTarget >= ANIMATION_TARGET_NONE && animTarget <= ANIMATION_TARGET_MAX), E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid."); + + _AnimationGroupImpl::AnimationStore animStoreNew; + + animStoreNew.animTarget = animTarget; + + result r = E_SUCCESS; + + animStoreNew.pAnimationBase = _pAnimationGroupImpl->CloneAnimation(animTarget, const_cast< AnimationBase& >(animation), r); + SysTryReturnResult(NID_UI_ANIM, (animStoreNew.pAnimationBase), r, "Failed to clone animation "); + + int animationCount = _pAnimationGroupImpl->animationList.GetCount(); + int index = 0; + + _AnimationGroupImpl::AnimationStore animStore; + + for (index = 0; index < animationCount; index++) + { + _pAnimationGroupImpl->animationList.GetAt(index, animStore); + + if (animStore.animTarget == animTarget) + { + break; + } + } + + r = _pAnimationGroupImpl->animationList.Add(animStoreNew); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation."); + + delete animStoreNew.pAnimationBase; + animStoreNew.pAnimationBase = null; + + return E_SYSTEM; + } + + if (index < animationCount) + { + _pAnimationGroupImpl->animationList.RemoveAt(index); + + delete animStore.pAnimationBase; + animStore.pAnimationBase = null; + } + + return E_SUCCESS; +} + +result +ParallelAnimationGroup::RemoveAnimation(AnimationTargetType animTarget) +{ + SysTryReturnResult(NID_UI_ANIM, (animTarget >= ANIMATION_TARGET_NONE && animTarget <= ANIMATION_TARGET_MAX), E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid."); + + int animationCount = _pAnimationGroupImpl->animationList.GetCount(); + _AnimationGroupImpl::AnimationStore animStore; + + for (int index = 0; index < animationCount; index++) + { + _pAnimationGroupImpl->animationList.GetAt(index, animStore); + + if (animStore.animTarget == animTarget) + { + _pAnimationGroupImpl->animationList.RemoveAt(index); + + delete animStore.pAnimationBase; + animStore.pAnimationBase = null; + + return E_SUCCESS; + } + } + + return E_OBJ_NOT_FOUND; +} + +AnimationBase* +ParallelAnimationGroup::GetAnimationN(AnimationTargetType animTarget) const +{ + result r = E_SUCCESS; + + int animationCount = _pAnimationGroupImpl->animationList.GetCount(); + _AnimationGroupImpl::AnimationStore animStore; + + for (int index = 0; index < animationCount; index++) + { + _pAnimationGroupImpl->animationList.GetAt(index, animStore); + + if (animStore.animTarget == animTarget) + { + SysTryReturn(NID_UI_ANIM, (animStore.pAnimationBase), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is invalid."); + + AnimationBase *pAnimationBase = _pAnimationGroupImpl->CloneAnimation(animTarget, *(animStore.pAnimationBase), r); + SysTryReturn(NID_UI_ANIM, (pAnimationBase), null, r, "[%s] Failed to clone animation.", GetErrorMessage(r)); + + return pAnimationBase; + } + } + + return null; +} + +bool +ParallelAnimationGroup::IsAnimationAdded(AnimationTargetType animTarget) +{ + int animationCount = _pAnimationGroupImpl->animationList.GetCount(); + _AnimationGroupImpl::AnimationStore animStore; + + for (int index = 0; index < animationCount; index++) + { + _pAnimationGroupImpl->animationList.GetAt(index, animStore); + + if (animStore.animTarget == animTarget) + { + return true; + } + } + + return false; +} + +AnimationGroupType +ParallelAnimationGroup::GetType(void) const +{ + return ANIMATION_GROUP_TYPE_PARALLEL; +} + +}}} // Tizen::Ui::Animations diff --git a/src/ui/animations/FUiAnimPointAnimation.cpp b/src/ui/animations/FUiAnimPointAnimation.cpp new file mode 100644 index 0000000..75060cd --- /dev/null +++ b/src/ui/animations/FUiAnimPointAnimation.cpp @@ -0,0 +1,396 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimPointAnimation.cpp + * @brief This file contains implementation of PointAnimation class + * + * This file contains implementation of PointAnimation class. + */ + +#include + +#include +#include + +#include + +#include "FUiAnim_PointAnimationImpl.h" +#include "FUiAnim_AnimationBaseImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +PointAnimation::PointAnimation(void) + : _pPointAnimationImpl(null) +{ +} + +PointAnimation::PointAnimation(const Point& startValue, const Point& endValue, long duration, AnimationInterpolatorType interpolator) + : AnimationBase(duration, interpolator) + , _pPointAnimationImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + _pPointAnimationImpl = new (std::nothrow) _PointAnimationImpl(this); + if (_pPointAnimationImpl == null) + { + SysLogException(NID_UI_ANIM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + + return; + } + + _pPointAnimationImpl->startValue = startValue; + _pPointAnimationImpl->endValue = endValue; +} + +PointAnimation::~PointAnimation(void) +{ + delete _pPointAnimationImpl; + _pPointAnimationImpl = null; +} + +PointAnimation::PointAnimation(const PointAnimation& pointAnimation) + : AnimationBase(pointAnimation) + , _pPointAnimationImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + _pPointAnimationImpl = new (std::nothrow) _PointAnimationImpl(this); + SysTryCatch(NID_UI_ANIM, (_pPointAnimationImpl), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = _pPointAnimationImpl->CopyPointAnimationValue(pointAnimation); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to copy point animation value."); + + return; + +CATCH: + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + delete _pPointAnimationImpl; + _pPointAnimationImpl = null; +} + +PointAnimation& +PointAnimation::operator =(const PointAnimation& rhs) +{ + ClearLastResult(); + + if ((&rhs) != this) + { + result r = E_SUCCESS; + + AnimationBase::operator =(rhs); + + r = _pPointAnimationImpl->CopyPointAnimationValue(rhs); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to copy point animation value."); + } + + return *this; +} + +bool +PointAnimation::operator ==(const PointAnimation& rhs) const +{ + result r = E_SUCCESS; + + if (_pAnimationBaseImpl->keyFrameList.GetCount() != rhs._pAnimationBaseImpl->keyFrameList.GetCount()) + { + return false; + } + + ArrayListT< long >* pKeyList1 = null; + ArrayListT< long >* pKeyList2 = null; + ICollectionT< long >* pKeyN = _pAnimationBaseImpl->keyFrameList.GetKeysN(); + ICollectionT< long >* pKeyN1 = rhs._pAnimationBaseImpl->keyFrameList.GetKeysN(); + + if (_pAnimationBaseImpl->keyFrameList.GetCount() != 0) + { + pKeyList1 = new (std::nothrow) ArrayListT< long >; + SysTryCatch(NID_UI_ANIM, (pKeyList1 && pKeyN), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList1->Construct(*pKeyN); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + + pKeyList2 = new (std::nothrow) ArrayListT< long >; + SysTryCatch(NID_UI_ANIM, (pKeyList2 && pKeyN1), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList2->Construct(*pKeyN1); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + + ComparerT< long > comparer; + + r = pKeyList1->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = pKeyList2->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + long time1 = 0; + long time2 = 0; + Object* pObjValue1 = null; + Object* pObjValue2 = null; + + for (int index = 0; index < _pAnimationBaseImpl->keyFrameList.GetCount(); index++) + { + pKeyList1->GetAt(index, time1); + pKeyList2->GetAt(index, time2); + if (time1 != time2) + { + goto CATCH; + } + + _pAnimationBaseImpl->keyFrameList.GetValue(time1, pObjValue1); + rhs._pAnimationBaseImpl->keyFrameList.GetValue(time2, pObjValue2); + + if ((!pObjValue1) && (!pObjValue2)) + { + continue; + } + else if ((!pObjValue1) || (!pObjValue2)) + { + goto CATCH; + } + + Point* pPointValue1 = dynamic_cast< Point* >(pObjValue1); + if (pPointValue1 == null) + { + goto CATCH; + } + Point* pPointValue2 = dynamic_cast< Point* >(pObjValue2); + if (pPointValue2 == null) + { + goto CATCH; + } + if (!(pPointValue1->Equals(*pPointValue2))) + { + goto CATCH; + } + } + delete pKeyList1; + delete pKeyList2; + } + + delete pKeyN; + delete pKeyN1; + + if (!((_pPointAnimationImpl->startValue).Equals(rhs._pPointAnimationImpl->startValue)) || + !((_pPointAnimationImpl->endValue).Equals(rhs._pPointAnimationImpl->endValue))) + { + return false; + } + + return _pAnimationBaseImpl->CompareTimingValues(rhs); + +CATCH: + delete pKeyN; + delete pKeyN1; + delete pKeyList1; + delete pKeyList2; + + return false; +} + +bool +PointAnimation::operator !=(const PointAnimation& rhs) const +{ + return !(*this == rhs); +} + +bool +PointAnimation::Equals(const Object& rhs) const +{ + const PointAnimation* pPointAnim = dynamic_cast< const PointAnimation* >(&rhs); + if (pPointAnim == null) + { + return false; + } + + return (*this == *pPointAnim); +} + +int +PointAnimation::GetHashCode(void) const +{ + return (((int) GetRepeatCount()) + ((int) GetOffset()) + ((int) GetDuration()) + ((int) GetDelay())); +} + +result +PointAnimation::GetAnimatedValue(long currentTime, Point& animatedValue) const +{ + SysTryReturnResult(NID_UI_ANIM, (currentTime >= 0 && currentTime <= GetDuration()), E_INVALID_ARG, "Invalid argument(s) is used. currentTime = %ld", currentTime); + + float actualProgress = _pAnimationBaseImpl->GetActualProgressValue(currentTime); + SysTryReturnResult(NID_UI_ANIM, (actualProgress >= 0.0f && actualProgress <= 1.0f), E_SYSTEM, "System error in calculating progress."); + + return _pPointAnimationImpl->GetAnimatedValue(actualProgress, animatedValue); +} + +result +PointAnimation::AddKeyFrame(long time, const Point& value) +{ + SysTryReturnResult(NID_UI_ANIM, (time > 0 && time != _pAnimationBaseImpl->duration), E_INVALID_ARG, "Invalid argument(s) is used. time = %ld", time); + + result r = E_SUCCESS; + Point* pPointObj = null; + + if (time > _pAnimationBaseImpl->duration) + { + pPointObj = new (std::nothrow) Point(_pPointAnimationImpl->endValue); + SysTryReturnResult(NID_UI_ANIM, (pPointObj), E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = _pAnimationBaseImpl->keyFrameList.Add(_pAnimationBaseImpl->duration, dynamic_cast< Object* >(pPointObj)); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. "); + + _pAnimationBaseImpl->duration = time; + _pPointAnimationImpl->endValue = value; //pointObj; + } + else + { + pPointObj = new (std::nothrow) Point(value); + SysTryReturnResult(NID_UI_ANIM, (pPointObj), E_OUT_OF_MEMORY, "Memory allocation failed."); + + Object* pKeyValue = null; + _pAnimationBaseImpl->keyFrameList.GetValue(time, pKeyValue); + if (pKeyValue) + { + _pAnimationBaseImpl->keyFrameList.Remove(time); + + delete pKeyValue; + } + r = _pAnimationBaseImpl->keyFrameList.Add(time, dynamic_cast< Object* >(pPointObj)); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred. Failed to add to key frame list."); + } + return r; + +CATCH: + delete pPointObj; + return r; +} + +result +PointAnimation::GetKeyFrameAt(int index, long& time, Point& value) const +{ + SysTryReturnResult(NID_UI_ANIM, (index >= 0 && index < _pAnimationBaseImpl->keyFrameList.GetCount()), + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index (%d) is out of range.", index); + + result r = E_SUCCESS; + Object* pObjValue = null; + Point* pPointValue = null; + ComparerT< long > comparer; + + ArrayListT< long >* pKeyList = new (std::nothrow) ArrayListT< long >; + ICollectionT< long >* pKeyN = _pAnimationBaseImpl->keyFrameList.GetKeysN(); + + SysTryCatch(NID_UI_ANIM, (pKeyList && pKeyN), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList->Construct(*pKeyN); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + + SysTryCatch(NID_UI_ANIM, (pKeyList->GetCount() > 0), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Key list count is invalid."); + + r = pKeyList->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = pKeyList->GetAt(index, time); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get the time from list."); + + r = _pAnimationBaseImpl->keyFrameList.GetValue(time, pObjValue); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get key value."); + SysTryCatch(NID_UI_ANIM, (pObjValue != null), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get key frame."); + + pPointValue = dynamic_cast< Point* >(pObjValue); + if (pPointValue) + { + value = *pPointValue; + } + + //fall through + +CATCH: + delete pKeyN; + delete pKeyList; + return r; +} + +result +PointAnimation::RemoveKeyFrame(long time) +{ + return _pAnimationBaseImpl->RemoveKeyFrame(time); +} + +result +PointAnimation::RemoveKeyFrameAt(int index) +{ + return _pAnimationBaseImpl->RemoveKeyFrameAt(index); +} + +result +PointAnimation::RemoveAllKeyFrames(void) +{ + return _pAnimationBaseImpl->RemoveAllKeyFrames(); +} + +result +PointAnimation::SetStartValue(const Point& startValue) +{ + _pPointAnimationImpl->startValue = startValue; + + return E_SUCCESS; +} + +result +PointAnimation::SetEndValue(const Point& endValue) +{ + _pPointAnimationImpl->endValue = endValue; + + return E_SUCCESS; +} + +Tizen::Graphics::Point +PointAnimation::GetStartValue(void) const +{ + return _pPointAnimationImpl->startValue; +} + +Tizen::Graphics::Point +PointAnimation::GetEndValue(void) const +{ + return _pPointAnimationImpl->endValue; +} + +AnimationType +PointAnimation::GetType(void) const +{ + return ANIMATION_TYPE_POINT_ANIMATION; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimRectangleAnimation.cpp b/src/ui/animations/FUiAnimRectangleAnimation.cpp new file mode 100644 index 0000000..dfc097b --- /dev/null +++ b/src/ui/animations/FUiAnimRectangleAnimation.cpp @@ -0,0 +1,446 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimRectangleAnimation.cpp + * @brief This file contains implementation of RectangleAnimation class + * + * This file contains implementation of RectangleAnimation class. + */ + +#include +#include + +#include + +#include "FUiAnim_RectangleAnimationImpl.h" +#include "FUiAnim_AnimationBaseImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +RectangleAnimation::RectangleAnimation(void) + : _pRectangleAnimationImpl(null) +{ +} + +RectangleAnimation::RectangleAnimation(const Rectangle& startValue, const Rectangle& endValue, long duration, AnimationInterpolatorType interpolator) + : AnimationBase(duration, interpolator) + , _pRectangleAnimationImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + SysTryReturnVoidResult(NID_UI_ANIM, (startValue.height >= 0 && startValue.width >= 0 && endValue.height >= 0 && endValue.width >= 0), + E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. startValue = (%d, %d, %d, %d), endValue = (%d, %d, %d, %d)", + startValue.x, startValue.y, startValue.width, startValue.height, endValue.x, endValue.y, endValue.width, endValue.height); + + _pRectangleAnimationImpl = new (std::nothrow) _RectangleAnimationImpl(this); + if (_pRectangleAnimationImpl == null) + { + SysLogException(NID_UI_ANIM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + + return; + } + + _pRectangleAnimationImpl->startValue = startValue; + _pRectangleAnimationImpl->endValue = endValue; +} + +RectangleAnimation::~RectangleAnimation(void) +{ + delete _pRectangleAnimationImpl; + _pRectangleAnimationImpl = null; +} + +RectangleAnimation::RectangleAnimation(const RectangleAnimation& rectangleAnimation) + : AnimationBase(rectangleAnimation) + , _pRectangleAnimationImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + _pRectangleAnimationImpl = new (std::nothrow) _RectangleAnimationImpl(this); + SysTryCatch(NID_UI_ANIM, (_pRectangleAnimationImpl), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + rectangleAnimation.GetAnchor(_pRectangleAnimationImpl->anchorX, _pRectangleAnimationImpl->anchorY); + + r = _pRectangleAnimationImpl->CopyRectangleAnimationValue(rectangleAnimation); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to copy rectangle animation value."); + + return; + +CATCH: + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + delete _pRectangleAnimationImpl; + _pRectangleAnimationImpl = null; +} + +RectangleAnimation& +RectangleAnimation::operator =(const RectangleAnimation& rhs) +{ + ClearLastResult(); + + if ((&rhs) != this) + { + result r = E_SUCCESS; + + AnimationBase::operator =(rhs); + + rhs.GetAnchor(_pRectangleAnimationImpl->anchorX, _pRectangleAnimationImpl->anchorY); + + r = _pRectangleAnimationImpl->CopyRectangleAnimationValue(rhs); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to copy rectangle animation value."); + } + + return *this; +} + +bool +RectangleAnimation::operator ==(const RectangleAnimation& rhs) const +{ + result r = E_SUCCESS; + + if (_pAnimationBaseImpl->keyFrameList.GetCount() != rhs._pAnimationBaseImpl->keyFrameList.GetCount()) + { + return false; + } + + ArrayListT< long >* pKeyList1 = null; + ArrayListT< long >* pKeyList2 = null; + ICollectionT< long >* pKeyN = _pAnimationBaseImpl->keyFrameList.GetKeysN(); + + if (_pAnimationBaseImpl->keyFrameList.GetCount() != 0) + { + pKeyList1 = new (std::nothrow) ArrayListT< long >; + SysTryCatch(NID_UI_ANIM, (pKeyList1 != null && pKeyN != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList1->Construct(*pKeyN); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + + pKeyList2 = new (std::nothrow) ArrayListT< long >; + SysTryCatch(NID_UI_ANIM, (pKeyList2 != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + ComparerT< long > comparer; + + r = pKeyList1->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = pKeyList2->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + long time1 = 0; + long time2 = 0; + Object* pObjValue1 = null; + Object* pObjValue2 = null; + + for (int index = 0; index < _pAnimationBaseImpl->keyFrameList.GetCount(); index++) + { + pKeyList1->GetAt(index, time1); + pKeyList2->GetAt(index, time2); + if (time1 != time2) + { + goto CATCH; + } + + _pAnimationBaseImpl->keyFrameList.GetValue(time1, pObjValue1); + rhs._pAnimationBaseImpl->keyFrameList.GetValue(time2, pObjValue2); + + if ((!pObjValue1) && (!pObjValue2)) + { + continue; + } + else if ((!pObjValue1) || (!pObjValue2)) + { + goto CATCH; + } + + Rectangle* pRectValue1 = dynamic_cast< Rectangle* >(pObjValue1); + if (pRectValue1 == null) + { + goto CATCH; + } + Rectangle* pRectValue2 = dynamic_cast< Rectangle* >(pObjValue2); + if (pRectValue2 == null) + { + goto CATCH; + } + if (!(pRectValue1->Equals(*pRectValue2))) + { + goto CATCH; + } + + } + + delete pKeyList1; + delete pKeyList2; + } + delete pKeyN; + + if (!((_pRectangleAnimationImpl->startValue).Equals(rhs._pRectangleAnimationImpl->startValue)) || + !((_pRectangleAnimationImpl->endValue).Equals(rhs._pRectangleAnimationImpl->endValue))) + { + return false; + } + + if (((Float::Compare(_pRectangleAnimationImpl->anchorX, rhs._pRectangleAnimationImpl->anchorX)) != 0) && + ((Float::Compare(_pRectangleAnimationImpl->anchorY, rhs._pRectangleAnimationImpl->anchorY)) != 0)) + { + return false; + } + + return _pAnimationBaseImpl->CompareTimingValues(rhs); + + +CATCH: + delete pKeyN; + delete pKeyList1; + delete pKeyList2; + return false; +} + +bool +RectangleAnimation::operator !=(const RectangleAnimation& rhs) const +{ + return !(*this == rhs); +} + +bool +RectangleAnimation::Equals(const Object& obj) const +{ + const RectangleAnimation* pRectangleAnim = dynamic_cast< const RectangleAnimation* >(&obj); + if (pRectangleAnim == null) + { + return false; + } + + return (*this == *pRectangleAnim); +} + +int +RectangleAnimation::GetHashCode(void) const +{ + return (((int) GetRepeatCount()) + ((int) GetOffset()) + ((int) GetDuration()) + ((int) GetDelay())); +} + +result +RectangleAnimation::SetAnchor(float anchorX, float anchorY) +{ + SysTryReturnResult(NID_UI_ANIM, (anchorX >= 0.0 && anchorX <= 1.0 && anchorY >= 0.0 && anchorY <= 1.0), E_INVALID_ARG, "Invalid argument(s) is used. anchorX = %f, anchorY = %f.", anchorX, anchorY); + + _pRectangleAnimationImpl->anchorX = anchorX; + _pRectangleAnimationImpl->anchorY = anchorY; + + return E_SUCCESS; +} + +void +RectangleAnimation::GetAnchor(float& anchorX, float& anchorY) const +{ + anchorX = _pRectangleAnimationImpl->anchorX; + anchorY = _pRectangleAnimationImpl->anchorY; +} + +result +RectangleAnimation::GetAnimatedValue(long currentTime, Rectangle& animatedValue) const +{ + SysTryReturnResult(NID_UI_ANIM, (currentTime >= 0 && currentTime <= GetDuration()), E_INVALID_ARG, "Invalid argument(s) is used. currentTime = %ld", currentTime); + + float actualProgress = _pAnimationBaseImpl->GetActualProgressValue(currentTime); + SysTryReturnResult(NID_UI_ANIM, (actualProgress >= 0.0f && actualProgress <= 1.0f), E_SYSTEM, "System error in calculating progress."); + + return _pRectangleAnimationImpl->GetAnimatedValue(actualProgress, animatedValue); +} + +result +RectangleAnimation::AddKeyFrame(long time, const Rectangle& value) +{ + SysTryReturnResult(NID_UI_ANIM, (time > 0 && time != _pAnimationBaseImpl->duration), E_INVALID_ARG, "Invalid argument(s) is used. time = %ld", time); + + result r = E_SUCCESS; + Rectangle* pRectObj = null; + + if (time > _pAnimationBaseImpl->duration) + { + pRectObj = new (std::nothrow) Rectangle(_pRectangleAnimationImpl->endValue); + SysTryReturnResult(NID_UI_ANIM, (pRectObj != null), E_OUT_OF_MEMORY, "Memory allocation failed"); + + r = _pAnimationBaseImpl->keyFrameList.Add(_pAnimationBaseImpl->duration, dynamic_cast< Object* >(pRectObj)); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add to key frame list."); + + _pAnimationBaseImpl->duration = time; + _pRectangleAnimationImpl->endValue = value; + } + else + { + pRectObj = new (std::nothrow) Rectangle(value); + SysTryReturnResult(NID_UI_ANIM, (pRectObj != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + Object* pKeyValue = null; + _pAnimationBaseImpl->keyFrameList.GetValue(time, pKeyValue); + if (pKeyValue != null) + { + _pAnimationBaseImpl->keyFrameList.Remove(time); // Remove the already existing entry + delete pKeyValue; + } + r = _pAnimationBaseImpl->keyFrameList.Add(time, dynamic_cast< Object* >(pRectObj)); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add to key frame list."); + } + + return r; + +CATCH: + delete pRectObj; + return r; +} + +result +RectangleAnimation::GetKeyFrameAt(int index, long& time, Rectangle& value) const +{ + SysTryReturnResult(NID_UI_ANIM, (index >= 0 && index < _pAnimationBaseImpl->keyFrameList.GetCount()), + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index (%d) is out of range.", index); + + result r = E_SUCCESS; + Object* pObjValue = null; + Rectangle* pDimValue = null; + ComparerT< long > comparer; + + ArrayListT< long >* pKeyList = new (std::nothrow) ArrayListT< long >; + ICollectionT< long >* pKeyN = _pAnimationBaseImpl->keyFrameList.GetKeysN(); + + SysTryCatch(NID_UI_ANIM, (pKeyList != null && pKeyN != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList->Construct(*pKeyN); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + SysTryCatch(NID_UI_ANIM, !(pKeyList->GetCount() <= 0), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Key list count is invalid."); + + r = pKeyList->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = pKeyList->GetAt(index, time); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get the time from list."); + + r = _pAnimationBaseImpl->keyFrameList.GetValue(time, pObjValue); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get key value."); + + pDimValue = dynamic_cast< Rectangle* >(pObjValue); + if (pDimValue) + { + value = *pDimValue; + } + + //fall through +CATCH: + delete pKeyN; + delete pKeyList; + return r; +} + +result +RectangleAnimation::RemoveKeyFrame(long time) +{ + return _pAnimationBaseImpl->RemoveKeyFrame(time); +} + +result +RectangleAnimation::RemoveKeyFrameAt(int index) +{ + return _pAnimationBaseImpl->RemoveKeyFrameAt(index); +} + +result +RectangleAnimation::RemoveAllKeyFrames(void) +{ + result r = E_SUCCESS; + + IMapEnumeratorT< long, Object* >* pMapEnum = _pAnimationBaseImpl->keyFrameList.GetMapEnumeratorN(); + SysTryReturnResult(NID_UI_ANIM, (pMapEnum), E_OUT_OF_MEMORY, "Memory allocation failed."); + + MapEntryT< long, Object* > value; + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + r = pMapEnum->GetCurrent(value); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get the current value."); + + Object* pObj = value.GetValue(); + + delete pObj; + } + + _pAnimationBaseImpl->keyFrameList.RemoveAll(); + + //fall through +CATCH: + delete pMapEnum; + + return r; +} + +result +RectangleAnimation::SetStartValue(const Rectangle& startValue) +{ + SysTryReturnResult(NID_UI_ANIM, (startValue.width >= 0 && startValue.height >= 0), E_INVALID_ARG, "Invalid argument(s) is used. size = (%d, %d)", startValue.width, startValue.height); + + _pRectangleAnimationImpl->startValue = startValue; + + return E_SUCCESS; + +} + +result +RectangleAnimation::SetEndValue(const Rectangle& endValue) +{ + SysTryReturnResult(NID_UI_ANIM, (endValue.width >= 0 && endValue.height >= 0), E_INVALID_ARG, "Invalid argument(s) is used. size = (%d, %d)", endValue.width, endValue.height); + + _pRectangleAnimationImpl->endValue = endValue; + + return E_SUCCESS; +} + +Rectangle +RectangleAnimation::GetStartValue(void) const +{ + return _pRectangleAnimationImpl->startValue; +} + +Rectangle +RectangleAnimation::GetEndValue(void) const +{ + return _pRectangleAnimationImpl->endValue; +} + +AnimationType +RectangleAnimation::GetType(void) const +{ + return ANIMATION_TYPE_RECTANGLE_ANIMATION; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimRotateAnimation.cpp b/src/ui/animations/FUiAnimRotateAnimation.cpp new file mode 100644 index 0000000..3e69164 --- /dev/null +++ b/src/ui/animations/FUiAnimRotateAnimation.cpp @@ -0,0 +1,181 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimRotateAnimation.cpp + * @brief This file contains implementation of RotateAnimation class + * + * This file contains implementation of RotateAnimation class. + */ + +#include +#include + +#include + +#include "FUiAnim_RotateAnimationImpl.h" +#include "FUiAnim_AnimationBaseImpl.h" +#include "FUiAnim_FloatAnimationImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base::Collection; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +RotateAnimation::RotateAnimation(void) + : _pRotateAnimationImpl(null) +{ +} + +RotateAnimation::RotateAnimation(float startValue, float endValue, long duration, AnimationInterpolatorType interpolator) + : FloatAnimation(startValue, endValue, duration, interpolator) + , _pRotateAnimationImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + _pRotateAnimationImpl = new (std::nothrow) _RotateAnimationImpl(this); + if (_pRotateAnimationImpl == null) + { + SysLogException(NID_UI_ANIM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + delete _pFloatAnimationImpl; + _pFloatAnimationImpl = null; + + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + + return; + } + + return; +} + +RotateAnimation::~RotateAnimation(void) +{ + delete _pRotateAnimationImpl; + _pRotateAnimationImpl = null; +} + +RotateAnimation::RotateAnimation(const RotateAnimation& rotateAnimation) + : FloatAnimation(rotateAnimation) + , _pRotateAnimationImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationBaseImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + _pRotateAnimationImpl = new (std::nothrow) _RotateAnimationImpl(this); + SysTryCatch(NID_UI_ANIM, (_pRotateAnimationImpl != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + rotateAnimation.GetAnchor(_pRotateAnimationImpl->anchorX, _pRotateAnimationImpl->anchorY); + + return; + +CATCH: + delete _pAnimationBaseImpl; + _pAnimationBaseImpl = null; + delete _pFloatAnimationImpl; + _pFloatAnimationImpl = null; +} + +RotateAnimation& +RotateAnimation::operator =(const RotateAnimation& rhs) +{ + ClearLastResult(); + + if ((&rhs) != this) + { + FloatAnimation::operator =(rhs); + + rhs.GetAnchor(_pRotateAnimationImpl->anchorX, _pRotateAnimationImpl->anchorY); + } + + return *this; +} + +bool +RotateAnimation::operator ==(const RotateAnimation& rhs) const +{ + if (!(FloatAnimation::operator ==(rhs))) + { + return false; + } + + if (Float::Compare(_pRotateAnimationImpl->anchorX, rhs._pRotateAnimationImpl->anchorX) != 0 || + Float::Compare(_pRotateAnimationImpl->anchorY, rhs._pRotateAnimationImpl->anchorY) != 0) + { + return false; + } + + return true; +} + +bool +RotateAnimation::operator !=(const RotateAnimation& rhs) const +{ + return !(*this == rhs); +} + +bool +RotateAnimation::Equals(const Tizen::Base::Object& rhs) const +{ + const RotateAnimation* pRotateAnim = dynamic_cast< const RotateAnimation* >(&rhs); + if (pRotateAnim == null) + { + return false; + } + + return (*this == *pRotateAnim); +} + +int +RotateAnimation::GetHashCode(void) const +{ + return (((int) GetRepeatCount()) + ((int) GetOffset()) + ((int) GetDuration()) + ((int) GetDelay())); +} + +result +RotateAnimation::SetAnchor(float anchorX, float anchorY) +{ + SysTryReturnResult(NID_UI_ANIM, (anchorX >= 0.0 && anchorX <= 1.0 && anchorY >= 0.0 && anchorY <= 1.0), E_INVALID_ARG, "Invalid argument(s) is used. anchorX = %f, anchorX= %f.", anchorX, anchorY); + + _pRotateAnimationImpl->anchorX = anchorX; + _pRotateAnimationImpl->anchorY = anchorY; + + return E_SUCCESS; +} + +void +RotateAnimation::GetAnchor(float& anchorX, float& anchorY) const +{ + anchorX = _pRotateAnimationImpl->anchorX; + anchorY = _pRotateAnimationImpl->anchorY; + + return; +} + +AnimationType +RotateAnimation::GetType(void) const +{ + return ANIMATION_TYPE_ROTATE_ANIMATION; +} + +}}} // Tizen::Ui::Animations diff --git a/src/ui/animations/FUiAnimSequentialAnimationGroup.cpp b/src/ui/animations/FUiAnimSequentialAnimationGroup.cpp new file mode 100644 index 0000000..8aee7f3 --- /dev/null +++ b/src/ui/animations/FUiAnimSequentialAnimationGroup.cpp @@ -0,0 +1,367 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimSequentialAnimationGroup.cpp + * @brief This file contains implementation of SequentialAnimationGroup class + * + * This file contains implementation of SequentialAnimationGroup class. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "FUiAnim_AnimationGroupImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +SequentialAnimationGroup::SequentialAnimationGroup(void) + : AnimationGroup() + , _pSequentialAnimationGroupImpl(null) +{ +} + +SequentialAnimationGroup::~SequentialAnimationGroup(void) +{ +} + +SequentialAnimationGroup::SequentialAnimationGroup(const SequentialAnimationGroup& animationGroup) + : AnimationGroup(animationGroup) + , _pSequentialAnimationGroupImpl(null) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationGroupImpl), r, "[%s] Propagating.", GetErrorMessage(r)); + + int animationCount = animationGroup._pAnimationGroupImpl->animationList.GetCount(); + + _AnimationGroupImpl::AnimationStore animStore; + + for (int index = 0; index < animationCount; index++) + { + animationGroup._pAnimationGroupImpl->animationList.GetAt(index, animStore); + + r = AddAnimation(animStore.animTarget, *(animStore.pAnimationBase)); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete _pAnimationGroupImpl; + _pAnimationGroupImpl = null; + + return; + } + } +} + +SequentialAnimationGroup& +SequentialAnimationGroup::operator =(const SequentialAnimationGroup& rhs) +{ + ClearLastResult(); + + if ((&rhs) != this) + { + result r = E_SUCCESS; + + // Deleting the contents + if (_pAnimationGroupImpl->animationList.GetCount() > 0) + { + int index = _pAnimationGroupImpl->animationList.GetCount(); + + while (index > 0) + { + _AnimationGroupImpl::AnimationStore animStore; + + _pAnimationGroupImpl->animationList.GetAt(index - 1, animStore); + + if (animStore.pAnimationBase) + { + delete animStore.pAnimationBase; + animStore.pAnimationBase = null; + } + + index--; + } + + _pAnimationGroupImpl->animationList.RemoveAll(); + } + + // Copying the contents + int animationCount = rhs._pAnimationGroupImpl->animationList.GetCount(); + + for (int index = 0; index < animationCount; index++) + { + _AnimationGroupImpl::AnimationStore animStore; + + rhs._pAnimationGroupImpl->animationList.GetAt(index, animStore); + + _AnimationGroupImpl::AnimationStore animStoreNew; + animStoreNew.animTarget = animStore.animTarget; + + animStoreNew.pAnimationBase = _pAnimationGroupImpl->CloneAnimation(animStore.animTarget, *(animStore.pAnimationBase), r); + SysTryReturn(NID_UI_ANIM, (animStoreNew.pAnimationBase), *this, r, "Failed to clone animation.", GetErrorMessage(r)); + + r = _pAnimationGroupImpl->animationList.Add(animStoreNew); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + return *this; +} + +bool +SequentialAnimationGroup::operator ==(const SequentialAnimationGroup& rhs) const +{ + if (_pAnimationGroupImpl->animationList.GetCount() != rhs._pAnimationGroupImpl->animationList.GetCount()) + { + return false; + } + + int animationCount = rhs._pAnimationGroupImpl->animationList.GetCount(); + + for (int index = 0; index < animationCount; index++) + { + _AnimationGroupImpl::AnimationStore animStore; + + _pAnimationGroupImpl->animationList.GetAt(index, animStore); + + if (!(rhs._pAnimationGroupImpl->animationList.Contains(animStore))) + { + return false; + } + } + + return true; +} + +bool +SequentialAnimationGroup::operator !=(const SequentialAnimationGroup& rhs) const +{ + return !(*this == rhs); +} + +bool +SequentialAnimationGroup::Equals(const Object& obj) const +{ + const SequentialAnimationGroup* pSequentialGrp = dynamic_cast< const SequentialAnimationGroup* >(&obj); + if (pSequentialGrp == null) + { + return false; + } + + return (*this == *pSequentialGrp); +} + +int +SequentialAnimationGroup::GetHashCode(void) const +{ + return GetAnimationCount(); +} + +void +SequentialAnimationGroup::RemoveAllAnimations(void) +{ + int index = _pAnimationGroupImpl->animationList.GetCount() - 1; + + while (index >= 0) + { + _AnimationGroupImpl::AnimationStore animStore; + + _pAnimationGroupImpl->animationList.GetAt(index, animStore); + + delete animStore.pAnimationBase; + animStore.pAnimationBase = null; + + index--; + } + + _pAnimationGroupImpl->animationList.RemoveAll(); +} + +int +SequentialAnimationGroup::GetAnimationCount(void) const +{ + return _pAnimationGroupImpl->animationList.GetCount(); +} + +result +SequentialAnimationGroup::AddAnimation(AnimationTargetType animTarget, const AnimationBase& animation) +{ + SysTryReturnResult(NID_UI_ANIM, (animTarget >= ANIMATION_TARGET_NONE && animTarget <= ANIMATION_TARGET_MAX), E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid."); + + result r = E_SUCCESS; + + _AnimationGroupImpl::AnimationStore animStore; + animStore.animTarget = animTarget; + + animStore.pAnimationBase = _pAnimationGroupImpl->CloneAnimation(animTarget, const_cast< AnimationBase& >(animation), r); + SysTryReturnResult(NID_UI_ANIM, (animStore.pAnimationBase), r, "Failed to clone animation."); + + r = _pAnimationGroupImpl->animationList.Add(animStore); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add to animation list."); + + delete animStore.pAnimationBase; + animStore.pAnimationBase = null; + + return r; + } + + return E_SUCCESS; +} + +result +SequentialAnimationGroup::SetAnimationAt(int index, AnimationTargetType animTarget, const AnimationBase& animation) +{ + SysTryReturnResult(NID_UI_ANIM, (animTarget >= ANIMATION_TARGET_NONE && animTarget <= ANIMATION_TARGET_MAX), E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid."); + SysTryReturnResult(NID_UI_ANIM, (index >= 0 && index < _pAnimationGroupImpl->animationList.GetCount()), E_OUT_OF_RANGE, "Index (%d) is out of range.", index); + + result r = E_SUCCESS; + + _AnimationGroupImpl::AnimationStore animStore; + animStore.animTarget = animTarget; + + animStore.pAnimationBase = _pAnimationGroupImpl->CloneAnimation(animTarget, const_cast< AnimationBase& >(animation), r); + SysTryReturnResult(NID_UI_ANIM, (animStore.pAnimationBase), r, "Failed to clone animation."); + + _AnimationGroupImpl::AnimationStore animStoreCurrent; + _pAnimationGroupImpl->animationList.GetAt(index, animStoreCurrent); + + r = _pAnimationGroupImpl->animationList.SetAt(animStore, index); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to insert into the animation list."); + + delete animStore.pAnimationBase; + animStore.pAnimationBase = null; + + return r; + } + + delete animStoreCurrent.pAnimationBase; + animStoreCurrent.pAnimationBase = null; + + return E_SUCCESS; +} + + +result +SequentialAnimationGroup::InsertAnimationAt(int index, AnimationTargetType animTarget, const AnimationBase& animation) +{ + SysTryReturnResult(NID_UI_ANIM, (animTarget >= ANIMATION_TARGET_NONE && animTarget <= ANIMATION_TARGET_MAX), E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid."); + SysTryReturnResult(NID_UI_ANIM, (index >= 0 && index < _pAnimationGroupImpl->animationList.GetCount()), E_OUT_OF_RANGE, "Index (%d) is out of range.", index); + + result r = E_SUCCESS; + + _AnimationGroupImpl::AnimationStore animStore; + animStore.animTarget = animTarget; + + animStore.pAnimationBase = _pAnimationGroupImpl->CloneAnimation(animTarget, const_cast< AnimationBase& >(animation), r); + SysTryReturnResult(NID_UI_ANIM, (animStore.pAnimationBase), r, "Failed to clone animation."); + + _AnimationGroupImpl::AnimationStore animStoreCurrent; + _pAnimationGroupImpl->animationList.GetAt(index, animStoreCurrent); + + r = _pAnimationGroupImpl->animationList.InsertAt(animStore, index); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to insert into the animation list."); + + delete animStore.pAnimationBase; + animStore.pAnimationBase = null; + + return r; + } + + return E_SUCCESS; +} + +result +SequentialAnimationGroup::RemoveAnimationAt(int index) +{ + SysTryReturnResult(NID_UI_ANIM, (index >= 0 && index < _pAnimationGroupImpl->animationList.GetCount()), E_OUT_OF_RANGE, "Index (%d) is out of range.", index); + + result r = E_SUCCESS; + + _AnimationGroupImpl::AnimationStore animStore; + + _pAnimationGroupImpl->animationList.GetAt(index, animStore); + + SysTryReturnResult(NID_UI_ANIM, (animStore.pAnimationBase), E_SYSTEM, "A system error has been occurred. Animation is invalid."); + + r = _pAnimationGroupImpl->animationList.RemoveAt(index); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to remove animation from animation list.") + + delete animStore.pAnimationBase; + animStore.pAnimationBase = null; + + return E_SUCCESS; +} + +AnimationBase* +SequentialAnimationGroup::GetAnimationAtN(int index) const +{ + SysTryReturn(NID_UI_ANIM, (index >= 0 && index < _pAnimationGroupImpl->animationList.GetCount()), null, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index (%d) is out of range.", index); + + _AnimationGroupImpl::AnimationStore animStore; + + _pAnimationGroupImpl->animationList.GetAt(index, animStore); + + SysTryReturn(NID_UI_ANIM, (animStore.pAnimationBase), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is invalid."); + + result r = E_SUCCESS; + + AnimationBase *pAnimationBase = _pAnimationGroupImpl->CloneAnimation(animStore.animTarget, *(animStore.pAnimationBase), r); + SysTryReturn(NID_UI_ANIM, (pAnimationBase), null, r, "[%s] Failed to clone animation.", GetErrorMessage(r)); + + return pAnimationBase; +} + +AnimationTargetType +SequentialAnimationGroup::GetAnimationTargetTypeAt(int index) const +{ + SysTryReturn(NID_UI_ANIM, (index >= 0 && index < _pAnimationGroupImpl->animationList.GetCount()), ANIMATION_TARGET_NONE, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index (%d) is out of range.", index); + + _AnimationGroupImpl::AnimationStore animStore; + _pAnimationGroupImpl->animationList.GetAt(index, animStore); + + return animStore.animTarget; +} + +AnimationGroupType +SequentialAnimationGroup::GetType(void) const +{ + return ANIMATION_GROUP_TYPE_SEQUENTIAL; +} + +}}} // Tizen::Ui::Animations diff --git a/src/ui/animations/FUiAnimVisualElement.cpp b/src/ui/animations/FUiAnimVisualElement.cpp new file mode 100644 index 0000000..d0914f1 --- /dev/null +++ b/src/ui/animations/FUiAnimVisualElement.cpp @@ -0,0 +1,872 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElement.cpp + * @brief This file contains implementation of VisualElement class + * + * This file contains implementation VisualElement class. + */ + +#include +#include +#include +#include +#include + +#include "FUiAnim_VisualElementAnimationImpl.h" +#include "FUiAnim_VisualElementImpl.h" + +#include "FUiAnim_Debug.h" + +#define CHECK_NOT_CONSTRUCTED \ + SysAssertf(_pVisualElementImpl->__pSharedData == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + +#define CHECK_CONSTRUCTED \ + SysAssertf(_pVisualElementImpl->__pSharedData != null, "Not yet constructed! Construct() should be called before use."); + +#define CHECK_PARAMETER_CONSTRUCTED(element) \ + SysAssertf((element)._pVisualElementImpl && (element)._pVisualElementImpl->__pSharedData, "Not yet constructed! Construct() should be called before use."); + +namespace Tizen { namespace Ui { namespace Animations +{ + +using namespace Tizen; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +VisualElement::VisualElement(void) + : _pVisualElementImpl(null) +{ + _pVisualElementImpl = new (std::nothrow) _VisualElementImpl(*this); +} + +VisualElement::VisualElement(const VisualElement& rhs) + : _pVisualElementImpl(null) +{ + CHECK_PARAMETER_CONSTRUCTED(rhs); + + _pVisualElementImpl = new (std::nothrow) _VisualElementImpl(*this, *rhs._pVisualElementImpl); +} + +VisualElement* +VisualElement::CloneN(void) const +{ + CHECK_CONSTRUCTED; + + VisualElement* pCloned = new (std::nothrow) VisualElement(*this); + SysTryReturn(NID_UI_ANIM, pCloned, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pCloned; +} + +VisualElement::~VisualElement(void) +{ + if (_pVisualElementImpl) + { + SysLogException(NID_UI_ANIM, E_INVALID_STATE, "[E_INVALID_STATE] should be called Destroy() for deallocating the VisualElement."); + _pVisualElementImpl->Destroy(); + _pVisualElementImpl = null; + } +} + +result +VisualElement::Construct(void) +{ + SysTryReturnResult(NID_UI_ANIM, _pVisualElementImpl, E_OUT_OF_MEMORY, "Memory allocation failed."); + + SysAssertf(_pVisualElementImpl->__pSharedData == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + result r = E_SUCCESS; + VisualElement* pClone = null; + + r = _pVisualElementImpl->Construct(); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Failed to construct VisualElement instance.", GetErrorMessage(r)); + + pClone = CloneN(); + SysTryReturnResult(NID_UI_ANIM, pClone, E_INVALID_STATE, "Failed to create the presentation."); + SysTryCatch(NID_UI_ANIM, pClone->_pVisualElementImpl, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Presentation is invalid."); + + pClone->_pVisualElementImpl->__pSharedData = _pVisualElementImpl->__pSharedData; + pClone->_pVisualElementImpl->__pSharedData->AddRef(); + _pVisualElementImpl->__pSharedData->invalidatedNativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_MASK; + + pClone->_pVisualElementImpl->__pModel = _pVisualElementImpl; + pClone->_pVisualElementImpl->__pPresentation = pClone->_pVisualElementImpl; + + _pVisualElementImpl->__pModel = _pVisualElementImpl; + _pVisualElementImpl->__pPresentation = pClone->_pVisualElementImpl; + + + // WARNING: + // Exceptional case for constructed-callback: + // This callback is invoked inside public-class, not inside impl-class because 'Construct' method will not be called for cloned(Presentation) VE + + // This is model object, not presentation object. + _pVisualElementImpl->InvokeOnConstructed(); + //pClone->_pVisualElementImpl->InvokeOnConstructed(); + + return r; + +CATCH: + delete pClone; + + return r; +} + +void +VisualElement::Destroy(void) +{ + if (likely(_pVisualElementImpl)) + { + if (likely(!_pVisualElementImpl->__isDestroying)) + { + _pVisualElementImpl->Destroy(); + _pVisualElementImpl = null; + + delete this; + } + } + else + { + delete this; + } +} + +Variant +VisualElement::GetProperty(const Tizen::Base::String& property) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->InvokeOnGetPropertyRequested(property); +} + +Variant +VisualElement::OnGetPropertyRequested(const Tizen::Base::String& property) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetProperty(property); +} + +result +VisualElement::SetProperty(const Tizen::Base::String& property, const Variant& value) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->InvokeOnSetPropertyRequested(property, value); +} + +result +VisualElement::OnSetPropertyRequested(const Tizen::Base::String& property, const Variant& value) +{ + CHECK_CONSTRUCTED; + result r = E_SUCCESS; + + r =_pVisualElementImpl->SetProperty(property, value); + if(r == E_KEY_NOT_FOUND) + { + r = _pVisualElementImpl->UpdatePresentationWhenCustomPropertyChanged(property, value); + } + return r; +} + +result +VisualElement::SetZOrderGroup(int zOrderGroup) +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_UI_ANIM, zOrderGroup >= Z_ORDER_GROUP_LOWEST, E_OUT_OF_RANGE, "zOrderGroup is less than Z_ORDER_GROUP_LOWEST"); + SysTryReturnResult(NID_UI_ANIM, zOrderGroup <= Z_ORDER_GROUP_HIGHEST, E_OUT_OF_RANGE, "zOrderGroup is greater than Z_ORDER_GROUP_HIGHEST"); + + return _pVisualElementImpl->SetZOrderGroup(zOrderGroup); +} + +int +VisualElement::GetZOrderGroup(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetZOrderGroup(); +} + +bool +VisualElement::IsRedrawOnResizeEnabled(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetRedrawOnResizeEnabled(); +} + +void +VisualElement::SetRedrawOnResizeEnabled(bool enabled) +{ + CHECK_CONSTRUCTED; + + _pVisualElementImpl->SetRedrawOnResizeEnabled(enabled); +} + +FloatRectangle +VisualElement::GetBounds(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetBounds(); +} + +result +VisualElement::SetBounds(const FloatRectangle& bounds) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->SetBounds(bounds); +} + +float +VisualElement::GetZPosition(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetZPosition(); +} + +void +VisualElement::SetZPosition(float zPosition) +{ + CHECK_CONSTRUCTED; + + _pVisualElementImpl->SetZPosition(zPosition); +} + +bool +VisualElement::IsVisible(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->IsVisible(); +} + +bool +VisualElement::GetShowState(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetShowState(); +} + +void +VisualElement::SetShowState(bool show) +{ + CHECK_CONSTRUCTED; + + _pVisualElementImpl->SetShowState(show); +} + +float +VisualElement::GetOpacity(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetOpacity(); +} + +void +VisualElement::SetOpacity(float opacity) +{ + CHECK_CONSTRUCTED; + + _pVisualElementImpl->SetOpacity(opacity); +} + +Tizen::Graphics::FloatMatrix4 +VisualElement::GetTransformMatrix(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetTransformMatrix(); +} + +result +VisualElement::SetTransformMatrix(const Tizen::Graphics::FloatMatrix4& transform) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->SetTransformMatrix(transform); +} + +Tizen::Graphics::FloatMatrix4 +VisualElement::GetChildrenTransformMatrix(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetChildrenTransformMatrix(); +} + +result +VisualElement::SetChildrenTransformMatrix(const Tizen::Graphics::FloatMatrix4& transform) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->SetChildrenTransformMatrix(transform); +} + +FloatPoint +VisualElement::GetAnchor(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetAnchor(); +} + +void +VisualElement::SetAnchor(const FloatPoint& anchor) +{ + CHECK_CONSTRUCTED; + + _pVisualElementImpl->SetAnchor(anchor); +} + +float +VisualElement::GetAnchorZ(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetAnchorZ(); +} + +void +VisualElement::SetAnchorZ(float anchorZ) +{ + CHECK_CONSTRUCTED; + + _pVisualElementImpl->SetAnchorZ(anchorZ); + +} + +VisualElement* +VisualElement::GetParent(void) const +{ + CHECK_CONSTRUCTED; + + if (_pVisualElementImpl->__isHidingParent) + { + return null; + } + + if (_pVisualElementImpl->GetParent() && !_pVisualElementImpl->GetParent()->__isInternal) + { + return _pVisualElementImpl->GetParent()->GetPublic(); + } + else + { + return null; + } +} + +Tizen::Base::Collection::IList* +VisualElement::GetChildrenN(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetPublicChildrenN(); +} + +int +VisualElement::GetChildrenCount(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetChildrenCount(); +} + +bool +VisualElement::IsChildOf(const VisualElement& element) const +{ + CHECK_CONSTRUCTED; + CHECK_PARAMETER_CONSTRUCTED(element); + + return _pVisualElementImpl->IsChildOf(*element._pVisualElementImpl); +} + +result +VisualElement::AttachChild(const VisualElement& child) +{ + CHECK_CONSTRUCTED; + CHECK_PARAMETER_CONSTRUCTED(child); + + return _pVisualElementImpl->AddChild(*child._pVisualElementImpl); +} + +result +VisualElement::InsertChild(const VisualElement& child, const VisualElement* pReference, bool above) +{ + CHECK_CONSTRUCTED; + CHECK_PARAMETER_CONSTRUCTED(child); + + _VisualElementImpl* pRefInternal = null; + if (pReference) + { + CHECK_PARAMETER_CONSTRUCTED(*pReference); + pRefInternal = pReference->_pVisualElementImpl; + } + + return _pVisualElementImpl->InsertChild(*child._pVisualElementImpl, pRefInternal, above); +} + +result +VisualElement::DetachChild(const VisualElement& child) +{ + CHECK_CONSTRUCTED; + CHECK_PARAMETER_CONSTRUCTED(child); + + _VisualElementImpl* pInternal = null; + + pInternal = child._pVisualElementImpl; + + return _pVisualElementImpl->RemoveChild(*pInternal, false); +} + +result +VisualElement::ChangeZOrder(const VisualElement* pReference, bool above) +{ + CHECK_CONSTRUCTED; + + _VisualElementImpl* pRefInternal = null; + if (pReference) + { + CHECK_PARAMETER_CONSTRUCTED(*pReference); + pRefInternal = pReference->_pVisualElementImpl; + } + + return _pVisualElementImpl->SetZOrder(pRefInternal, above); +} + +result +VisualElement::SetAnimationProvider(IVisualElementAnimationProvider* pProvider) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->SetAnimationProvider(pProvider); +} + + +IVisualElementAnimationProvider* +VisualElement::GetAnimationProvider(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetAnimationProvider(); +} + +result +VisualElement::SetContentProvider(IVisualElementContentProvider* pProvider) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->SetContentProvider(pProvider); +} + +IVisualElementContentProvider* +VisualElement::GetContentProvider(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetContentProvider(); +} + + +result +VisualElement::SetVisualElementEventListener(IVisualElementEventListener* pListener) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->SetVisualElementEventListener(pListener); +} + +IVisualElementEventListener* +VisualElement::GetVisualElementEventListener(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetVisualElementEventListener(); +} + + +Tizen::Base::String +VisualElement::GetName(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetName(); +} + +void +VisualElement::SetName(const Tizen::Base::String& name) +{ + CHECK_CONSTRUCTED; + + _pVisualElementImpl->SetName(name); +} + +void +VisualElement::SetUserData(void* pUserData) +{ + CHECK_CONSTRUCTED; + + _pVisualElementImpl->SetUserData(pUserData); +} + +void* +VisualElement::GetUserData(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetUserData(); +} + +result +VisualElement::SetSurface(VisualElementSurface* pSurface) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->SetSurface(pSurface); +} + +VisualElementSurface* +VisualElement::GetSurfaceN(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetSurfaceN(); +} + +result +VisualElement::SetRenderOperation(RenderOperation renderOperation) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->SetRenderOperation(renderOperation); +} + +VisualElement::RenderOperation +VisualElement::GetRenderOperation(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetRenderOperation(); +} + +VisualElement* +VisualElement::GetChild(const Tizen::Base::String& name, bool searchDescendants) const +{ + CHECK_CONSTRUCTED; + + _VisualElementImpl* pChild = _pVisualElementImpl->GetChild(name, searchDescendants); + if (pChild) + { + return pChild->GetPublic(); + } + + return null; +} + +result +VisualElement::InvalidateRectangle(const FloatRectangle* pRectangle) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->InvalidateRectangle(pRectangle); +} + +FloatRectangle +VisualElement::GetUpdateRectangle(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetUpdateRectangle(); +} + +result +VisualElement::Draw(void) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->Draw(); +} + +Canvas* +VisualElement::GetCanvasN(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetCanvasN(); +} + +Canvas* +VisualElement::GetCanvasN(const Tizen::Graphics::Rectangle& bounds) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetCanvasN(bounds); +} + +VisualElement* +VisualElement::GetChildAt(const FloatPoint& point) const +{ + CHECK_CONSTRUCTED; + + _VisualElementImpl* pChild = _pVisualElementImpl->GetChildAt(point); + if (pChild) + { + return pChild->GetPublic(); + } + + return null; +} + +bool +VisualElement::IsClipChildrenEnabled(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->IsClipChildrenEnabled(); +} + +void +VisualElement::SetClipChildrenEnabled(bool clipChildren) +{ + CHECK_CONSTRUCTED; + + _pVisualElementImpl->SetClipChildrenEnabled(clipChildren); +} + +result +VisualElement::ConvertCoordinates(FloatPoint& point, const VisualElement* pFromVisualElement) const +{ + CHECK_CONSTRUCTED; + + _VisualElementImpl* pFrom = null; + + if (pFromVisualElement) + { + CHECK_PARAMETER_CONSTRUCTED(*pFromVisualElement); + pFrom = pFromVisualElement->_pVisualElementImpl; + } + + return _pVisualElementImpl->ConvertCoordinates(point, pFrom); +} + +result +VisualElement::ConvertCoordinates(FloatRectangle& rectangle, const VisualElement* pFromVisualElement) const +{ + CHECK_CONSTRUCTED; + + _VisualElementImpl* pFrom = null; + + if (pFromVisualElement) + { + CHECK_PARAMETER_CONSTRUCTED(*pFromVisualElement); + pFrom = pFromVisualElement->_pVisualElementImpl; + } + + return _pVisualElementImpl->ConvertCoordinates(rectangle, pFrom); +} + +result +VisualElement::SetContentBounds(const FloatRectangle& contentBounds) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->SetContentBounds(contentBounds); +} + +FloatRectangle +VisualElement::GetContentBounds(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetContentBounds(); +} + + +result +VisualElement::AddAnimation(const VisualElementAnimation& animation) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->AddAnimation(null, const_cast< VisualElementAnimation& >(animation)); +} + +result +VisualElement::AddAnimation(const Tizen::Base::String& keyName, const VisualElementAnimation& animation) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->AddAnimation(&keyName, const_cast< VisualElementAnimation& >(animation)); +} + + +result +VisualElement::RemoveAnimation(const Tizen::Base::String& keyName) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->RemoveAnimation(keyName); +} + +VisualElementAnimation* +VisualElement::GetAnimationN(const Tizen::Base::String& keyName) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetAnimationN(keyName); +} + +void +VisualElement::RemoveAllAnimations(void) +{ + CHECK_CONSTRUCTED; + + _pVisualElementImpl->RemoveAllAnimations(); +} + +const VisualElement* +VisualElement::AcquirePresentationInstance(void) +{ + CHECK_CONSTRUCTED; + + if (likely(_pVisualElementImpl->GetPresentation())) + { + return _pVisualElementImpl->GetPresentation()->GetPublic(); + } + + return null; +} + +void +VisualElement::ReleasePresentationInstance(void) +{ + return; +} + +const VisualElement* +VisualElement::AcquireModelInstance(void) +{ + CHECK_CONSTRUCTED; + + if (likely(_pVisualElementImpl->GetModel())) + { + return _pVisualElementImpl->GetModel()->GetPublic(); + } + + return null; +} + +void +VisualElement::ReleaseModelInstance(void) +{ + return; +} + +void +VisualElement::SetImplicitAnimationEnabled(bool enable) +{ + CHECK_CONSTRUCTED; + + _pVisualElementImpl->SetImplicitAnimationEnabled(enable); +} + +bool +VisualElement::IsImplicitAnimationEnabled(void) const +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->GetImplicitAnimationEnabled(); +} + +// Delegations +void +VisualElement::OnConstructed(void) +{ + +} + +/** + * This method is invoked before deallocating the VisualElement instance in the Destroy() method. + * @since 2.0 + * + * @see Destroy() + * @see Construct() + * @see OnConstructed() + */ +void +VisualElement::OnDestructing(void) +{ +} + +HitTestResult +VisualElement::OnHitTest(const FloatPoint& point) +{ + CHECK_CONSTRUCTED; + + int hitResult = _pVisualElementImpl->HitTestI(point); + + if (hitResult == _VisualElementImpl::HITTEST_MATCH) + { + return HIT_TEST_MATCH; + } + + return HIT_TEST_NOWHERE; +} + +bool +VisualElement::OnPrepareDraw(void) +{ + return true; +} + +result +VisualElement::SetFlushNeeded(void) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->SetFlushNeeded(); +} + +result +VisualElement::Flush(void) +{ + return _VisualElementImpl::FlushI(); +} + +void +VisualElement::OnDraw(Canvas& canvas) +{ +} + +VisualElementAnimation* +VisualElement::OnCreateAnimationForProperty(const Tizen::Base::String& property) +{ + CHECK_CONSTRUCTED; + + return _pVisualElementImpl->CreateAnimationForPropertyI(property); +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimVisualElementAnimation.cpp b/src/ui/animations/FUiAnimVisualElementAnimation.cpp new file mode 100644 index 0000000..8a96b27 --- /dev/null +++ b/src/ui/animations/FUiAnimVisualElementAnimation.cpp @@ -0,0 +1,465 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementAnimation.cpp + * @brief This file contains implementation of VisualElementAnimation class + * + * This file contains implementation VisualElementAnimation class. + */ + +#include +#include +#include + +#include + +#include "FUiAnim_TimingFunction.h" +#include "FUiAnim_VisualElementAnimationImpl.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +// for TimingFunction +class _Singleton +{ +private: + _Singleton(void) + { + // TODO: may need lock for multi thread + pTimingFunctions = new (std::nothrow) Tizen::Base::Collection::HashMap(); + SysTryReturnVoidResult(NID_UI_ANIM, pTimingFunctions, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pTimingFunctions->Construct(); + if (r != E_SUCCESS) + { + delete pTimingFunctions; + pTimingFunctions = null; + + SetLastResult(r); + return; + } + + // Add timing functions to map + // Linear + LinearTimingFunction* pTimingFunctionLinear = new (std::nothrow) LinearTimingFunction(); + SysTryReturnVoidResult(NID_UI_ANIM, pTimingFunctionLinear, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::String* pKeyLinear = new (std::nothrow) Tizen::Base::String(L"Linear"); + SysTryReturnVoidResult(NID_UI_ANIM, pKeyLinear, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pKeyLinear->ToLower(); + pTimingFunctions->Add(*pKeyLinear, *pTimingFunctionLinear); + + // EaseIn + EaseInTimingFunction* pTimingFunctionEaseIn = new (std::nothrow) EaseInTimingFunction(); + SysTryReturnVoidResult(NID_UI_ANIM, pTimingFunctionEaseIn, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::String* pKeyEaseIn = new (std::nothrow) Tizen::Base::String(L"EaseIn"); + SysTryReturnVoidResult(NID_UI_ANIM, pKeyEaseIn, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pKeyEaseIn->ToLower(); + pTimingFunctions->Add(*pKeyEaseIn, *pTimingFunctionEaseIn); + + // EaseOut + EaseOutTimingFunction* pTimingFunctionEaseOut = new (std::nothrow) EaseOutTimingFunction(); + SysTryReturnVoidResult(NID_UI_ANIM, pTimingFunctionEaseOut, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::String* pKeyEaseOut = new (std::nothrow) Tizen::Base::String(L"EaseOut"); + SysTryReturnVoidResult(NID_UI_ANIM, pKeyEaseOut, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pKeyEaseOut->ToLower(); + pTimingFunctions->Add(*pKeyEaseOut, *pTimingFunctionEaseOut); + + // EaseInOut + EaseInOutTimingFunction* pTimingFunctionEaseInOut = new (std::nothrow) EaseInOutTimingFunction(); + SysTryReturnVoidResult(NID_UI_ANIM, pTimingFunctionEaseInOut, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::String* pKeyEaseInOut = new (std::nothrow) Tizen::Base::String(L"EaseInOut"); + SysTryReturnVoidResult(NID_UI_ANIM, pKeyEaseInOut, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pKeyEaseInOut->ToLower(); + pTimingFunctions->Add(*pKeyEaseInOut, *pTimingFunctionEaseInOut); + + // EaseOutIn + EaseOutInTimingFunction* pTimingFunctionEaseOutIn = new (std::nothrow) EaseOutInTimingFunction(); + SysTryReturnVoidResult(NID_UI_ANIM, pTimingFunctionEaseOutIn, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::String* pKeyEaseOutIn = new (std::nothrow) Tizen::Base::String(L"EaseOutIn"); + SysTryReturnVoidResult(NID_UI_ANIM, pKeyEaseOutIn, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pKeyEaseOutIn->ToLower(); + pTimingFunctions->Add(*pKeyEaseOutIn, *pTimingFunctionEaseOutIn); + + // Discrete + DiscreteTimingFunction* pTimingFunctionDiscrete = new (std::nothrow) DiscreteTimingFunction(); + SysTryReturnVoidResult(NID_UI_ANIM, pTimingFunctionDiscrete, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::String* pKeyDiscrete = new (std::nothrow) Tizen::Base::String(L"Discrete"); + SysTryReturnVoidResult(NID_UI_ANIM, pKeyDiscrete, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pKeyDiscrete->ToLower(); + pTimingFunctions->Add(*pKeyDiscrete, *pTimingFunctionDiscrete); + + // Bezier + BezierTimingFunction* pTimingFunctionBezier = new (std::nothrow) BezierTimingFunction(); + SysTryReturnVoidResult(NID_UI_ANIM, pTimingFunctionBezier, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::String* pKeyBezier = new (std::nothrow) Tizen::Base::String(L"Bezier"); + SysTryReturnVoidResult(NID_UI_ANIM, pKeyBezier, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pKeyBezier->ToLower(); + pTimingFunctions->Add(*pKeyBezier, *pTimingFunctionBezier); + + // ExpIn + ExpInTimingFunction* pTimingFunctionExpIn = new (std::nothrow) ExpInTimingFunction(); + SysTryReturnVoidResult(NID_UI_ANIM, pTimingFunctionExpIn, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::String* pKeyExpIn = new (std::nothrow) Tizen::Base::String(L"ExpIn"); + SysTryReturnVoidResult(NID_UI_ANIM, pKeyExpIn, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pKeyExpIn->ToLower(); + pTimingFunctions->Add(*pKeyExpIn, *pTimingFunctionExpIn); + + // ExpOut + ExpOutTimingFunction* pTimingFunctionExpOut = new (std::nothrow) ExpOutTimingFunction(); + SysTryReturnVoidResult(NID_UI_ANIM, pTimingFunctionExpOut, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::String* pKeyExpOut = new (std::nothrow) Tizen::Base::String(L"ExpOut"); + SysTryReturnVoidResult(NID_UI_ANIM, pKeyExpOut, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pKeyExpOut->ToLower(); + pTimingFunctions->Add(*pKeyExpOut, *pTimingFunctionExpOut); + + // EaseElasticIn + EaseElasticInTimingFunction* pTimingFunctionEaseElasticIn = new (std::nothrow) EaseElasticInTimingFunction(); + SysTryReturnVoidResult(NID_UI_ANIM, pTimingFunctionEaseElasticIn, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::String* pKeyEaseElasticIn = new (std::nothrow) Tizen::Base::String(L"EaseElasticIn"); + SysTryReturnVoidResult(NID_UI_ANIM, pKeyEaseElasticIn, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pKeyEaseElasticIn->ToLower(); + pTimingFunctions->Add(*pKeyEaseElasticIn, *pTimingFunctionEaseElasticIn); + + // EaseElasticOut + EaseElasticOutTimingFunction* pTimingFunctionEaseElasticOut = new (std::nothrow) EaseElasticOutTimingFunction(); + SysTryReturnVoidResult(NID_UI_ANIM, pTimingFunctionEaseElasticOut, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Tizen::Base::String* pKeyEaseElasticOut = new (std::nothrow) Tizen::Base::String(L"EaseElasticOut"); + SysTryReturnVoidResult(NID_UI_ANIM, pKeyEaseElasticOut, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pKeyEaseElasticOut->ToLower(); + pTimingFunctions->Add(*pKeyEaseElasticOut, *pTimingFunctionEaseElasticOut); + } + + ~_Singleton(void) + { + if (pTimingFunctions) + { + pTimingFunctions->RemoveAll(true); + } + + delete pTimingFunctions; + pTimingFunctions = null; + } + + static void + InitSingleton(void) + { + static _Singleton inst; + __pInstance = &inst; + } + +public: + static _Singleton* + GetInstance(void) + { + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + if (!__pInstance) + { + pthread_once(&once_block, InitSingleton); + } + + return __pInstance; + } + + +public: + Tizen::Base::Collection::HashMap* pTimingFunctions; + +private: + _Singleton(const _Singleton& rhs); + _Singleton& operator =(const _Singleton& rhs); + static _Singleton* __pInstance; + +}; + +_Singleton* _Singleton::__pInstance = null; + +VisualElementAnimation::VisualElementAnimation(void) +{ + ClearLastResult(); + + _pAnimationImpl = new (std::nothrow) _VisualElementAnimationImpl(); + if (_pAnimationImpl == null) + { + SetLastResult(E_OUT_OF_MEMORY); + } +} + +VisualElementAnimation::~VisualElementAnimation(void) +{ + if (_pAnimationImpl) + { + delete _pAnimationImpl; + _pAnimationImpl = null; + } +} + +VisualElementAnimation::VisualElementAnimation(_VisualElementAnimationImpl* pAnimationImpl) + : _pAnimationImpl(pAnimationImpl) +{ + ClearLastResult(); +} + +VisualElementAnimation::VisualElementAnimation(const VisualElementAnimation& animation) + : _pAnimationImpl(null) +{ + ClearLastResult(); + + _pAnimationImpl = new (std::nothrow) _VisualElementAnimationImpl(*(animation._pAnimationImpl)); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationImpl != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); +} + +VisualElementAnimation& +VisualElementAnimation::operator =(const VisualElementAnimation& rhs) +{ + if (this != (&rhs)) + { + result r = _pAnimationImpl->CopyAnimationValue(*(rhs._pAnimationImpl)); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, r, "[%s] Failed to copy the animation value.", GetErrorMessage(r)); + } + + return *this; +} + +bool +VisualElementAnimation::operator ==(const VisualElementAnimation& rhs) const +{ + if (this == &rhs) + { + return true; + } + + return (_pAnimationImpl->Equals(*(rhs._pAnimationImpl))); +} + +bool +VisualElementAnimation::operator !=(const VisualElementAnimation& rhs) const +{ + return (!operator == (rhs)); +} + +bool +VisualElementAnimation::Equals(const Tizen::Base::Object& obj) const +{ + const VisualElementAnimation* pAnimation = dynamic_cast< const VisualElementAnimation* >(&obj); + + if (pAnimation == null) + { + return false; + } + + return (*this == *pAnimation); +} + +int +VisualElementAnimation::GetHashCode(void) const +{ + return _pAnimationImpl->GetHashCode(); +} + +VisualElementAnimation* +VisualElementAnimation::CloneN(void) const +{ + VisualElementAnimation* pCloned = new (std::nothrow) VisualElementAnimation(*this); + SysTryReturn(NID_UI_ANIM, (pCloned != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pCloned; +} + +void +VisualElementAnimation::SetVisualElementAnimationStatusEventListener(IVisualElementAnimationStatusEventListener* pListener) +{ + _pAnimationImpl->SetStatusEventListener(pListener); +} + +IVisualElementAnimationStatusEventListener* +VisualElementAnimation::GetVisualElementAnimationStatusEventListener(void) const +{ + return _pAnimationImpl->GetStatusEventListener(); +} + +void +VisualElementAnimation::SetTimingFunction(const IVisualElementAnimationTimingFunction* pTimingFunction) +{ + _pAnimationImpl->SetTimingFunction(pTimingFunction); +} + +const IVisualElementAnimationTimingFunction* +VisualElementAnimation::GetTimingFunction(void) const +{ + return _pAnimationImpl->GetTimingFunction(); +} + +void +VisualElementAnimation::SetValueInterpolator(const IVisualElementAnimationValueInterpolator* pInterpolator) +{ + _pAnimationImpl->SetValueInterpolator(pInterpolator); +} + +const IVisualElementAnimationValueInterpolator* +VisualElementAnimation::GetValueInterpolator(void) const +{ + return _pAnimationImpl->GetValueInterpolator(); +} + +result +VisualElementAnimation::SetDuration(long milliseconds) +{ + SysTryReturnResult(NID_UI_ANIM, (milliseconds >= 0 && milliseconds >= _pAnimationImpl->GetOffset()), + E_INVALID_ARG, "Invalid argument(s) is used. milliseconds = %ld", milliseconds); + + _pAnimationImpl->SetDuration(milliseconds); + + return E_SUCCESS; +} + +long +VisualElementAnimation::GetDuration(void) const +{ + return _pAnimationImpl->GetDuration(); +} + +result +VisualElementAnimation::SetOffset(long milliseconds) +{ + SysTryReturnResult(NID_UI_ANIM, (milliseconds >= 0 && milliseconds <= _pAnimationImpl->GetDuration()), + E_INVALID_ARG, "Invalid argument(s) is used. milliseconds = %ld", milliseconds); + + _pAnimationImpl->SetOffset(milliseconds); + + return E_SUCCESS; +} + +long +VisualElementAnimation::GetOffset(void) const +{ + return _pAnimationImpl->GetOffset(); +} + +result +VisualElementAnimation::SetDelay(long milliseconds) +{ + SysTryReturnResult(NID_UI_ANIM, (milliseconds >= 0), E_INVALID_ARG, "Invalid argument(s) is used. milliseconds = %ld", milliseconds); + + _pAnimationImpl->SetDelay(milliseconds); + + return E_SUCCESS; +} + +long +VisualElementAnimation::GetDelay(void) const +{ + return _pAnimationImpl->GetDelay(); +} + +result +VisualElementAnimation::SetRepeatCount(long count) +{ + SysTryReturnResult(NID_UI_ANIM, (count >= 0), E_INVALID_ARG, "Invalid argument(s) is used. count = %ld", count); + + _pAnimationImpl->SetRepeatCount(count); + + return E_SUCCESS; +} + +long +VisualElementAnimation::GetRepeatCount(void) const +{ + return _pAnimationImpl->GetRepeatCount(); +} + +void +VisualElementAnimation::SetAutoReverseEnabled(bool autoReverse) +{ + _pAnimationImpl->SetAutoReverseEnabled(autoReverse); +} + +bool +VisualElementAnimation::IsAutoReverseEnabled(void) const +{ + return _pAnimationImpl->IsAutoReverseEnabled(); +} + +result +VisualElementAnimation::SetScaleRatio(float scaleRatio) +{ + SysTryReturnResult(NID_UI_ANIM, (scaleRatio > 0.f), E_INVALID_ARG, "Invalid argument(s) is used. scaleRatio = %f", scaleRatio); + + _pAnimationImpl->SetScaleRatio(scaleRatio); + + return E_SUCCESS; +} + +float +VisualElementAnimation::GetScaleRatio(void) const +{ + return _pAnimationImpl->GetScaleRatio(); +} + +void +VisualElementAnimation::SetUserData(void* pUserData) +{ + _pAnimationImpl->SetUserData(pUserData); +} + +void* +VisualElementAnimation::GetUserData(void) const +{ + return _pAnimationImpl->GetUserData(); +} + +const IVisualElementAnimationTimingFunction* +VisualElementAnimation::GetTimingFunctionByName(const Tizen::Base::String& name) +{ + _Singleton* pInstance = _Singleton::GetInstance(); + + SysTryReturn(NID_UI_ANIM, pInstance, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + SysTryReturn(NID_UI_ANIM, pInstance->pTimingFunctions, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + const_cast< Tizen::Base::String& >(name).ToLower(); + + IVisualElementAnimationTimingFunction* pTimingFunction = dynamic_cast< IVisualElementAnimationTimingFunction* >(pInstance->pTimingFunctions->GetValue(name)); + + SysTryReturn(NID_UI_ANIM, pTimingFunction, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. name = %ls.", name.GetPointer()); + + return pTimingFunction; +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimVisualElementAnimationGroup.cpp b/src/ui/animations/FUiAnimVisualElementAnimationGroup.cpp new file mode 100644 index 0000000..e261497 --- /dev/null +++ b/src/ui/animations/FUiAnimVisualElementAnimationGroup.cpp @@ -0,0 +1,162 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementAnimationGroup.cpp + * @brief This file contains implementation of VisualElementAnimationGroup class + * + * This file contains implementation VisualElementAnimationGroup class. + */ + +#include + +#include +#include + +#include "FUiAnim_VisualElementAnimationGroupImpl.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +VisualElementAnimationGroup::VisualElementAnimationGroup(void) + : VisualElementAnimation(new (std::nothrow) _VisualElementAnimationGroupImpl()) +{ + if (_pAnimationImpl == null) + { + SetLastResult(E_OUT_OF_MEMORY); + } +} + +VisualElementAnimationGroup::~VisualElementAnimationGroup(void) +{ + +} + +VisualElementAnimationGroup::VisualElementAnimationGroup(const VisualElementAnimationGroup& animationGroup) + : VisualElementAnimation(null) +{ + ClearLastResult(); + + const _VisualElementAnimationGroupImpl* pAnimationImpl = _VisualElementAnimationGroupImpl::GetInstance(animationGroup); + + _pAnimationImpl = new (std::nothrow) _VisualElementAnimationGroupImpl(*pAnimationImpl); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationImpl), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); +} + +VisualElementAnimationGroup& +VisualElementAnimationGroup::operator =(const VisualElementAnimationGroup& rhs) +{ + ClearLastResult(); + + if (this != (&rhs)) + { + _VisualElementAnimationGroupImpl* pAnimationImpl = _VisualElementAnimationGroupImpl::GetInstance(*this); + const _VisualElementAnimationGroupImpl* pRhsAnimationImpl = _VisualElementAnimationGroupImpl::GetInstance(rhs); + + result r = pAnimationImpl->CopyAnimationValue(*pRhsAnimationImpl); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, r, "[%s] Failed to copy the animation value.", GetErrorMessage(r)); + } + + return *this; +} + +bool +VisualElementAnimationGroup::operator ==(const VisualElementAnimationGroup& rhs) const +{ + return VisualElementAnimation::operator ==(rhs); +} + +bool +VisualElementAnimationGroup::operator !=(const VisualElementAnimationGroup& rhs) const +{ + return (!operator ==(rhs)); +} + +bool +VisualElementAnimationGroup::Equals(const Tizen::Base::Object& obj) const +{ + const VisualElementAnimationGroup* pAnimationGroup = dynamic_cast< const VisualElementAnimationGroup* >(&obj); + + if (pAnimationGroup == null) + { + return false; + } + + return (*this == *pAnimationGroup); +} + +int +VisualElementAnimationGroup::GetHashCode(void) const +{ + return VisualElementAnimation::GetHashCode(); +} + +VisualElementAnimation* +VisualElementAnimationGroup::CloneN(void) const +{ + VisualElementAnimation* pCloned = new (std::nothrow) VisualElementAnimationGroup(*this); + SysTryReturn(NID_UI_ANIM, pCloned, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pCloned; +} + +int +VisualElementAnimationGroup::GetAnimationCount(void) const +{ + const _VisualElementAnimationGroupImpl* pAnimationImpl = _VisualElementAnimationGroupImpl::GetInstance(*this); + + return pAnimationImpl->GetAnimationCount(); +} + +result +VisualElementAnimationGroup::AddAnimation(const VisualElementAnimation& animation) +{ + _VisualElementAnimationGroupImpl* pAnimationImpl = _VisualElementAnimationGroupImpl::GetInstance(*this); + + return pAnimationImpl->AddAnimation(animation); +} + +result +VisualElementAnimationGroup::RemoveAnimationAt(int index) +{ + _VisualElementAnimationGroupImpl* pAnimationImpl = _VisualElementAnimationGroupImpl::GetInstance(*this); + + SysTryReturnResult(NID_UI_ANIM, (index >= 0 && index < pAnimationImpl->GetAnimationCount()), E_OUT_OF_RANGE, "Index (%d) is out of range.", index); + + return pAnimationImpl->RemoveAnimationAt(index); +} + +void +VisualElementAnimationGroup::RemoveAllAnimations(void) +{ + _VisualElementAnimationGroupImpl* pAnimationImpl = _VisualElementAnimationGroupImpl::GetInstance(*this); + + pAnimationImpl->RemoveAllAnimations(); +} + +VisualElementAnimation* +VisualElementAnimationGroup::GetAnimationAtN(int index) const +{ + const _VisualElementAnimationGroupImpl* pAnimationImpl = _VisualElementAnimationGroupImpl::GetInstance(*this); + + SysTryReturn(NID_UI_ANIM, (index >= 0 && index < pAnimationImpl->GetAnimationCount()), null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index (%d) is out of range.", index); + + return pAnimationImpl->GetAnimationAtN(index); +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimVisualElementAnimationProvider.cpp b/src/ui/animations/FUiAnimVisualElementAnimationProvider.cpp new file mode 100644 index 0000000..9569206 --- /dev/null +++ b/src/ui/animations/FUiAnimVisualElementAnimationProvider.cpp @@ -0,0 +1,46 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementAnimationProvider.cpp + * @brief This file contains implementation of VisualElementAnimationProvider class + * + * This file contains implementation VisualElementAnimationProvider class. + */ + +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +VisualElementAnimationProvider::VisualElementAnimationProvider(void) +{ +} + +VisualElementAnimationProvider::~VisualElementAnimationProvider(void) +{ +} + +VisualElementAnimation* +VisualElementAnimationProvider::CreateAnimationForProperty(VisualElement& target, const Tizen::Base::String& property) +{ + return target.OnCreateAnimationForProperty(property); +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimVisualElementContentProvider.cpp b/src/ui/animations/FUiAnimVisualElementContentProvider.cpp new file mode 100644 index 0000000..49a1d70 --- /dev/null +++ b/src/ui/animations/FUiAnimVisualElementContentProvider.cpp @@ -0,0 +1,58 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementContentProvider.cpp + * @brief This file contains implementation of VisualElementContentProvider class + * + * This file contains implementation VisualElementContentProvider class. + */ + +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +VisualElementContentProvider::VisualElementContentProvider(void) +{ +} + +VisualElementContentProvider::~VisualElementContentProvider(void) +{ +} + +bool +VisualElementContentProvider::PrepareDraw(VisualElement& target) +{ + return true; +} + +void +VisualElementContentProvider::DrawContent(VisualElement& target, Tizen::Graphics::Canvas& canvas) +{ + target.OnDraw(canvas); +} + +enum HitTestResult +VisualElementContentProvider::HitTest(VisualElement& target, const Tizen::Graphics::FloatPoint& point) +{ + return target.OnHitTest(point); +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimVisualElementPropertyAnimation.cpp b/src/ui/animations/FUiAnimVisualElementPropertyAnimation.cpp new file mode 100644 index 0000000..9aca281 --- /dev/null +++ b/src/ui/animations/FUiAnimVisualElementPropertyAnimation.cpp @@ -0,0 +1,137 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementPropertyAnimation.cpp + * @brief This file contains implementation of VisualElementPropertyAnimation class + * + * This file contains implementation VisualElementPropertyAnimation class. + */ + +#include + +#include + +#include "FUiAnim_VisualElementPropertyAnimationImpl.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +VisualElementPropertyAnimation::VisualElementPropertyAnimation(void) + : VisualElementValueAnimation(new (std::nothrow) _VisualElementPropertyAnimationImpl()) +{ + if (_pAnimationImpl == null) + { + SetLastResult(E_OUT_OF_MEMORY); + } +} + +VisualElementPropertyAnimation::~VisualElementPropertyAnimation(void) +{ + +} + +VisualElementPropertyAnimation::VisualElementPropertyAnimation(const VisualElementPropertyAnimation& animation) + : VisualElementValueAnimation(null) +{ + ClearLastResult(); + + const _VisualElementPropertyAnimationImpl* pAnimationImpl = _VisualElementPropertyAnimationImpl::GetInstance(animation); + + _pAnimationImpl = new (std::nothrow) _VisualElementPropertyAnimationImpl(*pAnimationImpl); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationImpl), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); +} + +VisualElementPropertyAnimation& +VisualElementPropertyAnimation::operator =(const VisualElementPropertyAnimation& rhs) +{ + ClearLastResult(); + + if (this != (&rhs)) + { + _VisualElementPropertyAnimationImpl* pAnimationImpl = _VisualElementPropertyAnimationImpl::GetInstance(*this); + const _VisualElementPropertyAnimationImpl* pRhsAnimationImpl = _VisualElementPropertyAnimationImpl::GetInstance(rhs); + + result r = pAnimationImpl->CopyAnimationValue(*pRhsAnimationImpl); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, r, "[%s] Failed to copy the animation value.", GetErrorMessage(r)); + } + + return *this; +} + +bool +VisualElementPropertyAnimation::operator ==(const VisualElementPropertyAnimation& rhs) const +{ + return VisualElementValueAnimation::operator ==(rhs); +} + +bool +VisualElementPropertyAnimation::operator !=(const VisualElementPropertyAnimation& rhs) const +{ + return (!operator ==(rhs)); +} + +bool +VisualElementPropertyAnimation::Equals(const Tizen::Base::Object& obj) const +{ + const VisualElementPropertyAnimation* pAnimation = dynamic_cast< const VisualElementPropertyAnimation* >(&obj); + + if (pAnimation == null) + { + return false; + } + + return (*this == *pAnimation); +} + +int +VisualElementPropertyAnimation::GetHashCode(void) const +{ + return VisualElementValueAnimation::GetHashCode(); +} + +VisualElementAnimation* +VisualElementPropertyAnimation::CloneN(void) const +{ + VisualElementPropertyAnimation* pCloned = new (std::nothrow) VisualElementPropertyAnimation(*this); + SysTryReturn(NID_UI_ANIM, (pCloned != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pCloned; +} + +result +VisualElementPropertyAnimation::SetPropertyName(const Tizen::Base::String& property) +{ + _VisualElementPropertyAnimationImpl* pAnimationImpl = _VisualElementPropertyAnimationImpl::GetInstance(*this); + + SysTryReturnResult(NID_UI_ANIM, (property.IsEmpty() == false), E_INVALID_ARG, "Invalid argument(s) is used. property is empty."); + + pAnimationImpl->SetPropertyName(property); + + return E_SUCCESS; +} + +Tizen::Base::String +VisualElementPropertyAnimation::GetPropertyName(void) const +{ + const _VisualElementPropertyAnimationImpl* pAnimationImpl = _VisualElementPropertyAnimationImpl::GetInstance(*this); + + return pAnimationImpl->GetPropertyName(); +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimVisualElementSurface.cpp b/src/ui/animations/FUiAnimVisualElementSurface.cpp new file mode 100644 index 0000000..4c061cd --- /dev/null +++ b/src/ui/animations/FUiAnimVisualElementSurface.cpp @@ -0,0 +1,144 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementSurface.cpp + * @brief This file contains implementation of VisualElementSurface class + * + * This file contains implementation VisualElementSurface class. + */ + +#include +#include +#include + +#include "FUiAnim_VisualElementCanvas.h" +#include "FUiAnim_VisualElementSurfaceImpl.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + + +#define CHECK_NOT_CONSTRUCTED \ + SysAssertf(__pVisualElementSurfaceImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + +#define CHECK_CONSTRUCTED \ + SysAssertf(__pVisualElementSurfaceImpl, "Not yet constructed! Construct() should be called before use."); + +#define CHECK_PARAMETER_CONSTRUCTED(element) \ + SysAssertf((element).__pVisualElementSurfaceImpl, "Not yet constructed! Construct() should be called before use."); + +namespace Tizen { namespace Ui { namespace Animations +{ + +VisualElementSurface::VisualElementSurface(void) + : __pVisualElementSurfaceImpl(null) +{ +} + +VisualElementSurface::VisualElementSurface(const VisualElementSurface& rhs) + : __pVisualElementSurfaceImpl(null) +{ + CHECK_PARAMETER_CONSTRUCTED(rhs); + + __pVisualElementSurfaceImpl = rhs.__pVisualElementSurfaceImpl; + __pVisualElementSurfaceImpl->AddRef(); +} + +VisualElementSurface& +VisualElementSurface::operator =(const VisualElementSurface& rhs) +{ + CHECK_PARAMETER_CONSTRUCTED(rhs); + + if (&rhs != this) + { + if (__pVisualElementSurfaceImpl != null) + { + __pVisualElementSurfaceImpl->Release(); + } + __pVisualElementSurfaceImpl = rhs.__pVisualElementSurfaceImpl; + __pVisualElementSurfaceImpl->AddRef(); + } + + return *this; +} + +VisualElementSurface::~VisualElementSurface(void) +{ + CHECK_CONSTRUCTED; + + if (__pVisualElementSurfaceImpl->Release()) + { + __pVisualElementSurfaceImpl = null; + } +} + +result +VisualElementSurface::Construct(const DisplayContext& displayContext, const Dimension& size) +{ + CHECK_NOT_CONSTRUCTED; + + SysTryReturnResult(NID_UI_ANIM, size.width >= 0 && size.height >= 0, E_OUT_OF_RANGE, "Can't create the canvas which size is less than zero."); + + unique_ptr<_VisualElementSurfaceImpl> pImpl(_VisualElementSurfaceImpl::CreateInstanceN(displayContext, size)); + result r = GetLastResult(); + SysTryReturnResult(NID_UI_ANIM, pImpl, r, "Propagating."); + + __pVisualElementSurfaceImpl = pImpl.release(); + + return E_SUCCESS; +} + +result +VisualElementSurface::GetBufferInfo(BufferInfo& bufferInfo) const +{ + CHECK_CONSTRUCTED; + + SysTryReturnResult(NID_UI_ANIM, &bufferInfo != null, E_INVALID_STATE, "BufferInfo is not initialized."); + + __pVisualElementSurfaceImpl->GetBufferInfo(bufferInfo); + + return E_SUCCESS; +} + +Dimension +VisualElementSurface::GetSize(void) const +{ + CHECK_CONSTRUCTED; + + return __pVisualElementSurfaceImpl->GetSize(); +} + +bool +VisualElementSurface::Equals(const Tizen::Base::Object& obj) const +{ + CHECK_CONSTRUCTED; + + return __pVisualElementSurfaceImpl->Equals(obj); +} + +int +VisualElementSurface::GetHashCode(void) const +{ + CHECK_CONSTRUCTED; + + return __pVisualElementSurfaceImpl->GetHashCode(); +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnimVisualElementValueAnimation.cpp b/src/ui/animations/FUiAnimVisualElementValueAnimation.cpp new file mode 100644 index 0000000..bf0d805 --- /dev/null +++ b/src/ui/animations/FUiAnimVisualElementValueAnimation.cpp @@ -0,0 +1,223 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnimVisualElementValueAnimation.cpp + * @brief This file contains implementation of VisualElementVAlueAnimation class + * + * This file contains implementation VisualElementPropertyAnimation class. + */ + +#include + +#include + +#include "FUiAnim_VisualElementValueAnimationImpl.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +VisualElementValueAnimation::VisualElementValueAnimation(void) + : VisualElementAnimation(new (std::nothrow) _VisualElementValueAnimationImpl()) +{ + if (_pAnimationImpl == null) + { + SetLastResult(E_OUT_OF_MEMORY); + } +} + +VisualElementValueAnimation::~VisualElementValueAnimation(void) +{ + +} + +VisualElementValueAnimation::VisualElementValueAnimation(_VisualElementValueAnimationImpl* pImpl) + : VisualElementAnimation(pImpl) +{ +} + +VisualElementValueAnimation::VisualElementValueAnimation(const VisualElementValueAnimation& animation) + : VisualElementAnimation(null) +{ + ClearLastResult(); + + const _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(animation); + + _pAnimationImpl = new (std::nothrow) _VisualElementValueAnimationImpl(*pAnimationImpl); + SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationImpl), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); +} + +VisualElementValueAnimation& +VisualElementValueAnimation::operator =(const VisualElementValueAnimation& rhs) +{ + ClearLastResult(); + + if (this != (&rhs)) + { + _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*this); + const _VisualElementValueAnimationImpl* pRhsAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(rhs); + + result r = pAnimationImpl->CopyAnimationValue(*pRhsAnimationImpl); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, r, "[%s] Failed to copy the animation value.", GetErrorMessage(r)); + } + + return *this; +} + +bool +VisualElementValueAnimation::operator ==(const VisualElementValueAnimation& rhs) const +{ + return VisualElementAnimation::operator ==(rhs); +} + +bool +VisualElementValueAnimation::operator !=(const VisualElementValueAnimation& rhs) const +{ + return (!operator ==(rhs)); +} + +bool +VisualElementValueAnimation::Equals(const Tizen::Base::Object& obj) const +{ + const VisualElementValueAnimation* pAnimation = dynamic_cast< const VisualElementValueAnimation* >(&obj); + + if (pAnimation == null) + { + return false; + } + + return (*this == *pAnimation); +} + +int +VisualElementValueAnimation::GetHashCode(void) const +{ + return VisualElementAnimation::GetHashCode(); +} + +VisualElementAnimation* +VisualElementValueAnimation::CloneN(void) const +{ + VisualElementAnimation* pCloned = new (std::nothrow) VisualElementValueAnimation(*this); + SysTryReturn(NID_UI_ANIM, (pCloned != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pCloned; +} + +void +VisualElementValueAnimation::SetVisualElementAnimationTickEventListener(IVisualElementAnimationTickEventListener* pListener) +{ + _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*this); + + pAnimationImpl->SetTickEventListener(pListener); +} + +IVisualElementAnimationTickEventListener* +VisualElementValueAnimation::GetVisualElementAnimationTickEventListener(void) const +{ + const _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*this); + + return pAnimationImpl->GetTickEventListener(); +} + +result +VisualElementValueAnimation::SetStartValue(const Tizen::Ui::Variant& startValue) +{ + SysTryReturnResult(NID_UI_ANIM, (startValue.IsEmpty() == false), E_INVALID_ARG, "Invalid argument(s) is used. startValue is empty."); + + _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*this); + + pAnimationImpl->SetStartValue(startValue); + + return E_SUCCESS; +} + +Tizen::Ui::Variant +VisualElementValueAnimation::GetStartValue(void) const +{ + const _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*this); + + return pAnimationImpl->GetStartValue(); +} + +result +VisualElementValueAnimation::SetEndValue(const Tizen::Ui::Variant& endValue) +{ + SysTryReturnResult(NID_UI_ANIM, (endValue.IsEmpty() == false), E_INVALID_ARG, "Invalid argument(s) is used. endValue is empty."); + + _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*this); + + pAnimationImpl->SetEndValue(endValue); + + return E_SUCCESS; +} + +Tizen::Ui::Variant +VisualElementValueAnimation::GetEndValue(void) const +{ + const _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*this); + + return pAnimationImpl->GetEndValue(); +} + +void +VisualElementValueAnimation::SetEndValueApplied(bool apply) +{ + _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*this); + + pAnimationImpl->SetEndValueApplied(apply); +} + +bool +VisualElementValueAnimation::IsEndValueApplied(void) const +{ + const _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*this); + + return pAnimationImpl->IsEndValueApplied(); +} + +result +VisualElementValueAnimation::AddKeyFrame(float timeProgress, const Tizen::Ui::Variant& value, const IVisualElementAnimationTimingFunction* pTimingFunction) +{ + SysTryReturnResult(NID_UI_ANIM, (timeProgress > 0.0f && timeProgress < 1.0f), E_OUT_OF_RANGE, "The time (%f) is out of range.", timeProgress); + SysTryReturnResult(NID_UI_ANIM, (value.IsEmpty() == false), E_INVALID_ARG, "Invalid argument(s) is used. value is empty."); + + _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*this); + + return pAnimationImpl->AddKeyFrame(timeProgress, value, pTimingFunction); +} + +result +VisualElementValueAnimation::RemoveKeyFrame(float timeProgress) +{ + SysTryReturnResult(NID_UI_ANIM, (timeProgress > 0.0f && timeProgress < 1.0f), E_OUT_OF_RANGE, "The time (%f) is out of range.", timeProgress); + + _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*this); + + return pAnimationImpl->RemoveKeyFrame(timeProgress); +} + +void +VisualElementValueAnimation::RemoveAllKeyFrames(void) +{ + _VisualElementValueAnimationImpl* pAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*this); + + pAnimationImpl->RemoveAllKeyFrames(); +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_AnimationBaseImpl.cpp b/src/ui/animations/FUiAnim_AnimationBaseImpl.cpp new file mode 100644 index 0000000..590015d --- /dev/null +++ b/src/ui/animations/FUiAnim_AnimationBaseImpl.cpp @@ -0,0 +1,250 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_AnimationBaseImpl.cpp + * @brief This file contains implementation of _AnimationBaseImpl class + * + * This file contains implementation _AnimationBaseImpl class. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "FUiAnim_AnimationBaseImpl.h" + + +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + + +#define INTERPOLATOR_LINEAR L"Linear" +#define INTERPOLATOR_EASEIN L"EaseIn" +#define INTERPOLATOR_EASEOUT L"EaseOut" +#define INTERPOLATOR_EASEINOUT L"EaseInOut" +#define INTERPOLATOR_DISCRETE L"Discrete" +#define INTERPOLATOR_BEZIER L"Bezier" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +_AnimationBaseImpl::_AnimationBaseImpl(AnimationBase* pAnimationBase) + : controlPointTime1(0.0) + , controlPointValue1(0.0) + , controlPointTime2(0.0) + , controlPointValue2(0.0) + , interpolator(ANIMATION_INTERPOLATOR_LINEAR) + , animName(String()) + , duration(250) + , offset(0) + , delay(0) + , repeatCount(1) + , autoReverse(false) + , scaleRatio(1.0f) + , holdEnd(true) + , __pAnimationBase(pAnimationBase) +{ + +} + +_AnimationBaseImpl::~_AnimationBaseImpl(void) +{ + result r = RemoveAllKeyFrames(); + + SysTryReturnVoidResult(NID_UI_ANIM, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +_AnimationBaseImpl::Construct(void) +{ + return keyFrameList.Construct(); +} + + +result +_AnimationBaseImpl::RemoveKeyFrame(long time) +{ + SysTryReturnResult(NID_UI_ANIM, (time > 0 && time <= duration), E_INVALID_ARG, "Invalid argument(s) is used. time =%ld", time); + + result r = E_SUCCESS; + + Object* pObj = null; + + r = keyFrameList.GetValue(time, pObj); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_OBJ_NOT_FOUND, "Key frame is not found. time = %ld", time); + + delete pObj; + + keyFrameList.Remove(time); + + return E_SUCCESS; +} + +result +_AnimationBaseImpl::RemoveKeyFrameAt(int index) +{ + SysTryReturnResult(NID_UI_ANIM, (index >= 0 && index < keyFrameList.GetCount()), E_OUT_OF_RANGE, "Index (%d) is out of range.", index); + + result r = E_SUCCESS; + + ComparerT< long > comparer; + + Object* pObj = null; + long time = 0; + + ArrayListT< long >* pKeyList = new (std::nothrow) ArrayListT< long >; + SysTryReturnResult(NID_UI_ANIM, (pKeyList), E_OUT_OF_MEMORY, "Memory allocation failed."); + + ICollectionT< long >* pKeyN = keyFrameList.GetKeysN(); + SysTryCatch(NID_UI_ANIM, (pKeyN), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pKeyList->Construct(*pKeyN); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to construct key list."); + SysTryCatch(NID_UI_ANIM, !(pKeyList->GetCount() <= 0), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Key list count is invalid."); + + r = pKeyList->Sort(comparer); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + r = pKeyList->GetAt(index, time); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to sort key list."); + + keyFrameList.GetValue(time, pObj); + delete pObj; + + keyFrameList.Remove(time); + + //fall through +CATCH: + delete pKeyN; + delete pKeyList; + return r; + + return E_SUCCESS; +} + +result +_AnimationBaseImpl::RemoveAllKeyFrames(void) +{ + if (keyFrameList.GetCount() > 0) + { + IMapEnumeratorT< long, Object* >* pMapEnum = keyFrameList.GetMapEnumeratorN(); + result r = GetLastResult(); + SysTryReturnResult(NID_UI_ANIM, (pMapEnum != null), r, "Propagating."); + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + Object* pValue = null; + pMapEnum->GetValue(pValue); + delete pValue; + } + + delete pMapEnum; + + keyFrameList.RemoveAll(); + } + + return E_SUCCESS; +} + +bool +_AnimationBaseImpl::CompareTimingValues(const AnimationBase& animBase) +{ + return ((interpolator == animBase._pAnimationBaseImpl->interpolator) + && (animName == animBase._pAnimationBaseImpl->animName) + && (duration == animBase._pAnimationBaseImpl->duration) + && (offset == animBase._pAnimationBaseImpl->offset) + && (delay == animBase._pAnimationBaseImpl->delay) + && (repeatCount == animBase._pAnimationBaseImpl->repeatCount) + && (autoReverse == animBase._pAnimationBaseImpl->autoReverse) + && (!(Float::Compare(scaleRatio, animBase._pAnimationBaseImpl->scaleRatio))) + && (holdEnd == animBase._pAnimationBaseImpl->holdEnd) + && (!(Float::Compare(controlPointTime1, animBase._pAnimationBaseImpl->controlPointTime1))) + && (!(Float::Compare(controlPointValue1, animBase._pAnimationBaseImpl->controlPointValue1))) + && (!(Float::Compare(controlPointTime2, animBase._pAnimationBaseImpl->controlPointTime2))) + && (!(Float::Compare(controlPointValue2, animBase._pAnimationBaseImpl->controlPointValue2)))); +} + +float +_AnimationBaseImpl::GetActualProgressValue(long currentTime) +{ + const IVisualElementAnimationTimingFunction* pTimingFunction = null; + + switch (interpolator) + { + case ANIMATION_INTERPOLATOR_LINEAR: + { + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_LINEAR); + } + break; + + case ANIMATION_INTERPOLATOR_EASE_IN: + { + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_EASEIN); + } + break; + + case ANIMATION_INTERPOLATOR_EASE_OUT: + { + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_EASEOUT); + } + break; + + case ANIMATION_INTERPOLATOR_EASE_IN_OUT: + { + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_EASEINOUT); + } + break; + + case ANIMATION_INTERPOLATOR_DISCRETE: + { + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_DISCRETE); + } + break; + + case ANIMATION_INTERPOLATOR_BEZIER: + { + pTimingFunction = new (std::nothrow) BezierTimingFunction(); + SysTryReturn(NID_UI_ANIM, (pTimingFunction), -1.0f, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + ((BezierTimingFunction*) pTimingFunction)->SetControlPoints(controlPointTime1, controlPointValue1, controlPointTime2, controlPointValue2); + } + break; + + } + + SysTryReturn(NID_UI_ANIM, pTimingFunction, -1.0f, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Timing function is null."); + + long duration = __pAnimationBase->GetDuration(); + float dur = (1.0f / (float) duration) * ((float) currentTime); + float actualProgress = pTimingFunction->CalculateProgress( static_cast< float >(dur)); + + return actualProgress; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_AnimationBaseImpl.h b/src/ui/animations/FUiAnim_AnimationBaseImpl.h new file mode 100644 index 0000000..4e0542b --- /dev/null +++ b/src/ui/animations/FUiAnim_AnimationBaseImpl.h @@ -0,0 +1,186 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_AnimationBaseImpl.h + * @brief This is the header file for the _AnimationBaseImpl class. + * + * This header file contains the declarations of the _AnimationBaseImpl class. @n + */ + +#ifndef _FUI_ANIM_INTERNAL_ANIMATION_BASE_IMPL_H_ +#define _FUI_ANIM_INTERNAL_ANIMATION_BASE_IMPL_H_ + +#include +#include + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +/** + * @class _AnimationBaseImpl + * @brief This is the header file for the _AnimationBaseImpl class. + * @since 2.0 + * + * This header file contains the declarations of the _AnimationBaseImpl class. @n + * + */ +class _AnimationBaseImpl + : public Tizen::Base::Object +{ +public: + /** + * Default constructor for %_AnimationBaseImpl class. + */ + _AnimationBaseImpl(AnimationBase* pAnimationBase); + + /** + * Destructor for %_AnimationBaseImpl class. + */ + ~_AnimationBaseImpl(void); + + /** + * Initializes this instance of Animation with the specified parameters. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM Failed to construct. + */ + result Construct(void); + + result RemoveKeyFrame(long time); + result RemoveKeyFrameAt(int index); + result RemoveAllKeyFrames(void); + + /** + * Compares the timeline values of two Animation instances + */ + bool CompareTimingValues(const AnimationBase& animBase); + + /** + * Calculates actual progress based on timing function + */ + float GetActualProgressValue(long currentTime); + + /** + * The List composing keyframe values + */ + Tizen::Base::Collection::HashMapT< long, Tizen::Base::Object* > keyFrameList; + + /** + * The Bezier Control point - Time1 + */ + float controlPointTime1; + + /** + * The Bezier Control point - value 1 + */ + float controlPointValue1; + + /** + * The Bezier Control point - Time 2 + */ + float controlPointTime2; + + /** + * The Bezier Control point - value 2 + */ + float controlPointValue2; + + /** + * The Interpolator type + */ + AnimationInterpolatorType interpolator; + + /** + * The Animation name + */ + Tizen::Base::String animName; + + /** + * The duration of animation in milliseconds + */ + long duration; + + /** + * Offset in milliseconds after the start of the animation + */ + long offset; + + /** + * The delay in milliseconds before animaiton start + */ + long delay; + + /** + * Number of times the animation has to be repeated + */ + long repeatCount; + + /** + * AutoReverse the animation after completing the animation + */ + bool autoReverse; + + /** + * Sclae ratio of the animation duration + */ + float scaleRatio; + + /** + * Hold the animation end values or not + */ + bool holdEnd; + +private: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + _AnimationBaseImpl& operator =(const _AnimationBaseImpl&); + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the copy constructor for this class. + // + // @since 2.0 + // + _AnimationBaseImpl(const _AnimationBaseImpl& rhs); + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // @since 2.0 + // + Tizen::Ui::Animations::AnimationBase* __pAnimationBase; +}; // _AnimationBaseImpl + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_ANIMATION_BASE_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_AnimationGroupImpl.cpp b/src/ui/animations/FUiAnim_AnimationGroupImpl.cpp new file mode 100644 index 0000000..3eb2976 --- /dev/null +++ b/src/ui/animations/FUiAnim_AnimationGroupImpl.cpp @@ -0,0 +1,357 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_AnimationGroupImpl.cpp + * @brief This file contains implementation of _AnimationGroupImpl class + * + * This file contains implementation _AnimationGroupImpl class. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "FUiAnim_AnimationGroupImpl.h" + + +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +_AnimationGroupImpl::_AnimationGroupImpl(AnimationGroup* pAnimationGroup) + : __pAnimationGroup(pAnimationGroup) +{ +} + +_AnimationGroupImpl::~_AnimationGroupImpl(void) +{ + result r = Dispose(); + + SysTryReturnVoidResult(NID_UI_ANIM, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +_AnimationGroupImpl::Dispose(void) +{ + result r = E_SUCCESS; + + int index = animationList.GetCount(); + + while (index > 0) + { + _AnimationGroupImpl::AnimationStore animStore; + + r = animationList.GetAt(index - 1, animStore); + + delete animStore.pAnimationBase; + animStore.pAnimationBase = null; + + index--; + } + + animationList.RemoveAll(); + + return r; +} + +AnimationBase* +_AnimationGroupImpl::CloneAnimation(AnimationTargetType animTarget, AnimationBase& animation, result& r) +{ + AnimationType animationType = animation.GetType(); + + switch (animTarget) + { + case ANIMATION_TARGET_SIZE: + { + switch (animationType) + { + case ANIMATION_TYPE_DIMENSION_ANIMATION: + { + DimensionAnimation* pDimValue = dynamic_cast< DimensionAnimation* >(&animation); + SysTryReturn(NID_UI_ANIM, (pDimValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not DimensionAnimation."); + + DimensionAnimation* pAnimValue = new (std::nothrow) DimensionAnimation(*pDimValue); + SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pAnimValue; + } + break; + + case ANIMATION_TYPE_RECTANGLE_ANIMATION: + { + RectangleAnimation* pRectValue = dynamic_cast< RectangleAnimation* >(&animation); + SysTryReturn(NID_UI_ANIM, (pRectValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RectangleAnimation."); + + RectangleAnimation* pAnimValue = new (std::nothrow) RectangleAnimation(*pRectValue); + SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pAnimValue; + } + break; + + default: + r = E_INVALID_ARG; + return null; + } + } + break; + + + case ANIMATION_TARGET_POSITION: + { + switch (animationType) + { + case ANIMATION_TYPE_POINT_ANIMATION: + { + PointAnimation* pPtValue = dynamic_cast< PointAnimation* >(&animation); + SysTryReturn(NID_UI_ANIM, (pPtValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not PointAnimation."); + + PointAnimation* pAnimValue = new (std::nothrow) PointAnimation(*pPtValue); + SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pAnimValue; + } + break; + + case ANIMATION_TYPE_RECTANGLE_ANIMATION: + { + RectangleAnimation* pRectValue = dynamic_cast< RectangleAnimation* >(&animation); + SysTryReturn(NID_UI_ANIM, (pRectValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RectangleAnimation."); + + RectangleAnimation* pAnimValue = new (std::nothrow) RectangleAnimation(*pRectValue); + SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pAnimValue; + } + break; + + default: + r = E_INVALID_ARG; + return null; + } + } + break; + + case ANIMATION_TARGET_ALPHA: + { + switch (animationType) + { + case ANIMATION_TYPE_FLOAT_ANIMATION: + { + FloatAnimation* pFloatValue = dynamic_cast< FloatAnimation* >(&animation); + SysTryReturn(NID_UI_ANIM, (pFloatValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not FloatAnimation."); + + FloatAnimation* pAnimValue = new (std::nothrow) FloatAnimation(*pFloatValue); + SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pAnimValue; + } + break; + + case ANIMATION_TYPE_INTEGER_ANIMATION: + { + IntegerAnimation* pIntValue = dynamic_cast< IntegerAnimation* >(&animation); + SysTryReturn(NID_UI_ANIM, (pIntValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not IntegerAnimation."); + + IntegerAnimation* pAnimValue = new (std::nothrow) IntegerAnimation(*pIntValue); + SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pAnimValue; + } + break; + + default: + r = E_INVALID_ARG; + return null; + } + } + break; + + case ANIMATION_TARGET_ROTATION: + { + if (animationType == ANIMATION_TYPE_ROTATE_ANIMATION) + { + RotateAnimation* pRotateValue = dynamic_cast< RotateAnimation* >(&animation); + SysTryReturn(NID_UI_ANIM, (pRotateValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RotateAnimation."); + + RotateAnimation* pAnimValue = new (std::nothrow) RotateAnimation(*pRotateValue); + SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pAnimValue; + } + else + { + r = E_INVALID_ARG; + return null; + } + } + break; + + default: + r = E_INVALID_ARG; + return null; + } +} + +result +_AnimationGroupImpl::Construct() +{ + return animationList.Construct(); +} + +bool +_AnimationGroupImpl::AnimationStore::operator ==(const AnimationStore& animStore) const +{ + if (animTarget != animStore.animTarget) + { + return false; + } + + if ((!pAnimationBase) && (!animStore.pAnimationBase)) + { + return true; + } + else if (((pAnimationBase == null) && (animStore.pAnimationBase != null)) || + ((pAnimationBase != null) && (animStore.pAnimationBase == null))) + { + return false; + } + + if (pAnimationBase->GetType() != animStore.pAnimationBase->GetType()) + { + return false; + } + + switch (pAnimationBase->GetType()) + { + case ANIMATION_TYPE_FLOAT_ANIMATION: + { + FloatAnimation* pFlAnim1 = dynamic_cast< FloatAnimation* >(pAnimationBase); + SysTryReturn(NID_UI_ANIM, (pFlAnim1), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not FloatAnimation."); + + FloatAnimation* pFlAnim2 = dynamic_cast< FloatAnimation* >(animStore.pAnimationBase); + SysTryReturn(NID_UI_ANIM, (pFlAnim2), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not FloatAnimation."); + + if ((*pFlAnim1) != (*pFlAnim2)) + { + return false; + } + break; + } + + case ANIMATION_TYPE_INTEGER_ANIMATION: + { + IntegerAnimation* pIntAnim1 = dynamic_cast< IntegerAnimation* >(pAnimationBase); + SysTryReturn(NID_UI_ANIM, (pIntAnim1), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not IntegerAnimation."); + + IntegerAnimation* pIntAnim2 = dynamic_cast< IntegerAnimation* >(animStore.pAnimationBase); + SysTryReturn(NID_UI_ANIM, (pIntAnim2), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not IntegerAnimation."); + + if ((*pIntAnim1) != (*pIntAnim2)) + { + return false; + } + break; + } + + case ANIMATION_TYPE_DIMENSION_ANIMATION: + { + DimensionAnimation* pDimAnim1 = dynamic_cast< DimensionAnimation* >(pAnimationBase); + SysTryReturn(NID_UI_ANIM, (pDimAnim1), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not DimensionAnimation."); + + DimensionAnimation* pDimAnim2 = dynamic_cast< DimensionAnimation* >(animStore.pAnimationBase); + SysTryReturn(NID_UI_ANIM, (pDimAnim2), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not DimensionAnimation."); + + if ((*pDimAnim1) != (*pDimAnim2)) + { + return false; + } + break; + } + + case ANIMATION_TYPE_RECTANGLE_ANIMATION: + { + RectangleAnimation* pRectAnim1 = dynamic_cast< RectangleAnimation* >(pAnimationBase); + SysTryReturn(NID_UI_ANIM, (pRectAnim1), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RectangleAnimation."); + + RectangleAnimation* pRectAnim2 = dynamic_cast< RectangleAnimation* >(animStore.pAnimationBase); + SysTryReturn(NID_UI_ANIM, (pRectAnim2), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RectangleAnimation."); + + if ((*pRectAnim1) != (*pRectAnim2)) + { + return false; + } + break; + } + + case ANIMATION_TYPE_POINT_ANIMATION: + { + PointAnimation* pPtAnim1 = dynamic_cast< PointAnimation* >(pAnimationBase); + SysTryReturn(NID_UI_ANIM, (pPtAnim1), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not PointAnimation."); + + PointAnimation* pPtAnim2 = dynamic_cast< PointAnimation* >(animStore.pAnimationBase); + SysTryReturn(NID_UI_ANIM, (pPtAnim2), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not PointAnimation."); + + if ((*pPtAnim1) != (*pPtAnim2)) + { + return false; + } + break; + } + + case ANIMATION_TYPE_ROTATE_ANIMATION: + { + RotateAnimation* pRotAnim1 = dynamic_cast< RotateAnimation* >(pAnimationBase); + SysTryReturn(NID_UI_ANIM, (pRotAnim1), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RotateAnimation."); + + RotateAnimation* pRotAnim2 = dynamic_cast< RotateAnimation* >(animStore.pAnimationBase); + SysTryReturn(NID_UI_ANIM, (pRotAnim2), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RotateAnimation."); + + if ((*pRotAnim1) != (*pRotAnim2)) + { + return false; + } + break; + } + + default: + return false; + } + + return true; +} + +bool +_AnimationGroupImpl::AnimationStore::operator !=(const AnimationStore& animStore) const +{ + return !(*this == animStore); +} + +}}} //Tizen::Ui::Animations diff --git a/src/ui/animations/FUiAnim_AnimationGroupImpl.h b/src/ui/animations/FUiAnim_AnimationGroupImpl.h new file mode 100644 index 0000000..09da083 --- /dev/null +++ b/src/ui/animations/FUiAnim_AnimationGroupImpl.h @@ -0,0 +1,153 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_AnimationGroupImpl.h + * @brief This is the header file for the _AnimationGroupImpl class. + * + * This header file contains the declarations of the _AnimationGroupImpl class. @n + */ + +#ifndef _FUI_ANIM_INTERNAL_ANIMATION_GROUP_IMPL_H_ +#define _FUI_ANIM_INTERNAL_ANIMATION_GROUP_IMPL_H_ + +#include +#include + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class _AnimationGroupImpl + * @brief This is the header file for the _AnimationGroupImpl class. + * @since 2.0 + * + * This header file contains the declarations of the _AnimationGroupImpl class. @n + * + */ +class _AnimationGroupImpl + : public Tizen::Base::Object +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + ~_AnimationGroupImpl(void); + + /** + * This is the constructor for this class. + * + * @since 2.0 + */ + _AnimationGroupImpl(AnimationGroup* pAnimationGroup); + + /** + * Initializes this instance of _AnimationGroupImpl with the specified parameters. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM Failed to construct. + */ + result Construct(void); + + /** + * Frees the resources allocated by this _AnimationGroupImpl instance. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM Failed to free the resource possessed by this instance. + */ + result Dispose(void); + + /** + * Returns a copy of %AnimationBase object. + * + * @return An error code + * @param[in] animTarget Property to be animated. + * @param[in] animationBase An object of type %AnimationBase whose copy is to be created + * @param[out] res Error code + * @exception null If the passed argument is invalid. + */ + AnimationBase* CloneAnimation(AnimationTargetType animTarget, AnimationBase& animationBase, result& res); + + + /** + * Structure Used For Storing Animations + */ + struct AnimationStore + { + AnimationTargetType animTarget; + AnimationBase* pAnimationBase; + AnimationStore(void) + { + animTarget = ANIMATION_TARGET_NONE; + pAnimationBase = null; + } + ~AnimationStore(void) + { + + } + bool operator ==(const AnimationStore& animStore) const; + bool operator !=(const AnimationStore& animStore) const; + }; + + /** + * The List maintaining the animations + */ + Tizen::Base::Collection::ArrayListT< AnimationStore > animationList; + +private: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the assignment operator for this class. + // + // @since 2.0 + // + _AnimationGroupImpl& operator =(const _AnimationGroupImpl&); + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // This is the copy constructor for this class. + // + // @since 2.0 + // + _AnimationGroupImpl(const _AnimationGroupImpl& animationBaseImpl); + + // + // This variable is for internal use only. Using this variable can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // @since 2.0 + // + Tizen::Ui::Animations::AnimationGroup* __pAnimationGroup; + +}; // _AnimationGroupImpl + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_ANIMATION_GROUP_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_AnimationImpl.cpp b/src/ui/animations/FUiAnim_AnimationImpl.cpp new file mode 100644 index 0000000..711e5da --- /dev/null +++ b/src/ui/animations/FUiAnim_AnimationImpl.cpp @@ -0,0 +1,51 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_AnimationImpl.cpp + * @brief This file contains implementation of _AnimationImpl class + * + * This file contains implementation _AnimationImpl class. + */ + + +#include +#include "FUiAnim_AnimationImpl.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + + + +_AnimationImpl::_AnimationImpl(void) +{ + +} +_AnimationImpl::~_AnimationImpl(void) +{ + +} + +_Animation& +_AnimationImpl::GetCore(void) +{ + return __core; +} + + +}}} diff --git a/src/ui/animations/FUiAnim_AnimationManager.cpp b/src/ui/animations/FUiAnim_AnimationManager.cpp new file mode 100644 index 0000000..7d86f03 --- /dev/null +++ b/src/ui/animations/FUiAnim_AnimationManager.cpp @@ -0,0 +1,628 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_AnimationManager.cpp + * @brief This file contains implementation of _AnimationManager class + * + * This file contains implementation _AnimationManager class. + */ + +#include + +#include + +#include +#include +#include +#include + +#include "FUi_EcoreEvas.h" +#include "FUi_EcoreEvasMgr.h" + +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_VisualElementAnimationImpl.h" +#include "FUiAnim_TransactionNode.h" +#include "FUiAnim_VisualElementAnimationVariantInterpolator.h" + +#include "FUiAnim_AnimationManager.h" +#include "FUiAnim_DisplayManager.h" + +#include "FUiAnim_Debug.h" + +#if 0 +class ElapsedTime +{ +public: + ElapsedTime(const char* tag = null) + { + struct timeval tv; + + tagName = tag; + + gettimeofday(&tv, null); + start_time = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; + } + + ~ElapsedTime(void) + { + long long end_time; + struct timeval tv; + gettimeofday(&tv, null); + end_time = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; + +// Tizen::Ui::Animations::_AnimationManager* pAnimationManager = Tizen::Ui::Animations::_AnimationManager::GetInstance(); +// Tizen::Ui::Animations::_RootVisualElement* pRoot = (Tizen::Ui::Animations::_RootVisualElement*)pAnimationManager->GetRoot()->GetPresentation(); + } + + +public: + long long start_time; + const char* tagName; +}; +#endif + + +static const double fpsLimitInterval = 1.0 / 55.0; +Ecore_Animator* pAnimator = null; + + +Eina_Bool +__AnimatorCallback(void* pData) +{ +#ifndef VE_VSYNC_UPDATE + pAnimationManager->ProcessAnimationTick(); +// pManager->PreRender(); +#endif + + return EINA_TRUE; +} + +namespace Tizen { namespace Ui { namespace Animations +{ + +#ifdef VE_DEBUG_MODULE +Eina_Bool +__SigProcUser(void* pData, int type, void* pEvent) +{ + _VeDebug::DumpVeTree(0, 0); + _VeDebug::DumpEvasTree(0, 0); + _VeDebug::DumpAllEvas(); + return ECORE_CALLBACK_PASS_ON; +} +#endif + + +// default transaction event listener +class _TransactionEventListener + : public IAnimationTransactionEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + _TransactionEventListener(void); + virtual ~_TransactionEventListener(void); + + void SetTransactionEventListener(const IAnimationTransactionEventListener* pListener); + + virtual void OnAnimationTransactionStarted(int transactionId); + virtual void OnAnimationTransactionStopped(int transactionId); + virtual void OnAnimationTransactionFinished(int transactionId); + +private: + IAnimationTransactionEventListener* __pEventListener; +}; + +_TransactionEventListener::_TransactionEventListener(void) + : __pEventListener(null) +{ +} + +_TransactionEventListener::~_TransactionEventListener(void) +{ +} + +void +_TransactionEventListener::SetTransactionEventListener(const IAnimationTransactionEventListener* pListener) +{ + __pEventListener = const_cast< IAnimationTransactionEventListener* >(pListener); +} + +void +_TransactionEventListener::OnAnimationTransactionStarted(int transactionId) +{ + if (__pEventListener) + { + __pEventListener->OnAnimationTransactionStarted(transactionId); + } +} + +void +_TransactionEventListener::OnAnimationTransactionStopped(int transactionId) +{ + if (__pEventListener) + { + __pEventListener->OnAnimationTransactionStopped(transactionId); + } +} + +void +_TransactionEventListener::OnAnimationTransactionFinished(int transactionId) +{ + if (__pEventListener) + { + __pEventListener->OnAnimationTransactionFinished(transactionId); + } +} + +_AnimationManager* _AnimationManager::__pInstance = null; + +_AnimationManager::_AnimationManager(void) + : __isAnimating(false) + , __isInAnimationTick(false) + , __pRootTransaction(null) + , __pCurrentTransaction(null) + , __pCurrentTransactionExceptGroup(null) + , __pDefaultTransactionEventListener(null) + , __pDefaultTimingFunction(null) + , __pDefaultInterpolator(null) +{ +} + +_AnimationManager::~_AnimationManager(void) +{ +} + +_AnimationManager* +_AnimationManager::GetInstance(void) +{ + return __pInstance; +} + +result +_AnimationManager::CreateInstance(void) +{ + SysAssertf((__pInstance == null), "Already created."); + + __pInstance = new (std::nothrow) _AnimationManager(); + SysTryReturnResult(NID_UI_ANIM, __pInstance != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + result r = __pInstance->Construct(); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, r, "[%s] Failed to construct _AnimationManager instance.", GetErrorMessage(r)); + + delete __pInstance; + __pInstance = null; + + return null; + } + + return E_SUCCESS; +} + +void +_AnimationManager::ReleaseInstance(void) +{ + if (__pInstance != null) + { + __pInstance->Release(); + + delete __pInstance; + __pInstance = null; + } +} + +result +_AnimationManager::Release(void) +{ + if (pAnimator) + { + ecore_animator_del(pAnimator); + } + + pAnimator = null; + + delete __pRootTransaction; + __pRootTransaction = null; + + delete __pDefaultTransactionEventListener; + __pDefaultTransactionEventListener = null; + + delete __pDefaultTimingFunction; + __pDefaultTimingFunction = null; + + delete __pDefaultInterpolator; + __pDefaultInterpolator = null; + + return E_SUCCESS; +} + +result +_AnimationManager::Construct(void) +{ + result r = E_SUCCESS; + +#ifdef VE_DEBUG_MODULE + ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, __SigProcUser, null); +#endif + + __pRootTransaction = new (std::nothrow) _TransactionNode(); + SysTryReturnResult(NID_UI_ANIM, (__pRootTransaction != null), E_OUT_OF_MEMORY, "Memory allocation failed. Failed to create root transaction"); + + r = GetLastResult(); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Failed to create root transaction.", GetErrorMessage(r)); + + __pRootTransaction->Commit(); //root is always committed. + + __pCurrentTransaction = __pRootTransaction; + __pCurrentTransactionExceptGroup = __pRootTransaction; + + __pDefaultTransactionEventListener = new (std::nothrow) _TransactionEventListener(); + SysTryCatch(NID_UI_ANIM, __pDefaultTransactionEventListener != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed. Failed to create default transaction event listener."); + + __pDefaultTimingFunction = new (std::nothrow) LinearTimingFunction(); + SysTryCatch(NID_UI_ANIM, __pDefaultTimingFunction != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed. Failed to create default timing function map."); + + __pDefaultInterpolator = new (std::nothrow) _VisualElementAnimationVariantInterpolator(); + SysTryCatch(NID_UI_ANIM, __pDefaultInterpolator != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed. Failed to create default interpolator."); + + return E_SUCCESS; + +CATCH: + delete __pDefaultInterpolator; + delete __pDefaultTimingFunction; + delete __pDefaultTransactionEventListener; + delete __pRootTransaction; + + return r; +} + + +#ifdef VE_DEBUG +static long __RenderCount = 0; //Need? +#endif + +void +_AnimationManager::SetAnimatorEnabled(bool animating) +{ +#ifdef VE_VSYNC_UPDATE + + __isAnimating = animating; + + if (likely(animating)) + { + if (likely(pAnimator == null)) + { + ecore_animator_frametime_set(fpsLimitInterval); + pAnimator = (Ecore_Animator*)ecore_animator_add(__AnimatorCallback, _AnimationManager::GetInstance()); + } + } + else + { + if (pAnimator) + { + ecore_animator_del(pAnimator); + pAnimator = null; + } + } +#else + if (animating) + { + _DisplayManager::GetInstance()->AddWakeUpEvent(); + } +#endif +} + +result +_AnimationManager::AddAnimation(VisualElement& target, const Tizen::Base::String* pKeyName, VisualElementAnimation& animation) +{ + SysTryReturnResult(NID_UI_ANIM, (__pCurrentTransaction != null), E_SYSTEM, "A system error has been occurred. Current transaction is null."); + + if (pKeyName != null && pKeyName->IsEmpty() == false) + { + SysTryReturnResult(NID_UI_ANIM, (DoesAnimationExist(target, *pKeyName) == false), E_INVALID_ARG, "Invalid argument(s) is used. Animation with keyName exists. key name = %ls", pKeyName->GetPointer()); + } + + result r = E_SUCCESS; + + if (_VisualElementAnimationImpl::GetInstance(animation)->GetTimingFunction() == null) + { + animation.SetTimingFunction(__pDefaultTimingFunction); + } + + if (_VisualElementAnimationImpl::GetInstance(animation)->GetValueInterpolator() == null) + { + animation.SetValueInterpolator(__pDefaultInterpolator); + } + + // current trasaction + r = __pCurrentTransaction->AddAnimation(target, pKeyName, animation); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Failed to add animation."); + + if (__pCurrentTransaction == __pRootTransaction && __isAnimating == false) + { + SetAnimatorEnabled(true); + } + + return E_SUCCESS; +} + +result +_AnimationManager::RemoveAnimation(VisualElement& target, const Tizen::Base::String& keyName) +{ + return __pRootTransaction->RemoveChildrenAnimation(target, keyName); +} + +void +_AnimationManager::RemoveAnimationForProperty(VisualElement& target, const Tizen::Base::String& property) +{ + __pRootTransaction->RemoveChildrenAnimationByProperty(target, property); +} + +void +_AnimationManager::RemoveAllAnimations(VisualElement& target) +{ + __pRootTransaction->RemoveChildrenAllAnimations(target); +} + +VisualElementAnimation* +_AnimationManager::GetAnimationN(VisualElement& target, const Tizen::Base::String& keyName) const +{ + VisualElementAnimation* pAnimation = const_cast< VisualElementAnimation* >(__pRootTransaction->GetChildrenAnimation(target, keyName)); + + if (pAnimation != null) + { + SetLastResult(E_SUCCESS); + return pAnimation->CloneN(); + } + + SetLastResult(E_OBJ_NOT_FOUND); + return null; +} + +bool +_AnimationManager::DoesAnimationExist(VisualElement& target, const Tizen::Base::String& keyName) const +{ + return (__pRootTransaction->GetChildrenAnimation(target, keyName) != null); +} + +VisualElementAnimation* +_AnimationManager::GetAnimationForPropertyN(VisualElement& target, const Tizen::Base::String& property) const +{ + VisualElementAnimation* pAnimation = const_cast< VisualElementAnimation* >(__pRootTransaction->GetChildrenAnimationByProperty(target, property)); + + if (pAnimation != null) + { + SetLastResult(E_SUCCESS); + return pAnimation->CloneN(); + } + + SetLastResult(E_OBJ_NOT_FOUND); + return null; +} + +int +_AnimationManager::BeginTransaction(void) +{ + SysTryReturn(NID_UI_ANIM, (__pCurrentTransaction != null), -1, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Current transaction is null."); + + _TransactionNode* pNode = new (std::nothrow) _TransactionNode(*__pCurrentTransaction); + SysTryReturn(NID_UI_ANIM, (pNode != null), -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. Failed to create _TransactionNode."); + + result r = GetLastResult(); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Failed to create _TransactionNode instance.", GetErrorMessage(r)); + + r = __pCurrentTransaction->AddChild(*pNode); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Failed to add child.", GetErrorMessage(r)); + + __pCurrentTransaction = pNode; + __pCurrentTransactionExceptGroup = pNode; + + pNode->SetDefaultEventListener(__pDefaultTransactionEventListener); + + return pNode->GetId(); + +CATCH: + delete pNode; + + return -1; +} + +int +_AnimationManager::BeginGroupTransaction(VisualElement& target, const Tizen::Base::String* pKeyName, VisualElementAnimation& animation) +{ + SysTryReturn(NID_UI_ANIM, (__pCurrentTransaction != null), -1, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Current transaction is null."); + + if (pKeyName != null && pKeyName->IsEmpty() == false) + { + SysTryReturn(NID_UI_ANIM, (DoesAnimationExist(target, *pKeyName) == false), 0, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation with keyName exists."); + } + + _AnimationGroupNode* pNode = new (std::nothrow) _AnimationGroupNode(target, pKeyName, animation); + SysTryReturn(NID_UI_ANIM, (pNode != null), -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. Failed to create _AnimationNode."); + + result r = GetLastResult(); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Failed to _AnimationGroupNode instance.", GetErrorMessage(r)); + + r = __pCurrentTransaction->AddChild(*pNode); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Failed to add a child.", GetErrorMessage(r)); + + __pCurrentTransaction = pNode; + + return pNode->GetId(); + +CATCH: + + delete pNode; + + return -1; +} + +result +_AnimationManager::CommitTransaction(void) +{ + SysTryReturnResult(NID_UI_ANIM, __pCurrentTransaction != null, E_SYSTEM, "A system error has been occurred. Current transaction is null."); + SysTryReturnResult(NID_UI_ANIM, __pCurrentTransaction != __pRootTransaction, E_INVALID_OPERATION, "Transaction isn't opened."); + + _TransactionNode* pParentTransaction = __pCurrentTransaction->GetParent(); + + if (__pCurrentTransaction->IsEmpty()) + { + pParentTransaction->RemoveChild(*__pCurrentTransaction); + } + else + { + if (pParentTransaction == __pRootTransaction && __pRootTransaction->IsEmpty() == false) + { + __pCurrentTransaction->SetChildrenBaseTime(_AnimationTime::GetTime()); + + SetAnimatorEnabled(true); + } + + __pCurrentTransaction->Commit(); + } + + __pCurrentTransaction = pParentTransaction; + + if (dynamic_cast< _AnimationGroupNode* > (pParentTransaction) == null) + { + __pCurrentTransactionExceptGroup = pParentTransaction; + } + + return E_SUCCESS; +} + +result +_AnimationManager::DiscardTransaction(void) +{ + SysTryReturnResult(NID_UI_ANIM, (__pCurrentTransaction != __pRootTransaction), E_INVALID_OPERATION, "Transaction isn't opened."); + + _TransactionNode* pLastChild = __pRootTransaction->GetLastChild(); + SysTryReturnResult(NID_UI_ANIM, pLastChild != null, E_SYSTEM, "A system error has been occurred. Last child is null."); + + __pRootTransaction->RemoveChild(*pLastChild); + + __pCurrentTransaction = __pRootTransaction; + __pCurrentTransactionExceptGroup = __pRootTransaction; + + return E_SUCCESS; +} + +result +_AnimationManager::StopTransaction(int transactionId) +{ + _TransactionNode* pChild = __pRootTransaction->GetChild(transactionId); + + if (pChild != null && pChild->IsCommitted(true) == true) + { + __pRootTransaction->RemoveChild(transactionId); + + return E_SUCCESS; + } + + return E_INVALID_ARG; +} + +result +_AnimationManager::CancelTransaction(int transactionId) +{ + if (__pCurrentTransaction->GetId() == transactionId) + { + _TransactionNode* pParentTransaction = __pCurrentTransaction->GetParent(); + + __pCurrentTransaction = pParentTransaction; + + if (dynamic_cast< _AnimationGroupNode* > (pParentTransaction) == null) + { + __pCurrentTransactionExceptGroup = pParentTransaction; + } + } + + __pRootTransaction->RemoveChild(transactionId); + + return E_SUCCESS; +} + +bool +_AnimationManager::IsTransactionRunning(int transactionId) const +{ + _TransactionNode* pChild = __pRootTransaction->GetChild(transactionId); + + if (pChild != null) + { + return pChild->IsRunning(); + } + + return false; +} + +bool +_AnimationManager::IsImplicitAnimationEnabled(void) const +{ + return __pCurrentTransactionExceptGroup->IsImplicitAnimationEnabled(); +} + +_TransactionNode* +_AnimationManager::GetCurrentTransaction(bool withGroup) const +{ + if (__pCurrentTransaction == __pRootTransaction) + { + return null; + } + + if (withGroup == false) + { + return __pCurrentTransactionExceptGroup; + } + + return __pCurrentTransaction; +} + +void +_AnimationManager::SetTransactionEventListener(const IAnimationTransactionEventListener* pListener) +{ + static_cast< _TransactionEventListener* >(__pDefaultTransactionEventListener)->SetTransactionEventListener(pListener); +} + +void +_AnimationManager::ProcessAnimationTick(void) +{ + if (unlikely(__isInAnimationTick)) + { + return; + } + + __isInAnimationTick = true; + + // process transactions; + __pRootTransaction->ProcessAnimationTick(_AnimationTime::GetTime()); + + if (likely(__pRootTransaction->IsEmpty() == true)) + { + SetAnimatorEnabled(false); + } + + __isInAnimationTick = false; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_AnimationManager.h b/src/ui/animations/FUiAnim_AnimationManager.h new file mode 100644 index 0000000..ef890e7 --- /dev/null +++ b/src/ui/animations/FUiAnim_AnimationManager.h @@ -0,0 +1,113 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_AnimationManager.h + * @brief This is the header file for the _AnimationManager class. + * + * This header file contains the declarations of the _AnimationManager class. + */ + +#ifndef _FUI_ANIM_INTERNAL_ANIMATION_MANAGER_H_ +#define _FUI_ANIM_INTERNAL_ANIMATION_MANAGER_H_ + +#include +#include +#include + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class IAnimationTransactionEventListener; +class IVisualElementAnimationTimingFunction; +class IVisualElementAnimationValueInterpolator; +class VisualElementAnimation; +class VisualElementAnimationGroup; +class _RootVisualElement; +class _TransactionNode; + +class _AnimationManager +{ +public: + static _AnimationManager* GetInstance(void); + static result CreateInstance(void); + static void ReleaseInstance(void); + + //for animation + result AddAnimation(VisualElement& target, const Tizen::Base::String* pKeyName, VisualElementAnimation& animation); + result RemoveAnimation(VisualElement& target, const Tizen::Base::String& keyName); + void RemoveAnimationForProperty(VisualElement& target, const Tizen::Base::String& property); + void RemoveAllAnimations(VisualElement& target); + bool DoesAnimationExist(VisualElement& target, const Tizen::Base::String& keyName) const; + bool DoesAnimationExistForProperty(VisualElement& target, const Tizen::Base::String& keyName) const; + VisualElementAnimation* GetAnimationN(VisualElement& target, const Tizen::Base::String& keyName) const; + VisualElementAnimation* GetAnimationForPropertyN(VisualElement& target, const Tizen::Base::String& property) const; + + //for transaction + int BeginTransaction(void); + int BeginGroupTransaction(VisualElement& target, const Tizen::Base::String* pKeyName, VisualElementAnimation& animation); + result CommitTransaction(void); + result DiscardTransaction(void); + result StopTransaction(int transactionId); + result CancelTransaction(int transactionId); + bool IsTransactionRunning(int transactionId) const; + bool IsImplicitAnimationEnabled(void) const; // OnCurrentTransaction + _TransactionNode* GetCurrentTransaction(bool withGroup = true) const; + void SetTransactionEventListener(const IAnimationTransactionEventListener* pListener); + + void ProcessAnimationTick(void); + bool IsAnimating(void) const + { + return __isAnimating; + } + +private: + _AnimationManager(void); + ~_AnimationManager(void); + + _AnimationManager(const _AnimationManager&); + _AnimationManager& operator =(const _AnimationManager&); + + result Construct(void); + result Release(void); + + void SetAnimatorEnabled(bool animating); + +private: + static _AnimationManager* __pInstance; + + bool __isAnimating; + bool __isInAnimationTick; + + _TransactionNode* __pRootTransaction; + _TransactionNode* __pCurrentTransaction; + _TransactionNode* __pCurrentTransactionExceptGroup; + + IAnimationTransactionEventListener* __pDefaultTransactionEventListener; + const IVisualElementAnimationTimingFunction* __pDefaultTimingFunction; + const IVisualElementAnimationValueInterpolator* __pDefaultInterpolator; + + friend class _DisplayManager; +}; // _AnimationManager + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_ANIMATION_MANAGER_H_ + diff --git a/src/ui/animations/FUiAnim_ControlAnimatorImpl.cpp b/src/ui/animations/FUiAnim_ControlAnimatorImpl.cpp new file mode 100644 index 0000000..25b229e --- /dev/null +++ b/src/ui/animations/FUiAnim_ControlAnimatorImpl.cpp @@ -0,0 +1,3144 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_ControlAnimatorImpl.cpp + * @brief This file contains implementation of _ControlAnimatorImpl class + * + * This file contains implementation _ControlAnimatorImpl class. + */ + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FUi_ControlImplManager.h" +#include "FUi_WindowImpl.h" +#include "FUiAnim_ControlAnimatorImpl.h" +#include "FUiAnim_VisualElement.h" +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_VisualElementAnimationImpl.h" +#include "FUiAnim_VisualElementAnimationKeyFrame.h" +#include "FUiAnim_AnimationManager.h" +#include "FUiAnim_MatrixUtil.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + + +#define TRANSACTION "TRANSACTION" +#define GROUP "GROUP" +#define POSITION "POS" +#define DIMENSION "DIM" +#define ALPHA "ALP" +#define ROTATION "ROT" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +///INIT_SYSCLASSTYPE(_ControlAnimatorImpl); + +_ControlAnimatorImpl::_ControlAnimatorImpl(ControlAnimator* pControlAnimator) + : __pActiveAnimationList(null) + , __pControl(null) + , __pControlImpl(null) + , __animatorStatus(ANIMATOR_STATUS_STOPPED) + , __logicalBoundsHolder(0, 0, 0, 0) + , __showStateHolder(true) + , __targetCount(0) + , __prevAnimationBoundsHolder(0, 0, 0, 0) + , __sequentialGroupAnimation(false) + , __sequelDelay(0) + , __pControlAnimator(pControlAnimator) + , __pVisualElement(null) + , __pAnimStatusEventListener(null) + , __pAnimDetailedEventListener(null) + , __animId(0) + , __groupName(0) + , __presentationBounds(0.0f, 0.0f, 0.0f, 0.0f) +{ + for (int animTarget = 0; animTarget < ANIMATION_TARGET_MAX; animTarget++) + { + __isAnimationTargetAnimating[animTarget] = false; + } + + for (int property = 0; property < ANIMATION_TRIGGER_SHOW_STATE_CHANGE; property++) + { + __pPropertyAnimationGroupList[property] = null; + __propertyAnimationGroupType[property] = PROPERTY_ANIMATION_GROUP_TYPE_NONE; + } +} + +result +_ControlAnimatorImpl::Construct(const Control& source) +{ + result r = E_SUCCESS; + + SysAssertf((__pControl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + __pControl = const_cast< Control* >(&source); + __pActiveAnimationList = new (std::nothrow) ArrayListT< ActiveAnimation >(); + SysTryCatch(NID_UI_ANIM, __pActiveAnimationList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pActiveAnimationList->Construct(); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to construct _ControlAnimatorImpl instance."); + + __pControlImpl = _ControlImpl::GetInstance(*__pControl); + __pVisualElement = __pControlImpl->GetCore().GetVisualElement(); + + return r; + +CATCH: + Dispose(); + + return r; +} + +_ControlAnimatorImpl::~_ControlAnimatorImpl() +{ + result r = E_SUCCESS; + + r = Dispose(); + + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + for (int animTrigger = 0; animTrigger < ANIMATION_TRIGGER_SHOW_STATE_CHANGE; animTrigger++) + { + if (__pPropertyAnimationGroupList[animTrigger]) + { + __pPropertyAnimationGroupList[animTrigger]->RemoveAllAnimations(); + delete __pPropertyAnimationGroupList[animTrigger]; + __pPropertyAnimationGroupList[animTrigger] = null; + } + } + + delete __pAnimStatusEventListener; + __pAnimStatusEventListener = null; + delete __pAnimDetailedEventListener; + __pAnimDetailedEventListener = null; +} + +result +_ControlAnimatorImpl::Dispose(void) +{ + result r = E_SUCCESS; + + if (__pActiveAnimationList) + { + r = RemoveAllAnimations(); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, r, "[%s] Failed to remove all animations.", GetErrorMessage(r)); + r = E_SYSTEM; + } + __pActiveAnimationList->RemoveAll(); + + delete __pActiveAnimationList; + __pActiveAnimationList = null; + } + + return r; +} + +bool +_ControlAnimatorImpl::ActiveAnimation::operator ==(const _ControlAnimatorImpl::ActiveAnimation& rhs) const +{ + if ((animTarget == rhs.animTarget) && (pAnimationBase == rhs.pAnimationBase)) + { + return true; + } + + return false; +} + +bool +_ControlAnimatorImpl::ActiveAnimation::operator !=(const _ControlAnimatorImpl::ActiveAnimation& rhs) const +{ + if ((animTarget != rhs.animTarget) || (pAnimationBase != rhs.pAnimationBase)) + { + return true; + } + + return false; +} + +result +_ControlAnimatorImpl::SetAnimation(AnimationTargetType animTarget, AnimationBase& animationBase, ControlAnimatorTriggerType triggerType, VisualElementAnimationGroup* pAnimationGroup) +{ + result r = E_SUCCESS; + AnimationBase* pAnimationBase = const_cast< AnimationBase* >(&animationBase); + String animIdentifier; + const IVisualElementAnimationTimingFunction* pTimingFunction = null; + BezierTimingFunction* pBezierTimingFunction = null; + + SysTryReturnResult(NID_UI_ANIM, (animTarget > ANIMATION_TARGET_NONE && animTarget < ANIMATION_TARGET_MAX), E_INVALID_OPERATION, "Invalid Argument is used. animTarget is invalid."); + + switch (pAnimationBase->GetInterpolatorType()) + { + case ANIMATION_INTERPOLATOR_LINEAR: + { + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_LINEAR); + } + break; + + case ANIMATION_INTERPOLATOR_EASE_IN: + { + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_EASEIN); + } + break; + + case ANIMATION_INTERPOLATOR_EASE_OUT: + { + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_EASEOUT); + } + break; + + case ANIMATION_INTERPOLATOR_EASE_IN_OUT: + { + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_EASEINOUT); + } + break; + + case ANIMATION_INTERPOLATOR_DISCRETE: + { + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_DISCRETE); + } + break; + + case ANIMATION_INTERPOLATOR_BEZIER: + { + float cpTime1 = 0.0; + float cpValue1 = 0.0; + float cpTime2 = 0.0; + float cpValue2 = 0.0; + + r = pAnimationBase->GetBezierControlPoints(cpTime1, cpValue1, cpTime2, cpValue2); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to get bezier points."); + + pBezierTimingFunction = new (std::nothrow) BezierTimingFunction(); + SysTryReturnResult(NID_UI_ANIM, (pBezierTimingFunction), E_OUT_OF_MEMORY, "Memory allocation failed."); + + pBezierTimingFunction->SetControlPoints(cpTime1, cpValue1, cpTime2, cpValue2); + pTimingFunction = pBezierTimingFunction; + + } + break; + } + + SysTryReturnResult(NID_UI_ANIM, (pTimingFunction != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + VisualElementPropertyAnimation* pAnimation = null; + VisualElementValueAnimation* pBoundsAnimation = null; + VisualElementValueAnimation* pBaseAnimation = null; + + if (animTarget == ANIMATION_TARGET_SIZE) + { + pBoundsAnimation = new (std::nothrow) VisualElementValueAnimation(); //deletion will happen in catch/ in Destroy animation + SysTryCatch(NID_UI_ANIM, (pBoundsAnimation), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pBoundsAnimation->SetTimingFunction(pTimingFunction); + } + else + { + pAnimation = new (std::nothrow) VisualElementPropertyAnimation(); //deletion will happen in catch/ in Destroy animation + SysTryCatch(NID_UI_ANIM, (pAnimation), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pAnimation->SetTimingFunction(pTimingFunction); + } + + switch (animTarget) + { + case ANIMATION_TARGET_SIZE: + { + DimensionAnimation* pDimensionAnim = null; + RectangleAnimation* pRectangleAnim = null; + + pDimensionAnim = dynamic_cast< DimensionAnimation* >(pAnimationBase); + pRectangleAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase); + + SysTryCatch(NID_UI_ANIM, ((pDimensionAnim) || (pRectangleAnim)), , + E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid."); + + Dimension controlSize; + Dimension controlPrevSize; + float anchorX = 0.0f; + float anchorY = 0.0f; + + float startWidth = 0.0f; + float startHeight = 0.0f; + float endWidth = 0.0f; + float endHeight = 0.0f; + + controlSize = __pControl->GetSize(); + controlPrevSize.width = __prevAnimationBoundsHolder.width; + controlPrevSize.height = __prevAnimationBoundsHolder.height; + + if (pDimensionAnim) + { + pDimensionAnim->GetAnchor(anchorX, anchorY); + + Dimension startSize = pDimensionAnim->GetStartValue(); + Dimension endSize = pDimensionAnim->GetEndValue(); + + startWidth = static_cast< float >(startSize.width); + startHeight = static_cast< float >(startSize.height); + endWidth = static_cast< float >(endSize.width); + endHeight = static_cast< float >(endSize.height); + + if (__sequentialGroupAnimation) + { + controlSize = controlPrevSize; + } + +#if MULTI_RESOLUTION + Dimension StartDim = _CoordinateSystemUtils::Transform(StartSize); + Dimension EndDim = _CoordinateSystemUtils::Transform(EndSize); + Dimension ControlDim = _CoordinateSystemUtils::Transform(ControlSize); + + Dimension ControlPrevDim = _CoordinateSystemUtils::Transform(ControlPrevSize); + ControlPrevSize = ControlPrevDim; + + StartSize = StartDim; + EndSize = EndDim; + ControlSize = ControlDim; +#endif + } + else + { + pRectangleAnim->GetAnchor(anchorX, anchorY); + + Rectangle startSize = pRectangleAnim->GetStartValue(); + Rectangle endSize = pRectangleAnim->GetEndValue(); + + if (__sequentialGroupAnimation) + { + controlSize = controlPrevSize; + } + + startWidth = static_cast< float >(startSize.width); + startHeight = static_cast< float >(startSize.height); + endWidth = static_cast< float >(endSize.width); + endHeight = static_cast< float >(endSize.height); + +#if MULTI_RESOLUTION + Rectangle StartRect = _CoordinateSystemUtils::Transform(StartSize); + Rectangle EndRect = _CoordinateSystemUtils::Transform(EndSize); + Dimension ControlDim = _CoordinateSystemUtils::Transform(ControlSize); + + Dimension ControlPrevDim = _CoordinateSystemUtils::Transform(ControlPrevSize); + ControlPrevSize = ControlPrevDim; + + StartSize = StartRect; + EndSize = EndRect; + ControlSize = ControlDim; +#endif + } + + FloatRectangle presentationBounds = const_cast((__pVisualElement)->AcquirePresentationInstance())->GetBounds(); + FloatRectangle modelBounds = __pVisualElement->GetBounds(); + + __presentationBounds = presentationBounds; + + float currentAnchorX = presentationBounds.width * anchorX; + float currentAnchorY = presentationBounds.height * anchorY; + + float startAnchorX = startWidth * anchorX; + float startAnchorY = startHeight * anchorY; + + float endAnchorX = endWidth * anchorX; + float endAnchorY = endHeight * anchorY; + + float startX = presentationBounds.x + (currentAnchorX - startAnchorX); + float startY = presentationBounds.y + (currentAnchorY - startAnchorY); + + float endX = modelBounds.x + (currentAnchorX - endAnchorX); + float endY = modelBounds.y + (currentAnchorY - endAnchorY); + + pBoundsAnimation->SetStartValue(Variant(FloatRectangle(startX, startY, startWidth, startHeight))); + pBoundsAnimation->SetEndValue(Variant(FloatRectangle(endX, endY, endWidth, endHeight))); + pBoundsAnimation->SetVisualElementAnimationTickEventListener(this); + animIdentifier.Append(DIMENSION); + + __pVisualElement->ReleasePresentationInstance(); + } + break; + + case ANIMATION_TARGET_POSITION: + { + PointAnimation* pPointAnim = null; + RectangleAnimation* pRectangleAnim = null; + + pPointAnim = dynamic_cast< PointAnimation* >(pAnimationBase); + pRectangleAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase); + + SysTryCatch(NID_UI_ANIM, ((pPointAnim) || (pRectangleAnim)), , E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid."); + + Point controlPos; + float absStartX = 0.0f; + float absStartY = 0.0f; + float absEndX = 0.0f; + float absEndY = 0.0f; + + controlPos = __pControl->GetPosition(); + + Point parentPosition(0, 0); + + if (__pControlImpl->GetParent()) + { + parentPosition.x = __pControlImpl->GetParent()->GetClientBounds().x; + parentPosition.y = __pControlImpl->GetParent()->GetClientBounds().y; + } + + if (pPointAnim) + { + Point startPos = pPointAnim->GetStartValue(); + Point endPos = pPointAnim->GetEndValue(); + + absStartX = (static_cast< float >(parentPosition.x) + static_cast< float >(startPos.x)); + absStartY = (static_cast< float >(parentPosition.y) + static_cast< float >(startPos.y)); + + absEndX = (static_cast< float >(parentPosition.x) + static_cast< float >(endPos.x)); + absEndY = (static_cast< float >(parentPosition.y) + static_cast< float >(endPos.y)); + + //Todo : below API's are unavailable now +#if MULTI_RESOLUTION + Point StartPt = _CoordinateSystemUtils::Transform(StartPos); + Point EndPt = _CoordinateSystemUtils::Transform(EndPos); + Point ControlPt = _CoordinateSystemUtils::Transform(controlPos); + StartPos = StartPt; + EndPos = EndPt; + controlPos = ControlPt; +#endif + } + else + { + Rectangle startPos = pRectangleAnim->GetStartValue(); + Rectangle endPos = pRectangleAnim->GetEndValue(); + + absStartX = (static_cast< float >(parentPosition.x) + static_cast< float >(startPos.x)); + absStartY = (static_cast< float >(parentPosition.y) + static_cast< float >(startPos.y)); + + absEndX = (static_cast< float >(parentPosition.x) + static_cast< float >(endPos.x)); + absEndY = (static_cast< float >(parentPosition.y) + static_cast< float >(endPos.y)); + +#if MULTI_RESOLUTION + Rectangle StartRect = _CoordinateSystemUtils::Transform(StartPos); + Rectangle EndRect = _CoordinateSystemUtils::Transform(EndPos); + Point ControlPt = _CoordinateSystemUtils::Transform(controlPos); + StartPos = StartRect; + EndPos = EndRect; + controlPos = ControlPt; +#endif + } + + pAnimation->SetPropertyName(VeSubPropBoundsPosition); + + Variant startPosition(FloatPoint(absStartX, absStartY)); + Variant endPosition(FloatPoint(absEndX, absEndY)); + + pAnimation->SetStartValue(startPosition); + pAnimation->SetEndValue(endPosition); + animIdentifier.Append(POSITION); + } + break; + + case ANIMATION_TARGET_ALPHA: + { + IntegerAnimation* pIntegerAnim = null; + FloatAnimation* pFloatAnim = null; + + pIntegerAnim = dynamic_cast< IntegerAnimation* >(pAnimationBase); + pFloatAnim = dynamic_cast< FloatAnimation* >(pAnimationBase); + + SysTryCatch(NID_UI_ANIM, ((pIntegerAnim) || (pFloatAnim)), , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid."); + + pAnimation->SetPropertyName(VePrivPropShowOpacity); // need to change this with show state + + if (pIntegerAnim) + { + int startAlpha = 0; + int endAlpha = 1; + + startAlpha = pIntegerAnim->GetStartValue(); + endAlpha = pIntegerAnim->GetEndValue(); + + Variant startOpacityInt(static_cast< float >(startAlpha)); + Variant endOpacityInt(static_cast< float >(endAlpha)); + + pAnimation->SetStartValue(startOpacityInt); + pAnimation->SetEndValue(endOpacityInt); + } + else + { + float startAlpha = 0.0; + float endAlpha = 1.0; + + startAlpha = static_cast< float >(pFloatAnim->GetStartValue()); + endAlpha = static_cast< float >(pFloatAnim->GetEndValue()); + + Variant startOpacityFloat(startAlpha); + Variant endOpacityFloat(endAlpha); + + pAnimation->SetStartValue(startOpacityFloat); + pAnimation->SetEndValue(endOpacityFloat); + } + animIdentifier.Append(ALPHA); + } + break; + + case ANIMATION_TARGET_ROTATION: + { + RotateAnimation* pRotateAnim = null; + float anchorX = 0.0f; + float anchorY = 0.0f; + + pRotateAnim = dynamic_cast< RotateAnimation* >(pAnimationBase); + SysTryCatch(NID_UI_ANIM, (pRotateAnim), , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid."); + + pAnimation->SetPropertyName(VeSubPropTransformRotationZ); //check this :Todo + pRotateAnim->GetAnchor(anchorX, anchorY); + + _VisualElementImpl::GetInstance(*__pVisualElement)->SetAnchor(FloatPoint(anchorX, anchorY)); + + pAnimation->SetStartValue(Variant(pRotateAnim->GetStartValue())); + pAnimation->SetEndValue(Variant(pRotateAnim->GetEndValue())); + animIdentifier.Append(ROTATION); + } + break; + + default: + SysAssertf(false, "Animation type is invalid!"); + break; + } + + if (animTarget == ANIMATION_TARGET_SIZE) + { + pBaseAnimation = pBoundsAnimation; + } + else + { + pBaseAnimation = pAnimation; + } + + //Set the Animation values and start the Animation + pBaseAnimation->SetRepeatCount(pAnimationBase->GetRepeatCount()); + pBaseAnimation->SetEndValueApplied(pAnimationBase->IsHoldEndEnabled()); + pBaseAnimation->SetAutoReverseEnabled(pAnimationBase->IsAutoReverseEnabled()); + pBaseAnimation->SetScaleRatio(pAnimationBase->GetScaleRatio()); + pBaseAnimation->SetDuration(pAnimationBase->GetDuration()); + pBaseAnimation->SetOffset(pAnimationBase->GetOffset()); + pBaseAnimation->SetDelay(pAnimationBase->GetDelay()); + pBaseAnimation->SetVisualElementAnimationStatusEventListener(this); + + if (__sequentialGroupAnimation) + { + pBaseAnimation->SetDelay(pAnimationBase->GetDelay() + __sequelDelay); + } + + if (pAnimationBase->GetKeyFrameCount() > 0) + { + r = SetKeyFrameAnimation(animTarget, pAnimationBase, pTimingFunction, pBaseAnimation); + } + + animIdentifier.Append(__animId); + + if (_AnimationManager::GetInstance()->GetCurrentTransaction() != null) + { + animIdentifier.Append(TRANSACTION); + } + + __animId++; + + if (pAnimationGroup == null) + { + r = __pVisualElement->AddAnimation(animIdentifier, *pBaseAnimation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation could not be started."); + r = AddActiveAnimation(animTarget, *pAnimationBase, *pBaseAnimation, triggerType, animIdentifier, pBezierTimingFunction); //Todo : check this + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation could not be added to playlist."); + } + else + { + String* pAnimName = new (std::nothrow) String(animIdentifier.GetLength() + __groupName.GetLength()); + SysTryCatch(NID_UI_ANIM, (pAnimName != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + *pAnimName = animIdentifier; + + pAnimName->Append(__groupName); + + pBaseAnimation->SetUserData((void*) (pAnimName)); + + r = pAnimationGroup->AddAnimation(*pBaseAnimation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation could not be added to the group."); + r = AddActiveAnimation(animTarget, *pAnimationBase, *pBaseAnimation, triggerType, *pAnimName, pBezierTimingFunction); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation could not be added to playlist."); + } + + return r; + +CATCH: + //In case of error: free pAnimationBase if not added to ActiveAnimList. If added, its freed in Destroy Animation. + delete pAnimationBase; + delete pAnimation; + delete pBoundsAnimation; + delete pBezierTimingFunction; + + return r; +} + +result +_ControlAnimatorImpl::SetCustomImplicitAnimationParams(ControlAnimatorTriggerType triggerType, AnimationBase& animationBase, Rectangle& bounds, bool showState, bool lastTargetOccurence) +{ + result r = E_SUCCESS; + + AnimationBase* pAnimationBase = const_cast< AnimationBase* >(&animationBase); + + if ((__targetCount == 1) || ((__targetCount > 1) && lastTargetOccurence)) + { + pAnimationBase->SetHoldEndEnabled(true); + pAnimationBase->SetAutoReverseEnabled(false); + } + + if (triggerType == ANIMATION_TRIGGER_POSITION_CHANGE) + { + Point newPosition = Point(bounds.x, bounds.y); + Point currentPosition = __pControl->GetPosition(); + + PointAnimation* pPointAnim = null; + RectangleAnimation* pRectangleAnim = null; + + pPointAnim = dynamic_cast< PointAnimation* >(pAnimationBase); + pRectangleAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase); + SysTryReturnResult(NID_UI_ANIM, ((pPointAnim) || (pRectangleAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + if (pPointAnim) + { + if (__targetCount == 1) + { + pPointAnim->SetStartValue(currentPosition); + pPointAnim->SetEndValue(newPosition); + } + else //__targetCount > 1 + { + (lastTargetOccurence) ? (pPointAnim->SetEndValue(newPosition)) : (pPointAnim->SetStartValue(currentPosition)); + } + pAnimationBase = pPointAnim; + } + else //if (pRectangleAnim) + { + Rectangle newRectangle = Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); + Rectangle currentRectangle = Rectangle(__pControl->GetBounds()); + + if (__targetCount == 1) + { + pRectangleAnim->SetStartValue(currentRectangle); + pRectangleAnim->SetEndValue(newRectangle); + } + else //__targetCount > 1 + { + (lastTargetOccurence) ? (pRectangleAnim->SetEndValue(newRectangle)) : (pRectangleAnim->SetStartValue(currentRectangle)); + } + pAnimationBase = pRectangleAnim; + } + } + else if (triggerType == ANIMATION_TRIGGER_SIZE_CHANGE) + { + Dimension newSize = Dimension(bounds.width, bounds.height); + Dimension currentSize = __pControl->GetSize(); + + DimensionAnimation* pDimensionAnim = null; + RectangleAnimation* pRectangleAnim = null; + + pDimensionAnim = dynamic_cast< DimensionAnimation* >(pAnimationBase); + pRectangleAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase); + SysTryReturnResult(NID_UI_ANIM, ((pDimensionAnim) || (pRectangleAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + if (pDimensionAnim) + { + if (__targetCount == 1) + { + pDimensionAnim->SetStartValue(currentSize); + pDimensionAnim->SetEndValue(newSize); + } + else //__targetCount > 1 + { + (lastTargetOccurence) ? (pDimensionAnim->SetEndValue(newSize)) : (pDimensionAnim->SetStartValue(currentSize)); + } + pAnimationBase = pDimensionAnim; + } + else //if (pRectangleAnim) + { + Rectangle newRectangle = Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); + Rectangle currentRectangle = Rectangle(__pControl->GetBounds()); + + if (__targetCount == 1) + { + pRectangleAnim->SetStartValue(currentRectangle); + pRectangleAnim->SetEndValue(newRectangle); + } + else //__targetCount > 1 + { + (lastTargetOccurence) ? (pRectangleAnim->SetEndValue(newRectangle)) : (pRectangleAnim->SetStartValue(currentRectangle)); + } + pAnimationBase = pRectangleAnim; + } + } + if (triggerType == ANIMATION_TRIGGER_SHOW_STATE_CHANGE) + { + FloatAnimation* pFloatAnim = null; + IntegerAnimation* pIntegerAnim = null; + + pFloatAnim = dynamic_cast< FloatAnimation* >(pAnimationBase); + pIntegerAnim = dynamic_cast< IntegerAnimation* >(pAnimationBase); + SysTryReturnResult(NID_UI_ANIM, ((pFloatAnim) || (pIntegerAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + float newShowState = 0.0f; + float currentShowState = 0.0f; + int inewShowState = 0; + int icurrentShowState = 0; + + if (pFloatAnim) + { + newShowState = ((showState) ? (1.0f) : (0.0f)); + currentShowState = ((showState) ? (0.0f) : (1.0f)); + } + else //if (pIntegerAnim) + { + inewShowState = ((showState) ? (1) : (0)); + icurrentShowState = ((showState) ? (0) : (1)); + } + + if (pFloatAnim) + { + if (__targetCount == 1) + { + pFloatAnim->SetStartValue(currentShowState); + pFloatAnim->SetEndValue(newShowState); + } + else //__targetCount > 1 + { + (lastTargetOccurence) ? (pFloatAnim->SetEndValue(newShowState)) : (pFloatAnim->SetStartValue(currentShowState)); + } + pAnimationBase = pFloatAnim; + } + else //if (pIntegerAnim) + { + if (__targetCount == 1) + { + pIntegerAnim->SetStartValue(icurrentShowState); + pIntegerAnim->SetEndValue(inewShowState); + } + else //__targetCount > 1 + { + (lastTargetOccurence) ? (pIntegerAnim->SetEndValue(inewShowState)) : (pIntegerAnim->SetStartValue(icurrentShowState)); + } + pAnimationBase = pIntegerAnim; + } + } + return r; +} + +result +_ControlAnimatorImpl::StartCustomImplicitAnimation(ControlAnimatorTriggerType triggerType, int x, int y, int width, int height, bool showState) +{ + result r = E_SUCCESS; + SysTryReturnResult(NID_UI_ANIM, (triggerType == ANIMATION_TRIGGER_POSITION_CHANGE || + triggerType == ANIMATION_TRIGGER_SIZE_CHANGE || + triggerType == ANIMATION_TRIGGER_SHOW_STATE_CHANGE), E_INVALID_ARG, "Invalid argument(s) is used. Trigger type is invalid."); + + long delay = 0; + long totalDelay = 0; + long groupDuration = 0; + + AnimationTargetType equivalentAnimTarget = ANIMATION_TARGET_NONE; + + VisualElementAnimationGroup* pAnimationGroup = null; + + __sequelDelay = 0; + pAnimationGroup = new (std::nothrow) VisualElementAnimationGroup(); + SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + if (triggerType == ANIMATION_TRIGGER_POSITION_CHANGE) + { + equivalentAnimTarget = ANIMATION_TARGET_POSITION; + } + else if (triggerType == ANIMATION_TRIGGER_SIZE_CHANGE) + { + equivalentAnimTarget = ANIMATION_TARGET_SIZE; + } + else + { + equivalentAnimTarget = ANIMATION_TARGET_ALPHA; + } + + ParallelAnimationGroup* pParallelAnimGrp = null; + SequentialAnimationGroup* pSequentialAnimGrp = null; + String animIdentifier; + + __targetCount = 0; + animIdentifier.Append(GROUP); + animIdentifier.Append(__animId); + __animId++; + __groupName.Clear(); + __groupName = animIdentifier; + + if (__propertyAnimationGroupType[triggerType - 1] == PROPERTY_ANIMATION_GROUP_TYPE_SEQUENTIAL) + { + pSequentialAnimGrp = dynamic_cast< SequentialAnimationGroup* >(__pPropertyAnimationGroupList[triggerType - 1]); + if (pSequentialAnimGrp) + { + for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++) + { + AnimationTargetType animTgt = ANIMATION_TARGET_NONE; + + animTgt = pSequentialAnimGrp->GetAnimationTargetTypeAt(index); + if (animTgt > ANIMATION_TARGET_NONE && animTgt < ANIMATION_TARGET_MAX) + { + if (__isAnimationTargetAnimating[animTgt]) + { + SysLogException(NID_UI_ANIM, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Same AnimationTargetType is being animated."); + delete pAnimationGroup; + return E_INVALID_OPERATION; + } + } + } + + for (int index = pSequentialAnimGrp->GetAnimationCount() - 1; index >= 0; index--) + { + if (pSequentialAnimGrp->GetAnimationTargetTypeAt(index) == equivalentAnimTarget) + { + __targetCount++; + } + } + + //Overwrite last Animation in AnimationGroup and check for IsAnimatable + bool verified = false; + for (int count = pSequentialAnimGrp->GetAnimationCount() - 1; count >= 0; count--) + { + AnimationTargetType animTgt = ANIMATION_TARGET_NONE; + animTgt = pSequentialAnimGrp->GetAnimationTargetTypeAt(count); + if (animTgt == equivalentAnimTarget) + { + bool animatable = false; + AnimationBase* pAnimBase = null; + pAnimBase = pSequentialAnimGrp->GetAnimationAtN(count); + + if (pAnimBase) + { + Rectangle rect(x, y, width, height); + + r = SetCustomImplicitAnimationParams(triggerType, *pAnimBase, rect, showState, true); + + //Comment: Only the last associated TGT_TYPE is checked for IsAnimatable as the rest is checked in ControlAnimator::SetAnimation(). + animatable = IsAnimatable(animTgt, rect, pAnimBase); + delete pAnimBase; + verified = true; + } + + if ((!animatable) || (r != E_SUCCESS)) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set custom implicit animation."); + delete pAnimationGroup; + return E_INVALID_ARG; + } + + if (verified) + { + break; + } + } + } + + int firstOccurence = -1; + int lastOccurence = -1; + + for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++) + { + if (pSequentialAnimGrp->GetAnimationTargetTypeAt(index) == equivalentAnimTarget) + { + firstOccurence = index; + break; + } + } + + for (int index = pSequentialAnimGrp->GetAnimationCount() - 1; index >= 0; index--) + { + if (pSequentialAnimGrp->GetAnimationTargetTypeAt(index) == equivalentAnimTarget) + { + lastOccurence = index; + break; + } + } + + if (!(firstOccurence >= 0 && lastOccurence >= 0)) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start custom implicit animation."); + delete pAnimationGroup; + return E_SYSTEM; + } + + __prevAnimationBoundsHolder = __pControl->GetBounds(); + for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++) + { + AnimationTargetType animTarget = ANIMATION_TARGET_MAX; + AnimationBase* pAnimationBase = null; + pAnimationBase = pSequentialAnimGrp->GetAnimationAtN(index); + animTarget = pSequentialAnimGrp->GetAnimationTargetTypeAt(index); + if (pAnimationBase) + { + if (animTarget == equivalentAnimTarget) + { + Rectangle rect(x, y, width, height); + + if (firstOccurence == lastOccurence) // (or) __targetCount==1 + { + r = SetCustomImplicitAnimationParams(triggerType, *pAnimationBase, rect, showState, true); + } + else + { + if (index == firstOccurence) + { + r = SetCustomImplicitAnimationParams(triggerType, *pAnimationBase, rect, showState, false); + } + else if (index == lastOccurence) + { + r = SetCustomImplicitAnimationParams(triggerType, *pAnimationBase, rect, showState, true); + } + } + if (r != E_SUCCESS) + { + delete pAnimationBase; + delete pAnimationGroup; + + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set parameters for custom implicit animation."); + return E_SYSTEM; + } + } + if (!IsAnimationSupported()) + { + if (animTarget == equivalentAnimTarget) + { + if (index == lastOccurence) + { + Rectangle rect(x, y, width, height); + + r = SetCustomImplicitAnimationParams(triggerType, *pAnimationBase, rect, showState, true); + + if (r != E_SUCCESS) + { + delete pAnimationBase; + delete pAnimationGroup; + + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set parameters for custom implicit animation."); + + return E_SYSTEM; + } + + r = SetControlProperty(animTarget, *pAnimationBase); + + delete pAnimationBase; + delete pAnimationGroup; + + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set control property."); + return E_SYSTEM; + } + else + { + return E_SUCCESS; + } + } + } + } + else + { + __sequentialGroupAnimation = true; + r = SetAnimation(animTarget, *pAnimationBase, triggerType, pAnimationGroup); //check this group animation + __sequentialGroupAnimation = false; + + delay = pAnimationBase->GetDelay() + totalDelay; + totalDelay = delay + (pAnimationBase->GetDuration() * pAnimationBase->GetRepeatCount()); + totalDelay = totalDelay - (pAnimationBase->GetOffset()); + __sequelDelay = totalDelay; + groupDuration = groupDuration + __sequelDelay * pAnimationBase->GetScaleRatio(); + + if (r != E_SUCCESS) + { + delete pAnimationBase; + delete pAnimationGroup; + + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set parameters for custom implicit animation."); + + return r; + } + + if (animTarget == ANIMATION_TARGET_SIZE) + { + if (SetPrevAnimationBoundsProperty(animTarget, *pAnimationBase) != E_SUCCESS) + { + delete pAnimationBase; + delete pAnimationGroup; + + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to store previous animation bounds."); + + return E_SYSTEM; + } + } + } + } + } + } + } + else if (__propertyAnimationGroupType[triggerType - 1] == PROPERTY_ANIMATION_GROUP_TYPE_PARALLEL) + { + pParallelAnimGrp = dynamic_cast< ParallelAnimationGroup* >(__pPropertyAnimationGroupList[triggerType - 1]); + if (pParallelAnimGrp) + { + for (int target = (static_cast< int >(ANIMATION_TARGET_NONE) + 1); target < (static_cast< int >(ANIMATION_TARGET_MAX)); target++) + { + + AnimationTargetType animTgt = static_cast< AnimationTargetType >(target); + + if (pParallelAnimGrp->IsAnimationAdded(animTgt) && __isAnimationTargetAnimating[animTgt]) + { + SysLogException(NID_UI_ANIM, E_INVALID_OPERATION, " [E_INVALID_OPERATION] Same AnimationTargetType is being animated."); + delete pAnimationGroup; + + return E_INVALID_OPERATION; + } + } + + __targetCount = 1; + for (int target = (static_cast< int >(ANIMATION_TARGET_NONE) + 1); target < (static_cast< int >(ANIMATION_TARGET_MAX)); target++) + { + AnimationTargetType animTgt = static_cast< AnimationTargetType >(target); + AnimationBase* pAnimBase = null; + pAnimBase = pParallelAnimGrp->GetAnimationN(animTgt); + if (pAnimBase != null) + { + bool animatable = false; + if (animTgt == equivalentAnimTarget) + { + Rectangle rect(x, y, width, height); + + r = SetCustomImplicitAnimationParams(triggerType, *pAnimBase, rect, showState); + //Comment: Only associated TGT_TYPE is checked for IsAnimatable as the rest is checked in ControlAnimator::SetAnimation(). + animatable = IsAnimatable(animTgt, rect, pAnimBase); + } + + delete pAnimBase; + + if (((animTgt == equivalentAnimTarget) && (!animatable)) || (r != E_SUCCESS)) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set custom implicit animation."); + delete pAnimationGroup; + + return E_INVALID_ARG; + } + } + } + + AnimationTargetType animTargetArray[ANIMATION_TARGET_MAX] = + { + ANIMATION_TARGET_ROTATION, + ANIMATION_TARGET_SIZE, + ANIMATION_TARGET_POSITION, + ANIMATION_TARGET_ALPHA + }; + + for (int target = (static_cast< int >(ANIMATION_TARGET_NONE) + 1); target < (static_cast< int >(ANIMATION_TARGET_MAX)); target++) + { + AnimationTargetType _animTarget = animTargetArray[target]; + AnimationBase* pAnimationBase = null; + pAnimationBase = pParallelAnimGrp->GetAnimationN(_animTarget); + if (pAnimationBase) + { + long duration = pAnimationBase->GetDuration(); + + duration = (duration * (pAnimationBase->GetRepeatCount()) * (pAnimationBase->GetScaleRatio())) + (pAnimationBase->GetDelay()) - (pAnimationBase->GetOffset()* pAnimationBase->GetScaleRatio()); + + if (duration > groupDuration) + { + groupDuration = duration; + } + + Rectangle rect(x, y, width, height); +#if 0 + if (_animTarget == equivalentAnimTarget) + { + r = SetCustomImplicitAnimationParams(triggerType, *pAnimationBase, rect, showState); + if (r != E_SUCCESS) + { + delete pAnimationBase; + delete pAnimationGroup; + + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set parameters for custom implicit animation."); + return E_SYSTEM; + } + } +#endif + if (IsAnimationSupported() == false) + { + if (_animTarget == equivalentAnimTarget) + { + r = SetCustomImplicitAnimationParams(triggerType, *pAnimationBase, rect, showState, true); + if (r != E_SUCCESS) + { + delete pAnimationBase; + delete pAnimationGroup; + + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set parameters for custom implicit animation."); + return E_SYSTEM; + } + + r = SetControlProperty(_animTarget, *pAnimationBase); + + delete pAnimationBase; + delete pAnimationGroup; + + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set control property."); + return E_SYSTEM; + } + else + { + return E_SUCCESS; + } + } + } + else + { + //Create and set the animation to the layer + //Comment: Deep copy need not be done here as AnimationGroup did. + r = SetAnimation(_animTarget, *pAnimationBase, triggerType, pAnimationGroup); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start the animation."); + delete pAnimationGroup; + + return E_SYSTEM; + } + } + } + } + } + } + + if (equivalentAnimTarget != ANIMATION_TARGET_ALPHA) + { + bool disable = false; + bool propagation = false; + + result r = DisableImplicitAnimation(disable); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation."); + + r = DisableVisualElementPropagation(propagation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation."); + + r = __pControl->SetBounds(x, y, width, height); + + if (propagation) + { + DisableVisualElementPropagation(propagation); + } + if (disable) + { + DisableImplicitAnimation(disable); + } + + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds."); + } + else + { + bool disable = false; + bool propagation = false; + + result r = DisableImplicitAnimation(disable); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation."); + + r = DisableVisualElementPropagation(propagation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation."); + + r = __pControl->SetShowState(showState); + + if (propagation) + { + DisableVisualElementPropagation(propagation); + } + if (disable) + { + DisableImplicitAnimation(disable); + } + + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set show state."); + } + + // for layout + __pControlImpl->SetBoundsAndUpdateLayout(__pControlImpl->GetBounds()); + + pAnimationGroup->SetDuration(groupDuration); + __pVisualElement->AddAnimation(animIdentifier, *pAnimationGroup); + +CATCH: + delete pAnimationGroup; + pAnimationGroup = null; + + return r; + +} + +result +_ControlAnimatorImpl::AddActiveAnimation(AnimationTargetType animTarget, AnimationBase& animBase, VisualElementAnimation& animNative, + ControlAnimatorTriggerType triggerType, + const String& animName, BezierTimingFunction* pBezierTiming) +{ + SysTryReturnResult(NID_UI_ANIM, (animTarget > ANIMATION_TARGET_NONE && animTarget < ANIMATION_TARGET_MAX), E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid."); + + result r = E_SUCCESS; + ActiveAnimation activeAnim; + + activeAnim.animType = triggerType; + activeAnim.animTarget = animTarget; + activeAnim.pAnimationBase = (&animBase); + activeAnim.pAnimation = (&animNative); + activeAnim.animName = animName; + activeAnim.pBezierTimingFunction = pBezierTiming; + + r = __pActiveAnimationList->Add(activeAnim); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to add animations to active play list."); + + return r; +} + +String +_ControlAnimatorImpl::GetActiveAnimationAt(int index) const +{ + SysTryReturn(NID_UI_ANIM, (index > 0 && __pActiveAnimationList->GetCount() > 0 && index < __pActiveAnimationList->GetCount()), + null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index (%d) is out of range.", index); + + ActiveAnimation activeAnim; + + if (__pActiveAnimationList->GetAt(index, activeAnim) == E_SUCCESS) + { + return activeAnim.animName; + } + else + { + return null; + } +} + +String +_ControlAnimatorImpl::GetActiveAnimationAt(int index, ControlAnimatorTriggerType animTrigger) const +{ + if (!((__pActiveAnimationList->GetCount() > 0) && (index < __pActiveAnimationList->GetCount()) && (index >= 0))) + { + SysLog(NID_UI_ANIM, "[E_SYSTEM] A system error has been occurred. index (%d) is invalid.", index); + int empty = 0; + return String(empty); + } + + ActiveAnimation activeAnim; + + if (__pActiveAnimationList->GetAt(index, activeAnim) == E_SUCCESS) + { + if (animTrigger == activeAnim.animType) + { + return activeAnim.animName; + } + + return null; + } + else + { + SysLog(NID_UI_ANIM, "[E_SYSTEM] A system error has been occurred. Failed to get from list for index = %d", index); + return null; + } +} + +int +_ControlAnimatorImpl::GetActiveAnimationListCount(void) const +{ + return __pActiveAnimationList->GetCount(); +} + +int +_ControlAnimatorImpl::GetActiveAnimationListCount(AnimationTargetType animTarget) const +{ + result r = E_SUCCESS; + int count = 0; + + for (int count = __pActiveAnimationList->GetCount() - 1; count >= 0; count--) + { + ActiveAnimation activeAnim; + r = __pActiveAnimationList->GetAt(count, activeAnim); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), -1, r, "[%s] Failed to retrieve active animation from list.", GetErrorMessage(r)); + if (activeAnim.animTarget == animTarget) + { + count++; + } + } + + return count; +} + +result +_ControlAnimatorImpl::RemoveAnimationAt(int index) +{ + SysTryReturnResult(NID_UI_ANIM, + (index >= 0 && index < __pActiveAnimationList->GetCount()), E_OUT_OF_RANGE, "Index (%d) is out of range.", index); + + result r = E_SUCCESS; + ActiveAnimation activeAnim; + + r = __pActiveAnimationList->GetAt(index, activeAnim); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Failed to retrieve active animation from list."); + + r = __pActiveAnimationList->Remove(activeAnim); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to remove animation from play list."); + + delete activeAnim.pAnimationBase; + activeAnim.pAnimationBase = null; + delete activeAnim.pAnimation; + activeAnim.pAnimation = null; + delete activeAnim.pBezierTimingFunction; + activeAnim.pBezierTimingFunction = null; + + return r; +} + +result +_ControlAnimatorImpl::RemoveAllAnimations(void) +{ + result r = E_SUCCESS; + + for (int count = __pActiveAnimationList->GetCount() - 1; count >= 0; count--) + { + r = RemoveAnimationAt(count); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_OBJ_NOT_FOUND, "Failed to remove animation. index = %d", count); + } + + return r; +} + +result +_ControlAnimatorImpl::DestroyAnimation(int preActiveAnimationCount) +{ + result r = E_SUCCESS; + + for (int count = GetActiveAnimationListCount() - 1; count >= preActiveAnimationCount; count--) + { + String animName; + + animName = GetActiveAnimationAt(count); + r = __pVisualElement->RemoveAnimation(animName); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Failed to remove animation. keyName = %ls", animName.GetPointer()); + + if (RemoveAnimationAt(count) != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to remove animation. index = %d", count); + return E_SYSTEM; + } + } + + return r; +} + +result +_ControlAnimatorImpl::DestroyAnimation(AnimationBase& animBase, AnimationTargetType animTarget) +{ + result r = E_SUCCESS; + + int index = -1; + ActiveAnimation activeAnim; + + activeAnim.animTarget = animTarget; + activeAnim.pAnimationBase = (dynamic_cast< AnimationBase* >(&animBase)); + r = __pActiveAnimationList->IndexOf(activeAnim, index); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Failed to retrieve active animation from list."); + + r = RemoveAnimationAt(index); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Failed to remove animation from play list."); + + return r; +} + +result +_ControlAnimatorImpl::SetControlProperty(AnimationTargetType animTarget, AnimationBase& animationBase) +{ + result r = E_SUCCESS; + + if (animationBase.IsHoldEndEnabled() == true) + { + switch (animTarget) + { + case ANIMATION_TARGET_SIZE: + { + DimensionAnimation* pDimAnim = null; + RectangleAnimation* pRectAnim = null; + + pDimAnim = dynamic_cast< DimensionAnimation* >(const_cast< AnimationBase* >(&animationBase)); + pRectAnim = dynamic_cast< RectangleAnimation* >(const_cast< AnimationBase* >(&animationBase)); + SysTryReturnResult(NID_UI_ANIM, ((pDimAnim) || (pRectAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + if (pDimAnim) + { + Dimension dimVal(0, 0); + + (animationBase.IsAutoReverseEnabled()) ? (dimVal = pDimAnim->GetStartValue()) : (dimVal = pDimAnim->GetEndValue()); + r = (__pControl)->SetSize(dimVal.width, dimVal.height); + } + else //if (pRectAnim) + { + Rectangle rectVal(0, 0, 0, 0); + + (animationBase.IsAutoReverseEnabled()) ? (rectVal = pRectAnim->GetStartValue()) : (rectVal = pRectAnim->GetEndValue()); + r = (__pControl)->SetSize(rectVal.width, rectVal.height); + } + } + break; + + case ANIMATION_TARGET_POSITION: + { + PointAnimation* pPointAnim = null; + RectangleAnimation* pRectAnim = null; + + pPointAnim = dynamic_cast< PointAnimation* >(const_cast< AnimationBase* >(&animationBase)); + pRectAnim = dynamic_cast< RectangleAnimation* >(const_cast< AnimationBase* >(&animationBase)); + SysTryReturnResult(NID_UI_ANIM, ((pPointAnim) || (pRectAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + if (pPointAnim) + { + Point val(0, 0); + + (animationBase.IsAutoReverseEnabled()) ? (val = pPointAnim->GetStartValue()) : (val = pPointAnim->GetEndValue()); + r = (__pControl)->SetPosition(val.x, val.y); + } + else //if (pRectAnim) + { + Rectangle rectVal(0, 0, 0, 0); + + (animationBase.IsAutoReverseEnabled()) ? (rectVal = pRectAnim->GetStartValue()) : (rectVal = pRectAnim->GetEndValue()); + r = (__pControl)->SetPosition(rectVal.x, rectVal.y); + } + } + break; + + case ANIMATION_TARGET_ALPHA: + { + FloatAnimation* pFloatAnim = null; + IntegerAnimation* pIntegerAnim = null; + + pFloatAnim = dynamic_cast< FloatAnimation* >(const_cast< AnimationBase* >(&animationBase)); + pIntegerAnim = dynamic_cast< IntegerAnimation* >(const_cast< AnimationBase* >(&animationBase)); + SysTryReturnResult(NID_UI_ANIM, ((pFloatAnim) || (pIntegerAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + if (pFloatAnim) + { + float floatVal = 0.0f; + + (animationBase.IsAutoReverseEnabled()) ? (floatVal = pFloatAnim->GetStartValue()) : (floatVal = pFloatAnim->GetEndValue()); + + if (!(Float::Compare(floatVal, 1.0))) + { + r = __pControl->SetShowState(true); + } + else + { + r = __pControl->SetShowState(false); + } + + } + else //if (pIntegerAnim) + { + int intVal = 0; + + (animationBase.IsAutoReverseEnabled()) ? (intVal = pIntegerAnim->GetStartValue()) : (intVal = pIntegerAnim->GetEndValue()); + + if (intVal == 1) + { + r = __pControl->SetShowState(true); + } + else + { + r = __pControl->SetShowState(false); + } + } + } + break; + + case ANIMATION_TARGET_ROTATION: + { + //Comment: The Control's property will be the same even after the rotate animation is completed. + //So, no need to update the window property. + } + break; + + default: + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. animTarget is invalid."); + return E_SYSTEM; + } + break; + } + } + + if (IsAnimationSupported() == false) + { + _WindowImpl* pWindow = null; + pWindow = _ControlImplManager::GetInstance()->GetCurrentFrame(); + SysTryReturnResult(NID_UI_ANIM, (pWindow), E_SYSTEM, "A system error has been occurred. Failed to get current frame."); + + pWindow->GetPublic().Draw(); + __isAnimationTargetAnimating[animTarget] = false; + } + + return r; +} + +result +_ControlAnimatorImpl::SetControlShowState(AnimationTargetType animTarget, AnimationBase& animationBase) +{ + SysTryReturnResult(NID_UI_ANIM, (animTarget == ANIMATION_TARGET_ALPHA), E_SYSTEM, "animTarget is invalid."); + + if (animationBase.IsHoldEndEnabled() == true) + { + IntegerAnimation* pIntAnim = dynamic_cast< IntegerAnimation* >(const_cast< AnimationBase* >(&animationBase)); + FloatAnimation* pFloatAnim = dynamic_cast< FloatAnimation* >(const_cast< AnimationBase* >(&animationBase)); + + SysTryReturnResult(NID_UI_ANIM, (pIntAnim || pFloatAnim), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + if (pIntAnim) + { + int endVal = -1; + + if (animationBase.IsAutoReverseEnabled() == false) + { + endVal = static_cast< float >(pIntAnim->GetEndValue()); + __showStateHolder = ((endVal == 1) ? (true) : (false)); + } + } + else //if (pFloatAnim) + { + float endVal = -1.0f; + + if (animationBase.IsAutoReverseEnabled() == false) + { + endVal = (static_cast< float >(pFloatAnim->GetEndValue())); + __showStateHolder = (((!(Float::Compare(endVal, 1.0)))) ? (true) : (false)); + } + } + } + + if ((__pControl->GetShowState() == false) && ((animationBase.IsAutoReverseEnabled()) || (animationBase.IsHoldEndEnabled() == false))) + { + __pVisualElement->SetShowState(true); + __pVisualElement->Draw(); + __pVisualElement->SetShowState(false); + } + + return E_SUCCESS; +} + +result +_ControlAnimatorImpl::SetControlLogicalBounds(AnimationTargetType animTarget, AnimationBase& animationBase) +{ + result r = E_SUCCESS; + + if (animationBase.IsHoldEndEnabled() == true) + { + switch (animTarget) + { + case ANIMATION_TARGET_SIZE: + { + DimensionAnimation* pDimAnim = dynamic_cast< DimensionAnimation* >(const_cast< AnimationBase* >(&animationBase)); + RectangleAnimation* pRectAnim = dynamic_cast< RectangleAnimation* >(const_cast< AnimationBase* >(&animationBase)); + SysTryReturnResult(NID_UI_ANIM, ((pDimAnim) || (pRectAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + if (pDimAnim) + { + Dimension dimVal(0, 0); + if (animationBase.IsAutoReverseEnabled() == false) + { + dimVal = pDimAnim->GetEndValue(); + __logicalBoundsHolder.width = dimVal.width; + __logicalBoundsHolder.height = dimVal.height; + } + } + else //if (pRectAnim) + { + Rectangle rectVal(0, 0, 0, 0); + if (animationBase.IsAutoReverseEnabled() == false) + { + rectVal = pRectAnim->GetEndValue(); + __logicalBoundsHolder.width = rectVal.width; + __logicalBoundsHolder.height = rectVal.height; + } + } + } + break; + + case ANIMATION_TARGET_POSITION: + { + PointAnimation* pPointAnim = dynamic_cast< PointAnimation* >(const_cast< AnimationBase* >(&animationBase)); + RectangleAnimation* pRectAnim = dynamic_cast< RectangleAnimation* >(const_cast< AnimationBase* >(&animationBase)); + SysTryReturnResult(NID_UI_ANIM, ((pPointAnim) || (pRectAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + if (pPointAnim) + { + Point val(0, 0); + + if (animationBase.IsAutoReverseEnabled() == false) + { + val = pPointAnim->GetEndValue(); + __logicalBoundsHolder.x = val.x; + __logicalBoundsHolder.y = val.y; + } + } + else + { + Rectangle rectVal(0, 0, 0, 0); + + if (animationBase.IsAutoReverseEnabled() == false) + { + rectVal = pRectAnim->GetEndValue(); + __logicalBoundsHolder.x = rectVal.x; + __logicalBoundsHolder.y = rectVal.y; + } + } + } + break; + + default: + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. animTarget is invalid."); + return E_SYSTEM; + } + break; + } + } + return r; +} + +AnimationBase* +_ControlAnimatorImpl::CloneAnimation(AnimationTargetType animTarget, AnimationBase& animationBase) +{ + AnimationBase* pAnimationBase = null; + + //Comment: Deep copy animation object & pass to SetAnimation, which will store in list of structures + switch (animTarget) + { + case ANIMATION_TARGET_SIZE: + { + DimensionAnimation* pDimAnim = null; + RectangleAnimation* pRectAnim = null; + + pDimAnim = dynamic_cast< DimensionAnimation* >(&animationBase); + pRectAnim = dynamic_cast< RectangleAnimation* >(&animationBase); + SysTryReturn(NID_UI_ANIM, ((pDimAnim) || (pRectAnim)), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid."); + + if (pDimAnim) + { + DimensionAnimation* pDimValue = new (std::nothrow) DimensionAnimation(*pDimAnim); + pAnimationBase = pDimValue; + } + else + { + RectangleAnimation* pRectValue = new (std::nothrow) RectangleAnimation(*pRectAnim); + pAnimationBase = pRectValue; + } + } + break; + + case ANIMATION_TARGET_POSITION: + { + PointAnimation* pPointAnim = null; + RectangleAnimation* pRectAnim = null; + + pPointAnim = dynamic_cast< PointAnimation* >(&animationBase); + pRectAnim = dynamic_cast< RectangleAnimation* >(&animationBase); + SysTryReturn(NID_UI_ANIM, ((pPointAnim) || (pRectAnim)), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid."); + + if (pPointAnim) + { + PointAnimation* pPointValue = new (std::nothrow) PointAnimation(*pPointAnim); + pAnimationBase = pPointValue; + } + else + { + RectangleAnimation* pRectValue = new (std::nothrow) RectangleAnimation(*pRectAnim); + pAnimationBase = pRectValue; + } + } + break; + + case ANIMATION_TARGET_ALPHA: + { + FloatAnimation* pFloatAnim = null; + IntegerAnimation* pIntegerAnim = null; + + pFloatAnim = dynamic_cast< FloatAnimation* >(&animationBase); + pIntegerAnim = dynamic_cast< IntegerAnimation* >(&animationBase); + SysTryReturn(NID_UI_ANIM, ((pFloatAnim) || (pIntegerAnim)), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid."); + + if (pFloatAnim) + { + FloatAnimation* pFloatValue = new (std::nothrow) FloatAnimation(*pFloatAnim); + pAnimationBase = pFloatValue; + } + else + { + IntegerAnimation* pIntegerValue = new (std::nothrow) IntegerAnimation(*pIntegerAnim); + pAnimationBase = pIntegerValue; + } + } + break; + + case ANIMATION_TARGET_ROTATION: + { + RotateAnimation* pRotateAnimation = dynamic_cast< RotateAnimation* >(&animationBase); + SysTryReturn(NID_UI_ANIM, ((pRotateAnimation)), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid."); + + RotateAnimation* pRotateValue = new (std::nothrow) RotateAnimation(*pRotateAnimation); + pAnimationBase = pRotateValue; + } + break; + + default: + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. animTarget is invalid."); + return null; + } + break; + } + + return pAnimationBase; +} + +bool +_ControlAnimatorImpl::IsAnimatable(AnimationTargetType animTarget, Rectangle& bounds, AnimationBase* pAnimationBase, ControlAnimatorTriggerType animTrigger) const +{ + bool animatable = false; + Rectangle endBounds(0, 0, 0, 0); + + endBounds = bounds; + + if (pAnimationBase) + { + if (pAnimationBase->IsHoldEndEnabled() == true) + { + switch (animTarget) + { + case ANIMATION_TARGET_SIZE: + { + if (animTrigger == ANIMATION_TRIGGER_USER) + { + DimensionAnimation* pDimAnim = null; + RectangleAnimation* pRectAnim = null; + + if (pAnimationBase->GetType() == ANIMATION_TYPE_DIMENSION_ANIMATION) + { + pDimAnim = dynamic_cast< DimensionAnimation* >(pAnimationBase); + if (pDimAnim != null) + { + if (pAnimationBase->IsAutoReverseEnabled()) + { + endBounds.width = pDimAnim->GetStartValue().width; + endBounds.height = pDimAnim->GetStartValue().height; + } + else + { + endBounds.width = pDimAnim->GetEndValue().width; + endBounds.height = pDimAnim->GetEndValue().height; + } + } + } + else if (pAnimationBase->GetType() == ANIMATION_TYPE_RECTANGLE_ANIMATION) + { + pRectAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase); + if (pRectAnim != null) + { + if (pAnimationBase->IsAutoReverseEnabled()) + { + endBounds.width = pRectAnim->GetStartValue().width; + endBounds.height = pRectAnim->GetStartValue().height; + } + else + { + endBounds.width = pRectAnim->GetEndValue().width; + endBounds.height = pRectAnim->GetEndValue().height; + } + } + } + else + { + return false; + } + } + + if (!(__pControl->IsResizable())) + { + animatable = false; + } + else + { + //Scale Animation is allowed with any anchor (0,0) when HoldEnd=TRUE & Auto Reverse=FALSE + float ancX = 0.0f; + float ancY = 0.0f; + DimensionAnimation* pDimAnim = dynamic_cast< DimensionAnimation* >(pAnimationBase); + RectangleAnimation* pRectAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase); + + (pDimAnim) ? (pDimAnim->GetAnchor(ancX, ancY)) : (pRectAnim->GetAnchor(ancX, ancY)); + + if ((Float::Compare(ancX, 0.0)) || (Float::Compare(ancY, 0.0))) + { + return false; + } + + //CustomControl Changes + CustomControlBase* pControlBase = dynamic_cast< CustomControlBase* >(__pControl); + + if (pControlBase) + { + Dimension endDimension(endBounds.width, endBounds.height); + __pControlImpl->OnEvaluateSize(endDimension); + } + else + { + Dimension controlMinSize = __pControl->GetMinimumSize(); + SysTryReturn(NID_UI_ANIM, ((endBounds.width >= controlMinSize.width) && (endBounds.height >= controlMinSize.height)), + false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. end size = (%d, %d)", endBounds.width, endBounds.height); + + Dimension controlMaxSize = __pControl->GetMaximumSize(); + SysTryReturn(NID_UI_ANIM, ((endBounds.width <= controlMaxSize.width) && (endBounds.height <= controlMaxSize.height)), + false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. end size = (%d, %d)", endBounds.width, endBounds.height); + } + animatable = true; + } + } + break; + + case ANIMATION_TARGET_POSITION: + { + if (animTrigger == ANIMATION_TRIGGER_USER) + { + PointAnimation* pPointAnim = null; + RectangleAnimation* pRectAnim = null; + + if (pAnimationBase->GetType() == ANIMATION_TYPE_POINT_ANIMATION) + { + pPointAnim = dynamic_cast< PointAnimation* >(pAnimationBase); + if (pPointAnim != null) + { + if (pAnimationBase->IsAutoReverseEnabled()) + { + endBounds.x = pPointAnim->GetStartValue().x; + endBounds.y = pPointAnim->GetStartValue().y; + } + else + { + endBounds.x = pPointAnim->GetEndValue().x; + endBounds.y = pPointAnim->GetEndValue().y; + } + } + } + else if (pAnimationBase->GetType() == ANIMATION_TYPE_RECTANGLE_ANIMATION) + { + pRectAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase); + if (pRectAnim != null) + { + if (pAnimationBase->IsAutoReverseEnabled()) + { + endBounds.x = pRectAnim->GetStartValue().x; + endBounds.y = pRectAnim->GetStartValue().y; + } + else + { + endBounds.x = pRectAnim->GetEndValue().x; + endBounds.y = pRectAnim->GetEndValue().y; + } + } + } + else + { + return false; + } + } + + if (!(__pControl->IsMovable())) + { + animatable = false; + } + else + { + //CustomControl Changes + CustomControlBase* pControlBase = dynamic_cast< CustomControlBase* >(__pControl); + + if (pControlBase) + { + __pControlImpl->OnBoundsChanging(endBounds); //check this this API has been changed in 2.0 + } + //Comment. No limit on positive & negative "x" & "y" for the movable %Control's position property + animatable = true; + } + } + break; + + case ANIMATION_TARGET_ALPHA: + { + float endVal = -1.0f; + IntegerAnimation* pIntAnim = null; + FloatAnimation* pFloatAnim = null; + + if (pAnimationBase->GetType() == ANIMATION_TYPE_FLOAT_ANIMATION) + { + pFloatAnim = dynamic_cast< FloatAnimation* >(pAnimationBase); + if (pFloatAnim != null) + { + if (pAnimationBase->IsAutoReverseEnabled()) + { + endVal = pFloatAnim->GetStartValue(); + } + else + { + endVal = pFloatAnim->GetEndValue(); + } + } + } + else if (pAnimationBase->GetType() == ANIMATION_TYPE_INTEGER_ANIMATION) + { + pIntAnim = dynamic_cast< IntegerAnimation* >(pAnimationBase); + if (pIntAnim != null) + { + if (pAnimationBase->IsAutoReverseEnabled()) + { + endVal = (static_cast< float >(pIntAnim->GetStartValue())); + } + else + { + endVal = (static_cast< float >(pIntAnim->GetEndValue())); + } + } + } + else + { + return false; + } + + //removing the code of IsShowStateChangeable + if ((!(Float::Compare(endVal, 1.0))) || (!(Float::Compare(endVal, 0.0)))) + { + animatable = true; + } + else + { + SysLogException(NID_UI_ANIM, E_INVALID_ARG, "Invalid argument(s) is used. End value is invalid."); + return false; + } + + } + break; + + case ANIMATION_TARGET_ROTATION: + { + if (animTrigger == ANIMATION_TRIGGER_USER) + { + RotateAnimation* pRotAnim = null; + if (pAnimationBase->GetType() == ANIMATION_TYPE_ROTATE_ANIMATION) + { + float endVal = -1.0f; + pRotAnim = dynamic_cast< RotateAnimation* >(pAnimationBase); + if (pRotAnim != null) + { + if (pAnimationBase->IsAutoReverseEnabled()) + { + endVal = pRotAnim->GetStartValue(); + } + else + { + endVal = pRotAnim->GetEndValue(); + } + } + int roundingVal = Tizen::Base::Utility::Math::Round((double) endVal); + + if ((!(Float::Compare(endVal, static_cast< float >(roundingVal)))) && (((static_cast< int >(endVal) % 360) == 0))) //check this : Todo + { + animatable = true; + } + else + { + SysLogException(NID_UI_ANIM, E_INVALID_ARG, "Invalid argument(s) is used. End value is invalid."); + return false; + } + } + else + { + SysLogException(NID_UI_ANIM, E_INVALID_ARG, "Invalid argument(s) is used. End value is invalid."); + return false; + } + } + } + break; + + default: + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. animTarget is invalid."); + animatable = false; + } + break; + } + } + else //IsHoldEndEnabled = false + { + animatable = true; + } + } + + return animatable; +} + +bool +_ControlAnimatorImpl::IsAnimationSupported(void) const +{ + return _VisualElementAnimationImpl::IsAnimationSupported(); +} + +void +_ControlAnimatorImpl::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) +{ + ActiveAnimation activeAnim; + int index = -1; + String animName(0); + + if (keyName.IsEmpty() == true) + { + String* pUserData = (String*) (animation.GetUserData()); + if (pUserData != null) + { + animName = *pUserData; + } + } + else + { + animName = keyName; + } + + index = GetActiveAnimationIndex(animName); + + if (index == -1) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation name mismatch in the playlist."); + return; + } + + if (__pActiveAnimationList->GetAt(index, activeAnim) != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not present in the playlist."); + return; + } + + __isAnimationTargetAnimating[activeAnim.animTarget] = true; + + int startIndex = 0; + int indexOf = 0; + + if ((animName.IndexOf(TRANSACTION, startIndex, indexOf)) != E_SUCCESS) + { + //Calling simple listeners registered in this control animator + if (__pAnimStatusEventListener) + { + IControlAnimatorEventListener* pCaEventListener = null; + for (int count = (__pAnimStatusEventListener->GetCount() - 1); count >= 0; count--) + { + __pAnimStatusEventListener->GetAt(count, pCaEventListener); + if (pCaEventListener) + { + pCaEventListener->OnControlAnimationStarted(*__pControlAnimator, *__pControl); + } + } + } + + //calling detailed event listerners registered in this control animator + if (__pAnimDetailedEventListener) + { + IControlAnimatorDetailedEventListener* pDetailedEventListener = null; + + for (int count = (__pAnimDetailedEventListener->GetCount() - 1); count >= 0; count--) + { + __pAnimDetailedEventListener->GetAt(count, pDetailedEventListener); + + if (pDetailedEventListener) + { + pDetailedEventListener->OnControlAnimationStarted(*__pControlAnimator, *__pControl, activeAnim.animType, activeAnim.animTarget, activeAnim.pAnimationBase); + } + } + } + } +} + +void +_ControlAnimatorImpl::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) +{ + ActiveAnimation activeAnim; + int index = -1; + String animName(0); + + if (keyName.IsEmpty() == true) + { + String* pUserData = (String*) (animation.GetUserData()); + + if (pUserData != null) + { + animName = *pUserData; + } + } + else + { + animName = keyName; + } + + index = GetActiveAnimationIndex(animName); + if (index == -1) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation name mismatch in the playlist."); + return; + } + + if (__pActiveAnimationList->GetAt(index, activeAnim) != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not present in the playlist."); + return; + } + + int startIndex = 0; + int indexOf = 0; + + if ((animName.IndexOf(TRANSACTION, startIndex, indexOf)) != E_SUCCESS) + { + if (__pAnimDetailedEventListener) + { + IControlAnimatorDetailedEventListener* pDetailedEventListener = null; + + for (int count = (__pAnimDetailedEventListener->GetCount() - 1); count >= 0; count--) + { + __pAnimDetailedEventListener->GetAt(count, pDetailedEventListener); + + if (pDetailedEventListener) + { + pDetailedEventListener->OnControlAnimationRepeated(*__pControlAnimator, *__pControl, activeAnim.animType, activeAnim.animTarget, activeAnim.pAnimationBase, currentRepeatCount); + } + } + } + } +} + +void +_ControlAnimatorImpl::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally) +{ + String animName(0); + + if (keyName.IsEmpty() == true) + { + String* pUserData = (String*) (animation.GetUserData()); + + if (pUserData != null) + { + animName = *pUserData; + delete pUserData; + pUserData = null; + } + } + else + { + animName = keyName; + } + + _VisualElementImpl* pPresentationImpl = _VisualElementImpl::GetInstance(*const_cast(__pVisualElement->AcquirePresentationInstance())); + + if (pPresentationImpl == null) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Screen is not updated with end values."); + } + else + { + VisualElementValueAnimation* pValueAnimation = dynamic_cast< VisualElementValueAnimation* >(const_cast< VisualElementAnimation* >(&animation)); + VisualElementPropertyAnimation* pAnimation = dynamic_cast< VisualElementPropertyAnimation* >(const_cast< VisualElementAnimation* >(&animation)); + + if (completedNormally == false || (pValueAnimation && pValueAnimation->IsEndValueApplied() == false)) + { + if (pAnimation) + { + String propName = pAnimation->GetPropertyName(); + + int startIndex = 0; + int indexOf = 0; + result r = E_SUCCESS; + + if ((propName.IndexOf(VeSubPropBoundsPosition, startIndex, indexOf)) == E_SUCCESS) + { + r = pPresentationImpl->SetProperty(VePropBounds, __pVisualElement->GetBounds()); + } + else if ((propName.IndexOf(VePropBounds, startIndex, indexOf)) == E_SUCCESS) + { + r = pPresentationImpl->SetProperty(VePropBounds, __pVisualElement->GetBounds()); + } + else if ((propName.IndexOf(VeSubPropTransformRotationZ, startIndex, indexOf)) == E_SUCCESS) + { + r = pPresentationImpl->SetProperty(VePropTransform, __pVisualElement->GetTransformMatrix()); + } + else if ((propName.IndexOf(VePrivPropShowOpacity, startIndex, indexOf)) == E_SUCCESS) + { + r = pPresentationImpl->SetProperty(VePropShowState, __pVisualElement->GetShowState()); + } + + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Screen is not updated with end values."); + } + } + else if (pValueAnimation) + { + pPresentationImpl->SetProperty(VePropBounds, __pVisualElement->GetBounds()); + } + } + } + + __pVisualElement->ReleasePresentationInstance(); + + ActiveAnimation activeAnim; + int index = -1; + + index = GetActiveAnimationIndex(animName); + + if (index == -1) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation name mismatch in the playlist."); + return; + } + + if (__pActiveAnimationList->GetAt(index, activeAnim) != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not present in the playlist."); + return; + } + + int startIndex = 0; + int indexOf = 0; + + __isAnimationTargetAnimating[activeAnim.animTarget] = false; + + if ((animName.IndexOf(TRANSACTION, startIndex, indexOf)) != E_SUCCESS) + { + if (__pAnimStatusEventListener) + { + IControlAnimatorEventListener* pCaEventListener = null; + + for (int count = (__pAnimStatusEventListener->GetCount() - 1); count >= 0; count--) + { + __pAnimStatusEventListener->GetAt(count, pCaEventListener); + if (pCaEventListener) + { + if (completedNormally) + { + pCaEventListener->OnControlAnimationFinished(*__pControlAnimator, *__pControl); + } + else + { + pCaEventListener->OnControlAnimationStopped(*__pControlAnimator, *__pControl); + } + } + } + } + + //Calling detailed event listeners + if (__pAnimDetailedEventListener) + { + IControlAnimatorDetailedEventListener* pDetailedEventListener = null; + + for (int count = (__pAnimDetailedEventListener->GetCount() - 1); count >= 0; count--) + { + __pAnimDetailedEventListener->GetAt(count, pDetailedEventListener); + + if (pDetailedEventListener) + { + if (completedNormally) + { + pDetailedEventListener->OnControlAnimationFinished(*__pControlAnimator, *__pControl, activeAnim.animType, activeAnim.animTarget, activeAnim.pAnimationBase); + } + else + { + pDetailedEventListener->OnControlAnimationStopped(*__pControlAnimator, *__pControl, activeAnim.animType, activeAnim.animTarget, activeAnim.pAnimationBase); + } + } + } + } + } + + RemoveAnimationAt(index); +} + +result +_ControlAnimatorImpl::StopAllAnimations(void) +{ + result r = E_SUCCESS; + + __pVisualElement->RemoveAllAnimations(); + + return r; +} + +result +_ControlAnimatorImpl::StopAnimation(ControlAnimatorTriggerType animTrigger) +{ + SysTryReturnResult(NID_UI_ANIM, (GetActiveAnimationListCount() > 0), E_SUCCESS, "No active animation."); + + result r = E_SUCCESS; + + for (int index = GetActiveAnimationListCount() - 1; index >= 0; index--) + { + String animName; + + animName = GetActiveAnimationAt(index, animTrigger); + if (!(animName.IsEmpty())) + { + int startIndex = 0; + int indexOfGroup = 0; + if ((animName.IndexOf(GROUP, startIndex, indexOfGroup)) == E_SUCCESS) + { + String groupName; + r = animName.SubString(indexOfGroup, groupName); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Group name is not found."); + + r = __pVisualElement->RemoveAnimation(groupName); + } + else + { + r = __pVisualElement->RemoveAnimation(animName); + } + + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Animation is either running or already removed."); + } + } + + return r; +} + +result +_ControlAnimatorImpl::AddControlAnimatorEventListener(const IControlAnimatorEventListener& listener) +{ + if (__pAnimStatusEventListener == null) + { + __pAnimStatusEventListener = new (std::nothrow) LinkedListT< IControlAnimatorEventListener* >(); + SysTryReturnResult(NID_UI_ANIM, (__pAnimStatusEventListener), E_OUT_OF_MEMORY, "Memory allocation failed."); + } + + IControlAnimatorEventListener* pStatusListener = const_cast< IControlAnimatorEventListener* >(&listener); + + if (__pAnimStatusEventListener->Contains(pStatusListener) == true) + { + return E_OBJ_ALREADY_EXIST; + } + + return __pAnimStatusEventListener->Add(pStatusListener); +} + +result +_ControlAnimatorImpl::RemoveControlAnimatorEventListener(const IControlAnimatorEventListener& listener) +{ + result r = E_SYSTEM; + + if (__pAnimStatusEventListener) + { + return __pAnimStatusEventListener->Remove((const_cast< IControlAnimatorEventListener* >(&listener))); + } + + return r; +} + +result +_ControlAnimatorImpl::AddControlAnimatorDetailedEventListener(const IControlAnimatorDetailedEventListener& listener) +{ + if (__pAnimDetailedEventListener == null) + { + __pAnimDetailedEventListener = new (std::nothrow) LinkedListT< IControlAnimatorDetailedEventListener* >(); + SysTryReturnResult(NID_UI_ANIM, (__pAnimDetailedEventListener), E_OUT_OF_MEMORY, "Memory allocation failed."); + } + + IControlAnimatorDetailedEventListener* pStatusListener = const_cast< IControlAnimatorDetailedEventListener* >(&listener); + + if (__pAnimDetailedEventListener->Contains(pStatusListener) == true) + { + return E_OBJ_ALREADY_EXIST; + } + + return __pAnimDetailedEventListener->Add(pStatusListener); +} + +result +_ControlAnimatorImpl::RemoveControlAnimatorDetailedEventListener(const IControlAnimatorDetailedEventListener& listener) +{ + result r = E_SYSTEM; + + if (__pAnimDetailedEventListener) + { + return __pAnimDetailedEventListener->Remove((const_cast< IControlAnimatorDetailedEventListener* >(&listener))); + } + + return r; +} + +int +_ControlAnimatorImpl::GetActiveAnimationIndex(const String& animName) const +{ + result r = E_SUCCESS; + + for (int index = 0; index < __pActiveAnimationList->GetCount(); index++) + { + ActiveAnimation activeAnim; + + r = __pActiveAnimationList->GetAt(index, activeAnim); + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), -1, r, "[%s] Failed to retrieve animation from the list.", GetErrorMessage(r)); + + if (activeAnim.animName == animName) + { + return index; + } + } + + return -1; +} + +result +_ControlAnimatorImpl::SetPrevAnimationBoundsProperty(AnimationTargetType animTarget, AnimationBase& animationBase) +{ + result r = E_SUCCESS; + + if (animationBase.IsHoldEndEnabled() == true) + { + switch (animTarget) + { + case ANIMATION_TARGET_SIZE: + { + DimensionAnimation* pDimAnim = null; + RectangleAnimation* pRectAnim = null; + pDimAnim = dynamic_cast< DimensionAnimation* >(const_cast< AnimationBase* >(&animationBase)); + pRectAnim = dynamic_cast< RectangleAnimation* >(const_cast< AnimationBase* >(&animationBase)); + SysTryReturnResult(NID_UI_ANIM, ((pDimAnim) || (pRectAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + if (pDimAnim) + { + Dimension dimVal(0, 0); + (animationBase.IsAutoReverseEnabled()) ? (dimVal = pDimAnim->GetStartValue()) : (dimVal = pDimAnim->GetEndValue()); + __prevAnimationBoundsHolder.width = dimVal.width; + __prevAnimationBoundsHolder.height = dimVal.height; + } + else //if (pRectAnim) + { + Rectangle rectVal(0, 0, 0, 0); + (animationBase.IsAutoReverseEnabled()) ? (rectVal = pRectAnim->GetStartValue()) : (rectVal = pRectAnim->GetEndValue()); + __prevAnimationBoundsHolder.width = rectVal.width; + __prevAnimationBoundsHolder.height = rectVal.height; + } + } + break; + + default: + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. animTarget is invalid."); + return E_SYSTEM; + } + } + + return r; +} + +result +_ControlAnimatorImpl::SetAnimationTargetStatus(ControlAnimatorTriggerType triggerType) +{ + SysTryReturnResult(NID_UI_ANIM, (triggerType >= ANIMATION_TRIGGER_POSITION_CHANGE && triggerType <= ANIMATION_TRIGGER_SHOW_STATE_CHANGE), E_INVALID_ARG, "Invalid argument(s) is used. Animation trigger type is invalid."); + + result r = E_SUCCESS; + ParallelAnimationGroup* pParallelAnimGrp = null; + SequentialAnimationGroup* pSequentialAnimGrp = null; + + if (__propertyAnimationGroupType[triggerType - 1] == PROPERTY_ANIMATION_GROUP_TYPE_SEQUENTIAL) + { + pSequentialAnimGrp = dynamic_cast< SequentialAnimationGroup* >(__pPropertyAnimationGroupList[triggerType - 1]); + if (pSequentialAnimGrp) + { + for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++) + { + AnimationTargetType _animTarget = pSequentialAnimGrp->GetAnimationTargetTypeAt(index); + SysTryReturnResult(NID_UI_ANIM, ((_animTarget > ANIMATION_TARGET_NONE) && (_animTarget < ANIMATION_TARGET_MAX)), + E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid."); + __isAnimationTargetAnimating[_animTarget] = true; + + if (_animTarget == ANIMATION_TARGET_POSITION || _animTarget == ANIMATION_TARGET_SIZE || _animTarget == ANIMATION_TARGET_ALPHA) + { + AnimationBase* pAnimationBase = null; + + pAnimationBase = pSequentialAnimGrp->GetAnimationAtN(index); + if (pAnimationBase) + { + if (_animTarget == ANIMATION_TARGET_ALPHA) + { + SetControlShowState(_animTarget, *pAnimationBase); + } + else + { + SetControlLogicalBounds(_animTarget, *pAnimationBase); + } + + delete pAnimationBase; + } + } + } + } + } + else if (__propertyAnimationGroupType[triggerType - 1] == PROPERTY_ANIMATION_GROUP_TYPE_PARALLEL) + { + pParallelAnimGrp = dynamic_cast< ParallelAnimationGroup* >(__pPropertyAnimationGroupList[triggerType - 1]); + if (pParallelAnimGrp) + { + for (int index = (static_cast< int >(ANIMATION_TARGET_NONE) + 1); index < (static_cast< int >(ANIMATION_TARGET_MAX)); index++) + { + AnimationTargetType _animTarget = static_cast< AnimationTargetType >(index); + AnimationBase* pAnimBase = null; + + pAnimBase = pParallelAnimGrp->GetAnimationN(_animTarget); + if (pAnimBase != null) + { + SysTryReturnResult(NID_UI_ANIM, ((_animTarget > ANIMATION_TARGET_NONE) && (_animTarget < ANIMATION_TARGET_MAX)), + E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid."); + __isAnimationTargetAnimating[_animTarget] = true; + + if (_animTarget == ANIMATION_TARGET_POSITION || _animTarget == ANIMATION_TARGET_SIZE) + { + SetControlLogicalBounds(_animTarget, *pAnimBase); + } + else if (_animTarget == ANIMATION_TARGET_ALPHA) + { + SetControlShowState(_animTarget, *pAnimBase); + } + + delete pAnimBase; + } + } + } + } + //Set Target status playing in case of platform defined Implicit animations + else + { + if (triggerType == ANIMATION_TRIGGER_POSITION_CHANGE) + { + __isAnimationTargetAnimating[ANIMATION_TARGET_POSITION] = true; + } + + if (triggerType == ANIMATION_TRIGGER_SIZE_CHANGE) + { + __isAnimationTargetAnimating[ANIMATION_TARGET_SIZE] = true; + } + + if (triggerType == ANIMATION_TRIGGER_SHOW_STATE_CHANGE) + { + __isAnimationTargetAnimating[ANIMATION_TARGET_ALPHA] = true; + } + } + + return r; +} + +result +_ControlAnimatorImpl::SetKeyFrameAnimation(AnimationTargetType animTarget, AnimationBase* pAnimationBase, const IVisualElementAnimationTimingFunction* pTimingFunction, VisualElementAnimation* pAnimation) +{ + long keyTime = 0; + result r = E_SUCCESS; + + VisualElementValueAnimation* pPropertyAnimation = dynamic_cast< VisualElementValueAnimation* >(pAnimation); + SysTryReturnResult(NID_UI_ANIM, (pPropertyAnimation != null), E_INVALID_ARG, "Invalid argument(s) is used. VisualElementAnimation is null."); + + switch (animTarget) + { + + case ANIMATION_TARGET_SIZE: + { + DimensionAnimation* pDimensionAnim = null; + RectangleAnimation* pRectangleAnim = null; + + pDimensionAnim = dynamic_cast< DimensionAnimation* >(pAnimationBase); + pRectangleAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase); + SysTryReturnResult(NID_UI_ANIM, ((pDimensionAnim) || (pRectangleAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + Dimension controlSize; + float anchorX = 0.0f; + float anchorY = 0.0f; + + controlSize = __pControl->GetSize(); + + if (pDimensionAnim) + { + Dimension dimValue(0, 0); + + pDimensionAnim->GetAnchor(anchorX, anchorY); + + for (int index = 0; index < pDimensionAnim->GetKeyFrameCount(); index++) + { + pDimensionAnim->GetKeyFrameAt(index, keyTime, dimValue); + + if (keyTime < pDimensionAnim->GetDuration()) + { + FloatRectangle modelBounds = __pVisualElement->GetBounds(); + FloatRectangle presentationBounds = const_cast((__pVisualElement)->AcquirePresentationInstance())->GetBounds(); + __pVisualElement->ReleasePresentationInstance(); + + float currentAnchorX = presentationBounds.width * anchorX; + float currentAnchorY = presentationBounds.height * anchorY; + float endAnchorX = dimValue.width * anchorX; + float endAnchorY = dimValue.height * anchorY; + + float endX = modelBounds.x + (currentAnchorX - endAnchorX); + float endY = modelBounds.y + (currentAnchorY - endAnchorY); + + Variant keyValue(FloatRectangle(endX, endY, static_cast< float >(dimValue.width), static_cast< float >(dimValue.height))); + + r = pPropertyAnimation->AddKeyFrame(keyTime / static_cast< float >(pDimensionAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction)); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame."); + } + } + } + else //if (pRectangleAnim) + { + Rectangle dimValue(0, 0, 0, 0); + + pRectangleAnim->GetAnchor(anchorX, anchorY); + + for (int index = 0; index < pRectangleAnim->GetKeyFrameCount(); index++) + { + pRectangleAnim->GetKeyFrameAt(index, keyTime, dimValue); + + if (keyTime < pRectangleAnim->GetDuration()) + { + FloatRectangle modelBounds = __pVisualElement->GetBounds(); + FloatRectangle presentationBounds = const_cast((__pVisualElement)->AcquirePresentationInstance())->GetBounds(); + __pVisualElement->ReleasePresentationInstance(); + + float currentAnchorX = presentationBounds.width * anchorX; + float currentAnchorY = presentationBounds.height * anchorY; + float endAnchorX = dimValue.width * anchorX; + float endAnchorY = dimValue.height * anchorY; + + float endX = modelBounds.x + (currentAnchorX - endAnchorX); + float endY = modelBounds.y + (currentAnchorY - endAnchorY); + + Variant keyValue(FloatRectangle(endX, endY, static_cast< float >(dimValue.width), static_cast< float >(dimValue.height))); + r = pPropertyAnimation->AddKeyFrame(keyTime / static_cast< float >(pRectangleAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction)); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame."); + } + } + } + } + break; + + case ANIMATION_TARGET_POSITION: + { + PointAnimation* pPointAnim = null; + RectangleAnimation* pRectangleAnim = null; + + pPointAnim = dynamic_cast< PointAnimation* >(pAnimationBase); + pRectangleAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase); + SysTryReturnResult(NID_UI_ANIM, ((pPointAnim) || (pRectangleAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + Point controlPos; + Rectangle clientBounds = __pControlImpl->GetParent()->GetClientBounds(); + FloatRectangle modelBounds = __pVisualElement->GetBounds(); + + controlPos = __pControl->GetPosition(); + + if (pPointAnim) + { + Point pointValue(0, 0); + Point prevPointValue = controlPos; + + for (int index = 0; index < pPointAnim->GetKeyFrameCount(); index++) + { + pPointAnim->GetKeyFrameAt(index, keyTime, pointValue); + + + if (keyTime < pPointAnim->GetDuration()) + { + float absPointX = (static_cast< float >(clientBounds.x) + static_cast< float >(pointValue.x)); + float absPointY = (static_cast< float >(clientBounds.y) + static_cast< float >(pointValue.y)); + + Variant keyValue(FloatPoint(absPointX, absPointY)); + + r = pPropertyAnimation->AddKeyFrame(static_cast< float >(keyTime) / static_cast< float >(pPointAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction)); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame."); + } + + } + } + else //if (pRectangleAnim) + { + Rectangle pointValue(0, 0, 0, 0); + Rectangle prevPointValue = Rectangle(controlPos.x, controlPos.y, 0, 0); + + for (int index = 0; index < pRectangleAnim->GetKeyFrameCount(); index++) + { + pRectangleAnim->GetKeyFrameAt(index, keyTime, pointValue); + + if (keyTime < pRectangleAnim->GetDuration()) + { + float absPointX = (static_cast< float >(clientBounds.x) + static_cast< float >(pointValue.x)); + float absPointY = (static_cast< float >(clientBounds.y) + static_cast< float >(pointValue.y)); + + Variant keyValue(FloatPoint(absPointX, absPointY)); + + r = pPropertyAnimation->AddKeyFrame(static_cast< float >(keyTime) / static_cast< float >(pRectangleAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction)); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame."); + } + } + } + } + break; + + case ANIMATION_TARGET_ALPHA: + { + IntegerAnimation* pIntegerAnim = null; + FloatAnimation* pFloatAnim = null; + + pIntegerAnim = dynamic_cast< IntegerAnimation* >(pAnimationBase); + pFloatAnim = dynamic_cast< FloatAnimation* >(pAnimationBase); + SysTryReturnResult(NID_UI_ANIM, (pIntegerAnim || pFloatAnim), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + if (pIntegerAnim) + { + int alphaIntValue = 0; + + for (int index = 0; index < pIntegerAnim->GetKeyFrameCount(); index++) + { + pIntegerAnim->GetKeyFrameAt(index, keyTime, alphaIntValue); + + if (keyTime < pIntegerAnim->GetDuration()) + { + Variant keyValue(static_cast< float >(alphaIntValue)); + + r = pPropertyAnimation->AddKeyFrame(static_cast< float >(keyTime) / static_cast< float >(pIntegerAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction)); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame."); + + } + } + } + else //if (pFloatAnim) + { + float alphaFltValue = 0.0; + + for (int index = 0; index < pFloatAnim->GetKeyFrameCount(); index++) + { + pFloatAnim->GetKeyFrameAt(index, keyTime, alphaFltValue); + + if (keyTime < pFloatAnim->GetDuration()) + { + Variant keyValue(static_cast< float >(alphaFltValue)); + + r = pPropertyAnimation->AddKeyFrame(static_cast< float >(keyTime) / static_cast< float >(pFloatAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction)); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame."); + } + } + } + } + break; + + case ANIMATION_TARGET_ROTATION: + { + RotateAnimation* pRotateAnim = null; + + pRotateAnim = dynamic_cast< RotateAnimation* >(pAnimationBase); + SysTryReturnResult(NID_UI_ANIM, (pRotateAnim), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid."); + + float rotateFltValue = 0; + + for (int index = 0; index < pRotateAnim->GetKeyFrameCount(); index++) + { + pRotateAnim->GetKeyFrameAt(index, keyTime, rotateFltValue); + + if (keyTime < pRotateAnim->GetDuration()) + { + Variant keyValue(rotateFltValue); + + r = pPropertyAnimation->AddKeyFrame(static_cast< float >(keyTime) / static_cast< float >(pRotateAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction)); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame."); + } + } + } + break; + + default: + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. animTarget is invalid."); + return E_SYSTEM; + } + break; + } + + return E_SUCCESS; +} + +result +_ControlAnimatorImpl::SetGroupAnimation(AnimationGroup* pAnimGrp) +{ + result r = E_SUCCESS; + ParallelAnimationGroup* pParallelAnimGrp = null; + SequentialAnimationGroup* pSequentialAnimGrp = null; + AnimationTargetType animTargetArray[ANIMATION_TARGET_MAX] = + { + ANIMATION_TARGET_ROTATION, + ANIMATION_TARGET_SIZE, + ANIMATION_TARGET_POSITION, + ANIMATION_TARGET_ALPHA + }; + bool setLogicalBnds = false; + bool setShowStateInternal = false; + long delay = 0; + long duration = 0; + long totalDelay = 0; + long groupDuration = 0; + VisualElementAnimationGroup* pAnimationGroup = null; + String animIdentifier; + int activeAnimationCount = GetActiveAnimationListCount(); + + pParallelAnimGrp = dynamic_cast< ParallelAnimationGroup* >(pAnimGrp); + pSequentialAnimGrp = dynamic_cast< SequentialAnimationGroup* >(pAnimGrp); + SysTryReturnResult(NID_UI_ANIM, ((pParallelAnimGrp) || (pSequentialAnimGrp)), E_INVALID_ARG, "Invalid argument(s) is used. AnimationGroup argument is invalid."); + + __sequelDelay = 0; + pAnimationGroup = new (std::nothrow) VisualElementAnimationGroup(); + SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + animIdentifier.Append(__animId); + animIdentifier.Append(GROUP); + __animId++; + __groupName.Clear(); + __groupName = animIdentifier; + + if (pParallelAnimGrp) + { + for (int target = (static_cast< int >(ANIMATION_TARGET_NONE) + 1); target < (static_cast< int >(ANIMATION_TARGET_MAX)); target++) + { + AnimationTargetType animTarget = animTargetArray[target]; + AnimationBase* pAnimationBase = null; + pAnimationBase = pParallelAnimGrp->GetAnimationN(animTarget); + + if (pAnimationBase != null) + { + long duration = pAnimationBase->GetDuration(); + + if (pAnimationBase->IsAutoReverseEnabled()) + { + duration = duration * 2; + } + + duration = (duration * pAnimationBase->GetRepeatCount() * pAnimationBase->GetScaleRatio()) + ((pAnimationBase->GetDelay() - pAnimationBase->GetOffset()) * pAnimationBase->GetScaleRatio()); + + if (duration > groupDuration) + { + groupDuration = duration; + } + + if (IsAnimationSupported() == false) + { + r = SetControlProperty(animTarget, *pAnimationBase); + delete pAnimationBase; + + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to store animation values."); + } + else + { + if (pParallelAnimGrp->IsAnimationAdded(ANIMATION_TARGET_POSITION) || + pParallelAnimGrp->IsAnimationAdded(ANIMATION_TARGET_SIZE)) + { + __logicalBoundsHolder = __pControl->GetBounds(); + setLogicalBnds = true; + } + else if (pParallelAnimGrp->IsAnimationAdded(ANIMATION_TARGET_ALPHA)) + { + __showStateHolder = __pControl->GetShowState(); + setShowStateInternal = true; + } + + r = SetAnimation(animTarget, *pAnimationBase, ANIMATION_TRIGGER_USER, pAnimationGroup); + + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start animation."); + goto CATCH; + } + + __isAnimationTargetAnimating[animTarget] = true; + + if (animTarget == ANIMATION_TARGET_POSITION || animTarget == ANIMATION_TARGET_SIZE) + { + SetControlLogicalBounds(animTarget, *pAnimationBase); + } + else if (animTarget == ANIMATION_TARGET_ALPHA) + { + SetControlShowState(animTarget, *pAnimationBase); + } + } + } + } + } + else + { + __prevAnimationBoundsHolder = __pControl->GetBounds(); + + for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++) + { + AnimationTargetType animTarget = ANIMATION_TARGET_MAX; + AnimationBase* pAnimationBase = null; + pAnimationBase = pSequentialAnimGrp->GetAnimationAtN(index); + animTarget = pSequentialAnimGrp->GetAnimationTargetTypeAt(index); + + if (pAnimationBase != null) + { + if (IsAnimationSupported() == false) + { + r = SetControlProperty(animTarget, *pAnimationBase); + delete pAnimationBase; + + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to store animation values."); + } + else + { + if ((pSequentialAnimGrp->GetAnimationTargetTypeAt(index) == ANIMATION_TARGET_POSITION) || + (pSequentialAnimGrp->GetAnimationTargetTypeAt(index) == ANIMATION_TARGET_SIZE)) + { + __logicalBoundsHolder = __pControl->GetBounds(); + setLogicalBnds = true; + } + + if (pSequentialAnimGrp->GetAnimationTargetTypeAt(index) == ANIMATION_TARGET_ALPHA) + { + __showStateHolder = __pControl->GetShowState(); + setShowStateInternal = true; + } + + if (animTarget == ANIMATION_TARGET_SIZE) + { + r = SetPrevAnimationBoundsProperty(animTarget, *pAnimationBase); + + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to store previous animation bounds."); + delete pAnimationBase; + + goto CATCH; + } + } + + __sequentialGroupAnimation = true; + //Add the animation to the group + r = SetAnimation(animTarget, *pAnimationBase, ANIMATION_TRIGGER_USER, pAnimationGroup); + __sequentialGroupAnimation = false; + + if (pAnimationBase->IsAutoReverseEnabled() == true) + { + duration = 2 * pAnimationBase->GetDuration(); + } + else + { + duration = pAnimationBase->GetDuration(); + } + + delay = pAnimationBase->GetDelay(); + totalDelay = delay + duration * pAnimationBase->GetRepeatCount(); + totalDelay = totalDelay - (pAnimationBase->GetOffset()); + __sequelDelay = totalDelay; + groupDuration = groupDuration + __sequelDelay * pAnimationBase->GetScaleRatio(); + + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start animation."); + goto CATCH; + } + + __isAnimationTargetAnimating[animTarget] = true; + + if (animTarget == ANIMATION_TARGET_POSITION || animTarget == ANIMATION_TARGET_SIZE) + { + SetControlLogicalBounds(animTarget, *pAnimationBase); + } + else if (animTarget == ANIMATION_TARGET_ALPHA) + { + SetControlShowState(animTarget, *pAnimationBase); + } + } + } + } + } + + if (setLogicalBnds) + { + bool disable = false; + bool propagation = false; + + result r = DisableImplicitAnimation(disable); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation."); + //if (pParallelAnimGrp == null) + { + r = DisableVisualElementPropagation(propagation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation."); + } + r = __pControl->SetBounds(__logicalBoundsHolder); + + if (propagation) + { + DisableVisualElementPropagation(propagation); + } + if (disable) + { + DisableImplicitAnimation(disable); + } + + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds."); + } + + if (setShowStateInternal) + { + bool disable = false; + bool propagation = false; + + result r = DisableImplicitAnimation(disable); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation."); + + r = DisableVisualElementPropagation(propagation); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation."); + + r = __pControl->SetShowState(__showStateHolder); + + if (propagation) + { + DisableVisualElementPropagation(propagation); + } + if (disable) + { + DisableImplicitAnimation(disable); + } + + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set show state."); + } + + // for layout + __pControlImpl->SetBoundsAndUpdateLayout(__pControlImpl->GetBounds()); + + pAnimationGroup->SetDuration(groupDuration); + r = __pVisualElement->AddAnimation(animIdentifier, *pAnimationGroup); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start group animation."); + + delete pAnimationGroup; + return r; + +CATCH: + //check clean up + delete pAnimationGroup; + + if (DestroyAnimation(activeAnimationCount) != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to deallocate memory."); + return E_SYSTEM; + } + + return r; +} + +result +_ControlAnimatorImpl::DisableImplicitAnimation(bool& state) +{ + bool enable = __pVisualElement->IsImplicitAnimationEnabled(); + __pVisualElement->SetImplicitAnimationEnabled(state); + state = enable; + + return E_SUCCESS; +} + +result +_ControlAnimatorImpl::DisableVisualElementPropagation(bool& state) +{ + bool propagate = _VisualElementImpl::GetInstance(*__pVisualElement)->GetPropertyPropagationEnabled(); + result r = _VisualElementImpl::GetInstance(*__pVisualElement)->SetPropertyPropagationEnabled(state); + state = propagate; + + return r; +} + +void +_ControlAnimatorImpl::OnTickOccurred(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, const Variant& currentValue) +{ + VisualElementValueAnimation* pAnimation = dynamic_cast< VisualElementValueAnimation* >(const_cast< VisualElementAnimation* >(&animation)); + VisualElement* pPresentation = const_cast< VisualElement* >(target.AcquirePresentationInstance()); + + if (pPresentation && pAnimation) + { + float diffX = 0.0f; + float diffY = 0.0f; + + if (!pAnimation->IsEndValueApplied() && (__isAnimationTargetAnimating[ANIMATION_TARGET_POSITION])) + { + diffX = pPresentation->GetBounds().x + currentValue.ToFloatRectangle().x - __presentationBounds.x; + diffY = pPresentation->GetBounds().y + currentValue.ToFloatRectangle().y - __presentationBounds.y; + } + else + { + diffX = pPresentation->GetBounds().x; + diffY = pPresentation->GetBounds().y; + } + + Variant newBounds(FloatRectangle(diffX, diffY, currentValue.ToFloatRectangle().width, currentValue.ToFloatRectangle().height)); + _VisualElementImpl::GetInstance(*pPresentation)->SetProperty(VePropBounds, newBounds); + } + else + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get presentation instance of visual element."); + } + + target.ReleasePresentationInstance(); +} +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_ControlAnimatorImpl.h b/src/ui/animations/FUiAnim_ControlAnimatorImpl.h new file mode 100644 index 0000000..afc7e3a --- /dev/null +++ b/src/ui/animations/FUiAnim_ControlAnimatorImpl.h @@ -0,0 +1,924 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_ControlAnimatorImpl.h + * @brief Header file of _ControlAnimatorImpl class + * + * This file contains declarations _ControlAnimatorImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_CONTROL_ANIMATOR_IMPL_H_ +#define _FUI_ANIM_INTERNAL_CONTROL_ANIMATOR_IMPL_H_ + +#include +#include +#include +#include +#include + +#include "FUi_ControlImpl.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ +class VisualElement; +class BezierTimingFunction; + +/** + * @enum AnimationFormPosition + * Defines the Form's position, either current or Next Form + * @since 2.0 + */ +enum AnimationFormPosition +{ + ANIMATION_FORM_POSITION_CURRENT_FORM = 0, /**< Current Form*/ + ANIMATION_FORM_POSITION_NEXT_FORM /**< Next Form */ +}; + +enum StoredPropertyAnimationGroupType +{ + PROPERTY_ANIMATION_GROUP_TYPE_NONE, + PROPERTY_ANIMATION_GROUP_TYPE_PARALLEL, + PROPERTY_ANIMATION_GROUP_TYPE_SEQUENTIAL +}; + +#define INTERPOLATOR_LINEAR L"Linear" +#define INTERPOLATOR_EASEIN L"EaseIn" +#define INTERPOLATOR_EASEOUT L"EaseOut" +#define INTERPOLATOR_EASEINOUT L"EaseInOut" +#define INTERPOLATOR_DISCRETE L"Discrete" +#define INTERPOLATOR_BEZIER L"Bezier" + + +/** + * @class _ControlAnimatorImpl + * @brief This class defines the animation API for Control + * @since 2.0 + * + * The %_ControlAnimatorImpl class is used to control the animations operated on Tizen::UiControls + * + */ +class _ControlAnimatorImpl + : public Tizen::Base::Object + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , public Tizen::Ui::Animations::IVisualElementAnimationTickEventListener +{ +public: + /** + * Destructor for %_ControlAnimatorImpl class. + * + * @since 2.0 + */ + ~_ControlAnimatorImpl(void); + + /** + * Default constructor for %_ControlAnimatorImpl class. + * + * @since 2.0 + */ + _ControlAnimatorImpl(ControlAnimator* pAnimator); + + /** + * Initializes this %_ControlAnimatorImpl class. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance has already been constructed. + * @exception E_OUT_OF_MEMORY Insufficient memory. + * @exception E_SYSTEM System error occurred. + */ + result Construct(const Control& control); + + /** + * Adds the %Animation to the ActiveAnimation List. + * + * @since 2.0 + * @return An error code + * @param[in] animTarget %AnimationTarget + * @param[in] animBase An object of %AnimationBase + * @param[in] animNative An object of _Animation + * @param[in] triggerType Trigger type + * @param[in] animName Animation name (unique Id) + * @param[in] pBezierTiming Bezier timing function. + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result AddActiveAnimation(AnimationTargetType animTarget, AnimationBase& animBase, Tizen::Ui::Animations::VisualElementAnimation& animNative, ControlAnimatorTriggerType triggerType, const Tizen::Base::String& animName, BezierTimingFunction* pBezierTiming); + + /** + * This is the copy constructor for this class. + * + * @since 2.0 + * @param[in] animator Object to be copied + */ + _ControlAnimatorImpl(const _ControlAnimatorImpl& rhs); + + /** + * Gets the %Animation Name from the ActiveAnimation List attached against specified %AnimationTarget. + * + * @since 2.0 + * @return Animation name + * @param[in] index Value at the index to be retrieved + */ + Tizen::Base::String GetActiveAnimationAt(int index) const; + + /** + * Gets the %Animation from the ActiveAnimation List attached against specified %AnimationTarget. + * + * @since 2.0 + * @return Animation Name + * @param[in] index Value at the index to be retrieved + * @param[in] animTrigger %ControlAnimatorTriggerType + */ + Tizen::Base::String GetActiveAnimationAt(int index, ControlAnimatorTriggerType animTrigger) const; + + /** + * Destroys the %Animation Name from the ActiveAnimation List after the specified %index + * + * @since 2.0 + * @return An error code + * @param[in] preActiveAnimationCount ActiveAnimationCount + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result DestroyAnimation(int preActiveAnimationCount); + + /** + * Destroys the %Animation from the ActiveAnimation List after the specified %index + * + * @since 2.0 + * @return An error code + * @param[in] animTarget AnimationTargetType + * @param[in] pAnimBase An object of %AnimationBase + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result DestroyAnimation(AnimationBase& animBase, AnimationTargetType animTarget); + + /** + * Gets the ActiveAnimation Count of type the ANimationTarget + * + * @since 2.0 + * @return Total number of ActiveAnimations added to the list + */ + int GetActiveAnimationListCount(AnimationTargetType animTarget) const; + + /** + * Gets the ActiveAnimation Count value + * + * @since 2.0 + * @return Total number of ActiveAnimations added to the list + */ + int GetActiveAnimationListCount(void) const; + + /** + * Removes the %Animation from the ActiveAnimation List at specified index. + * + * @since 2.0 + * @return An error code + * @param[in] index Values at the index to be retrieved + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result RemoveAnimationAt(int index); + + /** + * Removes all the %Animation from the ActiveAnimation List. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result RemoveAllAnimations(void); + + /** + * Sets an %Animation to a internal Layer. + * + * @since 2.0 + * @return An error code + * @param[in] animTarget Property to be animated. + * @param[in] animationBase An object of type %AnimationBase. + * @param[in] animType ControlAnimatorTriggerType + * @param[in] pAnimGroup Animation Group object for sequence and parallel group animation + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified parameter is invalid. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. + * @exception E_SYSTEM A system error occurred. + * + */ + result SetAnimation(AnimationTargetType animTarget, AnimationBase& animationBase, ControlAnimatorTriggerType animType = ANIMATION_TRIGGER_USER, VisualElementAnimationGroup* pAnimGroup = null); + + /** + * Returns a copy of %AnimationBase object. + * + * @since 2.0 + * @return An error code + * @param[in] animTarget Property to be animated. + * @param[in] animationBase An object of type %AnimationBase whose copy is to be created + * @exception null If the passed argument is invalid. + */ + AnimationBase* CloneAnimation(AnimationTargetType animTarget, AnimationBase& animationBase); + + /** + * Sets the property of the object with specified input + * + * @since 2.0 + * @return An error code + * @param[in] animTarget Enumeration of animation target type + * @param[in] animationBase An instance of %AnimationBase object + */ + result SetControlProperty(AnimationTargetType animTarget, AnimationBase& animationBase); + + /** + * Checks for the property change is valid on a control + * + * @since 2.0 + * @return An error code + * @param[in] animTarget Enumeration of animation target type + * @param[in] rect Bounds of a %Control + * @param[in] pAnimationBase Animation base object + * @param[in] animTrigger Animation trigger type + * @remarks %This function returns whether property is changeable or not. @n + * If @c true, property can be changed. @n + * If @c false, property cannot be changed. + */ + bool IsAnimatable(AnimationTargetType animTarget, Tizen::Graphics::Rectangle& rect, AnimationBase* pAnimationBase = null + , ControlAnimatorTriggerType animTrigger = ANIMATION_TRIGGER_USER) const; + + /** + * Starts the custom implicit %animation + * + * @since 2.0 + * @return An error code + * @param[in] animTrigger %AnimationTriggerType + * @param[in] x x position of control + * @param[in] y y position of control + * @param[in] width width of control + * @param[in] height height of control + * @param[in] showState showState of Control + * + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result StartCustomImplicitAnimation(ControlAnimatorTriggerType triggerType, int x, int y, int width, int height, bool showState); + + /** + * Sets the Custom Implicit Animation parameters + * + * @since 2.0 + * @return An error code + * @param[in] triggerType %AnimationTriggerType + * @param[in] animationBase %AnimationBase object + * @param[in] bounds %Bounds of the %Control overwritten with corresponding new custom animation values + * @param[in] showState %showState of the %Control overwritten with corresponding new custom animation values + * @param[in] lastTargetOccurence variable to find whether the Animation attached against the equivalent AnimationTarget is the last one in the list or not + * + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result SetCustomImplicitAnimationParams(ControlAnimatorTriggerType triggerType, AnimationBase& animationBase, Tizen::Graphics::Rectangle& bounds, bool showState, bool lastTargetOccurence = false); + /** + * returns whether animation supported by underlying platform or not + * + * @since 2.0 + * @return An error code + * @remarks %This function returns whether animation is supported or not. @n + * If @c true, animation supported. @n + * If @c false, animation not supported. + */ + bool IsAnimationSupported(void) const; + + /** + * Sets the property of the Control with specified input + * + * @since 2.0 + * @return An error code + * @param[in] animTarget Enumeration of animation target type + * @param[in] animationBase An instance of %AnimationBase object + */ + result SetControlLogicalBounds(AnimationTargetType animTarget, AnimationBase& animationBase); + + /** + * Sets the property of the Control with specified input + * + * @since 2.0 + * @return An error code + * @param[in] animTarget Enumeration of animation target type + * @param[in] animationBase An instance of %AnimationBase object + */ + result SetControlShowState(AnimationTargetType animTarget, AnimationBase& animationBase); + + /** + * This function will be called to Stop All Animations + * + * @since 2.0 + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result StopAllAnimations(void); + + /** + * This function will be called to Stop an animation based on trigger type + * + * @since 2.0 + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result StopAnimation(ControlAnimatorTriggerType animTrigger); + + /** + * Delete & frees the memory used by the object + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM Failed to free the resource possessed by this instance. + */ + result Dispose(void); + + /** + * Adds the Control animator event listener to the listeners list. + * + * @since 2.0 + * @return An error code + * @param[in] listener Control animator event listener + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result AddControlAnimatorEventListener(const IControlAnimatorEventListener& listener); + + + /** + * Removes the Control animator event listener from the listeners list. + * + * @since 2.0 + * @return An error code + * @param[in] listener Control animator event listener + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result RemoveControlAnimatorEventListener(const IControlAnimatorEventListener& listener); + + /** + * Adds the Control detailed animator event listener to the listeners list. + * + * @since 2.0 + * @return An error code + * @param[in] listener Control animator event listener + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result AddControlAnimatorDetailedEventListener(const IControlAnimatorDetailedEventListener& listener); + + /** + * Removes the Detailed Control animator event listener from the listeners list. + * + * @since 2.0 + * @return An error code + * @param[in] listener Control animator event listener + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result RemoveControlAnimatorDetailedEventListener(const IControlAnimatorDetailedEventListener& listener); + /** + * Returns animation Index based on animation name. + * + * @since 2.0 + * @return Animation index in the active animation list + * @param[in] animName unique name of animation + */ + int GetActiveAnimationIndex(const Tizen::Base::String& animName) const; + + /** + * Sets the Bounds property of the object with specified input + * + * @return An error code + * @param[in] animTarget Enumeration of animation target type + * @param[in] animationBase An instance of %AnimationBase object + */ + result SetPrevAnimationBoundsProperty(AnimationTargetType animTarget, AnimationBase& animationBase); + /** + * Sets animation target status + * + * @since 2.0 + * @return An error code + * @param[in] triggerType Control animator trigger type + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result SetAnimationTargetStatus(ControlAnimatorTriggerType triggerType); + + /** + * Sets animation target status + * + * @since 2.0 + * @return An error code + * @param[in] animTarget Control animator Target type + * @param[in] pAnimationBase Animation Base object + * @param[in] pTimingFunction Timing function ex: Linear + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result SetKeyFrameAnimation(AnimationTargetType animTarget, AnimationBase* pAnimationBase, const IVisualElementAnimationTimingFunction* pTimingFunction, VisualElementAnimation* pAnimation); + + /** + * Sets animation target status + * + * @since 2.0 + * @return An error code + * @param[in] animGroup Animation Group object. + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result SetGroupAnimation(AnimationGroup* pAnimGrp); + + /** + * Disables / Enables Propagation of properties from model layer to presentation layer + * + * @since 2.0 + * @return An error code + * @param[in] state true or false + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result DisableImplicitAnimation(bool& state); + + /** + * Disables / Enables Implicit animation at Visual element + * + * @since 2.0 + * @return An error code + * @param[in] state true or false + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result DisableVisualElementPropagation(bool& state); + + /** + * Returns the stored logical bounds. + * + * @since 2.0 + * @return Logical bounds + */ + Tizen::Graphics::Rectangle + GetLogicalBounds(void) const + { + return __logicalBoundsHolder; + } + + /** + * Sets logical bounds. + * + * @since 2.0 + * @return void + * @param[in] rectangle Logical bounds + */ + void + SetLogicalBounds(Tizen::Graphics::Rectangle rect) + { + __logicalBoundsHolder = rect; + } + + /** + * Returns the Animation type for a given trigger type + * + * @since 2.0 + * @param[in] triggerType trigger for animation + * Allowed values ANIMATION_TRIGGER_POSITION_CHANGE-1 to ANIMATION_TRIGGER_SHOW_STATE_CHANGE-1 + * ANIMATION_TRIGGER_POSITION_CHANGE = 1, //Stored at index 0 [NONE (or) PARALLEL (or) SEQUENTIAL] + * ANIMATION_TRIGGER_SIZE_CHANGE = 2, //Stored at index 1 [NONE (or) PARALLEL (or) SEQUENTIAL] + * ANIMATION_TRIGGER_SHOW_STATE_CHANGE = 3, //Stored at index 2 [NONE (or) PARALLEL (or) SEQUENTIAL] + * + * @return Animation type [NONE (or) PARALLEL (or) SEQUENTIAL] + */ + StoredPropertyAnimationGroupType + GetStoredPropertyAnimationGroupType(int triggerType) const + { + return __propertyAnimationGroupType[triggerType]; + } + + /** + * Sets logical bounds. + * + * @since 2.0 + * @return void + * @param[in] triggerType + * Allowed values ANIMATION_TRIGGER_POSITION_CHANGE-1 to ANIMATION_TRIGGER_SHOW_STATE_CHANGE-1 + * ANIMATION_TRIGGER_POSITION_CHANGE = 1, //Stored at index 0 + * ANIMATION_TRIGGER_SIZE_CHANGE = 2, //Stored at index 1 + * ANIMATION_TRIGGER_SHOW_STATE_CHANGE = 3, //Stored at index 2 + * @param[in] animationType Type of animation [NONE (or) PARALLEL (or) SEQUENTIAL] + */ + void + SetStoredPropertyAnimationGroupType(int triggerType, StoredPropertyAnimationGroupType groupType) + { + __propertyAnimationGroupType[triggerType] = groupType; + } + + /** + * Returns group of animations for a particular trigger type + * + * @since 2.0 + * @param[in] triggerType + * Allowed values ANIMATION_TRIGGER_POSITION_CHANGE-1 to ANIMATION_TRIGGER_SHOW_STATE_CHANGE-1 + * ANIMATION_TRIGGER_POSITION_CHANGE = 1, //Stored at index 0 + * ANIMATION_TRIGGER_SIZE_CHANGE = 2, //Stored at index 1 + * ANIMATION_TRIGGER_SHOW_STATE_CHANGE = 3, //Stored at index 2 + * @return Returns group of animations for a particular trigger type + */ + AnimationGroup* + GetPropertyGroupList(int triggerType) const + { + return __pPropertyAnimationGroupList[triggerType]; + } + + /** + * Sets animation group to a trigger type + * + * @since 2.0 + * @param[in] triggerType + * + * Allowed values ANIMATION_TRIGGER_POSITION_CHANGE-1 to ANIMATION_TRIGGER_SHOW_STATE_CHANGE-1 + * ANIMATION_TRIGGER_POSITION_CHANGE = 1, //Stored at index 0 + * ANIMATION_TRIGGER_SIZE_CHANGE = 2, //Stored at index 1 + * ANIMATION_TRIGGER_SHOW_STATE_CHANGE = 3, //Stored at index 2 + * @return void + */ + void + SetPropertyGroupList(int triggerType, AnimationGroup* animGroup) + { + __pPropertyAnimationGroupList[triggerType] = animGroup; + } + + /** + * Returns the show state of control + * + * @since 2.0 + * @return Returns the show state of control + */ + bool GetShowState(void) const + { + return __showStateHolder; + } + + /** + * Stores show state + * + * @since 2.0 + * @return void + * @param[in] showState Show state + */ + void + SetShowState(bool showState) + { + __showStateHolder = showState; + } + + /** + * Returns the state of control animator (playing/stopped) + * + * @since 2.0 + * @return State of control animator (playing/stopped) + */ + AnimatorStatus + GetAnimatorStatus(void) const + { + return __animatorStatus; + } + + /** + * Stores whether a target is animating or not + * + * @since 2.0 + * @return void + * @param[in] animatorStatus State of control animator (playing/stopped) + */ + void + SetAnimatorStatus(AnimatorStatus animatorStatus) + { + __animatorStatus = animatorStatus; + } + + /** + * Stores whether a target is animating or not + * + * @since 2.0 + * @return void + * @param[in] target Target type + * @param[in] animating or not animating + */ + void + SetAnimationTargetAnimating(int target, bool animating) + { + __isAnimationTargetAnimating[target] = animating; + } + + /** + * Returns the whether the animation target is animating + * + * @since 2.0 + * @return Animation target is currently animating or not + */ + bool + IsAnimationTargetAnimating(int target) const + { + return __isAnimationTargetAnimating[target]; + } + + /** + * Returns reference to control + * + * @since 2.0 + * @return Reference to control + */ + Control& + GetControl(void) const + { + return *__pControl; + } + + /** + * Stores control pointer + * + * @since 2.0 + * @return void + * @param[in] control Reference to the control + */ + void + SetControl(Control& control) + { + __pControl = &control; + } + + /** + * This function will be called when the animation is started. + * + * @since 2.0 + * @param[in] target UIObject that animation is applied to. + * @param[in] animation Animation that is started. + */ + void OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const Tizen::Base::String& keyName, VisualElement& target); + + /** + * This function will be called when the animation is repeated. + * + * @since 2.0 + * @param[in] target UIObject that animation is applied to. + * @param[in] animation Animation that is repeated. + * @param[in] currentRepeatCount repeat count + */ + void OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const Tizen::Base::String& keyName, VisualElement& target, long currentRepeatCount); + + /** + * This function will be called when the animation is stopped. + * + * @since 2.0 + * @param[in] target UIObject that animation is applied to. + * @param[in] animation Animation that is stopped. + * @param[in] completed Whether animation is completed normally or canceled in the middle of running. + */ + void OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const Tizen::Base::String& keyName, VisualElement& target, bool completedNormally); + + /** + * This function will be called when the animation is stopped. + * + * @since 2.0 + * @param[in] animation Visual Element animation. + * @param[in] keyName Animation name. + * @param[in] currentValue Current value of animation. + */ + void OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue); + + /** + * This is the assignment operator implementation for this class. @n + * + * @since 2.0 + */ + _ControlAnimatorImpl& operator =(const _ControlAnimatorImpl& rhs); + +private: + /** + * Structure used for storing Active Animations + * + * @since 2.0 + * @enum struct + * + */ + struct ActiveAnimation + { + ControlAnimatorTriggerType animType; + AnimationTargetType animTarget; + AnimationBase* pAnimationBase; + VisualElementAnimation* pAnimation; + Tizen::Base::String animName; + Tizen::Ui::Animations::BezierTimingFunction* pBezierTimingFunction; + + ActiveAnimation(void) + { + animTarget = ANIMATION_TARGET_NONE; + animType = ANIMATION_TRIGGER_USER; + pAnimationBase = null; + pAnimation = null; + animName = Tizen::Base::String(""); + pBezierTimingFunction = null; + } + ~ActiveAnimation(void) + { + + } + bool operator ==(const ActiveAnimation& rhs) const; + bool operator !=(const ActiveAnimation& rhs) const; + }; + /** + * The List maintaining the Active Animations + * + * @since 2.0 + */ + Tizen::Base::Collection::ArrayListT< ActiveAnimation >* __pActiveAnimationList; + + /** + * This is the object of control. + * + * @since 2.0 + */ + //TODO: @remark: This object need not be deleted in ControlAnimator scope + Tizen::Ui::Control* __pControl; + + /** + * This is the object _ControlImpl. + * + * @since 2.0 + */ + //TODO: @remark: This object need not be deleted in ControlAnimator scope + Tizen::Ui::_ControlImpl* __pControlImpl; + /** + * The animation status (play / stopped) + * + * @since 2.0 + */ + AnimatorStatus __animatorStatus; + + /** + * PROPERTY_GROUP_TYPE_NONE if the __pPropertyAnimationGroupList is not populated with user defined custom defined implicit animations + * + * @since 2.0 + * ANIMATION_TRIGGER_POSITION_CHANGE = 1, //Stored at index 0 [NONE (or) PARALLEL (or) SEQUENTIAL] + * ANIMATION_TRIGGER_SIZE_CHANGE = 2, //Stored at index 1 [NONE (or) PARALLEL (or) SEQUENTIAL] + * ANIMATION_TRIGGER_SHOW_STATE_CHANGE = 3, //Stored at index 2 [NONE (or) PARALLEL (or) SEQUENTIAL] + */ + StoredPropertyAnimationGroupType __propertyAnimationGroupType[ANIMATION_TRIGGER_SHOW_STATE_CHANGE]; + + /** + * This is the object of AnimationGroup. + * + * @since 2.0 + * ANIMATION_TRIGGER_POSITION_CHANGE = 1, //Stored at index 0 [NONE (or) PARALLEL (or) SEQUENTIAL] + * ANIMATION_TRIGGER_SIZE_CHANGE = 2, //Stored at index 1 [NONE (or) PARALLEL (or) SEQUENTIAL] + * ANIMATION_TRIGGER_SHOW_STATE_CHANGE = 3, //Stored at index 2 [NONE (or) PARALLEL (or) SEQUENTIAL] + * + * @remarks The array size should be changed if anything is added to ControlAnimationTriggerType. + */ + Tizen::Ui::Animations::AnimationGroup* __pPropertyAnimationGroupList[ANIMATION_TRIGGER_SHOW_STATE_CHANGE]; + /** + * Array of bool to keep track whether an %AnimationTarget is being animated or not. + * + * @since 2.0 + * ANIMATION_TARGET_SIZE at index - 0 + * ANIMATION_TARGET_POSITION at index - 1 + * ANIMATION_TARGET_ALPHA at index - 2 + * ANIMATION_TARGET_ORIENTATION at index - 3 + */ + bool __isAnimationTargetAnimating[ANIMATION_TARGET_MAX]; + + /** + * LogicalBounds Holder + * + * @since 2.0 + */ + Tizen::Graphics::Rectangle __logicalBoundsHolder; + + /** + * showState Holder + * + * @since 2.0 + */ + bool __showStateHolder; + + /** + * Holder for number of animations of same TargetType in AnimationGroupSequential + * + * @since 2.0 + */ + int __targetCount; + + /** + * LogicalBounds Holder + * + * @since 2.0 + */ + Tizen::Graphics::Rectangle __prevAnimationBoundsHolder; + + /** + * sequentialGroupAnimation or parallel Animation group + * + * @since 2.0 + */ + bool __sequentialGroupAnimation; + + /** + * sequentialGroupAnimation delay + * + * @since 2.0 + */ + float __sequelDelay; + + + /** + * This is object of ControlAnimator class + * + * @since 2.0 + */ + Tizen::Ui::Animations::ControlAnimator* __pControlAnimator; + + /** + * This is object of ControlAnimator class + * + * @since 2.0 + */ + Tizen::Ui::Animations::VisualElement* __pVisualElement; + + /** + * This is the list controlanimator event listeners + * + * @since 2.0 + */ + Tizen::Base::Collection::LinkedListT< IControlAnimatorEventListener* >* __pAnimStatusEventListener; + + /** + * This is the list controlanimator event listeners + * + * @since 2.0 + */ + Tizen::Base::Collection::LinkedListT< IControlAnimatorDetailedEventListener* >* __pAnimDetailedEventListener; + + /** + * This is Id or each animation + * + * @since 2.0 + */ + int __animId; + /** + * This is name for group animation + * + * @since 2.0 + */ + Tizen::Base::String __groupName; + /** + * This is to hold presentation bounds + * + * @since 2.0 + */ + Tizen::Graphics::FloatRectangle __presentationBounds; + + friend class Tizen::Ui::Control; +}; // _ControlAnimatorImpl + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_CONTROL_ANIMATOR_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_ControlVisualElement.cpp b/src/ui/animations/FUiAnim_ControlVisualElement.cpp new file mode 100644 index 0000000..d7a76fa --- /dev/null +++ b/src/ui/animations/FUiAnim_ControlVisualElement.cpp @@ -0,0 +1,343 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_ControlVisualElement.cpp + * @brief This file contains implementation of _ControlVisualElement class + * + * This file contains implementation _ControlVisualElement class. + */ + +#include + +#include "FUiAnim_EflNode.h" +#include "FUiAnim_ControlVisualElement.h" +#include "FUiAnim_VisualElementImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +//IMPLEMENT_PROPERTY(_ControlVisualElement); + +_ControlVisualElement::_ControlVisualElement(void) + : __autoResize(false) +{ + +} + +_ControlVisualElement::~_ControlVisualElement(void) +{ +} + +VisualElement* +_ControlVisualElement::CloneN(void) const +{ + return new (std::nothrow) _ControlVisualElement(*this); +} + +_ControlVisualElement::_ControlVisualElement(const _ControlVisualElement& rhs) + : _VisualElement(rhs) + , __autoResize(rhs.__autoResize) +{ +} + +result +_ControlVisualElement::ConstructControlVisualElement(void) +{ + result r = VisualElement::Construct(); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Propagating."); + + _pVisualElementImpl->SetZOrderGroup(Z_ORDER_GROUP_CONTROL); + + SetImplicitAnimationEnabled(false); + + return r; +} + +_ControlVisualElement* +_ControlVisualElement::__GetControlChildAtPoint(Tizen::Graphics::FloatPoint& point, int parentHitTest) +{ + _ControlVisualElement* pHitTarget = null; + Tizen::Graphics::FloatPoint hitPoint = point; + int hitTest = _pVisualElementImpl->InvokeHitTest(point); + if ((hitTest & _VisualElementImpl::HITTEST_MATCH) != 0) + { + // passed hittest + pHitTarget = this; +#if 0 + // this passed hittest, but not parent --> clipped out by parent + if (GetParent() && IsClipToParent()) + { + if ((parentHitTest & HITTEST_MATCH) == 0) + pHitTarget = null; + } +#endif + } + + if ((hitTest & _VisualElementImpl::HITTEST_NOMORECHILDREN) == 0) + { + int count = _pVisualElementImpl->__children.GetCount(); + for (int i = count - 1; i >= 0; i--) // from top to bottom + { + // Skip non-ControlVisualElement + _VisualElementImpl* pTemp = _pVisualElementImpl->__children.GetChildAt(i); + _ControlVisualElement* pChild = null; + if (!pTemp) + { + continue; + } + + pChild = dynamic_cast< _ControlVisualElement* >(pTemp->GetPublic()); + if (!pChild) + { + continue; + } + + Tizen::Graphics::FloatPoint childHitPoint = point; + + pChild->ConvertCoordinates(childHitPoint, this); + + _ControlVisualElement* pChildHitTarget = pChild->__GetControlChildAtPoint(childHitPoint, hitTest); + if (pChildHitTarget) + { + pHitTarget = pChildHitTarget; + hitPoint = childHitPoint; + break; + } + } + } + + + if (pHitTarget) + { + point = hitPoint; + return pHitTarget; + } + + return null; +} + +// WARNING: +// Because Hit-Testing from self, clipping flags of self will be ignored. +_ControlVisualElement* +_ControlVisualElement::GetControlChildAtPoint(Tizen::Graphics::FloatPoint& point) +{ + _ControlVisualElement* pHitTarget = __GetControlChildAtPoint(point, _VisualElementImpl::HITTEST_MATCH); + + if (!pHitTarget) + { + SetLastResult(E_OBJ_NOT_FOUND); // TBD: error code + } + else + { + ClearLastResult(); + } + return pHitTarget; +} + +bool +_ControlVisualElement::IsAutoResizeChildrenEnabled(void) const +{ + return __autoResize; +} + +result +_ControlVisualElement::SetAutoResizeChildrenEnabled(bool autoResize) +{ + ClearLastResult(); + + __autoResize = autoResize; +// _ControlVisualElement* pVisualElement = dynamic_cast< _ControlVisualElement* >(__pPresentation->__pPublicInstance); +// pVisualElement->__autoResize = autoResize; + + return E_SUCCESS; +} + +Variant +_ControlVisualElement::OnGetPropertyRequested(const Tizen::Base::String& property) const +{ + if (property == *pVePropBounds) + { + return _PropGetControlBounds(); + } + else if (property == *pVePropImplicitAnimationEnabled) + { + return _PropGetControlImplicitAnimationEnabled(); + } + else if (property == *pVePropPropertyPropagationEnabled) + { + return _PropGetControlPropertyPropagationEnabled(); + } + + return VisualElement::OnGetPropertyRequested(property); +} + +result +_ControlVisualElement::OnSetPropertyRequested(const Tizen::Base::String& property, const Variant& value) +{ + if (property == *pVePropBounds) + { + return _PropSetControlBounds(value); + } + else if (property == *pVePropImplicitAnimationEnabled) + { + return _PropSetControlImplicitAnimationEnabled(value); + } + else if (property == *pVePropPropertyPropagationEnabled) + { + return _PropSetControlPropertyPropagationEnabled(value); + } + + return VisualElement::OnSetPropertyRequested(property, value); +} + +Variant +_ControlVisualElement::_PropGetControlBounds(void) const +{ + return _VisualElementImpl::GetInstance(*this)->GetBoundsProperty(); +} + +result +_ControlVisualElement::_PropSetControlBounds(const Variant& v) +{ + result r = _VisualElementImpl::GetInstance(*this)->SetBoundsProperty(v); + SysTryReturnResult(NID_UI_ANIM, !IsFailed(r), r,"Can't set bounds for control VisualElement."); + + if (__autoResize) + { + Tizen::Base::Collection::IList* pList = GetChildrenN(); + if (!pList) + { + return E_SYSTEM; + } + + Tizen::Graphics::FloatRectangle clientBounds = v.ToFloatRectangle(); + clientBounds.x = 0.0f; + clientBounds.y = 0.0f; + + for (int i = 0; i < pList->GetCount(); i++) + { + _ControlVisualElement* pChild = dynamic_cast< _ControlVisualElement* >(pList->GetAt(i)); + if (pChild) + { + pChild->SetBounds(clientBounds); + } + } + + if (pList->GetCount() > 2) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid control state(root/system/client)"); + } + + delete pList; + } + + return E_SUCCESS; +} + +Variant +_ControlVisualElement::_PropGetControlImplicitAnimationEnabled(void) const +{ + return _VisualElementImpl::GetInstance(*this)->GetImplicitAnimationProperty(); +} + +result +_ControlVisualElement::_PropSetControlImplicitAnimationEnabled(const Variant& v) +{ + result r = _VisualElementImpl::GetInstance(*this)->SetImplicitAnimationProperty(v); + SysTryReturnResult(NID_UI_ANIM, !IsFailed(r), r, "Can't enable or diable implicit animation for control VisualElement."); + + if (__autoResize) + { + Tizen::Base::Collection::IList* pList = GetChildrenN(); + if (!pList) + { + return E_SYSTEM; + } + + bool enable = v.ToBool(); + + for (int i = 0; i < pList->GetCount(); i++) + { + _ControlVisualElement* pChild = dynamic_cast< _ControlVisualElement* >(pList->GetAt(i)); + if (pChild) + { + pChild->SetImplicitAnimationEnabled(enable); + } + } + + if (pList->GetCount() > 2) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid control state(root/system/client)"); + } + + delete pList; + } + + return E_SUCCESS; +} + +Variant +_ControlVisualElement::_PropGetControlPropertyPropagationEnabled(void) const +{ + return _VisualElementImpl::GetInstance(*this)->GetPropertyPropagationProperty(); +} + +result +_ControlVisualElement::_PropSetControlPropertyPropagationEnabled(const Variant& v) +{ + result r = _VisualElementImpl::GetInstance(*this)->SetPropertyPropagationProperty(v); + SysTryReturnResult(NID_UI_ANIM, !IsFailed(r), r, "Can't enable or diable property propagation for control VisualElement."); + + if (__autoResize) + { + Tizen::Base::Collection::IList* pList = GetChildrenN(); + if (!pList) + { + return E_SYSTEM; + } + + bool enable = v.ToBool(); + + for (int i = 0; i < pList->GetCount(); i++) + { + _ControlVisualElement* pChild = dynamic_cast< _ControlVisualElement* >(pList->GetAt(i)); + if (pChild) + { + _VisualElementImpl::GetInstance(*pChild)->SetPropertyPropagationEnabled(enable); + } + } + + if (pList->GetCount() > 2) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid control state(root/system/client)"); + } + + delete pList; + } + + return E_SUCCESS; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_ControlVisualElement.h b/src/ui/animations/FUiAnim_ControlVisualElement.h new file mode 100644 index 0000000..85d53f9 --- /dev/null +++ b/src/ui/animations/FUiAnim_ControlVisualElement.h @@ -0,0 +1,130 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_ControlVisualElement.h + * @brief Header file of _ControlVisualElement class + * + * This file contains declarations _ControlVisualElement class. + */ + +#ifndef _FUI_ANIM_INTERNAL_CONTROL_VISUAL_ELEMENT_H_ +#define _FUI_ANIM_INTERNAL_CONTROL_VISUAL_ELEMENT_H_ + +#include "FUiAnim_VisualElement.h" +#include "FUi_Colorf.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _ControlVisualElement + : public _VisualElement +{ +#if 0 + DECLARE_CLASS_BEGIN(_ControlVisualElement, _VisualElementImpl); + DECLARE_PROPERTY(VePropBounds, _PropGetControlBounds, _PropSetControlBounds); + DECLARE_PROPERTY(VePropImplicitAnimationEnabled, _PropGetControlImplicitAnimationEnabled, _PropSetControlImplicitAnimationEnabled); + DECLARE_PROPERTY(VePropPropertyPropagationEnabled, _PropGetControlPropertyPropagationEnabled, _PropSetControlPropertyPropagationEnabled); + DECLARE_CLASS_END(); +#endif + +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _ControlVisualElement(void); + + + /** + * Initializes the instance of _ControlVisualElement. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS This method was successful. + * @exception E_SYSTEM A system error occurred. + */ + result ConstructControlVisualElement(void); + +protected: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ControlVisualElement(void); + + + _ControlVisualElement(const _ControlVisualElement& rhs); + +public: + /** + * Definition for VisualElement's ZOrder Group. + * Z_ORDER_GROUP_SYSTEM group has higher position then position of Z_ORDER_GROUP_ALWASY_ON_TOP group. + * @since 2.0 + */ + static const int Z_ORDER_GROUP_CONTROL = 2001; // the UI system use this level. (Control) + + /** + * Clones the instance of VisualElement. + * + * @since 2.0 + * @return The pointer to the cloned VisualElement instance. + */ + virtual VisualElement* CloneN(void) const; + + /** + * Gets the top-most child ControlVisualElement indicated by @c point. + * + * @since 2.0 + * @return the child ControlVisualElement indicated by point. + * @param[in] point The position to find the child ControlVisualElement. + */ + _ControlVisualElement* GetControlChildAtPoint(Tizen::Graphics::FloatPoint& point); + + + bool IsAutoResizeChildrenEnabled(void) const; + + result SetAutoResizeChildrenEnabled(bool autoResize); + + + virtual Variant OnGetPropertyRequested(const Tizen::Base::String& property) const; + + + virtual result OnSetPropertyRequested(const Tizen::Base::String& property, const Variant& value); + +private: + _ControlVisualElement* __GetControlChildAtPoint(Tizen::Graphics::FloatPoint& point, int parentHitTest); + + Variant _PropGetControlBounds(void) const; + result _PropSetControlBounds(const Variant& v); + + Variant _PropGetControlImplicitAnimationEnabled(void) const; + result _PropSetControlImplicitAnimationEnabled(const Variant& v); + + Variant _PropGetControlPropertyPropagationEnabled(void) const; + result _PropSetControlPropertyPropagationEnabled(const Variant& v); +private: + bool __autoResize; + +}; // _ControlVisualElement + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_CONTROL_VISUAL_ELEMENT_H_ + diff --git a/src/ui/animations/FUiAnim_Debug.cpp b/src/ui/animations/FUiAnim_Debug.cpp new file mode 100644 index 0000000..414f42a --- /dev/null +++ b/src/ui/animations/FUiAnim_Debug.cpp @@ -0,0 +1,1244 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_Debug.cpp + * @brief This file contains implementation of _VeDebug class + * + * This file contains implementation _VeDebug class. + */ + +#ifdef VE_DEBUG_MODULE +#include +#endif + +#include +#include +#include +#include +#include +#include + +#ifndef VE_SIMULATOR +#include +#include +#endif + +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_VisualElementSharedData.h" +#include "FUiAnim_VisualElementSurfaceImpl.h" +#include "FUiAnim_Debug.h" + +#ifdef VE_DEBUG_MODULE + +#ifndef VE_SIMULATOR +#include "FUi_ControlImpl.h" +#include "FUiCtrl_Label.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_Popup.h" +#endif + +#include "FUiAnim_EflNode.h" +#include "FUiAnim_AnimationManager.h" +#include "FUiAnim_DisplayManager.h" + +#include "FUi_EcoreEvas.h" +#include "FUi_EcoreEvasMgr.h" + + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Animations +{ + +#ifdef _OSP_PERF_ +int _ElapsedTime::depth = 0; +char _ElapsedTime::logs[500][256]; +int _ElapsedTime::maxdepth = 0; +int _ElapsedTime::count = 0; +#endif + +#define DIGITATPOSITION(number, digit) static_cast< int >((number % static_cast< int >(powf(10.0f, (digit)))) / powf(10.0f, (digit - 1))) + +bool _VeDebug::__veDebugEnabled = false; + +void +_VeDebug::SetDebugEnabled(bool enable) +{ + __veDebugEnabled = enable; +} + +bool +_VeDebug::IsDebugEnabled(void) +{ + return __veDebugEnabled; +} + +void +_VeDebug::DumpVisualElement(_VisualElementImpl* pElement, const char* func, int line, const char* fmt, ...) +{ + static int count = 0; + int len = 0; + int depth = 0; + int nativeVisible = -1; + _VisualElementImpl* pDepth = null; + _VisualElementImpl* pModel = null; + _VisualElementImpl* pPresentation = null; + char logPlaceMessage[LOG_LEN_MAX] = { 0, }; + char logMessage[LOG_LEN_MAX] = {0, }; + char logSpaces[LOG_LEN_MAX] = { 0, }; + va_list args; + + if (!pElement) + { + return; + } + + depth = -1; + pDepth = pElement; + while (pDepth) + { + depth++; + pDepth = pDepth->__pParent; + } + + if (pElement->GetModel() == pElement) // presenter + { + pModel = pElement->GetModel(); + pPresentation = pElement->GetPresentation(); + } + else + { + pModel = null; + pPresentation = pElement; + } + + if (pPresentation && pPresentation->__pSharedData->pNativeNode) + { + VisualElementSurface* pSurface = dynamic_cast< VisualElementSurface* >(pPresentation->__pSharedData->pNativeNode->GetSurface()); + if (pSurface && _VisualElementSurfaceImpl::GetInstance(*pSurface)) + { + nativeVisible = evas_object_visible_get(reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*pSurface)->GetNativeHandle())); + } + } + + if (func) + { + snprintf(logPlaceMessage, sizeof(logPlaceMessage), "(%s:%4d)", func, line); + } + + snprintf(logSpaces, sizeof(logSpaces), "%*s", depth * 3, " "); + + Tizen::Base::String name = pElement->GetSharedData().name; + +#ifndef VE_SIMULATOR + Tizen::Ui::_Control* pControl = null; + Tizen::Ui::_ControlImpl* pCtrlImpl = null; + + pControl = dynamic_cast< Tizen::Ui::_Control* >(static_cast< Tizen::Ui::_Control* >(pElement->GetUserData())); + if (pControl) + { + pCtrlImpl = dynamic_cast< Tizen::Ui::_ControlImpl* >(static_cast< Tizen::Ui::_ControlImpl* >(pControl->GetUserData())); + if (pCtrlImpl) + { + name = name + L", " + pCtrlImpl->GetPublicClassName(); + } + + Tizen::Ui::Controls::_Label* pLabel = null; + Tizen::Ui::Controls::_Edit* pEdit = null; + Tizen::Ui::Controls::_Button* pButton = null; + Tizen::Ui::Controls::_Popup* pPopup = null; + Tizen::Ui::Controls::Form* pForm = null; + Tizen::Ui::Controls::Header* pHeader = null; + Tizen::Ui::_Window* pWindow = null; + + pLabel = dynamic_cast< Tizen::Ui::Controls::_Label* >(pControl); + if (pLabel) + { + name = name + L", '" + pLabel->GetText() + L"'"; + } + + pEdit = dynamic_cast< Tizen::Ui::Controls::_Edit* >(pControl); + if (pEdit) + { + name = name + L", '" + pEdit->GetText() + L"'"; + } + + pButton = dynamic_cast< Tizen::Ui::Controls::_Button* >(pControl); + if (pButton) + { + name = name + L", '" + pButton->GetText() + L"'"; + } + + pPopup = dynamic_cast< Tizen::Ui::Controls::_Popup* >(pControl); + if (pPopup) + { + name = name + L", '" + pPopup->GetTitleText() + L"'"; + } + + pWindow = dynamic_cast< Tizen::Ui::_Window* >(pControl); + if (pWindow) + { + name = name + L", '_Window'"; + } + + pForm = dynamic_cast< Tizen::Ui::Controls::Form* >(pControl); + if (pForm) + { + name = name + L", '" + pForm->GetTitleText() + L"'"; + } + + pHeader = dynamic_cast< Tizen::Ui::Controls::Header* >(pControl); + if (pHeader) + { + name = name + L", '" + pHeader->GetTitleText() + L"'"; + } + } +#endif + + +#define TERMCOLOR_FMT //"%c[%d;%d;%dm" + + len = snprintf(logMessage, sizeof(logMessage), + TERMCOLOR_FMT "\n%4d = %2d%s:" TERMCOLOR_FMT "\n%s - [VE(%ls): 0x%08lx->0x%08lx]%s\n%s - [show:%s, %s, %d] [op=%.1f, %.1f, %.1f, %.1f] [%s] [0x%x, " + "0x%x, 0x%x %s=%p]\n%s - bounds=" VELOGRECTTAG " invRect=" VELOGRECTTAG " vRect=" VELOGRECTTAG, + /*0x1B, 1, 31, 10,*/ + count, depth, + (pElement != pElement->__pModel ? "P" : " "), + /*0x1B, 0, 0, 10,*/ + logSpaces, + name.GetPointer(), //(pElement->__pSharedData ? pElement->__pSharedData->name.GetPointer() : L" "), + (unsigned long) pModel, (unsigned long) pPresentation, + logPlaceMessage, + logSpaces, + (pElement->GetShowState() ? "show" : "hide"), (pElement->IsVisible() ? " visible" : "invisible"), nativeVisible, + pElement->__showOpacity, pElement->__opacity, pElement->__contentOpacity, pElement->GetOpacityFromRoot(), + (pElement->__pSharedData->pSurface ? " sfc" : "nosfc"), + pElement->__invalidatedProps, + pElement->__childrenNeedsUpdateProps, + pElement->__pSharedData->invalidatedNativeProps, (pElement->__isClipChildren ? "CS" : "NOCS"), + pElement->__pClipSource, + logSpaces, + VELOGRECT(pElement->__bounds), + VELOGRECT(pElement->__pSharedData->invalidatedRegion), + VELOGRECT(pElement->__visibleRect) + ); + +#undef TERMCOLOR_FMT + + va_start(args, fmt); + vsnprintf(&logMessage[len], sizeof(logMessage) - len, fmt, args); + va_end(args); + + //VeLog(NID_UI_ANIM, "%s", logMessage); + + + if (pElement == pPresentation && pElement->__pSharedData->pNativeNode) + { + _EflNode* pNativeNode = dynamic_cast< _EflNode* >(pPresentation->__pSharedData->pNativeNode); + if (pNativeNode) + { + Evas_Object* pEvasObject = null; + + if (pNativeNode->GetSurface() && _VisualElementSurfaceImpl::GetInstance(*pNativeNode->GetSurface())) + { + pEvasObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*pNativeNode->GetSurface())->GetNativeHandle()); + } + else + { + pEvasObject = pNativeNode->__pRectangleObject; + } + + if (pEvasObject) + { + int iw = 0; + int ih = 0; + int ox = 0; + int oy = 0; + int ow = 0; + int oh = 0; + int fx = 0; + int fy = 0; + int fw = 0; + int fh = 0; + int red = 0; + int green = 0; + int blue = 0; + int alpha = 0; + int argb = 0; + const char* eoType = evas_object_type_get(pEvasObject); + + if (!pElement->GetName().IsEmpty()) + { + ByteBuffer* pByteBuffer(Tizen::Base::Utility::StringUtil::StringToUtf8N(pElement->GetName())); + evas_object_name_set(pEvasObject, (const char*)pByteBuffer->GetPointer()); + delete pByteBuffer; + } + + + if (!strcmp(eoType, "image")) + { + if (evas_object_image_source_get(pEvasObject)) + { + evas_object_image_size_get(evas_object_image_source_get(pEvasObject), &iw, &ih); + } + else + { + evas_object_image_size_get(pEvasObject, &iw, &ih); + } + evas_object_image_fill_get(pEvasObject, &fx, &fy, &fw, &fh); + } + + evas_object_geometry_get(pEvasObject, &ox, &oy, &ow, &oh); + evas_object_color_get(pEvasObject, &red, &green, &blue, &alpha); + argb = (((alpha << 24) & 0xff000000) | ((red << 16) & 0x00ff0000) | ((green << 8) & 0x0000ff00) | (blue & 0x000000ff)); + bool showState = evas_object_visible_get(pEvasObject); + + len = strlen(logMessage); + snprintf(&logMessage[len], sizeof(logMessage) - len, "%s - type=%s[%p] bounds=[%d:%d ~ %d:%d] fill=[%d:%d ~ %d:%d] imgsize=[%d:%d] show=%s color=%08X", + logSpaces, evas_object_type_get(pEvasObject), pEvasObject, ox, oy, ox + ow, oy + oh, fx, fy, fx + fw, fy + fh, iw, ih, (showState ? "visible" : "invisible"), argb); + + //VeLog(NID_UI_ANIM, "%s", logMessage); + } + } + } + + VeLog(NID_UI_ANIM, "%s", logMessage); + + count++; +} + +void +_VeDebug::DumpVeTree(_VisualElementImpl* pElement, int indent) +{ + if (!pElement) + { + _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); + if (pDisplayManager != null && pDisplayManager->GetRoot(0)) + { + pElement = _VisualElementImpl::GetInstance(*pDisplayManager->GetRoot(0)); + } + } + + bool prevDebugEnabled = IsDebugEnabled(); + SetDebugEnabled(true); + + if (pElement) + { + if (indent == 0) + { + VeLog(NID_UI_ANIM, "--------------------------[VE DUMP START]---------------------------"); + } + + VELOGEX_NOFUNCTION(pElement, ""); + VELOGEX_NOFUNCTION(pElement->__pPresentation, "\n"); + + int count = pElement->__children.GetCount(); + for (int i = 0; i < count; i++) + { + _VeDebug::DumpVeTree(pElement->__children.GetChildAt(i), indent + 3); + } + + if (indent == 0) + { + VeLog(NID_UI_ANIM, "--------------------------[VE DUMP END]-----------------------------"); +#if 0 + extern int sfc_memory_usage; + VeLog(NID_UI_ANIM, "--------------------------[IMAGE SIZE=%d KB]-----------------------------", sfc_memory_usage / 1024); +#endif + } + } + + SetDebugEnabled(prevDebugEnabled); + + return; +} + + +void +_VeDebug::DumpEvasTree(_VisualElementImpl* pElement, int indent) +{ + if (!pElement) + { + _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); + if (pDisplayManager != null && pDisplayManager->GetRoot(0)) + { + pElement = _VisualElementImpl::GetInstance(*pDisplayManager->GetRoot(0)); + } + } + + bool prevDebugEnabled = IsDebugEnabled(); + SetDebugEnabled(true); + + if (pElement) + { + if (indent == 0) + { + VeLog(NID_UI_ANIM, "--------------------------[EVAS DUMP START]---------------------------"); + } + + //VELOGEX_NOFUNCTION(pElement, ""); + //VELOGEX_NOFUNCTION(pElement->__pPresentation, "\n"); + + DumpEvasTreeI((Evas_Object*)((_EflNode*)pElement->__pSharedData->pNativeNode)->GetGroupContainer(), indent); + + if (indent == 0) + { + VeLog(NID_UI_ANIM, "--------------------------[EVAS DUMP END]-----------------------------"); + } + } + + SetDebugEnabled(prevDebugEnabled); + + return; +} + + +void +_VeDebug::DumpEvasTreeI(Evas_Object* pParent, int indent) +{ + if (!pParent) + { + return; + } + + bool prevDebugEnabled = IsDebugEnabled(); + SetDebugEnabled(true); + + char logMessage1[LOG_LEN_MAX] = { 0, }; + char logMessage2[LOG_LEN_MAX] = { 0, }; + char logSpaces[LOG_LEN_MAX] = { 0, }; + + int iw = 0; + int ih = 0; + int mox = 0; + int moy = 0; + int mow = 0; + int moh = 0; + int sox = 0; + int soy = 0; + int sow = 0; + int soh = 0; + int mfx = 0; + int mfy = 0; + int mfw = 0; + int mfh = 0; + int sfx = 0; + int sfy = 0; + int sfw = 0; + int sfh = 0; + int red = 0; + int green = 0; + int blue = 0; + int alpha = 0; + int argb = 0; + int renderOperation = 0; + bool mshowState = false; + bool sshowState = false; + void* pBuffer = null; + Tizen::Base::String type(evas_object_type_get(pParent)); + evas_object_geometry_get(pParent, &mox, &moy, &mow, &moh); + + // color & show state + renderOperation = evas_object_render_op_get(pParent); + evas_object_color_get(pParent, &red, &green, &blue, &alpha); + argb = (((alpha << 24) & 0xff000000) | ((red << 16) & 0x00ff0000) | ((green << 8) & 0x0000ff00) | (blue & 0x000000ff)); + mshowState = evas_object_visible_get(pParent); + + if (type != "visual_element")// && argb != 0) + { + bool clip = evas_object_clip_get(pParent) ? true : false; + char source = ' '; + + snprintf(logSpaces, sizeof(logSpaces), "%*s", indent, " "); + if (type == "image") + { + source = 'P'; + } + + if (evas_object_clipees_get(pParent)) + { + type = "cliper"; + } + + snprintf(logMessage1, sizeof(logMessage1), + "%s[%#x][%c] : %ls(%s) fill(%d,%d,%d,%d) bounds(%d,%d,%d,%d) argb(0x%08x) %s clip=%s show=%s", + logSpaces, (unsigned int)pParent, source, type.GetPointer(), evas_object_name_get(pParent), mfx, mfy, mfw, mfh, mox, moy, mow, moh, + (unsigned int)argb, (renderOperation ? "COPY" : "BLEND"), (clip ? "true" : "false"), (mshowState ? "true" : "false") + ); + + VeLog(NID_UI_ANIM, "%s", logMessage1); + + if (type == "image") + { + source = 'S'; + evas_object_image_fill_get(pParent, &mfx, &mfy, &mfw, &mfh); + + // image + Evas_Object* pSource = evas_object_image_source_get(pParent); + pSource = pSource ? pSource : pParent; + + evas_object_image_size_get(pSource, &iw, &ih); + pBuffer = (void*)evas_object_image_data_get(pSource, EINA_FALSE); + evas_object_geometry_get(pSource, &sox, &soy, &sow, &soh); + evas_object_image_fill_get(pSource, &sfx, &sfy, &sfw, &sfh); + sshowState = evas_object_visible_get(pSource); + + snprintf(logMessage2, sizeof(logMessage2), + "%s[%#x][%c] : %ls(%s:%#x %d,%d) fill(%d,%d,%d,%d) bounds(%d,%d,%d,%d) argb(0x%08x) %s show=%s", + logSpaces, (unsigned int)pSource, source, type.GetPointer(), evas_object_name_get(pParent), (unsigned int)pBuffer, iw, ih, sfx, sfy, sfw, sfh, sox, soy, sow, soh, + (unsigned int)argb, (renderOperation ? "COPY" : "BLEND"), (sshowState ? "true" : "false") + ); + + VeLog(NID_UI_ANIM, "%s", logMessage2); + } + } + + + void* pObject = null; + Eina_List* pList = evas_object_smart_members_get(pParent); + EINA_LIST_FREE(pList, pObject) + { + if (pObject) + { + DumpEvasTreeI((Evas_Object*)pObject, indent+2); + } + } + + SetDebugEnabled(prevDebugEnabled); + + return; +} + +void +_VeDebug::DumpEvasObjectForGraphI(FILE* pFile, Evas_Object* pEvasObject, int depth, int pos) +{ + if (!pEvasObject) + { + return; + } + + Tizen::Base::String typeName(evas_object_type_get(pEvasObject)); + + int objX = 0; + int objY = 0; + int objW = 0; + int objH = 0; + evas_object_geometry_get(pEvasObject, &objX, &objY, &objW, &objH); + + Evas_Object* pClipper = evas_object_clip_get(pEvasObject); + const Evas_Map* pMap = evas_object_map_get(pEvasObject); + Evas_Render_Op renderOp = evas_object_render_op_get(pEvasObject); + + int r = 0; + int g = 0; + int b = 0; + int a = 0; + evas_object_color_get(pEvasObject, &r, &g, &b, &a); + + int visible = evas_object_visible_get(pEvasObject); + + Tizen::Base::String output; + Tizen::Base::String label; + Tizen::Base::String common; + Tizen::Base::String type; + Tizen::Base::String order; + Tizen::Base::String clipper; + Tizen::Base::String map; + Tizen::Base::String bounds; + Tizen::Base::String showState; + Tizen::Base::String rop; + Tizen::Base::String color; + Tizen::Base::String imageSize; + Tizen::Base::String imageFill; + Tizen::Base::String imageSource; + + + type.Format(256, L"type %ls", typeName.GetPointer()); + order.Format(256, L"order %d-%d", depth, pos); + clipper.Format(256, L"clipper %x", pClipper); + map.Format(256, L"map %ls", (pMap ? L"used" : L"unused")); + bounds.Format(256, L"bounds %d : %d ~ %d : %d", objX, objY, objX + objW, objY + objH); + showState.Format(256, L"showState %ls", (visible ? L"show" : L"hidden")); + rop.Format(256, L"rop %d", renderOp); + color.Format(256, L"color 0x%08x", (a << 24) | (r << 16) | (g << 8) | b); + + + if (typeName == "image") + { + int iw = 0; + int ih = 0; + evas_object_image_size_get(pEvasObject, &iw, &ih); + int fillX = 0; + int fillY = 0; + int fillW = 0; + int fillH = 0; + evas_object_image_fill_get(pEvasObject, &fillX, &fillY, &fillW, &fillH); + Evas_Object* pSource = evas_object_image_source_get(pEvasObject); + + imageSize.Format(256, L"imageSize %d:%d", iw, ih); + imageFill.Format(256, L"fill %d : %d ~ %d : %d", fillX, fillY, fillX + fillW, fillY + fillH); + imageSource.Format(256, L"source N%lx", pSource); + + if (pSource) + { + DumpEvasObjectForGraphI(pFile, pSource, depth, pos); + fprintf(pFile, "N%lx:proxy -> N%lx [style=dashed, label=source];\n", (unsigned long)pEvasObject, (unsigned long)pSource); + } + } + + + label = L"" + type + L""; + label += L"" + order + L""; + label += L"" + clipper + L""; + label += L"" + map + L""; + label += L"" + bounds + L""; + label += L"" + showState + L""; + label += L"" + rop + L""; + label += L"" + color + L""; + + if (!imageSize.IsEmpty()) + { + label += L"" + imageSize + L""; + } + + if (!imageFill.IsEmpty()) + { + label += L"" + imageFill + L""; + } + + if (!imageSource.IsEmpty()) + { + label += L"" + imageSource + L""; + } + + output.Format(1024, L"N%lx [ fillcolor=\"#%06x\", style=filled, label=<%ls
>];\n", + (unsigned long)pEvasObject, + 0xFAF0E6, + label.GetPointer() + ); + + fprintf(pFile, "%ls", output.GetPointer()); + + + if (pClipper) + { + fprintf(pFile, "N%lx:clipper -> N%lx [style=\"dotted\", label=clipper]; \n", + (unsigned long)pEvasObject, + (unsigned long)pClipper + ); + } +} + +void +_VeDebug::DumpEvasTreeGraphI(FILE* pFile, Evas_Object* pObject, int depth, int pos) +{ + if (!pObject) + { + return; + } + + bool prevDebugEnabled = IsDebugEnabled(); + SetDebugEnabled(true); + + DumpEvasObjectForGraphI(pFile, pObject, depth, pos); + + pos = 0; + void* pChild = null; + Eina_List* pList = evas_object_smart_members_get(pObject); + EINA_LIST_FREE(pList, pChild) + { + if (pChild) + { + DumpEvasTreeGraphI(pFile, (Evas_Object*)pChild, depth + 1, pos++); + fprintf(pFile, "N%lx -> N%lx [style=\"solid,bold\"] \n", (unsigned long)pChild, (unsigned long)pObject); + } + } + + SetDebugEnabled(prevDebugEnabled); +} + +void +_VeDebug::DumpVeObjectForGraphI(FILE* pFile, _VisualElementImpl* pVisualElementImpl, int depth, int pos) +{ + if (!pVisualElementImpl) + { + return; + } + + bool isModel = (pVisualElementImpl == pVisualElementImpl->__pModel); + bool isPresentation = (pVisualElementImpl == pVisualElementImpl->__pPresentation); + + Tizen::Base::String output; + Tizen::Base::String label; + Tizen::Base::String model; + Tizen::Base::String name; + Tizen::Base::String order; + Tizen::Base::String clip; + Tizen::Base::String transformed; + Tizen::Base::String show; + Tizen::Base::String visible; + Tizen::Base::String ror; + Tizen::Base::String opacity; + Tizen::Base::String showOpacity; + Tizen::Base::String opacityFromRoot; + Tizen::Base::String bounds; + Tizen::Base::String invBounds; + Tizen::Base::String rop; + const Tizen::Graphics::FloatRectangle& boundsRect = pVisualElementImpl->__bounds; + const Tizen::Graphics::FloatRectangle& invBoundsRect = pVisualElementImpl->GetSharedData().invalidatedRegion; + + model.Format(256, L"type %ls", (isModel ? L"Model" : isPresentation ? L"Presentation" : L"")); + name.Format(256, L"name %ls", pVisualElementImpl->GetSharedData().name.GetPointer()); + order.Format(256, L"order %d-%d", depth, pos); + clip.Format(256, L"clip %ls", (pVisualElementImpl->__isClipChildren ? L"CS" : L"NO-CS")); + transformed.Format(256, L"xform %ls", (pVisualElementImpl->__needTransform ? L"NO-AA" : L"AA")); + show.Format(256, L"showState %ls", (pVisualElementImpl->GetShowState() ? L"show" : L"hidden")); + visible.Format(256, L"visibility %ls", (pVisualElementImpl->IsVisible() ? L"visible" : L"invisible")); + ror.Format(256, L"redrawOnResize %ls", (pVisualElementImpl->GetRedrawOnResizeEnabled() ? L"ROR" : L"NO-ROR")); + opacity.Format(256, L"opacity %3.1f", pVisualElementImpl->GetOpacity()); + showOpacity.Format(256, L"showOpacity %3.1f", pVisualElementImpl->__showOpacity); + opacityFromRoot.Format(256, L"visOpacity %3.1f", pVisualElementImpl->GetOpacityFromRoot()); + bounds.Format(256, L"bounds %.2f : %.2f ~ %.2f : %.2f", boundsRect.x, boundsRect.y, boundsRect.x + boundsRect.width, boundsRect.y + boundsRect.height); + invBounds.Format(256, L"invBounds %.2f : %.2f ~ %.2f : %.2f", invBoundsRect.x, invBoundsRect.y, invBoundsRect.x + invBoundsRect.width, invBoundsRect.y + invBoundsRect.height); + rop.Format(256, L"rop %d", pVisualElementImpl->__renderOperation); + + + long color = (isModel ? 0xF0FFF0 : isPresentation ? 0xE6E6FA : 0x708090); + + label = L"" + model + L""; + label += L"" + name + L""; + label += L"" + order + L""; + label += L"" + clip + L""; + label += L"" + transformed + L""; + label += L"" + show + L""; + label += L"" + visible + L""; + label += L"" + ror + L""; + label += L"" + opacity + L""; + label += L"" + showOpacity + L""; + label += L"" + opacityFromRoot + L""; + label += L"" + bounds + L""; + label += L"" + invBounds + L""; + label += L"" + rop + L""; + + output.Format(1024, L"N%lx [ fillcolor=\"#%06x\", style=filled, label=<%ls
>];\n", + (unsigned long)pVisualElementImpl->GetPublic(), + color, + label.GetPointer() + ); + + fprintf(pFile, "%ls", output.GetPointer()); + + + if (isPresentation) + { + _EflNode* pEflNode = static_cast< _EflNode* >(pVisualElementImpl->GetSharedData().pNativeNode); + Evas_Object* pEvasObject = reinterpret_cast< Evas_Object* >(pEflNode->GetGroupContainer()); + + fprintf(pFile, "N%lx -> N%lx [dir=none, style=\"dotted\", label=native]; \n", + (unsigned long)pVisualElementImpl->GetPublic(), + (unsigned long)pEvasObject + ); + + if (pVisualElementImpl->__pModel && pVisualElementImpl->__pModel->GetPublic() && + pVisualElementImpl->__pPresentation && pVisualElementImpl->__pPresentation->GetPublic()) + { + fprintf(pFile, "N%lx -> N%lx [style=\"dotted\"]; \n", + (unsigned long)pVisualElementImpl->__pModel->GetPublic(), + (unsigned long)pVisualElementImpl->__pPresentation->GetPublic() + ); + } + } +} + +void +_VeDebug::DumpVeTreeGraphI(FILE* pFile, _VisualElementImpl* pVisualElementImpl, int depth, int pos) +{ + if (!pVisualElementImpl) + { + return; + } + + bool prevDebugEnabled = IsDebugEnabled(); + SetDebugEnabled(true); + + DumpVeObjectForGraphI(pFile, pVisualElementImpl, depth, pos); + + for (int i = 0; i < pVisualElementImpl->__children.GetCount(); i++) + { + _VisualElementImpl* pChild = pVisualElementImpl->__children.GetChildAt(i); + DumpVeTreeGraphI(pFile, pChild, depth + 1, i); + fprintf(pFile, "N%lx -> N%lx [style=\"solid,bold\"] \n", + (unsigned long)pChild->GetPublic(), + (unsigned long)pVisualElementImpl->GetPublic() + ); + } + + SetDebugEnabled(prevDebugEnabled); +} + +void +_VeDebug::DumpEvasTreeGraph(const char* pFilePath, VisualElement* pVisualElement) +{ + _VisualElementImpl* pElement = null; + + if (!pVisualElement) + { + _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); + if (pDisplayManager != null && pDisplayManager->GetRoot(0)) + { + pElement = _VisualElementImpl::GetInstance(*pDisplayManager->GetRoot(0)); + } + } + else + { + pElement = _VisualElementImpl::GetInstance(*pVisualElement); + } + + if (!pElement) + { + return; + } + + FILE* pFile = fopen(pFilePath, "wt"); + if (!pFile) + { + return; + } + + fprintf(pFile, "digraph VisualElementDump {\n"); + fprintf(pFile, "node [shape=plaintext, fontsize=10.0];\n"); + fprintf(pFile, "edge [fontsize=10.0];\n"); + //fprintf(pFile, "rankdir = TB;\n"); + fprintf(pFile, "rankdir = BT;\n"); + fprintf(pFile, "\n"); + + + bool prevDebugEnabled = IsDebugEnabled(); + SetDebugEnabled(true); + + + _EflNode* pEflNode = static_cast< _EflNode* >(pElement->GetSharedData().pNativeNode); + Evas_Object* pEvasObject = reinterpret_cast< Evas_Object* >(pEflNode->GetGroupContainer()); + + fprintf(pFile, "subgraph cluster_evas {\n"); + fprintf(pFile, "clusterrank = local;\n"); + fprintf(pFile, "fontsize = 30.0;\n"); + fprintf(pFile, "label = \"Evas Object\";\n"); + DumpEvasTreeGraphI(pFile, pEvasObject, 0, 0); + fprintf(pFile, "}\n"); + + fprintf(pFile, "subgraph cluster_model {\n"); + fprintf(pFile, "clusterrank = local;\n"); + fprintf(pFile, "fontsize = 30.0;\n"); + fprintf(pFile, "label = \"Model\";\n"); + DumpVeTreeGraphI(pFile, pElement->__pModel, 0, 0); + fprintf(pFile, "}\n"); + + fprintf(pFile, "subgraph cluster_presentation {\n"); + fprintf(pFile, "clusterrank = local;\n"); + fprintf(pFile, "fontsize = 30.0;\n"); + fprintf(pFile, "label = \"Presentation\";\n"); + DumpVeTreeGraphI(pFile, pElement->__pPresentation, 0, 0); + fprintf(pFile, "}\n"); + + fprintf(pFile, "\n"); + + SetDebugEnabled(prevDebugEnabled); + + fprintf(pFile, "}\n\n"); + + fclose(pFile); +} + +void +_VeDebug::DumpAllEvas(void) +{ + Eina_List* pEvasObjects = null; + void* pObject = null; + Evas_Object* pEvasObject = null; +// int w, h; + + if (GetEcoreEvasMgr() && GetEcoreEvasMgr()->GetEcoreEvas() && GetEcoreEvasMgr()->GetEcoreEvas()->GetEvas()) + { +// evas_output_size_get(GetEcoreEvasMgr()->GetEcoreEvas()->GetEvas(), &w, &h); + + pEvasObjects = evas_objects_in_rectangle_get( + GetEcoreEvasMgr()->GetEcoreEvas()->GetEvas(), +// 0, 0, w, h, + -99999, -99999, 99999 * 2, 99999 * 2, + 1, 1 + ); + } + + if (!pEvasObjects) + { + return; + } + + VeLog(NID_UI_ANIM, "--------------------------[EVAS ALL DUMP START]-----------------------------"); + + pEvasObject = null; + EINA_LIST_FREE(pEvasObjects, pObject) + { + if (likely(pObject)) + { + pEvasObject = (Evas_Object*)pObject; + + Tizen::Base::String type(evas_object_type_get(pEvasObject)); + + char logMessage[1024]; + int iw = 0; + int ih = 0; + int ox = 0; + int oy = 0; + int ow = 0; + int oh = 0; + int red = 0; + int green = 0; + int blue = 0; + int alpha = 0; + int argb = 0; + Evas_Object* pSource = NULL; + if (type == "image") + { + pSource = evas_object_image_source_get(pEvasObject); + evas_object_image_size_get(pEvasObject, &iw, &ih); + } + evas_object_geometry_get(pEvasObject, &ox, &oy, &ow, &oh); + evas_object_color_get(pEvasObject, &red, &green, &blue, &alpha); + argb = (((alpha << 24) & 0xff000000) | ((red << 16) & 0x00ff0000) | ((green << 8) & 0x0000ff00) | (blue & 0x000000ff)); + bool showState = evas_object_visible_get(pEvasObject); + + snprintf(logMessage, sizeof(logMessage), " - type=%ls[%p] bounds=[%d:%d ~ %d:%d] imgsize=[%d:%d] show=%s color=%08X source=%p", + type.GetPointer(), pEvasObject, ox, oy, ox + ow, oy + oh, iw, ih, (showState ? "visible" : "invisible"), argb, pSource); + + VeLog(NID_UI_ANIM, "%s", logMessage); + } + } + + VeLog(NID_UI_ANIM, "--------------------------[EVAS ALL DUMP END]-----------------------------"); +} + +void +_VeDebug::PrintVeTree(_VisualElementImpl* pElement, int depth, unsigned int remainingChild) +{ + static Tizen::Base::String output = ""; + Tizen::Base::String item = ""; + Tizen::Base::String surface = ""; + Tizen::Base::String name = ""; + + if (!pElement) + { + _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); + if (pDisplayManager != null && pDisplayManager->GetRoot(0)) + { + pElement = _VisualElementImpl::GetInstance(*pDisplayManager->GetRoot(0)); + } + } + + if (!pElement) + { + return; + } + + + bool prevDebugEnabled = IsDebugEnabled(); + SetDebugEnabled(true); + + if (pElement->GetSharedData().pSurface) + { + surface = "(S)"; + } + + if (pElement->GetName().GetLength() <= 0) + { + name.Format(255, L"%ls%#x", surface.GetPointer(), pElement); + } + else + { + name.Format(255, L"%ls%ls", surface.GetPointer(), pElement->GetName().GetPointer()); + } + + // Print + for (int i = 1; i <= depth; i++) + { + int childrenCount = 0; + if (pElement->__pParent) + { + childrenCount = pElement->__pParent->__children.GetCount(); + } + + // only one child + if (childrenCount <= 1) + { + if (remainingChild) + { + remainingChild -= pow(10, depth - 1); + } + + // Print name + item.Format(255, L"-%-16ls", name.GetPointer()); + output.Append(item); + break; + } + // first child + else if (DIGITATPOSITION(remainingChild, depth) == childrenCount) + { + remainingChild -= powf(10.0f, depth - 1); + + // Print name + item.Format(255, L"T%-16ls", name.GetPointer()); + output.Append(item); + break; + } + // last child + else if (depth == i) + { + remainingChild -= powf(10.0f, depth - 1); + // Print name + item.Format(255, L"%s%-16ls", (DIGITATPOSITION(remainingChild, i) == 0) ? "L" : "L", name.GetPointer()); + output.Append(item); + } + // other + else + { + item.Format(255, L"%s%-16ls", (DIGITATPOSITION(remainingChild, i) > 0) ? "|" : " ", L""); + output.Append(item); + } + } + + // Print children + int count = pElement->__children.GetCount(); + if (count > 0) + { + for (int i = 0; i < count; i++) + { + if (pElement->__children.GetChildAt(i)) + { + PrintVeTree(pElement->__children.GetChildAt(i), depth + 1, remainingChild + (count - i) * powf(10.0f, depth)); + } + } + } + else + { + //output.Append("\n"); + // Print log + VeLog(NID_UI_ANIM, "%s", output.GetPointer()); + output = ""; + } + + SetDebugEnabled(prevDebugEnabled); +} + +void +_VeDebug::DumpVeImage(_VisualElementImpl* pElement, const char* pathPrefix) +{ + static int count = 0; + char filename[2048] = {0, }; + + if (!pathPrefix) + { + pathPrefix = "/tmp/"; + } + + if (!pElement) + { + _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); + if (pDisplayManager != null && pDisplayManager->GetRoot(0)) + { + pElement = _VisualElementImpl::GetInstance(*pDisplayManager->GetRoot(0)); + } + } + + if (!pElement) + { + return; + } + + + Tizen::Base::String name = pElement->GetName(); + if (name.GetLength() > 0) + { + sprintf(filename, "%sVE_%d_%ls_%08x.png", pathPrefix, count++, pElement->GetName().GetPointer(), (unsigned int)pElement->GetPresentation()); + } + else + { + sprintf(filename, "%sVE_%d_%08x.png", pathPrefix, count++, (unsigned int)pElement->GetPresentation()); + } + + VisualElementSurface* pSurface = pElement->__pSharedData->pNativeNode->GetSurface(); + if (pSurface && _VisualElementSurfaceImpl::GetInstance(*pSurface)) + { + Evas_Object* pEvasObjectImage = null; + Evas_Object* pSource = evas_object_image_source_get((Evas_Object*)_VisualElementSurfaceImpl::GetInstance(*pSurface)->GetNativeHandle()); + if (pSource) + { + pEvasObjectImage = pSource; + } + else + { + pEvasObjectImage = (Evas_Object*)_VisualElementSurfaceImpl::GetInstance(*pSurface)->GetNativeHandle(); + } + + if (pEvasObjectImage) + { + VeLog(NID_UI_ANIM, "--------------------------[VE DUMP IMAGE START %#08x]---------------------------", pElement); + if (evas_object_image_save(pEvasObjectImage, filename, NULL, "quality=100 compress=9")) + { + evas_object_image_save(pEvasObjectImage, "/tmp/lastimage.png", NULL, "quality=100 compress=9"); + VeLog(NID_UI_ANIM, "--------------------------[VE DUMP IMAGE END]-----------------------------"); + } + else + { + VeLog(NID_UI_ANIM, "--------------------------[VE DUMP IMAGE ERROR!!!]-----------------------------"); + } + } + } +} + +void +_VeDebug::DumpAllVeImages(_VisualElementImpl* pElement, const char* pathPrefix) +{ + if (!pElement) + { + _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); + if (pDisplayManager != null && pDisplayManager->GetRoot(0)) + { + pElement = _VisualElementImpl::GetInstance(*pDisplayManager->GetRoot(0)); + } + } + + if (pElement == null) + { + return; + } + + DumpVeImage(pElement, pathPrefix); + + int count = pElement->__children.GetCount(); + for (int i = 0; i < count; i++) + { + if (pElement->__children.GetChildAt(i)) + { + DumpAllVeImages(pElement->__children.GetChildAt(i), pathPrefix); + } + } +} + +void +_VeDebug::ReflushAll(_VisualElementImpl* pElement, int depth) +{ + pElement->SetFlushNeeded(); + + int count = pElement->__children.GetCount(); + for (int i = 0; i < count; i++) + { + ReflushAll(pElement->__children.GetChildAt(i), depth + 1); + } + + if (depth == 0) + { + _EflNode* pEflNode = dynamic_cast< _EflNode* >(pElement->__pSharedData->pNativeNode); + if (pEflNode != null) + { + ecore_evas_manual_render(ecore_evas_ecore_evas_get(pEflNode->GetEvas())); + } + } +} + + +}}} // Tizen::Ui::Animations + + +extern "C" _OSP_EXPORT_ void +DumpVeTree(void) +{ + Tizen::Ui::Animations::_DisplayManager* pDisplayManager = Tizen::Ui::Animations::_DisplayManager::GetInstance(); + + for (int i = 0; i < pDisplayManager->GetRootCount(); i++) + { + Tizen::Ui::Animations::_VisualElementImpl* pVisualElementImpl = Tizen::Ui::Animations::_VisualElementImpl::GetInstance(*pDisplayManager->GetRoot(i)); + if (pVisualElementImpl) + { + Tizen::Ui::Animations::_VeDebug::DumpVeTree(pVisualElementImpl, 0); + } + } +} + +extern "C" _OSP_EXPORT_ void +DumpEvasTree(void) +{ + Tizen::Ui::Animations::_DisplayManager* pDisplayManager = Tizen::Ui::Animations::_DisplayManager::GetInstance(); + + for (int i = 0; i < pDisplayManager->GetRootCount(); i++) + { + Tizen::Ui::Animations::_VisualElementImpl* pVisualElementImpl = Tizen::Ui::Animations::_VisualElementImpl::GetInstance(*pDisplayManager->GetRoot(i)); + if (pVisualElementImpl) + { + Tizen::Ui::Animations::_VeDebug::DumpEvasTree(pVisualElementImpl, 0); + } + } +} + +extern "C" _OSP_EXPORT_ void +DumpAllVeImages(void) +{ + Tizen::Ui::Animations::_DisplayManager* pDisplayManager = Tizen::Ui::Animations::_DisplayManager::GetInstance(); + + for (int i = 0; i < pDisplayManager->GetRootCount(); i++) + { + Tizen::Ui::Animations::_VisualElementImpl* pVisualElementImpl = Tizen::Ui::Animations::_VisualElementImpl::GetInstance(*pDisplayManager->GetRoot(i)); + if (pVisualElementImpl) + { + Tizen::Ui::Animations::_VeDebug::DumpAllVeImages(pVisualElementImpl, 0); + } + } +} + +extern "C" _OSP_EXPORT_ void +DumpAllEvas(void) +{ + Tizen::Ui::Animations::_VeDebug::DumpAllEvas(); +} + +extern "C" _OSP_EXPORT_ void +DumpEvasTreeGraph(void) +{ + Tizen::Ui::Animations::_DisplayManager* pDisplayManager = Tizen::Ui::Animations::_DisplayManager::GetInstance(); + + for (int i = 0; i < pDisplayManager->GetRootCount(); i++) + { + char filePath[256]; + snprintf(filePath, sizeof(filePath), "/tmp/graph_%d.dot", i); + Tizen::Ui::Animations::_VeDebug::DumpEvasTreeGraph(filePath, pDisplayManager->GetRoot(i)); + } +} + +#ifdef __i386__ +extern "C" _OSP_EXPORT_ void +DebugAnimBreak(void) +{ + asm volatile ("int $3\n"); +} +#endif + + +#endif + diff --git a/src/ui/animations/FUiAnim_Debug.h b/src/ui/animations/FUiAnim_Debug.h new file mode 100644 index 0000000..2fd972e --- /dev/null +++ b/src/ui/animations/FUiAnim_Debug.h @@ -0,0 +1,180 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_Debug.h + * @brief Header file of _VeDebug class + * + * This file contains declarations _VeDebug class. + */ + +#ifndef _FUI_ANIM_INTERNAL_DEBUG_H_ +#define _FUI_ANIM_INTERNAL_DEBUG_H_ + +#include +#include + +//#define VE_DEBUG // debug config +#define VE_DEBUG_MODULE + +namespace Tizen { namespace Ui { namespace Animations +{ + +#ifdef VE_DEBUG_MODULE + +#ifdef _OSP_PERF_ +class _ElapsedTime +{ +public: + _ElapsedTime(const char* tag = null) + { + struct timeval tv; + + tagName = tag; + + gettimeofday(&tv, null); + start_time = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; + + depth++; + maxdepth++; + } + + ~_ElapsedTime(void) + { + long long end_time; + struct timeval tv; + gettimeofday(&tv, null); + end_time = (long long)tv.tv_sec * 1000000LL + (long long)tv.tv_usec / 1LL; + + depth--; + if (count < 500) + snprintf(logs[count++], 256, "%*s -->[%s]=%lld us\n", depth * 3, " ", tagName, end_time - start_time); + + if (depth == 0) + { + for (int i = 0; i < count; i++) + printf("%s", logs[i]); + + maxdepth = 0; + count = 0; + } + } + + +public: + static char logs[500][256]; + static int depth; + static int count; + static int maxdepth; + long long start_time; + const char* tagName; +}; // _ElapsedTime +#endif + +#define VeLog(UID, ...) \ + SysLogInternal(UID, 0, 0, __VA_ARGS__); +#define VELOG(...) \ + do \ + { \ + if (_VeDebug::IsDebugEnabled()) \ + { \ + _VeDebug::DumpVisualElement(this, __func__, __LINE__, __VA_ARGS__); \ + } \ + } while (0) + +#define VELOGEX(_ELEMENT_, ...) \ + do \ + { \ + if (_VeDebug::IsDebugEnabled()) \ + { \ + _VeDebug::DumpVisualElement(_ELEMENT_, __func__, __LINE__, __VA_ARGS__); \ + } \ + } while (0) + +#define VELOGEX_NOFUNCTION(_ELEMENT_, ...) \ + do \ + { \ + if (_VeDebug::IsDebugEnabled()) \ + { \ + _VeDebug::DumpVisualElement(_ELEMENT_, null, 0, __VA_ARGS__); \ + } \ + } while (0) + +#define VEDUMPTREE(_ELEMENT_, _INDENT_) \ + do \ + { \ + if (_VeDebug::IsDebugEnabled()) \ + { \ + _VeDebug::DumpVeTree(_ELEMENT_, _INDENT_); \ + } \ + } while (0) + +#define VELOGRECTTAG "[%.1f:%.1f ~ %.1f:%.1f]" +#define VELOGRECT(r) (r).x, (r).y, (r).GetBottomRight().x, (r).GetBottomRight().y + +class _VisualElementImpl; + +class _VeDebug +{ +public: + static void DumpVisualElement(_VisualElementImpl* pElement, const char* func, int line, const char* fmt, ...); + static void PrintVeTree(_VisualElementImpl* pElement = 0, int depth = 0, unsigned int remainedChild = 0); + static void DumpVeTree(_VisualElementImpl* pElement = 0, int indent = 0); + static void DumpVeImage(_VisualElementImpl* pElement = 0, const char* pathPrefix = 0); + static void DumpAllVeImages(_VisualElementImpl* pElement = 0, const char* pathPrefix = 0); + static void ReflushAll(_VisualElementImpl* pElement, int depth = 0); + static void SetDebugEnabled(bool enable); + static bool IsDebugEnabled(void); + + static void DumpEvasTree(_VisualElementImpl* pElement, int indent); + static void DumpAllEvas(void); + + static void DumpEvasObjectForGraphI(FILE* pFile, Evas_Object* pEvasObject, int depth, int pos); + static void DumpEvasTreeGraphI(FILE* pFile, Evas_Object* pObject, int depth, int pos); + static void DumpVeObjectForGraphI(FILE* pFile, _VisualElementImpl* pVisualElementImpl, int depth, int pos); + static void DumpVeTreeGraphI(FILE* pFile, _VisualElementImpl* pVisualElementImpl, int depth, int pos); + + static void DumpEvasTreeGraph(const char* pFilePath, VisualElement* pVisualElement); + + +private: + _VeDebug(void); + _VeDebug(const _VeDebug& rhs); + ~_VeDebug(void); + + _VeDebug& operator =(const _VeDebug& rhs); + +private: + static void DumpEvasTreeI(Evas_Object* pParent, int indent); + +private: + static bool __veDebugEnabled; +}; //_VeDebug + +#else +#define VELOG(...) +#define VELOGEX(_Element_, ...) +#define VELOGEX_NOFUNCTION(_ELEMENT_, ...) +#define VEDUMPTREE(_ELEMENT_, _INDENT_) +#define VELOGRECTTAG +#define VELOGRECT(r) +#endif + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_DEBUG_H_ + diff --git a/src/ui/animations/FUiAnim_DimensionAnimationImpl.cpp b/src/ui/animations/FUiAnim_DimensionAnimationImpl.cpp new file mode 100644 index 0000000..04ed1e8 --- /dev/null +++ b/src/ui/animations/FUiAnim_DimensionAnimationImpl.cpp @@ -0,0 +1,129 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_DimensionAnimationImpl.cpp + * @brief This file contains implementation of _DimensionAnimationImpl class + * + * This file contains implementation _DimensionAnimationImpl class. + */ + +#include +#include + +#include + +#include "FUiAnim_VisualElementAnimationVariantInterpolator.h" +#include "FUiAnim_AnimationBaseImpl.h" +#include "FUiAnim_DimensionAnimationImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +_DimensionAnimationImpl::~_DimensionAnimationImpl(void) +{ +} + +_DimensionAnimationImpl::_DimensionAnimationImpl(DimensionAnimation* pDimensionAnimation) + : anchorX(0.0f) + , anchorY(0.0f) + , startValue(Dimension(0, 0)) + , endValue(Dimension(0, 0)) + , __pDimensionAnimation(pDimensionAnimation) +{ +} + +result +_DimensionAnimationImpl::CopyDimensionAnimationValue(const DimensionAnimation& dimensionAnimation) +{ + result r = E_SUCCESS; + + _AnimationBaseImpl* pAnimationBaseImpl = __pDimensionAnimation->_pAnimationBaseImpl; + + // Deleting the contents of existing keyframe + r = pAnimationBaseImpl->RemoveAllKeyFrames(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + // Copying the contents + startValue = dimensionAnimation._pDimensionAnimationImpl->startValue; + endValue = dimensionAnimation._pDimensionAnimationImpl->endValue; + + if (dimensionAnimation._pAnimationBaseImpl->keyFrameList.GetCount() == 0) + { + return E_SUCCESS; + } + + IMapEnumeratorT< long, Object* >* pMapEnum = null; + MapEntryT< long, Object* > value; + Dimension* pDimensionObj = null; + + pMapEnum = dimensionAnimation._pAnimationBaseImpl->keyFrameList.GetMapEnumeratorN(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_ANIM, (pMapEnum), r, "Failed to GetMapEnumeratorN()"); + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + r = pMapEnum->GetCurrent(value); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + Dimension* pDimValue = dynamic_cast< Dimension* >(value.GetValue()); + SysTryCatch(NID_UI_ANIM, (pDimValue), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. KeyFrame value is invalid."); + + pDimensionObj = new (std::nothrow) Dimension(*pDimValue); + SysTryCatch(NID_UI_ANIM, (pDimensionObj), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pAnimationBaseImpl->keyFrameList.Add(value.GetKey(), pDimensionObj); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + delete pMapEnum; + + return E_SUCCESS; + +CATCH: + delete pDimensionObj; + delete pMapEnum; + + return r; +} + +result +_DimensionAnimationImpl::GetAnimatedValue(float actualProgress, Tizen::Graphics::Dimension& animatedValue) const +{ + Variant startDimension(startValue); + Variant endDimension(endValue); + Variant value(Dimension(0, 0)); + + _VisualElementAnimationVariantInterpolator variantInterpolator; + result r = variantInterpolator.Interpolate(actualProgress, startDimension, endDimension, value); + + animatedValue = value.ToDimension(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to get the animated value."); + + return r; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_DimensionAnimationImpl.h b/src/ui/animations/FUiAnim_DimensionAnimationImpl.h new file mode 100644 index 0000000..ca73f97 --- /dev/null +++ b/src/ui/animations/FUiAnim_DimensionAnimationImpl.h @@ -0,0 +1,116 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_DimensionAnimationImpl.h + * @brief This is the header file for the _DimensionAnimationImpl class. + * + * This header file contains the declarations of the _DimensionAnimationImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_DIMENSION_ANIMATION_IMPL_H_ +#define _FUI_ANIM_INTERNAL_DIMENSION_ANIMATION_IMPL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _DimensionAnimationImpl + : public Tizen::Base::Object +{ + +public: + /** + * Destructor for %_DimensionAnimationImpl class. + */ + ~_DimensionAnimationImpl(void); + + /** + * Default constructor for %_DimensionAnimationImpl class. + */ + _DimensionAnimationImpl(DimensionAnimation* pDimensionAnimation); + + /** + * To copy Dimension animation object + * + * @since 2.0 + * @return An error code + * @param[in] dimensionAnimation Dimension animation object + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result CopyDimensionAnimationValue(const DimensionAnimation& dimensionAnimation); + + /** + * Gets the animated value for the current time. + * + * @since 2.0 + * @return An error code + * @param[in] actualProgress The current time value of the animation @n + * The value should be between @c 0 and 1 + * @param[out] animatedValue The animated value for the current time passed as the input parameter + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_STATE This instance has not been properly constructed. + * @exception E_SYSTEM A system error has occurred. + * + */ + result GetAnimatedValue(float actualProgress, Tizen::Graphics::Dimension& animatedValue) const; + + /** + * The Anchor X value for scaling + */ + float anchorX; + + /** + * The Anchor Y value for scaling + */ + float anchorY; + + /** + * The start value of the animation + */ + Tizen::Graphics::Dimension startValue; + + /** + * The end value of the animation + */ + Tizen::Graphics::Dimension endValue; + + +private: + /** + * Private copy constructor. + */ + _DimensionAnimationImpl(const DimensionAnimation& rhs); + + /** + * Private assignment operator. + */ + _DimensionAnimationImpl& operator =(const _DimensionAnimationImpl& rhs); + + /** + * This is object of DimensionAnimation class + */ + DimensionAnimation* __pDimensionAnimation; +}; // _DimensionAnimationImpl + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_DIMENSION_ANIMATION_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_DisplayContextImpl.cpp b/src/ui/animations/FUiAnim_DisplayContextImpl.cpp new file mode 100644 index 0000000..1a603fc --- /dev/null +++ b/src/ui/animations/FUiAnim_DisplayContextImpl.cpp @@ -0,0 +1,101 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_DisplayContextImpl.cpp + * @brief This is the implementation file for DisplayContext class. + * + * This file contains implementation DisplayContext class. + */ + +#include +#include "FUiAnim_NativeLayer.h" +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnimDisplayContext.h" +#include "FUiAnim_DisplayContextImpl.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Animations +{ + +_DisplayContextImpl::_DisplayContextImpl(const _NativeLayer& layer) + : _pPublicInstance(null) +{ + __pLayer = const_cast<_NativeLayer*>(&layer); +} + +_DisplayContextImpl::~_DisplayContextImpl(void) +{ + _pPublicInstance = null; + __pLayer = null; +} + +result +_DisplayContextImpl::SetPublicInstance(DisplayContext* pInstance) +{ + _pPublicInstance = pInstance; + return E_SUCCESS; +} + +DisplayContext* +_DisplayContextImpl::GetPublicInstance(void) +{ + return _pPublicInstance; +} + +result +_DisplayContextImpl::SetNativeLayer(const _NativeLayer& layer) +{ + __pLayer = const_cast<_NativeLayer*>(&layer); + + return E_SUCCESS; +} + +_DisplayContextImpl* +_DisplayContextImpl::GetInstance(DisplayContext& displayContext) +{ + return displayContext._pDisplayContextImpl; +} + +const _DisplayContextImpl* +_DisplayContextImpl::GetInstance(const DisplayContext& displayContext) +{ + return displayContext._pDisplayContextImpl; +} + +DisplayContext* +_DisplayContextImpl::CreatePublicInstance(const _NativeLayer& layer) +{ + DisplayContext* pContext = new (std::nothrow) DisplayContext(); + + SysTryReturn(NID_UI_ANIM, pContext, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pContext->_pDisplayContextImpl = new (std::nothrow) _DisplayContextImpl(layer); + + return pContext; +} + +result +_DisplayContextImpl::DestroyPublicInstance(const DisplayContext& displayContext) +{ + delete &displayContext; + return E_SUCCESS; +} + + +}}} diff --git a/src/ui/animations/FUiAnim_DisplayManager.cpp b/src/ui/animations/FUiAnim_DisplayManager.cpp new file mode 100644 index 0000000..1274c41 --- /dev/null +++ b/src/ui/animations/FUiAnim_DisplayManager.cpp @@ -0,0 +1,324 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_DisplayManager.cpp + * @brief This file contains implementation of _DisplayManager class + * + * This file contains implementation _DisplayManager class. + */ +#include +#include +#include +#include "FUiAnim_NativeLayer.h" +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_VisualElementEnvironment.h" +#include "FUiAnim_AnimationManager.h" +#include "FUiAnim_DisplayManager.h" + +using namespace Tizen; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui::Animations; + + +namespace +{ +Eina_Bool +WakeupEventCallback(void* pData, int type, void* pEvent) +{ + _DisplayManager::__wakeUpEventAdded = false; + + return ECORE_CALLBACK_PASS_ON; +} + +} + +namespace Tizen { namespace Ui { namespace Animations +{ +int _DisplayManager::__eventType = 0; +void* _DisplayManager::__pWakeUpEventHandler = null; +bool _DisplayManager::__wakeUpEventAdded = false; +_DisplayManager* _DisplayManager::__pInstance = null; + +_DisplayManager::_DisplayManager(void) + : __roots() +{ + __roots.Construct(); +} + +_DisplayManager::~_DisplayManager(void) +{ + while (__roots.GetCount() > 0) + { + _RootVisualElement* pRoot = static_cast< _RootVisualElement* >(__roots.GetAt(0)); + + pRoot->Destroy(); + __roots.RemoveAt(0); + } +} + +result +_DisplayManager::CreateInstance(void) +{ + SysTryReturnResult(NID_UI_ANIM, !__pInstance, E_OBJ_ALREADY_EXIST, "The display manager is already created."); + + __pInstance = new (std::nothrow) _DisplayManager(); + if (!__pInstance) + { + return E_OUT_OF_MEMORY; + } + + _VisualElementEnvironment::Initialize(); + + // for wake up event + __eventType = ecore_event_type_new(); + __pWakeUpEventHandler = (void*)ecore_event_handler_add(__eventType, WakeupEventCallback, null); + + return E_SUCCESS; +} + +result +_DisplayManager::ReleaseInstance(void) +{ + SysTryReturnResult(NID_UI_ANIM, __pInstance, E_INVALID_STATE, "The display manager is not created."); + + if (__pWakeUpEventHandler) + { + ecore_event_handler_del((Ecore_Event_Handler*)__pWakeUpEventHandler); + } + + delete __pInstance; + __pInstance = null; + + return E_SUCCESS; +} + +_RootVisualElement* +_DisplayManager::CreateRoot(void) +{ + _RootVisualElement* pRoot = new (std::nothrow) _RootVisualElement(); + if (!pRoot) + { + return null; + } + + pRoot->Construct(); + pRoot->SetImplicitAnimationEnabled(false); + pRoot->SetShowState(true); + + RegisterRoot(*pRoot); + + return pRoot; +} + +result +_DisplayManager::DestroyRoot(_RootVisualElement& root) +{ + result r = UnregisterRoot(root); + + if (r != E_SUCCESS) + { + SysLogException(NID_UI_ANIM, E_INVALID_ARG, "[E_INVALID_ARG] root is not managed in the DisplayManager" ); + } + + root.Destroy(); + + return E_SUCCESS; +} + +result +_DisplayManager::RegisterRoot(_RootVisualElement& root) +{ + return __roots.Add(root); +} + +result +_DisplayManager::UnregisterRoot(_RootVisualElement& root) +{ + return __roots.Remove(root); +} + +int +_DisplayManager::GetRootCount(void) const +{ + return __roots.GetCount(); +} + +_RootVisualElement* +_DisplayManager::GetRoot(int index) const +{ + const _RootVisualElement* pRoot = static_cast< const _RootVisualElement* >(__roots.GetAt(index)); + return const_cast< _RootVisualElement* >(pRoot); +} + +void +_DisplayManager::AddWakeUpEvent(void) +{ + if (!__wakeUpEventAdded) + { + ecore_event_add(__eventType, NULL, NULL, NULL); + __wakeUpEventAdded = true; + } +} + +bool +_DisplayManager::RenderAll(void) +{ + bool needUpdate = false; + int count = __roots.GetCount(); + if (count > 0) + { + for (int i = 0; i < count; i++) + { + _RootVisualElement* pRoot = static_cast< _RootVisualElement* >(__roots.GetAt(i)); + if (likely(pRoot)) + { + bool updated = Render(*pRoot); + + needUpdate |= updated; + + if (updated) + { + _NativeLayer* pLayer = pRoot->GetNativeLayer(); + if (likely(pLayer)) + { + pLayer->SetFlushNeeded(); + } + } + + PostRender(*pRoot); + } + } + } + + return needUpdate; +} + +bool +_DisplayManager::Render(_RootVisualElement& root) +{ + // VisualElement Rendering + // Fill contents + + // Prevent recursion for rendering ! + + // WARNING: + // EFL BUG !!!!! + // if the contents of evas object image is changed with geometry change, + // damage area is not calculated correctly !!! when event freeze/thaw enabled. + // --> artifact occurs + + //evas_event_freeze(__pEvas); + + bool updated = false; + + _RootVisualElement* pPresentationRoot = static_cast< _RootVisualElement* >(const_cast(root.AcquirePresentationInstance())); + if (pPresentationRoot) + { + _VisualElementImpl* pRootModelImpl = _VisualElementImpl::GetInstance(root); + _VisualElementImpl* pRootPresentationImpl = _VisualElementImpl::GetInstance(*pPresentationRoot); + + if (likely(pRootModelImpl) && likely(pRootPresentationImpl)) + { + //-------------------; + // + if (//likely((pRootModelImpl->__childrenNeedsUpdateProps) != 0) || + likely(pRootPresentationImpl->__childrenNeedsUpdateProps != 0) || + likely(pRootPresentationImpl->__pSharedData->NeedNativeReconfigure()) || + unlikely(root.GetNeedsContentUpdate()) || + unlikely(pPresentationRoot->GetNeedsContentUpdate())) + { + root.SetNeedsContentUpdate(false); + root.Draw(); + + pPresentationRoot->SetNeedsContentUpdate(false); + pPresentationRoot->Draw(); + + updated = true; + } + } + } + root.ReleasePresentationInstance(); + + + //evas_event_thaw(__pEvas); + //evas_event_thaw_eval(__pEvas); // CHECKME: needed ??? + + return updated; +} + +result +_DisplayManager::PostRender(_RootVisualElement& root) +{ +// _ElapsedTime foo("PostRender"); + + + _RootVisualElement* pPresentationRoot = static_cast< _RootVisualElement* >(const_cast(root.AcquirePresentationInstance())); + if (likely(pPresentationRoot)) + { + _VisualElementImpl* pRootPresentationImpl = _VisualElementImpl::GetInstance(*pPresentationRoot); + + if (likely((pRootPresentationImpl->__childrenNeedsUpdateProps & ~_VisualElementImpl::HIERARCHY_PROPERTY_CONTENT) != 0) || + likely(pRootPresentationImpl->__pSharedData->NeedNativeReconfigure()) || + unlikely(root.GetNeedsContentUpdate()) || + unlikely(pPresentationRoot->GetNeedsContentUpdate())) + { + // CHECKME: + // We need wake-up main-loop for VE to be validated(draw) on next loop iteration. + // Is there another good method for this??? + + AddWakeUpEvent(); + } + } + root.ReleasePresentationInstance(); + + return E_SUCCESS; +} + +result +_DisplayManager::Flush(void) +{ + int count = __roots.GetCount(); + if (count > 0) + { + for (int i = 0; i < count; i++) + { + _RootVisualElement* pRoot = static_cast< _RootVisualElement* >(__roots.GetAt(i)); + if (likely(pRoot)) + { + _NativeLayer* pLayer = pRoot->GetNativeLayer(); + +//CHECK ME : when evas marked update flag. +// if (pLayer && pLayer->IsFlushNeeded()) + { + pLayer->Flush(); + pLayer->ResetFlushNeeded(); + } + } + } + } + + return E_SUCCESS; +} + + + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_EflLayer.cpp b/src/ui/animations/FUiAnim_EflLayer.cpp new file mode 100755 index 0000000..9503cf1 --- /dev/null +++ b/src/ui/animations/FUiAnim_EflLayer.cpp @@ -0,0 +1,627 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_EflLayer.cpp + * @brief This file contains implementation of _EflLayer class + * + * This file contains implementation _EflLayer class. + */ + +#include +#include +#include + +#include +#include + +#include +#include "FUiAnim_NativeLayer.h" +#include "FUiAnim_EflLayer.h" +#include "FUiAnim_EflNode.h" +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_AnimationManager.h" +#include "FUiAnim_DisplayManager.h" +#include "FUi_Math.h" + + +using namespace Tizen; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +#define _NEED_DAMAGE_HANDER_ + +//#define PRINT printf +#define PRINT(...) + + + + +namespace +{ +#define __UNUSED__ +#ifdef VE_VSYNC_UPDATE + +Ecore_Idle_Enterer* __pOnIdleLoopIterator = null; + + +//static const double fpsLimitInterval = 1.0 / 55.0; + +Eina_Bool +OnIdleLoopIterate(void* pData) +{ + _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); + +// PRINT("OnIdleLoopIterate()\n"); + + + if (!pDisplayManager) + { + return ECORE_CALLBACK_CANCEL; // for remove callback + } + + Tizen::Ui::Animations::_AnimationManager* pAnimationManager = Tizen::Ui::Animations::_AnimationManager::GetInstance(); + + if (!pAnimationManager) + { + return ECORE_CALLBACK_CANCEL; // for remove callback + } + + //CHECK ME : how about the performance? +// double currentTime = ecore_time_get(); +// static double prevFlushTime = 0; + +// if (currentTime - prevFlushTime >= fpsLimitInterval * 0.99) + { + pAnimationManager->ProcessAnimationTick(); + +// prevFlushTime = currentTime; + + pDisplayManager->RenderAll(); + + pDisplayManager->Flush(); + } + + return ECORE_CALLBACK_RENEW; +} + +// WARNING: Without this, idle-enterer will be called after evas destroyed which may cause crash while accessing ecore-evas. +void +OnEcoreEvasFree(Ecore_Evas* pEcoreEvas) +{ + ecore_evas_manual_render_set(pEcoreEvas, EINA_FALSE); +} +#endif + + +#ifdef _NEED_DAMAGE_HANDER_ + +Eina_Bool +OnXWindowDamaged(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo) +{ +#if 1 + _Ecore_X_Event_Window_Damage* pEvent = (_Ecore_X_Event_Window_Damage*)pEventInfo; + + if (pData) + { + _EflLayer* pLayer = (_EflLayer*)pData; + + if (pLayer->GetEvas() && pLayer->GetEcoreEvas() && pEvent->win == ecore_evas_window_get(pLayer->GetEcoreEvas())) + { + FloatRectangle bounds = pLayer->GetBounds(); + + evas_damage_rectangle_add(pLayer->GetEvas(), 0, 0, (int)bounds.width, (int)bounds.height); + pLayer->SetEvasRenderNeeded(); + + _DisplayManager::GetInstance()->AddWakeUpEvent(); + + PRINT("OnXWindowDamaged(%p)[%d,%d,%d,%d]------------\n", pLayer->GetEvas(), pEvent->x, pEvent->y, pEvent->w, pEvent->h); + } + } +#endif + return EINA_TRUE; +} + +Eina_Bool +OnXWindowConfigured(void* pData, int type, void* pEventInfo) +{ +#if 0 + _Ecore_X_Event_Window_Configure* pEvent = (_Ecore_X_Event_Window_Configure*)pEventInfo; + + if (pData) + { + _EflLayer* pLayer = (_EflLayer*)pData; + + if (pLayer->GetEvas() && pLayer->GetEcoreEvas() && pEvent->win == ecore_evas_window_get(pLayer->GetEcoreEvas())) + { + FloatRectangle bounds = pLayer->GetBounds(); + + evas_damage_rectangle_add(pLayer->GetEvas(), 0, 0, (int)bounds.width, (int)bounds.height); + pLayer->SetEvasRenderNeeded(); + + _DisplayManager::GetInstance()->AddWakeUpEvent(); + + PRINT("OnXWindowConfigured(%p)[%d,%d,%d,%d]------------\n", pLayer->GetEvas(), pEvent->x, pEvent->y, pEvent->w, pEvent->h); + } + } +#endif + + return EINA_TRUE; +} + +Eina_Bool +OnXWindowHidden(void* pData, int type, void* pEventInfo) +{ + _Ecore_X_Event_Window_Hide* pEvent = (_Ecore_X_Event_Window_Hide*)pEventInfo; + + if (!pData) + { + return EINA_TRUE; + } + + _EflLayer* pLayer = (_EflLayer*)pData; + PRINT("############ Hidden (%p, 0x%x) \n" , pLayer, pEvent->win); + + if (pLayer->GetEvas() && pLayer->GetEcoreEvas() && pEvent->win == ecore_evas_window_get(pLayer->GetEcoreEvas())) + { + PRINT("############ Hidden (%p) -> EventDone() \n" , pData); + pLayer->SetVisibilityChangeCompleted(); + _DisplayManager::GetInstance()->AddWakeUpEvent(); + } + + return EINA_TRUE; +} + +Eina_Bool +OnXWindowShown(void* pData, int type, void* pEventInfo) +{ + _Ecore_X_Event_Window_Show* pEvent = (_Ecore_X_Event_Window_Show*)pEventInfo; + + if (!pData) + { + return EINA_TRUE; + } + + _EflLayer* pLayer = (_EflLayer*)pData; + PRINT("############ Shown (%p, 0x%x) \n" , pLayer, pEvent->win); + + if (pLayer->GetEvas() && pLayer->GetEcoreEvas() && pEvent->win == ecore_evas_window_get(pLayer->GetEcoreEvas())) + { + PRINT("############ Shown (%p) -> EventDone() \n" , pData); + + FloatRectangle bounds = pLayer->GetBounds(); + + evas_damage_rectangle_add(pLayer->GetEvas(), 0, 0, (int)bounds.width, (int)bounds.height); + + pLayer->SetVisibilityChangeCompleted(); + _DisplayManager::GetInstance()->AddWakeUpEvent(); + } + + return EINA_TRUE; +} + +#endif + +void +PreRenderCallback(Ecore_Evas* ee) +{ + _EflLayer* pEflLayer = (_EflLayer*)ecore_evas_data_get(ee, "EflLayer"); + + if (pEflLayer && pEflLayer->GetRootVisualElement()) + { +#ifndef VE_VSYNC_UPDATE + static double loopTime = 0; + double prevLoopTime = loopTime; + loopTime = ecore_loop_time_get(); + if (loopTime != prevLoopTime) + { + _AnimationManager::GetInstance()->ProcessAnimationTick(); + } +#endif + + _DisplayManager::GetInstance()->Render(*pEflLayer->GetRootVisualElement()); + } +} + +void +PostRenderCallback(Ecore_Evas* ee) +{ + _EflLayer* pEflLayer = (_EflLayer*)ecore_evas_data_get(ee, "EflLayer"); + + if (pEflLayer && pEflLayer->GetRootVisualElement()) + { + _DisplayManager::GetInstance()->PostRender(*pEflLayer->GetRootVisualElement()); + } +} + +} + +namespace Tizen { namespace Ui { namespace Animations +{ + +int _EflLayer::_countOfLayer = 0; + +_EflLayer::_EflLayer(void) + : _pRootVisualElement(null) + , _pEvas(null) + , _pEcoreEvas(null) + , _pWindow(null) + , _pOnWindowDamagedHandler(null) + , _pOnWindowConfiguredHandler(null) + , _pOnWindowHideHandler(null) + , _pOnWindowShowHandler(null) + , _needEvasRender(0) + , _needShowStateChangeRequest(false) + , _isShow(false) + , _isVisibilityChangeInProgress(false) + , _needAsyncVisibilityChangeRequest(true) +{ + _countOfLayer++; +} + + +_EflLayer::~_EflLayer(void) +{ + _countOfLayer--; +#ifdef VE_VSYNC_UPDATE + ecore_evas_manual_render_set(_pEcoreEvas, EINA_FALSE); + + if(_countOfLayer <= 0) + { + ecore_idle_enterer_del(__pOnIdleLoopIterator); + __pOnIdleLoopIterator = null; + + } +#ifdef _NEED_DAMAGE_HANDER_ + if (_pOnWindowDamagedHandler) + { + ecore_event_handler_del(_pOnWindowDamagedHandler); + _pOnWindowDamagedHandler = null; + } + + if (_pOnWindowConfiguredHandler) + { + ecore_event_handler_del(_pOnWindowConfiguredHandler); + _pOnWindowConfiguredHandler = null; + } + if (_pOnWindowHideHandler) + { + ecore_event_handler_del(_pOnWindowHideHandler); + _pOnWindowHideHandler = null; + } + + if (_pOnWindowShowHandler) + { + ecore_event_handler_del(_pOnWindowShowHandler); + _pOnWindowShowHandler = null; + } +#endif + +#endif + + + if (_pEcoreEvas) + { + ecore_evas_callback_pre_render_set(_pEcoreEvas, null); + ecore_evas_callback_post_render_set(_pEcoreEvas, null); + _pEcoreEvas = null; + } + + if (_pWindow) + { + evas_object_del(_pWindow); + } + _pWindow = null; + _pEvas = null; + +} + +result +_EflLayer::OnConstructed(void) +{ + //Ecore_X_Window window = 0; + + if (_pWindow) + { + return E_OBJ_ALREADY_EXIST; + } + + _pWindow = elm_win_add(NULL, NULL, ELM_WIN_BASIC); + + SysTryReturnResult(NID_UI, _pWindow, E_SYSTEM, "A system error has been occurred."); + + result r = Initialize(_pWindow); + if (r != E_SUCCESS) + { + evas_object_del(_pWindow); + return E_SYSTEM; + } + + Ecore_X_Window window = (Ecore_X_Window) ecore_evas_window_get(_pEcoreEvas); + SysTryReturnResult(NID_UI, window != 0,E_SYSTEM, "A system error has been occurred."); + +#ifdef VE_VSYNC_UPDATE + ecore_x_vsync_animator_tick_source_set(window); + ecore_evas_manual_render_set(_pEcoreEvas, EINA_TRUE); + ecore_evas_callback_pre_free_set(_pEcoreEvas, OnEcoreEvasFree); +#endif + + ecore_x_netwm_window_type_set(window, ECORE_X_WINDOW_TYPE_NORMAL); + ecore_x_e_virtual_keyboard_state_set(window, (Ecore_X_Virtual_Keyboard_State)ELM_WIN_KEYBOARD_UNKNOWN); + + return E_SUCCESS; +} + + +result +_EflLayer::Initialize(Evas_Object* pWindow) +{ + _pWindow = pWindow; + SysTryCatch(NID_UI, _pWindow, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred."); + _pEvas = evas_object_evas_get(_pWindow); + SysTryCatch(NID_UI, _pEvas, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred."); + _pEcoreEvas = ecore_evas_ecore_evas_get(_pEvas); + SysTryCatch(NID_UI, _pEcoreEvas, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred."); + +// CHECK ME: Is this needed for GL mode? +#ifdef _NEED_DAMAGE_HANDER_ + if(_pOnWindowDamagedHandler == null) + { + _pOnWindowDamagedHandler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DAMAGE, OnXWindowDamaged, this); + } + + if (_pOnWindowConfiguredHandler == null) + { + _pOnWindowConfiguredHandler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CONFIGURE, OnXWindowConfigured, this); + } + + if (_pOnWindowHideHandler == null) + { + _pOnWindowHideHandler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE, OnXWindowHidden, this); + } + + if (_pOnWindowShowHandler == null) + { + _pOnWindowShowHandler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, OnXWindowShown, this); + } + +#endif + +#ifdef VE_VSYNC_UPDATE + if(__pOnIdleLoopIterator == null) + { + __pOnIdleLoopIterator = ecore_idle_enterer_add(OnIdleLoopIterate, null); + } +#else + ecore_evas_callback_pre_render_set(_pEcoreEvas, PreRenderCallback); + ecore_evas_callback_post_render_set(_pEcoreEvas, PostRenderCallback); +#endif + + ecore_evas_data_set(_pEcoreEvas, "EflLayer", this); + + return E_SUCCESS; + +CATCH: + _pWindow = null; + _pEcoreEvas = null; + _pEvas = null; + _pRootVisualElement = null; + return E_SYSTEM; +} + +result +_EflLayer::Configure(_RootVisualElement& rootElement) +{ + _EflNode* pNode = dynamic_cast<_EflNode*>(rootElement.GetNativeNode()); + if (pNode) + { + _pRootVisualElement = &rootElement; + + return pNode->ReConstruct(*this); + } + + return E_SYSTEM; +} + +result +_EflLayer::SetBounds(const FloatRectangle& bounds) +{ + if (_pWindow) + { + evas_object_move(_pWindow, bounds.x, bounds.y); + evas_object_resize(_pWindow, bounds.width, bounds.height); + } + return E_SUCCESS; +} + +FloatRectangle +_EflLayer::GetBounds(void) const +{ + if (_pWindow) + { + int x = 0; + int y = 0; + int w = 0; + int h = 0; + evas_object_geometry_get(_pWindow, &x, &y, &w, &h); + + return FloatRectangle(x, y, w, h); + } + + return FloatRectangle(); +} + +result +_EflLayer::SetShowState(bool show) +{ +#ifdef ECORE_EVAS_ASYNC_VISIBILITY_BUG_HACK + if (_isShow == show) + { + return E_SUCCESS; + } + + if (_needShowStateChangeRequest) + { + // Show State is not applied yet. Need cancel the visibility change request. + _needShowStateChangeRequest = false; + PRINT("Cancel SetShowState request (%d)\n", show); + } + else + { + _needShowStateChangeRequest = true; + _DisplayManager::GetInstance()->AddWakeUpEvent(); + PRINT("SetShowState request (%d)\n", show); + } + + _isShow = show; +#else + if (_pWindow) + { + if (show) + { + evas_object_show(_pWindow); + } + else + { + evas_object_hide(_pWindow); + } + } +#endif + + return E_SUCCESS; +} + +bool +_EflLayer::GetShowState(void) const +{ + return _isShow; +} + +void +_EflLayer::SetOpacity(float opacity) +{ + if (!_pWindow) + return; + + if (opacity > 1.0f) + { + opacity = 1.0f; + } + else if(opacity<0.0f) + { + opacity = 0.0f; + } + + if (_FloatCompare(opacity, 1.0f)) + { + ecore_evas_alpha_set(_pEcoreEvas, EINA_FALSE); + int r,g,b,a; + evas_object_color_get(_pWindow, &r, &g, &b, &a); + evas_object_color_set(_pWindow, r, g, b, 255); + + } + else if (opacity < 1.0f) + { + + ecore_evas_alpha_set(_pEcoreEvas, EINA_TRUE); + + int r,g,b,a; + evas_object_color_get(_pWindow, &r, &g, &b, &a); + a = opacity*255; + evas_object_color_set(_pWindow, r, g, b, a); + } +} + +float +_EflLayer::GetOpacity(void) +{ + if (!_pWindow) + return 0.0f; + + int r,g,b,a; + evas_object_color_get(_pWindow, &r, &g, &b, &a); + if (a > 255) + return 1.0f; + + return a / 255.0f; + +} + +void +_EflLayer::Flush(void) +{ + if (_pEcoreEvas) + { + PRINT("Flush StateChange(%p) - is Pending(%d) \n",this , _isVisibilityChangeInProgress); + + if (_needShowStateChangeRequest && (!_needAsyncVisibilityChangeRequest || !_isVisibilityChangeInProgress)) + { + if (_isShow) + { + evas_object_show(_pWindow); + + // QUICK-DIRTY HACK TO BE REMOVED !!! +#ifdef ECORE_EVAS_ASYNC_VISIBILITY_BUG_HACK + ecore_x_sync(); + ecore_x_flush(); + usleep(30 * 1000); + + FloatRectangle bounds = GetBounds(); + evas_damage_rectangle_add(_pEvas, 0, 0, (int)bounds.width, (int)bounds.height); +#endif + + PRINT("evas_object_show(%p) \n", this); + } + else + { + evas_object_hide(_pWindow); + PRINT("evas_object_hide(%p) \n", this); + } + + _isVisibilityChangeInProgress = true; + _needShowStateChangeRequest = false; + } + + if (_needEvasRender > 0) + { + _DisplayManager::GetInstance()->AddWakeUpEvent(); + _needEvasRender--; + } + + + ecore_evas_manual_render(_pEcoreEvas); + } + +#if 0 + if (_pEvas) + { + if(show) + { + evas_render_idle_flush(_pEvas); + } + else + { + evas_render(_pEvas); + } + } +#endif +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_EflNode.cpp b/src/ui/animations/FUiAnim_EflNode.cpp new file mode 100644 index 0000000..aa28d3c --- /dev/null +++ b/src/ui/animations/FUiAnim_EflNode.cpp @@ -0,0 +1,1642 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_EflNode.cpp + * @brief This file contains implementation of _EflNode class + * + * This file contains implementation _EflNode class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FUi_CoordinateSystemUtils.h" +#include "FUi_EcoreEvas.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUiAnim_Debug.h" +#include "FUiAnim_EflLayer.h" +#include "FUiAnim_EflNode.h" +#include "FUiAnim_MatrixUtil.h" +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_VisualElementSurfaceImpl.h" +#include "FUiAnim_RootVisualElement.h" + +#include "FUiAnim_EflVisualElementSurfaceImpl.h" + +// for capture +#include +#include + +using namespace std; +using namespace Tizen; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace +{ + +void EvasSmartObjectShowChildren(Evas_Object* pSmartObject); +void EvasSmartObjectHideChildren(Evas_Object* pSmartObject); +void EvasSmartObjectHideAllChildren(Evas_Object* pSmartObject); + +Evas_Smart_Class smartClassForVisualElement = +{ + "visual_element", // name + 4, // version + null, // add + null, // del + null, // move + null, // resize + EvasSmartObjectShowChildren, // show + EvasSmartObjectHideChildren, // hide + null, // color_set + null, // clip_set + null, // clip_unset + null, // calculate + null, // member_add + null, // member_del + null, // parent + null, // call-backs + null, // interfaces + null, // data +}; + +Evas_Smart_Class smartClassForImageHolder = +{ + "image_holder", // name + 4, // version + null, // add + null, // del + null, // move + null, // resize + EvasSmartObjectShowChildren, // show + EvasSmartObjectHideChildren, // hide + null, // color_set + null, // clip_set + null, // clip_unset + null, // calculate + null, // member_add + null, // member_del + null, // parent + null, // call-backs + null, // interfaces + null, // data +}; + +void +EvasSmartObjectShowChildren(Evas_Object* pSmartObject) +{ + Eina_List* pChildrenList = evas_object_smart_members_get(pSmartObject); + if (likely(pChildrenList)) + { + void* pEvasObject = null; + EINA_LIST_FREE(pChildrenList, pEvasObject) + { + if (likely(pEvasObject) && unlikely(evas_object_type_get((Evas_Object*)pEvasObject) != smartClassForVisualElement.name)) + { + evas_object_show((Evas_Object*)pEvasObject); + + } + } + } +} + +void +EvasSmartObjectHideChildren(Evas_Object* pSmartObject) +{ + // hide objects only for this node + Eina_List* pChildrenList = evas_object_smart_members_get(pSmartObject); + if (likely(pChildrenList)) + { + void* pEvasObject = null; + EINA_LIST_FREE(pChildrenList, pEvasObject) + { + if (likely(pEvasObject) && unlikely(evas_object_type_get((Evas_Object*)pEvasObject) != smartClassForVisualElement.name)) + { + evas_object_hide((Evas_Object*)pEvasObject); + } + } + } +} + +void +EvasSmartObjectHideAllChildren(Evas_Object* pSmartObject) +{ + // hide all descendants + Eina_List* pChildrenList = evas_object_smart_members_get(pSmartObject); + if (likely(pChildrenList)) + { + void* pEvasObject = null; + EINA_LIST_FREE(pChildrenList, pEvasObject) + { + if (likely(pEvasObject)) + { + evas_object_hide((Evas_Object*)pEvasObject); + } + } + } +} + +inline void +NormalizeUniformRectangle(Rectangle& rectangle, int width, int height) +{ + if (unlikely(width <= 0) || unlikely(height <= 0)) + { + return; + } + + if (unlikely(rectangle.x < 0)) + { + rectangle.x = width - ((-rectangle.x) % width); + } + + if (unlikely(rectangle.y < 0)) + { + rectangle.y = height - ((-rectangle.y) % height); + } +} + +inline Evas_Render_Op +GetRenderOperation(Tizen::Ui::Animations::VisualElement::RenderOperation renderOperation) +{ + switch (renderOperation) + { + default: + case Tizen::Ui::Animations::VisualElement::RENDER_OPERATION_BLEND: + return EVAS_RENDER_BLEND; + + case Tizen::Ui::Animations::VisualElement::RENDER_OPERATION_COPY: + return EVAS_RENDER_COPY; + } +} + +//Evas* __pEvas = null; +}; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +Evas_Smart* _EflNode::__pStaticSmartClass = null; +Evas_Smart* _EflNode::__pStaticSmartClassForImageHolder = null; + +_EflNode::_EflNode(void) + : __pSurface(null) + , __pSharedSurface(null) + , __pEvas(null) + , __pSmartObject(null) + , __pClipObject(null) + , __pRectangleObject(null) + , __pImageHolder(null) + , __pNativeSmartObject(null) + , __pMap(null) + , __mapUsed(false) + , __renderOperation(VisualElement::RENDER_OPERATION_BLEND) + , __needEvasObjectSync(false) + , __realBounds(0.0f, 0.0f, 0.0f, 0.0f) + , __backgroundColor(0.0f, 0.0f, 0.0f, 0.0f) // fully transparent rectangle object by default + , __pLayer(null) +{ +} + +_EflNode::~_EflNode(void) +{ + Destruct(); +} + +result +_EflNode::Construct(void) +{ +#if 0 + if (__pSmartObject || __pMap) + { + return E_INVALID_STATE; + } + + if (!__pEvas) + { + // todo: need refactoring ! + Tizen::Ui::_EcoreEvasMgr* pMgr = Tizen::Ui::GetEcoreEvasMgr(); + + if (pMgr && pMgr->GetEcoreEvas()) + { + __pEvas = pMgr->GetEcoreEvas()->GetEvas(); + } + + if (!__pEvas) + { + return E_SYSTEM; + } + } + + + if (!__pStaticSmartClass) + { + __pStaticSmartClass = evas_smart_class_new(&smartClassForVisualElement); // TODO: no need to delete ??? + } + + __pSmartObject = evas_object_smart_add(__pEvas, __pStaticSmartClass); + if (!__pSmartObject) + { + goto failure; + } + + //evas_object_pass_events_set(__pSmartObject, EINA_TRUE); + evas_object_propagate_events_set(__pSmartObject, EINA_TRUE); + //evas_object_propagate_events_set(__pSmartObject, EINA_FALSE); + + evas_object_show(__pSmartObject); + +// __pClipObject = evas_object_rectangle_add(__pEvas); +// if (!__pClipObject) +// goto failure; +// +// +// evas_object_smart_member_add(__pClipObject,__pSmartObject); +// evas_object_lower(__pClipObject); +// +// evas_object_pass_events_set(__pClipObject, EINA_TRUE); + + // Create map for 3D + __pMap = evas_map_new(4); + if (!__pMap) + { + goto failure; + } + + evas_map_alpha_set(__pMap, EINA_TRUE); + evas_map_smooth_set(__pMap, EINA_TRUE); + + return E_SUCCESS; + +failure: + if (__pSmartObject) + { + evas_object_del(__pSmartObject); + } + + __pSmartObject = null; + +// if (__pClipObject) +// evas_object_del(__pClipObject); +// +// __pClipObject = null; + + if (__pMap) + { + evas_map_free(__pMap); + } + + __pMap = null; + + return E_SYSTEM; +#else + return E_SUCCESS; +#endif +} + +result +_EflNode::RebuildIfNeeded(const _INativeNode& parent) +{ + _EflNode* pParent = dynamic_cast<_EflNode*>(const_cast<_INativeNode*>(&parent)); + if (!pParent) + { + return E_INVALID_ARG; + } + if (pParent->__pLayer) + { + return ReConstruct(*pParent->__pLayer); + } + return E_INVALID_STATE; +// __pLayer = pParent->pLayer; + //return ReConstruct(pParent->__pEvas); +} + +result +_EflNode::ReConstruct(const _NativeLayer& layer) +{ + _EflLayer* pLayer = dynamic_cast<_EflLayer*>(const_cast<_NativeLayer*>(&layer)); + if (!pLayer) + { + return E_INVALID_ARG; + } + __pLayer = pLayer; + return ReConstruct(pLayer->GetEvas()); +} + +result +_EflNode::ReConstruct(const Evas* pEvas) +{ + if (pEvas == null) + { + return E_INVALID_ARG; + } + + Destruct(); + + __pEvas = const_cast(pEvas); + + + if (!__pStaticSmartClass) + { + __pStaticSmartClass = evas_smart_class_new(&smartClassForVisualElement); // TODO: no need to delete ??? + } + + __pSmartObject = evas_object_smart_add(__pEvas, __pStaticSmartClass); + if (!__pSmartObject) + { + goto failure; + } + + if (!__pStaticSmartClassForImageHolder) + { + __pStaticSmartClassForImageHolder = evas_smart_class_new(&smartClassForImageHolder); // TODO: no need to delete ??? + } + + //evas_object_pass_events_set(__pSmartObject, EINA_TRUE); + evas_object_propagate_events_set(__pSmartObject, EINA_TRUE); + //evas_object_propagate_events_set(__pSmartObject, EINA_FALSE); + + if (__pNativeSmartObject) + { + evas_object_smart_member_add(__pNativeSmartObject, __pSmartObject); + AdjustEvasObjectOrder(); + } + + evas_object_show(__pSmartObject); + +// __pClipObject = evas_object_rectangle_add(pEvas); +// if (!__pClipObject) +// goto failure; +// +// +// evas_object_smart_member_add(__pClipObject,__pSmartObject); +// evas_object_lower(__pClipObject); +// +// evas_object_pass_events_set(__pClipObject, EINA_TRUE); + + // Create map for 3D + if (__pMap) + { + evas_map_free(__pMap); + } + __pMap = evas_map_new(4); + if (!__pMap) + { + goto failure; + } + + evas_map_alpha_set(__pMap, EINA_TRUE); + evas_map_smooth_set(__pMap, EINA_TRUE); + + return E_SUCCESS; + +failure: + __pEvas = null; + + if (__pSmartObject) + { + evas_object_del(__pSmartObject); + } + + __pSmartObject = null; + +// if (__pClipObject) +// evas_object_del(__pClipObject); +// +// __pClipObject = null; + + if (__pMap) + { + evas_map_free(__pMap); + } + + __pMap = null; + + return E_SYSTEM; +} + +result +_EflNode::Destruct(void) +{ + __pEvas = null; + if (__pSmartObject) + { + evas_object_del(__pSmartObject); + __pSmartObject = null; + } + + if (__pClipObject) + { + evas_object_del(__pClipObject); + __pClipObject = null; + } + + if (__pRectangleObject) + { + evas_object_del(__pRectangleObject); + __pRectangleObject = null; + } + + if (__pMap) + { + evas_map_free(__pMap); + __pMap = null; + } + + if (__pSurface) + { + delete __pSurface; + __pSurface = null; + } + + if (__pSharedSurface) + { + delete __pSharedSurface; + __pSharedSurface = null; + } + + if (__pImageHolder) + { + evas_object_del(__pImageHolder); + } + + if (unlikely(__pNativeSmartObject)) + { + evas_object_smart_member_del(__pNativeSmartObject); + //__pNativeSmartObject = null; + } + + return E_SUCCESS; +} + +Evas* +_EflNode::GetEvas(void) const +{ + return __pEvas; +} + +Handle +_EflNode::GetGroupContainer(void) const +{ + return reinterpret_cast< Handle >(__pSmartObject); +} + +void +_EflNode::AdjustEvasObjectOrder(void) +{ + + if (__pNativeSmartObject) + evas_object_lower(__pNativeSmartObject); +// evas_object_raise(__pNativeSmartObject); + +} + +void +_EflNode::SetNativeObject(VisualElement& element, Evas_Object* pNativeObject) +{ + if (unlikely(__pNativeSmartObject != pNativeObject)) + { + if (unlikely(__pNativeSmartObject)) + { + evas_object_smart_member_del(__pNativeSmartObject); + } + + __pNativeSmartObject = pNativeObject; + + if (__pNativeSmartObject) + { + evas_object_smart_member_add(__pNativeSmartObject, __pSmartObject); + } + } + + AdjustEvasObjectOrder(); + + + const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES + | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY + | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY + | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS; + + _VisualElementImpl* pElementImpl = _VisualElementImpl::GetInstance(element); + if (likely(pElementImpl)) + { + pElementImpl->InvalidateHierarchyProps(nativeProps, false, false); + } +} + +void +_EflNode::AddNativeSmartObject(VisualElement& element, Evas_Object* pSmartObject) +{ + SetNativeObject(element, pSmartObject); +} + +void +_EflNode::RemoveNativeObject(void) +{ + __pNativeSmartObject = null; +} + +Evas_Object* +_EflNode::GetNativeObject(void) const +{ + return __pNativeSmartObject; +} + +result +_EflNode::InsertChild(_INativeNode& child, const _INativeNode* pReference, bool above) +{ + _EflNode& nativeChild = dynamic_cast< _EflNode& >(child); + const _EflNode* pNativeReference = dynamic_cast< const _EflNode* >(pReference); + + RemoveChild(nativeChild); + + if (!__pSmartObject) + { + return E_INVALID_STATE; + } + + evas_object_smart_member_add(nativeChild.__pSmartObject, __pSmartObject); + + // The order of evas objects should be as follows: + // [native smart object] [image/image-holder/rectangle/clipper] [child smart object]* + + if (likely(pNativeReference)) + { + if (likely(above)) + { + evas_object_stack_above(nativeChild.__pSmartObject, pNativeReference->__pSmartObject); + } + else + { + evas_object_stack_below(nativeChild.__pSmartObject, pNativeReference->__pSmartObject); + } + } + else + { + if (likely(above)) + { + evas_object_raise(nativeChild.__pSmartObject); + } + else + { + Evas_Object* pRefObject = null; + + + if (likely(__pSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*__pSurface))) + { + pRefObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle()); + } + else if (likely(__pRectangleObject)) + { + pRefObject = __pRectangleObject; + } + else if (likely(__pImageHolder)) + { + pRefObject = __pImageHolder; + } + + if (likely(pRefObject)) + { + evas_object_stack_above(nativeChild.__pSmartObject, pRefObject); + } + else + { + evas_object_lower(nativeChild.__pSmartObject); + } + } + } + + AdjustEvasObjectOrder(); + + return E_SUCCESS; +} + +result +_EflNode::RemoveChild(_INativeNode& child) +{ + _EflNode& nativeChild = dynamic_cast< _EflNode& >(child); + + // WARNING: + // Perform recursive hiding evas objects ! + // After removing a child, it is not managed by visual element. + // Hence, because all descendants of it will not be hided automatically, it is needed to + // hide all descendants of it (or need adding damage region) + smartClassForVisualElement.hide = EvasSmartObjectHideAllChildren; + evas_object_hide(nativeChild.__pSmartObject); + smartClassForVisualElement.hide = EvasSmartObjectHideChildren; + + evas_object_smart_member_del(nativeChild.__pSmartObject); + +#if 0 + if (nativeChild.__pClipObject) + evas_object_hide((Evas_Object*)nativeChild.__pClipObject); + + if (nativeChild.__pRectangleObject) + evas_object_hide((Evas_Object*)nativeChild.__pRectangleObject); + + if (nativeChild.__pSurface && nativeChild.__pSurface->GetNativeHandle()) + evas_object_hide((Evas_Object*)nativeChild.__pSurface->GetNativeHandle()); +#endif + + return E_SUCCESS; +} + +result +_EflNode::SetFlushNeeded(void) +{ +#if 0 + evas_damage_rectangle_add( + __pEvas, + static_cast< int >(floorf(dirtyRectangle.x)), + static_cast< int >(floorf(dirtyRectangle.y)), + static_cast< int >(ceilf(dirtyRectangle.width)), + static_cast< int >(ceilf(dirtyRectangle.height)) + ); +#endif + + if (!__pSurface || !_VisualElementSurfaceImpl::GetInstance(*__pSurface)) + { + return E_INVALID_STATE; + } +#if 0 + evas_object_image_pixels_dirty_set(reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle()), true); +#else + + Evas_Object* pImageObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle()); + + if (pImageObject) + { + int imageWidth = 0; + int imageHeight = 0; + + evas_object_image_data_set(pImageObject, evas_object_image_data_get(pImageObject, 1)); + + evas_object_image_size_get(pImageObject, &imageWidth, &imageHeight); + evas_object_image_data_update_add(pImageObject, 0, 0, imageWidth, imageHeight); + } + +#endif + + if(__pLayer) + { + __pLayer->SetFlushNeeded(); + } + +#if 0 + //contentChanged = false; + bool contentChanged = false; + + if (contentChanged) + { + evas_object_image_pixels_dirty_set((Evas_Object*) _VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle(), true); + } + else + { + evas_object_image_data_update_add( + (Evas_Object*) _VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle(), + dirtyRectangle.x, + dirtyRectangle.y, + dirtyRectangle.width, + dirtyRectangle.height + ); + +#if 1 + evas_object_image_data_update_add( + (Evas_Object*) _VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle(), + dirtyRectangle.x, + dirtyRectangle.y, + dirtyRectangle.width, + dirtyRectangle.height + ); +#endif + } + +#endif + + return E_SUCCESS; +} + +result +_EflNode::Flush(void) +{ +#ifndef VE_VSYNC_UPDATE + if(__pLayer) + { + __pLayer->Flush(); + } +// ecore_evas_manual_render(ecore_evas_ecore_evas_get(__pEvas)); +#endif + + return E_SUCCESS; +} + +_Colorf +_EflNode::GetBackgroundColor(void) const +{ +// if (!__pRectangleObject) +// return _Colorf(); // CHECKME: Default background color ? + + return __backgroundColor; +} + +result +_EflNode::SetBackgroundColor(const _Colorf& backgroundColor) +{ +// if (!__pRectangleObject) +// return E_INVALID_STATE; + + __backgroundColor = backgroundColor; + + return E_SUCCESS; +} + +bool +_EflNode::AdjustImageHolder(bool useHolder) +{ + if (unlikely(!__pSurface)) + { + return false; + } + + Evas_Object* pImageObject = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle()); + if (unlikely(!pImageObject)) + { + return false; + } + + if (unlikely(useHolder)) + { + if (likely(!__pImageHolder)) + { + __pImageHolder = evas_object_smart_add(__pEvas, __pStaticSmartClassForImageHolder); + if (unlikely(!__pSmartObject)) + { + SysLog(NID_UI_ANIM, "Smart object cannot be created."); + return false; + } + + evas_object_propagate_events_set(__pImageHolder, EINA_TRUE); + evas_object_smart_member_add(pImageObject, __pImageHolder); + + evas_object_smart_member_add(__pImageHolder, __pSmartObject); + evas_object_lower(__pImageHolder); + AdjustEvasObjectOrder(); + + if (evas_object_visible_get(__pSmartObject)) + { + evas_object_show(__pImageHolder); + } + else + { + evas_object_hide(__pImageHolder); + } + + return true; + } + } + else + { + if (likely(__pImageHolder)) + { + evas_object_smart_member_add(pImageObject, __pSmartObject); + evas_object_lower(pImageObject); + AdjustEvasObjectOrder(); + + evas_object_del(__pImageHolder); + __pImageHolder = null; + + return true; + } + } + + return false; +} + +result +_EflNode::Reconfigure(VisualElementSurface* pSurface, _VisualElementImpl& element, bool surfaceOnly) +{ + Evas_Object* pImageObjectOrg = null; + Evas_Object* pImageObjectNew = null; + int imageWidth = 0; + int imageHeight = 0; + + const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES + | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY + | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY + | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS; + int& invalidatedNativeProps = element.__pSharedData->invalidatedNativeProps; + + invalidatedNativeProps &= nativeProps; + + if (likely(pSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*pSurface))) + { + pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*pSurface)->GetNativeHandle()); + } + + if (likely(__pSharedSurface) && likely(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface))) + { + pImageObjectOrg = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetNativeHandle()); + } + + + if (likely(pImageObjectNew)) + { + bool createNewObject = true; + + evas_object_image_size_get(pImageObjectNew, &imageWidth, &imageHeight); + + if (likely(__pSurface)) + { + // if the surfaces are same, change the size + if (likely(pImageObjectNew == pImageObjectOrg)) + { + createNewObject = false; + } + // if the surface is changed, delete old surface + else + { + delete __pSharedSurface; + __pSharedSurface = null; + } + } + + // create new surface + if (unlikely(createNewObject)) + { + + unique_ptr pNewSharedSurface(new (std::nothrow) VisualElementSurface(*pSurface)); + SysTryReturnResult(NID_UI_ANIM, pNewSharedSurface, E_OUT_OF_MEMORY, "Memory allocation failed."); + + _EflVisualElementSurfaceImpl* pEflVisualElementSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface)); + if (pEflVisualElementSurfaceImpl && pEflVisualElementSurfaceImpl->__pBuffer == null) + { + unique_ptr pNewSurface(new (std::nothrow) VisualElementSurface(*pSurface)); + SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed."); + + if (__pSurface) + { + delete __pSurface; + __pSurface = null; + } + __pSurface = pNewSurface.release(); + } + else + { + unique_ptr pNewSurface(_VisualElementSurfaceImpl::CreateSurfaceN((Handle)__pLayer, Dimension(1, 1))); + SysTryReturnResult(NID_UI_ANIM, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed."); + + if (__pSurface) + { + delete __pSurface; + __pSurface = null; + } + __pSurface = pNewSurface.release(); + + if (!element.GetModel()->__imageFilePath.IsEmpty() && _VisualElementSurfaceImpl::GetInstance(*__pSurface)) + { + _VisualElementSurfaceImpl::GetInstance(*__pSurface)->SetImage(element.GetModel()->__imageFilePath); + } + } + + if (__pSharedSurface) + { + delete __pSharedSurface; + __pSharedSurface = null; + } + __pSharedSurface = pNewSharedSurface.release(); + + Evas_Object* pImageObject = null; + if (_VisualElementSurfaceImpl::GetInstance(*__pSurface)) + { + pImageObject = (Evas_Object*)_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle(); + + if (likely(pImageObject)) + { + evas_object_anti_alias_set(pImageObject, EINA_TRUE); + + evas_object_smart_member_add(pImageObject, __pSmartObject); + evas_object_lower(pImageObject); + AdjustEvasObjectOrder(); + + if (evas_object_visible_get(__pSmartObject)) + { + evas_object_show(pImageObject); + } + else + { + evas_object_hide(pImageObject); + } + + + _EflVisualElementSurfaceImpl* pEflVisualElementSurfaceImpl = dynamic_cast<_EflVisualElementSurfaceImpl*>(_VisualElementSurfaceImpl::GetInstance(*pSurface)); + if (pEflVisualElementSurfaceImpl && pEflVisualElementSurfaceImpl->__pBuffer != null) + { + evas_object_image_source_set(pImageObject, pImageObjectNew); + } + + //evas_object_pass_events_set(pImageObject, EINA_TRUE); + + __needEvasObjectSync = true; + invalidatedNativeProps |= nativeProps; + } + } + } + // TODO : Have surface, but not newly created + + } + else + { + // delete old surface + delete __pSurface; + __pSurface = null; + + // delete shared surface + delete __pSharedSurface; + __pSharedSurface = null; + } + + + if (likely(__pSurface && _VisualElementSurfaceImpl::GetInstance(*__pSurface))) + { + pImageObjectNew = reinterpret_cast< Evas_Object* >(_VisualElementSurfaceImpl::GetInstance(*__pSurface)->GetNativeHandle()); + + if (unlikely(__pRectangleObject)) + { + evas_object_del(__pRectangleObject); + __pRectangleObject = null; + } + } + else + { + pImageObjectNew = null; + + // WARNING: + // Newly created rectangle object must be reconfigured by VE!!! (size/pos/visibility/etc) + // + if (likely(!__pRectangleObject) && likely(element.__pSharedData->needSurface)) + { + __pRectangleObject = evas_object_rectangle_add(__pEvas); + if (likely(__pRectangleObject)) + { + //evas_object_pass_events_set(__pRectangleObject, EINA_TRUE); + evas_object_smart_member_add(__pRectangleObject, __pSmartObject); + evas_object_lower(__pRectangleObject); + AdjustEvasObjectOrder(); + + if (evas_object_visible_get(__pSmartObject)) + { + evas_object_show(__pRectangleObject); + } + else + { + evas_object_hide(__pRectangleObject); + } + + __needEvasObjectSync = true; + invalidatedNativeProps |= nativeProps; + } + } + } + + element.__pSharedData->surfaceChanged = false; + + if (surfaceOnly) + { + return E_SUCCESS; + } + + + const bool isVeVisible = element.IsVisibleI(); + const bool isEvasVisible = evas_object_visible_get(__pSmartObject); + + + // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object + if (unlikely(!isVeVisible)) + { + if (isEvasVisible) + { + evas_object_hide(__pSmartObject); + } + + invalidatedNativeProps = 0; + + goto finished; + } + else + { + if (!isEvasVisible) + { + // WARNING: + // When visibility of VE is changed into 'visible' and evas object is invisible, + // it is needed to set all evas object properties because not all properties were applied due to short-circuit optimization + // (When VE is invisible, bounds and colors are not set for optimization) + invalidatedNativeProps = nativeProps; + } + } + + // Change hierarchy properties such as bounds, clipping and map + if (likely(invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS)) || unlikely(__needEvasObjectSync)) + { + bool needResize = false; + bool needMove = false; + bool clipChanged = false; + bool needMap = false; + + Evas_Coord newX = 0; + Evas_Coord newY = 0; + Evas_Coord newW = 0; + Evas_Coord newH = 0; + + __realBounds.width = element.__alignedSize.width; + __realBounds.height = element.__alignedSize.height; + + //_VisualElementImpl::AdjustSizeForSurface(__realBounds.width, __realBounds.height); + _VisualElementCoordinateSystem::ConvertDimensionToPhysical(__realBounds.width, __realBounds.height); + + // WARNING: + // Do not use to MakeIntegralDimension. All information about coordinates(position/size) are calculated with same(point) way. + _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.width, __realBounds.height, newW, newH); + + + float clipX = 0.0f; + float clipY = 0.0f; + float clipW = 0.0f; + float clipH = 0.0f; + Evas_Object* pParentClipper = null; + + if (unlikely(element.__needTransform) || likely(element.__needClipForUntransformed)) + { + const _VisualElementImpl* pClipSource = element.GetClipSource(); + + if (likely(pClipSource)) + { + _EflNode* pParentClipNode = static_cast< _EflNode* >(pClipSource->GetNativeNode()); + if (likely(pParentClipNode)) + { + clipX = pParentClipNode->__realBounds.x; + clipY = pParentClipNode->__realBounds.y; + clipW = pParentClipNode->__realBounds.width; + clipH = pParentClipNode->__realBounds.height; + + pParentClipper = pParentClipNode->__pClipObject; + } + } + } + + + // Coordinates(including __needTransform flag) are validated by getting clip-source above + + if (likely(!element.__needTransform)) + { + __realBounds.x = element.__boundingBoxToClipSource.x; + __realBounds.y = element.__boundingBoxToClipSource.y; + _VisualElementCoordinateSystem::ConvertPointToPhysical(__realBounds.x, __realBounds.y); + + __realBounds.x += clipX; + __realBounds.y += clipY; + _VisualElementCoordinateSystem::MakeIntegralPoint(__realBounds.x, __realBounds.y, newX, newY); + +#if 0 + int evasOutputW, evasOutputH; + evas_output_size_get(__pEvas, &evasOutputW, &evasOutputH); + +// if (newX >= 480 || newY >= 800 || newX + newW < 0 || newY + newH < 0) +// if ((newX >= SCREEN_WIDTH || newY >= SCREEN_HEIGHT || newX + newW < 0 || newY + newH < 0) || + if ((newX >= evasOutputW || newY >= evasOutputH || newX + newW < 0 || newY + newH < 0) || + (likely(pParentClipper) && (newX >= clipX + clipW || newY >= clipY + clipH || newX + newW < clipX || newY + newH < clipY))) + { + if (isEvasVisible) + evas_object_hide(__pSmartObject); + + element.__pSharedData->invalidatedNativeProps = 0; + + goto finished; + } +#endif + +#if 0 + if (likely(pParentClipper)) + { + if (likely(newX >= clipX) && likely(newY >= clipY) && likely(newX + newW <= clipX + clipW) && likely(newY + newH <= clipY + clipH)) + pParentClipper = null; + } +#endif + } + else + { + float x[4]; + float y[4]; + float z[4]; + int intX[4]; + int intY[4]; + const Tizen::Graphics::FloatMatrix4& xform = element.GetMatrixToClipSource(); + + x[0] = 0.0f; + y[0] = 0.0f; + z[0] = 0.0f; + x[1] = element.__alignedSize.width; + y[1] = 0.0f; + z[1] = 0.0f; + x[2] = element.__alignedSize.width; + y[2] = element.__alignedSize.height; + z[2] = 0.0f; + x[3] = 0.0f; + y[3] = element.__alignedSize.height; + z[3] = 0.0f; + + for (int i = 0; i < 4; i++) + { + _MatrixUtilTransform(xform, &x[i], &y[i], &z[i]); + _VisualElementCoordinateSystem::ConvertPointToPhysical(x[i], y[i]); + + x[i] += clipX; + y[i] += clipY; + } + + // WARNING: + // Use surface size for UV-mapping *ONLY FOR* direct-map-on-image-object, not map-on-smart-object !!! + if (unlikely(!__pSharedSurface) || unlikely(element.__useContentBounds) || likely(__pClipObject)) + { + evas_map_point_image_uv_set(__pMap, 0, 0.0, 0.0); + evas_map_point_image_uv_set(__pMap, 1, (double)newW, 0.0); + evas_map_point_image_uv_set(__pMap, 2, (double)newW, (double)newH); + evas_map_point_image_uv_set(__pMap, 3, 0.0, (double)newH); + } + else + { + const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize()); + + evas_map_point_image_uv_set(__pMap, 0, 0.0, 0.0); + evas_map_point_image_uv_set(__pMap, 1, (double)surfaceSize.width, 0.0); + evas_map_point_image_uv_set(__pMap, 2, (double)surfaceSize.width, (double)surfaceSize.height); + evas_map_point_image_uv_set(__pMap, 3, 0.0, (double)surfaceSize.height); + } + + for (int i = 0; i < 4; i++) + { + // WARNING: Do not need integral Z ?? + _VisualElementCoordinateSystem::MakeIntegralPoint(x[i], y[i], intX[i], intY[i]); + evas_map_point_coord_set(__pMap, i, intX[i], intY[i], static_cast< int >(z[i])); + } + + + __realBounds.x = x[0]; + __realBounds.y = y[0]; + newX = intX[0]; + newY = intY[0]; + + needMap = true; + } + + // Adjust flag for bounds changing + if (unlikely(__needEvasObjectSync)) + { + needMove = true; + needResize = true; + } + else + { + Evas_Coord objX; + Evas_Coord objY; + Evas_Coord objW; + Evas_Coord objH; + + evas_object_geometry_get(__pSmartObject, &objX, &objY, &objW, &objH); + + if (likely(!needMove)) + { + needMove = (newX != objX || newY != objY); + } + + if (likely(!needResize)) + { + needResize = (newW != objW || newH != objH); + } + } + + + if (unlikely(element.__isClipChildren)) + { + if (unlikely(!__pClipObject) && likely(element.__pSharedData->needSurface)) + { + __pClipObject = evas_object_rectangle_add(__pEvas); + if (likely(__pClipObject)) + { + evas_object_smart_member_add(__pClipObject, __pSmartObject); + evas_object_lower(__pClipObject); + AdjustEvasObjectOrder(); + + evas_object_pass_events_set(__pClipObject, EINA_TRUE); + evas_object_static_clip_set(__pClipObject, 0); // CHECKME: What does this mean by ? + + if (evas_object_visible_get(__pSmartObject)) + { + evas_object_show(__pClipObject); + } + else + { + evas_object_hide(__pClipObject); + } + + needMove = true; + needResize = true; + clipChanged = true; + } + } + } + else + { + if (unlikely(__pClipObject)) + { + evas_object_del(__pClipObject); + __pClipObject = null; + clipChanged = true; + } + } + + + // WARNING: + // Update image-holder information before using it ! + // Image-Holder is needed only when using content-bounds and maps on image-object, not smart-object. + if (unlikely(AdjustImageHolder(element.__useContentBounds && !__pClipObject && needMap))) + { + needMove = true; + needResize = true; + clipChanged = true; + __needEvasObjectSync = true; + } + + + // WARNING: + // In general, changing size/position before mapping/clipping *may* improve performance, because calculating map and clip + // needs bounds information. + + // Set-up Position + if (likely(needMove)) + { + evas_object_move(__pSmartObject, newX, newY); + + if (likely(__pClipObject)) + { + evas_object_move(__pClipObject, newX, newY); + } + + if (likely(__pImageHolder)) + { + evas_object_move(__pImageHolder, newX, newY); + } + + if (likely(pImageObjectNew)) + { + evas_object_move(pImageObjectNew, newX, newY); + } + + if (unlikely(__pRectangleObject)) + { + evas_object_move(__pRectangleObject, newX, newY); + } + + if (unlikely(__pNativeSmartObject)) + { + evas_object_move(__pNativeSmartObject, newX, newY); + } + } + + // Set-up Size + if (unlikely(needResize)) + { + evas_object_resize(__pSmartObject, newW, newH); + + if (likely(__pClipObject)) + { + evas_object_resize(__pClipObject, newW, newH); + } + + if (likely(__pImageHolder)) + { + evas_object_resize(__pImageHolder, newW, newH); + } + + if (likely(pImageObjectNew)) + { + evas_object_resize(pImageObjectNew, newW, newH); + } + + if (unlikely(__pRectangleObject)) + { + evas_object_resize(__pRectangleObject, newW, newH); + } + + if (unlikely(__pNativeSmartObject)) + { + evas_object_resize(__pNativeSmartObject, newW, newH); + } + + } + + + // Set-up Clipping + if (unlikely(__needEvasObjectSync) || unlikely(clipChanged) || unlikely(evas_object_clip_get(__pSmartObject) != pParentClipper)) + { + evas_object_clip_set(__pSmartObject, pParentClipper); + + // CHECKME: + // Is it needed to set clipper for image-holder smart object ? + + if (likely(__pClipObject)) + { + evas_object_clip_set(__pClipObject, pParentClipper); + + if (unlikely(__pImageHolder)) + { + evas_object_clip_set(__pImageHolder, __pClipObject); + } + + if (likely(pImageObjectNew)) + { + evas_object_clip_set(pImageObjectNew, __pClipObject); + } + + if (unlikely(__pRectangleObject)) + { + evas_object_clip_set(__pRectangleObject, __pClipObject); + } + + if (unlikely(__pNativeSmartObject)) + { + evas_object_clip_set(__pNativeSmartObject, __pClipObject); + } + } + else + { + if (unlikely(__pImageHolder)) + { + evas_object_clip_set(__pImageHolder, pParentClipper); + } + + if (likely(pImageObjectNew)) + { + evas_object_clip_set(pImageObjectNew, pParentClipper); + } + + if (unlikely(__pRectangleObject)) + { + evas_object_clip_set(__pRectangleObject, pParentClipper); + } + + if (unlikely(__pNativeSmartObject)) + { + evas_object_clip_set(__pNativeSmartObject, pParentClipper); + } + + } + } + + + // Set-up Maps + if (unlikely(__needEvasObjectSync) || unlikely(__mapUsed != needMap) || unlikely(needMap) || unlikely(clipChanged)) + { + const bool needClipSmartMap = (__pClipObject && needMap); + const bool needClipObjectMap = (!__pClipObject && needMap); + + evas_object_map_enable_set(__pSmartObject, needClipSmartMap); + evas_object_map_set(__pSmartObject, (needClipSmartMap ? __pMap : null)); + + if (unlikely(__pImageHolder)) + { + evas_object_map_enable_set(__pImageHolder, needClipObjectMap); + evas_object_map_set(__pImageHolder, (needClipObjectMap ? __pMap : null)); + + if (likely(pImageObjectNew)) + { + evas_object_map_enable_set(pImageObjectNew, EINA_FALSE); + evas_object_map_set(pImageObjectNew, null); + } + } + else if (likely(pImageObjectNew)) + { + evas_object_map_enable_set(pImageObjectNew, needClipObjectMap); + evas_object_map_set(pImageObjectNew, (needClipObjectMap ? __pMap : null)); + } + + if (unlikely(__pRectangleObject)) + { + evas_object_map_enable_set(__pRectangleObject, needClipObjectMap); + evas_object_map_set(__pRectangleObject, (needClipObjectMap ? __pMap : null)); + } + + if (unlikely(__pNativeSmartObject)) + { + evas_object_map_enable_set(__pNativeSmartObject, needClipObjectMap); + evas_object_map_set(__pNativeSmartObject, (needClipObjectMap ? __pMap : null)); + } + __mapUsed = needMap; + } + + + // Set-up Content Bounds + // WARNING: + // EFL Bug! - evas_object_fill_set should be invoked only *AFTER* adjusting maps !!!!! + // If contents bounds are modifed before adjusting maps, it will not be applied !!! + if (likely(pImageObjectNew) && likely(__pSharedSurface)) + { + bool needDefaultFillSet = true; + + if (unlikely(element.__useContentBounds)) + { + const Dimension surfaceSize(_VisualElementSurfaceImpl::GetInstance(*__pSharedSurface)->GetPhysicalSize()); + const FloatRectangle& contentBounds = element.__contentBounds; + Rectangle contentBoundsAdjusted; + + // Formula: + // + // content bounds(px) = content bounds(uniform) * surface size(px) + // + // surface size(px) 1 + // mapped content size(px) = bounds size(px) * ------------------ = bounds size(px) * ----------------------- + // content size(px) content size(uniform) + // + // mapped content size(px) : surface size(px) = mapped content pos(px) : content pos(px) + // + // mapped content size(px) content pos(uniform) * bounds size(px) + // mapped content pos(px) = content pos(px) * ------------------------- = ----------------------------------------- + // surface size(px) content size(uniform) + + _VisualElementCoordinateSystem::MakeIntegralPoint( + -contentBounds.x * static_cast< float >(newW) / contentBounds.width, + -contentBounds.y * static_cast< float >(newH) / contentBounds.height, + contentBoundsAdjusted.x, + contentBoundsAdjusted.y + ); + _VisualElementCoordinateSystem::MakeIntegralPoint( + static_cast< float >(newW) / contentBounds.width, // WARNING: No use of __realBounds. new[WH] is the real displaying value which is integral. + static_cast< float >(newH) / contentBounds.height, + contentBoundsAdjusted.width, + contentBoundsAdjusted.height + ); + + //NormalizeUniformRectangle(contentBoundsAdjusted, surfaceSize.width, surfaceSize.height); + + if (likely(contentBoundsAdjusted.width > 0) && likely(contentBoundsAdjusted.height > 0)) + { + evas_object_image_fill_set( + pImageObjectNew, + contentBoundsAdjusted.x, + contentBoundsAdjusted.y, + contentBoundsAdjusted.width, + contentBoundsAdjusted.height + ); + + needDefaultFillSet = false; + } + } + + if (likely(needDefaultFillSet)) + { + evas_object_image_fill_set(pImageObjectNew, 0, 0, newW, newH); + } + } + + + invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS); + } + + + if ((invalidatedNativeProps & (_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY)) || unlikely(__needEvasObjectSync)) + { + float alpha = element.GetOpacityFromRoot(); + bool renderOperationChanged = false; + + if (unlikely(__renderOperation != element.__renderOperation)) + { + renderOperationChanged = true; + __renderOperation = element.__renderOperation; + } + + + // pImageObjectNew does exist. + if (likely(pImageObjectNew)) + { + if (unlikely(renderOperationChanged)) + { + evas_object_render_op_set(pImageObjectNew, GetRenderOperation(element.__renderOperation)); + } +// +// if (unlikely(__renderOperation == VisualElement::RENDER_OPERATION_COPY)) +// { +// evas_object_color_set(pImageObjectNew, 255, 255, 255, 255); +// } +// else +// { + int premultipliedColor = static_cast< int >(255.0f * alpha); // white color + evas_object_color_set(pImageObjectNew, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor); +// } + } + + + // rectangle setting + if (unlikely(__pRectangleObject)) + { + if (unlikely(renderOperationChanged)) + { + evas_object_render_op_set(__pRectangleObject, GetRenderOperation(element.__renderOperation)); + } + + float alphaRect = alpha * __backgroundColor.Alpha() * 255.0f; + + evas_object_color_set( + __pRectangleObject, + static_cast< int >(__backgroundColor.Red() * alphaRect), + static_cast< int >(__backgroundColor.Green() * alphaRect), + static_cast< int >(__backgroundColor.Blue() * alphaRect), + static_cast< int >(alphaRect) + ); + } + + // WARNING: CHECKME: TODO: + // How can we native smart object + + // Native Smart Object does exist. + if (unlikely(__pNativeSmartObject)) + { + + if (unlikely(renderOperationChanged)) + { + evas_object_render_op_set(__pNativeSmartObject, GetRenderOperation(element.__renderOperation)); + } + + if (unlikely(element.__renderOperation == VisualElement::RENDER_OPERATION_COPY)) + { + evas_object_color_set(__pNativeSmartObject, 0, 0, 0, 0); // for smart +// evas_object_color_set(__pNativeSmartObject, 255, 255, 255, 255);// for image + } + else + { + int premultipliedColor = static_cast< int >(255.0f * alpha); // white color + evas_object_color_set(__pNativeSmartObject, premultipliedColor, premultipliedColor, premultipliedColor, premultipliedColor); + } + + } + + invalidatedNativeProps &= ~(_VisualElementImpl::HIERARCHY_PROPERTY_OPACITY | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY); + } + + + // WARNING: Adjust properties after creating objects such as surface(image object), rectangle and clip object + if (likely(isVeVisible)) + { + if (unlikely(!isEvasVisible)) + { + evas_object_show(__pSmartObject); // Children of smart-object such as rectangle and clip-object may be invisible here. + } + } + else + { + if (unlikely(isEvasVisible)) + { + evas_object_hide(__pSmartObject); + } + } + + + // WARNING: + // Only after setting all invalidated properties, need-sync flag can be cleared + __needEvasObjectSync = false; + +finished: + + return E_SUCCESS; +} + +VisualElementSurface* +_EflNode::GetSurface(void) const +{ + return __pSurface; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_EflVisualElementSurfaceImpl.cpp b/src/ui/animations/FUiAnim_EflVisualElementSurfaceImpl.cpp new file mode 100644 index 0000000..2d08bdf --- /dev/null +++ b/src/ui/animations/FUiAnim_EflVisualElementSurfaceImpl.cpp @@ -0,0 +1,272 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_EflVisualElementSurfaceImpl.cpp + * @brief This file contains implementation of _EflVisualElementSurfaceImpl class + * + * This file contains implementation _EflVisualElementSurfaceImpl class. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "FUi_CoordinateSystemUtils.h" +#include "FUi_EcoreEvas.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUiAnim_EflNode.h" +#include "FUiAnim_EflLayer.h" +#include "FUiAnim_EflVisualElementSurfaceImpl.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Animations +{ + +_EflVisualElementSurfaceImpl::_EflVisualElementSurfaceImpl(const Handle layer, const Dimension& size) + : _VisualElementSurfaceImpl(size) + , __pEvasImage(null) + , __pBuffer(null) +{ + ClearLastResult(); + + int stride = 0; + _EflLayer* pLayer = reinterpret_cast<_EflLayer*>(layer); + __pEvasImage = evas_object_image_filled_add(pLayer->GetEvas()); + SysTryReturnVoidResult(NID_UI_ANIM, __pEvasImage, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to create a new surface."); + + evas_object_image_alpha_set(__pEvasImage, EINA_TRUE); + + Dimension outputSize = _CoordinateSystemUtils::Transform(size); + SysTryCatch(NID_UI_ANIM, outputSize.width >= 0 && outputSize.height >= 0, , E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. size(%d:%d)", outputSize.width, outputSize.height); + // Todo : Temporary code(HW limitation) + //SysTryCatch(NID_UI_ANIM, outputSize.width <= 4096 && outputSize.height <= 4096, , E_OUT_OF_MEMORY, + // "[E_OUT_OF_MEMORY] Memory allocation failed. size(%d:%d)", outputSize.width, outputSize.height); + + evas_object_image_size_set(__pEvasImage, outputSize.width, outputSize.height); + + stride = evas_object_image_stride_get(__pEvasImage); + __pBuffer = new (std::nothrow) unsigned char[stride * outputSize.height]; + SysTryCatch(NID_UI_ANIM, __pBuffer, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. size(%d:%d)" + , outputSize.width, outputSize.height); + + evas_object_resize(__pEvasImage, outputSize.width, outputSize.height); + evas_object_image_data_set(__pEvasImage, reinterpret_cast(__pBuffer)); + +#if 1 // Todo : Temporary code(regarding the visibility of evas source object) + evas_object_show(__pEvasImage); + evas_object_move(__pEvasImage, -999999, -999999); +#else + evas_object_hide(__pEvasImage); +#endif + return; + +CATCH: + evas_object_del(__pEvasImage); + __pEvasImage = null; +} + +_EflVisualElementSurfaceImpl::_EflVisualElementSurfaceImpl(const Handle layer, const Handle object, const Dimension& size) + : _VisualElementSurfaceImpl(size) + , __pEvasImage(null) + , __pBuffer(null) +{ + ClearLastResult(); + + _EflLayer* pLayer = reinterpret_cast<_EflLayer*>(layer); + Evas* evas = evas_object_evas_get(reinterpret_cast(object)); + if (pLayer->GetEvas() == evas) + { + __pEvasImage = reinterpret_cast(object); + } + SysTryReturnVoidResult(NID_UI_ANIM, __pEvasImage, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to create a new surface."); + +#if 1 // Todo : Temporary code(regarding the visibility of evas source object) + evas_object_show(__pEvasImage); + evas_object_move(__pEvasImage, -999999, -999999); +#else + evas_object_hide(__pEvasImage); +#endif +} + +result +_EflVisualElementSurfaceImpl::SetImage(const String& fileName) +{ + SysTryReturnResult(NID_UI_ANIM, __pEvasImage, E_SYSTEM, "A system error has been occurred. Surface is null."); + + unique_ptr pBuffer(Tizen::Base::Utility::StringUtil::StringToUtf8N(fileName)); + SysTryReturnResult(NID_UI_ANIM, pBuffer, E_SYSTEM, "A system error has been occurred. Can not convert the file name."); + + Evas_Object* pSource = evas_object_image_source_get(__pEvasImage); + pSource = pSource ? pSource : __pEvasImage; + + evas_object_image_file_set(pSource, (const char*)(pBuffer->GetPointer()), null); + + Evas_Load_Error err = evas_object_image_load_error_get(__pEvasImage); + SysTryReturnResult(NID_UI_ANIM, err == EVAS_LOAD_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Image file(%s) load failed . MSG = %s", + (const char*)(pBuffer->GetPointer()), evas_load_error_str(err)); + + if (__pBuffer != null) + { + delete []__pBuffer; + } + + __pBuffer = null; + + return E_SUCCESS; +} + +_EflVisualElementSurfaceImpl::~_EflVisualElementSurfaceImpl(void) +{ + if (__pBuffer != null) + { + evas_object_image_data_set(__pEvasImage, null); + delete []__pBuffer; + } + + if (__pEvasImage != null) + { + evas_object_smart_member_del(__pEvasImage); + evas_object_del(__pEvasImage); + } + + __pBuffer = null; + __pEvasImage = null; +} + +Handle +_EflVisualElementSurfaceImpl::GetNativeHandle(void) const +{ + return (Handle)__pEvasImage; +} + +result +_EflVisualElementSurfaceImpl::GetBufferInfo(BufferInfo& bufferInfo) const +{ + Evas_Object* pSource = evas_object_image_source_get(__pEvasImage); + pSource = pSource ? pSource : __pEvasImage; + + int w = 0; + int h = 0; + evas_object_image_size_get(pSource, &w, &h); + bufferInfo.width = w; + bufferInfo.height = h; + bufferInfo.pitch = evas_object_image_stride_get(__pEvasImage); + + Evas_Colorspace colorspace = evas_object_image_colorspace_get(__pEvasImage); + bufferInfo.bitsPerPixel = GetBytePerPixel(colorspace) * 8; + bufferInfo.pixelFormat = GetPixelFormat(colorspace); + + _BufferInfoImpl* pBufferInfoImpl = _BufferInfoImpl::GetInstance(bufferInfo); + SysTryReturnResult(NID_UI_ANIM, pBufferInfoImpl, E_OUT_OF_MEMORY, "Memory allocation failed."); + pBufferInfoImpl->SetHandle(_BufferInfoImpl::HANDLE_TYPE_VE_SURFACE, reinterpret_cast(__pEvasImage)); + pBufferInfoImpl->SetBounds(Rectangle(0, 0, w, h)); + + return E_SUCCESS; +} + +Dimension +_EflVisualElementSurfaceImpl::GetPhysicalSize(void) const +{ + SysTryReturn(NID_UI_ANIM, __pEvasImage, Dimension(-1, -1), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Surface is null."); + + int w = 0; + int h = 0; + Evas_Object* pSource = evas_object_image_source_get(__pEvasImage); + if (unlikely(!pSource)) + { + pSource = __pEvasImage; + } + + evas_object_image_size_get(pSource, &w, &h); + +#if 0 + _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance(); + _ICoordinateTransformer* pXformer = pCoordSystem->GetInverseTransformer(); + SysTryReturn(NID_UI_ANIM, pXformer, Dimension(-1, -1), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to load coordinate transformer."); + + w = pXformer->Transform(w); + h = pXformer->Transform(h); +#endif + + return Tizen::Graphics::Dimension(w, h); +} + +PixelFormat +_EflVisualElementSurfaceImpl::GetPixelFormat(Evas_Colorspace colorspace) const +{ + switch (colorspace) + { + case EVAS_COLORSPACE_ARGB8888: + return PIXEL_FORMAT_ARGB8888; + + case EVAS_COLORSPACE_YCBCR422P601_PL: + // fall through + case EVAS_COLORSPACE_YCBCR422P709_PL: + // fall through + case EVAS_COLORSPACE_RGB565_A5P: + // fall through + case EVAS_COLORSPACE_GRY8: + // fall through + case EVAS_COLORSPACE_YCBCR422601_PL: + // fall through + case EVAS_COLORSPACE_YCBCR420NV12601_PL: + // fall through + case EVAS_COLORSPACE_YCBCR420TM12601_PL: + // fall through + default: + return PIXEL_FORMAT_MIN; + } +} + +int +_EflVisualElementSurfaceImpl::GetBytePerPixel(Evas_Colorspace colorspace) const +{ + switch (colorspace) + { + case EVAS_COLORSPACE_ARGB8888: + return 4; + + case EVAS_COLORSPACE_YCBCR422P601_PL: + // fall through + case EVAS_COLORSPACE_YCBCR422P709_PL: + // fall through + case EVAS_COLORSPACE_RGB565_A5P: + // fall through + case EVAS_COLORSPACE_GRY8: + // fall through + case EVAS_COLORSPACE_YCBCR422601_PL: + // fall through + case EVAS_COLORSPACE_YCBCR420NV12601_PL: + // fall through + case EVAS_COLORSPACE_YCBCR420TM12601_PL: + // fall through + default: + return 0; + } +} + +}}} + diff --git a/src/ui/animations/FUiAnim_EflVisualElementSurfaceImpl.h b/src/ui/animations/FUiAnim_EflVisualElementSurfaceImpl.h new file mode 100644 index 0000000..60d8288 --- /dev/null +++ b/src/ui/animations/FUiAnim_EflVisualElementSurfaceImpl.h @@ -0,0 +1,74 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_EflVisualElementSurfaceImpl.h + * @brief This is the header file for the %_EflVisualElementSurfaceImpl class. + * + * This file contains declarations _EflVisualElementSurfaceImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_EFL_VISUAL_ELEMENT_SURFACE_IMPL_H_ +#define _FUI_ANIM_INTERNAL_EFL_VISUAL_ELEMENT_SURFACE_IMPL_H_ + +#include +#include + +#include "FUiAnim_VisualElementSurfaceImpl.h" + +namespace Tizen { namespace Graphics +{ + enum PixelFormat; +}} + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _EflVisualElementSurfaceImpl + : public _VisualElementSurfaceImpl +{ +public: + _EflVisualElementSurfaceImpl(const Handle layer, const Tizen::Graphics::Dimension& size); + _EflVisualElementSurfaceImpl(const Handle layer, const Handle object, const Tizen::Graphics::Dimension& size); + virtual ~_EflVisualElementSurfaceImpl(void); + +public: + virtual Handle GetNativeHandle(void) const; + virtual Tizen::Graphics::Dimension GetPhysicalSize(void) const; + virtual result SetImage(const Tizen::Base::String& fileName); + virtual result GetBufferInfo(Tizen::Graphics::BufferInfo& bufferInfo) const; + +private: + _EflVisualElementSurfaceImpl(void); // no implementation + _EflVisualElementSurfaceImpl(const _EflVisualElementSurfaceImpl& rhs); + _EflVisualElementSurfaceImpl& operator =(const _EflVisualElementSurfaceImpl& rhs); + + Tizen::Graphics::PixelFormat GetPixelFormat(Evas_Colorspace colorspace) const; + int GetBytePerPixel(Evas_Colorspace colorspace) const; + +private: + Evas_Object* __pEvasImage; + unsigned char* __pBuffer; + + friend class _VisualElementSurfaceImpl; + friend class _VisualElementImpl; + friend class _EflNode; +}; // _EflVisualElementSurfaceImpl + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_EFL_VISUAL_ELEMENT_SURFACE_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_FloatAnimationImpl.cpp b/src/ui/animations/FUiAnim_FloatAnimationImpl.cpp new file mode 100644 index 0000000..ec3a750 --- /dev/null +++ b/src/ui/animations/FUiAnim_FloatAnimationImpl.cpp @@ -0,0 +1,127 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_FloatAnimationImpl.cpp + * @brief This file contains implementation of _FloatAnimationImpl class + * + * This file contains implementation _FloatAnimationImpl class. + */ + +#include +#include + +#include + + +#include "FUiAnim_VisualElementAnimationVariantInterpolator.h" +#include "FUiAnim_AnimationBaseImpl.h" +#include "FUiAnim_FloatAnimationImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base::Collection; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +_FloatAnimationImpl::~_FloatAnimationImpl(void) +{ +} + +_FloatAnimationImpl::_FloatAnimationImpl(FloatAnimation* pFloat) + : startValue(Float(0.0f)) + , endValue(Float(0.0f)) + , __pFloatAnimation(pFloat) +{ +} + +result +_FloatAnimationImpl::CopyFloatAnimationValue(const FloatAnimation& floatAnimation) +{ + result r = E_SUCCESS; + + _AnimationBaseImpl* pAnimationBaseImpl = __pFloatAnimation->_pAnimationBaseImpl; + + // Deleting the contents of existing keyframe + r = pAnimationBaseImpl->RemoveAllKeyFrames(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + // Copying the contents + startValue = floatAnimation._pFloatAnimationImpl->startValue; + endValue = floatAnimation._pFloatAnimationImpl->endValue; + + if (floatAnimation._pAnimationBaseImpl->keyFrameList.GetCount() == 0) + { + return E_SUCCESS; + } + + IMapEnumeratorT< long, Object* >* pMapEnum = null; + MapEntryT< long, Object* > value; + Float* pFloatObj = null; + + pMapEnum = floatAnimation._pAnimationBaseImpl->keyFrameList.GetMapEnumeratorN(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_ANIM, (pMapEnum), r, "Failed to get the enumerator."); + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + r = pMapEnum->GetCurrent(value); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + Float* pFloatValue = dynamic_cast< Float* >(value.GetValue()); + SysTryCatch(NID_UI_ANIM, (pFloatValue), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Key frame is invalid."); + + pFloatObj = new (std::nothrow) Float(*pFloatValue); + SysTryCatch(NID_UI_ANIM, (pFloatObj), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pAnimationBaseImpl->keyFrameList.Add(value.GetKey(), pFloatObj); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + delete pMapEnum; + + return E_SUCCESS; + +CATCH: + delete pFloatObj; + delete pMapEnum; + + return r; +} + +result +_FloatAnimationImpl::GetAnimatedValue(float actualProgress, float& animatedValue) const +{ + Variant startFloatValue(startValue.ToFloat()); + Variant endFloatValue(endValue.ToFloat()); + Variant value(0.0f); + + _VisualElementAnimationVariantInterpolator variantInterpolator; + result r = variantInterpolator.Interpolate(actualProgress, startFloatValue, endFloatValue, value); + + animatedValue = value.ToFloat(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to get the animated value."); + + return r; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_FloatAnimationImpl.h b/src/ui/animations/FUiAnim_FloatAnimationImpl.h new file mode 100644 index 0000000..37ac3bd --- /dev/null +++ b/src/ui/animations/FUiAnim_FloatAnimationImpl.h @@ -0,0 +1,108 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_FloatAnimationImpl.h + * @brief This is the header file for the _FloatAnimationImpl class. + * + * This header file contains the declarations of the _FloatAnimationImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_FLOAT_ANIMATION_IMPL_H_ +#define _FUI_ANIM_INTERNAL_FLOAT_ANIMATION_IMPL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _FloatAnimationImpl + : public Tizen::Base::Object +{ + +public: + /** + * Destructor for %_FloatAnimationImpl class. + */ + ~_FloatAnimationImpl(void); + + /** + * Default constructor for %_FloatAnimationImpl class. + */ + _FloatAnimationImpl(FloatAnimation* pFloat); + + /** + * To copy float animation object + * + * @since 2.0 + * @return An error code + * @param[in] floatAnimation Float animation object + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result CopyFloatAnimationValue(const FloatAnimation& floatAnimation); + + /** + * Gets the animated value for the current time. + * + * @since 2.0 + * @return An error code + * @param[in] actualProgress The current time value of the animation @n + * The value should be between @c 0 and 1 + * @param[out] animatedValue The animated value for the current time passed as the input parameter + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_STATE This instance has not been properly constructed. + * @exception E_SYSTEM A system error has occurred. + * + */ + result GetAnimatedValue(float actualProgress, float& animatedValue) const; + + /** + * The start value of the animation + */ + Tizen::Base::Float startValue; + + /** + * The end value of the animation + */ + Tizen::Base::Float endValue; + + +private: + /** + * Private copy constructor. + */ + _FloatAnimationImpl(const _FloatAnimationImpl& rhs); + + /** + * Private assignment operator. + */ + _FloatAnimationImpl& operator =(const _FloatAnimationImpl& rhs); + + /** + * This is object of FloatAnimation class + * + */ + FloatAnimation* __pFloatAnimation; + +}; //_FloatAnimationImpl + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_FLOAT_ANIMATION_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_FrameAnimatorImpl.cpp b/src/ui/animations/FUiAnim_FrameAnimatorImpl.cpp new file mode 100644 index 0000000..0e59d61 --- /dev/null +++ b/src/ui/animations/FUiAnim_FrameAnimatorImpl.cpp @@ -0,0 +1,959 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_FrameAnimatorImpl.cpp + * @brief This file contains implementation of _FrameAnimatorImpl class + * + * This file contains implementation of _FrameAnimatorImpl class. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FUi_ControlImpl.h" +#include "FUi_Matrix3Df.h" +#include "FUiAnim_FrameAnimatorImpl.h" +#include "FUiAnim_VisualElementAnimationImpl.h" + +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_ControlVisualElement.h" +#include "FUiAnim_MatrixUtil.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +_FrameAnimatorImpl::_FrameAnimatorImpl(FrameAnimator* pFrameAnimator) + : __pFrame(null) + , __pFrameAnimator(pFrameAnimator) + , __transactionId(-1) + , __frameAnimatorStatus(ANIMATOR_STATUS_STOPPED) + , __pCurrentForm(null) + , __pNextForm(null) + , __pCurrentFormVisualElement(null) + , __pNextFormVisualElement(null) + , __animationEffectType(FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_FADE_IN_OUT) + , __animInterpolatorType(ANIMATION_INTERPOLATOR_LINEAR) + , __duration(400) + , __firstBezierControlPointsTime(0.0f) + , __firstBezierControlPointsValue(0.0f) + , __secondBezierControlPointsTime(0.0f) + , __secondBezierControlPointsValue(0.0f) + , __veDefaultMatrix() + , __veDefaultBounds(0, 0, 0, 0) + , __veDefaultOpacity(0) + , __pBgElement(null) + , __pCurrentCaptureVisualElement(null) + , __pNextCaptureVisualElement(null) + , __pDummySurface(null) +{ +} + +result +_FrameAnimatorImpl::Construct(const Frame& source) +{ + SysAssertf((__pFrame == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + result r = E_SUCCESS; + + __pFrame = const_cast< Frame* >(&source); + + r = __frameActiveAnimationList.Construct(); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r,"[%s] Failed to construct FrameActiveAnimationList.", GetErrorMessage(r)); + + __pBgElement = new (std::nothrow) _ControlVisualElement(); + SysTryCatch(NID_UI_ANIM, (__pBgElement != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pBgElement->ConstructControlVisualElement(); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Failed to construct ControlVisualElement.", GetErrorMessage(r)); + + __pBgElement->SetName("FrameAnimatorBG"); + __pBgElement->SetShowState(true); + __pBgElement->SetImplicitAnimationEnabled(false); + + __pCurrentCaptureVisualElement = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_ANIM, (__pCurrentCaptureVisualElement != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pCurrentCaptureVisualElement->Construct(); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Failed to construct VisualElement.", GetErrorMessage(r)); + + __pCurrentCaptureVisualElement->SetName("FrameAnimatorCurrentCapture"); + __pCurrentCaptureVisualElement->SetShowState(false); + __pCurrentCaptureVisualElement->SetImplicitAnimationEnabled(false); + + __pNextCaptureVisualElement = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_ANIM, (__pNextCaptureVisualElement != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pNextCaptureVisualElement->Construct(); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Failed to construct VisualElement.", GetErrorMessage(r)); + + __pNextCaptureVisualElement->SetName("FrameAnimatorNextCapture"); + __pNextCaptureVisualElement->SetShowState(false); + __pNextCaptureVisualElement->SetImplicitAnimationEnabled(false); + + __pBgElement->AttachChild(*__pCurrentCaptureVisualElement); + __pBgElement->AttachChild(*__pNextCaptureVisualElement); + + __pDummySurface = new (std::nothrow) VisualElementSurface(); + SysTryCatch(NID_UI_ANIM, (__pDummySurface != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pDummySurface->Construct(*__pFrame->GetDisplayContext(), Dimension(1,1)); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Failed to construct VisualElementSurface.", GetErrorMessage(r)); + + return r; + +CATCH: + Dispose(); + + return r; +} + +_FrameAnimatorImpl::~_FrameAnimatorImpl(void) +{ + Dispose(); +} + +result +_FrameAnimatorImpl::Dispose(void) +{ + if (__transactionId) + { + AnimationTransaction::Stop(__transactionId); + __transactionId = -1; + } + + if (__pDummySurface) + { + delete __pDummySurface; + __pDummySurface = null; + } + + // delete with children + if (__pBgElement) + { + __pBgElement->Destroy(); + __pBgElement = null; + } + + __frameActiveAnimationList.RemoveAll(); + __frameAnimStatusEventListener.RemoveAll(); + + return E_SUCCESS; +} + +bool +_FrameAnimatorImpl::FrameActiveAnimation::operator ==(const FrameActiveAnimation& frameActiveAnim) const +{ + if ((formTransitionAnimationType == frameActiveAnim.formTransitionAnimationType) && (pPropertyAnimation == frameActiveAnim.pPropertyAnimation)) + { + return true; + } + + return false; +} + +bool +_FrameAnimatorImpl::FrameActiveAnimation::operator !=(const FrameActiveAnimation& frameActiveAnim) const +{ + if ((formTransitionAnimationType != frameActiveAnim.formTransitionAnimationType) || (pPropertyAnimation != frameActiveAnim.pPropertyAnimation)) + { + return true; + } + + return false; +} + +result +_FrameAnimatorImpl::AddFrameAnimatorEventListener(IFrameAnimatorEventListener& listener) +{ + IFrameAnimatorEventListener* pStatusListener = &listener; + + if (__frameAnimStatusEventListener.Contains(pStatusListener) == true) + { + return E_OBJ_ALREADY_EXIST; + } + + result r = __frameAnimStatusEventListener.Add(pStatusListener); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add frame animator event listener."); + + return r; +} + +result +_FrameAnimatorImpl::RemoveFrameAnimatorEventListener(IFrameAnimatorEventListener& listener) +{ + IFrameAnimatorEventListener* pStatusListener = &listener; + + result r = __frameAnimStatusEventListener.Remove(pStatusListener); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_OBJ_NOT_FOUND, "Propagating."); + + return r; +} + +result +_FrameAnimatorImpl::StopAllAnimations(void) +{ + if (__transactionId != -1) + { + result r = AnimationTransaction::Stop(__transactionId); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + } + + return E_SUCCESS; +} + +result +_FrameAnimatorImpl::AddControl(const Control& control) +{ + Form* pCurrentForm = __pFrame->GetCurrentForm(); + + Form* pNextForm = dynamic_cast< Form* >(const_cast< Control* >(&control)); + SysTryReturnResult(NID_UI_ANIM, (pNextForm), E_INVALID_ARG, "Invalid argument(s) is used. Control is not Form."); + SysTryReturnResult(NID_UI_ANIM, (pCurrentForm != pNextForm), E_SUCCESS, "Current form is same as the new form."); + + result r = __pFrame->AddControl(control); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + r = ChangeCurrentForm(pCurrentForm, *pNextForm); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + return E_SUCCESS; +} + +result +_FrameAnimatorImpl::SetCurrentForm(const Form& form) +{ + Form* pCurrentForm = __pFrame->GetCurrentForm(); + + Form* pNextForm = const_cast< Form* >(&form); + SysTryReturnResult(NID_UI_ANIM, (pCurrentForm != pNextForm), E_SUCCESS, "Current form is same as the new form."); + + result r = ChangeCurrentForm(pCurrentForm, *pNextForm); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + return E_SUCCESS; +} + +result +_FrameAnimatorImpl::ChangeCurrentForm(Form* pCurrentForm, Form& nextForm) +{ + SysTryReturnResult(NID_UI_ANIM, __transactionId == -1, E_INVALID_OPERATION, "Last frame animation was not completed."); + + result r = E_SUCCESS; + + if (IsAnimationSupported() == false || pCurrentForm == null) + { + r = __pFrame->SetCurrentForm(nextForm); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + __pNextForm->Draw(); + + return E_SUCCESS; + } + + __pCurrentForm = pCurrentForm; + __pNextForm = &nextForm; + + _ControlImpl* pControlImpl = null; + + pControlImpl = _ControlImpl::GetInstance(*__pCurrentForm); + __pCurrentFormVisualElement = pControlImpl->GetCore().GetVisualElement(); + + r = __pFrame->SetCurrentForm(*__pNextForm); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + pControlImpl = _ControlImpl::GetInstance(*__pNextForm); + __pNextFormVisualElement = pControlImpl->GetCore().GetVisualElement(); + + // for Layout + pControlImpl->SetBoundsAndUpdateLayout(pControlImpl->GetBounds()); + + __veDefaultMatrix = __pCurrentFormVisualElement->GetTransformMatrix(); + __veDefaultBounds = _VisualElementImpl::GetInstance(*__pCurrentFormVisualElement)->GetBoundingBox(); + __veDefaultOpacity = 1.0f; //TODO: check__pCurrentFormVisualElement->GetOpacity(); + __pCurrentFormVisualElement->SetShowState(true); + + // prepare background + FloatRectangle bgBounds = __pCurrentFormVisualElement->GetBounds(); + + if (__animationEffectType == FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_LEFT + || __animationEffectType == FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_RIGHT) + { + if (bgBounds.width <= bgBounds.height) + { + bgBounds.width = bgBounds.height; + } + else + { + bgBounds.height = bgBounds.width; + } + } + + __pBgElement->SetBounds(bgBounds); + + Color bgColor = pCurrentForm->GetBackgroundColor(); + __pBgElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255, (float)bgColor.GetGreen() / 255, (float)bgColor.GetBlue() / 255, (float)bgColor.GetAlpha() / 255)); + + VisualElement* pParentVisualElement = __pCurrentFormVisualElement->GetParent(); + SysTryReturnResult(NID_UI_ANIM, (pParentVisualElement), E_SYSTEM, "A system error has been occurred. Failed to get visual element's parent."); + + pParentVisualElement->InsertChild(*__pBgElement, __pCurrentFormVisualElement, false); + + AnimationTransaction::Begin(__transactionId); + AnimationTransaction::SetCurrentTransactionEventListener(this); + + r = SetAnimations(); + + if (r != E_SUCCESS) + { + AnimationTransaction::Discard(); + RemoveAllAnimations(true); + + return r; + } + + r = AnimationTransaction::Commit(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to commit transaction."); + + __frameAnimatorStatus = ANIMATOR_STATUS_PLAYING; + return E_SUCCESS; +} + +result +_FrameAnimatorImpl::SetAnimations(void) +{ + result r = E_SUCCESS; + + String transId = ""; + transId.Append(__transactionId); + + switch (__animationEffectType) + { + case FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_LEFT: + { + Dimension currentSize = __pCurrentForm->GetSize(); + Dimension nextSize = __pNextForm->GetSize(); + + Point currFormStartPoint = Point(0, 0); + Point currFormEndPoint = Point((-1 * (currentSize.width)), 0); + + Point nextFormStartPoint = Point((currentSize.width), 0); + Point nextFormEndPoint = Point(0, 0); + + if (currentSize.width > nextSize.width) + { + currFormStartPoint = Point((-1 * (currentSize.width - nextSize.width)), 0); + nextFormStartPoint = Point((nextSize.width), 0); + } + + r = StartLayerAnimation(__pCurrentFormVisualElement, ANIMATION_TARGET_POSITION, Variant(currFormStartPoint), Variant(currFormEndPoint), transId + (L"CurrentFormLeftTranslatePosition")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + + r = StartLayerAnimation(__pNextFormVisualElement, ANIMATION_TARGET_POSITION, Variant(nextFormStartPoint), Variant(nextFormEndPoint), transId + (L"NextFormLeftTranslatePosition")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + } + break; + + case FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_RIGHT: + { + Dimension currentSize = __pCurrentForm->GetSize(); + Dimension nextSize = __pNextForm->GetSize(); + + Point currFormStartPoint = Point(0, 0); + Point currFormEndPoint = Point((nextSize.width), 0); + + Point nextFormStartPoint = Point((-1 * (nextSize.width)), 0); + Point nextFormEndPoint = Point(0, 0); + + if (currentSize.width < nextSize.width) + { + currFormStartPoint = Point((nextSize.width - currentSize.width), 0); + nextFormStartPoint = Point((-1 * (currentSize.width)), 0); + } + + r = StartLayerAnimation(__pCurrentFormVisualElement, ANIMATION_TARGET_POSITION, Variant(currFormStartPoint), Variant(currFormEndPoint), transId + (L"CurrentFormRightTranslatePosition")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list"); + + r = StartLayerAnimation(__pNextFormVisualElement, ANIMATION_TARGET_POSITION, Variant(nextFormStartPoint), Variant(nextFormEndPoint), transId + (L"NextFormRightTranslatePosition")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list"); + } + break; + + case FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_FADE_IN_OUT: + { + r = PrepareCapture(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to capture."); + +// r = StartLayerAnimation(__pCurrentCaptureVisualElement, ANIMATION_TARGET_ALPHA, Variant(1.0f), Variant(0.0f), transId + (L"CurrentFormFadeOutAlpha")); +// SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + + r = StartLayerAnimation(__pNextCaptureVisualElement, ANIMATION_TARGET_ALPHA, Variant(0.0f), Variant(1.0f), transId + (L"NextFormFadeInAlpha")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + } + break; + + case FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_ZOOM_IN: + { + Dimension currentSize = __pCurrentForm->GetSize(); + + Dimension startSize = Dimension((currentSize.width * 80) / 100, (currentSize.height * 80) / 100); + Dimension endSize = currentSize; + + r = StartLayerAnimation(__pCurrentFormVisualElement, ANIMATION_TARGET_ALPHA, Variant(1.0f), Variant(0.0f), transId + (L"CurrentFormZoomInAlpha")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + + r = StartLayerAnimation(__pNextFormVisualElement, ANIMATION_TARGET_ALPHA, Variant(0.0f), Variant(1.0f), transId + (L"NextFormZoomInAlpha")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + + r = StartLayerAnimation(__pNextFormVisualElement, ANIMATION_TARGET_SIZE, Variant(startSize), Variant(endSize), transId + (L"NextFormZoomInSize")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + } + break; + + case FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_ZOOM_OUT: + { + r = PrepareCapture(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to capture."); + + Dimension currentSize = __pCurrentForm->GetSize(); + + Dimension startSize = currentSize; + Dimension endSize = Dimension((currentSize.width * 80) / 100, (currentSize.height * 80) / 100); + + r = StartLayerAnimation(__pCurrentCaptureVisualElement, ANIMATION_TARGET_SIZE, Variant(startSize), Variant(endSize), transId + (L"CurrentFormZoomOutSize")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + + r = StartLayerAnimation(__pCurrentCaptureVisualElement, ANIMATION_TARGET_ALPHA, Variant(1.0f), Variant(0.0f), transId + (L"CurrentFormZoomOutAlpha")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + + r = StartLayerAnimation(__pNextCaptureVisualElement, ANIMATION_TARGET_ALPHA, Variant(0.0f), Variant(1.0f), transId + (L"NextFormZoomOutAlpha")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + } + break; + + + case FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_DEPTH_IN: + { + r = PrepareCapture(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to capture."); + + Dimension currentSize = __pCurrentForm->GetSize(); + + Dimension currFormStartSize = currentSize; + Dimension currFormEndSize = Dimension((currentSize.width * 80) / 100, (currentSize.height * 80) / 100); + Dimension nextFormStartSize = Dimension((currentSize.width * 120) / 100, (currentSize.height * 120) / 100); + Dimension nextFormEndSize = currentSize; + + r = StartLayerAnimation(__pCurrentCaptureVisualElement, ANIMATION_TARGET_ALPHA, Variant(1.0f), Variant(0.0f), transId + (L"CurrentFormDepthInAplha")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + + r = StartLayerAnimation(__pCurrentCaptureVisualElement, ANIMATION_TARGET_SIZE, Variant(currFormStartSize), Variant(currFormEndSize), transId + (L"CurrentFormDepthInSize")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + + r = StartLayerAnimation(__pNextCaptureVisualElement, ANIMATION_TARGET_ALPHA, Variant(0.0f), Variant(1.0f), transId + (L"NextFormDepthInAplha")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + + r = StartLayerAnimation(__pNextCaptureVisualElement, ANIMATION_TARGET_SIZE, Variant(nextFormStartSize), Variant(nextFormEndSize), transId + (L"NextFormDepthInSize")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + } + break; + + case FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_DEPTH_OUT: + { + Dimension currentSize = __pCurrentForm->GetSize(); + + Dimension currFormStartSize = currentSize; + Dimension currFormEndSize = Dimension((currentSize.width * 120) / 100, (currentSize.height * 120) / 100); + Dimension nextFormStartSize = Dimension((currentSize.width * 80) / 100, (currentSize.height * 80) / 100); + Dimension nextFormEndSize = currentSize; + + r = StartLayerAnimation(__pCurrentFormVisualElement, ANIMATION_TARGET_ALPHA, Variant(1.0f), Variant(0.0f), transId + (L"CurrentFormDepthOutAlpha")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + + r = StartLayerAnimation(__pNextFormVisualElement, ANIMATION_TARGET_ALPHA, Variant(0.0f), Variant(1.0f), transId + (L"NextFormDepthOutAlpha")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + + r = StartLayerAnimation(__pCurrentFormVisualElement, ANIMATION_TARGET_SIZE, Variant(currFormStartSize), Variant(currFormEndSize), transId + (L"CurrentFormDepthOutSize")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + + r = StartLayerAnimation(__pNextFormVisualElement, ANIMATION_TARGET_SIZE, Variant(nextFormStartSize), Variant(nextFormEndSize), transId + (L"NextFormDepthOutSize")); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation to play list."); + } + break; + + default: + SysLogException(NID_UI_ANIM, E_SYSTEM, "A system error has been occurred. FrameAnimatorFormTransitionAnimation is invalid."); + return E_SYSTEM; + } + + return E_SUCCESS; +} + +result +_FrameAnimatorImpl::PrepareCapture(void) +{ + VisualElement* pParentVisualElement = __pNextFormVisualElement->GetParent(); + SysTryReturnResult(NID_UI_ANIM, (pParentVisualElement), E_SYSTEM, "A system error has been occurred. Failed to get visual element's parent."); + + pParentVisualElement->InsertChild(*__pBgElement, __pNextFormVisualElement, true); + + // remove dummy surface + __pCurrentCaptureVisualElement->SetSurface(null); + __pNextCaptureVisualElement->SetSurface(null); + + // set default value + __pCurrentCaptureVisualElement->SetOpacity(1.0f); + __pNextCaptureVisualElement->SetOpacity(1.0f); + + __pCurrentCaptureVisualElement->SetTransformMatrix(__pCurrentFormVisualElement->GetTransformMatrix()); + __pNextCaptureVisualElement->SetTransformMatrix(__pNextFormVisualElement->GetTransformMatrix()); + + __pCurrentCaptureVisualElement->SetShowState(true); + __pNextCaptureVisualElement->SetShowState(true); + + FloatRectangle currentBounds = __pCurrentFormVisualElement->GetBounds(); + __pCurrentCaptureVisualElement->SetBounds(currentBounds); + + FloatRectangle nextBounds = __pNextFormVisualElement->GetBounds(); + __pNextCaptureVisualElement->SetBounds(nextBounds); + + // drawing + __pCurrentFormVisualElement->Draw(); + __pNextFormVisualElement->Draw(); + + Canvas* pCanvas = null; + + pCanvas = __pCurrentCaptureVisualElement->GetCanvasN(); + SysTryReturnResult(NID_UI_ANIM, (pCanvas), E_SYSTEM, "A system error has been occurred. Failed to get canvas."); + + currentBounds.SetPosition(0, 0); + _VisualElementImpl::GetInstance(*__pCurrentFormVisualElement)->Capture(*pCanvas, currentBounds, true); + delete pCanvas; + + pCanvas = __pNextCaptureVisualElement->GetCanvasN(); + SysTryReturnResult(NID_UI_ANIM, (pCanvas), E_SYSTEM, "A system error has been occurred. Failed to get canvas."); + + nextBounds.SetPosition(0, 0); + _VisualElementImpl::GetInstance(*__pNextFormVisualElement)->Capture(*pCanvas, nextBounds, true); + delete pCanvas; + + return E_SUCCESS; +} + + +result +_FrameAnimatorImpl::StartLayerAnimation(VisualElement* pLayer, AnimationTargetType animTarget, Variant startValue, Variant endValue, String animName) +{ + result r = E_SUCCESS; + + Dimension startSize, endSize; + Point startPoint, endPoint; + + VisualElementPropertyAnimation* propAnimation = null; + propAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturnResult(NID_UI_ANIM, (propAnimation), E_OUT_OF_MEMORY, "Memory allocation failed."); + + propAnimation->SetDuration(__duration); + + const IVisualElementAnimationTimingFunction* pTimingFunction = null; + const wchar_t* pVePropType = null; + Rectangle rect = __pCurrentForm->GetBounds(); + + switch (__animInterpolatorType) + { + case ANIMATION_INTERPOLATOR_LINEAR: + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(L"Linear"); //INTERPOLATION_LINEAR + break; + + case ANIMATION_INTERPOLATOR_EASE_IN: + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(L"EaseIn"); //INTERPOLATION_EASE_IN + break; + + case ANIMATION_INTERPOLATOR_EASE_OUT: + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(L"EaseOut"); //INTERPOLATION_EASE_OUT + break; + + case ANIMATION_INTERPOLATOR_EASE_IN_OUT: + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(L"EaseInOut"); //INTERPOLATION_EASE_INOUT + break; + + case ANIMATION_INTERPOLATOR_DISCRETE: + pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(L"Discrete"); //INTERPOLATION_DISCRETE + break; + + case ANIMATION_INTERPOLATOR_BEZIER: + { + pTimingFunction = new (std::nothrow) BezierTimingFunction(); + SysTryCatch(NID_UI_ANIM, (pTimingFunction), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to get TimingFunction."); + + ((BezierTimingFunction*) pTimingFunction)->SetControlPoints(__firstBezierControlPointsTime, __firstBezierControlPointsValue, __secondBezierControlPointsTime, __secondBezierControlPointsValue); + } + break; + + default: + SysTryCatch(NID_UI_ANIM, false, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation interpolator is invalid. "); + break; + } + + SysTryCatch(NID_UI_ANIM, (pTimingFunction), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get TimingFunction."); + propAnimation->SetTimingFunction(pTimingFunction); + + switch(startValue.GetType()) + { + case VARIANT_TYPE_POINT: + startPoint = startValue.ToPoint(); + endPoint = endValue.ToPoint(); + break; + case VARIANT_TYPE_DIMENSION: + startSize = startValue.ToDimension(); + endSize = endValue.ToDimension(); + break; + default: break; + } + + switch (animTarget) + { + case ANIMATION_TARGET_SIZE: + { + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + + pVePropType = VePropTransform; + + anchorX = (float) rect.width * anchorX; + anchorY = (float) rect.height * anchorY; + + scaleX = (float) startSize.width / (float) rect.width; + scaleY = (float) startSize.height / (float) rect.height; + + Tizen::Graphics::FloatMatrix4 startMatrix = Tizen::Graphics::FloatMatrix4(); + //startMatrix.SetAsIdentity(); // default value is identity matrix + _MatrixUtilScale(startMatrix, scaleX, scaleY, scaleZ); + _MatrixUtilAtAnchor(startMatrix, anchorX, anchorY, anchorZ); + + scaleX = (float) endSize.width / (float) rect.width; + scaleY = (float) endSize.height / (float) rect.height; + + Tizen::Graphics::FloatMatrix4 endMatrix = Tizen::Graphics::FloatMatrix4(); + //endMatrix.SetAsIdentity(); // default value is identity matrix + _MatrixUtilScale(endMatrix, scaleX, scaleY, scaleZ); + _MatrixUtilAtAnchor(endMatrix, anchorX, anchorY, anchorZ); + + propAnimation->SetStartValue(Variant(startMatrix)); + propAnimation->SetEndValue(Variant(endMatrix)); + } + break; + + case ANIMATION_TARGET_POSITION: + { + pVePropType = VePropBounds; + + FloatRectangle rect; + + rect = pLayer->GetBounds(); + rect.x = startPoint.x; + rect.y = startPoint.y; + propAnimation->SetStartValue(Variant(rect)); + + rect.x = endPoint.x; + rect.y = endPoint.y; + propAnimation->SetEndValue(Variant(rect)); + } + break; + + case ANIMATION_TARGET_ALPHA: + { + pVePropType = VePropOpacity; + propAnimation->SetStartValue(startValue); + propAnimation->SetEndValue(endValue); + } + break; + + case ANIMATION_TARGET_ROTATION: + { + float anchorX = 0.0f; + float anchorY = 0.0f; + + pVePropType = VeSubPropTransformRotationZ; + _VisualElementImpl::GetInstance(*pLayer)->SetAnchor(FloatPoint(anchorX, anchorY)); + + propAnimation->SetStartValue(startValue); + propAnimation->SetEndValue(endValue); + } + break; + + default: + { + SysTryCatch(NID_UI_ANIM, false, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] animTarget is invalid."); + } + break; + } + + SysTryCatch(NID_UI_ANIM, (pVePropType), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Animation property type is invalid."); + propAnimation->SetPropertyName(pVePropType); + + r = pLayer->AddAnimation(animName, *propAnimation); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, r, "[E_SYSTEM] A system error has been occurred. Failed to add animation to visual element."); + + r = AddFrameActiveAnimation(pLayer, __animationEffectType, propAnimation, const_cast < IVisualElementAnimationTimingFunction* >(pTimingFunction), animName); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, r, "[E_SYSTEM] A system error has been occurred. Failed to add frame active animation to the playing list."); + + return E_SUCCESS; + +CATCH: + delete propAnimation; + + SysLogException(NID_UI_ANIM, E_SYSTEM, "A system error has been occurred. Failed to start frame animation."); + return E_SYSTEM; +} + +result +_FrameAnimatorImpl::AddFrameActiveAnimation(VisualElement* _pVisualElement, FrameAnimatorFormTransitionAnimation _formAnimation, + VisualElementPropertyAnimation* _pPropertyAnimation, IVisualElementAnimationTimingFunction* _pTimingFunction, + String _animName) +{ + SysTryReturnResult(NID_UI_ANIM + , (_formAnimation >= FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_TRANSLATE_LEFT + && _formAnimation < FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_MAX) + , E_INVALID_ARG, "Invalid argument(s) is used. FormTransitionType argument is invalid."); + + result r = E_SUCCESS; + FrameActiveAnimation frameActiveAnim; + + frameActiveAnim.pVisualElement = _pVisualElement; + frameActiveAnim.formTransitionAnimationType = _formAnimation; + frameActiveAnim.pPropertyAnimation = _pPropertyAnimation; + frameActiveAnim.pTimingFunction = _pTimingFunction; + frameActiveAnim.animName = _animName; + + r = __frameActiveAnimationList.Add(frameActiveAnim); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + return r; +} + +Tizen::Ui::Animations::VisualElementPropertyAnimation* +_FrameAnimatorImpl::GetFrameActiveAnimationAt(int index) +{ + SysTryReturn(NID_UI_ANIM, (index < __frameActiveAnimationList.GetCount() && (index >= 0)), + null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Index (%d) is out of range."); + + FrameActiveAnimation frameActiveAnim; + result r = __frameActiveAnimationList.GetAt(index, frameActiveAnim); + + SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to retrieve FrameActiveAnimation."); + return frameActiveAnim.pPropertyAnimation; +} + +result +_FrameAnimatorImpl::RemoveAnimationAt(int index) +{ + result r = E_SUCCESS; + SysTryReturnResult(NID_UI_ANIM, (index >= 0 && index < __frameActiveAnimationList.GetCount()), E_OUT_OF_RANGE, "Index (%d) is out of range.", index); + + FrameActiveAnimation frameActiveAnim; + + r = __frameActiveAnimationList.GetAt(index, frameActiveAnim); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to retrieve FrameActiveAnimation."); + + r = __frameActiveAnimationList.RemoveAt(index); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to remove animation from play list."); + + if (__animInterpolatorType == ANIMATION_INTERPOLATOR_BEZIER) + { + frameActiveAnim.pPropertyAnimation->SetTimingFunction(null); + delete frameActiveAnim.pTimingFunction; + frameActiveAnim.pTimingFunction = null; + } + + delete frameActiveAnim.pPropertyAnimation; + frameActiveAnim.pPropertyAnimation = null; + + return r; +} + +result +_FrameAnimatorImpl::RemoveAllAnimations(bool deleteAnimation) +{ + VisualElement* pParentVisualElement = __pBgElement->GetParent(); + if (pParentVisualElement) + { + pParentVisualElement->DetachChild(*__pBgElement); + + __pCurrentCaptureVisualElement->SetShowState(false); + __pNextCaptureVisualElement->SetShowState(false); + + __pCurrentCaptureVisualElement->SetSurface(__pDummySurface); + __pNextCaptureVisualElement->SetSurface(__pDummySurface); + } + + if (deleteAnimation) + { + __pNextFormVisualElement->RemoveAllAnimations(); + __pCurrentFormVisualElement->RemoveAllAnimations(); + } + + __transactionId = -1; + + result r = E_SUCCESS; + + for (int index = __frameActiveAnimationList.GetCount() - 1; index >= 0; index--) + { + r = RemoveAnimationAt(index); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + } + + return r; +} + +bool +_FrameAnimatorImpl::IsAnimationSupported(void) const +{ + return _VisualElementAnimationImpl::IsAnimationSupported(); +} + +bool +_FrameAnimatorImpl::IsFormPresent(Tizen::Ui::Controls::Form& pPrevForm) const +{ + LinkedList* pLinkedList = null; + + pLinkedList = dynamic_cast< LinkedList* >(__pFrame->GetControls()); + SysTryReturn(NID_UI_ANIM, (pLinkedList), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get control list."); + + bool isPresent = pLinkedList->Contains(pPrevForm); + + if (isPresent) + { + return true; + } + else + { + return false; + } +} + +void +_FrameAnimatorImpl::OnAnimationTransactionStarted(int transactionId) +{ + OnFrameAnimationStarted(); +} + + +void +_FrameAnimatorImpl::OnAnimationTransactionStopped(int transactionId) +{ + OnFrameAnimationStopped(false); +} + +void +_FrameAnimatorImpl::OnAnimationTransactionFinished(int transactionId) +{ + OnFrameAnimationStopped(true); +} + +void +_FrameAnimatorImpl::OnFrameAnimationStarted(void) +{ + result r = E_SUCCESS; + + for (int index = __frameAnimStatusEventListener.GetCount() - 1; index >= 0; index--) + { + IFrameAnimatorEventListener* pStatusListener = null; + + r = __frameAnimStatusEventListener.GetAt(index, pStatusListener); + SysTryReturnVoidResult(NID_UI_ANIM, (r == E_SUCCESS), E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index (%d) is out of range.", index); + + pStatusListener->OnFormTransitionAnimationStarted(*__pFrameAnimator, *__pFrame, *__pCurrentForm, *__pNextForm); + } +} + +void +_FrameAnimatorImpl::OnFrameAnimationStopped(bool completed) +{ + result r = E_SUCCESS; + + if (IsFormPresent(*__pCurrentForm)) + { + __pCurrentFormVisualElement->SetTransformMatrix(__veDefaultMatrix); + __pCurrentFormVisualElement->SetBounds(__veDefaultBounds); + __pCurrentFormVisualElement->SetOpacity(__veDefaultOpacity); + __pCurrentFormVisualElement->SetShowState(false); + } + + RemoveAllAnimations(false); + + for (int index = __frameAnimStatusEventListener.GetCount() - 1; index >= 0; index--) + { + IFrameAnimatorEventListener* pStatusListener = null; + + r = __frameAnimStatusEventListener.GetAt(index, pStatusListener); + SysTryReturnVoidResult(NID_UI_ANIM, (r == E_SUCCESS), E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index (%d) is out of range.", index); + + if (!completed) + { + pStatusListener->OnFormTransitionAnimationStopped(*__pFrameAnimator, *__pFrame, *__pCurrentForm, *__pNextForm); + } + else + { + pStatusListener->OnFormTransitionAnimationFinished(*__pFrameAnimator, *__pFrame, *__pCurrentForm, *__pNextForm); + } + } + + __frameAnimatorStatus = ANIMATOR_STATUS_STOPPED; +} + +_FrameAnimatorImpl* +_FrameAnimatorImpl::GetInstance(FrameAnimator& frameAnimator) +{ + return frameAnimator._pFrameAnimatorImpl; +} + +const _FrameAnimatorImpl* +_FrameAnimatorImpl::GetInstance(const FrameAnimator& frameAnimator) +{ + return frameAnimator._pFrameAnimatorImpl; +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_FrameAnimatorImpl.h b/src/ui/animations/FUiAnim_FrameAnimatorImpl.h new file mode 100644 index 0000000..20e5c17 --- /dev/null +++ b/src/ui/animations/FUiAnim_FrameAnimatorImpl.h @@ -0,0 +1,632 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_FrameAnimatorImpl.h + * @brief This is the header file for the _FrameAnimatorImpl class. + * + * This header file contains the declarations of the _FrameAnimatorImpl class. @n + */ + +#ifndef _FUI_ANIM_INTERNAL_FRAME_ANIMATOR_IMPL_H_ +#define _FUI_ANIM_INTERNAL_FRAME_ANIMATOR_IMPL_H_ + +#include +#include +#include + +#include "FUiAnim_ControlVisualElement.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class _FrameAnimatorImpl + * @brief This class defines the animation API for Container::Frame + * @since 2.0 + * + * The %_FrameAnimatorImpl class is used to control the animations operated on Tizen::Ui::Controls::Container::Frame + * + */ +class _FrameAnimatorImpl + : public Tizen::Base::Object + , public IAnimationTransactionEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * Destructor for %_FrameAnimatorImpl class. + * + * @since 2.0 + */ + ~_FrameAnimatorImpl(void); + + /** + * Default constructor for %_FrameAnimatorImpl class. + * + * @since 2.0 + */ + _FrameAnimatorImpl(FrameAnimator* pFrameAnimator); + + /** + * Initializes this %_FrameAnimatorImpl class. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + result Construct(const Tizen::Ui::Controls::Frame& source); + + /** + * Adds framestatusevent listener to list. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM System error occurred. + */ + result AddFrameAnimatorEventListener(IFrameAnimatorEventListener& listener); + + /** + * Removes framestatusevent listener from list. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM System error occurred. + * @exception E_OBJ_NOT_FOUND Listener object not found in list. + */ + result RemoveFrameAnimatorEventListener(IFrameAnimatorEventListener& listener); + + /** + * Stops all the animations that are currently playing and jumps to the final frame of the animation. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result StopAllAnimations(void); + + /** + * Adds the control at the end of the list maintained by the container with animation. + * + * @since 2.0 + * + * @return An error code + * @param[in] control The control to be added to the container + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * The specified @c control is an instance of Window, or this control's parent container. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_MAX_EXCEEDED The number of child controls has exceeded the maximum limit. + * @exception E_SYSTEM A system error has occurred. + * @remarks When the control is added, it is placed at the top of the drawing stack maintained by the container.@n + * This means the last control added is drawn last + * @remarks A control becomes displayable only after it has been added to a displayable container. Some methods may not work normally if the methods + * of the control are called before adding the control to a container. After the control is added to a %Container, the OnInitializing() + * method of the control are called before adding the control to a container. After the control is added to a Container, the + * OnInitializing() method of the control is invoked for the initialization of the control such as creating and adding child controls. + * @see Tizen::Ui::Control::OnInitializing() + * @see Tizen::Ui::Control::OnTerminating() + */ + result AddControl(const Tizen::Ui::Control& control); + + /** + * Sets the current form with animation. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_STATE This instance has already been constructed. + * @exception E_OUT_OF_MEMORY Insufficient memory. + * @exception E_SYSTEM System error occurred. + */ + result SetCurrentForm(const Tizen::Ui::Controls::Form& form); + + + /** + * returns whether animation supported by underlying platform or not + * + * @since 2.0 + * + * @return An error code + * @remarks %This function returns whether animation is supported or not. @n + * If @c true, animation supported. @n + * If @c false, animation not supported. + */ + bool IsAnimationSupported(void) const; + + + /** + * This Callback is called when an animation is started. + * + * @since 2.0 + */ + virtual void OnAnimationTransactionStarted(int transactionId); + + + /** + * This Callback is called when an animation ends. + * + * @since 2.0 + */ + virtual void OnAnimationTransactionStopped(int transactionId); + + + /** + * This Callback is called when an animation ends. + * + * @since 2.0 + */ + virtual void OnAnimationTransactionFinished(int transactionId); + + + /** + * This Callback is called when an animation is started. + * + * @since 2.0 + */ + void OnFrameAnimationStarted(void); + + + /** + * This Callback is called when an animation ends. + * + * @since 2.0 + */ + void OnFrameAnimationStopped(bool completed); + + + /** + * Returns frame animator status. + * + * @since 2.0 + * + * @return AnimatorStatus for the frameanimator. + */ + AnimatorStatus + GetFrameAnimatorStatus(void) const + { + return __frameAnimatorStatus; + } + + /** + * Returns frame animator FrameAnimatorFormTransitionAnimation. + * + * @since 2.0 + * + * @return FrameAnimatorFormTransitionAnimation for the frameanimator. + */ + FrameAnimatorFormTransitionAnimation + GetAnimationEffectType(void) const + { + return __animationEffectType; + } + + /** + * Sets frame animator FrameAnimatorFormTransitionAnimation. + * + * @since 2.0 + */ + void + SetAnimationEffectType(FrameAnimatorFormTransitionAnimation animationEffectType) + { + __animationEffectType = animationEffectType; + } + + /** + * Returns frame animator animation duration. + * + * @since 2.0 + * + * @return long duration for the frameanimator. + */ + long + GetDuration(void) const + { + return __duration; + } + + /** + * Sets frame animator animation duration. + * + * @since 2.0 + */ + void + SetDuration(long duration) + { + __duration = duration; + } + + /** + * Returns frame animator AnimInterpolatorType. + * + * @since 2.0 + * + * @return AnimInterpolatorType for the frameanimator. + */ + AnimationInterpolatorType + GetAnimInterpolatorType(void) const + { + return __animInterpolatorType; + } + + /** + * Sets frame animator AnimInterpolatorType. + * + * @since 2.0 + */ + void + SetAnimInterpolatorType(AnimationInterpolatorType animInterpolatorType) + { + __animInterpolatorType = animInterpolatorType; + } + + /** + * Returns frame animator bezier control points. + * + * @since 2.0 + * + * @return A float type value. + */ + void + GetFormTransitionBezierControlPoints(float& firstTime, float& firstValue, float& secondTime, float& secondValue) const + { + firstTime = __firstBezierControlPointsTime; + firstValue = __firstBezierControlPointsValue; + secondTime = __secondBezierControlPointsTime; + secondValue = __secondBezierControlPointsValue; + } + + /** + * Sets frame animator bezier control points. + * + * @since 2.0 + * + * @return A float type value. + */ + void + SetFormTransitionBezierControlPoints(float firstTime, float firstValue, float secondTime, float secondValue) + { + __firstBezierControlPointsTime = firstTime; + __firstBezierControlPointsValue = firstValue; + __secondBezierControlPointsTime = secondTime; + __secondBezierControlPointsValue = secondValue; + } + + static _FrameAnimatorImpl* GetInstance(FrameAnimator& frameAnimator); + static const _FrameAnimatorImpl* GetInstance(const FrameAnimator& frameAnimator); + +private: + /** + * This is the copy constructor for this class. @n + * + * @since 2.0 + */ + _FrameAnimatorImpl(const _FrameAnimatorImpl& rhs); + + /** + * This is the assignment operator implementation for this class. @n + * + * @since 2.0 + */ + _FrameAnimatorImpl& operator =(const _FrameAnimatorImpl& rhs); + + /** + * Delete & frees the memory used by the object. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM Failed to free the resource possessed by this instance. + */ + result Dispose(void); + + /** + * Starts the Layer animation. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_STATE This instance has already been constructed. + * @exception E_OUT_OF_MEMORY Insufficient memory. + * @exception E_SYSTEM System error occurred. + */ + result StartLayerAnimation(VisualElement* pLayer, AnimationTargetType animTarget, Variant startValue, Variant endValue, Tizen::Base::String animName); + + + /** + * Adds the %Animation to the ActiveAnimation List. + * + * @since 2.0 + * + * @return An error code + * @param[in] formAnimation %FrameAnimatorFormTransitionAnimation + * @param[in] propAnimation An object of VisualElementPropertyAnimation + * @param[in] animName Unique animation name + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result AddFrameActiveAnimation(VisualElement* _pVisualElement, FrameAnimatorFormTransitionAnimation _formAnimation, + VisualElementPropertyAnimation* _pPropertyAnimation, IVisualElementAnimationTimingFunction* _pTimingFunction, Tizen::Base::String _animName); + + /** + * Gets the %Animation from the FrameActiveAnimation List attached against specified index + * + * @since 2.0 + * + * @return An error code + * @param[in] index Value at the index to be retrieved + * @param[out] propAnimation An object of VisualElementPropertyAnimation + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + VisualElementPropertyAnimation* GetFrameActiveAnimationAt(int index); + + /** + * Removes the %Animation from the FrameActiveAnimation List at specified index. + * + * @since 2.0 + * + * @return An error code + * @param[in] index Values at the index to be removed. + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result RemoveAnimationAt(int index); + + /** + * Removes all the %Animation from the FrameActiveAnimation List. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result RemoveAllAnimations(bool deleteAnimation); + + /** + * Searches the Frame's children list, for the given form, if present returns true else false. + * + * @since 2.0 + * + * @return bool True if form is still in the children list, else false. + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + bool IsFormPresent(Tizen::Ui::Controls::Form& pPrevForm) const; + + /** + * Removes all the %Animation from the FrameActiveAnimation List. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result ChangeCurrentForm(Tizen::Ui::Controls::Form* pCurrentForm, Tizen::Ui::Controls::Form& nextForm); + + result SetAnimations(void); + + result PrepareCapture(void); + +private: + /** + * Structure used for storing Frame Active Animations + * + * @since 2.0 + */ + struct FrameActiveAnimation + { + VisualElement* pVisualElement; + FrameAnimatorFormTransitionAnimation formTransitionAnimationType; + VisualElementPropertyAnimation* pPropertyAnimation; + IVisualElementAnimationTimingFunction* pTimingFunction; + Tizen::Base::String animName; + FrameActiveAnimation(void) + { + pVisualElement = null; + formTransitionAnimationType = FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_MAX; + pPropertyAnimation = null; + pTimingFunction = null; + animName = ""; + } + ~FrameActiveAnimation(void) + { + } + bool operator ==(const FrameActiveAnimation& frameActiveAnim) const; + bool operator !=(const FrameActiveAnimation& frameActiveAnim) const; + }; // FrameActiveAnimation + +private: + /** + * This is the object of Frame. + * + * @since 2.0 + * @remark: This object need not be deleted in FrameAnimator scope + */ + Tizen::Ui::Controls::Frame* __pFrame; + + /** + * This is object of FrameAnimator class. + * + * @since 2.0 + */ + FrameAnimator* __pFrameAnimator; + + /** + * The List maintaining the Frame Active Animations. + * + * @since 2.0 + */ + Tizen::Base::Collection::ArrayListT< FrameActiveAnimation > __frameActiveAnimationList; + + /** + * This Callback is called when an animation is repeated. + * + * @since 2.0 + */ + Tizen::Base::Collection::LinkedListT< IFrameAnimatorEventListener* > __frameAnimStatusEventListener; + + /** + * This is transactionID for the Form Transition animation + * + * @since 2.0 + */ + int __transactionId; + + /** + * The animation status (play / stopped) + * + * @since 2.0 + */ + AnimatorStatus __frameAnimatorStatus; + + /** + * CurrentForm object pointer. + * + * @since 2.0 + */ + Tizen::Ui::Controls::Form* __pCurrentForm; + + /** + * NextForm object pointer. + * + * @since 2.0 + */ + Tizen::Ui::Controls::Form* __pNextForm; + + /** + * The VisualElement of CurrentForm. + * + * @since 2.0 + */ + VisualElement* __pCurrentFormVisualElement; + + /** + * The VisualElement of NextForm. + * + * @since 2.0 + */ + VisualElement* __pNextFormVisualElement; + + /** + * This is the AnimationFormTransitionEffect used in animation. + * + * @since 2.0 + */ + FrameAnimatorFormTransitionAnimation __animationEffectType; + + /** + * This is the AnimationInterpolatorType used in animation. + * + * @since 2.0 + */ + AnimationInterpolatorType __animInterpolatorType; + + /** + * This is the duration of animation. + * + * @since 2.0 + */ + long __duration; + + /** + * This is input time1 of Bezier Control point. + * + * @since 2.0 + */ + float __firstBezierControlPointsTime; + + /** + * This is input value1 of Bezier Control point. + * + * @since 2.0 + */ + float __firstBezierControlPointsValue; + + /** + * This is input time2 of Bezier Control point. + * + * @since 2.0 + */ + float __secondBezierControlPointsTime; + + /** + * This is input value2 of Bezier Control point. + * + * @since 2.0 + */ + float __secondBezierControlPointsValue; + + /** + * This Tizen::Graphics::FloatMatrix4 object to set default transform matrix to current form after animation. + * + * @since 2.0 + */ + Tizen::Graphics::FloatMatrix4 __veDefaultMatrix; + + /** + * This Tizen::Graphics::FloatRectangle object to set default bounds to forms after animation. + * + * @since 2.0 + */ + Tizen::Graphics::FloatRectangle __veDefaultBounds; + + /** + * This float value to set default opacity to forms after animation. + * + * @since 2.0 + */ + float __veDefaultOpacity; + + /** + * Background ControlVisualElement to give a backgroud to Animating forms, so that background forms aren't visible + * in case of alpha animation. + * + * @since 2.0 + */ + _ControlVisualElement* __pBgElement; + VisualElement* __pCurrentCaptureVisualElement; + VisualElement* __pNextCaptureVisualElement; + VisualElementSurface* __pDummySurface; + +}; // _FrameAnimatorImpl + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_FRAME_ANIMATOR_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_INativeNode.cpp b/src/ui/animations/FUiAnim_INativeNode.cpp new file mode 100644 index 0000000..e420990 --- /dev/null +++ b/src/ui/animations/FUiAnim_INativeNode.cpp @@ -0,0 +1,72 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_INativeNode.cpp + * @brief This file contains implementation of _INativeNode class + * + * This file contains implementation _INativeNode class. + */ + +#include +#include +#include "FUiAnim_INativeNode.h" +#include "FUiAnim_DisplayManager.h" +#include "FUiAnim_EflNode.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + + +_INativeNode::_INativeNode(void) +{ +} + +_INativeNode::~_INativeNode(void) +{ +} + +_INativeNode* +_INativeNode::CreateInstanceN(void) +{ +#if defined(VE_EFL)// EFL version + _EflNode* pNode = new (std::nothrow) _EflNode; +#if 0 + if (pNode) + { + result r = pNode->Construct(); + SysTryCatch(NID_UI, + pNode->Construct() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to construct the NativeNode(internal module)."); + +CATCH: + delete pNode; + return null; + } +#endif + return pNode; + +// return static_cast< _INativeNode* >(new (std::nothrow) _EflNode); + +#else ////#elif defined(VE_OPENGL) + + return null; + +#endif +} + +}}} + diff --git a/src/ui/animations/FUiAnim_IntegerAnimationImpl.cpp b/src/ui/animations/FUiAnim_IntegerAnimationImpl.cpp new file mode 100644 index 0000000..b5f3e02 --- /dev/null +++ b/src/ui/animations/FUiAnim_IntegerAnimationImpl.cpp @@ -0,0 +1,125 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_IntegerAnimationImpl.cpp + * @brief This file contains implementation of _IntegerAnimationImpl class + * + * This file contains implementation _IntegerAnimationImpl class. + */ + +#include +#include +#include + +#include "FUiAnim_VisualElementAnimationVariantInterpolator.h" +#include "FUiAnim_AnimationBaseImpl.h" +#include "FUiAnim_IntegerAnimationImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base::Collection; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +_IntegerAnimationImpl::~_IntegerAnimationImpl(void) +{ +} + +_IntegerAnimationImpl::_IntegerAnimationImpl(IntegerAnimation* pInt) + : startValue(Integer(0)) + , endValue(Integer(0)) + , __pIntegerAnimation(pInt) +{ +} + +result +_IntegerAnimationImpl::CopyIntegerAnimationValue(const IntegerAnimation& integerAnimation) +{ + result r = E_SUCCESS; + + _AnimationBaseImpl* pAnimationBaseImpl = __pIntegerAnimation->_pAnimationBaseImpl; + + // Deleting the contents of existing keyframe + r = pAnimationBaseImpl->RemoveAllKeyFrames(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + // Copying the contents + startValue = integerAnimation._pIntegerAnimationImpl->startValue; + endValue = integerAnimation._pIntegerAnimationImpl->endValue; + + if (integerAnimation._pAnimationBaseImpl->keyFrameList.GetCount() == 0) + { + return E_SUCCESS; + } + + IMapEnumeratorT< long, Object* >* pMapEnum = null; + MapEntryT< long, Object* > value; + Integer* pIntegerObj = null; + + pMapEnum = integerAnimation._pAnimationBaseImpl->keyFrameList.GetMapEnumeratorN(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_ANIM, (pMapEnum), r, "Failed to get enumerator."); + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + r = pMapEnum->GetCurrent(value); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + Integer* pIntValue = dynamic_cast< Integer* >(value.GetValue()); + SysTryCatch(NID_UI_ANIM, (pIntValue), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. KeyFrame value is invalid."); + + pIntegerObj = new (std::nothrow) Integer(*pIntValue); + SysTryCatch(NID_UI_ANIM, (pIntegerObj), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pAnimationBaseImpl->keyFrameList.Add(value.GetKey(), pIntegerObj); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + delete pMapEnum; + + return E_SUCCESS; + +CATCH: + delete pIntegerObj; + delete pMapEnum; + + return r; +} + +result +_IntegerAnimationImpl::GetAnimatedValue(float actualProgress, int& animatedValue) const +{ + Variant startIntValue(startValue.ToInt()); + Variant endIntValue(endValue.ToInt()); + Variant value(0); + + _VisualElementAnimationVariantInterpolator variantInterpolator; + result r = variantInterpolator.Interpolate(actualProgress, startIntValue, endIntValue, value); + + animatedValue = value.ToInt(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to get the animated value."); + + return r; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_IntegerAnimationImpl.h b/src/ui/animations/FUiAnim_IntegerAnimationImpl.h new file mode 100644 index 0000000..e9ea9ed --- /dev/null +++ b/src/ui/animations/FUiAnim_IntegerAnimationImpl.h @@ -0,0 +1,108 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_IntegerAnimationImpl.h + * @brief This is the header file for the _IntegerAnimationImpl class. + * + * This header file contains the declarations of the _IntegerAnimationImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_INTEGER_ANIMATION_IMPL_H_ +#define _FUI_ANIM_INTERNAL_INTEGER_ANIMATION_IMPL_H_ + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _IntegerAnimationImpl + : public Tizen::Base::Object +{ + +public: + /** + * Destructor for %_IntegerAnimationImpl class. + */ + ~_IntegerAnimationImpl(void); + + /** + * Default constructor for %_IntegerAnimationImpl class. + */ + _IntegerAnimationImpl(IntegerAnimation* pInt); + + /** + * To copy Integer animation object + * + * @since 2.0 + * @return An error code + * @param[in] integerAnimation Dimension animation object + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result CopyIntegerAnimationValue(const IntegerAnimation& integerAnimation); + + /** + * Gets the animated value for the current time. + * + * @since 2.0 + * @return An error code + * @param[in] actualProgress The current time value of the animation @n + * The value should be between @c 0 and 1 + * @param[out] animatedValue The animated value for the current time passed as the input parameter + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_STATE This instance has not been properly constructed. + * @exception E_SYSTEM A system error has occurred. + * + */ + result GetAnimatedValue(float actualProgress, int& animatedValue) const; + + /** + * The start value of the animation + */ + Tizen::Base::Integer startValue; + + /** + * The end value of the animation + */ + Tizen::Base::Integer endValue; + + +private: + /** + * Private copy constructor. + */ + _IntegerAnimationImpl(const _IntegerAnimationImpl& rhs); + + /** + * Private assignment operator. + */ + _IntegerAnimationImpl& operator =(const _IntegerAnimationImpl& rhs); + + /** + * This is object of IntegerAnimation class + * + */ + IntegerAnimation* __pIntegerAnimation; +}; //_IntegerAnimationImpl + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_INTEGER_ANIMATION_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_MatrixUtil.cpp b/src/ui/animations/FUiAnim_MatrixUtil.cpp new file mode 100644 index 0000000..f3788d7 --- /dev/null +++ b/src/ui/animations/FUiAnim_MatrixUtil.cpp @@ -0,0 +1,464 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_MatrixUtil.cpp + * @brief This file contains implementation of _MatrixUtil module + * + * This file contains implementation _MatrixUtil module. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FUi_Math.h" +#include "FUiAnim_MatrixUtil.h" + + +using namespace Tizen; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Animations +{ + +static const float _IDENTITY_MATRIX[4][4] = +{ + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f } +}; + + +Matrix4Type +_GetMatrix4Type(const Tizen::Graphics::FloatMatrix4& floatMatrix) +{ + if (floatMatrix.matrix[3][3] != 1.0f) + { + return MATRIX4_Generic; + } + + if (floatMatrix.matrix[1][0] != 0.0f || floatMatrix.matrix[2][0] != 0.0f || floatMatrix.matrix[2][1] != 0.0f) + { + return MATRIX4_Generic; + } + + if (floatMatrix.matrix[0][1] != 0.0f || floatMatrix.matrix[0][2] != 0.0f || floatMatrix.matrix[0][3] != 0.0f || + floatMatrix.matrix[1][2] != 0.0f || floatMatrix.matrix[1][3] != 0.0f || floatMatrix.matrix[2][3] != 0.0f) + { + return MATRIX4_Generic; + } + + bool isTranslate = (floatMatrix.matrix[3][0] != 0.0f || floatMatrix.matrix[3][1] != 0.0f || floatMatrix.matrix[3][2] != 0.0f); + bool isDiagonal = (floatMatrix.matrix[0][0] == 1.0f && floatMatrix.matrix[1][1] == 1.0f && floatMatrix.matrix[2][2] == 1.0f); + + if (isTranslate && isDiagonal) + { + return MATRIX4_Translation; + } + + if (isTranslate) + { + return MATRIX4_Generic; + } + + if (isDiagonal) + { + return MATRIX4_Identity; + } + + return MATRIX4_Scale; +} + +bool +_MatrixUtilIsEqual(const Tizen::Graphics::FloatMatrix4& m1, const Tizen::Graphics::FloatMatrix4& m2) +{ + return (memcmp(m1.matrix, m2.matrix, sizeof(m1.matrix)) == 0); +} + +void +_MatrixUtilSetIdentity(Tizen::Graphics::FloatMatrix4& m) +{ + memcpy(m.matrix, _IDENTITY_MATRIX, sizeof(_IDENTITY_MATRIX)); +} + +void +_MatrixUtilSetTranslation(Tizen::Graphics::FloatMatrix4& m, float tx, float ty, float tz) +{ + memcpy(m.matrix, _IDENTITY_MATRIX, sizeof(_IDENTITY_MATRIX)); + m.matrix[3][0] = tx; + m.matrix[3][1] = ty; + m.matrix[3][2] = tz; + m.matrix[3][3] = 1.0f; +} + +void +_MatrixUtilTransform(const Tizen::Graphics::FloatMatrix4& m, float* pX, float* pY, float* pZ) +{ + FloatVector4 vec4(*pX, *pY, *pZ, 1.0f); + vec4 = m * vec4; + *pX = vec4.x; + *pY = vec4.y; + *pZ = vec4.z; + + if (vec4.w != 1.0f && vec4.w != 0.0f) + { + *pX /= vec4.w; + *pY /= vec4.w; + *pZ /= vec4.w; + } +} + +void +_MatrixUtilTranslate(Tizen::Graphics::FloatMatrix4& m, float tx, float ty, float tz) +{ + m.matrix[3][0] += (m.matrix[0][0] * tx + m.matrix[1][0] * ty + m.matrix[2][0] * tz); + m.matrix[3][1] += (m.matrix[0][1] * tx + m.matrix[1][1] * ty + m.matrix[2][1] * tz); + m.matrix[3][2] += (m.matrix[0][2] * tx + m.matrix[1][2] * ty + m.matrix[2][2] * tz); + m.matrix[3][3] += (m.matrix[0][3] * tx + m.matrix[1][3] * ty + m.matrix[2][3] * tz); +} + +bool +_MatrixUtilIsTranslation(const Tizen::Graphics::FloatMatrix4& m) +{ + bool isTranslate = (m.matrix[3][0] != 0.0f || m.matrix[3][1] != 0.0f || m.matrix[3][2] != 0.0f); + bool isDiagonal = (m.matrix[0][0] == 1.0f && m.matrix[1][1] == 1.0f && m.matrix[2][2] == 1.0f); + + if (isTranslate && isDiagonal) + { + return true; + } + + return false; +} + +void +_MatrixUtilScale(Tizen::Graphics::FloatMatrix4& m, float sx, float sy, float sz) +{ + if (sx != 1.0f) + { + m.matrix[0][0] *= sx; + m.matrix[0][1] *= sx; + m.matrix[0][2] *= sx; + m.matrix[0][3] *= sx; + } + + if (sy != 1.0f) + { + m.matrix[1][0] *= sy; + m.matrix[1][1] *= sy; + m.matrix[1][2] *= sy; + m.matrix[1][3] *= sy; + } + + if (sz != 1.0f) + { + m.matrix[2][0] *= sz; + m.matrix[2][1] *= sz; + m.matrix[2][2] *= sz; + m.matrix[2][3] *= sz; + } +} + +void +_MatrixUtilAtAnchor(Tizen::Graphics::FloatMatrix4& m, float x, float y, float z) +{ + Tizen::Graphics::FloatMatrix4 tr; + Tizen::Graphics::FloatMatrix4 trInv; + + tr.matrix[3][0] = x; + tr.matrix[3][1] = y; + tr.matrix[3][2] = z; + + trInv.matrix[3][0] = -x; + trInv.matrix[3][1] = -y; + trInv.matrix[3][2] = -z; + + m = tr * m * trInv; +} + +void +_MatrixUtilRotate(Tizen::Graphics::FloatMatrix4& m, float angle, float x, float y, float z) +{ + if (angle == 0.0f) + { + return; + } + + // Rotation using quaternion + + angle = angle * M_PI / 180.0f; + + angle /= 2.0f; + float sinA = sinf(angle); + float cosA = cosf(angle); + float sinA2 = sinA * sinA; + + // normalize + float length = sqrtf(x * x + y * y + z * z); + if (length == 0.0f) + { + // bad vector, just use something reasonable + return; + } + else if (length != 1.0f) + { + x /= length; + y /= length; + z /= length; + } + + + float mat[4][4] = { {0.0f, }, }; + + // optimize case where axis is along major axis + if (x == 1.0f && y == 0.0f && z == 0.0f) + { + mat[0][0] = 1.0f; + mat[0][1] = 0.0f; + mat[0][2] = 0.0f; + mat[1][0] = 0.0f; + mat[1][1] = 1.0f - 2.0f * sinA2; + mat[1][2] = 2.0f * sinA * cosA; + mat[2][0] = 0.0f; + mat[2][1] = -2.0f * sinA * cosA; + mat[2][2] = 1.0f - 2.0f * sinA2; + mat[0][3] = mat[1][3] = mat[2][3] = 0.0f; + mat[3][0] = mat[3][1] = mat[3][2] = 0.0f; + mat[3][3] = 1.0f; + } + else if (x == 0.0f && y == 1.0f && z == 0.0f) + { + mat[0][0] = 1.0f - 2.0f * sinA2; + mat[0][1] = 0.0f; + mat[0][2] = -2.0f * sinA * cosA; + mat[1][0] = 0.0f; + mat[1][1] = 1.0f; + mat[1][2] = 0.0f; + mat[2][0] = 2.0f * sinA * cosA; + mat[2][1] = 0.0f; + mat[2][2] = 1.0f - 2.0f * sinA2; + mat[0][3] = mat[1][3] = mat[2][3] = 0.0f; + mat[3][0] = mat[3][1] = mat[3][2] = 0.0f; + mat[3][3] = 1.0f; + } + else if (x == 0.0f && y == 0.0f && z == 1.0f) + { + mat[0][0] = 1.0f - 2.0f * sinA2; + mat[0][1] = 2.0f * sinA * cosA; + mat[0][2] = 0.0f; + mat[1][0] = -2.0f * sinA * cosA; + mat[1][1] = 1.0f - 2.0f * sinA2; + mat[1][2] = 0.0f; + mat[2][0] = 0.0f; + mat[2][1] = 0.0f; + mat[2][2] = 1.0f; + mat[0][3] = mat[1][3] = mat[2][3] = 0.0f; + mat[3][0] = mat[3][1] = mat[3][2] = 0.0f; + mat[3][3] = 1.0f; + } + else + { + float x2 = x * x; + float y2 = y * y; + float z2 = z * z; + + mat[0][0] = 1.0f - 2.0f * (y2 + z2) * sinA2; + mat[0][1] = 2.0f * (x * y * sinA2 + z * sinA * cosA); + mat[0][2] = 2.0f * (x * z * sinA2 - y * sinA * cosA); + mat[1][0] = 2.0f * (y * x * sinA2 - z * sinA * cosA); + mat[1][1] = 1.0f - 2.0f * (z2 + x2) * sinA2; + mat[1][2] = 2.0f * (y * z * sinA2 + x * sinA * cosA); + mat[2][0] = 2.0f * (z * x * sinA2 + y * sinA * cosA); + mat[2][1] = 2.0f * (z * y * sinA2 - x * sinA * cosA); + mat[2][2] = 1.0f - 2.0f * (x2 + y2) * sinA2; + mat[0][3] = mat[1][3] = mat[2][3] = 0.0f; + mat[3][0] = mat[3][1] = mat[3][2] = 0.0f; + mat[3][3] = 1.0f; + } + + m *= Tizen::Graphics::FloatMatrix4(mat); +} + +bool +_MatrixUtilInvert(Tizen::Graphics::FloatMatrix4& m) +{ + // TODO: + // WOW!!! WOW!!! WOW!!! WOW!!! + // + float a0; + float a1; + float a2; + float a3; + float a4; + float a5; + float b0; + float b1; + float b2; + float b3; + float b4; + float b5; + float det; + + if (m.IsIdentity()) + { + return true; + } + + a0 = m.matrix[0][0] * m.matrix[1][1] - m.matrix[0][1] * m.matrix[1][0]; + a1 = m.matrix[0][0] * m.matrix[1][2] - m.matrix[0][2] * m.matrix[1][0]; + a2 = m.matrix[0][0] * m.matrix[1][3] - m.matrix[0][3] * m.matrix[1][0]; + a3 = m.matrix[0][1] * m.matrix[1][2] - m.matrix[0][2] * m.matrix[1][1]; + a4 = m.matrix[0][1] * m.matrix[1][3] - m.matrix[0][3] * m.matrix[1][1]; + a5 = m.matrix[0][2] * m.matrix[1][3] - m.matrix[0][3] * m.matrix[1][2]; + + b0 = m.matrix[2][0] * m.matrix[3][1] - m.matrix[2][1] * m.matrix[3][0]; + b1 = m.matrix[2][0] * m.matrix[3][2] - m.matrix[2][2] * m.matrix[3][0]; + b2 = m.matrix[2][0] * m.matrix[3][3] - m.matrix[2][3] * m.matrix[3][0]; + b3 = m.matrix[2][1] * m.matrix[3][2] - m.matrix[2][2] * m.matrix[3][1]; + b4 = m.matrix[2][1] * m.matrix[3][3] - m.matrix[2][3] * m.matrix[3][1]; + b5 = m.matrix[2][2] * m.matrix[3][3] - m.matrix[2][3] * m.matrix[3][2]; + + det = a0 * b5 - a1 * b4 + a2 * b3 + a3 * b2 - a4 * b1 + a5 * b0; +// if (_FloatHardCompare(det, 0.0f)) + if (det == 0.0f) + { + return false; + } + + + float inverse_m[4][4]; + + inverse_m[0][0] = +m.matrix[1][1] * b5 - m.matrix[1][2] * b4 + m.matrix[1][3] * b3; + inverse_m[1][0] = -m.matrix[1][0] * b5 + m.matrix[1][2] * b2 + m.matrix[1][3] * b1; + inverse_m[2][0] = +m.matrix[1][0] * b4 - m.matrix[1][1] * b2 + m.matrix[1][3] * b0; + inverse_m[3][0] = -m.matrix[1][0] * b3 + m.matrix[1][1] * b1 - m.matrix[1][2] * b0; + inverse_m[0][1] = -m.matrix[0][1] * b5 + m.matrix[0][2] * b4 - m.matrix[0][3] * b3; + inverse_m[1][1] = +m.matrix[0][0] * b5 - m.matrix[0][2] * b2 + m.matrix[0][3] * b1; + inverse_m[2][1] = -m.matrix[0][0] * b4 + m.matrix[0][1] * b2 - m.matrix[0][3] * b0; + inverse_m[3][1] = +m.matrix[0][0] * b3 - m.matrix[0][1] * b1 + m.matrix[0][2] * b0; + inverse_m[0][2] = +m.matrix[3][1] * a5 - m.matrix[3][2] * a4 + m.matrix[3][3] * a3; + inverse_m[1][2] = -m.matrix[3][0] * a5 + m.matrix[3][2] * a2 - m.matrix[3][3] * a1; + inverse_m[2][2] = +m.matrix[3][0] * a4 - m.matrix[3][1] * a2 + m.matrix[3][3] * a0; + inverse_m[3][2] = -m.matrix[3][0] * a3 + m.matrix[3][1] * a1 - m.matrix[3][2] * a0; + inverse_m[0][3] = -m.matrix[2][1] * a5 + m.matrix[2][2] * a4 - m.matrix[2][3] * a3; + inverse_m[1][3] = +m.matrix[2][0] * a5 - m.matrix[2][2] * a2 + m.matrix[2][3] * a1; + inverse_m[2][3] = -m.matrix[2][0] * a4 + m.matrix[2][1] * a2 - m.matrix[2][3] * a0; + inverse_m[3][3] = +m.matrix[2][0] * a3 - m.matrix[2][1] * a1 + m.matrix[2][2] * a0; + + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 4; j++) + { + inverse_m[j][i] /= det; + } + } + + memcpy(m.matrix, inverse_m, sizeof(m.matrix)); +// __complexity = GenericMatrix; + + return true; +} + +void +_MatrixUtilMultiply(Tizen::Graphics::FloatMatrix4& d, const Tizen::Graphics::FloatMatrix4& m1, const Tizen::Graphics::FloatMatrix4& m2) +{ + d = m1 * m2; +} + +}}} + + +#if 0 +void +__PrintMatrix(const Tizen::Graphics::FloatMatrix4& m) +{ + printf("Matrix: %f %f %f %f\n", m.matrix[0][0], m.matrix[1][0], m.matrix[2][0], m.matrix[3][0]); + printf(" %f %f %f %f\n", m.matrix[0][1], m.matrix[1][1], m.matrix[2][1], m.matrix[3][1]); + printf(" %f %f %f %f\n", m.matrix[0][2], m.matrix[1][2], m.matrix[2][2], m.matrix[3][2]); + printf(" %f %f %f %f\n", m.matrix[0][3], m.matrix[1][3], m.matrix[2][2], m.matrix[3][3]); +} + +void +__TestMatrix(void) +{ + Tizen::Graphics::FloatMatrix4 ok; + Tizen::Graphics::FloatMatrix4 m; + Tizen::Graphics::FloatMatrix4 m1; + Tizen::Graphics::FloatMatrix4 m2; + + Tizen::Ui::Animations::_MatrixUtilRotate(m1, 45, 0, 0, 1); + Tizen::Ui::Animations::_MatrixUtilRotate(m2, 45, 0, 1, 0); + ok = m1 * m2; + __PrintMatrix(ok); + + Tizen::Ui::Animations::_MatrixUtilMultiply(m, m1, m2); + __PrintMatrix(m); + + + struct _VariantData + { + union { + int valueInt; + unsigned int valueUInt; + bool valueBool; + float valueFloat; + double valueDouble; + long valueLong; + unsigned long valueULong; + long long valueLongLong; + unsigned long long valueULongLong; + } u; + Tizen::Base::String* pString; + Tizen::Base::DateTime* dateTime; + Tizen::Graphics::Color* color; + Tizen::Graphics::Point* point; + Tizen::Graphics::FloatPoint* floatPoint; + Tizen::Graphics::Rectangle* rect; + Tizen::Graphics::FloatRectangle* rectf; + Tizen::Graphics::Dimension* dimension; + Tizen::Graphics::FloatDimension* floatDimension; + Tizen::Graphics::FloatMatrix4* floatMatrix4; + }; + + struct timeval s; + struct timeval e; + + gettimeofday(&s, null); + for (int i = 0; i < 10000; i++) + { + Tizen::Ui::Variant v; + v = 3; +// memset(&v, 0, sizeof(v)); +// v.floatMatrix4 = new FloatMatrix4; +// v.u.valueInt = 2; + } + gettimeofday(&e, null); + printf("--------- %d\n", static_cast< int >(e.tv_usec - s.tv_usec)); +} +#endif + diff --git a/src/ui/animations/FUiAnim_MatrixUtil.h b/src/ui/animations/FUiAnim_MatrixUtil.h new file mode 100644 index 0000000..d529ee3 --- /dev/null +++ b/src/ui/animations/FUiAnim_MatrixUtil.h @@ -0,0 +1,144 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_MatrixUtil.h + * @brief Header file of _MatrixUtil module + * + * This file contains declarations _MatrixUtil module. + */ + +#ifndef _FUI_ANIM_INTERNAL_MATRIX_UTIL_H_ +#define _FUI_ANIM_INTERNAL_MATRIX_UTIL_H_ + +#include +#include +#include +#include "FUi_Math.h" +#include "FUiAnim_TransformMatrix3Df.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +inline bool +RectUtilIsEqual(const Tizen::Graphics::FloatRectangle& r1, const Tizen::Graphics::FloatRectangle& r2) +{ + return (memcmp(&r1.x, &r2.x, sizeof(r1.x) * 4) == 0); +} + +inline void +RectUtilCopy(Tizen::Graphics::FloatRectangle& d, const Tizen::Graphics::FloatRectangle& s) +{ + memcpy(&d.x, &s.x, sizeof(d.x) * 4); +} + +inline void +RectUtilMakeIntegral(Tizen::Graphics::FloatRectangle& rectangle) +{ + if (unlikely(rectangle.IsEmpty())) + return; + + rectangle.width = ceilf(rectangle.x + rectangle.width); + rectangle.height = ceilf(rectangle.y + rectangle.height); + + rectangle.x = floorf(rectangle.x); + rectangle.y = floorf(rectangle.y); + + rectangle.width -= rectangle.x; + rectangle.height -= rectangle.y; +} + +inline void +RectUtilIntersect(Tizen::Graphics::FloatRectangle& rectangle, const Tizen::Graphics::FloatRectangle& mask) +{ + if (unlikely(rectangle.IsEmpty()) || unlikely(mask.IsEmpty())) + return; + + if (unlikely(rectangle.x >= mask.x + mask.width)) + return; + + if (unlikely(rectangle.y >= mask.y + mask.height)) + return; + + if (unlikely(rectangle.x + rectangle.width <= mask.x)) + return; + + if (unlikely(rectangle.y + rectangle.height <= mask.y)) + return; + + + // intersected + + rectangle.x = _Max(rectangle.x, mask.x); + rectangle.y = _Max(rectangle.y, mask.y); + rectangle.width = _Min(rectangle.x + rectangle.width, mask.x + mask.width) - rectangle.x; + rectangle.height = _Min(rectangle.y + rectangle.height, mask.y + mask.height) - rectangle.y; +} + +inline void +RectUtilUnion(Tizen::Graphics::FloatRectangle& rectangle, const Tizen::Graphics::FloatRectangle& source) +{ + if (rectangle.IsEmpty()) + { + if (source.IsEmpty()) + return; + + rectangle = source; + return; + } + else + { + if (source.IsEmpty()) + return; + } + + + // intersected + float x = _Min(rectangle.x, source.x); + float y = _Min(rectangle.y, source.y); + float width = _Max(rectangle.x + rectangle.width, source.x + source.width) - x; + float height = _Max(rectangle.y + rectangle.height, source.y + source.height) - y; + + rectangle.SetBounds(x, y, width, height); +} + + +inline void +MatrixUtilCopy(Tizen::Graphics::FloatMatrix4& d, const Tizen::Graphics::FloatMatrix4& s) +{ + memcpy(d.matrix, s.matrix, sizeof(d.matrix)); +} + +Matrix4Type _GetMatrix4Type(const Tizen::Graphics::FloatMatrix4& floatMatrix); +void _MatrixUtilSetIdentity(Tizen::Graphics::FloatMatrix4& m); +bool _MatrixUtilIsEqual(const Tizen::Graphics::FloatMatrix4& m1, const Tizen::Graphics::FloatMatrix4& m2); +void _MatrixUtilSetTranslation(Tizen::Graphics::FloatMatrix4& m, float tx, float ty, float tz); +void _MatrixUtilTransform(const Tizen::Graphics::FloatMatrix4& m, float* pX, float* pY, float* pZ); +void _MatrixUtilTranslate(Tizen::Graphics::FloatMatrix4& m, float tx, float ty, float tz); +bool _MatrixUtilIsTranslation(const Tizen::Graphics::FloatMatrix4& m); +void _MatrixUtilScale(Tizen::Graphics::FloatMatrix4& m, float sx, float sy, float sz); +void _MatrixUtilAtAnchor(Tizen::Graphics::FloatMatrix4& m, float x, float y, float z); +void _MatrixUtilRotate(Tizen::Graphics::FloatMatrix4& m, float angle, float x, float y, float z); +bool _MatrixUtilInvert(Tizen::Graphics::FloatMatrix4& m); +void _MatrixUtilMultiply(Tizen::Graphics::FloatMatrix4& d, const Tizen::Graphics::FloatMatrix4& m1, const Tizen::Graphics::FloatMatrix4& m2); + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_MATRIX_UTIL_H_ + diff --git a/src/ui/animations/FUiAnim_NativeLayer.cpp b/src/ui/animations/FUiAnim_NativeLayer.cpp new file mode 100644 index 0000000..238e1b1 --- /dev/null +++ b/src/ui/animations/FUiAnim_NativeLayer.cpp @@ -0,0 +1,109 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_NativeLayer.cpp + * @brief This file contains implementation of _NativeLayer class + * + * This file contains implementation _NativeLayer class. + */ + +#include +#include + +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_NativeLayer.h" +#include "FUiAnim_DisplayManager.h" +#include "FUiAnim_EflLayer.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +_NativeLayer::_NativeLayer(void) + : _pRootVisualElement(null) +{ + +} +_NativeLayer::~_NativeLayer(void) +{ + if(_pRootVisualElement) + { + _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); + if(pDisplayManager) + { + pDisplayManager->UnregisterRoot(*_pRootVisualElement); + } + _pRootVisualElement->SetNativeLayer(null); + _pRootVisualElement->Destroy(); + _pRootVisualElement = null; + } +} + +_NativeLayer* +_NativeLayer::CreateInstanceN(void) +{ +#if defined(VE_EFL) + _EflLayer* pLayer = new (std::nothrow) _EflLayer; + + if (pLayer) + { + pLayer->Construct(); + } + return pLayer; + +#else ////#elif defined(VE_OPENGL) + + return null; + +#endif + +} + +result +_NativeLayer::Construct(void) +{ + SysAssertf(_pRootVisualElement == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + _pRootVisualElement = new _RootVisualElement(); + result r = _pRootVisualElement->Construct(); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Propagating."); + _pRootVisualElement->SetShowState(true); + + _DisplayManager* pDisplayManager = _DisplayManager::GetInstance(); + if(pDisplayManager) + { + pDisplayManager->RegisterRoot(*_pRootVisualElement); + } + + r = OnConstructed(); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Constructing failed."); + + _pRootVisualElement->SetNativeLayer(this); + + r = Configure(*_pRootVisualElement); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Configuring failed."); + + return E_SUCCESS; +} + +_RootVisualElement* +_NativeLayer::GetRootVisualElement(void) const +{ + return _pRootVisualElement; +} + +}}} diff --git a/src/ui/animations/FUiAnim_PointAnimationImpl.cpp b/src/ui/animations/FUiAnim_PointAnimationImpl.cpp new file mode 100644 index 0000000..cd96213 --- /dev/null +++ b/src/ui/animations/FUiAnim_PointAnimationImpl.cpp @@ -0,0 +1,127 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_PointAnimationImpl.cpp + * @brief This file contains implementation of _PointAnimationImpl class + * + * This file contains implementation _PointAnimationImpl class. + */ + +#include +#include + +#include +#include +#include +#include + +#include "FUiAnim_AnimationBaseImpl.h" +#include "FUiAnim_PointAnimationImpl.h" +#include "FUiAnim_VisualElementAnimationVariantInterpolator.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +_PointAnimationImpl::~_PointAnimationImpl(void) +{ +} + +_PointAnimationImpl::_PointAnimationImpl(PointAnimation* pPoint) + : startValue(Point(0, 0)) + , endValue(Point(0, 0)) + , __pPointAnimation(pPoint) +{ +} + +result +_PointAnimationImpl::CopyPointAnimationValue(const PointAnimation& pointAnimation) +{ + result r = E_SUCCESS; + + _AnimationBaseImpl* pAnimationBaseImpl = __pPointAnimation->_pAnimationBaseImpl; + + // Deleting the contents of existing keyframe + r = pAnimationBaseImpl->RemoveAllKeyFrames(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + // Copying the contents + startValue = pointAnimation._pPointAnimationImpl->startValue; + endValue = pointAnimation._pPointAnimationImpl->endValue; + + if (pointAnimation._pAnimationBaseImpl->keyFrameList.GetCount() == 0) + { + return E_SUCCESS; + } + + IMapEnumeratorT< long, Object* >* pMapEnum = null; + MapEntryT< long, Object* > value; + Point* pPointObj = null; + + pMapEnum = pointAnimation._pAnimationBaseImpl->keyFrameList.GetMapEnumeratorN(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_ANIM, (pMapEnum), r, "Failed to get enumerator."); + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + r = pMapEnum->GetCurrent(value); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + Point* pPointValue = dynamic_cast< Point* >(value.GetValue()); + SysTryCatch(NID_UI_ANIM, (pPointValue), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. KeyFrame value is invalid."); + + pPointObj = new (std::nothrow) Point(*pPointValue); + SysTryCatch(NID_UI_ANIM, (pPointObj), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pAnimationBaseImpl->keyFrameList.Add(value.GetKey(), pPointObj); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + delete pMapEnum; + + return E_SUCCESS; + +CATCH: + delete pPointObj; + delete pMapEnum; + + return r; +} + +result +_PointAnimationImpl::GetAnimatedValue(float actualProgress, Tizen::Graphics::Point& animatedValue) const +{ + Variant startPoint(startValue); + Variant endPoint(endValue); + Variant value(Point(0,0)); + + _VisualElementAnimationVariantInterpolator variantInterpolator; + result r = variantInterpolator.Interpolate(actualProgress, startPoint, endPoint, value); + + animatedValue = value.ToPoint(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to get the animated value."); + return r; +} + +}}} //Tizen::Ui::Animations diff --git a/src/ui/animations/FUiAnim_PointAnimationImpl.h b/src/ui/animations/FUiAnim_PointAnimationImpl.h new file mode 100644 index 0000000..33b77fd --- /dev/null +++ b/src/ui/animations/FUiAnim_PointAnimationImpl.h @@ -0,0 +1,107 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_PointAnimationImpl.h + * @brief This is the header file for the _PointAnimationImpl class. + * + * This header file contains the declarations of the _PointAnimationImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_POINT_ANIMATION_IMPL_H_ +#define _FUI_ANIM_INTERNAL_POINT_ANIMATION_IMPL_H_ + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _PointAnimationImpl + : public Tizen::Base::Object +{ + +public: + /** + * Destructor for %_PointAnimationImpl class. + */ + ~_PointAnimationImpl(void); + + /** + * Default constructor for %_PointAnimationImpl class. + */ + _PointAnimationImpl(PointAnimation* pPoint); + + /** + * To copy float animation object + * + * @since 2.0 + * @return An error code + * @param[in] pointAnimation Point animation object + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result CopyPointAnimationValue(const PointAnimation& pointAnimation); + + /** + * Gets the animated value for the current time. + * + * @since 2.0 + * @return An error code + * @param[in] actualProgress The current time value of the animation @n + * The value should be between @c 0 and 1 + * @param[out] animatedValue The animated value for the current time passed as the input parameter + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_STATE This instance has not been properly constructed. + * @exception E_SYSTEM A system error has occurred. + * + */ + result GetAnimatedValue(float actualProgress, Tizen::Graphics::Point& animatedValue) const; + + /** + * The start value of the animation + */ + Tizen::Graphics::Point startValue; + + /** + * The end value of the animation + */ + Tizen::Graphics::Point endValue; + + +private: + /** + * Private copy constructor. + */ + _PointAnimationImpl(const _PointAnimationImpl& rhs); + + /** + * Private assignment operator. + */ + _PointAnimationImpl& operator =(const _PointAnimationImpl& rhs); + + /** + * This is object of PointAnimation class + */ + PointAnimation* __pPointAnimation; +}; // _PointAnimationImpl + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_POINT_ANIMATION_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_RectangleAnimationImpl.cpp b/src/ui/animations/FUiAnim_RectangleAnimationImpl.cpp new file mode 100644 index 0000000..0641c7d --- /dev/null +++ b/src/ui/animations/FUiAnim_RectangleAnimationImpl.cpp @@ -0,0 +1,132 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_RectangleAnimationImpl.cpp + * @brief This file contains implementation of _RectangleAnimationImpl class + * + * This file contains implementation _RectanngleAnimationImpl class. + */ + +#include +#include + +#include + +#include "FUiAnim_VisualElementAnimationVariantInterpolator.h" +#include "FUiAnim_AnimationBaseImpl.h" +#include "FUiAnim_RectangleAnimationImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +_RectangleAnimationImpl::~_RectangleAnimationImpl(void) +{ + +} + +_RectangleAnimationImpl::_RectangleAnimationImpl(RectangleAnimation* pRectangle) + : anchorX(0.0) + , anchorY(0.0) + , startValue(Rectangle(0, 0, 0, 0)) + , endValue(Rectangle(0, 0, 0, 0)) + , __pRectangleAnimation(pRectangle) +{ + +} + +result +_RectangleAnimationImpl::CopyRectangleAnimationValue(const RectangleAnimation& rectangleAnimation) +{ + result r = E_SUCCESS; + + _AnimationBaseImpl* pAnimationBaseImpl = __pRectangleAnimation->_pAnimationBaseImpl; + + // Deleting the contents of existing keyframe + r = pAnimationBaseImpl->RemoveAllKeyFrames(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + // Copying the contents + startValue = rectangleAnimation._pRectangleAnimationImpl->startValue; + endValue = rectangleAnimation._pRectangleAnimationImpl->endValue; + + if (rectangleAnimation._pAnimationBaseImpl->keyFrameList.GetCount() == 0) + { + return E_SUCCESS; + } + + IMapEnumeratorT< long, Object* >* pMapEnum = null; + MapEntryT< long, Object* > value; + Rectangle* pRectObj = null; + + pMapEnum = rectangleAnimation._pAnimationBaseImpl->keyFrameList.GetMapEnumeratorN(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_ANIM, (pMapEnum), r, "Failed to get enumerator."); + + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + r = pMapEnum->GetCurrent(value); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + Rectangle* pRectValue = dynamic_cast< Rectangle* >(value.GetValue()); + SysTryCatch(NID_UI_ANIM, (pRectValue), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. KeyFrame value is invalid."); + + pRectObj = new (std::nothrow) Rectangle(*pRectValue); + SysTryCatch(NID_UI_ANIM, (pRectObj), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pAnimationBaseImpl->keyFrameList.Add(value.GetKey(), pRectObj); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + delete pMapEnum; + + return E_SUCCESS; + +CATCH: + delete pRectObj; + delete pMapEnum; + + return r; +} + +result +_RectangleAnimationImpl::GetAnimatedValue(float actualProgress, Tizen::Graphics::Rectangle& animatedValue) const +{ + Variant startRect(startValue); + Variant endRect(endValue); + Variant value(Rectangle(0, 0, 0, 0)); + + _VisualElementAnimationVariantInterpolator variantInterpolator; + result r = variantInterpolator.Interpolate(actualProgress, startRect, endRect, value); + + animatedValue = value.ToRectangle(); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, " A system error has been occurred. Failed to get the animated value."); + + return r; +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_RectangleAnimationImpl.h b/src/ui/animations/FUiAnim_RectangleAnimationImpl.h new file mode 100644 index 0000000..e77baf3 --- /dev/null +++ b/src/ui/animations/FUiAnim_RectangleAnimationImpl.h @@ -0,0 +1,116 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_RectangleAnimationImpl.h + * @brief This is the header file for the _RectangleAnimationImpl class. + * + * This header file contains the declarations of the _RectangleAnimationImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_RECTANGLE_ANIMATION_IMPL_H_ +#define _FUI_ANIM_INTERNAL_RECTANGLE_ANIMATION_IMPL_H_ + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _RectangleAnimationImpl + : public Tizen::Base::Object +{ + +public: + /** + * Destructor for %_RectangleAnimationImpl class. + */ + ~_RectangleAnimationImpl(void); + + /** + * Default constructor for %_RectangleAnimationImpl class. + */ + _RectangleAnimationImpl(RectangleAnimation* pRectangle); + + /** + * To copy Point animation object + * + * @since 2.0 + * @return An error code + * @param[in] rectangleAnimation Rectangle animation object + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result CopyRectangleAnimationValue(const RectangleAnimation& rectangleAnimation); + + /** + * Gets the animated value for the current time. + * + * @since 2.0 + * @return An error code + * @param[in] actualProgress The current time value of the animation @n + * The value should be between @c 0 and 1 + * @param[out] animatedValue The animated value for the current time passed as the input parameter + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + * @exception E_INVALID_STATE This instance has not been properly constructed. + * @exception E_SYSTEM A system error has occurred. + * + */ + result GetAnimatedValue(float actualProgress, Tizen::Graphics::Rectangle& animatedValue) const; + + /** + * The Anchor X value for scaling + */ + float anchorX; + + /** + * The Anchor Y value for scaling + */ + float anchorY; + + /** + * The start value of the animation + */ + Tizen::Graphics::Rectangle startValue; + + /** + * The end value of the animation + */ + Tizen::Graphics::Rectangle endValue; + +private: + /** + * Private copy constructor. + */ + _RectangleAnimationImpl(const _RectangleAnimationImpl& rhs); + + /** + * Private assignment operator. + */ + _RectangleAnimationImpl& operator =(const _RectangleAnimationImpl& rhs); + + /** + * This is object of RectangleAnimation class + */ + RectangleAnimation* __pRectangleAnimation; +}; // _RectangleAnimationImpl + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_RECTANGLE_ANIMATION_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_RootVisualElement.cpp b/src/ui/animations/FUiAnim_RootVisualElement.cpp new file mode 100644 index 0000000..f07330d --- /dev/null +++ b/src/ui/animations/FUiAnim_RootVisualElement.cpp @@ -0,0 +1,97 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_RootVisualElement.cpp + * @brief This is the implementation file for the _RootVisualElement class. + * + * This file contains implementation _RootVisualElement class. + */ + +#include +#include +#include "FUiAnim_DisplayManager.h" +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_NativeLayer.h" +#include "FUiAnim_VisualElementImpl.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +// Root Element implementation +_RootVisualElement::_RootVisualElement(void) + : __needsUpdateFromRoot(false) + , __isModel(true) + , __pLayer(null) +{ + _pVisualElementImpl->__isRoot = true; + _pVisualElementImpl->__isInternal = true; + _pVisualElementImpl->__isImplicitAnimationEnabled = false; +} + +_RootVisualElement::_RootVisualElement(const _RootVisualElement& rhs) + : _VisualElement(rhs) + , __needsUpdateFromRoot(false) + , __isModel(false) + , __pLayer(rhs.__pLayer) +{ + +} + +_RootVisualElement::~_RootVisualElement(void) +{ + + if(__pLayer) + { + SysLogException(NID_UI_ANIM, E_INVALID_STATE,"[E_INVALID_STATE] The RootVisualElement instance has been destroyed, but the layer information was not cleaned."); +// __pLayer->_pRootVisualElement = NULL; + } + __pLayer = NULL; +} + + +VisualElement* +_RootVisualElement::CloneN(void) const +{ + return new (std::nothrow) _RootVisualElement(*this); +} + +result +_RootVisualElement::SetNativeLayer(_NativeLayer* pLayer) +{ + if (__pLayer == pLayer) + { + return E_SUCCESS; + } + + SysTryReturnResult(NID_UI_ANIM, !__pLayer || (__pLayer && pLayer == null), E_INVALID_STATE, "The layer is already assigned to another RootVisualElement instance."); + __pLayer = pLayer; + + _RootVisualElement* pPresentation = null; + if (_pVisualElementImpl && _pVisualElementImpl->__pPresentation) + { + pPresentation = dynamic_cast<_RootVisualElement*>(_pVisualElementImpl->__pPresentation->__pPublicInstance); + } + SysTryReturnResult(NID_UI_ANIM, pPresentation, E_INVALID_STATE, "The presentation instance is not available."); + + pPresentation->__pLayer = pLayer; + + return E_SUCCESS; +} + +}}} //namespace Tizen { namespace Ui { namespace Animations { + diff --git a/src/ui/animations/FUiAnim_RotateAnimationImpl.cpp b/src/ui/animations/FUiAnim_RotateAnimationImpl.cpp new file mode 100644 index 0000000..5fc2558 --- /dev/null +++ b/src/ui/animations/FUiAnim_RotateAnimationImpl.cpp @@ -0,0 +1,46 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_RotateAnimationImpl.cpp + * @brief This file contains implementation of _RotateAnimationImpl class + * + * This file contains implementation _RotateAnimationImpl class. + */ + + +#include "FUiAnim_RotateAnimationImpl.h" + + +using namespace Tizen::Ui::Animations; + + +namespace Tizen { namespace Ui { namespace Animations +{ + +_RotateAnimationImpl::~_RotateAnimationImpl(void) +{ +} + +_RotateAnimationImpl::_RotateAnimationImpl(RotateAnimation* pRotate) + : anchorX(0.5f) + , anchorY(0.5f) + , __pRotateAnimation(pRotate) +{ +} + +}}} //Tizen::Ui::Animations diff --git a/src/ui/animations/FUiAnim_RotateAnimationImpl.h b/src/ui/animations/FUiAnim_RotateAnimationImpl.h new file mode 100644 index 0000000..365300b --- /dev/null +++ b/src/ui/animations/FUiAnim_RotateAnimationImpl.h @@ -0,0 +1,78 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_RotateAnimationImpl.h + * @brief This is the header file for the _RotateAnimationImpl class. + * + * This header file contains the declarations of the _RotateAnimationImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_ROTATE_ANIMATION_IMPL_H_ +#define _FUI_ANIM_INTERNAL_ROTATE_ANIMATION_IMPL_H_ + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _RotateAnimationImpl + : public Tizen::Base::Object +{ + +public: + /** + * Destructor for %_RotateAnimationImpl class. + */ + ~_RotateAnimationImpl(void); + + /** + * Default constructor for %_RotateAnimationImpl class. + */ + _RotateAnimationImpl(RotateAnimation* pRotate); + + /** + * The Anchor X value for scaling + */ + float anchorX; + + /** + * The Anchor Y value for scaling + */ + float anchorY; + +private: + /** + * Private copy constructor. + */ + _RotateAnimationImpl(const _RotateAnimationImpl& rhs); + + /** + * Private assignment operator. + */ + _RotateAnimationImpl& operator =(const _RotateAnimationImpl& rhs); + + /** + * This is object of RotateAnimation class + */ + Tizen::Ui::Animations::RotateAnimation* __pRotateAnimation; +}; // _RotateAnimationImpl + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_ROTATE_ANIMATION_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_TimingFunction.h b/src/ui/animations/FUiAnim_TimingFunction.h new file mode 100644 index 0000000..fd95259 --- /dev/null +++ b/src/ui/animations/FUiAnim_TimingFunction.h @@ -0,0 +1,40 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_TimingFunction.h + * @brief This is the header file for the TimingFunction classes. + * + * This header file contains the declarations of the TimingFunction classes. + */ + +#ifndef _FUI_ANIM_INTERNAL_TIMING_FUNCTION_H_ +#define _FUI_ANIM_INTERNAL_TIMING_FUNCTION_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif //_FUI_ANIM_INTERNAL_TIMING_FUNCTION_H_ diff --git a/src/ui/animations/FUiAnim_TransactionNode.cpp b/src/ui/animations/FUiAnim_TransactionNode.cpp new file mode 100644 index 0000000..a42dbe9 --- /dev/null +++ b/src/ui/animations/FUiAnim_TransactionNode.cpp @@ -0,0 +1,2143 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_TransactionNode.cpp + * @brief This file contains implementation of _TransactionNode class + * + * This file contains implementation _TransactionNode class. + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include "FUi_Math.h" +#include "FUi_EcoreEvas.h" +#include "FUiAnim_VisualElementValueAnimationImpl.h" +#include "FUiAnim_VisualElementAnimationKeyFrame.h" +#include "FUiAnim_TransactionNode.h" +#include "FUiAnim_Debug.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +//#define VE_DEBUG_ANIMATION + +namespace Tizen { namespace Ui { namespace Animations +{ + +#define TN_CAST(_T) static_cast< _TransactionNode* >(_T) +#define TN_CONST_CAST(_T) static_cast< _TransactionNode* >(const_cast< Object* >(_T)) + +#define AD_CAST(_AD) static_cast< _AnimationData* >(_AD) +#define AD_CONST_CAST(_AD) static_cast< _AnimationData* >(const_cast< Object* >(_AD)) + +unsigned int +_AnimationTime::GetTime(bool loopTime) +{ +#ifdef VE_DEBUG_ANIMATION + static unsigned int debug_time = 0; + + debug_time += 20; + return debug_time; +#else + if (likely(loopTime)) + { + return (unsigned int) (ecore_loop_time_get() * 1000.0f); // ecore_loop_time_get() returns a value in seconds. + } + + return (unsigned int) (ecore_time_get() * 1000.0f); // ecore_loop_time_get() returns a value in seconds. +#endif +} + +_AnimationData::_AnimationData(VisualElement& target, const Tizen::Base::String* pName, VisualElementAnimation& animation) + : __target(target) + , __animation(animation) + , __startValue() + , __endValue() + , __totalDuration(0) + , __baseTime(0) + , __currentRepeatCount(1) + , __keyFrameIndex(0) + , __forward(true) + , __progress(0.0f) + , __status(_STATUS_READY) + , __pendingMode(_PENDING_MODE_NONE) +{ + if (pName != null) + { + __name = *pName; + } + + VisualElementValueAnimation* pValueAnimation = dynamic_cast< VisualElementValueAnimation* >(&__animation); + if (pValueAnimation) + { + __startValue = pValueAnimation->GetStartValue(); + __endValue = pValueAnimation->GetEndValue(); + } + + long repeatCount = __animation.IsAutoReverseEnabled() ? __animation.GetRepeatCount() * 2 : __animation.GetRepeatCount(); + + __totalDuration = __animation.GetDelay() + (__animation.GetDuration() * repeatCount - __animation.GetOffset()); + +#ifdef VE_DEBUG_MODULE + __tick = 0; +#endif +} + +_AnimationData::~_AnimationData(void) +{ + delete &__animation; +} + +VisualElementAnimation& +_AnimationData::GetAnimation(void) const +{ + return __animation; +} + +String +_AnimationData::GetName(void) const +{ + return __name; +} + +VisualElement& +_AnimationData::GetTarget(void) const +{ + return __target; +} + +bool +_AnimationData::IsRemoved(void) const +{ + return (__pendingMode == _PENDING_MODE_REMOVING || __pendingMode == _PENDING_MODE_REMOVE); +} + +result +_AnimationData::SetBaseTime(unsigned int baseTime) +{ + __baseTime = baseTime; + + if (__status == _STATUS_END) + { + // reset for group repeat + __status = _STATUS_READY; + __keyFrameIndex = 0; + __forward = true; + } + +#ifdef VE_DEBUG_MODULE + if (_VeDebug::IsDebugEnabled()) + { + __tick = baseTime; + } +#endif + + return E_SUCCESS; +} + +void +_AnimationData::FillValueForProperty(void) +{ + if (__startValue.IsEmpty() || __endValue.IsEmpty()) + { + VisualElementPropertyAnimation* pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(&__animation); + if (pPropertyAnimation) + { + Variant currentValue = __target.GetProperty(pPropertyAnimation->GetPropertyName()); + + if (__startValue.IsEmpty()) + { + __startValue = currentValue; + } + else + { + __endValue = currentValue; + } + } + } +} + +Variant +_AnimationData::CalculateValueByTime(unsigned int currentTime) +{ + long currentRepeatCount = 0; + long oldRepeatCount = 0; + long repeatCount = 0; + long delay = 0; + long duration = 0; + long offset = 0; + + // Set current Time +#ifdef VE_DEBUG_MODULE + if (_VeDebug::IsDebugEnabled()) + { + currentTime = __tick; + __tick += 16; + } +#endif + + if (__status == _STATUS_END) + { + return Variant(); + } + + if (__status == _STATUS_STOP) + { + __status = _STATUS_END; + + return CalculateValue(); + } + + // Clac progress + if (__animation.GetScaleRatio() > 0.f) + { + currentTime = (unsigned int) ((currentTime - __baseTime) / __animation.GetScaleRatio()); // Apply time scale value + } + + delay = __animation.GetDelay(); + + if (currentTime < (unsigned int)(delay)) + { + // Not started + __currentRepeatCount = 1; + __forward = true; + __progress = -1.0f; + + return CalculateValue(); + } + + offset = __animation.GetOffset(); + repeatCount = __animation.GetRepeatCount(); + duration = __animation.GetDuration(); + if (duration == 0) + { + duration = 1; + repeatCount = 1; + } + + oldRepeatCount = __currentRepeatCount; + currentRepeatCount = ((currentTime - delay + offset) / duration) + 1; + + if (__animation.IsAutoReverseEnabled()) + { + __currentRepeatCount = (currentRepeatCount + 1) >> 1; + + __progress = static_cast< float >(currentTime - (delay + duration * (currentRepeatCount - 1) - offset)) / static_cast< float >(duration); + + if (currentRepeatCount & 0x1) + { + // forward + if (!__forward) + { + __progress = 0.0f; + __forward = true; + } + } + else + { + // backward + if (__forward) + { + __progress = 1.0f; + __forward = false; + } + else + { + __progress = 1.0f - __progress; + } + + } + } + else + { + __currentRepeatCount = currentRepeatCount; + __forward = true; + + __progress = static_cast< float >(currentTime - (delay + duration * (currentRepeatCount - 1) - offset)) / static_cast< float >(duration); + } + + if (__status == _STATUS_READY) + { + __status = _STATUS_START; + + FillValueForProperty(); + } + else if (repeatCount > 0 && currentTime >= __totalDuration) // infinite loop if repeatCount == 0 + { + // Finished + __currentRepeatCount = repeatCount; + __forward = true; + __progress = (__animation.IsAutoReverseEnabled() ? 0.0f : 1.0f); + + __status = _STATUS_STOP; + } + else if (__currentRepeatCount > oldRepeatCount) + { + __status = _STATUS_REPEAT; + + __progress = (__animation.IsAutoReverseEnabled() ? 0.0f : 1.0f); + } + else + { + __status = _STATUS_RUNNING; + } + + return CalculateValue(); +} + +Variant +_AnimationData::CalculateValue(void) +{ + float calcProgress = 0.0f; + Variant current; + + if (__progress < 0.0f || __progress > 1.0f) + { + return current; + } + + VisualElementValueAnimation* pValueAnimation = dynamic_cast< VisualElementValueAnimation* >(&__animation); + + // In case of VisualElementAnimation + if (pValueAnimation == null) + { + return current; + } + + const IVisualElementAnimationTimingFunction* pTimingFunction = __animation.GetTimingFunction(); + SysAssertf(pTimingFunction, "Timing function is null."); + + const IVisualElementAnimationValueInterpolator* pInterpolator = __animation.GetValueInterpolator(); + SysAssertf(pInterpolator, "Interpolotor is null."); + + _VisualElementAnimationKeyFrame* pKeyFrame = _VisualElementValueAnimationImpl::GetInstance(*pValueAnimation)->GetKeyFrame(); + + if (pKeyFrame != null) + { + _VariantEx start; + _VariantEx end; + + int keyFrameCount = pKeyFrame->GetCount(); + SysAssertf(keyFrameCount > 0, "The count of key frames is zero."); + + if (__forward) + { + if (__keyFrameIndex == keyFrameCount) // last section + { + _VisualElementAnimationKeyFrameInfo* pFromInfo = pKeyFrame->GetKeyFrameInfoAt(__keyFrameIndex - 1); + SysAssertf(pFromInfo, "Index (%d) of key frame is invalid.", __keyFrameIndex - 1); + + start = pFromInfo->GetValueEx(); + end = __endValue; + + calcProgress = pTimingFunction->CalculateProgress((__progress - pFromInfo->GetTime()) / (1.0f - pFromInfo->GetTime())); + + if (_FloatCompare(__progress, 1.0f)) + { + __keyFrameIndex = 0; + } + } + else + { + _VisualElementAnimationKeyFrameInfo* pToInfo = pKeyFrame->GetKeyFrameInfoAt(__keyFrameIndex); + SysAssertf(pToInfo, "Index (%d) of key frame is invalid.", __keyFrameIndex); + + while (__progress > pToInfo->GetTime()) + { + __keyFrameIndex++; + if (__keyFrameIndex == keyFrameCount) + { + break; + } + + pToInfo = pKeyFrame->GetKeyFrameInfoAt(__keyFrameIndex); + SysAssertf(pToInfo, "Index (%d) of key frame is invalid.", __keyFrameIndex); + } + + const IVisualElementAnimationTimingFunction* pToTimingFunction = pToInfo->GetTimingFunction(); + if (pToTimingFunction == null) + { + pToTimingFunction = pTimingFunction; + } + + if (__keyFrameIndex == 0) //first section + { + start = __startValue; + end = pToInfo->GetValueEx(); + + calcProgress = pToTimingFunction->CalculateProgress(__progress / pToInfo->GetTime()); + } + else if (__keyFrameIndex == keyFrameCount) //last section + { + // pToInfo means pFromInfo in last section + start = pToInfo->GetValueEx(); + end = __endValue; + + calcProgress = pTimingFunction->CalculateProgress((__progress - pToInfo->GetTime()) / (1.0f - pToInfo->GetTime())); + } + else + { + _VisualElementAnimationKeyFrameInfo* pFromInfo = pKeyFrame->GetKeyFrameInfoAt(__keyFrameIndex - 1); + SysAssertf(pFromInfo, "Index (%d) of key frame is invalid.", __keyFrameIndex - 1); + + start = pFromInfo->GetValueEx(); + end = pToInfo->GetValueEx(); + + calcProgress = pToTimingFunction->CalculateProgress((__progress - pFromInfo->GetTime()) / (pToInfo->GetTime() - pFromInfo->GetTime())); + } + } + } + else //backward + { + if (__keyFrameIndex == 0) //last section in backward (= first section in forward) + { + _VisualElementAnimationKeyFrameInfo* pFromInfo = pKeyFrame->GetKeyFrameInfoAt(__keyFrameIndex); + SysAssertf(pFromInfo, "Index (%d) of key frame is invalid.", __keyFrameIndex); + + const IVisualElementAnimationTimingFunction* pFromTimingFunction = pFromInfo->GetTimingFunction(); + if (pFromTimingFunction == null) + { + pFromTimingFunction = pTimingFunction; + } + + start = __startValue; + end = pFromInfo->GetValueEx(); + + calcProgress = pFromTimingFunction->CalculateProgress(__progress / pFromInfo->GetTime()); + } + else + { + _VisualElementAnimationKeyFrameInfo* pToInfo = pKeyFrame->GetKeyFrameInfoAt(__keyFrameIndex - 1); + SysAssertf(pToInfo, "Index (%d) of key frame is invalid.", __keyFrameIndex - 1); + + while (__progress < pToInfo->GetTime()) + { + __keyFrameIndex--; + if (__keyFrameIndex == 0) + { + break; + } + + pToInfo = pKeyFrame->GetKeyFrameInfoAt(__keyFrameIndex - 1); + SysAssertf(pToInfo, "Index (%d) of key frame is invalid", __keyFrameIndex - 1); + } + + const IVisualElementAnimationTimingFunction* pToTimingFunction = pToInfo->GetTimingFunction(); + if (pToTimingFunction == null) + { + pToTimingFunction = pTimingFunction; + } + + if (__keyFrameIndex == 0) //last section in backward + { + start = __startValue; + end = pToInfo->GetValueEx(); + + calcProgress = pToTimingFunction->CalculateProgress(__progress / pToInfo->GetTime()); + } + else if (__keyFrameIndex == keyFrameCount) //first section in backward (= last section in forward) + { + start = pToInfo->GetValueEx(); + end = __endValue; + + calcProgress = pTimingFunction->CalculateProgress((__progress - pToInfo->GetTime()) / (1.0f - pToInfo->GetTime())); + } + else + { + _VisualElementAnimationKeyFrameInfo* pFromInfo = pKeyFrame->GetKeyFrameInfoAt(__keyFrameIndex); + SysAssertf(pFromInfo, "Index (%d) of key frame is invalid.", __keyFrameIndex); + + const IVisualElementAnimationTimingFunction* pFromTimingFunction = pFromInfo->GetTimingFunction(); + if (pFromTimingFunction == null) + { + pFromTimingFunction = pTimingFunction; + } + + start = pToInfo->GetValueEx(); + end = pFromInfo->GetValueEx(); + + calcProgress = pFromTimingFunction->CalculateProgress((__progress - pToInfo->GetTime()) / (pFromInfo->GetTime() - pToInfo->GetTime())); + } + } + } + + if (pInterpolator->Interpolate(calcProgress, start, end, current) != E_SUCCESS) + { + return start; + } + } + else // no keyframe + { + calcProgress = pTimingFunction->CalculateProgress(__progress); + + if (pInterpolator->Interpolate(calcProgress, __startValue, __endValue, current) != E_SUCCESS) + { + return __startValue; + } + } + + return current; +} + +void +_AnimationData::NotifyAnimationStatus(bool completed) +{ + if (__status == _STATUS_END) + { + return; + } + + IVisualElementAnimationStatusEventListener* pListener = _VisualElementAnimationImpl::GetInstance(__animation)->GetStatusEventListener(); + if (pListener == null) + { + return; + } + + _VisualElementAnimationImpl* pAnimationImpl = _VisualElementAnimationImpl::GetInstance(__animation); + + if (completed == false) + { + pListener->OnVisualElementAnimationFinished(__animation, __name, pAnimationImpl->GetEventTarget(), false); + return; + } + + switch (__status) + { + case _AnimationData::_STATUS_START: + pListener->OnVisualElementAnimationStarted(__animation, __name, pAnimationImpl->GetEventTarget()); + break; + + case _AnimationData::_STATUS_REPEAT: + pListener->OnVisualElementAnimationRepeated(__animation, __name, pAnimationImpl->GetEventTarget(), __currentRepeatCount); + break; + + case _AnimationData::_STATUS_STOP: + pListener->OnVisualElementAnimationFinished(__animation, __name, pAnimationImpl->GetEventTarget(), true); + break; + + default: + break; + } +} + +void +_AnimationData::NotifyAnimationFinished(bool completed) +{ + if (__status == _STATUS_END) + { + return; + } + + if (__status != _STATUS_STOP) + { + __status = _STATUS_STOP; + } + + IVisualElementAnimationStatusEventListener* pListener = _VisualElementAnimationImpl::GetInstance(__animation)->GetStatusEventListener(); + if (pListener == null) + { + return; + } + + _VisualElementAnimationImpl* pAnimationImpl = _VisualElementAnimationImpl::GetInstance(__animation); + + pListener->OnVisualElementAnimationFinished(__animation, __name, pAnimationImpl->GetEventTarget(), completed); +} + +void +_AnimationData::OnTickOccurred(VisualElement& target, const Tizen::Ui::Variant& currentValue) +{ + if (currentValue.IsEmpty() == true) + { + return; + } + + VisualElementValueAnimation* pValueAnimation = dynamic_cast< VisualElementValueAnimation* >(&__animation); + + if (pValueAnimation != null) + { + _VisualElementValueAnimationImpl* pValueAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*pValueAnimation); + + pValueAnimationImpl->OnTickOccurred(target, currentValue); + + IVisualElementAnimationTickEventListener *pTickListener = pValueAnimationImpl->GetTickEventListener(); + + if (pTickListener != null) + { + pTickListener->OnTickOccurred(*pValueAnimation, __name, pValueAnimationImpl->GetEventTarget(), currentValue); + } + } +} + +static int id = -1; + +// class _TransactionNode +_TransactionNode::_TransactionNode(void) + : __id(-1) + , __pParent(null) + , __pRoot(this) + , __pDefaultListener(null) + , __pListener(null) + , __isImplicitAnimationEnabled(true) + , __isCommitted(false) + , __isReservedRemove(false) + , __isInAnimationTick(false) + , __status(_STATUS_READY) + , __baseTime(0) + , __adjustedBaseTime(0) + , __currentRepeatCount(1) +{ + ClearLastResult(); + + __id = id = (id >= 0xFFFFFF ? 0 : id + 1); + + result r = __children.Construct(); + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to construct children list.", GetErrorMessage(r)); + + r = __pendingAnimations.Construct(); + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to construct pending list.", GetErrorMessage(r)); + + r = __animations.Construct(); + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to construct animations map.", GetErrorMessage(r)); +} + +_TransactionNode::_TransactionNode(const _TransactionNode& node) + : __id(-1) + , __pParent(null) + , __pRoot(node.__pRoot) + , __pDefaultListener(null) + , __pListener(null) + , __isImplicitAnimationEnabled(node.__isImplicitAnimationEnabled) + , __isCommitted(false) + , __isReservedRemove(false) + , __isInAnimationTick(false) + , __status(_STATUS_READY) + , __baseTime(0) + , __adjustedBaseTime(0) + , __currentRepeatCount(1) +{ + ClearLastResult(); + + __id = id = (id >= 0xFFFFFF ? 0 : id + 1); + + result r = __children.Construct(); + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to construct children list.", GetErrorMessage(r)); + + r = __pendingAnimations.Construct(); + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to construct pending list.", GetErrorMessage(r)); + + r = __animations.Construct(); + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to construct animations map.", GetErrorMessage(r)); + + r = CopyAnimationValue(node); + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to copy the animation value.", GetErrorMessage(r)); +} + +_TransactionNode::~_TransactionNode(void) +{ + __children.RemoveAll(true); + + __pendingAnimations.RemoveAll(true); + + RemoveAllAnimations(); +} + +bool +_TransactionNode::Equals(const Object& obj) const +{ + if (this == &obj) + { + return true; + } + + return false; +} + +int +_TransactionNode::GetId(void) const +{ + return __id; +} + +_TransactionNode* +_TransactionNode::GetParent(void) const +{ + return __pParent; +} + +result +_TransactionNode::SetParent(_TransactionNode& parent) +{ + __pParent = &parent; + + return E_SUCCESS; +} + +result +_TransactionNode::SetDefaultEventListener(const IAnimationTransactionEventListener* pListener) +{ + __pDefaultListener = const_cast< IAnimationTransactionEventListener* >(pListener); + + return E_SUCCESS; +} + +IAnimationTransactionEventListener* +_TransactionNode::GetEventListener(void) const +{ + return __pListener; +} + +result +_TransactionNode::SetEventListener(const IAnimationTransactionEventListener* pListener) +{ + __pListener = const_cast< IAnimationTransactionEventListener* >(pListener); + + return E_SUCCESS; +} + +bool +_TransactionNode::IsImplicitAnimationEnabled(void) const +{ + return __isImplicitAnimationEnabled; +} + +result +_TransactionNode::SetImplicitAnimationEnabled(bool enable) +{ + __isImplicitAnimationEnabled = enable; + + return E_SUCCESS; +} + +int +_TransactionNode::GetChildrenCount(void) const +{ + return __children.GetCount(); +} + +_TransactionNode* +_TransactionNode::GetChild(int transactionId) const +{ + SysTryReturn(NID_UI_ANIM, transactionId > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. transactionId = %d", transactionId); + + int childrenCount = GetChildrenCount(); + + if (childrenCount <= 0) + { + return null; + } + + _TransactionNode* pChild = null; + + for (int index = 0; index < childrenCount; index++) + { + pChild = TN_CONST_CAST(__children.GetAt(index)); + + if (pChild->GetId() == transactionId) + { + return pChild; + } + + pChild = pChild->GetChild(transactionId); + + if (pChild != null) + { + return pChild; + } + } + + return null; +} + +_TransactionNode* +_TransactionNode::GetLastChild(void) const +{ + int index = GetChildrenCount() - 1; + + SysTryReturn(NID_UI_ANIM, index >= 0, null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] This node has no child."); + + return TN_CONST_CAST(__children.GetAt(index)); +} + +result +_TransactionNode::AddChild(_TransactionNode& child) +{ + result r = __children.Add(child); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Propagating."); + + child.SetParent(*this); + + return E_SUCCESS; +} + +void +_TransactionNode::RemoveChild(int transactionId) +{ + SysTryReturnVoidResult(NID_UI_ANIM, transactionId > 0, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. transactionId = %d", transactionId); + + int childrenCount = GetChildrenCount(); + + if (childrenCount <= 0) + { + return; + } + + _TransactionNode* pChild = null; + + for (int index = 0; index < childrenCount; index++) + { + pChild = TN_CAST(__children.GetAt(index)); + + if (pChild->GetId() == transactionId) + { + if (pChild->IsReservedRemove() == false) + { + pChild->RemoveAll(); + + pChild->ReservedRemove(); + + pChild->NotifyTransactionStatus(false); + + RemoveChild(*pChild); + } + break; + } + + pChild->RemoveChild(transactionId); + } +} + +void +_TransactionNode::RemoveChild(_TransactionNode& child) +{ + if (child.IsInAnimationTick()) + { + child.ReservedRemove(); + } + else + { + result r = __children.Remove(child, true); + + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to remove child.", GetErrorMessage(r)); + } +} + +void +_TransactionNode::RemoveAll(void) //TODO: rename RemoveAll() +{ + _TransactionNode* pChild = null; + + int childrenCount = GetChildrenCount(); + + for (int index = childrenCount-1; index >= 0; index--) + { + pChild = TN_CAST(__children.GetAt(index)); + + if (pChild->IsReservedRemove() == false) + { + pChild->RemoveAll(); + + pChild->ReservedRemove(true); + + pChild->NotifyTransactionStatus(false); + + RemoveChild(*pChild); + } + } + + RemoveAllAnimations(); +} + +int +_TransactionNode::GetAnimationCount(void) const +{ + //TODO: make exactly + return __animations.GetCount(); +} + +_AnimationData* +_TransactionNode::GetAnimationDataInPending(VisualElement& target, const String& keyName) const +{ + int pendingCount = __pendingAnimations.GetCount(); + + _AnimationData* pAnimationData = null; + + for (int index = 0; index < pendingCount; index++) + { + pAnimationData = AD_CONST_CAST(__pendingAnimations.GetAt(index)); + + if (&(pAnimationData->GetTarget()) == &target && pAnimationData->IsRemoved() == false) + { + if (pAnimationData->GetName() == keyName) + { + return pAnimationData; + } + } + } + + return null; +} + +_AnimationData* +_TransactionNode::GetAnimationDataInPendingByProperty(VisualElement& target, const String& property) const +{ + int pendingCount = __pendingAnimations.GetCount(); + + _AnimationData* pAnimationData = null; + VisualElementPropertyAnimation* pPropertyAnimation = null; + + for (int index = 0; index < pendingCount; index++) + { + pAnimationData = AD_CONST_CAST(__pendingAnimations.GetAt(index)); + + if (&(pAnimationData->GetTarget()) == &target && pAnimationData->IsRemoved() == false) + { + pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(&(pAnimationData->GetAnimation())); + + if(pPropertyAnimation != null && pPropertyAnimation->GetPropertyName() == property) + { + return pAnimationData; + } + } + } + + return null; +} + +result +_TransactionNode::AddAnimationData(_AnimationData& animationData) +{ + result r = E_SUCCESS; + + ArrayList* pAnimationList = null; + VisualElement* pTarget = &(animationData.GetTarget()); + + __animations.GetValue(pTarget, pAnimationList); + + if (pAnimationList == null) + { + pAnimationList = new (std::nothrow) ArrayList(); + SysTryReturnResult(NID_UI_ANIM, pAnimationList != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = pAnimationList->Construct(); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Failed to construct animation list."); + + __animations.Add(pTarget, pAnimationList); + } + + // base time for root + animationData.SetBaseTime(_AnimationTime::GetTime()); + animationData.SetPendingMode(_AnimationData::_PENDING_MODE_NONE); + + return pAnimationList->Add(animationData); +} + +void +_TransactionNode::RemoveAnimationData(_AnimationData& animationData) +{ + ArrayList* pAnimationList = null; + VisualElement* pTarget = &(animationData.GetTarget()); + + __animations.GetValue(pTarget, pAnimationList); + + if (pAnimationList == null) + { + return; + } + + pAnimationList->Remove(animationData, true); + + if (pAnimationList->GetCount() <= 0) + { + __animations.Remove(pTarget); + + delete pAnimationList; + } +} + +result +_TransactionNode::SetAnimationDataAsPending(_AnimationData& animationData, bool remove, bool completed) +{ + result r = E_SUCCESS; + + if (remove == true) + { + if (animationData.IsRemoved()) + { + return E_SUCCESS; + } + + if (animationData.GetPendingMode() == _AnimationData::_PENDING_MODE_NONE) + { + r = __pendingAnimations.Add(animationData); + } + + animationData.SetPendingMode(_AnimationData::_PENDING_MODE_REMOVING); + + animationData.NotifyAnimationFinished(completed); + + animationData.SetPendingMode(_AnimationData::_PENDING_MODE_REMOVE); + } + else + { + animationData.SetPendingMode(_AnimationData::_PENDING_MODE_ADD); + + r = __pendingAnimations.Add(animationData); + } + + return r; +} + +result +_TransactionNode::AddAnimation(VisualElement& target, const String* pKeyName, VisualElementAnimation& animation) +{ + result r = E_SUCCESS; + + _AnimationData* pAnimationData = new (std::nothrow) _AnimationData(target, pKeyName, animation); + SysTryReturnResult(NID_UI_ANIM, pAnimationData != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + if (__isInAnimationTick == true) + { + r = SetAnimationDataAsPending(*pAnimationData, false); + } + else + { + r = AddAnimationData(*pAnimationData); + } + + if (r != E_SUCCESS) + { + delete pAnimationData; + + return r; + } + + return E_SUCCESS; +} + +result +_TransactionNode::RemoveAnimation(VisualElement& target, const String& keyName) +{ + if (GetAnimationCount() <= 0) + { + return E_OBJ_NOT_FOUND; + } + + result r = E_OBJ_NOT_FOUND; + + _AnimationData* pAnimationData = GetAnimationDataInPending(target, keyName); + + if (pAnimationData != null) + { + r = SetAnimationDataAsPending(*pAnimationData, true, false); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Failed to add to pending list."); + + return E_SUCCESS; + } + + ArrayList* pAnimationList = null; + + __animations.GetValue(&target, pAnimationList); + + if (pAnimationList == null) + { + return E_OBJ_NOT_FOUND; + } + + int animationCount = pAnimationList->GetCount(); + + for (int index = 0; index < animationCount; index++) + { + pAnimationData = AD_CAST(pAnimationList->GetAt(index)); + + if (pAnimationData->IsRemoved() == false) + { + if (pAnimationData->GetName() == keyName) + { + r = SetAnimationDataAsPending(*pAnimationData, true, false); + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, r, "Failed to add to pending list."); + + break; + } + } + } + + ProcessPendingAnimations(); + + return r; +} + +result +_TransactionNode::RemoveChildrenAnimation(VisualElement& target, const String& keyName) +{ + SysTryReturnResult(NID_UI_ANIM, keyName.IsEmpty() == false, E_OBJ_NOT_FOUND, "keyName is empty."); + + if (RemoveAnimation(target, keyName) == E_SUCCESS) + { + return E_SUCCESS; + } + + int childrenCount = GetChildrenCount(); + + if (childrenCount <= 0) + { + return E_OBJ_NOT_FOUND; + } + + _TransactionNode* pChild = null; + _AnimationGroupNode* pGroup = null; + + for (int index = 0; index < childrenCount; index++) + { + pChild = TN_CAST(__children.GetAt(index)); + pGroup = dynamic_cast< _AnimationGroupNode* >(pChild); + + if (pGroup != null && pGroup->IsEqual(target, keyName)) + { + pChild->NotifyTransactionStatus(false); + + RemoveChild(*pChild); + return E_SUCCESS; + } + else if (pChild->RemoveChildrenAnimation(target, keyName) == E_SUCCESS) + { + return E_SUCCESS; + } + } + + return E_OBJ_NOT_FOUND; +} + +void +_TransactionNode::RemoveAnimationByProperty(VisualElement& target, const String& property) +{ + if (GetAnimationCount() <= 0) + { + return; + } + + result r = E_OBJ_NOT_FOUND; + + _AnimationData* pAnimationData = GetAnimationDataInPendingByProperty(target, property); + + if (pAnimationData != null) + { + r = SetAnimationDataAsPending(*pAnimationData, true, false); + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to add to pending list.", GetErrorMessage(r)); + + return; + } + + ArrayList* pAnimationList = null; + + __animations.GetValue(&target, pAnimationList); + + if (pAnimationList == null) + { + return; + } + + VisualElementPropertyAnimation* pPropertyAnimation = null; + + int animationCount = pAnimationList->GetCount(); + + for (int index = 0; index < animationCount; index++) + { + pAnimationData = AD_CAST(pAnimationList->GetAt(index)); + + if (pAnimationData->IsRemoved() == false) + { + pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(&(pAnimationData->GetAnimation())); + + if (pPropertyAnimation != null && pPropertyAnimation->GetPropertyName() == property) + { + r = SetAnimationDataAsPending(*pAnimationData, true, false); + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to add to pending list.", GetErrorMessage(r)); + + break; + } + } + } + + ProcessPendingAnimations(); +} + +void +_TransactionNode::RemoveChildrenAnimationByProperty(VisualElement& target, const String& property) +{ + RemoveAnimationByProperty(target, property); + + int childrenCount = GetChildrenCount(); + + if (childrenCount <= 0) + { + return; + } + + _TransactionNode* pChild = null; + + for (int index = 0; index < childrenCount; index++) + { + pChild = TN_CAST(__children.GetAt(index)); + + pChild->RemoveChildrenAnimationByProperty(target, property); + } +} + +void +_TransactionNode::RemoveAllAnimations(void) +{ + if (GetAnimationCount() <= 0) + { + return; + } + + // use key list because map item would be removed + IListT* pKeyList = __animations.GetKeysN(); + SysTryReturnVoidResult(NID_UI_ANIM, pKeyList != null, E_SYSTEM, "[E_SYSTEM] Failed to add to animation."); + + VisualElement* pTarget = null; + + for (int index = 0; index < pKeyList->GetCount(); index++) + { + pKeyList->GetAt(index, pTarget); + + if (pTarget != null) + { + RemoveAllAnimations(*pTarget); + } + } + + delete pKeyList; + + __animations.RemoveAll(); +} + +void +_TransactionNode::RemoveAllAnimations(VisualElement& target) +{ + if (GetAnimationCount() <= 0) + { + return; + } + + ArrayList* pAnimationList = null; + + __animations.GetValue(&target, pAnimationList); + + if (pAnimationList == null) + { + return; + } + + result r = E_SUCCESS; + _AnimationData* pAnimationData = null; + + int animationCount = pAnimationList->GetCount(); + + for (int index = 0; index < animationCount; index++) + { + pAnimationData = AD_CAST(pAnimationList->GetAt(index)); + + r = SetAnimationDataAsPending(*pAnimationData, true, false); + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to add to pending list.", GetErrorMessage(r)); + } + + ProcessPendingAnimations(); +} + +void +_TransactionNode::RemoveChildrenAllAnimations(VisualElement& target) +{ + RemoveAllAnimations(target); + + int childrenCount = GetChildrenCount(); + + if (childrenCount <= 0) + { + return; + } + + _TransactionNode* pChild = null; + + for (int index = childrenCount-1; index >= 0; index--) + { + pChild = TN_CAST(__children.GetAt(index)); + + pChild->RemoveChildrenAllAnimations(target); + + if (pChild->IsReservedRemove() == false && pChild->IsCommitted() == true && pChild->IsEmpty() == true) + { + pChild->NotifyTransactionStatus(false); + + RemoveChild(*pChild); + } + } +} + +const VisualElementAnimation* +_TransactionNode::GetAnimation(VisualElement& target, const String& keyName) const +{ + if (GetAnimationCount() <= 0) + { + return null; + } + + _AnimationData* pAnimationData = GetAnimationDataInPending(target, keyName); + + if (pAnimationData != null) + { + return &(pAnimationData->GetAnimation()); + } + + ArrayList* pAnimationList = null; + + __animations.GetValue(&target, pAnimationList); + + if (pAnimationList == null) + { + return null; + } + + int animationCount = pAnimationList->GetCount(); + + for (int index = 0; index < animationCount; index++) + { + pAnimationData = AD_CAST(pAnimationList->GetAt(index)); + + if (pAnimationData->IsRemoved() == false) + { + if (pAnimationData->GetName() == keyName) + { + return &(pAnimationData->GetAnimation()); + } + } + } + + return null; +} + +const VisualElementAnimation* +_TransactionNode::GetChildrenAnimation(VisualElement& target, const String& keyName) const +{ + SysTryReturn(NID_UI_ANIM, keyName.IsEmpty() == false, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] keyName is empty."); + + const VisualElementAnimation* pAnimation = GetAnimation(target, keyName); + + if (pAnimation != null) + { + return pAnimation; + } + + int childrenCount = GetChildrenCount(); + + if (childrenCount <= 0) + { + return null; + } + + _TransactionNode* pChild = null; + _AnimationGroupNode* pGroup = null; + + for (int index = 0; index < childrenCount; index++) + { + pChild = TN_CONST_CAST(__children.GetAt(index)); + pGroup = dynamic_cast< _AnimationGroupNode* >(pChild); + + if (pGroup != null && pGroup->IsEqual(target, keyName)) + { + pAnimation = &(pGroup->GetAnimation()); + } + else + { + pAnimation = pChild->GetChildrenAnimation(target, keyName); + } + + if (pAnimation != null) + { + return pAnimation; + } + } + + return null; +} + +const VisualElementAnimation* +_TransactionNode::GetAnimationByProperty(VisualElement& target, const String& property) const +{ + if (GetAnimationCount() <= 0) + { + return null; + } + + _AnimationData* pAnimationData = GetAnimationDataInPendingByProperty(target, property); + + if (pAnimationData != null) + { + return &(pAnimationData->GetAnimation()); + } + + ArrayList* pAnimationList = null; + + __animations.GetValue(&target, pAnimationList); + + if (pAnimationList == null) + { + return null; + } + + const VisualElementPropertyAnimation* pPropertyAnimation = null; + + int animationCount = pAnimationList->GetCount(); + + for (int index = 0; index < animationCount; index++) + { + pAnimationData = AD_CAST(pAnimationList->GetAt(index)); + + if (pAnimationData->IsRemoved() == false) + { + pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(&(pAnimationData->GetAnimation())); + + if (pPropertyAnimation != null && pPropertyAnimation->GetPropertyName() == property) + { + break; + } + } + } + + return pPropertyAnimation; +} + +const VisualElementAnimation* +_TransactionNode::GetChildrenAnimationByProperty(VisualElement& target, const String& property) const +{ + const VisualElementAnimation* pAnimation = GetAnimationByProperty(target, property); + + if (pAnimation != null) + { + return pAnimation; + } + + int childrenCount = GetChildrenCount(); + + if (childrenCount <= 0) + { + return null; + } + + _TransactionNode* pChild = null; + + for (int index = 0; index < childrenCount; index++) + { + pChild = TN_CONST_CAST(__children.GetAt(index)); + + pAnimation = pChild->GetChildrenAnimationByProperty(target, property); + + if (pAnimation != null) + { + break; + } + } + + return pAnimation; +} + +void +_TransactionNode::SetBaseTime(unsigned int baseTime) +{ + if (GetAnimationCount() <= 0) + { + return; + } + + IMapEnumeratorT* pMapEnum = __animations.GetMapEnumeratorN(); + + ArrayList* pAnimationList = null; + _AnimationData* pAnimationData = null; + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + pMapEnum->GetValue(pAnimationList); + + if (pAnimationList == null) + { + continue; + } + + int animationCount = pAnimationList->GetCount(); + + for (int index = 0; index < animationCount; index++) + { + pAnimationData = AD_CAST(pAnimationList->GetAt(index)); + + pAnimationData->SetBaseTime(baseTime); + } + } + + delete pMapEnum; +} + +void +_TransactionNode::SetChildrenBaseTime(unsigned int baseTime, bool self) +{ + if (self == true) + { + __baseTime = baseTime; + __adjustedBaseTime = __baseTime; + + if (__status == _STATUS_END) + { + __status = _STATUS_READY; + } + } + + SetBaseTime(baseTime); + + int childrenCount = GetChildrenCount(); + + if (childrenCount <= 0) + { + return; + } + + _TransactionNode* pChild = null; + + for (int index = 0; index < childrenCount; index++) + { + pChild = TN_CAST(__children.GetAt(index)); + + pChild->SetChildrenBaseTime(baseTime, true); + } +} + +void +_TransactionNode::Commit(void) +{ + __isCommitted = true; +} + +bool +_TransactionNode::IsCommitted(bool ancestors) const +{ + if (ancestors == true) + { + if (__isCommitted == false) + { + return __isCommitted; + } + + bool isCommitted = true; + + if (__pParent != null) + { + isCommitted = __pParent->IsCommitted(); + } + + return (isCommitted && __isCommitted); + } + + return __isCommitted; +} + +bool +_TransactionNode::IsEmpty(void) const +{ + return (GetAnimationCount() <= 0 && GetChildrenCount() <= 0); +} + +bool +_TransactionNode::IsRunning(void) const +{ + return (__status > _STATUS_READY && __status < _STATUS_STOP); +} + +void +_TransactionNode::ReservedRemove(bool remove) +{ + __isReservedRemove = remove; +} + +bool +_TransactionNode::IsReservedRemove(void) const +{ + return __isReservedRemove; +} + +bool +_TransactionNode::IsRemovable(void) const +{ + return true; +} + +bool +_TransactionNode::IsInAnimationTick(void) +{ + if (__isInAnimationTick == true) + { + return true; + } + + int childrenCount = GetChildrenCount(); + + if (childrenCount <= 0) + { + return false; + } + + _TransactionNode* pChild = null; + + for (int index = 0; index < childrenCount; index++) + { + pChild = TN_CAST(__children.GetAt(index)); + + if (pChild->IsInAnimationTick() == true) + { + return true; + } + } + + return false; +} + +void +_TransactionNode::CalculateProgress(unsigned int currentTime) +{ + if (__status == _STATUS_READY) + { + __status = _STATUS_START; + } + else + { + __status = _STATUS_RUNNING; + } +} + +void +_TransactionNode::NotifyTransactionStatus(bool completed) +{ + if (__isCommitted == false) + { + return; + } + + IAnimationTransactionEventListener* pListener = null; + + pListener = (__pListener != null) ? __pListener : __pDefaultListener; + + // root transaction doesn't has default listener + if (pListener == null) + { + return; + } + + if (completed == false) + { + pListener->OnAnimationTransactionStopped(__id); + return; + } + + switch (__status) + { + case _STATUS_START: + pListener->OnAnimationTransactionStarted(__id); + break; + + case _STATUS_STOP: + pListener->OnAnimationTransactionFinished(__id); + break; + + default: + break; + } +} + +bool +_TransactionNode::RemoveAnimationByDuplicatedProperty(_AnimationData& animationData) +{ + VisualElementPropertyAnimation* pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(&(animationData.GetAnimation())); + + if (pPropertyAnimation == null) + { + return true; + } + + VisualElement* pTarget = &(animationData.GetTarget()); + + ArrayList* pAnimationList = null; + + __animations.GetValue(pTarget, pAnimationList); + + if (pAnimationList != null) + { + _AnimationData* pRemoveAnimationData = null; + VisualElementPropertyAnimation* pRemovePropertyAnimation = null; + + int animationCount = pAnimationList->GetCount(); + + for (int index = 0; index < animationCount; index++) + { + pRemoveAnimationData = AD_CAST(pAnimationList->GetAt(index)); + + if (&animationData == pRemoveAnimationData) + { + return true; + } + + pRemovePropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(&(pRemoveAnimationData->GetAnimation())); + + if (pRemovePropertyAnimation && pRemovePropertyAnimation->GetPropertyName() == pPropertyAnimation->GetPropertyName()) + { + result r = SetAnimationDataAsPending(*pRemoveAnimationData, true, false); + SysTryReturn(NID_UI_ANIM, r == E_SUCCESS, r, false, "[%s] Failed to add to pending list.", GetErrorMessage(r)); + + //TODO: refactoring for group + if (IsRemovable() == false && pRemoveAnimationData->GetStatus() != _AnimationData::_STATUS_READY) + { + pRemoveAnimationData->SetStatus(_AnimationData::_STATUS_END); + pRemoveAnimationData->SetPendingMode(_AnimationData::_PENDING_MODE_NONE); + __pendingAnimations.Remove(*pRemoveAnimationData, false); + } + } + } + } + + int childrenCount = GetChildrenCount(); + + if (childrenCount <= 0) + { + return false; + } + + _TransactionNode* pChild = null; + + for (int index = 0; index < childrenCount; index++) + { + pChild = TN_CAST(__children.GetAt(index)); + + if (pChild->RemoveAnimationByDuplicatedProperty(animationData)) + { + return true; + } + } + + return false; +} + +void +_TransactionNode::ProcessPendingAnimations(void) +{ + if (__isInAnimationTick == true) + { + return; + } + + if (__pendingAnimations.GetCount() <= 0) + { + return; + } + + _AnimationData* pAnimationData = null; + int pendingAnimationCount = __pendingAnimations.GetCount(); + + for (int index = 0; index < pendingAnimationCount; index++) + { + pAnimationData = AD_CAST(__pendingAnimations.GetAt(index)); + + switch(pAnimationData->GetPendingMode()) + { + case _AnimationData::_PENDING_MODE_ADD: + + if (AddAnimationData(*pAnimationData) != E_SUCCESS) + { + delete pAnimationData; + } + + break; + + case _AnimationData::_PENDING_MODE_REMOVE: + + RemoveAnimationData(*pAnimationData); + break; + + default: + break; + } + } + + __pendingAnimations.RemoveAll(false); +} + +void +_TransactionNode::ProcessAnimationTick(unsigned int tick) +{ + if (__isCommitted == false) + { + return; + } + + if (__baseTime > tick) // this node is added in animation tick + { + return; + } + + CalculateProgress(tick); + + if (__status == _STATUS_READY) + { + return; + } + + if (__status != _STATUS_STOP) + { + NotifyTransactionStatus(true); + } + + if (IsReservedRemove() == true) + { + return; + } + + OnAnimationTick(tick); + + _TransactionNode* pChild = null; + + for (int index = 0; index < GetChildrenCount(); index++) + { + pChild = TN_CAST(__children.GetAt(index)); + + if (pChild->IsReservedRemove()) + { + RemoveChild(*pChild); + index--; + + continue; + } + + pChild->ProcessAnimationTick(tick); + + if (pChild->__status == _STATUS_STOP) + { + pChild->ReservedRemove(); + + pChild->NotifyTransactionStatus(true); + + if (pChild->IsRemovable()) // only nested group + { + RemoveChild(*pChild); + index--; + } + else + { + pChild->ReservedRemove(false); + } + } + } + + if (IsEmpty() == true) + { + __status = _STATUS_STOP; + } +} + +void +_TransactionNode::OnAnimationTick(unsigned int tick) +{ + if (GetAnimationCount() <= 0) + { + return; + } + + __isInAnimationTick = true; + + IMapEnumeratorT* pMapEnum = __animations.GetMapEnumeratorN(); + SysTryReturnVoidResult(NID_UI_ANIM, (pMapEnum != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + VisualElement* pTarget = null; + ArrayList* pAnimationList = null; + _AnimationData* pAnimationData = null; + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + pMapEnum->GetKey(pTarget); //TODO: remove + pMapEnum->GetValue(pAnimationList); + + if (pTarget == null || pAnimationList == null) + { + continue; + } + + int animationCount = pAnimationList->GetCount(); + + for (int index = 0; index < animationCount; index++) + { + pAnimationData = AD_CAST(pAnimationList->GetAt(index)); + + // Send finish notification + if (pAnimationData->GetStatus() == _AnimationData::_STATUS_STOP) + { + SetAnimationDataAsPending(*pAnimationData, true, true); + + //TODO: refactoring for group + if (IsRemovable() == false) + { + pAnimationData->SetPendingMode(_AnimationData::_PENDING_MODE_NONE); + __pendingAnimations.Remove(*pAnimationData, false); + } + } + + if (pAnimationData->IsRemoved()) + { + continue; + } + + Variant currentValue = pAnimationData->CalculateValueByTime(tick); + + // check same property animation + if (pAnimationData->GetStatus() == _AnimationData::_STATUS_START) + { + __pRoot->RemoveAnimationByDuplicatedProperty(*pAnimationData); + } + + // Send start, repeat notification + if (pAnimationData->GetStatus() != _AnimationData::_STATUS_STOP) + { + pAnimationData->NotifyAnimationStatus(true); + } + + pAnimationData->OnTickOccurred(*pTarget, currentValue); + } + } + + delete pMapEnum; + + __isInAnimationTick = false; + + ProcessPendingAnimations(); +} + +_AnimationGroupNode::_AnimationGroupNode(VisualElement& target, const Tizen::Base::String* pName, VisualElementAnimation& animation) + : _TransactionNode() + , __target(target) + , __animation(animation) + , __deleteAnimation(false) + , __totalDuration(0) + , __progress(0.0f) +{ + if (pName != null) + { + __name = *pName; + } + + _VisualElementAnimationImpl* pAnimationImpl = _VisualElementAnimationImpl::GetInstance(animation); + + result r = CopyAnimationValue(*pAnimationImpl); + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to copy the animation value.", GetErrorMessage(r)); + + // __pAnimation->GetRepeatCount() == 0 infinite + __totalDuration = __animation.GetDelay() + (__animation.GetDuration() * __animation.GetRepeatCount()) - __animation.GetOffset(); + + if (GetDuration() == 0) + { + SetDuration(1); + SetRepeatCount(1); + } + +#ifdef VE_DEBUG_MODULE + __tick = 0; +#endif +} + +_AnimationGroupNode::~_AnimationGroupNode(void) +{ + if (__deleteAnimation == true) + { + delete &__animation; + } +} + +VisualElementAnimation& +_AnimationGroupNode::GetAnimation(void) const +{ + return __animation; +} + +bool +_AnimationGroupNode::IsEqual(VisualElement& target, const Tizen::Base::String& keyName) const +{ + return (&__target == &target && __name == keyName); +} + +void +_AnimationGroupNode::Commit(void) +{ + __isCommitted = true; + + if (dynamic_cast< _AnimationGroupNode* > (__pParent) == null) + { + __deleteAnimation = true; + } +} + +bool +_AnimationGroupNode::IsRemovable(void) const +{ + return (__pParent->IsRemovable() && __currentRepeatCount == GetRepeatCount()); +} + +void +_AnimationGroupNode::CalculateProgress(unsigned int currentTime) +{ + long oldRepeatCount = 0; + long repeatCount = 0; + long delay = 0; + long duration = 0; + long offset = 0; + + // Set current Time +#ifdef VE_DEBUG_MODULE + if (_VeDebug::IsDebugEnabled()) + { + __tick += 16; + } +#endif + + if (__status == _STATUS_END) + { + return; + } + + if (__status == _STATUS_STOP) + { + __status = _STATUS_END; + + return; + } + + if (GetScaleRatio() > 0.f) + { + currentTime = (unsigned int) ((currentTime - __baseTime) / GetScaleRatio()); // Apply time scale value + } + + delay = GetDelay(); + + if (currentTime < (unsigned int)(delay)) + { + // Not started + __currentRepeatCount = 1; + __progress = -1.0f; + + return; + } + + offset = __animation.GetOffset(); + repeatCount = __animation.GetRepeatCount(); + duration = __animation.GetDuration(); + if (duration == 0) + { + duration = 1; + repeatCount = 1; + } + + oldRepeatCount = __currentRepeatCount; + __currentRepeatCount = ((currentTime - delay + offset) / duration) + 1; + + __progress = static_cast< float >(currentTime - (delay + duration * (__currentRepeatCount - 1) - offset)) / static_cast< float >(duration); + + if (__status == _STATUS_READY) + { + __status = _STATUS_START; + __adjustedBaseTime = delay - offset; // __currentRepeatCount is always 1 + + SetChildrenBaseTime(__baseTime + __adjustedBaseTime, false); + } + else if (repeatCount > 0 && currentTime >= __totalDuration) // infinite loop if repeatCount == 0 + { + __currentRepeatCount = repeatCount; + __progress = 1.0f; + + __status = _STATUS_STOP; + } + else if (__currentRepeatCount > oldRepeatCount) + { + __status = _STATUS_REPEAT; + __adjustedBaseTime = delay + duration * (__currentRepeatCount - 1) - offset; + + SetChildrenBaseTime(__baseTime + __adjustedBaseTime, false); + } + else + { + __status = _STATUS_RUNNING; + } +} + +void +_AnimationGroupNode::NotifyTransactionStatus(bool completed) +{ + if (__status == _STATUS_END) + { + return; + } + if (__isCommitted == false) + { + return; + } + + _VisualElementAnimationImpl* pAnimationImpl = _VisualElementAnimationImpl::GetInstance(__animation); + + IVisualElementAnimationStatusEventListener* pListener = pAnimationImpl->GetStatusEventListener(); + + if (pListener == null) + { + return; + } + + if (completed == false) + { + pListener->OnVisualElementAnimationFinished(__animation, __name, pAnimationImpl->GetEventTarget(), false); + return; + } + + switch (__status) + { + case _STATUS_START: + pListener->OnVisualElementAnimationStarted(__animation, __name, pAnimationImpl->GetEventTarget()); + break; + + case _STATUS_REPEAT: + pListener->OnVisualElementAnimationRepeated(__animation, __name, pAnimationImpl->GetEventTarget(), __currentRepeatCount); + break; + + case _STATUS_STOP: + pListener->OnVisualElementAnimationFinished(__animation, __name, pAnimationImpl->GetEventTarget(), true); + break; + + default: + break; + } +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_TransactionNode.h b/src/ui/animations/FUiAnim_TransactionNode.h new file mode 100644 index 0000000..b073664 --- /dev/null +++ b/src/ui/animations/FUiAnim_TransactionNode.h @@ -0,0 +1,292 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_TransactionNode.h + * @brief This is the header file for the _TransactionNode class. + * + * This header file contains the declarations of the _TransactionNode class. + */ + +#ifndef _FUI_ANIM_INTERNAL_TRANSACTION_NODE_H_ +#define _FUI_ANIM_INTERNAL_TRANSACTION_NODE_H_ + +#include +#include +#include + +#include "FUiAnim_VisualElementAnimationImpl.h" +#include "FUiAnim_Debug.h" + +#include "FUiAnim_VariantEx.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class IAnimationTransactionEventListener; + +class _AnimationTime +{ +public: + static unsigned int GetTime(bool loopTime = false); +}; // _AnimationTime + +class _AnimationData + : public Tizen::Base::Object +{ +public: + enum _AnimationStatus + { + _STATUS_READY, + _STATUS_START, + _STATUS_RUNNING, + _STATUS_REPEAT, + _STATUS_STOP, + _STATUS_END + }; + + enum _PendingMode + { + _PENDING_MODE_NONE, + _PENDING_MODE_ADD, + _PENDING_MODE_REMOVING, + _PENDING_MODE_REMOVE + }; + + _AnimationData(VisualElement& target, const Tizen::Base::String* pName, VisualElementAnimation& animation); + virtual ~_AnimationData(void); + +public: + VisualElementAnimation& GetAnimation(void) const; + Tizen::Base::String GetName(void) const; + VisualElement& GetTarget(void) const; + + result SetBaseTime(unsigned int baseTime); + + void SetStatus(_AnimationStatus status) { __status = status; } + _AnimationStatus GetStatus(void) const { return __status; } + + void SetPendingMode(_PendingMode mode) { __pendingMode = mode; } + _PendingMode GetPendingMode(void) const { return __pendingMode; } + + bool IsRemoved(void) const; + + void FillValueForProperty(void); + + Variant CalculateValueByTime(unsigned int currentTime); + + void NotifyAnimationStatus(bool completed); + void NotifyAnimationFinished(bool completed); + + void OnTickOccurred(VisualElement& target, const Tizen::Ui::Variant& currentValue); + +private: + _AnimationData(void); + _AnimationData(const _AnimationData&); + _AnimationData& operator =(const _AnimationData&); + + Variant CalculateValue(void); + +private: + VisualElement& __target; + Tizen::Base::String __name; + VisualElementAnimation& __animation; + + _VariantEx __startValue; + _VariantEx __endValue; + + unsigned int __totalDuration; + unsigned int __baseTime; + long __currentRepeatCount; + int __keyFrameIndex; + + bool __forward; + float __progress; + + _AnimationStatus __status; + + _PendingMode __pendingMode; + +#ifdef VE_DEBUG_MODULE + unsigned int __tick; +#endif +}; // _AnimationData + +class _TransactionNode + : public _VisualElementAnimationImpl +{ +public: + enum _TransactionStatus + { + _STATUS_READY, + _STATUS_START, + _STATUS_RUNNING, + _STATUS_REPEAT, + _STATUS_STOP, + _STATUS_END + }; + + _TransactionNode(void); + _TransactionNode(const _TransactionNode& node); + virtual ~_TransactionNode(void); + + virtual bool Equals(const Object& obj) const; + + int GetId(void) const; + + _TransactionNode* GetParent(void) const; + result SetParent(_TransactionNode& parent); + + result SetDefaultEventListener(const IAnimationTransactionEventListener* pListener); + + IAnimationTransactionEventListener* GetEventListener(void) const; + result SetEventListener(const IAnimationTransactionEventListener* pListener); + + bool IsImplicitAnimationEnabled(void) const; + result SetImplicitAnimationEnabled(bool enable); + + int GetChildrenCount(void) const; + _TransactionNode* GetChild(int transactionId) const; + _TransactionNode* GetLastChild(void) const; + + result AddChild(_TransactionNode& child); + void RemoveChild(int transactionId); + void RemoveChild(_TransactionNode& child); + + int GetAnimationCount(void) const; + result AddAnimation(VisualElement& target, const Tizen::Base::String* pKeyName, VisualElementAnimation& animation); + result RemoveChildrenAnimation(VisualElement& target, const Tizen::Base::String& keyName); + void RemoveChildrenAnimationByProperty(VisualElement& target, const Tizen::Base::String& property); + void RemoveChildrenAllAnimations(VisualElement& target); + + const VisualElementAnimation* GetChildrenAnimation(VisualElement& target, const Tizen::Base::String& keyName) const; + const VisualElementAnimation* GetChildrenAnimationByProperty(VisualElement& target, const Tizen::Base::String& property) const; + + void SetChildrenBaseTime(unsigned int baseTime, bool self = true); + + virtual void Commit(void); + bool IsCommitted(bool ancestors = false) const; + + bool IsEmpty(void) const; + + bool IsRunning(void) const; + virtual bool IsRemovable(void) const; + + virtual void NotifyTransactionStatus(bool completed); + + void ProcessAnimationTick(unsigned int tick); + +private: + _TransactionNode& operator =(const _TransactionNode& rhs); + + void RemoveAll(void); + + result AddAnimationData(_AnimationData& animationData); + void RemoveAnimationData(_AnimationData& animationData); + result SetAnimationDataAsPending(_AnimationData& animationData, bool remove, bool completed = false); + + _AnimationData* GetAnimationDataInPending(VisualElement& target, const Tizen::Base::String& keyName) const; + _AnimationData* GetAnimationDataInPendingByProperty(VisualElement& target, const Tizen::Base::String& property) const; + + result RemoveAnimation(VisualElement& target, const Tizen::Base::String& keyName); + void RemoveAnimationByProperty(VisualElement& target, const Tizen::Base::String& property); + void RemoveAllAnimations(void); + void RemoveAllAnimations(VisualElement& target); + + const VisualElementAnimation* GetAnimation(VisualElement& target, const Tizen::Base::String& property) const; + const VisualElementAnimation* GetAnimationByProperty(VisualElement& target, const Tizen::Base::String& property) const; + + void SetBaseTime(unsigned int baseTime); + + void ReservedRemove(bool remove = true); + bool IsReservedRemove(void) const; + + virtual void CalculateProgress(unsigned int currentTime); + + bool RemoveAnimationByDuplicatedProperty(_AnimationData& animationData); + + bool IsInAnimationTick(void); + void ProcessPendingAnimations(void); + void OnAnimationTick(unsigned int tick); + +protected: + int __id; + + _TransactionNode* __pParent; + _TransactionNode* __pRoot; + + IAnimationTransactionEventListener* __pDefaultListener; + IAnimationTransactionEventListener* __pListener; + + bool __isImplicitAnimationEnabled; + + bool __isCommitted; + bool __isReservedRemove; + bool __isInAnimationTick; + + _TransactionStatus __status; + + unsigned int __baseTime; + unsigned int __adjustedBaseTime; + long __currentRepeatCount; + + Tizen::Base::Collection::ArrayList __children; + Tizen::Base::Collection::ArrayList __pendingAnimations; + Tizen::Base::Collection::HashMapT __animations; +}; // _TransactionNode + +class _AnimationGroupNode + : public _TransactionNode +{ +public: + _AnimationGroupNode(VisualElement& target, const Tizen::Base::String* pName, VisualElementAnimation& animation); + virtual ~_AnimationGroupNode(void); + + VisualElementAnimation& GetAnimation(void) const; + bool IsEqual(VisualElement& target, const Tizen::Base::String& keyName) const; + + virtual void Commit(void); + + virtual bool IsRemovable(void) const; + + virtual void NotifyTransactionStatus(bool completed); + +private: + _AnimationGroupNode(void); + _AnimationGroupNode(const _AnimationGroupNode& rhs); + _AnimationGroupNode& operator =(const _AnimationGroupNode& rhs); + + virtual void CalculateProgress(unsigned int currentTime); + + VisualElement& __target; + Tizen::Base::String __name; + VisualElementAnimation& __animation; + bool __deleteAnimation; + + unsigned int __totalDuration; + float __progress; + +#ifdef VE_DEBUG_MODULE + unsigned int __tick; +#endif +}; // _AnimationGroupNode + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_TRANSACTION_NODE_H_ + diff --git a/src/ui/animations/FUiAnim_TransformMatrix3Df.cpp b/src/ui/animations/FUiAnim_TransformMatrix3Df.cpp new file mode 100644 index 0000000..a79ed3d --- /dev/null +++ b/src/ui/animations/FUiAnim_TransformMatrix3Df.cpp @@ -0,0 +1,1152 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_TransformMatrix3Df.cpp + * @brief This file contains implementation of _TransformMatrix3Df class + * + * This file contains implementation _TransformMatrix3Df class. + */ + +#include +#include + +#include "FUiAnim_MatrixUtil.h" +#include "FUiAnim_TransformMatrix3Df.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +#define DEGTORAD(d) ((d) * M_PI / 180.0f) +#define RADTODEG(r) ((r) * 180.0f / M_PI) + +#if 0 +void +DumpQuaternion(const _TransformMatrix3Df& tm) +{ + float x, y, z, w; + float halfth; + + tm.GetQuaternion(x, y, z, w); + halfth = acosf(w); + if (halfth > 1e-5f) + { + float sinh = sin(halfth); + float rx = x / sinh; + float ry = y / sinh; + float rz = z / sinh; + printf("QuatR: x= %f, y= %f, z= %f, w= %f\n", x, y, z, w); + printf("Quat: rx= %f, ry= %f, rz= %f, theta= %f\n", rx, ry, rz, 2.0f * halfth * 180.0f / M_PI); + } + + tm.GetEulerAngles(x, y, z); + printf("Euler Rotation: %f, %f, %f\n", x, y, z); +} + +void +DumpMatrix(const FloatMatrix4& m) +{ + printf("Matrix: %f %f %f %f\n", m.matrix[0][0], m.matrix[1][0], m.matrix[2][0], m.matrix[3][0]); + printf(" %f %f %f %f\n", m.matrix[0][1], m.matrix[1][1], m.matrix[2][1], m.matrix[3][1]); + printf(" %f %f %f %f\n", m.matrix[0][2], m.matrix[1][2], m.matrix[2][2], m.matrix[3][2]); + printf(" %f %f %f %f\n", m.matrix[0][3], m.matrix[1][3], m.matrix[2][2], m.matrix[3][3]); +} +#endif + +namespace { + +FloatMatrix4 +GetTranslationMatrix(float tx, float ty, float tz) +{ + FloatMatrix4 tm; + tm.matrix[0][3] = tx; + tm.matrix[1][3] = ty; + tm.matrix[2][3] = tz; + return tm; +} + +} + +namespace Tizen { namespace Ui { namespace Animations { + +_TransformMatrix3Df::_TransformMatrix3Df(void) + : __transformType(MATRIX4_Identity) + , __usePerspective(false) + , __useScale(false) + , __useShear(false) + , __useRotation(false) + , __useTranslation(false) + , __scaleX(1.0f) + , __scaleY(1.0f) + , __scaleZ(1.0f) + , __shearXY(0.0f) + , __shearXZ(0.0f) + , __shearYZ(0.0f) + , __quatX(0.0f) + , __quatY(0.0f) + , __quatZ(0.0f) + , __quatW(1.0f) + , __translationX(0.0f) + , __translationY(0.0f) + , __translationZ(0.0f) + , __perspectiveX(0.0f) + , __perspectiveY(0.0f) + , __perspectiveZ(0.0f) + , __perspectiveW(1.0f) + , __rotAnchorX(0.0f) + , __rotAnchorY(0.0f) + , __rotAnchorZ(0.0f) + , __scaleAnchorX(0.0f) + , __scaleAnchorY(0.0f) + , __scaleAnchorZ(0.0f) + , __rotX(0.0f) + , __rotY(0.0f) + , __rotZ(0.0f) +{ +} + +_TransformMatrix3Df::~_TransformMatrix3Df(void) +{ +} + +void +_TransformMatrix3Df::Clear(void) +{ + __rotX = __rotY = __rotZ = 0.0f; + __scaleX = __scaleY = __scaleZ = 1.0f; + __shearXY = __shearXZ = __shearYZ = 0.0f; + __quatX = __quatY = __quatZ = 0.0f; __quatW = 1.0f; + __translationX = __translationY = __translationZ = 0.0f; + __perspectiveX = __perspectiveY = __perspectiveZ = 0.0f; __perspectiveW = 1.0f; + + __usePerspective = false; + __useScale = false; + __useRotation = false; + __useTranslation = false; + __transformType = MATRIX4_Identity; +} + +bool +_TransformMatrix3Df::SetTransformMatrix(const FloatMatrix4& transformMatrix) +{ + // Check if fast-path is available +// if (transformMatrix.IsIdentity()) +#if 0 + if (transformMatrix == FloatMatrix4::IDENTITY_MATRIX) + { + Clear(); + return true; + } +#endif + + // Normalize the matrix. +// float mw = transformMatrix.Get(3, 3); + float mw = transformMatrix.matrix[3][3]; +// if (_FloatHardCompare(mw, 0.0f)) + if (unlikely(mw == 0.0f)) + { + return false; + } + + FloatMatrix4 locmat; + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 4; j++) + //locmat.Set(i, j, transformMatrix.Get(j, i) / mw); + locmat.matrix[j][i] = transformMatrix.matrix[i][j] / mw; + } + + // pmat is used to solve for perspective, but it also provides + // an easy way to test for singularity of the upper 3x3 component. + // + FloatMatrix4 pmat(locmat); + for (int i = 0; i < 3; i++) +// pmat.Set(i, 3, 0.0f); + pmat.matrix[3][i] = 0.0f; + +// pmat.Set(3, 3, 1.0f); + pmat.matrix[3][3] = 1.0f; + + FloatMatrix4 pmatInverseTranspose(pmat); +// if (!pmatInverseTranspose.Invert()) +// return false; +#if 0 + if (!pmatInverseTranspose.IsInvertible()) + { + return false; + } +#endif + if (pmatInverseTranspose.Invert() != E_SUCCESS) + { + return false; + } + + + // First, isolate perspective. This is the messiest. +// if (!_FloatHardCompare(locmat.Get(0, 3), 0.0f) || !_FloatHardCompare(locmat.Get(1, 3), 0.0f) || !_FloatHardCompare(locmat.Get(2, 3), 0.0f)) + if (unlikely(locmat.matrix[3][0] != 0.0f) || unlikely(locmat.matrix[3][1] != 0.0f) || unlikely(locmat.matrix[3][2] != 0.0f)) + { + // prhs is the right hand side of the equation. + Vector4Df prhs, psol; + +// prhs.x = locmat.Get(0, 3); +// prhs.y = locmat.Get(1, 3); +// prhs.z = locmat.Get(2, 3); +// prhs.w = locmat.Get(3, 3); + prhs.x = locmat.matrix[3][0]; + prhs.y = locmat.matrix[3][1]; + prhs.z = locmat.matrix[3][2]; + prhs.w = locmat.matrix[3][3]; + + + pmatInverseTranspose.Transpose(); + + // Solve the equation by inverting pmat and multiplying + // prhs by the inverse. (This is the easiest way, not necessarily the best.) + // inverse function (and det4x4, above) from the Matrix Inversion gem in the first volume. + // + //V4MulPointByMatrix(prhs, pmatInverseTranspose, psol); + psol = prhs.Transform(pmatInverseTranspose); + + + // Stuff the answer away. + __perspectiveX = psol.x; + __perspectiveY = psol.y; + __perspectiveZ = psol.z; + __perspectiveW = psol.w; + + // Clear the perspective partition. +// locmat.Set(0, 3, 0.0f); +// locmat.Set(1, 3, 0.0f); +// locmat.Set(2, 3, 0.0f); +// locmat.Set(3, 3, 1.0f); + locmat.matrix[3][0] = (0.0f); + locmat.matrix[3][1] = (0.0f); + locmat.matrix[3][2] = (0.0f); + locmat.matrix[3][3] = (1.0f); + } + else + { + // No perspective. + __perspectiveX = 0.0f; + __perspectiveY = 0.0f; + __perspectiveZ = 0.0f; + __perspectiveW = 1.0f; // CHECKME: W of perspective is 1, right ? (or 0 ?) + } + + // Next take care of translation (easy). +// __translationX = locmat.Get(3, 0); +// __translationY = locmat.Get(3, 1); +// __translationZ = locmat.Get(3, 2); + __translationX = locmat.matrix[0][3]; + __translationY = locmat.matrix[1][3]; + __translationZ = locmat.matrix[2][3]; + + for (int i = 0; i < 3; i++) + { +// locmat.Set(3, i, 0.0f); + locmat.matrix[i][3] = 0.0f; + } + + + // Now get scale and shear. + Vector3Df row[3]; + for (int i = 0; i < 3; i++) + { +// row[i].x = locmat.Get(i, 0); +// row[i].y = locmat.Get(i, 1); +// row[i].z = locmat.Get(i, 2); + row[i].x = locmat.matrix[0][i]; + row[i].y = locmat.matrix[1][i]; + row[i].z = locmat.matrix[2][i]; + } + + // Compute X scale factor and normalize first row. + __scaleX = row[0].GetLength(); + row[0].Scale(1.0f); + + // Compute XY shear factor and make 2nd row orthogonal to 1st. + __shearXY = row[0].Dot(row[1]); + Vector3Df::Combine(row[1], row[1], row[0], 1.0f, -__shearXY); + + // Now, compute Y scale and normalize 2nd row. + __scaleY = row[1].GetLength(); + row[1].Scale(1.0f); + __shearXY /= __scaleY; + + // Compute XZ and YZ shears, orthogonalize 3rd row. + __shearXZ = row[0].Dot(row[2]); + Vector3Df::Combine(row[2], row[2], row[0], 1.0f, -__shearXZ); + __shearYZ = row[1].Dot(row[2]); + Vector3Df::Combine(row[2], row[2], row[1], 1.0f, -__shearYZ); + + // Next, get Z scale and normalize 3rd row. + __scaleZ = row[2].GetLength(); + row[2].Scale(1.0f); + __shearXZ /= __scaleZ; + __shearYZ /= __scaleZ; + + // At this point, the matrix (in rows[]) is orthonormal. + // Check for a coordinate system flip. If the determinant + // is -1, then negate the matrix and the scaling factors. + // + Vector3Df pdum3 = row[1].Cross(row[2]); + if (row[0].Dot(pdum3) < 0.0f) + { + for (int i = 0; i < 3; i++) + { + row[i].x *= -1.0f; + row[i].y *= -1.0f; + row[i].z *= -1.0f; + } + + __scaleX *= -1.0f; + __scaleY *= -1.0f; + __scaleZ *= -1.0f; + } + + // Now, get the rotations out + // For correctness, we use quaternions + float s, t, x, y, z, w; + + t = row[0].x + row[1].y + row[2].z + 1.0f; + + if (t > 1e-4f) + { + s = 0.5f / sqrtf(t); + w = 0.25f / s; + x = (row[2].y - row[1].z) * s; + y = (row[0].z - row[2].x) * s; + z = (row[1].x - row[0].y) * s; + } + else if (row[0].x > row[1].y && row[0].x > row[2].z) + { + s = sqrtf(1.0f + row[0].x - row[1].y - row[2].z) * 2.0f; // S = 4 * qx + x = 0.25f * s; + y = (row[0].y + row[1].x) / s; + z = (row[0].z + row[2].x) / s; + w = (row[2].y - row[1].z) / s; + } + else if (row[1].y > row[2].z) + { + s = sqrtf(1.0f + row[1].y - row[0].x - row[2].z) * 2.0f; // S = 4 * qy + x = (row[0].y + row[1].x) / s; + y = 0.25f * s; + z = (row[1].z + row[2].y) / s; + w = (row[0].z - row[2].x) / s; + } + else + { + s = sqrtf(1.0f + row[2].z - row[0].x - row[1].y) * 2.0f; // S = 4 * qz + x = (row[0].z + row[2].x) / s; + y = (row[1].z + row[2].y) / s; + z = 0.25f * s; + w = (row[1].x - row[0].y) / s; + } + + __quatX = -x; + __quatY = -y; + __quatZ = -z; + __quatW = w; + + + __rotY = asinf(-row[0].z); + if (cosf(__rotY) != 0.0f) + { + __rotX = RADTODEG(atan2f(row[1].z, row[2].z)); + __rotZ = RADTODEG(atan2f(row[0].y, row[0].x)); + } + else + { + __rotX = RADTODEG(atan2f(-row[2].x, row[1].y)); + __rotZ = 0.0f; + } + + __rotY = RADTODEG(__rotY); + + + + // Clear anchor information + __rotAnchorX = 0.0f; + __rotAnchorY = 0.0f; + __rotAnchorZ = 0.0f; + __scaleAnchorX = 0.0f; + __scaleAnchorY = 0.0f; + __scaleAnchorZ = 0.0f; + +#if 0 + //printf("--------- Rotate: %f, %f, %f, %f\n", __quatX, __quatY, __quatZ, __quatW); + DumpQuaternion(*this); + DumpMatrix(transformMatrix); +// printf("--------- Scale: %f, %f, %f\n", __scaleX, __scaleY, __scaleZ); +// printf("--------- Translate: %f, %f, %f\n", __translationX, __translationY, __translationZ); + printf("\n\n"); +#endif + + UpdateMatrixType(true); + + return true; +} + +FloatMatrix4 +_TransformMatrix3Df::Interpolate(const _TransformMatrix3Df& transformMatrixFrom, float progress) const +{ +#define FLOAT_INTP(v, c, f, t, p) do { if (likely((f.v) != (t.v))) c.v = (f.v) + ((t.v) - (f.v)) * (p); else c.v = f.v; } while (0) + + const _TransformMatrix3Df& fromTransform = transformMatrixFrom; + const _TransformMatrix3Df& toTransform = *this; + _TransformMatrix3Df currentTransform; + + FLOAT_INTP(__scaleX, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__scaleY, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__scaleZ, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__shearXY, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__shearXZ, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__shearYZ, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__translationX, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__translationY, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__translationZ, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__perspectiveX, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__perspectiveY, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__perspectiveZ, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__perspectiveW, currentTransform, fromTransform, toTransform, progress); + + // Interpolate anchor points + FLOAT_INTP(__rotAnchorX, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__rotAnchorY, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__rotAnchorZ, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__scaleAnchorX, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__scaleAnchorY, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__scaleAnchorZ, currentTransform, fromTransform, toTransform, progress); + + // rotation component + // WARNING: + // It is not needed to update __rotX/Y/Z because the calculating interpolated matrix would not use those values +#if 0 + FLOAT_INTP(__rotX, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__rotY, currentTransform, fromTransform, toTransform, progress); + FLOAT_INTP(__rotZ, currentTransform, fromTransform, toTransform, progress); + currentTransform.UpdateRotationFromEulerAngles(currentTransform.__rotX, currentTransform.__rotY, currentTransform.__rotZ); +#else + DoSlerp(¤tTransform.__quatX, &fromTransform.__quatX, &toTransform.__quatX, progress); +#endif + + // WARNING: + // 'GetTransformMatrix' will use matrix type + currentTransform.UpdateMatrixType(true); + + +#if 0 + printf("----------p: %f\n", progress); + printf("--------- qf: %f, %f, %f, %f\n", fromTransform.__quatX, fromTransform.__quatY, fromTransform.__quatZ, fromTransform.__quatW); + printf("--------- qt: %f, %f, %f, %f\n", toTransform.__quatX, toTransform.__quatY, toTransform.__quatZ, toTransform.__quatW); + printf("--------- q: %f, %f, %f, %f\n", currentTransform.__quatX, currentTransform.__quatY, currentTransform.__quatZ, currentTransform.__quatW); + + float rx, ry, rz; + float halfth = acosf(currentTransform.__quatW); + if (halfth > 1e-5) + { + rx = currentTransform.__quatX / sinf(halfth); + ry = currentTransform.__quatY / sinf(halfth); + rz = currentTransform.__quatZ / sinf(halfth); + printf(" ==> q: %f, %f, %f, %f\n", rx, ry, rz, 2.0f * halfth * 180 / M_PI); + printf(" ==> q: %f, %f, %f, %f\n", -rx, -ry, -rz, 2.0f * halfth * 180 / M_PI); + } +#endif + +#if 1 + return currentTransform.GetTransformMatrix(); +#else + printf("--------- q: %f, %f, %f, %f\n", currentTransform.__quatX, currentTransform.__quatY, currentTransform.__quatZ, currentTransform.__quatW); + FloatMatrix4 cm = currentTransform.GetTransformMatrix(); + DumpMatrix(cm); + return cm; +#endif + +#undef FLOAT_INTP +} + +void +_TransformMatrix3Df::UpdateMatrixType(bool needFullCheck) +{ + if (unlikely(needFullCheck)) + { + __useRotation = (unlikely(!_FloatCompare(__quatX, 0.0f)) || unlikely(!_FloatCompare(__quatY, 0.0f)) || unlikely(!_FloatCompare(__quatZ, 0.0f)) || unlikely(!_FloatCompare(__quatW, 1.0f))); + __useShear = (unlikely(!_FloatCompare(__shearXY, 0.0f)) || unlikely(!_FloatCompare(__shearXZ, 0.0f)) || unlikely(!_FloatCompare(__shearYZ, 0.0f))); + __useScale = (unlikely(!_FloatCompare(__scaleX, 1.0f)) || unlikely(!_FloatCompare(__scaleY, 1.0f)) || unlikely(!_FloatCompare(__scaleZ, 1.0f))); + __useTranslation = (unlikely(!_FloatCompare(__translationX, 0.0f)) || unlikely(!_FloatCompare(__translationY, 0.0f)) || unlikely(!_FloatCompare(__translationZ, 0.0f))); + __usePerspective = (unlikely(!_FloatCompare(__perspectiveX, 0.0f)) || unlikely(!_FloatCompare(__perspectiveY, 0.0f)) || unlikely(!_FloatCompare(__perspectiveZ, 0.0f)) || unlikely(!_FloatCompare(__perspectiveW, 1.0f))); + } + + + if (unlikely(__usePerspective) || unlikely(__useRotation) || unlikely(__useShear)) + { + __transformType = MATRIX4_Generic; + } + else if (unlikely(__useScale)) + { + __transformType = MATRIX4_Scale; + } + else if (likely(__useTranslation)) + { + __transformType = MATRIX4_Translation; + } + else + { + __transformType = MATRIX4_Identity; + } +} + +FloatMatrix4 +_TransformMatrix3Df::GetTransformMatrix(void) const +{ + FloatMatrix4 m; + + if (likely(__transformType == MATRIX4_Translation)) + { + m.matrix[3][0] = __translationX; + m.matrix[3][1] = __translationY; + m.matrix[3][2] = __translationZ; + m.matrix[3][3] = 1.0f; + return m; + } + else if (unlikely(__transformType == MATRIX4_Identity)) + { + _MatrixUtilSetIdentity(m); + return m; + } + + + + // apply perspective; +// m.Set(0, 3, __perspectiveX); +// m.Set(1, 3, __perspectiveY); +// m.Set(2, 3, __perspectiveZ); +// m.Set(3, 3, __perspectiveW); + m.matrix[3][0] = __perspectiveX; + m.matrix[3][1] = __perspectiveY; + m.matrix[3][2] = __perspectiveZ; + m.matrix[3][3] = __perspectiveW; + + + // apply translation +// m.Set(3, 0, __translationX); +// m.Set(3, 1, __translationY); +// m.Set(3, 2, __translationZ); +// m.Set(3, 3, __perspectiveW + (__perspectiveX * __translationX) + (__perspectiveY * __translationY) + (__perspectiveZ * __translationZ)); + m.matrix[0][3] = __translationX; + m.matrix[1][3] = __translationY; + m.matrix[2][3] = __translationZ; + m.matrix[3][3] = __perspectiveW + (__perspectiveX * __translationX) + (__perspectiveY * __translationY) + (__perspectiveZ * __translationZ); + + + // apply rotation + if (unlikely(__quatX != 0.0f) || unlikely(__quatY != 0.0f) || unlikely(__quatZ != 0.0f)) + { + float xx = __quatX * __quatX; + float xy = __quatX * __quatY; + float xz = __quatX * __quatZ; + float xw = __quatX * __quatW; + float yy = __quatY * __quatY; + float yz = __quatY * __quatZ; + float yw = __quatY * __quatW; + float zz = __quatZ * __quatZ; + float zw = __quatZ * __quatW; + + // Construct a composite rotation matrix from the quaternion values +#if 0 + const float rotM[4][4] = { // WARNING: C++ array is row-major order ! + { 1 - 2 * (yy + zz), 2 * (xy + zw), 2 * (xz - yw), 0 }, + { 2 * (xy - zw), 1 - 2 * (xx + zz), 2 * (yz + xw), 0 }, + { 2 * (xz + yw), 2 * (yz - xw), 1 - 2 * (xx + yy), 0 }, + { 0, 0, 0, 1 } + }; +#else + const float rotM[4][4] = { // WARNING: C++ array is row-major order ! + { 1 - 2 * (yy + zz), 2 * (xy - zw), 2 * (xz + yw), 0 }, + { 2 * (xy + zw), 1 - 2 * (xx + zz), 2 * (yz - xw), 0 }, + { 2 * (xz - yw), 2 * (yz + xw), 1 - 2 * (xx + yy), 0 }, + { 0, 0, 0, 1 } + }; +#endif +#if 0 + m = FloatMatrix4(rotM) * m; +#else +#if 0 + if (__rotAnchorX != 0.0f || __rotAnchorY != 0.0f || __rotAnchorZ != 0.0f) + m = GetTranslationMatrix(-__rotAnchorX, -__rotAnchorY, -__rotAnchorZ) * FloatMatrix4(rotM) * GetTranslationMatrix(__rotAnchorX, __rotAnchorY, __rotAnchorZ) * m; + else + m = FloatMatrix4(rotM) * m; +#else + if (__rotAnchorX != 0.0f || __rotAnchorY != 0.0f || __rotAnchorZ != 0.0f) + { + const FloatMatrix4& back = GetTranslationMatrix(-__rotAnchorX, -__rotAnchorY, -__rotAnchorZ); + const FloatMatrix4& move = GetTranslationMatrix(__rotAnchorX, __rotAnchorY, __rotAnchorZ); + FloatMatrix4 intm; + _MatrixUtilMultiply(intm, back, FloatMatrix4(rotM)); + _MatrixUtilMultiply(intm, intm, move); + _MatrixUtilMultiply(m, intm, m); + } + else + { + _MatrixUtilMultiply(m, FloatMatrix4(rotM), m); + } +#endif +#endif + } + + + // apply shear + + if (__shearYZ) + { + FloatMatrix4 sh; + //sh.Set(2, 1, __shearYZ); + sh.matrix[1][2] = __shearYZ; +// m = sh * m; + _MatrixUtilMultiply(m, sh, m); + } + + if (__shearXZ) + { + FloatMatrix4 sh; + //sh.Set(2, 0, __shearXZ); + sh.matrix[0][2] = __shearXZ; +// m = sh * m; + _MatrixUtilMultiply(m, sh, m); + } + + if (__shearXY) + { + FloatMatrix4 sh; + //sh.Set(1, 0, __shearXY); + sh.matrix[0][1] = __shearXY; +// m = sh * m; + _MatrixUtilMultiply(m, sh, m); + } + + // apply scale +#if 0 + if (__scaleX != 1.0f) + { +// m.Set(0, 0, m.Get(0, 0) * __scaleX); +// m.Set(0, 1, m.Get(0, 1) * __scaleX); +// m.Set(0, 2, m.Get(0, 2) * __scaleX); +// m.Set(0, 3, m.Get(0, 3) * __scaleX); + m.matrix[0][0] = m.matrix[0][0] * __scaleX; + m.matrix[1][0] = m.matrix[1][0] * __scaleX; + m.matrix[2][0] = m.matrix[2][0] * __scaleX; + m.matrix[3][0] = m.matrix[3][0] * __scaleX; + } + + if (__scaleY != 1.0f) + { +// m.Set(1, 0, m.Get(1, 0) * __scaleY); +// m.Set(1, 1, m.Get(1, 1) * __scaleY); +// m.Set(1, 2, m.Get(1, 2) * __scaleY); +// m.Set(1, 3, m.Get(1, 3) * __scaleY); + m.matrix[0][1] = m.matrix[0][1] * __scaleX; + m.matrix[1][1] = m.matrix[1][1] * __scaleX; + m.matrix[2][1] = m.matrix[2][1] * __scaleX; + m.matrix[3][1] = m.matrix[3][1] * __scaleX; + } + + if (__scaleZ != 1.0f) + { +// m.Set(2, 0, m.Get(2, 0) * __scaleZ); +// m.Set(2, 1, m.Get(2, 1) * __scaleZ); +// m.Set(2, 2, m.Get(2, 2) * __scaleZ); +// m.Set(2, 3, m.Get(2, 3) * __scaleZ); + m.matrix[0][2] = m.matrix[0][2] * __scaleX; + m.matrix[1][2] = m.matrix[1][2] * __scaleX; + m.matrix[2][2] = m.matrix[2][2] * __scaleX; + m.matrix[3][2] = m.matrix[3][2] * __scaleX; + } +#else + if (__scaleAnchorX != 0.0f || __scaleAnchorY != 0.0f || __scaleAnchorZ != 0.0f) + { + FloatMatrix4 sc; + _MatrixUtilScale(sc, __scaleX, __scaleY, __scaleZ); +// m = GetTranslationMatrix(-__scaleAnchorX, -__scaleAnchorY, -__scaleAnchorZ) * sc * GetTranslationMatrix(__scaleAnchorX, __scaleAnchorY, __scaleAnchorZ) * m; + + const FloatMatrix4& back = GetTranslationMatrix(-__scaleAnchorX, -__scaleAnchorY, -__scaleAnchorZ); + const FloatMatrix4& move = GetTranslationMatrix(__scaleAnchorX, __scaleAnchorY, __scaleAnchorZ); + FloatMatrix4 intm; + _MatrixUtilMultiply(intm, back, sc); + _MatrixUtilMultiply(intm, intm, move); + _MatrixUtilMultiply(m, intm, m); + } + else + { + if (__scaleX != 1.0f) + { + m.matrix[0][0] = m.matrix[0][0] * __scaleX; + m.matrix[1][0] = m.matrix[1][0] * __scaleX; + m.matrix[2][0] = m.matrix[2][0] * __scaleX; + m.matrix[3][0] = m.matrix[3][0] * __scaleX; + } + + if (__scaleY != 1.0f) + { + m.matrix[0][1] = m.matrix[0][1] * __scaleY; + m.matrix[1][1] = m.matrix[1][1] * __scaleY; + m.matrix[2][1] = m.matrix[2][1] * __scaleY; + m.matrix[3][1] = m.matrix[3][1] * __scaleY; + } + + if (__scaleZ != 1.0f) + { + m.matrix[0][2] = m.matrix[0][2] * __scaleZ; + m.matrix[1][2] = m.matrix[1][2] * __scaleZ; + m.matrix[2][2] = m.matrix[2][2] * __scaleZ; + m.matrix[3][2] = m.matrix[3][2] * __scaleZ; + } + } +#endif + + m.Transpose(); + + return m; +} + +void +_TransformMatrix3Df::UpdateRotationFromEulerAngles(float x, float y, float z) +{ + // WARNING: + // Internal quaternion complies with left-hand system. + // + float hx = 0.5f * DEGTORAD(x); + float hy = 0.5f * DEGTORAD(y); + float hz = 0.5f * DEGTORAD(z); + float xcosh = cosf(hx); + float ycosh = cosf(hy); + float zcosh = cosf(hz); + float xsinh = sinf(hx); + float ysinh = sinf(hy); + float zsinh = sinf(hz); + + __quatW = zcosh * ycosh * xcosh + zsinh * ysinh * xsinh; + __quatX = zcosh * ycosh * xsinh - zsinh * ysinh * xcosh; + __quatY = zcosh * ysinh * xcosh + zsinh * ycosh * xsinh; + __quatZ = zsinh * ycosh * xcosh - zcosh * ysinh * xsinh; + +#if 0 + printf("--euler:%f,%f,%f(%f, %f, %f)\n", + x, y, z, + atan2f(2.0f * (__quatW * __quatX + __quatY * __quatZ), 1.0f - 2.0f * (__quatX * __quatX + __quatY * __quatY)) * 180.0f / M_PI, + asinf(2.0f * (__quatW * __quatY - __quatZ * __quatX)) * 180.0f / M_PI, + atan2f(2.0f * (__quatW * __quatZ + __quatX * __quatY), 1.0f - 2.0f * (__quatY * __quatY + __quatZ * __quatZ)) * 180.0f / M_PI + ); +#endif + + __rotX = x; + __rotY = y; + __rotZ = z; + + + __useRotation = (unlikely(!_FloatCompare(__quatX, 0.0f)) || unlikely(!_FloatCompare(__quatY, 0.0f)) || unlikely(!_FloatCompare(__quatZ, 0.0f)) || unlikely(!_FloatCompare(__quatW, 1.0f))); + UpdateMatrixType(false); + + //DumpQuaternion(*this); +} + +#if 0 +void +_TransformMatrix3Df::CalcEulerAngles(void) +{ + exit(1); + + float sx = __quatX * __quatX; + float sy = __quatY * __quatY; + float sz = __quatZ * __quatZ; + +#if 0 + float sw = __quatW * __quatW; + + __rotX = atan2f(2.0f * (__quatY * __quatZ + __quatX * __quatW), (sw - sx - sy + sz)); + __rotY = asinf(-2.0f * (__quatX * __quatZ - __quatY * __quatW)); + __rotZ = atan2f(2.0f * (__quatX * __quatY + __quatZ * __quatW), (sw + sx - sy - sz)); +#else + __rotX = atan2f(2.0f * (__quatX * __quatW + __quatY * __quatZ), 1.0f - 2.0f * (sx + sy)); + __rotY = asinf(-2.0f * (__quatX * __quatZ - __quatY * __quatW)); + __rotZ = atan2f(2.0f * (__quatX * __quatY + __quatZ * __quatW), 1.0f - 2.0f * (sy + sz)); +#endif + + __rotX *= 180.0f / M_PI; + __rotY *= 180.0f / M_PI; + __rotZ *= 180.0f / M_PI; +} +#endif + +void +_TransformMatrix3Df::GetEulerAngles(float& x, float& y, float& z) const +{ + x = __rotX; + y = __rotY; + z = __rotZ; +} + +void +_TransformMatrix3Df::GetQuaternion(float& x, float& y, float& z, float& w) const +{ + x = __quatX; + y = __quatY; + z = __quatZ; + w = __quatW; +} + +void +_TransformMatrix3Df::GetRotationAnchor(float& x, float& y, float& z) const +{ + x = __rotAnchorX; + y = __rotAnchorY; + z = __rotAnchorZ; +} + +void +_TransformMatrix3Df::SetRotationAnchor(float x, float y, float z) +{ + __rotAnchorX = x; + __rotAnchorY = y; + __rotAnchorZ = z; +} + +void +_TransformMatrix3Df::GetScaleFactors(float& x, float& y, float& z) const +{ + x = __scaleX; + y = __scaleY; + z = __scaleZ; +} + +void +_TransformMatrix3Df::SetScaleFactors(float x, float y, float z) +{ + __scaleX = x; + __scaleY = y; + __scaleZ = z; + + __useScale = (unlikely(!_FloatCompare(x, 1.0f)) || unlikely(!_FloatCompare(y, 1.0f)) || unlikely(!_FloatCompare(z, 1.0f))); + UpdateMatrixType(false); +} + +void +_TransformMatrix3Df::GetScaleAnchor(float& x, float& y, float& z) const +{ + x = __scaleAnchorX; + y = __scaleAnchorY; + z = __scaleAnchorZ; +} + +void +_TransformMatrix3Df::SetScaleAnchor(float x, float y, float z) +{ + __scaleAnchorX = x; + __scaleAnchorY = y; + __scaleAnchorZ = z; +} + +void +_TransformMatrix3Df::GetShearFactors(float& xy, float& xz, float& yz) const +{ + xy = __shearXY; + xz = __shearXZ; + yz = __shearYZ; +} + +void +_TransformMatrix3Df::SetShearFactors(float xy, float xz, float yz) +{ + __shearXY = xy; + __shearXZ = xz; + __shearYZ = yz; + + __useShear = (unlikely(!_FloatCompare(xy, 0.0f)) || unlikely(!_FloatCompare(xz, 0.0f)) || unlikely(!_FloatCompare(yz, 0.0f))); + UpdateMatrixType(false); +} + +void +_TransformMatrix3Df::GetTranslationFactors(float& x, float& y, float& z) const +{ + x = __translationX; + y = __translationY; + z = __translationZ; +} + +void +_TransformMatrix3Df::SetTranslationFactors(float x, float y, float z) +{ + __translationX = x; + __translationY = y; + __translationZ = z; + + __useTranslation = (unlikely(!_FloatCompare(x, 0.0f)) || unlikely(!_FloatCompare(y, 0.0f)) || unlikely(!_FloatCompare(z, 0.0f))); + UpdateMatrixType(false); +} + +void +_TransformMatrix3Df::GetPerspectiveFactors(float& x, float& y, float& z, float& w) const +{ + x = __perspectiveX; + y = __perspectiveY; + z = __perspectiveZ; + w = __perspectiveW; +} + +void +_TransformMatrix3Df::SetPerspectiveFactors(float x, float y, float z, float w) +{ + __perspectiveX = x; + __perspectiveY = y; + __perspectiveZ = z; + __perspectiveW = w; + + __usePerspective = (unlikely(!_FloatCompare(x, 0.0f)) || !unlikely(_FloatCompare(y, 0.0f)) || !unlikely(_FloatCompare(z, 0.0f)) || unlikely(!_FloatCompare(w, 1.0f))); + UpdateMatrixType(false); +} + +// Perform a spherical linear interpolation between the two +// passed quaternions with 0 <= t <= 1 +void +_TransformMatrix3Df::DoSlerp(float* result, const float* src1, const float* src2, float t) const +{ + float ax, ay, az, aw; + float bx, by, bz, bw; + float cx, cy, cz, cw; + float angle; + float th, invth, scale, invscale; + + if (unlikely(t == 0.0f)) + { + result[0] = src1[0]; + result[1] = src1[1]; + result[2] = src1[2]; + result[3] = src1[3]; + return; + } + + if (unlikely(t == 1.0f)) + { + result[0] = src2[0]; + result[1] = src2[1]; + result[2] = src2[2]; + result[3] = src2[3]; + return; + } + + + ax = src1[0]; ay = src1[1]; az = src1[2]; aw = src1[3]; + bx = src2[0]; by = src2[1]; bz = src2[2]; bw = src2[3]; + + angle = ax * bx + ay * by + az * bz + aw * bw; + +#if 1 + if (angle < 0.0f) + { + ax = -ax; ay = -ay; + az = -az; aw = -aw; + angle = -angle; + } + + if (angle + 1.0f > 0.05f) + { + if (1.0f - angle >= 0.05f) + { + th = acosf(angle); + invth = 1.0f / sinf(th); + scale = sinf(th * (1.0f - t)) * invth; + invscale = sinf(th * t) * invth; + } + else + { + scale = 1.0f - t; + invscale = t; + } + } + else + { + bx = -ay; + by = ax; + bz = -aw; + bw = az; + scale = sinf(M_PI * (0.5f - t)); + invscale = sinf(M_PI * t); + } + + cx = ax * scale + bx * invscale; + cy = ay * scale + by * invscale; + cz = az * scale + bz * invscale; + cw = aw * scale + bw * invscale; + //cz = -cz; +#if 0 + float the, a, rx, ry, rz; + the = acosf(cw); + a = the * 2.0f * 180.0f / M_PI; + rx = cx / sinf(the); + ry = cy / sinf(the); + rz = cz / sinf(the); +//printf("--- angle= %f(f= %f,%f,%f)(%f, %f, %f, %f)\n", a, rx, ry, rz, cx, cy, cz, cw); +#endif +#endif + +#if 0 + if (angle < 0) + { + bx = -bx; + by = -by; + bz = -bz; + bw = -bw; + angle = -angle; + } + + if (angle <= -1.0f || angle >= 1.0f) + { + cx = ax; + cy = ay; + cz = az; + cw = aw; + } + else + { + th = acos(angle); + float sinHalfTheta = sqrt(1.0 - angle * angle); + if (abs(sinHalfTheta) < 0.001) + { + cx = ax * 0.5 + bx * 0.5; + cy = ay * 0.5 + by * 0.5; + cz = az * 0.5 + bz * 0.5; + cw = aw * 0.5 + bw * 0.5; + } + else + { + float ra = sin((1.0 - t) * th) / sinHalfTheta; + float rb = sin(t * th) / sinHalfTheta; + cx = ax * ra + bx * rb; + cy = ay * ra + by * rb; + cz = az * ra + bz * rb; + cw = aw * ra + bw * rb; + } + } +#endif + + + result[0] = cx; + result[1] = cy; + result[2] = cz; + result[3] = cw; +} + +#if 0 +void +_TransformMatrix3Df::V4MulPointByMatrix(const _Vector4Df& pin, const FloatMatrix4& m, _Vector4Df& pout) const +{ +/* + pout.x = (pin.x * m.Get(0, 0)) + + (pin.y * m.Get(1, 0)) + + (pin.z * m.Get(2, 0)) + + (pin.w * m.Get(3, 0)); + + pout.y = (pin.x * m.Get(0, 1)) + + (pin.y * m.Get(1, 1)) + + (pin.z * m.Get(2, 1)) + + (pin.w * m.Get(3, 1)); + + pout.z = (pin.x * m.Get(0, 2)) + + (pin.y * m.Get(1, 2)) + + (pin.z * m.Get(2, 2)) + + (pin.w * m.Get(3, 2)); + + pout.w = (pin.x * m.Get(0, 3)) + + (pin.y * m.Get(1, 3)) + + (pin.z * m.Get(2, 3)) + + (pin.w * m.Get(3, 3)); +*/ + + pout.x = (pin.x * m.matrix[0][0]) + + (pin.y * m.matrix[0][1]) + + (pin.z * m.matrix[0][2]) + + (pin.w * m.matrix[0][3]); + + pout.y = (pin.x * m.matrix[1][0]) + + (pin.y * m.matrix[1][1]) + + (pin.z * m.matrix[1][2]) + + (pin.w * m.matrix[1][3]); + + pout.z = (pin.x * m.matrix[2][0]) + + (pin.y * m.matrix[2][1]) + + (pin.z * m.matrix[2][2]) + + (pin.w * m.matrix[2][3]); + + pout.w = (pin.x * m.matrix[3][0]) + + (pin.y * m.matrix[3][1]) + + (pin.z * m.matrix[3][2]) + + (pin.w * m.matrix[3][3]); + +} + +float +_TransformMatrix3Df::V3SquaredLength(const _Vector3Df& v) const +{ + return ((v.x * v.x) + (v.y * v.y) + (v.z * v.z)); +} + +float +_TransformMatrix3Df::V3Length(const _Vector3Df& v) const +{ + return (sqrtf(V3SquaredLength(v))); +} + +void +_TransformMatrix3Df::V3Scale(_Vector3Df& v, float newlen) const +{ + float len = V3Length(v); + + if (len != 0.0f) + { + v.x *= newlen / len; + v.y *= newlen / len; + v.z *= newlen / len; + } +} + +float +_TransformMatrix3Df::V3Dot(const _Vector3Df& a, const _Vector3Df& b) const +{ + return ((a.x * b.x) + (a.y * b.y) + (a.z * b.z)); +} + +void +_TransformMatrix3Df::V3Combine(const _Vector3Df& a, const _Vector3Df& b, _Vector3Df& result, float ascl, float bscl) const +{ + result.x = (ascl * a.x) + (bscl * b.x); + result.y = (ascl * a.y) + (bscl * b.y); + result.z = (ascl * a.z) + (bscl * b.z); +} + +void +_TransformMatrix3Df::V3Cross(const _Vector3Df& a, const _Vector3Df& b, _Vector3Df& c) const +{ + c.x = (a.y * b.z) - (a.z * b.y); + c.y = (a.z * b.x) - (a.x * b.z); + c.z = (a.x * b.y) - (a.y * b.x); +} +#endif + +}}} // Tizen::Ui::Animations + + diff --git a/src/ui/animations/FUiAnim_VariantEx.cpp b/src/ui/animations/FUiAnim_VariantEx.cpp new file mode 100644 index 0000000..7362544 --- /dev/null +++ b/src/ui/animations/FUiAnim_VariantEx.cpp @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VariantEx.cpp + * @brief This file contains implementation of _VariantEx class + * + * This file contains implementation _VariantEx class. + */ + +#include "FUiAnim_VariantEx.h" +#include "FUiAnim_TransformMatrix3Df.h" + +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Animations { + +_VariantEx::_VariantEx(void) + : Variant() + , __transformMatrix() + , __isValidTransformMatrix(false) +{ +} + +_VariantEx::_VariantEx(const Variant& v) + : Variant(v) + , __transformMatrix() + , __isValidTransformMatrix(false) +{ + UpdateVariant(v); +} + +_VariantEx::~_VariantEx(void) +{ +} + +void +_VariantEx::UpdateVariant(const Variant& v) +{ + Variant::operator= (v); + + __isValidTransformMatrix = false; + + if (v.GetType() == VARIANT_TYPE_FLOAT_MATRIX4) + __isValidTransformMatrix = __transformMatrix.SetTransformMatrix(v.ToFloatMatrix4()); + + if (!__isValidTransformMatrix) + __transformMatrix.Clear(); +} + +bool +_VariantEx::IsValidTransformMatrix(void) const +{ + return __isValidTransformMatrix; +} + +const _TransformMatrix3Df& +_VariantEx::GetTransformMatrix(void) const +{ + return __transformMatrix; +} + +}}} // Tizen::Ui::Animations + + diff --git a/src/ui/animations/FUiAnim_VariantEx.h b/src/ui/animations/FUiAnim_VariantEx.h new file mode 100644 index 0000000..43faee6 --- /dev/null +++ b/src/ui/animations/FUiAnim_VariantEx.h @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VariantEx.h + * @brief Header file of _VariantEx class + * + * This file contains declarations _VariantEx class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VARIANTEX_H_ +#define _FUI_ANIM_INTERNAL_VARIANTEX_H_ + +#include +#include +#include "FUiAnim_TransformMatrix3Df.h" + +namespace Tizen { namespace Ui { namespace Animations { + +class _VariantEx : + public Tizen::Ui::Variant +{ +public: + _VariantEx(void); + _VariantEx(const Variant& v); + virtual ~_VariantEx(void); + +public: + bool IsValidTransformMatrix(void) const; + const _TransformMatrix3Df& GetTransformMatrix(void) const; + +#if 0 + _VariantEx& operator= (const Variant& v) + { + if (&v != this) + UpdateVariant(v); + + return *this; + } +#endif + + _VariantEx& operator= (const _VariantEx& v) + { + if (&v != this) + { + __transformMatrix = v.__transformMatrix; + __isValidTransformMatrix = v.__isValidTransformMatrix; + + Variant::operator= (v); + } + + return *this; + } + +private: + void UpdateVariant(const Variant& v); + + _TransformMatrix3Df __transformMatrix; + bool __isValidTransformMatrix; +}; // _VariantEx + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_VARIANTEX_H_ + diff --git a/src/ui/animations/FUiAnim_VisualElement.cpp b/src/ui/animations/FUiAnim_VisualElement.cpp new file mode 100644 index 0000000..fef79b5 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElement.cpp @@ -0,0 +1,204 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElement.cpp + * @brief This file contains implementation of _VisualElement class + * + * This file contains implementation _VisualElement class. + */ + +#include + +#include "FUiAnim_EflNode.h" +#include "FUiAnim_VisualElement.h" +#include "FUiAnim_VisualElementImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Animations +{ + + +//IMPLEMENT_PROPERTY(_VisualElement); + +_VisualElement::_VisualElement(void) + : __pUserData(null) +{ + +} + +_VisualElement::~_VisualElement(void) +{ +} + +VisualElement* +_VisualElement::CloneN(void) const +{ + return new (std::nothrow) _VisualElement(*this); +} + +_VisualElement::_VisualElement(const _VisualElement& rhs) + : VisualElement(rhs) + , __pUserData(null) +{ +} + +_Colorf +_VisualElement::GetBackgroundColor(void) const +{ + _EflNode* pNativeNode = dynamic_cast< _EflNode* >(_pVisualElementImpl->GetNativeNode()); + + SysTryReturn(NID_UI, pNativeNode, _Colorf(0.0f, 0.0f, 0.0f, 1.0f), E_INVALID_STATE, "[E_INVALID_STATE] No object for background."); // CHECKME: Default BG? + + return pNativeNode->GetBackgroundColor(); +} + +result +_VisualElement::SetBackgroundColor(const _Colorf& color) +{ + result r = E_SUCCESS; + _EflNode* pNativeNode = dynamic_cast< _EflNode* >(_pVisualElementImpl->GetNativeNode()); + + SysTryReturnResult(NID_UI, pNativeNode, E_INVALID_STATE, "No object for background."); // CHECKME: Default BG? + + r = pNativeNode->SetBackgroundColor(color); + if (_pVisualElementImpl->GetPresentation()) (_pVisualElementImpl->GetPresentation())->InvalidateHierarchyProps((int)_VisualElementImpl::HIERARCHY_PROPERTY_NATIVENODE, false, false); + + return r; +} + +FloatRectangle +_VisualElement::GetBoundingBox(void) +{ + return _pVisualElementImpl->GetBoundingBox(); +} + +result +_VisualElement::SetZOrder(const VisualElement* pReference, bool above) +{ + const _VisualElementImpl* pImpl = null; + if (pReference) + { + pImpl = _VisualElementImpl::GetInstance(*pReference); + } + + return _pVisualElementImpl->SetZOrder(pImpl , above); +} + +result +_VisualElement::SetImageSource(const String& fileName) +{ + return _pVisualElementImpl->SetImageSource(fileName); +} + +result +_VisualElement::SetContentOpacity(float contentOpacity) +{ + return _pVisualElementImpl->SetContentOpacity(contentOpacity); +} + +result +_VisualElement::Capture(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& boundsToDraw, bool withChilren) +{ + return _pVisualElementImpl->Capture(canvas, boundsToDraw, withChilren); +} + +_INativeNode* +_VisualElement::GetNativeNode(void) const +{ + return _pVisualElementImpl->GetNativeNode(); +} + +_VisualElement* _VisualElement::GetPresentation(void) +{ + return dynamic_cast< _VisualElement* >(_pVisualElementImpl->__pPresentation->__pPublicInstance); +} + +_VisualElement* _VisualElement::GetModel(void) +{ + return dynamic_cast< _VisualElement* >(_pVisualElementImpl->__pPresentation->__pPublicInstance); +} + +void +_VisualElement::SetControlUserData(void* pUserData) +{ + ClearLastResult(); + __pUserData = pUserData; +} + +void* +_VisualElement::GetControlUserData(void) const +{ + ClearLastResult(); + return __pUserData; +} + + +bool +_VisualElement::OnPrepareDraw(void) +{ + return false; +} + +result +_VisualElement::SetClipToParent(bool clipToParent) +{ + return _pVisualElementImpl->SetClipToParent(clipToParent); +} + +result +_VisualElement::SetBackBufferEnabled(bool enable) +{ + return _pVisualElementImpl->SetBackBufferEnabled(enable); +} + +result +_VisualElement::SetSurfaceOpaque(bool isSurfaceOpaque) +{ + return _pVisualElementImpl->SetSurfaceOpaque(isSurfaceOpaque); +} + +result +_VisualElement::ScrollByPoint(const FloatPoint& pointOffset, bool scrollSelf) +{ + return _pVisualElementImpl->ScrollByPoint(pointOffset, scrollSelf); +} + +IVisualElementAnimationProvider* +_VisualElement::GetAnimationProvider(void) const +{ + return _pVisualElementImpl->GetAnimationProvider(); +} + +IVisualElementContentProvider* +_VisualElement::GetContentProvider(void) const +{ + return _pVisualElementImpl->GetContentProvider(); +} + + +IVisualElementEventListener* +_VisualElement::GetVisualElementEventListener(void) const +{ + return _pVisualElementImpl->GetVisualElementEventListener(); +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_VisualElementAnimationGroupImpl.cpp b/src/ui/animations/FUiAnim_VisualElementAnimationGroupImpl.cpp new file mode 100644 index 0000000..1787392 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementAnimationGroupImpl.cpp @@ -0,0 +1,196 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementAnimationGroupImpl.cpp + * @brief This file contains implementation of _VisualElementAnimationGroupImpl class + * + * This file contains implementation _VisualElementAnimationGroupImpl class. + */ + +#include + +#include +#include + +#include "FUiAnim_VisualElementAnimationGroupImpl.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + + +_VisualElementAnimationGroupImpl::_VisualElementAnimationGroupImpl(void) +{ + result r = __animationList.Construct(); + + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Failed to construct the animation list.", GetErrorMessage(r)); +} + +_VisualElementAnimationGroupImpl::_VisualElementAnimationGroupImpl(const _VisualElementAnimationGroupImpl& animationGroupImpl) +{ + __animationList.Construct(); + + result r = CopyAnimationValue(animationGroupImpl); + + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +_VisualElementAnimationGroupImpl::~_VisualElementAnimationGroupImpl(void) +{ + __animationList.RemoveAll(true); +} + +bool +_VisualElementAnimationGroupImpl::Equals(const Tizen::Base::Object& obj) const +{ + if (this == &obj) + { + return true; + } + + if (_VisualElementAnimationImpl::Equals(obj) == false) + { + return false; + } + + const _VisualElementAnimationGroupImpl* pAnimationGroupImpl = dynamic_cast< const _VisualElementAnimationGroupImpl* >(&obj); + + if (pAnimationGroupImpl == null || GetAnimationCount() != pAnimationGroupImpl->GetAnimationCount()) + { + return false; + } + + for (int index = 0; index < GetAnimationCount(); index++) + { + if ((__animationList.GetAt(index))->Equals(*(pAnimationGroupImpl->__animationList.GetAt(index))) == false) + { + return false; + } + } + + return true; +} + +int +_VisualElementAnimationGroupImpl::GetHashCode(void) const +{ + return (_VisualElementAnimationImpl::GetHashCode() + __animationList.GetHashCode()); +} + +result +_VisualElementAnimationGroupImpl::CopyAnimationValue(const _VisualElementAnimationGroupImpl& animationGroupImpl) +{ + result r = E_SUCCESS; + + r = _VisualElementAnimationImpl::CopyAnimationValue(animationGroupImpl); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + const VisualElementAnimation* pAnimation = null; + VisualElementAnimation* pCloned = null; + + for (int index = 0; index < animationGroupImpl.GetAnimationCount(); index++) + { + pAnimation = dynamic_cast< const VisualElementAnimation* >(animationGroupImpl.__animationList.GetAt(index)); + + if (pAnimation != null) + { + pCloned = const_cast< VisualElementAnimation* >(pAnimation)->CloneN(); + + if (pCloned == null) + { + __animationList.RemoveAll(true); + + SysLogException(NID_UI_ANIM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + return E_OUT_OF_MEMORY; + } + + __animationList.Add(*pCloned); + } + } + + return E_SUCCESS; +} + +int +_VisualElementAnimationGroupImpl::GetAnimationCount(void) const +{ + return __animationList.GetCount(); +} + +result +_VisualElementAnimationGroupImpl::AddAnimation(const VisualElementAnimation& animation) +{ + VisualElementAnimation* pCloned = const_cast< VisualElementAnimation& >(animation).CloneN(); + SysTryReturnResult(NID_UI_ANIM, pCloned != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + result r = __animationList.Add(*pCloned); + + if (r != E_SUCCESS) + { + delete pCloned; + } + + return r; +} + +result +_VisualElementAnimationGroupImpl::RemoveAnimationAt(int index) +{ + return __animationList.RemoveAt(index); +} + +void +_VisualElementAnimationGroupImpl::RemoveAllAnimations(void) +{ + __animationList.RemoveAll(true); +} + +VisualElementAnimation* +_VisualElementAnimationGroupImpl::GetAnimationAtN(int index) const +{ + const VisualElementAnimation* pAnimation = dynamic_cast< const VisualElementAnimation* >(__animationList.GetAt(index)); + + if (pAnimation) + { + SetLastResult(E_SUCCESS); + return const_cast< VisualElementAnimation* >(pAnimation)->CloneN(); + } + + SetLastResult(E_OBJ_NOT_FOUND); + return null; +} + +VisualElementAnimation* +_VisualElementAnimationGroupImpl::GetAnimation(int index) const +{ + return dynamic_cast< VisualElementAnimation* >(const_cast< Tizen::Base::Object* >(__animationList.GetAt(index))); +} + +_VisualElementAnimationGroupImpl* +_VisualElementAnimationGroupImpl::GetInstance(VisualElementAnimationGroup& animation) +{ + return dynamic_cast<_VisualElementAnimationGroupImpl*>(animation._pAnimationImpl); +} + +const _VisualElementAnimationGroupImpl* +_VisualElementAnimationGroupImpl::GetInstance(const VisualElementAnimationGroup& animation) +{ + return dynamic_cast(animation._pAnimationImpl); +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_VisualElementAnimationGroupImpl.h b/src/ui/animations/FUiAnim_VisualElementAnimationGroupImpl.h new file mode 100644 index 0000000..b3bd8f6 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementAnimationGroupImpl.h @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementAnimationGroupImpl.h + * @brief This is the header file for the _VisualElementAnimationGroupImpl class. + * + * This header file contains the declarations of the _VisualElementAnimationGroupImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_GROUP_IMPL_H_ +#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_GROUP_IMPL_H_ + +#include +#include +#include + +#include "FUiAnim_VisualElementAnimationImpl.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + + +class VisualElementAnimation; +class VisualElementAnimationGroup; + +class _VisualElementAnimationGroupImpl + : public _VisualElementAnimationImpl +{ +public: + _VisualElementAnimationGroupImpl(void); + _VisualElementAnimationGroupImpl(const _VisualElementAnimationGroupImpl& animationImpl); + virtual ~_VisualElementAnimationGroupImpl(void); + + virtual bool Equals(const Tizen::Base::Object& obj) const; + virtual int GetHashCode(void) const; + + result CopyAnimationValue(const _VisualElementAnimationGroupImpl& animationGroupImpl); + + int GetAnimationCount(void) const; + result AddAnimation(const VisualElementAnimation& animation); + result RemoveAnimationAt(int index); + void RemoveAllAnimations(void); + VisualElementAnimation* GetAnimationAtN(int index) const; + + // for internal + VisualElementAnimation* GetAnimation(int index) const; + + static _VisualElementAnimationGroupImpl* GetInstance(VisualElementAnimationGroup& pAnimation); + static const _VisualElementAnimationGroupImpl* GetInstance(const VisualElementAnimationGroup& pAnimation); + +private: + _VisualElementAnimationGroupImpl& operator =(const _VisualElementAnimationGroupImpl& rhs); + +private: + Tizen::Base::Collection::ArrayList __animationList; +}; // _VisualElementAnimationGroupImpl + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_GROUP_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_VisualElementAnimationImpl.cpp b/src/ui/animations/FUiAnim_VisualElementAnimationImpl.cpp new file mode 100644 index 0000000..5f10ebd --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementAnimationImpl.cpp @@ -0,0 +1,208 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementAnimationImpl.cpp + * @brief This file contains implementation of _VisualElementAnimationImpl class + * + * This file contains implementation _VisualElementAnimationImpl class. + */ + +#include + +#include +#include +#include +#include + +#include "FUiAnim_VisualElementAnimationImpl.h" +#include "FUiAnim_AnimationManager.h" +#include "FUiAnim_TransactionNode.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + + +_VisualElementAnimationImpl::_VisualElementAnimationImpl(void) + : __pStatusListener(null) + , __pTimingFunction(null) + , __pInterpolator(null) + , __pUserData(null) + , __pEventTarget(null) +{ + _TransactionNode* pNode = _AnimationManager::GetInstance()->GetCurrentTransaction(false); + + if (pNode) + { + result r = CopyAnimationValue(*pNode); + + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } +} + +_VisualElementAnimationImpl::_VisualElementAnimationImpl(const _VisualElementAnimationImpl& animationImpl) + : __pStatusListener(null) + , __pTimingFunction(null) + , __pInterpolator(null) + , __pUserData(null) + , __pEventTarget(null) +{ + result r = CopyAnimationValue(animationImpl); + + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +_VisualElementAnimationImpl::~_VisualElementAnimationImpl(void) +{ + +} + +bool +_VisualElementAnimationImpl::Equals(const Tizen::Base::Object& obj) const +{ + if (this == &obj) + { + return true; + } + + const _VisualElementAnimationImpl* pAnimationImpl = dynamic_cast< const _VisualElementAnimationImpl* >(&obj); + + if (pAnimationImpl == null) + { + return false; + } + + return ((GetDuration() == pAnimationImpl->GetDuration()) + && (GetDelay() == pAnimationImpl->GetDelay()) + && (GetOffset() == pAnimationImpl->GetOffset()) + && (GetRepeatCount() == pAnimationImpl->GetRepeatCount()) + && (GetScaleRatio() == pAnimationImpl->GetScaleRatio()) + && (IsAutoReverseEnabled() == pAnimationImpl->IsAutoReverseEnabled()) + && (__pStatusListener == pAnimationImpl->__pStatusListener) + && (__pTimingFunction == pAnimationImpl->__pTimingFunction) + && (__pInterpolator == pAnimationImpl->__pInterpolator) + && (__pUserData == pAnimationImpl->__pUserData)); +} + +int +_VisualElementAnimationImpl::GetHashCode(void) const +{ + return (GetDuration() + GetOffset() + GetDelay() + GetRepeatCount() + GetScaleRatio() + IsAutoReverseEnabled()); +} + +result +_VisualElementAnimationImpl::CopyAnimationValue(const _VisualElementAnimationImpl& animationImpl) +{ + SetDuration(animationImpl.GetDuration()); + SetDelay(animationImpl.GetDelay()); + SetOffset(animationImpl.GetOffset()); + SetRepeatCount(animationImpl.GetRepeatCount()); + SetScaleRatio(animationImpl.GetScaleRatio()); + SetAutoReverseEnabled(animationImpl.IsAutoReverseEnabled()); + + __pStatusListener = animationImpl.__pStatusListener; + __pTimingFunction = animationImpl.__pTimingFunction; + __pInterpolator = animationImpl.__pInterpolator; + __pUserData = animationImpl.__pUserData; + __pEventTarget = animationImpl.__pEventTarget; + + return E_SUCCESS; +} + +bool +_VisualElementAnimationImpl::IsAnimationSupported(void) +{ + static bool isAnimationSupported = true; + + return isAnimationSupported; +} + +void +_VisualElementAnimationImpl::SetStatusEventListener(IVisualElementAnimationStatusEventListener* pListener) +{ + __pStatusListener = pListener; +} + +IVisualElementAnimationStatusEventListener* +_VisualElementAnimationImpl::GetStatusEventListener(void) const +{ + return __pStatusListener; +} + +void +_VisualElementAnimationImpl::SetTimingFunction(const IVisualElementAnimationTimingFunction* pTimingFunction) +{ + __pTimingFunction = pTimingFunction; +} + +const IVisualElementAnimationTimingFunction* +_VisualElementAnimationImpl::GetTimingFunction(void) const +{ + return __pTimingFunction; +} + +void +_VisualElementAnimationImpl::SetValueInterpolator(const IVisualElementAnimationValueInterpolator* pInterpolator) +{ + __pInterpolator = pInterpolator; +} + +const IVisualElementAnimationValueInterpolator* +_VisualElementAnimationImpl::GetValueInterpolator(void) const +{ + return __pInterpolator; +} + +void +_VisualElementAnimationImpl::SetUserData(void* pUserData) +{ + __pUserData = pUserData; +} + +void* +_VisualElementAnimationImpl::GetUserData(void) const +{ + return __pUserData; +} + +void +_VisualElementAnimationImpl::SetEventTarget(VisualElement& target) +{ + __pEventTarget = ⌖ +} + +VisualElement& +_VisualElementAnimationImpl::GetEventTarget(void) const +{ + return *__pEventTarget; +} + +_VisualElementAnimationImpl* +_VisualElementAnimationImpl::GetInstance(VisualElementAnimation& animation) +{ + return animation._pAnimationImpl; +} + +const _VisualElementAnimationImpl* +_VisualElementAnimationImpl::GetInstance(const VisualElementAnimation& animation) +{ + return static_cast(animation._pAnimationImpl); +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_VisualElementAnimationImpl.h b/src/ui/animations/FUiAnim_VisualElementAnimationImpl.h new file mode 100644 index 0000000..689dc3a --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementAnimationImpl.h @@ -0,0 +1,91 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementAnimationImpl.h + * @brief This is the header file for the _VisualElementAnimationImpl class. + * + * This header file contains the declarations of the _VisualElementAnimationImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_IMPL_H_ +#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_IMPL_H_ + +#include +#include +#include + +#include "FUiAnim_VisualElementAnimationTiming.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class VisualElement; +class IVisualElementAnimationStatusEventListener; +class IVisualElementAnimationTimingFunction; +class IVisualElementAnimationValueInterpolator; +class VisualElementAnimation; + +class _VisualElementAnimationImpl + : public _VisualElementAnimationTiming +{ +public: + _VisualElementAnimationImpl(void); + _VisualElementAnimationImpl(const _VisualElementAnimationImpl& animationImpl); + virtual ~_VisualElementAnimationImpl(void); + + virtual bool Equals(const Tizen::Base::Object& obj) const; + virtual int GetHashCode(void) const; + + result CopyAnimationValue(const _VisualElementAnimationImpl& animationImpl); + + void SetStatusEventListener(IVisualElementAnimationStatusEventListener* pListener); + IVisualElementAnimationStatusEventListener* GetStatusEventListener(void) const; + + void SetTimingFunction(const IVisualElementAnimationTimingFunction* pTimingFunction); + const IVisualElementAnimationTimingFunction* GetTimingFunction(void) const; + + void SetValueInterpolator(const IVisualElementAnimationValueInterpolator* pInterpolator); + const IVisualElementAnimationValueInterpolator* GetValueInterpolator(void) const; + + void SetUserData(void* pUserData); + void* GetUserData(void) const; + + void SetEventTarget(VisualElement& target); + VisualElement& GetEventTarget(void) const; + + static bool IsAnimationSupported(void); + + static _VisualElementAnimationImpl* GetInstance(VisualElementAnimation& animation); + static const _VisualElementAnimationImpl* GetInstance(const VisualElementAnimation& animation); + +private: + _VisualElementAnimationImpl& operator =(const _VisualElementAnimationImpl& rhs); + +private: + IVisualElementAnimationStatusEventListener* __pStatusListener; + const IVisualElementAnimationTimingFunction* __pTimingFunction; + const IVisualElementAnimationValueInterpolator* __pInterpolator; + void* __pUserData; + VisualElement* __pEventTarget; +}; // _VisualElementAnimationImpl + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_VisualElementAnimationKeyFrame.cpp b/src/ui/animations/FUiAnim_VisualElementAnimationKeyFrame.cpp new file mode 100644 index 0000000..293cfcd --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementAnimationKeyFrame.cpp @@ -0,0 +1,242 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementAnimationKeyFrame.cpp + * @brief This file contains implementation of _VisualElementAnimationKeyFrame class + * + * This file contains implementation _VisualElementAnimationKeyFrame class. + */ + +#include +#include + +#include "FUi_Math.h" +#include "FUiAnim_VariantEx.h" +#include "FUiAnim_VisualElementAnimationKeyFrame.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _KeyFrameComparer + : public Tizen::Base::Collection::IComparer +{ +public: + _KeyFrameComparer(void) + { + } + + virtual ~_KeyFrameComparer(void) + { + } + + virtual result Compare(const Tizen::Base::Object& obj1, const Tizen::Base::Object& obj2, int& cmp) const + { + const _VisualElementAnimationKeyFrameInfo* pInfo1 = dynamic_cast (&obj1); + const _VisualElementAnimationKeyFrameInfo* pInfo2 = dynamic_cast (&obj2); + + SysTryReturnResult(NID_BASE, (pInfo1 != null && pInfo2 != null), E_INVALID_ARG, "Invalid argument(s) is used. Both of the obj1 and obj2 MUST be _VisualElementAnimationKeyFrameInfo."); + + cmp = Tizen::Base::Float::Compare(pInfo1->GetTime(), pInfo2->GetTime()); + + return E_SUCCESS; + } +}; + +_VisualElementAnimationKeyFrameInfo::_VisualElementAnimationKeyFrameInfo(float time, const Variant& value, const IVisualElementAnimationTimingFunction* pTimingFunction) + : __time(time) + , __value(value) + , __valueEx(value) + , __pTimingFunction(pTimingFunction) +{ +} + +_VisualElementAnimationKeyFrameInfo::~_VisualElementAnimationKeyFrameInfo(void) +{ +} + +bool +_VisualElementAnimationKeyFrameInfo::Equals(const Tizen::Base::Object& obj) const +{ + const _VisualElementAnimationKeyFrameInfo* pKeyFrameInfo = dynamic_cast< const _VisualElementAnimationKeyFrameInfo* >(&obj); + + if (pKeyFrameInfo == null) + { + return false; + } + + return ( + (_FloatCompare(__time, pKeyFrameInfo->__time)) + && (__valueEx == pKeyFrameInfo->__valueEx) + && (__pTimingFunction == pKeyFrameInfo->__pTimingFunction) + ); +} + +float +_VisualElementAnimationKeyFrameInfo::GetTime(void) const +{ + return __time; +} + +Variant +_VisualElementAnimationKeyFrameInfo::GetValue(void) const +{ + return __value; +} + +_VariantEx +_VisualElementAnimationKeyFrameInfo::GetValueEx(void) const +{ + return __valueEx; +} + +const IVisualElementAnimationTimingFunction* +_VisualElementAnimationKeyFrameInfo::GetTimingFunction(void) const +{ + return __pTimingFunction; +} + +_VisualElementAnimationKeyFrame::_VisualElementAnimationKeyFrame(void) +{ + __keyFrameList.Construct(); +} + +_VisualElementAnimationKeyFrame::~_VisualElementAnimationKeyFrame(void) +{ + __keyFrameList.RemoveAll(true); +} + +bool +_VisualElementAnimationKeyFrame::Equals(const Tizen::Base::Object& obj) const +{ + const _VisualElementAnimationKeyFrame* pKeyFrame = dynamic_cast< const _VisualElementAnimationKeyFrame* >(&obj); + + if (pKeyFrame == null) + { + return false; + } + + return __keyFrameList.Equals(pKeyFrame->__keyFrameList); +} + +_VisualElementAnimationKeyFrame* +_VisualElementAnimationKeyFrame::CloneN(void) const +{ + int i = 0; + int count = __keyFrameList.GetCount(); + SysAssertf(count > 0, "The count of key frames is 0."); + + _VisualElementAnimationKeyFrame* pCloned = new (std::nothrow) _VisualElementAnimationKeyFrame(); + SysTryReturn(NID_UI_ANIM, pCloned, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + const _VisualElementAnimationKeyFrameInfo* pInfo = null; + + for (i = 0; i < count; i++) + { + pInfo = static_cast< const _VisualElementAnimationKeyFrameInfo* >(__keyFrameList.GetAt(i)); + SysAssertf(pInfo != null, "Key frame is null. index = %d", i); + + if (pCloned->AddKeyFrame(pInfo->GetTime(), pInfo->GetValue(), pInfo->GetTimingFunction()) != E_SUCCESS) + { + delete pCloned; + return null; + } + } + + return pCloned; +} + +int +_VisualElementAnimationKeyFrame::GetCount(void) const +{ + return __keyFrameList.GetCount(); +} + +result +_VisualElementAnimationKeyFrame::AddKeyFrame(float time, const Variant& value, const IVisualElementAnimationTimingFunction* pTimingFunction) +{ + _VisualElementAnimationKeyFrameInfo* pInfo = new (std::nothrow) _VisualElementAnimationKeyFrameInfo(time, value, pTimingFunction); + SysTryReturnResult(NID_UI_ANIM, pInfo, E_OUT_OF_MEMORY, "Memory allocation failed."); + + int index = GetKeyFrameIndex(time); + + if (index >= 0) + { + __keyFrameList.SetAt(*pInfo, index, true); + } + else + { + __keyFrameList.Add(*pInfo); + } + + _KeyFrameComparer comparer; + + __keyFrameList.Sort(comparer); + + return E_SUCCESS; +} + +result +_VisualElementAnimationKeyFrame::RemoveKeyFrame(float time) +{ + int index = GetKeyFrameIndex(time); + SysTryReturnResult(NID_UI_ANIM, index >= 0, E_OBJ_NOT_FOUND, "Key frame is not found. time = %f", time); + + return __keyFrameList.RemoveAt(index, true); +} + +void +_VisualElementAnimationKeyFrame::RemoveAllKeyFrames(void) +{ + __keyFrameList.RemoveAll(true); +} + +_VisualElementAnimationKeyFrameInfo* +_VisualElementAnimationKeyFrame::GetKeyFrameInfoAt(int index) const +{ + SysTryReturn(NID_UI_ANIM, index >= 0, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Key frame is not found. index = %d"); + + return static_cast< _VisualElementAnimationKeyFrameInfo* >(const_cast< Tizen::Base::Object* >(__keyFrameList.GetAt(index))); +} + +int +_VisualElementAnimationKeyFrame::GetKeyFrameIndex(float time) const +{ + int i = 0; + int index = -1; + int count = 0; + + count = __keyFrameList.GetCount(); + + const _VisualElementAnimationKeyFrameInfo* pInfo = null; + for (i = 0; i < count ; i++) + { + pInfo = static_cast< const _VisualElementAnimationKeyFrameInfo* >(__keyFrameList.GetAt(i)); + SysAssertf(pInfo != null, "Key frame is null."); + + if (_FloatCompare(time, pInfo->GetTime())) + { + index = i; + break; + } + } + + return index; +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_VisualElementAnimationKeyFrame.h b/src/ui/animations/FUiAnim_VisualElementAnimationKeyFrame.h new file mode 100644 index 0000000..462d940 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementAnimationKeyFrame.h @@ -0,0 +1,196 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementAnimationKeyFrame.h + * @brief This is the header file for the _VisualElementAnimationKeyFrame class. + * + * This header file contains the declarations of the _VisualElementAnimationKeyFrame class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_KEY_FRAME_H_ +#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_KEY_FRAME_H_ + +#include +#include +#include +#include + +#include "FUiAnim_VariantEx.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class VisualElementAnimation; + +class _VisualElementAnimationKeyFrameInfo + : public Tizen::Base::Object +{ +public: + + // + // This is the default constructor for this class. + // + _VisualElementAnimationKeyFrameInfo(float time, const Variant& value, const IVisualElementAnimationTimingFunction* pTimingFunction); + + // + // This is the destructor for this class. + // + virtual ~_VisualElementAnimationKeyFrameInfo(void); + + // + // Equals Function. + // + virtual bool Equals(const Tizen::Base::Object& obj) const; + + /** + * Gets time of the keyframe. + * + * @since 2.0 + * @return Time of the keyframe + */ + float GetTime(void) const; + + /** + * Gets animation value of the keyframe. + * + * @since 2.0 + * @return Animation value of the keyframe + */ + Variant GetValue(void) const; + + /** + * Gets animation extended value of the keyframe. + * + * @since 2.0 + * @return Animation value of the keyframe + */ + _VariantEx GetValueEx(void) const; + + /** + * Gets timing function of the keyframe. + * + * @since 2.0 + * @return Timing function of the keyframe + */ + const IVisualElementAnimationTimingFunction* GetTimingFunction(void) const; + +private: + _VisualElementAnimationKeyFrameInfo(void); + _VisualElementAnimationKeyFrameInfo& operator= (const _VisualElementAnimationKeyFrameInfo&); + +private: + float __time; + Variant __value; + _VariantEx __valueEx; + const IVisualElementAnimationTimingFunction* __pTimingFunction; +}; // _VisualElementAnimationKeyFrameInfo + +/** + * @class _VisualElementAnimationKeyFrame + * @brief This is the header file for the _VisualElementAnimationKeyFrame class + * @since 2.0 + * + * This header file contains the declarations of the _VisualElementAnimationKeyFrame class. + */ + +class _VisualElementAnimationKeyFrame + : public Tizen::Base::Object +{ +public: + + // + // This is the default constructor for this class. + // + _VisualElementAnimationKeyFrame(void); + + // + // This is the destructor for this class. + // + virtual ~_VisualElementAnimationKeyFrame(void); + + // + // Equals Function. + // + virtual bool Equals(const Tizen::Base::Object& obj) const; + + /** + * Gets the copied instance of the class. + * + * @since 2.0 + * @return The copied instance + */ + _VisualElementAnimationKeyFrame* CloneN(void) const; + + /** + * Gets the count of key frame + * + * @since 2.0 + */ + int GetCount(void) const; + + /** + * Add key frame infomation for animation. + * + * @since 2.0 + * @return An error code + * @param[in] time specific time value. This must be in 0.0~1.0 and can't be 0.0 & 1.0. + * @param[in] value key frame value. + * @param[in] timingFunction timing function instance that is used in keyframe segment. + */ + result AddKeyFrame(float time, const Tizen::Ui::Variant& value, const IVisualElementAnimationTimingFunction* pTimingFunction); + + /** + * Remove key frame infomation for animation. + * + * @since 2.0 + * @return An error code + * @param[in] time specific time value. All information(KeyValue, timingFunction) with time will be removed. + */ + result RemoveKeyFrame(float time); + + /** + * Remove all key frame infomation for animation. + * + * @since 2.0 + * @return An error code + */ + void RemoveAllKeyFrames(void); + + /* + * Get the key frame information at the spectified index. + * + * @since 2.0 + */ + _VisualElementAnimationKeyFrameInfo* GetKeyFrameInfoAt(int index) const; + +private: + _VisualElementAnimationKeyFrame(const _VisualElementAnimationKeyFrame& rhs); + _VisualElementAnimationKeyFrame& operator =(const _VisualElementAnimationKeyFrame& rhs); + + int GetKeyFrameIndex(float time) const; + +private: + Tizen::Base::Collection::ArrayList __keyFrameList; +}; // _VisualElementAnimationKeyFrame + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_KEY_FRAME_H_ + diff --git a/src/ui/animations/FUiAnim_VisualElementAnimationTiming.cpp b/src/ui/animations/FUiAnim_VisualElementAnimationTiming.cpp new file mode 100644 index 0000000..1850cf0 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementAnimationTiming.cpp @@ -0,0 +1,133 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementAnimationTiming.cpp + * @brief This file contains implementation of _VisualElementAnimationTiming class + * + * This file contains implementation _VisualElementAnimationTiming class. + */ + +#include +#include + +#include "FUiAnim_VisualElementAnimationTiming.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +_VisualElementAnimationTiming::_VisualElementAnimationTiming(void) + : __duration(250) + , __offset(0) + , __delay(0) + , __repeatCount(1) + , __scale(1.0f) + , __autoReverse(false) +{ + +} + +_VisualElementAnimationTiming::_VisualElementAnimationTiming(const _VisualElementAnimationTiming& rhs) + : __duration(rhs.__duration) + , __offset(rhs.__offset) + , __delay(rhs.__delay) + , __repeatCount(rhs.__repeatCount) + , __scale(rhs.__scale) + , __autoReverse(rhs.__autoReverse) +{ + +} + +_VisualElementAnimationTiming::~_VisualElementAnimationTiming(void) +{ + +} + +long +_VisualElementAnimationTiming::GetDuration(void) const +{ + return __duration; +} + +void +_VisualElementAnimationTiming::SetDuration(long duration) +{ + __duration = duration; +} + +long +_VisualElementAnimationTiming::GetDelay(void) const +{ + return __delay; +} + +void +_VisualElementAnimationTiming::SetDelay(long delay) +{ + __delay = delay; +} + +long +_VisualElementAnimationTiming::GetOffset(void) const +{ + return __offset; +} + +void +_VisualElementAnimationTiming::SetOffset(long offset) +{ + __offset = offset; +} + +long +_VisualElementAnimationTiming::GetRepeatCount(void) const +{ + return __repeatCount; +} + +void +_VisualElementAnimationTiming::SetRepeatCount(long repeatCount) +{ + __repeatCount = repeatCount; +} + +float +_VisualElementAnimationTiming::GetScaleRatio(void) const +{ + return __scale; +} + +void +_VisualElementAnimationTiming::SetScaleRatio(float scale) +{ + __scale = scale; +} + +bool +_VisualElementAnimationTiming::IsAutoReverseEnabled(void) const +{ + return __autoReverse; +} + +void +_VisualElementAnimationTiming::SetAutoReverseEnabled(bool enable) +{ + __autoReverse = enable; +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_VisualElementAnimationTiming.h b/src/ui/animations/FUiAnim_VisualElementAnimationTiming.h new file mode 100644 index 0000000..e74db36 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementAnimationTiming.h @@ -0,0 +1,180 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementAnimationTiming.h + * @brief This is the header file for the _VisualElementAnimationTiming class. + * + * This header file contains the declarations of the _VisualElementAnimationTiming class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_TIMING_H_ +#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_TIMING_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class _VisualElementAnimationTiming + * @brief This class stores the information of a animation timing. + * @since 2.0 + * + * This class provides animation timing related information. + */ +class _VisualElementAnimationTiming + : public Tizen::Base::Object +{ +public: + + // + // This is the default constructor for this class. + // + _VisualElementAnimationTiming(void); + + // + // This is the destructor for this class. + // + virtual ~_VisualElementAnimationTiming(void); + + /** + * Gets the duration of the animation. + * + * @since 2.0 + * @return The duration of the animation in ms + */ + long GetDuration(void) const; + + /** + * Sets the duration of the animation in ms. + * + * @since 2.0 + * @param[in] duration The duration of the animation in ms + */ + void SetDuration(long duration); + + /** + * Gets the time offset of the animation. + * + * @since 2.0 + * @return The time offset of the animation in ms + */ + long GetOffset(void) const; + + /** + * Sets the time offset of the animation in ms. + * + * @since 2.0 + * @param[in] timeOffset The time offset of the animation in mss + */ + void SetOffset(long offset); + + /** + * Gets the time delay of the animation. + * + * @since 2.0 + * @return The time delay of the animation in ms + */ + long GetDelay(void) const; + + /** + * Sets the time delay of the animation in ms. + * + * @since 2.0 + * @param[in] timeDelay The start time of the animation in ms + */ + void SetDelay(long delay); + + /** + * Gets the repeat count of the animation. + * + * @since 2.0 + * @return The repeat count of the animation + */ + long GetRepeatCount(void) const; + + /** + * Sets the repeat count of the animation. + * + * @since 2.0 + * @param[in] repeatCount The repeat count of the animation + * @remarks If repeatCount is 0, the animation will be repeated infinitely. + */ + void SetRepeatCount(long repeatCount); + + /** + * Gets the time scale value of the animation. + * + * @since 2.0 + * @return The time scale value of the animation + */ + float GetScaleRatio(void) const; + + /** + * Sets the time scale value of the animation. + * + * @since 2.0 + * @param[in] scale The time scale of the animation + * @remarks If this value is 2.0, then the animation speed is 2 times fast. + */ + void SetScaleRatio(float scale); + + /** + * Checks whether the animation plays backwards after it finishes playing forwards. + * + * @since 2.0 + * @return @c true if the animation plays backwards after it finishes playing forwards @n + * @c false, otherwise + */ + bool IsAutoReverseEnabled(void) const; + + /** + * Sets the flag to play backwards after the animation finishes playing forwards. + * + * @since 2.0 + * @param[in] enable Set to @c true to enable auto reverse @n + * @c false, otherwise + */ + void SetAutoReverseEnabled(bool enable); + +private: + /** + * This is the default constructor for this class. + * + * @param[in] rhs A pointer to the Object instance which contains this instance. + */ + _VisualElementAnimationTiming(const _VisualElementAnimationTiming& rhs); + _VisualElementAnimationTiming& operator =(const _VisualElementAnimationTiming& rhs); + +private: + long __duration; + long __offset; + long __delay; + + long __repeatCount; + + float __scale; + + bool __autoReverse; +}; // _VisualElementAnimationTiming + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_TIMING_H_ + diff --git a/src/ui/animations/FUiAnim_VisualElementAnimationVariantInterpolator.cpp b/src/ui/animations/FUiAnim_VisualElementAnimationVariantInterpolator.cpp new file mode 100644 index 0000000..f74398b --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementAnimationVariantInterpolator.cpp @@ -0,0 +1,279 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementAnimationVariantInterpolator.cpp + * @brief This file contains implementation of _VisualElementAnimationVariantInterpolator class + * + * This file contains implementation _VisualElementAnimationVariantInterpolator class. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FUiAnim_VariantEx.h" +#include "FUiAnim_VisualElementAnimationVariantInterpolator.h" + +using namespace Tizen; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Animations +{ + +_VisualElementAnimationVariantInterpolator::_VisualElementAnimationVariantInterpolator(void) +{ +} + +_VisualElementAnimationVariantInterpolator::~_VisualElementAnimationVariantInterpolator(void) +{ +} + + +result +_VisualElementAnimationVariantInterpolator::Interpolate(float progress, const Tizen::Ui::Variant& startValue, const Tizen::Ui::Variant& endValue, Tizen::Ui::Variant& value) const +{ + SysTryReturnResult(NID_UI_ANIM, startValue.GetType() == endValue.GetType(), E_INVALID_ARG, "Invalid argument(s) is used. Variant types are not matched."); + + const _VariantEx* pStartValueEx = dynamic_cast< const _VariantEx* >(&startValue); + const _VariantEx* pEndValueEx = dynamic_cast< const _VariantEx* >(&endValue); + + if (pStartValueEx && pEndValueEx) + { + if (pStartValueEx->IsValidTransformMatrix() && pEndValueEx->IsValidTransformMatrix()) + { + value = pEndValueEx->GetTransformMatrix().Interpolate( + pStartValueEx->GetTransformMatrix(), + progress + ); + return E_SUCCESS; + } + } + + switch (startValue.GetType()) + { + case VARIANT_TYPE_INT: + { + int start = startValue.ToInt(); + int end = endValue.ToInt(); + + value = static_cast< int >(static_cast< float >(start) * (1.0f - progress) + static_cast< float >(end) * progress); + } + break; + + case VARIANT_TYPE_LONG: + { + long start = startValue.ToLong(); + long end = endValue.ToLong(); + + + value = static_cast< long >(static_cast< float >(start) * (1.0f - progress) + static_cast< float >(end) * progress); + } + break; + + case VARIANT_TYPE_LONGLONG: + { + long long start = startValue.ToLongLong(); + long long end = endValue.ToLongLong(); + + value = static_cast< long long >(static_cast< float >(start) * (1.0f - progress) + static_cast< float >(end) * progress); + } + break; + + case VARIANT_TYPE_FLOAT: + { + float start = startValue.ToFloat(); + float end = endValue.ToFloat(); + + value = start * (1.0f - progress) + end * progress; + } + break; + + case VARIANT_TYPE_DOUBLE: + { + double start = startValue.ToDouble(); + double end = endValue.ToDouble(); + + value = static_cast< double >(static_cast< double >(start) * (1.0 - static_cast< double >(progress)) + static_cast< double >(end) * static_cast< double >(progress)); + } + break; + + case VARIANT_TYPE_RECTANGLE: + { + const Tizen::Graphics::Rectangle& start = startValue.ToRectangle(); + const Tizen::Graphics::Rectangle& end = endValue.ToRectangle(); + Tizen::Graphics::Rectangle rect; + + rect.x = static_cast< int >(static_cast< float >(start.x) * (1.0f - progress) + static_cast< float >(end.x) * progress); + rect.y = static_cast< int >(static_cast< float >(start.y) * (1.0f - progress) + static_cast< float >(end.y) * progress); + rect.width = static_cast< int >(static_cast< float >(start.width) * (1.0f - progress) + static_cast< float >(end.width) * progress); + rect.height = static_cast< int >(static_cast< float >(start.height) * (1.0f - progress) + static_cast< float >(end.height) * progress); + + value = rect; + } + break; + + case VARIANT_TYPE_FLOAT_RECTANGLE: + { + const Tizen::Graphics::FloatRectangle& start = startValue.ToFloatRectangle(); + const Tizen::Graphics::FloatRectangle& end = endValue.ToFloatRectangle(); + + float left = start.x * (1.0f - progress) + end.x * progress; + float top = start.y * (1.0f - progress) + end.y * progress; + float width = start.width * (1.0f - progress) + end.width * progress; + float height = start.height * (1.0f - progress) + end.height * progress; + + value = Variant(Tizen::Graphics::FloatRectangle(left, top, width, height)); + } + break; + + case VARIANT_TYPE_POINT: + { + const Tizen::Graphics::Point& start = startValue.ToPoint(); + const Tizen::Graphics::Point& end = endValue.ToPoint(); + Tizen::Graphics::Point point; + + point.x = static_cast< int >(static_cast< float >(start.x) * (1.0f - progress) + static_cast< float >(end.x) * progress); + point.y = static_cast< int >(static_cast< float >(start.y) * (1.0f - progress) + static_cast< float >(end.y) * progress); + + value = point; + } + break; + + case VARIANT_TYPE_FLOAT_POINT: + { + const Tizen::Graphics::FloatPoint& start = startValue.ToFloatPoint(); + const Tizen::Graphics::FloatPoint& end = endValue.ToFloatPoint(); + + float x = start.x * (1.0f - progress) + end.x * progress; + float y = start.y * (1.0f - progress) + end.y * progress; + + value = Variant(Tizen::Graphics::FloatPoint(x, y)); + } + break; + + case VARIANT_TYPE_DIMENSION: + { + const Tizen::Graphics::Dimension& start = startValue.ToDimension(); + const Tizen::Graphics::Dimension& end = endValue.ToDimension(); + Tizen::Graphics::Dimension size; + + size.width = static_cast< int >(static_cast< float >(start.width) * (1.0f - progress) + static_cast< float >(end.width) * progress); + size.height = static_cast< int >(static_cast< float >(start.height) * (1.0f - progress) + static_cast< float >(end.height) * progress); + + value = size; + } + break; + + case VARIANT_TYPE_FLOAT_DIMENSION: + { + const Tizen::Graphics::FloatDimension& start = startValue.ToFloatDimension(); + const Tizen::Graphics::FloatDimension& end = endValue.ToFloatDimension(); + Tizen::Graphics::FloatDimension size; + + size.width = start.width * (1.0f - progress) + end.width * progress; + size.height = start.height * (1.0f - progress) + end.height * progress; + + value = size; + } + break; + + case VARIANT_TYPE_COLOR: + { + const Tizen::Graphics::Color& start = startValue.ToColor(); + const Tizen::Graphics::Color& end = endValue.ToColor(); + + byte r = static_cast< byte >(static_cast< float >(start.GetRed()) * (1.0f - progress) + static_cast< float >(end.GetRed()) * progress); + byte g = static_cast< byte >(static_cast< float >(start.GetGreen()) * (1.0f - progress) + static_cast< float >(end.GetGreen()) * progress); + byte b = static_cast< byte >(static_cast< float >(start.GetBlue()) * (1.0f - progress) + static_cast< float >(end.GetBlue()) * progress); + byte a = static_cast< byte >(static_cast< float >(start.GetAlpha()) * (1.0f - progress) + static_cast< float >(end.GetAlpha()) * progress); + + value = Variant(Tizen::Graphics::Color(r, g, b, a)); + } + break; + +#if 0 + case VARIANT_TYPE_COLORF: + { + const _Colorf& startValue = start.ToColorf(); + const _Colorf& endValue = end.ToColorf(); + + float r = startValue.Red() * (1.0f - progress) + endValue.Red() * progress; + float g = startValue.Green() * (1.0f - progress) + endValue.Green() * progress; + float b = startValue.Blue() * (1.0f - progress) + endValue.Blue() * progress; + float a = startValue.Alpha() * (1.0f - progress) + endValue.Alpha() * progress; + + value = Variant(_Colorf(r, g, b, a)); + } + break; +#endif + + case VARIANT_TYPE_FLOAT_MATRIX4: + { + const Tizen::Graphics::FloatMatrix4& start = startValue.ToFloatMatrix4(); + const Tizen::Graphics::FloatMatrix4& end = endValue.ToFloatMatrix4(); + float m[4][4] = {{0.0f}, }; + + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 4; j++) + { +// m[j][i] = start(i, j) * (1.0f - progress) + end(i, j) * progress; + m[j][i] = start.matrix[j][i] * (1.0f - progress) + end.matrix[j][i] * progress; + } + } + + value = Variant(Tizen::Graphics::FloatMatrix4(m)); + } + break; + + case VARIANT_TYPE_BOOL: + { + bool start = startValue.ToBool(); + bool end = endValue.ToBool(); + + if (progress > 0.0f) + { + value = end; + } + else + { + value = start; + } + } + break; + + case VARIANT_TYPE_NONE: + case VARIANT_TYPE_STRING: + default: + SysLogException(NID_UI_ANIM, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Variant type is invalid."); + return E_INVALID_ARG; + } + + return E_SUCCESS; +} + +}}} //Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_VisualElementAnimationVariantInterpolator.h b/src/ui/animations/FUiAnim_VisualElementAnimationVariantInterpolator.h new file mode 100644 index 0000000..62c1acd --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementAnimationVariantInterpolator.h @@ -0,0 +1,56 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementAnimationVariantInterpolator.h + * @brief This is the header file for the _VisualElementAnimationVariantInterpolator class. + * + * This header file contains the declarations of the _VisualElementAnimationVariantInterpolator class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_VARIANT_INTERPOLATOR_H_ +#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_VARIANT_INTERPOLATOR_H_ + +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ + +/** + * @class _VisualElementAnimationVariantInterpolator + * @brief This class stores the information of an interpolator of varitant type. + * @since 2.0 + * + * This class provides varitant type interpolator related information. + */ +class _VisualElementAnimationVariantInterpolator + : public Tizen::Base::Object + , public IVisualElementAnimationValueInterpolator +{ +public: + _VisualElementAnimationVariantInterpolator(void); + virtual ~_VisualElementAnimationVariantInterpolator(void); + +public: + virtual result Interpolate(float progress, const Tizen::Ui::Variant& startValue, const Tizen::Ui::Variant& endValue, Tizen::Ui::Variant& value) const; +}; // _VisualElementAnimationVariantInterpolator + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_ANIMATION_VARIANT_INTERPOLATOR_H_ diff --git a/src/ui/animations/FUiAnim_VisualElementCanvas.cpp b/src/ui/animations/FUiAnim_VisualElementCanvas.cpp new file mode 100644 index 0000000..f219c2b --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementCanvas.cpp @@ -0,0 +1,97 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementCanvas.cpp + * @brief This file contains implementation of _VisualElementCanvas class + * + * This file contains implementation _VisualElementCanvas class. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "FUi_CoordinateSystemUtils.h" +#include "FUiAnim_VisualElementCanvas.h" +#include "FUiAnim_VisualElementSurfaceImpl.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +// TBD: from WinCanvas...... new class really needed??? +//class _VisualElementCanvas : +// public Tizen::Ui::__WinCanvas +//{ +//}; + +_VisualElementCanvas::_VisualElementCanvas(void) +{ +} + +_VisualElementCanvas::~_VisualElementCanvas(void) +{ +} + +// TODO: +// need to convert rectangle into physical coordinates internally... +// +result +_VisualElementCanvas::Construct(const VisualElementSurface& surface, const Tizen::Graphics::Rectangle& rectangle) +{ + ClearLastResult(); + result r = E_SUCCESS; + + Tizen::Graphics::_CanvasImpl* pCanvasImpl = Tizen::Graphics::_CanvasImpl::GetInstance(*this); + Tizen::Graphics::_Canvas* pNativeCanvas = (pCanvasImpl) ? pCanvasImpl->_pNativeCanvas : 0; + + SysTryReturnResult(NID_UI, pCanvasImpl && pNativeCanvas, E_OUT_OF_MEMORY, "Memory allocation failed."); + SysTryReturnResult(NID_UI, _VisualElementSurfaceImpl::GetInstance(surface), E_SYSTEM, "A system error has been occurred. Invalid surface."); + + Handle window = _VisualElementSurfaceImpl::GetInstance(surface)->GetNativeHandle(); + r = pNativeCanvas->Construct(window, _CoordinateSystemUtils::Transform(rectangle)); + SysTryReturnResult(NID_UI, r == E_SUCCESS, r, "Failed to construct Canvas with the size (%d:%d).", rectangle.width, rectangle.height); + + pNativeCanvas->__windowHandle = static_cast< Handle >(window); + + Tizen::Graphics::Rectangle realBounds = pNativeCanvas->GetBounds(); + + Tizen::Graphics::Dimension adoptedSize; + + Tizen::Graphics::Dimension revisedSize = _CoordinateSystemUtils::InverseTransform(Tizen::Graphics::Dimension(realBounds.width, realBounds.height)); + Tizen::Graphics::Rectangle physicalGivenBounds = _CoordinateSystemUtils::Transform(rectangle); + + adoptedSize.width = (physicalGivenBounds.width == realBounds.width) ? rectangle.width : revisedSize.width; + adoptedSize.height = (physicalGivenBounds.height == realBounds.height) ? rectangle.height : revisedSize.height; + + Tizen::Graphics::Rectangle revisedBounds(rectangle.x, rectangle.y, adoptedSize.width, adoptedSize.height); + + if (pCanvasImpl->_pCoordHolder) + { + pCanvasImpl->_pCoordHolder->Init(revisedBounds); + } + + return r; +} + + +}}} diff --git a/src/ui/animations/FUiAnim_VisualElementCoordinateSystem.cpp b/src/ui/animations/FUiAnim_VisualElementCoordinateSystem.cpp new file mode 100644 index 0000000..a190faf --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementCoordinateSystem.cpp @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementCoordinateSystem.cpp + * @brief This file contains implementation of _VisualElementCoordinateSystem class + * + * This file contains implementation _VisualElementCoordinateSystem class. + */ + +#include +#include +#include +#include + +#include "FUi_CoordinateSystemUtils.h" +#include "FUiAnim_VisualElementCoordinateSystem.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +float _VisualElementCoordinateSystem::scaleFactorX = 1.0f; +float _VisualElementCoordinateSystem::scaleFactorY = 1.0f; +int _VisualElementCoordinateSystem::logScreenWidth = 0; +int _VisualElementCoordinateSystem::logScreenHeight = 0; +bool _VisualElementCoordinateSystem::needScale = false; + +void +_VisualElementCoordinateSystem::Initialize(void) +{ + needScale = false; + + // Initialize auto-scale factors + Tizen::Graphics::_CoordinateSystem* pCoordSys = Tizen::Graphics::_CoordinateSystem::GetInstance(); + + if (pCoordSys->IsTransformEnabled() == true) + { + scaleFactorX = pCoordSys->GetTransformer()->GetHorizontalScaleFactor(); + scaleFactorY = pCoordSys->GetTransformer()->GetVerticalScaleFactor(); + + // WARNING: + // 1. The values 'scaleFactorX' and 'scaleFactorY' may be greater than expected 'cause of float-error. + // So, it is needed to cut-off some significant digits to ensure the scale factors are always less or equal than real values. + // The cut-off position should be lower than the compensation value(> 10^3 due to rounding), too. + // 2. The number fo siginificant digits for float is about 6 (5 for sure). + // So, the scaleFactor to cut-off should be less or equal than 10^6. + + const float scaleFactor = 1000.0f / floatIntegralEpsilon; + //SysAssert(scaleFactor <= 1000000.0f); + + scaleFactorX = floorf(scaleFactorX * scaleFactor) / scaleFactor; + scaleFactorY = floorf(scaleFactorY * scaleFactor) / scaleFactor; + + needScale = true; + } + + int physScreenWidth = Tizen::Graphics::_Screen::GetWidth(); + int physScreenHeight = Tizen::Graphics::_Screen::GetHeight(); + float sWidth = static_cast< float >(physScreenWidth); + float sHeight = static_cast< float >(physScreenHeight); + + ConvertDimensionToLogicalIntegral(sWidth, sHeight); + logScreenWidth = static_cast< int >(sWidth); + logScreenHeight = static_cast< int >(sHeight); + + ConvertDimensionToPhysicalIntegral(sWidth, sHeight); + + SysAssert(static_cast< int >(sWidth) <= physScreenWidth); + SysAssert(static_cast< int >(sHeight) <= physScreenHeight); +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_VisualElementEnvironment.cpp b/src/ui/animations/FUiAnim_VisualElementEnvironment.cpp new file mode 100644 index 0000000..43e0acf --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementEnvironment.cpp @@ -0,0 +1,376 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementEnvironment.cpp + * @brief This file contains implementation of _VisualElementEnvironment class + * + * This file contains implementation _VisualElementEnvironment class. + */ +#include +#include +#include + + +#include "FUiAnim_VisualElementCoordinateSystem.h" +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_VisualElementEnvironment.h" + + +using namespace Tizen::Base; + + +namespace Tizen { namespace Ui { namespace Animations +{ + + + + +const wchar_t* VePropBounds = L"bounds"; +const wchar_t* VePropContentBounds = L"contentBounds"; +const wchar_t* VePropContentOpacity = L"contentOpacity"; +const wchar_t* VePropRenderOperation = L"renderOperation"; +const wchar_t* VePropOpacity = L"opacity"; +const wchar_t* VePropShowState = L"showState"; +const wchar_t* VePropAnchor = L"anchor"; +const wchar_t* VePropAnchorZ = L"anchorZ"; +const wchar_t* VePropTransform = L"transform"; +const wchar_t* VePropChildrenTransform = L"childrenTransform"; +const wchar_t* VePropZPosition = L"zPosition"; +const wchar_t* VePropZOrderGroup = L"zOrderGroup"; +const wchar_t* VePropClipToParent = L"clipToParent"; +const wchar_t* VePropClipChildren = L"clipChildren"; +const wchar_t* VePropSurfaceOpaque = L"surfaceOpaque"; +const wchar_t* VePropName = L"name"; +const wchar_t* VePropPropertyPropagationEnabled = L"propertyPropagation"; +const wchar_t* VePropImplicitAnimationEnabled = L"implicitAnimation"; + +#if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION) +const wchar_t* VePropActionDetach = L"detach"; +const wchar_t* VePropActionAttach = L"attach"; +#endif +const wchar_t* VeSubPropBounds = L"bounds."; +const wchar_t* VeSubPropBoundsPosition = L"bounds.position"; +const wchar_t* VeSubPropBoundsSize = L"bounds.size"; + +const wchar_t* VeSubPropTransform = L"transform."; +const wchar_t* VeSubPropTransformRotationX = L"transform.rotation.x"; +const wchar_t* VeSubPropTransformRotationY = L"transform.rotation.y"; +const wchar_t* VeSubPropTransformRotationZ = L"transform.rotation.z"; +const wchar_t* VeSubPropTransformScaleX = L"transform.scale.x"; +const wchar_t* VeSubPropTransformScaleY = L"transform.scale.y"; +const wchar_t* VeSubPropTransformScaleZ = L"transform.scale.z"; +const wchar_t* VeSubPropTransformTranslationX = L"transform.translation.x"; +const wchar_t* VeSubPropTransformTranslationY = L"transform.translation.y"; +const wchar_t* VeSubPropTransformTranslationZ = L"transform.translation.z"; +const wchar_t* VeSubPropTransformRotationAnchorX = L"transform.rotation.anchor.x"; +const wchar_t* VeSubPropTransformRotationAnchorY = L"transform.rotation.anchor.y"; +const wchar_t* VeSubPropTransformRotationAnchorZ = L"transform.rotation.anchor.z"; +const wchar_t* VeSubPropTransformScaleAnchorX = L"transform.scale.anchor.x"; +const wchar_t* VeSubPropTransformScaleAnchorY = L"transform.scale.anchor.y"; +const wchar_t* VeSubPropTransformScaleAnchorZ = L"transform.scale.anchor.z"; + +const wchar_t* VeSubPropTransformRotationXY = L"transform.rotation.xy"; +const wchar_t* VeSubPropTransformScaleXY = L"transform.scale.xy"; +const wchar_t* VeSubPropTransformTranslationXY = L"transform.translation.xy"; +const wchar_t* VeSubPropTransformRotationAnchorXY = L"transform.rotation.anchor.xy"; +const wchar_t* VeSubPropTransformScaleAnchorXY = L"transform.scale.anchor.xy"; + + +const wchar_t* VeSubPropChildrenTransform = L"childrenTransform."; +const wchar_t* VeSubPropChildrenTransformRotationX = L"childrenTransform.rotation.x"; +const wchar_t* VeSubPropChildrenTransformRotationY = L"childrenTransform.rotation.y"; +const wchar_t* VeSubPropChildrenTransformRotationZ = L"childrenTransform.rotation.z"; +const wchar_t* VeSubPropChildrenTransformScaleX = L"childrenTransform.scale.x"; +const wchar_t* VeSubPropChildrenTransformScaleY = L"childrenTransform.scale.y"; +const wchar_t* VeSubPropChildrenTransformScaleZ = L"childrenTransform.scale.z"; +const wchar_t* VeSubPropChildrenTransformTranslationX = L"childrenTransform.translation.x"; +const wchar_t* VeSubPropChildrenTransformTranslationY = L"childrenTransform.translation.y"; +const wchar_t* VeSubPropChildrenTransformTranslationZ = L"childrenTransform.translation.z"; +const wchar_t* VeSubPropChildrenTransformRotationAnchorX = L"childrenTransform.rotation.anchor.x"; +const wchar_t* VeSubPropChildrenTransformRotationAnchorY = L"childrenTransform.rotation.anchor.y"; +const wchar_t* VeSubPropChildrenTransformRotationAnchorZ = L"childrenTransform.rotation.anchor.z"; +const wchar_t* VeSubPropChildrenTransformScaleAnchorX = L"childrenTransform.scale.anchor.x"; +const wchar_t* VeSubPropChildrenTransformScaleAnchorY = L"childrenTransform.scale.anchor.y"; +const wchar_t* VeSubPropChildrenTransformScaleAnchorZ = L"childrenTransform.scale.anchor.z"; + +const wchar_t* VeSubPropChildrenTransformRotationXY = L"childrenTransform.rotation.xy"; +const wchar_t* VeSubPropChildrenTransformScaleXY = L"childrenTransform.scale.xy"; +const wchar_t* VeSubPropChildrenTransformTranslationXY = L"childrenTransform.translation.xy"; +const wchar_t* VeSubPropChildrenTransformRotationAnchorXY = L"childrenTransform.rotation.anchor.xy"; +const wchar_t* VeSubPropChildrenTransformScaleAnchorXY = L"childrenTransform.scale.anchor.xy"; + +const wchar_t* VePrivPropShowOpacity = L"__showOpacity"; + +String* pVePropBounds = null; +String* pVePropContentBounds = null; +String* pVePropContentOpacity = null; +String* pVePropRenderOperation = null; +String* pVePropOpacity = null; +String* pVePropShowState = null; +String* pVePropAnchor = null; +String* pVePropAnchorZ = null; +String* pVePropTransform = null; +String* pVePropChildrenTransform = null; +String* pVePropZPosition = null; +String* pVePropZOrderGroup = null; +String* pVePropClipToParent = null; +String* pVePropClipChildren = null; +String* pVePropSurfaceOpaque = null; +String* pVePropName = null; +String* pVePropPropertyPropagationEnabled = null; +String* pVePropImplicitAnimationEnabled = null; + +#if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION) +String* pVePropActionDetach = null; +String* pVePropActionAttach = null; +#endif +String* pVeSubPropBounds = null; +String* pVeSubPropBoundsPosition = null; +String* pVeSubPropBoundsSize = null; + +String* pVeSubPropTransform = null; +String* pVeSubPropTransformRotationX = null; +String* pVeSubPropTransformRotationY = null; +String* pVeSubPropTransformRotationZ = null; +String* pVeSubPropTransformScaleX = null; +String* pVeSubPropTransformScaleY = null; +String* pVeSubPropTransformScaleZ = null; +String* pVeSubPropTransformTranslationX = null; +String* pVeSubPropTransformTranslationY = null; +String* pVeSubPropTransformTranslationZ = null; +String* pVeSubPropTransformRotationAnchorX = null; +String* pVeSubPropTransformRotationAnchorY = null; +String* pVeSubPropTransformRotationAnchorZ = null; +String* pVeSubPropTransformScaleAnchorX = null; +String* pVeSubPropTransformScaleAnchorY = null; +String* pVeSubPropTransformScaleAnchorZ = null; + +String* pVeSubPropTransformRotationXY = null; +String* pVeSubPropTransformScaleXY = null; +String* pVeSubPropTransformTranslationXY = null; +String* pVeSubPropTransformRotationAnchorXY = null; +String* pVeSubPropTransformScaleAnchorXY = null; + + +String* pVeSubPropChildrenTransform = null; +String* pVeSubPropChildrenTransformRotationX = null; +String* pVeSubPropChildrenTransformRotationY = null; +String* pVeSubPropChildrenTransformRotationZ = null; +String* pVeSubPropChildrenTransformScaleX = null; +String* pVeSubPropChildrenTransformScaleY = null; +String* pVeSubPropChildrenTransformScaleZ = null; +String* pVeSubPropChildrenTransformTranslationX = null; +String* pVeSubPropChildrenTransformTranslationY = null; +String* pVeSubPropChildrenTransformTranslationZ = null; +String* pVeSubPropChildrenTransformRotationAnchorX = null; +String* pVeSubPropChildrenTransformRotationAnchorY = null; +String* pVeSubPropChildrenTransformRotationAnchorZ = null; +String* pVeSubPropChildrenTransformScaleAnchorX = null; +String* pVeSubPropChildrenTransformScaleAnchorY = null; +String* pVeSubPropChildrenTransformScaleAnchorZ = null; + +String* pVeSubPropChildrenTransformRotationXY = null; +String* pVeSubPropChildrenTransformScaleXY = null; +String* pVeSubPropChildrenTransformTranslationXY = null; +String* pVeSubPropChildrenTransformRotationAnchorXY = null; +String* pVeSubPropChildrenTransformScaleAnchorXY = null; + +String* pVePrivPropShowOpacity = null; + +_VisualElementEnvironment* _VisualElementEnvironment::__pInstance= NULL; + +_VisualElementEnvironment::_VisualElementEnvironment(void) +{ + +} +void +_VisualElementEnvironment::Initialize(void) +{ + if(!_VisualElementEnvironment::__pInstance) + { + static _VisualElementEnvironment instance; + _VisualElementEnvironment::__pInstance = &instance; + _VisualElementEnvironment::__pInstance->InitializeEnvironment(); + } +} + +void +_VisualElementEnvironment::InitializeEnvironment(void) +{ + pVePropBounds = new (std::nothrow) String(VePropBounds); + pVePropContentBounds = new (std::nothrow) String(VePropContentBounds); + pVePropContentOpacity = new (std::nothrow) String(VePropContentOpacity); + pVePropRenderOperation = new (std::nothrow) String(VePropRenderOperation); + pVePropOpacity = new (std::nothrow) String(VePropOpacity); + pVePropShowState = new (std::nothrow) String(VePropShowState); + pVePropAnchor = new (std::nothrow) String(VePropAnchor); + pVePropAnchorZ = new (std::nothrow) String(VePropAnchorZ); + pVePropTransform = new (std::nothrow) String(VePropTransform); + pVePropChildrenTransform = new (std::nothrow) String(VePropChildrenTransform); + pVePropZPosition = new (std::nothrow) String(VePropZPosition); + pVePropZOrderGroup = new (std::nothrow) String(VePropZOrderGroup); + pVePropClipToParent = new (std::nothrow) String(VePropClipToParent); + pVePropClipChildren = new (std::nothrow) String(VePropClipChildren); + pVePropSurfaceOpaque = new (std::nothrow) String(VePropSurfaceOpaque); + pVePropName = new (std::nothrow) String(VePropName); + pVePropPropertyPropagationEnabled = new (std::nothrow) String(VePropPropertyPropagationEnabled); + pVePropImplicitAnimationEnabled = new (std::nothrow) String(VePropImplicitAnimationEnabled); +#if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION) + pVePropActionDetach = new (std::nothrow) String(VePropActionDetach); + pVePropActionAttach = new (std::nothrow) String(VePropActionAttach); +#endif + pVeSubPropBounds = new (std::nothrow) String(VeSubPropBounds); + pVeSubPropBoundsPosition = new (std::nothrow) String(VeSubPropBoundsPosition); + pVeSubPropBoundsSize = new (std::nothrow) String(VeSubPropBoundsSize); + + pVeSubPropTransform = new (std::nothrow) String(VeSubPropTransform); + pVeSubPropTransformRotationX = new (std::nothrow) String(VeSubPropTransformRotationX); + pVeSubPropTransformRotationY = new (std::nothrow) String(VeSubPropTransformRotationY); + pVeSubPropTransformRotationZ = new (std::nothrow) String(VeSubPropTransformRotationZ); + pVeSubPropTransformScaleX = new (std::nothrow) String(VeSubPropTransformScaleX); + pVeSubPropTransformScaleY = new (std::nothrow) String(VeSubPropTransformScaleY); + pVeSubPropTransformScaleZ = new (std::nothrow) String(VeSubPropTransformScaleZ); + pVeSubPropTransformTranslationX = new (std::nothrow) String(VeSubPropTransformTranslationX); + pVeSubPropTransformTranslationY = new (std::nothrow) String(VeSubPropTransformTranslationY); + pVeSubPropTransformTranslationZ = new (std::nothrow) String(VeSubPropTransformTranslationZ); + pVeSubPropTransformRotationAnchorX = new (std::nothrow) String(VeSubPropTransformRotationAnchorX); + pVeSubPropTransformRotationAnchorY = new (std::nothrow) String(VeSubPropTransformRotationAnchorY); + pVeSubPropTransformRotationAnchorZ = new (std::nothrow) String(VeSubPropTransformRotationAnchorZ); + pVeSubPropTransformScaleAnchorX = new (std::nothrow) String(VeSubPropTransformScaleAnchorX); + pVeSubPropTransformScaleAnchorY = new (std::nothrow) String(VeSubPropTransformScaleAnchorY); + pVeSubPropTransformScaleAnchorZ = new (std::nothrow) String(VeSubPropTransformScaleAnchorZ); + + pVeSubPropTransformRotationXY = new (std::nothrow) String(VeSubPropTransformRotationXY); + pVeSubPropTransformScaleXY = new (std::nothrow) String(VeSubPropTransformScaleXY); + pVeSubPropTransformTranslationXY = new (std::nothrow) String(VeSubPropTransformTranslationXY); + pVeSubPropTransformRotationAnchorXY = new (std::nothrow) String(VeSubPropTransformRotationAnchorXY); + pVeSubPropTransformScaleAnchorXY = new (std::nothrow) String(VeSubPropTransformScaleAnchorXY); + + + pVeSubPropChildrenTransform = new (std::nothrow) String(VeSubPropChildrenTransform); + pVeSubPropChildrenTransformRotationX = new (std::nothrow) String(VeSubPropChildrenTransformRotationX); + pVeSubPropChildrenTransformRotationY = new (std::nothrow) String(VeSubPropChildrenTransformRotationY); + pVeSubPropChildrenTransformRotationZ = new (std::nothrow) String(VeSubPropChildrenTransformRotationZ); + pVeSubPropChildrenTransformScaleX = new (std::nothrow) String(VeSubPropChildrenTransformScaleX); + pVeSubPropChildrenTransformScaleY = new (std::nothrow) String(VeSubPropChildrenTransformScaleY); + pVeSubPropChildrenTransformScaleZ = new (std::nothrow) String(VeSubPropChildrenTransformScaleZ); + pVeSubPropChildrenTransformTranslationX = new (std::nothrow) String(VeSubPropChildrenTransformTranslationX); + pVeSubPropChildrenTransformTranslationY = new (std::nothrow) String(VeSubPropChildrenTransformTranslationY); + pVeSubPropChildrenTransformTranslationZ = new (std::nothrow) String(VeSubPropChildrenTransformTranslationZ); + pVeSubPropChildrenTransformRotationAnchorX = new (std::nothrow) String(VeSubPropChildrenTransformRotationAnchorX); + pVeSubPropChildrenTransformRotationAnchorY = new (std::nothrow) String(VeSubPropChildrenTransformRotationAnchorY); + pVeSubPropChildrenTransformRotationAnchorZ = new (std::nothrow) String(VeSubPropChildrenTransformRotationAnchorZ); + pVeSubPropChildrenTransformScaleAnchorX = new (std::nothrow) String(VeSubPropChildrenTransformScaleAnchorX); + pVeSubPropChildrenTransformScaleAnchorY = new (std::nothrow) String(VeSubPropChildrenTransformScaleAnchorY); + pVeSubPropChildrenTransformScaleAnchorZ = new (std::nothrow) String(VeSubPropChildrenTransformScaleAnchorZ); + + pVeSubPropChildrenTransformRotationXY = new (std::nothrow) String(VeSubPropChildrenTransformRotationXY); + pVeSubPropChildrenTransformScaleXY = new (std::nothrow) String(VeSubPropChildrenTransformScaleXY); + pVeSubPropChildrenTransformTranslationXY = new (std::nothrow) String(VeSubPropChildrenTransformTranslationXY); + pVeSubPropChildrenTransformRotationAnchorXY = new (std::nothrow) String(VeSubPropChildrenTransformRotationAnchorXY); + pVeSubPropChildrenTransformScaleAnchorXY = new (std::nothrow) String(VeSubPropChildrenTransformScaleAnchorXY); + + pVePrivPropShowOpacity = new (std::nothrow) String(VePrivPropShowOpacity); + + + _VisualElementCoordinateSystem::Initialize(); +} + + + + +_VisualElementEnvironment::~_VisualElementEnvironment(void) +{ + delete pVePropBounds; + delete pVePropContentBounds; + delete pVePropContentOpacity; + delete pVePropRenderOperation; + delete pVePropOpacity; + delete pVePropShowState; + delete pVePropAnchor; + delete pVePropAnchorZ; + delete pVePropTransform; + delete pVePropChildrenTransform; + delete pVePropZPosition; + delete pVePropZOrderGroup; + delete pVePropClipToParent; + delete pVePropClipChildren; + delete pVePropSurfaceOpaque; + delete pVePropName; + delete pVePropPropertyPropagationEnabled; + delete pVePropImplicitAnimationEnabled; + +#if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION) + delete pVePropActionDetach; + delete pVePropActionAttach; +#endif + + delete pVeSubPropBounds; + delete pVeSubPropBoundsPosition; + delete pVeSubPropBoundsSize; + + delete pVeSubPropTransform; + delete pVeSubPropTransformRotationX; + delete pVeSubPropTransformRotationY; + delete pVeSubPropTransformRotationZ; + delete pVeSubPropTransformScaleX; + delete pVeSubPropTransformScaleY; + delete pVeSubPropTransformScaleZ; + delete pVeSubPropTransformTranslationX; + delete pVeSubPropTransformTranslationY; + delete pVeSubPropTransformTranslationZ; + delete pVeSubPropTransformRotationAnchorX; + delete pVeSubPropTransformRotationAnchorY; + delete pVeSubPropTransformRotationAnchorZ; + delete pVeSubPropTransformScaleAnchorX; + delete pVeSubPropTransformScaleAnchorY; + delete pVeSubPropTransformScaleAnchorZ; + + delete pVeSubPropTransformRotationXY; + delete pVeSubPropTransformScaleXY; + delete pVeSubPropTransformTranslationXY; + delete pVeSubPropTransformRotationAnchorXY; + delete pVeSubPropTransformScaleAnchorXY; + + delete pVeSubPropChildrenTransform; + delete pVeSubPropChildrenTransformRotationX; + delete pVeSubPropChildrenTransformRotationY; + delete pVeSubPropChildrenTransformRotationZ; + delete pVeSubPropChildrenTransformScaleX; + delete pVeSubPropChildrenTransformScaleY; + delete pVeSubPropChildrenTransformScaleZ; + delete pVeSubPropChildrenTransformTranslationX; + delete pVeSubPropChildrenTransformTranslationY; + delete pVeSubPropChildrenTransformTranslationZ; + delete pVeSubPropChildrenTransformRotationAnchorX; + delete pVeSubPropChildrenTransformRotationAnchorY; + delete pVeSubPropChildrenTransformRotationAnchorZ; + delete pVeSubPropChildrenTransformScaleAnchorX; + delete pVeSubPropChildrenTransformScaleAnchorY; + delete pVeSubPropChildrenTransformScaleAnchorZ; + + delete pVeSubPropChildrenTransformRotationXY; + delete pVeSubPropChildrenTransformScaleXY; + delete pVeSubPropChildrenTransformTranslationXY; + delete pVeSubPropChildrenTransformRotationAnchorXY; + delete pVeSubPropChildrenTransformScaleAnchorXY; + + delete pVePrivPropShowOpacity; +} + +}}} //namespace Tizen { namespace Ui { namespace Animations diff --git a/src/ui/animations/FUiAnim_VisualElementEnvironment.h b/src/ui/animations/FUiAnim_VisualElementEnvironment.h new file mode 100644 index 0000000..7fa89c2 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementEnvironment.h @@ -0,0 +1,48 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementEnvironment.h + * @brief This is the header file for the _VisualElementEnvironment class. + * + * This header file contains the declarations of the _VisualElementEnvironment class. + */ + +#ifndef FUIANIM_VISUAL_ELEMENT_ENVIRONMENT_H_ +#define FUIANIM_VISUAL_ELEMENT_ENVIRONMENT_H_ + +namespace Tizen { namespace Ui { namespace Animations +{ + + +class _VisualElementEnvironment +{ +private: + _VisualElementEnvironment(void); + ~_VisualElementEnvironment(void); + +public: + static void Initialize(void); + +private: + void InitializeEnvironment(void); +private: + static _VisualElementEnvironment* __pInstance; +}; + +}}} //namespace Tizen { namespace Ui { namespace Animations +#endif /* FUIANIM_VISUAL_ELEMENT_ENVIRONMENT_H_ */ diff --git a/src/ui/animations/FUiAnim_VisualElementImpl.cpp b/src/ui/animations/FUiAnim_VisualElementImpl.cpp new file mode 100644 index 0000000..570b969 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementImpl.cpp @@ -0,0 +1,7114 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementImpl.cpp + * @brief This file contains implementation of _VisualElementImpl class + * + * This file contains implementation _VisualElementImpl class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "FUi_Rectanglef.h" +#include "FUi_CoordinateSystemUtils.h" + +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_VisualElementCanvas.h" + +#include "FUiAnim_VisualElementAnimationImpl.h" +#include "FUiAnim_VisualElementAnimationGroupImpl.h" +#include "FUiAnim_VisualElementValueAnimationImpl.h" +#include "FUiAnim_VisualElementPropertyAnimationImpl.h" +#include "FUiAnim_AnimationManager.h" +#include "FUiAnim_VisualElementSharedData.h" +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_ControlVisualElement.h" +#include "FUiAnim_MatrixUtil.h" +#include "FUiAnim_Debug.h" +#include "FUiAnim_EflNode.h" +#include "FUiAnim_VisualElementSurfaceImpl.h" +#include "FUiAnim_EflVisualElementSurfaceImpl.h" +#include "FUiAnim_DisplayManager.h" + + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +#define LAZY_EVALUATION // lazy updating and reconfiguring. +#define IMPLICIT_ANIMATION_IMPL //prototyping implicit animation. +//#define MANUAL_PROPERTY_CHANGE_NOTIFICATION + +#define IS_INTERNAL_CLASS(_PUBLIC) (likely(typeid(*(_PUBLIC)) == VeTypeId) || likely(typeid(*(_PUBLIC)) == internalVeTypeId) || likely(typeid(*(_PUBLIC)) == controlVeTypeId) || likely(typeid(*(_PUBLIC)) == rootVeTypeId)) +#define IS_NEEDED_UPDATE_PRESENTATION(__MODEL) (((__MODEL)->__isPropertyPropagationEnabled) && ((__MODEL)->__pPresentation)) +namespace { + +static const char* STR_ERROR_INVALID_VARIANT_ARG_TYPE = "[E_INVALID_ARG] Invalid argument(s) is used. Variant type is invalid."; + +void +CalculateBoundingBox(const float x[4], const float y[4], Tizen::Graphics::FloatRectangle& rectangle) +{ + float minX = x[0]; + float minY = y[0]; + float maxX = minX; + float maxY = minY; + for (int i = 1; i < 4; i++) + { + if (x[i] < minX) + minX = x[i]; + + if (y[i] < minY) + minY = y[i]; + + if (x[i] > maxX) + maxX = x[i]; + + if (y[i] > maxY) + maxY = y[i]; + } + + rectangle.x = minX; + rectangle.y = minY; + rectangle.width = maxX - minX; + rectangle.height = maxY - minY; +} + + +} + +namespace Tizen { namespace Ui { namespace Animations +{ +// rules of visual element. +// +// 1. almost controlling pSharedData occurred in the PRESENTATION layer. +// 2. almost Delegate's methods occurred in the MODEL layer. +// + +#define SHOWOPACITY_VISIBLE(so) \ + (so != 0.0f) + +#define VE_VISIBLE(o) \ + SHOWOPACITY_VISIBLE((o)->__showOpacity) + +#define HAVE_SURFACE(o) \ + (likely((o)->GetSharedData().pSurface)) + +//TODO: require further examination : __NeedSurface() instead of NEED_SURFACE() macro +#define NEED_SURFACE(o) \ + (likely((o)->GetSharedData().needSurface)) + +#define IS_ATTACHED(o) \ + ((o)->GetRoot() != null) + +#define IS_PRESENTATION(o) \ + ((o)->__pPresentation == (o)) + +#define IS_MODEL(o) \ + ((o)->__pModel == (o)) + +#define VE_DELEGATE(target, func, ...) \ + (target)->func(__VA_ARGS__) + + + +static const std::type_info& VeTypeId = typeid(VisualElement); +static const std::type_info& rootVeTypeId = typeid(_RootVisualElement); +static const std::type_info& internalVeTypeId = typeid(_VisualElement); +static const std::type_info& controlVeTypeId = typeid(_ControlVisualElement); + +// declared AnimationEventListener for implicit animation +class _VisualElementImplicitAnimationEventListener + : public IVisualElementAnimationStatusEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + _VisualElementImplicitAnimationEventListener(void) {} + virtual ~_VisualElementImplicitAnimationEventListener(void) {} + + virtual void OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) {} + virtual void OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) {} + virtual void OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally) + { + target.Destroy(); + delete this; + } +}; + +IMPLEMENT_PROPERTY(_VisualElementImpl); + +_VisualElementImpl::_VisualElementImpl(VisualElement& element) + : _zOrderGroup(Z_ORDER_GROUP_NORMAL) + , __pSharedData(null) + , __pParent(null) + , __pModel(null) + , __pPresentation(null) + , __pRoot(null) + , __isRoot(false) + , __isVisible(false) + , __showOpacity(0.0f) + , __needRecreateSurface(false) + , __bounds(0.0f, 0.0f, 0.0f, 0.0f) + , __alignedSize(0.0f, 0.0f) + , __contentBounds(0.0f, 0.0f, 1.0f, 1.0f) + , __useContentBounds(false) + , __zPosition(0.0f) + , __contentOpacity(1.0f) + , __opacity(1.0f) + , __anchor(0.5f, 0.5f) + , __anchorZ(0.0f) + , __transform() + , __decomposedTransform() + , __childrenTransform() + , __decomposedChildrenTransform() + , __childrenNeedsUpdateProps(HIERARCHY_PROPERTY_MASK & ~HIERARCHY_PROPERTY_CONTENT) + , __invalidatedProps(HIERARCHY_PROPERTY_MASK& ~HIERARCHY_PROPERTY_CONTENT) + , __matrixFromTopValid(false) + , __matrixFromTopInvertible(true) + , __matrixToSuperValid(false) + , __matrixToTopValid(false) + , __matrixToClipSourceValid(false) + , __boundingBoxValid(false) + , __visibleRectValid(false) + , __needTransform(false) + , __needClipForUntransformed(false) + , __isImplicitAnimationEnabled(true) + , __isClipChildren(false) + , __boundingBox(0.0f, 0.0f, 0.0f, 0.0f) + , __pClipSource(null) + , __visibleRect(0.0f, 0.0f, 0.0f, 0.0f) + , __isPropertyPropagationEnabled(true) + , __isDestroying(false) + , __isHidingParent(false) + , __isInternal(false) + , __isAllowedTreeModification(true) + , __pPublicInstance(&element) + , __imageFilePath() + , __renderOperation(VisualElement::RENDER_OPERATION_BLEND) + , __pBoundsChangedCallback(null) + , __pBoundsChangedCallbackData(null) +{ + ClearLastResult(); + + __children.Construct(); +} + +_VisualElementImpl::_VisualElementImpl(VisualElement& presentation, _VisualElementImpl& modelImpl) + : _zOrderGroup(modelImpl._zOrderGroup) + , __pSharedData(null) + , __pParent(null) + , __pModel(null) + , __pPresentation(null) + , __pRoot(null) + , __isRoot(modelImpl.__isRoot) + , __isVisible(modelImpl.__isVisible) + , __showOpacity(modelImpl.__showOpacity) + , __needRecreateSurface(false) + , __bounds(modelImpl.__bounds) + , __alignedSize(modelImpl.__alignedSize) + , __contentBounds(modelImpl.__contentBounds) + , __useContentBounds(modelImpl.__useContentBounds) + , __zPosition(modelImpl.__zPosition) + , __contentOpacity(modelImpl.__contentOpacity) + , __opacity(modelImpl.__opacity) + , __anchor(modelImpl.__anchor) + , __anchorZ(modelImpl.__anchorZ) + , __transform(modelImpl.__transform) + , __decomposedTransform(modelImpl.__decomposedTransform) + , __childrenTransform(modelImpl.__childrenTransform) + , __decomposedChildrenTransform(modelImpl.__decomposedChildrenTransform) + , __childrenNeedsUpdateProps(HIERARCHY_PROPERTY_MASK & ~HIERARCHY_PROPERTY_CONTENT) + , __invalidatedProps(HIERARCHY_PROPERTY_MASK & ~HIERARCHY_PROPERTY_CONTENT) + , __matrixFromTopValid(false) + , __matrixFromTopInvertible(true) + , __matrixToSuperValid(false) + , __matrixToTopValid(false) + , __matrixToClipSourceValid(false) + , __boundingBoxValid(false) + , __visibleRectValid(false) + , __needTransform(modelImpl.__needTransform) + , __needClipForUntransformed(modelImpl.__needClipForUntransformed) + , __isImplicitAnimationEnabled(modelImpl.__isImplicitAnimationEnabled) + , __isClipChildren(modelImpl.__isClipChildren) + , __boundingBox(0.0f, 0.0f, 0.0f, 0.0f) + , __pClipSource(null) + , __visibleRect(0.0f, 0.0f, 0.0f, 0.0f) + , __isPropertyPropagationEnabled(false) // it differs from the property of MODEL object + , __isDestroying(false) + , __isHidingParent(modelImpl.__isHidingParent) + , __isInternal(modelImpl.__isInternal) + , __isAllowedTreeModification(true) + , __pPublicInstance(&presentation) + , __imageFilePath(modelImpl.__imageFilePath) + , __renderOperation(modelImpl.__renderOperation) + , __pBoundsChangedCallback(modelImpl.__pBoundsChangedCallback) + , __pBoundsChangedCallbackData(modelImpl.__pBoundsChangedCallbackData) +{ + ClearLastResult(); + + //GetSharedData().AddRef(); + + __children.Construct(); + + //GetSharedData().invalidatedNativeProps = HIERARCHY_PROPERTY_MASK; + + // for MODEL object + //modelImpl.__pPresentation = this; +} + +_VisualElementImpl::~_VisualElementImpl(void) +{ + ClearLastResult(); + // clear data after detaching children + if (likely(__pSharedData)) + { + __pSharedData->Release(); + __pSharedData = null; + } + + // remove public instance + __pPublicInstance = null; + + + // Remove property observer finally +// if (IsPropertyChangeEventListenerAdded()) +// { +// RemovePropertyChangeEventListener(_VisualElementModelObserver::GetInstance()); +// } +} + +void +_VisualElementImpl::Destroy(void) +{ + //SysLog(NID_UI_ANIM, "destruct[%x]-->begin", this); + + if (unlikely(__isDestroying)) + { + return; + } + + __isDestroying = true; + + + // WARNING: + // Destroy and its callback will be called from the leaf of hiearchy tree first. + // That is, this method first destroys children(Destroy and OnDestructing), and it destroys itself later. + + while (__children.GetCount() > 0) + { + _VisualElementImpl* pChild = __children.GetChildAt(0); + if (likely(pChild)) + { + //pChild->RemoveFromParent(); + //or + if (likely(pChild->__pPublicInstance)) + { + pChild->__pPublicInstance->Destroy(); + } + else + { + SysAssertf(false, "VisualElement does not have public instance."); + } + + } + else + { + SysAssertf(false, "VisualElement has no child."); + } + + } + + + // CHECKME: + // Is this right place for invoking 'OnDestructing' ? + // OnConstructed will be called from public instance. + + if (!IS_PRESENTATION(this)) + { + VE_DELEGATE(this, InvokeOnDestructing); + } + + + RemoveFromParent(); + + + if (IS_MODEL(this)) + { + if (likely(__pPresentation)) + { + __pPresentation->__pPublicInstance->Destroy(); + } + __pPresentation = null; + } + else + { + _AnimationManager::GetInstance()->RemoveAllAnimations(*__pPublicInstance); + + __pModel = null; + } + + delete this; +} + +result +_VisualElementImpl::Construct(void) +{ + result r = E_SUCCESS; + __pSharedData = new (std::nothrow) _VisualElementSharedData; + SysTryCatch(NID_UI_ANIM, __pSharedData, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + SysTryCatch(NID_UI_ANIM, GetSharedData().Construct() == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] failed in shared data constructing."); + + __pModel = this; + __pPresentation = null; + //SysLog(NID_UI_ANIM, "Created(efl=%p)", GetSharedData().pNativeNode); + +#if 0 // REMOVED : We should invoke property observer method manually. + if (__isPropertyPropagationEnabled) + { + AddPropertyChangeEventListener(_VisualElementModelObserver::GetInstance()); + } +#endif + + //VE_DELEGATE(this, InvokeOnConstructed); + + return E_SUCCESS; + + +CATCH: + if (likely(__pSharedData)) + { + GetSharedData().Release(); + __pSharedData = null; + } + + return r; +} + +IVisualElementAnimationProvider* +_VisualElementImpl::GetAnimationProvider(void) const +{ + ClearLastResult(); + SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] VisualElement is not Model object."); + + return GetSharedData().pAnimationProvider; +} + +result +_VisualElementImpl::SetAnimationProvider(IVisualElementAnimationProvider* pProvider) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + + GetSharedData().pAnimationProvider = pProvider; + + return E_SUCCESS; +} + +IVisualElementContentProvider* +_VisualElementImpl::GetContentProvider(void) const +{ + ClearLastResult(); + SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] VisualElement is not Model object."); + + return GetSharedData().pContentProvider; +} + +result +_VisualElementImpl::SetContentProvider(IVisualElementContentProvider* pProvider) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + + GetSharedData().pContentProvider = pProvider; + + return E_SUCCESS; +} + +IVisualElementEventListener* +_VisualElementImpl::GetVisualElementEventListener(void) const +{ + ClearLastResult(); + SysTryReturn(NID_UI_ANIM, IS_MODEL(this), null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] VisualElement is not Model object."); + + return GetSharedData().pEventListener; +} + +result +_VisualElementImpl::SetVisualElementEventListener(IVisualElementEventListener* pListener) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + + GetSharedData().pEventListener = pListener; + + return E_SUCCESS; +} + +result +_VisualElementImpl::FlushI(void) +{ +#ifdef VE_VSYNC_UPDATE + _DisplayManager::GetInstance()->RenderAll(); +#endif + + return _DisplayManager::GetInstance()->Flush(); +} + +result +_VisualElementImpl::SetImageSource(const String& filePath) +{ + RebuildHierarchyProps(0, true, true); + + SysTryReturnResult(NID_UI_ANIM, HAVE_SURFACE(this), E_SYSTEM, "Realizing back-buffer surface failed."); + + result r = GetSharedData().SetImage(filePath); + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + __imageFilePath = filePath; + + return r; +} + + +bool +_VisualElementImpl::CreateImplicitAnimationIfNeeded( const String& property, + const Variant& newValue, const Variant& currentPresentationValue, const String** pSubProperties) +{ + bool r = true; + + _AnimationManager* pAnimationManager = _AnimationManager::GetInstance(); + + if (likely(GetRoot()) + && likely(GetSharedData().needSurface) + && (unlikely(pAnimationManager->IsImplicitAnimationEnabled() && __isImplicitAnimationEnabled)) ) + { + // WARNING: + // For performance, following must be done only when oldValue != newValue. + VisualElementAnimation* pAnimation = InvokeCreateAnimationForProperty(property); + + // user can make other type animation like aAnimationGroup or ValueAnimation + // in this case pPropertyAnimation will have a null value. + VisualElementPropertyAnimation* pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(pAnimation); + if (likely(pPropertyAnimation)) + { + if (pPropertyAnimation->GetEndValue().IsEmpty()) + { + pPropertyAnimation->SetEndValue(newValue); + } + + if (pPropertyAnimation->GetStartValue().IsEmpty()) + { + pPropertyAnimation->SetStartValue(currentPresentationValue); + } + } + + if(pSubProperties) + { // remove sub property + for(int i = 0 ; pSubProperties[i] != NULL ; i++) + { + pAnimationManager->RemoveAnimationForProperty(*__pPublicInstance, *pSubProperties[i]); + } + } + if (unlikely(pAnimation)) + { + /// WARNING: + // Adding property animation causes previous animation for same property to be removed in Animation Manager. + if (unlikely(IsFailed(AddAnimation(null, *pAnimation)))) + { + pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property); + r = false; + } + + delete pAnimation; + } + else + { + // WARNING: + // Remove previous animation even when trying to change the property without animation. + pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property); + r = false; + } + } + else + { + pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property); + r = false; + } + return r; +} + + +result +_VisualElementImpl::SetRenderOperation(VisualElement::RenderOperation renderOperation) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + + result r = InvokeOnSetPropertyRequested(*pVePropRenderOperation, Variant(static_cast< int >(renderOperation))); + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +VisualElement::RenderOperation +_VisualElementImpl::GetRenderOperation(void) const +{ + ClearLastResult(); + +#if 0 + int renderOperation = InvokeOnGetPropertyRequested(*pVePropRenderOperation).ToInt(); + if (GetLastResult() != E_SUCCESS) + { + return VisualElement::RENDER_OPERATION_BLEND; + } + + return static_cast< VisualElement::RenderOperation >(renderOperation); +#else + return __renderOperation; +#endif +} + +Variant +_VisualElementImpl::GetRenderOperationProperty(void) const +{ + ClearLastResult(); + + return Variant(static_cast< int >(__renderOperation)); +} + +result +_VisualElementImpl::SetRenderOperationProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_INT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + VisualElement::RenderOperation renderOperation = static_cast< VisualElement::RenderOperation >(v.ToInt()); + if (likely(__renderOperation != renderOperation)) + { + SysTryReturnResult( + NID_UI_ANIM, + renderOperation >= VisualElement::RENDER_OPERATION_BLEND && renderOperation <= VisualElement::RENDER_OPERATION_COPY, + E_INVALID_ARG, + "Invalid argument(s) is used. The given render operation is out of range." + ); + + __renderOperation = renderOperation; + InvalidateHierarchyProps(HIERARCHY_PROPERTY_OPACITY, false, false); + } + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + __pPresentation->SetRenderOperationProperty(__renderOperation); + } + + return E_SUCCESS; +} + +bool +_VisualElementImpl::GetBackBufferEnabled(void) const +{ + ClearLastResult(); + + return GetSharedData().needSurface; +} + +result +_VisualElementImpl::SetBackBufferEnabled(bool enabled) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + + if (likely(GetSharedData().needSurface != enabled)) + { + /// WARNING: + // Need to check transform matrix if the transform matrix is complex(generic). In this case, disabling Backing-Buffer + // should not be allowed ! + // + if (likely(NEED_SURFACE(this))) // may be redundant checking.... (or using !enabled). Check if this needs surface currently. + { +// _Matrix3Df; +// __transform.Optimize(); +// SysTryReturnResult(NID_UI_ANIM, !__transform.IsGeneric(), E_INVALID_STATE, "VisualElement cannot release back-buffer if transform isn't identity or translation."); + + Matrix4Type matrixType = _GetMatrix4Type(__transform); + SysTryReturnResult( + NID_UI_ANIM, + matrixType == MATRIX4_Identity || matrixType == MATRIX4_Translation, + E_INVALID_STATE, + "VisualElement cannot release back-buffer if transform isn't identity nor translation." + ); + } + + GetSharedData().needSurface = enabled; + + if (NEED_SURFACE(this)) + { + ExposeRectangle(null, true); + } + else + { + InvalidateVisibleRectToRenderTarget(null); + } + + SetSurfaceChanged(); + } + + return E_SUCCESS; +} + +bool +_VisualElementImpl::GetRedrawOnResizeEnabled(void) const +{ + ClearLastResult(); + + return GetSharedData().redrawOnResize; +} + +result +_VisualElementImpl::SetRedrawOnResizeEnabled(bool enabled) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + + GetSharedData().redrawOnResize = enabled; + + return E_SUCCESS; +} + +bool +_VisualElementImpl::GetPropertyPropagationEnabled(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + bool isPropertyPropagationEnabled = InvokeOnGetPropertyRequested(*pVePropPropertyPropagationEnabled).ToBool(); + if (GetLastResult() != E_SUCCESS) + { + return false; + } + + return isPropertyPropagationEnabled; +#else + return __isPropertyPropagationEnabled; +#endif +} + +result +_VisualElementImpl::SetPropertyPropagationEnabledI(bool enable) +{ + if (unlikely(enable == __isPropertyPropagationEnabled)) + { + return E_SUCCESS; + } + + __isPropertyPropagationEnabled = enable; + +// if (IS_MODEL(this)) +// { +// if (__isPropertyPropagationEnabled) +// { +// AddPropertyChangeEventListener(_VisualElementModelObserver::GetInstance()); +// } +// else +// { +// RemovePropertyChangeEventListener(_VisualElementModelObserver::GetInstance()); +// } +// } + + return E_SUCCESS; +} + +result +_VisualElementImpl::SetPropertyPropagationEnabled(bool enable) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + if (enable == __isPropertyPropagationEnabled) + return E_SUCCESS; + + result r = InvokeOnSetPropertyRequested(*pVePropPropertyPropagationEnabled, Variant(enable)); + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Variant +_VisualElementImpl::GetPropertyPropagationProperty(void) const +{ + ClearLastResult(); + + return Variant(__isPropertyPropagationEnabled); +} + +result +_VisualElementImpl::SetPropertyPropagationProperty(const Variant& v) +{ + // TODO: + // Remove this from property. It is used as a property because of _ControlVisualElement when a control was made up of three VEs. + if (IS_PRESENTATION(this)) + return E_SUCCESS; + + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + return SetPropertyPropagationEnabledI(v.ToBool()); +} + +bool +_VisualElementImpl::IsSurfaceNeeded(void) const +{ +// TBD: root VE must have surface always... + if (unlikely(!__pParent)) + { + return true; + } + +#if 0 + const _VisualElementImpl* pCurrent; + + pCurrent = this; + while (pCurrent) + { + if (!pCurrent->__pSharedData) + { + return false; + } + + if (!pCurrent->GetSharedData().needSurface) + { + return true; + } + + pCurrent = pCurrent->__pParent; + } + + return false; +#else + return GetSharedData().needSurface; +#endif +} + +void +_VisualElementImpl::RebuildSurfaces(void) +{ + if (unlikely(!IS_PRESENTATION(this)) || unlikely(!IS_ATTACHED(this))) + { + return; + } + + ResetSurfaceIfNeeded(); + + int count = __children.GetCount(); + for (int i = 0; i < count; i++) + { + __children.GetChildAt(i)->RebuildSurfaces(); + } +} + +void +_VisualElementImpl::ResetSurfaceIfNeeded(void) +{ + if (unlikely(!__needRecreateSurface)) + { + return; + } + + __needRecreateSurface = false; + + + if (unlikely(HAVE_SURFACE(this)) && unlikely(GetSharedData().fixedSurfaceSize)) + { + return; + } + + + _VisualElementImpl* pPresentation = null; + + if (likely(__pPresentation)) + { + pPresentation = __pPresentation; + } + else + { + pPresentation = this; + } + + + if (likely(IsSurfaceNeeded())) + { + if (GetRoot()) + { + _RootVisualElement* pRoot = dynamic_cast<_RootVisualElement*>(GetRoot()->GetPublic()); + + if (pRoot && pRoot->GetNativeLayer()) + { + GetSharedData().fixedSurfaceSize = false; + + float surfaceWidth = __bounds.width; + float surfaceHeight = __bounds.height; + + AdjustSizeForSurface(surfaceWidth, surfaceHeight); + + if (likely(GetSharedData().CreateSurface(Dimension(static_cast< int >(surfaceWidth), static_cast< int >(surfaceHeight)), *pRoot->GetNativeLayer()) == E_SUCCESS)) + { + if (unlikely(!HAVE_SURFACE(this))) + { + pPresentation->InvalidateVisibleRectToRenderTarget(null); + } + + SetSurfaceChanged(); + } + } + } + } + else // surface not needed, so remove Surface + { + if (unlikely(HAVE_SURFACE(this))) + { + GetSharedData().RemoveSurface(*pPresentation); + SetSurfaceChanged(); + } + } +} + +_VisualElementImpl* +_VisualElementImpl::GetRenderTarget(void) const +{ + _VisualElementImpl* pRenderTarget = const_cast< _VisualElementImpl* >(this); + + while (likely(pRenderTarget)) + { + if (likely(NEED_SURFACE(pRenderTarget))) + { + return pRenderTarget; + } + + pRenderTarget = pRenderTarget->__pParent; + } + + return null; +} + +VisualElementSurface* +_VisualElementImpl::GetSurfaceN(void) const +{ + _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this); + pThis->RebuildHierarchyProps(0, true, true); + + SysTryReturn(NID_UI_ANIM, pThis->IsSurfaceNeeded() && HAVE_SURFACE(pThis), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Realizing back-buffer surface failed."); + + VisualElementSurface* pSurface = new (std::nothrow) VisualElementSurface(*pThis->GetSharedData().pSurface); + SysTryReturn(NID_UI_ANIM, pSurface, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + ClearLastResult(); + + return pSurface; +} + +result +_VisualElementImpl::SetSurface(const VisualElementSurface* pSurface) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + SysTryReturnResult(NID_UI_ANIM, NEED_SURFACE(this), E_INVALID_OPERATION, "A surface cannot be set if VisualElement need no back-buffer."); + + if (unlikely(pSurface == GetSharedData().pSurface)) + { + return E_SUCCESS; + } + + if (likely(pSurface) && likely(GetSharedData().pSurface)) + { + if (unlikely(pSurface->Equals(*GetSharedData().pSurface))) + return E_SUCCESS; + } + + if (likely(pSurface)) + { + unique_ptr pTempSurface(new (std::nothrow) VisualElementSurface(*pSurface)); + SysTryReturnResult(NID_UI_ANIM, pTempSurface, E_OUT_OF_MEMORY, "Memory allocation failed."); + + // Delete the old surface + if (GetSharedData().pSurface) + { + delete GetSharedData().pSurface; + } + + GetSharedData().pSurface = pTempSurface.release(); + GetSharedData().fixedSurfaceSize = true; + + // Clear invalidated region if newly fixed-size surface is attached which do not need(inhibit) redrawing + GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, __bounds.width, __bounds.height); + } + else + { + // Delete the old surface + if (GetSharedData().pSurface) + { + delete GetSharedData().pSurface; + } + + __needRecreateSurface = true; + + GetSharedData().pSurface = null; + GetSharedData().fixedSurfaceSize = false; + + // Fully invalidate because new surface should be allocated and redrawn + GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, __bounds.width, __bounds.height); + } + + + SetSurfaceChanged(); + + return E_SUCCESS; +} + +void +_VisualElementImpl::SetSurfaceChanged(void) +{ + GetSharedData().surfaceChanged = true; + + if (likely(!IS_PRESENTATION(this))) + { + if(__pPresentation) + { + __pPresentation->InvalidateHierarchyProps(HIERARCHY_PROPERTY_SURFACE, false, false); + } + } + else + { + InvalidateHierarchyProps(HIERARCHY_PROPERTY_SURFACE, false, false); + } +} + +result +_VisualElementImpl::SetContentBoundsI(const FloatRectangle& contentBounds) +{ +// const Dimension& surfaceSize = GetSharedData().pSurface->GetSize(); +// SysTryReturn(NID_UI_ANIM, +// contentBounds.x >= 0 && contentBounds.y >= 0 && contentBounds.width >= 0 && contentBounds.height >= 0 && +// contentBounds.x + contentBounds.width <= surfaceSize.width && contentBounds.y + contentBounds.height <= surfaceSize.height, +// E_INVALID_ARG, +// E_INVALID_ARG, +// "[E_INVALID_ARG] Invalid content bounds.(%f,%f,%f,%f)", contentBounds.x, contentBounds.y, contentBounds.width, contentBounds.height +// ); + + if (unlikely(RectUtilIsEqual(__contentBounds, contentBounds))) + return E_SUCCESS; + + SysTryReturnResult(NID_UI_ANIM, contentBounds.width >= 0.0f && contentBounds.height >= 0.0f, E_INVALID_ARG, "Invalid argument(s) is used. The size of contents bounds must be greater than or equal to 0.0f."); + + __contentBounds = contentBounds; + __useContentBounds = (__contentBounds.x != 0.0f || __contentBounds.y != 0.0f || __contentBounds.width != 1.0f || __contentBounds.height != 1.0f); + + InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENTBOUNDS, false, false); + + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + FloatRectangle currentValue = __pPresentation->__contentBounds; + + if(CreateImplicitAnimationIfNeeded(*pVePropContentBounds, __contentBounds, currentValue, NULL) == false) + { + __pPresentation->SetContentBoundsProperty(__contentBounds); + } + } + + return E_SUCCESS; +} + +result +_VisualElementImpl::SetContentBounds(const FloatRectangle& contentBounds) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); +#if 0 + return SetContentBoundsI(contentBounds); +#else + result r = InvokeOnSetPropertyRequested(*pVePropContentBounds, Variant(contentBounds)); + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +#endif +} + +FloatRectangle +_VisualElementImpl::GetContentBounds(void) const +{ + ClearLastResult(); + + return __contentBounds; +} + +Variant +_VisualElementImpl::GetContentBoundsProperty(void) const +{ + ClearLastResult(); + + return Variant(__contentBounds); +} + +result +_VisualElementImpl::SetContentBoundsProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_RECTANGLE, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + return SetContentBoundsI(v.ToFloatRectangle()); +} + + +bool +_VisualElementImpl::GetImplicitAnimationEnabled(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + bool isImplicitAnimationEnabled = InvokeOnGetPropertyRequested(*pVePropImplicitAnimationEnabled).ToBool(); + if (GetLastResult() != E_SUCCESS) + return false; + + return isImplicitAnimationEnabled; +#else + return __isImplicitAnimationEnabled; +#endif +} + +result +_VisualElementImpl::SetImplicitAnimationEnabled(bool enable) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = InvokeOnSetPropertyRequested(*pVePropImplicitAnimationEnabled, Variant(enable)); + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Variant +_VisualElementImpl::GetImplicitAnimationProperty(void) const +{ + ClearLastResult(); + + return Variant(__isImplicitAnimationEnabled); +} + +result +_VisualElementImpl::SetImplicitAnimationProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + bool isImplicitAnimationEnabled = v.ToBool(); + if (isImplicitAnimationEnabled != __isImplicitAnimationEnabled) + { + __isImplicitAnimationEnabled = isImplicitAnimationEnabled; + } + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + __pPresentation->SetImplicitAnimationProperty(__isImplicitAnimationEnabled); + } + + return E_SUCCESS; +} + +FloatRectangle +_VisualElementImpl::GetBoundingBox(void) const +{ + ClearLastResult(); + + return GetBoundingBoxI(); +} + +FloatRectangle +_VisualElementImpl::GetBounds(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + FloatRectangle bounds = InvokeOnGetPropertyRequested(*pVePropBounds).ToFloatRectangle(); + if (GetLastResult() != E_SUCCESS) + { + return FloatRectangle(); + } + + return bounds; +#else + return __bounds; +#endif +} + +result +_VisualElementImpl::SetBoundsI(const FloatRectangle& bounds) +{ + _Rectanglef boundsAdjusted(bounds); + FloatRectangle oldValue(__bounds); + + result r = E_SUCCESS; + bool sizeChanged = false; + + if (unlikely(GetSharedData().pEventListener != null)) + { + if (IS_MODEL(this)) // CHECKME: checking need?? + { + FloatRectangle tmpBounds(bounds); + r = VE_DELEGATE(this, InvokeOnBoundsChanging, tmpBounds); + + boundsAdjusted = tmpBounds; + } + } + + if (likely(boundsAdjusted != __bounds)) + { + + float newWidth = boundsAdjusted.Width(); + if (unlikely(newWidth < 0.0f)) + { + newWidth = 0.0f; + } + + float newHeight = boundsAdjusted.Height(); + if (unlikely(newHeight < 0.0f)) + { + newHeight = 0.0f; + } + + + if (unlikely(newWidth != __bounds.width) || unlikely(newHeight != __bounds.height)) + { + sizeChanged = true; + + // WARNING: + // Adjust logical bounds(size) to sync. with that of surface(physical) + + float alignedWidth = newWidth; + float alignedHeight = newHeight; + + AdjustSizeForSurface(alignedWidth, alignedHeight); + + __needRecreateSurface = true; + if (likely(GetSharedData().pSurface)) + { + Dimension surfaceSize(GetSharedData().pSurface->GetSize()); + if (likely(static_cast< int >(alignedWidth) == surfaceSize.width) && likely(static_cast< int >(alignedHeight) == surfaceSize.height)) + __needRecreateSurface = false; + } + + _VisualElementCoordinateSystem::ConvertDimensionToPhysicalIntegral(alignedWidth, alignedHeight); + _VisualElementCoordinateSystem::ConvertDimensionToLogical(alignedWidth, alignedHeight); + + if (newWidth > 0.0f && alignedWidth == 0.0f) + { + alignedWidth = 1.0f / _VisualElementCoordinateSystem::scaleFactorX; + } + + if (newHeight > 0.0f && alignedHeight == 0.0f) + { + alignedHeight = 1.0f / _VisualElementCoordinateSystem::scaleFactorY; + } + + __alignedSize.width = alignedWidth; + __alignedSize.height = alignedHeight; + } + + + // TODO: Need to optimize dirty rectangle. + + // invalidate with previous bounds + if (unlikely(!NEED_SURFACE(this))) + InvalidateVisibleRectToRenderTarget(null); + + // if (sizeChanged) + // SysLog(NID_UI_ANIM, "size changing to " VELOGRECTTAG, VELOGRECT(boundsAdjusted)); + + __bounds.x = boundsAdjusted.Left(); + __bounds.y = boundsAdjusted.Top(); + __bounds.width = newWidth; + __bounds.height = newHeight; + + InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false); + + // TBD: Recreating surface may have to be done in presentation layer (thread!) + + // WARNING: + // Even when 'no redrawOnResize', it is needed to invalidate for redrawing if surface is not created yet. + // + if (unlikely(sizeChanged)) + { + if (unlikely(!NEED_SURFACE(this)) || unlikely(GetSharedData().redrawOnResize)) + ExposeRectangle(null, true); + + // WARNING: + // Shrink invalidated region to bounds + RectUtilIntersect(GetSharedData().invalidatedRegion, FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height)); + } + else + { + if (unlikely(!NEED_SURFACE(this))) + ExposeRectangle(null, true); + } + } + + // observer + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + FloatRectangle currentValue = __pPresentation->__bounds; + + const String* subProperties[] = { pVeSubPropBoundsSize, pVeSubPropBoundsPosition, NULL }; + if(CreateImplicitAnimationIfNeeded(*pVePropBounds, __bounds, currentValue, subProperties ) == false) + { + __pPresentation->SetBoundsProperty(__bounds); + } + + VE_DELEGATE(this, InvokeOnBoundsChanged, oldValue); + + if(__pBoundsChangedCallback && sizeChanged == true) + { + (*__pBoundsChangedCallback)(__pBoundsChangedCallbackData); + } + + } + + return r; +} + + +result +_VisualElementImpl::SetBounds(const FloatRectangle& bounds) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + + if (IS_INTERNAL_CLASS(__pPublicInstance)) + { + r = SetBoundsI(bounds); + } + else + { + r = InvokeOnSetPropertyRequested(*pVePropBounds, Variant(bounds)); + } + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Variant +_VisualElementImpl::GetBoundsProperty(void) const +{ + ClearLastResult(); + + return Variant(__bounds); +} + +result +_VisualElementImpl::SetBoundsProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_RECTANGLE, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + return SetBoundsI(v.ToFloatRectangle()); +} + +Variant +_VisualElementImpl::GetBoundsPositionSubProperty(void) const +{ + ClearLastResult(); + + return Variant(__bounds.GetTopLeft()); +} + +result +_VisualElementImpl::SetBoundsPositionSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const FloatPoint& position = v.ToFloatPoint(); + return SetBoundsProperty(Variant(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height))); +} + +Variant +_VisualElementImpl::GetBoundsSizeSubProperty(void) const +{ + ClearLastResult(); + + return Variant(FloatDimension(__bounds.width, __bounds.height)); +} + +result +_VisualElementImpl::SetBoundsSizeSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_DIMENSION, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const FloatDimension& size = v.ToFloatDimension(); + return SetBoundsProperty(Variant(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height))); +} + +float +_VisualElementImpl::GetZPosition(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + float zPosition = (const_cast< _VisualElementImpl* >(this))->InvokeOnGetPropertyRequested(*pVePropZPosition).ToFloat(); + if (GetLastResult() != E_SUCCESS) + { + return 0.0f; + } + + return zPosition; +#else + return __zPosition; +#endif +} + +result +_VisualElementImpl::SetZPositionI(float zPosition) +{ + if (likely(zPosition != __zPosition)) + { + __zPosition = zPosition; + InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false); // lazy evaluation: property changed flag + } + + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + float currentValue = __pPresentation->__zPosition; + + if(CreateImplicitAnimationIfNeeded(*pVePropZPosition, __zPosition, currentValue, NULL) == false) + { + __pPresentation->SetZPositionProperty(__zPosition); + } + } + + return E_SUCCESS; +} + + +result +_VisualElementImpl::SetZPosition(float zPosition) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + + if (IS_INTERNAL_CLASS(__pPublicInstance)) + { + r = SetZPositionI(zPosition); + } + else + { + r = InvokeOnSetPropertyRequested(*pVePropZPosition, Variant(zPosition)); + } + + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + + + +Variant +_VisualElementImpl::GetZPositionProperty(void) const +{ + ClearLastResult(); + + return Variant(__zPosition); +} + +result +_VisualElementImpl::SetZPositionProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + return SetZPositionI(v.ToFloat()); +} + +result +_VisualElementImpl::SetZOrderGroupI(int zOrderGroup) +{ + result r = E_SUCCESS; + + if (likely(__pParent)) + { + r= __pParent->ChangeZOrder(*this, null, true, zOrderGroup); + } + else + { + _zOrderGroup = zOrderGroup; + } + + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + __pPresentation->SetZOrderGroupProperty(_zOrderGroup); + } + return r; +} + +result +_VisualElementImpl::SetZOrderGroup(int zOrderGroup) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + + if (IS_INTERNAL_CLASS(__pPublicInstance)) + { + r = SetZOrderGroupI(zOrderGroup); + } + else + { + r = InvokeOnSetPropertyRequested(*pVePropZOrderGroup, Variant(zOrderGroup)); + } + + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +_VisualElementImpl::GetZOrderGroup(void) const +{ + ClearLastResult(); + + return _zOrderGroup; +} + +Variant +_VisualElementImpl::GetZOrderGroupProperty(void) const +{ + ClearLastResult(); + + return Variant(_zOrderGroup); +} + +result +_VisualElementImpl::SetZOrderGroupProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_INT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + + return SetZOrderGroupI(v.ToInt()); + + return E_SUCCESS; +} + +bool +_VisualElementImpl::IsVisible(void) const +{ + ClearLastResult(); + + return IsVisibleI(); +} + +#if 0 +bool +_VisualElementImpl::IsVisibleI(void) const +{ +#if 0 + const _VisualElementImpl* pElement = this; + const _VisualElementImpl* pRoot = GetRoot(); + + if (unlikely(!pRoot)) + return false; + + while (pElement) + { + if (!VE_VISIBLE(pElement)) + { + return false; + } + +#if 0 + if (!pElement->__pParent) + { + if (dynamic_cast< const _RootVisualElement* >(pElement) == null) + { + return false; + } + } +#else + if (!pElement->__pParent && pElement != pRoot) + return false; +#endif + + pElement = pElement->__pParent; + } + + return true; +#else + if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))) + { + const_cast< _VisualElementImpl* >(this)->RebuildCoordinates(); + } + + return __isVisible; +#endif +} +#endif + +bool +_VisualElementImpl::GetShowState(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + return InvokeOnGetPropertyRequested(*pVePropShowState).ToBool(); +#else + return VE_VISIBLE(this); +#endif +} + +result +_VisualElementImpl::SetShowOpacityI(float showOpacity) +{ + bool oldShowState = SHOWOPACITY_VISIBLE(__showOpacity); + + if (unlikely(showOpacity < 0.0f)) + { + showOpacity = 0.0f; + } + else if (unlikely(showOpacity > 1.0f)) + { + showOpacity = 1.0f; + } + + if (likely(__showOpacity != showOpacity)) + { + + bool showStateChanged = (oldShowState != SHOWOPACITY_VISIBLE(showOpacity)); + + __showOpacity = showOpacity; + + if (likely(showStateChanged)) + { + if (!oldShowState) + { + // WARNING: + // Coordinates are calculated using visibleRect which is empty when invisible state. + // Show-Recalculation is needed when being visible ! + InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY, true, false); + + if (unlikely(!NEED_SURFACE(this))) + { + ExposeRectangle(null, true); + } + } + else + { + InvalidateHierarchyProps(HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY, true, false); + + if (unlikely(!NEED_SURFACE(this))) + { + InvalidateVisibleRectToRenderTarget(null); + } + } + } + else + { + // WARNING: + // showOpacity is applicable only for surfaces + if (likely(NEED_SURFACE(this))) + { + InvalidateHierarchyProps(HIERARCHY_PROPERTY_OPACITY, true, false); + } + } + } + //Observer + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + bool needPresentationUpdate = true; + const String& property = *pVePropShowState; + _AnimationManager* pAnimationManager = _AnimationManager::GetInstance(); + + if (likely(GetRoot()) && likely(GetSharedData().needSurface) + && (unlikely(pAnimationManager->IsImplicitAnimationEnabled() && __isImplicitAnimationEnabled))) + { + // WARNING: + // For performance, following must be done only when oldValue != newValue. + VisualElementAnimation* pAnimation = InvokeCreateAnimationForProperty(property); + VisualElementPropertyAnimation* pPropertyAnimation = NULL; + if(!pAnimation) + { + pPropertyAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + if(pPropertyAnimation) + { + pPropertyAnimation->SetPropertyName(*pVePrivPropShowOpacity); + needPresentationUpdate = true; + } + } + else + { + pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(pAnimation); + } + + if (likely(pPropertyAnimation)) + { + if (pPropertyAnimation->GetEndValue().IsEmpty()) + { + pPropertyAnimation->SetEndValue(__showOpacity); + } + + if (pPropertyAnimation->GetStartValue().IsEmpty()) + { + pPropertyAnimation->SetStartValue(__pPresentation->__showOpacity); + } + } + + if (unlikely(pPropertyAnimation)) + { + /// WARNING: + // Adding property animation causes previous animation for same property to be removed in Animation Manager. + if (unlikely(IsFailed(AddAnimation(null, *pPropertyAnimation)))) + { + needPresentationUpdate = true; + //pAnimationManager->RemoveAnimationForProperty(*presentation.GetPublic(), property); + } + + delete pPropertyAnimation; + } + else + { + // WARNING: + // Remove previous animation even when trying to change the property without animation. + pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property); + needPresentationUpdate = true; + } + } + else + { + pAnimationManager->RemoveAnimationForProperty(*__pPresentation->__pPublicInstance, property); + needPresentationUpdate = true; + + } + if(needPresentationUpdate) + { + __pPresentation->SetShowStateProperty(SHOWOPACITY_VISIBLE(__showOpacity)); + } + InvokeOnShowStateChanged(oldShowState); + + } + + return E_SUCCESS; +} + +result +_VisualElementImpl::SetShowStateI(bool show) +{ + return SetShowOpacityI(show ? 1.0f : 0.0f); +} + +result +_VisualElementImpl::SetShowState(bool show) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + + if (IS_INTERNAL_CLASS(__pPublicInstance)) + { + r = SetShowOpacityI(show ? 1.0f : 0.0f); + } + else + { + r = InvokeOnSetPropertyRequested(*pVePropShowState, Variant(show)); + } + + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Variant +_VisualElementImpl::GetShowStateProperty(void) const +{ + ClearLastResult(); + + return Variant(VE_VISIBLE(this)); +} + +result +_VisualElementImpl::SetShowStateProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + bool showState = v.ToBool(); + + return SetShowOpacityI(showState ? 1.0f : 0.0f); +} + +Variant +_VisualElementImpl::GetShowOpacityPrivateProperty(void) const +{ + ClearLastResult(); + + return Variant(__showOpacity); +} + +result +_VisualElementImpl::SetShowOpacityPrivateProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + return SetShowOpacityI(v.ToFloat()); +} + +float +_VisualElementImpl::GetContentOpacity(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + return InvokeOnGetPropertyRequested(*pVePropContentOpacity).ToFloat(); +#else + return __contentOpacity; +#endif +} + +result +_VisualElementImpl::SetContentOpacityI(float contentOpacity) +{ + if (unlikely(contentOpacity == __contentOpacity)) // do not take care of float-error !! + { + return E_SUCCESS; + } + + SysTryReturnResult(NID_UI_ANIM, contentOpacity >= 0.0f && contentOpacity <= 1.0f, E_INVALID_ARG, "Invalid argument(s) is used. Invalid opacity range."); + + __contentOpacity = contentOpacity; + + InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENTOPACITY, false, false); //don't have to apply the changed opacity to children. + +#ifndef LAZY_EVALUATION + if (IS_PRESENTATION(this) && likely(__pSharedData) && likely(GetSharedData().pNativeNode)) + { + GetSharedData().NodeReconfigure(*this); + } +#endif + + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + float currentValue = __pPresentation->__contentOpacity; + + if(CreateImplicitAnimationIfNeeded(*pVePropContentOpacity, __contentOpacity, currentValue, NULL) == false) + { + __pPresentation->SetContentOpacityProperty(__contentOpacity); + } + } + return E_SUCCESS; +} + + +result +_VisualElementImpl::SetContentOpacity(float contentOpacity) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + +// PROPERTY_PROCESS(SetContentOpacityI, GetContentOpacityProperty, SetContentOpacityProperty, pVePropContentOpacity, __contentOpacity, contentOpacity); + if (IS_INTERNAL_CLASS(__pPublicInstance)) + { + r = SetContentOpacityI(contentOpacity); + } + else + { + r = InvokeOnSetPropertyRequested(*pVePropContentOpacity, Variant(contentOpacity)); + } + + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + + +Variant +_VisualElementImpl::GetContentOpacityProperty(void) const +{ + ClearLastResult(); + + return Variant(__contentOpacity); +} + +result +_VisualElementImpl::SetContentOpacityProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + return SetContentOpacityI(v.ToFloat()); +} + +float +_VisualElementImpl::GetOpacity(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + return InvokeOnGetPropertyRequested(*pVePropOpacity).ToFloat(); +#else + return __opacity; +#endif +} + +result +_VisualElementImpl::SetOpacityI(float opacity) +{ + if (likely(opacity != __opacity)) // do not take care of float-error !! + { + if (unlikely(opacity > 1.0f)) + { + opacity = 1.0f; + } + else if (unlikely(opacity < 0.0f)) + { + opacity = 0.0f; + } + + __opacity = opacity; + + InvalidateHierarchyProps(HIERARCHY_PROPERTY_OPACITY, true, false); + } + + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + float currentValue = __pPresentation->__opacity; + + if(CreateImplicitAnimationIfNeeded(*pVePropOpacity, __opacity, currentValue, NULL) == false) + { + __pPresentation->SetOpacityProperty(__opacity); + } + } + return E_SUCCESS; +} + +result +_VisualElementImpl::SetOpacity(float opacity) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + +// PROPERTY_PROCESS(SetOpacityI, GetOpacityProperty, SetOpacityProperty, pVePropOpacity, __opacity, opacity); + if (IS_INTERNAL_CLASS(__pPublicInstance)) + { + r = SetOpacityI(opacity); + } + else + { + r = InvokeOnSetPropertyRequested(*pVePropOpacity, Variant(opacity)); + } + + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Variant +_VisualElementImpl::GetOpacityProperty(void) const +{ + ClearLastResult(); + + return Variant(__opacity); +} + +result +_VisualElementImpl::SetOpacityProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + return SetOpacityI(v.ToFloat()); +} + +FloatPoint +_VisualElementImpl::GetAnchor(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + return InvokeOnGetPropertyRequested(*pVePropAnchor).ToFloatPoint(); +#else + return __anchor; +#endif +} + +result +_VisualElementImpl::SetAnchorI(const FloatPoint& anchor) +{ + if (likely(anchor != __anchor)) + { + + __anchor = anchor; + + InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false); + + // VE with surface will be exposed automatically on rebuilding coordinates... + if (unlikely(!HAVE_SURFACE(this))) + { + ExposeRectangle(null, true); // CHECKME: needed ??? + } + } + + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + FloatPoint currentValue = __pPresentation->__anchor; + + if(CreateImplicitAnimationIfNeeded(*pVePropAnchor, __anchor, currentValue, NULL) == false) + { + __pPresentation->SetAnchorProperty(__anchor); + } + } + return E_SUCCESS; +} + + +result +_VisualElementImpl::SetAnchor(const FloatPoint& anchor) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + +// PROPERTY_PROCESS(SetAnchorI, GetAnchorProperty, SetAnchorProperty, pVePropAnchor, __anchor, anchor); + if (IS_INTERNAL_CLASS(__pPublicInstance)) + { + r = SetAnchorI(anchor); + } + else + { + r = InvokeOnSetPropertyRequested(*pVePropAnchor, Variant(anchor)); + } + + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + + +Variant +_VisualElementImpl::GetAnchorProperty(void) const +{ + ClearLastResult(); + + return Variant(__anchor); +} + +result +_VisualElementImpl::SetAnchorProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + return SetAnchorI(v.ToFloatPoint()); +} + +float +_VisualElementImpl::GetAnchorZ(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + return InvokeOnGetPropertyRequested(*pVePropAnchorZ).ToFloat(); +#else + return __anchorZ; +#endif +} + +result +_VisualElementImpl::SetAnchorZI(float anchorZ) +{ + if (likely(anchorZ != __anchorZ)) + { + __anchorZ = anchorZ; + + InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false); + + // VE with surface will be exposed automatically on rebuilding coordinates... + if (unlikely(!HAVE_SURFACE(this))) + { + ExposeRectangle(null, true); // CHECKME: needed ??? + } + } + + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + float currentValue = __pPresentation->__anchorZ; + + if(CreateImplicitAnimationIfNeeded(*pVePropAnchorZ, __anchorZ, currentValue, NULL) == false) + { + __pPresentation->SetAnchorZProperty(__anchorZ); + } + } + return E_SUCCESS; +} + + +result +_VisualElementImpl::SetAnchorZ(float anchorZ) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + +// PROPERTY_PROCESS(SetAnchorZI, GetAnchorZProperty, SetAnchorZProperty, pVePropAnchorZ, __anchorZ, anchorZ); + if (IS_INTERNAL_CLASS(__pPublicInstance)) + { + r = SetAnchorZI(anchorZ); + } + else + { + r = InvokeOnSetPropertyRequested(*pVePropAnchorZ, Variant(anchorZ)); + } + + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + + + +Variant +_VisualElementImpl::GetAnchorZProperty(void) const +{ + ClearLastResult(); + + return Variant(__anchorZ); +} + +result +_VisualElementImpl::SetAnchorZProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + return SetAnchorZI(v.ToFloat()); +} + +FloatMatrix4 +_VisualElementImpl::GetTransformMatrix(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + return InvokeOnGetPropertyRequested(*pVePropTransform).ToFloatMatrix4(); +#else + return __transform; +#endif +} + +result +_VisualElementImpl::SetTransformMatrixI(const FloatMatrix4& xform, bool updateDecomposed) +{ + + result r = E_SUCCESS; + + FloatMatrix4 oldValue(__transform); + + FloatMatrix4 matrixAdjusted(xform); + + if (unlikely(GetSharedData().pEventListener != null)) + { + if (IS_MODEL(this)) // CHECKME: checking need?? + { + r = VE_DELEGATE(this, InvokeOnTransformMatrixChanging, matrixAdjusted); + } + } + + if (r == E_SUCCESS && likely(matrixAdjusted != __transform)) // check again because delegate may change the transform matrix + { + // render target updates for previous bounds + if (unlikely(!NEED_SURFACE(this))) + { + InvalidateVisibleRectToRenderTarget(null); + } + + + MatrixUtilCopy(__transform, matrixAdjusted); + + if (unlikely(updateDecomposed)) + { + __decomposedTransform.SetTransformMatrix(__transform); + } + + InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false); + + // VE with surface will be exposed automatically on rebuilding coordinates... + if (unlikely(!NEED_SURFACE(this))) + { + ExposeRectangle(null, true); // CHECKME: needed ??? + } + } + + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + FloatMatrix4 currentValue = __pPresentation->__transform; + + const String* subProperties[] = { pVeSubPropTransformRotationX, + pVeSubPropTransformRotationY, + pVeSubPropTransformRotationZ, + pVeSubPropTransformScaleX, + pVeSubPropTransformScaleY, + pVeSubPropTransformScaleZ, + pVeSubPropTransformTranslationX, + pVeSubPropTransformTranslationY, + pVeSubPropTransformTranslationZ, + pVeSubPropTransformRotationAnchorX, + pVeSubPropTransformRotationAnchorY, + pVeSubPropTransformRotationAnchorZ, + pVeSubPropTransformScaleAnchorX, + pVeSubPropTransformScaleAnchorY, + pVeSubPropTransformScaleAnchorZ, + NULL}; + + if(CreateImplicitAnimationIfNeeded(*pVePropTransform, __transform, currentValue, subProperties ) == false) + { + __pPresentation->SetTransformMatrixProperty(__transform); + } + + VE_DELEGATE(this, InvokeOnTransformMatrixChanged, oldValue); + } + return E_SUCCESS; +} + +result +_VisualElementImpl::SetTransformMatrix(const FloatMatrix4& xform) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + +// PROPERTY_PROCESS(SetTransformMatrixI, GetTransformMatrixProperty, SetTransformMatrixProperty, pVePropTransform, __transform, xform); + if (IS_INTERNAL_CLASS(__pPublicInstance)) + { + r = SetTransformMatrixI(xform); + } + else + { + r = InvokeOnSetPropertyRequested(*pVePropTransform, Variant(xform)); + } + + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + + + +Variant +_VisualElementImpl::GetTransformMatrixProperty(void) const +{ + ClearLastResult(); + + return Variant(__transform); +} + + +result +_VisualElementImpl::SetTransformMatrixProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_MATRIX4, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + return SetTransformMatrixI(v.ToFloatMatrix4(), true); +} + +Variant +_VisualElementImpl::GetTransformRotationXSubProperty(void) const +{ + ClearLastResult(); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ); + + return Variant(angleX); +} + +result +_VisualElementImpl::SetTransformRotationXSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ); + __decomposedTransform.UpdateRotationFromEulerAngles(v.ToFloat(), angleY, angleZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformRotationYSubProperty(void) const +{ + ClearLastResult(); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ); + + return Variant(angleY); +} + +result +_VisualElementImpl::SetTransformRotationYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ); + __decomposedTransform.UpdateRotationFromEulerAngles(angleX, v.ToFloat(), angleZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformRotationZSubProperty(void) const +{ + ClearLastResult(); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ); + + return Variant(angleZ); +} + +result +_VisualElementImpl::SetTransformRotationZSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ); + __decomposedTransform.UpdateRotationFromEulerAngles(angleX, angleY, v.ToFloat()); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformRotationXYSubProperty(void) const +{ + ClearLastResult(); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ); + + return Variant(FloatPoint(angleX, angleY)); +} + +result +_VisualElementImpl::SetTransformRotationXYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const FloatPoint& point = v.ToFloatPoint(); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedTransform.GetEulerAngles(angleX, angleY, angleZ); + __decomposedTransform.UpdateRotationFromEulerAngles(point.x, point.y, angleZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformRotationAnchorXSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + + return Variant(anchorX); +} + +result +_VisualElementImpl::SetTransformRotationAnchorXSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + __decomposedTransform.SetRotationAnchor(v.ToFloat(), anchorY, anchorZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformRotationAnchorYSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + + return Variant(anchorY); +} + +result +_VisualElementImpl::SetTransformRotationAnchorYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + __decomposedTransform.SetRotationAnchor(anchorX, v.ToFloat(), anchorZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformRotationAnchorZSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + + return Variant(anchorZ); +} + +result +_VisualElementImpl::SetTransformRotationAnchorZSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + __decomposedTransform.SetRotationAnchor(anchorX, anchorY, v.ToFloat()); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformRotationAnchorXYSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + + return Variant(FloatPoint(anchorX, anchorY)); +} + +result +_VisualElementImpl::SetTransformRotationAnchorXYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const FloatPoint& point = v.ToFloatPoint(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + __decomposedTransform.SetRotationAnchor(point.x, point.y, anchorZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformScaleXSubProperty(void) const +{ + ClearLastResult(); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + + return Variant(scaleX); +} + +result +_VisualElementImpl::SetTransformScaleXSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + __decomposedTransform.SetScaleFactors(v.ToFloat(), scaleY, scaleZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformScaleYSubProperty(void) const +{ + ClearLastResult(); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + + return Variant(scaleY); +} + +result +_VisualElementImpl::SetTransformScaleYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + __decomposedTransform.SetScaleFactors(scaleX, v.ToFloat(), scaleZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformScaleZSubProperty(void) const +{ + ClearLastResult(); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + + return Variant(scaleZ); +} + +result +_VisualElementImpl::SetTransformScaleZSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + __decomposedTransform.SetScaleFactors(scaleX, scaleY, v.ToFloat()); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformScaleXYSubProperty(void) const +{ + ClearLastResult(); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + + return Variant(FloatPoint(scaleX, scaleY)); +} + +result +_VisualElementImpl::SetTransformScaleXYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const FloatPoint& point = v.ToFloatPoint(); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + if (unlikely(scaleX == point.x) && unlikely(scaleY == point.y)) + { + return E_SUCCESS; + } + + __decomposedTransform.SetScaleFactors(point.x, point.y, scaleZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformScaleAnchorXSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + + return Variant(anchorX); +} + +result +_VisualElementImpl::SetTransformScaleAnchorXSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + __decomposedTransform.SetScaleAnchor(v.ToFloat(), anchorY, anchorZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformScaleAnchorYSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + + return Variant(anchorY); +} + +result +_VisualElementImpl::SetTransformScaleAnchorYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + __decomposedTransform.SetScaleAnchor(anchorX, v.ToFloat(), anchorZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformScaleAnchorZSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + + return Variant(anchorZ); +} + +result +_VisualElementImpl::SetTransformScaleAnchorZSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + __decomposedTransform.SetScaleAnchor(anchorX, anchorY, v.ToFloat()); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformScaleAnchorXYSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + + return Variant(FloatPoint(anchorX, anchorY)); +} + +result +_VisualElementImpl::SetTransformScaleAnchorXYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const FloatPoint& point = v.ToFloatPoint(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + __decomposedTransform.SetScaleAnchor(point.x, point.y, anchorZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformTranslationXSubProperty(void) const +{ + ClearLastResult(); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ); + + return Variant(translateX); +} + +result +_VisualElementImpl::SetTransformTranslationXSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ); + __decomposedTransform.SetTranslationFactors(v.ToFloat(), translateY, translateZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformTranslationYSubProperty(void) const +{ + ClearLastResult(); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ); + + return Variant(translateY); +} + +result +_VisualElementImpl::SetTransformTranslationYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ); + __decomposedTransform.SetTranslationFactors(translateX, v.ToFloat(), translateZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformTranslationZSubProperty(void) const +{ + ClearLastResult(); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ); + + return Variant(translateZ); +} + +result +_VisualElementImpl::SetTransformTranslationZSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ); + __decomposedTransform.SetTranslationFactors(translateX, translateY, v.ToFloat()); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetTransformTranslationXYSubProperty(void) const +{ + ClearLastResult(); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ); + + return Variant(FloatPoint(translateX, translateY)); +} + +result +_VisualElementImpl::SetTransformTranslationXYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const FloatPoint& point = v.ToFloatPoint(); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedTransform.GetTranslationFactors(translateX, translateY, translateZ); + __decomposedTransform.SetTranslationFactors(point.x, point.y, translateZ); + + return SetTransformMatrixI(__decomposedTransform.GetTransformMatrix(), false); +} + +FloatMatrix4 +_VisualElementImpl::GetChildrenTransformMatrix(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + return InvokeOnGetPropertyRequested(*pVePropChildrenTransform).ToFloatMatrix4(); +#else + return __childrenTransform; +#endif +} + + +result +_VisualElementImpl::SetChildrenTransformMatrixI(const FloatMatrix4& xform, bool updateDecomposed) +{ + FloatMatrix4 matrixAdjusted(xform); + FloatMatrix4 oldValue(__childrenTransform); + result r = E_SUCCESS; + + if (unlikely(GetSharedData().pEventListener != null)) + { + if (IS_MODEL(this)) // CHECKME: checking need?? + { + r = VE_DELEGATE(this, InvokeOnChildrenTransformMatrixChanging, matrixAdjusted); + } + } + + + if (r == E_SUCCESS && likely(matrixAdjusted != __childrenTransform)) // check again because delegate may change the transform matrix + { + + // May be un-needed from now...... (no support for VE without surface or shared-canvas) + if (!IS_PRESENTATION(this)) + { + int count = __children.GetCount(); + for (int i = 0; i < count; i++) + { + // VE with surface will be exposed automatically on rebuilding coordinates... + _VisualElementImpl* pVe = __children.GetChildAt(i); + if (pVe && !NEED_SURFACE(pVe)) + { + pVe->ExposeRectangle(null, true); + + // render target update for previous bounds + pVe->InvalidateVisibleRectToRenderTarget(null); + } + } + } + + MatrixUtilCopy(__childrenTransform, matrixAdjusted); + + if (unlikely(updateDecomposed)) + { + __decomposedChildrenTransform.SetTransformMatrix(__childrenTransform); + } + + InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false); + } + + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + FloatMatrix4 currentValue = __pPresentation->__childrenTransform; + const String* subProperties[] = { + pVeSubPropChildrenTransformRotationX, + pVeSubPropChildrenTransformRotationY, + pVeSubPropChildrenTransformRotationZ, + pVeSubPropChildrenTransformScaleX, + pVeSubPropChildrenTransformScaleY, + pVeSubPropChildrenTransformScaleZ, + pVeSubPropChildrenTransformTranslationX, + pVeSubPropChildrenTransformTranslationY, + pVeSubPropChildrenTransformTranslationZ, + pVeSubPropChildrenTransformRotationAnchorX, + pVeSubPropChildrenTransformRotationAnchorY, + pVeSubPropChildrenTransformRotationAnchorZ, + pVeSubPropChildrenTransformScaleAnchorX, + pVeSubPropChildrenTransformScaleAnchorY, + pVeSubPropChildrenTransformScaleAnchorZ, + NULL}; + + if(CreateImplicitAnimationIfNeeded(*pVePropChildrenTransform, __childrenTransform, currentValue, subProperties ) == false) + { + __pPresentation->SetChildrenTransformMatrixProperty(__childrenTransform); + } + + VE_DELEGATE(this, InvokeOnChildrenTransformMatrixChanged, oldValue); + } + return E_SUCCESS; +} + + +result +_VisualElementImpl::SetChildrenTransformMatrix(const FloatMatrix4& xform) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + + //PROPERTY_PROCESS(SetChildrenTransformMatrixI, GetChildrenTransformMatrixProperty, SetChildrenTransformMatrixProperty, pVePropChildrenTransform, __childrenTransform, xform); + if (IS_INTERNAL_CLASS(__pPublicInstance)) + { + r = SetChildrenTransformMatrixI(xform); + } + else + { + r = InvokeOnSetPropertyRequested(*pVePropChildrenTransform, Variant(xform)); + } + + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Variant +_VisualElementImpl::GetChildrenTransformMatrixProperty(void) const +{ + ClearLastResult(); + + return Variant(__childrenTransform); +} + + +result +_VisualElementImpl::SetChildrenTransformMatrixProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_MATRIX4, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + return SetChildrenTransformMatrixI(v.ToFloatMatrix4(), true); +} + +Variant +_VisualElementImpl::GetChildrenTransformRotationXSubProperty(void) const +{ + ClearLastResult(); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ); + + return Variant(angleX); +} + +result +_VisualElementImpl::SetChildrenTransformRotationXSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ); + __decomposedChildrenTransform.UpdateRotationFromEulerAngles(v.ToFloat(), angleY, angleZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformRotationYSubProperty(void) const +{ + ClearLastResult(); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ); + + return Variant(angleY); +} + +result +_VisualElementImpl::SetChildrenTransformRotationYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ); + __decomposedChildrenTransform.UpdateRotationFromEulerAngles(angleX, v.ToFloat(), angleZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformRotationZSubProperty(void) const +{ + ClearLastResult(); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ); + + return Variant(angleZ); +} + +result +_VisualElementImpl::SetChildrenTransformRotationZSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ); + __decomposedChildrenTransform.UpdateRotationFromEulerAngles(angleX, angleY, v.ToFloat()); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformRotationXYSubProperty(void) const +{ + ClearLastResult(); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ); + + return Variant(FloatPoint(angleX, angleY)); +} + +result +_VisualElementImpl::SetChildrenTransformRotationXYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const FloatPoint& point = v.ToFloatPoint(); + + float angleX = 0.0f; + float angleY = 0.0f; + float angleZ = 0.0f; + __decomposedChildrenTransform.GetEulerAngles(angleX, angleY, angleZ); + __decomposedChildrenTransform.UpdateRotationFromEulerAngles(point.x, point.y, angleZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformRotationAnchorXSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + + return Variant(anchorX); +} + +result +_VisualElementImpl::SetChildrenTransformRotationAnchorXSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + __decomposedChildrenTransform.SetRotationAnchor(v.ToFloat(), anchorY, anchorZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformRotationAnchorYSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + + return Variant(anchorY); +} + +result +_VisualElementImpl::SetChildrenTransformRotationAnchorYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + __decomposedChildrenTransform.SetRotationAnchor(anchorX, v.ToFloat(), anchorZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformRotationAnchorZSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + + return Variant(anchorZ); +} + +result +_VisualElementImpl::SetChildrenTransformRotationAnchorZSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + __decomposedChildrenTransform.SetRotationAnchor(anchorX, anchorY, v.ToFloat()); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformRotationAnchorXYSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + + return Variant(FloatPoint(anchorX, anchorY)); +} + +result +_VisualElementImpl::SetChildrenTransformRotationAnchorXYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const FloatPoint& point = v.ToFloatPoint(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetRotationAnchor(anchorX, anchorY, anchorZ); + __decomposedChildrenTransform.SetRotationAnchor(point.x, point.y, anchorZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformScaleXSubProperty(void) const +{ + ClearLastResult(); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + + return Variant(scaleX); +} + +result +_VisualElementImpl::SetChildrenTransformScaleXSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + __decomposedChildrenTransform.SetScaleFactors(v.ToFloat(), scaleY, scaleZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformScaleYSubProperty(void) const +{ + ClearLastResult(); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + + return Variant(scaleY); +} + +result +_VisualElementImpl::SetChildrenTransformScaleYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + __decomposedChildrenTransform.SetScaleFactors(scaleX, v.ToFloat(), scaleZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformScaleZSubProperty(void) const +{ + ClearLastResult(); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + + return Variant(scaleZ); +} + +result +_VisualElementImpl::SetChildrenTransformScaleZSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + __decomposedChildrenTransform.SetScaleFactors(scaleX, scaleY, v.ToFloat()); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformScaleXYSubProperty(void) const +{ + ClearLastResult(); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + + return Variant(FloatPoint(scaleX, scaleY)); +} + +result +_VisualElementImpl::SetChildrenTransformScaleXYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const FloatPoint& point = v.ToFloatPoint(); + + float scaleX = 1.0f; + float scaleY = 1.0f; + float scaleZ = 1.0f; + __decomposedChildrenTransform.GetScaleFactors(scaleX, scaleY, scaleZ); + __decomposedChildrenTransform.SetScaleFactors(point.x, point.y, scaleZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformScaleAnchorXSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + + return Variant(anchorX); +} + +result +_VisualElementImpl::SetChildrenTransformScaleAnchorXSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + __decomposedChildrenTransform.SetScaleAnchor(v.ToFloat(), anchorY, anchorZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformScaleAnchorYSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + + return Variant(anchorY); +} + +result +_VisualElementImpl::SetChildrenTransformScaleAnchorYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + __decomposedChildrenTransform.SetScaleAnchor(anchorX, v.ToFloat(), anchorZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformScaleAnchorZSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + + return Variant(anchorZ); +} + +result +_VisualElementImpl::SetChildrenTransformScaleAnchorZSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + __decomposedChildrenTransform.SetScaleAnchor(anchorX, anchorY, v.ToFloat()); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformScaleAnchorXYSubProperty(void) const +{ + ClearLastResult(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + + return Variant(FloatPoint(anchorX, anchorY)); +} + +result +_VisualElementImpl::SetChildrenTransformScaleAnchorXYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const FloatPoint& point = v.ToFloatPoint(); + + float anchorX = 0.0f; + float anchorY = 0.0f; + float anchorZ = 0.0f; + __decomposedChildrenTransform.GetScaleAnchor(anchorX, anchorY, anchorZ); + __decomposedChildrenTransform.SetScaleAnchor(point.x, point.y, anchorZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformTranslationXSubProperty(void) const +{ + ClearLastResult(); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ); + + return Variant(translateX); +} + +result +_VisualElementImpl::SetChildrenTransformTranslationXSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ); + __decomposedChildrenTransform.SetTranslationFactors(v.ToFloat(), translateY, translateZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformTranslationYSubProperty(void) const +{ + ClearLastResult(); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ); + + return Variant(translateY); +} + +result +_VisualElementImpl::SetChildrenTransformTranslationYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ); + __decomposedChildrenTransform.SetTranslationFactors(translateX, v.ToFloat(), translateZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformTranslationZSubProperty(void) const +{ + ClearLastResult(); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ); + + return Variant(translateZ); +} + +result +_VisualElementImpl::SetChildrenTransformTranslationZSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ); + __decomposedChildrenTransform.SetTranslationFactors(translateX, translateY, v.ToFloat()); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +Variant +_VisualElementImpl::GetChildrenTransformTranslationXYSubProperty(void) const +{ + ClearLastResult(); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ); + + return Variant(FloatPoint(translateX, translateY)); +} + +result +_VisualElementImpl::SetChildrenTransformTranslationXYSubProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_FLOAT_POINT, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const FloatPoint& point = v.ToFloatPoint(); + + float translateX = 0.0f; + float translateY = 0.0f; + float translateZ = 0.0f; + __decomposedChildrenTransform.GetTranslationFactors(translateX, translateY, translateZ); + __decomposedChildrenTransform.SetTranslationFactors(point.x, point.y, translateZ); + + return SetChildrenTransformMatrixI(__decomposedChildrenTransform.GetTransformMatrix(), false); +} + +bool +_VisualElementImpl::IsClipToParent(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + return InvokeOnGetPropertyRequested(*pVePropClipToParent).ToBool(); +#else + return false; +#endif +} + +// TBD: clipToParent is not animatable, right?? +result +_VisualElementImpl::SetClipToParent(bool clipToParent) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + + return InvokeOnSetPropertyRequested(*pVePropClipToParent, Variant(clipToParent)); +} + +Variant +_VisualElementImpl::GetClipToParentProperty(void) const +{ + ClearLastResult(); + //SysLog(NID_UI_ANIM, "WARNING: ClipToParent is deprecated."); + + return Variant(false); +} + +result +_VisualElementImpl::SetClipToParentProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + //SysLog(NID_UI_ANIM, "WARNING: ClipToParent is deprecated."); + + return E_SUCCESS; +} + +bool +_VisualElementImpl::IsClipChildrenEnabled(void) const +{ + ClearLastResult(); + + return __isClipChildren; +} + +result +_VisualElementImpl::SetClipChildrenEnabled(bool clipChildren) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + + if (IS_INTERNAL_CLASS(__pPublicInstance)) + { + r = SetClipChildrenProperty(Variant(clipChildren)); + } + else + { + r = InvokeOnSetPropertyRequested(*pVePropClipChildren, Variant(clipChildren)); + } + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Variant +_VisualElementImpl::GetClipChildrenProperty(void) const +{ + ClearLastResult(); + + return Variant(__isClipChildren); +} + +result +_VisualElementImpl::SetClipChildrenProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + bool clipChildren = v.ToBool(); + if (likely(clipChildren != __isClipChildren)) + { + + //SysLog(NID_UI_ANIM, "%p ClipChildren = %d", this, clipChildren); + + __isClipChildren = clipChildren; + InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false); + + } + + if(IS_MODEL(this) && IS_NEEDED_UPDATE_PRESENTATION(this)) + { + __pPresentation->SetClipChildrenProperty(__isClipChildren); + } + + return E_SUCCESS; +} + +bool +_VisualElementImpl::IsSurfaceOpaque(void) const +{ + ClearLastResult(); + + // TBD: forward using property or direct return ? +#if 0 + return InvokeOnGetPropertyRequested(*pVePropSurfaceOpaque).ToBool(); +#else + return GetSharedData().isSurfaceOpaque; +#endif +} + +result +_VisualElementImpl::SetSurfaceOpaque(bool isSurfaceOpaque) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + + if (IS_INTERNAL_CLASS(__pPublicInstance)) + { + r = SetSurfaceOpaqueProperty(Variant(isSurfaceOpaque)); + } + else + { + r = InvokeOnSetPropertyRequested(*pVePropSurfaceOpaque, Variant(isSurfaceOpaque)); + } + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Variant +_VisualElementImpl::GetSurfaceOpaqueProperty(void) const +{ + ClearLastResult(); + + return Variant(GetSharedData().isSurfaceOpaque); +} + +result +_VisualElementImpl::SetSurfaceOpaqueProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_BOOL, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + bool isSurfaceOpaque = v.ToBool(); + if (isSurfaceOpaque == GetSharedData().isSurfaceOpaque) + return E_SUCCESS; + + InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENTOPACITY, false, false); //don't have to apply the changed opacity to children. + + if (IS_PRESENTATION(this)) + { + GetSharedData().isSurfaceOpaque = isSurfaceOpaque; + +#ifndef LAZY_EVALUATION + // not needed when no surface + if (HAVE_SURFACE(this)) + GetSharedData().NodeReconfigure(*this); +#endif + } + else + { + if(IS_NEEDED_UPDATE_PRESENTATION(this)) + { + __pPresentation->SetSurfaceOpaqueProperty(isSurfaceOpaque); + } + } + + return E_SUCCESS; +} + +Canvas* +_VisualElementImpl::GetCanvasN(void) +{ + return GetCanvasN(Rectangle(0, 0, __bounds.width, __bounds.height)); +} + +Canvas* +_VisualElementImpl::GetCanvasN(const Rectangle& bounds) +{ + SysTryReturn(NID_UI_ANIM, !GetSharedData().fixedSurfaceSize, null, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Canvas can't be instantiated for fixed-size user surface."); + SysTryReturn(NID_UI_ANIM, bounds.width >= 0 && bounds.height >= 0, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Canvas size is out of range. size = (%f, %f)", bounds.width, bounds.height); + SysTryReturn(NID_UI_ANIM, __imageFilePath.IsEmpty(), null, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Can't get canvas for surface which is from image file."); + SysTryReturn(NID_UI_ANIM, GetRoot(), null, E_INVALID_STATE, "[E_INVALID_STATE] VisualElement is not attached to main tree."); + + + // WARNING: WARNING: WARNING: + // If need-redraw and surface is set by user, VE do *NOT* allow GetCanvasN + // because 'bounds' is for the VE does not comply with size of surface. + // (in which case the surface will be displayed scaled) + + _VisualElementImpl* pRenderTarget = null; + + pRenderTarget = GetRenderTarget(); + SysTryReturn(NID_UI_ANIM, pRenderTarget, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Target VisualElement is not available."); + SysTryReturn(NID_UI_ANIM, pRenderTarget->__pSharedData, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Target VisualElement is not constructed."); + + // WARNING: + // Forcefully create surface if GetCanvasN is called. + // Without followings, surface may not be created if size of bounds == 0 (the initial size) + if (!HAVE_SURFACE(this)) + __needRecreateSurface = true; + + pRenderTarget->RebuildHierarchyProps(0, true, true); +#if 1 + SysTryReturn(NID_UI_ANIM, pRenderTarget->GetSharedData().pNativeNode->GetSurface(), null, E_SYSTEM, "[E_INVALID_STATE] Target VisualElement's surface is not constructed."); +#else + SysTryReturn(NID_UI_ANIM, pRenderTarget->GetSharedData().pSurface, null, E_SYSTEM, "[E_INVALID_STATE] Target VisualElement's surface is not constructed."); +#endif + + + FloatRectangle canvasBounds; + FloatRectangle clipBounds; + + // TODO: FIXME: + // Use surface size, not bounds !!! + + int canvasX, canvasY, canvasW, canvasH; + + if (bounds.width == 0 || bounds.height == 0) + { + float surfaceWidth = __bounds.width; + float surfaceHeight = __bounds.height; + AdjustSizeForSurface(surfaceWidth, surfaceHeight); + + SysTryReturn(NID_UI_ANIM, bounds.x >= 0.0f && bounds.y >= 0.0f && bounds.x <= int(surfaceWidth) && bounds.y <= int(surfaceHeight), null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Bounds is out of range."); + + canvasX = bounds.x; + canvasY = bounds.y; + canvasW = 0; + canvasH = 0; + } + else + { + clipBounds.x = 0.0f; + clipBounds.y = 0.0f; + clipBounds.width = __bounds.width; + clipBounds.height = __bounds.height; + + canvasBounds.x = bounds.x; + canvasBounds.y = bounds.y; + canvasBounds.width = bounds.width; + canvasBounds.height = bounds.height; + + canvasBounds = canvasBounds.GetIntersection(clipBounds); + pRenderTarget->__pPresentation->ConvertCoordinates(canvasBounds, this->__pPresentation); + canvasBounds = canvasBounds.GetIntersection(pRenderTarget->GetDrawableRect()); + + SysTryReturn(NID_UI_ANIM, canvasBounds.width > 0 && canvasBounds.height > 0, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Bounds is out of range."); + _VisualElementCoordinateSystem::MakeIntegralPoint(canvasBounds.x, canvasBounds.y, canvasX, canvasY); + _VisualElementCoordinateSystem::MakeIntegralDimension(canvasBounds.width, canvasBounds.height, canvasW, canvasH); + } + + // WARNING: + // From now, canvasBounds contains the clipping area, not subcanvas area. + // (0, 0) of the canvas should be placed on the left-top of the VE ! + + unique_ptr<_VisualElementCanvas> pCanvas(new (std::nothrow) _VisualElementCanvas); + + result r = pCanvas->Construct(*pRenderTarget->GetSharedData().pNativeNode->GetSurface(), Rectangle(canvasX, canvasY, canvasW, canvasH)); + SysTryReturn(NID_UI_ANIM, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] VisualElement is not constructed."); + + pRenderTarget->SetFlushNeeded(); + + ClearLastResult(); + + return pCanvas.release(); +} + +_VisualElementImpl* +_VisualElementImpl::GetRoot(void) const +{ + ClearLastResult(); + + if (IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)) + { + const_cast< _VisualElementImpl* >(this)->RebuildCoordinates(); + } + + return __pRoot; +} + +_VisualElementImpl* +_VisualElementImpl::GetParent(void) const +{ + ClearLastResult(); + + return __pParent; +} + +int +_VisualElementImpl::GetChildrenCount(void) const +{ + ClearLastResult(); + + return __children.GetCount(); +} + +Tizen::Base::Collection::IList* +_VisualElementImpl::GetPublicChildrenN(void) const +{ + unique_ptr pArrayList(new (std::nothrow) Tizen::Base::Collection::ArrayList()); + SysTryReturn(NID_UI_ANIM, pArrayList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + int count = __children.GetCount(); + SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Construct(count)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + for (int i = 0; i < count; i++) + { + const _VisualElementImpl* pChild = __children.GetChildAt(i); + + if (likely(pChild) && likely(pChild->__pPublicInstance)) + { + SysTryReturn(NID_UI_ANIM, !IsFailed(pArrayList->Add(*pChild->__pPublicInstance)), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + } + } + + ClearLastResult(); + + return pArrayList.release(); +} + +bool +_VisualElementImpl::IsChildOf(const _VisualElementImpl& element) const +{ + ClearLastResult(); + + if (unlikely(this == &element)) + { + return false; + } + + if (unlikely(!__pParent)) + { + return false; + } + + if (likely(__pParent == &element)) + { + return true; + } + + return __pParent->IsChildOf(element); +} + +result +_VisualElementImpl::SetZOrder(const _VisualElementImpl* pReference, bool above) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + SysTryReturnResult(NID_UI_ANIM, !pReference || pReference->__pParent, E_INVALID_ARG, "pReference doesn't have parent."); + SysTryReturnResult(NID_UI_ANIM, __pParent, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement doesn't have a parent."); + SysTryReturnResult(NID_UI_ANIM, __isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener."); + + return __pParent->InsertChild(*this, pReference, above); +} + +void +_VisualElementImpl::RemoveFromParent(void) +{ + if (likely(__pParent)) + { + __pParent->RemoveChild(*this); + } +} + +result +_VisualElementImpl::AddChild(_VisualElementImpl& child) +{ + //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + SysTryReturnResult(NID_UI_ANIM, child.__pSharedData, E_INVALID_ARG, "Child VisualElement is not constructed."); + SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener."); + + return ChangeZOrder(child, null, true, child._zOrderGroup); +} + +int +_VisualElementImpl::GetChildIndex(const _VisualElementImpl& child) const +{ + int index = 0; + result r = __children.IndexOf(const_cast< _VisualElementImpl* >(&child), index); + + if (r == E_SUCCESS) + { + return index; + } + + // r == E_OUT_OF_RANGE or E_OBJ_NOT_FOUND + return -1; +} + +/** + * @param[in] group will be changed group of the visualemenet. + * @param[out] belowIndex the index of last item of below group's item. + * @param[out] aboveIndex the index of first item of above group's item. + * + * if group is lower than __children's lowest item, belowIndex = -1 , aboveIndex = 0 + * if group is higher than __children's highest item, belowIndex is last index of children, aboveIndex is 1 bigger than belowIndex. + * + *(ex) + * B = Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM // lowest drawing gadget.(Background) + * N = Z_ORDER_GROUP_NORMAL; // level of the default group. + * T = Z_ORDER_GROUP_ALWAYS_ON_TOP; // highest drawing gadget. + * 0 1 2 3 4 5 6 7 8 9 + * [B][B][B][N][N][N][N][T][T][T] + * __GetZOrderGroupIndex(Z_ORDER_GROUP_NORMAL, below, above); + * below = 2 + * above = 7 + * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_ON_TOP, below, above); + * below = 6 + * above = 10 + * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM, below, above); + * below = -1 + * above = 3 + * 0 1 2 3 4 5 6 7 8 9 + * [B][B][B][B][B][T][T][T][T][T] + * __GetZOrderGroupIndex(Z_ORDER_GROUP_NORMAL, below, above); + * below = 4 + * above = 5 + * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_ON_TOP, below, above); + * below = 4 + * above = 10 + * __GetZOrderGroupIndex(Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM, below, above); + * below = -1 + * above = 5 + * + */ + +int +_VisualElementImpl::GetZOrderGroupIndex(int group, int& belowIndex, int& aboveIndex) const +{ + int lastIndex = __children.GetCount() - 1; + if (lastIndex < 0) // _children is empty. + { + belowIndex = -1; + aboveIndex = 0; + return 0; + } + + if (group < (__children.GetChildAt(0))->_zOrderGroup) // group is lower than __children's lowest item. + { + belowIndex = -1; + aboveIndex = 0; + return -1; + } + + if (group > (__children.GetChildAt(lastIndex))->_zOrderGroup) // group is higher than __children's highest item. + { + belowIndex = lastIndex; + aboveIndex = lastIndex + 1; + return 1; + } + + int i = lastIndex; + + for (; i >= 0; i--) + { + if (group >= __children.GetChildAt(i)->_zOrderGroup) + { + break; + } + } + + aboveIndex = i + 1; + + for (; i >= 0; i--) + { + if (group > __children.GetChildAt(i)->_zOrderGroup) + { + break; + } + } + + belowIndex = i; + + return 0; +} + +result +_VisualElementImpl::InsertChild(_VisualElementImpl& child, const _VisualElementImpl* pReference, bool above) +{ + //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + SysTryReturnResult(NID_UI_ANIM, child.__pSharedData, E_INVALID_ARG, "Child VisualElement is not constructed."); + SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener."); + + int zOrderGroup = child._zOrderGroup; + + if (unlikely(pReference)) + { + zOrderGroup = pReference->_zOrderGroup; + } + + return ChangeZOrder(child, pReference, above, zOrderGroup); +} + +result +_VisualElementImpl::ChangeZOrder(_VisualElementImpl& child, const _VisualElementImpl* pReference, bool above, int group) +{ + int indexChild; + int indexReference = -1; + int indexInsert = -1; + + // If not constructed well, disallow attaching ! + + if (IsChildOf(child) || this == &child || &child == pReference || (pReference && pReference->__pParent != this)) + { + return E_INVALID_ARG; + } + + // TBD: check ownership!!! + if (IS_PRESENTATION(this)) + { + _RootVisualElement* pChildRoot = child.GetRootPublic(); + + if (GetRootPublic() != null && pChildRoot != GetRootPublic()) + { + child.RebuildNativeNodeTree(*this); + } + } + + if (pReference) + { + indexReference = GetChildIndex(*pReference); + SysTryReturnResult(NID_UI_ANIM, indexReference >= 0, E_INVALID_ARG, "Invalid argument(s) is used. pReference is not a child of this instance."); + + if (above) + { + indexReference++; + } + } + else + { + if (above) + { + indexReference = __children.GetCount(); + } + else + { + indexReference = 0; + } + } + + int belowIndex, aboveIndex, indexRange; + + indexRange = GetZOrderGroupIndex(group, belowIndex, aboveIndex); + + if (indexRange < 0) + { + indexInsert = 0; + } + else if (indexRange > 0) + { + indexInsert = __children.GetCount(); + } + else + { + if (indexReference <= belowIndex + 1) + { + indexInsert = belowIndex + 1; + } + else if (indexReference >= aboveIndex) + { + indexInsert = aboveIndex; + } + else + { + indexInsert = indexReference; + } + + if (indexInsert < 0) + { + indexInsert = 0; + } + } + + if (child.__pParent == this) //case 1: move to the same parent. (just changed order ) + { + indexChild = GetChildIndex(child); + SysTryReturn(NID_UI_ANIM, indexChild >= 0, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The child(%p) isn't managed by this instance.", &child); + + if (indexChild < indexInsert) + { + indexInsert--; // one of child item is removed so total item index is decreased. + } + + if (indexChild == indexInsert) //same position. don't have to do any action. + { + child._zOrderGroup = group; + + //update presentation zorder group + if (!IS_PRESENTATION(this)) + { + child.UpdatePresentationWhenZOrderChanged(pReference, above); + } + return E_SUCCESS; + } + + SysTryReturn(NID_UI_ANIM, RemoveChildWithoutReconfiguring(indexChild, true) == E_SUCCESS, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Failed to remove a child(%p) from this instance.", &child); + + } + else //case 2: move to the other parent. + { //case 3: child never been attached to the any parent. + if (child.__pParent) + { + child.__pParent->RemoveChild(child); + } + + // Setting implicit animation to the child. + if (!IS_PRESENTATION(this) && _AnimationManager::GetInstance()->IsImplicitAnimationEnabled() && child.__isImplicitAnimationEnabled) + { + RemoveAnimation(*pVePropActionAttach); + +#if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION) + VisualElementAnimation* pAnimation = child.InvokeCreateAnimationForProperty(*pVePropActionAttach); +#else + VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturn(NID_UI_ANIM, pAnimation != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + pAnimation->SetPropertyName(*pVePropOpacity); + pAnimation->SetStartValue(Variant(0.0f)); +#endif + if (pAnimation != null) + { + pAnimation->SetVisualElementAnimationStatusEventListener(null); + (child.GetPublic())->AddAnimation(*pVePropActionAttach, *pAnimation); + } + delete pAnimation; + } + } + + // set ZOrder group + child._zOrderGroup = group; + + //SysLog(NID_UI_ANIM, "Insert child %p(%d)", &child, indexInsert); + + if (!IS_PRESENTATION(this)) + { + VE_DELEGATE(this, InvokeOnChildAttaching, child); + VE_DELEGATE(&child, InvokeOnAttaching, *this); + } + + __children.InsertAt(&child, indexInsert); // need addref -> jobs -> release ... + child.__pParent = this; + + child.InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_SHOWSTATE, true, false); + + // propagate child's prop. status to parents + //__InvalidateHierarchyProps(child.__childrenNeedsUpdateProps, false, true); + InvalidateHierarchyProps(child.__childrenNeedsUpdateProps, true, false); + + //SetRootNeedsContentUpdate(); + + // WARNING: + // When no surface, it is needed to invalidated. + // + if (unlikely(!NEED_SURFACE(&child))) + { + child.ExposeRectangle(null, true); + } + + // + // Because tree hierarchy is not a property, VE hierarchy tree changes are not + // notified by property observer. So, we invoke method in presentation VE directly. + // + + if (!IS_PRESENTATION(this)) + { + child.UpdatePresentationWhenZOrderChanged(pReference, above); + } + else + { + if (likely(GetSharedData().pNativeNode) && likely(child.GetSharedData().pNativeNode)) + { + _VisualElementImpl* pReferenceNode = null; + + if (indexInsert > 0) + { + pReferenceNode = __children.GetChildAt(indexInsert - 1); + } + + // exceptional case: the pRefenreceNode is null and indexInsert are more than __children.count() + 1, then this case is something wrong. + // normal case : when pReferenceNode is null , indexInsert has 0 or more small value. + + GetSharedData().pNativeNode->InsertChild( + *child.GetSharedData().pNativeNode, + (pReferenceNode ? pReferenceNode->GetSharedData().pNativeNode : null), + (pReferenceNode ? true : false) + ); + } + } + + return E_SUCCESS; +} + +result +_VisualElementImpl::UpdatePresentationWhenCustomPropertyChanged(const String& property, const Variant& value) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + + if (IS_NEEDED_UPDATE_PRESENTATION(this)) + { + + Variant oldV = __pPresentation->InvokeOnGetPropertyRequested(property); + + if(CreateImplicitAnimationIfNeeded(property,value,oldV, NULL) == false) + { + r = __pPresentation->InvokeOnSetPropertyRequested(property, value); + } + } + return r; +} + +void +_VisualElementImpl::UpdatePresentationWhenZOrderChanged(const _VisualElementImpl* pReferenceModel, bool above) +{ + if(!IS_MODEL(this) || !__pParent) + { + return; + } + + _VisualElementImpl* pReferencePresenter = (pReferenceModel ? (pReferenceModel->__pPresentation ? pReferenceModel->__pPresentation : null) : null); + + if (likely(__pParent->__pPresentation) && likely(__pPresentation)) + { + __pParent->__pPresentation->ChangeZOrder(*__pPresentation, pReferencePresenter, above, _zOrderGroup); + + if (GetSharedData().pEventListener != null) + { + InvokeOnAttached(); + } + + if (__pParent->GetSharedData().pEventListener != null) + { + __pParent->InvokeOnChildAttached(*this); + } + } +} + +void +_VisualElementImpl::UpdatePresentationWhenChildRemoved(_VisualElementImpl& child, bool deallocate) +{ + if(!IS_MODEL(this)) + { + return; + } + + if (likely(__pPresentation) && likely(child.GetPresentation())) + { + __pPresentation->RemoveChild(*child.GetPresentation(), deallocate); + } + + // IMPORTANT! When destroying, don't have to invoke OnDetached and OnDetaching after invoked OnDestructing. + // call OnDestructing -> call OnDetaching it is ambiguous operation + // it is called by RemoveFromParent() method, so pChild is destroying currently. + if (!child.__isDestroying && child.GetSharedData().pEventListener != null) + { + child.InvokeOnDetached(*this); + } + + if (GetSharedData().pEventListener != null) + { + InvokeOnChildDetached(child); + } +} + +result +_VisualElementImpl::RemoveChildWithoutReconfiguring(int indexChild, bool invalidate) +{ + SysTryReturnResult(NID_UI_ANIM, indexChild >= 0 && indexChild < __children.GetCount(), E_OBJ_NOT_FOUND, "There is no VisualElement at %d th index.", indexChild); + + _VisualElementImpl* pChild = __children.GetChildAt(indexChild); + SysTryReturnResult(NID_UI_ANIM, pChild, E_OBJ_NOT_FOUND, "There is no VisualElement at %d th index.", indexChild); + + if (!IS_PRESENTATION(this)) + { + + VE_DELEGATE(this, InvokeOnChildDetaching, *pChild); + + // IMPORTANT! When destroying, don't have to invoke OnDetached and OnDetaching after invoked OnDestructing. + // call OnDestructing -> call OnDetaching it is ambiguous operation + // it is called by RemoveFromParent() method, so pChild is destroying currently. + if (!pChild->__isDestroying) + { + VE_DELEGATE(pChild, InvokeOnDetaching); + } + } + + //SysLog(NID_UI_ANIM, "Remove child %p(%d)", pChild, indexChild); + __children.RemoveAt(indexChild); + pChild->__pParent = null; +// pChild->__ClearHierarchyInfo(); + + + if (!IS_PRESENTATION(this)) + { + // removed element need not invalidation ! + if (invalidate) + { + if (NEED_SURFACE(pChild)) + { + pChild->ExposeRectangle(null, false); + } + else + { + pChild->InvalidateVisibleRectToRenderTarget(null); + } + } + } + else + { + if (GetSharedData().pNativeNode && pChild->GetSharedData().pNativeNode) + { + GetSharedData().pNativeNode->RemoveChild(*pChild->GetSharedData().pNativeNode); + } + } + + // WARNING: + // Because some properties such as root, visible rect and etc. can be accessed detached, invalidating is needed here ! + // (Will be invalidated again on attaching) + // + pChild->InvalidateHierarchyProps(HIERARCHY_PROPERTY_COORDINATES, true, false); + + return E_SUCCESS; +} + +result +_VisualElementImpl::CreateElementTreeForDetachImplicitAnimation(_VisualElementImpl& child) +{ + result r = E_SYSTEM; + + VisualElement* pRoot = child.CreateElementForImplicitAnimationN(); + if (pRoot == null) + { + return r; + } + + pRoot->_pVisualElementImpl->SetInternal(true); + +#if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION) + VisualElementAnimation* pAnimation = child.InvokeCreateAnimationForProperty(*pVePropActionDetach); +#else + VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + pAnimation->SetPropertyName(*pVePropOpacity); + pAnimation->SetEndValue(Variant(0.0f)); +#endif + if (pAnimation) + { + _VisualElementImplicitAnimationEventListener* pListener = new (std::nothrow) _VisualElementImplicitAnimationEventListener(); + if (pListener) + { + pAnimation->SetVisualElementAnimationStatusEventListener(pListener); + + r = pRoot->AddAnimation(*pVePropActionDetach, *pAnimation); + if (r == E_SUCCESS) + { + if (!GetPublic()) + { + return E_SYSTEM; + } + + r = GetPublic()->AttachChild(*pRoot); + if (r == E_SUCCESS) + { + delete pAnimation; + + return r; + } + } + + delete pListener; + } + + delete pAnimation; + } + + return r; +} + +VisualElement* +_VisualElementImpl::CreateElementForImplicitAnimationN(void) const +{ + VisualElement* pElement = new (std::nothrow) VisualElement(*GetPublic()); + if (pElement == null) + { + return null; + } + + result r = pElement->Construct(); + if (r != E_SUCCESS) + { + pElement->Destroy(); + return null; + } + + pElement->SetImplicitAnimationEnabled(false); + + if (HAVE_SURFACE(this)) + { + VisualElementSurface* pSurface = GetSurfaceN(); + if (pSurface) + { + pElement->SetSurface(pSurface); + delete pSurface; + } + } + + int count = __children.GetCount(); + for (int i = 0; i < count; i++) + { + _VisualElementImpl* pVisualElementImpl = __children.GetChildAt(i); + if (likely(pVisualElementImpl)) + { + r = pElement->AttachChild(*pVisualElementImpl->CreateElementForImplicitAnimationN()); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + return pElement; + +CATCH: + delete pElement; + return null; +} + + +result +_VisualElementImpl::RemoveChild(_VisualElementImpl& child, bool deallocate) +{ + //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + SysTryReturnResult(NID_UI_ANIM, child.__isAllowedTreeModification == true, E_INVALID_OPERATION, "Z-order cannot be modified inside the OnAttached() or OnDetached() method of VisualElementEventListener."); + + int indexChild = GetChildIndex(child); + SysTryReturnResult(NID_UI_ANIM, indexChild >= 0, E_OBJ_NOT_FOUND, "child is not a child of this instance."); + if (unlikely(indexChild < 0)) + return E_OBJ_NOT_FOUND; + + + result r = RemoveChildWithoutReconfiguring(indexChild, true); + if (unlikely(r != E_SUCCESS)) + { + return E_OBJ_NOT_FOUND; + } + + if (!IS_PRESENTATION(this) && (_AnimationManager::GetInstance()->IsImplicitAnimationEnabled() + && child.__isImplicitAnimationEnabled) && child.IsAncestorDestroying() == false) + { + r = CreateElementTreeForDetachImplicitAnimation(child); + if (unlikely(r != E_SUCCESS)) + { + SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Dummy VisualElement cannot be attached."); + } + } + + // + // Because tree hierarchy is not a property, VE hierarchy tree changes are not + // notified by property observer. So, we invoke method in presentation VE directly. + // + if (!IS_PRESENTATION(this)) + { + UpdatePresentationWhenChildRemoved(child,deallocate); + } + + // TODO: + // DEALLOCATE !!! + // + + return E_SUCCESS; +} + +result +_VisualElementImpl::RemoveAllChild(void) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + return E_SUCCESS; +} + + +void +_VisualElementImpl::RebuildNativeNodeTree(_VisualElementImpl& parent) +{ + if (!IS_PRESENTATION(this)) + { + return; + } + + _INativeNode* pNode = GetNativeNode(); + _INativeNode* pParentNode = parent.GetNativeNode(); + + if (!pNode || !pParentNode) + { + return; + } + + pNode->RebuildIfNeeded(*pParentNode); + +//TODO : must check ,don't you need to rebuild??? +// RebuildCoordinates(); + + const int nativeProps = _VisualElementImpl::HIERARCHY_PROPERTY_COORDINATES + | _VisualElementImpl::HIERARCHY_PROPERTY_OPACITY + | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTOPACITY + | _VisualElementImpl::HIERARCHY_PROPERTY_CONTENTBOUNDS; + + + InvalidateHierarchyProps(nativeProps, false, false); + + int count = __children.GetCount(); + for ( int i = 0 ; i < count ; i++ ) + { + _VisualElementImpl* pVe = __children.GetChildAt(i); + if (pVe) + { + pVe->RebuildNativeNodeTree(*this); + _INativeNode* pChildNode = pVe->GetNativeNode(); + pNode->InsertChild(*pChildNode,null, true); + } + } + +} + + +Tizen::Base::String +_VisualElementImpl::GetName(void) const +{ + ClearLastResult(); + +#if 0 + return InvokeOnGetPropertyRequested(*pVePropName).ToString(); +#else + return GetSharedData().name; +#endif +} + +result +_VisualElementImpl::SetName(const Tizen::Base::String& name) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = InvokeOnSetPropertyRequested(*pVePropName, Variant(name)); + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + + +Variant +_VisualElementImpl::GetNameProperty(void) const +{ + ClearLastResult(); + + return Variant(GetSharedData().name); +} + +result +_VisualElementImpl::SetNameProperty(const Variant& v) +{ + SysTryReturn(NID_UI_ANIM, v.GetType() == VARIANT_TYPE_STRING, E_INVALID_ARG, E_INVALID_ARG, STR_ERROR_INVALID_VARIANT_ARG_TYPE); + + const Tizen::Base::String& name = v.ToString(); + if (name == GetSharedData().name) + { + return E_SUCCESS; + } + + GetSharedData().name = name; + + return E_SUCCESS; +} + +result +_VisualElementImpl::SetUserData(void* pUserData) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + + GetSharedData().pUserData = pUserData; + + return E_SUCCESS; +} + +void* +_VisualElementImpl::GetUserData(void) const +{ + ClearLastResult(); + + return GetSharedData().pUserData; +} + +_VisualElementImpl* +_VisualElementImpl::GetChild(const Tizen::Base::String& name, bool searchAllDescendants) const +{ + ClearLastResult(); + + int count = __children.GetCount(); + + // for performance, look children directly + for (int i = 0; i < count; i++) + { + const _VisualElementImpl* pChild = __children.GetChildAt(i); + if (unlikely(pChild->GetSharedData().name == name)) + { + return const_cast< _VisualElementImpl* >(pChild); + } + } + + if (searchAllDescendants) + { + for (int i = 0; i < count; i++) + { + const _VisualElementImpl* pChild = __children.GetChildAt(i)->GetChild(name, true); + if (likely(pChild)) + { + return const_cast< _VisualElementImpl* >(pChild); + } + } + } + + SetLastResult(E_OBJ_NOT_FOUND); + + return null; +} + +FloatRectangle +_VisualElementImpl::GetVisibleRect(void) const +{ + _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this); + + if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))) + pThis->RebuildCoordinates(); + + if (!IsVisibleI()) + return FloatRectangle(); + + if (likely(__visibleRectValid)) + return __visibleRect; + + if (__pClipSource) + { + FloatRectangle parentVisibleRect(__pClipSource->GetVisibleRect()); + ConvertCoordinates(parentVisibleRect, __pClipSource); + pThis->__visibleRect = parentVisibleRect.GetIntersection(__visibleRect); + } + + pThis->__visibleRectValid = true; + + return __visibleRect; +} + +FloatRectangle +_VisualElementImpl::GetDrawableRect(void) const +{ + // If VE has backing-buffer, visible status is not important for drawing... + bool needSurface = NEED_SURFACE(this); + + if (unlikely(!needSurface)) + { + return FloatRectangle(); + } + + if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))) + { + _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this); + pThis->RebuildCoordinates(); + } + + // WARNING: + // Even when surface exists, the size might be invalidated by changing bounds. + // +#if 0 + RebuildHierarchyProps(HIERARCHY_PROPERTY_MASK & (~HIERARCHY_PROPERTY_CONTENT), true); + if (!HAVE_SURFACE(this)) + { + return __visibleRect; + } +#endif + if (HAVE_SURFACE(this) && GetSharedData().fixedSurfaceSize) + { + return FloatRectangle(0.0f, 0.0f, static_cast< float >(GetSharedData().pSurface->GetSize().width), static_cast< float >(GetSharedData().pSurface->GetSize().height)); + } + + return FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height); +} + +float +_VisualElementImpl::GetOpacityFromRoot(void) const +{ + float opacity = __contentOpacity * __opacity * __showOpacity; + const _VisualElementImpl* pElement = __pParent; + while (pElement) + { + if (!VE_VISIBLE(pElement)) + { + return 0.0f; + } + + opacity *= pElement->__opacity * pElement->__showOpacity; + pElement = pElement->__pParent; + } + + return opacity; +} + +const FloatRectangle& +_VisualElementImpl::GetBoundingBoxI(void) const +{ + _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this); + + if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))) + { + pThis->RebuildCoordinates(); + } + + if (unlikely(!__boundingBoxValid)) + { +#if 0 + float x[4] = { 0.0f, __bounds.width, 0.0f, __bounds.width }; + float y[4] = { 0.0f, 0.0f, __bounds.height, __bounds.height }; + float z[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + + for (int i = 0; i < 4; i++) + { + _MatrixUtilTransform(GetMatrixToTop(), &x[i], &y[i], &z[i]); + } + + pThis->__boundingBox.SetBounds(x[0], y[0], x[0], y[0]); + + float l = x[0]; + float r = x[0]; + float t = y[0]; + float b = y[0]; + for (int i = 1; i < 4; i++) + { + if (x[i] < l) + { + l = x[i]; + } + + if (y[i] < t) + { + t = y[i]; + } + + if (x[i] > r) + { + r = x[i]; + } + + if (y[i] > b) + { + b = y[i]; + } + } + + pThis->__boundingBox.SetBounds(l, t, r - l, b - t); +#else + float x[4] = { 0.0f, __bounds.width, 0.0f, __bounds.width }; + float y[4] = { 0.0f, 0.0f, __bounds.height, __bounds.height }; + CalculateBoundingBox(x, y, pThis->__boundingBox); +#endif + + pThis->__boundingBoxValid = true; + } + + return __boundingBox; +} + +const FloatMatrix4& +_VisualElementImpl::GetMatrixToSuper(void) const +{ + if (unlikely(__matrixToSuperValid)) + return __matrixToSuper; + + + _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this); + + pThis->__matrixToSuperValid = true; + + if (unlikely(__pParent == null)) + { + _MatrixUtilSetIdentity(pThis->__matrixToSuper); + return __matrixToSuper; + } + + const bool needSurface = NEED_SURFACE(this); + + // apply subprojection && translation + if (likely(needSurface)) + { + MatrixUtilCopy(pThis->__matrixToSuper, __pParent->__childrenTransform); + _MatrixUtilTranslate(pThis->__matrixToSuper, __bounds.x, __bounds.y, __zPosition); + } + else + { + _MatrixUtilSetTranslation(pThis->__matrixToSuper, __bounds.x, __bounds.y, __zPosition); + } + + + // apply transform + if (likely(needSurface)) + { + if (likely(__decomposedTransform.GetMatrixType() != MATRIX4_Identity)) + { + bool needAnchor = (unlikely(__anchorZ != 0.0f) || unlikely(__anchor.x != 0.0f) || unlikely(__anchor.y != 0.0f)); + if (unlikely(needAnchor)) + _MatrixUtilTranslate(pThis->__matrixToSuper, __anchor.x * __bounds.width, __anchor.y * __bounds.height, __anchorZ); + + _MatrixUtilMultiply(pThis->__matrixToSuper, __matrixToSuper, __transform); + + if (unlikely(needAnchor)) + _MatrixUtilTranslate(pThis->__matrixToSuper, -__anchor.x * __bounds.width, -__anchor.y * __bounds.height, -__anchorZ); + } + } + + return __matrixToSuper; +} + +const FloatMatrix4& +_VisualElementImpl::GetMatrixToTop(void) const +{ + _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this); + + if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))) + { + pThis->RebuildCoordinates(); + } + + + if (unlikely(!__matrixToTopValid)) + { + _MatrixUtilMultiply(pThis->__matrixToTop, __pParent->GetMatrixToTop(), GetMatrixToSuper()); + pThis->__matrixToTopValid = true; + } + + return __matrixToTop; +} + +const FloatMatrix4& +_VisualElementImpl::GetMatrixFromTop(void) const +{ + _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this); + + if (IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)) + { + pThis->RebuildCoordinates(); + } + + if (!__matrixFromTopValid) + { + MatrixUtilCopy(pThis->__matrixFromTop, GetMatrixToTop()); + pThis->__matrixFromTopInvertible = _MatrixUtilInvert(pThis->__matrixFromTop); + pThis->__matrixFromTopValid = true; + } + + return __matrixFromTop; +} + +FloatMatrix4 +_VisualElementImpl::CalcMatrixToBase(const _VisualElementImpl& base) const +{ + if (this == &base) + return FloatMatrix4(); + + FloatMatrix4 matrixToBase(GetMatrixToSuper()); + + const _VisualElementImpl* pParent = GetParent(); + if (pParent) + { + pParent = pParent->GetParent(); + while (pParent) + { + _MatrixUtilMultiply(matrixToBase, pParent->GetMatrixToSuper(), matrixToBase); + pParent = pParent->GetParent(); + } + } + + return matrixToBase; +} + +const FloatMatrix4& +_VisualElementImpl::GetMatrixToClipSource(void) const +{ + _VisualElementImpl* pThis = const_cast< _VisualElementImpl* >(this); + + if (IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES)) + { + pThis->RebuildCoordinates(); + } + + + if (unlikely(!__matrixToClipSourceValid)) + { + if (likely(__pParent)) + { + if (__pParent->__isClipChildren) + { + MatrixUtilCopy(pThis->__matrixToClipSource, GetMatrixToSuper()); + } + else + { + _MatrixUtilMultiply(pThis->__matrixToClipSource, __pParent->GetMatrixToClipSource(), GetMatrixToSuper()); + } + } + else + { + _MatrixUtilSetIdentity(pThis->__matrixToClipSource); + } + + pThis->__matrixToClipSourceValid = true; + } + + return __matrixToClipSource; +} + +void +_VisualElementImpl::InvalidateVisibleRectToRenderTarget(const FloatRectangle* pDirtyRectangle) +{ + if (unlikely(GetSharedData().invalidationLockCount > 0)) + return; + + if (!IsDrawingObject()) + return; + + FloatRectangle bounds; + + bounds = __pPresentation->GetVisibleRect(); + if (pDirtyRectangle) + { + bounds = bounds.GetIntersection(*pDirtyRectangle); + } + + if (!bounds.IsEmpty()) + { + _VisualElementImpl* pRenderTarget = __pPresentation->GetRenderTarget(); + if (pRenderTarget) + { + pRenderTarget->ConvertCoordinates(bounds, this); + pRenderTarget->InvalidateRectangleI(&bounds); + } + } +} + +void +_VisualElementImpl::RebuildCoordinates(void) +{ + if (unlikely(!IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))) + { + return; + } + + SetPropsValidaty(HIERARCHY_PROPERTY_COORDINATES, 0); + + __visibleRect.x = 0.0f; + __visibleRect.y = 0.0f; + __visibleRect.width = __bounds.width; + __visibleRect.height = __bounds.height; + + + if (unlikely(!__pParent)) + { + // FIXME: + // Need to allowing transform to root element ! + + _MatrixUtilSetIdentity(__matrixToTop); + _MatrixUtilSetIdentity(__matrixFromTop); + _MatrixUtilSetIdentity(__matrixToClipSource); + __pClipSource = null; + + GetMatrixToSuper(); + + RectUtilCopy(__boundingBox, __bounds); + RectUtilCopy(__boundingBoxToClipSource, __bounds); + + _RootVisualElement* pRoot = dynamic_cast< _RootVisualElement* >(__pPublicInstance); + + if (likely(pRoot)) + { + __pRoot = pRoot->_pVisualElementImpl; + } + else + { + __pRoot = null; + } + + __needTransform = false; + __needClipForUntransformed = false; + + + __matrixFromTopValid = true; + __matrixToTopValid = true; + __matrixToClipSourceValid = true; + __matrixToSuperValid = true; + + __boundingBoxValid = true; + __visibleRectValid = true; + } + else + { + if (unlikely(__pParent->IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))) + { + __pParent->RebuildCoordinates(); + } + + __pRoot = __pParent->__pRoot; + + Matrix4Type transformType = __decomposedTransform.GetMatrixType(); + const Matrix4Type parentChildrenTransformType = __pParent->__decomposedChildrenTransform.GetMatrixType(); + + if (parentChildrenTransformType > MATRIX4_Translation) + transformType = MATRIX4_Generic; + + + if (unlikely(__pParent->__isClipChildren)) + { + __pClipSource = __pParent; + + __needTransform = (transformType > MATRIX4_Translation); + if (likely(!__needTransform)) + { + __boundingBoxToClipSource.x = __bounds.x + __transform.matrix[3][0]; + __boundingBoxToClipSource.y = __bounds.y + __transform.matrix[3][1]; + __boundingBoxToClipSource.width = __bounds.width; + __boundingBoxToClipSource.height = __bounds.height; + } + } + else + { + __pClipSource = __pParent->__pClipSource; + + if (unlikely(transformType > MATRIX4_Translation)) + __needTransform = true; + else + __needTransform = __pParent->__needTransform; + + if (likely(!__needTransform)) + { + __boundingBoxToClipSource.x = __pParent->__boundingBoxToClipSource.x + __bounds.x + __transform.matrix[3][0]; + __boundingBoxToClipSource.y = __pParent->__boundingBoxToClipSource.y + __bounds.y + __transform.matrix[3][1]; + __boundingBoxToClipSource.width = __bounds.width; + __boundingBoxToClipSource.height = __bounds.height; +#if 0 + if (unlikely(parentChildrenTransformType == MATRIX4_Translation)) + { + __boundingBoxToClipSource.x += __pParent->__childrenTransform.matrix[3][0]; + __boundingBoxToClipSource.y += __pParent->__childrenTransform.matrix[3][1]; + } +#endif + } + } + + if (likely(!__needTransform)) + { + if (unlikely(parentChildrenTransformType == MATRIX4_Translation)) + { + __boundingBoxToClipSource.x += __pParent->__childrenTransform.matrix[3][0]; + __boundingBoxToClipSource.y += __pParent->__childrenTransform.matrix[3][1]; + } + } + + __needClipForUntransformed = __pParent->__needClipForUntransformed; + if (likely(!__needClipForUntransformed) && likely(__pClipSource)) + { + if (likely(__boundingBoxToClipSource.x >= 0.0f) && + likely(__boundingBoxToClipSource.y >= 0.0f) && + likely(__boundingBoxToClipSource.x + __boundingBoxToClipSource.width <= __pClipSource->__bounds.width) && + likely(__boundingBoxToClipSource.y + __boundingBoxToClipSource.height <= __pClipSource->__bounds.height)) + __needClipForUntransformed = false; + else + __needClipForUntransformed = true; + } + else + { + __needClipForUntransformed = true; + } + + + __matrixFromTopValid = false; + __matrixToTopValid = false; + __matrixToClipSourceValid = false; + __matrixToSuperValid = false; + + __boundingBoxValid = false; + __visibleRectValid = false; + } +} + +void +_VisualElementImpl::RebuildVisibility(void) +{ + const int mask = HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_CONTENTOPACITY; + + if (unlikely(!IsPropsInvalidated(mask))) + { + return; + } + + if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))) + { + RebuildCoordinates(); + } + + + SetPropsValidaty(mask, 0); + + if (unlikely(!__pParent)) + { + // FIXME: + // Need to allowing transform to root element ! + + if(!__isRoot) + __isVisible = false; + else + __isVisible = VE_VISIBLE(this); + } + else + { + if (unlikely(__pParent->IsPropsInvalidated(mask))) + { + __pParent->RebuildVisibility(); + } + + if (likely(__pParent->__isVisible)) + __isVisible = VE_VISIBLE(this); + else + __isVisible = false; + } +} + +void +_VisualElementImpl::LockInvalidate(bool lock) +{ + GetSharedData().LockInvalidate(lock); +} + +void +_VisualElementImpl::InvalidateHierarchyPropsDownward(int invalidProps, bool broadcastToChildren, bool propagateToParentsOnly) +{ + invalidProps &= HIERARCHY_PROPERTY_MASK; + + __childrenNeedsUpdateProps |= invalidProps; + + if (likely(!propagateToParentsOnly)) + { + SetPropsValidaty(0, invalidProps); + + if (likely(invalidProps & HIERARCHY_PROPERTY_COORDINATES)) + { + __matrixFromTopValid = false; + __matrixToSuperValid = false; + __boundingBoxValid = false; + } + } + + if (unlikely(!broadcastToChildren)) + { + return; + } + + int count = __children.GetCount(); + for (int i = 0; i < count; i++) + { + __children.GetChildAt(i)->InvalidateHierarchyPropsDownward(invalidProps, broadcastToChildren, propagateToParentsOnly); + } + + // may need update some attribute variables for other hierarchy properties +} + +void +_VisualElementImpl::InvalidateHierarchyProps(int invalidProps, bool broadcastToChildren, bool propagateToParentsOnly) +{ + invalidProps &= HIERARCHY_PROPERTY_MASK; + +// // For model tree, it is not needed to invalidate children-opacity and show-state +// if (!IS_PRESENTATION(this)) +// { +// invalidProps &= ~(HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_SHOWSTATE); +// } + + if (unlikely(!invalidProps)) + { + return; + } + + InvalidateHierarchyPropsDownward(invalidProps, broadcastToChildren, propagateToParentsOnly); + + _VisualElementImpl* pElement = __pParent; // WARNING: 'this' is updated in '__InvalidateHierarchyPropsDownward' + while (pElement) + { + pElement->__childrenNeedsUpdateProps |= invalidProps; + pElement = pElement->__pParent; + } +} + +// HIERARCHY_PROPERTY_CONTENT is not handled here, but in drawing logic +void +_VisualElementImpl::RebuildHierarchyProps(int props, bool checkSurface, bool reconfSurfaceOnly) +{ + if (likely(__pParent) && (unlikely(__pParent->IsPropsInvalidated(props)) || unlikely(__pParent->GetSharedData().NeedNativeReconfigure()))) + { + // WARNING: + // 'checkSurface' for parent will make surface ! + __pParent->RebuildHierarchyProps(props, false, false); + } + + + // TBD: Recreating surface may have to be done in presentation layer (thread!) + if (unlikely(checkSurface)) + { + if (likely(IsDrawingObject())) + { + ResetSurfaceIfNeeded(); // may invalidate GetSharedData().surfaceChanged + } + } + + const bool needApplyNatives = GetSharedData().NeedNativeReconfigure(); + + props &= HIERARCHY_PROPERTY_MASK; + if (unlikely(!IsPropsInvalidated(props)) && likely(!checkSurface) && unlikely(needApplyNatives == 0)) + { + return; + } + + if (unlikely(props & HIERARCHY_PROPERTY_SURFACE) && unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_SURFACE))) + { + SetPropsValidaty(HIERARCHY_PROPERTY_SURFACE, 0); + } + + if (likely(props & HIERARCHY_PROPERTY_CONTENTBOUNDS) && likely(IsPropsInvalidated(HIERARCHY_PROPERTY_CONTENTBOUNDS))) + { + SetPropsValidaty(HIERARCHY_PROPERTY_CONTENTBOUNDS, 0); + } + + if (likely(props & HIERARCHY_PROPERTY_COORDINATES) && likely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))) + { + RebuildCoordinates(); + //__SetPropsValidaty(HIERARCHY_PROPERTY_COORDINATES, 0); --> need not. __RebuildCoordinates will validate. + } + + // WARNING: + // 'Visibility' should be checked after validating tree-hierarchy information. + // (For example, attaching/detaching may affect visibility.) + const int mask = HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_CONTENTOPACITY; + if (unlikely((props & mask) != 0) && unlikely(IsPropsInvalidated(props & mask))) + { + RebuildVisibility(); + } + + if (likely(__pPresentation) && likely(needApplyNatives)) + { + if (unlikely(!IS_PRESENTATION(this))) + { + // WARNING: + // In model, native nodes are updated only when the surface was changed. + //if (unlikely(GetSharedData().surfaceChanged)) + { + __pPresentation->FlushNativeChanges(); + } + } + else + { + GetSharedData().NodeReconfigure(*__pPresentation, false); + } + } +} + +void +_VisualElementImpl::FlushNativeChanges(void) +{ + if (unlikely(!IS_PRESENTATION(this))) + return; + + if (likely(__pPresentation)) + GetSharedData().NodeReconfigure(*__pPresentation, false); +} + +void +_VisualElementImpl::UpdateHierarchyProps(void) +{ + // WARNING: + // HIERARCHY_PROPERTY_CONTENT is not handled here, but in drawing logic. + const int mask = HIERARCHY_PROPERTY_MASK & (~HIERARCHY_PROPERTY_CONTENT); + + if (unlikely((__childrenNeedsUpdateProps & mask) == 0)) + return; + + // Node will be reconfigured later(before OnDraw, or DrawRectangle, ...) + if (likely(IsPropsInvalidated(mask)) || likely(GetSharedData().NeedNativeReconfigure())) + RebuildHierarchyProps(mask, false, false); + + // WARNING: + // __childrenNeedsUpdateProps should be cleared *ONLY AFTER* flushing native nodes ! + __childrenNeedsUpdateProps &= ~mask; + + int count = __children.GetCount(); + for (int i = 0; i < count; i++) + { + _VisualElementImpl* pChild = __children.GetChildAt(i); + if (likely((pChild->__childrenNeedsUpdateProps & mask) != 0)) + pChild->UpdateHierarchyProps(); + } +} + +void +_VisualElementImpl::ExposeRectangle(const FloatRectangle* pDirtyRectangle, bool invalidate) +{ + if (unlikely(!IsDrawingObject())) + return; + + if (unlikely(invalidate)) + { + InvalidateRectangleI(pDirtyRectangle); + } +#if 0 // exposing object without content changes is not needed for EFL + else + { + SetFlushNeeded(); + } +#endif +} + +result +_VisualElementImpl::SetFlushNeeded(void) +{ + FloatRectangle rect; + + if (!IS_PRESENTATION(this)) + { + return __pPresentation->SetFlushNeeded(); + } + + rect = __bounds; + rect.SetPosition(0.0f, 0.0f); + + if (likely(HAVE_SURFACE(this))) + { + GetSharedData().pNativeNode->SetFlushNeeded(); + } + else + { + _VisualElementImpl* pRenderTarget = GetRenderTarget(); + + if (likely(pRenderTarget && pRenderTarget->GetSharedData().pNativeNode)) + { + pRenderTarget->__pPresentation->ConvertCoordinates(rect, this->__pPresentation); + pRenderTarget->GetSharedData().pNativeNode->SetFlushNeeded(); + } + } + + return E_SUCCESS; +} + +result +_VisualElementImpl::Flush(void) +{ + if (likely(GetSharedData().pNativeNode)) + { + GetSharedData().pNativeNode->Flush(); + } + + return E_SUCCESS; +} + +result +_VisualElementImpl::InvalidateRectangle(const FloatRectangle* pRectangle) +{ +//!!! don't have to check attached state +// SysTryReturnResult(NID_UI_ANIM, IS_ATTACHED(this), E_INVALID_STATE, "Invalidating VisualElement should be attached to the root tree."); + + return InvalidateRectangleI(pRectangle); +} + +result +_VisualElementImpl::InvalidateRectangleI(const FloatRectangle* pRectangle) +{ + SysTryReturnResult(NID_UI_ANIM, !GetSharedData().fixedSurfaceSize, E_INVALID_OPERATION, "VisualElement with User-Surface do not allow invalidating and redrawing."); + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "Invalidating VisualElement should be performed on a model layer."); + + if (unlikely(GetSharedData().invalidationLockCount > 0)) + { + return E_SUCCESS; + } + + + FloatRectangle invRect; + + if (unlikely(pRectangle)) + { + if (unlikely(pRectangle->IsEmpty())) + { + return E_SUCCESS; + } + + invRect = *pRectangle; + } + else + { + invRect = __bounds; + invRect.SetPosition(0.0f, 0.0f); + } + + if (unlikely(invRect.IsEmpty())) + { + return E_SUCCESS; + } + + + // WARNING: + // 'GetUnion' method will not behave as our intention. + // If the parameter or self is empty, the union of rectangle should ignore it ! + //invRect = GetSharedData().invalidatedRegion.GetUnion(invRect); + RectUtilUnion(invRect, GetSharedData().invalidatedRegion); + + + // TODO: + // If new requested invalidate region is already included currently, + // we can skip the following calculations (but invalidating flags are STILL needed !) + + _VisualElementImpl* pRenderTarget = GetRenderTarget(); + + if (likely(pRenderTarget == this)) + { + // Make invalidated area a bit larger to be aligned on the render target + RectUtilMakeIntegral(invRect); + } + + GetSharedData().invalidatedRegion = invRect; + + InvalidateHierarchyProps(HIERARCHY_PROPERTY_CONTENT, false, false); + SetRootNeedsContentUpdate(); + + return E_SUCCESS; +} + +FloatRectangle +_VisualElementImpl::GetInvalidatedRectangle(void) const +{ + ClearLastResult(); + + if (IS_PRESENTATION(this)) + { + if (__pModel) + { + return __pModel->GetInvalidatedRectangle(); + } + } + + return GetSharedData().invalidatedRegion; +} + +FloatRectangle +_VisualElementImpl::GetUpdateRectangle(void) const +{ + ClearLastResult(); + + return GetSharedData().updateRegion; +} + +bool +_VisualElementImpl::IsOpaque(void) const +{ + ClearLastResult(); + + if (HAVE_SURFACE(this)) + { + return IsSurfaceOpaque(); + } + + return true; +} + +result +_VisualElementImpl::Draw(void) +{ + SysTryReturnResult(NID_UI_ANIM, IS_ATTACHED(this), E_INVALID_STATE, "Drawing VisualElement should be attached to the root tree."); + if (!IS_MODEL(this)) + { + //SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + } + + // WARNING: + // Not a good position to apply property changes into native(EFL) system. + // Because of no-compositor in VE, we cannot control each element's + // visibilities (show-state, bounds, opacity, etc.) ! + // Is there any good idea ? + // +// if (IS_PRESENTATION(this)) +// __UpdateHierarchyProps(); + + if (unlikely((__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT) != 0)) + { +// if (unlikely(!IS_PRESENTATION(this))) +// __UpdateHierarchyProps(); + + + // + // Drawing must be done from first opaque. + // But, because we assume all VE's are transparent, all drawings are done from root !!! + + _VisualElementImpl* pRenderTarget = GetRenderTarget(); + bool needFullScreenDraw = __isRoot; + + if (unlikely(!pRenderTarget)) + { + // On no render target, flush invalidated area from root + pRenderTarget = GetRoot(); + SysTryReturnResult(NID_UI_ANIM, pRenderTarget, E_SYSTEM, "A system error has been occurred. This VisualElement doesn't have rendering target."); + needFullScreenDraw = true; + } + + + // WARNING + // To minimize drawing area(with clip), use '__DrawRectangleIfNeeded' + // To reduce drawing calls such as 'OnDraw', use '__DrawRectangle' directly + // + int maxScreenSize = _Max(_VisualElementCoordinateSystem::logScreenWidth, _VisualElementCoordinateSystem::logScreenHeight); + pRenderTarget->DrawRectangleIfNeeded( + needFullScreenDraw ? FloatRectangle(0.0f, 0.0f, maxScreenSize, maxScreenSize) : GetDrawableRect() + ); + } + + if (IS_PRESENTATION(this)) + UpdateHierarchyProps(); + + return E_SUCCESS; +} + +void +_VisualElementImpl::DrawRectangleIfNeeded(const FloatRectangle& drawRect) +{ + if ((__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT) == 0 || unlikely(!IsVisibleI())) + { + return; + } + + // WARNING: + // VE with surface redraws *ALL INVALIDATED* region !! --> TBD: make an option/flags for this??? + // + FloatRectangle drawableRect; + + if (NEED_SURFACE(this)) + { + // WARNING: + // Redraw only if the request has some valid region to draw. + drawableRect = GetDrawableRect(); + if (!drawRect.IsIntersected(drawableRect)) + drawableRect.SetSize(0.0f, 0.0f); // Make empty + } + else + { + drawableRect = drawRect; + } + + DrawRectangle(drawableRect.GetIntersection(GetSharedData().invalidatedRegion)); + + // + // needUpdate flag may be 'true' after drawring invalidated region. + // This means that some children still need to be updated ! + // + if (likely((__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT) == 0)) + { + return; + } + + // + // Some children still need to update in case that invalidated rect of this + // is smaller than 'drawRect' which can overlap the invalid rect of children + // + + // + // Because user can do anything in drawing logic, + // adding-reference may be safe....... + // + _VisualElementImpl* pChild = null; + FloatRectangle updateRect, childBounds; + bool childrenNeedUpdate = false; + int count = __children.GetCount(); + for (int i = 0; i < count; i++) + { + pChild = __children.GetChildAt(i); + if (!pChild) + { + continue; + } + + if ((pChild->__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT) == 0) + { + continue; + } + + + // WARNING: + // Draw all children with surface. + // Children with empty invalidated region will ignore re-drawing. + + updateRect = drawRect; + pChild->__pPresentation->ConvertCoordinates(updateRect, this->__pPresentation); + + if (likely(NEED_SURFACE(pChild))) + { + pChild->DrawRectangleIfNeeded(updateRect); + } + else + { + childBounds = pChild->__pPresentation->__bounds; + childBounds.SetPosition(0.0f, 0.0f); + updateRect = updateRect.GetIntersection(childBounds); + if (unlikely(!updateRect.IsEmpty())) + pChild->DrawRectangleIfNeeded(updateRect); + } + + if ((pChild->__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT) != 0) + { + childrenNeedUpdate = true; + } + } + + // update 'needUpdate' flag regarding children only if no invalidated-region + if (GetSharedData().invalidatedRegion.IsEmpty()) + { + SetPropsValidaty(HIERARCHY_PROPERTY_CONTENT, 0); + if (childrenNeedUpdate) + { + __childrenNeedsUpdateProps |= HIERARCHY_PROPERTY_CONTENT; + } + else + { + __childrenNeedsUpdateProps &= ~HIERARCHY_PROPERTY_CONTENT; + } + } +} + +// TODO: change name(remove 'rectangle') +void +_VisualElementImpl::DrawRectangle(const FloatRectangle& drawRect) +{ + if (unlikely(!GetRootPublic()) || unlikely(!IsVisibleI()) || unlikely(drawRect.IsEmpty())) + { + return; + } + + //SysLog(NID_UI_ANIM, "DrawRectangle"); + + bool needDraw = false; + bool fullValidated = false; + FloatRectangle drawableRect(GetDrawableRect()); + FloatRectangle drawRectVisible(drawRect.GetIntersection(drawableRect)); + FloatRectangle invalidatedRectVisible(GetSharedData().invalidatedRegion.GetIntersection(drawableRect)); + + if (unlikely(!drawRectVisible.IsEmpty())) + { +#if 0 + // Draw full-invalidated-content (not partial) if VE has surface. + if (likely(NEED_SURFACE(this))) + drawRectVisible = drawableRect; +#endif + + needDraw = true; + } + + // WARNING: + // Make dirty/draw area a bit larger to be pixel-aligned and prevent drawing-artifacts caused by float-error. + RectUtilMakeIntegral(drawRectVisible); + RectUtilMakeIntegral(invalidatedRectVisible); + + // DO NOT USE drawRectVisible.Contains(invalidatedRectVisible)) + if (invalidatedRectVisible.IsEmpty() || (drawRectVisible.x <= invalidatedRectVisible.x && + drawRectVisible.y <= invalidatedRectVisible.y && + drawRectVisible.x + drawRectVisible.width >= invalidatedRectVisible.x + invalidatedRectVisible.width && + drawRectVisible.y + drawRectVisible.height >= invalidatedRectVisible.y + invalidatedRectVisible.height)) + { + fullValidated = true; + } + + + + // WARNING: + // VisualElement with User-Set surface does not allow invalidating and redrawing. + // Because there should be no invalidated region in this case, checking User-Surface may redundant. + // + if (GetSharedData().fixedSurfaceSize) + { + needDraw = false; + fullValidated = true; + drawRectVisible = GetSharedData().invalidatedRegion; + } + + + // WARNING: + // Set update region before 'CanDraw' and 'OnDraw' delegations to check real-update region + // + GetSharedData().updateRegion = drawRectVisible; + + if (fullValidated) + { + // WARNING: + // Clear *BEFORE* drawing because 'OnDraw' may add invalidated regions... + // + GetSharedData().invalidatedRegion.SetBounds(0.0f, 0.0f, 0.0f, 0.0f); // SetEmpty() + + SetPropsValidaty(HIERARCHY_PROPERTY_CONTENT, 0); + __childrenNeedsUpdateProps &= ~HIERARCHY_PROPERTY_CONTENT; + } + + + if (needDraw) + { + if (!VE_DELEGATE(this, InvokePrepareDraw)) + { + needDraw = false; + } + } + + if (needDraw) + { + Canvas* pCanvas = null; + pCanvas = GetCanvasN(); + + if (pCanvas) + { + result r = pCanvas->SetClipBounds(Rectangle(drawRectVisible.x, + drawRectVisible.y, + drawRectVisible.width, + drawRectVisible.height)); + if (IsFailed(r)) + { + SysLogException(NID_UI_ANIM, r, "[%s] Failed to set clip-bounds on canvas", GetErrorMessage(r)); + } + + VE_DELEGATE(this, InvokeOnDraw, *pCanvas); + delete pCanvas; + } + + // WARNING: + // Flushing canvas is done at GetCanvasN. + // + //SetFlushNeeded(); + } + + + // Clear update region after drawing + GetSharedData().updateRegion.SetBounds(0.0f, 0.0f, 0.0f, 0.0f); + + + // + // Because user can do anything in drawing logic, + // adding-reference/copying-list may be safe....... + // + _VisualElementImpl* pChild = null; + int count = __children.GetCount(); + bool childrenNeedUpdate = false; + FloatRectangle childBounds; + for (int i = 0; i < count; i++) + { + pChild = __children.GetChildAt(i); + if (likely(!NEED_SURFACE(pChild))) + { + drawRectVisible = drawRect; + pChild->__pPresentation->ConvertCoordinates(drawRectVisible, this->__pPresentation); + childBounds = pChild->__pPresentation->__bounds; + + childBounds.SetPosition(0.0f, 0.0f); + + drawRectVisible = drawRectVisible.GetIntersection(childBounds); + if (likely(!drawRectVisible.IsEmpty())) + pChild->DrawRectangle(drawRectVisible); + } + + if ((pChild->__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT) != 0) + { + childrenNeedUpdate = true; + } + } + + // + // If not all children have been validated during update, + // we should not clear update flag to flush them later. + // + if (childrenNeedUpdate) + { + __childrenNeedsUpdateProps |= HIERARCHY_PROPERTY_CONTENT; + } +} + +// for a cumstom property animation +result +_VisualElementImpl::SetPropertyI(const String& property, const Variant& value) +{ + result r = E_SUCCESS; + + if (likely(__pPublicInstance)) + { + r = __pPublicInstance->OnSetPropertyRequested(property, value); + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_VisualElementImpl::InvokeOnSetPropertyRequested(const String& property, const Variant& value) +{ + SysTryReturnResult(NID_UI_ANIM, IS_MODEL(this), E_INVALID_OPERATION, "VisualElement is not Model object."); + result r = E_SUCCESS; + + if (likely(__pPublicInstance)) + { + r = __pPublicInstance->OnSetPropertyRequested(property, value); + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +int +_VisualElementImpl::HitTestI(const FloatPoint& point) +{ + if (!IsVisibleI()) + { + return HITTEST_NOWHERE; + } + + if (//NEED_SURFACE(&target) && + !GetSharedData().isSurfaceOpaque && + _FloatHardCompare(GetOpacityFromRoot(), 0.0f)) + { + return HITTEST_NOWHERE; + } + + if (!GetVisibleRect().Contains(point)) + { + return HITTEST_NOWHERE; + } + + _VisualElementImpl* pClipSource = GetClipSource(); + while (pClipSource) + { + FloatPoint pt = point; + pClipSource->ConvertCoordinates(pt, this); + + if (!pClipSource->GetVisibleRect().Contains(pt)) + { + return HITTEST_NOWHERE; + } + else + { + pClipSource = pClipSource->GetClipSource(); + } + } + + return HITTEST_MATCH; +} + +_VisualElementImpl* +_VisualElementImpl::GetChildAtPointI(const FloatPoint& point, int parentHitTest) +{ + _VisualElementImpl* pHitTarget = null; + FloatPoint hitPoint = point; + int hitTest; + + hitTest = VE_DELEGATE(this, InvokeHitTest, point); + if ((hitTest & HITTEST_MATCH) != 0) + { + // passed hittest + pHitTarget = this; + } + + if ((hitTest & HITTEST_NOMORECHILDREN) == 0) + { + int count = __children.GetCount(); + for (int i = count - 1; i >= 0; i--) // from top to bottom + { + _VisualElementImpl* pChild = __children.GetChildAt(i); + if (!pChild) + { + continue; + } + + FloatPoint childHitPoint = point; + pChild->ConvertCoordinates(childHitPoint, this); + + _VisualElementImpl* pChildHitTarget = pChild->GetChildAtPointI(childHitPoint, hitTest); + if (pChildHitTarget) + { + pHitTarget = pChildHitTarget; + hitPoint = childHitPoint; + break; + } + } + } + + + if (pHitTarget) + { +// point = hitPoint; + return pHitTarget; + } + + return null; +} + +// WARNING: +// Because Hit-Testing from self, clipping flags of self will be ignored. +// +_VisualElementImpl* +_VisualElementImpl::GetChildAt(const FloatPoint& point) +{ + _VisualElementImpl* pHitTarget = GetChildAtPointI(point, HITTEST_MATCH); + if (unlikely(!pHitTarget)) + { + SetLastResult(E_OBJ_NOT_FOUND); + } + else + { + ClearLastResult(); + } + + return pHitTarget; +} + +result +_VisualElementImpl::ScrollByPoint(const FloatPoint& pointOffset, bool scrollSelf) +{ + if (_FloatCompare(pointOffset.x, 0.0f) && _FloatCompare(pointOffset.y, 0.0f)) + { + return E_SUCCESS; + } + + result r; + FloatMatrix4 xform = __childrenTransform; + FloatMatrix4 xformOrg = xform; + FloatRectangle rectInvalidated; + + _MatrixUtilTranslate(xform, pointOffset.x, pointOffset.y, 0.0f); + + if (HAVE_SURFACE(this)) + { + int count = __children.GetCount(); + + LockInvalidate(true); + for (int i = 0; i < count; i++) + { + __children.GetChildAt(i)->LockInvalidate(true); + } + + r = SetChildrenTransformMatrix(xform); + + LockInvalidate(false); + for (int i = 0; i < count; i++) + { + __children.GetChildAt(i)->LockInvalidate(false); + } + } + else + { + r = SetChildrenTransformMatrix(xform); + } + + SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, E_SYSTEM, "Failed to translate matrix for scrolling "); + + if (!NEED_SURFACE(this)) + { + InvalidateVisibleRectToRenderTarget(null); + } + else if (scrollSelf) + { + Canvas* pCanvas = null; + _CanvasImpl* pCanvasImpl = null; + + pCanvas = GetCanvasN(); // TODO: clip rect...... + if (pCanvas) + { + pCanvasImpl = _CanvasImpl::GetInstance(*pCanvas); + if (pCanvasImpl) + { + Point pointDest; + Rectangle rectSource; + + rectSource.SetBounds(0, 0, __bounds.width, __bounds.height); + + rectInvalidated = __bounds; + rectInvalidated.SetPosition(0.0f, 0.0f); + if (pointOffset.x > 0) + { + rectSource.width -= pointOffset.x; + pointDest.x = pointOffset.x; + rectInvalidated.width = pointOffset.x; + } + else + { + rectSource.x += -pointOffset.x; + rectSource.width -= -pointOffset.x; + pointDest.x = 0; + rectInvalidated.x = rectSource.width; + rectInvalidated.width = -pointOffset.x; + } + + InvalidateVisibleRectToRenderTarget(&rectInvalidated); + + + rectInvalidated = __bounds; + rectInvalidated.SetPosition(0.0f, 0.0f); + if (pointOffset.y > 0) + { + rectSource.height -= pointOffset.y; + pointDest.y = pointOffset.y; + rectInvalidated.height = pointOffset.y; + } + else + { + rectSource.y += -pointOffset.y; + rectSource.height -= -pointOffset.y; + pointDest.y = 0; + rectInvalidated.y = rectSource.height; + rectInvalidated.height = -pointOffset.y; + } + + InvalidateVisibleRectToRenderTarget(&rectInvalidated); + + + r = pCanvasImpl->CopyEx(pointDest, *pCanvasImpl, rectSource); + if (r != E_SUCCESS) + { + // revert... + SysLogException(NID_UI_ANIM, r, "[%s] Can't copy area.", GetErrorMessage(r)); + SetChildrenTransformMatrix(xformOrg); // ??????????????????? + } + else + { + SetFlushNeeded(); + } + } + + delete pCanvas; + } + } + + return r; +} + +result +_VisualElementImpl::ConvertCoordinates(FloatPoint& point, const _VisualElementImpl* pFromElement) const +{ + if (unlikely(this == pFromElement)) + { + return E_SUCCESS; + } + + _VisualElementImpl* pFromRoot = null; + float x = point.x; + float y = point.y; + float z = 0.0f; + + if (likely(pFromElement)) + { + pFromRoot = pFromElement->GetRoot(); + SysTryReturnResult(NID_UI_ANIM, GetRoot() == pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement and pFromElement is not belong to the same tree."); + SysTryReturnResult(NID_UI_ANIM, pFromRoot || pFromElement->IsChildOf(*this) || IsChildOf(*pFromElement), + E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and pFromElement(%p) is not related.", this, pFromElement); + } + else + { + pFromRoot = GetRoot(); + SysTryReturnResult(NID_UI_ANIM, pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement is not attached to main tree."); + } + + + const FloatMatrix4& toTopMatrix = (pFromElement ? pFromElement->GetMatrixToTop() : pFromRoot->GetMatrixToTop()); + _MatrixUtilTransform(toTopMatrix, &x, &y, &z); + + if (this != pFromRoot) + { + const FloatMatrix4& fromTopMatrix = GetMatrixFromTop(); + + if (!__matrixFromTopInvertible) + return E_INVALID_OPERATION; + + + // WARNING: + // We should calculate z of world-coordinate mapped x-y plane of depth==0 in VE coordinate ! + z = -(fromTopMatrix.matrix[0][2] * x + fromTopMatrix.matrix[1][2] * y + fromTopMatrix.matrix[3][2]) / fromTopMatrix.matrix[2][2]; + + _MatrixUtilTransform(fromTopMatrix, &x, &y, &z); + } + + + point.SetPosition(x, y); // z is omitted + + return E_SUCCESS; +} + +result +_VisualElementImpl::ConvertCoordinates(FloatRectangle& rectangle, const _VisualElementImpl* pFromElement) const +{ + if (unlikely(this == pFromElement)) + { + return E_SUCCESS; + } + + _VisualElementImpl* pFromRoot = null; + float x[4] = { rectangle.x, rectangle.x + rectangle.width, rectangle.x, rectangle.x + rectangle.width }; + float y[4] = { rectangle.y, rectangle.y, rectangle.y + rectangle.height, rectangle.y + rectangle.height }; + float z[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + + if (likely(pFromElement)) + { + pFromRoot = pFromElement->GetRoot(); + SysTryReturnResult(NID_UI_ANIM, GetRoot() == pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement and pFromElement is not belong to the same main tree."); + SysTryReturnResult(NID_UI_ANIM, pFromRoot || pFromElement->IsChildOf(*this) || IsChildOf(*pFromElement), + E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and pFromElement(%p) is not related.", this, pFromElement); + } + else + { + pFromRoot = GetRoot(); + SysTryReturnResult(NID_UI_ANIM, pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement is not attached to main tree."); + } + + const FloatMatrix4& toTopMatrix = (pFromElement ? pFromElement->GetMatrixToTop() : pFromRoot->GetMatrixToTop()); + + for (int i = 0; i < 4; i++) + { + _MatrixUtilTransform(toTopMatrix, &x[i], &y[i], &z[i]); + } + + if (this != pFromRoot) + { + const FloatMatrix4& fromTopMatrix = GetMatrixFromTop(); + + if (!__matrixFromTopInvertible) + return E_INVALID_OPERATION; + + for (int i = 0; i < 4; i++) + { + // WARNING: + // We should calculate z of world-coordinate mapped x-y plane of depth==0 in VE coordinate ! + z[i] = -(fromTopMatrix.matrix[0][2] * x[i] + fromTopMatrix.matrix[1][2] * y[i] + fromTopMatrix.matrix[3][2]) / fromTopMatrix.matrix[2][2]; + _MatrixUtilTransform(fromTopMatrix, &x[i], &y[i], &z[i]); + } + + } + + CalculateBoundingBox(x, y, rectangle); + + return E_SUCCESS; +} + +result +_VisualElementImpl::ConvertCoordinates(float* x, float* y, float* z, int count, const _VisualElementImpl* pFromElement) const +{ + if (unlikely(this == pFromElement) || unlikely(count <= 0)) + { + return E_SUCCESS; + } + + _VisualElementImpl* pFromRoot = null; + + if (likely(pFromElement)) + { + pFromRoot = pFromElement->GetRoot(); + SysTryReturnResult(NID_UI_ANIM, GetRoot() == pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement and pFromElement is not belong to the same main tree."); + SysTryReturnResult(NID_UI_ANIM, pFromRoot || pFromElement->IsChildOf(*this) || IsChildOf(*pFromElement), + E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement(%p) and pFromElement(%p) is not related.", this, pFromElement); + } + else + { + pFromRoot = GetRoot(); + SysTryReturnResult(NID_UI_ANIM, pFromRoot, E_INVALID_ARG, "Invalid argument(s) is used. This VisualElement is not attached to main tree."); + } + + + bool isUpwardConvertOnly = (pFromElement && pFromElement->IsChildOf(*this)); + const FloatMatrix4& toTopMatrix = (isUpwardConvertOnly ? pFromElement->CalcMatrixToBase(*this) : + pFromElement ? pFromElement->GetMatrixToTop() : pFromRoot->GetMatrixToTop()); + + for (int i = 0; i < count; i++) + { + _MatrixUtilTransform(toTopMatrix, &x[i], &y[i], &z[i]); + } + + if (!isUpwardConvertOnly) + { + const FloatMatrix4& fromTopMatrix = GetMatrixFromTop(); + + if (!__matrixFromTopInvertible) + return E_INVALID_OPERATION; + + for (int i = 0; i < count; i++) + { + // WARNING: + // We should calculate z of world-coordinate mapped x-y plane of depth==0 in VE coordinate ! + z[i] = -(fromTopMatrix.matrix[0][2] * x[i] + fromTopMatrix.matrix[1][2] * y[i] + fromTopMatrix.matrix[3][2]) / fromTopMatrix.matrix[2][2]; + _MatrixUtilTransform(fromTopMatrix, &x[i], &y[i], &z[i]); + } + } + + return E_SUCCESS; +} + +result +_VisualElementImpl::CaptureI(Canvas& outputCanvas, const FloatRectangle& rectDest, _VisualElementImpl& reference, const FloatRectangle& clipRect, bool withChilren, int depth) +{ + _CanvasImpl* pOutput = _CanvasImpl::GetInstance(outputCanvas); + + SysTryReturnResult(NID_UI_ANIM, pOutput, E_INVALID_ARG, "Invalid argument(s) is used. Output canvas is invalid."); + SysTryReturnResult(NID_UI_ANIM, GetRoot(), E_INVALID_STATE, "Invalid argument(s) is used. VisualElement is not attached to main tree."); + + FloatRectangle bounds = __bounds;//GetDrawableRect(); + + bounds.x = 0.0f; + bounds.y = 0.0f; + + reference.ConvertCoordinates(bounds, this); + FloatRectangle drawRect = bounds; + + _VisualElementImpl* pRenderTarget = this->GetRenderTarget(); + drawRect = bounds.GetIntersection(clipRect); + + FloatRectangle tempRect = drawRect; + + + drawRect.x -= bounds.x; + drawRect.y -= bounds.y; //--> 0 - -20 = 20 : 20 - 20 = 0 + + + bounds = tempRect; + + if (!drawRect.IsEmpty()) + { + if (pRenderTarget && HAVE_SURFACE(pRenderTarget)) // If element have surface , justly draw to the canvas + { + //Canvas* pCanvas = GetCanvasN(elementbounds); +#ifdef USE_CANVAS_FOR_CAPTURE + Canvas* pCanvas = GetCanvasN(); + if (pCanvas) + { + Bitmap bitmap; + bitmap.Construct(*pCanvas, Rectangle(drawRect.x, drawRect.y, drawRect.width, drawRect.height)); + bitmap.SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot()*255)); + + Point point; + point.x = rectDest.x + bounds.x; + point.y = rectDest.y + bounds.y; + outputCanvas.DrawBitmap(point, bitmap); + delete pCanvas; + +#else + if (__pSharedData->pSurface) + { + BufferInfo info; + __pSharedData->pSurface->GetBufferInfo(info); + + _VisualElementSurfaceImpl* pSurfImpl = _VisualElementSurfaceImpl::GetInstance(*__pSharedData->pSurface); + + if(pSurfImpl && pSurfImpl->GetNativeHandle()) + { + byte* pStart = (byte*)evas_object_image_data_get((Evas_Object*)pSurfImpl->GetNativeHandle(), false); + + if(pStart) + { + byte* pCopy = new (std::nothrow) byte[info.height*(info.pitch)]; + if (pCopy) + { + memcpy(pCopy, pStart, info.height*(info.pitch)); + + for (int y = 0; y < info.height; y++) + { + for (int x = 0; x < info.width; x++) + { + unsigned int* pAddr = (unsigned int*)((unsigned char*)pCopy + info.pitch * y + x * 4); + int a = ((*pAddr) >> 24) & 0xff; + int r = ((*pAddr) >> 16) & 0xff; + int g = ((*pAddr) >> 8) & 0xff; + int b = ((*pAddr) >> 0) & 0xff; + if (a > 0) + { + float fa = (float)a / 255.0f; + r = r / fa; + g = g / fa; + b = b / fa; + *pAddr = (a << 24) | (r << 16) | (g << 8) | b; + } + } + } + + ByteBuffer buffer; + result r = buffer.Construct(pCopy, 0, info.height*(info.pitch), info.height*(info.pitch)); + + if (r == E_SUCCESS) + { + Bitmap* pBitmap = Bitmap::GetNonScaledBitmapN(buffer, Dimension(info.width, info.height), BITMAP_PIXEL_FORMAT_ARGB8888); + if (pBitmap) + { + pBitmap->SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot() * 255.0f)); + Rectangle outputR(drawRect.x, drawRect.y, drawRect.width, drawRect.height); + Rectangle srcRect = outputR; + outputR.x = rectDest.x + bounds.x; + outputR.y = rectDest.y + bounds.y; + outputCanvas.DrawBitmap(outputR, *pBitmap, srcRect); + + delete pBitmap; + } + } + + delete [] pCopy; + } + } + } +#endif + } + } + else + { + _EflNode* pNativeNode = dynamic_cast< _EflNode* >(GetNativeNode()); + + SysTryReturnResult(NID_UI_ANIM, pNativeNode, E_INVALID_STATE, "No object for background"); // CHECKME: Default BG? + _Colorf bgcolorf = pNativeNode->GetBackgroundColor(); + Color color(bgcolorf.Red()*255, bgcolorf.Green()*255, bgcolorf.Blue()*255, bgcolorf.Alpha()*255); + + Point point; + point.x = rectDest.x + bounds.x; + point.y = rectDest.y + bounds.y; + + //pOutput->FillRectangle(color, Rectangle(drawRect.x + bounds.x, drawRect.y + bounds.y, drawRect.width, drawRect.height)); + pOutput->FillRectangle(color, Rectangle(point.x, point.y, drawRect.width, drawRect.height)); + } + } + + if (withChilren) // child draw + { + _VisualElementImpl* pChild = null; + + FloatRectangle clipBounds = clipRect; + + int count = __children.GetCount(); + + if(count > 0 && __isClipChildren) + { + clipBounds = clipRect.GetIntersection(bounds); + } + + for (int i = 0; i < count; i++) + { + pChild = __children.GetChildAt(i); + if (unlikely(!pChild) || unlikely(!VE_VISIBLE(pChild))) + { + continue; + } + pChild->CaptureI(outputCanvas, rectDest, reference, clipBounds, true, depth + 1); + } + } + + return E_SUCCESS; +} + + + +result +_VisualElementImpl::Capture(Canvas& outputCanvas, const FloatRectangle& rectDest, bool withChildren) +{ + FloatRectangle tempDestRect = rectDest; + tempDestRect.x = __bounds.x; + tempDestRect.y = __bounds.y; + FloatRectangle clipBounds = __bounds; + + clipBounds = tempDestRect.GetIntersection(__bounds); + clipBounds.x = 0; + clipBounds.y = 0; + + if(!VE_VISIBLE(this)) + return E_SUCCESS; + + return CaptureI(outputCanvas, rectDest, *this, clipBounds, withChildren, 0); +// test boundray +// Rectangle cBounds = outputCanvas.GetBounds(); +// outputCanvas.SetForegroundColor(Color(10,110,20)); +// outputCanvas.DrawRectangle(Rectangle(cBounds.x+1,cBounds.y+1,cBounds.width-2,cBounds.height-2)); +// outputCanvas.SetForegroundColor(Color(10,20,20)); +// outputCanvas.DrawRectangle(Rectangle(rectDest.x+1,rectDest.y+1,rectDest.width-2,rectDest.height-2)); +// return E_SUCCESS; +} +#if 0 +result +_VisualElementImpl::Capture(Canvas& outputCanvas, const FloatRectangle& rectDest, bool withChildren) +{ + result r = E_SUCCESS; + + Rectangle rect; + + rect.x = rectDest.x; + rect.y = rectDest.y; + rect.width = rectDest.width; + rect.height = rectDest.height; + + if (!withChildren) + { + Canvas* pCanvas = GetCanvasN(); + if (pCanvas) + { + r = outputCanvas.Copy(Point(0,0), *pCanvas, rect); + delete pCanvas; + return r; + } + + return GetLastResult(); + } + else + { + _EflNode* pNode = dynamic_cast<_EflNode*>(GetNativeNode()); + SysTryReturnResult(pNode, E_INVALID_STATE, "VisualElement is invalid."); + if (pNode) + { + r = pNode->Capture(outputCanvas, Point(0,0), rect); + } + + SysTryReturn(r == E_SUCCESS, r, r,"[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} +#endif +result +_VisualElementImpl::AddAnimation(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation) +{ + SysTryReturnResult(NID_UI_ANIM, !IS_PRESENTATION(this), E_INVALID_OPERATION, "This is not model."); + + result r = E_SUCCESS; + + bool isPropertyPropagationEnabled = __isPropertyPropagationEnabled; + + __isPropertyPropagationEnabled = false; + + if (dynamic_cast< VisualElementAnimationGroup* >(&animation) != null) + { + VisualElementAnimation* pCloned = animation.CloneN(); + SysTryReturnResult(NID_UI_ANIM, pCloned != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = AddAnimationGroupI(pKeyName, *pCloned); + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + if (r != E_SUCCESS) + { + delete pCloned; + } + } + else + { + r = AddAnimationI(pKeyName, animation); + SysTryLog(NID_UI_ANIM, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + } + + __isPropertyPropagationEnabled = isPropertyPropagationEnabled; + + return r; +} + +result +_VisualElementImpl::AddAnimationI(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation) +{ + result r = E_SUCCESS; + + IVisualElementAnimationTickEventListener* pTickListener = null; + + // Validate + VisualElementValueAnimation* pValueAnimation = dynamic_cast< VisualElementValueAnimation* >(&animation); + if (pValueAnimation != null) + { + _VisualElementValueAnimationImpl* pValueAnimationImpl = _VisualElementValueAnimationImpl::GetInstance(*pValueAnimation); + SysTryReturnResult(NID_UI_ANIM, (pValueAnimationImpl->IsValid()), E_INVALID_ARG, "Invalid argument(s) is used. Animation value is invalid."); + + pTickListener = pValueAnimationImpl->GetTickEventListener(); + } + + // Copy animation + VisualElementAnimation* pCloned = animation.CloneN(); + SysTryReturnResult(NID_UI_ANIM, (pCloned != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + _VisualElementAnimationImpl* pAnimationImpl = _VisualElementAnimationImpl::GetInstance(*pCloned); + + if (pAnimationImpl->GetStatusEventListener() != null || pTickListener != null) + { + pAnimationImpl->SetEventTarget(*GetPublic()); + } + + // Use presentation tree for animation + VisualElement* pPresentation = __pPresentation->__pPublicInstance; + + r = _AnimationManager::GetInstance()->AddAnimation(*pPresentation, pKeyName, *pCloned); + if (r != E_SUCCESS) + { + SysTryLog(NID_UI_ANIM, "[%s] Failed to add animation.", GetErrorMessage(r)); + + delete pCloned; + return r; + } + + // Change model tree value if endValueApplied is true + VisualElementPropertyAnimation* pPropertyAnimation = dynamic_cast< VisualElementPropertyAnimation* >(pCloned); + + if (pPropertyAnimation + && pPropertyAnimation->IsEndValueApplied() + && !pPropertyAnimation->IsAutoReverseEnabled() + && pPropertyAnimation->GetRepeatCount() != 0) + { + const String& propertyName = pPropertyAnimation->GetPropertyName(); + const Variant& endValue = pPropertyAnimation->GetEndValue(); + + if (endValue.IsEmpty() == false && InvokeOnGetPropertyRequested(propertyName) != endValue) + { + (void) InvokeOnSetPropertyRequested(propertyName, endValue); + } + } + + return E_SUCCESS; +} + +result +_VisualElementImpl::AddAnimationGroupI(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation) +{ + _AnimationManager* pAnimationManager = _AnimationManager::GetInstance(); + + // Get presentation tree + VisualElement* pPresentation = __pPresentation->__pPublicInstance; + + VisualElementAnimationGroup* pAnimationGroup = dynamic_cast< VisualElementAnimationGroup* >(&animation); + + SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup != null), E_INVALID_ARG, "Invalid argument(s) is used. Failed to add animation group."); + SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup->GetAnimationCount() > 0), E_INVALID_ARG, "Invalid argument(s) is used. Animation group has no animation."); + + _VisualElementAnimationGroupImpl* pAnimationGroupImpl = _VisualElementAnimationGroupImpl::GetInstance(*pAnimationGroup); + + if (pAnimationGroupImpl->GetStatusEventListener() != null) + { + pAnimationGroupImpl->SetEventTarget(*GetPublic()); + } + + result r = E_SUCCESS; + + VisualElementAnimation* pAnimation = null; + Tizen::Base::String name; + int animationCount = 0; + + int transactionID = pAnimationManager->BeginGroupTransaction(*pPresentation, pKeyName, *pAnimationGroup); + + r = GetLastResult(); + SysTryCatch(NID_UI_ANIM, (transactionID > 0), , r, "[%s] Transaction is not created.", GetErrorMessage(r)); + + animationCount = pAnimationGroupImpl->GetAnimationCount(); + + for (int index = 0; index < animationCount; index++) + { + pAnimation = pAnimationGroupImpl->GetAnimation(index); + + if (pAnimation == null) + { + continue; + } + + if (dynamic_cast< VisualElementAnimationGroup* >(pAnimation) != null) + { + r = AddAnimationGroupI(&name, *pAnimation); + } + else + { + r = AddAnimationI(&name, *pAnimation); + } + + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] animation manager is null.", GetErrorMessage(r)); + } + + pAnimationManager->CommitTransaction(); + + return E_SUCCESS; + +CATCH: + + if (transactionID > 0) + { + pAnimationManager->CancelTransaction(transactionID); + } + + return r; +} + +result +_VisualElementImpl::RemoveAnimation(const Tizen::Base::String& keyName) +{ + VisualElement* pPresentation = __pPresentation->__pPublicInstance; + + return _AnimationManager::GetInstance()->RemoveAnimation(*pPresentation, keyName); +} + +result +_VisualElementImpl::RemoveAllAnimations(void) +{ + VisualElement* pPresentation = __pPresentation->__pPublicInstance; + + _AnimationManager::GetInstance()->RemoveAllAnimations(*pPresentation); + + return E_SUCCESS; +} + +VisualElementAnimation* +_VisualElementImpl::GetAnimationN(const Tizen::Base::String& keyName) const +{ + VisualElement* pPresentation = __pPresentation->__pPublicInstance; + + ClearLastResult(); + + return _AnimationManager::GetInstance()->GetAnimationN(*pPresentation, keyName); +} + +VisualElementAnimation* +_VisualElementImpl::GetAnimationForPropertyN(const Tizen::Base::String& property) const +{ + VisualElement* pPresentation = __pPresentation->__pPublicInstance; + + ClearLastResult(); + + return _AnimationManager::GetInstance()->GetAnimationForPropertyN(*pPresentation, property); +} + +bool +_VisualElementImpl::CheckIfAnimatable(const String& property) const +{ + // TODO: + // Optimize using map or other algorithms ! + // + +#if 0 + static const wchar_t* supportedProperties[] = { + VeSubPropTransformScaleXY, + + VePropBounds, + VePropContentOpacity, + VePropOpacity, + VePropTransform, + VePropChildrenTransform, + VePropZPosition, // TBD: + VeSubPropBoundsPosition, + VeSubPropBoundsSize, + + VeSubPropTransformRotationX, + VeSubPropTransformRotationY, + VeSubPropTransformRotationZ, + VeSubPropTransformRotationXY, + VeSubPropTransformScaleX, + VeSubPropTransformScaleY, + VeSubPropTransformScaleZ, + + VeSubPropTransformTranslationX, + VeSubPropTransformTranslationY, + VeSubPropTransformTranslationZ, + VeSubPropTransformTranslationXY, + VeSubPropChildrenTransformRotationX, + VeSubPropChildrenTransformRotationY, + VeSubPropChildrenTransformRotationZ, + VeSubPropChildrenTransformRotationXY, + VeSubPropChildrenTransformScaleX, + VeSubPropChildrenTransformScaleY, + VeSubPropChildrenTransformScaleZ, + VeSubPropChildrenTransformScaleXY, + VeSubPropChildrenTransformTranslationX, + VeSubPropChildrenTransformTranslationY, + VeSubPropChildrenTransformTranslationZ, + VeSubPropChildrenTransformTranslationXY + }; +#else + static String* const* supportedProperties[] = { + &pVePropBounds, + &pVePropContentOpacity, + &pVePropOpacity, + &pVePropTransform, + &pVePropChildrenTransform, + &pVePropZPosition, // TBD: + &pVeSubPropBoundsPosition, + &pVeSubPropBoundsSize, + + &pVePropContentBounds, +#if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION) + &pVePropActionDetach, + &pVePropActionAttach, +#endif + &pVeSubPropTransformRotationX, + &pVeSubPropTransformRotationY, + &pVeSubPropTransformRotationZ, + &pVeSubPropTransformRotationXY, + &pVeSubPropTransformScaleX, + &pVeSubPropTransformScaleY, + &pVeSubPropTransformScaleZ, + &pVeSubPropTransformScaleXY, + &pVeSubPropTransformTranslationX, + &pVeSubPropTransformTranslationY, + &pVeSubPropTransformTranslationZ, + &pVeSubPropTransformTranslationXY, + &pVeSubPropChildrenTransformRotationX, + &pVeSubPropChildrenTransformRotationY, + &pVeSubPropChildrenTransformRotationZ, + &pVeSubPropChildrenTransformRotationXY, + &pVeSubPropChildrenTransformScaleX, + &pVeSubPropChildrenTransformScaleY, + &pVeSubPropChildrenTransformScaleZ, + &pVeSubPropChildrenTransformScaleXY, + &pVeSubPropChildrenTransformTranslationX, + &pVeSubPropChildrenTransformTranslationY, + &pVeSubPropChildrenTransformTranslationZ, + &pVeSubPropChildrenTransformTranslationXY + }; +#endif + + for (int i = 0; i < static_cast< int >(sizeof(supportedProperties) / sizeof(supportedProperties[0])); i++) + { + //if (wcscmp(property.GetPointer(), supportedProperties[i]) == 0) + if (property.GetPointer() == (*supportedProperties[i])->GetPointer() || property == **supportedProperties[i]) + { + return true; + } + } + + return false; +} + +VisualElementAnimation* +_VisualElementImpl::CreateAnimationForPropertyI(const Tizen::Base::String& property) +{ + if (IS_PRESENTATION(this) || !CheckIfAnimatable(property)) + { + return null; + } + +#if 0 + if (property.CompareTo(String(VePropBounds)) == 0) + { + //ToDo: default implementation + } + else if (property.CompareTo(String(VePropOpacity)) == 0) + { + //ToDo: default implementation + } + else if (property.CompareTo(String(VePropChildrenOpacity)) == 0) + { + //ToDo: default implementation + } + else if (property.CompareTo(String(VePropShowState)) == 0) + { + //ToDo: default implementation + } + else if (property.CompareTo(String(VePropTransform)) == 0) + { + //ToDo: default implementation + } + else if (property.CompareTo(String(VePropChildrenTransform)) == 0) + { + //ToDo: default implementation + } + else if (property.CompareTo(String(VePropZPosition)) == 0) + { + //ToDo: default implementation + } + else + return null; +#endif + VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturn(NID_UI_ANIM, pAnimation != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + +#if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION) + if (unlikely(property == *pVePropActionAttach)) + { + pAnimation->SetPropertyName(*pVePropOpacity); + pAnimation->SetStartValue(Variant(0.0f)); + } + else if (unlikely(property == *pVePropActionDetach)) + { + pAnimation->SetPropertyName(*pVePropOpacity); + pAnimation->SetEndValue(Variant(0.0f)); + } + else +#endif + { + _VisualElementImpl* pPresentation = GetPresentation(); + + const Variant& curValue = pPresentation->InvokeOnGetPropertyRequested(property); + result r = GetLastResult(); + SysTryCatch(NID_UI_ANIM, !IsFailed(r), , r, "[%s] No property for animation exists.", GetErrorMessage(r)); + + pAnimation->SetPropertyName(property); + pAnimation->SetStartValue(curValue); + } + + return pAnimation; + + +CATCH: + delete pAnimation; + + return null; +} + +void +_VisualElementImpl::SetBoundsChangedCallback(BoundsChangedCallback pCallback, void* pData) +{ + __pBoundsChangedCallback = pCallback; + __pBoundsChangedCallbackData = pData; +} + + +// delegate--------------------------------------------------------------------------------- + +void +_VisualElementImpl::InvokeOnConstructed(void) +{ + if (__pPublicInstance) + { + if (IS_MODEL(this)) + { + __pPublicInstance->OnConstructed(); + } + } + + ClearLastResult(); +} + +void +_VisualElementImpl::InvokeOnDestructing(void) +{ + if (__pPublicInstance) + { + if (IS_MODEL(this)) + { + __pPublicInstance->OnDestructing(); + } + } + + ClearLastResult(); +} + +int +_VisualElementImpl::InvokeHitTest(const Tizen::Graphics::FloatPoint& point) +{ + int hitTest = _VisualElementImpl::HITTEST_NOWHERE; + + if (__pPublicInstance && !__isInternal) + { + HitTestResult hitResult = HIT_TEST_NOWHERE; + + if (GetSharedData().pContentProvider) + { + hitResult = GetSharedData().pContentProvider->HitTest(*__pPublicInstance, point); + } + else + { + hitResult = __pPublicInstance->OnHitTest(point); + } + + if (hitResult == HIT_TEST_NOWHERE) + { + hitTest = _VisualElementImpl::HITTEST_NOWHERE; + } + else + { + hitTest = _VisualElementImpl::HITTEST_MATCH; + } + } + else + { + return HitTestI(point); + } + + ClearLastResult(); + + return hitTest; +} + +bool +_VisualElementImpl::InvokePrepareDraw(void) +{ + bool result = true; + + if (__pPublicInstance) + { + if (GetSharedData().pContentProvider) + { + result = GetSharedData().pContentProvider->PrepareDraw(*__pPublicInstance); + } + else + { + result = __pPublicInstance->OnPrepareDraw(); + } + } + + ClearLastResult(); + + return result; +} + +void +_VisualElementImpl::InvokeOnDraw(Tizen::Graphics::Canvas& canvas) +{ + if (__pPublicInstance) + { + if (GetSharedData().pContentProvider) + { + GetSharedData().pContentProvider->DrawContent(*__pPublicInstance, canvas); + } + else + { + __pPublicInstance->OnDraw(canvas); + } + } + + ClearLastResult(); +} + +VisualElementAnimation* +_VisualElementImpl::InvokeCreateAnimationForProperty(const Tizen::Base::String& property) +{ + VisualElementAnimation* pAnimation = null; + + if (__pPublicInstance) + { + if (GetSharedData().pAnimationProvider) + { + pAnimation = GetSharedData().pAnimationProvider->CreateAnimationForProperty(*__pPublicInstance, property); + } + else + { + pAnimation = __pPublicInstance->OnCreateAnimationForProperty(property); + } + } + + ClearLastResult(); + + return pAnimation; +} + +result +_VisualElementImpl::InvokeOnChildAttaching(_VisualElementImpl& child) +{ + ClearLastResult(); + return E_SUCCESS; +} + +void +_VisualElementImpl::InvokeOnChildAttached(_VisualElementImpl& child) +{ + if (__pPublicInstance && !__isInternal) + { + VisualElement* pChild = child.__pPublicInstance; + + if (GetSharedData().pEventListener) + { + GetSharedData().pEventListener->OnChildAttached(*__pPublicInstance, *pChild); + } + } + + ClearLastResult(); +} + +result +_VisualElementImpl::InvokeOnChildDetaching(_VisualElementImpl& child) +{ + ClearLastResult(); + return E_SUCCESS; +} + +void +_VisualElementImpl::InvokeOnChildDetached(_VisualElementImpl& child) +{ + if (__pPublicInstance && !__isInternal) + { + VisualElement* pChild = child.__pPublicInstance; + + if (GetSharedData().pEventListener) + { + GetSharedData().pEventListener->OnChildDetached(*__pPublicInstance, *pChild); + } + } + + ClearLastResult(); +} + +result +_VisualElementImpl::InvokeOnAttaching(_VisualElementImpl& parent) +{ + ClearLastResult(); + return E_SUCCESS; +} + +void +_VisualElementImpl::InvokeOnAttached(void) +{ + if (__pPublicInstance && !__isInternal) + { + _VisualElementImpl* pParentInternal = GetParent(); + if (pParentInternal) + { + VisualElement* pParent = pParentInternal->__pPublicInstance; + + if (GetSharedData().pEventListener) + { + __isAllowedTreeModification = false; + GetSharedData().pEventListener->OnAttached(*__pPublicInstance, *pParent); + __isAllowedTreeModification = true; + } + } + } + + ClearLastResult(); +} + +result +_VisualElementImpl::InvokeOnDetaching(void) +{ + ClearLastResult(); + return E_SUCCESS; +} + +void +_VisualElementImpl::InvokeOnDetached(_VisualElementImpl& parent) +{ + if (__pPublicInstance && !__isInternal) + { + VisualElement* pParent = parent.__pPublicInstance; + + if (GetSharedData().pEventListener) + { + __isAllowedTreeModification = false; + GetSharedData().pEventListener->OnDetached(*__pPublicInstance, *pParent); + __isAllowedTreeModification = true; + } + } +} + +result +_VisualElementImpl::InvokeOnAnimationAdded(const VisualElementAnimation* pAnimation) +{ + //TODO: Implementation + ClearLastResult(); + return E_SUCCESS; +} + +result +_VisualElementImpl::InvokeOnAnimationRemoved(const VisualElementAnimation* pAnimation) +{ + //TODO: Implementation + ClearLastResult(); + return E_SUCCESS; +} + +void +_VisualElementImpl::InvokeOnShowStateChanged(bool showState) +{ + if (__pPublicInstance && !__isInternal) + { + if (GetSharedData().pEventListener) + { + GetSharedData().pEventListener->OnShowStateChanged(*__pPublicInstance, showState); + } + } + + ClearLastResult(); +} + +result +_VisualElementImpl::InvokeOnTransformMatrixChanging(FloatMatrix4& newTransform) +{ + if (__pPublicInstance && !__isInternal) + { + if (GetSharedData().pEventListener) + { + return GetSharedData().pEventListener->OnTransformChanging(*__pPublicInstance, newTransform); + } + + return E_SUCCESS; + } + + return E_INVALID_STATE; +} + +void +_VisualElementImpl::InvokeOnTransformMatrixChanged(const FloatMatrix4& oldTransform) +{ + if (__pPublicInstance && !__isInternal) + { + if (GetSharedData().pEventListener) + { + GetSharedData().pEventListener->OnTransformChanged(*__pPublicInstance, oldTransform); + } + } + + ClearLastResult(); +} + +result +_VisualElementImpl::InvokeOnChildrenTransformMatrixChanging(FloatMatrix4& newTransform) +{ + if (__pPublicInstance && !__isInternal) + { + if (GetSharedData().pEventListener) + { + return GetSharedData().pEventListener->OnChildrenTransformChanging(*__pPublicInstance, newTransform); + } + + return E_SUCCESS; + } + + return E_INVALID_STATE; +} + +void +_VisualElementImpl::InvokeOnChildrenTransformMatrixChanged(const FloatMatrix4& oldTransform) +{ + if (__pPublicInstance && !__isInternal) + { + if (GetSharedData().pEventListener) + { + GetSharedData().pEventListener->OnChildrenTransformChanged(*__pPublicInstance, oldTransform); + } + } + + ClearLastResult(); +} + +result +_VisualElementImpl::InvokeOnBoundsChanging(FloatRectangle& newBounds) +{ + if (__pPublicInstance && !__isInternal) + { + if (GetSharedData().pEventListener) + { + return GetSharedData().pEventListener->OnBoundsChanging(*__pPublicInstance, newBounds); + } + + return E_SUCCESS; + } + + return E_INVALID_STATE; +} + +void +_VisualElementImpl::InvokeOnBoundsChanged(const FloatRectangle& oldBounds) +{ + if (__pPublicInstance && !__isInternal) + { + if (GetSharedData().pEventListener) + { + GetSharedData().pEventListener->OnBoundsChanged(*__pPublicInstance, oldBounds); + } + } + + ClearLastResult(); +} + +}}} + diff --git a/src/ui/animations/FUiAnim_VisualElementPropertyAnimationImpl.cpp b/src/ui/animations/FUiAnim_VisualElementPropertyAnimationImpl.cpp new file mode 100644 index 0000000..38bc412 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementPropertyAnimationImpl.cpp @@ -0,0 +1,134 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementPropertyAnimationImpl.cpp + * @brief This file contains implementation of _VisualElementPropertyAnimationImpl class + * + * This file contains implementation _VisualElementValueAnimationImpl class. + */ + +#include + +#include +#include +#include + +#include "FUiAnim_VisualElementPropertyAnimationImpl.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + + +_VisualElementPropertyAnimationImpl::_VisualElementPropertyAnimationImpl(void) +{ + +} + +_VisualElementPropertyAnimationImpl::_VisualElementPropertyAnimationImpl(const _VisualElementPropertyAnimationImpl& animationImpl) +{ + result r = CopyAnimationValue(animationImpl); + + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +_VisualElementPropertyAnimationImpl::~_VisualElementPropertyAnimationImpl(void) +{ + +} + +bool +_VisualElementPropertyAnimationImpl::Equals(const Tizen::Base::Object& obj) const +{ + if (this == &obj) + { + return true; + } + + const _VisualElementPropertyAnimationImpl* pAnimationImpl = dynamic_cast< const _VisualElementPropertyAnimationImpl* >(&obj); + + if (pAnimationImpl == null) + { + return false; + } + + return (_VisualElementValueAnimationImpl::Equals(obj) && __property == pAnimationImpl->__property); +} + +int +_VisualElementPropertyAnimationImpl::GetHashCode(void) const +{ + return (_VisualElementValueAnimationImpl::GetHashCode() + __property.GetHashCode()); +} + +result +_VisualElementPropertyAnimationImpl::CopyAnimationValue(const _VisualElementPropertyAnimationImpl& animationImpl) +{ + result r = _VisualElementValueAnimationImpl::CopyAnimationValue(animationImpl); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + __property = animationImpl.__property; + + return E_SUCCESS; +} + +void +_VisualElementPropertyAnimationImpl::SetPropertyName(const Tizen::Base::String& property) +{ + __property = property; +} + +Tizen::Base::String +_VisualElementPropertyAnimationImpl::GetPropertyName(void) const +{ + return __property; +} + +_VisualElementPropertyAnimationImpl* +_VisualElementPropertyAnimationImpl::GetInstance(VisualElementPropertyAnimation& animation) +{ + return dynamic_cast<_VisualElementPropertyAnimationImpl*>(animation._pAnimationImpl); +} + +const _VisualElementPropertyAnimationImpl* +_VisualElementPropertyAnimationImpl::GetInstance(const VisualElementPropertyAnimation& animation) +{ + return dynamic_cast(animation._pAnimationImpl); +} + +bool +_VisualElementPropertyAnimationImpl::IsValidValues(void) const +{ + SysTryReturn(NID_UI_ANIM, (__property.IsEmpty() == false), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The property name is not set."); + SysTryReturn(NID_UI_ANIM, (__start.IsEmpty() == false || __end.IsEmpty() == false), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The start value and end value is invalid."); + + if (__start.IsEmpty() == false && __end.IsEmpty() == false) + { + SysTryReturn(NID_UI_ANIM, (__start.GetType() == __end.GetType()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The types of variant are different."); + } + + return true; +} + +void +_VisualElementPropertyAnimationImpl::OnTickOccurred(VisualElement& target, const Tizen::Ui::Variant& currentValue) +{ + _VisualElementImpl::GetInstance(target)->SetPropertyI(__property, currentValue); +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_VisualElementPropertyAnimationImpl.h b/src/ui/animations/FUiAnim_VisualElementPropertyAnimationImpl.h new file mode 100644 index 0000000..af70656 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementPropertyAnimationImpl.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementPropertyAnimationImpl.h + * @brief This is the header file for the _VisualElementPropertyAnimationImpl class. + * + * This header file contains the declarations of the _VisualElementPropertyAnimationImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_PROPERTY_ANIMATION_IMPL_H_ +#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_PROPERTY_ANIMATION_IMPL_H_ + +#include +#include +#include + +#include "FUiAnim_VisualElementValueAnimationImpl.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class VisualElement; +class VisualElementPropertyAnimation; + +class _VisualElementPropertyAnimationImpl + : public _VisualElementValueAnimationImpl +{ +public: + _VisualElementPropertyAnimationImpl(void); + _VisualElementPropertyAnimationImpl(const _VisualElementPropertyAnimationImpl& animationImpl); + virtual ~_VisualElementPropertyAnimationImpl(void); + + virtual bool Equals(const Tizen::Base::Object& obj) const; + virtual int GetHashCode(void) const; + + result CopyAnimationValue(const _VisualElementPropertyAnimationImpl& animationImpl); + + void SetPropertyName(const Tizen::Base::String& property); + Tizen::Base::String GetPropertyName(void) const; + + static _VisualElementPropertyAnimationImpl* GetInstance(VisualElementPropertyAnimation& animation); + static const _VisualElementPropertyAnimationImpl* GetInstance(const VisualElementPropertyAnimation& animation); + + virtual bool IsValidValues(void) const; + virtual void OnTickOccurred(VisualElement& target, const Tizen::Ui::Variant& currentValue); + +private: + _VisualElementPropertyAnimationImpl& operator =(const _VisualElementPropertyAnimationImpl& rhs); + +private: + Tizen::Base::String __property; +}; // _VisualElementPropertyAnimationImpl + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_PROPERTY_ANIMATION_IMPL_H_ diff --git a/src/ui/animations/FUiAnim_VisualElementSharedData.cpp b/src/ui/animations/FUiAnim_VisualElementSharedData.cpp new file mode 100644 index 0000000..e827715 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementSharedData.cpp @@ -0,0 +1,173 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementSharedData.cpp + * @brief This file contains implementation of _VisualElementSharedData class + * + * This file contains implementation _VisualElementSharedData class. + */ + +#include +#include +#include +#include + +#include "FUiAnim_VisualElement.h" +#include "FUiAnim_VisualElementSharedData.h" +#include "FUiAnim_VisualElementSurfaceImpl.h" +#include "FUiAnim_INativeNode.h" +#include "FUiAnim_NativeLayer.h" + +using namespace std; + +namespace Tizen { namespace Ui { namespace Animations +{ + +_VisualElementSharedData::_VisualElementSharedData(void) + : invalidatedNativeProps(-1) + , surfaceChanged(false) + , pNativeNode(null) + , pSurface(null) + , invalidatedRegion(0.0f, 0.0f, 0.0f, 0.0f) + , drawOnPresentation(false) + , needSurface(true) + , redrawOnResize(false) + , isSurfaceOpaque(true) + , fixedSurfaceSize(false) + , invalidationLockCount(0) + , updateRegion(0.0f, 0.0f, 0.0f, 0.0f) + , pAnimationProvider(null) + , pContentProvider(null) + , pEventListener(null) + , name("") + , pUserData(null) + , __refCount(1) +{ +} + +_VisualElementSharedData::~_VisualElementSharedData(void) +{ + if (pSurface) + { + delete pSurface; + pSurface = null; + } + + if (pNativeNode) + { + delete pNativeNode; + } +} + +result +_VisualElementSharedData::Construct(void) +{ + ClearLastResult(); + SysAssert(pNativeNode == null); + + pNativeNode = _INativeNode::CreateInstanceN(); + SysTryReturnResult(NID_UI, pNativeNode, E_OUT_OF_MEMORY, "Memory allocation failed."); + + return E_SUCCESS; +} + +void +_VisualElementSharedData::AddRef(void) +{ + __refCount++; +} + +void +_VisualElementSharedData::Release(void) +{ + if (__refCount >= 1) + { + __refCount--; + if (__refCount == 0) + { + delete this; + } + + return; + } + + // error reference counting......... +} + +int +_VisualElementSharedData::GetReferenceCount(void) const +{ + return __refCount; +} + +void +_VisualElementSharedData::LockInvalidate(bool lock) +{ + if (lock) + { + invalidationLockCount++; + } + else if (invalidationLockCount >= 1) + { + invalidationLockCount--; + } +} + +result +_VisualElementSharedData::CreateSurface(const Tizen::Graphics::Dimension& size, _NativeLayer& layer) +{ + unique_ptr pNewSurface(_VisualElementSurfaceImpl::CreateSurfaceN((const Handle)&layer, size)); + SysTryReturnResult(NID_UI, pNewSurface, E_OUT_OF_MEMORY, "Memory allocation failed."); + + if (pSurface) + { + delete pSurface; + pSurface = null; + } + + pSurface = pNewSurface.release(); + return E_SUCCESS; +} + +result +_VisualElementSharedData::SetImage(const Tizen::Base::String& fileName) +{ + SysTryReturnResult(NID_UI, pNativeNode, E_INVALID_STATE, "The Native Node is invalid."); + SysTryReturnResult(NID_UI, pSurface, E_INVALID_STATE, "The Native Node is invalid."); + + _VisualElementSurfaceImpl* pImpl = _VisualElementSurfaceImpl::GetInstance(*pSurface); + SysTryReturnResult(NID_UI, pImpl, E_SYSTEM, "A system error has been occurred."); + SysTryReturnResult(NID_UI, pImpl->SetImage(fileName) == E_SUCCESS, E_SYSTEM, "A system error has been occurred."); + + return E_SUCCESS; +} + +void +_VisualElementSharedData::RemoveSurface(_VisualElementImpl& presentation) +{ + if (likely(pNativeNode)) + { + pNativeNode->Reconfigure(null, presentation, true); + } + + delete pSurface; + pSurface = null; +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_VisualElementSurfaceImpl.cpp b/src/ui/animations/FUiAnim_VisualElementSurfaceImpl.cpp new file mode 100644 index 0000000..cc5fec7 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementSurfaceImpl.cpp @@ -0,0 +1,189 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementSurfaceImpl.cpp + * @brief This file contains implementation of _VisualElementSurfaceImpl class + * + * This file contains implementation _VisualElementSurfaceImpl class. + */ + +#include +#include +#include +#include +#include + +#include "FUiAnim_VisualElementCoordinateSystem.h" +#include "FUiAnim_EflVisualElementSurfaceImpl.h" +#include "FUiAnim_VisualElementSurfaceImpl.h" +#include "FUiAnim_DisplayContextImpl.h" +#include "FUiAnim_EflLayer.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Animations +{ + +VisualElementSurface* +_VisualElementSurfaceImpl::CreateSurfaceN(const Handle handle, const Tizen::Graphics::Dimension& size) +{ + SysTryReturn(NID_UI_ANIM, size.width >= 0 && size.height >= 0, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Surface size is out of range. size = (%d, %d)", size.width, size.height); + SysTryReturn(NID_UI_ANIM, handle != 0, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The handle is invalid."); + + unique_ptr pSurface(new(std::nothrow) VisualElementSurface()); + SysTryReturn(NID_UI_ANIM, pSurface , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + unique_ptr<_EflVisualElementSurfaceImpl> pImpl(new (std::nothrow) _EflVisualElementSurfaceImpl(handle, size)); + SysTryReturn(NID_UI_ANIM, pImpl, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The handle is invalid."); + pSurface->__pVisualElementSurfaceImpl = pImpl.release(); + + return pSurface.release(); +} + +VisualElementSurface* +_VisualElementSurfaceImpl::CreateSurfaceUsingExistingObjectN(const DisplayContext& displayContext, const Handle handle, const Tizen::Graphics::Dimension& size) +{ + SysTryReturn(NID_UI_ANIM, size.width >= 0 && size.height >= 0, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Surface size is out of range. size = (%d, %d)", size.width, size.height); + SysTryReturn(NID_UI_ANIM, handle != 0, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The handle is invalid."); + + unique_ptr pSurface(new(std::nothrow) VisualElementSurface()); + SysTryReturn(NID_UI_ANIM, pSurface , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + _DisplayContextImpl* pDisplayContext = const_cast<_DisplayContextImpl*>(_DisplayContextImpl::GetInstance(displayContext)); + SysTryReturn(NID_UI_ANIM, pDisplayContext != null, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. DisplayContext is invalid."); + + _EflLayer* pLayer = dynamic_cast<_EflLayer*>(pDisplayContext->GetNativeLayer()); + SysTryReturn(NID_UI_ANIM, pLayer != null, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. DisplayContext is invalid."); + + unique_ptr<_EflVisualElementSurfaceImpl> pImpl(new (std::nothrow) _EflVisualElementSurfaceImpl(reinterpret_cast(pLayer), handle, size)); + SysTryReturn(NID_UI_ANIM, pImpl, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The handle is invalid."); + result r = GetLastResult(); + SysTryReturn(NID_UI_ANIM, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pSurface->__pVisualElementSurfaceImpl = pImpl.release(); + + return pSurface.release(); +} + +_VisualElementSurfaceImpl* +_VisualElementSurfaceImpl::CreateInstanceN(const DisplayContext& displayContext, const Tizen::Graphics::Dimension& size) +{ + SysTryReturn(NID_UI_ANIM, size.width >= 0 && size.height >= 0, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Surface size is out of range. size = (%d, %d)", size.width, size.height); + + _DisplayContextImpl* pDisplayContext = const_cast<_DisplayContextImpl*>(_DisplayContextImpl::GetInstance(displayContext)); + SysTryReturn(NID_UI_ANIM, pDisplayContext != null, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. DisplayContext is invalid."); + + _EflLayer* pLayer = dynamic_cast<_EflLayer*>(pDisplayContext->GetNativeLayer()); + SysTryReturn(NID_UI_ANIM, pLayer != null, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. DisplayContext is invalid."); + + _VisualElementSurfaceImpl* pVisualElementSurfaceImpl = new (std::nothrow) _EflVisualElementSurfaceImpl(reinterpret_cast(pLayer), size); + result r = GetLastResult(); + SysTryReturn(NID_UI_ANIM, pVisualElementSurfaceImpl != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pVisualElementSurfaceImpl; + +CATCH: + delete pVisualElementSurfaceImpl; + return null; +} + +_VisualElementSurfaceImpl::_VisualElementSurfaceImpl(const Dimension& size) + : __refCount(1) + , __logicalSize(size) +{ +} + +result +_VisualElementSurfaceImpl::SetImage(const String& fileName) +{ + return E_SUCCESS; +} + +_VisualElementSurfaceImpl::~_VisualElementSurfaceImpl(void) +{ +} + +void +_VisualElementSurfaceImpl::AddRef(void) +{ + __refCount++; +} + +bool +_VisualElementSurfaceImpl::Release(void) +{ + if (likely(__refCount >= 1)) + { + __refCount--; + if (likely(__refCount == 0)) + { + delete this; + return true; + } + } + + return false; +} + +int +_VisualElementSurfaceImpl::GetReferenceCount(void) const +{ + return __refCount; +} + +result +_VisualElementSurfaceImpl::GetBufferInfo(BufferInfo& bufferInfo) const +{ + return E_SUCCESS; +} + +Dimension +_VisualElementSurfaceImpl::GetPhysicalSize(void) const +{ + return Dimension(); +} + +bool +_VisualElementSurfaceImpl::Equals(const Tizen::Base::Object& obj) const +{ + const VisualElementSurface* pSurface = dynamic_cast< const VisualElementSurface* >(&obj); + if (pSurface == null) + { + return false; + } + + const _VisualElementSurfaceImpl* pSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pSurface); + if (pSurfaceImpl == this) + { + return true; + } + + return (this == pSurfaceImpl); +} + +int +_VisualElementSurfaceImpl::GetHashCode(void) const +{ + return reinterpret_cast< int >(this); +} + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_VisualElementValueAnimationImpl.cpp b/src/ui/animations/FUiAnim_VisualElementValueAnimationImpl.cpp new file mode 100644 index 0000000..aa6cca1 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementValueAnimationImpl.cpp @@ -0,0 +1,288 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementValueAnimationImpl.cpp + * @brief This file contains implementation of _VisualElementValueAnimationImpl class + * + * This file contains implementation _VisualElementValueAnimationImpl class. + */ + +#include + +#include +#include + +#include "FUiAnim_VisualElementAnimationKeyFrame.h" +#include "FUiAnim_VisualElementValueAnimationImpl.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + + +_VisualElementValueAnimationImpl::_VisualElementValueAnimationImpl(void) + : __pTickListener(null) + , __applyEndValue(true) + , __pKeyFrame(null) +{ + +} + +_VisualElementValueAnimationImpl::_VisualElementValueAnimationImpl(const _VisualElementValueAnimationImpl& animationImpl) + : __pTickListener(null) + , __applyEndValue(true) + , __pKeyFrame(null) +{ + result r = CopyAnimationValue(animationImpl); + + SysTryReturnVoidResult(NID_UI_ANIM, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +_VisualElementValueAnimationImpl::~_VisualElementValueAnimationImpl(void) +{ + if (__pKeyFrame) + { + delete __pKeyFrame; + __pKeyFrame = null; + } +} + +bool +_VisualElementValueAnimationImpl::Equals(const Tizen::Base::Object& obj) const +{ + if (this == &obj) + { + return true; + } + + const _VisualElementValueAnimationImpl* pAnimationImpl = dynamic_cast< const _VisualElementValueAnimationImpl* >(&obj); + + if (pAnimationImpl == null) + { + return false; + } + + bool isKeyFrameEqual = false; + + if (__pKeyFrame != null && pAnimationImpl->__pKeyFrame != null) + { + isKeyFrameEqual = __pKeyFrame->Equals(*(pAnimationImpl->__pKeyFrame)); + } + else if (__pKeyFrame == null && pAnimationImpl->__pKeyFrame == null) + { + isKeyFrameEqual = true; + } + + return (_VisualElementAnimationImpl::Equals(obj) + && (__pTickListener == pAnimationImpl->__pTickListener) + && (__start == pAnimationImpl->__start) + && (__end == pAnimationImpl->__end) + && (__applyEndValue == pAnimationImpl->__applyEndValue) + && (isKeyFrameEqual)); +} + +int +_VisualElementValueAnimationImpl::GetHashCode(void) const +{ + return (_VisualElementAnimationImpl::GetHashCode() + __start.GetHashCode() + __end.GetHashCode() + __applyEndValue); +} + +result +_VisualElementValueAnimationImpl::CopyAnimationValue(const _VisualElementValueAnimationImpl& animationImpl) +{ + result r = _VisualElementAnimationImpl::CopyAnimationValue(animationImpl); + SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating."); + + __pTickListener = animationImpl.__pTickListener; + __start = animationImpl.__start; + __end = animationImpl.__end; + __applyEndValue = animationImpl.__applyEndValue; + + if (animationImpl.__pKeyFrame != null) + { + __pKeyFrame = animationImpl.__pKeyFrame->CloneN(); + SysTryReturnResult(NID_UI_ANIM, (__pKeyFrame != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + } + + return E_SUCCESS; +} + +void +_VisualElementValueAnimationImpl::SetTickEventListener(IVisualElementAnimationTickEventListener* pListener) +{ + __pTickListener = pListener; +} + +IVisualElementAnimationTickEventListener* +_VisualElementValueAnimationImpl::GetTickEventListener(void) const +{ + return __pTickListener; +} + +void +_VisualElementValueAnimationImpl::SetStartValue(const Variant& startValue) +{ + __start = startValue; +} + +Tizen::Ui::Variant +_VisualElementValueAnimationImpl::GetStartValue(void) const +{ + return __start; +} + +void +_VisualElementValueAnimationImpl::SetEndValue(const Variant& endValue) +{ + __end = endValue; +} + +Tizen::Ui::Variant +_VisualElementValueAnimationImpl::GetEndValue(void) const +{ + return __end; +} + +void +_VisualElementValueAnimationImpl::SetEndValueApplied(bool apply) +{ + __applyEndValue = apply; +} + +bool +_VisualElementValueAnimationImpl::IsEndValueApplied(void) const +{ + return __applyEndValue; +} + +result +_VisualElementValueAnimationImpl::AddKeyFrame(float timeProgress, const Tizen::Ui::Variant& value, const IVisualElementAnimationTimingFunction* pTimingFunction) +{ + if (__pKeyFrame == null) + { + __pKeyFrame = new (std::nothrow) _VisualElementAnimationKeyFrame(); + SysTryReturnResult(NID_UI_ANIM, (__pKeyFrame != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + } + else + { + _VisualElementAnimationKeyFrameInfo* pInfo = __pKeyFrame->GetKeyFrameInfoAt(0); + SysAssertf(pInfo != null, "Key frame with index 0 is null."); + + SysTryReturnResult(NID_UI_ANIM, (pInfo->GetValue().GetType() == value.GetType()), E_INVALID_ARG, "Invalid argument(s) is used. The value type is different from another"); + } + + return __pKeyFrame->AddKeyFrame(timeProgress, value, pTimingFunction); +} + +result +_VisualElementValueAnimationImpl::RemoveKeyFrame(float timeProgress) +{ + if (__pKeyFrame == null) + { + return E_OBJ_NOT_FOUND; + } + + result r = __pKeyFrame->RemoveKeyFrame(timeProgress); + + if (__pKeyFrame->GetCount() == 0) + { + delete __pKeyFrame; + __pKeyFrame = null; + } + + return r; +} + +void +_VisualElementValueAnimationImpl::RemoveAllKeyFrames(void) +{ + if (__pKeyFrame != null) + { + __pKeyFrame->RemoveAllKeyFrames(); + + delete __pKeyFrame; + __pKeyFrame = null; + } +} + +_VisualElementValueAnimationImpl* +_VisualElementValueAnimationImpl::GetInstance(VisualElementValueAnimation& animation) +{ + return dynamic_cast<_VisualElementValueAnimationImpl*>(animation._pAnimationImpl); +} + +const _VisualElementValueAnimationImpl* +_VisualElementValueAnimationImpl::GetInstance(const VisualElementValueAnimation& animation) +{ + return dynamic_cast(animation._pAnimationImpl); +} + +_VisualElementAnimationKeyFrame* +_VisualElementValueAnimationImpl::GetKeyFrame(void) const +{ + return __pKeyFrame; +} + +bool +_VisualElementValueAnimationImpl::IsValid(void) const +{ + return (IsValidValues() && IsValidKeyFrameType()); +} + +bool +_VisualElementValueAnimationImpl::IsValidKeyFrameType(void) const +{ + if (__pKeyFrame != null) + { + VariantType type; + + if (__start.IsEmpty() == false) + { + type = __start.GetType(); + } + else + { + type = __end.GetType(); + } + + _VisualElementAnimationKeyFrameInfo* pInfo = __pKeyFrame->GetKeyFrameInfoAt(0); + SysAssertf(pInfo != null, "Key frame with index 0 is null."); + + SysTryReturn(NID_UI_ANIM, (pInfo->GetValue().GetType() == type), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The types of variant are different."); + } + + return true; +} + +bool +_VisualElementValueAnimationImpl::IsValidValues(void) const +{ + SysTryReturn(NID_UI_ANIM, (__start.IsEmpty() == false && __end.IsEmpty() == false), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The start value or end value is invalid."); + SysTryReturn(NID_UI_ANIM, (__start.GetType() == __end.GetType()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. The types of variant are different."); + + return true; +} + +void +_VisualElementValueAnimationImpl::OnTickOccurred(VisualElement& target, const Tizen::Ui::Variant& currentValue) +{ + +} + + +}}} // Tizen::Ui::Animations + diff --git a/src/ui/animations/FUiAnim_VisualElementValueAnimationImpl.h b/src/ui/animations/FUiAnim_VisualElementValueAnimationImpl.h new file mode 100644 index 0000000..3d4c266 --- /dev/null +++ b/src/ui/animations/FUiAnim_VisualElementValueAnimationImpl.h @@ -0,0 +1,101 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementValueAnimationImpl.h + * @brief This is the header file for the _VisualElementAnimationImpl class. + * + * This header file contains the declarations of the _VisualElementAnimationImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_VALUE_ANIMATION_IMPL_H_ +#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_VALUE_ANIMATION_IMPL_H_ + +#include +#include +#include + +#include "FUiAnim_VisualElementAnimationImpl.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class IVisualElementAnimationTickEventListener; +class _VisualElementAnimationKeyFrame; +class VisualElementValueAnimation; + +class _VisualElementValueAnimationImpl + : public _VisualElementAnimationImpl +{ +public: + _VisualElementValueAnimationImpl(void); + _VisualElementValueAnimationImpl(const _VisualElementValueAnimationImpl& animationImpl); + virtual ~_VisualElementValueAnimationImpl(void); + + virtual bool Equals(const Tizen::Base::Object& obj) const; + virtual int GetHashCode(void) const; + + result CopyAnimationValue(const _VisualElementValueAnimationImpl& animationImpl); + + void SetTickEventListener(IVisualElementAnimationTickEventListener* pListener); + IVisualElementAnimationTickEventListener* GetTickEventListener(void) const; + + void SetStartValue(const Tizen::Ui::Variant& startValue); + Tizen::Ui::Variant GetStartValue(void) const; + + void SetEndValue(const Tizen::Ui::Variant& endValue); + Tizen::Ui::Variant GetEndValue(void) const; + + void SetEndValueApplied(bool apply); + bool IsEndValueApplied(void) const; + + result AddKeyFrame(float timeProgress, const Tizen::Ui::Variant& value, const IVisualElementAnimationTimingFunction* pTimingFunction); + result RemoveKeyFrame(float timeProgress); + void RemoveAllKeyFrames(void); + + static _VisualElementValueAnimationImpl* GetInstance(VisualElementValueAnimation& animation); + static const _VisualElementValueAnimationImpl* GetInstance(const VisualElementValueAnimation& animation); + + _VisualElementAnimationKeyFrame* GetKeyFrame(void) const; + + bool IsValid(void) const; + bool IsValidKeyFrameType(void) const; + + virtual bool IsValidValues(void) const; + virtual void OnTickOccurred(VisualElement& target, const Tizen::Ui::Variant& currentValue); + +private: + _VisualElementValueAnimationImpl& operator =(const _VisualElementValueAnimationImpl& rhs); + +protected: + Variant __start; + Variant __end; + +private: + IVisualElementAnimationTickEventListener* __pTickListener; + + bool __applyEndValue; + + _VisualElementAnimationKeyFrame* __pKeyFrame; + +}; // _VisualElementValueAnimationImpl + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_VALUE_ANIMATION_IMPL_H_ diff --git a/src/ui/controls/FUiCtrlAnimation.cpp b/src/ui/controls/FUiCtrlAnimation.cpp new file mode 100644 index 0000000..1e563fd --- /dev/null +++ b/src/ui/controls/FUiCtrlAnimation.cpp @@ -0,0 +1,188 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlAnimation.cpp + * @brief This is the implementation file for Animation class. + */ + +#include +#include +#include "FUiCtrl_AnimationImpl.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Animation::Animation(void) +{ +} + +Animation::~Animation(void) +{ +} + +result +Animation::Construct(const Rectangle& rectangle, const IList& animationFrames) +{ + result r = E_SUCCESS; + + _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this); + + SysAssertf((pAnimationImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + pAnimationImpl = _AnimationImpl::CreateAnimationImplN(this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pAnimationImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pAnimationImpl; + + r = Control::SetBounds(rectangle.x, rectangle.y, rectangle.width, rectangle.height); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pAnimationImpl->SetAnimationFrames(animationFrames); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pAnimationImpl->SetImageCount(animationFrames.GetCount()); + + return E_SUCCESS; + +CATCH: + delete pAnimationImpl; + pAnimationImpl = null; + + _pControlImpl = null; + + return r; +} + +void +Animation::AddAnimationEventListener(IAnimationEventListener& listener) +{ + _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this); + SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pAnimationImpl->AddAnimationEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return; +} + +void +Animation::RemoveAnimationEventListener(IAnimationEventListener& listener) +{ + _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this); + SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pAnimationImpl->RemoveAnimationEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return; +} + +void +Animation::SetRepeatCount(int count) +{ + _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this); + SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pAnimationImpl->SetRepeatCount(count); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return; +} + +int +Animation::GetRepeatCount(void) const +{ + const _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this); + SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pAnimationImpl->GetRepeatCount(); +} + +int +Animation::GetCurrentRepeatedCount(void) const +{ + const _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this); + SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pAnimationImpl->GetCurrentRepeatedCount(); +} + +int +Animation::GetImageCount(void) const +{ + const _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this); + SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pAnimationImpl->GetImageCount(); +} + +void +Animation::Play(void) +{ + _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this); + SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pAnimationImpl->Play(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return; +} + +void +Animation::Stop(void) +{ + _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this); + SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pAnimationImpl->Stop(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return; +} + +void +Animation::Pause(void) +{ + _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this); + SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pAnimationImpl->Pause(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return; +} + +AnimationStatus +Animation::GetStatus(void) const +{ + const _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this); + SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pAnimationImpl->GetStatus(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlAnimationFrame.cpp b/src/ui/controls/FUiCtrlAnimationFrame.cpp new file mode 100644 index 0000000..3d54ab2 --- /dev/null +++ b/src/ui/controls/FUiCtrlAnimationFrame.cpp @@ -0,0 +1,99 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlAnimationFrame.cpp + * @brief This is the implementation file for AnimationFrame class. + */ + +#include +#include +#include "FUiCtrl_AnimationFrameImpl.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +AnimationFrame::AnimationFrame(void) + : __pAnimationFrameImpl(null) +{ + ClearLastResult(); + + __pAnimationFrameImpl = new (std::nothrow) _AnimationFrameImpl(); + SysTryReturnVoidResult(NID_UI_CTRL, __pAnimationFrameImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); +} + +AnimationFrame::AnimationFrame(const Bitmap& frame, long duration) + : __pAnimationFrameImpl(null) +{ + ClearLastResult(); + + __pAnimationFrameImpl = new (std::nothrow) _AnimationFrameImpl(frame, duration); + SysTryReturnVoidResult(NID_UI_CTRL, __pAnimationFrameImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); +} + +AnimationFrame::~AnimationFrame(void) +{ + delete __pAnimationFrameImpl; + __pAnimationFrameImpl = null; +} + +void +AnimationFrame::SetFrame(const Bitmap& frame) +{ + SysAssertf(__pAnimationFrameImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = __pAnimationFrameImpl->SetFrame(frame); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return; +} + +const Bitmap* +AnimationFrame::GetFrame(void) const +{ + ClearLastResult(); + + SysAssertf(__pAnimationFrameImpl != null, "Not yet constructed. Construct() should be called before use."); + + return __pAnimationFrameImpl->GetFrame(); +} + +void +AnimationFrame::SetDuration(long duration) +{ + SysAssertf(__pAnimationFrameImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = __pAnimationFrameImpl->SetDuration(duration); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return; +} + +long +AnimationFrame::GetDuration(void) const +{ + ClearLastResult(); + + SysAssertf(__pAnimationFrameImpl != null, "Not yet constructed. Construct() should be called before use."); + + return __pAnimationFrameImpl->GetDuration(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlButton.cpp b/src/ui/controls/FUiCtrlButton.cpp new file mode 100644 index 0000000..1b169c8 --- /dev/null +++ b/src/ui/controls/FUiCtrlButton.cpp @@ -0,0 +1,382 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrlButton.cpp +* @brief This file contains implementation of Button class +*/ + +#include +#include +#include "FUiCtrl_ButtonImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Button::Button(void) +{ + +} + +Button::~Button(void) +{ + +} + +result +Button::Construct(const Rectangle& rect, const String& text) +{ + result r = E_SUCCESS; + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + + SysAssertf(pButtonImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pButtonImpl = _ButtonImpl::CreateButtonImplN(this, rect); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pButtonImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pButtonImpl->SetText(text); + SysAssert(r == E_SUCCESS); // [ToDo] Exception. Which exception can occur? + + _pControlImpl = pButtonImpl; + + return E_SUCCESS; +} + +void +Button::AddActionEventListener(IActionEventListener& listener) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pButtonImpl->AddActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +Button::RemoveActionEventListener(IActionEventListener& listener) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pButtonImpl->RemoveActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +Button::SetActionId(int actionId) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetActionId(actionId); + + return; +} + +int +Button::GetActionId(void) const +{ + const _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pButtonImpl->GetActionId(); +} + +void +Button::SetText(const String& text) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetText(text); + + return; +} + +void +Button::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetTextHorizontalAlignment(alignment); + + return; +} + +void +Button::SetTextVerticalAlignment(VerticalAlignment alignment) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetTextVerticalAlignment(alignment); + + return; +} + +String +Button::GetText(void) const +{ + const _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pButtonImpl->GetText(); +} + +HorizontalAlignment +Button::GetTextHorizontalAlignment(void) const +{ + const _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pButtonImpl->GetTextHorizontalAlignment(); +} + +VerticalAlignment +Button::GetTextVerticalAlignment(void) const +{ + const _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pButtonImpl->GetTextVerticalAlignment(); +} + +void +Button::SetTextColor(const Color& color) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetTextColor(color); + + return; +} + +Color +Button::GetTextColor(void) const +{ + const _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pButtonImpl->GetTextColor(); +} + +void +Button::SetPressedTextColor(const Color& color) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetPressedTextColor(color); + + return; +} + +Color +Button::GetPressedTextColor(void) const +{ + const _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pButtonImpl->GetPressedTextColor(); +} + +void +Button::SetDisabledTextColor(const Color& color) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetDisabledTextColor(color); + + return; +} + +Color +Button::GetDisabledTextColor(void) const +{ + const _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pButtonImpl->GetDisabledTextColor(); +} + +void +Button::SetHighlightedTextColor(const Color& color) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetHighlightedTextColor(color); + + return; +} + +Color +Button::GetHighlightedTextColor(void) const +{ + const _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pButtonImpl->GetHighlightedTextColor(); +} + +void +Button::SetNormalBitmap(const Point& position, const Bitmap& bitmap) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetNormalBitmap(position, bitmap); + + return; +} + +void +Button::SetPressedBitmap(const Point& position, const Bitmap& bitmap) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetPressedBitmap(position, bitmap); + + return; +} + +void +Button::SetDisabledBitmap(const Point& position, const Bitmap& bitmap) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetDisabledBitmap(position, bitmap); + + return; +} + +void +Button::SetNormalBackgroundBitmap(const Bitmap& bitmap) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetNormalBackgroundBitmap(bitmap); + + return; +} + +void +Button::SetPressedBackgroundBitmap(const Bitmap& bitmap) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetPressedBackgroundBitmap(bitmap); + + return; +} + +void +Button::SetHighlightedBackgroundBitmap(const Bitmap& bitmap) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pButtonImpl->SetHighlightedBackgroundBitmap(bitmap); + + return; +} + +Color +Button::GetColor(ButtonStatus status) const +{ + const _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pButtonImpl->GetColor(status); +} + +result +Button::SetColor(ButtonStatus status, const Color& color) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pButtonImpl->SetColor(status, color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +int +Button::GetTextSize(void) const +{ + const _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pButtonImpl->GetTextSize(); +} + +result +Button::SetTextSize(int size) +{ + _ButtonImpl* pButtonImpl = _ButtonImpl::GetInstance(*this); + SysAssertf(pButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pButtonImpl->SetTextSize(size); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlButtonItem.cpp b/src/ui/controls/FUiCtrlButtonItem.cpp new file mode 100644 index 0000000..cbad07b --- /dev/null +++ b/src/ui/controls/FUiCtrlButtonItem.cpp @@ -0,0 +1,126 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrlButtonItem.cpp +* @brief This is the implementation file for ButtonItem class. +*/ + +#include +#include +#include +#include "FUiCtrl_ButtonItemImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +ButtonItem::ButtonItem(void) + : __pImpl(null) +{ +} + +ButtonItem::~ButtonItem(void) +{ + if (__pImpl) + { + delete __pImpl; + __pImpl = null; + } +} + +result +ButtonItem::Construct(ButtonItemStyle style, int actionId) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (actionId >= BUTTON_ITEM_ACTION_ID_MIN && actionId <= BUTTON_ITEM_ACTION_ID_MAX), E_INVALID_ARG, + "[E_INVALID_ARG] The actionId is invalid."); + + _ButtonItemImpl* pImpl = _ButtonItemImpl::GetInstance(*this); + SysAssertf(pImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + __pImpl = new (std::nothrow) _ButtonItemImpl(this); + SysTryReturnResult(NID_UI_CTRL, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Impl instance is not constructed"); + + r = __pImpl->Construct(style, actionId); + + if (IsFailed(r)) + { + delete __pImpl; + __pImpl = null; + SysLog(NID_UI_CTRL, "[%s] Propagated.", GetErrorMessage(r)); + return r; + } + + return r; +} + +int +ButtonItem::GetActionId(void) const +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->GetActionId(); +} + +Tizen::Base::String +ButtonItem::GetText(void) const +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->GetText(); +} + +result +ButtonItem::SetActionId(int actionId) +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetActionId(actionId); +} + +result +ButtonItem::SetBackgroundBitmap(ButtonItemStatus status, const Tizen::Graphics::Bitmap* pBitmap) +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetBackgroundBitmap(status, pBitmap); +} + +result +ButtonItem::SetIcon(ButtonItemStatus status, const Tizen::Graphics::Bitmap* pIcon) +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetIcon(status, pIcon); +} + +result +ButtonItem::SetText(const Tizen::Base::String& text) +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetText(text); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlCheckButton.cpp b/src/ui/controls/FUiCtrlCheckButton.cpp new file mode 100644 index 0000000..2ed9021 --- /dev/null +++ b/src/ui/controls/FUiCtrlCheckButton.cpp @@ -0,0 +1,514 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrlCheckButton.cpp +* @brief This file contains implementation of CheckButton class +*/ + +#include +#include +#include "FUiCtrl_CheckButtonImpl.h" + +#define CONTROL_MINIMUM_LENGTH_LIMIT 0 +#define CONTROL_MAXIMUM_LENGTH_LIMIT 0xFFFF +#define CONTROL_MINIMUM_SIZE_LIMIT 0, 0 +#define CONTROL_MAXIMUM_SIZE_LIMIT 0xFFFF, 0xFFFF + +#define PROPERTY_CHECKBUTTON_MIN_WIDTH 0 +#define PROPERTY_CHECKBUTTON_MIN_HEIGHT 0 +#define PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_TITLE 0 +#define PROPERTY_CHECKBUTTON_MIN_HEIGHT_WITH_TITLE 0 +#define PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_DIVIDER 0 +#define PROPERTY_CHECKBUTTON_MIN_WIDTH_ONOFF_SLIDING 0 +#define PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_DETAILED 0 +#define PROPERTY_CHECK_MARK_REGION_CONFIG 108 +int checkMinWidth, checkMinHeight = 0; + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +CheckButton::CheckButton(void) +{ + +} + +CheckButton::~CheckButton(void) +{ + +} + +result +CheckButton::Construct(const Rectangle& rect, CheckButtonStyle style, BackgroundStyle backgroundStyle, + bool showTitle, const String& text, GroupStyle groupStyle) +{ + switch (style) + { + case CHECK_BUTTON_STYLE_MARK_WITH_DIVIDER: + // fall through + case CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER: + // fall through + case CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER: + checkMinWidth = PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_DIVIDER; + break; + + case CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON: + // fall through + case CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON: + checkMinWidth = PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_DETAILED; + break; + + case CHECK_BUTTON_STYLE_ONOFF_SLIDING: + checkMinWidth = PROPERTY_CHECKBUTTON_MIN_WIDTH_ONOFF_SLIDING; + break; + + default: //CHECK_BUTTON_STYLE_MARK , CHECK_BUTTON_STYLE_ONOFF, CHECK_BUTTON_STYLE_RADIO + checkMinWidth = showTitle ? PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_TITLE : PROPERTY_CHECKBUTTON_MIN_WIDTH; + } + + checkMinHeight = showTitle ? PROPERTY_CHECKBUTTON_MIN_HEIGHT_WITH_TITLE : PROPERTY_CHECKBUTTON_MIN_HEIGHT; + + SysTryReturn(NID_UI_CTRL, (rect.width >= checkMinWidth && rect.width <= CONTROL_MAXIMUM_LENGTH_LIMIT), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The width error occurred"); + + SysTryReturn(NID_UI_CTRL, (rect.height >= checkMinHeight && rect.height <= CONTROL_MAXIMUM_LENGTH_LIMIT), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The height error occurred"); + + SysTryReturn(NID_UI_CTRL, !(backgroundStyle == BACKGROUND_STYLE_NONE && groupStyle != GROUP_STYLE_NONE), + E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Unable to set group style."); + + result r = E_SUCCESS; + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + + SysAssertf(pCheckButtonImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pCheckButtonImpl = _CheckButtonImpl::CreateCheckButtonImplN(this, rect); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCheckButtonImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + + r = pCheckButtonImpl->SetCheckButtonStyle(style); + SysAssert(r == E_SUCCESS); // [ToDo] Exception. Which exception can occur? + + r = pCheckButtonImpl->SetBackgroundStyle(backgroundStyle); + SysAssert(r == E_SUCCESS); // [ToDo] Exception. Which exception can occur? + + r = pCheckButtonImpl->SetShowTitle(showTitle); + SysAssert(r == E_SUCCESS); // [ToDo] Exception. Which exception can occur? + + r = pCheckButtonImpl->SetText(text); + SysAssert(r == E_SUCCESS); // [ToDo] Exception. Which exception can occur? + + r = pCheckButtonImpl->SetGroupStyle(groupStyle); + SysAssert(r == E_SUCCESS); // [ToDo] Exception. Which exception can occur? + + r = pCheckButtonImpl->SetMinimumSize(Dimension(checkMinWidth, checkMinHeight)); + SysAssert(r == E_SUCCESS); // [ToDo] Exception. Which exception can occur? + + _pControlImpl = pCheckButtonImpl; + + return E_SUCCESS; +} + +void +CheckButton::SetSelected(bool select) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pCheckButtonImpl->SetSelected(select); + + return; +} + +bool +CheckButton::IsSelected(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->IsSelected(); +} + +void +CheckButton::AddActionEventListener(IActionEventListener& listener) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pCheckButtonImpl->AddActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +CheckButton::RemoveActionEventListener(IActionEventListener& listener) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pCheckButtonImpl->RemoveActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +CheckButton::SetActionId(int checkedActionId, int uncheckedActionId, int selectedActionId) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pCheckButtonImpl->SetActionId(checkedActionId, uncheckedActionId, selectedActionId); + + return; +} + +int +CheckButton::GetCheckedActionId(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetCheckedActionId(); +} + +int +CheckButton::GetUncheckedActionId(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetUncheckedActionId(); +} + +int +CheckButton::GetSelectedActionId(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetSelectedActionId(); +} + +void +CheckButton::SetText(const String& text) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pCheckButtonImpl->SetText(text); + + return; +} + +String +CheckButton::GetText(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetText(); +} + +result +CheckButton::SetTitleText(const String& title) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pCheckButtonImpl->SetTitleText(title); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +String +CheckButton::GetTitleText(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetTitleText(); +} + +void +CheckButton::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pCheckButtonImpl->SetTextHorizontalAlignment(alignment); + + return; +} + +HorizontalAlignment +CheckButton::GetTextHorizontalAlignment(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetTextHorizontalAlignment(); +} + +void +CheckButton::SetTextVerticalAlignment(VerticalAlignment alignment) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pCheckButtonImpl->SetTextVerticalAlignment(alignment); + + return; +} + +VerticalAlignment +CheckButton::GetTextVerticalAlignment(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetTextVerticalAlignment(); +} + +void +CheckButton::SetTextColor(const Color& color) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pCheckButtonImpl->SetTextColor(color); + + return; +} + +Color +CheckButton::GetTextColor(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetTextColor(); +} + +result +CheckButton::SetDisabledTextColor(const Color& color) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pCheckButtonImpl->SetDisabledTextColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Color +CheckButton::GetDisabledTextColor(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetDisabledTextColor(); +} + +result +CheckButton::SetPressedTextColor(const Color& color) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pCheckButtonImpl->SetPressedTextColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Color +CheckButton::GetPressedTextColor(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetPressedTextColor(); +} + +result +CheckButton::SetHighlightedTextColor(const Color& color) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pCheckButtonImpl->SetHighlightedTextColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Color +CheckButton::GetHighlightedTextColor(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetHighlightedTextColor(); +} + +void +CheckButton::SetTitleTextColor(const Color& color) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pCheckButtonImpl->SetTitleTextColor(color); + + return; +} + +Color +CheckButton::GetTitleTextColor(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetTitleTextColor(); +} + +result +CheckButton::SetDisabledTitleTextColor(const Color& color) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pCheckButtonImpl->SetDisabledTitleTextColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Color +CheckButton::GetDisabledTitleTextColor(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetDisabledTitleTextColor(); +} + +result +CheckButton::SetPressedTitleTextColor(const Color& color) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pCheckButtonImpl->SetPressedTitleTextColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Color +CheckButton::GetPressedTitleTextColor(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetPressedTitleTextColor(); +} + +result +CheckButton::SetHighlightedTitleTextColor(const Color& color) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pCheckButtonImpl->SetHighlightedTitleTextColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Color +CheckButton::GetHighlightedTitleTextColor(void) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetHighlightedTitleTextColor(); +} + +result +CheckButton::SetColor(CheckButtonStatus status, const Color& color) +{ + _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pCheckButtonImpl->SetColor(status, color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS;; +} + +Color +CheckButton::GetColor(CheckButtonStatus status) const +{ + const _CheckButtonImpl* pCheckButtonImpl = _CheckButtonImpl::GetInstance(*this); + SysAssertf(pCheckButtonImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pCheckButtonImpl->GetColor(status); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlColorPicker.cpp b/src/ui/controls/FUiCtrlColorPicker.cpp new file mode 100644 index 0000000..0e0f6eb --- /dev/null +++ b/src/ui/controls/FUiCtrlColorPicker.cpp @@ -0,0 +1,174 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlColorPicker.cpp + * @brief This is the implementation file for the %ColorPicker class. + */ + +#include +#include +#include "FUiCtrl_ColorPickerImpl.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +ColorPicker::ColorPicker(void) +{ +} + +ColorPicker::~ColorPicker(void) +{ +} + +result +ColorPicker::Construct(const Point& point) +{ + SysAssertf((_ColorPickerImpl::GetInstance(*this) == null), + "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class"); + + _ColorPickerImpl* pImpl = _ColorPickerImpl::CreateColorPickerImplN(*this); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pImpl != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + r = SetPosition(point); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete pImpl; + pImpl = null; + + return r; +} + +Color +ColorPicker::GetColor(void) const +{ + const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + Color color = pImpl->GetColor(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), color, r, "[%s] Propagating.", GetErrorMessage(r)); + + return color; +} + +int +ColorPicker::GetHue(void) const +{ + const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + int hue = pImpl->GetHue(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), hue, r, "[%s] Propagating.", GetErrorMessage(r)); + + return hue; +} + +int +ColorPicker::GetSaturation(void) const +{ + const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + int sat = pImpl->GetSaturation(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), sat, r, "[%s] Propagating.", GetErrorMessage(r)); + + return sat; +} + +int +ColorPicker::GetLuminance(void) const +{ + const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + int lum = pImpl->GetLuminance(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), lum, r, "[%s] Propagating.", GetErrorMessage(r)); + + return lum; +} + +void +ColorPicker::SetColor(const Tizen::Graphics::Color& color) +{ + _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetColor(color); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ColorPicker::SetHue(int hue) +{ + _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetHue(hue); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ColorPicker::SetSaturation(int saturation) +{ + _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetSaturation(saturation); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ColorPicker::SetLuminance(int luminance) +{ + _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetLuminance(luminance); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ColorPicker::AddColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener) +{ + _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddColorChangeEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ColorPicker::RemoveColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener) +{ + _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveColorChangeEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlContextMenu.cpp b/src/ui/controls/FUiCtrlContextMenu.cpp new file mode 100644 index 0000000..f1c586a --- /dev/null +++ b/src/ui/controls/FUiCtrlContextMenu.cpp @@ -0,0 +1,618 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlContextMenu.cpp + * @brief This file contains implementation of ContextMenu class + */ + +#include +#include +#include +#include +#include "FUiCtrl_ContextMenuImpl.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +ContextMenu::ContextMenu(void) +{ +} + +ContextMenu::~ContextMenu(void) +{ +} + +result +ContextMenu::Construct(const Tizen::Graphics::Point& point, ContextMenuStyle style) +{ + result r = E_SUCCESS; + + r = Construct(point, style, CONTEXT_MENU_ANCHOR_DIRECTION_AUTO); + + return r; +} + +result +ContextMenu::Construct(const Tizen::Graphics::Point& point, ContextMenuStyle style, ContextMenuAnchorDirection direction) +{ + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + result r = E_SUCCESS; + + // Create a ContextMenu Impl + pImpl = _ContextMenuImpl::CreateContextMenuImplN(this, point, style, direction); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return r; +} + +void +ContextMenu::AddActionEventListener(Tizen::Ui::IActionEventListener& listener) +{ + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + r = pImpl->AddActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ContextMenu::RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener) +{ + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + r = pImpl->RemoveActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +ContextMenu::AddItem(const Tizen::Base::String& text, int actionId) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + r = pImpl->AddItem(text, actionId, null, null, null); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::AddItem(const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, + const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + ContextMenuStyle style = pImpl->GetPublicStyle(); + + if (style != CONTEXT_MENU_STYLE_LIST) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument at style."); + return E_INVALID_ARG; + } + + r = pImpl->AddItem(text, actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::AddItem(const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, int actionId) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + ContextMenuStyle style = pImpl->GetPublicStyle(); + + if (style == CONTEXT_MENU_STYLE_LIST) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "[E_INVALID_STATE] Invalid argument at style."); + return E_INVALID_STATE; + } + + r = pImpl->AddItem(Tizen::Base::String(""), actionId, &normalBitmap, pPressedBitmap, null); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::AddItem(const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap, + int actionId) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + ContextMenuStyle style = pImpl->GetPublicStyle(); + + if (style == CONTEXT_MENU_STYLE_LIST) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "[E_INVALID_STATE] Invalid argument at style."); + return E_INVALID_STATE; + } + + r = pImpl->AddItem(Tizen::Base::String(""), actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::InsertItemAt(int index, const Tizen::Base::String& text, int actionId) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + if (index > GetItemCount() || index < 0) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is not valid(index = %d).", index); + return E_OUT_OF_RANGE; + } + + r = pImpl->InsertItem(index, text, actionId, null, null, null); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::InsertItemAt(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, + const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + ContextMenuStyle style = pImpl->GetPublicStyle(); + + if (style != CONTEXT_MENU_STYLE_LIST) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "[E_INVALID_STATE] Invalid argument at style."); + return E_INVALID_STATE; + } + + if (index > GetItemCount() || index < 0) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is not valid(index = %d).", index); + return E_OUT_OF_RANGE; + } + + r = pImpl->InsertItem(index, text, actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::InsertItemAt(int index, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, + int actionId) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + ContextMenuStyle style = pImpl->GetPublicStyle(); + + if (style == CONTEXT_MENU_STYLE_LIST) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "[E_INVALID_STATE] Invalid argument at style."); + return E_INVALID_STATE; + } + + if (index > GetItemCount() || index < 0) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is not valid(index = %d).", index); + return E_OUT_OF_RANGE; + } + + r = pImpl->InsertItem(index, Tizen::Base::String(""), actionId, &normalBitmap, pPressedBitmap, null); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::InsertItemAt(int index, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap, + int actionId) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + ContextMenuStyle style = pImpl->GetPublicStyle(); + + if (style == CONTEXT_MENU_STYLE_LIST) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "[E_INVALID_STATE] Invalid argument at style."); + return E_INVALID_STATE; + } + + if (index > GetItemCount() || index < 0) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is not valid(index = %d).", index); + return E_OUT_OF_RANGE; + } + + r = pImpl->InsertItem(index, Tizen::Base::String(""), actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::SetItemAt(int index, const Tizen::Base::String& text, int actionId) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + if (index >= GetItemCount() || index < 0) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is not valid(index = %d).", index); + return E_OUT_OF_RANGE; + } + + r = pImpl->SetItem(index, text, actionId, null, null, null); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::SetItemAt(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, + const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + ContextMenuStyle style = pImpl->GetPublicStyle(); + + if (style != CONTEXT_MENU_STYLE_LIST) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "[E_INVALID_STATE] Invalid argument at style."); + return E_INVALID_STATE; + } + + if (index >= GetItemCount() || index < 0) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is not valid(index = %d).", index); + return E_OUT_OF_RANGE; + } + + r = pImpl->SetItem(index, text, actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::SetItemAt(int index, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, + int actionId) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + ContextMenuStyle style = pImpl->GetPublicStyle(); + + if (style == CONTEXT_MENU_STYLE_LIST) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "[E_INVALID_STATE] Invalid argument at style."); + return E_INVALID_STATE; + } + + if (index >= GetItemCount() || index < 0) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is not valid(index = %d).", index); + return E_OUT_OF_RANGE; + } + + r = pImpl->SetItem(index, Tizen::Base::String(""), actionId, &normalBitmap, pPressedBitmap, null); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::SetItemAt(int index, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap, + int actionId) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + ContextMenuStyle style = pImpl->GetPublicStyle(); + + if (style == CONTEXT_MENU_STYLE_LIST) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "[E_INVALID_STATE] Invalid argument at style."); + return E_INVALID_STATE; + } + +// if (index >= MAX_ITEM_COUNT || index < 0) + if (index >= GetItemCount() || index < 0) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is not valid(index = %d).", index); + return E_OUT_OF_RANGE; + } + + r = pImpl->SetItem(index, Tizen::Base::String(""), actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::RemoveItemAt(int index) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + r = pImpl->RemoveItemAt(index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::RemoveAllItems(void) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + r = pImpl->RemoveAllItems(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +ContextMenu::GetItemCount(void) const +{ + // check whether the ContextMenu was created. + const _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemCount(); +} + +int +ContextMenu::GetItemIndexFromActionId(int actionId) const +{ + // check whether the ContextMenu was created. + const _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromActionId(actionId); +} + +int +ContextMenu::GetItemActionIdAt(int index) const +{ + // check whether the ContextMenu was created. + const _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + +// if (index > MAX_ITEM_COUNT || index < 0) + if (index >= GetItemCount() || index < 0) + { + SysTryReturn(NID_UI_CTRL, false, -1, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified index is not valid(index = %d).", index); + } + + return pImpl->GetItemActionIdAt(index); +} + +Tizen::Graphics::Color +ContextMenu::GetItemTextColor(ContextMenuItemStatus status) const +{ + // check whether the ContextMenu was created. + const _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + Tizen::Graphics::Color color = pImpl->GetItemTextColor(status); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Tizen::Graphics::Color(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r)); + + return color; +} + +result +ContextMenu::SetItemTextColor(ContextMenuItemStatus status, const Tizen::Graphics::Color& color) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + r = pImpl->SetItemTextColor(status, color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ContextMenu::SetAnchorPosition(const Tizen::Graphics::Point& position) +{ + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + r = pImpl->SetAnchorPosition(position.x, position.y); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Tizen::Graphics::Point +ContextMenu::GetAnchorPosition(void) const +{ + const _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + Tizen::Graphics::Point position = pImpl->GetAnchorPosition(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Tizen::Graphics::Point(0, 0), r, "[%s] Propagating.", GetErrorMessage(r)); + + return position; +} + + +Tizen::Graphics::Color +ContextMenu::GetColor(void) const +{ + // check whether the ContextMenu was created. + const _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + Tizen::Graphics::Color color = pImpl->GetColor(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Tizen::Graphics::Color(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r)); + + return color; +} + +result +ContextMenu::SetColor(const Tizen::Graphics::Color& color) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + r = pImpl->SetColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Tizen::Graphics::Color +ContextMenu::GetItemColor(ContextMenuItemStatus status) const +{ + // check whether the ContextMenu was created. + const _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI_CTRL, (status != CONTEXT_MENU_ITEM_STATUS_NORMAL), Color(0, 0, 0, 0), E_INVALID_STATE, + "[E_INVALID_ARG] CONTEXT_MENU_ITEM_STATUS_NORMAL is not supported."); + + Tizen::Graphics::Color color = pImpl->GetItemColor(status); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Tizen::Graphics::Color(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r)); + + return color; +} + +result +ContextMenu::SetItemColor(ContextMenuItemStatus status, const Tizen::Graphics::Color& color) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI_CTRL, (status != CONTEXT_MENU_ITEM_STATUS_NORMAL), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] CONTEXT_MENU_ITEM_STATUS_NORMAL is not supported."); + + result r = E_SUCCESS; + + r = pImpl->SetItemColor(status, color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +ContextMenu::GetMaxVisibleItemsCount(void) const +{ + // check whether the ContextMenu was created. + const _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetMaxVisibleItemsCount(); +} + +result +ContextMenu::SetMaxVisibleItemsCount(int maxItemsCount) +{ + // check whether the ContextMenu was created. + _ContextMenuImpl* pImpl = _ContextMenuImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + // check count + SysTryReturnResult(NID_UI_CTRL, ((maxItemsCount > 0) && (maxItemsCount < 8)), E_OUT_OF_RANGE, + "Maximum should be greater than 0 and less than 8."); + + result r = E_SUCCESS; + + r = pImpl->SetMaxVisibleItemsCount(maxItemsCount); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +}}} // Tizen::Ui: Control diff --git a/src/ui/controls/FUiCtrlCustomItem.cpp b/src/ui/controls/FUiCtrlCustomItem.cpp new file mode 100644 index 0000000..9a593b4 --- /dev/null +++ b/src/ui/controls/FUiCtrlCustomItem.cpp @@ -0,0 +1,162 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlCustomItem.cpp + * @brief This is the implementation file for CustomItem class. + * + * This file contains the implementation of CustomItem class. + */ + +#include +#include +#include "FUiCtrl_CustomItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +CustomItem::CustomItem(void) +{ +} + +CustomItem::~CustomItem(void) +{ +} + +result +CustomItem::Construct(const Dimension& itemSize, ListAnnexStyle style) +{ + result r = E_SUCCESS; + + _CustomItemImpl* pCustomImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pCustomImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pCustomImpl = _CustomItemImpl::CreateCustomItemImplN(this, itemSize, style); + SysTryReturn(NID_UI_CTRL, pCustomImpl != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _pImpl = pCustomImpl; + + return r; +} + +result +CustomItem::AddElement(const Rectangle& rect, int elementId, const EnrichedText& text) +{ + _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddElement(rect, elementId, text); +} + +result +CustomItem::AddElement(const Rectangle& rect, int elementId, const String& text, bool textSliding) +{ + _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddElement(rect, elementId, text, textSliding); +} + +result +CustomItem::AddElement(const Rectangle& rect, int elementId, const String& text, int textSize, const Color& normalTextColor, + const Color& pressedTextColor, const Color& highlightedTextColor, bool textSliding) +{ + _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddElement(rect, elementId, text, textSize, normalTextColor, + pressedTextColor, highlightedTextColor, textSliding); +} + +result +CustomItem::AddElement(const Rectangle& rect, int elementId, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap, + const Bitmap* pHighlightedbitmap) +{ + _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddElement(rect, elementId, normalBitmap, pPressedBitmap, pHighlightedbitmap); +} + +result +CustomItem::AddElement(const Rectangle& rect, int elementId, const ICustomElement& element) +{ + _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddElement(rect, elementId, element); +} + +result +CustomItem::RemoveAllElements(void) +{ + _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveAllElements(); +} + +result +CustomItem::RemoveElement(int elementId) +{ + _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveElement(elementId); +} + +result +CustomItem::SetElementSelectionEnabled(int elementId, bool enable) +{ + _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetElementSelectionEnabled(elementId, enable); +} + +result +CustomItem::SetElementTextHorizontalAlignment(int elementId, HorizontalAlignment alignment) +{ + _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetElementTextHorizontalAlignment(elementId, alignment); +} + +result +CustomItem::SetElementTextVerticalAlignment(int elementId, VerticalAlignment alignment) +{ + _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetElementTextVerticalAlignment(elementId, alignment); +} + +result +CustomItem::SetElementAutoLinkMask(int elementId, unsigned long mask) +{ + _CustomItemImpl* pImpl = static_cast<_CustomItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetElementAutoLinkMask(elementId, mask); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlCustomList.cpp b/src/ui/controls/FUiCtrlCustomList.cpp new file mode 100644 index 0000000..469e2cb --- /dev/null +++ b/src/ui/controls/FUiCtrlCustomList.cpp @@ -0,0 +1,424 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlCustomList.cpp +* @brief This file contains implementation of CustomList class +*/ + + +#include +#include +#include "FUiCtrl_CustomListImpl.h" + +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +CustomList::CustomList(void) +{ +} + +CustomList::~CustomList(void) +{ +} + +result +CustomList::Construct(const Rectangle& rect, CustomListStyle style, bool itemDivider) +{ + result r = E_SUCCESS; + + _CustomListImpl* pCustomListImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pCustomListImpl == null), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pCustomListImpl = _CustomListImpl::CreateCustomListImplN(this, rect, itemDivider); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCustomListImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pCustomListImpl; + + r = pCustomListImpl->InitializeBounds(rect); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCustomListImpl->SetListStyle(style); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pCustomListImpl->Initialize(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pCustomListImpl->LoadDefaultBitmap(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return E_SUCCESS; + +CATCH: + Dispose(); + return E_SYSTEM; +} + +void +CustomList::AddCustomItemEventListener(ICustomItemEventListener& listener) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddCustomItemEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +CustomList::RemoveCustomItemEventListener(ICustomItemEventListener& listener) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveCustomItemEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +CustomList::AddItem(const CustomListItem& item, int itemId) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddItem(item, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to add an item.", GetErrorMessage(r)); + + return r; +} + +result +CustomList::InsertItemAt(int index, const CustomListItem& item, int itemId) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->InsertItemAt(index, item, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to insert an item.", GetErrorMessage(r)); + + return r; +} + +result +CustomList::SetItemAt(int index, const CustomListItem& item, int itemId) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetItemAt(index, item, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to set an item.", GetErrorMessage(r)); + + return r; +} + +result +CustomList::RemoveItemAt(int index) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveItemAt(index); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to remove an item.", GetErrorMessage(r)); + + return r; +} + +result +CustomList::RemoveAllItems(void) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveAllItems(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to remove all items.", GetErrorMessage(r)); + + return r; +} + +const CustomListItem* +CustomList::GetItemAt(int index) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + const CustomListItem* pItem = pImpl->GetCustomListItemAt(-1, index); + return pItem; +} + +int +CustomList::GetItemCount(void) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemCount(); +} + +result +CustomList::SetItemEnabled(int index, bool enable) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetItemEnabled(index, enable); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to SetItemEnabled.", GetErrorMessage(r)); + + return r; +} + +bool +CustomList::IsItemEnabled(int index) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemEnabled(index); +} + +result +CustomList::SetItemChecked(int index, bool check) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetItemChecked(index, check); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to SetItemChecked.", GetErrorMessage(r)); + + return r; +} + +bool +CustomList::IsItemChecked(int index) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemChecked(index); +} + +result +CustomList::SetAllItemsChecked(bool check) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetAllItemsChecked(check); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to SetAllItemsChecked.", GetErrorMessage(r)); + + return r; +} + +result +CustomList::RemoveAllCheckedItems(void) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveAllCheckedItems(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to SetAllItemsChecked.", GetErrorMessage(r)); + + return r; +} + +int +CustomList::GetFirstCheckedItemIndex(void) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetFirstCheckedItemIndex(); +} + +int +CustomList::GetLastCheckedItemIndex(void) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLastCheckedItemIndex(); +} + +int +CustomList::GetNextCheckedItemIndexAfter(int index) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetNextCheckedItemIndexAfter(index); +} + +int +CustomList::GetItemIndexFromPosition(int x, int y) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int groupIndex = -1; + int itemIndex = -1; + + result r = pImpl->GetItemIndexFromPosition(Point(x, y), groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return itemIndex; +} + +int +CustomList::GetItemIndexFromPosition(const Point& position) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int groupIndex = -1; + int itemIndex = -1; + + result r = pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return itemIndex; +} + +int +CustomList::GetTopDrawnItemIndex(void) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int groupIndex = -1; + int itemIndex = -1; + + result r = pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return itemIndex; +} + +int +CustomList::GetBottomDrawnItemIndex(void) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int groupIndex = -1; + int itemIndex = -1; + + result r = pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return itemIndex; +} + +void +CustomList::SetBackgroundColor(const Color& color) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->SetBackgroundColor(color); +} + +void +CustomList::SetTextOfEmptyList(const String& text) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextOfEmptyList(text); +} + +void +CustomList::SetTextColorOfEmptyList(const Color& color) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextColorOfEmptyList(color); +} + +Color +CustomList::GetTextColorOfEmptyList(void) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextColorOfEmptyList(); +} + +int +CustomList::GetItemIndexFromItemId(int itemId) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromItemId(itemId); +} + +int +CustomList::GetItemIdAt(int index) const +{ + const _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIdAt(index); +} + +void +CustomList::ScrollToBottom(void) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->ScrollToBottom(); +} + +void +CustomList::ScrollToTop(void) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->ScrollToTop(); +} + +result +CustomList::ScrollToTop(int index) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollToTop(index); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to ScrollToTop.", GetErrorMessage(r)); + + return r; +} + +result +CustomList::RefreshItem(int index) +{ + _CustomListImpl* pImpl = _CustomListImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RefreshItem(index); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to Refresh an item.", GetErrorMessage(r)); + + return r; +} + +}}} // Tizen::Controls::Ui diff --git a/src/ui/controls/FUiCtrlCustomListItem.cpp b/src/ui/controls/FUiCtrlCustomListItem.cpp new file mode 100644 index 0000000..343c1d1 --- /dev/null +++ b/src/ui/controls/FUiCtrlCustomListItem.cpp @@ -0,0 +1,175 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlCustomListItem.cpp +* @brief This file contains implementation of CustomListItem class +*/ + +#include +#include +#include +#include +#include +#include "FUiCtrl_CustomListItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +CustomListItem::CustomListItem(void) + : __pCustomListItemFormat(null) + , __pCustomListItemImpl(null) +{ +} + +CustomListItem::~CustomListItem(void) +{ + delete __pCustomListItemImpl; + __pCustomListItemImpl = null; +} + +result +CustomListItem::Construct(int itemHeight) +{ + result r = E_SUCCESS; + + SysAssertf((__pCustomListItemImpl == null), + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for thisclass."); + + __pCustomListItemImpl = _CustomListItemImpl::CreateInstanceN(itemHeight); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pCustomListItemImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +CustomListItem::SetItemFormat(const CustomListItemFormat& itemFormat) +{ + SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use."); + __pCustomListItemFormat = const_cast< CustomListItemFormat* >(&itemFormat); +} + +const CustomListItemFormat* +CustomListItem::GetItemFormat(void) const +{ + return __pCustomListItemFormat; +} + +void +CustomListItem::SetFocusedItemBackgroundBitmap(const Bitmap& bitmap) +{ + SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use."); + __pCustomListItemImpl->SetFocusedItemBackgroundBitmap(bitmap); +} + +void +CustomListItem::SetNormalItemBackgroundBitmap(const Bitmap& bitmap) +{ + SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use."); + __pCustomListItemImpl->SetNormalItemBackgroundBitmap(bitmap); +} + +void +CustomListItem::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap) +{ + SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use."); + __pCustomListItemImpl->SetHighlightedItemBackgroundBitmap(bitmap); +} + +result +CustomListItem::SetElement(int elementId, const String& text) +{ + SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use."); + result r = __pCustomListItemImpl->SetElement(elementId, text); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to Set an Element.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +CustomListItem::SetElement(int elementId, const Bitmap& normalBitmap, const Bitmap* pFocusedBitmap) +{ + SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = __pCustomListItemImpl->SetElement(elementId, normalBitmap, pFocusedBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to Set an Element.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +CustomListItem::SetElement(int elementId, const Bitmap& normalBitmap, const Bitmap* pFocusedBitmap, const Bitmap* pHighlightedBitmap) +{ + SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = __pCustomListItemImpl->SetElement(elementId, normalBitmap, pFocusedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to Set an Element.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +CustomListItem::SetElement(int elementId, const ICustomListElement& element) +{ + SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = __pCustomListItemImpl->SetElement(elementId, element); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to Set an Element.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +CustomListItem::SetCheckBox(int elementId) +{ + SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use."); + + SysTryReturnResult(NID_UI_CTRL, __pCustomListItemFormat, E_SYSTEM, "The CustomListItemFormat is not constructed."); + + if (__pCustomListItemFormat->GetElement(elementId) == Rectangle(0, 0, -1, -1)) + { + return E_SYSTEM; + } + + __pCustomListItemImpl->SetCheckBox(elementId); + + return E_SUCCESS; +} + +result +CustomListItem::SetValue(int value) +{ + SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = __pCustomListItemImpl->SetValue(value); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to set the value."); + + return r; +} + +int +CustomListItem::GetValue(void) const +{ + SysAssertf((__pCustomListItemImpl != null), "Not yet constructed. Construct() should be called before use."); + return __pCustomListItemImpl->GetValue(); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlCustomListItemFormat.cpp b/src/ui/controls/FUiCtrlCustomListItemFormat.cpp new file mode 100644 index 0000000..b6b1c0d --- /dev/null +++ b/src/ui/controls/FUiCtrlCustomListItemFormat.cpp @@ -0,0 +1,175 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlCustomListItemFormat.cpp +* @brief This file contains implementation of CustomListItemFormat class +*/ + +#include +#include +#include +#include +#include "FUiCtrl_CustomListItemFormatImpl.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +CustomListItemFormat::CustomListItemFormat(void) + :__pCustomListItemFormatImpl(null) +{ +} + +CustomListItemFormat::~CustomListItemFormat(void) +{ + delete __pCustomListItemFormatImpl; + __pCustomListItemFormatImpl = null; +} + +result +CustomListItemFormat::Construct(void) +{ + SysAssertf((__pCustomListItemFormatImpl == null), + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + __pCustomListItemFormatImpl = _CustomListItemFormatImpl::CreateInstanceN(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pCustomListItemFormatImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +CustomListItemFormat::AddElement(int elementId, const Rectangle& rect) +{ + SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use."); + + SysTryReturnResult(NID_UI_CTRL, (rect.width > 0 && rect.height >0), E_INVALID_ARG, "The width and height should be greater than 0."); + + result r = __pCustomListItemFormatImpl->AddElement(elementId, rect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] A System error occurred.", GetErrorMessage(r)); + + return r; + +} + +result +CustomListItemFormat::AddElement(int elementId, const Rectangle& rect, int textSize) +{ + SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use."); + + SysTryReturnResult(NID_UI_CTRL, (rect.width > 0 && rect.height >0), E_INVALID_ARG, "The width and height should be greater than 0."); + + result r = __pCustomListItemFormatImpl->AddElement(elementId, rect, textSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] A System error occurred.", GetErrorMessage(r)); + + return r; +} + +result +CustomListItemFormat::AddElement(int elementId, const Rectangle& rect, int textSize, const Color& normalTextColor, const Color& focusedTextColor) +{ + SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use."); + + SysTryReturnResult(NID_UI_CTRL, (rect.width > 0 && rect.height >0), E_INVALID_ARG, "The width and height should be greater than 0."); + + result r = __pCustomListItemFormatImpl->AddElement(elementId, rect, textSize, normalTextColor, focusedTextColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] A System error occurred.", GetErrorMessage(r)); + + return r; +} + +result +CustomListItemFormat::AddElement(int elementId, const Rectangle& rect, int textSize, const Color& normalTextColor, const Color& focusedTextColor, const Color& highlightedTextColor) +{ + SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use."); + + SysTryReturnResult(NID_UI_CTRL, (rect.width > 0 && rect.height >0), E_INVALID_ARG, "The width and height should be greater than 0."); + + result r = __pCustomListItemFormatImpl->AddElement(elementId, rect, textSize, normalTextColor, focusedTextColor, highlightedTextColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] A System error occurred.", GetErrorMessage(r)); + + return r; +} + +Rectangle +CustomListItemFormat::GetElement(int elementId) const +{ + SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + return __pCustomListItemFormatImpl->GetElement(elementId); +} + +int +CustomListItemFormat::GetFirstElementId(void) const +{ + SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + return __pCustomListItemFormatImpl->GetFirstElementId(); +} + +int +CustomListItemFormat::GetNextElementId(int elementId) const +{ + SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + return __pCustomListItemFormatImpl->GetNextElementId(elementId); +} + +int +CustomListItemFormat::GetFirstEnabledElementId(void) const +{ + SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + return __pCustomListItemFormatImpl->GetFirstEnabledElementId(); +} + +int +CustomListItemFormat::GetNextEnabledElementId(int elementId) const +{ + SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + return __pCustomListItemFormatImpl->GetNextEnabledElementId(elementId); +} + +int +CustomListItemFormat::GetPreviousEnabledElementId(int elementId) const +{ + SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + return __pCustomListItemFormatImpl->GetPreviousEnabledElementId(elementId); +} + +void +CustomListItemFormat::SetElementEventEnabled(int elementId, bool enable) +{ + SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + __pCustomListItemFormatImpl->SetElementEventEnabled(elementId, enable); +} + +bool +CustomListItemFormat::IsElementEventEnabled(int elementId) +{ + SysAssertf((__pCustomListItemFormatImpl != null), "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + return __pCustomListItemFormatImpl->IsElementEventEnabled(elementId); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlDatePicker.cpp b/src/ui/controls/FUiCtrlDatePicker.cpp new file mode 100644 index 0000000..6b1c83c --- /dev/null +++ b/src/ui/controls/FUiCtrlDatePicker.cpp @@ -0,0 +1,219 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlDatePicker.cpp + * @brief This is the implementation file for the DatePicker class. + */ + +#include +#include +#include +#include "FUiCtrl_DatePickerImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::System; + +namespace Tizen { namespace Ui { namespace Controls +{ + +DatePicker::DatePicker(void) +{ +} + +DatePicker::~DatePicker(void) +{ +} + +result +DatePicker::Construct(const Tizen::Base::String& title) +{ + _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl == null), + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _DatePickerImpl::CreateDatePickerImplN(this, title); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pImpl != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + pImpl->GetCore().SetResizable(false); + pImpl->GetCore().SetMovable(false); + + return r; +} + +void +DatePicker::AddDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener) +{ + _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddDateChangeEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +DatePicker::RemoveDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener) +{ + _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveDateChangeEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +Tizen::Base::DateTime +DatePicker::GetDate(void) const +{ + result r = E_SUCCESS; + Tizen::Base::DateTime dateTime; + const _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + if (pImpl == null) + { + r = SystemTime::GetCurrentTime(WALL_TIME, dateTime); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, dateTime, r, "[%s] Propagating.", GetErrorMessage(r)); + return dateTime; + } + + dateTime = pImpl->GetDate(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, dateTime, r, "[%s] Propagating.", GetErrorMessage(r)); + + return dateTime; +} + +int +DatePicker::GetDay(void) const +{ + const _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int day = pImpl->GetDay(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, day, r, "[%s] Propagating.", GetErrorMessage(r)); + + return day; +} + +int +DatePicker::GetMonth(void) const +{ + const _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int month = pImpl->GetMonth(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, month, r, "[%s] Propagating.", GetErrorMessage(r)); + + return month; +} + +int +DatePicker::GetYear(void) const +{ + const _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int year = pImpl->GetYear(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, year, r, "[%s] Propagating.", GetErrorMessage(r)); + + return year; +} + +void +DatePicker::SetDate(const Tizen::Base::DateTime& date) +{ + _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->SetDate(date); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +DatePicker::SetCurrentDate(void) +{ + _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->SetCurrentDate(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +DatePicker::SetYear(int year) +{ + _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetYear(year); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +DatePicker::SetMonth(int month) +{ + _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetMonth(month); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +DatePicker::SetDay(int day) +{ + _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetDay(day); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +DatePicker::SetYearRange(int minYear, int maxYear) +{ + _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetYearRange(minYear, maxYear); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +DatePicker::GetYearRange(int& minYear, int& maxYear) const +{ + const _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetYearRange(minYear, maxYear); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlDateTimePicker.cpp b/src/ui/controls/FUiCtrlDateTimePicker.cpp new file mode 100644 index 0000000..4de0388 --- /dev/null +++ b/src/ui/controls/FUiCtrlDateTimePicker.cpp @@ -0,0 +1,287 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlDateTimePicker.cpp + * @brief This is the implementation file for the DateTimePicker class. + */ + +#include +#include +#include +#include +#include "FUiCtrl_DateTimePickerImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::System; + +namespace Tizen { namespace Ui { namespace Controls +{ + +DateTimePicker::DateTimePicker(void) +{ +} + +DateTimePicker::~DateTimePicker(void) +{ +} + +result +DateTimePicker::Construct(const Tizen::Base::String& title) +{ + _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl == null), + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _DateTimePickerImpl::CreateDateTimePickerImplN(this, title); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pImpl != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + pImpl->GetCore().SetResizable(false); + pImpl->GetCore().SetMovable(false); + + return r; +} + +void +DateTimePicker::AddDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener) +{ + _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddDateTimeChangeEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +DateTimePicker::RemoveDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener) +{ + _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveDateTimeChangeEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +DateTimePicker::SetDateTime(const Tizen::Base::DateTime& dateTime) +{ + _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->SetDateTime(dateTime); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +DateTimePicker::SetCurrentDateTime(void) +{ + _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->SetCurrentDateTime(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +DateTimePicker::SetYear(int year) +{ + _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetYear(year); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +DateTimePicker::SetMonth(int month) +{ + _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetMonth(month); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +DateTimePicker::SetDay(int day) +{ + _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetDay(day); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +DateTimePicker::SetHour(int hour) +{ + _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetHour(hour); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +DateTimePicker::SetMinute(int minute) +{ + _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetMinute(minute); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Tizen::Base::DateTime +DateTimePicker::GetDateTime(void) const +{ + const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + DateTime dateTime = pImpl->GetDateTime(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, dateTime, r, "[%s] Propagating.", GetErrorMessage(r)); + + return dateTime; +} + +int +DateTimePicker::GetYear(void) const +{ + const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int year = pImpl->GetYear(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, year, r, "[%s] Propagating.", GetErrorMessage(r)); + + return year; +} + +int +DateTimePicker::GetMonth(void) const +{ + const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int month = pImpl->GetMonth(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, month, r, "[%s] Propagating.", GetErrorMessage(r)); + + return month; +} + +int +DateTimePicker::GetDay(void) const +{ + const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int day = pImpl->GetDay(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, day, r, "[%s] Propagating.", GetErrorMessage(r)); + + return day; +} + +int +DateTimePicker::GetHour(void) const +{ + const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int hour = pImpl->GetHour(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, hour, r, "[%s] Propagating.", GetErrorMessage(r)); + + return hour; +} + +int +DateTimePicker::GetMinute(void) const +{ + const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int minute = pImpl->GetMinute(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, minute, r, "[%s] Propagating.", GetErrorMessage(r)); + + return minute; +} + +void +DateTimePicker::Set24HourNotationEnabled(bool enable) +{ + _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->Set24HourNotationEnabled(enable); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +bool +DateTimePicker::Is24HourNotationEnabled(void) const +{ + const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + bool enabled = pImpl->Is24HourNotationEnabled(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, enabled, r, "[%s] Propagating.", GetErrorMessage(r)); + + return enabled; +} + +result +DateTimePicker::SetYearRange(int minYear, int maxYear) +{ + _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetYearRange(minYear, maxYear); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +DateTimePicker::GetYearRange(int& minYear, int& maxYear) const +{ + const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetYearRange(minYear, maxYear); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlEditArea.cpp b/src/ui/controls/FUiCtrlEditArea.cpp new file mode 100644 index 0000000..acb0df4 --- /dev/null +++ b/src/ui/controls/FUiCtrlEditArea.cpp @@ -0,0 +1,858 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlEditArea.cpp + * @brief This is the implementation file for EditArea class. + */ + +#include +#include +#include "FUiCtrl_EditAreaImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::Security; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +EditArea::EditArea(void) +{ +} + +EditArea::~EditArea(void) +{ + +} + +result +EditArea::Construct(const Rectangle& rect, InputStyle inputStyle, int limitLength) +{ + result r = E_SUCCESS; + + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pEditAreaImpl = _EditAreaImpl::CreateEditAreaImplN(this, rect); + SysTryReturn(NID_UI_CTRL, pEditAreaImpl != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _pControlImpl = pEditAreaImpl; + + r = SetBounds(rect.x, rect.y, rect.width, rect.height); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pEditAreaImpl->Initialize(inputStyle, limitLength); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete pEditAreaImpl; + _pControlImpl = null; + + return r; +} + +HorizontalAlignment +EditArea::GetTextAlignment(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetTextAlignment(); +} + +result +EditArea::SetTextAlignment(HorizontalAlignment alignment) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetTextAlignment(alignment); +} + +bool +EditArea::IsViewModeEnabled(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->IsViewModeEnabled(); +} + +result +EditArea::SetViewModeEnabled(bool enable) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetViewModeEnabled(enable); +} + +result +EditArea::SetAutoLinkMask(unsigned long autoLinks) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetAutoLinkMask(autoLinks); +} + +unsigned long +EditArea::GetAutoLinkMask(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetAutoLinkMask(); +} + +int +EditArea::GetLineSpacing(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetLineSpacing(); +} + +result +EditArea::SetLineSpacing(int multiplier, int extra) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetLineSpacing(multiplier, extra); +} + +int +EditArea::GetMargin(EditMarginType marginType) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetMargin(marginType); +} + +result +EditArea::SetMargin(EditMarginType marginType, int margin) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetMargin(marginType, margin); +} + +result +EditArea::SetKeypadActionEnabled(bool enable) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetKeypadActionEnabled(enable); +} + +bool +EditArea::IsKeypadActionEnabled(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->IsKeypadActionEnabled(); +} + + +KeypadAction +EditArea::GetKeypadAction(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetKeypadAction(); +} + +result +EditArea::SetKeypadAction(KeypadAction keypadAction) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetKeypadAction(keypadAction); +} + +KeypadStyle +EditArea::GetKeypadStyle(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetKeypadStyle(); +} + +result +EditArea::SetKeypadStyle(KeypadStyle keypadStyle) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetKeypadStyle(keypadStyle); +} + +bool +EditArea::IsTextPredictionEnabled(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->IsTextPredictionEnabled(); +} + +result +EditArea::SetTextPredictionEnabled(bool enable) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetTextPredictionEnabled(enable); +} + +result +EditArea::SetOverlayKeypadCommandButtonVisible(bool visible) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetOverlayKeypadCommandButtonVisible(visible); +} + +bool +EditArea::IsOverlayCommandButtonVisible(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->IsOverlayCommandButtonVisible(); +} + +result +EditArea::HideKeypad(void) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->HideKeypad(); +} + +int +EditArea::GetTextSize(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetTextSize(); +} + +result +EditArea::SetTextSize(int size) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetTextSize(size); +} + +Color +EditArea::GetColor(EditStatus status) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetColor(status); +} + +Color +EditArea::GetTextColor(EditTextColor type) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetTextColor(type); +} + +result +EditArea::SetBackgroundBitmap(EditStatus status, const Bitmap& bitmap) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetBackgroundBitmap(status, bitmap); +} + +result +EditArea::SetColor(EditStatus status, const Color& color) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetColor(status, color); +} + +result +EditArea::SetTextColor(EditTextColor type, const Color& color) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetTextColor(type, color); +} + +String +EditArea::GetText(int start, int end) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetText(start, end); +} + +void +EditArea::AddUiLinkEventListener(IUiLinkEventListener& listener) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditAreaImpl->AddUiLinkEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::RemoveUiLinkEventListener(IUiLinkEventListener& listener) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditAreaImpl->RemoveUiLinkEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::AddKeypadEventListener(IKeypadEventListener& listener) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditAreaImpl->AddKeypadEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::RemoveKeypadEventListener(IKeypadEventListener& listener) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditAreaImpl->RemoveKeypadEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::AddTextBlockEventListener(ITextBlockEventListener& listener) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditAreaImpl->AddTextBlockEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::RemoveTextBlockEventListener(ITextBlockEventListener& listener) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditAreaImpl->RemoveTextBlockEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::AddTextEventListener(ITextEventListener& listener) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditAreaImpl->AddTextEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::RemoveTextEventListener(ITextEventListener& listener) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditAreaImpl->RemoveTextEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::AddScrollPanelEventListener(IScrollPanelEventListener& listener) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditAreaImpl->AddScrollPanelEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::RemoveScrollPanelEventListener(IScrollPanelEventListener& listener) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditAreaImpl->RemoveScrollPanelEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::AddActionEventListener(IActionEventListener& listener) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditAreaImpl->AddActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::RemoveActionEventListener(IActionEventListener& listener) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditAreaImpl->RemoveActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::AddLanguageEventListener(ILanguageEventListener& listener) +{ + result r = E_SUCCESS; + + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + r = pEditAreaImpl->AddLanguageEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditArea::RemoveLanguageEventListener(ILanguageEventListener& listener) +{ + result r = E_SUCCESS; + + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + r = pEditAreaImpl->RemoveLanguageEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +int +EditArea::GetRemainingLength(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetRemainingLength(); +} + +void +EditArea::SetLowerCaseModeEnabled(bool enable) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + pEditAreaImpl->SetLowerCaseModeEnabled(enable); +} + +bool +EditArea::IsLowerCaseModeEnabled(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->IsLowerCaseModeEnabled(); +} + +result +EditArea::SetInputModeCategory(unsigned long categories, bool enable) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetInputModeCategory(categories, enable); +} + +result +EditArea::SetCurrentInputModeCategory(EditInputModeCategory inputModeCategory) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetCurrentInputModeCategory(inputModeCategory); +} + +unsigned long +EditArea::GetInputModeCategory(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetInputModeCategory(); +} + +EditInputModeCategory +EditArea::GetCurrentInputModeCategory(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetCurrentInputModeCategory(); +} + +result +EditArea::SetCursorPosition(int position) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetCursorPosition(position); +} + +int +EditArea::GetCursorPosition(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetCursorPosition(); +} + +String +EditArea::GetText(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetText(); +} + +int +EditArea::GetTextLength(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetTextLength(); +} + +result +EditArea::SetText(const String& text) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetText(text); +} + +result +EditArea::InsertTextAtCursorPosition(const String& text) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->InsertTextAtCursorPosition(text); +} + +result +EditArea::AppendText(const String& text) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->AppendText(text); +} + +result +EditArea::AppendCharacter(const Character& character) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->AppendCharacter(character); +} + +result +EditArea::InsertTextAt(int position, const String& text, const Bitmap& textImage) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->InsertTextAt(position, text, textImage); +} + +result +EditArea::AppendText(const String& text, const Bitmap& textImage) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->AppendText(text, textImage); +} + +result +EditArea::Clear(void) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->Clear(); +} + +result +EditArea::DeleteCharacterAtCursorPosition(void) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->DeleteCharacterAtCursorPosition(); +} + +void +EditArea::GetCurrentTextRange(int& start, int& end) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetCurrentTextRange(start, end); +} + +void +EditArea::SetGuideText(const String& guideText) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetGuideText(guideText); +} + +String +EditArea::GetGuideText(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetGuideText(); +} + +Color +EditArea::GetGuideTextColor(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetGuideTextColor(); +} + +result +EditArea::SetGuideTextColor(const Color& color) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetGuideTextColor(color); +} + +void +EditArea::SetKeypadEnabled(bool enable) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + pEditAreaImpl->SetKeypadEnabled(enable); +} + +bool +EditArea::IsKeypadEnabled(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->IsKeypadEnabled(); +} + +result +EditArea::ShowKeypad(void) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->ShowKeypad(); +} + +int +EditArea::GetTextLineCount(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetTextLineCount(); +} + +void +EditArea::GetBlockRange(int& start, int& end) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + pEditAreaImpl->GetBlockRange(start, end); +} + +result +EditArea::BeginBlock(void) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->BeginBlock(); +} + +result +EditArea::ReleaseBlock(void) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->ReleaseBlock(); +} + +bool +EditArea::IsBlocked(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->IsBlocked(); +} + +result +EditArea::Copy(void) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->Copy(); +} + +result +EditArea::Cut(void) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->Cut(); +} + +result +EditArea::Paste(void) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->Paste(); +} + +result +EditArea::Remove(void) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->Remove(); +} + +bool +EditArea::IsClipped(void) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->IsClipped(); +} + +result +EditArea::SetOverlayKeypadCommandButton(CommandButtonPosition position, const String& text, int actionId) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetOverlayKeypadCommandButton(position, text, actionId); +} + +String +EditArea::GetOverlayKeypadCommandButtonText(CommandButtonPosition position) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetOverlayKeypadCommandButtonText(position); +} + +int +EditArea::GetOverlayKeypadCommandButtonActionId(CommandButtonPosition position) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetOverlayKeypadCommandButtonActionId(position); +} + +result +EditArea::SetCurrentLanguage(LanguageCode languageCode) +{ + _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->SetCurrentLanguage(languageCode); +} + +result +EditArea::GetCurrentLanguage(LanguageCode& language) const +{ + const _EditAreaImpl* pEditAreaImpl = _EditAreaImpl::GetInstance(*this); + SysAssertf(pEditAreaImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditAreaImpl->GetCurrentLanguage(language); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlEditDate.cpp b/src/ui/controls/FUiCtrlEditDate.cpp new file mode 100644 index 0000000..d4a4722 --- /dev/null +++ b/src/ui/controls/FUiCtrlEditDate.cpp @@ -0,0 +1,200 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlEditDate.cpp +* @brief This file contains implementation of EditDate class +*/ + +#include +#include +#include "FUiCtrl_EditDateImpl.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +EditDate::EditDate(void) +{ +} + +EditDate::~EditDate(void) +{ +} + +result +EditDate::Construct(const Point& point, const String& title) +{ + _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl == null), + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pEditDateImpl = _EditDateImpl::CreateEditDateImplN(this, point, title); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pEditDateImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pEditDateImpl; + + return r; +} + +void +EditDate::AddDateChangeEventListener(IDateChangeEventListener& listener) +{ + _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pEditDateImpl->AddDateChangeEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + return; +} + +void +EditDate::RemoveDateChangeEventListener(IDateChangeEventListener& listener) +{ + _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pEditDateImpl->RemoveDateChangeEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + return; +} + +DateTime +EditDate::GetDate(void) const +{ + const _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditDateImpl->GetDate(); +} + +int +EditDate::GetDay(void) const +{ + const _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditDateImpl->GetDay(); +} + +int +EditDate::GetMonth(void) const +{ + const _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditDateImpl->GetMonth(); +} + +int +EditDate::GetYear(void) const +{ + const _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditDateImpl->GetYear(); +} + +void +EditDate::SetDate(const DateTime& date) +{ + _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + pEditDateImpl->SetDate(date); + return; +} + +void +EditDate::SetCurrentDate(void) +{ + _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + pEditDateImpl->SetCurrentDate(); + return; +} + +result +EditDate::SetYear(int year) +{ + _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditDateImpl->SetYear(year); +} + +result +EditDate::SetMonth(int month) +{ + _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditDateImpl->SetMonth(month); +} + +result +EditDate::SetDay(int day) +{ + _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditDateImpl->SetDay(day); +} + +void +EditDate::SetDatePickerEnabled(bool enable) +{ + _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + pEditDateImpl->SetDatePickerEnabled(enable); + return; +} + +bool +EditDate::IsDatePickerEnabled(void) const +{ + const _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditDateImpl->IsDatePickerEnabled(); +} + +result +EditDate::SetYearRange(int minYear, int maxYear) +{ + _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditDateImpl->SetYearRange(minYear, maxYear); +} + +result +EditDate::GetYearRange(int& minYear, int& maxYear) const +{ + const _EditDateImpl* pEditDateImpl = _EditDateImpl::GetInstance(*this); + SysAssertf((pEditDateImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditDateImpl->GetYearRange(minYear, maxYear); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlEditField.cpp b/src/ui/controls/FUiCtrlEditField.cpp new file mode 100644 index 0000000..fc23de0 --- /dev/null +++ b/src/ui/controls/FUiCtrlEditField.cpp @@ -0,0 +1,896 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlEditField.cpp + * @brief This file contains implementation of EditField class + */ + +#include +#include +#include "FUiCtrl_EditFieldImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::Security; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +EditField::EditField(void) +{ +} + +EditField::~EditField(void) +{ +} + +result +EditField::Construct(const Rectangle& rect, EditFieldStyle style, InputStyle inputStyle, bool showTitle, + int limitLength, + GroupStyle groupStyle) +{ + result r = E_SUCCESS; + + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + EditFieldTitleStyle titleStyle = EDIT_FIELD_TITLE_STYLE_NONE; + bool enableClear = false; + + if (showTitle == true) + { + titleStyle = EDIT_FIELD_TITLE_STYLE_TOP; + } + + pEditFieldImpl = _EditFieldImpl::CreateEditFieldImplN(this, rect, style, titleStyle); + if (pEditFieldImpl == null) + { + r = GetLastResult(); + return r; + } + + _pControlImpl = pEditFieldImpl; + + r = pEditFieldImpl->Initialize(style, inputStyle, titleStyle, enableClear, limitLength, groupStyle); + if (r != E_SUCCESS) + { + goto CATCH; + } + + SetBounds(rect.x, rect.y, rect.width, rect.height); + + return r; + +CATCH: + delete pEditFieldImpl; + _pControlImpl = null; + + return r; +} + +result +EditField::Construct(const Rectangle& rect, EditFieldStyle style, InputStyle inputStyle, + EditFieldTitleStyle titleStyle, bool enableClear, int limitLength, + GroupStyle groupStyle) +{ + result r = E_SUCCESS; + + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pEditFieldImpl = _EditFieldImpl::CreateEditFieldImplN(this, rect, style, titleStyle); + if (pEditFieldImpl == null) + { + r = GetLastResult(); + return r; + } + + _pControlImpl = pEditFieldImpl; + + r = pEditFieldImpl->Initialize(style, inputStyle, titleStyle, enableClear, limitLength, groupStyle); + if (r != E_SUCCESS) + { + goto CATCH; + } + + r = SetBounds(rect.x, rect.y, rect.width, rect.height); + if (r != E_SUCCESS) + { + goto CATCH; + } + + return r; + +CATCH: + delete pEditFieldImpl; + _pControlImpl = null; + + return r; +} + +HorizontalAlignment +EditField::GetTextAlignment(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetTextAlignment(); +} + +result +EditField::SetTextAlignment(HorizontalAlignment alignment) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetTextAlignment(alignment); +} + +bool +EditField::IsViewModeEnabled(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->IsViewModeEnabled(); +} + +result +EditField::SetViewModeEnabled(bool enable) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetViewModeEnabled(enable); +} + +result +EditField::SetAutoLinkMask(unsigned long autoLinks) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetAutoLinkMask(autoLinks); +} + +unsigned long +EditField::GetAutoLinkMask(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetAutoLinkMask(); +} + +int +EditField::GetMargin(EditMarginType marginType) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetMargin(marginType); +} + +result +EditField::SetMargin(EditMarginType marginType, int margin) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetMargin(marginType, margin); +} + +result +EditField::SetKeypadActionEnabled(bool enable) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetKeypadActionEnabled(enable); +} + +bool +EditField::IsKeypadActionEnabled(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->IsKeypadActionEnabled(); +} + +KeypadAction +EditField::GetKeypadAction(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetKeypadAction(); +} + +result +EditField::SetKeypadAction(KeypadAction keypadAction) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetKeypadAction(keypadAction); +} + +result +EditField::SetOverlayKeypadCommandButtonVisible(bool visible) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetOverlayKeypadCommandButtonVisible(visible); +} + +bool +EditField::IsOverlayCommandButtonVisible(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->IsOverlayCommandButtonVisible(); +} + +result +EditField::HideKeypad(void) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->HideKeypad(); +} + +EllipsisPosition +EditField::GetEllipsisPosition(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetEllipsisPosition(); +} + +result +EditField::SetEllipsisPosition(EllipsisPosition position) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetEllipsisPosition(position); +} + +int +EditField::GetTextSize(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetTextSize(); +} + +result +EditField::SetTextSize(int size) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetTextSize(size); +} + +Color +EditField::GetColor(EditStatus status) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetColor(status); +} + +Color +EditField::GetTextColor(EditTextColor type) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetTextColor(type); +} + +result +EditField::SetBackgroundBitmap(EditStatus status, const Bitmap& bitmap) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetBackgroundBitmap(status, bitmap); +} + +result +EditField::SetColor(EditStatus status, const Color& color) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetColor(status, color); +} + +result +EditField::SetTextColor(EditTextColor type, const Color& color) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetTextColor(type, color); +} + +String +EditField::GetText(int start, int end) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetText(start, end); +} + +void +EditField::AddUiLinkEventListener(IUiLinkEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditFieldImpl->AddUiLinkEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditField::RemoveUiLinkEventListener(IUiLinkEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditFieldImpl->RemoveUiLinkEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditField::AddKeypadEventListener(IKeypadEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditFieldImpl->AddKeypadEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditField::RemoveKeypadEventListener(IKeypadEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditFieldImpl->RemoveKeypadEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditField::AddTextBlockEventListener(ITextBlockEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditFieldImpl->AddTextBlockEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditField::RemoveTextBlockEventListener(ITextBlockEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditFieldImpl->RemoveTextBlockEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditField::AddTextEventListener(ITextEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + pEditFieldImpl->AddTextEventListener(listener); +} + +void +EditField::RemoveTextEventListener(ITextEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + pEditFieldImpl->RemoveTextEventListener(listener); +} + +void +EditField::AddScrollPanelEventListener(IScrollPanelEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditFieldImpl->AddScrollPanelEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditField::RemoveScrollPanelEventListener(IScrollPanelEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditFieldImpl->RemoveScrollPanelEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditField::AddActionEventListener(IActionEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditFieldImpl->AddActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditField::RemoveActionEventListener(IActionEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pEditFieldImpl->RemoveActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditField::AddLanguageEventListener(ILanguageEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + pEditFieldImpl->AddLanguageEventListener(listener); +} + +void +EditField::RemoveLanguageEventListener(ILanguageEventListener& listener) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + pEditFieldImpl->RemoveLanguageEventListener(listener); +} + +int +EditField::GetRemainingLength(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetRemainingLength(); +} + +void +EditField::SetLowerCaseModeEnabled(bool enable) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + pEditFieldImpl->SetLowerCaseModeEnabled(enable); +} + +bool +EditField::IsLowerCaseModeEnabled(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->IsLowerCaseModeEnabled(); +} + +result +EditField::SetInputModeCategory(unsigned long categories, bool enable) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetInputModeCategory(categories, enable); +} + +result +EditField::SetCurrentInputModeCategory(EditInputModeCategory inputModeCategory) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetCurrentInputModeCategory(inputModeCategory); +} + +unsigned long +EditField::GetInputModeCategory(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetInputModeCategory(); +} + +EditInputModeCategory +EditField::GetCurrentInputModeCategory(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetCurrentInputModeCategory(); +} + +result +EditField::SetCursorPosition(int position) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetCursorPosition(position); +} + +int +EditField::GetCursorPosition(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetCursorPosition(); +} + +String +EditField::GetText(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetText(); +} + +int +EditField::GetTextLength(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetTextLength(); +} + +result +EditField::SetText(const String& text) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetText(text); +} + +result +EditField::InsertTextAtCursorPosition(const String& text) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->InsertTextAtCursorPosition(text); +} + +result +EditField::AppendText(const String& text) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->AppendText(text); +} + +result +EditField::AppendCharacter(const Character& character) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->AppendCharacter(character); +} + +result +EditField::Clear(void) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->Clear(); +} + +result +EditField::DeleteCharacterAtCursorPosition(void) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->DeleteCharacterAtCursorPosition(); +} + +void +EditField::GetCurrentTextRange(int& start, int& end) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetCurrentTextRange(start, end); +} + +void +EditField::SetGuideText(const String& guideText) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetGuideText(guideText); +} + +String +EditField::GetGuideText(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetGuideText(); +} + +Color +EditField::GetGuideTextColor(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetGuideTextColor(); +} + +result +EditField::SetGuideTextColor(const Color& color) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetGuideTextColor(color); +} + +void +EditField::SetKeypadEnabled(bool enable) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + pEditFieldImpl->SetKeypadEnabled(enable); +} + +bool +EditField::IsKeypadEnabled(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->IsKeypadEnabled(); +} + +bool +EditField::IsTextPredictionEnabled(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->IsTextPredictionEnabled(); +} + +result +EditField::SetTextPredictionEnabled(bool enable) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetTextPredictionEnabled(enable); +} + +result +EditField::ShowKeypad(void) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->ShowKeypad(); +} + +void +EditField::GetBlockRange(int& start, int& end) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + pEditFieldImpl->GetBlockRange(start, end); +} + +result +EditField::BeginBlock(void) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->BeginBlock(); +} + +result +EditField::ReleaseBlock(void) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->ReleaseBlock(); +} + +bool +EditField::IsBlocked(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->IsBlocked(); +} + +result +EditField::Copy(void) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->Copy(); +} + +result +EditField::Cut(void) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->Cut(); +} + +result +EditField::Paste(void) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->Paste(); +} + +result +EditField::Remove(void) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->Remove(); +} + +bool +EditField::IsClipped(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->IsClipped(); +} + +result +EditField::SetTitleText(const String& title) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetTitleText(title); +} + +String +EditField::GetTitleText(void) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetTitleText(); +} + +result +EditField::SetTitleTextColor(EditStatus status, const Color& color) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetTitleTextColor(status, color); +} + +Color +EditField::GetTitleTextColor(EditStatus status) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetTitleTextColor(status); +} + +result +EditField::SetOverlayKeypadCommandButton(CommandButtonPosition position, const String& text, int actionId) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetOverlayKeypadCommandButton(position, text, actionId); +} + +String +EditField::GetOverlayKeypadCommandButtonText(CommandButtonPosition position) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetOverlayKeypadCommandButtonText(position); +} + +int +EditField::GetOverlayKeypadCommandButtonActionId(CommandButtonPosition position) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetOverlayKeypadCommandButtonActionId(position); +} + +result +EditField::SetCurrentLanguage(LanguageCode languageCode) +{ + _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->SetCurrentLanguage(languageCode); +} + +result +EditField::GetCurrentLanguage(LanguageCode& language) const +{ + const _EditFieldImpl* pEditFieldImpl = _EditFieldImpl::GetInstance(*this); + SysAssertf(pEditFieldImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pEditFieldImpl->GetCurrentLanguage(language); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlEditTime.cpp b/src/ui/controls/FUiCtrlEditTime.cpp new file mode 100644 index 0000000..7edfe95 --- /dev/null +++ b/src/ui/controls/FUiCtrlEditTime.cpp @@ -0,0 +1,172 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlEditTime.cpp +* @brief This file contains implementation of EditTime class +*/ + +#include +#include +#include "FUiCtrl_EditTimeImpl.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +EditTime::EditTime(void) +{ +} + +EditTime::~EditTime(void) +{ +} + +result +EditTime::Construct(const Point& point, const String& title) +{ + _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl == null), + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pEditTimeImpl = _EditTimeImpl::CreateEditTimeImplN(this, point, title); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pEditTimeImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pEditTimeImpl; + + return r; +} + +void +EditTime::AddTimeChangeEventListener(ITimeChangeEventListener& listener) +{ + _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pEditTimeImpl->AddTimeChangeEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +EditTime::RemoveTimeChangeEventListener(ITimeChangeEventListener& listener) +{ + _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pEditTimeImpl->RemoveTimeChangeEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + return; +} + +DateTime +EditTime::GetTime(void) const +{ + const _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditTimeImpl->GetTime(); +} + +int +EditTime::GetHour(void) const +{ + const _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditTimeImpl->GetHour(); +} + +int +EditTime::GetMinute(void) const +{ + const _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditTimeImpl->GetMinute(); +} + +void +EditTime::SetTime(const DateTime& time) +{ + _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl != null), "Not yet constructed. Construct() should be called before use."); + + pEditTimeImpl->SetTime(time); + return; +} + +void +EditTime::SetCurrentTime(void) +{ + _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl != null), "Not yet constructed. Construct() should be called before use."); + + pEditTimeImpl->SetCurrentTime(); + return; +} + +result +EditTime::SetHour(int hour) +{ + _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditTimeImpl->SetHour(hour); +} + +result +EditTime::SetMinute(int minute) +{ + _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditTimeImpl->SetMinute(minute); +} + +void +EditTime::SetTimePickerEnabled(bool enable) +{ + _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl != null), "Not yet constructed. Construct() should be called before use."); + + pEditTimeImpl->SetTimePickerEnabled(enable); + return; +} + +bool +EditTime::IsTimePickerEnabled(void) const +{ + const _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditTimeImpl->IsTimePickerEnabled(); +} + +void +EditTime::Set24HourNotationEnabled(bool enable) +{ + _EditTimeImpl* pEditTimeImpl = _EditTimeImpl::GetInstance(*this); + SysAssertf((pEditTimeImpl != null), "Not yet constructed. Construct() should be called before use."); + + return pEditTimeImpl->Set24HourNotationEnabled(enable); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlExpandableEditArea.cpp b/src/ui/controls/FUiCtrlExpandableEditArea.cpp new file mode 100644 index 0000000..4173441 --- /dev/null +++ b/src/ui/controls/FUiCtrlExpandableEditArea.cpp @@ -0,0 +1,877 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlExpandableEditArea.cpp + * @brief This file contains implementation of ExpandableEditArea class + */ + +#include +#include +#include "FUiCtrl_ExpandableEditAreaImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +static const int MINIMUM_SIZE_VALUE = 0; +static const int MAXIMUM_SIZE_VALUE = 65535; +static const int MAX_EXPANDABLE_LINES = 100; + +namespace Tizen { namespace Ui { namespace Controls +{ + +ExpandableEditArea::ExpandableEditArea(void) +{ + // Nothing. +} + +ExpandableEditArea::~ExpandableEditArea(void) +{ + // Nothing. +} + +result +ExpandableEditArea::Construct(const Rectangle& rect, ExpandableEditAreaStyle style, + ExpandableEditAreaTitleStyle titleStyle, + int maxExpandableLines) +{ + result r = E_SUCCESS; + + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + SysTryReturnResult(NID_UI_CTRL, (maxExpandableLines > 0), E_INVALID_ARG, "Invalid argument is used. maxExpandableLines is less than zero"); + SysTryReturnResult(NID_UI_CTRL, (maxExpandableLines <= MAX_EXPANDABLE_LINES), E_MAX_EXCEEDED, "maxExpandableLines exceeds the maximum limit."); + + SysTryReturnResult(NID_UI_CTRL, !(style == EXPANDABLE_EDIT_AREA_STYLE_TOKEN && titleStyle == EXPANDABLE_EDIT_AREA_TITLE_STYLE_TOP), + E_UNSUPPORTED_OPTION, "The input option EXPANDABLE_EDIT_AREA_TITLE_STYLE_TOP is unsupported. The token style EXPANDABLE_EDIT_AREA_STYLE_TOKEN does not support the title style EXPANDABLE_EDIT_AREA_TITLE_STYLE_TOP"); + + SysTryReturnResult(NID_UI_CTRL, + (rect.width >= MINIMUM_SIZE_VALUE && rect.width <= MAXIMUM_SIZE_VALUE && rect.height >= MINIMUM_SIZE_VALUE && rect.height <= MAXIMUM_SIZE_VALUE), E_INVALID_ARG, + "Invalid argument is used. The specified size(%d, %d) is outside range of min size(%d, %d) and max size(%d, %d) of ExpandableEditArea." + , rect.width, rect.height, MINIMUM_SIZE_VALUE, MINIMUM_SIZE_VALUE, MAXIMUM_SIZE_VALUE, MAXIMUM_SIZE_VALUE); + + pImpl = _ExpandableEditAreaImpl::CreateExpandableEditAreaImplN(this, rect, style, titleStyle); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pImpl != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + r = SetBounds(rect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->Construct(rect, style, titleStyle, maxExpandableLines); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + Control::Dispose(); + return r; +} + +result +ExpandableEditArea::AppendCharacter(const Character& character) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AppendCharacter(character); +} + +result +ExpandableEditArea::AppendText(const String& text) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AppendText(text); +} + +result +ExpandableEditArea::AppendText(const String& text, const Bitmap& textImage) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AppendText(text, textImage); +} + +result +ExpandableEditArea::DeleteCharacterAt(int index) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->DeleteCharacterAt(index); +} + +result +ExpandableEditArea::InsertCharacterAt(int index, const Character& character) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->InsertCharacterAt(index, character); +} + +result +ExpandableEditArea::InsertTextAt(int index, const String& text) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->InsertTextAt(index, text); +} + +result +ExpandableEditArea::InsertTextAt(int position, const String& text, const Bitmap& textImage) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->InsertTextAt(position, text, textImage); +} + +String +ExpandableEditArea::GetText(int start, int end) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetText(start, end); +} + +String +ExpandableEditArea::GetText(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetText(); +} + +int +ExpandableEditArea::GetTextLength(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextLength(); +} + +result +ExpandableEditArea::SetText(const String& text) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetText(text); +} + +result +ExpandableEditArea::Clear(void) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->Clear(); +} + +result +ExpandableEditArea::SetTitleText(const String& title) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTitleText(title); +} + +String +ExpandableEditArea::GetTitleText(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTitleText(); +} + +String +ExpandableEditArea::GetGuideText(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetGuideText(); +} + +result +ExpandableEditArea::SetGuideText(const String& guideText) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetGuideText(guideText); +} + +int +ExpandableEditArea::GetLineSpacing (void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLineSpacing(); +} + +result +ExpandableEditArea::SetLineSpacing (int multiplier, int extra) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetLineSpacing(multiplier, extra); +} + +int +ExpandableEditArea::GetMaxLineCount(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetMaxLineCount(); +} + +int +ExpandableEditArea::GetTextLineCount(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextLineCount(); +} + +int +ExpandableEditArea::GetTextSize(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextSize(); +} + +result +ExpandableEditArea::SetTextSize(int size) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTextSize(size); +} + +int +ExpandableEditArea::GetMargin(EditMarginType marginType) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetMargin(marginType); +} + +result +ExpandableEditArea::SetMargin(EditMarginType marginType, int margin) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetMargin(marginType, margin); +} + +result +ExpandableEditArea::SetLowerCaseModeEnabled(bool enable) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetLowerCaseModeEnabled(enable); +} + +bool +ExpandableEditArea::IsLowerCaseModeEnabled(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsLowerCaseModeEnabled(); +} + +int +ExpandableEditArea::GetCursorPosition(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetCursorPosition(); +} + +result +ExpandableEditArea::SetCursorPosition(int position) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetCursorPosition(position); +} + +result +ExpandableEditArea::GetBlockRange(int& start, int& end) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBlockRange(start, end); +} + +result +ExpandableEditArea::ReleaseBlock(void) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ReleaseBlock(); +} + +result +ExpandableEditArea::RemoveTextBlock(void) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveTextBlock(); +} + +result +ExpandableEditArea::SetBlockRange(int start, int end) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetBlockRange(start, end); +} + +KeypadAction +ExpandableEditArea::GetKeypadAction(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetKeypadAction(); +} + +KeypadStyle +ExpandableEditArea::GetKeypadStyle(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetKeypadStyle(); +} + +result +ExpandableEditArea::HideKeypad(void) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->HideKeypad(); +} + +bool +ExpandableEditArea::IsKeypadEnabled(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsKeypadEnabled(); +} + +result +ExpandableEditArea::SetKeypadAction(KeypadAction keypadAction) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetKeypadAction(keypadAction); +} + +result +ExpandableEditArea::SetKeypadStyle(KeypadStyle keypadStyle) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetKeypadStyle(keypadStyle); +} + +bool +ExpandableEditArea::IsTextPredictionEnabled(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsTextPredictionEnabled(); +} + +result +ExpandableEditArea::SetTextPredictionEnabled(bool enable) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTextPredictionEnabled(enable); +} + +result +ExpandableEditArea::SetKeypadEnabled(bool enable) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetKeypadEnabled(enable); + + return E_SUCCESS; +} + +result +ExpandableEditArea::ShowKeypad(void) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ShowKeypad(); +} + +result +ExpandableEditArea::SetTokenFilter(const ITokenFilter* pFilter) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTokenFilter(pFilter); +} + +ITokenFilter* +ExpandableEditArea::GetTokenFilter(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTokenFilter(); +} + +result +ExpandableEditArea::AppendToken(const String& token) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AppendToken(token); +} + +result +ExpandableEditArea::InsertTokenAt(int index, const String& token) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->InsertTokenAt(index, token); +} + +String +ExpandableEditArea::GetTokenAt(int index) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTokenAt(index); +} + +int +ExpandableEditArea::GetTokenCount(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTokenCount(); +} + +int +ExpandableEditArea::GetSelectedTokenIndex(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSelectedTokenIndex(); +} + +bool +ExpandableEditArea::IsTokenEditModeEnabled(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsTokenEditModeEnabled(); +} + +result +ExpandableEditArea::RemoveTokenAt(int index) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveTokenAt(index); +} + +result +ExpandableEditArea::SetTokenSelected(int index, bool selected) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTokenSelected(index, selected); +} + +result +ExpandableEditArea::SetTokenEditModeEnabled(bool enable) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTokenEditModeEnabled(enable); +} + +int +ExpandableEditArea::GetLimitLength(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLimitLength(); +} + +result +ExpandableEditArea::SetLimitLength(int limitLength) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetLimitLength(limitLength); +} + +Color +ExpandableEditArea::GetColor(EditStatus status) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetColor(status); +} + +Color +ExpandableEditArea::GetTextColor(EditTextColor type) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextColor(type); +} + +Color +ExpandableEditArea::GetGuideTextColor(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetGuideTextColor(); +} + +Color +ExpandableEditArea::GetTitleTextColor(EditStatus status) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTitleTextColor(status); +} + +Color +ExpandableEditArea::GetTokenColor(ExpandableEditAreaTokenStatus status) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTokenColor(status); +} + +Color +ExpandableEditArea::GetTokenTextColor(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTokenTextColor(); +} + +Color +ExpandableEditArea::GetSelectedTokenTextColor(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSelectedTokenTextColor(); +} + +result +ExpandableEditArea::SetBackgroundBitmap(EditStatus status, const Bitmap& bitmap) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetBackgroundBitmap(status, bitmap); +} + +result +ExpandableEditArea::SetColor(EditStatus status, const Color& color) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetColor(status, color); +} + +result +ExpandableEditArea::SetGuideTextColor(const Color& color) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetGuideTextColor(color); +} + +result +ExpandableEditArea::SetTitleTextColor(EditStatus status, const Color& color) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTitleTextColor(status, color); +} + +result +ExpandableEditArea::SetTextColor(EditTextColor type, const Color& color) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTextColor(type, color); +} + +result +ExpandableEditArea::SetSelectedTokenTextColor(const Color& color) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetSelectedTokenTextColor(color); +} + +result +ExpandableEditArea::SetTokenColor(ExpandableEditAreaTokenStatus status, const Color& color) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTokenColor(status, color); +} + +result +ExpandableEditArea::SetTokenTextColor(const Color& color) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTokenTextColor(color); +} + +result +ExpandableEditArea::SetAutoResizingEnabled(bool enable) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetAutoResizingEnabled(enable); +} + +bool +ExpandableEditArea::IsAutoResizingEnabled(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsAutoResizingEnabled(); +} + +result +ExpandableEditArea::SetCurrentLanguage(LanguageCode languageCode) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetCurrentLanguage(languageCode); +} + +result +ExpandableEditArea::GetCurrentLanguage(LanguageCode& language) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetCurrentLanguage(language); +} + +void +ExpandableEditArea::AddExpandableEditAreaEventListener(IExpandableEditAreaEventListener& listener) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddExpandableEditAreaEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ExpandableEditArea::AddKeypadEventListener(IKeypadEventListener& listener) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddKeypadEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ExpandableEditArea::AddTextBlockEventListener(ITextBlockEventListener& listener) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddTextBlockEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ExpandableEditArea::AddTextEventListener(ITextEventListener& listener) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddTextEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ExpandableEditArea::RemoveExpandableEditAreaEventListener(IExpandableEditAreaEventListener& listener) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveExpandableEditAreaEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ExpandableEditArea::RemoveKeypadEventListener(IKeypadEventListener& listener) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveKeypadEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ExpandableEditArea::RemoveTextBlockEventListener(ITextBlockEventListener& listener) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveTextBlockEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ExpandableEditArea::RemoveTextEventListener(ITextEventListener& listener) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveTextEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ExpandableEditArea::AddLanguageEventListener(ILanguageEventListener& listener) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddLanguageEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ExpandableEditArea::RemoveLanguageEventListener(ILanguageEventListener& listener) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveLanguageEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +ExpandableEditArea::SetAutoShrinkModeEnabled(bool enable) +{ + _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetAutoShrinkModeEnabled(enable); +} + +bool +ExpandableEditArea::IsAutoShrinkModeEnabled(void) const +{ + const _ExpandableEditAreaImpl* pImpl = _ExpandableEditAreaImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsAutoShrinkModeEnabled(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlExpandableList.cpp b/src/ui/controls/FUiCtrlExpandableList.cpp new file mode 100644 index 0000000..7e0de9d --- /dev/null +++ b/src/ui/controls/FUiCtrlExpandableList.cpp @@ -0,0 +1,651 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlExpandableList.cpp +* @brief This is the implementation file for FUiCtrlExpandableList class. +* +*/ + +#include +#include +#include "FUiCtrl_CustomListImpl.h" +#include "FUiCtrl_ExpandableListImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Ui { namespace Controls +{ + +ExpandableList::ExpandableList(void) +{ +} + +ExpandableList::~ExpandableList(void) +{ +} + +result +ExpandableList::Construct(const Rectangle& rect, CustomListStyle style, bool itemDivider) +{ + result r = E_SUCCESS; + + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class"); + + pImpl = _ExpandableListImpl::CreateExpandableListImplN(this, rect, itemDivider); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + r = pImpl->UpdateBounds(rect); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->SetListStyle(style); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[E_SYSTEM] A system error occurred."); + + r = pImpl->Initialize(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pImpl->LoadDefaultBitmap(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[E_SYSTEM] A system error occurred."); + + ClearLastResult(); + + return E_SUCCESS; + +CATCH: + Dispose(); + return E_SYSTEM; +} + +void +ExpandableList::AddExpandableItemEventListener(IExpandableItemEventListener& listener) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddExpandableItemEventListener(listener); + + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SetLastResult(E_SUCCESS); + + return; +} + +void +ExpandableList::RemoveExpandableItemEventListener(IExpandableItemEventListener& listener) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveExpandableItemEventListener(listener); + + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SetLastResult(E_SUCCESS); + + return; +} + +result +ExpandableList::AddItem(const CustomListItem& item, int itemId) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddItem(item, itemId); +} + +result +ExpandableList::InsertItemAt(int index, const CustomListItem& item, int itemId) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->InsertItemAt(index, item, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +ExpandableList::SetItemAt(int index, const CustomListItem& item, int itemId) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + result r = pImpl->SetItemAt(index, item, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +ExpandableList::RemoveItemAt(int mainIndex) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveItemAt(mainIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +ExpandableList::RemoveAllItems(void) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveAllItems(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +const CustomListItem* +ExpandableList::GetItemAt(int index) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + const CustomListItem* pItem = pImpl->GetCustomListItemAt(index, -1); + return pItem; +} + +result +ExpandableList::AddSubItem(int mainIndex, const CustomListItem& item, int itemId) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddSubItem(mainIndex, item, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +ExpandableList::InsertSubItemAt(int mainIndex, int subIndex, const CustomListItem& item, int itemId) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->InsertSubItemAt(mainIndex, subIndex, item, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +ExpandableList::SetSubItemAt(int mainIndex, int subIndex, const CustomListItem& item, int itemId) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetSubItemAt(mainIndex, subIndex, item, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +ExpandableList::RemoveSubItemAt(int mainIndex, int subIndex) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveSubItemAt(mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +ExpandableList::RemoveAllSubItemsAt(int mainIndex) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveAllSubItemsAt(mainIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +int +ExpandableList::GetItemCount(void) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetItemCount(); +} + +int +ExpandableList::GetSubItemCount(int mainIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetSubItemCount(mainIndex); +} + +const CustomListItem* +ExpandableList::GetSubItemAt(int mainIndex, int subIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && subIndex >= 0), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d subIndex = %d", mainIndex, subIndex); + + const CustomListItem* pItem = pImpl->GetCustomListItemAt(mainIndex, subIndex); + return pItem; +} + +int +ExpandableList::GetFirstCheckedItemIndex(void) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetFirstCheckedItemIndex(); +} + +int +ExpandableList::GetItemIdAt(int mainIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetItemIdAt(mainIndex); +} + +int +ExpandableList::GetItemIndexFromItemId(int itemId) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetItemIndexFromItemId(itemId); +} + +int +ExpandableList::GetSubItemIdAt(int mainIndex, int subIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetSubItemIdAt(mainIndex, subIndex); +} + +result +ExpandableList::SetItemExpanded(int mainIndex, bool expand) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemExpanded(mainIndex, expand); +} + +bool +ExpandableList::IsItemExpanded(int mainIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->IsItemExpanded(mainIndex); +} + +result +ExpandableList::SetItemEnabled(int mainIndex, bool enable) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetItemEnabled(mainIndex, enable); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +bool +ExpandableList::IsItemEnabled(int index) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->IsItemEnabled(index); +} + +result +ExpandableList::SetSubItemEnabled(int mainIndex, int subIndex, bool enable) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetSubItemEnabled(mainIndex, subIndex, enable); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +bool +ExpandableList::IsSubItemEnabled(int mainIndex, int subIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->IsSubItemEnabled(mainIndex, subIndex); +} + +result +ExpandableList::SetItemChecked(int mainIndex, bool check) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetItemChecked(mainIndex, check); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +bool +ExpandableList::IsItemChecked(int mainIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemChecked(mainIndex); +} + +result +ExpandableList::SetSubItemChecked(int mainIndex, int subIndex, bool check) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetSubItemChecked(mainIndex, subIndex, check); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +bool +ExpandableList::IsSubItemChecked(int mainIndex, int subIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->IsSubItemChecked(mainIndex, subIndex); +} + +result +ExpandableList::SetAllSubItemsChecked(int mainIndex, bool check) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetAllSubItemsChecked(mainIndex, check); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +ExpandableList::RemoveAllCheckedSubItemsAt(int mainIndex) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveAllCheckedSubItemsAt(mainIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +int +ExpandableList::GetFirstCheckedSubItemIndex(int mainIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetFirstCheckedSubItemIndex(mainIndex); +} + +int +ExpandableList::GetLastCheckedItemIndex(void) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetLastCheckedItemIndex(); +} + +int +ExpandableList::GetLastCheckedSubItemIndex(int mainIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetLastCheckedSubItemIndex(mainIndex); +} + +int +ExpandableList::GetNextCheckedItemIndexAfter(int index) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetNextCheckedItemIndexAfter(index); +} + +int +ExpandableList::GetNextCheckedSubItemIndexAfter(int mainIndex, int subIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetNextCheckedSubItemIndexAfter(mainIndex, subIndex); +} + +result +ExpandableList::GetSubItemIndexFromItemId(int itemId, int& mainIndex, int& subIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSubItemIndexFromItemId(itemId, mainIndex, subIndex); +} + +result +ExpandableList::GetItemIndexFromPosition(int x, int y, int& mainIndex, int& subIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(Point(x, y), mainIndex, subIndex); +} + +result +ExpandableList::GetItemIndexFromPosition(const Point& position, int& mainIndex, int& subIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(position, mainIndex, subIndex); +} + +result +ExpandableList::GetTopDrawnItemIndex(int& mainIndex, int& subIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTopDrawnItemIndex(mainIndex, subIndex); +} + +result +ExpandableList::GetBottomDrawnItemIndex(int& mainIndex, int& subIndex) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBottomDrawnItemIndex(mainIndex, subIndex); +} + +void +ExpandableList::SetBackgroundColor(const Color& color) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + pImpl->SetBgColor(color); + return; +} + +void +ExpandableList::SetTextOfEmptyList(const String& text) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + pImpl->SetTextOfEmptyList(text); + return; +} + +void +ExpandableList::SetTextColorOfEmptyList(const Color& color) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextColorOfEmptyList(color); + SetLastResult(E_SUCCESS); + + return; +} + +Color +ExpandableList::GetTextColorOfEmptyList(void) const +{ + const _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetTextColorOfEmptyList(); +} + +void +ExpandableList::ScrollToBottom(void) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollToBottom(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + SetLastResult(E_SUCCESS); + + return; +} + +void +ExpandableList::ScrollToTop(void) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + result r = pImpl->ScrollToTop(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +result +ExpandableList::ScrollToTop(int mainIndex, int subIndex) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollToTop(mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +ExpandableList::ScrollToTop(int mainIndex) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollToTop(mainIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +ExpandableList::RefreshSubItem(int mainIndex, int subIndex) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RefreshSubItem(mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +ExpandableList::RefreshItem(int mainIndex) +{ + _ExpandableListImpl* pImpl = _ExpandableListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RefreshItem(mainIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlFooter.cpp b/src/ui/controls/FUiCtrlFooter.cpp new file mode 100644 index 0000000..4761543 --- /dev/null +++ b/src/ui/controls/FUiCtrlFooter.cpp @@ -0,0 +1,539 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrlFooter.cpp +* @brief This is the implementation file for Footer class. +*/ + +#include +#include +#include "FUiCtrl_FooterImpl.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +result +Footer::AddItem(const FooterItem& item) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->AddItem(item); +} + +result +Footer::InsertItemAt(int itemIndex, const FooterItem& item) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->InsertItemAt(itemIndex, item); +} + +bool +Footer::IsButtonSet(ButtonPosition position) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->IsButtonSet(position); +} + +bool +Footer::IsBackButtonSet(void) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->IsBackButtonSet(); +} + +bool +Footer::IsTabEditModeEnabled(void) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->IsTabEditModeEnabled(); +} + +Color +Footer::GetButtonColor(ButtonItemStatus status) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->GetButtonColor(status); +} + +Color +Footer::GetButtonTextColor(ButtonItemStatus status) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->GetButtonTextColor(status); +} + +ButtonItemStatus +Footer::GetButtonStatus(ButtonPosition position) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->GetButtonStatus(position); +} + +ButtonItemStatus +Footer::GetBackButtonStatus(void) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->GetBackButtonStatus(); +} + +Color +Footer::GetItemColor(FooterItemStatus status) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->GetItemColor(status); +} + +int +Footer::GetItemCount(void) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->GetItemCount(); +} + +result +Footer::GetItemStatus(int itemIndex, FooterItemStatus& status) const +{ + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->GetItemStatus(itemIndex, status); +} + +Color +Footer::GetItemTextColor(FooterItemStatus status) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->GetItemTextColor(status); +} + +FooterStyle +Footer::GetStyle(void) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->GetStyle(); +} + +int +Footer::GetSelectedItemIndex(void) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->GetSelectedItemIndex(); +} + +Color +Footer::GetColor(void) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->GetColor(); +} + +result +Footer::RemoveAllButtons(void) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->RemoveAllButtons(); +} + +result +Footer::RemoveButtonAt(ButtonPosition position) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->RemoveButtonAt(position); +} + +result +Footer::RemoveBackButton(void) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->RemoveBackButton(); +} + +result +Footer::RemoveAllItems(void) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->RemoveAllItems(); +} + +result +Footer::RemoveItemAt(int itemIndex) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->RemoveItemAt(itemIndex); +} + +result +Footer::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetBackgroundBitmap(pBitmap); +} + +result +Footer::SetButton(ButtonPosition position, const ButtonItem& button) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetButton(position, button); +} + +result +Footer::SetButtonColor(ButtonItemStatus status, const Color& color) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetButtonColor(status, color); +} + +result +Footer::SetButtonTextColor(ButtonItemStatus status, const Color& color) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetButtonTextColor(status, color); +} + +result +Footer::SetButtonEnabled(ButtonPosition position, bool enable) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetButtonEnabled(position, enable); +} + +result +Footer::SetBackButtonEnabled(bool enable) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetBackButtonEnabled(enable); +} + +result +Footer::SetBackButton(void) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetBackButton(); +} + +result +Footer::SetItemAt(int itemIndex, const FooterItem& item) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetItemAt(itemIndex, item); +} + +result +Footer::SetItemColor(FooterItemStatus status, const Color& color) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetItemColor(status, color); +} + +result +Footer::SetItemEnabled(int itemIndex, bool enabled) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetItemEnabled(itemIndex, enabled); +} + +result +Footer::SetItemBadgeIcon(int itemIndex, const Bitmap* pBadgeIcon) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetItemBadgeIcon(itemIndex, pBadgeIcon); +} + +result +Footer::SetItemTextColor(FooterItemStatus status, const Color& color) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetItemTextColor(status, color); +} + +result +Footer::SetItemSelected(int itemIndex) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetItemSelected(itemIndex); +} + +result +Footer::SetItemNumberedBadgeIcon(int itemIndex, int number) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetItemNumberedBadgeIcon(itemIndex, number); +} + +result +Footer::SetColor(const Color& color) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetColor(color); +} + +result +Footer::SetStyle(FooterStyle style) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetStyle(style); +} + +result +Footer::SetTabEditModeEnabled(bool enable) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->SetTabEditModeEnabled(enable); +} + +void +Footer::AddActionEventListener(IActionEventListener& listener) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pFooterImpl->AddActionEventListener(listener); + + return; +} + +void +Footer::RemoveActionEventListener(IActionEventListener& listener) +{ + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pFooterImpl->RemoveActionEventListener(listener); + + return; +} + +Footer::Footer(void) +{ +} + +Footer::~Footer(void) +{ +} + +result +Footer::Construct(void) +{ + SysAssertf(_pControlImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + result r = E_SUCCESS; + + _FooterImpl* pImpl = _FooterImpl::CreateFooterImplN(this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return r; +} + +Rectangle +Footer::GetButtonBounds(ButtonPosition position) const +{ + ClearLastResult(); + + const _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*this); + + SysAssertf(pFooterImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pFooterImpl->GetButtonBounds(position); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlFooterItem.cpp b/src/ui/controls/FUiCtrlFooterItem.cpp new file mode 100644 index 0000000..067139a --- /dev/null +++ b/src/ui/controls/FUiCtrlFooterItem.cpp @@ -0,0 +1,132 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrlFooterItem.cpp +* @brief This is the implementation file for FooterItem class. +*/ + +#include +#include +#include +#include "FUiCtrl_FooterItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +FooterItem::FooterItem(void) + : __pImpl(null) +{ +} + +FooterItem::~FooterItem(void) +{ + if (__pImpl) + { + delete __pImpl; + __pImpl = null; + } +} + +result +FooterItem::Construct(int actionId) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (actionId >= FOOTER_ITEM_ACTION_ID_MIN && actionId <= FOOTER_ITEM_ACTION_ID_MAX), E_INVALID_ARG, + "[E_INVALID_ARG] The actionId is invalid."); + + _FooterItemImpl* pImpl = _FooterItemImpl::GetInstance(*this); + + SysAssertf(pImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + __pImpl = new (std::nothrow) _FooterItemImpl(this); + SysTryReturnResult(NID_UI_CTRL, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Impl instance is not constructed"); + + r = __pImpl->Construct(actionId); + + if (IsFailed(r)) + { + delete __pImpl; + __pImpl = null; + SysLog(NID_UI_CTRL, "[%s] Propagated.", GetErrorMessage(r)); + return r; + } + + return r; +} + +int +FooterItem::GetActionId(void) const +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->GetActionId(); +} + +String +FooterItem::GetText(void) const +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->GetText(); +} + +result +FooterItem::SetActionId(int actionId) +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetActionId(actionId); +} + +result +FooterItem::SetBackgroundBitmap(FooterItemStatus status, const Bitmap* pBitmap) +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetBackgroundBitmap(status, pBitmap); +} + +result +FooterItem::SetIcon(FooterItemStatus status, const Bitmap* pIcon) +{ + SysTryReturnResult(NID_UI_CTRL, pIcon, E_INVALID_ARG, "[E_INVALID_ARG] pIcon is invalid."); + + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetIcon(status, pIcon); +} + +result +FooterItem::SetText(const String& text) +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetText(text); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlForm.cpp b/src/ui/controls/FUiCtrlForm.cpp new file mode 100644 index 0000000..7fe93a4 --- /dev/null +++ b/src/ui/controls/FUiCtrlForm.cpp @@ -0,0 +1,640 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlForm.cpp + * @brief This is the implementation file for Form class. + */ + +// Includes +#include +#include +#include +#include "FUi_UiBuilder.h" +#include "FUiCtrl_FormImpl.h" +#include "FUiCtrl_HeaderImpl.h" +#include "FUiCtrl_FooterImpl.h" +#include "FUiCtrl_TabImpl.h" + +using namespace std; +using namespace Tizen::Ui; +using namespace Tizen::Graphics; +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Form::Form(void) +{ +} + +Form::~Form(void) +{ +} + +result +Form::Construct(unsigned long formStyle) +{ + result r = E_SUCCESS; + + SysAssertf(_FormImpl::GetInstance(*this) == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _FormImpl* pImpl = _FormImpl::CreateFormImplN(this); + SysTryReturn(NID_UI_CTRL, pImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _pControlImpl = pImpl; + + pImpl->SetFormStyle(formStyle); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +Form::Construct(const Tizen::Base::String& resourceId) +{ + ClearLastResult(); + + // Parse UiBuilder XML file + unique_ptr<_UiBuilder> pBuilder(new _UiBuilder()); + SysTryReturn(NID_UI_CTRL, pBuilder, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + result r = pBuilder->Construct(resourceId, this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = pBuilder->Parse(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +Form::Construct(const Layout& layout, unsigned long formStyle) +{ + result r = E_SUCCESS; + + SysAssertf(_FormImpl::GetInstance(*this) == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + r = Construct(layout, layout, formStyle); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +Form::Construct(const Layout& portraitLayout, const Layout& landscapeLayout, unsigned long formStyle) +{ + result r = E_SUCCESS; + + SysAssertf(_FormImpl::GetInstance(*this) == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + Layout* pPortraitLayout = const_cast (&portraitLayout); + Layout* pLandscapeLayout = const_cast (&landscapeLayout); + + _FormImpl* pImpl = _FormImpl::CreateFormImplN(this, pPortraitLayout, pLandscapeLayout); + SysTryReturn(NID_UI_CTRL, pImpl, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _pControlImpl = pImpl; + + pImpl->SetFormStyle(formStyle); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +Form::AddOrientationEventListener(IOrientationEventListener& listener) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->AddOrientationEventListener(listener); +} + +void +Form::AddOptionkeyActionListener(IActionEventListener& listener) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->AddOptionkeyActionListener(listener); +} + +void +Form::AddSoftkeyActionListener(Softkey softkey, IActionEventListener& listener) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->AddSoftkeyActionListener(softkey, listener); +} + +void +Form::RemoveOptionkeyActionListener(IActionEventListener& listener) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveOptionkeyActionListener(listener); +} + +void +Form::RemoveOrientationEventListener(IOrientationEventListener& listener) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveOrientationEventListener(listener); +} + +void +Form::RemoveSoftkeyActionListener(Softkey softkey, IActionEventListener& listener) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveSoftkeyActionListener(softkey, listener); +} + +Color +Form::GetBackgroundColor(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBackgroundColor(); +} + +Rectangle +Form::GetClientAreaBounds(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetClientBounds(); +} + +unsigned long +Form::GetFormStyle(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetFormStyle(); +} + +Orientation +Form::GetOrientation(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetOrientation(); +} + +OrientationStatus +Form::GetOrientationStatus(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetOrientationStatus(); +} + +int +Form::GetSoftkeyActionId(Softkey softkey) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSoftkeyActionId(softkey); +} + +String +Form::GetSoftkeyText(Softkey softkey) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSoftkeyText(softkey); +} + +Tab* +Form::GetTab(void) const +{ + _FormImpl* pImpl = const_cast <_FormImpl*>(_FormImpl::GetInstance(*this)); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + _TabImpl* pTabImpl = pImpl->GetTabImpl(); + if (!pTabImpl) + { + return null; + } + + return pTabImpl->GetTab(); +} + + +String +Form::GetTitleText(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTitleText(); +} + +HorizontalAlignment +Form::GetTitleTextHorizontalAlignment(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTitleTextHorizontalAlignment(); +} + +bool +Form::HasIndicator(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->HasIndicator(); +} + +bool +Form::HasOptionkey(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->HasOptionkey(); +} + +bool +Form::HasSoftkey(Softkey softkey) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->HasSoftkey(softkey); +} + +bool +Form::HasTab(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->HasTab(); +} + +bool +Form::HasTitle(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->HasTitle(); +} + +bool +Form::IsSoftkeyEnabled(Softkey softkey) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsSoftkeyEnabled(softkey); +} + +void +Form::SetBackgroundColor(const Color& color) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->SetBackgroundColor(color); +} + +void +Form::SetFormStyle(unsigned long formStyle) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->SetFormStyle(formStyle); +} + +void +Form::SetOptionkeyActionId(int actionId) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->SetOptionkeyActionId(actionId); +} + +void +Form::SetOrientation(Orientation orientation) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->SetOrientation(orientation); +} + +void +Form::SetSoftkeyActionId(Softkey softkey, int actionId) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->SetSoftkeyActionId(softkey, actionId); +} + +void +Form::SetSoftkeyEnabled(Softkey softkey, bool enable) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->SetSoftkeyEnabled(softkey, enable); +} + +result +Form::SetTitleIcon(const Bitmap* pTitleBitmap) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTitleIcon(pTitleBitmap); +} + +result +Form::SetTitleText(const String& title, HorizontalAlignment alignment) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTitleText(title, alignment); +} + +void +Form::SetSoftkeyIcon(Softkey softkey, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->SetSoftkeyIcon(softkey, normalBitmap, pPressedBitmap); +} + +void +Form::SetSoftkeyText(Softkey softkey, const String& text) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->SetSoftkeyText(softkey, text); +} + +Footer* +Form::GetFooter(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + _FooterImpl* pFooterImpl = pImpl->GetFooter(); + if (!pFooterImpl) + { + return null; + } + + return pFooterImpl->GetFooter(); +} + +Header* +Form::GetHeader(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + _HeaderImpl* pHeaderImpl = pImpl->GetHeader(); + if (!pHeaderImpl) + { + return null; + } + + return pHeaderImpl->GetHeader(); +} + +bool +Form::HasFooter(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->HasFooter(); +} + +bool +Form::HasHeader(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->HasHeader(); +} + +bool +Form::IsIndicatorVisible(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsIndicatorVisible(); +} + +bool +Form::IsHeaderVisible(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsHeaderVisible(); +} + +bool +Form::IsFooterVisible(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsFooterVisible(); +} + +bool +Form::IsIndicatorTranslucent(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsIndicatorTranslucent(); +} + +bool +Form::IsHeaderTranslucent(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsHeaderTranslucent(); +} + +bool +Form::IsFooterTranslucent(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsFooterTranslucent(); +} + +result +Form::SetActionBarsTranslucent(unsigned long actionBars, bool translucent) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetActionBarsTranslucent(actionBars, translucent); +} + +result +Form::SetActionBarsVisible(unsigned long actionBars, bool visible) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetActionBarsVisible(actionBars, visible); +} + +OverlayRegion* +Form::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetOverlayRegionN(rect, regionType); +} + +Canvas* +Form::GetClientAreaCanvasN(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetClientAreaCanvasN(); +} + +Point +Form::TranslateToClientAreaPosition(const Point& position) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->TranslateToClientAreaPosition(position); +} + +Point +Form::TranslateFromClientAreaPosition(const Point& clientPosition) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->TranslateFromClientAreaPosition(clientPosition); +} + +void +Form::SetFormBackEventListener(IFormBackEventListener* pFormBackEventListener) +{ + _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetFormBackEventListener(pFormBackEventListener); +} + +DataBindingContext* +Form::GetDataBindingContextN(void) const +{ + const _FormImpl* pImpl = _FormImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetDataBindingContextN(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlFrame.cpp b/src/ui/controls/FUiCtrlFrame.cpp new file mode 100644 index 0000000..dc6153c --- /dev/null +++ b/src/ui/controls/FUiCtrlFrame.cpp @@ -0,0 +1,227 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlFrame.cpp + * @brief This is the implementation for the Frame class. + */ + +// Includes +#include +#include +#include "FUiCtrl_FrameImpl.h" +#include "FUiCtrl_FormImpl.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Frame::Frame(void) +{ +} + +Frame::~Frame(void) +{ +} + +result +Frame::Construct(void) +{ + SysAssertf(_FrameImpl::GetInstance(*this) == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + result r = E_SUCCESS; + + _FrameImpl* pImpl = _FrameImpl::CreateFrameImplN(this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return r; +} + +result +Frame::Construct(const Rectangle& rect) +{ + SysAssertf(_FrameImpl::GetInstance(*this) == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + result r = E_SUCCESS; + + _FrameImpl* pImpl = _FrameImpl::CreateFrameImplN(this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + pImpl->SetFloatingBounds(rect); + + return r; +} + +void +Frame::AddOrientationEventListener(IOrientationEventListener& listener) +{ + _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->AddOrientationEventListener(listener); +} + +void +Frame::AddFrameEventListener(IFrameEventListener& listener) +{ + _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->AddFrameEventListener(listener); +} + +void +Frame::RemoveOrientationEventListener(IOrientationEventListener& listener) +{ + _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveOrientationEventListener(listener); +} + +void +Frame::RemoveFrameEventListener(IFrameEventListener& listener) +{ + _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveFrameEventListener(listener); + + return; +} + +Form* +Frame::GetCurrentForm(void) const +{ + const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + _FormImpl* pFormImpl = pImpl->GetCurrentForm(); + SysTryReturn(NID_UI_CTRL, pFormImpl, null, E_INVALID_STATE, "[E_INVALID_STATE] The current Form does not exist."); + + return &pFormImpl->GetPublic(); +} + +result +Frame::SetCurrentForm(const Form& form) +{ + _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetCurrentForm(*_FormImpl::GetInstance(form)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Color +Frame::GetBackgroundColor(void) const +{ + const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBackgroundColor(); +} + +void +Frame::SetBackgroundColor(const Color& color) +{ + _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->SetBackgroundColor(color); +} + +void +Frame::SetOrientation(Orientation orientation) +{ + _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pImpl->SetOrientation(orientation); +} + +Orientation +Frame::GetOrientation(void) const +{ + const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetOrientation(); +} + +OrientationStatus +Frame::GetOrientationStatus(void) const +{ + const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetOrientationStatus(); +} + +FrameAnimator* +Frame::GetFrameAnimator(void) const +{ + const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetFrameAnimator(); +} + +result +Frame::SetShowMode(FrameShowMode mode) +{ + _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetShowMode(mode); +} + +FrameShowMode +Frame::GetShowMode(void) const +{ + const _FrameImpl* pImpl = _FrameImpl::GetInstance(*this); + SysAssertf(pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetShowMode(); +} + +}}} // Tizen::Ui::Constrols diff --git a/src/ui/controls/FUiCtrlGallery.cpp b/src/ui/controls/FUiCtrlGallery.cpp new file mode 100644 index 0000000..aa3783c --- /dev/null +++ b/src/ui/controls/FUiCtrlGallery.cpp @@ -0,0 +1,366 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlGallery.cpp + * @brief This file contains implementation of Gallery class. + * + * This header file contains the declarations of the Gallery class and its helper classes. + */ + +//Includes +#include +#include "FUiCtrl_GalleryImpl.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Ui::Effects; + +namespace Tizen { namespace Ui { namespace Controls { + +Gallery::Gallery(void) +{ + // Do nothing +} + +Gallery::~Gallery(void) +{ +} + +result +Gallery::Construct(const Rectangle& rect) +{ + SysAssertf(_GalleryImpl::GetInstance(*this) == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _GalleryImpl* pGalleryImpl = _GalleryImpl::CreateGalleryImplN(this); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + _pControlImpl = pGalleryImpl; + + r = Control::SetBounds(rect); + SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid."); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; + +CATCH: + delete pGalleryImpl; + _pControlImpl = null; + return r; +} + +result +Gallery::SetItemProvider(IGalleryItemProvider &provider) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGalleryImpl->SetItemProvider(provider); + + return r; +} + +void +Gallery::AddGalleryEventListener(IGalleryEventListener &listener) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + pGalleryImpl->AddGalleryEventListener(listener); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +Gallery::RemoveGalleryEventListener(IGalleryEventListener &listener) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + pGalleryImpl->RemoveGalleryEventListener(listener); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +int +Gallery::GetCurrentItemIndex(void) const +{ + const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + int currentItemIndex = pGalleryImpl->GetCurrentItemIndex(); + + return currentItemIndex; +} + +result +Gallery::SetCurrentItemIndex(int index) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGalleryImpl->SetCurrentItemIndex(index); + SysTryReturn(NID_UI_CTRL, r != E_OUT_OF_RANGE, r, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified %d index is out of range.", index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; +} + +int +Gallery::GetItemCount(void) const +{ + const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + int itemCount = pGalleryImpl->GetItemCount(); + return itemCount; +} + +result +Gallery::RefreshGallery(int itemIndex, GalleryRefreshType type) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGalleryImpl->RefreshGallery(itemIndex, type); + SysTryReturn(NID_UI_CTRL, r != E_OUT_OF_RANGE, r, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified %d index is out of range.", itemIndex); + SysTryReturn(NID_UI_CTRL, r != E_INVALID_OPERATION, r, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation."); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; +} + +result +Gallery::UpdateGallery(void) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGalleryImpl->UpdateGallery(); + SysTryReturn(NID_UI_CTRL, r != E_INVALID_OPERATION, r, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation."); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; +} + +result +Gallery::SetTextOfEmptyGallery(const String &text) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGalleryImpl->SetTextOfEmptyGallery(text); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; +} + +String +Gallery::GetTextOfEmptyGallery(void) const +{ + const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + String textOfEmptyGallery = pGalleryImpl->GetTextOfEmptyGallery(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, textOfEmptyGallery, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return textOfEmptyGallery; +} + +result +Gallery::SetBitmapOfEmptyGallery(const Bitmap* pBitmap) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGalleryImpl->SetBitmapOfEmptyGallery(pBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; +} + +result +Gallery::SetSlideShowAnimation(GalleryAnimation animation) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGalleryImpl->SetSlideShowAnimation(animation); + SysTryReturn(NID_UI_CTRL, r != E_UNSUPPORTED_OPERATION, r, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported."); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; +} + +GalleryAnimation +Gallery::GetSlideShowAnimation(void) const +{ + const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + GalleryAnimation slideShowAnimation = pGalleryImpl->GetSlideShowAnimation(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r != E_UNSUPPORTED_OPERATION, slideShowAnimation, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported."); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, slideShowAnimation, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return slideShowAnimation; +} + +result +Gallery::SetSlideShowAnimationDuration(int duration) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGalleryImpl->SetSlideShowAnimationDuration(duration); + SysTryReturn(NID_UI_CTRL, r != E_OUT_OF_RANGE, r, E_OUT_OF_RANGE, "The specified %d duration is out of the possible duration range.", duration); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; +} + +int +Gallery::GetSlideShowAnimationDuration(void) const +{ + const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + int slideShowAnimationDuration = pGalleryImpl->GetSlideShowAnimationDuration(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, slideShowAnimationDuration, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return slideShowAnimationDuration; +} + +result +Gallery::SetSlideShowViewDuration(int duration) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGalleryImpl->SetSlideShowViewDuration(duration); + SysTryReturn(NID_UI_CTRL, r != E_OUT_OF_RANGE, r, E_OUT_OF_RANGE, "The specified %d duration is out of the possible duration range.", duration); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; +} + +int +Gallery::GetSlideShowViewDuration(void) const +{ + const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + int slideShowViewDuration = pGalleryImpl->GetSlideShowViewDuration(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, slideShowViewDuration, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return slideShowViewDuration; +} + +result +Gallery::StartSlideShow(bool repeat) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGalleryImpl->StartSlideShow(repeat); + SysTryReturn(NID_UI_CTRL, r != E_INVALID_OPERATION, r, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation."); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; +} + +result +Gallery::StopSlideShow(void) const +{ + const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGalleryImpl->StopSlideShow(); + SysTryReturn(NID_UI_CTRL, r != E_INVALID_OPERATION, r, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation."); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; +} + +bool +Gallery::IsSlideShowStarted(void) const +{ + const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + bool slideShowStarted = pGalleryImpl->IsSlideShowStarted(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, slideShowStarted, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return slideShowStarted; +} + +result +Gallery::SetZoomingEnabled(bool enable) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pGalleryImpl->SetZoomingEnabled(enable); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; +} + +bool +Gallery::IsZoomingEnabled(void) const +{ + const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + bool zoomingEnable = pGalleryImpl->IsZoomingEnabled(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, zoomingEnable, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return zoomingEnable; +} + +result +Gallery::SetBackgroundColor(const Color& color) +{ + _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + Color tempColor = color; + tempColor.SetAlpha(255); + pGalleryImpl->SetBackgroundColor(tempColor); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return r; +} + +Color +Gallery::GetBackgroundColor(void) const +{ + const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this); + SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use."); + + Color backgroundColor = pGalleryImpl->GetBackgroundColor(); + return backgroundColor; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlGalleryItem.cpp b/src/ui/controls/FUiCtrlGalleryItem.cpp new file mode 100644 index 0000000..8353f0c --- /dev/null +++ b/src/ui/controls/FUiCtrlGalleryItem.cpp @@ -0,0 +1,83 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlGalleryItem.cpp + * @brief This is the header file for the GalleryItem class. + * + * This header file contains the declarations of the GalleryItem class and its helper classes. + */ + +//includes +#include +#include +#include +#include "FUiCtrl_GalleryItemImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Io; + +namespace Tizen { namespace Ui { namespace Controls +{ + +GalleryItem::GalleryItem(void) + : __pImpl(null) +{ + // Do nothing +} + +GalleryItem::~GalleryItem(void) +{ + delete __pImpl; +} + +result +GalleryItem::Construct(const Bitmap& bitmap, GalleryImageRotation rotation) +{ + return Construct(bitmap, L"", rotation); +} + +result +GalleryItem::Construct(const Bitmap& bitmap, const String& filePath, GalleryImageRotation rotation) +{ + _GalleryItemImpl* pImpl = _GalleryItemImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + result r = E_SUCCESS; + if (filePath != L"") + { + SysTryReturn(NID_UI_CTRL, File::IsFileExist(filePath), E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] File does not exist."); + } + + String imagefilePath(filePath); + + pImpl = _GalleryItemImpl::CreateGalleryItemImplN(this, bitmap, rotation, imagefilePath); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pImpl = pImpl; + + return E_SUCCESS; + +CATCH: + delete pImpl; + + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlGroupItem.cpp b/src/ui/controls/FUiCtrlGroupItem.cpp new file mode 100644 index 0000000..94b7be5 --- /dev/null +++ b/src/ui/controls/FUiCtrlGroupItem.cpp @@ -0,0 +1,127 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlGroupItem.cpp + * @brief This is the implementation file for GroupItem class. + * + * This header file contains the implementation of GroupItem class. + */ + +#include +#include +#include "FUiCtrl_GroupItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +GroupItem::GroupItem(void) + : _pImpl(null) +{ +} + +GroupItem::~GroupItem(void) +{ + delete _pImpl; + _pImpl = null; +} + +result +GroupItem::Construct(const Dimension& itemSize) +{ + result r = E_SUCCESS; + + _GroupItemImpl* pGroupItemImpl = _GroupItemImpl::GetInstance(*this); + SysAssertf((pGroupItemImpl == null), + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pGroupItemImpl = _GroupItemImpl::CreateGroupItemImpN(this, itemSize); + SysTryReturn(NID_UI_CTRL, (pGroupItemImpl != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _pImpl = pGroupItemImpl; + + return r; +} + +result +GroupItem::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->SetBackgroundBitmap(pBitmap); +} + +result +GroupItem::SetBackgroundColor(const Color& color) +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->SetBackgroundColor(color); +} + +Color +GroupItem::GetBackgroundColor(void) const +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->GetBackgroundColor(); +} + +result +GroupItem::SetTextColor(const Color& color) +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->SetTextColor(color); +} + +Color +GroupItem::GetTextColor(void) const +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->GetTextColor(); +} + +result +GroupItem::SetTextSize(int size) +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->SetTextSize(size); +} + +int +GroupItem::GetTextSize(void) const +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->GetTextSize(); +} + +result +GroupItem::SetElement(const String& text, const Bitmap* pBitmap) +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->SetElement(text, pBitmap); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlGroupedList.cpp b/src/ui/controls/FUiCtrlGroupedList.cpp new file mode 100644 index 0000000..131b79f --- /dev/null +++ b/src/ui/controls/FUiCtrlGroupedList.cpp @@ -0,0 +1,636 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlGroupedList.cpp +* @brief This file contains implementation of GroupedList class +*/ + + +#include +#include +#include "FUiCtrl_GroupedListImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls { + +GroupedList::GroupedList(void) +{ + +} + +GroupedList::~GroupedList(void) +{ + +} + +result +GroupedList::Construct(const Rectangle& rect, CustomListStyle style, bool itemDivider, bool fastScroll) +{ + result r = E_SUCCESS; + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _GroupedListImpl::CreateGroupedListImplN(this, rect, itemDivider, fastScroll); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + r = pImpl->SetListStyle(style); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error"); + + r = pImpl->Initialize(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error"); + + r = pImpl->LoadDefaultBitmap(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error"); + + ClearLastResult(); + + return E_SUCCESS; + +CATCH: + Dispose(); + return E_SYSTEM; +} + +result +GroupedList::AddGroup(const String& text, const Bitmap* pBackgroundBitmap, int groupId) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddGroup(text, pBackgroundBitmap, groupId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::InsertGroupAt(int groupIndex, const String& text, const Bitmap* pBackgroundBitmap, int groupId) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->InsertGroupAt(groupIndex, text, pBackgroundBitmap, groupId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::SetGroupAt(int groupIndex, const String& text, const Bitmap* pBackgroundBitmap, int groupId) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetGroupAt(groupIndex, text, pBackgroundBitmap, groupId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::RemoveAllGroups(void) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveAllGroups(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +GroupedList::GetGroupCount(void) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SetLastResult(E_SUCCESS); + return pImpl->GetGroupCount(); +} + +void +GroupedList::AddFastScrollEventListener(IFastScrollEventListener& listener) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddFastScrollEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return; +} + +void +GroupedList::RemoveFastScrollEventListener(IFastScrollEventListener& listener) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveFastScrollEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return; +} + +void +GroupedList::AddGroupedItemEventListener(IGroupedItemEventListener& listener) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddGroupedItemEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return; +} + +void +GroupedList::RemoveGroupedItemEventListener(IGroupedItemEventListener& listener) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveGroupedItemEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return; +} + +result +GroupedList::AddItem(int groupIndex, const CustomListItem& item, int itemId) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddItem(groupIndex, item, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::InsertItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->InsertItemAt(groupIndex, itemIndex, item, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::SetItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetItemAt(groupIndex, itemIndex, item, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::RemoveItemAt(int groupIndex, int itemIndex) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveItemAt(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::RemoveGroupAt(int groupIndex) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveGroupAt(groupIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::RemoveAllItems(void) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveAllItems(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::RemoveAllItemsAt(int groupIndex) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveAllItemsAt(groupIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::RemoveAllCheckedItemsAt(int groupIndex) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveAllCheckedItemsAt(groupIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +GroupedList::GetItemCountAt(int groupIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSubItemCountAt(groupIndex); +} + +const CustomListItem* +GroupedList::GetItemAt(int groupIndex, int itemIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && itemIndex >= 0), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex); + + const CustomListItem* pItem = pImpl->GetCustomListItemAt(groupIndex, itemIndex); + return pItem; +} + +result +GroupedList::SetItemEnabled(int groupIndex, int itemIndex, bool enable) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetItemEnabled(groupIndex, itemIndex, enable); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +bool +GroupedList::IsItemEnabled(int groupIndex, int itemIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SetLastResult(E_SUCCESS); + return pImpl->IsItemEnabled(groupIndex, itemIndex); +} + +result +GroupedList::SetItemChecked(int groupIndex, int itemIndex, bool check) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetItemChecked(groupIndex, itemIndex, check); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +bool +GroupedList::IsItemChecked(int groupIndex, int itemIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SetLastResult(E_SUCCESS); + return pImpl->IsItemChecked(groupIndex, itemIndex); +} + +result +GroupedList::SetAllItemsChecked(int groupIndex, bool check) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetAllItemsChecked(groupIndex, check); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::RemoveAllCheckedItems(void) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveAllCheckedItems(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::GetFirstCheckedItemIndex(int& groupIndex, int& itemIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->GetFirstCheckedItemIndex(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::GetLastCheckedItemIndex(int& groupIndex, int& itemIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->GetLastCheckedItemIndex(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::GetNextCheckedItemIndexAfter(int& groupIndex, int& itemIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->GetNextCheckedItemIndexAfter(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->GetItemIndexFromPosition(Point(x, y), groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +GroupedList::SetBackgroundColor(const Color& color) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetListBackgroundColor(color); + SetLastResult(E_SUCCESS); + return; +} + +void +GroupedList::SetTextOfEmptyList(const String& text) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextOfEmptyList(text); + SetLastResult(E_SUCCESS); + return; +} + +void +GroupedList::SetTextColorOfEmptyList(const Color& color) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextColorOfEmptyList(color); + SetLastResult(E_SUCCESS); + return; +} + +Color +GroupedList::GetTextColorOfEmptyList(void) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SetLastResult(E_SUCCESS); + return pImpl->GetTextColorOfEmptyList(); +} + +int +GroupedList::GetGroupIndexFromGroupId(int groupId) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SetLastResult(E_SUCCESS); + return pImpl->GetGroupIndexFromGroupId(groupId); +} + + +result +GroupedList::GetItemIndexFromItemId(int itemId, int& groupIndex, int& itemIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->GetItemIndexFromItemId(itemId, groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +GroupedList::GetItemIdAt(int groupIndex, int itemIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SetLastResult(E_SUCCESS); + return pImpl->GetItemIdAt(groupIndex, itemIndex); +} + +int +GroupedList::GetGroupIdAt(int groupIndex) const +{ + const _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SetLastResult(E_SUCCESS); + return pImpl->GetGroupIdAt(groupIndex); +} + +void +GroupedList::ScrollToBottom(void) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SetLastResult(E_SUCCESS); + pImpl->ScrollToBottom(); +} + +void +GroupedList::ScrollToTop(void) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SetLastResult(E_SUCCESS); + pImpl->ScrollToTop(); +} + +result +GroupedList::ScrollToTop(int groupIndex, int itemIndex) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollToTop(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::ScrollToTop(int groupIndex) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollToTop(groupIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::SetFastScrollMainIndex(const String& text) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetFastScrollMainIndex(text); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::SetFastScrollSubIndex(const String& text, FastScrollIndexDigit indexDigit) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetFastScrollSubIndex(text, indexDigit); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::RefreshItem(int groupIndex, int itemIndex) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RefreshItem(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedList::RefreshGroup(int groupIndex) +{ + _GroupedListImpl* pImpl = _GroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RefreshGroup(groupIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlGroupedListView.cpp b/src/ui/controls/FUiCtrlGroupedListView.cpp new file mode 100644 index 0000000..d9f4fc0 --- /dev/null +++ b/src/ui/controls/FUiCtrlGroupedListView.cpp @@ -0,0 +1,530 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlGroupedListView.cpp + * @brief This is the implementation file for GroupedListView class. + * + * This header file contains the implementation of GroupedListView class. + */ + +#include +#include +#include "FUiCtrl_GroupedListViewImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +GroupedListView::GroupedListView(void) +{ +} + +GroupedListView::~GroupedListView(void) +{ +} + +result +GroupedListView::Construct(const Rectangle& rect, GroupedListViewStyle style, bool itemDivider, bool fastScroll) +{ + result r = E_SUCCESS; + + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + if (fastScroll == true) + { + pImpl = _GroupedListViewImpl::CreateGroupedListViewImplN(this, style, itemDivider, SCROLL_STYLE_FAST_SCROLL); + } + else + { + pImpl = _GroupedListViewImpl::CreateGroupedListViewImplN(this, style, itemDivider, SCROLL_STYLE_FADE_OUT); + } + SysTryReturn(NID_UI_CTRL, pImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _pControlImpl = pImpl; + + r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + Control::Dispose(); + return r; +} + +result +GroupedListView::Construct(const Rectangle& rect, GroupedListViewStyle style, bool itemDivider, ListScrollStyle scrollStyle) +{ + result r = E_SUCCESS; + + SysAssertf((_GroupedListViewImpl::GetInstance(*this) == null), + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::CreateGroupedListViewImplN(this, style, itemDivider, scrollStyle); + SysTryReturn(NID_UI_CTRL, (pImpl != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _pControlImpl = pImpl; + + r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + Control::Dispose(); + return r; +} + +result +GroupedListView::SetItemProvider(IGroupedListViewItemProvider& provider) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemProvider(provider); +} + +void +GroupedListView::AddGroupedListViewItemEventListener(IGroupedListViewItemEventListener& listener) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddGroupedListViewItemEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +GroupedListView::RemoveGroupedListViewItemEventListener(IGroupedListViewItemEventListener& listener) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveGroupedListViewItemEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +GroupedListView::AddFastScrollListener(IFastScrollListener& listener) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddFastScrollListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +GroupedListView::RemoveFastScrollListener(IFastScrollListener& listener) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveFastScrollListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +GroupedListView::AddScrollEventListener(IScrollEventListener& listener) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddScrollEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +GroupedListView::RemoveScrollEventListener(IScrollEventListener& listener) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveScrollEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +GroupedListView::AddUiLinkEventListener(IUiLinkEventListener& listener) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddUiLinkEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +GroupedListView::RemoveUiLinkEventListener(IUiLinkEventListener& listener) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveUiLinkEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +result +GroupedListView::SetSweepEnabled(bool enable) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetSweepEnabled(enable); +} + +result +GroupedListView::SetFastScrollIndex(const String& text, bool useSearchIcon) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetFastScrollIndex(text, useSearchIcon); +} + +result +GroupedListView::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex); +} + +result +GroupedListView::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex); +} + +result +GroupedListView::ScrollToItem(int groupIndex, int itemIndex) +{ + return ScrollToItem(groupIndex, itemIndex, LIST_SCROLL_ITEM_ALIGNMENT_TOP); +} + +result +GroupedListView::ScrollToItem(int groupIndex, int itemIndex, ListScrollItemAlignment itemAlignment) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ScrollToItem(groupIndex, itemIndex, itemAlignment); +} + +result +GroupedListView::SetItemChecked(int groupIndex, int itemIndex, bool check) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemChecked(groupIndex, itemIndex, check); +} + +bool +GroupedListView::IsItemChecked(int groupIndex, int itemIndex) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemChecked(groupIndex, itemIndex); +} + +result +GroupedListView::SetItemEnabled(int groupIndex, int itemIndex, bool enable) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemEnabled(groupIndex, itemIndex, enable); +} + +bool +GroupedListView::IsItemEnabled(int groupIndex, int itemIndex) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemEnabled(groupIndex, itemIndex); +} + +int +GroupedListView::GetGroupCount(void) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetGroupCount(); +} + +int +GroupedListView::GetItemCountAt(int groupIndex) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemCountAt(groupIndex); +} + +result +GroupedListView::ShowItemDescriptionText(int groupIndex, int itemIndex) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ShowItemDescriptionText(groupIndex, itemIndex); +} + +result +GroupedListView::HideItemDescriptionText(int groupIndex, int itemIndex) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->HideItemDescriptionText(groupIndex, itemIndex); +} + +result +GroupedListView::RefreshList(int groupIndex, int itemIndex, ListRefreshType type) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RefreshList(groupIndex, itemIndex, type); +} + +result +GroupedListView::RefreshList(int groupIndex, int itemIndex, int elementId) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RefreshList(groupIndex, itemIndex, elementId); +} + +result +GroupedListView::UpdateList(void) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->UpdateList(); +} + +result +GroupedListView::GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex) const +{ + return GetItemIndexFromPosition(Point(x, y), groupIndex, itemIndex); +} + +result +GroupedListView::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex); +} + +result +GroupedListView::GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex, int& elementId) const +{ + return GetItemIndexFromPosition(Point(x, y), groupIndex, itemIndex, elementId); +} + +result +GroupedListView::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex, int& elementId) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex, elementId); +} + +result +GroupedListView::SetSectionColor(const Color& color) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetSectionColor(color); +} + +Color +GroupedListView::GetSectionColor(void) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSectionColor(); +} + +result +GroupedListView::SetItemDividerColor(const Color& color) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemDividerColor(color); +} + +Color +GroupedListView::GetItemDividerColor(void) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemDividerColor(); +} + +result +GroupedListView::SetBackgroundColor(const Color& color) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetListBackgroundColor(color); + + return E_SUCCESS; +} + +Color +GroupedListView::GetBackgroundColor(void) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBackgroundColor(); +} + +result +GroupedListView::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetBackgroundBitmap(pBitmap); +} + +result +GroupedListView::SetBitmapOfEmptyList(const Bitmap* pBitmap) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetBitmapOfEmptyList(pBitmap); +} + +result +GroupedListView::SetTextOfEmptyList(const String& text) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTextOfEmptyList(text); +} + +String +GroupedListView::GetTextOfEmptyList(void) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextOfEmptyList(); +} + +result +GroupedListView::SetTextColorOfEmptyList(const Color& color) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTextColorOfEmptyList(color); +} + +Color +GroupedListView::GetTextColorOfEmptyList(void) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextColorOfEmptyList(); +} + +result +GroupedListView::ExpandGroup(int groupIndex) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ExpandGroup(groupIndex); +} + +result +GroupedListView::CollapseGroup(int groupIndex) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->CollapseGroup(groupIndex); +} + +bool +GroupedListView::IsGroupExpanded(int groupIndex) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsGroupExpanded(groupIndex); +} + +result +GroupedListView::BeginReorderingMode(void) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->BeginReorderingMode(); +} + +result +GroupedListView::EndReorderingMode(void) +{ + _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->EndReorderingMode(); +} + +bool +GroupedListView::IsInReorderingMode(void) const +{ + const _GroupedListViewImpl* pImpl = _GroupedListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsInReorderingMode(); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlGroupedTableView.cpp b/src/ui/controls/FUiCtrlGroupedTableView.cpp new file mode 100644 index 0000000..fbf079b --- /dev/null +++ b/src/ui/controls/FUiCtrlGroupedTableView.cpp @@ -0,0 +1,460 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlGroupedTableView.cpp +* @brief This is the implementation file for GroupedTableView class. +* +* This header file contains the implementation of GroupedTableView class. +*/ + +#include +#include +#include +#include +#include "FUiCtrl_TableViewImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +//////////////////////////////////////////////////////////////////////////////// +/// GroupedTableView class + +GroupedTableView::GroupedTableView(void) +{ +} + +GroupedTableView::~GroupedTableView(void) +{ +} + +result +GroupedTableView::Construct(const Tizen::Graphics::Rectangle& rect, bool itemDivider, TableViewScrollBarStyle scrollStyle) +{ + result r = E_SUCCESS; + + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _TableViewImpl::CreateTableViewImplN(this, rect, TABLE_VIEW_STYLE_GROUPED, itemDivider, scrollStyle); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + r = SetBounds(rect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + Control::Dispose(); + + return r; +} + +void +GroupedTableView::SetItemProvider(IGroupedTableViewItemProvider* pProvider) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetGroupedStyleItemProvider(pProvider); +} + + +result +GroupedTableView::AddGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddGroupedTableViewItemEventListener(listener); +} + +result +GroupedTableView::RemoveGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveGroupedTableViewItemEventListener(listener); +} + +result +GroupedTableView::AddFastScrollListener(IFastScrollListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddFastScrollListener(listener); +} + +result +GroupedTableView::RemoveFastScrollListener(IFastScrollListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveFastScrollListener(listener); +} + +result +GroupedTableView::AddScrollEventListener(IScrollEventListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddScrollEventListener(listener); +} + +result +GroupedTableView::RemoveScrollEventListener(IScrollEventListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveScrollEventListener(listener); +} + +void +GroupedTableView::SetCollapseByPinchGestureEnabled(bool enable) +{ + + //TODO : seperate +} + +bool +GroupedTableView::IsCollapseByPinchGestureEnabled(void) const +{ + //TODO : seperate + return false; +} + +result +GroupedTableView::SetFastScrollIndex(const String& text, bool useSearchIcon) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetFastScrollIndex(text, useSearchIcon); +} + +result +GroupedTableView::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex); +} + +result +GroupedTableView::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + + return pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex); +} + +result +GroupedTableView::SetItemChecked(int groupIndex, int itemIndex, bool check) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemChecked(groupIndex, itemIndex, check); +} + +bool +GroupedTableView::IsItemChecked(int groupIndex, int itemIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemChecked(groupIndex, itemIndex); +} + +result +GroupedTableView::SetItemEnabled(int groupIndex, int itemIndex, bool enable) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemEnabled(groupIndex, itemIndex, enable); +} + +bool +GroupedTableView::IsItemEnabled(int groupIndex, int itemIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemEnabled(groupIndex, itemIndex); +} + +int +GroupedTableView::GetGroupCount(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetGroupCount(); +} + +int +GroupedTableView::GetItemCountAt(int groupIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemCountAt(groupIndex); +} + +result +GroupedTableView::RefreshItem(int groupIndex, int itemIndex, TableViewRefreshType type) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RefreshTableView(groupIndex, itemIndex, type); +} + +void +GroupedTableView::UpdateTableView(void) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->UpdateTableView(); +} + +void +GroupedTableView::GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex); +} + +void +GroupedTableView::SetItemDividerColor(const Color& color) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetItemDividerColor(color); +} + +Color +GroupedTableView::GetItemDividerColor(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemDividerColor(); +} + +void +GroupedTableView::SetBackgroundColor(const Color& color) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetBackgroundColor(color); + + return; +} + +Color +GroupedTableView::GetBackgroundColor(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBackgroundColor(); +} + +result +GroupedTableView::ExpandGroup(int groupIndex) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ExpandGroup(groupIndex); +} + +result +GroupedTableView::CollapseGroup(int groupIndex) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->CollapseGroup(groupIndex); +} + +void +GroupedTableView::ExpandAllGroup(void) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->ExpandAllGroup(); +} + +void +GroupedTableView::CollapseAllGroup(void) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->CollapseAllGroup(); +} + +bool +GroupedTableView::IsGroupExpanded(int groupIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsGroupExpanded(groupIndex); +} + +void +GroupedTableView::SetGroupedLookEnabled(bool enable) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetGroupedLookEnabled(enable); +} + +bool +GroupedTableView::IsGroupedLookEnabled(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsGroupedLookEnabled(); +} + +result +GroupedTableView::ScrollToItem(int groupIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollToItem(groupIndex, itemIndex, itemAlignment); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +GroupedTableView::ScrollByPixel(int scrollDistance) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollByPixel(scrollDistance); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +GroupedTableView::SetScrollInputMode(ScrollInputMode mode) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->SetScrollInputMode(mode); +} + +ScrollInputMode +GroupedTableView::GetScrollInputMode(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + return pImpl->GetScrollInputMode(); +} + +//void +//GroupedTableView::BeginReorderingMode(void) +//{ +// _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); +// SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); +// +// pImpl->BeginReorderingMode(); +//} +// +//void +//GroupedTableView::EndReorderingMode(void) +//{ +// _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); +// SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); +// +// pImpl->EndReorderingMode(); +//} +// +//bool +//GroupedTableView::IsInReorderingMode(void) const +//{ +// const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); +// SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); +// +// return pImpl->IsInReorderingMode(); +//} + +int +GroupedTableView::GetCurrentScrollPosition(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetCurrentScrollPosition(); +} + +void +GroupedTableView::SetScrollEnabled(bool enable) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetScrollEnabled(enable); + + return; +} + +bool +GroupedTableView::IsScrollEnabled(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsScrollEnabled(); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlHeader.cpp b/src/ui/controls/FUiCtrlHeader.cpp new file mode 100644 index 0000000..ff31c60 --- /dev/null +++ b/src/ui/controls/FUiCtrlHeader.cpp @@ -0,0 +1,718 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlHeader.cpp + * @brief This is the implementation file for Header class. + */ + +#include +#include +#include "FUiCtrl_HeaderImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +result +Header::Construct(void) +{ + SysAssertf(_pControlImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + result r = E_SUCCESS; + + _HeaderImpl* pImpl = _HeaderImpl::CreateHeaderImplN(this); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return r; +} + +result +Header::AddItem(const HeaderItem& item) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->AddItem(item); +} + +ButtonItemStatus +Header::GetButtonStatus(ButtonPosition position) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetButtonStatus(position); +} + +Color +Header::GetButtonColor(ButtonItemStatus status) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetButtonColor(status); +} + +Color +Header::GetButtonTextColor(ButtonItemStatus status) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetButtonTextColor(status); +} + +String +Header::GetDescriptionText(void) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetDescriptionText(); +} + +Color +Header::GetDescriptionTextColor(void) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetDescriptionTextColor(); +} + +Color +Header::GetItemColor(HeaderItemStatus status) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetItemColor(status); +} + +int +Header::GetItemCount(void) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetItemCount(); +} + +result +Header::GetItemStatus(int itemIndex, HeaderItemStatus& status) const +{ + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetItemStatus(itemIndex, status); +} + +Color +Header::GetItemTextColor(HeaderItemStatus status) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetItemTextColor(status); +} + +HeaderStyle +Header::GetStyle(void) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetStyle(); +} + +int +Header::GetSelectedItemIndex(void) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetSelectedItemIndex(); +} + +String +Header::GetTitleText(void) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetTitleText(); +} + +Color +Header::GetTitleTextColor(void) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetTitleTextColor(); +} + +Color +Header::GetColor(void) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetColor(); +} + +AnimationStatus +Header::GetWaitingAnimationStatus(HeaderAnimationPosition animationPos) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetWaitingAnimationStatus(animationPos); +} + +result +Header::InsertItemAt(int itemIndex, const HeaderItem& item) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->InsertItemAt(itemIndex, item); +} + +bool +Header::IsButtonSet(ButtonPosition position) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->IsButtonSet(position); +} + +result +Header::PauseWaitingAnimation(HeaderAnimationPosition animationPos) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->PauseWaitingAnimation(animationPos); +} + +result +Header::PlayWaitingAnimation(HeaderAnimationPosition animationPos) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->PlayWaitingAnimation(animationPos); +} + +result +Header::RemoveAllButtons(void) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->RemoveAllButtons(); +} + +result +Header::RemoveAllItems(void) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->RemoveAllItems(); +} + +result +Header::RemoveItemAt(int itemIndex) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->RemoveItemAt(itemIndex); +} + +result +Header::RemoveButtonAt(ButtonPosition position) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->RemoveButtonAt(position); +} + +result +Header::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetBackgroundBitmap(pBitmap); +} + +result +Header::SetButton(ButtonPosition position, const ButtonItem& button) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetButton(position, button); +} + +result +Header::SetButtonColor(ButtonItemStatus status, const Color& color) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetButtonColor(status, color); +} + +result +Header::SetButtonEnabled(ButtonPosition position, bool enable) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetButtonEnabled(position, enable); +} + +result +Header::SetButtonTextColor(ButtonItemStatus status, const Color& color) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetButtonTextColor(status, color); +} + +result +Header::SetButtonBadgeIcon(ButtonPosition position, const Bitmap* pBadgeIcon) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetButtonBadgeIcon(position, pBadgeIcon); +} + +result +Header::SetButtonNumberedBadgeIcon(ButtonPosition position, int number) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetButtonNumberedBadgeIcon(position, number); +} + +result +Header::SetItemAt(int itemIndex, const HeaderItem& item) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetItemAt(itemIndex, item); +} + +result +Header::SetItemBadgeIcon(int itemIndex, const Bitmap* pBadgeIcon) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetItemBadgeIcon(itemIndex, pBadgeIcon); +} + +result +Header::SetItemNumberedBadgeIcon(int itemIndex, int number) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetItemNumberedBadgeIcon(itemIndex, number); +} + +result +Header::SetItemColor(HeaderItemStatus status, const Color& color) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetItemColor(status, color); +} + +result +Header::SetItemEnabled(int itemIndex, bool enable) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetItemEnabled(itemIndex, enable); +} + +result +Header::SetItemTextColor(HeaderItemStatus status, const Color& color) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetItemTextColor(status, color); +} + +result +Header::SetItemSelected(int itemIndex) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetItemSelected(itemIndex); +} + +result +Header::SetColor(const Color& color) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetColor(color); +} + +result +Header::SetStyle(HeaderStyle style) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetStyle(style); +} + +result +Header::SetTitleIcon(const Bitmap* pIcon) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetTitleIcon(pIcon); +} + +result +Header::SetTitleText(const String& text) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetTitleText(text); +} + +result +Header::SetTitleTextColor(const Color& color) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetTitleTextColor(color); +} + +result +Header::SetDescriptionText(const String& text) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetDescriptionText(text); +} + +result +Header::SetDescriptionTextColor(const Color& color) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetDescriptionTextColor(color); +} + +result +Header::StopWaitingAnimation(HeaderAnimationPosition animationPos) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->StopWaitingAnimation(animationPos); +} + +void +Header::AddActionEventListener(IActionEventListener& listener) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pHeaderImpl->AddActionEventListener(listener); + + return; +} + +void +Header::RemoveActionEventListener(IActionEventListener& listener) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pHeaderImpl->RemoveActionEventListener(listener); + + return; +} + +bool +Header::IsTabEditModeEnabled(void) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->IsTabEditModeEnabled(); +} + +result +Header::SetTabEditModeEnabled(bool enable) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetTabEditModeEnabled(enable); +} + +result +Header::SetBackButton(void) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetBackButton(); +} + +bool +Header::IsBackButtonSet(void) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->IsBackButtonSet(); +} + +void +Header::RemoveBackButton(void) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pHeaderImpl->RemoveBackButton(); + + return; +} + +result +Header::SetBackButtonEnabled(bool enable) +{ + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->SetBackButtonEnabled(enable); +} + +ButtonItemStatus +Header::GetBackButtonStatus(void) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetBackButtonStatus(); +} + +Rectangle +Header::GetButtonBounds(ButtonPosition position) const +{ + ClearLastResult(); + + const _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*this); + + SysAssertf(pHeaderImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pHeaderImpl->GetButtonBounds(position); +} + +Header::Header(void) +{ +} + +Header::~Header(void) +{ +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlHeaderItem.cpp b/src/ui/controls/FUiCtrlHeaderItem.cpp new file mode 100644 index 0000000..48b2f10 --- /dev/null +++ b/src/ui/controls/FUiCtrlHeaderItem.cpp @@ -0,0 +1,129 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrlHeaderItem.cpp +* @brief This is the implementation file for HeaderItem class. +*/ + +#include +#include +#include +#include "FUiCtrl_HeaderItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +HeaderItem::HeaderItem(void) + : __pImpl(null) +{ +} + +HeaderItem::~HeaderItem(void) +{ + if (__pImpl) + { + delete __pImpl; + __pImpl = null; + } +} + +result +HeaderItem::Construct(int actionId) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (actionId >= HEADER_ITEM_ACTION_ID_MIN && actionId <= HEADER_ITEM_ACTION_ID_MAX), E_INVALID_ARG, + "[E_INVALID_ARG] The actionId is invalid."); + + _HeaderItemImpl* pImpl = _HeaderItemImpl::GetInstance(*this); + SysAssertf(pImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + __pImpl = new (std::nothrow) _HeaderItemImpl(this); + SysTryReturnResult(NID_UI_CTRL, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Impl instance is not constructed"); + + r = __pImpl->Construct(actionId); + + if (IsFailed(r)) + { + delete __pImpl; + __pImpl = null; + SysLog(NID_UI_CTRL, "[%s] Propagated.", GetErrorMessage(r)); + return r; + } + + return r; +} + +int +HeaderItem::GetActionId(void) const +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->GetActionId(); +} + +String +HeaderItem::GetText(void) const +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->GetText(); +} + +result +HeaderItem::SetActionId(int actionId) +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetActionId(actionId); +} + +result +HeaderItem::SetBackgroundBitmap(HeaderItemStatus status, const Bitmap* pBitmap) +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetBackgroundBitmap(status, pBitmap); +} + +result +HeaderItem::SetIcon(HeaderItemStatus status, const Bitmap* pIcon) +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetIcon(status, pIcon); +} + +result +HeaderItem::SetText(const String& text) +{ + SysAssertf(__pImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetText(text); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlIGroupedListViewItemEventListener.cpp b/src/ui/controls/FUiCtrlIGroupedListViewItemEventListener.cpp new file mode 100644 index 0000000..cff92c1 --- /dev/null +++ b/src/ui/controls/FUiCtrlIGroupedListViewItemEventListener.cpp @@ -0,0 +1,47 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIGroupedListViewItemEventListener.cpp + * @brief This is the implementation file for IGroupedListViewItemEventListener class. + * + * This header file contains the implementation of IGroupedListViewItemEventListener class. + */ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +void +IGroupedListViewItemEventListener::OnGroupedListViewItemLongPressed(GroupedListView& listView, int groupIndex, int itemIndex, + int elementId, bool& invokeListViewItemCallback) +{ +} + +void +IGroupedListViewItemEventListener::OnGroupedListViewGroupItemSelected(GroupedListView& listView, int groupIndex) +{ +} + +void +IGroupedListViewItemEventListener::OnGroupedListViewItemReordered(GroupedListView& listView, + int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo) +{ +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlIGroupedListViewItemProvider.cpp b/src/ui/controls/FUiCtrlIGroupedListViewItemProvider.cpp new file mode 100644 index 0000000..c71c99d --- /dev/null +++ b/src/ui/controls/FUiCtrlIGroupedListViewItemProvider.cpp @@ -0,0 +1,36 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIGroupedListViewItemProvider.cpp + * @brief This is the implementation file for IGroupedListViewItemProvider class. + * + * This header file contains the implementation of IGroupedListViewItemProvider class. + */ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +bool +IGroupedListViewItemProvider::IsReorderable(int groupIndexFrom, int groupIndexTo) +{ + return true; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlIListViewItemEventListener.cpp b/src/ui/controls/FUiCtrlIListViewItemEventListener.cpp new file mode 100644 index 0000000..fe7ae54 --- /dev/null +++ b/src/ui/controls/FUiCtrlIListViewItemEventListener.cpp @@ -0,0 +1,41 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIListViewItemEventListener.cpp + * @brief This is the implementation file for IListViewItemEventListener class. + * + * This header file contains the implementation of IListViewItemEventListener class. + */ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +void +IListViewItemEventListener::OnListViewItemLongPressed(ListView& listView, int index, int elementId, + bool& invokeListViewItemCallback) +{ +} + +void +IListViewItemEventListener::OnListViewItemReordered(ListView& listView, int indexFrom, int indexTo) +{ +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlIconList.cpp b/src/ui/controls/FUiCtrlIconList.cpp new file mode 100644 index 0000000..80666b9 --- /dev/null +++ b/src/ui/controls/FUiCtrlIconList.cpp @@ -0,0 +1,474 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlIconList.cpp + * @brief This is the implementation file for FUiCtrlIconList class + * + * This file contains the implementation of FUiCtrlIconList class + */ + +#include +#include +#include "FUiCtrl_IconListImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IconList::IconList(void) +{ +} + +IconList::~IconList(void) +{ +} + +result +IconList::Construct(const Rectangle& rect, IconListStyle style, int itemWidth, int itemHeight) +{ + result r = E_SUCCESS; + + SysAssertf((_IconListImpl::GetInstance(*this) == null), + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _IconListImpl* pImpl = _IconListImpl::CreateIconListImplN(this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error"); + + // Set Initial Parameters + + r = pImpl->SetIconListStyle(style); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error"); + + r = pImpl->InitializeIconList(itemWidth, itemHeight); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error"); + + r = pImpl->SetItemProvider(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error"); + + r = pImpl->SetListener(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error"); + + r = pImpl->SetNonSlidable(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "Internal Error"); + + return E_SUCCESS; + +CATCH: + Dispose(); + return r; +} + +void +IconList::AddItemEventListener(IItemEventListener& listener) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddItemEventListener(listener); +} + +void +IconList::RemoveItemEventListener(IItemEventListener& listener) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveItemEventListener(listener); +} + +void +IconList::SetBackgroundBitmap(const Bitmap& bitmap) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetBackgroundBitmap(bitmap); + +} + +result +IconList::SetMargin(int topMargin, int leftMargin) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetMargin(topMargin, leftMargin); +} + +int +IconList::GetTopMargin(void) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTopMargin(); +} + +int +IconList::GetLeftMargin(void) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLeftMargin(); +} + +result +IconList::AddItem(const String* pText, const Bitmap* pNormalBitmap, const Bitmap* pFocusedBitmap, int itemId) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddItem(pText, pNormalBitmap, pFocusedBitmap, itemId); +} + +result +IconList::InsertItemAt(int index, const String* pText, const Bitmap* pNormalBitmap, const Bitmap* pFocusedBitmap, int itemId) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->InsertItemAt(index, pText, pNormalBitmap, pFocusedBitmap, itemId); +} + +result +IconList::SetItemAt(int index, const String* pText, const Bitmap* pNormalBitmap, const Bitmap* pFocusedBitmap, int itemId) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemAt(index, pText, pNormalBitmap, pFocusedBitmap, itemId); +} + +result +IconList::RemoveItemAt(int index) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveItemAt(index); +} + +result +IconList::RemoveAllItems(void) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveAllItems(); +} + +int +IconList::GetColumnCount(void) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetColumnCount(); +} + +int +IconList::GetItemCount(void) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemCount(); +} + +result +IconList::SetItemChecked(int index, bool check) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemChecked(index, check); +} + +bool +IconList::IsItemChecked(int index) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemChecked(index); +} + +result +IconList::SetAllItemsChecked(bool check) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetAllItemsChecked(check); +} + +result +IconList::RemoveAllCheckedItems(void) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveAllCheckedItems(); +} + +int +IconList::GetFirstCheckedItemIndex(void) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetFirstCheckedItemIndex(); +} + +int +IconList::GetLastCheckedItemIndex(void) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLastCheckedItemIndex(); +} + +int +IconList::GetNextCheckedItemIndexAfter(int index) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetNextCheckedItemIndexAfter(index); +} + +int +IconList::GetItemIndexFromPosition(int x, int y) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(Point(x, y)); +} + +int +IconList::GetItemIndexFromPosition(const Point& position) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(position); +} + +void +IconList::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTextHorizontalAlignment(alignment); +} + +void +IconList::SetTextVerticalAlignment(VerticalAlignment alignment) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTextVerticalAlignment(alignment); +} + +HorizontalAlignment +IconList::GetTextHorizontalAlignment(void) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextHorizontalAlignment(); +} + +VerticalAlignment +IconList::GetTextVerticalAlignment(void) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextVerticalAlignment(); +} + +void +IconList::SetBackgroundColor(const Color& color) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetBackgroundColor(color); +} + +void +IconList::SetTextOfEmptyList(const String& text) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextOfEmptyList(text); +} + +void +IconList::SetTextColorOfEmptyList(const Color& color) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextColorOfEmptyList(color); +} + +Color +IconList::GetTextColorOfEmptyList(void) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextColorOfEmptyList(); +} + +void +IconList::SetItemTextColor(const Color& textColor) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetItemTextColor(textColor); +} + +Color +IconList::GetItemTextColor(void) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemTextColor(); + +} + +void +IconList::SetTextSize(int size) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextSize(size); +} + +int +IconList::GetTextSize(void) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextSize(); +} + +int +IconList::GetItemIndexFromItemId(int itemId) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromItemId(itemId); +} + +int +IconList::GetItemIdAt(int index) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIdAt(index); +} + +void +IconList::SetCheckBoxPosition(IconListCheckBoxPosition position) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetCheckBoxPosition(position); +} + +IconListCheckBoxPosition +IconList::GetCheckBoxPosition(void) const +{ + const _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetCheckBoxPosition(); +} + +void +IconList::SetFocusAnimationEnabled(bool enable) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetFocusAnimationEnabled(enable); +} + +void +IconList::ScrollToBottom(void) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ScrollToBottom(); +} + +void +IconList::ScrollToTop(void) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ScrollToTop(); +} + +result +IconList::ScrollToTop(int itemIndex) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ScrollToTop(itemIndex); +} + +result +IconList::RefreshItem(int index) +{ + _IconListImpl* pImpl = _IconListImpl::GetInstance(*this); + SysAssertf(pImpl, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RefreshItem(index); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlIconListView.cpp b/src/ui/controls/FUiCtrlIconListView.cpp new file mode 100644 index 0000000..a7c286a --- /dev/null +++ b/src/ui/controls/FUiCtrlIconListView.cpp @@ -0,0 +1,638 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIconListView.cpp + * @brief This is the implementation file for the IconListView class. + */ + +//Includes +#include +#include +#include + +#include "FUiCtrl_IconListViewImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class IconListView + * @brief This class defines common behavior for a %IconListView control. + * @since 2.0 + * + * Details.... + * + * Example: + * + * @image html GUI_IconListView.png + * + * This is the simple UI application which uses a IconListView control. + * + * @code + + * @endcode + * + */ + +IconListView::IconListView(void) +{ + // Do nothing +} + +IconListView::~IconListView(void) +{ + // Do nothing +} + +result +IconListView::Construct(const Rectangle& rect, const Dimension& itemBitmapSize, IconListViewStyle style, + IconListViewScrollDirection scrollDirection, IconListViewScrollStyle scrollStyle) +{ + // Check whether _pControlImpl has been set, that is, "already constructed" condition. + SysAssertf(_pControlImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + // Create _IconListViewImpl + _IconListViewImpl* pImpl = _IconListViewImpl::CreateIconListViewImplN(this); + SysTryReturn(NID_UI_CTRL, (pImpl != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + // Set _IconListViewImpl + _pControlImpl = pImpl; + + // Set Bounds + result r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height); + if (r != E_SUCCESS) + { + Dispose(); + Control::Dispose(); + return r; + } + + // Set Initial Parameters + r = pImpl->Initialize(this, itemBitmapSize, style, scrollDirection, scrollStyle); + if (r != E_SUCCESS) + { + Dispose(); + Control::Dispose(); + } + + return r; +} + +result +IconListView::SetItemProvider(IIconListViewItemProvider& provider) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetItemProvider(provider); +} + +void +IconListView::AddIconListViewItemEventListener(IIconListViewItemEventListener& listener) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + pImpl->AddIconListViewItemEventListener(listener); +} + +void +IconListView::RemoveIconListViewItemEventListener(IIconListViewItemEventListener& listener) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + pImpl->RemoveIconListViewItemEventListener(listener); +} + +void +IconListView::AddScrollEventListener(IScrollEventListener& listener) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + pImpl->AddScrollEventListener(listener); +} + +void +IconListView::RemoveScrollEventListener(IScrollEventListener& listener) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + pImpl->RemoveScrollEventListener(listener); +} + +result +IconListView::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetBackgroundBitmap(pBitmap); +} + +result +IconListView::SetBackgroundColor(const Color& color) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + pImpl->SetBackgroundColor(color); + + result r = GetLastResult(); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +Color +IconListView::GetBackgroundColor(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetBackgroundColor(); +} + +result +IconListView::SetMargin(MarginType type, int value) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetMargin(type, value); +} + +int +IconListView::GetMargin(MarginType type) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetMargin(type); +} + +result +IconListView::SetItemSpacing(int horizontalSpacing, int verticalSpacing) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetItemSpacing(horizontalSpacing, verticalSpacing); +} + +int +IconListView::GetItemHorizontalSpacing(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemHorizontalSpacing(); +} + +int +IconListView::GetItemVerticalSpacing(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemVerticalSpacing(); +} + +result +IconListView::SetItemChecked(int index, bool check) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetItemChecked(index, check); +} + +bool +IconListView::IsItemChecked(int index) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->IsItemChecked(index); +} + +int +IconListView::GetItemIndexFromPosition(int x, int y) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemIndexFromPosition(x, y); +} + +int +IconListView::GetItemIndexFromPosition(const Point& position) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemIndexFromPosition(position); +} + +result +IconListView::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetTextHorizontalAlignment(alignment); +} + +result +IconListView::SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetTextVerticalAlignment(alignment); +} + +HorizontalAlignment +IconListView::GetTextHorizontalAlignment(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetTextHorizontalAlignment(); +} + +IconListViewItemTextVerticalAlignment +IconListView::GetTextVerticalAlignment(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetTextVerticalAlignment(); +} + +result +IconListView::SetTextOfEmptyList(const String& text) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetTextOfEmptyList(text); +} + +String +IconListView::GetTextOfEmptyList(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetTextOfEmptyList(); +} + +result +IconListView::SetTextColorOfEmptyList(const Color& color) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetTextColorOfEmptyList(color); +} + +Color +IconListView::GetTextColorOfEmptyList(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetTextColorOfEmptyList(); +} + +result +IconListView::SetItemTextColor(IconListViewItemDrawingStatus status, const Color& color) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetItemTextColor(status, color); +} + +Color +IconListView::GetItemTextColor(IconListViewItemDrawingStatus status) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemTextColor(status); +} + +result +IconListView::SetItemTextSize(int size) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetItemTextSize(size); +} + +int +IconListView::GetItemTextSize(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemTextSize(); +} + +result +IconListView::SetCheckBoxPosition(IconListViewCheckBoxPosition position) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetCheckBoxPosition(position); +} + +IconListViewCheckBoxPosition +IconListView::GetCheckBoxPosition(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetCheckBoxPosition(); +} + +result +IconListView::SetTouchAnimationEnabled(bool enable) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetTouchAnimationEnabled(enable); +} + +bool +IconListView::IsTouchAnimationEnabled(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->IsTouchAnimationEnabled(); +} + +result +IconListView::ScrollToItem(int index) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->ScrollToItem(index); +} + +result +IconListView::RefreshList(int index, ListRefreshType type) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->RefreshList(index, type); +} + +result +IconListView::UpdateList(void) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->UpdateList(); +} + +result +IconListView::GetItemBitmapSize(int& width, int& height) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemBitmapSize(width, height); +} + +Dimension +IconListView::GetItemBitmapSize(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemBitmapSize(); +} + +result +IconListView::GetItemSize(int& width, int& height) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemSize(width, height); +} + +Dimension +IconListView::GetItemSize(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemSize(); +} + +result +IconListView::SetMagneticScrollSize(int scrollSize) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetMagneticScrollSize(scrollSize); +} + +int +IconListView::GetMagneticScrollSize(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetMagneticScrollSize(); +} + +int +IconListView::GetItemCountPerAxis(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemCountPerAxis(); +} + +result +IconListView::SetItemLayoutHorizontalAlignment(HorizontalAlignment alignment) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetItemLayoutHorizontalAlignment(alignment); +} + +result +IconListView::SetItemLayoutVerticalAlignment(VerticalAlignment alignment) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetItemLayoutVerticalAlignment(alignment); +} + +HorizontalAlignment +IconListView::GetItemLayoutHorizontalAlignment(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemLayoutHorizontalAlignment(); +} + +VerticalAlignment +IconListView::GetItemLayoutVerticalAlignment(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemLayoutVerticalAlignment(); +} + +result +IconListView::SetItemBorderStyle(IconListViewItemBorderStyle borderStyle) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetItemBorderStyle(borderStyle); +} + +IconListViewItemBorderStyle +IconListView::GetItemBorderStyle(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->GetItemBorderStyle(); +} + +result +IconListView::SetBitmapOfEmptyList(const Bitmap* pBitmap) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->SetBitmapOfEmptyList(pBitmap); +} + +result +IconListView::BeginReorderingMode(void) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->BeginReorderingMode(); +} + +result +IconListView::EndReorderingMode(void) +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->EndReorderingMode(); +} + +bool +IconListView::IsInReorderingMode(void) const +{ + // Check whether _pControlImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(_pControlImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _IconListViewImpl* pImpl = _IconListViewImpl::GetInstance(*this); + return pImpl->IsInReorderingMode(); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlIconListViewItem.cpp b/src/ui/controls/FUiCtrlIconListViewItem.cpp new file mode 100644 index 0000000..6922f59 --- /dev/null +++ b/src/ui/controls/FUiCtrlIconListViewItem.cpp @@ -0,0 +1,80 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlIconListViewItem.cpp + * @brief This is the implementation file for the IconListViewItem class. + */ + +// Includes +#include +#include + +#include "FUiCtrl_IconListViewItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IconListViewItem::IconListViewItem(void) + : __pImpl(null) +{ + // nothing +} + +IconListViewItem::~IconListViewItem(void) +{ + delete __pImpl; + __pImpl = null; +} + +result +IconListViewItem::Construct(const Bitmap& bitmap, const String* pText, const Bitmap* pSelectedBitmap, + const Bitmap* pHighlightedBitmap) +{ + // Check whether __pImpl has been set, that is, "already constructed" condition. + SysAssertf(__pImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + __pImpl = _IconListViewItemImpl::CreateIconListViewItemImplN(*this, bitmap, pText, pSelectedBitmap, pHighlightedBitmap); + + result r = GetLastResult(); + if (__pImpl == null) + { + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = E_SUCCESS; + } + + return r; +} + +result +IconListViewItem::SetOverlayBitmap(int overlayBitmapId, const Bitmap* pOverlayBitmap, + HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) +{ + // Check whether __pImpl has not been set as a precondition of this method, that is, "not-yet constructed" condition. + SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetOverlayBitmap(overlayBitmapId, pOverlayBitmap, horizontalAlignment, verticalAlignment); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlKeypad.cpp b/src/ui/controls/FUiCtrlKeypad.cpp new file mode 100644 index 0000000..3ea448d --- /dev/null +++ b/src/ui/controls/FUiCtrlKeypad.cpp @@ -0,0 +1,145 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrlKeypad.cpp +* @brief This file contains implementation of Keypad class +* +* This file contains implementation of Keypad class. +*/ + +#include +#include +#include "FUiCtrl_KeypadImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Keypad::Keypad(void) +{ + +} + +Keypad::~Keypad(void) +{ + +} + +result +Keypad::Construct(KeypadStyle keypadStyle, int limitLength) +{ + return Construct(keypadStyle, KEYPAD_MODE_ALPHA, limitLength); +} + +result +Keypad::Construct(KeypadStyle keypadStyle, KeypadInputModeCategory category, int limitLength) +{ + result r = E_SUCCESS; + + _KeypadImpl* pImpl = _KeypadImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + + pImpl = _KeypadImpl::CreateKeypadImplN(this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + r = pImpl->Initialize(keypadStyle, category, limitLength); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete pImpl; + _pControlImpl = null; + + return r; +} + +bool +Keypad::IsTextPredictionEnabled(void) const +{ + const _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this); + SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pKeypadImpl->IsTextPredictionEnabled(); +} + +result +Keypad::SetTextPredictionEnabled(bool enable) +{ + _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this); + SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use."); + + pKeypadImpl->SetTextPredictionEnabled(enable); + + return E_SUCCESS; +} + +result +Keypad::SetSingleLineEnabled(bool enabled) +{ + _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this); + SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use."); + return pKeypadImpl->SetSingleLineEnabled(enabled); +} + +bool +Keypad::IsSingleLineEnabled(void) const +{ + const _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this); + SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use."); + return pKeypadImpl->IsSingleLineEnabled(); +} + +void +Keypad::AddTextEventListener(ITextEventListener& listener) +{ + _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this); + SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use."); + pKeypadImpl->AddTextEventListener(listener); +} + +void +Keypad::RemoveTextEventListener(ITextEventListener& listener) +{ + _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this); + SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use."); + pKeypadImpl->RemoveTextEventListener(listener); +} + +String +Keypad::GetText(void) const +{ + const _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this); + SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use."); + return pKeypadImpl->GetText(); +} + +void +Keypad::SetText(String text) +{ + _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this); + SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use."); + return pKeypadImpl->SetText(text); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlLabel.cpp b/src/ui/controls/FUiCtrlLabel.cpp new file mode 100644 index 0000000..4448c7e --- /dev/null +++ b/src/ui/controls/FUiCtrlLabel.cpp @@ -0,0 +1,259 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrlLabel.cpp +* @brief This is the implementation file for Label class. +*/ + +#include +#include +#include "FUiCtrl_LabelImpl.h" + +#define MINIMUM_VALUE 0 +#define MAXIMUM_VALUE 65535 + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Label::Label(void) +{ + +} + +Label::~Label(void) +{ + +} + +result +Label::Construct(const Rectangle& rect, const String& text) +{ + SysTryReturn(NID_UI_CTRL, (rect.width >= MINIMUM_VALUE && rect.width <= MAXIMUM_VALUE), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The width error occurred"); + + SysTryReturn(NID_UI_CTRL, (rect.height >= MINIMUM_VALUE && rect.height <= MAXIMUM_VALUE), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The height error occurred"); + + result r = E_SUCCESS; + _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + + SysAssertf(pLabelImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pLabelImpl = _LabelImpl::CreateLabelImplN(this, rect); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pLabelImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pLabelImpl->SetText(text); + SysAssert(r == E_SUCCESS); // [ToDo] Exception. Which exception can occur? + + _pControlImpl = pLabelImpl; + + return E_SUCCESS; +} + +void +Label::SetText(const String& text) +{ + _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pLabelImpl->SetText(text); + + return; +} + +String +Label::GetText(void) const +{ + const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pLabelImpl->GetText(); +} + +void +Label::SetBackgroundBitmap(const Bitmap& bitmap) +{ + _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pLabelImpl->SetBackgroundBitmap(bitmap); + + return; +} + +void +Label::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pLabelImpl->SetTextHorizontalAlignment(alignment); + + return; +} + +void +Label::SetTextVerticalAlignment(VerticalAlignment alignment) +{ + _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pLabelImpl->SetTextVerticalAlignment(alignment); + + return; +} + +HorizontalAlignment +Label::GetTextHorizontalAlignment(void) const +{ + const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pLabelImpl->GetTextHorizontalAlignment(); +} + +VerticalAlignment +Label::GetTextVerticalAlignment(void) const +{ + const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pLabelImpl->GetTextVerticalAlignment(); +} + +void +Label::SetBackgroundColor(const Color& color) +{ + _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pLabelImpl->SetBackgroundColor(color); + + return; +} + +Color +Label::GetBackgroundColor(void) const +{ + const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pLabelImpl->GetBackgroundColor(); +} + +void +Label::SetTextColor(const Color& color) +{ + _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pLabelImpl->SetTextColor(color); + + return; +} + +Color +Label::GetTextColor(void) const +{ + const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pLabelImpl->GetTextColor(); +} + +void +Label::SetTextConfig(int size, LabelTextStyle style) +{ + _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pLabelImpl->SetTextConfig(size, style); + + return; +} + +int +Label::GetTextSize(void) const +{ + const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pLabelImpl->GetTextSize(); +} + +LabelTextStyle +Label::GetTextStyle(void) const +{ + const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pLabelImpl->GetTextStyle(); +} + +result +Label::SetMargin(int topMargin, int leftMargin) +{ + _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = pLabelImpl->SetMargin(topMargin, leftMargin); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +Label::GetTopMargin(void) const +{ + const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pLabelImpl->GetTopMargin(); +} + +int +Label::GetLeftMargin(void) const +{ + const _LabelImpl* pLabelImpl = _LabelImpl::GetInstance(*this); + SysAssertf(pLabelImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pLabelImpl->GetLeftMargin(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlList.cpp b/src/ui/controls/FUiCtrlList.cpp new file mode 100644 index 0000000..6f7d863 --- /dev/null +++ b/src/ui/controls/FUiCtrlList.cpp @@ -0,0 +1,655 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlList.cpp + * @brief This is the implementation file for List class. + * + * This file contains the implementation of List class. + */ + +#include +#include +#include "FUiCtrl_ListViewImpl.h" +#include "FUiCtrl_ListImpl.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls +{ + +List::List(void) +{ + +} + +List::~List(void) +{ + +} + +result +List::Construct(const Rectangle& rect, ListStyle style, ListItemFormat itemFormat, int row1Height, int row2Height, int column1Width, int column2Width) +{ + result r = E_SUCCESS; + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + + SysAssertf((pImpl == null), + "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class"); + + SysTryReturn(NID_UI_CTRL, (row1Height > 0 && row2Height >= 0), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] row1Height must be greater than %d and row2Height must be greater than or equal to %d.", 0, 0); + + SysTryReturn(NID_UI_CTRL, (column1Width > 0 && column2Width >= 0), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] column1Width must be greater than %d and column2Width must be greater than or equal to %d.", 0, 0); + + pImpl = _ListImpl::CreateListImplN(this, rect); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + r = pImpl->UpdateBounds(rect); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->SetStyle(style); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] The current value of list style is invalid.", GetErrorMessage(r)); + + r = pImpl->Initialize(itemFormat, row1Height, row2Height, column1Width, column2Width); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->LoadDefaultBitmap(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + ClearLastResult(); + + return r; + +CATCH: + Dispose(); + return r; + +} + +void +List::AddItemEventListener(IItemEventListener& listener) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddItemEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return; +} + +void +List::RemoveItemEventListener(IItemEventListener& listener) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveItemEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return; +} + +result +List::AddItem(const String* pText1, const String* pText2, + const Bitmap* pBitmap1, const Bitmap* pBitmap2, int itemId) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddItem(pText1, pText2, pBitmap1, pBitmap2, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +List::InsertItemAt(int index, const String* pText1, const String* pText2, + const Bitmap* pBitmap1, const Bitmap* pBitmap2, int itemId) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->InsertItemAt(index, pText1, pText2, pBitmap1, pBitmap2, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +List::SetItemAt(int index, const String* pText1, const String* pText2, + const Bitmap* pBitmap1, const Bitmap* pBitmap2, int itemId) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetItemAt(index, pText1, pText2, pBitmap1, pBitmap2, itemId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +List::RemoveItemAt(int index) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveItemAt(index); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +List::RemoveAllItems(void) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveAllItems(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +List::GetItemCount(void) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SetLastResult(E_SUCCESS); + + return pImpl->GetItemCount(); +} + +result +List::SetItemEnabled(int index, bool enable) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetItemEnabled(index, enable); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +bool +List::IsItemEnabled(int index) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SetLastResult(E_SUCCESS); + return pImpl->IsItemEnabled(index); +} + +void +List::SetFocusedItemBackgroundBitmap(const Bitmap& bitmap) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetFocusedItemBackgroundBitmap(bitmap); + SetLastResult(E_SUCCESS); + + return; +} + +void +List::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetHighlightedItemBackgroundBitmap(bitmap); + SetLastResult(E_SUCCESS); + + return; +} + +void +List::SetNormalItemBackgroundBitmap(const Bitmap& bitmap) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetNormalItemBackgroundBitmap(bitmap); + SetLastResult(E_SUCCESS); + + return; +} + +int +List::GetTopDrawnItemIndex(void) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + int groupIndex = -1; + int itemIndex = -1; + + result r = pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return itemIndex; +} + +int +List::GetBottomDrawnItemIndex(void) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + int groupIndex = -1; + int itemIndex = -1; + + result r = pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return itemIndex; +} + +void +List::SetTextOfEmptyList(const String& text) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextOfEmptyList(text); + SetLastResult(E_SUCCESS); + + return; +} + +void +List::SetTextColorOfEmptyList(const Color& color) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextColorOfEmptyList(color); + SetLastResult(E_SUCCESS); + + return; +} + +Color +List::GetTextColorOfEmptyList(void) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetTextColorOfEmptyList(); +} + +void +List::SetBackgroundColor(const Color& color) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetBackgroundColor(color); + SetLastResult(E_SUCCESS); + + return; +} + +void +List::SetItemTextColor(ListItemText textIndex, const Color& textColor) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetItemTextColor(textIndex, textColor); + SetLastResult(E_SUCCESS); + + return; +} + +Color +List::GetItemTextColor(ListItemText textIndex) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetItemTextColor(textIndex); +} + +void +List::EnableTextSlide(ListItemText textIndex) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->EnableTextSlide(textIndex); + SetLastResult(E_SUCCESS); + + return; +} + +void +List::DisableTextSlide(void) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->DisableTextSlide(); + SetLastResult(E_SUCCESS); + + return; +} + +int +List::GetItemHeight(void) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetItemHeight(); +} + +int +List::GetRow1Height(void) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetRow1Height(); +} + +int +List::GetRow2Height(void) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetRow2Height(); +} + +int +List::GetColumn1Width(void) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetColumn1Width(); +} + +int +List::GetColumn2Width(void) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetColumn2Width(); +} + +result +List::SetRow1Height(int row1Height) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI_CTRL, row1Height > 0, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] row1Height must be greater than 0."); + + result r = pImpl->SetRow1Height(row1Height); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +List::SetRow2Height(int row2Height) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI_CTRL, row2Height >= 0, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] row2Height must be greater than or equal to 0."); + + result r = pImpl->SetRow2Height(row2Height); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +List::SetColumn1Width(int column1Width) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI_CTRL, column1Width > 0, + E_SYSTEM, E_SYSTEM, "[E_SYSTEM] column1Width must be greater than 0."); + + result r = pImpl->SetColumn1Width(column1Width); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +List::SetColumn2Width(int column2Width) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + SysTryReturn(NID_UI_CTRL, column2Width >= 0, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] column2Width must be greater than or equal to 0."); + + result r = pImpl->SetColumn2Width(column2Width); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +List::SetItemChecked(int index, bool check) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetItemChecked(index, check); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +bool +List::IsItemChecked(int index) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->IsItemChecked(index); +} + +result +List::SetAllItemsChecked(bool check) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetAllItemsChecked(check); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +List::RemoveAllCheckedItems(void) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveAllCheckedItems(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +List::GetFirstCheckedItemIndex(void) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetFirstCheckedItemIndex(); +} + +int +List::GetLastCheckedItemIndex(void) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetLastCheckedItemIndex(); +} + +int +List::GetNextCheckedItemIndexAfter(int index) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetNextCheckedItemIndexAfter(index); +} + +int +List::GetItemIndexFromItemId(int itemId) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetItemIndexFromItemId(itemId); +} + +int +List::GetItemIndexFromPosition(int x, int y) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + int groupIndex = -1; + int itemIndex = -1; + + result r = pImpl->GetItemIndexFromPosition(Point(x, y), groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return itemIndex; +} + +int +List::GetItemIndexFromPosition(const Point& position) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + int groupIndex = -1; + int itemIndex = -1; + + result r = pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return itemIndex; +} + +int +List::GetItemIdAt(int index) const +{ + const _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SetLastResult(E_SUCCESS); + + return pImpl->GetItemIdAt(index); +} + +void +List::ScrollToBottom(void) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->ScrollToBottom(); + SetLastResult(E_SUCCESS); + + return; +} + +void +List::ScrollToTop(void) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->ScrollToTop(); + SetLastResult(E_SUCCESS); + + return; +} + +result +List::ScrollToTop(int index) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollToTop(index); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +List::RefreshItem(int index) +{ + _ListImpl* pImpl = _ListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RefreshItem(index); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlListContextItem.cpp b/src/ui/controls/FUiCtrlListContextItem.cpp new file mode 100644 index 0000000..7a7ead1 --- /dev/null +++ b/src/ui/controls/FUiCtrlListContextItem.cpp @@ -0,0 +1,114 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlListContextItem.cpp + * @brief This is the implementation file for ListContextItem class. + * + * This file contains the implementation of ListContextItem class. + */ + +#include +#include +#include "FUiCtrl_ListContextItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +ListContextItem::ListContextItem(void) + : __pImpl(null) +{ +} + +ListContextItem::~ListContextItem(void) +{ + delete __pImpl; + __pImpl = null; +} + +result +ListContextItem::Construct(void) +{ + _ListContextItemImpl* pImpl = _ListContextItemImpl::GetInstance(*this); + SysAssertf(pImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _ListContextItemImpl::CreateListContextItemImplN(this); + SysTryReturn(NID_UI_CTRL, pImpl != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pImpl = pImpl; + + return E_SUCCESS; +} + +result +ListContextItem::AddElement(int elementId, const String& text, bool enable) +{ + SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return __pImpl->AddElement(elementId, text, enable); +} + +result +ListContextItem::AddElement(int elementId, const Bitmap& normalBitmap, const Bitmap& pressedBitmap, + const Bitmap* pHighlightedBitmap, bool enable) +{ + SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return __pImpl->AddElement(elementId, normalBitmap, pressedBitmap, pHighlightedBitmap, enable); +} + +result +ListContextItem::AddElement(int elementId, const String& text, const Bitmap& normalBitmap, + const Bitmap& pressedBitmap, const Bitmap* pHighlightedBitmap, bool enable) +{ + SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return __pImpl->AddElement(elementId, text, normalBitmap, pressedBitmap, pHighlightedBitmap, enable); + +} + +result +ListContextItem::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetBackgroundBitmap(pBitmap); + +} + +result +ListContextItem::SetBackgroundColor(const Color& color) +{ + SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return __pImpl->SetBackgroundColor(color); + +} + +Color +ListContextItem::GetBackgroundColor(void) const +{ + SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return __pImpl->GetBackgroundColor(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlListItemBase.cpp b/src/ui/controls/FUiCtrlListItemBase.cpp new file mode 100644 index 0000000..58232eb --- /dev/null +++ b/src/ui/controls/FUiCtrlListItemBase.cpp @@ -0,0 +1,134 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlListItemBase.cpp + * @brief This is the implementation file for ListItemBase class. + * + * This file contains the implementation of ListItemBase class. + */ + +#include +#include +#include "FUiCtrl_ListContextItemImpl.h" +#include "FUiCtrl_ListItemBaseImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +ListItemBase::ListItemBase(void) + : _pImpl(null) +{ +} + +ListItemBase::~ListItemBase(void) +{ + delete _pImpl; + _pImpl = null; +} + +result +ListItemBase::Construct(const Dimension& itemSize, ListAnnexStyle style) +{ + result r = E_SUCCESS; + + _ListItemBaseImpl* pImpl = _ListItemBaseImpl::GetInstance(*this); + SysAssertf(pImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _ListItemBaseImpl::CreateListItemBaseImplN(this, itemSize, style); + SysTryReturn(NID_UI_CTRL, pImpl != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _pImpl = pImpl; + + return r; +} + +result +ListItemBase::SetBackgroundBitmap(ListItemDrawingStatus status, const Bitmap* pBitmap) +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->SetBackgroundBitmap(status, pBitmap); +} + +result +ListItemBase::SetBackgroundColor(ListItemDrawingStatus status, const Color& color) +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->SetBackgroundColor(status, color); +} + +Color +ListItemBase::GetBackgroundColor(ListItemDrawingStatus status) const +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->GetBackgroundColor(status); +} + +result +ListItemBase::SetContextItem(const ListContextItem* pItem) +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->SetContextItem(_ListContextItemImpl::GetInstance(*pItem)); +} + +result +ListItemBase::SetDescriptionText(const String& text) +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->SetDescriptionText(text); +} + +result +ListItemBase::SetDescriptionTextColor(const Color& color) +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->SetDescriptionTextColor(color); +} + +result +ListItemBase::SetProgressValue(int value) +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->SetProgressValue(value); +} + +result +ListItemBase::SetProgressMargins(int leftMargin, int rightMargin) +{ + SysAssertf(_pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return _pImpl->SetProgressMargins(leftMargin, rightMargin); +} + +int +ListItemBase::GetAnnexWidth(ListAnnexStyle style) +{ + return _ListItemBaseImpl::GetAnnexWidth(style); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlListView.cpp b/src/ui/controls/FUiCtrlListView.cpp new file mode 100644 index 0000000..8ca7b8c --- /dev/null +++ b/src/ui/controls/FUiCtrlListView.cpp @@ -0,0 +1,477 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlListView.cpp + * @brief This is the implementation file for ListView class. + * + * This file contains the implementation of ListView class. + */ + +#include +#include +#include "FUiCtrl_ListViewImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +ListView::ListView(void) +{ +} + +ListView::~ListView(void) +{ +} + +result +ListView::Construct(const Rectangle& rect, bool itemDivider, bool fastScroll) +{ + result r = E_SUCCESS; + + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + if (fastScroll == true) + { + pImpl = _ListViewImpl::CreateListViewImplN(this, itemDivider, SCROLL_STYLE_FAST_SCROLL); + } + else + { + pImpl = _ListViewImpl::CreateListViewImplN(this, itemDivider, SCROLL_STYLE_FADE_OUT); + } + SysTryReturn(NID_UI_CTRL, pImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _pControlImpl = pImpl; + r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + Control::Dispose(); + + return r; +} + +result +ListView::Construct(const Rectangle& rect, bool itemDivider, ListScrollStyle scrollStyle) +{ + result r = E_SUCCESS; + + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _ListViewImpl::CreateListViewImplN(this, itemDivider, scrollStyle); + SysTryReturn(NID_UI_CTRL, pImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _pControlImpl = pImpl; + r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + Control::Dispose(); + + return r; +} + +result +ListView::SetItemProvider(IListViewItemProvider& provider) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemProvider(provider); +} + +void +ListView::AddListViewItemEventListener(IListViewItemEventListener& listener) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddListViewItemEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +ListView::RemoveListViewItemEventListener(IListViewItemEventListener& listener) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveListViewItemEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +ListView::AddFastScrollListener(IFastScrollListener& listener) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddFastScrollListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +ListView::RemoveFastScrollListener(IFastScrollListener& listener) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveFastScrollListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +ListView::AddScrollEventListener(IScrollEventListener& listener) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddScrollEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +ListView::RemoveScrollEventListener(IScrollEventListener& listener) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveScrollEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +ListView::AddUiLinkEventListener(IUiLinkEventListener& listener) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddUiLinkEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +ListView::RemoveUiLinkEventListener(IUiLinkEventListener& listener) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveUiLinkEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +result +ListView::SetSweepEnabled(bool enable) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetSweepEnabled(enable); +} + +result +ListView::SetFastScrollIndex(const String& text, bool useSearchIcon) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetFastScrollIndex(text, useSearchIcon); +} + +int +ListView::GetTopDrawnItemIndex(void) const +{ + const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTopDrawnItemIndex(); +} + +int +ListView::GetBottomDrawnItemIndex(void) const +{ + const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBottomDrawnItemIndex(); +} + +result +ListView::ScrollToItem(int index) +{ + return ScrollToItem(index, LIST_SCROLL_ITEM_ALIGNMENT_TOP); +} + +result +ListView::ScrollToItem(int index, ListScrollItemAlignment itemAlignment) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ScrollToItem(index, itemAlignment); +} + +result +ListView::SetItemChecked(int index, bool check) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemChecked(index, check); +} + +bool +ListView::IsItemChecked(int index) const +{ + const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemChecked(index); +} + +result +ListView::SetItemEnabled(int index, bool enable) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemEnabled(index, enable); +} + +bool +ListView::IsItemEnabled(int index) const +{ + const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemEnabled(index); +} + +int +ListView::GetItemCount(void) const +{ + const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemCount(); +} + +result +ListView::ShowItemDescriptionText(int index) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ShowItemDescriptionText(index); +} + +result +ListView::HideItemDescriptionText(int index) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->HideItemDescriptionText(index); +} + +result +ListView::RefreshList(int index, ListRefreshType type) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RefreshList(index, type); +} + +result +ListView::RefreshList(int index, int elementId) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RefreshList(index, elementId); +} + +result +ListView::UpdateList(void) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->UpdateList(); +} + +int +ListView::GetItemIndexFromPosition(int x, int y) const +{ + return GetItemIndexFromPosition(Point(x, y)); +} + +int +ListView::GetItemIndexFromPosition(const Point& position) const +{ + const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(position); +} + +result +ListView::GetItemIndexFromPosition(int x, int y, int& itemIndex, int& elementId) const +{ + return GetItemIndexFromPosition(Point(x, y), itemIndex, elementId); +} + +result +ListView::GetItemIndexFromPosition(const Point& position, int& itemIndex, int& elementId) const +{ + const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(position, itemIndex, elementId); +} + +result +ListView::SetItemDividerColor(const Color& color) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemDividerColor(color); +} + +Color +ListView::GetItemDividerColor(void) const +{ + const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemDividerColor(); +} + +result +ListView::SetBackgroundColor(const Color& color) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetListBackgroundColor(color); + + return E_SUCCESS; +} + +Color +ListView::GetBackgroundColor(void) const +{ + const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBackgroundColor(); +} + +result +ListView::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetBackgroundBitmap(pBitmap); +} + +result +ListView::SetBitmapOfEmptyList(const Bitmap* pBitmap) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetBitmapOfEmptyList(pBitmap); +} + +result +ListView::SetTextOfEmptyList(const String& text) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTextOfEmptyList(text); +} + +String +ListView::GetTextOfEmptyList(void) const +{ + const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextOfEmptyList(); +} + +result +ListView::SetTextColorOfEmptyList(const Color& color) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetTextColorOfEmptyList(color); +} + +Color +ListView::GetTextColorOfEmptyList(void) const +{ + const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextColorOfEmptyList(); +} + +result +ListView::BeginReorderingMode(void) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->BeginReorderingMode(); +} + +result +ListView::EndReorderingMode(void) +{ + _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->EndReorderingMode(); +} + +bool +ListView::IsInReorderingMode(void) const +{ + const _ListViewImpl* pImpl = _ListViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsInReorderingMode(); +} + +}}} // Controls diff --git a/src/ui/controls/FUiCtrlMessageBox.cpp b/src/ui/controls/FUiCtrlMessageBox.cpp new file mode 100644 index 0000000..f43b094 --- /dev/null +++ b/src/ui/controls/FUiCtrlMessageBox.cpp @@ -0,0 +1,182 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlMessageBox.cpp + * @brief This file contains implementation of MessageBox class + */ + +#include +#include +#include "FUiCtrl_MessageBoxImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::App; + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +MessageBox::MessageBox(void) +{ + //empty statement +} + +MessageBox::~MessageBox(void) +{ + //empty statement +} + +result +MessageBox::Construct(const String& title, const String& text, MessageBoxStyle style, unsigned long timeout) +{ + result r = E_SUCCESS; + int maxLength = 0; + + _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this); + SysAssertf(pMessageBoxImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pMessageBoxImpl = _MessageBoxImpl::CreateMessageBoxImplN(this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pMessageBoxImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + maxLength = pMessageBoxImpl->GetMaxTextLength(); + SysTryCatch(NID_UI_CTRL, text.GetLength() <= maxLength, + r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Text length is too long to create MessageBox."); + + //Set _MessageBoxImpl + _pControlImpl = pMessageBoxImpl; + + r = pMessageBoxImpl->Initialize(title, text, style, timeout); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete pMessageBoxImpl; + + _pControlImpl = null; + + return r; +} + +result +MessageBox::ShowAndWait(int& modalResult) +{ + _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this); + SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use."); + + result r = pMessageBoxImpl->ShowAndWait(modalResult); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +String +MessageBox::GetTitleText(void) const +{ + const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this); + SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pMessageBoxImpl->GetTitleText(); +} + +String +MessageBox::GetText(void) const +{ + const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this); + SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pMessageBoxImpl->GetText(); +} + +MessageBoxStyle +MessageBox::GetMessageBoxStyle(void) const +{ + const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this); + SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pMessageBoxImpl->GetMessageBoxStyle(); +} + +unsigned long +MessageBox::GetTimeout(void) const +{ + const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this); + SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pMessageBoxImpl->GetTimeout(); +} + +void +MessageBox::SetColor(const Color& color) +{ + _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this); + SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use."); + + pMessageBoxImpl->SetColor(color); +} + +Color +MessageBox::GetColor(void) const +{ + const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this); + SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pMessageBoxImpl->GetColor(); +} + +void +MessageBox::SetTitleTextColor(const Color& color) +{ + _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this); + SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use."); + + pMessageBoxImpl->SetTitleTextColor(color); +} + +Color +MessageBox::GetTitleTextColor(void) const +{ + const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this); + SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pMessageBoxImpl->GetTitleTextColor(); +} + +void +MessageBox::SetTextColor(const Color& color) +{ + _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this); + SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use."); + + pMessageBoxImpl->SetTextColor(color); +} + +Color +MessageBox::GetTextColor(void) const +{ + const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this); + SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pMessageBoxImpl->GetTextColor(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlOptionMenu.cpp b/src/ui/controls/FUiCtrlOptionMenu.cpp new file mode 100644 index 0000000..70018dc --- /dev/null +++ b/src/ui/controls/FUiCtrlOptionMenu.cpp @@ -0,0 +1,284 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlOptionMenu.cpp + * @brief This is the implementation file for the OptionMenu class. + */ + +#include +#include + +#include "FUiCtrl_OptionMenuImpl.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls +{ + +OptionMenu::OptionMenu(void) +{ +} + +OptionMenu::~OptionMenu(void) +{ +} + +result +OptionMenu::Construct(void) +{ + ClearLastResult(); + SysAssertf((_OptionMenuImpl::GetInstance(*this) == null), + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + // Create _OptionMenuImpl + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::CreateOptionMenuImplN(*this); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pOptionMenuImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Set _OptionMenuImpl + _pControlImpl = pOptionMenuImpl; + + return E_SUCCESS; +} + +void +OptionMenu::AddActionEventListener(IActionEventListener& listener) +{ + ClearLastResult(); + + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pOptionMenuImpl->AddActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +OptionMenu::RemoveActionEventListener(IActionEventListener& listener) +{ + ClearLastResult(); + + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pOptionMenuImpl->RemoveActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +OptionMenu::AddItem(const String& text, int actionId) +{ + ClearLastResult(); + + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pOptionMenuImpl->AddItem(text, actionId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +OptionMenu::InsertItemAt(int mainIndex, const String& text, int actionId) +{ + ClearLastResult(); + + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pOptionMenuImpl->InsertItemAt(mainIndex, text, actionId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +OptionMenu::SetItemAt(int mainIndex, const String& text, int actionId) +{ + ClearLastResult(); + + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pOptionMenuImpl->SetItemAt(mainIndex, text, actionId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +OptionMenu::RemoveItemAt(int mainIndex) +{ + ClearLastResult(); + + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pOptionMenuImpl->RemoveItemAt(mainIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +OptionMenu::GetItemCount(void) const +{ + ClearLastResult(); + + const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + int count = pOptionMenuImpl->GetItemCount(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (count >= 0), -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + return count; +} + +int +OptionMenu::GetItemIndexFromActionId(int actionId) const +{ + ClearLastResult(); + + const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + int index = pOptionMenuImpl->GetItemIndexFromActionId(actionId); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (index >= 0), -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + return index; +} + +int +OptionMenu::GetItemActionIdAt(int mainIndex) const +{ + ClearLastResult(); + + const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + int actionId = pOptionMenuImpl->GetItemActionIdAt(mainIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + return actionId; +} + +result +OptionMenu::AddSubItem(int mainIndex, const String& text, int actionId) +{ + ClearLastResult(); + + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pOptionMenuImpl->AddSubItem(mainIndex, text, actionId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +OptionMenu::InsertSubItemAt(int mainIndex, int subIndex, const String& text, int actionId) +{ + ClearLastResult(); + + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pOptionMenuImpl->InsertSubItemAt(mainIndex, subIndex, text, actionId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +OptionMenu::SetSubItemAt(int mainIndex, int subIndex, const String& text, int actionId) +{ + ClearLastResult(); + + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pOptionMenuImpl->SetSubItemAt(mainIndex, subIndex, text, actionId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +OptionMenu::RemoveSubItemAt(int mainIndex, int subIndex) +{ + ClearLastResult(); + + _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pOptionMenuImpl->RemoveSubItemAt(mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +OptionMenu::GetSubItemCount(int mainIndex) const +{ + ClearLastResult(); + + const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + int count = pOptionMenuImpl->GetSubItemCount(mainIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (count >= 0), -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + return count; +} + +int +OptionMenu::GetSubItemIndexFromActionId(int actionId) const +{ + ClearLastResult(); + + const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + int index = pOptionMenuImpl->GetSubItemIndexFromActionId(actionId); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (index >= 0), -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + return index; +} + +int +OptionMenu::GetSubItemActionIdAt(int mainIndex, int subIndex) const +{ + ClearLastResult(); + + const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this); + SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use."); + + int actionId = pOptionMenuImpl->GetSubItemActionIdAt(mainIndex, subIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + return actionId; +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlOverlayPanel.cpp b/src/ui/controls/FUiCtrlOverlayPanel.cpp new file mode 100644 index 0000000..a83ab7c --- /dev/null +++ b/src/ui/controls/FUiCtrlOverlayPanel.cpp @@ -0,0 +1,134 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrlOverlayPanel.cpp +* @brief This is the implementation file for OverlayPanel class. +* +* This cpp file contains the implementation of OverlayPanel class. @n +*/ +#include +#include +#include "FUiCtrl_OverlayPanelImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +OverlayPanel::OverlayPanel(void) +{ +} + +OverlayPanel::~OverlayPanel(void) +{ +} + +result +OverlayPanel::Construct(const Rectangle& rect) +{ + _OverlayPanelImpl* pOverlayPanelImpl = _OverlayPanelImpl::GetInstance(*this); + SysAssertf(pOverlayPanelImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pOverlayPanelImpl = _OverlayPanelImpl::CreateOverlayPanelImplN(this, rect); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pOverlayPanelImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pOverlayPanelImpl; + + return r; +} + +void +OverlayPanel::SetRendererRotation(OverlayPanel::Rotation rotation) +{ + _OverlayPanelImpl* pOverlayPanelImpl = _OverlayPanelImpl::GetInstance(*this); + SysAssertf(pOverlayPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + pOverlayPanelImpl->SetRendererRotation(rotation); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} + +void +OverlayPanel::SetRendererSize(Dimension& dim) +{ + _OverlayPanelImpl* pOverlayPanelImpl = _OverlayPanelImpl::GetInstance(*this); + SysAssertf(pOverlayPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + pOverlayPanelImpl->SetRendererSize(dim); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} + +void +OverlayPanel::SetRendererAspectRatio(bool fix) +{ + _OverlayPanelImpl* pOverlayPanelImpl = _OverlayPanelImpl::GetInstance(*this); + SysAssertf(pOverlayPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + pOverlayPanelImpl->SetRendererAspectRatio(fix); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} + +result +OverlayPanel::SetInputBuffer(const Dimension& destDim, const ByteBuffer& srcBuffer, const Dimension& srcDim, BufferPixelFormat srcFormat) +{ + _OverlayPanelImpl* pOverlayPanelImpl = _OverlayPanelImpl::GetInstance(*this); + SysAssertf(pOverlayPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pOverlayPanelImpl->SetInputBuffer(destDim, srcBuffer, srcDim, srcFormat); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +OverlayPanel::GetBackgroundBufferInfo(BufferInfo& info) const +{ + const _OverlayPanelImpl* pOverlayPanelImpl = _OverlayPanelImpl::GetInstance(*this); + SysAssertf(pOverlayPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pOverlayPanelImpl->GetBackgroundBufferInfo(info); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +OverlayPanel::GetMaskingColor(void) const +{ + const _OverlayPanelImpl* pOverlayPanelImpl = _OverlayPanelImpl::GetInstance(*this); + SysAssertf(pOverlayPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + Color maskingColor = pOverlayPanelImpl->GetMaskingColor(); + + SetLastResult(E_SUCCESS); + + return maskingColor; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrlOverlayRegion.cpp b/src/ui/controls/FUiCtrlOverlayRegion.cpp new file mode 100644 index 0000000..268ea2f --- /dev/null +++ b/src/ui/controls/FUiCtrlOverlayRegion.cpp @@ -0,0 +1,319 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlOverlayRegion.cpp + * @brief This is the implementation file for OverlayRegion class. + */ + +#include + +#include + +#include "FUi_Control.h" +#include "FUi_ResourceManager.h" +#include "FUi_CoordinateSystemUtils.h" +#include "FUiCtrl_OverlayRegionImpl.h" +#include "FUiCtrl_OverlayAgent.h" + +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EcoreEvas.h" + +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +OverlayRegion::OverlayRegion(void) + : __pOverlayRegionImpl(null) +{ + +} + +OverlayRegion::~OverlayRegion(void) +{ + delete __pOverlayRegionImpl; + __pOverlayRegionImpl = null; +} + +Tizen::Graphics::Rectangle +OverlayRegion::GetBounds(void) const +{ + if (__pOverlayRegionImpl == null) + { + SysAssertf(__pOverlayRegionImpl != null, "Not yet constructed. Construct() should be called before use."); + return Tizen::Graphics::Rectangle(); + } + + return __pOverlayRegionImpl->GetBounds(); +} + +void +OverlayRegion::GetBounds(int& x, int& y, int& width, int& height) const +{ + SysAssertf(__pOverlayRegionImpl != null, "Not yet constructed. Construct() should be called before use."); + + __pOverlayRegionImpl->GetBounds(x, y, width, height); + + return; +} + +result +OverlayRegion::SetInputBuffer(const Tizen::Base::ByteBuffer& srcBuffer, const Tizen::Graphics::Dimension& sourceDim, Tizen::Ui::Controls::OverlayRegionBufferPixelFormat srcFormat) +{ + SysAssertf(__pOverlayRegionImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = __pOverlayRegionImpl->SetInputBuffer(srcBuffer, sourceDim, srcFormat, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +OverlayRegion::GetBackgroundBufferInfo(Tizen::Graphics::BufferInfo& info) const +{ + SysAssertf(__pOverlayRegionImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = __pOverlayRegionImpl->GetBackgroundBufferInfo(info); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +OverlayRegion::Show(void) +{ + SysAssertf(__pOverlayRegionImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = __pOverlayRegionImpl->Show(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +bool +OverlayRegion::EvaluateBounds(OverlayRegionEvaluationOption option, Tizen::Graphics::Rectangle& rect, bool& modified) +{ + modified = false; + + if (rect.width <= 0 || rect.height <= 0) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] input rect size is invalid."); + return false; + } + + Tizen::Graphics::Rectangle physicalRect(_CoordinateSystemUtils::Transform(rect)); + SysLog(NID_UI_CTRL, "org user rect width : %d Height : %d , org physicalRect[%d, %d]!", rect.width, rect.height, physicalRect.width, physicalRect.height); + + int deviceLcdWidth = 0; + int deviceLcdHeight = 0; + + SysTryReturn(NID_UI_CTRL, Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/screen.width", deviceLcdWidth) == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] failed to get the value of ScreenWidth from SystemInfo."); + SysTryReturn(NID_UI_CTRL, Tizen::System::_SystemInfoImpl::GetSysInfo(L"http://tizen.org/feature/screen.height", deviceLcdHeight) == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] failed to get the value of ScreenHeight from SystemInfo."); + + const int widthUnit = GetWidthUnit(); + const int heightUnit = GetHeightUnit(); + + if (widthUnit == -1 || heightUnit == -1) + { + SetLastResult(E_SYSTEM); + return false; + } + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + int rotation = ecore_evas_rotation_get(pEcoreEvas->GetEcoreEvas()); + + if (rotation == 90 || rotation == 270) + { + int temp = deviceLcdWidth; + deviceLcdWidth = deviceLcdHeight; + deviceLcdHeight = temp; + + SysLog(NID_UI_CTRL, "rotate[%d] : deviceLcdWidth[%d], deviceLcdHeight[%d] is swapped", rotation, deviceLcdWidth, deviceLcdHeight); + } + + int maxW = deviceLcdWidth - (deviceLcdWidth % widthUnit); + int maxH = deviceLcdHeight - (deviceLcdHeight % heightUnit); + + int logicalMaxW = _CoordinateSystemUtils::InverseHorizontalTransform(maxW); + int logicalMaxH = _CoordinateSystemUtils::InverseVerticalTransform(maxH); + + SysLog(NID_UI_CTRL, "logicalMax[%d, %d], physicalMax[%d, %d]!", logicalMaxW, logicalMaxH, maxW, maxH); + + int dstMinWidth = _OverlayAgent::GetDstRectMinWidth(); + int dstMinHeight = _OverlayAgent::GetDstRectMinHeight(); + + SysLog(NID_UI_CTRL, "dstMinDimention[%d, %d]", dstMinWidth, dstMinHeight); + + int widthReminder = physicalRect.width % widthUnit; + int heightReminder = physicalRect.height % heightUnit; + + switch (option) + { + case OVERLAY_REGION_EVALUATION_OPTION_GREATER_THAN: + { + if (physicalRect.width > maxW || physicalRect.height > maxH) + { + modified = false; + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_OPTION, "[E_UNSUPPORTED_OPTION] the input rect size is already over physical maximun size."); + return false; + } + + if (rect.width > logicalMaxW || rect.height > logicalMaxH) + { + modified = false; + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_OPTION, "[E_UNSUPPORTED_OPTION] the input rect size is already over logical maximun size."); + return false; + } + + if (widthReminder != 0) + { + widthReminder -= widthUnit; + } + + if (heightReminder != 0) + { + heightReminder -= heightUnit; + } + + physicalRect.width -= widthReminder; + physicalRect.height -= heightReminder; + + if (physicalRect.width < dstMinWidth) + { + physicalRect.width = dstMinWidth; + } + + if (physicalRect.height < dstMinHeight) + { + physicalRect.height = dstMinHeight; + } + } + break; + case OVERLAY_REGION_EVALUATION_OPTION_LESS_THAN: + { + if (physicalRect.width < dstMinWidth || physicalRect.height < dstMinHeight) + { + modified = false; + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_OPTION, "[E_UNSUPPORTED_OPTION] the input rect size doesn't meet the minimun size."); + return false; + } + + if (physicalRect.width > maxW) + { + physicalRect.width = maxW + widthReminder; + SysLog(NID_UI_CTRL, "adjusted width [%d] [%d + %d = %d]!", physicalRect.width, maxW, widthReminder, maxW + widthReminder); + } + + if (physicalRect.height > maxH) + { + physicalRect.height = maxH + heightReminder; + SysLog(NID_UI_CTRL, "adjusted height [%d] [%d + %d = %d]!", physicalRect.height, maxH, heightReminder, maxH+ heightReminder); + } + + physicalRect.width -= widthReminder; + physicalRect.height -= heightReminder; + } + break; + default: + modified = false; + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_OPTION, "[E_UNSUPPORTED_OPTION] option is invalid."); + return false; + } + + Rectangle orgRrect(rect); + + rect = _CoordinateSystemUtils::InverseTransform(physicalRect); + + if (rect != orgRrect) + { + SysLog(NID_UI_CTRL, "org logical rect [%d, %d, %d, %d] changed to rect [%d, %d, %d, %d]", + orgRrect.x, orgRrect.y, orgRrect.width, orgRrect.height, rect.x, rect.y, rect.width, rect.height); + modified = true; + } + + SysLog(NID_UI_CTRL, "adjusted PhysicalRect [W %d, H %d]!", physicalRect.width, physicalRect.height); + + SetLastResult(E_SUCCESS); + return true; +} + +int +OverlayRegion::GetWidthUnit(void) +{ + int widthUnit = _OverlayRegionImpl::GetWidthUnit(); + SysTryReturn(NID_UI_CTRL, widthUnit != -1, -1, E_SYSTEM, "[E_SYSTEM] can't get the width Unit"); + + return widthUnit; +} + +int +OverlayRegion::GetHeightUnit(void) +{ + int heightUnit = _OverlayRegionImpl::GetHeightUnit(); + SysTryReturn(NID_UI_CTRL, heightUnit != -1, -1, E_SYSTEM, "[E_SYSTEM] can't get the height Unit"); + + return heightUnit; +} + +int +OverlayRegion::GetMaxCount(void) +{ + int maxCount = _OverlayRegionImpl::GetMaxCount(); + SysTryReturn(NID_UI_CTRL, maxCount != -1, -1, E_SYSTEM, "[E_SYSTEM] can't get the maximum count value"); + + return maxCount; +} + +IListT< Tizen::Ui::Controls::OverlayRegionBufferPixelFormat >* +OverlayRegion::GetSupportedBufferPixelFormatListN(void) +{ + if (!_OverlayRegionImpl::overlayRegionPixelFomatList[0]) + { + result r = _OverlayRegionImpl::SetPixelFormatList(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + Tizen::Base::Collection::ArrayListT* pFormatList = null; + + pFormatList = new (std::nothrow) ArrayListT(); + SysTryReturn(NID_UI_CTRL, pFormatList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] failed to create a list instance"); + if (pFormatList->Construct() != E_SUCCESS) + { + SysLogException(NID_UI_CTRL, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + delete pFormatList; + return null; + } + + for (int i = 1; i < OVERLAY_REGION_BUFFER_PIXEL_FORMAT_MAX; i++) + { + if (_OverlayRegionImpl::overlayRegionPixelFomatList[i]) + { + pFormatList->Add(static_cast(i)); + } + } + + SysLog(NID_UI_CTRL, "format list count : %d", pFormatList->GetCount()); + + SetLastResult(E_SUCCESS); + return pFormatList; +} + +} } } // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlPanel.cpp b/src/ui/controls/FUiCtrlPanel.cpp new file mode 100644 index 0000000..7c990b8 --- /dev/null +++ b/src/ui/controls/FUiCtrlPanel.cpp @@ -0,0 +1,176 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlPanel.cpp +* @brief This is the implementation file for %Panel class. +* +*/ + +#include +#include +#include +#include +#include "FUi_UiBuilder.h" +#include "FUiCtrl_PanelImpl.h" +#include "FUiCtrl_Panel.h" + +using namespace std; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Panel::Panel(void) +{ + // Nothing +} + + +Panel::~Panel(void) +{ + // Nothing +} + +result +Panel::Construct(const Rectangle& rect, GroupStyle groupStyle) +{ + _PanelImpl* pImpl = _PanelImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _PanelImpl::CreatePanelImplN(this, rect, groupStyle); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , r, "[%s] A specified input parameter is invalid.", GetErrorMessage(r)); + SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , r, "[%s] The memory is insufficient.", GetErrorMessage(r)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM)); + + _pControlImpl = pImpl; + + return r; + +CATCH: + delete pImpl; + + SetLastResult(r); + return r; + +} + +result +Panel::Construct(const Tizen::Base::String& resourceId) +{ + ClearLastResult(); + + // Parse UiBuilder XML file + unique_ptr<_UiBuilder> pBuilder(new _UiBuilder()); + SysTryReturn(NID_UI_CTRL, pBuilder, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + result r = pBuilder->Construct(resourceId, this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = pBuilder->Parse(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +Panel::Construct(const Layout& layout, const Rectangle& rect, GroupStyle groupStyle) +{ + return Construct(layout, layout, rect, groupStyle); +} + +result +Panel::Construct(const Layout& portraitLayout, const Layout& landscapeLayout, const Rectangle& rect, GroupStyle groupStyle) +{ + _PanelImpl* pImpl = _PanelImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _PanelImpl::CreatePanelImplN(this, rect, groupStyle, &(const_cast (portraitLayout)), &(const_cast (landscapeLayout))); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , r, "[%s] A specified input parameter is invalid.", GetErrorMessage(r)); + SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , r, "[%s] The memory is insufficient.", GetErrorMessage(r)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM)); + + _pControlImpl = pImpl; + + return r; + +CATCH: + delete pImpl; + + SetLastResult(r); + return r; +} + +Color +Panel::GetBackgroundColor(void) const +{ + const _PanelImpl* pImpl = _PanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + Color color = pImpl->GetBackgroundColor(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(0, 0, 0, 0), E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM)); + + return color; +} + +void +Panel::SetBackgroundColor(const Color& color) +{ + _PanelImpl* pImpl = _PanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->SetBackgroundColor(color); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM)); +} + +result +Panel::SetCompositeEnabled(bool composite) +{ + _PanelImpl* pImpl = _PanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + result r = pImpl->SetCompositeEnabled(composite); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM)); + + return r; +} + +bool +Panel::IsCompositeEnabled(void) const +{ + const _PanelImpl* pImpl = _PanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + return pImpl->IsCompositeEnabled(); +} + +DataBindingContext* +Panel::GetDataBindingContextN(void) const +{ + const _PanelImpl* pImpl = _PanelImpl::GetInstance(*this); + if (pImpl == null) + { + return null; + } + return pImpl->GetDataBindingContextN(); +} + + +}}} //Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrlPopup.cpp b/src/ui/controls/FUiCtrlPopup.cpp new file mode 100644 index 0000000..08d3fcc --- /dev/null +++ b/src/ui/controls/FUiCtrlPopup.cpp @@ -0,0 +1,246 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlPopup.cpp + * @brief This is the implementation file for Popup class. + */ + +#include +#include +#include +#include "FUi_UiBuilder.h" +#include "FUiCtrl_PopupImpl.h" + +using namespace std; + +namespace Tizen { namespace Ui { namespace Controls +{ + + +Popup::Popup(void) +{ + //empty statement +} + +Popup::~Popup(void) +{ + //empty statement +} + +result +Popup::Construct(bool hasTitle, const Tizen::Graphics::Dimension& dim) +{ + result r = E_SUCCESS; + + _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pPopupImpl = _PopupImpl::CreatePopupImplN(this, dim); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pPopupImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Set _PopupImpl + _pControlImpl = pPopupImpl; + + r = pPopupImpl->Initialize(hasTitle, dim); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete pPopupImpl; + + _pControlImpl = null; + + return r; +} + +result +Popup::Construct(const Tizen::Base::String& resourceId) +{ + ClearLastResult(); + + // Parse UiBuilder XML file + unique_ptr<_UiBuilder> pBuilder(new _UiBuilder()); + SysTryReturn(NID_UI_CTRL, pBuilder, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + result r = pBuilder->Construct(resourceId, this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = pBuilder->Parse(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +Popup::Construct(const Tizen::Ui::Layout& layout, bool hasTitle, const Tizen::Graphics::Dimension& dim) +{ + return Construct(layout, layout, hasTitle, dim); +} + +result +Popup::Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, + bool hasTitle, const Tizen::Graphics::Dimension& dim) +{ + result r = E_SUCCESS; + + _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pPopupImpl = _PopupImpl::CreatePopupImplN(this, dim, + &(const_cast (portraitLayout)), + &(const_cast (landscapeLayout))); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pPopupImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Set _PopupImpl + _pControlImpl = pPopupImpl; + + r = pPopupImpl->Initialize(hasTitle, dim); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete pPopupImpl; + + return r; +} + +result +Popup::DoModal(int& modalResult) +{ + _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pPopupImpl->DoModal(modalResult); +} + +result +Popup::EndModal(int modalResult) +{ + _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pPopupImpl->EndModal(modalResult); +} + +Tizen::Graphics::Rectangle +Popup::GetClientAreaBounds(void) const +{ + const _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pPopupImpl->GetClientAreaBounds(); +} + +Tizen::Graphics::Canvas* +Popup::GetClientAreaCanvasN(void) const +{ + const _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pPopupImpl->GetClientAreaCanvasN(); +} + +Tizen::Graphics::Point +Popup::TranslateToClientAreaPosition(const Tizen::Graphics::Point& position) const +{ + const _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pPopupImpl->TranslateToClientAreaPosition(position); +} + +Tizen::Graphics::Point +Popup::TranslateFromClientAreaPosition(const Tizen::Graphics::Point& clientPosition) const +{ + const _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pPopupImpl->TranslateFromClientAreaPosition(clientPosition); +} + +Tizen::Graphics::Color +Popup::GetColor(void) const +{ + const _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pPopupImpl->GetColor(); +} + +result +Popup::SetColor(const Tizen::Graphics::Color& color) +{ + _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pPopupImpl->SetColor(color); +} + +Tizen::Base::String +Popup::GetTitleText(void) const +{ + const _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pPopupImpl->GetTitleText(); +} + +result +Popup::SetTitleText(const Tizen::Base::String& title) +{ + _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + result r = pPopupImpl->SetTitleText(title); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[E_SYSTEM] A system error occurred."); + + return E_SUCCESS; +} + +Tizen::Graphics::Color +Popup::GetTitleTextColor(void) const +{ + const _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pPopupImpl->GetTitleTextColor(); +} + +result +Popup::SetTitleTextColor(const Tizen::Graphics::Color& color) +{ + _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pPopupImpl->SetTitleTextColor(color); +} + +DataBindingContext* +Popup::GetDataBindingContextN(void) const +{ + const _PopupImpl* pPopupImpl = _PopupImpl::GetInstance(*this); + SysAssertf(pPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pPopupImpl->GetDataBindingContextN(); +} + + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlProgress.cpp b/src/ui/controls/FUiCtrlProgress.cpp new file mode 100644 index 0000000..97bf337 --- /dev/null +++ b/src/ui/controls/FUiCtrlProgress.cpp @@ -0,0 +1,139 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlProgress.cpp + * @brief This is the implementation file for Progress class. + */ + +#include +#include +#include "FUiCtrl_ProgressImpl.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Progress::Progress(void) +{ +} + +Progress::~Progress(void) +{ +} + +result +Progress::Construct(const Rectangle& rect, int minValue, int maxValue) +{ + result r = E_SUCCESS; + + _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this); + SysAssertf((pProgressImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + pProgressImpl = _ProgressImpl::CreateProgressImplN(this, rect); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pProgressImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pProgressImpl; + + r = pProgressImpl->SetRange(minValue, maxValue); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pProgressImpl->SetValue(minValue); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + delete pProgressImpl; + pProgressImpl = null; + + _pControlImpl = null; + + return r; +} + +void +Progress::SetValue(int value) +{ + _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this); + SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pProgressImpl->SetValue(value); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +result +Progress::SetRange(int minValue, int maxValue) +{ + _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this); + SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pProgressImpl->SetRange(minValue, maxValue); +} + +int +Progress::GetValue(void) const +{ + const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this); + SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pProgressImpl->GetValue(); +} + +void +Progress::GetRange(int& minValue, int& maxValue) const +{ + const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this); + SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pProgressImpl->GetRange(minValue, maxValue); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +int +Progress::GetPercentComplete(void) const +{ + const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this); + SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pProgressImpl->GetPercentComplete(); +} + +result +Progress::SetBarColor(const Color& color) +{ + _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this); + SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pProgressImpl->SetBarColor(color); +} + +Color +Progress::GetBarColor(void) const +{ + const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this); + SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pProgressImpl->GetBarColor(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlProgressPopup.cpp b/src/ui/controls/FUiCtrlProgressPopup.cpp new file mode 100644 index 0000000..29097f2 --- /dev/null +++ b/src/ui/controls/FUiCtrlProgressPopup.cpp @@ -0,0 +1,140 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlProgressPopup.cpp + * @brief This file contains implementation of ProgressPopup class + */ + +#include +#include +#include "FUiCtrl_ProgressPopupImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::App; + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +ProgressPopup::ProgressPopup(void) +{ + //empty statement +} + +ProgressPopup::~ProgressPopup(void) +{ + //empty statement +} + +result +ProgressPopup::Construct(bool cancelButton, bool translucent) +{ + result r = E_SUCCESS; + + _ProgressPopupImpl* pProgressPopupImpl = _ProgressPopupImpl::GetInstance(*this); + SysAssertf(pProgressPopupImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pProgressPopupImpl = _ProgressPopupImpl::CreateProgressPopupImplN(this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pProgressPopupImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + //Set _ProgressPopupImpl + _pControlImpl = pProgressPopupImpl; + + r = pProgressPopupImpl->Initialize(cancelButton, translucent); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete pProgressPopupImpl; + + _pControlImpl = null; + + return r; +} + +result +ProgressPopup::AddProgressPopupEventListener(Tizen::Ui::IProgressPopupEventListener& listener) +{ + _ProgressPopupImpl* pProgressPopupImpl = _ProgressPopupImpl::GetInstance(*this); + SysAssertf(pProgressPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + result r = pProgressPopupImpl->AddProgressPopupEventListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ProgressPopup::RemoveProgressPopupEventListener(Tizen::Ui::IProgressPopupEventListener& listener) +{ + _ProgressPopupImpl* pProgressPopupImpl = _ProgressPopupImpl::GetInstance(*this); + SysAssertf(pProgressPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + result r = pProgressPopupImpl->RemoveProgressPopupEventListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ProgressPopup::SetText(const String& text) +{ + _ProgressPopupImpl* pProgressPopupImpl = _ProgressPopupImpl::GetInstance(*this); + SysAssertf(pProgressPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + result r = pProgressPopupImpl->SetText(text); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +String +ProgressPopup::GetText(void) const +{ + const _ProgressPopupImpl* pProgressPopupImpl = _ProgressPopupImpl::GetInstance(*this); + SysAssertf(pProgressPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pProgressPopupImpl->GetText(); +} + +void +ProgressPopup::SetTextColor(const Color& color) +{ + _ProgressPopupImpl* pProgressPopupImpl = _ProgressPopupImpl::GetInstance(*this); + SysAssertf(pProgressPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + pProgressPopupImpl->SetTextColor(color); +} + +Color +ProgressPopup::GetTextColor(void) const +{ + const _ProgressPopupImpl* pProgressPopupImpl = _ProgressPopupImpl::GetInstance(*this); + SysAssertf(pProgressPopupImpl != null, "Not-yet constructed. Construct() should be called before use."); + + return pProgressPopupImpl->GetTextColor(); +} + + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrlRadioGroup.cpp b/src/ui/controls/FUiCtrlRadioGroup.cpp new file mode 100644 index 0000000..7ef84fe --- /dev/null +++ b/src/ui/controls/FUiCtrlRadioGroup.cpp @@ -0,0 +1,134 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrlRadioGroup.cpp +* @brief This file contains implementation of RadioGroup class +*/ + +#include +#include +#include "FUiCtrl_RadioGroupImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +RadioGroup::RadioGroup(void) +{ + +} + +RadioGroup::~RadioGroup(void) +{ + +} + +result +RadioGroup::Construct(void) +{ + result r = E_SUCCESS; + _RadioGroupImpl* pRadioGroupImpl = _RadioGroupImpl::GetInstance(*this); + + SysAssertf(pRadioGroupImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pRadioGroupImpl = _RadioGroupImpl::CreateRadioGroupImplN(this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pRadioGroupImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pRadioGroupImpl; + + return E_SUCCESS; +} + +result +RadioGroup::Add(const CheckButton& checkButton) +{ + _RadioGroupImpl* pRadioGroupImpl = _RadioGroupImpl::GetInstance(*this); + SysTryReturn(NID_UI_CTRL, pRadioGroupImpl, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + result r = pRadioGroupImpl->Add(checkButton); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +RadioGroup::Remove(const CheckButton& checkButton) +{ + _RadioGroupImpl* pRadioGroupImpl = _RadioGroupImpl::GetInstance(*this); + SysTryReturn(NID_UI_CTRL, pRadioGroupImpl, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.\n"); + + result r = pRadioGroupImpl->Remove(checkButton); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +int +RadioGroup::GetItemCount(void) const +{ + const _RadioGroupImpl* pRadioGroupImpl = _RadioGroupImpl::GetInstance(*this); + SysAssertf(pRadioGroupImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pRadioGroupImpl->GetItemCount(); +} + +void +RadioGroup::SetSelectedItem(const CheckButton& checkButton) +{ + _RadioGroupImpl* pRadioGroupImpl = _RadioGroupImpl::GetInstance(*this); + SysAssertf(pRadioGroupImpl != null, + "Not yet constructed. Construct() should be called before use."); + + pRadioGroupImpl->SetSelectedItem(checkButton); + + return; +} + +const CheckButton* +RadioGroup::GetSelectedItem(void) const +{ + const _RadioGroupImpl* pRadioGroupImpl = _RadioGroupImpl::GetInstance(*this); + SysAssertf(pRadioGroupImpl != null, + "Not yet constructed. Construct() should be called before use."); + + return pRadioGroupImpl->GetSelectedItem(); +} + +result +RadioGroup::Draw(void) +{ + return E_UNSUPPORTED_OPERATION; +} + +result +RadioGroup::Show(void) +{ + return E_UNSUPPORTED_OPERATION; +} + +result +RadioGroup::SetFocus(void) +{ + return E_UNSUPPORTED_OPERATION; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlScrollPanel.cpp b/src/ui/controls/FUiCtrlScrollPanel.cpp new file mode 100644 index 0000000..b1b7550 --- /dev/null +++ b/src/ui/controls/FUiCtrlScrollPanel.cpp @@ -0,0 +1,327 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlScrollPanel.cpp +* @brief This is the implementation for the %ScrollPanel class. + * + */ + +#include +#include +#include +#include "FUi_UiBuilder.h" +#include "FUiCtrl_ScrollPanelImpl.h" + +using namespace std; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +ScrollPanel::ScrollPanel(void) +{ + // Nothing +} + + +ScrollPanel::~ScrollPanel(void) +{ + // Nothing +} + +result +ScrollPanel::Construct(const Rectangle& rect) +{ + result r = Construct(rect, SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, true); + + return r; +} + +result +ScrollPanel::Construct(const Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable) +{ + _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _ScrollPanelImpl::CreateScrollPanelImplN(this, rect, scrollDirection, autoResizingEnable); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , r, "[%s] The given width or height is less than 0.", GetErrorMessage(r)); + SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , r, "[%s] The memory is insufficient.", GetErrorMessage(r)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM)); + + _pControlImpl = pImpl; + + return r; + +CATCH: + delete pImpl; + + SetLastResult(r); + return r; +} + +result +ScrollPanel::Construct(const Tizen::Base::String& resourceId) +{ + ClearLastResult(); + + // Parse UiBuilder XML file + unique_ptr<_UiBuilder> pBuilder(new _UiBuilder()); + SysTryReturn(NID_UI_CTRL, pBuilder, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + result r = pBuilder->Construct(resourceId, this); + SysTryReturn(NID_UI_CTRL, r != E_OUT_OF_MEMORY, r, r, "[%s] The memory is insufficient.", GetErrorMessage(r)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = pBuilder->Parse(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +ScrollPanel::Construct(const Layout& layout, const Rectangle& rect) +{ + result r = Construct(layout, layout, rect, SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, true); + + return r; +} + +result +ScrollPanel::Construct(const Layout& layout, const Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable) +{ + result r = Construct(layout, layout, rect, scrollDirection, autoResizingEnable); + + return r; +} + +result +ScrollPanel::Construct(const Layout& portraitLayout, const Layout& landscapeLayout, const Rectangle& rect) +{ + result r = Construct(portraitLayout, landscapeLayout, rect, SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, true); + + return r; +} + +result +ScrollPanel::Construct(const Layout& portraitLayout, const Layout& landscapeLayout, const Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable) +{ + _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _ScrollPanelImpl::CreateScrollPanelImplN(this, rect, scrollDirection, autoResizingEnable, &(const_cast (portraitLayout)), &(const_cast (landscapeLayout))); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , r, "[%s] portraitLayout or landscapeLayout is already bound to another container, or the given width or height is less than 0.", GetErrorMessage(r)); + SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , r, "[%s] The memory is insufficient.", GetErrorMessage(r)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM)); + + _pControlImpl = pImpl; + + return r; + +CATCH: + delete pImpl; + + SetLastResult(r); + return r; +} + +void +ScrollPanel::AddScrollEventListener(IScrollEventListener& listener) +{ + _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->AddScrollEventListener(listener); +} + +void +ScrollPanel::RemoveScrollEventListener(IScrollEventListener& listener) +{ + _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->RemoveScrollEventListener(listener); +} + +int +ScrollPanel::GetScrollPosition(void) const +{ + const _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + return pImpl->GetScrollPosition(); +} + +void +ScrollPanel::SetScrollPosition(int position) +{ + _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->SetScrollPosition(position, false); +} + +void +ScrollPanel::SetScrollPosition(int position, bool withAnimation) +{ + _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->SetScrollPosition(position, withAnimation); +} + +void +ScrollPanel::ScrollToBottom(void) const +{ + const _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->ScrollToBottom(); +} + +void +ScrollPanel::ScrollToTop(void) const +{ + const _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->ScrollToTop(); +} + +result +ScrollPanel::CloseOverlayWindow(void) +{ + _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + result r = pImpl->CloseOverlayWindow(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM)); + + return r; +} + +Rectangle +ScrollPanel::GetClientAreaBounds(void) const +{ + const _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + return pImpl->GetClientAreaBounds(); +} + +result +ScrollPanel::SetClientAreaWidth(int width) +{ + _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + result r = pImpl->SetClientAreaWidth(width); + SysTryReturn(NID_UI_CTRL, r != E_INVALID_ARG, r, r, "[%s] width is less than the width of ScrollPanel.", GetErrorMessage(r)); + SysTryReturn(NID_UI_CTRL, r != E_INVALID_OPERATION, r, r, "[%s] The width of the client area cannot be set when auto resizing of the client area is off, or the scroll direction is vertical.", GetErrorMessage(r)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM)); + + return r; +} + +result +ScrollPanel::SetClientAreaHeight(int height) +{ + _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + result r = pImpl->SetClientAreaHeight(height); + SysTryReturn(NID_UI_CTRL, r != E_INVALID_ARG, r, r, "[%s] height is less than the height of ScrollPanel.", GetErrorMessage(r)); + SysTryReturn(NID_UI_CTRL, r != E_INVALID_OPERATION, r, r, "[%s] The height of the client area cannot be set when auto resizing of the client area is off, or the scroll direction is horizontal.", GetErrorMessage(r)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has occurred.", GetErrorMessage(E_SYSTEM)); + + return r; +} + +ScrollPanelScrollDirection +ScrollPanel::GetScrollDirection(void) const +{ + const _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + return pImpl->GetScrollDirection(); +} + +bool +ScrollPanel::IsScrollAreaAutoResizingEnabled(void) const +{ + const _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + return pImpl->IsScrollAreaAutoResizingEnabled(); +} + +void +ScrollPanel::SetPageScrollEnabled(bool enable) +{ + _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->SetPageScrollEnabled(enable); +} + +bool +ScrollPanel::IsPageScrollEnabled(void) const +{ + const _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + return pImpl->IsPageScrollEnabled(); +} + +void +ScrollPanel::SetScrollBarVisible(bool visible) +{ + _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->SetScrollBarVisible(visible); +} + +bool +ScrollPanel::IsScrollBarVisible(void) const +{ + const _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + return pImpl->IsScrollBarVisible(); +} + +void +ScrollPanel::SetScrollInputMode(ScrollInputMode mode) +{ + _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->SetScrollInputMode(mode); +} + +ScrollInputMode +ScrollPanel::GetScrollInputMode(void) const +{ + const _ScrollPanelImpl* pImpl = _ScrollPanelImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + return pImpl->GetScrollInputMode(); +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrlSearchBar.cpp b/src/ui/controls/FUiCtrlSearchBar.cpp new file mode 100644 index 0000000..0cae3a2 --- /dev/null +++ b/src/ui/controls/FUiCtrlSearchBar.cpp @@ -0,0 +1,755 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlSearchBar.cpp +* @brief This is the implementation file for SearchBar class. +*/ + +#include +#include +#include +#include "FUiCtrl_SearchBarImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls { + +SearchBar::SearchBar(void) +{ +} + +SearchBar::~SearchBar(void) +{ +} + +result +SearchBar::Construct(const Rectangle& rect, bool searchBarButton, KeypadAction keypadAction) +{ + result r = E_SUCCESS; + + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pSearchBarImpl = _SearchBarImpl::CreateSearchBarImplN(this, rect, searchBarButton, keypadAction); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pSearchBarImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pSearchBarImpl; + + return r; +} + +Control* +SearchBar::GetContent(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetContent(); +} + +result +SearchBar::SetContent(const Control* pContent) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetContent(pContent); +} + +result +SearchBar::UpdateContentArea(bool invalidate) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->UpdateContentArea(invalidate); +} + +result +SearchBar::SetContentAreaVisible(bool visible) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetContentAreaVisible(visible); +} + +bool +SearchBar::IsContentAreaVisible(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->IsContentAreaVisible(); +} + +result +SearchBar::SetContentAreaSize(const Dimension& size) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetContentAreaSize(size); +} + +Dimension +SearchBar::GetContentAreaSize(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetContentAreaSize(); +} + +SearchBarMode +SearchBar::GetMode(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetMode(); +} + +bool +SearchBar::IsModeLocked(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->IsModeLocked(); +} + +result +SearchBar::SetMode(SearchBarMode mode) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetMode(mode); +} + +result +SearchBar::SetModeLocked(bool modeLocked) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetModeLocked(modeLocked); +} + +int +SearchBar::GetButtonActionId(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetButtonActionId(); +} + +Color +SearchBar::GetButtonColor(SearchBarButtonStatus status) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetButtonColor(status); +} + +Color +SearchBar::GetButtonTextColor(SearchBarButtonStatus status) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetButtonTextColor(status); +} + +SearchBarButtonStatus +SearchBar::GetButtonStatus(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetButtonStatus(); +} + +result +SearchBar::SetButton(const String& text, int actionId) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetButton(text, actionId); +} + +result +SearchBar::SetButtonEnabled(bool enabled) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetButtonEnabled(enabled); +} + +result +SearchBar::SetButtonColor(SearchBarButtonStatus status, const Color& color) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetButtonColor(status, color); +} + +result +SearchBar::SetButtonTextColor(SearchBarButtonStatus status, const Color& color) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetButtonTextColor(status, color); +} + +result +SearchBar::AppendCharacter(const Character& character) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->AppendCharacter(character); +} + +result +SearchBar::AppendText(const String& text) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->AppendText(text); +} + +result +SearchBar::SetText(const String& text) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetText(text); +} + +result +SearchBar::InsertCharacterAt(int index, const Character& character) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->InsertCharacterAt(index, character); +} + +result +SearchBar::InsertTextAt(int index, const String& text) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->InsertTextAt(index, text); +} + +result +SearchBar::DeleteCharacterAt(int index) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->DeleteCharacterAt(index); +} + +result +SearchBar::Clear(void) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->Clear(); +} + +int +SearchBar::GetTextLength(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetTextLength(); +} + +String +SearchBar::GetText(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetText(); +} + +String +SearchBar::GetText(int start, int end) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetText(start, end); +} + +int +SearchBar::GetLimitLength(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetLimitLength(); +} + +result +SearchBar::SetLimitLength(int limitLength) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetLimitLength(limitLength); +} + +result +SearchBar::ShowKeypad(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->ShowKeypad(); +} + +result +SearchBar::HideKeypad(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->HideKeypad(); +} + +int +SearchBar::GetSearchFieldTextSize(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetSearchFieldTextSize(); +} + +result +SearchBar::SetSearchFieldTextSize(int size) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetSearchFieldTextSize(size); +} + +result +SearchBar::GetBlockRange(int& start, int& end) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetBlockRange(start, end); +} + +result +SearchBar::ReleaseBlock(void) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->ReleaseBlock(); +} + +result +SearchBar::SetBlockRange(int start, int end) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetBlockRange(start, end); +} + +result +SearchBar::RemoveTextBlock(void) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->RemoveTextBlock(); +} + +Color +SearchBar::GetColor(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetColor(); +} + +Color +SearchBar::GetSearchFieldColor(SearchFieldStatus status) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetSearchFieldColor(status); +} + +Color +SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetSearchFieldTextColor(status); +} + +result +SearchBar::SetBackgroundBitmap(const Bitmap& bitmap) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetBackgroundBitmap(bitmap); +} + +result +SearchBar::SetColor(const Color& color) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetColor(color); +} + +result +SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetSearchFieldColor(status, color); +} + +result +SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetSearchFieldTextColor(status, color); +} + +String +SearchBar::GetGuideText(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetGuideText(); +} + +result +SearchBar::SetGuideText(const String& guideText) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetGuideText(guideText); +} + +Color +SearchBar::GetGuideTextColor(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetGuideTextColor(); +} + +result +SearchBar::SetGuideTextColor(const Color& color) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetGuideTextColor(color); +} + +int +SearchBar::GetCursorPosition(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetCursorPosition(); +} + +result +SearchBar::SetCursorPosition(int index) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetCursorPosition(index); +} + +bool +SearchBar::IsLowerCaseModeEnabled(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->IsLowerCaseModeEnabled(); +} + +void +SearchBar::SetLowerCaseModeEnabled(bool enable) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + pSearchBarImpl->SetLowerCaseModeEnabled(enable); + + return; +} + +EllipsisPosition +SearchBar::GetEllipsisPosition(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetEllipsisPosition(); +} + +result +SearchBar::SetEllipsisPosition(EllipsisPosition position) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetEllipsisPosition(position); +} + +KeypadAction +SearchBar::GetKeypadAction(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetKeypadAction(); +} + +bool +SearchBar::IsTextPredictionEnabled(void) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->IsTextPredictionEnabled(); +} + +result +SearchBar::SetTextPredictionEnabled(bool enable) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetTextPredictionEnabled(enable); +} + +result +SearchBar::SetCurrentLanguage(LanguageCode languageCode) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->SetCurrentLanguage(languageCode); +} + +result +SearchBar::GetCurrentLanguage(LanguageCode& language) const +{ + const _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSearchBarImpl->GetCurrentLanguage(language); +} + +void +SearchBar::AddActionEventListener(IActionEventListener& listener) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + result r = pSearchBarImpl->AddActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +SearchBar::RemoveActionEventListener(IActionEventListener& listener) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + result r = pSearchBarImpl->RemoveActionEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +SearchBar::AddTextEventListener(ITextEventListener& listener) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + result r = pSearchBarImpl->AddTextEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +SearchBar::RemoveTextEventListener(ITextEventListener& listener) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + result r = pSearchBarImpl->RemoveTextEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +SearchBar::AddSearchBarEventListener(ISearchBarEventListener& listener) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + result r = pSearchBarImpl->AddSearchBarEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +SearchBar::RemoveSearchBarEventListener(ISearchBarEventListener& listener) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + result r = pSearchBarImpl->RemoveSearchBarEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +SearchBar::AddTextBlockEventListener(ITextBlockEventListener& listener) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + result r = pSearchBarImpl->AddTextBlockEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +SearchBar::RemoveTextBlockEventListener(ITextBlockEventListener& listener) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + result r = pSearchBarImpl->RemoveTextBlockEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +SearchBar::AddKeypadEventListener(IKeypadEventListener& listener) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + result r = pSearchBarImpl->AddKeypadEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +SearchBar::RemoveKeypadEventListener(IKeypadEventListener& listener) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl, "Not yet constructed. Construct() should be called before use."); + + result r = pSearchBarImpl->RemoveKeypadEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +SearchBar::AddLanguageEventListener(ILanguageEventListener& listener) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSearchBarImpl->AddLanguageEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +SearchBar::RemoveLanguageEventListener(ILanguageEventListener& listener) +{ + _SearchBarImpl* pSearchBarImpl = _SearchBarImpl::GetInstance(*this); + SysAssertf(pSearchBarImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSearchBarImpl->RemoveLanguageEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlSectionTableView.cpp b/src/ui/controls/FUiCtrlSectionTableView.cpp new file mode 100644 index 0000000..2dda27b --- /dev/null +++ b/src/ui/controls/FUiCtrlSectionTableView.cpp @@ -0,0 +1,392 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlSectionTableView.cpp +* @brief This is the implementation file for SectionTableView class. +* +* This header file contains the implementation of SectionTableView class. +*/ + +#include +#include +#include +#include +#include "FUiCtrl_TableViewImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +//////////////////////////////////////////////////////////////////////////////// +/// SectionTableView class + +SectionTableView::SectionTableView(void) +{ +} + +SectionTableView::~SectionTableView(void) +{ +} + +result +SectionTableView::Construct(const Tizen::Graphics::Rectangle& rect, bool itemDivider, TableViewScrollBarStyle scrollStyle) +{ + result r = E_SUCCESS; + + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _TableViewImpl::CreateTableViewImplN(this, rect, TABLE_VIEW_STYLE_SECTION, itemDivider, scrollStyle); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + r = SetBounds(rect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + Control::Dispose(); + + return r; +} + +void +SectionTableView::SetItemProvider(ISectionTableViewItemProvider* pProvider) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetSectionStyleItemProvider(pProvider); +} + + +result +SectionTableView::AddSectionTableViewItemEventListener(ISectionTableViewItemEventListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddSectionTableViewItemEventListener(listener); +} + +result +SectionTableView::RemoveSectionTableViewItemEventListener(ISectionTableViewItemEventListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveSectionTableViewItemEventListener(listener); +} + +result +SectionTableView::AddFastScrollListener(IFastScrollListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddFastScrollListener(listener); +} + +result +SectionTableView::RemoveFastScrollListener(IFastScrollListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveFastScrollListener(listener); +} + +result +SectionTableView::AddScrollEventListener(IScrollEventListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddScrollEventListener(listener); +} + +result +SectionTableView::RemoveScrollEventListener(IScrollEventListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveScrollEventListener(listener); +} + +result +SectionTableView::SetFastScrollIndex(const String& text, bool useSearchIcon) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetFastScrollIndex(text, useSearchIcon); +} + +result +SectionTableView::GetTopDrawnItemIndex(int& sectionIndex, int& itemIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTopDrawnItemIndex(sectionIndex, itemIndex); +} + +result +SectionTableView::GetBottomDrawnItemIndex(int& sectionIndex, int& itemIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + + return pImpl->GetBottomDrawnItemIndex(sectionIndex, itemIndex); +} + +result +SectionTableView::SetItemChecked(int sectionIndex, int itemIndex, bool check) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemChecked(sectionIndex, itemIndex, check); +} + +bool +SectionTableView::IsItemChecked(int sectionIndex, int itemIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemChecked(sectionIndex, itemIndex); +} + +result +SectionTableView::SetItemEnabled(int sectionIndex, int itemIndex, bool enable) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemEnabled(sectionIndex, itemIndex, enable); +} + +bool +SectionTableView::IsItemEnabled(int sectionIndex, int itemIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemEnabled(sectionIndex, itemIndex); +} + +int +SectionTableView::GetSectionCount(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetGroupCount(); +} + +int +SectionTableView::GetItemCountAt(int sectionIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemCountAt(sectionIndex); +} + +result +SectionTableView::RefreshItem(int sectionIndex, int itemIndex, TableViewRefreshType type) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RefreshTableView(sectionIndex, itemIndex, type); +} + +void +SectionTableView::UpdateTableView(void) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->UpdateTableView(); +} + +result +SectionTableView::GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& sectionIndex, int& itemIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(position, sectionIndex, itemIndex); +} + +void +SectionTableView::SetSectionColor(const Color& color) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetSectionColor(color); +} + +Color +SectionTableView::GetSectionColor(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSectionColor(); +} + +void +SectionTableView::SetItemDividerColor(const Color& color) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetItemDividerColor(color); +} + +Color +SectionTableView::GetItemDividerColor(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemDividerColor(); +} + +void +SectionTableView::SetBackgroundColor(const Color& color) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetBackgroundColor(color); + + return; +} + +Color +SectionTableView::GetBackgroundColor(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBackgroundColor(); +} + +void +SectionTableView::SetGroupedLookEnabled(bool enable) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetGroupedLookEnabled(enable); +} + +bool +SectionTableView::IsGroupedLookEnabled(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsGroupedLookEnabled(); +} + +result +SectionTableView::ScrollToItem(int sectionIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollToItem(sectionIndex, itemIndex, itemAlignment); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +SectionTableView::ScrollByPixel(int scrollDistance) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollByPixel(scrollDistance); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +SectionTableView::GetCurrentScrollPosition(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetCurrentScrollPosition(); +} + +void +SectionTableView::SetScrollEnabled(bool enable) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetScrollEnabled(enable); + + return; +} + +bool +SectionTableView::IsScrollEnabled(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsScrollEnabled(); +} + +void +SectionTableView::SetScrollInputMode(ScrollInputMode mode) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->SetScrollInputMode(mode); +} + +ScrollInputMode +SectionTableView::GetScrollInputMode(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + return pImpl->GetScrollInputMode(); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlSimpleItem.cpp b/src/ui/controls/FUiCtrlSimpleItem.cpp new file mode 100644 index 0000000..b574a37 --- /dev/null +++ b/src/ui/controls/FUiCtrlSimpleItem.cpp @@ -0,0 +1,69 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlSimpleItem.cpp + * @brief This is the implementation file for SimpleItem class. + * + * This file contains the implementation of SimpleItem class. + */ + +#include +#include +#include "FUiCtrl_SimpleItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +SimpleItem::SimpleItem(void) +{ +} + +SimpleItem::~SimpleItem(void) +{ +} + +result +SimpleItem::Construct(const Dimension& itemSize, ListAnnexStyle style) +{ + result r = E_SUCCESS; + + _SimpleItemImpl* pSimpleImpl = static_cast<_SimpleItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pSimpleImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pSimpleImpl = _SimpleItemImpl::CreateSimpleItemImplN(this, itemSize, style); + SysTryReturn(NID_UI_CTRL, pSimpleImpl != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _pImpl = pSimpleImpl; + + return r; +} + +result +SimpleItem::SetElement(const String& text, const Bitmap* pBitmap) +{ + _SimpleItemImpl* pImpl = static_cast<_SimpleItemImpl*>(_ListItemBaseImpl::GetInstance(*this)); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetElement(text, pBitmap); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlSlidableGroupedList.cpp b/src/ui/controls/FUiCtrlSlidableGroupedList.cpp new file mode 100644 index 0000000..4602ace --- /dev/null +++ b/src/ui/controls/FUiCtrlSlidableGroupedList.cpp @@ -0,0 +1,649 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlSlidableGroupedList.cpp + * @brief This is the implementation file for SlidableGroupedList class. + * + * This file contains the implementation of SlidableGroupedList class. + */ + +#include +#include +#include "FUiCtrl_SlidableGroupedListImpl.h" +#include "FUiCtrl_CustomListImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Base::Collection; + + +namespace Tizen { namespace Ui { namespace Controls +{ + +SlidableGroupedList::SlidableGroupedList(void) +{ +} + +SlidableGroupedList::~SlidableGroupedList(void) +{ +} + +result +SlidableGroupedList::Construct(const Rectangle& rect, CustomListStyle style, bool itemDivider, bool bFastScroll) +{ + result r = E_SUCCESS; + + SysAssertf((_SlidableGroupedListImpl::GetInstance(*this) == null), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::CreateSlidableGroupedListImplN(this, itemDivider, bFastScroll); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + r = Control::SetBounds(rect.x, rect.y, rect.width, rect.height); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->SetListStyle(style); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->LoadDefaultBitmap(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl->Initialize(); + + return E_SUCCESS; + +CATCH: + Dispose(); + return r; + +} + +void +SlidableGroupedList::AddSlidableGroupedListEventListener(ISlidableGroupedListEventListener& listener) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddSlidableGroupedListEventListener(listener); +} + +void +SlidableGroupedList::RemoveSlidableGroupedListEventListener(ISlidableGroupedListEventListener& listener) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveSlidableGroupedListEventListener(listener); +} + +result +SlidableGroupedList::LoadItemToTop(const CustomListItem& item, int itemId) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->LoadItemToTop(item, itemId); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +SlidableGroupedList::LoadItemToBottom(const CustomListItem& item, int itemId) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->LoadItemToBottom(item, itemId); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +SlidableGroupedList::UnloadAllItems(void) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->UnloadAllItems(); +} + +result +SlidableGroupedList::RemoveAllItemsAt(int groupIndex) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveAllItemsAt(groupIndex); +} + +result +SlidableGroupedList::RemoveAllItems(void) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveAllItems(); +} + +void +SlidableGroupedList::RemoveFastScrollEventListener(IFastScrollEventListener& listener) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveFastScrollEventListener(listener); +} + +void +SlidableGroupedList::RemoveGroupedItemEventListener(IGroupedItemEventListener& listener) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveGroupedItemEventListener(listener); +} + +void +SlidableGroupedList::ScrollToBottom(void) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->ScrollToBottom(); +} + +void +SlidableGroupedList::ScrollToTop(void) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->ScrollToTop(); +} + +result +SlidableGroupedList::ScrollToTop(int groupIndex, int itemIndex) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ScrollToTop(groupIndex, itemIndex); +} + +result +SlidableGroupedList::ScrollToTop(int groupIndex) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ScrollToTop(groupIndex); +} + +result +SlidableGroupedList::SetAllItemsChecked(int groupIndex, bool check) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetAllItemsChecked(groupIndex, check); +} + +result +SlidableGroupedList::SetGroupAt(int groupIndex, const String& text, const Bitmap* pBackgroundBitmap, int groupId) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetGroupAt(groupIndex, text, pBackgroundBitmap, groupId); + +} + +result +SlidableGroupedList::SetItemChecked(int groupIndex, int index, bool check) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemChecked(groupIndex, index, check); +} + +result +SlidableGroupedList::SetLoadedItemEnabled(int groupIndex, int index, bool enable) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetLoadedItemEnabled(groupIndex, index, enable); +} + +result +SlidableGroupedList::RemoveAllCheckedItemsAt(int groupIndex, int itemHeight) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveAllCheckedItemsAt(groupIndex, itemHeight); +} + + +result +SlidableGroupedList::RemoveItemAt(int groupIndex, int index, int itemHeight) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveItemAt(groupIndex, index, itemHeight); +} + +result +SlidableGroupedList::RemoveGroupAt(int groupIndex) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveGroupAt(groupIndex); +} + +const CustomListItem* +SlidableGroupedList::GetLoadedItemAt(int groupIndex, int index) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLoadedItemAt(groupIndex, index); +} + +int +SlidableGroupedList::GetLoadedItemIdAt(int groupIndex, int index) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLoadedItemIdAt(groupIndex, index); +} + +result +SlidableGroupedList::GetLoadedItemIndexFromItemId(int itemId, int& groupIndex, int& itemIndex) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLoadedItemIndexFromItemId(itemId, groupIndex, itemIndex); +} + +result +SlidableGroupedList::RemoveAllCheckedItems(int height) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveAllCheckedItems(height); +} + +result +SlidableGroupedList::GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetFirstLoadedItemIndex(groupIndex, itemIndex); +} + +result +SlidableGroupedList::GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLastLoadedItemIndex(groupIndex, itemIndex); +} + +result +SlidableGroupedList::SetFastScrollMainIndex(const String& text) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetFastScrollMainIndex(text); +} + +result +SlidableGroupedList::SetFastScrollSubIndex(const String& text, FastScrollIndexDigit indexDigit) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetFastScrollSubIndex(text, indexDigit); +} + +void +SlidableGroupedList::SetBackgroundColor(const Color& color) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetBackgroundColor(color); +} + +void +SlidableGroupedList::SetTextOfEmptyList(const String& text) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextOfEmptyList(text); +} + +void +SlidableGroupedList::SetTextColorOfEmptyList(const Color& color) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextColorOfEmptyList(color); +} + +Color +SlidableGroupedList::GetTextColorOfEmptyList(void) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextColorOfEmptyList(); +} + +result +SlidableGroupedList::SetItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemAt(groupIndex, itemIndex, item, itemId); +} + +void +SlidableGroupedList::AddFastScrollEventListener(IFastScrollEventListener& listener) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddFastScrollEventListener(listener); +} + +result +SlidableGroupedList::AddGroup(const String& text, const Bitmap* pBackgroundBitmap, int itemCount, int groupHeight, int groupId) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddGroup(text, pBackgroundBitmap, itemCount, groupHeight, groupId); +} + +void +SlidableGroupedList::AddGroupedItemEventListener(IGroupedItemEventListener& listener) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddGroupedItemEventListener(listener); +} + +result +SlidableGroupedList::AddItem(int groupIndex, const CustomListItem& item, int itemId) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddItem(groupIndex, item, itemId); +} + +result +SlidableGroupedList::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex); +} + +result +SlidableGroupedList::GetFirstCheckedItemIndex(int& groupIndex, int& itemIndex) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetFirstCheckedItemIndex(groupIndex, itemIndex); +} + +int +SlidableGroupedList::GetGroupIdAt(int groupIndex) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetGroupIdAt(groupIndex); +} + +int +SlidableGroupedList::GetGroupIndexFromGroupId(int groupId) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetGroupIndexFromGroupId(groupId); +} + +result +SlidableGroupedList::GetLastCheckedItemIndex(int& groupIndex, int& itemIndex) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLastCheckedItemIndex(groupIndex, itemIndex); +} + +result +SlidableGroupedList::GetNextCheckedItemIndexAfter(int& groupIndex, int& index) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetNextCheckedItemIndexAfter(groupIndex, index); +} + +result +SlidableGroupedList::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex); +} + +result +SlidableGroupedList::GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(x, y, groupIndex, itemIndex); +} + +result +SlidableGroupedList::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex); +} + +result +SlidableGroupedList::InsertGroupAt(int groupIndex, const String& text, const Bitmap* pBackgroundBitmap, int itemCount, int groupHeight, int groupId) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->InsertGroupAt(groupIndex, text, pBackgroundBitmap, itemCount, groupHeight, groupId); +} + +bool +SlidableGroupedList::IsItemChecked(int groupIndex, int index) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemChecked(groupIndex, index); +} + +bool +SlidableGroupedList::IsLoadedItemEnabled(int groupIndex, int index) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsLoadedItemEnabled(groupIndex, index); +} + +bool +SlidableGroupedList::IsItemLoaded(int groupIndex, int itemIndex) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemLoaded(groupIndex, itemIndex); +} + +result +SlidableGroupedList::RemoveAllGroups(void) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveAllGroups(); +} + +int +SlidableGroupedList::GetGroupCount(void) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetGroupCount(); +} + +result +SlidableGroupedList::InsertItemAt(int groupIndex, int index, const CustomListItem& item, int itemId) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->InsertItemAt(groupIndex, index, item, itemId); +} + +int +SlidableGroupedList::GetItemCountAt(int groupIndex) const +{ + const _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemCountAt(groupIndex); +} + +result +SlidableGroupedList::RefreshItem(int groupIndex, int index) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RefreshItem(groupIndex, index); +} + +result +SlidableGroupedList::RefreshGroup(int groupIndex) +{ + _SlidableGroupedListImpl* pImpl = _SlidableGroupedListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RefreshGroup(groupIndex); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlSlidableList.cpp b/src/ui/controls/FUiCtrlSlidableList.cpp new file mode 100644 index 0000000..1651537 --- /dev/null +++ b/src/ui/controls/FUiCtrlSlidableList.cpp @@ -0,0 +1,489 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlSlidableList.cpp + * @brief This is the implementation file for SlidableList class. + */ + +#include +#include +#include "FUiCtrl_SlidableListImpl.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +SlidableList::SlidableList(void) +{ +} + +SlidableList::~SlidableList(void) +{ +} + +result +SlidableList::Construct(const Tizen::Graphics::Rectangle& rect, CustomListStyle style, bool itemDivider) +{ + result r = E_SUCCESS; + + SysAssertf((_SlidableListImpl::GetInstance(*this) == null), "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _SlidableListImpl* pImpl = _SlidableListImpl::CreateSlidableListImplN(this, rect, itemDivider); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + r = pImpl->UpdateBounds(rect); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->SetListStyle(style); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->Initalize(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->LoadDefaultBitmap(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + Dispose(); + return r; + +} + +void +SlidableList::AddSlidableListEventListener(Tizen::Ui::ISlidableListEventListener& listener) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddSlidableListEventListener(listener); +} + +void +SlidableList::RemoveSlidableListEventListener(Tizen::Ui::ISlidableListEventListener& listener) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveSlidableListEventListener(listener); +} + +void +SlidableList::AddCustomItemEventListener(Tizen::Ui::ICustomItemEventListener& listener) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddCustomItemEventListener(listener); +} + +result +SlidableList::AddItem(const CustomListItem& item, int itemId) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddItem(item, itemId); +} + +int +SlidableList::GetBottomDrawnItemIndex(void) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBottomDrawnItemIndex(); +} + +int +SlidableList::GetFirstCheckedItemIndex(void) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetFirstCheckedItemIndex(); +} + +int +SlidableList::GetItemCount(void) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemCount(); +} + +int +SlidableList::GetLastCheckedItemIndex(void) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLastCheckedItemIndex(); +} + +int +SlidableList::GetNextCheckedItemIndexAfter(int index) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetNextCheckedItemIndexAfter(index); +} + +int +SlidableList::GetTopDrawnItemIndex(void) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTopDrawnItemIndex(); +} + +result +SlidableList::InsertItemAt(int index, const CustomListItem& item, int itemId) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->InsertItemAt(index, item, itemId); +} + +result +SlidableList::RemoveAllItems(void) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveAllItems(); +} + +void +SlidableList::RemoveCustomItemEventListener(Tizen::Ui::ICustomItemEventListener& listener) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveCustomItemEventListener(listener); +} + +void +SlidableList::ScrollToBottom(void) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->ScrollToBottom(); +} + +void +SlidableList::ScrollToTop(void) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->ScrollToTop(); +} + +result +SlidableList::ScrollToTop(int index) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->ScrollToTop(index); +} + +result +SlidableList::SetAllItemsChecked(bool check) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetAllItemsChecked(check); +} + +result +SlidableList::SetItemChecked(int index, bool check) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemChecked(index, check); +} + +result +SlidableList::SetLoadedItemEnabled(int index, bool enable) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetLoadedItemEnabled(index, enable); +} + +void +SlidableList::SetBackgroundColor(const Tizen::Graphics::Color& color) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetBackgroundColor(color); +} + +void +SlidableList::SetTextOfEmptyList(const Tizen::Base::String& text) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextOfEmptyList(text); +} + +void +SlidableList::SetTextColorOfEmptyList(const Tizen::Graphics::Color& color) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTextColorOfEmptyList(color); +} + +Tizen::Graphics::Color +SlidableList::GetTextColorOfEmptyList(void) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetTextColorOfEmptyList(); +} + +const CustomListItem* +SlidableList::GetLoadedItemAt(int index) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLoadedItemAt(index); +} + +int +SlidableList::GetLoadedItemIdAt(int index) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLoadedItemIdAt(index); +} + +bool +SlidableList::IsItemChecked(int index) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemChecked(index); +} + +bool +SlidableList::IsLoadedItemEnabled(int index) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsLoadedItemEnabled(index); +} + +int +SlidableList::GetLoadedItemIndexFromItemId(int itemId) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLoadedItemIndexFromItemId(itemId); +} + +result +SlidableList::LoadItemToTop(const CustomListItem& item, int itemId) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->LoadItemToTop(item, itemId); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to load item at top", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +SlidableList::LoadItemToBottom(const CustomListItem& item, int itemId) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->LoadItemToBottom(item, itemId); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to load item at bottom", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +SlidableList::SetItemCountAndHeight(int count, int listHeight) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetItemCountAndHeight(count, listHeight); +} + +result +SlidableList::UnloadAllItems(void) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->UnloadAllItems(); +} + +result +SlidableList::SetItemAt(int index, const CustomListItem& item, int itemId) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemAt(index, item, itemId); +} + +result +SlidableList::RemoveItemAt(int index, int itemHeight) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveItemAt(index, itemHeight); +} + +result +SlidableList::RemoveAllCheckedItems(int itemHeight) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveAllCheckedItems(itemHeight); +} + +bool +SlidableList::IsItemLoaded(int index) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemLoaded(index); +} + +int +SlidableList::GetFirstLoadedItemIndex(void) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetFirstLoadedItemIndex(); +} + +int +SlidableList::GetLastLoadedItemIndex(void) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetLastLoadedItemIndex(); +} + +int +SlidableList::GetItemIndexFromPosition(int x, int y) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(x, y); +} + +int +SlidableList::GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const +{ + const _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemIndexFromPosition(position); +} + +result +SlidableList::RefreshItem(int index) +{ + _SlidableListImpl* pImpl = _SlidableListImpl::GetInstance(*this); + + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RefreshItem(index); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlSlider.cpp b/src/ui/controls/FUiCtrlSlider.cpp new file mode 100644 index 0000000..0a0760c --- /dev/null +++ b/src/ui/controls/FUiCtrlSlider.cpp @@ -0,0 +1,333 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlSlider.cpp + * @brief This is the implementation file for Slider class. + */ + +#include +#include +#include "FUiCtrl_SliderImpl.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Slider::Slider(void) +{ +} + +Slider::~Slider(void) +{ +} + +result +Slider::Construct(const Rectangle& rect, BackgroundStyle backgroundStyle, bool showTitle, int minValue, int maxValue, GroupStyle groupStyle) +{ + result r = E_SUCCESS; + + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf((pSliderImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + int sliderStyle = 0; + if (showTitle == true) + { + sliderStyle |= SLIDER_STYLE_TITLE; + } + sliderStyle |= SLIDER_STYLE_BUBBLE; + + pSliderImpl = _SliderImpl::CreateSliderImplN(this, rect, sliderStyle); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pSliderImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pSliderImpl->Initialize(minValue, maxValue, backgroundStyle, sliderStyle, groupStyle); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pSliderImpl; + + return r; + +CATCH: + delete pSliderImpl; + pSliderImpl = null; + + return r; +} + +result +Slider::Construct(const Rectangle& rect, unsigned long sliderStyle, int minValue, int maxValue) +{ + result r = E_SUCCESS; + + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf((pSliderImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + + pSliderImpl = _SliderImpl::CreateSliderImplN(this, rect, sliderStyle); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pSliderImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pSliderImpl->Initialize(minValue, maxValue, BACKGROUND_STYLE_DEFAULT, sliderStyle, GROUP_STYLE_NONE); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pSliderImpl; + + return r; + +CATCH: + delete pSliderImpl; + pSliderImpl = null; + + return r; +} + +result +Slider::SetRange(int minValue, int maxValue) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->SetRange(minValue, maxValue); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +Slider::GetRange(int& minValue, int& maxValue) const +{ + const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->GetRange(minValue, maxValue); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +Slider::SetValue(int value) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->SetValue(value); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +int +Slider::GetValue(void) const +{ + const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + int value = pSliderImpl->GetValue(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + return value; +} + +void +Slider::SetIcon(IconPosition position, const Bitmap& icon) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->SetIcon(position, icon); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +Slider::AddAdjustmentEventListener(IAdjustmentEventListener& listener) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->AddAdjustmentEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +Slider::RemoveAdjustmentEventListener(IAdjustmentEventListener& listener) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->RemoveAdjustmentEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +result +Slider::SetTitleText(const String& title) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->SetTitleText(title); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +String +Slider::GetTitleText(void) const +{ + const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + String string = pSliderImpl->GetTitleText(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, String(), r, "[%s] Propagating.", GetErrorMessage(r)); + + return string; +} + +void +Slider::SetTitleTextColor(const Color& color) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->SetTitleTextColor(color); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +Color +Slider::GetTitleTextColor(void) const +{ + const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + Color color = pSliderImpl->GetTitleTextColor(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r)); + + return color; +} + +void +Slider::AddSliderEventListener(ISliderEventListener& listener) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->AddSliderEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +Slider::RemoveSliderEventListener(ISliderEventListener& listener) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->RemoveSliderEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +result +Slider::SetBarColor(const Color& color) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->SetBarColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +Slider::GetBarColor(void) const +{ + const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + Color color = pSliderImpl->GetBarColor(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r)); + + return color; +} + +result +Slider::SetColor(const Color& color) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->SetColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +Slider::GetColor(void) const +{ + const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + Color color = pSliderImpl->GetColor(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r)); + + return color; +} + +result +Slider::SetThumbBitmap(SliderThumbStatus status, const Bitmap& bitmap) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pSliderImpl->SetThumbBitmap(status, bitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +Slider::SetThumbTextColor(SliderThumbStatus status, const Color& color) +{ + _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this); + SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use."); + + pSliderImpl->SetThumbTextColor(status, color); + + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlSplitPanel.cpp b/src/ui/controls/FUiCtrlSplitPanel.cpp new file mode 100644 index 0000000..7f0ccb8 --- /dev/null +++ b/src/ui/controls/FUiCtrlSplitPanel.cpp @@ -0,0 +1,190 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlSplitPanel.cpp +* @brief This file contains implementation of SplitPanel class +*/ + +// Includes +#include +#include +#include "FUiCtrl_SplitPanelImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +SplitPanel::SplitPanel(void) +{ + +} + +SplitPanel::~SplitPanel(void) +{ + +} + +result +SplitPanel::Construct(const Tizen::Graphics::Rectangle& rect, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection) +{ + result r = E_SUCCESS; + _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + + SysAssertf(pSplitPanelImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pSplitPanelImpl = _SplitPanelImpl::CreateSplitPanelImplN(this, rect, splitPanelDividerStyle, splitPanelDividerDirection); + SysTryReturnResult(NID_UI_CTRL, pSplitPanelImpl, GetLastResult(), "Propagating."); + + _pControlImpl = pSplitPanelImpl; + + r = pSplitPanelImpl->Initialize(rect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete pSplitPanelImpl; + _pControlImpl = null; + + return r; +} + +result +SplitPanel::SetPane(Control* pControl, SplitPanelPaneOrder paneOrder) +{ + _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSplitPanelImpl->SetPane(const_cast <_ControlImpl*>(_ControlImpl::GetInstance(*pControl)), paneOrder); +} + +Control* +SplitPanel::GetPane(SplitPanelPaneOrder paneOrder) const +{ + const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + _ControlImpl* pSplitPaneImpl = pSplitPanelImpl->GetPane(paneOrder); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pSplitPaneImpl, null, r, "[%s] Propagating.", GetErrorMessage(r)); + return &(pSplitPaneImpl->GetPublic()); +} + +result +SplitPanel::SetDividerPosition(int position) +{ + _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSplitPanelImpl->SetDividerPosition(position); +} + +int +SplitPanel::GetDividerPosition(void) const +{ + const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSplitPanelImpl->GetDividerPosition(); +} + +result +SplitPanel::SetMaximumDividerPosition(int position) +{ + _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSplitPanelImpl->SetMaximumDividerPosition(position); +} + +int +SplitPanel::GetMaximumDividerPosition(void) const +{ + const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSplitPanelImpl->GetMaximumDividerPosition(); +} + +result +SplitPanel::SetMinimumDividerPosition(int position) +{ + _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSplitPanelImpl->SetMinimumDividerPosition(position); +} + +int +SplitPanel::GetMinimumDividerPosition(void) const +{ + const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSplitPanelImpl->GetMinimumDividerPosition(); +} + +result +SplitPanel::MaximizePane(SplitPanelPaneOrder paneOrder) +{ + _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSplitPanelImpl->MaximizePane(paneOrder); +} + +bool +SplitPanel::IsPaneMaximized(SplitPanelPaneOrder paneOrder) const +{ + const _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSplitPanelImpl->IsPaneMaximized(paneOrder); +} + +result +SplitPanel::RestorePane(void) +{ + _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSplitPanelImpl->RestorePane(); +} + +result +SplitPanel::AddSplitPanelEventListener(ISplitPanelEventListener& listener) +{ + _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSplitPanelImpl->AddSplitPanelEventListener(listener); +} + +result +SplitPanel::RemoveSplitPanelEventListener(ISplitPanelEventListener& listener) +{ + _SplitPanelImpl* pSplitPanelImpl = _SplitPanelImpl::GetInstance(*this); + SysAssertf(pSplitPanelImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pSplitPanelImpl->RemoveSplitPanelEventListener(listener); +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrlTab.cpp b/src/ui/controls/FUiCtrlTab.cpp new file mode 100644 index 0000000..210368b --- /dev/null +++ b/src/ui/controls/FUiCtrlTab.cpp @@ -0,0 +1,348 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlTab.cpp + * @brief This is the implementation file for Tab class. + * + * This file contains the implementation of Tab class. + */ + +#include +#include "FUiCtrl_TabImpl.h" + +// using namespaces +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + + +namespace Tizen { namespace Ui { namespace Controls +{ +//////////////////////////////////////////////////////////////////////////////// +/// Tab class Lifecycle + +Tab::Tab(void) +{ + +} + +Tab::~Tab(void) +{ + +} + + +result +Tab::Construct(void) +{ + result r = E_SUCCESS; + + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + + SysAssertf(pTabImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pTabImpl = _TabImpl::CreateTabImplN(this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pTabImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _pControlImpl = pTabImpl; + + return E_SUCCESS; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Tab class Operation +void +Tab::AddActionEventListener(IActionEventListener& listener) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + pTabImpl->AddActionEventListener(listener); +} + + +void +Tab::RemoveActionEventListener(IActionEventListener& listener) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + pTabImpl->RemoveActionEventListener(listener); +} + +result +Tab::AddItem(const String& text, int actionId) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->AddItem(text, actionId); +} + +result +Tab::AddItem(const Bitmap& titleIcon, const String& text, int actionId) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->AddItem(titleIcon, text, actionId); +} + +result +Tab::AddItem(const Bitmap& icon, int actionId) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->AddItem(icon, actionId); +} + +result +Tab::InsertItemAt(int index, const String& text, int actionId) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->InsertItemAt(index, text, actionId); +} + +result +Tab::InsertItemAt(int index, const Bitmap& titleIcon, const String& text, int actionId) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->InsertItemAt(index, titleIcon, text, actionId); +} + +result +Tab::InsertItemAt(int index, const Bitmap& icon, int actionId) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->InsertItemAt(index, icon, actionId); +} + +result +Tab::SetItemAt(int index, const String& text, int actionId) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->SetItemAt(index, text, actionId); +} + +result +Tab::SetItemAt(int index, const Bitmap& titleIcon, const String& text, int actionId) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->SetItemAt(index, titleIcon, text, actionId); +} + +result +Tab::SetItemAt(int index, const Bitmap& icon, int actionId) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->SetItemAt(index, icon, actionId); +} + +result +Tab::RemoveItemAt(int index) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->RemoveItemAt(index); +} + + +result +Tab::RemoveAllItems(void) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->RemoveAllItems(); +} + + +result +Tab::SetBadgeIcon(int actionId, const Tizen::Graphics::Bitmap* pBadgeIcon) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->SetBadgeIcon(actionId, pBadgeIcon); +} + +int +Tab::GetItemCount(void) const +{ + const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->GetItemCount(); +} + +int +Tab::GetItemIndexFromActionId(int actionId) const +{ + const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->GetItemIndexFromActionId(actionId); +} + +int +Tab::GetItemActionIdAt(int index) const +{ + const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->GetItemActionIdAt(index); +} + +void +Tab::SetSelectedItem(int index) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + pTabImpl->SetSelectedItem(index); +} + +int +Tab::GetSelectedItemIndex(void) const +{ + const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->GetSelectedItemIndex(); +} + +void +Tab::SetEditModeEnabled(bool enable) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + pTabImpl->SetEditModeEnabled(enable); +} + +bool +Tab::IsEditModeEnabled(void) const +{ + const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->IsEditModeEnabled(); +} + +result +Tab::SetBackgroundBitmap(const Bitmap& bitmap) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->SetBackgroundBitmap(bitmap); +} + +result +Tab::SetFocusedItemBackgroundBitmap(const Bitmap& bitmap) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->SetFocusedItemBackgroundBitmap(bitmap); +} + +void +Tab::SetTextColor(const Color& color) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + pTabImpl->SetTextColor(color); +} + +Color +Tab::GetTextColor(void) const +{ + const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->GetTextColor(); +} + +void +Tab::SetSelectedTextColor(const Color& color) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + pTabImpl->SetSelectedTextColor(color); +} + +Color +Tab::GetSelectedTextColor(void) const +{ + const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->GetSelectedTextColor(); +} + +void +Tab::SetHighlightedTextColor(const Color& color) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + pTabImpl->SetHighlightedTextColor(color); +} + +Color +Tab::GetHighlightedTextColor(void) const +{ + const _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->GetHighlightedTextColor(); +} + +result +Tab::SetHighlightedItemBackgroundBitmap (const Bitmap& bitmap) +{ + _TabImpl* pTabImpl = _TabImpl::GetInstance(*this); + SysAssertf(pTabImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTabImpl->SetHighlightedItemBackgroundBitmap(bitmap); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlTabBar.cpp b/src/ui/controls/FUiCtrlTabBar.cpp new file mode 100644 index 0000000..2c2cbb7 --- /dev/null +++ b/src/ui/controls/FUiCtrlTabBar.cpp @@ -0,0 +1,220 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrlTabBar.cpp +* @brief This file contains implementation of TabBar class +*/ + +#include +#include +#include +#include "FUiCtrl_TabBarItemImpl.h" +#include "FUiCtrl_TabBarImpl.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Controls; + +namespace Tizen { namespace Ui { namespace Controls +{ + +TabBar::TabBar(void) +{ +} + + +TabBar::~TabBar(void) +{ +} + + +result +TabBar::Construct(int x, int y, int width) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl == null, + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _TabBarImpl::CreateTabBarImplN(this, Rectangle(x, y, width, 0)); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return r; +} + +result +TabBar::AddItem(const TabBarItem& item) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SysTryReturn(NID_UI_CTRL, item.__pTabBarItemImpl != null, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Input TabBarItem is not constructed.\n"); + + return pImpl->AddItem(item.GetText(), item.GetActionId()); +} + +result +TabBar::InsertItemAt(int index, const TabBarItem& item) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SysTryReturn(NID_UI_CTRL, item.__pTabBarItemImpl != null, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Input TabBarItem is not constructed.\n"); + + return pImpl->InsertItemAt(index, item.GetText(), item.GetActionId()); +} + +Tizen::Graphics::Color +TabBar::GetColor(void) const +{ + const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetColor(); +} + +int +TabBar::GetItemCount(void) const +{ + const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemCount(); +} + +Tizen::Graphics::Color +TabBar::GetSelectedItemColor(void) const +{ + const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSelectedItemColor(); +} + +Tizen::Graphics::Color +TabBar::GetItemTextColor(TabBarItemStatus status) const +{ + const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemTextColor(status); +} + +int +TabBar::GetSelectedItemIndex(void) const +{ + const _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSelectedItemIndex(); +} + +result +TabBar::RemoveItemAt(int index) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveItemAt(index); +} + +result +TabBar::RemoveAllItems(void) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveAllItems(); +} + +result +TabBar::SetColor(const Tizen::Graphics::Color& color) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetColor(color); +} + +result +TabBar::SetItemAt(int index, const TabBarItem& item) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + SysTryReturn(NID_UI_CTRL, item.__pTabBarItemImpl != null, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Input TabBarItem is not constructed.\n"); + + return pImpl->SetItemAt(index, item.GetText(), item.GetActionId()); +} + +result +TabBar::SetItemSelected(int index) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemSelected(index); +} + +result +TabBar::SetItemTextColor(TabBarItemStatus status, const Tizen::Graphics::Color& color) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemTextColor(status, color); +} + +result +TabBar::SetSelectedItemColor(const Tizen::Graphics::Color& color) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetSelectedItemColor(color); +} + +result +TabBar::SetWidth(int width) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetWidth(width); +} + +void +TabBar::AddActionEventListener(Tizen::Ui::IActionEventListener& listener) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->AddActionEventListener(listener); +} + + +void +TabBar::RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener) +{ + _TabBarImpl* pImpl = _TabBarImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->RemoveActionEventListener(listener); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlTabBarItem.cpp b/src/ui/controls/FUiCtrlTabBarItem.cpp new file mode 100644 index 0000000..6c9fed0 --- /dev/null +++ b/src/ui/controls/FUiCtrlTabBarItem.cpp @@ -0,0 +1,141 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrlTabBarItem.cpp +* @brief This file contains implementation of TabBarItem class +*/ + +#include +#include +#include +#include +#include "FUiCtrl_TabBarItemImpl.h" + +using namespace Tizen::Ui::Controls; + +namespace Tizen { namespace Ui { namespace Controls +{ + +TabBarItem::TabBarItem(void) + : __pTabBarItemImpl(null) +{ +} + + +TabBarItem::~TabBarItem(void) +{ + delete __pTabBarItemImpl; + __pTabBarItemImpl = null; +} + + +result +TabBarItem::Construct(const Tizen::Base::String& text, int actionId) +{ + if (__pTabBarItemImpl != null) + { + SysLog(NID_UI_CTRL, "[E_INVALID_STATE] This instance is already allocated."); + return E_INVALID_STATE; + } + + if (actionId < 0) + { + SysLog(NID_UI_CTRL, "[E_INVALID_ARG] The action ID of the item must be a positive integer."); + return E_INVALID_ARG; + } + + __pTabBarItemImpl = new (std::nothrow) _TabBarItemImpl(); + if (__pTabBarItemImpl == null) + { + SysLog(NID_UI_CTRL, "[E_OUT_OF_MEMORY] SeedItem of TabBarItem can not be allocated due to the memory shortage."); + delete __pTabBarItemImpl; + __pTabBarItemImpl = null; + return E_OUT_OF_MEMORY; + } + + __pTabBarItemImpl->SetText(text); + __pTabBarItemImpl->SetActionId(actionId); + + return E_SUCCESS; +} + +result +TabBarItem::SetActionId(int actionId) +{ + if (__pTabBarItemImpl == null) + { + SysLog(NID_UI_CTRL, "[E_INVALID_STATE] This instance isn't constructed."); + return E_INVALID_STATE; + } + + if (actionId < 0) + { + SysLog(NID_UI_CTRL, "[E_INVALID_ARG] The action ID of the item must be a positive integer."); + return E_INVALID_ARG; + } + + __pTabBarItemImpl->SetActionId(actionId); + return E_SUCCESS; +} + +int +TabBarItem::GetActionId(void) const +{ + ClearLastResult(); + + if (__pTabBarItemImpl == null) + { + SysLog(NID_UI_CTRL, "[E_INVALID_STATE] This instance isn't constructed."); + SetLastResult(E_INVALID_STATE); + return -1; + } + + SetLastResult(E_SUCCESS); + return __pTabBarItemImpl->GetActionId(); +} + +Tizen::Base::String +TabBarItem::GetText(void) const +{ + ClearLastResult(); + + if (__pTabBarItemImpl == null) + { + SysLog(NID_UI_CTRL, "[E_INVALID_STATE] This instance isn't constructed."); + SetLastResult(E_INVALID_STATE); + return Tizen::Base::String(); + } + + SetLastResult(E_SUCCESS); + return __pTabBarItemImpl->GetText(); +} + +result +TabBarItem::SetText(const Tizen::Base::String& text) +{ + if (__pTabBarItemImpl == null) + { + SysLog(NID_UI_CTRL, "[E_INVALID_STATE] This instance isn't constructed."); + return E_INVALID_STATE; + } + + __pTabBarItemImpl->SetText(text); + + return E_SUCCESS; +} + +} } } // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlTableView.cpp b/src/ui/controls/FUiCtrlTableView.cpp new file mode 100644 index 0000000..2122a76 --- /dev/null +++ b/src/ui/controls/FUiCtrlTableView.cpp @@ -0,0 +1,386 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlTableView.cpp +* @brief This is the implementation file for TableView class. +* +* This header file contains the implementation of TableView class. +*/ + +#include +#include +#include +#include +#include "FUiCtrl_TableViewImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +//////////////////////////////////////////////////////////////////////////////// +/// TableView class + +TableView::TableView(void) +{ +} + +TableView::~TableView(void) +{ +} + +result +TableView::Construct(const Tizen::Graphics::Rectangle& rect, bool itemDivider, TableViewScrollBarStyle scrollStyle) +{ + result r = E_SUCCESS; + + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _TableViewImpl::CreateTableViewImplN(this, rect, TABLE_VIEW_STYLE_SIMPLE, itemDivider, scrollStyle); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + r = SetBounds(rect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + Control::Dispose(); + + return r; +} + +void +TableView::SetItemProvider(ITableViewItemProvider* pProvider) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetSimpleStyleItemProvider(pProvider); +} + +result +TableView::AddTableViewItemEventListener(ITableViewItemEventListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddTableViewItemEventListener(listener); +} + +result +TableView::RemoveTableViewItemEventListener(ITableViewItemEventListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveTableViewItemEventListener(listener); +} + +result +TableView::AddFastScrollListener(IFastScrollListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddFastScrollListener(listener); +} + +result +TableView::RemoveFastScrollListener(IFastScrollListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveFastScrollListener(listener); +} + +result +TableView::AddScrollEventListener(IScrollEventListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->AddScrollEventListener(listener); +} + +result +TableView::RemoveScrollEventListener(IScrollEventListener& listener) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RemoveScrollEventListener(listener); +} + +result +TableView::SetFastScrollIndex(const String& text, bool useSearchIcon) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetFastScrollIndex(text, useSearchIcon); +} + +int +TableView::GetTopDrawnItemIndex(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + int itemIndex = -1; + int groupIndex = -1; + pImpl->GetTopDrawnItemIndex(groupIndex, itemIndex); + + return itemIndex; +} + +int +TableView::GetBottomDrawnItemIndex(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + int itemIndex = -1; + int groupIndex = -1; + pImpl->GetBottomDrawnItemIndex(groupIndex, itemIndex); + + return itemIndex; +} + +result +TableView::ScrollToItem(int itemIndex, TableViewScrollItemAlignment itemAlignment) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollToItem(0, itemIndex, itemAlignment); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +TableView::SetItemChecked(int itemIndex, bool check) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemChecked(0, itemIndex, check); +} + +bool +TableView::IsItemChecked(int itemIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemChecked(0, itemIndex); +} + +result +TableView::SetItemEnabled(int itemIndex, bool enable) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetItemEnabled(0, itemIndex, enable); +} + +bool +TableView::IsItemEnabled(int itemIndex) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsItemEnabled(0, itemIndex); +} + +int +TableView::GetItemCount(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemCountAt(0); +} + +result +TableView::RefreshItem(int itemIndex, TableViewRefreshType type) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->RefreshTableView(0, itemIndex, type); +} + +void +TableView::UpdateTableView(void) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->UpdateTableView(); +} + +int +TableView::GetItemIndexFromPosition(const Point& position) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + int itemIndex = -1; + int groupIndex = -1; + + pImpl->GetItemIndexFromPosition(position, groupIndex, itemIndex); + + return itemIndex; +} + +void +TableView::SetItemDividerColor(const Color& color) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetItemDividerColor(color); +} + +Color +TableView::GetItemDividerColor(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetItemDividerColor(); +} + +void +TableView::SetBackgroundColor(const Color& color) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetBackgroundColor(color); + + return; +} + +Color +TableView::GetBackgroundColor(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBackgroundColor(); +} + +void +TableView::BeginReorderingMode(void) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->BeginReorderingMode(); +} + +void +TableView::EndReorderingMode(void) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->EndReorderingMode(); +} + +bool +TableView::IsInReorderingMode(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsInReorderingMode(); +} + +result +TableView::ScrollByPixel(int scrollDistance) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->ScrollByPixel(scrollDistance); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +TableView::GetCurrentScrollPosition(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetCurrentScrollPosition(); +} + +void +TableView::SetScrollEnabled(bool enable) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetScrollEnabled(enable); + + return; +} + +bool +TableView::IsScrollEnabled(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->IsScrollEnabled(); +} + +void +TableView::SetScrollInputMode(ScrollInputMode mode) +{ + _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + pImpl->SetScrollInputMode(mode); +} + +ScrollInputMode +TableView::GetScrollInputMode(void) const +{ + const _TableViewImpl* pImpl = _TableViewImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not-yet constructed! Construct() should be called before use."); + + return pImpl->GetScrollInputMode(); +} + + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlTableViewContextItem.cpp b/src/ui/controls/FUiCtrlTableViewContextItem.cpp new file mode 100644 index 0000000..8ac3a37 --- /dev/null +++ b/src/ui/controls/FUiCtrlTableViewContextItem.cpp @@ -0,0 +1,55 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrlTableViewContextItem.cpp + * @brief This is the implementation file for TableViewContextItem class. + * + * This file contains the implementation of TableViewContextItem class. + */ + +#include +#include "FUiCtrl_TableViewItemImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +TableViewContextItem::TableViewContextItem(void) +{ +} + +TableViewContextItem::~TableViewContextItem(void) +{ +} + +result +TableViewContextItem::Construct(const Tizen::Graphics::Dimension& itemSize) +{ + result r = E_SUCCESS; + + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + _pControlImpl = _TableViewItemImpl::CreateTableViewItemImplN(this, itemSize); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, _pControlImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlTableViewGroupItem.cpp b/src/ui/controls/FUiCtrlTableViewGroupItem.cpp new file mode 100644 index 0000000..e27e625 --- /dev/null +++ b/src/ui/controls/FUiCtrlTableViewGroupItem.cpp @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlTableViewGroupItem.cpp +* @brief This is the implementation file for TableViewGroupItem class. +* +* This header file contains the implementation of TableViewGroupItem class. +*/ + +#include +#include "FUiCtrl_TableViewItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +TableViewGroupItem::TableViewGroupItem(void) +{ +} + +TableViewGroupItem::~TableViewGroupItem(void) +{ +} + +result +TableViewGroupItem::Construct(const Dimension& itemSize) +{ + result r = E_SUCCESS; + + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _TableViewItemImpl::CreateTableViewItemImplN(this, itemSize); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return r; +} + +result +TableViewGroupItem::Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Dimension& itemSize) +{ + return Construct(layout, layout, itemSize); +} + +result +TableViewGroupItem::Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Dimension& itemSize) +{ + result r = E_SUCCESS; + + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _TableViewItemImpl::CreateTableViewItemImplN(this, itemSize, TABLE_VIEW_ANNEX_STYLE_NORMAL, &(const_cast (portraitLayout)), &(const_cast (landscapeLayout))); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return r; +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlTableViewItem.cpp b/src/ui/controls/FUiCtrlTableViewItem.cpp new file mode 100644 index 0000000..c094f64 --- /dev/null +++ b/src/ui/controls/FUiCtrlTableViewItem.cpp @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlTableViewItem.cpp +* @brief This file contains implementation of TableViewItem class +*/ + + +//includes +#include +#include +#include "FUiCtrl_TableViewItemImpl.h" +#include "FUiCtrl_ListItemBaseImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +TableViewItem::TableViewItem(void) + : TableViewItemBase() +{ + // empty statement +} + +TableViewItem::~TableViewItem(void) +{ + // empty statement +} + +result +TableViewItem::Construct(const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style) +{ + result r = E_SUCCESS; + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _TableViewItemImpl::CreateTableViewItemImplN(this, itemSize, style); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return r; +} + +result +TableViewItem::Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style) +{ + return Construct(layout, layout, itemSize, style); +} + +result +TableViewItem::Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style) +{ + result r = E_SUCCESS; + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _TableViewItemImpl::CreateTableViewItemImplN(this, itemSize, style, &(const_cast (portraitLayout)), &(const_cast (landscapeLayout))); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + return r; +} + +void +TableViewItem::SetContextItem(const TableViewContextItem* pItem) +{ + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + _TableViewItemImpl* pItemImpl = null; + if (pItem != null) + { + pItemImpl = const_cast<_TableViewItemImpl*>(_TableViewItemImpl::GetInstance(*pItem)); + } + + pImpl->SetContextItem(pItemImpl); +} + +int +TableViewItem::GetAnnexWidth(TableViewAnnexStyle style) +{ + return _TableViewItemImpl::GetAnnexWidth(style); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlTableViewItemBase.cpp b/src/ui/controls/FUiCtrlTableViewItemBase.cpp new file mode 100644 index 0000000..876c7eb --- /dev/null +++ b/src/ui/controls/FUiCtrlTableViewItemBase.cpp @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlTableViewItemBase.cpp +* @brief This file contains implementation of TableViewItemBase class +*/ + +//includes +#include +#include "FUiCtrl_TableViewItemImpl.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +TableViewItemBase::TableViewItemBase(void) +{ + // empty statement +} + +TableViewItemBase::~TableViewItemBase(void) +{ + // empty statement +} + +result +TableViewItemBase::SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap, TableViewItemDrawingStatus status) +{ + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetBackgroundBitmap(status, pBitmap); +} + +void +TableViewItemBase::SetBackgroundColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status) +{ + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetBackgroundColor(status, color); +} + +Tizen::Graphics::Color +TableViewItemBase::GetBackgroundColor(TableViewItemDrawingStatus status) const +{ + const _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetBackgroundColor(status); +} + +result +TableViewItemBase::SetIndividualSelectionEnabled(const Tizen::Ui::Control* pControl, bool enable) +{ + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*pControl); + SysTryReturnResult(NID_UI_CTRL, pControlImpl != null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return pImpl->SetIndividualSelectionEnabled(*pControlImpl, enable); +} + +bool +TableViewItemBase::IsIndividualSelectionEnabled(const Tizen::Ui::Control* pControl) +{ + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + const _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*pControl); + SysTryReturnResult(NID_UI_CTRL, pControlImpl != null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return pImpl->IsIndividualSelectionEnabled(*pControlImpl); +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrlTableViewSimpleGroupItem.cpp b/src/ui/controls/FUiCtrlTableViewSimpleGroupItem.cpp new file mode 100644 index 0000000..ccb8e6c --- /dev/null +++ b/src/ui/controls/FUiCtrlTableViewSimpleGroupItem.cpp @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlTableViewSimpleGroupItem.cpp +* @brief This is the implementation file for TableViewSimpleGroupItem class. +* +* This header file contains the implementation of TableViewSimpleGroupItem class. +*/ + +#include +#include "FUiCtrl_TableViewItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +TableViewSimpleGroupItem::TableViewSimpleGroupItem(void) +{ +} + +TableViewSimpleGroupItem::~TableViewSimpleGroupItem(void) +{ +} + +result +TableViewSimpleGroupItem::Construct(const Dimension& itemSize) +{ + return TableViewGroupItem::Construct(itemSize); +} + +result +TableViewSimpleGroupItem::SetItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap) +{ + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetSimpleItemContents(text, pBitmap, true); +} + +result +TableViewSimpleGroupItem::SetTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status) +{ + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetSimpleItemTextColor(color, status); +} + +Tizen::Graphics::Color +TableViewSimpleGroupItem::GetTextColor(TableViewItemDrawingStatus status) const +{ + const _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSimpleItemTextColor(status); +} + +result +TableViewSimpleGroupItem::SetTextSize(int size) +{ + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetSimpleItemTextSize(size); +} + +int +TableViewSimpleGroupItem::GetTextSize(void) const +{ + const _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSimpleItemTextSize(); +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlTableViewSimpleItem.cpp b/src/ui/controls/FUiCtrlTableViewSimpleItem.cpp new file mode 100644 index 0000000..366a2b6 --- /dev/null +++ b/src/ui/controls/FUiCtrlTableViewSimpleItem.cpp @@ -0,0 +1,98 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlTableViewSimpleItem.cpp +* @brief This file contains implementation of TableViewSimpleItem class +*/ + + +//includes +#include +#include +#include "FUiCtrl_TableViewItemImpl.h" + + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +TableViewSimpleItem::TableViewSimpleItem(void) + : TableViewItem() +{ + // empty statement +} + +TableViewSimpleItem::~TableViewSimpleItem(void) +{ + // empty statement +} + +result +TableViewSimpleItem::Construct(const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style) +{ + return TableViewItem::Construct(itemSize, style); +} + +result +TableViewSimpleItem::SetItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap) +{ + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetSimpleItemContents(text, pBitmap); +} + +void +TableViewSimpleItem::SetTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status) +{ + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + pImpl->SetSimpleItemTextColor(color, status); +} + +Tizen::Graphics::Color +TableViewSimpleItem::GetTextColor(TableViewItemDrawingStatus status) const +{ + const _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSimpleItemTextColor(status); +} + +result +TableViewSimpleItem::SetTextSize(int size) +{ + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->SetSimpleItemTextSize(size); +} + +int +TableViewSimpleItem::GetTextSize(void) const +{ + const _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*this); + SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pImpl->GetSimpleItemTextSize(); +} + +}}} + diff --git a/src/ui/controls/FUiCtrlTextBox.cpp b/src/ui/controls/FUiCtrlTextBox.cpp new file mode 100644 index 0000000..4e0cc3a --- /dev/null +++ b/src/ui/controls/FUiCtrlTextBox.cpp @@ -0,0 +1,384 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrlTextBox.cpp +* @brief This is the implementation file for TextBox class. +*/ + +#include +#include +#include "FUiCtrl_TextBoxImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +TextBox::TextBox(void) +{ +} + +TextBox::~TextBox(void) +{ +} + +result +TextBox::Construct(const Rectangle& rect, TextBoxBorder border) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pTextBoxImpl = _TextBoxImpl::CreateTextBoxImplN(this); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pTextBoxImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pTextBoxImpl; + + r = SetBounds(rect.x, rect.y, rect.width, rect.height); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTextBoxImpl->Initialize(border); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +} + +result +TextBox::SetAutoLinkMask(unsigned long autoLinks) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->SetAutoLinkMask(autoLinks); +} + +unsigned long +TextBox::GetAutoLinkMask(void) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetAutoLinkMask(); +} + +void +TextBox::AddUiLinkEventListener(IUiLinkEventListener& listener) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pTextBoxImpl->AddUiLinkEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +TextBox::RemoveUiLinkEventListener(IUiLinkEventListener& listener) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pTextBoxImpl->RemoveUiLinkEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +TextBox::AppendCharacter(const Character& character) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->AppendCharacter(character); +} + +result +TextBox::AppendText(const String& text) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->AppendText(text); +} + +result +TextBox::Clear(void) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->Clear(); +} + +int +TextBox::GetLineCount(void) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetLineCount(); +} + +String +TextBox::GetText(void) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetText(); +} + +String +TextBox::GetText(int start, int end) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetText(start, end); +} + +int +TextBox::GetTextLength(void) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetTextLength(); +} + +result +TextBox::InsertCharacterAt(int index, const Character& character) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->InsertCharacterAt(index, character); +} + +result +TextBox::InsertTextAt(int index, const String& text) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->InsertTextAt(index, text); +} + +result +TextBox::SetText(const String& text) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->SetText(text); +} + +int +TextBox::GetLineSpacing(void) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetLineSpacing(); +} + +result +TextBox::SetLineSpacing(int multiplier, int extra) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->SetLineSpacing(multiplier, extra); +} + +HorizontalAlignment +TextBox::GetTextAlignment(void) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetTextAlignment(); +} + +result +TextBox::SetTextAlignment(HorizontalAlignment alignment) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->SetTextAlignment(alignment); +} + +int +TextBox::GetTextSize(void) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetTextSize(); +} + +result +TextBox::SetTextSize(int size) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->SetTextSize(size); +} + +result +TextBox::GetFontType(String& typefaceName, unsigned long& styleMask) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetFontType(typefaceName, styleMask); +} + +result +TextBox::SetFontType(const String& typefaceName, unsigned long styleMask) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->SetFontType(typefaceName, styleMask); +} + +unsigned long +TextBox::GetTextStyle(void) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetTextStyle(); +} + +result +TextBox::SetTextStyle(unsigned long style) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->SetTextStyle(style); +} + +result +TextBox::SetFont(const Font& font) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->SetFont(font); +} + +result +TextBox::ReleaseBlock(void) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + + return pTextBoxImpl->ReleaseBlock(); +} + +result +TextBox::GetBlockRange(int& start, int& end) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetBlockRange(start, end); +} + +result +TextBox::SetBlockRange(int start, int end) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->SetBlockRange(start, end); +} + +void +TextBox::AddTextBlockEventListener(ITextBlockEventListener& listener) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pTextBoxImpl->AddTextBlockEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +TextBox::RemoveTextBlockEventListener(ITextBlockEventListener& listener) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + result r = pTextBoxImpl->RemoveTextBlockEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +Color +TextBox::GetColor(TextBoxStatus status) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetColor(status); +} + +Color +TextBox::GetTextColor(TextBoxTextColor type) const +{ + const _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->GetTextColor(type); +} + +result +TextBox::SetColor(TextBoxStatus status, const Color& color) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->SetColor(status, color); +} + +result +TextBox::SetTextColor(TextBoxTextColor type, const Color& color) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->SetTextColor(type, color); +} + +result +TextBox::SetBackgroundBitmap(TextBoxStatus status, const Bitmap& bitmap) +{ + _TextBoxImpl* pTextBoxImpl = _TextBoxImpl::GetInstance(*this); + SysAssertf(pTextBoxImpl != null, "Not yet constructed. Construct() should be called before use."); + + return pTextBoxImpl->SetBackgroundBitmap(status, bitmap); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrlTimePicker.cpp b/src/ui/controls/FUiCtrlTimePicker.cpp new file mode 100644 index 0000000..cedd61e --- /dev/null +++ b/src/ui/controls/FUiCtrlTimePicker.cpp @@ -0,0 +1,186 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrlTimePicker.cpp + * @brief This is the implementation file for the TimePicker class. + */ + +// Includes +#include +#include +#include +#include "FUiCtrl_TimePickerImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::System; + +namespace Tizen { namespace Ui { namespace Controls +{ + +TimePicker::TimePicker(void) +{ +} + +TimePicker::~TimePicker(void) +{ +} + +result +TimePicker::Construct(const Tizen::Base::String& title) +{ + _TimePickerImpl* pImpl = null; + pImpl = _TimePickerImpl::GetInstance(*this); + SysAssertf((pImpl == null), + "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + pImpl = _TimePickerImpl::CreateTimePickerImplN(this, title); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pImpl != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl; + + pImpl->GetCore().SetResizable(false); + pImpl->GetCore().SetMovable(false); + + return r; +} + +void +TimePicker::AddTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener) +{ + _TimePickerImpl* pImpl = _TimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->AddTimeChangeEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +TimePicker::RemoveTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener) +{ + _TimePickerImpl* pImpl = _TimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->RemoveTimeChangeEventListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +int +TimePicker::GetHour(void) const +{ + const _TimePickerImpl* pImpl = _TimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int hour = pImpl->GetHour(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, hour, r, "[%s] Propagating.", GetErrorMessage(r)); + + return hour; +} + +int +TimePicker::GetMinute(void) const +{ + const _TimePickerImpl* pImpl = _TimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + int minute = pImpl->GetMinute(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, minute, r, "[%s] Propagating.", GetErrorMessage(r)); + + return minute; +} + +Tizen::Base::DateTime +TimePicker::GetTime(void) const +{ + result r = E_SUCCESS; + Tizen::Base::DateTime dateTime; + const _TimePickerImpl* pImpl = _TimePickerImpl::GetInstance(*this); + if (pImpl == null) + { + r = SystemTime::GetCurrentTime(WALL_TIME, dateTime); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, dateTime, r, "[%s] Propagating.", GetErrorMessage(r)); + return dateTime; + } + + dateTime = pImpl->GetTime(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, dateTime, r, "[%s] Propagating.", GetErrorMessage(r)); + + return dateTime; +} + +void +TimePicker::Set24HourNotationEnabled(bool enable) +{ + _TimePickerImpl* pImpl = _TimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->Set24HourNotationEnabled(enable); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +TimePicker::SetHour(int hour) +{ + _TimePickerImpl* pImpl = _TimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetHour(hour); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +TimePicker::SetMinute(int minute) +{ + _TimePickerImpl* pImpl = _TimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + result r = pImpl->SetMinute(minute); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +TimePicker::SetTime(const Tizen::Base::DateTime& time) +{ + _TimePickerImpl* pImpl = _TimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->SetTime(time); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +TimePicker::SetCurrentTime(void) +{ + _TimePickerImpl* pImpl = _TimePickerImpl::GetInstance(*this); + SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use."); + + pImpl->SetCurrentTime(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ActionEvent.cpp b/src/ui/controls/FUiCtrl_ActionEvent.cpp new file mode 100644 index 0000000..d643bbc --- /dev/null +++ b/src/ui/controls/FUiCtrl_ActionEvent.cpp @@ -0,0 +1,166 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_ActionEvent.cpp +* @brief This is the implementation for the ActionEvent class. +*/ + +#include +#include +#include +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_ActionEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _ActionEventArg + * @brief This class is used as the argument to action event listener. + * + * This class is used as the argument to action event listener. When an action event is generated + * (such as when a button is pressed) the ActionEvent calls ActionEventListener's OnActionPerformed + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the action ID. + */ +class _OSP_EXPORT_ _ActionEventArg + : public IEventArg + , public Object +{ +public: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Object instance which contains this instance. + * @param[in] actionId Action Id. + */ + _ActionEventArg(int actionId); + + /** + * This is the class destructor. + * + */ + virtual ~_ActionEventArg(void); + +public: + /** + * This method returns the actionId which the event initially occurred. + * + * @return See the comment above. + */ + int GetActionId(void) const; + +private: + /** + * Action Id. + */ + int __actionId; +}; // _ActionEventArg + +_ActionEventArg::_ActionEventArg(int actionId) + : __actionId(actionId) +{ + // nothing +} + +_ActionEventArg::~_ActionEventArg(void) +{ + // nothing +} + +int +_ActionEventArg::GetActionId(void) const +{ + return __actionId; +} + +_ActionEvent::_ActionEvent(const _Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + SetLastResult(E_SUCCESS); + } +} + +_ActionEvent::~_ActionEvent(void) +{ + // nothing +} + +_ActionEvent* +_ActionEvent::CreateInstanceN(const _Control& source) +{ + _ActionEvent* pActionEvent = new (std::nothrow) _ActionEvent(source); + SysTryReturn(NID_UI_CTRL, pActionEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pActionEvent; + +CATCH: + delete pActionEvent; + return null; +} + +const _Control* +_ActionEvent::GetSource(void) const +{ + return __pSource; +} + +void +_ActionEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to _IActionEventListener + _IActionEventListener* pActionListener = dynamic_cast <_IActionEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pActionListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given.\n"); + + // cast to _ActionEventArg + const _ActionEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + // call cursor change event listener method + pActionListener->OnActionPerformed(*__pSource, pArg->GetActionId()); + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_ActionEvent::CreateActionEventArgN(int actionId) +{ + _ActionEventArg* pEventArg = new (std::nothrow) _ActionEventArg(actionId); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_AdjustmentEvent.cpp b/src/ui/controls/FUiCtrl_AdjustmentEvent.cpp new file mode 100644 index 0000000..f759859 --- /dev/null +++ b/src/ui/controls/FUiCtrl_AdjustmentEvent.cpp @@ -0,0 +1,142 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_AdjustmentEvent.cpp + * @brief This is the implementation for the _AdjustmentEvent class. + * + * This file contains the implementation of _AdjustmentEvent class. @n + */ + +#include +#include +#include +#include "FUiCtrl_IAdjustmentEventListener.h" +#include "FUiCtrl_AdjustmentEvent.h" + +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _OSP_EXPORT_ _AdjustmentEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + _AdjustmentEventArg(int adjustment); + virtual ~_AdjustmentEventArg(void); + +// Access +public: + int GetAdjustment(void) const; + +// Attribute +private: + int __adjustment; + +}; // _AdjustmentEventArg + +_AdjustmentEventArg::_AdjustmentEventArg(int adjustment) + : __adjustment(adjustment) +{ +} + +_AdjustmentEventArg::~_AdjustmentEventArg(void) +{ +} + +int +_AdjustmentEventArg::GetAdjustment(void) const +{ + return __adjustment; +} + + +_AdjustmentEvent::_AdjustmentEvent(const _Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_AdjustmentEvent::~_AdjustmentEvent(void) +{ +} + +_AdjustmentEvent* +_AdjustmentEvent::CreateInstanceN(const _Control& source) +{ + _AdjustmentEvent* pAdjustmentEvent = new (std::nothrow) _AdjustmentEvent(source); + SysTryReturn(NID_UI_CTRL, pAdjustmentEvent != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pAdjustmentEvent; + +CATCH: + delete pAdjustmentEvent; + pAdjustmentEvent = null; + + return null; +} + +const _Control* +_AdjustmentEvent::GetSource(void) const +{ + return __pSource; +} + +void +_AdjustmentEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to _IAdjustmentEventListener + _IAdjustmentEventListener* pAdjustmentListener = dynamic_cast <_IAdjustmentEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pAdjustmentListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given.\n"); + + // cast to _AdjustmentEventArg + const _AdjustmentEventArg* pAdjustmentEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pAdjustmentEventArg != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + // call cursor change event listener method + pAdjustmentListener->OnAdjustmentValueChanged(*__pSource, pAdjustmentEventArg->GetAdjustment()); + SetLastResult(E_SUCCESS); + return; +} + +IEventArg* +_AdjustmentEvent::CreateAdjustmentEventArgN(int adjustment) +{ + _AdjustmentEventArg* pEventArg = new (std::nothrow) _AdjustmentEventArg(adjustment); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Animation.cpp b/src/ui/controls/FUiCtrl_Animation.cpp new file mode 100644 index 0000000..532f863 --- /dev/null +++ b/src/ui/controls/FUiCtrl_Animation.cpp @@ -0,0 +1,327 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Animation.cpp + * @brief This is the implementation file for the _Animation class. + */ + +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_Animation.h" +#include "FUiCtrl_AnimationPresenter.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_Animation); + +_Animation::_Animation(void) + : __pAnimationPresenter(null) + , __pControlAnimation(null) + , __pAnimationEvent(null) + , __pAnimationFrames(null) + , __pAccessibilityElement(null) +{ + _VisualElement* pBase = GetVisualElement(); + + if (pBase != null) + { + pBase->SetSurfaceOpaque(false); + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer) + { + pContainer->Activate(true); + } +} + +_Animation::~_Animation(void) +{ + if (__pAnimationEvent != null) + { + delete __pAnimationEvent; + __pAnimationEvent = null; + } + + if (__pAnimationFrames != null) + { + __pAnimationFrames->RemoveAll(false); + delete __pAnimationFrames; + __pAnimationFrames = null; + } + + delete __pAnimationPresenter; + __pAnimationPresenter = null; + + if (__pAccessibilityElement) + { + __pAccessibilityElement->Activate(false); + __pAccessibilityElement = null; + } +} + +_Animation* +_Animation::CreateAnimationN(void) +{ + result r = E_SUCCESS; + + _Animation* pAnimation = new (std::nothrow) _Animation(); + SysTryReturn(NID_UI_CTRL, pAnimation != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pAnimation->__pAnimationPresenter = _AnimationPresenter::CreateInstanceN(*pAnimation); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pAnimation->__pAnimationPresenter, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pAnimation->__pAnimationEvent = _AnimationEvent::CreateInstanceN(*pAnimation); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pAnimation->__pAnimationEvent, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pAnimation->AcquireHandle(); + pAnimation->SetFocusable(false); + + SetLastResult(E_SUCCESS); + + return pAnimation; + +CATCH: + delete pAnimation; + pAnimation = null; + + return null; +} + +void +_Animation::OnTimerExpired(Timer& timer) +{ + if (__pAnimationPresenter->IsTimerExpired(timer) == true) + { + IEventArg* pEventArg = _AnimationEvent::CreateAnimationEventArgN(); + if (pEventArg != null) + { + __pAnimationEvent->Fire(*pEventArg); + } + } + + return; +} + +result +_Animation::OnAttachedToMainTree(void) +{ + if (__pAccessibilityElement) + { + return E_SUCCESS; + } + + if (likely((_AccessibilityManager::IsActivated()))) + { + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if (pContainer) + { + __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + if (__pAccessibilityElement) + { + __pAccessibilityElement->SetBounds(Rectangle(0, 0, GetBounds().width, GetBounds().height)); + __pAccessibilityElement->SetLabel(L"Animation"); + __pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_NONE); + pContainer->AddElement(*__pAccessibilityElement); + } + } + } + + return E_SUCCESS; +} + +void +_Animation::OnBoundsChanged(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + if (__pAccessibilityElement) + { + __pAccessibilityElement->SetBounds(Rectangle(0, 0, GetBounds().width, GetBounds().height)); + } + + return; +} + +void +_Animation::SetImageCount(int imageCount) +{ + __pAnimationPresenter->SetImageCount(imageCount); + + return; +} + +result +_Animation::SetAnimationFrames(const IList& animationFrames) +{ + int frameCount = 0; + + ArrayList* pTempList = new (std::nothrow) ArrayList(); + SysTryReturnResult(NID_UI_CTRL, pTempList != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + result r = pTempList->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + frameCount = animationFrames.GetCount(); + + for (int index = 0; index < frameCount; index++) + { + AnimationFrame* pInputAnimationFrame = dynamic_cast (const_cast (animationFrames.GetAt(index))); + SysTryCatch(NID_UI_CTRL, pInputAnimationFrame != null, pTempList->RemoveAll(true), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the AnimationFrame at index %d", index); + + r = pTempList->Add(*pInputAnimationFrame); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, pTempList->RemoveAll(true), r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (__pAnimationFrames != null) + { + __pAnimationFrames->RemoveAll(true); + delete __pAnimationFrames; + } + __pAnimationFrames = pTempList; + + r = __pAnimationPresenter->SetAnimationFrames(__pAnimationFrames); + if (r != E_SUCCESS) + { + __pAnimationFrames->RemoveAll(true); + __pAnimationFrames = null; + goto CATCH; + } + + return r; + +CATCH: + delete pTempList; + pTempList = null; + + return r; +} + +IList* +_Animation::GetAnimationFrames(void) const +{ + return __pAnimationFrames; +} + +result +_Animation::AddAnimationEventListener(const _IAnimationEventListener& listener) +{ + return __pAnimationEvent->AddListener(listener); +} + +result +_Animation::RemoveAnimationEventListener(const _IAnimationEventListener& listener) +{ + return __pAnimationEvent->RemoveListener(listener); +} + +result +_Animation::SetPropertyRepeatCount(const Variant& repeatCount) +{ + SysTryReturnResult(NID_UI_CTRL, __pAnimationPresenter->GetStatus() == ANIMATION_STOPPED, E_SYSTEM, + "A system error has occurred. Repeat count cannot be set during animation play."); + + SysTryReturnResult(NID_UI_CTRL, repeatCount.ToInt() >= 0, E_INVALID_ARG, "Invalid argument(s) is used. Repeat count must be a positive integer."); + + __pAnimationPresenter->SetRepeatCount(repeatCount.ToInt()); + + return E_SUCCESS; +} + +result +_Animation::SetRepeatCount(int count) +{ + return SetProperty("repeatCount", Variant(count)); +} + +Variant +_Animation::GetPropertyRepeatCount(void) const +{ + return Variant(__pAnimationPresenter->GetRepeatCount()); +} + +int +_Animation::GetRepeatCount(void) const +{ + Variant repeatCount = GetProperty("repeatCount"); + + return repeatCount.ToInt(); +} + +int +_Animation::GetCurrentRepeatedCount(void) const +{ + return __pAnimationPresenter->GetCurrentRepeatedCount(); +} + +int +_Animation::GetImageCount(void) const +{ + return __pAnimationPresenter->GetImageCount(); +} + +result +_Animation::Play(void) +{ + return __pAnimationPresenter->Play(); +} + +result +_Animation::Stop(void) +{ + return __pAnimationPresenter->Stop(); +} + +result +_Animation::Pause(void) +{ + return __pAnimationPresenter->Pause(); +} + +AnimationStatus +_Animation::GetStatus(void) const +{ + return __pAnimationPresenter->GetStatus(); +} + +void +_Animation::OnDraw(void) +{ + result r = __pAnimationPresenter->Draw(); + + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_AnimationEvent.cpp b/src/ui/controls/FUiCtrl_AnimationEvent.cpp new file mode 100644 index 0000000..2bb86ab --- /dev/null +++ b/src/ui/controls/FUiCtrl_AnimationEvent.cpp @@ -0,0 +1,114 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_AnimationEvent.cpp +* @brief This is the implementation for the AnimationEvent class. +*/ + +#include +#include +#include +#include "FUiCtrl_IAnimationEventListener.h" +#include "FUiCtrl_AnimationEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _OSP_EXPORT_ _AnimationEventArg + : public IEventArg + , public Object +{ +public: + _AnimationEventArg(void); + virtual ~_AnimationEventArg(void); + +}; // _AnimationEventArg + +_AnimationEventArg::_AnimationEventArg(void) +{ +} + +_AnimationEventArg::~_AnimationEventArg(void) +{ +} + + +_AnimationEvent::_AnimationEvent(const _Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_AnimationEvent::~_AnimationEvent(void) +{ +} + +_AnimationEvent* +_AnimationEvent::CreateInstanceN(const _Control& source) +{ + _AnimationEvent* pAnimationEvent = new (std::nothrow) _AnimationEvent(source); + SysTryReturn(NID_UI_CTRL, pAnimationEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (IsFailed(GetLastResult())) + { + delete pAnimationEvent; + pAnimationEvent = null; + + return null; + } + + return pAnimationEvent; +} + +const _Control* +_AnimationEvent::GetSource(void) const +{ + return __pSource; +} + +void +_AnimationEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _IAnimationEventListener* pAnimationListener = dynamic_cast <_IAnimationEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pAnimationListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The _IAnimationEventListener instance is null."); + + pAnimationListener->OnAnimationStopped(*__pSource); + + SetLastResult(E_SUCCESS); + return; +} + +IEventArg* +_AnimationEvent::CreateAnimationEventArgN(void) +{ + _AnimationEventArg* pEventArg = new (std::nothrow) _AnimationEventArg(); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + SetLastResult(E_SUCCESS); + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_AnimationFrameImpl.cpp b/src/ui/controls/FUiCtrl_AnimationFrameImpl.cpp new file mode 100644 index 0000000..33c5c2c --- /dev/null +++ b/src/ui/controls/FUiCtrl_AnimationFrameImpl.cpp @@ -0,0 +1,101 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_AnimationFrameImpl.cpp + * @brief This is the implementation file for the _AnimationFrameImpl class. + */ + +#include +#include +#include +#include "FUiCtrl_AnimationFrameImpl.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_AnimationFrameImpl::_AnimationFrameImpl(void) + : __pFrame(null) + , __duration(0) +{ +} + +_AnimationFrameImpl::_AnimationFrameImpl(const Bitmap& frame, long duration) + : __pFrame(null) + , __duration(0) +{ + result r = E_SUCCESS; + + r = SetFrame(frame); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = SetDuration(duration); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return; + +CATCH: + delete __pFrame; + __pFrame = null; + + return; +} + +_AnimationFrameImpl::~_AnimationFrameImpl(void) +{ + delete __pFrame; + __pFrame = null; +} + +result +_AnimationFrameImpl::SetFrame(const Bitmap& frame) +{ + Bitmap* pNewFrame = _BitmapImpl::CloneN(frame); + result r = GetLastResult(); + + SysTryReturn(NID_UI_CTRL, pNewFrame != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pFrame; + __pFrame = pNewFrame; + + return r; +} + +const Bitmap* +_AnimationFrameImpl::GetFrame(void) const +{ + return __pFrame; +} + +result +_AnimationFrameImpl::SetDuration(long duration) +{ + SysTryReturnResult(NID_UI_CTRL, duration > 0, E_INVALID_ARG, "Invalid argument(s) is used. Duration must be a positive integer."); + + __duration = duration; + + return E_SUCCESS; +} + +long +_AnimationFrameImpl::GetDuration(void) const +{ + return __duration; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_AnimationImpl.cpp b/src/ui/controls/FUiCtrl_AnimationImpl.cpp new file mode 100644 index 0000000..d45c86d --- /dev/null +++ b/src/ui/controls/FUiCtrl_AnimationImpl.cpp @@ -0,0 +1,244 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_AnimationImpl.cpp + * @brief This is the implementation file for the _AnimationImpl class. + */ + +#include +#include +#include "FUiCtrl_AnimationImpl.h" +#include "FUiCtrl_Animation.h" + +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_AnimationImpl* +_AnimationImpl::GetInstance(Animation& animation) +{ + return static_cast<_AnimationImpl*> (animation._pControlImpl); +} + +const _AnimationImpl* +_AnimationImpl::GetInstance(const Animation& animation) +{ + return static_cast (animation._pControlImpl); +} + +_AnimationImpl::_AnimationImpl(Animation* pPublic, _Animation* pCore) + : _ControlImpl(pPublic, pCore) + , __pPublicAnimationEvent(null) +{ + SetFocusableChangable(false); +} + +_AnimationImpl::~_AnimationImpl(void) +{ + if (__pPublicAnimationEvent != null) + { + delete __pPublicAnimationEvent; + __pPublicAnimationEvent = null; + } +} + +_AnimationImpl* +_AnimationImpl::CreateAnimationImplN(Animation* pControl) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + _Animation* pCore = _Animation::CreateAnimationN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _AnimationImpl* pImpl = new (std::nothrow) _AnimationImpl(pControl, pCore); + + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl->__pPublicAnimationEvent = _PublicAnimationEvent::CreateInstanceN(*pControl); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pImpl->__pPublicAnimationEvent != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddAnimationEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; + +CATCH: + delete pImpl; + pImpl = null; + + return null; +} + +result +_AnimationImpl::SetAnimationFrames(const IList& animationFrames) +{ + ClearLastResult(); + + return GetCore().SetAnimationFrames(animationFrames); +} + +void +_AnimationImpl::SetImageCount(int imageCount) +{ + GetCore().SetImageCount(imageCount); + + return; +} + +result +_AnimationImpl::AddAnimationEventListener(IAnimationEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, __pPublicAnimationEvent, E_SYSTEM, "A system error has occurred. The _PublicAnimationEvent instance is null"); + + result r = __pPublicAnimationEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, "A system error has occurred. The IAnimationEventListener instance already exists in the event listener list."); + + return r; +} + +result +_AnimationImpl::RemoveAnimationEventListener(IAnimationEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, __pPublicAnimationEvent, E_SYSTEM, "A system error has occurred. The _PublicAnimationEvent instance is null"); + + result r = __pPublicAnimationEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, "A system error has occurred. The IAnimationEventListener instance does not exist in the event listener list."); + + return r; +} + +result +_AnimationImpl::SetRepeatCount(int count) +{ + ClearLastResult(); + + Variant repeatCount(count); + + return GetCore().SetPropertyRepeatCount(repeatCount); +} + +int +_AnimationImpl::GetRepeatCount(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyRepeatCount().ToInt(); +} + +int +_AnimationImpl::GetCurrentRepeatedCount(void) const +{ + ClearLastResult(); + + return GetCore().GetCurrentRepeatedCount(); +} + +int +_AnimationImpl::GetImageCount(void) const +{ + ClearLastResult(); + + return GetCore().GetImageCount(); +} + +result +_AnimationImpl::Play(void) +{ + ClearLastResult(); + + return GetCore().Play(); +} + +result +_AnimationImpl::Stop(void) +{ + ClearLastResult(); + + return GetCore().Stop(); +} + +result +_AnimationImpl::Pause(void) +{ + ClearLastResult(); + + return GetCore().Pause(); +} + +AnimationStatus +_AnimationImpl::GetStatus(void) const +{ + return GetCore().GetStatus(); +} + +void +_AnimationImpl::OnAnimationStopped(const _Control& source) +{ + IEventArg* pEventArg = _PublicAnimationEvent::CreateAnimationEventArgN(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pPublicAnimationEvent->Fire(*pEventArg); + + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return; +} + +const char* +_AnimationImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::Animation"; +} + +const Animation& +_AnimationImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +Animation& +_AnimationImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Animation& +_AnimationImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Animation& +_AnimationImpl::GetCore(void) +{ + return static_cast <_Animation&>(_ControlImpl::GetCore()); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_AnimationModel.cpp b/src/ui/controls/FUiCtrl_AnimationModel.cpp new file mode 100644 index 0000000..6b375d2 --- /dev/null +++ b/src/ui/controls/FUiCtrl_AnimationModel.cpp @@ -0,0 +1,96 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_AnimationModel.cpp + * @brief This is the implementation file for the _AnimationModel class. + */ + +#include "FUiCtrl_AnimationModel.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +_AnimationModel::_AnimationModel(void) + : __animationStatus(ANIMATION_STOPPED) + , __imageCount(0) + , __repeatCount(1) + , __currentRepeatedCount(0) +{ +} + +_AnimationModel::~_AnimationModel(void) +{ +} + +void +_AnimationModel::SetAnimationStatus(AnimationStatus status) +{ + __animationStatus = status; + + return; +} + +AnimationStatus +_AnimationModel::GetAnimationStatus(void) const +{ + return __animationStatus; +} + +void +_AnimationModel::SetImageCount(int imageCount) +{ + __imageCount = imageCount; + + return; +} + +int +_AnimationModel::GetImageCount(void) const +{ + return __imageCount; +} + +void +_AnimationModel::SetRepeatCount(int repeatCount) +{ + __repeatCount = repeatCount; + + return; +} + +int +_AnimationModel::GetRepeatCount(void) const +{ + return __repeatCount; +} + +void +_AnimationModel::SetCurrentRepeatedCount(int currentRepeatCount) +{ + __currentRepeatedCount = currentRepeatCount; + + return; +} + +int +_AnimationModel::GetCurrentRepeatedCount(void) const +{ + return __currentRepeatedCount; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_AnimationPresenter.cpp b/src/ui/controls/FUiCtrl_AnimationPresenter.cpp new file mode 100644 index 0000000..a6082ed --- /dev/null +++ b/src/ui/controls/FUiCtrl_AnimationPresenter.cpp @@ -0,0 +1,388 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_AnimationPresenter.cpp + * @brief This is the implementation file for the _AnimationPresenter class. + */ + +#include +#include +#include "FUiCtrl_AnimationPresenter.h" +#include "FUiCtrl_Animation.h" +#include "FUiCtrl_AnimationModel.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_AnimationPresenter::_AnimationPresenter(void) + : __pAnimation(null) + , __pAnimationModel(null) + , __pTimer(null) + , __pCurrentFrame(null) + , __isTimerRunning(false) + , __pVisualElement(null) +{ +} + +_AnimationPresenter::~_AnimationPresenter(void) +{ + Dispose(); +} + +_AnimationPresenter* +_AnimationPresenter::CreateInstanceN(const _Animation& animation) +{ + result r = E_SUCCESS; + + _AnimationPresenter* pAnimationPresenter = new (std::nothrow) _AnimationPresenter(); + SysTryReturn(NID_UI_CTRL, pAnimationPresenter != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pAnimationPresenter->Initialize(animation); + + if (r != E_SUCCESS) + { + SysLogException(NID_UI_CTRL, r, "Failed to initialize the Animation Presenter."); + + delete pAnimationPresenter; + pAnimationPresenter = null; + + return null; + } + + return pAnimationPresenter; +} + +result +_AnimationPresenter::Initialize(const _Animation& animation) +{ + result r = E_SUCCESS; + + __pAnimation = const_cast <_Animation*>(&animation); + SysTryReturnResult(NID_UI_CTRL, __pAnimation != null, E_SYSTEM, "A system error has occurred. Animation control core is null."); + + __pAnimationModel = new (std::nothrow) _AnimationModel(); + SysTryCatch(NID_UI_CTRL, __pAnimationModel != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTimer = new (std::nothrow) Timer(); + SysTryCatch(NID_UI_CTRL, __pTimer != null, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to create a new timer."); + + r = __pTimer->Construct(*__pAnimation); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[E_SYSTEM] A system error has occurred. Failed to construct the timer."); + + __pVisualElement = __pAnimation->GetVisualElement(); + SysTryCatch(NID_UI_CTRL, __pVisualElement != null, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the root visual element"); + + return r; + +CATCH: + Dispose(); + return r; +} + +bool +_AnimationPresenter::IsTimerExpired(Timer& timer) +{ + bool isTimerExpired = false; + + __isTimerRunning = false; + SysTryReturn(NID_UI_CTRL, __pAnimationModel->GetAnimationStatus() == ANIMATION_PLAYING, false, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Animation is in ANIMATION_PLAYING state."); + + AnimationFrame* pNextFrame = GetNextFrame(); + SysTryReturn(NID_UI_CTRL, pNextFrame != null, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the next animation frame."); + + if (__pAnimationModel->GetCurrentRepeatedCount() < __pAnimationModel->GetRepeatCount()) + { + if (timer.Start(pNextFrame->GetDuration()) == E_SUCCESS) + { + __isTimerRunning = true; + } + else + { + __pAnimationModel->SetAnimationStatus(ANIMATION_PAUSED); + } + isTimerExpired = false; + } + else + { + __pAnimationModel->SetCurrentRepeatedCount(0); + + __pAnimationModel->SetAnimationStatus(ANIMATION_STOPPED); + isTimerExpired = true; + } + + result r = Draw(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + return isTimerExpired; +} + +void +_AnimationPresenter::SetImageCount(int imageCount) +{ + __pAnimationModel->SetImageCount(imageCount); + + return; +} + +result +_AnimationPresenter::SetAnimationFrames(const IList* pAnimationFrames) +{ + SysTryReturnResult(NID_UI_CTRL, pAnimationFrames != null, E_SYSTEM, "A system error has occurred. AnimationFrame list is null"); + + __pCurrentFrame = pAnimationFrames->GetEnumeratorN(); + SysTryReturnResult(NID_UI_CTRL, __pCurrentFrame != null, E_SYSTEM, "A system error has occurred. Failed to get the AnimationFrame list."); + + return E_SUCCESS; +} + +void +_AnimationPresenter::SetRepeatCount(int count) +{ + __pAnimationModel->SetRepeatCount(count); + + return; +} + +int +_AnimationPresenter::GetRepeatCount(void) const +{ + return __pAnimationModel->GetRepeatCount(); +} + +int +_AnimationPresenter::GetCurrentRepeatedCount(void) const +{ + return __pAnimationModel->GetCurrentRepeatedCount(); +} + +int +_AnimationPresenter::GetImageCount(void) const +{ + return __pAnimationModel->GetImageCount(); +} + +result +_AnimationPresenter::Play(void) +{ + result r = E_SUCCESS; + + if (__isTimerRunning == true) + { + return E_SUCCESS; + } + + if (__pAnimationModel->GetAnimationStatus() != ANIMATION_PAUSED) + { + __pAnimationModel->SetCurrentRepeatedCount(0); + } + + AnimationFrame* pFrame = dynamic_cast (__pCurrentFrame->GetCurrent()); + + if (pFrame == null) + { + pFrame = GetNextFrame(); + SysTryReturnResult(NID_UI_CTRL, pFrame != null, E_SYSTEM, "A system error has occurred. Failed to get the next AnimationFrame."); + + r = Draw(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pTimer->Start(pFrame->GetDuration()); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "A system error has occurred. Failed to start the timer"); + + __isTimerRunning = true; + __pAnimationModel->SetAnimationStatus(ANIMATION_PLAYING); + + return r; +} + +result +_AnimationPresenter::Stop(void) +{ + if (__isTimerRunning == true) + { + if (__pTimer != null) + { + __pTimer->Cancel(); + } + __isTimerRunning = false; + } + + __pAnimationModel->SetCurrentRepeatedCount(0); + __pCurrentFrame->Reset(); + __pAnimationModel->SetAnimationStatus(ANIMATION_STOPPED); + + result r = Draw(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_AnimationPresenter::Pause(void) +{ + SysTryReturnResult(NID_UI_CTRL, __isTimerRunning == true, E_SYSTEM, "A system error has occurred. Timer is not in running state."); + + if (__pTimer != null) + { + __pTimer->Cancel(); + } + __isTimerRunning = false; + + __pAnimationModel->SetAnimationStatus(ANIMATION_PAUSED); + + return E_SUCCESS; +} + +AnimationStatus +_AnimationPresenter::GetStatus(void) const +{ + return __pAnimationModel->GetAnimationStatus(); +} + +AnimationFrame* +_AnimationPresenter::GetCurrentFrame(void) const +{ + AnimationFrame* pFrame = dynamic_cast (__pCurrentFrame->GetCurrent()); + + if (pFrame != null) + { + return pFrame; + } + + int imageCount = __pAnimationModel->GetImageCount(); + for (int index = 0; index < imageCount; index++) + { + if (__pCurrentFrame->MoveNext() == E_OUT_OF_RANGE) + { + __pCurrentFrame->Reset(); + } + + pFrame = dynamic_cast (__pCurrentFrame->GetCurrent()); + + if (pFrame != null) + { + break; + } + } + + return pFrame; +} + +AnimationFrame* +_AnimationPresenter::GetNextFrame(void) const +{ + AnimationFrame* pNextFrame = null; + + int imageCount = __pAnimationModel->GetImageCount(); + for (int index = 0; index < imageCount; index++) + { + if (__pCurrentFrame->MoveNext() == E_SUCCESS) + { + pNextFrame = dynamic_cast (__pCurrentFrame->GetCurrent()); + + if (pNextFrame != null) + { + break; + } + } + else + { + __pCurrentFrame->Reset(); + int currentRepeatedCount = __pAnimationModel->GetCurrentRepeatedCount(); + __pAnimationModel->SetCurrentRepeatedCount(++currentRepeatedCount); + } + } + + return pNextFrame; +} + +result +_AnimationPresenter::Dispose(void) +{ + __pAnimation = null; + + delete __pCurrentFrame; + __pCurrentFrame = null; + + if (__pTimer != null && __isTimerRunning == true) + { + __pTimer->Cancel(); + } + + delete __pTimer; + __pTimer = null; + + delete __pAnimationModel; + __pAnimationModel = null; + + __pVisualElement = null; + + return E_SUCCESS; +} + +result +_AnimationPresenter::Draw(void) +{ + result r = E_SUCCESS; + + Rectangle bounds = __pAnimation->GetBounds(); + Color bgColor = __pAnimation->GetBackgroundColor(); + Canvas* pCanvas = null; + AnimationFrame* pFrame = null; + Bitmap* pBitmap = null; + + pFrame = GetCurrentFrame(); + SysTryCatch(NID_UI_CTRL, pFrame != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the current animation frame."); + + pBitmap = const_cast (pFrame->GetFrame()); + + if (pBitmap != null) + { + pCanvas = __pAnimation->GetCanvasN(); + + SysTryReturnResult(NID_UI_CTRL, pCanvas != null, E_SYSTEM, "A system error has occurred. Failed to get the animation canvas."); + + pCanvas->SetBackgroundColor(Color()); + pCanvas->Clear(); + + if (pBitmap->IsNinePatchedBitmap()) + { + r = pCanvas->DrawNinePatchedBitmap(bounds, *pBitmap); + } + else + { + r = pCanvas->DrawBitmap(Rectangle(0, 0, bounds.width, bounds.height), *pBitmap); + } + + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw the bitmap", GetErrorMessage(r)); + } + +CATCH: + delete pCanvas; + pCanvas = null; + + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Button.cpp b/src/ui/controls/FUiCtrl_Button.cpp new file mode 100644 index 0000000..f62a29c --- /dev/null +++ b/src/ui/controls/FUiCtrl_Button.cpp @@ -0,0 +1,1210 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Button.cpp + * @brief This is the implementation file for the _Button class. + */ + +#include +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityManager.h" +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_ButtonPresenter.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_Button); + +_Button::_Button() + : __pButtonPresenter(null) + , __pActionEvent(null) + , __actionId(0) + , __text(L"") + , __horizontalAlignment(ALIGNMENT_CENTER) + , __verticalAlignment(ALIGNMENT_MIDDLE) + , __buttonStatus(_BUTTON_STATUS_NORMAL) + , __buttonStyle(_BUTTON_STYLE_NORMAL) + , __textSize(0) + , __textMaxLine(2) + , __parentMoveDistance(0) + , __previousTouchArea(false) + , __userDefinedText(false) + , __topMargin(0) + , __leftMargin(0) + , __drawInner(false) + , __userDefinedTextArea(0,0,0,0) + , __pTextElement(null) +{ + result r = E_SUCCESS; + + _AccessibilityContainer* pContainer = null; + + GET_SHAPE_CONFIG(BUTTON::DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __textSize); + + _ButtonPresenter* pPresenter = new (std::nothrow) _ButtonPresenter(); + SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = SetPresenter(*pPresenter); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pPresenter->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pPresenter->Install(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + for (int i = 0; i < NUMBER_OF_BUTTON_STATUS; i++) + { + __pBitmap[i] = null; + __pToolbarItemBackgroundBitmap[i] = null; + __pBackgroundBitmap[i] = null; + __pBackgroundEffectBitmap[i] = null; + __isUserBackgroundBitmap[i] = false; + __isUserBackgroundEffectBitmap[i] = false; + } + + __pToolbarSelectedBitmap = null; + + GET_COLOR_CONFIG(BUTTON::BG_NORMAL, __color[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(BUTTON::BG_DISABLED, __color[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(BUTTON::BG_PRESSED, __color[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(BUTTON::BG_HIGHLIGHTED, __color[_BUTTON_STATUS_HIGHLIGHTED]); + GET_COLOR_CONFIG(BUTTON::BG_PRESSED, __color[_BUTTON_STATUS_SELECTED]); + + GET_COLOR_CONFIG(BUTTON::TEXT_NORMAL, __textColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(BUTTON::TEXT_DISABLED, __textColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(BUTTON::TEXT_PRESSED, __textColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(BUTTON::TEXT_HIGHLIGHTED, __textColor[_BUTTON_STATUS_HIGHLIGHTED]); + GET_COLOR_CONFIG(BUTTON::TEXT_PRESSED, __textColor[_BUTTON_STATUS_SELECTED]); + + GET_SHAPE_CONFIG(BUTTON::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __topMargin); + GET_SHAPE_CONFIG(BUTTON::LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __leftMargin); + + AddPropertyChangeEventListener(*this); + + pContainer = GetAccessibilityContainer(); + + if(pContainer) + { + pContainer->Activate(true); + } + + ClearLastResult(); + + return; + +CATCH: + delete pPresenter; +} + +_Button* +_Button::CreateButtonN(void) +{ + _Button* pButton = new (std::nothrow) _Button(); + SysTryReturn(NID_UI_CTRL, pButton, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pButton->AcquireHandle(); + + return pButton; + +CATCH: + delete pButton; + return null; +} + +_Button::~_Button(void) +{ + if (__pButtonPresenter) + { + delete __pButtonPresenter; + __pButtonPresenter = null; + } + + if (__pActionEvent) + { + delete __pActionEvent; + __pActionEvent = null; + } + + for (int i = 0; i < NUMBER_OF_BUTTON_STATUS; i++) + { + if (__pBitmap[i]) + { + delete __pBitmap[i]; + __pBitmap[i] = null; + } + + if (__pToolbarItemBackgroundBitmap[i]) + { + delete __pToolbarItemBackgroundBitmap[i]; + __pToolbarItemBackgroundBitmap[i] = null; + } + + if (__pBackgroundBitmap[i]) + { + delete __pBackgroundBitmap[i]; + __pBackgroundBitmap[i] = null; + } + + if (__pBackgroundEffectBitmap[i]) + { + delete __pBackgroundEffectBitmap[i]; + __pBackgroundEffectBitmap[i] = null; + } + } + + if (__pToolbarSelectedBitmap) + { + delete __pToolbarSelectedBitmap; + __pToolbarSelectedBitmap = null; + } + + if (__pTextElement) + { + __pTextElement->Activate(false); + __pTextElement = null; + } + + ClearLastResult(); +} + +result +_Button::SetPresenter(const _ButtonPresenter& buttonPresenter) +{ + __pButtonPresenter = const_cast<_ButtonPresenter*>(&buttonPresenter); + + return E_SUCCESS; +} + +void +_Button::OnDraw(void) +{ + __pButtonPresenter->Draw(); + + return; +} + +result +_Button::OnAttachedToMainTree(void) +{ + InitializeAccessibilityElement(); + + return E_SUCCESS; +} + +void +_Button::InitializeAccessibilityElement(void) +{ + if(__pTextElement) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if(pContainer) + { + __pTextElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pTextElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pTextElement->SetBounds(Rectangle(0,0, GetBounds().width, GetBounds().height)); + __pTextElement->SetLabel(GetText()); + __pTextElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON); + __pTextElement->SetName(L"ButtonText"); + + pContainer->AddElement(*__pTextElement); + } + + return; +} + +void +_Button::OnPropertyChanging(_PropertyBase& source, const String& name, const Variant& oldValue, const Variant& newValue) +{ + return; +} + +void +_Button::OnPropertyChanged(_PropertyBase& source, const String& name, const Variant& oldValue, const Variant& newValue) +{ + return; +} + +bool +_Button::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pButtonPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_Button::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pButtonPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_Button::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pButtonPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_Button::OnTouchCanceled(const _Control & source, const _TouchInfo & touchinfo) +{ + return __pButtonPresenter->OnTouchCanceled(source, touchinfo); +} + +void +_Button::OnTouchMoveHandled(const _Control& control) +{ + __pButtonPresenter->OnTouchMoveHandled(control); + + return; +} + +void +_Button::OnBoundsChanged(void) +{ + if(__pTextElement) + { + __pTextElement->SetBounds(Rectangle(0,0, GetBounds().width, GetBounds().height)); + } + + return; +} + +void +_Button::OnFontChanged(Font* pFont) +{ + __pButtonPresenter->OnFontChanged(pFont); + + return; +} + +void +_Button::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pButtonPresenter->OnFontInfoRequested(style, size); + + return; +} + +result +_Button::SetText(const String& text) +{ + return SetProperty("text", Variant(text)); +} + +result +_Button::SetPropertyText(const Variant& text) +{ + __text = text.ToString(); + + if(__pTextElement) + { + __pTextElement->SetLabel(__text); + } + + result r = __pButtonPresenter->InitTextObject(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +String +_Button::GetText(void) const +{ + Variant text = GetProperty("text"); + + return text.ToString(); +} + +Variant +_Button::GetPropertyText(void) const +{ + return Variant(__text); +} + +result +_Button::SetColor(_ButtonStatus status, const Color& color) +{ + result r = E_SUCCESS; + + switch (status) + { + case _BUTTON_STATUS_NORMAL: + r = SetProperty("normalColor", Variant(color)); + break; + case _BUTTON_STATUS_DISABLED: + r = SetProperty("disabledColor", Variant(color)); + break; + case _BUTTON_STATUS_PRESSED: + r = SetProperty("pressedColor", Variant(color)); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + r = SetProperty("highlightedColor", Variant(color)); + break; + default: + r = SetProperty("selectedColor", Variant(color)); + } + + return r; +} + +result +_Button::SetPropertyNormalColor(const Variant& color) +{ + __color[_BUTTON_STATUS_NORMAL] = color.ToColor(); + + return E_SUCCESS; +} + +result +_Button::SetPropertyDisabledColor(const Variant& color) +{ + __color[_BUTTON_STATUS_DISABLED] = color.ToColor(); + + return E_SUCCESS; +} + +result +_Button::SetPropertyPressedColor(const Variant& color) +{ + __color[_BUTTON_STATUS_PRESSED] = color.ToColor(); + + return E_SUCCESS; +} + +result +_Button::SetPropertyHighlightedColor(const Variant& color) +{ + __color[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor(); + + return E_SUCCESS; +} + +result +_Button::SetPropertySelectedColor(const Variant& color) +{ + __color[_BUTTON_STATUS_SELECTED] = color.ToColor(); + + return E_SUCCESS; +} + +Color +_Button::GetColor(_ButtonStatus status) const +{ + Variant color; + + switch (status) + { + case _BUTTON_STATUS_NORMAL: + color = GetProperty("normalColor"); + break; + case _BUTTON_STATUS_DISABLED: + color = GetProperty("disabledColor"); + break; + case _BUTTON_STATUS_PRESSED: + color = GetProperty("pressedColor"); + break;; + case _BUTTON_STATUS_HIGHLIGHTED: + color = GetProperty("highlightedColor"); + break; + default: + color = GetProperty("selectedColor"); + } + + return color.ToColor(); +} + +Variant +_Button::GetPropertyNormalColor(void) const +{ + return Variant(__color[_BUTTON_STATUS_NORMAL]); +} + +Variant +_Button::GetPropertyDisabledColor(void) const +{ + return Variant(__color[_BUTTON_STATUS_DISABLED]); +} + +Variant +_Button::GetPropertyPressedColor(void) const +{ + return Variant(__color[_BUTTON_STATUS_PRESSED]); +} + +Variant +_Button::GetPropertyHighlightedColor(void) const +{ + return Variant(__color[_BUTTON_STATUS_HIGHLIGHTED]); +} + +Variant +_Button::GetPropertySelectedColor(void) const +{ + return Variant(__color[_BUTTON_STATUS_SELECTED]); +} + +result +_Button::AddActionEventListener(const _IActionEventListener& listener) +{ + if (__pActionEvent == null) + { + __pActionEvent = _ActionEvent::CreateInstanceN(*this); + SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + } + + result r = __pActionEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_Button::RemoveActionEventListener(const _IActionEventListener& listener) +{ + result r = E_OBJ_NOT_FOUND; + + if (__pActionEvent) + { + r = __pActionEvent->RemoveListener(listener); + } + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_Button::SetActionId(int actionId) +{ + return SetProperty("actionId", Variant(actionId)); +} + +result +_Button::SetPropertyActionId(const Variant& actionId) +{ + __actionId = actionId.ToInt(); + + return E_SUCCESS; +} + +int +_Button::GetActionId(void) const +{ + Variant actionId = GetProperty("actionId"); + + return actionId.ToInt(); +} + +Variant +_Button::GetPropertyActionId(void) const +{ + return Variant(__actionId); +} + +result +_Button::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + __horizontalAlignment = alignment; + + return E_SUCCESS; +} + +HorizontalAlignment +_Button::GetTextHorizontalAlignment(void) const +{ + return __horizontalAlignment; +} + +result +_Button::SetTextVerticalAlignment(VerticalAlignment alignment) +{ + __verticalAlignment = alignment; + + return E_SUCCESS; +} + +VerticalAlignment +_Button::GetTextVerticalAlignment(void) const +{ + return __verticalAlignment; +} + +result +_Button::SetTextColor(_ButtonStatus status, const Color& color) +{ + result r = E_SUCCESS; + + switch (status) + { + case _BUTTON_STATUS_NORMAL: + r = SetProperty("normalTextColor", Variant(color)); + break; + case _BUTTON_STATUS_DISABLED: + r = SetProperty("disabledTextColor", Variant(color)); + break; + case _BUTTON_STATUS_PRESSED: + r = SetProperty("pressedTextColor", Variant(color)); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + r = SetProperty("highlightedTextColor", Variant(color)); + break; + default: + r = SetProperty("selectedTextColor", Variant(color)); + } + + return r; +} + +result +_Button::SetPropertyNormalTextColor(const Variant& color) +{ + __textColor[_BUTTON_STATUS_NORMAL] = color.ToColor(); + + return E_SUCCESS; +} + +result +_Button::SetPropertyDisabledTextColor(const Variant& color) +{ + __textColor[_BUTTON_STATUS_DISABLED] = color.ToColor(); + + return E_SUCCESS; +} + +result +_Button::SetPropertyPressedTextColor(const Variant& color) +{ + __textColor[_BUTTON_STATUS_PRESSED] = color.ToColor(); + + return E_SUCCESS; +} + +result +_Button::SetPropertyHighlightedTextColor(const Variant& color) +{ + __textColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor(); + + return E_SUCCESS; +} + +result +_Button::SetPropertySelectedTextColor(const Variant& color) +{ + __textColor[_BUTTON_STATUS_SELECTED] = color.ToColor(); + + return E_SUCCESS; +} + +Color +_Button::GetTextColor(_ButtonStatus status) const +{ + Variant color; + + switch (status) + { + case _BUTTON_STATUS_NORMAL: + color = GetProperty("normalTextColor"); + break; + case _BUTTON_STATUS_DISABLED: + color = GetProperty("disabledTextColor"); + break; + case _BUTTON_STATUS_PRESSED: + color = GetProperty("pressedTextColor"); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + color = GetProperty("highlightedTextColor"); + break; + default: + color = GetProperty("selectedTextColor"); + } + + return color.ToColor(); +} + +Variant +_Button::GetPropertyNormalTextColor(void) const +{ + return Variant(__textColor[_BUTTON_STATUS_NORMAL]); +} + +Variant +_Button::GetPropertyDisabledTextColor(void) const +{ + return Variant(__textColor[_BUTTON_STATUS_DISABLED]); +} + +Variant +_Button::GetPropertyPressedTextColor(void) const +{ + return Variant(__textColor[_BUTTON_STATUS_PRESSED]); +} + +Variant +_Button::GetPropertyHighlightedTextColor(void) const +{ + return Variant(__textColor[_BUTTON_STATUS_HIGHLIGHTED]); +} + +Variant +_Button::GetPropertySelectedTextColor(void) const +{ + return Variant(__textColor[_BUTTON_STATUS_SELECTED]); +} + +result +_Button::SetBitmap(_ButtonStatus status, const Point& position, const Bitmap& bitmap) +{ + result r = E_SYSTEM; + + Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap); + + if (pClonedBitmap) + { + __bitmapPosition[status] = position; + + if (__pBitmap[status] != null) + { + delete __pBitmap[status]; + } + + __pBitmap[status] = pClonedBitmap; + + r = E_SUCCESS; + } + + return r; +} + +Bitmap* +_Button::GetBitmap(_ButtonStatus status) const +{ + return __pBitmap[status]; +} + +result +_Button::SetToolbarItemBackgroundBitmap(_ButtonStatus status, const Bitmap& bitmap) +{ + result r = E_SYSTEM; + + Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap); + + if (pClonedBitmap) + { + if (__pToolbarItemBackgroundBitmap[status] != null) + { + delete __pToolbarItemBackgroundBitmap[status]; + } + + __pToolbarItemBackgroundBitmap[status] = pClonedBitmap; + + r = E_SUCCESS; + } + + return r; +} + +Bitmap* +_Button::GetToolbarItemBackgroundBitmap(_ButtonStatus status) const +{ + return __pToolbarItemBackgroundBitmap[status]; +} + +result +_Button::SetToolbarSelectedBitmap(const Tizen::Graphics::Bitmap& bitmap, bool drawInner) +{ + result r = E_SYSTEM; + + Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap); + + if (pClonedBitmap) + { + if (__pToolbarSelectedBitmap != null) + { + delete __pToolbarSelectedBitmap; + } + + __pToolbarSelectedBitmap = pClonedBitmap; + + r = E_SUCCESS; + } + + __drawInner = drawInner; + + return r; +} + +bool +_Button::IsDrawInner(void) const +{ + return __drawInner; +} + +Tizen::Graphics::Bitmap* +_Button::GetToolbarSelectedBitmap(void) const +{ + return __pToolbarSelectedBitmap; +} + +Point +_Button::GetBitmapPosition(_ButtonStatus status) const +{ + return __bitmapPosition[status]; +} + +result +_Button::SetBackgroundBitmap(_ButtonStatus status, const Bitmap& bitmap) +{ + result r = E_SYSTEM; + + Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap); + + if (pClonedBitmap) + { + if (__pBackgroundBitmap[status] != null) + { + delete __pBackgroundBitmap[status]; + } + + __pBackgroundBitmap[status] = pClonedBitmap; + __isUserBackgroundBitmap[status] = true; + + r = E_SUCCESS; + } + + return r; +} + +Bitmap* +_Button::GetBackgroundBitmap(_ButtonStatus status) const +{ + result r = E_SYSTEM; + + _Button* pButton = const_cast<_Button*>(this); + + if (!pButton->__pBackgroundBitmap[status]) + { + switch(status) + { + case _BUTTON_STATUS_NORMAL: + r = GET_BITMAP_CONFIG_N(BUTTON::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundBitmap[_BUTTON_STATUS_NORMAL]); + break; + case _BUTTON_STATUS_DISABLED: + r = GET_BITMAP_CONFIG_N(BUTTON::BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundBitmap[_BUTTON_STATUS_DISABLED]); + break; + case _BUTTON_STATUS_PRESSED: + r = GET_BITMAP_CONFIG_N(BUTTON::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundBitmap[_BUTTON_STATUS_PRESSED]); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + r = GET_BITMAP_CONFIG_N(BUTTON::BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundBitmap[_BUTTON_STATUS_HIGHLIGHTED]); + break; + default: + r = GET_BITMAP_CONFIG_N(BUTTON::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundBitmap[_BUTTON_STATUS_SELECTED]); + break; + } + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pButton->__pBackgroundBitmap[status]; +} + +result +_Button::SetBackgroundEffectBitmap(_ButtonStatus status, const Bitmap& bitmap) +{ + result r = E_SYSTEM; + + Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap); + + if (pClonedBitmap) + { + if (__pBackgroundEffectBitmap[status] != null) + { + delete __pBackgroundEffectBitmap[status]; + } + + __pBackgroundEffectBitmap[status] = pClonedBitmap; + __isUserBackgroundEffectBitmap[status] = true; + + r= E_SUCCESS; + } + + return r; +} + +Bitmap* +_Button::GetBackgroundEffectBitmap(_ButtonStatus status) const +{ + result r = E_SYSTEM; + + _Button* pButton = const_cast<_Button*>(this); + + if (!pButton->__pBackgroundEffectBitmap[status]) + { + switch(status) + { + case _BUTTON_STATUS_NORMAL: + r = GET_BITMAP_CONFIG_N(BUTTON::BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundEffectBitmap[_BUTTON_STATUS_NORMAL]); + break; + case _BUTTON_STATUS_DISABLED: + r = GET_BITMAP_CONFIG_N(BUTTON::BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundEffectBitmap[_BUTTON_STATUS_DISABLED]); + break; + case _BUTTON_STATUS_PRESSED: + r = GET_BITMAP_CONFIG_N(BUTTON::BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundEffectBitmap[_BUTTON_STATUS_PRESSED]); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + r = GET_BITMAP_CONFIG_N(BUTTON::BG_EFFECT_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundEffectBitmap[_BUTTON_STATUS_HIGHLIGHTED]); + break; + default: + r = GET_BITMAP_CONFIG_N(BUTTON::BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundEffectBitmap[_BUTTON_STATUS_SELECTED]); + break; + } + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pButton->__pBackgroundEffectBitmap[status]; +} + +result +_Button::SetTextSize(int size, unsigned long fontStyle) +{ + __pButtonPresenter->SetTextSize(size, fontStyle); + + return SetProperty("textSize", Variant(size)); +} + +result +_Button::SetPropertyTextSize(const Variant& textSize) +{ + result r = E_SUCCESS; + + if (textSize.ToInt() > 0) + { + __textSize = textSize.ToInt(); + } + else + { + r = E_INVALID_ARG; + SysLogException(NID_UI_CTRL, r, "[E_INVALID_ARG] Text size is no greater than 0."); + } + + return r; +} + +int +_Button::GetTextSize(void) const +{ + Variant size = GetProperty("textSize"); + + return size.ToInt(); +} + +Variant +_Button::GetPropertyTextSize(void) const +{ + return Variant(__textSize); +} + +result +_Button::SetButtonStyle(_ButtonStyle buttonStyle) +{ + __buttonStyle = buttonStyle; + + return E_SUCCESS; +} + +_ButtonStyle +_Button::GetButtonStyle(void) const +{ + return __buttonStyle; +} + +result +_Button::SetButtonStatus(_ButtonStatus buttonStatus, bool fire) +{ + result r = E_SUCCESS; + + if (__buttonStatus != buttonStatus) + { + __buttonStatus = buttonStatus; + } + + if (_BUTTON_STATUS_DISABLED == __buttonStatus) + { + SetEnableState(false); + } + else + { + SetEnableState(true); + } + + if (_BUTTON_STATUS_SELECTED == __buttonStatus && fire) + { + r = FireActionEvent(); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + } + if(__pTextElement) + { + if(buttonStatus == _BUTTON_STATUS_SELECTED ) + { + __pTextElement->SetStatus(L"Selected"); + } + else + { + __pTextElement->SetStatus(L""); + } + } + return r; +} + +_ButtonStatus +_Button::GetButtonStatus(void) const +{ + _ButtonStatus status = __buttonStatus; + + if (!IsEnabled()) + { + status = _BUTTON_STATUS_DISABLED; + } + + return status; +} + +result +_Button::SetTextMaxLine(int textMaxLine) +{ + __textMaxLine = textMaxLine; + + return E_SUCCESS; +} + +int +_Button::GetTextMaxLine(void) const +{ + return __textMaxLine; +} + +result +_Button::UnloadBackgroundBitmap(_ButtonStatus status) +{ + if (__pBackgroundBitmap[status] != null) + { + delete __pBackgroundBitmap[status]; + __pBackgroundBitmap[status] = null; + } + return E_SUCCESS; +} + +result +_Button::UnloadBackgroundEffectBitmap(_ButtonStatus status) +{ + if (__pBackgroundEffectBitmap[status] != null) + { + delete __pBackgroundEffectBitmap[status]; + __pBackgroundEffectBitmap[status] = null; + } + return E_SUCCESS; +} + +bool +_Button::IsUserBackgroundBitmap(_ButtonStatus status) const +{ + return __isUserBackgroundBitmap[status]; +} + +bool +_Button::IsUserBackgroundEffectBitmap(_ButtonStatus status) const +{ + return __isUserBackgroundEffectBitmap[status]; +} + +bool +_Button::IsTouchAreaChanged(bool currentButtonArea) +{ + if (__previousTouchArea != currentButtonArea) + { + __previousTouchArea = currentButtonArea; + return true; + } + else + { + return false; + } +} + +result +_Button::FireActionEvent(void) +{ + result r = E_SUCCESS; + + if (__pActionEvent) + { + IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId); + SysTryReturn(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + __pActionEvent->Fire(*pEventArg); + } + + return r; +} + +result +_Button::SetUserDefinedTextArea(const Rectangle& bounds) +{ + __userDefinedText = true; + __userDefinedTextArea = bounds; + + return E_SUCCESS; +} + +Rectangle +_Button::GetUserDefinedTextArea(void) const +{ + return __userDefinedTextArea; +} + +bool +_Button::UserDefinedText(void) const +{ + return __userDefinedText; +} + +result +_Button::SetMargin(int topMargin, int leftMargin) +{ + __topMargin = topMargin; + __leftMargin = leftMargin; + + return E_SUCCESS; +} + +int +_Button::GetTopMargin(void) const +{ + return __topMargin; +} + +int +_Button::GetLeftMargin(void) const +{ + return __leftMargin; +} + +Tizen::Graphics::Dimension +_Button::GetContentSize(void) const +{ + return GetContentSizeInternal(); +} + +Tizen::Graphics::Dimension +_Button::GetContentSizeInternal(void) const +{ + for (int i = 0; i < NUMBER_OF_BUTTON_STATUS; i++) + { + if (__text.IsEmpty() && __pBitmap[i] == null && __isUserBackgroundBitmap[i] == false) + { + return Dimension(GetBounds().width, GetBounds().height); + } + } + + Dimension dimension(0,0); + Rectangle contentRect(0,0,0,0); + + TextObject* pTextObject = __pButtonPresenter->GetTextObject(); + + TextObjectActionType previousActionType = pTextObject->GetAction(); + TextObjectWrapType previousWrapType = pTextObject->GetWrap(); + Rectangle previousRect = pTextObject->GetBounds(); + + pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE); + pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + pTextObject->Compose(); + dimension = pTextObject->GetTextExtent(0, pTextObject->GetTextLength()); + + contentRect.width = _ControlManager::GetInstance()->GetScreenSize().width; + + if (dimension.width > contentRect.width - GetBounds().x) + { + dimension.width = contentRect.width - GetBounds().x; + + pTextObject->SetBounds(Rectangle(previousRect.x, previousRect.y, dimension.width, previousRect.height)); + pTextObject->Compose(); + } + + dimension.height = pTextObject->GetTotalHeight(); + + pTextObject->SetBounds(previousRect); + pTextObject->SetAction(previousActionType); + pTextObject->SetWrap(previousWrapType); + pTextObject->Compose(); + + dimension.width += __leftMargin * 4; + dimension.height += __topMargin * 4; + + for (int i = 0; i < NUMBER_OF_BUTTON_STATUS; i++) + { + if (__pBitmap[i] != null || __isUserBackgroundBitmap[i] == true) + { + dimension.width = GetBounds().width; + dimension.height = GetBounds().height; + } + } + + return dimension; +} + +int +_Button::GetTextExtentSize(void) const +{ + int textExtentSize = 0; + + TextObject* pTextObject = __pButtonPresenter->GetTextObject(); + + TextObjectActionType previousActionType = pTextObject->GetAction(); + TextObjectWrapType previousWrapType = pTextObject->GetWrap(); + Rectangle previousRect = pTextObject->GetBounds(); + + pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE); + pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + pTextObject->Compose(); + + textExtentSize = pTextObject->GetTextExtent(0, pTextObject->GetTextLength()).width; + + pTextObject->SetBounds(previousRect); + pTextObject->SetAction(previousActionType); + pTextObject->SetWrap(previousWrapType); + pTextObject->Compose(); + + return textExtentSize; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ButtonImpl.cpp b/src/ui/controls/FUiCtrl_ButtonImpl.cpp new file mode 100644 index 0000000..bbbea5d --- /dev/null +++ b/src/ui/controls/FUiCtrl_ButtonImpl.cpp @@ -0,0 +1,798 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ButtonImpl.cpp + * @brief This is the implementation file for the _ButtonImpl class. + */ + +#include +#include +#include +#include +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_ButtonImpl.h" +#include "FUiCtrl_Button.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Dimension +_ButtonImpl::ButtonSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Dimension dimension(0, 0); + + r = GET_DIMENSION_CONFIG(BUTTON::MIN_SIZE, orientation, dimension); + SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] A system error occurred.", GetErrorMessage(r)); + + SetLastResult(r); + + return dimension; +} + +_ButtonImpl* +_ButtonImpl::GetInstance(Button& button) +{ + return static_cast<_ButtonImpl*> (button._pControlImpl); +} + +const _ButtonImpl* +_ButtonImpl::GetInstance(const Button& button) +{ + return static_cast (button._pControlImpl); +} + +_ButtonImpl::_ButtonImpl(Button* pPublic, _Button* pCore) + : _ControlImpl(pPublic, pCore) + , __pPublicActionEvent(null) +{ + ClearLastResult(); +} + +_ButtonImpl::~_ButtonImpl(void) +{ + _ButtonImpl::GetCore().RemoveActionEventListener(*this); + + if (__pPublicActionEvent) + { + delete __pPublicActionEvent; + __pPublicActionEvent = null; + } + + ClearLastResult(); +} + +_ButtonImpl* +_ButtonImpl::CreateButtonImplN(Button* pControl, const Rectangle& bounds) +{ + result r = E_SUCCESS; + r = GET_SIZE_INFO(Button).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] The given size is not valid."); + + _Button* pCore = _Button::CreateButtonN(); + SysTryReturn(NID_UI_CTRL, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _ButtonImpl* pImpl = new (std::nothrow) _ButtonImpl(pControl, pCore); + r = _ControlImpl::CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Button), bounds, pCore->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddActionEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + ClearLastResult(); + + return pImpl; + +CATCH: + delete pImpl; + return null; +} + +const Color +_ButtonImpl::GetColorOnError(void) +{ + return Color(0xFFFFFFFF); +} + +const char* +_ButtonImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::Button"; +} + +const Button& +_ButtonImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +Button& +_ButtonImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Button& +_ButtonImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Button& +_ButtonImpl::GetCore(void) +{ + return static_cast <_Button&>(_ControlImpl::GetCore()); +} + +result +_ButtonImpl::SetText(const String& text) +{ + int textLength = text.GetLength(); + int buttonTextMaxLength = 0; + GET_FIXED_VALUE_CONFIG(BUTTON::TEXT_MAX_LENGTH, _CONTROL_ORIENTATION_PORTRAIT, buttonTextMaxLength); + String tempText = String(text); + + if (textLength >= buttonTextMaxLength) + { + tempText.Remove(buttonTextMaxLength - 1, textLength - buttonTextMaxLength + 1); + } + + Variant var(tempText); + result r = GetCore().SetPropertyText(var); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +String +_ButtonImpl::GetText(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyText().ToString(); +} + +result +_ButtonImpl::SetColor(ButtonStatus status, const Color& color) +{ + _ButtonStatus coreStatus = ConvertStatus(status); + result r = GetCore().SetColor(coreStatus, color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_ButtonImpl::GetColor(ButtonStatus status) const +{ + ClearLastResult(); + _ButtonStatus coreStatus = ConvertStatus(status); + + return GetCore().GetColor(coreStatus); +} + +result +_ButtonImpl::AddActionEventListener(IActionEventListener& listener) +{ + if (__pPublicActionEvent == null) + { + __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + } + + result r = __pPublicActionEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return E_SUCCESS; +} + +result +_ButtonImpl::RemoveActionEventListener(IActionEventListener& listener) +{ + result r = E_OBJ_NOT_FOUND; + + if (__pPublicActionEvent) + { + r = __pPublicActionEvent->RemoveListener(listener); + } + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return E_SUCCESS; +} + +result +_ButtonImpl::SetActionId(int actionId) +{ + result r = GetCore().SetActionId(actionId); + + SetLastResultReturn(r); +} + +int +_ButtonImpl::GetActionId(void) const +{ + ClearLastResult(); + + return GetCore().GetActionId(); +} + +result +_ButtonImpl::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + result r = GetCore().SetTextHorizontalAlignment(alignment); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +HorizontalAlignment +_ButtonImpl::GetTextHorizontalAlignment(void) const +{ + ClearLastResult(); + + return GetCore().GetTextHorizontalAlignment(); +} + +result +_ButtonImpl::SetTextVerticalAlignment(VerticalAlignment alignment) +{ + result r = GetCore().SetTextVerticalAlignment(alignment); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +VerticalAlignment +_ButtonImpl::GetTextVerticalAlignment(void) const +{ + ClearLastResult(); + + return GetCore().GetTextVerticalAlignment(); +} + +result +_ButtonImpl::SetTextColor(const Color& color) +{ + result r = GetCore().SetTextColor(_BUTTON_STATUS_NORMAL, color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_ButtonImpl::GetTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetTextColor(_BUTTON_STATUS_NORMAL); +} + +result +_ButtonImpl::SetDisabledTextColor(const Color& color) +{ + result r = GetCore().SetTextColor(_BUTTON_STATUS_DISABLED, color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_ButtonImpl::GetDisabledTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetTextColor(_BUTTON_STATUS_DISABLED); +} + +result +_ButtonImpl::SetPressedTextColor(const Color& color) +{ + result r = GetCore().SetTextColor(_BUTTON_STATUS_PRESSED, color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_ButtonImpl::GetPressedTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetTextColor(_BUTTON_STATUS_PRESSED); +} + +result +_ButtonImpl::SetHighlightedTextColor(const Color& color) +{ + result r = GetCore().SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_ButtonImpl::GetHighlightedTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetTextColor(_BUTTON_STATUS_HIGHLIGHTED); +} + +result +_ButtonImpl::SetNormalBitmap(const Point& position, const Bitmap& bitmap) +{ + result r = GetCore().SetBitmap(_BUTTON_STATUS_NORMAL, position, bitmap); + SetLastResultReturn(r); +} + +result +_ButtonImpl::SetDisabledBitmap(const Point& position, const Bitmap& bitmap) +{ + result r = GetCore().SetBitmap(_BUTTON_STATUS_DISABLED, position, bitmap); + SetLastResultReturn(r); +} + +result +_ButtonImpl::SetPressedBitmap(const Point& position, const Bitmap& bitmap) +{ + result r = GetCore().SetBitmap(_BUTTON_STATUS_PRESSED, position, bitmap); + SetLastResultReturn(r); +} + +result +_ButtonImpl::SetNormalBackgroundBitmap(const Bitmap& bitmap) +{ + result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, bitmap); + SetLastResultReturn(r); +} + +result +_ButtonImpl::SetPressedBackgroundBitmap(const Bitmap& bitmap) +{ + result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, bitmap); + SetLastResultReturn(r); +} + +result +_ButtonImpl::SetHighlightedBackgroundBitmap(const Bitmap& bitmap) +{ + result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, bitmap); + SetLastResultReturn(r); +} + +result +_ButtonImpl::SetTextSize(int size) +{ + result r = GetCore().SetTextSize(size); + SetLastResultReturn(r); +} + +int +_ButtonImpl::GetTextSize(void) const +{ + ClearLastResult(); + + return GetCore().GetTextSize(); +} + +void +_ButtonImpl::OnActionPerformed(const _Control& source, int actionId) +{ + if (__pPublicActionEvent != null) + { + __pPublicActionEvent->Fire(*_PublicActionEvent::CreateActionEventArgN(actionId)); + } + + return; +} + +result +_ButtonImpl::OnAttachedToMainTree(void) +{ + SetFocusable(true); + + _ControlImpl::OnAttachedToMainTree(); + + return E_SUCCESS; +} + +bool +_ButtonImpl::OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) && (!source.IsEnabled() || !source.GetEnableState())) + { + return true; + } + + return false; +} + +bool +_ButtonImpl::OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) && (!source.IsEnabled() || !source.GetEnableState())) + { + return true; + } + + return false; +} + +bool +_ButtonImpl::OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) && (!source.IsEnabled() || !source.GetEnableState())) + { + return true; + } + + return false; +} + +bool +_ButtonImpl::OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) && (!source.IsEnabled() || !source.GetEnableState())) + { + return true; + } + + return false; +} + +Tizen::Graphics::Dimension +_ButtonImpl::GetContentSize(void) const +{ + return GetCore().GetContentSizeInternal(); +} + +_ButtonStatus +_ButtonImpl::ConvertStatus(ButtonStatus status) const +{ + _ButtonStatus coreStatus = _BUTTON_STATUS_HIGHLIGHTED; + switch (status) + { + case BUTTON_STATUS_NORMAL: + coreStatus = _BUTTON_STATUS_NORMAL; + break; + case BUTTON_STATUS_DISABLED: + coreStatus = _BUTTON_STATUS_DISABLED; + break; + case BUTTON_STATUS_PRESSED: + coreStatus = _BUTTON_STATUS_PRESSED; + break; + default: + coreStatus = _BUTTON_STATUS_HIGHLIGHTED; + } + + return coreStatus; +} + +class _ButtonMaker + : public _UiBuilderControlMaker +{ +public: + _ButtonMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + _ButtonMaker(){}; + virtual ~_ButtonMaker(){}; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _ButtonMaker* pButtonMaker = new (std::nothrow) _ButtonMaker(uibuilder); + return static_cast<_UiBuilderControlMaker*>(pButtonMaker); + }; +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + + AppResource* pAppResource = null; + UiApp* pUiApp = UiApp::GetInstance(); + if (pUiApp) + { + pAppResource = UiApp::GetInstance()->GetAppResource(); + } + + _UiBuilderControlLayout* pControlProperty = null; + Button* pButton = null; + HorizontalAlignment horizontalAlignment; + VerticalAlignment verticalAlignment; + Color color; + int size = 0; + int opacity = 0; + Rectangle rect; + Rectangle buttonRect(0, 0, 0, 0); + Tizen::Base::String elementString; + + GetProperty(pControl, &pControlProperty); + + if (pControlProperty == null) + { + return null; + } + + pButton = new (std::nothrow) Button(); + if (pButton == null) + { + return null; + } + + buttonRect = pControlProperty->GetRect(); + + if (pControl->GetElement(L"text", elementString)) + { + r = pButton->Construct(buttonRect, elementString); + } + else + { + r = pButton->Construct(buttonRect); + } + + if (r != E_SUCCESS) + { + delete pButton; + return null; + } + + if (pControl->GetElement(L"horizontalAlign", elementString) || pControl->GetElement(L"hAlign", elementString)) + { + if (ConvertHAlignToHorizontalAlignment(elementString, horizontalAlignment)) + { + pButton->SetTextHorizontalAlignment(horizontalAlignment); + } + } + + if (pControl->GetElement(L"verticalAlign", elementString) || pControl->GetElement(L"vAlign", elementString)) + { + if (ConvertVAlignToVerticalAlignment(elementString, verticalAlignment)) + { + pButton->SetTextVerticalAlignment(verticalAlignment); + } + } + + if (pControl->GetElement(L"normalTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pButton->SetTextColor(color); + } + + if (pControl->GetElement(L"pressedTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pButton->SetPressedTextColor(color); + } + + if (pControl->GetElement(L"disableTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pButton->SetDisabledTextColor(color); + } + + if (pControl->GetElement(L"normalBitmapPath", elementString) || pControl->GetElement(L"NormalBitmapPath", elementString)) + { + Bitmap* pNormalBitmap = null; + Point position; + + pNormalBitmap = pAppResource->GetBitmapN(elementString); + if (pControl->GetElement(L"NormalBitmapX", elementString)) + { + Base::Integer::Parse(elementString, position.x); + if ((position.x < 0) || (position.x > ((Control*) (GetContainer()))->GetBounds().width - ((Control*) (GetContainer()))->GetBounds().x)) + { + position.x = 0; + } + } + + if (pControl->GetElement(L"NormalBitmapY", elementString)) + { + Base::Integer::Parse(elementString, position.y); + if (position.y < 0 || (position.y > ((Control*) (GetContainer()))->GetBounds().width - ((Control*) (GetContainer()))->GetBounds().x)) + { + position.y = 0; + } + } + + if (pNormalBitmap != null) + { + pButton->SetNormalBitmap(position, *pNormalBitmap); + delete pNormalBitmap; + } + } + + if (pControl->GetElement(L"PressedBitmapPath", elementString)) + { + Bitmap* pPressedBitmap = null; + Point position; + + pPressedBitmap = pAppResource->GetBitmapN(elementString); + if (pControl->GetElement(L"PressedBitmapX", elementString)) + { + Base::Integer::Parse(elementString, position.x); + if ((position.x < 0) || (position.x > ((Control*) (GetContainer()))->GetBounds().width - ((Control*) (GetContainer()))->GetBounds().x)) + { + position.x = 0; + } + } + + if (pControl->GetElement(L"PressedBitmapY", elementString)) + { + Base::Integer::Parse(elementString, position.y); + if (position.y < 0 || (position.y > ((Control*) (GetContainer()))->GetBounds().width - ((Control*) (GetContainer()))->GetBounds().x)) + { + position.y = 0; + } + } + + if (pPressedBitmap != null) + { + pButton->SetPressedBitmap(position, *pPressedBitmap); + delete pPressedBitmap; + } + } + + if (pControl->GetElement(L"DisabledBitmapPath", elementString)) + { + Bitmap* pDisabledBitmap = null; + Point position; + pDisabledBitmap = pAppResource->GetBitmapN(elementString); + if (pControl->GetElement(L"DisabledBitmapX", elementString)) + { + Base::Integer::Parse(elementString, position.x); + if ((position.x < 0) || (position.x > ((Control*) (GetContainer()))->GetBounds().width - ((Control*) (GetContainer()))->GetBounds().x)) + { + position.x = 0; + } + } + + if (pControl->GetElement(L"DisabledBitmapY", elementString)) + { + Base::Integer::Parse(elementString, position.y); + if (position.y < 0 || (position.y > ((Control*) (GetContainer()))->GetBounds().width - ((Control*) (GetContainer()))->GetBounds().x)) + { + position.y = 0; + } + } + + if (pDisabledBitmap != null) + { + pButton->SetDisabledBitmap(position, *pDisabledBitmap); + delete pDisabledBitmap; + } + } + + if (pControl->GetElement(L"NormalBGBitmapPath", elementString)) + { + Bitmap* pNormalBGBitmap = null; + pNormalBGBitmap = pAppResource->GetBitmapN(elementString); + if (pNormalBGBitmap != null) + { + pButton->SetNormalBackgroundBitmap(*pNormalBGBitmap); + delete pNormalBGBitmap; + } + } + + if (pControl->GetElement(L"PressedBGBitmapPath", elementString)) + { + Bitmap* pPressedBGBitmap = null; + pPressedBGBitmap = pAppResource->GetBitmapN(elementString); + if (pPressedBGBitmap != null) + { + pButton->SetPressedBackgroundBitmap(*pPressedBGBitmap); + delete pPressedBGBitmap; + } + } + + if (pControl->GetElement(L"HighlightedBGBitmapPath", elementString)) + { + Bitmap* pHighlightedBGBitmap = null; + pHighlightedBGBitmap = pAppResource->GetBitmapN(elementString); + if (pHighlightedBGBitmap != null) + { + pButton->SetHighlightedBackgroundBitmap(*pHighlightedBGBitmap); + delete pHighlightedBGBitmap; + } + } + + if (pControl->GetElement(L"highlightedTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pButton->SetHighlightedTextColor(color); + } + + if (pControl->GetElement(L"normalColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"normalColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pButton->SetColor(BUTTON_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"pressedColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"pressedColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pButton->SetColor(BUTTON_STATUS_PRESSED, color); + } + + if (pControl->GetElement(L"disabledColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"disabledColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pButton->SetColor(BUTTON_STATUS_DISABLED, color); + } + + if (pControl->GetElement(L"highlightedColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"highlightedColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pButton->SetColor(BUTTON_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"textSize", elementString)) + { + _ICoordinateSystemTransformer* pTransform = GetTransformer(); + Base::Integer::Parse(elementString, size); + if (pTransform) + { + size = pTransform->Transform(size); + } + + pButton->SetTextSize(size); + } + + return pButton; + } +private: +}; // _ButtonMaker + +_ButtonRegister::_ButtonRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"Button", _ButtonMaker::GetInstance); +} +_ButtonRegister::~_ButtonRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"Button"); +} +static _ButtonRegister ButtonRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ButtonItemImpl.cpp b/src/ui/controls/FUiCtrl_ButtonItemImpl.cpp new file mode 100644 index 0000000..32ea273 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ButtonItemImpl.cpp @@ -0,0 +1,160 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_ButtonItemImpl.cpp +* @brief This is the implementation file for _ButtonItemImpl class. +*/ + +#include +#include "FUiCtrl_ButtonItemImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ButtonItemImpl::_ButtonItemImpl(ButtonItem* pPublic) + : __actionId(-1) + , __itemStyle(BUTTON_ITEM_STYLE_TEXT) + , __itemText(L"") +{ + for (int i = 0; i < BUTTON_ITEM_MAX_STATE_COUNT; i++) + { + __pIconBitmap[i] = null; + __pButtonItemBackgroundBitmap[i] = null; + } +} + +_ButtonItemImpl::~_ButtonItemImpl(void) +{ + for (int i = 0; i < BUTTON_ITEM_MAX_STATE_COUNT; i++) + { + __pIconBitmap[i] = null; + __pButtonItemBackgroundBitmap[i] = null; + } +} + +const _ButtonItemImpl* +_ButtonItemImpl::GetInstance(const ButtonItem& buttonItem) +{ + return static_cast (buttonItem.__pImpl); +} + +_ButtonItemImpl* +_ButtonItemImpl::GetInstance(ButtonItem& buttonItem) +{ + return static_cast<_ButtonItemImpl*> (buttonItem.__pImpl); +} + +result +_ButtonItemImpl::Construct(ButtonItemStyle style, int actionId) +{ + SysTryReturnResult(NID_UI_CTRL, (actionId >= BUTTON_ITEM_ACTION_ID_MIN && actionId <= BUTTON_ITEM_ACTION_ID_MAX), + E_INVALID_ARG, "[E_INVALID_ARG] The actionId is invalid."); + + __actionId = actionId; + __itemText = Tizen::Base::String(L""); + + __itemStyle = style; + + for (int i = 0; i < BUTTON_ITEM_MAX_STATE_COUNT; i++) + { + __pIconBitmap[i] = null; + __pButtonItemBackgroundBitmap[i] = null; + } + + return E_SUCCESS; +} + +int +_ButtonItemImpl::GetActionId(void) const +{ + ClearLastResult(); + + return __actionId; +} + +const Tizen::Graphics::Bitmap* +_ButtonItemImpl::GetBackgroundBitmap(ButtonItemStatus status) const +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, (status >= 0 && status < BUTTON_ITEM_MAX_STATE_COUNT), null, E_INVALID_ARG, + "[E_INVALID_ARG] status is invalid."); + + return __pButtonItemBackgroundBitmap[status]; +} + +const Tizen::Graphics::Bitmap* +_ButtonItemImpl::GetIcon(ButtonItemStatus status) const +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, (status >= 0 && status < BUTTON_ITEM_MAX_STATE_COUNT), null, E_INVALID_ARG, + "[E_INVALID_ARG] status is invalid."); + + return __pIconBitmap[status]; +} + +Tizen::Base::String +_ButtonItemImpl::GetText(void) const +{ + ClearLastResult(); + + return __itemText; +} + +result +_ButtonItemImpl::SetActionId(int actionId) +{ + SysTryReturnResult(NID_UI_CTRL, (actionId > BUTTON_ITEM_ACTION_ID_MIN && actionId < BUTTON_ITEM_ACTION_ID_MAX), + E_INVALID_ARG, "[E_INVALID_ARG] The actionId is invalid."); + + __actionId = actionId; + + return E_SUCCESS; +} + +result +_ButtonItemImpl::SetBackgroundBitmap(ButtonItemStatus status, const Tizen::Graphics::Bitmap* pBitmap) +{ + SysTryReturnResult(NID_UI_CTRL, (status >= 0 && status < BUTTON_ITEM_MAX_STATE_COUNT), E_INVALID_ARG, + "[E_INVALID_ARG] status is invalid."); + + __pButtonItemBackgroundBitmap[status] = pBitmap; + + return E_SUCCESS; +} + +result +_ButtonItemImpl::SetIcon(ButtonItemStatus status, const Tizen::Graphics::Bitmap* pIcon) +{ + SysTryReturnResult(NID_UI_CTRL, (status >= 0 && status < BUTTON_ITEM_MAX_STATE_COUNT), E_INVALID_ARG, + "[E_INVALID_ARG] status is invalid."); + + __pIconBitmap[status] = pIcon; + + return E_SUCCESS; +} + +result +_ButtonItemImpl::SetText(const Tizen::Base::String& text) +{ + __itemText = text; + + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ButtonModel.cpp b/src/ui/controls/FUiCtrl_ButtonModel.cpp new file mode 100644 index 0000000..768e7d4 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ButtonModel.cpp @@ -0,0 +1,47 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ButtonModel.cpp + * @brief This is the implementation file for the _ButtonModel class. + */ + +#include +#include +#include "FUiCtrl_ButtonModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ButtonModel::_ButtonModel(void) +{ + +} + +_ButtonModel::~_ButtonModel(void) +{ + +} + +result +_ButtonModel::Construct(void) +{ + result r = E_SUCCESS; + + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ButtonPresenter.cpp b/src/ui/controls/FUiCtrl_ButtonPresenter.cpp new file mode 100644 index 0000000..31fa047 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ButtonPresenter.cpp @@ -0,0 +1,872 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ButtonPresenter.cpp + * @brief This is the implementation file for the _ButtonPresenter class. + */ + +#include +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_ButtonPresenter.h" +#include "FUiCtrl_ButtonModel.h" +#include "FUiCtrl_Button.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::App; + +namespace Tizen { namespace Ui { namespace Controls +{ +_ButtonPresenter::_ButtonPresenter(void) + : __pButton(null) + , __pButtonModel(null) + , __previousEnabledState(false) + , __touchMoveHandled(false) + , __pFont(null) + , __pTextObject(null) + , __pBase(null) + , __fontStyle(0) + , __fontSize(0) +{ + +} + +_ButtonPresenter::~_ButtonPresenter(void) +{ + if (__pButtonModel) + { + delete __pButtonModel; + __pButtonModel = null; + } + + if (__pTextObject) + { + delete __pTextObject; + __pTextObject = null; + } +} + +result +_ButtonPresenter::Construct(const _Button& button) +{ + result r = E_SUCCESS; + + __pButton = const_cast <_Button*>(&button); + __fontStyle = FONT_STYLE_PLAIN; + __fontSize = __pButton->GetTextSize(); + __pFont = __pButton->GetFallbackFont(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pFont, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTextObject = new (std::nothrow) TextObject(); + SysTryCatch(NID_UI_CTRL, __pTextObject != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + return E_SUCCESS; + +CATCH: + + delete __pTextObject; + __pTextObject = null; + + return r; +} + +result +_ButtonPresenter::Install(void) +{ + result r = E_SUCCESS; + + __pBase = __pButton->GetVisualElement(); + + _ButtonModel* pModel = new (std::nothrow) _ButtonModel(); + SysTryReturn(NID_UI_CTRL, pModel, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = SetModel(*pModel); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pModel->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return E_SUCCESS; + +CATCH: + delete pModel; + return r; +} + +result +_ButtonPresenter::SetModel(const _ButtonModel& buttonModel) +{ + __pButtonModel = const_cast <_ButtonModel*>(&buttonModel); + + return E_SUCCESS; +} + +result +_ButtonPresenter::InitTextObject(void) +{ + TextSimple* pSimpleText = null; + + pSimpleText = new (std::nothrow) TextSimple(const_cast(__pButton->GetText().GetPointer()), __pButton->GetText().GetLength()); + SysTryReturn(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + __pTextObject->Construct(); + __pTextObject->AppendElement(*pSimpleText); + __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __pTextObject->SetBounds(Rectangle(__pButton->GetLeftMargin(), __pButton->GetTopMargin(), + __pButton->GetBounds().width - __pButton->GetLeftMargin() * 2, __pButton->GetBounds().height - __pButton->GetTopMargin() * 2)); + __pTextObject->Compose(); + + return E_SUCCESS; +} + +void +_ButtonPresenter::OnFontChanged(Font* pFont) +{ + __pFont = pFont; + + return; +} + +void +_ButtonPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = __fontStyle; + size = __fontSize; + + return; +} + +void +_ButtonPresenter::SetTextSize(int size, unsigned long fontStyle) +{ + result r = E_SUCCESS; + + bool isStrikeOut = __pFont->IsStrikeOut(); + bool isUnderLine = __pFont->IsUnderlined(); + + if (__pFont->IsItalic()) + { + fontStyle |= FONT_STYLE_ITALIC; + } + + if (__pFont->IsBold()) + { + fontStyle |= FONT_STYLE_BOLD; + } + + __fontStyle = fontStyle; + __fontSize = size; + + __pFont = __pButton->GetFallbackFont(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, __pFont, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pFont->SetStrikeOut(isStrikeOut); + __pFont->SetUnderline(isUnderLine); + + return; +} + +void +_ButtonPresenter::SetFontInfo(unsigned long style, int size) +{ + __fontStyle = style; + __fontSize = size; + + return; +} + +TextObject* +_ButtonPresenter::GetTextObject(void) const +{ + return __pTextObject; +} + +void +_ButtonPresenter::Draw(void) +{ + _ButtonStatus status = __pButton->GetButtonStatus(); + Bitmap* pToolbarItemBackgroundBitmap = __pButton->GetToolbarItemBackgroundBitmap(status); + + if (pToolbarItemBackgroundBitmap) + { + DrawToolbarItemBackground(); + } + else + { + DrawBackground(); + } + + DrawBitmap(); + DrawText(); + + if (status == _BUTTON_STATUS_SELECTED) + { + DrawToolbarSelectedBitmap(); + } + + return; +} + +void +_ButtonPresenter::DrawBackground(void) +{ + Canvas* pCanvas = null; + + Bitmap* pReplacementColorBackgroundBitmap = null; + Bitmap* pBackgroundBitmap = null; + Bitmap* pBackgroundEffectBitmap = null; + + Rectangle bounds(0, 0, __pButton->GetBounds().width, __pButton->GetBounds().height); + + _ButtonStatus status = __pButton->GetButtonStatus(); + + if (__pButton->IsUserBackgroundBitmap(status)) + { + pBackgroundBitmap = __pButton->GetBackgroundBitmap(status); + pBackgroundEffectBitmap = __pButton->GetBackgroundEffectBitmap(status); + + if (pBackgroundBitmap) + { + pCanvas = __pButton->GetCanvasN(); + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + return; + } + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + if (pBackgroundBitmap->IsNinePatchedBitmap()) //ninepatch + { + if (pBackgroundEffectBitmap) + { + if (pBackgroundEffectBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap); + if (__pButton->IsUserBackgroundEffectBitmap(status)) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundEffectBitmap); + } + } + else + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap); + if (__pButton->IsUserBackgroundEffectBitmap(status)) + { + pCanvas->DrawBitmap(bounds, *pBackgroundEffectBitmap, Rectangle(0, 0, pBackgroundEffectBitmap->GetWidth(), pBackgroundEffectBitmap->GetHeight())); + } + } + } + else + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap); + } + } + else // not ninepatch + { + if (pBackgroundEffectBitmap) + { + if (pBackgroundEffectBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawBitmap(bounds, *pBackgroundBitmap, Rectangle(0, 0, pBackgroundBitmap->GetWidth(), pBackgroundBitmap->GetHeight())); + if (__pButton->IsUserBackgroundEffectBitmap(status)) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundEffectBitmap); + } + } + else + { + pCanvas->DrawBitmap(bounds, *pBackgroundBitmap, Rectangle(0, 0, pBackgroundBitmap->GetWidth(), pBackgroundBitmap->GetHeight())); + if (__pButton->IsUserBackgroundEffectBitmap(status)) + { + pCanvas->DrawBitmap(bounds, *pBackgroundEffectBitmap, Rectangle(0, 0, pBackgroundEffectBitmap->GetWidth(), pBackgroundEffectBitmap->GetHeight())); + } + } + } + else + { + pCanvas->DrawBitmap(bounds, *pBackgroundBitmap, Rectangle(0, 0, pBackgroundBitmap->GetWidth(), pBackgroundBitmap->GetHeight())); + } + } + } + else + { + pCanvas = __pButton->GetCanvasN(); + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + return; + } + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + if (pBackgroundEffectBitmap) + { + if (pBackgroundEffectBitmap->IsNinePatchedBitmap()) + { + if (__pButton->IsUserBackgroundEffectBitmap(status)) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundEffectBitmap); + } + } + else + { + if (__pButton->IsUserBackgroundEffectBitmap(status)) + { + pCanvas->DrawBitmap(bounds, *pBackgroundEffectBitmap, Rectangle(0, 0, pBackgroundEffectBitmap->GetWidth(), pBackgroundEffectBitmap->GetHeight())); + } + } + } + else + { + pCanvas->FillRectangle(__pButton->GetColor(status), bounds); + } + } + } + else // nobody set bitmap (default bitmap draw) + { + pCanvas = __pButton->GetCanvasN(); + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + return; + } + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + if (status == _BUTTON_STATUS_DISABLED) + { + pBackgroundBitmap = __pButton->GetBackgroundBitmap(_BUTTON_STATUS_DISABLED); + + if(!__pButton->IsUserBackgroundBitmap(_BUTTON_STATUS_NORMAL)) + { + pBackgroundEffectBitmap = __pButton->GetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL); + } + + pReplacementColorBackgroundBitmap = + _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pButton->GetColor(_BUTTON_STATUS_DISABLED)); + } + else + { + pBackgroundBitmap = __pButton->GetBackgroundBitmap(status); + pBackgroundEffectBitmap = __pButton->GetBackgroundEffectBitmap(status); + pReplacementColorBackgroundBitmap = + _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pButton->GetColor(status)); + } + + if (pReplacementColorBackgroundBitmap) + { + if (pReplacementColorBackgroundBitmap->IsNinePatchedBitmap()) + { + if (pBackgroundEffectBitmap) + { + if (pBackgroundEffectBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pReplacementColorBackgroundBitmap); + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundEffectBitmap); + } + else + { + pCanvas->DrawNinePatchedBitmap(bounds, *pReplacementColorBackgroundBitmap); + pCanvas->DrawBitmap(bounds, *pBackgroundEffectBitmap, Rectangle(0, 0, pBackgroundEffectBitmap->GetWidth(), pBackgroundEffectBitmap->GetHeight())); + } + } + else + { + pCanvas->DrawNinePatchedBitmap(bounds, *pReplacementColorBackgroundBitmap); + } + } + else + { + if (pBackgroundEffectBitmap) + { + if (pBackgroundEffectBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawBitmap(bounds, *pReplacementColorBackgroundBitmap, Rectangle(0, 0, pReplacementColorBackgroundBitmap->GetWidth(), + pReplacementColorBackgroundBitmap->GetHeight())); + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundEffectBitmap); + } + else + { + pCanvas->DrawBitmap(bounds, *pReplacementColorBackgroundBitmap, Rectangle(0, 0, pReplacementColorBackgroundBitmap->GetWidth(), + pReplacementColorBackgroundBitmap->GetHeight())); + pCanvas->DrawBitmap(bounds, *pBackgroundEffectBitmap, Rectangle(0, 0, pBackgroundEffectBitmap->GetWidth(), pBackgroundEffectBitmap->GetHeight())); + } + } + else + { + pCanvas->DrawBitmap(bounds, *pReplacementColorBackgroundBitmap, Rectangle(0, 0, pReplacementColorBackgroundBitmap->GetWidth(), + pReplacementColorBackgroundBitmap->GetHeight())); + } + } + } + else + { + if (pBackgroundEffectBitmap) + { + if (pBackgroundEffectBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundEffectBitmap); + } + else + { + pCanvas->DrawBitmap(bounds, *pBackgroundEffectBitmap, Rectangle(0, 0, pBackgroundEffectBitmap->GetWidth(), pBackgroundEffectBitmap->GetHeight())); + } + } + else + { + if (status == _BUTTON_STATUS_DISABLED) + { + pCanvas->FillRectangle(__pButton->GetColor(_BUTTON_STATUS_NORMAL), bounds); + } + else + { + pCanvas->FillRectangle(__pButton->GetColor(status), bounds); + } + } + } + } + + if (!__pButton->IsUserBackgroundBitmap(status)) + { + __pButton->UnloadBackgroundBitmap(status); + } + + if (!__pButton->IsUserBackgroundEffectBitmap(status)) + { + __pButton->UnloadBackgroundEffectBitmap(status); + } + + if (pCanvas) + { + delete pCanvas; + } + + delete pReplacementColorBackgroundBitmap; + + return; +} + +void +_ButtonPresenter::DrawToolbarItemBackground(void) +{ + _ButtonStatus status = __pButton->GetButtonStatus(); + Bitmap* pToolbarItemBackgroundBitmap = __pButton->GetToolbarItemBackgroundBitmap(status); + + if (pToolbarItemBackgroundBitmap) + { + Canvas* pCanvas = __pButton->GetCanvasN(); + + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + return; + } + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + Rectangle bounds(0, 0, __pButton->GetBounds().width, __pButton->GetBounds().height); + + if (pToolbarItemBackgroundBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pToolbarItemBackgroundBitmap); + } + else + { + pCanvas->DrawBitmap(bounds, *pToolbarItemBackgroundBitmap, Rectangle(0, 0, pToolbarItemBackgroundBitmap->GetWidth(), pToolbarItemBackgroundBitmap->GetHeight())); + } + + delete pCanvas; + } + + return; +} + +void +_ButtonPresenter::DrawBitmap(void) +{ + Canvas* pCanvas = null; + + _ButtonStatus status = __pButton->GetButtonStatus(); + + Bitmap* pBitmap = __pButton->GetBitmap(status); + Bitmap* pNormalBitmap = __pButton->GetBitmap(_BUTTON_STATUS_NORMAL); + + Rectangle bounds(0, 0, __pButton->GetBounds().width, __pButton->GetBounds().height); + + if (pBitmap) + { + pCanvas = __pButton->GetCanvasN(); + + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + return; + } + + if (__pButton->GetSize().width - __pButton->GetBitmapPosition(status).x < pBitmap->GetWidth() + || __pButton->GetSize().height - __pButton->GetBitmapPosition(status).y < pBitmap->GetHeight()) + { + pCanvas->DrawBitmap(bounds, *pBitmap, Rectangle(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight())); + } + else + { + pCanvas->DrawBitmap(__pButton->GetBitmapPosition(status), *pBitmap); + } + } + else if (pNormalBitmap) + { + pCanvas = __pButton->GetCanvasN(); + + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + return; + } + + if (__pButton->GetSize().width - __pButton->GetBitmapPosition(_BUTTON_STATUS_NORMAL).x < pNormalBitmap->GetWidth() + || __pButton->GetSize().height - __pButton->GetBitmapPosition(_BUTTON_STATUS_NORMAL).y < pNormalBitmap->GetHeight()) + { + pCanvas->DrawBitmap(bounds, *pNormalBitmap, Rectangle(0, 0, pNormalBitmap->GetWidth(), pNormalBitmap->GetHeight())); + } + else + { + pCanvas->DrawBitmap(__pButton->GetBitmapPosition(_BUTTON_STATUS_NORMAL), *pNormalBitmap); + } + } + + delete pCanvas; + + return; +} + +void +_ButtonPresenter::DrawText(void) +{ + TextSimple* pSimpleText = null; + TextObjectAlignment horizontalAlign = TEXT_OBJECT_ALIGNMENT_CENTER; + TextObjectAlignment verticalAlign = TEXT_OBJECT_ALIGNMENT_MIDDLE; + + int buttonTopMargin = __pButton->GetTopMargin(); + int buttonLeftMargin = __pButton->GetLeftMargin(); + int multilineFontSize = 0; + + Canvas* pCanvas = __pButton->GetCanvasN(); + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + return; + } + + switch (__pButton->GetTextHorizontalAlignment()) + { + case ALIGNMENT_LEFT: + horizontalAlign = TEXT_OBJECT_ALIGNMENT_LEFT; + break; + case ALIGNMENT_CENTER: + horizontalAlign = TEXT_OBJECT_ALIGNMENT_CENTER; + break; + default: + horizontalAlign = TEXT_OBJECT_ALIGNMENT_RIGHT; + } + + switch (__pButton->GetTextVerticalAlignment()) + { + case ALIGNMENT_TOP: + verticalAlign = TEXT_OBJECT_ALIGNMENT_TOP; + break; + case ALIGNMENT_MIDDLE: + verticalAlign = TEXT_OBJECT_ALIGNMENT_MIDDLE; + break; + default: + verticalAlign = TEXT_OBJECT_ALIGNMENT_BOTTOM; + } + + __pTextObject->RemoveAll(); + pSimpleText = new (std::nothrow) TextSimple(const_cast(__pButton->GetText().GetPointer()), __pButton->GetText().GetLength()); + __pTextObject->AppendElement(*pSimpleText); + + if (__pButton->UserDefinedText()) + { + __pTextObject->SetBounds(__pButton->GetUserDefinedTextArea()); + } + else + { + __pTextObject->SetBounds(Rectangle(buttonLeftMargin, buttonTopMargin, + __pButton->GetBounds().width - buttonLeftMargin * 2, __pButton->GetBounds().height - buttonTopMargin * 2)); + } + __pTextObject->SetAlignment(horizontalAlign | verticalAlign); + + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + __pTextObject->Compose(); + + if (__pTextObject->GetTotalLineCount() >= 2) + { + GET_SHAPE_CONFIG(BUTTON::MULTILINE_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, multilineFontSize); + + if (multilineFontSize < __fontSize) + { + __fontSize = multilineFontSize; + SetTextSize(__fontSize); + + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + __pTextObject->Compose(); + } + } + + __pTextObject->SetForegroundColor(__pButton->GetTextColor(__pButton->GetButtonStatus()), 0, __pTextObject->GetTextLength()); + __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + + delete pCanvas; + + return; +} + +void +_ButtonPresenter::DrawToolbarSelectedBitmap(void) +{ + int selectedBitmapMargin = 0; + int selectedBitmapHeight = 0; + int segmentedHeight = 0; + + GET_SHAPE_CONFIG(HEADER::HEADER_ITEM_SELECTED_BITMAP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, selectedBitmapMargin); + GET_SHAPE_CONFIG(HEADER::HEADER_ITEM_SELECTED_BITMAP_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, selectedBitmapHeight); + GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, segmentedHeight); + + Bitmap* pToolbarSelectedBitmap = __pButton->GetToolbarSelectedBitmap(); + + bool isDrawInner = __pButton->IsDrawInner(); + + if (pToolbarSelectedBitmap) + { + Canvas* pCanvas = __pButton->GetCanvasN(); + + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + return; + } + + Rectangle bounds(selectedBitmapMargin, __pButton->GetBounds().height - (__pButton->GetBounds().height - segmentedHeight) / 2, + __pButton->GetBounds().width - selectedBitmapMargin * 2, selectedBitmapHeight); + + if (isDrawInner) + { + bounds.y -= selectedBitmapHeight; + } + + if (pToolbarSelectedBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pToolbarSelectedBitmap); + } + else + { + pCanvas->DrawBitmap(bounds, *pToolbarSelectedBitmap, Rectangle(0, 0, pToolbarSelectedBitmap->GetWidth(), pToolbarSelectedBitmap->GetHeight())); + } + + delete pCanvas; + } + + return; +} + +bool +_ButtonPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pButton) + { + return false; + } + + if (!__pButton->IsEnabled()) + { + return true; + } + + __touchMoveHandled = false; + _ButtonStatus status = __pButton->GetButtonStatus(); + + if (status != _BUTTON_STATUS_SELECTED) + { + __pButton->SetButtonStatus(_BUTTON_STATUS_PRESSED); + } + + __pButton->Invalidate(); + + if (__pButton->GetButtonStyle() == _BUTTON_STYLE_SEGMENT) + { + return false; + } + + return true; +} + +bool +_ButtonPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pButton) + { + return false; + } + + if (!__pButton->IsEnabled()) + { + return true; + } + + _ButtonStatus status = __pButton->GetButtonStatus(); + + if (__pButton->GetButtonStyle() == _BUTTON_STYLE_SEGMENT) + { + return false; + } + + if (status == _BUTTON_STATUS_NORMAL) + { + return true; + } + + Point touchPoint = touchinfo.GetCurrentPosition(); + + touchPoint.x += source.GetClientBounds().x; + touchPoint.y += source.GetClientBounds().y; + + Rectangle bounds = __pButton->GetClientBounds(); + + __pButton->SetButtonStatus(_BUTTON_STATUS_NORMAL); + __pButton->Invalidate(); + + if (bounds.Contains(touchPoint)) + { + __pButton->FireActionEvent(); + } + + return true; +} + +bool +_ButtonPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pButton) + { + return false; + } + + if (!__pButton->IsEnabled()) + { + return true; + } + + if (__pButton->GetButtonStyle() == _BUTTON_STYLE_SEGMENT) + { + return false; + } + + Point touchPoint = touchinfo.GetCurrentPosition(); + + touchPoint.x += source.GetClientBounds().x; + touchPoint.y += source.GetClientBounds().y; + + Rectangle bounds = __pButton->GetClientBounds(); + bool isInButtonArea = bounds.Contains(touchPoint); + _ButtonStatus oldStatus = __pButton->GetButtonStatus(); + + if (isInButtonArea && (__touchMoveHandled != true)) + { + __pButton->SetButtonStatus(_BUTTON_STATUS_PRESSED); + } + else + { + __pButton->SetButtonStatus(_BUTTON_STATUS_NORMAL); + } + + if (__pButton->GetButtonStatus() != oldStatus) + { + __pButton->Invalidate(); + } + + return false; +} + +bool +_ButtonPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pButton) + { + return false; + } + + if (!__pButton->IsEnabled()) + { + return true; + } + + if (__pButton->GetButtonStyle() == _BUTTON_STYLE_SEGMENT) + { + return false; + } + + __pButton->SetButtonStatus(_BUTTON_STATUS_NORMAL); + __pButton->Invalidate(); + + return true; +} + +void +_ButtonPresenter::OnTouchMoveHandled(const _Control& control) +{ + if (__touchMoveHandled == false) + { + __touchMoveHandled = true; + __pButton->SetButtonStatus(_BUTTON_STATUS_NORMAL); + __pButton->Invalidate(); + } + + return; +} + +bool +_ButtonPresenter::IsEnabledStateChanged(void) +{ + bool __currentEnabledState = __pButton->GetEnableState(); + bool ret = false; + + if (__currentEnabledState != __previousEnabledState) + { + __previousEnabledState = __currentEnabledState; + ret = true; + } + + return ret; +} + + + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_CheckButton.cpp b/src/ui/controls/FUiCtrl_CheckButton.cpp new file mode 100644 index 0000000..91810b3 --- /dev/null +++ b/src/ui/controls/FUiCtrl_CheckButton.cpp @@ -0,0 +1,1579 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_CheckButton.cpp + * @brief This is the implementation file for the _CheckButton class. + */ + +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityManager.h" +#include "FUi_ResourceManager.h" +#include "FUi_UiNotificationEvent.h" +#include "FUi_UiEventManager.h" +#include "FUiCtrl_ScrollPanel.h" +#include "FUiCtrl_CheckButton.h" +#include "FUiCtrl_CheckButtonPresenter.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +class CheckButtonAccessibilityListener + : public _IAccessibilityListener +{ +public: + CheckButtonAccessibilityListener(_CheckButton* pCheckButton) + : __pCheckButton(pCheckButton) + { + } + virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element) + { + CheckButtonStyle style = __pCheckButton->GetCheckButtonStyle(); + if (style == CHECK_BUTTON_STYLE_MARK || style == CHECK_BUTTON_STYLE_MARK_WITH_DIVIDER || style == CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON) + { + if(__pCheckButton->IsSelected()) + { + _AccessibilityManager::GetInstance()->ReadContent(L"ticked"); + } + else + { + _AccessibilityManager::GetInstance()->ReadContent(L"unticked"); + } + } + else if (style == CHECK_BUTTON_STYLE_RADIO || style == CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER || style == CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON) + { + if(__pCheckButton->IsSelected()) + { + _AccessibilityManager::GetInstance()->ReadContent(L"selected"); + } + else + { + _AccessibilityManager::GetInstance()->ReadContent(L"unselected"); + } + } + else if (style == CHECK_BUTTON_STYLE_ONOFF || style == CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER || style == CHECK_BUTTON_STYLE_ONOFF_SLIDING) + { + if(__pCheckButton->IsSelected()) + { + _AccessibilityManager::GetInstance()->ReadContent(L"on"); + } + else + { + _AccessibilityManager::GetInstance()->ReadContent(L"off"); + } + } + return true; + } + + _CheckButton* __pCheckButton; +}; + +IMPLEMENT_PROPERTY(_CheckButton); + +_CheckButton::_CheckButton(void) + : __checkButtonStyle(CHECK_BUTTON_STYLE_MARK) + , __backgroundStyle(BACKGROUND_STYLE_DEFAULT) + , __showTitle(false) + , __groupStyle(GROUP_STYLE_NONE) + , __checkButtonStatus(CHECK_BUTTON_STATUS_NORMAL) + , __pCheckButtonPresenter(null) + , __pActionEvent(null) + , __selected(false) + , __checkedActionId(0) + , __uncheckedActionId(0) + , __selectedActionId(-1) + , __text(L"") + , __titleText(L"") + , __pMarkBgNormalBitmap(null) + , __pMarkBgPressedBitmap(null) + , __pMarkBitmap(null) + , __pOnOffBgNormalBitmap(null) + , __pOnOffBgPressedBitmap(null) + , __pOnOffBitmap(null) + , __pOnOffSlidingOnBitmap(null) + , __pOnOffSlidingOffBitmap(null) + , __pDimOnOffSlidingOnBitmap(null) + , __pDimOnOffSlidingOffBitmap(null) + , __pCircleBitmap(null) + , __pCircleNormalEffectBitmap(null) + , __pCirclePressedEffectBitmap(null) + , __pDetailedBitmap(null) + , __pBackgroundBitmap(null) + , __pBackgroundNormalEffectBitmap(null) + , __pBackgroundPressedEffectBitmap(null) + , __pBackgroundTopBitmap(null) + , __pBackgroundTopNormalEffectBitmap(null) + , __pBackgroundTopPressedEffectBitmap(null) + , __pBackgroundMiddleBitmap(null) + , __pBackgroundMiddleNormalEffectBitmap(null) + , __pBackgroundMiddlePressedEffectBitmap(null) + , __pBackgroundBottomBitmap(null) + , __pBackgroundBottomNormalEffectBitmap(null) + , __pBackgroundBottomPressedEffectBitmap(null) + , __horizontalAlignment(ALIGNMENT_LEFT) + , __verticalAlignment(ALIGNMENT_MIDDLE) + , __textSize(0) + , __titleTextSize(0) + , __parentMoveDistance(0) + , __previousTouchArea(false) + , __pRadioGroup(null) + , __pButtonElement(null) + , __pDetailButtonElement(null) + , __pAccessibilityListener(null) +{ + result r = E_SUCCESS; + + _AccessibilityContainer* pContainer = null; + + GET_SHAPE_CONFIG(CHECKBUTTON::TEXT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __textSize); + GET_SHAPE_CONFIG(CHECKBUTTON::TITLE_TEXT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __titleTextSize); + + _CheckButtonPresenter* pPresenter = new (std::nothrow) _CheckButtonPresenter(); + SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = SetPresenter(*pPresenter); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pPresenter->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pPresenter->Install(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + GET_COLOR_CONFIG(CHECKBUTTON::TEXT_NORMAL, __normalTextColor); + GET_COLOR_CONFIG(CHECKBUTTON::TEXT_DISABLED, __disabledTextColor); + GET_COLOR_CONFIG(CHECKBUTTON::TEXT_PRESSED, __pressedTextColor); + GET_COLOR_CONFIG(CHECKBUTTON::TEXT_HIGHLIGHTED, __highlightedTextColor); + + GET_COLOR_CONFIG(CHECKBUTTON::TITLE_TEXT_NORMAL, __normalTitleTextColor); + GET_COLOR_CONFIG(CHECKBUTTON::TITLE_TEXT_DISABLED, __disabledTitleTextColor); + GET_COLOR_CONFIG(CHECKBUTTON::TITLE_TEXT_PRESSED, __pressedTitleTextColor); + GET_COLOR_CONFIG(CHECKBUTTON::TITLE_TEXT_HIGHLIGHTED, __highlightedTitleTextColor); + + GET_COLOR_CONFIG(CHECKBUTTON::BG_NORMAL, __normalColor); + GET_COLOR_CONFIG(CHECKBUTTON::BG_DISABLED, __disabledColor); + GET_COLOR_CONFIG(CHECKBUTTON::BG_PRESSED, __pressedColor); + GET_COLOR_CONFIG(CHECKBUTTON::BG_HIGHLIGHTED, __highlightedColor); + + pContainer = GetAccessibilityContainer(); + + if(pContainer) + { + pContainer->Activate(true); + __pAccessibilityListener = new (std::nothrow) CheckButtonAccessibilityListener(this); + pContainer->AddListener(*__pAccessibilityListener); + } + + ClearLastResult(); + + return; + +CATCH: + delete pPresenter; +} + +_CheckButton* +_CheckButton::CreateCheckButtonN(void) +{ + _CheckButton* pCheckButton = new (std::nothrow) _CheckButton(); + SysTryReturn(NID_UI_CTRL, pCheckButton, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pCheckButton->AcquireHandle(); + + pCheckButton->LoadDefaultBackgroundBitmap(); + + return pCheckButton; + +CATCH: + delete pCheckButton; + return null; +} + +_CheckButton::~_CheckButton(void) +{ + if (__pCheckButtonPresenter) + { + delete __pCheckButtonPresenter; + __pCheckButtonPresenter = null; + } + + if (__pActionEvent) + { + delete __pActionEvent; + __pActionEvent = null; + } + + if (__pMarkBgNormalBitmap) + { + delete __pMarkBgNormalBitmap; + __pMarkBgNormalBitmap = null; + } + + if (__pMarkBgPressedBitmap) + { + delete __pMarkBgPressedBitmap; + __pMarkBgPressedBitmap = null; + } + + if (__pMarkBitmap) + { + delete __pMarkBitmap; + __pMarkBitmap = null; + } + + if (__pOnOffBgNormalBitmap) + { + delete __pOnOffBgNormalBitmap; + __pOnOffBgNormalBitmap = null; + } + + if (__pOnOffBgPressedBitmap) + { + delete __pOnOffBgPressedBitmap; + __pOnOffBgPressedBitmap = null; + } + + if (__pOnOffBitmap) + { + delete __pOnOffBitmap; + __pOnOffBitmap = null; + } + + if (__pOnOffSlidingOnBitmap) + { + delete __pOnOffSlidingOnBitmap; + __pOnOffSlidingOnBitmap = null; + } + + if (__pOnOffSlidingOffBitmap) + { + delete __pOnOffSlidingOffBitmap; + __pOnOffSlidingOffBitmap = null; + } + + if (__pDimOnOffSlidingOnBitmap) + { + delete __pDimOnOffSlidingOnBitmap; + __pDimOnOffSlidingOnBitmap = null; + } + + if (__pDimOnOffSlidingOffBitmap) + { + delete __pDimOnOffSlidingOffBitmap; + __pDimOnOffSlidingOffBitmap = null; + } + + if (__pCircleBitmap) + { + delete __pCircleBitmap; + __pCircleBitmap = null; + } + + if (__pCircleNormalEffectBitmap) + { + delete __pCircleNormalEffectBitmap; + __pCircleNormalEffectBitmap = null; + } + + if (__pCirclePressedEffectBitmap) + { + delete __pCirclePressedEffectBitmap; + __pCirclePressedEffectBitmap = null; + } + + if (__pDetailedBitmap) + { + delete __pDetailedBitmap; + __pDetailedBitmap = null; + } + + if (__pBackgroundBitmap) + { + delete __pBackgroundBitmap; + __pBackgroundBitmap = null; + } + + if (__pBackgroundNormalEffectBitmap) + { + delete __pBackgroundNormalEffectBitmap; + __pBackgroundNormalEffectBitmap = null; + } + + if (__pBackgroundPressedEffectBitmap) + { + delete __pBackgroundPressedEffectBitmap; + __pBackgroundPressedEffectBitmap = null; + } + + if (__pBackgroundTopBitmap) + { + delete __pBackgroundTopBitmap; + __pBackgroundTopBitmap = null; + } + + if (__pBackgroundTopNormalEffectBitmap) + { + delete __pBackgroundTopNormalEffectBitmap; + __pBackgroundTopNormalEffectBitmap = null; + } + + if (__pBackgroundTopPressedEffectBitmap) + { + delete __pBackgroundTopPressedEffectBitmap; + __pBackgroundTopPressedEffectBitmap = null; + } + + if (__pBackgroundMiddleBitmap) + { + delete __pBackgroundMiddleBitmap; + __pBackgroundMiddleBitmap = null; + } + + if (__pBackgroundMiddleNormalEffectBitmap) + { + delete __pBackgroundMiddleNormalEffectBitmap; + __pBackgroundMiddleNormalEffectBitmap = null; + } + + if (__pBackgroundMiddlePressedEffectBitmap) + { + delete __pBackgroundMiddlePressedEffectBitmap; + __pBackgroundMiddlePressedEffectBitmap = null; + } + + if (__pBackgroundBottomBitmap) + { + delete __pBackgroundBottomBitmap; + __pBackgroundBottomBitmap = null; + } + + if (__pBackgroundBottomNormalEffectBitmap) + { + delete __pBackgroundBottomNormalEffectBitmap; + __pBackgroundBottomNormalEffectBitmap = null; + } + + if (__pBackgroundBottomPressedEffectBitmap) + { + delete __pBackgroundBottomPressedEffectBitmap; + __pBackgroundBottomPressedEffectBitmap = null; + } + + if (__pButtonElement) + { + __pButtonElement->Activate(false); + __pButtonElement = null; + } + if (__pDetailButtonElement) + { + __pDetailButtonElement->Activate(false); + __pDetailButtonElement = null; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if(pContainer) + { + pContainer->RemoveListener(*__pAccessibilityListener); + } + delete __pAccessibilityListener; + __pAccessibilityListener = null; + + ClearLastResult(); +} + +result +_CheckButton::SetPresenter(const _CheckButtonPresenter& checkButtonPresenter) +{ + __pCheckButtonPresenter = const_cast <_CheckButtonPresenter*>(&checkButtonPresenter); + + return E_SUCCESS; +} + +void +_CheckButton::OnDraw(void) +{ + __pCheckButtonPresenter->Draw(); + UpdateAccessibilityElement(); + + return; +} + +result +_CheckButton::OnAttachedToMainTree(void) +{ + UpdateAccessibilityElement(); + + return E_SUCCESS; +} + +void +_CheckButton::UpdateAccessibilityElement(void) +{ + if(likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + CheckButtonStyle checkStyle = GetCheckButtonStyle(); + + if(pContainer) + { + String label = L""; + if(GetShowTitle()) + { + label = GetTitleText(); + label.Append(L", "); + } + + if (checkStyle == CHECK_BUTTON_STYLE_MARK || checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DIVIDER || checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON) + { + if (__pButtonElement == null) + { + __pButtonElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pButtonElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + pContainer->AddElement(*__pButtonElement); + } + __pButtonElement->SetBounds(Rectangle(0,0, GetBounds().width, GetBounds().height)); + __pButtonElement->SetLabel(label + GetText()); + __pButtonElement->SetTrait(L"Tickbox"); + __pButtonElement->SetName(L"CheckButton"); + + if (checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON) + { + if (__pDetailButtonElement == null) + { + __pDetailButtonElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pDetailButtonElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + pContainer->AddElement(*__pDetailButtonElement); + } + __pDetailButtonElement->SetBounds(__pCheckButtonPresenter->GetDetailedButtonBounds()); + __pDetailButtonElement->SetLabel(L"More"); + __pDetailButtonElement->SetTrait(L"More Button"); + __pDetailButtonElement->SetName(L"MoreButton"); + } + } + else if (checkStyle == CHECK_BUTTON_STYLE_RADIO || checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER || checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON) + { + if (__pButtonElement == null) + { + __pButtonElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pButtonElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + pContainer->AddElement(*__pButtonElement); + } + __pButtonElement->SetBounds(Rectangle(0,0, GetBounds().width, GetBounds().height)); + __pButtonElement->SetLabel(label + GetText()); + __pButtonElement->SetTrait(L"Radio Button"); + __pButtonElement->SetName(L"RadioButton"); + + if (checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON) + { + if (__pDetailButtonElement == null) + { + __pDetailButtonElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pDetailButtonElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + pContainer->AddElement(*__pDetailButtonElement); + } + __pDetailButtonElement->SetBounds(__pCheckButtonPresenter->GetDetailedButtonBounds()); + __pDetailButtonElement->SetLabel(L"More"); + __pDetailButtonElement->SetTrait(L"More Button"); + __pDetailButtonElement->SetName(L"MoreButton"); + } + } + else if (checkStyle == CHECK_BUTTON_STYLE_ONOFF || checkStyle == CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER || checkStyle == CHECK_BUTTON_STYLE_ONOFF_SLIDING) + { + if (__pButtonElement == null) + { + __pButtonElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pButtonElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + pContainer->AddElement(*__pButtonElement); + } + __pButtonElement->SetBounds(Rectangle(0,0, GetBounds().width, GetBounds().height)); + __pButtonElement->SetLabel(label + GetText()); + __pButtonElement->SetTrait(L"On off button"); + __pButtonElement->SetName(L"OnOffButton"); + } + UpdateAccessibilityCheckStatus(); + } + + return; +} + +bool +_CheckButton::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pCheckButtonPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_CheckButton::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pCheckButtonPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_CheckButton::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pCheckButtonPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_CheckButton::OnTouchCanceled(const _Control & source, const _TouchInfo & touchinfo) +{ + return __pCheckButtonPresenter->OnTouchCanceled(source, touchinfo); +} + +void +_CheckButton::OnTouchMoveHandled(const _Control& control) +{ + __pCheckButtonPresenter->OnTouchMoveHandled(control); + + return; +} + +void +_CheckButton::OnBoundsChanged(void) +{ + if(__pButtonElement) + { + __pButtonElement->SetBounds(Rectangle(0,0, GetBounds().width, GetBounds().height)); + } + + if(__pDetailButtonElement) + { + __pDetailButtonElement->SetBounds(__pCheckButtonPresenter->GetDetailedButtonBounds()); + } + + return; +} + +void +_CheckButton::OnFontChanged(Font* pFont) +{ + __pCheckButtonPresenter->OnFontChanged(pFont); + + return; +} + +void +_CheckButton::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pCheckButtonPresenter->OnFontInfoRequested(style, size); + + return; +} + +void +_CheckButton::SendTouchReleasedEvent(const _Control& control) +{ + const _Control* pDestination = dynamic_cast (&control); + SysTryReturnVoidResult(NID_UI_CTRL, pDestination != null, E_SYSTEM, "[E_SYSTEM] pDestination is null."); + + ArrayList* pArgs = new (std::nothrow) ArrayList(); + SysTryReturnVoidResult(NID_UI_CTRL, pArgs != null, E_SYSTEM, "[E_SYSTEM] pArgs is null."); + + result r = E_SYSTEM; + r = pArgs->Construct(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to construct pArgs"); + + // Index 0 : Type + String type(L"CheckButtonReleasedEvent"); + r = pArgs->Add(type); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to add type to pArgs"); + + r = pArgs->Add(*this); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to add data to pArgs"); + + + _UiNotificationEvent event(__pRadioGroup->GetHandle(), pArgs); + + r = _UiEventManager::GetInstance()->SendEvent(event); + + return; +} + +result +_CheckButton::SetSelected(bool select) +{ + return SetProperty("selected", Variant(select)); +} + +result +_CheckButton::SetPropertySelected(const Variant& selected) +{ + __selected = selected.ToBool(); + + __pCheckButtonPresenter->Draw(); + + return E_SUCCESS; +} + +bool +_CheckButton::IsSelected(void) const +{ + Variant selected = GetProperty("selected"); + + return selected.ToBool(); +} + +Variant +_CheckButton::GetPropertySelected(void) const +{ + return Variant(__selected); +} + +result +_CheckButton::AddActionEventListener(const Controls::_IActionEventListener& listener) +{ + if (__pActionEvent == null) + { + __pActionEvent = _ActionEvent::CreateInstanceN(*this); + SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.\n"); + } + + result r = __pActionEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_CheckButton::RemoveActionEventListener(const Controls::_IActionEventListener& listener) +{ + result r = E_OBJ_NOT_FOUND; + + if (__pActionEvent) + { + r = __pActionEvent->RemoveListener(listener); + } + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_CheckButton::AddRadioGroup(const _Control& radioGroup) +{ + SysTryReturn(NID_UI_CTRL, __pRadioGroup == null, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The CheckButton is already belonged to a RadioGroup.\n"); + + __pRadioGroup = const_cast <_Control*>(&radioGroup); + + return E_SUCCESS; +} + +result +_CheckButton::RemoveRadioGroup(void) +{ + SysTryReturn(NID_UI_CTRL, __pRadioGroup, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, + "[E_OBJ_NOT_FOUND] Unable to find the CheckButton.\n"); + + __pRadioGroup = null; + + return E_SUCCESS; +} + +result +_CheckButton::SetActionId(int checkedActionId, int uncheckedActionId, int selectedActionId) +{ + result r = E_SUCCESS; + + r = SetProperty("checkedActionId", Variant(checkedActionId)); + r = SetProperty("uncheckedActionId", Variant(uncheckedActionId)); + r = SetProperty("selectedActionId", Variant(selectedActionId)); + + return r; +} + +result +_CheckButton::SetPropertyCheckedActionId(const Variant& checkedActionId) +{ + __checkedActionId = checkedActionId.ToInt(); + + return E_SUCCESS; +} + +int +_CheckButton::GetCheckedActionId(void) const +{ + Variant checkedActionId = GetProperty("checkedActionId"); + + return checkedActionId.ToInt(); +} + +Variant +_CheckButton::GetPropertyCheckedActionId(void) const +{ + return Variant(__checkedActionId); +} + +result +_CheckButton::SetPropertyUncheckedActionId(const Variant& uncheckedActionId) +{ + __uncheckedActionId = uncheckedActionId.ToInt(); + + return E_SUCCESS; +} + +int +_CheckButton::GetUncheckedActionId(void) const +{ + Variant uncheckedActionId = GetProperty("uncheckedActionId"); + + return uncheckedActionId.ToInt(); +} + +Variant +_CheckButton::GetPropertyUncheckedActionId(void) const +{ + return Variant(__uncheckedActionId); +} + +result +_CheckButton::SetPropertySelectedActionId(const Variant& selectedActionId) +{ + __selectedActionId = selectedActionId.ToInt(); + + return E_SUCCESS; +} + +int +_CheckButton::GetSelectedActionId(void) const +{ + Variant selectedActionId = GetProperty("selectedActionId"); + + return selectedActionId.ToInt(); +} + +Variant +_CheckButton::GetPropertySelectedActionId(void) const +{ + return Variant(__selectedActionId); +} + +result +_CheckButton::LoadDefaultBackgroundBitmap(void) +{ + result r = E_SUCCESS; + + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundNormalEffectBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundPressedEffectBitmap); + + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundTopBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::TOP_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundTopNormalEffectBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::TOP_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundTopPressedEffectBitmap); + + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::CENTER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundMiddleBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::CENTER_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundMiddleNormalEffectBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::CENTER_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundMiddlePressedEffectBitmap); + + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundBottomBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::BOTTOM_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundBottomNormalEffectBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::BOTTOM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundBottomPressedEffectBitmap); + + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::MARK_ICON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pMarkBgNormalBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::MARK_ICON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pMarkBgPressedBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::MARK_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pMarkBitmap); + + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::ONOFF_ICON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pOnOffBgNormalBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::ONOFF_ICON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pOnOffBgPressedBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::ONOFF_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pOnOffBitmap); + + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::ONOFF_SLIDING_ICON_ON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pOnOffSlidingOnBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::ONOFF_SLIDING_ICON_OFF_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pOnOffSlidingOffBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::ONOFF_SLIDING_ICON_ON_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDimOnOffSlidingOnBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::ONOFF_SLIDING_ICON_OFF_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDimOnOffSlidingOffBitmap); + + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::DETAILED_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pCircleBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::DETAILED_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pCircleNormalEffectBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::DETAILED_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pCirclePressedEffectBitmap); + r = GET_BITMAP_CONFIG_N(CHECKBUTTON::DETAILED_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDetailedBitmap); + + return r; +} + +result +_CheckButton::SetText(const String& text) +{ + return SetProperty("text", Variant(text)); +} + +result +_CheckButton::SetPropertyText(const Variant& text) +{ + __text = text.ToString(); + + if(__pButtonElement) + { + __pButtonElement->SetLabel(__text); + } + + return E_SUCCESS; +} + +String +_CheckButton::GetText(void) const +{ + Variant text = GetProperty("text"); + + return text.ToString(); +} + +Variant +_CheckButton::GetPropertyText(void) const +{ + return Variant(__text); +} + +result +_CheckButton::SetTitleText(const String& title) +{ + return SetProperty("titleText", Variant(title)); +} + +result +_CheckButton::SetPropertyTitleText(const Variant& title) +{ + __titleText = title.ToString(); + + if (__pButtonElement) + { + String label = __titleText; + label.Append(L", "); + + __pButtonElement->SetLabel(label + GetText()); + } + return E_SUCCESS; +} + +String +_CheckButton::GetTitleText(void) const +{ + Variant title = GetProperty("titleText"); + + return title.ToString(); +} + +Variant +_CheckButton::GetPropertyTitleText(void) const +{ + return Variant(__titleText); +} + +result +_CheckButton::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + __horizontalAlignment = alignment; + return E_SUCCESS; +} + +HorizontalAlignment +_CheckButton::GetTextHorizontalAlignment(void) const +{ + return __horizontalAlignment; +} + +result +_CheckButton::SetTextVerticalAlignment(VerticalAlignment alignment) +{ + __verticalAlignment = alignment; + return E_SUCCESS; +} + +VerticalAlignment +_CheckButton::GetTextVerticalAlignment(void) const +{ + return __verticalAlignment; +} + +result +_CheckButton::SetTextColor(const Color& color) +{ + return SetProperty("normalTextColor", Variant(color)); +} + +Color +_CheckButton::GetTextColor(void) const +{ + Variant color = GetProperty("normalTextColor"); + + return color.ToColor(); +} + +result +_CheckButton::SetDisabledTextColor(const Color& color) +{ + return SetProperty("disabledTextColor", Variant(color)); +} + +Color +_CheckButton::GetDisabledTextColor(void) const +{ + Variant color = GetProperty("disabledTextColor"); + + return color.ToColor(); +} + +result +_CheckButton::SetPressedTextColor(const Color& color) +{ + return SetProperty("pressedTextColor", Variant(color)); +} + +Color +_CheckButton::GetPressedTextColor(void) const +{ + Variant color = GetProperty("pressedTextColor"); + + return color.ToColor(); +} + +result +_CheckButton::SetHighlightedTextColor(const Color& color) +{ + return SetProperty("highlightedTextColor", Variant(color)); +} + +Color +_CheckButton::GetHighlightedTextColor(void) const +{ + + Variant color = GetProperty("highlightedTextColor"); + + return color.ToColor(); +} + +result +_CheckButton::SetPropertyNormalTextColor(const Variant& color) +{ + __normalTextColor = color.ToColor(); + return E_SUCCESS; +} + +result +_CheckButton::SetPropertyDisabledTextColor(const Variant& color) +{ + __disabledTextColor = color.ToColor(); + return E_SUCCESS; +} + +result +_CheckButton::SetPropertyPressedTextColor(const Variant& color) +{ + __pressedTextColor = color.ToColor(); + return E_SUCCESS; +} + +result +_CheckButton::SetPropertyHighlightedTextColor(const Variant& color) +{ + __highlightedTextColor = color.ToColor(); + return E_SUCCESS; +} + +Variant +_CheckButton::GetPropertyNormalTextColor(void) const +{ + return Variant(__normalTextColor); +} + +Variant +_CheckButton::GetPropertyDisabledTextColor(void) const +{ + return Variant(__disabledTextColor); +} + +Variant +_CheckButton::GetPropertyPressedTextColor(void) const +{ + return Variant(__pressedTextColor); +} + +Variant +_CheckButton::GetPropertyHighlightedTextColor(void) const +{ + return Variant(__highlightedTextColor); +} + +result +_CheckButton::SetTitleTextColor(const Color& color) +{ + return SetProperty("normalTitleTextColor", Variant(color)); +} + +Color +_CheckButton::GetTitleTextColor(void) const +{ + Variant color = GetProperty("normalTitleTextColor"); + + return color.ToColor(); +} + +result +_CheckButton::SetDisabledTitleTextColor(const Color& color) +{ + return SetProperty("disabledTitleTextColor", Variant(color)); +} + +Color +_CheckButton::GetDisabledTitleTextColor(void) const +{ + Variant color = GetProperty("disabledTitleTextColor"); + + return color.ToColor(); +} + +result +_CheckButton::SetPressedTitleTextColor(const Color& color) +{ + return SetProperty("pressedTitleTextColor", Variant(color)); +} + +Color +_CheckButton::GetPressedTitleTextColor(void) const +{ + Variant color = GetProperty("pressedTitleTextColor"); + + return color.ToColor(); +} + +result +_CheckButton::SetHighlightedTitleTextColor(const Color& color) +{ + return SetProperty("highlightedTitleTextColor", Variant(color)); +} + +Color +_CheckButton::GetHighlightedTitleTextColor(void) const +{ + Variant color = GetProperty("highlightedTitleTextColor"); + + return color.ToColor(); +} + +result +_CheckButton::SetPropertyNormalTitleTextColor(const Variant& color) +{ + __normalTitleTextColor = color.ToColor(); + return E_SUCCESS; +} + +result +_CheckButton::SetPropertyDisabledTitleTextColor(const Variant& color) +{ + __disabledTitleTextColor = color.ToColor(); + return E_SUCCESS; +} + +result +_CheckButton::SetPropertyPressedTitleTextColor(const Variant& color) +{ + __pressedTitleTextColor = color.ToColor(); + return E_SUCCESS; +} + +result +_CheckButton::SetPropertyHighlightedTitleTextColor(const Variant& color) +{ + __highlightedTitleTextColor = color.ToColor(); + return E_SUCCESS; +} + +Variant +_CheckButton::GetPropertyNormalTitleTextColor(void) const +{ + return Variant(__normalTitleTextColor); +} + +Variant +_CheckButton::GetPropertyDisabledTitleTextColor(void) const +{ + return Variant(__disabledTitleTextColor); +} + +Variant +_CheckButton::GetPropertyPressedTitleTextColor(void) const +{ + return Variant(__pressedTitleTextColor); +} + +Variant +_CheckButton::GetPropertyHighlightedTitleTextColor(void) const +{ + return Variant(__highlightedTitleTextColor); +} + +result +_CheckButton::SetColor(CheckButtonStatus status, const Color& color) +{ + result r = E_SUCCESS; + + switch (status) + { + case CHECK_BUTTON_STATUS_NORMAL: + r = SetProperty("normalColor", Variant(color)); + break; + case CHECK_BUTTON_STATUS_DISABLED: + r = SetProperty("disabledColor", Variant(color)); + break; + case CHECK_BUTTON_STATUS_PRESSED: + r = SetProperty("pressedColor", Variant(color)); + break; + default: + r = SetProperty("highlightedColor", Variant(color)); + } + + return r; +} + +result +_CheckButton::SetPropertyNormalColor(const Variant& color) +{ + __normalColor = color.ToColor(); + return E_SUCCESS; +} + +result +_CheckButton::SetPropertyDisabledColor(const Variant& color) +{ + __disabledColor = color.ToColor(); + return E_SUCCESS; +} + +result +_CheckButton::SetPropertyPressedColor(const Variant& color) +{ + __pressedColor = color.ToColor(); + return E_SUCCESS; +} + +result +_CheckButton::SetPropertyHighlightedColor(const Variant& color) +{ + __highlightedColor = color.ToColor(); + return E_SUCCESS; +} + +Color +_CheckButton::GetColor(CheckButtonStatus status) const +{ + Variant color; + + switch (status) + { + case CHECK_BUTTON_STATUS_NORMAL: + color = GetProperty("normalColor"); + break; + case CHECK_BUTTON_STATUS_DISABLED: + color = GetProperty("disabledColor"); + break; + case CHECK_BUTTON_STATUS_PRESSED: + color = GetProperty("pressedColor"); + break; + default: + color = GetProperty("highlightedColor"); + } + + return color.ToColor(); +} + +Variant +_CheckButton::GetPropertyNormalColor(void) const +{ + return Variant(__normalColor); +} + +Variant +_CheckButton::GetPropertyDisabledColor(void) const +{ + return Variant(__disabledColor); +} + +Variant +_CheckButton::GetPropertyPressedColor(void) const +{ + return Variant(__pressedColor); +} + +Variant +_CheckButton::GetPropertyHighlightedColor(void) const +{ + return Variant(__highlightedColor); +} + +int +_CheckButton::GetTextSize(void) const +{ + return __textSize; +} + +int +_CheckButton::GetTitleTextSize(void) const +{ + return __titleTextSize; +} + +result +_CheckButton::SetCheckButtonStyle(const CheckButtonStyle& checkButtonStyle) +{ + __checkButtonStyle = checkButtonStyle; + return E_SUCCESS; +} + +result +_CheckButton::SetBackgroundStyle(const BackgroundStyle& backgroundStyle) +{ + __backgroundStyle = backgroundStyle; + return E_SUCCESS; +} + +result +_CheckButton::SetShowTitle(bool showTitle) +{ + __showTitle = showTitle; + return E_SUCCESS; +} + +result +_CheckButton::SetGroupStyle(const GroupStyle& groupStyle) +{ + __groupStyle = groupStyle; + return E_SUCCESS; +} + +result +_CheckButton::SetCheckButtonStatus(CheckButtonStatus checkButtonStatus) +{ + if (__checkButtonStatus != checkButtonStatus) + { + __checkButtonStatus = checkButtonStatus; + } + + if (CHECK_BUTTON_STATUS_DISABLED == __checkButtonStatus) + { + SetEnableState(false); + } + else + { + SetEnableState(true); + } + + return E_SUCCESS; +} + +CheckButtonStyle +_CheckButton::GetCheckButtonStyle(void) const +{ + return __checkButtonStyle; +} + +BackgroundStyle +_CheckButton::GetBackgroundStyle(void) const +{ + return __backgroundStyle; +} + +bool +_CheckButton::GetShowTitle(void) const +{ + return __showTitle; +} + +GroupStyle +_CheckButton::GetGroupStyle(void) const +{ + return __groupStyle; +} + +CheckButtonStatus +_CheckButton::GetCheckButtonStatus(void) const +{ + CheckButtonStatus status = __checkButtonStatus; + + if (!IsEnabled()) + { + status = CHECK_BUTTON_STATUS_DISABLED; + } + + return status; +} + +Bitmap* +_CheckButton::GetMarkBgNormalBitmap(void) const +{ + return __pMarkBgNormalBitmap; +} + +Bitmap* +_CheckButton::GetMarkBgPressedBitmap(void) const +{ + return __pMarkBgPressedBitmap; +} + +Bitmap* +_CheckButton::GetMarkBitmap(void) const +{ + return __pMarkBitmap; +} + +Bitmap* +_CheckButton::GetOnOffBgNormalBitmap(void) const +{ + return __pOnOffBgNormalBitmap; +} + +Bitmap* +_CheckButton::GetOnOffBgPressedBitmap(void) const +{ + return __pOnOffBgPressedBitmap; +} + +Bitmap* +_CheckButton::GetOnOffBitmap(void) const +{ + return __pOnOffBitmap; +} + +Bitmap* +_CheckButton::GetOnOffSlidingOnBitmap(void) const +{ + return __pOnOffSlidingOnBitmap; +} + +Bitmap* +_CheckButton::GetOnOffSlidingOffBitmap(void) const +{ + return __pOnOffSlidingOffBitmap; +} + +Bitmap* +_CheckButton::GetDimOnOffSlidingOnBitmap(void) const +{ + return __pDimOnOffSlidingOnBitmap; +} + +Bitmap* +_CheckButton::GetDimOnOffSlidingOffBitmap(void) const +{ + return __pDimOnOffSlidingOffBitmap; +} + +Bitmap* +_CheckButton::GetCircleBitmap(void) const +{ + return __pCircleBitmap; +} + +Bitmap* +_CheckButton::GetCircleNormalEffectBitmap(void) const +{ + return __pCircleNormalEffectBitmap; +} + +Bitmap* +_CheckButton::GetCirclePressedEffectBitmap(void) const +{ + return __pCirclePressedEffectBitmap; +} + +Bitmap* +_CheckButton::GetDetailedBitmap(void) const +{ + return __pDetailedBitmap; +} + +Bitmap* +_CheckButton::GetBackgroundBitmap(GroupStyle groupStyle) const +{ + switch(groupStyle) + { + case GROUP_STYLE_TOP: + return __pBackgroundTopBitmap; + break; + case GROUP_STYLE_MIDDLE: + return __pBackgroundMiddleBitmap; + break; + case GROUP_STYLE_BOTTOM: + return __pBackgroundBottomBitmap; + break; + default: + return __pBackgroundBitmap; + } +} + +Bitmap* +_CheckButton::GetBackgroundNormalEffectBitmap(GroupStyle groupStyle) const +{ + switch(groupStyle) + { + case GROUP_STYLE_TOP: + return __pBackgroundTopNormalEffectBitmap; + break; + case GROUP_STYLE_MIDDLE: + return __pBackgroundMiddleNormalEffectBitmap; + break; + case GROUP_STYLE_BOTTOM: + return __pBackgroundBottomNormalEffectBitmap; + break; + default: + return __pBackgroundNormalEffectBitmap; + } +} + +Bitmap* +_CheckButton::GetBackgroundPressedEffectBitmap(GroupStyle groupStyle) const +{ + switch(groupStyle) + { + case GROUP_STYLE_TOP: + return __pBackgroundTopPressedEffectBitmap; + break; + case GROUP_STYLE_MIDDLE: + return __pBackgroundMiddlePressedEffectBitmap; + break; + case GROUP_STYLE_BOTTOM: + return __pBackgroundBottomPressedEffectBitmap; + break; + default: + return __pBackgroundPressedEffectBitmap; + } +} + +bool +_CheckButton::IsTouchAreaChanged(bool currentButtonArea) +{ + if (__previousTouchArea != currentButtonArea) + { + __previousTouchArea = currentButtonArea; + return true; + } + else + { + return false; + } +} + +result +_CheckButton::FireActionEvent(void) +{ + result r = E_SUCCESS; + + if (__selected) + { + __selected = false; + + if (__pActionEvent) + { + IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__uncheckedActionId); + SysTryReturn(NID_UI_CTRL, pEventArg, E_INVALID_STATE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + __pActionEvent->Fire(*pEventArg); + } + } + else + { + __selected = true; + + if (__pActionEvent) + { + IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__checkedActionId); + SysTryReturn(NID_UI_CTRL, pEventArg, E_INVALID_STATE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + __pActionEvent->Fire(*pEventArg); + } + } + return r; +} + +_Control* +_CheckButton::GetRadioGroup(void) +{ + return __pRadioGroup; +} + +void +_CheckButton::UpdateAccessibilityCheckStatus(void) +{ + if(likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + if (__checkButtonStyle == CHECK_BUTTON_STYLE_MARK || __checkButtonStyle == CHECK_BUTTON_STYLE_MARK_WITH_DIVIDER || __checkButtonStyle == CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON) + { + if (__pButtonElement != null) + { + if(__selected) + { + __pButtonElement->SetValue(L"tick"); + } + else + { + __pButtonElement->SetValue(L"untick"); + } + } + } + else if (__checkButtonStyle == CHECK_BUTTON_STYLE_RADIO || __checkButtonStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER || __checkButtonStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON) + { + if (__pButtonElement != null) + { + if(__selected) + { + __pButtonElement->SetValue(L"selected"); + } + else + { + __pButtonElement->SetValue(L"unselected"); + } + } + } + else if (__checkButtonStyle == CHECK_BUTTON_STYLE_ONOFF || __checkButtonStyle == CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER) + { + if (__pButtonElement != null) + { + if(__selected) + { + __pButtonElement->SetValue(L"on"); + } + else + { + __pButtonElement->SetValue(L"off"); + } + } + } + + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_CheckButtonImpl.cpp b/src/ui/controls/FUiCtrl_CheckButtonImpl.cpp new file mode 100644 index 0000000..0b2a415 --- /dev/null +++ b/src/ui/controls/FUiCtrl_CheckButtonImpl.cpp @@ -0,0 +1,971 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_CheckButtonImpl.cpp + * @brief This is the implementation file for the _CheckButtonImpl class. + */ + +#include +#include +#include +#include +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_CheckButtonImpl.h" +#include "FUiCtrl_CheckButton.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::App; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Dimension +_CheckButtonImpl::CheckButtonSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Dimension dimension(0, 0); + + r = GET_DIMENSION_CONFIG(CHECKBUTTON::MIN_SIZE, orientation, dimension); + SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] A system error occurred.", GetErrorMessage(r)); + + SetLastResult(r); + + return dimension; +} + +_CheckButtonImpl* +_CheckButtonImpl::GetInstance(CheckButton& checkButton) +{ + return static_cast<_CheckButtonImpl*> (checkButton._pControlImpl); +} + +const _CheckButtonImpl* +_CheckButtonImpl::GetInstance(const CheckButton& checkButton) +{ + return static_cast (checkButton._pControlImpl); +} + +_CheckButtonImpl::_CheckButtonImpl(CheckButton* pPublic, _CheckButton* pCore) + : _ControlImpl(pPublic, pCore) + , __pPublicActionEvent(null) +{ + ClearLastResult(); +} + +_CheckButtonImpl::~_CheckButtonImpl(void) +{ + _CheckButtonImpl::GetCore().RemoveActionEventListener(*this); + + if (__pPublicActionEvent) + { + delete __pPublicActionEvent; + __pPublicActionEvent = null; + } + + ClearLastResult(); +} + +_CheckButtonImpl* +_CheckButtonImpl::CreateCheckButtonImplN(CheckButton* pControl, const Rectangle& bounds) +{ + result r = E_SUCCESS; + r = GET_SIZE_INFO(CheckButton).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] The given size is not valid."); + + _CheckButton* pCore = _CheckButton::CreateCheckButtonN(); + SysTryReturn(NID_UI_CTRL, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _CheckButtonImpl* pImpl = new (std::nothrow) _CheckButtonImpl(pControl, pCore); + r = _ControlImpl::CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(CheckButton), bounds, pCore->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddActionEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + ClearLastResult(); + + return pImpl; + +CATCH: + delete pImpl; + return null; +} + +Color +_CheckButtonImpl::GetColorOnError(void) +{ + return Color(0XFFFFFFFF); +} + +const char* +_CheckButtonImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::CheckButton"; +} + +const CheckButton& +_CheckButtonImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +CheckButton& +_CheckButtonImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _CheckButton& +_CheckButtonImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_CheckButton& +_CheckButtonImpl::GetCore(void) +{ + return static_cast <_CheckButton&>(_ControlImpl::GetCore()); +} + +result +_CheckButtonImpl::SetSelected(bool select) +{ + result r = GetCore().SetSelected(select); + + SetLastResultReturn(r); +} + +bool +_CheckButtonImpl::IsSelected(void) const +{ + ClearLastResult(); + + return GetCore().IsSelected(); +} + +result +_CheckButtonImpl::AddActionEventListener(IActionEventListener& listener) +{ + if (__pPublicActionEvent == null) + { + __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.") + } + + result r = __pPublicActionEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return E_SUCCESS; +} + +result +_CheckButtonImpl::RemoveActionEventListener(IActionEventListener& listener) +{ + result r = E_OBJ_NOT_FOUND; + + if (__pPublicActionEvent) + { + r = __pPublicActionEvent->RemoveListener(listener); + } + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return E_SUCCESS; +} + +result +_CheckButtonImpl::SetActionId(int checkedActionId, int uncheckedActionId, int selectedActionId) +{ + result r = GetCore().SetActionId(checkedActionId, uncheckedActionId, selectedActionId); + + SetLastResultReturn(r); +} + +int +_CheckButtonImpl::GetCheckedActionId(void) const +{ + ClearLastResult(); + + return GetCore().GetCheckedActionId(); +} + +int +_CheckButtonImpl::GetUncheckedActionId(void) const +{ + ClearLastResult(); + + return GetCore().GetUncheckedActionId(); +} + +int +_CheckButtonImpl::GetSelectedActionId(void) const +{ + ClearLastResult(); + + return GetCore().GetSelectedActionId(); +} + +result +_CheckButtonImpl::SetText(const String& text) +{ + int textLength = text.GetLength(); + int checkButtonTextMaxLength = 0; + GET_FIXED_VALUE_CONFIG(CHECKBUTTON::TEXT_MAX_LENGTH, _CONTROL_ORIENTATION_PORTRAIT, checkButtonTextMaxLength); + String tempText = String(text); + + if (textLength >= checkButtonTextMaxLength) + { + tempText.Remove(checkButtonTextMaxLength - 1, textLength - checkButtonTextMaxLength + 1); + } + + Variant var(tempText); + result r = GetCore().SetPropertyText(var); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +String +_CheckButtonImpl::GetText(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyText().ToString(); +} + +result +_CheckButtonImpl::SetTitleText(const String& title) +{ + SysTryReturn(NID_UI_CTRL, GetCore().GetShowTitle() == true , E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] The CheckButton has no title style.\n"); + + int titleLength = title.GetLength(); + int checkButtonTitleMaxLength = 0; + GET_FIXED_VALUE_CONFIG(CHECKBUTTON::TITLE_TEXT_MAX_LENGTH, _CONTROL_ORIENTATION_PORTRAIT, checkButtonTitleMaxLength); + String tempTitle = String(title); + + if (titleLength >= checkButtonTitleMaxLength) + { + tempTitle.Remove(checkButtonTitleMaxLength - 1, titleLength - checkButtonTitleMaxLength + 1); + } + + Variant var(tempTitle); + result r = GetCore().SetPropertyTitleText(var); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +String +_CheckButtonImpl::GetTitleText(void) const +{ + SysTryReturn(NID_UI_CTRL, GetCore().GetShowTitle() == true, L"", E_INVALID_STATE, + "[E_INVALID_STATE] The CheckButton has no title style.\n"); + + ClearLastResult(); + + return GetCore().GetPropertyTitleText().ToString(); +} + +result +_CheckButtonImpl::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + result r = GetCore().SetTextHorizontalAlignment(alignment); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +HorizontalAlignment +_CheckButtonImpl::GetTextHorizontalAlignment(void) const +{ + ClearLastResult(); + + return GetCore().GetTextHorizontalAlignment(); +} + +result +_CheckButtonImpl::SetTextVerticalAlignment(VerticalAlignment alignment) +{ + result r = GetCore().SetTextVerticalAlignment(alignment); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +VerticalAlignment +_CheckButtonImpl::GetTextVerticalAlignment(void) const +{ + ClearLastResult(); + + return GetCore().GetTextVerticalAlignment(); +} + +result +_CheckButtonImpl::SetTextColor(const Color& color) +{ + result r = GetCore().SetTextColor(color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_CheckButtonImpl::GetTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetTextColor(); +} + +result +_CheckButtonImpl::SetDisabledTextColor(const Color& color) +{ + result r = GetCore().SetDisabledTextColor(color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_CheckButtonImpl::GetDisabledTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetDisabledTextColor(); +} + +result +_CheckButtonImpl::SetPressedTextColor(const Color& color) +{ + result r = GetCore().SetPressedTextColor(color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_CheckButtonImpl::GetPressedTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetPressedTextColor(); +} + +result +_CheckButtonImpl::SetHighlightedTextColor(const Color& color) +{ + result r = GetCore().SetHighlightedTextColor(color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_CheckButtonImpl::GetHighlightedTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetHighlightedTextColor(); +} + +result +_CheckButtonImpl::SetTitleTextColor(const Color& color) +{ + result r = GetCore().SetTitleTextColor(color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_CheckButtonImpl::GetTitleTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetTitleTextColor(); +} + +result +_CheckButtonImpl::SetDisabledTitleTextColor(const Color& color) +{ + result r = GetCore().SetDisabledTitleTextColor(color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_CheckButtonImpl::GetDisabledTitleTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetDisabledTitleTextColor(); +} + +result +_CheckButtonImpl::SetPressedTitleTextColor(const Color& color) +{ + result r = GetCore().SetPressedTitleTextColor(color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_CheckButtonImpl::GetPressedTitleTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetPressedTitleTextColor(); +} + +result +_CheckButtonImpl::SetHighlightedTitleTextColor(const Color& color) +{ + result r = GetCore().SetHighlightedTitleTextColor(color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_CheckButtonImpl::GetHighlightedTitleTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetHighlightedTitleTextColor(); +} + +result +_CheckButtonImpl::SetColor(CheckButtonStatus status, const Color& color) +{ + SysTryReturn(NID_UI_CTRL, GetCore().GetBackgroundStyle() != BACKGROUND_STYLE_NONE, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] Unable to set color.\n"); + + result r = GetCore().SetColor(status, color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Color +_CheckButtonImpl::GetColor(CheckButtonStatus status) const +{ + SysTryReturn(NID_UI_CTRL, GetCore().GetBackgroundStyle() != BACKGROUND_STYLE_NONE, + _CheckButtonImpl::GetColorOnError(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] Unable to get color.\n"); + + ClearLastResult(); + + return GetCore().GetColor(status); +} + +result +_CheckButtonImpl::SetCheckButtonStyle(const CheckButtonStyle& checkButtonStyle) +{ + result r = GetCore().SetCheckButtonStyle(checkButtonStyle); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_CheckButtonImpl::SetBackgroundStyle(const BackgroundStyle& backgroundStyle) +{ + result r = GetCore().SetBackgroundStyle(backgroundStyle); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_CheckButtonImpl::SetShowTitle(bool showTitle) +{ + result r = GetCore().SetShowTitle(showTitle); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_CheckButtonImpl::SetGroupStyle(const GroupStyle& groupStyle) +{ + result r = GetCore().SetGroupStyle(groupStyle); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +bool +_CheckButtonImpl::IsLayoutable(void) const +{ + return true; +} + +void +_CheckButtonImpl::OnActionPerformed(const _Control& source, int actionId) +{ + if (__pPublicActionEvent != null) + { + __pPublicActionEvent->Fire(*_PublicActionEvent::CreateActionEventArgN(actionId)); + } + + return; +} + +class _CheckButtonMaker + : public _UiBuilderControlMaker +{ +public: + _CheckButtonMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_CheckButtonMaker(){}; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _CheckButtonMaker* pCheckButtonMaker = new (std::nothrow) _CheckButtonMaker(uibuilder); + return static_cast<_UiBuilderControlMaker*>(pCheckButtonMaker); + }; +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + bool isText = false; + bool isRadioStyle = false; + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + CheckButton* pCheck = null; + BackgroundStyle backgroundStyle = BACKGROUND_STYLE_DEFAULT; + Rectangle rect; + + Tizen::Base::String elementString; + String checkText; + HorizontalAlignment horizontalAlignment; + VerticalAlignment verticalAlignment; + GroupStyle groupStyle = GROUP_STYLE_NONE; + bool showTitle = false; + Color color; + int opacity = 0; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pCheck = new (std::nothrow) CheckButton(); + rect = pControlProperty->GetRect(); + + Tizen::Base::String styleString; + styleString = pControlProperty->GetStyle(); + + //Construct + if (pControl->GetElement("text", elementString)) + { + isText = true; + checkText = elementString; + } + + if (pControl->GetElement("backgroundStyle", elementString) || pControl->GetElement("BackgroundStyle", elementString)) + { + if (elementString.Equals(L"BACKGROUND_STYLE_NONE", false)) + { + backgroundStyle = BACKGROUND_STYLE_NONE; + } + } + + if (pControl->GetElement("showtitleText", elementString) || pControl->GetElement("bShowtitleText", elementString)) + { + if (elementString.Equals(L"true", false)) + { + showTitle = true; + } + } + + if (pControl->GetElement("groupStyle", elementString) || pControl->GetElement("GroupStyle", elementString)) + { + if (elementString.Equals(L"GROUP_STYLE_NONE", false)) + { + groupStyle = GROUP_STYLE_NONE; + } + + if (elementString.Equals(L"GROUP_STYLE_SINGLE", false)) + { + groupStyle = GROUP_STYLE_SINGLE; + } + + if (elementString.Equals(L"GROUP_STYLE_TOP", false)) + { + groupStyle = GROUP_STYLE_TOP; + } + + if (elementString.Equals(L"GROUP_STYLE_MIDDLE", false)) + { + groupStyle = GROUP_STYLE_MIDDLE; + } + + if (elementString.Equals(L"GROUP_STYLE_BOTTOM", false)) + { + groupStyle = GROUP_STYLE_BOTTOM; + } + } + + if (styleString.Equals(L"CHECK_BUTTON_STYLE_ONOFF", false)) + { + r = pCheck->Construct(rect, CHECK_BUTTON_STYLE_ONOFF, backgroundStyle, showTitle, checkText, groupStyle); + } + else if (styleString.Equals(L"CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER", false)) + { + r = pCheck->Construct(rect, CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER, backgroundStyle, showTitle, checkText, groupStyle); + } + else if (styleString.Equals(L"CHECK_BUTTON_STYLE_MARK_WITH_DIVIDER", false)) + { + r = pCheck->Construct(rect, CHECK_BUTTON_STYLE_MARK_WITH_DIVIDER, backgroundStyle, showTitle, checkText, groupStyle); + } + else if (styleString.Equals(L"CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER", false)) + { + r = pCheck->Construct(rect, CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER, backgroundStyle, showTitle, checkText, groupStyle); + isRadioStyle = true; + } + else if (styleString.Equals(L"CHECK_BUTTON_STYLE_RADIO", false)) + { + r = pCheck->Construct(rect, CHECK_BUTTON_STYLE_RADIO, backgroundStyle, showTitle, checkText, groupStyle); + isRadioStyle = true; + } + else if (styleString.Equals(L"CHECK_BUTTON_STYLE_ONOFF_SLIDING", false)) + { + r = pCheck->Construct(rect, CHECK_BUTTON_STYLE_ONOFF_SLIDING, backgroundStyle, showTitle, checkText, groupStyle); + } + else if (styleString.Equals(L"CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON", false)) + { + r = pCheck->Construct(rect, CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON, backgroundStyle, showTitle, checkText, groupStyle); + } + else if (styleString.Equals(L"CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON", false)) + { + r = pCheck->Construct(rect, CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON, backgroundStyle, showTitle, checkText, groupStyle); + isRadioStyle = true; + } + else + { + r = pCheck->Construct(rect, CHECK_BUTTON_STYLE_MARK, backgroundStyle, showTitle, checkText, groupStyle); + } + + if (r != E_SUCCESS) + { + delete pCheck; + return null; + } + + if (showTitle) + { + if (pControl->GetElement("titleText", elementString)) + { + pCheck->SetTitleText(elementString); + } + + if (pControl->GetElement("colorOfTitleText", elementString)) + { + ConvertStringToColor(elementString, color); + pCheck->SetTitleTextColor(color); + } + + if (pControl->GetElement("pressedTitleTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pCheck->SetPressedTitleTextColor(color); + } + + if (pControl->GetElement("disabledTitleTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pCheck->SetDisabledTitleTextColor(color); + } + + if (pControl->GetElement("highlightedTitleTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pCheck->SetHighlightedTitleTextColor(color); + } + } + + if (isText) + { + if (pControl->GetElement("colorOfText", elementString)) + { + ConvertStringToColor(elementString, color); + pCheck->SetTextColor(color); + } + + if (pControl->GetElement("pressedTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pCheck->SetPressedTextColor(color); + } + + if (pControl->GetElement("disabledTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pCheck->SetDisabledTextColor(color); + } + + if (pControl->GetElement("highlightedTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pCheck->SetHighlightedTextColor(color); + } + } + + if (isRadioStyle && pControl->GetElement("GroupID", elementString)) + { + RadioGroup* pGroup = (RadioGroup*) ((GetContainer())->GetControl(elementString, true)); + + if (pGroup == null) + { + pGroup = new (std::nothrow) RadioGroup(); + r = pGroup->Construct(); + + if (r != E_SUCCESS) + { + // SysLogExceptionxception( "[E_SYSTEM] UiBuilder::__MakeCheck: Failed to create Group(%s)",buffer); + delete pCheck; + delete pGroup; + return null; + } + pGroup->SetName(elementString); + GetContainer()->AddControl(*pGroup); + + r = pGroup->Add(*pCheck); + } + else + { + r = pGroup->Add(*pCheck); + } + } + + if (pControl->GetElement("horizontalAlign", elementString) || pControl->GetElement("hAlign", elementString)) + { + if (ConvertHAlignToHorizontalAlignment(elementString, horizontalAlignment)) + { + pCheck->SetTextHorizontalAlignment(horizontalAlignment); + } + } + + if (pControl->GetElement("verticalAlign", elementString) || pControl->GetElement("vAlign", elementString)) + { + if (ConvertVAlignToVerticalAlignment(elementString, verticalAlignment)) + { + pCheck->SetTextVerticalAlignment(verticalAlignment); + } + } + + if (pControl->GetElement("normalColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement("normalColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pCheck->SetColor(CHECK_BUTTON_STATUS_NORMAL, color); + } + + if (pControl->GetElement("pressedColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement("pressedColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pCheck->SetColor(CHECK_BUTTON_STATUS_PRESSED, color); + } + + if (pControl->GetElement("disabledColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement("disabledColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pCheck->SetColor(CHECK_BUTTON_STATUS_DISABLED, color); + } + + if (pControl->GetElement("highlightedColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement("highlightedColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pCheck->SetColor(CHECK_BUTTON_STATUS_HIGHLIGHTED, color); + } +#if 0 + //-------safety for Minimum size------------------- + tempRect = (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->GetRect(); + if ((pStyleString != null) && + ((strcmp((const char*)pStyleString,"CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER") == 0) + || (strcmp((const char*)pStyleString,"CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER") == 0) + || (strcmp((const char*)pStyleString,"CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER") == 0))) + { + if (tempRect.w < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_DIVIDER)) + { + tempRect.w = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_DIVIDER); + } + } + else if ((pStyleString != null) && + ((strcmp((const char*)pStyleString,"CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON") == 0) + || (strcmp((const char*)pStyleString,"CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON") == 0))) + { + if (tempRect.w < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_DETAILED)) + { + tempRect.w = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_DETAILED); + } + } + else if ((pStyleString != null) && + (strcmp((const char*)pStyleString,"CHECK_BUTTON_STYLE_ONOFF_SLIDING") == 0)) + { + if (tempRect.w < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_ONOFF_SLIDING)) + { + tempRect.w = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_ONOFF_SLIDING); + } + } + else + { + if (showTitle) + { + if (tempRect.w < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_TITLE)) + { + tempRect.w = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_TITLE); + } + } + else + { + if (tempRect.w < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH)) + { + tempRect.w = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH); + } + } + } + + if (showTitle) + { + if (tempRect.h < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_HEIGHT_WITH_TITLE)) + { + tempRect.h = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_HEIGHT_WITH_TITLE); + } + } + else // no title + { + if (tempRect.h < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_HEIGHT)) + { + tempRect.h = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_HEIGHT); + } + } + + (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(tempRect.x,tempRect.y,tempRect.w,tempRect.h); + + tempRect = (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->GetRect(); + if ((pStyleString != null) && + ((strcmp((const char*)pStyleString,"CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER") == 0) + || (strcmp((const char*)pStyleString,"CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER") == 0) + || (strcmp((const char*)pStyleString,"CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER") == 0))) + { + if (tempRect.w < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_DIVIDER)) + { + tempRect.w = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_DIVIDER); + } + } + else if ((pStyleString != null) && + ((strcmp((const char*)pStyleString,"CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON") == 0) + || (strcmp((const char*)pStyleString,"CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON") == 0))) + { + if (tempRect.w < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_DETAILED)) + { + tempRect.w = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_DETAILED); + } + } + else if ((pStyleString != null) && + (strcmp((const char*)pStyleString,"CHECK_BUTTON_STYLE_ONOFF_SLIDING") == 0)) + { + if (tempRect.w < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_ONOFF_SLIDING)) + { + tempRect.w = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_ONOFF_SLIDING); + } + } + else + { + if (showTitle) + { + if (tempRect.w < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_TITLE)) + { + tempRect.w = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH_WITH_TITLE); + } + } + else + { + if (tempRect.w < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH)) + { + tempRect.w = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_WIDTH); + } + } + } + + if (showTitle) + { + if (tempRect.h < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_HEIGHT_WITH_TITLE)) + { + tempRect.h = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_HEIGHT_WITH_TITLE); + } + } + else // no title + { + if (tempRect.h < __BaseProperty(PROPERTY_CHECKBUTTON_MIN_HEIGHT)) + { + tempRect.h = __BaseProperty(PROPERTY_CHECKBUTTON_MIN_HEIGHT); + } + } + + (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(tempRect.x,tempRect.y,tempRect.w,tempRect.h); + + //--------end safety code------------------------ + +#endif + return pCheck; + } + +private: +}; // _CheckButtonMaker + +_CheckButtonRegister::_CheckButtonRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"CheckButton", _CheckButtonMaker::GetInstance); +} +_CheckButtonRegister::~_CheckButtonRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"CheckButton"); +} +static _CheckButtonRegister CheckButtonRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_CheckButtonModel.cpp b/src/ui/controls/FUiCtrl_CheckButtonModel.cpp new file mode 100644 index 0000000..bc09f05 --- /dev/null +++ b/src/ui/controls/FUiCtrl_CheckButtonModel.cpp @@ -0,0 +1,48 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_CheckButtonModel.cpp + * @brief This is the implementation file for the _CheckButtonModel class. + */ + +#include +#include +#include "FUiCtrl_CheckButtonModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + + +_CheckButtonModel::_CheckButtonModel(void) +{ + +} + +_CheckButtonModel::~_CheckButtonModel(void) +{ + +} + +result +_CheckButtonModel::Construct(void) +{ + result r = E_SUCCESS; + + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_CheckButtonPresenter.cpp b/src/ui/controls/FUiCtrl_CheckButtonPresenter.cpp new file mode 100644 index 0000000..4c81869 --- /dev/null +++ b/src/ui/controls/FUiCtrl_CheckButtonPresenter.cpp @@ -0,0 +1,1119 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_CheckButtonPresenter.cpp + * @brief This is the implementation file for the _CheckButtonPresenter class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_CheckButtonPresenter.h" +#include "FUiCtrl_CheckButtonModel.h" +#include "FUiCtrl_CheckButton.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_CheckButtonPresenter::_CheckButtonPresenter(void) + : __pCheckButton(null) + , __pCheckButtonModel(null) + , __previousEnabledState(false) + , __touchMoveHandled(false) + , __pTextFont(null) + , __pTitleTextFont(null) + , __pTextObject(null) + , __pTitleTextObject(null) + , __titleTextBounds(Rectangle()) + , __textBounds(Rectangle()) + , __defaultButtonBounds(Rectangle()) + , __onOffSlidingButtonBounds(Rectangle()) + , __detailedButtonBounds(Rectangle()) + , __fontStyle(0) + , __fontSize(0) + , __pCheckAnimationTimer(null) + , __ratio(10) +{ + +} + +_CheckButtonPresenter::~_CheckButtonPresenter(void) +{ + if (__pCheckButtonModel) + { + delete __pCheckButtonModel; + __pCheckButtonModel = null; + } + + if (__pTextObject) + { + delete __pTextObject; + __pTextObject = null; + } + + if (__pTitleTextObject) + { + delete __pTitleTextObject; + __pTitleTextObject = null; + } + + if (__pCheckAnimationTimer) + { + delete __pCheckAnimationTimer; + __pCheckAnimationTimer = null; + } +} + +result +_CheckButtonPresenter::Construct(const _CheckButton& checkButton) +{ + result r = E_SUCCESS; + + __pCheckButton = const_cast <_CheckButton*>(&checkButton); + + __fontStyle = FONT_STYLE_PLAIN; + + __pTextObject = new (std::nothrow) TextObject(); + SysTryCatch(NID_UI_CTRL, __pTextObject != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + __pTitleTextObject = new (std::nothrow) TextObject(); + SysTryCatch(NID_UI_CTRL, __pTitleTextObject != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + __pTextObject->Construct(); + __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + __pTitleTextObject->Construct(); + __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + CalculateTextBounds(); + CalculateTitleTextBounds(); + CalculateButtonBounds(); + + return E_SUCCESS; + +CATCH: + + delete __pTextObject; + __pTextObject = null; + + delete __pTitleTextObject; + __pTitleTextObject = null; + + return r; +} + +result +_CheckButtonPresenter::Install(void) +{ + result r = E_SUCCESS; + + _CheckButtonModel* pModel = new (std::nothrow) _CheckButtonModel(); + SysTryReturn(NID_UI_CTRL, pModel, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = SetModel(*pModel); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pModel->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return E_SUCCESS; + +CATCH: + delete pModel; + return r; +} + +result +_CheckButtonPresenter::SetModel(const _CheckButtonModel& checkButtonModel) +{ + __pCheckButtonModel = const_cast <_CheckButtonModel*>(&checkButtonModel); + + return E_SUCCESS; +} + +void +_CheckButtonPresenter::OnFontChanged(Font* pFont) +{ + __pTextFont = pFont; + __pTitleTextFont = pFont; + + return; +} + +void +_CheckButtonPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = __fontStyle; + size = __fontSize; + + return; +} + +void +_CheckButtonPresenter::SetFontInfo(unsigned long style, int size) +{ + __fontStyle = style; + __fontSize = size; + + return; +} + +void +_CheckButtonPresenter::Draw(void) +{ + DrawBackground(); + DrawCheckBitmap(); + DrawText(); + + return; +} + +void +_CheckButtonPresenter::DrawBackground(void) +{ + Canvas* pCanvas = __pCheckButton->GetCanvasN(); + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + + return; + } + + Bitmap* pReplacementColorBackgroundBitmap = null; + Bitmap* pBackgroundBitmap = __pCheckButton->GetBackgroundBitmap(__pCheckButton->GetGroupStyle()); + Bitmap* pBackgroundNormalEffectBitmap = __pCheckButton->GetBackgroundNormalEffectBitmap(__pCheckButton->GetGroupStyle()); + Bitmap* pBackgroundPressedEffectBitmap = __pCheckButton->GetBackgroundPressedEffectBitmap(__pCheckButton->GetGroupStyle()); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + Rectangle bounds(0, 0, __pCheckButton->GetBounds().width, __pCheckButton->GetBounds().height); + CheckButtonStatus checkStatus = __pCheckButton->GetCheckButtonStatus(); + BackgroundStyle backgroundStyle = __pCheckButton->GetBackgroundStyle(); + + if (checkStatus == CHECK_BUTTON_STATUS_NORMAL) + { + if (backgroundStyle == BACKGROUND_STYLE_NONE) + { + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + } + else + { + if (pBackgroundBitmap && pBackgroundBitmap->IsNinePatchedBitmap()) + { + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), + __pCheckButton->GetColor(CHECK_BUTTON_STATUS_NORMAL)); + if (pReplacementColorBackgroundBitmap) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pReplacementColorBackgroundBitmap); + } + if (pBackgroundNormalEffectBitmap) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundNormalEffectBitmap); + } + } + else + { + if (pBackgroundBitmap) + { + pCanvas->DrawBitmap(Rectangle(0, 0, bounds.width, bounds.height), *pBackgroundBitmap); + } + } + } + } + else if (checkStatus == CHECK_BUTTON_STATUS_DISABLED) + { + if (backgroundStyle == BACKGROUND_STYLE_NONE) + { + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + } + else + { + if (pBackgroundBitmap && pBackgroundBitmap->IsNinePatchedBitmap()) + { + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), + __pCheckButton->GetColor(CHECK_BUTTON_STATUS_DISABLED)); + if (pReplacementColorBackgroundBitmap) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pReplacementColorBackgroundBitmap); + } + if (pBackgroundNormalEffectBitmap) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundNormalEffectBitmap); + } + } + else + { + if (pBackgroundBitmap) + { + pCanvas->DrawBitmap(Rectangle(0, 0, bounds.width, bounds.height), *pBackgroundBitmap); + } + } + } + } + else if (checkStatus == CHECK_BUTTON_STATUS_PRESSED) + { + if (backgroundStyle == BACKGROUND_STYLE_NONE) + { + pCanvas->SetBackgroundColor(__pCheckButton->GetColor(CHECK_BUTTON_STATUS_PRESSED)); + pCanvas->Clear(); + } + else + { + if (pBackgroundBitmap && pBackgroundBitmap->IsNinePatchedBitmap()) + { + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), + __pCheckButton->GetColor(CHECK_BUTTON_STATUS_PRESSED)); + if (pReplacementColorBackgroundBitmap) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pReplacementColorBackgroundBitmap); + } + if (pBackgroundPressedEffectBitmap) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundPressedEffectBitmap); + } + } + else + { + if (pBackgroundBitmap) + { + pCanvas->DrawBitmap(Rectangle(0, 0, bounds.width, bounds.height), *pBackgroundBitmap); + } + } + } + } + else + { + if (backgroundStyle == BACKGROUND_STYLE_NONE) + { + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + } + else + { + if (pBackgroundBitmap && pBackgroundBitmap->IsNinePatchedBitmap()) + { + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), + __pCheckButton->GetColor(CHECK_BUTTON_STATUS_HIGHLIGHTED)); + if (pReplacementColorBackgroundBitmap) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pReplacementColorBackgroundBitmap); + } + if (pBackgroundNormalEffectBitmap) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundNormalEffectBitmap); + } + } + else + { + if (pBackgroundBitmap) + { + pCanvas->DrawBitmap(Rectangle(0, 0, bounds.width, bounds.height), *pBackgroundBitmap); + } + } + } + } + + delete pCanvas; + delete pReplacementColorBackgroundBitmap; + + return; +} + +void +_CheckButtonPresenter::DrawCheckBitmap(void) +{ + Canvas* pCanvas = __pCheckButton->GetCanvasN(); + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + + return; + } + + Color detailedNormalBackgroundColor; + Color detailedPressedBackgroundColor; + Color detailedNormalTextColor; + Color detailedPressedTextColor; + + GET_COLOR_CONFIG(CHECKBUTTON::DETAILED_ICON_BG_NORMAL, detailedNormalBackgroundColor); + GET_COLOR_CONFIG(CHECKBUTTON::DETAILED_ICON_BG_PRESSED, detailedPressedBackgroundColor); + GET_COLOR_CONFIG(CHECKBUTTON::DETAILED_ICON_TEXT_NORMAL, detailedNormalTextColor); + GET_COLOR_CONFIG(CHECKBUTTON::DETAILED_ICON_TEXT_PRESSED, detailedPressedTextColor); + + Bitmap* pReplacementColorBackgroundBitmap = null; + Bitmap* pReplacementColorTextBitmap = null; + Bitmap* pOnOffBitmap = __pCheckButton->GetOnOffBitmap(); + Bitmap* pCircleBitmap = __pCheckButton->GetCircleBitmap(); + Bitmap* pDetailedBitmap = __pCheckButton->GetDetailedBitmap(); + Bitmap* pCircleNormalEffectBitmap = __pCheckButton->GetCircleNormalEffectBitmap(); + Bitmap* pCirclePressedEffectBitmap = __pCheckButton->GetCirclePressedEffectBitmap(); + + CheckButtonStatus checkStatus = __pCheckButton->GetCheckButtonStatus(); + CheckButtonStyle checkStyle = __pCheckButton->GetCheckButtonStyle(); + + CalculateButtonBounds(); + + if (checkStyle == CHECK_BUTTON_STYLE_MARK || checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DIVIDER || checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON) + { + if (checkStatus == CHECK_BUTTON_STATUS_NORMAL || checkStatus == CHECK_BUTTON_STATUS_DISABLED) + { + Bitmap* pMarkBgNormalBitmap = __pCheckButton->GetMarkBgNormalBitmap(); + + if (pMarkBgNormalBitmap) + { + pCanvas->DrawBitmap(Point(__defaultButtonBounds.x, __defaultButtonBounds.y), *pMarkBgNormalBitmap); + } + + if (checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON) + { + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pCircleBitmap, Color::GetColor(COLOR_ID_MAGENTA), detailedNormalBackgroundColor); + pReplacementColorTextBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDetailedBitmap, Color::GetColor(COLOR_ID_MAGENTA), detailedNormalTextColor); + + if (pReplacementColorBackgroundBitmap) + { + pCanvas->DrawBitmap(Point(__detailedButtonBounds.x, __detailedButtonBounds.y), *pReplacementColorBackgroundBitmap); + } + if (pCircleNormalEffectBitmap) + { + pCanvas->DrawBitmap(Point(__detailedButtonBounds.x, __detailedButtonBounds.y), *pCircleNormalEffectBitmap); + } + if (pReplacementColorTextBitmap) + { + pCanvas->DrawBitmap(Point(__detailedButtonBounds.x, __detailedButtonBounds.y), *pReplacementColorTextBitmap); + } + } + } + else if (checkStatus == CHECK_BUTTON_STATUS_PRESSED) + { + Bitmap* pMarkBgPressedBitmap = __pCheckButton->GetMarkBgPressedBitmap(); + + if (pMarkBgPressedBitmap) + { + pCanvas->DrawBitmap(Point(__defaultButtonBounds.x, __defaultButtonBounds.y), *pMarkBgPressedBitmap); + } + + if (checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON) + { + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pCircleBitmap, Color::GetColor(COLOR_ID_MAGENTA), detailedPressedBackgroundColor); + pReplacementColorTextBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDetailedBitmap, Color::GetColor(COLOR_ID_MAGENTA), detailedPressedTextColor); + + if (pReplacementColorBackgroundBitmap) + { + pCanvas->DrawBitmap(Point(__detailedButtonBounds.x, __detailedButtonBounds.y), *pReplacementColorBackgroundBitmap); + } + if (pCirclePressedEffectBitmap) + { + pCanvas->DrawBitmap(Point(__detailedButtonBounds.x, __detailedButtonBounds.y), *pCirclePressedEffectBitmap); + } + if (pReplacementColorTextBitmap) + { + pCanvas->DrawBitmap(Point(__detailedButtonBounds.x, __detailedButtonBounds.y), *pReplacementColorTextBitmap); + } + } + } + + DrawMarkAnimation(); + } + else if (checkStyle == CHECK_BUTTON_STYLE_RADIO || checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER || checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON) + { + if (checkStatus == CHECK_BUTTON_STATUS_NORMAL || checkStatus == CHECK_BUTTON_STATUS_DISABLED) + { + if (checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON) + { + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pCircleBitmap, Color::GetColor(COLOR_ID_MAGENTA), detailedNormalBackgroundColor); + pReplacementColorTextBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDetailedBitmap, Color::GetColor(COLOR_ID_MAGENTA), detailedNormalTextColor); + + if (pReplacementColorBackgroundBitmap) + { + pCanvas->DrawBitmap(Point(__detailedButtonBounds.x, __detailedButtonBounds.y), *pReplacementColorBackgroundBitmap); + } + if (pCircleNormalEffectBitmap) + { + pCanvas->DrawBitmap(Point(__detailedButtonBounds.x, __detailedButtonBounds.y), *pCircleNormalEffectBitmap); + } + if (pReplacementColorTextBitmap) + { + pCanvas->DrawBitmap(Point(__detailedButtonBounds.x, __detailedButtonBounds.y), *pReplacementColorTextBitmap); + } + } + } + else if (checkStatus == CHECK_BUTTON_STATUS_PRESSED) + { + if (checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON) + { + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pCircleBitmap, Color::GetColor(COLOR_ID_MAGENTA), detailedPressedBackgroundColor); + pReplacementColorTextBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDetailedBitmap, Color::GetColor(COLOR_ID_MAGENTA), detailedPressedTextColor); + + if (pReplacementColorBackgroundBitmap) + { + pCanvas->DrawBitmap(Point(__detailedButtonBounds.x, __detailedButtonBounds.y), *pReplacementColorBackgroundBitmap); + } + if (pCirclePressedEffectBitmap) + { + pCanvas->DrawBitmap(Point(__detailedButtonBounds.x, __detailedButtonBounds.y), *pCirclePressedEffectBitmap); + } + if (pReplacementColorTextBitmap) + { + pCanvas->DrawBitmap(Point(__detailedButtonBounds.x, __detailedButtonBounds.y), *pReplacementColorTextBitmap); + } + } + } + + DrawMarkAnimation(); + } + else if (checkStyle == CHECK_BUTTON_STYLE_ONOFF || checkStyle == CHECK_BUTTON_STYLE_ONOFF_WITH_DIVIDER) + { + if (checkStatus == CHECK_BUTTON_STATUS_NORMAL || checkStatus == CHECK_BUTTON_STATUS_DISABLED) + { + Bitmap* pOnOffBgNormalBitmap = __pCheckButton->GetOnOffBgNormalBitmap(); + + if (pOnOffBgNormalBitmap) + { + pCanvas->DrawBitmap(Point(__defaultButtonBounds.x, __defaultButtonBounds.y), *pOnOffBgNormalBitmap); + } + } + else if (checkStatus == CHECK_BUTTON_STATUS_PRESSED) + { + Bitmap* pOnOffBgPressedBitmap = __pCheckButton->GetOnOffBgPressedBitmap(); + + if (pOnOffBgPressedBitmap) + { + pCanvas->DrawBitmap(Point(__defaultButtonBounds.x, __defaultButtonBounds.y), *pOnOffBgPressedBitmap); + } + } + + if (__pCheckButton->IsSelected() && pOnOffBitmap) + { + pCanvas->DrawBitmap(Point(__defaultButtonBounds.x, __defaultButtonBounds.y), *pOnOffBitmap); + } + } + else if (checkStyle == CHECK_BUTTON_STYLE_ONOFF_SLIDING) + { + if (__pCheckButton->IsSelected()) + { + Bitmap* pOnOffSlidingOnBitmap = __pCheckButton->GetOnOffSlidingOnBitmap(); + + if (pOnOffSlidingOnBitmap) + { + pCanvas->DrawBitmap(Point(__onOffSlidingButtonBounds.x, __onOffSlidingButtonBounds.y), *pOnOffSlidingOnBitmap); + } + } + else + { + Bitmap* pOnOffSlidingOffBitmap = __pCheckButton->GetOnOffSlidingOffBitmap(); + + if (pOnOffSlidingOffBitmap) + { + pCanvas->DrawBitmap(Point(__onOffSlidingButtonBounds.x, __onOffSlidingButtonBounds.y), *pOnOffSlidingOffBitmap); + } + } + } + + delete pCanvas; + delete pReplacementColorBackgroundBitmap; + delete pReplacementColorTextBitmap; + + return; +} + +void +_CheckButtonPresenter::DrawText(void) +{ + result r = E_SUCCESS; + + TextSimple* pSimpleText = null; + TextSimple* pSimpleTitleText = null; + TextObjectAlignment horizontalAlign = TEXT_OBJECT_ALIGNMENT_CENTER; + TextObjectAlignment verticalAlign = TEXT_OBJECT_ALIGNMENT_MIDDLE; + + CheckButtonStatus checkStatus = __pCheckButton->GetCheckButtonStatus(); + bool showTitle = __pCheckButton->GetShowTitle(); + + Canvas* pCanvas = __pCheckButton->GetCanvasN(); + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + + return; + } + + __pTextObject->RemoveAll(); + pSimpleText = new (std::nothrow) TextSimple(const_cast(__pCheckButton->GetText().GetPointer()), __pCheckButton->GetText().GetLength()); + __pTextObject->AppendElement(*pSimpleText); + + __pTitleTextObject->RemoveAll(); + pSimpleTitleText = new (std::nothrow) TextSimple(const_cast(__pCheckButton->GetTitleText().GetPointer()), __pCheckButton->GetTitleText().GetLength()); + __pTitleTextObject->AppendElement(*pSimpleTitleText); + + if (checkStatus == CHECK_BUTTON_STATUS_NORMAL) + { + __pTextObject->SetForegroundColor(__pCheckButton->GetTextColor(), 0, __pTextObject->GetTextLength()); + __pTitleTextObject->SetForegroundColor(__pCheckButton->GetTitleTextColor(), 0, __pTitleTextObject->GetTextLength()); + } + else if (checkStatus == CHECK_BUTTON_STATUS_DISABLED) + { + __pTextObject->SetForegroundColor(__pCheckButton->GetDisabledTextColor(), 0, __pTextObject->GetTextLength()); + __pTitleTextObject->SetForegroundColor(__pCheckButton->GetDisabledTitleTextColor(), 0, __pTitleTextObject->GetTextLength()); + } + else if (checkStatus == CHECK_BUTTON_STATUS_HIGHLIGHTED) + { + __pTextObject->SetForegroundColor(__pCheckButton->GetHighlightedTextColor(), 0, __pTextObject->GetTextLength()); + __pTitleTextObject->SetForegroundColor(__pCheckButton->GetHighlightedTitleTextColor(), 0, __pTitleTextObject->GetTextLength()); + } + else + { + __pTextObject->SetForegroundColor(__pCheckButton->GetPressedTextColor(), 0, __pTextObject->GetTextLength()); + __pTitleTextObject->SetForegroundColor(__pCheckButton->GetPressedTitleTextColor(), 0, __pTitleTextObject->GetTextLength()); + } + + CalculateTextBounds(); + CalculateTitleTextBounds(); + + __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pTextObject->SetBounds(GetTextBounds()); + __pTextObject->Compose(); + + __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pTitleTextObject->SetBounds(GetTitleTextBounds()); + __pTitleTextObject->Compose(); + + switch (__pCheckButton->GetTextHorizontalAlignment()) + { + case ALIGNMENT_LEFT: + horizontalAlign = TEXT_OBJECT_ALIGNMENT_LEFT; + break; + case ALIGNMENT_CENTER: + horizontalAlign = TEXT_OBJECT_ALIGNMENT_CENTER; + break; + default: + horizontalAlign = TEXT_OBJECT_ALIGNMENT_RIGHT; + } + + switch (__pCheckButton->GetTextVerticalAlignment()) + { + case ALIGNMENT_TOP: + verticalAlign = TEXT_OBJECT_ALIGNMENT_TOP; + break; + case ALIGNMENT_MIDDLE: + verticalAlign = TEXT_OBJECT_ALIGNMENT_MIDDLE; + break; + default: + verticalAlign = TEXT_OBJECT_ALIGNMENT_BOTTOM; + } + + __fontSize = __pCheckButton->GetTextSize(); + __pTextFont = __pCheckButton->GetFallbackFont(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, __pTextFont, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTextObject->SetAlignment(horizontalAlign | verticalAlign); + __pTextObject->SetFont(__pTextFont, 0, __pTextObject->GetTextLength()); + __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + + __fontSize = __pCheckButton->GetTitleTextSize(); + __pTitleTextFont = __pCheckButton->GetFallbackFont(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, __pTitleTextFont, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength()); + + if (showTitle) + { + __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + } + + delete pCanvas; + + return; +} + +bool +_CheckButtonPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pCheckButton) + { + return false; + } + + if (!__pCheckButton->IsEnabled()) + { + return true; + } + + __touchMoveHandled = false; + + __pCheckButton->SetCheckButtonStatus(CHECK_BUTTON_STATUS_PRESSED); + + __pCheckButton->Invalidate(); + + return true; +} + +bool +_CheckButtonPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + int checkButtonLeftMargin = 0; + int checkButtonDetailedBitmapWidth = 0; + + GET_SHAPE_CONFIG(CHECKBUTTON::LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, checkButtonLeftMargin); + GET_SHAPE_CONFIG(CHECKBUTTON::DETAILED_BITMAP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, checkButtonDetailedBitmapWidth); + + if (&source != __pCheckButton) + { + return false; + } + + if (!__pCheckButton->IsEnabled()) + { + return true; + } + + CheckButtonStatus status = __pCheckButton->GetCheckButtonStatus(); + CheckButtonStyle checkStyle = __pCheckButton->GetCheckButtonStyle(); + + if (status == CHECK_BUTTON_STATUS_NORMAL) + { + return true; + } + + if (checkStyle == CHECK_BUTTON_STYLE_MARK || checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DIVIDER || checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON + || checkStyle == CHECK_BUTTON_STYLE_RADIO || checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER || checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON) + { + StartCheckAnimationTimer(); + __ratio = 0; + } + + Point touchPoint = touchinfo.GetCurrentPosition(); + + touchPoint.x += source.GetClientBounds().x; + touchPoint.y += source.GetClientBounds().y; + + Rectangle bounds = __pCheckButton->GetClientBounds(); + Rectangle detailedBounds = __pCheckButton->GetClientBounds(); + detailedBounds.width = detailedBounds.width - checkButtonLeftMargin - checkButtonDetailedBitmapWidth; + + __pCheckButton->SetCheckButtonStatus(CHECK_BUTTON_STATUS_NORMAL); + __pCheckButton->Invalidate(); + + if (checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON || checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON) + { + if (detailedBounds.Contains(touchPoint)) + { + __pCheckButton->FireActionEvent(); + + if (__pCheckButton->GetRadioGroup() != null) + { + __pCheckButton->SendTouchReleasedEvent(*__pCheckButton); + } + } + } + else + { + if (bounds.Contains(touchPoint)) + { + __pCheckButton->FireActionEvent(); + + if (__pCheckButton->GetRadioGroup() != null) + { + __pCheckButton->SendTouchReleasedEvent(*__pCheckButton); + } + } + } + + return true; +} + +bool +_CheckButtonPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pCheckButton) + { + return false; + } + + if (!__pCheckButton->IsEnabled()) + { + return true; + } + + Point touchPoint = touchinfo.GetCurrentPosition(); + + touchPoint.x += source.GetClientBounds().x; + touchPoint.y += source.GetClientBounds().y; + + Rectangle bounds = __pCheckButton->GetClientBounds(); + bool isInCheckButtonArea = bounds.Contains(touchPoint); + + if (isInCheckButtonArea && (__touchMoveHandled != true)) + { + __pCheckButton->SetCheckButtonStatus(CHECK_BUTTON_STATUS_PRESSED); + } + else + { + __pCheckButton->SetCheckButtonStatus(CHECK_BUTTON_STATUS_NORMAL); + } + + __pCheckButton->Invalidate(); + + return false; +} + +bool +_CheckButtonPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pCheckButton) + { + return false; + } + + if (!__pCheckButton->IsEnabled()) + { + return true; + } + + __pCheckButton->SetCheckButtonStatus(CHECK_BUTTON_STATUS_NORMAL); + __pCheckButton->Invalidate(); + + return true; +} + +void +_CheckButtonPresenter::OnTouchMoveHandled(const _Control& control) +{ + __touchMoveHandled = true; + __pCheckButton->SetCheckButtonStatus(CHECK_BUTTON_STATUS_NORMAL); + __pCheckButton->Invalidate(); + + return; +} + +bool +_CheckButtonPresenter::IsEnabledStateChanged(void) +{ + bool __currentEnabledState = __pCheckButton->GetEnableState(); + + if (__currentEnabledState != __previousEnabledState) + { + __previousEnabledState = __currentEnabledState; + return true; + } + else + { + return false; + } +} + +result +_CheckButtonPresenter::CalculateTitleTextBounds(void) +{ + int checkButtonLeftMargin = 0; + int checkButtonTopMargin = 0; + int checkButtonBitmapWidth = 0; + int checkButtonOnOffSlidingBitmappWidth = 0; + int checkButtonDetailedBitmapWidth = 0; + int checkButtonTitleTextHeight = 0; + int checkButtonTextHeight = 0; + + GET_SHAPE_CONFIG(CHECKBUTTON::LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, checkButtonLeftMargin); + GET_SHAPE_CONFIG(CHECKBUTTON::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, checkButtonTopMargin); + GET_SHAPE_CONFIG(CHECKBUTTON::MARK_BITMAP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, checkButtonBitmapWidth); + GET_SHAPE_CONFIG(CHECKBUTTON::ONOFF_SLIDING_BITMAP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, checkButtonOnOffSlidingBitmappWidth); + GET_SHAPE_CONFIG(CHECKBUTTON::DETAILED_BITMAP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, checkButtonDetailedBitmapWidth); + GET_SHAPE_CONFIG(CHECKBUTTON::TITLE_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, checkButtonTitleTextHeight); + GET_SHAPE_CONFIG(CHECKBUTTON::TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, checkButtonTextHeight); + + CheckButtonStyle checkStyle = __pCheckButton->GetCheckButtonStyle(); + + if (checkStyle == CHECK_BUTTON_STYLE_ONOFF_SLIDING) + { + __titleTextBounds.x = checkButtonLeftMargin; + __titleTextBounds.y = checkButtonTopMargin; + __titleTextBounds.width = __pCheckButton->GetBounds().width - checkButtonLeftMargin * 3 - checkButtonOnOffSlidingBitmappWidth; + __titleTextBounds.height = __pCheckButton->GetBounds().height - checkButtonTopMargin * 2 - __textBounds.height; + } + else + { + if (checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON || checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON) + { + __titleTextBounds.x = checkButtonLeftMargin * 2 + checkButtonBitmapWidth; + __titleTextBounds.y = checkButtonTopMargin; + __titleTextBounds.width = __pCheckButton->GetBounds().width - checkButtonLeftMargin * 4 - checkButtonBitmapWidth - checkButtonDetailedBitmapWidth; + __titleTextBounds.height = __pCheckButton->GetBounds().height - checkButtonTopMargin * 2 - __textBounds.height; + } + else + { + __titleTextBounds.x = checkButtonLeftMargin * 2 + checkButtonBitmapWidth; + __titleTextBounds.y = checkButtonTopMargin; + __titleTextBounds.width = __pCheckButton->GetBounds().width - checkButtonLeftMargin * 3 - checkButtonBitmapWidth; + __titleTextBounds.height = __pCheckButton->GetBounds().height - checkButtonTopMargin * 2 - __textBounds.height; + } + } + + return E_SUCCESS; +} + +result +_CheckButtonPresenter::CalculateTextBounds(void) +{ + int checkButtonLeftMargin = 0; + int checkButtonTopMargin = 0; + int checkButtonBitmapWidth = 0; + int checkButtonOnOffSlidingBitmapWidth = 0; + int checkButtonDetailedBitmapWidth = 0; + int checkButtonTitleTextHeight = 0; + int checkButtonTextHeight = 0; + + GET_SHAPE_CONFIG(CHECKBUTTON::LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, checkButtonLeftMargin); + GET_SHAPE_CONFIG(CHECKBUTTON::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, checkButtonTopMargin); + GET_SHAPE_CONFIG(CHECKBUTTON::MARK_BITMAP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, checkButtonBitmapWidth); + GET_SHAPE_CONFIG(CHECKBUTTON::ONOFF_SLIDING_BITMAP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, checkButtonOnOffSlidingBitmapWidth); + GET_SHAPE_CONFIG(CHECKBUTTON::DETAILED_BITMAP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, checkButtonDetailedBitmapWidth); + GET_SHAPE_CONFIG(CHECKBUTTON::TITLE_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, checkButtonTitleTextHeight); + GET_SHAPE_CONFIG(CHECKBUTTON::TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, checkButtonTextHeight); + + CheckButtonStyle checkStyle = __pCheckButton->GetCheckButtonStyle(); + bool showTitle = __pCheckButton->GetShowTitle(); + + if (checkStyle == CHECK_BUTTON_STYLE_ONOFF_SLIDING) + { + if (showTitle) + { + __textBounds.x = checkButtonLeftMargin; + __textBounds.y = checkButtonTopMargin + checkButtonTitleTextHeight; + __textBounds.width = __pCheckButton->GetBounds().width - checkButtonLeftMargin * 3 - checkButtonOnOffSlidingBitmapWidth; + __textBounds.height = __pCheckButton->GetBounds().height - checkButtonTopMargin * 2 - checkButtonTitleTextHeight; + } + else + { + __textBounds.x = checkButtonLeftMargin; + __textBounds.y = checkButtonTopMargin; + __textBounds.width = __pCheckButton->GetBounds().width - checkButtonLeftMargin * 3 - checkButtonOnOffSlidingBitmapWidth; + __textBounds.height = __pCheckButton->GetBounds().height - checkButtonTopMargin * 2; + } + } + else + { + if (checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON || checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON) + { + if (showTitle) + { + __textBounds.x = checkButtonLeftMargin * 2 + checkButtonBitmapWidth; + __textBounds.y = checkButtonTopMargin + checkButtonTitleTextHeight; + __textBounds.width = __pCheckButton->GetBounds().width - checkButtonLeftMargin * 4 - checkButtonBitmapWidth - checkButtonDetailedBitmapWidth; + __textBounds.height = __pCheckButton->GetBounds().height - checkButtonTopMargin * 2 - checkButtonTitleTextHeight; + } + else + { + __textBounds.x = checkButtonLeftMargin * 2 + checkButtonBitmapWidth; + __textBounds.y = checkButtonTopMargin; + __textBounds.width = __pCheckButton->GetBounds().width - checkButtonLeftMargin * 4 - checkButtonBitmapWidth - checkButtonDetailedBitmapWidth; + __textBounds.height = __pCheckButton->GetBounds().height - checkButtonTopMargin * 2; + } + } + else + { + if (showTitle) + { + __textBounds.x = checkButtonLeftMargin * 2 + checkButtonBitmapWidth; + __textBounds.y = checkButtonTopMargin + checkButtonTitleTextHeight; + __textBounds.width = __pCheckButton->GetBounds().width - checkButtonLeftMargin * 3 - checkButtonBitmapWidth; + __textBounds.height = __pCheckButton->GetBounds().height - checkButtonTopMargin * 2 - checkButtonTitleTextHeight; + } + else + { + __textBounds.x = checkButtonLeftMargin * 2 + checkButtonBitmapWidth; + __textBounds.y = checkButtonTopMargin; + __textBounds.width = __pCheckButton->GetBounds().width - checkButtonLeftMargin * 3 - checkButtonBitmapWidth; + __textBounds.height = __pCheckButton->GetBounds().height - checkButtonTopMargin * 2; + } + } + } + + return E_SUCCESS; +} + +result +_CheckButtonPresenter::CalculateButtonBounds(void) +{ + int checkButtonLeftMargin = 0; + int checkButtonBitmapWidth = 0; + int checkButtonBitmapHeight = 0; + int checkButtonOnOffSlidingBitmapWidth = 0; + int checkButtonOnOffSlidingBitmapHeight = 0; + int checkButtonDetaieldBitmapWidth = 0; + int checkButtonDetaieldBitmapHeight = 0; + + GET_SHAPE_CONFIG(CHECKBUTTON::LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, checkButtonLeftMargin); + GET_SHAPE_CONFIG(CHECKBUTTON::MARK_BITMAP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, checkButtonBitmapWidth); + GET_SHAPE_CONFIG(CHECKBUTTON::MARK_BITMAP_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, checkButtonBitmapHeight); + GET_SHAPE_CONFIG(CHECKBUTTON::ONOFF_SLIDING_BITMAP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, checkButtonOnOffSlidingBitmapWidth); + GET_SHAPE_CONFIG(CHECKBUTTON::ONOFF_SLIDING_BITMAP_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, checkButtonOnOffSlidingBitmapHeight); + GET_SHAPE_CONFIG(CHECKBUTTON::DETAILED_BITMAP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, checkButtonDetaieldBitmapWidth); + GET_SHAPE_CONFIG(CHECKBUTTON::DETAILED_BITMAP_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, checkButtonDetaieldBitmapHeight); + + __defaultButtonBounds.x = checkButtonLeftMargin; + __defaultButtonBounds.y = (__pCheckButton->GetBounds().height - checkButtonBitmapHeight) / 2; + __defaultButtonBounds.width = checkButtonBitmapWidth; + __defaultButtonBounds.height = checkButtonBitmapHeight; + + __onOffSlidingButtonBounds.x = __pCheckButton->GetBounds().width - checkButtonLeftMargin - checkButtonOnOffSlidingBitmapWidth; + __onOffSlidingButtonBounds.y = (__pCheckButton->GetBounds().height - checkButtonOnOffSlidingBitmapHeight) / 2; + __onOffSlidingButtonBounds.width = checkButtonOnOffSlidingBitmapWidth; + __onOffSlidingButtonBounds.height = checkButtonOnOffSlidingBitmapHeight; + + __detailedButtonBounds.x = __pCheckButton->GetBounds().width - checkButtonLeftMargin - checkButtonDetaieldBitmapWidth; + __detailedButtonBounds.y = (__pCheckButton->GetBounds().height - checkButtonDetaieldBitmapHeight) / 2; + __detailedButtonBounds.width = checkButtonDetaieldBitmapWidth; + __detailedButtonBounds.height = checkButtonDetaieldBitmapHeight; + + return E_SUCCESS; +} + +Rectangle +_CheckButtonPresenter::GetTitleTextBounds(void) const +{ + return __titleTextBounds; +} + +Rectangle +_CheckButtonPresenter::GetTextBounds(void) const +{ + return __textBounds; +} + +Rectangle +_CheckButtonPresenter::GetDefaultButtonBounds(void) const +{ + return __defaultButtonBounds; +} +Rectangle +_CheckButtonPresenter::GetOnOffSlidingButtonBounds(void) const +{ + return __onOffSlidingButtonBounds; +} +Rectangle +_CheckButtonPresenter::GetDetailedButtonBounds(void) const +{ + return __detailedButtonBounds; +} + +result +_CheckButtonPresenter::StartCheckAnimationTimer(void) +{ + result r = E_SUCCESS; + if (__pCheckAnimationTimer == null) + { + __pCheckAnimationTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI_CTRL, (__pCheckAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memroy allocation failed."); + + r = __pCheckAnimationTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pCheckAnimationTimer->Cancel(); + } + + __pCheckAnimationTimer->Start(CHECK_ACTION_TIMER_PERIOD); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +CATCH: + ResetCheckAnimationTimer(); + return r; +} + +result +_CheckButtonPresenter::ResetCheckAnimationTimer(void) +{ + delete __pCheckAnimationTimer; + __pCheckAnimationTimer = null; + + return E_SUCCESS; +} + +void +_CheckButtonPresenter::OnTimerExpired(Timer& timer) +{ + __ratio++; + + if (__ratio <= RATIO_MAX) + { + StartCheckAnimationTimer(); + DrawMarkAnimation(); + } + else + { + ResetCheckAnimationTimer(); + __ratio = 10; + } + + return; +} + +void +_CheckButtonPresenter::DrawMarkAnimation(void) +{ + Canvas* pCanvas = __pCheckButton->GetCanvasN(); + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + + return; + } + + Bitmap* pMarkBitmap = __pCheckButton->GetMarkBitmap(); + //CheckButtonStyle checkStyle = __pCheckButton->GetCheckButtonStyle(); + + //if (checkStyle == CHECK_BUTTON_STYLE_MARK || checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DIVIDER || checkStyle == CHECK_BUTTON_STYLE_MARK_WITH_DETAILED_BUTTON + // || checkStyle == CHECK_BUTTON_STYLE_RADIO || checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER || checkStyle == CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON) + { + if (__pCheckButton->IsSelected() && pMarkBitmap) + { + Rectangle sourceRect(0, 0, pMarkBitmap->GetWidth() * __ratio * 0.1, pMarkBitmap->GetHeight()); + Rectangle destRect(__defaultButtonBounds.x, __defaultButtonBounds.y, pMarkBitmap->GetWidth() * __ratio * 0.1, pMarkBitmap->GetHeight()); + + pCanvas->DrawBitmap(destRect, *pMarkBitmap, sourceRect); + } + } + + delete pCanvas; + + return; + } + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ColorChangeEvent.cpp b/src/ui/controls/FUiCtrl_ColorChangeEvent.cpp new file mode 100644 index 0000000..bf1f083 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ColorChangeEvent.cpp @@ -0,0 +1,130 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_ColorChangeEvent.cpp +* @brief This is the implementation for the _ColorChangeEvent class. +*/ + +#include +#include +#include +#include +#include "FUiCtrl_ColorChangeEvent.h" +#include "FUiCtrl_IColorChangeEventListener.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _OSP_EXPORT_ _ColorChangeEventArg + : public IEventArg + , public Object +{ +public: + _ColorChangeEventArg(const Color& color) + : __color(color) + { + } + + virtual ~_ColorChangeEventArg(void) + { + } + + const Color + GetColor(void) const + { + return __color; + } + +private: + _ColorChangeEventArg(const _ColorChangeEventArg&); + + _ColorChangeEventArg& operator=(const _ColorChangeEventArg&); + +private: + Color __color; +}; // _ColorChangeEventArg + +_ColorChangeEvent::_ColorChangeEvent(const _Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_ColorChangeEvent::~_ColorChangeEvent(void) +{ +} + +const _Control* +_ColorChangeEvent::GetSource(void) const +{ + return (__pSource); +} + +void +_ColorChangeEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _IColorChangeEventListener* pColorChangeListener = dynamic_cast <_IColorChangeEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, (pColorChangeListener != null), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The _IColorChangeEventListener instance is null."); + + const _ColorChangeEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, (pArg != null), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The _ColorChangeEventArg instance is null."); + + pColorChangeListener->OnColorChanged(*__pSource, Color(pArg->GetColor())); + + return; +} + +_ColorChangeEvent* +_ColorChangeEvent::CreateInstanceN(const _Control& source) +{ + _ColorChangeEvent* pColorChangeEvent = new (std::nothrow) _ColorChangeEvent(source); + SysTryReturn(NID_UI_CTRL, (pColorChangeEvent != null), null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (IsFailed(GetLastResult()) == true) + { + delete pColorChangeEvent; + return null; + } + + return pColorChangeEvent; +} + +IEventArg* +_ColorChangeEvent::CreateColorChangeEventArgN(const Color& color) +{ + _ColorChangeEventArg* pEventArg = new (std::nothrow) _ColorChangeEventArg(color); + SysTryReturn(NID_UI_CTRL, (pEventArg != null), null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ColorPicker.cpp b/src/ui/controls/FUiCtrl_ColorPicker.cpp new file mode 100644 index 0000000..096612c --- /dev/null +++ b/src/ui/controls/FUiCtrl_ColorPicker.cpp @@ -0,0 +1,671 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_ColorPicker.cpp +* @brief This file contains implementation of _ColorPicker class +* +* This file contains implementation of _ColorPicker class. +*/ + +#include +#include +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_ColorPicker.h" +#include "FUiCtrl_ColorPickerPresenter.h" +#include "FUiCtrl_IColorChangeEventListener.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_ResourceManager.h" +#include "FUi_ResourceSizeInfo.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_ColorPicker); + +_ColorPicker::_ColorPicker(void) + : __pColorPickerPresenter(null) + , __pColorChangeEvent(null) + , __pHueHandler(null) + , __pSaturationHandler(null) + , __pLuminanceHandler(null) + , __pDecreaseHueButtonElement(null) + , __pIncreaseHueButtonElement(null) + , __pDecreaseSaturationButtonElement(null) + , __pIncreaseSaturationButtonElement(null) + , __pDecreaseLuminanceButtonElement(null) + , __pIncreaseLuminanceButtonElement(null) + , __pHueBarElement(null) + , __pSaturationBarElement(null) + , __pLuminanceBarElement(null) +{ +} + +_ColorPicker::~_ColorPicker(void) +{ + delete __pColorPickerPresenter; + __pColorPickerPresenter = null; + + delete __pColorChangeEvent; + __pColorChangeEvent = null; + + if (__pHueHandler != null) + { + __pHueHandler->Destroy(); + __pHueHandler = null; + } + + if (__pSaturationHandler != null) + { + __pSaturationHandler->Destroy(); + __pSaturationHandler = null; + } + + if (__pLuminanceHandler != null) + { + __pLuminanceHandler->Destroy(); + __pLuminanceHandler = null; + } + + if (__pDecreaseHueButtonElement) + { + __pDecreaseHueButtonElement->Activate(false); + __pDecreaseHueButtonElement = null; + } + if (__pIncreaseHueButtonElement) + { + __pIncreaseHueButtonElement->Activate(false); + __pIncreaseHueButtonElement = null; + } + if (__pDecreaseSaturationButtonElement) + { + __pDecreaseSaturationButtonElement->Activate(false); + __pDecreaseSaturationButtonElement = null; + } + if (__pIncreaseSaturationButtonElement) + { + __pIncreaseSaturationButtonElement->Activate(false); + __pIncreaseSaturationButtonElement = null; + } + if (__pDecreaseLuminanceButtonElement) + { + __pDecreaseLuminanceButtonElement->Activate(false); + __pDecreaseLuminanceButtonElement = null; + } + if (__pIncreaseLuminanceButtonElement) + { + __pIncreaseLuminanceButtonElement->Activate(false); + __pIncreaseLuminanceButtonElement = null; + } + if (__pHueBarElement) + { + __pHueBarElement->Activate(false); + __pHueBarElement = null; + } + if (__pSaturationBarElement) + { + __pSaturationBarElement->Activate(false); + __pSaturationBarElement = null; + } + if (__pLuminanceBarElement) + { + __pLuminanceBarElement->Activate(false); + __pLuminanceBarElement = null; + } +} + +_ColorPicker* +_ColorPicker::CreateColorPickerN(void) +{ + result r = E_SUCCESS; + Dimension colorPickerSize; + _VisualElement* pBase = null; + + r = GET_DIMENSION_CONFIG(COLORPICKER::DEFAULT_SIZE, _ControlManager::GetInstance()->GetOrientation(), colorPickerSize); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the default ColorPicker size from config file."); + + _ColorPicker* pColorPicker = new (std::nothrow) _ColorPicker; + SysTryReturn(NID_UI_CTRL, (pColorPicker != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pColorPicker->AcquireHandle(); + + pColorPicker->__pColorPickerPresenter = _ColorPickerPresenter::CreateInstanceN(*pColorPicker); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pColorPicker->__pColorPickerPresenter != null), , r, + "[%s] Propagating.", GetErrorMessage(r)); + + pColorPicker->__pColorChangeEvent = _ColorChangeEvent::CreateInstanceN(*pColorPicker); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pColorPicker->__pColorChangeEvent != null), , r, + "[%s] Propagating.", GetErrorMessage(r)); + + pBase = pColorPicker->GetVisualElement(); + SysTryCatch(NID_UI_CTRL, (pBase != null), r = E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the ColorPicker visual element."); + + // Set alpha merge to VisualElement + pBase->SetSurfaceOpaque(false); + pColorPicker->SetBackgroundColor(Color()); + + r = pColorPicker->SetSize(colorPickerSize); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pColorPicker->SetResizable(false); + + if (pColorPicker->GetAccessibilityContainer() != null) + { + pColorPicker->GetAccessibilityContainer()->Activate(true); + } + + return pColorPicker; + +CATCH: + delete pColorPicker; + return null; +} + +Color +_ColorPicker::GetColor(void) const +{ + Variant color = GetProperty("color"); + + return color.ToColor(); +} + +Variant +_ColorPicker::GetPropertyColor(void) const +{ + return Variant(__pColorPickerPresenter->GetColor()); +} + +int +_ColorPicker::GetHue(void) const +{ + Variant varHue = GetProperty("hue"); + + return varHue.ToInt(); +} + +Variant +_ColorPicker::GetPropertyHue(void) const +{ + return Variant(__pColorPickerPresenter->GetHue()); +} + +int +_ColorPicker::GetSaturation(void) const +{ + Variant varSaturation = GetProperty("saturation"); + + return varSaturation.ToInt(); +} + +Variant +_ColorPicker::GetPropertySaturation(void) const +{ + return Variant(__pColorPickerPresenter->GetSaturation()); +} + +int +_ColorPicker::GetLuminance(void) const +{ + Variant varLuminance = GetProperty("luminance"); + + return varLuminance.ToInt(); +} + +Variant +_ColorPicker::GetPropertyLuminance(void) const +{ + return Variant(__pColorPickerPresenter->GetLuminance()); +} + +result +_ColorPicker::SetColor(const Color& color) +{ + return SetProperty("color", Variant(color)); +} + +result +_ColorPicker::SetPropertyColor(const Variant& color) +{ + __pColorPickerPresenter->SetColor(color.ToColor()); + + return GetLastResult(); +} + +result +_ColorPicker::SetHue(int hue) +{ + return SetProperty("hue", Variant(hue)); +} + +result +_ColorPicker::SetPropertyHue(const Variant& hue) +{ + __pColorPickerPresenter->SetHue(hue.ToInt()); + + if (__pHueBarElement) + { + String hueValue; + hueValue.Append(__pColorPickerPresenter->GetHue()); + __pHueBarElement->SetValue(hueValue); + } + + return GetLastResult(); +} + +result +_ColorPicker::SetSaturation(int saturation) +{ + return SetProperty("saturation", Variant(saturation)); +} + +result +_ColorPicker::SetPropertySaturation(const Variant& saturation) +{ + __pColorPickerPresenter->SetSaturation(saturation.ToInt()); + + if (__pSaturationBarElement) + { + String saturationValue; + saturationValue.Append(__pColorPickerPresenter->GetSaturation()); + __pSaturationBarElement->SetValue(saturationValue); + } + + return GetLastResult(); +} + +result +_ColorPicker::SetLuminance(int luminance) +{ + return SetProperty("luminance", Variant(luminance)); +} + +result +_ColorPicker::SetPropertyLuminance(const Variant& luminance) +{ + __pColorPickerPresenter->SetLuminance(luminance.ToInt()); + + if (__pLuminanceBarElement) + { + String luminanceValue; + luminanceValue.Append(__pColorPickerPresenter->GetLuminance()); + __pLuminanceBarElement->SetValue(luminanceValue); + } + + return GetLastResult(); +} + +bool +_ColorPicker::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pColorPickerPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_ColorPicker::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pColorPickerPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_ColorPicker::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pColorPickerPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_ColorPicker::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pColorPickerPresenter->OnTouchCanceled(source, touchinfo); +} + +result +_ColorPicker::OnAttachedToMainTree(void) +{ + InitializeAccessibilityElement(); + + __pColorPickerPresenter->LoadDrawingProperties(GetBounds()); + + _VisualElement* pBase = GetVisualElement(); + + // Create All Handler + _ColorPickerComponentType handlerType = HUE_HANDLER; + + if (__pHueHandler == null) + { + __pHueHandler = __pColorPickerPresenter->CreateHandlerN(*pBase, handlerType); + } + + SysTryReturnResult(NID_UI_CTRL, (__pHueHandler != null), E_SYSTEM, + "A system error has occurred. Failed to create hue handler."); + + handlerType = SAT_HANDLER; + + if (__pSaturationHandler == null) + { + __pSaturationHandler = __pColorPickerPresenter->CreateHandlerN(*pBase, handlerType); + } + + SysTryReturnResult(NID_UI_CTRL, (__pSaturationHandler != null), E_SYSTEM, + "A system error has occurred. Failed to create saturation handler."); + + handlerType = LUM_HANDLER; + + if (__pLuminanceHandler == null) + { + __pLuminanceHandler = __pColorPickerPresenter->CreateHandlerN(*pBase, handlerType); + } + + SysTryReturnResult(NID_UI_CTRL, (__pLuminanceHandler != null), E_SYSTEM, + "A system error has occurred. Failed to create luminance handler."); + + return E_SUCCESS; +} + +void +_ColorPicker::InitializeAccessibilityElement(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer != null) + { + __pDecreaseHueButtonElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pDecreaseHueButtonElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pDecreaseHueButtonElement->SetLabel(L"Decrease Hue value"); + __pDecreaseHueButtonElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON); + + pContainer->AddElement(*__pDecreaseHueButtonElement); + + __pHueBarElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pHueBarElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + String hintText(L"Double tap and drag to adjust"); + + __pHueBarElement->SetLabel("Hue Slider"); + __pHueBarElement->SetTrait(ACCESSIBILITY_TRAITS_NONE); + __pHueBarElement->SetHint(hintText); + pContainer->AddElement(*__pHueBarElement); + + String hueValue; + hueValue.Append(__pColorPickerPresenter->GetHue()); + __pHueBarElement->SetValue(hueValue); + + __pIncreaseHueButtonElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pIncreaseHueButtonElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pIncreaseHueButtonElement->SetLabel(L"Increase Hue value"); + __pIncreaseHueButtonElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON); + pContainer->AddElement(*__pIncreaseHueButtonElement); + + __pDecreaseSaturationButtonElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pDecreaseSaturationButtonElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pDecreaseSaturationButtonElement->SetLabel(L"Decrease Saturation value"); + __pDecreaseSaturationButtonElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON); + pContainer->AddElement(*__pDecreaseSaturationButtonElement); + + __pSaturationBarElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pSaturationBarElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pSaturationBarElement->SetLabel("Saturation Slider"); + __pSaturationBarElement->SetTrait(ACCESSIBILITY_TRAITS_NONE); + __pSaturationBarElement->SetHint(hintText); + pContainer->AddElement(*__pSaturationBarElement); + + String saturationValue; + saturationValue.Append(__pColorPickerPresenter->GetSaturation()); + __pSaturationBarElement->SetValue(saturationValue); + + __pIncreaseSaturationButtonElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pIncreaseSaturationButtonElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pIncreaseSaturationButtonElement->SetLabel(L"Increase Saturation value"); + __pIncreaseSaturationButtonElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON); + pContainer->AddElement(*__pIncreaseSaturationButtonElement); + + __pDecreaseLuminanceButtonElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pDecreaseLuminanceButtonElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pDecreaseLuminanceButtonElement->SetLabel(L"Decrease Luminance value"); + __pDecreaseLuminanceButtonElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON); + pContainer->AddElement(*__pDecreaseLuminanceButtonElement); + + __pLuminanceBarElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pLuminanceBarElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pLuminanceBarElement->SetLabel("Luminance Slider"); + __pLuminanceBarElement->SetTrait(ACCESSIBILITY_TRAITS_NONE); + __pLuminanceBarElement->SetHint(hintText); + pContainer->AddElement(*__pLuminanceBarElement); + + String luminanceValue; + luminanceValue.Append(__pColorPickerPresenter->GetLuminance()); + __pLuminanceBarElement->SetValue(luminanceValue); + + __pIncreaseLuminanceButtonElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pIncreaseLuminanceButtonElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pIncreaseLuminanceButtonElement->SetLabel(L"Increase Luminance value"); + __pIncreaseLuminanceButtonElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON); + pContainer->AddElement(*__pIncreaseLuminanceButtonElement); + + pContainer->AddListener(*this); + } + return; +} + +void +_ColorPicker::OnBoundsChanged(void) +{ + __pColorPickerPresenter->LoadDrawingProperties(GetBounds()); + return; +} + +void +_ColorPicker::OnChangeLayout(_ControlOrientation orientation) +{ + __pColorPickerPresenter->OnChangeLayout(orientation); + return; +} + +void +_ColorPicker::OnDraw(void) +{ + __pColorPickerPresenter->Draw(); + return; +} + +result +_ColorPicker::AddColorChangeEventListener(const _IColorChangeEventListener& listener) +{ + result r = __pColorChangeEvent->AddListener(listener); + + SysTryReturnResult(NID_UI_CTRL, (r != E_OBJ_ALREADY_EXIST), E_SYSTEM, + "A system error has occurred. The _IColorChangeEventListener instance already exists in the event listener list."); + + return r; +} + +result +_ColorPicker::RemoveColorChangeEventListener(const _IColorChangeEventListener& listener) +{ + result r = __pColorChangeEvent->RemoveListener(listener); + + SysTryReturnResult(NID_UI_CTRL, (r != E_OBJ_NOT_FOUND), E_SYSTEM, + "A system error has occurred. The _IColorChangeEventListener instance does not exist in the event listener list."); + + return r; +} + +result +_ColorPicker::FireColorChangeEvent(const Color& color) +{ + IEventArg* pEventArg = _ColorChangeEvent::CreateColorChangeEventArgN(color); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pEventArg != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pColorChangeEvent->Fire(*pEventArg); + + return E_SUCCESS; +} + +_VisualElement* +_ColorPicker::GetHueHandler(void) +{ + return __pHueHandler; +} + +_VisualElement* +_ColorPicker::GetSaturationHandler(void) +{ + return __pSaturationHandler; +} + +_VisualElement* +_ColorPicker::GetLuminanceHandler(void) +{ + return __pLuminanceHandler; +} + +_AccessibilityElement* +_ColorPicker::GetAccessibilityElement(int elementId) +{ + _AccessibilityElement* pAccessibilityElement = null; + + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return null; + } + + switch (elementId) + { + case HUE_BAR: + pAccessibilityElement = __pHueBarElement; + break; + case SAT_BAR: + pAccessibilityElement = __pSaturationBarElement; + break; + case LUM_BAR: + pAccessibilityElement = __pLuminanceBarElement; + break; + case HUE_ARROWLEFT: + pAccessibilityElement = __pDecreaseHueButtonElement; + break; + case HUE_ARROWRIGHT: + pAccessibilityElement = __pIncreaseHueButtonElement; + break; + case SAT_ARROWLEFT: + pAccessibilityElement = __pDecreaseSaturationButtonElement; + break; + case SAT_ARROWRIGHT: + pAccessibilityElement = __pIncreaseSaturationButtonElement; + break; + case LUM_ARROWLEFT: + pAccessibilityElement = __pDecreaseLuminanceButtonElement; + break; + case LUM_ARROWRIGHT: + pAccessibilityElement = __pIncreaseLuminanceButtonElement; + break; + } + + return pAccessibilityElement; +} + +result +_ColorPicker::UpdateView(void) +{ + if (GetVisualElement() == null) + { + return E_SYSTEM; + } + + return GetVisualElement()->SetFlushNeeded(); +} + +bool +_ColorPicker::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + String elementLabel = element.GetLabel(); + String string; + + if (elementLabel.Equals(L"Hue Slider", false)) + { + SetHue(GetHue() + 1); + string.Append(GetHue() + 1); + } + else if (elementLabel.Equals(L"Saturation Slider", false)) + { + SetSaturation(GetSaturation() + 1); + string.Append(GetSaturation() + 1); + } + else if (elementLabel.Equals(L"Luminance Slider", false)) + { + SetLuminance(GetLuminance() + 1); + string.Append(GetLuminance() + 1); + } + + Invalidate(); + _AccessibilityManager::GetInstance()->ReadContent(string); + + return true; +} + +bool +_ColorPicker::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + String elementLabel = element.GetLabel(); + String string; + + if (elementLabel.Equals(L"Hue Slider", false)) + { + SetHue(GetHue() - 1); + string.Append(GetHue() - 1); + } + else if (elementLabel.Equals(L"Saturation Slider", false)) + { + SetSaturation(GetSaturation() - 1); + string.Append(GetSaturation() - 1); + } + else if (elementLabel.Equals(L"Luminance Slider", false)) + { + SetLuminance(GetLuminance() - 1); + string.Append(GetLuminance() - 1); + } + + Invalidate(); + _AccessibilityManager::GetInstance()->ReadContent(string); + + return true; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ColorPickerImpl.cpp b/src/ui/controls/FUiCtrl_ColorPickerImpl.cpp new file mode 100644 index 0000000..cecfae1 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ColorPickerImpl.cpp @@ -0,0 +1,336 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_ColorPickerImpl.cpp +* @brief This file contains implementation of _ColorPickerImpl class +* +* This file contains implementation of _ColorPickerImpl class. +*/ + +#include "FUi_ResourceManager.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_ColorPickerImpl.h" +#include "FUiCtrl_ColorPickerPresenter.h" +#include "FUiCtrl_PublicColorChangeEvent.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Dimension +_ColorPickerImpl::ColorPickerSizeInfo::GetDefaultMaximumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Dimension colorPickerMaxSize; + + r = GET_DIMENSION_CONFIG(COLORPICKER::DEFAULT_SIZE, orientation, colorPickerMaxSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, colorPickerMaxSize, r, "[%s] Propagating.", GetErrorMessage(r)); + + return colorPickerMaxSize; +} + +Dimension +_ColorPickerImpl::ColorPickerSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Dimension colorPickerMinSize; + + r = GET_DIMENSION_CONFIG(COLORPICKER::DEFAULT_SIZE, orientation, colorPickerMinSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, colorPickerMinSize, r, "[%s] Propagating.", GetErrorMessage(r)); + + return colorPickerMinSize; +} + +_ColorPickerImpl* +_ColorPickerImpl::GetInstance(ColorPicker& colorPicker) +{ + return static_cast<_ColorPickerImpl*>(colorPicker._pControlImpl); +} + +const _ColorPickerImpl* +_ColorPickerImpl::GetInstance(const ColorPicker& colorPicker) +{ + return static_cast(colorPicker._pControlImpl); +} + +_ColorPickerImpl::_ColorPickerImpl(ColorPicker& pPublic, _ColorPicker& pCore) + : _ControlImpl(&pPublic, &pCore) + , __pPublicColorChangeEvent(null) +{ + __pPublicColorChangeEvent = _PublicColorChangeEvent::CreateInstanceN(pPublic); + pCore.AddColorChangeEventListener(*this); +} + +_ColorPickerImpl::~_ColorPickerImpl(void) +{ + if (__pPublicColorChangeEvent != null) + { + delete __pPublicColorChangeEvent; + __pPublicColorChangeEvent = null; + } +} + +_ColorPickerImpl* +_ColorPickerImpl::CreateColorPickerImplN(ColorPicker& control) +{ + ClearLastResult(); + _ColorPicker* pCore = _ColorPicker::CreateColorPickerN(); + if (pCore == null) + { + return null; + } + + _ColorPickerImpl* pImpl = new (std::nothrow) _ColorPickerImpl(control, *pCore); + result r = CheckConstruction(pCore, pImpl); + if (r != E_SUCCESS) + { + return null; + } + + Dimension defaultSize; + r = GET_DIMENSION_CONFIG(COLORPICKER::DEFAULT_SIZE, pCore->GetOrientation(), defaultSize); + if (r != E_SUCCESS) + { + goto CATCH; + } + + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(ColorPicker), defaultSize, pCore->GetOrientation()); + if (r != E_SUCCESS) + { + goto CATCH; + } + + return pImpl; +CATCH: + delete pImpl; + return null; +} + +const Tizen::Graphics::Color +_ColorPickerImpl::GetColor(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyColor().ToColor(); +} + +const int +_ColorPickerImpl::GetHue(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyHue().ToInt(); +} + +const int +_ColorPickerImpl::GetSaturation(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertySaturation().ToInt(); +} + +const int +_ColorPickerImpl::GetLuminance(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyLuminance().ToInt(); +} + +result +_ColorPickerImpl::SetColor(const Tizen::Graphics::Color& color) +{ + ClearLastResult(); + Variant varColor(color); + + return GetCore().SetPropertyColor(varColor); +} + +result +_ColorPickerImpl::SetHue(int hue) +{ + ClearLastResult(); + Variant varHue(hue); + + return GetCore().SetPropertyHue(varHue); +} + +result +_ColorPickerImpl::SetSaturation(int saturation) +{ + ClearLastResult(); + Variant varSaturation(saturation); + + return GetCore().SetPropertySaturation(varSaturation); +} + +result +_ColorPickerImpl::SetLuminance(int luminance) +{ + ClearLastResult(); + Variant varLuminance(luminance); + + return GetCore().SetPropertyLuminance(varLuminance); +} + +result +_ColorPickerImpl::AddColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (__pPublicColorChangeEvent != null), E_SYSTEM, "A system error has occurred. The _PublicColorChangeEvent instance is null."); + + r = __pPublicColorChangeEvent->AddListener(listener); + + SysTryReturnResult(NID_UI_CTRL, (r != E_OBJ_ALREADY_EXIST), E_SYSTEM, + "A system error has occurred. The IColorChangeEventListener instance already exists in the event listener list."); + + return r; +} + +result +_ColorPickerImpl::RemoveColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener) +{ + ClearLastResult(); + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, __pPublicColorChangeEvent != null, E_SYSTEM, "A system error has occurred. The _PublicColorChangeEvent instance is null."); + + r = __pPublicColorChangeEvent->RemoveListener(listener); + + SysTryReturnResult(NID_UI_CTRL, (r != E_OBJ_NOT_FOUND), E_SYSTEM, + "A system error has occurred. The IColorChangeEventListener instance does not exist in the event listener list."); + + return r; +} + +ColorPicker& +_ColorPickerImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const ColorPicker& +_ColorPickerImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +_ColorPicker& +_ColorPickerImpl::GetCore(void) +{ + return static_cast <_ColorPicker&>(_ControlImpl::GetCore()); +} + +const _ColorPicker& +_ColorPickerImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +const char* +_ColorPickerImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::ColorPicker"; +} + +void +_ColorPickerImpl::OnColorChanged(const Tizen::Ui::_Control& source, const Tizen::Graphics::Color& color) +{ + Tizen::Base::Runtime::IEventArg * pColorChangeEventArg = _PublicColorChangeEvent::CreateColorChangeEventArgN(color); + if (pColorChangeEventArg == null) + { + return; + } + + __pPublicColorChangeEvent->Fire(*pColorChangeEventArg); + + return; +} + +class _ColorPickerMaker + : public _UiBuilderControlMaker +{ +public: + _ColorPickerMaker(_UiBuilder* pUibuilder) + : _UiBuilderControlMaker(pUibuilder) + { + } + + virtual ~_ColorPickerMaker(void) + { + } + + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _ColorPickerMaker* pColorPickerMaker = new (std::nothrow) _ColorPickerMaker(uibuilder); + return pColorPickerMaker; + } + +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SUCCESS; + _UiBuilderControlLayout* pControlProperty = null; + ColorPicker* pColorPicker = null; + Point point; + Rectangle rect; + + GetProperty(pControl, &pControlProperty); + SysTryReturn(NID_UI_CTRL, (pControlProperty != null), null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to read the attributes."); + + pColorPicker = new (std::nothrow) ColorPicker; + SysTryReturn(NID_UI_CTRL, (pColorPicker != null), null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + rect = pControlProperty->GetRect(); + + point.x = rect.x; + point.y = rect.y; + + r = pColorPicker->Construct(point); + if (r != E_SUCCESS) + { + delete pColorPicker; + return null; + } + + return pColorPicker; + } +}; + +_ColorPickerRegister::_ColorPickerRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"ColorPicker", _ColorPickerMaker::GetInstance); +} + +_ColorPickerRegister::~_ColorPickerRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"ColorPicker"); +} + +static _ColorPickerRegister ColorPickerRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ColorPickerModel.cpp b/src/ui/controls/FUiCtrl_ColorPickerModel.cpp new file mode 100644 index 0000000..d32d461 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ColorPickerModel.cpp @@ -0,0 +1,316 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_ColorPickerModel.cpp +* @brief This file contains implementation of _ColorPickerModel class +* +* This file contains implementation of _ColorPickerModel class. +*/ + +#include +#include +#include "FUiCtrl_ColorPickerModel.h" +#include "FUiCtrl_ColorPickerPresenter.h" + +using namespace Tizen::Graphics; + +const double MAX_COLOR_DEGREE = 255.0; +const double MIN_VALUE = 0.0; +const double MAX_VALUE = 1.0; +const double MAX_HUE_VALUE = 0.999999; +const double STANDARD_SATURATION_VALUE = 1.0; +const double STANDARD_LUMINANCE_VALUE = 0.5; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ColorPickerModel::_ColorPickerModel(void) + : __hue(MIN_VALUE) + , __sat(MIN_VALUE) + , __lum(MIN_VALUE) + , __color(Color::GetColor(COLOR_ID_BLACK)) +{ +} + +_ColorPickerModel::~_ColorPickerModel() +{ +} + +_ColorPickerModel* +_ColorPickerModel::CreateInstanceN(void) +{ + _ColorPickerModel* pColorPickerModel = new (std::nothrow) _ColorPickerModel; + SysTryReturn(NID_UI_CTRL, (pColorPickerModel != null), null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (IsFailed(GetLastResult()) == true) + { + delete pColorPickerModel; + return null; + } + + return pColorPickerModel; +} + +double +_ColorPickerModel::GetHue(void) const +{ + return __hue; +} + +double +_ColorPickerModel::GetSaturation(void) const +{ + return __sat; +} + +double +_ColorPickerModel::GetLuminance(void) const +{ + return __lum; +} + +void +_ColorPickerModel::SetHue(double hueValue) +{ + if (hueValue > MAX_HUE_VALUE) + { + __hue = MAX_HUE_VALUE; + } + else if (hueValue < MIN_VALUE) + { + __hue = MIN_VALUE; + } + else + { + __hue = hueValue; + } + CalulateColor(); +} + +void +_ColorPickerModel::SetSaturation(double saturationValue) +{ + if (saturationValue > MAX_VALUE) + { + __sat = MAX_VALUE; + } + else if (saturationValue < MIN_VALUE) + { + __sat = MIN_VALUE; + } + else + { + __sat = saturationValue; + } + CalulateColor(); +} + +void +_ColorPickerModel::SetLuminance(double luminanceValue) +{ + if (luminanceValue > MAX_VALUE) + { + __lum = MAX_VALUE; + } + else if (luminanceValue < MIN_VALUE) + { + __lum = MIN_VALUE; + } + else + { + __lum = luminanceValue; + } + CalulateColor(); +} + +Color +_ColorPickerModel::GetHueColor(void) const +{ + Color color; + + ConvertHSLToRGB(__hue, STANDARD_SATURATION_VALUE, STANDARD_LUMINANCE_VALUE, color); + + return color; +} + +Color +_ColorPickerModel::GetSaturationColor(void) const +{ + Color color; + + ConvertHSLToRGB(__hue, __sat, STANDARD_LUMINANCE_VALUE, color); + + return color; +} + +Color +_ColorPickerModel::GetColor(void) const +{ + return __color; +} + +void +_ColorPickerModel::SetColor(const Color& color) +{ + __color = color; + + ConvertRGBToHSL(__color, __hue, __sat, __lum); +} + +void +_ColorPickerModel::CalulateColor(void) +{ + ConvertHSLToRGB(__hue, __sat, __lum, __color); +} + +void +_ColorPickerModel::ConvertRGBToHSL(const Color& color, double& h, double& s, double& l) +{ + double normalizeR = (double)color.GetRed() / MAX_COLOR_DEGREE; + double normalizeG = (double)color.GetGreen() / MAX_COLOR_DEGREE; + double normalizeB = (double)color.GetBlue() / MAX_COLOR_DEGREE; + double max = (normalizeR > normalizeG) ? ((normalizeR > normalizeB) ? normalizeR : normalizeB) + : ((normalizeG > normalizeB) ? normalizeG : normalizeB); + double min = (normalizeR > normalizeG) ? ((normalizeG > normalizeB) ? normalizeB : normalizeG) + : ((normalizeR > normalizeB) ? normalizeB : normalizeR); + double diff = max - min; + if (diff <= 0.0) + { + return; + } + + l = (min + max) / 2.0; + s = diff / ((l <= STANDARD_LUMINANCE_VALUE) ? (max + min) : (2.0 - max - min)); + + if (normalizeR >= max) + { + if (normalizeG <= min) + { + h = 5.0 + (max - normalizeB) / diff; + } + else + { + h = 1.0 - (max - normalizeG) / diff; + } + } + else if (normalizeG >= max) + { + if (normalizeB <= min) + { + h = 1.0 + (max - normalizeR) / diff; + } + else + { + h = 3.0 - (max - normalizeB) / diff; + } + } + else + { + if (normalizeR <= min) + { + h = 3.0 + (max - normalizeG) / diff; + } + else + { + h = 5.0 - (max - normalizeR) / diff; + } + } + + h /= 6.0; +} + +void +_ColorPickerModel::ConvertHSLToRGB(double h, double s, double l, Color& color) +{ + result r = E_SUCCESS; + double v = 0.0; + double normalizeR = 0.0; + double normalizeG = 0.0; + double normalizeB = 0.0; + + normalizeR = l; + normalizeG = l; + normalizeB = l; + + v = (l <= STANDARD_LUMINANCE_VALUE) ? (l + l * s) : (l + s - l * s); + + if (v > 0) + { + double m = l + l - v; + + h *= 6.0; + + int sextant = (int) h; + double fract = h - sextant; + double vsf = (v - m) * fract; + double mid1 = m + vsf; + double mid2 = v - vsf; + + switch (sextant) + { + case 0: + normalizeR = v; + normalizeG = mid1; + normalizeB = m; + break; + + case 1: + normalizeR = mid2; + normalizeG = v; + normalizeB = m; + break; + + case 2: + normalizeR = m; + normalizeG = v; + normalizeB = mid1; + break; + + case 3: + normalizeR = m; + normalizeG = mid2; + normalizeB = v; + break; + + case 4: + normalizeR = mid1; + normalizeG = m; + normalizeB = v; + break; + + case 5: + normalizeR = v; + normalizeG = m; + normalizeB = mid2; + break; + + default: + r = E_SYSTEM; + break; + } + + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[E_SYSTEM] A system error has occurred. Hue value is out of range."); + } + + color.SetColorComponents((byte)(normalizeR * MAX_COLOR_DEGREE), // red + (byte)(normalizeG * MAX_COLOR_DEGREE), // green + (byte)(normalizeB * MAX_COLOR_DEGREE), // blue + (byte)(MAX_COLOR_DEGREE)); // alpha +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ColorPickerPresenter.cpp b/src/ui/controls/FUiCtrl_ColorPickerPresenter.cpp new file mode 100644 index 0000000..83efe2c --- /dev/null +++ b/src/ui/controls/FUiCtrl_ColorPickerPresenter.cpp @@ -0,0 +1,1380 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ColorPickerPresenter.cpp + * @brief This is the implementation file for the FUiCtrl_ColorPickerPresenter class. + */ + +#include +#include +#include +#include +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_ColorPickerPresenter.h" +#include "FUiCtrl_ColorPickerModel.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +const int ARROW_MOVE_STEP = 5; +const int SLIDE_ACTIVATION_TIME = 500; +const int SLIDE_MOVE_TIME = 60; +const double MAX_VALUE_DEGREE = 100.0; +const double MIN_VALUE = 0.0; +const double MAX_VALUE = 1.0; + +namespace Tizen { namespace Ui { namespace Controls +{ + +union _Color32 +{ + unsigned int color32; + struct + { + byte b; + byte g; + byte r; + byte a; + } colorArgb; +}; + +_ColorPickerPresenter::_ColorPickerPresenter(_ColorPicker& colorPicker) + : __pColorPicker(&colorPicker) + , __pColorPickerModel(null) + , __eventType(HSL_NOT) + , __topMargin(0) + , __blockMargin(0) + , __blockHeight(0) + , __dividerMargin(0) + , __dividerWidth(0) + , __hueColor(0) + , __saturationColor(0) + , __pSlideTimer(null) + , __pHueSliderBgBitmap(null) + , __pCustomBitmap(null) + , __pLuminanceSliderBgBitmap(null) + , __pSaturationSliderBgBitmap(null) + , __pColorNormalReplacementBgBitmap(null) + , __pColorPressedReplacementBgBitmap(null) + , __pColorDisabledReplacementBgBitmap(null) + , __pColorNormalEffectReplacementBgBitmap(null) + , __pColorPressedEffectReplacementBgBitmap(null) + , __pColorDisabledEffectReplacementBgBitmap(null) + , __pLeftArrowNormalBitmap(null) + , __pLeftArrowPressedBitmap(null) + , __pLeftArrowDisabledBitmap(null) + , __pRightArrowNormalBitmap(null) + , __pRightArrowPressedBitmap(null) + , __pRightArrowDisabledBitmap(null) + , __pHandlerBitmap(null) + , __pLandscapeHueSliderBgBitmap(null) + , __pLandscapeCustomBitmap(null) + , __pLandscapeLuminanceSliderBgBitmap(null) + , __pLandscapeSaturationSliderBgBitmap(null) +{ +} + +_ColorPickerPresenter::~_ColorPickerPresenter(void) +{ + __pColorPicker = null; + + delete __pColorPickerModel; + __pColorPickerModel = null; + + if (__pSlideTimer != null) + { + __pSlideTimer->Cancel(); + delete __pSlideTimer; + __pSlideTimer = null; + } + + delete __pHueSliderBgBitmap; + __pHueSliderBgBitmap = null; + + delete __pCustomBitmap; + __pCustomBitmap = null; + + delete __pLuminanceSliderBgBitmap; + __pLuminanceSliderBgBitmap = null; + + delete __pSaturationSliderBgBitmap; + __pSaturationSliderBgBitmap = null; + + delete __pColorNormalReplacementBgBitmap; + __pColorNormalReplacementBgBitmap = null; + + delete __pColorPressedReplacementBgBitmap; + __pColorPressedReplacementBgBitmap = null; + + delete __pColorDisabledReplacementBgBitmap; + __pColorDisabledReplacementBgBitmap = null; + + delete __pColorNormalEffectReplacementBgBitmap; + __pColorNormalEffectReplacementBgBitmap = null; + + delete __pColorPressedEffectReplacementBgBitmap; + __pColorPressedEffectReplacementBgBitmap = null; + + delete __pColorDisabledEffectReplacementBgBitmap; + __pColorDisabledEffectReplacementBgBitmap = null; + + delete __pLeftArrowNormalBitmap; + __pLeftArrowNormalBitmap = null; + + delete __pLeftArrowPressedBitmap; + __pLeftArrowPressedBitmap = null; + + delete __pLeftArrowDisabledBitmap; + __pLeftArrowDisabledBitmap = null; + + delete __pRightArrowNormalBitmap; + __pRightArrowNormalBitmap = null; + + delete __pRightArrowPressedBitmap; + __pRightArrowPressedBitmap = null; + + delete __pRightArrowDisabledBitmap; + __pRightArrowDisabledBitmap = null; + + delete __pHandlerBitmap; + __pHandlerBitmap = null; + + delete __pLandscapeHueSliderBgBitmap; + __pLandscapeHueSliderBgBitmap = null; + + delete __pLandscapeCustomBitmap; + __pLandscapeCustomBitmap = null; + + delete __pLandscapeLuminanceSliderBgBitmap; + __pLandscapeLuminanceSliderBgBitmap = null; + + delete __pLandscapeSaturationSliderBgBitmap; + __pLandscapeSaturationSliderBgBitmap = null; +} + +_ColorPickerPresenter* +_ColorPickerPresenter::CreateInstanceN(_ColorPicker& colorPicker) +{ + _ColorPickerPresenter* pColorPickerPresenter = new (std::nothrow) _ColorPickerPresenter(colorPicker); + SysTryReturn(NID_UI_CTRL, (pColorPickerPresenter != null), null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pColorPickerPresenter->__pColorPickerModel = _ColorPickerModel::CreateInstanceN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pColorPickerPresenter->__pColorPickerModel != null), , r, + "[%s] Propagating.", GetErrorMessage(r)); + + r = pColorPickerPresenter->LoadResource(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to load the ColorPicker resources."); + + pColorPickerPresenter->__pColorPickerModel->SetHue(MIN_VALUE); + pColorPickerPresenter->__pColorPickerModel->SetSaturation(MAX_VALUE); + pColorPickerPresenter->__pColorPickerModel->SetLuminance(MIN_VALUE); + + return pColorPickerPresenter; +CATCH: + delete pColorPickerPresenter; + return null; +} + +_VisualElement* +_ColorPickerPresenter::CreateHandlerN(_VisualElement& rootElement, _ColorPickerComponentType handlerType) +{ + Canvas* pCanvas = null; + int handlerWidth = 0; + int handlerHeight = 0; + result r = E_SUCCESS; + Rectangle handlerBounds = __componentBounds[handlerType]; + Rectangle bounds = __pColorPicker->GetClientBounds(); + + _VisualElement* pHandler = new (std::nothrow) _VisualElement; + SysTryReturn(NID_UI_CTRL, (pHandler != null), null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pHandler->Construct(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_SHAPE_CONFIG(COLORPICKER::HANDLER_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, handlerWidth); + GET_SHAPE_CONFIG(COLORPICKER::HANDLER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, handlerHeight); + + pHandler->SetImplicitAnimationEnabled(false); + + pHandler->SetBounds(FloatRectangle(bounds.x + handlerBounds.x, bounds.y + handlerBounds.y, handlerWidth, handlerHeight)); + pHandler->SetShowState(true); + pHandler->SetBackBufferEnabled(true); + + pHandler->SetRedrawOnResizeEnabled(true); + pHandler->SetSurfaceOpaque(false); + + r = rootElement.AttachChild(*pHandler); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas = pHandler->GetCanvasN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas->SetBackgroundColor(Color()); + pCanvas->Clear(); + DrawResourceBitmap(*pCanvas, Rectangle(0, 0, handlerWidth, handlerHeight), __pHandlerBitmap); + + delete pCanvas; + + return pHandler; +CATCH: + pHandler->Destroy(); + return null; +} + +result +_ColorPickerPresenter::Draw(void) +{ + Canvas* pCanvas = __pColorPicker->GetCanvasN(); + if (pCanvas == null) + { + SetLastResult(E_SYSTEM); + return E_SYSTEM; + } + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + DrawLine(*pCanvas); + DrawArrowButtons(*pCanvas); + + DrawHueSlider(*pCanvas); + MoveHandler(HUE_HANDLER); + + DrawSaturationSlider(*pCanvas); + MoveHandler(SAT_HANDLER); + + DrawLuminanceSlider(*pCanvas); + MoveHandler(LUM_HANDLER); + + delete pCanvas; + pCanvas = null; + + return E_SUCCESS; +} + +Color +_ColorPickerPresenter::GetColor(void) const +{ + return __pColorPickerModel->GetColor(); +} + +int +_ColorPickerPresenter::GetHue(void) const +{ + return __pColorPickerModel->GetHue() * MAX_VALUE_DEGREE; +} + +int +_ColorPickerPresenter::GetSaturation(void) const +{ + return __pColorPickerModel->GetSaturation() * MAX_VALUE_DEGREE; +} + +int +_ColorPickerPresenter::GetLuminance(void) const +{ + return __pColorPickerModel->GetLuminance() * MAX_VALUE_DEGREE; +} + +void +_ColorPickerPresenter::SetColor(const Color& color) +{ + __pColorPickerModel->SetColor(color); + SetHandlerPositionByRatio(HUE_HANDLER, __pColorPickerModel->GetHue()); + SetHandlerPositionByRatio(SAT_HANDLER, __pColorPickerModel->GetSaturation()); + SetHandlerPositionByRatio(LUM_HANDLER, __pColorPickerModel->GetLuminance()); + + return; +} + +result +_ColorPickerPresenter::SetHue(int hue) +{ + SysTryReturn(NID_UI_CTRL, (hue <= MAX_VALUE_DEGREE && hue >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. Hue value is invalid."); + + __pColorPickerModel->SetHue((double)hue / MAX_VALUE_DEGREE); + SetHandlerPositionByRatio(HUE_HANDLER, __pColorPickerModel->GetHue()); + + return E_SUCCESS; +} + +result +_ColorPickerPresenter::SetSaturation(int saturation) +{ + SysTryReturn(NID_UI_CTRL, (saturation <= MAX_VALUE_DEGREE && saturation >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. Saturation value is invalid."); + + __pColorPickerModel->SetSaturation((double)saturation / MAX_VALUE_DEGREE); + SetHandlerPositionByRatio(SAT_HANDLER, __pColorPickerModel->GetSaturation()); + + return E_SUCCESS; +} + +result +_ColorPickerPresenter::SetLuminance(int luminance) +{ + SysTryReturn(NID_UI_CTRL, (luminance <= MAX_VALUE_DEGREE && luminance >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. Luminance value is invalid."); + + __pColorPickerModel->SetLuminance((double)luminance / MAX_VALUE_DEGREE); + SetHandlerPositionByRatio(LUM_HANDLER, __pColorPickerModel->GetLuminance()); + + return E_SUCCESS; +} + +void +_ColorPickerPresenter::LoadDrawingProperties(const Rectangle& controlBounds) +{ + const int _BLOCK_COUNT = 3; + int arrowButtonLeftMargin = 0; + int arrowButtonTopMargin = 0; + int barTopMargin = 0; + int barLeftMargin = 0; + int sliderHeight = 0; + int sliderWidth = 0; + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + GET_SHAPE_CONFIG(COLORPICKER::ARROW_BUTTON_LEFT_MARGIN, orientation, arrowButtonLeftMargin); + GET_SHAPE_CONFIG(COLORPICKER::ARROW_BUTON_TOP_MARGIN, orientation, arrowButtonTopMargin); + GET_SHAPE_CONFIG(COLORPICKER::BAR_TOP_MARGIN, orientation, barTopMargin); + GET_SHAPE_CONFIG(COLORPICKER::BAR_LEFT_MARGIN, orientation, barLeftMargin); + GET_SHAPE_CONFIG(COLORPICKER::SLIDER_HEIGHT, orientation, sliderHeight); + GET_FIXED_VALUE_CONFIG(COLORPICKER::BLOCK_MARGIN, orientation, __blockMargin); + GET_SHAPE_CONFIG(COLORPICKER::BLOCK_HEIGHT, orientation, __blockHeight); + GET_SHAPE_CONFIG(COLORPICKER::DIVIDER_MARGIN, orientation, __dividerMargin); + GET_SHAPE_CONFIG(COLORPICKER::DIVIDER_WIDTH, orientation, __dividerWidth); + + __topMargin = (controlBounds.height - (__blockMargin + __blockHeight) * _BLOCK_COUNT + __blockMargin) / 2; + + if (__topMargin < 0) + { + __topMargin = 0; + } + + int arrowButtonWidth = 0; + int arrowButtonHeight = 0; + + GET_SHAPE_CONFIG(COLORPICKER::ARROW_BUTTON_WIDTH, orientation, arrowButtonWidth); + GET_SHAPE_CONFIG(COLORPICKER::ARROW_BUTTON_HEIGHT, orientation, arrowButtonHeight); + + int handlerWidth = 0; + int handlerHeight = 0; + + GET_SHAPE_CONFIG(COLORPICKER::HANDLER_WIDTH, orientation, handlerWidth); + GET_SHAPE_CONFIG(COLORPICKER::HANDLER_HEIGHT, orientation, handlerHeight); + + int btnStartY = arrowButtonTopMargin + __topMargin; + int barStartY = barTopMargin + __topMargin; + + GET_SHAPE_CONFIG(COLORPICKER::BAR_WIDTH, orientation, sliderWidth); + + //Set contents position + __componentBounds[HUE_ARROWLEFT].SetBounds(arrowButtonLeftMargin, btnStartY, arrowButtonWidth, arrowButtonHeight); + + __componentBounds[HUE_BAR].SetBounds(arrowButtonLeftMargin + arrowButtonWidth + barLeftMargin, barStartY, sliderWidth, sliderHeight); + + __componentBounds[HUE_ARROWRIGHT].SetBounds(__componentBounds[HUE_BAR].x + sliderWidth + barLeftMargin, btnStartY, + arrowButtonWidth, arrowButtonHeight); + + btnStartY += __blockHeight + __blockMargin; + __componentBounds[SAT_ARROWLEFT].SetBounds(arrowButtonLeftMargin, btnStartY, arrowButtonWidth, arrowButtonHeight); + + __componentBounds[SAT_BAR].SetBounds(arrowButtonLeftMargin + arrowButtonWidth + barLeftMargin, barStartY + __blockHeight + __blockMargin, + sliderWidth, sliderHeight); + + __componentBounds[SAT_ARROWRIGHT].SetBounds(__componentBounds[SAT_BAR].x + sliderWidth + barLeftMargin, btnStartY, + arrowButtonWidth, arrowButtonHeight); + + btnStartY += __blockHeight + __blockMargin; + __componentBounds[LUM_ARROWLEFT].SetBounds(arrowButtonLeftMargin, btnStartY, arrowButtonWidth, arrowButtonHeight); + + __componentBounds[LUM_BAR].SetBounds(arrowButtonLeftMargin + arrowButtonWidth + barLeftMargin, barStartY + (__blockHeight + __blockMargin) * 2, + sliderWidth, sliderHeight); + + __componentBounds[LUM_ARROWRIGHT].SetBounds(__componentBounds[LUM_BAR].x + sliderWidth + barLeftMargin, btnStartY, + arrowButtonWidth, arrowButtonHeight); + + int differentialY = (handlerHeight - sliderHeight) / 2; + + __componentBounds[HUE_HANDLER].SetBounds( + __componentBounds[HUE_BAR].x + (__componentBounds[HUE_BAR].width - handlerWidth) * __pColorPickerModel->GetHue(), + __componentBounds[HUE_BAR].y - differentialY, + handlerWidth, + handlerHeight); + + __componentBounds[SAT_HANDLER].SetBounds( + __componentBounds[SAT_BAR].x + (__componentBounds[SAT_BAR].width - handlerWidth) * (MAX_VALUE - __pColorPickerModel->GetSaturation()), + __componentBounds[SAT_BAR].y - differentialY, + handlerWidth, + handlerHeight); + + __componentBounds[LUM_HANDLER].SetBounds( + __componentBounds[LUM_BAR].x + (__componentBounds[LUM_BAR].width - handlerWidth) * __pColorPickerModel->GetLuminance(), + __componentBounds[LUM_BAR].y - differentialY, + handlerWidth, + handlerHeight); + + // Set bounds of AccessibilityElement + _AccessibilityElement* pElement = null; + for (int elementId = HUE_BAR; elementId <= LUM_ARROWRIGHT; elementId++) + { + pElement = __pColorPicker->GetAccessibilityElement(elementId); + if (pElement != null) + { + pElement->SetBounds(__componentBounds[elementId]); + pElement = null; + } + } + return; +} + +void +_ColorPickerPresenter::OnChangeLayout(_ControlOrientation orientation) +{ + Dimension colorPickerSize; + result r = GET_DIMENSION_CONFIG(COLORPICKER::DEFAULT_SIZE, orientation, colorPickerSize); + if (r == E_SUCCESS && colorPickerSize != __pColorPicker->GetSize()) + { + __pColorPicker->SetResizable(true); + __pColorPicker->SetSize(colorPickerSize); + __pColorPicker->SetResizable(false); + } + return; +} + +bool +_ColorPickerPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + Point point = touchinfo.GetCurrentPosition(); + __eventType = GetTouchActionType(point); + + if (__eventType >= HUE_ARROWLEFT && __eventType <= LUM_ARROWRIGHT) + { + Rectangle buttonBounds = __componentBounds[__eventType]; + Canvas* pCanvas = __pColorPicker->GetCanvasN(buttonBounds); + if (pCanvas != null) + { + buttonBounds.x = 0; + buttonBounds.y = 0; + DrawArrowButton(*pCanvas, buttonBounds, true, IsLeftButton(__eventType)); + delete pCanvas; + __pColorPicker->UpdateView(); + } + TouchButton(); + + if (__pSlideTimer == null) + { + __pSlideTimer = new (std::nothrow) Timer; + if (__pSlideTimer == null) + { + return false; + } + + result r = __pSlideTimer->Construct(*this); + if (r != E_SUCCESS) + { + delete __pSlideTimer; + __pSlideTimer = null; + + return false; + } + } + __pSlideTimer->Start(SLIDE_ACTIVATION_TIME); + } + else if (__eventType >= HUE_HANDLER && __eventType <= LUM_HANDLER) + { + TouchHandler(point.x); + } + + return false; +} + +bool +_ColorPickerPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__eventType >= HUE_HANDLER && __eventType <= LUM_HANDLER) + { + TouchHandler(touchinfo.GetCurrentPosition().x); + } + + return false; +} + +bool +_ColorPickerPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__pSlideTimer != null) + { + __pSlideTimer->Cancel(); + } + + if (__eventType >= HUE_HANDLER && __eventType <= LUM_HANDLER) + { + TouchHandler(touchinfo.GetCurrentPosition().x); + __eventType = HSL_NOT; + } + else + { + __eventType = HSL_NOT; + __pColorPicker->Draw(); + } + + return false; +} + +bool +_ColorPickerPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return OnTouchReleased(source, touchinfo); +} + +void +_ColorPickerPresenter::OnTimerExpired(Timer& timer) +{ + if (__eventType >= HUE_ARROWLEFT && __eventType <= LUM_ARROWRIGHT) + { + TouchButton(); + } + + timer.Start(SLIDE_MOVE_TIME); +} + +result +_ColorPickerPresenter::LoadResource(void) +{ + result r = E_SUCCESS; + Color buttonNormalColor; + Color buttonPressedColor; + Color buttonDisabledColor; + Color buttonBgNormalColor; + Color buttonBgPressedColor; + Color buttonBgDisabledColor; + Bitmap* pBgNormalBitmap = null; + Bitmap* pBgPressedBitmap = null; + Bitmap* pBgDisabledBitmap = null; + Bitmap* pBgEffectNormalBitmap = null; + Bitmap* pBgEffectPressedBitmap = null; + Bitmap* pBgEffectDisabledBitmap = null; + Bitmap* pLeftArrowNormalBitmap = null; + Bitmap* pLeftArrowPressedBitmap = null; + Bitmap* pLeftArrowDisabledBitmap = null; + Bitmap* pRightArrowNormalBitmap = null; + Bitmap* pRightArrowPressedBitmap = null; + Bitmap* pRightArrowDisabledBitmap = null; + + r = GET_COLOR_CONFIG(COLORPICKER::ARROW_BUTTON_BG_NORMAL, buttonBgNormalColor); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(COLORPICKER::ARROW_BUTTON_BG_PRESSED, buttonBgPressedColor); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(COLORPICKER::ARROW_BUTTON_BG_DISABLED, buttonBgDisabledColor); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(COLORPICKER::ARROW_BUTTON_NORMAL, buttonNormalColor); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(COLORPICKER::ARROW_BUTTON_PRESSED, buttonPressedColor); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(COLORPICKER::ARROW_BUTTON_DISABLED, buttonDisabledColor); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::HUE_BAR_PORTRAIT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHueSliderBgBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::BAR_BG_PORTRAIT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pCustomBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::LUMINANCE_BAR_PORTRAIT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pLuminanceSliderBgBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::SATURATION_BAR_PORTRAIT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pSaturationSliderBgBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::HUE_BAR_LANDSCAPE_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pLandscapeHueSliderBgBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::BAR_BG_LANDSCAPE_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pLandscapeCustomBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::LUMINANCE_BAR_LANDSCAPE_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pLandscapeLuminanceSliderBgBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::SATURATION_BAR__LANDSCAPE_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pLandscapeSaturationSliderBgBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::ARROW_BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBgNormalBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::ARROW_BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pBgPressedBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::ARROW_BUTTON_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pBgDisabledBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::ARROW_BUTTON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBgEffectNormalBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::ARROW_BUTTON_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pBgEffectPressedBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::ARROW_BUTTON_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pBgEffectDisabledBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::LEFT_ARROW_BUTTON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pLeftArrowNormalBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::LEFT_ARROW_BUTTON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pLeftArrowPressedBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::LEFT_ARROW_BUTTON_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pLeftArrowDisabledBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::RIGHT_ARROW_BUTTON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pRightArrowNormalBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::RIGHT_ARROW_BUTTON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pRightArrowPressedBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::RIGHT_ARROW_BUTTON_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pRightArrowDisabledBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pColorNormalReplacementBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBgNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonBgNormalColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pColorPressedReplacementBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBgPressedBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonBgPressedColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pColorDisabledReplacementBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBgDisabledBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonBgDisabledColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pColorNormalEffectReplacementBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBgEffectNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonBgNormalColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pColorPressedEffectReplacementBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBgEffectPressedBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonBgPressedColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pColorDisabledEffectReplacementBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBgEffectDisabledBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonBgDisabledColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLeftArrowNormalBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pLeftArrowNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLeftArrowPressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pLeftArrowPressedBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonPressedColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLeftArrowDisabledBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pLeftArrowDisabledBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonDisabledColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pRightArrowNormalBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pRightArrowNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pRightArrowPressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pRightArrowPressedBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonPressedColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pRightArrowDisabledBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pRightArrowDisabledBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonDisabledColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(COLORPICKER::HANDLER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pBgNormalBitmap; + pBgNormalBitmap = null; + + delete pBgPressedBitmap; + pBgPressedBitmap = null; + + delete pBgDisabledBitmap; + pBgDisabledBitmap = null; + + delete pBgEffectNormalBitmap; + pBgEffectNormalBitmap = null; + + delete pBgEffectPressedBitmap; + pBgEffectPressedBitmap = null; + + delete pBgEffectDisabledBitmap; + pBgEffectDisabledBitmap = null; + + delete pLeftArrowNormalBitmap; + pLeftArrowNormalBitmap = null; + + delete pLeftArrowPressedBitmap; + pLeftArrowPressedBitmap = null; + + delete pLeftArrowDisabledBitmap; + pLeftArrowDisabledBitmap = null; + + delete pRightArrowNormalBitmap; + pRightArrowNormalBitmap = null; + + delete pRightArrowPressedBitmap; + pRightArrowPressedBitmap = null; + + delete pRightArrowDisabledBitmap; + pRightArrowDisabledBitmap = null; + + return r; + +CATCH: + delete __pHueSliderBgBitmap; + __pHueSliderBgBitmap = null; + + delete __pCustomBitmap; + __pCustomBitmap = null; + + delete __pLuminanceSliderBgBitmap; + __pLuminanceSliderBgBitmap = null; + + delete __pSaturationSliderBgBitmap; + __pSaturationSliderBgBitmap = null; + + delete pBgNormalBitmap; + pBgNormalBitmap = null; + + delete pBgPressedBitmap; + pBgPressedBitmap = null; + + delete pBgDisabledBitmap; + pBgDisabledBitmap = null; + + delete pBgEffectNormalBitmap; + pBgEffectNormalBitmap = null; + + delete pBgEffectPressedBitmap; + pBgEffectPressedBitmap = null; + + delete pBgEffectDisabledBitmap; + pBgEffectDisabledBitmap = null; + + delete pLeftArrowNormalBitmap; + pLeftArrowNormalBitmap = null; + + delete pLeftArrowPressedBitmap; + pLeftArrowPressedBitmap = null; + + delete pLeftArrowDisabledBitmap; + pLeftArrowDisabledBitmap = null; + + delete pRightArrowNormalBitmap; + pRightArrowNormalBitmap = null; + + delete pRightArrowPressedBitmap; + pRightArrowPressedBitmap = null; + + delete pRightArrowDisabledBitmap; + pRightArrowDisabledBitmap = null; + + delete __pColorNormalReplacementBgBitmap; + __pColorNormalReplacementBgBitmap = null; + + delete __pColorPressedReplacementBgBitmap; + __pColorPressedReplacementBgBitmap = null; + + delete __pColorDisabledReplacementBgBitmap; + __pColorDisabledReplacementBgBitmap = null; + + delete __pColorNormalEffectReplacementBgBitmap; + __pColorNormalEffectReplacementBgBitmap = null; + + delete __pColorPressedEffectReplacementBgBitmap; + __pColorPressedEffectReplacementBgBitmap = null; + + delete __pColorDisabledEffectReplacementBgBitmap; + __pColorDisabledEffectReplacementBgBitmap = null; + + delete __pLeftArrowNormalBitmap; + __pLeftArrowNormalBitmap = null; + + delete __pLeftArrowPressedBitmap; + __pLeftArrowPressedBitmap = null; + + delete __pLeftArrowDisabledBitmap; + __pLeftArrowDisabledBitmap = null; + + delete __pRightArrowNormalBitmap; + __pRightArrowNormalBitmap = null; + + delete __pRightArrowPressedBitmap; + __pRightArrowPressedBitmap = null; + + delete __pRightArrowDisabledBitmap; + __pRightArrowDisabledBitmap = null; + + return r; +} + +result +_ColorPickerPresenter::DrawHueSlider(Canvas& canvas) +{ + result r = E_SUCCESS; + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + if (__pHueSliderBgBitmap != null && orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + r = DrawResourceBitmap(canvas, __componentBounds[HUE_BAR], __pHueSliderBgBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (__pLandscapeHueSliderBgBitmap != null && orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + r = DrawResourceBitmap(canvas, __componentBounds[HUE_BAR], __pLandscapeHueSliderBgBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_ColorPickerPresenter::DrawLuminanceSlider(Canvas& canvas) +{ + result r = E_SUCCESS; + Bitmap* pColorReplacementBitmap = null; + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + if (__pCustomBitmap != null && __pLuminanceSliderBgBitmap != null && orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + pColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pCustomBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pColorPickerModel->GetSaturationColor()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pColorReplacementBitmap, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(canvas, __componentBounds[LUM_BAR], pColorReplacementBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(canvas, __componentBounds[LUM_BAR], __pLuminanceSliderBgBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (__pLandscapeCustomBitmap != null && __pLandscapeLuminanceSliderBgBitmap != null && orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + pColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pLandscapeCustomBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pColorPickerModel->GetSaturationColor()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pColorReplacementBitmap, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(canvas, __componentBounds[LUM_BAR], pColorReplacementBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(canvas, __componentBounds[LUM_BAR], __pLandscapeLuminanceSliderBgBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + + __saturationColor = __pColorPickerModel->GetSaturationColor(); + + delete pColorReplacementBitmap; + pColorReplacementBitmap = null; + + return r; + +CATCH: + + delete pColorReplacementBitmap; + pColorReplacementBitmap = null; + + return r; +} + +result +_ColorPickerPresenter::DrawSaturationSlider(Canvas& canvas) +{ + result r = E_SUCCESS; + Bitmap* pColorReplacementBitmap = null; + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + if (__pCustomBitmap != null && __pSaturationSliderBgBitmap != null && orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + pColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pCustomBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pColorPickerModel->GetHueColor()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pColorReplacementBitmap, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(canvas, __componentBounds[SAT_BAR], pColorReplacementBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(canvas, __componentBounds[SAT_BAR], __pSaturationSliderBgBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (__pLandscapeCustomBitmap != null && __pLandscapeSaturationSliderBgBitmap != null && orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + pColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pLandscapeCustomBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pColorPickerModel->GetHueColor()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pColorReplacementBitmap, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(canvas, __componentBounds[SAT_BAR], pColorReplacementBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(canvas, __componentBounds[SAT_BAR], __pLandscapeSaturationSliderBgBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + + __hueColor = __pColorPickerModel->GetHueColor(); + + delete pColorReplacementBitmap; + pColorReplacementBitmap = null; + + return r; + +CATCH: + + delete pColorReplacementBitmap; + pColorReplacementBitmap = null; + + return r; +} + +result +_ColorPickerPresenter::DrawLine(Canvas& canvas) +{ + if (__blockMargin <= 0) + { + return E_SUCCESS; + } + + result r = E_SUCCESS; + Color foregroundColor = canvas.GetForegroundColor(); + Color lineColor; + r = GET_COLOR_CONFIG(COLORPICKER::DIVIDER_NORMAL, lineColor); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + canvas.SetForegroundColor(lineColor); + canvas.SetLineWidth(__blockMargin); + + r = canvas.DrawLine(Point(__dividerMargin, __topMargin + __blockHeight), + Point(__dividerMargin + __dividerWidth, __topMargin + __blockHeight)); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = canvas.DrawLine(Point(__dividerMargin, __topMargin + __blockHeight * 2 + __blockMargin), + Point(__dividerMargin + __dividerWidth, __topMargin + __blockHeight * 2 + __blockMargin)); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + canvas.SetForegroundColor(foregroundColor); + + return r; +} + +result +_ColorPickerPresenter::DrawArrowButton(Canvas& canvas, const Rectangle& rcButton, bool isSelected, bool drawLeftButton) +{ + result r = E_SUCCESS; + + if (__pColorPicker->IsEnabled() == false) + { + r = DrawResourceBitmap(canvas, rcButton, __pColorDisabledEffectReplacementBgBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(canvas, rcButton, __pColorDisabledReplacementBgBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (drawLeftButton) + { + r = DrawResourceBitmap(canvas, rcButton, __pLeftArrowDisabledBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = DrawResourceBitmap(canvas, rcButton, __pRightArrowDisabledBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else if (isSelected) + { + r = DrawResourceBitmap(canvas, rcButton, __pColorPressedEffectReplacementBgBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(canvas, rcButton, __pColorPressedReplacementBgBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (drawLeftButton) + { + r = DrawResourceBitmap(canvas, rcButton, __pLeftArrowPressedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = DrawResourceBitmap(canvas, rcButton, __pRightArrowPressedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + r = DrawResourceBitmap(canvas, rcButton, __pColorNormalEffectReplacementBgBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(canvas, rcButton, __pColorNormalReplacementBgBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (drawLeftButton) + { + r = DrawResourceBitmap(canvas, rcButton, __pLeftArrowNormalBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = DrawResourceBitmap(canvas, rcButton, __pRightArrowNormalBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + return r; +} + +result +_ColorPickerPresenter::DrawArrowButtons(Canvas& canvas) +{ + DrawArrowButton(canvas, __componentBounds[HUE_ARROWLEFT], __eventType == HUE_ARROWLEFT, true); + DrawArrowButton(canvas, __componentBounds[HUE_ARROWRIGHT], __eventType == HUE_ARROWRIGHT, false); + DrawArrowButton(canvas, __componentBounds[SAT_ARROWLEFT], __eventType == SAT_ARROWLEFT, true); + DrawArrowButton(canvas, __componentBounds[SAT_ARROWRIGHT], __eventType == SAT_ARROWRIGHT, false); + DrawArrowButton(canvas, __componentBounds[LUM_ARROWLEFT], __eventType == LUM_ARROWLEFT, true); + DrawArrowButton(canvas, __componentBounds[LUM_ARROWRIGHT], __eventType == LUM_ARROWRIGHT, false); + + return E_SUCCESS; +} + +result +_ColorPickerPresenter::MoveHandler(_ColorPickerComponentType handlerType) +{ + _VisualElement* pHandler = null; + result r = E_SUCCESS; + + switch (handlerType) + { + case HUE_HANDLER: + pHandler = __pColorPicker->GetHueHandler(); + break; + case SAT_HANDLER: + pHandler = __pColorPicker->GetSaturationHandler(); + break; + case LUM_HANDLER: + pHandler = __pColorPicker->GetLuminanceHandler(); + break; + default: + r = E_INVALID_ARG; + break; + } + + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Handler event type is invalid."); + + SysTryReturnResult(NID_UI_CTRL, pHandler != null, E_SYSTEM, "A system error has occurred. Failed to get the handler."); + + Rectangle bounds = __pColorPicker->GetClientBounds(); + Rectangle& handlerBounds = __componentBounds[handlerType]; + pHandler->SetBounds(FloatRectangle(bounds.x + handlerBounds.x, bounds.y + handlerBounds.y, handlerBounds.width, handlerBounds.height)); + + return r; +} + +result +_ColorPickerPresenter::TouchButton(void) +{ + result r = E_SUCCESS; + + switch (__eventType) + { + case HUE_ARROWLEFT: + SetHandlerPosition(HUE_HANDLER, __componentBounds[HUE_HANDLER].x - ARROW_MOVE_STEP); + MoveHandler(HUE_HANDLER); + ChangeColorFromCurrentHandlerPosition(HUE_HANDLER); + break; + case HUE_ARROWRIGHT: + SetHandlerPosition(HUE_HANDLER, __componentBounds[HUE_HANDLER].x + ARROW_MOVE_STEP); + MoveHandler(HUE_HANDLER); + ChangeColorFromCurrentHandlerPosition(HUE_HANDLER); + break; + case SAT_ARROWLEFT: + SetHandlerPosition(SAT_HANDLER, __componentBounds[SAT_HANDLER].x - ARROW_MOVE_STEP); + MoveHandler(SAT_HANDLER); + ChangeColorFromCurrentHandlerPosition(SAT_HANDLER); + break; + case SAT_ARROWRIGHT: + SetHandlerPosition(SAT_HANDLER, __componentBounds[SAT_HANDLER].x + ARROW_MOVE_STEP); + MoveHandler(SAT_HANDLER); + ChangeColorFromCurrentHandlerPosition(SAT_HANDLER); + break; + case LUM_ARROWLEFT: + SetHandlerPosition(LUM_HANDLER, __componentBounds[LUM_HANDLER].x - ARROW_MOVE_STEP); + MoveHandler(LUM_HANDLER); + ChangeColorFromCurrentHandlerPosition(LUM_HANDLER); + break; + case LUM_ARROWRIGHT: + SetHandlerPosition(LUM_HANDLER, __componentBounds[LUM_HANDLER].x + ARROW_MOVE_STEP); + MoveHandler(LUM_HANDLER); + ChangeColorFromCurrentHandlerPosition(LUM_HANDLER); + break; + default: + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Arrow button type is invalid."); + r = E_INVALID_ARG; + break; + } + + return r; +} + +result +_ColorPickerPresenter::TouchHandler(int x) +{ + result r = E_SUCCESS; + + switch (__eventType) + { + case HUE_HANDLER: + // fall through + case SAT_HANDLER: + // fall through + case LUM_HANDLER: + SetHandlerPosition(__eventType, x - __componentBounds[__eventType].width / 2); + MoveHandler(__eventType); + ChangeColorFromCurrentHandlerPosition(__eventType); + break; + default: + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Handler event type is invalid."); + r = E_INVALID_ARG; + break; + } + + return r; +} + +result +_ColorPickerPresenter::SetHandlerPosition(_ColorPickerComponentType handlerType, int position) +{ + result r = E_SUCCESS; + + switch (handlerType) + { + case HUE_HANDLER: + // fall through + case SAT_HANDLER: + // fall through + case LUM_HANDLER: + { + Rectangle& barBounds = GetBarBoundsFromHandler(handlerType); + if (position < barBounds.x) + { + position = barBounds.x; + } + else if (position > (barBounds.x + barBounds.width - __componentBounds[handlerType].width)) + { + position = barBounds.x + barBounds.width - __componentBounds[handlerType].width; + } + + __componentBounds[handlerType].x = position; + } + break; + default: + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Handler event type is invalid."); + r = E_SYSTEM; + break; + } + + return r; +} + +result +_ColorPickerPresenter::SetHandlerPositionByRatio(_ColorPickerComponentType handlerType, double ratio) +{ + result r = E_SUCCESS; + Rectangle& barBounds = GetBarBoundsFromHandler(handlerType); + switch (handlerType) + { + case HUE_HANDLER: + __componentBounds[handlerType].x = barBounds.x + (barBounds.width - __componentBounds[handlerType].width) * ratio; + break; + + case SAT_HANDLER: + __componentBounds[handlerType].x = barBounds.x + (barBounds.width - __componentBounds[handlerType].width) * (MAX_VALUE - ratio); + break; + + case LUM_HANDLER: + + __componentBounds[handlerType].x = barBounds.x + (barBounds.width - __componentBounds[handlerType].width) * ratio; + break; + + default: + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Handler event type is invalid."); + r = E_SYSTEM; + break; + } + + return r; +} + +result +_ColorPickerPresenter::ChangeColorFromCurrentHandlerPosition(_ColorPickerComponentType handlerType) +{ + result r = E_SUCCESS; + _AccessibilityElement* pElement = null; + String value; + + switch (handlerType) + { + case HUE_HANDLER: + __pColorPickerModel->SetHue((double)(__componentBounds[HUE_HANDLER].x - __componentBounds[HUE_BAR].x) + / (double)(__componentBounds[HUE_BAR].width - __componentBounds[HUE_HANDLER].width)); + + pElement = __pColorPicker->GetAccessibilityElement(HUE_BAR); + value.Append(GetHue()); + break; + case SAT_HANDLER: + __pColorPickerModel->SetSaturation(MAX_VALUE - ((double)(__componentBounds[SAT_HANDLER].x - __componentBounds[SAT_BAR].x) + / (double)(__componentBounds[SAT_BAR].width - __componentBounds[SAT_HANDLER].width))); + + pElement = __pColorPicker->GetAccessibilityElement(SAT_BAR); + value.Append(GetSaturation()); + break; + case LUM_HANDLER: + __pColorPickerModel->SetLuminance((double)(__componentBounds[LUM_HANDLER].x - __componentBounds[LUM_BAR].x) + / (double)(__componentBounds[LUM_BAR].width - __componentBounds[LUM_HANDLER].width)); + + pElement = __pColorPicker->GetAccessibilityElement(LUM_BAR); + value.Append(GetLuminance()); + break; + default: + r = E_SYSTEM; + break; + } + + if (pElement != null) + { + pElement->SetValue(value); + } + + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Handler event type is invalid."); + + bool isHueChanged = __hueColor != __pColorPickerModel->GetHueColor(); + bool isSaturationChanged = __saturationColor != __pColorPickerModel->GetSaturationColor(); + if (isHueChanged == true || isSaturationChanged == true) + { + Canvas* pCanvas = __pColorPicker->GetCanvasN(); + if (pCanvas != null) + { + if (isHueChanged == true) + { + DrawSaturationSlider(*pCanvas); + } + if (isSaturationChanged == true) + { + DrawLuminanceSlider(*pCanvas); + } + delete pCanvas; + + __pColorPicker->UpdateView(); + } + } + + return __pColorPicker->FireColorChangeEvent(__pColorPickerModel->GetColor()); +} + +bool +_ColorPickerPresenter::IsLeftButton(_ColorPickerComponentType buttonType) +{ + return (buttonType == HUE_ARROWLEFT || buttonType == SAT_ARROWLEFT || buttonType == LUM_ARROWLEFT); +} + +Rectangle& +_ColorPickerPresenter::GetBarBoundsFromHandler(_ColorPickerComponentType handlerType) +{ + if (handlerType == HUE_HANDLER) + { + return __componentBounds[HUE_BAR]; + } + else if (handlerType == SAT_HANDLER) + { + return __componentBounds[SAT_BAR]; + } + else if (handlerType == LUM_HANDLER) + { + return __componentBounds[LUM_BAR]; + } + + return __componentBounds[HSL_NOT]; +} + +_ColorPickerComponentType +_ColorPickerPresenter::GetTouchActionType(const Point& position) const +{ + if (__componentBounds[HUE_BAR].Contains(position) == true) + { + return HUE_HANDLER; + } + else if (__componentBounds[SAT_BAR].Contains(position) == true) + { + return SAT_HANDLER; + } + else if (__componentBounds[LUM_BAR].Contains(position) == true) + { + return LUM_HANDLER; + } + + for (int type = HUE_ARROWLEFT; type < COMPONENT_TYPE_MAX; type++) + { + if (__componentBounds[type].Contains(position) == true) + { + return (_ColorPickerComponentType)type; + } + } + + return HSL_NOT; +} + +result +_ColorPickerPresenter::DrawResourceBitmap(Canvas& canvas, const Rectangle& bounds, Bitmap* pBitmap) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, pBitmap != null, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Provided bitmap is null."); + + if (pBitmap->IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = canvas.DrawBitmap(bounds, *pBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + return r; +} +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ContextMenu.cpp b/src/ui/controls/FUiCtrl_ContextMenu.cpp new file mode 100644 index 0000000..091b5ea --- /dev/null +++ b/src/ui/controls/FUiCtrl_ContextMenu.cpp @@ -0,0 +1,1230 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ContextMenu.cpp + * @brief This is the implementation file for the _ContextMenu class. + */ + +#include +#include +#include +#include +#include "FUi_ControlImplManager.h" +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiAnim_AnimationManager.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_ContextMenu.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_ContextMenu); + +_ContextMenu::_ContextMenu(const Point& point, enum ContextMenuCoreStyle style, enum ContextMenuCoreAlign contextMenuAlign) + : __pContextMenuPresenter(null) + , __style(style) + , __align(contextMenuAlign) + , __showItemCount(MAX_CONTEXTMENU_LIST_SHOW_ITEM) + , __showItemMaxCount(0) + , __isAttachedToMainTree(false) + , __ownerInputEnableState(false) + , __anchorPoint(point) + , __bodyRect(Rectangle(0, 0, 0, 0)) + , __arrowRect(Rectangle(0, 0, 0, 0)) + , __windowRect(Rectangle(0, 0, 0, 0)) + , __pActionEvent(null) + , __pBackgroundNormalBitmap(null) + , __pBackgroundEffectBitmap(null) + , __dropPosition(CONTEXT_MENU_CORE_DROP_POSITION_INVALID) + , __layout(_CONTROL_ORIENTATION_PORTRAIT) + , __pScrollPanel(null) +{ + __backgroundColor = Color(255, 255, 255, 255); + + __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = Color(255, 255, 255, 255); + __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = Color(255, 255, 255, 255); + __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = Color(255, 255, 255, 255); + + __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = Color(255, 255, 255, 255); + __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = Color(255, 255, 255, 255); + __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = Color(255, 255, 255, 255); + + for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++) + { + __pArrowNormalBitmap[i] = null; + __pArrowEffectBitmap[i] = null; + } +} + +_ContextMenu::~_ContextMenu(void) +{ + _Control* pOwner = GetOwner(); + if (__isAttachedToMainTree == true && pOwner != null) + { + pOwner->SetInputEnableState(__ownerInputEnableState); + } + + if (__pScrollPanel) { + __pScrollPanel->DetachAllChildren(); + DetachChild(*__pScrollPanel); + delete __pScrollPanel; + __pScrollPanel = null; + } + + delete __pContextMenuPresenter; + __pContextMenuPresenter = null; + + if (__pBackgroundNormalBitmap != null) + { + delete __pBackgroundNormalBitmap; + __pBackgroundNormalBitmap = null; + } + + if (__pBackgroundEffectBitmap != null) + { + delete __pBackgroundEffectBitmap; + __pBackgroundEffectBitmap = null; + } + + if (__pActionEvent) + { + delete __pActionEvent; + __pActionEvent = null; + } + + for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++) + { + delete __pArrowNormalBitmap[i]; + __pArrowNormalBitmap[i] = null; + + delete __pArrowEffectBitmap[i]; + __pArrowEffectBitmap[i] = null; + } + + __actionId.RemoveAll(); + + RemoveAllAccessibilityElement(); +} + + +bool +_ContextMenu::IsActivatedOnOpen(void) const +{ + return false; +} + +_ContextMenu* +_ContextMenu::CreateContextMenuN(const Point& point, enum ContextMenuCoreStyle style, enum ContextMenuCoreAlign contextMenuAlign) +{ + _ContextMenu* pContextMenu = new (std::nothrow) _ContextMenu(point, style, contextMenuAlign); + SysTryReturn(NID_UI_CTRL, pContextMenu != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = E_SUCCESS; + +#if defined(MULTI_WINDOW) + r = pContextMenu->CreateRootVisualElement(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pContextMenu->SetActivationEnabled(false); +#endif + + r = pContextMenu->Initialize(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Initialize.", GetErrorMessage(r)); + + r = pContextMenu->Install(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Install.", GetErrorMessage(r)); + + pContextMenu->AcquireHandle(); + + if (pContextMenu->GetAccessibilityContainer() != null) + { + pContextMenu->GetAccessibilityContainer()->Activate(true); + } + + if (style == CONTEXT_MENU_CORE_STYLE_LIST) + { + int minWidth, minHeight; // for visible scrollbar when scrollable + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MIN_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, minWidth); + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, minHeight); + pContextMenu->__pScrollPanel = _ScrollPanel::CreateScrollPanelN(Rectangle(0, 0, minWidth, minHeight), SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, false, false); + pContextMenu->AttachChild(*(pContextMenu->__pScrollPanel)); + } + + return pContextMenu; + +CATCH: + delete pContextMenu; + + return null; +} + +_ScrollPanel* +_ContextMenu::GetScrollPanel(void) +{ + return __pScrollPanel; +} + +result +_ContextMenu::Install(void) +{ + result r = E_SUCCESS; + + // load bitmap of a background and arrow + r = LoadBitmap(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to load bitmap."); + + r = __actionId.Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to construct arraylist."); + + if (__style == CONTEXT_MENU_CORE_STYLE_LIST) + { + _IContextMenuPresenter* pPresenter = new (std::nothrow) _ContextMenuListPresenter(this); + SysTryReturnResult(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + SetPresenter(*pPresenter); + + r = pPresenter->Install(); + } + else + { + _IContextMenuPresenter* pPresenter = new (std::nothrow) _ContextMenuGridPresenter(this); + SysTryReturnResult(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + SetPresenter(*pPresenter); + + r = pPresenter->Install(); + } + + return r; +} + +result +_ContextMenu::Initialize(void) +{ + Dimension screen = _ControlManager::GetInstance()->GetScreenSize(); + result r = E_SUCCESS; + + Color backgroundColor; + Color backgroundSelectedColor; + Color itemTextColor; + Color itemTextSelectedColor; + + r = SetBounds(Rectangle(0, 0, screen.width, screen.height)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "SetBounds failed."); + + SetMovable(false); // To do Modify + SetResizable(false); // To do Modify + + GET_COLOR_CONFIG(CONTEXTMENU::BG_NORMAL, backgroundColor); + GET_COLOR_CONFIG(CONTEXTMENU::ITEM_BG_PRESSED, backgroundSelectedColor); + GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_NORMAL, itemTextColor); + GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_PRESSED, itemTextSelectedColor); + + __backgroundColor = backgroundColor; + __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = backgroundColor; + __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = backgroundSelectedColor; + __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = itemTextColor; + __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = itemTextSelectedColor; + + if (GetVisualElement() != null) + { + GetVisualElement()->SetSurfaceOpaque(false); + } + + return r; + +} + +result +_ContextMenu::SetPresenter(const _IContextMenuPresenter& ContextMenuPresenter) +{ + __pContextMenuPresenter = const_cast <_IContextMenuPresenter*>(&ContextMenuPresenter); + + return E_SUCCESS; +} + +void +_ContextMenu::OnDraw() +{ + __pContextMenuPresenter->Draw(); +} + +result +_ContextMenu::OnAttachedToMainTree(void) +{ + result r = E_SUCCESS; + + if (GetOwner() == null) + { + _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Current frame instance is not available."); + + _Form* pForm = pFrame->GetCurrentForm(); + if (pForm != null) + { + SetOwner(pForm); + } + else + { + SetOwner(pFrame); + } + } + + _Control* pOwner = GetOwner(); + if (pOwner != null && __isAttachedToMainTree == false) + { + __ownerInputEnableState = pOwner->GetInputEnableState(); + pOwner->SetInputEnableState(false); + } + + __layout = _ControlManager::GetInstance()->GetOrientation(); + AdjustDropPosition(); + GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, __layout, __showItemMaxCount); + + if (GetItemCount() <= 0) + { + __pContextMenuPresenter->CalculateShowItemCount(); + } + + __pContextMenuPresenter->CalculateWindowRect(); + + r = Open(); + + SetVisibleState(true); + + if (__style == CONTEXT_MENU_CORE_STYLE_LIST) + { + SetTouchCapture(); + } + else + { + SetTouchCapture(true); + } + + SetAllAccessibilityElement(); + + __isAttachedToMainTree = true; + + return r; +} + +result +_ContextMenu::OnDetachingFromMainTree(void) +{ + result r = E_SUCCESS; + + ReleaseTouchCapture(); + + _Control* pOwner = GetOwner(); + if (pOwner != null) + { + pOwner->SetInputEnableState(__ownerInputEnableState); + } + + __isAttachedToMainTree = false; + + return r; +} + +result +_ContextMenu::AddItem(const Base::String& text, int actionId, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap, + const Bitmap* pHighlightedBitmap) +{ + result r = E_SUCCESS; + + r = __pContextMenuPresenter->AddItem(text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to add a item."); + + __actionId.Add(actionId); + + __pContextMenuPresenter->CalculateShowItemCount(); + __pContextMenuPresenter->CalculateWindowRect(); + + return r; +} + +result +_ContextMenu::InsertItem(int index, const Base::String& text, int actionId, const Bitmap* pNormalBitmap, + const Bitmap* pPressedBitmap, + const Bitmap* pHighlightedBitmap) +{ + result r = E_SUCCESS; + + r = __pContextMenuPresenter->InsertItem(index, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to insert a item."); + + __actionId.InsertAt(actionId, index); + + __pContextMenuPresenter->CalculateShowItemCount(); + __pContextMenuPresenter->CalculateWindowRect(); + + return r; +} + +result +_ContextMenu::SetItem(int index, const Base::String& text, int actionId, const Bitmap* pNormalBitmap, + const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) +{ + result r = E_SUCCESS; + + r = __pContextMenuPresenter->SetItem(index, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to set a item."); + + __actionId.SetAt(actionId, index); + + __pContextMenuPresenter->CalculateWindowRect(); + + return r; +} + +result +_ContextMenu::RemoveItemAt(int index) +{ + result r = E_SUCCESS; + + r = __pContextMenuPresenter->DeleteItem(index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove a item."); + + __actionId.RemoveAt(index); + + __pContextMenuPresenter->CalculateShowItemCount(); + __pContextMenuPresenter->CalculateWindowRect(); + + return r; +} + +result +_ContextMenu::RemoveAllItems(void) +{ + result r = E_SUCCESS; + + r = __pContextMenuPresenter->DeleteItemAll(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove all items."); + + __actionId.RemoveAll(); + + __pContextMenuPresenter->CalculateShowItemCount(); + __pContextMenuPresenter->CalculateWindowRect(); + + return r; +} + +int +_ContextMenu::GetItemCount(void) const +{ + return __actionId.GetCount(); +} + +int +_ContextMenu::GetItemIndexAt(int actionId) const +{ + int count = __actionId.GetCount(); + + for (int i = 0; i < count; i++) + { + int index = GetItemActionIdAt(i); + + if (actionId == index) + { + return i; + } + } + + return -1; +} + +int +_ContextMenu::GetItemActionIdAt(int index) const +{ + int count = __actionId.GetCount(); + int actionId = -1; + + if (count <= 0 || index >= count) + { + return -1; + } + + __actionId.GetAt(index, actionId); + + return actionId; +} + +result +_ContextMenu::SetAnchorPosition(int x, int y) +{ + __anchorPoint.x = x; + __anchorPoint.y = y; + + if (__align == CONTEXT_MENU_CORE_ALIGN_AUTO) + { + AdjustDropPosition(); + } + + __pContextMenuPresenter->CalculateWindowRect(); + return E_SUCCESS; +} + +Point +_ContextMenu::GetAnchorPosition(void) const +{ + return __anchorPoint; +} + +result +_ContextMenu::SetBodyRect(const Rectangle& rect) +{ + __bodyRect = rect; + + return E_SUCCESS; +} + +Rectangle +_ContextMenu::GetBodyRect(void) const +{ + return __bodyRect; +} + +result +_ContextMenu::SetArrowRect(const Rectangle& rect) +{ + __arrowRect = rect; + + return E_SUCCESS; +} + +Rectangle +_ContextMenu::GetArrowRect(void) const +{ + return __arrowRect; +} + +result +_ContextMenu::SetWindowRect(const Rectangle& rect) +{ + __windowRect = rect; + + return E_SUCCESS; +} + +Rectangle +_ContextMenu::GetWindowRect(void) const +{ + return __windowRect; +} + +result +_ContextMenu::SetPropertyMaxVisibleItemsCount(const Variant& count) +{ + int showCount = count.ToInt(); + + if (showCount < 1) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "Count is invalid."); + return E_INVALID_ARG; + } + + + __showItemCount = showCount; + + return E_SUCCESS; +} + +Variant +_ContextMenu::GetPropertyMaxVisibleItemsCount(void) const +{ + return Tizen::Ui::Variant(__showItemCount); +} + +int +_ContextMenu::GetShowItemCount(void) const +{ + Variant count = GetProperty("maxVisibleItemsCount"); + + return count.ToInt(); +} + +int +_ContextMenu::GetShowItemMaxCount(void) const +{ + return __showItemMaxCount; +} + +result +_ContextMenu::SetShowItemCount(int count) +{ + result r; + + r = SetProperty("maxVisibleItemsCount", Variant(count)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to set property."); + + if (__style == CONTEXT_MENU_CORE_STYLE_LIST) + { + r = __pContextMenuPresenter->CalculateWindowRect(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to calculate window."); + } + + return E_SUCCESS; +} + +result +_ContextMenu::SetPropertyColor(const Variant& color) +{ + __backgroundColor = color.ToColor(); + + LoadColorReplacedBitmap(__backgroundColor); + + return E_SUCCESS; +} + +Variant +_ContextMenu::GetPropertyColor(void) const +{ + return Tizen::Ui::Variant(__backgroundColor); +} + +result +_ContextMenu::SetColor(const Graphics::Color& color) +{ + return SetProperty("color", Variant(color)); +} + +Color +_ContextMenu::GetColor(void) const +{ + Variant color = GetProperty("color"); + + return color.ToColor(); +} + +result +_ContextMenu::SetPropertyNormalItemColor(const Variant& color) +{ + __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = color.ToColor(); + + return __pContextMenuPresenter->ApplyColorProperty(); +} + +Variant +_ContextMenu::GetPropertyNormalItemColor(void) const +{ + return Tizen::Ui::Variant(__itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL]); +} + +result +_ContextMenu::SetPropertyPressedItemColor(const Variant& color) +{ + __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = color.ToColor(); + + return __pContextMenuPresenter->ApplyColorProperty(); +} + +Variant +_ContextMenu::GetPropertyPressedItemColor(void) const +{ + return Tizen::Ui::Variant(__itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED]); +} + +result +_ContextMenu::SetPropertyHighlightedItemColor(const Variant & color) +{ + __itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = color.ToColor(); + + return __pContextMenuPresenter->ApplyColorProperty(); +} + +Variant +_ContextMenu::GetPropertyHighlightedItemColor(void) const +{ + return Tizen::Ui::Variant(__itemColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED]); +} + +result +_ContextMenu::SetItemColor(enum ContextMenuCoreItemStatus status, const Graphics::Color& color) +{ + result r = E_SUCCESS; + + if (status == CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL) + { + r = SetProperty("normalItemColor", Variant(color)); + } + else if (status == CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED) + { + r = SetProperty("pressedItemColor", Variant(color)); + } + else + { + r = SetProperty("highlightedItemColor", Variant(color)); + } + + return r; +} + +Color +_ContextMenu::GetItemColor(enum ContextMenuCoreItemStatus status) const +{ + Color itemColor; + + if (status == CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL) + { + Variant color = GetProperty("normalItemColor"); + itemColor = color.ToColor(); + + } + else if (status == CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED) + { + Variant color = GetProperty("pressedItemColor"); + itemColor = color.ToColor(); + + } + else + { + Variant color = GetProperty("highlightedItemColor"); + itemColor = color.ToColor(); + } + + return itemColor; + +} + +result +_ContextMenu::SetPropertyNormalItemTextColor(const Variant& color) +{ + __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL] = color.ToColor(); + + return __pContextMenuPresenter->ApplyColorProperty(); +} + +Variant +_ContextMenu::GetPropertyNormalItemTextColor(void) const +{ + return Tizen::Ui::Variant(__textColor[CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL]); +} + +result +_ContextMenu::SetPropertyPressedItemTextColor(const Variant& color) +{ + __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED] = color.ToColor(); + + return __pContextMenuPresenter->ApplyColorProperty(); +} + +Variant +_ContextMenu::GetPropertyPressedItemTextColor(void) const +{ + return Tizen::Ui::Variant(__textColor[CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED]); +} + +result +_ContextMenu::SetPropertyHighlightedItemTextColor(const Variant & color) +{ + __textColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = color.ToColor(); + + return __pContextMenuPresenter->ApplyColorProperty(); +} + +Variant +_ContextMenu::GetPropertyHighlightedItemTextColor(void) const +{ + return Tizen::Ui::Variant(__textColor[CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED]); +} + +result +_ContextMenu::SetTextColor(enum ContextMenuCoreItemStatus status, const Graphics::Color& color) +{ + result r = E_SUCCESS; + + if (status == CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL) + { + r = SetProperty("normalItemTextColor", Variant(color)); + } + else if (status == CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED) + { + r = SetProperty("pressedItemTextColor", Variant(color)); + } + else + { + r = SetProperty("highlightedItemTextColor", Variant(color)); + } + + return r; + +} + +Color +_ContextMenu::GetTextColor(enum ContextMenuCoreItemStatus status) const +{ + Color textColor; + + if (status == CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL) + { + Variant color = GetProperty("normalItemTextColor"); + textColor = color.ToColor(); + + } + else if (status == CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED) + { + Variant color = GetProperty("pressedItemTextColor"); + textColor = color.ToColor(); + + } + else + { + Variant color = GetProperty("highlightedItemTextColor"); + textColor = color.ToColor(); + } + + return textColor; +} + +result +_ContextMenu::AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pActionEvent == null) + { + __pActionEvent = _ActionEvent::CreateInstanceN(*this); + SysTryReturn(NID_UI_CTRL, __pActionEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient.") + + r = __pActionEvent->AddListener(listener); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to remove an action event listener.") + } + + return r; + +CATCH: + delete __pActionEvent; + __pActionEvent = null; + return r; +} + +result +_ContextMenu::RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pActionEvent != null, E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] The action event instance isn't constructed.") + + result r = E_SUCCESS; + + r = __pActionEvent->RemoveListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove an action event listener") + + return r; +} + +Tizen::Ui::Controls::_ActionEvent* +_ContextMenu::GetActionEvent(void) const +{ + return __pActionEvent; +} + +result +_ContextMenu::LoadBitmap(void) +{ + Color backgroundColor; + + // Delete old bitmap + if (__pBackgroundEffectBitmap != null) + { + delete __pBackgroundEffectBitmap; + __pBackgroundEffectBitmap = null; + } + + for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++) + { + if (__pArrowEffectBitmap[i] != null) + { + delete __pArrowEffectBitmap[i]; + __pArrowEffectBitmap[i] = null; + } + } + + backgroundColor = GetColor(); + + + result r; + r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_EFFECT_UP, BITMAP_PIXEL_FORMAT_ARGB8888, + __pArrowEffectBitmap[CONTEXT_MENU_CORE_DROP_POSITION_UP]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + + r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_EFFECT_DOWN, BITMAP_PIXEL_FORMAT_ARGB8888, + __pArrowEffectBitmap[CONTEXT_MENU_CORE_DROP_POSITION_DOWN]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + + r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_EFFECT_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888, + __pArrowEffectBitmap[CONTEXT_MENU_CORE_DROP_POSITION_LEFT]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + + r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_EFFECT_RIGHT, BITMAP_PIXEL_FORMAT_ARGB8888, + __pArrowEffectBitmap[CONTEXT_MENU_CORE_DROP_POSITION_RIGHT]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + + r = GET_BITMAP_CONFIG_N(CONTEXTMENU::BG_OUTLINE_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + + r = LoadColorReplacedBitmap(backgroundColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + + return r; + +CATCH: + delete __pBackgroundEffectBitmap; + __pBackgroundEffectBitmap = null; + + for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++) + { + + delete __pArrowEffectBitmap[i]; + __pArrowEffectBitmap[i] = null; + } + + return r; +} + +result +_ContextMenu::LoadColorReplacedBitmap(const Tizen::Graphics::Color& color) +{ + Bitmap* ptempNormalBitmap = null; + + // Delete old bitmap + if (__pBackgroundNormalBitmap != null) + { + delete __pBackgroundNormalBitmap; + __pBackgroundNormalBitmap = null; + } + + for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++) + { + if (__pArrowNormalBitmap[i] != null) + { + delete __pArrowNormalBitmap[i]; + __pArrowNormalBitmap[i] = null; + } + } + + result r; + r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_NORMAL_UP, BITMAP_PIXEL_FORMAT_ARGB8888, ptempNormalBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_UP] = _BitmapImpl::GetColorReplacedBitmapN(*ptempNormalBitmap, + Color::GetColor(COLOR_ID_MAGENTA), color); + SysTryCatch(NID_UI_CTRL, __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_UP] != null, , GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + delete ptempNormalBitmap; + ptempNormalBitmap = null; + + r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_NORMAL_DOWN, BITMAP_PIXEL_FORMAT_ARGB8888, ptempNormalBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_DOWN] = _BitmapImpl::GetColorReplacedBitmapN(*ptempNormalBitmap, + Color::GetColor(COLOR_ID_MAGENTA), color); + SysTryCatch(NID_UI_CTRL, __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_DOWN] != null, , GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + delete ptempNormalBitmap; + ptempNormalBitmap = null; + + r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_NORMAL_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888, ptempNormalBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_LEFT] = _BitmapImpl::GetColorReplacedBitmapN(*ptempNormalBitmap, + Color::GetColor(COLOR_ID_MAGENTA), color); + SysTryCatch(NID_UI_CTRL, __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_LEFT] != null, , GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + delete ptempNormalBitmap; + ptempNormalBitmap = null; + + r = GET_BITMAP_CONFIG_N(CONTEXTMENU::ANCHOR_NORMAL_RIGHT, BITMAP_PIXEL_FORMAT_ARGB8888, ptempNormalBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_RIGHT] = _BitmapImpl::GetColorReplacedBitmapN(*ptempNormalBitmap, + Color::GetColor(COLOR_ID_MAGENTA), color); + SysTryCatch(NID_UI_CTRL, __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_RIGHT] != null, , GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + delete ptempNormalBitmap; + ptempNormalBitmap = null; + + r = GET_BITMAP_CONFIG_N(CONTEXTMENU::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, ptempNormalBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + __pBackgroundNormalBitmap = _BitmapImpl::GetColorReplacedBitmapN(*ptempNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), color); + SysTryCatch(NID_UI_CTRL, __pBackgroundNormalBitmap != null, , GetLastResult(), "[%s] Propagating.", + GetErrorMessage(GetLastResult())); + delete ptempNormalBitmap; + + return r; + +CATCH: + delete ptempNormalBitmap; + + delete __pBackgroundNormalBitmap; + __pBackgroundNormalBitmap = null; + + for (int i = 0; i < CONTEXT_MENU_CORE_DROP_POSITION_MAX; i++) + { + delete __pArrowNormalBitmap[i]; + __pArrowNormalBitmap[i] = null; + } + + return r; +} + +const Bitmap* +_ContextMenu::GetArrowNormalBitmap(ContextMenuCoreDropPosition dropPosition) const +{ + if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_INVALID || dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_MAX) + { + return null; + } + + return __pArrowNormalBitmap[dropPosition]; +} + +const Bitmap* +_ContextMenu::GetArrowEffectBitmap(ContextMenuCoreDropPosition dropPosition) const +{ + if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_INVALID || dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_MAX) + { + return null; + } + + return __pArrowEffectBitmap[dropPosition]; +} + +const Bitmap* +_ContextMenu::GetBackgroundNormalBitmap(void) const +{ + return __pBackgroundNormalBitmap; +} + +const Bitmap* +_ContextMenu::GetBackgroundEffectBitmap(void) const +{ + return __pBackgroundEffectBitmap; +} + +enum ContextMenuCoreDropPosition +_ContextMenu::GetDropPosition(void) const +{ + return __dropPosition; +} + +void +_ContextMenu::AdjustDropPosition(void) +{ + Dimension screen = _ControlManager::GetInstance()->GetScreenSize(); + + if (__align == CONTEXT_MENU_CORE_ALIGN_UP) + { + __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_UP; + } + else if (__align == CONTEXT_MENU_CORE_ALIGN_DOWN) + { + __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_DOWN; + } + else if (__align == CONTEXT_MENU_CORE_ALIGN_LEFT) + { + __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_LEFT; + } + else if (__align == CONTEXT_MENU_CORE_ALIGN_RIGHT) + { + __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_RIGHT; + } + else + { + if (__layout == _CONTROL_ORIENTATION_LANDSCAPE) + { + screen.SetSize(screen.height, screen.width); + } + + if (screen.height > screen.width) + { + if ((screen.height / 2) > __anchorPoint.y) + { + __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_DOWN; + } + else + { + __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_UP; + } + } + else + { + if ((screen.width / 2) > __anchorPoint.x) + { + __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_RIGHT; + } + else + { + __dropPosition = CONTEXT_MENU_CORE_DROP_POSITION_LEFT; + } + } + } +} + +_UiTouchEventDelivery +_ContextMenu::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pContextMenuPresenter->OnPreviewTouchPressed(source, touchinfo); +} + +bool +_ContextMenu::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pContextMenuPresenter->OnTouchPressed(source, touchinfo); +} + +_UiTouchEventDelivery +_ContextMenu::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pContextMenuPresenter->OnPreviewTouchMoved(source, touchinfo); +} + +bool +_ContextMenu::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pContextMenuPresenter->OnTouchMoved(source, touchinfo); +} + +_UiTouchEventDelivery +_ContextMenu::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pContextMenuPresenter->OnPreviewTouchReleased(source, touchinfo); +} + +bool +_ContextMenu::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pContextMenuPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_ContextMenu::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + __pContextMenuPresenter->OnTouchCanceled(source, touchinfo); + + SetVisibleState(false); + + return true; +} + +void +_ContextMenu::OnFontChanged(Tizen::Graphics::Font* pFont) +{ + return __pContextMenuPresenter->OnFontChanged(pFont); +} + +void +_ContextMenu::OnFontInfoRequested(unsigned long& style, int& size) +{ + return __pContextMenuPresenter->OnFontInfoRequested(style, size); +} + +void +_ContextMenu::OnVisibleStateChanged(void) +{ +#if defined(MULTI_WINDOW) + _Window::OnVisibleStateChanged(); +#endif +} + +void +_ContextMenu::OnChangeLayout(_ControlOrientation orientation) +{ + GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, orientation, __showItemMaxCount); + + if (__isAttachedToMainTree == true) + { + if (__layout != orientation) + { + SetVisibleState(false); + } + } + + __layout = orientation; +} + +_AccessibilityElement* +_ContextMenu::GetAccessibilityElement(const int mainIndex) const +{ + _AccessibilityElement* pElement = null; + result r = __accessibilityElements.GetAt(mainIndex, pElement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed at AccessibilityElement.", GetErrorMessage(r)); + + return pElement; + +CATCH: + delete pElement; + + return null; +} + +void +_ContextMenu::AddAccessibilityElement(const _AccessibilityElement& element) +{ + __accessibilityElements.Add(const_cast<_AccessibilityElement*>(&element)); +} + +void +_ContextMenu::SetAllAccessibilityElement(void) +{ + RemoveAllAccessibilityElement(); + __pContextMenuPresenter->SetAllAccessibilityElement(); +} + +void +_ContextMenu::RemoveAllAccessibilityElement(void) +{ + while (__accessibilityElements.GetCount() > 0) + { + _AccessibilityElement* pElement = null; + if (__accessibilityElements.GetAt(0, pElement) == E_SUCCESS) + { + __accessibilityElements.RemoveAt(0); + pElement->GetParent()->RemoveElement(*pElement); + } + } +} + +_ContextMenuItemInfo +_ContextMenu::GetItemFromPosition(const Point& position) const +{ + return __pContextMenuPresenter->GetItemFromPosition(position); +} + +_ContextMenuItemInfo +_ContextMenu::FindItem(int index) const +{ + return __pContextMenuPresenter->FindItem(index); +} + +result +_ContextMenu::SetTopDrawnItemIndex(int index) +{ + return __pContextMenuPresenter->SetTopDrawnItemIndex(index); +} + +_ControlOrientation +_ContextMenu::GetLayout(void) const +{ + return __layout; +} + +}}} // Tizen::Ui: Control diff --git a/src/ui/controls/FUiCtrl_ContextMenuGridPresenter.cpp b/src/ui/controls/FUiCtrl_ContextMenuGridPresenter.cpp new file mode 100644 index 0000000..cc6a05d --- /dev/null +++ b/src/ui/controls/FUiCtrl_ContextMenuGridPresenter.cpp @@ -0,0 +1,1559 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ContextMenuGridPresenter.cpp + * @brief This is the implementation file for the _ContextMenuGridPresenter class. + */ + +#include +#include +#include +#include +#include "FUiCtrl_ContextMenuGridPresenter.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_ActionEvent.h" +#include "FUi_ResourceManager.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics::_Text; + +static const int MAX_COUNT_PER_LINE = 5; +static const int MIN_COUNT_PER_LINE = 3; +static const int MAX_LINE_COUNT = 32; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ContextMenuGridPresenter::_ContextMenuGridPresenter(_ContextMenu* pContextMenu) + : __pContextMenu(pContextMenu) + , __pModel(null) + , __pTextObject(null) + , __pFont(null) + , __layoutSize(Dimension(0, 0)) + , __touchOutRect(false) + , __selectedIndex(-1) + , __pressedIndex(-1) + , __maxWidth(0) + , __minWidth(0) + , __topMargin(0) + , __bottomMargin(0) + , __leftMargin(0) + , __rightMargin(0) + , __screenTopMargin(0) + , __screenBottomMargin(0) + , __screenLeftMargin(0) + , __screenRightMargin(0) + , __arrowMargin(0) + , __arrowWidth(0) + , __arrowHeight(0) + , __itemWidth(0) + , __itemHeight(0) + , __itemMaxWidth(0) + , __itemTextMargin(0) + , __itemGap(0) + , __itemBitmapWidth(0) + , __itemBitmapHeight(0) + , __itemFontSize(0) + , __dividerHeight(0) +{ + +} + +_ContextMenuGridPresenter::~_ContextMenuGridPresenter(void) +{ + __pContextMenu = null; + + delete __pModel; + __pModel = null; + + if (__pTextObject) + { + __pTextObject->RemoveAll(); + delete __pTextObject; + __pTextObject = null; + } + + __pFont = null; + +} + +result +_ContextMenuGridPresenter::Install(void) +{ + result r = E_SUCCESS; + + LoadShape(); + + __pModel = new (std::nothrow) _ContextMenuModel; + SysTryCatch(NID_UI_CTRL, __pModel != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + r = __pModel->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create data instance."); + + __pFont = __pContextMenu->GetFallbackFont(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (__pFont != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTextObject = new (std::nothrow) TextObject(); + SysTryCatch(NID_UI_CTRL, __pTextObject, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create data instance."); + + __pTextObject->Construct(); + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + + return r; + +CATCH: + delete __pModel; + __pModel = null; + + __pFont = null; + + delete __pTextObject; + __pTextObject = null; + + return r; +} + + +void +_ContextMenuGridPresenter::LoadShape(void) +{ + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemWidth); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_MAX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemMaxWidth); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemHeight); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_TEXT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __itemTextMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_GAP, _CONTROL_ORIENTATION_PORTRAIT, __itemGap); + + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_MIN_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __minWidth); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __topMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __bottomMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __leftMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __rightMargin); + + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __itemFontSize); + GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenTopMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenBottomMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenLeftMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenRightMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __arrowWidth); + GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __arrowHeight); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ICON_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapWidth); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ICON_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapHeight); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __dividerHeight); +} + +_ContextMenuItem* +_ContextMenuGridPresenter::CreateItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + _ContextMenuItem* pItem = _ContextMenuItem::CreateContextMenuItemN(); + SysTryReturn(NID_UI_CTRL, pItem != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + ContextMenuItemDrawingType itemType = CONTEXT_MENU_ITEM_DRAWING_TYPE_NONE; + result r = E_SUCCESS; + + if (text.GetLength() != 0) + { + r = pItem->SetText(text); + if (r != E_SUCCESS) + { + delete pItem; + return null; + } + + itemType = CONTEXT_MENU_ITEM_DRAWING_TYPE_TEXT; + } + else + { + if (pNormalBitmap == null && pPressedBitmap == null) + { + delete pItem; + return null; + } + + if (pNormalBitmap != null) + { + r = pItem->SetBitmap(CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL, pNormalBitmap); + if (r != E_SUCCESS) + { + delete pItem; + return null; + } + } + + if (pPressedBitmap != null) + { + r = pItem->SetBitmap(CONTEXT_MENU_ITEM_DRAWING_STATUS_PRESSED, pPressedBitmap); + if (r != E_SUCCESS) + { + delete pItem; + return null; + } + } + + itemType = CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP; + } + + pItem->SetType(itemType); + pItem->SetActionId(actionId); + + // calculate item size + SetItemSize(pItem); + + return pItem; +} + +result +_ContextMenuGridPresenter::AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, + const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + _ContextMenuItem* pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient."); + + result r = __pModel->AddItem(pItem); + + if (r != E_SUCCESS) + { + delete pItem; + SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item."); + } + + + return r; +} + +result +_ContextMenuGridPresenter::InsertItem(int index, const Tizen::Base::String& text, int actionId, + const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + if (text.GetLength() == 0 && normalBitmap == null && pPressedBitmap == null) + { + return E_INVALID_ARG; + } + + _ContextMenuItem* pItem = null; + + pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient."); + + result r = __pModel->InsertItem(pItem, index); + if (r != E_SUCCESS) + { + delete pItem; + SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item."); + } + + return E_SUCCESS; +} + +result +_ContextMenuGridPresenter::SetItem(int index, const Tizen::Base::String& text, int actionId, + const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + if (text.GetLength() == 0 && normalBitmap == null && pPressedBitmap == null) + { + return E_INVALID_ARG; + } + + _ContextMenuItem* pItem = null; + pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient."); + + result r = __pModel->SetItem(pItem, index); + if (r != E_SUCCESS) + { + delete pItem; + SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item."); + } + + return E_SUCCESS; +} + +result +_ContextMenuGridPresenter::DeleteItem(int index) +{ + int itemCount = __pContextMenu->GetItemCount(); + + if (itemCount <= 0 || index >= itemCount || index < 0) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "Invalid argument."); + return E_INVALID_STATE; + } + + result r = __pModel->RemoveItem(index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to delete item."); + + return r; +} + +result +_ContextMenuGridPresenter::DeleteItemAll(void) +{ + int itemCount = __pContextMenu->GetItemCount(); + + if (itemCount <= 0) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "Invalid argument."); + return E_INVALID_STATE; + } + + result r = __pModel->RemoveAllItem(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to delete item all."); + + return r; +} + + +int +_ContextMenuGridPresenter::CalculateShowItemCount(void) +{ + return __pContextMenu->GetShowItemCount(); +} + +void +_ContextMenuGridPresenter::SetItemSize(_ContextMenuItem* pItem) +{ + ContextMenuItemDrawingType itemType = pItem->GetType(); + + if (itemType == CONTEXT_MENU_ITEM_DRAWING_TYPE_TEXT) + { + int textMargin = __itemTextMargin; + int minWidth = __itemWidth; + int maxWidth = __itemMaxWidth; + + String text = pItem->GetText(); + + textMargin = textMargin * 2; + minWidth = minWidth - textMargin; + maxWidth = maxWidth - textMargin; + + Dimension textArea(0, 0); + Dimension itemSize(0, 0); + + __pFont->GetTextExtent(text, text.GetLength(), textArea); + + if (textArea.width < minWidth) + { + textArea.width = minWidth; + } + + if (textArea.width > maxWidth) + { + textArea.width = maxWidth; + } + + itemSize.width = textArea.width + textMargin; + itemSize.height = __itemHeight; + + pItem->SetSize(itemSize); + + } + else if (itemType == CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP) + { + Dimension itemSize(__itemWidth, __itemHeight); + + pItem->SetSize(itemSize); + } +} + +result +_ContextMenuGridPresenter::CalculateWindowRect(void) +{ + result r = E_SUCCESS; + + AdjustItemLayout(); + + r = CalculateRect(); + + AdjustItemPosition(); + + return r; +} + +result +_ContextMenuGridPresenter::ApplyColorProperty(void) +{ + return E_SUCCESS; +} + + +result +_ContextMenuGridPresenter::CalculateRect(void) +{ + Tizen::Graphics::Rectangle windowRect = Tizen::Graphics::Rectangle(0, 0, 0, 0); // Window Rect is bodyRect + arrowRect + Tizen::Graphics::Rectangle bodyRect = Tizen::Graphics::Rectangle(0, 0, 0, 0); // ContextMenu rect except arrowRect + Tizen::Graphics::Rectangle arrowRect = Tizen::Graphics::Rectangle(0, 0, 0, 0); // Arrow rect of the ContextMenu + + int bodyTopMargin = __topMargin; + int bodyBottomMargin = __bottomMargin; + int bodyLeftMargin = __leftMargin; + int bodyRightMargin = __rightMargin; + + int screenTopMargin = __screenTopMargin; + int screenBottomMargin = __screenBottomMargin; + int screenLeftMargin = __screenLeftMargin; + int screenRightMargin = __screenRightMargin; + int arrowMargin = __arrowMargin; + + Point anchorPosition = __pContextMenu->GetAnchorPosition(); +// Point arrowPosition; + + Dimension screen = _ControlManager::GetInstance()->GetScreenSize(); + if (__pContextMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE) + { + screen.SetSize(screen.height, screen.width); + } + + // calculate arrow area + enum ContextMenuCoreDropPosition dropPosition = __pContextMenu->GetDropPosition(); + if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_UP || dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_DOWN) // down, up Arrow + { + arrowRect.width = __arrowWidth; + arrowRect.height = __arrowHeight; + } + else // left, right Arrow + { + arrowRect.width = __arrowHeight; + arrowRect.height = __arrowWidth; + } + + // calculate body rect + // calculate real drawing margin for contextmenu + int leftMargin = screenLeftMargin; + int rightMargin = screen.width - screenRightMargin; + int topMargin = screenTopMargin; + int bottomMargin = screen.height - screenBottomMargin; + + if (__pModel->GetItemCount() <= 0) + { + __layoutSize.width = __itemWidth; + __layoutSize.height = __itemHeight; + } + + bodyRect.width = __layoutSize.width + bodyLeftMargin + bodyRightMargin; + bodyRect.height = __layoutSize.height + bodyTopMargin + bodyBottomMargin; + + // calculate the position of the arrow and body rect. + if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_UP) // down Arrow + { + // Check touch position + // - Check left margin + if (anchorPosition.x <= leftMargin + arrowRect.width) + { + anchorPosition.x = leftMargin + arrowRect.width; + } + // - check right margin + if (anchorPosition.x >= (rightMargin - arrowRect.width)) + { + anchorPosition.x = rightMargin - arrowRect.width; + } + // - check top margin + if (anchorPosition.y <= topMargin) + { + anchorPosition.y = topMargin + bodyRect.height; + } + // - check bottom margin + if (anchorPosition.y >= bottomMargin) + { + anchorPosition.y = bottomMargin; + } + + // Set body position x + bodyRect.x = anchorPosition.x - (bodyRect.width / 2); + // - Check left margin + if (bodyRect.x <= leftMargin) + { + bodyRect.x = leftMargin; + } + // - check right margin + if ((bodyRect.x + bodyRect.width) >= rightMargin) + { + bodyRect.x = rightMargin - bodyRect.width; + } + // Set body position y + bodyRect.y = anchorPosition.y - arrowRect.height - bodyRect.height; + // - check top margin + if (bodyRect.y <= topMargin) + { + bodyRect.y = topMargin; + } + + windowRect.x = bodyRect.x; + windowRect.y = bodyRect.y; + windowRect.width = bodyRect.width; + windowRect.height = bodyRect.height + arrowRect.height; + + bodyRect.x = 0; + bodyRect.y = arrowMargin; + + // Set arrow position + arrowRect.x = anchorPosition.x - (arrowRect.width / 2) - windowRect.x; + arrowRect.y = bodyRect.height; + } + else if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_DOWN) // up Arrow + { + // Check touch position + // - Check left margin + if (anchorPosition.x <= leftMargin + arrowRect.width) + { + anchorPosition.x = leftMargin + arrowRect.width; + } + // - check right margin + if (anchorPosition.x >= (rightMargin - arrowRect.width)) + { + anchorPosition.x = rightMargin - arrowRect.width; + } + // - check top margin + if (anchorPosition.y <= topMargin) + { + anchorPosition.y = topMargin; + } + // - check bottom margin + if (anchorPosition.y >= bottomMargin) + { + anchorPosition.y = bottomMargin; + } + + // Set body position x + bodyRect.x = anchorPosition.x - (bodyRect.width / 2); + // - Check left margin + if (bodyRect.x <= leftMargin) + { + bodyRect.x = leftMargin; + } + // - check right margin + if ((bodyRect.x + bodyRect.width) >= rightMargin) + { + bodyRect.x = rightMargin - bodyRect.width; + } + // Set body position y + bodyRect.y = anchorPosition.y + arrowRect.height; + // - Check bottom margin + if ((bodyRect.y + bodyRect.height) >= bottomMargin) + { + bodyRect.y = bottomMargin - bodyRect.height; + } + + windowRect.x = bodyRect.x; + windowRect.y = bodyRect.y - arrowRect.height; + windowRect.width = bodyRect.width; + windowRect.height = bodyRect.height + arrowRect.height; + + bodyRect.x = 0; + bodyRect.y = arrowRect.height - arrowMargin; + + // Set arrow position + arrowRect.x = anchorPosition.x - (arrowRect.width / 2) - windowRect.x; + arrowRect.y = 0; + } + else if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_LEFT) // right Arrow + { + // Check touch position + // - Check left margin + if (anchorPosition.x <= leftMargin) + { + anchorPosition.x = leftMargin + bodyRect.width; + } + // - check right margin + if (anchorPosition.x >= rightMargin) + { + anchorPosition.x = rightMargin; + } + // - Check top margin + if (anchorPosition.y <= topMargin + arrowRect.height) + { + anchorPosition.y = topMargin + arrowRect.height; + } + // - check bottom margin + if (anchorPosition.y >= (bottomMargin - arrowRect.height)) + { + anchorPosition.y = bottomMargin - arrowRect.height; + } + + // Set body position x + bodyRect.x = anchorPosition.x - arrowRect.width - bodyRect.width; + // - Check left margin + if (bodyRect.x <= leftMargin) + { + bodyRect.x = leftMargin; + } + // - check right margin + if ((bodyRect.x + bodyRect.width + arrowRect.width) >= rightMargin) + { + bodyRect.x = rightMargin - bodyRect.width - arrowRect.width; + } + + // Set body position y + bodyRect.y = anchorPosition.y - (bodyRect.height / 2); + // - check top margin + if (bodyRect.y <= topMargin) + { + bodyRect.y = topMargin; + } + // - check bottom margin + if ((bodyRect.y + bodyRect.height) >= bottomMargin) + { + bodyRect.y = bottomMargin - bodyRect.height; + } + + windowRect.x = bodyRect.x; + windowRect.y = bodyRect.y; + windowRect.width = bodyRect.width + arrowRect.width; + windowRect.height = bodyRect.height; + + bodyRect.x = arrowMargin; + bodyRect.y = 0; + + // Set arrow position + arrowRect.x = bodyRect.width; + arrowRect.y = anchorPosition.y - (arrowRect.height / 2) - windowRect.y; + } + else // left Arrow + { + // Check touch position + // - Check top margin + if (anchorPosition.x <= leftMargin) + { + anchorPosition.x = leftMargin; + } + // - check right margin + if (anchorPosition.x >= rightMargin) + { + anchorPosition.x = rightMargin - bodyRect.width; + } + // - Check top margin + if (anchorPosition.y <= topMargin + arrowRect.height) + { + anchorPosition.y = topMargin + arrowRect.height; + } + // - check bottom margin + if (anchorPosition.y >= (bottomMargin - arrowRect.height)) + { + anchorPosition.y = bottomMargin - arrowRect.height; + } + + // Set body position x + bodyRect.x = anchorPosition.x + arrowRect.width; + // - Check left margin + if (bodyRect.x <= leftMargin) + { + bodyRect.x = leftMargin; + } + // - check right margin + if ((bodyRect.x + bodyRect.width) >= rightMargin) + { + bodyRect.x = rightMargin - bodyRect.width; + } + // Set body position y + bodyRect.y = anchorPosition.y - (bodyRect.height / 2); + // - check top margin + if (bodyRect.y <= topMargin) + { + bodyRect.y = topMargin; + } + // - check bottom margin + if ((bodyRect.y + bodyRect.height) >= bottomMargin) + { + bodyRect.y = bottomMargin - bodyRect.height; + } + + windowRect.x = bodyRect.x + arrowRect.width; + windowRect.y = bodyRect.y; + windowRect.width = bodyRect.width + arrowRect.width; + windowRect.height = bodyRect.height; + + bodyRect.x = arrowRect.width - arrowMargin; + bodyRect.y = 0; + + // Set arrow position + arrowRect.x = 0; + arrowRect.y = anchorPosition.y - (arrowRect.height / 2) - windowRect.y; + } + + __pContextMenu->SetBodyRect(bodyRect); + __pContextMenu->SetArrowRect(arrowRect); + __pContextMenu->SetWindowRect(windowRect); + __pContextMenu->SetMovable(true); // To do Modify a enabling + __pContextMenu->SetResizable(true); // To do Modify a enabling + __pContextMenu->SetMinimumSize(Dimension(0, 0)); // To do Modify + __pContextMenu->SetMaximumSize(screen); // To do Modify + __pContextMenu->SetBounds(windowRect); + __pContextMenu->SetMovable(false); // To do Modify a enabling + __pContextMenu->SetResizable(false); // To do Modify a enabling + + return E_SUCCESS; +} + +bool +_ContextMenuGridPresenter::IsLayoutBitmapOnly(void) +{ + int itemCount = __pModel->GetItemCount(); + + if (itemCount <= 0) + { + return false; + } + + _ContextMenuItem* pItem = null; + + for (int i = 0; i < itemCount; i++) + { + pItem = __pModel->GetItem(i); + if (pItem == null) + { + return false; + } + + if (pItem->GetType() == CONTEXT_MENU_ITEM_DRAWING_TYPE_TEXT) + { + return false; + } + } + + return true; +} + +void +_ContextMenuGridPresenter::AdjustItemLayout(void) +{ + int itemCount = __pModel->GetItemCount(); + Dimension layoutSize(0, 0); + + if (itemCount <= 0) + { + __layoutSize.width = __itemWidth; + __layoutSize.height = __itemHeight; + return; + } + + bool bitmapOnly = IsLayoutBitmapOnly(); + + if (bitmapOnly == true) + { + layoutSize = AdjustItemLayoutIconStyle(); + } + else + { + layoutSize = AdjustItemLayoutTabStyle(); + } + + Dimension screen = _ControlManager::GetInstance()->GetScreenSize(); + + if (__pContextMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE) + { + screen.SetSize(screen.height, screen.width); + } + + int maxHeight = screen.height - __screenTopMargin - __screenBottomMargin - __arrowHeight; + if (layoutSize.height > maxHeight) + { + layoutSize.height = maxHeight; + } + + __layoutSize = layoutSize; +} + +Tizen::Graphics::Dimension +_ContextMenuGridPresenter::AdjustItemLayoutIconStyle(void) +{ + int countPerLine = 0; + int itemCount = __pModel->GetItemCount(); + int itemWidth = __itemWidth + __itemGap; + int itemHeight = __itemHeight + __itemGap; + + if (itemCount <= MAX_COUNT_PER_LINE) + { + countPerLine = itemCount; + } + else + { + countPerLine = GetCountPerLine(itemCount, MIN_COUNT_PER_LINE, MAX_COUNT_PER_LINE); + } + + int lineCount = itemCount / countPerLine; + if (itemCount % countPerLine != 0) + { + lineCount++; + } + + Dimension layoutSize(0, 0); + + layoutSize.width = countPerLine * __itemWidth + (countPerLine -1) * __itemGap; + layoutSize.height = lineCount * __itemHeight + (lineCount - 1) *__itemGap; + + _ContextMenuItem* pItem = null; + + for (int line = 0; line < lineCount; line++) + { + for (int i = 0; i < countPerLine; i++) + { + int index = (line * countPerLine) + i; + if (index >= itemCount) + { + break; + } + + pItem = __pModel->GetItem(index); + + if (pItem == null) + { + break; + } + + Rectangle drawRect(0, 0, __itemWidth, __itemHeight); + + drawRect.x = (i * itemWidth); + drawRect.y = (line * itemHeight); + + bool drawDivider = true; + if (i == countPerLine -1) + { + drawDivider = false; + } + + pItem->SetDrawRect(drawRect); + pItem->SetDivider(drawDivider); + } + } + + return layoutSize; + +} + +Tizen::Graphics::Dimension +_ContextMenuGridPresenter::AdjustItemLayoutTabStyle(void) +{ + int lineWidthList[MAX_LINE_COUNT] = {0, }; + int lineItemCountList[MAX_LINE_COUNT] = {0, }; + + int itemCount = __pModel->GetItemCount(); + int maxWidth = __itemWidth; + int itemHeight = __itemHeight + __itemGap; + int lineCount = 1; + int lineWidth = 0; + int lineItemCount = 0; + int x = 0; + int y = 0; + int remainWidth; + Dimension screen = _ControlManager::GetInstance()->GetScreenSize(); + Point anchorPosition = __pContextMenu->GetAnchorPosition(); + ContextMenuCoreDropPosition dropPosition = __pContextMenu->GetDropPosition(); + + if (__pContextMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE) + { + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_MAX_WIDTH, _CONTROL_ORIENTATION_LANDSCAPE, __maxWidth); + screen.SetSize(screen.height, screen.width); + } + else + { + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_MAX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __maxWidth); + } + + if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_LEFT || dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_RIGHT) + { + remainWidth = anchorPosition.x * 2 < screen.width ? screen.width - anchorPosition.x : anchorPosition.x; + remainWidth -= __screenLeftMargin + __leftMargin + __rightMargin + __screenRightMargin; + remainWidth -= __arrowHeight; + __maxWidth = __maxWidth < remainWidth ? __maxWidth : remainWidth; + } + + _ContextMenuItem* pItem = null; + for (int i = 0; i < itemCount; i++) + { + pItem = __pModel->GetItem(i); + if (pItem == null) + { + break; + } + + Dimension itemSize = pItem->GetSize(); + if (lineWidth + itemSize.width > __maxWidth) + { + _ContextMenuItem* pPreviousItem = __pModel->GetItem(i - 1); + if (pPreviousItem != null) + { + pPreviousItem->SetDivider(false); + } + + x = 0; + y = y + itemHeight; + + lineWidth = 0; + lineItemCount = 0; + lineCount++; + } + + Rectangle drawRect(x, y, itemSize.width, itemSize.height); + pItem->SetDrawRect(drawRect); + pItem->SetDivider(true); + + x = x + itemSize.width + __itemGap; + lineWidth = lineWidth + itemSize.width + __itemGap; + + if (lineWidth > maxWidth) + { + maxWidth = lineWidth; + } + + lineItemCount++; + if (lineItemCount > MAX_LINE_COUNT) + { + lineItemCount = MAX_LINE_COUNT; + break; + } + + lineWidthList[lineCount - 1] = lineWidth; + lineItemCountList[lineCount -1] = lineItemCount; + } + + // last item + if (pItem != null) + { + pItem->SetDivider(false); + } + + Dimension layoutSize(__itemWidth, __itemHeight); + layoutSize.width = maxWidth - __itemGap; + layoutSize.height = lineCount * __itemHeight + (lineCount - 1) *__itemGap; + + if (lineCount == 1) + { + return layoutSize; + } + + // divide margin + int itemIndex = 0; + for (int line = 0; line < lineCount; line++) + { + int width = lineWidthList[line]; + int count = lineItemCountList[line]; + + if (maxWidth == width) + { + itemIndex += count; + continue; + } + + int margin = (maxWidth - width) / count; + + for (int i = 0; i < count; i++) + { + int index = itemIndex + i; + pItem = __pModel->GetItem(index); + if (pItem == null) + { + break; + } + + Rectangle drawRect = pItem->GetDrawRect(); + + drawRect.width = drawRect.width + margin; + drawRect.x = drawRect.x + (i * margin); + + pItem->SetDrawRect(drawRect); + } + + itemIndex += count; + } + + return layoutSize; +} + +void +_ContextMenuGridPresenter::AdjustItemPosition(void) +{ + int itemCount = __pModel->GetItemCount(); + + if (itemCount <= 0) + { + return; + } + + int x = __pContextMenu->GetBodyRect().x + __leftMargin; + int y = __pContextMenu->GetBodyRect().y + __topMargin; + + _ContextMenuItem* pItem = null; + + for (int i = 0; i < itemCount; i++) + { + pItem = __pModel->GetItem(i); + + if (pItem == null) + { + break; + } + + Rectangle drawRect = pItem->GetDrawRect(); + + drawRect.x += x; + drawRect.y += y; + + pItem->SetDrawRect(drawRect); + } +} + +int +_ContextMenuGridPresenter::GetCountPerLine(int count, int min, int max) const +{ + int minBlank = max; + int countPerLine = max; + + for (int i = max; i >= min; i--) + { + int remainder = count % i; + + if (remainder == 0) + { + countPerLine = i; + break; + } + + int blank = i - remainder; + + if (blank < minBlank) + { + minBlank = blank; + countPerLine = i; + } + } + + return countPerLine; +} + +int +_ContextMenuGridPresenter::GetItemIndexFromPosition(const Tizen::Graphics::Point& point) const +{ + int index = -1; + int itemCount = __pModel->GetItemCount(); + + if (itemCount < 0) + { + return -1; + } + + _ContextMenuItem* pItem = null; + + for (int i = 0; i < itemCount; i++) + { + pItem = __pModel->GetItem(i); + + if (pItem == null) + { + break; + } + + Rectangle drawRect = pItem->GetDrawRect(); + + if (drawRect.Contains(point) == true) + { + index = i; + break; + } + } + + return index; +} + + +result +_ContextMenuGridPresenter::Draw(void) +{ + result r = E_SUCCESS; + + Canvas* pCanvas = __pContextMenu->GetCanvasN(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient."); + + // Clear canvas for drawing area of the ContextMenu. + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + Tizen::Graphics::Rectangle bounds(__pContextMenu->GetWindowRect()); + pCanvas->Clear(Tizen::Graphics::Rectangle(0, 0, bounds.width, bounds.height)); + + r = DrawBackground(pCanvas); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to draw background."); + + r = DrawArrow(pCanvas); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to draw arrow."); + + r = DrawItem(pCanvas); + + delete pCanvas; + + return r; +} + +result +_ContextMenuGridPresenter::DrawBackground(Canvas* pCanvas) +{ + SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = E_SUCCESS; + + Tizen::Graphics::Rectangle bodyRect = __pContextMenu->GetBodyRect(); + + const Bitmap* pBackgroundNormalBitmap = __pContextMenu->GetBackgroundNormalBitmap(); + const Bitmap* pBackgroundEffectBitmap = __pContextMenu->GetBackgroundEffectBitmap(); + + if (pBackgroundNormalBitmap == null && pBackgroundEffectBitmap == null) + { + pCanvas->SetForegroundColor(__pContextMenu->GetColor()); + pCanvas->DrawRectangle(bodyRect); + } + else + { + if (pBackgroundNormalBitmap != null) + { + r = pCanvas->DrawNinePatchedBitmap(bodyRect, *pBackgroundNormalBitmap); + } + + if (pBackgroundEffectBitmap != null) + { + r = pCanvas->DrawNinePatchedBitmap(bodyRect, *pBackgroundEffectBitmap); + } + } + + return r; +} + + +result +_ContextMenuGridPresenter::DrawArrow(Canvas* pCanvas) +{ + SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = E_SUCCESS; + Tizen::Graphics::Rectangle arrowRect = __pContextMenu->GetArrowRect(); + ContextMenuCoreDropPosition dropPosition = __pContextMenu->GetDropPosition(); + + const Bitmap* pArrowNormalBitmap = __pContextMenu->GetArrowNormalBitmap(dropPosition); + const Bitmap* pEffectArrowBitmap = __pContextMenu->GetArrowEffectBitmap(dropPosition); + + if (pArrowNormalBitmap != null) + { + r = DrawBitmap(*pCanvas, arrowRect, *pArrowNormalBitmap); + } + + if (pEffectArrowBitmap != null) + { + r = DrawBitmap(*pCanvas, arrowRect, *pEffectArrowBitmap); + } + + return r; +} + +result +_ContextMenuGridPresenter::DrawItem(Tizen::Graphics::Canvas* pCanvas) +{ + SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = E_SUCCESS; + TextSimple* pSimpleText = null; + + int itemCount = __pModel->GetItemCount(); + + if (itemCount <= 0) + { + return E_SUCCESS; + } + + Rectangle bodyRect = __pContextMenu->GetBodyRect(); + Color pressedColor = __pContextMenu->GetItemColor(CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED); + + int bitmapLeftMargin = __itemBitmapWidth >> 1; + int bitmapTopMargin = __itemBitmapHeight >> 1; + int linePositionX = bodyRect.x + __leftMargin + __rightMargin; + int linePositionY = bodyRect.y + __topMargin; + + _ContextMenuItem* pItem = null; + + for (int i = 0; i < itemCount; i++) + { + pItem = __pModel->GetItem(i); + + if (pItem == null) + { + continue; + } + + Rectangle rect = pItem->GetDrawRect(); + ContextMenuItemDrawingType itemType = pItem->GetType(); + + if (itemType == CONTEXT_MENU_ITEM_DRAWING_TYPE_TEXT) + { + Rectangle drawRect = rect; + drawRect.x = drawRect.x + __itemTextMargin; + drawRect.width = drawRect.width - (__itemTextMargin * 2); + + ContextMenuCoreItemStatus itemStatus = CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL; + + if (__selectedIndex == i) + { + itemStatus = CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED; + + //pCanvas->FillRectangle(pressedColor, rect); + pCanvas->FillRoundRectangle(pressedColor, rect, Dimension(3, 3)); + } + + String text = pItem->GetText(); + + __pTextObject->RemoveAll(); + pSimpleText = new (std::nothrow)TextSimple(const_cast (text.GetPointer()), text.GetLength()); + SysTryReturn(NID_UI_CTRL, pSimpleText != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + __pTextObject->AppendElement(*pSimpleText); + + __pTextObject->SetForegroundColor(__pContextMenu->GetTextColor(itemStatus), 0, __pTextObject->GetTextLength()); + __pTextObject->SetBounds(drawRect); + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + + } + else + { + Rectangle drawRect = rect; + + drawRect.x = drawRect.x + (drawRect.width >> 1) - bitmapLeftMargin; + drawRect.y = drawRect.y + (drawRect.height >> 1) - bitmapTopMargin; + drawRect.width = __itemBitmapWidth; + drawRect.height = __itemBitmapHeight; + + ContextMenuItemDrawingStatus itemStatus = CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL; + + if (__selectedIndex == i) + { + itemStatus = CONTEXT_MENU_ITEM_DRAWING_STATUS_PRESSED; + + //pCanvas->FillRectangle(pressedColor, rect); + pCanvas->FillRoundRectangle(pressedColor, rect, Dimension(3, 3)); + } + + const Bitmap* pBitmap = pItem->GetBitmap(itemStatus); + if (pBitmap != null) + { + DrawBitmap(*pCanvas, drawRect, *pBitmap); + } + } + + // divder + bool drawDivider = pItem->GetDivider(); + if (drawDivider == true) + { + int x = rect.x + rect.width; + int y = rect.y + __topMargin; + + Point point1(x, y); + Point point2(x, y + __dividerHeight); + + + DrawLine(pCanvas, point1, point2, true); + } + + // horizontal line + if (linePositionY != rect.y) + { + linePositionY = rect.y; + + int x = linePositionX + __layoutSize.width - __leftMargin - __rightMargin; + int y = linePositionY - __itemGap; + + Point point1(linePositionX, y); + Point point2(x, y); + + DrawLine(pCanvas, point1, point2, false); + } + } + + return r; +} + +result +_ContextMenuGridPresenter::DrawLine(Tizen::Graphics::Canvas* pCanvas, Tizen::Graphics::Point point1, Tizen::Graphics::Point point2, bool drawVLine) +{ + SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = E_SUCCESS; + + Color colorGridItemDivider01; + Color colorGridItemDivider02; + + GET_COLOR_CONFIG(CONTEXTMENU::GRID_ITEM_DIVIDER_01, colorGridItemDivider01); + GET_COLOR_CONFIG(CONTEXTMENU::GRID_ITEM_DIVIDER_02, colorGridItemDivider02); + + if (drawVLine == true) + { + pCanvas->SetForegroundColor(colorGridItemDivider01); + pCanvas->DrawLine(point1, point2); + + point1.x++; + point2.x++; + + pCanvas->SetForegroundColor(colorGridItemDivider02); + pCanvas->DrawLine(point1, point2); + } + else + { + pCanvas->SetForegroundColor(colorGridItemDivider01); + pCanvas->DrawLine(point1, point2); + + point1.y++; + point2.y++; + + pCanvas->SetForegroundColor(colorGridItemDivider02); + pCanvas->DrawLine(point1, point2); + } + + return r; +} + +_UiTouchEventDelivery +_ContextMenuGridPresenter::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES; +} + +bool +_ContextMenuGridPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + Rectangle bodyRect = __pContextMenu->GetBodyRect(); + + if (bodyRect.Contains(touchinfo.GetCurrentPosition()) == false) + { + __selectedIndex = -1; + __pressedIndex = -1; + __touchOutRect = true; + + return true; + } + + __selectedIndex = GetItemIndexFromPosition(touchinfo.GetCurrentPosition()); + __pressedIndex = __selectedIndex; + __touchOutRect = false; + Draw(); + + return true; +} + +_UiTouchEventDelivery +_ContextMenuGridPresenter::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES; +} + +bool +_ContextMenuGridPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + Rectangle bodyRect = __pContextMenu->GetBodyRect(); + + if (__touchOutRect == true) + { + __pContextMenu->SetVisibleState(false); + } + + int currentSelectedIndex = GetItemIndexFromPosition(touchinfo.GetCurrentPosition()); + if (__selectedIndex != -1 && (__selectedIndex == currentSelectedIndex)) + { + _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent(); + + if (pActionEvent == null) + { + return true; + } + + _ContextMenuItem* pItem = null; + pItem = __pModel->GetItem(__selectedIndex); + + if (pItem == null) + { + __selectedIndex = -1; + __pressedIndex = -1; + return true; + } + + __selectedIndex = -1; + __pressedIndex = -1; + __pContextMenu->SetVisibleState(false); + + int actionId = pItem->GetActionId(); + + IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId); + + if (pEventArg == null) + { + return true; + } + + pActionEvent->Fire(*pEventArg); + } + + return true; +} + +bool +_ContextMenuGridPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return true; +} + +_UiTouchEventDelivery +_ContextMenuGridPresenter::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES; +} + +bool +_ContextMenuGridPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__selectedIndex != -1) + { + _ContextMenuItem* pItem = __pModel->GetItem(__selectedIndex); + + if (pItem == null) + { + __selectedIndex = -1; + __pressedIndex = -1; + return true; + } + + Rectangle drawRect = pItem->GetDrawRect(); + if (drawRect.Contains(touchinfo.GetCurrentPosition()) == false) + { + __selectedIndex = -1; + Draw(); + } + } + else if (__pressedIndex != -1) + { + _ContextMenuItem* pItem = __pModel->GetItem(__pressedIndex); + if(pItem != null) + { + Rectangle drawRect = pItem->GetDrawRect(); + if(drawRect.Contains(touchinfo.GetCurrentPosition())) + { + __selectedIndex = __pressedIndex; + Draw(); + } + } + } + + return true; +} + +void +_ContextMenuGridPresenter::OnFontChanged(Font* pFont) +{ + __pFont = pFont; +} + +void +_ContextMenuGridPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = FONT_STYLE_PLAIN; + size = __itemFontSize; +} + +void +_ContextMenuGridPresenter::SetAllAccessibilityElement(void) +{ + _AccessibilityContainer* pContainer = __pContextMenu->GetAccessibilityContainer(); + if (pContainer != null) + { + int itemCount = __pModel->GetItemCount(); + for (int i = 0; i < itemCount; i++) + { + _ContextMenuItem* pItem = __pModel->GetItem(i); + _AccessibilityElement* pElement = new (std::nothrow) _AccessibilityElement(true); + if (pItem != null && pElement != null) + { + pElement->SetLabel(pItem->GetText()); +// pElement->SetTrait(ACCESSIBILITY_TRAITS_CONTEXTMENU); + pElement->SetTrait(ACCESSIBILITY_TRAITS_LIST); // not yet + pElement->SetBounds(pItem->GetDrawRect()); + if (i == 0) + { + pElement->SetHint(L"The first of Contextual popup"); + } + else if(i == itemCount - 1) + { + pElement->SetHint(L"The last of Contextual popup"); + } + pContainer->AddElement(*pElement); + __pContextMenu->AddAccessibilityElement(*pElement); + } + else + { + delete pElement; + } + } + } + +} + +_ContextMenuItemInfo +_ContextMenuGridPresenter::GetItemFromPosition(const Point& position) +{ + _ContextMenuItemInfo itemInfo; + int index = GetItemIndexFromPosition(position); + itemInfo.pContextMenuItem = __pModel->GetItem(index); + + itemInfo.bListItem = false; + itemInfo.pListItem = null; + return itemInfo; +} + +_ContextMenuItemInfo +_ContextMenuGridPresenter::FindItem(int index) +{ + _ContextMenuItemInfo itemInfo; + itemInfo.bListItem = false; + itemInfo.pListItem = null; + itemInfo.pContextMenuItem = __pModel->GetItem(index); + return itemInfo; +} + +result +_ContextMenuGridPresenter::SetTopDrawnItemIndex(int index) +{ + return E_SUCCESS; +} + +result +_ContextMenuGridPresenter::DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap) +{ + result r = E_SUCCESS; + if (bitmap.IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw ninepatched bitmap.") + } + else + { + r = canvas.DrawBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw bitmap.") + } + + return r; +} + +}}} // Tizen::Ui: Control diff --git a/src/ui/controls/FUiCtrl_ContextMenuImpl.cpp b/src/ui/controls/FUiCtrl_ContextMenuImpl.cpp new file mode 100644 index 0000000..52089cd --- /dev/null +++ b/src/ui/controls/FUiCtrl_ContextMenuImpl.cpp @@ -0,0 +1,547 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ContextMenuImpl.cpp + * @brief This is the implementation file for the _ContextMenuImpl class. + */ + +#include +#include +#include "FUi_ControlImplManager.h" +#include "FUiCtrl_ContextMenuImpl.h" +#include "FUiCtrl_FrameImpl.h" +#include "FUiCtrl_Form.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ContextMenuImpl* +_ContextMenuImpl::GetInstance(ContextMenu& contextMenu) +{ + return static_cast<_ContextMenuImpl*> (contextMenu._pControlImpl); +} + +const _ContextMenuImpl* +_ContextMenuImpl::GetInstance(const ContextMenu& contextMenu) +{ + return static_cast (contextMenu._pControlImpl); +} + +_ContextMenuImpl::_ContextMenuImpl(ContextMenu* pPublic, _ContextMenu* pCore, ContextMenuStyle style) + : _WindowImpl(pPublic, pCore) + , __style(style) + , __pContextMenu(pCore) + , __pPublicActionEvent(null) +{ +} + +_ContextMenuImpl* +_ContextMenuImpl::CreateContextMenuImplN(ContextMenu* pPublic, const Point& point, ContextMenuStyle style, + ContextMenuAnchorDirection direction) +{ + + ClearLastResult(); + result r = E_SUCCESS; + + enum ContextMenuCoreStyle coreStyle = CONTEXT_MENU_CORE_STYLE_LIST; + switch (style) + { + case CONTEXT_MENU_STYLE_LIST: + coreStyle = CONTEXT_MENU_CORE_STYLE_LIST; + break; + + case CONTEXT_MENU_STYLE_GRID: + coreStyle = CONTEXT_MENU_CORE_STYLE_GRID; + break; + + case CONTEXT_MENU_STYLE_ICON: + coreStyle = CONTEXT_MENU_CORE_STYLE_GRID; + break; + + default: + SysLogException(NID_UI_CTRL, E_SYSTEM, "Unable to convert ContextMenu style."); + break; + } + + enum ContextMenuCoreAlign contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_AUTO; + switch (direction) + { + case CONTEXT_MENU_ANCHOR_DIRECTION_LEFTWARD: + contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_LEFT; + break; + + case CONTEXT_MENU_ANCHOR_DIRECTION_RIGHTWARD: + contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_RIGHT; + break; + + case CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD: + contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_UP; + break; + + case CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD: + contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN; + break; + + default: + contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_AUTO; + break; + } + + _ContextMenu* pCore = _ContextMenu::CreateContextMenuN(point, coreStyle, contextMenuAlign); + SysTryReturn(NID_UI_CTRL, pCore != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _ContextMenuImpl* pImpl = new (std::nothrow) _ContextMenuImpl(pPublic, pCore, style); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; +} + +_ContextMenuImpl::~_ContextMenuImpl(void) +{ + _Dispose(); +} + +result +_ContextMenuImpl::_Dispose(void) +{ + result r = E_SUCCESS; + + if (__pPublicActionEvent) + { + delete __pPublicActionEvent; + __pPublicActionEvent = null; + } + __pContextMenu = null; + + return r; +} + +result +_ContextMenuImpl::AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, + const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + return __pContextMenu->AddItem(text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap); +} + +result +_ContextMenuImpl::InsertItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, + const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + return __pContextMenu->InsertItem(index, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap); +} + +result +_ContextMenuImpl::SetItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, + const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + return __pContextMenu->SetItem(index, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap); +} + +result +_ContextMenuImpl::RemoveItemAt(int index) +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + if (index >= GetItemCount() || index < 0) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is not valid(index = %d).", index); + + return (_AppInfo::GetApiVersion() <= _API_VERSION_2_0 && _AppInfo::IsOspCompat())?E_SYSTEM:E_OUT_OF_RANGE; + } + + return __pContextMenu->RemoveItemAt(index); +} + +result +_ContextMenuImpl::RemoveAllItems(void) +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + return __pContextMenu->RemoveAllItems(); +} + +result +_ContextMenuImpl::OnAttachedToMainTree(void) +{ + result r = E_SUCCESS; + ClearLastResult(); + + if (GetOwner() == null) + { + _FrameImpl* pFrameImpl = dynamic_cast <_FrameImpl*>(_ControlImplManager::GetInstance()->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, pFrameImpl != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance is not constructed."); + _Form* pForm = pFrameImpl->GetCore().GetCurrentForm(); + _ContextMenu& control = GetCore(); + + if (pForm != null) + { + control.SetOwner(pForm); + } + else + { + control.SetOwner(&pFrameImpl->GetCore()); + } + } + + r = _WindowImpl::OnAttachedToMainTree(); + return r; +} + +result +_ContextMenuImpl::SetAnchorPosition(int x, int y) +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + return __pContextMenu->SetAnchorPosition(x, y); +} + +Tizen::Graphics::Point +_ContextMenuImpl::GetAnchorPosition(void) const +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + Tizen::Graphics::Point point; + + point = __pContextMenu->GetAnchorPosition(); + + return point; +} + +int +_ContextMenuImpl::GetItemCount(void) const +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + return __pContextMenu->GetItemCount(); +} + +result +_ContextMenuImpl::SetMaxVisibleItemsCount(int maxItemsCount) +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + return __pContextMenu->SetShowItemCount(maxItemsCount); +} + +int +_ContextMenuImpl::GetMaxVisibleItemsCount(void) const +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + return __pContextMenu->GetShowItemCount(); +} + +int +_ContextMenuImpl::GetItemIndexFromActionId(int actionId) const +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + return __pContextMenu->GetItemIndexAt(actionId); +} + +int +_ContextMenuImpl::GetItemActionIdAt(int index) const +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + return __pContextMenu->GetItemActionIdAt(index); +} + +result +_ContextMenuImpl::SetColor(const Graphics::Color& color) +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + r = __pContextMenu->SetColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to set color."); + + return r; +} + +Tizen::Graphics::Color +_ContextMenuImpl::GetColor(void) const +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + return __pContextMenu->GetColor(); + +} + +result +_ContextMenuImpl::SetItemTextColor(ContextMenuItemStatus status, const Tizen::Graphics::Color& color) +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + switch (status) + { + case CONTEXT_MENU_ITEM_STATUS_NORMAL: + r = __pContextMenu->SetTextColor(CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL, color); + break; + + case CONTEXT_MENU_ITEM_STATUS_PRESSED: + r = __pContextMenu->SetTextColor(CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED, color); + break; + + case CONTEXT_MENU_ITEM_STATUS_HIGHLIGHTED: + r = __pContextMenu->SetTextColor(CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED, color); + break; + + default: + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "Invalid argument at ContextMenuItemStatus."); + r = E_INVALID_ARG; + break; + } + + return r; + +} + +Tizen::Graphics::Color +_ContextMenuImpl::GetItemTextColor(ContextMenuItemStatus status) const +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + Tizen::Graphics::Color color(0, 0, 0, 0); + + switch (status) + { + case CONTEXT_MENU_ITEM_STATUS_NORMAL: + color = __pContextMenu->GetTextColor(CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL); + break; + + case CONTEXT_MENU_ITEM_STATUS_PRESSED: + color = __pContextMenu->GetTextColor(CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED); + break; + + case CONTEXT_MENU_ITEM_STATUS_HIGHLIGHTED: + color = __pContextMenu->GetTextColor(CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED); + break; + + default: + SysLogException(NID_UI_CTRL, E_SYSTEM, "Invalid argument at ContextMenuItemStatus."); + break; + } + return color; + +} + +result +_ContextMenuImpl::SetItemColor(ContextMenuItemStatus status, const Tizen::Graphics::Color& color) +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + switch (status) + { + case CONTEXT_MENU_ITEM_STATUS_NORMAL: + r = __pContextMenu->SetItemColor(CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL, color); + break; + + case CONTEXT_MENU_ITEM_STATUS_PRESSED: + r = __pContextMenu->SetItemColor(CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED, color); + break; + + case CONTEXT_MENU_ITEM_STATUS_HIGHLIGHTED: + r = __pContextMenu->SetItemColor(CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED, color); + break; + + default: + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "Invalid argument at ContextMenuItemStatus."); + r = E_INVALID_ARG; + break; + } + + return r; + +} + +Tizen::Graphics::Color +_ContextMenuImpl::GetItemColor(ContextMenuItemStatus status) const +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + Tizen::Graphics::Color color(0, 0, 0, 0); + + switch (status) + { + case CONTEXT_MENU_ITEM_STATUS_NORMAL: + color = __pContextMenu->GetItemColor(CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL); + break; + + case CONTEXT_MENU_ITEM_STATUS_PRESSED: + color = __pContextMenu->GetItemColor(CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED); + break; + + case CONTEXT_MENU_ITEM_STATUS_HIGHLIGHTED: + color = __pContextMenu->GetItemColor(CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED); + break; + + default: + SysLogException(NID_UI_CTRL, E_SYSTEM, "Invalid argument at ContextMenuItemStatus."); + break; + } + + SetLastResult(E_SUCCESS); + return color; + +} + +ContextMenuStyle +_ContextMenuImpl::GetPublicStyle(void) const +{ + return __style; +} + +result +_ContextMenuImpl::AddActionEventListener(Tizen::Ui::IActionEventListener& listener) +{ + ClearLastResult(); + + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + if (__pPublicActionEvent == null) + { + __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicActionEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + + r = __pPublicActionEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to add an action event listener."); + + r = __pContextMenu->AddActionEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to add an action event listener."); + + return r; +} + +result +_ContextMenuImpl::RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener) +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, __pPublicActionEvent != null, E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] This instance isn't constructed.") + SysAssertf(__pContextMenu != null, "Not yet constructed. Construct() should be called before use."); + + result r = E_SUCCESS; + + r = __pPublicActionEvent->RemoveListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove an action event listener."); + + r = __pContextMenu->RemoveActionEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove an action event listener."); + + return r; +} + +void +_ContextMenuImpl::OnActionPerformed(const Tizen::Ui::_Control& source, int actionId) +{ + ClearLastResult(); + + if (__pPublicActionEvent != null) + { + __pPublicActionEvent->Fire(*_PublicActionEvent::CreateActionEventArgN(actionId)); + } +} + +const char* +_ContextMenuImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::ContextMenu"; +} + +const ContextMenu& +_ContextMenuImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +ContextMenu& +_ContextMenuImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _ContextMenu& +_ContextMenuImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_ContextMenu& +_ContextMenuImpl::GetCore(void) +{ + return static_cast <_ContextMenu&>(_ControlImpl::GetCore()); +} + +}}} // Tizen::Ui: Control diff --git a/src/ui/controls/FUiCtrl_ContextMenuItem.cpp b/src/ui/controls/FUiCtrl_ContextMenuItem.cpp new file mode 100644 index 0000000..e380620 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ContextMenuItem.cpp @@ -0,0 +1,424 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ContextMenuItem.cpp + * @brief This is the implementation file for the _ContextMenuItem class. + */ + +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_ContextMenuItem.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ContextMenuItem::_ContextMenuItem(void) + : __type(CONTEXT_MENU_ITEM_DRAWING_TYPE_NONE) + , __actionId(-1) + , __divider(false) + , __selected(false) + , __parentScrollEnable(false) + , __textSize(0) + , __text(L"") + , __size(Dimension(0, 0)) + , __drawRect(Rectangle(0, 0, 0, 0)) + , __pBitmapLabel(null) + , __pTextLabel(null) + , __pDividerLineLabel1(null) + , __pDividerLineLabel2(null) +{ + __pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL] = null; + __pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_PRESSED] = null; + __pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED] = null; +} + +_ContextMenuItem::~_ContextMenuItem(void) +{ + if (__pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL] != null) + { + delete __pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL]; + __pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL] = null; + } + + if (__pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_PRESSED] != null) + { + delete __pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_PRESSED]; + __pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_PRESSED] = null; + } + + if (__pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED] != null) + { + delete __pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED]; + __pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED] = null; + } +} + +_ContextMenuItem* +_ContextMenuItem::CreateContextMenuItemN(void) +{ + ClearLastResult(); + + _ContextMenuItem* pItem = null; + + pItem = new (std::nothrow) _ContextMenuItem(); + if (pItem == null) + { + SetLastResult(E_OUT_OF_MEMORY); + return null; + } + + pItem->AcquireHandle(); + + SetLastResult(E_SUCCESS); + return pItem; +} + +void +_ContextMenuItem::SetBitmapLabel(_Label* pLabel) +{ + __pBitmapLabel = pLabel; +} + +void +_ContextMenuItem::SetTextLabel(_Label* pLabel) +{ + __pTextLabel = pLabel; +} + + +void +_ContextMenuItem::SetType(ContextMenuItemDrawingType type) +{ + __type = type; +} + +ContextMenuItemDrawingType +_ContextMenuItem::GetType(void) const +{ + return __type; +} + +void +_ContextMenuItem::SetActionId(int actionId) +{ + __actionId = actionId; +} + +int +_ContextMenuItem::GetActionId(void) const +{ + return __actionId; +} + +void +_ContextMenuItem::SetDivider(bool drawDivider) +{ + __divider = drawDivider; +} +bool +_ContextMenuItem::GetDivider(void) const +{ + return __divider; +} + +void +_ContextMenuItem::SetTextSize(int size) +{ + __textSize = size; +} + +result +_ContextMenuItem::SetText(const Tizen::Base::String& text) +{ + if (text.GetLength() <= 0) + { + return E_INVALID_ARG; + } + + __text = text; + + return E_SUCCESS; +} + +const Tizen::Base::String& +_ContextMenuItem::GetText(void) const +{ + return __text; +} + +result +_ContextMenuItem::SetBitmap(ContextMenuItemDrawingStatus status, const Tizen::Graphics::Bitmap* pBitmap) +{ + if (status < CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL || status > CONTEXT_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED) + { + return E_INVALID_ARG; + } + + SysTryReturn(NID_UI_CTRL, (status != CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL || pBitmap != null), E_INVALID_ARG, + E_INVALID_ARG, + "[E_INVALID_ARG] The normal bitmap must not be null."); + + Bitmap* pClonedBitmap = _BitmapImpl::CloneN(*pBitmap); + + // If bitmap is in _ContextMenuItem, delete old one. + if (__pBitmap[status] != null) + { + delete __pBitmap[status]; + __pBitmap[status] = null; + } + + __pBitmap[status] = pClonedBitmap; + + return E_SUCCESS; +} + +const Tizen::Graphics::Bitmap* +_ContextMenuItem::GetBitmap(ContextMenuItemDrawingStatus status) const +{ + if (status < CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL || status > CONTEXT_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED) + { + return null; + } + + return __pBitmap[status]; +} + +void +_ContextMenuItem::SetSize(Tizen::Graphics::Dimension size) +{ + __size = size; +} + +Tizen::Graphics::Dimension +_ContextMenuItem::GetSize(void) const +{ + return __size; +} + +void +_ContextMenuItem::SetDrawRect(Tizen::Graphics::Rectangle rect) +{ + __drawRect = rect; + +} + +Tizen::Graphics::Rectangle +_ContextMenuItem::GetDrawRect(void) const +{ + return __drawRect; +} + + +int +_ContextMenuItem::Release(void) +{ + delete this; + + return 0; +} + +void +_ContextMenuItem::OnDraw(void) +{ + DrawItem(); +} + + +void +_ContextMenuItem::DrawItem(void) +{ + if(__selected) + { + Color selectedBgColor; + GET_COLOR_CONFIG(CONTEXTMENU::ITEM_BG_PRESSED, selectedBgColor); + SetBackgroundColor(selectedBgColor); + } + else + { + SetBackgroundColor(Color(0, 0, 0, 0)); + } + + DrawItemDivider(); +} + +void +_ContextMenuItem::DrawItemDivider(void) +{ + int leftMargin, rightMargin; + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, rightMargin); + if (__pDividerLineLabel1 == null) + { + __pDividerLineLabel1 = _Label::CreateLabelN(); + SysTryReturnVoidResult(NID_UI_CTRL, __pDividerLineLabel1, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + Rectangle bounds = GetBounds(); + + __pDividerLineLabel1->SetBounds(Rectangle(leftMargin, bounds.height - 2, bounds.width - leftMargin - rightMargin, 1)); + + Color dividerLineColor; + GET_COLOR_CONFIG(CONTEXTMENU::LIST_ITEM_DIVIDER1, dividerLineColor); + __pDividerLineLabel1->SetBackgroundColor(dividerLineColor); + + AttachChild(*__pDividerLineLabel1); + } + + __pDividerLineLabel1->Invalidate(); + + if (__pDividerLineLabel2 == null) + { + __pDividerLineLabel2 = _Label::CreateLabelN(); + SysTryReturnVoidResult(NID_UI_CTRL, __pDividerLineLabel2, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + Rectangle bounds = GetBounds(); + + __pDividerLineLabel2->SetBounds(Rectangle(leftMargin, bounds.height - 1, bounds.width - leftMargin - rightMargin, 1)); + + Color dividerLineColor; + GET_COLOR_CONFIG(CONTEXTMENU::LIST_ITEM_DIVIDER2, dividerLineColor); + __pDividerLineLabel2->SetBackgroundColor(dividerLineColor); + + AttachChild(*__pDividerLineLabel2); + } + + __pDividerLineLabel2->Invalidate(); +} + +_UiTouchEventDelivery +_ContextMenuItem::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES; +} + +_UiTouchEventDelivery +_ContextMenuItem::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES; +} + +_UiTouchEventDelivery +_ContextMenuItem::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES; +} + +bool +_ContextMenuItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + __selected = true; + __pressed = true; + Invalidate(); + + return false; +} + +bool +_ContextMenuItem::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + Reset(); + + Invalidate(); + + return false; +} + +bool +_ContextMenuItem::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__pressed) + { + if (__parentScrollEnable) + { + if (__selected) + { + __selected = false; + Invalidate(); + } + } + else + { + int oldSelected = __selected; + + Rectangle bounds(0, 0, __size.width, __size.height); + if (bounds.Contains(touchinfo.GetCurrentPosition())) + { + __selected = true; + } + else + { + __selected = false; + } + + if (oldSelected != __selected) + { + Invalidate(); + } + } + } + return false; +} + +void +_ContextMenuItem::OnFontChanged(Tizen::Graphics::Font* pFont) +{ + String fontName = _Control::GetFont(); + + if (__pTextLabel != null) + { + __pTextLabel->SetFont(fontName); + } +} + +void +_ContextMenuItem::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = FONT_STYLE_PLAIN; + size = __textSize; +} + +void +_ContextMenuItem::SetParentScrollEnable(bool enable) +{ + __parentScrollEnable = enable; +} + +bool +_ContextMenuItem::GetParentScrollEnable() const +{ + return __parentScrollEnable; +} + +bool +_ContextMenuItem::IsSelected() const +{ + return __selected; +} + +void +_ContextMenuItem::Reset() +{ + __selected = false; + __pressed = false; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ContextMenuListPresenter.cpp b/src/ui/controls/FUiCtrl_ContextMenuListPresenter.cpp new file mode 100644 index 0000000..7a34ce2 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ContextMenuListPresenter.cpp @@ -0,0 +1,1131 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ContextMenuListPresenter.cpp + * @brief This is the implementation file for the _ContextMenuListPresenter class. + */ + +#include +#include +#include +#include +#include +#include "FUiCtrl_ContextMenuListPresenter.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_ActionEvent.h" +#include "FUi_ResourceManager.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics::_Text; + +static const int CONTEXT_MENU_LIST_ELEMENT_TEXT = 0; +static const int CONTEXT_MENU_LIST_ELEMENT_BITMAP = 1; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ContextMenuListPresenter::_ContextMenuListPresenter(_ContextMenu* pContextMenu) + : __pContextMenu(pContextMenu) + , __pModel(null) + , __pFont(null) + , __layoutSize(Dimension(0, 0)) + , __touchOutRect(false) + , __selectedIndex(-1) + , __scrollEnable(false) + , __maxWidth(0) + , __minWidth(0) + , __topMargin(0) + , __bottomMargin(0) + , __leftMargin(0) + , __rightMargin(0) + , __screenTopMargin(0) + , __screenBottomMargin(0) + , __screenLeftMargin(0) + , __screenRightMargin(0) + , __arrowMargin(0) + , __arrowWidth(0) + , __arrowHeight(0) + , __itemWidth(0) + , __itemMinWidth(0) + , __itemHeight(0) + , __itemMaxWidth(0) + , __itemGap(0) + , __itemBitmapWidth(0) + , __itemBitmapHeight(0) + , __itemFontSize(0) + , __dividerHeight(0) +{ + +} + +_ContextMenuListPresenter::~_ContextMenuListPresenter(void) +{ + __pContextMenu = null; + + delete __pModel; + __pModel = null; + + __pFont = null; + +} + +result +_ContextMenuListPresenter::Install(void) +{ + result r = E_SUCCESS; + + LoadShape(); + + __pModel = new (std::nothrow) _ContextMenuModel; + SysTryCatch(NID_UI_CTRL, __pModel != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + r = __pModel->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create data instance."); + + __pFont = __pContextMenu->GetFallbackFont(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (__pFont != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete __pModel; + __pModel = null; + + __pFont = null; + + return r; +} + + +void +_ContextMenuListPresenter::LoadShape(void) +{ + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MIN_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemMinWidth); + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MAX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemMaxWidth); + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemHeight); + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_GAP, _CONTROL_ORIENTATION_PORTRAIT, __itemGap); + + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __topMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __bottomMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __leftMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __rightMargin); + + GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenTopMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenBottomMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenLeftMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenRightMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __arrowWidth); + GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __arrowHeight); + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ICON_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapWidth); + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ICON_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapHeight); + + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __itemFontSize); + GET_SHAPE_CONFIG(CONTEXTMENU::LIST_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __dividerHeight); + + __itemWidth = __itemMinWidth; +} + +_ContextMenuItem* +_ContextMenuListPresenter::CreateItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + _ContextMenuItem* pItem = _ContextMenuItem::CreateContextMenuItemN(); + SysTryReturn(NID_UI_CTRL, pItem != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + ContextMenuItemDrawingType itemType = CONTEXT_MENU_ITEM_DRAWING_TYPE_TEXT; + + result r = E_SUCCESS; + _Label* pLabel = null; + + if (pNormalBitmap != null) + { + r = pItem->SetBitmap(CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL, pNormalBitmap); + if (r != E_SUCCESS) + { + delete pItem; + return null; + } + + // add bitmap label + pLabel = _Label::CreateLabelN(); + pLabel->SetBackgroundBitmap(*pNormalBitmap); + pLabel->SetBackgroundColor(Color(0, 0, 0, 0)); + + int bitmapY = (__itemHeight - __itemBitmapHeight ) / 2; + pLabel->SetBounds(Rectangle(__leftMargin, bitmapY, __itemBitmapWidth, __itemBitmapHeight)); + pItem->AttachChild(*pLabel); + _AccessibilityContainer* pContainer = pLabel->GetAccessibilityContainer(); + if (pContainer) + { + pContainer->Activate(false); + } + pItem->SetBitmapLabel(pLabel); + + itemType = CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP; + } + + if (pPressedBitmap != null) + { + r = pItem->SetBitmap(CONTEXT_MENU_ITEM_DRAWING_STATUS_PRESSED, pPressedBitmap); + if (r != E_SUCCESS) + { + delete pItem; + return null; + } + } + + pItem->SetType(itemType); + pItem->SetActionId(actionId); + + pItem->SetTextSize(__itemFontSize); + r = pItem->SetText(text); + if (r != E_SUCCESS) + { + delete pItem; + return null; + } + + // calculate item size + int bitmapWidth = (itemType == CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP) ? __itemBitmapWidth : 0; + + Dimension textArea(0, 0); + Dimension itemSize(0, 0); + + __pFont->GetTextExtent(text, text.GetLength(), textArea); + int labelLeftMargin, labelTopMargin; + GET_SHAPE_CONFIG(LABEL::LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, labelLeftMargin); + GET_SHAPE_CONFIG(LABEL::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, labelTopMargin); + textArea.width += 2 * labelLeftMargin; + textArea.height += 2 * labelTopMargin; + itemSize.height = __itemHeight + __dividerHeight; + itemSize.width = __leftMargin + textArea.width + __rightMargin + bitmapWidth; + + itemSize.width = itemSize.width < __itemMinWidth ? __itemMinWidth : itemSize.width; + itemSize.width = itemSize.width > __itemMaxWidth ? __itemMaxWidth : itemSize.width; + + pItem->SetSize(itemSize); + + // add text label + int textLabelX = __leftMargin + bitmapWidth; + int textLabelWidth = textArea.width; + + pLabel = _Label::CreateLabelN(); + pLabel->SetText(text); + ContextMenuCoreItemStatus itemStatus = CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL; + pLabel->SetTextColor(__pContextMenu->GetTextColor(itemStatus)); + pLabel->SetBackgroundColor(Color(0, 0, 0, 0)); + + itemSize = pItem->GetSize(); + pLabel->SetBounds(Rectangle(textLabelX, (itemSize.height - textArea.height) / 2, textLabelWidth, textArea.height)); + pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pLabel->SetTextConfig(__itemFontSize, LABEL_TEXT_STYLE_NORMAL); + + pItem->AttachChild(*pLabel); + _AccessibilityContainer* pContainer = pLabel->GetAccessibilityContainer(); + if (pContainer) + { + pContainer->Activate(false); + } + pItem->SetTextLabel(pLabel); + + __itemWidth = __itemWidth < itemSize.width ? itemSize.width : __itemWidth; + + return pItem; +} + +result +_ContextMenuListPresenter::AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, + const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + _ContextMenuItem* pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient."); + + result r = __pModel->AddItem(pItem); + + if (r != E_SUCCESS) + { + delete pItem; + SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item."); + } + + return r; +} + +result +_ContextMenuListPresenter::InsertItem(int index, const Tizen::Base::String& text, int actionId, + const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + if (text.GetLength() == 0 && normalBitmap == null && pPressedBitmap == null) + { + return E_INVALID_ARG; + } + + _ContextMenuItem* pItem = null; + + pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient."); + + result r = __pModel->InsertItem(pItem, index); + if (r != E_SUCCESS) + { + delete pItem; + SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item."); + } + + return E_SUCCESS; +} + +result +_ContextMenuListPresenter::SetItem(int index, const Tizen::Base::String& text, int actionId, + const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap) +{ + if (text.GetLength() == 0 && normalBitmap == null && pPressedBitmap == null) + { + return E_INVALID_ARG; + } + + result r = __pContextMenu->GetScrollPanel()->DetachChild(*__pModel->GetItem(index)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to detach item."); + + _ContextMenuItem* pItem = null; + pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap); + SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient."); + + r = __pModel->SetItem(pItem, index); + if (r != E_SUCCESS) + { + delete pItem; + SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item."); + } + + return E_SUCCESS; +} + +result +_ContextMenuListPresenter::DeleteItem(int index) +{ + if (__pContextMenu->GetItemCount() <= 0) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "Invalid argument."); + return E_INVALID_STATE; + } + + result r = __pContextMenu->GetScrollPanel()->DetachChild(*__pModel->GetItem(index)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to detach item."); + + r = __pModel->RemoveItem(index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to delete item."); + + return r; +} + +result +_ContextMenuListPresenter::DeleteItemAll(void) +{ + if (__pContextMenu->GetItemCount() <= 0) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "Invalid argument."); + return E_INVALID_STATE; + } + + __pContextMenu->GetScrollPanel()->DetachAllChildren(); + + result r = __pModel->RemoveAllItem(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to delete item all."); + + return r; +} + + +int +_ContextMenuListPresenter::CalculateShowItemCount(void) +{ + int itemMaxCount = 0; + GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, _CONTROL_ORIENTATION_PORTRAIT, itemMaxCount); + + int maxVisibleCount = __pContextMenu->GetShowItemCount(); + + return maxVisibleCount > itemMaxCount ? itemMaxCount : maxVisibleCount; +} + +result +_ContextMenuListPresenter::CalculateWindowRect(void) +{ + result r = CalculateRect(); + AdjustItemPosition(); + + return r; +} + +result +_ContextMenuListPresenter::ApplyColorProperty(void) +{ + return E_SUCCESS; +} + + +result +_ContextMenuListPresenter::CalculateRect(void) +{ + Tizen::Graphics::Rectangle windowRect = Tizen::Graphics::Rectangle(0, 0, 0, 0); // Window Rect is bodyRect + arrowRect + Tizen::Graphics::Rectangle bodyRect = Tizen::Graphics::Rectangle(0, 0, 0, 0); // ContextMenu rect except arrowRect + Tizen::Graphics::Rectangle arrowRect = Tizen::Graphics::Rectangle(0, 0, 0, 0); // Arrow rect of the ContextMenu + + int bodyTopMargin = __topMargin; + int bodyBottomMargin = __bottomMargin; + int bodyLeftMargin = __leftMargin; + int bodyRightMargin = __rightMargin; + + int screenTopMargin = __screenTopMargin; + int screenBottomMargin = __screenBottomMargin; + int screenLeftMargin = __screenLeftMargin; + int screenRightMargin = __screenRightMargin; + int arrowMargin = __arrowMargin; + + Point anchorPosition = __pContextMenu->GetAnchorPosition(); + + Dimension screen = _ControlManager::GetInstance()->GetScreenSize(); + if (__pContextMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE) + { + screen.SetSize(screen.height, screen.width); + } + + // calculate arrow area + enum ContextMenuCoreDropPosition dropPosition = __pContextMenu->GetDropPosition(); + if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_UP || dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_DOWN) // down, up Arrow + { + arrowRect.width = __arrowWidth; + arrowRect.height = __arrowHeight; + } + else // left, right Arrow + { + arrowRect.width = __arrowHeight; + arrowRect.height = __arrowWidth; + } + + // calculate body rect + // calculate real drawing margin for contextmenu + int leftMargin = screenLeftMargin; + int rightMargin = screen.width - screenRightMargin; + int topMargin = screenTopMargin; + int bottomMargin = screen.height - screenBottomMargin; + + // calculate layout size (__layoutSize) + AdjustItemLayout(); + + bodyRect.width = __layoutSize.width + bodyLeftMargin + bodyRightMargin; + bodyRect.height = __layoutSize.height + bodyTopMargin + bodyBottomMargin; + + // calculate the position of the arrow and body rect. + if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_UP) // down Arrow + { + // Check touch position + // - Check left margin + if (anchorPosition.x <= leftMargin + arrowRect.width) + { + anchorPosition.x = leftMargin + arrowRect.width; + } + // - check right margin + if (anchorPosition.x >= (rightMargin - arrowRect.width)) + { + anchorPosition.x = rightMargin - arrowRect.width; + } + // - check top margin + if (anchorPosition.y <= topMargin) + { + anchorPosition.y = topMargin + bodyRect.height; + } + // - check bottom margin + if (anchorPosition.y >= bottomMargin) + { + anchorPosition.y = bottomMargin; + } + + // Set body position x + bodyRect.x = anchorPosition.x - (bodyRect.width / 2); + // - Check left margin + if (bodyRect.x <= leftMargin) + { + bodyRect.x = leftMargin; + } + // - check right margin + if ((bodyRect.x + bodyRect.width) >= rightMargin) + { + bodyRect.x = rightMargin - bodyRect.width; + } + // Set body position y + bodyRect.y = anchorPosition.y - arrowRect.height - bodyRect.height; + // - check top margin + if (bodyRect.y <= topMargin) + { + bodyRect.y = topMargin; + } + + windowRect.x = bodyRect.x; + windowRect.y = bodyRect.y; + windowRect.width = bodyRect.width; + windowRect.height = bodyRect.height + arrowRect.height; + + bodyRect.x = 0; + bodyRect.y = arrowMargin; + + // Set arrow position + arrowRect.x = anchorPosition.x - (arrowRect.width / 2) - windowRect.x; + arrowRect.y = bodyRect.height; + } + else if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_DOWN) // up Arrow + { + // Check touch position + // - Check left margin + if (anchorPosition.x <= leftMargin + arrowRect.width) + { + anchorPosition.x = leftMargin + arrowRect.width; + } + // - check right margin + if (anchorPosition.x >= (rightMargin - arrowRect.width)) + { + anchorPosition.x = rightMargin - arrowRect.width; + } + // - check top margin + if (anchorPosition.y <= topMargin) + { + anchorPosition.y = topMargin; + } + // - check bottom margin + if (anchorPosition.y >= bottomMargin) + { + anchorPosition.y = bottomMargin; + } + + // Set body position x + bodyRect.x = anchorPosition.x - (bodyRect.width / 2); + // - Check left margin + if (bodyRect.x <= leftMargin) + { + bodyRect.x = leftMargin; + } + // - check right margin + if ((bodyRect.x + bodyRect.width) >= rightMargin) + { + bodyRect.x = rightMargin - bodyRect.width; + } + // Set body position y + bodyRect.y = anchorPosition.y + arrowRect.height; + // - Check bottom margin + if ((bodyRect.y + bodyRect.height) >= bottomMargin) + { + bodyRect.y = bottomMargin - bodyRect.height; + } + + windowRect.x = bodyRect.x; + windowRect.y = bodyRect.y - arrowRect.height; + windowRect.width = bodyRect.width; + windowRect.height = bodyRect.height + arrowRect.height; + + bodyRect.x = 0; + bodyRect.y = arrowRect.height - arrowMargin; + + // Set arrow position + arrowRect.x = anchorPosition.x - (arrowRect.width / 2) - windowRect.x; + arrowRect.y = 0; + } + else if (dropPosition == CONTEXT_MENU_CORE_DROP_POSITION_LEFT) // right Arrow + { + // Check touch position + // - Check left margin + if (anchorPosition.x <= leftMargin) + { + anchorPosition.x = leftMargin + bodyRect.width; + } + // - check right margin + if (anchorPosition.x >= rightMargin) + { + anchorPosition.x = rightMargin; + } + // - Check top margin + if (anchorPosition.y <= topMargin + arrowRect.height) + { + anchorPosition.y = topMargin + arrowRect.height; + } + // - check bottom margin + if (anchorPosition.y >= (bottomMargin - arrowRect.height)) + { + anchorPosition.y = bottomMargin - arrowRect.height; + } + + // Set body position x + bodyRect.x = anchorPosition.x - arrowRect.width - bodyRect.width; + // - Check left margin + if (bodyRect.x <= leftMargin) + { + bodyRect.x = leftMargin; + } + // - check right margin + if ((bodyRect.x + bodyRect.width + arrowRect.width) >= rightMargin) + { + bodyRect.x = rightMargin - bodyRect.width - arrowRect.width; + } + + // Set body position y + bodyRect.y = anchorPosition.y - (bodyRect.height / 2); + // - check top margin + if (bodyRect.y <= topMargin) + { + bodyRect.y = topMargin; + } + // - check bottom margin + if ((bodyRect.y + bodyRect.height) >= bottomMargin) + { + bodyRect.y = bottomMargin - bodyRect.height; + } + + windowRect.x = bodyRect.x; + windowRect.y = bodyRect.y; + windowRect.width = bodyRect.width + arrowRect.width; + windowRect.height = bodyRect.height; + + bodyRect.x = arrowMargin; + bodyRect.y = 0; + + // Set arrow position + arrowRect.x = bodyRect.width; + arrowRect.y = anchorPosition.y - (arrowRect.height / 2) - windowRect.y; + } + else // left Arrow + { + // Check touch position + // - Check top margin + if (anchorPosition.x <= leftMargin) + { + anchorPosition.x = leftMargin; + } + // - check right margin + if (anchorPosition.x >= rightMargin) + { + anchorPosition.x = rightMargin - bodyRect.width; + } + // - Check top margin + if (anchorPosition.y <= topMargin + arrowRect.height) + { + anchorPosition.y = topMargin + arrowRect.height; + } + // - check bottom margin + if (anchorPosition.y >= (bottomMargin - arrowRect.height)) + { + anchorPosition.y = bottomMargin - arrowRect.height; + } + + // Set body position x + bodyRect.x = anchorPosition.x + arrowRect.width; + // - Check left margin + if (bodyRect.x <= leftMargin) + { + bodyRect.x = leftMargin; + } + // - check right margin + if ((bodyRect.x + bodyRect.width) >= rightMargin) + { + bodyRect.x = rightMargin - bodyRect.width; + } + // Set body position y + bodyRect.y = anchorPosition.y - (bodyRect.height / 2); + // - check top margin + if (bodyRect.y <= topMargin) + { + bodyRect.y = topMargin; + } + // - check bottom margin + if ((bodyRect.y + bodyRect.height) >= bottomMargin) + { + bodyRect.y = bottomMargin - bodyRect.height; + } + + windowRect.x = bodyRect.x + arrowRect.width; + windowRect.y = bodyRect.y; + windowRect.width = bodyRect.width + arrowRect.width; + windowRect.height = bodyRect.height; + + bodyRect.x = arrowRect.width - arrowMargin; + bodyRect.y = 0; + + // Set arrow position + arrowRect.x = 0; + arrowRect.y = anchorPosition.y - (arrowRect.height / 2) - windowRect.y; + } + + __pContextMenu->SetBodyRect(bodyRect); + __pContextMenu->SetArrowRect(arrowRect); + __pContextMenu->SetWindowRect(windowRect); + + // _ScrollPanel API call sequence: SetBounds() -> SetScrollAreaBounds() + // _Scroll visual interaction if Bounds < ScrollAreaBounds + if (__pContextMenu->IsVisible()) { + __pContextMenu->GetScrollPanel()->SetBounds(Rectangle(bodyRect.x + bodyLeftMargin, bodyRect.y + bodyTopMargin, __layoutSize.width, __layoutSize.height)); + int itemCount = __pModel->GetItemCount(); + int itemHeight = __itemHeight + __dividerHeight; + int layoutClientHeight = itemCount * itemHeight - __dividerHeight; + __pContextMenu->GetScrollPanel()->SetClientAreaHeight(layoutClientHeight); + } + + __pContextMenu->SetMovable(true); // To do Modify a enabling + __pContextMenu->SetResizable(true); // To do Modify a enabling + __pContextMenu->SetMinimumSize(Dimension(0, 0)); // To do Modify + __pContextMenu->SetMaximumSize(screen); // To do Modify + __pContextMenu->SetBounds(windowRect); + __pContextMenu->SetMovable(false); // To do Modify a enabling + __pContextMenu->SetResizable(false); // To do Modify a enabling + + return E_SUCCESS; +} + +void +_ContextMenuListPresenter::AdjustItemLayout(void) +{ + Dimension layoutSize(0, 0); + + int itemCount = __pModel->GetItemCount(); + if (itemCount <= 0) + { + __layoutSize.width = __itemWidth; + __layoutSize.height = __itemHeight; + return; + } + + layoutSize = AdjustItemLayoutStyle(); + + Dimension screen = _ControlManager::GetInstance()->GetScreenSize(); + if (__pContextMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE) + { + screen.SetSize(screen.height, screen.width); + } + + int maxHeight = screen.height - __screenTopMargin - __screenBottomMargin - __arrowHeight; + if (layoutSize.height > maxHeight) + { + layoutSize.height = maxHeight; + } + + __layoutSize = layoutSize; +} + + +Tizen::Graphics::Dimension +_ContextMenuListPresenter::AdjustItemLayoutStyle(void) +{ + int itemMaxCount = CalculateShowItemCount(); + + int itemCount = __pModel->GetItemCount(); + int itemHeight = __itemHeight + __dividerHeight; + + Dimension layoutSize(__itemWidth, 0); + + int layoutClientHeight = itemCount * itemHeight - __dividerHeight; + int layoutMaxHeight = itemMaxCount * itemHeight - __dividerHeight; + if (layoutClientHeight > layoutMaxHeight) + { + __scrollEnable = true; + layoutSize.height = layoutMaxHeight; + } + else + { + __scrollEnable = false; + layoutSize.height = layoutClientHeight; + } + + return layoutSize; +} + +void +_ContextMenuListPresenter::AdjustItemPosition(void) +{ + int itemCount = __pModel->GetItemCount(); + if (itemCount <= 0) + { + return; + } + + int itemHeight = __itemHeight + __dividerHeight; + int drawItemY = 0; + + int x = __pContextMenu->GetBodyRect().x + __leftMargin; + int y = __pContextMenu->GetBodyRect().y + __topMargin; + + _ContextMenuItem* pItem = null; + + for (int i = 0; i < itemCount; i++) + { + pItem = __pModel->GetItem(i); + + if (pItem == null) + { + break; + } + + Rectangle drawRect(x, drawItemY + y, __itemWidth, itemHeight); + + pItem->SetDrawRect(drawRect); + pItem->SetDivider(true); + pItem->SetParentScrollEnable(__scrollEnable); + pItem->SetBounds(Rectangle(0, drawItemY, drawRect.width, drawRect.height)); + + if (pItem->HasParent() == false) + { + __pContextMenu->GetScrollPanel()->AttachChild(*pItem); + } + + drawItemY += itemHeight; + } +} + +int +_ContextMenuListPresenter::GetItemIndexFromPosition(const Tizen::Graphics::Point& point) const +{ + int index = -1; + int itemCount = __pModel->GetItemCount(); + + if (itemCount < 0) + { + return -1; + } + + _ContextMenuItem* pItem = null; + + int scrollPosition = __pContextMenu->GetScrollPanel()->GetScrollPosition(); + Point position(point.x, point.y + scrollPosition); + + for (int i = 0; i < itemCount; i++) + { + pItem = __pModel->GetItem(i); + + if (pItem == null) + { + break; + } + + Rectangle drawRect = pItem->GetDrawRect(); + + if (drawRect.Contains(position) == true) + { + index = i; + break; + } + } + + return index; +} + + +result +_ContextMenuListPresenter::Draw(void) +{ + result r = E_SUCCESS; + + Canvas* pCanvas = __pContextMenu->GetCanvasN(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient."); + + // Clear canvas for drawing area of the ContextMenu. + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + Tizen::Graphics::Rectangle bounds(__pContextMenu->GetWindowRect()); + pCanvas->Clear(Tizen::Graphics::Rectangle(0, 0, bounds.width, bounds.height)); + + r = DrawBackground(pCanvas); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to draw background."); + + r = DrawArrow(pCanvas); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to draw arrow."); + + delete pCanvas; + + return r; +} + +result +_ContextMenuListPresenter::DrawBackground(Canvas* pCanvas) +{ + SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = E_SUCCESS; + + Tizen::Graphics::Rectangle bodyRect = __pContextMenu->GetBodyRect(); + + const Bitmap* pBackgroundNormalBitmap = __pContextMenu->GetBackgroundNormalBitmap(); + const Bitmap* pBackgroundEffectBitmap = __pContextMenu->GetBackgroundEffectBitmap(); + + if (pBackgroundNormalBitmap == null && pBackgroundEffectBitmap == null) + { + pCanvas->SetForegroundColor(__pContextMenu->GetColor()); + pCanvas->DrawRectangle(bodyRect); + } + else + { + if (pBackgroundNormalBitmap != null) + { + r = pCanvas->DrawNinePatchedBitmap(bodyRect, *pBackgroundNormalBitmap); + } + + if (pBackgroundEffectBitmap != null) + { + r = pCanvas->DrawNinePatchedBitmap(bodyRect, *pBackgroundEffectBitmap); + } + } + + return r; +} + + +result +_ContextMenuListPresenter::DrawArrow(Canvas* pCanvas) +{ + SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = E_SUCCESS; + Tizen::Graphics::Rectangle arrowRect = __pContextMenu->GetArrowRect(); + ContextMenuCoreDropPosition dropPosition = __pContextMenu->GetDropPosition(); + + const Bitmap* pArrowNormalBitmap = __pContextMenu->GetArrowNormalBitmap(dropPosition); + const Bitmap* pEffectArrowBitmap = __pContextMenu->GetArrowEffectBitmap(dropPosition); + + if (pArrowNormalBitmap != null) + { + r = DrawBitmap(*pCanvas, arrowRect, *pArrowNormalBitmap); + } + + if (pEffectArrowBitmap != null) + { + r = DrawBitmap(*pCanvas, arrowRect, *pEffectArrowBitmap); + } + + return r; +} + +_UiTouchEventDelivery +_ContextMenuListPresenter::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES; +} + +bool +_ContextMenuListPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + Rectangle bodyRect = __pContextMenu->GetBodyRect(); + if (!bodyRect.Contains(touchinfo.GetCurrentPosition())) + { + __selectedIndex = -1; + __touchOutRect = true; + return true; + } + + __selectedIndex = GetItemIndexFromPosition(touchinfo.GetCurrentPosition()); + __touchOutRect = false; + return true; +} + +_UiTouchEventDelivery +_ContextMenuListPresenter::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES; +} + +bool +_ContextMenuListPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__touchOutRect) + { + Rectangle bodyRect = __pContextMenu->GetBodyRect(); + if (!bodyRect.Contains(touchinfo.GetCurrentPosition())) + { + __pContextMenu->SetVisibleState(false); + } + } + + int currentSelectedIndex = GetItemIndexFromPosition(touchinfo.GetCurrentPosition()); + if (__selectedIndex != -1 && (__selectedIndex == currentSelectedIndex)) + { + _ContextMenuItem* pItem = null; + pItem = __pModel->GetItem(__selectedIndex); + + __selectedIndex = -1; + __pContextMenu->SetVisibleState(false); + + int actionId = pItem->GetActionId(); + + _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent(); + if (pActionEvent == null) + { + return true; + } + + IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId); + if (pEventArg == null) + { + return true; + } + + pActionEvent->Fire(*pEventArg); + } + + return true; +} + +_UiTouchEventDelivery +_ContextMenuListPresenter::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__scrollEnable) + { + __selectedIndex = -1; + } + + return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES; +} + +bool +_ContextMenuListPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__scrollEnable) + { + __selectedIndex = -1; + } + + return true; +} + +bool +_ContextMenuListPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + __pModel->ResetAllItem(); + + return true; +} + +void +_ContextMenuListPresenter::OnFontChanged(Tizen::Graphics::Font* pFont) +{ + __pFont = pFont; + String fontName = __pContextMenu->GetFont(); + + int itemCount = __pModel->GetItemCount(); + for (int i = 0; i < itemCount; i++) + { + _ContextMenuItem* pItem = __pModel->GetItem(i); + if (pItem != null) + { + pItem->SetFont(fontName); + } + } +} + +void +_ContextMenuListPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = FONT_STYLE_PLAIN; + size = __itemFontSize; +} + +void +_ContextMenuListPresenter::SetAllAccessibilityElement(void) +{ + _AccessibilityContainer* pContainer = __pContextMenu->GetAccessibilityContainer(); + if (pContainer != null) + { + int itemCount = __pModel->GetItemCount(); + for (int i = 0; i < itemCount; i++) + { + _ContextMenuItem* pItem = __pModel->GetItem(i); + _AccessibilityElement* pElement = new (std::nothrow) _AccessibilityElement(true); + if (pItem != null && pElement != null) + { + pElement->SetLabel(pItem->GetText()); +// pElement->SetTrait(ACCESSIBILITY_TRAITS_CONTEXTMENU); + pElement->SetTrait(ACCESSIBILITY_TRAITS_LIST); // not yet + pElement->SetBounds(pItem->GetDrawRect()); + if (i == 0) + { + pElement->SetHint(L"The first of Contextual popup"); + } + else if(i == itemCount - 1) + { + pElement->SetHint(L"The last of Contextual popup"); + } + pContainer->AddElement(*pElement); + __pContextMenu->AddAccessibilityElement(*pElement); + } + else + { + delete pElement; + } + } + } + +} + +_ContextMenuItemInfo +_ContextMenuListPresenter::GetItemFromPosition(const Point& position) +{ + _ContextMenuItemInfo itemInfo; + int index = GetItemIndexFromPosition(position); + itemInfo.pContextMenuItem = __pModel->GetItem(index); + + itemInfo.bListItem = false; + itemInfo.pListItem = null; + return itemInfo; +} + +_ContextMenuItemInfo +_ContextMenuListPresenter::FindItem(int index) +{ + _ContextMenuItemInfo itemInfo; + itemInfo.bListItem = false; + itemInfo.pListItem = null; + itemInfo.pContextMenuItem = __pModel->GetItem(index); + return itemInfo; +} + +result +_ContextMenuListPresenter::SetTopDrawnItemIndex(int index) +{ + return E_SUCCESS; +} + +result +_ContextMenuListPresenter::DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap) +{ + result r = E_SUCCESS; + if (bitmap.IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw ninepatched bitmap.") + } + else + { + r = canvas.DrawBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw bitmap.") + } + + return r; +} + +}}} // Tizen::Ui: Control diff --git a/src/ui/controls/FUiCtrl_ContextMenuModel.cpp b/src/ui/controls/FUiCtrl_ContextMenuModel.cpp new file mode 100644 index 0000000..76e0d4e --- /dev/null +++ b/src/ui/controls/FUiCtrl_ContextMenuModel.cpp @@ -0,0 +1,167 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ContextMenuModel.cpp + * @brief This is the implementation file for the _ContextMenuModel class. + */ + +#include +#include +#include "FUiCtrl_ContextMenuModel.h" + +static const int DEFAULT_ITEM_COUNT = 32; + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ContextMenuModel::_ContextMenuModel(void) +{ + +} + +_ContextMenuModel::~_ContextMenuModel(void) +{ + __items.RemoveAll(true); +} + + +result +_ContextMenuModel::Construct(void) +{ + + result r = __items.Construct(DEFAULT_ITEM_COUNT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to construct ArrayList."); + + return r; +} + +bool +_ContextMenuModel::IsValidItem(_ContextMenuItem *pItem) +{ + if (pItem == null) + return false; + + int actionId = pItem->GetActionId(); + int itemCount = __items.GetCount(); + + for (int i = 0; i < itemCount; i++) + { + _ContextMenuItem* pTargetItem = GetItem(i); + + if (pTargetItem == null) + return false; + + if (pTargetItem->GetActionId() == actionId) + { + return false; + } + } + + return true; +} + +int +_ContextMenuModel::GetItemCount(void) const +{ + + return __items.GetCount(); +} + +result +_ContextMenuModel::AddItem(_ContextMenuItem* pItem) +{ + if (IsValidItem(pItem) == false) + { + return E_SYSTEM; + } + + return __items.Add(*pItem); +} + +result +_ContextMenuModel::InsertItem( _ContextMenuItem* pItem, int index) +{ + if (IsValidItem(pItem) == false) + { + return E_SYSTEM; + } + + return __items.InsertAt(*pItem, index); +} + +result +_ContextMenuModel::SetItem(_ContextMenuItem* pItem, int index) +{ + if (IsValidItem(pItem) == false) + { + _ContextMenuItem* pTargetItem = GetItem(index); + if (pItem == null || pTargetItem == null || pItem->GetActionId() != pTargetItem->GetActionId()) + { + return E_SYSTEM; + } + } + + return __items.SetAt(*pItem, index, true); +} + +result +_ContextMenuModel::RemoveItem(int index) +{ + return __items.RemoveAt(index, true); +} + +result +_ContextMenuModel::RemoveAllItem(void) +{ + __items.RemoveAll(true); + + return E_SUCCESS; +} + +void +_ContextMenuModel::ResetAllItem() +{ + int count = __items.GetCount(); + + _ContextMenuItem* pItem; + for(int index = 0; index < count; index++) + { + pItem = static_cast <_ContextMenuItem*>(__items.GetAt(index)); + pItem->Reset(); + } +} + +_ContextMenuItem* +_ContextMenuModel::GetItem(int index) const +{ + int count = __items.GetCount(); + + if (index < 0 || index >= count) + { + return null; + } + + const _ContextMenuItem* pItem = static_cast (__items.GetAt(index)); + return const_cast<_ContextMenuItem*>(pItem); + +// return static_cast <_ContextMenuItem*>(__items.GetAt(index)); +} + + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_CustomElement.cpp b/src/ui/controls/FUiCtrl_CustomElement.cpp new file mode 100644 index 0000000..d1ee42f --- /dev/null +++ b/src/ui/controls/FUiCtrl_CustomElement.cpp @@ -0,0 +1,86 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_CustomElement.cpp + * @brief This is the implementation file for _CustomElement class. + * + * This file contains the implementation of _CustomElement class. + */ + +#include +#include +#include "FUiCtrl_CustomElement.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_CustomElement::_CustomElement(int elementId) + : __pElement(null) + , __elementId(elementId) +{ +} + +_CustomElement::~_CustomElement(void) +{ +} + +int +_CustomElement::GetElementId(void) const +{ + return __elementId; +} + +bool +_CustomElement::DrawElement(Canvas* pCanvas, Rectangle& rect, ListViewItemDrawingStatus status) +{ + bool result = true; + switch (status) + { + case LISTVIEW_ITEM_STATUS_NORMAL: + result = __pElement->OnDraw(*pCanvas, rect, LIST_ITEM_DRAWING_STATUS_NORMAL); + break; + + case LISTVIEW_ITEM_STATUS_PRESSED: + result = __pElement->OnDraw(*pCanvas, rect, LIST_ITEM_DRAWING_STATUS_PRESSED); + break; + + case LISTVIEW_ITEM_STATUS_HIGHLIGHTED: + result = __pElement->OnDraw(*pCanvas, rect, LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED); + break; + + default: + result = __pElement->OnDraw(*pCanvas, rect, LIST_ITEM_DRAWING_STATUS_NORMAL); + break; + } + + return result; +} + +void +_CustomElement::SetElement(const ICustomElement& element) +{ + __pElement = const_cast (&element); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_CustomItemImpl.cpp b/src/ui/controls/FUiCtrl_CustomItemImpl.cpp new file mode 100644 index 0000000..17c3292 --- /dev/null +++ b/src/ui/controls/FUiCtrl_CustomItemImpl.cpp @@ -0,0 +1,429 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_CustomItemImpl.cpp + * @brief This is the implementation file for _CustomItemImpl class. + * + * This file contains the implementation of _CustomItemImpl class. + */ + +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_CustomElement.h" +#include "FUiCtrl_CustomItemImpl.h" +#include "FUiCtrl_ListViewItem.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_CustomItemImpl::_CustomItemImpl(CustomItem* pPublic) + : _ListItemBaseImpl(pPublic) +{ + +} + +_CustomItemImpl::~_CustomItemImpl(void) +{ + +} + +CustomItem& +_CustomItemImpl::GetPublic(void) +{ + return static_cast (_ListItemBaseImpl::GetPublic()); +} + +const char* +_CustomItemImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::CustomItem"; +} + +_CustomItemImpl* +_CustomItemImpl::CreateCustomItemImplN(CustomItem* pPublic, const Dimension& itemSize, ListAnnexStyle style) +{ + result r = E_SUCCESS; + + _CustomItemImpl* pImpl = new (std::nothrow) _CustomItemImpl(pPublic); + SysTryReturn(NID_UI_CTRL, (pImpl != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = pImpl->Construct(itemSize, style); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[E_SYSTEM] Unable to construct _CustomItemImpl."); + + return pImpl; + +CATCH: + delete pImpl; + pImpl = null; + + return null; +} + +result +_CustomItemImpl::Construct(const Dimension& itemSize, ListAnnexStyle style) +{ + result r = _ListItemBaseImpl::Construct(itemSize, style); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetListViewItem()->SetListViewItemType(LISTVIEW_ITEM_TYPE_CUSTOM); + + SetLastResultReturn(r); +} + +result +_CustomItemImpl::AddElement(const Rectangle& rect, int elementId, const EnrichedText& text) +{ + _ListViewItem* pItem = GetListViewItem(); + + SysTryReturn(NID_UI_CTRL, (rect.width >= 0) && (rect.height >= 0), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] The width and height should be greater than 0.")); + + SysTryReturn(NID_UI_CTRL, (elementId >= 0) && (elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("E_INVALID_ARG] The element ID should not be less than 0.")); + + Rectangle bounds = rect; + ListAnnexStyle style = GetListItemAnnexStyle(); + + if (style == LIST_ANNEX_STYLE_MARK || style == LIST_ANNEX_STYLE_RADIO) + { + int elementLeftMargin = 0; + GET_SHAPE_CONFIG(LISTVIEW::ITEM_ELEMENT_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, elementLeftMargin); + + bounds.x += GetAnnexWidth(style) + elementLeftMargin; + } + + result r = pItem->AddElement(bounds, elementId, &text); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pItem->SetTextCutlinkViewMode(elementId, true, false); + + return r; +} + +result +_CustomItemImpl::AddElement(const Rectangle& rect, int elementId, const String& text, bool textSliding) +{ + _ListViewItem* pItem = GetListViewItem(); + + SysTryReturn(NID_UI_CTRL, (rect.width >= 0) && (rect.height >= 0), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] The width and height should be greater than 0.")); + + SysTryReturn(NID_UI_CTRL, (elementId >= 0) && (elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("E_INVALID_ARG] The element ID should not be less than 0.")); + + Rectangle bounds = rect; + ListAnnexStyle style = GetListItemAnnexStyle(); + + if (style == LIST_ANNEX_STYLE_MARK || style == LIST_ANNEX_STYLE_RADIO) + { + int elementLeftMargin = 0; + GET_SHAPE_CONFIG(LISTVIEW::ITEM_ELEMENT_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, elementLeftMargin); + + bounds.x += GetAnnexWidth(style) + elementLeftMargin; + } + + result r = pItem->AddElement(bounds, elementId, text, textSliding); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (textSliding == true) + { + pItem->SetTextWrapType(elementId, TEXT_OBJECT_WRAP_TYPE_NONE); + } + + return r; +} + +result +_CustomItemImpl::AddElement(const Rectangle& rect, int elementId, const String& text, int textSize, + const Color& normalTextColor, const Color& pressedTextColor, const Color& highlightedTextColor, bool textSliding) +{ + _ListViewItem* pItem = GetListViewItem(); + + SysTryReturn(NID_UI_CTRL, (rect.width >= 0) && (rect.height >= 0), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] The width and height should be greater than 0.")); + + SysTryReturn(NID_UI_CTRL, (elementId >= 0) && (elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("E_INVALID_ARG] The element ID should not be less than 0.")); + + Rectangle bounds = rect; + ListAnnexStyle style = GetListItemAnnexStyle(); + bool ret; + result r = E_SUCCESS; + + if (style == LIST_ANNEX_STYLE_MARK || style == LIST_ANNEX_STYLE_RADIO) + { + int elementLeftMargin = 0; + GET_SHAPE_CONFIG(LISTVIEW::ITEM_ELEMENT_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, elementLeftMargin); + + bounds.x += GetAnnexWidth(style) + elementLeftMargin; + } + + r = pItem->AddElement(bounds, elementId, text, textSliding); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + ret = pItem->SetTextSize(elementId, textSize); + SysTryCatch(NID_UI_CTRL, (ret == true), (r = E_SYSTEM), E_SYSTEM, ("[E_SYSTEM] Unable to add element.")); + + ret = pItem->SetTextColor(elementId, normalTextColor, LISTVIEW_ITEM_STATUS_NORMAL); + SysTryCatch(NID_UI_CTRL, (ret == true), (r = E_SYSTEM), E_SYSTEM, ("[E_SYSTEM] Unable to add element.")); + + ret = pItem->SetTextColor(elementId, pressedTextColor, LISTVIEW_ITEM_STATUS_PRESSED); + SysTryCatch(NID_UI_CTRL, (ret == true), (r = E_SYSTEM), E_SYSTEM, ("[E_SYSTEM] Unable to add element.")); + + ret = pItem->SetTextColor(elementId, highlightedTextColor, LISTVIEW_ITEM_STATUS_HIGHLIGHTED); + SysTryCatch(NID_UI_CTRL, (ret == true), (r = E_SYSTEM), E_SYSTEM, ("[E_SYSTEM] Unable to add element.")); + + if (textSliding == true) + { + pItem->SetTextWrapType(elementId, TEXT_OBJECT_WRAP_TYPE_NONE); + } + + return E_SUCCESS; + +CATCH: + if (pItem->DeleteElement(elementId) == false) + { + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + + return r; +} + +result +_CustomItemImpl::AddElement(const Rectangle& rect, int elementId, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap, + const Bitmap* pHighlightedBitmap) +{ + _ListViewItem* pItem = GetListViewItem(); + + SysTryReturn(NID_UI_CTRL, (rect.width >= 0) && (rect.height >= 0), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] The width and height should be greater than 0.")); + + SysTryReturn(NID_UI_CTRL, (elementId >= 0) && (elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("E_INVALID_ARG] The element ID should not be less than 0.")); + + Rectangle bounds = rect; + ListAnnexStyle style = GetListItemAnnexStyle(); + + if (style == LIST_ANNEX_STYLE_MARK || style == LIST_ANNEX_STYLE_RADIO) + { + int elementLeftMargin = 0; + GET_SHAPE_CONFIG(LISTVIEW::ITEM_ELEMENT_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, elementLeftMargin); + + bounds.x += GetAnnexWidth(style) + elementLeftMargin; + } + + result r = pItem->AddElement(bounds, elementId, &normalBitmap, pPressedBitmap, pPressedBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return r; +} + +result +_CustomItemImpl::AddElement(const Rectangle& rect, int elementId, const ICustomElement& element) +{ + _ListViewItem* pItem = GetListViewItem(); + + SysTryReturn(NID_UI_CTRL, (rect.width >= 0) && (rect.height >= 0), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] The width and height should be greater than 0.")); + + SysTryReturn(NID_UI_CTRL, (elementId >= 0) && (elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("E_INVALID_ARG] The element ID should not be less than 0.")); + + _CustomElement* pCustomElement = null; + Rectangle bounds = rect; + ListAnnexStyle style = GetListItemAnnexStyle(); + + if (style == LIST_ANNEX_STYLE_MARK || style == LIST_ANNEX_STYLE_RADIO) + { + int elementLeftMargin = 0; + GET_SHAPE_CONFIG(LISTVIEW::ITEM_ELEMENT_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, elementLeftMargin); + + bounds.x += GetAnnexWidth(style) + elementLeftMargin; + } + + pCustomElement = new (std::nothrow) _CustomElement(elementId); + SysTryReturn(NID_UI_CTRL, (pCustomElement != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + pCustomElement->SetElement(element); + + result r = pItem->AddElement(bounds, elementId, pCustomElement); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return r; + +CATCH: + delete pCustomElement; + pCustomElement = null; + + return r; +} + +result +_CustomItemImpl::RemoveAllElements(void) +{ + GetListViewItem()->DeleteAllElement(); + + return E_SUCCESS; +} + +result +_CustomItemImpl::RemoveElement(int elementId) +{ + SysTryReturn(NID_UI_CTRL, (elementId >= 0) && (elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("E_INVALID_ARG] The element ID should not be less than 0.")); + + SysTryReturn(NID_UI_CTRL, (GetListViewItem()->DeleteElement(elementId) == true), E_SYSTEM, E_SYSTEM, + ("[E_SYSTEM] Unable to remove element.")); + + return E_SUCCESS; +} + +result +_CustomItemImpl::SetElementSelectionEnabled(int elementId, bool enable) +{ + _ListViewItem* pItem = GetListViewItem(); + + SysTryReturn(NID_UI_CTRL, (elementId >= 0) && (elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("E_INVALID_ARG] The element ID should not be less than 0.")); + + SysTryReturn(NID_UI_CTRL, (pItem->HasElement(elementId) == true), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] This elementId does not exist.")); + + SysTryReturn(NID_UI_CTRL, (pItem->SetElementSelectionEnabled(elementId, enable) == true), E_SYSTEM, E_SYSTEM, + ("[E_SYSTEM] Unable to set selection type of element.")); + + return E_SUCCESS; +} + +result +_CustomItemImpl::SetElementTextHorizontalAlignment(int elementId, HorizontalAlignment alignment) +{ + _ListViewItem* pItem = GetListViewItem(); + + SysTryReturn(NID_UI_CTRL, (elementId >= 0) && (elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("E_INVALID_ARG] The element ID should not be less than 0.")); + + SysTryReturn(NID_UI_CTRL, (pItem->GetElementType(elementId) == LISTVIEW_ITEM_ELEMENT_TEXT), E_INVALID_OPERATION, E_INVALID_OPERATION, + ("[E_INVALID_OPERATION] This element is not text.")); + + TextObjectAlignment align = 0x0000; + switch (alignment) + { + case ALIGNMENT_LEFT: + align = TEXT_OBJECT_ALIGNMENT_LEFT; + break; + + case ALIGNMENT_RIGHT: + align = TEXT_OBJECT_ALIGNMENT_RIGHT; + break; + + case ALIGNMENT_CENTER: + align = TEXT_OBJECT_ALIGNMENT_CENTER; + break; + + default: + SysTryReturn(NID_UI_CTRL, false, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to set TextAlignment."); + } + + SysTryReturn(NID_UI_CTRL, (pItem->SetTextAlignment(elementId, align) == true), E_SYSTEM, E_SYSTEM, + ("[E_SYSTEM] Unable to set TextAlignment.")); + + return E_SUCCESS; +} + +result +_CustomItemImpl::SetElementTextVerticalAlignment(int elementId, VerticalAlignment alignment) +{ + _ListViewItem* pItem = GetListViewItem(); + + SysTryReturn(NID_UI_CTRL, (elementId >= 0) && (elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("E_INVALID_ARG] The element ID should not be less than 0.")); + + SysTryReturn(NID_UI_CTRL, (pItem->GetElementType(elementId) == LISTVIEW_ITEM_ELEMENT_TEXT), E_INVALID_OPERATION, E_INVALID_OPERATION, + ("[E_INVALID_OPERATION] This element is not text.")); + + TextObjectAlignment align = 0x0000; + switch (alignment) + { + case ALIGNMENT_TOP: + align = TEXT_OBJECT_ALIGNMENT_TOP; + break; + + case ALIGNMENT_BOTTOM: + align = TEXT_OBJECT_ALIGNMENT_BOTTOM; + break; + + case ALIGNMENT_MIDDLE: + align = TEXT_OBJECT_ALIGNMENT_MIDDLE; + break; + + default: + SysTryReturn(NID_UI_CTRL, false, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to set TextAlignment."); + } + + SysTryReturn(NID_UI_CTRL, (pItem->SetTextAlignment(elementId, align) == true), E_SYSTEM, E_SYSTEM, + ("[E_SYSTEM] Unable to set TextAlignment.")); + + return E_SUCCESS; +} + +result +_CustomItemImpl::SetElementAutoLinkMask(int elementId, unsigned long mask) +{ + _ListViewItem* pItem = GetListViewItem(); + + SysTryReturn(NID_UI_CTRL, (elementId >= 0) && (elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("E_INVALID_ARG] The element ID should not be less than 0.")); + + SysTryReturn(NID_UI_CTRL, (pItem->GetElementType(elementId) == LISTVIEW_ITEM_ELEMENT_TEXT), E_INVALID_OPERATION, E_INVALID_OPERATION, + ("[E_INVALID_OPERATION] This element is not text.")); + + SysTryReturn(NID_UI_CTRL, (pItem->SetTextCutlinkViewMode(elementId, true) == true), E_SYSTEM, E_SYSTEM, + ("[E_SYSTEM] Unable to set auto link.")); + + unsigned long linktype = 0x0; + + if (LINK_TYPE_URL & mask) + { + linktype |= TEXT_CUTLINK_TYPE_URL; + } + + if (LINK_TYPE_EMAIL & mask) + { + linktype |= TEXT_CUTLINK_TYPE_EMAIL; + } + + if (LINK_TYPE_TEL_NUM & mask) + { + linktype |= TEXT_CUTLINK_TYPE_PHONE_NUMBER; + } + + SysTryReturn(NID_UI_CTRL, (pItem->SetTextCutlinkMask(elementId, linktype) == true), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] Unable to set auto link."); + + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_CustomListElements.cpp b/src/ui/controls/FUiCtrl_CustomListElements.cpp new file mode 100644 index 0000000..5e57bdc --- /dev/null +++ b/src/ui/controls/FUiCtrl_CustomListElements.cpp @@ -0,0 +1,711 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_CustomListElements.cpp +* @brief This is the header file for the classes related to implementing elements in CustomListItem. +*/ + +#include +#include +#include +#include +#include "FUiCtrl_CustomListItemImpl.h" +#include "FUiCtrl_CustomListItemFormatImpl.h" +#include "FUiCtrl_PanelImpl.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ElementBaseModel::_ElementBaseModel(void) + : _elementId(-1) + , _itemStatus(CUSTOM_LIST_ITEM_STATUS_NORMAL) +{ +} + +_ElementBaseModel::~_ElementBaseModel(void) +{ +} + +int +_ElementBaseModel::GetElementId(void) +{ + return _elementId; +} + +CustomListItemStatus +_ElementBaseModel::GetItemStatus(void) +{ + return _itemStatus; +} + +void +_ElementBaseModel::HandleElementEvent(CustomListItemStatus itemStatus) +{ + _itemStatus = itemStatus; +} + +_TextElementModel::_TextElementModel(const String& text) + : __text(text) + , __textSize(0) + , __slidingEnabled(false) +{ +} + +_TextElementModel::~_TextElementModel(void) +{ +} + +void +_TextElementModel::SetTextSliding(bool enable) +{ + __slidingEnabled = enable; +} + +bool +_TextElementModel::GetTextSliding(void) +{ + return __slidingEnabled; +} + +void +_TextElementModel::GetData(String& text, Color& textColor, int& textSize) const +{ + text = __text; + textColor = __textColor[_itemStatus]; + textSize = __textSize; + + return; +} + +int +_TextElementModel::GetTextSize(void) const +{ + return __textSize; +} + +result +_TextElementModel::CreateElementView(_ElementViewParams& elementParams) +{ + _TextElementModel* pTextElementModel = dynamic_cast<_TextElementModel*>(elementParams.pElementModel); + SysTryReturn(NID_UI_CTRL, (pTextElementModel != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element model"); + + SysTryReturn(NID_UI_CTRL, (elementParams.pElementFormatData != null), E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. pElementFormatData must not be null"); + SysTryReturn(NID_UI_CTRL, (elementParams.pTableViewItemBase != null), E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. pTableViewItemBase must not be null"); + SysTryReturn(NID_UI_CTRL, (elementParams.pCustomListItemImpl != null), E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. pCustomListItemImpl must not be null"); + + pTextElementModel->__textSize = elementParams.pElementFormatData->textSize; + pTextElementModel->__textColor[CUSTOM_LIST_ITEM_STATUS_NORMAL] = elementParams.pElementFormatData->normalTextColor; + pTextElementModel->__textColor[CUSTOM_LIST_ITEM_STATUS_FOCUSED] = elementParams.pElementFormatData->focusedTextColor; + pTextElementModel->__textColor[CUSTOM_LIST_ITEM_STATUS_SELECTED] = elementParams.pElementFormatData->highlightedTextColor; + + TextObject* pText = new (std::nothrow) TextObject(); + SysTryReturn(NID_UI_CTRL, pText, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pText->Construct(); + + TextSimple* pSimpleText = new (std::nothrow) TextSimple(const_cast (pTextElementModel->__text.GetPointer()), pTextElementModel->__text.GetLength()); + SysTryReturn(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pText->AppendElement(*pSimpleText); + + pText->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE); + pText->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); + pText->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + pText->Compose(); + + _TextElementView* pTextElementView = new (std::nothrow) _TextElementView(pText); + SysTryReturn(NID_UI_CTRL, (pTextElementView != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pTextElementView->Construct(elementParams.pElementFormatData->rect); + pTextElementView->AddTouchEventListener(*elementParams.pCustomListItemImpl); + elementParams.pTableViewItemBase->AddControl(*pTextElementView); + pTextElementView->SetModel(pTextElementModel); + elementParams.pTableViewItemBase->SetIndividualSelectionEnabled(pTextElementView, true); + + return E_SUCCESS; +} + +_BitmapElementModel::_BitmapElementModel(void) +{ + for (int i = 0; i <= CUSTOM_LIST_ITEM_STATUS_FOCUSED; i++) + { + __pBitmap[i] = null; + } +} + +_BitmapElementModel::~_BitmapElementModel(void) +{ + for (int i = 0; i <= CUSTOM_LIST_ITEM_STATUS_FOCUSED; i++) + { + delete __pBitmap[i]; + } +} + +Bitmap* +_BitmapElementModel::GetData(void) const +{ + return __pBitmap[_itemStatus]; +} + +result +_BitmapElementModel::CreateElementView(_ElementViewParams& elementParams) +{ + _BitmapElementModel* pBitmapElementModel = dynamic_cast<_BitmapElementModel*>(elementParams.pElementModel); + SysTryReturn(NID_UI_CTRL, (pBitmapElementModel != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element model"); + + SysTryReturn(NID_UI_CTRL, (elementParams.pElementFormatData != null), E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. pElementFormatData must not be null"); + SysTryReturn(NID_UI_CTRL, (elementParams.pCustomListItemImpl != null), E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. pCustomListItemImpl must not be null"); + SysTryReturn(NID_UI_CTRL, (elementParams.pTableViewItemBase != null), E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. pTableViewItemBase must not be null"); + + _BitmapElementView* pBitmapElementView = new (std::nothrow) _BitmapElementView(); + SysTryReturn(NID_UI_CTRL, (pBitmapElementView != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pBitmapElementView->Construct(elementParams.pElementFormatData->rect); + pBitmapElementView->AddTouchEventListener(*elementParams.pCustomListItemImpl); + elementParams.pTableViewItemBase->AddControl(*pBitmapElementView); + pBitmapElementView->SetModel(pBitmapElementModel); + elementParams.pTableViewItemBase->SetIndividualSelectionEnabled(pBitmapElementView, true); + + return E_SUCCESS; +} + +_CustomElementModel::_CustomElementModel(void) + : __pListElement(null) +{ +} + +_CustomElementModel::~_CustomElementModel(void) +{ +} + +ICustomListElement* +_CustomElementModel::GetData(void) const +{ + return __pListElement; +} + +result +_CustomElementModel::CreateElementView(_ElementViewParams& elementParams) +{ + _CustomElementModel* pCustomElementModel = dynamic_cast<_CustomElementModel*>(elementParams.pElementModel); + SysTryReturn(NID_UI_CTRL, (pCustomElementModel != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element model"); + + SysTryReturn(NID_UI_CTRL, (elementParams.pElementFormatData != null), E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. pElementFormatData must not be null"); + SysTryReturn(NID_UI_CTRL, (elementParams.pCustomListItemImpl != null), E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. pCustomListItemImpl must not be null"); + SysTryReturn(NID_UI_CTRL, (elementParams.pTableViewItemBase != null), E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. pTableViewItemBase must not be null"); + + _CustomElementView* pCustomElementView = new (std::nothrow) _CustomElementView(); + SysTryReturn(NID_UI_CTRL, (pCustomElementView != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pCustomElementView->Construct(elementParams.pElementFormatData->rect); + pCustomElementView->AddTouchEventListener(*elementParams.pCustomListItemImpl); + elementParams.pTableViewItemBase->AddControl(*pCustomElementView); + pCustomElementView->SetModel(pCustomElementModel); + elementParams.pTableViewItemBase->SetIndividualSelectionEnabled(pCustomElementView, true); + + return E_SUCCESS; +} + +_CheckElementModel::_CheckElementModel(void) + : __checkBoxStatus(CHECK_BOX_UNCHECKED) + , __pCheckBitmaps(null) + , __isDividerEnabled(false) + , __rightDivider(false) + , __leftDivider(false) +{ +} + +_CheckElementModel::~_CheckElementModel(void) +{ +} + +void +_CheckElementModel::SetCheckBoxStatus(_CheckBoxBitmapType checkBoxStatus) +{ + __checkBoxStatus = checkBoxStatus; +} + +_CheckBoxBitmapType +_CheckElementModel::GetCheckBoxStatus(void) +{ + return __checkBoxStatus; +} + +const _CheckBoxBitmapType +_CheckElementModel::GetCheckBoxStatus(void) const +{ + return __checkBoxStatus; +} + +void +_CheckElementModel::GetData(Rectangle& bitmapBounds, bool& isDividerEnabled, bool& leftDivider, bool& rightDivider) const +{ + bitmapBounds = __bitmapBounds; + isDividerEnabled = __isDividerEnabled; + leftDivider = __leftDivider; + rightDivider = __rightDivider; + + return; +} + +Bitmap* +_CheckElementModel::GetCheckBitmap(void) const +{ + return __pCheckBitmaps[__checkBoxStatus]; +} + +result +_CheckElementModel::CreateElementView(_ElementViewParams& elementParams) +{ + SysTryReturn(NID_UI_CTRL, (elementParams.pElementFormatData != null), E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. pElementFormatData must not be null"); + SysTryReturn(NID_UI_CTRL, (elementParams.pCustomListItemImpl != null), E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. pCustomListItemImpl must not be null"); + SysTryReturn(NID_UI_CTRL, (elementParams.pTableViewItemBase != null), E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. pTableViewItemBase must not be null"); + + if (elementParams.annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL) + { + Rectangle checkBoxBounds(elementParams.pElementFormatData->rect); + int dividerMargin = 0; + + GET_SHAPE_CONFIG(LIST::CHECK_ELEMENT_DIVIDER_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, dividerMargin); + + if (elementParams.isDividerEnabled) + { + checkBoxBounds.width += 2 * dividerMargin; + checkBoxBounds.y = 0; + checkBoxBounds.height = elementParams.pCustomListItemImpl->height; + } + + _CheckElementModel* pCheckElementModel = dynamic_cast<_CheckElementModel*>(elementParams.pElementModel); + SysTryReturn(NID_UI_CTRL, (pCheckElementModel != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element model"); + + pCheckElementModel->__pCheckBitmaps = elementParams.pCheckBitmaps; + pCheckElementModel->__isDividerEnabled = elementParams.isDividerEnabled; + + pCheckElementModel->__bitmapBounds.width = elementParams.pElementFormatData->rect.width; + pCheckElementModel->__bitmapBounds.height = elementParams.pElementFormatData->rect.height; + + if (elementParams.isDividerEnabled) + { + pCheckElementModel->__bitmapBounds.x = ((checkBoxBounds.x + dividerMargin) > elementParams.pElementFormatData->rect.x) ? (dividerMargin) : (0); + pCheckElementModel->__bitmapBounds.y = elementParams.pElementFormatData->rect.y; + + _CustomListItemImpl::SetDividerRequired(*elementParams.pElementFormat, elementParams.pElementFormatData->rect, pCheckElementModel->__leftDivider, pCheckElementModel->__rightDivider); + } + else + { + pCheckElementModel->__bitmapBounds.x = 0; + pCheckElementModel->__bitmapBounds.y = 0; + } + + _CheckElementView* pCheckElementView = new (std::nothrow) _CheckElementView(); + SysTryReturn(NID_UI_CTRL, (pCheckElementView != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pCheckElementView->Construct(checkBoxBounds); + pCheckElementView->AddTouchEventListener(*elementParams.pCustomListItemImpl); + elementParams.pTableViewItemBase->AddControl(*pCheckElementView); + pCheckElementView->SetModel(pCheckElementModel); + elementParams.pTableViewItemBase->SetIndividualSelectionEnabled(pCheckElementView, true); + } + + return E_SUCCESS; +} + +_ElementBaseView::_ElementBaseView(void) + : __pElementBaseModel(null) +{ +} + +_ElementBaseView::~_ElementBaseView(void) +{ +} + +int +_ElementBaseView::GetElementId(void) const +{ + SysTryReturn(NID_UI_CTRL, (__pElementBaseModel != null), -1, E_SYSTEM, "Element model not set"); + + return __pElementBaseModel->GetElementId(); +} + +_TextElementView::_TextElementView(TextObject* pText) + : __pText(pText) +{ +} + +_TextElementView::~_TextElementView(void) +{ + __pText->RemoveAll(); + + delete __pText; + __pText = null; + +} + +result +_TextElementView::OnDraw(void) +{ + result r = E_SUCCESS; + + _TextElementModel* __pTextElementModel = dynamic_cast<_TextElementModel*>(__pElementBaseModel); + SysTryReturn(NID_UI_CTRL, (__pTextElementModel), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occured. Failed to get _TextElementModel."); + + Canvas* pCanvas = GetCanvasN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pCanvas), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + String text; + Color textColor; + int textSize = 0; + + __pTextElementModel->GetData(text, textColor, textSize); + + if (IsEnabled() == false) + { + GET_COLOR_CONFIG(LIST::LIST_ELEMENT_TEXT_DISABLED_COLOR, textColor); + } + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + if (__pText) + { + Rectangle bounds = GetBounds(); + bounds.x = 0; + bounds.y = 0; + + _ListBaseImpl* pListBaseImpl = _CustomListItemImpl::GetListBaseImplFromElement(*this); + SysTryCatch(NID_UI_CTRL, (pListBaseImpl != null), , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get _ListBaseImpl instance."); + + Font font; + r = font.Construct(pListBaseImpl->GetCore().GetFont(), FONT_STYLE_PLAIN, textSize); + if (r != E_SUCCESS) + { + font.Construct(FONT_STYLE_PLAIN, textSize); + } + + __pText->SetFont(&font, 0, __pText->GetTextLength()); + __pText->SetForegroundColor(textColor, 0, __pText->GetTextLength()); + __pText->SetBounds(bounds); + __pText->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + } + + delete pCanvas; + return E_SUCCESS; + +CATCH: + delete pCanvas; + return E_SYSTEM; +} + +void +_TextElementView::SetModel(_TextElementModel* pTextElementModel) +{ + __pElementBaseModel = pTextElementModel; +} + +void +_TextElementView::StartTextSlide(void) +{ + if (IsEnabled() == false) + { + return; + } + + Canvas* pCanvas = GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, (pCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + if (__pText->GetTextLengthAt(0) < __pText->GetTextLength()) + { + __pText->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT); + __pText->Compose(); + __pText->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas)); + } + else + { + __pText->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + } + + delete pCanvas; +} + +void +_TextElementView::StopTextSlide(void) +{ + if (IsEnabled() == false) + { + return; + } + + Canvas* pCanvas = GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, (pCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + __pText->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE); + __pText->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __pText->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __pText->Compose(); + __pText->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas)); + + delete pCanvas; +} + +_BitmapElementView::_BitmapElementView(void) +{ +} + +_BitmapElementView::~_BitmapElementView(void) +{ +} + +result +_BitmapElementView::OnDraw(void) +{ + result r = E_SUCCESS; + Canvas* pCanvas = GetCanvasN(); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pCanvas), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _BitmapElementModel* __pBitmapElementModel = dynamic_cast<_BitmapElementModel*>(__pElementBaseModel); + SysTryReturn(NID_UI_CTRL, (__pBitmapElementModel), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occured. Failed to get _BitmapElementModel."); + + Bitmap *pBitmap = __pBitmapElementModel->GetData(); + + if (pBitmap) + { + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + if (pBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, GetWidth(), GetHeight()), *pBitmap); + } + else + { + pCanvas->DrawBitmap(Rectangle(0, 0, GetWidth(), GetHeight()), *pBitmap); + } + } + + delete pCanvas; + + return E_SUCCESS; +} + +void +_BitmapElementView::SetModel(_BitmapElementModel* pBitmapElementModel) +{ + __pElementBaseModel = static_cast<_ElementBaseModel*>(pBitmapElementModel); +} + +_CustomElementView::_CustomElementView(void) +{ +} + +_CustomElementView::~_CustomElementView(void) +{ +} + +result +_CustomElementView::OnDraw(void) +{ + result r = E_SUCCESS; + Canvas* pCanvas = GetCanvasN(); + + CustomListItemStatus itemStatus; + ICustomListElement* pListElement; + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pCanvas), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _CustomElementModel* __pCustomElementModel = dynamic_cast<_CustomElementModel*>(__pElementBaseModel); + SysTryCatch(NID_UI_CTRL, (__pCustomElementModel), , E_SYSTEM, "[E_SYSTEM] A system error has occured. Failed to get _CustomElementModel."); + + itemStatus = __pCustomElementModel->GetItemStatus(); + pListElement = __pCustomElementModel->GetData(); + + if (pListElement) + { + TableViewItemBase* pParentItem = dynamic_cast(GetParent()); + SysTryCatch(NID_UI_CTRL, pParentItem, , E_SYSTEM, "[E_SYSTEM] Failed to get parent item"); + + Color bgColor = pParentItem->GetBackgroundColor(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + pCanvas->SetBackgroundColor(bgColor); + pCanvas->Clear(); + pListElement->DrawElement(*pCanvas, Rectangle(0, 0, GetWidth(), GetHeight()), itemStatus); + } + + delete pCanvas; + return E_SUCCESS; + +CATCH: + delete pCanvas; + return E_SYSTEM; + +} + +void +_CustomElementView::SetModel(_CustomElementModel* pCustomElementModel) +{ + __pElementBaseModel = static_cast<_ElementBaseModel*>(pCustomElementModel); +} + +_CheckElementView::_CheckElementView(void) + : __pressedState(false) +{ + GET_COLOR_CONFIG(LIST::LISTITEM_DIVIDER_LEFT_HALF_COLOR, __leftHalfDividerColor); + GET_COLOR_CONFIG(LIST::LISTITEM_DIVIDER_RIGHT_HALF_COLOR, __rightHalfDividerColor); +} + +_CheckElementView::~_CheckElementView(void) +{ +} + +result +_CheckElementView::OnDraw(void) +{ + result r = E_SUCCESS; + Canvas* pCanvas = GetCanvasN(); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pCanvas), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Rectangle bitmapBounds; + bool isDividerEnabled = false; + bool leftDivider = false; + bool rightDivider = false; + Bitmap* pCheckBitmap = null; + + _CheckElementModel* __pCheckElementModel = dynamic_cast<_CheckElementModel*>(__pElementBaseModel); + SysTryCatch(NID_UI_CTRL, (__pCheckElementModel), , E_SYSTEM, "[E_SYSTEM] A system error has occured. Failed to get _CheckElementModel."); + + __pCheckElementModel->GetData(bitmapBounds, isDividerEnabled, leftDivider, rightDivider); + + if (isDividerEnabled) + { + _ListBaseImpl* pListBaseImpl = _CustomListItemImpl::GetListBaseImplFromElement(*this); + + if (pListBaseImpl) + { + Color bgColor; + + if (__pressedState == true) + { + GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_PRESSED, bgColor); + } + else + { + bgColor = pListBaseImpl->GetBackgroundColor(); + Color defaultColor(0, 0, 0, 0); + _ContainerImpl* pParent = null; + + while (bgColor == defaultColor) + { + pParent = pListBaseImpl->GetParent(); + + if (pParent) + { + bgColor = pParent->GetBackgroundColor(); + } + else + { + break; + } + } + } + + pCanvas->SetBackgroundColor(bgColor); + } + } + else + { + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + } + + pCheckBitmap = __pCheckElementModel->GetCheckBitmap(); + + pCanvas->Clear(); + pCanvas->DrawBitmap(bitmapBounds, *pCheckBitmap); + + if (isDividerEnabled) + { + int lineWidth = 0; + + GET_SHAPE_CONFIG(LIST::CHECK_ELEMENT_DIVIDER_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, lineWidth); + + Rectangle bounds = GetBounds(); + int dividerHeight = 0; + + dividerHeight = bounds.height / 2; + bounds.y = bounds.y + ((bounds.height - dividerHeight) / 2); + + if (leftDivider) + { + pCanvas->SetLineWidth(lineWidth / 2); + pCanvas->SetForegroundColor(__leftHalfDividerColor); + pCanvas->DrawLine(Point(0, bounds.y), Point(0, dividerHeight + bounds.y)); + + pCanvas->SetLineWidth(lineWidth / 2); + pCanvas->SetForegroundColor(__rightHalfDividerColor); + pCanvas->DrawLine(Point(1, bounds.y), Point(1, dividerHeight + bounds.y)); + } + + if (rightDivider) + { + pCanvas->SetLineWidth(lineWidth / 2); + pCanvas->SetForegroundColor(__leftHalfDividerColor); + pCanvas->DrawLine(Point(bounds.width - lineWidth, bounds.y), Point(bounds.width - lineWidth, dividerHeight + bounds.y)); + + pCanvas->SetLineWidth(lineWidth / 2); + pCanvas->SetForegroundColor(__rightHalfDividerColor); + pCanvas->DrawLine(Point(bounds.width - lineWidth + 1, bounds.y), Point(bounds.width - lineWidth + 1, dividerHeight + bounds.y)); + } + } + + delete pCanvas; + return E_SUCCESS; + +CATCH: + delete pCanvas; + return E_SYSTEM; +} + +void +_CheckElementView::SetModel(_CheckElementModel* pCheckElementModel) +{ + __pElementBaseModel = static_cast<_ElementBaseModel*>(pCheckElementModel); +} + +void +_CheckElementView::SetPressed(bool pressedState) +{ + __pressedState = pressedState; +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_CustomListImpl.cpp b/src/ui/controls/FUiCtrl_CustomListImpl.cpp new file mode 100644 index 0000000..f7f2d1e --- /dev/null +++ b/src/ui/controls/FUiCtrl_CustomListImpl.cpp @@ -0,0 +1,1004 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_CustomListImpl.cpp +* @brief This file contains implementation of _CustomListImpl class +*/ + +#include +#include +#include +#include "FUi_ResourceSizeInfo.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_CustomListItemFormatImpl.h" +#include "FUiCtrl_CustomListItemImpl.h" +#include "FUiCtrl_CustomListImpl.h" +#include "FUiCtrl_ListListener.h" +#include "FUiCtrl_ListItemBaseImpl.h" + +#include "FUiCtrl_TableViewItemProvider.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +extern const int INVALID_INDEX; + +_CustomListItemDataProvider::_CustomListItemDataProvider(_CustomListImpl* pList) + : __pList(pList) +{ +} + +_CustomListItemDataProvider::~_CustomListItemDataProvider(void) +{ +} + +int +_CustomListItemDataProvider::GetItemCount(void) +{ + SysTryReturn(NID_UI_CTRL, __pList, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly."); + return __pList->GetItemCount(); +} + +TableViewItem* +_CustomListItemDataProvider::CreateItem(int index, int itemWidth) +{ + SysTryReturn(NID_UI_CTRL, __pList, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly."); + + CustomListItem* pCustomListItem = __pList->GetCustomListItemAt(-1, index); + SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", index); + + _CustomListItemImpl* pCustomListItemImpl = null; + pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl; + SysTryReturn(NID_UI_CTRL, pCustomListItemImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. CustomListItem not yet constructed."); + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = pCustomListItem; + tableViewItemParams.width = itemWidth; + tableViewItemParams.itemId = pCustomListItemImpl->itemId; + tableViewItemParams.groupIndex = -1; + tableViewItemParams.itemIndex = index; + tableViewItemParams.isDividerEnabled = __pList->_isDividerEnabled; + tableViewItemParams.pCheckBitmaps = __pList->_pCheckBitmaps; + tableViewItemParams.annexStyle = __pList->_annexStyle; + + result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCustomListItemImpl->__pTableViewItemData->AddTouchEventListener(*__pList); + + return pCustomListItemImpl->__pTableViewItemData; +} + +bool +_CustomListItemDataProvider::DeleteItem(const int itemIndex, TableViewItem* pItem) +{ + _TableViewItemData* pTableViewItemData = dynamic_cast<_TableViewItemData*>(pItem); + delete pTableViewItemData; + + CustomListItem* pCustomListItem = __pList->GetCustomListItemAt(-1, itemIndex); + pCustomListItem->__pCustomListItemImpl->__pTableViewItemData = null; + + return true; +} + +void +_CustomListItemDataProvider::UpdateItem(int itemIndex, TableViewItem* pItem) +{ + //return true; +} + +int +_CustomListItemDataProvider::GetDefaultItemHeight(void) +{ + SysTryReturn(NID_UI_CTRL, __pList, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly."); + + CustomListItem* pCustomListItem = __pList->GetCustomListItemAt(-1, 0); + SysTryReturn(NID_UI_CTRL, pCustomListItem, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get first item"); + + _CustomListItemImpl* pCustomListItemImpl = null; + pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl; + SysTryReturn(NID_UI_CTRL, pCustomListItemImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. CustomListItem not yet constructed."); + + return pCustomListItemImpl->height; +} + +_CustomListImpl* +_CustomListImpl::GetInstance(CustomList& customList) +{ + return static_cast<_CustomListImpl*>(customList._pControlImpl); +} + +const _CustomListImpl* +_CustomListImpl::GetInstance(const CustomList& customList) +{ + return static_cast(customList._pControlImpl); +} + +_CustomListImpl::_CustomListImpl(Control* pList, _TableView* pCore) + : _ListBaseImpl(pList, pCore) + , __pItemProvider(null) +{ +} + +_CustomListImpl::~_CustomListImpl(void) +{ + RemoveAllFromItemsList(); + + __itemListenersList.RemoveAll(true); + + delete __pItemProvider; +} + +const char* +_CustomListImpl::GetPublicClassName(void) const +{ + return "CustomList"; +} + +const CustomList& +_CustomListImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +CustomList& +_CustomListImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _TableView& +_CustomListImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_TableView& +_CustomListImpl::GetCore(void) +{ + return static_cast<_TableView&>(_ControlImpl::GetCore()); +} + +_CustomListImpl* +_CustomListImpl::CreateCustomListImplN(CustomList* pControl, const Rectangle& bounds, bool itemDivider) +{ + result r = E_SUCCESS; + + r = GET_SIZE_INFO(CustomList).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _TableView* pCore = null; + _CustomListImpl* pImpl = null; + + pCore = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_SIMPLE, itemDivider, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl = new (std::nothrow) _CustomListImpl(pControl, pCore); + SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + ClearLastResult(); + + return pImpl; + +CATCH: + delete pCore; + return null; +} + +result +_CustomListImpl::InitializeBounds(const Rectangle& rect) +{ + result r = E_SUCCESS; + + r = InitializeBoundsProperties(GET_SIZE_INFO(CustomList), rect, GetCore().GetOrientation()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_CustomListImpl::AddCustomItemEventListener(const ICustomItemEventListener& listener) +{ + _ListListener* pListenersList = new (std::nothrow) _ListListener(); + SysTryReturn(NID_UI_CTRL, pListenersList, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pListenersList->pListener = const_cast(&listener); + + __itemListenersList.Add(*pListenersList); + + return E_SUCCESS; +} + +result +_CustomListImpl::RemoveCustomItemEventListener(const ICustomItemEventListener& listener) +{ + _ListListener* pListenersList = null; + result r = E_SYSTEM; + + int count = __itemListenersList.GetCount(); + + for (int itemListenerCount = 0; itemListenerCount < count; itemListenerCount++) + { + pListenersList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(itemListenerCount)); + + if ((pListenersList != null) && (pListenersList->pListener == &listener)) + { + r = E_SUCCESS; + __itemListenersList.RemoveAt(itemListenerCount, true); + break; + } + } + + return r; +} + +result +_CustomListImpl::Initialize(void) +{ + result r = E_SUCCESS; + + __pItemProvider = new (std::nothrow) _CustomListItemDataProvider(this); + SysTryReturnResult(NID_UI_CTRL, __pItemProvider != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryReturn(NID_UI_CTRL, style == TABLE_VIEW_STYLE_SIMPLE, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SIMPLE"); + + _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style); + SysTryReturn(NID_UI_CTRL, pItemProvider != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pItemProvider->SetSimpleStyleItemProvider(__pItemProvider); + + if (r != E_SUCCESS) + { + delete pItemProvider; + SysTryReturn(NID_UI_CTRL, false, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = GetCore().SetItemProvider(pItemProvider); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetCore().AddTableViewItemEventListener(*this); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_CustomListImpl::AddItem(const CustomListItem& item, int itemId) +{ + return InsertItemAt(GetItemCount(), item, itemId); +} + +result +_CustomListImpl::InsertItemAt(int index, const CustomListItem& item, int itemId) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index <= GetItemCount()), + E_INVALID_ARG, "The index %d is invalid.", index); + + item.__pCustomListItemImpl->itemId = itemId; + + r = InsertIntoItemsList(item, -1, index); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to insert an item."); + + if (GetCore().GetFirstDrawnFlag() == false) + { + r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] Propagating.",GetErrorMessage(r)); + } + + return r; + +CATCH: + RemoveFromItemsList(-1, index); + return E_SYSTEM; +} + +result +_CustomListImpl::SetItemAt(int index, const CustomListItem& item, int itemId) +{ + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), + E_INVALID_ARG, "The index %d is invalid.", index); + + SysTryReturnResult(NID_UI_CTRL, (IsItemNew(item) == true), E_SYSTEM, "A system error has occurred. The item already exists."); + + result r = E_SUCCESS; + + item.__pCustomListItemImpl->__pTableViewItemData = GetTableViewItemAt(-1, index); + + _CheckElementModel* pOldCheckElement = GetCheckElementAt(-1, index); + _CheckBoxBitmapType oldCheckStatus = (pOldCheckElement) ? (pOldCheckElement->GetCheckBoxStatus()) : CHECK_BOX_UNCHECKED; + + item.__pCustomListItemImpl->itemId = itemId; + + _CheckElementModel* pCheckElement = item.__pCustomListItemImpl->GetCheckElement(); + + if (pCheckElement) + { + pCheckElement->SetCheckBoxStatus(oldCheckStatus); + } + + r = SetInItemsList(item, -1, index); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to set an item."); + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = const_cast(&item); + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item."); + + if (GetCore().GetFirstDrawnFlag() == false) + { + r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Propagating."); + } + + return r; +} + +result +_CustomListImpl::RemoveItemAt(int index) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), + E_INVALID_ARG, "The index %d is invalid.", index); + + int groupIndex = 0; + + if (GetCore().GetFirstDrawnFlag() == false) + { + r = GetCore().RefreshTableView(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Propagating."); + } + + r = RemoveFromItemsList(-1, index); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to remove an item."); + + return r; +} + +result +_CustomListImpl::RemoveAllItems(void) +{ + result r = E_SUCCESS; + result finalResult = E_SUCCESS; + + for (int index = GetItemCount() - 1; index >= 0; index--) + { + r = RemoveItemAt(index); + + if (r != E_SUCCESS) + { + finalResult = r; + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Item at %d index not removed successfully.", index); + } + } + + return finalResult; +} + +result +_CustomListImpl::SetItemEnabled(int index, bool enable) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), + E_SYSTEM, "[E_SYSTEM] A system error has occurred. The index %d is invalid.", index); + + _CheckElementModel* pCheckElementModel = GetCheckElementAt(-1, index); + + if (pCheckElementModel) + { + if (enable) + { + if (pCheckElementModel->GetCheckBoxStatus() == CHECK_BOX_DISABLED) + { + pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_CHECKED); + } + } + else + { + if (pCheckElementModel->GetCheckBoxStatus() == CHECK_BOX_CHECKED) + { + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) + { + pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_DISABLED); + } + } + } + } + + r = GetCore().SetItemEnabled(0, index, enable); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + DrawItem(-1, index); + + return r; +} + +bool +_CustomListImpl::IsItemEnabled(int index) const +{ + return GetCore().IsItemEnabled(0, index); +} + +result +_CustomListImpl::SetItemChecked(int groupIndex, int itemIndex, bool check) +{ + return SetItemChecked(itemIndex, check); +} + +result +_CustomListImpl::SetItemChecked(int index, bool check) +{ + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The index %d is invalid.", index); + + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + if (IsItemChecked(index) == check) + { + return E_SUCCESS; + } + + SysTryReturnResult(NID_UI_CTRL, (IsItemEnabled(index)), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The List item is not enabled at index %d.", index); + + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + { + if (check) + { + if (_currentRadioIndex != -1) + { + _CheckElementModel* pOldCheckElementModel = GetCheckElementAt(-1, _currentRadioIndex); + SysTryReturnResult(NID_UI_CTRL, pOldCheckElementModel, E_SYSTEM, "A system error has occurred. tableViewItem is not constructed correctly."); + + pOldCheckElementModel->SetCheckBoxStatus(CHECK_BOX_UNCHECKED); + + _TableViewItemData* pOldRadioItem = GetTableViewItemAt(-1, _currentRadioIndex); + SysTryReturnResult(NID_UI_CTRL, pOldRadioItem, E_SYSTEM, "A system error has occurred. Failed to get item at %d index.", _currentRadioIndex); + + pOldRadioItem->Invalidate(true); + } + _currentRadioIndex = index; + } + else + { + _currentRadioIndex = -1; + } + } + + _CheckElementModel* pCheckElementModel = GetCheckElementAt(-1, index); + SysTryReturnResult(NID_UI_CTRL, pCheckElementModel, E_SYSTEM, "A system error has occurred. TableViewItem is not constructed correctly."); + + pCheckElementModel->SetCheckBoxStatus((_CheckBoxBitmapType)check); + + DrawItem(-1, index); + + return E_SUCCESS; +} + +bool +_CustomListImpl::IsItemChecked(int groupIndex, int subIndex) const +{ + return IsItemChecked(subIndex); +} + +bool +_CustomListImpl::IsItemChecked(int index) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), + false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. list style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL."); + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), + false, E_INVALID_ARG, "[E_INVALID_ARG] The index %d is invalid.", index); + + const _CheckElementModel* pCheckElement = GetCheckElementAt(-1, index); + SysTryReturn(NID_UI_CTRL, pCheckElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. CheckElement is not constructed properly."); + + return (bool)pCheckElement->GetCheckBoxStatus(); +} + +result +_CustomListImpl::SetAllItemsChecked(bool check) +{ + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_RADIO"); + + _CheckElementModel* pCheckElement = null; + + for (int index = 0; index < GetItemCount(); index++) + { + if (IsItemEnabled(index)) + { + pCheckElement = GetCheckElementAt(-1, index); + SysTryReturnResult(NID_UI_CTRL, (pCheckElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Checkbox element not created"); + + pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check); + } + } + + GetCore().Draw(); + + return E_SUCCESS; +} + +result +_CustomListImpl::RemoveAllCheckedItems(void) +{ + result r = E_SUCCESS; + result finalResult = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_RADIO"); + + for (int index = GetItemCount() -1; index >= 0; index--) + { + if (IsItemChecked(index)) + { + r = RemoveItemAt(index); + + if (r != E_SUCCESS) + { + finalResult = r; + SysLog(NID_UI_CTRL, "Item at %d index not removed successfully.", index); + } + } + } + + return finalResult; +} + +int +_CustomListImpl::GetFirstCheckedItemIndex(void) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + for (int index = 0; index < GetItemCount(); index++) + { + if (IsItemChecked(index)) + { + SetLastResult(E_SUCCESS); + return index; + } + } + SetLastResult(E_SUCCESS); + return INVALID_INDEX; +} + +int +_CustomListImpl::GetLastCheckedItemIndex(void) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + for (int index = GetItemCount() - 1; index >= 0; index--) + { + if (IsItemChecked(index)) + { + SetLastResult(E_SUCCESS); + return index; + } + } + SetLastResult(E_SUCCESS); + return INVALID_INDEX; +} + +int +_CustomListImpl::GetNextCheckedItemIndexAfter(int index) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), + INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The index %d is invalid.", index); + + for (int itemCount = index + 1; itemCount < GetItemCount(); itemCount++) + { + if (IsItemChecked(itemCount)) + { + SetLastResult(E_SUCCESS); + return itemCount; + } + } + SetLastResult(E_SUCCESS); + return INVALID_INDEX; +} + +int +_CustomListImpl::GetItemIndexFromItemId(int itemId) const +{ + for (int index = 0; index < GetItemCount(); index++) + { + const CustomListItem* pCustomListItem = GetCustomListItemAt(-1, index); + SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", index); + + SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", index); + + if (pCustomListItem->__pCustomListItemImpl->itemId == itemId) + { + SetLastResult(E_SUCCESS); + return index; + } + } + SetLastResult(E_SUCCESS); + return INVALID_INDEX; +} + +void +_CustomListImpl::ScrollToBottom(void) +{ + GetCore().SetBottomDrawnItemIndex(0 ,GetItemCount() - 1); + GetCore().Draw(); + return; +} +void +_CustomListImpl::ScrollToTop(void) +{ + GetCore().SetTopDrawnItemIndex(0,0); + GetCore().Draw(); + return; +} + +result +_CustomListImpl::ScrollToTop(int index) +{ + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), E_INVALID_ARG, "Invalid index(%d).", index); + + result r = GetCore().SetTopDrawnItemIndex(0, index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + return r; +} + +result +_CustomListImpl::RefreshItem(int index) +{ + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), E_INVALID_ARG, "Invalid index(%d).", index); + + int topItemIndex = -1; + int bottomItemIndex = -1; + int groupIndex = -1; + + GetCore().GetTopDrawnItemIndex(groupIndex, topItemIndex); + GetCore().GetBottomDrawnItemIndex(groupIndex, bottomItemIndex); + + SysTryReturnResult(NID_UI_CTRL, (index >= topItemIndex && index <= bottomItemIndex), E_INVALID_OPERATION, + "Index should be within drawn item range %d.", index); + + result r = E_SUCCESS; + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = GetCustomListItemAt(-1, index); + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item."); + + DrawItem(-1, index); + + return E_SUCCESS; +} + +int +_CustomListImpl::GetItemIdAt(int index) const +{ + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), + -1, E_INVALID_ARG, "[E_INVALID_ARG] The index %d is invalid.", index); + + const CustomListItem* pCustomListItem = GetCustomListItemAt(-1, index); + SysTryReturn(NID_UI_CTRL, pCustomListItem, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", index); + + SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", index); + + SetLastResult(E_SUCCESS); + return pCustomListItem->__pCustomListItemImpl->itemId; +} + +void +_CustomListImpl::OnTableViewItemStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + ItemStatus itemStatus = ITEM_HIGHLIGHTED; + + switch (status) + { + case TABLE_VIEW_ITEM_STATUS_SELECTED: + itemStatus = ITEM_SELECTED; + break; + case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED: + itemStatus = ITEM_HIGHLIGHTED; + break; + case TABLE_VIEW_ITEM_STATUS_CHECKED: + itemStatus = ITEM_CHECKED; + break; + case TABLE_VIEW_ITEM_STATUS_UNCHECKED: + itemStatus = ITEM_UNCHECKED; + break; + default: + SetLastResult(E_SYSTEM); + break; + } + + if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL)) + { + bool isChecked = IsItemChecked(itemIndex); + + if (isChecked) + { + itemStatus = ITEM_UNCHECKED; + } + else + { + itemStatus = ITEM_CHECKED; + } + + SetItemChecked(itemIndex, !isChecked); + } + + ProcessItemStateChange(-1, itemIndex, itemStatus); + return; +} + +void +_CustomListImpl::OnTableViewContextItemActivationStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_CustomListImpl::OnTableViewItemReordered(_TableView& tableView, int itemIndexFrom, int itemIndexTo) +{ + return; +} + +void +_CustomListImpl::OnGroupedTableViewGroupItemStateChanged(_TableView& tableView, int groupIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + return; +} + +void +_CustomListImpl::OnGroupedTableViewItemStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + return; +} + +void +_CustomListImpl::OnGroupedTableViewContextItemActivationStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_CustomListImpl::OnGroupedTableViewItemReordered(_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo) +{ + return; +} + +void +_CustomListImpl::OnSectionTableViewItemStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + return; +} + +void +_CustomListImpl::OnSectionTableViewContextItemActivationStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_CustomListImpl::OnTableViewItemSwept(_TableView& tableView, int groupIndex, int itemIndex, TableViewSweepDirection direction) +{ + return; +} + +void +_CustomListImpl::ProcessItemStateChange(int groupIndex, int index, int elementId, ItemStatus itemStatus) +{ + int itemId = GetItemIdAt(index); + + _ListListener* pListenerList = null; + ICustomItemEventListener* pEventListener = null; + + int count = __itemListenersList.GetCount(); + for (int listenerCount = 0; listenerCount < count; listenerCount++) + { + pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get Listener."); + + pEventListener = dynamic_cast(pListenerList->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get Listener."); + + pEventListener->OnItemStateChanged(GetPublic(), index, itemId, elementId, itemStatus); + } + SetLastResult(E_SUCCESS); + + return; +} + +void +_CustomListImpl::ProcessItemStateChange(int groupIndex, int index, ItemStatus itemStatus) +{ + int itemId = GetItemIdAt(index); + + _ListListener* pListenerList = null; + ICustomItemEventListener* pEventListener = null; + + int count = __itemListenersList.GetCount(); + for (int listenerCount = 0; listenerCount < count; listenerCount++) + { + pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get Listener."); + + pEventListener = dynamic_cast(pListenerList->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get Listener."); + + pEventListener->OnItemStateChanged(GetPublic(), index, itemId, itemStatus); + } + SetLastResult(E_SUCCESS); + + return; +} + +class _CustomListMaker + : public _UiBuilderControlMaker +{ +public: + _CustomListMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_CustomListMaker(){}; + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _CustomListMaker* pCustomListMaker = new (std::nothrow) _CustomListMaker(uibuilder); + return pCustomListMaker; + }; +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + CustomList* pCustomList = null; + + Tizen::Base::String elementString; + Color color; + Rectangle rect; + + CustomListStyle style = CUSTOM_LIST_STYLE_NORMAL; + bool isItemDivider = true; + + GetProperty(pControl, &pControlProperty); + + if (pControlProperty == null) + { + return null; + } + + pCustomList = new (std::nothrow) CustomList(); + if (pCustomList == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + + Tizen::Base::String styleString; + styleString = pControlProperty->GetStyle(); + + if (styleString.Equals(L"CUSTOM_LIST_STYLE_NORMAL", false)) + { + style = CUSTOM_LIST_STYLE_NORMAL; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO", false)) + { + style = CUSTOM_LIST_STYLE_RADIO; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK", false)) + { + style = CUSTOM_LIST_STYLE_MARK; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF", false)) + { + style = CUSTOM_LIST_STYLE_ONOFF; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER; + } + else + { + style = CUSTOM_LIST_STYLE_NORMAL; + } + + //Construct + if (pControl->GetElement(L"itemDivider", elementString)) + { + if (elementString.Equals(L"true", false)) + { + isItemDivider = true; + } + else + { + isItemDivider = false; + } + } + + r = pCustomList->Construct(rect, style, isItemDivider); + if (r != E_SUCCESS) + { + delete pCustomList; + return null; + } + + if (pControl->GetElement(L"textOfEmptyList", elementString)) + { + pCustomList->SetTextOfEmptyList(elementString); + } + + if (pControl->GetElement(L"colorOfEmptyListText", elementString)) + { + ConvertStringToColor(elementString, color); + pCustomList->SetTextColorOfEmptyList(color); + } + + return pCustomList; + } + +};// _ButtonMaker + +_CustomListRegister::_CustomListRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + + if (pUiBuilderControlTableManager) + { + pUiBuilderControlTableManager->RegisterControl(L"CustomList", _CustomListMaker::GetInstance); + } +} +_CustomListRegister::~_CustomListRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + + if (pUiBuilderControlTableManager) + { + pUiBuilderControlTableManager->UnregisterControl(L"CustomList"); + } +} +static _CustomListRegister CustomListRegisterToUiBuilder; +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_CustomListItemFormatImpl.cpp b/src/ui/controls/FUiCtrl_CustomListItemFormatImpl.cpp new file mode 100644 index 0000000..41d2332 --- /dev/null +++ b/src/ui/controls/FUiCtrl_CustomListItemFormatImpl.cpp @@ -0,0 +1,356 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_CustomListItemFormatImpl.cpp +* @brief This file contains implementation of _CustomListItemFormatImpl class +*/ + +#include +#include "FUiCtrl_CustomListItemFormatImpl.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ElementFormatData::_ElementFormatData(void) + : elementId(-1) + , textSize(0) + , enable(false) +{ +} + +_ElementFormatData::~_ElementFormatData(void) +{ +} + +_CustomListItemFormatImpl::_CustomListItemFormatImpl(void) +{ +} + +_CustomListItemFormatImpl::~_CustomListItemFormatImpl(void) +{ + elementFormatDataList.RemoveAll(true); +} + +_CustomListItemFormatImpl* +_CustomListItemFormatImpl::CreateInstanceN(void) +{ + _CustomListItemFormatImpl* pImpl = new (std::nothrow) _CustomListItemFormatImpl(); + SysTryReturn(NID_UI_CTRL, pImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pImpl; +} + +_ElementFormatData* +_CustomListItemFormatImpl::GetElementFormatById(int elementId) +{ + for (int elementCount = 0; elementCount < elementFormatDataList.GetCount(); elementCount++) + { + _ElementFormatData* pElementFormatData = dynamic_cast<_ElementFormatData*>(elementFormatDataList.GetAt(elementCount)); + SysTryReturn(NID_UI_CTRL, pElementFormatData, null, E_SYSTEM, "Invalid format data."); + + if (pElementFormatData->elementId == elementId) + { + return pElementFormatData; + } + } + + return null; +} + +_ElementFormatData* +_CustomListItemFormatImpl::CreateElementN(int elementId) +{ + _ElementFormatData* pElementFormatData = new (std::nothrow) _ElementFormatData(); + SysTryReturn(NID_UI_CTRL, pElementFormatData, null, E_OUT_OF_MEMORY, "The memory is insufficient."); + + pElementFormatData->elementId = elementId; + + GET_SHAPE_CONFIG(LIST::TEXT_ELEMENT_FONTSIZE_DEFAULT, _CONTROL_ORIENTATION_PORTRAIT, pElementFormatData->textSize); + + GET_COLOR_CONFIG(LIST::ELEMENT_TEXT_NORMAL, pElementFormatData->normalTextColor); + GET_COLOR_CONFIG(LIST::ELEMENT_TEXT_NORMAL, pElementFormatData->highlightedTextColor); + GET_COLOR_CONFIG(LIST::ELEMENT_TEXT_NORMAL, pElementFormatData->focusedTextColor); + + return pElementFormatData; +} + +result +_CustomListItemFormatImpl::AddElement(int elementId, const Rectangle& rect) +{ + _ElementFormatData* pElementFormatData = GetElementFormatById(elementId); + result r = E_SUCCESS; + + if (!pElementFormatData) + { + pElementFormatData = CreateElementN(elementId); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pElementFormatData, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = elementFormatDataList.Add(*pElementFormatData); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_SHAPE_CONFIG(LIST::TEXT_ELEMENT_FONTSIZE_DEFAULT, _CONTROL_ORIENTATION_PORTRAIT, pElementFormatData->textSize); + } + + pElementFormatData->rect = rect; + + return r; +} + +result +_CustomListItemFormatImpl::AddElement(int elementId, const Rectangle& rect, int textSize) +{ + _ElementFormatData* pElementFormatData = GetElementFormatById(elementId); + result r = E_SUCCESS; + + if (!pElementFormatData) + { + pElementFormatData = CreateElementN(elementId); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pElementFormatData, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = elementFormatDataList.Add(*pElementFormatData); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + pElementFormatData->rect = rect; + pElementFormatData->textSize = textSize; + + return r; +} + +result +_CustomListItemFormatImpl::AddElement(int elementId, const Rectangle& rect, int textSize, const Color& normalTextColor, const Color& focusedTextColor) +{ + _ElementFormatData* pElementFormatData = GetElementFormatById(elementId); + result r = E_SUCCESS; + + if (!pElementFormatData) + { + pElementFormatData = CreateElementN(elementId); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pElementFormatData, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = elementFormatDataList.Add(*pElementFormatData); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + pElementFormatData->rect = rect; + pElementFormatData->textSize = textSize; + + pElementFormatData->normalTextColor = normalTextColor; + pElementFormatData->focusedTextColor = focusedTextColor; + pElementFormatData->highlightedTextColor = normalTextColor; + + return r; +} + +result +_CustomListItemFormatImpl::AddElement(int elementId, const Rectangle& rect, int textSize, const Color& normalTextColor, const Color& focusedTextColor, const Color& highlightedTextColor) +{ + _ElementFormatData* pElementFormatData = GetElementFormatById(elementId); + result r = E_SUCCESS; + + if (!pElementFormatData) + { + pElementFormatData = CreateElementN(elementId); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pElementFormatData, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = elementFormatDataList.Add(*pElementFormatData); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + pElementFormatData->rect = rect; + pElementFormatData->textSize = textSize; + + pElementFormatData->normalTextColor = normalTextColor; + pElementFormatData->focusedTextColor = focusedTextColor; + pElementFormatData->highlightedTextColor = highlightedTextColor; + + return r; +} + +Rectangle +_CustomListItemFormatImpl::GetElement(int elementId) const +{ + _ElementFormatData* pElementFormatData = null; + for (int count = 0; count < elementFormatDataList.GetCount(); count++) + { + pElementFormatData = dynamic_cast<_ElementFormatData*>(const_cast(elementFormatDataList.GetAt(count))); + + if (pElementFormatData != null && pElementFormatData->elementId == elementId) + { + return pElementFormatData->rect; + } + } + + return Rectangle(0, 0, -1, -1); +} + +int +_CustomListItemFormatImpl::GetFirstElementId(void) +{ + _ElementFormatData* pElementFormatData = null; + + for (int count = 0; count < elementFormatDataList.GetCount(); count++) + { + pElementFormatData = dynamic_cast<_ElementFormatData*>(const_cast(elementFormatDataList.GetAt(count))); + if (pElementFormatData != null) + { + return pElementFormatData->elementId; + } + } + + return -1; +} + +int +_CustomListItemFormatImpl::GetFirstEnabledElementId(void) +{ + _ElementFormatData* pElementFormatData = null; + + for (int count = 0; count < elementFormatDataList.GetCount(); count++) + { + pElementFormatData = dynamic_cast<_ElementFormatData*>(const_cast(elementFormatDataList.GetAt(count))); + if (pElementFormatData != null && pElementFormatData->enable) + { + return pElementFormatData->elementId; + } + } + + return -1; +} + +int +_CustomListItemFormatImpl::GetNextElementId(int elementId) +{ + _ElementFormatData* pElementFormatData = null; + int nextElementId = -1; + bool found = false; + + for (int count = 0; count < elementFormatDataList.GetCount(); count++) + { + pElementFormatData = dynamic_cast<_ElementFormatData*>(elementFormatDataList.GetAt(count)); + if (pElementFormatData != null) + { + if (elementId == pElementFormatData->elementId) + { + found = true; + } + else if (found == true) + { + nextElementId = pElementFormatData->elementId; + break; + } + } + } + return nextElementId; +} + +int +_CustomListItemFormatImpl::GetNextEnabledElementId(int elementId) +{ + _ElementFormatData* pElementFormatData = null; + int nextEnabledElementId = -1; + bool found = false; + + for (int count = 0; count < elementFormatDataList.GetCount(); count++) + { + pElementFormatData = dynamic_cast<_ElementFormatData*>(elementFormatDataList.GetAt(count)); + if (pElementFormatData != null) + { + if (pElementFormatData->elementId == elementId) + { + found = true; + } + else if (pElementFormatData->enable && found == true) + { + nextEnabledElementId = pElementFormatData->elementId; + break; + } + } + } + + return nextEnabledElementId; +} + +int +_CustomListItemFormatImpl::GetPreviousEnabledElementId(int elementId) +{ + _ElementFormatData* pElementFormatData = null; + int prevEnabledElementId = -1; + + for (int count = 0; count < elementFormatDataList.GetCount(); count++) + { + pElementFormatData = dynamic_cast<_ElementFormatData*>(elementFormatDataList.GetAt(count)); + if (pElementFormatData != null) + { + if (pElementFormatData->elementId != elementId) + { + prevEnabledElementId = pElementFormatData->elementId; + } + else if (pElementFormatData->enable && pElementFormatData->elementId == elementId) + { + break; + } + } + } + + return prevEnabledElementId; +} + +bool +_CustomListItemFormatImpl::IsElementEventEnabled(int elementId) +{ + _ElementFormatData* pElementFormatData = null; + + for (int count = 0; count < elementFormatDataList.GetCount(); count++) + { + pElementFormatData = dynamic_cast<_ElementFormatData*>(const_cast(elementFormatDataList.GetAt(count))); + if (pElementFormatData != null && pElementFormatData->elementId == elementId) + { + return pElementFormatData->enable; + } + } + + return false; +} + +void +_CustomListItemFormatImpl::SetElementEventEnabled(int elementId, bool enable) +{ + _ElementFormatData* pElementFormatData = null; + + for (int count = 0; count < elementFormatDataList.GetCount(); count++) + { + pElementFormatData = dynamic_cast<_ElementFormatData*>(const_cast(elementFormatDataList.GetAt(count))); + if (pElementFormatData != null && pElementFormatData->elementId == elementId) + { + pElementFormatData->enable = enable; + } + } + + return; +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_CustomListItemImpl.cpp b/src/ui/controls/FUiCtrl_CustomListItemImpl.cpp new file mode 100644 index 0000000..1de425b --- /dev/null +++ b/src/ui/controls/FUiCtrl_CustomListItemImpl.cpp @@ -0,0 +1,1158 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_CustomListItemImpl.cpp + * @brief This file contains implementation of _CustomListItemImpl class + */ + +#include +#include +#include +#include "FUiCtrl_CustomListItemImpl.h" +#include "FUiCtrl_CustomListItemFormatImpl.h" +#include "FUiCtrl_PanelImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +const int INVALID_INDEX = -1; + +_TableViewItemData::_TableViewItemData(void) + : itemIndex(-1) + , groupIndex(-1) +{ +} + +_TableViewItemData::~_TableViewItemData(void) +{ +} + +void +_TableViewItemData::GetIndex(int& mainIndex, int& subIndex) const +{ + mainIndex = groupIndex; + subIndex = itemIndex; +} + +result +_TableViewItemData::SetEnabled(bool enable) +{ + Control* pControl = null; + + for (int count = 0; count < GetControlCount(); count++) + { + pControl = GetControl(count); + + if (pControl) + { + pControl->SetEnabled(enable); + } + } + + return E_SUCCESS; +} + +_TableViewGroupItemData::_TableViewGroupItemData(void) + : groupIndex(-1) +{ +} + +_TableViewGroupItemData::~_TableViewGroupItemData(void) +{ +} + +void +_TableViewGroupItemData::GetIndex(int& mainIndex, int& subIndex) const +{ + mainIndex = groupIndex; + subIndex = -1; +} + +result +_TableViewGroupItemData::SetEnabled(bool enable) +{ + Control* pControl = null; + + for (int count = 0; count < GetControlCount(); count++) + { + pControl = GetControl(count); + + if (pControl) + { + pControl->SetEnabled(enable); + } + } + + return E_SUCCESS; +} + +_CustomListItemImpl::_CustomListItemImpl(int itemHeight) + : height(itemHeight) + , itemId(LIST_ITEM_UNSPECIFIED_ID) + , __percentValue(0) + , __pTableViewItemData(null) + , __pTableViewGroupItemData(null) + , __pSubItemsList(null) + , __pTextSlideTimer(null) + , __isMoved(false) +{ + for (int i = 0; i <= CUSTOM_LIST_ITEM_STATUS_FOCUSED; i++) + { + __pBitmaps[i] = null; + } +} + +_CustomListItemImpl::~_CustomListItemImpl(void) +{ + for (int i = 0; i <= CUSTOM_LIST_ITEM_STATUS_FOCUSED; i++) + { + delete __pBitmaps[i]; + } + + elements.RemoveAll(true); +} + +_CustomListItemImpl* +_CustomListItemImpl::CreateInstanceN(int itemHeight) +{ + _CustomListItemImpl* pImpl = new (std::nothrow) _CustomListItemImpl(itemHeight); + SysTryReturn(NID_UI_CTRL, pImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + SetLastResult(E_SUCCESS); + return pImpl; +} + +int +_CustomListItemImpl::GetValue(void) const +{ + return __percentValue; +} + +void +_CustomListItemImpl::RemoveElement(int elementId) +{ + _ElementBaseModel* pBaseModel = GetElementModelById(elementId); + elements.Remove(*pBaseModel, true); +} + +result +_CustomListItemImpl::SetCheckBox(int elementId) +{ + _CheckElementModel* pCheckElement = null; + _ElementBaseModel* pBaseModel = GetElementModelById(elementId); + + if (pBaseModel && pBaseModel->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX) + { + return E_SYSTEM; + } + + pCheckElement = new (std::nothrow) _CheckElementModel(); + SysTryReturn(NID_UI_CTRL, pCheckElement, E_SYSTEM, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pCheckElement->_elementId = elementId; + pCheckElement->_elementType = LIST_ITEM_ELEMENT_TYPE_CHECKBOX; + + elements.Add(*pCheckElement); + return E_SUCCESS; +} + +result +_CustomListItemImpl::SetElement(int elementId, const Bitmap& normalBitmap, const Bitmap* pFocusedBitmap, const Bitmap* pHighlightedBitmap) +{ + _ElementBaseModel* pBaseModel = GetElementModelById(elementId); + if (pBaseModel && pBaseModel->_elementType != LIST_ITEM_ELEMENT_TYPE_BITMAP) + { + RemoveElement(elementId); + } + + result r = E_SUCCESS; + _BitmapElementModel* pBitmapElement = dynamic_cast<_BitmapElementModel*>(pBaseModel); + + if (!pBitmapElement) + { + pBitmapElement = new (std::nothrow) _BitmapElementModel(); + SysTryReturnResult(NID_UI_CTRL, pBitmapElement, E_OUT_OF_MEMORY, "Memory allocation failed."); + + pBitmapElement->_elementId = elementId; + pBitmapElement->_elementType = LIST_ITEM_ELEMENT_TYPE_BITMAP; + elements.Add(*pBitmapElement); + } + else + { + delete pBitmapElement->__pBitmap[CUSTOM_LIST_ITEM_STATUS_NORMAL]; + delete pBitmapElement->__pBitmap[CUSTOM_LIST_ITEM_STATUS_SELECTED]; + delete pBitmapElement->__pBitmap[CUSTOM_LIST_ITEM_STATUS_FOCUSED]; + } + + pBitmapElement->__pBitmap[CUSTOM_LIST_ITEM_STATUS_NORMAL] = _BitmapImpl::CloneN(normalBitmap); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (pFocusedBitmap) + { + pBitmapElement->__pBitmap[CUSTOM_LIST_ITEM_STATUS_FOCUSED] = _BitmapImpl::CloneN(*pFocusedBitmap); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + pBitmapElement->__pBitmap[CUSTOM_LIST_ITEM_STATUS_FOCUSED] = null; + } + + if (pHighlightedBitmap) + { + pBitmapElement->__pBitmap[CUSTOM_LIST_ITEM_STATUS_SELECTED] = _BitmapImpl::CloneN(*pHighlightedBitmap); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + pBitmapElement->__pBitmap[CUSTOM_LIST_ITEM_STATUS_SELECTED] = null; + } + + return E_SUCCESS; +} + +result +_CustomListItemImpl::SetElement(int elementId, const String& text) +{ + _ElementBaseModel* pBaseModel = GetElementModelById(elementId); + if (pBaseModel && pBaseModel->_elementType != LIST_ITEM_ELEMENT_TYPE_TEXT) + { + RemoveElement(elementId); + } + + _TextElementModel* pTextElement = dynamic_cast<_TextElementModel*>(pBaseModel); + + if (!pTextElement) + { + pTextElement = new (std::nothrow) _TextElementModel(text); + SysTryReturnResult(NID_UI_CTRL, pTextElement, E_OUT_OF_MEMORY, "Memory allocation failed."); + + pTextElement->_elementType = LIST_ITEM_ELEMENT_TYPE_TEXT; + pTextElement->_elementId = elementId; + + elements.Add(*pTextElement); + } + else + { + pTextElement->__text = text; + } + + return E_SUCCESS; +} + +result +_CustomListItemImpl::SetElement(int elementId, const Bitmap& normalBitmap, const Bitmap* pFocusedBitmap) +{ + return SetElement(elementId, normalBitmap, pFocusedBitmap, &normalBitmap); +} + +result +_CustomListItemImpl::SetElement(int elementId, const ICustomListElement& element) +{ + _ElementBaseModel* pBaseModel = GetElementModelById(elementId); + if (pBaseModel && pBaseModel->_elementType != LIST_ITEM_ELEMENT_TYPE_CUSTOM) + { + RemoveElement(elementId); + } + + _CustomElementModel* pCustomListElement = dynamic_cast<_CustomElementModel*>(pBaseModel); + + if (!pCustomListElement) + { + pCustomListElement = new (std::nothrow) _CustomElementModel(); + SysTryReturnResult(NID_UI_CTRL, pCustomListElement, E_OUT_OF_MEMORY, "Memory allocation failed."); + + pCustomListElement->_elementId = elementId; + pCustomListElement->_elementType = LIST_ITEM_ELEMENT_TYPE_CUSTOM; + pCustomListElement->__pListElement = const_cast(&element); + + elements.Add(*pCustomListElement); + } + else + { + pCustomListElement->__pListElement = const_cast(&element); + } + + return E_SUCCESS; +} + +result +_CustomListItemImpl::SetTextSliding(int elementId, bool enable) +{ + _TextElementModel* pTextElementModel = dynamic_cast<_TextElementModel*>(GetElementModelById(elementId)); + SysTryReturn(NID_UI_CTRL, pTextElementModel, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element data"); + + pTextElementModel->SetTextSliding(enable); + + return E_SUCCESS; +} + +void +_CustomListItemImpl::StartSliding(void) +{ + _TextElementModel* pTextElementModel = null; + + for (int i = 0; i < elements.GetCount(); i++) + { + pTextElementModel = dynamic_cast<_TextElementModel*>(const_cast(elements.GetAt(i))); + if (pTextElementModel && pTextElementModel->GetTextSliding()) + { + StartTextSlideTimer(); + break; + } + } +} + +void +_CustomListItemImpl::StopSliding(void) +{ + _TextElementModel* pTextElementModel = null; + + for (int i = 0; i < elements.GetCount(); i++) + { + pTextElementModel = dynamic_cast<_TextElementModel*>(const_cast(elements.GetAt(i))); + if (pTextElementModel && pTextElementModel->GetTextSliding()) + { + _TextElementView* pTextElementView = dynamic_cast<_TextElementView*>(GetElementViewById(pTextElementModel->_elementId)); + SysTryReturnVoidResult(NID_UI_CTRL, (pTextElementView != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pTextElementView->StopTextSlide(); + } + } + + StopTextSlideTimer(); +} + +void +_CustomListItemImpl::StartTextSlideTimer(void) +{ + result r = E_SUCCESS; + + if (__pTextSlideTimer == null) + { + __pTextSlideTimer = new (std::nothrow) Timer(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pTextSlideTimer != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pTextSlideTimer->Construct(*this); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), ,E_SYSTEM, "[E_SYSTEM] A system error has occured. Failed to construct sliding timer."); + } + else + { + __pTextSlideTimer->Cancel(); + } + + r = __pTextSlideTimer->Start(TEXT_SLIDING_TIMER_DURATION); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has occured. Failed to start sliding timer."); + + return; + +CATCH: + StopTextSlideTimer(); +} + +void +_CustomListItemImpl::StopTextSlideTimer(void) +{ + delete __pTextSlideTimer; + __pTextSlideTimer = null; +} + +void +_CustomListItemImpl::OnTimerExpired(Timer& timer) +{ + if (&timer == __pTextSlideTimer) + { + _TextElementModel* pTextElementModel = null; + bool timerRequired = false; + + for (int i = 0; i < elements.GetCount(); i++) + { + pTextElementModel = dynamic_cast<_TextElementModel*>(const_cast(elements.GetAt(i))); + if (pTextElementModel && pTextElementModel->GetTextSliding()) + { + _TextElementView* pTextElementView = dynamic_cast<_TextElementView*>(GetElementViewById(pTextElementModel->_elementId)); + SysTryReturnVoidResult(NID_UI_CTRL, (pTextElementView != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pTextElementView->StartTextSlide(); + timerRequired = true; + } + } + + if (timerRequired) + { + StartTextSlideTimer(); + } + } +} + +_ElementBaseModel* +_CustomListItemImpl::GetElementModelById(int elementId) const +{ + _ElementBaseModel* pElementBaseModel = null; + + for (int i = 0; i < elements.GetCount(); i++) + { + pElementBaseModel = dynamic_cast<_ElementBaseModel*>(const_cast(elements.GetAt(i))); + SysTryReturn(NID_UI_CTRL, pElementBaseModel, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element data"); + + if (pElementBaseModel->_elementId == elementId) + { + return pElementBaseModel; + } + } + + return null; +} + +_ElementBaseView* +_CustomListItemImpl::GetElementViewById(int elementId) const +{ + TableViewItemBase* pTableViewItemBase = null; + + if (__pTableViewItemData) + { + pTableViewItemBase = __pTableViewItemData; + } + else if (__pTableViewGroupItemData) + { + pTableViewItemBase = __pTableViewGroupItemData; + } + else + { + return null; + } + + _ElementBaseView* pElementBaseView = null; + int controlCount = pTableViewItemBase->GetControlCount(); + + for (int count = 0; count < controlCount; count++) + { + pElementBaseView = dynamic_cast<_ElementBaseView*>(const_cast(pTableViewItemBase->GetControl(count))); + SysTryReturn(NID_UI_CTRL, pElementBaseView, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element data"); + + if (pElementBaseView->GetElementId() == elementId) + { + return pElementBaseView; + } + } + + return null; +} + +void +_CustomListItemImpl::SetNormalItemBackgroundBitmap(const Bitmap& bitmap) +{ + SetBackgroundBitmap(bitmap, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + return; +} + +void +_CustomListItemImpl::SetFocusedItemBackgroundBitmap(const Bitmap& bitmap) +{ + SetBackgroundBitmap(bitmap, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED); + return; +} + +void +_CustomListItemImpl::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap) +{ + SetBackgroundBitmap(bitmap, TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED); + return; +} + +void +_CustomListItemImpl::SetBackgroundBitmap(const Bitmap& bitmap, TableViewItemDrawingStatus status) +{ + __pBitmaps[status] = _BitmapImpl::CloneN(bitmap); + + if (__pTableViewItemData) + { + bool returnValue = __pTableViewItemData->SetBackgroundBitmap(__pBitmaps[status], status); + result r = GetLastResult(); + + SysTryReturnVoidResult(NID_UI_CTRL, returnValue == true, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + SetLastResult(E_SUCCESS); + return; +} + +void +_CustomListItemImpl::UpdateBitmaps(void) +{ + for (int i = 0; i <= CUSTOM_LIST_ITEM_STATUS_FOCUSED; i++) + { + if (__pBitmaps[i]) + { + SetBackgroundBitmap(*__pBitmaps[i], (TableViewItemDrawingStatus)i); + } + } + + return; +} + +result +_CustomListItemImpl::SetValue(int value) +{ + __percentValue = value; + return E_SUCCESS; +} + +_CheckElementModel* +_CustomListItemImpl::GetCheckElement(void) +{ + _ElementBaseModel* pElementBase = null; + _CheckElementModel* pCheckElement = null; + + for (int i = 0; i < elements.GetCount(); i++) + { + pElementBase = dynamic_cast<_ElementBaseModel*>(elements.GetAt(i)); + SysTryReturn(NID_UI_CTRL, (pElementBase != null), null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element"); + + if (pElementBase->_elementType == LIST_ITEM_ELEMENT_TYPE_CHECKBOX) + { + pCheckElement = dynamic_cast<_CheckElementModel*>(pElementBase); + return pCheckElement; + } + } + + return null; +} + +result +_CustomListItemImpl::SetDividerRequired(LinkedList& elementFormatList, Rectangle& checkElementBounds, bool& leftDivider, bool& rightDivider) +{ + _ElementFormatData* pFormatData = null; + + for (int formatDataCount = elementFormatList.GetCount() - 1; formatDataCount >= 0; formatDataCount--) + { + pFormatData = dynamic_cast<_ElementFormatData*>(elementFormatList.GetAt(formatDataCount)); + SysTryReturnResult(NID_UI_CTRL, (pFormatData != null), E_SYSTEM, "A system error has occurred. Failed to get format data"); + + if (pFormatData->rect.x < checkElementBounds.x) + { + leftDivider = true; + } + else if (pFormatData->rect.x > checkElementBounds.x + checkElementBounds.width) + { + rightDivider = true; + } + } + + return E_SUCCESS; +} + +result +_CustomListItemImpl::CreateTableViewItem(_TableViewItemParams& tableViewItemParams) +{ + TableViewItemBase* pTableViewItemBase = null; + + if (tableViewItemParams.itemIndex == -1) + { + pTableViewItemBase = CreateTableViewGroupItemN(tableViewItemParams); + } + else + { + pTableViewItemBase = CreateTableViewItemN(tableViewItemParams); + } + + SysTryReturnResult(NID_UI_CTRL, (pTableViewItemBase != null), E_SYSTEM, "A system error has occurred. Failed to create tableViewItem"); + + _CustomListItemImpl* pCustomListItemImpl = GetItemImpl(tableViewItemParams.pItem); + SysTryReturnResult(NID_UI_CTRL, (pCustomListItemImpl != null), E_INVALID_ARG, "Invalid argument is used. CustomListItem is null"); + + _CustomListItemFormatImpl* pFormatImpl = GetFormatImpl(tableViewItemParams.pItem); + SysTryReturnResult(NID_UI_CTRL, (pFormatImpl != null), E_INVALID_ARG, "Invalid argument is used. CustomListItemFormat is null"); + + LinkedList* pElementFormat = &pFormatImpl->elementFormatDataList; + LinkedList* pElements = &pCustomListItemImpl->elements; + _ElementBaseModel* pElementBase = null; + + for (int elementCount = pElements->GetCount() - 1; elementCount >= 0; elementCount--) + { + pElementBase = dynamic_cast<_ElementBaseModel*>(pElements->GetAt(elementCount)); + SysTryCatch(NID_UI_CTRL, (pElementBase != null), , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element."); + + if (!pCustomListItemImpl->IsElementIdValid(pElementFormat, pElementBase->_elementId)) + { + pElements->RemoveAt(elementCount, true); + SysLog(NID_UI_CTRL, "The provided elementId is not present in CustomListItemFormat."); + continue; + } + + result r = E_SUCCESS; + + _ElementViewParams elementParams; + elementParams.pTableViewItemBase = pTableViewItemBase; + elementParams.pElementModel = pElementBase; + elementParams.pElementFormatData = pFormatImpl->GetElementFormatById(pElementBase->_elementId); + elementParams.isDividerEnabled = tableViewItemParams.isDividerEnabled; + elementParams.annexStyle = tableViewItemParams.annexStyle; + elementParams.pCustomListItemImpl = pCustomListItemImpl; + elementParams.pCheckBitmaps = tableViewItemParams.pCheckBitmaps; + elementParams.pElementFormat = pElementFormat; + + r = pElementBase->CreateElementView(elementParams); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to create element view."); + } + + return E_SUCCESS; + +CATCH: + if (tableViewItemParams.itemIndex == -1) + { + _TableViewGroupItemData* pTableViewGroupItemData = dynamic_cast<_TableViewGroupItemData*>(pTableViewItemBase); + delete pTableViewGroupItemData; + } + else + { + _TableViewItemData* pTableViewItemData = dynamic_cast<_TableViewItemData*>(pTableViewItemBase); + delete pTableViewItemData; + } + + return E_SYSTEM; +} + +TableViewItemBase* +_CustomListItemImpl::CreateTableViewGroupItemN(_TableViewItemParams& tableViewItemParams) +{ + result r = E_SUCCESS; + + _TableViewGroupItemData* pTableViewGroupItemData = null; + + pTableViewGroupItemData = new (std::nothrow) _TableViewGroupItemData(); + SysTryReturn(NID_UI_CTRL, pTableViewGroupItemData, null, E_SYSTEM, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pTableViewGroupItemData->Construct(Dimension(tableViewItemParams.width, tableViewItemParams.pItem->__pCustomListItemImpl->height)); + SysTryCatch(NID_UI_CTRL, pTableViewGroupItemData, , E_SYSTEM, "[%s] Failed to create an item.", GetErrorMessage(r)); + + + pTableViewGroupItemData->groupIndex = tableViewItemParams.groupIndex; + tableViewItemParams.pItem->__pCustomListItemImpl->__pTableViewGroupItemData = pTableViewGroupItemData; + + tableViewItemParams.pItem->__pCustomListItemImpl->UpdateBitmaps(); + + return pTableViewGroupItemData; + +CATCH: + delete pTableViewGroupItemData; + return null; +} + +TableViewItemBase* +_CustomListItemImpl::CreateTableViewItemN(_TableViewItemParams& tableViewItemParams) +{ + result r = E_SUCCESS; + _TableViewItemData* pTableViewItemData = null; + + pTableViewItemData = new (std::nothrow) _TableViewItemData(); + SysTryReturn(NID_UI_CTRL, pTableViewItemData, null, E_SYSTEM, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pTableViewItemData->Construct(Dimension(tableViewItemParams.width, tableViewItemParams.pItem->__pCustomListItemImpl->height), TABLE_VIEW_ANNEX_STYLE_NORMAL); + SysTryCatch(NID_UI_CTRL, pTableViewItemData, , E_SYSTEM, "[%s] Failed to create an item.", GetErrorMessage(r)); + + pTableViewItemData->groupIndex = tableViewItemParams.groupIndex; + pTableViewItemData->itemIndex = tableViewItemParams.itemIndex; + tableViewItemParams.pItem->__pCustomListItemImpl->__pTableViewItemData = pTableViewItemData; + + tableViewItemParams.pItem->__pCustomListItemImpl->UpdateBitmaps(); + + return pTableViewItemData; + +CATCH: + delete pTableViewItemData; + return null; +} + +result +_CustomListItemImpl::SetElementData(_ElementBaseModel* pElement) +{ + SysTryReturnResult(NID_UI_CTRL, (pElement != null), E_INVALID_ARG, "Invalid argument used. pElement must not be null."); + + _ElementBaseModel* pTempElement = null; + int i = 0; + result r = E_SUCCESS; + + for (; i < elements.GetCount(); i++) + { + pTempElement = dynamic_cast<_ElementBaseModel*>(elements.GetAt(i)); + SysTryReturnResult(NID_UI_CTRL, pTempElement, E_SYSTEM, "A system error has occurred. Failed to get element"); + + if (pElement->_elementId == pTempElement->_elementId) + { + break; + } + } + + if (i != elements.GetCount()) + { + r = elements.SetAt(*pElement, i, true); + } + else + { + r = elements.Add(*pElement); + } + + return r; +} + +bool +_CustomListItemImpl::IsElementIdValid(LinkedList* pElementFormat, int elementId) const +{ + for (int elementFormatDataCount = pElementFormat->GetCount() - 1; elementFormatDataCount >= 0; elementFormatDataCount--) + { + _ElementFormatData* pElementFormatData = dynamic_cast<_ElementFormatData*>(const_cast(pElementFormat->GetAt(elementFormatDataCount))); + + if (pElementFormatData != null && pElementFormatData->elementId == elementId) + { + return true; + } + } + + return false; +} + +_CustomListItemFormatImpl* +_CustomListItemImpl::GetFormatImpl(CustomListItem* pItem) +{ + SysTryReturn(NID_UI_CTRL, (pItem != null), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. CustomListItem is null"); + + CustomListItemFormat* pFormat = pItem->__pCustomListItemFormat; + SysTryReturn(NID_UI_CTRL, (pFormat != null), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. CustomListItemFormat is null"); + + return pItem->__pCustomListItemFormat->__pCustomListItemFormatImpl; +} + +_CustomListItemImpl* +_CustomListItemImpl::GetItemImpl(CustomListItem* pItem) +{ + SysTryReturn(NID_UI_CTRL, (pItem != null), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. CustomListItem is null"); + + return pItem->__pCustomListItemImpl; +} + +result +_CustomListItemImpl::UpdateTableViewItem(_TableViewItemUpdateParams& updateParams) +{ + _CustomListItemImpl* pCustomListItemImpl = GetItemImpl(updateParams.pItem); + SysTryReturnResult(NID_UI_CTRL, (pCustomListItemImpl != null), E_SYSTEM, "Invalid argument used. __pCustomListItemImpl must not be null"); + + TableViewItemBase* pTableViewItemBase = null; + + if (pCustomListItemImpl->__pTableViewItemData) + { + pTableViewItemBase = pCustomListItemImpl->__pTableViewItemData; + } + else + { + pTableViewItemBase = pCustomListItemImpl->__pTableViewGroupItemData; + } + + SysTryReturnResult(NID_UI_CTRL, (pTableViewItemBase != null), E_SYSTEM, "A system error has occurred. Failed to create tableViewItem"); + + _CustomListItemFormatImpl* pFormatImpl = GetFormatImpl(updateParams.pItem); + SysTryReturnResult(NID_UI_CTRL, (pFormatImpl != null), E_SYSTEM, "Invalid argument used. Item format must not be null"); + + LinkedList* pElementFormat = &pFormatImpl->elementFormatDataList; + _ElementBaseModel* pElementBase = null; + bool isValidElementId = false; + + for (int i = 0; i < pTableViewItemBase->GetControlCount(); i++) + { + Control* pControl = dynamic_cast(pTableViewItemBase->GetControl(i)); + pTableViewItemBase->SetIndividualSelectionEnabled(pControl, false); + } + + pTableViewItemBase->RemoveAllControls(); + + for (int elementCount = pCustomListItemImpl->elements.GetCount() -1; elementCount >= 0; elementCount--) + { + isValidElementId = false; + + pElementBase = dynamic_cast<_ElementBaseModel*>(pCustomListItemImpl->elements.GetAt(elementCount)); + SysTryReturnResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "Invalid element."); + + if (!pCustomListItemImpl->IsElementIdValid(pElementFormat, pElementBase->_elementId)) + { + pCustomListItemImpl->elements.RemoveAt(elementCount, true); + SysLog(NID_UI_CTRL, "The provided elementId is not present in CustomListItemFormat."); + continue; + } + + result r = E_SUCCESS; + + _ElementViewParams elementParams; + elementParams.pTableViewItemBase = pTableViewItemBase; + elementParams.pElementModel = pElementBase; + elementParams.pElementFormatData = pFormatImpl->GetElementFormatById(pElementBase->_elementId); + elementParams.isDividerEnabled = updateParams.isDividerEnabled; + elementParams.annexStyle = updateParams.annexStyle; + elementParams.pCustomListItemImpl = pCustomListItemImpl; + elementParams.pCheckBitmaps = updateParams.pCheckBitmaps; + elementParams.pElementFormat = pElementFormat; + + r = pElementBase->CreateElementView(elementParams); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to create element view."); + } + + pCustomListItemImpl->UpdateBitmaps(); + + return E_SUCCESS; +} + +void +_CustomListItemImpl::OnTouchDoublePressed (const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + return; +} + +void +_CustomListItemImpl::OnTouchFocusIn (const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + return; +} + +void +_CustomListItemImpl::OnTouchFocusOut (const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + if (source.IsEnabled() == false || touchInfo.IsFlicked()) + { + return; + } + + _ElementBaseView* pCurrentElement = dynamic_cast<_ElementBaseView*>(const_cast(&source)); + SysTryReturnVoidResult(NID_UI_CTRL, (pCurrentElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element"); + + _ListBaseImpl* pListBaseImpl = GetListBaseImplFromElement(source); + SysTryReturnVoidResult(NID_UI_CTRL, (pListBaseImpl != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + UpdateElements(source, pCurrentElement->GetElementId(), false, pListBaseImpl->_isDividerEnabled); + + UpdateItemBackground(source, pListBaseImpl->_isDividerEnabled); + + return; +} + +void +_CustomListItemImpl::OnTouchLongPressed (const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + return; +} + +void +_CustomListItemImpl::OnTouchMoved (const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + __isMoved = true; + return; +} + +void +_CustomListItemImpl::OnTouchPressed (const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + if (source.IsEnabled() == false || touchInfo.IsFlicked()) + { + return; + } + _ElementBaseView* pCurrentElement = dynamic_cast<_ElementBaseView*>(const_cast(&source)); + SysTryReturnVoidResult(NID_UI_CTRL, (pCurrentElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element"); + + _ListBaseImpl* pListBaseImpl = GetListBaseImplFromElement(source); + SysTryReturnVoidResult(NID_UI_CTRL, (pListBaseImpl != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + int elementId = pCurrentElement->GetElementId(); + + UpdateElements(source, elementId, true, pListBaseImpl->_isDividerEnabled); + + UpdateItemBackground(source, pListBaseImpl->_isDividerEnabled); +} + +void +_CustomListItemImpl::OnTouchReleased (const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + if (source.IsEnabled() == false || touchInfo.IsFlicked()) + { + return; + } + _ElementBaseView* pCurrentElement = dynamic_cast<_ElementBaseView*>(const_cast(&source)); + SysTryReturnVoidResult(NID_UI_CTRL, (pCurrentElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element"); + + _ListBaseImpl* pListBaseImpl = GetListBaseImplFromElement(source); + SysTryReturnVoidResult(NID_UI_CTRL, (pListBaseImpl != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + _CheckElementView* pCheckElementView = dynamic_cast<_CheckElementView*>(const_cast(&source)); + + UpdateElements(source, pCurrentElement->GetElementId(), false, pListBaseImpl->_isDividerEnabled); + + if (__isMoved == false) + { + int groupIndex = -1; + int itemIndex = -1; + + GetIndexFromElement(source, groupIndex, itemIndex); + + if (((pListBaseImpl->_isDividerEnabled) && (pCheckElementView)) || (!pListBaseImpl->_isDividerEnabled)) + { + pListBaseImpl->SetItemChecked(groupIndex, itemIndex, !pListBaseImpl->IsItemChecked(groupIndex, itemIndex)); + } + + UpdateItemBackground(source, pListBaseImpl->_isDividerEnabled); + + bool elementIdEnabled = IsElementEventEnabled(source); + if (!elementIdEnabled) + { + pListBaseImpl->ProcessItemStateChange(groupIndex, itemIndex, ITEM_SELECTED); + } + else + { + pListBaseImpl->ProcessItemStateChange(groupIndex, itemIndex, pCurrentElement->GetElementId(), ITEM_SELECTED); + } + } + else + { + UpdateItemBackground(source, pListBaseImpl->_isDividerEnabled); + } + + __isMoved = false; + + return; +} + +_ElementBaseView* +_CustomListItemImpl::GetViewById(int elementId) const +{ + TableViewItemBase* pTableViewItemBase = null; + + if (__pTableViewItemData) + { + pTableViewItemBase = __pTableViewItemData; + } + else if (__pTableViewGroupItemData) + { + pTableViewItemBase = __pTableViewGroupItemData; + } + else + { + return null; + } + + _ElementBaseView* pElementBaseView = null; + + for (int controlIndex = 0; controlIndex < pTableViewItemBase->GetControlCount(); controlIndex++) + { + pElementBaseView = dynamic_cast<_ElementBaseView*>(pTableViewItemBase->GetControl(controlIndex)); + SysTryReturn(NID_UI_CTRL, (pElementBaseView != null), null, E_SYSTEM, "[E_SYSTEM] Invalid Element added to item"); + + if (pElementBaseView->GetElementId() == elementId) + { + SetLastResult(E_SUCCESS); + return pElementBaseView; + } + } + + SetLastResult(E_SYSTEM); + return null; +} + +_ListBaseImpl* +_CustomListItemImpl::GetListBaseImplFromElement(const Control& element) +{ + _ElementBaseView* pCurrentElement = dynamic_cast<_ElementBaseView*>(const_cast(&element)); + SysTryReturn(NID_UI_CTRL, (pCurrentElement != null), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. source is not an element"); + + TableViewItemBase* pTableViewItemBase = dynamic_cast(pCurrentElement->GetParent()); + SysTryReturn(NID_UI_CTRL, (pTableViewItemBase != null), null, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. source is not an element"); + + Control* pControl = dynamic_cast(pTableViewItemBase->GetParent()); + SysTryReturn(NID_UI_CTRL, (pControl != null), null, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. source is not an element"); + + _ListBaseImpl* pListBaseImpl = static_cast<_ListBaseImpl*>(_ControlImpl::GetInstance(*pControl)); + SysTryReturn(NID_UI_CTRL, (pListBaseImpl != null), null, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. source is not an element"); + + return pListBaseImpl; +} + +CustomListItem* +_CustomListItemImpl::GetItemFromElement(const Control& source) const +{ + _ElementBaseView* pCurrentElement = dynamic_cast<_ElementBaseView*>(const_cast(&source)); + SysTryReturn(NID_UI_CTRL, (pCurrentElement != null), null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element"); + + _ITableViewBaseItemData* pBaseData = dynamic_cast<_ITableViewBaseItemData*>(pCurrentElement->GetParent()); + SysTryReturn(NID_UI_CTRL, (pBaseData != null), null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + _ListBaseImpl* pListBaseImpl = GetListBaseImplFromElement(source); + SysTryReturn(NID_UI_CTRL, (pListBaseImpl != null), null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + int groupIndex = -1; + int itemIndex = -1; + + pBaseData->GetIndex(groupIndex, itemIndex); + + CustomListItem* pCustomListItem = pListBaseImpl->GetCustomListItemAt(groupIndex, itemIndex - pListBaseImpl->GetTopItemIndex(groupIndex)); + SysTryReturn(NID_UI_CTRL, (pCustomListItem != null), null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + return pCustomListItem; +} + +void +_CustomListItemImpl::GetIndexFromElement(const Control& source, int& groupIndex, int& itemIndex) const +{ + _ElementBaseView* pCurrentElement = dynamic_cast<_ElementBaseView*>(const_cast(&source)); + SysTryReturnVoidResult(NID_UI_CTRL, (pCurrentElement != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element"); + + _ITableViewBaseItemData* pBaseData = dynamic_cast<_ITableViewBaseItemData*>(pCurrentElement->GetParent()); + SysTryReturnVoidResult(NID_UI_CTRL, (pBaseData != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + _ListBaseImpl* pListBaseImpl = GetListBaseImplFromElement(source); + SysTryReturnVoidResult(NID_UI_CTRL, (pListBaseImpl != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + pBaseData->GetIndex(groupIndex, itemIndex); +} + +bool +_CustomListItemImpl::IsElementEventEnabled(const Control& element) +{ + CustomListItem* pCustomListItem = GetItemFromElement(element); + SysTryReturn(NID_UI_CTRL, (pCustomListItem != null), false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + CustomListItemFormat* pFormat = pCustomListItem->__pCustomListItemFormat; + SysTryReturn(NID_UI_CTRL, (pFormat != null), false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + _ElementBaseView* pCurrentElement = dynamic_cast<_ElementBaseView*>(const_cast(&element)); + SysTryReturn(NID_UI_CTRL, (pCurrentElement != null), false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element"); + + return pFormat->__pCustomListItemFormatImpl->IsElementEventEnabled(pCurrentElement->GetElementId()); +} + +void +_CustomListItemImpl::UpdateElements(const Control &source, int elementId, bool isPressed, bool isDividerEnabled) +{ + bool elementIdEnabled = IsElementEventEnabled(source); + CustomListItemStatus customListItemStatus; + + _CheckElementView* pCheckElementView = dynamic_cast<_CheckElementView*>(const_cast(&source)); + + if (isPressed == true) + { + customListItemStatus = CUSTOM_LIST_ITEM_STATUS_FOCUSED; + StartSliding(); + } + else + { + customListItemStatus = CUSTOM_LIST_ITEM_STATUS_NORMAL; + StopSliding(); + } + + int elementCount = elements.GetCount(); + + if (elementIdEnabled) + { + if (pCheckElementView) + { + GetCheckElement()->HandleElementEvent(customListItemStatus); + pCheckElementView->SetPressed(isPressed); + } + else + { + _ElementBaseModel* pElementBaseModel = GetElementModelById(elementId); + SysTryReturnVoidResult(NID_UI_CTRL, (pElementBaseModel != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + pElementBaseModel->HandleElementEvent(customListItemStatus); + } + } + else + { + if (isDividerEnabled) + { + if (pCheckElementView) + { + GetCheckElement()->HandleElementEvent(customListItemStatus); + pCheckElementView->SetPressed(isPressed); + } + else + { + for (int i = 0; i < elementCount; i++) + { + _ElementBaseModel* pElementBase = dynamic_cast<_ElementBaseModel*>(elements.GetAt(i)); + SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element"); + + if (pElementBase->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX) + { + pElementBase->HandleElementEvent(customListItemStatus); + } + } + } + } + else + { + for (int i = 0; i < elementCount; i++) + { + _ElementBaseModel* pElementBase = dynamic_cast<_ElementBaseModel*>(elements.GetAt(i)); + SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element"); + + pElementBase->HandleElementEvent(customListItemStatus); + } + } + } +} + +void +_CustomListItemImpl::UpdateItemBackground(const Control& element, bool isDividerEnabled) +{ + TableViewItemBase* pTableViewItemBase = dynamic_cast(element.GetParent()); + SysTryReturnVoidResult(NID_UI_CTRL, (pTableViewItemBase != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + _CheckElementView* pCheckElementView = dynamic_cast<_CheckElementView*>(const_cast(&element)); + + bool elementIdEnabled = IsElementEventEnabled(element); + if (!elementIdEnabled) + { + if (isDividerEnabled) + { + if (!pCheckElementView) + { + pTableViewItemBase->SetBackgroundColor(Color(0, 0, 0, 0)); + } + } + else + { + pTableViewItemBase->SetBackgroundColor(Color(0, 0, 0, 0)); + } + } + + pTableViewItemBase->Invalidate(true); +} + +void +_CustomListItemImpl::DeleteCustomListItem(Tizen::Base::Object* pObj) +{ + CustomListItem* pCustomListItem = dynamic_cast(pObj); + delete pCustomListItem; +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DatePickerImpl.cpp b/src/ui/controls/FUiCtrl_DatePickerImpl.cpp new file mode 100644 index 0000000..b7fd824 --- /dev/null +++ b/src/ui/controls/FUiCtrl_DatePickerImpl.cpp @@ -0,0 +1,393 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DatePickerImpl.cpp + * @brief This is the implementation file for the _DatePickerImpl class. + */ + +#include +#include +#include "FUiCtrl_DatePickerImpl.h" +#include "FUiCtrl_FrameImpl.h" +#include "FUiCtrl_DateTimePicker.h" +#include "FUi_ControlImplManager.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_Form.h" + +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Base; +using namespace Tizen::System; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Ui { namespace Controls +{ + +Dimension +_DatePickerImpl::DatePickerSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + Dimension pickerSize(0, 0); + Dimension screenSize(0, 0); + + screenSize = _ControlManager::GetInstance()->GetScreenSize(); + pickerSize = screenSize; + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + pickerSize.width = screenSize.height; + pickerSize.height = screenSize.width; + } + + return pickerSize; +} + +Dimension +_DatePickerImpl::DatePickerSizeInfo::GetDefaultMaximumSize(_ControlOrientation orientation) const +{ + Dimension pickerSize(0, 0); + Dimension screenSize(0, 0); + + screenSize = _ControlManager::GetInstance()->GetScreenSize(); + pickerSize = screenSize; + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + pickerSize.width = screenSize.height; + pickerSize.height = screenSize.width; + } + + return pickerSize; +} + +_DatePickerImpl::_DatePickerImpl(DatePicker* pPublic, _DateTimePicker* pCore) + : _WindowImpl(pPublic, pCore) + , __pPublicDateTimeChangeEvent(null) +{ +} + +_DatePickerImpl::~_DatePickerImpl(void) +{ + if (__pPublicDateTimeChangeEvent != null) + { + delete __pPublicDateTimeChangeEvent; + __pPublicDateTimeChangeEvent = null; + } +} + +_DatePickerImpl* +_DatePickerImpl::CreateDatePickerImplN(DatePicker* pControl, const String& title) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + _DateTimePicker* pCore = _DateTimePicker::CreateDateTimePickerN(DATETIME_OUTPUT_STYLE_DATE, title); + SysTryReturn(NID_UI_CTRL, (pCore != null), null, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _DatePickerImpl* pPickerImpl = new (std::nothrow) _DatePickerImpl(pControl, pCore); + r = CheckConstruction(pCore, pPickerImpl); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pPickerImpl->__pPublicDateTimeChangeEvent = new (std::nothrow) _PublicDateTimeChangeEvent(*pControl); + SysTryCatch(NID_UI_CTRL, (pPickerImpl->__pPublicDateTimeChangeEvent != null), , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pPickerImpl->InitializeBoundsProperties(GET_SIZE_INFO(DatePicker), pCore->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddDateTimeChangeEventListener(*pPickerImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pPickerImpl; + +CATCH: + delete pPickerImpl; + + return null; +} + +const char* +_DatePickerImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::DatePicker"; +} + +const DatePicker& +_DatePickerImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +DatePicker& +_DatePickerImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _DateTimePicker& +_DatePickerImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_DateTimePicker& +_DatePickerImpl::GetCore(void) +{ + return static_cast <_DateTimePicker&>(_ControlImpl::GetCore()); +} + +_DatePickerImpl* +_DatePickerImpl::GetInstance(DatePicker& datePicker) +{ + return static_cast<_DatePickerImpl*> (_ControlImpl::GetInstance(datePicker)); +} + +const _DatePickerImpl* +_DatePickerImpl::GetInstance(const DatePicker& datePicker) +{ + return static_cast (_ControlImpl::GetInstance(datePicker)); +} + +result +_DatePickerImpl::AddDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, (__pPublicDateTimeChangeEvent != null), E_SYSTEM, + "A system error has occurred. The _PublicDateTimeChangeEvent instance is null."); + + result r = __pPublicDateTimeChangeEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +result +_DatePickerImpl::RemoveDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, (__pPublicDateTimeChangeEvent != null), E_SYSTEM, + "A system error has occurred. The _PublicDateTimeChangeEvent instance is null."); + + result r = __pPublicDateTimeChangeEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +DateTime +_DatePickerImpl::GetDate(void) const +{ + ClearLastResult(); + + DateTime dateTime; + dateTime.SetValue(GetYear(), GetMonth(), GetDay(), 0, 0, 0); + return dateTime; +} + +int +_DatePickerImpl::GetDay(void) const +{ + ClearLastResult(); + + Variant dayValue = GetCore().GetPropertyDay(); + + return dayValue.ToInt(); +} + +int +_DatePickerImpl::GetMonth(void) const +{ + ClearLastResult(); + + Variant monthValue = GetCore().GetPropertyMonth(); + + return monthValue.ToInt(); +} + +int +_DatePickerImpl::GetYear(void) const +{ + ClearLastResult(); + + Variant yearValue = GetCore().GetPropertyYear(); + + return yearValue.ToInt(); +} + +void +_DatePickerImpl::SetDate(const DateTime& date) +{ + ClearLastResult(); + + SetYear(date.GetYear()); + SetMonth(date.GetMonth()); + SetDay(date.GetDay()); +} + +void +_DatePickerImpl::SetCurrentDate(void) +{ + ClearLastResult(); + + DateTime dateTime; + SystemTime::GetCurrentTime(WALL_TIME, dateTime); + SetDate(dateTime); +} + +result +_DatePickerImpl::SetYear(int year) +{ + ClearLastResult(); + + Variant yearValue(year); + + return GetCore().SetPropertyYear(yearValue); +} + +result +_DatePickerImpl::SetMonth(int month) +{ + ClearLastResult(); + + Variant monthValue(month); + + return GetCore().SetPropertyMonth(monthValue); +} + +result +_DatePickerImpl::SetDay(int day) +{ + ClearLastResult(); + + Variant dayValue(day); + + return GetCore().SetPropertyDay(dayValue); +} + +result +_DatePickerImpl::SetYearRange(int minYear, int maxYear) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + Variant currentMinYearValue = GetCore().GetPropertyMinYearRange(); + Variant minYearValue(minYear); + Variant maxYearValue(maxYear); + + r = GetCore().SetPropertyMinYearRange(minYearValue); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.", GetErrorMessage(r)); + + r = GetCore().SetPropertyMaxYearRange(maxYearValue); + if (r != E_SUCCESS) + { + // rollback minYearValue + GetCore().SetPropertyMinYearRange(minYearValue); + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_DatePickerImpl::GetYearRange(int& minYear, int& maxYear) const +{ + ClearLastResult(); + + Variant minYearValue = GetCore().GetPropertyMinYearRange(); + Variant maxYearValue = GetCore().GetPropertyMaxYearRange(); + + minYear = minYearValue.ToInt(); + maxYear = maxYearValue.ToInt(); + + return E_SUCCESS; +} + +void +_DatePickerImpl::OnDateTimeChanged(const Tizen::Ui::_Control& source, int year, int month, int day, int hour, int minute) +{ + ClearLastResult(); + + if (__pPublicDateTimeChangeEvent == null) + { + return; + } + + _PublicDateTimeChangeEventArg* pEventArg = new (std::nothrow) _PublicDateTimeChangeEventArg(DATE_PUBLIC_CHANGE_SAVED); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pEventArg->SetDate(year, month, day); + pEventArg->SetTime(hour, minute); + + __pPublicDateTimeChangeEvent->Fire(*pEventArg); +} + +void +_DatePickerImpl::OnDateTimeChangeCanceled(const Tizen::Ui::_Control& source) +{ + ClearLastResult(); + + if (__pPublicDateTimeChangeEvent == null) + { + return; + } + + _PublicDateTimeChangeEventArg* pEventArg = new (std::nothrow) _PublicDateTimeChangeEventArg(DATE_PUBLIC_CHANGE_CANCELED); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pPublicDateTimeChangeEvent->Fire(*pEventArg); +} + +void +_DatePickerImpl::OnChangeLayout(Tizen::Ui::_ControlOrientation orientation) +{ + ClearLastResult(); + + InitializeBoundsProperties(GET_SIZE_INFO(DatePicker), orientation); + _ControlImpl::OnChangeLayout(orientation); +} + +result +_DatePickerImpl::OnAttachedToMainTree(void) +{ + result r = E_SUCCESS; + + if (GetOwner() == null) + { + _FrameImpl* pFrameImpl = dynamic_cast <_FrameImpl*>(_ControlImplManager::GetInstance()->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, pFrameImpl != null, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] This instance is not constructed."); + + _Form* pForm = pFrameImpl->GetCore().GetCurrentForm(); + if (pForm != null) + { + GetCore().SetOwner(pForm); + } + else + { + GetCore().SetOwner(&pFrameImpl->GetCore()); + } + } + SetVisibleState(true); + + _WindowImpl::OnAttachedToMainTree(); + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DateTimeBar.cpp b/src/ui/controls/FUiCtrl_DateTimeBar.cpp new file mode 100644 index 0000000..017e782 --- /dev/null +++ b/src/ui/controls/FUiCtrl_DateTimeBar.cpp @@ -0,0 +1,689 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DateTimeBar.cpp + * @brief This is the implementation file for the _DateTimeBar class. + */ + +#include "FUiAnim_VisualElement.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_DateTimeBar.h" +#include "FUiCtrl_DateTimeBarPresenter.h" +#include "FUiCtrl_ActionEvent.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_Form.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ +_DateTimeBar::_DateTimeBar(void) + : __pDateTimeBarPresenter(null) + , __pActionEvent(null) + , __selectedBoxId(DATETIME_ID_NONE) + , __alignment(DATETIME_BAR_ALIGN_DOWN) + , __pDateTimeChangeEvent(null) + , __pGestureFlick(null) + , __parentWindowBounds(0, 0, 0, 0) +{ + +} + +_DateTimeBar::~_DateTimeBar(void) +{ + if (__pDateTimeChangeEvent != null) + { + delete __pDateTimeChangeEvent; + __pDateTimeChangeEvent = null; + } + + if (__pActionEvent) + { + delete __pActionEvent; + __pActionEvent = null; + } + + delete __pDateTimeBarPresenter; + __pDateTimeBarPresenter = null; + + delete __pGestureFlick; + __pGestureFlick = null; + + RemoveAllAccessibilityElement(); + + ClearLastResult(); +} + +_DateTimeBar* +_DateTimeBar::CreateDateTimeBarN(void) +{ + result r = E_SUCCESS; + ClearLastResult(); + + _DateTimeBar* pDateTimeBar = new (std::nothrow) _DateTimeBar; + SysTryReturn(NID_UI_CTRL, pDateTimeBar != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + +#if defined(MULTI_WINDOW) + r = pDateTimeBar->CreateRootVisualElement(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); +#endif + + pDateTimeBar->__pDateTimeBarPresenter = _DateTimeBarPresenter::CreateInstanceN(*pDateTimeBar); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pDateTimeBar->__pDateTimeBarPresenter != null, , r, + "[%s] Propagating.", GetErrorMessage(r)); + + pDateTimeBar->__pDateTimeChangeEvent = new (std::nothrow) _DateTimeChangeEvent(*pDateTimeBar); + SysTryCatch(NID_UI_CTRL, (pDateTimeBar->__pDateTimeChangeEvent != null), , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pDateTimeBar->AcquireHandle(); + + if (pDateTimeBar->GetVisualElement() != null) + { + pDateTimeBar->GetVisualElement()->SetSurfaceOpaque(false); + } + + pDateTimeBar->__pGestureFlick = new (std::nothrow) _TouchFlickGestureDetector(); + SysTryCatch(NID_UI_CTRL, (pDateTimeBar->__pGestureFlick != null), , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pDateTimeBar->AddGestureDetector(*(pDateTimeBar->__pGestureFlick)); + SysTryCatch(NID_UI_CTRL, (GetLastResult() == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pDateTimeBar->__pGestureFlick->AddGestureListener(*pDateTimeBar); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pDateTimeBar->InitializeAccessibilityElement(); + return pDateTimeBar; + +CATCH: + delete pDateTimeBar; + return null; +} + +result +_DateTimeBar::SetPositionAndAlignment(const Point& point, _DateTimeBarAlignment alignment) +{ + ClearLastResult(); + + result r = E_SUCCESS; + SetAlignment(alignment); + + r = __pDateTimeBarPresenter->LoadArrowBitmap(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int height = 0; + + r = GET_SHAPE_CONFIG(DATETIMEBAR::ITEM_HEIGHT, GetOrientation(), height); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetMovable(true); + SetResizable(true); + + if (alignment == DATETIME_BAR_ALIGN_DOWN) + { + SetPosition(Point(point.x, point.y)); + + } + else + { + SetPosition(Point(point.x, point.y - height)); + } + + __pDateTimeBarPresenter->CalculateWindowBounds(); + + return r; +} + +_DateTimeBarAlignment +_DateTimeBar::GetAlignment(void) const +{ + return __alignment; +} + +void +_DateTimeBar::SetAlignment(_DateTimeBarAlignment alignment) +{ + __alignment = alignment; + return; +} + +void +_DateTimeBar::OnDraw(void) +{ + ClearLastResult(); + + __pDateTimeBarPresenter->Draw(); + return; +} + +result +_DateTimeBar::RemoveAllItems(void) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + r = __pDateTimeBarPresenter->RemoveAllItems(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_DateTimeBar::SetInitialValue(int minValue, int maxValue, int displayValue, _DateTimeId boxId) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + SetSelectedBoxId(boxId); + + __pDateTimeBarPresenter->SetMinimumValue(minValue); + __pDateTimeBarPresenter->SetMaximumValue(maxValue); + + r = __pDateTimeBarPresenter->AddItems(displayValue); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +_DateTimeId +_DateTimeBar::GetSelectedBoxId(void) const +{ + return __selectedBoxId; +} + +void +_DateTimeBar::SetSelectedBoxId(_DateTimeId boxId) +{ + __selectedBoxId = boxId; + return; +} + + +void +_DateTimeBar::InitializeAccessibilityElement(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if (pContainer) + { + pContainer->Activate(true); + pContainer->AddListener(*this); + } + + return; +} + +int +_DateTimeBar::GetItemCount(void) const +{ + ClearLastResult(); + + return __pDateTimeBarPresenter->GetItemCount(); +} + +result +_DateTimeBar::AddActionEventListener(const _IActionEventListener& listener) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + if (__pActionEvent == null) + { + __pActionEvent = _ActionEvent::CreateInstanceN(*this); + SysTryReturn(NID_UI_CTRL, __pActionEvent != null, E_SYSTEM, E_SYSTEM, + "[%s] Propagating.", GetErrorMessage(r)); + } + r = __pActionEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_DateTimeBar::RemoveActionEventListener(const _IActionEventListener& listener) +{ + ClearLastResult(); + + result r = E_OBJ_NOT_FOUND; + + if (__pActionEvent) + { + r = __pActionEvent->RemoveListener(listener); + } + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_DateTimeBar::AddDateTimeChangeEventListener(const _IDateTimeChangeEventListener& listener) +{ + ClearLastResult(); + + return __pDateTimeChangeEvent->AddListener(listener); +} + +result +_DateTimeBar::RemoveDateTimeChangeEventListener(const _IDateTimeChangeEventListener& listener) +{ + ClearLastResult(); + + return __pDateTimeChangeEvent->RemoveListener(listener); +} + +result +_DateTimeBar::FireDateTimeChangeEvent(_DateTimeChangeStatus status) +{ + ClearLastResult(); + + _DateTimeChangeEventArg* pDateTimeEventArg = new (std::nothrow) _DateTimeChangeEventArg(status); + SysTryReturn(NID_UI_CTRL, (pDateTimeEventArg != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pDateTimeChangeEvent->Fire(*pDateTimeEventArg); + + return E_SUCCESS; +} + +result +_DateTimeBar::FireActionEvent(int actionId) +{ + ClearLastResult(); + + if (__pActionEvent) + { + Tizen::Base::Runtime::IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pEventArg, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pActionEvent->Fire(*pEventArg); + } + + return E_SUCCESS; +} + +result +_DateTimeBar::CalculateArrowBounds(const Rectangle& bounds) +{ + ClearLastResult(); + + Rectangle arrowBounds(0, 0, 0, 0); + + arrowBounds = __pDateTimeBarPresenter->GetArrowBounds(); + arrowBounds.x = bounds.x + (bounds.width / 2) - (arrowBounds.width / 2); + arrowBounds.x -= __pDateTimeBarPresenter->GetWindowBounds().x; + + __pDateTimeBarPresenter->SetArrowBounds(arrowBounds); + + return E_SUCCESS; +} + +bool +_DateTimeBar::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + return __pDateTimeBarPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_DateTimeBar::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + return __pDateTimeBarPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_DateTimeBar::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + return __pDateTimeBarPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_DateTimeBar::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + return __pDateTimeBarPresenter->OnTouchCanceled(source, touchinfo); +} + +bool +_DateTimeBar::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) +{ + int xDistance = 0; + int yDistance = 0; + gesture.GetDistance(xDistance, yDistance); + int duration = gesture.GetDuration(); + + return __pDateTimeBarPresenter->OnFlickGestureDetected(xDistance, yDistance, duration); +} + +bool +_DateTimeBar::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture) +{ + return false; +} + +void +_DateTimeBar::OnTouchMoveHandled(const Tizen::Ui::_Control& control) +{ + ClearLastResult(); + + return __pDateTimeBarPresenter->OnTouchMoveHandled(control); +} + +result +_DateTimeBar::OnAttachingToMainTree(const _Control* pParent) +{ + if (GetOwner() == null) + { + _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] This instance is not constructed."); + + _Form* pForm = pFrame->GetCurrentForm(); + if (pForm != null) + { + SetOwner(pForm); + } + else + { + SetOwner(pFrame); + } + } + + return _Window::OnAttachingToMainTree(pParent); +} + +result +_DateTimeBar::OnAttachedToMainTree(void) +{ + _Window::OnAttachedToMainTree(); + return E_SUCCESS; +} + +result +_DateTimeBar::OnDetachingFromMainTree(void) +{ + return _Window::OnDetachingFromMainTree(); +} + +void +_DateTimeBar::OnActivated(void) +{ + _Window::OnActivated(); + + int itemWidth = 0; + + if (GetSelectedBoxId() == DATETIME_ID_MONTH) + { + GET_SHAPE_CONFIG(DATETIMEBAR::MONTH_ITEM_WIDTH, _ControlManager::GetInstance()->GetOrientation(), itemWidth); + } + else if (GetSelectedBoxId() == DATETIME_ID_YEAR) + { + GET_SHAPE_CONFIG(DATETIMEBAR::YEAR_ITEM_WIDTH, _ControlManager::GetInstance()->GetOrientation(), itemWidth); + } + else + { + GET_SHAPE_CONFIG(DATETIMEBAR::DAY_ITEM_WIDTH, _ControlManager::GetInstance()->GetOrientation(), itemWidth); + } + + __pDateTimeBarPresenter->SetInitialAnimationValue(itemWidth); + + __pDateTimeBarPresenter->StartAnimationEffect(); + + SetTouchCapture(); + return; +} + +void +_DateTimeBar::OnDeactivated(void) +{ + ReleaseTouchCapture(); + _Window::OnDeactivated(); + return; +} + +void +_DateTimeBar::AddAccessibilityElement(const Rectangle& itemBounds, const Tizen::Base::String& itemText) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer) + { + _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + String labelText = itemText; + pAccessibilityElement->SetBounds(itemBounds); + pAccessibilityElement->SetLabel(labelText); + pAccessibilityElement->SetTrait(GetAccessibilityTraitValue()); + pContainer->AddElement(*pAccessibilityElement); + __accessibilityElements.Add(pAccessibilityElement); + } + + return; +} + +void +_DateTimeBar::RemoveAllAccessibilityElement(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if (pContainer == null) + { + return; + } + + _AccessibilityElement* pAccessibilityElement = null; + + while (__accessibilityElements.GetCount() > 0) + { + if ((__accessibilityElements.GetAt(0, pAccessibilityElement)) == E_SUCCESS) + { + __accessibilityElements.RemoveAt(0); + pContainer->RemoveElement(*pAccessibilityElement); + } + else + { + __accessibilityElements.RemoveAt(0); + } + } + + return; +} + +AccessibilityTraits +_DateTimeBar::GetAccessibilityTraitValue() +{ + AccessibilityTraits traitsValue = ACCESSIBILITY_TRAITS_NONE; + + if (GetSelectedBoxId() == DATETIME_ID_DAY) + { + traitsValue = ACCESSIBILITY_TRAITS_DAY; + } + else if (GetSelectedBoxId() == DATETIME_ID_MONTH) + { + traitsValue = ACCESSIBILITY_TRAITS_MONTH; + } + else if (GetSelectedBoxId() == DATETIME_ID_YEAR) + { + traitsValue = ACCESSIBILITY_TRAITS_YEAR; + } + else if (GetSelectedBoxId() == DATETIME_ID_HOUR) + { + traitsValue = ACCESSIBILITY_TRAITS_HOUR; + } + else if (GetSelectedBoxId() == DATETIME_ID_MINUTE) + { + traitsValue = ACCESSIBILITY_TRAITS_MINUTE; + } + + return traitsValue; +} + +String +_DateTimeBar::GetMonthValue(int month) const +{ + String monthValue; + + switch (month) + { + case 1: + monthValue = L"January"; + break; + case 2: + monthValue = L"February"; + break; + case 3: + monthValue = L"March"; + break; + case 4: + monthValue = L"April"; + break; + case 5: + monthValue = L"May"; + break; + case 6: + monthValue = L"June"; + break; + case 7: + monthValue = L"July"; + break; + case 8: + monthValue = L"August"; + break; + case 9: + monthValue = L"September"; + break; + case 10: + monthValue = L"October"; + break; + case 11: + monthValue = L"November"; + break; + case 12: + monthValue = L"December"; + break; + default: + monthValue = L""; + } + + return monthValue; +} + +void +_DateTimeBar::SetFont(Font& pFont) +{ + __pDateTimeBarPresenter->SetFont(pFont); + + return; +} + +void +_DateTimeBar::SetParentWindowBounds(Rectangle& parentWindowBounds) +{ + __parentWindowBounds = parentWindowBounds; + return; +} + +Rectangle +_DateTimeBar::GetParentWindowBounds() const +{ + return __parentWindowBounds; +} + +bool +_DateTimeBar::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return __pDateTimeBarPresenter->OnAccessibilityFocusMovedNext(control, element); +} + +bool +_DateTimeBar::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return __pDateTimeBarPresenter->OnAccessibilityFocusMovedPrevious(control, element); +} + +bool +_DateTimeBar::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_DateTimeBar::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_DateTimeBar::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_DateTimeBar::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_DateTimeBar::OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&) +{ + return false; +} + +bool +_DateTimeBar::OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&) +{ + return false; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DateTimeBarItem.cpp b/src/ui/controls/FUiCtrl_DateTimeBarItem.cpp new file mode 100644 index 0000000..bbc3914 --- /dev/null +++ b/src/ui/controls/FUiCtrl_DateTimeBarItem.cpp @@ -0,0 +1,121 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DateTimeBarItem.cpp + * @brief This is the implementation file for the _DateTimeBarItem class. + */ + +#include "FUi_ResourceManager.h" +#include "FUiCtrl_DateTimeBarItem.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ +_DateTimeBarItem::_DateTimeBarItem(void) + : __actionId(-1) + , __text() + , __status(DATETIMEBAR_ITEM_STATUS_NORMAL) + , __bounds(Rectangle()) +{ + ClearLastResult(); +} + +_DateTimeBarItem::~_DateTimeBarItem(void) +{ +} + +_DateTimeBarItem* +_DateTimeBarItem::CreateInstanceN(_DateTimeBarAlignment alignment, int itemWidth) +{ + _DateTimeBarItem* pItem = new (std::nothrow) _DateTimeBarItem; + SysTryReturn(NID_UI_CTRL, pItem != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = E_SUCCESS; + + if (alignment == DATETIME_BAR_ALIGN_DOWN) + { + r = GET_SHAPE_CONFIG(DATETIMEBAR::ARROW_HEIGHT, _ControlManager::GetInstance()->GetOrientation(), pItem->__bounds.y); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + pItem->__bounds.width = itemWidth; + + r = GET_SHAPE_CONFIG(DATETIMEBAR::ITEM_HEIGHT, _ControlManager::GetInstance()->GetOrientation(), pItem->__bounds.height); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pItem; + +CATCH: + delete pItem; + return null; +} + +void +_DateTimeBarItem::SetActionId(int actionId) +{ + __actionId = actionId; + return; +} + +int +_DateTimeBarItem::GetActionId(void) const +{ + return __actionId; +} + +void +_DateTimeBarItem::SetText(const Tizen::Base::String& text) +{ + __text = text; + return; +} + +Tizen::Base::String +_DateTimeBarItem::GetText(void) const +{ + return __text; +} + +void +_DateTimeBarItem::SetStatus(_DateTimeBarItemStatus status) +{ + __status = status; + return; +} + +_DateTimeBarItemStatus +_DateTimeBarItem::GetStatus(void) const +{ + return __status; +} + +void +_DateTimeBarItem::SetBounds(const Tizen::Graphics::Rectangle& bounds) +{ + __bounds = bounds; + return; +} + +Rectangle +_DateTimeBarItem::GetBounds(void) const +{ + return __bounds; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DateTimeBarModel.cpp b/src/ui/controls/FUiCtrl_DateTimeBarModel.cpp new file mode 100644 index 0000000..7de82a3 --- /dev/null +++ b/src/ui/controls/FUiCtrl_DateTimeBarModel.cpp @@ -0,0 +1,234 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DateTimeBarModel.cpp + * @brief This is the implementation file for the _DateTimeBarModel class. + */ + +#include "FUiCtrl_DateTimeBarModel.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ +const int CACHING_SIZE = 50; + +_DateTimeBarModel::_DateTimeBarModel(void) + : __selectedItemIndex(-1) + , __firstDrawnItemIndex(0) + , __minValue(-1) + , __maxValue(-1) + , __maxCachingSize(CACHING_SIZE) + , __itemStartPositionX(0) +{ +} + +_DateTimeBarModel::~_DateTimeBarModel(void) +{ + __dateTimeBarItems.RemoveAll(true); +} + +_DateTimeBarModel* +_DateTimeBarModel::CreateInstanceN(void) +{ + _DateTimeBarModel* pDateTimeBarModel = new (std::nothrow) _DateTimeBarModel; + SysTryReturn(NID_UI_CTRL, pDateTimeBarModel, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = E_SUCCESS; + r = pDateTimeBarModel->__dateTimeBarItems.Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pDateTimeBarModel; + +CATCH: + delete pDateTimeBarModel; + return null; +} + +void +_DateTimeBarModel::SetSelectedItemIndex(int index) +{ + __selectedItemIndex = index; + return; +} + +int +_DateTimeBarModel::GetSelectedItemIndex(void) const +{ + return __selectedItemIndex; +} + +void +_DateTimeBarModel::SetFirstDrawnItemIndex(int index) +{ + __firstDrawnItemIndex = index; + return; +} + +int +_DateTimeBarModel::GetFirstDrawnItemIndex(void) const +{ + return __firstDrawnItemIndex; +} + +int +_DateTimeBarModel::GetItemCount(void) const +{ + return __dateTimeBarItems.GetCount(); +} + +result +_DateTimeBarModel::AddItem(const Tizen::Base::String& text, int actionId, _DateTimeBarAlignment alignment, int itemWidth, int margin) +{ + _DateTimeBarItem* pItem = _DateTimeBarItem::CreateInstanceN(alignment, itemWidth); + + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pItem != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pItem->SetText(text); + pItem->SetActionId(actionId); + + int itemCount = 0; + _DateTimeBarItem* pPrevItem = null; + + itemCount = GetItemCount(); + + if (itemCount > 0) + { + pPrevItem = GetItemAt(itemCount - 1); + } + else + { + Rectangle itemBounds = pItem->GetBounds(); + + itemBounds.x = __itemStartPositionX; + + pItem->SetBounds(itemBounds); + } + + if (pPrevItem != null) + { + Rectangle prevItemBounds = pPrevItem->GetBounds(); + Rectangle itemBounds = pItem->GetBounds(); + itemBounds.x = prevItemBounds.x + prevItemBounds.width + margin; + + pItem->SetBounds(itemBounds); + } + + return __dateTimeBarItems.Add(*pItem); +} + +result +_DateTimeBarModel::InsertItemAt(int index, const Tizen::Base::String& text, int actionId, _DateTimeBarAlignment alignment, int itemWidth, int margin) +{ + _DateTimeBarItem* pItem = _DateTimeBarItem::CreateInstanceN(alignment, itemWidth); + + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pItem != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pItem->SetText(text); + pItem->SetActionId(actionId); + + _DateTimeBarItem* pPrevItem = GetItemAt(index); + if (pPrevItem != null) + { + Rectangle prevItemBounds = pPrevItem->GetBounds(); + Rectangle itemBounds = pItem->GetBounds(); + itemBounds.x = prevItemBounds.x - itemBounds.width - margin; + + pItem->SetBounds(itemBounds); + } + + return __dateTimeBarItems.InsertAt(*pItem, index); +} + +result +_DateTimeBarModel::RemoveItemAt(int index) +{ + if (GetFirstDrawnItemIndex() == index) + { + if (GetItemAt(index + 1) == null) + { + SetFirstDrawnItemIndex(-1); + } + } + + return __dateTimeBarItems.RemoveAt(index, true); +} + +void +_DateTimeBarModel::RemoveAllItems() +{ + __dateTimeBarItems.RemoveAll(true); + SetFirstDrawnItemIndex(0); + SetSelectedItemIndex(-1); + return; +} + +const _DateTimeBarItem* +_DateTimeBarModel::GetItemAt(int index) const +{ + return dynamic_cast (__dateTimeBarItems.GetAt(index)); +} + +_DateTimeBarItem* +_DateTimeBarModel::GetItemAt(int index) +{ + return dynamic_cast <_DateTimeBarItem*>(__dateTimeBarItems.GetAt(index)); +} + +int +_DateTimeBarModel::GetMinimumValue(void) const +{ + return __minValue; +} + +void +_DateTimeBarModel::SetMinimumValue(int minValue) +{ + __minValue = minValue; + return; +} + +int +_DateTimeBarModel::GetMaximumValue(void) const +{ + return __maxValue; +} + +void +_DateTimeBarModel::SetMaximumValue(int maxValue) +{ + __maxValue = maxValue; + return; +} + +int +_DateTimeBarModel::GetMaxCachingSize(void) const +{ + return __maxCachingSize; +} + +result +_DateTimeBarModel::SetItemStartPosition(int positionX) +{ + __itemStartPositionX = positionX; + return E_SUCCESS; +} +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DateTimeBarPresenter.cpp b/src/ui/controls/FUiCtrl_DateTimeBarPresenter.cpp new file mode 100644 index 0000000..a8b1094 --- /dev/null +++ b/src/ui/controls/FUiCtrl_DateTimeBarPresenter.cpp @@ -0,0 +1,1537 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DateTimeBarPresenter.cpp + * @brief This is the implementation file for the _DateTimeBarPresenter class. + */ + +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_DateTimeUtils.h" +#include "FUiCtrl_DateTimeBar.h" +#include "FUiCtrl_DateTimeBarPresenter.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics::_Text; + +const int UPDATE_ITEM_COUNT = 3; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_DateTimeBarPresenter::_DateTimeBarPresenter(_DateTimeBar* pDateTimeBar) + : __pDateTimeBar(pDateTimeBar) + , __pDateTimeBarModel(null) + , __currentPoint(Point(0, 0)) + , __isTouchMoved(false) + , __touchMoveHandled(false) + , __distance(0) + , __pFlickAnimationTimer(null) + , __flickAnimation() + , __selectedText(L"") + , __bodyAreaBounds(Rectangle()) + , __arrowAreaBounds(Rectangle()) + , __windowAreaBounds(Rectangle()) + , __pBgColorReplacementBitmap(null) + , __pArrowColorReplacementBitmap(null) + , __isInitialAnimation(false) + , __initialAnimationValue(0) + , __pFont(null) +{ +} + +_DateTimeBarPresenter::~_DateTimeBarPresenter(void) +{ + delete __pDateTimeBarModel; + __pDateTimeBarModel = 0; + + delete __pBgColorReplacementBitmap; + __pBgColorReplacementBitmap = null; + + delete __pArrowColorReplacementBitmap; + __pArrowColorReplacementBitmap = null; + + delete __pFlickAnimationTimer; + __pFlickAnimationTimer = null; + + delete __pFont; + __pFont = null; +} + +_DateTimeBarPresenter* +_DateTimeBarPresenter::CreateInstanceN(_DateTimeBar& dateTimeBar) +{ + result r = E_SUCCESS; + + _DateTimeBarPresenter* pDateTimeBarPresenter = new (std::nothrow) _DateTimeBarPresenter(&dateTimeBar); + SysTryReturn(NID_UI_CTRL, pDateTimeBarPresenter, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pDateTimeBarPresenter->__pDateTimeBarModel = _DateTimeBarModel::CreateInstanceN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pDateTimeBarPresenter->__pDateTimeBarModel, , r, + "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(DATETIMEBAR::ARROW_WIDTH, dateTimeBar.GetOrientation(), pDateTimeBarPresenter->__arrowAreaBounds.width); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to get arrow width from resource.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(DATETIMEBAR::ARROW_HEIGHT, dateTimeBar.GetOrientation(), pDateTimeBarPresenter->__arrowAreaBounds.height); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to get arrow height from resource.", GetErrorMessage(r)); + + r = pDateTimeBarPresenter->LoadResource(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to load the resources.", GetErrorMessage(r)); + + return pDateTimeBarPresenter; + +CATCH: + delete pDateTimeBarPresenter; + + return null; +} + +void +_DateTimeBarPresenter::AddFlickAnimationInfo() +{ + __flickAnimation.SetSensitivity(FLICK_ANIMATION_FPS_DATE_TIME_BAR, FLICK_ANIMATION_SENSITIVITY_DATE_TIME_BAR); + __flickAnimation.SetDirection(FD_HORIZONTAL); +} + +result +_DateTimeBarPresenter::LoadResource(void) +{ + result r = E_SUCCESS; + Color bgBitmapColor; + Bitmap* pBackgroundNormalBitmap = null; + + r = GET_BITMAP_CONFIG_N(DATETIMEBAR::TIMEPICKERBAR_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBackgroundNormalBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_COLOR_CONFIG(DATETIMEBAR::BG_NORMAL, bgBitmapColor); + __pBgColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundNormalBitmap, + Color::GetColor(COLOR_ID_MAGENTA), bgBitmapColor); + SysTryCatch(NID_UI_CTRL, __pBgColorReplacementBitmap != null, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", + GetErrorMessage(GetLastResult())); + + r = LoadArrowBitmap(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to load resources.", GetErrorMessage(r)); + + delete pBackgroundNormalBitmap; + pBackgroundNormalBitmap = null; + + AddFlickAnimationInfo(); + + return r; + +CATCH: + + delete pBackgroundNormalBitmap; + pBackgroundNormalBitmap = null; + + delete __pBgColorReplacementBitmap; + __pBgColorReplacementBitmap = null; + + return r; +} + +result +_DateTimeBarPresenter::LoadArrowBitmap(void) +{ + result r = E_SUCCESS; + Color arrowColor; + Bitmap* pArrowNormalBitmap = null; + + GET_COLOR_CONFIG(DATETIMEBAR::BG_NORMAL, arrowColor); + + if (__pDateTimeBar->GetAlignment() == DATETIME_BAR_ALIGN_DOWN) + { + r = GET_BITMAP_CONFIG_N(DATETIMEBAR::TAIL_DOWN, BITMAP_PIXEL_FORMAT_ARGB8888, pArrowNormalBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = GET_BITMAP_CONFIG_N(DATETIMEBAR::TAIL_UP, BITMAP_PIXEL_FORMAT_ARGB8888, pArrowNormalBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (__pArrowColorReplacementBitmap != null) + { + delete __pArrowColorReplacementBitmap; + __pArrowColorReplacementBitmap = null; + } + + __pArrowColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pArrowNormalBitmap, + Color::GetColor(COLOR_ID_MAGENTA), arrowColor); + SysTryCatch(NID_UI_CTRL, __pArrowColorReplacementBitmap != null, r = GetLastResult(), GetLastResult(), "[%s] Propagating.", + GetErrorMessage(GetLastResult())); + + delete pArrowNormalBitmap; + pArrowNormalBitmap = null; + + return r; + +CATCH: + + delete pArrowNormalBitmap; + pArrowNormalBitmap = null; + + delete __pArrowColorReplacementBitmap; + __pArrowColorReplacementBitmap = null; + + return r; +} + +result +_DateTimeBarPresenter::Draw(void) +{ + result r = E_SUCCESS; + + Canvas* pCanvas = __pDateTimeBar->GetCanvasN(); + SysAssertf((pCanvas != null), "Failed to get canvas."); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + + r = pCanvas->Clear(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawBackground(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawArrow(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawItem(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pCanvas; + return r; + +CATCH: + delete pCanvas; + return r; +} + +result +_DateTimeBarPresenter::DrawItem(Canvas& canvas) +{ + result r = E_SUCCESS; + + Rectangle clientBounds = canvas.GetBounds(); + + _DateTimeBarItem* pDrawItem = null; + Rectangle itemBounds(0, 0, 0, 0); + + String drawText; + Rectangle textAreaBounds(0, 0, 0, 0); + + Color textColor; + GET_COLOR_CONFIG(DATETIMEBAR::TEXT_NORMAL, textColor); + + Color textPressedColor; + GET_COLOR_CONFIG(DATETIMEBAR::TEXT_PRESSED, textPressedColor); + + _DateTimeBarItemStatus itemStatus = DATETIMEBAR_ITEM_STATUS_NORMAL; + + int itemCount = GetItemCount(); + + RefreshAccessibilityElement(); + + for (int i = __pDateTimeBarModel->GetFirstDrawnItemIndex(); i < itemCount; i++) + { + pDrawItem = __pDateTimeBarModel->GetItemAt(i); + if (pDrawItem == null) + { + break; + } + + itemBounds = pDrawItem->GetBounds(); + + if (itemBounds.x + itemBounds.width <= 0) + { + continue; + } + + textAreaBounds = Rectangle(itemBounds.x, itemBounds.y, itemBounds.width, itemBounds.height); + + drawText = pDrawItem->GetText(); + + if (drawText.CompareTo(__selectedText) == 0) + { + pDrawItem->SetStatus(DATETIMEBAR_ITEM_STATUS_SELECTED); + } + + itemStatus = pDrawItem->GetStatus(); + + int fontSize = GetFontSize(); + + TextSimple* pSimpleText = null; + TextObject* pTextObject = new (std::nothrow) TextObject; + SysTryReturn(NID_UI_CTRL, (pTextObject != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pTextObject->Construct(); + pSimpleText = new (std::nothrow)TextSimple((const_cast (drawText.GetPointer())), drawText.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + pTextObject->AppendElement(*pSimpleText); + + pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + SysAssertf(__pFont != null, "Font instance is null"); + + if (itemStatus == DATETIMEBAR_ITEM_STATUS_SELECTED) + { + (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize); + (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD); + pTextObject->SetFont(__pFont, 0, pTextObject->GetTextLength()); + pTextObject->SetForegroundColor(textPressedColor, 0, pTextObject->GetTextLength()); + } + else + { + (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize); + (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_PLAIN); + pTextObject->SetFont(__pFont, 0, pTextObject->GetTextLength()); + pTextObject->SetForegroundColor(textColor, 0, pTextObject->GetTextLength()); + } + + pTextObject->SetBounds(textAreaBounds); + pTextObject->Draw(*_CanvasImpl::GetInstance(canvas)); + + delete pTextObject; + + if ((textAreaBounds.x + textAreaBounds.width + GetLeftRightMargin()) >= clientBounds.width) + { + break; + } + } + + return r; +} + +result +_DateTimeBarPresenter::DrawBackground(Canvas& canvas) +{ + result r = E_SUCCESS; + + Rectangle bodyAreaBounds = GetBodyBounds(); + + if (__pBgColorReplacementBitmap != null) + { + if (__pBgColorReplacementBitmap->IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bodyAreaBounds, *__pBgColorReplacementBitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + else + { + r = canvas.DrawBitmap(bodyAreaBounds, *__pBgColorReplacementBitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + + else + { + r = canvas.DrawRectangle(bodyAreaBounds); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + + return r; +} + +result +_DateTimeBarPresenter::DrawArrow(Canvas& canvas) +{ + result r = E_SUCCESS; + Rectangle arrowAreaBounds = GetArrowBounds(); + + if (__pArrowColorReplacementBitmap != null) + { + if (__pArrowColorReplacementBitmap->IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(arrowAreaBounds, *__pArrowColorReplacementBitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + else + { + r = canvas.DrawBitmap(arrowAreaBounds, *__pArrowColorReplacementBitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + + return r; +} + +void +_DateTimeBarPresenter::SetItemSelected(int index) +{ + __pDateTimeBarModel->SetSelectedItemIndex(index); + return; +} + +int +_DateTimeBarPresenter::GetSelectedItemIndex(void) const +{ + return __pDateTimeBarModel->GetSelectedItemIndex(); +} + +int +_DateTimeBarPresenter::GetItemIndexFromPosition(const Point& point) const +{ + Rectangle clientBounds = __pDateTimeBar->GetBounds(); + + if (point.x > clientBounds.width + || point.y > clientBounds.height) + { + return -1; + } + + int itemIndex = __pDateTimeBarModel->GetFirstDrawnItemIndex(); + _DateTimeBarItem* pItem = __pDateTimeBarModel->GetItemAt(itemIndex); + int startX = 0; + + while (pItem != null) + { + Rectangle itemBounds = pItem->GetBounds(); + + if (itemBounds.x > clientBounds.x) + { + if (itemIndex == __pDateTimeBarModel->GetFirstDrawnItemIndex()) + { + startX = itemBounds.x; + } + + itemBounds.x -= startX; + } + + if (itemBounds.Contains(point) == true) + { + return itemIndex; + } + + itemIndex++; + + if (itemIndex == GetItemCount()) + { + break; + } + + pItem = __pDateTimeBarModel->GetItemAt(itemIndex); + } + + return -1; +} + +result +_DateTimeBarPresenter::SetItemStatus(int index, _DateTimeBarItemStatus status) +{ + _DateTimeBarItem* pItem = __pDateTimeBarModel->GetItemAt(index); + SysTryReturn(NID_UI_CTRL, pItem, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _DateTimeBarItem at index (%d).", index); + + if (status != DATETIMEBAR_ITEM_STATUS_NORMAL) + { + __pDateTimeBarModel->SetSelectedItemIndex(index); + } + pItem->SetStatus(status); + + return E_SUCCESS; +} + +_DateTimeBarItemStatus +_DateTimeBarPresenter::GetItemStatus(int index) const +{ + _DateTimeBarItem* pItem = __pDateTimeBarModel->GetItemAt(index); + SysTryReturn(NID_UI_CTRL, pItem, DATETIMEBAR_ITEM_STATUS_NORMAL, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _DateTimeBarItem at index (%d).", index); + + return pItem->GetStatus(); +} + +int +_DateTimeBarPresenter::GetFirstDrawnItemIndex(void) const +{ + return __pDateTimeBarModel->GetFirstDrawnItemIndex(); +} + +void +_DateTimeBarPresenter::SetFirstDrawnItemIndex(int index) +{ + __pDateTimeBarModel->SetFirstDrawnItemIndex(index); + return; +} + +int +_DateTimeBarPresenter::GetMinimumValue(void) const +{ + return __pDateTimeBarModel->GetMinimumValue(); +} + +void +_DateTimeBarPresenter::SetMinimumValue(int minValue) +{ + __pDateTimeBarModel->SetMinimumValue(minValue); + return; +} + +int +_DateTimeBarPresenter::GetMaximumValue(void) const +{ + return __pDateTimeBarModel->GetMaximumValue(); +} + +void +_DateTimeBarPresenter::SetMaximumValue(int maxValue) +{ + __pDateTimeBarModel->SetMaximumValue(maxValue); + return; +} + +int +_DateTimeBarPresenter::GetItemWidth(void) const +{ + result r = E_SUCCESS; + + _DateTimeId boxId = __pDateTimeBar->GetSelectedBoxId(); + + int itemWidth = 0; + + if (boxId == DATETIME_ID_YEAR) + { + GET_SHAPE_CONFIG(DATETIMEBAR::YEAR_ITEM_WIDTH, _ControlManager::GetInstance()->GetOrientation(), itemWidth); + } + else if (boxId == DATETIME_ID_DAY || boxId == DATETIME_ID_HOUR || boxId == DATETIME_ID_MINUTE) + { + GET_SHAPE_CONFIG(DATETIMEBAR::DAY_ITEM_WIDTH, _ControlManager::GetInstance()->GetOrientation(), itemWidth); + } + else if (boxId == DATETIME_ID_MONTH) + { + GET_SHAPE_CONFIG(DATETIMEBAR::MONTH_ITEM_WIDTH, _ControlManager::GetInstance()->GetOrientation(), itemWidth); + + Dimension textArea; + + int fontSize = 0; + GET_SHAPE_CONFIG(DATETIMEBAR::MONTH_FONT_SIZE, __pDateTimeBar->GetOrientation(), fontSize); + + SysAssertf(__pFont != null, "Font instance is null"); + + (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize); + (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_PLAIN); + + for (int i = DATETIME_MONTH_MIN; i <= DATETIME_MONTH_MAX; i++) + { + String string; + _DateTimeUtils dateTimeUtils; + string = dateTimeUtils.GetMonthString(i); + + r = __pFont->GetTextExtent(string, string.GetLength(), textArea); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (textArea.width > itemWidth) + { + itemWidth = textArea.width; + } + } + } + + return itemWidth; +} + +int +_DateTimeBarPresenter::GetFontSize(void) const +{ + int fontSize = 0; + _DateTimeId boxId = __pDateTimeBar->GetSelectedBoxId(); + + if (boxId == DATETIME_ID_YEAR) + { + GET_SHAPE_CONFIG(DATETIMEBAR::YEAR_FONT_SIZE, _ControlManager::GetInstance()->GetOrientation(), fontSize); + } + else if (boxId == DATETIME_ID_DAY || boxId == DATETIME_ID_HOUR || boxId == DATETIME_ID_MINUTE) + { + GET_SHAPE_CONFIG(DATETIMEBAR::DAY_FONT_SIZE, _ControlManager::GetInstance()->GetOrientation(), fontSize); + } + else if (boxId == DATETIME_ID_MONTH) + { + GET_SHAPE_CONFIG(DATETIMEBAR::MONTH_FONT_SIZE, _ControlManager::GetInstance()->GetOrientation(), fontSize); + } + + return fontSize; +} + +int +_DateTimeBarPresenter::GetLeftRightMargin(void) const +{ + int leftRightMargin = 0; + _DateTimeId boxId = __pDateTimeBar->GetSelectedBoxId(); + + if (boxId == DATETIME_ID_YEAR) + { + GET_SHAPE_CONFIG(DATETIMEBAR::YEAR_LEFT_RIGHT_MARGIN, _ControlManager::GetInstance()->GetOrientation(), leftRightMargin); + } + else if (boxId == DATETIME_ID_DAY || boxId == DATETIME_ID_HOUR || boxId == DATETIME_ID_MINUTE) + { + GET_SHAPE_CONFIG(DATETIMEBAR::DAY_LEFT_RIGHT_MARGIN, _ControlManager::GetInstance()->GetOrientation(), leftRightMargin); + } + else if (boxId == DATETIME_ID_MONTH) + { + GET_SHAPE_CONFIG(DATETIMEBAR::MONTH_LEFT_RIGHT_MARGIN, _ControlManager::GetInstance()->GetOrientation(), leftRightMargin); + } + + return leftRightMargin; +} + +int +_DateTimeBarPresenter::GetItemMargin(void) const +{ + int margin = 0; + _DateTimeId boxId = __pDateTimeBar->GetSelectedBoxId(); + + if (boxId == DATETIME_ID_YEAR) + { + GET_SHAPE_CONFIG(DATETIMEBAR::YEAR_ITEM_MARGIN, _ControlManager::GetInstance()->GetOrientation(), margin); + } + else if (boxId == DATETIME_ID_DAY || boxId == DATETIME_ID_HOUR || boxId == DATETIME_ID_MINUTE) + { + GET_SHAPE_CONFIG(DATETIMEBAR::DAY_ITEM_MARGIN, _ControlManager::GetInstance()->GetOrientation(), margin); + } + else if (boxId == DATETIME_ID_MONTH) + { + GET_SHAPE_CONFIG(DATETIMEBAR::MONTH_ITEM_MARGIN, _ControlManager::GetInstance()->GetOrientation(), margin); + } + + return margin; +} + +result +_DateTimeBarPresenter::AdjustItemPosition(int distance) +{ + int index = 0; + + _DateTimeBarItem* pItem = null; + pItem = __pDateTimeBarModel->GetItemAt(index); + + while (pItem != null) + { + Rectangle bounds = pItem->GetBounds(); + bounds.x += distance; + pItem->SetBounds(bounds); + index++; + + if (index == GetItemCount()) + { + break; + } + + pItem = __pDateTimeBarModel->GetItemAt(index); + } + + return E_SUCCESS; +} + +String +_DateTimeBarPresenter::GetDisplayedText(int value) const +{ + String string; + + if (__pDateTimeBar->GetSelectedBoxId() == DATETIME_ID_MONTH) + { + String monthString; + _DateTimeUtils dateTimeUtils; + monthString = dateTimeUtils.GetMonthString(value); + string.Append(monthString); + } + else if (__pDateTimeBar->GetSelectedBoxId() == DATETIME_ID_YEAR) + { + string.Format(10, L"%04d", value); + } + else + { + string.Format(10, L"%02d", value); + } + + return string; +} + +result +_DateTimeBarPresenter::AddItems(int actionId) +{ + result r = E_SUCCESS; + int cachingSize = __pDateTimeBarModel->GetMaxCachingSize() / 2; + + int firstDrawItemIndex = cachingSize; + + int value = actionId; + int startPosition = 0; + int itemWidth = GetItemWidth(); + int itemMargin = GetItemMargin(); + + startPosition = (GetWindowBounds().width) / 2; + startPosition = startPosition + (itemWidth / 2) + itemMargin; + __pDateTimeBarModel->SetItemStartPosition(startPosition); + + while (cachingSize > 0) + { + String string; + + string = GetDisplayedText(value); + + r = __pDateTimeBarModel->AddItem(string, value, __pDateTimeBar->GetAlignment(), itemWidth, itemMargin); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + cachingSize--; + + value++; + + if (__pDateTimeBarModel->GetMaximumValue() < value) + { + value = __pDateTimeBarModel->GetMinimumValue(); + } + } + + r = InsertItems(actionId -1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _DateTimeBarItem* pItem = null; + pItem = GetItemAt(firstDrawItemIndex); + + if (pItem != null) + { + __selectedText.Clear(); + __selectedText.Append(pItem->GetText().GetPointer()); + } + + SetItemStatus(firstDrawItemIndex, DATETIMEBAR_ITEM_STATUS_SELECTED); + + return r; +} + +result +_DateTimeBarPresenter::InsertItems(int actionId) +{ + result r = E_SUCCESS; + + int cachingSize = __pDateTimeBarModel->GetMaxCachingSize() / 2; + + int value = actionId; + int itemWidth = GetItemWidth(); + int itemMargin = GetItemMargin(); + + while (cachingSize > 0) + { + String string; + + if (value < __pDateTimeBarModel->GetMinimumValue()) + { + value = __pDateTimeBarModel->GetMaximumValue(); + } + + string = GetDisplayedText(value); + r = __pDateTimeBarModel->InsertItemAt(0, string, value, __pDateTimeBar->GetAlignment(), itemWidth, itemMargin); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + cachingSize--; + + value--; + } + + return r; +} + +result +_DateTimeBarPresenter::InsertItem(int index, int actionId) +{ + result r = E_SUCCESS; + + String string; + + string = GetDisplayedText(actionId); + + r = __pDateTimeBarModel->InsertItemAt(index, string, actionId, __pDateTimeBar->GetAlignment(), GetItemWidth(), GetItemMargin()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_DateTimeBarPresenter::AddItem(int actionId) +{ + result r = E_SUCCESS; + + String string; + + string = GetDisplayedText(actionId); + + r = __pDateTimeBarModel->AddItem(string, actionId, __pDateTimeBar->GetAlignment(), GetItemWidth(), GetItemMargin()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_DateTimeBarPresenter::DeleteItem(int index) +{ + int itemCount = GetItemCount(); + + SysTryReturn(NID_UI_CTRL, itemCount > 0, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. index = %d", index); + + SysTryReturn(NID_UI_CTRL, index < itemCount, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. index = %d", index); + + SysTryReturn(NID_UI_CTRL, index >= 0, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. index = %d", index); + + result r = E_SUCCESS; + + r = __pDateTimeBarModel->RemoveItemAt(index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_DateTimeBarPresenter::RemoveAllItems(void) +{ + SysTryReturn(NID_UI_CTRL, GetItemCount() > 0, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] Items count is zero."); + + result r = E_SUCCESS; + + __pDateTimeBarModel->RemoveAllItems(); + + return r; +} + +int +_DateTimeBarPresenter::GetItemCount(void) const +{ + return __pDateTimeBarModel->GetItemCount(); +} + +_DateTimeBarItem* +_DateTimeBarPresenter::GetItemAt(int index) const +{ + return __pDateTimeBarModel->GetItemAt(index); +} + +result +_DateTimeBarPresenter::CalculateWindowBounds(void) +{ + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + Rectangle windowAreaBounds = Rectangle(0, 0, 0, 0); + Rectangle bodyAreaBounds = Rectangle(0, 0, 0, 0); + Rectangle arrowAreaBounds = Rectangle(0, 0, 0, 0); + + Rectangle parentWindowBounds = __pDateTimeBar->GetParentWindowBounds(); + int itemHeight = 0; + + arrowAreaBounds = GetArrowBounds(); + + Point arrowPosition; + + GET_SHAPE_CONFIG(DATETIMEBAR::ARROW_HEIGHT, orientation, arrowAreaBounds.height); + GET_SHAPE_CONFIG(DATETIMEBAR::ARROW_WIDTH, orientation, arrowAreaBounds.width); + + GET_SHAPE_CONFIG(DATETIMEBAR::ITEM_HEIGHT, orientation, itemHeight); + + bodyAreaBounds.width = parentWindowBounds.width; + bodyAreaBounds.height = itemHeight; + + bodyAreaBounds.x = 0; + Point tempPoint = __pDateTimeBar->GetPosition(); + windowAreaBounds.x = tempPoint.x; + + if (__pDateTimeBar->GetAlignment() == DATETIME_BAR_ALIGN_DOWN) + { + bodyAreaBounds.y = arrowAreaBounds.height; + arrowAreaBounds.y = 0; + windowAreaBounds.y = tempPoint.y - arrowAreaBounds.height; + } + else + { + arrowAreaBounds.y = bodyAreaBounds.height; + bodyAreaBounds.y = 0; + windowAreaBounds.y = tempPoint.y; + } + + windowAreaBounds.width = bodyAreaBounds.width; + windowAreaBounds.height = bodyAreaBounds.height + arrowAreaBounds.height; + + SetBodyBounds(bodyAreaBounds); + SetArrowBounds(arrowAreaBounds); + SetWindowBounds(windowAreaBounds); + __pDateTimeBar->SetMovable(true); + __pDateTimeBar->SetResizable(true); + __pDateTimeBar->SetBounds(windowAreaBounds); + __pDateTimeBar->SetMovable(false); + __pDateTimeBar->SetResizable(false); + + return E_SUCCESS; +} + +void +_DateTimeBarPresenter::SetBodyBounds(const Rectangle& bounds) +{ + __bodyAreaBounds = bounds; + return; +} + +Rectangle +_DateTimeBarPresenter::GetBodyBounds(void) const +{ + return __bodyAreaBounds; +} + +void +_DateTimeBarPresenter::SetArrowBounds(const Rectangle& bounds) +{ + __arrowAreaBounds = bounds; + return; +} + +Rectangle +_DateTimeBarPresenter::GetArrowBounds(void) const +{ + return __arrowAreaBounds; +} + +void +_DateTimeBarPresenter::SetWindowBounds(const Rectangle& bounds) +{ + __windowAreaBounds = bounds; + return; +} + +Rectangle +_DateTimeBarPresenter::GetWindowBounds(void) const +{ + return __windowAreaBounds; +} + +bool +_DateTimeBarPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pDateTimeBar) + { + return false; + } + + if (GetBodyBounds().Contains(touchinfo.GetCurrentPosition()) == false) + { + return false; + } + + if (__isFlickEnabled) + { + ResetFlickAnimationTimer(); + } + + __touchMoveHandled = false; + + __currentPoint = touchinfo.GetCurrentPosition(); + + int index = GetItemIndexFromPosition(touchinfo.GetCurrentPosition()); + + if (index == -1) + { + return true; + } + + __pDateTimeBar->Draw(); + + return true; +} + +bool +_DateTimeBarPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pDateTimeBar) + { + return false; + } + + int index = GetItemIndexFromPosition(touchinfo.GetCurrentPosition()); + bool isEventFire = true; + + if (index != -1 && __isTouchMoved == false && __isFlickEnabled == false) + { + SetItemStatus(index, DATETIMEBAR_ITEM_STATUS_SELECTED); + __pDateTimeBarModel->SetFirstDrawnItemIndex(index); + } + else + { + isEventFire = false; + } + + __isTouchMoved = false; + __distance = 0; + + __pDateTimeBar->Draw(); + + if (GetBodyBounds().Contains(touchinfo.GetCurrentPosition()) == false) + { + __pDateTimeBar->Close(); + ResetFlickAnimationTimer(); + return false; + } + + if (isEventFire == true) + { + int index = GetFirstDrawnItemIndex(); + + _DateTimeBarItem* pItem = null; + + if (index >= 0) + { + pItem = GetItemAt(index); + } + + if (pItem != null) + { + __pDateTimeBar->Close(); + + __pDateTimeBar->FireActionEvent(pItem->GetActionId()); + + if (__pDateTimeBar->GetSelectedBoxId() >= DATETIME_ID_YEAR && __pDateTimeBar->GetSelectedBoxId() <= DATETIME_ID_DAY) + { + __pDateTimeBar->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_SAVED); + } + else if (__pDateTimeBar->GetSelectedBoxId() >= DATETIME_ID_HOUR && __pDateTimeBar->GetSelectedBoxId() <= DATETIME_ID_MINUTE) + { + __pDateTimeBar->FireDateTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED); + } + } + } + + return true; +} + +bool +_DateTimeBarPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pDateTimeBar) + { + return false; + } + + if (GetBodyBounds().Contains(touchinfo.GetCurrentPosition()) == false || __touchMoveHandled == true) + { + return false; + } + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + __isTouchMoved = true; + + Dimension screen(0, 0); + GET_DIMENSION_CONFIG(DATETIMEBAR::DEFAULT_SIZE, orientation, screen); + + const int _BOUNDARY_X_POSITION = screen.width * 2; + int distance = (touchinfo.GetCurrentPosition()).x - __currentPoint.x; + + _DateTimeBarItem* pItem = null; + + Rectangle itemBounds; + + bool needItem = false; + int updateItemCount = 1; + + if (distance > 0) + { + pItem = __pDateTimeBarModel->GetItemAt(GetFirstDrawnItemIndex()); + + if (pItem == null) + { + return true; + } + + itemBounds = pItem->GetBounds(); + + __distance += distance; + + if (__distance > itemBounds.width / 2) + { + needItem = true; + if (__distance > itemBounds.width) + { + updateItemCount = UPDATE_ITEM_COUNT; + } + } + if (needItem == true) + { + while (updateItemCount > 0) + { + pItem = __pDateTimeBarModel->GetItemAt(GetFirstDrawnItemIndex()); + if (pItem == null) + { + break; + } + + int actionId = pItem->GetActionId() - 1; + + if (__pDateTimeBarModel->GetMinimumValue() > actionId) + { + actionId = __pDateTimeBarModel->GetMaximumValue(); + } + + if (pItem->GetBounds().x > _BOUNDARY_X_POSITION * -1) + { + if (InsertItem(0, actionId) == E_SUCCESS) + { + SetFirstDrawnItemIndex(0); + } + } + + if (GetItemCount() >= __pDateTimeBarModel->GetMaxCachingSize()) + { + DeleteItem(GetItemCount() - 1); + } + + updateItemCount--; + } + __distance = 0; + } + } + else + { + pItem = __pDateTimeBarModel->GetItemAt(GetItemCount() - 1); + if (pItem == null) + { + return true; + } + + itemBounds = pItem->GetBounds(); + + __distance += distance; + + if (__distance * -1 > itemBounds.width / 2) + { + needItem = true; + if (__distance * -1 > itemBounds.width) + { + updateItemCount = UPDATE_ITEM_COUNT; + } + __distance = 0; + } + + if (needItem == true) + { + while (updateItemCount > 0) + { + pItem = __pDateTimeBarModel->GetItemAt(GetItemCount() - 1); + if (pItem == null) + { + break; + } + + int actionId = pItem->GetActionId() + 1; + + if (__pDateTimeBarModel->GetMaximumValue() < actionId) + { + actionId = __pDateTimeBarModel->GetMinimumValue(); + } + + if (pItem->GetBounds().x < _BOUNDARY_X_POSITION) + { + AddItem(actionId); + } + + if (GetItemCount() >= __pDateTimeBarModel->GetMaxCachingSize()) + { + DeleteItem(0); + SetFirstDrawnItemIndex(0); + } + updateItemCount--; + } + } + } + + __currentPoint = touchinfo.GetCurrentPosition(); + + AdjustItemPosition(distance); + + __pDateTimeBar->Draw(); + + return true; +} + +bool +_DateTimeBarPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pDateTimeBar) + { + return false; + } + + __isTouchMoved = false; + __distance = 0; + + __pDateTimeBar->Draw(); + + return true; +} + +result +_DateTimeBarPresenter::LoadItems() +{ + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + Dimension screen(0, 0); + GET_DIMENSION_CONFIG(DATETIMEBAR::DEFAULT_SIZE, orientation, screen); + + const int _BOUNDARY_X_POSITION = screen.width * 2; + + _DateTimeBarItem* pItem = null; + + Rectangle itemBounds; + + int updateItemCount = UPDATE_ITEM_COUNT; + + if (__distance > 0) + { + pItem = __pDateTimeBarModel->GetItemAt(GetFirstDrawnItemIndex()); + + if (pItem == null) + { + return true; + } + + + while (updateItemCount > 0) + { + pItem = __pDateTimeBarModel->GetItemAt(GetFirstDrawnItemIndex()); + if (pItem == null) + { + break; + } + + int actionId = pItem->GetActionId() - 1; + + if (__pDateTimeBarModel->GetMinimumValue() > actionId) + { + actionId = __pDateTimeBarModel->GetMaximumValue(); + } + + if (pItem->GetBounds().x > _BOUNDARY_X_POSITION * -1) + { + if (InsertItem(0, actionId) == E_SUCCESS) + { + SetFirstDrawnItemIndex(0); + } + } + + if (GetItemCount() >= __pDateTimeBarModel->GetMaxCachingSize()) + { + DeleteItem(GetItemCount() - 1); + } + updateItemCount--; + } + + } + else + { + pItem = __pDateTimeBarModel->GetItemAt(GetItemCount() - 1); + if (pItem == null) + { + return true; + } + + + while (updateItemCount > 0) + { + pItem = __pDateTimeBarModel->GetItemAt(GetItemCount() - 1); + if (pItem == null) + { + break; + } + + int actionId = pItem->GetActionId() + 1; + + if (__pDateTimeBarModel->GetMaximumValue() < actionId) + { + actionId = __pDateTimeBarModel->GetMinimumValue(); + } + + if (pItem->GetBounds().x < _BOUNDARY_X_POSITION) + { + AddItem(actionId); + } + + if (GetItemCount() >= __pDateTimeBarModel->GetMaxCachingSize()) + { + DeleteItem(0); + SetFirstDrawnItemIndex(0); + } + updateItemCount--; + } + } + + return true; +} + +bool +_DateTimeBarPresenter::OnFlickGestureDetected(int distanceX,int distanceY,int duration) +{ + __isFlickEnabled = true; + __isInitialAnimation = false; + + int velX = 0; + int velY = 0; + + __flickAnimation.CalculateInitializeVelocity(distanceX, 0, duration, &velX, &velY); + __flickAnimation.InitializeFlickAmount(velX); + + StartFlickAnimationTimer(); + return true; +} + +void +_DateTimeBarPresenter::StartFlickAnimation(void) +{ + int moveX = 0; + int moveY = 0; + + __flickAnimation.CalculateNextMove(&moveX, &moveY); + + __distance = moveX; + if (moveX != 0) + { + StartFlickAnimationTimer(); + } + + LoadItems(); + AdjustItemPosition(__distance); + Draw(); + return; +} + +void +_DateTimeBarPresenter::StartAnimationEffect(void) +{ + __isInitialAnimation = true; + __distance = -10; + + if (__initialAnimationValue >= 0 ) + { + __initialAnimationValue = __initialAnimationValue + __distance; + StartFlickAnimationTimer(); + + LoadItems(); + AdjustItemPosition(__distance); + Draw(); + } + else + { + __initialAnimationValue = 0; + __isInitialAnimation = false; + ResetFlickAnimationTimer(); + ValidateAndAdjustStartPosition(); + } + + return; +} + +result +_DateTimeBarPresenter::StartFlickAnimationTimer(void) +{ + result r = E_SUCCESS; + + if (__pFlickAnimationTimer == null) + { + __pFlickAnimationTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI_CTRL, (__pFlickAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create timer."); + + r = __pFlickAnimationTimer->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pFlickAnimationTimer->Cancel(); + } + + r = __pFlickAnimationTimer->Start(FLICK_ANIMATION_TIMER_PERIOD); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + ResetFlickAnimationTimer(); + return r; +} + +result +_DateTimeBarPresenter::ResetFlickAnimationTimer(void) +{ + if (__pFlickAnimationTimer) + { + delete __pFlickAnimationTimer; + __pFlickAnimationTimer = null; + } + + __isFlickEnabled = false; + return E_SUCCESS; +} + +void +_DateTimeBarPresenter::OnTimerExpired(Timer& timer) +{ + if (&timer == __pFlickAnimationTimer) + { + if (__isInitialAnimation) + { + StartAnimationEffect(); + } + else + { + StartFlickAnimation(); + } + } + return; +} + +void +_DateTimeBarPresenter::ValidateAndAdjustStartPosition(void) +{ + int index = -1; + int adjustPosition = 0; + int leftMargin = GetLeftRightMargin(); + Rectangle bodyBounds = GetBodyBounds(); + + index = GetItemIndexFromPosition(Point(GetLeftRightMargin() + GetItemMargin(), bodyBounds.y + (bodyBounds.height / 2))); + + if (index == -1) + { + return; + } + + _DateTimeBarItem* pDrawItem = null; + pDrawItem = __pDateTimeBarModel->GetItemAt(index); + + if (pDrawItem == null) + { + return; + } + + if (pDrawItem->GetBounds().x > 0 && pDrawItem->GetBounds().x < leftMargin) + { + adjustPosition = leftMargin - pDrawItem->GetBounds().x; + } + else if (pDrawItem->GetBounds().x < 0) + { + pDrawItem = __pDateTimeBarModel->GetItemAt(index + 1); + if (pDrawItem == null) + { + return; + } + adjustPosition = leftMargin - pDrawItem->GetBounds().x; + } + else if (pDrawItem->GetBounds().x > leftMargin) + { + adjustPosition = leftMargin - pDrawItem->GetBounds().x; + } + + AdjustItemPosition(adjustPosition); + Draw(); + return; +} + +void +_DateTimeBarPresenter::SetInitialAnimationValue(int animationValue) +{ + __initialAnimationValue = animationValue; + return; +} + +void +_DateTimeBarPresenter::SetFont(Font& pFont) +{ + delete __pFont; + __pFont = null; + + __pFont = _FontImpl::CloneN(pFont); + SysTryReturnVoidResult(NID_UI_CTRL, (__pFont != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return; +} + +bool +_DateTimeBarPresenter::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + __distance = (GetItemWidth() + GetItemMargin()) * (-1); + + if (element.GetBounds().x + element.GetBounds().width > GetWindowBounds().width) + { + AdjustItemPosition(__distance); + Draw(); + } + return true; +} + +bool +_DateTimeBarPresenter::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + __distance = (GetItemWidth() + GetItemMargin()); + + if (element.GetBounds().x < GetWindowBounds().x) + { + AdjustItemPosition(__distance); + Draw(); + } + return true; +} + +void +_DateTimeBarPresenter::OnTouchMoveHandled(const Tizen::Ui::_Control& control) +{ + __touchMoveHandled = true; + + __isTouchMoved = false; + __distance = 0; + + __pDateTimeBar->Draw(); +} + +void +_DateTimeBarPresenter::RefreshAccessibilityElement(void) +{ + __pDateTimeBar->RemoveAllAccessibilityElement(); + + for (int index = 0; index < __pDateTimeBarModel->GetItemCount(); index++) + { + _DateTimeBarItem* pItem = __pDateTimeBarModel->GetItemAt(index); + + if (pItem != null) + { + if (__pDateTimeBar->GetSelectedBoxId() == DATETIME_ID_MONTH) + { + __pDateTimeBar->AddAccessibilityElement(pItem->GetBounds(), __pDateTimeBar->GetMonthValue(pItem->GetActionId())); + } + else + { + __pDateTimeBar->AddAccessibilityElement(pItem->GetBounds(), pItem->GetText()); + } + } + } + + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DateTimeChangeEvent.cpp b/src/ui/controls/FUiCtrl_DateTimeChangeEvent.cpp new file mode 100644 index 0000000..56bb367 --- /dev/null +++ b/src/ui/controls/FUiCtrl_DateTimeChangeEvent.cpp @@ -0,0 +1,175 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DateTimeChangeEvent.cpp + * @brief This is the implementation file for the _DateTimeChangeEvent and _DateTimeChangeEventArg classes. + */ + +#include +#include +#include +#include "FUiCtrl_DateTimeChangeEvent.h" +#include "FUiCtrl_IDateTimeChangeEventListener.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::System; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_DateTimeChangeEventArg::_DateTimeChangeEventArg(_DateTimeChangeStatus status) + : __status(status) + , __year(1) + , __month(1) + , __day(1) + , __hour(0) + , __minute(0) +{ + SystemTime::GetCurrentTime(WALL_TIME, __dateTime); +} + +_DateTimeChangeEventArg::~_DateTimeChangeEventArg(void) +{ + // Nothing. +} + +void +_DateTimeChangeEventArg::SetDateTime(const DateTime& dateTime) +{ + __dateTime = dateTime; + + return; +} + +int +_DateTimeChangeEventArg::GetYear(void) const +{ + return __year; +} + +int +_DateTimeChangeEventArg::GetMonth(void) const +{ + return __month; +} + +int +_DateTimeChangeEventArg::GetDay(void) const +{ + return __day; +} + +int +_DateTimeChangeEventArg::GetHour(void) const +{ + return __hour; +} + +int +_DateTimeChangeEventArg::GetMinute(void) const +{ + return __minute; +} + +DateTime +_DateTimeChangeEventArg::GetDateTime(void) const +{ + return __dateTime; +} + +_DateTimeChangeStatus +_DateTimeChangeEventArg::GetStatus(void) const +{ + return __status; +} + +void +_DateTimeChangeEventArg::SetTime(int hour, int minute) +{ + __hour = hour; + __minute = minute; + + return; +} + +void +_DateTimeChangeEventArg::SetDate(int year, int month, int day) +{ + __year = year; + __month = month; + __day = day; + + return; +} + +_DateTimeChangeEvent::_DateTimeChangeEvent(const Tizen::Ui::_Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + if (r == E_SUCCESS) + { + __pSource = const_cast<_Control*>(&source); + } +} + +_DateTimeChangeEvent::~_DateTimeChangeEvent(void) +{ + // Nothing. +} + +void +_DateTimeChangeEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // DateTimePicker + _IDateTimeChangeEventListener* pDateTimeChangeEventListener = dynamic_cast <_IDateTimeChangeEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, (pDateTimeChangeEventListener != null), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The instance of _IDateTimeChangeEventListener is null."); + + // cast Argument + const _DateTimeChangeEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, (pArg != null), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The instance of _DateTimeChangeEventArg is null."); + + switch (pArg->GetStatus()) + { + case DATE_INTERNAL_CHANGE_SAVED: + // fall through + case DATETIME_INTERNAL_CHANGE_SAVED: + // fall through + case TIME_INTERNAL_CHANGE_SAVED: + pDateTimeChangeEventListener->OnDateTimeChanged(*__pSource, pArg->GetYear(), pArg->GetMonth(), + pArg->GetDay(), pArg->GetHour(), pArg->GetMinute()); + break; + + case DATE_INTERNAL_CHANGE_CANCELED: + // fall through + case DATETIME_INTERNAL_CHANGE_CANCELED: + // fall through + case TIME_INTERNAL_CHANGE_CANCELED: + pDateTimeChangeEventListener->OnDateTimeChangeCanceled(*__pSource); + break; + + default: + break; + } + + SetLastResult(E_SUCCESS); + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DateTimeDisplayBox.cpp b/src/ui/controls/FUiCtrl_DateTimeDisplayBox.cpp new file mode 100644 index 0000000..2e476f0 --- /dev/null +++ b/src/ui/controls/FUiCtrl_DateTimeDisplayBox.cpp @@ -0,0 +1,318 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DateTimeDisplayBox.cpp + * @brief This is the implementation file for the _DateTimeDisplayBox class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_DateTimeDisplayBox.h" +#include "FUiCtrl_DateTimeDefine.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_DateTimeDisplayBox::_DateTimeDisplayBox(const Rectangle& bounds, int boxId) + : __windowBounds(bounds) + , __boxId(boxId) + , __pTextObject(null) + , __text() + , __focusable(true) + , __pFont(null) + , __pBackgroundEffectBitmap(null) + , __pBackgroundPressedEffectBitmap(null) + , __pBackgroundDisabledEffectBitmap(null) +{ + for (int i = 0; i < DATETIME_STATUS_MAX; i++) + { + __pBackgroundNormalBitmap[i] = null; + } + + for (int i = 0; i < DATETIME_STATUS_MAX; i++) + { + __backgroundColor[i] = Color(); + } + + GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_NORMAL, __textColor[DATETIME_STATUS_NORMAL]); + GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_HIGHLIGHTED, __textColor[DATETIME_STATUS_FOCUSED]); + GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_PRESSED, __textColor[DATETIME_STATUS_SELECTED]); + GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_DISABLED, __textColor[DATETIME_STATUS_DISABLED]); +} + +_DateTimeDisplayBox::~_DateTimeDisplayBox(void) +{ + if (__pTextObject != null) + { + __pTextObject->RemoveAll(); + delete __pTextObject; + __pTextObject = null; + } + + for (int i = 0; i < DATETIME_STATUS_MAX; i++) + { + delete __pBackgroundNormalBitmap[i]; + __pBackgroundNormalBitmap[i] = null; + } +} + +Rectangle +_DateTimeDisplayBox::GetDisplayBoxBounds(void) const +{ + return __windowBounds; +} + +int +_DateTimeDisplayBox::GetDisplayBoxId(void) const +{ + return __boxId; +} + +bool +_DateTimeDisplayBox::SetText(const String& text) +{ + result r = E_SUCCESS; + TextSimple* pSimpleText = null; + + TextObject * pTextObject = new (std::nothrow) TextObject; + SysTryReturn(NID_UI_CTRL, (pTextObject != null), false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __text.Clear(); + __text = text; + wchar_t* pString = const_cast (__text.GetPointer()); + + r = pTextObject->Construct(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pSimpleText = new (std::nothrow)TextSimple(pString, __text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_UI_CTRL, (pSimpleText != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pTextObject->AppendElement(*pSimpleText); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTextObject->SetFont(__pFont, 0, pTextObject->GetTextLength()); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pTextObject != null) + { + r = __pTextObject->RemoveAll(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pTextObject; + __pTextObject = null; + } + __pTextObject = pTextObject; + + return true; + +CATCH: + pTextObject->RemoveAll(); + + delete pTextObject; + delete pSimpleText; + + return false; +} + +const String& +_DateTimeDisplayBox::GetText(void) const +{ + return __text; +} + +void +_DateTimeDisplayBox::DrawDisplayBox(Canvas& canvas, DateTimePickerStatus status) +{ + if ((__focusable == false) && (status == DATETIME_STATUS_FOCUSED)) + { + status = DATETIME_STATUS_NORMAL; + } + + DrawBackground(canvas, status); + DrawText(canvas, status); + + return; +} + +void +_DateTimeDisplayBox::DrawBackground(Canvas& canvas, DateTimePickerStatus status) +{ + result r = E_SUCCESS; + + if (__pBackgroundNormalBitmap[status] == null) + { + return; + } + + if (__pBackgroundNormalBitmap[status]->IsNinePatchedBitmap() == true) + { + r = canvas.DrawNinePatchedBitmap(__windowBounds, *__pBackgroundNormalBitmap[status]); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = canvas.DrawBitmap(__windowBounds, *__pBackgroundNormalBitmap[status]); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (status == DATETIME_STATUS_FOCUSED && __pBackgroundPressedEffectBitmap != null ) + { + if (__pBackgroundEffectBitmap->IsNinePatchedBitmap() == true) + { + r = canvas.DrawNinePatchedBitmap(__windowBounds, *__pBackgroundPressedEffectBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = canvas.DrawBitmap(__windowBounds, *__pBackgroundPressedEffectBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else if (status == DATETIME_STATUS_DISABLED && __pBackgroundDisabledEffectBitmap != null) + { + if (__pBackgroundDisabledEffectBitmap->IsNinePatchedBitmap() == true) + { + r = canvas.DrawNinePatchedBitmap(__windowBounds, *__pBackgroundDisabledEffectBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = canvas.DrawBitmap(__windowBounds, *__pBackgroundDisabledEffectBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else if (__pBackgroundEffectBitmap != null) + { + if (__pBackgroundEffectBitmap->IsNinePatchedBitmap() == true) + { + r = canvas.DrawNinePatchedBitmap(__windowBounds, *__pBackgroundEffectBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = canvas.DrawBitmap(__windowBounds, *__pBackgroundEffectBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + return; +} + +void +_DateTimeDisplayBox::DrawText(Canvas& canvas, DateTimePickerStatus status) +{ + SysTryReturnVoidResult(NID_UI_CTRL, (__pTextObject != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The instance of TextObject is null."); + + result r = E_SUCCESS; + + r = __pTextObject->SetForegroundColor(__textColor[status], 0, __pTextObject->GetTextLength()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pTextObject->SetBounds(__windowBounds); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas)); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +_DateTimeDisplayBox::SetFocusable(bool focusable) +{ + __focusable = focusable; + + return; +} + +void +_DateTimeDisplayBox::SetBackgroundBitmap(Bitmap* pNormalBitmap, Bitmap* pEffectBitmap, Bitmap* pPressedEffectBitmap, Bitmap* pDisabledEffectBitmap) +{ + result r = E_SUCCESS; + + GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_NORMAL, __backgroundColor[DATETIME_STATUS_NORMAL]); + GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_PRESSED, __backgroundColor[DATETIME_STATUS_SELECTED]); + GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_HIGHLIGHTED, __backgroundColor[DATETIME_STATUS_FOCUSED]); + GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_BG_DISABLED, __backgroundColor[DATETIME_STATUS_DISABLED]); + + GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_TEXT_NORMAL, __textColor[DATETIME_STATUS_NORMAL]); + GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_TEXT_PRESSED, __textColor[DATETIME_STATUS_SELECTED]); + GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_TEXT_HIGHLIGHTED, __textColor[DATETIME_STATUS_FOCUSED]); + GET_COLOR_CONFIG(DATETIMEPICKER::AMPM_TEXT_DISABLED, __textColor[DATETIME_STATUS_DISABLED]); + + for (int i = 0; i < DATETIME_STATUS_MAX; i++) + { + __pBackgroundNormalBitmap[i] = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), __backgroundColor[i]); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (__pBackgroundNormalBitmap[i] != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __pBackgroundEffectBitmap = pEffectBitmap; + __pBackgroundPressedEffectBitmap = pPressedEffectBitmap; + __pBackgroundDisabledEffectBitmap = pDisabledEffectBitmap; + + return; + +CATCH: + for (int i = 0; i < DATETIME_STATUS_MAX; i++) + { + delete __pBackgroundNormalBitmap[i]; + __pBackgroundNormalBitmap[i] = null; + } + + return; +} + +void +_DateTimeDisplayBox::UpdateDisplayBoxBounds(Rectangle& bounds) +{ + __windowBounds = bounds; + + return; +} + +void +_DateTimeDisplayBox::SetFont(Font* pFont) +{ + __pFont = pFont; + + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DateTimeModel.cpp b/src/ui/controls/FUiCtrl_DateTimeModel.cpp new file mode 100644 index 0000000..5ece421 --- /dev/null +++ b/src/ui/controls/FUiCtrl_DateTimeModel.cpp @@ -0,0 +1,210 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DateTimeModel.cpp + * @brief This is the implementation file for the _DateTimeModel class. + */ + +#include +#include +#include +#include "FUiCtrl_DateTimeModel.h" + +using namespace Tizen::Base; +using namespace Tizen::System; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_DateTimeModel::~_DateTimeModel(void) +{ +} + +_DateTimeModel::_DateTimeModel(void) + : __year(1) + , __month(1) + , __day(1) + , __maxYear(DATETIME_YEAR_MAX) + , __minYear(DATETIME_YEAR_MIN) + , __hour(0) + , __minute(0) + , __second(0) +{ + SetCurrentDateTime(); + SetSecond(0); +} + +void +_DateTimeModel::SetCurrentDateTime(void) +{ + DateTime dateTime; + SystemTime::GetCurrentTime(WALL_TIME, dateTime); + + SetYear(dateTime.GetYear()); + SetMonth(dateTime.GetMonth()); + SetDay(dateTime.GetDay()); + SetHour(dateTime.GetHour()); + SetMinute(dateTime.GetMinute()); + SetSecond(dateTime.GetSecond()); +} + +DateTime +_DateTimeModel::GetDateTime(void) const +{ + DateTime dateTime; + dateTime.SetValue(GetYear(), GetMonth(), GetDay(), GetHour(), GetMinute(), GetSecond()); + + return dateTime; +} + +void +_DateTimeModel::SetDateTime(const DateTime& dateTime) +{ + SetYear(dateTime.GetYear()); + SetMonth(dateTime.GetMonth()); + SetDay(dateTime.GetDay()); + SetHour(dateTime.GetHour()); + SetMinute(dateTime.GetMinute()); + SetSecond(dateTime.GetSecond()); +} + +result +_DateTimeModel::SetYear(int year) +{ + __year = year; + + return E_SUCCESS; +} + +result +_DateTimeModel::SetMonth(int month) +{ + __month = month; + + return E_SUCCESS; +} + +result +_DateTimeModel::SetDay(int day) +{ + __day = day; + + return E_SUCCESS; +} + +result +_DateTimeModel::SetHour(int hour) +{ + __hour = hour; + + return E_SUCCESS; +} + +result +_DateTimeModel::SetMinute(int minute) +{ + __minute = minute; + + return E_SUCCESS; +} + +void +_DateTimeModel::SetSecond(int second) +{ + if (second < DATETIME_SECOND_MIN) + { + second = 0; + } + else if (second > DATETIME_SECOND_MAX) + { + second = DATETIME_SECOND_MAX; + } + + __second = second; +} + +result +_DateTimeModel::SetMaxYear(int maxYear) +{ + __maxYear = maxYear; + + if (__maxYear < __year) + { + __year = __maxYear; + } + + return E_SUCCESS; +} + +result +_DateTimeModel::SetMinYear(int minYear) +{ + __minYear = minYear; + + if (__minYear > __year) + { + __year = __minYear; + } + + return E_SUCCESS; +} + +int +_DateTimeModel::GetYear(void) const +{ + return __year; +} + +int +_DateTimeModel::GetMonth(void) const +{ + return __month; +} + +int +_DateTimeModel::GetDay(void) const +{ + return __day; +} + +int +_DateTimeModel::GetHour(void) const +{ + return __hour; +} + +int +_DateTimeModel::GetMinute(void) const +{ + return __minute; +} + +int +_DateTimeModel::GetSecond(void) const +{ + return __second; +} + +result +_DateTimeModel::GetYearRange(int& minYear, int& maxYear) const +{ + minYear = __minYear; + maxYear = __maxYear; + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DateTimePicker.cpp b/src/ui/controls/FUiCtrl_DateTimePicker.cpp new file mode 100644 index 0000000..e657f0f --- /dev/null +++ b/src/ui/controls/FUiCtrl_DateTimePicker.cpp @@ -0,0 +1,1160 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DateTimePicker.cpp + * @brief This is the implementation file for the _DateTimePicker class. + */ + +#include +#include +#include +#include + +#include "FUiCtrl_DateTimePicker.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_DateTimeDefine.h" +#include "FUiCtrl_DateTimePresenter.h" +#include "FUiCtrl_DateTimeDisplayBox.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_Toolbar.h" +#include "FUiCtrl_DateTimeChangeEvent.h" +#include "FUiCtrl_IDateTimeChangeEventListener.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_DateTimePicker); + +_DateTimePicker::_DateTimePicker(_DateTimePresenter* pPresenter, const String& title) + : __pPresenter(pPresenter) + , __pHeader(null) + , __pFooter(null) + , __title(title) + , __pDateTimeChangeEvent(null) + , __pFont(null) + , __pDisplayVisualElement(null) +{ + GetAccessibilityContainer()->Activate(true); +} + +_DateTimePicker::~_DateTimePicker(void) +{ + if (__pDateTimeChangeEvent != null) + { + delete __pDateTimeChangeEvent; + __pDateTimeChangeEvent = null; + } + + if (__pHeader != null) + { + DetachSystemChild(*__pHeader); + delete __pHeader; + __pHeader = null; + } + + if (__pFooter != null) + { + DetachSystemChild(*__pFooter); + delete __pFooter; + __pFooter = null; + } + + if (__pDisplayVisualElement != null) + { + __pDisplayVisualElement->Destroy(); + __pDisplayVisualElement = null; + } + + delete __pPresenter; + __pPresenter = null; + + if (likely(_AccessibilityManager::IsActivated())) + { + _AccessibilityElement* pElement = null; + while (__accessibilityElements.GetCount() > 0) + { + if ((__accessibilityElements.GetAt(0, pElement)) == E_SUCCESS) + { + __accessibilityElements.RemoveAt(0); + pElement->GetParent()->RemoveElement(*pElement); + } + else + { + __accessibilityElements.RemoveAt(0); + } + } + } +} + +_DateTimePicker* +_DateTimePicker::CreateDateTimePickerN(int style, const String& title) +{ + result r = E_SUCCESS; + Dimension pickerSize(0, 0); + Dimension screenSize(0, 0); + _ControlOrientation orientation = _CONTROL_ORIENTATION_PORTRAIT; + + SysTryReturn(NID_UI_CTRL, ((style & DATETIME_OUTPUT_STYLE_DATETIME) != DATETIME_OUTPUT_STYLE_INVALID), null, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The style provided is not present in the _DateTimeOutputStyle list."); + + _DateTimePresenter* pPresenter = new (std::nothrow) _DateTimePresenter(style, title); + SysTryReturn(NID_UI_CTRL, (pPresenter != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + _DateTimePicker* pView = new (std::nothrow) _DateTimePicker(pPresenter, title); + SysTryCatch(NID_UI_CTRL, (pView != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pView->InitializeFont(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to set the Font."); + +#if defined(MULTI_WINDOW) + r = pView->CreateRootVisualElement(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); +#endif + + orientation = pView->GetOrientation(); + screenSize = _ControlManager::GetInstance()->GetScreenSize(); + pickerSize = screenSize; + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + pickerSize.width = screenSize.height; + pickerSize.height = screenSize.width; + } + r = pView->SetSize(pickerSize); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set the size for this control"); + + if (title.IsEmpty() == false && orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + r = pView->CreateHeader(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to create the header for this control"); + } + + r = pView->CreateFooter(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to create the footer for this control"); + + r = pView->CreateDisplayVisualElement(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to create the display visual element for this control"); + + r = pPresenter->Construct(*pView); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to construct the presenter instance for this control"); + + pView->AcquireHandle(); + + pView->__pDateTimeChangeEvent = new (std::nothrow) _DateTimeChangeEvent(*pView); + SysTryCatch(NID_UI_CTRL, (pView->__pDateTimeChangeEvent != null), , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (likely(_AccessibilityManager::IsActivated()) && pView->GetAccessibilityContainer() != null) + { + pView->GetAccessibilityContainer()->Activate(true); + } + + return pView; + +CATCH: + delete pPresenter; + delete pView; + + return null; +} + +result +_DateTimePicker::CreateHeader(void) +{ + Rectangle indicatorBounds(0, 0, 0, 0); + Rectangle headerBounds(0, 0, 0, 0); + _Frame* pFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame()); + SysTryReturnResult(NID_UI_CTRL, (pFrame != null), E_SYSTEM, + "A system error has occurred. Failed to get the instance of frame."); + + _Form* pForm = pFrame->GetCurrentForm(); + SysTryReturnResult(NID_UI_CTRL, (pForm != null), E_SYSTEM, + "A system error has occurred. Failed to get the instance of form."); + + indicatorBounds = pForm->GetIndicatorBounds(); + + _Toolbar* pHeader = _Toolbar::CreateToolbarN(true); + result r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, (pHeader != null), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = AttachSystemChild(*pHeader); + if (r != E_SUCCESS) + { + delete pHeader; + return r; + } + + pHeader->SetStyle(TOOLBAR_TITLE); + pHeader->SetTitleText(__title); + pHeader->SetMovable(true); + pHeader->SetResizable(true); + headerBounds = pHeader->GetBounds(); + headerBounds.y = indicatorBounds.height; + pHeader->SetBounds(headerBounds); + pHeader->SetMovable(false); + pHeader->SetResizable(false); + + if (__pHeader != null) + { + DetachSystemChild(*__pHeader); + delete __pHeader; + __pHeader = null; + } + + __pHeader = pHeader; + + return E_SUCCESS; +} + +result +_DateTimePicker::DestroyHeader(void) +{ + if (__pHeader != null) + { + DetachSystemChild(*__pHeader); + delete __pHeader; + __pHeader = null; + } + + return E_SUCCESS; +} + +result +_DateTimePicker::CreateFooter(void) +{ + result r = E_SUCCESS; + _Button* pSaveButton = null; + _Button* pCancelButton = null; + Rectangle bounds; + String text; + _ControlOrientation orientation = GetOrientation(); + + _Toolbar* pFooter = _Toolbar::CreateToolbarN(false); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, (pFooter != null), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = AttachSystemChild(*pFooter); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_SHAPE_CONFIG(DATETIMEPICKER::FOOTER_HEIGHT, orientation, bounds.height); + GET_SHAPE_CONFIG(DATETIMEPICKER::INPUTPAD_HEIGHT, orientation, bounds.y); + + bounds.x = 0; + bounds.y = GetBounds().height - bounds.y - bounds.height; + bounds.width = GetBounds().width; + + pFooter->SetMovable(true); + pFooter->SetResizable(true); + + r = pFooter->SetBounds(bounds); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pFooter->SetMovable(false); + pFooter->SetResizable(false); + + pFooter->AddActionEventListener(*this); + + r = pFooter->SetStyle(TOOLBAR_TEXT); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Create 'Save' button + pSaveButton = _Button::CreateButtonN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pSaveButton->SetActionId(DATETIME_EVENT_ID_SAVE); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_STRING_CONFIG(IDS_COM_SK_SAVE, text); + + r = pSaveButton->SetText(text); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Create 'Cancel' button + pCancelButton = _Button::CreateButtonN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCancelButton->SetActionId(DATETIME_EVENT_ID_CANCEL); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_STRING_CONFIG(IDS_COM_POP_CANCEL, text); + + r = pCancelButton->SetText(text); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pFooter->AddItem(pSaveButton); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pFooter->AddItem(pCancelButton); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating."); + + if (__pFooter != null) + { + DetachSystemChild(*__pFooter); + + delete __pFooter; + __pFooter = null; + } + + __pFooter = pFooter; + + return E_SUCCESS; +CATCH: + DetachSystemChild(*pFooter); + + delete pFooter; + delete pSaveButton; + delete pCancelButton; + + return r; +} + +result +_DateTimePicker::DestroyFooter(void) +{ + if (__pFooter != null) + { + DetachSystemChild(*__pFooter); + + delete __pFooter; + __pFooter = null; + } + + return E_SUCCESS; +} + +Rectangle +_DateTimePicker::GetHeaderBounds(void) +{ + Rectangle headerBounds(0, 0, 0, 0); + + if (__pHeader != null) + { + headerBounds = __pHeader->GetBounds(); + } + else + { + _Frame* pFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, (pFrame != null), Rectangle(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the instance of frame."); + + _Form* pForm = pFrame->GetCurrentForm(); + SysTryReturn(NID_UI_CTRL, (pForm != null), Rectangle(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the instance of form."); + + headerBounds = pForm->GetIndicatorBounds(); + } + + return headerBounds; +} + +result +_DateTimePicker::CreateDisplayVisualElement(void) +{ + result r = E_SUCCESS; + + __pDisplayVisualElement = new (std::nothrow) _VisualElement(); + SysTryReturnResult(NID_UI_CTRL, __pDisplayVisualElement, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pDisplayVisualElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pDisplayVisualElement->SetShowState(true); + __pDisplayVisualElement->SetImplicitAnimationEnabled(false); + + r = GetVisualElement()->AttachChild(*__pDisplayVisualElement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + __pDisplayVisualElement->Destroy(); + __pDisplayVisualElement = null; + + return r; +} + +void +_DateTimePicker::SetDisplayVisualElementBounds(Rectangle bounds) +{ + if (__pDisplayVisualElement != null) + { + __pDisplayVisualElement->SetBounds(FloatRectangle(bounds.x, bounds.y, bounds.width, bounds.height)); + } + + return; +} + +_VisualElement* +_DateTimePicker::GetDisplayVisualElement(void) +{ + return __pDisplayVisualElement; +} + +result +_DateTimePicker::AddDateTimeChangeEventListener(const Controls::_IDateTimeChangeEventListener& listener) +{ + SysTryReturnResult(NID_UI_CTRL, (__pDateTimeChangeEvent != null), E_SYSTEM, + "A system error has occurred. The _DateTimeChangeEvent instance is null."); + + result r = __pDateTimeChangeEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +result +_DateTimePicker::RemoveDateTimeChangeEventListener(const Controls::_IDateTimeChangeEventListener& listener) +{ + SysTryReturnResult(NID_UI_CTRL, (__pDateTimeChangeEvent != null), E_SYSTEM, + "A system error has occurred. The _DateTimeChangeEvent instance is null."); + + result r = __pDateTimeChangeEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +result +_DateTimePicker::FireDateTimeChangeEvent(_DateTimeChangeStatus status, DateTime& dateTime) +{ + SysTryReturnResult(NID_UI_CTRL, (__pDateTimeChangeEvent != null), E_SYSTEM, + "A system error has occurred. The _DateTimeChangeEvent instance is null"); + + SysTryReturnResult(NID_UI_CTRL, (status >= DATE_INTERNAL_CHANGE_SAVED && status <= TIME_INTERNAL_CHANGE_CANCELED), E_INVALID_ARG, + "Invalid argument(s) is used. The status provided is not present in the _DateTimeChangeStatus list."); + + _DateTimeChangeEventArg* pDateTimeEventArg = new (std::nothrow) _DateTimeChangeEventArg(status); + SysTryReturnResult(NID_UI_CTRL, (pDateTimeEventArg != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + pDateTimeEventArg->SetDateTime(dateTime); + pDateTimeEventArg->SetDate(dateTime.GetYear(), dateTime.GetMonth(), dateTime.GetDay()); + pDateTimeEventArg->SetTime(dateTime.GetHour(), dateTime.GetMinute()); + __pDateTimeChangeEvent->Fire(*pDateTimeEventArg); + + return E_SUCCESS; +} + +result +_DateTimePicker::SetPropertyYear(const Variant& year) +{ + int yearValue = year.ToInt(); + + SysTryReturnResult(NID_UI_CTRL, (yearValue >= DATETIME_YEAR_MIN && yearValue <= DATETIME_YEAR_MAX), E_INVALID_ARG, + "Invalid argument(s) is used. The year (%d) must be greater than or equal to (%d) and less than or equal to (%d).", yearValue, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX); + + return __pPresenter->SetYear(yearValue); +} + +result +_DateTimePicker::SetYear(int year) +{ + return SetProperty("year", Variant(year)); +} + +Variant +_DateTimePicker::GetPropertyYear(void) const +{ + int year = -1; + + year = __pPresenter->GetYear(); + + return Variant(year); +} + +int +_DateTimePicker::GetYear(void) const +{ + Variant year = GetProperty("year"); + + return year.ToInt(); +} + +result +_DateTimePicker::SetPropertyMonth(const Variant& month) +{ + int monthValue = month.ToInt(); + + SysTryReturnResult(NID_UI_CTRL, (monthValue >= DATETIME_MONTH_MIN && monthValue <= DATETIME_MONTH_MAX), E_INVALID_ARG, + "Invalid argument(s) is used. The month (%d) must be greater than or equal to (%d) and less than or equal to (%d).", monthValue, DATETIME_MONTH_MIN, DATETIME_MONTH_MAX); + + return __pPresenter->SetMonth(monthValue); +} + +result +_DateTimePicker::SetMonth(int month) +{ + return SetProperty("month", Variant(month)); +} + +Variant +_DateTimePicker::GetPropertyMonth(void) const +{ + int month = -1; + + month = __pPresenter->GetMonth(); + + return Variant(month); +} + +int +_DateTimePicker::GetMonth(void) const +{ + Variant month = GetProperty("month"); + + return month.ToInt(); +} + +result +_DateTimePicker::SetPropertyDay(const Variant& day) +{ + int dayValue = day.ToInt(); + + SysTryReturnResult(NID_UI_CTRL, (dayValue >= DATETIME_DAY_MIN && dayValue <= DATETIME_DAY_MAX), E_INVALID_ARG, + "Invalid argument(s) is used. The day (%d) must be greater than or equal to (%d) and less than or equal to (%d).", dayValue, DATETIME_DAY_MIN, DATETIME_DAY_MAX); + + return __pPresenter->SetDay(dayValue); + +} + +result +_DateTimePicker::SetDay(int day) +{ + return SetProperty("day", Variant(day)); +} + +Variant +_DateTimePicker::GetPropertyDay(void) const +{ + int day = -1; + + day = __pPresenter->GetDay(); + + return Variant(day); +} + +int +_DateTimePicker::GetDay(void) const +{ + Variant day = GetProperty("day"); + + return day.ToInt(); +} + +result +_DateTimePicker::SetPropertyHour(const Variant& hour) +{ + int hourValue = hour.ToInt(); + + SysTryReturnResult(NID_UI_CTRL, (hourValue >= DATETIME_HOUR_MIN && hourValue <= DATETIME_HOUR_MAX), E_INVALID_ARG, + "Invalid argument(s) is used. The hour (%d) must be greater than or equal to (%d) and less than or equal to (%d).", hourValue, DATETIME_HOUR_MIN, DATETIME_HOUR_MAX); + + return __pPresenter->SetHour(hourValue); + +} + +result +_DateTimePicker::SetHour(int hour) +{ + return SetProperty("hour", Variant(hour)); +} + +Variant +_DateTimePicker::GetPropertyHour(void) const +{ + int hour = -1; + + hour = __pPresenter->GetHour(); + + return Variant(hour); +} + +int +_DateTimePicker::GetHour(void) const +{ + Variant hour = GetProperty("hour"); + + return hour.ToInt(); +} + +result +_DateTimePicker::SetPropertyMinute(const Variant& minute) +{ + int minuteValue = minute.ToInt(); + + SysTryReturnResult(NID_UI_CTRL, (minuteValue >= DATETIME_MINUTE_MIN && minuteValue <= DATETIME_MINUTE_MAX), E_INVALID_ARG, + "Invalid argument(s) is used. The minute (%d) must be greater than or equal to (%d) and less than or equal to (%d).", minuteValue, DATETIME_MINUTE_MIN, DATETIME_MINUTE_MAX); + + return __pPresenter->SetMinute(minuteValue); + +} + +result +_DateTimePicker::SetMinute(int minute) +{ + return SetProperty("minute", Variant(minute)); +} + +Variant +_DateTimePicker::GetPropertyMinute(void) const +{ + int minute = -1; + + minute = __pPresenter->GetMinute(); + + return Variant(minute); +} + +int +_DateTimePicker::GetMinute(void) const +{ + Variant minute = GetProperty("minute"); + + return minute.ToInt(); +} + +result +_DateTimePicker::SetProperty24HourNotation(const Variant& enable) +{ + bool enableValue = enable.ToBool(); + + __pPresenter->Set24HourNotationEnabled(enableValue); + + return E_SUCCESS; +} + +void +_DateTimePicker::Set24HourNotationEnabled(bool enable) +{ + SetProperty("24hourNotation", Variant(enable)); + + return; +} + +Variant +_DateTimePicker::GetProperty24HourNotation(void) const +{ + bool is24HourNotation = false; + + is24HourNotation = __pPresenter->Is24HourNotationEnabled(); + + return Variant(is24HourNotation); +} + +bool +_DateTimePicker::Is24HourNotationEnabled(void) const +{ + Variant enable = GetProperty("24hourNotation"); + + return enable.ToBool(); +} + +result +_DateTimePicker::SetPropertyMinYearRange(const Variant& minYear) +{ + int minYearValue = minYear.ToInt(); + int currentMinYear = DATETIME_YEAR_MIN; + int currentMaxYear = DATETIME_YEAR_MAX; + + SysTryReturnResult(NID_UI_CTRL, (minYearValue >= DATETIME_YEAR_MIN && minYearValue <= DATETIME_YEAR_MAX), E_INVALID_ARG, + "Invalid argument(s) is used. The min year (%d) must be greater than or equal to (%d) and less than or equal to (%d).", minYearValue, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX); + + __pPresenter->GetYearRange(currentMinYear, currentMaxYear); + + SysTryReturnResult(NID_UI_CTRL, (currentMaxYear >= minYearValue), E_INVALID_ARG, + "Invalid argument(s) is used. The year (%d) must be less than or equal to (%d).", minYearValue, currentMaxYear); + + return __pPresenter->SetYearRange(minYearValue, currentMaxYear); +} + +Variant +_DateTimePicker::GetPropertyMinYearRange(void) const +{ + int currentMinYear = DATETIME_YEAR_MIN; + int currentMaxYear = DATETIME_YEAR_MAX; + + __pPresenter->GetYearRange(currentMinYear, currentMaxYear); + + return Variant(currentMinYear); +} + +result +_DateTimePicker::SetPropertyMaxYearRange(const Variant& maxYear) +{ + int maxYearValue = maxYear.ToInt(); + int currentMinYear = DATETIME_YEAR_MIN; + int currentMaxYear = DATETIME_YEAR_MAX; + + SysTryReturnResult(NID_UI_CTRL, (maxYearValue >= DATETIME_YEAR_MIN && maxYearValue <= DATETIME_YEAR_MAX), E_INVALID_ARG, + "Invalid argument(s) is used. The year (%d) must be greater than or equal to (%d) and less than or equal to (%d).", maxYearValue, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX); + + __pPresenter->GetYearRange(currentMinYear, currentMaxYear); + + SysTryReturnResult(NID_UI_CTRL, (maxYearValue >= currentMinYear), E_INVALID_ARG, + "Invalid argument(s) is used. The year (%d) must be greater than or equal to (%d).", maxYearValue, currentMinYear); + + return __pPresenter->SetYearRange(currentMinYear, maxYearValue); +} + +Variant +_DateTimePicker::GetPropertyMaxYearRange(void) const +{ + int currentMinYear = DATETIME_YEAR_MIN; + int currentMaxYear = DATETIME_YEAR_MAX; + + __pPresenter->GetYearRange(currentMinYear, currentMaxYear); + + return Variant(currentMaxYear); +} + +result +_DateTimePicker::SetYearRange(int minYear, int maxYear) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (minYear >= DATETIME_YEAR_MIN && minYear <= DATETIME_YEAR_MAX), E_INVALID_ARG, + "Invalid argument(s) is used. The minYear (%d) must be greater than or equal to (%d) and less than or equal to (%d).", minYear, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX); + SysTryReturnResult(NID_UI_CTRL, (maxYear >= DATETIME_YEAR_MIN && maxYear <= DATETIME_YEAR_MAX), E_INVALID_ARG, + "Invalid argument(s) is used. The maxYear (%d) must be greater than or equal to (%d) and less than or equal to (%d).", maxYear, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX); + SysTryReturnResult(NID_UI_CTRL, (maxYear >= minYear), E_INVALID_ARG, + "Invalid argument(s) is used. The maxYear (%d) must be greater than or equal to minYear (%d).", maxYear, minYear); + + r = SetProperty("minYearRange", Variant(minYear)); + if (r != E_SUCCESS ) + { + return r; + } + + r = SetProperty("maxYearRange", Variant(maxYear)); + + return r; +} + +result +_DateTimePicker::GetYearRange(int& minYear, int& maxYear) const +{ + Variant currentMinYear = GetProperty("minYearRange"); + Variant currentMaxYear = GetProperty("maxYearRange"); + + minYear = currentMinYear.ToInt(); + maxYear = currentMaxYear.ToInt(); + + return E_SUCCESS; +} + +result +_DateTimePicker::SetPropertyDateTime(const Variant& varDateTime) +{ + DateTime dateTime = varDateTime.ToDateTime(); + + __pPresenter->SetDateTime(dateTime); + + return E_SUCCESS; +} + +void +_DateTimePicker::SetDateTime(const DateTime& dateTime) +{ + SetProperty("dateTime", Variant(dateTime)); + + return; +} + +Variant +_DateTimePicker::GetPropertyDateTime(void) const +{ + DateTime dateTime = DateTime(); + + dateTime = __pPresenter->GetDateTime(); + + return Variant(dateTime); +} + +DateTime +_DateTimePicker::GetDateTime(void) const +{ + Variant dateTime = GetProperty("dateTime"); + + return dateTime.ToDateTime(); +} + +void +_DateTimePicker::SetCurrentDateTime(void) +{ + __pPresenter->SetCurrentDateTime(); + + return; +} + +void +_DateTimePicker::SetFocusBoxId(int boxId) +{ + __pPresenter->SetFocusBoxId(boxId); + + return; +} + +void +_DateTimePicker::SetAccessibilityElementText(int index, const String& text, bool isAmPm) +{ + _AccessibilityElement* pElement = null; + int elementIndex = __accessibilityElements.GetCount() - 1 - index; + String hintAmPmText(L"Double tap to change to "); + + if (__accessibilityElements.GetAt(elementIndex, pElement) == E_SUCCESS) + { + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (pElement != null), r, "[%s] Propagating.", GetErrorMessage(r)); + + pElement->SetLabel(text); + + if (isAmPm) + { + String amText; + GET_STRING_CONFIG(IDS_COM_BODY_AM, amText); + + if (text == amText) + { + hintAmPmText.Append(L"PM"); + } + else + { + hintAmPmText.Append(L"AM"); + } + + pElement->SetHint(hintAmPmText); + } + } + + SetLastResult(E_SUCCESS); + + return; +} + +bool +_DateTimePicker::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_DateTimePicker::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_DateTimePicker::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_DateTimePicker::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pPresenter->OnTouchCanceled(source, touchinfo); +} + +result +_DateTimePicker::OnAttachedToMainTree(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return E_SUCCESS; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer != null) + { + pContainer->AddListener(*this); + + const _DateTimeDisplayBox* pBox = null; + const _DateTimeDisplayBox* pAmPmBox = null; + + for (int index = 0; index < DATETIME_ID_MAX; index++) + { + pBox = __pPresenter->GetDisplayBox(index); + if (pBox != null) + { + _AccessibilityElement* pElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnResult(NID_UI_CTRL, (pElement != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + Rectangle displayBoxBounds = pBox->GetDisplayBoxBounds(); + int displayBoxId = pBox->GetDisplayBoxId(); + + String hintText(L"Double tap to edit"); + + switch (displayBoxId) + { + case DATETIME_ID_DAY: + pElement->SetTrait(ACCESSIBILITY_TRAITS_DAY); + pElement->SetHint(hintText); + break; + case DATETIME_ID_MONTH: + pElement->SetTrait(ACCESSIBILITY_TRAITS_MONTH); + pElement->SetHint(hintText); + break; + case DATETIME_ID_YEAR: + pElement->SetTrait(ACCESSIBILITY_TRAITS_YEAR); + pElement->SetHint(hintText); + break; + case DATETIME_ID_HOUR: + pElement->SetTrait(ACCESSIBILITY_TRAITS_HOUR); + pElement->SetHint(hintText); + break; + case DATETIME_ID_MINUTE: + pElement->SetTrait(ACCESSIBILITY_TRAITS_MINUTE); + pElement->SetHint(hintText); + break; + } + + if (__pDisplayVisualElement) + { + displayBoxBounds.y += __pDisplayVisualElement->GetBounds().y; + } + + pElement->SetLabel(pBox->GetText()); + pElement->SetBounds(displayBoxBounds); + pContainer->AddElement(*pElement); + } + } + + String hintAmPmText(L"Double tap to change"); + + pAmPmBox = __pPresenter->GetAmPmBox(); + if (pAmPmBox != null) + { + _AccessibilityElement* pElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnResult(NID_UI_CTRL, (pElement != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + Rectangle amPmBoxBounds = pAmPmBox->GetDisplayBoxBounds(); + + if (__pDisplayVisualElement) + { + amPmBoxBounds.y += __pDisplayVisualElement->GetBounds().y; + } + + pElement->SetLabel(pAmPmBox->GetText()); + pElement->SetBounds(amPmBoxBounds); + pElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON); + pElement->SetHint(hintAmPmText); + pContainer->AddElement(*pElement); + } + } + + if (pContainer) + { + pContainer->GetElements(__accessibilityElements); + } + + return E_SUCCESS; +} + +void +_DateTimePicker::OnChangeLayout(_ControlOrientation orientation) +{ + result r = E_SUCCESS; + Dimension pickerSize(0, 0); + Dimension screenSize(0, 0); + + screenSize = _ControlManager::GetInstance()->GetScreenSize(); + pickerSize = screenSize; + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + pickerSize.width = screenSize.height; + pickerSize.height = screenSize.width; + } + SetSize(pickerSize); + + if (__pHeader != null) + { + r = DestroyHeader(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to destroy the header for this control."); + } + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT && __title.IsEmpty() == false) + { + r = CreateHeader(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to create the header for this control."); + } + + r = DestroyFooter(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to destroy the footer for this control."); + + r = CreateFooter(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to create the footer for this control."); + + __pPresenter->OnChangeLayout(orientation); + + if (likely(_AccessibilityManager::IsActivated())) + { + const _DateTimeDisplayBox* pBox = null; + IEnumeratorT<_AccessibilityElement*>* pEnumerator = __accessibilityElements.GetEnumeratorN(); + _AccessibilityElement* pElement = null; + int index = 0; + while (pEnumerator->MoveNext() == E_SUCCESS) + { + if (pEnumerator->GetCurrent(pElement) == E_SUCCESS) + { + pBox = __pPresenter->GetDisplayBox(index); + if (pBox != null) + { + Rectangle displayBoxBounds = pBox->GetDisplayBoxBounds(); + + if (__pDisplayVisualElement) + { + displayBoxBounds.y += __pDisplayVisualElement->GetBounds().y; + } + + pElement->SetBounds(displayBoxBounds); + } + } + index++; + } + delete pEnumerator; + } + + return; +} + +void +_DateTimePicker::OnDraw(void) +{ + __pPresenter->Draw(); + + return; +} + +void +_DateTimePicker::OnActionPerformed(const _Control& source, int actionId) +{ + __pPresenter->OnActionPerformed(source, actionId); + + return; +} + +bool +_DateTimePicker::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + String amString = L""; + String pmString = L""; + String label = L""; + + label = element.GetLabel(); + + GET_STRING_CONFIG(IDS_COM_BODY_AM, amString); + GET_STRING_CONFIG(IDS_COM_POP_PM, pmString); + + if (label == amString || label == pmString) + { + label.Append(L" Selected"); + _AccessibilityManager::GetInstance()->ReadContent(label); + } + + return true; +} + +void +_DateTimePicker::OnFontChanged(Font* pFont) +{ + result r = E_SUCCESS; + + if (pFont != null) + { + if (__pPresenter != null) + { + r = __pPresenter->SetFont(pFont); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating."); + } + + if (__pHeader != null) + { + r = __pHeader->SetFont(pFont->GetFaceName()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating."); + } + + if (__pFooter != null) + { + for (int i=0; i < __pFooter->GetItemCount(); i++) + { + _Button* pButton = __pFooter->GetItem(i); + + if (pButton != null) + { + r = pButton->SetFont(pFont->GetFaceName()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + } + + __pFont = pFont; + } + + return; +} + +void +_DateTimePicker::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = FONT_STYLE_PLAIN; + + GET_SHAPE_CONFIG(DATETIMEPICKER::FONT_SIZE, GetOrientation(), size); + + return; +} + +Font* +_DateTimePicker::GetDateTimeFont(void) +{ + return __pFont; +} + +result +_DateTimePicker::InitializeFont(void) +{ + result r = E_SUCCESS; + + __pFont = GetFallbackFont(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, (__pFont != null), r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DateTimePickerImpl.cpp b/src/ui/controls/FUiCtrl_DateTimePickerImpl.cpp new file mode 100644 index 0000000..a184bae --- /dev/null +++ b/src/ui/controls/FUiCtrl_DateTimePickerImpl.cpp @@ -0,0 +1,450 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DateTimePickerImpl.cpp + * @brief This is the implementation file for the _DateTimePickerImpl class. + */ + +#include +#include +#include "FUiCtrl_DateTimePickerImpl.h" +#include "FUiCtrl_DateTimePicker.h" +#include "FUiCtrl_FrameImpl.h" +#include "FUi_ControlImplManager.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_Form.h" + +using namespace Tizen::Ui::Animations; + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Ui { namespace Controls +{ + +Dimension +_DateTimePickerImpl::DateTimePickerSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + Dimension pickerSize(0, 0); + Dimension screenSize(0, 0); + + screenSize = _ControlManager::GetInstance()->GetScreenSize(); + pickerSize = screenSize; + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + pickerSize.width = screenSize.height; + pickerSize.height = screenSize.width; + } + + return pickerSize; +} + +Dimension +_DateTimePickerImpl::DateTimePickerSizeInfo::GetDefaultMaximumSize(_ControlOrientation orientation) const +{ + Dimension pickerSize(0, 0); + Dimension screenSize(0, 0); + + screenSize = _ControlManager::GetInstance()->GetScreenSize(); + pickerSize = screenSize; + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + pickerSize.width = screenSize.height; + pickerSize.height = screenSize.width; + } + + return pickerSize; +} + +_DateTimePickerImpl::_DateTimePickerImpl(DateTimePicker* pPublic, _DateTimePicker* pCore) + : _WindowImpl(pPublic, pCore) + , __pPublicDateTimeChangeEvent(null) +{ +} + +_DateTimePickerImpl::~_DateTimePickerImpl(void) +{ + if (__pPublicDateTimeChangeEvent != null) + { + delete __pPublicDateTimeChangeEvent; + __pPublicDateTimeChangeEvent = null; + } +} + +_DateTimePickerImpl* +_DateTimePickerImpl::CreateDateTimePickerImplN(DateTimePicker* pControl, const String& title) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + _DateTimePicker* pCore = _DateTimePicker::CreateDateTimePickerN(DATETIME_OUTPUT_STYLE_DATE | DATETIME_OUTPUT_STYLE_TIME, title); + SysTryReturn(NID_UI_CTRL, (pCore != null), null, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _DateTimePickerImpl* pDateTimePickerImpl = new (std::nothrow) _DateTimePickerImpl(pControl, pCore); + r = CheckConstruction(pCore, pDateTimePickerImpl); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pDateTimePickerImpl->__pPublicDateTimeChangeEvent = new (std::nothrow) _PublicDateTimeChangeEvent(*pControl); + SysTryCatch(NID_UI_CTRL, (pDateTimePickerImpl->__pPublicDateTimeChangeEvent != null), , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pDateTimePickerImpl->InitializeBoundsProperties(GET_SIZE_INFO(DateTimePicker), pCore->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddDateTimeChangeEventListener(*pDateTimePickerImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pDateTimePickerImpl; + +CATCH: + delete pDateTimePickerImpl; + + return null; +} + +const char* +_DateTimePickerImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::DateTimePicker"; +} + +const DateTimePicker& +_DateTimePickerImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +DateTimePicker& +_DateTimePickerImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _DateTimePicker& +_DateTimePickerImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_DateTimePicker& +_DateTimePickerImpl::GetCore(void) +{ + return static_cast <_DateTimePicker&>(_ControlImpl::GetCore()); +} + +_DateTimePickerImpl* +_DateTimePickerImpl::GetInstance(DateTimePicker& dateTimePicker) +{ + return static_cast<_DateTimePickerImpl*> (_ControlImpl::GetInstance(dateTimePicker)); +} + +const _DateTimePickerImpl* +_DateTimePickerImpl::GetInstance(const DateTimePicker& dateTimePicker) +{ + return static_cast (_ControlImpl::GetInstance(dateTimePicker)); +} + +result +_DateTimePickerImpl::AddDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, (__pPublicDateTimeChangeEvent != null), E_SYSTEM, + "A system error has occurred. The _PublicDateTimeChangeEvent instance is null."); + + result r = __pPublicDateTimeChangeEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +result +_DateTimePickerImpl::RemoveDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, (__pPublicDateTimeChangeEvent != null), E_SYSTEM, + "A system error has occurred. The _PublicDateTimeChangeEvent instance is null."); + + result r = __pPublicDateTimeChangeEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +void +_DateTimePickerImpl::SetDateTime(const DateTime& dateTime) +{ + ClearLastResult(); + + Variant dateTimeValue(dateTime); + + GetCore().SetPropertyDateTime(dateTimeValue); +} + +void +_DateTimePickerImpl::SetCurrentDateTime(void) +{ + ClearLastResult(); + + GetCore().SetCurrentDateTime(); +} + +result +_DateTimePickerImpl::SetYear(int year) +{ + ClearLastResult(); + + Variant yearValue(year); + + return GetCore().SetPropertyYear(yearValue); +} + +result +_DateTimePickerImpl::SetMonth(int month) +{ + ClearLastResult(); + + Variant monthValue(month); + + return GetCore().SetPropertyMonth(monthValue); +} + +result +_DateTimePickerImpl::SetDay(int day) +{ + ClearLastResult(); + + Variant dayValue(day); + + return GetCore().SetPropertyDay(dayValue); +} + +result +_DateTimePickerImpl::SetHour(int hour) +{ + ClearLastResult(); + + Variant hourValue(hour); + + return GetCore().SetPropertyHour(hourValue); +} + +result +_DateTimePickerImpl::SetMinute(int minute) +{ + ClearLastResult(); + + Variant minuteValue(minute); + + return GetCore().SetPropertyMinute(minuteValue); +} + +DateTime +_DateTimePickerImpl::GetDateTime(void) const +{ + ClearLastResult(); + + Variant dateTimeValue = GetCore().GetPropertyDateTime(); + + return dateTimeValue.ToDateTime(); +} + +int +_DateTimePickerImpl::GetYear(void) const +{ + ClearLastResult(); + + Variant yearValue = GetCore().GetPropertyYear(); + + return yearValue.ToInt(); +} + +int +_DateTimePickerImpl::GetMonth(void) const +{ + ClearLastResult(); + + Variant monthValue = GetCore().GetPropertyMonth(); + + return monthValue.ToInt(); +} + +int +_DateTimePickerImpl::GetDay(void) const +{ + ClearLastResult(); + + Variant dayValue = GetCore().GetPropertyDay(); + + return dayValue.ToInt(); +} + +int +_DateTimePickerImpl::GetHour(void) const +{ + ClearLastResult(); + + Variant hourValue = GetCore().GetPropertyHour(); + + return hourValue.ToInt(); +} + +int +_DateTimePickerImpl::GetMinute(void) const +{ + ClearLastResult(); + + Variant minuteValue = GetCore().GetPropertyMinute(); + + return minuteValue.ToInt(); +} + +void +_DateTimePickerImpl::Set24HourNotationEnabled(bool enable) +{ + ClearLastResult(); + + Variant enabledValue(enable); + + GetCore().SetProperty24HourNotation(enabledValue); +} + +bool +_DateTimePickerImpl::Is24HourNotationEnabled(void) const +{ + ClearLastResult(); + + Variant enabledValue = GetCore().GetProperty24HourNotation(); + + return enabledValue.ToBool(); +} + +result +_DateTimePickerImpl::SetYearRange(int minYear, int maxYear) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + Variant currentMinYearValue = GetCore().GetPropertyMinYearRange(); + Variant minYearValue(minYear); + Variant maxYearValue(maxYear); + + r = GetCore().SetPropertyMinYearRange(minYearValue); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = GetCore().SetPropertyMaxYearRange(maxYearValue); + if (r != E_SUCCESS) + { + // rollback minYearValue + GetCore().SetPropertyMinYearRange(minYearValue); + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_DateTimePickerImpl::GetYearRange(int& minYear, int& maxYear) const +{ + ClearLastResult(); + + Variant minYearValue = GetCore().GetPropertyMinYearRange(); + Variant maxYearValue = GetCore().GetPropertyMaxYearRange(); + + minYear = minYearValue.ToInt(); + maxYear = maxYearValue.ToInt(); + + return E_SUCCESS; +} + +void +_DateTimePickerImpl::OnDateTimeChanged(const Tizen::Ui::_Control& source, int year, int month, int day, int hour, int minute) +{ + ClearLastResult(); + + if (__pPublicDateTimeChangeEvent == null) + { + return; + } + + _PublicDateTimeChangeEventArg* pEventArg = new (std::nothrow) _PublicDateTimeChangeEventArg(DATETIME_PUBLIC_CHANGE_SAVED); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pEventArg->SetDate(year, month, day); + pEventArg->SetTime(hour, minute); + + __pPublicDateTimeChangeEvent->Fire(*pEventArg); +} + +void +_DateTimePickerImpl::OnDateTimeChangeCanceled(const Tizen::Ui::_Control& source) +{ + ClearLastResult(); + + if (__pPublicDateTimeChangeEvent == null) + { + return; + } + + _PublicDateTimeChangeEventArg* pEventArg = new (std::nothrow) _PublicDateTimeChangeEventArg(DATETIME_PUBLIC_CHANGE_CANCELED); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pPublicDateTimeChangeEvent->Fire(*pEventArg); +} + +void +_DateTimePickerImpl::OnChangeLayout(Tizen::Ui::_ControlOrientation orientation) +{ + ClearLastResult(); + + InitializeBoundsProperties(GET_SIZE_INFO(DateTimePicker), orientation); + _ControlImpl::OnChangeLayout(orientation); +} + +result +_DateTimePickerImpl::OnAttachedToMainTree(void) +{ + result r = E_SUCCESS; + + if (GetOwner() == null) + { + _FrameImpl* pFrameImpl = dynamic_cast <_FrameImpl*>(_ControlImplManager::GetInstance()->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, pFrameImpl != null, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] This instance is not constructed."); + + _Form* pForm = pFrameImpl->GetCore().GetCurrentForm(); + + if (pForm != null) + { + GetCore().SetOwner(pForm); + } + else + { + GetCore().SetOwner(&pFrameImpl->GetCore()); + } + } + SetVisibleState(true); + _WindowImpl::OnAttachedToMainTree(); + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DateTimePresenter.cpp b/src/ui/controls/FUiCtrl_DateTimePresenter.cpp new file mode 100644 index 0000000..c1bd875 --- /dev/null +++ b/src/ui/controls/FUiCtrl_DateTimePresenter.cpp @@ -0,0 +1,1912 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DateTimePresenter.cpp + * @brief This is the implementation file for the _DateTimePresenter class. + */ + +#include +#include +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_DateTimePresenter.h" +#include "FUiCtrl_InputPad.h" +#include "FUiCtrl_DateTimeDefine.h" +#include "FUiCtrl_DateTimeModel.h" +#include "FUiCtrl_DateTimeDisplayBox.h" +#include "FUiCtrl_DateTimePicker.h" +#include "FUiCtrl_DateTimeUtils.h" +#include "FUi_AccessibilityManager.h" + +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ +const int DATETIME_DISPLAY_STRING_MAX_LENGTH = 10; + +_DateTimePresenter::_DateTimePresenter(int pickerStyle, const String& title) + : __pView(null) + , __pModel(null) + , __selectedBoxIndex(-1) + , __focusedBoxIndex(0) + , __pInputPad(null) + , __inputPadType(INPUTPAD_STYLE_NORMAL) + , __pickerStyle(pickerStyle) + , __inputPadEnabled(true) + , __outputBoxMaxCount(0) + , __year(0) + , __month(0) + , __day(0) + , __hour(0) + , __minute(0) + , __is24HourNotation(false) + , __isPm(false) + , __isPmButtonPressed(false) + , __isFocusBoxChanged(false) + , __inputComposing(DATETIME_INPUT_END) + , __changeFocusCounter(DATE_TIME_CHANGE_FOCUS_COUNTER_MIN) + , __pPmBoxNormalBitmap(null) + , __pPmBoxEffectBitmap(null) + , __pPmBoxPressedEffectBitmap(null) + , __pPmBoxDisabledEffectBitmap(null) + , __pColonBitmap(null) + , __pFont(null) + , __pPmBox(null) +{ + for (int i = 0; i < DATETIME_ID_MAX; i++) + { + __pDisplayBox[i] = null; + } +} + +_DateTimePresenter::~_DateTimePresenter(void) +{ + Dispose(); +} + +void +_DateTimePresenter::Dispose(void) +{ + delete __pPmBoxNormalBitmap; + __pPmBoxNormalBitmap = null; + + delete __pPmBoxEffectBitmap; + __pPmBoxEffectBitmap = null; + + delete __pPmBoxPressedEffectBitmap; + __pPmBoxPressedEffectBitmap = null; + + delete __pPmBoxDisabledEffectBitmap; + __pPmBoxDisabledEffectBitmap = null; + + delete __pColonBitmap; + __pColonBitmap = null; + + for (int i = 0; i < DATETIME_ID_MAX; i++) + { + delete __pDisplayBox[i]; + __pDisplayBox[i] = null; + } + + delete __pPmBox; + __pPmBox = null; + + if ((__inputPadEnabled == true) && (__pInputPad != null)) + { + __pView->DetachChild(*__pInputPad); + delete __pInputPad; + __pInputPad = null; + } + + delete __pModel; + __pModel = null; +} + +result +_DateTimePresenter::Construct(_DateTimePicker& view) +{ + result r = E_SUCCESS; + + __pView = &view; + _ControlOrientation orientation = __pView->GetOrientation(); + + __pFont = __pView->GetDateTimeFont(); + SysTryReturnResult(NID_UI_CTRL, (__pFont != null), E_SYSTEM, "A system error has occurred. Failed to get the font."); + + LoadResource(); + UpdateDateTimeOutputConfig(); + + Rectangle inputPadBounds(0, 0, 0, 0); + Rectangle pickerBounds(0, 0, 0, 0); + + pickerBounds = __pView->GetBounds(); + + GET_SHAPE_CONFIG(DATETIMEPICKER::INPUTPAD_HEIGHT, orientation, inputPadBounds.height); + + inputPadBounds.x = 0; + inputPadBounds.width = pickerBounds.width; + inputPadBounds.y = pickerBounds.height - inputPadBounds.height; + + __pModel = new (std::nothrow) _DateTimeModel; + SysTryReturnResult(NID_UI_CTRL, (__pModel != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + // Load display data for sync with model data + LoadPickerData(); + + if (__inputPadEnabled == true) + { + __pInputPad = new (std::nothrow) _InputPad; + SysTryCatch(NID_UI_CTRL, (__pInputPad != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pInputPad->Construct(inputPadBounds); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to construct the instance of Inputpad."); + + r = __pView->AttachChild(*__pInputPad); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pInputPad->SetInputPadEventListener(*this); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set InputPadEventListener to the Inputpad."); + + __pInputPad->SetInputPadStyle(INPUTPAD_STYLE_NORMAL); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set InputPadStyle to the Inputpad."); + + __pInputPad->SetFont(__pFont); + + _DateTimeDisplayBox* pDisplayBox = __pDisplayBox[__focusedBoxIndex]; + SysTryCatch(NID_UI_CTRL, (pDisplayBox != null), , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get Display box."); + + SetFocusBoxId(pDisplayBox->GetDisplayBoxId()); + } + + return r; + +CATCH: + Dispose(); + + return r; +} + +result +_DateTimePresenter::SetYear(int year) +{ + result r = E_SUCCESS; + int minYear = 0; + int maxYear = 0; + + GetYearRange(minYear, maxYear); + + if (year < minYear) + { + year = minYear; + } + else if (year > maxYear) + { + year = maxYear; + } + + r = __pModel->SetYear(year); + + if (r == E_SUCCESS) + { + UpdateDisplayData(DATETIME_ID_YEAR); + } + + return r; +} + +result +_DateTimePresenter::SetMonth(int month) +{ + result r = __pModel->SetMonth(month); + + if (r == E_SUCCESS) + { + UpdateDisplayData(DATETIME_ID_MONTH); + } + + return r; +} + +result +_DateTimePresenter::SetDay(int day) +{ + result r = __pModel->SetDay(day); + + if (r == E_SUCCESS) + { + UpdateDisplayData(DATETIME_ID_DAY); + } + + return r; +} + +result +_DateTimePresenter::SetHour(int hour) +{ + result r = __pModel->SetHour(hour); + + if (r == E_SUCCESS) + { + UpdateDisplayData(DATETIME_ID_HOUR); + } + + return r; +} + +result +_DateTimePresenter::SetMinute(int minute) +{ + result r = __pModel->SetMinute(minute); + + if (r == E_SUCCESS) + { + UpdateDisplayData(DATETIME_ID_MINUTE); + } + + return r; +} + +result +_DateTimePresenter::SetYearRange(int minYear, int maxYear) +{ + __pModel->SetMinYear(minYear); + __pModel->SetMaxYear(maxYear); + + return E_SUCCESS; +} + +int +_DateTimePresenter::GetYear(void) const +{ + return __pModel->GetYear(); +} + +int +_DateTimePresenter::GetMonth(void) const +{ + return __pModel->GetMonth(); +} + +int +_DateTimePresenter::GetDay(void) const +{ + return __pModel->GetDay(); +} + +int +_DateTimePresenter::GetHour(void) const +{ + return __pModel->GetHour(); +} + +int +_DateTimePresenter::GetMinute(void) const +{ + return __pModel->GetMinute(); +} + +result +_DateTimePresenter::GetYearRange(int& minYear, int& maxYear) const +{ + return __pModel->GetYearRange(minYear, maxYear); +} + +void +_DateTimePresenter::Set24HourNotationEnabled(bool enable) +{ + __is24HourNotation = enable; + + UpdateDateTimeOutputConfig(); +} + +bool +_DateTimePresenter::Is24HourNotationEnabled(void) const +{ + return __is24HourNotation; +} + +void +_DateTimePresenter::SetCurrentDateTime(void) +{ + __pModel->SetCurrentDateTime(); + + UpdateDisplayData(DATETIME_ID_YEAR); + UpdateDisplayData(DATETIME_ID_MONTH); + UpdateDisplayData(DATETIME_ID_DAY); + UpdateDisplayData(DATETIME_ID_HOUR); + UpdateDisplayData(DATETIME_ID_MINUTE); +} + +void +_DateTimePresenter::SetDateTime(const DateTime& dateTime) +{ + __pModel->SetDateTime(dateTime); + + UpdateDisplayData(DATETIME_ID_YEAR); + UpdateDisplayData(DATETIME_ID_MONTH); + UpdateDisplayData(DATETIME_ID_DAY); + UpdateDisplayData(DATETIME_ID_HOUR); + UpdateDisplayData(DATETIME_ID_MINUTE); +} + +DateTime +_DateTimePresenter::GetDateTime(void) const +{ + return __pModel->GetDateTime(); +} + +void +_DateTimePresenter::SetFocusBoxId(int boxId) +{ + for (int i = 0; i < __outputBoxMaxCount; i++) + { + int displayBoxId = __pDisplayBox[i]->GetDisplayBoxId(); + + if (boxId == displayBoxId) + { + SetFocusBox(i); + ChangeInputPadStyle(boxId); + return; + } + } +} + +const _DateTimeDisplayBox* +_DateTimePresenter::GetDisplayBox(int index) const +{ + return __pDisplayBox[index]; +} + +const _DateTimeDisplayBox* +_DateTimePresenter::GetAmPmBox(void) const +{ + return __pPmBox; +} + +bool +_DateTimePresenter::Draw(void) +{ + result r = E_SUCCESS; + + _VisualElement* pVisualElement = null; + Canvas* pCanvas = null; + Color backgroundColor; + + pVisualElement = __pView->GetDisplayVisualElement(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pVisualElement != null), false, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas = pVisualElement->GetCanvasN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Draw Background + GET_COLOR_CONFIG(DATETIMEPICKER::BG_NORMAL, backgroundColor); + __pView->SetBackgroundColor(backgroundColor); + + // Draw DisplayBox Background + pCanvas->SetBackgroundColor(backgroundColor); + pCanvas->Clear(); + + DrawDividers(*pCanvas); + + for (int i = 0; i < __outputBoxMaxCount; i++) + { + DrawDateTimeDisplayBox(*pCanvas, i); + } + + if ((__pickerStyle & DATETIME_OUTPUT_STYLE_DATE) && (__pickerStyle & DATETIME_OUTPUT_STYLE_TIME)) + { + DrawColon(*pCanvas); + DrawPm(*pCanvas); + } + else if (__pickerStyle & DATETIME_OUTPUT_STYLE_TIME) + { + DrawColon(*pCanvas); + DrawPm(*pCanvas); + } + + if (likely(_AccessibilityManager::IsActivated())) + { + SetAccessibilityElementText(); + } + + delete pCanvas; + + return true; +} + +result +_DateTimePresenter::SetFont(Font* pFont) +{ + result r = E_SUCCESS; + int fontSize = 0; + + if (__pView == null) + { + return E_SUCCESS; + } + + GET_SHAPE_CONFIG(DATETIMEPICKER::FONT_SIZE, __pView->GetOrientation(), fontSize); + + r = _FontImpl::GetInstance(*pFont)->SetStyle(FONT_STYLE_PLAIN); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = _FontImpl::GetInstance(*pFont)->SetSize(fontSize); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + for (int i = 0; i < DATETIME_ID_MAX; i++) + { + if (__pDisplayBox[i] != null) + { + __pDisplayBox[i]->SetFont(pFont); + } + } + + if (__pPmBox != null) + { + __pPmBox->SetFont(pFont); + } + + if (__pInputPad != null) + { + __pInputPad->SetFont(pFont); + } + + return E_SUCCESS; +} + +void +_DateTimePresenter::OnChangeLayout(_ControlOrientation orientation) +{ + result r = E_SUCCESS; + Rectangle inputPadBounds(0, 0, 0, 0); + Rectangle pickerBounds(0, 0, 0, 0); + + pickerBounds = __pView->GetBounds(); + + UpdateDateTimeOutputConfig(); + + inputPadBounds.x = 0; + + GET_SHAPE_CONFIG(DATETIMEPICKER::INPUTPAD_HEIGHT, orientation, inputPadBounds.height); + + inputPadBounds.width = pickerBounds.width; + inputPadBounds.y = pickerBounds.height - inputPadBounds.height; + + if (__pInputPad != null) + { + r = __pInputPad->SetBounds(inputPadBounds); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } +} + +bool +_DateTimePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__pView != &source) + { + return false; + } + + int touchedAreaId = CalculateTouchArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y); + + if (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM) + { + __isPmButtonPressed = true; + __pView->Draw(); + return true; + } + + __selectedBoxIndex = CalculateTouchOutputArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y); + + if (__selectedBoxIndex != -1 && __selectedBoxIndex != __focusedBoxIndex) + { + result r = E_SUCCESS; + _VisualElement* pVisualElement = null; + Canvas* pCanvas = null; + + pVisualElement = __pView->GetDisplayVisualElement(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pVisualElement != null), false, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas = pVisualElement->GetCanvasN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, r, "[%s] Propagating.", GetErrorMessage(r)); + + DrawDateTimeDisplayBox(*pCanvas, __selectedBoxIndex); + + delete pCanvas; + + __pView->Draw(); + + return true; + } + + return true; +} + +bool +_DateTimePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__pView != &source) + { + return false; + } + + return true; +} + +bool +_DateTimePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + result r = E_SUCCESS; + + if (__pView != &source) + { + return false; + } + + int touchedAreaId = CalculateTouchArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y); + + if (__isPmButtonPressed == true) + { + if (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM) + { + __isPm = (!__isPm); + } + + __inputComposing = DATETIME_INPUT_END; + __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN; + __isPmButtonPressed = false; + __pView->Draw(); + + return true; + } + + if ((touchedAreaId == DATETIME_AREA_NONE) || (touchedAreaId == DATETIME_AREA_INPUT) || + (touchedAreaId == DATETIME_AREA_OUTPUT_AMPM)) + { + __selectedBoxIndex = -1; + __isPmButtonPressed = false; + __pView->Draw(); + + return true; + } + + int newOutputFocusedIndex = -1; + + if (touchedAreaId == DATETIME_AREA_OUTPUT) + { + newOutputFocusedIndex = CalculateTouchOutputArea(touchinfo.GetCurrentPosition().x, touchinfo.GetCurrentPosition().y); + if ((newOutputFocusedIndex == (-1)) || (newOutputFocusedIndex == __focusedBoxIndex)) + { + __selectedBoxIndex = -1; + __pView->Draw(); + + return true; + } + + if (newOutputFocusedIndex == __selectedBoxIndex) + { + for (int i = 0; i < __outputBoxMaxCount; i++) + { + AdjustDisplayValue(i); + } + + SetFocusBox(newOutputFocusedIndex); + } + + _VisualElement* pVisualElement = null; + Canvas* pCanvas = null; + + pVisualElement = __pView->GetDisplayVisualElement(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pVisualElement != null), false, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas = pVisualElement->GetCanvasN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, r, "[%s] Propagating.", GetErrorMessage(r)); + + DrawDateTimeDisplayBox(*pCanvas, __focusedBoxIndex); + + delete pCanvas; + + __selectedBoxIndex = -1; + __inputComposing = DATETIME_INPUT_END; + __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN; + + int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId(); + ChangeInputPadStyle(boxId); + + __pView->Draw(); + + return true; + } + + return true; +} + +bool +_DateTimePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__pView != &source) + { + return false; + } + + __selectedBoxIndex = -1; + __isPmButtonPressed = false; + __inputComposing = DATETIME_INPUT_END; + __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN; + + __pView->Draw(); + + return true; +} + +void +_DateTimePresenter::OnInputPadValueChanged(const _Control& source, int inputPadReturnValue) +{ + if ((__inputPadEnabled == false) || (inputPadReturnValue == -1)) + { + return; + } + + int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId(); + int currentNumber = GetNumberInBox(boxId); + int newNumber = 0; + + if (boxId == DATETIME_ID_YEAR) + { + __changeFocusCounter++; + + if (__isFocusBoxChanged == true) + { + newNumber = inputPadReturnValue; + __isFocusBoxChanged = false; + } + else + { + newNumber = SetFourDigit(currentNumber, inputPadReturnValue); + } + + __inputComposing = DATETIME_INPUT_BEGIN; + SetNumberInBox(boxId, newNumber); + + int min = 0; + int max = 0; + + GetYearRange(min, max); + + if ((newNumber >= max) || (newNumber > DATETIME_THREE_DIGIT_MAX) || __changeFocusCounter == DATE_TIME_CHANGE_FOCUS_COUNTER_MAX) + { + ChangeFocusBox(); + } + } + else if (boxId == DATETIME_ID_MONTH) + { + newNumber = inputPadReturnValue; + __inputComposing = DATETIME_INPUT_BEGIN; + + SetNumberInBox(boxId, newNumber); + ChangeFocusBox(); + } + else + { + __changeFocusCounter++; + + if (__isFocusBoxChanged == true) + { + newNumber = inputPadReturnValue; + __isFocusBoxChanged = false; + } + else + { + newNumber = SetTwoDigit(currentNumber, inputPadReturnValue); + } + + __inputComposing = DATETIME_INPUT_BEGIN; + + SetNumberInBox(boxId, newNumber); + + if (newNumber > DATETIME_ONE_DIGIT_MAX || __changeFocusCounter == DATE_TIME_CHANGE_FOCUS_COUNTER_MAX / 2) + { + ChangeFocusBox(); + } + } + + __pView->Draw(); +} + +void +_DateTimePresenter::OnActionPerformed(const _Control& source, int actionId) +{ + result r = E_SUCCESS; + + if (__pView == null) + { + return; + } + + if (actionId != DATETIME_EVENT_ID_SAVE && actionId != DATETIME_EVENT_ID_CANCEL ) + { + return; + } + + DateTime dateTime; + + __inputComposing = DATETIME_INPUT_END; + __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN; + __focusedBoxIndex = 0; + + int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId(); + + SetFocusBoxId(boxId); + __pView->Close(); + + if (actionId == DATETIME_EVENT_ID_SAVE) + { + for (int i = 0; i < __outputBoxMaxCount; i++) + { + AdjustDisplayValue(i); + } + + SavePickerData(); + + switch (__pickerStyle) + { + case DATETIME_OUTPUT_STYLE_DATE: + r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pView->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_SAVED, dateTime); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to fire the event for DateTime change saved."); + break; + + case DATETIME_OUTPUT_STYLE_TIME: + r = dateTime.SetValue(dateTime.GetYear(), dateTime.GetMonth(), dateTime.GetDay(), GetHour(), GetMinute(), dateTime.GetSecond()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pView->FireDateTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED, dateTime); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to fire the event for DateTime change saved."); + break; + + case DATETIME_OUTPUT_STYLE_DATETIME: + r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), GetHour(), GetMinute(), dateTime.GetSecond()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pView->FireDateTimeChangeEvent(DATETIME_INTERNAL_CHANGE_SAVED, dateTime); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to fire the event for DateTime change saved."); + break; + + default: + break; + } + } + else if (actionId == DATETIME_EVENT_ID_CANCEL) + { + LoadPickerData(); + + switch (__pickerStyle) + { + case DATETIME_OUTPUT_STYLE_DATE: + r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pView->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_CANCELED, dateTime); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to fire the event for DateTime change canceled."); + break; + + case DATETIME_OUTPUT_STYLE_TIME: + r = dateTime.SetValue(dateTime.GetYear(), dateTime.GetMonth(), dateTime.GetDay(), GetHour(), GetMinute(), dateTime.GetSecond()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pView->FireDateTimeChangeEvent(TIME_INTERNAL_CHANGE_CANCELED, dateTime); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to fire the event for DateTime change canceled."); + break; + + case DATETIME_OUTPUT_STYLE_DATETIME: + r = dateTime.SetValue(GetYear(), GetMonth(), GetDay(), GetHour(), GetMinute(), dateTime.GetSecond()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pView->FireDateTimeChangeEvent(DATETIME_INTERNAL_CHANGE_CANCELED, dateTime); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to fire the event for DateTime change canceled."); + break; + + default: + break; + } + } +} + +void +_DateTimePresenter::UpdateDateTimeOutputConfig(void) +{ + _ControlOrientation orientation = __pView->GetOrientation(); + _DateTimeDisplayBox* pPmBox = null; + _DateTimeDisplayBox* pDisplayBox[DATETIME_ID_MAX]; + + Rectangle outputAreaBounds(0, 0, 0, 0); + Rectangle dateBounds(0, 0, 0, 0); + Rectangle monthBounds(0, 0, 0, 0); + Rectangle yearBounds(0, 0, 0, 0); + Rectangle hourBounds(0, 0, 0, 0); + Rectangle minuteBounds(0, 0, 0, 0); + Rectangle amPmBounds(0, 0, 0, 0); + + int indexBox = 0; + int boxCount = 0; + int dateElementWidth = 0; + int displayBoxHeight = 0; + int dateTimeElementY = 0; + int dividerMargin = 0; + int dateTimeMargin = 0; + int leftMargin = 0; + int timeOutputMargin = 0; + int timeElementWidth = 0; + int colonWidth = 0; + int colonMargin = 0; + int amPmWidth = 0; + int amPmMargin = 0; + + for (indexBox = 0; indexBox < DATETIME_ID_MAX; indexBox++) + { + pDisplayBox[indexBox] = null; + } + + outputAreaBounds = GetOutputArea(); + __pView->SetDisplayVisualElementBounds(outputAreaBounds); + + GET_FIXED_VALUE_CONFIG(DATETIMEPICKER::DIVIDER_WIDTH, orientation, dividerMargin); + GET_SHAPE_CONFIG(DATETIMEPICKER::DATE_ELEMENT_WIDTH, orientation, dateElementWidth); + GET_SHAPE_CONFIG(DATETIMEPICKER::DISPLAY_BOX_HEIGHT, orientation, displayBoxHeight); + GET_SHAPE_CONFIG(DATETIMEPICKER::DATE_TIME_MARGIN, orientation, dateTimeMargin); + GET_SHAPE_CONFIG(DATETIMEPICKER::LEFT_MARGIN, orientation, leftMargin); + GET_SHAPE_CONFIG(DATETIMEPICKER::TIME_OUTPUT_MARGIN, orientation, timeOutputMargin); + GET_SHAPE_CONFIG(DATETIMEPICKER::TIME_ELEMENT_WIDTH, orientation, timeElementWidth); + GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_WIDTH, orientation, colonWidth); + GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_MARGIN, orientation, colonMargin); + GET_SHAPE_CONFIG(DATETIMEPICKER::AMPM_WIDTH, orientation, amPmWidth); + GET_SHAPE_CONFIG(DATETIMEPICKER::TIME_AMPM_MARGIN, orientation, amPmMargin); + + dateTimeElementY = (outputAreaBounds.height - displayBoxHeight) / 2; + + dateBounds.width = monthBounds.width = yearBounds.width = dateElementWidth; + hourBounds.width = minuteBounds.width = timeElementWidth; + amPmBounds.width = amPmWidth; + + dateBounds.height = monthBounds.height = yearBounds.height = hourBounds.height = minuteBounds.height = amPmBounds.height = displayBoxHeight; + dateBounds.y = monthBounds.y = yearBounds.y = hourBounds.y = minuteBounds.y = amPmBounds.y = dateTimeElementY; + + if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATE || __pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME) + { + switch (GetLocaleDateFormat()) + { + case DATE_FORMAT_DDMMYYYY: + { + dateBounds.x = leftMargin; + monthBounds.x = dateBounds.x + dateBounds.width + dividerMargin; + yearBounds.x = monthBounds.x + monthBounds.width + dividerMargin; + hourBounds.x = yearBounds.x + yearBounds.width + dateTimeMargin; + + // Date + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY); + SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + + // Month + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH); + SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + + // Year + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR); + SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + } + break; + case DATE_FORMAT_MMDDYYYY: + { + monthBounds.x = leftMargin; + dateBounds.x = monthBounds.x + monthBounds.width + dividerMargin; + yearBounds.x = dateBounds.x + dateBounds.width + dividerMargin; + hourBounds.x = yearBounds.x + yearBounds.width + dateTimeMargin; + + // Month + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH); + SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + + // Date + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY); + SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + + // Year + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR); + SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + } + break; + case DATE_FORMAT_YYYYMMDD: + { + yearBounds.x = leftMargin; + monthBounds.x = yearBounds.x + yearBounds.width + dividerMargin; + dateBounds.x = monthBounds.x + monthBounds.width + dividerMargin; + hourBounds.x = dateBounds.x + dateBounds.width + dateTimeMargin; + + // Year + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR); + SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + + // Month + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH); + SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + + // Date + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY); + SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + } + break; + case DATE_FORMAT_YYYYDDMM: + { + yearBounds.x = leftMargin; + dateBounds.x = yearBounds.x + yearBounds.width + dividerMargin; + monthBounds.x = dateBounds.x + dateBounds.width + dividerMargin; + hourBounds.x = monthBounds.x + monthBounds.width + dateTimeMargin; + + // Year + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(yearBounds, DATETIME_ID_YEAR); + SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + + // Date + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(dateBounds, DATETIME_ID_DAY); + SysTryReturnVoidResult(NID_UI_CTRL, (pDisplayBox[boxCount] != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + + // Month + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(monthBounds, DATETIME_ID_MONTH); + SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + } + break; + } + } + + if (__pickerStyle == DATETIME_OUTPUT_STYLE_TIME || __pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME) + { + if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME) + { + minuteBounds.x = hourBounds.x + hourBounds.width + colonWidth; + amPmBounds.x = minuteBounds.x + minuteBounds.width + amPmMargin; + } + else + { + hourBounds.x = dateTimeMargin + leftMargin + timeOutputMargin; + minuteBounds.x = hourBounds.x + hourBounds.width + colonWidth + 2 * colonMargin; + amPmBounds.x = minuteBounds.x + minuteBounds.width + amPmMargin; + } + + // Hour + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(hourBounds, DATETIME_ID_HOUR); + SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + + // Minute + pDisplayBox[boxCount] = new (std::nothrow) _DateTimeDisplayBox(minuteBounds, DATETIME_ID_MINUTE); + SysTryCatch(NID_UI_CTRL, (pDisplayBox[boxCount] != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + boxCount++; + + // AmPm Button + if (__is24HourNotation == false) + { + pPmBox = new (std::nothrow) _DateTimeDisplayBox(amPmBounds, DATETIME_ID_AMPM); + SysTryCatch(NID_UI_CTRL, (pPmBox != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pPmBox->SetBackgroundBitmap(__pPmBoxNormalBitmap, __pPmBoxEffectBitmap, __pPmBoxPressedEffectBitmap, __pPmBoxDisabledEffectBitmap); + + delete __pPmBox; + __pPmBox = pPmBox; + } + } + + __outputBoxMaxCount = boxCount; + + for (indexBox = 0; indexBox < DATETIME_ID_MAX; indexBox++) + { + delete __pDisplayBox[indexBox]; + __pDisplayBox[indexBox] = pDisplayBox[indexBox]; + } + + SetFont(__pFont); + + return; + +CATCH: + for (int i = 0; i < DATETIME_ID_MAX; i++) + { + delete pDisplayBox[i]; + pDisplayBox[i] = null; + } + + return; +} + +void +_DateTimePresenter::LoadResource(void) +{ + Color colonColor; + result r = E_SUCCESS; + Bitmap* pColonBitmap = null; + + r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pPmBoxNormalBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pPmBoxEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_PRESSED_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pPmBoxPressedEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::AMPM_BG_DISABLED_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pPmBoxDisabledEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(DATETIMEPICKER::COLON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pColonBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_COLOR_CONFIG(DATETIMEPICKER::TEXT_NORMAL, colonColor); + + __pColonBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pColonBitmap, Color::GetColor(COLOR_ID_WHITE), colonColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (__pColonBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pColonBitmap; + + return; + +CATCH: + delete __pPmBoxNormalBitmap; + __pPmBoxNormalBitmap = null; + + delete __pPmBoxEffectBitmap; + __pPmBoxEffectBitmap = null; + + delete __pPmBoxPressedEffectBitmap; + __pPmBoxPressedEffectBitmap = null; + + delete __pPmBoxDisabledEffectBitmap; + __pPmBoxDisabledEffectBitmap = null; + + delete __pColonBitmap; + __pColonBitmap = null; + + delete pColonBitmap; + + return; +} + +void +_DateTimePresenter::DrawColon(Canvas& canvas) +{ + result r = E_SUCCESS; + _ControlOrientation orientation = __pView->GetOrientation(); + + Rectangle hourBounds(0, 0, 0, 0); + Rectangle colonBounds(0, 0, 0, 0); + + int colonWidth = 0; + int colonMargin = 0; + + GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_WIDTH, orientation, colonWidth); + GET_SHAPE_CONFIG(DATETIMEPICKER::COLON_MARGIN, orientation, colonMargin); + + for (int i = 0; i < __outputBoxMaxCount; i++) + { + if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_HOUR) + { + hourBounds = __pDisplayBox[i]->GetDisplayBoxBounds(); + } + } + + colonBounds.x = hourBounds.x + hourBounds.width; + colonBounds.y = hourBounds.y; + colonBounds.width = colonWidth; + colonBounds.height = hourBounds.height; + + if (__pickerStyle == DATETIME_OUTPUT_STYLE_TIME) + { + colonBounds.x += colonMargin; + } + + if (__pColonBitmap != null) + { + r = canvas.DrawBitmap(colonBounds, *__pColonBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } +} + +void +_DateTimePresenter::DrawDateTimeDisplayBox(Canvas& canvas, int index) +{ + result r = E_SUCCESS; + String text; + int number = 0; + int boxId = __pDisplayBox[index]->GetDisplayBoxId(); + number = GetNumberInBox(boxId); + DateTimePickerStatus status = DATETIME_STATUS_NORMAL; + + if (__pView->IsEnabled() == false) + { + status = DATETIME_STATUS_DISABLED; + } + else if (index == __selectedBoxIndex) + { + status = DATETIME_STATUS_SELECTED; + } + else if (index == __focusedBoxIndex) + { + status = DATETIME_STATUS_FOCUSED; + } + + if (boxId == DATETIME_ID_YEAR) + { + if ((__inputComposing == DATETIME_INPUT_BEGIN) && (status == DATETIME_STATUS_FOCUSED)) + { + String length = L"%0d"; + + r = length.Insert(__changeFocusCounter,2); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, length.GetPointer(), number); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%04d", number); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else if (boxId == DATETIME_ID_MONTH) + { + if (__pInputPad != null) + { + text.Clear(); + _DateTimeUtils dateTimeUtils; + text = dateTimeUtils.GetMonthString(number); + } + else + { + r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%02d", number); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + if ((__inputComposing == DATETIME_INPUT_BEGIN) && (status == DATETIME_STATUS_FOCUSED)) + { + r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%d", number); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = text.Format(DATETIME_DISPLAY_STRING_MAX_LENGTH, L"%02d", number); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + __pDisplayBox[index]->SetText(text); + __pDisplayBox[index]->DrawDisplayBox(canvas, status); + + return; +} + +void +_DateTimePresenter::DrawPm(Canvas& canvas) +{ + String text; + + if ((__is24HourNotation == true) || (__pPmBox == null)) + { + return; + } + + if (__isPm == false) + { + GET_STRING_CONFIG(IDS_COM_BODY_AM, text); + } + else + { + GET_STRING_CONFIG(IDS_COM_POP_PM, text); + } + + __pPmBox->SetText(text); + + if (__pView->IsEnabled() == false) + { + __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_DISABLED); + } + else if (__isPmButtonPressed == true) + { + __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_SELECTED); + } + else + { + __pPmBox->DrawDisplayBox(canvas, DATETIME_STATUS_NORMAL); + } +} + +void +_DateTimePresenter::DrawDividers(Canvas& canvas) +{ + result r = E_SUCCESS; + int dividerWidth = 0; + int dividerHeight = 0; + Point lineStart(0,0); + Point lineEnd(0,0); + Color colorHalfLeft; + Color colorHalfRight; + + _ControlOrientation orientation = __pView->GetOrientation(); + + GET_FIXED_VALUE_CONFIG(DATETIMEPICKER::DIVIDER_WIDTH, orientation, dividerWidth); + GET_SHAPE_CONFIG(DATETIMEPICKER::DIVIDER_HEIGHT, orientation, dividerHeight); + + GET_COLOR_CONFIG(DATETIMEPICKER::DIVIDER_LEFT_HALF, colorHalfLeft); + GET_COLOR_CONFIG(DATETIMEPICKER::DIVIDER_RIGHT_HALF, colorHalfRight); + + lineStart.y = (GetOutputArea().height - dividerHeight) / 2; + lineEnd.y = lineStart.y + dividerHeight; + + canvas.SetLineWidth(dividerWidth/2); + + for (int i = 0; i < __outputBoxMaxCount; i++) + { + bool isDrawDivider = false; + + if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATETIME) + { + if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_DAY || + __pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_MONTH || + __pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_YEAR) + { + isDrawDivider = true; + } + } + else if (__pickerStyle == DATETIME_OUTPUT_STYLE_DATE) + { + if (GetLocaleDateFormat() == DATE_FORMAT_YYYYMMDD) + { + if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_YEAR || + __pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_MONTH) + { + isDrawDivider = true; + } + } + else if (GetLocaleDateFormat() == DATE_FORMAT_YYYYDDMM) + { + if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_YEAR || + __pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_DAY) + { + isDrawDivider = true; + } + } + else + { + if (__pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_MONTH || + __pDisplayBox[i]->GetDisplayBoxId() == DATETIME_ID_DAY) + { + isDrawDivider = true; + } + } + } + + if (isDrawDivider) + { + lineStart.x = __pDisplayBox[i]->GetDisplayBoxBounds().x + __pDisplayBox[i]->GetDisplayBoxBounds().width; + lineEnd.x = lineStart.x; + + canvas.SetForegroundColor(colorHalfLeft); + r = canvas.DrawLine(lineStart, lineEnd); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + lineStart.x += dividerWidth/2; + lineEnd.x = lineStart.x; + + canvas.SetForegroundColor(colorHalfRight); + r = canvas.DrawLine(lineStart, lineEnd); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + return; +} + +Rectangle +_DateTimePresenter::GetOutputArea(void) +{ + _ControlOrientation orientation = __pView->GetOrientation(); + + Rectangle outputArea(0, 0, 0, 0); + Rectangle headerBounds = __pView->GetHeaderBounds(); + int margin = 0; + + GET_SHAPE_CONFIG(DATETIMEPICKER::TOP_MARGIN, orientation, margin); + + outputArea.y = headerBounds.y + headerBounds.height + margin; + outputArea.width = __pView->GetBounds().width; + + GET_SHAPE_CONFIG(DATETIMEPICKER::OUTPUT_AREA_HEIGHT, orientation, outputArea.height); + + return outputArea; +} + +void +_DateTimePresenter::ChangeInputPadStyle(int boxId) +{ + if (__inputPadEnabled == false) + { + return; + } + + SysTryReturnVoidResult(NID_UI_CTRL, __pInputPad != null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The instance of Inputpad is null."); + + _InputPadStyle inputPadType = INPUTPAD_STYLE_NORMAL; + switch (boxId) + { + case DATETIME_ID_MONTH: + inputPadType = INPUTPAD_STYLE_ALPHA; + break; + + case DATETIME_ID_YEAR: + // fall through intentional + case DATETIME_ID_DAY: + // fall through intentional + case DATETIME_ID_HOUR: + // fall through intentional + case DATETIME_ID_MINUTE: + // fall through intentional + default: + inputPadType = INPUTPAD_STYLE_NORMAL; + break; + } + + if (__inputPadType == inputPadType) + { + return; + } + __inputPadType = inputPadType; + + __pInputPad->SetInputPadStyle(inputPadType); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); +} + +int +_DateTimePresenter::CalculateTouchArea(int posX, int posY) +{ + _ControlOrientation orientation = __pView->GetOrientation(); + Rectangle outputArea = GetOutputArea(); + + int margin = 0; + + GET_SHAPE_CONFIG(DATETIMEPICKER::TOP_MARGIN, orientation, margin); + + if ((posX < outputArea.x) || (posY < outputArea.y)) + { + return DATETIME_AREA_NONE; + } + + int touched = DATETIME_AREA_NONE; + + if (posY < outputArea.y + outputArea.height) + { + int boxHeight = 0; + GET_SHAPE_CONFIG(DATETIMEPICKER::DISPLAY_BOX_HEIGHT, orientation, boxHeight); + + int boxPosY = outputArea.y + ((outputArea.height - boxHeight) / 2); + + if ((posY >= boxPosY) && (posY <= boxPosY + boxHeight)) + { + // output area + touched = DATETIME_AREA_OUTPUT; + + if (__pPmBox != null) + { + Rectangle boxBounds = __pPmBox->GetDisplayBoxBounds(); + + boxBounds.y = outputArea.y + ((outputArea.height - boxBounds.height) / 2); + + if ((posX >= boxBounds.x) && (posX < boxBounds.x + boxBounds.width) + && (posY >= boxBounds.y) && (posY < boxBounds.y + boxBounds.height)) + { + touched = DATETIME_AREA_OUTPUT_AMPM; + } + } + } + } + else + { + touched = DATETIME_AREA_INPUT; + } + + return touched; +} + +int +_DateTimePresenter::CalculateTouchOutputArea(int posX, int posY) +{ + Rectangle outputArea = GetOutputArea(); + + for (int i = 0; i < __outputBoxMaxCount; i++) + { + Rectangle boxBounds = __pDisplayBox[i]->GetDisplayBoxBounds(); + + boxBounds.y = outputArea.y + ((outputArea.height - boxBounds.height) / 2); + + if ((posX >= boxBounds.x) && (posX < boxBounds.x + boxBounds.width) + && (posY >= boxBounds.y) && (posY < boxBounds.y + boxBounds.height)) + { + return i; + } + } + + return -1; +} + +int +_DateTimePresenter::CalculateTwoDigit(int originalNumber, int number) +{ + int twoDigit = (originalNumber * 10) + number; + + if (twoDigit == 0) + { + return twoDigit; + } + + if ((twoDigit > 0) && (twoDigit > DATETIME_TWO_DIGIT_MAX)) + { + twoDigit = twoDigit % (DATETIME_TWO_DIGIT_MAX + 1); + } + + return twoDigit; +} + +int +_DateTimePresenter::CalculateFourDigit(int originalNumber, int number) +{ + int fourDigit = (originalNumber * 10) + number; + + if (fourDigit == 0) + { + return fourDigit; + } + + if ((fourDigit > 0) && (fourDigit > DATETIME_FOUR_DIGIT_MAX)) + { + fourDigit = fourDigit % (DATETIME_FOUR_DIGIT_MAX + 1); + } + return fourDigit; +} + +int +_DateTimePresenter::SetTwoDigit(int originalNumber, int number) +{ + int twoDigit = 0; + + if ((originalNumber <= DATETIME_ONE_DIGIT_MAX) && (__inputComposing == DATETIME_INPUT_BEGIN)) + { + twoDigit = (originalNumber * 10) + number; + } + else + { + twoDigit = number; + } + return twoDigit; +} + +int +_DateTimePresenter::SetFourDigit(int originalNumber, int number) +{ + int fourDigit = 0; + int minYear = 0; + int maxYear = 0; + + GetYearRange(minYear, maxYear); + if ((originalNumber <= DATETIME_THREE_DIGIT_MAX) && (__inputComposing == DATETIME_INPUT_BEGIN)) + { + fourDigit = (originalNumber * 10) + number; + if (fourDigit > maxYear) + { + fourDigit = maxYear; + } + } + else + { + fourDigit = number; + } + + return fourDigit; +} + +void +_DateTimePresenter::SetNumberInBox(int boxId, int number) +{ + switch (boxId) + { + case DATETIME_ID_YEAR: + __year = number; + break; + + case DATETIME_ID_MONTH: + __month = number; + break; + + case DATETIME_ID_DAY: + __day = number; + break; + + case DATETIME_ID_HOUR: + __hour = number; + break; + + case DATETIME_ID_MINUTE: + __minute = number; + break; + + default: + break; + } +} + +int +_DateTimePresenter::GetNumberInBox(int boxId) const +{ + int number = 0; + + switch (boxId) + { + case DATETIME_ID_YEAR: + number = __year; + break; + + case DATETIME_ID_MONTH: + number = __month; + break; + + case DATETIME_ID_DAY: + number = __day; + break; + + case DATETIME_ID_HOUR: + number = __hour; + break; + + case DATETIME_ID_MINUTE: + number = __minute; + break; + + default: + break; + } + + return number; +} + +void +_DateTimePresenter::SetFocusBox(int index) +{ + __focusedBoxIndex = index; + __isFocusBoxChanged = true; +} + +void +_DateTimePresenter::LoadPickerData(void) +{ + __year = GetYear(); + __month = GetMonth(); + __day = GetDay(); + __hour = GetHour(); + + if (__is24HourNotation == false) + { + int max = DATETIME_HOUR_MAX_FOR_24NOTATION; + + if (__hour == DATETIME_HOUR_MIN) + { + __hour = __hour + max; + __isPm = false; + } + else if (__hour < max && __hour != DATETIME_HOUR_MIN) + { + __isPm = false; + } + else if (__hour == max) + { + __isPm = true; + } + else if (__hour > max && __hour <= DATETIME_HOUR_MAX) + { + __hour = __hour - max; + __isPm = true; + } + else if (__hour == DATETIME_HOUR_MAX + 1) + { + __hour = max; + __isPm = false; + } + } + __minute = GetMinute(); +} + +void +_DateTimePresenter::SavePickerData(void) +{ + SetYear(__year); + SetMonth(__month); + SetDay(__day); + + if (__is24HourNotation == false) + { + int maxHour = DATETIME_HOUR_MAX_FOR_24NOTATION; + + if (__isPm == true) + { + if (__hour < maxHour) + { + SetHour(__hour + maxHour); + } + else + { + SetHour(__hour); + } + } + else + { + if (__hour < maxHour) + { + SetHour(__hour); + } + else + { + SetHour(__hour - maxHour); + } + } + } + else + { + SetHour(__hour); + } + + SetMinute(__minute); +} + +void +_DateTimePresenter::UpdateDisplayData(int boxId) +{ + switch (boxId) + { + case DATETIME_ID_YEAR: + __year = GetYear(); + break; + + case DATETIME_ID_MONTH: + __month = GetMonth(); + break; + + case DATETIME_ID_DAY: + __day = GetDay(); + break; + + case DATETIME_ID_HOUR: + __hour = GetHour(); + + if (__is24HourNotation == false) + { + int maxHour = DATETIME_HOUR_MAX_FOR_24NOTATION; + + if (__hour == DATETIME_HOUR_MIN) + { + __hour = maxHour; + __isPm = false; + } + else if (__hour < maxHour && __hour != DATETIME_HOUR_MIN) + { + __isPm = false; + } + else if (__hour == maxHour) + { + __isPm = true; + } + else if (__hour > maxHour && __hour <= DATETIME_HOUR_MAX) + { + __hour = __hour - maxHour; + __isPm = true; + } + else if (__hour == DATETIME_HOUR_MAX + 1) + { + __hour = __hour - maxHour; + __isPm = false; + } + } + break; + + case DATETIME_ID_MINUTE: + __minute = GetMinute(); + break; + + default: + break; + } +} + +void +_DateTimePresenter::AdjustValue(int& value, int minValue, int maxValue) +{ + if (value < minValue) + { + value = minValue; + } + else if (maxValue < value) + { + value = maxValue; + } +} + +void +_DateTimePresenter::AdjustDisplayValue(int index) +{ + int boxId = __pDisplayBox[index]->GetDisplayBoxId(); + _DateTimeUtils dateTimeUtils; + int minValue = 0; + int maxValue = 0; + + switch (boxId) + { + case DATETIME_ID_YEAR: + minValue = 0; + maxValue = 0; + GetYearRange(minValue, maxValue); + AdjustValue(__year, minValue, maxValue); + break; + + case DATETIME_ID_MONTH: + minValue = DATETIME_MONTH_MIN; + maxValue = DATETIME_MONTH_MAX; + AdjustValue(__month, minValue, maxValue); + break; + + case DATETIME_ID_DAY: + minValue = 1; + maxValue = dateTimeUtils.CalculateMaxDay(__year, __month); + AdjustValue(__day, minValue, maxValue); + break; + + case DATETIME_ID_HOUR: + minValue = DATETIME_HOUR_MIN; + maxValue = DATETIME_HOUR_MAX; + if (__is24HourNotation == false) + { + maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION; + + if(__hour == DATETIME_HOUR_MIN) + { + minValue = DATETIME_HOUR_MAX_FOR_24NOTATION; + } + } + AdjustValue(__hour, minValue, maxValue); + break; + + case DATETIME_ID_MINUTE: + minValue = DATETIME_MINUTE_MIN; + maxValue = DATETIME_MINUTE_MAX; + AdjustValue(__minute, minValue, maxValue); + break; + + default: + break; + } +} + +void +_DateTimePresenter::ChangeFocusBox(void) +{ + if (__focusedBoxIndex < (__outputBoxMaxCount - 1)) + { + __focusedBoxIndex++; + int boxId = __pDisplayBox[__focusedBoxIndex]->GetDisplayBoxId(); + ChangeInputPadStyle(boxId); + __isFocusBoxChanged = true; + } + + for (int i = 0; i < __outputBoxMaxCount; i++) + { + AdjustDisplayValue(i); + } + + __inputComposing = DATETIME_INPUT_END; + __changeFocusCounter = DATE_TIME_CHANGE_FOCUS_COUNTER_MIN; +} + +int +_DateTimePresenter::GetLocaleDateFormat(void) const +{ + int localeDateFormat = -1; + int error = vconf_get_int(VCONFKEY_SETAPPL_DATE_FORMAT_INT, &localeDateFormat); + if (error == -1) + { + localeDateFormat = SETTING_DATE_FORMAT_DD_MM_YYYY; + } + + return localeDateFormat; +} + +void +_DateTimePresenter::SetAccessibilityElementText(void) +{ + for (int index = 0; index < __outputBoxMaxCount; ++index) + { + if (__pDisplayBox[index]->GetDisplayBoxId() == DATETIME_ID_MONTH) + { + int number = GetNumberInBox(__pDisplayBox[index]->GetDisplayBoxId()); + __pView->SetAccessibilityElementText(index, __pInputPad->GetAccessebilityElementMonthName(number-1), false); + } + else + { + __pView->SetAccessibilityElementText(index, __pDisplayBox[index]->GetText(), false); + } + } + + if (__pPmBox) + { + __pView->SetAccessibilityElementText(__outputBoxMaxCount, __pPmBox->GetText(), true); + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DateTimeUtils.cpp b/src/ui/controls/FUiCtrl_DateTimeUtils.cpp new file mode 100644 index 0000000..958fdf1 --- /dev/null +++ b/src/ui/controls/FUiCtrl_DateTimeUtils.cpp @@ -0,0 +1,147 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DateTimeUtils.cpp + * @brief This is the implementation file for the _DateTimeUtils class. + */ + +#include +#include "FUiCtrl_DateTimeUtils.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_DateTimeUtils::~_DateTimeUtils(void) +{ +} + +_DateTimeUtils::_DateTimeUtils(void) +{ +} + +const String +_DateTimeUtils::GetMonthString(int month) const +{ + String text; + text.Clear(); + switch (month) + { + case 1: + GET_STRING_CONFIG(IDS_COM_BODY_JAN, text); + break; + + case 2: + GET_STRING_CONFIG(IDS_COM_BODY_FEB, text); + break; + + case 3: + GET_STRING_CONFIG(IDS_COM_BODY_MAR, text); + break; + + case 4: + GET_STRING_CONFIG(IDS_COM_BODY_APR, text); + break; + + case 5: + GET_STRING_CONFIG(IDS_COM_BODY_MAY, text); + break; + + case 6: + GET_STRING_CONFIG(IDS_COM_BODY_JUN, text); + break; + + case 7: + GET_STRING_CONFIG(IDS_COM_BODY_JUL, text); + break; + + case 8: + GET_STRING_CONFIG(IDS_COM_BODY_AUG, text); + break; + + case 9: + GET_STRING_CONFIG(IDS_COM_BODY_SEP, text); + break; + + case 10: + GET_STRING_CONFIG(IDS_COM_BODY_OCT, text); + break; + + case 11: + GET_STRING_CONFIG(IDS_COM_BODY_NOV, text); + break; + + case 12: + GET_STRING_CONFIG(IDS_COM_BODY_DEC, text); + break; + + default: + break; + } + return text; +} + +int +_DateTimeUtils::CalculateMaxDay(int displayYear, int month) const +{ + int maxDay = 0; + switch (month) + { + case 1: + // fall through + case 3: + // fall through + case 5: + // fall through + case 7: + // fall through + case 8: + // fall through + case 10: + // fall through + case 12: + maxDay = 31; + break; + + case 2: + if (IsLeapYear(displayYear)) + { + maxDay = 29; + } + else + { + maxDay = 28; + } + break; + + default: + maxDay = 30; + break; + } + return maxDay; +} + +bool +_DateTimeUtils::IsLeapYear(int year) const +{ + return DateTime::IsLeapYear(year); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_DimmingLayer.cpp b/src/ui/controls/FUiCtrl_DimmingLayer.cpp new file mode 100644 index 0000000..f88f249 --- /dev/null +++ b/src/ui/controls/FUiCtrl_DimmingLayer.cpp @@ -0,0 +1,221 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DimmingLayer.cpp + * @brief This is the implementation file for _DimmingLayer class. + * + * This file contains the implementation of _DimmingLayer class. + */ + + +#include + +#include "FUi_Control.h" +#include "FUi_ControlManager.h" +#include "FUi_Window.h" +#include "FUiCtrl_DimmingLayer.h" +#include "FUiAnim_ControlVisualElement.h" +#include "FUiAnim_RootVisualElement.h" + +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui; + +namespace Tizen +{ +namespace Ui +{ +namespace Controls +{ + +_DimmingLayer::_DimmingLayer(void) + : __enabled(false) + , __pControl(null) + , __pDimmingElement(null) + , __oldControlRenderOperation(VisualElement::RENDER_OPERATION_BLEND) +{ + +} + +_DimmingLayer::~_DimmingLayer(void) +{ + if (__pDimmingElement) + { + __pDimmingElement->Destroy(); + } + __pDimmingElement = null; + + if (__pControl) + { + VisualElement* pControlVisualElement = __pControl->GetVisualElement(); + if (pControlVisualElement) + { + pControlVisualElement->SetRenderOperation(__oldControlRenderOperation); + } + } +} + +result +_DimmingLayer::Construct(_Control& control) +{ + result r = E_SUCCESS; + VisualElement* pControlVisualElement = null; + + __pControl = &control; + + if (!__pDimmingElement) + { + __pDimmingElement = new (std::nothrow) _ControlVisualElement; + SysTryReturnResult(NID_UI, __pDimmingElement, E_OUT_OF_MEMORY, "Memory allocation failed."); + } + + r = __pDimmingElement->ConstructControlVisualElement(); + SysTryCatch(NID_UI, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pDimmingElement->SetImplicitAnimationEnabled(true); + __pDimmingElement->SetName("DimmingLayer"); + + r = __pDimmingElement->SetSurfaceOpaque(false); + SysTryCatch(NID_UI, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pDimmingElement->SetOpacity(0.65f); + + r = __pDimmingElement->SetBackgroundColor(_Colorf()); + SysTryCatch(NID_UI, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pControlVisualElement = __pControl->GetVisualElement(); + if (pControlVisualElement) + { + __oldControlRenderOperation = pControlVisualElement->GetRenderOperation(); + pControlVisualElement->SetRenderOperation(VisualElement::RENDER_OPERATION_BLEND); + } + + r = Rearrange(); + SysTryCatch(NID_UI, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + __pDimmingElement->Destroy(); + return E_SYSTEM; +} + +result +_DimmingLayer::SetOpacity(float opacity) +{ + SysTryReturnResult(NID_UI, __pDimmingElement, E_SYSTEM, "A system error has been occurred."); + + result r = E_SUCCESS; + + __pDimmingElement->SetOpacity(opacity); + + if (opacity >= 1.0f) + { + __pDimmingElement->SetSurfaceOpaque(true); + } + else + { + __pDimmingElement->SetSurfaceOpaque(false); + } + + SysTryReturnResult(NID_UI, !IsFailed(r), E_SYSTEM, "A system error has been occurred."); + + return r; +} + +float +_DimmingLayer::GetOpacity(void) const +{ + SysTryReturnResult(NID_UI, __pDimmingElement, E_SYSTEM, "A system error has been occurred."); + return __pDimmingElement->GetOpacity(); +} + +result +_DimmingLayer::SetDimmingEnabled(bool enabled) +{ + SysTryReturnResult(NID_UI, __pDimmingElement, E_SYSTEM, "A system error has been occurred."); + + result r = E_SUCCESS; + + _VisualElement* pControlVisualElement = __pControl->GetVisualElement(); + SysTryReturnResult(NID_UI, pControlVisualElement, E_SYSTEM, "A system error has been occurred."); + + __pDimmingElement->SetShowState(enabled); + if (enabled) + { +#if !defined(MULTI_WINDOW) + VisualElement* pParent = pControlVisualElement->GetParent(); +#else + _Window* pWindow = __pControl->GetRootWindow(); + _RootVisualElement* pParent = pWindow->GetRootVisualElement(); +#endif + if (pParent) + { + pParent->InsertChild(*__pDimmingElement, pControlVisualElement, false); + } + } + else + { +#if !defined(MULTI_WINDOW) + VisualElement* pParent = pControlVisualElement->GetParent(); +#else + _Window* pWindow = __pControl->GetRootWindow(); + _RootVisualElement* pParent = pWindow->GetRootVisualElement(); +#endif + if (pParent) + { + pParent->DetachChild(*__pDimmingElement); + } + } + + __enabled = enabled; + + return r; +} + +bool +_DimmingLayer::GetDimmingEnabled(void) const +{ + return __enabled; +} + +result +_DimmingLayer::Rearrange(void) +{ + SysTryReturnResult(NID_UI, __pDimmingElement, E_SYSTEM, "A system error has been occurred."); + SysTryReturnResult(NID_UI, __pControl, E_SYSTEM, "A system error has been occurred."); + + result r = E_SUCCESS; + + Dimension size = _ControlManager::GetInstance()->GetScreenSize(); + if (__pControl->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) + { + __pDimmingElement->SetBounds(Tizen::Graphics::FloatRectangle(0.0f, 0.0f, (float)size.width, (float)size.height)); + } + else + { + __pDimmingElement->SetBounds(Tizen::Graphics::FloatRectangle(0.0f, 0.0f, (float)size.height, (float)size.width)); + } + + return r; +} + +} // Tizen::Ui::Controls +} // Tizen::Ui +} // Osp diff --git a/src/ui/controls/FUiCtrl_Edit.cpp b/src/ui/controls/FUiCtrl_Edit.cpp new file mode 100644 index 0000000..fb1960c --- /dev/null +++ b/src/ui/controls/FUiCtrl_Edit.cpp @@ -0,0 +1,2866 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_Edit.cpp + * @brief This is the implementation file for the _Edit class. + */ + +#include +#include +#include +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_IAccessibilityListener.h" +#include "FUi_UiEventManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_EditPresenter.h" +#include "FUiCtrl_ScrollPanel.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Locales; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Base::Collection; + + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _EditInternalTouchEventListener + : public _ITouchEventListener + , virtual public _IUiEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + _EditInternalTouchEventListener(const _Edit& edit); + /** + * This is the destructor for this class. + */ + virtual ~_EditInternalTouchEventListener(void) {} + + /** + * Notifies when an entity is touch pressed. + * + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + + /** + * Notifies when an entity is touch released. + * + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo){return false;}; + + /** + * Notifies when an entity is touch moved. + * + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo){return false;}; + + /** + * Notifies when an entity is touch cancelled. + * + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo){return false;}; + +private: + _Edit* __pEdit; +}; // _ITouchEventListener + +_EditInternalTouchEventListener::_EditInternalTouchEventListener(const _Edit& edit) +{ + __pEdit = const_cast<_Edit*>(&edit); +} + +bool +_EditInternalTouchEventListener::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + _EditPresenter* pEditPresenter = __pEdit->GetPresenter(); + _Toolbar* pCommandButton = pEditPresenter->GetKeypadCommandButton(); + if (__pEdit == &source || pCommandButton == source.GetParent()) + { + return false; + } + else //check the state of Text Prediction & CopyPaste Popup + { + if (pEditPresenter->IsCopyPastePopupVisible()) + { + if (pEditPresenter->GetTextCompositionState()) + { + pEditPresenter->FinishTextComposition(); + } + + if (pEditPresenter->IsCopyPastePopup(source)) + { + return false; // CopyPastePopup is touched + } + else + { + pEditPresenter->InitializeCopyPasteManager(); + } + } + } + + return false; +} + +IMPLEMENT_PROPERTY(_Edit); + +_Edit::_Edit(void) + : _pEditPresenter(null) + , __bottomMargin(-1) + , __leftMargin(-1) + , __lineSpacing(-1) + , __rightMargin(-1) + , __textSize(-1) + , __topMargin(-1) + , __editStyle(EDIT_STYLE_NORMAL) + , __borderRoundStyle(false) + , __ellipsisPosition(ELLIPSIS_POSITION_END) + , __inputStyle(INPUT_STYLE_OVERLAY) + , __isConstructed(false) + , __guideTextColor(Color()) + , __isSettingGuideTextColor(false) + , __pDefaultBackgroundEffectBitmap(null) + , __pGestureFlick(null) + , __pGestureLongPress(null) + , __pGestureTap(null) + , __pEditInternalTouchEventListener(null) + , __pExpandableEditAreaEvent(null) + , __pKeypadEvent(null) + , __pLanguageEvent(null) + , __pLinkEvent(null) + , __pScrollPanelEvent(null) + , __pTextBlockEvent(null) + , __pTextEvent(null) + , __pTitleTextAccessibilityElement(null) + , __pTextAccessibilityElement(null) + , __pClearButtonTextAccessibilityElement(null) + , __pToolbarAccessibilityElement(null) + , __isAccessibilityCreated(false) + , __isFullScreenKeypadEdit(false) +{ + for (int status = 0; status < EDIT_COLOR_MAX; status++) + { + __pBackgroundBitmap[status] = null; + } + + for (int status = 0; status < EDIT_COLOR_MAX; status++) + { + __pDefaultBackgroundBitmap[status] = null; + } + + __blockTextColor.used = false; + __blockTextColor.blockTextColor = Color(); +} + +_Edit::~_Edit(void) +{ + delete _pEditPresenter; + _pEditPresenter = null; + + for (int status = 0; status < EDIT_COLOR_MAX; status++) + { + if (__pBackgroundBitmap[status]) + { + delete __pBackgroundBitmap[status]; + __pBackgroundBitmap[status] = null; + } + + if (__pDefaultBackgroundBitmap[status]) + { + delete __pDefaultBackgroundBitmap[status]; + __pDefaultBackgroundBitmap[status] = null; + } + } + + if (__pDefaultBackgroundEffectBitmap) + { + delete __pDefaultBackgroundEffectBitmap; + __pDefaultBackgroundEffectBitmap = null; + } + + if (__pTextBlockEvent) + { + delete __pTextBlockEvent; + __pTextBlockEvent = null; + } + + if (__pLinkEvent) + { + delete __pLinkEvent; + __pLinkEvent = null; + } + + if (__pKeypadEvent) + { + delete __pKeypadEvent; + __pKeypadEvent = null; + } + + if (__pScrollPanelEvent) + { + delete __pScrollPanelEvent; + __pScrollPanelEvent = null; + } + + if (__pLanguageEvent) + { + delete __pLanguageEvent; + __pLanguageEvent = null; + } + + if (__pGestureFlick) + { + _ITouchFlickGestureEventListener* pListener = dynamic_cast<_ITouchFlickGestureEventListener*>(this); + __pGestureFlick->RemoveGestureListener(*pListener); + RemoveGestureDetector(*__pGestureFlick); + delete __pGestureFlick; + __pGestureFlick = null; + } + + if (__pGestureLongPress) + { + _ITouchLongPressGestureEventListener* pListener = dynamic_cast<_ITouchLongPressGestureEventListener*>(this); + __pGestureLongPress->RemoveGestureListener(*pListener); + RemoveGestureDetector(*__pGestureLongPress); + delete __pGestureLongPress; + __pGestureLongPress = null; + } + + if (__pGestureTap) + { + _ITouchTapGestureEventListener* pListener = dynamic_cast<_ITouchTapGestureEventListener*>(this); + __pGestureTap->RemoveGestureListener(*pListener); + RemoveGestureDetector(*__pGestureTap); + delete __pGestureTap; + __pGestureTap = null; + } + + if (__pEditInternalTouchEventListener) + { + _UiEventManager::GetInstance()->RemoveTouchEventListener(*__pEditInternalTouchEventListener); + delete __pEditInternalTouchEventListener; + __pEditInternalTouchEventListener = null; + } + + if (__pTextEvent) + { + delete __pTextEvent; + __pTextEvent = null; + } + + if (__pExpandableEditAreaEvent) + { + delete __pExpandableEditAreaEvent; + __pExpandableEditAreaEvent = null; + } + + if (__pTitleTextAccessibilityElement) + { + __pTitleTextAccessibilityElement->Activate(false); + __pTitleTextAccessibilityElement = null; + } + if (__pTextAccessibilityElement) + { + __pTextAccessibilityElement->Activate(false); + __pTextAccessibilityElement = null; + } + if (__pClearButtonTextAccessibilityElement) + { + __pClearButtonTextAccessibilityElement->Activate(false); + __pClearButtonTextAccessibilityElement = null; + } + if (__pToolbarAccessibilityElement) + { + __pToolbarAccessibilityElement->Activate(false); + __pToolbarAccessibilityElement = null; + } +} + +_Edit* +_Edit::CreateEditN(void) +{ + _EditPresenter* pPresenter = _EditPresenter::CreateInstanceN(); + if (pPresenter == null) + { + SetLastResult(E_OUT_OF_MEMORY); + + return null; + } + + result r = E_SUCCESS; + _VisualElement* pBaseVisualElement = null; + _Edit* pEdit = new (std::nothrow) _Edit; + SysTryCatch(NID_UI_CTRL, pEdit, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pBaseVisualElement = pEdit->GetVisualElement(); + if (pBaseVisualElement) + { + r = pBaseVisualElement->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + pEdit->AcquireHandle(); + + r = pEdit->SetPresenter(*pPresenter); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pEdit; + +CATCH: + delete pPresenter; + delete pEdit; + + return null; +} + +result +_Edit::Initialize(int editStyle, InputStyle inputStyle, int limitLength, GroupStyle groupStyle) +{ + result r = E_SUCCESS; + + SetEditStyle(editStyle); + + r = LoadDefaultBackgroundBitmap(groupStyle); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to load Bitmaps", GetErrorMessage(r)); + + InitializeColorInformation(); + + r = _pEditPresenter->Initialize(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to construct", GetErrorMessage(r)); + + r = _pEditPresenter->SetTextLimitLength(limitLength); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to set limit length", GetErrorMessage(r)); + + __inputStyle = inputStyle; + if (inputStyle == INPUT_STYLE_OVERLAY) + { + if (!(editStyle & EDIT_STYLE_FLEXIBLE)) + { + _pEditPresenter->SetKeypadCommandButtonVisible(true); + } + } + + _pEditPresenter->SetEditGroupStyle(groupStyle); + + __textSize = _pEditPresenter->GetTextSize(); + + __pGestureFlick = new (std::nothrow) _TouchFlickGestureDetector; + SysTryReturn(NID_UI_CTRL, __pGestureFlick, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create touch flick gesture."); + r = AddGestureDetector(*__pGestureFlick); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add gesture listener", GetErrorMessage(r)); + r = __pGestureFlick->AddGestureListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add gesture listener", GetErrorMessage(r)); + + __pGestureLongPress = new (std::nothrow) _TouchLongPressGestureDetector; + SysTryReturn(NID_UI_CTRL, __pGestureLongPress, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create touch long press gesture."); + r = AddGestureDetector(*__pGestureLongPress); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add gesture detector", GetErrorMessage(r)); + r = __pGestureLongPress->AddGestureListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add gesture listener", GetErrorMessage(r)); + + __pGestureTap = new (std::nothrow) _TouchTapGestureDetector; + SysTryReturn(NID_UI_CTRL, __pGestureTap, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create touch tap gesture."); + r = AddGestureDetector(*__pGestureTap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add gesture detector", GetErrorMessage(r)); + r = __pGestureTap->AddGestureListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add gesture listener", GetErrorMessage(r)); + + __pEditInternalTouchEventListener = new (std::nothrow) _EditInternalTouchEventListener(*this); + SysTryReturn(NID_UI_CTRL, __pEditInternalTouchEventListener, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create internal touch listener."); + r = _UiEventManager::GetInstance()->AddTouchEventListener(*__pEditInternalTouchEventListener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Unable to add internal event listener", GetErrorMessage(r)); + + SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_INSENSITIVE); + __isConstructed = true; + + return r; +} + +void +_Edit::InitializeColorInformation(void) +{ + GET_COLOR_CONFIG(EDIT::BG_NORMAL, __color[EDIT_STATUS_NORMAL].backgroundColor); + GET_COLOR_CONFIG(EDIT::BG_PRESSED, __color[EDIT_STATUS_PRESSED].backgroundColor); + GET_COLOR_CONFIG(EDIT::BG_HIGHLIGHTED, __color[EDIT_STATUS_HIGHLIGHTED].backgroundColor); + GET_COLOR_CONFIG(EDIT::BG_DISABLED, __color[EDIT_STATUS_DISABLED].backgroundColor); + + GET_COLOR_CONFIG(EDIT::TITLE_TEXT_NORMAL, __color[EDIT_STATUS_NORMAL].titleTextColor); + GET_COLOR_CONFIG(EDIT::TITLE_TEXT_PRESSED, __color[EDIT_STATUS_PRESSED].titleTextColor); + GET_COLOR_CONFIG(EDIT::TITLE_TEXT_HIGHLIGHTED, __color[EDIT_STATUS_HIGHLIGHTED].titleTextColor); + GET_COLOR_CONFIG(EDIT::TITLE_TEXT_DISABLED, __color[EDIT_STATUS_DISABLED].titleTextColor); + + GET_COLOR_CONFIG(EDIT::TEXT_NORMAL, __color[EDIT_STATUS_NORMAL].textColor); + GET_COLOR_CONFIG(EDIT::TEXT_PRESSED, __color[EDIT_STATUS_PRESSED].textColor); + GET_COLOR_CONFIG(EDIT::TEXT_HIGHLIGHTED, __color[EDIT_STATUS_HIGHLIGHTED].textColor); + GET_COLOR_CONFIG(EDIT::TEXT_DISABLED, __color[EDIT_STATUS_DISABLED].textColor); + + GET_COLOR_CONFIG(EDIT::GUIDE_TEXT_NORMAL, __guideTextColor); + + memset(__cutlinkColor, 0, sizeof(EditCutlinkColor) * EDIT_LINK_TYPE_MAX); + for (int i = 0; i < EDIT_LINK_TYPE_MAX; i++) + { + EditCutLinkType type = (EditCutLinkType) i; + //GET_COLOR_CONFIG(EDIT::CUT_LINK_TEXT_NORMAL, __cutlinkColor[type].cutlinkFgColor); + __cutlinkColor[type].cutlinkFgColor = Color::GetColor(COLOR_ID_BLUE); + GET_COLOR_CONFIG(EDIT::CUT_LINK_BG_NORMAL, __cutlinkColor[type].cutlinkBgColor); + } +} + +result +_Edit::SetPresenter(const _EditPresenter& pPresenter) +{ + result r = E_SUCCESS; + + _pEditPresenter = const_cast<_EditPresenter*>(&pPresenter); + + return r; +} + +_EditPresenter* +_Edit::GetPresenter(void) const +{ + return _pEditPresenter; +} + +Dimension +_Edit::GetContentSizeInternal(void) const +{ + Dimension dimension(0,0); + int leftMargin = 0; + int rightMargin = 0; + int textTopMargin = 0; + int textBottomMargin = 0; + + _ControlOrientation orientation = GetOrientation(); + GET_SHAPE_CONFIG(EDIT::AREA_LEFT_MARGIN, orientation, leftMargin); + GET_SHAPE_CONFIG(EDIT::AREA_RIGHT_MARGIN, orientation, rightMargin); + GET_SHAPE_CONFIG(EDIT::AREA_TEXT_TOP_MARGIN, orientation, textTopMargin); + GET_SHAPE_CONFIG(EDIT::AREA_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin); + + TextObject* pTextObject = _pEditPresenter->GetTextObject(); + + if (!pTextObject) + { + return dimension; + } + + // store + TextObjectActionType previousActionType = pTextObject->GetAction(); + TextObjectWrapType previousWrapType = pTextObject->GetWrap(); + Rectangle previousRect = pTextObject->GetBounds(); + Rectangle newRect = previousRect; + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + newRect.width = _ControlManager::GetInstance()->GetScreenSize().width; + } + else + { + newRect.width = _ControlManager::GetInstance()->GetScreenSize().height; + } + + + pTextObject->SetBounds(newRect); + pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE); + pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + pTextObject->Compose(); + + dimension = pTextObject->GetTextExtent(0, pTextObject->GetTextLength()); + if (dimension.width > newRect.width) + { + dimension.width = newRect.width; + } + + dimension.height = pTextObject->GetTotalHeight(); + + // restore + pTextObject->SetBounds(previousRect); + pTextObject->SetAction(previousActionType); + pTextObject->SetWrap(previousWrapType); + pTextObject->Compose(); + + dimension.width += leftMargin + rightMargin; + dimension.height += textTopMargin + textBottomMargin; + + return dimension; +} + +HorizontalAlignment +_Edit::GetTextAlignment(void) const +{ + return _pEditPresenter->GetTextAlignment(); +} + +result +_Edit::SetTextAlignment(HorizontalAlignment alignment) +{ + return _pEditPresenter->SetTextAlignment(alignment); +} + +bool +_Edit::IsViewModeEnabled(void) const +{ + Variant var = GetProperty("viewModeEnabled"); + + return var.ToBool(); +} + +result +_Edit::SetViewModeEnabled(bool enable) +{ + Variant var(enable); + + return SetProperty("viewModeEnabled", var); +} + +result +_Edit::SetAutoLinkMask(unsigned long autoLinks) +{ + SysTryReturn(NID_UI_CTRL, (__inputStyle == INPUT_STYLE_OVERLAY), E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The current state unable to this operation."); + Variant var(autoLinks); + + return SetProperty("autoLinkMask", var); +} + +unsigned long +_Edit::GetAutoLinkMask(void) const +{ + SysTryReturn(NID_UI_CTRL, (__inputStyle == INPUT_STYLE_OVERLAY), LINK_TYPE_NONE, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The current state unable to this operation."); + Variant var = GetProperty("autoLinkMask"); + + return var.ToULong(); +} + +int +_Edit::GetLineSpacing(void) const +{ + return _pEditPresenter->GetLineSpacing(); +} + +result +_Edit::SetLineSpacing(int linePixelGap) +{ + return _pEditPresenter->SetLineSpacing(linePixelGap); +} + +void +_Edit::SetMaxLineCount(int maxLineCount) +{ + _pEditPresenter->SetMaxLineCount(maxLineCount); +} + +int +_Edit::GetMaxLineCount(void) const +{ + return _pEditPresenter->GetMaxLineCount(); +} + +int +_Edit::GetHorizontalMargin(EditTextHorizontalMargin marginType) const +{ + Variant var; + + switch (marginType) + { + case EDIT_TEXT_LEFT_MARGIN: + var = GetProperty("leftMargin"); + break; + + case EDIT_TEXT_RIGHT_MARGIN: + var = GetProperty("rightMargin"); + break; + + case EDIT_TEXT_HORIZONTAL_MARGIN: + var = GetProperty("leftMargin"); + break; + + default: + break; + } + + return var.ToInt(); +} + +int +_Edit::GetVerticalMargin(EditTextVerticalMargin marginType) const +{ + Variant var; + + switch (marginType) + { + case EDIT_TEXT_TOP_MARGIN: + var = GetProperty("topMargin"); + break; + + case EDIT_TEXT_BOTTOM_MARGIN: + var = GetProperty("bottomMargin"); + break; + + case EDIT_TEXT_VERTICAL_MARGIN: + var = GetProperty("topMargin"); + break; + + default: + break; + } + + return var.ToInt(); +} + +result +_Edit::SetHorizontalMargin(int margin, EditTextHorizontalMargin marginType) +{ + result r = E_SUCCESS; + Variant var(margin); + + SysTryReturn(NID_UI_CTRL, margin > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + + switch (marginType) + { + case EDIT_TEXT_LEFT_MARGIN: + r = SetProperty("leftMargin", var); + break; + + case EDIT_TEXT_RIGHT_MARGIN: + r = SetProperty("rightMargin", var); + break; + + case EDIT_TEXT_HORIZONTAL_MARGIN: + r = SetProperty("leftMargin", var); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to set margin."); + r = SetProperty("rightMargin", var); + break; + + default: + break; + } + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to set margin."); + + _pEditPresenter->SetClientBounds(); + r = _pEditPresenter->SetInitialBounds(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to set margin."); + + return r; + +} + +result +_Edit::SetVerticalMargin(int margin, EditTextVerticalMargin marginType) +{ + result r = E_SUCCESS; + Variant var(margin); + + SysTryReturn(NID_UI_CTRL, margin > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + + switch (marginType) + { + case EDIT_TEXT_TOP_MARGIN: + r = SetProperty("topMargin", var); + break; + + case EDIT_TEXT_BOTTOM_MARGIN: + r = SetProperty("bottomMargin", var); + break; + + case EDIT_TEXT_VERTICAL_MARGIN: + r = SetProperty("topMargin", var); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to set margin."); + r = SetProperty("bottomMargin", var); + break; + + default: + break; + } + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to set margin."); + + _pEditPresenter->SetClientBounds(); + r = _pEditPresenter->SetInitialBounds(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to set margin."); + + return r; + +} + +int +_Edit::GetTextLimitLength(void) const +{ + return _pEditPresenter->GetTextLimitLength(); +} + +result +_Edit::SetLimitLength(int limitLength) +{ + return _pEditPresenter->SetTextLimitLength(limitLength); +} + +result +_Edit::SetAutoResizingEnabled(bool enable) +{ + Variant var(enable); + + return SetProperty("autoResizingEnabled", var); +} + +bool +_Edit::IsAutoResizingEnabled(void) const +{ + Variant var = GetProperty("autoResizingEnabled"); + + return var.ToBool(); +} + +CoreKeypadAction +_Edit::GetKeypadAction(void) const +{ + Variant var = GetProperty("keypadAction"); + + return (CoreKeypadAction)var.ToInt(); +} + +result +_Edit::SetKeypadAction(CoreKeypadAction keypadAction) +{ + SysTryReturn(NID_UI_CTRL, (__inputStyle == INPUT_STYLE_OVERLAY), E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The current state unable to this operation."); + Variant var((int)keypadAction); + + return SetProperty("keypadAction", var); +} + +result +_Edit::SetKeypadActionEnabled(bool enabled) +{ + Variant var(enabled); + + return SetProperty("keypadActionEnabled", var); +} + +bool +_Edit::GetKeypadActionEnabled(void) const +{ + Variant var = GetProperty("keypadActionEnabled"); + + return var.ToBool(); +} + +KeypadStyle +_Edit::GetKeypadStyle(void) const +{ + Variant var = GetProperty("keypadStyle"); + + return (KeypadStyle)var.ToInt(); +} + +result +_Edit::SetKeypadStyle(KeypadStyle keypadStyle) +{ + SysTryReturn(NID_UI_CTRL, (KEYPAD_STYLE_PASSWORD != keypadStyle), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + Variant var((int)keypadStyle); + + return SetProperty("keypadStyle", var); +} + +result +_Edit::SetKeypadNormalNumberStyle(bool enable) +{ + return _pEditPresenter->SetKeypadNormalNumberStyle(enable); +} + +bool +_Edit::IsTextPredictionEnabled(void) const +{ + return _pEditPresenter->IsTextPredictionEnabled(); +} + +result +_Edit::SetTextPredictionEnabled(bool enable) +{ + return _pEditPresenter->SetTextPredictionEnabled(enable); +} + +void +_Edit::UpdateAccessibilityElement(EditAccessibilityElementType type) +{ + if (!__isAccessibilityCreated) + { + return; + } + + switch(type) + { + case EDIT_ACCESSIBILITY_ELEMENT_TYPE_TITLE_TEXT: + if (__pTitleTextAccessibilityElement) + { + __pTitleTextAccessibilityElement->SetBounds(_pEditPresenter->GetTitleBounds()); + __pTitleTextAccessibilityElement->SetLabel(GetTitleText()); + } + break; + case EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT: + if (__pTextAccessibilityElement) + { + __pTextAccessibilityElement->SetBounds(_pEditPresenter->GetTextAreaBounds()); + __pTextAccessibilityElement->SetLabel(GetText()); + } + break; + case EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON: + if (__pClearButtonTextAccessibilityElement) + { + __pClearButtonTextAccessibilityElement->SetBounds(_pEditPresenter->GetClearIconBounds()); + } + break; + default: + break; + } + return; +} + +void +_Edit::SetFullScreenKeypadEdit(bool enabled) +{ + __isFullScreenKeypadEdit = enabled; +} + +bool +_Edit::IsFullScreenKeypadEdit(void) +{ + return __isFullScreenKeypadEdit; +} + +result +_Edit::HideKeypad(void) +{ + return _pEditPresenter->HideKeypad(true); +} + +int +_Edit::GetTextSize(void) const +{ + Variant size = GetProperty("textSize"); + + return size.ToInt(); +} + +result +_Edit::SetTextSize(int size) +{ + Variant var(size); + + return SetProperty("textSize", Variant(size)); +} + +Color +_Edit::GetColor(EditStatus status) const +{ + Variant color; + switch (status) + { + case EDIT_STATUS_NORMAL: + color = GetProperty("normalColor"); + break; + + case EDIT_STATUS_DISABLED: + color = GetProperty("disabledColor"); + break; + + case EDIT_STATUS_HIGHLIGHTED: + color = GetProperty("highlightedColor"); + break; + + case EDIT_STATUS_PRESSED: + color = GetProperty("pressedColor"); + break; + + default: + break; + } + + return color.ToColor(); +} + +Color +_Edit::GetTextColor(EditTextColor type) const +{ + Variant variantColor; + Color color; + switch (type) + { + case EDIT_TEXT_COLOR_NORMAL: + variantColor = GetProperty("normalTextColor"); + color = variantColor.ToColor(); + break; + + case EDIT_TEXT_COLOR_DISABLED: + variantColor = GetProperty("disabledTextColor"); + color = variantColor.ToColor(); + break; + + case EDIT_TEXT_COLOR_HIGHLIGHTED: + variantColor = GetProperty("highlightedTextColor"); + color = variantColor.ToColor(); + break; + + case EDIT_TEXT_COLOR_LINK: + color = __cutlinkColor[EDIT_LINK_TYPE_URL].cutlinkFgColor; + break; + + default: + break; + } + + return color; +} + +Color +_Edit::GetTextColor(EditStatus status) const +{ + Variant variantColor; + Color color; + + switch (status) + { + case EDIT_STATUS_NORMAL: + variantColor = GetProperty("normalTextColor"); + color = variantColor.ToColor(); + break; + + case EDIT_STATUS_DISABLED: + variantColor = GetProperty("disabledTextColor"); + color = variantColor.ToColor(); + break; + + case EDIT_STATUS_HIGHLIGHTED: + variantColor = GetProperty("highlightedTextColor"); + color = variantColor.ToColor(); + break; + + case EDIT_STATUS_PRESSED: + variantColor = GetProperty("pressedTextColor"); + color = variantColor.ToColor(); + break; + + default: + break; + } + + return color; +} + +result +_Edit::SetBackgroundBitmap(EditStatus status, const Bitmap& bitmap) +{ + result r = E_SUCCESS; + + Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap); + SysTryReturn(NID_UI_CTRL, pNewBitmap, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + delete __pBackgroundBitmap[status]; + __pBackgroundBitmap[status] = pNewBitmap; + + return r; +} + +result +_Edit::SetColor(EditStatus status, const Color& color) +{ + result r = E_SUCCESS; + + switch (status) + { + case EDIT_STATUS_NORMAL: + r = SetProperty("normalColor", Variant(color)); + break; + + case EDIT_STATUS_DISABLED: + r = SetProperty("disabledColor", Variant(color)); + break; + + case EDIT_STATUS_HIGHLIGHTED: + r = SetProperty("highlightedColor", Variant(color)); + break; + + case EDIT_STATUS_PRESSED: + r = SetProperty("pressedColor", Variant(color)); + break; + + default: + r = E_INVALID_ARG; + break; + } + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Unable to set color.", GetErrorMessage(r)); + + return r; +} + +result +_Edit::SetTextColor(EditTextColor type, const Color& color) +{ + result r = E_SUCCESS; + EditCutlinkColor autoLinkColorInfo; + + switch (type) + { + case EDIT_TEXT_COLOR_NORMAL: + r = SetProperty("normalTextColor", Variant(color)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] System error occurred.", GetErrorMessage(r)); + break; + + case EDIT_TEXT_COLOR_DISABLED: + r = SetProperty("disabledTextColor", Variant(color)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] System error occurred.", GetErrorMessage(r)); + break; + + case EDIT_TEXT_COLOR_HIGHLIGHTED: + r = SetProperty("highlightedTextColor", Variant(color)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] System error occurred.", GetErrorMessage(r)); + + r = SetProperty("pressedTextColor", Variant(color)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] System error occurred.", GetErrorMessage(r)); + break; + + case EDIT_TEXT_COLOR_LINK: + GetCutlinkColorInfo(EDIT_LINK_TYPE_URL, &autoLinkColorInfo); + autoLinkColorInfo.cutlinkFgColor = color; + SetCutlinkColorInfo(EDIT_LINK_TYPE_URL, autoLinkColorInfo); + SetCutlinkColorInfo(EDIT_LINK_TYPE_EMAIL, autoLinkColorInfo); + SetCutlinkColorInfo(EDIT_LINK_TYPE_PHONE_NUM, autoLinkColorInfo); + break; + + default: + r = E_INVALID_ARG; + break; + } + + return r; +} + +String +_Edit::GetText(int start, int end) const +{ + SysTryReturn(NID_UI_CTRL, (start > -1 && end > -1 && end > start), String(), E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument(start = %d, end = %d) is given."); + + return _pEditPresenter->GetText(start, end); +} + +result +_Edit::AddExpandableEditAreaEventListener(const _IExpandableEditAreaEventListener& listener) +{ + if (__pExpandableEditAreaEvent == null) + { + __pExpandableEditAreaEvent = _ExpandableEditAreaEvent::CreateInstanceN(*this); + SysTryReturn(NID_UI_CTRL, __pExpandableEditAreaEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + } + + return __pExpandableEditAreaEvent->AddListener(listener); +} + +result +_Edit::RemoveExpandableEditAreaEventListener(const _IExpandableEditAreaEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pExpandableEditAreaEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + return __pExpandableEditAreaEvent->RemoveListener(listener); +} + +result +_Edit::AddUiLinkEventListener(const _IUiLinkEventListener& listener) +{ + if (__pLinkEvent == null) + { + __pLinkEvent = _LinkEvent::CreateInstanceN(*this); + SysTryReturn(NID_UI_CTRL, __pLinkEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + } + + return __pLinkEvent->AddListener(listener); +} + +result +_Edit::RemoveUiLinkEventListener(const _IUiLinkEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pLinkEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + return __pLinkEvent->RemoveListener(listener); +} + +result +_Edit::AddTextBlockEventListener(const _ITextBlockEventListener& listener) +{ + if (__pTextBlockEvent == null) + { + __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this); + SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + } + + return __pTextBlockEvent->AddListener(listener); +} + +result +_Edit::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + __pTextBlockEvent->RemoveListener(listener); + + return E_SUCCESS; +} + +result +_Edit::AddKeypadEventListener(const _IKeypadEventListener& listener) +{ + if (__pKeypadEvent == null) + { + __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this); + SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + } + + return __pKeypadEvent->AddListener(listener); +} + +result +_Edit::RemoveKeypadEventListener(const _IKeypadEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + __pKeypadEvent->RemoveListener(listener); + + return E_SUCCESS; +} + +result +_Edit::AddTextEventListener(const _ITextEventListener& listener) +{ + if (__pTextEvent == null) + { + __pTextEvent = _TextEvent::CreateInstanceN(*this); + SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + } + + return __pTextEvent->AddListener(listener); +} + +result +_Edit::RemoveTextEventListener(const _ITextEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + __pTextEvent->RemoveListener(listener); + + return E_SUCCESS; +} + +result +_Edit::AddScrollPanelEventListener(const _IScrollPanelEventListener& listener) +{ + if (__pScrollPanelEvent == null) + { + if (__inputStyle != INPUT_STYLE_OVERLAY) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] System error occurred."); + return E_SYSTEM; + } + else + { + __pScrollPanelEvent = _ScrollPanelEvent::CreateScrollPanelEventN(*this); + SysTryReturn(NID_UI_CTRL, __pScrollPanelEvent, + E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + } + } + + return __pScrollPanelEvent->AddListener(listener); +} + +result +_Edit::RemoveScrollPanelEventListener(const _IScrollPanelEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pScrollPanelEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + __pScrollPanelEvent->RemoveListener(listener); + + return E_SUCCESS; +} + +result +_Edit::AddActionEventListener(const _IActionEventListener& listener) +{ + _pEditPresenter->AddActionEventListener(listener); + + return E_SUCCESS; +} + +result +_Edit::RemoveActionEventListener(const _IActionEventListener& listener) +{ + _pEditPresenter->RemoveActionEventListener(listener); + + return E_SUCCESS; +} + +result +_Edit::AddLanguageEventListener(const _ILanguageEventListener& listener) +{ + if (__pLanguageEvent == null) + { + __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this); + + SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.") + + __pLanguageEvent->AddListener(listener); + } + + return E_SUCCESS; +} + +result +_Edit::RemoveLanguageEventListener(const _ILanguageEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + __pLanguageEvent->RemoveListener(listener); + + return E_SUCCESS; +} + +int +_Edit::GetRemainingLength(void) const +{ + return _pEditPresenter->GetRemainingLength(); +} + +void +_Edit::SetLowerCaseModeEnabled(bool enable) +{ + Variant var(enable); + + SetProperty("lowerCaseModeEnabled", var); +} + +bool +_Edit::IsLowerCaseModeEnabled(void) const +{ + Variant var = GetProperty("lowerCaseModeEnabled"); + + return var.ToBool(); +} + +result +_Edit::SetCursorPosition(int position) +{ + int textLength = GetTextLength(); + SysTryReturn(NID_UI_CTRL, (position >= 0 && position <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] This position is out of range."); + + Variant var(position); + + return SetProperty("cursorPosition", var); +} + +int +_Edit::GetCursorPosition(void) const +{ + Variant var = GetProperty("cursorPosition"); + + return var.ToInt(); +} + +String +_Edit::GetText(void) const +{ + Variant var = GetProperty("text"); + + return var.ToString(); +} + +int +_Edit::GetTextLength(void) const +{ + return _pEditPresenter->GetTextLength(); +} + +result +_Edit::SetText(const String& text) +{ + Variant var(text); + + return SetProperty("text", var); +} + +result +_Edit::InsertTextAtCursorPosition(const String& text) +{ + return _pEditPresenter->InsertTextAtCursorPosition(text); +} + +result +_Edit::InsertCharacterAt(int index, const Character& character) +{ + return _pEditPresenter->InsertCharacterAt(index, character); +} + +result +_Edit::InsertTextAt(int index, const String& text) +{ + return _pEditPresenter->InsertTextAt(index, text); +} + +result +_Edit::AppendText(const String& text) +{ + return _pEditPresenter->AppendText(text); +} + +result +_Edit::AppendCharacter(const Character& character) +{ + return _pEditPresenter->AppendCharacter(character); +} + +result +_Edit::InsertTextAt(int position, const String& text, const Bitmap& textImage) +{ + return _pEditPresenter->InsertTextAt(position, text, textImage); +} + +result +_Edit::AppendText(const String& text, const Bitmap& textImage) +{ + return _pEditPresenter->InsertTextAt(_pEditPresenter->GetTextLength(), text, textImage); +} + +result +_Edit::ClearText(void) +{ + return _pEditPresenter->ClearText(); +} + +result +_Edit::DeleteCharacterAt(int index) +{ + return _pEditPresenter->DeleteCharacterAt(index); +} + +result +_Edit::DeleteCharacterAtCursorPosition(void) +{ + return _pEditPresenter->DeleteCharacterAtCursorPosition(); +} + +void +_Edit::GetCurrentTextRange(int& start, int& end) const +{ + return _pEditPresenter->GetCurrentTextRange(start, end); +} + +void +_Edit::SetGuideText(const String& guideText) +{ + Variant var(guideText); + + SetProperty("guideText", var); +} + +String +_Edit::GetGuideText(void) const +{ + Variant var = GetProperty("guideText"); + + return var.ToString(); +} + +Color +_Edit::GetGuideTextColor(void) const +{ + Variant color = GetProperty("guideTextColor"); + + return color.ToColor(); +} + +result +_Edit::SetGuideTextColor(const Color& color) +{ + __isSettingGuideTextColor = true; + + return SetProperty("guideTextColor", Variant(color)); +} + +void +_Edit::SetKeypadEnabled(bool enable) +{ + Variant var(enable); + + SetProperty("keypadEnabled", var); +} + +bool +_Edit::IsKeypadEnabled(void) const +{ + Variant var = GetProperty("keypadEnabled"); + + return var.ToBool(); +} + +result +_Edit::ShowKeypad(void) +{ + SysTryReturn(NID_UI_CTRL, (HasParent() && GetParent()), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The keypad couldn't be shown."); + SysTryReturn(NID_UI_CTRL, (IsKeypadEnabled() && (__inputStyle == INPUT_STYLE_OVERLAY)), E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The keypad couldn't be shown."); + + return _pEditPresenter->ShowKeypad(); +} + +int +_Edit::GetTextLineCount(void) const +{ + return _pEditPresenter->GetTextLineCount(); +} + +int +_Edit::GetTextTotalHeight(void) const +{ + return _pEditPresenter->GetTextTotalHeight(); +} + +result +_Edit::SetBlockTextColor(const Color& color) +{ + Variant var(color); + + return SetProperty("blockedTextColor", var); +} + +Color +_Edit::GetBlockTextColor(void) const +{ + Variant var; + + if (__blockTextColor.used) + { + var = GetProperty("blockedTextColor"); + } + else + { + var = GetProperty("highlightedColor"); + } + + return var.ToColor(); +} + +void +_Edit::GetBlockRange(int& start, int& end) const +{ + _pEditPresenter->GetBlockRange(start, end); +} + +result +_Edit::SetBlockRange(int start, int end) +{ + return _pEditPresenter->SetBlockRange(start, end); +} + +void +_Edit::GetWordPosition(int cursorPos, int& startPos, int& endPos) const +{ + _pEditPresenter->GetWordPosition(cursorPos, startPos, endPos); +} + +result +_Edit::GetTextImageRangeAt(int postion, int& startPosition, int& endPosition) const +{ + return _pEditPresenter->GetTextImageRangeAt(postion, startPosition, endPosition); +} + +result +_Edit::BeginTextBlock(void) +{ + return _pEditPresenter->BeginTextBlock(); +} + +result +_Edit::ReleaseTextBlock(void) +{ + return _pEditPresenter->ReleaseTextBlock(); +} + +bool +_Edit::IsBlocked(void) const +{ + return _pEditPresenter->IsBlocked(); +} + +result +_Edit::CopyText(void) +{ + return _pEditPresenter->CopyText(); +} + +result +_Edit::CutText(void) +{ + return _pEditPresenter->CutText(); +} + +result +_Edit::PasteText(void) +{ + return _pEditPresenter->PasteText(); +} + +result +_Edit::RemoveTextBlock(void) +{ + return _pEditPresenter->RemoveTextBlock(); +} + +bool +_Edit::IsClipped(void) const +{ + return _pEditPresenter->IsClipped(); +} + +result +_Edit::SetCurrentLanguage(LanguageCode languageCode) +{ + return _pEditPresenter->SetCurrentLanguage(languageCode); +} + +result +_Edit::GetCurrentLanguage(LanguageCode& language) const +{ + return _pEditPresenter->GetCurrentLanguage(language); +} + +bool +_Edit::CalculateAbsoluteCursorBounds(int index, Rectangle& absCursorRect) +{ + return _pEditPresenter->CalculateAbsoluteCursorBounds(index, absCursorRect); +} + +void +_Edit::OnDraw(void) +{ + Canvas* pCanvas = GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance."); + + _pEditPresenter->Draw(*pCanvas); + + delete pCanvas; +} + +bool +_Edit::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return _pEditPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_Edit::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return _pEditPresenter->OnTouchCanceled(source, touchinfo); +} + +bool +_Edit::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return _pEditPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_Edit::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return _pEditPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_Edit::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) +{ + return _pEditPresenter->OnKeyPressed(source, keyInfo); +} + +bool +_Edit::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) +{ + return _pEditPresenter->OnKeyReleased(source, keyInfo); +} + +bool +_Edit::OnNotifiedN(const _Control& source, IList* pArgs) +{ + return _pEditPresenter->OnNotifiedN(pArgs); +} + + +bool +_Edit::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) +{ + int xDistance = 0; + int yDistance = 0; + gesture.GetDistance(xDistance, yDistance); + Point flickPoint(xDistance, yDistance); + + _pEditPresenter->InitializeCopyPasteManager(); + + _pEditPresenter->StartFlickAnimation(flickPoint, gesture.GetDuration()); + + return true; +} + +bool +_Edit::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture) +{ + return false; +} + +bool +_Edit::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture) +{ + _pEditPresenter->OnLongPressGestureDetected(); + + return true; +} + +bool +_Edit::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture) +{ + return false; +} + +bool +_Edit::OnTapGestureDetected(_TouchTapGestureDetector& gesture) +{ + _pEditPresenter->OnTapGestureDetected(); + + return true; +} + +bool +_Edit::OnTapGestureCanceled(_TouchTapGestureDetector& gesture) +{ + return false; +} + +void +_Edit::OnClipboardPopupClosed(const ClipboardItem* pClipboardItem) +{ + _pEditPresenter->OnClipboardPopupClosed(pClipboardItem); +} + +bool +_Edit::OnFocusGained(const _Control& source) +{ + return _pEditPresenter->OnFocusGained(); +} + +bool +_Edit::OnFocusLost(const _Control& source) +{ + _pEditPresenter->OnFocusLost(); + Invalidate(); + + return true; +} + +result +_Edit::OnAttachedToMainTree(void) +{ + if (__isAccessibilityCreated) + { + return E_SUCCESS; + } + + _AccessibilityContainer* pEditAccessibilityContainer = GetAccessibilityContainer(); + if(pEditAccessibilityContainer) + { + pEditAccessibilityContainer->Activate(true); + } + if (pEditAccessibilityContainer) + { + if ((__editStyle & EDIT_STYLE_TITLE_TOP) || (__editStyle & EDIT_STYLE_TITLE_LEFT)) + { + __pTitleTextAccessibilityElement = new _AccessibilityElement(true); + __pTitleTextAccessibilityElement->SetBounds(_pEditPresenter->GetTitleBounds()); + __pTitleTextAccessibilityElement->SetLabel(GetTitleText()); + __pTitleTextAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_TEXT_FIELD); + __pTitleTextAccessibilityElement->SetName(L"EditTitleText"); + pEditAccessibilityContainer->AddElement(*__pTitleTextAccessibilityElement); + } + + __pTextAccessibilityElement = new _AccessibilityElement(true); + __pTextAccessibilityElement->SetBounds(_pEditPresenter->GetTextAreaBounds()); + __pTextAccessibilityElement->SetLabel(GetText()); + __pTextAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_TEXT_FIELD); + __pTextAccessibilityElement->SetName(L"EditText"); + pEditAccessibilityContainer->AddElement(*__pTextAccessibilityElement); + + if (__editStyle & EDIT_STYLE_CLEAR) + { + __pClearButtonTextAccessibilityElement = new _AccessibilityElement(true); + __pClearButtonTextAccessibilityElement->SetBounds(_pEditPresenter->GetClearIconBounds()); + __pClearButtonTextAccessibilityElement->SetLabel(L"all clear, button"); + __pClearButtonTextAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_TEXT_FIELD); + __pClearButtonTextAccessibilityElement->SetName(L"EditFieldClearButton"); + pEditAccessibilityContainer->AddElement(*__pClearButtonTextAccessibilityElement); + } + } + + __isAccessibilityCreated = true; + + return E_SUCCESS; +} + +void +_Edit::OnBoundsChanged(void) +{ + if (__isConstructed) + { + SysAssertf(_pEditPresenter != null, "_pEditPresenter is null"); + + _pEditPresenter->Resize(); + + if(__isAccessibilityCreated) + { + if (__pTitleTextAccessibilityElement) + { + __pTitleTextAccessibilityElement->SetBounds(_pEditPresenter->GetTitleBounds()); + } + + if (__pTextAccessibilityElement) + { + __pTextAccessibilityElement->SetBounds(_pEditPresenter->GetTextAreaBounds()); + } + + if (__pClearButtonTextAccessibilityElement) + { + __pClearButtonTextAccessibilityElement->SetBounds(_pEditPresenter->GetClearIconBounds()); + } + } + } +} + +void +_Edit::OnChangeLayout(_ControlOrientation orientation) +{ + result r = _pEditPresenter->ChangeLayout(orientation); + SetLastResult(r); +} + +void +_Edit::OnScrollPanelBoundsChanged(void) +{ + _pEditPresenter->OnScrollPanelBoundsChanged(); +} + +void +_Edit::OnFontChanged(Font* pFont) +{ + _pEditPresenter->OnFontChanged(pFont); +} + +void +_Edit::OnFontInfoRequested(unsigned long& style, int& size) +{ + _pEditPresenter->OnFontInfoRequested(style, size); +} + +void +_Edit::OnAncestorEnableStateChanged(const _Control& control) +{ + bool enableState = false; + enableState = control.GetEnableState(); + + if (!enableState) + { + if (_Edit::IsFocused()) + { + _pEditPresenter->HideKeypad(true); + } + } + + Invalidate(); +} + +unsigned long +_Edit::GetEditStyle(void) const +{ + return __editStyle; +} + +void +_Edit::SetEditStyle(unsigned long style) +{ + __editStyle = style; +} + +void +_Edit::SetBorderRoundStyleEnabled(bool enable) +{ + __borderRoundStyle = enable; +} + +bool +_Edit::IsBorderRoundStyleEnabled(void) const +{ + return __borderRoundStyle; +} + +bool +_Edit::IsUsbKeyboardConnected(void) const +{ + return _pEditPresenter->IsUsbKeyboardConnected(); +} + +bool +_Edit::IsKeypadExist(void) const +{ + return _pEditPresenter->IsKeypadExist(); +} + +void +_Edit::SetAutoShrinkModeEnabled(bool enable) +{ + _pEditPresenter->SetAutoShrinkModeEnabled(enable); +} + +bool +_Edit::IsAutoShrinkModeEnabled(void) const +{ + return _pEditPresenter->IsAutoShrinkModeEnabled(); +} + +EllipsisPosition +_Edit::GetEllipsisPosition(void) const +{ + return __ellipsisPosition; +} + +void +_Edit::SetEllipsisPosition(EllipsisPosition position) +{ + __ellipsisPosition = position; + _pEditPresenter->SetEllipsisPosition(position); +} + +void +_Edit::GetCutlinkColorInfo(EditCutLinkType type, EditCutlinkColor* colorInfo) const +{ + *colorInfo = __cutlinkColor[type]; +} + +void +_Edit::SetCutlinkColorInfo(EditCutLinkType type, EditCutlinkColor colorInfo) +{ + __cutlinkColor[type] = colorInfo; +} + +Bitmap* +_Edit::GetBackgroundBitmap(EditStatus status) const +{ + return __pBackgroundBitmap[status]; +} + +result +_Edit::LoadDefaultBackgroundBitmap(GroupStyle groupStyle) +{ + result r = E_SUCCESS; + + switch(groupStyle) + { + case GROUP_STYLE_NONE: + r = GET_BITMAP_CONFIG_N(EDIT::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + break; + case GROUP_STYLE_SINGLE: + r = GET_BITMAP_CONFIG_N(EDIT::BG_SINGLE_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_SINGLE_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + break; + case GROUP_STYLE_TOP: + r = GET_BITMAP_CONFIG_N(EDIT::BG_TOP, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_TOP_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + break; + case GROUP_STYLE_MIDDLE: + r = GET_BITMAP_CONFIG_N(EDIT::BG_CENTER, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_CENTER_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + break; + case GROUP_STYLE_BOTTOM: + r = GET_BITMAP_CONFIG_N(EDIT::BG_BOTTOM, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_BOTTOM_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + break; + default: + r = GET_BITMAP_CONFIG_N(EDIT::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(EDIT::BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + break; + } + + return r; + +CATCH: + for (int status = 0; status < EDIT_COLOR_MAX; status++) + { + if (__pDefaultBackgroundBitmap[status]) + { + delete __pDefaultBackgroundBitmap[status]; + __pDefaultBackgroundBitmap[status] = null; + } + } + + delete __pDefaultBackgroundEffectBitmap; + __pDefaultBackgroundEffectBitmap = null; + + return r; +} + +result +_Edit::ReplaceDefaultBackgroundBitmapForSearchBar(void) +{ + result r = E_SUCCESS; + + for (int status = 0; status < EDIT_COLOR_MAX; status++) + { + if (__pDefaultBackgroundBitmap[status]) + { + delete __pDefaultBackgroundBitmap[status]; + __pDefaultBackgroundBitmap[status] = null; + } + } + + if (__pDefaultBackgroundEffectBitmap) + { + delete __pDefaultBackgroundEffectBitmap; + __pDefaultBackgroundEffectBitmap = null; + } + + r = GET_BITMAP_CONFIG_N(SEARCHBAR::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_NORMAL]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(SEARCHBAR::BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_DISABLED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(SEARCHBAR::BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_HIGHLIGHTED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(SEARCHBAR::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundBitmap[EDIT_STATUS_PRESSED]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + r = GET_BITMAP_CONFIG_N(SEARCHBAR::BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDefaultBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + + _pEditPresenter->SetSearchBarFlag(true); + + return r; + +CATCH: + for (int status = 0; status < EDIT_COLOR_MAX; status++) + { + if (__pDefaultBackgroundBitmap[status]) + { + delete __pDefaultBackgroundBitmap[status]; + __pDefaultBackgroundBitmap[status] = null; + } + } + + delete __pDefaultBackgroundEffectBitmap; + __pDefaultBackgroundEffectBitmap = null; + + return r; +} + +Bitmap* +_Edit::GetDefaultBackgroundBitmap(EditStatus status) const +{ + return __pDefaultBackgroundBitmap[status]; +} + +bool +_Edit::IsCustomDefaultBackgroundBitmap(EditStatus status) const +{ + bool isCustomBitmap = false; + + switch (status) + { + case EDIT_STATUS_NORMAL: + isCustomBitmap = IS_CUSTOM_BITMAP(EDIT::BG_NORMAL) + break; + case EDIT_STATUS_DISABLED: + isCustomBitmap = IS_CUSTOM_BITMAP(EDIT::BG_DISABLED) + break; + case EDIT_STATUS_HIGHLIGHTED: + isCustomBitmap = IS_CUSTOM_BITMAP(EDIT::BG_HIGHLIGHTED) + break; + case EDIT_STATUS_PRESSED: + isCustomBitmap = IS_CUSTOM_BITMAP(EDIT::BG_PRESSED) + break; + default: + isCustomBitmap = false; + break; + } + + return isCustomBitmap; +} + +Bitmap* +_Edit::GetDefaultBackgroundEffectBitmap(void) const +{ + return __pDefaultBackgroundEffectBitmap; + +} + +bool +_Edit::IsSettingGuideTextColor(void) const +{ + return __isSettingGuideTextColor; +} + +result +_Edit::SetFont(const Font& font) +{ + return _pEditPresenter->SetFont(font); +} + +void +_Edit::GetFontType(String& typefaceName, unsigned long& styleMask) const +{ + _pEditPresenter->GetFontType(typefaceName, styleMask); +} + +result +_Edit::SetFontType(const String& typefaceName, unsigned long styleMask) +{ + return _pEditPresenter->SetFontType(typefaceName, styleMask); +} + +unsigned long +_Edit::GetTextStyle(void) const +{ + return _pEditPresenter->GetTextStyle(); +} + +result +_Edit::SetTextStyle(unsigned long style) +{ + return _pEditPresenter->SetTextStyle(style); +} + +String +_Edit::GetTitleText(void) const +{ + SysTryReturn(NID_UI_CTRL, (GetEditStyle() & EDIT_STYLE_TITLE_TOP) || (GetEditStyle() & EDIT_STYLE_TITLE_LEFT), String(), E_SYSTEM, "[E_SYSTEM] The EditField has no title style.\n"); + + Variant var = GetProperty("titleText"); + + return var.ToString(); +} + +result +_Edit::SetTitleText(const String& title) +{ + SysTryReturn(NID_UI_CTRL, (GetEditStyle() & EDIT_STYLE_TITLE_TOP) || (GetEditStyle() & EDIT_STYLE_TITLE_LEFT), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The EditField has no title style.\n"); + Variant var(title); + + return SetProperty("titleText", var); +} + +Color +_Edit::GetTitleTextColor(EditStatus status) const +{ + Variant var; + switch (status) + { + case EDIT_STATUS_NORMAL: + var = GetProperty("normalTitleTextColor"); + break; + + case EDIT_STATUS_DISABLED: + var = GetProperty("disabledTitleTextColor"); + break; + + case EDIT_STATUS_HIGHLIGHTED: + var = GetProperty("highlightedTitleTextColor"); + break; + + case EDIT_STATUS_PRESSED: + var = GetProperty("pressedTitleTextColor"); + break; + + default: + break; + } + + return var.ToColor(); +} + +result +_Edit::SetTitleTextColor(EditStatus status, const Color& color) +{ + result r = E_SUCCESS; + + Variant var(color); + + switch (status) + { + case EDIT_STATUS_NORMAL: + r = SetProperty("normalTitleTextColor", var); + break; + + case EDIT_STATUS_DISABLED: + r = SetProperty("disabledTitleTextColor", var); + break; + + case EDIT_STATUS_HIGHLIGHTED: + r = SetProperty("highlightedTitleTextColor", var); + break; + + case EDIT_STATUS_PRESSED: + r = SetProperty("pressedTitleTextColor", var); + break; + + default: + r = E_INVALID_ARG; + break; + } + + return r; +} + +InputStyle +_Edit::GetInputStyle(void) const +{ + return __inputStyle; +} + +result +_Edit::SetKeypadCommandButtonVisible(bool visible) +{ + Variant var(visible); + + return SetProperty("overlayKeypadCommandButtonVisible", var); +} + +_Toolbar* +_Edit::GetKeypadCommandButton(void) const +{ + return _pEditPresenter->GetKeypadCommandButton(); +} + + +result +_Edit::SetKeypadCommandButton(CommandButtonPosition position, const String& text, int actionId) +{ + SysTryReturn(NID_UI_CTRL, (__inputStyle != INPUT_STYLE_FULLSCREEN), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to show the keypad due to a wrong input style."); + + return _pEditPresenter->SetKeypadCommandButton(position, text, actionId); +} + +result +_Edit::GetKeypadBounds(Rectangle& rect) const +{ + return _pEditPresenter->GetKeypadBounds(rect); +} + +result +_Edit::SendExpandableEditAreaEvent(_ExpandableEditAreaEventStatus status, int selectedTokenIndex) +{ + if (__pExpandableEditAreaEvent) + { + IEventArg* pEventArg = _ExpandableEditAreaEvent::CreateExpandableEditAreaEventArgN(status, selectedTokenIndex); + SysTryReturn(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pExpandableEditAreaEvent->Fire(*pEventArg); + } + + return E_SUCCESS; +} + +result +_Edit::SendScrollPanelEvent(CoreScrollPanelStatus eventstatus) +{ + if (__pScrollPanelEvent) + { + IEventArg* pEventArg = _ScrollPanelEvent::CreateScrollPanelEventArgN(eventstatus); + SysTryReturn(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _CoreScrollPanelEventArg."); + + __pScrollPanelEvent->Fire(*pEventArg); + } + + return E_SUCCESS; +} + +result +_Edit::SendKeypadEvent(CoreKeypadAction keypadAction, CoreKeypadEventStatus eventstatus) +{ + if (__pKeypadEvent) + { + IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, eventstatus); + SysTryReturn(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pKeypadEvent->Fire(*pEventArg); + } + + return E_SUCCESS; +} + +result +_Edit::SendTextEvent(CoreTextEventStatus textEventStatus) +{ + if (__pTextAccessibilityElement) + { + __pTextAccessibilityElement->SetLabel(GetText()); + } + + if (__pTextEvent) + { + IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(textEventStatus); + SysTryReturn(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pTextEvent->Fire(*pEventArg); + } + + return E_SUCCESS; +} + +result +_Edit::SendTextBlockEvent(int start, int end) +{ + if (__pTextBlockEvent) + { + IEventArg* pTextBlockEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end); + SysTryReturn(NID_UI_CTRL, pTextBlockEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _TextBlockEventArg."); + + __pTextBlockEvent->Fire(*pTextBlockEventArg); + } + + return E_SUCCESS; +} + +result +_Edit::SendLinkEvent(const String& text, LinkType linkType, const String& link) +{ + if (__pLinkEvent) + { + IEventArg* pLinkEventArg = _LinkEvent::CreateLinkEventArgN(text, linkType, link); + SysTryReturn(NID_UI_CTRL, pLinkEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pLinkEvent->Fire(*pLinkEventArg); + } + + return E_SUCCESS; +} + +result +_Edit::SendLanguageEvent(LanguageCode prevLanguageCode, LanguageCode currentLanguageCode) +{ + if (__pLanguageEvent) + { + IEventArg* pLanguageEventArg = _LanguageEvent::CreateLanguageEventArgN(prevLanguageCode, currentLanguageCode); + SysTryReturn(NID_UI_CTRL, pLanguageEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pLanguageEvent->Fire(*pLanguageEventArg); + } + + return E_SUCCESS; +} + +result +_Edit::AttachScrollPanelEvent(void) +{ + _ScrollPanel* pScrollPanelCore = dynamic_cast<_ScrollPanel*>(GetParent()); + if (pScrollPanelCore) + { + if (__pScrollPanelEvent) + { + pScrollPanelCore->SetScrollPanelEvent(__pScrollPanelEvent); + } + pScrollPanelCore->SetControlKeypadBinding(this); + } + + return E_SUCCESS; +} + +result +_Edit::DetachScrollPanelEvent(void) +{ + _ScrollPanel* pScrollPanelCore = dynamic_cast<_ScrollPanel*>(GetParent()); + if (pScrollPanelCore) + { + if (__pScrollPanelEvent && (pScrollPanelCore->GetScrollPanelEvent() == __pScrollPanelEvent)) + { + pScrollPanelCore->SetScrollPanelEvent(null); + } + pScrollPanelCore->SetControlKeypadBinding(null); + } + + return E_SUCCESS; +} + +bool +_Edit::IsKeypadCommandButtonVisible(void) const +{ + Variant var = GetProperty("overlayKeypadCommandButtonVisible"); + + return var.ToBool(); +} + +String +_Edit::GetKeypadCommandButtonText(CommandButtonPosition position) const +{ + SysTryReturn(NID_UI_CTRL, (__inputStyle != INPUT_STYLE_FULLSCREEN), String(), E_SYSTEM, "[E_SYSTEM] Unable to show the keypad due to a wrong input style."); + + return _pEditPresenter->GetKeypadCommandButtonText(position); +} + +int +_Edit::GetKeypadCommandButtonActionId(CommandButtonPosition position) const +{ + SysTryReturn(NID_UI_CTRL, (__inputStyle != INPUT_STYLE_FULLSCREEN), -1, E_SYSTEM, "[E_SYSTEM] Unable to show the keypad due to a wrong input style."); + + return _pEditPresenter->GetKeypadCommandButtonActionId(position); +} + +result +_Edit::GetCursorBounds(bool isAbsRect, Rectangle& cursorBounds) const +{ + return _pEditPresenter->GetCursorBounds(isAbsRect, cursorBounds); +} + +int +_Edit::GetCursorPositionAt(const Point& touchPoint) const +{ + return _pEditPresenter->GetCursorPositionAt(touchPoint); +} + +void +_Edit::SetCursorDisabled(bool disabled) +{ + return _pEditPresenter->SetCursorDisabled(disabled); +} + +result +_Edit::SetPropertyAutoResizingEnabled(const Variant& enable) +{ + result r = E_SUCCESS; + + r = _pEditPresenter->SetAutoResizingEnabled(enable.ToBool()); + + return r; +} + +Variant +_Edit::GetPropertyAutoResizingEnabled(void) const +{ + return Variant(_pEditPresenter->IsAutoResizingEnabled()); +} + +result +_Edit::SetPropertyCursorPosition(const Variant& position) +{ + result r = E_SUCCESS; + int textLength = GetTextLength(); + int cursorPos = position.ToInt(); + + SysTryReturn(NID_UI_CTRL, (cursorPos >= 0 && cursorPos <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] This position is out of range."); + + r = _pEditPresenter->SetCursorPosition(cursorPos); + + return r; +} + +Variant +_Edit::GetPropertyCursorPosition(void) const +{ + return Variant(_pEditPresenter->GetCursorPosition()); +} + +result +_Edit::SetPropertyDisabledColor(const Variant& color) +{ + __color[EDIT_STATUS_DISABLED].backgroundColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyDisabledColor(void) const +{ + return Variant(__color[EDIT_STATUS_DISABLED].backgroundColor); +} + +result +_Edit::SetPropertyDisabledTextColor(const Variant& color) +{ + __color[EDIT_STATUS_DISABLED].textColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyDisabledTextColor(void) const +{ + return Variant(__color[EDIT_STATUS_DISABLED].textColor); +} + +result +_Edit::SetPropertyGuideText(const Variant& guideText) +{ + if (__pTextAccessibilityElement) + { + __pTextAccessibilityElement->SetLabel(guideText.ToString()); + } + + return _pEditPresenter->SetGuideText(guideText.ToString()); +} + +Variant +_Edit::GetPropertyGuideText(void) const +{ + return Variant(_pEditPresenter->GetGuideText()); +} + +result +_Edit::SetPropertyGuideTextColor(const Variant& color) +{ + __guideTextColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyGuideTextColor(void) const +{ + return Variant(__guideTextColor); +} + +result +_Edit::SetPropertyKeypadActionEnabled(const Variant& enabled) +{ + return _pEditPresenter->SetKeypadActionEnabled(enabled.ToBool()); +} + +Variant +_Edit::GetPropertyKeypadActionEnabled(void) const +{ + return Variant(_pEditPresenter->IsKeypadActionEnabled()); +} + +result +_Edit::SetPropertyKeypadAction(const Variant& action) +{ + SysTryReturn(NID_UI_CTRL, (__inputStyle == INPUT_STYLE_OVERLAY), E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The current state unable to this operation."); + + result r = E_SUCCESS; + + r = _pEditPresenter->SetKeypadAction((CoreKeypadAction)action.ToInt()); + + return r; +} + +Variant +_Edit::GetPropertyKeypadAction(void) const +{ + return Variant((int)_pEditPresenter->GetKeypadAction()); +} + +result +_Edit::SetPropertyLineSpacing(const Variant& lineSpacing) +{ + __lineSpacing = lineSpacing.ToInt(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyLineSpacing(void) const +{ + return Variant(__lineSpacing); +} + +result +_Edit::SetPropertyNormalColor(const Variant& color) +{ + __color[EDIT_STATUS_NORMAL].backgroundColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyNormalColor(void) const +{ + return Variant(__color[EDIT_STATUS_NORMAL].backgroundColor); +} + +result +_Edit::SetPropertyPressedColor(const Variant& color) +{ + __color[EDIT_STATUS_PRESSED].backgroundColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyPressedColor(void) const +{ + return Variant(__color[EDIT_STATUS_PRESSED].backgroundColor); +} + +result +_Edit::SetPropertyHighlightedColor(const Variant& color) +{ + __color[EDIT_STATUS_HIGHLIGHTED].backgroundColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyHighlightedColor(void) const +{ + return Variant(__color[EDIT_STATUS_HIGHLIGHTED].backgroundColor); +} + +result +_Edit::SetPropertyTextSize(const Variant& textSize) +{ + int fontMinSize = 0; + int size = textSize.ToInt(); + result r = E_SUCCESS; + + GET_FIXED_VALUE_CONFIG(EDIT::FONT_MIN_SIZE, _CONTROL_ORIENTATION_PORTRAIT, fontMinSize); + SysTryReturn(NID_UI_CTRL, size >= fontMinSize, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid size is given."); + + r = _pEditPresenter->SetTextSize(size); + + __textSize = size; + + return r; +} + +Variant +_Edit::GetPropertyTextSize(void) const +{ + return Variant(__textSize); +} + +result +_Edit::SetPropertyNormalTextColor(const Variant& color) +{ + __color[EDIT_STATUS_NORMAL].textColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyNormalTextColor(void) const +{ + return Variant(__color[EDIT_STATUS_NORMAL].textColor); +} + +result +_Edit::SetPropertyHighlightedTextColor(const Variant& color) +{ + __color[EDIT_STATUS_HIGHLIGHTED].textColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyHighlightedTextColor(void) const +{ + return Variant(__color[EDIT_STATUS_HIGHLIGHTED].textColor); +} + +result +_Edit::SetPropertyPressedTextColor(const Variant& color) +{ + __color[EDIT_STATUS_PRESSED].textColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyPressedTextColor(void) const +{ + return Variant(__color[EDIT_STATUS_PRESSED].textColor); +} + +result +_Edit::SetPropertyKeypadEnabled(const Variant& enabled) +{ + _pEditPresenter->SetKeypadEnabled(enabled.ToBool()); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyKeypadEnabled(void) const +{ + return Variant(_pEditPresenter->IsKeypadEnabled()); +} + +result +_Edit::SetPropertyKeypadStyle(const Variant& style) +{ + SysTryReturn(NID_UI_CTRL, (KEYPAD_STYLE_PASSWORD != (KeypadStyle)style.ToInt()), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + + return _pEditPresenter->SetKeypadStyle((KeypadStyle)style.ToInt()); +} + +Variant +_Edit::GetPropertyKeypadStyle(void) const +{ + return Variant((int)_pEditPresenter->GetKeypadStyle()); +} + +result +_Edit::SetPropertyLowerCaseModeEnabled(const Variant& enabled) +{ + _pEditPresenter->SetLowerCaseModeEnabled(enabled.ToBool()); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyLowerCaseModeEnabled(void) const +{ + return Variant(_pEditPresenter->IsLowerCaseModeEnabled()); +} + +result +_Edit::SetPropertyOverlayKeypadCommandButtonVisible(const Variant& visible) +{ + return _pEditPresenter->SetKeypadCommandButtonVisible(visible.ToBool()); +} + +Variant +_Edit::GetPropertyOverlayKeypadCommandButtonVisible(void) const +{ + return Variant(_pEditPresenter->IsKeypadCommandButtonVisible()); +} + +result +_Edit::SetPropertyText(const Variant& text) +{ + return _pEditPresenter->SetText(text.ToString()); +} + +Variant +_Edit::GetPropertyText(void) const +{ + return Variant(_pEditPresenter->GetText()); +} + +result +_Edit::SetPropertyViewModeEnabled(const Variant& enabled) +{ + return _pEditPresenter->SetViewModeEnabled(enabled.ToBool()); +} + +Variant +_Edit::GetPropertyViewModeEnabled(void) const +{ + return Variant(_pEditPresenter->IsViewModeEnabled()); +} + +result +_Edit::SetPropertyAutoLinkMask(const Variant& autoLinks) +{ + SysTryReturn(NID_UI_CTRL, (__inputStyle == INPUT_STYLE_OVERLAY), E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The current state unable to this operation."); + + return _pEditPresenter->SetAutoLinkMask(autoLinks.ToULong()); +} + +Variant +_Edit::GetPropertyAutoLinkMask(void) const +{ + SysTryReturn(NID_UI_CTRL, (__inputStyle == INPUT_STYLE_OVERLAY), Variant((unsigned long)LINK_TYPE_NONE), E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The current state unable to this operation."); + + return Variant(_pEditPresenter->GetAutoLinkMask()); +} + +result +_Edit::SetPropertyTitleText(const Variant& titleText) +{ + return _pEditPresenter->SetTitleText(titleText.ToString()); +} + +Variant +_Edit::GetPropertyTitleText(void) const +{ + return Variant(_pEditPresenter->GetTitleText()); +} + +result +_Edit::SetPropertyNormalTitleTextColor(const Variant& color) +{ + __color[EDIT_STATUS_NORMAL].titleTextColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyNormalTitleTextColor(void) const +{ + return Variant(__color[EDIT_STATUS_NORMAL].titleTextColor); +} + +result +_Edit::SetPropertyDisabledTitleTextColor(const Variant& color) +{ + __color[EDIT_STATUS_DISABLED].titleTextColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyDisabledTitleTextColor(void) const +{ + return Variant(__color[EDIT_STATUS_DISABLED].titleTextColor); +} + +result +_Edit::SetPropertyHighlightedTitleTextColor(const Variant& color) +{ + __color[EDIT_STATUS_HIGHLIGHTED].titleTextColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyHighlightedTitleTextColor(void) const +{ + return Variant(__color[EDIT_STATUS_HIGHLIGHTED].titleTextColor); +} + +result +_Edit::SetPropertyPressedTitleTextColor(const Variant& color) +{ + __color[EDIT_STATUS_PRESSED].titleTextColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyPressedTitleTextColor(void) const +{ + return Variant(__color[EDIT_STATUS_PRESSED].titleTextColor); +} + +result +_Edit::SetPropertyBlockedTextColor(const Variant& color) +{ + __blockTextColor.blockTextColor = color.ToColor(); + __blockTextColor.used = true; + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyBlockedTextColor(void) const +{ + return Variant(__blockTextColor.blockTextColor); +} + +result +_Edit::SetPropertyTopMargin(const Variant& margin) +{ + SysTryReturn(NID_UI_CTRL, margin.ToInt() > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + + __topMargin = margin.ToInt(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyTopMargin(void) const +{ + return Variant(__topMargin); +} + +result +_Edit::SetPropertyBottomMargin(const Variant& margin) +{ + SysTryReturn(NID_UI_CTRL, margin.ToInt() > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + + __bottomMargin = margin.ToInt(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyBottomMargin(void) const +{ + return Variant(__bottomMargin); +} + +result +_Edit::SetPropertyLeftMargin(const Variant& margin) +{ + SysTryReturn(NID_UI_CTRL, margin.ToInt() > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + + __leftMargin = margin.ToInt(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyLeftMargin(void) const +{ + return Variant(__leftMargin); +} + +result +_Edit::SetPropertyRightMargin(const Variant& margin) +{ + SysTryReturn(NID_UI_CTRL, margin.ToInt() > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + + __rightMargin = margin.ToInt(); + + return E_SUCCESS; +} + +Variant +_Edit::GetPropertyRightMargin(void) const +{ + return Variant(__rightMargin); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditAreaImpl.cpp b/src/ui/controls/FUiCtrl_EditAreaImpl.cpp new file mode 100644 index 0000000..ae020c9 --- /dev/null +++ b/src/ui/controls/FUiCtrl_EditAreaImpl.cpp @@ -0,0 +1,1841 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditAreaImpl.cpp + * @brief This is the implementation file for _EditAreaImpl class. + */ + +#include +#include +#include +#include +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_EditAreaImpl.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Dimension +_EditAreaImpl::EditAreaSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Dimension editAreaMinimumSize(0, 0); + + r = GET_DIMENSION_CONFIG(EDIT::MIN_SIZE, orientation, editAreaMinimumSize); + SysTryReturn(NID_UI, r == E_SUCCESS, editAreaMinimumSize, r, "System Error occurred."); + + return editAreaMinimumSize; +} + +_EditAreaImpl* +_EditAreaImpl::GetInstance(EditArea& editArea) +{ + return (static_cast<_EditAreaImpl*> (editArea._pControlImpl)); +} + +const _EditAreaImpl* +_EditAreaImpl::GetInstance(const EditArea& editArea) +{ + return (static_cast (editArea._pControlImpl)); +} + +_EditAreaImpl::_EditAreaImpl(EditArea* pPublic, _Edit* pCore) + : _ControlImpl(pPublic, pCore) + , __pEdit(pCore) + , __inputModeCategory(EDIT_INPUTMODE_ALPHA | EDIT_INPUTMODE_PREDICTIVE | EDIT_INPUTMODE_NUMERIC | EDIT_INPUTMODE_SYMBOL) + , __currentInputMode(EDIT_INPUTMODE_ALPHA) + , __pPublicActionEvent(null) + , __pPublicKeypadEvent(null) + , __pPublicLanguageEvent(null) + , __pPublicLinkEvent(null) + , __pPublicScrollPanelEvent(null) + , __pPublicTextBlockEvent(null) + , __pPublicTextEvent(null) + , __autoLinkMask(LINK_TYPE_NONE) +{ +} + +_EditAreaImpl::~_EditAreaImpl(void) +{ + if (__pEdit) + { + __pEdit->RemoveActionEventListener(*this); + __pEdit->RemoveLanguageEventListener(*this); + __pEdit->RemoveKeypadEventListener(*this); + __pEdit->RemoveTextBlockEventListener(*this); + __pEdit->RemoveTextEventListener(*this); + __pEdit->RemoveScrollPanelEventListener(*this); + __pEdit->RemoveUiLinkEventListener(*this); + } + + if (__pPublicActionEvent) + { + delete __pPublicActionEvent; + __pPublicActionEvent = null; + } + + if (__pPublicKeypadEvent) + { + delete __pPublicKeypadEvent; + __pPublicKeypadEvent = null; + } + + if (__pPublicTextBlockEvent) + { + delete __pPublicTextBlockEvent; + __pPublicTextBlockEvent = null; + } + + if (__pPublicLinkEvent) + { + delete __pPublicLinkEvent; + __pPublicLinkEvent = null; + } + + if (__pPublicLanguageEvent) + { + delete __pPublicLanguageEvent; + __pPublicLanguageEvent = null; + } + + if (__pPublicScrollPanelEvent) + { + delete __pPublicScrollPanelEvent; + __pPublicScrollPanelEvent = null; + } + + if (__pPublicTextEvent) + { + delete __pPublicTextEvent; + __pPublicTextEvent = null; + } +} + +_EditAreaImpl* +_EditAreaImpl::CreateEditAreaImplN(EditArea* pControl, const Rectangle& rect) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _Edit* pCore = null; + + pCore = _Edit::CreateEditN(); + SysTryReturn(NID_UI_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _EditAreaImpl* pImpl = new (std::nothrow) _EditAreaImpl(pControl, pCore); + + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; +} + +const char* +_EditAreaImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::EditArea"; +} + +const EditArea& +_EditAreaImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +EditArea& +_EditAreaImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Edit& +_EditAreaImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Edit& +_EditAreaImpl::GetCore(void) +{ + return static_cast <_Edit&>(_ControlImpl::GetCore()); +} + +result +_EditAreaImpl::Initialize(InputStyle inputStyle, int limitLength) +{ + SysTryReturnResult(NID_UI_CTRL, (limitLength > 0), E_INVALID_ARG, "[E_INVALID_ARG] The limit length must be more than 0."); + + result r = __pEdit->Initialize(EDIT_STYLE_NORMAL, inputStyle, limitLength); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (!_AppInfo::IsOspCompat()) + { + __pEdit->SetKeypadCommandButtonVisible(false); + } + + __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] System error occurred."); + + r = __pEdit->AddActionEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicLanguageEvent = _PublicLanguageEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicLanguageEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] System error occurred."); + + r = __pEdit->AddLanguageEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent = _PublicKeypadEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] System error occurred."); + + r = __pEdit->AddKeypadEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTextBlockEvent = _PublicTextBlockEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] System error occurred."); + + r = __pEdit->AddTextBlockEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTextEvent = _PublicTextEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] System error occurred."); + + r = __pEdit->AddTextEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicScrollPanelEvent = _PublicScrollPanelEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicScrollPanelEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] System error occurred."); + + if (inputStyle == INPUT_STYLE_OVERLAY) + { + r = __pEdit->AddScrollPanelEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __pPublicLinkEvent = _PublicLinkEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicLinkEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] System error occurred."); + + r = __pEdit->AddUiLinkEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (inputStyle == INPUT_STYLE_OVERLAY) + { + __pEdit->SetAutoLinkMask(LINK_TYPE_URL | LINK_TYPE_EMAIL | LINK_TYPE_TEL_NUM); + } + + return r; +} + +HorizontalAlignment +_EditAreaImpl::GetTextAlignment(void) const +{ + return __pEdit->GetTextAlignment(); +} + +result +_EditAreaImpl::SetTextAlignment(HorizontalAlignment alignment) +{ + return __pEdit->SetTextAlignment(alignment); +} + +bool +_EditAreaImpl::IsViewModeEnabled(void) const +{ + return __pEdit->GetPropertyViewModeEnabled().ToBool(); +} + +result +_EditAreaImpl::SetViewModeEnabled(bool enable) +{ + Variant variantEnable(enable); + + return __pEdit->SetPropertyViewModeEnabled(variantEnable); +} + +result +_EditAreaImpl::SetAutoLinkMask(unsigned long autoLinks) +{ + result r = E_SUCCESS; + Variant variantAutoLinks(autoLinks); + + r = __pEdit->SetPropertyAutoLinkMask(variantAutoLinks); + + if (r == E_SUCCESS) + { + __autoLinkMask = autoLinks; + } + + return r; + +} + +unsigned long +_EditAreaImpl::GetAutoLinkMask(void) const +{ + SysTryReturn(NID_UI_CTRL, (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY), LINK_TYPE_NONE, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The current state unable to this operation."); + return __autoLinkMask; +} + +int +_EditAreaImpl::GetLineSpacing(void) const +{ + return __pEdit->GetLineSpacing(); +} + +result +_EditAreaImpl::SetLineSpacing(int multiplier, int extra) +{ + SysTryReturn(NID_UI_CTRL, multiplier >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + SysTryReturn(NID_UI_CTRL, extra >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + + return __pEdit->SetLineSpacing(DEFAULT_LINE_SPACE * multiplier + extra); +} + +int +_EditAreaImpl::GetMargin(EditMarginType marginType) const +{ + if (marginType == EDIT_MARGIN_TYPE_VERTICAL) + { + return __pEdit->GetVerticalMargin(EDIT_TEXT_TOP_MARGIN); + } + else + { + return __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + } +} + +result +_EditAreaImpl::SetMargin(EditMarginType marginType, int margin) +{ + result r = E_SUCCESS; + Variant varMargin(margin); + + if (marginType == EDIT_MARGIN_TYPE_HORIZONTAL) + { + r = __pEdit->SetHorizontalMargin(margin, EDIT_TEXT_LEFT_MARGIN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __pEdit->SetHorizontalMargin(margin, EDIT_TEXT_RIGHT_MARGIN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = __pEdit->SetVerticalMargin(margin, EDIT_TEXT_TOP_MARGIN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __pEdit->SetVerticalMargin(margin, EDIT_TEXT_BOTTOM_MARGIN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_EditAreaImpl::SetKeypadActionEnabled(bool enable) +{ + Variant variantEnable(enable); + + return __pEdit->SetPropertyKeypadActionEnabled(variantEnable); +} + +bool +_EditAreaImpl::IsKeypadActionEnabled(void) const +{ + return __pEdit->GetPropertyKeypadActionEnabled().ToBool(); +} + +KeypadAction +_EditAreaImpl::GetKeypadAction(void) const +{ + int coreKeypadAction = __pEdit->GetPropertyKeypadAction().ToInt(); + KeypadAction publicKeypadAction = KEYPAD_ACTION_ENTER; + + switch (coreKeypadAction) + { + case CORE_KEYPAD_ACTION_ENTER: + publicKeypadAction = KEYPAD_ACTION_ENTER; + break; + + case CORE_KEYPAD_ACTION_GO: + publicKeypadAction = KEYPAD_ACTION_GO; + break; + + case CORE_KEYPAD_ACTION_NEXT: + publicKeypadAction = KEYPAD_ACTION_NEXT; + break; + + case CORE_KEYPAD_ACTION_SEND: + publicKeypadAction = KEYPAD_ACTION_SEND; + break; + + case CORE_KEYPAD_ACTION_SEARCH: + publicKeypadAction = KEYPAD_ACTION_SEARCH; + break; + + case CORE_KEYPAD_ACTION_LOGIN: + publicKeypadAction = KEYPAD_ACTION_LOGIN; + break; + + case CORE_KEYPAD_ACTION_SIGN_IN: + publicKeypadAction = KEYPAD_ACTION_SIGN_IN; + break; + + case CORE_KEYPAD_ACTION_JOIN: + publicKeypadAction = KEYPAD_ACTION_JOIN; + break; + + case CORE_KEYPAD_ACTION_DONE: + publicKeypadAction = KEYPAD_ACTION_DONE; + break; + + default: + break; + } + + return publicKeypadAction; +} + +result +_EditAreaImpl::SetKeypadAction(KeypadAction keypadAction) +{ + CoreKeypadAction coreKeypadAction = CORE_KEYPAD_ACTION_ENTER; + + switch (keypadAction) + { + case KEYPAD_ACTION_ENTER: + coreKeypadAction = CORE_KEYPAD_ACTION_ENTER; + break; + + case KEYPAD_ACTION_GO: + coreKeypadAction = CORE_KEYPAD_ACTION_GO; + break; + + case KEYPAD_ACTION_NEXT: + coreKeypadAction = CORE_KEYPAD_ACTION_NEXT; + break; + + case KEYPAD_ACTION_SEND: + coreKeypadAction = CORE_KEYPAD_ACTION_SEND; + break; + + case KEYPAD_ACTION_SEARCH: + coreKeypadAction = CORE_KEYPAD_ACTION_SEARCH; + break; + + case KEYPAD_ACTION_LOGIN: + coreKeypadAction = CORE_KEYPAD_ACTION_LOGIN; + break; + + case KEYPAD_ACTION_SIGN_IN: + coreKeypadAction = CORE_KEYPAD_ACTION_SIGN_IN; + break; + + case KEYPAD_ACTION_JOIN: + coreKeypadAction = CORE_KEYPAD_ACTION_JOIN; + break; + + case KEYPAD_ACTION_DONE: + coreKeypadAction = CORE_KEYPAD_ACTION_DONE; + break; + + default: + break; + } + + Variant variantKeypadAction((int)coreKeypadAction); + + return __pEdit->SetPropertyKeypadAction(variantKeypadAction); +} + +KeypadStyle +_EditAreaImpl::GetKeypadStyle(void) const +{ + return (KeypadStyle)__pEdit->GetPropertyKeypadStyle().ToInt(); +} + +result +_EditAreaImpl::SetKeypadStyle(KeypadStyle keypadStyle) +{ + Variant variantKeypadStyle((int)keypadStyle); + + return __pEdit->SetPropertyKeypadStyle(variantKeypadStyle); +} + +result +_EditAreaImpl::SetOverlayKeypadCommandButtonVisible(bool visible) +{ + Variant variantVisible(visible); + + return __pEdit->SetPropertyOverlayKeypadCommandButtonVisible(variantVisible); +} + +bool +_EditAreaImpl::IsOverlayCommandButtonVisible(void) const +{ + return __pEdit->GetPropertyOverlayKeypadCommandButtonVisible().ToBool(); +} + +result +_EditAreaImpl::HideKeypad(void) +{ + return __pEdit->HideKeypad(); +} + +int +_EditAreaImpl::GetTextSize(void) const +{ + return __pEdit->GetPropertyTextSize().ToInt(); +} + +result +_EditAreaImpl::SetTextSize(int size) +{ + Variant variantSize(size); + + return __pEdit->SetPropertyTextSize(variantSize); +} + +Color +_EditAreaImpl::GetColor(EditStatus status) const +{ + Color color; + + switch (status) + { + case EDIT_STATUS_NORMAL: + color = __pEdit->GetPropertyNormalColor().ToColor(); + break; + + case EDIT_STATUS_DISABLED: + color = __pEdit->GetPropertyDisabledColor().ToColor(); + break; + + case EDIT_STATUS_HIGHLIGHTED: + color = __pEdit->GetPropertyHighlightedColor().ToColor(); + break; + + case EDIT_STATUS_PRESSED: + color = __pEdit->GetPropertyPressedColor().ToColor(); + break; + + default: + break; + } + + return color; +} + +Color +_EditAreaImpl::GetTextColor(EditTextColor type) const +{ + return __pEdit->GetTextColor(type); +} + +result +_EditAreaImpl::SetBackgroundBitmap(EditStatus status, const Bitmap& bitmap) +{ + return __pEdit->SetBackgroundBitmap(status, bitmap); +} + +result +_EditAreaImpl::SetColor(EditStatus status, const Color& color) +{ + result r = E_SUCCESS; + Variant variantColor(color); + + switch (status) + { + case EDIT_STATUS_NORMAL: + r = __pEdit->SetPropertyNormalColor(variantColor); + break; + + case EDIT_STATUS_DISABLED: + r = __pEdit->SetPropertyDisabledColor(variantColor); + break; + + case EDIT_STATUS_HIGHLIGHTED: + r = __pEdit->SetPropertyHighlightedColor(variantColor); + break; + + case EDIT_STATUS_PRESSED: + r = __pEdit->SetPropertyPressedColor(variantColor); + break; + + default: + r = E_INVALID_ARG; + break; + } + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Unable to set color.", GetErrorMessage(r)); + + return r; +} + +result +_EditAreaImpl::SetTextColor(EditTextColor type, const Color& color) +{ + return __pEdit->SetTextColor(type, color); +} + +String +_EditAreaImpl::GetText(int start, int end) const +{ + return __pEdit->GetText(start, end); +} + +result +_EditAreaImpl::AddUiLinkEventListener(IUiLinkEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicLinkEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicLinkEvent->AddListener(listener); +} + +result +_EditAreaImpl::RemoveUiLinkEventListener(IUiLinkEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicLinkEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicLinkEvent->RemoveListener(listener); +} + +result +_EditAreaImpl::AddKeypadEventListener(IKeypadEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicKeypadEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicKeypadEvent->AddListener(listener); +} + +result +_EditAreaImpl::RemoveKeypadEventListener(IKeypadEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicKeypadEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicKeypadEvent->RemoveListener(listener); +} + +result +_EditAreaImpl::AddTextBlockEventListener(ITextBlockEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicTextBlockEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicTextBlockEvent->AddListener(listener); +} + +result +_EditAreaImpl::RemoveTextBlockEventListener(ITextBlockEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicTextBlockEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicTextBlockEvent->RemoveListener(listener); +} + +result +_EditAreaImpl::AddTextEventListener(ITextEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicTextEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicTextEvent->AddListener(listener); +} + +result +_EditAreaImpl::RemoveTextEventListener(ITextEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicTextEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicTextEvent->RemoveListener(listener); +} + +result +_EditAreaImpl::AddScrollPanelEventListener(IScrollPanelEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.") + SysAssertf(__pPublicScrollPanelEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicScrollPanelEvent->AddListener(listener); +} + +result +_EditAreaImpl::RemoveScrollPanelEventListener(IScrollPanelEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicScrollPanelEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicScrollPanelEvent->RemoveListener(listener); +} + +result +_EditAreaImpl::AddActionEventListener(IActionEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicActionEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicActionEvent->AddListener(listener); +} + +result +_EditAreaImpl::RemoveActionEventListener(IActionEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicActionEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicActionEvent->RemoveListener(listener); +} + +result +_EditAreaImpl::AddLanguageEventListener(ILanguageEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicLanguageEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicLanguageEvent->AddListener(listener); +} + +result +_EditAreaImpl::RemoveLanguageEventListener(ILanguageEventListener& listener) +{ + ClearLastResult(); + SysAssertf(__pPublicLanguageEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicLanguageEvent->RemoveListener(listener); +} + +int +_EditAreaImpl::GetRemainingLength(void) const +{ + return __pEdit->GetRemainingLength(); +} + +void +_EditAreaImpl::SetLowerCaseModeEnabled(bool enable) +{ + Variant variantEnable(enable); + + __pEdit->SetPropertyLowerCaseModeEnabled(variantEnable); +} + +bool +_EditAreaImpl::IsLowerCaseModeEnabled(void) const +{ + return __pEdit->GetPropertyLowerCaseModeEnabled().ToBool(); +} + +result +_EditAreaImpl::SetInputModeCategory(unsigned long categories, bool enable) +{ + result r = E_SUCCESS; + const unsigned long INPUT_MODE_ALL_MASK = EDIT_INPUTMODE_ALPHA | EDIT_INPUTMODE_PREDICTIVE | EDIT_INPUTMODE_NUMERIC| EDIT_INPUTMODE_SYMBOL; + KeypadStyle keypadStyle = GetKeypadStyle(); + + switch (keypadStyle) + { + case KEYPAD_STYLE_NUMBER: + // fall through + case KEYPAD_STYLE_IP_V4: + if (enable) + { + if (categories & (EDIT_INPUTMODE_ALPHA | EDIT_INPUTMODE_PREDICTIVE | EDIT_INPUTMODE_SYMBOL)) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current keypad style can not support given categories."); + + return E_INVALID_OPERATION; + } + } + else + { + if (categories & EDIT_INPUTMODE_NUMERIC) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current keypad style can not support given categories."); + + return E_INVALID_OPERATION; + } + } + break; + + case KEYPAD_STYLE_PHONE_NUMBER: + if (enable) + { + if (categories & (EDIT_INPUTMODE_ALPHA | EDIT_INPUTMODE_PREDICTIVE)) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current keypad style can not support given categories."); + + return E_INVALID_OPERATION; + } + + if (!((categories & EDIT_INPUTMODE_NUMERIC) && (categories & EDIT_INPUTMODE_SYMBOL))) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current keypad style can not support given categories."); + + return E_INVALID_OPERATION; + } + } + else + { + if (categories & (EDIT_INPUTMODE_NUMERIC | EDIT_INPUTMODE_SYMBOL)) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current keypad style can not support given categories."); + + return E_INVALID_OPERATION; + } + } + break; + + default: + break; + } + + if (((enable == true) && (categories == 0)) || ((enable == false) && (categories == INPUT_MODE_ALL_MASK))) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] All input modes cannot be disabled."); + + return E_INVALID_ARG; + } + + if ((enable == false) && (categories & __currentInputMode)) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] The current input modes cannot be disabled."); + + return E_INVALID_ARG; + } + + if (enable) + { + __inputModeCategory = categories; + if ((~categories) & EDIT_INPUTMODE_PREDICTIVE) + { + __pEdit->SetTextPredictionEnabled(false); + } + } + else + { + __inputModeCategory = (~categories & INPUT_MODE_ALL_MASK); + if (categories == EDIT_INPUTMODE_PREDICTIVE) + { + __pEdit->SetTextPredictionEnabled(false); + } + } + + // if currentInputModeCategory doesn't exist in categories, then set tempInputMode. + if (!(categories & __currentInputMode)) + { + const int INPUT_MODE_CATEGORY_MAX = 4; + EditInputModeCategory newInputMode = __currentInputMode; + EditInputModeCategory tempInputMode = EDIT_INPUTMODE_ALPHA; + for (int i = 0; i < INPUT_MODE_CATEGORY_MAX; i++) + { + if ( (categories & tempInputMode) && (tempInputMode != EDIT_INPUTMODE_PREDICTIVE)) + { + newInputMode = tempInputMode; + break; + } + + switch (tempInputMode) + { + case EDIT_INPUTMODE_ALPHA: + tempInputMode = EDIT_INPUTMODE_PREDICTIVE; + break; + + case EDIT_INPUTMODE_PREDICTIVE: + tempInputMode = EDIT_INPUTMODE_NUMERIC; + break; + + case EDIT_INPUTMODE_NUMERIC: + tempInputMode = EDIT_INPUTMODE_SYMBOL; + break; + + default: + break; + } + } + + if (__currentInputMode != newInputMode) + { + r = SetCurrentInputModeCategory(newInputMode); + } + } + + return r; +} + +result +_EditAreaImpl::SetCurrentInputModeCategory(EditInputModeCategory inputModeCategory) +{ + KeypadStyle currentKeypadStyle = GetKeypadStyle(); + KeypadStyle keypadStyle = KEYPAD_STYLE_NORMAL; + + if (inputModeCategory == EDIT_INPUTMODE_NUMERIC) + { + if (currentKeypadStyle == KEYPAD_STYLE_NORMAL) + { + __pEdit->SetKeypadNormalNumberStyle(true); + } + else + { + keypadStyle = KEYPAD_STYLE_NUMBER; + Variant variantKeypadStyle((int)keypadStyle); + + __pEdit->SetPropertyKeypadStyle(variantKeypadStyle); + } + } + else if (inputModeCategory == EDIT_INPUTMODE_SYMBOL) + { + if (currentKeypadStyle == KEYPAD_STYLE_NORMAL) + { + __pEdit->SetKeypadNormalNumberStyle(true); + } + } + else if (inputModeCategory == EDIT_INPUTMODE_PREDICTIVE) + { + __pEdit->SetTextPredictionEnabled(true); + } + + __currentInputMode = inputModeCategory; + + return E_SUCCESS; +} + +unsigned long +_EditAreaImpl::GetInputModeCategory(void) const +{ + return __inputModeCategory; +} + +EditInputModeCategory +_EditAreaImpl::GetCurrentInputModeCategory(void) const +{ + return __currentInputMode; +} + +bool +_EditAreaImpl::IsTextPredictionEnabled(void) const +{ + return __pEdit->IsTextPredictionEnabled(); +} + +result +_EditAreaImpl::SetTextPredictionEnabled(bool enable) +{ + return __pEdit->SetTextPredictionEnabled(enable); +} + +result +_EditAreaImpl::SetCursorPosition(int position) +{ + Variant variantPosition(position); + + return __pEdit->SetPropertyCursorPosition(variantPosition); +} + +int +_EditAreaImpl::GetCursorPosition(void) const +{ + return __pEdit->GetPropertyCursorPosition().ToInt(); +} + +String +_EditAreaImpl::GetText(void) const +{ + return __pEdit->GetPropertyText().ToString(); +} + +int +_EditAreaImpl::GetTextLength(void) const +{ + return __pEdit->GetTextLength(); +} + +result +_EditAreaImpl::SetText(const String& text) +{ + Variant variantText(text); + + return __pEdit->SetPropertyText(variantText); +} + +result +_EditAreaImpl::InsertTextAtCursorPosition(const String& text) +{ + return __pEdit->InsertTextAtCursorPosition(text); +} + +result +_EditAreaImpl::AppendText(const String& text) +{ + return __pEdit->AppendText(text); +} + +result +_EditAreaImpl::AppendCharacter(const Character& character) +{ + return __pEdit->AppendCharacter(character); +} + +result +_EditAreaImpl::InsertTextAt(int position, const String& text, const Bitmap& textImage) +{ + return __pEdit->InsertTextAt(position, text, textImage); +} + +result +_EditAreaImpl::AppendText(const String& text, const Bitmap& textImage) +{ + return __pEdit->AppendText(text, textImage); +} + +result +_EditAreaImpl::Clear(void) +{ + return __pEdit->ClearText(); +} + +result +_EditAreaImpl::DeleteCharacterAtCursorPosition(void) +{ + return __pEdit->DeleteCharacterAtCursorPosition(); +} + +void +_EditAreaImpl::GetCurrentTextRange(int& start, int& end) const +{ + return __pEdit->GetCurrentTextRange(start, end); +} + +void +_EditAreaImpl::SetGuideText(const String& guideText) +{ + Variant variantGuideText(guideText); + + __pEdit->SetPropertyGuideText(variantGuideText); +} + +String +_EditAreaImpl::GetGuideText(void) const +{ + return __pEdit->GetPropertyGuideText().ToString(); +} + +Color +_EditAreaImpl::GetGuideTextColor(void) const +{ + return __pEdit->GetPropertyGuideTextColor().ToColor(); +} + +result +_EditAreaImpl::SetGuideTextColor(const Color& color) +{ + Variant variantColor(color); + + return __pEdit->SetPropertyGuideTextColor(variantColor); +} + +void +_EditAreaImpl::SetKeypadEnabled(bool enable) +{ + Variant variantEnable(enable); + + __pEdit->SetPropertyKeypadEnabled(variantEnable); +} + +bool +_EditAreaImpl::IsKeypadEnabled(void) const +{ + return __pEdit->GetPropertyKeypadEnabled().ToBool(); +} + +result +_EditAreaImpl::ShowKeypad(void) +{ + return __pEdit->ShowKeypad(); +} + +int +_EditAreaImpl::GetTextLineCount(void) const +{ + return __pEdit->GetTextLineCount(); +} + +void +_EditAreaImpl::GetBlockRange(int& start, int& end) const +{ + __pEdit->GetBlockRange(start, end); +} + +result +_EditAreaImpl::BeginBlock(void) +{ + return __pEdit->BeginTextBlock(); +} + +result +_EditAreaImpl::ReleaseBlock(void) +{ + return __pEdit->ReleaseTextBlock(); +} + +bool +_EditAreaImpl::IsBlocked(void) const +{ + return __pEdit->IsBlocked(); +} + +result +_EditAreaImpl::Copy(void) +{ + return __pEdit->CopyText(); +} + +result +_EditAreaImpl::Cut(void) +{ + return __pEdit->CutText(); +} + +result +_EditAreaImpl::Paste(void) +{ + return __pEdit->PasteText(); +} + +result +_EditAreaImpl::Remove(void) +{ + SysTryReturnResult(NID_UI_CTRL, (__pEdit->RemoveTextBlock() == E_SUCCESS), E_SYSTEM, "A system error has occurred"); + + return E_SUCCESS; +} + +bool +_EditAreaImpl::IsClipped(void) const +{ + return __pEdit->IsClipped(); +} + +result +_EditAreaImpl::SetOverlayKeypadCommandButton(CommandButtonPosition position, const String& text, int actionId) +{ + return __pEdit->SetKeypadCommandButton(position, text, actionId); +} + +String +_EditAreaImpl::GetOverlayKeypadCommandButtonText(CommandButtonPosition position) const +{ + return __pEdit->GetKeypadCommandButtonText(position); +} + +int +_EditAreaImpl::GetOverlayKeypadCommandButtonActionId(CommandButtonPosition position) const +{ + return __pEdit->GetKeypadCommandButtonActionId(position); +} + +result +_EditAreaImpl::SetCurrentLanguage(LanguageCode languageCode) +{ + return __pEdit->SetCurrentLanguage(languageCode); +} + +result +_EditAreaImpl::GetCurrentLanguage(LanguageCode& language) const +{ + return __pEdit->GetCurrentLanguage(language); +} + +result +_EditAreaImpl::OnBoundsChanged(const Rectangle& oldRect, const Rectangle& newRect) +{ + return E_SUCCESS; +} + +void +_EditAreaImpl::OnTextValueChanged(const _Control& source) +{ + if (__pPublicTextEvent != null) + { + IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CHANGED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pPublicTextEvent->Fire(*pEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnTextValueChangeCanceled(const _Control& source) +{ + if (__pPublicTextEvent != null) + { + IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CANCELED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pPublicTextEvent->Fire(*pEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnActionPerformed(const _Control& source, int actionId) +{ + if (__pPublicActionEvent != null) + { + IEventArg* pActionEventArg = _PublicActionEvent::CreateActionEventArgN(actionId); + SysTryReturnVoidResult(NID_UI_CTRL, pActionEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicActionEvent->Fire(*pActionEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnLinkClicked(_Control& source, const String& text, Utility::LinkType linkType, const String& link) +{ + if (__pPublicLinkEvent != null) + { + IEventArg* pLinkEventArg = _PublicLinkEvent::CreateLinkEventArgN(text, linkType, link); + SysTryReturnVoidResult(NID_UI_CTRL, pLinkEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicLinkEvent->Fire(*pLinkEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnTextBlockSelected(_Control& source, int start, int end) +{ + if (__pPublicTextBlockEvent != null) + { + IEventArg* pTextBlockEventArg = _PublicTextBlockEvent::CreateTextBlockEventArgN(start, end); + SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _TextBlockEventArg."); + + __pPublicTextBlockEvent->Fire(*pTextBlockEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnKeypadWillOpen(void) +{ + if (__pPublicKeypadEvent) + { + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_ENTER, KEYPAD_EVENT_STATUS_CREATED); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnKeypadOpened(void) +{ + if (__pPublicKeypadEvent) + { + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_ENTER, KEYPAD_EVENT_STATUS_OPEN); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnKeypadClosed(void) +{ + if (__pPublicKeypadEvent) + { + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_ENTER, KEYPAD_EVENT_STATUS_CLOSE); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnKeypadBoundsChanged(void) +{ + if (__pPublicKeypadEvent) + { + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_ENTER, KEYPAD_EVENT_STATUS_BOUNDS_CHANGED); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnKeypadActionPerformed(CoreKeypadAction keypadAction) +{ + if (__pPublicKeypadEvent) + { + KeypadAction onKeypadAction = KEYPAD_ACTION_ENTER; + switch (keypadAction) + { + case CORE_KEYPAD_ACTION_ENTER: + onKeypadAction = KEYPAD_ACTION_ENTER; + break; + + case CORE_KEYPAD_ACTION_GO: + onKeypadAction = KEYPAD_ACTION_GO; + break; + + case CORE_KEYPAD_ACTION_NEXT: + onKeypadAction = KEYPAD_ACTION_NEXT; + break; + + case CORE_KEYPAD_ACTION_SEND: + onKeypadAction = KEYPAD_ACTION_SEND; + break; + + case CORE_KEYPAD_ACTION_SEARCH: + onKeypadAction = KEYPAD_ACTION_SEARCH; + break; + + case CORE_KEYPAD_ACTION_LOGIN: + onKeypadAction = KEYPAD_ACTION_LOGIN; + break; + + case CORE_KEYPAD_ACTION_SIGN_IN: + onKeypadAction = KEYPAD_ACTION_SIGN_IN; + break; + + case CORE_KEYPAD_ACTION_JOIN: + onKeypadAction = KEYPAD_ACTION_JOIN; + break; + + case CORE_KEYPAD_ACTION_DONE: + onKeypadAction = KEYPAD_ACTION_DONE; + break; + + default: + break; + } + + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), onKeypadAction, KEYPAD_EVENT_STATUS_ENTERACTION); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnLanguageChanged(LanguageCode oldLanguage, LanguageCode newLanguage) +{ + if (__pPublicLanguageEvent) + { + IEventArg* pKLanguageEventArg = _PublicLanguageEvent::CreateLanguageEventArgN(GetPublic(), oldLanguage, newLanguage); + SysTryReturnVoidResult(NID_UI_CTRL, pKLanguageEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pPublicLanguageEvent->Fire(*pKLanguageEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnOverlayControlCreated(const _Control& source) +{ + if (__pPublicScrollPanelEvent != null) + { + IEventArg* pEventArg = _PublicScrollPanelEvent::CreateScrollPanelEventArgN(OVERLAY_CONTROL_CREATED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicScrollPanelEvent->Fire(*pEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnOverlayControlOpened(const _Control& source) +{ + if (__pPublicScrollPanelEvent != null) + { + IEventArg* pEventArg = _PublicScrollPanelEvent::CreateScrollPanelEventArgN(OVERLAY_CONTROL_OPENED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicScrollPanelEvent->Fire(*pEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnOverlayControlClosed(const _Control& source) +{ + if (__pPublicScrollPanelEvent != null) + { + IEventArg* pEventArg = _PublicScrollPanelEvent::CreateScrollPanelEventArgN(OVERLAY_CONTROL_CLOSED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicScrollPanelEvent->Fire(*pEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditAreaImpl::OnOtherControlSelected(const _Control& source) +{ + if (__pPublicScrollPanelEvent != null) + { + IEventArg* pEventArg = _PublicScrollPanelEvent::CreateScrollPanelEventArgN(OTHER_CONTROL_SELECTED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicScrollPanelEvent->Fire(*pEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +class _EditAreaMaker + : public _UiBuilderControlMaker +{ +public: + _EditAreaMaker(_UiBuilder* pUiBuilder) + : _UiBuilderControlMaker(pUiBuilder){}; + virtual ~_EditAreaMaker(){}; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* pUiBuilder) + { + _EditAreaMaker* pEditAreaMaker = new (std::nothrow) _EditAreaMaker(pUiBuilder); + return pEditAreaMaker; + }; +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + EditArea* pEditArea = null; + Rectangle rect; + String elementString; + InputStyle inputStyle = INPUT_STYLE_FULLSCREEN; + int limitLength = EDIT_AREA_DEFAULT_LIMIT_LENGTH; + + KeypadStyle keypadStyle = KEYPAD_STYLE_NORMAL; + KeypadAction keypadAction = KEYPAD_ACTION_ENTER; + bool lowerCaseMode = false; + HorizontalAlignment horizontalAlignment = ALIGNMENT_LEFT; + bool viewModeEnable = false; + bool commandButtonVisible = false; + int fontSize = 0; + Color color; + int opacity = EDIT_COLOR_OPACITY; + int horizontalMargin = 0; + int verticalMargin = 0; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pEditArea = new (std::nothrow) EditArea(); + if (pEditArea == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + + if (pControl->GetElement(L"inputStyle", elementString) || pControl->GetElement(L"InputStyle", elementString)) + { + if (elementString.Equals(L"INPUT_STYLE_OVERLAY", false)) + { + inputStyle = INPUT_STYLE_OVERLAY; + } + else + { + inputStyle = INPUT_STYLE_FULLSCREEN; + } + + if (pControl->GetElement(L"commandButtonVisible", elementString)) + { + if (elementString.Equals(L"true", false)) + { + commandButtonVisible = true; + } + + } + else + { + commandButtonVisible = true; + } + + } + + if (pControl->GetElement(L"limitLength", elementString)) + { + Base::Integer::Parse(elementString, limitLength); + } + + r = pEditArea->Construct(rect, inputStyle, limitLength); + if (r != E_SUCCESS) + { + delete pEditArea; + return null; + } + + if (commandButtonVisible == false) + { + pEditArea->SetOverlayKeypadCommandButtonVisible(false); + } + + if (pControl->GetElement(L"text", elementString)) + { + r = pEditArea->SetText(elementString); + } + if (pControl->GetElement(L"guideText", elementString)) + { + pEditArea->SetGuideText(elementString); + } + + if (pControl->GetElement(L"keypadStyle", elementString)) + { + if (elementString.Equals(L"KEYPAD_STYLE_NORMAL", false)) + { + keypadStyle = KEYPAD_STYLE_NORMAL; + } + else if (elementString.Equals(L"KEYPAD_STYLE_PASSWORD", false)) + { + keypadStyle = KEYPAD_STYLE_PASSWORD; + } + else if (elementString.Equals(L"KEYPAD_STYLE_EMAIL", false)) + { + keypadStyle = KEYPAD_STYLE_EMAIL; + } + else if (elementString.Equals(L"KEYPAD_STYLE_URL", false)) + { + keypadStyle = KEYPAD_STYLE_URL; + } + else if (elementString.Equals(L"KEYPAD_STYLE_NUMBER", false)) + { + keypadStyle = KEYPAD_STYLE_NUMBER; + } + else if (elementString.Equals(L"KEYPAD_STYLE_PHONE_NUMBER", false)) + { + keypadStyle = KEYPAD_STYLE_PHONE_NUMBER; + } + else if (elementString.Equals(L"KEYPAD_STYLE_IP_V4", false)) + { + keypadStyle = KEYPAD_STYLE_IP_V4; + } + + r = pEditArea->SetKeypadStyle(keypadStyle); + } + + if (pControl->GetElement(L"keypadAction", elementString)) + { + if (elementString.Equals(L"KEYPAD_ACTION_ENTER", false)) + { + keypadAction = KEYPAD_ACTION_ENTER; + } + else if (elementString.Equals(L"KEYPAD_ACTION_GO", false)) + { + keypadAction = KEYPAD_ACTION_GO; + } + else if (elementString.Equals(L"KEYPAD_ACTION_NEXT", false)) + { + keypadAction = KEYPAD_ACTION_NEXT; + } + else if (elementString.Equals(L"KEYPAD_ACTION_SEND", false)) + { + keypadAction = KEYPAD_ACTION_SEND; + } + else if (elementString.Equals(L"KEYPAD_ACTION_SEARCH", false)) + { + keypadAction = KEYPAD_ACTION_SEARCH; + } + else if (elementString.Equals(L"KEYPAD_ACTION_LOGIN", false)) + { + keypadAction = KEYPAD_ACTION_LOGIN; + } + else if (elementString.Equals(L"KEYPAD_ACTION_SIGN_IN", false)) + { + keypadAction = KEYPAD_ACTION_SIGN_IN; + } + else if (elementString.Equals(L"KEYPAD_ACTION_JOIN", false)) + { + keypadAction = KEYPAD_ACTION_JOIN; + } + else if (elementString.Equals(L"KEYPAD_ACTION_DONE", false)) + { + keypadAction = KEYPAD_ACTION_DONE; + } + + r = pEditArea->SetKeypadAction(keypadAction); + } + + if (pControl->GetElement(L"textHorizontalAlignment", elementString)) + { + if (elementString.Equals(L"ALIGNMENT_LEFT", false)) + { + horizontalAlignment = ALIGNMENT_LEFT; + } + else if (elementString.Equals(L"ALIGNMENT_CENTER", false)) + { + horizontalAlignment = ALIGNMENT_CENTER; + } + else if (elementString.Equals(L"ALIGNMENT_RIGHT", false)) + { + horizontalAlignment = ALIGNMENT_RIGHT; + } + + r = pEditArea->SetTextAlignment(horizontalAlignment); + } + + if (pControl->GetElement(L"lowerCaseMode", elementString)) + { + if (elementString.Equals(L"true", false)) + { + lowerCaseMode = true; + } + else + { + lowerCaseMode = false; + } + + pEditArea->SetLowerCaseModeEnabled(lowerCaseMode); + } + + if (pControl->GetElement(L"textSize", elementString)) + { + Base::Integer::Parse(elementString, fontSize); + _ICoordinateSystemTransformer* pTransform = GetTransformer(); + if (pTransform) + { + fontSize = pTransform->Transform(fontSize); + } + + r = pEditArea->SetTextSize(fontSize); + } + + if (pControl->GetElement(L"viewMode", elementString)) + { + if (elementString.Equals(L"true", false)) + { + viewModeEnable = true; + r = pEditArea->SetViewModeEnabled(viewModeEnable); + } + } + + if (pControl->GetElement(L"normalBGBitmapPath", elementString)) + { + Bitmap* pressedBGBitmap = null; + pressedBGBitmap = LoadBitmapN(elementString); + if (pressedBGBitmap != null) + { + r = pEditArea->SetBackgroundBitmap(EDIT_STATUS_NORMAL, *pressedBGBitmap); + delete pressedBGBitmap; + } + } + + if (pControl->GetElement(L"disabledBGBitmapPath", elementString)) + { + Bitmap* disalbedBGBitmap = null; + disalbedBGBitmap = LoadBitmapN(elementString); + if (disalbedBGBitmap != null) + { + r = pEditArea->SetBackgroundBitmap(EDIT_STATUS_DISABLED, *disalbedBGBitmap); + delete disalbedBGBitmap; + } + } + + if (pControl->GetElement(L"highlightedBGBitmapPath", elementString)) + { + Bitmap* highlightedBGBitmap = null; + highlightedBGBitmap = LoadBitmapN(elementString); + if (highlightedBGBitmap != null) + { + r = pEditArea->SetBackgroundBitmap(EDIT_STATUS_HIGHLIGHTED, *highlightedBGBitmap); + delete highlightedBGBitmap; + } + } + + if (pControl->GetElement(L"pressedBGBitmapPath", elementString)) + { + Bitmap* pressedBGBitmap = null; + pressedBGBitmap = LoadBitmapN(elementString); + if (pressedBGBitmap != null) + { + r = pEditArea->SetBackgroundBitmap(EDIT_STATUS_PRESSED, *pressedBGBitmap); + delete pressedBGBitmap; + } + } + + if (pControl->GetElement(L"normalColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"normalColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditArea->SetColor(EDIT_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"pressedColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"pressedColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditArea->SetColor(EDIT_STATUS_PRESSED, color); + } + + if (pControl->GetElement(L"highlightedColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"highlightedColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditArea->SetColor(EDIT_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"disabledColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"disabledColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditArea->SetColor(EDIT_STATUS_DISABLED, color); + } + + opacity = EDIT_COLOR_OPACITY; + if (pControl->GetElement(L"guideTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditArea->SetGuideTextColor(color); + } + + if (pControl->GetElement(L"normalTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditArea->SetTextColor(EDIT_TEXT_COLOR_NORMAL, color); + } + + if (pControl->GetElement(L"disabledTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pEditArea->SetTextColor(EDIT_TEXT_COLOR_DISABLED, color); + } + + if (pControl->GetElement(L"highlightedTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditArea->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"linkTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditArea->SetTextColor(EDIT_TEXT_COLOR_LINK, color); + } + + if (pControl->GetElement(L"horizontalMargin", elementString)) + { + Base::Integer::Parse(elementString, horizontalMargin); + r = pEditArea->SetMargin(EDIT_MARGIN_TYPE_HORIZONTAL, horizontalMargin); + } + + if (pControl->GetElement(L"verticalMargin", elementString)) + { + Base::Integer::Parse(elementString, verticalMargin); + r = pEditArea->SetMargin(EDIT_MARGIN_TYPE_VERTICAL, verticalMargin); + } + + return pEditArea; + } +private: +}; // _EditAreaMaker + +_EditAreaRegister::_EditAreaRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"EditArea", _EditAreaMaker::GetInstance); +} +_EditAreaRegister::~_EditAreaRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"EditArea"); +} +static _EditAreaRegister EditAreaRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditCopyPasteEvent.cpp b/src/ui/controls/FUiCtrl_EditCopyPasteEvent.cpp new file mode 100644 index 0000000..357824c --- /dev/null +++ b/src/ui/controls/FUiCtrl_EditCopyPasteEvent.cpp @@ -0,0 +1,171 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditCopyPasteEvent.cpp + * @brief This is the implementation file for the _EditCopyPasteEvent class. + */ + + +// Includes +#include +#include +#include +#include "FUiCtrl_EditCopyPasteEvent.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen {namespace Ui {namespace Controls +{ +/** + * @class + * @brief This class is used as the argument to change event listener. + * + * This class is used as the argument to change event listener. When an change event is generated + * (such as when a button is pressed) the TextSelectionEvent calls TextSelectionEventListener's OnTextd + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the change ID. + */ +class _OSP_EXPORT_ _EditCopyPasteEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Object instance which contains this instance. + */ + _EditCopyPasteEventArg(CoreCopyPasteStatus status, CoreCopyPasteAction action); + + /** + * This is the class destructor. + * + */ + virtual ~_EditCopyPasteEventArg(void); + +// Access + CoreCopyPasteStatus GetStatus(void) const; + CoreCopyPasteAction GetAction(void) const; + + +// Attribute +private: + CoreCopyPasteStatus __status; + CoreCopyPasteAction __action; +}; // _EditCopyPasteEventArg + +_EditCopyPasteEventArg::_EditCopyPasteEventArg(CoreCopyPasteStatus status, CoreCopyPasteAction action) + : __status(status) + , __action(action) +{ + // Nothing. +} + +_EditCopyPasteEventArg::~_EditCopyPasteEventArg(void) +{ + // Nothing. +} + +CoreCopyPasteStatus +_EditCopyPasteEventArg::GetStatus(void) const +{ + return __status; +} + +CoreCopyPasteAction +_EditCopyPasteEventArg::GetAction(void) const +{ + return __action; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _EditCopyPasteEvent class Lifecycle +_EditCopyPasteEvent::_EditCopyPasteEvent(const _EditCopyPasteManager& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // Set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_EditCopyPasteEvent::~_EditCopyPasteEvent(void) +{ + // Nothing. +} + +_EditCopyPasteEvent* +_EditCopyPasteEvent::CreateInstanceN(const _EditCopyPasteManager& source) +{ + _EditCopyPasteEvent* pCoreCopyPasteEvent = new (std::nothrow) _EditCopyPasteEvent(source); + SysTryReturn(NID_UI_CTRL, pCoreCopyPasteEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pCoreCopyPasteEvent; + +CATCH: + delete pCoreCopyPasteEvent; + return null; +} + +const _EditCopyPasteManager* +_EditCopyPasteEvent::GetSource(void) const +{ + return __pSource; +} + +void +_EditCopyPasteEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _IEditCopyPasteEventListener* pCopyPasteEventListener = dynamic_cast <_IEditCopyPasteEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pCopyPasteEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n"); + + _EditCopyPasteEventArg* pCopyPasteEventArg = dynamic_cast <_EditCopyPasteEventArg*>(const_cast(&arg)); + SysTryReturnVoidResult(NID_UI_CTRL, pCopyPasteEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n"); + + CoreCopyPasteStatus status = pCopyPasteEventArg->GetStatus(); + CoreCopyPasteAction action = pCopyPasteEventArg->GetAction(); + + pCopyPasteEventListener->OnEditCopyPasteStatusChanged(status, action); + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_EditCopyPasteEvent::CreateCopyPasteEventArgN(CoreCopyPasteStatus status, CoreCopyPasteAction action) +{ + _EditCopyPasteEventArg* pEventArg = new (std::nothrow) _EditCopyPasteEventArg(status, action); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditCopyPasteManager.cpp b/src/ui/controls/FUiCtrl_EditCopyPasteManager.cpp new file mode 100644 index 0000000..8ee5bbe --- /dev/null +++ b/src/ui/controls/FUiCtrl_EditCopyPasteManager.cpp @@ -0,0 +1,1585 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditCopyPasteManager.cpp + * @brief This is the implementation file for the _EditCopyPasteManager class. + */ + +#include +#include +#include +#include +#include "FUi_Clipboard.h" +#include "FUi_ClipboardItem.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUiCtrl_EditCopyPasteManager.h" +#include "FUiCtrl_EditCopyPasteEvent.h" +#include "FUiCtrl_EditPresenter.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Frame.h" + + +#if defined(MULTI_WINDOW) +#include "FUi_EcoreEvas.h" +#include "FUi_Window.h" +using namespace Tizen::Ui; +#endif + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +const int COPY_PASTE_SELECT_ID = 231; +const int COPY_PASTE_SELECT_ALL_ID = 232; +const int COPY_PASTE_COPY_ID = 233; +const int COPY_PASTE_CUT_ID = 234; +const int COPY_PASTE_PASTE_ID = 235; +const int COPY_PASTE_CLIPBOARD_ID = 236; + +/** +* @class _EditCopyPasteHandler +* @brief This class defines the common behavior for the %_EditCopyPasteHandler. +* +*/ +class _EditCopyPasteHandler + : public _Window + , virtual public IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ + +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler); + + /** + * This is the default class destructor. + * + */ + virtual ~_EditCopyPasteHandler(void); + +// Operations +public: + static _EditCopyPasteHandler* CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler = true); + int GetHandlerCursorPosition(void) const; + void SetHandlerCursorPosition(int handlerCursorPos); + void SetLeftHandler(bool set); + void AdjustBounds(void); +#if defined(MULTI_WINDOW) + Bitmap* GetHandlerBitmap(void) const; +#endif + +// virtual function + virtual void OnDraw(void); + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool IsActivatedOnOpen(void) const; + +private: + _EditCopyPasteHandler(const _EditCopyPasteHandler& value); + _EditCopyPasteHandler& operator =(const _EditCopyPasteHandler& value); + +// Attribute +private: + _VisualElement* __pRoot; + Bitmap* __pHandlerBitmap; + Bitmap* __pHandlerPressedBitmap; + Point __touchPressedPoint; + _EditCopyPasteManager* __pCopyPasteManager; + bool __leftHandler; + int __handlerCursorPos; + bool __isTouchPressed; + bool __isReverseBitmap; +}; // _EditCopyPasteHandler + +#if defined(MULTI_WINDOW) +Bitmap* +_EditCopyPasteHandler::GetHandlerBitmap(void) const +{ + return __pHandlerBitmap; +} +#endif + +_EditCopyPasteHandler::_EditCopyPasteHandler(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler) + : __pRoot(null) + , __pHandlerBitmap(null) + , __pHandlerPressedBitmap(null) + , __touchPressedPoint(0, 0) + , __pCopyPasteManager(pCopyPasteManager) + , __leftHandler(leftHandler) + , __handlerCursorPos(handlerCursorPos) + , __isTouchPressed(false) + , __isReverseBitmap(false) +{ + AcquireHandle(); + + __pRoot = GetVisualElement(); + __pRoot->SetSurfaceOpaque(false); + + Point handlerPoint(point); + + if (singleHandler) + { + GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap); + handlerPoint.x = handlerPoint.x - (__pHandlerBitmap->GetWidth() / 2); + } + else + { + if (leftHandler) + { + GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap); + GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_LEFT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerPressedBitmap); + handlerPoint.x = handlerPoint.x - __pHandlerBitmap->GetWidth(); + } + else + { + GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap); + GET_BITMAP_CONFIG_N(EDIT::COPY_PASTE_ICON_RIGHT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerPressedBitmap); + } + } + + Rectangle bounds(handlerPoint.x, handlerPoint.y, __pHandlerBitmap->GetWidth(), __pHandlerBitmap->GetHeight()); +#if !defined(MULTI_WINDOW) + SetBounds(bounds); + _Window::Open(false); +#endif + _Edit* pEdit = __pCopyPasteManager->GetEdit(); + SysTryReturnVoidResult(NID_UI_CTRL, pEdit, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _EditPresenter* pEditPresenter = pEdit->GetPresenter(); + SysTryReturnVoidResult(NID_UI_CTRL, pEdit, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _Form* pParentForm = pEditPresenter->GetParentForm(); + if (pParentForm) + { + SetOwner(pParentForm); + } + else + { + _Form* pForm = null; + _Frame* pCurrentFrame = dynamic_cast <_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame()); + if (pCurrentFrame) + { + pForm = pCurrentFrame->GetCurrentForm(); + if (pForm) + { + SetOwner(pForm); + } + else + { + SetOwner(pCurrentFrame); + } + } + } +} + +_EditCopyPasteHandler::~_EditCopyPasteHandler(void) +{ + if (__pHandlerBitmap) + { + delete __pHandlerBitmap; + __pHandlerBitmap = null; + } + if (__pHandlerPressedBitmap) + { + delete __pHandlerPressedBitmap; + __pHandlerPressedBitmap = null; + } +} + +_EditCopyPasteHandler* +_EditCopyPasteHandler::CreateInstanceN(const Point& point, int handlerCursorPos, _EditCopyPasteManager* pCopyPasteManager, bool singleHandler, bool leftHandler) +{ + _EditCopyPasteHandler* pCopyPasteHandler = new (std::nothrow) _EditCopyPasteHandler(point, handlerCursorPos, pCopyPasteManager, singleHandler, leftHandler); + SysTryReturn(NID_UI_CTRL, pCopyPasteHandler != null, null, E_OUT_OF_MEMORY, "pContextMenu is null"); + +#if defined(MULTI_WINDOW) + Point handlerPoint(point); + Rectangle bounds(0, 0, 0, 0); + Bitmap* pHandlerBitmap = pCopyPasteHandler->GetHandlerBitmap(); + + result r = pCopyPasteHandler->CreateRootVisualElement(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCopyPasteHandler->SetActivationEnabled(false); + + if (singleHandler) + { + handlerPoint.x = handlerPoint.x - (pHandlerBitmap->GetWidth() / 2); + } + else + { + if (leftHandler) + { + handlerPoint.x = handlerPoint.x - pHandlerBitmap->GetWidth(); + } + } + + bounds.x = handlerPoint.x; + bounds.y = handlerPoint.y; + bounds.width = pHandlerBitmap->GetWidth(); + bounds.height = pHandlerBitmap->GetHeight(); + + pCopyPasteHandler->SetBounds(bounds); + + pCopyPasteHandler->Open(false); +#endif + + return pCopyPasteHandler; + +#if defined(MULTI_WINDOW) +CATCH: + pCopyPasteHandler->Close(); + delete pCopyPasteHandler; + + return null; +#endif +} + +int +_EditCopyPasteHandler::GetHandlerCursorPosition(void) const +{ + return __handlerCursorPos; +} + +void +_EditCopyPasteHandler::SetHandlerCursorPosition(int handlerCursorPos) +{ + __handlerCursorPos = handlerCursorPos; +} + +void +_EditCopyPasteHandler::SetLeftHandler(bool set) +{ + __leftHandler = set; +} + +void +_EditCopyPasteHandler::AdjustBounds(void) +{ + int previousCursorPos; + Rectangle cursorRect; + Rectangle rect = GetBounds(); + + previousCursorPos = __pCopyPasteManager->GetCursorPosition(); + __pCopyPasteManager->SetCursorPosition(__handlerCursorPos); + cursorRect = __pCopyPasteManager->GetCursorBounds(true); + __pCopyPasteManager->SetCursorPosition(previousCursorPos); + + rect.x = cursorRect.x; + rect.y = cursorRect.y + cursorRect.height; + + if (__leftHandler) + { + rect.x = rect.x - __pHandlerBitmap->GetWidth(); + } + + SetBounds(rect); +} + +void +_EditCopyPasteHandler::OnDraw(void) +{ + Canvas* pCanvas = GetCanvasN(); + if (pCanvas == null) + { + return; + } + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + if (__isTouchPressed) + { + if (__pHandlerPressedBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(pCanvas->GetBounds(), *__pHandlerPressedBitmap); + } + else + { + pCanvas->DrawBitmap(pCanvas->GetBounds(), *__pHandlerPressedBitmap); + } + } + else + { + if (__pHandlerBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(pCanvas->GetBounds(), *__pHandlerBitmap); + } + else + { + pCanvas->DrawBitmap(pCanvas->GetBounds(), *__pHandlerBitmap); + } + } + + delete pCanvas; +} + +bool +_EditCopyPasteHandler::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + __pCopyPasteManager->ReleaseCopyPastePopup(); + __touchPressedPoint = touchinfo.GetCurrentPosition(); + __isTouchPressed = true; + Invalidate(); + return true; +} + +bool +_EditCopyPasteHandler::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + __isTouchPressed = false; + __pCopyPasteManager->CreateCopyPastePopup(); + __pCopyPasteManager->Show(); + __pCopyPasteManager->SendTextBlockEvent(); + Invalidate(); + return true; +} + +bool +_EditCopyPasteHandler::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + int cursorPos; + int previousCursorPos; + Rectangle cursorRect; + Rectangle absCursorRect; + Rectangle rect = GetBounds(); + Point point = touchinfo.GetCurrentPosition(); + Point touchPoint; + + _Edit* pEdit = __pCopyPasteManager->GetEdit(); + SysTryReturn(NID_UI_CTRL, pEdit, false, E_INVALID_STATE, "[E_INVALID_STATE] pEdit is null.\n"); + + _EditPresenter* pEditPresenter = pEdit->GetPresenter(); + SysTryReturn(NID_UI_CTRL, pEditPresenter, false, E_INVALID_STATE, "[E_INVALID_STATE] pEditPresenter is null.\n"); + + if (__touchPressedPoint.x == point.x && __touchPressedPoint.y == point.y) + { + return true; + } + + previousCursorPos = __pCopyPasteManager->GetCursorPosition(); + __pCopyPasteManager->SetCursorPosition(__handlerCursorPos); + cursorRect = __pCopyPasteManager->GetCursorBounds(false); + absCursorRect = __pCopyPasteManager->GetCursorBounds(true); + touchPoint.x = cursorRect.x + (point.x - __touchPressedPoint.x); + touchPoint.y = cursorRect.y + cursorRect.height/2 + (point.y - __touchPressedPoint.y); + cursorPos = __pCopyPasteManager->GetCursorPositionAt(touchPoint); + + if (cursorPos == -1 || (!__pCopyPasteManager->CheckHandleBounds(Point(absCursorRect.x, absCursorRect.y + absCursorRect.height)))) + { + TextObject* pTextObject = pEditPresenter->GetTextObject(); + int curCursorLine = pTextObject->GetLineIndexAtTextIndex(__handlerCursorPos); + int totalLine = pTextObject->GetTotalLineCount(); + Rectangle editVisibleArea = __pCopyPasteManager->GetEditVisibleArea(); + + if (cursorPos != -1) + { + if (editVisibleArea.y <= absCursorRect.y) // DownSide + { + if (curCursorLine < totalLine - 1) + { + int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine); + int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1); + cursorPos = offset + firstTextIndex; + int textLength = pTextObject->GetTextLengthAt(curCursorLine+1); + if (offset > textLength) + { + cursorPos = firstTextIndex+textLength; + } + + if (cursorPos != -1 && __leftHandler) + { + int line = pTextObject->GetFirstDisplayLineIndex(); + pTextObject->SetFirstDisplayLineIndex(line+1); + __pCopyPasteManager->SetCursorPosition(cursorPos); + absCursorRect = __pCopyPasteManager->GetCursorBounds(true); + int firstDisplayY = pTextObject->GetFirstDisplayPositionY(); + int gapY = absCursorRect.y + absCursorRect.height - (editVisibleArea.y + editVisibleArea.height); + int tempMargin = 2; + if (gapY > 0) + { + pTextObject->SetFirstDisplayPositionY(firstDisplayY + gapY + tempMargin); + } + } + } + } + else + { + if (curCursorLine !=0 ) + { + int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine); + int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1); + cursorPos = offset + firstTextIndex; + int textLength = pTextObject->GetTextLengthAt(curCursorLine-1); + if (offset > textLength) + { + cursorPos = firstTextIndex+textLength; + } + + if (cursorPos != -1 && __leftHandler) + { + int line = pTextObject->GetFirstDisplayLineIndex(); + if (__leftHandler) + { + pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos); + } + else + { + pTextObject->SetFirstDisplayLineIndex(line-1); + } + } + } + } + } + else + { + if (pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) + { + if (point.x - __touchPressedPoint.x >= 0) // RightSide + { + if (__handlerCursorPos == pEditPresenter->GetTextLength()) + { + cursorPos = __handlerCursorPos; + } + else + { + cursorPos = __handlerCursorPos + 1; + + if (__leftHandler && (cursorPos == pEditPresenter->GetTextLength())) + { + cursorPos = __handlerCursorPos; + } + } + } + else //LeftSide + { + if (__handlerCursorPos != 0) + { + cursorPos = __handlerCursorPos - 1; + + if (__leftHandler) + { + pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos); + } + } + } + + if (point.y < 0 || (point.y > GetBounds().height)) + { + return true; + } + } + else + { + if (point.y - __touchPressedPoint.y >= 0) // DownSide + { + if (curCursorLine < totalLine - 1) + { + int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine); + int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1); + cursorPos = offset + firstTextIndex; + int textLength = pTextObject->GetTextLengthAt(curCursorLine+1); + if (offset > textLength) + { + cursorPos = firstTextIndex+textLength; + } + + if (cursorPos != -1 && __leftHandler) + { + int line = pTextObject->GetFirstDisplayLineIndex(); + if (__leftHandler) + { + pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos); + } + else + { + pTextObject->SetFirstDisplayLineIndex(line+1); + } + } + } + } + else //UpSide + { + if (curCursorLine !=0 ) + { + int offset = __handlerCursorPos - pTextObject->GetFirstTextIndexAt(curCursorLine); + int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1); + cursorPos = offset + firstTextIndex; + int textLength = pTextObject->GetTextLengthAt(curCursorLine-1); + if (offset > textLength) + { + cursorPos = firstTextIndex+textLength; + } + + if (!__leftHandler && cursorPos <= __pCopyPasteManager->GetHandlerCursorPosition(false)) + { + cursorPos = __pCopyPasteManager->GetHandlerCursorPosition(false) + 1; + } + + if (cursorPos != -1 && __leftHandler) + { + int line = pTextObject->GetFirstDisplayLineIndex(); + if (__leftHandler) + { + pTextObject->SetFirstDisplayLineIndexFromTextIndex(cursorPos); + } + else + { + pTextObject->SetFirstDisplayLineIndex(line-1); + } + } + } + } + } + } + } + + if (cursorPos == -1 || __handlerCursorPos == cursorPos ||!__pCopyPasteManager->CheckHandlePosition(__leftHandler, cursorPos)) + { + __pCopyPasteManager->SetCursorPosition(previousCursorPos); + pEditPresenter->SetCursorChangedFlag(!__leftHandler); + return true; + } + + __pCopyPasteManager->SetCursorPosition(cursorPos); + + cursorRect = __pCopyPasteManager->GetCursorBounds(true); + + rect.x = cursorRect.x; + rect.y = cursorRect.y + cursorRect.height; + + if (__leftHandler) + { + rect.x = rect.x - __pHandlerBitmap->GetWidth(); + } + + __handlerCursorPos = cursorPos; + + SetBounds(rect); + + __pCopyPasteManager->RefreshBlock(true, __leftHandler); + + return true; +} + +bool +_EditCopyPasteHandler::IsActivatedOnOpen(void) const +{ + return false; +} + +_EditCopyPasteManager::_EditCopyPasteManager(_Edit& parenEdit) + : __pCopyPastePopup(null) + , __contextMenuAlign(CONTEXT_MENU_CORE_ALIGN_UP) + , __pCoreCopyPasteEvent(null) + , __pEdit(&parenEdit) + , __contextMenuHeight(0) + , __needToReleaseBlock(true) + , __isHandlerMoving(false) + , __editVisibleArea(0, 0, 0, 0) +{ + __pHandle[HANDLER_TYPE_LEFT] = null; + __pHandle[HANDLER_TYPE_RIGHT] = null; + + if (__pEdit->IsBlocked()) + { + CreateHandle(); + } +} + +_EditCopyPasteManager::~_EditCopyPasteManager(void) +{ + Release(); + + if (__pCoreCopyPasteEvent) + { + delete __pCoreCopyPasteEvent; + __pCoreCopyPasteEvent = null; + } +} + +void +_EditCopyPasteManager::Release(void) +{ + if (__pCopyPastePopup) + { + __pCopyPastePopup->Close(); + delete __pCopyPastePopup; + __pCopyPastePopup = null; + } + + if (__pHandle[HANDLER_TYPE_LEFT]) + { + __pHandle[HANDLER_TYPE_LEFT]->Close(); + delete __pHandle[HANDLER_TYPE_LEFT]; + __pHandle[HANDLER_TYPE_LEFT] = null; + } + + if (__pHandle[HANDLER_TYPE_RIGHT]) + { + __pHandle[HANDLER_TYPE_RIGHT]->Close(); + delete __pHandle[HANDLER_TYPE_RIGHT]; + __pHandle[HANDLER_TYPE_RIGHT] = null; + } +} + +void +_EditCopyPasteManager::ReleaseCopyPastePopup(void) +{ + if (__pCopyPastePopup) + { + __pCopyPastePopup->Close(); + delete __pCopyPastePopup; + __pCopyPastePopup = null; + } +} + +bool +_EditCopyPasteManager::IsCopyPastePopup(const _Control& control) const +{ + if (__pHandle[HANDLER_TYPE_LEFT] == &control) + { + return true; + } + + if (__pHandle[HANDLER_TYPE_RIGHT] == &control) + { + return true; + } + + if (__pCopyPastePopup == &control) + { + return true; + } + + return false; +} + +result +_EditCopyPasteManager::AddCopyPasteEventListener(const _IEditCopyPasteEventListener& listener) +{ + ClearLastResult(); + + if (__pCoreCopyPasteEvent == null) + { + __pCoreCopyPasteEvent = _EditCopyPasteEvent::CreateInstanceN(*this); + SysTryReturn(NID_UI_CTRL, __pCoreCopyPasteEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.\n"); + } + + return __pCoreCopyPasteEvent->AddListener(listener); +} + +result +_EditCopyPasteManager::SendCopyPasteEvent(CoreCopyPasteStatus status, CoreCopyPasteAction action) +{ + if (__pCoreCopyPasteEvent) + { + IEventArg* pCopyPasteEventArg = _EditCopyPasteEvent::CreateCopyPasteEventArgN(status, action); + SysTryReturn(NID_UI_CTRL, pCopyPasteEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pCoreCopyPasteEvent->Fire(*pCopyPasteEventArg); + } + + return E_SUCCESS; +} + +void +_EditCopyPasteManager::CreateCopyPastePopup(void) +{ + if (__pCopyPastePopup) + { + __pCopyPastePopup->Close(); + delete __pCopyPastePopup; + __pCopyPastePopup = null; + } + + Rectangle startRect; + Rectangle endRect; + Rectangle editAbsRect; + Rectangle editShowAreaAbsRect; + Rectangle commandButtonBounds; + Rectangle keypadBounds(0, 0, 0, 0); + bool keypadExist = false; + bool commandButtonExist = false; + Rectangle cursorRect = GetCursorBounds(true); + + int contextMenuHeight = 0; + int contextMenuTopMargin = 0; + int contextMenuBottomMargin = 0; + int contextMenuArrowHeight = 0; + int contextMenuLeftMargin = 0; + int contextMenuArrowWidth = 0; + int handlerHeight = 0; + bool isPasswordStyle = false; + if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) + { + isPasswordStyle = true; + } + + _ControlOrientation orientation = __pEdit->GetOrientation(); + + GET_SHAPE_CONFIG(EDIT::COPYPASTE_HANDLER_HEIGHT, orientation, handlerHeight); + + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ITEM_HEIGHT, orientation, contextMenuHeight); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_TOP_MARGIN, orientation, contextMenuTopMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::GRID_BOTTOM_MARGIN, orientation, contextMenuBottomMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::ARROW_HEIGHT, orientation, contextMenuArrowHeight); + GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_LEFT_MARGIN, orientation, contextMenuLeftMargin); + GET_SHAPE_CONFIG(CONTEXTMENU::ARROW_WIDTH, orientation, contextMenuArrowWidth); + + __contextMenuHeight = contextMenuHeight + contextMenuTopMargin + contextMenuBottomMargin + contextMenuArrowHeight; + if (__pEdit->IsClipped() == true && __pEdit->IsViewModeEnabled() == false && __pEdit->GetTextLength() > 0 && orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + __contextMenuHeight = __contextMenuHeight + contextMenuHeight; + } + + editAbsRect = __pEdit->GetAbsoluteBounds(); + _EditPresenter* pEditPresenter = __pEdit->GetPresenter(); + _Toolbar* pCommandButton = pEditPresenter->GetKeypadCommandButton(); + if (pCommandButton) + { + commandButtonBounds = pCommandButton->GetAbsoluteBounds(); + commandButtonExist = true; + } + __pEdit->GetKeypadBounds(keypadBounds); + Dimension screenSize(0, 0); + screenSize = _ControlManager::GetInstance()->GetScreenSize(); + if (keypadBounds.y != screenSize.height) + { + keypadExist = true; + } + + // Edit Show Area + { + editShowAreaAbsRect = editAbsRect; + + if (commandButtonExist) + { + if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > commandButtonBounds.y) + { + editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - commandButtonBounds.y); + } + } + else + { + if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > keypadBounds.y) + { + editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - keypadBounds.y); + } + } + __editVisibleArea = editShowAreaAbsRect; + } + Point copyPastePoint(0, 0); + __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_UP; + + if (__pEdit->IsBlocked()) + { + int start = -1; + int end = -1; + __pEdit->GetBlockRange(start, end); + if (start == -1 || end == -1) + { + SysLog(NID_UI_CTRL, "[EditCopyPasteManager] There is no blocked Range"); + return; + } + + __pEdit->CalculateAbsoluteCursorBounds(start, startRect); + __pEdit->CalculateAbsoluteCursorBounds(end, endRect); + if (startRect.x > endRect.x) + { + copyPastePoint.x = endRect.x + (startRect.x - endRect.x)/2; + } + else if (startRect.x < endRect.x) + { + copyPastePoint.x = startRect.x + (endRect.x - startRect.x)/2; + } + else + { + copyPastePoint.x = startRect.x; + } + //Both of handlers are located on the top of the Editor. + if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) < editShowAreaAbsRect.y)) + { + SysLog(NID_UI_CTRL, "Both of handlers are located on the top of the Editor.\n"); + PrintLog(copyPastePoint); + return; + } + //Both of handlers are located on the bottom of the Editor. + else if( ((startRect.y + startRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height ) && ((endRect.y + endRect.height) > editShowAreaAbsRect.y + editShowAreaAbsRect.height)) + { + SysLog(NID_UI_CTRL, "Both of handlers are located on the bottom of the Editor.\n"); + PrintLog(copyPastePoint); + return; + } + // Left handler is located on the top of the Editor and Right handler is located on the bottom of the Editor. + else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height))) + { + copyPastePoint.y = editShowAreaAbsRect.y + editShowAreaAbsRect.height/2; + + if (copyPastePoint.y < __contextMenuHeight) + { + __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN; + } + + } + // Left handler is located on the top of the Editor and Right handler is located on the Editor + else if ( ((startRect.y + startRect.height) < editShowAreaAbsRect.y) && ((endRect.y + endRect.height) < (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) ) + { + if ( (endRect.y + endRect.height + handlerHeight + __contextMenuHeight) < keypadBounds.y) + { + __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN; + copyPastePoint.y = endRect.y + endRect.height + handlerHeight; + } + else if (endRect.y - editShowAreaAbsRect.y > __contextMenuHeight) + { + copyPastePoint.y = editShowAreaAbsRect.y + __contextMenuHeight; + } + else if (endRect.y > __contextMenuHeight) + { + copyPastePoint.y = endRect.y; + } + else + { + SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n"); + PrintLog(copyPastePoint); + return; + } + } + // Left handler is located on the Editor and Right handler is located on the bottom of the Editor + else if ( ((startRect.y + startRect.height) > editShowAreaAbsRect.y) && ((endRect.y + endRect.height) > (editShowAreaAbsRect.y + editShowAreaAbsRect.height)) ) + { + if (__contextMenuHeight < startRect.y) + { + copyPastePoint.y = startRect.y; + } + else + { + copyPastePoint.y = startRect.y + (editShowAreaAbsRect.y + editShowAreaAbsRect.height - startRect.y)/2; + } + } + // There is a space on the top of the Editor. + else if (__contextMenuHeight < startRect.y) + { + copyPastePoint.y = startRect.y; + } + // There is a space on the bottom of the Editor. + else if ( keypadBounds.y > (endRect.y + endRect.height + handlerHeight + __contextMenuHeight)) + { + __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN; + + copyPastePoint.y = endRect.y + endRect.height + handlerHeight; + } + // There is no space on the top and bottom of the Editor. The Popup should be drawn on the center of the Editor. + else + { + if (endRect.y - startRect.y < __contextMenuHeight) + { + SysLog(NID_UI_CTRL, "There is no space to draw the copy&paste popup\n"); + PrintLog(copyPastePoint); + return; + } + copyPastePoint.y = startRect.y + __contextMenuHeight; + } + } + + else + { + Rectangle cursorRect; + int cursorPosition = GetCursorPosition(); + __pEdit->CalculateAbsoluteCursorBounds(cursorPosition, cursorRect); + copyPastePoint.x = cursorRect.x; + copyPastePoint.y = cursorRect.y; + if (copyPastePoint.y < __contextMenuHeight) + { + Rectangle cursorRect = GetCursorBounds(true); + + copyPastePoint.y += cursorRect.height; + __contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_DOWN; + } + } + + __pCopyPastePopup = _ContextMenu::CreateContextMenuN(copyPastePoint, CONTEXT_MENU_CORE_STYLE_GRID, __contextMenuAlign); + SysTryReturnVoidResult(NID_UI_CTRL, __pCopyPastePopup, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if ( __pEdit->GetTextLength() != 0 && !isPasswordStyle) + { + if (__pEdit->IsBlocked()) + { + String copyText; + String cutText; + + GET_STRING_CONFIG(IDS_COM_BODY_COPY, copyText); + GET_STRING_CONFIG(IDS_COM_BODY_CUT, cutText); + + __pCopyPastePopup->AddItem(copyText, COPY_PASTE_COPY_ID, null, null, null); + if (!__pEdit->IsViewModeEnabled()) + { + __pCopyPastePopup->AddItem(cutText, COPY_PASTE_CUT_ID, null, null, null); + } + } + else + { + String selectText; + String selectAllText; + + GET_STRING_CONFIG(IDS_COM_SK_SELECT, selectText); + GET_STRING_CONFIG(IDS_COM_BODY_SELECT_ALL, selectAllText); + + __pCopyPastePopup->AddItem(selectText, COPY_PASTE_SELECT_ID, null, null, null); + __pCopyPastePopup->AddItem(selectAllText, COPY_PASTE_SELECT_ALL_ID, null, null, null); + } + } + + if (__pEdit->IsClipped() == true) + { + if (!__pEdit->IsViewModeEnabled()) + { + String pasteText; + String clipboardText; + + GET_STRING_CONFIG(IDS_COM_BODY_PASTE, pasteText); + GET_STRING_CONFIG(IDS_COM_BODY_CLIPBOARD, clipboardText); + + __pCopyPastePopup->AddItem(pasteText, COPY_PASTE_PASTE_ID, null, null, null); + if (!isPasswordStyle) + { + __pCopyPastePopup->AddItem(clipboardText, COPY_PASTE_CLIPBOARD_ID, null, null, null); + } + } + } + + __pCopyPastePopup->AddActionEventListener(*this); + + return; +} + +void +_EditCopyPasteManager::PrintLog(const Point& point) +{ + Rectangle startRect; + Rectangle endRect; + Rectangle editAbsRect; + Rectangle keypadBounds; + Rectangle editShowAreaAbsRect; + Rectangle commandButtonBounds; + Rectangle formClientBounds(0, 0, 0, 0); + bool hasParentForm = false; + bool hasCommandButton = false; + Rectangle cursorRect = GetCursorBounds(true); + int indicatorHeight = 0; + + editAbsRect = __pEdit->GetAbsoluteBounds(); + _EditPresenter* pEditPresenter = __pEdit->GetPresenter(); + _Toolbar* pCommandButton = pEditPresenter->GetKeypadCommandButton(); + if (pCommandButton) + { + commandButtonBounds = pCommandButton->GetAbsoluteBounds(); + hasCommandButton = true; + } + _Form* pForm = pEditPresenter->GetParentForm(); + if (pForm) + { + formClientBounds = pForm->GetClientBounds(); + hasParentForm = true; + } + int start = -1; + int end = -1; + __pEdit->GetBlockRange(start, end); + if (start == -1 || end == -1) + { + SysLog(NID_UI_CTRL, "[EditCopyPasteManager] There is no blocked Range"); + return; + } + __pEdit->GetKeypadBounds(keypadBounds); + + if (pForm && pForm->IsIndicatorVisible()) + { + indicatorHeight = pForm->GetIndicatorBounds().height; + } + + { + editShowAreaAbsRect = editAbsRect; + if (indicatorHeight) + { + if (editShowAreaAbsRect.y < indicatorHeight) + { + editShowAreaAbsRect.y = indicatorHeight; + } + } + + if (hasCommandButton) + { + if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > commandButtonBounds.y) + { + editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - commandButtonBounds.y); + } + } + else + { + if (editShowAreaAbsRect.y + editShowAreaAbsRect.height > keypadBounds.y) + { + editShowAreaAbsRect.height -= (editShowAreaAbsRect.y + editShowAreaAbsRect.height - keypadBounds.y); + } + } + } + + __pEdit->CalculateAbsoluteCursorBounds(start, startRect); + __pEdit->CalculateAbsoluteCursorBounds(end, endRect); + + SysLog(NID_UI_CTRL, "copyPastePoint (x=%d), (y=%d)\n", point.x, point.y ); + SysLog(NID_UI_CTRL, "startRect (x=%d), (y=%d), (width=%d), (height=%d) \n", startRect.x, startRect.y ,startRect.width, startRect.height); + SysLog(NID_UI_CTRL, "endRect (x=%d), (y=%d), (width=%d), (height=%d) \n", endRect.x, endRect.y ,endRect.width, endRect.height); + SysLog(NID_UI_CTRL, "editAbsRect (x=%d), (y=%d), (width=%d), (height=%d) \n", editAbsRect.x, editAbsRect.y ,editAbsRect.width, editAbsRect.height); + SysLog(NID_UI_CTRL, "editShowAreaAbsRect (x=%d), (y=%d), (width=%d), (height=%d) \n", editShowAreaAbsRect.x, editShowAreaAbsRect.y ,editShowAreaAbsRect.width, editShowAreaAbsRect.height); + SysLog(NID_UI_CTRL, "keypadBounds (x=%d), (y=%d), (width=%d), (height=%d) \n", keypadBounds.x, keypadBounds.y ,keypadBounds.width, keypadBounds.height); + SysLog(NID_UI_CTRL, "commandButtonBounds (x=%d), (y=%d), (width=%d), (height=%d) \n", commandButtonBounds.x, commandButtonBounds.y ,commandButtonBounds.width, commandButtonBounds.height); + SysLog(NID_UI_CTRL, "formClientBounds (x=%d), (y=%d), (width=%d), (height=%d) \n", formClientBounds.x, formClientBounds.y ,formClientBounds.width, formClientBounds.height); + SysLog(NID_UI_CTRL, "contextMenuHeight = %d\n", __contextMenuHeight); +} + +void +_EditCopyPasteManager::CreateHandle(void) +{ + int start = -1; + int end = -1; + Rectangle startRect; + Rectangle endRect; + + __pEdit->GetBlockRange(start, end); + + __pEdit->CalculateAbsoluteCursorBounds(start, startRect); + __pEdit->CalculateAbsoluteCursorBounds(end, endRect); + + Point leftHandler(startRect.x, startRect.y + startRect.height); + Point rightHandler(endRect.x, endRect.y + endRect.height); + + __pHandle[HANDLER_TYPE_LEFT] = _EditCopyPasteHandler::CreateInstanceN(leftHandler, start, this, false, true); + __pHandle[HANDLER_TYPE_RIGHT] = _EditCopyPasteHandler::CreateInstanceN(rightHandler, end, this, false, false); +} + +void +_EditCopyPasteManager::Show(void) +{ + bool hasParentForm = false; + Rectangle formClientBounds(0, 0, 0, 0); + _EditPresenter* pEditPresenter = __pEdit->GetPresenter(); + + _Form* pForm = pEditPresenter->GetParentForm(); + if (pForm) + { + formClientBounds = pForm->GetClientBounds(); + hasParentForm = true; + } + + if (__pHandle[HANDLER_TYPE_LEFT] && __pHandle[HANDLER_TYPE_RIGHT]) + { + CheckVisibleState(true); + CheckVisibleState(false); + } + + if (__pCopyPastePopup) + { + __pCopyPastePopup->Open(); + __pCopyPastePopup->ReleaseTouchCapture(); + + _Control* pControl = __pCopyPastePopup->GetOwner(); + if (pControl) + { + pControl->SetInputEnableState(true); + } + } +} + +bool +_EditCopyPasteManager::CheckHandleBounds(const Point& point) +{ + bool hasCommandButton = false; + bool hasParentForm = false; + bool showCheck = true; + Rectangle commandButtonBounds(0, 0, 0, 0); + Rectangle formClientBounds(0, 0, 0, 0); + Rectangle editAbsBounds = __pEdit->GetAbsoluteBounds(); + _EditPresenter* pEditPresenter = __pEdit->GetPresenter(); + _Toolbar* pCommandButton = pEditPresenter->GetKeypadCommandButton(); + if (pCommandButton) + { + commandButtonBounds = pCommandButton->GetAbsoluteBounds(); + hasCommandButton = true; + } + _Form* pForm = pEditPresenter->GetParentForm(); + if (pForm) + { + formClientBounds = pForm->GetClientBounds(); + hasParentForm = true; + } + + if (editAbsBounds.x > point.x || point.x > (editAbsBounds.x + editAbsBounds.width)) + { + showCheck = false; + } + + if (editAbsBounds.y > point.y || point.y > (editAbsBounds.y + editAbsBounds.height)) + { + showCheck = false; + } + if (hasParentForm && (formClientBounds.y > point.y || point.y > (formClientBounds.y + formClientBounds.height))) + { + showCheck = false; + } + if (hasCommandButton && commandButtonBounds.Contains(point)) + { + showCheck = false; + } + return showCheck; +} + +bool +_EditCopyPasteManager::CheckHandlePosition(bool leftHandle, int cursorPosition) +{ + int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition(); + int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition(); + + if (leftHandle) + { + if (cursorPosition + 1 <= rightHandlerPosition) + { + return true; + } + else + { + return false; + } + } + else + { + if (cursorPosition >= leftHandlerPosition + 1) + { + return true; + } + else + { + return false; + } + } +} + +void +_EditCopyPasteManager::CheckVisibleState(bool leftHandle) +{ + if (leftHandle) + { + Point leftHandleXY(__pHandle[HANDLER_TYPE_LEFT]->GetAbsoluteBounds().x + __pHandle[HANDLER_TYPE_LEFT]->GetAbsoluteBounds().width, __pHandle[HANDLER_TYPE_LEFT]->GetAbsoluteBounds().y); + if (!CheckHandleBounds(leftHandleXY)) + { + __pHandle[HANDLER_TYPE_LEFT]->SetVisibleState(false); + } + else + { + __pHandle[HANDLER_TYPE_LEFT]->SetVisibleState(true); + __pHandle[HANDLER_TYPE_LEFT]->Open(); + } + } + else + { + Point rightHandleXY(__pHandle[HANDLER_TYPE_RIGHT]->GetAbsoluteBounds().x, __pHandle[HANDLER_TYPE_RIGHT]->GetAbsoluteBounds().y); + if (!CheckHandleBounds(rightHandleXY)) + { + __pHandle[HANDLER_TYPE_RIGHT]->SetVisibleState(false); + } + else + { + __pHandle[HANDLER_TYPE_RIGHT]->SetVisibleState(true); + __pHandle[HANDLER_TYPE_RIGHT]->Open(); + } + } +} + +void +_EditCopyPasteManager::HideHandle(void) +{ + __pEdit->ReleaseTextBlock(); + if (__pHandle[HANDLER_TYPE_LEFT]) + { + __pHandle[HANDLER_TYPE_LEFT]->SetVisibleState(false); + } + if (__pHandle[HANDLER_TYPE_RIGHT]) + { + __pHandle[HANDLER_TYPE_RIGHT]->SetVisibleState(false); + } +} + +void +_EditCopyPasteManager::RefreshBlock(bool changeVisibleState, bool isLeftHandle) +{ + int leftHandlerPos = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition(); + int rightHandlerPos = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition(); + + _EditPresenter* pEditPresenter = __pEdit->GetPresenter(); + SysTryReturnVoidResult(NID_UI_CTRL, pEditPresenter, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (!isLeftHandle) + { + pEditPresenter->ScrollPanelToCursorPosition(); + } + else + { + pEditPresenter->SetCursorPosition(leftHandlerPos); + pEditPresenter->ScrollPanelToCursorPosition(); + pEditPresenter->SetCursorPosition(rightHandlerPos); + } + __pEdit->SetBlockRange(leftHandlerPos, rightHandlerPos); + pEditPresenter->SetCursorChangedFlag(!isLeftHandle); + pEditPresenter->DrawText(); + + __pHandle[HANDLER_TYPE_LEFT]->AdjustBounds(); + __pHandle[HANDLER_TYPE_RIGHT]->AdjustBounds(); + + if (changeVisibleState) + { + CheckVisibleState(!isLeftHandle); + } +} + +Rectangle +_EditCopyPasteManager::GetCursorBounds(bool isAbsRect) const +{ + Rectangle cursorBounds; + + __pEdit->GetCursorBounds(isAbsRect, cursorBounds); + + return cursorBounds; +} + +int +_EditCopyPasteManager::GetCursorPositionAt(const Point& touchPoint) const +{ + return __pEdit->GetCursorPositionAt(touchPoint); +} + +result +_EditCopyPasteManager::SetCursorPosition(int position) +{ + return __pEdit->SetCursorPosition(position); +} + +int +_EditCopyPasteManager::GetCursorPosition(void) const +{ + return __pEdit->GetCursorPosition(); +} + +int +_EditCopyPasteManager::GetHandlerCursorPosition(bool rightHandler) const +{ + return __pHandle[rightHandler]->GetHandlerCursorPosition(); +} + +void +_EditCopyPasteManager::SendTextBlockEvent(void) +{ + int start = -1; + int end = -1; + result r = E_SUCCESS; + + __pEdit->GetBlockRange(start, end); + if (start != -1 && end != -1) + { + r = __pEdit->SendTextBlockEvent(start, end); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } +} + +void +_EditCopyPasteManager::OnActionPerformed(const _Control& source, int actionId) +{ + _Clipboard* pClipBoard = _Clipboard::GetInstance(); + SysTryReturnVoidResult(NID_UI_CTRL, pClipBoard, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _EditPresenter* pEditPresenter = __pEdit->GetPresenter(); + + ReleaseCopyPastePopup(); + + switch (actionId) + { + case COPY_PASTE_SELECT_ID: + { + int cursorPos = GetCursorPosition(); + int start, end; + + __pEdit->GetWordPosition(cursorPos, start, end); + __pEdit->SetBlockRange(start, end); + SendTextBlockEvent(); + + Release(); + CreateHandle(); + CreateCopyPastePopup(); + Show(); + + __pEdit->Draw(); + } + break; + + case COPY_PASTE_SELECT_ALL_ID: + { + int textLength = __pEdit->GetTextLength(); + __pEdit->SetBlockRange(0, textLength); + SendTextBlockEvent(); + pEditPresenter->UpdateComponentInformation(); + + Release(); + CreateHandle(); + CreateCopyPastePopup(); + Show(); + + __pEdit->Draw(); + } + break; + + case COPY_PASTE_COPY_ID: + SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_COPY); + break; + + case COPY_PASTE_CUT_ID: + SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_CUT); + break; + + case COPY_PASTE_PASTE_ID: + SendCopyPasteEvent(CORE_COPY_PASTE_STATUS_HIDE, CORE_COPY_PASTE_ACTION_PASTE); + break; + + case COPY_PASTE_CLIPBOARD_ID: + __needToReleaseBlock = false; + pEditPresenter->SetKeypadClosedEventSkipped(true); + pClipBoard->ShowPopup(CLIPBOARD_DATA_TYPE_TEXT, *__pEdit); + break; + default: + break; + } + + return; +} + +void +_EditCopyPasteManager::ScrollText(int distance) +{ + _EditPresenter* pEditPresenter = __pEdit->GetPresenter(); + TextObject* pTextObject = pEditPresenter->GetTextObject(); + + int newFirstDisplayY = pTextObject->GetFirstDisplayPositionY(); + newFirstDisplayY += distance; + int moveLine = pTextObject->GetLineIndexAtPositionY(newFirstDisplayY); + pTextObject->SetFirstDisplayLineIndex(moveLine); + pTextObject->SetFirstDisplayPositionY(newFirstDisplayY); + + return; +} + +void +_EditCopyPasteManager::AdjustBounds(void) +{ + if (__pHandle[HANDLER_TYPE_LEFT]) + { + __pHandle[HANDLER_TYPE_LEFT]->AdjustBounds(); + } + if (__pHandle[HANDLER_TYPE_RIGHT]) + { + __pHandle[HANDLER_TYPE_RIGHT]->AdjustBounds(); + } + if (__pCopyPastePopup) + { + //not need + } +} + +bool +_EditCopyPasteManager::GetTextBlockReleaseFlag(void) const +{ + return __needToReleaseBlock; +} + +void +_EditCopyPasteManager::SetTextBlockReleaseFlag(bool enabled) +{ + __needToReleaseBlock = enabled; +} + +_Edit* +_EditCopyPasteManager::GetEdit(void) const +{ + return __pEdit; +} + +void +_EditCopyPasteManager::MoveHandler(HandlerMoveType moveType) +{ + if (!__pHandle[HANDLER_TYPE_RIGHT] || ! __pHandle[HANDLER_TYPE_LEFT]) + { + return; + } + + int leftHandlerPosition = __pHandle[HANDLER_TYPE_LEFT]->GetHandlerCursorPosition(); + int rightHandlerPosition = __pHandle[HANDLER_TYPE_RIGHT]->GetHandlerCursorPosition(); + int textLength = __pEdit->GetTextLength(); + Rectangle cursorBounds; + int newCursorPosition; + __pEdit->GetCursorBounds(false, cursorBounds); + Point cursorPoint(cursorBounds.x, cursorBounds.y); + + _EditPresenter* pEditPresenter = __pEdit->GetPresenter(); + TextObject* pTextObject = pEditPresenter->GetTextObject(); + + switch(moveType) + { + case HANDLER_MOVE_TYPE_LEFT: + if (leftHandlerPosition < rightHandlerPosition-1) + { + __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(--rightHandlerPosition); + RefreshBlock(false); + } + else + { + return; + } + break; + case HANDLER_MOVE_TYPE_UP: + cursorPoint.y -= cursorBounds.height/2; + newCursorPosition = GetCursorPositionAt(cursorPoint); + + if (newCursorPosition <= 0) + { + int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex()); + + if (curCursorLine !=0 ) + { + int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine); + int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine-1); + newCursorPosition = offset + firstTextIndex; + int textLength = pTextObject->GetTextLengthAt(curCursorLine-1); + if (offset > textLength) + { + newCursorPosition = firstTextIndex+textLength; + } + + if (leftHandlerPosition >= newCursorPosition) + { + newCursorPosition = leftHandlerPosition + 1; + } + } + } + + if (newCursorPosition >= 0 && leftHandlerPosition < newCursorPosition) + { + __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition); + RefreshBlock(false); + } + else + { + return; + } + break; + case HANDLER_MOVE_TYPE_DOWN: + cursorPoint.y += cursorBounds.height + cursorBounds.height/2; + newCursorPosition = GetCursorPositionAt(cursorPoint); + + if (newCursorPosition < 0) + { + int curCursorLine = pTextObject->GetLineIndexAtTextIndex(pTextObject->GetCursorIndex()); + int totalLine = pTextObject->GetTotalLineCount(); + if (curCursorLine < totalLine - 1) + { + int offset = rightHandlerPosition - pTextObject->GetFirstTextIndexAt(curCursorLine); + int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine+1); + newCursorPosition = offset + firstTextIndex; + int textLength = pTextObject->GetTextLengthAt(curCursorLine+1); + if (offset > textLength) + { + newCursorPosition = firstTextIndex+textLength; + + } + } + else if (curCursorLine == totalLine - 1) + { + int firstTextIndex = pTextObject->GetFirstTextIndexAt(curCursorLine); + int textLength = pTextObject->GetTextLengthAt(curCursorLine); + newCursorPosition = firstTextIndex + textLength; + } + } + + if (newCursorPosition >= 0) + { + __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(newCursorPosition); + RefreshBlock(false); + } + else + { + return; + } + break; + case HANDLER_MOVE_TYPE_RIGHT: + if (textLength >= rightHandlerPosition+1) + { + __pHandle[HANDLER_TYPE_RIGHT]->SetHandlerCursorPosition(++rightHandlerPosition); + RefreshBlock(false); + } + else + { + return; + } + break; + default: + break; + } + + CheckVisibleState(true); + + ReleaseCopyPastePopup(); + __isHandlerMoving = true; + return; +} + +bool +_EditCopyPasteManager::IsHandlerMovingEnabled(void) const +{ + return __isHandlerMoving; +} + +void +_EditCopyPasteManager::SetHandlerMovingEnabled(bool enabled) +{ + __isHandlerMoving = enabled; +} + +Rectangle +_EditCopyPasteManager::GetEditVisibleArea(void) const +{ + return __editVisibleArea; +} + + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditDate.cpp b/src/ui/controls/FUiCtrl_EditDate.cpp new file mode 100644 index 0000000..f3ea071 --- /dev/null +++ b/src/ui/controls/FUiCtrl_EditDate.cpp @@ -0,0 +1,981 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditDate.cpp + * @brief This is the implementation file for the _EditDate class. + */ + +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_EditDate.h" +#include "FUiCtrl_EditDatePresenter.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_DateTimeUtils.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_EditDate); + +_EditDate::_EditDate(void) + : __pEditDatePresenter(null) + , __pDateChangeEvent(null) + , __pDateTimeBar(null) + , __absoluteBounds(Rectangle()) + , __title() + , __pAccessibilityTitleElement(null) + , __pAccessibilityYearElement(null) + , __pAccessibilityMonthElement(null) + , __pAccessibilityDayElement(null) +{ +} + +_EditDate::~_EditDate(void) +{ + delete __pDateTimeBar; + __pDateTimeBar = null; + + delete __pEditDatePresenter; + __pEditDatePresenter = null; + + if (__pDateChangeEvent != null) + { + delete __pDateChangeEvent; + __pDateChangeEvent = null; + } + + if (__pAccessibilityTitleElement) + { + __pAccessibilityTitleElement->Activate(false); + __pAccessibilityTitleElement = null; + } + if (__pAccessibilityYearElement) + { + __pAccessibilityYearElement->Activate(false); + __pAccessibilityYearElement = null; + } + if (__pAccessibilityMonthElement) + { + __pAccessibilityMonthElement->Activate(false); + __pAccessibilityMonthElement = null; + } + if (__pAccessibilityDayElement) + { + __pAccessibilityDayElement->Activate(false); + __pAccessibilityDayElement = null; + } +} + +_EditDate* +_EditDate::CreateEditDateN(const String& title) +{ + result r = E_SUCCESS; + + _AccessibilityContainer* pContainer = null; + + _EditDate* pEditDate = new (std::nothrow) _EditDate; + SysTryReturn(NID_UI_CTRL, pEditDate, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pEditDate->GetVisualElement()->SetSurfaceOpaque(false); + + pEditDate->__pEditDatePresenter = _EditDatePresenter::CreateInstanceN(*pEditDate, title); + + r = pEditDate->CreateDateTimeBar(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pEditDate->__pEditDatePresenter->Initialize(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pEditDate->__pEditDatePresenter, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pEditDate->__pEditDatePresenter->SetCurrentDate(); + + if (title.IsEmpty() != true) + { + pEditDate->__title = title; + } + + pEditDate->SetResizable(false); + + pContainer = pEditDate->GetAccessibilityContainer(); + + if (pContainer) + { + pContainer->Activate(true); + } + + pEditDate->AcquireHandle(); + + return pEditDate; + +CATCH: + delete pEditDate; + return null; +} + +result +_EditDate::CreateDateTimeBar(void) +{ + result r = E_SUCCESS; + + __pDateTimeBar = _DateTimeBar::CreateDateTimeBarN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (__pDateTimeBar != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pDateTimeBar->AddActionEventListener(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pDateTimeBar->AddDateTimeChangeEventListener(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete __pDateTimeBar; + return r; +} + +result +_EditDate::AddDateChangeEventListener(const _IDateTimeChangeEventListener& listener) +{ + if (__pDateChangeEvent == null) + { + __pDateChangeEvent = new (std::nothrow) _DateTimeChangeEvent(*this); + SysTryReturn(NID_UI_CTRL, (__pDateChangeEvent != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + } + + result r = __pDateChangeEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_EditDate::RemoveDateChangeEventListener(const _IDateTimeChangeEventListener& listener) +{ + result r = E_OBJ_NOT_FOUND; + + if (__pDateChangeEvent) + { + r = __pDateChangeEvent->RemoveListener(listener); + } + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +_EditDate::SetDate(const DateTime& date) +{ + SetProperty("date", Variant(date)); + return; +} + +result +_EditDate::SetPropertyDate(const Variant& date) +{ + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + __pEditDatePresenter->SetDate(date.ToDateTime()); + + UpdateAccessibilityElement(); + return E_SUCCESS; +} + +DateTime +_EditDate::GetDate(void) const +{ + Variant date = GetProperty("date"); + + return date.ToDateTime(); +} + +Variant +_EditDate::GetPropertyDate(void) const +{ + DateTime date; + + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + date = __pEditDatePresenter->GetDate(); + + return Variant(date); +} + +result +_EditDate::SetDay(int day) +{ + result r = E_SUCCESS; + + SetProperty("day", Variant(day)); + + r = GetLastResult(); + + return r; +} + +result +_EditDate::SetPropertyDay(const Variant& day) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + r = __pEditDatePresenter->SetDay(day.ToInt()); + + if (r == E_SUCCESS) + { + UpdateAccessibilityElement(); + } + + return r; +} + +int +_EditDate::GetDay(void) const +{ + Variant day = GetProperty("day"); + + return day.ToInt(); +} + +Variant +_EditDate::GetPropertyDay(void) const +{ + int day = -1; + + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + day = __pEditDatePresenter->GetDay(); + + return Variant(day); +} + +result +_EditDate::SetMonth(int month) +{ + result r = E_SUCCESS; + + SetProperty("month", Variant(month)); + + r = GetLastResult(); + + return r; +} + +result +_EditDate::SetPropertyMonth(const Variant& month) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + r = __pEditDatePresenter->SetMonth(month.ToInt()); + + if (r == E_SUCCESS) + { + UpdateAccessibilityElement(); + } + + return r; +} + +int +_EditDate::GetMonth(void) const +{ + Variant month = GetProperty("month"); + + return month.ToInt(); +} + +Variant +_EditDate::GetPropertyMonth(void) const +{ + int month = -1; + + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + month = __pEditDatePresenter->GetMonth(); + + return Variant(month); +} + +result +_EditDate::SetYear(int year) +{ + result r = E_SUCCESS; + + SetProperty("year", Variant(year)); + + r = GetLastResult(); + + return r; +} + +result +_EditDate::SetPropertyYear(const Variant& year) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + r = __pEditDatePresenter->SetYear(year.ToInt()); + + if (r == E_SUCCESS) + { + UpdateAccessibilityElement(); + } + + return r; +} + +int +_EditDate::GetYear(void) const +{ + Variant year = GetProperty("year"); + + return year.ToInt(); +} + +Variant +_EditDate::GetPropertyYear(void) const +{ + int year = -1; + + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + year = __pEditDatePresenter->GetYear(); + + return Variant(year); +} + +void +_EditDate::SetCurrentDate(void) +{ + SysTryReturnVoidResult(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + __pEditDatePresenter->SetCurrentDate(); + + UpdateAccessibilityElement(); + + return; +} + +void +_EditDate::SetDatePickerEnabled(bool enable) +{ + SetProperty("datePickerEnabled", Variant(enable)); + return; +} + +result +_EditDate::SetPropertyDatePickerEnabled(const Variant& enable) +{ + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + __pEditDatePresenter->SetDatePickerEnabled(enable.ToBool()); + + return E_SUCCESS; +} + +bool +_EditDate::IsDatePickerEnabled(void) const +{ + Variant enable = GetProperty("datePickerEnabled"); + + return enable.ToBool(); +} + +Variant +_EditDate::GetPropertyDatePickerEnabled(void) const +{ + bool enable = false; + + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + enable = __pEditDatePresenter->IsDatePickerEnabled(); + + return Variant(enable); +} + +result +_EditDate::SetYearRange(int minYear, int maxYear) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (maxYear >= DATETIME_YEAR_MIN && maxYear <= DATETIME_YEAR_MAX), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] maxYear(%d) must be greater than or equal to %d and less than or equal to %d.", + maxYear, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX); + + SysTryReturn(NID_UI_CTRL, (minYear >= DATETIME_YEAR_MIN && minYear <= DATETIME_YEAR_MAX), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] minYear(%d) must be greater than or equal to %d and less than or equal to %d.", + minYear, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX); + + SysTryReturn(NID_UI_CTRL, (maxYear >= minYear), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] maxYear(%d) must be greater than or equal to minYear(%d).", maxYear, minYear); + + Variant oldMinYear = GetPropertyMinYearRange(); + + r = SetPropertyMinYearRange(Variant(minYear)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetPropertyMaxYearRange(Variant(maxYear)); + + if (IsFailed(r)) + { + SetPropertyMinYearRange(oldMinYear); + } + + return r; +} + +result +_EditDate::SetMinYearRange(int minYear) +{ + result r = E_SUCCESS; + + r = SetProperty("minYearRange", Variant(minYear)); + + return r; +} + +result +_EditDate::SetMaxYearRange(int maxYear) +{ + result r = E_SUCCESS; + + r = SetProperty("maxYearRange", Variant(maxYear)); + + return r; +} + +result +_EditDate::SetPropertyMinYearRange(const Variant& minYear) +{ + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + return __pEditDatePresenter->SetMinYear(minYear.ToInt()); +} + +result +_EditDate::SetPropertyMaxYearRange(const Variant& maxYear) +{ + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + return __pEditDatePresenter->SetMaxYear(maxYear.ToInt()); +} + +result +_EditDate::GetYearRange(int& minYear, int& maxYear) const +{ + result r = E_SUCCESS; + + minYear = GetMinYearRange(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + maxYear = GetMaxYearRange(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +_EditDate::GetMinYearRange(void) const +{ + Variant minYear = GetProperty("minYearRange"); + + return minYear.ToInt(); +} + +int +_EditDate::GetMaxYearRange(void) const +{ + Variant maxYear = GetProperty("maxYearRange"); + + return maxYear.ToInt(); +} + +Variant +_EditDate::GetPropertyMinYearRange(void) const +{ + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + int minYear = 0; + + minYear = __pEditDatePresenter->GetMinYear(); + + return Variant(minYear); +} + +Variant +_EditDate::GetPropertyMaxYearRange(void) const +{ + SysTryReturn(NID_UI_CTRL, (__pEditDatePresenter != null), Variant(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + int maxYear = 0; + + maxYear = __pEditDatePresenter->GetMaxYear(); + + return Variant(maxYear); +} + +result +_EditDate::CalculateDateTimeBarPosition(void) +{ + result r = E_SUCCESS; + Rectangle absoluteBounds; + Rectangle parentBounds; + Rectangle frameBounds; + + absoluteBounds = GetAbsoluteBounds(); + + _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get frame instance."); + + _Form* pForm = pFrame->GetCurrentForm(); + SysTryReturn(NID_UI_CTRL, pForm != null, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get form instance."); + + parentBounds = pForm->GetClientBounds(); + frameBounds = pFrame->GetAbsoluteBounds(); + + int dateTimeBarHeight = 0; + GET_SHAPE_CONFIG(DATETIMEBAR::ITEM_HEIGHT, GetOrientation(), dateTimeBarHeight); + + Rectangle parentWindowBounds = GetParentWindowBounds(); + int bottomMargin = 0; + // DateTimeBar top margin can be used as Editdate's bottom margin. + GET_SHAPE_CONFIG(DATETIMEBAR::TOP_MARGIN, GetOrientation(), bottomMargin); + + int bottomPosition = 0; + bottomPosition = absoluteBounds.y + absoluteBounds.height + bottomMargin + dateTimeBarHeight; + + GetDateTimeBar()->SetParentWindowBounds(parentWindowBounds); + + if (bottomPosition > frameBounds.y + parentBounds.y + parentBounds.height) + { + r = GetDateTimeBar()->SetPositionAndAlignment(Point(parentWindowBounds.x, absoluteBounds.y), DATETIME_BAR_ALIGN_UP); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = GetDateTimeBar()->SetPositionAndAlignment(Point(parentWindowBounds.x, absoluteBounds.y + absoluteBounds.height + bottomMargin), DATETIME_BAR_ALIGN_DOWN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __absoluteBounds = absoluteBounds; + + return r; +} + +void +_EditDate::OnDraw(void) +{ + if (GetDateTimeBar() != null) + { + CalculateDateTimeBarPosition(); + } + + __pEditDatePresenter->Draw(); + return; +} + +result +_EditDate::OnAttachedToMainTree(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return E_SUCCESS; + } + + Rectangle dayBounds = __pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_DAY); + Rectangle monthBounds = __pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_MONTH); + Rectangle yearBounds = __pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_YEAR); + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer) + { + + if (__pAccessibilityTitleElement == null) + { + __pAccessibilityTitleElement = new _AccessibilityElement(true); + __pAccessibilityTitleElement->SetBounds(GetBounds()); + __pAccessibilityTitleElement->SetTrait(ACCESSIBILITY_TRAITS_NONE); + pContainer->AddElement(*__pAccessibilityTitleElement); + } + + if (__pAccessibilityYearElement == null && __pAccessibilityMonthElement == null && __pAccessibilityDayElement == null) + { + String hintText(L"Double tap to edit"); + + __pAccessibilityYearElement = new _AccessibilityElement(true); + __pAccessibilityYearElement->SetBounds(yearBounds); + __pAccessibilityYearElement->SetTrait(ACCESSIBILITY_TRAITS_YEAR); + __pAccessibilityYearElement->SetHint(hintText); + + __pAccessibilityMonthElement = new _AccessibilityElement(true); + __pAccessibilityMonthElement->SetBounds(monthBounds); + __pAccessibilityMonthElement->SetTrait(ACCESSIBILITY_TRAITS_MONTH); + __pAccessibilityMonthElement->SetHint(hintText); + + __pAccessibilityDayElement = new _AccessibilityElement(true); + __pAccessibilityDayElement->SetBounds(dayBounds); + __pAccessibilityDayElement->SetTrait(ACCESSIBILITY_TRAITS_DAY); + __pAccessibilityDayElement->SetHint(hintText); + + switch (__pEditDatePresenter->GetLocaleDateFormat()) + { + case SETTING_DATE_FORMAT_DD_MM_YYYY: + pContainer->AddElement(*__pAccessibilityDayElement); + pContainer->AddElement(*__pAccessibilityMonthElement); + pContainer->AddElement(*__pAccessibilityYearElement); + break; + case SETTING_DATE_FORMAT_MM_DD_YYYY: + pContainer->AddElement(*__pAccessibilityMonthElement); + pContainer->AddElement(*__pAccessibilityDayElement); + pContainer->AddElement(*__pAccessibilityYearElement); + break; + case SETTING_DATE_FORMAT_YYYY_MM_DD: + pContainer->AddElement(*__pAccessibilityYearElement); + pContainer->AddElement(*__pAccessibilityMonthElement); + pContainer->AddElement(*__pAccessibilityDayElement); + break; + case SETTING_DATE_FORMAT_YYYY_DD_MM: + pContainer->AddElement(*__pAccessibilityYearElement); + pContainer->AddElement(*__pAccessibilityDayElement); + pContainer->AddElement(*__pAccessibilityMonthElement); + break; + default: + break; + } + + UpdateAccessibilityElement(); + } + } + return E_SUCCESS; +} + +void +_EditDate::OnBoundsChanged(void) +{ + __pEditDatePresenter->Initialize(); + + if (__pAccessibilityTitleElement) + { + __pAccessibilityTitleElement->SetBounds(__pEditDatePresenter->GetTitleBounds()); + } + if (__pAccessibilityYearElement) + { + __pAccessibilityYearElement->SetBounds(__pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_YEAR)); + } + if (__pAccessibilityMonthElement) + { + __pAccessibilityMonthElement->SetBounds(__pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_MONTH)); + } + if (__pAccessibilityDayElement) + { + __pAccessibilityDayElement->SetBounds(__pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_DAY)); + } + + return; +} + +void +_EditDate::OnChangeLayout(_ControlOrientation orientation) +{ + __pEditDatePresenter->OnChangeLayout(orientation); + + if (GetDateTimeBar() != null) + { + CalculateDateTimeBarPosition(); + GetDateTimeBar()->Close(); + } + + return; +} + +bool +_EditDate::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + Rectangle absoluteBounds = GetAbsoluteBounds(); + + if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height) + { + CalculateDateTimeBarPosition(); + } + + return __pEditDatePresenter->OnTouchPressed(source, touchinfo); +} + +bool +_EditDate::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pEditDatePresenter->OnTouchReleased(source, touchinfo); +} + +bool +_EditDate::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pEditDatePresenter->OnTouchCanceled(source, touchinfo); +} + +bool +_EditDate::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pEditDatePresenter->OnTouchMoved(source, touchinfo); +} + +void +_EditDate::OnTouchMoveHandled(const _Control& control) +{ + __pEditDatePresenter->OnTouchMoveHandled(control); + return; +} + +result +_EditDate::FireDateChangeEvent(_DateTimeChangeStatus status) +{ + SysTryReturn(NID_UI_CTRL, (__pDateChangeEvent != null), E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] The _DateChangeEvent instance is null."); + + _DateTimeChangeEventArg* pDateTimeEventArg = new (std::nothrow) _DateTimeChangeEventArg(status); + SysTryReturn(NID_UI_CTRL, pDateTimeEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pDateTimeEventArg->SetDate(GetYear(), GetMonth(), GetDay()); + + __pDateChangeEvent->Fire(*pDateTimeEventArg); + + return E_SUCCESS; +} + +void +_EditDate::OnDateTimeChanged(const _Control& source, int year, int month, int day, int hour, int minute) +{ + __pEditDatePresenter->Animate(); + Invalidate(); + FireDateChangeEvent(DATE_INTERNAL_CHANGE_SAVED); + return; +} + +void +_EditDate::OnDateTimeChangeCanceled(const _Control& source) +{ + Invalidate(); + + FireDateChangeEvent(DATE_INTERNAL_CHANGE_CANCELED); + return; +} + +void +_EditDate::OnActionPerformed(const Ui::_Control& source, int actionId) +{ + _DateTimeId boxId = __pEditDatePresenter->GetLastSelectedId(); + + if (boxId == DATETIME_ID_YEAR) + { + SetYear(actionId); + AdjustDay(actionId, GetMonth()); + } + else if (boxId == DATETIME_ID_MONTH) + { + SetMonth(actionId); + AdjustDay(GetYear(), actionId); + } + else if (boxId == DATETIME_ID_DAY) + { + SetDay(actionId); + } + + Invalidate(); + + return; +} + +void +_EditDate::AdjustDay(int year, int month) +{ + _DateTimeUtils dateTimeUtils; + int maxValue = dateTimeUtils.CalculateMaxDay(year, month); + + if (GetDay() > maxValue) + { + SetDay(maxValue); + } + + return; +} + +_DateTimeBar* +_EditDate::GetDateTimeBar(void) const +{ + return __pDateTimeBar; +} + +void +_EditDate::OnFontChanged(Font* pFont) +{ + __pEditDatePresenter->OnFontChanged(pFont); + + return; +} + +void +_EditDate::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pEditDatePresenter->OnFontInfoRequested(style, size); + + return; +} + +Rectangle +_EditDate::GetParentWindowBounds(void) const +{ + _Form* pForm = null; + _Window* pwindow = null; + _Control* pControlCore = GetParent(); + + Dimension dateTimeBarSize(0, 0); + GET_DIMENSION_CONFIG(DATETIMEBAR::DEFAULT_SIZE, GetOrientation(), dateTimeBarSize); + Rectangle parentWindowBounds(0, 0, dateTimeBarSize.width, dateTimeBarSize.height); + + while (true) + { + if (pControlCore == null) + { + SysLog(NID_UI_CTRL,"[E_SYSTEM] Parent window not found."); + + return parentWindowBounds; + } + + // If the parent is a Frame, then return the Form's bounds. + pForm = dynamic_cast<_Form*>(pControlCore); + if (pForm != null) + { + parentWindowBounds = pForm->GetBounds(); + break; + } + + pwindow = dynamic_cast<_Window*>(pControlCore); + + if (pwindow != null) + { + parentWindowBounds = pwindow->GetBounds(); + break; + } + + pControlCore = pControlCore->GetParent(); + } + + return parentWindowBounds; +} + +void +_EditDate::UpdateAccessibilityElement(void) +{ + String string; + String yearString; + String dayString; + String space(L" "); + + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + if (__pAccessibilityTitleElement == null) + { + return; + } + + if (__title.IsEmpty() == false) + { + string.Append(__title); + string.Append(L", "); + } + + yearString.Append(GetYear()); + dayString.Append(GetDay()); + String monthString = GetDateTimeBar()->GetMonthValue(GetMonth()).GetPointer(); + + switch (__pEditDatePresenter->GetLocaleDateFormat()) + { + case SETTING_DATE_FORMAT_DD_MM_YYYY: + string.Append(dayString.GetPointer()); + string.Append(space.GetPointer()); + string.Append(monthString.GetPointer()); + string.Append(space.GetPointer()); + string.Append(yearString.GetPointer()); + break; + case SETTING_DATE_FORMAT_MM_DD_YYYY: + string.Append(monthString.GetPointer()); + string.Append(space.GetPointer()); + string.Append(dayString.GetPointer()); + string.Append(space.GetPointer()); + string.Append(yearString.GetPointer()); + break; + case SETTING_DATE_FORMAT_YYYY_MM_DD: + string.Append(yearString.GetPointer()); + string.Append(space.GetPointer()); + string.Append(monthString.GetPointer()); + string.Append(space.GetPointer()); + string.Append(dayString.GetPointer()); + break; + case SETTING_DATE_FORMAT_YYYY_DD_MM: + string.Append(yearString.GetPointer()); + string.Append(space.GetPointer()); + string.Append(dayString.GetPointer()); + string.Append(space.GetPointer()); + string.Append(monthString.GetPointer()); + break; + default: + break; + } + + __pAccessibilityTitleElement->SetLabel(string); + __pAccessibilityDayElement->SetLabel(dayString); + __pAccessibilityMonthElement->SetLabel(monthString); + __pAccessibilityYearElement->SetLabel(yearString); + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditDateImpl.cpp b/src/ui/controls/FUiCtrl_EditDateImpl.cpp new file mode 100644 index 0000000..563165a --- /dev/null +++ b/src/ui/controls/FUiCtrl_EditDateImpl.cpp @@ -0,0 +1,506 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditDateImpl.cpp + * @brief This is the implementation file for the _EditDateImpl class. + */ + +#include +#include "FUi_UiBuilder.h" +#include "FUi_ResourceManager.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUiCtrl_EditDateImpl.h" +#include "FUiCtrl_DateTimeDefine.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ +_EditDateImpl::EditDateSizeInfo::EditDateSizeInfo(void) + : __isTitle(false) +{ +} + +void +_EditDateImpl::EditDateSizeInfo::SetTitleStyle(bool titleStyle) +{ + __isTitle = titleStyle; + return; +} + +Dimension +_EditDateImpl::EditDateSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Tizen::Graphics::Dimension dimension(0, 0); + + r = GET_DIMENSION_CONFIG(EDITDATE::DEFAULT_SIZE, orientation, dimension); + + SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] Propagating.", GetErrorMessage(r)); + return dimension; +} + +Dimension +_EditDateImpl::EditDateSizeInfo::GetDefaultMaximumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Tizen::Graphics::Dimension dimension(0, 0); + + r = GET_DIMENSION_CONFIG(EDITDATE::DEFAULT_SIZE, orientation, dimension); + + SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] Propagating.", GetErrorMessage(r)); + return dimension; +} + +_EditDateImpl::_EditDateImpl(EditDate* pPublic, _EditDate* pCore) + : _ControlImpl(pPublic, pCore) + , __pPublicDateChangeEvent(null) +{ + ClearLastResult(); +} + +_EditDateImpl::~_EditDateImpl(void) +{ + if (__pPublicDateChangeEvent) + { + delete __pPublicDateChangeEvent; + __pPublicDateChangeEvent = null; + } + + ClearLastResult(); +} + +_EditDateImpl* +_EditDateImpl::GetInstance(EditDate& editDate) +{ + return static_cast<_EditDateImpl*>(editDate._pControlImpl); +} + +const _EditDateImpl* +_EditDateImpl::GetInstance(const EditDate& editDate) +{ + return static_cast(editDate._pControlImpl); +} + +_EditDateImpl* +_EditDateImpl::CreateEditDateImplN(EditDate* pControl, const Point& point, const String& title) +{ + result r = E_SUCCESS; + Rectangle defaultSize; + bool isTitle = false; + + _EditDate* pCore = _EditDate::CreateEditDateN(title); + SysTryReturn(NID_UI_CTRL, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _EditDateImpl* pImpl = new (std::nothrow) _EditDateImpl(pControl, pCore); + + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddDateChangeEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_SHAPE_CONFIG(EDITDATE::WIDTH, pCore->GetOrientation(), defaultSize.width); + + GET_SHAPE_CONFIG(EDITDATE::HEIGHT, pCore->GetOrientation(), defaultSize.height); + + defaultSize.x = point.x; + defaultSize.y = point.y; + + r = pImpl->InitializeBoundsProperties(FUNC_SIZE_INFO(EditDate)(isTitle), defaultSize, pCore->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + ClearLastResult(); + + return pImpl; + +CATCH: + delete pImpl; + return null; +} + +const char* +_EditDateImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::EditDate"; +} + +const EditDate& +_EditDateImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +EditDate& +_EditDateImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _EditDate& +_EditDateImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_EditDate& +_EditDateImpl::GetCore(void) +{ + return static_cast <_EditDate&>(_ControlImpl::GetCore()); +} + +result +_EditDateImpl::AddDateChangeEventListener(IDateChangeEventListener& listener) +{ + ClearLastResult(); + + if (__pPublicDateChangeEvent == null) + { + __pPublicDateChangeEvent = new (std::nothrow) _PublicDateTimeChangeEvent(GetPublic()); + + SysTryReturn(NID_UI_CTRL, __pPublicDateChangeEvent, + E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + } + + result r = __pPublicDateChangeEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, "The IDateChangeEventListener instance already exists."); + + return r; +} + +result +_EditDateImpl::RemoveDateChangeEventListener(IDateChangeEventListener& listener) +{ + ClearLastResult(); + + result r = E_OBJ_NOT_FOUND; + + if (__pPublicDateChangeEvent) + { + r = __pPublicDateChangeEvent->RemoveListener(listener); + } + + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, "IDateChangeEventListener instance is not found."); + + return r; +} + +DateTime +_EditDateImpl::GetDate(void) const +{ + ClearLastResult(); + + Variant date = GetCore().GetPropertyDate(); + + return date.ToDateTime(); +} + +int +_EditDateImpl::GetDay(void) const +{ + ClearLastResult(); + + Variant day = GetCore().GetPropertyDay(); + + return day.ToInt(); +} + +int +_EditDateImpl::GetMonth(void) const +{ + ClearLastResult(); + + Variant month = GetCore().GetPropertyMonth(); + + return month.ToInt(); +} + +int +_EditDateImpl::GetYear(void) const +{ + ClearLastResult(); + + Variant year = GetCore().GetPropertyYear(); + + return year.ToInt(); +} + +void +_EditDateImpl::SetDate(const DateTime& date) +{ + ClearLastResult(); + + GetCore().SetPropertyDate(Variant(date)); + return; +} + +void +_EditDateImpl::SetCurrentDate(void) +{ + ClearLastResult(); + + GetCore().SetCurrentDate(); + return; +} + +result +_EditDateImpl::SetYear(int year) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (year >= DATETIME_YEAR_MIN && year <= DATETIME_YEAR_MAX), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. year (%d).", year); + + result r = GetCore().SetPropertyYear(Variant(year)); + + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_EditDateImpl::SetMonth(int month) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (month >= DATETIME_MONTH_MIN && month <= DATETIME_MONTH_MAX), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. month (%d).", month); + + result r = GetCore().SetPropertyMonth(Variant(month)); + + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_EditDateImpl::SetDay(int day) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (day >= DATETIME_DAY_MIN && day <= DATETIME_DAY_MAX), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. day (%d).", day); + + result r = GetCore().SetPropertyDay(Variant(day)); + + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +_EditDateImpl::SetDatePickerEnabled(bool enable) +{ + ClearLastResult(); + + GetCore().SetPropertyDatePickerEnabled(Variant(enable)); + return; +} + +bool +_EditDateImpl::IsDatePickerEnabled(void) const +{ + ClearLastResult(); + + Variant enable = GetCore().GetPropertyDatePickerEnabled(); + + return enable.ToBool(); +} + +result +_EditDateImpl::SetYearRange(int minYear, int maxYear) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (maxYear >= DATETIME_YEAR_MIN && maxYear <= DATETIME_YEAR_MAX), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] maxYear (%d) must be greater than or equal to %d and less than or equal to %d.", + maxYear, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX); + + SysTryReturn(NID_UI_CTRL, (minYear >= DATETIME_YEAR_MIN && minYear <= DATETIME_YEAR_MAX), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] minYear (%d) must be greater than or equal to %d and less than or equal to %d.", + minYear, DATETIME_YEAR_MIN, DATETIME_YEAR_MAX); + + SysTryReturn(NID_UI_CTRL, (maxYear >= minYear), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] maxYear (%d) must be greater than or equal to minYear (%d).", maxYear, minYear); + + Variant oldMinYear = GetCore().GetPropertyMinYearRange(); + + r = GetCore().SetPropertyMinYearRange(Variant(minYear)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetCore().SetPropertyMaxYearRange(Variant(maxYear)); + if (r != E_SUCCESS) + { + GetCore().SetPropertyMinYearRange(oldMinYear); + SysLogException(NID_UI_CTRL, r, "[%s] Propagating", GetErrorMessage(r)); + } + + return r; +} + +result +_EditDateImpl::GetYearRange(int& minYear, int& maxYear) const +{ + ClearLastResult(); + + Variant tempMinYear = GetCore().GetPropertyMinYearRange(); + Variant tempMaxYear = GetCore().GetPropertyMaxYearRange(); + + minYear = tempMinYear.ToInt(); + maxYear = tempMaxYear.ToInt(); + + return GetLastResult(); +} + +void +_EditDateImpl::OnDateTimeChanged(const _Control& source, int year, int month, int day, int hour, int minute) +{ + ClearLastResult(); + + if (__pPublicDateChangeEvent == null) + { + return; + } + + _PublicDateTimeChangeEventArg* pEventArg = new (std::nothrow) _PublicDateTimeChangeEventArg(DATE_PUBLIC_CHANGE_SAVED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pEventArg->SetDate(year, month, day); + pEventArg->SetTime(hour, minute); + __pPublicDateChangeEvent->Fire(*pEventArg); + + return; +} + +void +_EditDateImpl::OnDateTimeChangeCanceled(const _Control& source) +{ + ClearLastResult(); + + if (__pPublicDateChangeEvent == null) + { + return; + } + + _PublicDateTimeChangeEventArg* pEventArg = new (std::nothrow) _PublicDateTimeChangeEventArg(DATE_PUBLIC_CHANGE_CANCELED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pPublicDateChangeEvent->Fire(*pEventArg); + + return; +} + +class _EditDateMaker + : public _UiBuilderControlMaker +{ +public: + _EditDateMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){} + virtual ~_EditDateMaker(void){} + static _UiBuilderControlMaker* GetInstance(_UiBuilder* pUiBuilder) + { + _EditDateMaker* pEditDateMaker = new (std::nothrow) _EditDateMaker(pUiBuilder); + return pEditDateMaker; + } + +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + result r = E_SUCCESS; + Point point; + Rectangle rect; + Tizen::Base::String elementStringOne; + Tizen::Base::String elementStringTwo; + bool titleEnable = false; + + _UiBuilderControlLayout* pControlProperty = null; + EditDate* pEditDate = null; + + int tempMin = 0; + int tempMax = 0; + int temp = 0; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + point.x = rect.x; + point.y = rect.y; + if (pControl->GetElement(L"titleText", elementStringOne)) + { + titleEnable = true; + } + pEditDate = new (std::nothrow) EditDate; + if (pEditDate == null) + { + return null; + } + + if (titleEnable) + { + r = pEditDate->Construct(point, elementStringOne); + } + else + { + r = pEditDate->Construct(point); + } + + if (r != E_SUCCESS) + { + delete pEditDate; + pEditDate = null; + return null; + } + + if (pControl->GetElement(L"minYearRange", elementStringOne) && pControl->GetElement(L"maxYearRange", elementStringTwo)) + { + Base::Integer::Parse(elementStringOne, tempMin); + Base::Integer::Parse(elementStringTwo, tempMax); + + if (tempMin > tempMax) + { + temp = tempMin; + tempMin = tempMax; + tempMax = tempMin; + } + + r = pEditDate->SetYearRange(tempMin, tempMax); + } + + return pEditDate; + } +}; // _EditDateMaker + +_EditDateRegister::_EditDateRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"EditDate", _EditDateMaker::GetInstance); +} + +_EditDateRegister::~_EditDateRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"EditDate"); +} +static _EditDateRegister EditDateRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditDatePresenter.cpp b/src/ui/controls/FUiCtrl_EditDatePresenter.cpp new file mode 100644 index 0000000..52ea85b --- /dev/null +++ b/src/ui/controls/FUiCtrl_EditDatePresenter.cpp @@ -0,0 +1,1100 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditDatePresenter.cpp + * @brief This is the implementation file for the _EditDatePresenter class. + */ + +#include +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_EditDatePresenter.h" +#include "FUiCtrl_EditDate.h" +#include "FUiCtrl_DateTimeModel.h" +#include "FUiCtrl_DateTimeUtils.h" +#include "FUiControl.h" +#include "FUiAnim_VisualElement.h" +#include "FUiAnimVisualElementPropertyAnimation.h" +#include "FGrpColor.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Ui::Animations; + + +namespace Tizen { namespace Ui { namespace Controls +{ +_EditDatePresenter::_EditDatePresenter(void) + : __pEditDateTimeModel(null) + , __pEditDate(null) + , __dayBounds(Rectangle()) + , __monthBounds(Rectangle()) + , __yearBounds(Rectangle()) + , __titleBounds(Rectangle()) + , __datePickerEnabled(true) + , __selectedId(DATETIME_ID_NONE) + , __lastSelectedId(DATETIME_ID_NONE) + , __touchMoveHandled(false) + , __titleObject() + , __textObject() + , __pFont(null) + , __dividerLineWidth(0) + , __dividerLineHeight(0) + , __titleFontSize(0) + , __dateFontSize(0) + , __pContentProvider(null) + , __isAnimating(false) + , __isEditDateInitialized(false) +{ +} + +_EditDatePresenter::~_EditDatePresenter(void) +{ + __titleObject.RemoveAll(); + __textObject.RemoveAll(); + + delete __pEditDateTimeModel; + __pEditDateTimeModel = null; +} + +_EditDatePresenter* +_EditDatePresenter::CreateInstanceN(const _EditDate& editDate, const String& title) +{ + _EditDatePresenter* pEditDatePresenter = new (std::nothrow) _EditDatePresenter; + SysTryReturn(NID_UI_CTRL, pEditDatePresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pEditDatePresenter->__pEditDate = const_cast <_EditDate*>(&editDate); + + pEditDatePresenter->__pEditDateTimeModel = new (std::nothrow) _DateTimeModel; + SysTryCatch(NID_UI_CTRL, pEditDatePresenter->__pEditDateTimeModel, , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + pEditDatePresenter->SetTitle(title); + + return pEditDatePresenter; + +CATCH: + delete pEditDatePresenter; + return null; +} + +void +_EditDatePresenter::SetTitle(const String& title) +{ + __title = title; +} +result +_EditDatePresenter::Initialize(void) +{ + result r = E_SUCCESS; + int editDateHeight = 0; + int editDateWidth = 0; + int leftMargin = 0; + int editDateFontSize = 0; + int titledateMargin = 0; + int dateHeight = 0; + Rectangle bounds(0, 0, 0, 0); + + GET_SHAPE_CONFIG(EDITDATE::WIDTH, __pEditDate->GetOrientation(), editDateWidth); + GET_SHAPE_CONFIG(EDITDATE::HEIGHT, __pEditDate->GetOrientation(), editDateHeight); + GET_SHAPE_CONFIG(EDITDATE::DATE_FONT_SIZE, __pEditDate->GetOrientation(), editDateFontSize); + GET_SHAPE_CONFIG(EDITDATE::DATE_TEXT_LEFT_MARGIN, __pEditDate->GetOrientation(), leftMargin); + GET_FIXED_VALUE_CONFIG(EDITDATE::ITEM_DIVIDER_WIDTH, __pEditDate->GetOrientation(), __dividerLineWidth); + GET_SHAPE_CONFIG(EDITDATE::ITEM_DIVIDER_HEIGHT, __pEditDate->GetOrientation(), __dividerLineHeight); + GET_SHAPE_CONFIG(EDITDATE::TEXT_FONT_SIZE, __pEditDate->GetOrientation(), __titleFontSize); + GET_SHAPE_CONFIG(EDITDATE::DATE_FONT_SIZE, __pEditDate->GetOrientation(), __dateFontSize); + GET_SHAPE_CONFIG(EDITDATE::TITLE_DATE_MARGIN, __pEditDate->GetOrientation(), titledateMargin); + GET_SHAPE_CONFIG(EDITDATE::DATE_HEIGHT, __pEditDate->GetOrientation(), dateHeight); + GET_SHAPE_CONFIG(EDITDATE::TEXT_HEIGHT, __pEditDate->GetOrientation(), __titleBounds.height); + + if (__pEditDate->GetBounds().height > editDateHeight) + { + editDateHeight = __pEditDate->GetBounds().height; + } + + __pFont = __pEditDate->GetFallbackFont(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pFont != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__title.IsEmpty() == false) + { + __titleBounds.x = leftMargin; + __titleBounds.y = (editDateHeight - (__titleBounds.height + titledateMargin + dateHeight)) / 2; + __titleBounds.width = editDateWidth; + + bounds.y = __titleBounds.y + __titleBounds.height + titledateMargin; + + __dayBounds.height = dateHeight; + __monthBounds.height = dateHeight; + __yearBounds.height = dateHeight; + + if (!__isEditDateInitialized) + { + r = InitializeTitleObject(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __titleObject.SetBounds(__titleBounds); + } + else + { + __dayBounds.height = editDateHeight; + __monthBounds.height = editDateHeight; + __yearBounds.height = editDateHeight; + } + + int elementWidth = 0; + GET_SHAPE_CONFIG(EDITDATE::TEXT_ELEMENT_WIDTH, __pEditDate->GetOrientation(), elementWidth); + + __dayBounds.width = elementWidth; + __monthBounds.width = elementWidth; + __yearBounds.width = elementWidth; + + __dayBounds.x = 0; + __monthBounds.x = 0; + __yearBounds.x = 0; + + __dayBounds.y = bounds.y; + __monthBounds.y = bounds.y; + __yearBounds.y = bounds.y; + + if (!__isEditDateInitialized) + { + r = InitializeTextObject(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __isEditDateInitialized = true; + + CalculateAreaBounds(); + + return r; +} + +result +_EditDatePresenter::InitializeTitleObject(void) +{ + result r = E_SUCCESS; + + Color titleNormalColor; + + GET_COLOR_CONFIG(EDITDATE::TITLE_TEXT_NORMAL, titleNormalColor); + + r = __titleObject.Construct(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + TextSimple* pSimpleText = null; + + pSimpleText = new (std::nothrow)TextSimple((const_cast (__title.GetPointer())), __title.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __titleObject.AppendElement(*pSimpleText); + + __titleObject.SetForegroundColor(titleNormalColor, 0, __titleObject.GetTextLength()); + __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength()); + __titleObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __titleObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __titleObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + return r; +} + +result +_EditDatePresenter::InitializeTextObject(void) +{ + result r = E_SUCCESS; + + r = __textObject.Construct(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + TextSimple* pSimpleText = null; + + pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __textObject.AppendElement(*pSimpleText); + + __textObject.SetFont(__pFont, 0, __textObject.GetTextLength()); + __textObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __textObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __textObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + return r; +} + +int +_EditDatePresenter::GetLocaleDateFormat(void) const +{ + int localeDateFormat = -1; + int error = vconf_get_int(VCONFKEY_SETAPPL_DATE_FORMAT_INT, &localeDateFormat); + if (error == -1) + { + localeDateFormat = SETTING_DATE_FORMAT_DD_MM_YYYY; + } + + return localeDateFormat; +} + +DateTime +_EditDatePresenter::GetDate(void) const +{ + SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null."); + + DateTime date; + date.SetValue(GetYear(), GetMonth(), GetDay(), DATETIME_HOUR_MIN, DATETIME_MINUTE_MIN); + + return date; +} + +int +_EditDatePresenter::GetDay(void) const +{ + SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null."); + + return __pEditDateTimeModel->GetDay(); +} + +int +_EditDatePresenter::GetMonth(void) const +{ + SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null."); + + return __pEditDateTimeModel->GetMonth(); +} + +int +_EditDatePresenter::GetYear(void) const +{ + SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null."); + + return __pEditDateTimeModel->GetYear(); +} + +void +_EditDatePresenter::SetDate(const DateTime& date) +{ + SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null."); + + __pEditDateTimeModel->SetDateTime(date); + return; +} + +void +_EditDatePresenter::SetCurrentDate(void) +{ + SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null."); + + __pEditDateTimeModel->SetCurrentDateTime(); + return; +} + +result +_EditDatePresenter::SetYear(int year) +{ + SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null."); + + return __pEditDateTimeModel->SetYear(year); +} + +result +_EditDatePresenter::SetMonth(int month) +{ + SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null."); + + return __pEditDateTimeModel->SetMonth(month); +} + +result +_EditDatePresenter::SetDay(int day) +{ + SysAssertf((__pEditDateTimeModel != null), "The _EditDateTimeModel instance is null."); + + return __pEditDateTimeModel->SetDay(day); +} + +void +_EditDatePresenter::SetDatePickerEnabled(bool enable) +{ + __datePickerEnabled = enable; + return; +} + +bool +_EditDatePresenter::IsDatePickerEnabled(void) const +{ + return __datePickerEnabled; +} + +result +_EditDatePresenter::SetMinYear(int minYear) +{ + return __pEditDateTimeModel->SetMinYear(minYear); +} + +result +_EditDatePresenter::SetMaxYear(int maxYear) +{ + return __pEditDateTimeModel->SetMaxYear(maxYear); +} + +int +_EditDatePresenter::GetMinYear(void) const +{ + int minYear = 0; + int maxYear = 0; + + __pEditDateTimeModel->GetYearRange(minYear, maxYear); + + return minYear; +} + +int +_EditDatePresenter::GetMaxYear(void) const +{ + int minYear = 0; + int maxYear = 0; + + __pEditDateTimeModel->GetYearRange(minYear, maxYear); + + return maxYear; +} + +result +_EditDatePresenter::Draw(void) +{ + result r = E_SUCCESS; + + if (__isAnimating) + { + return E_SUCCESS; + } + + Canvas* pCanvas = __pEditDate->GetCanvasN(); + SysAssertf((pCanvas != null), "Failed to get canvas."); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + if (__title.IsEmpty() == false) + { + DrawTitle(*pCanvas); + } + + String monthString; + String yearString; + String dayString; + + _DateTimeUtils dateTimeUtils; + monthString = dateTimeUtils.GetMonthString(GetMonth()); + yearString.Format(10, L"%04d", GetYear()); + dayString.Format(10, L"%02d", GetDay()); + + CalculateAreaBounds(); + + r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_DAY), dayString); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_MONTH), monthString); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_YEAR), yearString); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawDividers(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pCanvas; + + return r; + +CATCH: + delete pCanvas; + return r; +} + +result +_EditDatePresenter::CalculateAreaBounds(void) +{ + result r = E_SUCCESS; + + if (GetLocaleDateFormat() == DATE_FORMAT_DDMMYYYY) + { + __monthBounds.x = __dayBounds.x + __dayBounds.width + __dividerLineWidth; + __yearBounds.x = __monthBounds.x + __monthBounds.width + __dividerLineWidth; + } + else if (GetLocaleDateFormat() == DATE_FORMAT_MMDDYYYY) + { + __dayBounds.x = __monthBounds.x + __monthBounds.width + __dividerLineWidth; + __yearBounds.x = __dayBounds.x + __dayBounds.width + __dividerLineWidth; + } + else if (GetLocaleDateFormat() == DATE_FORMAT_YYYYMMDD) + { + __monthBounds.x = __yearBounds.x + __yearBounds.width + __dividerLineWidth; + __dayBounds.x = __monthBounds.x + __monthBounds.width + __dividerLineWidth; + } + else if (GetLocaleDateFormat() == DATE_FORMAT_YYYYDDMM) + { + __dayBounds.x = __yearBounds.x + __yearBounds.width + __dividerLineWidth; + __monthBounds.x = __dayBounds.x + __dayBounds.width + __dividerLineWidth; + } + + return r; +} + +result +_EditDatePresenter::DrawTitle(Canvas& canvas) +{ + if (!__pEditDate->IsEnabled()) + { + Color titleDisabledColor; + GET_COLOR_CONFIG(EDITDATE::TITLE_TEXT_DISABLED, titleDisabledColor); + __titleObject.SetForegroundColor(titleDisabledColor, 0, __titleObject.GetTextLength()); + } + + (_FontImpl::GetInstance(*__pFont))->SetSize(__titleFontSize); + __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength()); + __titleObject.Draw(*_CanvasImpl::GetInstance(canvas)); + + return E_SUCCESS; +} + +result +_EditDatePresenter::DrawText(Canvas& canvas, const Rectangle& bounds, const String& text) +{ + Color textColor; + + if (!__pEditDate->IsEnabled()) + { + GET_COLOR_CONFIG(EDITDATE::TEXT_DISABLED, textColor); + } + else + { + GET_COLOR_CONFIG(EDITDATE::TEXT_NORMAL, textColor); + } + + _DateTimeId boxId = DATETIME_ID_NONE; + boxId = GetBoxIdFromPosition(Point(bounds.x, bounds.y)); + + if (boxId == __selectedId && boxId != DATETIME_ID_NONE) + { + GET_COLOR_CONFIG(EDITDATE::TEXT_PRESSED, textColor); + } + + Rectangle drawAreaBounds(0, 0, 0, 0); + drawAreaBounds = bounds; + + TextSimple* pSimpleText = null; + pSimpleText = new (std::nothrow)TextSimple((const_cast (text.GetPointer())), text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __textObject.RemoveAll(); + + (_FontImpl::GetInstance(*__pFont))->SetSize(__dateFontSize); + + __textObject.AppendElement(*pSimpleText); + + __textObject.SetFont(__pFont, 0, __textObject.GetTextLength()); + __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength()); + __textObject.SetBounds(drawAreaBounds); + __textObject.Draw(*_CanvasImpl::GetInstance(canvas)); + + return E_SUCCESS; +} + +result +_EditDatePresenter::DrawDividers(Canvas& canvas) +{ + result r = E_SUCCESS; + + int elementWidth = 0; + int editDateHeight = 0; + int dateHeight = 0; + + GET_SHAPE_CONFIG(EDITDATE::TEXT_ELEMENT_WIDTH, __pEditDate->GetOrientation(), elementWidth); + GET_SHAPE_CONFIG(EDITDATE::DATE_HEIGHT, __pEditDate->GetOrientation(), dateHeight); + GET_SHAPE_CONFIG(EDITDATE::HEIGHT, __pEditDate->GetOrientation(), editDateHeight); + + if (__pEditDate->GetBounds().height > editDateHeight) + { + editDateHeight = __pEditDate->GetBounds().height; + } + + Color dividerHalfLeftColor; + Color dividerHalfRightColor; + + GET_COLOR_CONFIG(EDITDATE::DIVIDER_HALF_LEFT, dividerHalfLeftColor); + GET_COLOR_CONFIG(EDITDATE::DIVIDER_HALF_RIGHT, dividerHalfRightColor); + + Rectangle bounds(0, 0, 0, 0); + + bounds.x = elementWidth; + + if (__title.IsEmpty() == false) + { + bounds.y = __dayBounds.y + ((dateHeight - __dividerLineHeight) / 2); + } + else + { + bounds.y = __dayBounds.y + ((editDateHeight - __dividerLineHeight) / 2); + } + + for (int divider = 0; divider < __dividerCount; divider++) + { + canvas.SetForegroundColor(dividerHalfLeftColor); + canvas.SetLineWidth(__dividerLineWidth / 2); + + r = canvas.DrawLine(Point(bounds.x, bounds.y), Point(bounds.x, bounds.y + __dividerLineHeight)); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + canvas.SetForegroundColor(dividerHalfRightColor); + canvas.SetLineWidth(__dividerLineWidth / 2); + + r = canvas.DrawLine(Point(bounds.x + 1, bounds.y), Point(bounds.x + 1, bounds.y + __dividerLineHeight)); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + bounds.x = bounds.x + elementWidth; + } + + return r; +} +_DateTimeId +_EditDatePresenter::GetBoxIdFromPosition(const Point& point) const +{ + _DateTimeId displayBoxId = DATETIME_ID_NONE; + + if (point.y < __dayBounds.y || point.y > __dayBounds.y + __dayBounds.height) + { + return displayBoxId; + } + + if (__dayBounds.Contains(point) == true) + { + displayBoxId = DATETIME_ID_DAY; + } + else if (__monthBounds.Contains(point) == true) + { + displayBoxId = DATETIME_ID_MONTH; + } + else if (__yearBounds.Contains(point) == true) + { + displayBoxId = DATETIME_ID_YEAR; + } + + return displayBoxId; +} + +Rectangle +_EditDatePresenter::GetDateAreaBounds(_DateTimeId id) const +{ + if (id == DATETIME_ID_DAY) + { + return __dayBounds; + } + else if (id == DATETIME_ID_MONTH) + { + return __monthBounds; + } + else if (id == DATETIME_ID_YEAR) + { + return __yearBounds; + } + else + { + return Rectangle(); + } +} + +Rectangle +_EditDatePresenter::GetTitleBounds(void) const +{ + return __titleBounds; +} + +void +_EditDatePresenter::SetLastSelectedId(_DateTimeId boxId) +{ + __lastSelectedId = boxId; + return; +} + +_DateTimeId +_EditDatePresenter::GetLastSelectedId(void) const +{ + return __lastSelectedId; +} + +void +_EditDatePresenter::OnFontChanged(Font* pFont) +{ + __pFont = pFont; + + if (__pEditDate->GetDateTimeBar() != null) + { + __pEditDate->GetDateTimeBar()->SetFont(*pFont); + } + + return; +} + +void +_EditDatePresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = FONT_STYLE_PLAIN; + size = __dateFontSize; + + return; +} + +void +_EditDatePresenter::OnChangeLayout(_ControlOrientation orientation) +{ + Dimension editDateSize; + + result r = E_SUCCESS; + + r = GET_DIMENSION_CONFIG(EDITDATE::DEFAULT_SIZE, orientation, editDateSize); + + if (r == E_SUCCESS && editDateSize != __pEditDate->GetSize()) + { + __pEditDate->SetResizable(true); + __pEditDate->SetSize(editDateSize); + __pEditDate->SetResizable(false); + } + + r = Initialize(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +bool +_EditDatePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + SysTryReturn(NID_UI_CTRL, IsDatePickerEnabled() == true, true, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. EditDate instance is disabled."); + + if (&source != __pEditDate) + { + return false; + } + + __touchMoveHandled = false; + + Point point = touchinfo.GetCurrentPosition(); + + _DateTimeId boxId = DATETIME_ID_NONE; + boxId = GetBoxIdFromPosition(point); + + if (boxId < DATETIME_ID_YEAR || boxId > DATETIME_ID_DAY) + { + __selectedId = DATETIME_ID_NONE; + return true; + } + + int minValue = -1; + int maxValue = -1; + int displayValue = -1; + + if (boxId == DATETIME_ID_DAY) + { + if (__pEditDate->GetDateTimeBar() != null) + { + _DateTimeUtils dateTimeUtils; + maxValue = dateTimeUtils.CalculateMaxDay(GetYear(), GetMonth()); + minValue = DATETIME_DAY_MIN; + displayValue = GetDay(); + } + } + else if (boxId == DATETIME_ID_MONTH) + { + minValue = DATETIME_MONTH_MIN; + maxValue = DATETIME_MONTH_MAX; + displayValue = GetMonth(); + } + else if (boxId == DATETIME_ID_YEAR) + { + minValue = GetMinYear(); + maxValue = GetMaxYear(); + displayValue = GetYear(); + } + + if (__pEditDate->GetDateTimeBar() != null) + { + if (__pEditDate->GetDateTimeBar()->GetItemCount() > 0) + { + __pEditDate->GetDateTimeBar()->RemoveAllItems(); + } + + result r = __pEditDate->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId); + if (r != E_SUCCESS) + { + __selectedId = DATETIME_ID_NONE; + return true; + } + } + + __selectedId = boxId; + + __pEditDate->Invalidate(); + + return true; +} + +bool +_EditDatePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + SysTryReturn(NID_UI_CTRL, IsDatePickerEnabled() == true, true, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. EditDate instance is disabled."); + + if (&source != __pEditDate) + { + return false; + } + + Point point = touchinfo.GetCurrentPosition(); + + _DateTimeId boxId = DATETIME_ID_NONE; + boxId = GetBoxIdFromPosition(point); + + if (boxId != __selectedId) + { + __selectedId = DATETIME_ID_NONE; + } + + SetLastSelectedId(__selectedId); + __selectedId = DATETIME_ID_NONE; + + __lastSelectedValue = ""; + _DateTimeUtils dateTimeUtils; + if (GetLastSelectedId() == DATETIME_ID_YEAR) + { + __lastSelectedValue.Format(10, L"%04d", GetYear()); + } + else if (GetLastSelectedId() == DATETIME_ID_MONTH) + { + __lastSelectedValue = dateTimeUtils.GetMonthString(GetMonth()); + } + else if (GetLastSelectedId() == DATETIME_ID_DAY) + { + __lastSelectedValue.Format(10, L"%02d", GetDay()); + } + + __pEditDate->Invalidate(); + + if (__pEditDate->GetDateTimeBar() != null && GetLastSelectedId() != DATETIME_ID_NONE) + { + Rectangle bounds(0, 0, 0, 0); + bounds = GetDateAreaBounds(GetLastSelectedId()); + Rectangle absoluteBounds(0, 0, 0, 0); + absoluteBounds = __pEditDate->GetAbsoluteBounds(); + bounds.x += absoluteBounds.x; + + __pEditDate->GetDateTimeBar()->CalculateArrowBounds(bounds); + __pEditDate->GetDateTimeBar()->SetVisibleState(true); + __pEditDate->GetDateTimeBar()->Open(); + } + + return true; +} + +bool +_EditDatePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pEditDate) + { + return false; + } + + __selectedId = DATETIME_ID_NONE; + + __pEditDate->Invalidate(); + + return true; +} + +bool +_EditDatePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pEditDate) + { + return false; + } + + Point touchPoint = touchinfo.GetCurrentPosition(); + + if (GetBoxIdFromPosition(touchPoint) != __selectedId) + { + __selectedId = DATETIME_ID_NONE; + } + + __pEditDate->Invalidate(); + return false; +} + +void +_EditDatePresenter::OnTouchMoveHandled(const _Control& control) +{ + __touchMoveHandled = true; + __selectedId = DATETIME_ID_NONE; + __pEditDate->Invalidate(); + return; +} + +void +_EditDatePresenter::Animate(void) +{ + SysAssertf((__pFont != null), "Font instance must not be null."); + + (_FontImpl::GetInstance(*__pFont))->SetSize(__dateFontSize); + + result r = E_SUCCESS; + Rectangle rect; + String monthString; + String yearString; + String dayString; + String newValue; + + _DateTimeUtils dateTimeUtils; + monthString = dateTimeUtils.GetMonthString(GetMonth()); + yearString.Format(10, L"%04d", GetYear()); + dayString.Format(10, L"%02d", GetDay()); + + if (GetLastSelectedId() == DATETIME_ID_DAY) + { + SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(dayString) == false), E_SUCCESS, "Day string matched."); + + newValue = dayString; + rect = GetDateAreaBounds(DATETIME_ID_DAY); + } + else if (GetLastSelectedId() == DATETIME_ID_MONTH) + { + SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(monthString) == false), E_SUCCESS, "Month string matched."); + + newValue = monthString; + rect = GetDateAreaBounds(DATETIME_ID_MONTH); + } + else if (GetLastSelectedId() == DATETIME_ID_YEAR) + { + SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(yearString) == false), E_SUCCESS, "Year string matched."); + + newValue = yearString; + rect = GetDateAreaBounds(DATETIME_ID_YEAR); + } + + Dimension newTextDim; + Dimension oldTextDim; + Point textPoint; + VisualElement* pNewVisualElement = null; + VisualElement* pOldVisualElement = null; + VisualElement* pEditDateElement = null; + VisualElementPropertyAnimation* pNewBoundsAnimation = null; + VisualElementPropertyAnimation* pOldBoundsAnimation = null; + Canvas *pCanvas = null; + + __pFont->GetTextExtent(newValue, newValue.GetLength(), newTextDim); + __pFont->GetTextExtent(__lastSelectedValue, __lastSelectedValue.GetLength(), oldTextDim); + + if (newTextDim.width > oldTextDim.width) + { + textPoint.x = (rect.width - newTextDim.width) / 2; + } + else + { + textPoint.x = (rect.width - oldTextDim.width) / 2; + } + + SysTryReturnVoidResult(NID_UI_CTRL, (rect.x + textPoint.x < __pEditDate->GetBounds().width), E_SUCCESS, "Rolling animation cann't be played."); + + __isAnimating = true; + + __pContentProvider = new (std::nothrow) VisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pContentProvider != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pContentProvider->Construct(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pContentProvider->SetShowState(true); + __pContentProvider->SetClipChildrenEnabled(true); + __pContentProvider->SetImplicitAnimationEnabled(false); + + pEditDateElement = __pEditDate->GetVisualElement(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pEditDateElement != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pNewVisualElement = new (std::nothrow) VisualElement(); + SysTryCatch(NID_UI_CTRL, (pNewVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pNewVisualElement->Construct(); + if (r != E_SUCCESS) + { + pNewVisualElement->Destroy(); + } + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pOldVisualElement = new (std::nothrow) VisualElement(); + if (pOldVisualElement == null) + { + pNewVisualElement->Destroy(); + } + SysTryCatch(NID_UI_CTRL, (pOldVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pOldVisualElement->Construct(); + if (r != E_SUCCESS) + { + pNewVisualElement->Destroy(); + pOldVisualElement->Destroy(); + } + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pNewVisualElement->SetShowState(true); + pOldVisualElement->SetShowState(true); + + if (newTextDim.width > oldTextDim.width) + { + textPoint.x = (rect.width - newTextDim.width) / 2; + textPoint.y = (rect.height - newTextDim.height) / 2; + __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f)); + pNewVisualElement->SetBounds(FloatRectangle(0.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f)); + + rect.x = static_cast(__pContentProvider->GetBounds().x); + rect.y = static_cast(__pContentProvider->GetBounds().y); + rect.width = static_cast(__pContentProvider->GetBounds().width); + rect.height = static_cast(__pContentProvider->GetBounds().height); + + textPoint.x = (rect.width - oldTextDim.width) / 2; + textPoint.y = (rect.height - oldTextDim.height) / 2; + + pOldVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f)); + } + else + { + textPoint.x = (rect.width - oldTextDim.width) / 2; + textPoint.y = (rect.height - oldTextDim.height) / 2; + __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f)); + pOldVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f)); + + rect.x = static_cast(__pContentProvider->GetBounds().x); + rect.y = static_cast(__pContentProvider->GetBounds().y); + rect.width = static_cast(__pContentProvider->GetBounds().width); + rect.height = static_cast(__pContentProvider->GetBounds().height); + + textPoint.x = (rect.width - newTextDim.width) / 2; + textPoint.y = (rect.height - newTextDim.height) / 2; + + pNewVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f)); + } + + + pCanvas = pEditDateElement->GetCanvasN(rect); + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + delete pCanvas; + + pEditDateElement->AttachChild(*__pContentProvider); + + __pContentProvider->AttachChild(*pOldVisualElement); + __pContentProvider->AttachChild(*pNewVisualElement); + + pNewBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryCatch(NID_UI_CTRL, (pNewBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pNewBoundsAnimation->SetDuration(300); + pNewBoundsAnimation->SetPropertyName("bounds.position"); + pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, newTextDim.height * 1.0f))); + pNewBoundsAnimation->SetEndValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, 0.0f))); + pNewBoundsAnimation->SetVisualElementAnimationStatusEventListener(this); + + pOldBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryCatch(NID_UI_CTRL, (pOldBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pOldBoundsAnimation->SetDuration(300); + pOldBoundsAnimation->SetPropertyName("bounds.position"); + pOldBoundsAnimation->SetStartValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, 0.0f))); + pOldBoundsAnimation->SetEndValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, oldTextDim.height * -1.0f))); + pOldBoundsAnimation->SetVisualElementAnimationStatusEventListener(this); + + pCanvas = pOldVisualElement->GetCanvasN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + pCanvas->SetFont(*__pFont); + pCanvas->DrawText(Point(0,0),__lastSelectedValue); + + delete pCanvas; + pCanvas = null; + + pCanvas = pNewVisualElement->GetCanvasN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + pCanvas->SetFont(*__pFont); + pCanvas->DrawText(Point(0,0),newValue); + + delete pCanvas; + pCanvas = null; + + pOldVisualElement->SetImplicitAnimationEnabled(false); + pOldVisualElement->AddAnimation(*pOldBoundsAnimation); + + pNewVisualElement->SetImplicitAnimationEnabled(false); + pNewVisualElement->AddAnimation(*pNewBoundsAnimation); + + delete pOldBoundsAnimation; + delete pNewBoundsAnimation; + + return; + +CATCH: + __isAnimating = false; + __pContentProvider->Destroy(); + + delete pNewBoundsAnimation; + pNewBoundsAnimation = null; + + delete pOldBoundsAnimation; + pOldBoundsAnimation = null; + + delete pCanvas; + pCanvas = null; + + return; +} + +void +_EditDatePresenter::OnVisualElementAnimationFinished (const VisualElementAnimation &animation, const String &keyName, VisualElement &target, bool completedNormally) +{ + result r = E_SUCCESS; + __isAnimating = false; + + VisualElement* pEditDateElement = __pEditDate->GetVisualElement(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (pEditDateElement != null), r, "[%s] Propagating.", GetErrorMessage(r)); + + pEditDateElement->DetachChild(*__pContentProvider); + __pContentProvider->Destroy(); + + Draw(); + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditFieldImpl.cpp b/src/ui/controls/FUiCtrl_EditFieldImpl.cpp new file mode 100644 index 0000000..1a0a17e --- /dev/null +++ b/src/ui/controls/FUiCtrl_EditFieldImpl.cpp @@ -0,0 +1,2223 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditFieldImpl.cpp + * @brief This file contains implementation of _EditFieldImpl class + */ + +#include +#include +#include +#include +#include +#include +#include "FUi_ControlImpl.h" +#include "FUi_IFocusEventListener.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_EditFieldImpl.h" +#include "FUiCtrl_PublicActionEvent.h" +#include "FUiCtrl_PublicKeypadEvent.h" +#include "FUiCtrl_PublicLanguageEvent.h" +#include "FUiCtrl_PublicLinkEvent.h" +#include "FUiCtrl_PublicScrollPanelEvent.h" +#include "FUiCtrl_PublicTextBlockEvent.h" +#include "FUiCtrl_PublicTextEvent.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_EditFieldImpl::EditFieldSizeInfo::EditFieldSizeInfo(void) + :__titleStyle(EDIT_FIELD_TITLE_STYLE_NONE) + , __smallStyle(false) +{ +} + +Dimension +_EditFieldImpl::EditFieldSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Dimension editFieldMinimumSize(0, 0); + + if (__smallStyle) + { + r = GET_DIMENSION_CONFIG(EDIT::SMALL_STYLE_MIN_SIZE, orientation, editFieldMinimumSize); + SysTryReturn(NID_UI, r == E_SUCCESS, editFieldMinimumSize, r, "System Error occurred."); + } + else if (__titleStyle == EDIT_FIELD_TITLE_STYLE_TOP) + { + r = GET_DIMENSION_CONFIG(EDIT::TITLE_STYLE_MIN_SIZE, orientation, editFieldMinimumSize); + SysTryReturn(NID_UI, r == E_SUCCESS, editFieldMinimumSize, r, "System Error occurred."); + } + else + { + r = GET_DIMENSION_CONFIG(EDIT::MIN_SIZE, orientation, editFieldMinimumSize); + SysTryReturn(NID_UI, r == E_SUCCESS, editFieldMinimumSize, r, "System Error occurred."); + } + + return editFieldMinimumSize; +} + +void +_EditFieldImpl::EditFieldSizeInfo::SetTitleStyle(EditFieldTitleStyle titleStyle) +{ + __titleStyle = titleStyle; +} + +void +_EditFieldImpl::EditFieldSizeInfo::SetSmallStyle(bool isSmallStyle) +{ + __smallStyle = isSmallStyle; +} + + +_EditFieldImpl* +_EditFieldImpl::GetInstance(EditField& editField) +{ + return (static_cast<_EditFieldImpl*> (editField._pControlImpl)); +} + +const _EditFieldImpl* +_EditFieldImpl::GetInstance(const EditField& editField) +{ + return (static_cast (editField._pControlImpl)); +} + +_EditFieldImpl::_EditFieldImpl(EditField* pPublic, _Edit* pCore) + : _ControlImpl(pPublic, pCore) + , __pEdit(pCore) + , __editFieldStyle(EDIT_FIELD_STYLE_NORMAL) + , __inputStyle(INPUT_STYLE_OVERLAY) + , __inputModeCategory(EDIT_INPUTMODE_ALPHA | EDIT_INPUTMODE_PREDICTIVE | EDIT_INPUTMODE_NUMERIC | EDIT_INPUTMODE_SYMBOL) + , __currentInputMode(EDIT_INPUTMODE_ALPHA) + , __pPublicActionEvent(null) + , __pPublicKeypadEvent(null) + , __pPublicLanguageEvent(null) + , __pPublicLinkEvent(null) + , __pPublicScrollPanelEvent(null) + , __pPublicTextBlockEvent(null) + , __pPublicTextEvent(null) + , __autoLinkMask(LINK_TYPE_NONE) +{ +} + +_EditFieldImpl::~_EditFieldImpl(void) +{ + if (__pEdit) + { + __pEdit->RemoveTextEventListener(*this); + __pEdit->RemoveActionEventListener(*this); + __pEdit->RemoveTextBlockEventListener(*this); + __pEdit->RemoveUiLinkEventListener(*this); + __pEdit->RemoveKeypadEventListener(*this); + __pEdit->RemoveActionEventListener(*this); + __pEdit->RemoveScrollPanelEventListener(*this); + } + + if (__pPublicTextEvent) + { + delete __pPublicTextEvent; + __pPublicTextEvent = null; + } + + if (__pPublicActionEvent) + { + delete __pPublicActionEvent; + __pPublicActionEvent = null; + } + + if (__pPublicTextBlockEvent) + { + delete __pPublicTextBlockEvent; + __pPublicTextBlockEvent = null; + } + + if (__pPublicLinkEvent) + { + delete __pPublicLinkEvent; + __pPublicLinkEvent = null; + } + + if (__pPublicKeypadEvent) + { + delete __pPublicKeypadEvent; + __pPublicKeypadEvent = null; + } + + if (__pPublicLanguageEvent) + { + delete __pPublicLanguageEvent; + __pPublicLanguageEvent = null; + } + + if (__pPublicScrollPanelEvent) + { + delete __pPublicScrollPanelEvent; + __pPublicScrollPanelEvent = null; + } +} + +_EditFieldImpl* +_EditFieldImpl::CreateEditFieldImplN(EditField* pControl, const Rectangle& rect, EditFieldStyle style, EditFieldTitleStyle titleStyle) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + bool isSmallStyle = false; + + if (style == EDIT_FIELD_STYLE_NORMAL_SMALL || style == EDIT_FIELD_STYLE_PASSWORD_SMALL + || style == EDIT_FIELD_STYLE_EMAIL_SMALL || style == EDIT_FIELD_STYLE_URL_SMALL + || style == EDIT_FIELD_STYLE_IP_V4_SMALL || style == EDIT_FIELD_STYLE_PHONE_NUMBER_SMALL + || style == EDIT_FIELD_STYLE_NUMBER_SMALL || style == EDIT_FIELD_STYLE_PASSWORD_NUMBER_SMALL) + { + isSmallStyle = true; + } + + _Edit* pCore = _Edit::CreateEditN(); + SysTryReturn(NID_UI_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _EditFieldImpl* pImpl = new (std::nothrow) _EditFieldImpl(pControl, pCore); + r = _ControlImpl::CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; +} + +const char* +_EditFieldImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::EditField"; +} + +const EditField& +_EditFieldImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +EditField& +_EditFieldImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Edit& +_EditFieldImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Edit& +_EditFieldImpl::GetCore(void) +{ + return static_cast <_Edit&>(_ControlImpl::GetCore()); +} + +result +_EditFieldImpl::Initialize(EditFieldStyle style, InputStyle inputStyle, + EditFieldTitleStyle titleStlye, bool enableClear, int limitLength, + GroupStyle groupStyle) +{ + result r = E_SUCCESS; + + int editfieldStyle = EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_NOSCROLL; + bool isSmallStyle = false; + EditFieldStyle tempStyle = style; + KeypadStyle keypadStyle = KEYPAD_STYLE_NORMAL; + Variant variantKeypadStyle = (int)KEYPAD_STYLE_NORMAL; + + if (style == EDIT_FIELD_STYLE_NORMAL_SMALL || style == EDIT_FIELD_STYLE_PASSWORD_SMALL + || style == EDIT_FIELD_STYLE_EMAIL_SMALL || style == EDIT_FIELD_STYLE_URL_SMALL + || style == EDIT_FIELD_STYLE_IP_V4_SMALL || style == EDIT_FIELD_STYLE_PHONE_NUMBER_SMALL + || style == EDIT_FIELD_STYLE_NUMBER_SMALL || style == EDIT_FIELD_STYLE_PASSWORD_NUMBER_SMALL) + { + isSmallStyle = true; + switch (style) + { + case EDIT_FIELD_STYLE_EMAIL_SMALL: + tempStyle = EDIT_FIELD_STYLE_EMAIL; + break; + + case EDIT_FIELD_STYLE_PASSWORD_SMALL: + tempStyle = EDIT_FIELD_STYLE_PASSWORD; + break; + + case EDIT_FIELD_STYLE_URL_SMALL: + tempStyle = EDIT_FIELD_STYLE_URL; + break; + + case EDIT_FIELD_STYLE_NUMBER_SMALL: + tempStyle = EDIT_FIELD_STYLE_NUMBER; + break; + + case EDIT_FIELD_STYLE_PHONE_NUMBER_SMALL: + tempStyle = EDIT_FIELD_STYLE_PHONE_NUMBER; + break; + + case EDIT_FIELD_STYLE_PASSWORD_NUMBER_SMALL: + tempStyle = EDIT_FIELD_STYLE_PASSWORD_NUMBER; + break; + + case EDIT_FIELD_STYLE_IP_V4_SMALL: + tempStyle = EDIT_FIELD_STYLE_IP_V4; + break; + + default: + break; + } + } + + + + if (tempStyle == EDIT_FIELD_STYLE_PASSWORD || tempStyle == EDIT_FIELD_STYLE_PASSWORD_NUMBER) + { + editfieldStyle |= EDIT_STYLE_PASSWORD; + } + + if (isSmallStyle && (titleStlye != EDIT_FIELD_TITLE_STYLE_NONE)) + { + r = E_UNSUPPORTED_OPTION; + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_OPTION, "[E_UNSUPPORTED_OPTION] Unsupported operation."); + return r; + } + + if (titleStlye == EDIT_FIELD_TITLE_STYLE_INNER) + { + editfieldStyle |= EDIT_STYLE_TITLE_LEFT; + } + else if (titleStlye == EDIT_FIELD_TITLE_STYLE_TOP) + { + editfieldStyle |= EDIT_STYLE_TITLE_TOP; + } + + if (enableClear) + { + editfieldStyle |= EDIT_STYLE_CLEAR; + } + + __inputStyle = inputStyle; + __editFieldStyle = tempStyle; + + r = __pEdit->Initialize(editfieldStyle, inputStyle, limitLength, groupStyle); + if (r != E_SUCCESS) + { + return r; + } + + if (!_AppInfo::IsOspCompat()) + { + __pEdit->SetKeypadCommandButtonVisible(false); + } + + switch (tempStyle) + { + case EDIT_FIELD_STYLE_EMAIL : + keypadStyle = KEYPAD_STYLE_EMAIL; + break; + + case EDIT_FIELD_STYLE_URL : + keypadStyle = KEYPAD_STYLE_URL; + break; + + case EDIT_FIELD_STYLE_NUMBER : + keypadStyle = KEYPAD_STYLE_NUMBER; + break; + + case EDIT_FIELD_STYLE_PHONE_NUMBER : + keypadStyle = KEYPAD_STYLE_PHONE_NUMBER; + break; + + case EDIT_FIELD_STYLE_PASSWORD_NUMBER : + keypadStyle = KEYPAD_STYLE_NUMBER; + break; + + case EDIT_FIELD_STYLE_IP_V4 : + keypadStyle = KEYPAD_STYLE_IP_V4; + break; + + default: + break; + } + + variantKeypadStyle = (int) keypadStyle; + __pEdit->SetPropertyKeypadStyle(variantKeypadStyle); + + __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to initialize."); + + r = __pEdit->AddActionEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicLinkEvent = _PublicLinkEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicLinkEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to initialize."); + + r = __pEdit->AddUiLinkEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTextBlockEvent = _PublicTextBlockEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to initialize."); + + r = __pEdit->AddTextBlockEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent = _PublicKeypadEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to initialize."); + + r = __pEdit->AddKeypadEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTextEvent = _PublicTextEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to initialize."); + + r = __pEdit->AddTextEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicScrollPanelEvent = _PublicScrollPanelEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicScrollPanelEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to initialize."); + + if (inputStyle == INPUT_STYLE_OVERLAY) + { + r = __pEdit->AddScrollPanelEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __pPublicLanguageEvent = _PublicLanguageEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicLanguageEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to initialize."); + + r = __pEdit->AddLanguageEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (inputStyle == INPUT_STYLE_OVERLAY) + { + __pEdit->SetAutoLinkMask(LINK_TYPE_URL | LINK_TYPE_EMAIL | LINK_TYPE_TEL_NUM); + } + + return r; +} + +result +_EditFieldImpl::Dispose(void) +{ + result r = E_SUCCESS; + + if (__pEdit) + { + delete __pEdit; + __pEdit = null; + } + + return r; +} + +HorizontalAlignment +_EditFieldImpl::GetTextAlignment(void) const +{ + return __pEdit->GetTextAlignment(); +} + +result +_EditFieldImpl::SetTextAlignment(HorizontalAlignment alignment) +{ + return __pEdit->SetTextAlignment(alignment); +} + +bool +_EditFieldImpl::IsViewModeEnabled(void) const +{ + return __pEdit->GetPropertyViewModeEnabled().ToBool(); +} + +result +_EditFieldImpl::SetViewModeEnabled(bool enable) +{ + Variant variantEnable(enable); + + return __pEdit->SetPropertyViewModeEnabled(variantEnable); +} + +result +_EditFieldImpl::SetAutoLinkMask(unsigned long autoLinks) +{ + result r = E_SUCCESS; + Variant variantAutoLinks(autoLinks); + + r = __pEdit->SetPropertyAutoLinkMask(variantAutoLinks); + + if (r == E_SUCCESS) + { + __autoLinkMask = autoLinks; + } + + return r; +} + +unsigned long +_EditFieldImpl::GetAutoLinkMask(void) const +{ + SysTryReturn(NID_UI_CTRL, (__inputStyle == INPUT_STYLE_OVERLAY), LINK_TYPE_NONE, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The current state unable to this operation."); + return __autoLinkMask; +} + +int +_EditFieldImpl::GetMargin(EditMarginType marginType) const +{ + if (marginType == EDIT_MARGIN_TYPE_VERTICAL) + { + return __pEdit->GetVerticalMargin(EDIT_TEXT_TOP_MARGIN); + } + else + { + return __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + } +} + +result +_EditFieldImpl::SetMargin(EditMarginType marginType, int margin) +{ + result r = E_SUCCESS; + Variant varMargin(margin); + + if (marginType == EDIT_MARGIN_TYPE_HORIZONTAL) + { + r = __pEdit->SetHorizontalMargin(margin, EDIT_TEXT_LEFT_MARGIN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __pEdit->SetHorizontalMargin(margin, EDIT_TEXT_RIGHT_MARGIN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = __pEdit->SetVerticalMargin(margin, EDIT_TEXT_TOP_MARGIN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __pEdit->SetVerticalMargin(margin, EDIT_TEXT_BOTTOM_MARGIN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_EditFieldImpl::SetKeypadActionEnabled(bool enable) +{ + Variant variantEnable(enable); + + return __pEdit->SetPropertyKeypadActionEnabled(variantEnable); +} + +bool +_EditFieldImpl::IsKeypadActionEnabled(void) const +{ + return __pEdit->GetPropertyKeypadActionEnabled().ToBool(); +} + +KeypadAction +_EditFieldImpl::GetKeypadAction(void) const +{ + CoreKeypadAction coreKeypadAction = (CoreKeypadAction)__pEdit->GetPropertyKeypadAction().ToInt(); + KeypadAction publicKeypadAction = KEYPAD_ACTION_ENTER; + + switch (coreKeypadAction) + { + case CORE_KEYPAD_ACTION_ENTER: + publicKeypadAction = KEYPAD_ACTION_ENTER; + break; + + case CORE_KEYPAD_ACTION_GO: + publicKeypadAction = KEYPAD_ACTION_GO; + break; + + case CORE_KEYPAD_ACTION_NEXT: + publicKeypadAction = KEYPAD_ACTION_NEXT; + break; + + case CORE_KEYPAD_ACTION_SEND: + publicKeypadAction = KEYPAD_ACTION_SEND; + break; + + case CORE_KEYPAD_ACTION_SEARCH: + publicKeypadAction = KEYPAD_ACTION_SEARCH; + break; + + case CORE_KEYPAD_ACTION_LOGIN: + publicKeypadAction = KEYPAD_ACTION_LOGIN; + break; + + case CORE_KEYPAD_ACTION_SIGN_IN: + publicKeypadAction = KEYPAD_ACTION_SIGN_IN; + break; + + case CORE_KEYPAD_ACTION_JOIN: + publicKeypadAction = KEYPAD_ACTION_JOIN; + break; + + case CORE_KEYPAD_ACTION_DONE: + publicKeypadAction = KEYPAD_ACTION_DONE; + break; + + default: + break; + } + + return publicKeypadAction; +} + +result +_EditFieldImpl::SetKeypadAction(KeypadAction keypadAction) +{ + CoreKeypadAction coreKeypadAction = CORE_KEYPAD_ACTION_ENTER; + + switch (keypadAction) + { + case KEYPAD_ACTION_ENTER: + coreKeypadAction = CORE_KEYPAD_ACTION_ENTER; + break; + + case KEYPAD_ACTION_GO: + coreKeypadAction = CORE_KEYPAD_ACTION_GO; + break; + + case KEYPAD_ACTION_NEXT: + coreKeypadAction = CORE_KEYPAD_ACTION_NEXT; + break; + + case KEYPAD_ACTION_SEND: + coreKeypadAction = CORE_KEYPAD_ACTION_SEND; + break; + + case KEYPAD_ACTION_SEARCH: + coreKeypadAction = CORE_KEYPAD_ACTION_SEARCH; + break; + + case KEYPAD_ACTION_LOGIN: + coreKeypadAction = CORE_KEYPAD_ACTION_LOGIN; + break; + + case KEYPAD_ACTION_SIGN_IN: + coreKeypadAction = CORE_KEYPAD_ACTION_SIGN_IN; + break; + + case KEYPAD_ACTION_JOIN: + coreKeypadAction = CORE_KEYPAD_ACTION_JOIN; + break; + + case KEYPAD_ACTION_DONE: + coreKeypadAction = CORE_KEYPAD_ACTION_DONE; + break; + + default: + break; + } + + Variant variantKeypadAction((int)coreKeypadAction); + + return __pEdit->SetPropertyKeypadAction(variantKeypadAction); +} + +KeypadStyle +_EditFieldImpl::GetKeypadStyle(void) const +{ + return (KeypadStyle)__pEdit->GetPropertyKeypadStyle().ToInt(); +} + +result +_EditFieldImpl::SetOverlayKeypadCommandButtonVisible(bool visible) +{ + Variant variantVisible(visible); + + return __pEdit->SetPropertyOverlayKeypadCommandButtonVisible(variantVisible); +} + +bool +_EditFieldImpl::IsOverlayCommandButtonVisible(void) const +{ + return __pEdit->GetPropertyOverlayKeypadCommandButtonVisible().ToBool(); +} + +result +_EditFieldImpl::HideKeypad(void) +{ + return __pEdit->HideKeypad(); +} + +EllipsisPosition +_EditFieldImpl::GetEllipsisPosition(void) const +{ + return __pEdit->GetEllipsisPosition(); +} + +result +_EditFieldImpl::SetEllipsisPosition(EllipsisPosition position) +{ + __pEdit->SetEllipsisPosition(position); + + return E_SUCCESS; +} + +int +_EditFieldImpl::GetTextSize(void) const +{ + return __pEdit->GetPropertyTextSize().ToInt(); +} + +result +_EditFieldImpl::SetTextSize(int size) +{ + Variant variantSize(size); + + return __pEdit->SetPropertyTextSize(variantSize); +} + +Color +_EditFieldImpl::GetColor(EditStatus status) const +{ + Color color; + + switch (status) + { + case EDIT_STATUS_NORMAL: + color = __pEdit->GetPropertyNormalColor().ToColor(); + break; + + case EDIT_STATUS_DISABLED: + color = __pEdit->GetPropertyDisabledColor().ToColor(); + break; + + case EDIT_STATUS_HIGHLIGHTED: + color = __pEdit->GetPropertyHighlightedColor().ToColor(); + break; + + case EDIT_STATUS_PRESSED: + color = __pEdit->GetPropertyPressedColor().ToColor(); + break; + + default: + break; + } + + return color; +} + +Color +_EditFieldImpl::GetTextColor(EditTextColor type) const +{ + return __pEdit->GetTextColor(type); +} + +result +_EditFieldImpl::SetBackgroundBitmap(EditStatus status, const Bitmap& bitmap) +{ + return __pEdit->SetBackgroundBitmap(status, bitmap); +} + +result +_EditFieldImpl::SetColor(EditStatus status, const Color& color) +{ + result r = E_SUCCESS; + Variant variantColor(color); + + switch (status) + { + case EDIT_STATUS_NORMAL: + r = __pEdit->SetPropertyNormalColor(variantColor); + break; + + case EDIT_STATUS_DISABLED: + r = __pEdit->SetPropertyDisabledColor(variantColor); + break; + + case EDIT_STATUS_HIGHLIGHTED: + r = __pEdit->SetPropertyHighlightedColor(variantColor); + break; + + case EDIT_STATUS_PRESSED: + r = __pEdit->SetPropertyPressedColor(variantColor); + break; + + default: + r = E_INVALID_ARG; + break; + } + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Unable to set color.", GetErrorMessage(r)); + + return r; +} + +result +_EditFieldImpl::SetTextColor(EditTextColor type, const Color& color) +{ + result r = E_SUCCESS; + + r = __pEdit->SetTextColor(type, color); + + return r; +} + +String +_EditFieldImpl::GetText(int start, int end) const +{ + return __pEdit->GetText(start, end); +} + +result +_EditFieldImpl::AddUiLinkEventListener(IUiLinkEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicLinkEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.") + + return __pPublicLinkEvent->AddListener(listener); +} + +result +_EditFieldImpl::RemoveUiLinkEventListener(IUiLinkEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicLinkEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.") + + return __pPublicLinkEvent->RemoveListener(listener); +} + +result +_EditFieldImpl::AddTextBlockEventListener(ITextBlockEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + return __pPublicTextBlockEvent->AddListener(listener); +} + +result +_EditFieldImpl::RemoveTextBlockEventListener(ITextBlockEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + return __pPublicTextBlockEvent->RemoveListener(listener); +} + +result +_EditFieldImpl::AddKeypadEventListener(IKeypadEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + return __pPublicKeypadEvent->AddListener(listener); +} + +result +_EditFieldImpl::RemoveKeypadEventListener(IKeypadEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + return __pPublicKeypadEvent->RemoveListener(listener); +} + +result +_EditFieldImpl::AddTextEventListener(ITextEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.") + + return __pPublicTextEvent->AddListener(listener); +} + +result +_EditFieldImpl::RemoveTextEventListener(ITextEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + return __pPublicTextEvent->RemoveListener(listener); +} + +result +_EditFieldImpl::AddScrollPanelEventListener(IScrollPanelEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.") + SysTryReturn(NID_UI_CTRL, __pPublicScrollPanelEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + return __pPublicScrollPanelEvent->AddListener(listener); +} + +result +_EditFieldImpl::RemoveScrollPanelEventListener(IScrollPanelEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicScrollPanelEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + return __pPublicScrollPanelEvent->RemoveListener(listener); +} + +result +_EditFieldImpl::AddActionEventListener(IActionEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + return __pPublicActionEvent->AddListener(listener); +} + +result +_EditFieldImpl::RemoveActionEventListener(IActionEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.") + + return __pPublicActionEvent->RemoveListener(listener); +} + +result +_EditFieldImpl::AddLanguageEventListener(ILanguageEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + return __pPublicLanguageEvent->AddListener(listener); +} + +result +_EditFieldImpl::RemoveLanguageEventListener(ILanguageEventListener& listener) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed.") + + return __pPublicLanguageEvent->RemoveListener(listener); +} + +int +_EditFieldImpl::GetRemainingLength(void) const +{ + return __pEdit->GetRemainingLength(); +} + +void +_EditFieldImpl::SetLowerCaseModeEnabled(bool enable) +{ + Variant variantEnable(enable); + + __pEdit->SetPropertyLowerCaseModeEnabled(variantEnable); +} + +bool +_EditFieldImpl::IsLowerCaseModeEnabled(void) const +{ + return __pEdit->GetPropertyLowerCaseModeEnabled().ToBool(); +} + +result +_EditFieldImpl::SetInputModeCategory(unsigned long categories, bool enable) +{ + result r = E_SUCCESS; + const unsigned long INPUT_MODE_ALL_MASK = EDIT_INPUTMODE_ALPHA | EDIT_INPUTMODE_PREDICTIVE | EDIT_INPUTMODE_NUMERIC| EDIT_INPUTMODE_SYMBOL; + KeypadStyle keypadStyle = GetKeypadStyle(); + + switch (keypadStyle) + { + case KEYPAD_STYLE_NUMBER: + // fall through + case KEYPAD_STYLE_IP_V4: + if (enable) + { + if (categories & (EDIT_INPUTMODE_ALPHA | EDIT_INPUTMODE_PREDICTIVE | EDIT_INPUTMODE_SYMBOL)) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current keypad style can not support given categories."); + + return E_INVALID_OPERATION; + } + } + else + { + if (categories & EDIT_INPUTMODE_NUMERIC) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current keypad style can not support given categories."); + + return E_INVALID_OPERATION; + } + } + break; + + case KEYPAD_STYLE_PHONE_NUMBER: + if (enable) + { + if (categories & (EDIT_INPUTMODE_ALPHA | EDIT_INPUTMODE_PREDICTIVE)) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current keypad style can not support given categories."); + + return E_INVALID_OPERATION; + } + + if (!((categories & EDIT_INPUTMODE_NUMERIC) && (categories & EDIT_INPUTMODE_SYMBOL))) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current keypad style can not support given categories."); + + return E_INVALID_OPERATION; + } + else + { + if (categories & (EDIT_INPUTMODE_NUMERIC | EDIT_INPUTMODE_SYMBOL)) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current keypad style cna not support given categories."); + + return E_INVALID_OPERATION; + } + } + } + break; + + default: + break; + } + + if (((enable == true) && (categories == 0)) || ((enable == false) && (categories == INPUT_MODE_ALL_MASK))) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] All input modes cannot be disabled."); + + return E_INVALID_ARG; + } + + if ((enable == false) && (categories & __currentInputMode)) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] The current input modes cannot be disabled."); + + return E_INVALID_ARG; + } + + if (enable) + { + __inputModeCategory = categories; + if ((~categories) & EDIT_INPUTMODE_PREDICTIVE) + { + __pEdit->SetTextPredictionEnabled(false); + } + } + else + { + __inputModeCategory = (~categories & INPUT_MODE_ALL_MASK); + if (categories == EDIT_INPUTMODE_PREDICTIVE) + { + __pEdit->SetTextPredictionEnabled(false); + } + } + + // if currentInputModeCategory doesn't exist in categories, then set tempInputMode + if (!(categories & __currentInputMode)) + { + const int INPUT_MODE_CATEGORY_MAX = 4; + EditInputModeCategory newInputMode = __currentInputMode; + EditInputModeCategory tempInputMode = EDIT_INPUTMODE_ALPHA; + for (int i = 0; i < INPUT_MODE_CATEGORY_MAX; i++) + { + if ( (categories & tempInputMode) && (tempInputMode != EDIT_INPUTMODE_PREDICTIVE)) + { + newInputMode = tempInputMode; + break; + } + + switch (tempInputMode) + { + case EDIT_INPUTMODE_ALPHA: + tempInputMode = EDIT_INPUTMODE_PREDICTIVE; + break; + + case EDIT_INPUTMODE_PREDICTIVE: + tempInputMode = EDIT_INPUTMODE_NUMERIC; + break; + + case EDIT_INPUTMODE_NUMERIC: + tempInputMode = EDIT_INPUTMODE_SYMBOL; + break; + + default: + break; + } + } + + if (__currentInputMode != newInputMode) + { + r = SetCurrentInputModeCategory(newInputMode); + } + } + + return r; +} + +result +_EditFieldImpl::SetCurrentInputModeCategory(EditInputModeCategory inputModeCategory) +{ + KeypadStyle currentKeypadStyle = GetKeypadStyle(); + KeypadStyle keypadStyle = KEYPAD_STYLE_NORMAL; + + if (inputModeCategory == EDIT_INPUTMODE_NUMERIC) + { + if (currentKeypadStyle == KEYPAD_STYLE_NORMAL) + { + __pEdit->SetKeypadNormalNumberStyle(true); + } + else + { + keypadStyle = KEYPAD_STYLE_NUMBER; + Variant variantKeypadStyle((int)keypadStyle); + + __pEdit->SetPropertyKeypadStyle(variantKeypadStyle); + } + } + else if (inputModeCategory == EDIT_INPUTMODE_SYMBOL) + { + if (currentKeypadStyle == KEYPAD_STYLE_NORMAL) + { + __pEdit->SetKeypadNormalNumberStyle(true); + } + } + else if (inputModeCategory == EDIT_INPUTMODE_PREDICTIVE) + { + __pEdit->SetTextPredictionEnabled(true); + } + + __currentInputMode = inputModeCategory; + return E_SUCCESS; +} + +unsigned long +_EditFieldImpl::GetInputModeCategory(void) const +{ + return __inputModeCategory; +} + +EditInputModeCategory +_EditFieldImpl::GetCurrentInputModeCategory(void) const +{ + return __currentInputMode; +} + +bool +_EditFieldImpl::IsTextPredictionEnabled(void) const +{ + return __pEdit->IsTextPredictionEnabled(); +} + +result +_EditFieldImpl::SetTextPredictionEnabled(bool enable) +{ + return __pEdit->SetTextPredictionEnabled(enable); +} + +result +_EditFieldImpl::SetCursorPosition(int position) +{ + Variant variantPosition(position); + + return __pEdit->SetPropertyCursorPosition(variantPosition); +} + +int +_EditFieldImpl::GetCursorPosition(void) const +{ + return __pEdit->GetPropertyCursorPosition().ToInt(); +} + +String +_EditFieldImpl::GetText(void) const +{ + return __pEdit->GetPropertyText().ToString(); +} + +int +_EditFieldImpl::GetTextLength(void) const +{ + return __pEdit->GetTextLength(); +} + +result +_EditFieldImpl::SetText(const String& text) +{ + Variant variantText(text); + + return __pEdit->SetPropertyText(variantText); +} + +result +_EditFieldImpl::InsertTextAtCursorPosition(const String& text) +{ + return __pEdit->InsertTextAtCursorPosition(text); +} + +result +_EditFieldImpl::AppendText(const String& text) +{ + return __pEdit->AppendText(text); +} + +result +_EditFieldImpl::AppendCharacter(const Character& character) +{ + return __pEdit->AppendCharacter(character); +} + +result +_EditFieldImpl::Clear(void) +{ + return __pEdit->ClearText(); +} + +result +_EditFieldImpl::DeleteCharacterAtCursorPosition(void) +{ + return __pEdit->DeleteCharacterAtCursorPosition(); +} + +void +_EditFieldImpl::GetCurrentTextRange(int& start, int& end) const +{ + return __pEdit->GetCurrentTextRange(start, end); +} + +void +_EditFieldImpl::SetGuideText(const String& guideText) +{ + Variant variantGuideText(guideText); + + __pEdit->SetPropertyGuideText(variantGuideText); +} + +String +_EditFieldImpl::GetGuideText(void) const +{ + return __pEdit->GetPropertyGuideText().ToString(); +} + +Color +_EditFieldImpl::GetGuideTextColor(void) const +{ + return __pEdit->GetPropertyGuideTextColor().ToColor(); +} + +result +_EditFieldImpl::SetGuideTextColor(const Color& color) +{ + Variant variantColor(color); + + return __pEdit->SetPropertyGuideTextColor(variantColor); +} + +void +_EditFieldImpl::SetKeypadEnabled(bool enable) +{ + Variant variantEnable(enable); + + __pEdit->SetPropertyKeypadEnabled(variantEnable); +} + +bool +_EditFieldImpl::IsKeypadEnabled(void) const +{ + return __pEdit->GetPropertyKeypadEnabled().ToBool(); +} + +result +_EditFieldImpl::ShowKeypad(void) +{ + return __pEdit->ShowKeypad(); +} + +void +_EditFieldImpl::GetBlockRange(int& start, int& end) const +{ + __pEdit->GetBlockRange(start, end); +} + +result +_EditFieldImpl::BeginBlock(void) +{ + return __pEdit->BeginTextBlock(); +} + +result +_EditFieldImpl::ReleaseBlock(void) +{ + return __pEdit->ReleaseTextBlock(); +} + +bool +_EditFieldImpl::IsBlocked(void) const +{ + return __pEdit->IsBlocked(); +} + +result +_EditFieldImpl::Copy(void) +{ + return __pEdit->CopyText(); +} + +result +_EditFieldImpl::Cut(void) +{ + return __pEdit->CutText(); +} + +result +_EditFieldImpl::Paste(void) +{ + return __pEdit->PasteText(); +} + +result +_EditFieldImpl::Remove(void) +{ + SysTryReturnResult(NID_UI_CTRL, (__pEdit->RemoveTextBlock() == E_SUCCESS), E_SYSTEM, "A system error has occurred"); + + return E_SUCCESS; +} + +bool +_EditFieldImpl::IsClipped(void) const +{ + return __pEdit->IsClipped(); +} + +result +_EditFieldImpl::SetTitleText(const String& title) +{ + SysTryReturnResult(NID_UI_CTRL, (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP) || + (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT), E_SYSTEM, + "The EditField has no title style.\n"); + + Variant variantTitle(title); + + return __pEdit->SetPropertyTitleText(variantTitle); +} + +String +_EditFieldImpl::GetTitleText(void) const +{ + return __pEdit->GetPropertyTitleText().ToString(); +} + +result +_EditFieldImpl::SetTitleTextColor(EditStatus status, const Color& color) +{ + result r = E_SUCCESS; + Variant variantColor(color); + + switch (status) + { + case EDIT_STATUS_NORMAL: + r = __pEdit->SetPropertyNormalTitleTextColor(variantColor); + break; + + case EDIT_STATUS_DISABLED: + r = __pEdit->SetPropertyDisabledTitleTextColor(variantColor); + break; + + case EDIT_STATUS_HIGHLIGHTED: + r = __pEdit->SetPropertyHighlightedTitleTextColor(variantColor); + break; + + case EDIT_STATUS_PRESSED: + r = __pEdit->SetPropertyPressedTitleTextColor(variantColor); + break; + + default: + r = E_INVALID_ARG; + break; + } + + return r; +} + +Color +_EditFieldImpl::GetTitleTextColor(EditStatus status) const +{ + Color color; + + switch (status) + { + case EDIT_STATUS_NORMAL: + color = __pEdit->GetPropertyNormalTitleTextColor().ToColor(); + break; + + case EDIT_STATUS_DISABLED: + color = __pEdit->GetPropertyDisabledTitleTextColor().ToColor(); + break; + + case EDIT_STATUS_HIGHLIGHTED: + color = __pEdit->GetPropertyHighlightedTitleTextColor().ToColor(); + break; + + case EDIT_STATUS_PRESSED: + color = __pEdit->GetPropertyPressedTitleTextColor().ToColor(); + break; + + default: + break; + } + + return color; +} + +result +_EditFieldImpl::SetOverlayKeypadCommandButton(CommandButtonPosition position, const String& text, int actionId) +{ + return __pEdit->SetKeypadCommandButton(position, text, actionId); +} + +String +_EditFieldImpl::GetOverlayKeypadCommandButtonText(CommandButtonPosition position) const +{ + return __pEdit->GetKeypadCommandButtonText(position); +} + +int +_EditFieldImpl::GetOverlayKeypadCommandButtonActionId(CommandButtonPosition position) const +{ + return __pEdit->GetKeypadCommandButtonActionId(position); +} + +result +_EditFieldImpl::SetCurrentLanguage(LanguageCode languageCode) +{ + return __pEdit->SetCurrentLanguage(languageCode); +} + +result +_EditFieldImpl::GetCurrentLanguage(LanguageCode& language) const +{ + return __pEdit->GetCurrentLanguage(language); +} + +result +_EditFieldImpl::OnBoundsChanged(const Rectangle& oldRect, const Rectangle& newRect) +{ + return E_SUCCESS; +} + +void +_EditFieldImpl::OnTextValueChanged(const _Control& source) +{ + if (__pPublicTextEvent != null) + { + IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CHANGED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pPublicTextEvent->Fire(*pEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnTextValueChangeCanceled(const _Control& source) +{ + if (__pPublicTextEvent != null) + { + IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CANCELED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pPublicTextEvent->Fire(*pEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnActionPerformed(const _Control& source, int actionId) +{ + if (__pPublicActionEvent != null) + { + IEventArg* pActionEventArg = _PublicActionEvent::CreateActionEventArgN(actionId); + SysTryReturnVoidResult(NID_UI_CTRL, pActionEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicActionEvent->Fire(*pActionEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnLinkClicked(_Control& source, const String& text, Utility::LinkType linkType, + const String& link) +{ + if (__pPublicLinkEvent != null) + { + IEventArg* pLinkEventArg = _PublicLinkEvent::CreateLinkEventArgN(text, linkType, link); + SysTryReturnVoidResult(NID_UI_CTRL, pLinkEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicLinkEvent->Fire(*pLinkEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnTextBlockSelected(_Control& source, int start, int end) +{ + if (__pPublicTextBlockEvent != null) + { + IEventArg* pTextBlockEventArg = _PublicTextBlockEvent::CreateTextBlockEventArgN(start, end); + SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _TextBlockEventArg."); + + __pPublicTextBlockEvent->Fire(*pTextBlockEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnKeypadWillOpen(void) +{ + if (__pPublicKeypadEvent) + { + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_ENTER, KEYPAD_EVENT_STATUS_CREATED); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnKeypadOpened(void) +{ + if (__pPublicKeypadEvent) + { + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_ENTER, KEYPAD_EVENT_STATUS_OPEN); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnKeypadClosed(void) +{ + if (__pPublicKeypadEvent) + { + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_ENTER, KEYPAD_EVENT_STATUS_CLOSE); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnKeypadBoundsChanged(void) +{ + if (__pPublicKeypadEvent) + { + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_ENTER, KEYPAD_EVENT_STATUS_BOUNDS_CHANGED); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnKeypadActionPerformed(CoreKeypadAction keypadAction) +{ + if (__pPublicKeypadEvent) + { + KeypadAction onKeypadAction = KEYPAD_ACTION_ENTER; + switch (keypadAction) + { + case CORE_KEYPAD_ACTION_ENTER: + onKeypadAction = KEYPAD_ACTION_ENTER; + break; + + case CORE_KEYPAD_ACTION_GO: + onKeypadAction = KEYPAD_ACTION_GO; + break; + + case CORE_KEYPAD_ACTION_NEXT: + onKeypadAction = KEYPAD_ACTION_NEXT; + break; + + case CORE_KEYPAD_ACTION_SEND: + onKeypadAction = KEYPAD_ACTION_SEND; + break; + + case CORE_KEYPAD_ACTION_SEARCH: + onKeypadAction = KEYPAD_ACTION_SEARCH; + break; + + case CORE_KEYPAD_ACTION_LOGIN: + onKeypadAction = KEYPAD_ACTION_LOGIN; + break; + + case CORE_KEYPAD_ACTION_SIGN_IN: + onKeypadAction = KEYPAD_ACTION_SIGN_IN; + break; + + case CORE_KEYPAD_ACTION_JOIN: + onKeypadAction = KEYPAD_ACTION_JOIN; + break; + + case CORE_KEYPAD_ACTION_DONE: + onKeypadAction = KEYPAD_ACTION_DONE; + break; + + default: + break; + } + + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), onKeypadAction, KEYPAD_EVENT_STATUS_ENTERACTION); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnLanguageChanged(LanguageCode oldLanguage, LanguageCode newLanguage) +{ + if (__pPublicLanguageEvent) + { + IEventArg* pKLanguageEventArg = _PublicLanguageEvent::CreateLanguageEventArgN(GetPublic(), oldLanguage, newLanguage); + SysTryReturnVoidResult(NID_UI_CTRL, pKLanguageEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _KeypadEventArg."); + + __pPublicLanguageEvent->Fire(*pKLanguageEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnOverlayControlCreated(const _Control& source) +{ + if (__pPublicScrollPanelEvent != null) + { + IEventArg* pEventArg = _PublicScrollPanelEvent::CreateScrollPanelEventArgN(OVERLAY_CONTROL_CREATED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicScrollPanelEvent->Fire(*pEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnOverlayControlOpened(const _Control& source) +{ + if (__pPublicScrollPanelEvent != null) + { + IEventArg* pEventArg = _PublicScrollPanelEvent::CreateScrollPanelEventArgN(OVERLAY_CONTROL_OPENED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicScrollPanelEvent->Fire(*pEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnOverlayControlClosed(const _Control& source) +{ + if (__pPublicScrollPanelEvent != null) + { + IEventArg* pEventArg = _PublicScrollPanelEvent::CreateScrollPanelEventArgN(OVERLAY_CONTROL_CLOSED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicScrollPanelEvent->Fire(*pEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_EditFieldImpl::OnOtherControlSelected(const _Control& source) +{ + if (__pPublicScrollPanelEvent != null) + { + IEventArg* pEventArg = _PublicScrollPanelEvent::CreateScrollPanelEventArgN(OTHER_CONTROL_SELECTED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicScrollPanelEvent->Fire(*pEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +class _EditFieldMaker + : public _UiBuilderControlMaker +{ +public: + _EditFieldMaker(_UiBuilder* pUiBuilder) + : _UiBuilderControlMaker(pUiBuilder){}; + virtual ~_EditFieldMaker(){}; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* pUiBuilder) + { + _EditFieldMaker* pEditFieldMaker = new (std::nothrow) _EditFieldMaker(pUiBuilder); + return pEditFieldMaker; + }; +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + EditField* pEditField = null; + Rectangle rect; + + String elementString; + bool showTitle = false; + GroupStyle groupStyle = GROUP_STYLE_NONE; + InputStyle inputStyle = INPUT_STYLE_FULLSCREEN; + int limitLength = EDIT_FIELD_DEFAULT_LIMIT_LENGTH; + KeypadAction keypadAction = KEYPAD_ACTION_ENTER; + bool lowerCaseMode = false; + HorizontalAlignment horizontalAlignment = ALIGNMENT_LEFT; + bool viewModeEnable = false; + bool commandButtonVisible = false; + int fontSize = 0; + Color color; + int opacity = EDIT_COLOR_OPACITY; + EditFieldStyle editFieldStyle = EDIT_FIELD_STYLE_NORMAL; + EditFieldTitleStyle editFieldTitleStyle = EDIT_FIELD_TITLE_STYLE_NONE; + bool clearButtonEnable = false; + bool newConstructEnable = false; + int horizontalMargin = 0; + int verticalMargin = 0; + EllipsisPosition ellipsisPosition = ELLIPSIS_POSITION_END; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pEditField = new (std::nothrow) EditField(); + if (pEditField == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + String styleString; + styleString = pControlProperty->GetStyle(); + + if (pControl->GetElement(L"inputStyle", elementString)) + { + if (elementString.Equals(L"INPUT_STYLE_OVERLAY", false)) + { + inputStyle = INPUT_STYLE_OVERLAY; + } + else + { + inputStyle = INPUT_STYLE_FULLSCREEN; + } + + if (pControl->GetElement(L"commandButtonVisible", elementString)) + { + if (elementString.Equals(L"true", false)) + { + commandButtonVisible = true; + } + + } + else + { + commandButtonVisible = true; + } + } + + if (pControl->GetElement(L"limitLength", elementString)) + { + Base::Integer::Parse(elementString, limitLength); + } + if (pControl->GetElement(L"GroupStyle", elementString)) + { + if (elementString.Equals(L"GROUP_STYLE_NONE", false)) + { + groupStyle = GROUP_STYLE_NONE; + } + if (elementString.Equals(L"GROUP_STYLE_SINGLE", false)) + { + groupStyle = GROUP_STYLE_SINGLE; + } + if (elementString.Equals(L"GROUP_STYLE_TOP", false)) + { + groupStyle = GROUP_STYLE_TOP; + } + if (elementString.Equals(L"GROUP_STYLE_MIDDLE", false)) + { + groupStyle = GROUP_STYLE_MIDDLE; + } + if (elementString.Equals(L"GROUP_STYLE_BOTTOM", false)) + { + groupStyle = GROUP_STYLE_BOTTOM; + } + } + + if (pControl->GetElement(L"titleStyle", elementString)) + { + newConstructEnable = true; + + if (elementString.Equals(L"EDIT_FIELD_TITLE_STYLE_NONE", false)) + { + editFieldTitleStyle = EDIT_FIELD_TITLE_STYLE_NONE; + } + else if (elementString.Equals(L"EDIT_FIELD_TITLE_STYLE_INNER", false)) + { + editFieldTitleStyle = EDIT_FIELD_TITLE_STYLE_INNER; + } + else if (elementString.Equals(L"EDIT_FIELD_TITLE_STYLE_TOP", false)) + { + editFieldTitleStyle = EDIT_FIELD_TITLE_STYLE_TOP; + } + } + + if (pControl->GetElement(L"enableClear", elementString)) + { + if (elementString.Equals(L"true", false)) + { + clearButtonEnable = true; + } + } + + if (styleString.Equals(L"EDIT_FIELD_STYLE_PASSWORD", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_PASSWORD; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_NORMAL_SMALL", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_NORMAL_SMALL; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_PASSWORD_SMALL", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_PASSWORD_SMALL; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_EMAIL", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_EMAIL; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_URL", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_URL; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_EMAIL_SMALL", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_EMAIL_SMALL; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_URL_SMALL", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_URL_SMALL; + } + else + { + editFieldStyle = EDIT_FIELD_STYLE_NORMAL; + } + + if (styleString.Equals(L"EDIT_FIELD_STYLE_NUMBER", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_NUMBER; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_NUMBER_SMALL", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_NUMBER_SMALL; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_PHONE_NUMBER", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_PHONE_NUMBER; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_PHONE_NUMBER_SMALL", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_PHONE_NUMBER_SMALL; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_PASSWORD_NUMBER", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_PASSWORD_NUMBER; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_PASSWORD_NUMBER_SMALL", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_PASSWORD_NUMBER_SMALL; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_IP_V4", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_IP_V4; + } + else if (styleString.Equals(L"EDIT_FIELD_STYLE_IP_V4_SMALL", false)) + { + editFieldStyle = EDIT_FIELD_STYLE_IP_V4_SMALL; + } + + if (newConstructEnable) + { + r = pEditField->Construct(rect, editFieldStyle, inputStyle, editFieldTitleStyle, clearButtonEnable, limitLength, groupStyle); + } + else + { + r = pEditField->Construct(rect, editFieldStyle, inputStyle, showTitle, limitLength, groupStyle); + } + + if (r != E_SUCCESS) + { + delete pEditField; + pEditField = null; + + return null; + } + + if (commandButtonVisible == false) + { + pEditField->SetOverlayKeypadCommandButtonVisible(false); + } + + if (pControl->GetElement(L"text", elementString)) + { + r = pEditField->SetText(elementString); + } + if (pControl->GetElement(L"guideText", elementString)) + { + pEditField->SetGuideText(elementString); + } + if (pControl->GetElement(L"titleText", elementString)) + { + r = pEditField->SetTitleText(elementString); + } + if (pControl->GetElement(L"keypadEnabled", elementString) || pControl->GetElement(L"KeypadEnabled", elementString)) + { + if (elementString.Equals(L"true", false)) + { + pEditField->SetKeypadEnabled(true); + } + else + { + pEditField->SetKeypadEnabled(false); + } + } + else + pEditField->SetKeypadEnabled(true); + + if (pControl->GetElement(L"keypadAction", elementString)) + { + if (elementString.Equals(L"KEYPAD_ACTION_ENTER", false)) + { + keypadAction = KEYPAD_ACTION_ENTER; + } + else if (elementString.Equals(L"KEYPAD_ACTION_GO", false)) + { + keypadAction = KEYPAD_ACTION_GO; + } + else if (elementString.Equals(L"KEYPAD_ACTION_NEXT", false)) + { + keypadAction = KEYPAD_ACTION_NEXT; + } + else if (elementString.Equals(L"KEYPAD_ACTION_SEND", false)) + { + keypadAction = KEYPAD_ACTION_SEND; + } + else if (elementString.Equals(L"KEYPAD_ACTION_SEARCH", false)) + { + keypadAction = KEYPAD_ACTION_SEARCH; + } + else if (elementString.Equals(L"KEYPAD_ACTION_LOGIN", false)) + { + keypadAction = KEYPAD_ACTION_LOGIN; + } + else if (elementString.Equals(L"KEYPAD_ACTION_SIGN_IN", false)) + { + keypadAction = KEYPAD_ACTION_SIGN_IN; + } + else if (elementString.Equals(L"KEYPAD_ACTION_JOIN", false)) + { + keypadAction = KEYPAD_ACTION_JOIN; + } + else if (elementString.Equals(L"KEYPAD_ACTION_DONE", false)) + { + keypadAction = KEYPAD_ACTION_DONE; + } + + r = pEditField->SetKeypadAction(keypadAction); + } + + if (pControl->GetElement(L"textHorizontalAlignment", elementString)) + { + if (elementString.Equals(L"ALIGNMENT_LEFT", false)) + { + horizontalAlignment = ALIGNMENT_LEFT; + } + else if (elementString.Equals(L"ALIGNMENT_CENTER", false)) + { + horizontalAlignment = ALIGNMENT_CENTER; + } + else if (elementString.Equals(L"ALIGNMENT_RIGHT", false)) + { + horizontalAlignment = ALIGNMENT_RIGHT; + } + + r = pEditField->SetTextAlignment(horizontalAlignment); + } + + if (pControl->GetElement(L"lowerCaseMode", elementString)) + { + if (elementString.Equals(L"true", false)) + { + lowerCaseMode = true; + } + else + { + lowerCaseMode = false; + } + + pEditField->SetLowerCaseModeEnabled(lowerCaseMode); + } + + if (pControl->GetElement(L"textSize", elementString)) + { + Base::Integer::Parse(elementString, fontSize); + _ICoordinateSystemTransformer* pTransform = GetTransformer(); + if (pTransform) + { + fontSize = pTransform->Transform(fontSize); + } + r = pEditField->SetTextSize(fontSize); + } + + if (pControl->GetElement(L"viewMode", elementString)) + { + if (elementString.Equals(L"true", false)) + { + viewModeEnable = true; + r = pEditField->SetViewModeEnabled(viewModeEnable); + } + } + + if (pControl->GetElement(L"normalBGBitmapPath", elementString)) + { + Bitmap* pressedBGBitmap = null; + pressedBGBitmap = LoadBitmapN(elementString); + if (pressedBGBitmap != null) + { + r = pEditField->SetBackgroundBitmap(EDIT_STATUS_NORMAL, *pressedBGBitmap); + delete pressedBGBitmap; + pressedBGBitmap = null; + } + } + + if (pControl->GetElement(L"disabledBGBitmapPath", elementString)) + { + Bitmap* disalbedBGBitmap = null; + disalbedBGBitmap = LoadBitmapN(elementString); + if (disalbedBGBitmap != null) + { + r = pEditField->SetBackgroundBitmap(EDIT_STATUS_DISABLED, *disalbedBGBitmap); + delete disalbedBGBitmap; + disalbedBGBitmap = null; + } + } + + if (pControl->GetElement(L"highlightedBGBitmapPath", elementString)) + { + Bitmap* highlightedBGBitmap = null; + highlightedBGBitmap = LoadBitmapN(elementString); + if (highlightedBGBitmap != null) + { + r = pEditField->SetBackgroundBitmap(EDIT_STATUS_HIGHLIGHTED, *highlightedBGBitmap); + delete highlightedBGBitmap; + highlightedBGBitmap = null; + } + } + + if (pControl->GetElement(L"pressedBGBitmapPath", elementString)) + { + Bitmap* pressedBGBitmap = null; + pressedBGBitmap = LoadBitmapN(elementString); + if (pressedBGBitmap != null) + { + r = pEditField->SetBackgroundBitmap(EDIT_STATUS_PRESSED, *pressedBGBitmap); + delete pressedBGBitmap; + pressedBGBitmap = null; + } + } + + if (pControl->GetElement(L"normalColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"normalColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditField->SetColor(EDIT_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"pressedColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"pressedColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditField->SetColor(EDIT_STATUS_PRESSED, color); + } + + if (pControl->GetElement(L"highlightedColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"highlightedColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"disabledColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"disabledColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditField->SetColor(EDIT_STATUS_DISABLED, color); + } + + opacity = 100; + if (pControl->GetElement(L"guideTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditField->SetGuideTextColor(color); + } + + if (pControl->GetElement(L"normalTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditField->SetTextColor(EDIT_TEXT_COLOR_NORMAL, color); + } + + if (pControl->GetElement(L"disabledTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditField->SetTextColor(EDIT_TEXT_COLOR_DISABLED, color); + } + + if (pControl->GetElement(L"highlightedTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditField->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"linkTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditField->SetTextColor(EDIT_TEXT_COLOR_LINK, color); + } + + if (pControl->GetElement(L"horizontalMargin", elementString)) + { + Base::Integer::Parse(elementString, horizontalMargin); + r = pEditField->SetMargin(EDIT_MARGIN_TYPE_HORIZONTAL, horizontalMargin); + } + + if (pControl->GetElement(L"verticalMargin", elementString)) + { + Base::Integer::Parse(elementString, verticalMargin); + r = pEditField->SetMargin(EDIT_MARGIN_TYPE_VERTICAL, verticalMargin); + } + + if (pControl->GetElement(L"titleTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pEditField->SetTitleTextColor(EDIT_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"ellipsisPosition", elementString)) + { + if (elementString.Equals(L"ELLIPSIS_POSITION_START", false)) + { + ellipsisPosition = ELLIPSIS_POSITION_START; + } + else if (elementString.Equals(L"ELLIPSIS_POSITION_MIDDLE", false)) + { + ellipsisPosition = ELLIPSIS_POSITION_MIDDLE; + } + else + { + ellipsisPosition = ELLIPSIS_POSITION_END; + } + + r = pEditField->SetEllipsisPosition(ellipsisPosition); + } + + return pEditField; + } +}; // _EditFieldMaker + +_EditFieldRegister::_EditFieldRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"EditField", _EditFieldMaker::GetInstance); +} + +_EditFieldRegister::~_EditFieldRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"EditField"); +} +static _EditFieldRegister EditFieldRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditModel.cpp b/src/ui/controls/FUiCtrl_EditModel.cpp new file mode 100644 index 0000000..c8c082c --- /dev/null +++ b/src/ui/controls/FUiCtrl_EditModel.cpp @@ -0,0 +1,293 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditModel.cpp + * @brief This is the implementation file for the _EditModel class. + */ + +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_EditModel.h" + +using namespace Tizen::Base; +using namespace Tizen::Locales; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_EditModel::_EditModel(void) + : __autoLinkMask(Utility::LINK_TYPE_NONE) + , __keypadActionEnabled(true) + , __viewModeEnabled(false) + , __keypadStyle(KEYPAD_STYLE_NORMAL) + , __keypadEnabled(false) + , __isLowerCase(false) + , __isTextPredictionEnabled(true) + , __keypadAction(CORE_KEYPAD_ACTION_ENTER) + , __enablePredictiveAutoResizing(false) + , __maxLineCount(-1) + , __languageCode(LANGUAGE_ENG) + , __initialKeypadLanguageCode(LANGUAGE_INVALID) + , __leftCommandButtonActionId(100) + , __rightCommandButtonActionId(101) + , __leftCommandButtonText() + , __rightCommandButtonText() +{ + GET_STRING_CONFIG(IDS_COM_SK_DONE, __leftCommandButtonText); + GET_STRING_CONFIG(IDS_COM_SK_CANCEL, __rightCommandButtonText); +} + +_EditModel::~_EditModel(void) +{ +} + +result +_EditModel::SetAutoLinkMask(unsigned long autoLinks) +{ + result r = E_SUCCESS; + + __autoLinkMask = autoLinks; + + return r; +} + +unsigned long +_EditModel::GetAutoLinkMask(void) const +{ + return __autoLinkMask; +} + +bool +_EditModel::IsViewModeEnabled(void) const +{ + return __viewModeEnabled; +} + +result +_EditModel::SetViewModeEnabled(bool enable) +{ + result r = E_SUCCESS; + + __viewModeEnabled = enable; + + return r; +} + +result +_EditModel::SetKeypadActionEnabled(bool enable) +{ + result r = E_SUCCESS; + + __keypadActionEnabled = enable; + + return r; +} + +bool +_EditModel::IsKeypadActionEnabled(void) const +{ + return __keypadActionEnabled; +} + +CoreKeypadAction +_EditModel::GetKeypadAction(void) const +{ + return __keypadAction; +} + +result +_EditModel::SetKeypadAction(CoreKeypadAction keypadAction) +{ + result r = E_SUCCESS; + + __keypadAction = keypadAction; + + return r; +} + +result +_EditModel::SetCurrentLanguage(LanguageCode languageCode) +{ + result r = E_SUCCESS; + + __languageCode = languageCode; + + return r; +} + +result +_EditModel::GetCurrentLanguage(LanguageCode& language) const +{ + result r = E_SUCCESS; + + language = __languageCode; + + return r; +} + +result +_EditModel::SetInitialKeypadLanguage(LanguageCode languageCode) +{ + result r = E_SUCCESS; + + __initialKeypadLanguageCode = languageCode; + + return r; +} + +result +_EditModel::GetInitialKeypadLanguage(LanguageCode& language) const +{ + result r = E_SUCCESS; + + language = __initialKeypadLanguageCode; + + return r; +} + +result +_EditModel::SetTextPredictionEnabled(bool enable) +{ + __isTextPredictionEnabled = enable; + + return E_SUCCESS; +} + +bool +_EditModel::IsTextPredictionEnabled(void) const +{ + return __isTextPredictionEnabled; +} + +void +_EditModel::SetKeypadEnabled(bool enable) +{ + __keypadEnabled = enable; + + return; +} + +bool +_EditModel::IsKeypadEnabled(void) const +{ + return __keypadEnabled; +} + +void +_EditModel::SetLowerCaseModeEnabled(bool enable) +{ + __isLowerCase = enable; + + return; +} + +bool +_EditModel::IsLowerCaseModeEnabled(void) const +{ + return __isLowerCase; +} + +KeypadStyle +_EditModel::GetKeypadStyle(void) const +{ + return __keypadStyle; +} + +result +_EditModel::SetKeypadStyle(KeypadStyle keypadStyle) +{ + __keypadStyle = keypadStyle; + return E_SUCCESS; +} + +result +_EditModel::SetAutoResizingEnabled(bool enable) +{ + __enablePredictiveAutoResizing = enable; + return E_SUCCESS; +} + +bool +_EditModel::IsAutoResizingEnabled(void) const +{ + return __enablePredictiveAutoResizing; +} + +void +_EditModel::SetMaxLineCount(int maxLineCount) +{ + __maxLineCount = maxLineCount; + + return; +} + + +int +_EditModel::GetMaxLineCount(void) const +{ + return __maxLineCount; +} + +result +_EditModel::SetCommandButtonItem(CommandButtonPosition buttonPosition, int actionId, const String& text) +{ + result r = E_SUCCESS; + if (buttonPosition == COMMAND_BUTTON_POSITION_LEFT) + { + __leftCommandButtonActionId = actionId; + __leftCommandButtonText = text; + } + else + { + __rightCommandButtonActionId = actionId; + __rightCommandButtonText = text; + } + + return r; +} + +String +_EditModel::GetKeypadCommandButtonText(CommandButtonPosition position) const +{ + if (position == COMMAND_BUTTON_POSITION_LEFT) + { + return __leftCommandButtonText; + } + else + { + return __rightCommandButtonText; + } +} + +int +_EditModel::GetKeypadCommandButtonActionId(CommandButtonPosition position) const +{ + if (position == COMMAND_BUTTON_POSITION_LEFT) + { + return __leftCommandButtonActionId; + } + else + { + return __rightCommandButtonActionId; + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditPresenter.cpp b/src/ui/controls/FUiCtrl_EditPresenter.cpp new file mode 100644 index 0000000..3cd91aa --- /dev/null +++ b/src/ui/controls/FUiCtrl_EditPresenter.cpp @@ -0,0 +1,8322 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditPresenter.cpp + * @brief This is the implementation file for the _EditPresenter class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_Clipboard.h" +#include "FUi_ClipboardItem.h" +#include "FUi_Control.h" +#include "FUi_ControlImpl.h" +#include "FUi_ControlManager.h" +#include "FUi_ResourceManager.h" +#include "FUi_UiEventManager.h" +#include "FUi_UiNotificationEvent.h" +#include "FUiAnim_VisualElement.h" +#include "FUiAnim_EflNode.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_ContextMenu.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_EditCopyPasteManager.h" +#include "FUiCtrl_EditPresenter.h" +#include "FUiCtrl_FlickAnimation.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Scroll.h" +#include "FUiCtrl_ScrollPanel.h" +#include "FUiCtrl_Toolbar.h" +#include "FUiCtrl_TableView.h" + + +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; +using namespace Tizen::Media; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Base; +using namespace Tizen::Base::Utility; +using namespace Tizen::Base::Collection; +using namespace Tizen::Locales; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ +const int EDIT_PASSWORD_TIMER_PERIOD = 1000; +const int EDIT_CURSOR_TIMER_PERIOD = 600; +const int MAX_LINE_NUMBER = 100; +const int MAX_FLEXIBLE_HEIGHT_VERTICAL_MODE = 4000; +const int MAX_FLEXIBLE_HEIGHT_HORIZONTAL_MODE = 2500; +const int EDIT_FLICK_SCROLL_TIMER_INTERVAL = 10; +const float DIRECTION_DECISION_RATIO = 1.3; +const float HORIZONTAL_DECISION_RATIO = 1.5; +const int MOVE_SKIP_DECISION_RANGE = 5; +const int TITLE_SLIDING_TIME = 800; + +const int LANGUAGE_CODE_START = 0; +const int LANGUAGE_CODE_MAX = 2; + +bool _EditPresenter::__isKeypadExist = false; +int _EditPresenter::__initialParentHeight = 0; +bool _EditPresenter::__isPanelBoundsChanging = false; + +_EditAnimationProvider::_EditAnimationProvider(void) +{ +} + +_EditAnimationProvider::~_EditAnimationProvider(void) +{ +} + +VisualElementAnimation* +_EditAnimationProvider::CreateAnimationForProperty(VisualElement& source, const String& property) +{ + VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(source, property); + if (pAnimation != null) + { + pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut")); + pAnimation->SetDuration(ANIMATION_DURATION); + } + + return pAnimation; +} + +_EditPresenter::_EditPresenter(void) + : __pEdit(null) + , __pTextBuffer(null) + , __pTextString(null) + , __pEditModel(null) + , __pScrollBar(null) + , __pScrollEffect(null) + , __limitLength(0) + , __horizontalAlignment(ALIGNMENT_LEFT) + , __isScrollBarVisible(false) + , __scrollBarBounds() + , __initialBounds() + , __previousScrollBarPos(0) + , __previousScrollBarMaxPos(0) + , __pActionEventListener(null) + , __pCursorTimer(null) + , __pFlickAnimationTimer(null) + , __pPasswordTimer(null) + , __pTitleSlidingTimer(null) + , __pFont(null) + , __pCursorVisualElement(null) + , __pTextVisualElement(null) + , __pCopyPasteManager(null) + , __pFlickAnimation(null) + , __pParentForm(null) + , __pFullscreenKeypad(null) + , __pParentPanel(null) + , __pCommandButton(null) + , __pInputConnection(null) + , __isInputConnectionBound(false) + , __guideText() + , __titleText() + , __pressedPoint() + , __isCopyPastePopupMoving(false) + , __pressedAbsolutePoint() + , __clearIconBounds() + , __textBoxBounds() + , __textObjectBounds() + , __titleBounds() + , __clientBounds() + , __previousCursorBounds() + , __keypadBounds() + , __pTextObject(null) + , __pGuideTextObject(null) + , __pTitleTextObject(null) + , __titleSlidingAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT) + , __textObjectWrap(TEXT_OBJECT_WRAP_TYPE_WORD) + , __isTextBlocked(false) + , __isGuideTextColorChanged(false) + , __isKeypadCommandButtonVisible(false) + , __isKeypadHiding(false) + , __isTextComposing(false) + , __isCopyPastePopupVisible(false) + , __isCursorChanged(false) + , __isCursorInitialized(false) + , __isCursorDisabled(false) + , __isInitialized(false) + , __isMovingCursorByTouchMove(false) + , __isTouchMoving(false) + , __isTouchPressed(false) + , __isClearIconPressed(false) + , __isCursorOpaque(false) + , __isTouchReleaseSkipped(false) + , __isViewerModeEnabled(false) + , __isKeypadNormalNumberStyleEnabled(false) + , __isTextCompositionFinished(false) + , __isFlexibleHeightFrozen(false) + , __isKeypadShowing(false) + , __blockStartPos(0) + , __cursorPos(0) + , __maximumFlexibleHeight(-1) + , __prevTotalTextHeight(-1) + , __textLength(0) + , __composingTextLength(0) + , __titleWidth(-1) + , __verticalMargin(-1) + , __isUSBKeyboardConnected(false) + , __rotated(false) + , __isCutLinkParserEnabled(false) + , __echoChar('*') + , __footerVisibleStatus(EDIT_FOOTER_VISIBLE_STATUS_NONE) + , __ContentTextStatus(EDIT_TEXT_STATUS_COMPOSE_NON) + , __pEditVEDelegator(null) + , __isAutoShrinkEnabled(false) + , __groupStyle(GROUP_STYLE_NONE) + , __isFontInitialized(false) + , __contentFontSize(0) + , __titleFontSize(0) + , __contentFontStyle(FONT_STYLE_PLAIN) + , __contentTextStyle(TEXT_BOX_TEXT_STYLE_NORMAL) + , __titleFontFaceName("") + , __isSearchBar(false) + , __isKeypadClosedEventSkipped(false) + , __pCurrentFrame(null) +{ +} + +void +_EditPresenter::OnInputConnectionPanelShowStateChanged(InputConnection& source, InputPanelShowState showState) + { + if (showState == INPUT_PANEL_SHOW_STATE_SHOW)// 1. bounded 2.bounded&rotate + { + __isKeypadShowing = false; + + CheckUSBKeyboardStatus(); + CheckKeypadStatus(); + + if (__isInputConnectionBound) + { + if (__isKeypadCommandButtonVisible) + { + SetFooterVisible(false); + } + + ChangeLayoutInternal(__pEdit->GetOrientation()); + AdjustParentPanelHeight(false); + + if (__pCommandButton) + { + __pCommandButton->Invalidate(); + } + + if (__pParentForm) + { + ScrollPanelToTop(true); + ScrollPanelToCursorPosition(); + __pParentForm->Draw(); + } + } + + if (__isUSBKeyboardConnected && !__isKeypadCommandButtonVisible) + { + __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED); + } + + __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN); + __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_OPENED); + } + else if (showState == INPUT_PANEL_SHOW_STATE_HIDE)// 1.unbound 2.bounded&usb off -> usb on 3.Flick keypad hide + { + CheckUSBKeyboardStatus(); + CheckKeypadStatus(); + + if (__isCopyPastePopupVisible) + { + InitializeCopyPasteManager(); + __pTextObject->SetBlock(false); + __isTextBlocked = false; + } + + if (__isInputConnectionBound && __isUSBKeyboardConnected) // hide callback from external condition(usb mode off->on) + { + ChangeLayoutInternal(__pEdit->GetOrientation()); + AdjustParentPanelHeight(true); + + if (__pCommandButton) + { + __pCommandButton->Invalidate(); + } + + _Form* pParentForm = GetParentForm(); + if (pParentForm) + { + __pParentForm->Draw(); + } + } + else + { + _Form* pParentForm = GetParentForm(); + if (__isInputConnectionBound)// keypad drag down, auto keypad hide by clipboard switch + { + if (__pCommandButton && __pCommandButton->GetVisibleState() == true) + { + SetFooterVisible(true);// must be called ahead of DeflateClientRectHeight + __pCommandButton->SetVisibleState(false); + } + + if ( IsFocused() && pParentForm && __pEdit->IsFullScreenKeypadEdit() == false) + { + pParentForm->SetFocused(); + } + } + else// called by focus move or HideKeypad() api call + { + SetKeypadClosedEventSkipped(true);//it will adjust only fullscreen keypad edit. + } + + AdjustParentPanelHeight(true); + + __isInputConnectionBound = false; + + __pEdit->DetachScrollPanelEvent(); + + if (pParentForm) + { + pParentForm->DeflateClientRectHeight(0); + __pParentForm->Draw(); + } + } + + __isKeypadHiding = false; + + SetKeypadBounds(Rectangle()); + + if (!__isKeypadClosedEventSkipped) + { + __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE); + __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CLOSED); + } + __isKeypadClosedEventSkipped = false; + } + + return; + } + +void +_EditPresenter::OnInputConnectionPanelLanguageChanged(InputConnection& source, LanguageCode language) +{ + LanguageCode oldLanguageCode; + __pEditModel->GetCurrentLanguage(oldLanguageCode); + + __pEditModel->SetCurrentLanguage(language); + __pEdit->SendLanguageEvent(oldLanguageCode, language); + + return; +} + +void +_EditPresenter::OnInputConnectionPanelBoundsChanged(InputConnection& source, const Rectangle& bounds) +{ + CheckUSBKeyboardStatus(); + CheckKeypadStatus(); + + if ((__isUSBKeyboardConnected == false) && (IsKeypadExist() == false)) + { + return; + } + + ChangeLayoutInternal(__pEdit->GetOrientation()); + AdjustParentPanelHeight(false, true); + if (__pParentForm) + { + __pParentForm->Draw(); + ScrollPanelToCursorPosition(); + } + + __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED); + + return; +} + +void +_EditPresenter::OnInputConnectionTextPredictionShowStateChanged(InputConnection& source, bool isShown) +{ + CheckUSBKeyboardStatus(); + CheckKeypadStatus(); + + if ((__isUSBKeyboardConnected == false) && (IsKeypadExist() == false)) + { + return; + } + + ChangeLayoutInternal(__pEdit->GetOrientation()); + AdjustParentPanelHeight(false, true); + if (__pParentForm) + { + __pParentForm->Draw(); + ScrollPanelToCursorPosition(); + } + + __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED); + + return; +} + +void +_EditPresenter::OnInputConnectionTextPredictionBoundsChanged(InputConnection& source, const Rectangle& bounds) +{ + return; +} + +void +_EditPresenter::OnInputConnectionTextCommitted(InputConnection& source, const String& committedText) +{ + OnTextCommitted(committedText); + + return; +} + +void +_EditPresenter::OnTextCommitted(const String& commitText) +{ + bool isTextComposingFinished = false; + + if (IsViewModeEnabled() == true) + { + return; + } + + if (IsBlocked() == true) + { + int start = 0; + int end = 0; + GetBlockRange(start, end); + __isFlexibleHeightFrozen = true; + DeleteText(start, end); + __isFlexibleHeightFrozen = false; + ReleaseTextBlock(); + } + + if (__isCopyPastePopupVisible) + { + InitializeCopyPasteManager(); + } + + int textLength = commitText.GetLength(); + int compositionStart = __cursorPos - textLength; + + if (__isTextComposing == true) + { + __isFlexibleHeightFrozen = true; + DeleteText(__cursorPos-__composingTextLength, __cursorPos); + __isFlexibleHeightFrozen = false; + + __isTextComposing = false; + __composingTextLength = 0; + isTextComposingFinished = true; + } + + if (__ContentTextStatus != EDIT_TEXT_STATUS_COMPOSE_NON) + { + __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON; + } + + if (__pPasswordTimer) + { + ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar); + StopPasswordTimer(); + } + + char enterText1[2] = {'\n', }; + char enterText2[2] = {'\r', }; + + if (commitText == enterText1 || commitText == enterText2) + { + CoreKeypadAction keypadaction = GetKeypadAction(); + + __pEdit->SendKeypadEvent(keypadaction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION); + if (keypadaction != CORE_KEYPAD_ACTION_ENTER) + { + return; + } + + if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) + { + return; + } + } + + char tapText[2] = {'\t', }; + if (commitText == tapText) + { + return; + } + + // Limitation Protect + String insetText = commitText; + int currentLength = GetTextLength(); + int totalLength = currentLength + textLength; + int excessCharacterLength = totalLength - __limitLength; + + if (excessCharacterLength >= 0) + { + textLength -= excessCharacterLength; + if (textLength > 0) + { + insetText.Remove(textLength, excessCharacterLength); + } + else + { + textLength = 0; + } + } + + InsertTextAt(__cursorPos, insetText); + + ScrollPanelToCursorPosition(); + + if ((__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && isTextComposingFinished) + { + ReplaceTextIntoPasswordHyphenString(); + } + + if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false) + { + DrawText(); + } + + ChangePasswordToEchoCharacter((compositionStart + textLength), textLength); + + __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED); + + return; +} + +void +_EditPresenter::OnInputConnectionComposingTextChanged(InputConnection& source, const String& composingText, int cursorPosition) +{ + OnComposingTextChanged(composingText, cursorPosition); + + return; +} + +void +_EditPresenter::OnComposingTextChanged(const String& composingText, int cursorPosition) +{ + if (IsViewModeEnabled() == true) + { + return; + } + + if (IsBlocked() == true) + { + int start = 0; + int end = 0; + GetBlockRange(start, end); + __isFlexibleHeightFrozen = true; + DeleteText(start, end); + __isFlexibleHeightFrozen = false; + ReleaseTextBlock(); + } + + if (__isCopyPastePopupVisible) + { + InitializeCopyPasteManager(); + } + + int textLength = composingText.GetLength(); + + if (__isTextComposing == true) + { + int compositionStart = GetCursorPosition(); + + if (textLength == 0) + { + __isTextComposing = false; + + // FirstText Check Logic + int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex()); + int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine); + bool isFirstText = false; + if (firstTextIndex + 1 == __pTextObject->GetCursorIndex()) + { + isFirstText = true; + } + + DeleteText(compositionStart-__composingTextLength, compositionStart); + + if (isFirstText) + { + __isCursorChanged = false; + } + + __composingTextLength = 0; + + DrawText(); + + if (!__isCursorChanged) + { + __isCursorChanged = true; + } + __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED); + + return; + } + else + { + __isFlexibleHeightFrozen = true; + DeleteText(compositionStart-__composingTextLength, compositionStart); + __isFlexibleHeightFrozen = false; + } + } + + __composingTextLength = textLength; + if (__composingTextLength > 0) + { + __isTextComposing = true; + } + + // Limitation Protect + String insetText = composingText; + int currentLength = GetTextLength(); + int totalLength = currentLength + textLength; + int excessCharacterLength = totalLength - __limitLength; + + if (excessCharacterLength >= 0) + { + __composingTextLength -= excessCharacterLength; + if (__composingTextLength > 0) + { + insetText.Remove(__composingTextLength, excessCharacterLength); + } + else + { + __composingTextLength = 0; + } + } + + _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont); + SysTryReturnVoidResult(NID_UI_CTRL, fontImpl != null, E_SYSTEM, "[E_SYSTEM] fontImpl is null."); + fontImpl->SetUnderline(true); + __pTextObject->SetFont(__pFont, 0, 0); + + if (__composingTextLength > 0) + { + __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE; + } + + InsertTextAt(GetCursorPosition(), insetText); + + fontImpl->SetUnderline(false);// rollback to default content font + __pTextObject->SetFont(__pFont, 0, 0); + + ScrollPanelToCursorPosition(); + + DrawText(); + + __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED); + + return; +} + +void +_EditPresenter::DeleteSurroundingText(InputConnection& source, int offset, int charCount) +{ + OnSurroundingTextDeleted(offset, charCount); + + return; +} + +void +_EditPresenter::OnSurroundingTextDeleted(int offset, int charCount) +{ + int start = 0; + int end = 0; + + if (IsBlocked() == true) + { + GetBlockRange(start, end); + } + else + { + start = __cursorPos + offset; + if (start < 0) + { + return; + } + end = start + charCount; + if (end > __cursorPos) + { + return; + } + } + + DeleteText(start, end); + + if (__isCopyPastePopupVisible) + { + InitializeCopyPasteManager(); + } + + if (IsBlocked() == true) + { + ReleaseTextBlock(); + } + + DrawText(); + + __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED); + + return; +} + +void +_EditPresenter::GetPreviousText(InputConnection& source, String& text, int& cursorPosition) +{ + const int SURRONDING_TEXT_SIZE = 5; + int stringLength = 0; + String tempString; + + if (__cursorPos == 0) + { + text = null; + cursorPosition = 0; + } + else + { + if (__cursorPos < SURRONDING_TEXT_SIZE) + { + text = GetText(0, __cursorPos - 1); + } + else + { + text = GetText(__cursorPos-SURRONDING_TEXT_SIZE, __cursorPos - 1); + } + stringLength = text.GetLength(); + cursorPosition = stringLength; + } + + return; +} + +_EditPresenter::~_EditPresenter(void) +{ + Dispose(); +} + +result +_EditPresenter::Dispose(void) +{ + if (__pCurrentFrame) + { + __pCurrentFrame->RemoveFrameEventListener(*this); + __pCurrentFrame = null; + } + + if (__pCommandButton && __pCommandButton->GetVisibleState() == true) + { + __pCommandButton->SetVisibleState(false); + if (__isKeypadCommandButtonVisible) + { + SetFooterVisible(true); + } + + delete __pCommandButton; + __pCommandButton = null; + } + + _Form* pParentForm = GetParentForm(); + if (pParentForm) + { + pParentForm->DeflateClientRectHeight(0); + } + + AdjustParentPanelHeight(true); + + delete __pFullscreenKeypad; + __pFullscreenKeypad = null; + + delete __pScrollEffect; + __pScrollEffect = null; + + if (__pTextBuffer) + { + delete[] __pTextBuffer; + __pTextBuffer = null; + } + + delete __pTextString; + __pTextString = null; + + delete __pEditModel; + __pEditModel = null; + + if (__pCursorTimer) + { + __pCursorTimer->Cancel(); + delete __pCursorTimer; + __pCursorTimer = null; + } + + if (__pInputConnection) + { + delete __pInputConnection; + __pInputConnection = null; + + if (__pEdit) + { + __pEdit->DetachScrollPanelEvent(); + } + } + + delete __pTextObject; + __pTextObject = null; + + delete __pGuideTextObject; + __pGuideTextObject = null; + + delete __pTitleTextObject; + __pTitleTextObject = null; + + if (__pPasswordTimer) + { + __pPasswordTimer->Cancel(); + delete __pPasswordTimer; + __pPasswordTimer = null; + } + + if (__pScrollBar != null && __pEdit != null) + { + result r = __pEdit->DetachSystemChild(*__pScrollBar); + + if (r == E_SUCCESS) + { + delete __pScrollBar; + __pScrollBar = null; + } + } + + if (__pFlickAnimationTimer) + { + __pFlickAnimationTimer->Cancel(); + delete __pFlickAnimationTimer; + __pFlickAnimationTimer = null; + } + + if (__pTitleSlidingTimer) + { + __pTitleSlidingTimer->Cancel(); + delete __pTitleSlidingTimer; + __pTitleSlidingTimer = null; + } + + delete __pFlickAnimation; + __pFlickAnimation = null; + + if (__pCopyPasteManager != null) + { + __pCopyPasteManager->HideHandle(); + delete __pCopyPasteManager; + __pCopyPasteManager = null; + } + + if (__pTextVisualElement) + { + __pTextVisualElement->Destroy(); + __pTextVisualElement = null; + } + + if (__pCursorVisualElement) + { + __pCursorVisualElement->Destroy(); + __pCursorVisualElement = null; + } + + if (__pEditVEDelegator) + { + delete __pEditVEDelegator; + __pEditVEDelegator = null; + } + + return E_SUCCESS; +} + +void +_EditPresenter::CheckKeypadStatus(void) +{ + if (!__pEdit) + { + return ; + } + + Dimension screenSize; + Rectangle absKeypadBounds; + _ControlManager* pControlManager = _ControlManager::GetInstance(); + + GetKeypadBounds(absKeypadBounds); + + _ControlOrientation orientation = __pEdit->GetOrientation(); + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + screenSize.height = pControlManager->GetScreenSize().height; + } + else + { + screenSize.height = pControlManager->GetScreenSize().width; + } + + if (absKeypadBounds.y != screenSize.height) + { + __isKeypadExist = true; + } + else + { + __isKeypadExist = false; + } + + return; +} + +bool +_EditPresenter::IsKeypadExist(void) const +{ + return __isKeypadExist; +} + +void +_EditPresenter::CheckUSBKeyboardStatus(void) +{ + if (__pInputConnection->CheckUSBKeyboardStatus()) + { + __isUSBKeyboardConnected = true; + } + else + { + __isUSBKeyboardConnected = false; + } + + return; +} + +bool +_EditPresenter::IsUsbKeyboardConnected(void) const +{ + if (__pInputConnection->CheckUSBKeyboardStatus()) + { + return true; + } + else + { + return false; + } +} + +_EditPresenter* +_EditPresenter::CreateInstanceN(void) +{ + _EditPresenter* pPresenter = new (std::nothrow) _EditPresenter; + if (pPresenter == null) + { + SetLastResult(E_OUT_OF_MEMORY); + return null; + } + + return pPresenter; +} + +result +_EditPresenter::Initialize(const _Control& control) +{ + result r = E_SUCCESS; + _EditModel* pEditModel = null; + _VisualElement* pEditVisualElement = null; + TextSimple* pSimpleText = null; + _ControlManager* pControlManager = _ControlManager::GetInstance(); + _Window* pWindow = null; + + __pEdit = dynamic_cast<_Edit*>(const_cast<_Control*>(&control)); + SysAssertf(__pEdit != null, "__pEdit is null"); + + __pTextObject = new (std::nothrow) TextObject; + if (__pTextObject == null) + { + r = E_OUT_OF_MEMORY; + goto CATCH; + } + + __pTextObject->Construct(); + pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + __pTextObject->AppendElement(*pSimpleText); + + if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) + { + __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + if (__pEdit->IsFullScreenKeypadEdit()) + { + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP); + } + else + { + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); + } + __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __textObjectWrap = TEXT_OBJECT_WRAP_TYPE_NONE; + } + else + { + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP); + __pTextObject->SetWrap(__textObjectWrap); + } + + __pTextString = new (std::nothrow) String; + SysTryCatch(NID_UI_CTRL, __pTextString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer."); + __limitLength = 0; + + if (__pFont == null) + { + _ControlOrientation orientation = __pEdit->GetOrientation(); + int defaultFontSize = 0; + GET_SHAPE_CONFIG(EDIT::DEFAULT_FONT_SIZE, orientation, defaultFontSize); + + __contentFontSize = defaultFontSize; + __contentFontStyle = FONT_STYLE_PLAIN; + + __pFont = __pEdit->GetFallbackFont(); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pFont, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __titleFontFaceName = __pFont->GetFaceName(); + + __isFontInitialized = true; + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON; + } + + __pScrollEffect = new (std::nothrow) _EditScrollEffectInfo; + SysTryCatch(NID_UI_CTRL, __pScrollEffect, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create EditScrollEffectInfo"); + + for (int i = 0; i < EDIT_SCROLLFRAME_MAX; i++) + { + __pScrollEffect->touchScrollFrameLevel[i] = 2 + i; + } + + __pScrollEffect->previousY = -1; + __pScrollEffect->currentY = -1; + + pEditModel = new (std::nothrow) _EditModel; + SysTryCatch(NID_UI_CTRL, pEditModel, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance"); + + SetModel(*pEditModel); + + SetClientBounds(); + SetInitialBounds(); + + if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) + { + SetViewModeEnabled(true); + __isCutLinkParserEnabled = true; + } + else + { + SetKeypadEnabled(true); + __isCutLinkParserEnabled = false; + } + + __initialBounds = __pEdit->GetBounds(); + + __pCursorVisualElement = new (std::nothrow) _VisualElement; + SysTryCatch(NID_UI_CTRL, __pCursorVisualElement, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance"); + + r = __pCursorVisualElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r)); + + __pCursorVisualElement->SetSurfaceOpaque(false); + __pCursorVisualElement->SetImplicitAnimationEnabled(false); + + pEditVisualElement = __pEdit->GetVisualElement(); + SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element."); + + __pCursorVisualElement->SetShowState(true); + + r = pEditVisualElement->AttachChild(*__pCursorVisualElement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r)); + + __pInputConnection = _InputConnectionImpl::CreateInputConnectionImplN(null); + SysTryCatch(NID_UI_CTRL, __pInputConnection, , r = E_SYSTEM, "[E_SYSTEM] Unable to create an instance ."); + + __pInputConnection->Initialize(*__pEdit, *this, *this); + + __pTextObject->SetBounds(__textObjectBounds); + + __maximumFlexibleHeight = GetMaxLineCount() * __pFont->GetMaxHeight() + __verticalMargin; + + __pEditVEDelegator = new (std::nothrow) _EditAnimationProvider(); + SysTryCatch(NID_UI_CTRL, __pEditVEDelegator, , E_OUT_OF_MEMORY, "Memory allocation failed."); + + pWindow = pControlManager->GetCurrentFrame(); + if (pWindow) + { + __pCurrentFrame = dynamic_cast<_Frame*>(pWindow); + if (__pCurrentFrame) + { + __pCurrentFrame->AddFrameEventListener(*this); + } + } + + return r; + +CATCH: + Dispose(); + return r; +} + +result +_EditPresenter::InitializeAtFirstDrawing(void) +{ + result r = E_SUCCESS; + + Resize(); + + InitializeParentPanel(); + + if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false && (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE)) + { + r = AdjustFlexibleHeight(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to adjust flexible height."); + } + + ReplaceTextIntoPasswordHyphenString(); + + if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) + { + __pEdit->SetCursorPosition(0); + } + + __isInitialized = true; + + return r; +} + +result +_EditPresenter::DrawBackgroundBitmap(Canvas& canvas, bool focused) +{ + if (!DrawChangeableBackground(canvas, focused, 0, 0)) + { + return E_SYSTEM; + } + + return E_SUCCESS; +} + +result +_EditPresenter::DrawChangeableBackground(Canvas& canvas, bool focused, int bitmapId, int effectBitmapId, bool outLine, int outlineBitmapId) +{ + result r = E_SUCCESS; + Rectangle editRect(0, 0, __pEdit->GetBounds().width, __pEdit->GetBounds().height); + Color bitmapColor; + Bitmap* pEditBgBitmap = null; + Bitmap* pEditBgEffectBitmap = null; + Bitmap* pReplacementColorBackgroundBitmap = null; + bool borderRoundEnable = __pEdit->IsBorderRoundStyleEnabled(); + EditStatus editStatus = GetCurrentStatus(); + + pEditBgBitmap = __pEdit->GetDefaultBackgroundBitmap(editStatus); + + if (__pEdit->IsCustomDefaultBackgroundBitmap(editStatus)) + { + canvas.DrawBitmap(editRect, *pEditBgBitmap); + return r; + } + + if (borderRoundEnable) + { + pEditBgBitmap = null; + r = GET_BITMAP_CONFIG_N(EDIT::BG_ROUND_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBgBitmap) + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + } + + bitmapColor = __pEdit->GetColor(editStatus); + + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pEditBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), bitmapColor); + if (pReplacementColorBackgroundBitmap) + { + if (pReplacementColorBackgroundBitmap->IsNinePatchedBitmap()) + { + canvas.DrawNinePatchedBitmap(editRect, *pReplacementColorBackgroundBitmap); + } + else + { + canvas.DrawBitmap(editRect, *pReplacementColorBackgroundBitmap); + } + } + + if ((!__pEdit->IsFullScreenKeypadEdit() && __groupStyle != GROUP_STYLE_NONE) || GetSearchBarFlag()) + { + pEditBgEffectBitmap = __pEdit->GetDefaultBackgroundEffectBitmap(); + + if (borderRoundEnable) + { + pEditBgEffectBitmap = null; + r = GET_BITMAP_CONFIG_N(EDIT::BG_ROUND_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBgEffectBitmap) + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap"); + } + + if (pEditBgEffectBitmap) + { + if (pEditBgEffectBitmap->IsNinePatchedBitmap()) + { + canvas.DrawNinePatchedBitmap(editRect, *pEditBgEffectBitmap); + } + else + { + canvas.DrawBitmap(editRect, *pEditBgEffectBitmap); + } + } + } + + if (borderRoundEnable) + { + if (pEditBgBitmap) + { + delete pEditBgBitmap; + pEditBgBitmap = null; + } + + if (pEditBgEffectBitmap) + { + delete pEditBgEffectBitmap; + pEditBgEffectBitmap = null; + } + } + delete pReplacementColorBackgroundBitmap; + pReplacementColorBackgroundBitmap = null; + + return E_SUCCESS; +CATCH: + delete pEditBgBitmap; + delete pEditBgEffectBitmap; + + return r; +} + +result +_EditPresenter::DrawBackground(Canvas& canvas, bool drawTitleText) +{ + if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) + { + return DrawSingleLineBackground(canvas, drawTitleText); + } + + Rectangle editRect(0, 0, __pEdit->GetBounds().width, __pEdit->GetBounds().height); + + EditStatus editStatus = GetCurrentStatus(); + + Bitmap* pEditBgBitmap = __pEdit->GetBackgroundBitmap(editStatus); + + if (pEditBgBitmap) + { + if (pEditBgBitmap->IsNinePatchedBitmap()) + { + canvas.DrawNinePatchedBitmap(editRect, *pEditBgBitmap); + } + else + { + canvas.DrawBitmap(editRect, *pEditBgBitmap); + } + } + else + { + DrawBackgroundBitmap(canvas, IsFocused()); + } + + if (drawTitleText) + { + if ((__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP) || (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT)) + { + DrawTitleText(canvas); + } + } + + return E_SUCCESS; +} + +result +_EditPresenter::DrawTitleText(Canvas& canvas) +{ + if (__titleText == -1) + { + return E_SYSTEM; + } + + Variant value; + TextObjectActionType titleAction; + titleAction = __pTitleTextObject->GetAction(); + if (IsFocused() == true) + { + __pTitleTextObject->SetForegroundColor(__pEdit->GetTitleTextColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTitleTextObject->GetTextLength()); + + if (titleAction != __titleSlidingAction) + { + __pTitleTextObject->SetAction(__titleSlidingAction); + __pTitleTextObject->Compose(); + } + + __pTitleTextObject->SetBounds(__titleBounds); + __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(canvas)); + + StopTitleSlidingTimer(); + if (__pTitleTextObject->IsActionOn() == true) + { + StartTitleSlidingTimer(); + } + } + else + { + __pTitleTextObject->SetForegroundColor(__pEdit->GetTitleTextColor(GetCurrentStatus()), 0, __pTitleTextObject->GetTextLength()); + + if (titleAction != TEXT_OBJECT_ACTION_TYPE_ABBREV) + { + __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + } + // Draw title text + __pTitleTextObject->SetBounds(__titleBounds); + __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(canvas)); + } + + return E_SUCCESS; +} + +void +_EditPresenter::DrawText(void) +{ + Canvas* pCanvas = null; + + // In case of unfocused and touch moving + if (__isTouchMoving && !__pTextVisualElement) + { + result r = E_SUCCESS; + __pTextVisualElement = new (std::nothrow) _VisualElement; + SysTryReturnVoidResult(NID_UI_CTRL, __pTextVisualElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create __pTextVisualElement instance."); + + r = __pTextVisualElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r)); + + __pTextVisualElement->SetSurfaceOpaque(false); + __pTextVisualElement->SetImplicitAnimationEnabled(false); + + __pTextVisualElement->SetShowState(true); + + _VisualElement* pEditVisualElement = __pEdit->GetVisualElement(); + SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element."); + + pEditVisualElement->AttachChild(*__pTextVisualElement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r)); + + pCanvas = __pEdit->GetCanvasN(); + SysTryCatch(NID_UI_CTRL, pCanvas, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance."); + + pCanvas->SetBackgroundColor(Color(0)); + r = pCanvas->Clear(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + DrawBackground(*pCanvas); + + delete pCanvas; + pCanvas = null; + } + + if (__pTextVisualElement) + { + Rectangle editBounds = __pEdit->GetBounds(); + __pTextVisualElement->SetOpacity(1.0f); + __pTextVisualElement->SetBounds(FloatRectangle(0, 0, editBounds.width, editBounds.height)); + pCanvas = __pTextVisualElement->GetCanvasN(); + if (pCanvas == null) + { + return; + } + pCanvas->SetBackgroundColor(Color(0)); + pCanvas->Clear(); + + DrawText(*pCanvas); + + if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR) + { + DrawClearIcon(*pCanvas); + } + + InitializeCursor(); + delete pCanvas; + } + + return; + +CATCH: + __pTextVisualElement->Destroy(); + __pTextVisualElement = null; + + if (pCanvas) + { + delete pCanvas; + pCanvas = null; + } + + return; +} + +result +_EditPresenter::DrawText(Canvas& canvas) +{ + result r = E_SUCCESS; + + if (__pEdit->GetEnableState() == false) + { + __pTextObject->SetAlternateLookEnabled(true); + Color tempColor = __pEdit->GetTextColor(EDIT_STATUS_DISABLED); + __pTextObject->SetAlternativeForegroundColor(tempColor); + } + else + { + __pTextObject->SetAlternateLookEnabled(false); + } + + + if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) + { + return DrawTextForEntireFontSetting(canvas); + } + + // initital guide text + if (IsGuideTextActivated()) + { + __pGuideTextObject->SetForegroundColor(__pEdit->GetGuideTextColor(), 0, __pGuideTextObject->GetTextLength()); + + if (__isGuideTextColorChanged == true && __pEdit->IsSettingGuideTextColor() == false) + { + __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_NORMAL), 0, __pGuideTextObject->GetTextLength()); + __pGuideTextObject->SetBounds(__textObjectBounds); + __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas)); + __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_DISABLED), 0, __pGuideTextObject->GetTextLength()); + __isGuideTextColorChanged = false; + } + else + { + __pGuideTextObject->SetBounds(__textObjectBounds); + __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas)); + } + } + + if (GetTextLength() <= 0) + { + return E_SUCCESS; + } + ConvertLinkType(); + + EditStatus editStatus = GetCurrentStatus(); + + __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength()); + + if (__isTextBlocked == true && editStatus == EDIT_STATUS_HIGHLIGHTED) + { + __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTextObject->GetTextLength()); + __pTextObject->SetBlock(true); + __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos); + } + else if (__isTextBlocked == true && editStatus == EDIT_STATUS_PRESSED) + { + __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED), 0, __pTextObject->GetTextLength()); + __pTextObject->SetBlock(true); + __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos); + } + else if (__isTextBlocked == true && editStatus == EDIT_STATUS_NORMAL) + { + __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_NORMAL), 0, __pTextObject->GetTextLength()); + __pTextObject->SetBlock(true); + __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos); + } + else + { + __pTextObject->SetBlock(false); + __isTextBlocked = false; + } + + UpdateComponentInformation(); + + __pTextObject->SetBounds(__textObjectBounds); + __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas)); + + if (__isTextBlocked == true && editStatus == EDIT_STATUS_HIGHLIGHTED) + { + __pTextObject->SetBackgroundColor(Color::GetColor(COLOR_ID_BLACK), 0, __pTextObject->GetTextLength()); + } + + __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT); + + return r; +} + +result +_EditPresenter::DrawTextForEntireFontSetting(Canvas& canvas) +{ + result r = E_SUCCESS; + + if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) && IsFocused() == false) + { + __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + } + else + { + if (__pTextObject->GetAction() != TEXT_OBJECT_ACTION_TYPE_NONE) + { + __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE); + __isCursorChanged = true; + } + } + + // initital guide text + if (IsGuideTextActivated()) + { + __pGuideTextObject->SetForegroundColor(__pEdit->GetGuideTextColor(), 0, __pGuideTextObject->GetTextLength()); + + if (__isGuideTextColorChanged == true && __pEdit->IsSettingGuideTextColor() == false) + { + __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_NORMAL), 0, __pGuideTextObject->GetTextLength()); + __pGuideTextObject->SetBounds(__textObjectBounds); + __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas)); + __pGuideTextObject->SetForegroundColor(__pEdit->GetTextColor(EDIT_STATUS_DISABLED), 0, __pGuideTextObject->GetTextLength()); + __isGuideTextColorChanged = false; + } + else + { + __pGuideTextObject->SetBounds(__textObjectBounds); + __pGuideTextObject->Draw(*_CanvasImpl::GetInstance(canvas)); + } + } + + if (GetTextLength() <= 0) + { + return E_SUCCESS; + } + ConvertLinkType(); + + EditStatus editStatus = GetCurrentStatus(); + + if (IsFocused() == false) + { + __pTextObject->SetFirstDisplayLineIndexFromTextIndex(0); + __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength()); + + if (IsBlocked() == true) + { + __pTextObject->SetBlock(false); + } + } + else + { + int startRange = 0; + int lengthRange = 0; + + __pTextObject->GetRange(startRange, lengthRange); + __pTextObject->SetRange(0, GetTextLength()); + __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength()); + + if (IsBlocked() == true && editStatus == EDIT_STATUS_HIGHLIGHTED) + { + __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED), 0, __pTextObject->GetTextLength()); + __pTextObject->SetForegroundColor(__pEdit->GetTextColor(editStatus), 0, __pTextObject->GetTextLength()); + __pTextObject->SetBlock(true); + __pTextObject->SetRange(__blockStartPos, __cursorPos - __blockStartPos); + } + else if (__isTextBlocked == true && editStatus == EDIT_STATUS_PRESSED) + { + __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED), 0, __pTextObject->GetTextLength()); + __pTextObject->SetBlock(true); + __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos); + } + else if (__isTextBlocked == true && editStatus == EDIT_STATUS_NORMAL) + { + __pTextObject->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_NORMAL), 0, __pTextObject->GetTextLength()); + __pTextObject->SetBlock(true); + __pTextObject->SetBlockRange(__blockStartPos, __cursorPos - __blockStartPos); + } + else + { + __pTextObject->SetBlock(false); + __isTextBlocked = false; + } + + UpdateComponentInformation(); + } + + __pTextObject->SetBounds(__textObjectBounds); + __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas)); + + return r; +} + +result +_EditPresenter::DrawSingleLineBackground(Canvas& canvas, bool drawTitleText) +{ + Rectangle editField(0, 0, __pEdit->GetBounds().width, __pEdit->GetBounds().height); + EditStatus editStatus = GetCurrentStatus(); + + Bitmap* pEditBgBitmap = __pEdit->GetBackgroundBitmap(editStatus); + + if (pEditBgBitmap) + { + if (pEditBgBitmap->IsNinePatchedBitmap()) + { + canvas.DrawNinePatchedBitmap(editField, *pEditBgBitmap); + } + else + { + canvas.DrawBitmap(editField, *pEditBgBitmap); + } + } + else + { + DrawSingleLineBackgroundBitmap(canvas, IsFocused()); + } + + if (drawTitleText) + { + if (((__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_LEFT) && !(__titleText.GetLength() == 0)) || (__pEdit->GetEditStyle() & EDIT_STYLE_TITLE_TOP)) + { + DrawTitleText(canvas); + } + } + + return E_SUCCESS; +} + + +result +_EditPresenter::DrawSingleLineBackgroundBitmap(Canvas& canvas, bool focused) +{ + if (__isTouchPressed) + { + DrawChangeableBackground(canvas, focused, 0, 0); + } + else + { + if (focused) + { + DrawChangeableBackground(canvas, focused, 0, 0, true, 0); + } + else + { + bool tmpFocused = focused; + DrawChangeableBackground(canvas, tmpFocused, 0, 0); + } + } + + return true; +} + +result +_EditPresenter::DrawClearIcon(Canvas& canvas) +{ + result r = E_SUCCESS; + + int clearIconWidth = 0; + int clearIconHeight = 0; + + _ControlOrientation orientation = __pEdit->GetOrientation(); + GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth); + GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_HEIGHT, orientation, clearIconHeight); + + if (__pTextString->GetLength() == 0) + { + return E_SUCCESS; + } + + Bitmap* pEditBitmapClear = null; + Bitmap* pEditReplacedBitmapClear = null; + Color editClearIconColor; + + if (__isClearIconPressed) + { + r = GET_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBitmapClear); + + if (pEditBitmapClear == null) + { + return E_SYSTEM; + } + + GET_COLOR_CONFIG(EDIT::CLEAR_ICON_PRESSED, editClearIconColor); + } + else + { + r = GET_BITMAP_CONFIG_N(EDIT::CLEAR_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pEditBitmapClear); + if (pEditBitmapClear == null) + { + return E_SYSTEM; + } + + GET_COLOR_CONFIG(EDIT::CLEAR_ICON_NORMAL, editClearIconColor); + } + pEditReplacedBitmapClear = _BitmapImpl::GetColorReplacedBitmapN(*pEditBitmapClear, Color::GetColor(COLOR_ID_MAGENTA), + editClearIconColor); + if (pEditReplacedBitmapClear == null) + { + return E_SYSTEM; + } + + Rectangle textRect = __textObjectBounds; + Rectangle afterClearIconRect(textRect.x + textRect.width, textRect.y + (textRect.height - clearIconHeight) / 2, clearIconWidth, clearIconHeight); + if (__clearIconBounds != afterClearIconRect) + { + __clearIconBounds = afterClearIconRect; + __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON); + } + + Rectangle editBounds = __pEdit->GetBounds(); + if (editBounds.height < clearIconHeight) + { + __clearIconBounds.y = textRect.y; + } + + if (pEditReplacedBitmapClear->IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(__clearIconBounds, *pEditReplacedBitmapClear); + } + else + { + r = canvas.DrawBitmap(__clearIconBounds, *pEditReplacedBitmapClear); + } + + if (pEditBitmapClear) + { + delete pEditBitmapClear; + pEditBitmapClear = null; + } + + if (pEditReplacedBitmapClear) + { + delete pEditReplacedBitmapClear; + pEditReplacedBitmapClear = null; + } + + return r; +} + +result +_EditPresenter::Draw(Canvas& canvas) +{ + result r = E_SUCCESS; + + if (__isInitialized == false) + { + r = InitializeAtFirstDrawing(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Faild to initialize."); + + if (IsFocused() == true && __isInputConnectionBound == false) + { + if (IsViewModeEnabled() == false) + { + CheckUSBKeyboardStatus(); + + if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY) + { + ShowKeypad(false); + } + else + { + ShowFullscreenKeypad(); + } + } + } + } + + __isCursorOpaque = true; + + canvas.SetBackgroundColor(Color(0)); + r = canvas.Clear(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__rotated && !IsKeypadExist()) // Command button should be relocated after rotation in case of no keypad. + { + ChangeLayoutInternal(__pEdit->GetOrientation()); + __rotated = false; + } + + DrawBackground(canvas); + + if (__pTextVisualElement) + { + DrawText(); + } + else + { + DrawText(canvas); + + if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR) + { + DrawClearIcon(canvas); + } + } + + InitializeCursor(); + + // Set scroll bar + DrawScrollBar(); + + if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) + { + AdjustFlexibleHeight(); + } + + return r; +} + +result +_EditPresenter::ConvertLinkType(void) +{ + if (__isCutLinkParserEnabled == false || IsViewModeEnabled() == false) + { + return E_SUCCESS; + } + + unsigned long autoLinkMask = GetAutoLinkMask(); + bool isChangingCutLink = false; + EditCutLinkType editLinkType = EDIT_LINK_TYPE_INVALID; + TextCutLinkParser cutlinkParser; + cutlinkParser.SetCutLinkMask(autoLinkMask); + TextLinkInfo* pLinkInfo = cutlinkParser.Parse(__pTextBuffer, wcslen(__pTextBuffer), 0); + TextLinkInfo* pNextLinkInfo = null; + int cursorPos = __cursorPos; + + __isCutLinkParserEnabled = false; + + while (pLinkInfo != null) + { + if (IsViewModeEnabled() == true) + { + switch (pLinkInfo->linkType) + { + case LINK_TYPE_URL: + if (autoLinkMask & LINK_TYPE_URL) + { + isChangingCutLink = true; + editLinkType = EDIT_LINK_TYPE_URL; + } + break; + + case LINK_TYPE_EMAIL: + if (autoLinkMask & LINK_TYPE_EMAIL) + { + isChangingCutLink = true; + editLinkType = EDIT_LINK_TYPE_URL; + } + break; + + case LINK_TYPE_TEL_NUM: + if (autoLinkMask & LINK_TYPE_TEL_NUM) + { + isChangingCutLink = true; + editLinkType = EDIT_LINK_TYPE_PHONE_NUM; + } + break; + + default: + editLinkType = EDIT_LINK_TYPE_INVALID; + break; + } + } + else + { + _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(pLinkInfo->srcOffset); + if (pTextElement != null && pTextElement->GetType() != TEXT_ELEMENT_TYPE_CUTLINK) + { + pNextLinkInfo = pLinkInfo->pNextLinkInfo; + delete pLinkInfo; + pLinkInfo = pNextLinkInfo; + continue; + } + } + + wchar_t* pCutLinkString = null; + result r = E_SUCCESS; + + pCutLinkString = new(std::nothrow) wchar_t[(pLinkInfo->length + 1) * sizeof(wchar_t)]; + + if (!pCutLinkString) + { + while (pLinkInfo != null) + { + pNextLinkInfo = pLinkInfo->pNextLinkInfo; + delete pLinkInfo; + pLinkInfo = pNextLinkInfo; + } + SysLog(NID_UI_CTRL, "[E_SYSTEM] Unable to allocate cutlink text buffer."); + return E_SYSTEM; + } + + for (int i = 0; i < pLinkInfo->length; i++) + { + pCutLinkString[i] = __pTextBuffer[pLinkInfo->srcOffset + i]; + } + pCutLinkString[pLinkInfo->length] = null; + + r = DeleteText(pLinkInfo->srcOffset, pLinkInfo->srcOffset + pLinkInfo->length); + + if (r == E_SUCCESS) + { + int currentLength = __pTextString->GetLength(); + int fullLength = currentLength + pLinkInfo->length; + + r = __pTextString->Insert(String(pCutLinkString), pLinkInfo->srcOffset); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + wchar_t pOriginalString[currentLength - pLinkInfo->srcOffset]; + + // Save original text. + for (int i = 0; i < currentLength - pLinkInfo->srcOffset; i++) + { + pOriginalString[i] = __pTextBuffer[pLinkInfo->srcOffset + i]; + } + pOriginalString[currentLength - pLinkInfo->srcOffset] = 0; + + // Insert text. + for (int i = 0; i < pLinkInfo->length; i++) + { + __pTextBuffer[i + pLinkInfo->srcOffset] = pCutLinkString[i]; + } + + // Append origianal text. + for (int i = 0; i < currentLength - pLinkInfo->srcOffset; i++) + { + __pTextBuffer[i + pLinkInfo->srcOffset + pLinkInfo->length] = pOriginalString[i]; + } + __pTextBuffer[fullLength] = 0; + } + + if (isChangingCutLink) + { + TextCutLink* pCutLinkObject = null; + EditCutlinkColor cutlinkColor; + + Font* pFont = _FontImpl::CloneN(const_cast (*__pFont)); + SysTryReturnResult(NID_UI_CTRL, pFont, GetLastResult(), "[EDIT] Unable to get font."); + + _FontImpl* fontImpl = _FontImpl::GetInstance(*pFont); + SysTryReturnResult(NID_UI_CTRL, fontImpl, GetLastResult(), "[E_SYSTEM] fontImpl is null."); + fontImpl->SetUnderline(true); + + __pEdit->GetCutlinkColorInfo(editLinkType, &cutlinkColor); + pCutLinkObject = new (std::nothrow) TextCutLink(false, pLinkInfo->linkType, pCutLinkString, pLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, pFont, + cutlinkColor.cutlinkFgColor, cutlinkColor.cutlinkBgColor, 0); + + delete pFont; + + if (pCutLinkObject == null) + { + SysLog(NID_UI_CTRL, "[EDIT] Unable to allocate cutlink object."); + } + else + { + pCutLinkObject->SetEditModeEnable(true); + __pTextObject->InsertElementAt(pLinkInfo->srcOffset, *pCutLinkObject); + __pTextObject->ChangeTextOffset(__pTextBuffer, pLinkInfo->srcOffset, pLinkInfo->length); + } + } + else + { + TextSimple* pSimpleText = null; + pSimpleText = new (std::nothrow) TextSimple(pCutLinkString, pLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, GetFont()); + + if (pSimpleText == null) + { + SysLog(NID_UI_CTRL, "[EDIT] Unable to allocate text object."); + + } + else + { + __pTextObject->InsertElementAt(pLinkInfo->srcOffset, *pSimpleText); + __pTextObject->ChangeTextOffset(__pTextBuffer, pLinkInfo->srcOffset, pSimpleText->GetTextLength()); + } + } + + pNextLinkInfo = pLinkInfo->pNextLinkInfo; + delete pLinkInfo; + pLinkInfo = pNextLinkInfo; + + if (pCutLinkString != null) + { + delete[] pCutLinkString; + pCutLinkString = null; + } + } + + __pTextObject->Compose(); + + bool isCursorChanged = __isCursorChanged; + SetCursorPosition(cursorPos); + __isCursorChanged = isCursorChanged; + + return E_SUCCESS; +} + +int +_EditPresenter::GetLinkElementOffsetInTextBuffer(int elementIndex) const +{ + const int textElementCount = __pTextObject->GetElementCount(); + SysTryReturn(NID_UI_CTRL, elementIndex >= 0 && elementIndex <= textElementCount, -1, E_OUT_OF_RANGE, "[EDIT] The Invalid argument is given."); + + _Text::TextElement* pTextElement = null; + int elementOffset = -1; + int elementLength = 0; + int prevOffset = 0; + int prevLength = 0; + + for (int index = 0; index <= elementIndex; index++) + { + pTextElement = __pTextObject->GetElementAtElementIndex(index); + if (pTextElement == null) + { + return -1; + } + + elementOffset = static_cast(pTextElement->GetValue(SET_TEXT_OFFSET)); + elementLength = pTextElement->GetTextLength(); + + if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK) + { + elementOffset = prevOffset + prevLength; + } + + prevOffset = elementOffset; + prevLength = elementLength; + pTextElement = null; + } + + return elementOffset; +} + +int +_EditPresenter::GetCursorPositionAt(const Point& touchPoint) const +{ + Point cursorPoint; + int cursorPos = -1; + + if (__textObjectBounds.Contains(touchPoint)) + { + cursorPoint.x = touchPoint.x - __textObjectBounds.x; + cursorPoint.y = touchPoint.y - __textObjectBounds.y; + } + else if (__textBoxBounds.Contains(touchPoint)) + { + if (touchPoint.y <= __textObjectBounds.y) + { + cursorPoint.y = __textObjectBounds.y + 1; + } + else if (touchPoint.y >= (__textObjectBounds.y + __textObjectBounds.height)) + { + cursorPoint.y = __textObjectBounds.y + __textObjectBounds.height - 1; + } + else + { + cursorPoint.y = touchPoint.y; + } + + if (touchPoint.x <= __textObjectBounds.x) + { + cursorPoint.x = __textObjectBounds.x + 1; + } + else if (touchPoint.x >= (__textObjectBounds.x + __textObjectBounds.width)) + { + cursorPoint.x = __textObjectBounds.x + __textObjectBounds.width - 1; + } + else + { + cursorPoint.x = touchPoint.x; + } + cursorPoint.y -= __textObjectBounds.y; + cursorPoint.x -= __textObjectBounds.x; + } + else + { + return cursorPos; + } + + cursorPos = __pTextObject->GetTextIndexFromPosition(cursorPoint.x, cursorPoint.y); + + return cursorPos; +} + +bool +_EditPresenter::IsHorizontalDirection(const _TouchInfo& touchInfo) +{ + if (touchInfo.GetTouchStatus() != _TOUCH_MOVED) + { + return false; + } + + if (__isMovingCursorByTouchMove) + { + return true; + } + + Rectangle absoluteEditRect = __pEdit->GetAbsoluteBounds(); + Point touchStartPoint = __pressedAbsolutePoint; + Point touchPoint = touchInfo.GetCurrentPosition(); + + int movedWidth = touchStartPoint.x - touchPoint.x - absoluteEditRect.x; + int movedHeight = touchStartPoint.y - touchPoint.y - absoluteEditRect.y; + movedWidth = (movedWidth >= 0) ? movedWidth : -(movedWidth); + movedHeight = (movedHeight >= 0) ? movedHeight : -(movedHeight); + + if (movedWidth >= movedHeight * DIRECTION_DECISION_RATIO) + { + return true; + } + + return false; +} + +bool +_EditPresenter::IsInitialized(void) const +{ + return __isInitialized; +} + +result +_EditPresenter::CalculateCursorBounds(const Rectangle& textBounds, Rectangle& cursorBounds, int cursorPos) +{ + int cursorWidth = 0; + int cursorHeight = 0; + int cursorAbsX = 0; + int cursorAbsY = 0; + int cursorRelativeX = 0; + int cursorRelativeY = 0; + + __pTextObject->SetBounds(textBounds); + + if (cursorPos == -1) + { + cursorPos = __pTextObject->GetCursorIndex(); + } + + if (__pTextObject->GetTextPositionInfoAt(cursorPos, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS) + { + return E_SYSTEM; + } + + cursorBounds.x = cursorRelativeX; + cursorBounds.y = cursorRelativeY; + GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorBounds.width); + cursorBounds.height = cursorHeight; + + if (cursorBounds.y == 0) + { + cursorBounds.y = __textObjectBounds.y; + } + + if (cursorBounds.height == 0) + { + cursorBounds.height = __textObjectBounds.height; + } + + if (cursorBounds.height == 0) + { + return E_SYSTEM; + } + + if (cursorBounds.y < textBounds.y) + { + int cursorHeightDiff = textBounds.y - cursorBounds.y; + cursorBounds.y = textBounds.y; + cursorBounds.height -= cursorHeightDiff; + } + + if (cursorBounds.x == textBounds.x + textBounds.width) + { + cursorBounds.x -= 1; + } + else if (cursorBounds.x > textBounds.x + textBounds.width) + { + cursorBounds.x = textBounds.x + textBounds.width; + return E_SYSTEM; + } + + if (__pTextObject->GetBlock() == false) + { + cursorBounds.x -= 1; + if (cursorBounds.x < textBounds.x) + { + cursorBounds.x = textBounds.x; + } + } + + GET_SHAPE_CONFIG(EDIT::CURSOR_WIDTH, __pEdit->GetOrientation(), cursorBounds.width); + + return E_SUCCESS; +} + +result +_EditPresenter::ScrollContents(int moveY) +{ + int moveLine = 0; + int firstDisplayY = 0; + int effectDistance = moveY; + + int totalHeight = __pTextObject->GetTotalHeight(); + int newFirstDisplayY = firstDisplayY = __pTextObject->GetFirstDisplayPositionY(); + int currentCursorLine = 0; + + if (__pTextObject->GetTextLength() < 1) + { + return E_SYSTEM; + } + + if (__pScrollBar && __pScrollBar->GetScrollPosition() == 0 && effectDistance < 0) + { + if (__pFlickAnimationTimer) + { + StopFlickTimer(); + } + + if (__pScrollBar->IsOnFadeEffect() == true) + { + __pScrollBar->SetScrollVisibility(false); + } + + return E_SYSTEM; + } + else if (__pScrollBar && __pScrollBar->GetScrollPosition() != 0 && __pScrollBar->GetScrollPosition() == __previousScrollBarMaxPos && effectDistance > 0) + { + if (__pFlickAnimationTimer) + { + StopFlickTimer(); + } + + if (__pScrollBar->IsOnFadeEffect() == true) + { + __pScrollBar->SetScrollVisibility(false); + } + + return E_SYSTEM; + } + + if (__pTextObject->GetCursorIndex() == __pTextObject->GetTextLength()) + { + currentCursorLine = __pTextObject->GetTotalLineCount() - 1; + } + else + { + currentCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex()); + } + + if (currentCursorLine == -1) + { + return E_SYSTEM; + } + + if (currentCursorLine < 0) + { + currentCursorLine = 0; + } + + newFirstDisplayY += moveY; + + if (newFirstDisplayY > (totalHeight - __textObjectBounds.height)) + { + newFirstDisplayY = totalHeight - __textObjectBounds.height; + } + + if (newFirstDisplayY < 0) + { + newFirstDisplayY = 0; + } + + moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY); + + __pTextObject->SetFirstDisplayLineIndex(moveLine); + __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY); + + __isCursorOpaque = false; + if (__isCopyPastePopupVisible) + { + __pCopyPasteManager->AdjustBounds(); + } + + return E_SUCCESS; +} + +bool +_EditPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) +{ + if ((&source != __pEdit) || (__pEdit->GetEnableState() == false)) + { + return false; + } + + if (__isCopyPastePopupVisible) + { + __pCopyPasteManager->ReleaseCopyPastePopup(); + } + + __isTouchPressed = true; + + __pScrollEffect->previousY = touchInfo.GetCurrentPosition().y; + __pScrollEffect->currentY = touchInfo.GetCurrentPosition().y; + + Rectangle absoluteEditRect = __pEdit->GetAbsoluteBounds(); + + __pressedPoint = touchInfo.GetCurrentPosition(); + __pressedAbsolutePoint.x = __pressedPoint.x + absoluteEditRect.x; + __pressedAbsolutePoint.y = __pressedPoint.y + absoluteEditRect.y; + + if (IsViewModeEnabled()) + { + int cutLinkIndex = -1; + + __pTextObject->ResetAllCutLinkElementsState(); + + cutLinkIndex = __pTextObject->GetCutLinkIndexFromPositionData(__pressedPoint.x - __textObjectBounds.x, __pressedPoint.y - __textObjectBounds.y); + + if (cutLinkIndex != -1) + { + __pTextObject->ChangeCutLinkState(cutLinkIndex, true); + } + } + + if (__pEdit->GetEditStyle() & EDIT_STYLE_CLEAR) + { + if ((__pressedPoint.x >= __clearIconBounds.x) && (__pressedPoint.x <= __clearIconBounds.x + __clearIconBounds.width)) // Clear Icon Pressed + { + __isClearIconPressed = true; + } + } + StopFlickTimer(); + + __pEdit->Invalidate(); + + return true; +} + +bool +_EditPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + if ((&source != __pEdit) || (__pEdit->GetEnableState() == false)) + { + return false; + } + + if (__isClearIconPressed) + { + __isClearIconPressed = false; + } + + __isTouchPressed = false; + __isMovingCursorByTouchMove = false; + + if (__isTouchReleaseSkipped || __isTouchMoving) + { + __isTouchReleaseSkipped = false; + FadeOutScrollBar(); + __isTouchMoving = false; + } + + if (__isScrollBarVisible && __pScrollBar) + { + if (__pScrollBar->IsVisible()) + { + __pScrollBar->SetScrollVisibility(false); + } + __isScrollBarVisible = false; + } + + __isTouchMoving = false; + __pEdit->Invalidate(); + + return true; +} + +bool +_EditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) +{ + if (__isCopyPastePopupVisible) + { + if (__isTouchPressed && !__isCopyPastePopupMoving) + { + InitializeCopyPasteManager(); + } + else + { + __pCopyPasteManager->CreateCopyPastePopup(); + __pCopyPasteManager->AdjustBounds(); + __pCopyPasteManager->Show(); + } + __isCopyPastePopupMoving = false; + } + + if ((&source != __pEdit) || (__pEdit->GetEnableState() == false)) + { + return false; + } + + int cutLinkIndex = -1; + Rectangle clientBounds; + Point touchPoint = touchInfo.GetCurrentPosition(); + + if (IsViewModeEnabled()) + { + __pEdit->SetFocused(); + __pTextObject->ResetAllCutLinkElementsState(); + } + + if (__isClearIconPressed) + { + __isClearIconPressed = false; + if ((touchPoint.x >= __clearIconBounds.x) && (touchPoint.x <= __clearIconBounds.x + __clearIconBounds.width) + && (touchPoint.y >= __clearIconBounds.y) && (touchPoint.y <= __clearIconBounds.y + __clearIconBounds.height)) + { + ClearText(); + __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED); + __isTouchPressed = false; + __isMovingCursorByTouchMove = false; + __pEdit->Invalidate(); + + return true; + } + } + + if (!__isCopyPastePopupVisible) + { + __isTextBlocked = false; + } + __isTouchPressed = false; + __isMovingCursorByTouchMove = false; + + if (__isTouchReleaseSkipped) + { + __isTouchReleaseSkipped = false; + FadeOutScrollBar(); + __isTouchMoving = false; + __pEdit->Invalidate(); + + return true; + } + + if (IsViewModeEnabled()) + { + cutLinkIndex = __pTextObject->GetCutLinkIndexFromPositionData(touchPoint.x - __textObjectBounds.x, touchPoint.y - __textObjectBounds.y); + + if (cutLinkIndex != -1) + { + TextCutLink* pCutLinkObject = dynamic_cast(__pTextObject->GetCutLinkElementAtCutLinkElementIndex(cutLinkIndex)); + if (pCutLinkObject == null) + { + return true; + } + + String cutLinkString(pCutLinkObject->GetText()); + LinkType baseLinkType = pCutLinkObject->GetCutLinkType(); + + // Send Ui Link Event + __pEdit->SendLinkEvent(cutLinkString, baseLinkType, cutLinkString); + } + } + if (__isTouchMoving && __isInputConnectionBound == false) + { + FadeOutScrollBar(); + __isTouchMoving = false; + __isTouchReleaseSkipped = false; + __pEdit->Invalidate(); + + return true; + } + + clientBounds = __pEdit->GetBounds(); + clientBounds.x = 0; + clientBounds.y = 0; + touchPoint = touchInfo.GetCurrentPosition(); + if (clientBounds.Contains(touchPoint)) + { + int cursorPos = GetCursorPositionAt(touchPoint); + if (cursorPos != -1) + { + if (__isInputConnectionBound == true && __isTextComposing == true) + { + __pInputConnection->FinishTextComposition(); + } + if (!__isCopyPastePopupVisible) // Copy&Paste + { + if ((__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) == true && IsFocused() == false) + { + __isCursorChanged = true; + } + else + { + SetCursorPosition(cursorPos); + } + } + } + FadeOutScrollBar(); + + if ((cutLinkIndex < 0) && + ((__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) == false) && (IsKeypadEnabled())) + { + CheckUSBKeyboardStatus(); + + if (__isUSBKeyboardConnected) + { + if (!__isInputConnectionBound) + { + if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY) + { + if (IsFocused()) + { + ShowKeypad(false); + } + else + { + __pEdit->SetFocused(); + } + } + else + { + ShowFullscreenKeypad(); + } + } + } + else + { + CheckKeypadStatus(); + + if (!IsKeypadExist() || !__isInputConnectionBound) + { + if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY) + { + if (IsFocused()) + { + ShowKeypad(false); + } + else + { + __pEdit->SetFocused(); + } + } + else + { + ShowFullscreenKeypad(); + } + } + } + } + } + + if (__isScrollBarVisible && __pScrollBar) + { + if (__pScrollBar->IsVisible()) + { + __pScrollBar->SetScrollVisibility(false); + } + __isScrollBarVisible = false; + } + + __isTouchMoving = false; + __pEdit->Invalidate(); + + return true; +} + +bool +_EditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) +{ + if ((&source != __pEdit) || (__pEdit->GetEnableState() == false)) + { + return false; + } + + Point touchPoint = touchInfo.GetCurrentPosition(); + + if (__isClearIconPressed) + { + if ((touchPoint.x < __clearIconBounds.x) || (touchPoint.x > __clearIconBounds.x + __clearIconBounds.width) + || (touchPoint.y < __clearIconBounds.y) || (touchPoint.y > __clearIconBounds.y + __clearIconBounds.height)) + { + __isClearIconPressed = false; + __pEdit->Invalidate(); + } + } + + if (__isCopyPastePopupVisible) + { + __pCopyPasteManager->AdjustBounds(); + __pCopyPasteManager->Show(); + __isCopyPastePopupMoving = true; + } + + if (__isTouchMoving == false && IsHorizontalDirection(touchInfo)) + { + if (__isCopyPastePopupVisible && IsBlocked()) + { + return true; + } + + int newIndex = -1; + Rectangle fromBounds; + Rectangle toBounds; + + CalculateCursorBounds(__textObjectBounds, fromBounds); + newIndex = GetCursorPositionAt(touchInfo.GetCurrentPosition()); + if (newIndex != -1) + { + if (Math::Abs(newIndex - __cursorPos) > 3) + { + return true; + } + + CalculateCursorBounds(__textObjectBounds, toBounds, newIndex); + __isCursorChanged = true; + SetCursorPosition(newIndex); + + __isMovingCursorByTouchMove = true; + __isTouchReleaseSkipped = true; + + StopCursorTimer(); + MoveCursor(fromBounds, toBounds); + __pEdit->Invalidate(); + + return true; + } + + if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) + { + int horizontalGap = touchInfo.GetCurrentPosition().x - fromBounds.x; + Dimension currentCharacterDimension; + if (horizontalGap > 0 && __cursorPos < GetTextLength()) + { + currentCharacterDimension = __pTextObject->GetTextExtent(__cursorPos, 1); + if (horizontalGap >= currentCharacterDimension.width) + { + SetCursorPosition(__cursorPos+1); + __pEdit->Invalidate(); + return true; + } + } + if (horizontalGap < 0 && __cursorPos > 0) + { + currentCharacterDimension = __pTextObject->GetTextExtent(__cursorPos-1, 1); + if (Math::Abs(horizontalGap) >= currentCharacterDimension.width) + { + SetCursorPosition(__cursorPos-1); + __pEdit->Invalidate(); + return true; + } + } + } + + if (__isMovingCursorByTouchMove) + { + return true; + } + } + + int totalHeight = __pTextObject->GetTotalHeight(); + + if (__pParentPanel) + { + if (__textObjectBounds.height >= totalHeight) + { + __isTouchMoving = true; + __isTouchReleaseSkipped = true; + return false; + } + } + + if ((touchInfo.GetCurrentPosition().y == __pScrollEffect->currentY) || + (Math::Abs(touchInfo.GetCurrentPosition().y - __pScrollEffect->previousY) < MOVE_SKIP_DECISION_RANGE)) + { + return true; + } + + __pScrollEffect->previousY = __pScrollEffect->currentY; + __pScrollEffect->currentY = touchInfo.GetCurrentPosition().y; + + int moveGap = __pScrollEffect->previousY - __pScrollEffect->currentY; + + if (__isMovingCursorByTouchMove) + { + __isMovingCursorByTouchMove = false; + } + + if (!(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL)) + { + if (__pScrollBar) + { + if (totalHeight > __textObjectBounds.height) + { + __pScrollBar->SetScrollVisibility(true); + } + else + { + __pScrollBar->SetScrollVisibility(false); + } + } + } + + result returnResult = ScrollContents(moveGap); + + __isCursorChanged = false; + __isTouchMoving = true; + DrawText(); + DrawScrollBar(); + + if (returnResult == E_SUCCESS) + { + return true; + } + else + { + __isTouchReleaseSkipped = true; + return false; + } +} + +bool +_EditPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) +{ + result r = E_SUCCESS; + _KeyCode keyCode = keyInfo.GetKeyCode(); + int textLength = 0; + + if (IsViewModeEnabled() == true) + { + return false; + } + + if (__isUSBKeyboardConnected && (keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL)) + { + switch (keyCode) + { + case _KEY_A: + if (__isInputConnectionBound && __isTextComposing) + { + __pInputConnection->FinishTextComposition(); + __isTextComposing = false; + __composingTextLength = 0; + } + + if (__isCopyPastePopupVisible) + { + InitializeCopyPasteManager(); + } + + textLength = __pEdit->GetTextLength(); + if (!textLength) + { + return true; + } + __pEdit->SetBlockRange(0, textLength); + r = __pEdit->SendTextBlockEvent(0, textLength); + UpdateComponentInformation(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit); + SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, true, E_OUT_OF_MEMORY, "[EDIT] Unable to create _EditCopyPasteManager instance."); + __pCopyPasteManager->AddCopyPasteEventListener(*this); + __pCopyPasteManager->CreateCopyPastePopup(); + __pCopyPasteManager->Show(); + __isCopyPastePopupVisible = true; + break; + case _KEY_C: + textLength = __pEdit->GetTextLength(); + if (!textLength) + { + return true; + } + CopyText(); + if (__isCopyPastePopupVisible) + { + InitializeCopyPasteManager(); + } + break; + case _KEY_X: + textLength = __pEdit->GetTextLength(); + if (!textLength) + { + return true; + } + CutText(); + if (__isCopyPastePopupVisible) + { + InitializeCopyPasteManager(); + } + break; + case _KEY_V: + PasteText(); + if (__isCopyPastePopupVisible) + { + InitializeCopyPasteManager(); + } + break; + default: + return true; + } + if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false) + { + DrawText(); + } + else + { + __pEdit->Invalidate(); + } + + return true; + } + else if (__isUSBKeyboardConnected && keyInfo.GetKeyModifier() & _KEY_MODIFIER_SHIFT) + { + if (!__isCopyPastePopupVisible) + { + return false; + } + + switch (keyCode) + { + case _KEY_LEFT: + __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_LEFT); + break; + case _KEY_UP: + __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_UP); + break; + case _KEY_DOWN: + __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_DOWN); + break; + case _KEY_RIGHT: + __pCopyPasteManager->MoveHandler(_EditCopyPasteManager::HANDLER_MOVE_TYPE_RIGHT); + break; + default: + return false; + } + return true; + } + else if (_KEY_ENTER == keyCode) + { + if (__isInputConnectionBound != false && __isTextComposing != false) + { + return false; + } + else + { + if (IsKeypadActionEnabled()) + { + char enterText[2] = {'\n', }; + OnTextCommitted(String(enterText)); + } + + return true; + } + } + else if (_KEY_BACKSPACE == keyCode) + { + if (__isTextComposing == false) + { + OnSurroundingTextDeleted(-1, 1); + ScrollPanelToCursorPosition(); + return true; + } + } + else if ((keyInfo.GetKeyModifier() & _KEY_LOCK_NUM) && (_KEY_NUM_LEFT == keyCode || _KEY_NUM_RIGHT == keyCode || _KEY_NUM_UP == keyCode || _KEY_NUM_DOWN == keyCode)) + { + return false; + } + else if (_KEY_LEFT == keyCode || _KEY_NUM_LEFT == keyCode) + { + if (__isCopyPastePopupVisible) + { + InitializeCopyPasteManager(); + } + + if (__isInputConnectionBound != false && __isTextComposing != false) + { + __pInputConnection->FinishTextComposition(); + __isTextComposing = false; + __composingTextLength = 0; + } + + if (__cursorPos != 0) + { + int startPosition = -1; + int endPosition = -1; + GetTextImageRangeAt(__cursorPos-1, startPosition, endPosition); + if (startPosition>0 && startPosition < __cursorPos-1) + { + SetCursorPosition(startPosition); + } + else + { + SetCursorPosition(__cursorPos-1); + } + if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false) + { + DrawText(); + } + } + return true; + } + else if (_KEY_UP == keyCode || _KEY_NUM_UP == keyCode) + { + if (__isCopyPastePopupVisible) + { + InitializeCopyPasteManager(); + } + + if (__isInputConnectionBound != false && __isTextComposing != false) + { + __pInputConnection->FinishTextComposition(); + __isTextComposing = false; + __composingTextLength = 0; + } + + int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex()); + if (curCursorLine !=0 ) + { + int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine); + int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine-1); + int newCursorPosition = offset + firstTextIndex; + int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1); + Rectangle clientBounds(0, 0, 0, 0); + Rectangle absCursorBounds(0, 0, 0, 0); + if (offset newCursorPosition && startPosition < newCursorPosition) + { + newCursorPosition = endPosition; + } + SetCursorPosition(newCursorPosition); + } + else + { + wchar_t ch = '\0'; + __pTextString->GetCharAt(firstTextIndex+textLength - 1, ch); + if (ch == L'\n') + { + SetCursorPosition(firstTextIndex+textLength - 1); + } + else + { + SetCursorPosition(firstTextIndex+textLength); + } + } + + if (__pParentForm) + { + clientBounds = __pParentForm->GetClientBounds(); + GetCursorBounds(true, absCursorBounds); + if (!clientBounds.Contains(Point(absCursorBounds.x, absCursorBounds.y))) + { + ScrollPanelToCursorPosition(); + __pParentForm->Draw(); + } + } + if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false) + { + DrawText(); + } + } + return true; + } + else if (_KEY_DOWN == keyCode || _KEY_NUM_DOWN == keyCode) + { + if (__isCopyPastePopupVisible) + { + InitializeCopyPasteManager(); + } + + if (__isInputConnectionBound != false && __isTextComposing != false) + { + __pInputConnection->FinishTextComposition(); + __isTextComposing = false; + __composingTextLength = 0; + } + + int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex()); + int totalLine = __pTextObject->GetTotalLineCount(); + if (curCursorLine < totalLine - 1) + { + int offset = __cursorPos - __pTextObject->GetFirstTextIndexAt(curCursorLine); + int firstTextIndex = __pTextObject->GetFirstTextIndexAt(curCursorLine+1); + int newCursorPosition = offset + firstTextIndex; + int textLength = __pTextObject->GetTextLengthAt(curCursorLine+1); + Rectangle clientBounds(0, 0, 0, 0); + Rectangle absCursorBounds(0, 0, 0, 0); + + if (offset newCursorPosition && startPosition < newCursorPosition) + { + newCursorPosition = endPosition; + } + SetCursorPosition(newCursorPosition); + } + else + { + wchar_t ch = '\0'; + __pTextString->GetCharAt(firstTextIndex+textLength - 1, ch); + if (ch == L'\n') + { + SetCursorPosition(firstTextIndex+textLength - 1); + } + else + { + SetCursorPosition(firstTextIndex+textLength); + } + } + + if (__pParentForm) + { + clientBounds = __pParentForm->GetClientBounds(); + GetCursorBounds(true, absCursorBounds); + + if (!clientBounds.Contains(Point(absCursorBounds.x, absCursorBounds.y + absCursorBounds.height))) + { + ScrollPanelToCursorPosition(); + __pParentForm->Draw(); + } + } + if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false) + { + DrawText(); + } + } + return true; + } + else if (_KEY_RIGHT == keyCode || _KEY_NUM_RIGHT == keyCode) + { + if (__isCopyPastePopupVisible) + { + InitializeCopyPasteManager(); + } + + if (__isInputConnectionBound != false && __isTextComposing != false) + { + __pInputConnection->FinishTextComposition(); + __isTextComposing = false; + __composingTextLength = 0; + } + + if (__cursorPos < GetTextLength()) + { + int startPosition = -1; + int endPosition = -1; + GetTextImageRangeAt(__cursorPos, startPosition, endPosition); + if (endPosition > __cursorPos+1 && startPosition > -1) + { + SetCursorPosition(endPosition); + } + else + { + SetCursorPosition(__cursorPos+1); + } + if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false) + { + DrawText(); + } + } + return true; + } + else if (_KEY_DELETE == keyCode) + { + if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false) + { + if (!GetTextLength()) + { + return true; + } + } + + if (__isCopyPastePopupVisible) + { + if (IsBlocked() == true) + { + int start = 0; + int end = 0; + GetBlockRange(start, end); + DeleteText(start, end); + ReleaseTextBlock(); + } + else + { + int cursorPosition = GetCursorPosition(); + DeleteText(cursorPosition, cursorPosition+1); + } + + InitializeCopyPasteManager(); + } + else + { + if (__isInputConnectionBound && __isTextComposing) + { + __pInputConnection->FinishTextComposition(); + __isTextComposing = false; + __composingTextLength = 0; + } + + int cursorPosition = GetCursorPosition(); + if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false) + { + DeleteText(cursorPosition, cursorPosition+1); + } + else + { + OnSurroundingTextDeleted(0, 1); + } + } + if ((__pEdit->GetEditStyle() & EDIT_STYLE_TOKEN) == false) + { + DrawText(); + } + else + { + __pEdit->Invalidate(); + } + ScrollPanelToCursorPosition(); + + return true; + } + + return false; +} + +bool +_EditPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) +{ + _KeyCode keyCode = keyInfo.GetKeyCode(); + + if (__isUSBKeyboardConnected && (keyCode == _KEY_SHIFT_L || keyCode == _KEY_SHIFT_R)) + { + if (__pCopyPasteManager && __pCopyPasteManager->IsHandlerMovingEnabled()) + { + __pCopyPasteManager->SetHandlerMovingEnabled(false); + __pCopyPasteManager->CreateCopyPastePopup(); + __pCopyPasteManager->Show(); + } + return true; + } + + return false; +} + +void +_EditPresenter::OnClipboardPopupClosed(const ClipboardItem* pClipboardItem) +{ + int start = 0; + int end = 0; + int total = 0; + if (!pClipboardItem && IsBlocked()) + { + ReleaseTextBlock(); + } + + SysTryReturnVoidResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "[E_SYSTEM] _EditPresenter::OnClipboardPopupClosed: Unable to get the clipboarditem instance."); + + String* pClipString = dynamic_cast(pClipboardItem->GetData()); + SysTryReturnVoidResult(NID_UI_CTRL, pClipString != null, E_SYSTEM, "[E_SYSTEM] _EditPresenter::OnClipboardPopupClosed: Unable to get the clipboarditem instance."); + + int currentLength = GetTextLength(); + String* pSubString = null; + result r = E_SUCCESS; + + + if (IsBlocked()) + { + GetBlockRange(start, end); + total = currentLength - (end - start) + pClipString->GetLength(); + if (total > __limitLength) + { + DeleteText(start, end); + ReleaseTextBlock(); + pSubString = new String(__limitLength - currentLength + (end - start)); + SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer."); + + pClipString->SubString(0, __limitLength - currentLength + (end - start), *pSubString); + r = InsertTextAt(__cursorPos, pSubString->GetPointer()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + delete pSubString; + } + else + { + DeleteText(start, end); + ReleaseTextBlock(); + r = InsertTextAt(__cursorPos, pClipString->GetPointer()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else if (currentLength + pClipString->GetLength() > __limitLength) + { + if (__limitLength == currentLength) + { + delete pClipboardItem; + return; + } + + pSubString = new String(__limitLength - currentLength); + SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer."); + + pClipString->SubString(0, __limitLength - currentLength, *pSubString); + r = InsertTextAt(__cursorPos, pSubString->GetPointer()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + delete pSubString; + } + else + { + r = InsertTextAt(__cursorPos, pClipString->GetPointer()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED); + + __pEdit->Invalidate(); + + delete pClipboardItem; + + return; + +CATCH: + delete pClipboardItem; + delete pSubString; + return; +} + +bool +_EditPresenter::OnLongPressGestureDetected(void) +{ + if (__isCopyPastePopupVisible) + { + return true; + } + else if (IsFocused() == false && !IsViewModeEnabled()) + { + return true; + } + + __isTouchPressed = false; + Rectangle cursorBounds; + InitializeCopyPasteManager(); + if (IsClipped() || GetTextLength()) + { + if (IsClipped() && !GetTextLength() && (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)) + { + return true; + } + + if (__isInputConnectionBound && __isTextComposing) + { + __pInputConnection->FinishTextComposition(); + __isTextComposing = false; + __composingTextLength = 0; + } + + int cursorPos = GetCursorPositionAt(__pressedPoint); + if (cursorPos == -1) + { + cursorPos = 0; + } + SetCursorPosition(cursorPos); + ScrollPanelToCursorPosition(); + GetCursorBounds(true, cursorBounds); + + __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit); + SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "[EDIT] Unable to create _EditCopyPasteManager instance."); + __pCopyPasteManager->AddCopyPasteEventListener(*this); + __pCopyPasteManager->Show(); + __isCopyPastePopupVisible = true; + + } + + return true; +} + +bool +_EditPresenter::OnTapGestureDetected(void) +{ + if (IsFocused() == false || __isCopyPastePopupVisible) + { + return true; + } + + if (!__isUSBKeyboardConnected) + { + if (__isKeypadShowing) + return true; + } + + __isTouchPressed = false; + InitializeCopyPasteManager(); + + if (GetTextLength() > 0) + { + Rectangle cursorBounds; + int start = -1; + int end = -1; + int cursorPos = GetCursorPositionAt(__pressedPoint); + + if (cursorPos == -1) + { + cursorPos = 0; + } + + GetWordPosition(cursorPos, start, end); + SetBlockRange(start, end); + ScrollPanelToCursorPosition(); + GetCursorBounds(true, cursorBounds); + + __pCopyPasteManager = new (std::nothrow) _EditCopyPasteManager(*__pEdit); + SysTryReturn(NID_UI_CTRL, __pCopyPasteManager != null, false, E_SYSTEM, "[EDIT] Unable to create _EditCopyPasteManager instance."); + __pCopyPasteManager->AddCopyPasteEventListener(*this); + __pCopyPasteManager->CreateCopyPastePopup(); + __pCopyPasteManager->Show(); + __isCopyPastePopupVisible = true; + + if (__isInputConnectionBound && __isTextComposing) + { + __pInputConnection->FinishTextComposition(); + __isTextComposing = false; + __composingTextLength = 0; + } + __pEdit->Draw(); + } + + return true; +} + +HorizontalAlignment +_EditPresenter::GetTextAlignment(void) const +{ + return __horizontalAlignment; +} + +int +_EditPresenter::GetLineSpacing(void) const +{ + int linePixelGap = -1; + + linePixelGap = __pTextObject->GetLineSpace(); + + return linePixelGap; +} + +void +_EditPresenter::GetBlockRange(int& start, int& end) const +{ + if (__isTextBlocked == false || __cursorPos == __blockStartPos) + { + return; + } + + if (__cursorPos > __blockStartPos) + { + start = __blockStartPos; + end = __cursorPos; + } + else + { + start = __cursorPos; + end = __blockStartPos; + } + + return; +} + +result +_EditPresenter::SetBlockRange(int start, int end) +{ + result r = E_SUCCESS; + + r = SetCursorPosition(start); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = BeginTextBlock(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetCursorPosition(end); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_EditPresenter::BeginTextBlock(void) +{ + if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) + return E_SYSTEM; + + __isTextBlocked = true; + __blockStartPos = __cursorPos; + + return E_SUCCESS; +} + +result +_EditPresenter::ReleaseTextBlock(void) +{ + if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) + return E_SYSTEM; + + + if (__isTextBlocked == false) + { + return E_SYSTEM; + } + + __isTextBlocked = false; + + return E_SUCCESS; +} + +bool +_EditPresenter::IsBlocked(void) const +{ + return __isTextBlocked; +} + +result +_EditPresenter::CopyText(void) +{ + if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) + return E_SYSTEM; + + result r = E_SUCCESS; + + _Clipboard* pClipBoard = _Clipboard::GetInstance(); + SysTryReturnResult(NID_UI_CTRL, pClipBoard != null, E_SYSTEM, "[EDIT] Unable to get the clipboard instance."); + + int start = 0; + int end = 0; + GetBlockRange(start, end); + + String blockString(GetText(start, end - 1)); + + _ClipboardItem* pClipboardItem = _ClipboardItem::CreateInstanceN(CLIPBOARD_DATA_TYPE_TEXT, blockString); + SysTryReturnResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "[EDIT] Unable to get the clipboarditem instance."); + + r = pClipBoard->CopyItem(*pClipboardItem); + + delete pClipboardItem; + + _Text::TextElement* pStartTextElement = __pTextObject->GetElementAtTextIndex(start); + _Text::TextElement* pEndTextElement = __pTextObject->GetElementAtTextIndex(end-1); + + if (pStartTextElement == null || pEndTextElement == null) + { + return r; + } + + const int startIndex = __pTextObject->GetElementIndexOf(*pStartTextElement); + const int endIndex = __pTextObject->GetElementIndexOf(*pEndTextElement); + + for (int index = startIndex; index <= endIndex; index++) + { + _Text::TextElement* pTextElement = __pTextObject->GetElementAtElementIndex(index); + TextElementType objectType = pTextElement->GetType(); + if (objectType != TEXT_ELEMENT_TYPE_IMAGE) + { + continue; + } + TextImage* pImageText = null; + pImageText = dynamic_cast < TextImage* >(pTextElement); + if ( pImageText == null) + { + continue; + } + const Bitmap * pImage = pImageText->GetBitmap(); + SysTryReturnResult(NID_UI_CTRL, pImage != null, E_SYSTEM, "[EDIT] Unable to get the bitmap from textobject."); + + _ClipboardItem* pClipboardImageItem = _ClipboardItem::CreateInstanceN(CLIPBOARD_DATA_TYPE_IMAGE, *pImage); + SysTryReturnResult(NID_UI_CTRL, pClipboardImageItem != null, E_SYSTEM, "[EDIT] Unable to get the clipboardImageitem instance."); + + r = pClipBoard->CopyItem(*pClipboardImageItem); + + delete pClipboardImageItem; + } + + return r; +} + +result +_EditPresenter::CutText(void) +{ + if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) + return E_SYSTEM; + + result r = E_SUCCESS; + + r = CopyText(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int start = 0; + int end = 0; + GetBlockRange(start, end); + DeleteText(start, end); + ReleaseTextBlock(); + + __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED); + + return r; +} + +result +_EditPresenter::PasteText(void) +{ + result r = E_SUCCESS; + int currentLength = GetTextLength(); + String* pSubString = null; + int start = 0; + int end = 0; + int total = 0; + + + _Clipboard* pClipBoard = _Clipboard::GetInstance(); + SysTryReturnResult(NID_UI_CTRL, pClipBoard != null, E_SYSTEM, "[EDIT] Unable to get the clipboard instance."); + + const _ClipboardItem* pClipboardItem = pClipBoard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT); + SysTryReturnResult(NID_UI_CTRL, pClipboardItem != null, E_SYSTEM, "[EDIT] Unable to get the clipboarditem instance."); + + const String* pClipString = dynamic_cast(pClipboardItem->GetData()); + SysTryCatch(NID_UI_CTRL, pClipString, r = E_SYSTEM, E_SYSTEM, "[EDIT] Unable to get the clipboarditem instance."); + + if (IsBlocked()) + { + GetBlockRange(start, end); + total = currentLength - (end - start) + pClipString->GetLength(); + if (total > __limitLength) + { + DeleteText(start, end); + ReleaseTextBlock(); + pSubString = new String(__limitLength - currentLength + (end - start)); + SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer."); + + pClipString->SubString(0, __limitLength - currentLength + (end - start), *pSubString); + r = InsertTextAt(__cursorPos, pSubString->GetPointer()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + delete pSubString; + } + else + { + DeleteText(start, end); + ReleaseTextBlock(); + r = InsertTextAt(__cursorPos, pClipString->GetPointer()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else if (currentLength + pClipString->GetLength() > __limitLength) + { + if (__limitLength == currentLength) + { + delete pClipboardItem; + return E_SUCCESS; + } + + pSubString = new String(__limitLength - currentLength); + SysTryCatch(NID_UI_CTRL, pSubString, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to allocate text buffer."); + + pClipString->SubString(0, __limitLength - currentLength, *pSubString); + r = InsertTextAt(__cursorPos, pSubString->GetPointer()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + delete pSubString; + } + else + { + r = InsertTextAt(__cursorPos, pClipString->GetPointer()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + delete pClipboardItem; + + ReplaceTextIntoPasswordHyphenString(); + + __pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED); + + return r; + +CATCH: + delete pClipboardItem; + delete pSubString; + return r; +} + +result +_EditPresenter::RemoveTextBlock(void) +{ + if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) + return E_SYSTEM; + + + if (!__isTextBlocked) + { + return E_OBJ_NOT_FOUND; + } + + int start = 0; + int end = 0; + + GetBlockRange(start, end); + if (start == end) + { + return E_OBJ_NOT_FOUND; + } + + result r = DeleteText(start, end); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __isTextBlocked = false; + + return r; +} + +bool +_EditPresenter::IsClipped(void) const +{ + _Clipboard* pClipBoard = _Clipboard::GetInstance(); + SysTryReturn(NID_UI_CTRL, pClipBoard != null, false, E_SYSTEM, "[EDIT] Unable to get the clipboard instance."); + + const _ClipboardItem* pClipboardItem = pClipBoard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT); + if (pClipboardItem == null) + { + SetLastResult(E_SUCCESS); + return false; + } + delete pClipboardItem; + + return true; +} + +result +_EditPresenter::SetTextAlignment(HorizontalAlignment alignment) +{ + result r = E_SUCCESS; + + int textAlign = TEXT_OBJECT_ALIGNMENT_LEFT; + + if (alignment == ALIGNMENT_CENTER) + { + textAlign = TEXT_OBJECT_ALIGNMENT_CENTER; + } + else if (alignment == ALIGNMENT_RIGHT) + { + textAlign = TEXT_OBJECT_ALIGNMENT_RIGHT; + } + + if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) + { + r = __pTextObject->SetAlignment(textAlign | TEXT_OBJECT_ALIGNMENT_MIDDLE); + } + else + { + r = __pTextObject->SetAlignment(textAlign | TEXT_OBJECT_ALIGNMENT_TOP); + } + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[EDIT] Unable to set text alignment."); + __horizontalAlignment = alignment; + + return r; +} + +result +_EditPresenter::SetLineSpacing(int linePixelGap) +{ + result r = E_SUCCESS; + + __pTextObject->SetLineSpace(linePixelGap); + + return r; +} + +String +_EditPresenter::GetText(int start, int end) const +{ + String tempString; + + if (start > end) + { + return tempString; + } + + if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) + { + int length = end - start + 1; + __pTextString->SubString(start, length, tempString); + + return tempString; + } + + String resultString; + String elementString; + const int textElementCount = __pTextObject->GetElementCount(); + _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(start); + + if (pTextElement == null) + { + return resultString; + } + const int startIndex = __pTextObject->GetElementIndexOf(*pTextElement); + + for (int index = startIndex; index < textElementCount; index++) + { + _Text::TextElement* pTextElement = __pTextObject->GetElementAtElementIndex(index); + TextSimple* pSimpleText = null; + if (pTextElement == null) + { + break; + } + + TextElementType objectType = pTextElement->GetType(); + if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK) + { + pSimpleText = dynamic_cast < TextSimple* >(pTextElement); + if ( pSimpleText == null) + { + continue; + } + + } + else + { + continue; + } + + int elementOffset = static_cast < int >(pTextElement->GetValue(SET_TEXT_OFFSET)); + int elementLength = pTextElement->GetTextLength(); + + if (objectType == TEXT_ELEMENT_TYPE_CUTLINK) + { + elementOffset = GetLinkElementOffsetInTextBuffer(index); + if (elementOffset < 0) + { + continue; + } + } + + if (end < elementOffset) + { + break; + } + if (start >= elementOffset + elementLength) + { + continue; + } + + if (elementLength == 0) + { + continue; + } + elementString.Clear(); + elementString.Append(pSimpleText->GetText()); + elementString.SetLength(elementLength); + if (end < elementOffset + elementLength - 1) + { + int removingStartIndex = end + 1; + elementString.Remove(removingStartIndex - elementOffset, elementOffset + elementLength - removingStartIndex); + } + if (start > elementOffset) + { + elementString.Remove(0, start - elementOffset); + } + resultString.Append(elementString); + } + + return resultString; +} + +String +_EditPresenter::GetText(void) const +{ + return GetText(0, GetTextLength()-1); +} + +result +_EditPresenter::SetText(const String& text) +{ + result r = E_SUCCESS; + + int length = text.GetLength(); + if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) || (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)) + { + if (__limitLength <= length) + { + String tempString = GetText(); + SetTextLimitLength(length * 2); + } + } + else + { + SysTryReturnResult(NID_UI_CTRL, length <= __limitLength, E_INVALID_ARG, "[EDIT] The Invalid argument is given."); + } + + if (__isInputConnectionBound && __isTextComposing) + { + __pInputConnection->FinishTextComposition(); + __isTextComposing = false; + __composingTextLength = 0; + } + + __pTextString->Clear(); + __pTextString->Append(text); + + wchar_t* tempString = const_cast(text.GetPointer()); + for (int i = 0; i < length; i++) + { + __pTextBuffer[i] = tempString[i]; + } + __pTextBuffer[length] = 0; + + __pTextObject->RemoveAll(); + TextSimple* pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, length,TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont); + __pTextObject->AppendElement(*pSimpleText); + __pTextObject->Compose(); + + ReplaceTextIntoPasswordHyphenString(); + + SetCursorPosition(length); + + if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) + { + AdjustFlexibleHeight(); + } + + if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) + { + __isCutLinkParserEnabled = true; + } + + __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT); + + return r; +} + +int +_EditPresenter::GetRemainingLength(void) const +{ + return __limitLength - __pTextObject->GetTextLength(); +} + +result +_EditPresenter::SetCursorPosition(int position) +{ + result r = E_SUCCESS; + int length = GetTextLength(); + + SysTryReturnResult(NID_UI_CTRL, -1 < position && position <= length, E_INVALID_ARG, "[Edit] Invalid argument is given."); + + if (__isTouchMoving == false) + { + __isCursorChanged = true; + } + + r = __pTextObject->SetCursorIndex(position); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[Edit] Failed to set cursor position"); + + __cursorPos = position; + + return r; +} + +int +_EditPresenter::GetCursorPosition(void) const +{ + return __cursorPos; +} + +int +_EditPresenter::GetTextLength(void) const +{ + return __pTextObject->GetTextLength(); +} + +result +_EditPresenter::InsertTextAt(int index, const String& text) +{ + result r = E_SUCCESS; + + int currentLength = GetTextLength(); + int length = text.GetLength(); + int totalLength = currentLength + length; + + SysTryReturnResult(NID_UI_CTRL, index >= 0 && index <= currentLength, E_OUT_OF_RANGE, "[EDIT] The Invalid argument is given."); + + if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) + { + if (__limitLength <= totalLength) + { + String tempString = GetText(); + SetTextLimitLength(totalLength * 2); + SetText(tempString); + } + } + else + { + SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_INVALID_ARG, "[EDIT] The Invalid argument is given."); + } + + r = __pTextString->Insert(text, index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + wchar_t* pTempString = const_cast(text.GetPointer()); + wchar_t pOriginalString[currentLength - index]; + + for (int i = 0; i < currentLength - index; i++) + { + pOriginalString[i] = __pTextBuffer[index + i]; + } + pOriginalString[currentLength - index] = 0; + + for (int i = 0; i < length; i++) + { + __pTextBuffer[i + index] = pTempString[i]; + } + + for (int i = 0; i < currentLength - index; i++) + { + __pTextBuffer[i + index + length] = pOriginalString[i]; + } + __pTextBuffer[totalLength] = 0; + + __pTextObject->SetRange(index, length); + r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), length); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[Edit] Failed to set length"); + + __pTextObject->Compose(); + + if (__isTextBlocked == true) + { + DeleteText(__blockStartPos, __cursorPos); + ReleaseTextBlock(); + + SetCursorPosition(__cursorPos + length); + } + else + { + SetCursorPosition(index + length); + } + + if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) + { + AdjustFlexibleHeight(); + } + + __isCursorChanged = true; + + if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) + { + __isCutLinkParserEnabled = true; + } + + __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT); + + return r; +} + +result +_EditPresenter::AppendText(const String& text) +{ + result r = E_SUCCESS; + + int currentLength = GetTextLength(); + int length = text.GetLength(); + int totalLength = currentLength + length; + + if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) + { + if (__limitLength <= totalLength) + { + String tempString = GetText(); + SetTextLimitLength(totalLength * 2); + SetText(tempString); + } + } + else + { + SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_INVALID_ARG, "[EDIT] The Invalid argument is given."); + } + + r = __pTextString->Append(text); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + wchar_t* pTempString = const_cast(text.GetPointer()); + + for (int i = 0; i < length; i++) + { + __pTextBuffer[i + currentLength] = pTempString[i]; + } + __pTextBuffer[totalLength] = 0; + + __pTextObject->SetRange(currentLength, length); + r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), length); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[Edit] Failed to set length"); + + __pTextObject->Compose(); + + if (!__isTextBlocked) + { + SetCursorPosition(totalLength); + } + + if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) + { + AdjustFlexibleHeight(); + } + + if (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER) + { + __isCutLinkParserEnabled = true; + } + + __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT); + + return r; +} + +result +_EditPresenter::AppendCharacter(const Character& character) +{ + result r = E_SUCCESS; + + r = AppendText(character.ToString()); + + return r; +} + +result +_EditPresenter::ClearText(void) +{ + InitializeCopyPasteManager(); + + result r = E_SUCCESS; + + if (__isInputConnectionBound && __isTextComposing) + { + __pInputConnection->FinishTextComposition(); + __isTextComposing = false; + __composingTextLength = 0; + } + + int textLength = GetTextLength(); + + if (textLength == 0) + { + return r; + } + + r = DeleteText(0, textLength); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_EditPresenter::DeleteCharacterAt(int index) +{ + result r = E_SUCCESS; + + int length = -1; + length = GetTextLength(); + + SysTryReturnResult(NID_UI_CTRL, index >= 0, E_INVALID_ARG, "Specified index is negative."); + SysTryReturnResult(NID_UI_CTRL, index < length, E_OUT_OF_RANGE, "Specified index is outside the range."); + + r = DeleteText(index, index+1); + return r; +} + +result +_EditPresenter::DeleteText(int start, int end) +{ + result r = E_SUCCESS; + + int length = GetTextLength(); + + SysTryReturnResult(NID_UI_CTRL, -1 < start && start < end, E_INVALID_ARG, "[EDIT] Invalid argument is given."); + SysTryReturnResult(NID_UI_CTRL, start < end && end <= length, E_INVALID_ARG, "[EDIT] Invalid argument is given."); + + _Text::TextElement* pFirstTextElement = __pTextObject->GetElementAtTextIndex(start); + const TextSimple* pFirstSimpleText = dynamic_cast (pFirstTextElement); + if (pFirstSimpleText != null && pFirstSimpleText->GetBitmap() != null) + { + if (pFirstSimpleText->GetTextOffset() < start) + { + start = pFirstSimpleText->GetTextOffset(); + } + } + _Text::TextElement* pLastTextElement = __pTextObject->GetElementAtTextIndex(end - 1); + const TextSimple* pLastSimpleText = dynamic_cast (pLastTextElement); + if (pLastSimpleText != null && pLastSimpleText->GetBitmap() != null) + { + if( (pLastSimpleText->GetTextOffset() + pLastSimpleText->GetTextLength()) > end) + { + end = pLastSimpleText->GetTextOffset() + pLastSimpleText->GetTextLength(); + } + } + + r = __pTextString->Remove(start, end - start); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int currentLength = __pTextString->GetLength(); + + for (int i = start; i < length; i++) + { + __pTextBuffer[i] = __pTextBuffer[i + (length - currentLength)]; + } + + for (int i = currentLength; i < length; i++) + { + __pTextBuffer[i] = 0; + } + + SetCursorPosition(start); + + __pTextObject->SetRange(start, end - start); + r = __pTextObject->NotifyTextChanged(__pTextBuffer, 0, currentLength, -(end - start)); + r = __pTextObject->Compose(); + + if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) + { + AdjustFlexibleHeight(); + } + + __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT); + + return r; +} + +void +_EditPresenter::GetCurrentTextRange(int& start, int& end) const +{ + int currentLength = __pTextString->GetLength(); + + start = __cursorPos; + while (start > 0) + { + if (__pTextBuffer[--start] == TEXT_OBJ_CHARACTER) + { + start++; + break; + } + } + + end = __cursorPos; + while (end < currentLength && __pTextBuffer[end] != TEXT_OBJ_CHARACTER) + { + end++; + } + + return; +} + +int +_EditPresenter::GetTextLimitLength(void) const +{ + return __limitLength; +} + +result +_EditPresenter::SetTextLimitLength(int limitLength) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (limitLength > 0), E_INVALID_ARG, "The invalid limit length is given."); + + String tempString = GetText(); + + int textLength = tempString.GetLength(); + SysTryReturnResult(NID_UI_CTRL, (limitLength >= textLength), E_INVALID_ARG, "The invalid argument is given."); + + TextSimple* pSimpleText = null; + + if (limitLength == GetTextLimitLength()) + { + return E_SUCCESS; + } + + wchar_t* pTempBuffer = new (std::nothrow) wchar_t[limitLength + 1]; + SysTryReturnResult(NID_UI_CTRL, pTempBuffer, E_OUT_OF_MEMORY, "Unable to allocate buffer."); + + for (int i = 0; i < textLength; i++) + { + pTempBuffer[i] = __pTextBuffer[i]; + } + + for (int i = textLength; i < limitLength; i++) + { + pTempBuffer[i] = 0; + } + + pTempBuffer[limitLength] = '\0'; + + __pTextString->Clear(); + __pTextString->Append(tempString); + if (__pTextBuffer) + { + delete[] __pTextBuffer; + __pTextBuffer = null; + } + __pTextBuffer = pTempBuffer; + + __pTextObject->RemoveAll(); + pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, textLength, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, __pFont); + SysTryReturnResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "Insufficient memory."); + + r = __pTextObject->AppendElement(*pSimpleText); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetCursorPosition(textLength); + + __limitLength = limitLength; + + return r; + +CATCH: + delete pSimpleText; + pSimpleText = null; + return r; +} + +result +_EditPresenter::InsertCharacterAt(int index, const Character& character) +{ + result r = E_SUCCESS; + + r = InsertTextAt(index, character.ToString()); + + return r; +} + +result +_EditPresenter::SetModel(const _EditModel& editModel) +{ + if (__pEditModel) + { + delete __pEditModel; + __pEditModel = null; + } + + __pEditModel = const_cast<_EditModel*>(&editModel); + + return E_SUCCESS; +} + +result +_EditPresenter::SetAutoLinkMask(unsigned long autoLinks) +{ + __isCutLinkParserEnabled = true; + return __pEditModel->SetAutoLinkMask(autoLinks); +} + +unsigned long +_EditPresenter::GetAutoLinkMask(void) const +{ + return __pEditModel->GetAutoLinkMask(); +} + +bool +_EditPresenter::IsViewModeEnabled(void) const +{ + return __pEditModel->IsViewModeEnabled(); +} + +result +_EditPresenter::SetViewModeEnabled(bool enable) +{ + if (!enable && __pEditModel->IsViewModeEnabled() && IsFocused()) + { + __pEdit->SetFocusOff(__pEdit); + } + + int editStyle = __pEdit->GetEditStyle(); + + if (enable) + { + editStyle = editStyle | EDIT_STYLE_VIEWER; + } + else + { + editStyle = editStyle & (~EDIT_STYLE_VIEWER); + } + __pEdit->SetEditStyle(editStyle); + + if (enable) + { + __pEdit->SetCursorPosition(0); + + if (__pInputConnection && __isInputConnectionBound) + { + HideKeypad(true); + } + } + + __pEditModel->SetKeypadEnabled(!enable); + __isCursorDisabled = enable; + __pTextObject->SetCutLinkViewMode(enable); + + if (__pInputConnection) + { + __pInputConnection->SetKeyEventSkipped(enable); + } + + + return __pEditModel->SetViewModeEnabled(enable); +} + +result +_EditPresenter::SetKeypadActionEnabled(bool enable) +{ + + result r = E_SUCCESS; + + r = __pInputConnection->SetInputPanelActionEnabled(enable); + + if (r == E_SUCCESS) + __pEditModel->SetKeypadActionEnabled(enable); + + return r; +} + +bool +_EditPresenter::IsKeypadActionEnabled(void) +{ + bool enable = true; + bool enableIc = true; + + enable = __pEditModel->IsKeypadActionEnabled(); + enableIc = __pInputConnection->IsInputPanelActionEnabled(); + + return enable; +} + +CoreKeypadAction +_EditPresenter::GetKeypadAction(void) const +{ + return __pEditModel->GetKeypadAction(); +} + +InputPanelAction +_EditPresenter::ConvertKeypadAction(CoreKeypadAction keypadAction) +{ + InputPanelAction inputPanelAction = INPUT_PANEL_ACTION_ENTER; + + switch (keypadAction) + { + case CORE_KEYPAD_ACTION_ENTER: + inputPanelAction = INPUT_PANEL_ACTION_ENTER; + break; + case CORE_KEYPAD_ACTION_GO: + inputPanelAction = INPUT_PANEL_ACTION_GO; + break; + case CORE_KEYPAD_ACTION_NEXT: + inputPanelAction = INPUT_PANEL_ACTION_NEXT; + break; + case CORE_KEYPAD_ACTION_SEND: + inputPanelAction = INPUT_PANEL_ACTION_SEND; + break; + case CORE_KEYPAD_ACTION_SEARCH: + inputPanelAction = INPUT_PANEL_ACTION_SEARCH; + break; + case CORE_KEYPAD_ACTION_LOGIN: + inputPanelAction = INPUT_PANEL_ACTION_LOGIN; + break; + case CORE_KEYPAD_ACTION_SIGN_IN: + inputPanelAction = INPUT_PANEL_ACTION_SIGN_IN; + break; + case CORE_KEYPAD_ACTION_JOIN: + inputPanelAction = INPUT_PANEL_ACTION_JOIN; + break; + case CORE_KEYPAD_ACTION_DONE: + inputPanelAction = INPUT_PANEL_ACTION_DONE; + break; + default: + break; + } + + return inputPanelAction; +} + + +result +_EditPresenter::SetKeypadAction(CoreKeypadAction keypadAction) +{ + return __pEditModel->SetKeypadAction(keypadAction); +} + +void +_EditPresenter::SetKeypadEnabled(bool enable) +{ + SetViewModeEnabled(!enable); + + return; +} + +bool +_EditPresenter::IsKeypadEnabled(void) +{ + bool enable = true; + if (__pEdit->IsEnabled()) + { + enable = __pEditModel->IsKeypadEnabled(); + } + else + { + enable = false; + } + + return enable; +} + +result +_EditPresenter::SetCurrentLanguage(LanguageCode languageCode) +{ + result r = E_SUCCESS; + + if (__pInputConnection && __isInputConnectionBound) + { + r = __pInputConnection->SetInputPanelLanguage(languageCode); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __pEditModel->SetInitialKeypadLanguage(LANGUAGE_INVALID); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = __pEditModel->SetInitialKeypadLanguage(languageCode); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pEditModel->SetCurrentLanguage(languageCode); + + return r; +} + +result +_EditPresenter::GetCurrentLanguage(LanguageCode& language) const +{ + result r = E_SUCCESS; + if (__pInputConnection && __isInputConnectionBound) + { + language = __pInputConnection->GetInputPanelLanguage(); + r = __pEditModel->SetCurrentLanguage(language); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + return __pEditModel->GetCurrentLanguage(language); +} + +void +_EditPresenter::SetLowerCaseModeEnabled(bool enable) +{ + __pEditModel->SetLowerCaseModeEnabled(enable); + + return; +} + +bool +_EditPresenter::IsLowerCaseModeEnabled(void) const +{ + return __pEditModel->IsLowerCaseModeEnabled(); +} + +KeypadStyle +_EditPresenter::GetKeypadStyle(void) const +{ + return __pEditModel->GetKeypadStyle(); +} + +result +_EditPresenter::SetKeypadStyle(KeypadStyle keypadStyle) +{ + + bool textPredictionEnabled = __pEditModel->IsTextPredictionEnabled(); + + InputPanelStyle inputPanelStyle = INPUT_PANEL_STYLE_NORMAL; + + switch (keypadStyle) + { + case KEYPAD_STYLE_NORMAL: + if (__isKeypadNormalNumberStyleEnabled) + { + inputPanelStyle = INPUT_PANEL_STYLE_NUMBER; + } + else + { + inputPanelStyle = INPUT_PANEL_STYLE_NORMAL; + } + break; + case KEYPAD_STYLE_PASSWORD: + inputPanelStyle = INPUT_PANEL_STYLE_NORMAL; + break; + case KEYPAD_STYLE_EMAIL: + inputPanelStyle = INPUT_PANEL_STYLE_EMAIL; + break; + case KEYPAD_STYLE_URL: + inputPanelStyle = INPUT_PANEL_STYLE_URL; + break; + case KEYPAD_STYLE_NUMBER: + inputPanelStyle = INPUT_PANEL_STYLE_NUMBER_ONLY; + textPredictionEnabled = false; + break; + case KEYPAD_STYLE_PHONE_NUMBER: + inputPanelStyle = INPUT_PANEL_STYLE_PHONE_NUMBER; + textPredictionEnabled = false; + break; + case KEYPAD_STYLE_IP_V4: + inputPanelStyle = INPUT_PANEL_STYLE_IP; + textPredictionEnabled = false; + break; + default: + break; + } + + if (__pInputConnection && __isInputConnectionBound) + { + __pInputConnection->SetTextPredictionEnabled(textPredictionEnabled); + __pInputConnection->SetInputPanelStyle(inputPanelStyle); + } + + __pEditModel->SetTextPredictionEnabled(textPredictionEnabled); + + return __pEditModel->SetKeypadStyle(keypadStyle); +} + +result +_EditPresenter::SetKeypadNormalNumberStyle(bool enable) +{ + __isKeypadNormalNumberStyleEnabled = enable; + return SetKeypadStyle(__pEditModel->GetKeypadStyle()); +} + +bool +_EditPresenter::IsTextPredictionEnabled(void) const +{ + return __pEditModel->IsTextPredictionEnabled(); +} + +result +_EditPresenter::SetTextPredictionEnabled(bool enable) +{ + KeypadStyle keypadStyle = __pEditModel->GetKeypadStyle(); + + if (keypadStyle == KEYPAD_STYLE_NUMBER ||keypadStyle == KEYPAD_STYLE_PHONE_NUMBER || + keypadStyle == KEYPAD_STYLE_IP_V4) + return E_UNSUPPORTED_OPERATION; + + if (__pInputConnection && __isInputConnectionBound) + { + __pInputConnection->SetTextPredictionEnabled(enable); + } + + return __pEditModel->SetTextPredictionEnabled(enable); +} + +result +_EditPresenter::InsertTextAtCursorPosition(const String& text) +{ + return InsertTextAt(__cursorPos, text); +} + +result +_EditPresenter::InsertTextAt(int position, const String& text, const Bitmap& textImage) +{ + result r = E_SUCCESS; + + int currentLength = GetTextLength(); + int length = text.GetLength(); + int totalLength = currentLength + length; + + SysTryReturnResult(NID_UI_CTRL, position >= 0 && position <= currentLength, E_OUT_OF_RANGE, "[EDIT] The given position is out-of-range."); + + if ((__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) || (__pEdit->GetEditStyle() & EDIT_STYLE_VIEWER)) + { + if (__limitLength <= totalLength) + { + String backupString = GetText(); + SetTextLimitLength(totalLength * 2); + SetText(backupString); + } + } + else + { + SysTryReturnResult(NID_UI_CTRL, totalLength <= __limitLength, E_MAX_EXCEEDED, "[EDIT] The text exceeds the limitation length."); + } + + if (__isInputConnectionBound == true && __isTextComposing == true) + { + __pInputConnection->FinishTextComposition(); + __isTextComposing = false; + __composingTextLength = 0; + } + + r = __pTextString->Insert(text, position); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + wchar_t* pInsertString = const_cast(text.GetPointer()); + + if (currentLength > position) + { + wchar_t pOriginalString[currentLength - position]; + + for (int i = 0; i < currentLength - position; i++) + { + pOriginalString[i] = __pTextBuffer[position + i]; + } + pOriginalString[currentLength - position] = 0; + + for (int i = 0; i < length; i++) + { + __pTextBuffer[i + position] = pInsertString[i]; + } + + for (int i = 0; i < currentLength - position; i++) + { + __pTextBuffer[i + position + length] = pOriginalString[i]; + } + } + else + { + for (int i = 0; i < length; i++) + { + __pTextBuffer[i + position] = pInsertString[i]; + } + } + + __pTextBuffer[totalLength] = 0; + + TextSimple* pSimpleText = null; + pSimpleText = new (std::nothrow) TextSimple(__pTextBuffer, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, GetFont()); + SysTryReturnResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[Edit] Unable to allocate text simple element."); + + pSimpleText->ChangeTextOffset(__pTextBuffer, position); + pSimpleText->SetBitmap((Bitmap&)textImage); + __pTextObject->InsertElementAt(position, *pSimpleText); + __pTextObject->ChangeTextOffset(__pTextBuffer, position+pSimpleText->GetTextLength(), pSimpleText->GetTextLength()); + __pTextObject->Compose(); + + if (__isTextBlocked == true) + { + DeleteText(__blockStartPos, __cursorPos); + ReleaseTextBlock(); + + SetCursorPosition(__cursorPos + length); + } + else + { + SetCursorPosition(position + length); + } + + if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) + { + AdjustFlexibleHeight(); + } + + __isCursorChanged = true; + __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT); + return r; +} + +result +_EditPresenter::DeleteCharacterAtCursorPosition(void) +{ + return DeleteCharacterAt(__cursorPos); +} + +bool +_EditPresenter::IsFocused(void) const +{ + return __pEdit->IsFocused(); +} + +bool +_EditPresenter::OnFocusGained(void) +{ + if (__isAutoShrinkEnabled) + { + int flexibleHeight = CalculateFlexibleHeight(); + Rectangle initialRect = GetInitialBounds(); + initialRect.height = flexibleHeight; + + SetFlexBounds(initialRect); + } + + if (!__pTextVisualElement) + { + result r = E_SUCCESS; + __pTextVisualElement = new (std::nothrow) _VisualElement; + SysTryReturn(NID_UI_CTRL, __pTextVisualElement != null, false, E_OUT_OF_MEMORY, "[EDIT] Unable to create __pTextVisualElement instance."); + + r = __pTextVisualElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct", GetErrorMessage(r)); + + __pTextVisualElement->SetSurfaceOpaque(false); + __pTextVisualElement->SetImplicitAnimationEnabled(false); + + __pTextVisualElement->SetShowState(true); + + _VisualElement* pEditVisualElement = __pEdit->GetVisualElement(); + SysTryCatch(NID_UI_CTRL, pEditVisualElement, , r = E_SYSTEM, "[E_SYSTEM] Unable to get root visual element."); + + pEditVisualElement->AttachChild(*__pTextVisualElement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child", GetErrorMessage(r)); + } + + if (__pEdit->GetEnableState() == false) + { + return false; + } + + __isCursorOpaque = true; + + if (__isInputConnectionBound == false && __isInitialized) + { + if (IsViewModeEnabled() == false) + { + CheckUSBKeyboardStatus(); + + if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY) + { + ShowKeypad(false); + } + else + { + ShowFullscreenKeypad(); + } + } + + __pEdit->Invalidate(); + } + + return true; +CATCH: + __pTextVisualElement->Destroy(); + __pTextVisualElement = null; + + return false; +} + +bool +_EditPresenter::OnNotifiedN(IList* pArgs) +{ + String showKeypad(L"ShowKeypad"); + String* pType = dynamic_cast (pArgs->GetAt(0)); + + if (pType) + { + if (*pType == showKeypad) + { + if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY) + { + ShowKeypad(false); + } + else + { + ShowFullscreenKeypad(); + } + } + pArgs->RemoveAll(true); + delete pArgs; + + return true; + } + + return false; +} + +void +_EditPresenter::OnFrameActivated(const _Frame& source) +{ + if (IsFocused() == true && __isInputConnectionBound == false && __isInitialized) + { + if (IsViewModeEnabled() == false) + { + CheckUSBKeyboardStatus(); + + if (__pEdit->GetInputStyle() == INPUT_STYLE_OVERLAY) + { + ShowKeypad(false); + } + } + } + + return; +} + +void +_EditPresenter::OnFrameDeactivated(const _Frame& source) +{ + return; +} + +bool +_EditPresenter::OnFocusLost(void) +{ + if (__isAutoShrinkEnabled) + { + Rectangle intialWindowBounds = GetInitialBounds(); + SetFlexBounds(intialWindowBounds); + } + + if (__pTextVisualElement) + { + __pTextVisualElement->Destroy(); + __pTextVisualElement = null; + } + + if (__pEdit == null) + { + return false; + } + + ReplaceTextIntoPasswordHyphenString(); + + if (__isInputConnectionBound) + { + + if (__pScrollBar && !(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL)) + { + __pScrollBar->SetScrollVisibility(false); + } + + __isCursorOpaque = false; + __isTouchMoving = false; + __isTouchReleaseSkipped = false; + __isUSBKeyboardConnected = false; + + AdjustParentPanelHeight(true); + + HideKeypad(); + } + + __pEdit->Invalidate(); + + return true; +} + +EditStatus +_EditPresenter::GetCurrentStatus(void) const +{ + EditStatus editState = EDIT_STATUS_NORMAL; + + if (__pEdit->IsEnabled()) + { + if (IsFocused()) + { + editState = EDIT_STATUS_HIGHLIGHTED; + } + else if (__isTouchPressed) + { + editState = EDIT_STATUS_PRESSED; + } + } + else + { + editState = EDIT_STATUS_DISABLED; + } + + return editState; +} + +_VisualElement* +_EditPresenter::GetCursorVisualElement(void) const +{ + return __pCursorVisualElement; +} + +void +_EditPresenter::SetMaxLineCount(int maxLineCount) +{ + __pEditModel->SetMaxLineCount(maxLineCount); + + return; +} + +int +_EditPresenter::GetMaxLineCount(void) const +{ + return __pEditModel->GetMaxLineCount(); +} + +result +_EditPresenter::UpdateComponentInformation(void) +{ + result r = E_SUCCESS; + + if (__isCursorChanged == false) + { + return r; + } + + bool setFirstDisplayLine = true; + if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)) + { + int firstDisplayY = __pTextObject->GetFirstDisplayPositionY(); + int totalHeight = __pTextObject->GetTotalHeight(); + Rectangle displayBounds = __pTextObject->GetBounds(); + if (totalHeight >= displayBounds.height) + { + int textGapFromBottom = displayBounds.height - (totalHeight - firstDisplayY); + if (textGapFromBottom > 0) + { + ScrollText(-textGapFromBottom); + } + } + + Rectangle absCursorBounds(0, 0, 0, 0); + CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds); + setFirstDisplayLine = (IsContained(absCursorBounds) == false); + } + + if (setFirstDisplayLine) + { + if (__pTextObject->IsChanged()) + { + __pTextObject->Compose(); + } + __pTextObject->SetFirstDisplayLineIndexFromTextIndex(__cursorPos); + } + + __pTextObject->SetCursorIndex(__cursorPos); + + __isCursorChanged = false; + + return r; +} + +void +_EditPresenter::ScrollText(int distance) +{ + int newFirstDisplayY = __pTextObject->GetFirstDisplayPositionY(); + newFirstDisplayY += distance; + + int moveLine = __pTextObject->GetLineIndexAtPositionY(newFirstDisplayY); + + __pTextObject->SetFirstDisplayLineIndex(moveLine); + __pTextObject->SetFirstDisplayPositionY(newFirstDisplayY); + + return; +} + +bool +_EditPresenter::IsContained(Rectangle& paramRect) const +{ + Rectangle absBounds = __pEdit->GetAbsoluteBounds(); + + if ((paramRect.x < absBounds.x) || + (paramRect.y < absBounds.y) || + ((paramRect.x + paramRect.width) > (absBounds.x + absBounds.width)) || + ((paramRect.y + paramRect.height) > (absBounds.y + absBounds.height))) + { + return false; + } + + return true; +} + +result +_EditPresenter::CalculateAbsoluteCursorBounds(int index, Rectangle& absCursorBounds) +{ + int cursorAbsX = 0; + int cursorAbsY = 0; + int cursorWidth = 0; + int cursorHeight = 0; + int cursorRelativeX = 0; + int cursorRelativeY = 0; + + Rectangle absBounds = __pEdit->GetAbsoluteBounds(); + + __pTextObject->SetBounds(GetTextBounds()); + if (__pTextObject->GetTextPositionInfoAt(index, cursorWidth, cursorHeight, cursorAbsX, cursorAbsY, cursorRelativeX, cursorRelativeY) != E_SUCCESS) + { + return E_SYSTEM; + } + + absCursorBounds.x = absBounds.x + cursorRelativeX; + + if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) + { + Rectangle tempBounds; + GetCursorBounds(true, tempBounds); + absCursorBounds.y = tempBounds.y; + } + else + { + absCursorBounds.y = absBounds.y + cursorRelativeY; + } + + absCursorBounds.width = cursorWidth; + + if (cursorHeight > 0) + { + absCursorBounds.height = cursorHeight; + } + else + { + absCursorBounds.height = __pTextObject->GetLineHeightAt(0); + } + + return E_SUCCESS; +} + +result +_EditPresenter::GetCursorBounds(bool isAbsRect, Rectangle& cursorBounds) +{ + if (__isInitialized == false) + { + return E_SYSTEM; + } + + CalculateCursorBounds(GetTextBounds(), cursorBounds); + + if (isAbsRect) + { + Rectangle absBounds = __pEdit->GetAbsoluteBounds(); + cursorBounds.x += absBounds.x; + cursorBounds.y += absBounds.y; + } + + return E_SUCCESS; +} + +void +_EditPresenter::SetCursorDisabled(bool disabled) +{ + __isCursorDisabled = disabled; + + return; +} + +bool +_EditPresenter::IsGuideTextActivated(void) const +{ + if (__pGuideTextObject == null) + { + return false; + } + + if (GetGuideText().IsEmpty()) + { + return false; + } + + if (__pTextObject && GetTextLength() > 0) + { + return false; + } + + return true; +} + +_Button* +_EditPresenter::CreateCommandButtonItemN(int actionId, const String& text) +{ + result r = E_SUCCESS; + _Button* pButton = _Button::CreateButtonN(); + SysTryReturn(NID_UI_CTRL, pButton, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance."); + + int textSize = 0; + + r = pButton->SetActionId(actionId); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pButton->SetText(text); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_FONT_SIZE, __pEdit->GetOrientation(), textSize); + if (!IsFailed(r)) + { + r = pButton->SetTextSize(textSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pButton; + +CATCH: + delete pButton; + + return null; +} + +result +_EditPresenter::SetKeypadCommandButton(const Rectangle& bounds) +{ + result r = E_SUCCESS; + Bitmap* pNormalBackgroundBitmap = null; + Bitmap* pReplacementColorBackgroundBitmap = null; + String leftButtonText; + String rightButtonText; + _Control* pParent = null; + Color commandBackgroundColor; + + if (__pCommandButton) + { + __pCommandButton->SetResizable(true); + __pCommandButton->SetMovable(true); + + r = __pCommandButton->SetBounds(bounds); + + __pCommandButton->SetResizable(false); + __pCommandButton->SetMovable(false); + + return r; + } + + __pCommandButton = _Toolbar::CreateToolbarN(false); + SysTryReturn(NID_UI_CTRL, __pCommandButton, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance."); + + r = __pCommandButton->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap); + if (pNormalBackgroundBitmap) + { + GET_COLOR_CONFIG(FOOTER::BG_NORMAL, commandBackgroundColor); + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), commandBackgroundColor); + + if (pReplacementColorBackgroundBitmap) + { + r = __pCommandButton->SetBackgroundBitmap(*pReplacementColorBackgroundBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pReplacementColorBackgroundBitmap; + pReplacementColorBackgroundBitmap = null; + } + delete pNormalBackgroundBitmap; + pNormalBackgroundBitmap = null; + } + + r = __pCommandButton->SetStyle(TOOLBAR_TEXT); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pCommandButton->SetResizable(true); + __pCommandButton->SetMovable(true); + + r = __pCommandButton->SetBounds(bounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pCommandButton->SetResizable(false); + __pCommandButton->SetMovable(false); + + leftButtonText = __pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_LEFT); + r = __pCommandButton->AddItem(CreateCommandButtonItemN(__pEditModel->GetKeypadCommandButtonActionId(COMMAND_BUTTON_POSITION_LEFT), leftButtonText)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + rightButtonText = __pEditModel->GetKeypadCommandButtonText(COMMAND_BUTTON_POSITION_RIGHT); + r = __pCommandButton->AddItem(CreateCommandButtonItemN(__pEditModel->GetKeypadCommandButtonActionId(COMMAND_BUTTON_POSITION_RIGHT), rightButtonText)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pActionEventListener) + { + __pCommandButton->AddActionEventListener(*__pActionEventListener); + } + + if (GetParentForm()) + { + r = GetParentForm()->AttachChild(*__pCommandButton); + GetParentForm()->MoveChildToTop(*__pCommandButton); + } + else + { + pParent = __pEdit->GetParent(); + SysTryCatch(NID_UI_CTRL, pParent, r = E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r)); + r = pParent->AttachChild(*__pCommandButton); + } + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete pNormalBackgroundBitmap; + + delete __pCommandButton; + __pCommandButton = null; + + return r; +} + +void +_EditPresenter::CheckFooterVisible(void) +{ + _Form* pParentForm = GetParentForm(); + if (pParentForm == null) + { + return; + } + + _Toolbar* pFooter = pParentForm->GetFooter(); + if (pFooter) + { + if (pFooter->GetVisibleState() == false) + { + __footerVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_HIDE; + } + else + { + __footerVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_SHOW; + } + } + else + { + __footerVisibleStatus = EDIT_FOOTER_VISIBLE_STATUS_NONE; + } + + return; +} + +void +_EditPresenter::SetFooterVisible(bool isVisible) +{ + _Form* pParentForm = GetParentForm(); + if (pParentForm == null) + { + return; + } + + _Toolbar* pFooter = pParentForm->GetFooter(); + if (pFooter && __footerVisibleStatus == EDIT_FOOTER_VISIBLE_STATUS_SHOW) + { + if ((isVisible == true && pFooter->GetVisibleState() == false) || + (isVisible == false && pFooter->GetVisibleState() == true)) + { + pFooter->SetVisibleState(isVisible); + pFooter->Invalidate(); + } + } + + return; +} + +result +_EditPresenter::ShowFullscreenKeypad(void) +{ + result r = E_SUCCESS; + + if (__pFullscreenKeypad) + { + delete __pFullscreenKeypad; + __pFullscreenKeypad = null; + } + + int editStyle = __pEdit->GetEditStyle(); + + _KeypadStyleInfo keypadStyleInfo; + keypadStyleInfo.keypadStyle = __pEditModel->GetKeypadStyle(); + keypadStyleInfo.textPredictionEnabled = __pEditModel->IsTextPredictionEnabled(); + keypadStyleInfo.isNormalNumberStyle = __isKeypadNormalNumberStyleEnabled; + keypadStyleInfo.enterActionEnabled = true; + keypadStyleInfo.isLowerCaseModeEnabled = __pEditModel->IsLowerCaseModeEnabled(); + + if (editStyle & EDIT_STYLE_SINGLE_LINE) + { + keypadStyleInfo.enterActionEnabled = false; + } + + if (editStyle & EDIT_STYLE_PASSWORD) + { + editStyle = EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_PASSWORD; + } + else + { + editStyle = EDIT_STYLE_NORMAL; + } + + __pFullscreenKeypad = _Keypad::CreateKeypadN(); + SysTryReturn(NID_UI_CTRL, __pFullscreenKeypad, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance."); + r = __pFullscreenKeypad->Initialize(editStyle, keypadStyleInfo, GetTextLimitLength(), __pEdit); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pFullscreenKeypad->SetText(GetText()); + + r = __pFullscreenKeypad->Open(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pEdit->IsInputEnabled()) + { + __pEdit->SetInputEnableState(false); + } + + return r; +} + +result +_EditPresenter::GetKeypadBounds(Rectangle& bounds) const +{ + if (__pInputConnection == null) + { + return E_SYSTEM; + } + + bounds = __pInputConnection->GetInputPanelBounds(); + + _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance(); + SysTryReturnResult(NID_UI_CTRL, pCoordSystem, E_SYSTEM, "[EDIT] Coordinate system load failed."); + + _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetInverseTransformer(); + SysTryReturnResult(NID_UI_CTRL, pXformer, E_SYSTEM, "[EDIT] Coordinate system load failed."); + + bounds = pXformer->Transform(bounds); + + return E_SUCCESS; +} + +result +_EditPresenter::ShowKeypad(bool focus) +{ + SysTryReturnResult(NID_UI_CTRL, IsKeypadEnabled() == true, E_INVALID_STATE, "[EDIT] Keypad is not enabled."); + + if (focus) + { + __pEdit->SetFocused(); + } + + if (!__isInitialized) + { + return E_SUCCESS; + } + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + + if (!pControlManager->IsFrameActivated()) + { + return E_SUCCESS; + } + + __pInputConnection->BindInputMethod(); + __isInputConnectionBound = true; + __isKeypadShowing = true; + + SetKeypadStyle(__pEditModel->GetKeypadStyle()); + + if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE && GetKeypadAction() == CORE_KEYPAD_ACTION_ENTER) + { + __pInputConnection->SetInputPanelActionEnabled(false); + } + else + { + __pInputConnection->SetInputPanelAction(ConvertKeypadAction(GetKeypadAction())); + } + + //Need to complete AutoCapitalization functionality + if (__pEditModel->IsLowerCaseModeEnabled()) + { + __pInputConnection->SetAutoCapitalizationMode(AUTO_CAPITALIZATION_MODE_NONE); + } + else + { + __pInputConnection->SetAutoCapitalizationMode(AUTO_CAPITALIZATION_MODE_SENTENCE); + } + + LanguageCode initialKeypadLanguage = LANGUAGE_INVALID; + __pEditModel->GetInitialKeypadLanguage(initialKeypadLanguage); + if (initialKeypadLanguage != LANGUAGE_INVALID) + { + SetCurrentLanguage(initialKeypadLanguage); + } + + if (!__isUSBKeyboardConnected) + { + __pInputConnection->ShowInputPanel(); + __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED); + } + else + { + if (__isKeypadCommandButtonVisible) + { + __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CREATED); + } + } + + if (__isKeypadCommandButtonVisible) + { + CheckFooterVisible(); + SetFooterVisible(false); + } + + ChangeLayoutInternal(__pEdit->GetOrientation()); + + AdjustParentPanelHeight(false); + + ScrollPanelToTop(false); + ScrollPanelToCursorPosition(); + + __pEdit->AttachScrollPanelEvent(); + __pEdit->SendScrollPanelEvent(CORE_OVERLAY_CONTROL_CREATED); + + if (__isUSBKeyboardConnected) + { + __pEdit->Invalidate(); + } + + if (__isUSBKeyboardConnected) + { + if (__isKeypadCommandButtonVisible) + { + __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_OPEN); + } + } + + return E_SUCCESS; +} + +result +_EditPresenter::ChangeLayout(_ControlOrientation orientation) +{ + result r = E_SUCCESS; + + int commandButtonHeight = 0; + + if (__pCopyPasteManager) + { + __pCopyPasteManager->SetTextBlockReleaseFlag(false); + InitializeCopyPasteManager(); + } + + __rotated = true; + + CheckUSBKeyboardStatus(); + if (__isInputConnectionBound) + { + if (IsKeypadExist()) + { + _Form* pParentForm = GetParentForm(); + + if (pParentForm) + { + _Toolbar* pFooter = pParentForm->GetFooter(); + + if (pFooter && pFooter->GetVisibleState()) + { + GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonHeight); + } + + pParentForm->DeflateClientRectHeight(commandButtonHeight); + } + if (__pCommandButton && __pCommandButton->GetVisibleState()) + { + __pCommandButton->SetVisibleState(false); + } + } + else //usb mode on or bounded after keypad drag + { + ChangeLayoutInternal(orientation); + } + } + + __initialBounds = __pEdit->GetBounds(); + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to change layout.", GetErrorMessage(r)); + + return r; +} + +result +_EditPresenter::ChangeLayoutInternal(_ControlOrientation orientation) +{ + result r = E_SUCCESS; + + _Form* pParentForm = GetParentForm(); + Rectangle keypadBounds; + GetKeypadBounds(keypadBounds); + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturnResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "[EDIT] Failed to get root."); + Dimension screenSize; + Rectangle commandButtonBounds(0, 0, 0, 0); + + int formDeflateHeight = 0; + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + screenSize.width = pControlManager->GetScreenSize().width; + screenSize.height = pControlManager->GetScreenSize().height; + } + else + { + screenSize.width = pControlManager->GetScreenSize().height; + screenSize.height = pControlManager->GetScreenSize().width; + } + + if (__isInputConnectionBound) + { + if (__isKeypadCommandButtonVisible) + { + commandButtonBounds.width = screenSize.width; + GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonBounds.height); + + if (pParentForm) + { + formDeflateHeight += commandButtonBounds.height; + + if (IsKeypadExist()) + { + formDeflateHeight += keypadBounds.height; + commandButtonBounds.y = screenSize.height - keypadBounds.height - commandButtonBounds.height - pParentForm->GetClientBounds().y; + } + else + { + commandButtonBounds.y = screenSize.height - commandButtonBounds.height - pParentForm->GetClientBounds().y; + } + } + else + { + if (IsKeypadExist()) + { + commandButtonBounds.y = screenSize.height - keypadBounds.height - commandButtonBounds.height; + } + else + { + commandButtonBounds.y = screenSize.height - commandButtonBounds.height; + } + } + + r = SetKeypadCommandButton(commandButtonBounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pCommandButton) + { + __pCommandButton->SetVisibleState(true); + } + } + else + { + if (pParentForm) + { + if (IsKeypadExist()) + { + formDeflateHeight += keypadBounds.height; + } + } + } + } + + if (pParentForm) + pParentForm->DeflateClientRectHeight(formDeflateHeight); + + return r; +} + +void +_EditPresenter::OnScrollPanelBoundsChanged(void) +{ + if (__pParentPanel && __isPanelBoundsChanging == false) + { + __initialParentHeight = __pParentPanel->GetBounds().height; + if (__pParentPanel->GetOrientation() == __pEdit->GetOrientation()) + { + AdjustParentPanelHeight(false); + ScrollPanelToTop(false); + ScrollPanelToCursorPosition(); + } + } + + return; +} + +void +_EditPresenter::AdjustParentPanelHeight(bool restore, bool panelResizeByPrediction) +{ + if (__pParentPanel == null) + { + return; + } + + _ControlOrientation orientation; + int commandButtonHeight = 0; + + Rectangle absKeypadBounds; + result r = GetKeypadBounds(absKeypadBounds); + + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Form* pParentForm = GetParentForm(); + _Toolbar* pFooter = null; + + if (pParentForm) + { + pFooter = pParentForm->GetFooter(); + } + + Rectangle absScrollPanelBounds; + Rectangle scrollPanelBounds = __pParentPanel->GetBounds(); + int gapY = 0; + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + int displayedPanelHeight = 0; + Dimension screenSize; + + if (__pEdit->GetOrientation()== _CONTROL_ORIENTATION_PORTRAIT) + { + screenSize.width = pControlManager->GetScreenSize().width; + screenSize.height = pControlManager->GetScreenSize().height; + } + else + { + screenSize.width = pControlManager->GetScreenSize().height; + screenSize.height = pControlManager->GetScreenSize().width; + } + + if (panelResizeByPrediction) + restore = false; + + if (restore) + { + if (__initialParentHeight) + { + scrollPanelBounds.height = __initialParentHeight; + + __initialParentHeight = 0; + __isPanelBoundsChanging = true; + __pParentPanel->SetBounds(scrollPanelBounds); + __isPanelBoundsChanging = false; + __pParentPanel->Invalidate(); + } + } + else + { + if (__isKeypadCommandButtonVisible || (pFooter && (pFooter->GetVisibleState() == true))) + { + orientation = __pEdit->GetOrientation(); + GET_SHAPE_CONFIG(FOOTER::HEIGHT, orientation, commandButtonHeight); + } + + absScrollPanelBounds = __pParentPanel->GetAbsoluteBounds(); + displayedPanelHeight = screenSize.height - commandButtonHeight - absScrollPanelBounds.y; + gapY = (absKeypadBounds.y - commandButtonHeight)- absScrollPanelBounds.y; + + if (panelResizeByPrediction) + { + if (__isUSBKeyboardConnected) + { + if (gapY > 0) + { + scrollPanelBounds.height = gapY; + + __isPanelBoundsChanging = true; + __pParentPanel->SetBounds(scrollPanelBounds); + __isPanelBoundsChanging = false; + + __pParentPanel->Invalidate(); + } + } + else + { + if ((gapY > 0) && __initialParentHeight) + { + scrollPanelBounds.height = gapY; + + __isPanelBoundsChanging = true; + __pParentPanel->SetBounds(scrollPanelBounds); + __isPanelBoundsChanging = false; + + __pParentPanel->Invalidate(); + } + } + } + else + { + if ((absKeypadBounds.y - commandButtonHeight) >= (absScrollPanelBounds.y + absScrollPanelBounds.height)) + { + return; + } + + if ((gapY > 0) && (gapY < displayedPanelHeight) && !__initialParentHeight) + { + __initialParentHeight = scrollPanelBounds.height; + + scrollPanelBounds.height = gapY; + + __isPanelBoundsChanging = true; + __pParentPanel->SetBounds(scrollPanelBounds); + __isPanelBoundsChanging = false; + + __pParentPanel->Invalidate(); + } + } + } + + return; +} + +result +_EditPresenter::HideKeypad(bool focus) +{ + InitializeCopyPasteManager(); + + __isKeypadShowing = false; + + if (__isInitialized == false) + { + return E_SUCCESS; + } + + if (__isInputConnectionBound) + { + __pInputConnection->FinishTextComposition(); + __pInputConnection->HideInputPanel(); + __pInputConnection->UnbindInputMethod(); + __isKeypadHiding = true; + __isTextComposing = false; + __composingTextLength = 0; + } + + if (__pCommandButton && __pCommandButton->GetVisibleState() == true) + { + SetFooterVisible(true);//must be called ahead of DeflateClientRectHeights + __pCommandButton->SetVisibleState(false); + } + + _Form* pParentForm = GetParentForm(); + if (pParentForm) + { + pParentForm->DeflateClientRectHeight(0); + } + + AdjustParentPanelHeight(true); + + __isInputConnectionBound = false; + + if (focus && IsFocused() && pParentForm) + { + pParentForm->SetFocused(); + } + + if (__isUSBKeyboardConnected) + { + if (__isKeypadCommandButtonVisible) + { + __pEdit->SendKeypadEvent(GetKeypadAction(), CORE_KEYPAD_EVENT_STATUS_CLOSE); + } + } + + return E_SUCCESS; +} + +void +_EditPresenter::ChangeKeypadStatus(void) +{ + InitializeCopyPasteManager(); + + if (__isInputConnectionBound) + { + __isInputConnectionBound = false; + } + + return; +} + +void +_EditPresenter::OnTimerExpired(Timer& timer) +{ + Timer* onTimer = &timer; + + if (onTimer == __pCursorTimer) + { + OnCursorTimerExpired(); + } + else if (onTimer == __pTitleSlidingTimer) + { + OnTitleSlidingTimerExpired(); + } + else if (onTimer == __pPasswordTimer) + { + OnPasswordTimerExpired(); + } + else if (onTimer == __pFlickAnimationTimer) + { + OnFlickTimerExpired(); + } + + return; +} + +void +_EditPresenter::OnEditCopyPasteStatusChanged(CoreCopyPasteStatus status, CoreCopyPasteAction action) +{ + switch (action) + { + case CORE_COPY_PASTE_ACTION_COPY: + __pEdit->CopyText(); + break; + case CORE_COPY_PASTE_ACTION_CUT: + __pEdit->CutText(); + break; + case CORE_COPY_PASTE_ACTION_PASTE: + __pEdit->PasteText(); + break; + default: + break; + } + InitializeCopyPasteManager(); + __pEdit->Invalidate(); + + return; +} + +result +_EditPresenter::InitializeCursor(void) +{ + StopCursorTimer(); + + if (__isCursorDisabled == false && IsFocused() && __isTextBlocked == false) + { + Rectangle cursorBounds; + CalculateCursorBounds(__textObjectBounds, cursorBounds); + + __pCursorVisualElement->SetOpacity(1.0f); + __pCursorVisualElement->SetBounds(FloatRectangle(cursorBounds.x, cursorBounds.y, cursorBounds.width, cursorBounds.height)); + + Canvas* pCanvas = __pCursorVisualElement->GetCanvasN(); + if (pCanvas == null) + { + return E_SYSTEM; + } + __isCursorInitialized = false; + DrawCursor(*pCanvas, cursorBounds, __isCursorOpaque); + + if (__pInputConnection) + { + Rectangle absoluteEditRectangle; + if (GetCursorBounds(false, absoluteEditRectangle) == E_SUCCESS) + { + __pInputConnection->SetCursorBounds(absoluteEditRectangle); + } + } + __isCursorOpaque = __isCursorOpaque ? false : true; + + delete pCanvas; + + __previousCursorBounds = cursorBounds; + StartCursorTimer(); + } + else + { + __pCursorVisualElement->SetOpacity(0); + } + + if (__pInputConnection != null && __isInputConnectionBound == true && !__isCopyPastePopupVisible) + { + __pInputConnection->SetCursorPosition(__cursorPos); + } + + return E_SUCCESS; +} + +void +_EditPresenter::StopCursorTimer(void) +{ + if (__pCursorTimer) + { + __pCursorTimer->Cancel(); + delete __pCursorTimer; + __pCursorTimer = null; + } + return; +} + +result +_EditPresenter::StartCursorTimer(void) +{ + result r = E_SUCCESS; + + if (__pCursorTimer == null) + { + __pCursorTimer = new (std::nothrow) Timer; + if (__pCursorTimer == null) + { + return E_OUT_OF_MEMORY; + } + + r = __pCursorTimer->Construct(*this); + if (IsFailed(r)) + { + goto CATCH; + } + } + + r = __pCursorTimer->Start(EDIT_CURSOR_TIMER_PERIOD); + if (IsFailed(r)) + { + goto CATCH; + } + + return r; + +CATCH: + StopCursorTimer(); + + return r; +} + +result +_EditPresenter::DrawCursor(Canvas& canvas, Rectangle& cursorBounds, bool isCursorOpaque) +{ + result r = E_SUCCESS; + + if (__isCursorDisabled == false) + { + Color cursorColor; + GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor); + + if (__isCursorInitialized) + { + cursorBounds.SetPosition(0, 0); + + if (canvas.GetBackgroundColor() != cursorColor) + { + canvas.FillRectangle(cursorColor, cursorBounds); + } + + if (isCursorOpaque) + { + __pCursorVisualElement->SetOpacity(1.0f); + } + else + { + __pCursorVisualElement->SetOpacity(0); + } + } + else + { + cursorBounds.SetPosition(0, 0); + + canvas.FillRectangle(cursorColor, cursorBounds); + __isCursorInitialized = true; + + } + } + else + { + __pCursorVisualElement->SetOpacity(0); + } + + return r; +} + +result +_EditPresenter::MoveCursor(const Rectangle& fromRect, const Rectangle& toRect) +{ + if ((__previousCursorBounds.x != fromRect.x) || (__previousCursorBounds.y != fromRect.y) || (__previousCursorBounds.width != fromRect.width) || (__previousCursorBounds.height != fromRect.height)) + { + return E_SYSTEM; + } + + __pCursorVisualElement->SetOpacity(0); + + __pCursorVisualElement->SetBounds(FloatRectangle(toRect.x, toRect.y, toRect.width, toRect.height)); + Canvas* pCanvas = __pCursorVisualElement->GetCanvasN(); + + if (pCanvas == null) + { + return E_SYSTEM; + } + + if (toRect.y < 0 || toRect.y >= __clientBounds.height || + toRect.x < 0 || toRect.x >= __clientBounds.width) + { + delete pCanvas; + return E_SYSTEM; + } + + __pCursorVisualElement->SetOpacity(1.0f); + + Color cursorColor; + + GET_COLOR_CONFIG(EDIT::CURSOR_NORMAL, cursorColor); + + pCanvas->FillRectangle(cursorColor, toRect); + + __previousCursorBounds = toRect; + delete pCanvas; + + return E_SUCCESS; +} + +void +_EditPresenter::OnCursorTimerExpired(void) +{ + if (!IsFocused() && __isCursorDisabled) + { + StopCursorTimer(); + return; + } + + Rectangle cursorBounds; + + if (CalculateCursorBounds(__textObjectBounds, cursorBounds) != E_SUCCESS) + { + return; + } + + if ((__previousCursorBounds.x != cursorBounds.x) || (__previousCursorBounds.y != cursorBounds.y) || (__previousCursorBounds.width != cursorBounds.width) || (__previousCursorBounds.height != cursorBounds.height)) + { + __previousCursorBounds = cursorBounds; + } + + if (__pCursorVisualElement) + { + __pCursorVisualElement->SetBounds(FloatRectangle(cursorBounds.x, cursorBounds.y, cursorBounds.width, cursorBounds.height)); + Canvas* pCanvas = __pCursorVisualElement->GetCanvasN(); + if (pCanvas == null) + { + return; + } + + DrawCursor(*pCanvas, cursorBounds, __isCursorOpaque); + + delete pCanvas; + } + + __isCursorOpaque = __isCursorOpaque ? false : true; + StartCursorTimer(); + + return; +} + +EllipsisPosition +_EditPresenter::GetEllipsisPosition(void) const +{ + return __pEdit->GetEllipsisPosition(); +} + +result +_EditPresenter::SetEllipsisPosition(EllipsisPosition position) +{ + result r = E_SUCCESS; + TextObjectEllipsisType ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_TAIL; + if (position == ELLIPSIS_POSITION_START) + { + ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_HEAD; + } + else if (position == ELLIPSIS_POSITION_MIDDLE) + { + ellipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_MIDDLE; + } + + __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + r = __pTextObject->SetTextObjectEllipsisType(ellipsisType); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[EDIT] Unable to Set ellipsis position."); + + return r; +} + +void +_EditPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = __contentFontStyle; + size = __contentFontSize; + + return; +} + +void +_EditPresenter::OnFontChanged(Font* pFont) +{ + if (!__isFontInitialized) + { + return; + } + + result r = E_SUCCESS; + + r = AdjustFont(*pFont, EDIT_FONT_CHANGE_ALL); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[EDIT] Unable to set font."); + + __titleFontFaceName = pFont->GetFaceName(); + + return; +} + +Font* +_EditPresenter::GetFont(void) const +{ + return __pFont; +} + +int +_EditPresenter::GetTextSize(void) const +{ + return __contentFontSize; +} + +unsigned int +_EditPresenter::GetFontStyle(const Font* pBaseFont) const +{ + unsigned long style = FONT_STYLE_MIN; + + if (pBaseFont->IsPlain()) + { + style |= FONT_STYLE_PLAIN; + } + if (pBaseFont->IsItalic()) + { + style |= FONT_STYLE_ITALIC; + } + if (pBaseFont->IsBold()) + { + style |= FONT_STYLE_BOLD; + } + + return style; +} + +result +_EditPresenter::SetTextSize(const int size) +{ + result r = E_SUCCESS; + _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = fontImpl->SetSize(size); + SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed."); + + if (__pTextObject) + { + r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON; + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font."); + } + + if (IsGuideTextActivated()) + { + r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength()); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font."); + } + + __contentFontSize = size; + return r; +} + +result +_EditPresenter::SetFont(const Font& font) +{ + result r = E_SUCCESS; + + Font* pFont = _FontImpl::CloneN(const_cast (font)); + SysTryReturnResult(NID_UI_CTRL, pFont, GetLastResult(), "[EDIT] Unable to create font."); + + __pFont = pFont; + + if (__pTextObject) + { + r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON; + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[EDIT] Unable to set font."); + } + + if (IsGuideTextActivated()) + { + r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength()); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[EDIT] Unable to set font."); + } + + return r; +} + +result +_EditPresenter::AdjustFont(Font& font, _EditFontChange fontChange) +{ + result r = E_SUCCESS; + Font* pFont = &font; + + _FontImpl* fontImpl = _FontImpl::GetInstance(*pFont); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (fontChange == EDIT_FONT_CHANGE_TITLE || fontChange == EDIT_FONT_CHANGE_ALL) + { + if (__pTitleTextObject) + { + r = fontImpl->SetSize(__titleFontSize); + SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed."); + + r = __pTitleTextObject->SetFont(pFont, 0, __pTitleTextObject->GetTextLength()); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font."); + } + } + + if (fontChange == EDIT_FONT_CHANGE_CONTENT || fontChange == EDIT_FONT_CHANGE_ALL) + { + r = fontImpl->SetSize(__contentFontSize); + SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed."); + + unsigned long style = FONT_STYLE_PLAIN; + + if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_BOLD) + { + style |= FONT_STYLE_BOLD; + } + if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_ITALIC) + { + style |= FONT_STYLE_ITALIC; + } + + fontImpl->SetStyle(style); + + if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_UNDERLINE) + { + fontImpl->SetUnderline(true); + } + if (__contentTextStyle & TEXT_BOX_TEXT_STYLE_STRIKEOUT) + { + fontImpl->SetStrikeOut(true); + } + + if (__pTextObject) + { + r = __pTextObject->SetFont(pFont, 0, __pTextObject->GetTextLength()); + __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON; + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font."); + } + + if (IsGuideTextActivated()) + { + r = __pGuideTextObject->SetFont(pFont, 0, __pGuideTextObject->GetTextLength()); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font."); + } + } + + __pFont = pFont; + + return r; +} + +String +_EditPresenter::GetTitleFontFaceName(void) +{ + return __titleFontFaceName; +} + +result +_EditPresenter::GetFontType(String& typefaceName, unsigned long& styleMask) const +{ + result r = E_SUCCESS; + + if (__pFont) + { + typefaceName = __pFont->GetFaceName(); + } + + styleMask = __contentTextStyle; + + return r; +} + +result +_EditPresenter::SetFontType(const String& typefaceName, unsigned long styleMask) +{ + result r = E_SUCCESS; + + Font* pFont = null; + IList* systemFontList = Font::GetSystemFontListN(); + SysTryReturnResult(NID_UI_CTRL, systemFontList, E_SYSTEM, "[EDIT] Unable to get system font list.\n"); + + int fontListCount = systemFontList->GetCount(); + String tempFontFaceName; + bool isFaceNameAvailable = false; + + int textSize = __pFont->GetSize(); + unsigned long fontStyle = FONT_STYLE_PLAIN; + + if (styleMask & TEXT_BOX_TEXT_STYLE_ITALIC) + { + fontStyle |= FONT_STYLE_ITALIC; + } + if (styleMask & TEXT_BOX_TEXT_STYLE_BOLD) + { + fontStyle |= FONT_STYLE_BOLD; + } + + for (int i = 0; i < fontListCount; i++) + { + tempFontFaceName = *static_cast(systemFontList->GetAt(i)); + + pFont = new (std::nothrow) Font; + SysTryCatch(NID_UI_CTRL, pFont, , r = E_OUT_OF_MEMORY, "[EDIT] Unable to get text information.\n"); + r = pFont->Construct(tempFontFaceName, fontStyle, textSize); + SysTryCatch(NID_UI_CTRL, !IsFailed(r), , r, "[EDIT] Unable to construct Font.\n"); + + // check font face name. + if (typefaceName.Equals(pFont->GetFaceName(), true)) + { + isFaceNameAvailable = true; + break; + } + + delete pFont; + pFont = null; + } + + SysTryCatch(NID_UI_CTRL, isFaceNameAvailable, , r = E_INVALID_ARG, "[EDIT] The unsupported font face name is given.\n"); + + if (styleMask & TEXT_BOX_TEXT_STYLE_UNDERLINE) + { + pFont->SetUnderline(true); + } + if (styleMask & TEXT_BOX_TEXT_STYLE_STRIKEOUT) + { + pFont->SetStrikeOut(true); + } + + __contentFontStyle = fontStyle; + __contentTextStyle = styleMask; + + __pFont = pFont; + + systemFontList->RemoveAll(true); + delete systemFontList; + systemFontList = null; + + if (__pTextObject) + { + r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON; + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[EDIT] Unable to set font."); + } + + return r; +CATCH: + if (pFont) + { + delete pFont; + pFont = null; + } + + systemFontList->RemoveAll(true); + delete systemFontList; + systemFontList = null; + + return r; +} + +unsigned long +_EditPresenter::GetTextStyle(void) const +{ + return __contentTextStyle; +} + +result +_EditPresenter::SetTextStyle(unsigned long textStyle) +{ + result r = E_SUCCESS; + + _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + unsigned long style = FONT_STYLE_PLAIN; + + if (textStyle & TEXT_BOX_TEXT_STYLE_BOLD) + { + style |= FONT_STYLE_BOLD; + } + if (textStyle & TEXT_BOX_TEXT_STYLE_ITALIC) + { + style |= FONT_STYLE_ITALIC; + } + + fontImpl->SetStyle(style); + + if (textStyle & TEXT_BOX_TEXT_STYLE_UNDERLINE) + { + fontImpl->SetUnderline(true); + } + else + { + fontImpl->SetUnderline(false); + } + + if (textStyle & TEXT_BOX_TEXT_STYLE_STRIKEOUT) + { + fontImpl->SetStrikeOut(true); + } + else + { + fontImpl->SetStrikeOut(false); + } + + if (__pTextObject) + { + r = __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + __ContentTextStatus = EDIT_TEXT_STATUS_COMPOSE_NON; + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font."); + } + + if (IsGuideTextActivated()) + { + r = __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength()); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[EDIT] Unable to set font."); + } + + __contentTextStyle = textStyle; + + return r; +} + +String +_EditPresenter::GetGuideText(void) const +{ + return __guideText; +} + +result +_EditPresenter::SetGuideText(const String& guideText) +{ + result r = E_SUCCESS; + + int length = guideText.GetLength(); + + __guideText = String(guideText); + wchar_t* tempString = const_cast(__guideText.GetPointer()); + + // guide text + if (__pGuideTextObject != null) + { + delete __pGuideTextObject; + __pGuideTextObject = null; + } + + __pGuideTextObject = new (std::nothrow) TextObject; + if (__pGuideTextObject == null) + { + return E_OUT_OF_MEMORY; + } + __pGuideTextObject->Construct(); + TextSimple* pSimpleText = new (std::nothrow)TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + __pGuideTextObject->AppendElement(*pSimpleText); + + __pGuideTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pGuideTextObject->SetFont(__pFont, 0, __pGuideTextObject->GetTextLength()); + + if (__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE) + { + __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); + } + else + { + __pGuideTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP); + } + + if (!(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)) + { + __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_CHARACTER); + } + else + { + __pGuideTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + } + + return r; +} + +String +_EditPresenter::GetTitleText(void) const +{ + return __titleText; +} + +result +_EditPresenter::SetTitleText(const String& title) +{ + result r = E_SUCCESS; + + int length = title.GetLength(); + + __titleText = String(title); + wchar_t* tempString = const_cast(__titleText.GetPointer()); + + if (__pTitleTextObject != null) + { + delete __pTitleTextObject; + __pTitleTextObject = null; + } + + __pTitleTextObject = new (std::nothrow) TextObject; + if (__pTitleTextObject == null) + { + return E_OUT_OF_MEMORY; + } + __pTitleTextObject->Construct(); + TextSimple* pSimpleText = new (std::nothrow)TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + __pTitleTextObject->AppendElement(*pSimpleText); + + __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pTitleTextObject->Compose(); + + + int titleFontSize = 0; + GET_SHAPE_CONFIG(EDIT::DEFAULT_TITLE_FONT_SIZE, __pEdit->GetOrientation(), titleFontSize); + + __titleFontSize = titleFontSize; + + _FontImpl* fontImpl = _FontImpl::GetInstance(*__pFont); + + if(fontImpl) + { + r = fontImpl->SetSize(__titleFontSize); + SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed."); + } + else + { + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, fontImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __pTitleTextObject->SetFont(__pFont, 0, __pTitleTextObject->GetTextLength()); + + r = fontImpl->SetSize(__contentFontSize); + SysTryReturn(NID_UI_CTRL, !(IsFailed(r)), r, r, "[EDIT] SetSize is failed."); + + __pEdit->UpdateAccessibilityElement(EDIT_ACCESSIBILITY_ELEMENT_TYPE_TITLE_TEXT); + + return r; +} + +int +_EditPresenter::GetTextLineCount(void) const +{ + if (GetTextLength() == 0) + { + return 0; + } + + if (__isInitialized == false) + { + __pTextObject->SetBounds(__textObjectBounds); + __pTextObject->Compose(); + } + + return __pTextObject->GetTotalLineCount(); +} + +int +_EditPresenter::GetTextTotalHeight(void) const +{ + if (GetTextLength() == 0) + { + return 0; + } + + if (__isInitialized == false) + { + __pTextObject->SetBounds(__textObjectBounds); + __pTextObject->Compose(); + } + + return __pTextObject->GetTotalHeight(); +} + +result +_EditPresenter::Resize(void) +{ + SetClientBounds(); + SetInitialBounds(); + + __pTextObject->SetBounds(__textObjectBounds); + __pTextObject->Compose(); + __isCursorChanged = true; + + if (!(__pEdit->GetEditStyle() & EDIT_STYLE_NOSCROLL)) + { + if (__pScrollBar == null) + { + __pScrollBar = _Scroll::CreateScrollN(*__pEdit, + SCROLL_DIRECTION_VERTICAL, + true, + false, + false, + false, + 1, + 1, + 0); + SysTryReturn(NID_UI_CTRL, __pScrollBar != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the scroll."); + __pEdit->AttachSystemChild(*__pScrollBar); + } + __pScrollBar->SetScrollVisibility(false); + __pScrollBar->OnParentBoundsChanged(); + } + + __verticalMargin = __pEdit->GetBounds().height - __textObjectBounds.height; + + if (__pEdit->GetEditStyle() & EDIT_STYLE_FLEXIBLE) + { + if (__initialBounds.height > __verticalMargin) + { + if (__initialBounds.height > __pEdit->GetBounds().height) + { + __prevTotalTextHeight = __initialBounds.height - __verticalMargin; + } + else + { + __prevTotalTextHeight = __pEdit->GetBounds().height - __verticalMargin; + } + } + } + + return E_SUCCESS; +} + + +void +_EditPresenter::SetClientBounds(void) +{ + int editStyle = __pEdit->GetEditStyle(); + + __clientBounds = __pEdit->GetBounds(); + __clientBounds.x = 0; + __clientBounds.y = 0; + + if (!(editStyle & EDIT_STYLE_SINGLE_LINE)) + { + return; + } + + int leftBorder = 0; + int rightBorder = 0; + int topBorder = 0; + int bottomBorder = 0; + int leftMargin = 0; + int rightMargin = 0; + int topMargin = 0; + int bottomMargin = 0; + _ControlOrientation orientation = __pEdit->GetOrientation(); + + GET_SHAPE_CONFIG(EDIT::FIELD_LEFT_MARGIN, orientation, leftMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_RIGHT_MARGIN, orientation, rightMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_TOP_MARGIN, orientation, topMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_BOTTOM_MARGIN, orientation, bottomMargin); + + if (editStyle & EDIT_STYLE_TITLE_LEFT) + { + int titleWidth = 0; + if (__titleWidth != -1) + { + titleWidth = __titleWidth; + } + else + { + GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_WIDTH, orientation, titleWidth); + } + + leftBorder = titleWidth; + rightBorder = rightMargin; + topBorder = topMargin; + bottomBorder = bottomMargin; + } + else if (editStyle & EDIT_STYLE_TITLE_TOP) + { + int titletHeight = 0; + int titleTextTopMargin = 0; + GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_HEIGHT, orientation, titletHeight); + GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin); + + leftBorder = leftMargin; + rightBorder = rightMargin; + topBorder = titletHeight + titleTextTopMargin; + bottomBorder = bottomMargin; + } + + __clientBounds.x = leftBorder; + __clientBounds.y = topBorder; + __clientBounds.width -= leftBorder + rightBorder; + __clientBounds.height -= topBorder + bottomBorder; + + return; +} + +result +_EditPresenter::SetInitialEditFieldBounds(void) +{ + result r = E_SUCCESS; + int editStyle = __pEdit->GetEditStyle(); + int leftMargin = 0; + int rightMargin = 0; + int topMargin = 0; + int bottomMargin = 0; + int textLeftMargin = 0; + int textRightMargin = 0; + int textTopMargin = 0; + int textBottomMargin = 0; + int titleRectWidth = 0; + int titleRectHeight = 0; + int titleTextLeftMargin = 0; + int titleTextRightMargin = 0; + int titleTextTopMargin = 0; + int titleTextBottomMargin = 0; + int clearIconWidth = 0; + _ControlOrientation orientation = __pEdit->GetOrientation(); + + GET_SHAPE_CONFIG(EDIT::FIELD_LEFT_MARGIN, orientation, leftMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_RIGHT_MARGIN, orientation, rightMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_TOP_MARGIN, orientation, topMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_BOTTOM_MARGIN, orientation, bottomMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_LEFT_MARGIN, orientation, textLeftMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_RIGHT_MARGIN, orientation, textRightMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_TOP_MARGIN, orientation, textTopMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_WIDTH, orientation, titleRectWidth); + GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_RECT_HEIGHT, orientation, titleRectHeight); + GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_LEFT_MARGIN, orientation, titleTextLeftMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_RIGHT_MARGIN, orientation, titleTextRightMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin); + GET_SHAPE_CONFIG(EDIT::FIELD_TITLE_TEXT_BOTTOM_MARGIN, orientation, titleTextBottomMargin); + GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth); + + if (!(editStyle & EDIT_STYLE_SINGLE_LINE)) + { + return E_SYSTEM; + } + + Rectangle bounds = __pEdit->GetBounds(); + if (editStyle & EDIT_STYLE_TITLE_LEFT) + { + __textObjectBounds.x = __clientBounds.x + textLeftMargin; + __textObjectBounds.y = __clientBounds.y + textTopMargin; + __textObjectBounds.width = __clientBounds.width - textLeftMargin + - textRightMargin; + __textObjectBounds.height = __clientBounds.height - textTopMargin + - textBottomMargin; + + __titleBounds.x = titleTextLeftMargin; + __titleBounds.y = titleTextTopMargin; + __titleBounds.width = bounds.width - __clientBounds.width - __titleBounds.x; + __titleBounds.height = __clientBounds.height - titleTextTopMargin + - titleTextBottomMargin; + + if (editStyle & EDIT_STYLE_CLEAR) + { + __textObjectBounds.width -= clearIconWidth; + } + } + else if (editStyle & EDIT_STYLE_TITLE_TOP) + { + __textObjectBounds.x = __clientBounds.x + textLeftMargin; + __textObjectBounds.y = __clientBounds.y; + __textObjectBounds.width = __clientBounds.width - textLeftMargin + - textRightMargin; + __textObjectBounds.height = __clientBounds.height - textBottomMargin; + + __titleBounds.x = titleTextLeftMargin; + __titleBounds.y = titleTextTopMargin; + __titleBounds.width = bounds.width - __titleBounds.x + - titleTextRightMargin; + __titleBounds.height = bounds.height - __titleBounds.y - __clientBounds.height + - bottomMargin; + + if (editStyle & EDIT_STYLE_CLEAR) + { + __textObjectBounds.width -= clearIconWidth; + } + } + else if ((editStyle & EDIT_STYLE_NORMAL) || (editStyle & EDIT_STYLE_CLEAR)) + { + __textObjectBounds = __clientBounds; + int tempLeftMargin = __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + int tempRightMargin = __pEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN); + + if (tempLeftMargin != -1) + { + __textObjectBounds.x = __clientBounds.x + tempLeftMargin; + __textObjectBounds.width = __clientBounds.width - tempLeftMargin; + } + else + { + __textObjectBounds.x = __clientBounds.x + textLeftMargin; + __textObjectBounds.width = __clientBounds.width - textLeftMargin; + } + + if (tempRightMargin != -1) + { + __textObjectBounds.width -= tempRightMargin; + } + else + { + __textObjectBounds.width -= textRightMargin; + } + + if (editStyle & EDIT_STYLE_CLEAR) + { + __textObjectBounds.width -= clearIconWidth; + } + __textObjectBounds.y = __clientBounds.y + textTopMargin; + __textObjectBounds.height = __clientBounds.height - textTopMargin + - textBottomMargin; + } + else + { + int tempLeftMargin = __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + int tempRightMargin = __pEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN); + if (tempLeftMargin != -1) + { + __textObjectBounds.x = __clientBounds.x + tempLeftMargin; + __textObjectBounds.width = __clientBounds.width - tempLeftMargin; + } + else + { + __textObjectBounds.x = __clientBounds.x + textLeftMargin; + __textObjectBounds.width = __clientBounds.width - textLeftMargin; + } + + if (tempRightMargin != -1) + { + __textObjectBounds.width -= tempRightMargin; + } + else + { + __textObjectBounds.width -= textRightMargin; + } + __textObjectBounds.y = __clientBounds.y + textTopMargin; + __textObjectBounds.height = __clientBounds.height - textTopMargin + - textBottomMargin; + } + + int textObectMinimumWidth = 0; + GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth); + + if (__textObjectBounds.width < textObectMinimumWidth) + { + __textObjectBounds.width = textObectMinimumWidth; + } + + if (__textObjectBounds.height < __contentFontSize) + { + __textObjectBounds.height = __contentFontSize; + } + + if (editStyle & EDIT_STYLE_TITLE_LEFT) + { + int gap = 0; + if (__titleBounds.width < textObectMinimumWidth) + { + gap = textObectMinimumWidth - __titleBounds.width; + __titleBounds.width = textObectMinimumWidth; + __textObjectBounds.x += gap; + } + if (__titleBounds.height < __titleFontSize) + { + __titleBounds.height = __titleFontSize; + } + } + + return r; +} + + +result +_EditPresenter::SetInitialBounds(void) +{ + result r = E_SUCCESS; + Rectangle bounds = __pEdit->GetBounds(); + int editStyle = __pEdit->GetEditStyle(); + + if (editStyle & EDIT_STYLE_SINGLE_LINE) + { + r = SetInitialEditFieldBounds(); + __textBoxBounds.x = 0; + __textBoxBounds.y = 0; + __textBoxBounds.width = bounds.width; + __textBoxBounds.height = bounds.height; + + return r; + } + + int leftMargin = 0; + int rightMargin = 0; + int topMargin = 0; + int bottomMargin = 0; + int textLeftMargin = 0; + int textRightMargin = 0; + int textTopMargin = 0; + int textBottomMargin = 0; + int titleRectWidth = 0; + int titleRectHeight = 0; + int titleTextLeftMargin = 0; + int titleTextRightMargin = 0; + int titleTextTopMargin = 0; + int titleTextBottomMargin = 0; + int clearIconWidth = 0; + int scrollWidth = 0; + _ControlOrientation orientation = __pEdit->GetOrientation(); + + GET_SHAPE_CONFIG(EDIT::AREA_LEFT_MARGIN, orientation, leftMargin); + GET_SHAPE_CONFIG(EDIT::AREA_RIGHT_MARGIN, orientation, rightMargin); + GET_SHAPE_CONFIG(EDIT::AREA_TOP_MARGIN, orientation, topMargin); + GET_SHAPE_CONFIG(EDIT::AREA_BOTTOM_MARGIN, orientation, bottomMargin); + GET_SHAPE_CONFIG(EDIT::AREA_TEXT_LEFT_MARGIN, orientation, textLeftMargin); + GET_SHAPE_CONFIG(EDIT::AREA_TEXT_RIGHT_MARGIN, orientation, textRightMargin); + GET_SHAPE_CONFIG(EDIT::AREA_TEXT_TOP_MARGIN, orientation, textTopMargin); + GET_SHAPE_CONFIG(EDIT::AREA_TEXT_BOTTOM_MARGIN, orientation, textBottomMargin); + GET_SHAPE_CONFIG(EDIT::AREA_TITLE_RECT_WIDTH, orientation, titleRectWidth); + GET_SHAPE_CONFIG(EDIT::AREA_TITLE_RECT_HEIGHT, orientation, titleRectHeight); + GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_LEFT_MARGIN, orientation, titleTextLeftMargin); + GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_RIGHT_MARGIN, orientation, titleTextRightMargin); + GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_TOP_MARGIN, orientation, titleTextTopMargin); + GET_SHAPE_CONFIG(EDIT::AREA_TITLE_TEXT_BOTTOM_MARGIN, orientation, titleTextBottomMargin); + GET_SHAPE_CONFIG(EDIT::CLEAR_ICON_WIDTH, orientation, clearIconWidth); + GET_SHAPE_CONFIG(EDIT::AREA_SCROLL_WIDTH, orientation, scrollWidth); + + if (editStyle & EDIT_STYLE_TITLE_TOP) + { + __textBoxBounds.x = leftMargin; + __textBoxBounds.y = titleRectHeight + titleTextTopMargin; + __textBoxBounds.width = bounds.width - leftMargin - rightMargin; + __textBoxBounds.height = bounds.height - titleRectHeight - titleTextTopMargin - bottomMargin; + } + else if (editStyle & EDIT_STYLE_TITLE_LEFT) + { + int titleWidth = 0; + + if (__titleWidth != -1) + { + titleWidth = __titleWidth; + } + else + { + titleWidth = titleRectWidth; + } + __textBoxBounds.x = titleWidth; + __textBoxBounds.y = topMargin; + __textBoxBounds.width = bounds.width - titleWidth - leftMargin; + __textBoxBounds.height = bounds.height - topMargin - bottomMargin; + } + else + { + __textBoxBounds.x = 0; + __textBoxBounds.y = 0; + __textBoxBounds.width = bounds.width; + __textBoxBounds.height = bounds.height; + } + + // setting textBounds + if (editStyle & EDIT_STYLE_TITLE_TOP) + { + if (__pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN) != -1) + { + __textObjectBounds.x = __textBoxBounds.x + __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + __textObjectBounds.width = __textBoxBounds.width - __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + } + else + { + __textObjectBounds.x = __textBoxBounds.x + textLeftMargin; + __textObjectBounds.width = __textBoxBounds.width - textLeftMargin; + } + + if (__pEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN) != -1) + { + __textObjectBounds.width -= __pEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN); + } + else + { + __textObjectBounds.width -= textRightMargin; + + } + + __textObjectBounds.y = __textBoxBounds.y; + __textObjectBounds.height = __textBoxBounds.height - textBottomMargin; + } + else + { + if (__pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN) != -1) + { + __textObjectBounds.x = __textBoxBounds.x + __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + __textObjectBounds.width = __textBoxBounds.width - __pEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + } + else + { + __textObjectBounds.x = __textBoxBounds.x + textLeftMargin; + __textObjectBounds.width = __textBoxBounds.width - textLeftMargin; + } + + if (__pEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN) != -1) + { + __textObjectBounds.width -= __pEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN); + } + else + { + __textObjectBounds.width -= textRightMargin; + + } + + if (__pEdit->GetVerticalMargin(EDIT_TEXT_TOP_MARGIN) != -1) + { + __textObjectBounds.y = __textBoxBounds.y + __pEdit->GetVerticalMargin(EDIT_TEXT_TOP_MARGIN); + __textObjectBounds.height = __textBoxBounds.height - __pEdit->GetVerticalMargin(EDIT_TEXT_TOP_MARGIN); + } + else + { + __textObjectBounds.y = __textBoxBounds.y + textTopMargin; + __textObjectBounds.height = __textBoxBounds.height - textTopMargin; + } + + if (__pEdit->GetVerticalMargin(EDIT_TEXT_BOTTOM_MARGIN) != -1) + { + __textObjectBounds.height -= __pEdit->GetVerticalMargin(EDIT_TEXT_BOTTOM_MARGIN); + } + else + { + __textObjectBounds.height -= textBottomMargin; + } + } + + if (editStyle & EDIT_STYLE_TITLE_TOP) + { + __titleBounds.x = titleTextLeftMargin; + __titleBounds.y = titleTextTopMargin; + __titleBounds.width = bounds.width - titleTextLeftMargin + - titleTextRightMargin; + __titleBounds.height = bounds.height - __textBoxBounds.height - __titleBounds.y + - bottomMargin; + + } + else if (editStyle & EDIT_STYLE_TITLE_LEFT) + { + __titleBounds.x = titleTextLeftMargin; + __titleBounds.y = titleTextTopMargin; + __titleBounds.width = bounds.width - __textBoxBounds.width - __titleBounds.x + - titleTextRightMargin; + __titleBounds.height = __textBoxBounds.height - titleTextTopMargin + - titleTextBottomMargin; + } + + if (editStyle & EDIT_STYLE_NOSCROLL) + { + __isScrollBarVisible = false; + __scrollBarBounds.x = 0; + __scrollBarBounds.y = 0; + __scrollBarBounds.width = 0; + __scrollBarBounds.height = 0; + } + else + { + __scrollBarBounds.width = scrollWidth; + + __scrollBarBounds.x = bounds.width - __scrollBarBounds.width; + __scrollBarBounds.y = __textBoxBounds.y + textTopMargin; + __scrollBarBounds.height = __textBoxBounds.height - textTopMargin - textBottomMargin; + if (__scrollBarBounds.height < 0) + { + __scrollBarBounds.height = 0; + } + + __isScrollBarVisible = true; + + if (editStyle & EDIT_STYLE_TITLE_TOP) + { + __titleBounds.width -= __scrollBarBounds.width; + } + } + + int textObectMinimumWidth = 0; + GET_SHAPE_CONFIG(EDIT::TEXT_OBJECT_MININMUM_WIDTH, orientation, textObectMinimumWidth); + + if (__textObjectBounds.width < textObectMinimumWidth) + { + __textObjectBounds.width = textObectMinimumWidth; + } + + if (__textObjectBounds.height < __contentFontSize) + { + __textObjectBounds.height = __contentFontSize; + } + + return r; +} + +void +_EditPresenter::StopTitleSlidingTimer(void) +{ + if (__pTitleSlidingTimer) + { + __pTitleSlidingTimer->Cancel(); + delete __pTitleSlidingTimer; + __pTitleSlidingTimer = null; + } + + return; +} + +result +_EditPresenter::StartTitleSlidingTimer(void) +{ + result r = E_SUCCESS; + + if (__pTitleSlidingTimer == null) + { + __pTitleSlidingTimer = new (std::nothrow) Timer; + if (__pTitleSlidingTimer == null) + { + return E_OUT_OF_MEMORY; + } + + r = __pTitleSlidingTimer->Construct(*this); + if (IsFailed(r)) + { + goto CATCH; + } + } + r = __pTitleSlidingTimer->Start(TITLE_SLIDING_TIME); + if (IsFailed(r)) + { + goto CATCH; + } + return r; + +CATCH: + StopTitleSlidingTimer(); + return r; +} + +result +_EditPresenter::OnTitleSlidingTimerExpired(void) +{ + result r = E_SUCCESS; + + if (!IsFocused()) + { + StopTitleSlidingTimer(); + return r; + } + + Rectangle tempBounds(0, 0, __pEdit->GetBounds().width, __pEdit->GetBounds().height); + Canvas* pCanvas = __pEdit->GetCanvasN(tempBounds); + SysTryReturnResult(NID_UI_CTRL, pCanvas, E_OUT_OF_MEMORY, "[EDIT] pCanvas is invalid!"); + + if (__pTitleTextObject->IsChanged()) + { + DrawTitleText(*pCanvas); + } + + if (__isTouchPressed) + { + pCanvas->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_PRESSED)); + } + else + { + pCanvas->SetBackgroundColor(__pEdit->GetColor(EDIT_STATUS_HIGHLIGHTED)); + } + + pCanvas->Clear(__titleBounds); + __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas)); + r = pCanvas->Show(__titleBounds); + + delete pCanvas; + + r = StartTitleSlidingTimer(); + + return r; +} + +result +_EditPresenter::ChangePasswordToEchoCharacter(int cursorPos, int textLength) +{ + result r = E_SUCCESS; + + if (!(__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD)) + { + return E_SYSTEM; + } + + StartPasswordTimer(); + if (IsBlocked() == true) + { + __pTextObject->SetRange(cursorPos, textLength); + } + else + { + __pTextObject->NotifyTextChanged(__pTextBuffer, 0, __pTextString->GetLength(), 0); + } + + return r; +} + +void +_EditPresenter::StopPasswordTimer(void) +{ + if (__pPasswordTimer) + { + __pPasswordTimer->Cancel(); + delete __pPasswordTimer; + __pPasswordTimer = null; + } + + return; +} + +result +_EditPresenter::StartPasswordTimer(void) +{ + result r = E_SUCCESS; + + if (__pPasswordTimer == null) + { + __pPasswordTimer = new (std::nothrow) Timer; + if (__pPasswordTimer == null) + { + return E_OUT_OF_MEMORY; + } + + r = __pPasswordTimer->Construct(*this); + if (IsFailed(r)) + { + StopPasswordTimer(); + return r; + } + } + + r = __pPasswordTimer->Start(EDIT_PASSWORD_TIMER_PERIOD); + if (IsFailed(r)) + { + StopPasswordTimer(); + } + + return r; +} + +result +_EditPresenter::OnPasswordTimerExpired(void) +{ + result r = E_SUCCESS; + + if (!IsFocused()) + { + return E_SYSTEM; + } + + ReplaceTextIntoPasswordHyphenString(); + + __pEdit->Invalidate(); + + return r; +} + +result +_EditPresenter::ReplaceTextIntoPasswordHyphenString(void) +{ + result r = E_SUCCESS; + + if (__pEdit->GetEditStyle() & EDIT_STYLE_PASSWORD) + { + if (GetTextLength() > 0) + { + ChangePasswordToEchoCharacter(__pTextBuffer, __echoChar); + } + } + + return r; +} + +result +_EditPresenter::ChangePasswordToEchoCharacter(wchar_t* dspStrBuffer, wchar_t echoChar) +{ + result r = E_SUCCESS; + + int bufferLength = GetTextLength(); + + for (int i = 0; i < bufferLength && i < EDIT_PASSWORD_BUFFER_MAX - 1; i++) + { + dspStrBuffer[i] = echoChar; + } + dspStrBuffer[bufferLength] = null; + + return r; +} + +result +_EditPresenter::SetAutoResizingEnabled(bool enable) +{ + return __pEditModel->SetAutoResizingEnabled(enable); +} + +bool +_EditPresenter::IsAutoResizingEnabled(void) const +{ + return __pEditModel->IsAutoResizingEnabled(); +} + +result +_EditPresenter::SetDefaultFont(void) +{ + result r = E_SUCCESS; + + Font* pControlFont = null; + _ControlOrientation orientation = __pEdit->GetOrientation(); + int defaultFontSize = 0; + GET_SHAPE_CONFIG(EDIT::DEFAULT_FONT_SIZE, orientation, defaultFontSize); + + __isFontInitialized = false; + __contentFontSize = defaultFontSize; + __contentFontStyle = FONT_STYLE_PLAIN; + pControlFont = __pEdit->GetFallbackFont(); + if (pControlFont) + { + AdjustFont(*pControlFont); + } + + return r; +} + +int +_EditPresenter::CalculateFlexibleHeight(void) +{ + int height = 0; + int expectedEditHeight = __pTextObject->GetTotalHeight() + __verticalMargin; + int lineCount = __pTextObject->GetTotalLineCount(); + + if (__pTextObject->GetTotalHeight()) + { + if ((lineCount >= MAX_LINE_NUMBER) && (GetMaxLineCount() > MAX_LINE_NUMBER)) + { + height = MAX_LINE_NUMBER * __pTextObject->GetLineHeightAt(0) + __verticalMargin; + return height; + } + + int maxHeight = CalculateMaximumFlexibleHeight(); + + if (expectedEditHeight >= maxHeight) + { + height = maxHeight; + } + else if (expectedEditHeight < __initialBounds.height) + { + height = __initialBounds.height; + } + else + { + height = expectedEditHeight; + } + } + else + { + height = __initialBounds.height; + } + + return height; +} + +result +_EditPresenter::AdjustFlexibleHeight(void) +{ + result r = E_SUCCESS; + + if (__isFlexibleHeightFrozen == true) + { + return E_SYSTEM; + } + + if (__maximumFlexibleHeight > 0 && __maximumFlexibleHeight <= __initialBounds.height) + { + return E_SYSTEM; + } + + __pTextObject->Compose(); + + if (__prevTotalTextHeight == __pTextObject->GetTotalHeight()) // if text height has not changed. + { + __prevTotalTextHeight = __pTextObject->GetTotalHeight(); + return E_SYSTEM; + } + + // get edit height + Rectangle bounds = __pEdit->GetBounds(); + int calculateHeight = CalculateFlexibleHeight(); + + if (bounds.height != calculateHeight) + { + bounds.height = calculateHeight; + __prevTotalTextHeight = __pTextObject->GetTotalHeight(); + return SetFlexBounds(bounds); + } + __prevTotalTextHeight = __pTextObject->GetTotalHeight(); + return r; +} + +result +_EditPresenter::SetFlexBounds(const Rectangle& bounds) +{ + result r = E_SUCCESS; + + _ExpandableEditAreaEventStatus expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED; + if (__pEdit->GetBounds().height > bounds.height) + { + expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_REMOVED; + } + else if (__pEdit->GetBounds().height < bounds.height) + { + expandableEditAreaStatus = _EXPANDABLE_EDITAREA_EVENT_ADDED; + } + + _VisualElement* pVisualElement = __pEdit->GetVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pVisualElement, E_SYSTEM, "A system error has occurred. Unable to get root visual element."); + + pVisualElement->SetAnimationProvider(__pEditVEDelegator); + pVisualElement->SetImplicitAnimationEnabled(true); + + __pEdit->SetBounds(bounds); + Resize(); + + __pEdit->Invalidate(); + + __prevTotalTextHeight = __pTextObject->GetTotalHeight(); + __pEdit->SendExpandableEditAreaEvent(expandableEditAreaStatus); + + pVisualElement->SetImplicitAnimationEnabled(false); + + return r; +} + +int +_EditPresenter::CalculateMaximumFlexibleHeight(void) +{ + int maxHeight = __maximumFlexibleHeight; + int expectedEditHeight = __pTextObject->GetTotalHeight() + __verticalMargin; + int maximumFlexibleLineNumber = GetMaxLineCount(); + + // if height is longer than max height. + if (maxHeight > 0 && expectedEditHeight >= maxHeight) + { + maxHeight = __maximumFlexibleHeight; + } + else if (maximumFlexibleLineNumber > 0) // if max line number is set. + { + maxHeight = maximumFlexibleLineNumber * __pTextObject->GetLineHeightAt(0) + __verticalMargin; + + Dimension dim = __pEdit->GetMaximumSize(); + if (maxHeight > dim.height) + { + maxHeight = dim.height; + } + } + + return maxHeight; +} + +bool +_EditPresenter::SetKeypadBounds(const Rectangle& bounds) +{ + __keypadBounds.x = bounds.x; + __keypadBounds.y = bounds.y; + __keypadBounds.width = bounds.width; + __keypadBounds.height = bounds.height; + return true; +} + +_Form* +_EditPresenter::GetParentForm(void) +{ + if (!__pEdit) + { + return null; + } + + if (__pEdit->GetInputStyle() == INPUT_STYLE_FULLSCREEN) + { + return null; + } + + if (__pParentForm == null) + { + result r = E_SUCCESS; + + _Form* pForm = null; + _Control* pControlCore = null; + + for (pControlCore = __pEdit->GetParent(); pForm == null; pControlCore = pControlCore->GetParent()) + { + if (pControlCore == null) + { + r = E_SYSTEM; + goto CATCH; + } + + pForm = dynamic_cast<_Form*>(pControlCore); + } + __pParentForm = pForm; + } + +CATCH: + return __pParentForm; +} + +result +_EditPresenter::SetKeypadCommandButtonVisible(bool visible) +{ + __isKeypadCommandButtonVisible = visible; + return E_SUCCESS; +} + +result +_EditPresenter::SetKeypadCommandButton(CommandButtonPosition position, const String& text, int actionId) +{ + result r = E_SUCCESS; + FooterItem footerItem; + footerItem.Construct(actionId); + footerItem.SetText(text); + + __pEditModel->SetCommandButtonItem(position, actionId, text); + if (__pCommandButton) + { + _Button* pButton = __pCommandButton->GetItem(static_cast(position)); + if (pButton) + { + pButton->SetActionId(actionId); + pButton->SetText(text); + } + } + + return r; +} + +_Toolbar* +_EditPresenter::GetKeypadCommandButton(void) const +{ + return __pCommandButton; +} + +result +_EditPresenter::AddActionEventListener(const _IActionEventListener& listener) +{ + ClearLastResult(); + + if (__pCommandButton) + { + __pCommandButton->AddActionEventListener(listener); + } + + __pActionEventListener = const_cast<_IActionEventListener*>(&listener); + + return E_SUCCESS; +} + +result +_EditPresenter::RemoveActionEventListener(const _IActionEventListener& listener) +{ + ClearLastResult(); + + if (__pCommandButton) + { + __pCommandButton->RemoveActionEventListener(listener); + } + + __pActionEventListener = null; + + return E_SUCCESS; +} + +result +_EditPresenter::SetTextBounds(Rectangle& bounds) +{ + __textObjectBounds = bounds; + return E_SUCCESS; +} + +Rectangle +_EditPresenter::GetTextBounds(void) const +{ + return __textObjectBounds; +} + +bool +_EditPresenter::IsKeypadCommandButtonVisible(void) const +{ + return __isKeypadCommandButtonVisible; +} + +String +_EditPresenter::GetKeypadCommandButtonText(CommandButtonPosition position) const +{ + return __pEditModel->GetKeypadCommandButtonText(position); +} + +int +_EditPresenter::GetKeypadCommandButtonActionId(CommandButtonPosition position) const +{ + return __pEditModel->GetKeypadCommandButtonActionId(position); +} + +result +_EditPresenter::DrawScrollBar(void) +{ + result r = E_SUCCESS; + + if (__pScrollBar == null) + { + return E_SYSTEM; + } + + int totalHeight = __pTextObject->GetTotalHeight(); + int dspHeight = __textObjectBounds.height; + int firstDisplayY = __pTextObject->GetFirstDisplayPositionY(); + + if (totalHeight <= dspHeight) + { + if (__prevTotalTextHeight != 0 && __prevTotalTextHeight == totalHeight) // flexible edit's case + { + return E_SUCCESS; + } + + __pScrollBar->SetScrollRange(1, 1); + __pScrollBar->SetScrollPosition(0); + + __isScrollBarVisible = false; + __previousScrollBarPos = 0; + __previousScrollBarMaxPos = 0; + } + else + { + if (firstDisplayY > 0) + { + __pScrollBar->SetScrollRange(dspHeight, totalHeight); + __pScrollBar->SetScrollPosition(firstDisplayY); + __previousScrollBarMaxPos = totalHeight - dspHeight; + } + else + { + __pScrollBar->SetScrollRange(dspHeight, totalHeight); + __pScrollBar->SetScrollPosition(0); + __previousScrollBarMaxPos = 0; + } + + if (__pScrollBar->GetScrollVisibility()) + { + __isScrollBarVisible = true; + } + + __previousScrollBarPos = firstDisplayY; + } + + return r; +} + +void +_EditPresenter::FadeOutScrollBar(void) +{ + if (__pScrollBar) + { + __pScrollBar->SetScrollVisibility(false); + } + __isScrollBarVisible = false; + + return; +} + +result +_EditPresenter::InitializeFlickAnimation(void) +{ + result r = E_SUCCESS; + + if (__pFlickAnimation == null) + { + __pFlickAnimation = new (std::nothrow) _FlickAnimation; + } + + // Init Flick Animation Config + if (__pFlickAnimation) + { + __pFlickAnimation->SetSizeInformation(480, 800, DEVICE_SIZE_HORIZONTAL, DEVICE_SIZE_VERTICAL); + __pFlickAnimation->SetSensitivity(FLICK_ANIMATION_FPS_ICONLIST, FLICK_ANIMATION_SENSITIVITY_ICONLIST); + } + + // Stop Timer + StopFlickTimer(); + + // Create Timer + if (__pFlickAnimationTimer == null) + { + __pFlickAnimationTimer = new (std::nothrow) Timer; + if (__pFlickAnimationTimer == null) + { + r = E_OUT_OF_MEMORY; + goto CATCH; + } + + r = __pFlickAnimationTimer->Construct(*this); + if (IsFailed(r)) + { + delete __pFlickAnimationTimer; + goto CATCH; + } + } + + return r; + +CATCH: + return r; +} + +result +_EditPresenter::StartFlickAnimation(const Point& flickPosition, int flickTime) +{ + // delete Scroll Fadeout Timer + if (!__pScrollBar) + { + return E_SUCCESS; + } + + if (__pScrollBar->IsOnFadeEffect() == true) + { + __pScrollBar->CancelFadeEffect(); + } + + if (InitializeFlickAnimation() != E_SUCCESS) + { + return E_SYSTEM; + } + + + // Initialize flick animation + int velocityX = 0; + int velocityY = 0; + + __pFlickAnimation->CalculateInitializeVelocity(flickPosition.x, flickPosition.y, flickTime, &velocityX, &velocityY); + + if (Math::Abs(flickPosition.x) > Math::Abs(flickPosition.y)) + { + __pFlickAnimation->InitializeFlickAmount(velocityX); + } + else + { + __pFlickAnimation->InitializeFlickAmount(velocityY); + } + + return StartFlickTimer(velocityY, velocityX); +} + +result +_EditPresenter::StartFlickTimer(int flickVelocityX, int flickVelocityY) +{ + if (__pFlickAnimation) + { + if (ScrollContentsOnFlick() != E_SUCCESS) + { + // Stop Timer + StopFlickTimer(); + + return E_SYSTEM; + } + + // Operate timer + if (__pFlickAnimationTimer) + { + if (__pFlickAnimationTimer->Start(EDIT_FLICK_SCROLL_TIMER_INTERVAL) != E_SUCCESS) + { + StopFlickTimer(); + return E_SYSTEM; + } + } + + return E_SUCCESS; + } + else + { + return E_SYSTEM; + } +} + +result +_EditPresenter::ScrollContentsOnFlick(void) +{ + if (__pFlickAnimation) + { + int moveAmountX = 0; + int moveAmountY = 0; + __pFlickAnimation->CalculateNextMove(&moveAmountX, &moveAmountY); + + // Scroll process + if (ScrollOnFlick(-moveAmountY)) + { + __pEdit->Invalidate(); + + return E_SUCCESS; + } + } + + return E_SYSTEM; +} + +bool +_EditPresenter::ScrollOnFlick(int moveDistanceY) +{ + if (moveDistanceY == 0) + { + FadeOutScrollBar(); + return false; + } + + if (__pScrollBar->IsOnFadeEffect() == true) + { + __pScrollBar->CancelFadeEffect(); + } + + ScrollContents(moveDistanceY); + + return true; +} + +void +_EditPresenter::SetCursorEnabled(bool enable) +{ + __isCursorOpaque = enable; + + return; +} + +bool +_EditPresenter::IsCursorEnabled(void) const +{ + return __isCursorOpaque; +} + +void +_EditPresenter::StopFlickTimer(void) +{ + if (__pFlickAnimationTimer != null) + { + __pFlickAnimationTimer->Cancel(); + delete __pFlickAnimationTimer; + __pFlickAnimationTimer = null; + } + + return; +} + +result +_EditPresenter::OnFlickTimerExpired(void) +{ + result r = E_SUCCESS; + + if (__pFlickAnimationTimer) + { + // Start Timer + if (__pFlickAnimationTimer->Start(EDIT_FLICK_SCROLL_TIMER_INTERVAL) != E_SUCCESS) + { + StopFlickTimer(); + return E_SYSTEM; + } + + // Scroll DRAW + if (ScrollContentsOnFlick() != E_SUCCESS) + { + StopFlickTimer(); + + // Fade Out + FadeOutScrollBar(); + } + + r = E_SUCCESS; + } + else + { + r = E_SYSTEM; + } + + return r; +} + +void +_EditPresenter::SetScrollBarVisible(bool enable) +{ + __isScrollBarVisible = enable; + + return; +} + +void +_EditPresenter::SetScrollBarBounds(const Rectangle& bounds) +{ + __scrollBarBounds = bounds; + + return; +} + +Rectangle +_EditPresenter::GetDisplayScrollBounds(void) const +{ + return __scrollBarBounds; +} + +Rectangle +_EditPresenter::GetInitialBounds(void) const +{ + return __initialBounds; +} + +void +_EditPresenter::SetPreviousScrollBarPosition(int position) +{ + __previousScrollBarPos = position; + + return; +} + +int +_EditPresenter::GetPreviousScrollPosition(void) const +{ + return __previousScrollBarPos; +} + +void +_EditPresenter::SetMaximumPreviousScrollBarPosition(int position) +{ + __previousScrollBarMaxPos = position; + + return; +} + +_Scroll* +_EditPresenter::GetScrollBar(void) const +{ + return __pScrollBar; +} + +TextObject* +_EditPresenter::GetTextObject(void) const +{ + return __pTextObject; +} + +void +_EditPresenter::SetAutoShrinkModeEnabled(bool enable) +{ + __isAutoShrinkEnabled = enable; + + return; +} + +bool +_EditPresenter::IsAutoShrinkModeEnabled(void) const +{ + return __isAutoShrinkEnabled; +} + +_Edit* +_EditPresenter::GetEditView(void) const +{ + return __pEdit; +} + +void +_EditPresenter::InitializeParentPanel(void) +{ + if (__pParentPanel == null) + { + _ScrollPanel* pScrollPanel = null; + _Control* pControlCore = null; + + for (pControlCore = __pEdit->GetParent(); pScrollPanel == null; pControlCore = pControlCore->GetParent()) + { + if (pControlCore == null) + { + return; + } + + pScrollPanel = dynamic_cast<_ScrollPanel*>(pControlCore); + if (pScrollPanel) + { + __pParentPanel = pScrollPanel; + break; + } + } + } + + return; +} + +void +_EditPresenter::ScrollPanelToTop(bool show) +{ + if (!__pParentPanel) + return; + + Rectangle editAbsoluteBounds = __pEdit->GetAbsoluteBounds(); + Rectangle panelAbsoluteBounds = __pParentPanel->GetAbsoluteBounds(); + int scrollPosition = __pParentPanel->GetScrollPosition() + (editAbsoluteBounds.y - panelAbsoluteBounds.y); + + __pParentPanel->SetScrollPosition(scrollPosition); + + if (show) + { + __pParentPanel->Invalidate(); + } + + return; +} + +void +_EditPresenter::ScrollPanelToExposedRegion(bool show) +{ + if (!__pParentPanel) + return; + + __pParentPanel->ScrollToControl(*__pEdit); + + if (show) + { + __pParentPanel->Invalidate(); + } + + return; +} + +void +_EditPresenter::ScrollPanelToCursorPosition(bool show) +{ + if (!__pParentPanel) + return; + + result r = E_SUCCESS; + + Rectangle absCursorBounds(0, 0, 0, 0); + r = CalculateAbsoluteCursorBounds(__cursorPos, absCursorBounds); + + if (r != E_SUCCESS) + { + return; + } + + Rectangle absPanelRect = __pParentPanel->GetAbsoluteBounds(); + int panelHeight = __pParentPanel->GetBounds().height; + + int scrollPosition = __pParentPanel->GetScrollPosition(); + int cursorBoundsY = absCursorBounds.y - absPanelRect.y; + + int topYCompared = 0; + int bottomYCompared = panelHeight; + + if (__textObjectBounds.height < absCursorBounds.height) + { + absCursorBounds.height = __textObjectBounds.height; + } + + int upSideGap = topYCompared - cursorBoundsY; + int downSideGap = (upSideGap > 0) ? 0 : cursorBoundsY + absCursorBounds.height - bottomYCompared; + + if (upSideGap > 0 || downSideGap > 0) + { + int gap = 0; + int GAP_CORRECTION = __verticalMargin / 2; + + if (upSideGap > 0) + { + gap = scrollPosition - (upSideGap + GAP_CORRECTION); + } + else + { + gap = scrollPosition + (downSideGap + GAP_CORRECTION); + } + + __pParentPanel->SetScrollPosition(gap); + + __pParentPanel->Invalidate(); + } + + return; +} + +void +_EditPresenter::SetSearchBarFlag(bool enabled) +{ + __isSearchBar = enabled; + + return; +} + +bool +_EditPresenter::GetSearchBarFlag(void) const +{ + return __isSearchBar; +} + +result +_EditPresenter::SetFocused(void) +{ + bool focused = true; + if (__pParentPanel) + { + if ((__pParentPanel->GetFocused() != __pEdit) && IsFocused() == false) + { + focused = false; + } + } + else if (IsFocused() == false) + { + focused = false; + } + + if (focused == false) + { + __pEdit->SetFocused(); + } + + return E_SUCCESS; +} + +void +_EditPresenter::GetWordPosition(int cursorPos, int& startPos, int& endPos) const +{ + int textLength = GetTextLength(); + bool isDetected = false; + + if (cursorPos >= textLength && cursorPos > 0) + { + cursorPos--; + } + + if (IsDelimiter(__pTextBuffer[cursorPos]) && cursorPos > 0) + { + cursorPos--; + } + + for (int i = cursorPos; i >= 0; i--) + { + if (IsDelimiter(__pTextBuffer[i])) + { + startPos = i + 1; + isDetected = true; + break; + } + } + + if (isDetected == false) + { + startPos = 0; + } + else + { + isDetected = false; + } + + for (int i = cursorPos; i < textLength; i++) + { + if (IsDelimiter(__pTextBuffer[i])) + { + endPos = i; + isDetected = true; + break; + } + } + + if (isDetected == false) + { + endPos = textLength; + } + + return; +} + +result +_EditPresenter::GetTextImageRangeAt(int postion, int& startPosition, int& endPosition) const +{ + int length = GetTextLength(); + startPosition = -1; + endPosition = -1; + + SysTryReturnResult(NID_UI_CTRL, postion >= 0 && postion <= length, E_OUT_OF_RANGE, "[EDIT] The given index is out-of-range."); + SysTryReturnResult(NID_UI_CTRL, postion >0, E_OBJ_NOT_FOUND, "[EDIT] Object is not found at 0."); + + _Text::TextElement* pTextElement = __pTextObject->GetElementAtTextIndex(postion); + const TextSimple* pSimpleText = dynamic_cast (pTextElement); + if (pSimpleText != null && pSimpleText->GetBitmap() != null) + { + startPosition = pSimpleText->GetTextOffset(); + endPosition = startPosition + pSimpleText->GetTextLength(); + return E_SUCCESS; + } + + return E_OBJ_NOT_FOUND; +} + +bool +_EditPresenter::IsDelimiter(wchar_t character) const +{ + bool ret = false; + + switch (character) + { + case 0x0A: // NLine Feed + ret = true; + break; + case 0x0D: // Carriage Return + ret = true; + break; + case 0x20: // Space + ret = true; + break; + default: + break; + } + + return ret; +} + +void +_EditPresenter::InitializeCopyPasteManager(void) +{ + bool releaseBlock = true; + + if (__pCopyPasteManager) + { + releaseBlock = __pCopyPasteManager->GetTextBlockReleaseFlag(); + delete __pCopyPasteManager; + __pCopyPasteManager = null; + } + + if (IsBlocked() == true && releaseBlock) + { + ReleaseTextBlock(); + __pEdit->Invalidate(); + } + + __isCopyPastePopupVisible = false; + __isCopyPastePopupMoving = false; + + return; +} + +bool +_EditPresenter::IsCopyPastePopupVisible(void) const +{ + return __isCopyPastePopupVisible; +} + +Rectangle +_EditPresenter::GetTextAreaBounds(void) const +{ + return __textObjectBounds; +} + +Rectangle +_EditPresenter::GetTitleBounds(void) const +{ + return __titleBounds; +} + +Rectangle +_EditPresenter::GetClearIconBounds(void) const +{ + return __clearIconBounds; +} + +void +_EditPresenter::FinishTextComposition(void) +{ + if (__isInputConnectionBound) + { + __pInputConnection->FinishTextComposition(); + __isTextComposing = false; + __composingTextLength = 0; + } + + return; +} + +bool +_EditPresenter::GetTextCompositionState(void) const +{ + return __isTextComposing; +} + +bool +_EditPresenter::IsCopyPastePopup(const _Control& control) const +{ + if (__pCopyPasteManager) + { + return __pCopyPasteManager->IsCopyPastePopup(control); + } + + return false; +} + +void +_EditPresenter::SetCursorChangedFlag(bool enabled) +{ + __isCursorChanged = enabled; + + return; +} + +bool +_EditPresenter::GetCursorChangedFlag(void) const +{ + return __isCursorChanged; +} + +void +_EditPresenter::SetEditGroupStyle(GroupStyle groupStyle) +{ + __groupStyle = groupStyle; + + return; +} + +void +_EditPresenter::SetKeypadClosedEventSkipped(bool enabled) +{ + if (__pEdit->IsFullScreenKeypadEdit()) + { + __isKeypadClosedEventSkipped = enabled; + } + + return; +} + +void +_EditPresenter::PostInternalEvent(const Tizen::Base::String& type) +{ + ClearLastResult(); + + ArrayList* pArgs = new (std::nothrow) ArrayList(); + SysTryReturnVoidResult(NID_UI_CTRL, pArgs != null, E_SYSTEM, "[E_SYSTEM] pArgs is null."); + + result r = E_SYSTEM; + r = pArgs->Construct(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to construct pArgs"); + + String* pType = new (std::nothrow) String(type); + SysTryReturnVoidResult(NID_UI, pType, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + r = pArgs->Add(*pType); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to add type to pArgs"); + + _UiNotificationEvent event(__pEdit->GetHandle(), pArgs); + r = _UiEventManager::GetInstance()->PostEvent(event); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Unable to send event"); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditTime.cpp b/src/ui/controls/FUiCtrl_EditTime.cpp new file mode 100644 index 0000000..4e97e42 --- /dev/null +++ b/src/ui/controls/FUiCtrl_EditTime.cpp @@ -0,0 +1,867 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditTime.cpp + * @brief This is the implementation file for the _EditTime class. + */ + +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_EditTime.h" +#include "FUiCtrl_EditTimePresenter.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_DateTimeDefine.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_EditTime); + +_EditTime::_EditTime(void) + : __pEditTimePresenter(null) + , __pTimeChangeEvent(null) + , __pDateTimeBar(null) + , __absoluteBounds(Rectangle()) + , __title() + , __pAccessibilityTitleElement(null) + , __pAccessibilityHourElement(null) + , __pAccessibilityMinuteElement(null) + , __pAccessibilityAmPmElement(null) +{ +} + +_EditTime::~_EditTime(void) +{ + delete __pDateTimeBar; + __pDateTimeBar = null; + + delete __pEditTimePresenter; + __pEditTimePresenter = null; + + if (__pTimeChangeEvent != null) + { + delete __pTimeChangeEvent; + __pTimeChangeEvent = null; + } + + if (__pAccessibilityTitleElement) + { + __pAccessibilityTitleElement->Activate(false); + __pAccessibilityTitleElement = null; + } + if (__pAccessibilityHourElement) + { + __pAccessibilityHourElement->Activate(false); + __pAccessibilityHourElement = null; + } + if (__pAccessibilityMinuteElement) + { + __pAccessibilityMinuteElement->Activate(false); + __pAccessibilityMinuteElement = null; + } + if (__pAccessibilityAmPmElement) + { + __pAccessibilityAmPmElement->Activate(false); + __pAccessibilityAmPmElement = null; + } +} + +_EditTime* +_EditTime::CreateEditTimeN(const String& title) +{ + result r = E_SUCCESS; + + _AccessibilityContainer* pContainer = null; + + _EditTime* pEditTime = new (std::nothrow) _EditTime; + SysTryReturn(NID_UI_CTRL, pEditTime, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pEditTime->GetVisualElement()->SetSurfaceOpaque(false); + + pEditTime->__pEditTimePresenter = _EditTimePresenter::CreateInstanceN(*pEditTime, title); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pEditTime->__pEditTimePresenter, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pEditTime->CreateDateTimeBar(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pEditTime->__pEditTimePresenter->Initialize(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pEditTime->__pEditTimePresenter, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pEditTime->__pEditTimePresenter->SetCurrentTime(); + + if (title.IsEmpty() != true) + { + pEditTime->__title = title; + } + + pEditTime->SetResizable(false); + + pContainer = pEditTime->GetAccessibilityContainer(); + if (pContainer) + { + pContainer->Activate(true); + } + + pEditTime->AcquireHandle(); + + return pEditTime; + +CATCH: + delete pEditTime; + return null; +} + +result +_EditTime::CreateDateTimeBar(void) +{ + result r = E_SUCCESS; + + __pDateTimeBar = _DateTimeBar::CreateDateTimeBarN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (__pDateTimeBar != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pDateTimeBar->AddActionEventListener(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pDateTimeBar->AddDateTimeChangeEventListener(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete __pDateTimeBar; + return r; +} + +result +_EditTime::AddTimeChangeEventListener(const _IDateTimeChangeEventListener& listener) +{ + if (__pTimeChangeEvent == null) + { + __pTimeChangeEvent = new (std::nothrow) _DateTimeChangeEvent(*this); + SysTryReturn(NID_UI_CTRL, (__pTimeChangeEvent != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + } + + result r = __pTimeChangeEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_EditTime::RemoveTimeChangeEventListener(const _IDateTimeChangeEventListener& listener) +{ + result r = E_OBJ_NOT_FOUND; + + if (__pTimeChangeEvent) + { + r = __pTimeChangeEvent->RemoveListener(listener); + } + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +_EditTime::SetTime(const DateTime& time) +{ + SetProperty("time", Variant(time)); + return; +} + +result +_EditTime::SetPropertyTime(const Variant& time) +{ + SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + __pEditTimePresenter->SetTime(time.ToDateTime()); + + UpdateAccessibilityElement(); + return E_SUCCESS; +} + +DateTime +_EditTime::GetTime(void) const +{ + Variant time = GetProperty("time"); + + return time.ToDateTime(); +} + +Variant +_EditTime::GetPropertyTime(void) const +{ + DateTime time; + + SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), Variant(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + time = __pEditTimePresenter->GetTime(); + + return Variant(time); +} + +result +_EditTime::SetHour(int hour) +{ + result r = E_SUCCESS; + + SetProperty("hour", Variant(hour)); + + r = GetLastResult(); + + return r; +} + +result +_EditTime::SetPropertyHour(const Variant& hour) +{ + SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + result r = E_SUCCESS; + + r = __pEditTimePresenter->SetHour(hour.ToInt()); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + UpdateAccessibilityElement(); + + return r; +} + +int +_EditTime::GetHour(void) const +{ + Variant hour = GetProperty("hour"); + + return hour.ToInt(); +} + +Variant +_EditTime::GetPropertyHour(void) const +{ + int hour = -1; + + SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), Variant(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + hour = __pEditTimePresenter->GetHour(); + + return Variant(hour); +} + +result +_EditTime::SetMinute(int minute) +{ + result r = E_SUCCESS; + + SetProperty("minute", Variant(minute)); + + r = GetLastResult(); + + return r; +} + +result +_EditTime::SetPropertyMinute(const Variant& minute) +{ + SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + result r = E_SUCCESS; + + r = __pEditTimePresenter->SetMinute(minute.ToInt()); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + UpdateAccessibilityElement(); + + return r; +} + +int +_EditTime::GetMinute(void) const +{ + Variant minute = GetProperty("minute"); + + return minute.ToInt(); +} + +Variant +_EditTime::GetPropertyMinute(void) const +{ + int minute = -1; + + SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), Variant(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + minute = __pEditTimePresenter->GetMinute(); + + return Variant(minute); +} + +void +_EditTime::SetCurrentTime(void) +{ + SysTryReturnVoidResult(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + __pEditTimePresenter->SetCurrentTime(); + + UpdateAccessibilityElement(); + + return; +} + +void +_EditTime::SetTimePickerEnabled(bool enable) +{ + SetProperty("timePickerEnabled", Variant(enable)); + return; +} + +result +_EditTime::SetPropertyTimePickerEnabled(const Variant& enable) +{ + SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + __pEditTimePresenter->SetTimePickerEnabled(enable.ToBool()); + + return E_SUCCESS; +} + +bool +_EditTime::IsTimePickerEnabled(void) const +{ + Variant enable = GetProperty("timePickerEnabled"); + + return enable.ToBool(); +} + +Variant +_EditTime::GetPropertyTimePickerEnabled(void) const +{ + bool enable = false; + + SysTryReturn(NID_UI_CTRL, (__pEditTimePresenter != null), Variant(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + enable = __pEditTimePresenter->IsTimePickerEnabled(); + + return Variant(enable); +} + +void +_EditTime::Set24HourNotationEnabled(bool enable) +{ + SysTryReturnVoidResult(NID_UI_CTRL, (__pEditTimePresenter != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _EditDatePresenter instance is null."); + + __pEditTimePresenter->Set24HourNotationEnabled(enable); + return; +} + +bool +_EditTime::Is24HourNotationEnabled(void) const +{ + SysAssertf((__pEditTimePresenter != null), "The _EditDatePresenter instance is null."); + + return __pEditTimePresenter->Is24HourNotationEnabled(); +} + +result +_EditTime::CalculateDateTimeBarPosition(void) +{ + result r = E_SUCCESS; + Rectangle absoluteBounds; + Rectangle parentBounds; + Rectangle frameBounds; + + absoluteBounds = GetAbsoluteBounds(); + + _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, (pFrame != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get frame instance."); + + _Form* pForm = pFrame->GetCurrentForm(); + SysTryReturn(NID_UI_CTRL, (pForm != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get form instance."); + + parentBounds = pForm->GetClientBounds(); + frameBounds = pFrame->GetAbsoluteBounds(); + + int dateTimeBarHeight = 0; + GET_SHAPE_CONFIG(DATETIMEBAR::ITEM_HEIGHT, GetOrientation(), dateTimeBarHeight); + + Rectangle parentWindowBounds = GetParentWindowBounds(); + int bottomMargin = 0; + // DateTimeBar top margin can be used as EditTime's bottom margin. + GET_SHAPE_CONFIG(DATETIMEBAR::TOP_MARGIN, GetOrientation(), bottomMargin); + + int bottomPosition = 0; + bottomPosition = absoluteBounds.y + absoluteBounds.height + bottomMargin + dateTimeBarHeight; + + GetDateTimeBar()->SetParentWindowBounds(parentWindowBounds); + + if (bottomPosition > frameBounds.y + parentBounds.y + parentBounds.height) + { + r = GetDateTimeBar()->SetPositionAndAlignment(Point(parentWindowBounds.x, absoluteBounds.y), DATETIME_BAR_ALIGN_UP); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = GetDateTimeBar()->SetPositionAndAlignment(Point(parentWindowBounds.x, absoluteBounds.y + absoluteBounds.height + bottomMargin), DATETIME_BAR_ALIGN_DOWN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __absoluteBounds = absoluteBounds; + + return r; +} + +void +_EditTime::OnDraw(void) +{ + if (GetDateTimeBar() != null) + { + CalculateDateTimeBarPosition(); + } + + __pEditTimePresenter->Draw(); + + UpdateAccessibilityElement(); + return; +} + +result +_EditTime::OnAttachedToMainTree(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return E_SUCCESS; + } + + Rectangle hourBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR); + Rectangle minuteBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE); + Rectangle ampmBounds = __pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM); + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer) + { + pContainer->AddListener(*this); + if (__pAccessibilityTitleElement == null) + { + __pAccessibilityTitleElement = new _AccessibilityElement(true); + __pAccessibilityTitleElement->SetBounds(GetBounds()); + __pAccessibilityTitleElement->SetTrait(ACCESSIBILITY_TRAITS_NONE); + pContainer->AddElement(*__pAccessibilityTitleElement); + } + + if (__pAccessibilityHourElement == null && __pAccessibilityMinuteElement == null) + { + String hintText(L"Double tap to edit"); + + __pAccessibilityHourElement = new _AccessibilityElement(true); + __pAccessibilityHourElement->SetBounds(hourBounds); + __pAccessibilityHourElement->SetTrait(ACCESSIBILITY_TRAITS_HOUR); + __pAccessibilityHourElement->SetHint(hintText); + pContainer->AddElement(*__pAccessibilityHourElement); + + __pAccessibilityMinuteElement = new _AccessibilityElement(true); + __pAccessibilityMinuteElement->SetBounds(minuteBounds); + __pAccessibilityMinuteElement->SetTrait(ACCESSIBILITY_TRAITS_MINUTE); + __pAccessibilityMinuteElement->SetHint(hintText); + pContainer->AddElement(*__pAccessibilityMinuteElement); + + if (Is24HourNotationEnabled() == false) + { + __pAccessibilityAmPmElement = new _AccessibilityElement(true); + __pAccessibilityAmPmElement->SetBounds(ampmBounds); + __pAccessibilityAmPmElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON); + pContainer->AddElement(*__pAccessibilityAmPmElement); + } + } + } + + return E_SUCCESS; +} + +void +_EditTime::OnBoundsChanged(void) +{ + __pEditTimePresenter->Initialize(); + + if (__pAccessibilityTitleElement) + { + __pAccessibilityTitleElement->SetBounds(__pEditTimePresenter->GetTitleBounds()); + } + if (__pAccessibilityHourElement) + { + __pAccessibilityHourElement->SetBounds(__pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR)); + } + if (__pAccessibilityMinuteElement) + { + __pAccessibilityMinuteElement->SetBounds(__pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE)); + } + if (__pAccessibilityAmPmElement) + { + __pAccessibilityAmPmElement->SetBounds(__pEditTimePresenter->GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM)); + } + + return; +} + +void +_EditTime::OnChangeLayout(_ControlOrientation orientation) +{ + __pEditTimePresenter->OnChangeLayout(orientation); + + if (GetDateTimeBar() != null) + { + CalculateDateTimeBarPosition(); + GetDateTimeBar()->Close(); + } + + return; +} + +bool +_EditTime::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + Rectangle absoluteBounds = GetAbsoluteBounds(); + + if (absoluteBounds.y != __absoluteBounds.y || absoluteBounds.height != __absoluteBounds.height) + { + CalculateDateTimeBarPosition(); + } + + return __pEditTimePresenter->OnTouchPressed(source, touchinfo); +} + +bool +_EditTime::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pEditTimePresenter->OnTouchReleased(source, touchinfo); +} + +bool +_EditTime::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pEditTimePresenter->OnTouchCanceled(source, touchinfo); +} + +bool +_EditTime::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pEditTimePresenter->OnTouchMoved(source, touchinfo); +} + +void +_EditTime::OnTouchMoveHandled(const _Control& control) +{ + __pEditTimePresenter->OnTouchMoveHandled(control); + return; +} + +result +_EditTime::FireTimeChangeEvent(_DateTimeChangeStatus status) +{ + SysTryReturn(NID_UI_CTRL, (__pTimeChangeEvent != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _DateTimeChangeEvent instance is null."); + + _DateTimeChangeEventArg* pDateTimeEventArg = new (std::nothrow) _DateTimeChangeEventArg(status); + SysTryReturn(NID_UI_CTRL, pDateTimeEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pDateTimeEventArg->SetTime(GetHour(), GetMinute()); + + __pTimeChangeEvent->Fire(*pDateTimeEventArg); + + return E_SUCCESS; +} + +void +_EditTime::OnDateTimeChanged(const _Control& source, int year, int month, int day, int hour, int minute) +{ + __pEditTimePresenter->Animate(); + Invalidate(); + FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED); + return; +} + +void +_EditTime::OnDateTimeChangeCanceled(const _Control& source) +{ + Invalidate(); + + FireTimeChangeEvent(TIME_INTERNAL_CHANGE_CANCELED); + return; +} + +void +_EditTime::OnActionPerformed(const Ui::_Control& source, int actionId) +{ + _DateTimeId boxId = __pEditTimePresenter->GetLastSelectedId(); + + if (boxId == DATETIME_ID_HOUR) + { + bool amEnable = true; + amEnable = __pEditTimePresenter->GetAmEnabled(); + + int hour = 0; + hour = actionId; + if (amEnable == false && Is24HourNotationEnabled() == false) + { + if (hour < DATETIME_HOUR_MAX_FOR_24NOTATION) + { + hour += DATETIME_HOUR_MAX_FOR_24NOTATION; + } + } + else if (amEnable == true && Is24HourNotationEnabled() == false) + { + if (hour == DATETIME_HOUR_MAX_FOR_24NOTATION) + { + hour = DATETIME_HOUR_MIN; + } + } + SetHour(hour); + } + else if (boxId == DATETIME_ID_MINUTE) + { + SetMinute(actionId); + } + + Invalidate(); + return; +} + +_DateTimeBar* +_EditTime::GetDateTimeBar(void) const +{ + return __pDateTimeBar; +} + +void +_EditTime::OnFontChanged(Font* pFont) +{ + __pEditTimePresenter->OnFontChanged(pFont); + + return; +} + +void +_EditTime::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pEditTimePresenter->OnFontInfoRequested(style, size); + + return; +} + +Rectangle +_EditTime::GetParentWindowBounds(void) const +{ + _Form* pForm = null; + _Window* pwindow = null; + _Control* pControlCore = GetParent(); + + Dimension dateTimeBarSize(0, 0); + GET_DIMENSION_CONFIG(DATETIMEBAR::DEFAULT_SIZE, GetOrientation(), dateTimeBarSize); + Rectangle parentWindowBounds(0, 0, dateTimeBarSize.width, dateTimeBarSize.height); + + while (true) + { + if (pControlCore == null) + { + SysLog(NID_UI_CTRL,"[E_SYSTEM] Parent window not found."); + + return parentWindowBounds; + } + + // If the parent is a Frame, then return the Form's bounds. + pForm = dynamic_cast<_Form*>(pControlCore); + if (pForm != null) + { + parentWindowBounds = pForm->GetBounds(); + break; + } + + pwindow = dynamic_cast<_Window*>(pControlCore); + + if (pwindow != null) + { + parentWindowBounds = pwindow->GetBounds(); + break; + } + + pControlCore = pControlCore->GetParent(); + } + + return parentWindowBounds; +} + +void +_EditTime::UpdateAccessibilityElement(void) +{ + String string; + + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + if (__pAccessibilityTitleElement == null && __pAccessibilityHourElement == null + && __pAccessibilityMinuteElement == null && __pAccessibilityAmPmElement == null) + { + return; + } + + if (__title.IsEmpty() == false) + { + string.Append(__title); + string.Append(L", "); + } + + String hourString; + int hour = GetHour(); + int maxHour = DATETIME_HOUR_MAX_FOR_24NOTATION; + + if (Is24HourNotationEnabled() == false && (hour > maxHour)) + { + hourString.Format(10, L"%02d", hour - DATETIME_HOUR_MAX_FOR_24NOTATION); + } + else + { + hourString.Format(10, L"%02d", hour); + } + + string.Append(hourString.GetPointer()); + string.Append(L":"); + string.Append(GetMinute()); + string.Append(L" "); + + if (Is24HourNotationEnabled() == false) + { + String hintAmPmText(L"Double tap to change to "); + String amString; + String pmString; + GET_STRING_CONFIG(IDS_COM_BODY_AM, amString); + GET_STRING_CONFIG(IDS_COM_POP_PM, pmString); + + if (__pEditTimePresenter->GetAmEnabled() == true) + { + __pAccessibilityAmPmElement->SetLabel(amString); + hintAmPmText.Append(pmString.GetPointer()); + string.Append(amString.GetPointer()); + } + else + { + __pAccessibilityAmPmElement->SetLabel(pmString); + hintAmPmText.Append(amString.GetPointer()); + string.Append(pmString.GetPointer()); + } + + __pAccessibilityAmPmElement->SetHint(hintAmPmText); + } + + __pAccessibilityTitleElement->SetLabel(string); + + __pAccessibilityHourElement->SetLabel(hourString); + + string.Clear(); + string.Format(10, L"%02d", GetMinute()); + __pAccessibilityMinuteElement->SetLabel(string); + + return; +} + +bool +_EditTime::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_EditTime::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_EditTime::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_EditTime::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_EditTime::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_EditTime::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + String amString; + String pmString; + String labelText; + + labelText = element.GetLabel(); + + GET_STRING_CONFIG(IDS_COM_BODY_AM, amString); + GET_STRING_CONFIG(IDS_COM_POP_PM, pmString); + + if (labelText == amString || labelText == pmString) + { + labelText.Append(L" Selected"); + _AccessibilityManager::GetInstance()->ReadContent(labelText); + } + + return true; +} + +bool +_EditTime::OnAccessibilityValueIncreased(const _AccessibilityContainer&, const _AccessibilityElement&) +{ + return false; +} + +bool +_EditTime::OnAccessibilityValueDecreased(const _AccessibilityContainer&, const _AccessibilityElement&) +{ + return false; +} + +}}} // Controls diff --git a/src/ui/controls/FUiCtrl_EditTimeImpl.cpp b/src/ui/controls/FUiCtrl_EditTimeImpl.cpp new file mode 100644 index 0000000..7dd7502 --- /dev/null +++ b/src/ui/controls/FUiCtrl_EditTimeImpl.cpp @@ -0,0 +1,440 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditTimeImpl.cpp + * @brief This is the implementation file for the _EditTimeImpl class. + */ + +#include +#include +#include +#include "FUi_UiBuilder.h" +#include "FUi_ResourceManager.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUiCtrl_EditTimeImpl.h" +#include "FUiCtrl_DateTimeDefine.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base; +using namespace Tizen::App; + +namespace Tizen { namespace Ui { namespace Controls +{ +_EditTimeImpl::EditTimeSizeInfo::EditTimeSizeInfo(void) + : __isTitle(false) +{ +} + +void +_EditTimeImpl::EditTimeSizeInfo::SetTitleStyle(bool titleStyle) +{ + __isTitle = titleStyle; + return; +} + +Dimension +_EditTimeImpl::EditTimeSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Tizen::Graphics::Dimension dimension(0, 0); + + r = GET_DIMENSION_CONFIG(EDITTIME::DEFAULT_SIZE, orientation, dimension); + + SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] Propagating.", GetErrorMessage(r)); + return dimension; +} + +Dimension +_EditTimeImpl::EditTimeSizeInfo::GetDefaultMaximumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Tizen::Graphics::Dimension dimension(0, 0); + + r = GET_DIMENSION_CONFIG(EDITTIME::DEFAULT_SIZE, orientation, dimension); + + SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] Propagating.", GetErrorMessage(r)); + return dimension; +} + +_EditTimeImpl::_EditTimeImpl(EditTime* pPublic, _EditTime* pCore) + : _ControlImpl(pPublic, pCore) + , __pPublicTimeChangeEvent(null) +{ + ClearLastResult(); +} + +_EditTimeImpl::~_EditTimeImpl(void) +{ + if (__pPublicTimeChangeEvent) + { + delete __pPublicTimeChangeEvent; + __pPublicTimeChangeEvent = null; + } + + ClearLastResult(); +} + +_EditTimeImpl* +_EditTimeImpl::GetInstance(EditTime& editTime) +{ + return static_cast<_EditTimeImpl*> (editTime._pControlImpl); +} + +const _EditTimeImpl* +_EditTimeImpl::GetInstance(const EditTime& editTime) +{ + return static_cast (editTime._pControlImpl); +} + + +_EditTimeImpl* +_EditTimeImpl::CreateEditTimeImplN(EditTime* pControl, const Point& point, const String& title) +{ + result r = E_SUCCESS; + Rectangle defaultSize; + bool isTitle = false; + + _EditTime* pCore = _EditTime::CreateEditTimeN(title); + SysTryReturn(NID_UI_CTRL, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _EditTimeImpl* pImpl = new (std::nothrow) _EditTimeImpl(pControl, pCore); + + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddTimeChangeEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_SHAPE_CONFIG(EDITTIME::WIDTH, pCore->GetOrientation(), defaultSize.width); + + GET_SHAPE_CONFIG(EDITTIME::HEIGHT, pCore->GetOrientation(), defaultSize.height); + + + defaultSize.x = point.x; + defaultSize.y = point.y; + + r = pImpl->InitializeBoundsProperties(FUNC_SIZE_INFO(EditTime)(isTitle), defaultSize, pCore->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + ClearLastResult(); + + return pImpl; + +CATCH: + delete pImpl; + return null; +} + +const char* +_EditTimeImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::EditTime"; +} + +const EditTime& +_EditTimeImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +EditTime& +_EditTimeImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _EditTime& +_EditTimeImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_EditTime& +_EditTimeImpl::GetCore(void) +{ + return static_cast <_EditTime&>(_ControlImpl::GetCore()); +} + +result +_EditTimeImpl::AddTimeChangeEventListener(ITimeChangeEventListener& listener) +{ + ClearLastResult(); + + if (__pPublicTimeChangeEvent == null) + { + __pPublicTimeChangeEvent = new (std::nothrow) _PublicDateTimeChangeEvent(GetPublic()); + + SysTryReturn(NID_UI_CTRL, __pPublicTimeChangeEvent, + E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + } + + result r = __pPublicTimeChangeEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, "The ITimeChangeEventListener instance already exists."); + + return r; +} + +result +_EditTimeImpl::RemoveTimeChangeEventListener(ITimeChangeEventListener& listener) +{ + ClearLastResult(); + + result r = E_OBJ_NOT_FOUND; + + if (__pPublicTimeChangeEvent) + { + r = __pPublicTimeChangeEvent->RemoveListener(listener); + } + + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, "ITimeChangeEventListener instance is not found."); + + return r; +} + +DateTime +_EditTimeImpl::GetTime(void) const +{ + ClearLastResult(); + + Variant time = GetCore().GetPropertyTime(); + + return time.ToDateTime(); +} + +int +_EditTimeImpl::GetHour(void) const +{ + ClearLastResult(); + + Variant hour = GetCore().GetPropertyHour(); + + return hour.ToInt(); +} + +int +_EditTimeImpl::GetMinute(void) const +{ + ClearLastResult(); + + Variant minute = GetCore().GetPropertyMinute(); + + return minute.ToInt(); +} + +void +_EditTimeImpl::SetTime(const DateTime& time) +{ + ClearLastResult(); + + GetCore().SetPropertyTime(Variant(time)); + return; +} + +void +_EditTimeImpl::SetCurrentTime(void) +{ + ClearLastResult(); + + GetCore().SetCurrentTime(); + return; +} + +result +_EditTimeImpl::SetHour(int hour) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (hour >= DATETIME_HOUR_MIN && hour <= DATETIME_HOUR_MAX), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. hour (%d).", hour); + + result r = GetCore().SetPropertyHour(Variant(hour)); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_EditTimeImpl::SetMinute(int minute) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (minute >= DATETIME_MINUTE_MIN && minute <= DATETIME_MINUTE_MAX), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. minute (%d).", minute); + + result r = GetCore().SetPropertyMinute(Variant(minute)); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +_EditTimeImpl::SetTimePickerEnabled(bool enable) +{ + ClearLastResult(); + + GetCore().SetPropertyTimePickerEnabled(Variant(enable)); + return; +} + +bool +_EditTimeImpl::IsTimePickerEnabled(void) const +{ + ClearLastResult(); + + Variant enable = GetCore().GetPropertyTimePickerEnabled(); + + return enable.ToBool(); +} + +void +_EditTimeImpl::Set24HourNotationEnabled(bool enable) +{ + ClearLastResult(); + + GetCore().Set24HourNotationEnabled(enable); + return; +} + +void +_EditTimeImpl::OnDateTimeChanged(const _Control& source, int year, int month, int day, int hour, int minute) +{ + ClearLastResult(); + + if (__pPublicTimeChangeEvent == null) + { + return; + } + + _PublicDateTimeChangeEventArg* pEventArg = new (std::nothrow) _PublicDateTimeChangeEventArg(TIME_PUBLIC_CHANGE_SAVED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pEventArg->SetDate(year, month, day); + pEventArg->SetTime(hour, minute); + __pPublicTimeChangeEvent->Fire(*pEventArg); + + return; +} + +void +_EditTimeImpl::OnDateTimeChangeCanceled(const _Control& source) +{ + ClearLastResult(); + + if (__pPublicTimeChangeEvent == null) + { + return; + } + + _PublicDateTimeChangeEventArg* pEventArg = new (std::nothrow) _PublicDateTimeChangeEventArg(TIME_PUBLIC_CHANGE_CANCELED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pPublicTimeChangeEvent->Fire(*pEventArg); + + return; +} + +class _EditTimeMaker + : public _UiBuilderControlMaker +{ +public: + _EditTimeMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){} + virtual ~_EditTimeMaker(void){} + static _UiBuilderControlMaker* GetInstance(_UiBuilder* pUiBuilder) + { + _EditTimeMaker* pEditTimeMaker = new (std::nothrow) _EditTimeMaker(pUiBuilder); + return pEditTimeMaker; + } + +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + result r = E_SUCCESS; + + _UiBuilderControlLayout* pControlProperty = null; + EditTime* pEditTime = null; + + Point point; + Tizen::Base::String elementString; + bool titleEnable = false; + bool hourNotationEnable = false; + Rectangle rect; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + point.x = rect.x; + point.y = rect.y; + + if (pControl->GetElement(L"titleText", elementString)) + { + titleEnable = true; + } + + pEditTime = new (std::nothrow) EditTime; + if (pEditTime == null) + { + return null; + } + + if (titleEnable) + { + r = pEditTime->Construct(point, elementString); + } + else + { + r = pEditTime->Construct(point); + } + + if (r != E_SUCCESS) + { + delete pEditTime; + pEditTime = null; + return null; + } + + if (pControl->GetElement(L"b24HourNotationEnabled", elementString)) + { + if (elementString.Equals(L"true", false)) + { + hourNotationEnable = true; + pEditTime->Set24HourNotationEnabled(hourNotationEnable); + } + } + + return pEditTime; + } + +}; // _EditTimeMaker + +_EditTimeRegister::_EditTimeRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"EditTime", _EditTimeMaker::GetInstance); +} + +_EditTimeRegister::~_EditTimeRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"EditTime"); +} +static _EditTimeRegister EditTimeRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditTimePresenter.cpp b/src/ui/controls/FUiCtrl_EditTimePresenter.cpp new file mode 100644 index 0000000..093f3dd --- /dev/null +++ b/src/ui/controls/FUiCtrl_EditTimePresenter.cpp @@ -0,0 +1,1363 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditTimePresenter.cpp + * @brief This is the implementation file for the _EditTimePresenter class. + */ + +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_EditTimePresenter.h" +#include "FUiCtrl_EditTime.h" +#include "FUiCtrl_DateTimeModel.h" +#include "FUiCtrl_DateTimeUtils.h" +#include "FUiAnim_VisualElement.h" +#include "FUiAnimVisualElementPropertyAnimation.h" +#include "FGrpColor.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ +_EditTimePresenter::_EditTimePresenter(const String& title) + : __pEditDateTimeModel(null) + , __pEditTime(null) + , __bounds(Rectangle()) + , __titleBounds(Rectangle()) + , __ampmString(String()) + , __hourString(String()) + , __minuteString(String()) + , __title(title) + , __24hours(false) + , __amEnable(true) + , __timePickerEnabled(true) + , __selectedId(DATETIME_ID_NONE) + , __lastSelectedId(DATETIME_ID_NONE) + , __touchMoveHandled(false) + , __pAmPmBgNormalColorReplacementBitmap(null) + , __pAmPmBgDisabledColorReplacementBitmap(null) + , __pAmPmBgPressedColorReplacementBitmap(null) + , __pAmPmBgEffectNomralBitmap(null) + , __pAmPmBgEffectPressedBitmap(null) + , __pAmPmBgEffectDisabledBitmap(null) + , __pColonColorReplacementBitmap(null) + , __pColonDisabledColorReplacementBitmap(null) + , __pContentProvider(null) + , __textObject() + , __pFont(null) + , __titleObject() + , __amPmTextSize(0) + , __titleFontSize(0) + , __timeFontSize(0) + , __isAnimating(false) + , __isEditTimeInitialized(false) +{ +} + +_EditTimePresenter::~_EditTimePresenter(void) +{ + __textObject.RemoveAll(); + __titleObject.RemoveAll(); + + delete __pEditDateTimeModel; + __pEditDateTimeModel = null; + + delete __pAmPmBgNormalColorReplacementBitmap; + __pAmPmBgNormalColorReplacementBitmap = null; + + delete __pAmPmBgDisabledColorReplacementBitmap; + __pAmPmBgDisabledColorReplacementBitmap = null; + + delete __pAmPmBgPressedColorReplacementBitmap; + __pAmPmBgPressedColorReplacementBitmap = null; + + delete __pAmPmBgEffectNomralBitmap; + __pAmPmBgEffectNomralBitmap = null; + + delete __pAmPmBgEffectPressedBitmap; + __pAmPmBgEffectPressedBitmap = null; + + delete __pAmPmBgEffectDisabledBitmap; + __pAmPmBgEffectDisabledBitmap = null; + + delete __pColonColorReplacementBitmap; + __pColonColorReplacementBitmap = null; + + delete __pColonDisabledColorReplacementBitmap; + __pColonDisabledColorReplacementBitmap = null; +} + +_EditTimePresenter* +_EditTimePresenter::CreateInstanceN(const _EditTime& editTime, const String& title) +{ + _EditTimePresenter* pEditTimePresenter = new (std::nothrow) _EditTimePresenter(title); + SysTryReturn(NID_UI_CTRL, pEditTimePresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pEditTimePresenter->__pEditTime = const_cast <_EditTime*>(&editTime); + + pEditTimePresenter->__pEditDateTimeModel = new (std::nothrow) _DateTimeModel; + SysTryCatch(NID_UI_CTRL, pEditTimePresenter->__pEditDateTimeModel, , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pEditTimePresenter; + +CATCH: + delete pEditTimePresenter; + return null; +} + +DateTime +_EditTimePresenter::GetTime(void) const +{ + DateTime time; + time.SetValue(DATETIME_YEAR_MIN, DATETIME_MONTH_MIN, DATETIME_DAY_MIN, GetHour(), GetMinute(), 0); + + return time; +} + +int +_EditTimePresenter::GetHour(void) const +{ + return __pEditDateTimeModel->GetHour(); +} + +int +_EditTimePresenter::GetMinute(void) const +{ + return __pEditDateTimeModel->GetMinute(); +} + +void +_EditTimePresenter::SetTime(const DateTime& time) +{ + __pEditDateTimeModel->SetDateTime(time); +} + +void +_EditTimePresenter::SetCurrentTime(void) +{ + __pEditDateTimeModel->SetCurrentDateTime(); + return; +} + +result +_EditTimePresenter::SetHour(int hour) +{ + return __pEditDateTimeModel->SetHour(hour); +} + +result +_EditTimePresenter::SetMinute(int minute) +{ + return __pEditDateTimeModel->SetMinute(minute); +} + +void +_EditTimePresenter::SetTimePickerEnabled(bool enable) +{ + __timePickerEnabled = enable; + return; +} + +bool +_EditTimePresenter::IsTimePickerEnabled(void) const +{ + return __timePickerEnabled; +} + +void +_EditTimePresenter::Set24HourNotationEnabled(bool enable) +{ + __24hours = enable; + return; +} + +bool +_EditTimePresenter::Is24HourNotationEnabled(void) const +{ + return __24hours; +} + +void +_EditTimePresenter::SetTimeConversion(void) +{ + int hour = GetHour(); + int minute = GetMinute(); + + if (__24hours == false) + { + int max = DATETIME_HOUR_MAX_FOR_24NOTATION; + + if (hour > max) + { + __hourString.Format(10, L"%02d", hour - max); + } + else if (hour == DATETIME_HOUR_MIN) + { + __hourString.Format(10, L"%02d", hour + DATETIME_HOUR_MAX_FOR_24NOTATION); + } + else + { + __hourString.Format(10, L"%02d", hour); + } + + __minuteString.Format(10, L"%02d", minute); + } + else + { + __hourString.Format(10, L"%02d", hour); + __minuteString.Format(10, L"%02d", minute); + } + + return; +} + +void +_EditTimePresenter::SetAmEnabled(bool amEnable) +{ + String textAm; + String textPm; + + GET_STRING_CONFIG(IDS_COM_BODY_AM, textAm); + GET_STRING_CONFIG(IDS_COM_POP_PM, textPm); + + __amEnable = amEnable; + int hour = GetHour(); + + if (__amEnable == true) + { + __ampmString = textAm; + if (hour >= DATETIME_HOUR_MAX_FOR_24NOTATION) + { + SetHour(hour - DATETIME_HOUR_MAX_FOR_24NOTATION); + } + } + else + { + __ampmString = textPm; + if (hour < DATETIME_HOUR_MAX_FOR_24NOTATION) + { + SetHour(hour + DATETIME_HOUR_MAX_FOR_24NOTATION); + } + } + + return; +} + +bool +_EditTimePresenter::GetAmEnabled(void) const +{ + return __amEnable; +} + +Rectangle +_EditTimePresenter::GetDisplayAreaBoundsFromHoursStyle(_DateTimeId displayBoxId) const +{ + SysTryReturn(NID_UI_CTRL, displayBoxId >= DATETIME_ID_HOUR && displayBoxId <= DATETIME_ID_AMPM, Rectangle(), + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] displayBoxId is out of range."); + + Rectangle bounds(0, 0, 0, 0); + + int width = 0; + int colonWidth = 0; + int margin = 0; + int colonMargin = 0; + int timeElementWidth = 0; + int amPmHeight = 0; + int timeHeight = 0; + int titleTimeMargin = 0; + int leftMargin = 0; + + GET_SHAPE_CONFIG(EDITTIME::TIME_WIDTH, __pEditTime->GetOrientation(), width); + GET_SHAPE_CONFIG(EDITTIME::HEIGHT, __pEditTime->GetOrientation(), bounds.height); + GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonWidth); + GET_SHAPE_CONFIG(EDITTIME::TIME_AMPM_MARGIN, __pEditTime->GetOrientation(), margin); + GET_SHAPE_CONFIG(EDITTIME::TIME_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), leftMargin); + GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin); + GET_SHAPE_CONFIG(EDITTIME::HOUR_MINUTE_WIDTH, __pEditTime->GetOrientation(), timeElementWidth); + GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), amPmHeight); + GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin); + GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight); + + if (__pEditTime->GetBounds().height > bounds.height) + { + bounds.height = __pEditTime->GetBounds().height; + } + + if (!__title.IsEmpty()) + { + if (displayBoxId == DATETIME_ID_AMPM) + { + bounds.y = __titleBounds.y + __titleBounds.height; + } + else + { + bounds.y = __titleBounds.y + __titleBounds.height + titleTimeMargin; + bounds.height = timeHeight; + } + } + + bounds.x = leftMargin + ((width - (2 * timeElementWidth + colonWidth + 2 * colonMargin)) / 2); + + if (displayBoxId == DATETIME_ID_HOUR) + { + bounds.width = timeElementWidth; + } + else if (displayBoxId == DATETIME_ID_MINUTE) + { + bounds.x = bounds.x + timeElementWidth + colonWidth + 2 * colonMargin; + bounds.width = timeElementWidth; + } + else if (displayBoxId == DATETIME_ID_AMPM) + { + bounds.x = leftMargin + width + margin; + + if (__title.IsEmpty()) + { + bounds.y = bounds.y + (bounds.height - amPmHeight) / 2; + } + + GET_SHAPE_CONFIG(EDITTIME::AMPM_WIDTH, __pEditTime->GetOrientation(), bounds.width); + bounds.height = amPmHeight; + } + + return bounds; +} + +void +_EditTimePresenter::SetTitleBounds(void) +{ + GET_SHAPE_CONFIG(EDITTIME::TIME_TEXT_LEFT_MARGIN, __pEditTime->GetOrientation(), __titleBounds.x); + GET_SHAPE_CONFIG(EDITTIME::WIDTH, __pEditTime->GetOrientation(), __titleBounds.width); + GET_SHAPE_CONFIG(EDITTIME::TEXT_HEIGHT, __pEditTime->GetOrientation(), __titleBounds.height); + + return; +} + +Rectangle +_EditTimePresenter::GetTitleBounds(void) const +{ + return __titleBounds; +} + +result +_EditTimePresenter::LoadResource(void) +{ + result r = E_SUCCESS; + + Color buttonNormalBgColor; + Color buttonDisabledBgColor; + Color buttonNormalPressedColor; + Color colonTextColor; + Color colonTextDisabledColor; + Bitmap* pTempBitmap = null; + + GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_NORMAL, buttonNormalBgColor); + GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_PRESSED, buttonNormalPressedColor); + GET_COLOR_CONFIG(EDITTIME::BUTTON_BG_DISABLED, buttonDisabledBgColor); + GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, colonTextColor); + GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, colonTextDisabledColor); + + GET_SHAPE_CONFIG(EDITTIME::AMPM_FONT_SIZE, __pEditTime->GetOrientation(), __amPmTextSize); + + r = GET_BITMAP_CONFIG_N(EDITTIME::COLON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pColonColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_WHITE), + colonTextColor); + SysTryCatch(NID_UI_CTRL, (__pColonColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pColonDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_WHITE), + colonTextDisabledColor); + SysTryCatch(NID_UI_CTRL, (__pColonDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + delete pTempBitmap; + pTempBitmap = null; + + r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pAmPmBgNormalColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalBgColor); + SysTryCatch(NID_UI_CTRL, (__pAmPmBgNormalColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pAmPmBgDisabledColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonDisabledBgColor); + SysTryCatch(NID_UI_CTRL, (__pAmPmBgDisabledColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pAmPmBgPressedColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalPressedColor); + SysTryCatch(NID_UI_CTRL, (__pAmPmBgPressedColorReplacementBitmap != null), r = GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectNomralBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectPressedBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(EDITTIME::BUTTON_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pAmPmBgEffectDisabledBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + + delete pTempBitmap; + pTempBitmap = null; + + return r; + +CATCH: + delete pTempBitmap; + pTempBitmap = null; + + delete __pAmPmBgNormalColorReplacementBitmap; + __pAmPmBgNormalColorReplacementBitmap = null; + + delete __pAmPmBgPressedColorReplacementBitmap; + __pAmPmBgPressedColorReplacementBitmap = null; + + delete __pAmPmBgEffectNomralBitmap; + __pAmPmBgEffectNomralBitmap = null; + + delete __pAmPmBgEffectPressedBitmap; + __pAmPmBgEffectPressedBitmap = null; + + delete __pColonColorReplacementBitmap; + __pColonColorReplacementBitmap = null; + + return r; +} + +result +_EditTimePresenter::DrawResourceBitmap(Canvas& canvas, const Rectangle& bounds, Bitmap* pBitmap) +{ + result r = E_SUCCESS; + + if (pBitmap == null) + { + return r; + } + + if (pBitmap->IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = canvas.DrawBitmap(bounds, *pBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_EditTimePresenter::InitializeTitleObject(void) +{ + result r = E_SUCCESS; + + Color titleNormalColor; + + GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_NORMAL, titleNormalColor); + + r = __titleObject.Construct(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + TextSimple* pSimpleText = null; + + pSimpleText = new (std::nothrow)TextSimple((const_cast (__title.GetPointer())), __title.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __titleObject.AppendElement(*pSimpleText); + + __titleObject.SetForegroundColor(titleNormalColor, 0, __titleObject.GetTextLength()); + __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength()); + __titleObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __titleObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __titleObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + return r; +} + +result +_EditTimePresenter::InitializeTextObject(void) +{ + result r = E_SUCCESS; + + r = __textObject.Construct(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + TextSimple* pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __textObject.AppendElement(*pSimpleText); + + __textObject.SetFont(__pFont, 0, __textObject.GetTextLength()); + __textObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __textObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __textObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + return r; +} + +result +_EditTimePresenter::Draw(void) +{ + result r = E_SUCCESS; + + if (__isAnimating) + { + return E_SUCCESS; + } + + Canvas* pCanvas = __pEditTime->GetCanvasN(); + SysAssertf((pCanvas != null), "Failed to get canvas."); + + Rectangle colonBounds; + int colonMargin = 0; + + Dimension textArea; + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + Rectangle hourBounds(0, 0, 0, 0); + Rectangle minuteBounds(0, 0, 0, 0); + Rectangle ampmBounds(0, 0, 0, 0); + + hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR); + minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE); + + if (__24hours == false) + { + ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM); + } + + if (__24hours == false) + { + if (!__pEditTime->IsEnabled()) + { + r = DrawResourceBitmap(*pCanvas, ampmBounds, __pAmPmBgDisabledColorReplacementBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(*pCanvas, ampmBounds, __pAmPmBgEffectDisabledBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (__selectedId != DATETIME_ID_AMPM) + { + r = DrawResourceBitmap(*pCanvas, ampmBounds, __pAmPmBgNormalColorReplacementBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(*pCanvas, ampmBounds, __pAmPmBgEffectNomralBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = DrawResourceBitmap(*pCanvas, ampmBounds, __pAmPmBgPressedColorReplacementBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawResourceBitmap(*pCanvas, ampmBounds, __pAmPmBgEffectPressedBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + if (GetHour() >= DATETIME_HOUR_MAX_FOR_24NOTATION) + { + SetAmEnabled(false); + } + else + { + SetAmEnabled(true); + } + + SetTimeConversion(); + + GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonBounds.width); + GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin); + GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), colonBounds.height); + + colonBounds.x = hourBounds.x + hourBounds.width + colonMargin; + colonBounds.y = hourBounds.y + (hourBounds.height - colonBounds.height) / 2; + + if (__title.IsEmpty() == false) + { + r = DrawTitle(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = DrawText(*pCanvas, hourBounds, __hourString); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawText(*pCanvas, minuteBounds, __minuteString); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__24hours == false) + { + r = DrawText(*pCanvas, ampmBounds, __ampmString, __amPmTextSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = DrawColon(*pCanvas, colonBounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + +CATCH: + delete pCanvas; + + return r; +} + +result +_EditTimePresenter::DrawColon(Canvas& canvas, const Rectangle& bounds) +{ + result r = E_SUCCESS; + + if (!__pEditTime->IsEnabled()) + { + r = DrawResourceBitmap(canvas, bounds, __pColonDisabledColorReplacementBitmap); + } + else + { + r = DrawResourceBitmap(canvas, bounds, __pColonColorReplacementBitmap); + } + + if ( r != E_SUCCESS) + { + r = DrawText(canvas, bounds, L":"); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_EditTimePresenter::DrawTitle(Canvas& canvas) +{ + if (!__pEditTime->IsEnabled()) + { + Color titleDisabledColor; + GET_COLOR_CONFIG(EDITTIME::TITLE_TEXT_DISABLED, titleDisabledColor); + __titleObject.SetForegroundColor(titleDisabledColor, 0, __titleObject.GetTextLength()); + } + + (_FontImpl::GetInstance(*__pFont))->SetSize(__titleFontSize); + __titleObject.SetFont(__pFont, 0, __titleObject.GetTextLength()); + + __titleObject.Draw(*_CanvasImpl::GetInstance(canvas)); + + return E_SUCCESS; +} + +result +_EditTimePresenter::DrawText(Canvas& canvas, const Rectangle& bounds, const String& text, int textSize) +{ + result r = E_SUCCESS; + + Font font; + Color textColor; + + _DateTimeId boxId = DATETIME_ID_NONE; + boxId = GetBoxIdFromPosition(Point(bounds.x + 1, bounds.y)); + + if (!__pEditTime->IsEnabled()) + { + if (boxId == DATETIME_ID_AMPM) + { + GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_DISABLED, textColor); + } + else + { + GET_COLOR_CONFIG(EDITTIME::TEXT_DISABLED, textColor); + } + } + else + { + GET_COLOR_CONFIG(EDITTIME::TEXT_NORMAL, textColor); + + if (boxId == DATETIME_ID_AMPM) + { + GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_NORMAL, textColor); + } + + if (boxId > -1 && boxId == __selectedId) + { + if (boxId == DATETIME_ID_AMPM) + { + GET_COLOR_CONFIG(EDITTIME::BUTTON_TEXT_PRESSED, textColor); + } + else + { + GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textColor); + } + } + } + + Rectangle drawAreaBounds(0, 0, 0, 0); + drawAreaBounds = bounds; + + TextSimple* pSimpleText = null; + pSimpleText = new (std::nothrow)TextSimple((const_cast (text.GetPointer())), text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __textObject.RemoveAll(); + + (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize); + + __textObject.AppendElement(*pSimpleText); + + if (boxId == DATETIME_ID_AMPM) + { + (_FontImpl::GetInstance(*__pFont))->SetSize(textSize); + __textObject.SetFont(__pFont, 0, __textObject.GetTextLength()); + } + else + { + __textObject.SetFont(__pFont, 0, __textObject.GetTextLength()); + } + + __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength()); + __textObject.SetBounds(drawAreaBounds); + __textObject.Draw(*_CanvasImpl::GetInstance(canvas)); + + return r; +} + +_DateTimeId +_EditTimePresenter::GetBoxIdFromPosition(const Point& point) const +{ + _DateTimeId displayBoxId = DATETIME_ID_NONE; + + Rectangle hourBounds; + Rectangle minuteBounds; + Rectangle ampmBounds; + + hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR); + minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE); + + if (__24hours == false) + { + ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM); + } + + if (point.y < hourBounds.y || point.y > hourBounds.y + hourBounds.height) + { + return displayBoxId; + } + + if (hourBounds.Contains(point) == true) + { + displayBoxId = DATETIME_ID_HOUR; + } + else if (minuteBounds.Contains(point) == true) + { + displayBoxId = DATETIME_ID_MINUTE; + } + else if (ampmBounds.Contains(point) == true) + { + displayBoxId = DATETIME_ID_AMPM; + } + + return displayBoxId; +} + +void +_EditTimePresenter::SetLastSelectedId(_DateTimeId boxId) +{ + __lastSelectedId = boxId; + return; +} + +_DateTimeId +_EditTimePresenter::GetLastSelectedId(void) const +{ + return __lastSelectedId; +} + +bool +_EditTimePresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled."); + + if (&source != __pEditTime) + { + return false; + } + + __touchMoveHandled = false; + + Rectangle hourBounds(0, 0, 0, 0); + Rectangle minuteBounds(0, 0, 0, 0); + Rectangle ampmBounds(0, 0, 0, 0); + + hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR); + minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE); + + if (__24hours == false) + { + ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM); + } + + Point point = touchinfo.GetCurrentPosition(); + + _DateTimeId boxId = GetBoxIdFromPosition(point); + + int minValue = -1; + int maxValue = -1; + int displayValue = -1; + + if (boxId == DATETIME_ID_HOUR) + { + if (__pEditTime->GetDateTimeBar() != null) + { + if (__24hours == false) + { + if (GetHour() == 0) + { + minValue = DATETIME_HOUR_MIN + 1; + maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION; + displayValue = DATETIME_HOUR_MAX_FOR_24NOTATION; + } + else if (GetHour() > DATETIME_HOUR_MAX_FOR_24NOTATION) + { + minValue = DATETIME_HOUR_MIN + 1; + maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION; + displayValue = GetHour() - DATETIME_HOUR_MAX_FOR_24NOTATION; + } + else + { + minValue = DATETIME_HOUR_MIN + 1; + maxValue = DATETIME_HOUR_MAX_FOR_24NOTATION; + displayValue = GetHour(); + } + } + else + { + minValue = DATETIME_HOUR_MIN; + maxValue = DATETIME_HOUR_MAX; + displayValue = GetHour(); + } + + if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0) + { + __pEditTime->GetDateTimeBar()->RemoveAllItems(); + } + + __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId); + } + + __bounds = hourBounds; + } + else if (boxId == DATETIME_ID_MINUTE) + { + if (__pEditTime->GetDateTimeBar() != null) + { + minValue = DATETIME_MINUTE_MIN; + maxValue = DATETIME_MINUTE_MAX; + displayValue = GetMinute(); + + if (__pEditTime->GetDateTimeBar()->GetItemCount() > 0) + { + __pEditTime->GetDateTimeBar()->RemoveAllItems(); + } + + __pEditTime->GetDateTimeBar()->SetInitialValue(minValue, maxValue, displayValue, boxId); + } + + __bounds = minuteBounds; + } + else if (boxId == DATETIME_ID_AMPM) + { + __bounds = ampmBounds; + } + else + { + __selectedId = DATETIME_ID_NONE; + return false; + } + __selectedId = boxId; + + __pEditTime->Draw(); + + return true; +} + +bool +_EditTimePresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + SysTryReturn(NID_UI_CTRL, IsTimePickerEnabled() == true, true, E_SYSTEM, "[E_SYSTEM] A system error has occurred. EditTime instance is disabled."); + + if (&source != __pEditTime) + { + return false; + } + + Rectangle bounds = __pEditTime->GetBounds(); + + Point startPoint(0, 0); + GET_SHAPE_CONFIG(EDITTIME::TEXT_HEIGHT, __pEditTime->GetOrientation(), startPoint.y); + + __bounds = Rectangle(startPoint.x, startPoint.y, bounds.width, bounds.height); + + Point point = touchinfo.GetCurrentPosition(); + + _DateTimeId boxId = GetBoxIdFromPosition(point); + + if (boxId < 0) + { + __selectedId = DATETIME_ID_NONE; + } + + if (boxId != __selectedId) + { + __selectedId = DATETIME_ID_NONE; + } + + SetLastSelectedId(__selectedId); + __selectedId = DATETIME_ID_NONE; + + __lastSelectedValue = ""; + _DateTimeUtils dateTimeUtils; + if (GetLastSelectedId() == DATETIME_ID_HOUR) + { + int hours = GetHour(); + + if (!Is24HourNotationEnabled()) + { + hours = hours % 12; + + if (hours == DATETIME_HOUR_MIN) + { + hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION; + } + } + __lastSelectedValue.Format(10, L"%02d", hours); + } + else if (GetLastSelectedId() == DATETIME_ID_MINUTE) + { + __lastSelectedValue.Format(10, L"%02d", GetMinute()); + } + + if (GetLastSelectedId() == DATETIME_ID_AMPM) + { + SetAmEnabled(!GetAmEnabled()); + __pEditTime->FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED); + __pEditTime->UpdateAccessibilityElement(); + } + + __pEditTime->Draw(); + + if (__pEditTime->GetDateTimeBar() != null && boxId != DATETIME_ID_AMPM && GetLastSelectedId() != DATETIME_ID_NONE) + { + Rectangle bounds(0, 0, 0, 0); + bounds = GetDisplayAreaBoundsFromHoursStyle(GetLastSelectedId()); + Rectangle absoluteBounds = Rectangle(0, 0, 0, 0); + absoluteBounds = __pEditTime->GetAbsoluteBounds(); + bounds.x += absoluteBounds.x; + + __pEditTime->GetDateTimeBar()->CalculateArrowBounds(bounds); + __pEditTime->GetDateTimeBar()->SetVisibleState(true); + __pEditTime->GetDateTimeBar()->Open(); + } + + return true; +} + +bool +_EditTimePresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pEditTime) + { + return false; + } + + __selectedId = DATETIME_ID_NONE; + + __pEditTime->Draw(); + + return true; +} + +bool +_EditTimePresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pEditTime) + { + return false; + } + + Point touchPoint = touchinfo.GetCurrentPosition(); + + if (GetBoxIdFromPosition(touchPoint) != __selectedId) + { + __selectedId = DATETIME_ID_NONE; + } + + __pEditTime->Invalidate(); + return false; +} + +void +_EditTimePresenter::OnTouchMoveHandled(const _Control& control) +{ + __touchMoveHandled = true; + __selectedId = DATETIME_ID_NONE; + __pEditTime->Invalidate(); + return; +} + +void +_EditTimePresenter::OnFontChanged(Font* pFont) +{ + __pFont = pFont; + + if (__pEditTime->GetDateTimeBar() != null) + { + __pEditTime->GetDateTimeBar()->SetFont(*pFont); + } + + return; +} + +void +_EditTimePresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = FONT_STYLE_PLAIN; + size = __timeFontSize; + + return; +} + +void +_EditTimePresenter::OnChangeLayout(_ControlOrientation orientation) +{ + Dimension editTimeSize; + + result r = E_SUCCESS; + + r = GET_DIMENSION_CONFIG(EDITTIME::DEFAULT_SIZE, orientation, editTimeSize); + + if (r == E_SUCCESS && editTimeSize != __pEditTime->GetSize()) + { + __pEditTime->SetResizable(true); + __pEditTime->SetSize(editTimeSize); + __pEditTime->SetResizable(false); + } + + return; +} + +result +_EditTimePresenter::Initialize(void) +{ + result r = E_SUCCESS; + + int titleTimeMargin = 0; + int timeHeight = 0; + int editTimeHeight = 0; + + GET_SHAPE_CONFIG(EDITTIME::TEXT_FONT_SIZE, __pEditTime->GetOrientation(), __titleFontSize); + GET_SHAPE_CONFIG(EDITTIME::TIME_FONT_SIZE, __pEditTime->GetOrientation(), __timeFontSize); + GET_SHAPE_CONFIG(EDITTIME::TITLE_TIME_MARGIN, __pEditTime->GetOrientation(), titleTimeMargin); + GET_SHAPE_CONFIG(EDITTIME::TIME_HEIGHT, __pEditTime->GetOrientation(), timeHeight); + GET_SHAPE_CONFIG(EDITTIME::HEIGHT, __pEditTime->GetOrientation(), editTimeHeight); + + if (__pEditTime->GetBounds().height > editTimeHeight) + { + editTimeHeight = __pEditTime->GetBounds().height; + } + + if (__title.IsEmpty() == false) + { + SetTitleBounds(); + if (!__isEditTimeInitialized) + { + r = InitializeTitleObject(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __titleBounds.y = (editTimeHeight - (__titleBounds.height + titleTimeMargin + timeHeight)) / 2; + __titleObject.SetBounds(__titleBounds); + } + + __pFont = __pEditTime->GetFallbackFont(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pFont != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (!__isEditTimeInitialized) + { + r = LoadResource(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = InitializeTextObject(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __isEditTimeInitialized = true; + return r; +} + +void +_EditTimePresenter::Animate(void) +{ + SysAssertf((__pFont != null), "Font instance must not be null."); + + (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize); + + result r = E_SUCCESS; + Rectangle rect; + String hourString; + String minuteString; + String newValue; + + _DateTimeUtils dateTimeUtils; + int hours = GetHour(); + if (!Is24HourNotationEnabled()) + { + hours = hours % 12; + + if (hours == DATETIME_HOUR_MIN) + { + hours = hours + DATETIME_HOUR_MAX_FOR_24NOTATION; + } + } + hourString.Format(10, L"%02d", hours); + minuteString.Format(10, L"%02d", GetMinute()); + + if (GetLastSelectedId() == DATETIME_ID_HOUR) + { + SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(hourString) == false), E_SUCCESS, "[E_SUCCESS] Hour string matched."); + + newValue = hourString; + rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR); + } + else if (GetLastSelectedId() == DATETIME_ID_MINUTE) + { + SysTryReturnVoidResult(NID_UI_CTRL, (__lastSelectedValue.Equals(minuteString) == false), E_SUCCESS, "[E_SUCCESS] Minute string matched."); + + newValue = minuteString; + rect = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE); + } + + Dimension newTextDim; + Dimension oldTextDim; + Point textPoint; + VisualElement* pNewVisualElement = null; + VisualElement* pOldVisualElement = null; + VisualElement* pEditTimeElement = null; + VisualElementPropertyAnimation* pNewBoundsAnimation = null; + VisualElementPropertyAnimation* pOldBoundsAnimation = null; + Canvas *pCanvas = null; + + __pFont->GetTextExtent(newValue, newValue.GetLength(), newTextDim); + __pFont->GetTextExtent(__lastSelectedValue, __lastSelectedValue.GetLength(), oldTextDim); + + if (newTextDim.width > oldTextDim.width) + { + textPoint.x = (rect.width - newTextDim.width) / 2; + } + else + { + textPoint.x = (rect.width - oldTextDim.width) / 2; + } + + SysTryReturnVoidResult(NID_UI_CTRL, (rect.x + textPoint.x < __pEditTime->GetBounds().width), E_SUCCESS, "Rolling animation cann't be played."); + + __isAnimating = true; + + __pContentProvider = new (std::nothrow) VisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pContentProvider != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pContentProvider->Construct(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pContentProvider->SetShowState(true); + __pContentProvider->SetClipChildrenEnabled(true); + __pContentProvider->SetImplicitAnimationEnabled(false); + + pEditTimeElement = __pEditTime->GetVisualElement(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pEditTimeElement != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pNewVisualElement = new (std::nothrow) VisualElement(); + SysTryCatch(NID_UI_CTRL, (pNewVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pNewVisualElement->Construct(); + if (r != E_SUCCESS) + { + pNewVisualElement->Destroy(); + } + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pNewVisualElement->SetShowState(true); + + pOldVisualElement = new (std::nothrow) VisualElement(); + if (pOldVisualElement == null) + { + pNewVisualElement->Destroy(); + } + SysTryCatch(NID_UI_CTRL, (pOldVisualElement != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pOldVisualElement->Construct(); + if (r != E_SUCCESS) + { + pNewVisualElement->Destroy(); + pOldVisualElement->Destroy(); + } + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pOldVisualElement->SetShowState(true); + + if (newTextDim.width > oldTextDim.width) + { + textPoint.x = (rect.width - newTextDim.width) / 2; + textPoint.y = (rect.height - newTextDim.height) / 2; + __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f)); + pNewVisualElement->SetBounds(FloatRectangle(0.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f)); + + rect.x = static_cast(__pContentProvider->GetBounds().x); + rect.y = static_cast(__pContentProvider->GetBounds().y); + rect.width = static_cast(__pContentProvider->GetBounds().width); + rect.height = static_cast(__pContentProvider->GetBounds().height); + + textPoint.x = (rect.width - oldTextDim.width) / 2; + textPoint.y = (rect.height - oldTextDim.height) / 2; + + pOldVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f)); + } + else + { + textPoint.x = (rect.width - oldTextDim.width) / 2; + textPoint.y = (rect.height - oldTextDim.height) / 2; + __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f)); + pOldVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f)); + + rect.x = static_cast(__pContentProvider->GetBounds().x); + rect.y = static_cast(__pContentProvider->GetBounds().y); + rect.width = static_cast(__pContentProvider->GetBounds().width); + rect.height = static_cast(__pContentProvider->GetBounds().height); + + textPoint.x = (rect.width - newTextDim.width) / 2; + textPoint.y = (rect.height - newTextDim.height) / 2; + + pNewVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f)); + } + + pCanvas = pEditTimeElement->GetCanvasN(rect); + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + delete pCanvas; + + pEditTimeElement->AttachChild(*__pContentProvider); + + __pContentProvider->AttachChild(*pOldVisualElement); + __pContentProvider->AttachChild(*pNewVisualElement); + + pNewBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryCatch(NID_UI_CTRL, (pNewBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pNewBoundsAnimation->SetDuration(300); + pNewBoundsAnimation->SetPropertyName("bounds.position"); + pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, newTextDim.height * 1.0f))); + pNewBoundsAnimation->SetEndValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, 0.0f))); + pNewBoundsAnimation->SetVisualElementAnimationStatusEventListener(this); + + pOldBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryCatch(NID_UI_CTRL, (pOldBoundsAnimation != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pOldBoundsAnimation->SetDuration(300); + pOldBoundsAnimation->SetPropertyName("bounds.position"); + pOldBoundsAnimation->SetStartValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, 0.0f))); + pOldBoundsAnimation->SetEndValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, oldTextDim.height * -1.0f))); + pOldBoundsAnimation->SetVisualElementAnimationStatusEventListener(this); + + pCanvas = pOldVisualElement->GetCanvasN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + pCanvas->SetFont(*__pFont); + pCanvas->DrawText(Point(0,0),__lastSelectedValue); + + delete pCanvas; + pCanvas = null; + + pCanvas = pNewVisualElement->GetCanvasN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + pCanvas->SetFont(*__pFont); + pCanvas->DrawText(Point(0,0),newValue); + + delete pCanvas; + pCanvas = null; + + pOldVisualElement->SetImplicitAnimationEnabled(false); + pOldVisualElement->AddAnimation(*pOldBoundsAnimation); + + pNewVisualElement->SetImplicitAnimationEnabled(false); + pNewVisualElement->AddAnimation(*pNewBoundsAnimation); + + delete pOldBoundsAnimation; + delete pNewBoundsAnimation; + + return; + +CATCH: + __isAnimating = false; + __pContentProvider->Destroy(); + + delete pNewBoundsAnimation; + pNewBoundsAnimation = null; + + delete pOldBoundsAnimation; + pOldBoundsAnimation = null; + + delete pCanvas; + pCanvas = null; + + return; +} + +void +_EditTimePresenter::OnVisualElementAnimationFinished (const VisualElementAnimation &animation, const String &keyName, VisualElement &target, bool completedNormally) +{ + result r = E_SUCCESS; + __isAnimating = false; + + VisualElement* pEditTimeElement = __pEditTime->GetVisualElement(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (pEditTimeElement != null), r, "[%s] Propagating.", GetErrorMessage(r)); + + pEditTimeElement->DetachChild(*__pContentProvider); + __pContentProvider->Destroy(); + + Draw(); + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ExpandableEditAreaEvent.cpp b/src/ui/controls/FUiCtrl_ExpandableEditAreaEvent.cpp new file mode 100644 index 0000000..e4e5a4b --- /dev/null +++ b/src/ui/controls/FUiCtrl_ExpandableEditAreaEvent.cpp @@ -0,0 +1,204 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_ExpandableEditAreaEvent.cpp +* @brief This is the implementation for the _ExpandableEditAreaEvent class. +* @version 1.0 +*/ + +// includes +#include +#include +#include +#include "FUiCtrl_ExpandableEditAreaEvent.h" +#include "FUiCtrl_IExpandableEditAreaEventListener.h" + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen {namespace Ui {namespace Controls +{ + +/** + * @class _CoreExpandableEditAreaEventArg + * @brief This class is used as the argument to action event listener. + * + * This class is used as the argument to action event listener. When an action event is generated + * (such as when a button is pressed) the TextEvent calls TextEventListener's OnActionPerformed + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the action ID. + */ +class _OSP_EXPORT_ _CoreExpandableEditAreaEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Object instance which contains this instance. + * @param[in] actionId Action Id. + */ + _CoreExpandableEditAreaEventArg(_ExpandableEditAreaEventStatus status, int tokenIndex = -1); + + /** + * This is the class destructor. + * + */ + virtual ~_CoreExpandableEditAreaEventArg(void); + + +// Access +public: + /** + * This method returns the TextEventStatus which the event initially occurred. + * + * @return See the comment above. + */ + _ExpandableEditAreaEventStatus GetStatus(void) const; + + int GetSelectedTokenIndex(void) const; + + +// Attribute +private: + /** + * Action Id. + */ + _ExpandableEditAreaEventStatus __status; + + int __selecteTokenIndex; +}; // _CoreExpandableEditAreaEventArg + +_CoreExpandableEditAreaEventArg::_CoreExpandableEditAreaEventArg(_ExpandableEditAreaEventStatus status, int selectedTokenIndex) + : __status(status) + , __selecteTokenIndex(selectedTokenIndex) +{ + // nothing +} + +_CoreExpandableEditAreaEventArg::~_CoreExpandableEditAreaEventArg(void) +{ + // nothing +} + +//////////////////////////////////////////////////////////////////////////////// +/// _CoreExpandableEditAreaEventArg class Access + +_ExpandableEditAreaEventStatus +_CoreExpandableEditAreaEventArg::GetStatus(void) const +{ + return __status; +} + +int +_CoreExpandableEditAreaEventArg::GetSelectedTokenIndex(void) const +{ + return __selecteTokenIndex; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _CoreExpandableEditAreaEvent class Lifecycle + +_ExpandableEditAreaEvent::_ExpandableEditAreaEvent(const _Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_ExpandableEditAreaEvent::~_ExpandableEditAreaEvent(void) +{ + // nothing +} + +_ExpandableEditAreaEvent* +_ExpandableEditAreaEvent::CreateInstanceN(const _Control& source) +{ + _ExpandableEditAreaEvent* pCoreTextEvent = new (std::nothrow) _ExpandableEditAreaEvent(source); + SysTryReturn(NID_UI_CTRL, pCoreTextEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pCoreTextEvent; + +CATCH: + delete pCoreTextEvent; + return null; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _WindowEvent class Accessor + +const _Control* +_ExpandableEditAreaEvent::GetSource(void) const +{ + return __pSource; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _CoreExpandableEditAreaEvent class Operation + +void +_ExpandableEditAreaEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to _ITextEventListener + _IExpandableEditAreaEventListener* pExpandableEditAreaEventListener = + dynamic_cast <_IExpandableEditAreaEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pExpandableEditAreaEventListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given.\n"); + + // cast to _CoreExpandableEditAreaEventArg + const _CoreExpandableEditAreaEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + _ExpandableEditAreaEventStatus status = pArg->GetStatus(); + if (status == _EXPANDABLE_EDITAREA_EVENT_ADDED) + { + pExpandableEditAreaEventListener->OnExpandableEditAreaLineAdded(*__pSource, 0); + } + else if (status == _EXPANDABLE_EDITAREA_EVENT_REMOVED) + { + pExpandableEditAreaEventListener->OnExpandableEditAreaLineRemoved(*__pSource, 0); + } + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_ExpandableEditAreaEvent::CreateExpandableEditAreaEventArgN(_ExpandableEditAreaEventStatus status, int selectedTokenIndex) +{ + _CoreExpandableEditAreaEventArg* pEventArg = new (std::nothrow) _CoreExpandableEditAreaEventArg(status, selectedTokenIndex); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ExpandableEditAreaImpl.cpp b/src/ui/controls/FUiCtrl_ExpandableEditAreaImpl.cpp new file mode 100644 index 0000000..1445f26 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ExpandableEditAreaImpl.cpp @@ -0,0 +1,1907 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_ExpandableEditAreaImpl.cpp +* @brief This is the implementation for the _ExpandableEditAreaImpl class. +* @version 3.0 +*/ + +#include +#include +#include +#include "FUi_UiBuilder.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_ExpandableEditAreaImpl.h" +#include "FUiCtrl_TokenEdit.h" + +static const int _EXPANDABLE_EDIT_AREA_DEFAULT_MAX_LINE_COUNT = 10; + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ +_ExpandableEditAreaImpl* +_ExpandableEditAreaImpl::GetInstance(ExpandableEditArea& expandableEditArea) +{ + return (static_cast<_ExpandableEditAreaImpl*> (expandableEditArea._pControlImpl)); +} + +const _ExpandableEditAreaImpl* +_ExpandableEditAreaImpl::GetInstance(const ExpandableEditArea& expandableEditArea) +{ + return (static_cast (expandableEditArea._pControlImpl)); +} + +_ExpandableEditAreaImpl::_ExpandableEditAreaImpl(ExpandableEditArea* pPublic, _Edit* pCore) + : _ControlImpl(pPublic, pCore) + , __pExpandableEditArea(pCore) + , __expandableEditAreaStyle(EXPANDABLE_EDIT_AREA_STYLE_NORMAL) + , __expandableEditAreaTitleStyle(EXPANDABLE_EDIT_AREA_TITLE_STYLE_NONE) + , __maxLineCount(_EXPANDABLE_EDIT_AREA_DEFAULT_MAX_LINE_COUNT) + , __pPublicTextEvent(null) + , __pPublicExpandableEditAreaEvent(null) + , __pPublicTextBlockEvent(null) + , __pPublicKeypadEvent(null) + , __pPublicLanguageEvent(null) + , __pTokenFilter(null) +{ +} + +_ExpandableEditAreaImpl::~_ExpandableEditAreaImpl(void) +{ + if (__pExpandableEditArea) + { + __pExpandableEditArea->RemoveTextEventListener(*this); + __pExpandableEditArea->RemoveExpandableEditAreaEventListener(*this); + __pExpandableEditArea->RemoveTextBlockEventListener(*this); + __pExpandableEditArea->RemoveKeypadEventListener(*this); + } + + delete __pPublicTextEvent; + __pPublicTextEvent = null; + + delete __pPublicExpandableEditAreaEvent; + __pPublicExpandableEditAreaEvent = null; + + delete __pPublicTextBlockEvent; + __pPublicTextBlockEvent = null; + + delete __pPublicKeypadEvent; + __pPublicKeypadEvent = null; + +} + +_ExpandableEditAreaImpl* +_ExpandableEditAreaImpl::CreateExpandableEditAreaImplN(ExpandableEditArea* pControl, const Rectangle& rect, + ExpandableEditAreaStyle style, ExpandableEditAreaTitleStyle titleStyle) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + r = FUNC_SIZE_INFO(ExpandableEditArea)().CheckInitialSizeValid(Dimension(rect.width, rect.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. The given rect size is not valid."); + + _Edit* pCore = null; + if (style == EXPANDABLE_EDIT_AREA_STYLE_NORMAL) + { + pCore = _Edit::CreateEditN(); + } + else + { + pCore = _TokenEdit::CreateTokenEditN(); + } + SysTryReturn(NID_UI_CTRL, pCore != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _ExpandableEditAreaImpl* pImpl = new (std::nothrow) _ExpandableEditAreaImpl(pControl, pCore); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->InitializeBoundsProperties(FUNC_SIZE_INFO(ExpandableEditArea)(), _CONTROL_ORIENTATION_PORTRAIT); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddExpandableEditAreaEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddKeypadEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddTextBlockEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddTextEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddLanguageEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; + +CATCH: + delete pImpl; + return null; +} + +const char* +_ExpandableEditAreaImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::ExpandableEditArea"; +} + +const ExpandableEditArea& +_ExpandableEditAreaImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +ExpandableEditArea& +_ExpandableEditAreaImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Edit& +_ExpandableEditAreaImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Edit& +_ExpandableEditAreaImpl::GetCore(void) +{ + return static_cast <_Edit&>(_ControlImpl::GetCore()); +} + +result +_ExpandableEditAreaImpl::Construct(const Rectangle& rect, ExpandableEditAreaStyle style, + ExpandableEditAreaTitleStyle titleStyle, int maxExpandableLines) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + r = CreateExpandableEditArea(rect, style, titleStyle, maxExpandableLines); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +result +_ExpandableEditAreaImpl::Dispose(void) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + if (__pExpandableEditArea) + { + delete __pExpandableEditArea; + __pExpandableEditArea = null; + } + + return r; +} + +result +_ExpandableEditAreaImpl::CreateExpandableEditArea(const Rectangle& rect, ExpandableEditAreaStyle style, + ExpandableEditAreaTitleStyle titleStyle, int maxExpandableLines) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + int editStyle = EDIT_STYLE_NORMAL | EDIT_STYLE_FLEXIBLE; + if (style & EXPANDABLE_EDIT_AREA_STYLE_TOKEN) + { + editStyle |= EDIT_STYLE_TOKEN; + } + + if (titleStyle == EXPANDABLE_EDIT_AREA_TITLE_STYLE_INNER) + { + editStyle |= EDIT_STYLE_TITLE_LEFT; + } + else if (titleStyle == EXPANDABLE_EDIT_AREA_TITLE_STYLE_TOP) + { + editStyle |= EDIT_STYLE_TITLE_TOP; + } + + r = __pExpandableEditArea->Initialize(editStyle, INPUT_STYLE_OVERLAY, 1000); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + __pExpandableEditArea->SetMaxLineCount(maxExpandableLines); + + return r; +} + +int +_ExpandableEditAreaImpl::GetMargin(EditMarginType marginType) const +{ + ClearLastResult(); + + if (marginType == EDIT_MARGIN_TYPE_VERTICAL) + { + return __pExpandableEditArea->GetVerticalMargin(EDIT_TEXT_TOP_MARGIN); + } + else + { + return __pExpandableEditArea->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + } +} + +result +_ExpandableEditAreaImpl::SetMargin(EditMarginType marginType, int margin) +{ + ClearLastResult(); + + result r = E_SUCCESS; + Variant varMargin(margin); + + if (marginType == EDIT_MARGIN_TYPE_HORIZONTAL) + { + r = __pExpandableEditArea->SetHorizontalMargin(margin, EDIT_TEXT_LEFT_MARGIN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __pExpandableEditArea->SetHorizontalMargin(margin, EDIT_TEXT_RIGHT_MARGIN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = __pExpandableEditArea->SetVerticalMargin(margin, EDIT_TEXT_TOP_MARGIN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __pExpandableEditArea->SetVerticalMargin(margin, EDIT_TEXT_BOTTOM_MARGIN); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +KeypadAction +_ExpandableEditAreaImpl::GetKeypadAction(void) const +{ + ClearLastResult(); + + CoreKeypadAction coreKeypadAction = __pExpandableEditArea->GetKeypadAction(); + KeypadAction publicKeypadAction = KEYPAD_ACTION_ENTER; + + switch (coreKeypadAction) + { + case CORE_KEYPAD_ACTION_ENTER: + publicKeypadAction = KEYPAD_ACTION_ENTER; + break; + + case CORE_KEYPAD_ACTION_GO: + publicKeypadAction = KEYPAD_ACTION_GO; + break; + + case CORE_KEYPAD_ACTION_NEXT: + publicKeypadAction = KEYPAD_ACTION_NEXT; + break; + + case CORE_KEYPAD_ACTION_SEND: + publicKeypadAction = KEYPAD_ACTION_SEND; + break; + + case CORE_KEYPAD_ACTION_SEARCH: + publicKeypadAction = KEYPAD_ACTION_SEARCH; + break; + + case CORE_KEYPAD_ACTION_LOGIN: + publicKeypadAction = KEYPAD_ACTION_LOGIN; + break; + + case CORE_KEYPAD_ACTION_SIGN_IN: + publicKeypadAction = KEYPAD_ACTION_SIGN_IN; + break; + + case CORE_KEYPAD_ACTION_JOIN: + publicKeypadAction = KEYPAD_ACTION_JOIN; + break; + + case CORE_KEYPAD_ACTION_DONE: + publicKeypadAction = KEYPAD_ACTION_DONE; + break; + + default: + break; + } + + return publicKeypadAction; +} + +result +_ExpandableEditAreaImpl::SetKeypadAction(KeypadAction keypadAction) +{ + ClearLastResult(); + + CoreKeypadAction coreKeypadAction = CORE_KEYPAD_ACTION_ENTER; + + switch (keypadAction) + { + case KEYPAD_ACTION_ENTER: + coreKeypadAction = CORE_KEYPAD_ACTION_ENTER; + break; + + case KEYPAD_ACTION_GO: + coreKeypadAction = CORE_KEYPAD_ACTION_GO; + break; + + case KEYPAD_ACTION_NEXT: + coreKeypadAction = CORE_KEYPAD_ACTION_NEXT; + break; + + case KEYPAD_ACTION_SEND: + coreKeypadAction = CORE_KEYPAD_ACTION_SEND; + break; + + case KEYPAD_ACTION_SEARCH: + coreKeypadAction = CORE_KEYPAD_ACTION_SEARCH; + break; + + case KEYPAD_ACTION_LOGIN: + coreKeypadAction = CORE_KEYPAD_ACTION_LOGIN; + break; + + case KEYPAD_ACTION_SIGN_IN: + coreKeypadAction = CORE_KEYPAD_ACTION_SIGN_IN; + break; + + case KEYPAD_ACTION_JOIN: + coreKeypadAction = CORE_KEYPAD_ACTION_JOIN; + break; + + case KEYPAD_ACTION_DONE: + coreKeypadAction = CORE_KEYPAD_ACTION_DONE; + break; + + default: + break; + } + + return __pExpandableEditArea->SetKeypadAction(coreKeypadAction); +} + +KeypadStyle +_ExpandableEditAreaImpl::GetKeypadStyle(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetKeypadStyle(); +} + +result +_ExpandableEditAreaImpl::SetKeypadStyle(KeypadStyle keypadStyle) +{ + ClearLastResult(); + + return __pExpandableEditArea->SetKeypadStyle(keypadStyle); +} + +bool +_ExpandableEditAreaImpl::IsTextPredictionEnabled(void) const +{ + return __pExpandableEditArea->IsTextPredictionEnabled(); +} + +result +_ExpandableEditAreaImpl::SetTextPredictionEnabled(bool enable) +{ + return __pExpandableEditArea->SetTextPredictionEnabled(enable); +} + +result +_ExpandableEditAreaImpl::HideKeypad(void) +{ + ClearLastResult(); + + return __pExpandableEditArea->HideKeypad(); +} + +int +_ExpandableEditAreaImpl::GetTextSize(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetTextSize(); +} + +result +_ExpandableEditAreaImpl::SetTextSize(int size) +{ + ClearLastResult(); + + return __pExpandableEditArea->SetTextSize(size); +} + +Color +_ExpandableEditAreaImpl::GetColor(EditStatus status) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetColor(status); +} + +Color +_ExpandableEditAreaImpl::GetTextColor(EditTextColor type) const +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, type != EDIT_TEXT_COLOR_LINK, Color(), E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. The EditTextColor type is EDIT_TEXT_COLOR_LINK."); + + return __pExpandableEditArea->GetTextColor(type); +} + +result +_ExpandableEditAreaImpl::SetBackgroundBitmap(EditStatus status, const Bitmap& bitmap) +{ + ClearLastResult(); + + return __pExpandableEditArea->SetBackgroundBitmap(status, bitmap); +} + +result +_ExpandableEditAreaImpl::SetColor(EditStatus status, const Color& color) +{ + ClearLastResult(); + + return __pExpandableEditArea->SetColor(status, color); +} + +result +_ExpandableEditAreaImpl::SetTextColor(EditTextColor type, const Color& color) +{ + ClearLastResult(); + + return __pExpandableEditArea->SetTextColor(type, color); +} + +String +_ExpandableEditAreaImpl::GetText(int start, int end) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetText(start, end); +} + +result +_ExpandableEditAreaImpl::AddExpandableEditAreaEventListener(IExpandableEditAreaEventListener& listener) +{ + result r = E_SUCCESS; + ClearLastResult(); + + if (__pPublicExpandableEditAreaEvent == null) + { + __pPublicExpandableEditAreaEvent = _PublicExpandableEditAreaEvent::CreateInstanceN(GetPublic()); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, __pPublicExpandableEditAreaEvent != null, r, "Propagating."); + } + + r = __pPublicExpandableEditAreaEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, "A system error has occurred. The IExpandableEditAreaEventListener instance already exists in the event listener list."); + + return r; +} + +result +_ExpandableEditAreaImpl::RemoveExpandableEditAreaEventListener(IExpandableEditAreaEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, __pPublicExpandableEditAreaEvent != null, E_SYSTEM, "A system error has occurred. The _PublicExpandableEditAreaEvent instance is null"); + + result r = __pPublicExpandableEditAreaEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, "A system error has occurred. The IExpandableEditAreaEventListener instance does not exist in the event listener list."); + + return r; + +} + +result +_ExpandableEditAreaImpl::AddKeypadEventListener(IKeypadEventListener& listener) +{ + result r = E_SUCCESS; + ClearLastResult(); + + if (__pPublicKeypadEvent == null) + { + __pPublicKeypadEvent = _PublicKeypadEvent::CreateInstanceN(GetPublic()); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, __pPublicKeypadEvent != null, r, "Propagating."); + } + + r = __pPublicKeypadEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, "A system error has occurred. The IKeypadEventListener instance already exists in the event listener list."); + + return r; +} + +result +_ExpandableEditAreaImpl::RemoveKeypadEventListener(IKeypadEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, __pPublicKeypadEvent != null, E_SYSTEM, "A system error has occurred. The _PublicKeypadEvent instance is null."); + + result r = __pPublicKeypadEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, "A system error has occurred. The IKeypadEventListener instance does not exist in the event listener list."); + + return r; + +} + +result +_ExpandableEditAreaImpl::AddTextBlockEventListener(ITextBlockEventListener& listener) +{ + result r = E_SUCCESS; + ClearLastResult(); + + if (__pPublicTextBlockEvent == null) + { + __pPublicTextBlockEvent = _PublicTextBlockEvent::CreateInstanceN(GetPublic()); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, __pPublicTextBlockEvent != null, r, "Propagating."); + } + + r = __pPublicTextBlockEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, "A system error has occurred. The ITextBlockEventListener instance already exists in the event listener list."); + + return r; +} + +result +_ExpandableEditAreaImpl::RemoveTextBlockEventListener(ITextBlockEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, __pPublicTextBlockEvent, E_SYSTEM, "A system error has occurred. The _PublicTextBlockEvent instance is null."); + + result r = __pPublicTextBlockEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, "A system error has occurred. The ITextBlockEventListener instance does not exist in the event listener list."); + + return r; +} + +result +_ExpandableEditAreaImpl::AddTextEventListener(ITextEventListener& listener) +{ + result r = E_SUCCESS; + ClearLastResult(); + + if (__pPublicTextEvent == null) + { + __pPublicTextEvent = _PublicTextEvent::CreateInstanceN(GetPublic()); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + + r = __pPublicTextEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, "A system error has occurred. The ITextEventListener instance already exists in the event listener list."); + + return r; +} + +result +_ExpandableEditAreaImpl::RemoveTextEventListener(ITextEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, __pPublicTextEvent, E_SYSTEM, "A system error has occurred. The _PublicTextEvent instance is null."); + + result r = __pPublicTextEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, "A system error has occurred. The ITextEventListener instance does not exist in the event listener list."); + + return r; +} + +result +_ExpandableEditAreaImpl::AddLanguageEventListener(ILanguageEventListener& listener) +{ + result r = E_SUCCESS; + ClearLastResult(); + + if (__pPublicLanguageEvent == null) + { + __pPublicLanguageEvent = _PublicLanguageEvent::CreateInstanceN(GetPublic()); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + + SysAssertf(__pPublicLanguageEvent != null, "Not yet constructed. Construct() should be called before use."); + + r = __pPublicLanguageEvent->AddListener(listener); + + return r; +} + +result +_ExpandableEditAreaImpl::RemoveLanguageEventListener(ILanguageEventListener& listener) +{ + ClearLastResult(); + + SysAssertf(__pPublicLanguageEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicLanguageEvent->RemoveListener(listener); +} + +result +_ExpandableEditAreaImpl::SetLowerCaseModeEnabled(bool enable) +{ + ClearLastResult(); + + __pExpandableEditArea->SetLowerCaseModeEnabled(enable); + + return E_SUCCESS; +} + +bool +_ExpandableEditAreaImpl::IsLowerCaseModeEnabled(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->IsLowerCaseModeEnabled(); +} + +result +_ExpandableEditAreaImpl::SetCursorPosition(int position) +{ + ClearLastResult(); + + return __pExpandableEditArea->SetCursorPosition(position); +} + +int +_ExpandableEditAreaImpl::GetCursorPosition(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetCursorPosition(); +} + +String +_ExpandableEditAreaImpl::GetText(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetText(); +} + +int +_ExpandableEditAreaImpl::GetTextLength(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetTextLength(); +} + +result +_ExpandableEditAreaImpl::SetText(const String& text) +{ + ClearLastResult(); + + return __pExpandableEditArea->SetText(text); +} + +result +_ExpandableEditAreaImpl::InsertTextAt(int index, const String& text) +{ + ClearLastResult(); + + return __pExpandableEditArea->InsertTextAt(index, text); +} + +result +_ExpandableEditAreaImpl::AppendText(const String& text) +{ + ClearLastResult(); + + return __pExpandableEditArea->AppendText(text); +} + +result +_ExpandableEditAreaImpl::AppendCharacter(const Character& character) +{ + ClearLastResult(); + + return __pExpandableEditArea->AppendCharacter(character); +} + +result +_ExpandableEditAreaImpl::InsertTextAt(int position, const String& text, const Bitmap& textImage) +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturnResult(NID_UI_CTRL, pTokenEdit == null, E_UNSUPPORTED_OPERATION, + "ExpandableEditArea of style EXPANDABLE_EDIT_AREA_STYLE_TOKEN does not support this operation."); + + return __pExpandableEditArea->InsertTextAt(position, text, textImage); +} + +result +_ExpandableEditAreaImpl::AppendText(const String& text, const Bitmap& textImage) +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturnResult(NID_UI_CTRL, pTokenEdit == null, E_UNSUPPORTED_OPERATION, + "ExpandableEditArea of style EXPANDABLE_EDIT_AREA_STYLE_TOKEN does not support this operation."); + + return __pExpandableEditArea->AppendText(text, textImage); +} + +result +_ExpandableEditAreaImpl::Clear(void) +{ + ClearLastResult(); + + return __pExpandableEditArea->ClearText(); +} + +result +_ExpandableEditAreaImpl::DeleteCharacterAt(int index) +{ + ClearLastResult(); + + return __pExpandableEditArea->DeleteCharacterAt(index); +} + +result +_ExpandableEditAreaImpl::InsertCharacterAt(int index, const Character& character) +{ + ClearLastResult(); + + return __pExpandableEditArea->InsertCharacterAt(index, character); +} + +result +_ExpandableEditAreaImpl::SetGuideText(const String& guideText) +{ + ClearLastResult(); + + __pExpandableEditArea->SetGuideText(guideText); + + return E_SUCCESS; +} + +String +_ExpandableEditAreaImpl::GetGuideText(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetGuideText(); +} + +Color +_ExpandableEditAreaImpl::GetGuideTextColor(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetGuideTextColor(); +} + +result +_ExpandableEditAreaImpl::SetGuideTextColor(const Color& color) +{ + ClearLastResult(); + + return __pExpandableEditArea->SetGuideTextColor(color); +} + +int +_ExpandableEditAreaImpl::GetLineSpacing (void) const +{ + return __pExpandableEditArea->GetLineSpacing(); +} + +result +_ExpandableEditAreaImpl::SetLineSpacing (int multiplier, int extra) +{ + SysTryReturn(NID_UI_CTRL, multiplier >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. multiplier = %d ", multiplier); + SysTryReturn(NID_UI_CTRL, extra >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. extra = %d ", extra); + + return __pExpandableEditArea->SetLineSpacing(DEFAULT_LINE_SPACE * multiplier + extra); +} + +Color +_ExpandableEditAreaImpl::GetTitleTextColor(EditStatus status) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetTitleTextColor(status); +} + +result +_ExpandableEditAreaImpl::SetTitleTextColor(EditStatus status, const Color& color) +{ + ClearLastResult(); + + return __pExpandableEditArea->SetTitleTextColor(status, color); +} + +Color +_ExpandableEditAreaImpl::GetTokenColor(ExpandableEditAreaTokenStatus status) const +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturn(NID_UI_CTRL, pTokenEdit != null, Color(), E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + Variant var; + switch (status) + { + case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL : + var = pTokenEdit->GetPropertyNormalTokenColor(); + break; + + case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED : + var = pTokenEdit->GetPropertySelectedTokenColor(); + break; + + default : + break; + } + + return var.ToColor(); +} + +result +_ExpandableEditAreaImpl::SetTokenColor(ExpandableEditAreaTokenStatus status, const Color& color) +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturnResult(NID_UI_CTRL, pTokenEdit != null, E_UNSUPPORTED_OPERATION, + "ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + Variant var(color); + + switch (status) + { + case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL : + pTokenEdit->SetPropertyNormalTokenColor(var); + break; + + case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED : + pTokenEdit->SetPropertySelectedTokenColor(var); + break; + + default : + break; + } + + return E_SUCCESS; +} + +Color +_ExpandableEditAreaImpl::GetTokenTextColor(void) const +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturn(NID_UI_CTRL, pTokenEdit != null, Color(), E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + Variant var = pTokenEdit->GetPropertyTokenTextColor(); + + return var.ToColor(); +} + +Color +_ExpandableEditAreaImpl::GetSelectedTokenTextColor(void) const +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturn(NID_UI_CTRL, pTokenEdit != null, Color(), E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + return pTokenEdit->GetSelectedTokenTextColor(); +} + +result +_ExpandableEditAreaImpl::SetTokenTextColor(const Color& color) +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturnResult(NID_UI_CTRL, pTokenEdit != null, E_UNSUPPORTED_OPERATION, + "ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + Variant var(color); + + return pTokenEdit->SetPropertyTokenTextColor(var); +} + +result +_ExpandableEditAreaImpl::SetSelectedTokenTextColor(const Color& color) +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturnResult(NID_UI_CTRL, pTokenEdit != null, E_UNSUPPORTED_OPERATION, + "ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + return pTokenEdit->SetSelectedTokenTextColor(color); +} + +result +_ExpandableEditAreaImpl::SetCurrentLanguage(LanguageCode languageCode) +{ + ClearLastResult(); + + return __pExpandableEditArea->SetCurrentLanguage(languageCode); +} + +result +_ExpandableEditAreaImpl::GetCurrentLanguage(LanguageCode& language) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetCurrentLanguage(language); +} + +void +_ExpandableEditAreaImpl::SetKeypadEnabled(bool enable) +{ + ClearLastResult(); + + __pExpandableEditArea->SetKeypadEnabled(enable); +} + +bool +_ExpandableEditAreaImpl::IsKeypadEnabled(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->IsKeypadEnabled(); +} + +result +_ExpandableEditAreaImpl::ShowKeypad(void) +{ + ClearLastResult(); + + return __pExpandableEditArea->ShowKeypad(); +} + +int +_ExpandableEditAreaImpl::GetTextLineCount(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetTextLineCount(); +} + +result +_ExpandableEditAreaImpl::GetBlockRange(int& start, int& end) const +{ + ClearLastResult(); + + __pExpandableEditArea->GetBlockRange(start, end); + + if (!((start == 0) && (end == 0))) + { + end -= 1; + } + + return E_SUCCESS; +} + +result +_ExpandableEditAreaImpl::ReleaseBlock(void) +{ + ClearLastResult(); + + return __pExpandableEditArea->ReleaseTextBlock(); +} + +result +_ExpandableEditAreaImpl::RemoveTextBlock(void) +{ + ClearLastResult(); + + return __pExpandableEditArea->RemoveTextBlock(); +} + +result +_ExpandableEditAreaImpl::SetBlockRange(int start, int end) +{ + ClearLastResult(); + + int tempTextLength = __pExpandableEditArea->GetTextLength(); + SysTryReturnResult(NID_UI_CTRL, ((start > -1) && (end > -1) && (end >= start) && (end < tempTextLength)), E_OUT_OF_RANGE, + "start (%d) and end (%d) is out of range.", start, end); + + return __pExpandableEditArea->SetBlockRange(start, end + 1); +} + +result +_ExpandableEditAreaImpl::OnBoundsChanged(const Rectangle& oldRect, const Rectangle& newRect) +{ + ClearLastResult(); + + return E_SUCCESS; +} + +void +_ExpandableEditAreaImpl::SetMaxLineCount(int maxLineCount) +{ + ClearLastResult(); + + __pExpandableEditArea->SetMaxLineCount(maxLineCount); +} + +int +_ExpandableEditAreaImpl::GetMaxLineCount(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetMaxLineCount(); +} + +String +_ExpandableEditAreaImpl::GetTitleText(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetTitleText(); +} + +result +_ExpandableEditAreaImpl::SetTitleText(const String& title) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, (__pExpandableEditArea->GetEditStyle() & (EDIT_STYLE_TITLE_LEFT | EDIT_STYLE_TITLE_TOP)), + E_UNSUPPORTED_OPERATION, "The current title style cannot support this function.\n"); + + return __pExpandableEditArea->SetTitleText(title); +} + +int +_ExpandableEditAreaImpl::GetLimitLength(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->GetTextLimitLength(); +} + +result +_ExpandableEditAreaImpl::SetLimitLength(int limitLength) +{ + ClearLastResult(); + + return __pExpandableEditArea->SetLimitLength(limitLength); +} + +result +_ExpandableEditAreaImpl::SetAutoResizingEnabled(bool enable) +{ + ClearLastResult(); + + Variant var(enable); + + return __pExpandableEditArea->SetPropertyAutoResizingEnabled(var); +} + +bool +_ExpandableEditAreaImpl::IsAutoResizingEnabled(void) const +{ + ClearLastResult(); + + Variant var = __pExpandableEditArea->GetPropertyAutoResizingEnabled(); + + return var.ToBool(); +} + +void +_ExpandableEditAreaImpl::SetAutoShrinkModeEnabled(bool enable) +{ + ClearLastResult(); + + __pExpandableEditArea->SetAutoShrinkModeEnabled(enable); +} + +bool +_ExpandableEditAreaImpl::IsAutoShrinkModeEnabled(void) const +{ + ClearLastResult(); + + return __pExpandableEditArea->IsAutoShrinkModeEnabled(); +} + +ITokenFilter* +_ExpandableEditAreaImpl::GetTokenFilter(void) const +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturn(NID_UI_CTRL, pTokenEdit != null, null, E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + return __pTokenFilter; +} + +result +_ExpandableEditAreaImpl::SetTokenFilter(const ITokenFilter* pFilter) +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturnResult(NID_UI_CTRL, pTokenEdit != null, E_UNSUPPORTED_OPERATION, + "ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + __pTokenFilter = const_cast (pFilter); + + return pTokenEdit->SetTokenFilter(this); +} + +result +_ExpandableEditAreaImpl::AppendToken(const String& token) +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturnResult(NID_UI_CTRL, pTokenEdit != null, E_UNSUPPORTED_OPERATION, + "ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + return pTokenEdit->AppendToken(token); +} + +result +_ExpandableEditAreaImpl::InsertTokenAt(int index, const String& token) +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturnResult(NID_UI_CTRL, pTokenEdit != null, E_UNSUPPORTED_OPERATION, + "ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + return pTokenEdit->InsertTokenAt(index, token); +} + +String +_ExpandableEditAreaImpl::GetTokenAt(int index) const +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturn(NID_UI_CTRL, pTokenEdit != null, String(), E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + return pTokenEdit->GetTokenAt(index); +} + +int +_ExpandableEditAreaImpl::GetTokenCount(void) const +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturn(NID_UI_CTRL, pTokenEdit != null, -1, E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + return pTokenEdit->GetTokenCount(); +} + +int +_ExpandableEditAreaImpl::GetSelectedTokenIndex(void) const +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturn(NID_UI_CTRL, pTokenEdit != null, -1, E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + return pTokenEdit->GetSelectedTokenIndex(); +} + +bool +_ExpandableEditAreaImpl::IsTokenEditModeEnabled(void) const +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturn(NID_UI_CTRL, pTokenEdit != null, false, E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + Variant var = pTokenEdit->GetPropertyTokenEditModeEnabled(); + + return var.ToBool(); +} + +result +_ExpandableEditAreaImpl::RemoveTokenAt(int index) +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturnResult(NID_UI_CTRL, pTokenEdit != null, E_UNSUPPORTED_OPERATION, + "ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + return pTokenEdit->RemoveTokenAt(index); +} + +result +_ExpandableEditAreaImpl::SetTokenSelected(int index, bool selected) +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturnResult(NID_UI_CTRL, pTokenEdit != null, E_UNSUPPORTED_OPERATION, + "ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + return pTokenEdit->SetTokenSelected(index, selected); +} + +result +_ExpandableEditAreaImpl::SetTokenEditModeEnabled(bool enable) +{ + ClearLastResult(); + + _TokenEdit* pTokenEdit = dynamic_cast <_TokenEdit*>(__pExpandableEditArea); + SysTryReturnResult(NID_UI_CTRL, pTokenEdit != null, E_UNSUPPORTED_OPERATION, + "ExpandableEditArea of style EXPANDABLE_EDIT_AREA_NORMAL does not support this operation."); + + Variant var(enable); + return pTokenEdit->SetPropertyTokenEditModeEnabled(var); +} + +void +_ExpandableEditAreaImpl::OnTextValueChanged(const _Control& source) +{ + if (__pPublicTextEvent != null) + { + IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CHANGED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTextEvent->Fire(*pEventArg); + } +} + +void +_ExpandableEditAreaImpl::OnTextValueChangeCanceled(const _Control& source) +{ + if (__pPublicTextEvent != null) + { + IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CANCELED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTextEvent->Fire(*pEventArg); + } +} + +void +_ExpandableEditAreaImpl::OnExpandableEditAreaLineAdded(const _Control& source, int newLineCount) +{ + if (__pPublicExpandableEditAreaEvent) + { + IEventArg* pEventArg = _PublicExpandableEditAreaEvent::CreateExpandableEditAreaEventArgN( + EXPANDABLE_EDITAREA_EVENT_ADDED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicExpandableEditAreaEvent->Fire(*pEventArg); + } +} + +void +_ExpandableEditAreaImpl::OnExpandableEditAreaLineRemoved(const _Control& source, int newLineCount) +{ + if (__pPublicExpandableEditAreaEvent) + { + IEventArg* pEventArg = _PublicExpandableEditAreaEvent::CreateExpandableEditAreaEventArgN( + EXPANDABLE_EDITAREA_EVENT_REMOVED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicExpandableEditAreaEvent->Fire(*pEventArg); + } +} + +void +_ExpandableEditAreaImpl::OnTextBlockSelected(_Control& source, int start, int end) +{ + if (__pPublicTextBlockEvent != null) + { + IEventArg* pTextBlockEventArg = _PublicTextBlockEvent::CreateTextBlockEventArgN(start, end); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTextBlockEvent->Fire(*pTextBlockEventArg); + } +} + +void +_ExpandableEditAreaImpl::OnKeypadWillOpen(void) +{ + if (__pPublicKeypadEvent) + { + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_ENTER, KEYPAD_EVENT_STATUS_CREATED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } +} + +void +_ExpandableEditAreaImpl::OnKeypadOpened(void) +{ + if (__pPublicKeypadEvent) + { + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_ENTER, KEYPAD_EVENT_STATUS_OPEN); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } +} + +void +_ExpandableEditAreaImpl::OnKeypadClosed(void) +{ + if (__pPublicKeypadEvent) + { + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_ENTER, KEYPAD_EVENT_STATUS_CLOSE); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } +} + +void +_ExpandableEditAreaImpl::OnKeypadBoundsChanged(void) +{ + if (__pPublicKeypadEvent) + { + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_ENTER, KEYPAD_EVENT_STATUS_BOUNDS_CHANGED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } +} + +void +_ExpandableEditAreaImpl::OnLanguageChanged(LanguageCode oldLanguage, LanguageCode newLanguage) +{ + if (__pPublicLanguageEvent) + { + IEventArg* pKLanguageEventArg = _PublicLanguageEvent::CreateLanguageEventArgN(GetPublic(), oldLanguage, newLanguage); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pKLanguageEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicLanguageEvent->Fire(*pKLanguageEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } +} + +void +_ExpandableEditAreaImpl::OnKeypadActionPerformed(CoreKeypadAction keypadAction) +{ + if (__pPublicKeypadEvent) + { + KeypadAction onKeypadAction = KEYPAD_ACTION_ENTER; + switch (keypadAction) + { + case CORE_KEYPAD_ACTION_ENTER: + onKeypadAction = KEYPAD_ACTION_ENTER; + break; + + case CORE_KEYPAD_ACTION_GO: + onKeypadAction = KEYPAD_ACTION_GO; + break; + + case CORE_KEYPAD_ACTION_NEXT: + onKeypadAction = KEYPAD_ACTION_NEXT; + break; + + case CORE_KEYPAD_ACTION_SEND: + onKeypadAction = KEYPAD_ACTION_SEND; + break; + + case CORE_KEYPAD_ACTION_SEARCH: + onKeypadAction = KEYPAD_ACTION_SEARCH; + break; + + case CORE_KEYPAD_ACTION_LOGIN: + onKeypadAction = KEYPAD_ACTION_LOGIN; + break; + + case CORE_KEYPAD_ACTION_SIGN_IN: + onKeypadAction = KEYPAD_ACTION_SIGN_IN; + break; + + case CORE_KEYPAD_ACTION_JOIN: + onKeypadAction = KEYPAD_ACTION_JOIN; + break; + + case CORE_KEYPAD_ACTION_DONE: + onKeypadAction = KEYPAD_ACTION_DONE; + break; + + default: + break; + } + + IEventArg* pKeypadEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), onKeypadAction, KEYPAD_EVENT_STATUS_ENTERACTION); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent->Fire(*pKeypadEventArg); + } +} + +bool +_ExpandableEditAreaImpl::ReplaceToken(const String& token, String& replacement) +{ + bool enable = false; + if (__pTokenFilter) + { + enable = __pTokenFilter->ReplaceToken(token, replacement); + } + + return enable; +} + + +class _ExpandableEditAreaMaker + : public _UiBuilderControlMaker +{ +public: + _ExpandableEditAreaMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_ExpandableEditAreaMaker(){}; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _ExpandableEditAreaMaker* pExpandableEditAreaMaker = new (std::nothrow) _ExpandableEditAreaMaker(uibuilder); + return pExpandableEditAreaMaker; + }; + +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + result r = E_SUCCESS; + + Rectangle rect; + ExpandableEditArea* pExpandableEditArea = null; + _UiBuilderControlLayout* pControlProperty = null; + ExpandableEditAreaStyle style = EXPANDABLE_EDIT_AREA_STYLE_NORMAL; + ExpandableEditAreaTitleStyle titleStyle = EXPANDABLE_EDIT_AREA_TITLE_STYLE_NONE; + bool lowerCaseMode = false; + KeypadAction keypadAction = KEYPAD_ACTION_ENTER; + KeypadStyle keypadStyle = KEYPAD_STYLE_NORMAL; + int maxLines = 10; + String guideText; + int verticalMarin = 0; + int horizontalMargin = 0; + String text; + int textSize = 6; + String titleText; + int limitLength = 0; + int opacity = 100; + Color color; + bool autoResizing = false; + bool autoShrink = false; + String elementString; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pExpandableEditArea = new (std::nothrow) ExpandableEditArea(); + if (pExpandableEditArea == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + + if (pControl->GetElement(L"style", elementString)) + { + if (elementString.Equals(L"EXPANDABLE_EDIT_AREA_STYLE_NORMAL", false)) + { + style = EXPANDABLE_EDIT_AREA_STYLE_NORMAL; + } + else + { + style = EXPANDABLE_EDIT_AREA_STYLE_TOKEN; + } + } + + if (pControl->GetElement(L"titleStyle", elementString)) + { + if (elementString.Equals(L"EXPANDABLE_EDIT_AREA_TITLE_STYLE_NONE", false)) + { + titleStyle = EXPANDABLE_EDIT_AREA_TITLE_STYLE_NONE; + } + else if (elementString.Equals(L"EXPANDABLE_EDIT_AREA_TITLE_STYLE_TOP", false)) + { + titleStyle = EXPANDABLE_EDIT_AREA_TITLE_STYLE_TOP; + } + else + { + titleStyle = EXPANDABLE_EDIT_AREA_TITLE_STYLE_INNER; + } + } + + if (pControl->GetElement(L"maxLines", elementString)) + { + Base::Integer::Parse(elementString, maxLines); + } + + r = pExpandableEditArea->Construct(rect, style, titleStyle, maxLines); + if (r != E_SUCCESS) + { + return null; + } + + if (pControl->GetElement(L"text", elementString)) + { + r = pExpandableEditArea->SetText(elementString); + } + + if (pControl->GetElement(L"guideText", elementString)) + { + r = pExpandableEditArea->SetGuideText(elementString); + } + + if (pControl->GetElement(L"keypadStyle", elementString)) + { + if (elementString.Equals(L"KEYPAD_STYLE_NORMAL", false)) + { + keypadStyle = KEYPAD_STYLE_NORMAL; + } + else if (elementString.Equals(L"KEYPAD_STYLE_PASSWORD", false)) + { + keypadStyle = KEYPAD_STYLE_PASSWORD; + } + else if (elementString.Equals(L"KEYPAD_STYLE_EMAIL", false)) + { + keypadStyle = KEYPAD_STYLE_EMAIL; + } + else if (elementString.Equals(L"KEYPAD_STYLE_URL", false)) + { + keypadStyle = KEYPAD_STYLE_URL; + } + else if (elementString.Equals(L"KEYPAD_STYLE_NUMBER", false)) + { + keypadStyle = KEYPAD_STYLE_NUMBER; + } + else if (elementString.Equals(L"KEYPAD_STYLE_PHONE_NUMBER", false)) + { + keypadStyle = KEYPAD_STYLE_PHONE_NUMBER; + } + else if (elementString.Equals(L"KEYPAD_STYLE_IP_V4", false)) + { + keypadStyle = KEYPAD_STYLE_IP_V4; + } + + r = pExpandableEditArea->SetKeypadStyle(keypadStyle); + } + + if (pControl->GetElement(L"keypadAction", elementString)) + { + if (elementString.Equals(L"KEYPAD_ACTION_ENTER", false)) + { + keypadAction = KEYPAD_ACTION_ENTER; + } + else if (elementString.Equals(L"KEYPAD_ACTION_GO", false)) + { + keypadAction = KEYPAD_ACTION_GO; + } + else if (elementString.Equals(L"KEYPAD_ACTION_NEXT", false)) + { + keypadAction = KEYPAD_ACTION_NEXT; + } + else if (elementString.Equals(L"KEYPAD_ACTION_SEND", false)) + { + keypadAction = KEYPAD_ACTION_SEND; + } + else if (elementString.Equals(L"KEYPAD_ACTION_SEARCH", false)) + { + keypadAction = KEYPAD_ACTION_SEARCH; + } + else if (elementString.Equals(L"KEYPAD_ACTION_LOGIN", false)) + { + keypadAction = KEYPAD_ACTION_LOGIN; + } + else if (elementString.Equals(L"KEYPAD_ACTION_SIGN_IN", false)) + { + keypadAction = KEYPAD_ACTION_SIGN_IN; + } + else if (elementString.Equals(L"KEYPAD_ACTION_JOIN", false)) + { + keypadAction = KEYPAD_ACTION_JOIN; + } + else if (elementString.Equals(L"KEYPAD_ACTION_DONE", false)) + { + keypadAction = KEYPAD_ACTION_DONE; + } + + r = pExpandableEditArea->SetKeypadAction(keypadAction); + } + + if (pControl->GetElement(L"lowerCaseMode", elementString)) + { + if (elementString.Equals(L"true", false)) + { + lowerCaseMode = true; + } + else + { + lowerCaseMode = false; + } + + r = pExpandableEditArea->SetLowerCaseModeEnabled(lowerCaseMode); + } + + if (pControl->GetElement(L"textSize", elementString)) + { + Base::Integer::Parse(elementString, textSize); + _ICoordinateSystemTransformer* pTransform = GetTransformer(); + if (pTransform) + { + textSize = pTransform->Transform(textSize); + } + r = pExpandableEditArea->SetTextSize(textSize); + } + + if (pControl->GetElement(L"verticalMargin", elementString)) + { + Base::Integer::Parse(elementString, verticalMarin); + r = pExpandableEditArea->SetMargin(EDIT_MARGIN_TYPE_VERTICAL, verticalMarin); + } + + if (pControl->GetElement(L"horizontalMargin", elementString)) + { + Base::Integer::Parse(elementString, horizontalMargin); + r = pExpandableEditArea->SetMargin(EDIT_MARGIN_TYPE_HORIZONTAL, horizontalMargin); + } + + if (pControl->GetElement(L"limitLength", elementString)) + { + Base::Integer::Parse(elementString, limitLength); + r = pExpandableEditArea->SetLimitLength(limitLength); + } + + if (pControl->GetElement(L"titleText", elementString)) + { + r = pExpandableEditArea->SetTitleText(elementString); + } + + if (pControl->GetElement(L"normalBGBitmapPath", elementString)) + { + Bitmap* pNormalBGBitmap = null; + pNormalBGBitmap = LoadBitmapN(elementString); + if (pNormalBGBitmap != null) + { + r = pExpandableEditArea->SetBackgroundBitmap(EDIT_STATUS_NORMAL, *pNormalBGBitmap); + delete pNormalBGBitmap; + } + } + + if (pControl->GetElement(L"disabledBGBitmapPath", elementString)) + { + Bitmap* pNormalBGBitmap = null; + pNormalBGBitmap = LoadBitmapN(elementString); + if (pNormalBGBitmap != null) + { + r = pExpandableEditArea->SetBackgroundBitmap(EDIT_STATUS_DISABLED, *pNormalBGBitmap); + delete pNormalBGBitmap; + } + } + + if (pControl->GetElement(L"highlightedBGBitmapPath", elementString)) + { + Bitmap* pNormalBGBitmap = null; + pNormalBGBitmap = LoadBitmapN(elementString); + if (pNormalBGBitmap != null) + { + r = pExpandableEditArea->SetBackgroundBitmap(EDIT_STATUS_HIGHLIGHTED, *pNormalBGBitmap); + delete pNormalBGBitmap; + } + } + + if (pControl->GetElement(L"pressedBGBitmapPath", elementString)) + { + Bitmap* pNormalBGBitmap = null; + pNormalBGBitmap = LoadBitmapN(elementString); + if (pNormalBGBitmap != null) + { + r = pExpandableEditArea->SetBackgroundBitmap(EDIT_STATUS_PRESSED, *pNormalBGBitmap); + delete pNormalBGBitmap; + } + } + + if (pControl->GetElement(L"normalColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"normalColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetColor(EDIT_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"disabledColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"disabledColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetColor(EDIT_STATUS_DISABLED, color); + } + + if (pControl->GetElement(L"highlightedColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"highlightedColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetColor(EDIT_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"pressedColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"pressedColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetColor(EDIT_STATUS_PRESSED, color); + } + + if (pControl->GetElement(L"guideTextColor", elementString)) + { + opacity = 100; + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetGuideTextColor(color); + } + + if (pControl->GetElement(L"normalTitleTextColor", elementString)) + { + opacity = 100; + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetTitleTextColor(EDIT_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"disabledTitleTextColor", elementString)) + { + opacity = 100; + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetTitleTextColor(EDIT_STATUS_DISABLED, color); + } + + if (pControl->GetElement(L"highlightedTitleTextColor", elementString)) + { + opacity = 100; + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetTitleTextColor(EDIT_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"pressedTitleTextColor", elementString)) + { + opacity = 100; + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetTitleTextColor(EDIT_STATUS_PRESSED, color); + } + + if (pControl->GetElement(L"normalTextColor", elementString)) + { + opacity = 100; + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetTextColor(EDIT_TEXT_COLOR_NORMAL, color); + } + + if (pControl->GetElement(L"disabledTextColor", elementString)) + { + opacity = 100; + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetTextColor(EDIT_TEXT_COLOR_DISABLED, color); + } + + if (pControl->GetElement(L"highlightedTextColor", elementString)) + { + opacity = 100; + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"normalTokenColor", elementString)) + { + opacity = 100; + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetTokenColor(EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"selectedTokenColor", elementString)) + { + opacity = 100; + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetTokenColor(EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED, color); + } + + if (pControl->GetElement(L"tokenTextColor", elementString)) + { + opacity = 100; + ConvertStringToColor32(elementString, opacity, color); + r = pExpandableEditArea->SetTokenTextColor(color); + } + + if (pControl->GetElement(L"autoResizing", elementString)) + { + if (elementString.Equals(L"true", false)) + { + autoResizing = true; + } + else + { + autoResizing = false; + } + + r = pExpandableEditArea->SetAutoResizingEnabled(autoResizing); + } + + if (pControl->GetElement(L"autoShrinkModeEnabled", elementString)) + { + if (elementString.Equals(L"true", false)) + { + autoShrink = true; + } + else + { + autoShrink = false; + } + + pExpandableEditArea->SetAutoShrinkModeEnabled(autoShrink); + } + + return pExpandableEditArea; + } +}; + +_ExpandableEditAreaRegister::_ExpandableEditAreaRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"ExpandableEditArea", _ExpandableEditAreaMaker::GetInstance); +} +_ExpandableEditAreaRegister::~_ExpandableEditAreaRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"ExpandableEditArea"); +} +static _ExpandableEditAreaRegister ExpandableEditAreaRegisterToUIbuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ExpandableListData.cpp b/src/ui/controls/FUiCtrl_ExpandableListData.cpp new file mode 100644 index 0000000..5bef837 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ExpandableListData.cpp @@ -0,0 +1,119 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_ExpandableListData.cpp +* @brief This is the implementation file for _MainItem, _SubItem & _ExpandableListItemDataProvider class. +* +*/ + +// Includes +#include +#include "FUiCtrl_ExpandableListData.h" +#include "FUiCtrl_ExpandableListImpl.h" +#include "FUiCtrl_CustomListImpl.h" + +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_MainItem::_MainItem(void) + : isExpanded(false) + , isEnabled(true) + , checkCount(0) + , pCustomItemData(null) +{ +} + +_MainItem::~_MainItem(void) +{ + subItemList.RemoveAll(!isExpanded); + actualSubItemList.RemoveAll(true); +} + + +_SubItem::_SubItem(bool removeItemData) + : isEnabled(true) + , pCustomItemData(null) + , isDeleteNeeded(removeItemData) +{ +} + +_SubItem::~_SubItem(void) +{ + if (isDeleteNeeded) + { + delete pCustomItemData; + pCustomItemData = null; + } +} + + +_ExpandableListItemDataProvider::_ExpandableListItemDataProvider(_ExpandableListImpl* pList) + : __pList(pList) +{ +} + +_ExpandableListItemDataProvider::~_ExpandableListItemDataProvider(void) +{ + +} + +int +_ExpandableListItemDataProvider::GetItemCount(void) +{ + + if (__pList) + { + return __pList->__mainList.GetCount(); + } + + return 0; +} + +ListItemBase* +_ExpandableListItemDataProvider::CreateItem(int index, int itemWidth) +{ + _MainItem* pMainItem = null; + _SubItem* pSubItem = null; + _CustomItemData* pCustomItemData = null; + + pMainItem = dynamic_cast<_MainItem*>(__pList->__mainList.GetAt(index)); + + if (pMainItem!= null) + { + return pCustomItemData = dynamic_cast<_CustomItemData*>(pMainItem->pCustomItemData); + } + + pSubItem = dynamic_cast<_SubItem*>(__pList->__mainList.GetAt(index)); + + if (pSubItem != null) + { + return pCustomItemData = dynamic_cast<_CustomItemData*>(pSubItem->pCustomItemData); + } + + return null; +} + +bool +_ExpandableListItemDataProvider::DeleteItem(int index, ListItemBase* pItem, int itemWidth) +{ + return false; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ExpandableListImpl.cpp b/src/ui/controls/FUiCtrl_ExpandableListImpl.cpp new file mode 100644 index 0000000..94acc7d --- /dev/null +++ b/src/ui/controls/FUiCtrl_ExpandableListImpl.cpp @@ -0,0 +1,1936 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ExpandableListImpl.cpp + * @brief This file contains implementation of _ExpandableListImpl class + */ + +#include +#include +#include "FUiCtrl_CustomListItemImpl.h" +#include "FUiCtrl_CustomListItemFormatImpl.h" +#include "FUiCtrl_ExpandableListImpl.h" +#include "FUiCtrl_ListListener.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_ListItemBaseImpl.h" +#include "FUiCtrl_CustomListImpl.h" +#include "FUi_UiBuilder.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui { namespace Controls +{ + +extern const int INVALID_INDEX; + +static const int _EXPANDABLE_ARROW_X_POSITION = 5; +static const int _EXPANDABLE_ARROW_Y_POSITION = 20; +static const char* ARROW_ELEMENT_NAME = "Arrow"; + +_ExpandableListItemDataProvider::_ExpandableListItemDataProvider(_ExpandableListImpl* pList) + : __pListImpl(pList) +{ +} + +_ExpandableListItemDataProvider::~_ExpandableListItemDataProvider(void) +{ + +} + +int +_ExpandableListItemDataProvider::GetGroupCount(void) +{ + SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly."); + return __pListImpl->GetGroupCount(); +} + +int +_ExpandableListItemDataProvider::GetItemCount(int groupIndex) +{ + SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly."); + + return __pListImpl->GetSubItemCountAt(groupIndex); +} + +TableViewGroupItem* +_ExpandableListItemDataProvider::CreateGroupItem(int groupIndex, int itemWidth) +{ + SysTryReturn(NID_UI_CTRL, __pListImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly."); + + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, -1); + SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex); + + SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex); + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = pCustomListItem; + tableViewItemParams.width = itemWidth; + tableViewItemParams.itemId = pCustomListItem->__pCustomListItemImpl->itemId; + tableViewItemParams.groupIndex = groupIndex; + tableViewItemParams.itemIndex = -1; + tableViewItemParams.isDividerEnabled = __pListImpl->_isDividerEnabled; + tableViewItemParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps; + tableViewItemParams.annexStyle = __pListImpl->_annexStyle; + + result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData->AddTouchEventListener(*__pListImpl); + + if (__pListImpl->GetSubItemCountAt(groupIndex) > 0) + { + r = __pListImpl->CreateArrowIcon(groupIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData; +} + +TableViewItem* +_ExpandableListItemDataProvider::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + SysTryReturn(NID_UI_CTRL, __pListImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Invalid data structure."); + + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex); + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = pCustomListItem; + tableViewItemParams.width = itemWidth; + tableViewItemParams.itemId = pCustomListItem->__pCustomListItemImpl->itemId; + tableViewItemParams.groupIndex = groupIndex; + tableViewItemParams.itemIndex = itemIndex; + tableViewItemParams.isDividerEnabled = __pListImpl->_isDividerEnabled; + tableViewItemParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps; + tableViewItemParams.annexStyle = __pListImpl->_annexStyle; + + result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCustomListItem->__pCustomListItemImpl->__pTableViewItemData->AddTouchEventListener(*__pListImpl); + + if (__pListImpl->GetSubItemCountAt(groupIndex) == 1) + { + r = __pListImpl->CreateArrowIcon(groupIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pCustomListItem->__pCustomListItemImpl->__pTableViewItemData; +} + +int +_ExpandableListItemDataProvider::GetDefaultGroupItemHeight(void) +{ + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(0, -1); + SysTryReturn(NID_UI_CTRL, pCustomListItem, __pListImpl->_defaultItemHeight, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get first item"); + + SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, __pListImpl->_defaultItemHeight, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get first item"); + + return pCustomListItem->__pCustomListItemImpl->height; +} + +int +_ExpandableListItemDataProvider::GetDefaultItemHeight(void) +{ + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(0, 0); + + if (!pCustomListItem) + { + return __pListImpl->_defaultItemHeight; + } + else + { + return pCustomListItem->__pCustomListItemImpl->height; + } +} + +bool +_ExpandableListItemDataProvider::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + delete pItem; + + if (__pListImpl->__directDelete == false) + { + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex); + pCustomListItem->__pCustomListItemImpl->__pTableViewItemData = null; + } + + return true; +} + +bool +_ExpandableListItemDataProvider::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + delete pItem; + + if (__pListImpl->__directDelete == false) + { + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, -1); + pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData = null; + } + + return true; +} + +bool +_ExpandableListItemDataProvider::IsReorderable(int groupIndexFrom, int groupIndexTo) +{ + return false; +} + +void +_ExpandableListItemDataProvider::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + CustomListItem* pGroupCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, -1); + SysTryReturnVoidResult(NID_UI_CTRL, pGroupCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex); + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = pGroupCustomListItem; + updateParams.isDividerEnabled = __pListImpl->_isDividerEnabled; + updateParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps; + updateParams.annexStyle = __pListImpl->_annexStyle; + + result r = E_SUCCESS; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item."); + + SysTryReturnVoidResult(NID_UI_CTRL, pGroupCustomListItem->__pCustomListItemImpl, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex); + + _TableViewItemData* pTableViewItemData = pGroupCustomListItem->__pCustomListItemImpl->__pTableViewItemData; + SysTryReturnVoidResult(NID_UI_CTRL, pTableViewItemData, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex); + + pTableViewItemData->SetEnabled(true); + return; +} + +void +_ExpandableListItemDataProvider::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex); + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = pCustomListItem; + updateParams.isDividerEnabled = __pListImpl->_isDividerEnabled; + updateParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps; + updateParams.annexStyle = __pListImpl->_annexStyle; + + result r = E_SUCCESS; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item."); + + _TableViewItemData* pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData; + SysTryReturnVoidResult(NID_UI_CTRL, pTableViewItemData, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex); + + pTableViewItemData->SetEnabled(true); + + return; +} + +_ExpandableListImpl* +_ExpandableListImpl::GetInstance(ExpandableList& expandableList) +{ + return static_cast<_ExpandableListImpl*>(expandableList._pControlImpl); +} + +const _ExpandableListImpl* +_ExpandableListImpl::GetInstance(const ExpandableList& expandableList) +{ + return static_cast(expandableList._pControlImpl); +} + +_ExpandableListImpl::_ExpandableListImpl(Control* pList, _TableView* pCore) + : _ListBaseImpl(pList, pCore) + , __pOpenedImage(null) + , __pClosedImage(null) + , __pItemProvider(null) + , __directDelete(false) + , __groupExpandStateList(DeleteExpandStateFlag) +{ +} + +_ExpandableListImpl::~_ExpandableListImpl(void) +{ + GetCore().SetItemProvider(null); + + int count = GetItemCount(); + + for (int index = 0; index < count; index++) + { + RemoveFromSubItemsList(index); + } + + RemoveAllFromItemsList(); + + __groupExpandStateList.RemoveAll(true); + + __itemListenersList.RemoveAll(true); + + delete __pOpenedImage; + __pOpenedImage = null; + + delete __pClosedImage; + __pClosedImage = null; + + delete __pItemProvider; + __pItemProvider = null; +} + +const char* +_ExpandableListImpl::GetPublicClassName(void) const +{ + return "ExpandableList"; +} + +const ExpandableList& +_ExpandableListImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +ExpandableList& +_ExpandableListImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _TableView& +_ExpandableListImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_TableView& +_ExpandableListImpl::GetCore(void) +{ + return static_cast<_TableView&>(_ControlImpl::GetCore()); +} + +_ExpandableListImpl* +_ExpandableListImpl::CreateExpandableListImplN(ExpandableList* pControl, const Rectangle& bounds, bool itemDivider) +{ + result r = E_SUCCESS; + + r = GET_SIZE_INFO(ExpandableList).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _TableView* pCore = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_GROUPED, true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _ExpandableListImpl* pImpl = new (std::nothrow) _ExpandableListImpl(pControl, pCore); + SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pCore->SetItemDividerEnabled(itemDivider); + + r = pCore->SetScrollStyle(TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + ClearLastResult(); + + return pImpl; + +CATCH: + delete pCore; + delete pImpl; + return null; +} + +result +_ExpandableListImpl::UpdateBounds(const Rectangle& rect) +{ + result r = E_SUCCESS; + + r = InitializeBoundsProperties(GET_SIZE_INFO(CustomList), rect, GetCore().GetOrientation()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_ExpandableListImpl::Initialize(void) +{ + result r = E_SUCCESS; + + __pItemProvider = new (std::nothrow) _ExpandableListItemDataProvider(this); + SysTryReturnResult(NID_UI_CTRL, (__pItemProvider != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryReturnResult(NID_UI_CTRL, style == TABLE_VIEW_STYLE_GROUPED, E_INVALID_OPERATION, "The style of TableView is not TABLE_VIEW_STYLE_GROUPED"); + + _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style); + SysTryReturnResult(NID_UI_CTRL, pItemProvider != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = pItemProvider->SetGroupedStyleItemProvider(__pItemProvider); + + if (r != E_SUCCESS) + { + delete pItemProvider; + SysTryReturn(NID_UI_CTRL, false, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = GetCore().SetItemProvider(pItemProvider); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetCore().AddGroupedTableViewItemEventListener(*this); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + LoadArrowBitmap(); + + GET_COLOR_CONFIG(LIST::EXPANDABLELIST_SUB_ITEM_BG_COLOR, __subItemBgColor); + + return r; +} + +result +_ExpandableListImpl::CreateArrowIcon(int groupIndex) +{ + int size = __pOpenedImage->GetWidth(); + result r = E_SUCCESS; + + _TableViewGroupItemData* pTableViewGroupItemData = GetTableViewGroupItemAt(groupIndex); + SysTryReturnResult(NID_UI_CTRL, pTableViewGroupItemData, E_SYSTEM, "A system error has occurred. Failed to get GroupItemData at %d index.", groupIndex); + + Label* pArrowLabel = null; + pArrowLabel = dynamic_cast(pTableViewGroupItemData->GetControl(ARROW_ELEMENT_NAME)); + + if (!pArrowLabel) + { + Label* pArrowLabel = new (std::nothrow) Label(); + SysTryReturn(NID_UI_CTRL, pArrowLabel, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pArrowLabel->Construct(Rectangle((GetCore().GetBounds().width - (size + _EXPANDABLE_ARROW_X_POSITION)), _EXPANDABLE_ARROW_Y_POSITION, size, size), L""); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pArrowLabel->SetName(ARROW_ELEMENT_NAME); + pArrowLabel->SetBackgroundBitmap(*__pOpenedImage); + pArrowLabel->AddTouchEventListener(*this); + + pTableViewGroupItemData->AddControl(*pArrowLabel); + pTableViewGroupItemData->SetIndividualSelectionEnabled(pArrowLabel, true); + } + + return E_SUCCESS; +} + +result +_ExpandableListImpl::LoadArrowBitmap(void) +{ + result r = E_SUCCESS; + Bitmap* pTempBitmap = null; + Color normalColor; + + GET_COLOR_CONFIG(LIST::EXPANDABLELIST_DOWN_AND_UP_ARROW_COLOR, normalColor); + + r = GET_BITMAP_CONFIG_N(LIST::BUTTON_COLLAPSE_GROUP, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Failed to fetch Arrow Bitmap"); + __pOpenedImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), normalColor); + + delete pTempBitmap; + pTempBitmap = null; + + r = GET_BITMAP_CONFIG_N(LIST::BUTTON_EXPAND_GROUP, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Failed to fetch Arrow Bitmap"); + __pClosedImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), normalColor); + + delete pTempBitmap; + pTempBitmap = null; + + return r; +} + +result +_ExpandableListImpl::AddExpandableItemEventListener(const IExpandableItemEventListener& listener) +{ + _ListListener* pListenersList = new (std::nothrow) _ListListener(); + + SysTryReturn(NID_UI_CTRL, pListenersList, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pListenersList->pListener = const_cast(&listener); + __itemListenersList.Add(*pListenersList); + + return E_SUCCESS; +} + +result +_ExpandableListImpl::RemoveExpandableItemEventListener(const IExpandableItemEventListener& listener) +{ + _ListListener* pListenersList = null; + result r = E_SYSTEM; + int count = __itemListenersList.GetCount(); + + for (int listenerCount = 0; listenerCount < count; listenerCount++) + { + pListenersList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + + if ((pListenersList != null) && (pListenersList->pListener == &listener)) + { + r = E_SUCCESS; + __itemListenersList.RemoveAt(listenerCount, true); + break; + } + } + + return r; +} + +result +_ExpandableListImpl::AddItem(const CustomListItem& item, int itemId) +{ + return InsertItemAt(GetGroupCount(), item, itemId); +} + +result +_ExpandableListImpl::InsertItemAt(int mainIndex, const CustomListItem& item, int itemId) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex <= GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex); + + item.__pCustomListItemImpl->itemId = itemId; + + Boolean* pIsExpanded = new Boolean(false); + SysTryReturn(NID_UI_CTRL, pIsExpanded, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __groupExpandStateList.InsertAt(*pIsExpanded, mainIndex); + + r = InsertIntoItemsList(item, mainIndex, -1); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to insert an item."); + + r = GetCore().RefreshTableView(mainIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + if (GetCore().GetFirstDrawnFlag() == false) + { + SetItemExpanded(mainIndex, false); + } + + return E_SUCCESS; + +CATCH: + RemoveFromItemsList(mainIndex, -1); + __groupExpandStateList.RemoveAt(mainIndex, true); + + return E_SYSTEM; +} + +result +_ExpandableListImpl::AddSubItem(int mainIndex, const CustomListItem& item, int itemId) +{ + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex <= GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex); + + return InsertSubItemAt(mainIndex, GetSubItemCountAt(mainIndex), item, itemId); +} + +result +_ExpandableListImpl::InsertSubItemAt(int mainIndex, int subIndex, const CustomListItem& item, int itemId) +{ + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex <= GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d.", mainIndex); + + SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex <= GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex = %d.", subIndex); + + item.__pCustomListItemImpl->itemId = itemId; + + result r = E_SUCCESS; + + r = InsertIntoItemsList(item, mainIndex, subIndex); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to insert item"); + + r = GetCore().RefreshTableView(mainIndex, subIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + RemoveFromItemsList(mainIndex, subIndex); + return E_SYSTEM; +} + +int +_ExpandableListImpl::GetItemCount(void) const +{ + return GetGroupCount(); +} + +int +_ExpandableListImpl::GetSubItemCount(int mainIndex) const +{ + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d.", mainIndex); + + return GetSubItemCountAt(mainIndex); +} + +result +_ExpandableListImpl::SetItemAt(int mainIndex, const CustomListItem& item, int itemId) +{ + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex); + + SysTryReturnResult(NID_UI_CTRL, (IsItemNew(item) == true), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The item already exists."); + + result r = E_SUCCESS; + item.__pCustomListItemImpl->itemId = itemId; + + r = SetInItemsList(item, mainIndex, -1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = const_cast(&item); + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "A system error has occurred. Failed to refresh an item."); + + return E_SUCCESS; +} + +result +_ExpandableListImpl::RemoveItemAt(int mainIndex) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d.", mainIndex); + + r = RemoveFromSubItemsList(mainIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = RemoveFromItemsList(mainIndex, -1); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __groupExpandStateList.RemoveAt(mainIndex, true); + + __directDelete = true; + + r = GetCore().RefreshTableView(mainIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + + __directDelete = false; + + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_ExpandableListImpl::SetSubItemAt(int mainIndex, int subIndex, const CustomListItem& item, int itemId) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, ((mainIndex >= 0) && (mainIndex < GetGroupCount())), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + + _TableViewGroupItemData* pGroupItem = GetTableViewGroupItemAt(mainIndex); + SysTryReturn(NID_UI_CTRL, pGroupItem, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get GroupItem at %d index.", mainIndex); + + SysTryReturn(NID_UI_CTRL, ((subIndex >= 0) && (subIndex < GetSubItemCountAt(mainIndex))), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex); + + item.__pCustomListItemImpl->itemId = itemId; + + CustomListItem* pOldItem = GetCustomListItemAt(mainIndex, subIndex); + SysTryReturnResult(NID_UI_CTRL, pOldItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d), subIndex(%d).", mainIndex, subIndex); + SysTryReturnResult(NID_UI_CTRL, pOldItem->__pCustomListItemImpl, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d), subIndex(%d).", mainIndex, subIndex); + + item.__pCustomListItemImpl->__pTableViewItemData = pOldItem->__pCustomListItemImpl->__pTableViewItemData; + + r = SetInItemsList(item, mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to update an item."); + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = const_cast(&item); + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item."); + + r = GetCore().RefreshTableView(mainIndex, subIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "Item not inserted successFully."); + + return r; +} + +result +_ExpandableListImpl::RemoveSubItemAt(int mainIndex, int subIndex) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, ((mainIndex >= 0) && (mainIndex < GetGroupCount())), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + + SysTryReturn(NID_UI_CTRL, ((subIndex >= 0) && (subIndex < GetSubItemCount(mainIndex))), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex); + + r = RemoveFromItemsList(mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove item."); + + __directDelete = true; + + r = GetCore().RefreshTableView(mainIndex, subIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + + __directDelete = false; + + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove item."); + + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING) + { + int checkedCount = GetCheckedItemCount(mainIndex); + + if (checkedCount == 0) + { + _CheckElementModel* pGroupCheckElement = GetCheckElementAt(mainIndex, -1); + SysTryReturnResult(NID_UI_CTRL, pGroupCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at %d index.", mainIndex); + + pGroupCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED); + + DrawItem(mainIndex, -1); + } + } + + return E_SUCCESS; +} + +result +_ExpandableListImpl::RemoveAllSubItemsAt(int mainIndex) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d.", mainIndex); + + int count = GetSubItemCountAt(mainIndex); + for (int index = 0; index < count; index++) + { + r = RemoveSubItemAt(mainIndex, 0); + } + + return r; +} + +result +_ExpandableListImpl::RemoveAllItems(void) +{ + result r = E_SUCCESS; + result finalResult = E_SUCCESS; + + int count = GetGroupCount(); + for (int index = count - 1; index >= 0; index--) + { + r = RemoveItemAt(index); + + if (r != E_SUCCESS) + { + finalResult = r; + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Item at %d index not removed successfully", index); + index++; + } + } + return finalResult; +} + +bool +_ExpandableListImpl::IsItemChecked(int groupIndex, int subIndex) const +{ + if (subIndex == -1) + { + return IsItemChecked(groupIndex); + } + else + { + return IsSubItemChecked(groupIndex, subIndex); + } +} + +bool +_ExpandableListImpl::IsItemChecked(int mainIndex) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. list style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL."); + + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), + false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + + const _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, -1); + SysTryReturn(NID_UI_CTRL, pCheckElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get checkElement at mainIndex(%d).", mainIndex); + + return (bool)pCheckElement->GetCheckBoxStatus(); +} + +int +_ExpandableListImpl::GetFirstCheckedItemIndex(void) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, INVALID_INDEX, "[INVALID_INDEX] List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + int count = GetGroupCount(); + for (int index = 0; index < count; index++) + { + if (IsItemChecked(index)) + return index; + } + return INVALID_INDEX; +} + +int +_ExpandableListImpl::GetItemIdAt(int mainIndex) const +{ + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + + const CustomListItem* pCustomListItem = GetCustomListItemAt(mainIndex, -1); + SysTryReturn(NID_UI_CTRL, pCustomListItem, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d).", mainIndex); + + return pCustomListItem->__pCustomListItemImpl->itemId; +} + +int +_ExpandableListImpl::GetItemIndexFromItemId(int itemId) const +{ + int count = GetGroupCount(); + for (int index = 0; index < count; index++) + { + const CustomListItem* pCustomListItem = GetCustomListItemAt(index, -1); + SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", index); + + if (itemId == pCustomListItem->__pCustomListItemImpl->itemId) + return index; + } + return INVALID_INDEX; +} + +int +_ExpandableListImpl::GetSubItemIdAt(int mainIndex, int subIndex) const +{ + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + + SysTryReturn(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex); + + const CustomListItem* pCustomListItem = GetCustomListItemAt(mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d), subIndex(%d).", mainIndex, subIndex); + + return pCustomListItem->__pCustomListItemImpl->itemId; +} + +result +_ExpandableListImpl::SetItemExpanded(int mainIndex, bool expand) +{ + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex); + + Boolean* pIsExpanded = new Boolean(expand); + SysTryReturn(NID_UI_CTRL, pIsExpanded, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __groupExpandStateList.SetAt(*pIsExpanded, mainIndex, true); + + if (GetCore().GetFirstDrawnFlag() || (GetCore().IsGroupExpanded(mainIndex) == expand)) + { + return E_SUCCESS; + } + + result r = E_SUCCESS; + + _TableViewGroupItemData* pTableViewGroupItemData = GetTableViewGroupItemAt(mainIndex); + SysTryReturn(NID_UI_CTRL, pTableViewGroupItemData, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item at %d mainIndex.", mainIndex); + + Label* pArrowLabel = dynamic_cast(pTableViewGroupItemData->GetControl(ARROW_ELEMENT_NAME)); + SysTryReturn(NID_UI_CTRL, pArrowLabel, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get arrow icon."); + + if (expand) + { + r = GetCore().ExpandGroup(mainIndex); + pArrowLabel->SetBackgroundBitmap(*__pClosedImage); + } + else + { + r = GetCore().CollapseGroup(mainIndex); + pArrowLabel->SetBackgroundBitmap(*__pOpenedImage); + } + + pArrowLabel->Invalidate(true); + + return r; +} + +result +_ExpandableListImpl::SetItemEnabled(int mainIndex, bool enable) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex); + + _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, -1); + SysTryReturnResult(NID_UI_CTRL, pCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d).", mainIndex); + + if (pCheckElement) + { + if (enable) + { + if (pCheckElement->GetCheckBoxStatus() == CHECK_BOX_DISABLED) + { + pCheckElement->SetCheckBoxStatus(CHECK_BOX_CHECKED); + } + } + else + { + if (pCheckElement->GetCheckBoxStatus() == CHECK_BOX_CHECKED) + { + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) + { + pCheckElement->SetCheckBoxStatus(CHECK_BOX_DISABLED); + } + } + } + } + + r = GetCore().SetItemEnabled(mainIndex, -1, enable); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +bool +_ExpandableListImpl::IsItemEnabled(int mainIndex) const +{ + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + + return GetCore().IsItemEnabled(mainIndex, -1); +} + +result +_ExpandableListImpl::SetSubItemEnabled(int mainIndex, int subIndex, bool enable) +{ + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex(%d)", mainIndex); + SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex(%d)", subIndex); + + result r = E_SUCCESS; + + _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, subIndex); + SysTryReturnResult(NID_UI_CTRL, pCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", mainIndex, subIndex); + + if (pCheckElement) + { + if (enable) + { + if (pCheckElement->GetCheckBoxStatus() == CHECK_BOX_DISABLED) + { + pCheckElement->SetCheckBoxStatus(CHECK_BOX_CHECKED); + } + } + else + { + if (pCheckElement->GetCheckBoxStatus() == CHECK_BOX_CHECKED) + { + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) + { + pCheckElement->SetCheckBoxStatus(CHECK_BOX_DISABLED); + } + } + } + } + + r = GetCore().SetItemEnabled(mainIndex, subIndex, enable); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +bool +_ExpandableListImpl::IsSubItemEnabled(int mainIndex, int subIndex) const +{ + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + + SysTryReturn(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex); + + return GetCore().IsItemEnabled(mainIndex, subIndex); +} + +result +_ExpandableListImpl::SetItemChecked(int groupIndex, int itemIndex, bool check) +{ + if (itemIndex == -1) + { + return SetItemChecked(groupIndex, check); + } + else + { + return SetSubItemChecked(groupIndex, itemIndex, check); + } +} + +result +_ExpandableListImpl::SetItemChecked(int mainIndex, bool check) +{ + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex); + + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + SysTryReturnResult(NID_UI_CTRL, (IsItemEnabled(mainIndex)), E_SYSTEM, "A system error has occurred. The item is not enabled at mainIndex %d.", mainIndex); + + if (IsItemChecked(mainIndex) == check) + { + return E_SUCCESS; + } + + _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, -1); + SysTryReturnResult(NID_UI_CTRL, pCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d)", mainIndex); + + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + { + if (_currentRadioGroupIndex != -1) + { + _CheckElementModel* pOldSubCheckElement = GetCheckElementAt(_currentRadioGroupIndex, _currentRadioIndex); + SysTryReturnResult(NID_UI_CTRL, pOldSubCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", _currentRadioGroupIndex, _currentRadioIndex); + + pOldSubCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED); + + DrawItem(_currentRadioGroupIndex, _currentRadioIndex); + } + + _currentRadioGroupIndex = (check == true) ? mainIndex : -1; + pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check); + _currentRadioIndex = -1; + + return E_SUCCESS; + } + + int subCount = GetSubItemCountAt(mainIndex); + + if (subCount == 0) + { + pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check); + } + else + { + for (int subItemCount = 0; subItemCount < subCount; subItemCount++) + { + SetSubItemChecked(mainIndex, subItemCount, check); + } + } + + return E_SUCCESS; +} + +result +_ExpandableListImpl::SetSubItemCheckedRadio(int mainIndex, int subIndex, bool check) +{ + if (_currentRadioGroupIndex != -1) + { + _CheckElementModel* pOldSubCheckElement = GetCheckElementAt(_currentRadioGroupIndex, _currentRadioIndex); + SysTryReturnResult(NID_UI_CTRL, pOldSubCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", _currentRadioGroupIndex, _currentRadioIndex); + + pOldSubCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED); + + DrawItem(_currentRadioGroupIndex, _currentRadioIndex); + } + + if (check) + { + _currentRadioGroupIndex = mainIndex; + _currentRadioIndex = subIndex; + } + else + { + _currentRadioGroupIndex = -1; + _currentRadioIndex = -1; + } + + _CheckElementModel* pSubCheckElement = GetCheckElementAt(mainIndex, subIndex); + SysTryReturnResult(NID_UI_CTRL, pSubCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", mainIndex, subIndex); + + pSubCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check); + + DrawItem(mainIndex, subIndex); + + return E_SUCCESS; +} + +result +_ExpandableListImpl::SetSubItemCheckedMarkOnOff(int mainIndex, int subIndex, bool check) +{ + _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, subIndex); + SysTryReturnResult(NID_UI_CTRL, pCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", mainIndex, subIndex); + + pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check); + + _CheckElementModel* pGroupCheckElement = GetCheckElementAt(mainIndex, -1); + SysTryReturnResult(NID_UI_CTRL, pGroupCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d).", mainIndex); + + if ((check) || (GetCheckedItemCountAt(mainIndex) > 0)) + { + pGroupCheckElement->SetCheckBoxStatus(CHECK_BOX_CHECKED); + } + else + { + pGroupCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED); + } + + DrawItem(mainIndex, -1); + DrawItem(mainIndex, subIndex); + + return E_SUCCESS; +} + +result +_ExpandableListImpl::SetSubItemChecked(int mainIndex, int subIndex, bool check) +{ + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex); + + SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex = %d", subIndex); + + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + if (IsSubItemChecked(mainIndex, subIndex) == check) + { + return E_SUCCESS; + } + + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + { + return SetSubItemCheckedRadio(mainIndex, subIndex, check); + } + else + { + return SetSubItemCheckedMarkOnOff(mainIndex, subIndex, check); + } +} + +int +_ExpandableListImpl::GetCheckedItemCountAt(int mainIndex) const +{ + int totalSubItemCount = GetSubItemCountAt(mainIndex); + int count = 0; + + for (int index = 0; index < totalSubItemCount; index++) + { + if (IsSubItemChecked(mainIndex, index) == true) + { + count++; + } + } + + return count; +} + +bool +_ExpandableListImpl::IsSubItemChecked(int mainIndex, int subIndex) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. list style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL."); + + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + + SysTryReturn(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex); + + const _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, pCheckElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", mainIndex, subIndex); + + return (bool)pCheckElement->GetCheckBoxStatus(); +} + +result +_ExpandableListImpl::SetAllSubItemsChecked(int mainIndex, bool check) +{ + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex); + + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, "A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_RADIO"); + + int totalSubItemCount = GetSubItemCountAt(mainIndex); + result r = E_SUCCESS; + + for (int subItemCount = 0; subItemCount < totalSubItemCount; subItemCount++) + { + r = SetSubItemChecked(mainIndex, subItemCount, check); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; +} + +result +_ExpandableListImpl::RemoveAllCheckedSubItemsAt(int mainIndex) +{ + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex); + + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, "A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_RADIO"); + + result r = E_SUCCESS; + int totalSubItemCount = GetSubItemCountAt(mainIndex); + + for (int subItemCount = 0; subItemCount < totalSubItemCount; subItemCount++) + { + bool isChecked = IsSubItemChecked(mainIndex, subItemCount); + + if (isChecked) + { + r = RemoveSubItemAt(mainIndex, subItemCount); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to remove item"); + } + } + + return E_SUCCESS; +} + +int +_ExpandableListImpl::GetFirstCheckedSubItemIndex(int mainIndex) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + + int totalSubItemCount = GetSubItemCountAt(mainIndex); + + for (int subItemCount = 0; subItemCount < totalSubItemCount; subItemCount++) + { + if (IsSubItemChecked(mainIndex, subItemCount)) + { + return subItemCount; + } + } + + return INVALID_INDEX; +} + +int +_ExpandableListImpl::GetLastCheckedItemIndex(void) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + int count = GetGroupCount(); + + for (int index = count - 1; index >= 0; index--) + { + if (IsItemChecked(index)) + { + return index; + } + } + + return INVALID_INDEX; +} + +int +_ExpandableListImpl::GetLastCheckedSubItemIndex(int mainIndex) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + + int count = GetSubItemCountAt(mainIndex); + + for (int index = count - 1; index >= 0; index--) + { + if (IsSubItemChecked(mainIndex, index)) + { + return index; + } + } + return INVALID_INDEX; +} + +int +_ExpandableListImpl::GetNextCheckedItemIndexAfter(int mainIndex) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + + for (int index = mainIndex+1; index < GetGroupCount(); index++) + { + if (IsItemChecked(index)) + { + return index; + } + } + + return INVALID_INDEX; +} + +int +_ExpandableListImpl::GetNextCheckedSubItemIndexAfter(int mainIndex, int subIndex) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + SysTryReturn(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex); + + int count = GetSubItemCountAt(mainIndex); + + for (int index = subIndex + 1; index < count; index++) + { + if (IsSubItemChecked(mainIndex, index)) + { + return index; + } + } + + return INVALID_INDEX; +} + +result +_ExpandableListImpl::GetSubItemIndexFromItemId(int itemId, int& mainIndex, int& subIndex) const +{ + mainIndex = INVALID_INDEX; + subIndex = INVALID_INDEX; + + for (int index = 0; index < GetGroupCount(); index++) + { + for (int count = 0; count < GetSubItemCountAt(index); count++) + { + const CustomListItem* pCustomListItem = GetCustomListItemAt(index, count); + SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "A system error has occurred. Failed to get an item at mainIndex(%d) subIndex(%d).", index, count); + + SysTryReturnResult(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, E_SYSTEM, "A system error has occurred. Failed to get an item at mainIndex(%d) subIndex(%d).", index, count); + + if (itemId == pCustomListItem->__pCustomListItemImpl->itemId) + { + mainIndex = index; + subIndex = count; + return E_SUCCESS; + } + } + } + + return E_OBJ_NOT_FOUND; +} + +result +_ExpandableListImpl::ScrollToBottom(void) +{ + result r = E_SUCCESS; + + int lastGroupIndex = GetGroupCount() - 1; + int lastItemIndex = GetSubItemCountAt(lastGroupIndex) - 1; + + r = GetCore().SetBottomDrawnItemIndex(lastGroupIndex, lastItemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + return E_SUCCESS; +} +result +_ExpandableListImpl::ScrollToTop(void) +{ + result r = E_SUCCESS; + + r = GetCore().SetTopDrawnItemIndex(0, -1); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + SetLastResult(E_SUCCESS); + + GetCore().Draw(); + + return r; +} + +result +_ExpandableListImpl::ScrollToTop(int mainIndex, int subIndex) +{ + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex); + SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex = %d", subIndex); + result r = E_SUCCESS; + + r = GetCore().SetTopDrawnItemIndex(mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + return r; +} + +result +_ExpandableListImpl::ScrollToTop(int mainIndex) +{ + SysTryReturn(NID_UI_CTRL, ((mainIndex < GetGroupCount()) && (mainIndex >= 0)), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d.", mainIndex); + + result r = E_SUCCESS; + + r = GetCore().SetTopDrawnItemIndex(mainIndex, -1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + return r; +} + +void +_ExpandableListImpl::SetBgColor(const Color& color) +{ + GetCore().SetBackgroundColor(color); + return; +} + +result +_ExpandableListImpl::RefreshItem(int mainIndex) +{ + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d.", mainIndex); + + int topGroupIndex = -1; + int bottomGroupIndex = -1; + int itemIndex = -1; + + GetCore().GetTopDrawnItemIndex(topGroupIndex, itemIndex); + GetCore().GetBottomDrawnItemIndex(bottomGroupIndex, itemIndex); + + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= topGroupIndex && mainIndex <= bottomGroupIndex), E_INVALID_OPERATION, "Index should be within drawn item range %d.", mainIndex); + + result r = E_SUCCESS; + + int count = GetSubItemCountAt(mainIndex); + for (int indexItem = 0; indexItem < count; indexItem++) + { + r = RefreshSubItem(mainIndex, indexItem); + if (r != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Not able to refresh item with index %d %d.", mainIndex, indexItem); + } + } + + return E_SUCCESS; +} + +result +_ExpandableListImpl::RefreshSubItem(int mainIndex, int subIndex) +{ + SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex); + SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex = %d", subIndex); + + int topItemIndex = -1; + int bottomItemIndex = -1; + int groupItemIndex = -1; + + GetCore().GetTopDrawnItemIndex(groupItemIndex, topItemIndex); + GetCore().GetBottomDrawnItemIndex(groupItemIndex, bottomItemIndex); + + SysTryReturnResult(NID_UI_CTRL, (subIndex >= topItemIndex && subIndex <= bottomItemIndex), E_INVALID_OPERATION, + "Index should be within drawn item range %d.", subIndex); + + result r = E_SUCCESS; + + CustomListItem* pCustomListItem = GetCustomListItemAt(mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, pCustomListItem, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d) subIndex(%d).", mainIndex, subIndex); + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = pCustomListItem; + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "A system error has occurred. Failed to refresh an item."); + + _TableViewItemData* pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData; + SysTryReturn(NID_UI_CTRL, pTableViewItemData, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d) subIndex(%d).", mainIndex, subIndex); + + pTableViewItemData->Invalidate(true); + + return E_SUCCESS; +} + +int +_ExpandableListImpl::GetCheckedItemCount(int mainIndex) +{ + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), 0, E_INVALID_ARG, "[E_INVALID_ARG] The groupIndex %d is invalid", mainIndex); + + _TableViewGroupItemData* pGroupItem = GetTableViewGroupItemAt(mainIndex); + SysTryReturn(NID_UI_CTRL, pGroupItem, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get GroupItem at %d index.", mainIndex); + + int checkedCount = 0; + int subItemCount = GetSubItemCountAt(mainIndex); + + for (int itemCount = 0; itemCount < subItemCount; itemCount++) + { + if (IsSubItemChecked(mainIndex, itemCount) == true) + { + checkedCount++; + } + } + + return checkedCount; +} + +bool +_ExpandableListImpl::IsItemExpanded(int mainIndex) const +{ + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex); + + if (GetCore().GetFirstDrawnFlag()) + { + Boolean* pIsExpanded = dynamic_cast(const_cast(__groupExpandStateList.GetAt(mainIndex))); + SysTryReturn(NID_UI_CTRL, pIsExpanded, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get expanded state at index(%d).", mainIndex); + + return pIsExpanded->ToBool(); + + } + + return (GetCore().IsGroupExpanded(mainIndex)); +} + +void +_ExpandableListImpl::OnTableViewItemStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + return; +} + +void +_ExpandableListImpl::OnTableViewContextItemActivationStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_ExpandableListImpl::OnTableViewItemReordered(_TableView& tableView, int itemIndexFrom, int itemIndexTo) +{ + return; +} + +void +_ExpandableListImpl::OnGroupedTableViewGroupItemStateChanged(_TableView& tableView, int groupIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex); + + CustomListItemStatus customListItemStatus = CUSTOM_LIST_ITEM_STATUS_NORMAL; + ItemStatus itemStatus = ITEM_HIGHLIGHTED; + + switch (status) + { + case TABLE_VIEW_ITEM_STATUS_SELECTED: + itemStatus = ITEM_SELECTED; + customListItemStatus = CUSTOM_LIST_ITEM_STATUS_SELECTED; + break; + case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED: + itemStatus = ITEM_HIGHLIGHTED; + customListItemStatus = CUSTOM_LIST_ITEM_STATUS_FOCUSED; + break; + case TABLE_VIEW_ITEM_STATUS_CHECKED: + itemStatus = ITEM_CHECKED; + break; + case TABLE_VIEW_ITEM_STATUS_UNCHECKED: + itemStatus = ITEM_UNCHECKED; + break; + default: + SetLastResult(E_SYSTEM); + return; + } + + LinkedList* pElements = &pCustomListItem->__pCustomListItemImpl->elements; + _ElementBaseModel* pElementBase = null; + + for (int i = 0; i < pElements->GetCount(); i++) + { + pElementBase = dynamic_cast<_ElementBaseModel*>(pElements->GetAt(i)); + SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get valid element at index %d.", i); + + if (pElementBase->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX) + { + pElementBase->HandleElementEvent(customListItemStatus); + } + } + + if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL)) + { + bool isChecked = false; + isChecked = IsItemChecked(groupIndex); + + if (isChecked) + { + itemStatus = ITEM_UNCHECKED; + } + else + { + itemStatus = ITEM_CHECKED; + } + + SetItemChecked(groupIndex, !isChecked); + } + + ProcessItemStateChange(groupIndex, -1, itemStatus); + + return; +} + + +void +_ExpandableListImpl::OnGroupedTableViewItemStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d), itemIndex(%d).", groupIndex, itemIndex); + + CustomListItemStatus customListItemStatus = CUSTOM_LIST_ITEM_STATUS_NORMAL; + ItemStatus itemStatus = ITEM_HIGHLIGHTED; + result r = E_SUCCESS; + + switch (status) + { + case TABLE_VIEW_ITEM_STATUS_SELECTED: + itemStatus = ITEM_SELECTED; + customListItemStatus = CUSTOM_LIST_ITEM_STATUS_SELECTED; + break; + case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED: + itemStatus = ITEM_HIGHLIGHTED; + customListItemStatus = CUSTOM_LIST_ITEM_STATUS_FOCUSED; + break; + case TABLE_VIEW_ITEM_STATUS_CHECKED: + itemStatus = ITEM_CHECKED; + break; + case TABLE_VIEW_ITEM_STATUS_UNCHECKED: + itemStatus = ITEM_UNCHECKED; + break; + default: + SetLastResult(E_SYSTEM); + break; + } + + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[E_SYSTEM] A system error has occurred. ListItemStatus is invalid"); + + LinkedList* pElements = &pCustomListItem->__pCustomListItemImpl->elements; + _ElementBaseModel* pElementBase = null; + + for (int i = 0; i < pElements->GetCount(); i++) + { + pElementBase = dynamic_cast<_ElementBaseModel*>(pElements->GetAt(i)); + SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "Invalid element."); + + if (pElementBase->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX) + { + pElementBase->HandleElementEvent(customListItemStatus); + } + } + + if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL)) + { + bool isChecked = false; + isChecked = IsSubItemChecked(groupIndex, itemIndex); + + if (isChecked) + { + itemStatus = ITEM_UNCHECKED; + } + else + { + itemStatus = ITEM_CHECKED; + } + + SetSubItemChecked(groupIndex, itemIndex, !isChecked); + } + + ProcessItemStateChange(groupIndex, itemIndex, itemStatus); + + return; +} + +void +_ExpandableListImpl::OnGroupedTableViewContextItemActivationStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_ExpandableListImpl::OnGroupedTableViewItemReordered(_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo) +{ + return; +} + +void +_ExpandableListImpl::OnSectionTableViewItemStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + return; +} + +void +_ExpandableListImpl::OnSectionTableViewContextItemActivationStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_ExpandableListImpl::OnTableViewItemSwept(_TableView& tableView, int groupIndex, int itemIndex, TableViewSweepDirection direction) +{ + return; +} + +void +_ExpandableListImpl::OnTouchPressed (const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + Label* pArrowLabel = dynamic_cast(const_cast(&source)); + + if (pArrowLabel) + { + _TableViewGroupItemData* pTableViewGroupItemData = dynamic_cast<_TableViewGroupItemData*>(pArrowLabel->GetParent()); + SysTryReturnVoidResult(NID_UI_CTRL, (pTableViewGroupItemData != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get arrow icon."); + + if (GetCore().IsGroupExpanded(pTableViewGroupItemData->groupIndex)) + { + GetCore().CollapseGroup(pTableViewGroupItemData->groupIndex); + pArrowLabel->SetBackgroundBitmap(*__pOpenedImage); + } + else + { + GetCore().ExpandGroup(pTableViewGroupItemData->groupIndex); + pArrowLabel->SetBackgroundBitmap(*__pClosedImage); + } + + pArrowLabel->Invalidate(true); + } + else + { + _ListBaseImpl::OnTouchPressed(source, currentPosition, touchInfo); + } + return; +} + +void +_ExpandableListImpl::ProcessItemStateChange(int mainIndex, int subIndex, int elementId, ItemStatus itemStatus) +{ + int itemId = -1; + if (subIndex == -1 ) + { + itemId = GetItemIdAt(mainIndex); + } + else + { + itemId = GetSubItemIdAt(mainIndex, subIndex); + } + + _ListListener* pListenerList = null; + IExpandableItemEventListener* pEventListener = null; + + for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++) + { + pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get ListListener"); + + pEventListener = dynamic_cast(pListenerList->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get EventListener"); + + pEventListener->OnItemStateChanged(GetPublic(), mainIndex, subIndex, itemId, elementId, itemStatus); + } + SetLastResult(E_SUCCESS); + return; +} + +void +_ExpandableListImpl::ProcessItemStateChange(int mainIndex, int subIndex, ItemStatus itemStatus) +{ + int itemId = -1; + if (subIndex == -1 ) + { + itemId = GetItemIdAt(mainIndex); + } + else + { + itemId = GetSubItemIdAt(mainIndex, subIndex); + } + + _ListListener* pListenerList = null; + IExpandableItemEventListener* pEventListener = null; + + for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++) + { + pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get ListListener"); + + pEventListener = dynamic_cast(pListenerList->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get EventListener"); + + pEventListener->OnItemStateChanged(GetPublic(), mainIndex, subIndex, itemId, itemStatus); + } + SetLastResult(E_SUCCESS); + return; +} + +void +_ExpandableListImpl::OnDraw(void) +{ + if (GetCore().GetFirstDrawnFlag()) + { + _ListBaseImpl::OnDraw(); + + int mainItemCount = GetGroupCount(); + + for (int mainIndex = 0; mainIndex < mainItemCount; mainIndex++) + { + Boolean* pIsExpanded = dynamic_cast(__groupExpandStateList.GetAt(mainIndex)); + SysTryReturnVoidResult(NID_UI_CTRL, pIsExpanded, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get expanded state at index(%d).", mainIndex); + + if (!pIsExpanded->ToBool()) + { + SetItemExpanded(mainIndex, false); + } + } + + GetCore().UpdateTableView(); + } + else + { + _ListBaseImpl::OnDraw(); + } + + return; +} + +void +_ExpandableListImpl::DeleteExpandStateFlag(Object* pObj) +{ + Boolean* pExpanded = null; + pExpanded = dynamic_cast(pObj); + delete pExpanded; + return; +} + +class _ExpandableListMaker + : public _UiBuilderControlMaker +{ +public: + _ExpandableListMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_ExpandableListMaker(){}; + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _ExpandableListMaker* pExpandableListMaker = new (std::nothrow) _ExpandableListMaker(uibuilder); + + return pExpandableListMaker; + }; +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + ExpandableList* pExpandableList = null; + Rectangle rect; + Rectangle rectMin; + Dimension dimMin; + CustomListStyle style = CUSTOM_LIST_STYLE_NORMAL; + Tizen::Base::String elementString; + bool isItemDivider = true; + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pExpandableList = new (std::nothrow) ExpandableList(); + if (pExpandableList == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + Tizen::Base::String styleString; + styleString = pControlProperty->GetStyle(); + + if (styleString.Equals(L"CUSTOM_LIST_STYLE_NORMAL", false)) + { + style = CUSTOM_LIST_STYLE_NORMAL; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO", false)) + { + style = CUSTOM_LIST_STYLE_RADIO; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK", false)) + { + style = CUSTOM_LIST_STYLE_MARK; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF", false)) + { + style = CUSTOM_LIST_STYLE_ONOFF; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER; + } + else + { + style = CUSTOM_LIST_STYLE_NORMAL; + } + + if (pControl->GetElement(L"itemDivider", elementString)) + { + if (elementString.Equals(L"true", false)) + { + isItemDivider = true; + } + else + { + isItemDivider = false; + } + } + + r = pExpandableList->Construct(rect, style, isItemDivider); + if (r != E_SUCCESS) + { + delete pExpandableList; + return null; + } + + if (pControl->GetElement(L"textOfEmptyList", elementString)) + { + pExpandableList->SetTextOfEmptyList(elementString); + } + + if (pControl->GetElement(L"colorOfEmptyListText", elementString)) + { + ConvertStringToColor(elementString, color); + pExpandableList->SetTextColorOfEmptyList(color); + } + GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_PORTRAIT, dimMin); + rectMin = (pControl->GetAttribute(0))->GetRect(); + (pControl->GetAttribute(0))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height); + + GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_LANDSCAPE, dimMin); + rectMin = (pControl->GetAttribute(1))->GetRect(); + (pControl->GetAttribute(1))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height); + + return pExpandableList; + } + +private: +}; + +_ExpandableListRegister::_ExpandableListRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + + if (pUiBuilderControlTableManager) + { + pUiBuilderControlTableManager->RegisterControl(L"ExpandableList", _ExpandableListMaker::GetInstance); + } +} +_ExpandableListRegister::~_ExpandableListRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + + if (pUiBuilderControlTableManager) + { + pUiBuilderControlTableManager->UnregisterControl(L"ExpandableList"); + } +} +static _ExpandableListRegister ExpandableListRegisterToUiBuilder; +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FastScroll.cpp b/src/ui/controls/FUiCtrl_FastScroll.cpp new file mode 100644 index 0000000..b323535 --- /dev/null +++ b/src/ui/controls/FUiCtrl_FastScroll.cpp @@ -0,0 +1,296 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FastScroll.cpp + * @brief This is the implementation file for the _FastScroll class. + */ + +#include +#include "FUiCtrl_FastScroll.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + + +class _FastScrollAccessibilityListener + : public _IAccessibilityListener +{ +public: + _FastScrollAccessibilityListener(_FastScroll* pFastScroll) + : __pFastScroll(pFastScroll) + , __onAccessibility(false) + { + } + + virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;} + virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element) + { + if (__onAccessibility) + { + __onAccessibility = false; + __pFastScroll->ReleaseTouchCapture(); + } + else + { + __onAccessibility = true; + __pFastScroll->SetTouchCapture(true); + } + + _AccessibilityContainer* pAccessibilityContainer = __pFastScroll->GetAccessibilityContainer(); + __pFastScroll->AddAccessibilityElement(*pAccessibilityContainer, __onAccessibility); + + return true; + } + + _FastScroll* __pFastScroll; + bool __onAccessibility; +}; + +_FastScroll::_FastScroll(void) + : __pPresenter(null) + , __pAccessibilityListener(null) +{ +} + +_FastScroll::~_FastScroll(void) +{ + _AccessibilityContainer* pAccessibilityContainer = GetAccessibilityContainer(); + if (pAccessibilityContainer && pAccessibilityContainer->IsActivated()) + { + pAccessibilityContainer->RemoveAllElement(); + } + + delete __pPresenter; + __pPresenter = null; + + delete __pAccessibilityListener; + __pAccessibilityListener = null; +} + +_FastScroll* +_FastScroll::CreateFastScrollN(Tizen::Ui::_Control& parentCtrl) +{ + result r = E_SUCCESS; + ClearLastResult(); + + _FastScroll* pFastScroll = new (std::nothrow) _FastScroll(); + SysTryReturn(NID_UI_CTRL, pFastScroll, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pFastScroll->Construct(parentCtrl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pFastScroll; + +CATCH: + delete pFastScroll; + return null; +} + +result +_FastScroll::SetIndex(_FastScrollIndex* pIndex) +{ + return GetPresenter().SetRootIndex(pIndex); +} + +_FastScrollIndex* +_FastScroll::GetIndex(void) const +{ + return GetPresenter().GetRootIndex(); +} + +result +_FastScroll::UpdateIndex(void) +{ + _AccessibilityContainer* pAccessibilityContainer = GetAccessibilityContainer(); + if (pAccessibilityContainer && pAccessibilityContainer->IsActivated()) + { + GetPresenter().AddAccessibilityElement(*pAccessibilityContainer, false); + } + return GetPresenter().UpdateIndex(); +} + +void +_FastScroll::EnableFadeEffect(bool enable) +{ + GetPresenter().EnableFadeEffect(enable); +} + +bool +_FastScroll::IsEnabledFadeEffect(void) const +{ + return GetPresenter().IsEnabledFadeEffect(); +} + +bool +_FastScroll::IsOnFadeEffect(void) const +{ + return GetPresenter().IsOnFadeEffect(); +} + +result +_FastScroll::SetScrollVisibility(bool visibility) +{ + return GetPresenter().SetScrollVisibility(visibility); +} + +bool +_FastScroll::GetScrollVisibility(void) const +{ + return GetPresenter().GetScrollVisibility(); +} + +void +_FastScroll::CancelFadeEffect(void) +{ + GetPresenter().CancelFadeEffect(); +} + +result +_FastScroll::InitializeAccessibility(void) +{ + if (unlikely(!(_AccessibilityManager::IsActivated()))) + { + return E_SUCCESS; + } + + _AccessibilityContainer* pAccessibilityContainer = GetAccessibilityContainer(); + if (pAccessibilityContainer) + { + pAccessibilityContainer->Activate(true); + __pAccessibilityListener = new (std::nothrow) _FastScrollAccessibilityListener(this); + SysTryReturnResult(NID_UI_CTRL, __pAccessibilityListener, E_OUT_OF_MEMORY, "Memory allocation failed."); + + pAccessibilityContainer->AddListener(*__pAccessibilityListener); + } + return E_SUCCESS; +} + +result +_FastScroll::AddAccessibilityElement(const _AccessibilityContainer& control, bool onAccessibility) +{ + return GetPresenter().AddAccessibilityElement(control, onAccessibility); +} + +void +_FastScroll::AddFastScrollEventListener(const Tizen::Ui::Controls::_IUiFastScrollListener& listener) +{ + GetPresenter().AddFastScrollEventListener(listener); +} + +void +_FastScroll::RemoveFastScrollEventListener(const Tizen::Ui::Controls::_IUiFastScrollListener& listener) +{ + GetPresenter().RemoveFastScrollEventListener(listener); +} + +result +_FastScroll::OnAttachedToMainTree(void) +{ + return InitializeAccessibility(); +} + +void +_FastScroll::OnParentBoundsChanged(void) +{ + GetPresenter().OnParentBoundsChanged(); +} + +void +_FastScroll::OnDraw(void) +{ + GetPresenter().OnDraw(); +} + +bool +_FastScroll::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return GetPresenter().OnTouchPressed(source, touchinfo); +} + +bool +_FastScroll::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return GetPresenter().OnTouchReleased(source, touchinfo); +} + +bool +_FastScroll::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return GetPresenter().OnTouchMoved(source, touchinfo); +} + +bool +_FastScroll::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return GetPresenter().OnTouchCanceled(source, touchinfo); +} + +void +_FastScroll::OnFontChanged(Font* pFont) +{ + GetPresenter().OnFontChanged(pFont); +} + +void +_FastScroll::OnFontInfoRequested(unsigned long& style, int& size) +{ + GetPresenter().OnFontInfoRequested(style, size); +} + +HitTestResult +_FastScroll::HitTest(const Tizen::Graphics::FloatPoint& point) +{ + return GetPresenter().HitTest(point); +} + +result +_FastScroll::Construct(Tizen::Ui::_Control& parentCtrl) +{ + _FastScrollPresenter* pPresenter = _FastScrollPresenter::CreateFastScrollPresenterN(parentCtrl, *this); + SysTryReturnResult(NID_UI_CTRL, pPresenter, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + SetPresenter(*pPresenter); + + AcquireHandle(); + + return E_SUCCESS; +} + +void +_FastScroll::SetPresenter(_FastScrollPresenter& fastScrollPresenter) +{ + __pPresenter = &fastScrollPresenter; +} + +_FastScrollPresenter& +_FastScroll::GetPresenter(void) const +{ + return *__pPresenter; +} + +} } } // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FastScrollEvent.cpp b/src/ui/controls/FUiCtrl_FastScrollEvent.cpp new file mode 100644 index 0000000..5924ba8 --- /dev/null +++ b/src/ui/controls/FUiCtrl_FastScrollEvent.cpp @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_FastScrollEvent.cpp +* @brief This is the implementation for the _FastScrollEvent class. +*/ + +// includes +#include +#include +#include +#include "FUiCtrl_FastScrollEvent.h" +#include "FUiCtrl_FastScrollEventArg.h" + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +const wchar_t* const FAST_SCROLL_SEARCH_ICON_INDEX_STRING = L"[SEARCH_ICON_INDEX]"; + +//////////////////////////////////////////////////////////////////////////////// +/// __ExpandableItemEvent class Lifecycle + +_FastScrollEvent::_FastScrollEvent(void) + : __pSource(null) +{ + // nothing +} + +_FastScrollEvent::~_FastScrollEvent(void) +{ + // nothing +} + +result +_FastScrollEvent::Construct(const Tizen::Ui::Control& source) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = const_cast (&source); + } + + return r; +} + + +//////////////////////////////////////////////////////////////////////////////// +/// __WindowEvent class Accessor + +const Tizen::Ui::Control* +_FastScrollEvent::GetSource(void) const +{ + return __pSource; +} + +//////////////////////////////////////////////////////////////////////////////// +/// __ExpandableItemEvent class Operation + +void +_FastScrollEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to IFastScrollListener + IFastScrollListener* pFastScrollListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI, pFastScrollListener, E_INVALID_ARG, "[E_INVALID_ARG] Listener type is invalid."); + + // cast to __FastScrollEventArg + _FastScrollEventArg* pArg = (_FastScrollEventArg*) const_cast (&arg); + SysTryReturnVoidResult(NID_UI, pArg, E_INVALID_ARG, "[E_INVALID_ARG] Event argument type is invalid."); + + Tizen::Base::String index = pArg->GetIndex(); + pFastScrollListener->OnFastScrollIndexSelected(*pArg->GetSource(), index); +} +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FastScrollEventArg.cpp b/src/ui/controls/FUiCtrl_FastScrollEventArg.cpp new file mode 100644 index 0000000..6d014fd --- /dev/null +++ b/src/ui/controls/FUiCtrl_FastScrollEventArg.cpp @@ -0,0 +1,62 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_FastScrollEventArg.cpp +* @brief This is the implementation for the _FastScrollEventArg class. +*/ + +// includes +#include "FUiCtrl_FastScrollEventArg.h" + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +//////////////////////////////////////////////////////////////////////////////// +/// __FastScrollEventArg class Lifecycle + +_FastScrollEventArg::_FastScrollEventArg(const Tizen::Ui::Control& source, Tizen::Base::String& index) + : __pSource(const_cast (&source)) + , __index(index) +{ + // nothing +} + +_FastScrollEventArg::~_FastScrollEventArg(void) +{ + // nothing +} + +//////////////////////////////////////////////////////////////////////////////// +/// __ExpandableItemEventArg class Access + +Control* +_FastScrollEventArg::GetSource(void) +{ + return __pSource; +} + +Tizen::Base::String +_FastScrollEventArg::GetIndex(void) +{ + return Tizen::Base::String(__index); +} +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FastScrollIndex.cpp b/src/ui/controls/FUiCtrl_FastScrollIndex.cpp new file mode 100644 index 0000000..26c2996 --- /dev/null +++ b/src/ui/controls/FUiCtrl_FastScrollIndex.cpp @@ -0,0 +1,523 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FastScrollIndex.cpp + * @brief This is the implementation file for the _FastScrollIndex class. + */ + +#include +#include +#include "FUiCtrl_FastScrollIndex.h" +#include "FGrp_BitmapImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_FastScrollIndex::_FastScrollIndex(void) + : __pImage(null) + , __pText(null) + , __pParentIndex(null) + , __pIndexObserver(null) + , __omitted(false) + , __indexType(FAST_SCROLL_INDEX_TYPE_NORMAL) +{ +} + +_FastScrollIndex::~_FastScrollIndex(void) +{ + if (__pIndexObserver) + { + __pIndexObserver->OnIndexDeleted(*this); + } + + if (__pParentIndex) + { + __pParentIndex->RemoveChildIndex(this, false); + __pParentIndex = null; + } + + RemoveChildren(true); + + delete __pImage; + __pImage = null; + + delete __pText; + __pText = null; +} + + +_FastScrollIndex* +_FastScrollIndex::CreateFastScrollIndexN(void) +{ + _FastScrollIndex* pIndex = new (std::nothrow) _FastScrollIndex(); + SysTryReturn(NID_UI_CTRL, pIndex, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pIndex->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return pIndex; + +CATCH: + delete pIndex; + + return null; +} + +result +_FastScrollIndex::SetIndexText(Tizen::Base::String* pText) +{ + delete __pText; + __pText = null; + + if (pText) + { + __pText = new (std::nothrow) Tizen::Base::String(*pText); + SysTryReturnResult(NID_UI_CTRL, __pText, E_OUT_OF_MEMORY, "Memory allocation failed."); + } + + // send the action to _IFastScrollIndexObserver + if (__pIndexObserver) + { + __pIndexObserver->OnIndexDataUpdated(*this); + } + + return E_SUCCESS; +} + +Tizen::Base::String* +_FastScrollIndex::GetIndexText(void) const +{ + return __pText; +} + +result +_FastScrollIndex::SetIndexImage(Tizen::Graphics::Bitmap* pImage) +{ + delete __pImage; + __pImage = null; + + if (pImage) + { + __pImage = Tizen::Graphics::_BitmapImpl::CloneN(*pImage); + } + + // send the action to _IFastScrollIndexObserver + if (__pIndexObserver) + { + __pIndexObserver->OnIndexDataUpdated(*this); + } + + return E_SUCCESS; +} + +Tizen::Graphics::Bitmap* +_FastScrollIndex::GetIndexImage(void) const +{ + return __pImage; +} + +void +_FastScrollIndex::SetIndexObserver(_IFastScrollIndexObserver* pIndexListener) +{ + __pIndexObserver = pIndexListener; +} + +_IFastScrollIndexObserver* +_FastScrollIndex::GetIndexObserver(void) const +{ + return __pIndexObserver; +} + +result +_FastScrollIndex::SetOmissionIndex(int indexCountMax) +{ + int childCount = GetChildCount(); + int maxOmissionSlot = (indexCountMax - 1) / 2; + int omissionCount = childCount - indexCountMax; + int omittedNum = (omissionCount / maxOmissionSlot) + 1; + + int additionalOmittedNum = (omissionCount % maxOmissionSlot); + int additionalOmissionStartIndex = ((maxOmissionSlot - additionalOmittedNum) / 2); + int i = 0; + int j = 0; + result r = E_SUCCESS; + + Tizen::Base::String omissionText(L"."); + + if ((indexCountMax % 2) == 0) + { + r = AddChildIndex(GetChildIndex(i), true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add child index."); + i++; + j++; + } + + while (i < childCount) + { + r = AddChildIndex(GetChildIndex(i), true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add child index."); + + i++; + j++; + + if (i >= childCount) + { + break; + } + + int omittedCount = omittedNum; + if ((additionalOmissionStartIndex < 0) && (additionalOmittedNum > 0)) + { + omittedCount += 1; + additionalOmittedNum--; + } + + if (omittedCount < 2) + { + if ((i % 2) > 0) + { + additionalOmissionStartIndex--; + } + continue; + } + + r = AddChildIndex(&omissionText, null, true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add child index."); + + _FastScrollIndex* pOmissionBaseIndex = GetChildIndex(j, true); + SysTryReturnResult(NID_UI_CTRL, pOmissionBaseIndex, GetLastResult(), "Failed to get the child index."); + pOmissionBaseIndex->SetOmitted(true); + j++; + additionalOmissionStartIndex--; + + for (int k = 0; k < omittedCount; k++) + { + pOmissionBaseIndex->AddOmissionChildIndex(GetChildIndex(i + k)); + } + i += omittedCount; + } + SetIndexType(FAST_SCROLL_INDEX_TYPE_OMISSION); + + return r; +} + +result +_FastScrollIndex::AddChildIndex(Tizen::Base::String* pText, Tizen::Graphics::Bitmap* pImage, bool omitted) +{ + _FastScrollIndex* pNewIndex = _FastScrollIndex::CreateFastScrollIndexN(); + SysTryReturnResult(NID_UI_CTRL, pNewIndex, GetLastResult(), "Failed to create _FastScrollIndex."); + + result r = pNewIndex->SetIndexText(pText); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set text.", GetErrorMessage(r)); + + pNewIndex->SetIndexImage(pImage); + + return AddChildIndex(pNewIndex, omitted); + +CATCH: + delete pNewIndex; + + return r; +} + +result +_FastScrollIndex::AddChildIndex(_FastScrollIndex* pChildIndex, bool omitted) +{ + return AddChildIndex(GetChildCount(omitted), pChildIndex, omitted); +} + +result +_FastScrollIndex::AddChildIndex(int childOrder, Tizen::Base::String* pText, Tizen::Graphics::Bitmap* pImage, bool omitted) +{ + _FastScrollIndex* pNewIndex = _FastScrollIndex::CreateFastScrollIndexN(); + SysTryReturnResult(NID_UI_CTRL, pNewIndex, GetLastResult(), "Failed to create _FastScrollIndex."); + + result r = pNewIndex->SetIndexText(pText); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set text.", GetErrorMessage(r)); + + pNewIndex->SetIndexImage(pImage); + + return AddChildIndex(childOrder, pNewIndex, omitted); + +CATCH: + delete pNewIndex; + + return r; +} + +result +_FastScrollIndex::AddChildIndex(int childOrder, _FastScrollIndex* pChildIndex, bool omitted) +{ + SysTryReturnResult(NID_UI_CTRL, pChildIndex, E_INVALID_ARG, "Invalid argument is used. pChildIndex is null."); + + Tizen::Base::Collection::ArrayList* pList = &__childIndexList; + if (omitted) + { + pList = &__childOmittedIndexList; + } + + if (pList->GetCount() <= childOrder) + { + childOrder = GetChildCount(omitted); + } + + pList->InsertAt(*pChildIndex, childOrder); + pChildIndex->SetParentIndex(this); + + if (__pIndexObserver) + { + __pIndexObserver->OnChildIndexAttached(*this, childOrder, *pChildIndex); + } + + return E_SUCCESS; +} + +void +_FastScrollIndex::AddOmissionChildIndex(_FastScrollIndex* pChildIndex) +{ + if (GetOmitted() == false) + { + return; + } + + SysTryReturnVoidResult(NID_UI_CTRL, pChildIndex, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. pChildIndex is null."); + + __childIndexList.InsertAt(*pChildIndex, GetChildCount()); +} + +result +_FastScrollIndex::AddChildTextIndexArray(int childOrder, const wchar_t* pTextIndexArray, int textLenth, int indexCount) +{ + result r = E_SUCCESS; + + Tizen::Base::String* indexText = null; + + wchar_t* pTempChar = new (std::nothrow) wchar_t[textLenth+1]; + SysTryReturnResult(NID_UI_CTRL, pTempChar, E_OUT_OF_MEMORY, "Memory allocation failed."); + + int i = 0; + int j = 0; + for (i = 0; i < indexCount; i++) + { + for (j = 0; j < textLenth; j++) + { + pTempChar[j] = pTextIndexArray[(i*textLenth)+j]; + } + pTempChar[j] = 0; + + indexText = new (std::nothrow) Tizen::Base::String(pTempChar); + SysTryCatch(NID_UI_CTRL, indexText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = AddChildIndex(childOrder+i, indexText, null); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add child index.", GetErrorMessage(r)); + + delete indexText; + indexText = null; + } + + delete[] pTempChar; + return E_SUCCESS; + +CATCH: + delete indexText; + delete[] pTempChar; + + return r; +} + + +result +_FastScrollIndex::RemoveChildIndex(int childOrder, bool destroy) +{ + _FastScrollIndex* pIndex = GetChildIndex(childOrder); + SysTryReturnResult(NID_UI_CTRL, pIndex, GetLastResult(), "Failed to get the child index."); + + return RemoveChildIndex(pIndex, destroy); +} + +result +_FastScrollIndex::RemoveChildIndex(_FastScrollIndex* pChildIndex, bool destroy) +{ + int detachedOrder = 0; + + __childIndexList.IndexOf(*pChildIndex, detachedOrder); + + if (destroy == true) + { + __childIndexList.Remove(*pChildIndex, true); + } + else + { + __childIndexList.Remove(*pChildIndex, false); + pChildIndex->SetParentIndex(null); + } + + if (__pIndexObserver) + { + __pIndexObserver->OnChildIndexDetached(*this, detachedOrder, *pChildIndex); + } + + return E_SUCCESS; +} + +void +_FastScrollIndex::RemoveChildren(bool destroy) +{ + RemoveOmissionChildren(destroy); + + int childrenCount = __childIndexList.GetCount(); + for (int i = childrenCount-1; i >= 0; i--) + { + __childIndexList.RemoveAt(i, destroy); + } +} + +result +_FastScrollIndex::RemoveOmissionChildren(bool destroy) +{ + int childrenCount = __childOmittedIndexList.GetCount(); + + if (childrenCount <= 0) + { + return E_SUCCESS; + } + + for (int i = childrenCount-1; i >= 0; i--) + { + _FastScrollIndex* pIndex = GetChildIndex(i, true); + SysTryReturnResult(NID_UI_CTRL, pIndex, GetLastResult(), "Failed to get the child index."); + + if (pIndex->GetOmitted()) + { + pIndex->RemoveChildren(false); + + __childOmittedIndexList.RemoveAt(i, true); + } + else + { + __childOmittedIndexList.RemoveAt(i, false); + } + } + SetIndexType(FAST_SCROLL_INDEX_TYPE_NORMAL); + + return E_SUCCESS; +} + +_FastScrollIndex* +_FastScrollIndex::GetChildIndex(int childOrder, bool omitted) const +{ + if (omitted && __childOmittedIndexList.GetCount() > 0) + { + Object* pOmittedChildIndex = const_cast (__childOmittedIndexList.GetAt(childOrder)); + SysTryReturn(NID_UI_CTRL, pOmittedChildIndex, null, GetLastResult(), "[%s] Failed to get the child index.", + GetErrorMessage(GetLastResult())); + + return dynamic_cast <_FastScrollIndex*>(pOmittedChildIndex); + } + + Object* pChildIndex = const_cast (__childIndexList.GetAt(childOrder)); + SysTryReturn(NID_UI_CTRL, pChildIndex, null, GetLastResult(), "[%s] Failed to get the child index.", + GetErrorMessage(GetLastResult())); + + return dynamic_cast <_FastScrollIndex*>(pChildIndex); +} + +int +_FastScrollIndex::GetChildOrder(const _FastScrollIndex* pChildIndex, bool omitted) const +{ + int childIndex = -1; + if (omitted && __childOmittedIndexList.GetCount() > 0) + { + __childOmittedIndexList.IndexOf(*pChildIndex, childIndex); + } + else + { + __childIndexList.IndexOf(*pChildIndex, childIndex); + } + return childIndex; +} + +int +_FastScrollIndex::GetChildCount(bool omitted) const +{ + if (omitted) + { + return __childOmittedIndexList.GetCount(); + } + + return __childIndexList.GetCount(); +} + +void +_FastScrollIndex::SetParentIndex(_FastScrollIndex* pParent) +{ + __pParentIndex = pParent; +} + +_FastScrollIndex* +_FastScrollIndex::GetParentIndex(void) const +{ + return __pParentIndex; +} + +int +_FastScrollIndex::GetIndexOrder(bool omitted) const +{ + if (__pParentIndex) + { + return __pParentIndex->GetChildOrder(this, omitted); + } + else + { + return -1; + } +} + +void +_FastScrollIndex::SetIndexType(_FastScrollIndexType type) +{ + __indexType = type; +} + +_FastScrollIndexType +_FastScrollIndex::GetIndexType(void) const +{ + return __indexType; +} + +void +_FastScrollIndex::SetOmitted(bool omitted) +{ + __omitted = omitted; +} + +bool +_FastScrollIndex::GetOmitted(void) const +{ + return __omitted; +} + +result +_FastScrollIndex::Construct(void) +{ + return E_SUCCESS; +} + +} } } // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FastScrollIndexNode.cpp b/src/ui/controls/FUiCtrl_FastScrollIndexNode.cpp new file mode 100644 index 0000000..1895d8e --- /dev/null +++ b/src/ui/controls/FUiCtrl_FastScrollIndexNode.cpp @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FastScrollIndexNode.cpp + * @brief This is the implementation file for the _FastScrollIndexNode class. + */ + +#if 0 + +#include +#include +#include "FUiCtrl_FastScrollIndexNode.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +// Lifecycle +_FastScrollIndexNode::_FastScrollIndexNode(int indexLength) + : __indexLength(indexLength) + , __indexWidth(0) + , __indexHeight(0) + , __indexOmitted(false) + , __indexOmitPriority(true) + , __indexText(null) +{ +} + +_FastScrollIndexNode::~_FastScrollIndexNode(void) +{ +} + +void +_FastScrollIndexNode::SetIndexNodeWidth(int indexWdith) +{ + __indexWidth = indexWdith; +} + +int +_FastScrollIndexNode::GetIndexNodeWidth(void) const +{ + return __indexWidth; +} + +void +_FastScrollIndexNode::SetIndexNodeHeight(int indexHeight) +{ + __indexHeight = indexHeight; +} + +int +_FastScrollIndexNode::GetIndexNodeHeight(void) const +{ + return __indexHeight; +} + +void +_FastScrollIndexNode::SetIndexNodeOmitted(bool indexOmitted) +{ + __indexOmitted = indexOmitted; +} + +bool +_FastScrollIndexNode::GetIndexNodeOmitted(void) const +{ + return __indexOmitted; +} + +void +_FastScrollIndexNode::SetIndexNodeText(wchar_t* indexText) +{ + __indexText.clear(); + + for (int i = 0; i < __indexLength; i++) + { + __indexText.push_back(*(indexText + i)); + } +} + +void +_FastScrollIndexNode::GetIndexNodeText(wchar_t* indexText) +{ + for (int i = 0; i < (int) __indexText.size(); i++) + { + *(indexText + i) = __indexText[i]; + } +} + +int +_FastScrollIndexNode::GetIndexNodeLength(void) const +{ + return __indexText.size(); +} + +} } } // Tizen::Ui::Controls +#endif diff --git a/src/ui/controls/FUiCtrl_FastScrollModel.cpp b/src/ui/controls/FUiCtrl_FastScrollModel.cpp new file mode 100644 index 0000000..65e3517 --- /dev/null +++ b/src/ui/controls/FUiCtrl_FastScrollModel.cpp @@ -0,0 +1,78 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FastScrollModel.cpp + * @brief This is the implementation file for the _FastScrollModel class. + */ + +#include +#include "FUiCtrl_FastScrollModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +_FastScrollModel::_FastScrollModel(void) + : __visibleIndexNodeCount(0) + , __pRootIndex(null) +{ +} + +_FastScrollModel::~_FastScrollModel(void) +{ + delete __pRootIndex; + __pRootIndex = null; +} + +_FastScrollModel* +_FastScrollModel::CreateFastScrollModelN(void) +{ + _FastScrollModel* pModel = new (std::nothrow) _FastScrollModel(); + SysTryReturn(NID_UI_CTRL, pModel, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pModel->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return pModel; + +CATCH: + delete pModel; + + return null; +} + +result +_FastScrollModel::SetRootIndex(_FastScrollIndex* pIndex) +{ + __pRootIndex = pIndex; + + return E_SUCCESS; +} + +_FastScrollIndex* +_FastScrollModel::GetRootIndex(void) const +{ + return __pRootIndex; +} + +result +_FastScrollModel::Construct(void) +{ + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FastScrollPresenter.cpp b/src/ui/controls/FUiCtrl_FastScrollPresenter.cpp new file mode 100644 index 0000000..90233b8 --- /dev/null +++ b/src/ui/controls/FUiCtrl_FastScrollPresenter.cpp @@ -0,0 +1,3154 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FastScrollPresenter.cpp + * @brief This is the implementation file for the _FastScrollPresenter class. + */ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "FGrp_BitmapImpl.h" +#include "FGrp_TextTextObject.h" +#include +#include "FUiAnim_VisualElement.h" +#include "FUi_Control.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_IFastScrollListener.h" +#include "FUiCtrl_UiFastScrollEvent.h" +#include "FUiCtrl_UiFastScrollEventArg.h" +#include "FUiCtrl_FastScroll.h" +#include "FUiCtrl_FastScrollPresenter.h" +#include "FUiCtrl_FastScrollModel.h" +#include "FUiCtrl_FastScrollIndex.h" + +#include "FUiAnim_MatrixUtil.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics::_Text; + +namespace +{ +const float FASTSCROLL_OPACITY_ON = 1.0f; +const float FASTSCROLL_OPACITY_SELECTEDBG_DIM = 0.5f; +const float FASTSCROLL_OPACITY_LIGHT_DIM = 0.3f; +const float FASTSCROLL_OPACITY_OFF = 0.0f; +const int FASTSCROLL_POPUPINDEX_COUNT = 3; +} + +namespace Tizen { namespace Ui { namespace Controls +{ + +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + + +_FastScrollViewConfig::_FastScrollViewConfig(void) + : __indexBgColor(Color::GetColor(COLOR_ID_BLACK)) + , __indexHighlightColor(Color::GetColor(COLOR_ID_BLACK)) + , __indexLeftLineColor(Color::GetColor(COLOR_ID_BLACK)) + , __indexTextColor(Color::GetColor(COLOR_ID_BLACK)) + , __indexSeparatorColor(Color::GetColor(COLOR_ID_BLACK)) + , __selectedIndexBgColor(Color::GetColor(COLOR_ID_BLACK)) + , __selectedIndexTextColor(Color::GetColor(COLOR_ID_BLACK)) + , __selectedIndexOutlineColor(Color::GetColor(COLOR_ID_BLACK)) + , __popupBgColor(Color::GetColor(COLOR_ID_BLACK)) + , __popupTextColor(Color::GetColor(COLOR_ID_BLACK)) + , __indexSizeMin(0, 0) + , __popupSize(0, 0) + , __indexMarginRight(0) + , __indexMarginTop(0) + , __indexGap(0) + , __indexLeftLineThickness(0) + , __indexTextSize(0) + , __indexSeparatorThickness(0) + , __selectedIndexMarginRight(0) + , __selectedIndexHeight(0) + , __popupWidthIncrement(0) + , __popupTextSize(0) + , __popupShadowRight(0) + , __popupShadowBottom(0) + , __pIndexBgBitmap(null) + , __pSelectedIndexBgBitmap(null) + , __pSelectedIndexOutlineBitmap(null) + , __pPopupBgBitmap(null) + , __pPopupBgEffectBitmap(null) + , __pFont(null) +{ +} + +_FastScrollViewConfig::~_FastScrollViewConfig(void) +{ + ReleaseResources(); +} + +_FastScrollViewConfig* +_FastScrollViewConfig::CreateFastScrollViewConfigN(_ControlOrientation orientation) +{ + _FastScrollViewConfig* pConfig = new (std::nothrow) _FastScrollViewConfig(); + SysTryReturn(NID_UI_CTRL, pConfig, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pConfig->Construct(orientation); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return pConfig; + +CATCH: + delete pConfig; + + return null; +} + +result +_FastScrollViewConfig::ReloadConfig(_ControlOrientation orientation) +{ + result r = E_SUCCESS; + + // release allocated resources. + ReleaseResources(); + + // load bitmap resources + r = GET_BITMAP_CONFIG_N(FASTSCROLL::INDEX_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pIndexBgBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image."); + + r = GET_BITMAP_CONFIG_N(FASTSCROLL::SELECTED_INDEX_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pSelectedIndexBgBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image."); + + r = GET_BITMAP_CONFIG_N(FASTSCROLL::SELECTED_INDEX_OUTLINE, BITMAP_PIXEL_FORMAT_ARGB8888, __pSelectedIndexOutlineBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image."); + + r = GET_BITMAP_CONFIG_N(FASTSCROLL::POPUP_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pPopupBgEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image."); + + r = GET_BITMAP_CONFIG_N(FASTSCROLL::POPUP_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pPopupBgBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image."); + + + // load shape configuration + r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __indexSizeMin.width); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __indexSizeMin.height); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __indexMarginTop); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_LEFT_LINE_THICKNESS, _CONTROL_ORIENTATION_PORTRAIT, __indexLeftLineThickness); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __indexTextSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_FIXED_VALUE_CONFIG(FASTSCROLL::INDEX_SEPARATOR_THICKNESS, _CONTROL_ORIENTATION_PORTRAIT, __indexSeparatorThickness); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(FASTSCROLL::SELECTED_INDEX_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __selectedIndexMarginRight); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(FASTSCROLL::SELECTED_INDEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __selectedIndexHeight); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __popupSize.width); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __popupSize.height); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_WIDTH_INCREMENT, _CONTROL_ORIENTATION_PORTRAIT, __popupWidthIncrement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __popupTextSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_RIGHT_SHADOW, _CONTROL_ORIENTATION_PORTRAIT, __popupShadowRight); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_BOTTOM_SHADOW, _CONTROL_ORIENTATION_PORTRAIT, __popupShadowBottom); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + + // load color configuration + r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_BAR, __indexBgColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_LEFT_LINE, __indexLeftLineColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_BAR_TEXT, __indexTextColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_SEPARATOR, __indexSeparatorColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(FASTSCROLL::SELECTED_INDEX_BG, __selectedIndexBgColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(FASTSCROLL::SELECTED_INDEX_TEXT, __selectedIndexTextColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(FASTSCROLL::SELECTED_INDEX_OUTLINE, __selectedIndexOutlineColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(FASTSCROLL::POPUP_BG, __popupBgColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(FASTSCROLL::POPUP_TEXT, __popupTextColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + return E_SUCCESS; + +CATCH: + __indexBgColor = Color::GetColor(COLOR_ID_BLACK); + __indexHighlightColor = Color::GetColor(COLOR_ID_BLACK); + __indexLeftLineColor = Color::GetColor(COLOR_ID_BLACK); + __indexTextColor = Color::GetColor(COLOR_ID_BLACK); + __indexSeparatorColor = Color::GetColor(COLOR_ID_BLACK); + __selectedIndexBgColor = Color::GetColor(COLOR_ID_BLACK); + __selectedIndexTextColor = Color::GetColor(COLOR_ID_BLACK); + __selectedIndexOutlineColor = Color::GetColor(COLOR_ID_BLACK); + __popupBgColor = Color::GetColor(COLOR_ID_BLACK); + __popupTextColor = Color::GetColor(COLOR_ID_BLACK); + + __indexSizeMin.SetSize(0, 0); + __popupSize.SetSize(0, 0); + + __indexMarginRight = 0; + __indexMarginTop = 0; + __indexGap = 0; + __indexLeftLineThickness = 0; + __indexTextSize = 0; + __indexSeparatorThickness = 0; + __selectedIndexMarginRight = 0; + __selectedIndexHeight = 0; + __popupWidthIncrement = 0; + __popupTextSize = 0; + + ReleaseResources(); + + return E_SYSTEM; +} + +void +_FastScrollViewConfig::ReleaseResources(void) +{ + delete __pIndexBgBitmap; + delete __pSelectedIndexBgBitmap; + delete __pSelectedIndexOutlineBitmap; + delete __pPopupBgBitmap; + delete __pPopupBgEffectBitmap; + + __pIndexBgBitmap = null; + __pSelectedIndexBgBitmap = null; + __pSelectedIndexOutlineBitmap = null; + __pPopupBgBitmap = null; + __pPopupBgEffectBitmap = null; +} + +result +_FastScrollViewConfig::Construct(_ControlOrientation orientation) +{ + return ReloadConfig(orientation); +} + + +_FastScrollIndexView::_FastScrollIndexView(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig) + : __parentVe(parentVe) + , __viewConfig(viewConfig) + , __pBaseIndex(null) + , __pSelectedIndex(null) + , __pSelectedIndexInOmittedIndex(null) + , __pFormerIndex(null) + , __pBaseIndexVe(null) + , __pSelectedBgVe(null) + , __pSelectedIndexVe(null) + , __needUpdateBaseIndex(false) + , __needUpdateSelectedIndex(false) + , __needDestroySelf(false) +{ +} + +_FastScrollIndexView::~_FastScrollIndexView(void) +{ + if (__pSelectedIndexVe) + { + __pSelectedIndexVe->RemoveAllAnimations(); + __pSelectedIndexVe->SetAnimationProvider(null); + + __pSelectedIndexVe->Destroy(); + __pSelectedIndexVe = null; + } + + if (__pSelectedBgVe) + { + __pSelectedBgVe->RemoveAllAnimations(); + __pSelectedBgVe->SetAnimationProvider(null); + + __pSelectedBgVe->Destroy(); + __pSelectedBgVe = null; + } + + if (__pBaseIndexVe) + { + __pBaseIndexVe->RemoveAllAnimations(); + __pBaseIndexVe->SetAnimationProvider(null); + + __pBaseIndexVe->Destroy(); + __pBaseIndexVe = null; + } +} + +_FastScrollIndexView* +_FastScrollIndexView::CreateFastScrollIndexViewN(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig) +{ + _FastScrollIndexView* pIndexView = new (std::nothrow) _FastScrollIndexView(parentVe, viewConfig); + SysTryReturn(NID_UI_CTRL, pIndexView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pIndexView->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return pIndexView; + +CATCH: + delete pIndexView; + + return null; +} + +result +_FastScrollIndexView::FadeOutAndDestroy(void) +{ + __needDestroySelf = true; + if (__pSelectedIndexVe) + { + __pSelectedIndexVe->RemoveAllAnimations(); + } + + if (__pSelectedBgVe) + { + __pSelectedBgVe->RemoveAllAnimations(); + } + + return SetIndexVisibility(false); +} + +result +_FastScrollIndexView::SetBaseIndex(_FastScrollIndex* pIndex) +{ + __pBaseIndex = pIndex; + + result r = UpdateIndex(false); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view."); + + return E_SUCCESS; +} + +_FastScrollIndex* +_FastScrollIndexView::GetBaseIndex(void) const +{ + return __pBaseIndex; +} + +result +_FastScrollIndexView::SetIndexBounds(const Rectangle& indexBounds) +{ + SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null."); + + FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height); + + __pBaseIndexVe->SetBounds(veBounds); + + __needUpdateBaseIndex = true; + + veBounds.x = 0; + veBounds.y = 0; + __pSelectedIndexVe->SetBounds(veBounds); + + __needUpdateSelectedIndex = true; + + return E_SUCCESS; +} + +Rectangle +_FastScrollIndexView::GetIndexBounds(void) const +{ + FloatRectangle veBounds = __pBaseIndexVe->GetBounds(); + return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height); +} + +result +_FastScrollIndexView::SetSelectedBgBounds(const Rectangle& indexBounds) +{ + SysTryReturnResult(NID_UI_CTRL, __pSelectedBgVe, E_INVALID_STATE, "__pSelectedBgVe must not be null."); + + FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height); + __pSelectedBgVe->SetBounds(veBounds); + + return E_SUCCESS; +} + +Rectangle +_FastScrollIndexView::GetSelectedBgBounds(void) const +{ + SysTryReturn(NID_UI_CTRL, __pSelectedBgVe, Rectangle(0, 0, 0, 0), E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedBgVe must not be null."); + + FloatRectangle veBounds = __pSelectedBgVe->GetBounds(); + return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height); +} + +result +_FastScrollIndexView::SetSelectedIndexBounds(const Rectangle& indexBounds) +{ + SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null."); + + FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height); + __pSelectedIndexVe->SetBounds(veBounds); + + return E_SUCCESS; +} + +Rectangle +_FastScrollIndexView::GetSelectedIndexBounds(void) const +{ + SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, Rectangle(0, 0, 0, 0), E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndexVe must not be null."); + + FloatRectangle veBounds = __pSelectedIndexVe->GetBounds(); + return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height); +} + +_FastScrollIndex* +_FastScrollIndexView::GetIndexAtPoint(const Point& point) const +{ + SysTryReturn(NID_UI_CTRL, __pBaseIndex, null, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null."); + + int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType()); + SysTryReturn(NID_UI_CTRL, childCount > 0, null, E_INVALID_STATE, "[E_INVALID_STATE] The index have no children."); + + _FastScrollIndex* pChildIndex = null; + + Rectangle bounds = GetIndexBounds(); + if (bounds.Contains(point) == true) + { + int touchY = point.y - bounds.y - __viewConfig.__indexMarginTop; + int indexHeight = GetIndexHeight(); + int indexOrder = 0; + + if ((touchY != 0) && (indexHeight != 0)) + { + indexOrder = touchY / indexHeight; + } + + pChildIndex = __pBaseIndex->GetChildIndex(indexOrder, true); + SysTryReturn(NID_UI_CTRL, pChildIndex, null, GetLastResult(), "[%s] Failed to get the child index.", + GetErrorMessage(GetLastResult())); + } + + SetLastResult(E_SUCCESS); + return pChildIndex; +} + +_FastScrollIndex* +_FastScrollIndexView::GetOmissionIndexAtPoint(_FastScrollIndex* pIndex, const Point& point) const +{ + Rectangle bounds = GetIndexBounds(); + int touchY = point.y - bounds.y - __viewConfig.__indexMarginTop - (pIndex->GetIndexOrder(true) * GetIndexHeight()); + int indexHeight = GetIndexHeight() / pIndex->GetChildCount(); + int omissionIndexOrder = 0; + + if ((touchY != 0) && (indexHeight != 0)) + { + omissionIndexOrder = touchY / indexHeight; + } + + _FastScrollIndex* pChildIndex = pIndex->GetChildIndex(omissionIndexOrder); + SysTryReturn(NID_UI_CTRL, pChildIndex, null, GetLastResult(), "[%s] Failed to get the child index.", + GetErrorMessage(GetLastResult())); + + SetLastResult(E_SUCCESS); + return pChildIndex; +} + +int +_FastScrollIndexView::GetIndexHeight(void) const +{ + Rectangle bounds = GetIndexBounds(); + int indexHeight = __viewConfig.__indexSizeMin.height; + + if (__pBaseIndex->GetParentIndex() == null) + { + indexHeight = MAX(indexHeight, + ((bounds.height - __viewConfig.__indexMarginTop * 2) / __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType()))); + } + + return indexHeight; +} + +result +_FastScrollIndexView::SelectIndex(int indexOrder) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "__pBaseIndex must not be null."); + + _FastScrollIndex* pIndex = __pBaseIndex->GetChildIndex(indexOrder, true); + SysTryReturnResult(NID_UI_CTRL, pIndex, GetLastResult(), "Failed to get the child index."); + + r = SelectIndex(pIndex, false); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the index."); + + return E_SUCCESS; +} + +result +_FastScrollIndexView::SelectIndex(_FastScrollIndex* pIndex, bool animation) +{ + result r = E_SUCCESS; + + if (__pSelectedIndex == pIndex) + { + return E_SUCCESS; + } + + __pSelectedIndex = pIndex; + + if (__pSelectedIndex) + { + r = SetSelectedBgBounds(CalculateSelectedBg()); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to get the canvas of the Selected Bg ve."); + + if (GetSelectedIndexVisibility() == false) + { + r = SetSelectedIndexVisibility(true, animation); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the Selected Bg ve."); + } + } + else + { + if (GetSelectedIndexVisibility() == true) + { + r = SetSelectedIndexVisibility(false, animation); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the Selected Bg ve."); + } + SetSelectedIndexInOmittedIndex(null); + __pFormerIndex = null; + } + + r = UpdateIndex(false); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view."); + + return E_SUCCESS; +} + +int +_FastScrollIndexView::GetSelectedIndexOrder(void) const +{ + SysTryReturn(NID_UI_CTRL, __pBaseIndex, -1, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null."); + SysTryReturn(NID_UI_CTRL, __pSelectedIndex, -1, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndex must not be null."); + + return __pBaseIndex->GetChildOrder(__pSelectedIndex, true); +} + +_FastScrollIndex* +_FastScrollIndexView::GetSelectedIndex(void) const +{ + return __pSelectedIndex; +} + +void +_FastScrollIndexView::SetSelectedIndexInOmittedIndex(_FastScrollIndex* pIndex) +{ + __pFormerIndex = __pSelectedIndexInOmittedIndex; + __pSelectedIndexInOmittedIndex = pIndex; +} + +_FastScrollIndex* +_FastScrollIndexView::GetSelectedIndexInOmittedIndex(void) const +{ + return __pSelectedIndexInOmittedIndex; +} + +_FastScrollIndex* +_FastScrollIndexView::GetFormerIndex(void) const +{ + return __pFormerIndex; +} + +bool +_FastScrollIndexView::IsOnAnimation(void) const +{ + return false; +} + +void +_FastScrollIndexView::RemoveAllAnimations(void) +{ + __pBaseIndexVe->RemoveAllAnimations(); +} + +result +_FastScrollIndexView::SetIndexVisibility(bool visibility) +{ + result r = E_SUCCESS; + + __pBaseIndexVe->SetImplicitAnimationEnabled(true); + + if (visibility) + { + __pBaseIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON); + } + else + { + __pBaseIndexVe->SetOpacity(FASTSCROLL_OPACITY_OFF); + } + // else keep up current visibility. + + __pBaseIndexVe->SetImplicitAnimationEnabled(false); + + return r; +} + +bool +_FastScrollIndexView::GetIndexVisibility(void) const +{ + float opacity = __pBaseIndexVe->GetOpacity(); + if (opacity > FASTSCROLL_OPACITY_OFF) + { + return true; + } + else + { + return false; + } +} + +result +_FastScrollIndexView::SetSelectedIndexVisibility(bool visibility, bool animation) +{ + SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null."); + SysTryReturnResult(NID_UI_CTRL, __pSelectedBgVe, E_INVALID_STATE, "__pSelectedBgVe must not be null."); + + if (animation) + { + __pSelectedIndexVe->SetImplicitAnimationEnabled(true); + __pSelectedBgVe->SetImplicitAnimationEnabled(true); + } + + if (visibility) + { + __pSelectedIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON); + __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_SELECTEDBG_DIM); + } + else + { + __pSelectedIndexVe->SetOpacity(FASTSCROLL_OPACITY_OFF); + __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_OFF); + } + // else keep up current visibility. + + __pSelectedIndexVe->SetImplicitAnimationEnabled(false); + __pSelectedBgVe->SetImplicitAnimationEnabled(false); + + return E_SUCCESS; +} + +bool +_FastScrollIndexView::GetSelectedIndexVisibility(void) const +{ + SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, false, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndexVe must not be null."); + + float opacity = __pSelectedIndexVe->GetOpacity(); + if (opacity > FASTSCROLL_OPACITY_OFF) + { + return true; + } + + return false; +} + + +result +_FastScrollIndexView::AddAccessibilityElement(const _AccessibilityContainer& control) +{ + SysTryReturnResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null."); + + int omittedChildCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType()); + SysTryReturnResult(NID_UI_CTRL, omittedChildCount > 0, E_INVALID_STATE, "The index have no children."); + + Rectangle bounds = GetIndexBounds(); + int indexHeight = GetIndexHeight(); + Rectangle indexRect(bounds.x, __viewConfig.__indexMarginTop, bounds.width, indexHeight); + int nonOmittedIndex = 0; + + _AccessibilityElement* pAccessibilityElement = null; + result r = E_SUCCESS; + for (int i = 0; i < omittedChildCount; ) + { + _FastScrollIndex* pChildIndex = __pBaseIndex->GetChildIndex(i, true); + SysTryReturnResult(NID_UI_CTRL, pChildIndex, GetLastResult(), "Failed to get the child index."); + + int omittedCount = 0; + if (pChildIndex->GetOmitted()) + { + omittedCount = pChildIndex->GetChildCount(); + pChildIndex = __pBaseIndex->GetChildIndex(nonOmittedIndex, false); + SysTryReturnResult(NID_UI_CTRL, pChildIndex, GetLastResult(), "Failed to get the child index."); + } + + Bitmap* pChildIndexImage = pChildIndex->GetIndexImage(); + if (pChildIndexImage == null) + { + String* pChildIndexText = pChildIndex->GetIndexText(); + SysTryReturnResult(NID_UI_CTRL, pChildIndexText, E_INVALID_STATE, "pChildIndexText must not be null."); + + _AccessibilityContainer* pAccessibilityContainer = const_cast <_AccessibilityContainer*>(&control); + pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement, E_OUT_OF_MEMORY, "Memory allocation failed."); + pAccessibilityElement->SetBounds(indexRect); + pAccessibilityElement->SetLabel(*pChildIndexText); + pAccessibilityElement->SetName(L"FastScrollIndex"); + pAccessibilityElement->SetHint(L"double tap to move ," + *pChildIndexText + L", list"); + r = pAccessibilityContainer->AddElement(*pAccessibilityElement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add accessibility element.", GetErrorMessage(r)); + } + + if (omittedCount > 1) + { + omittedCount--; + } + else + { + indexRect.y += indexHeight; + i++; + } + + nonOmittedIndex++; + } + + return E_SUCCESS; + +CATCH: + delete pAccessibilityElement; + return r; +} + +result +_FastScrollIndexView::UpdateIndex(bool bNeedUpdateBaseIndex) +{ + result r = E_SUCCESS; + + r = __parentVe.InvalidateRectangle(null); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to invalidate the index Ve."); + + if (__pSelectedIndex) + { + __needUpdateSelectedIndex = true; + } + + if (bNeedUpdateBaseIndex) + { + __needUpdateBaseIndex = true; + } + + return E_SUCCESS; +} + +Rectangle +_FastScrollIndexView::CalculateSelectedBg(void) +{ + SysTryReturn(NID_UI_CTRL, __pBaseIndex, Rectangle(0, 0, 0, 0), E_INVALID_STATE, + "[E_INVALID_STATE] __pBaseIndex must not be null."); + SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, Rectangle(0, 0, 0, 0), E_INVALID_STATE, + "[E_INVALID_STATE] __pSelectedIndexVe must not be null."); + SysTryReturn(NID_UI_CTRL, __pSelectedIndex, Rectangle(0, 0, 0, 0), E_INVALID_STATE, + "[E_INVALID_STATE] __pSelectedIndex must not be null."); + + int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType()); + SysTryReturn(NID_UI_CTRL, childCount > 0, Rectangle(0, 0, 0, 0), E_INVALID_STATE, "[E_INVALID_STATE] The index have no children."); + + Rectangle bounds = GetIndexBounds(); + int indexHeight = GetIndexHeight(); + int selectedIndexOrder = GetSelectedIndexOrder(); + Rectangle selectedRect(0, 0, (bounds.width - __viewConfig.__selectedIndexMarginRight), __viewConfig.__selectedIndexHeight); + + if (indexHeight > __viewConfig.__selectedIndexHeight) + { + selectedRect.y = (selectedIndexOrder * indexHeight) + __viewConfig.__indexMarginTop * 2; + selectedRect.height = indexHeight - (__viewConfig.__indexMarginTop * 2) ; + } + else if (bounds.height <= __viewConfig.__selectedIndexHeight) + { + selectedRect.height = bounds.height; + } + else + { + if (selectedIndexOrder == (childCount - 1)) + { + selectedRect.y = bounds.height - __viewConfig.__selectedIndexHeight - __viewConfig.__indexMarginTop; + } + else + { + selectedRect.y = ((selectedIndexOrder * indexHeight) + __viewConfig.__indexMarginTop) - (__viewConfig.__selectedIndexHeight - indexHeight) / 2; + selectedRect.y = MAX (selectedRect.y, __viewConfig.__indexMarginTop); + } + } + + return selectedRect; +} + +void +_FastScrollIndexView::OnDraw(void) +{ + DrawBaseIndex(); + if (__pSelectedIndex) + { + DrawSelectedBg(); + DrawSelectedIndex(); + } +} + +void +_FastScrollIndexView::DrawBaseIndex() +{ + if (!__needUpdateBaseIndex) + { + return; + } + + SysTryReturnVoidResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null."); + + result r = E_SUCCESS; + + int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType()); + SysTryReturnVoidResult(NID_UI_CTRL, childCount > 0, E_INVALID_STATE, "[E_INVALID_STATE] The index have no children."); + + Canvas* pCanvas = __pBaseIndexVe->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the index ve.", + GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + //Draw Seperator + pCanvas->SetLineWidth(__viewConfig.__indexSeparatorThickness); + + Rectangle bounds = GetIndexBounds(); + int indexHeight = GetIndexHeight(); + + //Draw background ef, bitmap + Rectangle bgBounds(0, 0, bounds.width, bounds.height); + if (__viewConfig.__pIndexBgBitmap) + { + Bitmap* pReplacementColorBackgroundBitmap = + _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pIndexBgBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__indexBgColor); + DrawBitmap(*pCanvas, bgBounds, *pReplacementColorBackgroundBitmap); + + delete pReplacementColorBackgroundBitmap; + } + + Rectangle indexRect(0, __viewConfig.__indexMarginTop, bounds.width, indexHeight); + Bitmap* pReplacementColorBitmap = null; + + TextObject* pTextObject = new (std::nothrow) TextObject(); + SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pTextObject->Construct(); + + for (int i = 0; i < childCount; i++) + { + TextSimple* pSimpleText = null; + + _FastScrollIndex* pChildIndex = __pBaseIndex->GetChildIndex(i, true); + SysTryCatch(NID_UI_CTRL, pChildIndex, , GetLastResult(), "[%s] Failed to get the child index.", + GetErrorMessage(GetLastResult())); + + Bitmap* pChildIndexImage = pChildIndex->GetIndexImage(); + if (pChildIndexImage) + { + Rectangle imageRect = indexRect; + + float scaleFactor = MIN(((float)indexRect.width / pChildIndexImage->GetWidth()), ((float)indexRect.height / pChildIndexImage->GetHeight())); + + imageRect.width = pChildIndexImage->GetWidth() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM; + imageRect.height = pChildIndexImage->GetHeight() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM; + + if (indexRect.width - imageRect.width > 0) + { + imageRect.x = indexRect.x + (indexRect.width - imageRect.width)/2; + } + + if (indexRect.height - imageRect.height > 0) + { + imageRect.y = indexRect.y + (indexRect.height - imageRect.height)/2; + } + + pReplacementColorBitmap = + _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage, + Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__indexTextColor); + r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap, + Rectangle(0, 0, pChildIndexImage->GetWidth(), pChildIndexImage->GetHeight())); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r)); + + delete pReplacementColorBitmap; + pReplacementColorBitmap = null; + } + else + { + String* pChildIndexText = pChildIndex->GetIndexText(); + SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "pChildIndexText must not be null."); + + pTextObject->RemoveAll(); + + pSimpleText = new (std::nothrow)TextSimple(const_cast(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed"); + + r = pTextObject->AppendElement(*pSimpleText); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simple text.", GetErrorMessage(r)); + + r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r)); + + r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r)); + + r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r)); + + r = pTextObject->SetBounds(indexRect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r)); + + r = pTextObject->SetForegroundColor(__viewConfig.__indexTextColor, 0, pTextObject->GetTextLength()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r)); + + r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r)); + + } + + indexRect.y += indexHeight; + if (i != (childCount - 1)) + { + pCanvas->SetForegroundColor(__viewConfig.__indexSeparatorColor); + pCanvas->DrawLine(Point(indexRect.x, indexRect.y + __viewConfig.__indexSeparatorThickness), + Point(indexRect.x + indexRect.width, indexRect.y + __viewConfig.__indexSeparatorThickness)); + } + } + + __needUpdateBaseIndex = false; + //fall through +CATCH: + delete pTextObject; + delete pCanvas; + delete pReplacementColorBitmap; +} + +void +_FastScrollIndexView::DrawSelectedBg() +{ + if (!__needUpdateSelectedIndex) + { + return; + } + + SysTryReturnVoidResult(NID_UI_CTRL, __pSelectedIndex, E_INVALID_STATE, + "[E_INVALID_STATE] __pSelectedIndex must not be null."); + + Canvas* pCanvas = __pSelectedBgVe->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the Selected Bg ve.", + GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + Rectangle bounds = GetSelectedBgBounds(); + bounds.y = 0; + + if (__viewConfig.__pSelectedIndexBgBitmap) + { + Bitmap* pReplacementColorBackgroundBitmap = null; + pReplacementColorBackgroundBitmap = + _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pSelectedIndexBgBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexBgColor); + DrawBitmap(*pCanvas, bounds, *pReplacementColorBackgroundBitmap); + + delete pReplacementColorBackgroundBitmap; + } + + delete pCanvas; +} + +void +_FastScrollIndexView::DrawSelectedIndex() +{ + if (!__needUpdateSelectedIndex) + { + return; + } + + SysTryReturnVoidResult(NID_UI_CTRL, __pSelectedIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndex must not be null."); + + Canvas* pCanvas = __pSelectedIndexVe->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the selected index ve.", + GetErrorMessage(GetLastResult())); + + result r = E_SUCCESS; + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + Rectangle bounds = GetSelectedIndexBounds(); + + //draw selected outline + Rectangle outlineBounds = GetSelectedBgBounds(); + if (__viewConfig.__pSelectedIndexOutlineBitmap) + { + Bitmap* pReplacementColorBackgroundBitmap = null; + pReplacementColorBackgroundBitmap = + _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pSelectedIndexOutlineBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexOutlineColor); + DrawBitmap(*pCanvas, outlineBounds, *pReplacementColorBackgroundBitmap); + + delete pReplacementColorBackgroundBitmap; + } + + //Draw left line + pCanvas->SetLineWidth(__viewConfig.__indexLeftLineThickness); + pCanvas->SetForegroundColor(__viewConfig.__indexLeftLineColor); + + pCanvas->DrawLine(Point(0, 0), Point(0, outlineBounds.y)); + pCanvas->DrawLine(Point(0, (outlineBounds.y + 1 + outlineBounds.height)), Point(0, bounds.height)); + + //draw text + TextObject* pTextObject = null; + TextSimple* pSimpleText = null; + + int indexHeight = GetIndexHeight(); + Rectangle indexRect(0, ((GetSelectedIndexOrder() * indexHeight) + __viewConfig.__indexMarginTop), + bounds.width, indexHeight); + + Bitmap* pChildIndexImage = __pSelectedIndex->GetIndexImage(); + Bitmap* pReplacementColorBitmap = null; + if (pChildIndexImage) + { + Rectangle imageRect = indexRect; + + float scaleFactor = MIN(((float)indexRect.width / pChildIndexImage->GetWidth()), ((float)indexRect.height / pChildIndexImage->GetHeight())); + + imageRect.width = pChildIndexImage->GetWidth() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM; + imageRect.height = pChildIndexImage->GetHeight() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM; + + if (indexRect.width - imageRect.width > 0) + { + imageRect.x = indexRect.x + (indexRect.width - imageRect.width)/2; + } + + if (indexRect.height - imageRect.height > 0) + { + imageRect.y = indexRect.y + (indexRect.height - imageRect.height)/2; + } + + pReplacementColorBitmap = + _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage, + Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexTextColor); + r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap, + Rectangle(0, 0, pChildIndexImage->GetWidth(), pChildIndexImage->GetHeight())); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r)); + + delete pReplacementColorBitmap; + pReplacementColorBitmap = null; + } + else + { + String* pChildIndexText = __pSelectedIndex->GetIndexText(); + SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "[E_INVALID_STATE] pChildIndexText must not be null."); + + pTextObject = new (std::nothrow) TextObject(); + SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pTextObject->Construct(); + + pSimpleText = new (std::nothrow)TextSimple(const_cast(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pTextObject->AppendElement(*pSimpleText); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simpletext.", GetErrorMessage(r)); + + r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r)); + + r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r)); + + r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r)); + + r = pTextObject->SetBounds(indexRect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r)); + + r = pTextObject->SetForegroundColor(__viewConfig.__selectedIndexTextColor, 0, pTextObject->GetTextLength()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r)); + + r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r)); + + } + + __needUpdateSelectedIndex = false; + + //fall through +CATCH: + delete pTextObject; + delete pCanvas; + delete pReplacementColorBitmap; +} + +result +_FastScrollIndexView::DrawBitmap(Canvas& canvas, const Rectangle& bounds, const Bitmap& bitmap) +{ + result r = E_SUCCESS; + if (bitmap.IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap"); + } + else + { + r = canvas.DrawBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap"); + } + + return E_SUCCESS; +} + +result +_FastScrollIndexView::DrawBitmap(Canvas& canvas, const Rectangle& srcRect, const Bitmap& bitmap, const Rectangle& dstRect) +{ + result r = E_SUCCESS; + if (bitmap.IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(srcRect, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap"); + } + else + { + r = canvas.DrawBitmap(srcRect, bitmap, dstRect); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap"); + } + + return E_SUCCESS; +} + +VisualElementAnimation* +_FastScrollIndexView::CreateAnimationForProperty(VisualElement& target, const String& property) +{ + VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property); + + if (pAnimation) + { + const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut"); + if (pTimingFunction) + { + pAnimation->SetTimingFunction(pTimingFunction); + } + pAnimation->SetVisualElementAnimationStatusEventListener(this); + } + return pAnimation; +} + +void +_FastScrollIndexView::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) +{ +} + +void +_FastScrollIndexView::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) +{ +} + +void +_FastScrollIndexView::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally) +{ + if (__pBaseIndexVe == (static_cast <_VisualElement*>(&target))) + { + if (__needDestroySelf && completedNormally) + { + if (__pSelectedIndexVe) + { + __pSelectedIndexVe->RemoveAllAnimations(); + __pSelectedIndexVe->SetAnimationProvider(null); + } + + if (__pSelectedBgVe) + { + __pSelectedBgVe->RemoveAllAnimations(); + __pSelectedBgVe->SetAnimationProvider(null); + } + + __pBaseIndexVe->RemoveAllAnimations(); + __pBaseIndexVe->SetAnimationProvider(null); + + delete this; + } + } +} + +result +_FastScrollIndexView::Construct(void) +{ + result r = E_SUCCESS; + + // FormattedText for Title text + __pBaseIndexVe = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_CTRL, __pBaseIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pBaseIndexVe->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the index Ve.", GetErrorMessage(r)); + + __pBaseIndexVe->SetAnimationProvider(this); + + r = __pBaseIndexVe->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the base index ve.", GetErrorMessage(r)); + + __pBaseIndexVe->SetImplicitAnimationEnabled(false); + + r = __parentVe.AttachChild(*__pBaseIndexVe); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the base index ve to the parent.", GetErrorMessage(r)); + + __pBaseIndexVe->SetShowState(true); + + //__pSelectedBgVe + __pSelectedBgVe = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_CTRL, __pSelectedBgVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pSelectedBgVe->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the selected Bg ve.", GetErrorMessage(r)); + + __pSelectedBgVe->SetAnimationProvider(this); + + r = __pSelectedBgVe->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the selected Bg ve.", GetErrorMessage(r)); + + __pSelectedBgVe->SetImplicitAnimationEnabled(false); + + r = __pBaseIndexVe->AttachChild(*__pSelectedBgVe); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the selected Bg ve to the parent.", GetErrorMessage(r)); + + __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_SELECTEDBG_DIM); + + __pSelectedBgVe->SetShowState(true); + + //__pSelectedIndexVe + __pSelectedIndexVe = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_CTRL, __pSelectedIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pSelectedIndexVe->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the selected index ve.", GetErrorMessage(r)); + + __pSelectedIndexVe->SetAnimationProvider(this); + + r = __pSelectedIndexVe->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the selected index ve.", GetErrorMessage(r)); + + __pSelectedIndexVe->SetImplicitAnimationEnabled(false); + + r = __pBaseIndexVe->AttachChild(*__pSelectedIndexVe); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the selected index ve to the parent.", GetErrorMessage(r)); + + __pSelectedIndexVe->SetShowState(true); + + return E_SUCCESS; + +CATCH: + if (__pSelectedIndexVe) + { + __pSelectedIndexVe->Destroy(); + __pSelectedIndexVe = null; + } + + if (__pSelectedBgVe) + { + __pSelectedBgVe->Destroy(); + __pSelectedBgVe = null; + } + + if (__pBaseIndexVe) + { + __pBaseIndexVe->Destroy(); + __pBaseIndexVe = null; + } + + return r; +} + +_FastScrollPopupView::_FastScrollPopupView(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig) + : __parentVe(parentVe) + , __viewConfig(viewConfig) + , __pPopupVe(null) + , __needUpdatePopupVe(false) + , __needUpdatePopupIndexVe(false) + , __needDestroySelf(false) +{ +} + +_FastScrollPopupView::~_FastScrollPopupView(void) +{ + for (int i = 0; i < GetIndexVeCount(); i++) + { + _VisualElement* pIndexVe = GetIndexVe(i); + + if (pIndexVe) + { + pIndexVe->RemoveAllAnimations(); + pIndexVe->SetAnimationProvider(null); + pIndexVe->Destroy(); + } + } + __indexViews.RemoveAll(false); + + if (__pPopupVe) + { + __pPopupVe->RemoveAllAnimations(); + __pPopupVe->SetAnimationProvider(null); + + __pPopupVe->Destroy(); + __pPopupVe = null; + } +} + +_FastScrollPopupView* +_FastScrollPopupView::CreateFastScrollPopupViewN(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig) +{ + _FastScrollPopupView* pPopupView = new (std::nothrow) _FastScrollPopupView(parentVe, viewConfig); + SysTryReturn(NID_UI_CTRL, pPopupView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pPopupView->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return pPopupView; + +CATCH: + delete pPopupView; + + return null; +} + +result +_FastScrollPopupView::FadeOutAndDestroy(void) +{ + __needDestroySelf = true; + + for (int i = 0; i < GetIndexVeCount(); i++) + { + _VisualElement* pIndexVe = GetIndexVe(i); + SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view."); + + pIndexVe->RemoveAllAnimations(); + } + + return SetPopupVisibility(false); +} + +result +_FastScrollPopupView::SelectIndex(int indexLevel, _FastScrollIndex* pIndex, _FastScrollIndex* pFormerIndex) +{ + _VisualElement* pIndexVe = GetIndexVe(indexLevel); + SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view."); + + if (pIndex) + { + pIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON); + FloatRectangle popupVeBounds = __pPopupVe->GetBounds(); + FloatMatrix4 popupVeMatrix; + popupVeMatrix.SetAsIdentity(); + + if (pFormerIndex && (pFormerIndex != pIndex)) + { + FloatRectangle popupIndexVeBounds = pIndexVe->GetBounds(); + + int selectedOrder = pIndex->GetIndexOrder(false); + int oldOrder = pFormerIndex->GetIndexOrder(false); + + if (selectedOrder > oldOrder) + { + _MatrixUtilTranslate(popupVeMatrix, 0, 0, 0); + } + else + { + _MatrixUtilTranslate(popupVeMatrix, 0, -(popupVeBounds.height * (FASTSCROLL_POPUPINDEX_COUNT - 1)), 0); + } + pIndexVe->SetTransformMatrix(popupVeMatrix); + pIndexVe->SetImplicitAnimationEnabled(true); + + popupVeMatrix.SetAsIdentity(); + _MatrixUtilTranslate(popupVeMatrix, 0, -popupVeBounds.height, 0); + pIndexVe->SetTransformMatrix(popupVeMatrix); + + pIndexVe->SetImplicitAnimationEnabled(false); + } + else + { + _MatrixUtilTranslate(popupVeMatrix, 0, -popupVeBounds.height, 0); + pIndexVe->SetTransformMatrix(popupVeMatrix); + } + } + else + { + pIndexVe->SetOpacity(FASTSCROLL_OPACITY_LIGHT_DIM); + } + + return E_SUCCESS; +} + +result +_FastScrollPopupView::AddPopupIndexVe(int indexLevel) +{ + result r = E_SUCCESS; + _VisualElement* pPopupIndexVe = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_CTRL, pPopupIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pPopupIndexVe->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the popup index ve.", GetErrorMessage(r)); + + pPopupIndexVe->SetAnimationProvider(this); + + r = pPopupIndexVe->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the popup index ve.", GetErrorMessage(r)); + + pPopupIndexVe->SetImplicitAnimationEnabled(false); + + r = __pPopupVe->AttachChild(*pPopupIndexVe); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the popup index ve to the popup ve.", GetErrorMessage(r)); + + pPopupIndexVe->SetShowState(true); + + r = __indexViews.InsertAt(*pPopupIndexVe, indexLevel); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to change the last index view.", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + if (pPopupIndexVe) + { + pPopupIndexVe->RemoveAllAnimations(); + pPopupIndexVe->SetAnimationProvider(null); + + pPopupIndexVe->Destroy(); + } + + return r; +} + +result +_FastScrollPopupView::RemovePopupIndexVe(int indexLevel) +{ + result r = E_SUCCESS; + + if (indexLevel < GetIndexVeCount()) + { + _VisualElement* pIndexVe = GetIndexVe(indexLevel); + SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index ve."); + + r = __indexViews.Remove(*pIndexVe, false); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove the popup index ve."); + + pIndexVe->RemoveAllAnimations(); + pIndexVe->SetAnimationProvider(null); + pIndexVe->Destroy(); + } + + return E_SUCCESS; +} + +result +_FastScrollPopupView::SetPopupBounds(const Rectangle& indexBounds) +{ + SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null."); + + FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height); + __pPopupVe->SetBounds(veBounds); + + return E_SUCCESS; +} + +Rectangle +_FastScrollPopupView::GetPopupBounds(void) const +{ + SysTryReturn(NID_UI_CTRL, __pPopupVe, Rectangle(0, 0, 0, 0), E_INVALID_STATE, + "[E_INVALID_STATE] __pPopupVe must not be null."); + + FloatRectangle veBounds = __pPopupVe->GetBounds(); + return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height); +} + +result +_FastScrollPopupView::SetPopupIndexBounds(int indexLevel, const _FastScrollIndex* pBaseIndex) +{ + FloatRectangle veBounds = __pPopupVe->GetBounds(); + _VisualElement* pIndexVe = GetIndexVe(indexLevel); + SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view."); + + if (pBaseIndex) + { + veBounds.x = 0; + veBounds.y = 0; + veBounds.height = veBounds.height * FASTSCROLL_POPUPINDEX_COUNT; + } + + int indexVeCount = GetIndexVeCount(); + int indexWidth = veBounds.width; + if (indexVeCount > 0) + { + indexWidth /= indexVeCount; + } + + veBounds.width = indexWidth; + veBounds.x = veBounds.width * indexLevel; + + pIndexVe->SetBounds(veBounds); + + return E_SUCCESS; +} + +Rectangle +_FastScrollPopupView::GetPopupIndexBounds(int indexLevel) const +{ + _VisualElement* pIndexVe = GetIndexVe(indexLevel); + SysTryReturn(NID_UI_CTRL, pIndexVe, Rectangle(0, 0, 0, 0), GetLastResult(), "[%s] Failed to get the popup index view.", + GetErrorMessage(GetLastResult())); + + FloatRectangle veBounds = pIndexVe->GetBounds(); + return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height); +} + +_VisualElement* +_FastScrollPopupView::GetIndexVe(int indexLevel) const +{ + Object* pObj = const_cast(__indexViews.GetAt(indexLevel)); + SysTryReturn(NID_UI_CTRL, pObj, null, GetLastResult(), "[%s] Failed to get the popup index ve.", + GetErrorMessage(GetLastResult())); + + return dynamic_cast<_VisualElement*>(pObj); +} + +int +_FastScrollPopupView::GetIndexVeCount(void) const +{ + return __indexViews.GetCount(); +} + +bool +_FastScrollPopupView::IsOnAnimation(void) const +{ + return false; +} + +void +_FastScrollPopupView::RemoveAllAnimations(void) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null."); + __pPopupVe->RemoveAllAnimations(); +} + +result +_FastScrollPopupView::SetPopupVisibility(bool visibility) +{ + SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null."); + + if (visibility) + { + __pPopupVe->SetTransformMatrix(__matrixFadeInStart); + __pPopupVe->SetImplicitAnimationEnabled(true); + __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_ON); + __pPopupVe->SetTransformMatrix(__matrixOrigin); + __pPopupVe->SetImplicitAnimationEnabled(false); + } + else + { + __pPopupVe->SetImplicitAnimationEnabled(true); + __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_OFF); + __pPopupVe->SetTransformMatrix(__matrixFadeOutEnd); + __pPopupVe->SetImplicitAnimationEnabled(false); + } + // else keep up current visibility. + + return E_SUCCESS; +} + +bool +_FastScrollPopupView::GetPopupVisibility(void) const +{ + SysTryReturn(NID_UI_CTRL, __pPopupVe, false, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null."); + + float opacity = __pPopupVe->GetOpacity(); + if (opacity > FASTSCROLL_OPACITY_OFF) + { + return true; + } + + return false; +} + +void +_FastScrollPopupView::SetPopupVeUpdateNeeded(bool needUpdate) +{ + __needUpdatePopupIndexVe = needUpdate; +} + +result +_FastScrollPopupView::UpdateIndex(void) +{ + SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null."); + + result r = E_SUCCESS; + + r = __parentVe.InvalidateRectangle(null); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to invaildate the popup Ve."); + + __needUpdatePopupIndexVe = true; + + return E_SUCCESS; +} + +void +_FastScrollPopupView::DrawPopupVe(void) +{ + if (!__needUpdatePopupVe) + { + return; + } + + SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null."); + + Canvas* pCanvas = __pPopupVe->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the popup ve.", + GetErrorMessage(GetLastResult())); + + Rectangle bounds = GetPopupBounds(); + bounds.SetPosition(0, 0); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + if (__viewConfig.__pPopupBgEffectBitmap) + { + DrawBitmap(*pCanvas, bounds, *__viewConfig.__pPopupBgEffectBitmap); + } + + if (__viewConfig.__pPopupBgBitmap) + { + Bitmap* pReplacementColorBackgroundBitmap = null; + pReplacementColorBackgroundBitmap = + _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pPopupBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__popupBgColor); + DrawBitmap(*pCanvas, bounds, *pReplacementColorBackgroundBitmap); + + delete pReplacementColorBackgroundBitmap; + } + + delete pCanvas; + + __needUpdatePopupVe = false; +} + + +void +_FastScrollPopupView::DrawPopupIndexVe(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex) +{ + if (__needUpdatePopupIndexVe != true) + { + return; + } + + SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] pBaseIndex must not be null."); + SysTryReturnVoidResult(NID_UI_CTRL, pSelectedIndex, E_INVALID_STATE, "[E_INVALID_STATE] pBaseIndex must not be null."); + + result r = E_SUCCESS; + + int childCount = pBaseIndex->GetChildCount(); + SysTryReturnVoidResult(NID_UI_CTRL, childCount > 0, E_INVALID_STATE, "[E_INVALID_STATE] The index have no children."); + + _VisualElement* pIndexVe = GetIndexVe(indexLevel); + SysTryReturnVoidResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "[%s] Failed to get the popup index ve.", + GetErrorMessage(GetLastResult())); + + Canvas* pCanvas = pIndexVe->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the popup index ve.", + GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + FloatRectangle veBounds = pIndexVe->GetBounds(); + Rectangle bounds(veBounds.x, veBounds.y, veBounds.width, veBounds.height); + + int indexHeight = bounds.height / FASTSCROLL_POPUPINDEX_COUNT; + indexHeight = MAX(__viewConfig.__popupTextSize, indexHeight); + + Rectangle indexRect(0, 0, bounds.width, indexHeight); + int selectedOrder = pSelectedIndex->GetIndexOrder(false); + Bitmap* pReplacementColorBitmap = null; + + TextObject* pTextObject = new (std::nothrow) TextObject(); + SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pTextObject->Construct(); + + for (int i = -1; i < 2; i++) + { + TextSimple* pSimpleText = null; + + _FastScrollIndex* pChildIndex = pBaseIndex->GetChildIndex(selectedOrder + i); + if (pChildIndex) + { + Bitmap* pChildIndexImage = pChildIndex->GetIndexImage(); + if (pChildIndexImage) + { + Rectangle imageRect = indexRect; + float widthScale = (float)indexRect.width / pChildIndexImage->GetWidth(); + int rectHeight = MIN(indexRect.height, __viewConfig.__popupTextSize); + float heightScale = (float)rectHeight / pChildIndexImage->GetHeight(); + float scaleFactor = MIN(widthScale, heightScale); + + imageRect.width = pChildIndexImage->GetWidth() * scaleFactor; + imageRect.height = pChildIndexImage->GetHeight() * scaleFactor; + + if (indexRect.width - imageRect.width > 0) + { + imageRect.x = indexRect.x + (indexRect.width - imageRect.width)/2; + } + + if (indexRect.height - imageRect.height > 0) + { + imageRect.y = indexRect.y + (indexRect.height - imageRect.height)/2; + } + + pReplacementColorBitmap = + _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage, + Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__popupTextColor); + r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap, + Rectangle(0, 0, pChildIndexImage->GetWidth(), pChildIndexImage->GetHeight())); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r)); + + delete pReplacementColorBitmap; + pReplacementColorBitmap = null; + } + else + { + String* pChildIndexText = pChildIndex->GetIndexText(); + SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "[E_INVALID_STATE] pChildIndexText must not be null."); + + pTextObject->RemoveAll(); + + pSimpleText = new (std::nothrow)TextSimple(const_cast(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pTextObject->AppendElement(*pSimpleText); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simple text.", GetErrorMessage(r)); + + r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r)); + + r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r)); + + r = pTextObject->SetForegroundColor(__viewConfig.__popupTextColor, 0, pTextObject->GetTextLength()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r)); + + r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r)); + + r = pTextObject->SetBounds(indexRect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r)); + + r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r)); + } + } + + indexRect.y += indexHeight; + } + + //fall through +CATCH: + delete pTextObject; + delete pCanvas; + delete pReplacementColorBitmap; +} + +void +_FastScrollPopupView::OnDraw(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex) +{ + DrawPopupVe(); + DrawPopupIndexVe(indexLevel, pBaseIndex, pSelectedIndex); +} + +result +_FastScrollPopupView::DrawBitmap(Canvas& canvas, const Rectangle& bounds, const Bitmap& bitmap) +{ + result r = E_SUCCESS; + if (bitmap.IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap"); + } + else + { + r = canvas.DrawBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap"); + } + + return E_SUCCESS; +} + +result +_FastScrollPopupView::DrawBitmap(Canvas& canvas, const Rectangle& srcRect, const Bitmap& bitmap, const Rectangle& dstRect) +{ + result r = E_SUCCESS; + if (bitmap.IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(srcRect, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap"); + } + else + { + r = canvas.DrawBitmap(srcRect, bitmap, dstRect); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap"); + } + + return E_SUCCESS; +} + +VisualElementAnimation* +_FastScrollPopupView::CreateAnimationForProperty(VisualElement& target, const String& property) +{ + VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property); + + if (pAnimation) + { + const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut"); + if (pTimingFunction) + { + pAnimation->SetTimingFunction(pTimingFunction); + } + pAnimation->SetVisualElementAnimationStatusEventListener(this); + } + return pAnimation; +} + +void +_FastScrollPopupView::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) +{ +} + +void +_FastScrollPopupView::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) +{ +} + +void +_FastScrollPopupView::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] The popup Ve must not be null."); + if (__pPopupVe == (static_cast <_VisualElement*>(&target))) + { + if (__needDestroySelf && completedNormally) + { + for (int i = 0; i < GetIndexVeCount(); i++) + { + _VisualElement* pIndexVe = GetIndexVe(i); + if (pIndexVe) + { + pIndexVe->RemoveAllAnimations(); + pIndexVe->SetAnimationProvider(null); + } + } + + __pPopupVe->RemoveAllAnimations(); + __pPopupVe->SetAnimationProvider(null); + + delete this; + } + } +} + +result +_FastScrollPopupView::Construct(void) +{ + result r = E_SUCCESS; + + __pPopupVe = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_CTRL, __pPopupVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pPopupVe->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the popup ve.", GetErrorMessage(r)); + + __pPopupVe->SetAnimationProvider(this); + + r = __pPopupVe->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the popup ve.", GetErrorMessage(r)); + + __pPopupVe->SetImplicitAnimationEnabled(false); + + r = __parentVe.AttachChild(*__pPopupVe); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the popup ve to the parent.", GetErrorMessage(r)); + + __pPopupVe->SetShowState(true); + __pPopupVe->SetClipChildrenEnabled(true); + __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_OFF); + + __needUpdatePopupVe = true; + + __matrixOrigin.SetAsIdentity(); + __matrixFadeInStart.SetAsIdentity(); + __matrixFadeOutEnd.SetAsIdentity(); + + _MatrixUtilScale(__matrixFadeInStart, 0.8, 0.8, 1); + _MatrixUtilScale(__matrixFadeOutEnd, 0.1, 0.1, 1); + + return E_SUCCESS; + +CATCH: + if (__pPopupVe) + { + __pPopupVe->Destroy(); + __pPopupVe = null; + } + + return r; +} + +_FastScrollPresenter::_FastScrollPresenter(_Control& parentCtrl, _FastScroll& fastScroll, bool visibility) + : __parentCtrl(parentCtrl) + , __fastScroll(fastScroll) + , __pCtrlVe(null) + , __pViewConfig(null) + , __pFastScrollEvent(null) + , __pFastScrollModel(null) + , __fontStyle(0) + , __fontSize(0) + , __pPopupView(null) + , __focusedIndexLevel(0) + , __pSelectedIndex(null) + , __enableFadeEffect(true) + , __indexCountMax(0) + , __fadeIn(false) + , __fadeOut(false) + , __scrollVisibility(visibility) + , __fadeEffectDuration_ms(500) +{ +} + +_FastScrollPresenter::~_FastScrollPresenter(void) +{ + delete __pFastScrollEvent; + __pFastScrollEvent = null; + + delete __pFastScrollModel; + __pFastScrollModel = null; + + delete __pPopupView; + __pPopupView = null; + + RemoveAllIndexViews(false); + + delete __pViewConfig; + __pViewConfig = null; + + if (__pCtrlVe) + { + __pCtrlVe->RemoveAllAnimations(); + __pCtrlVe->SetAnimationProvider(null); + } +} + +_FastScrollPresenter* +_FastScrollPresenter::CreateFastScrollPresenterN(_Control& parentCtrl, _FastScroll& fastScroll, bool visibility) +{ + _FastScrollPresenter* pPresenter = new (std::nothrow) _FastScrollPresenter(parentCtrl, fastScroll, visibility); + SysTryReturn(NID_UI_CTRL, pPresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pPresenter->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pPresenter; + +CATCH: + delete pPresenter; + + return null; +} + +result +_FastScrollPresenter::SetRootIndex(_FastScrollIndex* pIndex) +{ + result r = E_SUCCESS; + + // initialize index views + RemoveAllIndexViews(false); + + // initialize the popup view + if (__pPopupView) + { + r = __pPopupView->SetPopupVisibility(false); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear visibility of the popup view."); + } + + r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__indexTextSize); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set font."); + + // set the root index into _FastScrollModel + r = __pFastScrollModel->SetRootIndex(pIndex); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the root index into _FastScrollModel"); + + // add new root index view. + if (pIndex) + { + r = AddIndexView(0, *pIndex); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add the root index view."); + } + + return E_SUCCESS; +} + +_FastScrollIndex* +_FastScrollPresenter::GetRootIndex(void) const +{ + return __pFastScrollModel->GetRootIndex(); +} + +result +_FastScrollPresenter::UpdateIndex(void) +{ + result r = E_SUCCESS; + + // update the base index of index views + int indexViewCount = GetIndexViewCount(); + for (int i = 0; i < indexViewCount; i++) + { + _FastScrollIndexView* pIndexView = GetIndexView(i); + SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view."); + + _FastScrollIndex* pIndex = pIndexView->GetBaseIndex(); + + if ((pIndex->GetChildCount() > __indexCountMax) && (pIndex->GetIndexType() != FAST_SCROLL_INDEX_TYPE_OMISSION)) + { + r = pIndex->SetOmissionIndex(__indexCountMax); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set omiited index."); + } + + r = pIndexView->UpdateIndex(true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view."); + } + + // update the base index of the popup view + if (__pPopupView) + { + r = __pPopupView->UpdateIndex(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the popup view."); + } + + return E_SUCCESS; +} + +void +_FastScrollPresenter::EnableFadeEffect(bool enable) +{ + __enableFadeEffect = enable; +} + +bool +_FastScrollPresenter::IsEnabledFadeEffect(void) const +{ + return __enableFadeEffect; +} + +bool +_FastScrollPresenter::IsOnFadeEffect(void) const +{ + return (__fadeIn || __fadeOut); +} + +bool +_FastScrollPresenter::IsScrollVisible(void) const +{ + return (__fadeIn || __fadeOut || __scrollVisibility); +} + +result +_FastScrollPresenter::SetScrollVisibility(bool visibility) +{ + result r = E_SUCCESS; + + if (GetScrollVisibility() == visibility) + { + // keep up current visibility. + return E_SUCCESS; + } + + __pCtrlVe->RemoveAllAnimations(); + if (visibility) + { + if (__enableFadeEffect) + { + __fadeIn = true; + __fadeOut = false; + + __pCtrlVe->SetImplicitAnimationEnabled(true); + } + + __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON); + + if (__enableFadeEffect) + { + __pCtrlVe->SetImplicitAnimationEnabled(false); + } + else + { + __fadeIn = false; + __fadeOut = false; + } + } + else + { + if (__enableFadeEffect) + { + __fadeIn = false; + __fadeOut = true; + + __pCtrlVe->SetImplicitAnimationEnabled(true); + } + + __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF); + + if (__enableFadeEffect) + { + __pCtrlVe->SetImplicitAnimationEnabled(false); + } + else + { + __fadeIn = false; + __fadeOut = false; + } + } + + __scrollVisibility = visibility; + + return r; +} + +bool +_FastScrollPresenter::GetScrollVisibility(void) const +{ + float opacity = __pCtrlVe->GetOpacity(); + + if (__enableFadeEffect) + { + if (__scrollVisibility) + { + return true; + } + } + else if (opacity > FASTSCROLL_OPACITY_OFF) + { + return true; + } + + return false; +} + +void +_FastScrollPresenter::CancelFadeEffect(void) +{ + if (__fadeIn) + { + __fadeIn = false; + __scrollVisibility = false; + __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF); + } + else if (__fadeOut) + { + __fadeOut = false; + __scrollVisibility = true; + __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON); + } +} + +void +_FastScrollPresenter::AddFastScrollEventListener(const Controls::_IUiFastScrollListener& listener) +{ + result r = E_SUCCESS; + + if (__pFastScrollEvent == null) + { + __pFastScrollEvent = new (std::nothrow) _UiFastScrollEvent(); + SysTryReturnVoidResult(NID_UI_CTRL, __pFastScrollEvent, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pFastScrollEvent->Construct(__fastScroll); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pFastScrollEvent->AddListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_FastScrollPresenter::RemoveFastScrollEventListener(const Controls::_IUiFastScrollListener& listener) +{ + result r = E_SUCCESS; + + SysTryReturnVoidResult(NID_UI_CTRL, __pFastScrollEvent, E_INVALID_STATE, "[E_INVALID_STATE] __pFastScrollEvent must not be null."); + + r = __pFastScrollEvent->RemoveListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +_FastScrollPresenter::AddAccessibilityElement(const _AccessibilityContainer& control, bool onAccessibility) +{ + _FastScrollIndexView* pIndexView = GetIndexView(0); + SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get fastscroll indexview.", + GetErrorMessage(GetLastResult())); + + _AccessibilityContainer* pAccessibilityContainer = const_cast <_AccessibilityContainer*>(&control); + result r = pAccessibilityContainer->RemoveAllElement(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove accessibility elements."); + _AccessibilityElement* pAccessibilityElement = null; + + if (onAccessibility) + { + r = pIndexView->AddAccessibilityElement(control); + SysTryReturnResult(NID_UI_CTRL, r = E_SUCCESS, r, "Failed to Add accessibility element."); + } + else + { + pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement, E_OUT_OF_MEMORY, "Memory allocation failed."); + + pAccessibilityElement->SetBounds(pIndexView->GetIndexBounds()); + pAccessibilityElement->SetTrait(L"Fast scroll bar"); + pAccessibilityElement->SetName(L"FastScroll"); + pAccessibilityElement->SetHint(L"double tap to enter fast scroll mode"); + r = pAccessibilityContainer->AddElement(*pAccessibilityElement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Add accessibility element.", GetErrorMessage(r)); + } + return E_SUCCESS; + +CATCH: + delete pAccessibilityElement; + return r; +} + +void +_FastScrollPresenter::OnParentBoundsChanged(void) +{ + RelayoutFastScrollChildren(); +} + +void +_FastScrollPresenter::OnDraw(void) +{ + // draw index views + int indexViewCount = GetIndexViewCount(); + for (int i = 0; i < indexViewCount; i++) + { + _FastScrollIndexView* pIndexView = GetIndexView(i); + SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.", + GetErrorMessage(GetLastResult())); + + result r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__indexTextSize); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r)); + pIndexView->OnDraw(); + + // draw the popup view + if (__pPopupView && i <= __focusedIndexLevel) + { + r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__popupTextSize); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r)); + __pPopupView->OnDraw(i, pIndexView->GetBaseIndex(), pIndexView->GetSelectedIndexInOmittedIndex()); + } + } + + if (__pPopupView) + { + __pPopupView->SetPopupVeUpdateNeeded(false); + } +} + +bool +_FastScrollPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return OnTouchPressedAndMoved(touchinfo.GetCurrentPosition(), true); +} + +bool +_FastScrollPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return OnTouchReleasedAndCanceled(); +} + +bool +_FastScrollPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return OnTouchPressedAndMoved(touchinfo.GetCurrentPosition(), false); +} + +bool +_FastScrollPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return OnTouchReleasedAndCanceled(); +} + +void +_FastScrollPresenter::OnFontChanged(Font* pFont) +{ + __pViewConfig->__pFont = pFont; +} + +void +_FastScrollPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = __fontStyle; + size = __fontSize; +} + +result +_FastScrollPresenter::SetFontInfo(unsigned long style, int size) +{ + __fontStyle = style; + __fontSize = size; + + __pViewConfig->__pFont = __fastScroll.GetFallbackFont(); + SysTryReturnResult(NID_UI_CTRL, __pViewConfig->__pFont, GetLastResult(), "Failed to get a font."); + + return E_SUCCESS; +} + +VisualElementAnimation* +_FastScrollPresenter::CreateAnimationForProperty(VisualElement& target, const String& property) +{ + VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property); + + if (pAnimation) + { + const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut"); + if (pTimingFunction) + { + pAnimation->SetTimingFunction(pTimingFunction); + } + pAnimation->SetVisualElementAnimationStatusEventListener(this); + } + return pAnimation; +} + +void +_FastScrollPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) +{ +} + +void +_FastScrollPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) +{ +} + +void +_FastScrollPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally) +{ + if (__pCtrlVe == (static_cast <_VisualElement*>(&target))) + { + __fadeIn = false; + __fadeOut = false; + } +} + +HitTestResult +_FastScrollPresenter::HitTest(const Tizen::Graphics::FloatPoint& point) +{ + if (IsScrollVisible() == false) + { + return HIT_TEST_NOWHERE; + } + + int indexViewCount = GetIndexViewCount(); + for (int i = 0; i < indexViewCount; i++) + { + _FastScrollIndexView* pIndexView = GetIndexView(i); + SysTryReturn(NID_UI_CTRL, pIndexView, HIT_TEST_NOWHERE, GetLastResult(), "[%s] Failed to get the index view.", + GetErrorMessage(GetLastResult())); + + Rectangle indexBounds = pIndexView->GetIndexBounds(); + if (indexBounds.Contains(Point(point.x, point.y)) == true) + { + return HIT_TEST_MATCH; + } + } + + return HIT_TEST_NOWHERE; +} + +void +_FastScrollPresenter::OnIndexDataUpdated(_FastScrollIndex& updatedIndex) +{ + result r = E_SUCCESS; + + int indexViewCount = GetIndexViewCount(); + for (int i = 0; i < indexViewCount; i++) + { + _FastScrollIndexView* pIndexView = GetIndexView(i); + SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.", + GetErrorMessage(GetLastResult())); + + if (pIndexView->GetBaseIndex() == &updatedIndex) + { + r = pIndexView->UpdateIndex(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r)); + + if (__pPopupView) + { + r = __pPopupView->UpdateIndex(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update the popup view.", GetErrorMessage(r)); + } + break; + } + } +} + +void +_FastScrollPresenter::OnIndexDeleted(_FastScrollIndex& deletedIndex) +{ + result r = E_SUCCESS; + + int indexViewCount = GetIndexViewCount(); + for (int i = 0; i < indexViewCount; i++) + { + _FastScrollIndexView* pIndexView = GetIndexView(i); + SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.", + GetErrorMessage(GetLastResult())); + + if (pIndexView->GetBaseIndex() == &deletedIndex) + { + // first of all, update the base index view + if (i != 0) + { + _FastScrollIndexView* pBaseIndexView = GetIndexView(i - 1); + SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndexView, GetLastResult(), "[%s] Failed to get the index view.", + GetErrorMessage(GetLastResult())); + + r = pBaseIndexView->UpdateIndex(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r)); + } + + // then remove the index view for detached index. + RemoveIndexView(i, true); + + delete __pPopupView; + __pPopupView = null; + + break; + } + else if (pIndexView->GetBaseIndex() == deletedIndex.GetParentIndex()) + { + r = pIndexView->UpdateIndex(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r)); + + r = __pPopupView->UpdateIndex(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r)); + } + } +} + +void +_FastScrollPresenter::OnChildIndexAttached(_FastScrollIndex& parentIndex, int attachedOrder, _FastScrollIndex& attachedIndex) +{ + result r = E_SUCCESS; + + int indexViewCount = GetIndexViewCount(); + for (int i = 0; i < indexViewCount; i++) + { + _FastScrollIndexView* pIndexView = GetIndexView(i); + SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.", + GetErrorMessage(GetLastResult())); + + if (pIndexView->GetBaseIndex() == &parentIndex) + { + r = pIndexView->UpdateIndex(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r)); + + r = __pPopupView->UpdateIndex(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r)); + break; + } + } +} + +void +_FastScrollPresenter::OnChildIndexDetached(_FastScrollIndex& parentIndex, int detachedOrder, _FastScrollIndex& detachedIndex) +{ + result r = E_SUCCESS; + + int indexViewCount = GetIndexViewCount(); + for (int i = 0; i < indexViewCount; i++) + { + _FastScrollIndexView* pIndexView = GetIndexView(i); + SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.", + GetErrorMessage(GetLastResult())); + + if (pIndexView->GetBaseIndex() == &detachedIndex) + { + // first of all, update the base index view + if (i != 0) + { + _FastScrollIndexView* pBaseIndexView = GetIndexView(i - 1); + SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndexView, GetLastResult(), "[%s] Failed to get the index view.", + GetErrorMessage(GetLastResult())); + + r = pBaseIndexView->UpdateIndex(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r)); + } + + // then remove the index view for detached index. + RemoveIndexView(i, true); + + delete __pPopupView; + __pPopupView = null; + break; + } + else if (pIndexView->GetBaseIndex() == &parentIndex) + { + r = pIndexView->UpdateIndex(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r)); + + r = __pPopupView->UpdateIndex(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r)); + } + } +} + + +result +_FastScrollPresenter::Construct(void) +{ + result r = E_SUCCESS; + + // load color/shape configuration and bitmap resources + __pViewConfig = _FastScrollViewConfig::CreateFastScrollViewConfigN(_CONTROL_ORIENTATION_PORTRAIT); + SysTryReturnResult(NID_UI_CTRL, __pViewConfig, GetLastResult(), "Failed to create _FastScrollViewConfig."); + + // create _FastScrollModel + __pFastScrollModel = _FastScrollModel::CreateFastScrollModelN(); + SysTryCatch(NID_UI_CTRL, __pFastScrollModel, , GetLastResult(), "[%s] Failed to create _FastScrollModel.", + GetErrorMessage(GetLastResult())); + + // initialize visual elements + __pCtrlVe = __fastScroll.GetVisualElement(); + SysTryCatch(NID_UI_CTRL, __pCtrlVe, , GetLastResult(), "[%s] Failed to get VisualElement of the _FastScroll", + GetErrorMessage(GetLastResult())); + + __pCtrlVe->SetAnimationProvider(this); + __pCtrlVe->SetClipChildrenEnabled(false); + + if (__scrollVisibility) + { + __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON); + } + else + { + __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF); + } + + // initialize the fastscroll control + r = __fastScroll.SetBounds(CalculateFastScrollBounds(0)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the bounds of _FastScroll", GetErrorMessage(r)); + + __fastScroll.SetBackgroundColor(Tizen::Graphics::Color(0, 0, 0, 0)); + + __indexCountMax = (__fastScroll.GetBounds().height - (__pViewConfig->__indexMarginTop * 2)) / __pViewConfig->__indexSizeMin.height; + + return E_SUCCESS; + +CATCH: + delete __pFastScrollModel; + __pFastScrollModel = null; + + delete __pViewConfig; + __pViewConfig = null; + + return GetLastResult(); +} + +Rectangle +_FastScrollPresenter::CalculateFastScrollBounds(int indexCount) +{ + Rectangle fastScrollBounds(0, 0, 0, 0); + Rectangle parentBounds = __parentCtrl.GetBounds(); + fastScrollBounds.width = parentBounds.width; + fastScrollBounds.height = parentBounds.height; + return fastScrollBounds; +} + +Rectangle +_FastScrollPresenter::CalculateIndexBounds(int indexLevel, _FastScrollIndex& pIndex) +{ + Rectangle indexBounds(0, 0, 0, 0); + Rectangle fastScrollBounds = __fastScroll.GetBounds(); + + indexBounds.x = fastScrollBounds.width; + for (int i = 0; i <= indexLevel; i++) + { + if ( i != 0) + { + indexBounds.x -= __pViewConfig->__indexGap; + } + + indexBounds.x -= __pViewConfig->__indexSizeMin.width; + } + indexBounds.x = MAX(indexBounds.x, 0); + indexBounds.y = 0; + + indexBounds.width = __pViewConfig->__indexSizeMin.width; + indexBounds.height = fastScrollBounds.height; + + if (indexLevel != 0) + { + int childCount = pIndex.GetChildCount(); + indexBounds.height = (childCount * __pViewConfig->__indexSizeMin.height) + (__pViewConfig->__indexMarginTop * 2); + + if (indexBounds.height < fastScrollBounds.height) + { + _FastScrollIndexView* pParentIndexView = GetIndexView(indexLevel - 1); + if (pParentIndexView) + { + int parentIndexHeight = pParentIndexView->GetIndexHeight(); + Rectangle parentBounds = pParentIndexView->GetIndexBounds(); + + indexBounds.y = parentBounds.y + (pIndex.GetIndexOrder() * parentIndexHeight) - __pViewConfig->__indexMarginTop; + indexBounds.y = MAX(indexBounds.y, fastScrollBounds.y); + + if (indexBounds.y + indexBounds.height >= fastScrollBounds.height) + { + indexBounds.y = fastScrollBounds.height - indexBounds.height; + } + } + } + else + { + indexBounds.height = fastScrollBounds.height; + } + } + + return indexBounds; +} + +Rectangle +_FastScrollPresenter::CalculatePopupBounds(void) +{ + Rectangle popupBounds(0, 0, 0, 0); + Rectangle parentBounds = __parentCtrl.GetBounds(); + Rectangle fastScrollBounds = __fastScroll.GetBounds(); + int popupWidth = __pViewConfig->__popupSize.width + (__pViewConfig->__popupWidthIncrement * __focusedIndexLevel); + + popupBounds.width = MIN(popupWidth, parentBounds.width); + popupBounds.height = MIN(__pViewConfig->__popupSize.height, parentBounds.height); + + popupBounds.x = (parentBounds.width - popupBounds.width) ? ((parentBounds.width - popupBounds.width)/2) : 0; + popupBounds.y = (parentBounds.height - popupBounds.height) ? ((parentBounds.height - popupBounds.height)/2) : 0; + + popupBounds.x -= fastScrollBounds.x; + popupBounds.y -= fastScrollBounds.y; + + return popupBounds; +} + +void +_FastScrollPresenter::RelayoutFastScrollChildren(void) +{ + result r = E_SUCCESS; + + int indexViewCount = GetIndexViewCount(); + + // initialize the fastscroll control + r = __fastScroll.SetBounds(CalculateFastScrollBounds(indexViewCount)); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set the bounds of _FastScroll", GetErrorMessage(r)); + + __indexCountMax = (__fastScroll.GetBounds().height - (__pViewConfig->__indexMarginTop * 2)) / __pViewConfig->__indexSizeMin.height; + + for (int i = 0; i < indexViewCount; i++) + { + _FastScrollIndexView* pIndexView = GetIndexView(i); + SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.", + GetErrorMessage(GetLastResult())); + + r = pIndexView->SetIndexBounds(CalculateIndexBounds(i, *(pIndexView->GetBaseIndex()))); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set bounds of the index.", GetErrorMessage(r)); + + _FastScrollIndex* pIndex = pIndexView->GetBaseIndex(); + if (pIndex->GetIndexType() == FAST_SCROLL_INDEX_TYPE_OMISSION) + { + r = pIndex->RemoveOmissionChildren(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to remove omission index view", GetErrorMessage(r)); + } + + if (pIndex->GetChildCount() > __indexCountMax) + { + r = pIndex->SetOmissionIndex(__indexCountMax); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set omission index.", GetErrorMessage(r)); + } + + r = pIndexView->UpdateIndex(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r)); + } + + if (__pPopupView) + { + r = __pPopupView->SetPopupBounds(CalculatePopupBounds()); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set bounds of the popup view.", GetErrorMessage(r)); + } +} + +_FastScrollIndex* +_FastScrollPresenter::SelectOnIndexViews(const Point& point, bool animation) +{ + result r = E_SUCCESS; + + _FastScrollIndex* pSelectedIndex = null; + int selectedIndexLevel = 0; + int indexViewCount = GetIndexViewCount(); + SysTryReturn(NID_UI_CTRL, indexViewCount > 0, null, E_INVALID_STATE, "[E_INVALID_STATE] The root index view is invalid state."); + + // search the hit index on index views, then fade out other index views + for (int i = 0; i < indexViewCount; i++) + { + _FastScrollIndexView* pIndexView = GetIndexView(i); + SysTryReturn(NID_UI_CTRL, pIndexView, null, GetLastResult(), "[%s] Failed to get the index view.", + GetErrorMessage(GetLastResult())); + + _FastScrollIndex* pIndex = pIndexView->GetIndexAtPoint(point); + if (pIndex) + { + // select the index of the index view. + r = pIndexView->SelectIndex(pIndex, animation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r)); + pSelectedIndex = pIndex; + if (pIndex->GetOmitted() == true) + { + pSelectedIndex = pIndexView->GetOmissionIndexAtPoint(pIndex, point); + } + pIndexView->SetSelectedIndexInOmittedIndex(pSelectedIndex); + + selectedIndexLevel = i; + break; + } + } + + // if can no find the index on views, select index of the last index view + if ((pSelectedIndex == null) && (__focusedIndexLevel != -1)) + { + _FastScrollIndexView* pFocusedIndexView = GetIndexView(__focusedIndexLevel); + SysTryReturn(NID_UI_CTRL, pFocusedIndexView, null, GetLastResult(), "[%s] Failed to get the index view.", + GetErrorMessage(GetLastResult())); + + _FastScrollIndex* pIndex = pFocusedIndexView->GetIndexAtPoint(Point(pFocusedIndexView->GetIndexBounds().x, point.y)); + if (pIndex) + { + // select the index of the focused index view. + r = pFocusedIndexView->SelectIndex(pIndex, animation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r)); + pSelectedIndex = pIndex; + + if (pIndex->GetOmitted() == true) + { + pSelectedIndex = pFocusedIndexView->GetOmissionIndexAtPoint(pIndex, + Point(pFocusedIndexView->GetIndexBounds().x, point.y)); + } + pFocusedIndexView->SetSelectedIndexInOmittedIndex(pSelectedIndex); + + selectedIndexLevel = __focusedIndexLevel; + } + else + { + pSelectedIndex = pFocusedIndexView->GetSelectedIndex(); + selectedIndexLevel = __focusedIndexLevel; + } + } + + if (pSelectedIndex) + { + int childCount = pSelectedIndex->GetChildCount(); + if (childCount > 0) + { + _FastScrollIndexView* pSelectedIndexView = GetIndexView(selectedIndexLevel + 1); + if (pSelectedIndexView) + { + r = pSelectedIndexView->SelectIndex((_FastScrollIndex*)null, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r)); + + r = pSelectedIndexView->SetBaseIndex(pSelectedIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set the base index of the index view.", GetErrorMessage(r)); + + r = pSelectedIndexView->SetIndexBounds(CalculateIndexBounds(selectedIndexLevel + 1, *pSelectedIndex)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set bounds of the index.", GetErrorMessage(r)); + + r = pSelectedIndexView->SetIndexVisibility(true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set the visibility of the index view.", GetErrorMessage(r)); + + indexViewCount = GetIndexViewCount(); + while (indexViewCount > selectedIndexLevel + 2) + { + r = RemoveIndexView(indexViewCount - 1, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r)); + indexViewCount = GetIndexViewCount(); + } + } + else + { + r = AddIndexView(*pSelectedIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to add new child index.", GetErrorMessage(r)); + } + + if ((childCount > __indexCountMax) && (pSelectedIndex->GetIndexType() != FAST_SCROLL_INDEX_TYPE_OMISSION)) + { + r = pSelectedIndex->SetOmissionIndex(__indexCountMax); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set omission index.", GetErrorMessage(r)); + } + } + else + { + indexViewCount = GetIndexViewCount(); + while (indexViewCount > selectedIndexLevel + 1) + { + r = RemoveIndexView(indexViewCount - 1, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r)); + indexViewCount = GetIndexViewCount(); + } + } + } + else + { + indexViewCount = GetIndexViewCount(); + while (indexViewCount > 1) + { + r = RemoveIndexView(indexViewCount - 1, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r)); + indexViewCount = GetIndexViewCount(); + } + } + + __focusedIndexLevel = selectedIndexLevel; + return pSelectedIndex; +} + +result +_FastScrollPresenter::DeselectIndexViews(void) +{ + result r = E_SUCCESS; + + while (GetIndexViewCount() > 1) + { + RemoveIndexView(GetIndexViewCount() - 1, true); + } + + _FastScrollIndexView* pIndexView = GetIndexView(0); + SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view."); + + r = pIndexView->SelectIndex((_FastScrollIndex*)null, true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear the index selection."); + pIndexView->SetSelectedIndexInOmittedIndex(null); + + __fastScroll.Invalidate(); + + return E_SUCCESS; +} + +result +_FastScrollPresenter::SetPopupIndex(_FastScrollIndex& popupIndex, const Point& point) +{ + result r = E_SUCCESS; + + // set the selected node into the popup views. + if (__pPopupView == null) + { + __pPopupView = _FastScrollPopupView::CreateFastScrollPopupViewN(*__pCtrlVe, *__pViewConfig); + SysTryReturnResult(NID_UI_CTRL, __pPopupView, GetLastResult(), "Propagating."); + + r = __pPopupView->SetPopupBounds(CalculatePopupBounds()); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup view."); + + r = __pPopupView->SetPopupVisibility(true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the popup view."); + } + + int indexViewCount = __focusedIndexLevel + 1; + int popupIndexViewCount = __pPopupView->GetIndexVeCount(); + + if (indexViewCount != popupIndexViewCount) + { + r = __pPopupView->SetPopupBounds(CalculatePopupBounds()); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup view."); + + if (indexViewCount > popupIndexViewCount) + { + for (int i = popupIndexViewCount; i < indexViewCount; i++) + { + r = __pPopupView->AddPopupIndexVe(i); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add popup index ve."); + } + } + else if (indexViewCount < popupIndexViewCount) + { + for (int i = indexViewCount; i < popupIndexViewCount; i++) + { + r = __pPopupView->RemovePopupIndexVe(i); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove popup index ve."); + } + } + } + + r = __pPopupView->UpdateIndex(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the popup view."); + + for (int i = 0; i < indexViewCount; i++) + { + _FastScrollIndexView* pIndexView = GetIndexView(i); + SysTryReturnResult(NID_UI_CTRL, pIndexView, r, "Failed to index view."); + + r = __pPopupView->SetPopupIndexBounds(i, pIndexView->GetBaseIndex()); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup index ve."); + + _FastScrollIndex* pFormerIndex = null; + if ( i == __focusedIndexLevel ) + { + pFormerIndex = pIndexView->GetFormerIndex(); + r = __pPopupView->SelectIndex(i, &popupIndex, pFormerIndex); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the popup index."); + } + else + { + r = __pPopupView->SelectIndex(i, null, null); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the popup index."); + } + } + + return E_SUCCESS; +} + +result +_FastScrollPresenter::ClearPopupIndex(void) +{ + result r = E_SUCCESS; + + // clear the node data of the popup view + if (__pPopupView) + { + r = __pPopupView->FadeOutAndDestroy(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear visibility of the popup view."); + + __pPopupView = null; + } + + return E_SUCCESS; +} + +result +_FastScrollPresenter::FireFastScrollEvent(_FastScrollIndex& selectedIndex) +{ + // fire the fast scroll event + if (__pFastScrollEvent) + { + String* pIndexNodeText = selectedIndex.GetIndexText(); + if (pIndexNodeText) + { + _UiFastScrollEventArg* pEventArg = new (std::nothrow) _UiFastScrollEventArg(*__pFastScrollEvent->GetSource(), selectedIndex); + SysTryReturnResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "Memory allocation failed."); + + __pFastScrollEvent->Fire(*pEventArg); + } + } + + return E_SUCCESS; +} + +bool +_FastScrollPresenter::OnTouchPressedAndMoved(const Point& point, bool animation) +{ + result r = E_SUCCESS; + if (__scrollVisibility == false) + { + r = SetScrollVisibility(true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to fade out fastscroll.", GetErrorMessage(r)); + } + + _FastScrollIndex* pSelectedIndex = SelectOnIndexViews(point, animation); + if (pSelectedIndex && (__pSelectedIndex != pSelectedIndex)) + { + r = SetPopupIndex(*pSelectedIndex, point); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to set the poup index.", GetErrorMessage(r)); + + r = FireFastScrollEvent(*pSelectedIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to send the fast scroll event.", GetErrorMessage(r)); + } + + __pSelectedIndex = pSelectedIndex; + + return true; +} + +bool +_FastScrollPresenter::OnTouchReleasedAndCanceled(void) +{ + result r = E_SUCCESS; + + r = DeselectIndexViews(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to deselect index views.", GetErrorMessage(r)); + + r = ClearPopupIndex(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to clear the popup index.", GetErrorMessage(r)); + + if (__scrollVisibility == false) + { + r = SetScrollVisibility(false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to fade out fastscroll.", GetErrorMessage(r)); + } + + __pSelectedIndex = null; + + return true; +} + +result +_FastScrollPresenter::AddIndexView(_FastScrollIndex& baseIndex) +{ + return AddIndexView(GetIndexViewCount(), baseIndex); +} + +result +_FastScrollPresenter::AddIndexView(int indexLevel, _FastScrollIndex& baseIndex) +{ + result r = E_SUCCESS; + + _FastScrollIndexView* pNewIndexView = _FastScrollIndexView::CreateFastScrollIndexViewN( *__pCtrlVe, *__pViewConfig); + SysTryReturnResult(NID_UI_CTRL, pNewIndexView, GetLastResult(), "Propagating."); + + r = __fastScroll.SetBounds(CalculateFastScrollBounds(GetIndexViewCount() + 1)); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll."); + + r = pNewIndexView->SetIndexBounds(CalculateIndexBounds(indexLevel, baseIndex)); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the index view."); + + r = pNewIndexView->SetBaseIndex(&baseIndex); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the index data for the index view."); + + r = pNewIndexView->SetIndexVisibility(true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the index view."); + + r = __indexViews.InsertAt(*pNewIndexView, indexLevel); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to change the last index view."); + + return E_SUCCESS; +} + +result +_FastScrollPresenter::RemoveIndexView(int indexLevel, bool fadeout) +{ + result r = E_SUCCESS; + + int indexViewCount = GetIndexViewCount(); + if (indexLevel < indexViewCount) + { + _FastScrollIndexView* pIndexView = GetIndexView(indexLevel); + SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view."); + + if (fadeout) + { + r = pIndexView->FadeOutAndDestroy(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to request to fade out of the index view."); + } + + r = __indexViews.Remove(*pIndexView, false); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove the index views."); + + // initialize the fastscroll control + r = __fastScroll.SetBounds(CalculateFastScrollBounds(GetIndexViewCount())); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll"); + } + + return E_SUCCESS; +} + +result +_FastScrollPresenter::RemoveAllIndexViews(bool fadeout) +{ + result r = E_SUCCESS; + + if (fadeout) + { + int indexViewCount = GetIndexViewCount(); + for (int i = 0; i < indexViewCount; i++) + { + _FastScrollIndexView* pIndexView = GetIndexView(i); + SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view."); + + r = pIndexView->FadeOutAndDestroy(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to request to fade out of the index view."); + } + } + + __indexViews.RemoveAll(true); + + // initialize the fastscroll control + r = __fastScroll.SetBounds(CalculateFastScrollBounds(0)); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll."); + + return E_SUCCESS; +} + +_FastScrollIndexView* +_FastScrollPresenter::GetIndexView(int indexLevel) const +{ + Object* pIndexView = const_cast(__indexViews.GetAt(indexLevel)); + SysTryReturn(NID_UI_CTRL, pIndexView, null, GetLastResult(), "[%s] Failed to get the index view.", + GetErrorMessage(GetLastResult())); + + return dynamic_cast<_FastScrollIndexView*>(pIndexView); +} + +int +_FastScrollPresenter::GetIndexViewCount(void) const +{ + return __indexViews.GetCount(); +} + +} } } // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FlickAnimation.cpp b/src/ui/controls/FUiCtrl_FlickAnimation.cpp new file mode 100644 index 0000000..a96ae50 --- /dev/null +++ b/src/ui/controls/FUiCtrl_FlickAnimation.cpp @@ -0,0 +1,666 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FlickAnimation.cpp + * @brief This is the implementation file for _FlickAnimation class. + * + * This file contains the implementation of _FlickAnimation class. + */ + +#include +#include "FUiCtrl_FlickAnimation.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +namespace Tizen { namespace Ui { namespace Controls +{ +// Defined Parameter +const int FLK_REF_RESOL_PXL[2] = {480, 800}; // Reference Pixel + +enum +{ + _X = 0, + _Y = 1 +}; + + +_FlickAnimation::_FlickAnimation(void) +{ + __flickDirection = FD_VERTICAL; + + __dimension[_X] = 0; // 42 + __dimension[_Y] = 0; // 70 + + __resolution[_X] = 240; + __resolution[_Y] = 320; + + __align[_X] = __resolution[_X] / FLK_ANI_DEFAULT_ALIGN_RATIO; + __align[_Y] = __resolution[_Y] / FLK_ANI_DEFAULT_ALIGN_RATIO; + + __margin[_X] = 0; + __margin[_Y] = 0; + + __flickAnimationFPS = 25; + __flickAnimationFPSRef = 20; + __flickAnimaionTimeMin = FLK_ANI_TIME_MIN_MSEC * __flickAnimationFPS / 1000; + __flickAnimationTimeMax = FLK_ANI_TIME_MAX_MSEC * __flickAnimationFPS / 1000; + + __friction[_X] = 10; + __friction[_Y] = 10; + __velocity[_X] = 0; + __velocity[_Y] = 0; + + __frictionMin[_X] = 5; + __frictionMin[_Y] = 5; + __velocityMin[_X] = 0; + __velocityMin[_Y] = 0; + + __acceleration[_X] = 0; + __acceleration[_Y] = 0; + __drawCount = 0; + + __tensionStatus[_X] = TENSION_DONE; + __tensionStatus[_Y] = TENSION_DONE; + __tensionDistMax[_X] = 0; + __tensionDistMax[_Y] = 0; +} + +_FlickAnimation::~_FlickAnimation(void) +{ +} + +void +_FlickAnimation::SetSizeInformation(int resW, int resH, int mmW, int mmH) +{ + if (resW > 0 && resH > 0 && mmW > 0 && mmH > 0) + { + __resolution[_X] = resW; + __resolution[_Y] = resH; + + __dimension[_X] = mmW; + __dimension[_Y] = mmH; + } +} + +void +_FlickAnimation::SetAlignInformation(int alignW, int alignH) +{ + // Align Value < 0 then Resolution * 1/n + if (alignW > 0) + { + __align[_X] = alignW; + } + else + { + __align[_X] = __resolution[_X] / FLK_ANI_DEFAULT_ALIGN_RATIO; + } + + if (alignH > 0) + { + __align[_Y] = alignH; + } + else + { + __align[_Y] = __resolution[_Y] / FLK_ANI_DEFAULT_ALIGN_RATIO; + } + + // set Margin + __margin[_X] = __align[_X] / 20; + __margin[_Y] = __align[_Y] / 20; +} + +// sensitivity increases, the larger the distance but, less than fps. +void +_FlickAnimation::SetSensitivity(int fps, int sensitivity) +{ + if (fps > 0) + { + __flickAnimationFPS = fps; + + // max sensitivity is fps + if (0 < sensitivity && sensitivity < fps) + { + __flickAnimationFPSRef = sensitivity; + } + else + { + __flickAnimationFPSRef = fps; + } + + // Update + __flickAnimaionTimeMin = FLK_ANI_TIME_MIN_MSEC * __flickAnimationFPS / 1000; + __flickAnimationTimeMax = FLK_ANI_TIME_MAX_MSEC * __flickAnimationFPS / 1000; + } +} + +void +_FlickAnimation::SetDirection(int dir) +{ + __flickDirection = dir; +} + +void +_FlickAnimation::SetTensionEnable(bool enableX, bool enableY) +{ + if (enableX) + { + __tensionStatus[_X] = TENSION_DONE; + } + else + { + __tensionStatus[_X] = TENSION_NA; + } + + if (enableY) + { + __tensionStatus[_Y] = TENSION_DONE; + } + else + { + __tensionStatus[_Y] = TENSION_NA; + } +} + +bool +_FlickAnimation::IsItemExecutable(int flickX, int flickY) +{ + bool returnValue = (__velocity[_X] == 0 && __velocity[_Y] == 0 && flickX == 0 && flickY == 0); + + return returnValue; +} + +void +_FlickAnimation::CalculateInitializeVelocity(int flickX, int flickY, int flickTime, int* pFlkVelX, int* pFlkVelY) +{ + if (flickTime < 1) // {{110726 lsw2000}} Prevent 'Divide by 0' + { + flickTime = 1; + } + + // Calculateulate Velocity + int velX = flickX * 1000 / flickTime; // in pixel unit + int velY = flickY * 1000 / flickTime; // in pixel unit +// int velX = flickX * 1000/flickTime * m_nMmW/m_nResW; // in mm unit +// int velY = flickY * 1000/flickTime * m_nMmH/m_nResH; // in mm unit + + // Calculateulate Flick Amount using velocity and distance + // (input in mm) = (input in pixel) * (mm/resolution) + // (output in pixel) = (input in mm) * (alpha * resolution) <= (alpha = pixel output per mm input depends on resoultion) + // then (output in pixel) = (input in pixel) * (mm) * (alpha) +// *pFlkVelX = (velX*FLK_WEIGHT_VEL + flickX*FLK_WEIGHT_DIST)*m_nMmW/FLK_ALPHA_PER_MM; +// *pFlkVelY = (velY*FLK_WEIGHT_VEL + flickY*FLK_WEIGHT_DIST)*m_nMmH/FLK_ALPHA_PER_MM; + *pFlkVelX = (velX * FLK_WEIGHT_VEL + flickX * FLK_WEIGHT_DIST) / FLK_ALPHA_PER_PIXEL; + *pFlkVelY = (velY * FLK_WEIGHT_VEL + flickY * FLK_WEIGHT_DIST) / FLK_ALPHA_PER_PIXEL; +} + +int +_FlickAnimation::EstimateInitializeVelocity(int totalDist, int idx) +{ + int flkVel = 0; + int vel = 0; + bool minusFlag = (totalDist < 0); + totalDist = ((totalDist < 0) ? (-totalDist) : (totalDist)); + + // totalDist => vel => FlkVel + int velMax = __align[idx] * 2 / 3 * __flickAnimationFPSRef; + int distMax = velMax / __flickAnimationFPS; + int thres1 = distMax * __flickAnimaionTimeMin / 2; + int thres2 = distMax * __flickAnimationTimeMax / 2; + + if (totalDist < thres1) + { + int velMin = velMax / FLK_ANI_SPEED_MIN_RATIO; + vel = totalDist * __flickAnimationFPS * 2 / __flickAnimaionTimeMin; + flkVel = (vel - velMin) * (FLK_SPEED_THRES1 - FLK_SPEED_MIN) / (velMax - velMin) + FLK_SPEED_MIN; + } + else if (totalDist < thres2) + { + flkVel = (totalDist * 2 / distMax - __flickAnimaionTimeMin) + * (FLK_SPEED_THRES2 - FLK_SPEED_THRES1) / (__flickAnimationTimeMax - __flickAnimaionTimeMin) + FLK_SPEED_THRES1; + } + else + { + int totalDistRemain = totalDist - thres2; + int alpha = __align[idx] * (FLK_ANI_OVERSPEED_END_CNT - FLK_ANI_OVERSPEED_START_CNT - 1); + int accel = (totalDistRemain + alpha / 2) / alpha; + flkVel = FLK_SPEED_THRES2 + accel * FLK_OVERSPEED_STEP; + } + + if (minusFlag) + { + flkVel *= -1; + } + + return flkVel; +} + +// Set Flick Animation Variables from Flick Algorithm result +void +_FlickAnimation::InitializeFlickAmount(int flkVelX, int flkVelY) +{ + InitializeFlick(flkVelX, flkVelY); +} + +void +_FlickAnimation::InitializeFlickAmount(int flkVel) +{ + switch (__flickDirection) + { + case FD_VERTICAL: + InitializeFlick(0, flkVel); + break; + + case FD_HORIZONTAL: + InitializeFlick(flkVel, 0); + break; + + default: + // Error!!! + break; + } +} + +void +_FlickAnimation::InitializeFlick(int flkVelX, int flkVelY) +{ + InitializeTension(); + + __acceleration[_X] = 0; + __acceleration[_Y] = 0; + __drawCount = 0; + + if (flkVelX == 0 && flkVelY == 0) + { + __velocity[_X] = 0; + __velocity[_Y] = 0; + return; + } + + if (flkVelY == 0) + { + __velocity[_Y] = 0; + if (__flickDirection == FD_VERTICAL) + { + return; + } + } + else + { + InitializeFlickXY(flkVelY, _Y); + } + + if (flkVelX == 0) + { + __velocity[_X] = 0; + + if (__flickDirection == FD_HORIZONTAL) + { + return; + } + } + else + { + InitializeFlickXY(flkVelX, _X); + } +} + +void +_FlickAnimation::InitializeFlickXY(int flkVel, int idx) +{ + bool minusFlag = (flkVel < 0); + flkVel = ((flkVel < 0) ? (-flkVel) : (flkVel)); + + if (flkVel < FLK_SPEED_MIN) + { + flkVel = FLK_SPEED_MIN; + } + + // calculate __velocity & __friction based on FlkVel + /************************************************************************** + FlkVel | Vmin ~ Vth1 | Vth1 ~ Vth2 | > Vth2 + __velocity | 0 ~ velMax | velMax | velMax + Accel + Time | Tmin | Tmin ~ Tmax | Tmax + __acceleration | 0 | 0 | (flkVel-Vth2)/Step + **************************************************************************/ + int velMax = __align[idx] * 2 / 3 * __flickAnimationFPSRef; + + if (flkVel < FLK_SPEED_THRES1) + { + int velMin = velMax / FLK_ANI_SPEED_MIN_RATIO; + __velocity[idx] = (flkVel - FLK_SPEED_MIN) * (velMax - velMin) / (FLK_SPEED_THRES1 - FLK_SPEED_MIN) + velMin; + __friction[idx] = __velocity[idx] / __flickAnimaionTimeMin; + } + else if (flkVel < FLK_SPEED_THRES2) + { + __velocity[idx] = velMax; + __friction[idx] = velMax / + ((__flickAnimationTimeMax - + __flickAnimaionTimeMin) * + (flkVel - FLK_SPEED_THRES1) / (FLK_SPEED_THRES2 - FLK_SPEED_THRES1) + __flickAnimaionTimeMin); + } + else + { + __velocity[idx] = velMax; + __friction[idx] = velMax / __flickAnimationTimeMax; + __acceleration[idx] = (flkVel - FLK_SPEED_THRES2 + FLK_OVERSPEED_STEP / 2) / FLK_OVERSPEED_STEP; + } + + if (minusFlag) + { + __velocity[idx] *= -1; + __acceleration[idx] *= -1; + } + + // calculate Minimum Velocity, Friction for slowdown + int deltaMin = 8 * __flickAnimationFPSRef / __flickAnimationFPS * __resolution[idx] / FLK_REF_RESOL_PXL[idx]; + __velocityMin[idx] = deltaMin * __flickAnimationFPS; + __frictionMin[idx] = velMax / __flickAnimationTimeMax * 1 / 2; + + if (__frictionMin[idx] > __friction[idx]) + { + __frictionMin[idx] = __friction[idx]; + } + + if (__friction[idx] == 0) + { + __friction[idx] = 1; + } +} + +// Return next step distance and update Velocity. +int +_FlickAnimation::CalculateNextMove(int* pMoveX, int* pMoveY) +{ + *pMoveX = CalculateNextMoveXY(_X); + *pMoveY = CalculateNextMoveXY(_Y); + + __drawCount++; + + if (*pMoveX == 0 && *pMoveY == 0) + { + return 0; + } + else + { + return 1; + } +} + +int +_FlickAnimation::CalculateNextMove(void) +{ + int moved = 0; + + switch (__flickDirection) + { + case FD_VERTICAL: + moved = CalculateNextMoveXY(_Y); + break; + + case FD_HORIZONTAL: + moved = CalculateNextMoveXY(_X); + break; + + default: + // Error!!! + return 0; + } + __drawCount++; + + return moved; +} + +int +_FlickAnimation::CalculateNextMoveXY(int idx) +{ + if (__velocity[idx] == 0) + { + return 0; + } + + int delta = __velocity[idx] / __flickAnimationFPS; + + // removal reverse Flick effect + if (delta >= __align[idx] / 2 - __margin[idx]) + { + delta = __align[idx] / 2 - __margin[idx]; + } + else if (delta <= -(__align[idx] / 2 - __margin[idx])) + { + delta = -(__align[idx] / 2 - __margin[idx]); + } + + // adding start accelerate effect when fast Flick + if (__acceleration[idx] && __drawCount > FLK_ANI_OVERSPEED_START_CNT && __drawCount < FLK_ANI_OVERSPEED_END_CNT) + { + delta += __align[idx] * __acceleration[idx]; + } + else + { + int deltaNew = delta; + +// if (deltaNew > 10 && deltaNew%(m_alignH/12)) +// deltaNew = (deltaNew/(m_alignH/12)+1)*(m_alignH/12); + +// if (__velocity && delta == 0) +// deltaNew = m_alignH/24; + + delta = deltaNew; + } + + // ceiling RoundOff for smooth stop + if (delta == 0) + { + if (__velocity[idx] > 0) + { + delta = 1; + } + else if (__velocity[idx] < 0) + { + delta = -1; + } + } + +// if (delta == 1 && m_nSlowStopCnt < __flickAnimationFPS) +// { +// return delta; +// } + + // Velocity Decrease according to Friction Coefficient + // V(i+1)= V(i) - u*g*dT + if (__velocity[idx] > __velocityMin[idx] + __friction[idx]) + { + __velocity[idx] -= __friction[idx]; + } + else if (__velocity[idx] > __velocityMin[idx]) + { + __velocity[idx] = __velocityMin[idx]; + __friction[idx] = __frictionMin[idx]; + } + else if (__velocity[idx] > __friction[idx]) + { + __velocity[idx] -= __friction[idx]; + } + else if (__velocity[idx] < -__velocityMin[idx] - __friction[idx]) + { + __velocity[idx] += __friction[idx]; + } + else if (__velocity[idx] < -__velocityMin[idx]) + { + __velocity[idx] = -__velocityMin[idx]; + __friction[idx] = __frictionMin[idx]; + } + else if (__velocity[idx] < -__friction[idx]) + { + __velocity[idx] += __friction[idx]; + } + else + { + __velocity[idx] = 0; + } + + return delta; +} + +void +_FlickAnimation::InitializeTension(void) +{ + if (__tensionStatus[_X] != TENSION_NA) + { + __tensionStatus[_X] = TENSION_DONE; + } + + if (__tensionStatus[_Y] != TENSION_NA) + { + __tensionStatus[_Y] = TENSION_DONE; + } +} + +// start Tension effect and return true upon reaching the end of both. +bool +_FlickAnimation::StartTensionEffect(int pos, int end, int idx) +{ + if (__tensionStatus[idx] == TENSION_NA) + { + return false; + } + + bool reachEndFlag = false; + int vel = 0; + + if (pos > 0) + { + switch (__tensionStatus[idx]) + { + case TENSION_DONE: + // Tension start => calculate final distance (max : Resolution * 1/3) + __tensionDistMax[idx] = __resolution[idx] / 3 * __velocity[idx] / (__align[idx] * 2 / 3 * __flickAnimationFPSRef); + __acceleration[idx] = 0; + __tensionStatus[idx] = TENSION_COMPRESS; + // fall through + + case TENSION_COMPRESS: + vel = (__tensionDistMax[idx] - pos) * __flickAnimationFPS; + + if (vel < __velocity[idx]) + { + __velocity[idx] = vel; + } + + // Before Reaching End (delta > 0) + if (__velocity[idx] / __flickAnimationFPS > 0) + { + break; + } + + // After Reaching End, Tension Release Start + __tensionStatus[idx] = TENSION_RELEASE; + reachEndFlag = true; + // fall through + + case TENSION_RELEASE: + __velocity[idx] = -(pos * __flickAnimationFPS / 2); + + if (__velocity[idx] > -__flickAnimationFPS) + { + __velocity[idx] = -__flickAnimationFPS; // Adjust final position is 0. + } + break; + + default: + break; + } + } + else if (pos < end && pos < 0) + { + int delta = 0; + + if (end > 0) + { + delta = pos; + } + else + { + delta = pos - end; + } + + switch (__tensionStatus[idx]) + { + case TENSION_DONE: + __tensionDistMax[idx] = __resolution[idx] / 3 * __velocity[idx] / (__align[idx] * 2 / 3 * __flickAnimationFPSRef); + __acceleration[idx] = 0; + __tensionStatus[idx] = TENSION_COMPRESS; + // fall through + + case TENSION_COMPRESS: + vel = (__tensionDistMax[idx] - delta) * __flickAnimationFPS; + + if (vel > __velocity[idx]) + { + __velocity[idx] = vel; + } + + // Before Reaching End (delta > 0) + if (__velocity[idx] / __flickAnimationFPS < 0) + { + break; + } + + // After Reaching End, Tension Release Start + __tensionStatus[idx] = TENSION_RELEASE; + reachEndFlag = true; + // fall through + + case TENSION_RELEASE: + __velocity[idx] = -(delta * __flickAnimationFPS / 2); + + if (__velocity[idx] < __flickAnimationFPS) + { + __velocity[idx] = __flickAnimationFPS; + } + break; + + default: + break; + } + } + + if (__velocity[idx] == 0) + { + __tensionStatus[idx] = TENSION_DONE; + } + + return reachEndFlag; +} + +int +_FlickAnimation::GetCurVelocity(int idx) const +{ + return __velocity[idx]; +} + +int +_FlickAnimation::GetCurFriction(int idx) const +{ + return __friction[idx]; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_FooterImpl.cpp b/src/ui/controls/FUiCtrl_FooterImpl.cpp new file mode 100644 index 0000000..51131ea --- /dev/null +++ b/src/ui/controls/FUiCtrl_FooterImpl.cpp @@ -0,0 +1,1868 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FooterImpl.cpp + * @brief This is the implementation file for the _FooterImpl class. + */ + +#include +#include +#include "FUi_Control.h" +#include "FUi_ResourceManager.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_ButtonItemImpl.h" +#include "FUiCtrl_FooterImpl.h" +#include "FUiCtrl_FooterItemImpl.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_PublicActionEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_FooterImpl* +_FooterImpl::CreateFooterImplN(Footer* pControl) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _Toolbar* pCore = null; + + pCore = _Toolbar::CreateToolbarN(false); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->InitializeLongPressGesture(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _FooterImpl* pFooterImpl = new (std::nothrow) _FooterImpl(pControl, pCore); + + r = CheckConstruction(pCore, pFooterImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pFooterImpl; +} + +_FooterImpl::_FooterImpl(Footer* pPublic, _Toolbar* pCore) + : _ControlImpl(pPublic, pCore) + //, __calledBySetItemSelected(false) + , __style(FOOTER_STYLE_BUTTON_TEXT) + , __pPublicActionEvent(null) +{ + result r = GetLastResult(); // Check if _ControlImpl succeeded. + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCore->SetStyle(TOOLBAR_TEXT); + + Color tempColor = Color(0); + + GET_COLOR_CONFIG(FOOTER::BG_NORMAL, tempColor); + pCore->SetColor(tempColor); +} + +_FooterImpl::~_FooterImpl(void) +{ + if (__pPublicActionEvent) + { + delete __pPublicActionEvent; + __pPublicActionEvent = null; + } +} + +Footer* +_FooterImpl::GetFooter(void) const +{ + return &const_cast (GetPublic()); +} + +const char* +_FooterImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::Footer"; +} + +const Footer& +_FooterImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +Footer& +_FooterImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _Toolbar& +_FooterImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_Toolbar& +_FooterImpl::GetCore(void) +{ + return static_cast<_Toolbar&>(_ControlImpl::GetCore()); +} + +const _FooterImpl* +_FooterImpl::GetInstance(const Footer& footer) +{ + return static_cast (footer._pControlImpl); +} + +_FooterImpl* +_FooterImpl::GetInstance(Footer& footer) +{ + return static_cast<_FooterImpl*> (footer._pControlImpl); +} + +result +_FooterImpl::AddItem(const FooterItem& item) +{ + SysTryReturnResult(NID_UI_CTRL, (__style >= FOOTER_STYLE_BUTTON_TEXT && __style <= FOOTER_MAX_STATE_COUNT), + E_INVALID_OPERATION, "[E_INVALID_OPERATION] Current Footer style doesn't support this operation."); + + SysTryReturnResult(NID_UI_CTRL, (item.GetActionId() <= FOOTER_ITEM_ACTION_ID_MAX && item.GetActionId() >= FOOTER_ACTION_ID_MIN), + E_INVALID_ARG, "[E_INVALID_ARG] The item isn't constructed."); + + result r = CheckItemValidate(item); + + if (IsFailed(r)) + { + return r; + } + + _Button* pButton = ConvertFooterItem(item); + + if (__style == FOOTER_STYLE_SEGMENTED_TEXT || __style == FOOTER_STYLE_SEGMENTED_ICON || __style == FOOTER_STYLE_SEGMENTED_ICON_TEXT || __style == FOOTER_STYLE_TAB) + { + pButton->SetButtonStyle(_BUTTON_STYLE_SEGMENT); + } + + return GetCore().AddItem(pButton); +} + +Color +_FooterImpl::GetButtonColor(ButtonItemStatus status) const +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().GetButtonColor(tempStatus); +} + +Color +_FooterImpl::GetButtonTextColor(ButtonItemStatus status) const +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().GetButtonTextColor(tempStatus); +} + +ButtonItemStatus +_FooterImpl::GetButtonStatus(ButtonPosition position) const +{ + SysTryReturn(NID_UI_CTRL, (IsButtonSet(position) == true), BUTTON_ITEM_STATUS_NORMAL, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] No button item is set at the specified position."); + + _ButtonStatus buttonStatus; + + if (position == BUTTON_POSITION_LEFT) + { + buttonStatus = GetCore().GetButtonStatus(LEFT_BUTTON); + } + else if (position == BUTTON_POSITION_RIGHT) + { + buttonStatus = GetCore().GetButtonStatus(RIGHT_BUTTON); + } + else + { + return BUTTON_ITEM_STATUS_NORMAL; + } + + return ConvertButtonItemStatus(buttonStatus); +} + +ButtonItemStatus +_FooterImpl::GetBackButtonStatus(void) const +{ + SysTryReturn(NID_UI_CTRL, (IsBackButtonSet() == true), BUTTON_ITEM_STATUS_NORMAL, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] A Back button doesn't exist"); + + _ButtonStatus buttonStatus; + + buttonStatus = GetCore().GetButtonStatus(BACK_BUTTON); + + return ConvertButtonItemStatus(buttonStatus); +} + +Color +_FooterImpl::GetItemColor(FooterItemStatus status) const +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().GetItemColor(tempStatus); +} + +int +_FooterImpl::GetItemCount(void) const +{ + return GetCore().GetItemCount(); +} + +result +_FooterImpl::GetItemStatus(int itemIndex, FooterItemStatus& status) const +{ + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + _Button* pButton = GetCore().GetItem(itemIndex); + + SysTryReturnResult(NID_UI_CTRL, pButton, E_SYSTEM, "[E_SYSTEM] Unable to get the item status."); + + status = ConvertFooterItemStatus(pButton->GetButtonStatus()); + + return E_SUCCESS; +} + +Color +_FooterImpl::GetItemTextColor(FooterItemStatus status) const +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().GetItemTextColor(tempStatus); +} + +FooterStyle +_FooterImpl::GetStyle(void) const +{ + return __style; +} + +int +_FooterImpl::GetSelectedItemIndex(void) const +{ + SysTryReturn(NID_UI_CTRL, (__style != FOOTER_STYLE_BUTTON_TEXT && __style != FOOTER_STYLE_BUTTON_ICON && __style != FOOTER_STYLE_BUTTON_ICON_TEXT), -1, + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Unable to get the selected item itemIndex because the current style does not support it."); + + return GetCore().GetSelectedItemIndex(); +} + +Color +_FooterImpl::GetColor(void) const +{ + return GetCore().GetColor(); +} + +result +_FooterImpl::InsertItemAt(int itemIndex, const FooterItem& item) +{ + result r = CheckItemValidate(item); + + if (IsFailed(r)) + { + return r; + } + + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex <= count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + _Button* pButton = ConvertFooterItem(item); + + if (__style == FOOTER_STYLE_SEGMENTED_TEXT || __style == FOOTER_STYLE_SEGMENTED_ICON || __style == FOOTER_STYLE_SEGMENTED_ICON_TEXT || __style == FOOTER_STYLE_TAB) + { + pButton->SetButtonStyle(_BUTTON_STYLE_SEGMENT); + } + + return GetCore().InsertItemAt(itemIndex, pButton); +} + +bool +_FooterImpl::IsButtonSet(ButtonPosition position) const +{ + if (position == BUTTON_POSITION_LEFT) + { + return GetCore().IsButtonSet(LEFT_BUTTON); + } + else if (position == BUTTON_POSITION_RIGHT) + { + return GetCore().IsButtonSet(RIGHT_BUTTON); + } + else + { + return false; + } +} + +bool +_FooterImpl::IsBackButtonSet(void) const +{ + return GetCore().IsButtonSet(BACK_BUTTON); +} + +bool +_FooterImpl::IsTabEditModeEnabled(void) const +{ + return GetCore().IsTabEditModeEnabled(); +} + +result +_FooterImpl::RemoveAllButtons(void) +{ + return GetCore().RemoveAllButtons(); +} + +result +_FooterImpl::RemoveButtonAt(ButtonPosition position) +{ + if (position == BUTTON_POSITION_LEFT) + { + return GetCore().RemoveButtonAt(LEFT_BUTTON); + } + else if (position == BUTTON_POSITION_RIGHT) + { + return GetCore().RemoveButtonAt(RIGHT_BUTTON); + } + + return E_SUCCESS; +} + +result +_FooterImpl::RemoveBackButton(void) +{ + return GetCore().RemoveButtonAt(BACK_BUTTON); +} + +result +_FooterImpl::RemoveAllItems(void) +{ + return GetCore().RemoveAllItems(); +} + +result +_FooterImpl::RemoveItemAt(int itemIndex) +{ + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + return GetCore().RemoveItemAt(itemIndex); +} + +result +_FooterImpl::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + return GetCore().SetBackgroundBitmap(*pBitmap); +} + +result +_FooterImpl::SetButton(ButtonPosition position, const ButtonItem& button) +{ + SysTryReturnResult(NID_UI_CTRL, (__style == FOOTER_STYLE_SEGMENTED_TEXT || __style == FOOTER_STYLE_SEGMENTED_ICON || __style == FOOTER_STYLE_SEGMENTED_ICON_TEXT + || __style == FOOTER_STYLE_BUTTON_TEXT || __style == FOOTER_STYLE_BUTTON_ICON || __style == FOOTER_STYLE_BUTTON_ICON_TEXT), + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Unable to set the button item because the current style does not support it."); + + SysTryReturnResult(NID_UI_CTRL, (button.GetActionId() >= FOOTER_ACTION_ID_MIN && button.GetActionId() <= FOOTER_ACTION_ID_MAX), + E_INVALID_ARG, "[E_INVALID_ARG] The actionId is invalid."); + + int count = GetItemCount(); + + if (__style == FOOTER_STYLE_SEGMENTED_TEXT || __style == FOOTER_STYLE_SEGMENTED_ICON || __style == FOOTER_STYLE_SEGMENTED_ICON_TEXT + || __style == FOOTER_STYLE_BUTTON_TEXT || __style == FOOTER_STYLE_BUTTON_ICON || __style == FOOTER_STYLE_BUTTON_ICON_TEXT) + { + if (position == BUTTON_POSITION_RIGHT) + { + SysTryReturnResult(NID_UI_CTRL, (IsBackButtonSet() == false), E_SYSTEM, + "[E_SYSTEM] A Back button exists."); + } + + SysTryReturnResult(NID_UI_CTRL, (count <= FOOTER_MAX_ITEM_COUNT_WITH_BUTTON), E_SYSTEM, + "[E_SYSTEM] If the item count is larger then 3, no button can be set."); + } + + SysTryReturnResult(NID_UI_CTRL, (position == BUTTON_POSITION_LEFT || position == BUTTON_POSITION_RIGHT), E_INVALID_ARG, + "[E_INVALID_ARG] The position is invalid."); + + _Button* pButton = ConvertButtonItem(button); + + if (position == BUTTON_POSITION_LEFT) + { + return GetCore().SetButton(LEFT_BUTTON, pButton); + } + else if (position == BUTTON_POSITION_RIGHT) + { + return GetCore().SetButton(RIGHT_BUTTON, pButton); + } + + return E_SUCCESS; +} + +result +_FooterImpl::SetButtonColor(ButtonItemStatus status, const Color& color) +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().SetButtonColor(tempStatus, color); +} + +result +_FooterImpl::SetButtonTextColor(ButtonItemStatus status, const Color& color) +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().SetButtonTextColor(tempStatus, color); +} + +result +_FooterImpl::SetBackButton(void) +{ + SysTryReturnResult(NID_UI_CTRL, (__style != FOOTER_STYLE_TAB), E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] The current Footer style does not support the operation."); + + if ((__style == FOOTER_STYLE_SEGMENTED_TEXT || __style == FOOTER_STYLE_SEGMENTED_ICON || __style == FOOTER_STYLE_SEGMENTED_ICON_TEXT) && GetItemCount() > 4) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to set the back button."); + return E_SYSTEM; + } + else if ((__style == FOOTER_STYLE_BUTTON_ICON || __style == FOOTER_STYLE_BUTTON_TEXT || __style == FOOTER_STYLE_BUTTON_ICON_TEXT) && GetItemCount() > 5) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to set the back button."); + return E_SYSTEM; + } + + _Button* pButton = _Button::CreateButtonN(); + + int buttonHeight = 0; + int buttonWidth = 0; + int iconSize = 0; + + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_HEIGHT, GetCore().GetOrientation(), buttonHeight); + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetCore().GetOrientation(), buttonWidth); + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_ICON_SIZE, GetCore().GetOrientation(), iconSize); + + pButton->SetSize(Dimension(buttonWidth, buttonHeight)); + + Bitmap* pBackgroundBaseBitmap = null; + Bitmap* pPressedBitmap = null; + Bitmap* pColorReplacedBitmap = null; + Bitmap* pIconBaseBitmap = null; + Bitmap* pIconBaseEffectBitmap = null; + + GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBackgroundBaseBitmap); + GET_BITMAP_CONFIG_N(FOOTER::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedBitmap); + GET_BITMAP_CONFIG_N(FOOTER::BACK_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pIconBaseBitmap); + GET_BITMAP_CONFIG_N(FOOTER::BACK_ICON_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pIconBaseEffectBitmap); + + if (pBackgroundBaseBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBaseBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_NORMAL)); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBaseBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_HIGHLIGHTED)); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBaseBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_DISABLED)); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + delete pBackgroundBaseBitmap; + } + + //# if (pBackgroundEffectBitmap) + //# { + //# pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *pBackgroundEffectBitmap); + //# pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pBackgroundEffectBitmap); + //# pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_DISABLED, *pBackgroundEffectBitmap); + //# delete pBackgroundEffectBitmap; + //# } + + if (pPressedBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_PRESSED)); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + delete pPressedBitmap; + } + + //# if (pPressedEffectBitmap) + //# { + //# pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *pPressedEffectBitmap); + //# delete pPressedEffectBitmap; + //# } + + if (pIconBaseBitmap) + { + Color normalColor; + Color pressedColor; + Color disabledColor; + + GET_COLOR_CONFIG(FOOTER::BACK_ICON_NORMAL, normalColor); + GET_COLOR_CONFIG(FOOTER::BACK_ICON_PRESSED, pressedColor); + GET_COLOR_CONFIG(FOOTER::BACK_ICON_DISABLED, disabledColor); + + pIconBaseBitmap->Scale(Dimension(iconSize, iconSize)); + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pIconBaseBitmap, Color::GetColor(COLOR_ID_MAGENTA), normalColor); + if (pColorReplacedBitmap) + { + pButton->SetBitmap(_BUTTON_STATUS_NORMAL, + Point((buttonWidth - iconSize) / 2, (buttonHeight - iconSize) / 2), *pColorReplacedBitmap); + + delete pColorReplacedBitmap; + } + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pIconBaseBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedColor); + if (pColorReplacedBitmap) + { + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, + Point((buttonWidth - iconSize) / 2, (buttonHeight - iconSize) / 2), *pColorReplacedBitmap); + delete pColorReplacedBitmap; + } + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pIconBaseBitmap, Color::GetColor(COLOR_ID_MAGENTA), disabledColor); + if (pColorReplacedBitmap) + { + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, + Point((buttonWidth - iconSize) / 2, (buttonHeight - iconSize) / 2), *pColorReplacedBitmap); + delete pColorReplacedBitmap; + } + + delete pIconBaseBitmap; + } + + if (pIconBaseEffectBitmap) + { + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *pIconBaseEffectBitmap); + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *pIconBaseEffectBitmap); + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_SELECTED, *pIconBaseEffectBitmap); + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pIconBaseEffectBitmap); + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_DISABLED, *pIconBaseEffectBitmap); + + delete pIconBaseEffectBitmap; + } + + return GetCore().SetButton(BACK_BUTTON, pButton); +} + +result +_FooterImpl::SetItemAt(int itemIndex, const FooterItem& item) +{ + SysTryReturnResult(NID_UI_CTRL, (item.GetActionId() != -1), E_INVALID_ARG, "[E_INVALID_ARG] The FooterItem isn't constructed."); + + if (item.GetActionId() < FOOTER_ACTION_ID_MIN || item.GetActionId() > FOOTER_ACTION_ID_MAX) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] The actionId is invalid."); + return E_INVALID_ARG; + } + + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + _Button* pButton = ConvertFooterItem(item); + + if (__style == FOOTER_STYLE_SEGMENTED_TEXT || __style == FOOTER_STYLE_SEGMENTED_ICON || __style == FOOTER_STYLE_SEGMENTED_ICON_TEXT || __style == FOOTER_STYLE_TAB) + { + pButton->SetButtonStyle(_BUTTON_STYLE_SEGMENT); + } + + return GetCore().SetItemAt(itemIndex, pButton); +} + +result +_FooterImpl::SetItemColor(FooterItemStatus status, const Color& color) +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().SetItemColor(tempStatus, color); +} + +result +_FooterImpl::SetItemEnabled(int itemIndex, bool enable) +{ + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + if (__style == FOOTER_STYLE_SEGMENTED_TEXT || __style == FOOTER_STYLE_SEGMENTED_ICON || __style == FOOTER_STYLE_SEGMENTED_ICON_TEXT || __style == FOOTER_STYLE_TAB) + { + // Selected item cannot be disabled. + int selectedItemIndex = GetSelectedItemIndex(); + + if ((selectedItemIndex == itemIndex && enable == false) || (selectedItemIndex == -1 && itemIndex == 0 && enable == false)) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The Selected item cannot be disabled."); + return E_INVALID_OPERATION; + } + } + + return GetCore().SetItemEnabled(itemIndex, enable); +} + +result +_FooterImpl::SetItemBadgeIcon(int itemIndex, const Bitmap* pBadgeIcon) +{ + SysTryReturnResult(NID_UI_CTRL, (__style != FOOTER_STYLE_BUTTON_ICON && __style != FOOTER_STYLE_BUTTON_ICON_TEXT), E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] Unable to set the badge icon because the current style does not support it."); + + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + return GetCore().SetItemBadgeIcon(itemIndex, pBadgeIcon); +} + +result +_FooterImpl::SetItemTextColor(FooterItemStatus status, const Color& color) +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().SetItemTextColor(tempStatus, color); +} + +result +_FooterImpl::SetButtonEnabled(ButtonPosition position, bool enable) +{ + bool isButtonSet = IsButtonSet(position); + + SysTryReturnResult(NID_UI_CTRL, isButtonSet, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] No button item is set at the specified position."); + + if (position == BUTTON_POSITION_LEFT) + { + return GetCore().SetButtonEnabled(LEFT_BUTTON, enable); + } + else if (position == BUTTON_POSITION_RIGHT) + { + return GetCore().SetButtonEnabled(RIGHT_BUTTON, enable); + } + + return E_INVALID_STATE; +} + +result +_FooterImpl::SetBackButtonEnabled(bool enable) +{ + return GetCore().SetButtonEnabled(BACK_BUTTON, enable); +} + +result +_FooterImpl::SetItemSelected(int itemIndex) +{ + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + SysTryReturnResult(NID_UI_CTRL, (__style != FOOTER_STYLE_BUTTON_ICON && __style != FOOTER_STYLE_BUTTON_TEXT && __style != FOOTER_STYLE_BUTTON_ICON_TEXT), + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Unable to get the selected item itemIndex because the current style does not support it."); + + // Disabled item can not selected. + FooterItemStatus status; + result r = GetItemStatus(itemIndex, status); + + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[E_INVALID_STATE] Failed to get item status."); + + SysTryReturnResult(NID_UI_CTRL, (status != FOOTER_ITEM_STATUS_DISABLED), E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The disabled item can not be selected."); + + //__calledBySetItemSelected = true; + + return GetCore().SetItemSelected(itemIndex); +} + +result +_FooterImpl::SetItemNumberedBadgeIcon(int itemIndex, int number) +{ + SysTryReturnResult(NID_UI_CTRL, (__style != FOOTER_STYLE_BUTTON_ICON && __style != FOOTER_STYLE_BUTTON_ICON_TEXT), E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] Unable to set the badge icon because the current style does not support it."); + + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + SysTryReturnResult(NID_UI_CTRL, (number >= 0 && number <= FOOTER_NUMBERD_BADGE_ICON_NUMBER_MAX), E_INVALID_ARG, + "[E_INVALID_ARG] The number is invalid."); + + return GetCore().SetItemNumberedBadgeIcon(itemIndex, number); +} + +result +_FooterImpl::SetColor(const Color& color) +{ + return GetCore().SetColor(color); +} + +result +_FooterImpl::SetStyle(FooterStyle style) +{ + RemoveAllItems(); + RemoveAllButtons(); + + __style = style; + + return GetCore().SetStyle(ConvertFooterStyle(__style)); +} + +result +_FooterImpl::SetTabEditModeEnabled(bool enable) +{ + SysTryReturnResult(NID_UI_CTRL, (__style == FOOTER_STYLE_TAB), E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] This operation is only for FOOTER_STYLE_TAB."); + + return GetCore().SetTabEditModeEnabled(enable); +} + +result +_FooterImpl::SetTransparent(bool transparent) +{ + return GetCore().SetTransparent(transparent); +} + +Rectangle +_FooterImpl::GetButtonBounds(ButtonPosition position) const +{ + bool isButtonSet = IsButtonSet(position); + + SysTryReturn(NID_UI_CTRL, isButtonSet, Rectangle(-1, -1, -1, -1), + E_INVALID_OPERATION, "[E_INVALID_OPERATION] No button item is set at the specified position."); + + Rectangle rect; + + if (position == BUTTON_POSITION_LEFT) + { + rect = GetCore().GetButtonBounds(LEFT_BUTTON); + } + else if (position == BUTTON_POSITION_RIGHT) + { + rect = GetCore().GetButtonBounds(RIGHT_BUTTON); + } + + return rect; +} + +void +_FooterImpl::AddActionEventListener(IActionEventListener& listener) +{ + if (__pPublicActionEvent == null) + { + __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + + if (IsFailed(GetLastResult())) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] System error occurred."); + delete __pPublicActionEvent; + return; + } + } + + __pPublicActionEvent->AddListener(listener); + + GetCore().AddActionEventListener(*this); + + return; +} + +void +_FooterImpl::RemoveActionEventListener(IActionEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnVoidResult(NID_UI_CTRL, __pPublicActionEvent, E_INVALID_STATE, "[E_INVALID_STATE] This instance isn't constructed."); + + // Todo : check fail case of RemoveListener + __pPublicActionEvent->RemoveListener(listener); + + GetCore().RemoveActionEventListener(*this); + + return; +} + +void +_FooterImpl::OnActionPerformed(const _Control& source, int actionId) +{ + //if (__calledBySetItemSelected) + //{ + // __calledBySetItemSelected = false; + // return ; + //} + + if (GetCore().IsInitialDraw() == true && GetCore().GetSelectedItemIndex() == 0) + { + return; + } + + if (__pPublicActionEvent != null) + { + __pPublicActionEvent->Fire(*_PublicActionEvent::CreateActionEventArgN(actionId)); + } + + return; +} + +result +_FooterImpl::CheckItemValidate(const FooterItem& item) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (item.GetActionId() != -1), E_INVALID_ARG, + "[E_INVALID_ARG] The FooterItem isn't constructed."); + + int count = GetItemCount(); + + if (__style == FOOTER_STYLE_BUTTON_ICON || __style == FOOTER_STYLE_BUTTON_TEXT || __style == FOOTER_STYLE_BUTTON_ICON_TEXT) + { + SysTryReturnResult(NID_UI_CTRL, (count < 5), E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] The number of items have exceeded the maximum limit."); + } + else if (__style == FOOTER_STYLE_TAB) + { + SysTryReturnResult(NID_UI_CTRL, (count < 15), E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] The number of items have exceeded the maximum limit."); + } + else if (__style == FOOTER_STYLE_SEGMENTED_TEXT || __style == FOOTER_STYLE_SEGMENTED_ICON || __style == FOOTER_STYLE_SEGMENTED_ICON_TEXT + || __style == FOOTER_STYLE_BUTTON_TEXT || __style == FOOTER_STYLE_BUTTON_ICON || __style == FOOTER_STYLE_BUTTON_ICON_TEXT) + { + if (IsButtonSet(BUTTON_POSITION_LEFT)) + { + SysTryReturnResult(NID_UI_CTRL, (count < 3), E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] The number of items have exceeded the maximum limit."); + } + else + { + if (IsBackButtonSet()) + { + SysTryReturnResult(NID_UI_CTRL, (count < 4), E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] The number of items have exceeded the maximum limit."); + } + else + { + if (IsButtonSet(BUTTON_POSITION_RIGHT)) + { + SysTryReturnResult(NID_UI_CTRL, (count < 3), E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] The number of items have exceeded the maximum limit."); + } + else + { + SysTryReturnResult(NID_UI_CTRL, (count < 4), E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] The number of items have exceeded the maximum limit."); + } + } + } + } + + if (item.GetActionId() < FOOTER_ACTION_ID_MIN || item.GetActionId() > FOOTER_ACTION_ID_MAX) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] The actionId is invalid."); + return E_INVALID_ARG; + } + + return r; +} + +_Button* +_FooterImpl::ConvertButtonItem(const ButtonItem& buttonItem) +{ + _Button* pButton = _Button::CreateButtonN(); + + int buttonItemWidth = 0; + int buttonItemHeight = 0; + + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetCore().GetOrientation(), buttonItemWidth); + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_HEIGHT, GetCore().GetOrientation(), buttonItemHeight); + + pButton->SetMargin(0, 0); + pButton->SetSize(Dimension(buttonItemWidth, buttonItemHeight)); + + pButton->SetActionId(buttonItem.GetActionId()); + + pButton->SetText(buttonItem.GetText()); + + pButton->SetTextMaxLine(2); + + int fontSize = 0; + result r = GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_FONT_SIZE, GetCore().GetOrientation(), fontSize); + + if (!IsFailed(r)) + { + pButton->SetTextSize(fontSize, FONT_STYLE_BOLD); + } + + int iconSize = 0; + + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_ICON_SIZE, GetCore().GetOrientation(), iconSize); + + Bitmap* pIconBitmap = null; + + pIconBitmap = const_cast(buttonItem.__pImpl->GetIcon(BUTTON_ITEM_STATUS_NORMAL)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_NORMAL, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + } + + pIconBitmap = const_cast(buttonItem.__pImpl->GetIcon(BUTTON_ITEM_STATUS_PRESSED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + } + + pIconBitmap = const_cast(buttonItem.__pImpl->GetIcon(BUTTON_ITEM_STATUS_HIGHLIGHTED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + } + + pIconBitmap = const_cast(buttonItem.__pImpl->GetIcon(BUTTON_ITEM_STATUS_DISABLED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + } + + Bitmap* pNormalBackgroundBitmap = null; + Bitmap* pColorReplacedBitmap = null; + + GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap); + + if (pNormalBackgroundBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_NORMAL)); + + if (GetCore().GetButtonColor(_BUTTON_STATUS_NORMAL).GetAlpha() != 0xFF) + { + pColorReplacedBitmap->SetAlphaConstant(GetCore().GetButtonColor(_BUTTON_STATUS_NORMAL).GetAlpha()); + } + + pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_PRESSED)); + + if (GetCore().GetButtonColor(_BUTTON_STATUS_PRESSED).GetAlpha() != 0xFF) + { + pColorReplacedBitmap->SetAlphaConstant(GetCore().GetButtonColor(_BUTTON_STATUS_PRESSED).GetAlpha()); + } + + pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_HIGHLIGHTED)); + + if (GetCore().GetButtonColor(_BUTTON_STATUS_HIGHLIGHTED).GetAlpha() != 0xFF) + { + pColorReplacedBitmap->SetAlphaConstant(GetCore().GetButtonColor(_BUTTON_STATUS_HIGHLIGHTED).GetAlpha()); + } + + pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_DISABLED)); + + if (GetCore().GetButtonColor(_BUTTON_STATUS_DISABLED).GetAlpha() != 0xFF) + { + pColorReplacedBitmap->SetAlphaConstant(GetCore().GetButtonColor(_BUTTON_STATUS_DISABLED).GetAlpha()); + } + + pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap); + + + delete pColorReplacedBitmap; + + delete pNormalBackgroundBitmap; + } + + if (buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_NORMAL, *buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL)); + } + if (buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_PRESSED, *buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED)); + } + if (buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_HIGHLIGHTED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_HIGHLIGHTED)); + } + if (buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_DISABLED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_DISABLED, *buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_DISABLED)); + } + + return pButton; +} + +_Button* +_FooterImpl::ConvertFooterItem(const FooterItem& footerItem) +{ + _Button* pButton = _Button::CreateButtonN(); + + int minItemLength = 0; + + GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_WIDTH_1_MIN, GetCore().GetOrientation(), minItemLength); + + pButton->SetSize(Dimension(minItemLength, minItemLength)); + + pButton->SetActionId(footerItem.GetActionId()); + + if (__style != FOOTER_STYLE_BUTTON_ICON && __style != FOOTER_STYLE_SEGMENTED_ICON) + { + pButton->SetText(footerItem.GetText()); + } + + pButton->SetTextMaxLine(2); + + int fontSize = 0; + int iconSize = 0; + + result r = E_SUCCESS; + + if (__style == FOOTER_STYLE_SEGMENTED_TEXT || __style == FOOTER_STYLE_SEGMENTED_ICON + || __style == FOOTER_STYLE_SEGMENTED_ICON_TEXT || __style == FOOTER_STYLE_TAB) + { + r = GET_SHAPE_CONFIG(FOOTER::SEGMENTED_ITEM_FONT_SIZE, GetCore().GetOrientation(), fontSize); + + if (footerItem.GetText() != L"") + { + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_ICON_SIZE_WITH_TEXT, GetCore().GetOrientation(), iconSize); + } + else + { + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_ICON_SIZE, GetCore().GetOrientation(), iconSize); + } + + Bitmap* pSelectedBitmap = null; + Bitmap* pColorReplacedBitmap = null; + Color selectedBitmapColor; + + GET_BITMAP_CONFIG_N(HEADER::TAB_ITEM_BG_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pSelectedBitmap); + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_PRESSED, selectedBitmapColor); + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSelectedBitmap, Color::GetColor(COLOR_ID_MAGENTA), selectedBitmapColor); + + if (pColorReplacedBitmap) + { + pButton->SetToolbarSelectedBitmap(*pColorReplacedBitmap, false); + + delete pColorReplacedBitmap; + + delete pSelectedBitmap; + } + } + else if (__style == FOOTER_STYLE_BUTTON_TEXT || __style == FOOTER_STYLE_BUTTON_ICON || __style == FOOTER_STYLE_BUTTON_ICON_TEXT) + { + r = GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_FONT_SIZE, GetCore().GetOrientation(), fontSize); + + if (footerItem.GetText() != L"") + { + GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_BUTTON_STYLE_ICON_SIZE_WITH_TEXT, GetCore().GetOrientation(), iconSize); + } + else + { + GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_BUTTON_STYLE_ICON_SIZE, GetCore().GetOrientation(), iconSize); + } + } + + if (!IsFailed(r)) + { + pButton->SetTextSize(fontSize, FONT_STYLE_BOLD); + } + + Bitmap* pIconBitmap = null; + + if (__style != FOOTER_STYLE_BUTTON_TEXT && __style != FOOTER_STYLE_SEGMENTED_TEXT) + { + pIconBitmap = const_cast(footerItem.__pImpl->GetIcon(FOOTER_ITEM_STATUS_NORMAL)); + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_NORMAL, Point(0, 0), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, Point(0, 0), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_SELECTED, Point(0, 0), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, Point(0, 0), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, Point(0, 0), *pIconBitmap); + } + + pIconBitmap = const_cast(footerItem.__pImpl->GetIcon(FOOTER_ITEM_STATUS_PRESSED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, Point(0, 0), *pIconBitmap); + } + + pIconBitmap = const_cast(footerItem.__pImpl->GetIcon(FOOTER_ITEM_STATUS_SELECTED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_SELECTED, Point(0, 0), *pIconBitmap); + } + + pIconBitmap = const_cast(footerItem.__pImpl->GetIcon(FOOTER_ITEM_STATUS_HIGHLIGHTED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, Point(0, 0), *pIconBitmap); + } + + pIconBitmap = const_cast(footerItem.__pImpl->GetIcon(FOOTER_ITEM_STATUS_DISABLED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, Point(0, 0), *pIconBitmap); + } + } + + if (footerItem.__pImpl->GetBackgroundBitmap(FOOTER_ITEM_STATUS_NORMAL) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_NORMAL, + *footerItem.__pImpl->GetBackgroundBitmap(FOOTER_ITEM_STATUS_NORMAL)); + } + if (footerItem.__pImpl->GetBackgroundBitmap(FOOTER_ITEM_STATUS_PRESSED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_PRESSED, + *footerItem.__pImpl->GetBackgroundBitmap(FOOTER_ITEM_STATUS_PRESSED)); + } + if (footerItem.__pImpl->GetBackgroundBitmap(FOOTER_ITEM_STATUS_SELECTED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_SELECTED, + *footerItem.__pImpl->GetBackgroundBitmap(FOOTER_ITEM_STATUS_SELECTED)); + } + if (footerItem.__pImpl->GetBackgroundBitmap(FOOTER_ITEM_STATUS_HIGHLIGHTED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, + *footerItem.__pImpl->GetBackgroundBitmap(FOOTER_ITEM_STATUS_HIGHLIGHTED)); + } + if (footerItem.__pImpl->GetBackgroundBitmap(FOOTER_ITEM_STATUS_DISABLED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_DISABLED, + *footerItem.__pImpl->GetBackgroundBitmap(FOOTER_ITEM_STATUS_DISABLED)); + } + + return pButton; +} + +void +_FooterImpl::OnChangeLayout(_ControlOrientation orientation) +{ + GetCore().OnChangeLayout(orientation); + + return; +} + +ButtonItemStatus +_FooterImpl::ConvertButtonItemStatus(_ButtonStatus status) const +{ + switch (status) + { + case _BUTTON_STATUS_NORMAL: + return BUTTON_ITEM_STATUS_NORMAL; + break; + + case _BUTTON_STATUS_DISABLED: + return BUTTON_ITEM_STATUS_DISABLED; + break; + + case _BUTTON_STATUS_PRESSED: + return BUTTON_ITEM_STATUS_PRESSED; + break; + + case _BUTTON_STATUS_HIGHLIGHTED: + return BUTTON_ITEM_STATUS_HIGHLIGHTED; + break; + + default: + return BUTTON_ITEM_STATUS_DISABLED; + break; + } +} + +FooterItemStatus +_FooterImpl::ConvertFooterItemStatus(_ButtonStatus status) const +{ + switch (status) + { + case _BUTTON_STATUS_NORMAL: + return FOOTER_ITEM_STATUS_NORMAL; + break; + + case _BUTTON_STATUS_DISABLED: + return FOOTER_ITEM_STATUS_DISABLED; + break; + + case _BUTTON_STATUS_PRESSED: + return FOOTER_ITEM_STATUS_PRESSED; + break; + + case _BUTTON_STATUS_HIGHLIGHTED: + return FOOTER_ITEM_STATUS_HIGHLIGHTED; + break; + + case _BUTTON_STATUS_SELECTED: + return FOOTER_ITEM_STATUS_SELECTED; + break; + + default: + return FOOTER_ITEM_STATUS_DISABLED; + break; + } +} + +_ButtonStatus +_FooterImpl::ConvertButtonStatus(ButtonItemStatus status) const +{ + switch (status) + { + case BUTTON_ITEM_STATUS_NORMAL: + return _BUTTON_STATUS_NORMAL; + break; + + case BUTTON_ITEM_STATUS_DISABLED: + return _BUTTON_STATUS_DISABLED; + break; + + case BUTTON_ITEM_STATUS_PRESSED: + return _BUTTON_STATUS_PRESSED; + break; + + case BUTTON_ITEM_STATUS_HIGHLIGHTED: + return _BUTTON_STATUS_HIGHLIGHTED; + break; + + default: + return _BUTTON_STATUS_DISABLED; + break; + } +} + +_ButtonStatus +_FooterImpl::ConvertButtonStatus(FooterItemStatus status) const +{ + switch (status) + { + case FOOTER_ITEM_STATUS_NORMAL: + return _BUTTON_STATUS_NORMAL; + break; + + case FOOTER_ITEM_STATUS_DISABLED: + return _BUTTON_STATUS_DISABLED; + break; + + case FOOTER_ITEM_STATUS_PRESSED: + return _BUTTON_STATUS_PRESSED; + break; + + case FOOTER_ITEM_STATUS_HIGHLIGHTED: + return _BUTTON_STATUS_HIGHLIGHTED; + break; + + case FOOTER_ITEM_STATUS_SELECTED: + return _BUTTON_STATUS_SELECTED; + break; + + default: + return _BUTTON_STATUS_DISABLED; + break; + } +} + +ToolbarStyle +_FooterImpl::ConvertFooterStyle(FooterStyle style) +{ + ToolbarStyle viewStyle = TOOLBAR_TEXT; + + switch (style) + { + case FOOTER_STYLE_TAB: + viewStyle = TOOLBAR_TAB; + break; + + case FOOTER_STYLE_SEGMENTED_TEXT: + // fall through + + case FOOTER_STYLE_SEGMENTED_ICON_TEXT: + // fall through + + case FOOTER_STYLE_SEGMENTED_ICON: + viewStyle = TOOLBAR_SEGMENTED; + break; + + case FOOTER_STYLE_BUTTON_TEXT: + viewStyle = TOOLBAR_TEXT; + break; + + case FOOTER_STYLE_BUTTON_ICON: + viewStyle = TOOLBAR_ICON; + break; + + case FOOTER_STYLE_BUTTON_ICON_TEXT: + viewStyle = TOOLBAR_ICON_TEXT; + + default: + break; + } + + return viewStyle; +} + +class _FooterMaker + : public _UiBuilderControlMaker +{ +public: + _FooterMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_FooterMaker(){}; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _FooterMaker* pFooterMaker = new (std::nothrow) _FooterMaker(uibuilder); + return pFooterMaker; + }; +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + Footer* pFooter = null; + Rectangle rect; + + String elementString; + int opacity = 0; + Color color; + + //Construct + FooterStyle fstyle = FOOTER_STYLE_BUTTON_TEXT; + Form* pForm = static_cast(GetContainer()); + pFooter = pForm->GetFooter(); + + if (null == pFooter) + { + return null; + } + + if (pControl->GetElement(L"footerStyle", elementString)) + { + if (elementString.Equals(L"FOOTER_STYLE_BUTTON_TEXT", false)) + { + fstyle = FOOTER_STYLE_BUTTON_TEXT; + } + else if (elementString.Equals(L"FOOTER_STYLE_BUTTON_ICON", false)) + { + fstyle = FOOTER_STYLE_BUTTON_ICON; + } + else if (elementString.Equals(L"FOOTER_STYLE_BUTTON_ICON_TEXT", false)) + { + fstyle = FOOTER_STYLE_BUTTON_ICON_TEXT; + } + else if (elementString.Equals(L"FOOTER_STYLE_SEGMENTED_TEXT", false)) + { + fstyle = FOOTER_STYLE_SEGMENTED_TEXT; + } + else if (elementString.Equals(L"FOOTER_STYLE_SEGMENTED_ICON", false)) + { + fstyle = FOOTER_STYLE_SEGMENTED_ICON; + } + else if (elementString.Equals(L"FOOTER_STYLE_SEGMENTED_ICON_TEXT", false)) + { + fstyle = FOOTER_STYLE_SEGMENTED_ICON_TEXT; + } + else if (elementString.Equals(L"FOOTER_STYLE_TAB", false)) + { + fstyle = FOOTER_STYLE_TAB; + } + + pFooter->SetStyle(fstyle); + } + + if (pControl->GetElement(L"backgroundBitmapPath", elementString) || pControl->GetElement(L"BGBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + pFooter->SetBackgroundBitmap(pBitmap); + } + + // footer color + if (pControl->GetElement(L"colorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"color", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pFooter->SetColor(color); + } + + // normal button + if (pControl->GetElement(L"normalButtonColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"normalButtonColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pFooter->SetButtonColor(BUTTON_ITEM_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"normalButtonTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pFooter->SetButtonTextColor(BUTTON_ITEM_STATUS_NORMAL, color); + } + + // pressed button + if (pControl->GetElement(L"pressedButtonColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"pressedButtonColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pFooter->SetButtonColor(BUTTON_ITEM_STATUS_PRESSED, color); + } + + if (pControl->GetElement(L"pressedButtonTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pFooter->SetButtonTextColor(BUTTON_ITEM_STATUS_PRESSED, color); + } + + // highlighted button + if (pControl->GetElement(L"highlightedButtonColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"highlightedButtonColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pFooter->SetButtonColor(BUTTON_ITEM_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"highlightedButtonTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pFooter->SetButtonTextColor(BUTTON_ITEM_STATUS_HIGHLIGHTED, color); + } + + // disabled button + if (pControl->GetElement(L"disabledButtonColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"disabledButtonColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pFooter->SetButtonColor(BUTTON_ITEM_STATUS_DISABLED, color); + } + + if (pControl->GetElement(L"disabledButtonTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pFooter->SetButtonTextColor(BUTTON_ITEM_STATUS_DISABLED, color); + } + + if (pControl->GetElement(L"normalItemColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"normalItemColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pFooter->SetItemColor(FOOTER_ITEM_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"normalItemTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pFooter->SetItemTextColor(FOOTER_ITEM_STATUS_NORMAL, color); + } + + // pressed item + if (pControl->GetElement(L"pressedItemColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"pressedItemColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pFooter->SetItemColor(FOOTER_ITEM_STATUS_PRESSED, color); + } + + if (pControl->GetElement(L"pressedItemTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pFooter->SetItemTextColor(FOOTER_ITEM_STATUS_PRESSED, color); + } + + // selected item + if (pControl->GetElement(L"selectedItemColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"selectedItemColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pFooter->SetItemColor(FOOTER_ITEM_STATUS_SELECTED, color); + } + + if (pControl->GetElement(L"selectedItemTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pFooter->SetItemTextColor(FOOTER_ITEM_STATUS_SELECTED, color); + } + + // highlighted item + if (pControl->GetElement(L"highlightedItemColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"highlightedItemColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pFooter->SetItemColor(FOOTER_ITEM_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"highlightedItemTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pFooter->SetItemTextColor(FOOTER_ITEM_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"disabledItemColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"disabledItemColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pFooter->SetItemColor(FOOTER_ITEM_STATUS_DISABLED, color); + } + + if (pControl->GetElement(L"disabledItemTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pFooter->SetItemTextColor(FOOTER_ITEM_STATUS_DISABLED, color); + } + + if ((FOOTER_STYLE_TAB != fstyle) && (pControl->GetElement(L"showBackButton", elementString))) + { + if (elementString.Equals(L"true", false)) + { + pFooter->SetBackButton(); + } + } + + int itemCnt = pControl->GetItemCount(); + ButtonItemStyle buttonItemStyle = BUTTON_ITEM_STYLE_TEXT; + ButtonPosition buttonPosition = BUTTON_POSITION_LEFT; + String footerItemString; + + for (int i = 0; i < itemCnt; i++) + { + footerItemString = pControl->GetItemName(i); + + if (footerItemString.Equals(L"footerItem", false)) + { + FooterItem footerItem; + + if (pControl->GetItemElement(i, "actionId", elementString)) + { + int actionId =0; + Base::Integer::Parse(elementString, actionId); + footerItem.Construct(actionId); + } + + if (pControl->GetItemElement(i, "text", elementString)) + { + footerItem.SetText(elementString); + } + + // footeritem background bitmap path setting + // normal bg bitmap + if (pControl->GetItemElement(i, "normalBGBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + footerItem.SetBackgroundBitmap(FOOTER_ITEM_STATUS_NORMAL, pBitmap); + } + + // pressed bg bitmap + if (pControl->GetItemElement(i, "pressedBGBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + footerItem.SetBackgroundBitmap(FOOTER_ITEM_STATUS_PRESSED, pBitmap); + } + + // selected bg bitmap + if (pControl->GetItemElement(i, "selectedBGBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + footerItem.SetBackgroundBitmap(FOOTER_ITEM_STATUS_SELECTED, pBitmap); + } + + // highlighted bg bitmap + if (pControl->GetItemElement(i, "highlightedBGBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + footerItem.SetBackgroundBitmap(FOOTER_ITEM_STATUS_HIGHLIGHTED, pBitmap); + } + + // disabled bg bitmap + if (pControl->GetItemElement(i, "disabledBGBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + footerItem.SetBackgroundBitmap(FOOTER_ITEM_STATUS_DISABLED, pBitmap); + } + + // footeritem icon bitmap setting + // normal + if (pControl->GetItemElement(i, "normalIconPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + footerItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmap); + } + + // pressed + if (pControl->GetItemElement(i, "pressedIconPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + footerItem.SetIcon(FOOTER_ITEM_STATUS_PRESSED, pBitmap); + } + + // selected + if (pControl->GetItemElement(i, "selectedIconPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + footerItem.SetIcon(FOOTER_ITEM_STATUS_SELECTED, pBitmap); + } + + // highlighted + if (pControl->GetItemElement(i, "highlightedIconPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + footerItem.SetIcon(FOOTER_ITEM_STATUS_HIGHLIGHTED, pBitmap); + } + + // disabled + if (pControl->GetItemElement(i, "disabledIconPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + footerItem.SetIcon(FOOTER_ITEM_STATUS_DISABLED, pBitmap); + } + + pFooter->AddItem(footerItem); + } + else if (footerItemString.Equals(L"buttonItem", false)) + { + ButtonItem buttonItem; + + // set button style + if (pControl->GetItemElement(i, "style", elementString)) + { + if (elementString.Equals(L"BUTTON_ITEM_STYLE_TEXT", false)) + { + buttonItemStyle = BUTTON_ITEM_STYLE_TEXT; + } + else if (elementString.Equals(L"BUTTON_ITEM_STYLE_ICON", false)) + { + buttonItemStyle = BUTTON_ITEM_STYLE_ICON; + } + } + + // set button position + if (pControl->GetItemElement(i, "position", elementString)) + { + if (elementString.Equals(L"BUTTON_POSITION_LEFT", false)) + { + buttonPosition = BUTTON_POSITION_LEFT; + } + else if (elementString.Equals(L"BUTTON_POSITION_RIGHT", false)) + { + buttonPosition = BUTTON_POSITION_RIGHT; + } + } + + // Construct + if (pControl->GetItemElement(i, "actionId", elementString)) + { + int actionId = 0; + Base::Integer::Parse(elementString, actionId); + buttonItem.Construct(buttonItemStyle, actionId); + } + + // SetText + if (pControl->GetItemElement(i, "text", elementString)) + { + buttonItem.SetText(elementString); + } + + // buttonitem background bitmap path setting + // normal bg bitmap + if (pControl->GetItemElement(i, "normalBGBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmap); + } + + // pressed bg bitmap + if (pControl->GetItemElement(i, "pressedBGBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmap); + } + + // highlighted bg bitmap + if (pControl->GetItemElement(i, "highlightedBGBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_HIGHLIGHTED, pBitmap); + } + + // disabled bg bitmap + if (pControl->GetItemElement(i, "disabledBGBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_DISABLED, pBitmap); + } + + // buttonitem icon bitmap setting + if (pControl->GetItemElement(i, "normalIconPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + buttonItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmap); + } + + if (pControl->GetItemElement(i, "pressedIconPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + buttonItem.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmap); + } + + if (pControl->GetItemElement(i, "highlightedIconPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + buttonItem.SetIcon(BUTTON_ITEM_STATUS_HIGHLIGHTED, pBitmap); + } + + if (pControl->GetItemElement(i, "disabledIconPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + buttonItem.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmap); + } + + pFooter->SetButton(buttonPosition, buttonItem); + } + } + + return pFooter; + } + +private: + +}; + +_FooterRegister::_FooterRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"Footer", _FooterMaker::GetInstance); +} + +_FooterRegister::~_FooterRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"Footer"); +} + +static _FooterRegister FooterRegisterToUiBuilder; + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FooterItemImpl.cpp b/src/ui/controls/FUiCtrl_FooterItemImpl.cpp new file mode 100644 index 0000000..e4cc5e3 --- /dev/null +++ b/src/ui/controls/FUiCtrl_FooterItemImpl.cpp @@ -0,0 +1,160 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_FooterItemImpl.cpp +* @brief This is the implementation file for _FooterItemImpl class. +*/ + +#include +#include "FUiCtrl_FooterItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_FooterItemImpl::_FooterItemImpl(FooterItem* pPublic) + : __actionId(-1) + , __itemText(L"") +{ + for (int i = 0; i < FOOTER_ITEM_MAX_STATE_COUNT; i++) + { + __pIconBitmap[i] = null; + __pFooterItemBackgroundBitmap[i] = null; + } +} + +_FooterItemImpl::~_FooterItemImpl(void) +{ + for (int i = 0; i < FOOTER_ITEM_MAX_STATE_COUNT; i++) + { + __pIconBitmap[i] = null; + __pFooterItemBackgroundBitmap[i] = null; + } +} + +const _FooterItemImpl* +_FooterItemImpl::GetInstance(const FooterItem& footerItem) +{ + return static_cast (footerItem.__pImpl); +} + +_FooterItemImpl* +_FooterItemImpl::GetInstance(FooterItem& footerItem) +{ + return static_cast<_FooterItemImpl*> (footerItem.__pImpl); +} + +result +_FooterItemImpl::Construct(int actionId) +{ + SysTryReturnResult(NID_UI_CTRL, (actionId >= FOOTER_ITEM_ACTION_ID_MIN && actionId <= FOOTER_ITEM_ACTION_ID_MAX), + E_INVALID_ARG, "[E_INVALID_ARG] The actionId is invalid."); + + __actionId = actionId; + __itemText = String(L""); + + for (int i = 0; i < FOOTER_ITEM_MAX_STATE_COUNT; i++) + { + __pIconBitmap[i] = null; + __pFooterItemBackgroundBitmap[i] = null; + } + + return E_SUCCESS; +} + +int +_FooterItemImpl::GetActionId(void) const +{ + ClearLastResult(); + + return __actionId; +} + +const Bitmap* +_FooterItemImpl::GetBackgroundBitmap(FooterItemStatus status) const +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, (status >= FOOTER_ITEM_STATUS_NORMAL && status < FOOTER_ITEM_MAX_STATE_COUNT), null, E_INVALID_ARG, + "[E_INVALID_ARG] status is invalid."); + + return __pFooterItemBackgroundBitmap[status]; +} + +const Bitmap* +_FooterItemImpl::GetIcon(FooterItemStatus status) const +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, (status >= FOOTER_ITEM_STATUS_NORMAL && status < FOOTER_ITEM_MAX_STATE_COUNT), null, E_INVALID_ARG, + "[E_INVALID_ARG] status is invalid."); + + return __pIconBitmap[status]; +} + +String +_FooterItemImpl::GetText(void) const +{ + ClearLastResult(); + + return __itemText; +} + +result +_FooterItemImpl::SetActionId(int actionId) +{ + SysTryReturnResult(NID_UI_CTRL, (actionId >= FOOTER_ITEM_ACTION_ID_MIN && actionId <= FOOTER_ITEM_ACTION_ID_MAX), + E_INVALID_ARG, "[E_INVALID_ARG] The actionId is invalid."); + + __actionId = actionId; + + return E_SUCCESS; +} + +result +_FooterItemImpl::SetBackgroundBitmap(FooterItemStatus status, const Bitmap* pBitmap) +{ + SysTryReturnResult(NID_UI_CTRL, (status >= FOOTER_ITEM_STATUS_NORMAL && status < FOOTER_ITEM_MAX_STATE_COUNT), E_INVALID_ARG, + "[E_INVALID_ARG] status is invalid."); + + __pFooterItemBackgroundBitmap[status] = pBitmap; + + return E_SUCCESS; +} + +result +_FooterItemImpl::SetIcon(FooterItemStatus status, const Bitmap* pIcon) +{ + SysTryReturnResult(NID_UI_CTRL, (status >= FOOTER_ITEM_STATUS_NORMAL && status < FOOTER_ITEM_MAX_STATE_COUNT), E_INVALID_ARG, + "[E_INVALID_ARG] status is invalid."); + + __pIconBitmap[status] = pIcon; + + return E_SUCCESS; +} + +result +_FooterItemImpl::SetText(const String& text) +{ + __itemText = text; + + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Form.cpp b/src/ui/controls/FUiCtrl_Form.cpp new file mode 100644 index 0000000..892497e --- /dev/null +++ b/src/ui/controls/FUiCtrl_Form.cpp @@ -0,0 +1,2227 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Form.cpp + * @brief This is the implementation file for the _Form class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EcoreEvas.h" +#include "FUi_CoordinateSystemUtils.h" +#include "FUi_DataBindingContext.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityManager.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_FormPresenter.h" +#include "FUiCtrl_Toolbar.h" +#include "FUiCtrl_Tab.h" +#include "FUiCtrl_ActionEvent.h" +#include "FUiCtrl_OverlayRegionImpl.h" +#include "FUiCtrl_OverlayPanelImpl.h" +#include "FUiCtrl_IFormBackEventListener.h" +#include "FUiCtrl_Indicator.h" + +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui; +using namespace Tizen::Base; // Rotation +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_Form::_Form(void) + : __pFormPresenter(null) + , __pFormBackEventListener(null) + , __formStyle(0) + , __pActionEvent(null) + , __pHeader(null) + , __pFooter(null) + , __pTab(null) + , __pIndicator(null) + , __transparentIndicator(false) + , __transparentHeader(false) + , __transparentFooter(false) + , __transparentTab(false) + , __indicatorShowState(false) + , __deflated(false) + , __deflatedHeight(0) + , __overlayRegionCount(0) + , __ppOverlayerRegionImplArray(null) + , __softkeyCount(SOFTKEY_COUNT + 1) + , __updatedSoftkeyCount(0) +{ + Color color; + result r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color); + if (r == E_SUCCESS) + { + SetBackgroundColor(color); + } + else + { + SetBackgroundColor(0xff000000); + } + + _FormPresenter* pPresenter = new (std::nothrow) _FormPresenter(*this); + SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + SetPresenter(*pPresenter); + + for (int i = 0; i < __softkeyCount; i++) + { + __actionId[_SOFTKEY_0 + i] = 0; + __softkeyText[_SOFTKEY_0 + i] = String(); + __showSoftkey[_SOFTKEY_0 + i] = false; + __enableSoftkey[_SOFTKEY_0 + i] = false; + } + + for (int j = 0; j < SOFTKEY_COUNT+1; j++) + { + __pSoftkeyNormalBitmap[_SOFTKEY_0 + j] = null; + __pSoftkeyPressedBitmap[_SOFTKEY_0 + j] = null; + } + + for (int j = 0; j < SOFTKEY_COUNT+1; j++) + { + __pSoftkeyNormalEffectBitmap[_SOFTKEY_0 + j] = null; + __pSoftkeyPressedEffectBitmap[_SOFTKEY_0 + j] = null; + } + + for (int k = 0; k < SOFTKEY_COUNT; k++) + { + __pSoftkeyNormalIcon[_SOFTKEY_0 + k] = null; + __pSoftkeyPressedIcon[_SOFTKEY_0 + k] = null; + } + + //create data binding context + _DataBindingContext* pContext = new (std::nothrow) _DataBindingContext(*this); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pContext && GetLastResult() == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + SetDataBindingContext(pContext); + + ClearLastResult(); + GetAccessibilityContainer()->Activate(true); + return; + +CATCH: + delete pContext; +} + +_Form::~_Form(void) +{ + delete __pFormPresenter; + __pFormPresenter = null; + + if (__pActionEvent) + { + delete __pActionEvent; + __pActionEvent = null; + } + + for (int i = 0; i < SOFTKEY_COUNT+1 ; i++) + { + if (__pSoftkeyNormalBitmap[i]) + { + delete __pSoftkeyNormalBitmap[i]; + __pSoftkeyNormalBitmap[i] = null; + } + } + + for (int i = 0; i < SOFTKEY_COUNT+1 ; i++) + { + if (__pSoftkeyPressedBitmap[i]) + { + delete __pSoftkeyPressedBitmap[i]; + __pSoftkeyPressedBitmap[i] = null; + } + } + + for (int i = 0; i < SOFTKEY_COUNT+1 ; i++) + { + if (__pSoftkeyNormalEffectBitmap[i]) + { + delete __pSoftkeyNormalEffectBitmap[i]; + __pSoftkeyNormalEffectBitmap[i] = null; + } + } + + for (int i = 0; i < SOFTKEY_COUNT+1 ; i++) + { + if (__pSoftkeyPressedEffectBitmap[i]) + { + delete __pSoftkeyPressedEffectBitmap[i]; + __pSoftkeyPressedEffectBitmap[i] = null; + } + } + + for (int i = 0; i < SOFTKEY_COUNT ; i++) + { + if (__pSoftkeyNormalIcon[i]) + { + delete __pSoftkeyNormalIcon[i]; + __pSoftkeyNormalIcon[i] = null; + } + + if (__pSoftkeyPressedIcon[i]) + { + delete __pSoftkeyPressedIcon[i]; + __pSoftkeyPressedIcon[i] = null; + } + } + + if (__ppOverlayerRegionImplArray != null) + { + int maxCount = OverlayRegion::GetMaxCount(); + + for (int i = 0; i < maxCount; i++) + { + if (__ppOverlayerRegionImplArray[i]) + { + OverlayRegion* _pOverlayRegion = __ppOverlayerRegionImplArray[i]->GetOverlayRegion(); + delete _pOverlayRegion; + } + } + + delete[] __ppOverlayerRegionImplArray; + } + + if (__pIndicator) + { + delete __pIndicator; + __pIndicator = null; + } + + ClearLastResult(); +} + +_Form* +_Form::CreateFormN(void) +{ + _Form* pForm = null; + + pForm = new (std::nothrow) _Form; + SysTryReturn(NID_UI_CTRL, pForm, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pForm->SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_INSENSITIVE); + + pForm->AcquireHandle(); + + SetLastResult(E_SUCCESS); + + return pForm; + +CATCH: + delete pForm; + + return null; +} + +result +_Form::SetPresenter(const _FormPresenter& formPresenter) +{ + __pFormPresenter = const_cast <_FormPresenter*>(&formPresenter); + + return E_SUCCESS; +} + +void +_Form::OnDraw(void) +{ + if (__pFormPresenter) + { + __pFormPresenter->Draw(); + } + + if (__formStyle & FORM_STYLE_SOFTKEY_0 || __formStyle & FORM_STYLE_SOFTKEY_1 || __formStyle & FORM_STYLE_OPTIONKEY) + { + if (__pFooter) + { + UpdateSoftkey(__formStyle); + } + } + if(unlikely((_AccessibilityManager::IsActivated()))) + { + _AccessibilityManager::GetInstance()->RequestAutoReading(); + } + return; +} + +void +_Form::SetFormBackEventListener(_IFormBackEventListener* pFormBackEventListener) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pFooter || __pHeader, E_INVALID_STATE, "[E_INVALID_STATE] Footer and Header aren't constructed."); + __pFormBackEventListener = pFormBackEventListener; + if (__pFooter) + { + __pFooter->SetBackEventListener(*this, ID_BACK_BUTTON); + } + if (__pHeader) + { + __pHeader->SetBackEventListener(*this, ID_BACK_BUTTON); + } + + SetLastResult(E_SUCCESS); +} + +unsigned long +_Form::GetFormStyle(void) const +{ + return __formStyle; +} + +_Toolbar* +_Form::GetFooter(void) const +{ + return __pFooter; +} + +_Toolbar* +_Form::GetHeader(void) const +{ + return __pHeader; +} + +_Tab* +_Form::GetTab(void) const +{ + return __pTab; +} + +_Indicator* +_Form::GetIndicator(void) const +{ + return __pIndicator; +} + +String +_Form::GetTitleText(void) const +{ + if (__pHeader && (__formStyle & FORM_STYLE_TITLE)) + { + return __pHeader->GetTitleText(); + } + else + { + return String(L""); + } +} + +HorizontalAlignment +_Form::GetTitleTextHorizontalAlignment(void) const +{ + if (__pHeader && (__formStyle & FORM_STYLE_TITLE)) + { + return __pHeader->GetTitleTextHorizontalAlignment(); + } + else + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] The title is not valid."); + return ALIGNMENT_LEFT; + } +} + +OverlayRegion* +_Form::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType) +{ + _OverlayRegionImpl* pOverlayRegionImpl = null; + OverlayRegion* pOverlayRegion = null; + Color bgColor(0, 0, 0, 0); + int idx = 0; + int maxCount = 0; + _OverlayPanel* pOverlayPanel = null; + result r = E_SYSTEM; + bool modified = false; + + ClearLastResult(); + + maxCount = OverlayRegion::GetMaxCount(); + SysTryReturn(NID_UI_CTRL, maxCount > 0, null, E_SYSTEM, "[E_SYSTEM] maxCount [%d] is invalid", maxCount); + + if (__ppOverlayerRegionImplArray == null) + { + __ppOverlayerRegionImplArray = new (std::nothrow) _OverlayRegionImpl*[maxCount]; + SysTryReturn(NID_UI_CTRL, __ppOverlayerRegionImplArray != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Can not allocate memory for the OverlayRegionList."); + + for (int i = 0; i < maxCount; i++) + { + __ppOverlayerRegionImplArray[i] = null; + } + __overlayRegionCount = 0; + } + + Rectangle clientRect(GetClientBounds()); + Point overlayPosition(clientRect.x + rect.x, clientRect.y + rect.y); + Rectangle overlayRect(overlayPosition.x, overlayPosition.y, rect.width, rect.height); + + Rectangle userPhyRect = _CoordinateSystemUtils::Transform(rect); + Rectangle devBounds = _CoordinateSystemUtils::Transform(overlayRect); + + SysLog(NID_UI_CTRL, "rect [%d, %d, %d, %d] ", rect.x, rect.y, rect.width, rect.height); + SysLog(NID_UI_CTRL, "userPhyRect [%d, %d, %d, %d] ", userPhyRect.x, userPhyRect.y, userPhyRect.width, userPhyRect.height); + SysLog(NID_UI_CTRL, "overlayRect [%d, %d, %d, %d]", overlayPosition.x, overlayPosition.y, rect.width, rect.height); + SysLog(NID_UI_CTRL, "devBounds [%d, %d, %d, %d]", devBounds.x, devBounds.y, devBounds.width, devBounds.height); + + // 1. width , height unit check + if (_OverlayRegionImpl::IsValidOverlayRect(overlayRect, devBounds, _CoordinateSystemUtils::Transform(clientRect), modified) != E_SUCCESS) + { + SysTryReturn(NID_UI_CTRL, 0, null, E_INVALID_ARG, "[E_INVALID_ARG] IsValidOverlayRect is failed!"); + } + + if (modified) + { + SysLog(NID_UI_CTRL, "devBounds modified [%d, %d, %d, %d]", devBounds.x, devBounds.y, devBounds.width, devBounds.height); + } + + // 2. check for using OverlayPanel simutaneously + for (idx = 0 ; idx < GetChildCount() ; idx++) + { + pOverlayPanel = dynamic_cast <_OverlayPanel*>(GetChild(idx)); + SysTryReturn(NID_UI_CTRL, pOverlayPanel == null, null, E_SYSTEM, "[E_SYSTEM] Using OverlayRegion mixed with OverlayPanel is not supported!"); + } + + // 3. find the empty slot idx + for (idx = 0; idx < maxCount; idx++) + { + if (__ppOverlayerRegionImplArray[idx] == null) + { + break; + } + } + + SysTryReturn(NID_UI_CTRL, idx < maxCount, null, E_SYSTEM, "[E_SYSTEM] already used permitted maximum number of OverlayRegion!"); + + // 4. make OverlayRegion object + pOverlayRegionImpl = new (std::nothrow) _OverlayRegionImpl(); + SysTryReturn(NID_UI_CTRL, pOverlayRegionImpl != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] failed to make the OverlayRegionImpl instance!"); + + r = pOverlayRegionImpl->Construct(this, regionType, overlayPosition, rect, devBounds); + if (r != E_SUCCESS) + { + delete pOverlayRegionImpl; + SysTryReturn(NID_UI_CTRL, 0, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + pOverlayRegion = pOverlayRegionImpl->CreateOverlayRegionN(); + if (pOverlayRegion == null) + { + delete pOverlayRegionImpl; + SysTryReturn(NID_UI_CTRL, 0, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + + __ppOverlayerRegionImplArray[idx] = pOverlayRegionImpl; + pOverlayRegionImpl->SetFormArrayIndex(idx); + + __overlayRegionCount++; + + SetLastResult(E_SUCCESS); + + return pOverlayRegion; +} + +int +_Form::GetOverlayRegionCount(void) const +{ + return __overlayRegionCount; +} + +void +_Form::MoveOverlayRegion(bool top) +{ + if (__ppOverlayerRegionImplArray == null) + { + return; + } + for (int i = 0; i < OverlayRegion::GetMaxCount(); i++) + { + if (__ppOverlayerRegionImplArray[i] != null) + { + if (top) + { + __ppOverlayerRegionImplArray[i]->GoForeground(); + } + else + { + __ppOverlayerRegionImplArray[i]->GoBackground(); + } + } + } +} + +void +_Form::CreateSoftkey(unsigned long formStyle) +{ + Bitmap* pTempBitmap = null; + Dimension softkeyDimension(0, 0); + Dimension softkeyDisplayDimension(0, 0); + Dimension optionkeyDimension(0, 0); + int softkeyTextSize = 0; + int leftSoftkeyLeftMargin = 0; + int rightSoftkeyLeftMargin = 0; + int softkeyTopMargin = 0; + Color softkeyNormalBackgroundColor; + Color softkeyPressedBackgroundColor; + Color softkeyNormalTextColor; + Color softkeyPressedTextColor; + Color softkeyNormalIconColor; + Color softkeyPressedIconColor; + + GET_DIMENSION_CONFIG(FOOTER::SOFTKEY_RECT, GetOrientation(), softkeyDimension); + GET_DIMENSION_CONFIG(FOOTER::SOFTKEY_DISPLAY_RECT_WITH_TEXT, GetOrientation(), softkeyDisplayDimension); + GET_DIMENSION_CONFIG(FOOTER::OPTIONKEY_RECT, GetOrientation(), optionkeyDimension); + GET_SHAPE_CONFIG(FOOTER::SOFTKEY_TEXT_SIZE, GetOrientation(), softkeyTextSize); + GET_SHAPE_CONFIG(FOOTER::SOFTKEY_0_LEFT_MARGIN, GetOrientation(), leftSoftkeyLeftMargin); + GET_SHAPE_CONFIG(FOOTER::SOFTKEY_1_LEFT_MARGIN, GetOrientation(), rightSoftkeyLeftMargin); + GET_SHAPE_CONFIG(FOOTER::SOFTKEY_TOP_MARGIN, GetOrientation(), softkeyTopMargin); + GET_COLOR_CONFIG(FOOTER::SOFTKEY_BG_NORMAL, softkeyNormalBackgroundColor); + GET_COLOR_CONFIG(FOOTER::SOFTKEY_BG_PRESSED, softkeyPressedBackgroundColor); + GET_COLOR_CONFIG(FOOTER::SOFTKEY_TEXT_NORMAL, softkeyNormalTextColor); + GET_COLOR_CONFIG(FOOTER::SOFTKEY_TEXT_PRESSED, softkeyPressedTextColor); + GET_COLOR_CONFIG(FOOTER::SOFTKEY_ICON_NORMAL, softkeyNormalIconColor); + GET_COLOR_CONFIG(FOOTER::SOFTKEY_ICON_PRESSED, softkeyPressedIconColor); + + result r = E_SUCCESS; + + if (__pFooter != null) + { + __pFooter->SetStyle(TOOLBAR_SOFTKEY); + } + + if (formStyle & FORM_STYLE_SOFTKEY_0) + { + r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_LEFT_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + if (__pSoftkeyNormalBitmap[_SOFTKEY_0]) + { + delete __pSoftkeyNormalBitmap[_SOFTKEY_0]; + __pSoftkeyNormalBitmap[_SOFTKEY_0] = null; + } + __pSoftkeyNormalBitmap[_SOFTKEY_0] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalBackgroundColor); + delete pTempBitmap; + + r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_LEFT_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + if (__pSoftkeyPressedBitmap[_SOFTKEY_0]) + { + delete __pSoftkeyPressedBitmap[_SOFTKEY_0]; + __pSoftkeyPressedBitmap[_SOFTKEY_0] = null; + } + __pSoftkeyPressedBitmap[_SOFTKEY_0] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedBackgroundColor); + delete pTempBitmap; + + r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_LEFT_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + if (__pSoftkeyNormalEffectBitmap[_SOFTKEY_0]) + { + delete __pSoftkeyNormalEffectBitmap[_SOFTKEY_0]; + __pSoftkeyNormalEffectBitmap[_SOFTKEY_0] = null; + } + __pSoftkeyNormalEffectBitmap[_SOFTKEY_0] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalBackgroundColor); + delete pTempBitmap; + + r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_LEFT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + if (__pSoftkeyPressedEffectBitmap[_SOFTKEY_0]) + { + delete __pSoftkeyPressedEffectBitmap[_SOFTKEY_0]; + __pSoftkeyPressedEffectBitmap[_SOFTKEY_0] = null; + } + __pSoftkeyPressedEffectBitmap[_SOFTKEY_0] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedBackgroundColor); + delete pTempBitmap; + + r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_ICON_ADD_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pSoftkeyNormalIcon[_SOFTKEY_0]) + { + delete __pSoftkeyNormalIcon[_SOFTKEY_0]; + __pSoftkeyNormalIcon[_SOFTKEY_0] = null; + } + __pSoftkeyNormalIcon[_SOFTKEY_0] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalIconColor); + + if (__pSoftkeyPressedIcon[_SOFTKEY_0]) + { + delete __pSoftkeyPressedIcon[_SOFTKEY_0]; + __pSoftkeyPressedIcon[_SOFTKEY_0] = null; + } + __pSoftkeyPressedIcon[_SOFTKEY_0] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedIconColor); + + delete pTempBitmap; + + _Button* pButton = _Button::CreateButtonN(); + + if (pButton) + { + pButton->SetSize(softkeyDimension); + pButton->SetTextSize(softkeyTextSize); + pButton->SetUserDefinedTextArea(Rectangle(leftSoftkeyLeftMargin, softkeyTopMargin, softkeyDisplayDimension.width, softkeyDisplayDimension.height)); + pButton->SetTextColor(_BUTTON_STATUS_NORMAL, softkeyNormalTextColor); + pButton->SetTextColor(_BUTTON_STATUS_PRESSED, softkeyPressedTextColor); + __pFooter->SetButton(LEFT_BUTTON, pButton); + } + } + + if (formStyle & FORM_STYLE_SOFTKEY_1) + { + r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_RIGHT_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + if (__pSoftkeyNormalBitmap[_SOFTKEY_1]) + { + delete __pSoftkeyNormalBitmap[_SOFTKEY_1]; + __pSoftkeyNormalBitmap[_SOFTKEY_1] = null; + } + __pSoftkeyNormalBitmap[_SOFTKEY_1] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalBackgroundColor); + delete pTempBitmap; + + r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_RIGHT_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + if (__pSoftkeyPressedBitmap[_SOFTKEY_1]) + { + delete __pSoftkeyPressedBitmap[_SOFTKEY_1]; + __pSoftkeyPressedBitmap[_SOFTKEY_1] = null; + } + __pSoftkeyPressedBitmap[_SOFTKEY_1] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedBackgroundColor); + delete pTempBitmap; + + r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_RIGHT_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + if (__pSoftkeyNormalEffectBitmap[_SOFTKEY_1]) + { + delete __pSoftkeyNormalEffectBitmap[_SOFTKEY_1]; + __pSoftkeyNormalEffectBitmap[_SOFTKEY_1] = null; + } + __pSoftkeyNormalEffectBitmap[_SOFTKEY_1] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalBackgroundColor); + delete pTempBitmap; + + r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_RIGHT_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + if (__pSoftkeyPressedEffectBitmap[_SOFTKEY_1]) + { + delete __pSoftkeyPressedEffectBitmap[_SOFTKEY_1]; + __pSoftkeyPressedEffectBitmap[_SOFTKEY_1] = null; + } + __pSoftkeyPressedEffectBitmap[_SOFTKEY_1] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedBackgroundColor); + delete pTempBitmap; + + r = GET_BITMAP_CONFIG_N(FOOTER::SOFTKEY_ICON_ZOOM_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pSoftkeyNormalIcon[_SOFTKEY_1]) + { + delete __pSoftkeyNormalIcon[_SOFTKEY_1]; + __pSoftkeyNormalIcon[_SOFTKEY_1] = null; + } + __pSoftkeyNormalIcon[_SOFTKEY_1] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalIconColor); + + if (__pSoftkeyPressedIcon[_SOFTKEY_1]) + { + delete __pSoftkeyPressedIcon[_SOFTKEY_1]; + __pSoftkeyPressedIcon[_SOFTKEY_1] = null; + } + __pSoftkeyPressedIcon[_SOFTKEY_1] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedIconColor); + + delete pTempBitmap; + + _Button* pButton = _Button::CreateButtonN(); + if (pButton) + { + pButton->SetSize(softkeyDimension); + pButton->SetTextSize(softkeyTextSize); + pButton->SetUserDefinedTextArea(Rectangle(rightSoftkeyLeftMargin, softkeyTopMargin, softkeyDisplayDimension.width, softkeyDisplayDimension.height)); + pButton->SetTextColor(_BUTTON_STATUS_NORMAL, softkeyNormalTextColor); + pButton->SetTextColor(_BUTTON_STATUS_PRESSED, softkeyPressedTextColor); + __pFooter->SetButton(RIGHT_BUTTON, pButton); + } + } + + if (formStyle & FORM_STYLE_OPTIONKEY) + { + r = GET_BITMAP_CONFIG_N(FOOTER::OPTIONKEY_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + if (__pSoftkeyNormalBitmap[SOFTKEY_COUNT]) + { + delete __pSoftkeyNormalBitmap[SOFTKEY_COUNT]; + __pSoftkeyNormalBitmap[SOFTKEY_COUNT] = null; + } + __pSoftkeyNormalBitmap[SOFTKEY_COUNT] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalBackgroundColor); + delete pTempBitmap; + + r = GET_BITMAP_CONFIG_N(FOOTER::OPTIONKEY_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + if (__pSoftkeyPressedBitmap[SOFTKEY_COUNT]) + { + delete __pSoftkeyPressedBitmap[SOFTKEY_COUNT]; + __pSoftkeyPressedBitmap[SOFTKEY_COUNT] = null; + } + __pSoftkeyPressedBitmap[SOFTKEY_COUNT] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedBackgroundColor); + delete pTempBitmap; + + r = GET_BITMAP_CONFIG_N(FOOTER::OPTIONKEY_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + if (__pSoftkeyNormalEffectBitmap[SOFTKEY_COUNT]) + { + delete __pSoftkeyNormalEffectBitmap[SOFTKEY_COUNT]; + __pSoftkeyNormalEffectBitmap[SOFTKEY_COUNT] = null; + } + __pSoftkeyNormalEffectBitmap[SOFTKEY_COUNT] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyNormalBackgroundColor); + delete pTempBitmap; + + r = GET_BITMAP_CONFIG_N(FOOTER::OPTIONKEY_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + if (__pSoftkeyPressedEffectBitmap[SOFTKEY_COUNT]) + { + delete __pSoftkeyPressedEffectBitmap[SOFTKEY_COUNT]; + __pSoftkeyPressedEffectBitmap[SOFTKEY_COUNT] = null; + } + __pSoftkeyPressedEffectBitmap[SOFTKEY_COUNT] = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), softkeyPressedBackgroundColor); + delete pTempBitmap; + + _Button* pButton = _Button::CreateButtonN(); + if (pButton) + { + pButton->SetSize(optionkeyDimension); + pButton->SetTextColor(_BUTTON_STATUS_NORMAL, softkeyNormalTextColor); + pButton->SetTextColor(_BUTTON_STATUS_PRESSED, softkeyPressedTextColor); + __pFooter->SetButton(MIDDLE_BUTTON, pButton); + } + } +} + +void +_Form::UpdateSoftkey(unsigned long formStyle) +{ + int softkeyIconGap = 3; + + if (__formStyle & FORM_STYLE_SOFTKEY_0)// && __updatedSoftkeyCount % 2 == 0) + { + if (__pFooter->GetButton(LEFT_BUTTON)) + { + __pFooter->GetButton(LEFT_BUTTON)->SetActionId(__actionId[_SOFTKEY_0]); + + if (__pSoftkeyNormalBitmap[_SOFTKEY_0]) + { + __pFooter->GetButton(LEFT_BUTTON)->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *__pSoftkeyNormalBitmap[_SOFTKEY_0]); + } + + if (__pSoftkeyNormalEffectBitmap[_SOFTKEY_0]) + { + __pFooter->GetButton(LEFT_BUTTON)->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *__pSoftkeyNormalEffectBitmap[_SOFTKEY_0]); + } + + if (__pSoftkeyPressedBitmap[_SOFTKEY_0]) + { + __pFooter->GetButton(LEFT_BUTTON)->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *__pSoftkeyPressedBitmap[_SOFTKEY_0]); + } + + if (__pSoftkeyPressedEffectBitmap[_SOFTKEY_0]) + { + __pFooter->GetButton(LEFT_BUTTON)->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *__pSoftkeyPressedEffectBitmap[_SOFTKEY_0]); + } + + if (__softkeyText[_SOFTKEY_0] != String()) + { + __pFooter->GetButton(LEFT_BUTTON)->SetText(__softkeyText[_SOFTKEY_0]); + + __pFooter->RearrangeItems(); + } + else + { + if (__pSoftkeyNormalIcon[_SOFTKEY_0]) + { + __pFooter->GetButton(LEFT_BUTTON)->SetBitmap(_BUTTON_STATUS_NORMAL, + Point((__pFooter->GetButton(LEFT_BUTTON)->GetSize().width - __pSoftkeyNormalIcon[_SOFTKEY_0]->GetWidth()) / 2, + (__pFooter->GetButton(LEFT_BUTTON)->GetSize().height - __pSoftkeyNormalIcon[_SOFTKEY_0]->GetHeight()) / 2 + softkeyIconGap), *__pSoftkeyNormalIcon[_SOFTKEY_0]); + } + + if (__pSoftkeyPressedIcon[_SOFTKEY_0]) + { + __pFooter->GetButton(LEFT_BUTTON)->SetBitmap(_BUTTON_STATUS_PRESSED, + Point((__pFooter->GetButton(LEFT_BUTTON)->GetSize().width - __pSoftkeyPressedIcon[_SOFTKEY_0]->GetWidth()) / 2, + (__pFooter->GetButton(LEFT_BUTTON)->GetSize().height - __pSoftkeyPressedIcon[_SOFTKEY_0]->GetHeight()) / 2 + softkeyIconGap), *__pSoftkeyPressedIcon[_SOFTKEY_0]); + } + } + } + } + + if (__formStyle & FORM_STYLE_SOFTKEY_1)// && __updatedSoftkeyCount % 2 == 0) + { + if (__pFooter->GetButton(RIGHT_BUTTON)) + { + __pFooter->GetButton(RIGHT_BUTTON)->SetActionId(__actionId[_SOFTKEY_1]); + + if (__pSoftkeyNormalBitmap[_SOFTKEY_1]) + { + __pFooter->GetButton(RIGHT_BUTTON)->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *__pSoftkeyNormalBitmap[_SOFTKEY_1]); + } + + if (__pSoftkeyNormalEffectBitmap[_SOFTKEY_1]) + { + __pFooter->GetButton(RIGHT_BUTTON)->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *__pSoftkeyNormalEffectBitmap[_SOFTKEY_1]); + } + + if (__pSoftkeyPressedBitmap[_SOFTKEY_1]) + { + __pFooter->GetButton(RIGHT_BUTTON)->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *__pSoftkeyPressedBitmap[_SOFTKEY_1]); + } + + if (__pSoftkeyPressedEffectBitmap[_SOFTKEY_1]) + { + __pFooter->GetButton(RIGHT_BUTTON)->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *__pSoftkeyPressedEffectBitmap[_SOFTKEY_1]); + } + + if (__softkeyText[_SOFTKEY_1] != String()) + { + __pFooter->GetButton(RIGHT_BUTTON)->SetText(__softkeyText[_SOFTKEY_1]); + + __pFooter->RearrangeItems(); + } + else + { + if (__pSoftkeyNormalIcon[_SOFTKEY_1]) + { + __pFooter->GetButton(RIGHT_BUTTON)->SetBitmap(_BUTTON_STATUS_NORMAL, + Point((__pFooter->GetButton(RIGHT_BUTTON)->GetSize().width - __pSoftkeyNormalIcon[_SOFTKEY_1]->GetWidth()) / 2, + (__pFooter->GetButton(RIGHT_BUTTON)->GetSize().height - __pSoftkeyNormalIcon[_SOFTKEY_1]->GetHeight()) / 2 + softkeyIconGap), *__pSoftkeyNormalIcon[_SOFTKEY_1]); + } + + if (__pSoftkeyPressedIcon[_SOFTKEY_1]) + { + __pFooter->GetButton(RIGHT_BUTTON)->SetBitmap(_BUTTON_STATUS_PRESSED, + Point((__pFooter->GetButton(RIGHT_BUTTON)->GetSize().width - __pSoftkeyPressedIcon[_SOFTKEY_1]->GetWidth()) / 2, + (__pFooter->GetButton(RIGHT_BUTTON)->GetSize().height - __pSoftkeyPressedIcon[_SOFTKEY_1]->GetHeight()) / 2 + softkeyIconGap), *__pSoftkeyPressedIcon[_SOFTKEY_1]); + } + } + } + } + + if (__formStyle & FORM_STYLE_OPTIONKEY)// && __updatedSoftkeyCount % 2 == 0) + { + if (__pFooter->GetButton(MIDDLE_BUTTON)) + { + __pFooter->GetButton(MIDDLE_BUTTON)->SetActionId(__actionId[SOFTKEY_COUNT]); + + if (__pSoftkeyNormalBitmap[SOFTKEY_COUNT]) + { + __pFooter->GetButton(MIDDLE_BUTTON)->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *__pSoftkeyNormalBitmap[SOFTKEY_COUNT]); + } + + if (__pSoftkeyPressedBitmap[SOFTKEY_COUNT]) + { + __pFooter->GetButton(MIDDLE_BUTTON)->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *__pSoftkeyPressedBitmap[SOFTKEY_COUNT]); + } + + if (__pSoftkeyNormalEffectBitmap[SOFTKEY_COUNT]) + { + __pFooter->GetButton(MIDDLE_BUTTON)->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *__pSoftkeyNormalEffectBitmap[SOFTKEY_COUNT]); + } + + if (__pSoftkeyPressedEffectBitmap[SOFTKEY_COUNT]) + { + __pFooter->GetButton(MIDDLE_BUTTON)->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *__pSoftkeyPressedEffectBitmap[SOFTKEY_COUNT]); + } + } + } + + //__updatedSoftkeyCount++; +} + +String +_Form::GetDescription(void) const +{ + String description = _Control::GetDescription(); + + String descriptionTemp(L""); + + descriptionTemp.Format(LOG_LEN_MAX, L"_Form: style(%d) transparent(%d %d %d %d) deflated(%d) deflatedHeight(%d) overlayRegionCount(%d) softkeyCount(%d) updatedSoftkeyCount(%d)", + __formStyle, __transparentIndicator, __transparentHeader, __transparentFooter, __transparentTab, __deflated, __deflatedHeight, + __overlayRegionCount, __softkeyCount, __updatedSoftkeyCount); + + description.Append(descriptionTemp); + + return description; +} + +Canvas* +_Form::GetClientAreaCanvasN(void) const +{ + Canvas* pCanvas = GetCanvasN(GetClientBounds()); + if ((pCanvas == null) || (GetLastResult() != E_SUCCESS)) + { + SysLog(NID_UI_CTRL, "[%s] Propagated.", GetErrorMessage(GetLastResult())); + delete pCanvas; + return null; + } + + return pCanvas; +} + +int +_Form::GetSoftkeyActionId(_Softkey softkey) const +{ + if (CheckSoftkey(softkey) == false) + { + return -1; + } + + return __actionId[softkey]; +} + +int +_Form::GetOptionkeyActionId(void) const +{ + if (HasOptionkey() == false) + { + return -1; + } + + return __actionId[SOFTKEY_COUNT]; +} + +String +_Form::GetSoftkeyText(_Softkey softkey) const +{ + if (CheckSoftkey(softkey) == false) + { + return String(L""); + } + + return __softkeyText[softkey]; +} + +void +_Form::SetFormStyle(unsigned long formStyle) +{ + result r = E_SUCCESS; + + __formStyle = formStyle; + + if (!__pIndicator) + { + __pIndicator = CreateIndicatorN(); + SysTryReturnVoidResult(NID_UI_CTRL, __pIndicator != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + int indicatorwidth = GetClientBounds().width; + int indicatorheight = 0; + + GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight); + + __pIndicator->SetBounds(Rectangle(0, 0, indicatorwidth, indicatorheight)); + r = AttachSystemChild(*__pIndicator); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } +} + +result +_Form::SetActionBarsTranslucent(unsigned long actionBars, bool translucent) +{ + SysTryReturn( + NID_UI_CTRL, + ((actionBars & FORM_ACTION_BAR_INDICATOR) || (actionBars & FORM_ACTION_BAR_HEADER) || + (actionBars & FORM_ACTION_BAR_FOOTER) || (actionBars & FORM_ACTION_BAR_TAB)), + E_INVALID_OPERATION, E_INVALID_OPERATION, + ("[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation.")); + + if ((!(__formStyle & FORM_STYLE_INDICATOR) && (actionBars & FORM_ACTION_BAR_INDICATOR)) + || (!(__formStyle & FORM_STYLE_HEADER) && (actionBars & FORM_ACTION_BAR_HEADER)) + || (!(__formStyle & FORM_STYLE_FOOTER) && (actionBars & FORM_ACTION_BAR_FOOTER)) + || (!(__formStyle & FORM_STYLE_TEXT_TAB) && (actionBars & FORM_ACTION_BAR_TAB))) + { + SysLog(NID_UI_CTRL, + "[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation."); + return E_INVALID_OPERATION; + } + + result r = E_SUCCESS; + + Color bgColor(0, 0, 0, 0); + if (actionBars & FORM_ACTION_BAR_INDICATOR) + { + if (translucent) + { + r = SetIndicatorOpacity(_INDICATOR_OPACITY_TRANSLUCENT); + } + else + { + r = SetIndicatorOpacity(_INDICATOR_OPACITY_OPAQUE); + } + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (actionBars & FORM_ACTION_BAR_HEADER) + { + if (IsHeaderTranslucent() != translucent) + { + if (__pHeader) + { + __pHeader->SetTransparent(translucent); + __transparentHeader = translucent; + } + } + } + + if (IsIndicatorTranslucent() != IsHeaderTranslucent()) + { + if (IsIndicatorTranslucent()) + { + r = SetIndicatorOpacity(_INDICATOR_OPACITY_OPAQUE); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + if (actionBars & FORM_ACTION_BAR_FOOTER) + { + if (IsFooterTranslucent() != translucent) + { + if (__pFooter) + { + __pFooter->SetTransparent(translucent); + __transparentFooter = translucent; + } + } + } + + AdjustClientBounds(); + + return E_SUCCESS; +} + +result +_Form::SetActionBarsVisible(unsigned long actionBars, bool visible) +{ + SysTryReturn( + NID_UI_CTRL, + ((actionBars & FORM_ACTION_BAR_INDICATOR) || (actionBars & FORM_ACTION_BAR_HEADER) || + (actionBars & FORM_ACTION_BAR_FOOTER)), + E_INVALID_OPERATION, + E_INVALID_OPERATION, + ("[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation. ")); + + if ((!(__formStyle & FORM_STYLE_INDICATOR) && (actionBars & FORM_ACTION_BAR_INDICATOR)) + || (!(__formStyle & FORM_STYLE_HEADER) && (actionBars & FORM_ACTION_BAR_HEADER)) + || (!(__formStyle & FORM_STYLE_FOOTER) && (actionBars & FORM_ACTION_BAR_FOOTER))) + { + SysLog(NID_UI_CTRL, "[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation."); + return E_INVALID_OPERATION; + } + + Rectangle bounds = GetBounds(); + SetBounds(bounds); + + if (actionBars & FORM_ACTION_BAR_INDICATOR) + { + SetIndicatorShowState(visible); + } + + if (actionBars & FORM_ACTION_BAR_HEADER) + { + if (IsHeaderVisible() != visible) + { + if (__pHeader) + { + if (visible == true) + { + int adjHeight = 0; + if (IsIndicatorVisible()) + { + Rectangle indicatorBounds = GetIndicatorBounds(); + adjHeight = indicatorBounds.height; + } + Rectangle bounds = __pHeader->GetBounds(); + bounds.y = adjHeight; + + SetHeaderBounds(bounds); + } + __pHeader->SetVisibleState(visible); + } + } + } + + if (actionBars & FORM_ACTION_BAR_FOOTER) + { + if (__pFooter) + { + __pFooter->SetVisibleState(visible); + } + } + + AdjustClientBounds(); + + return E_SUCCESS; +} + +result +_Form::SetTitleIcon(const Bitmap* pTitleBitmap) +{ + SysTryReturn(NID_UI_CTRL, (__formStyle & FORM_STYLE_TITLE), E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This API is only for FORM_STYLE_TITLE."); + + SysTryReturn(NID_UI_CTRL, __pHeader, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The title is not valid."); + + result r = __pHeader->SetTitleIcon(*pTitleBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_Form::SetTitleText(const String& title, HorizontalAlignment alignment) +{ + SysTryReturn(NID_UI_CTRL, (__formStyle & FORM_STYLE_TITLE), E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This API is only for FORM_STYLE_TITLE."); + + SysTryReturn(NID_UI_CTRL, __pHeader, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The title is not valid."); + + result r = __pHeader->SetTitleText(title, alignment); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_Form::SetSoftkeyEnabled(_Softkey softkey, bool enable) +{ + result r = E_SYSTEM; + + if (CheckSoftkey(softkey) == false) + { + return r; + } + + __enableSoftkey[softkey] = enable; + + r = E_SUCCESS; + + return r; +} + +result +_Form::SetOptionkeyActionId(int actionId) +{ + result r = E_SYSTEM; + + if (HasOptionkey() == false) + { + return r; + } + + __actionId[SOFTKEY_COUNT] = actionId; + + r = E_SUCCESS; + + return r; +} + +result +_Form::SetSoftkeyActionId(_Softkey softkey, int actionId) +{ + result r = E_SYSTEM; + + if (CheckSoftkey(softkey) == false) + { + return r; + } + + __actionId[softkey] = actionId; + + r = E_SUCCESS; + + return r; +} + +result +_Form::SetSoftkeyText(_Softkey softkey, const String& text) +{ + result r = E_SYSTEM; + + if (CheckSoftkey(softkey) == false) + { + return r; + } + + __softkeyText[softkey] = text; + + r = E_SUCCESS; + + return r; +} + +result +_Form::SetSoftkeyIcon(_Softkey softkey, const Bitmap& normalBitmap, const Bitmap* pPressedBitmap) +{ + result r = E_SYSTEM; + + if (CheckSoftkey(softkey) == false) + { + return r; + } + + int softkey_icon_size = 0; + + GET_SHAPE_CONFIG(FOOTER::SOFTKEY_ICON_SIZE, GetOrientation(), softkey_icon_size); + + Bitmap* pClonedNormalBitmap = _BitmapImpl::CloneN(normalBitmap); + + if (pClonedNormalBitmap) + { + if (__pSoftkeyNormalIcon[softkey] != null) + { + delete __pSoftkeyNormalIcon[softkey]; + } + + __pSoftkeyNormalIcon[softkey] = pClonedNormalBitmap; + + __pSoftkeyNormalIcon[softkey]->Scale(Dimension(softkey_icon_size, softkey_icon_size)); + + r = E_SUCCESS; + } + + if (pPressedBitmap != null) + { + Bitmap* pClonedPressedBitmap = _BitmapImpl::CloneN(*pPressedBitmap); + + if (pClonedPressedBitmap) + { + if (__pSoftkeyPressedIcon[softkey] != null) + { + delete __pSoftkeyPressedIcon[softkey]; + } + + __pSoftkeyPressedIcon[softkey] = pClonedPressedBitmap; + + __pSoftkeyPressedIcon[softkey]->Scale(Dimension(softkey_icon_size, softkey_icon_size)); + + r = E_SUCCESS; + } + } + + return r; +} + +bool +_Form::HasFooter(void) const +{ + if (__pFooter) + { + return true; + } + else + { + return false; + } +} + +bool +_Form::HasHeader(void) const +{ + if (__pHeader) + { + return true; + } + else + { + return false; + } +} + +bool +_Form::HasIndicator(void) const +{ + if (__pIndicator && (GetFormStyle() & FORM_STYLE_INDICATOR)) + { + return true; + } + else + { + return false; + } +} + +bool +_Form::HasTitle(void) const +{ + if (__pHeader && (__formStyle & FORM_STYLE_TITLE)) + { + return true; + } + else + { + return false; + } +} + +bool +_Form::HasTab(void) const +{ + if ((__pTab && (__formStyle & FORM_STYLE_TEXT_TAB)) +|| (__pTab && (__formStyle & FORM_STYLE_ICON_TAB))) + { + return true; + } + else + { + return false; + } +} + +bool +_Form::IsIndicatorVisible(void) const +{ + _Control* pParent = GetParent(); + _Frame* pFrame = dynamic_cast<_Frame*>(pParent); + + bool visible = true; + + if (pFrame && IsAttachedToMainTree()) + { + visible = __pIndicator->GetIndicatorShowState(); + SysTryReturn(NID_UI_CTRL, GetLastResult() == E_SUCCESS, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + else + { + visible = __indicatorShowState; + } + + return visible; +} + +bool +_Form::IsHeaderVisible(void) const +{ + if (__pHeader) + { + return __pHeader->IsVisible(); + } + else + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] The header is not valid."); + return false; + } +} + +bool +_Form::IsFooterVisible(void) const +{ + if (__pFooter) + { + return __pFooter->IsVisible(); + } + else + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] The footer is not valid."); + return false; + } +} + +bool +_Form::IsIndicatorTranslucent(void) const +{ + _Control* pParent = GetParent(); + _Frame* pFrame = dynamic_cast<_Frame*>(pParent); + + _IndicatorOpacity opacity = _INDICATOR_OPACITY_UNKNOWN; + + bool transparent = false; + + if (pFrame && IsAttachedToMainTree()) + { + FrameShowMode mode = pFrame->GetShowMode(); + if (mode == FRAME_SHOW_MODE_FULL_SCREEN) + { + opacity = __pIndicator->GetIndicatorOpacity(); + SysTryReturn(NID_UI_CTRL, GetLastResult() == E_SUCCESS, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (opacity == _INDICATOR_OPACITY_TRANSLUCENT) + { + transparent = true; + } + else if (opacity == _INDICATOR_OPACITY_OPAQUE) + { + transparent = false; + } + } + } + else + { + transparent = __transparentIndicator; + } + + return transparent; +} + +bool +_Form::IsHeaderTranslucent(void) const +{ + return __transparentHeader; +} + +bool +_Form::IsFooterTranslucent(void) const +{ + return __transparentFooter; +} + +bool +_Form::IsTabTranslucent(void) const +{ + return __transparentTab; +} + +bool +_Form::HasOptionkey(void) const +{ + if (GetFormStyle() & FORM_STYLE_OPTIONKEY) + { + return true; + } + else + { + return false; + } +} + +bool +_Form::HasSoftkey(_Softkey softkey) const +{ + unsigned long __formStyle = FORM_STYLE_NORMAL; + + if (softkey == _SOFTKEY_0) + { + __formStyle = FORM_STYLE_SOFTKEY_0; + } + else if (softkey == _SOFTKEY_1) + { + __formStyle = FORM_STYLE_SOFTKEY_1; + } + else + { + return false; + } + + if (GetFormStyle() & __formStyle) + { + return true; + } + else + { + return false; + } +} + +bool +_Form::IsSoftkeyEnabled(_Softkey softkey) const +{ + if (CheckSoftkey(softkey) == false) + { + return false; + } + + return __enableSoftkey[softkey]; +} + +bool +_Form::CheckSoftkey(_Softkey softkey) const +{ + bool result = true; + + if (HasSoftkey(softkey) == false) + { + return false; + } + + if (softkey >= _SOFTKEY_COUNT) + { + return false; + } + + return result; +} + +bool +_Form::IsOrientationRoot(void) const +{ + return true; +} + +Point +_Form::TranslateToClientAreaPosition(const Point& position) const +{ + Rectangle clientArea = GetClientBounds(); + return Point(position.x - clientArea.x, position.y - clientArea.y); +} + +Point +_Form::TranslateFromClientAreaPosition(const Point& clientPosition) const +{ + Rectangle clientArea = GetClientBounds(); + return Point(clientPosition.x + clientArea.x, clientPosition.y + clientArea.y); +} + +bool +_Form::DeflateClientRectHeight(int height) +{ + if ( height > 0) + { + __deflated = true; + } + else + { + __deflated = false; + } + + __deflatedHeight = height; + + AdjustClientBounds(); + + if (__pFooter) + { + int adjHeight = 0; + + if (!(__pFooter->GetVisibleState()) || IsFooterTranslucent()) + { + adjHeight = GetToolbarHeight(false); + } + + Rectangle bounds(0, GetClientBounds().y + GetClientBounds().height-adjHeight, + GetClientBounds().width, GetToolbarHeight(false)); + SetFooterBounds(bounds); + } + + return true; +} + +_Toolbar* +_Form::CreateHeaderN(void) +{ + _Toolbar* __pHeader = _Toolbar::CreateToolbarN(true); + SysTryReturn(NID_UI_CTRL, __pHeader, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return __pHeader; +} + +_Toolbar* +_Form::CreateFooterN(void) +{ + _Toolbar* __pFooter = _Toolbar::CreateToolbarN(false); + SysTryReturn(NID_UI_CTRL, __pFooter, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return __pFooter; +} + +_Tab* +_Form::CreateTabN(void) +{ + _Tab* __pTab = _Tab::CreateTabN(); + SysTryReturn(NID_UI_CTRL, __pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return __pTab; +} + +_Indicator* +_Form::CreateIndicatorN(void) +{ + _Indicator* pIndicator = new (std::nothrow) _Indicator; + SysTryReturn(NID_UI_CTRL, pIndicator, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return pIndicator; +} + +int +_Form::GetToolbarHeight(bool header) const +{ + int toolbarHeight = 0; + + if (header && (__formStyle & FORM_STYLE_HEADER)) + { + if (__pHeader) + { + toolbarHeight = __pHeader->GetBounds().height; + } + } + else if (header && (__formStyle & FORM_STYLE_TITLE)) + { + GET_SHAPE_CONFIG(HEADER::HEIGHT, GetOrientation(), toolbarHeight); + } + else if (__formStyle & FORM_STYLE_SOFTKEY_0 || __formStyle & FORM_STYLE_SOFTKEY_1 || __formStyle & FORM_STYLE_OPTIONKEY) + { + GET_SHAPE_CONFIG(FOOTER::SOFTKEY_HEIGHT, GetOrientation(), toolbarHeight); + } + else + { + if (__pFooter) + { + toolbarHeight = __pFooter->GetBounds().height; + } + + //GET_SHAPE_CONFIG(L"FOOTER_HEIGHT", GetOrientation(), toolbarHeight); + } + + return toolbarHeight; +} + +int +_Form::GetTabHeight(void) const +{ + int height = 0; + + if ((__formStyle & FORM_STYLE_TEXT_TAB) || (__formStyle & FORM_STYLE_ICON_TAB)) + { + GET_SHAPE_CONFIG(TAB::HEIGHT, GetOrientation(), height); + } + + return height; +} + +bool +_Form::RemoveHeader(void) +{ + result r = E_SUCCESS; + if (__pHeader) + { + r = DetachSystemChild(*__pHeader); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + __pHeader = null; + + AdjustClientBounds(); + } + else + { + return false; + } + + return true; +} + +bool +_Form::RemoveFooter(void) +{ + result r = E_SUCCESS; + if (__pFooter) + { + r = DetachSystemChild(*__pFooter); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + __pFooter = null; + + AdjustClientBounds(); + } + else + { + return false; + } + + return true; +} + +bool +_Form::RemoveTab(void) +{ + result r = E_SUCCESS; + if (__pTab) + { + r = DetachSystemChild(*__pTab); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + __pTab = null; + + AdjustClientBounds(); + } + else + { + return false; + } + + return true; +} + +bool +_Form::RemoveIndicator(void) +{ + result r = E_SUCCESS; + if (__pIndicator) + { + r = DetachSystemChild(*__pIndicator); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + __pIndicator = null; + } + else + { + return false; + } + + return true; +} + +result +_Form::SetHeaderBounds(Rectangle& bounds) +{ + SysTryReturn(NID_UI_CTRL, __pHeader, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Header isn't constructed."); + + bool movable = __pHeader->IsMovable(); + bool resizable = __pHeader->IsResizable(); + + __pHeader->SetMovable(true); + __pHeader->SetResizable(true); + + result r = E_SUCCESS; + r = __pHeader->SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHeader->SetMovable(movable); + __pHeader->SetResizable(resizable); + + AdjustClientBounds(); + + return r; +} + +result +_Form::SetHeaderFloatBounds(FloatRectangle& bounds) +{ + SysTryReturn(NID_UI_CTRL, __pHeader, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Header isn't constructed."); + + bool movable = __pHeader->IsMovable(); + bool resizable = __pHeader->IsResizable(); + + __pHeader->SetMovable(true); + __pHeader->SetResizable(true); + + result r = E_SUCCESS; + r = __pHeader->SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHeader->SetMovable(movable); + __pHeader->SetResizable(resizable); + + AdjustClientBounds(); + + return r; +} + +result +_Form::SetFooterBounds(Rectangle& bounds) +{ + SysTryReturn(NID_UI_CTRL, __pFooter, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed."); + + bool movable = __pFooter->IsMovable(); + bool resizable = __pFooter->IsResizable(); + + __pFooter->SetMovable(true); + __pFooter->SetResizable(true); + + result r = E_SUCCESS; + r = __pFooter->SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pFooter->SetMovable(movable); + __pFooter->SetResizable(resizable); + + AdjustClientBounds(); + + return r; +} + +result +_Form::SetTabBounds(Rectangle& bounds) +{ + SysTryReturn(NID_UI_CTRL, __pTab, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Tab isn't constructed."); + + bool movable = __pTab->IsMovable(); + bool resizable = __pTab->IsResizable(); + + __pTab->SetMovable(true); + __pTab->SetResizable(true); + + result r = E_SUCCESS; + r = __pTab->SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTab->SetMovable(movable); + __pTab->SetResizable(resizable); + + AdjustClientBounds(); + + return r; +} + +result +_Form::AddActionEventListener(_IActionEventListener& listener) +{ + if (__pActionEvent == null) + { + __pActionEvent = _ActionEvent::CreateInstanceN(*this); + + SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.") + } + + result r = __pActionEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +_Form::AddOptionkeyActionListener(_IActionEventListener& listener) +{ + if (HasOptionkey() == false) + { + return ; + } +} + +void +_Form::AddSoftkeyActionListener(_Softkey softkey, _IActionEventListener& listener) +{ + if (CheckSoftkey(softkey) == false) + { + return ; + } +} + +result +_Form::RemoveActionEventListener(_IActionEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pActionEvent, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This instance isn't constructed.") + // Todo : check fail case of RemoveListener + result r = __pActionEvent->RemoveListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +_Form::RemoveOptionkeyActionListener(_IActionEventListener& listener) +{ + if (HasOptionkey() == false) + { + return ; + } +} + +void +_Form::RemoveSoftkeyActionListener(_Softkey softkey, _IActionEventListener& listener) +{ + if (CheckSoftkey(softkey) == false) + { + return ; + } +} + +void +_Form::OnActionPerformed(const _Control& source, int actionId) +{ + switch (actionId) + { + case ID_BACK_BUTTON: + if (__pFormBackEventListener) + { + __pFormBackEventListener->OnFormBackRequested(*this); + } + break; + + default: + break; + } +} + +void +_Form::OnChildVisibleStateChanged(const _Control& child) +{ + if (IsHeaderVisible()) + { + int adjHeight = 0; + if (IsIndicatorVisible()) + { + Rectangle indicatorBounds = GetIndicatorBounds(); + adjHeight = indicatorBounds.height; + } + Rectangle bounds = __pHeader->GetBounds(); + bounds.y = adjHeight; + SetHeaderBounds(bounds); + } + + AdjustClientBounds(); +} + +Rectangle +_Form::GetIndicatorBounds(void) const +{ + _Control* pParent = GetParent(); + _Frame* pFrame = dynamic_cast<_Frame*>(pParent); + + if (pFrame) + { + FrameShowMode mode = pFrame->GetShowMode(); + if (mode != FRAME_SHOW_MODE_FULL_SCREEN) + { + return Rectangle(0, 0, 0, 0); + } + } + + int indicatorwidth = GetClientBounds().width; + int indicatorheight = 0; + + GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight); + + Rectangle rect (0, 0, indicatorwidth, indicatorheight); + + SetLastResult(E_SUCCESS); + + return rect; +} + +FloatRectangle +_Form::GetIndicatorFloatBounds(void) const +{ + _Control* pParent = GetParent(); + _Frame* pFrame = dynamic_cast<_Frame*>(pParent); + + if (pFrame) + { + FrameShowMode mode = pFrame->GetShowMode(); + if (mode != FRAME_SHOW_MODE_FULL_SCREEN) + { + return FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); + } + } + + int indicatorwidth = GetClientBounds().width; + int indicatorheight = 0; + + GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight); + + Rectangle rect (0, 0, indicatorwidth, indicatorheight); + + Tizen::Graphics::FloatRectangle outputRect(rect.x, rect.y, rect.width, rect.height); + + SetLastResult(E_SUCCESS); + + return outputRect; +} + +void +_Form::SetHeader(_Toolbar* pToolbar) +{ + __pHeader = pToolbar; +} + +void +_Form::SetFooter(_Toolbar* pToolbar) +{ + __pFooter = pToolbar; +} + +void +_Form::SetTab(_Tab* pTab) +{ + __pTab = pTab; +} + +void +_Form::SetTabStyle(int style) +{ + __pTab->SetStyle(style); +} + +result +_Form::SetIndicatorShowState(bool state) +{ + result r = E_SUCCESS; + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturn(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get evas"); + + _Control* pParent = GetParent(); + if (!pParent) + { + pParent = const_cast<_Control*>(pEcoreEvas->GetFrame()); + } + _Frame* pFrame = dynamic_cast<_Frame*>(pParent); + + if (pFrame && IsAttachedToMainTree()) + { + FrameShowMode mode = pFrame->GetShowMode(); + if (mode == FRAME_SHOW_MODE_FULL_SCREEN) + { + r = __pIndicator->SetIndicatorShowState(state); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = __pIndicator->SetIndicatorShowState(false); + return r; + } + } + else if (!pFrame && IsAttachedToMainTree()) + { + r = __pIndicator->SetIndicatorShowState(false); + } + + __indicatorShowState = state; + + return r; +} + +result +_Form::SetIndicatorOpacity(_IndicatorOpacity opacity) +{ + result r = E_SUCCESS; + + _Control* pParent = GetParent(); + _Frame* pFrame = dynamic_cast<_Frame*>(pParent); + + if (pFrame && IsAttachedToMainTree()) + { + FrameShowMode mode = pFrame->GetShowMode(); + if (mode == FRAME_SHOW_MODE_FULL_SCREEN) + { + r = __pIndicator->SetIndicatorOpacity(opacity); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + if (opacity == _INDICATOR_OPACITY_TRANSLUCENT) + { + __transparentIndicator = true; + } + else if (opacity == _INDICATOR_OPACITY_OPAQUE) + { + __transparentIndicator = false; + } + + return r; +} + +result +_Form::AddIndicatorObject(void) +{ + result r = E_SUCCESS; + + if (__pIndicator) + { + r = __pIndicator->AddEvasObject(this); + } + + return r; +} + +result +_Form::DeleteIndicatorObject(void) +{ + result r = E_SUCCESS; + if (__pIndicator) + { + r = __pIndicator->DeleteEvasObject(); + } + + return r; +} + +result +_Form::AttachedToMainTree(void) +{ + _Frame* pFrame = dynamic_cast<_Frame*>(GetParent()); + if (pFrame != null) + { + FrameShowMode mode = pFrame->GetShowMode(); + if (mode != FRAME_SHOW_MODE_FULL_SCREEN) + { + SetBounds(Rectangle(0, 0, pFrame->GetBounds().width, pFrame->GetBounds().height)); + } + } + + result r = E_SUCCESS; + + if (FORM_STYLE_INDICATOR & GetFormStyle()) + { + AddIndicatorObject(); + + if (__indicatorShowState != IsIndicatorVisible()) + { + SetIndicatorShowState(__indicatorShowState); + } + + if (__transparentIndicator != IsIndicatorTranslucent()) + { + if (__transparentIndicator == true) + { + SetIndicatorOpacity(_INDICATOR_OPACITY_TRANSLUCENT); + } + else + { + SetIndicatorOpacity(_INDICATOR_OPACITY_OPAQUE); + } + } + + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = SetIndicatorShowState(false); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_Form::DetachingFromMainTree(void) +{ + result r = E_SUCCESS; + r = DeleteIndicatorObject(); + return r; +} + +result +_Form::AdjustClientBounds(void) +{ + result r = E_SUCCESS; + + Dimension size = GetSize(); + Rectangle clientBounds(0, 0, size.width, size.height); + + if (__deflated) + { + clientBounds.height -= __deflatedHeight; + } + + Rectangle indicatorBounds = GetIndicatorBounds(); + + _Control* pParent = GetParent(); + _Frame* pFrame = dynamic_cast<_Frame*>(pParent); + if (pFrame) + { + FrameShowMode mode = pFrame->GetShowMode(); + if (mode == FRAME_SHOW_MODE_FULL_SCREEN) + { + if (FORM_STYLE_INDICATOR & __formStyle) + { + if (IsIndicatorVisible() && !IsIndicatorTranslucent()) + { + clientBounds.y += indicatorBounds.height; + clientBounds.height -= indicatorBounds.height; + } + } + } + } + else + { + if (FORM_STYLE_INDICATOR & __formStyle) + { + if (IsIndicatorVisible() && !IsIndicatorTranslucent()) + { + clientBounds.y += indicatorBounds.height; + clientBounds.height -= indicatorBounds.height; + } + } + } + + if (__pHeader) + { + if (__pHeader->GetVisibleState() && !IsHeaderTranslucent()) + { + clientBounds.y += GetToolbarHeight(true); + clientBounds.height -= GetToolbarHeight(true); + } + } + + if (__pTab) + { + if (__pTab->GetVisibleState()) //&& !IsHeaderTranslucent()) + { + clientBounds.y += GetTabHeight(); + clientBounds.height -= GetTabHeight(); + } + } + + if (__pFooter) + { + if (FORM_STYLE_FOOTER & __formStyle || FORM_STYLE_SOFTKEY_0 & __formStyle || FORM_STYLE_SOFTKEY_1 & __formStyle + || FORM_STYLE_OPTIONKEY & __formStyle) + { + if (__pFooter->GetVisibleState() && !IsFooterTranslucent()) + { + clientBounds.height -= GetToolbarHeight(false); + } + } + } + + if (clientBounds.height < 0) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] The Client bounds is not valid. : client height(%d), indicator height(%d), header height(%d), footer height(%d)", + clientBounds.height, indicatorBounds.height, GetToolbarHeight(true), GetToolbarHeight(false)); + } + + SetClientBounds(clientBounds); + + return r; + +} + +void +_Form::OnBoundsChanged(void) +{ + Rectangle toolbarBounds; + FloatRectangle indicatorFloatBounds(0.0f, 0.0f, 0.0f, 0.0f); + + int indicatorheight = 0; + + GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight); + if (__pIndicator) + __pIndicator->SetBounds(Rectangle(0, 0, GetClientBounds().width, indicatorheight)); + AdjustClientBounds(); + + if (HasHeader()) + { + indicatorFloatBounds = GetIndicatorFloatBounds(); + + toolbarBounds = GetHeader()->GetBounds(); + toolbarBounds.width = GetSize().width; + + FloatRectangle bounds(toolbarBounds.x, indicatorFloatBounds.height, toolbarBounds.width, toolbarBounds.height); + SetHeaderFloatBounds(bounds); + } + + if (HasFooter()) + { + toolbarBounds = GetFooter()->GetBounds(); + toolbarBounds.width = GetSize().width; + toolbarBounds.y = GetSize().height - toolbarBounds.height; + SetFooterBounds(toolbarBounds); + } + + if (HasTab()) + { + toolbarBounds = GetTab()->GetBounds(); + toolbarBounds.width = GetSize().width; + SetTabBounds(toolbarBounds); + } + + AdjustClientBounds(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FormImpl.cpp b/src/ui/controls/FUiCtrl_FormImpl.cpp new file mode 100644 index 0000000..6696768 --- /dev/null +++ b/src/ui/controls/FUiCtrl_FormImpl.cpp @@ -0,0 +1,1748 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_LayoutImpl.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EcoreEvas.h" +#include "FUi_ControlImplManager.h" +#include "FUi_OrientationAgent.h" +#include "FUi_UiBuilder.h" +#include "FUi_CoordinateSystemUtils.h" +#include "FUi_DataBindingContextImpl.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_FormImpl.h" +#include "FUiCtrl_HeaderImpl.h" +#include "FUiCtrl_FooterImpl.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_TabImpl.h" +#include "FUiCtrl_Indicator.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +#define OPTIONKEY SOFTKEY_COUNT + +namespace Tizen { namespace Ui { namespace Controls +{ + +Dimension +_FormImpl::FormSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Dimension dimension(0, 0); + SetLastResult(r); + + return dimension; +} + +const _FormImpl* +_FormImpl::GetInstance(const Form& form) +{ + return static_cast (form._pControlImpl); +} + +_FormImpl* +_FormImpl::GetInstance(Form& form) +{ + return static_cast<_FormImpl*> (form._pControlImpl); +} + +_FormImpl::_FormImpl(Form* pPublic, _Form* pCore, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout) + : _ContainerImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout) + , __pForm(null) + , __pFormBackEventListener(null) + , __pOriAgent(null) + , __pLeftSoftkeyActionEvent(null) + , __pRightSoftkeyActionEvent(null) + , __pOptionMenuActionEvent(null) +{ + __pForm = pCore; + + __pOriAgent = _OrientationAgent::CreateInstanceN(*pPublic); + SysTryReturnVoidResult(NID_UI_CTRL, __pOriAgent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +_FormImpl::~_FormImpl(void) +{ + delete __pOriAgent; + __pOriAgent = null; + + if (__pLeftSoftkeyActionEvent) + { + delete __pLeftSoftkeyActionEvent; + __pLeftSoftkeyActionEvent = null; + } + + if (__pRightSoftkeyActionEvent) + { + delete __pRightSoftkeyActionEvent; + __pRightSoftkeyActionEvent = null; + } + + if (__pOptionMenuActionEvent) + { + delete __pOptionMenuActionEvent; + __pOptionMenuActionEvent = null; + } + + __leftSoftkeyActionList.RemoveAll(false); + __rightSoftkeyActionList.RemoveAll(false); + + RemoveHeader(); + RemoveFooter(); + RemoveTabImpl(); + + __pForm = null; + + ClearLastResult(); +} + +_FormImpl* +_FormImpl::CreateFormImplN(Form* pControl, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout) +{ + result r = E_SUCCESS; + _VisualElement* pVisualElement = null; + + _Form* pCore = _Form::CreateFormN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); // [ToDo] interpret last result. + + _FormImpl* pImpl = new (std::nothrow) _FormImpl(pControl, pCore, pPublicPortraitLayout, pPublicLandscapeLayout); + + r = _ControlImpl::CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize(); + const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width); + + _ControlOrientation orientation = pCore->GetOrientation(); + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Form), portraitSize, orientation); + } + else + { + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Form), landscapeSize, orientation); + } + SysAssert(r == E_SUCCESS); + + // Make surface opaque. + pVisualElement = pCore->GetVisualElement(); + SysTryCatch(NID_UI_CTRL, pVisualElement, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + r = pVisualElement->SetSurfaceOpaque(true); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); // [ToDo] interpret last result. + + SetLastResult(E_SUCCESS); + + return pImpl; + +CATCH: + delete pCore; + delete pImpl; + + return null; +} + +const char* +_FormImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::Form"; +} + +const Form& +_FormImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +Form& +_FormImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _Form& +_FormImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_Form& +_FormImpl::GetCore(void) +{ + return static_cast<_Form&>(_ControlImpl::GetCore()); +} + +_ControlImpl* +_FormImpl::GetFocusControl(void) +{ + return null; +} + +unsigned long +_FormImpl::GetFormStyle(void) const +{ + return GetCore().GetFormStyle(); +} + +bool +_FormImpl::HasIndicator(void) const +{ + return GetCore().HasIndicator(); +} + +void +_FormImpl::SetFormStyle(unsigned long formStyle) +{ + result r = E_SUCCESS; + + _HeaderImpl* pHeader = GetHeader(); + _FooterImpl* pFooter = GetFooter(); + _TabImpl* pTabImpl = GetTabImpl(); + + if (IsAttachedToMainTree()) + { + if (FORM_STYLE_INDICATOR & formStyle) + { + _Frame* pFrame = dynamic_cast<_Frame*>(GetCore().GetParent()); + SysTryReturnVoidResult(NID_UI_CTRL, pFrame != null, E_INVALID_ARG, "A Form which has FORM_STYLE_INDICATOR style cannot be added to a container except Frame."); + } + } + + // check formstyle + if (((formStyle & FORM_STYLE_TITLE) || (formStyle & FORM_STYLE_TEXT_TAB) || (formStyle & FORM_STYLE_ICON_TAB)) && (formStyle & FORM_STYLE_HEADER)) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid form style. FORM_STYLE_TITLE, FORM_STYLE_TEXT_TAB or FORM_STYLE_ICON_TAB and FORM_STYLE_HEADER can't use each other."); + + // remove Header + if (pHeader) + { + RemoveHeader(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return; + } + + if (((formStyle & FORM_STYLE_SOFTKEY_0) || (formStyle & FORM_STYLE_SOFTKEY_1) || (formStyle & FORM_STYLE_OPTIONKEY)) && (formStyle & FORM_STYLE_FOOTER)) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid form style. FORM_STYLE_SOFTKEY0, FORM_STYLE_SOFTKEY_1 or FORM_STYLE_OPTIONKEY and FORM_STYLE_FOOTER can't use each other."); + + // remove Footer + if (pFooter) + { + RemoveFooter(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + return; + } + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas."); + + GetCore().SetFormStyle(formStyle); + + Rectangle indicatorBounds(0, 0, 0, 0); + FloatRectangle indicatorFloatBounds(0.0f, 0.0f, 0.0f, 0.0f); + + if (FORM_STYLE_INDICATOR & formStyle) + { + GetCore().SetIndicatorShowState(true); + indicatorBounds = GetCore().GetIndicatorBounds(); + indicatorFloatBounds = GetCore().GetIndicatorFloatBounds(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = GetCore().SetIndicatorShowState(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (formStyle & FORM_STYLE_HEADER) + { + if (!pHeader) + { + pHeader = CreateHeaderN(); + SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().SetHeader(&pHeader->GetCore()); + GetCore().AdjustClientBounds(); + + FloatRectangle bounds(0, indicatorFloatBounds.height, GetClientBounds().width, GetCore().GetToolbarHeight(true)); + GetCore().SetHeaderFloatBounds(bounds); + + r = GetCore().AttachSystemChild(pHeader->GetCore()); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().SetFormBackEventListener(this); + } + } + else if (formStyle & FORM_STYLE_TITLE) + { + if (!pHeader) + { + pHeader = CreateHeaderN(); + SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().SetHeader(&pHeader->GetCore()); + GetCore().AdjustClientBounds(); + + FloatRectangle bounds(0, indicatorFloatBounds.height, GetClientBounds().width, GetCore().GetToolbarHeight(true)); + GetCore().SetHeaderFloatBounds(bounds); + + r = GetCore().AttachSystemChild(pHeader->GetCore()); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + // remove Header + if (pHeader) + { + RemoveHeader(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + if (formStyle & FORM_STYLE_TEXT_TAB) + { + int titleHeight = 0; + + if (formStyle & FORM_STYLE_TITLE) + { + if (pHeader) + { + titleHeight = pHeader->GetBounds().height; + } + } + + if (!pTabImpl) + { + pTabImpl = CreateTabImplN(); + SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + int posY = indicatorBounds.height + titleHeight; + + GetCore().SetTab(&pTabImpl->GetCore()); + GetCore().AdjustClientBounds(); + + Rectangle bounds(0, posY, GetClientBounds().width, GetCore().GetTabHeight()); + GetCore().SetTabBounds(bounds); + + r = GetCore().AttachSystemChild(pTabImpl->GetCore()); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + GetCore().SetTabStyle(_TAB_STYLE_TEXT); + } + else if (formStyle & FORM_STYLE_ICON_TAB) + { + int titleHeight = 0; + + if (formStyle & FORM_STYLE_TITLE) + { + if (pHeader) + { + titleHeight = pHeader->GetBounds().height; + } + } + + if (!pTabImpl) + { + pTabImpl = CreateTabImplN(); + SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + int posY = indicatorBounds.height + titleHeight; + + GetCore().SetTab(&pTabImpl->GetCore()); + GetCore().AdjustClientBounds(); + + Rectangle bounds(0, posY, GetClientBounds().width, GetCore().GetTabHeight()); + GetCore().SetTabBounds(bounds); + + r = GetCore().AttachSystemChild(pTabImpl->GetCore()); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + GetCore().SetTabStyle(_TAB_STYLE_ICON); + } + else + { + if (pTabImpl) + { + RemoveTabImpl(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + if (formStyle & FORM_STYLE_FOOTER) + { + if (!pFooter) + { + pFooter = CreateFooterN(); + SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().SetFooter(&pFooter->GetCore()); + GetCore().AdjustClientBounds(); + + Rectangle clientbounds = GetClientBounds(); + Rectangle bounds(0, clientbounds.y + clientbounds.height, clientbounds.width, GetCore().GetToolbarHeight(false)); + + GetCore().SetFooterBounds(bounds); + + r = GetCore().AttachSystemChild(pFooter->GetCore()); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + //[ToDo] + GetCore().SetFormBackEventListener(this); + } + } + else if (formStyle & FORM_STYLE_SOFTKEY_0 || formStyle & FORM_STYLE_SOFTKEY_1 || formStyle & FORM_STYLE_OPTIONKEY) + { + if (pFooter) + { + RemoveFooter(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + pFooter = GetFooter(); + + if (!pFooter) + { + pFooter = CreateFooterN(); + SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().SetFooter(&pFooter->GetCore()); + GetCore().AdjustClientBounds(); + + Rectangle clientbounds = GetClientBounds(); + Rectangle bounds(0, clientbounds.y + clientbounds.height - GetCore().GetToolbarHeight(false), clientbounds.width, GetCore().GetToolbarHeight(false)); + + GetCore().SetFooterBounds(bounds); + + r = GetCore().AttachSystemChild(pFooter->GetCore()); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().CreateSoftkey(formStyle); + + pFooter->GetCore().AddActionEventListener(*this); + } + } + else + { + // remove Footer + if (pFooter) + { + RemoveFooter(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + GetCore().AdjustClientBounds(); + } + } + + GetCore().AdjustClientBounds(); + + SetLastResult(E_SUCCESS); + + return; +} + +_FooterImpl* +_FormImpl::GetFooter(void) const +{ + _Toolbar* pToolbar = __pForm->GetFooter(); + if (pToolbar == null) + { + return null; + } + + _FooterImpl* pFooterImpl = static_cast<_FooterImpl*>(pToolbar->GetUserData()); + + return pFooterImpl; +} + +_HeaderImpl* +_FormImpl::GetHeader(void) const +{ + _Toolbar* pToolbar = __pForm->GetHeader(); + if (pToolbar == null) + { + return null; + } + + _HeaderImpl* pHeaderImpl = static_cast<_HeaderImpl*>(pToolbar->GetUserData()); + + return pHeaderImpl; +} + +// Ki-Dong,Hong.Temp +_TabImpl* +_FormImpl::GetTabImpl(void) const +{ + _Tab* pTab = __pForm->GetTab(); + if (pTab == null) + { + return null; + } + + _TabImpl* pTabImpl = static_cast<_TabImpl*>(pTab->GetUserData()); + + return pTabImpl; +} + +String +_FormImpl::GetTitleText(void) const +{ + return GetCore().GetTitleText(); +} + +HorizontalAlignment +_FormImpl::GetTitleTextHorizontalAlignment(void) const +{ + return GetCore().GetTitleTextHorizontalAlignment(); +} + +bool +_FormImpl::HasFooter(void) const +{ + return GetCore().HasFooter(); +} + +bool +_FormImpl::HasHeader(void) const +{ + return GetCore().HasHeader(); +} + +bool +_FormImpl::HasTitle(void) const +{ + return GetCore().HasTitle(); +} + +bool +_FormImpl::HasTab(void) const +{ + return GetCore().HasTab(); +} + +bool +_FormImpl::IsIndicatorVisible(void) const +{ + return GetCore().IsIndicatorVisible(); +} + +bool +_FormImpl::IsHeaderVisible(void) const +{ + return GetCore().IsHeaderVisible(); +} + +bool +_FormImpl::IsFooterVisible(void) const +{ + return GetCore().IsFooterVisible(); +} + +bool +_FormImpl::IsIndicatorTranslucent(void) const +{ + return GetCore().IsIndicatorTranslucent(); +} + +bool +_FormImpl::IsHeaderTranslucent(void) const +{ + return GetCore().IsHeaderTranslucent(); +} + +bool +_FormImpl::IsFooterTranslucent(void) const +{ + return GetCore().IsFooterTranslucent(); +} + +// Ki-Dong,Hong.Temp +bool +_FormImpl::IsTabTranslucent(void) const +{ + return GetCore().IsTabTranslucent(); +} + +result +_FormImpl::SetActionBarsTranslucent(unsigned long actionBars, bool translucent) +{ + return GetCore().SetActionBarsTranslucent(actionBars, translucent); +} + +result +_FormImpl::SetActionBarsVisible(unsigned long actionBars, bool visible) +{ + return GetCore().SetActionBarsVisible(actionBars, visible); +} + +result +_FormImpl::SetTitleIcon(const Bitmap* pTitleBitmap) +{ + return GetCore().SetTitleIcon(pTitleBitmap); +} + +result +_FormImpl::SetTitleText(const String& title, HorizontalAlignment alignment) +{ + return GetCore().SetTitleText(title, alignment); +} + +OverlayRegion* +_FormImpl::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType) +{ + return GetCore().GetOverlayRegionN(rect, regionType); +} + +void +_FormImpl::OnDraw(void) +{ + // [ToDo] Versioning!!! + __pOriAgent->FireOrientationEvent(); + + _ContainerImpl::OnDraw(); +} + +bool +_FormImpl::OnKeyReleased(const _ControlImpl& source, _KeyCode keyCode) +{ + switch (keyCode) + { + case _KEY_BACKSPACE: + if (GetCore().GetFooter() || GetCore().GetHeader()) + { + if (__pFormBackEventListener) + { + Form* pForm = dynamic_cast (&GetPublic()); + if (pForm) + { + __pFormBackEventListener->OnFormBackRequested(*pForm); + } + } + else + { + break; + } + } + else + { + break; + } + break; + + default: + return false; + } + + return true; +} + +void +_FormImpl::OnActionPerformed(const _Control& source, int actionId) +{ + if (GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetFormStyle() & FORM_STYLE_SOFTKEY_1 || GetFormStyle() & FORM_STYLE_OPTIONKEY) + { + Tizen::Base::Runtime::IEventArg* tempArg = null; + tempArg = _PublicActionEvent::CreateActionEventArgN(actionId); + SysTryReturnVoidResult(NID_UI_CTRL, tempArg , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create Eventarg."); + bool fired = true; + + _PublicActionEvent* pSoftkeyActionEvent = null; + + if (GetCore().GetFooter()->IsButtonSet(LEFT_BUTTON) && GetSoftkeyActionId(SOFTKEY_0) == actionId) + { + for (int i = 0; i < __leftSoftkeyActionList.GetCount(); i++) + { + pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__leftSoftkeyActionList.GetAt(i)); + + if (pSoftkeyActionEvent) + { + pSoftkeyActionEvent->Fire(*tempArg); + fired = false; + } + } + } + + if (GetCore().GetFooter()->IsButtonSet(RIGHT_BUTTON) && GetSoftkeyActionId(SOFTKEY_1) == actionId) + { + for (int i = 0; i < __rightSoftkeyActionList.GetCount(); i++) + { + pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__rightSoftkeyActionList.GetAt(i)); + + if (pSoftkeyActionEvent) + { + pSoftkeyActionEvent->Fire(*tempArg); + fired = false; + } + } + } + + if (GetCore().GetFooter()->IsButtonSet(MIDDLE_BUTTON) && GetOptionkeyActionId() == actionId) + { + if (__pOptionMenuActionEvent) + { + __pOptionMenuActionEvent->Fire(*tempArg); + fired = false; + } + } + if (fired) + { + delete tempArg; + } + } +} + +Canvas* +_FormImpl::GetClientAreaCanvasN(void) const +{ + return GetCore().GetClientAreaCanvasN(); +} + +Point +_FormImpl::TranslateToClientAreaPosition(const Point& position) const +{ + return GetCore().TranslateToClientAreaPosition(position); +} + +Point +_FormImpl::TranslateFromClientAreaPosition(const Point& clientPosition) const +{ + return GetCore().TranslateFromClientAreaPosition(clientPosition); +} + +void +_FormImpl::SetFormBackEventListener(const IFormBackEventListener* pFormBackEventListener) +{ + SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed."); + __pFormBackEventListener = const_cast (pFormBackEventListener); + GetCore().SetFormBackEventListener(this); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_FormImpl::AddOrientationEventListener(IOrientationEventListener& listener) +{ + __pOriAgent->AddListener(listener); +} + +void +_FormImpl::AddOptionkeyActionListener(const IActionEventListener& listener) +{ + if (HasOptionkey() == false) + { + return ; + } + + __pOptionMenuActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + + SysTryReturnVoidResult(NID_UI_CTRL, __pOptionMenuActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pOptionMenuActionEvent->AddListener(listener); +} + +void +_FormImpl::AddSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener) +{ + _Softkey _softkey = ConvertSoftkey(softkey); + + if (GetCore().CheckSoftkey(_softkey) == false) + { + return ; + } + + if (softkey == SOFTKEY_0) + { + __pLeftSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + + SysTryReturnVoidResult(NID_UI_CTRL, __pLeftSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pLeftSoftkeyActionEvent->AddListener(listener); + + __leftSoftkeyActionList.Add(*__pLeftSoftkeyActionEvent); + } + else if (softkey == SOFTKEY_1) + { + __pRightSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + + SysTryReturnVoidResult(NID_UI_CTRL, __pRightSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pRightSoftkeyActionEvent->AddListener(listener); + + __rightSoftkeyActionList.Add(*__pRightSoftkeyActionEvent); + } +} + +void +_FormImpl::RemoveOrientationEventListener(IOrientationEventListener& listener) +{ + __pOriAgent->RemoveListener(listener); +} + +void +_FormImpl::RemoveOptionkeyActionListener(const IActionEventListener& listener) +{ + if (HasOptionkey() == false) + { + return ; + } + + if (__pOptionMenuActionEvent) + { + __pOptionMenuActionEvent->RemoveListener(listener); + } +} + +void +_FormImpl::RemoveSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener) +{ + _Softkey _softkey = ConvertSoftkey(softkey); + + if (GetCore().CheckSoftkey(_softkey) == false) + { + return ; + } + + if (softkey == SOFTKEY_0) + { + if (__pLeftSoftkeyActionEvent) + { + __pLeftSoftkeyActionEvent->RemoveListener(listener); + } + } + else if (softkey == SOFTKEY_1) + { + if (__pRightSoftkeyActionEvent) + { + __pRightSoftkeyActionEvent->RemoveListener(listener); + } + } +} + +void +_FormImpl::SetOrientation(Orientation orientation) +{ + __pOriAgent->SetMode(orientation); +} + +Orientation +_FormImpl::GetOrientation(void) const +{ + return __pOriAgent->GetMode(); +} + +OrientationStatus +_FormImpl::GetOrientationStatus(void) const +{ + return __pOriAgent->GetStatus(); +} + +void +_FormImpl::UpdateOrientationStatus(bool draw) +{ + __pOriAgent->Update(draw); +} + +bool +_FormImpl::HasOptionkey(void) const +{ + return GetCore().HasOptionkey(); +} + +bool +_FormImpl::HasSoftkey(Softkey softkey) const +{ + _Softkey _softkey = ConvertSoftkey(softkey); + + return GetCore().HasSoftkey(_softkey); +} + +result +_FormImpl::SetSoftkeyEnabled(Softkey softkey, bool enable) +{ + _Softkey _softkey = ConvertSoftkey(softkey); + + result r = GetCore().SetSoftkeyEnabled(_softkey, enable); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +bool +_FormImpl::IsSoftkeyEnabled(Softkey softkey) const +{ + _Softkey _softkey = ConvertSoftkey(softkey); + + return GetCore().IsSoftkeyEnabled(_softkey); +} + +int +_FormImpl::GetSoftkeyActionId(Softkey softkey) const +{ + _Softkey _softkey = ConvertSoftkey(softkey); + + return GetCore().GetSoftkeyActionId(_softkey); +} + +int +_FormImpl::GetOptionkeyActionId(void) const +{ + return GetCore().GetOptionkeyActionId(); +} + +String +_FormImpl::GetSoftkeyText(Softkey softkey) const +{ + _Softkey _softkey = ConvertSoftkey(softkey); + + return GetCore().GetSoftkeyText(_softkey); +} + +result +_FormImpl::SetOptionkeyActionId(int actionId) +{ + result r = GetCore().SetOptionkeyActionId(actionId); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_FormImpl::SetSoftkeyActionId(Softkey softkey, int actionId) +{ + _Softkey _softkey = ConvertSoftkey(softkey); + + result r = GetCore().SetSoftkeyActionId(_softkey, actionId); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_FormImpl::SetSoftkeyText(Softkey softkey, const String& text) +{ + _Softkey _softkey = ConvertSoftkey(softkey); + + result r = GetCore().SetSoftkeyText(_softkey, text); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_FormImpl::SetSoftkeyIcon(Softkey softkey, const Bitmap& pNormalBitmap, const Bitmap* ppPressedBitmap) +{ + _Softkey _softkey = ConvertSoftkey(softkey); + + result r = GetCore().SetSoftkeyIcon(_softkey, pNormalBitmap, ppPressedBitmap); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +_FormImpl::OnChangeLayout(_ControlOrientation orientation) +{ + const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize(); + const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width); + + // Change layout. + _ContainerImpl::OnChangeLayout(orientation); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + SetSize(portraitSize); + } + else + { + SetSize(landscapeSize); + } + + int indicatorheight = 0; + + GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetCore().GetOrientation(), indicatorheight); + if (GetCore().HasIndicator()) + { + _Indicator* pIndicator = GetCore().GetIndicator(); + if (pIndicator) + pIndicator->SetBounds(Rectangle(0, 0, GetClientBounds().width, indicatorheight)); + GetCore().AdjustClientBounds(); + } + + + int adjHeight = 0; + + if (GetCore().HasHeader()) + { + FloatRectangle indicatorFloatBounds(0.0f, 0.0f, 0.0f, 0.0f); + if (GetCore().IsIndicatorVisible()) + { + indicatorFloatBounds = GetCore().GetIndicatorFloatBounds(); + } + + FloatRectangle bounds(0, indicatorFloatBounds.height, GetClientBounds().width, GetCore().GetToolbarHeight(true)); + GetCore().SetHeaderFloatBounds(bounds); + } + + if (GetCore().HasTab()) // Ki-Dong,Hong.Temp + { + int titleHeight = 0; + + if (GetCore().GetFormStyle() & FORM_STYLE_TITLE) + { + if (GetCore().HasHeader()) + { + _HeaderImpl* pHeaderImpl = GetHeader(); + if (pHeaderImpl) + { + titleHeight = pHeaderImpl->GetBounds().height; + } + } + } + + Rectangle indicatorBounds(0, 0, 0, 0); + + if (GetCore().IsIndicatorVisible()) + { + indicatorBounds = GetCore().GetIndicatorBounds(); + } + + int posY = indicatorBounds.height + titleHeight; + + Rectangle bounds(0, posY, GetClientBounds().width, GetCore().GetTabHeight()); + GetCore().SetTabBounds(bounds); + } + + if (GetCore().HasFooter()) + { + if (GetCore().GetFooter()->GetVisibleState() && !GetCore().IsFooterTranslucent()) + { + adjHeight = 0; + } + else + { + adjHeight = GetCore().GetToolbarHeight(false); + } + + if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1 + || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY)) + { + adjHeight = GetCore().GetToolbarHeight(false); + } + + Rectangle bounds(0, GetClientBounds().y + GetClientBounds().height - adjHeight, + GetClientBounds().width, GetCore().GetToolbarHeight(false)); + GetCore().SetFooterBounds(bounds); + } +} + +_HeaderImpl* +_FormImpl::CreateHeaderN(void) +{ + result r = E_SUCCESS; + + Header* pHeader = new (std::nothrow) Header; + SysTryReturn(NID_UI_CTRL, pHeader, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = pHeader->Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*pHeader); + + SetLastResult(E_SUCCESS); + + return pHeaderImpl; +} + +_FooterImpl* +_FormImpl::CreateFooterN(void) +{ + result r = E_SUCCESS; + + Footer* pFooter = new (std::nothrow) Footer; + SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = pFooter->Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*pFooter); + + SetLastResult(E_SUCCESS); + + return pFooterImpl; +} + +// Ki-Dong,Hong.Temp +_TabImpl* +_FormImpl::CreateTabImplN(void) +{ + //result r = E_SUCCESS; + + //Tab* pTab = new (std::nothrow) Tab; + //SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + //r = pTab->Construct(); + //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Unable to consturct tab."); + + //return pTab->GetTabImpl(); + Tab* pTab = _TabImpl::CreateTabN(); + SysTryReturn(NID_UI_CTRL, pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _TabImpl* pTabImpl = _TabImpl::GetInstance(*pTab); + + SetLastResult(E_SUCCESS); + + return pTabImpl; +} + +bool +_FormImpl::DeflateClientRectHeight(int height) +{ + return GetCore().DeflateClientRectHeight(height); +} + +bool +_FormImpl::RemoveHeader(void) +{ + _HeaderImpl* pHeaderImpl = GetHeader(); + + if (pHeaderImpl) + { + __pForm->RemoveHeader(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + Header* pHeader = pHeaderImpl->GetHeader(); + + delete pHeader; + } + else + return false; + + return true; +} + +bool +_FormImpl::RemoveFooter(void) +{ + _FooterImpl* pFooterImpl = GetFooter(); + + if (pFooterImpl) + { + __pForm->RemoveFooter(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + Footer* pFooter = pFooterImpl->GetFooter(); + + delete pFooter; + } + else + { + return false; + } + + return true; +} + +// Ki-Dong,Hong.Temp +bool +_FormImpl::RemoveTabImpl(void) +{ + _TabImpl* pTabImpl = GetTabImpl(); + + if (pTabImpl) + { + __pForm->RemoveTab(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + Tab* pTab = pTabImpl->GetTab(); + + pTabImpl->DeleteTab(pTab); + } + else + { + return false; + } + + return true; +} + +DataBindingContext* +_FormImpl::GetDataBindingContextN(void) const +{ + return _DataBindingContextImpl::GetDataBindingContextN(*this); +} + +result +_FormImpl::OnAttaching(const _Control* pParent) +{ + result r = E_SUCCESS; + _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>((pParent))); + if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle()) + { + SysTryReturnResult(NID_UI_CTRL, pFrame != null, E_INVALID_ARG, "A Form which has FORM_STYLE_INDICATOR style cannot be added to a container except Frame."); + } + r = _ControlImpl::OnAttaching(pParent); + return r; +} + +result +_FormImpl::OnAttachedToMainTree(void) +{ + result r = E_SUCCESS; + SetFocused(); + + r = GetCore().AttachedToMainTree(); + r = _ContainerImpl::OnAttachedToMainTree(); + + Rectangle indicatorBounds(0, 0, 0, 0); + FloatRectangle indicatorFloatBounds(0.0f, 0.0f, 0.0f, 0.0f); + + if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle()) + { + indicatorBounds = GetCore().GetIndicatorBounds(); + indicatorFloatBounds = GetCore().GetIndicatorFloatBounds(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + _HeaderImpl* pHeader = GetHeader(); + _FooterImpl* pFooter = GetFooter(); + _TabImpl* pTabImpl = GetTabImpl(); + + if (pHeader) + { + FloatRectangle bounds(0, indicatorFloatBounds.height, GetClientBounds().width, GetCore().GetToolbarHeight(true)); + GetCore().SetHeaderFloatBounds(bounds); + } + + int titleHeight = 0; + + if (pHeader) + { + titleHeight = pHeader->GetBounds().height; + } + + if (pTabImpl) + { + int posY = indicatorBounds.height + titleHeight; + + Rectangle bounds(0, posY, GetClientBounds().width, GetCore().GetTabHeight()); + GetCore().SetTabBounds(bounds); + } + + if (pFooter) + { + int adjHeight = 0; + + if (!(GetCore().GetFooter()->GetVisibleState()) || GetCore().IsFooterTranslucent()) + { + adjHeight = GetCore().GetToolbarHeight(false); + } + + if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1 + || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY)) + { + adjHeight = GetCore().GetToolbarHeight(false); + } + + Rectangle clientbounds = GetClientBounds(); + Rectangle bounds(0, clientbounds.y + clientbounds.height - adjHeight, clientbounds.width, GetCore().GetToolbarHeight(false)); + + GetCore().SetFooterBounds(bounds); + } + + UpdateOrientationStatus(); + + return r; +} + +result +_FormImpl::OnDetachingFromMainTree(void) +{ + result r = E_SUCCESS; + r = GetCore().DetachingFromMainTree(); + r = _ContainerImpl::OnDetachingFromMainTree(); + + return r; +} + +void +_FormImpl::OnFormBackRequested(Tizen::Ui::Controls::_Form& source) +{ + if (__pFormBackEventListener) + { + _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData()); + Form* pForm = dynamic_cast (&pFormImpl->GetPublic()); + if (pForm) + { + __pFormBackEventListener->OnFormBackRequested(*pForm); + } + else + { + return; + } + } +} + +bool +_FormImpl::IsOpaque(void) const +{ + return true; +} + +_Softkey +_FormImpl::ConvertSoftkey(Softkey softkey) const +{ + _Softkey _softkey; + + if (softkey == SOFTKEY_0) + { + _softkey = _SOFTKEY_0; + } + else if (softkey == SOFTKEY_1) + { + _softkey = _SOFTKEY_1; + } + else + { + _softkey = _SOFTKEY_COUNT; + } + + return _softkey; +} + +class _FormMaker + : public _UiBuilderControlMaker +{ +public: + _FormMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_FormMaker() + { + }; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _FormMaker* pFormMaker = new (std::nothrow) _FormMaker(uibuilder); + return pFormMaker; + }; +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + _UiBuilderControlLayout* pControlProperty = null; + result r = E_SUCCESS; + int style = 0; + int opacity = 0; + Tizen::Base::String elementString; + bool isTitleAlign = false; + Color color; + + HorizontalAlignment align = ALIGNMENT_CENTER; + Form* pForm = (Form*) GetContainer(); + + // Get control manager + _ControlManager* pControlManager = _ControlManager::GetInstance(); + if (pControlManager == null) + { + SysLog(NID_UI_CTRL, "Unable to get the control manager.n"); + return null; + } + Dimension screenSize = pControlManager->GetScreenSize(); + + //Set rect + (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(0, 0, screenSize.width, screenSize.height); + (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(0, 0, screenSize.height, screenSize.width); + + // Get device orientation + app_device_orientation_e deviceOrientation = app_get_device_orientation(); + bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270); + + if (isHorizontal) + { + pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE); + } + else + { + pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT); + } + + if (pControlProperty == null) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Can't read attributes"); + return null; + } + + pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT); + Tizen::Base::String styleString; + styleString = pControlProperty->GetStyle(); + + if (styleString.Contains(L"FORM_STYLE_TITLE")) + { + style |= FORM_STYLE_TITLE; + } + if (styleString.Contains(L"FORM_STYLE_SOFTKEY_0")) + { + style |= FORM_STYLE_SOFTKEY_0; + } + if (styleString.Contains(L"FORM_STYLE_SOFTKEY_1")) + { + style |= FORM_STYLE_SOFTKEY_1; + } + if (styleString.Contains(L"FORM_STYLE_OPTIONKEY")) + { + style |= FORM_STYLE_OPTIONKEY; + } + if (styleString.Contains(L"FORM_STYLE_INDICATOR")) + { + style |= FORM_STYLE_INDICATOR; + } + if (styleString.Contains(L"FORM_STYLE_TEXT_TAB")) + { + style |= FORM_STYLE_TEXT_TAB; + } + if (styleString.Contains(L"FORM_STYLE_ICON_TAB")) + { + style |= FORM_STYLE_ICON_TAB; + } + if (styleString.Contains(L"FORM_STYLE_HEADER")) + { + style |= FORM_STYLE_HEADER; + } + if (styleString.Contains(L"FORM_STYLE_FOOTER")) + { + style |= FORM_STYLE_FOOTER; + } + + _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE; + GetLayoutType(pControlProperty, layoutType); + if (layoutType == UIBUILDER_LAYOUT_NONE) + { + // Construct + r = pForm->Construct(style); + } + else + { + Layout* pPortraitLayout = null; + Layout* pLandscapeLayout = null; + result tempResult = E_SUCCESS; + tempResult = GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout); + if (E_SUCCESS == tempResult) + { + r = pForm->Construct(*pPortraitLayout, *pLandscapeLayout, style); + } + else + { + r = tempResult; + } + + _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE; + + if (GetLayoutType(pControlProperty, layoutType) == false) + { + return null; + } + + if ( layoutType == UIBUILDER_LAYOUT_GRID) + { + for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++) + { + GridLayout* pGridLayout = null; + pControlProperty = pControl->GetAttribute(i); + + if ( i == UIBUILDER_ATTRIBUTE_PORTRAIT) + { + pGridLayout = dynamic_cast(pPortraitLayout); + } + else + { + pGridLayout = dynamic_cast(pLandscapeLayout); + } + SetGridLayoutContainerProperty(pGridLayout, pControlProperty); + } + } + delete pPortraitLayout; + if (pPortraitLayout != pLandscapeLayout) + { + delete pLandscapeLayout; + } + } + + if (r != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Failed to create Form."); + return null; + } + + // Set Property + if (pControl->GetElement(L"titleAlign", elementString)) + { + if (elementString.Equals(L"ALIGN_CENTER", false)) + { + align = ALIGNMENT_CENTER; + } + else if (elementString.Equals(L"ALIGN_RIGHT", false)) + { + align = ALIGNMENT_RIGHT; + } + else + { + align = ALIGNMENT_LEFT; + } + isTitleAlign = true; + } + + if (pControl->GetElement(L"title", elementString)) + { + if (isTitleAlign) + { + pForm->SetTitleText(elementString, align); + } + else + { + pForm->SetTitleText(elementString); + } + } + else + { + if (isTitleAlign) + { + pForm->SetTitleText(L"", align); + } + else + { + pForm->SetTitleText(L""); + } + } + + if (pControl->GetElement(L"titleIcon", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + if (pBitmap != null) + { + r = pForm->SetTitleIcon(pBitmap); + delete pBitmap; + if (IsFailed(r)) + { + SysLog(NID_UI_CTRL, "Failed to set TitleIcon."); + } + } + } + + if (pControl->GetElement(L"softKey0Text", elementString)) + { + pForm->SetSoftkeyText(SOFTKEY_0, elementString); + } + if (pControl->GetElement(L"softKey1Text", elementString)) + { + pForm->SetSoftkeyText(SOFTKEY_1, elementString); + } + if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pForm->SetBackgroundColor(color); + } + else + { + Color color; + r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color); + if (r == E_SUCCESS) + { + pForm->SetBackgroundColor(color); + } + else + { + pForm->SetBackgroundColor(0xff000000); + } + } + + if (pControl->GetElement(L"softKey0Icon", elementString) || pControl->GetElement(L"softKey0NormalIcon", elementString)) + { + Bitmap* pNormalBitmap = null; + Bitmap* pPressedBitmap = null; + pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565); + + if (pNormalBitmap != null) + { + if (pControl->GetElement(L"softKey0PressedIcon", elementString)) + { + pPressedBitmap = LoadBitmapN(elementString); + } + + if (pPressedBitmap != null) + { + pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, pPressedBitmap); + delete pNormalBitmap; + delete pPressedBitmap; + } + else + { + pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, null); + delete pNormalBitmap; + } + } + } + if (pControl->GetElement(L"softKey1Icon", elementString) || pControl->GetElement(L"softKey1NormalIcon", elementString)) + { + Bitmap* pNormalBitmap = null; + Bitmap* pPressedBitmap = null; + pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565); + + if (pNormalBitmap != null) + { + if (pControl->GetElement(L"softKey1PressedIcon", elementString)) + { + pPressedBitmap = LoadBitmapN(elementString); // __image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565); + } + + if (pPressedBitmap != null) + { + pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, pPressedBitmap); + delete pNormalBitmap; + delete pPressedBitmap; + } + else + { + pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, null); + delete pNormalBitmap; + } + } + } + + if (pControl->GetElement(L"Orientation", elementString) || pControl->GetElement(L"orientation", elementString)) + { + //ORIENTATION_NONE, + //ORIENTATION_PORTRAIT, + //ORIENTATION_LANDSACPE, + //ORIENTATION_PORTRAIT_REVERSE, + //ORIENTATION_LANDSACPE_REVERSE, + //ORIENTATION_AUTO = 6, + //ORIENTATION_AUTO_FOUR_DIRECTION = 8, + + if (elementString.Equals(L"Automatic:2Dir", false) || elementString.Equals(L"Automatic", false)) + { + pForm->SetOrientation(ORIENTATION_AUTOMATIC); + } + else if (elementString.Equals(L"Automatic:4Dir", false)) + { + pForm->SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION); + } + else if (elementString.Equals(L"Landscape", false)) + { + pForm->SetOrientation(ORIENTATION_LANDSCAPE); + SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL); + } + else if (elementString.Equals(L"Landscape:Reverse", false)) + { + pForm->SetOrientation(ORIENTATION_LANDSCAPE_REVERSE); + SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL); + } + else if (elementString.Equals(L"Portrait", false)) + { + pForm->SetOrientation(ORIENTATION_PORTRAIT); + SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL); + } + else if (elementString.Equals(L"Portrait:Reverse", false)) + { + pForm->SetOrientation(ORIENTATION_PORTRAIT_REVERSE); + SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL); + } + } + + if (style & FORM_STYLE_HEADER) + { + if (pControl->GetElement(L"translucentHeader", elementString)) + { + if (elementString.Equals(L"true", false)) + { + pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_HEADER, true); + } + } + } + + if (style & FORM_STYLE_FOOTER) + { + if (pControl->GetElement(L"translucentFooter", elementString)) + { + if (elementString.Equals(L"true", false)) + { + pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_FOOTER, true); + } + } + } + + if (style & FORM_STYLE_INDICATOR) + { + if (pControl->GetElement(L"translucentIndicator", elementString)) + { + if (elementString.Equals(L"true", false)) + { + pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true); + } + } + } + + return pForm; + } + +}; + +_FormRegister::_FormRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"Form", _FormMaker::GetInstance); +} +_FormRegister::~_FormRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"Form"); +} +static _FormRegister FormRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FormModel.cpp b/src/ui/controls/FUiCtrl_FormModel.cpp new file mode 100644 index 0000000..ee56737 --- /dev/null +++ b/src/ui/controls/FUiCtrl_FormModel.cpp @@ -0,0 +1,35 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FormModel.cpp + * @brief This is the implementation file for the _FormModel class. + */ + +#include "FUiCtrl_FormModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_FormModel::_FormModel(void) +{ +} + +_FormModel::~_FormModel(void) +{ +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FormPresenter.cpp b/src/ui/controls/FUiCtrl_FormPresenter.cpp new file mode 100644 index 0000000..bf17fae --- /dev/null +++ b/src/ui/controls/FUiCtrl_FormPresenter.cpp @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FormPresenter.cpp + * @brief This is the implementation file for the _FormPresenter class. + */ + +#include +#include +#include +#include "FUiCtrl_FormPresenter.h" +#include "FUiCtrl_FormModel.h" +#include "FUiCtrl_Form.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_FormPresenter::_FormPresenter(const _Form& form) + : __pForm(null) + , __pFormModel(null) +{ + __pForm = const_cast <_Form*>(&form); + + _FormModel* pModel = new (std::nothrow) _FormModel; + SysTryReturnVoidResult(NID_UI_CTRL, pModel, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.."); + + SetModel(*pModel); + + SetLastResult(E_SUCCESS); + + return; +} + +_FormPresenter::~_FormPresenter(void) +{ + if (__pFormModel) + { + delete __pFormModel; + __pFormModel = null; + } +} + +result +_FormPresenter::SetModel(const _FormModel& formModel) +{ + __pFormModel = const_cast <_FormModel*>(&formModel); + + return E_SUCCESS; +} + +void +_FormPresenter::Draw(void) +{ + _Draw(); + + return; +} + +void +_FormPresenter::_Draw(void) +{ + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Frame.cpp b/src/ui/controls/FUiCtrl_Frame.cpp new file mode 100644 index 0000000..8328f19 --- /dev/null +++ b/src/ui/controls/FUiCtrl_Frame.cpp @@ -0,0 +1,686 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Frame.cpp + * @brief This is the implementation file for the _Frame class. + */ + +#include +#include +#include +#include +#include "FUi_UiNotificationEvent.h" +#include "FUi_UiEventManager.h" +#include "FUi_ControlManager.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EcoreEvas.h" +#include "FUi_TouchManager.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_FramePresenter.h" +#include "FUiCtrl_FrameEvent.h" +#include "FUiCtrl_IFrameEventListener.h" +#include "FUiCtrl_IFormActivationChangeEventListener.h" +#include "FUiCtrl_Form.h" +#include "FUiAnim_VisualElement.h" +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_EflLayer.h" + +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls { + +_Frame::_Frame(void) + : __pFramePresenter(null) + , __pFrameEvent(null) + , __floatingBounds(0, 0, 0, 0) + , __showMode(FRAME_SHOW_MODE_FULL_SCREEN) + , __restore(false) + , __activated(false) + , __pFormActivationChangeEventListener(null) +{ + _FramePresenter* pPresenter = new (std::nothrow) _FramePresenter(*this); + SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + Dimension screen = _ControlManager::GetInstance()->GetScreenSize(); + __floatingBounds.width = screen.width; + __floatingBounds.height = screen.height; + + __pFrameEvent = _FrameEvent::CreateInstanceN(*this); + SysTryCatch(NID_UI_CTRL, __pFrameEvent, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + SetPresenter(*pPresenter); + SetClipChildrenEnabled(false); + + ClearLastResult(); + + return; + +CATCH: + delete pPresenter; + pPresenter = null; +} + +_Frame::~_Frame(void) +{ + if (__pFrameEvent) + { + delete __pFrameEvent; + __pFrameEvent = null; + } + + delete __pFramePresenter; + __pFramePresenter = null; + + ClearLastResult(); +} + +_Frame* +_Frame::CreateFrameN(void) +{ + //_VisualElement* pFrameVE = null; + +#if defined(MULTI_WINDOW) + result r = E_SUCCESS; + _RootVisualElement* pRootVE = null; + _EflLayer* pLayer = null; +#endif + + _Frame* pFrame = new (std::nothrow) _Frame; + SysTryCatch(NID_UI_CTRL, pFrame, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + +#if defined(MULTI_WINDOW) + r = pFrame->CreateRootVisualElement(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pRootVE = pFrame->GetRootVisualElement(); + SysAssert(pRootVE); + + pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer()); + SysAssert(pLayer); + + pLayer->SetOpacity(1); +#endif + + //pFrameVE = pFrame->GetVisualElement(); + //pFrameVE->SetRenderOperation(_VisualElement::RENDER_OPERATION_COPY); + + pFrame->AcquireHandle(); + + SetLastResult(E_SUCCESS); + + return pFrame; + +CATCH: + delete pFrame; + + return null; +} + +result +_Frame::SetPresenter(const _FramePresenter& framePresenter) +{ + __pFramePresenter = const_cast <_FramePresenter*>(&framePresenter); + + return E_SUCCESS; +} + +void +_Frame::OnDraw(void) +{ + if (__pFramePresenter) + { + __pFramePresenter->Draw(); + } +} + +void +_Frame::OnActivated(void) +{ + SysLog(NID_UI, "activated(%d)", __activated); + + if (!__activated) + { + return; + } + +#if defined(MULTI_WINDOW) + _Window::OnActivated(); +#endif + + _Form* pCurrentForm = GetCurrentForm(); + if (pCurrentForm == null) + { + return; + } + + _Control* pFocusedControl = pCurrentForm->GetFocused(); + if (pFocusedControl) + { + pFocusedControl->SetFocused(); + } + else + { + pCurrentForm->SetFocused(); + } +} + +bool +_Frame::OnNotifiedN(const _Control& source, IList* pArgs) +{ + SysTryReturn(NID_UI_CTRL, pArgs, false, E_SYSTEM, "[E_SYSTEM] pArgs is null.") + + String* pType = dynamic_cast (pArgs->GetAt(0)); + SysTryReturn(NID_UI_CTRL, pType, false, E_SYSTEM, "[E_SYSTEM] pType is null.") + + if (*pType == L"VisibilityEvent") + { + int obscured = 0; + + Integer* pObscured = dynamic_cast(pArgs->GetAt(1)); + if (pObscured == null) + { + pArgs->RemoveAll(true); + delete pArgs; + + return true; + } + + obscured = pObscured->ToInt(); + if (obscured == 0) + { + __activated = true; + OnFrameActivated(); + } + else + { + __activated = false; + OnFrameDeactivated(); + } + + pArgs->RemoveAll(true); + delete pArgs; + + return true; + } + + return false; +} + +void +_Frame::OnFrameActivated(void) +{ + int childcount = GetChildCount(); + + for (int i = 0 ; i < childcount ; i++) + { + _Control* pChild = GetChild(i); + _Form* pForm = dynamic_cast<_Form*>(pChild); + if (pForm) + { + pForm->MoveOverlayRegion(true); + } + } + + // Fire Event. + IEventArg* pArg = _FrameEvent::CreateFrameEventArgN(*this, _FRAME_STATUS_ACTIVATED); + __pFrameEvent->Fire(*pArg); + + if (GetChildCount() < 1) + { + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas"); +#if !defined(MULTI_WINDOW) + pEcoreEvas->SetIndicatorShowState(false); +#else + if (GetShowMode() == FRAME_SHOW_MODE_FULL_SCREEN) + { + pEcoreEvas->SetIndicatorShowState(*GetRootWindow(), false); + } +#endif + } +} + +void +_Frame::OnFrameDeactivated(void) +{ + int childcount = GetChildCount(); + + for (int i = 0 ; i < childcount ; i++) + { + _Control* pChild = GetChild(i); + _Form* pForm = dynamic_cast<_Form*>(pChild); + if (pForm) + { + pForm->MoveOverlayRegion(false); + } + } + + // Fire Event. + IEventArg* pArg = _FrameEvent::CreateFrameEventArgN(*this, _FRAME_STATUS_DEACTIVATED); + __pFrameEvent->Fire(*pArg); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + if (pTouchManager) + { + pTouchManager->SetTouchCanceled(true); + } +} + +bool +_Frame::IsFocusableDescendant(const _Control* pFocus) const +{ + const _Control* pTopChild = GetChild(GetChildCount() - 1); // Find the current Form. + const _Control* pTop = pFocus; + + if (pTop == this) + { + return true; + } + + // 1. Find the Form of the pFocus. + // 2. If the Form is the current Form, then return true. + while (pTop) + { + if (pTop == pTopChild) + { + return true; + } + pTop = pTop->GetParent(); + } + + return false; +} + +void +_Frame::SetFocusOff(_Control* pFocus) +{ + _Control* pTopOfFocus = null; + _Control* pTemp = pFocus; + + while (pTemp != this) + { + pTopOfFocus = pTemp; + pTemp = pTemp->GetParent(); + } + + // [ToDo] If pTem == null??? + + if (pTopOfFocus) + { + pTopOfFocus->SetFocusOff(pFocus); + } +} + +void +_Frame::SetCurrentForm(const _Form* pForm) +{ + result r = E_SUCCESS; + + SysTryReturnVoidResult(NID_UI_CTRL, pForm != null, E_INVALID_ARG, "[E_INVALID_ARG] Form to become a new current form is null"); + _Form* pNewForm = const_cast<_Form*>(pForm); + + _Form* pCurrentForm = GetCurrentForm(); + pNewForm->AddIndicatorObject(); + + if (pCurrentForm != null) + { + if (pCurrentForm != pForm) + { + // Change order + r = MoveChildToTop(*pForm); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pNewForm->MoveOverlayRegion(true); + + pCurrentForm->SetVisibleState(false); + pCurrentForm->MoveOverlayRegion(false); + + if (__pFormActivationChangeEventListener) + __pFormActivationChangeEventListener->OnFormDeactivated(*pCurrentForm); + } + } + + _Control* pFocus = pNewForm->GetFocused(); + if (pFocus) + { + pFocus->SetFocused(); + } + else + { + pNewForm->SetFocused(); + } + + pNewForm->SetVisibleState(true); + pNewForm->SetUpdateLayoutState(true); + + if (__pFormActivationChangeEventListener) + __pFormActivationChangeEventListener->OnFormActivated(*pNewForm); + + SetLastResult(E_SUCCESS); + + return; +} + +_Form* +_Frame::GetCurrentForm(void) const +{ + _Form* pCurrentForm = null; + int controlCount = GetChildCount(); + + if (controlCount > 0) + { + for (int i = controlCount; i > 0; i--) + { + pCurrentForm = dynamic_cast<_Form*>(GetChild(i - 1)); + SysTryReturn(NID_UI_CTRL, pCurrentForm != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + if (pCurrentForm->IsVisible()) + { + break; + } + } + } + + return pCurrentForm; +} + +#if !defined(MULTI_WINDOW) +bool +_Frame::IsLayoutChangable(void) const +{ + return false; +} +#endif + +bool +_Frame::IsOrientationRoot(void) const +{ + return true; +} + +void +_Frame::AddFrameEventListener(const _IFrameEventListener& listener) +{ + result r = __pFrameEvent->AddListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_Frame::RemoveFrameEventListener(const _IFrameEventListener& listener) +{ + result r = __pFrameEvent->RemoveListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_Frame::SetFormActivationChangeEventListener(const _IFormActivationChangeEventListener* plistener) +{ + __pFormActivationChangeEventListener = const_cast<_IFormActivationChangeEventListener*>(plistener); +} + + +void +_Frame::SetFloatingBounds(const Rectangle& rect) +{ + __floatingBounds = rect; +} + +result +_Frame::SetShowMode(FrameShowMode showMode) +{ + bool changeMode = true; + + if ((showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (showMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING)) + { + _Form* pCurrentForm = GetCurrentForm(); + + if (pCurrentForm) + { + if (pCurrentForm->GetFormStyle() & _FORM_STYLE_INDICATOR) + { + changeMode = false; + } + } + } + + SysTryReturnResult(NID_UI_CTRL, changeMode == true, E_SYSTEM, "The method cannot proceed due to a severe system error."); + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturnResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "The method cannot proceed due to a severe system error."); + + int oldShowMode = __showMode; + __showMode = showMode; + + result r = E_SUCCESS; + + switch (__showMode) + { + case FRAME_SHOW_MODE_FULL_SCREEN: + if (oldShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING) + { +#if !defined(MULTI_WINDOW) + r = pEcoreEvas->SetFloatingMode(false); +#else + r = pEcoreEvas->SetFloatingMode(*GetRootWindow(), false); +#endif + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (oldShowMode != FRAME_SHOW_MODE_FULL_SCREEN) + { + Dimension screen = _ControlManager::GetInstance()->GetScreenSize(); + + __restore = true; + + if (GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) + { + SetBounds(Rectangle(0, 0, screen.width, screen.height)); + } + else + { + SetBounds(Rectangle(0, 0, screen.height, screen.width)); + } + + __restore = false; + } + + break; + case FRAME_SHOW_MODE_PARTIAL_SCREEN: + if (oldShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING) + { +#if !defined(MULTI_WINDOW) + r = pEcoreEvas->SetFloatingMode(false); +#else + r = pEcoreEvas->SetFloatingMode(*GetRootWindow(), false); +#endif + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (oldShowMode == FRAME_SHOW_MODE_FULL_SCREEN) + { + SetBounds(__floatingBounds); + } + else if (oldShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING) + { +#if !defined(MULTI_WINDOW) + pEcoreEvas->SetWindowBounds(__floatingBounds); +#else + pEcoreEvas->SetWindowBounds(*GetRootWindow(), __floatingBounds); +#endif + } + + break; + case FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING: + if (oldShowMode != FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING) + { +#if !defined(MULTI_WINDOW) + r = pEcoreEvas->SetFloatingMode(true); +#else + r = pEcoreEvas->SetFloatingMode(*GetRootWindow(), true); +#endif + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (oldShowMode == FRAME_SHOW_MODE_FULL_SCREEN) + { + SetBounds(__floatingBounds); + } + + break; + default: + break; + } + + return E_SUCCESS; +} + +FrameShowMode +_Frame::GetShowMode(void) const +{ + return __showMode; +} + +bool +_Frame::IsActivated(void) const +{ + return __activated; +} + +void +_Frame::OnChildAttached(const _Control& child) +{ + _Form* pCurrentForm = GetCurrentForm(); + + if (pCurrentForm == &child) + { + int controlCount = GetChildCount(); + + if (controlCount > 1) + { + _Control* pOldCurrentForm = GetChild(controlCount - 2); + SysTryReturnVoidResult(NID_UI_CTRL, pOldCurrentForm != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + pOldCurrentForm->SetVisibleState(false); + } + } +} + +void +_Frame::OnChildDetached(const _Control& child) +{ + int controlCount = GetChildCount(); + + if (controlCount > 0) + { + _Control* pCurrentForm = GetChild(controlCount - 1); + SysTryReturnVoidResult(NID_UI_CTRL, pCurrentForm, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + pCurrentForm->SetVisibleState(true); + } + else + { + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas"); +#if !defined(MULTI_WINDOW) + pEcoreEvas->SetIndicatorShowState(false); +#else + pEcoreEvas->SetIndicatorShowState(*GetRootWindow(), false); +#endif + } +} + +result +_Frame::OnBoundsChanging(const Rectangle& bounds) +{ + if (__restore == false) + { + __floatingBounds = bounds; + } + + if ((__showMode == FRAME_SHOW_MODE_FULL_SCREEN) && (__restore == false)) + { + return E_SUCCESS; + } + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + +#if !defined(MULTI_WINDOW) + pEcoreEvas->SetWindowBounds(bounds); +#else + pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds); +#endif + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + + +result +_Frame::OnAttached(void) +{ + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysAssert(pEcoreEvas); + +#if !defined(MULTI_WINDOW) + pEcoreEvas->SetWindowVisibleState(true); +#else + pEcoreEvas->SetWindowVisibleState(*GetRootWindow(), true); +#endif + + return E_SUCCESS; +} + +#if !defined(MULTI_WINDOW) +result +_Frame::OnAttachedToMainTree(void) +{ + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysAssert(pEcoreEvas); + + _RootVisualElement* pRootVE = pEcoreEvas->GetRootVisualElement(); + SysAssert(pRootVE); + + _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer()); + SysAssert(pLayer); + + pLayer->SetShowState(true); + pRootVE->SetShowState(true); + + return E_SUCCESS; +} + +void +_Frame::OnVisibleStateChanged(void) +{ + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + bool visibleState = GetVisibleState(); + + pEcoreEvas->SetWindowVisibleState(visibleState); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} +#endif + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FrameEvent.cpp b/src/ui/controls/FUiCtrl_FrameEvent.cpp new file mode 100644 index 0000000..0ce7b77 --- /dev/null +++ b/src/ui/controls/FUiCtrl_FrameEvent.cpp @@ -0,0 +1,179 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FrameEvent.cpp + * @brief This is the implementation for the _FrameEvent class. + * @version 1.0 + */ + +#include +#include +#include +#include +#include "FUiCtrl_IFrameEventListener.h" +#include "FUiCtrl_FrameEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _FrameEventArg + * @brief This class is used as an argument of event listener's method. + * + * This class is used as an argument of event listener's method. When frame event is generated, + * the @c _FrameEvent instance calls WindowEventListener's method with instance of this class as an argument. + */ +class _FrameEventArg + : public Tizen::Base::Object + , public Tizen::Base::Runtime::IEventArg +{ +public: +// Lifecycle + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the _Frame instance which contains this instance. + * @param[in] frameState The frame event type. + */ + _FrameEventArg(const _Frame& source, int frameState); + + /** + * This is the class destructor. + * + */ + virtual ~_FrameEventArg(void); + +// Accessor + /** + * This method returns the Window object which the event initially occurred. + * + * @return See the comment above. + * + */ + const _Frame* GetSource(void) const; + + /** + * This method returns the event type of frame event. + * + * @return See the comment above. + */ + int GetType(void) const; + +private: +// Attribute + _Frame* __pSource; + int __frameState; +}; // _FrameEventArg + +_FrameEventArg::_FrameEventArg(const _Frame& source, int frameState) + : __pSource(const_cast <_Frame*>(&source)) + , __frameState(frameState) +{ +} + +_FrameEventArg::~_FrameEventArg(void) +{ +} + +const _Frame* +_FrameEventArg::GetSource(void) const +{ + return __pSource; +} + +int +_FrameEventArg::GetType(void) const +{ + return __frameState; +} + +_FrameEvent* +_FrameEvent::CreateInstanceN(const _Frame& source) +{ + _FrameEvent* pFrameEvent = new (std::nothrow) _FrameEvent(source); + SysTryReturn(NID_UI_CTRL, pFrameEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + SetLastResult(E_SUCCESS); + + return pFrameEvent; + +CATCH: + delete pFrameEvent; + return null; +} + +IEventArg* +_FrameEvent::CreateFrameEventArgN(const _Frame& source, int frameState) +{ + _FrameEventArg* pEventArg = new (std::nothrow) _FrameEventArg(source, frameState); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + SetLastResult(E_SUCCESS); + + return pEventArg; +} + +_FrameEvent::~_FrameEvent(void) +{ +} + +const _Frame* +_FrameEvent::GetSource(void) const +{ + return __pSource; +} + +void +_FrameEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _IFrameEventListener* pFrameListener = dynamic_cast <_IFrameEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pFrameListener, E_INVALID_ARG, "[E_INVALID_ARG] The invalid listener was given."); + + const _FrameEventArg* pArg = static_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_INVALID_ARG, "[E_INVALID_ARG] The invalid event argument was given."); + + if (pArg->GetType() == _FRAME_STATUS_ACTIVATED) + { + pFrameListener->OnFrameActivated(*pArg->GetSource()); + } + else if (pArg->GetType() == _FRAME_STATUS_DEACTIVATED) + { + pFrameListener->OnFrameDeactivated(*pArg->GetSource()); + } + + return; +} + +_FrameEvent::_FrameEvent(const _Frame& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSource = &source; + + ClearLastResult(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FrameImpl.cpp b/src/ui/controls/FUiCtrl_FrameImpl.cpp new file mode 100644 index 0000000..36b3844 --- /dev/null +++ b/src/ui/controls/FUiCtrl_FrameImpl.cpp @@ -0,0 +1,470 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include +#include +#include "FUi_ControlManager.h" +#include "FUi_OrientationAgent.h" +#include "FUiCtrlForm.h" +#include "FUiCtrl_FrameImpl.h" +#include "FUiCtrl_FormImpl.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_PublicFrameEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls { + +const _FrameImpl* +_FrameImpl::GetInstance(const Frame& frame) +{ + return static_cast (frame._pControlImpl); +} + +_FrameImpl* +_FrameImpl::GetInstance(Frame& frame) +{ + return static_cast<_FrameImpl*> (frame._pControlImpl); +} + +void +_FrameImpl::Dispose(void) +{ + GetCore().RemoveFrameEventListener(*this); + + if (__pFrameEvent) + { + delete __pFrameEvent; + __pFrameEvent = null; + } + + delete __pOrientationAgent; + __pOrientationAgent = null; + + delete __pFrameAnimator; + __pFrameAnimator = null; +} + +_FrameImpl::_FrameImpl(Frame* pPublic, _Frame* pCore) + : _WindowImpl(pPublic, pCore) + , __pFrameEvent(null) + , __pFrameAnimator(null) + , __pOrientationAgent(null) +{ + __pFrameEvent = _PublicFrameEvent::CreateInstanceN(*pPublic); + SysTryReturnVoidResult(NID_UI_CTRL, __pFrameEvent, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pOrientationAgent = _OrientationAgent::CreateInstanceN(*pPublic); + SysTryCatch(NID_UI_CTRL, __pOrientationAgent != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return; + +CATCH: + Dispose(); +} + +_FrameImpl::~_FrameImpl(void) +{ + // [ToDo] Wrong point to call OnFrameTerminating(). + if (__pFrameEvent) + { + IEventArg* pEventArg = _PublicFrameEvent::CreateFrameEventArgN(_FrameImpl::GetPublic(), FRAME_STATE_TERMINATING); + if (pEventArg) + { + __pFrameEvent->Fire(*pEventArg); + } + } + + Dispose(); + ClearLastResult(); +} + +const char* +_FrameImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::Frame"; +} + +const Frame& +_FrameImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +Frame& +_FrameImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _Frame& +_FrameImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_Frame& +_FrameImpl::GetCore(void) +{ + return static_cast<_Frame&>(_ControlImpl::GetCore()); +} + +result +_FrameImpl::SetCurrentForm(const _FormImpl& formImpl) +{ + result r = E_SUCCESS; + + _FormImpl* pNewCurForm = const_cast<_FormImpl*>(&formImpl); + + SysTryReturn(NID_UI_CTRL, + pNewCurForm != null, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The Form is not initialized."); + + SysTryReturn(NID_UI_CTRL, + IsAncestorOf(pNewCurForm), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The Form is not the child of this Frame."); + + if (GetCore().GetShowMode() != FRAME_SHOW_MODE_FULL_SCREEN) + { + SysTryReturn(NID_UI_CTRL, !(pNewCurForm->GetFormStyle() & FORM_STYLE_INDICATOR), E_INVALID_ARG, E_INVALID_ARG, "Only Frame whose show mode is @c FRAME_SHOW_MODE_FULL_SCREEN can set a Form which has the style of @c FORM_STYLE_INDICATOR as the current form."); + } + + + r = MoveChildToTop(*pNewCurForm); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // [ToDo] Change the method to return result. And the arg should be reference. + GetCore().SetCurrentForm(&pNewCurForm->GetCore()); + r = GetLastResult(); + SysAssert(r == E_SUCCESS); // [ToDo] Exception check. + + pNewCurForm->UpdateOrientationStatus(); + + // [ToDo] Check last result + SysAssert(GetLastResult() == E_SUCCESS); + return E_SUCCESS; +} + +// [ToDo] This function should return _FormImpl*. +_FormImpl* +_FrameImpl::GetCurrentForm(void) const +{ + _Control* pFormCore = GetCore().GetCurrentForm(); + SysTryReturn(NID_UI_CTRL, pFormCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _FormImpl* pFormImpl = static_cast<_FormImpl*>(pFormCore->GetUserData()); + + return pFormImpl; +} + +_FrameImpl* +_FrameImpl::CreateFrameImplN(Frame* pPublic) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _Frame* pCore = _Frame::CreateFrameN(); + SysTryReturn(NID_UI_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _FrameImpl* pImpl = new (std::nothrow) _FrameImpl(pPublic, pCore); + r = _ControlImpl::CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCore->SetSize(_ControlManager::GetInstance()->GetScreenSize()); + + pCore->AddFrameEventListener(*pImpl); + + SetLastResult(E_SUCCESS); + + return pImpl; +} + +void +_FrameImpl::AddFrameEventListener(IFrameEventListener& listener) +{ + result r = __pFrameEvent->AddListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_FrameImpl::RemoveFrameEventListener(IFrameEventListener& listener) +{ + result r = __pFrameEvent->RemoveListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +Animations::FrameAnimator* +_FrameImpl::GetFrameAnimator(void) const +{ + if (__pFrameAnimator == null) + { + FrameAnimator* pFrameAnimator = new (std::nothrow) FrameAnimator(); + SysTryReturn(NID_UI_CTRL, + pFrameAnimator != null, null, + E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + result r = pFrameAnimator->Construct(GetPublic()); + if (IsFailed(r)) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] FrameAnimator::Construct failed"); + delete pFrameAnimator; + return null; + } + + const_cast<_FrameImpl*>(this)->__pFrameAnimator = pFrameAnimator; + } + + SetLastResult(E_SUCCESS); + + return __pFrameAnimator; +} + +void +_FrameImpl::OnDraw(void) +{ + __pOrientationAgent->FireOrientationEvent(); + + _WindowImpl::OnDraw(); +} + +void +_FrameImpl::OnChangeLayout(_ControlOrientation orientation) +{ + // Change layout. + _ContainerImpl::OnChangeLayout(orientation); + SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + bool resizable = IsResizable(); + SetResizable(true); + + _ControlManager* pCoreManager = _ControlManager::GetInstance(); + SysAssert(pCoreManager); + const Dimension& screenSize = pCoreManager->GetScreenSize(); + +#if !defined(MULTI_WINDOW) + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + SetSize(screenSize); + } + else + { + SetSize(Dimension(screenSize.height, screenSize.width)); + } +#else + if (GetCore().GetShowMode() == FRAME_SHOW_MODE_FULL_SCREEN) + { + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + SetSize(screenSize); + } + else + { + SetSize(Dimension(screenSize.height, screenSize.width)); + } + } +#endif + + SetResizable(resizable); +} + +void +_FrameImpl::OnChildDetaching(const _Control& child) +{ + result r = E_SUCCESS; + + _FormImpl* pFormImpl = static_cast<_FormImpl*>(child.GetUserData()); + + _FormImpl* pCurrentForm = GetCurrentForm(); + + if (pCurrentForm != null) + { + if (pCurrentForm == pFormImpl) + { + // if the given control will be the current form, hide the current form + int count = GetChildCount(); + if (count > 1) + { + _ControlImpl* pControlImpl = GetChild(count - 2); + if (!pControlImpl) + { + return ; + } + + Form* pPrevForm = static_cast(&pControlImpl->GetPublic()); + + if (pPrevForm != null) + { + r = pPrevForm->SetShowState(true); + if (IsFailed(r)) + { + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return ; + } + } + } + } + } +} + +void +_FrameImpl::OnChildDetached(const _Control& child) +{ + _ControlImpl::OnChildDetached(child); + + int childCount = GetCore().GetChildCount(); + if (childCount == 0) + { + UpdateOrientationStatus(); + } +} + +void +_FrameImpl::OnFrameActivated(const _Frame& source) +{ + if (__pFrameEvent) + { + IEventArg* pEventArg = _PublicFrameEvent::CreateFrameEventArgN(_FrameImpl::GetPublic(), FRAME_STATE_ACTIVATED); + if (pEventArg) + { + __pFrameEvent->Fire(*pEventArg); + } + } +} + +void +_FrameImpl::OnFrameDeactivated(const _Frame& source) +{ + if (__pFrameEvent) + { + IEventArg* pEventArg = _PublicFrameEvent::CreateFrameEventArgN(_FrameImpl::GetPublic(), FRAME_STATE_DEACTIVATED); + if (pEventArg) + { + __pFrameEvent->Fire(*pEventArg); + } + } +} + +void +_FrameImpl::OnBoundsChanged(void) +{ + int childcount = GetChildCount(); + Rectangle bounds = GetBounds(); + + for (int i = 0 ; i < childcount ; i++) + { + _ControlImpl* pChild = GetChild(i); + _FormImpl* pForm = dynamic_cast<_FormImpl*>(pChild); + if (pForm) + { + if (GetShowMode() == FRAME_SHOW_MODE_FULL_SCREEN) + { + if (pForm->GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || pForm->GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE) + { + pForm->SetBounds(Rectangle(0, 0, GetBounds().width, GetBounds().height)); + } + else + { + pForm->SetBounds(Rectangle(0, 0, GetBounds().height, GetBounds().width)); + } + } + else + { + pForm->SetBounds(Rectangle(0, 0, GetBounds().width, GetBounds().height)); + } + + } + } + + _ContainerImpl::OnBoundsChanged(); + +} + + +void +_FrameImpl::AddOrientationEventListener(Tizen::Ui::IOrientationEventListener& listener) +{ + __pOrientationAgent->AddListener(listener); +} + +void +_FrameImpl::RemoveOrientationEventListener(Tizen::Ui::IOrientationEventListener& listener) +{ + __pOrientationAgent->RemoveListener(listener); +} + +void +_FrameImpl::SetOrientation(Orientation orientation) +{ + __pOrientationAgent->SetMode(orientation); +} + +Orientation +_FrameImpl::GetOrientation(void) const +{ + return __pOrientationAgent->GetMode(); +} + +OrientationStatus +_FrameImpl::GetOrientationStatus(void) const +{ + return __pOrientationAgent->GetStatus(); +} + +bool +_FrameImpl::IsChildAttachable(_ControlImpl& child) const +{ + return (dynamic_cast<_FormImpl*>(&child) != null); +} + +void +_FrameImpl::UpdateOrientationStatus(void) +{ + __pOrientationAgent->Update(); +} + +bool +_FrameImpl::IsOpaque(void) const +{ + return true; +} + +void +_FrameImpl::SetFloatingBounds(const Rectangle& rect) +{ + GetCore().SetFloatingBounds(rect); +} + +result +_FrameImpl::SetShowMode(FrameShowMode showMode) +{ + return GetCore().SetShowMode(showMode); +} + +FrameShowMode +_FrameImpl::GetShowMode(void) const +{ + return GetCore().GetShowMode(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FrameModel.cpp b/src/ui/controls/FUiCtrl_FrameModel.cpp new file mode 100644 index 0000000..aa4e252 --- /dev/null +++ b/src/ui/controls/FUiCtrl_FrameModel.cpp @@ -0,0 +1,37 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FrameModel.cpp + * @brief This is the implementation file for the _FrameModel class. + */ + +#include +#include +#include "FUiCtrl_FrameModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_FrameModel::_FrameModel(void) +{ +} + +_FrameModel::~_FrameModel(void) +{ +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_FramePresenter.cpp b/src/ui/controls/FUiCtrl_FramePresenter.cpp new file mode 100644 index 0000000..628dc8c --- /dev/null +++ b/src/ui/controls/FUiCtrl_FramePresenter.cpp @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FramePresenter.cpp + * @brief This is the implementation file for the _FramePresenter class. + */ + +#include +#include +#include +#include +#include "FUiCtrl_FramePresenter.h" +#include "FUiCtrl_FrameModel.h" +#include "FUiCtrl_Frame.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_FramePresenter::_FramePresenter(const _Frame& frame) + : __pFrame(null) + , __pFrameModel(null) +{ + __pFrame = const_cast <_Frame*>(&frame); + + _FrameModel* pModel = new (std::nothrow) _FrameModel; + SysTryReturnVoidResult(NID_UI_CTRL, pModel, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + _SetModel(*pModel); + + ClearLastResult(); + + return; +} + +_FramePresenter::~_FramePresenter(void) +{ + if (__pFrameModel) + { + delete __pFrameModel; + __pFrameModel = null; + } + + ClearLastResult(); +} + +result +_FramePresenter::_SetModel(const _FrameModel& frameModel) +{ + __pFrameModel = const_cast <_FrameModel*>(&frameModel); + + return E_SUCCESS; +} + +void +_FramePresenter::Draw(void) +{ + _Draw(); + + return; +} + +void +_FramePresenter::_Draw(void) +{ + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Gallery.cpp b/src/ui/controls/FUiCtrl_Gallery.cpp new file mode 100644 index 0000000..5d2e497 --- /dev/null +++ b/src/ui/controls/FUiCtrl_Gallery.cpp @@ -0,0 +1,479 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include "FUi_TouchFlickGestureDetector.h" +#include "FUi_TouchTapGestureDetector.h" +#include "FUi_TouchPinchGestureDetector.h" +#include "FUiCtrl_Gallery.h" +#include "FUiCtrl_GalleryBitmap.h" +#include "FUiCtrl_GalleryPresenter.h" +#include "FUiCtrl_GalleryRenderer.h" +#include "FUiCtrl_GalleryRendererNotification.h" +#include "FUiCtrl_GalleryViewEventInfo.h" +#include "FUiCtrl_GalleryViewEvent.h" +#include "FUiCtrl_IGalleryCoreEventListener.h" +#include "FUiCtrl_IGalleryRendererNotiListener.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Effects; + +namespace Tizen { namespace Ui { namespace Controls { + +_Gallery::_Gallery(void) + : __pRenderer(null) + , __pPresenter(null) + , __modelInitialized(false) +{ + // Do nothing. +} + +_Gallery::~_Gallery(void) +{ + result r = __flickGesture.RemoveGestureListener(*this); + if (r != E_SUCCESS) + { + SetLastResult(r); + SysAssert(false); + } + + r = RemoveGestureDetector(__flickGesture); + if (r != E_SUCCESS) + { + SetLastResult(r); + SysAssert(false); + } + + r = __tapGesture.RemoveGestureListener(*this); + if (r != E_SUCCESS) + { + SetLastResult(r); + SysAssert(false); + } + + r = RemoveGestureDetector(__tapGesture); + if (r != E_SUCCESS) + { + SetLastResult(r); + SysAssert(false); + } + + r = __pinchGesture.RemoveGestureListener(*this); + if (r != E_SUCCESS) + { + SetLastResult(r); + SysAssert(false); + } + + r = RemoveGestureDetector(__pinchGesture); + if (r != E_SUCCESS) + { + SetLastResult(r); + SysAssert(false); + } + + delete __pRenderer; + delete __pPresenter; +} + +_Gallery* +_Gallery::CreateGalleryN(_GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor) +{ + result r = E_SUCCESS; + ClearLastResult(); + + _Gallery* pGallery = new (std::nothrow) _Gallery(); + SysTryCatch(NID_UI_CTRL, pGallery != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _Gallery."); + + r = pGallery->Construct(pGalleryItemProviderAdaptor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pGallery; + +CATCH: + delete pGallery; + + return null; +} + +result +_Gallery::Construct(_GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor) +{ + result r = E_SUCCESS; + _GalleryRenderer* pRenderer = null; + _GalleryPresenter* pPresenter = null; + + pRenderer = _GalleryRenderer::CreateGalleryRendererN((Tizen::Ui::_Control&)*this); + SysTryCatch(NID_UI_CTRL, pRenderer != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the _GalleryRenderer."); + + pPresenter = _GalleryPresenter::CreateGalleryPresenterN((_IGalleryRenderer&)*pRenderer, pGalleryItemProviderAdaptor); + SysTryCatch(NID_UI_CTRL, pPresenter != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the _GalleryPresenter."); + + r = pRenderer->AddNotiListener(*pPresenter); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + AcquireHandle(); + + r = __flickGesture.AddGestureListener(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = _Control::AddGestureDetector(__flickGesture); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __tapGesture.AddGestureListener(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __tapGesture.SetTapCount(2); + r = _Control::AddGestureDetector(__tapGesture); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetMultiTouchEnabled(true); + r = _Control::AddGestureDetector(__pinchGesture); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pinchGesture.AddGestureListener(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetRenderer((_GalleryRenderer &)*pRenderer); + SetPresenter((_GalleryPresenter &)*pPresenter); + + return E_SUCCESS; + +CATCH: + delete pRenderer; + delete pPresenter; + + return r; +} + +// presenter access +result +_Gallery::SetTextOfEmptyGallery(const String& text) +{ + return GetPresenter().SetTextOfEmptyGallery(text); +} + +String +_Gallery::GetTextOfEmptyGallery(void) const +{ + return GetPresenter().GetTextOfEmptyGallery(); +} + +result +_Gallery::SetBitmapOfEmptyGallery(const _GalleryBitmap* pBitmap) +{ + return GetPresenter().SetBitmapOfEmptyGallery(pBitmap); +} + +result +_Gallery::SetCoreEventListener(const _IGalleryCoreEventListener& coreEventListener) +{ + return GetPresenter().SetCoreEventListener(coreEventListener); +} + +result +_Gallery::RemoveCoreEventListener(const _IGalleryCoreEventListener& coreEventListener) +{ + return GetPresenter().RemoveCoreEventListener(coreEventListener); +} + +result +_Gallery::SetZoomingEnabled(bool enable) +{ + return GetPresenter().SetZoomingEnabled(enable); +} + +bool +_Gallery::IsZoomingEnabled(void) const +{ + return GetPresenter().IsZoomingEnabled(); +} + +result +_Gallery::SetSlideShowType(_GallerySlideShowType slideShowType) +{ + return GetPresenter().SetSlideShowType(slideShowType); +} + +_GallerySlideShowType +_Gallery::GetSlideShowType(void) const +{ + return GetPresenter().GetSlideShowType(); +} + +result +_Gallery::SetSlideShowAnimationDuration(int duration) +{ + return GetPresenter().SetSlideShowAnimationDuration(duration); +} + +int +_Gallery::GetSlideShowAnimationDuration(void) const +{ + return GetPresenter().GetSlideShowAnimationDuration(); +} + +result +_Gallery::SetSlideShowViewDuration(int duration) +{ + return GetPresenter().SetSlideShowViewDuration(duration); +} + +int +_Gallery::GetSlideShowViewDuration(void) const +{ + return GetPresenter().GetSlideShowViewDuration(); +} + +result +_Gallery::StartSlideShow(bool repeat) +{ + return GetPresenter().StartSlideShow(repeat); +} + +result +_Gallery::StopSlideShow(void) +{ + return GetPresenter().StopSlideShow(); +} + +bool +_Gallery::IsSlideShowStarted(void) const +{ + return GetPresenter().IsSlideShowStarted(); +} + +// model access +result +_Gallery::SetCurrentItemIndex(int itemIndex) +{ + return GetPresenter().SetCurrentItem(itemIndex); +} + +int +_Gallery::GetCurrentItemIndex(void) const +{ + return GetPresenter().GetCurrentItemIndex(); +} + +int +_Gallery::GetItemCount(void) const +{ + return GetPresenter().GetItemCount(); +} + +result +_Gallery::RequestToLoadItem(int itemIndex) +{ + SysTryReturnResult(NID_UI_CTRL, __modelInitialized == true, E_INVALID_OPERATION, "Does not call to first draw."); + return GetPresenter().RequestToLoadItem(itemIndex); +} + +result +_Gallery::RequestToUnloadItem(int itemIndex) +{ + SysTryReturnResult(NID_UI_CTRL, __modelInitialized == true, E_INVALID_OPERATION, "Does not call to first draw."); + return GetPresenter().RequestToUnloadItem(itemIndex); +} + +result +_Gallery::RequestToUnloadAllItems(void) +{ + return GetPresenter().RequestToUnloadAllItems(); +} + +result +_Gallery::RequestToUpdateItem(int itemIndex) +{ + SysTryReturnResult(NID_UI_CTRL, __modelInitialized == true, E_INVALID_OPERATION, "Does not call to first draw."); + return GetPresenter().RequestToUpdateItem(itemIndex); +} + +result +_Gallery::RequestToUpdateAllItems(void) +{ + return GetPresenter().RequestToUpdateAllItems(); +} + +bool +_Gallery::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) +{ + _GalleryViewEventInfo viewEventInfo; + int distanceX = 0; + int distanceY = 0; + gesture.GetDistance(distanceX, distanceY); + Point flickPoint(distanceX, distanceY); + + viewEventInfo.SetFlickPosition(flickPoint); + viewEventInfo.SetFlicked(true); + viewEventInfo.SetFlickTime(gesture.GetDuration()); + _GalleryViewEvent viewEvent(GALLERY_VIEW_EVENT_TOUCH_FLICK, &viewEventInfo); + bool r = GetPresenter().PostEvent(viewEvent); + SysTryReturn(NID_UI_CTRL, r == true, true, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return true; +} + +bool +_Gallery::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture) +{ + return false; +} + +bool +_Gallery::OnTapGestureDetected(_TouchTapGestureDetector& gesture) +{ + Point pos(0, 0); + Tizen::Ui::_TouchInfo touchInfo(0, _TOUCH_DOUBLE_PRESSED, pos, false, 0); + _GalleryViewEventInfo viewEventInfo(touchInfo); + _GalleryViewEvent viewEvent(GALLERY_VIEW_EVENT_TOUCH_DOUBLE_PRESSED, &viewEventInfo); + + bool r = GetPresenter().PostEvent(viewEvent); + SysTryReturn(NID_UI_CTRL, r == true, true, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return true; +} + +bool +_Gallery::OnTapGestureCanceled(_TouchTapGestureDetector& gesture) +{ + return false; +} + +bool +_Gallery::OnPinchGestureStarted(_TouchPinchGestureDetector& gesture) +{ + //return OnPinchGestureChanged(gesture); + return true; +} + +bool +_Gallery::OnPinchGestureChanged(_TouchPinchGestureDetector& gesture) +{ + _GalleryViewEventInfo viewEventInfo; + viewEventInfo.SetPinchCenterPosition(gesture.GetCenterPoint()); + viewEventInfo.SetPinchArea(gesture.GetScale()); + _GalleryViewEvent viewEvent(GALLERY_VIEW_EVENT_TOUCH_PINCH_ZOOM, &viewEventInfo); + bool r = GetPresenter().PostEvent(viewEvent); + SysTryReturn(NID_UI_CTRL, r == true, true, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + return true; +} + +bool +_Gallery::OnPinchGestureFinished(_TouchPinchGestureDetector& gesture) +{ + //return OnPinchGestureChanged(gesture); + return true; +} + +bool +_Gallery::OnPinchGestureCanceled(_TouchPinchGestureDetector& gesture) +{ + return false; +} + +// Touch Event Callbacks +bool +_Gallery::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + _GalleryViewEventInfo viewEventInfo(const_cast <_TouchInfo&>(touchinfo)); + _GalleryViewEvent viewEvent(GALLERY_VIEW_EVENT_TOUCH_PRESSED, &viewEventInfo); + + return GetPresenter().PostEvent(viewEvent); +} + +bool +_Gallery::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + _GalleryViewEventInfo viewEventInfo(const_cast <_TouchInfo&>(touchinfo)); + _GalleryViewEvent viewEvent(GALLERY_VIEW_EVENT_TOUCH_RELEASED, &viewEventInfo); + + return GetPresenter().PostEvent(viewEvent); +} + +bool +_Gallery::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + _GalleryViewEventInfo viewEventInfo(const_cast <_TouchInfo&>(touchinfo)); + _GalleryViewEvent viewEvent(GALLERY_VIEW_EVENT_TOUCH_MOVED, &viewEventInfo); + + bool r = GetPresenter().PostEvent(viewEvent); + SysTryReturn(NID_UI_CTRL, r == true, true, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return true; +} + +bool +_Gallery::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return true; +} + +// Windowing Event Callbacks +void +_Gallery::OnDraw(void) +{ + if (__modelInitialized == false) + { + //GetPresenter().RequestToUpdateItemCount(); + __modelInitialized = true; + } + + GetPresenter().OnDraw(); +} + +void +_Gallery::OnBoundsChanged(void) +{ +// GetRenderer().OnBoundsChanged(); + _GalleryViewEventInfo viewEventInfo; + _GalleryViewEvent viewEvent(GALLERY_VIEW_EVENT_BOUNDS_CHANGED, &viewEventInfo); + + bool r = GetPresenter().PostEvent(viewEvent); + SysTryReturnVoidResult(NID_UI_CTRL, r == true, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); +} + +void +_Gallery::OnFontInfoRequested(unsigned long& style, int& size) +{ + GetPresenter().OnFontInfoRequested(style, size); +} + +void +_Gallery::OnFontChanged(Font* pFont) +{ + GetPresenter().OnFontChanged(); +} + +void +_Gallery::SetEffect(Effect* pEffect) +{ + GetRenderer().SetEffect(pEffect); +} + +Effect* +_Gallery::GetEffect(void) +{ + return GetRenderer().GetEffect(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryBitmap.cpp b/src/ui/controls/FUiCtrl_GalleryBitmap.cpp new file mode 100644 index 0000000..90046d2 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryBitmap.cpp @@ -0,0 +1,323 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include +#include +#include <../util/FGrp_Util.h> +#include "FUi_Math.h" +#include "FUiCtrl_GalleryBitmap.h" + + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryBitmap::_GalleryBitmap(void) + : __pBitmap(null) + , __rotation(GALLERY_INTERNAL_IMAGE_ROTATION_0) + , __bitmapSizeAndRotateAdjusted(false) +{ + // Do nothing +} + +_GalleryBitmap::~_GalleryBitmap(void) +{ + delete __pBitmap; +} + +_GalleryBitmap* +_GalleryBitmap::CloneN(_GalleryBitmap* pBitmap) +{ + Bitmap* pInternalBitmap = null; + _GalleryBitmap* pCloneBitmap = new(std::nothrow) _GalleryBitmap(); + SysTryCatch(NID_UI_CTRL, pCloneBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pInternalBitmap = _BitmapImpl::CloneN(*pBitmap->GetInternalBitmap()); + SysTryCatch(NID_UI_CTRL, pInternalBitmap != null, , GetLastResult(), "[%s] Propagating", GetErrorMessage(GetLastResult())); + + pCloneBitmap->SetInternalBitmap(pInternalBitmap); + + pCloneBitmap->SetAdjustBitmapFlag(pBitmap->IsInitialize()); + + pCloneBitmap->SetBitmapRotation(pBitmap->GetBitmapRotation()); + + SetLastResult(E_SUCCESS); + + return pCloneBitmap; + +CATCH: + delete pCloneBitmap; + + return null; +} + +_GalleryBitmap* +_GalleryBitmap::CreateGalleryBitmapN(Bitmap* pBitmap) +{ + Bitmap* pInternalBitmap = null; + _GalleryBitmap* pCloneBitmap = new(std::nothrow) _GalleryBitmap(); + SysTryCatch(NID_UI_CTRL, pCloneBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pInternalBitmap = _BitmapImpl::CloneN(*pBitmap); + SysTryCatch(NID_UI_CTRL, pInternalBitmap != null, , GetLastResult(), "[%s] Propagating", GetErrorMessage(GetLastResult())); + + pCloneBitmap->SetInternalBitmap(pInternalBitmap); + + SetLastResult(E_SUCCESS); + + return pCloneBitmap; + +CATCH: + delete pCloneBitmap; + + return null; +} + +result +_GalleryBitmap::SetSize(const Dimension& size) +{ + if (size.width == GetSize().width && size.height == GetSize().height) + { + return E_SUCCESS; + } + + Dimension scaledSize = size; + float width = GetSize().width; + float height = GetSize().height; + + float widthFactor = (float)size.width / width; + float heightFactor = (float)size.height / height; + + if (widthFactor > heightFactor) + { + scaledSize.width = width * heightFactor + 0.5f; + } + else + { + scaledSize.height = height * widthFactor + 0.5f; + } + + result r = __pBitmap->Scale(scaledSize); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return E_SUCCESS; +} + +Dimension +_GalleryBitmap::GetSize(void) const +{ + Dimension dim; + dim.width = __pBitmap->GetWidth(); + dim.height = __pBitmap->GetHeight(); + + return dim; +} + +result +_GalleryBitmap::Initialize(const Dimension& size, _GalleryFittingType fittingType) +{ + if (IsInitialize() == false) + { + result r = AdjustBitmapRotate(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = AdjustBitmapSize(size, fittingType); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetAdjustBitmapFlag(true); + } + + return E_SUCCESS; +} + +result +_GalleryBitmap::AdjustBitmapSize(const Dimension& size, _GalleryFittingType fittingType) +{ + Dimension scaledSize = size; + if (fittingType == GALLERY_FITTING_TYPE_NONE) + { + return E_SUCCESS; + } + + if (fittingType != GALLERY_FITTING_TYPE_FIT_XY) + { + float width = GetSize().width; + float height = GetSize().height; + + float widthFactor = (float)size.width / width; + float heightFactor = (float)size.height / height; + + if (fittingType == GALLERY_FITTING_TYPE_STRECTABLE) + { + if (widthFactor < 1.0f && heightFactor < 1.0f) + { + return E_SUCCESS; + } + } + else if (fittingType == GALLERY_FITTING_TYPE_SHRINKABLE) + { + if (widthFactor > 1.0f && heightFactor > 1.0f) + { + return E_SUCCESS; + } + } + + if (widthFactor > heightFactor) + { + scaledSize.width = width * heightFactor + 0.5f; + } + else + { + scaledSize.height = height * widthFactor + 0.5f; + } + } + + result r = __pBitmap->Scale(scaledSize); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return E_SUCCESS; +} + +result +_GalleryBitmap::AdjustBitmapRotate(void) +{ + Bitmap* pImage = null; + _Util::LockManager* pSrcLock = null; + _Util::LockManager* pDstLock = null; + Bitmap* pBitmap = null; + result r = E_SUCCESS; + + Dimension dim; + int degree = 0; + switch (__rotation) + { + case GALLERY_INTERNAL_IMAGE_ROTATION_0: + dim.SetSize(__pBitmap->GetWidth(), __pBitmap->GetHeight()); + break; + case GALLERY_INTERNAL_IMAGE_ROTATION_90: + degree = 90; + dim.SetSize(__pBitmap->GetHeight(), __pBitmap->GetWidth()); + break; + case GALLERY_INTERNAL_IMAGE_ROTATION_180: + degree = 180; + dim.SetSize(__pBitmap->GetWidth(), __pBitmap->GetHeight()); + break; + case GALLERY_INTERNAL_IMAGE_ROTATION_270: + degree = 270; + dim.SetSize(__pBitmap->GetHeight(), __pBitmap->GetWidth()); + break; + default: + SysAssert(false); + break; + } + + if (__rotation != GALLERY_INTERNAL_IMAGE_ROTATION_0) + { + pImage = new(std::nothrow) Bitmap(); + SysTryReturn(NID_UI_CTRL, pImage != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pImage->Construct(dim, __pBitmap->GetPixelColorFormat()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r)); + + pSrcLock = new (std::nothrow) _Util::LockManager(*_BitmapImpl::GetInstance(*__pBitmap)); + SysTryCatch(NID_UI_CTRL, pSrcLock != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pDstLock = new (std::nothrow) _Util::LockManager(*_BitmapImpl::GetInstance(*pImage)); + SysTryCatch(NID_UI_CTRL, pDstLock != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + { + const BufferInfo& srcBufferInfo = pSrcLock->GetBufferInfo(); + const BufferInfo& dstBufferInfo = pDstLock->GetBufferInfo(); + + _Util::Pixmap srcImage(srcBufferInfo.width, srcBufferInfo.height, srcBufferInfo.bitsPerPixel, srcBufferInfo.pPixels, srcBufferInfo.pitch); + _Util::Pixmap dstImage(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, dstBufferInfo.pPixels, dstBufferInfo.pitch); + + _Effect::RotateDesc rotateDesc = { degree, __pBitmap->GetWidth() >> 1 , __pBitmap->GetHeight() >> 1}; //??? + bool pass = _Effect::RotateImage(dstImage, dim.width >> 1, dim.height >> 1, srcImage, rotateDesc, 255); + //bool pass = _Effect::RotateImage(dstImage, dstBufferInfo.width >> 1, dstBufferInfo.height >> 1, srcImage, rotateDesc, 255); + if (pass == true) + { + pBitmap = new (std::nothrow) Bitmap(); + SysTryCatch(NID_UI_CTRL, pBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Rectangle rect(0, 0, dim.width, dim.height); + r = pBitmap->Construct(*pImage, rect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r)); + + delete __pBitmap; + __pBitmap = pBitmap; + } + else + { + r = GetLastResult(); + } + delete pSrcLock; + delete pDstLock; + } + delete pImage; + } + + return r; + +CATCH: + delete pBitmap; + delete pDstLock; + delete pSrcLock; + delete pImage; + + return r; +} + +bool +_GalleryBitmap::IsInitialize(void) const +{ + return __bitmapSizeAndRotateAdjusted; +} + +void +_GalleryBitmap::SetBitmapRotation(_GalleryImageRotation rotation) +{ + __rotation = rotation; +} + +_GalleryImageRotation +_GalleryBitmap::GetBitmapRotation(void) const +{ + return __rotation; +} + +Bitmap* +_GalleryBitmap::GetInternalBitmap(void) const +{ + return __pBitmap; +} + +void +_GalleryBitmap::SetAdjustBitmapFlag(bool initialize) +{ + __bitmapSizeAndRotateAdjusted = initialize; +} + +void +_GalleryBitmap::SetInternalBitmap(Bitmap* pBitmap) +{ + __pBitmap = pBitmap; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryCanvas.cpp b/src/ui/controls/FUiCtrl_GalleryCanvas.cpp new file mode 100644 index 0000000..3fc7f6b --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryCanvas.cpp @@ -0,0 +1,707 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include +#include +#include +#include +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_GalleryCanvas.h" +#include "FUiCtrl_GalleryBitmap.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_GalleryAnimationProvider::_GalleryAnimationProvider(void) + : __pAnimationDelegator(null) +{ + __animationTiming.duration_ms = 0; + __animationTiming.timingFunction = GALLERY_ANIMATION_TIMING_FUNC_LINEAR; +} + +_GalleryAnimationProvider::~_GalleryAnimationProvider(void) +{ + // Do nothing +} + +VisualElementAnimation* +_GalleryAnimationProvider::CreateAnimationForProperty(VisualElement& source, const String& property) +{ + const IVisualElementAnimationTimingFunction* pTimingFunction = GetTimingFunc(__animationTiming.timingFunction); + + VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(source, property);//dynamic_cast(visualElement.CreateAnimationForPropertyN(visualElement, VEPropTransform)); + if (pAnimation != null) + { + result r = pAnimation->SetDuration(__animationTiming.duration_ms); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pAnimation->SetTimingFunction(pTimingFunction); + pAnimation->SetVisualElementAnimationStatusEventListener(__pAnimationDelegator); + } + + SetLastResult(E_SUCCESS); + + return pAnimation; + +CATCH: + delete pAnimation; + + return null; +} + +void +_GalleryAnimationProvider::SetAnimationDelegator(IVisualElementAnimationStatusEventListener* pAnimationDelegator) +{ + __pAnimationDelegator = pAnimationDelegator; + return; +} + +void +_GalleryAnimationProvider::SetGalleryAnimationTiming(_GalleryAnimationTiming animationTiming) +{ + __animationTiming = animationTiming; + return; +} + +const IVisualElementAnimationTimingFunction* +_GalleryAnimationProvider::GetTimingFunc(_GalleryAnimationTimingFunction timingFunction) const +{ + const IVisualElementAnimationTimingFunction* pTimingFunc = null; + switch (timingFunction) + { + case GALLERY_ANIMATION_TIMING_FUNC_LINEAR: + pTimingFunc = VisualElementAnimation::GetTimingFunctionByName("Linear"); + break; + case GALLERY_ANIMATION_TIMING_FUNC_EASEIN: + pTimingFunc = VisualElementAnimation::GetTimingFunctionByName("EaseIn"); + break; + case GALLERY_ANIMATION_TIMING_FUNC_EASEOUT: + pTimingFunc = VisualElementAnimation::GetTimingFunctionByName("EaseOut"); + break; + case GALLERY_ANIMATION_TIMING_FUNC_EASEINOUT: + pTimingFunc = VisualElementAnimation::GetTimingFunctionByName("EaseInOut"); + break; + default: + break; + } + + return pTimingFunc; +} + + +// _GalleryCanvas +_GalleryCanvas* +_GalleryCanvas::CreateGalleryCanvasN(Rectangle& canvasBounds) +{ + result r = E_SUCCESS; + + _GalleryCanvas* pCanvas = new (std::nothrow) _GalleryCanvas(); + SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryCanvas."); + + r = pCanvas->Construct(canvasBounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pCanvas; + +CATCH: + delete pCanvas; + + return null; +} + +result +_GalleryCanvas::SetImage(const _GalleryBitmap* pImage, const Rectangle& viewBounds, _GalleryFittingType fittingType) +{ + if (pImage == null) + { + return E_SUCCESS; + } + + Rectangle canvasBounds = GetBounds(); + canvasBounds.width = viewBounds.width; + canvasBounds.height = viewBounds.height; + result r = SetBounds(canvasBounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _GalleryBitmap* pCanvasImage = _GalleryBitmap::CloneN(const_cast<_GalleryBitmap*>(pImage)); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvasImage != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pImage; + __pImage = pCanvasImage; + + if (__pImage->IsInitialize() == false || __visualElementBoundsChanged == true) + { + result r = __pImage->Initialize(__pRootCanvas->GetControlSize(), fittingType); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Dimension imageSize = __pImage->GetSize(); + Point position(0,0); + if (__imageVerticalAlignment == GALLERY_VERTICAL_ALIGN_MIDDLE) + { + position.y = (__bounds.height - imageSize.height) >> 1; + } + else if (__imageVerticalAlignment == GALLERY_VERTICAL_ALIGN_BOTTOM) + { + position.y = (__bounds.height - imageSize.height); + } + if (__imageHorizontalAlignment == GALLERY_HORIZONTAL_ALIGN_CENTER) + { + position.x = (__bounds.width - imageSize.width) >> 1; + } + else if (__imageHorizontalAlignment == GALLERY_HORIZONTAL_ALIGN_RIGHT) + { + position.x = (__bounds.width - imageSize.width); + } + + Rectangle visualElementBounds(position.x, position.y, imageSize.width, imageSize.height); + r = SetVisualElementBounds(visualElementBounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __originalImageBounds = visualElementBounds; + SetImageBounds(GetBounds()); + + __visualElementBoundsChanged = false; + } + + SetNeedUpdateImage(true); + + return E_SUCCESS; +} + +_GalleryBitmap* +_GalleryCanvas::GetImage(void) const +{ + return __pImage; +} + +result +_GalleryCanvas::SetBounds(const Rectangle& bounds) +{ + SysTryReturnResult(NID_UI_CTRL, bounds.width >= 0 && bounds.height >= 0, E_INVALID_ARG, + "The bounds width or height is negative value."); + __bounds = bounds; + if (GetFrameVisualElement().IsClipChildrenEnabled() == true) + { + FloatRectangle floatBounds(bounds.x, bounds.y, bounds.width, bounds.height); + GetFrameVisualElement().SetBounds(floatBounds); + } + return E_SUCCESS; +} + +const Rectangle& +_GalleryCanvas::GetBounds(void) const +{ + return __bounds; +} + +result +_GalleryCanvas::SetVisibility(bool visibility) +{ + GetImageVisualElement().SetImplicitAnimationEnabled(false); + GetImageVisualElement().SetShowState(visibility); + GetFrameVisualElement().SetImplicitAnimationEnabled(false); + GetFrameVisualElement().SetShowState(visibility); + + return E_SUCCESS; +} + +bool +_GalleryCanvas::IsVisibility(void) const +{ + return GetImageVisualElement().GetShowState(); +} + +result +_GalleryCanvas::RefreshCanvas(void) +{ + return GetImageVisualElement().InvalidateRectangle(null); +} + +result +_GalleryCanvas::LoadImage(void) +{ + Canvas* pCanvas = null; + result r = E_SUCCESS; + + if (IsNeedUpdateImage() == true) + { + _GalleryBitmap* pImage = GetImage(); + if (pImage != null) + { + pCanvas = GetImageVisualElement().GetCanvasN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pCanvas != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->DrawBitmap(Point(0, 0), *pImage->GetInternalBitmap()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetImageVisualElement().SetFlushNeeded(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pCanvas; + } + SetNeedUpdateImage(false); + } + + return E_SUCCESS; + +CATCH: + delete pCanvas; + return r; +} + +_GalleryCanvas::_GalleryCanvas(void) + : __pImageVisualElement(null) + , __pFrameVisualElement(null) + , __pAnimation(null) + , __bounds(0, 0, 0, 0) + , __pImage(null) + , __visableRegionOfImage(0, 0, 0, 0) + , __needUpdateImage(false) + , __visualElementBoundsChanged(false) + , __imageBounds(0, 0, 0, 0) + , __originalImageBounds(0, 0, 0, 0) + , __pRootCanvas(null) + , __factor(1.0) + , __imageAnchor(0, 0) + , __imageVerticalAlignment(GALLERY_VERTICAL_ALIGN_MIDDLE) + , __imageHorizontalAlignment(GALLERY_HORIZONTAL_ALIGN_CENTER) +{ + // Do nothing +} + +_GalleryCanvas::~_GalleryCanvas(void) +{ + GetImageVisualElement().RemoveAllAnimations(); + + delete __pImage; + __pImage = null; + + if (__pImageVisualElement != null) + { + __pImageVisualElement->Destroy(); + } + + if (__pFrameVisualElement != null) + { + __pFrameVisualElement->Destroy(); + } +} + +result +_GalleryCanvas::Construct(Rectangle& canvasBounds) +{ + result r = E_SUCCESS; + _VisualElement* pImageVisualElement = null; + _VisualElement* pFrameVisualElement = null; + FloatRectangle floatBounds(canvasBounds.x, canvasBounds.y, canvasBounds.width, canvasBounds.height); + + pImageVisualElement = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_CTRL, pImageVisualElement != null, , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _VisualElement."); + + r = pImageVisualElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pImageVisualElement->SetImplicitAnimationEnabled(false); + pImageVisualElement->SetBounds(floatBounds); + + pImageVisualElement->SetShowState(true); + + r = pImageVisualElement->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetImageVisualElement(*pImageVisualElement); + + pFrameVisualElement = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_CTRL, pFrameVisualElement != null, , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _VisualElement."); + r = pFrameVisualElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pFrameVisualElement->SetImplicitAnimationEnabled(false); + pFrameVisualElement->SetBounds(floatBounds); + + pFrameVisualElement->SetShowState(true); + + SetFrameVisualElement(*pFrameVisualElement); + + r = GetFrameVisualElement().AttachChild(GetImageVisualElement()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + GetFrameVisualElement().SetClipChildrenEnabled(true); + + return E_SUCCESS; + +CATCH: + if (pImageVisualElement != null) + { + pImageVisualElement->Destroy(); + } + + if (pFrameVisualElement != null) + { + pFrameVisualElement->Destroy(); + } + __pImageVisualElement = null; + __pFrameVisualElement = null; + + return r; +} + +void +_GalleryCanvas::SetImageVisualElement(_VisualElement& visualElement) +{ + __pImageVisualElement = &visualElement; + return; +} + +_VisualElement& +_GalleryCanvas::GetImageVisualElement(void) const +{ + return *__pImageVisualElement; +} + +void +_GalleryCanvas::SetFrameVisualElement(_VisualElement& visualElement) +{ + __pFrameVisualElement = &visualElement; + return; +} + +_VisualElement& +_GalleryCanvas::GetFrameVisualElement(void) const +{ + return *__pFrameVisualElement; +} + +void +_GalleryCanvas::SetAnimation(VisualElementPropertyAnimation& animation) +{ + __pAnimation = &animation; + return; +} + +VisualElementPropertyAnimation& +_GalleryCanvas::GetAnimation(void) const +{ + return *__pAnimation; +} + +void +_GalleryCanvas::SetNeedUpdateImage(bool needUpdate) +{ + __needUpdateImage = needUpdate; + return; +} + +bool +_GalleryCanvas::IsNeedUpdateImage(void) const +{ + return __needUpdateImage; +} + +void +_GalleryCanvas::SetCanvasFactor(float factor) +{ + __factor = factor; + return; +} + +float +_GalleryCanvas::GetCanvasFactor(void) const +{ + return __factor; +} + +result +_GalleryCanvas::SetVisualElementBounds(const Rectangle& bounds) +{ + __visualElementBoundsChanged = true; + FloatRectangle floatBounds(bounds.x, bounds.y, bounds.width, bounds.height); + return GetImageVisualElement().SetBounds(floatBounds); +} + +Rectangle +_GalleryCanvas::GetImageVisualElementBounds(void) const +{ + FloatRectangle floatRect = GetImageVisualElement().GetBounds(); + Rectangle bounds(floatRect.x, floatRect.y, floatRect.width, floatRect.height); + + return bounds; +} + +void +_GalleryCanvas::SetImageBounds(const Rectangle& canvasBounds) +{ + float factor = GetCanvasFactor(); + if (__visualElementBoundsChanged == true) + { + factor = 1.0f; + } + __imageBounds.width = __originalImageBounds.width * factor; + __imageBounds.height = __originalImageBounds.height * factor; + + if (__imageVerticalAlignment == GALLERY_VERTICAL_ALIGN_MIDDLE) + { + __imageBounds.y = (canvasBounds.height - __imageBounds.height) >> 1; + } + else if (__imageVerticalAlignment == GALLERY_VERTICAL_ALIGN_BOTTOM) + { + __imageBounds.y = (canvasBounds.height - __imageBounds.height); + } + if (__imageHorizontalAlignment == GALLERY_HORIZONTAL_ALIGN_CENTER) + { + __imageBounds.x = (canvasBounds.width - __imageBounds.width) >> 1; + } + else if (__imageHorizontalAlignment == GALLERY_HORIZONTAL_ALIGN_RIGHT) + { + __imageBounds.x = (canvasBounds.width - __imageBounds.width); + } + + return; +} + +Rectangle +_GalleryCanvas::GetOriginalImageBounds(void) const +{ + return __originalImageBounds; +} + +Rectangle +_GalleryCanvas::GetImageBounds(void) const +{ + return __imageBounds; +} + +result +_GalleryCanvas::SetAnimationDelegator(_GalleryAnimationProvider* pVEDelegator) +{ + result r = GetImageVisualElement().SetAnimationProvider(pVEDelegator); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetFrameVisualElement().SetAnimationProvider(pVEDelegator); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +_GalleryCanvas::SetRootCanvas(_GalleryRootCanvas& rootCanvas) +{ + __pRootCanvas = &rootCanvas; + return; +} + +void +_GalleryCanvas::SetImageAnchor(Tizen::Graphics::FloatPoint anchor) +{ + __imageAnchor = anchor; + return; +} + +FloatPoint +_GalleryCanvas::GetImageAnchor(void) const +{ + return __imageAnchor; +} + +Rectangle +_GalleryCanvas::GetAlignBoundary(void) const +{ + Rectangle imageBounds = GetImageBounds(); + if (__originalImageBounds.width != imageBounds.width || __originalImageBounds.height != imageBounds.height) + { + imageBounds.x += GetBounds().x; + imageBounds.y += GetBounds().y; + return imageBounds; + } + else + { + return Rectangle(-1, -1, -1, -1); + } +} + +void +_GalleryCanvas::SetClippingOfFrameVisualElement(bool clipping) +{ + GetFrameVisualElement().SetClipChildrenEnabled(clipping); +} + +void +_GalleryCanvas::SetImageAlignment(_GalleryVerticalAlignment imageVerticalAlignment + , _GalleryHorizontalAlignment imageHorizontalAlignment) +{ + __imageVerticalAlignment = imageVerticalAlignment; + __imageHorizontalAlignment = imageHorizontalAlignment; +} + +void +_GalleryCanvas::GetImageAlignment(_GalleryVerticalAlignment& imageVerticalAlignment + , _GalleryHorizontalAlignment& imageHorizontalAlignment) const +{ + imageVerticalAlignment = __imageVerticalAlignment; + imageHorizontalAlignment = __imageHorizontalAlignment; +} + + +// _GalleryRootCanvas +_GalleryRootCanvas* +_GalleryRootCanvas::CreateGalleryRootCanvasN(_Control& control) +{ + _GalleryRootCanvas* pRootCanvas = new (std::nothrow) _GalleryRootCanvas(control); + SysTryReturn(NID_UI_CTRL, pRootCanvas != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryRootCanvas."); + + SetLastResult(E_SUCCESS); + + return pRootCanvas; +} + +result +_GalleryRootCanvas::SetBackgroundImage(const _GalleryBitmap* pImage) +{ + __pBackgroundImage = const_cast <_GalleryBitmap*>(pImage); + return E_SUCCESS; +} + +_GalleryBitmap* +_GalleryRootCanvas::GetBackgroundImage(void) const +{ + return __pBackgroundImage; +} + +Color +_GalleryRootCanvas::GetBackgroundColor(void) const +{ + return GetControl().GetBackgroundColor(); +} + +result +_GalleryRootCanvas::SetBounds(const Rectangle& bounds) +{ + return GetControl().SetBounds(bounds); +} + +Rectangle +_GalleryRootCanvas::GetBounds(void) const +{ + return GetControl().GetBounds(); +} + +Dimension +_GalleryRootCanvas::GetControlSize(void) const +{ + return GetControl().GetSize(); +} + +result +_GalleryRootCanvas::SetVisibility(bool visibility) +{ + GetControl().SetVisibleState(visibility); + + return E_SUCCESS; +} + +bool +_GalleryRootCanvas::IsVisibility(void) const +{ + return GetControl().GetVisibleState(); +} + +result +_GalleryRootCanvas::AddChildCanvas(_GalleryCanvas& canvas) +{ + _VisualElement& childVisualElement = canvas.GetFrameVisualElement(); + _VisualElement* pRootVisualElement = GetImageVisualElement(); + SysTryReturn(NID_UI_CTRL, pRootVisualElement != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Root VisualElement is null."); + + result r = pRootVisualElement->AttachChild(childVisualElement); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + canvas.SetRootCanvas(*this); + + return E_SUCCESS; +} + +result +_GalleryRootCanvas::RemoveChildCanvas(_GalleryCanvas& canvas) +{ + _VisualElement& childVisualElement = canvas.GetFrameVisualElement(); + _VisualElement* pRootVisualElement = GetImageVisualElement(); + SysTryReturn(NID_UI_CTRL, pRootVisualElement != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Root VisualElement is null."); + + result r = pRootVisualElement->DetachChild(childVisualElement); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryRootCanvas::RefreshCanvas(void) +{ + //GetControl().Draw(); + GetControl().Invalidate(); + return E_SUCCESS; +} + +_GalleryRootCanvas::_GalleryRootCanvas(_Control& control) + : __pControl(null) + , __bounds(0, 0, 0, 0) + , __pBackgroundImage(null) + , __needUpdateBackgroundImage(false) +{ + SetControl(control); +} + +_GalleryRootCanvas::~_GalleryRootCanvas(void) +{ + // Do nothing +} + +void +_GalleryRootCanvas::SetControl(_Control& control) +{ + __pControl = &control; + return; +} + +_Control& +_GalleryRootCanvas::GetControl(void) const +{ + return *__pControl; +} + +_VisualElement* +_GalleryRootCanvas::GetImageVisualElement(void) const +{ + return GetControl().GetVisualElement(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryCanvasManager.cpp b/src/ui/controls/FUiCtrl_GalleryCanvasManager.cpp new file mode 100644 index 0000000..29283ec --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryCanvasManager.cpp @@ -0,0 +1,309 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include "FUi_Control.h" +#include "FUiCtrl_GalleryCanvasManager.h" +#include "FUiCtrl_GalleryCanvas.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryCanvasManager* +_GalleryCanvasManager::CreateCanvasManagerN(_Control& control, int initialCanvasCount, + Rectangle& initialCanvasBounds, _GalleryAnimationProvider* pVEDelegator) +{ + result r = E_SUCCESS; + + _GalleryCanvasManager* pCanvasManager = new (std::nothrow) _GalleryCanvasManager(); + SysTryCatch(NID_UI_CTRL, pCanvasManager != null, , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryCanvasManager."); + + r = pCanvasManager->Construct(control, initialCanvasCount, initialCanvasBounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvasManager->SetAnimationDelegator(*pVEDelegator); + + SetLastResult(E_SUCCESS); + + return pCanvasManager; + +CATCH: + delete pCanvasManager; + + return null; +} + +result +_GalleryCanvasManager::ResetCanvasManager(int canvasCount, Rectangle& canvasBounds) +{ + SysTryReturn(NID_UI_CTRL, canvasCount >= 0, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The maxCount parameter is invalid."); + + result r = RemoveAllCanvas(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __canvasArray.SetCapacity(canvasCount); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + for (int i = 0; i < GetCanvasCount(); i++) + { + _GalleryCanvas* pCanvas = _GalleryCanvas::CreateGalleryCanvasN(canvasBounds); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pCanvas != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __canvasArray.Add(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetRootCanvas().AddChildCanvas(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->SetAnimationDelegator(__pVEDelegator); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->SetBounds(canvasBounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; + +CATCH: + __canvasArray.RemoveAll(true); + + return r; +} + +int +_GalleryCanvasManager::GetCanvasCount(void) const +{ + return __canvasArray.GetCapacity(); +} + +_GalleryRootCanvas& +_GalleryCanvasManager::GetRootCanvas(void) const +{ + if (__pRootCanvas == null) + { + //SysLog(NID_UI_CTRL, "[Assertion] The _GalleryRootCanvas is null"); + SysAssert(false); + } + + return *__pRootCanvas; +} + +_GalleryCanvas* +_GalleryCanvasManager::GetCanvas(int canvasIndex) const +{ + SysTryReturn(NID_UI_CTRL, (canvasIndex >= 0 && canvasIndex < GetCanvasCount()), null, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The canvasIndex is out of range."); + + _GalleryCanvas* pCanvas = dynamic_cast<_GalleryCanvas*>(const_cast(__canvasArray.GetAt(canvasIndex))); + SysTryReturn(NID_UI_CTRL, pCanvas != null, null, E_INVALID_STATE, + "[E_INVALID_STATE] The _GalleryCanvasArray is in an invalid state."); + + return pCanvas; +} + +result +_GalleryCanvasManager::ReleaseAllCanvasResource(void) +{ + __canvasArray.RemoveAll(true); + + return E_SUCCESS; +} + +result +_GalleryCanvasManager::ResetAllCanvas(Tizen::Graphics::Rectangle& canvasBounds) +{ + _GalleryCanvas* pCanvas = null; + result r = E_SUCCESS; + int canvasCount = __canvasArray.GetCount(); + for (int i = 0; i < canvasCount - 1; i++) // last index is empty canvas index + { + pCanvas = GetCanvas(i); + if (pCanvas != null) + { + r = GetRootCanvas().RemoveChildCanvas(*pCanvas); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + for (int i = 0; i < canvasCount - 1; i++) + { + r = __canvasArray.RemoveAt(0, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + for (int i = 0; i < canvasCount - 1; i++) // last index is empty canvas index + { + _GalleryCanvas* pCanvas = _GalleryCanvas::CreateGalleryCanvasN(canvasBounds); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pCanvas != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __canvasArray.InsertAt(*pCanvas, i); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetRootCanvas().AddChildCanvas(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->SetAnimationDelegator(__pVEDelegator); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->SetBounds(canvasBounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; + +CATCH: + __canvasArray.RemoveAll(true); + + return r; +} + +result +_GalleryCanvasManager::LoadAllCanvasImage(void) +{ + result r = E_SUCCESS; + for (int i = 0; i < GetCanvasCount(); i++) + { + _GalleryCanvas* pCanvas = dynamic_cast<_GalleryCanvas*>(__canvasArray.GetAt(i)); + SysTryReturn(NID_UI_CTRL, pCanvas != null, E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] The _GalleryCanvasArray is in an invalid state."); + + r = pCanvas->LoadImage(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; +} + +_GalleryCanvasManager::_GalleryCanvasManager(void) + : __pControl(null) + , __pRootCanvas(null) + , __pVEDelegator(null) +{ + // Do nothing +} + +_GalleryCanvasManager::~_GalleryCanvasManager(void) +{ + result r = RemoveAllCanvas(); + delete __pRootCanvas; + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + + +result +_GalleryCanvasManager::Construct(_Control& control, int initialCanvasCount, Rectangle& initialCanvasBounds) +{ + result r = E_SUCCESS; + _GalleryRootCanvas* pRootCanvas = null; + + pRootCanvas = _GalleryRootCanvas::CreateGalleryRootCanvasN(control); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pRootCanvas != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __canvasArray.Construct(initialCanvasCount); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + for (int i = 0; i < GetCanvasCount(); i++) + { + _GalleryCanvas* pCanvas = _GalleryCanvas::CreateGalleryCanvasN(initialCanvasBounds); + SysTryCatch(NID_UI_CTRL, pCanvas != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __canvasArray.Add(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pRootCanvas->AddChildCanvas(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->SetAnimationDelegator(__pVEDelegator); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->SetBounds(initialCanvasBounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + SetControl(control); + SetRootCanvas(*pRootCanvas); + + return E_SUCCESS; + +CATCH: + delete pRootCanvas; + __canvasArray.RemoveAll(true); + + return r; +} + +result +_GalleryCanvasManager::RemoveAllCanvas(void) +{ + _GalleryCanvas* pCanvas = null; + result r = E_SUCCESS; + for (int i = 0; i < __canvasArray.GetCount(); i++) + { + pCanvas = GetCanvas(i); + if (pCanvas != null) + { + r = GetRootCanvas().RemoveChildCanvas(*pCanvas); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + __canvasArray.RemoveAll(true); + + return E_SUCCESS; +} + +void +_GalleryCanvasManager::SetControl(_Control& control) +{ + __pControl = &control; +} + +_Control& +_GalleryCanvasManager::GetControl(void) const +{ + return *__pControl; +} + +void +_GalleryCanvasManager::SetRootCanvas(_GalleryRootCanvas& rootCanvas) +{ + __pRootCanvas = &rootCanvas; +} + +void +_GalleryCanvasManager::SetAnimationDelegator(_GalleryAnimationProvider& pVEDelegator) +{ + __pVEDelegator = &pVEDelegator; +} + +_GalleryAnimationProvider& +_GalleryCanvasManager::GetAnimationDelegator(void) const +{ + return *__pVEDelegator; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryCoreEvent.cpp b/src/ui/controls/FUiCtrl_GalleryCoreEvent.cpp new file mode 100644 index 0000000..0fc567c --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryCoreEvent.cpp @@ -0,0 +1,67 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include "FUiCtrl_GalleryCoreEvent.h" +#include "FUiCtrl_GalleryCoreEventArg.h" +#include "FUiCtrl_IGalleryCoreEventListener.h" +#include "FUiCtrl_GalleryItem.h" + +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryCoreEvent::_GalleryCoreEvent(void) +{ + // Do nothing +} + +_GalleryCoreEvent::~_GalleryCoreEvent(void) +{ + // Do nothing +} + +void +_GalleryCoreEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _IGalleryCoreEventListener* pGalleryEventListener = dynamic_cast<_IGalleryCoreEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pGalleryEventListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] listener is invalid listener type."); + + const _GalleryCoreEventArg& galleryArg = static_cast(arg); + + switch (galleryArg.GetEventType()) + { + case GALLERY_CORE_EVENT_CURRENT_ITEM_CHANGED: + pGalleryEventListener->OnCurrentItemChanged(galleryArg.GetArg1()); + break; + case GALLERY_CORE_EVENT_ITEM_CLICKED: + pGalleryEventListener->OnItemClicked(galleryArg.GetArg1()); + break; + case GALLERY_CORE_EVENT_SLIDE_SHOW_STARTED: + pGalleryEventListener->OnSlideShowStarted(); + break; + case GALLERY_CORE_EVENT_SLIDE_SHOW_STOPPED: + pGalleryEventListener->OnSlideShowStopped(); + break; + default: + SysTryReturnVoidResult(NID_UI_CTRL, false, E_INVALID_ARG, "[E_INVALID_ARG] The event type is invalid type."); + break; + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryCoreEventArg.cpp b/src/ui/controls/FUiCtrl_GalleryCoreEventArg.cpp new file mode 100644 index 0000000..455d5b5 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryCoreEventArg.cpp @@ -0,0 +1,60 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include "FUiCtrl_GalleryCoreEventArg.h" +#include "FUiCtrl_GalleryItem.h" + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryCoreEventArg::_GalleryCoreEventArg(_GalleryCoreEventType eventType, int arg1, _GalleryItem** arg2, bool arg3) + : __arg1(arg1) + , __ppArg2(arg2) + , __arg3(arg3) + , __eventType(eventType) +{ + // Do nothing +} + +_GalleryCoreEventArg::~_GalleryCoreEventArg(void) +{ + // Do nothing +} + +int& +_GalleryCoreEventArg::GetArg1(void) const +{ + return const_cast(__arg1); +} + +_GalleryItem** +_GalleryCoreEventArg::GetArg2(void) const +{ + return __ppArg2; +} + +bool& +_GalleryCoreEventArg::GetArg3(void) const +{ + return const_cast(__arg3); +} + +_GalleryCoreEventType +_GalleryCoreEventArg::GetEventType(void) const +{ + return __eventType; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryCoreEventListener.cpp b/src/ui/controls/FUiCtrl_GalleryCoreEventListener.cpp new file mode 100644 index 0000000..3ff2d0f --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryCoreEventListener.cpp @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include +#include "FUiCtrl_GalleryCoreEventListener.h" +#include "FUiCtrl_GalleryImplEvent.h" +#include "FUiCtrl_GalleryImplEventArg.h" +#include "FUiCtrl_GalleryItemImpl.h" +#include "FUiCtrl_GalleryItem.h" + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryCoreEventListener::_GalleryCoreEventListener(_GalleryImplEvent& implEvent) + : __pItemProvider(null) + , __implEvent(implEvent) +{ + // Do nothing +} + +_GalleryCoreEventListener::~_GalleryCoreEventListener(void) +{ + // Do nothing +} + +void +_GalleryCoreEventListener::OnCurrentItemChanged(int currentIndex) +{ + _GalleryImplEventArg* pEventArg = new (std::nothrow) _GalleryImplEventArg(GALLERY_EVENT_CURRENT_ITEM_CHANGED, currentIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __implEvent.Fire(*pEventArg); +} + +void +_GalleryCoreEventListener::OnItemClicked(int itemIndex) +{ + _GalleryImplEventArg* pEventArg = new (std::nothrow) _GalleryImplEventArg(GALLERY_EVENT_ITEM_CLICKED, itemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __implEvent.Fire(*pEventArg); +} + +void +_GalleryCoreEventListener::OnSlideShowStarted(void) +{ + _GalleryImplEventArg* pEventArg = new (std::nothrow) _GalleryImplEventArg(GALLERY_EVENT_SLIDE_SHOW_STARTED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __implEvent.Fire(*pEventArg); +} + +void +_GalleryCoreEventListener::OnSlideShowStopped(void) +{ + _GalleryImplEventArg* pEventArg = new (std::nothrow) _GalleryImplEventArg(GALLERY_EVENT_SLIDE_SHOW_STOPPED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __implEvent.Fire(*pEventArg); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryImageReader.cpp b/src/ui/controls/FUiCtrl_GalleryImageReader.cpp new file mode 100644 index 0000000..72c0b6e --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryImageReader.cpp @@ -0,0 +1,171 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include +#include +#include +#include +#include "FUiCtrl_GalleryImageReader.h" +#include "FUiCtrl_GalleryBitmap.h" +#include "FUiCtrl_GalleryModel.h" +#include "FUiCtrl_GalleryItem.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Media; + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryImageReader::_GalleryImageReader(_GalleryModel& galleryModel) + : __galleryModel(galleryModel) + , __pTmpFileBitmap(null) + , __currentLoadBitmapIndex(-1) + , __currentLoadBitmapSize(0, 0) +{ + // Do nothing +} + +_GalleryImageReader::~_GalleryImageReader(void) +{ + delete __pTmpFileBitmap; +} + +_GalleryBitmap* +_GalleryImageReader::GetPartialImageFromFileN(int index, const Rectangle& partialBounds, const Dimension& imageSize) const +{ + SysTryReturn(NID_UI_CTRL, index >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The index argument is negative value."); + SysTryReturn(NID_UI_CTRL, index < __galleryModel.GetItemCount(), null, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The index argument is out of range"); + + if (__currentLoadBitmapIndex != index || __currentLoadBitmapSize != imageSize) + { + const_cast<_GalleryImageReader*>(this)->LoadPartialImageFromFile(index, imageSize); + } + + _GalleryBitmap* pPartialGalleryBitmap = null; + Bitmap* pPartialBitmap = new(std::nothrow) Bitmap(); + SysTryReturn(NID_UI_CTRL, pPartialBitmap != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pPartialBitmap->Construct(*__pTmpFileBitmap, partialBounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pPartialGalleryBitmap = _GalleryBitmap::CreateGalleryBitmapN(pPartialBitmap); + SysTryCatch(NID_UI_CTRL, pPartialGalleryBitmap != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + SetLastResult(E_SUCCESS); + delete pPartialBitmap; + + return pPartialGalleryBitmap; + +CATCH: + //delete pPartialGalleryBitmap; + delete pPartialBitmap; + + return null; +} + +_GalleryBitmap* +_GalleryImageReader::GetItemImage(int index) const +{ + SysTryReturn(NID_UI_CTRL, index >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The index argument is negative value."); + SysTryReturn(NID_UI_CTRL, index < __galleryModel.GetItemCount(), null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index argument is out of range."); + + _GalleryItem* pItem = __galleryModel.GetItem(index); + SysTryReturn(NID_UI_CTRL, pItem != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return pItem->GetGalleryItemImage(); +} + +void +_GalleryImageReader::LoadPartialImageFromFile(int index, const Dimension& imageSize) +{ + _GalleryBitmap* pPartialGalleryBitmap = null; + Dimension bitmapSize; + ByteBuffer* pBuffer = null; + MediaPixelFormat mediaPixelFormat = MEDIA_PIXEL_FORMAT_NONE; + result r = E_SUCCESS; + + _GalleryItem* pItem = __galleryModel.GetItem(index); + SysTryCatch(NID_UI_CTRL, pItem != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (pItem->GetGalleryItemImage() == null) + { + SysTryCatch(NID_UI_CTRL, false, , E_SYSTEM, "[E_SYSTEM] The gallery bitmap not exist."); + } + + switch (pItem->GetGalleryItemImage()->GetInternalBitmap()->GetPixelColorFormat()) + { + case BITMAP_PIXEL_FORMAT_RGB565: + mediaPixelFormat = MEDIA_PIXEL_FORMAT_RGB565LE; + break; + case BITMAP_PIXEL_FORMAT_ARGB8888: + mediaPixelFormat = MEDIA_PIXEL_FORMAT_BGRA8888; + break; + case BITMAP_PIXEL_FORMAT_R8G8B8A8: + mediaPixelFormat = MEDIA_PIXEL_FORMAT_RGBA8888; + break; + default: + SysAssert(false); + break; + } + + pBuffer = _ImageDecoder::DecodeToBufferN(pItem->GetGalleryItemFilePath(), mediaPixelFormat, bitmapSize.width, bitmapSize.height); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pTmpFileBitmap; + __pTmpFileBitmap = new (std::nothrow) Bitmap(); + SysTryCatch(NID_UI_CTRL, __pTmpFileBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pTmpFileBitmap->Construct(*pBuffer, bitmapSize, pItem->GetGalleryItemImage()->GetInternalBitmap()->GetPixelColorFormat()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pPartialGalleryBitmap = _GalleryBitmap::CreateGalleryBitmapN(__pTmpFileBitmap); + SysTryCatch(NID_UI_CTRL, pPartialGalleryBitmap != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pPartialGalleryBitmap->SetBitmapRotation(pItem->GetGalleryRotation()); + + r = pPartialGalleryBitmap->Initialize(imageSize, GALLERY_FITTING_TYPE_FIT); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pPartialGalleryBitmap->SetSize(imageSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pTmpFileBitmap; + __pTmpFileBitmap = _BitmapImpl::CloneN(*pPartialGalleryBitmap->GetInternalBitmap()); + SysTryCatch(NID_UI_CTRL, __pTmpFileBitmap != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + __currentLoadBitmapIndex = index; + __currentLoadBitmapSize = imageSize; + + delete pBuffer; + delete pPartialGalleryBitmap; + return; + +CATCH: + delete pBuffer; + delete __pTmpFileBitmap; + __pTmpFileBitmap = null; + delete pPartialGalleryBitmap; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryImpl.cpp b/src/ui/controls/FUiCtrl_GalleryImpl.cpp new file mode 100644 index 0000000..483052e --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryImpl.cpp @@ -0,0 +1,554 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include +#include "FUi_UiBuilder.h" +#include "FUiCtrl_Gallery.h" +#include "FUiCtrl_GalleryImpl.h" +#include "FUiCtrl_GalleryBitmap.h" +#include "FUiCtrl_GalleryItemProviderAdaptorImpl.h" +#include "FUiCtrl_GalleryCoreEventListener.h" +#include "FUiCtrl_GalleryImplEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Effects; + +namespace Tizen { namespace Ui { namespace Controls { + +namespace +{ + +_GallerySlideShowType +ConvertEnum(GalleryAnimation var) +{ + switch (var) + { + case GALLERY_ANIMATION_PAGE: + return GALLERY_SLIDESHOW_PAGE; + + case GALLERY_ANIMATION_DISSOLVE: + return GALLERY_SLIDESHOW_DISSOLVE; + + case GALLERY_ANIMATION_ZOOM: + return GALLERY_SLIDESHOW_ZOOM; + + default: + return (_GallerySlideShowType)-1; + } +} + +GalleryAnimation +ConvertEnum(_GallerySlideShowType var) +{ + switch (var) + { + case GALLERY_SLIDESHOW_PAGE: + return GALLERY_ANIMATION_PAGE; + + case GALLERY_SLIDESHOW_DISSOLVE: + return GALLERY_ANIMATION_DISSOLVE; + + case GALLERY_SLIDESHOW_ZOOM: + return GALLERY_ANIMATION_ZOOM; + + default: + return (GalleryAnimation)-1; + } +} + +} // unnamed namespace + +_GalleryImpl::_GalleryImpl(Gallery* pGallery, _Gallery* pCore, _GalleryImplEvent* pImplEvent, + _GalleryCoreEventListener* pCoreEventListener, _GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor) + : _ControlImpl(pGallery, pCore) + , __pImplEvent(pImplEvent) + , __pCoreEventListener(pCoreEventListener) + , __pGalleryItemProviderAdaptor(pGalleryItemProviderAdaptor) +{ +} + +_GalleryImpl::~_GalleryImpl(void) +{ + RequestToUnloadAllItems(); + + delete __pImplEvent; + delete __pCoreEventListener; + delete __pGalleryItemProviderAdaptor; +} + +_GalleryImpl* +_GalleryImpl::CreateGalleryImplN(Gallery* pGallery) +{ + SysTryReturn(NID_UI_CTRL, pGallery != null, null, E_INVALID_ARG, "[E_INVALID_ARG] pGallery is null."); + + _GalleryCoreEventListener* pCoreEventListener = null; + _GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor = null; + _Gallery* pCore = null; + _GalleryImpl* pImpl = null; + result r = E_SUCCESS; + + _GalleryImplEvent* pImplEvent = new (std::nothrow) _GalleryImplEvent(); + SysTryCatch(NID_UI_CTRL, pImplEvent != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pCoreEventListener = new (std::nothrow) _GalleryCoreEventListener(*pImplEvent); + SysTryCatch(NID_UI_CTRL, pCoreEventListener != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pGalleryItemProviderAdaptor = new (std::nothrow) _GalleryItemProviderAdaptorImpl(); + SysTryCatch(NID_UI_CTRL, pGalleryItemProviderAdaptor != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pCore = _Gallery::CreateGalleryN(pGalleryItemProviderAdaptor); + SysTryCatch(NID_UI_CTRL, pCore != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pCore->SetCoreEventListener(*pCoreEventListener); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl = new (std::nothrow) _GalleryImpl(pGallery, pCore, pImplEvent, pCoreEventListener, pGalleryItemProviderAdaptor); + SysTryCatch(NID_UI_CTRL, pImpl != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + //pCore = null; + + SetLastResult(E_SUCCESS); + return pImpl; + +CATCH: + delete pCoreEventListener; + delete pImplEvent; + delete pCore; + //delete pImpl; + + return null; +} + +const char* +_GalleryImpl::GetPublicClassName(void) const +{ + return "Control::Gallery"; +} + +const Gallery& +_GalleryImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +Gallery& +_GalleryImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _Gallery& +_GalleryImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_Gallery& +_GalleryImpl::GetCore(void) +{ + return static_cast<_Gallery&>(_ControlImpl::GetCore()); +} + +void +_GalleryImpl::AddGalleryEventListener(IGalleryEventListener& listener) +{ + result r = __pImplEvent->AddListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} + +void +_GalleryImpl::RemoveGalleryEventListener(IGalleryEventListener& listener) +{ + result r = __pImplEvent->RemoveListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} + +result +_GalleryImpl::SetItemProvider(IGalleryItemProvider& provider) +{ + __pGalleryItemProviderAdaptor->SetGalleryItemProvider(provider); + + return GetCore().RequestToUpdateAllItems(); +} + +result +_GalleryImpl::SetCurrentItemIndex(int index) +{ + SysTryReturn(NID_UI_CTRL, __pGalleryItemProviderAdaptor->HasGalleryItemProvider() == true, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Item provider is null"); + + return GetCore().SetCurrentItemIndex(index); +} + +int +_GalleryImpl::GetCurrentItemIndex(void) const +{ + return GetCore().GetCurrentItemIndex(); +} + +result +_GalleryImpl::SetZoomingEnabled(bool enable) +{ + return GetCore().SetZoomingEnabled(enable); +} + +bool +_GalleryImpl::IsZoomingEnabled(void) const +{ + return GetCore().IsZoomingEnabled(); +} + +result +_GalleryImpl::SetTextOfEmptyGallery(const String& text) +{ + return GetCore().SetTextOfEmptyGallery(text); +} + +String +_GalleryImpl::GetTextOfEmptyGallery(void) const +{ + return GetCore().GetTextOfEmptyGallery(); +} + +result +_GalleryImpl::SetBitmapOfEmptyGallery(const Bitmap* pBitmap) +{ + _GalleryBitmap* pGalleryBitmap = _GalleryBitmap::CreateGalleryBitmapN(const_cast(pBitmap)); + SysTryReturn(NID_UI_CTRL, pGalleryBitmap != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return GetCore().SetBitmapOfEmptyGallery(pGalleryBitmap); +} + +result +_GalleryImpl::SetSlideShowAnimation(GalleryAnimation animation) +{ + _GallerySlideShowType slideShowType = ConvertEnum(animation); + + SysTryReturn(NID_UI_CTRL, slideShowType != -1, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The animation argument(%d) is invalid argument.", animation); + + return GetCore().SetSlideShowType(slideShowType); +} + +GalleryAnimation +_GalleryImpl::GetSlideShowAnimation(void) const +{ + return ConvertEnum(GetCore().GetSlideShowType()); +} + +result +_GalleryImpl::SetSlideShowAnimationDuration(int duration) +{ + return GetCore().SetSlideShowAnimationDuration(duration); +} + +int +_GalleryImpl::GetSlideShowAnimationDuration(void) const +{ + return GetCore().GetSlideShowAnimationDuration(); +} + +result +_GalleryImpl::SetSlideShowViewDuration(int duration) +{ + return GetCore().SetSlideShowViewDuration(duration); +} + +int +_GalleryImpl::GetSlideShowViewDuration(void) const +{ + return GetCore().GetSlideShowViewDuration(); +} + +result +_GalleryImpl::StartSlideShow(bool repeat) +{ + return GetCore().StartSlideShow(repeat); +} + +result +_GalleryImpl::StopSlideShow(void) const +{ + _Gallery* pCore = const_cast<_Gallery*>(&GetCore()); // ??? + + return pCore->StopSlideShow(); +} + +bool +_GalleryImpl::IsSlideShowStarted(void) const +{ + return GetCore().IsSlideShowStarted(); +} + +int +_GalleryImpl::GetItemCount(void) const +{ + return GetCore().GetItemCount(); +} + +result +_GalleryImpl::RefreshGallery(int itemIndex, GalleryRefreshType type) +{ + SysTryReturn(NID_UI_CTRL, __pGalleryItemProviderAdaptor->HasGalleryItemProvider() == true, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] Item provider is null"); + + switch (type) + { + case GALLERY_REFRESH_TYPE_ITEM_ADD: + return GetCore().RequestToLoadItem(itemIndex); + case GALLERY_REFRESH_TYPE_ITEM_REMOVE: + return GetCore().RequestToUnloadItem(itemIndex); + case GALLERY_REFRESH_TYPE_ITEM_MODIFY: + return GetCore().RequestToUpdateItem(itemIndex); + default: + SysTryReturn(NID_UI_CTRL, false, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The refresh type(%d) is invalid type.", type); + break; + } + + return E_SUCCESS; +} + +result +_GalleryImpl::UpdateGallery(void) +{ + SysTryReturn(NID_UI_CTRL, __pGalleryItemProviderAdaptor->HasGalleryItemProvider() == true, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] Item provider is null"); + + result r = GetCore().RequestToUpdateAllItems(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +_GalleryImpl::RequestToUnloadAllItems(void) +{ + result r = GetCore().RequestToUnloadAllItems(); + SysAssert(r == E_SUCCESS); +} + +void +_GalleryImpl::SetEffect(Effect* pEffect) +{ + GetCore().SetEffect(pEffect); +} + +Effect* +_GalleryImpl::GetEffect(void) +{ + return GetCore().GetEffect(); +} + +_GalleryImpl* +_GalleryImpl::GetInstance(Gallery& gallery) +{ + return static_cast<_GalleryImpl*> (gallery._pControlImpl); +} + +const _GalleryImpl* +_GalleryImpl::GetInstance(const Gallery& gallery) +{ + return static_cast (gallery._pControlImpl); +} + +// Ui Builder +class _GalleryMaker + : public _UiBuilderControlMaker +{ +public: + _GalleryMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder) {}; + virtual ~_GalleryMaker() {}; + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _GalleryMaker* pListViewMaker = new (std::nothrow) _GalleryMaker(uibuilder); + return pListViewMaker; + }; +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + Gallery* pGallery = null; + Rectangle rect; + Tizen::Base::String elementString; + int currentIndex = 0; + int duration = 0; + Color color; + bool isZoomingEnabled = true; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pGallery = new (std::nothrow) Gallery(); + if (pGallery == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + //Construct + r = pGallery->Construct(rect); + if (r != E_SUCCESS) + { + delete pGallery; + return null; + } + + if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString)) + { + ConvertStringToColor32(elementString, 100, color); + r = pGallery->SetBackgroundColor(color); + if (r != E_SUCCESS) + { + delete pGallery; + return null; + } + } + + if (pControl->GetElement(L"bitmapPathOfEmptyGallery", elementString)) + { + Bitmap* pBackgroundBitmap = null; + pBackgroundBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565); + if (pBackgroundBitmap != null) + { + r = pGallery->SetBitmapOfEmptyGallery(pBackgroundBitmap); + if (r != E_SUCCESS) + { + delete pBackgroundBitmap; + delete pGallery; + return null; + } + delete pBackgroundBitmap; + } + } + + if (pControl->GetElement(L"currentItemIndex", elementString)) + { + Base::Integer::Parse(elementString, currentIndex); + r = pGallery->SetCurrentItemIndex(currentIndex); + if (r != E_SUCCESS) + { + delete pGallery; + return null; + } + } + + if (pControl->GetElement(L"slideShowAnimation", elementString)) + { + GalleryAnimation animation = GALLERY_ANIMATION_DISSOLVE; + if (elementString.Equals(L"GALLERY_ANIMATION_PAGE", false)) + { + animation = GALLERY_ANIMATION_PAGE; + } + else if (elementString.Equals(L"GALLERY_ANIMATION_ZOOM", false)) + { + animation = GALLERY_ANIMATION_ZOOM; + } + + r = pGallery->SetSlideShowAnimation(animation); + if (r != E_SUCCESS) + { + delete pGallery; + return null; + } + } + + if (pControl->GetElement(L"slideShowAnimationDuration", elementString)) + { + Base::Integer::Parse(elementString, duration); + r = pGallery->SetSlideShowAnimationDuration(duration); + if (r != E_SUCCESS) + { + delete pGallery; + return null; + } + } + + if (pControl->GetElement(L"slideShowViewDuration", elementString)) + { + Base::Integer::Parse(elementString, duration); + r = pGallery->SetSlideShowViewDuration(duration); + if (r != E_SUCCESS) + { + delete pGallery; + return null; + } + } + + if (pControl->GetElement(L"textOfEmptyGallery", elementString)) + { + r = pGallery->SetTextOfEmptyGallery(elementString); + if (r != E_SUCCESS) + { + delete pGallery; + return null; + } + } + + if (pControl->GetElement(L"zoomingEabled", elementString)) + { + { + if (elementString.Equals(L"true", false)) + { + isZoomingEnabled = true; + } + else + { + isZoomingEnabled = false; + } + } + r = pGallery->SetZoomingEnabled(isZoomingEnabled); + if (r != E_SUCCESS) + { + delete pGallery; + return null; + } + } + + return pGallery; + } + +private: +}; + +_GalleryRegister::_GalleryRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"Gallery", _GalleryMaker::GetInstance); +} +_GalleryRegister::~_GalleryRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"Gallery"); +} +static _GalleryRegister GalleryRegisterToUiBuilder; +}}} // Controls diff --git a/src/ui/controls/FUiCtrl_GalleryImplEvent.cpp b/src/ui/controls/FUiCtrl_GalleryImplEvent.cpp new file mode 100644 index 0000000..532074c --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryImplEvent.cpp @@ -0,0 +1,74 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include "FUiCtrl_GalleryImplEvent.h" +#include "FUiCtrl_GalleryImplEventArg.h" + +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryImplEvent::_GalleryImplEvent(void) + : __pSource(null) +{ + // Do nothing +} + +_GalleryImplEvent::~_GalleryImplEvent(void) +{ + // Do nothing +} + +result +_GalleryImplEvent::Construct(Gallery* pSource) +{ + __pSource = pSource; + + return E_SUCCESS; +} + +void +_GalleryImplEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + IGalleryEventListener* pGalleryEventListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pGalleryEventListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] pListener is invalid listener type."); + + const _GalleryImplEventArg& galleryArg = static_cast(arg); + + switch (galleryArg.GetEventType()) + { + case GALLERY_EVENT_CURRENT_ITEM_CHANGED: + pGalleryEventListener->OnGalleryCurrentItemChanged(*__pSource, galleryArg.GetArg1()); + break; + case GALLERY_EVENT_ITEM_CLICKED: + pGalleryEventListener->OnGalleryItemClicked(*__pSource, galleryArg.GetArg1()); + break; + case GALLERY_EVENT_SLIDE_SHOW_STARTED: + pGalleryEventListener->OnGallerySlideShowStarted(*__pSource); + break; + case GALLERY_EVENT_SLIDE_SHOW_STOPPED: + pGalleryEventListener->OnGallerySlideShowStopped(*__pSource); + break; + default: + SysTryReturnVoidResult(NID_UI_CTRL, false, E_INVALID_ARG, "[E_INVALIDE_ARG] The event type is invalid type."); + break; + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryImplEventArg.cpp b/src/ui/controls/FUiCtrl_GalleryImplEventArg.cpp new file mode 100644 index 0000000..3a6251d --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryImplEventArg.cpp @@ -0,0 +1,45 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include "FUiCtrl_GalleryImplEventArg.h" + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryImplEventArg::_GalleryImplEventArg(_GalleryEventType eventType, int arg1) + : __arg1(arg1) + , __eventType(eventType) +{ + // Do nothing +} + +_GalleryImplEventArg::~_GalleryImplEventArg(void) +{ + // Do nothing +} + +int +_GalleryImplEventArg::GetArg1(void) const +{ + return __arg1; +} + +_GalleryEventType +_GalleryImplEventArg::GetEventType(void) const +{ + return __eventType; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryItem.cpp b/src/ui/controls/FUiCtrl_GalleryItem.cpp new file mode 100644 index 0000000..1fb49e0 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryItem.cpp @@ -0,0 +1,138 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include "FUiCtrl_GalleryItem.h" +#include "FUiCtrl_GalleryBitmap.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryItem::_GalleryItem(_GalleryBitmap* pImage, String imageFilePath, _GalleryImageRotation rotation) + : __pOriginImage(pImage) + , __pImage(null) + , __imageFilePath(imageFilePath) + , __rotation(rotation) + , __itemIndex(-1) +{ + // Do nothing +} + +_GalleryItem::~_GalleryItem(void) +{ + + delete __pOriginImage; + __pOriginImage = null; + + delete __pImage; + __pImage = null; +} + +void +_GalleryItem::SetGalleryItemImage(_GalleryBitmap* pImage) +{ + delete __pImage; + __pImage = pImage; +} + +_GalleryBitmap* +_GalleryItem::GetGalleryItemImage(void) const +{ + if (__pOriginImage == null) + { + SetLastResult(E_SYSTEM); + return null; + } + + Dimension dim = __pOriginImage->GetSize(); + Rectangle rect(0, 0, dim.width, dim.height); + + result r = E_SUCCESS; + _GalleryBitmap* pImage = null; + + Bitmap* pBitmap = new(std::nothrow) Bitmap(); + SysTryCatch(NID_UI_CTRL, pBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pBitmap->Construct(*__pOriginImage->GetInternalBitmap(), rect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pImage = _GalleryBitmap::CreateGalleryBitmapN(pBitmap); + SysTryCatch(NID_UI_CTRL, pImage != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + pImage->SetBitmapRotation(__pOriginImage->GetBitmapRotation()); + const_cast<_GalleryItem*>(this)->SetGalleryItemImage(pImage); + + delete pBitmap; + return pImage; + +CATCH: + delete pBitmap; + const_cast<_GalleryItem*>(this)->SetGalleryItemImage(null); + return null; +} + +void +_GalleryItem::SetOriginGalleryItemImage(_GalleryBitmap* pImage) +{ + delete __pOriginImage; + __pOriginImage = pImage; +} + +_GalleryBitmap* +_GalleryItem::GetOriginItemImage(void) const +{ + return __pOriginImage; +} + +void +_GalleryItem::SetGalleryItemFilePath(String& filePath) +{ + __imageFilePath = filePath; +} + +String +_GalleryItem::GetGalleryItemFilePath(void) const +{ + return __imageFilePath; +} + +void +_GalleryItem::SetGalleryRotation(_GalleryImageRotation rotation) +{ + __rotation = rotation; +} + +_GalleryImageRotation +_GalleryItem::GetGalleryRotation(void) const +{ + return __rotation; +} + +void +_GalleryItem::SetItemIndex(int groupIndex, int itemIndex) +{ + __itemIndex = itemIndex; +} + +void +_GalleryItem::GetItemIndex(int& groupIndex, int& itemIndex) const +{ + groupIndex = 0; + itemIndex = __itemIndex; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryItemImpl.cpp b/src/ui/controls/FUiCtrl_GalleryItemImpl.cpp new file mode 100644 index 0000000..cc18ec2 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryItemImpl.cpp @@ -0,0 +1,118 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include +#include "FUiCtrl_GalleryItemImpl.h" +#include "FUiCtrl_GalleryItem.h" +#include "FUiCtrl_GalleryBitmap.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryItemImpl::_GalleryItemImpl(GalleryItem* pPublicGalleryItem, _GalleryItem* pCoreGalleryItem) + : __pPublicGalleryItem(pPublicGalleryItem) + , __pCoreGalleryItem(pCoreGalleryItem) +{ + // Do nothing +} +_GalleryItemImpl::~_GalleryItemImpl(void) +{ + delete __pCoreGalleryItem; +} + +_GalleryItemImpl* +_GalleryItemImpl::CreateGalleryItemImplN(GalleryItem* pPubilcGalleryItem, const Bitmap& image, + GalleryImageRotation rotation, String filePath) +{ + SysTryReturn(NID_UI_CTRL, pPubilcGalleryItem != null, null, E_INVALID_ARG, + "[E_INVALID_ARG] The public gallery item argument is null."); + + _GalleryItem* pCoreGalleryItem = null; + _GalleryItemImpl* pImplGalleryItem = null; + _GalleryBitmap* pGalleryBitmap = null; + + pGalleryBitmap = _GalleryBitmap::CreateGalleryBitmapN(const_cast(&image)); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pGalleryBitmap != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(r)); + + pGalleryBitmap->SetBitmapRotation(static_cast<_GalleryImageRotation>(rotation)); + + pCoreGalleryItem = new (std::nothrow) _GalleryItem(pGalleryBitmap, filePath, static_cast<_GalleryImageRotation>(rotation)); + SysTryCatch(NID_UI_CTRL, pCoreGalleryItem != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pImplGalleryItem = new (std::nothrow) _GalleryItemImpl(pPubilcGalleryItem, pCoreGalleryItem); + SysTryCatch(NID_UI_CTRL, pImplGalleryItem != null, pGalleryBitmap = null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + SetLastResult(E_SUCCESS); + + return pImplGalleryItem; +CATCH: + //delete pImplGalleryItem; + delete pCoreGalleryItem; + delete pGalleryBitmap; + + return null; +} + +const char* +_GalleryItemImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::GalleryItem"; +} + +const GalleryItem& +_GalleryItemImpl::GetPublic(void) const +{ + return *__pPublicGalleryItem; +} + +GalleryItem& +_GalleryItemImpl::GetPublic(void) +{ + return *__pPublicGalleryItem; +} + +const _GalleryItem& +_GalleryItemImpl::GetCore(void) const +{ + return *__pCoreGalleryItem; +} + +_GalleryItem& +_GalleryItemImpl::GetCore(void) +{ + return *__pCoreGalleryItem; +} + +_GalleryItemImpl* +_GalleryItemImpl::GetInstance(GalleryItem& galleryItem) +{ + return static_cast<_GalleryItemImpl*> (galleryItem.__pImpl); +} + +const _GalleryItemImpl* +_GalleryItemImpl::GetInstance(const GalleryItem& galleryItem) +{ + return static_cast (galleryItem.__pImpl); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryItemProvider.cpp b/src/ui/controls/FUiCtrl_GalleryItemProvider.cpp new file mode 100644 index 0000000..5196d97 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryItemProvider.cpp @@ -0,0 +1,71 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include "FUiCtrl_GalleryItemProvider.h" +#include "FUiCtrl_GalleryCoreEvent.h" +#include "FUiCtrl_GalleryCoreEventArg.h" +#include "FUiCtrl_GalleryItem.h" +#include "FUiCtrl_GalleryItemProviderAdaptorImpl.h" +#include "FUiCtrl_GalleryBitmap.h" + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryItemProvider::_GalleryItemProvider(_GalleryCoreEvent& coreEvent, _GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor) + : __coreEvent(coreEvent) + , __pItemProviderAdaptor(pGalleryItemProviderAdaptor) +{ + // Do nothing. +} + +_GalleryItemProvider::~_GalleryItemProvider(void) +{ + // Do nothing. +} + +_GalleryItem* +_GalleryItemProvider::CreateItem(int index) +{ + _GalleryItem* pItem = __pItemProviderAdaptor->CreateItem(index); + + SetLastResult(E_SUCCESS); + return pItem; +} + +bool +_GalleryItemProvider::DeleteItem(int index, _GalleryItem* pItem) +{ + SetLastResult(E_SUCCESS); + return __pItemProviderAdaptor->DeleteItem(index, pItem); +} + +bool +_GalleryItemProvider::UnloadItem(int index, _GalleryItem* pItem) +{ + SetLastResult(E_SUCCESS); + return __pItemProviderAdaptor->UnloadItem(index, pItem); +} + +int +_GalleryItemProvider::GetItemCount(void) const +{ + SetLastResult(E_SUCCESS); + return __pItemProviderAdaptor->GetItemCount(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryItemProviderAdaptor.cpp b/src/ui/controls/FUiCtrl_GalleryItemProviderAdaptor.cpp new file mode 100644 index 0000000..b28650a --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryItemProviderAdaptor.cpp @@ -0,0 +1,135 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include "FUiCtrl_GalleryItemProviderAdaptor.h" +#include "FUiCtrl_IGalleryItemProvider.h" +#include "FUiCtrl_GalleryItem.h" +#include "FUiCtrl_GalleryBitmap.h" + + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryItemProviderAdaptor::_GalleryItemProviderAdaptor(_IGalleryItemProvider& itemProvider) + : __itemProvider(itemProvider) +{ + // Do nothing. +} + +_GalleryItemProviderAdaptor::~_GalleryItemProviderAdaptor(void) +{ + // Do nothing. +} + +result +_GalleryItemProviderAdaptor::SetGalleryItemProvider(_IGalleryItemProvider& itemProvider) +{ + __itemProvider = itemProvider; + + return E_SUCCESS; +} + +_IListItemCommon* +_GalleryItemProviderAdaptor::LoadItem(int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, itemIndex >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] Item index argument is negative."); + + _GalleryItem* pItem = __itemProvider.CreateItem(itemIndex); + SysTryReturn(NID_UI_CTRL, pItem != null, null, E_SYSTEM, "[E_SYSTEM] Did not create a GalleryItem"); + + SetLastResult(E_SUCCESS); + + return pItem; +} + +result +_GalleryItemProviderAdaptor::UnloadItem(_IListItemCommon* pItem, int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, pItem != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Gallery Item is null"); + SysTryReturn(NID_UI_CTRL, itemIndex >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] Item index is negative."); + //SysTryReturn(NID_UI_CTRL, itemIndex < GetItemCount(), null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Item index argument is out of range."); + + _GalleryItem* pGalleryItem = dynamic_cast<_GalleryItem*>(pItem); + SysTryReturn(NID_UI_CTRL, pGalleryItem != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] pItem is not a _GalleryItem object"); + + bool deleteSuccess = true; + if (pGalleryItem->GetAppInfo() != null) + { + deleteSuccess = __itemProvider.UnloadItem(itemIndex, pGalleryItem); + } + else + { + delete pGalleryItem; + } + + if (deleteSuccess == true) + { + return E_SUCCESS; + } + else if (GetLastResult() != E_SUCCESS) + { + return GetLastResult(); + } + else + { + return E_INVALID_STATE; + } +} + +int +_GalleryItemProviderAdaptor::GetItemCount(int groupIndex) const +{ + return __itemProvider.GetItemCount(); +} + +result +_GalleryItemProviderAdaptor::DeleteItem(_IListItemCommon* pItem, int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, pItem != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Gallery Item is null."); + SysTryReturn(NID_UI_CTRL, itemIndex >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] Item index is negative."); + + _GalleryItem* pGalleryItem = dynamic_cast<_GalleryItem*>(pItem); + SysTryReturn(NID_UI_CTRL, pGalleryItem != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] pItem is not a _GalleryItem object"); + + bool deleteSuccess = true; + if (pGalleryItem->GetAppInfo() != null) + { + deleteSuccess = __itemProvider.DeleteItem(itemIndex, pGalleryItem); + } + else + { + delete pGalleryItem; + } + + if (deleteSuccess == true) + { + return E_SUCCESS; + } + else if (GetLastResult() != E_SUCCESS) + { + return GetLastResult(); + } + else + { + return E_INVALID_STATE; + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryItemProviderAdaptorImpl.cpp b/src/ui/controls/FUiCtrl_GalleryItemProviderAdaptorImpl.cpp new file mode 100644 index 0000000..e21b782 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryItemProviderAdaptorImpl.cpp @@ -0,0 +1,114 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include +#include "FUiCtrl_GalleryItemProviderAdaptorImpl.h" +#include "FUiCtrl_GalleryItemImpl.h" +#include "FUiCtrl_GalleryItem.h" + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryItemProviderAdaptorImpl::_GalleryItemProviderAdaptorImpl(void) + : __pItemProvider(null) +{ + // Do nothing +} + +_GalleryItemProviderAdaptorImpl::~_GalleryItemProviderAdaptorImpl(void) +{ + // Do nothing +} + +void +_GalleryItemProviderAdaptorImpl::SetGalleryItemProvider(const IGalleryItemProvider& itemProvider) +{ + __pItemProvider = &const_cast(itemProvider); +} + +bool +_GalleryItemProviderAdaptorImpl::HasGalleryItemProvider(void) const +{ + return __pItemProvider != null ? true : false; +} + +_GalleryItem* +_GalleryItemProviderAdaptorImpl::CreateItem(int index) +{ + if (HasGalleryItemProvider() == false) + { + return null; + } + + GalleryItem* pPublicItem = __pItemProvider->CreateItem(index); + if (pPublicItem != null) + { + _GalleryItemImpl* pImplItem = _GalleryItemImpl::GetInstance(*pPublicItem); + SysTryReturn(NID_UI_CTRL, pImplItem != null, null, E_INVALID_STATE, "[E_INVALID_STATE] Gallery item impl is null."); + pImplItem->GetCore().SetAppInfo(pImplItem); + return &pImplItem->GetCore(); + } + + SetLastResult(E_SUCCESS); + return null; +} + +bool +_GalleryItemProviderAdaptorImpl::UnloadItem(int index, _GalleryItem* pItem) +{ + if (HasGalleryItemProvider() == false) + { + return true; + } + + SysTryReturn(NID_UI_CTRL, pItem != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The pItem is null."); + + _GalleryItemImpl* pImplItem = static_cast<_GalleryItemImpl*>(pItem->GetAppInfo()); + GalleryItem* pPublicItem = static_cast(&pImplItem->GetPublic()); + + SetLastResult(E_SUCCESS); + if (__pItemProvider->DeleteItem(index, pPublicItem) == false) + { + delete pPublicItem; + } + + return true; +} + +bool +_GalleryItemProviderAdaptorImpl::DeleteItem(int index, _GalleryItem* pItem) +{ + _GalleryItemImpl* pImplItem = static_cast<_GalleryItemImpl*>(pItem->GetAppInfo()); + GalleryItem* pPublicItem = &pImplItem->GetPublic(); + delete pPublicItem; + + SetLastResult(E_SUCCESS); + return true; +} + +int +_GalleryItemProviderAdaptorImpl::GetItemCount(void) const +{ + if (HasGalleryItemProvider() == false) + { + return 0; + } + return __pItemProvider->GetItemCount(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryModel.cpp b/src/ui/controls/FUiCtrl_GalleryModel.cpp new file mode 100644 index 0000000..656d47f --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryModel.cpp @@ -0,0 +1,217 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include "FUiCtrl_GalleryModel.h" +#include "FUiCtrl_GalleryItem.h" +#include "FUiCtrl_GalleryItemProviderAdaptor.h" + +namespace Tizen { namespace Ui { namespace Controls { + +namespace +{ + +const int GALLERY_ITEM_CACHE_SIZE = 5; + +} // unnamed namespace + +_GalleryModel::_GalleryModel(void) + : __pGalleryItemProviderAdaptor(null) + , __itemCount(0) +{ + // Do nothing. +} + +_GalleryModel::~_GalleryModel(void) +{ + result r = __listViewModel.RemoveAllItem(); + + delete __pGalleryItemProviderAdaptor; + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +_GalleryModel* +_GalleryModel::CreateGalleryModelN(_IGalleryItemProvider& galleryItemProvider) +{ + result r = E_SUCCESS; + + _GalleryItemProviderAdaptor* pGalleryItemProviderAdaptor = new (std::nothrow) _GalleryItemProviderAdaptor(galleryItemProvider); + SysTryReturn(NID_UI_CTRL, pGalleryItemProviderAdaptor != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + _GalleryModel* pGalleryModel = new (std::nothrow) _GalleryModel(); + SysTryCatch(NID_UI_CTRL, pGalleryModel != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pGalleryModel->RegisterItemProviderAdaptor(pGalleryItemProviderAdaptor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pGalleryModel->SetCacheSize(GALLERY_ITEM_CACHE_SIZE); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return pGalleryModel; + +CATCH: + delete pGalleryItemProviderAdaptor; + delete pGalleryModel; + + return null; +} + +result +_GalleryModel::RegisterItemProviderAdaptor(_GalleryItemProviderAdaptor* pGalleryItemProviderAdaptor) +{ + __pGalleryItemProviderAdaptor = pGalleryItemProviderAdaptor; + return __listViewModel.RegisterItemProviderAdaptor(pGalleryItemProviderAdaptor); +} + +_GalleryItem* +_GalleryModel::GetItem(int index) const +{ + SysTryReturn(NID_UI_CTRL, index >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The argument(%d) is negative value.", index); + + _GalleryItem* pItem = static_cast<_GalleryItem*>(const_cast<_ListViewModel*>(&__listViewModel)->LoadItem(0, index)); + SysTryReturn(NID_UI_CTRL, pItem != null, null, GetLastResult(), + "[%s] gallery item(%d) is invalid object", GetErrorMessage(GetLastResult()), index); + + SetLastResult(E_SUCCESS); + + return pItem; +} + +result +_GalleryModel::SetItemProvider(_IGalleryItemProvider& provider) +{ + return __pGalleryItemProviderAdaptor->SetGalleryItemProvider(provider); +} + +int +_GalleryModel::GetItemCount(void) const +{ + return __itemCount; +} + +int +_GalleryModel::GetItemCountFromProvider(void) const +{ + return __pGalleryItemProviderAdaptor->GetItemCount(0); +} + +void +_GalleryModel::UpdateItemCount(void) +{ + __itemCount = GetItemCountFromProvider(); +} + +result +_GalleryModel::RequestToLoadItem(int index) +{ + SysTryReturn(NID_UI_CTRL, index >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The argument(%d) is out of range.", index); + SysTryReturnResult(NID_UI_CTRL, index <= GetItemCount(), E_OUT_OF_RANGE, "Item index is out of range."); + + _IListItemCommon* pCommonItem = __pGalleryItemProviderAdaptor->LoadItem(0, index); + SysTryReturnResult(NID_UI_CTRL, pCommonItem != null, GetLastResult(), "Propagating."); + + // pCommonItem is always _GalleryItem type. + _GalleryItem* pItem = static_cast<_GalleryItem*>(pCommonItem); + result r = __listViewModel.InsertItemToGroup(pItem, 0, index); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + __itemCount++; + + return E_SUCCESS; +} + +result +_GalleryModel::RequestToUnloadItem(int index) +{ + SysTryReturn(NID_UI_CTRL, index >= 0 && index < GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The argument(%d) is out of range.", index); + + result r = __listViewModel.RemoveItemAt(0, index); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + __itemCount--; + + return E_SUCCESS; +} + + +result +_GalleryModel::RequestToUnloadAllItems(void) +{ + return __listViewModel.DeleteAllGroupAndItem(); +} + +result +_GalleryModel::RequestToUpdateItem(int index) +{ + SysTryReturn(NID_UI_CTRL, index >= 0 && index < GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The argument(%d) is out of range.", index); + + _IListItemCommon* pItem = __pGalleryItemProviderAdaptor->LoadItem(0, index); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pItem != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __listViewModel.SetItem(*pItem, 0, index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryModel::RequestToUpdateAllItems(void) +{ + UpdateItemCount(); + result r = RequestToUnloadAllItems(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = AddGroup(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryModel::SetCacheSize(int size) +{ + SysTryReturn(NID_UI_CTRL, size >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The argument(%d) is out of range.", size); + return __listViewModel.SetMaxCachingSize(size); +} + +int +_GalleryModel::GetCacheSize(void) const +{ + return __listViewModel.GetMaxCachingSize(); +} + +result +_GalleryModel::AddGroup(void) +{ + int itemCount = GetItemCount(); + if (__listViewModel.GetAllGroupCount() == 0) + { + result r = __listViewModel.AddGroup(itemCount); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + //r = __listViewModel.SetAllItemCountAndHeight(1, itemCount, 1); + //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryPresenter.cpp b/src/ui/controls/FUiCtrl_GalleryPresenter.cpp new file mode 100644 index 0000000..300a16d --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryPresenter.cpp @@ -0,0 +1,1256 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include "FUi_Math.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_GalleryPresenter.h" +#include "FUiCtrl_GalleryModel.h" +#include "FUiCtrl_GalleryItemProvider.h" +#include "FUiCtrl_GalleryCoreEvent.h" +#include "FUiCtrl_GalleryCoreEventArg.h" +#include "FUiCtrl_GalleryImageReader.h" +#include "FUiCtrl_GalleryViewEventHandler.h" +#include "FUiCtrl_IGalleryCoreEventListener.h" +#include "FUiCtrl_IGalleryRenderer.h" +#include "FUiCtrl_GalleryBitmap.h" +#include "FUiCtrl_GalleryViewEvent.h" +#include "FUiAnim_VisualElement.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls { + +namespace +{ + +const int DEFAULT_ITEM_SPACING = 30; + +const int DEFAULT_ANIMATION_DURATION = 3000; +const int MIN_ANIMATION_DURATION = 300; +const int MAX_ANIMATION_DURATION = 20000; +const int DEFAULT_VIEW_DURATION = 10; +const int MIN_VIEW_DURATION = 10; +const int FIRST_SLIDE_SHOW_DURATION = 1; + +const int PARTIAL_CANVAS = 0; +} // unnamed namespace + +IMPLEMENT_PROPERTY(_GalleryPresenter); + +_GalleryPresenter::_GalleryPresenter(_IGalleryRenderer& galleryRenderer) + : __galleryRenderer(galleryRenderer) + , __pGalleryViewEventHandler(null) + , __pGalleryCoreEvent(null) + , __pGalleryItemProvider(null) + , __pGalleryModel(null) + , __pGalleryImageReader(null) + , __pEmptyGalleryImage(null) + , __emptyText(L"") + , __slideShowAnimationDuration(DEFAULT_ANIMATION_DURATION) + , __slideShowViewDuration(DEFAULT_VIEW_DURATION) + , __gallerySlideShowType(GALLERY_SLIDESHOW_DISSOLVE) + , __currentItemIndex(NO_CURRENT_IMAGE) + , __slideShowRepeat(false) + , __slideShowStarted(false) + , __zoomingEnabled(true) + , __pSlideShowTimer(null) + , __slideShowPlayCount(0) + , __itemSpacing(DEFAULT_ITEM_SPACING) + , __pItemToCanvas(null) + , __fittingType(GALLERY_FITTING_TYPE_FIT) + , __verticalAlignment(GALLERY_VERTICAL_ALIGN_MIDDLE) + , __horizontalAlignment(GALLERY_HORIZONTAL_ALIGN_CENTER) + , __emptyFontSize(0) + , __emptyFontStyle(FONT_STYLE_PLAIN) +{ + AddPropertyChangeEventListener(*this); +} + +_GalleryPresenter::~_GalleryPresenter(void) +{ + delete __pGalleryViewEventHandler; + delete __pGalleryImageReader; + delete __pGalleryModel; + delete __pGalleryItemProvider; + delete __pGalleryCoreEvent; + delete __pEmptyGalleryImage; + delete[] __pItemToCanvas; + delete __pSlideShowTimer; + __pSlideShowTimer = null; +} + +_GalleryPresenter* +_GalleryPresenter::CreateGalleryPresenterN(_IGalleryRenderer& galleryRenderer, _GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor) +{ + _GalleryPresenter* pPresenter = new (std::nothrow) _GalleryPresenter(galleryRenderer); + SysTryReturn(NID_UI_CTRL, pPresenter != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pPresenter->Construct(pGalleryItemProviderAdaptor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return pPresenter; + +CATCH: + delete pPresenter; + + return null; +} + +result +_GalleryPresenter::Construct(_GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor) +{ + SetLastResult(E_SUCCESS); + + result r = E_SUCCESS; + + __pGalleryCoreEvent = new (std::nothrow) _GalleryCoreEvent(); + SysTryCatch(NID_UI_CTRL, __pGalleryCoreEvent != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pGalleryItemProvider = new (std::nothrow) _GalleryItemProvider(*__pGalleryCoreEvent, pGalleryItemProviderAdaptor); + SysTryCatch(NID_UI_CTRL, __pGalleryItemProvider != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pGalleryModel = _GalleryModel::CreateGalleryModelN(*__pGalleryItemProvider); + SysTryCatch(NID_UI_CTRL, __pGalleryModel != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pGalleryImageReader = new (std::nothrow) _GalleryImageReader(*__pGalleryModel); + SysTryCatch(NID_UI_CTRL, __pGalleryImageReader != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pItemToCanvas = new(std::nothrow) int[MAX_CANVAS_COUNT]; + SysTryCatch(NID_UI_CTRL, __pItemToCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + memset(__pItemToCanvas, -1, sizeof(int) * MAX_CANVAS_COUNT); + + r = __galleryRenderer.SetCanvasMaxCount(MAX_CANVAS_COUNT); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.EnableEmptyView(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_STRING_CONFIG(IDS_COM_BODY_NO_IMAGES, __emptyText); + r = __galleryRenderer.SetEmptyText(__emptyText); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pGalleryViewEventHandler = new (std::nothrow) _GalleryViewEventHandler(*this, __galleryRenderer, *__pGalleryImageReader); + SysTryCatch(NID_UI_CTRL, __pGalleryViewEventHandler != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pGalleryViewEventHandler->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetFontStyle(FONT_STYLE_PLAIN); + SetFontSize(32); + + return E_SUCCESS; + +CATCH: + delete __pGalleryViewEventHandler; + delete __pGalleryImageReader; + delete __pGalleryModel; + delete __pGalleryItemProvider; + delete __pGalleryCoreEvent; + delete[] __pItemToCanvas; + + return r; +} + +int +_GalleryPresenter::GetCurrentItemIndex(void) const +{ + return __currentItemIndex; +} + +result +_GalleryPresenter::SetCurrentItemIndex(int index, bool eventFire) +{ + SysTryReturn(NID_UI_CTRL, index < __pGalleryModel->GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The argument(%d) is out of range.", index); + + if (__currentItemIndex != NO_CURRENT_IMAGE && __currentItemIndex != index) + { + __currentItemIndex = index; + if (eventFire == true) + { + ChangedItem(); + } + } + else + { + __currentItemIndex = index; + } + + __pGalleryViewEventHandler->SetZoomFlag(false); + + return E_SUCCESS; +} + +result +_GalleryPresenter::SetCurrentItem(int index) +{ + SysTryReturn(NID_UI_CTRL, index >=0 && index < __pGalleryModel->GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The argument(%d) is out of range.", index); + + int oldCurrentCanvasIndex = 0; + result r = E_SUCCESS; + + if (index == __currentItemIndex) + { + return E_SUCCESS; + } + + if (__currentItemIndex != NO_CURRENT_IMAGE) + { + oldCurrentCanvasIndex = SearchCanvasIndex(__currentItemIndex); + SysTryReturn(NID_UI_CTRL, oldCurrentCanvasIndex != NOT_EXIST_CANVAS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] The canvas of %d item is not exist.", oldCurrentCanvasIndex); + + if (__currentItemIndex > index) + { + Rectangle rect = __galleryRenderer.GetViewRect(); + rect.x = rect.width; + r = __galleryRenderer.SetCanvasBounds(oldCurrentCanvasIndex, rect); + } + else if (__currentItemIndex < index) + { + Rectangle rect = __galleryRenderer.GetViewRect(); + rect.x = -rect.width; + r = __galleryRenderer.SetCanvasBounds(oldCurrentCanvasIndex, rect); + } + + r = __galleryRenderer.SetCanvasVisibility(oldCurrentCanvasIndex, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + int newCurrentCanvasIndex = SearchCanvasIndex(index); + if (newCurrentCanvasIndex == NOT_EXIST_CANVAS) + { + r = SetCanvasImage(index); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + newCurrentCanvasIndex = SearchCanvasIndex(index); + } + r = __galleryRenderer.SetCanvasBounds(newCurrentCanvasIndex, __galleryRenderer.GetViewRect()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasVisibility(newCurrentCanvasIndex, true); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetCurrentItemIndex(index); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + //RefreshView(); + + return E_SUCCESS; + +CATCH: + result resultValue = __galleryRenderer.SetCanvasVisibility(oldCurrentCanvasIndex, true); + if (resultValue != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "[%s] Failed to setting of canvas visibility.", GetErrorMessage(resultValue)); + } + + return r; +} + +int +_GalleryPresenter::GetItemCount(void) const +{ + return __pGalleryModel->GetItemCount(); +} + +void +_GalleryPresenter::SetItemSpacing(int spacing) +{ + __itemSpacing = spacing; +} +int +_GalleryPresenter::GetItemSpacing(void) const +{ + return __itemSpacing; +} + +_GallerySlideShowType +_GalleryPresenter::GetSlideShowType(void) const +{ + return __gallerySlideShowType; +} + +result +_GalleryPresenter::SetSlideShowType(_GallerySlideShowType slideShowType) +{ + SysTryReturn(NID_UI_CTRL, slideShowType >= GALLERY_SLIDESHOW_DISSOLVE && slideShowType <= GALLERY_SLIDESHOW_PAGE, + E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The animation argument(%d) is out of range", slideShowType); + + __gallerySlideShowType = slideShowType; + + return E_SUCCESS; +} + +int +_GalleryPresenter::GetSlideShowAnimationDuration(void) const +{ + Variant variant = GetProperty("slideShowAnimationDuration"); + return variant.ToInt(); +} + +result +_GalleryPresenter::SetSlideShowAnimationDuration(int duration) +{ + SysTryReturn(NID_UI_CTRL, duration >= MIN_ANIMATION_DURATION && duration <= MAX_ANIMATION_DURATION, + E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The argument(%d) is out of range.", duration); + + return SetProperty("slideShowAnimationDuration", Variant(duration)); +} + +int +_GalleryPresenter::GetSlideShowViewDuration(void) const +{ + Variant variant = GetProperty("slideShowViewDuration"); + return variant.ToInt(); +} + +result +_GalleryPresenter::SetSlideShowViewDuration(int duration) +{ + SysTryReturn(NID_UI_CTRL, duration >= MIN_VIEW_DURATION, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The argument(%d) is out of range.", duration); + + return SetProperty("slideShowViewDuration", Variant(duration)); +} + +result +_GalleryPresenter::StartSlideShow(bool repeat) +{ + SysTryReturn(NID_UI_CTRL, __pSlideShowTimer == null, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] Slide show is already started"); + + if (GetItemCount() == 0) + { + return E_SUCCESS; + } + + __slideShowRepeat = repeat; + __slideShowPlayCount = GetItemCount() - 1; + + result r = StartSlideShowTimer(GetSlideShowViewDuration()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _GalleryCoreEventArg* pArg = new(std::nothrow) _GalleryCoreEventArg(GALLERY_CORE_EVENT_SLIDE_SHOW_STARTED); + __pGalleryCoreEvent->Fire(*pArg); + + return E_SUCCESS; +} + +result +_GalleryPresenter::StopSlideShow(void) +{ + SysTryReturn(NID_UI_CTRL, __pSlideShowTimer != null, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] Slide show is already stopped"); + + StopSlideShowTimer(); + __galleryRenderer.StopAllCanvasAnimation(); + + result r = __pGalleryViewEventHandler->SetVisibleCanvas(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _GalleryCoreEventArg* pArg = new(std::nothrow) _GalleryCoreEventArg(GALLERY_CORE_EVENT_SLIDE_SHOW_STOPPED); + __pGalleryCoreEvent->Fire(*pArg); + + r = __galleryRenderer.RefreshView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +String +_GalleryPresenter::GetTextOfEmptyGallery(void) const +{ + Variant variant = GetProperty("textOfEmptyGallery"); + return variant.ToString(); +} + +result +_GalleryPresenter::SetTextOfEmptyGallery(const String& text) +{ + result r = __galleryRenderer.SetEmptyText(text); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return SetProperty("textOfEmptyGallery", Variant(text)); +} + +result +_GalleryPresenter::SetBitmapOfEmptyGallery(const _GalleryBitmap* pBitmap) +{ + result r = __galleryRenderer.SetEmptyImage(pBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pEmptyGalleryImage = const_cast <_GalleryBitmap*>(pBitmap); + + return E_SUCCESS; +} + +bool +_GalleryPresenter::IsSlideShowStarted(void) const +{ + return __pSlideShowTimer != null ? true : false; +} + +result +_GalleryPresenter::SetZoomingEnabled(bool enable) +{ + return SetProperty("zoomingEnabled", Variant(enable)); +} + +bool +_GalleryPresenter::IsZoomingEnabled(void) const +{ + Variant variant = GetProperty("zoomingEnabled"); + + return variant.ToBool(); +} + +bool +_GalleryPresenter::PostEvent(_GalleryViewEvent& event) +{ + bool slideShowStarted = false; + if (__pSlideShowTimer != null && event.GetEventType() != GALLERY_VIEW_EVENT_BOUNDS_CHANGED) + { + result r = StopSlideShow(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + slideShowStarted = true; + } + + if (GetItemCount() == 0) + { + if (event.GetEventType() == GALLERY_VIEW_EVENT_BOUNDS_CHANGED) + { + return OnBoundsChanged(); + } + //SetLastResult(E_SUCCESS); + return true; + } + + switch (event.GetEventType()) + { + case GALLERY_VIEW_EVENT_TOUCH_PRESSED: + { + if (slideShowStarted == true) + { + result r = __pGalleryViewEventHandler->SetVisibleCanvas(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + return true; + } + return __pGalleryViewEventHandler->OnTouchPressed(*(event.GetEventInfo())); + } + + case GALLERY_VIEW_EVENT_TOUCH_RELEASED: + return __pGalleryViewEventHandler->OnTouchReleased(*(event.GetEventInfo())); + + case GALLERY_VIEW_EVENT_TOUCH_DOUBLE_PRESSED: + __galleryRenderer.SetCanvasVisibility(PARTIAL_CANVAS, false); + return __pGalleryViewEventHandler->OnTouchDoublePressed(*(event.GetEventInfo())); + + case GALLERY_VIEW_EVENT_TOUCH_MOVED: + __galleryRenderer.SetCanvasVisibility(PARTIAL_CANVAS, false); + return __pGalleryViewEventHandler->OnTouchMoved(*(event.GetEventInfo())); + + case GALLERY_VIEW_EVENT_TOUCH_PINCH_ZOOM: + return __pGalleryViewEventHandler->OnTouchPinchZoom(*(event.GetEventInfo())); + + case GALLERY_VIEW_EVENT_TOUCH_FLICK: + //__galleryRenderer.SetCanvasVisibility(PARTIAL_CANVAS, false); + return __pGalleryViewEventHandler->OnTouchFlicked(*(event.GetEventInfo())); + + case GALLERY_VIEW_EVENT_BOUNDS_CHANGED: + return OnBoundsChanged(); + + default: + SysTryReturn(NID_UI_CTRL, false, false, E_INVALID_ARG, + "[E_INVALID_ARG] The event type(%d) is invalid type", event.GetEventType()); + } + + //SetLastResult(E_SUCCESS); + return true; +} + +bool +_GalleryPresenter::OnBoundsChanged(void) +{ + int itemIndex = -1; + result r = E_SUCCESS; + + r = __galleryRenderer.InitializeCanvasBounds(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (GetItemCount() > 0) + { + for (int canvasIndex = PARTIAL_CANVAS + 1; canvasIndex < MAX_CANVAS_COUNT; canvasIndex++) + { + itemIndex = __pItemToCanvas[canvasIndex]; + if (itemIndex != NOT_EXIST_CANVAS) + { + r = __galleryRenderer.SetCanvasImage(canvasIndex, __pGalleryImageReader->GetItemImage(itemIndex) + , __verticalAlignment, __horizontalAlignment, __fittingType); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + } + else + { + r = __galleryRenderer.EnableEmptyView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + SetLastResult(E_SUCCESS); + return true; + } + + int currentItemIndex = GetCurrentItemIndex(); + int currentCanvasIndex = SearchCanvasIndex(currentItemIndex); + int nextItemIndex = GetCurrentItemIndex() + 1; + if (nextItemIndex >= GetItemCount()) + { + nextItemIndex = 0; + } + int nextCanvasIndex = SearchCanvasIndex(nextItemIndex); + + r = __galleryRenderer.SetCanvasShowState(currentCanvasIndex, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pSlideShowTimer != null && __slideShowStarted == true) + { + r = __galleryRenderer.SetCanvasShowState(nextCanvasIndex, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __galleryRenderer.GalleryBoundsChanged(currentCanvasIndex); + Rectangle canvasBounds = __galleryRenderer.GetCanvasBounds(currentCanvasIndex); + Rectangle imageBounds = __galleryRenderer.GetCanvasImageBounds(currentCanvasIndex); + __pGalleryViewEventHandler->CorrectCanvasPosition(canvasBounds, imageBounds); + r = __galleryRenderer.SetCanvasBounds(currentCanvasIndex, canvasBounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pGalleryViewEventHandler->AlignCanvas(false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + SetLastResult(E_SUCCESS); + + return true; +} + +void +_GalleryPresenter::OnDraw(void) +{ + result r = E_SUCCESS; + + if (GetItemCount() > 0 && GetCurrentItemIndex() == NO_CURRENT_IMAGE) + { + r = SetCurrentItem(0); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __galleryRenderer.Draw(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} + +result +_GalleryPresenter::SetCoreEventListener(const _IGalleryCoreEventListener& coreEventListener) +{ + return __pGalleryCoreEvent->AddListener(coreEventListener); +} + +result +_GalleryPresenter::RemoveCoreEventListener(const _IGalleryCoreEventListener& coreEventListener) +{ + return __pGalleryCoreEvent->RemoveListener(coreEventListener); +} + +bool +_GalleryPresenter::ClickedItem(void) +{ + _GalleryCoreEventArg* pArg = new(std::nothrow) _GalleryCoreEventArg(GALLERY_CORE_EVENT_ITEM_CLICKED, __currentItemIndex); + return __pGalleryCoreEvent->Fire(*pArg); +} + +bool +_GalleryPresenter::ChangedItem(void) +{ + if (__currentItemIndex == NO_CURRENT_IMAGE) + { + return true; + } + + _GalleryCoreEventArg* pArg = new(std::nothrow) _GalleryCoreEventArg(GALLERY_CORE_EVENT_CURRENT_ITEM_CHANGED, __currentItemIndex); + return __pGalleryCoreEvent->Fire(*pArg); +} + +result +_GalleryPresenter::RequestToLoadItem(int itemIndex) +{ + result r = __pGalleryModel->RequestToLoadItem(itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + SortItemToCanvasIndex(itemIndex, true); + + if (GetItemCount() == 1) + { + r = __galleryRenderer.DisableEmptyView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetCurrentItem(itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __galleryRenderer.RefreshView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryPresenter::RequestToUnloadItem(int itemIndex) +{ + result r = __pGalleryModel->RequestToUnloadItem(itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int canvasIndex = SearchCanvasIndex(itemIndex); + if (canvasIndex != NOT_EXIST_CANVAS) + { + __galleryRenderer.SetCanvasVisibility(canvasIndex, false); + __pItemToCanvas[canvasIndex] = NOT_USED_CANVAS; + } + SortItemToCanvasIndex(itemIndex, false); + + if (GetItemCount() == 0) + { + r = SetCurrentItemIndex(NO_CURRENT_IMAGE); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.EnableEmptyView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + if (itemIndex < GetItemCount()) + { + r = SetCanvasImage(itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int canvasIndex = SearchCanvasIndex(itemIndex); + SysTryReturn(NID_UI_CTRL, canvasIndex != NOT_EXIST_CANVAS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] Failed to search canvas"); + + r = __galleryRenderer.SetCanvasVisibility(canvasIndex, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = SetCurrentItem(itemIndex - 1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + r = __galleryRenderer.RefreshView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryPresenter::RequestToUnloadAllItems(void) +{ + result r = __pGalleryModel->RequestToUnloadAllItems(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + for (int i = 0; i < MAX_CANVAS_COUNT; i++) + { + __pItemToCanvas[i] = NOT_USED_CANVAS; + } + + r = SetCurrentItemIndex(NO_CURRENT_IMAGE); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.EnableEmptyView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + //r = __galleryRenderer.RefreshView(); + //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryPresenter::RequestToUpdateItem(int itemIndex) +{ + result r = __pGalleryModel->RequestToUpdateItem(itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int canvasIndex = SearchCanvasIndex(itemIndex); + if (itemIndex == GetCurrentItemIndex()) + { + _GalleryBitmap* pImage = __pGalleryImageReader->GetItemImage(itemIndex); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImage != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasImage(canvasIndex, (const _GalleryBitmap*)pImage + , __verticalAlignment, __horizontalAlignment, __fittingType); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (canvasIndex != NOT_EXIST_CANVAS) + { + __pItemToCanvas[canvasIndex] = NOT_USED_CANVAS; + } + + r = __galleryRenderer.RefreshView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryPresenter::RequestToUpdateAllItems(void) +{ + result r = __pGalleryModel->RequestToUpdateAllItems(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.ResetAllCanvas(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + for (int i = 0; i < MAX_CANVAS_COUNT; i++) + { + __pItemToCanvas[i] = NOT_USED_CANVAS; + } + + int itemCount = GetItemCount(); + if (itemCount > 0) + { + r = __galleryRenderer.DisableEmptyView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (GetCurrentItemIndex() != NO_CURRENT_IMAGE) + { + r = SetCanvasImage(GetCurrentItemIndex()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasVisibility(SearchCanvasIndex(GetCurrentItemIndex()), true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = SetCurrentItem(0); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasVisibility(SearchCanvasIndex(0), true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + r = __galleryRenderer.EnableEmptyView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + //r = __galleryRenderer.RefreshView(); + //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryPresenter::RequestToUpdateItemCount(void) +{ + __pGalleryModel->UpdateItemCount(); + + return E_SUCCESS; +} + +void +_GalleryPresenter::OnTimerExpired(Runtime::Timer& timer) +{ + result r = E_SUCCESS; + if (&timer == __pSlideShowTimer) + { + r = PlaySlideShow(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + SetLastResult(E_SUCCESS); +} + +void +_GalleryPresenter::OnTransitionCancel(void) +{ + __slideShowStarted = false; + int endItemIndex = __currentItemIndex + 1; + if (GetItemCount() > 0) + { + endItemIndex = endItemIndex % GetItemCount(); + } + else + { + endItemIndex = 0; + } + + result r = SetCurrentItemIndex(endItemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + StopSlideShowTimer(); +} + +void +_GalleryPresenter::OnTransitionCompleted(void) +{ + __slideShowStarted = false; + if (__slideShowPlayCount > 0 || __slideShowRepeat == true) + { + StartSlideShowTimer(GetSlideShowViewDuration()); + } + else + { + result r = StopSlideShow(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating", GetErrorMessage(r)); + } + + int endItemIndex = __currentItemIndex + 1; + if (GetItemCount() > 0) + { + endItemIndex = endItemIndex % GetItemCount(); + } + else + { + endItemIndex = 0; + } + + result r = SetCurrentItemIndex(endItemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} + +void +_GalleryPresenter::OnCanvasAnimationCancel(void) +{ +} + +void +_GalleryPresenter::OnCanvasAnimationCompleted(void) +{ +} + +void +_GalleryPresenter::OnCanvasAnimationStarted(void) +{ + __slideShowStarted = true; +} + +result +_GalleryPresenter::SetCanvasImage(int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, itemIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The argument(%d) is negative value.", itemIndex); + SysTryReturn(NID_UI_CTRL, itemIndex >=0 && itemIndex < __pGalleryModel->GetItemCount(), + E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The argument(%d) is out of range.", itemIndex); + + if (SearchCanvasIndex(itemIndex) != NOT_EXIST_CANVAS) + { + return E_SUCCESS; + } + + int emptyCanvasIndex = GetEmptyCanvasIndex(); + if (emptyCanvasIndex == NOT_EXIST_CANVAS) + { + emptyCanvasIndex = ClearCanvasIndex(__currentItemIndex); + } + + _GalleryBitmap* pImage = __pGalleryImageReader->GetItemImage(itemIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pItemToCanvas[emptyCanvasIndex] = itemIndex; + r = __galleryRenderer.SetCanvasImage(emptyCanvasIndex, (const _GalleryBitmap*)pImage + , __verticalAlignment, __horizontalAlignment, __fittingType); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Rectangle bounds = __galleryRenderer.GetViewRect(); + r = __galleryRenderer.SetCanvasBounds(emptyCanvasIndex, bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasVisibility(emptyCanvasIndex, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryPresenter::SetPartialCanvasImage(void) +{ + SysTryReturn(NID_UI_CTRL, __currentItemIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The argument(%d) is negative value.", __currentItemIndex); + + if (__galleryRenderer.IsCanvasVisibility(PARTIAL_CANVAS) == true) + { + return E_SUCCESS; + } + + int currentCanvasIndex = SearchCanvasIndex(__currentItemIndex); + Rectangle canvasBounds = __galleryRenderer.GetCanvasBounds(currentCanvasIndex); + Rectangle imageBounds = __galleryRenderer.GetCanvasImageBounds(currentCanvasIndex); + Rectangle viewBounds = __galleryRenderer.GetViewRect(); + + if (imageBounds.width < viewBounds.width) + { + imageBounds.x -= (viewBounds.width - imageBounds.width) / 2; + } + + if (imageBounds.height < viewBounds.height) + { + imageBounds.y -= (viewBounds.height - imageBounds.height) / 2; + } + + canvasBounds.x = _Abs(-canvasBounds.x - imageBounds.x); + canvasBounds.y = _Abs(-canvasBounds.y - imageBounds.y); + canvasBounds.width = viewBounds.width < imageBounds.width ? viewBounds.width : imageBounds.width; + canvasBounds.height = viewBounds.height < imageBounds.height ? viewBounds.height : imageBounds.height; + + //Dimension size(canvasBounds.width, canvasBounds.height); + Dimension size(imageBounds.width, imageBounds.height); + + _GalleryBitmap* pImage = __pGalleryImageReader->GetPartialImageFromFileN(__currentItemIndex, canvasBounds, size); + SysTryReturn(NID_UI_CTRL, pImage != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pItemToCanvas[PARTIAL_CANVAS] = __currentItemIndex; + result r = __galleryRenderer.SetCanvasImage(PARTIAL_CANVAS, (const _GalleryBitmap*)pImage + , GALLERY_VERTICAL_ALIGN_MIDDLE, GALLERY_HORIZONTAL_ALIGN_CENTER, __fittingType); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasBounds(PARTIAL_CANVAS, viewBounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasVisibility(PARTIAL_CANVAS, true); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pImage; + + return E_SUCCESS; +CATCH: + delete pImage; + + return r; +} + +int +_GalleryPresenter::SearchCanvasIndex(int itemIndex) +{ + if (itemIndex == NO_CURRENT_IMAGE) + { + return NOT_EXIST_CANVAS; + } + + for (int i = 1; i < MAX_CANVAS_COUNT; i++) + { + if (__pItemToCanvas[i] == itemIndex) + { + return i; + } + } + + return NOT_EXIST_CANVAS; +} + +int +_GalleryPresenter::GetEmptyCanvasIndex(void) const +{ + for (int i = 1; i < MAX_CANVAS_COUNT; i++) + { + if (__pItemToCanvas[i] == NOT_USED_CANVAS) + { + return i; + } + } + return NOT_EXIST_CANVAS; +} + +result +_GalleryPresenter::SetCanvasIndex(int canvasIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, canvasIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The argument(%d) is negative value.", canvasIndex); + SysTryReturn(NID_UI_CTRL, canvasIndex > 0 && canvasIndex < MAX_CANVAS_COUNT, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The canvas index(%d) is out of range", canvasIndex); + SysTryReturn(NID_UI_CTRL, itemIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The argument(%d) is negative value.", itemIndex); + SysTryReturn(NID_UI_CTRL, itemIndex >=0 && itemIndex < __pGalleryModel->GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The argument(%d) is out of range.", itemIndex); + + if (__pItemToCanvas[canvasIndex] == NOT_USED_CANVAS) + { + __pItemToCanvas[canvasIndex] = itemIndex; + } + else + { + SysTryReturn(NID_UI_CTRL, false, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The canvas index(%d) is used.", canvasIndex); + } + + return E_SUCCESS; +} + +int +_GalleryPresenter::ClearCanvasIndex(int currentItemIndex) +{ + SysTryReturn(NID_UI_CTRL, currentItemIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument(%d) is negative value.", currentItemIndex); + + int clearCanvasIndex = 1; + int maxAbsValue = 0; + int absValue = 0; + + for (int i = 1; i < MAX_CANVAS_COUNT; i++) + { + absValue = _Abs(currentItemIndex - __pItemToCanvas[i]); + if (absValue > maxAbsValue) + { + maxAbsValue = absValue; + clearCanvasIndex = i; + } + } + __pItemToCanvas[clearCanvasIndex] = NOT_USED_CANVAS; + + SetLastResult(E_SUCCESS); + return clearCanvasIndex; +} + +void +_GalleryPresenter::SortItemToCanvasIndex(int itemIndex, bool add) +{ + if (add == true) + { + for (int i = 0; i < MAX_CANVAS_COUNT; i++) + { + if (__pItemToCanvas[i] >= itemIndex) + { + __pItemToCanvas[i]++; + } + } + } + else + { + for (int i = 0; i < MAX_CANVAS_COUNT; i++) + { + if (__pItemToCanvas[i] > itemIndex) + { + __pItemToCanvas[i]--; + } + } + } +} + +result +_GalleryPresenter::StartSlideShowTimer(int duration) +{ + result r = E_SUCCESS; + if (__pSlideShowTimer != null) + { + delete __pSlideShowTimer; + __pSlideShowTimer = null; + } + + __pSlideShowTimer = new(std::nothrow) Runtime::Timer(); + SysTryCatch(NID_UI_CTRL, __pSlideShowTimer != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pSlideShowTimer->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSlideShowTimer->Start(duration); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + delete __pSlideShowTimer; + __pSlideShowTimer = null; + + return GetLastResult(); +} + +void +_GalleryPresenter::StopSlideShowTimer(void) +{ + delete __pSlideShowTimer; + __pSlideShowTimer = null; + + __slideShowRepeat = false; + __slideShowPlayCount = 0; +} + +result +_GalleryPresenter::PlaySlideShow(void) +{ + int startCanvasIndex = SearchCanvasIndex(__currentItemIndex); + SysTryReturn(NID_UI_CTRL, startCanvasIndex != NOT_EXIST_CANVAS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] The current item not exist."); + + int endItemIndex = __currentItemIndex + 1; + if (endItemIndex >= GetItemCount()) + { + endItemIndex = 0; + } + + result r = __galleryRenderer.SetCanvasVisibility(PARTIAL_CANVAS, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasVisibility(startCanvasIndex, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int endCanvasIndex = SearchCanvasIndex(endItemIndex); + if (endCanvasIndex == NOT_EXIST_CANVAS) + { + r = SetCanvasImage(endItemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + endCanvasIndex = SearchCanvasIndex(endItemIndex); + } + + _GalleryTransitionType transition = static_cast<_GalleryTransitionType>(GetSlideShowType()); + _GalleryAnimationTiming animation = {__slideShowAnimationDuration, GALLERY_ANIMATION_TIMING_FUNC_EASEOUT}; + r = __galleryRenderer.SetCanvasVisibility(endCanvasIndex, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.RunCanvasTransition(startCanvasIndex, endCanvasIndex, transition, &animation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__slideShowRepeat == false) + { + __slideShowPlayCount--; + } + + r = __galleryRenderer.RefreshView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +// property access +Variant +_GalleryPresenter::GetPropertySlideShowViewDuration(void) const +{ + return Variant(__slideShowViewDuration); +} + +result +_GalleryPresenter::SetPropertySlideShowViewDuration(const Variant& variant) +{ + __slideShowViewDuration = variant.ToInt(); + + return E_SUCCESS; +} + +Variant +_GalleryPresenter::GetPropertySlideShowAnimationDuration(void) const +{ + return Variant(__slideShowAnimationDuration); +} + +result +_GalleryPresenter::SetPropertySlideShowAnimationDuration(const Variant& variant) +{ + __slideShowAnimationDuration = variant.ToInt(); + + return E_SUCCESS; +} + +Variant +_GalleryPresenter::GetPropertyTextOfEmptyGallery(void) const +{ + return Variant(__emptyText); +} + +result +_GalleryPresenter::SetPropertyTextOfEmptyGallery(const Variant& variant) +{ + __emptyText = variant.ToString(); + + return E_SUCCESS; +} + +Variant +_GalleryPresenter::GetPropertyZoomingEnabled(void) const +{ + return Variant(__zoomingEnabled); +} + +result +_GalleryPresenter::SetPropertyZoomingEnabled(const Variant& variant) +{ + __zoomingEnabled = variant.ToBool(); + + return E_SUCCESS; +} + +void +_GalleryPresenter::OnPropertyChanging(_PropertyBase& source, const String& name, + const Variant& oldProperty, const Variant& newProperty) +{ +} + +void +_GalleryPresenter::OnPropertyChanged(_PropertyBase& source, const String& name, + const Variant& oldProperty, const Variant& newProperty) +{ +} + +void +_GalleryPresenter::SetFontSize(int size) +{ + __emptyFontSize = size; +} + +int +_GalleryPresenter::GetFontSize(void) const +{ + return __emptyFontSize; +} + +void +_GalleryPresenter::SetFontStyle(FontStyle style) +{ + __emptyFontStyle = style; +} + +FontStyle +_GalleryPresenter::GetFontStyle(void) const +{ + return __emptyFontStyle; +} + +void +_GalleryPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = GetFontStyle(); + size = GetFontSize(); +} + +void +_GalleryPresenter::OnFontChanged(void) +{ + if (GetItemCount() == 0) + { + result r = __galleryRenderer.EnableEmptyView(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryRenderer.cpp b/src/ui/controls/FUiCtrl_GalleryRenderer.cpp new file mode 100644 index 0000000..d9a8111 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryRenderer.cpp @@ -0,0 +1,1280 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_Control.h" +#include "FUi_ResourceManager.h" +#include "FUiAnim_MatrixUtil.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_GalleryImpl.h" +#include "FUiCtrl_GalleryRenderer.h" +#include "FUiCtrl_GalleryBitmap.h" +#include "FUiCtrl_GalleryCanvasManager.h" +#include "FUiCtrl_GalleryCanvas.h" +#include "FUiCtrl_GalleryRendererNotifier.h" +#include "FUiCtrl_GalleryRendererNotification.h" +#include "FUiCtrl_IGalleryRendererNotiListener.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Effects; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls { + +namespace +{ + +const int GALLERY_CANVAS_INITIAL_MAX_COUNT = 5; +const int GALLERY_ZOOM_TRANSITION_ZOOM_FACTOR = 10; + +} // unnamed namespace + +_GalleryRenderer* +_GalleryRenderer::CreateGalleryRendererN(_Control& control) +{ + result r = E_SUCCESS; + + _GalleryRenderer* pRenderer = new (std::nothrow) _GalleryRenderer(); + SysTryCatch(NID_UI_CTRL, pRenderer != null, , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryRenderer."); + + r = pRenderer->Construct(control); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pRenderer; + +CATCH: + delete pRenderer; + + return null; +} + +result +_GalleryRenderer::AddNotiListener(const _IGalleryRendererNotiListener& notiListener) +{ + return GetRendererNotifier().AddListener((const IEventListener&)notiListener); +} + +result +_GalleryRenderer::RemoveNotiListener(const _IGalleryRendererNotiListener& notiListener) +{ + return GetRendererNotifier().RemoveListener((const IEventListener&)notiListener); +} + +result +_GalleryRenderer::SetCanvasMaxCount(int maxCount) +{ + result r = E_SUCCESS; + _GalleryCanvasManager& canvasManager = GetCanvasManager(); + Rectangle viewRect = GetViewRect(); + + r = canvasManager.ResetCanvasManager(maxCount + 1, viewRect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetEmptyCanvasIndex(maxCount); + + return E_SUCCESS; +} + +int +_GalleryRenderer::GetCanvasMaxCount(void) const +{ + return GetCanvasManager().GetCanvasCount(); +} + +result +_GalleryRenderer::SetCanvasVisibility(int canvasIndex, bool visibility) +{ + _GalleryCanvas* pCanvas = GetCanvasManager().GetCanvas(canvasIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas->GetFrameVisualElement().SetImplicitAnimationEnabled(false); + + if (visibility == true) + { + r = pCanvas->GetFrameVisualElement().SetZOrderGroup(1000); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas->GetFrameVisualElement().SetOpacity(1.0); + } + else + { + r = pCanvas->GetFrameVisualElement().SetZOrderGroup(0); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pCanvas->SetVisibility(visibility); +} +result +_GalleryRenderer::SetCanvasShowState(int canvasIndex, bool showState) +{ + _GalleryCanvas* pCanvas = GetCanvasManager().GetCanvas(canvasIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pCanvas->SetVisibility(showState); +} + +bool +_GalleryRenderer::IsCanvasVisibility(int canvasIndex) const +{ + _GalleryCanvas* pCanvas = GetCanvasManager().GetCanvas(canvasIndex); + SysTryReturn(NID_UI_CTRL, pCanvas != null, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return pCanvas->IsVisibility(); +} + +Rectangle +_GalleryRenderer::GetViewRect(void) const +{ + Rectangle rect = GetCanvasManager().GetRootCanvas().GetBounds(); + rect.x = 0; + rect.y = 0; + return rect; +} + +result +_GalleryRenderer::SetEmptyImage(const _GalleryBitmap* pImage) +{ + _GalleryCanvas* pCanvas = GetCanvasManager().GetCanvas(GetEmptyCanvasIndex()); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->SetImage(pImage, GetViewRect(), GALLERY_FITTING_TYPE_NONE); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; + + return E_SUCCESS; +} + +result +_GalleryRenderer::SetEmptyText(const String& pText) +{ + __emptyString = pText; + + return E_SUCCESS; +} + +result +_GalleryRenderer::EnableEmptyView(void) +{ + __showEmptyImage = true; + __needDrawEmptyCanvas = true; + + return E_SUCCESS; +} + +result +_GalleryRenderer::DisableEmptyView(void) +{ + result r = SetCanvasVisibility(GetEmptyCanvasIndex(), false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __showEmptyImage = false; + __needDrawEmptyCanvas = false; + + return E_SUCCESS; +} + +result +_GalleryRenderer::SetCanvasImage(int canvasIndex, const _GalleryBitmap* pImage + , _GalleryVerticalAlignment imageVerticalAlignment, _GalleryHorizontalAlignment imageHorizontalAlignment + , _GalleryFittingType fittingType) +{ + _GalleryCanvas* pCanvas = GetCanvasManager().GetCanvas(canvasIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas->SetImageAlignment(imageVerticalAlignment, imageHorizontalAlignment); + r = pCanvas->SetImage(pImage, GetViewRect(), fittingType); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryRenderer::SetCanvasBounds(int canvasIndex, const Rectangle& bounds, + const _GalleryAnimationTiming* pAnimation) +{ + _GalleryCanvas* pCanvas = GetCanvasManager().GetCanvas(canvasIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _VisualElement& visualElement = pCanvas->GetImageVisualElement(); + _VisualElement& frameVisualElement = pCanvas->GetFrameVisualElement(); + frameVisualElement.SetImplicitAnimationEnabled(false); + + Rectangle canvasVEBounds = pCanvas->GetImageVisualElementBounds(); + FloatMatrix4 endMatrix;// = visualElement.GetTransformMatrix(); + endMatrix.SetAsIdentity(); + +#if 0 + float factor = (float)bounds.width / (float)canvasVEBounds.width; + float translateX = (float)realBounds.x - (float)canvasVEBounds.x; + float translateY = (float)realBounds.y - (float)canvasVEBounds.y; +#else + float translateX = (float)bounds.x; + float translateY = (float)bounds.y; +#endif + + Rectangle viewRect = GetViewRect(); + Rectangle imageBounds = pCanvas->GetOriginalImageBounds(); + if (bounds.width != viewRect.width) + { + float factor = (float)bounds.width / (float)(viewRect.width); + translateX = translateX - (imageBounds.width / 2 + imageBounds.x) + ((imageBounds.width / 2 + imageBounds.x) * factor); + translateY = translateY - (imageBounds.height / 2 + imageBounds.y) + ((imageBounds.height / 2 + imageBounds.y) * factor); + endMatrix.SetAsIdentity(); + _MatrixUtilTranslate(endMatrix, translateX, translateY, 0); + _MatrixUtilScale(endMatrix, factor, factor, 1); + pCanvas->SetCanvasFactor(factor); + pCanvas->SetClippingOfFrameVisualElement(false); + } + else + { + //_MatrixUtilTranslate(endMatrix, translateX, translateY, 0); + pCanvas->SetCanvasFactor(1.0f); + pCanvas->SetClippingOfFrameVisualElement(true); + } + + r = SetCanvasImageBounds(canvasIndex, bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (pAnimation != null) + { + visualElement.SetImplicitAnimationEnabled(true); + frameVisualElement.SetImplicitAnimationEnabled(true); + AddAnimationCount(); + + GetAnimationDelegator().SetGalleryAnimationTiming(*pAnimation); + + r = visualElement.SetTransformMatrix(endMatrix); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + __animationRunning = true; + + pCanvas->SetBounds(bounds); + + visualElement.SetImplicitAnimationEnabled(false); + frameVisualElement.SetImplicitAnimationEnabled(false); + } + else + { + visualElement.RemoveAllAnimations(); + + if (GetAnimationCount() != 0) + { + ResetAnimationCount(); + OnAnimationCancel(); + } + + visualElement.SetImplicitAnimationEnabled(false); + + r = visualElement.SetTransformMatrix(endMatrix); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas->SetBounds(bounds); + } + + FloatPoint anchor; + imageBounds = pCanvas->GetImageBounds(); + anchor.x = (float)(-bounds.x + (GetViewRect().width / 2)) / (float)bounds.width; + anchor.y = (float)(-bounds.y + (GetViewRect().height / 2)) / (float)bounds.height; + pCanvas->SetImageAnchor(anchor); + + return E_SUCCESS; +} + +Rectangle +_GalleryRenderer::GetCanvasBounds(int canvasIndex) const +{ + _GalleryCanvas* pCanvas = GetCanvasManager().GetCanvas(canvasIndex); + SysTryReturn(NID_UI_CTRL, pCanvas != null, Rectangle(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + SetLastResult(E_SUCCESS); + + return pCanvas->GetBounds(); +} + +Rectangle +_GalleryRenderer::GetCanvasAlignBoundary(int canvasIndex) const +{ + _GalleryCanvas* pCanvas = GetCanvasManager().GetCanvas(canvasIndex); + SysTryReturn(NID_UI_CTRL, pCanvas != null, Rectangle(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + SetLastResult(E_SUCCESS); + + Rectangle alignBoundary = pCanvas->GetAlignBoundary(); + if (alignBoundary.width == -1 || alignBoundary.width < GetViewRect().width) + { + alignBoundary = GetViewRect(); + } + + return alignBoundary; +} + +result +_GalleryRenderer::SetCanvasImageBounds(int canvasIndex, const Rectangle& bounds) +{ + _GalleryCanvas* pCanvas = GetCanvasManager().GetCanvas(canvasIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pCanvas->SetImageBounds(bounds); + + return E_SUCCESS; +} + +Rectangle +_GalleryRenderer::GetCanvasImageBounds(int canvasIndex) const +{ + _GalleryCanvas* pCanvas = GetCanvasManager().GetCanvas(canvasIndex); + SysTryReturn(NID_UI_CTRL, pCanvas != null, Rectangle(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + SetLastResult(E_SUCCESS); + + return pCanvas->GetImageBounds(); +} + +result +_GalleryRenderer::RunCanvasTransition(int startCanvasIndex, int endCanvasIndex, _GalleryTransitionType transition, + const _GalleryAnimationTiming* pAnimation) +{ + result r = E_SUCCESS; + ResetAnimationCount(); + + _GalleryCanvas* pCanvas = null; + for (int i = 0; i < GetCanvasManager().GetCanvasCount(); i++) + { + pCanvas = GetCanvasManager().GetCanvas(i); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pCanvas->SetVisibility(false); + } + + pCanvas = GetCanvasManager().GetCanvas(startCanvasIndex); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->SetVisibility(true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas = GetCanvasManager().GetCanvas(endCanvasIndex); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->SetVisibility(true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + switch (transition) + { + case GALLERY_TRANSITION_DISSOLVE: + r = RunDissolveTransition(startCanvasIndex, endCanvasIndex, pAnimation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + break; + case GALLERY_TRANSITION_ZOOM: + r = RunZoomTransition(startCanvasIndex, endCanvasIndex, pAnimation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + break; + case GALLERY_TRANSITION_PAGE: + r = RunPageTransition(startCanvasIndex, endCanvasIndex, pAnimation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + break; + default: + break; + } + //r = RefreshView(); + //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +_GalleryRenderer::StopAllCanvasAnimation(void) +{ + StopAllAnimation(); + + SetLastResult(E_SUCCESS); + return; +} + +bool +_GalleryRenderer::IsRunningCanvasTransition(void) const +{ + bool returnValue = (GetSlideShowPlayType() == GALLERY_SLIDESHOW_NONE && __animationRunning == false); + + return returnValue; +} + +bool +_GalleryRenderer::IsRunningCanvasAnimation(void) const +{ + return __animationRunning; +} + +bool +_GalleryRenderer::IsExposed(void) const +{ + return false; +} + +result +_GalleryRenderer::RefreshView(void) +{ + return GetCanvasManager().GetRootCanvas().RefreshCanvas(); +} + +result +_GalleryRenderer::ReleaseAllCanvasResource(void) +{ + return GetCanvasManager().ReleaseAllCanvasResource(); +} + +result +_GalleryRenderer::ResetAllCanvas(void) +{ + Rectangle viewRect = GetViewRect(); + result r = GetCanvasManager().ResetAllCanvas(viewRect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryRenderer::InitializeCanvasBounds(void) +{ + int canvasCount = GetCanvasManager().GetCanvasCount(); + _GalleryCanvas* pCanvas = null; + Rectangle bounds = GetViewRect(); + result r = E_SUCCESS; + for (int canvasIndex = 0; canvasIndex < canvasCount; canvasIndex++) + { + pCanvas = GetCanvasManager().GetCanvas(canvasIndex); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + //r = pCanvas->SetVisualElementBounds(bounds); + //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->SetVisibility(false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; +} + + +result +_GalleryRenderer::Draw(void) +{ + result r = E_SUCCESS; + if (__showEmptyImage == true) + { + r = ShowEmptyImageAndText(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + SysLog(NID_UI_CTRL, "There is no image in gallery."); + } + else + { + r = GetCanvasManager().LoadAllCanvasImage(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; +} + +void +_GalleryRenderer::GalleryBoundsChanged(int currentCanvasIndex) +{ + _GalleryCanvas* pCanvas = null; + result r = E_SUCCESS; + + pCanvas = GetCanvasManager().GetCanvas(currentCanvasIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + float factor = pCanvas->GetCanvasFactor(); + Rectangle bounds = pCanvas->GetBounds(); + bounds.width *= factor; + bounds.height *= factor; + + if (bounds.width != GetViewRect().width) + { + bounds.x = -(pCanvas->GetImageAnchor().x * bounds.width - GetViewRect().width / 2); + bounds.y = -(pCanvas->GetImageAnchor().y * bounds.height - GetViewRect().height / 2); + + r = pCanvas->GetFrameVisualElement().SetBounds(FloatRectangle(0, 0, bounds.width, bounds.height)); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + pCanvas->SetImageBounds(bounds); + + r = pCanvas->SetBounds(bounds); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + SetLastResult(E_SUCCESS); + return; +} + +void +_GalleryRenderer::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) +{ + _GalleryRendererNotification* pRendererNotifier = new (std::nothrow)_GalleryRendererNotification(GALLERY_RENDERER_NOTI_CANVAS_ANIMATION_STARTED); + SysTryReturnVoidResult(NID_UI_CTRL, pRendererNotifier != null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryRendererNotification."); + GetRendererNotifier().Fire(*pRendererNotifier); +} + +void +_GalleryRenderer::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) +{ + return; +} + +void +_GalleryRenderer::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, + const String& keyName, + VisualElement& target, + bool completedNormally) +{ + _GalleryRendererNotification* pRendererNotifier = null; + + if (completedNormally == true) + { + ReleaseAnimationCount(); + if (GetSlideShowPlayType() == GALLERY_SLIDESHOW_NONE) + { + if (GetAnimationCount() == 0) + { + pRendererNotifier = new (std::nothrow)_GalleryRendererNotification(GALLERY_RENDERER_NOTI_CANVAS_ANIMATION_COMPLETED); + SysTryReturnVoidResult(NID_UI_CTRL, pRendererNotifier != null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryRendererNotification."); + GetRendererNotifier().Fire(*pRendererNotifier); + __animationRunning = false; + } + } + else + { + if (GetAnimationCount() == 0) + { + SetSlideShowPlayType(GALLERY_SLIDESHOW_NONE); + pRendererNotifier = new (std::nothrow)_GalleryRendererNotification(GALLERY_RENDERER_NOTI_TRANSITION_COMPLETED); + SysTryReturnVoidResult(NID_UI_CTRL, pRendererNotifier != null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryRendererNotification."); + + GetRendererNotifier().Fire(*pRendererNotifier); + } + } + } + else + { + if (GetSlideShowPlayType() != GALLERY_SLIDESHOW_NONE) + { + SetSlideShowPlayType(GALLERY_SLIDESHOW_NONE); + pRendererNotifier = new (std::nothrow)_GalleryRendererNotification(GALLERY_RENDERER_NOTI_TRANSITION_CANCEL); + SysTryReturnVoidResult(NID_UI_CTRL, pRendererNotifier != null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryRendererNotification."); + + GetRendererNotifier().Fire(*pRendererNotifier); + } + } + + SetLastResult(E_SUCCESS); + return; +} + +_GalleryRenderer::_GalleryRenderer(void) + : __pControl(null) + , __pCanvasManager(null) + , __pRendererNotifyer(null) + , __pGalleryAnimationDelegator(null) + , __emptyString(L"") + , __emptyCanvasIndex(-1) + , __slideShowAnimationCount(0) + , __slideShowPlayType(GALLERY_SLIDESHOW_NONE) + , __showEmptyImage(true) + , __animationRunning(false) + , __needDrawEmptyCanvas(true) + , __startCanvasOfPageCurling(-1) + , __endCanvasOfPageCurling(-1) + , __pEffect(null) + , __pTransparentBitmap(null) + , __pPageCurlingBitmap(null) +{ + GET_COLOR_CONFIG(GALLERY::EMPTY_GALLERY_TEXT_NORMAL, __emptyTextColor); +} + +_GalleryRenderer::~_GalleryRenderer(void) +{ + + StopAllAnimation(); + + if (GetEffect() != null) + { + EffectManager::DestroyInstance(); + __pEffect = null; + } + + delete __pCanvasManager; + delete __pGalleryAnimationDelegator; + delete __pRendererNotifyer; + delete __pTransparentBitmap; + delete __pPageCurlingBitmap; +} + +result +_GalleryRenderer::Construct(_Control& control) +{ + result r = E_SUCCESS; + _GalleryRendererNotifier* pRendererNotifier = null; + _GalleryCanvasManager* pCanvasManager = null; + _GalleryAnimationProvider* pVEDelegator = null; + Rectangle initialCanvasBounds = control.GetBounds(); + + pRendererNotifier = new (std::nothrow) _GalleryRendererNotifier(); + SysTryCatch(NID_UI_CTRL, pRendererNotifier != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pVEDelegator = new (std::nothrow) _GalleryAnimationProvider(); + SysTryCatch(NID_UI_CTRL, pRendererNotifier != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pCanvasManager = _GalleryCanvasManager::CreateCanvasManagerN(control, GALLERY_CANVAS_INITIAL_MAX_COUNT, initialCanvasBounds, pVEDelegator); + SysTryCatch(NID_UI_CTRL, pCanvasManager != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + SetControl(control); + SetRendererNotifier(*pRendererNotifier); + SetCanvasManager(*pCanvasManager); + SetAnimationDelegator(*pVEDelegator); + + GetAnimationDelegator().SetAnimationDelegator(this); + + return E_SUCCESS; + +CATCH: + delete pRendererNotifier; + delete pVEDelegator; + + return r; +} + +result +_GalleryRenderer::ShowEmptyImageAndText(void) +{ + Canvas* pEmptyCanvas = null; + Dimension textDimension(0, 0); + Font* pFont = null; + TextObject* pTextObject = null; + result r = E_SUCCESS; + + if (__needDrawEmptyCanvas == true) + { + _GalleryCanvas* pEmptyGalleryCanvas = GetCanvasManager().GetCanvas(GetEmptyCanvasIndex()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pEmptyGalleryCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pEmptyGalleryCanvas->SetBounds(GetViewRect()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + // text + if (__emptyString.GetLength() != 0) + { + pFont = GetControl().GetFallbackFont(); + SysTryCatch(NID_UI_CTRL, pFont != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pFont->GetTextExtent(__emptyString, __emptyString.GetLength(), textDimension); + + pTextObject = new (std::nothrow) TextObject; + SysTryCatch(NID_UI_CTRL, pTextObject != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pTextObject->Construct();//(const_cast(__emptyString.GetPointer())), __emptyString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + TextSimple* pSimpleText = new (std::nothrow)TextSimple((const_cast(__emptyString.GetPointer())), __emptyString.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + pTextObject->AppendElement(*pSimpleText); + + pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + pTextObject->SetFont(pFont, 0, pTextObject->GetTextLength()); + textDimension = pTextObject->GetTextExtent(0, pTextObject->GetTextLength()); + if (textDimension.width > GetViewRect().width) + { + textDimension.width = GetViewRect().width; + } + pTextObject->SetForegroundColor(__emptyTextColor, 0, pTextObject->GetTextLength()); + } + + Point imagePosition(0, 0); + Point textPosition(0, 0); + Dimension imageSize(0, 0); + Rectangle visualElementBounds(0, 0, 0, 0); + _GalleryBitmap* pImage = pEmptyGalleryCanvas->GetImage(); + if (pImage != null) + { + imageSize = pImage->GetSize(); + } + + if (imageSize.width >= textDimension.width) + { + visualElementBounds.x = GetViewRect().width - imageSize.width; + visualElementBounds.width = imageSize.width; + if (imageSize.width != textDimension.width) + { + textPosition.x = (imageSize.width - textDimension.width) / 2; + } + } + else + { + visualElementBounds.x = GetViewRect().width - textDimension.width; + visualElementBounds.width = textDimension.width; + imagePosition.x = (textDimension.width - imageSize.width) / 2; + } + visualElementBounds.height = imageSize.height + textDimension.height; + visualElementBounds.y = GetViewRect().height - visualElementBounds.height; + + visualElementBounds.x = visualElementBounds.x / 2; + visualElementBounds.y = visualElementBounds.y / 2; + + pEmptyGalleryCanvas->SetVisualElementBounds(visualElementBounds); + + Rectangle imageBounds(imagePosition.x, imagePosition.y, imageSize.width, imageSize.height); + pEmptyGalleryCanvas->SetImageBounds(imageBounds); + + if (pImage != null || __emptyString.GetLength() != 0) + { + pEmptyCanvas = pEmptyGalleryCanvas->GetImageVisualElement().GetCanvasN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pEmptyCanvas != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + Color color(0, 0, 0, 0); + pEmptyCanvas->SetBackgroundColor(color); + + r = pEmptyCanvas->Clear(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (pImage != null) + { + if (pImage->GetInternalBitmap()->IsNinePatchedBitmap() == true) + { + Dimension size = pImage->GetSize(); + Rectangle rect(imagePosition.x, imagePosition.y, size.width, size.height); + r = pEmptyCanvas->DrawNinePatchedBitmap(rect, *pImage->GetInternalBitmap()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = pEmptyCanvas->DrawBitmap(imagePosition, *pImage->GetInternalBitmap()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + textPosition.y = imageBounds.y + imageBounds.height; + if (pTextObject != null) + { + pTextObject->SetBounds(Rectangle(textPosition.x, textPosition.y, textDimension.width, textDimension.height)); + pTextObject->Draw(*_CanvasImpl::GetInstance(*pEmptyCanvas)); + + delete pTextObject; + pTextObject = null; + } + } + + r = pEmptyGalleryCanvas->GetImageVisualElement().SetFlushNeeded(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pEmptyCanvas; + + r = pEmptyGalleryCanvas->SetVisibility(true); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __needDrawEmptyCanvas = false; + } + + return E_SUCCESS; + +CATCH: + delete pTextObject; + delete pEmptyCanvas; + + return r; +} + +result +_GalleryRenderer::RunDissolveTransition(int startCanvasIndex, int endCanvasIndex, const _GalleryAnimationTiming* pAnimation) +{ + SysTryReturn(NID_UI_CTRL, pAnimation != null, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The gallery animation timing is null"); + + Rectangle viewBounds = GetViewRect(); + result r = SetCanvasBounds(endCanvasIndex, viewBounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _GalleryCanvas* pStartCanvas = GetCanvasManager().GetCanvas(startCanvasIndex); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pStartCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _GalleryCanvas* pEndCanvas = GetCanvasManager().GetCanvas(endCanvasIndex); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pEndCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _VisualElement& startVisualElement = pStartCanvas->GetFrameVisualElement(); + r = startVisualElement.SetZOrder(&pEndCanvas->GetFrameVisualElement(), true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + startVisualElement.SetImplicitAnimationEnabled(true); + + GetAnimationDelegator().SetGalleryAnimationTiming(*pAnimation); + startVisualElement.SetOpacity(0.0f); + AddAnimationCount(); + + startVisualElement.SetImplicitAnimationEnabled(false); + + pEndCanvas->GetFrameVisualElement().SetOpacity(0.0f); + + pEndCanvas->GetFrameVisualElement().SetImplicitAnimationEnabled(true); + + pEndCanvas->GetFrameVisualElement().SetOpacity(1.0f); + //AddAnimationCount(); + + pEndCanvas->GetFrameVisualElement().SetImplicitAnimationEnabled(false); + + SetSlideShowPlayType(GALLERY_SLIDESHOW_DISSOLVE); + + return E_SUCCESS; +} + +result +_GalleryRenderer::RunZoomTransition(int startCanvasIndex, int endCanvasIndex, const _GalleryAnimationTiming* pAnimation) +{ + result r = RunDissolveTransition(startCanvasIndex, endCanvasIndex, pAnimation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Rectangle viewRect = GetViewRect(); + Rectangle zoomBounds = viewRect; + zoomBounds.width *= GALLERY_ZOOM_TRANSITION_ZOOM_FACTOR; + zoomBounds.height *= GALLERY_ZOOM_TRANSITION_ZOOM_FACTOR; + zoomBounds.x = -(viewRect.width / 2 * (GALLERY_ZOOM_TRANSITION_ZOOM_FACTOR - 1)); + zoomBounds.y = -(viewRect.height / 2 * (GALLERY_ZOOM_TRANSITION_ZOOM_FACTOR - 1)); + + r = SetCanvasBounds(startCanvasIndex, zoomBounds, pAnimation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + //AddAnimationCount(); + + SetSlideShowPlayType(GALLERY_SLIDESHOW_ZOOM); + + return E_SUCCESS; +} + +result +_GalleryRenderer::RunPageTransition(int startCanvasIndex, int endCanvasIndex, const _GalleryAnimationTiming* pAnimation) +{ + SysTryReturn(NID_UI_CTRL, pAnimation != null, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The gallery animation timing is null"); + + result r = E_SUCCESS; + if (GetEffect() == null) + { + Effect* pEffect = EffectManager::GetInstance()->CreateEffect(L"/usr/share/osp/effects/gallery_page_curling.eff"); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _GalleryImpl* pImpl = static_cast<_GalleryImpl*>(__pControl->GetUserData()); + Gallery& pPublic = pImpl->GetPublic(); + r = pEffect->SetRenderTarget(&pPublic); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetEffect(pEffect); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + SetStartCanvasOfPageCurling(startCanvasIndex); + SetEndCanvasOfPageCurling(endCanvasIndex); + + r = SetCanvasBounds(startCanvasIndex, GetViewRect()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetCanvasVisibility(startCanvasIndex, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetCanvasVisibility(endCanvasIndex, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pEffect->Start(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + //AddAnimationCount(); + + SetSlideShowPlayType(GALLERY_SLIDESHOW_PAGE); + + return E_SUCCESS; +} + +void +_GalleryRenderer::OnAnimationCancel(void) +{ + _GalleryRendererNotification* pRendererNoti = new (std::nothrow)_GalleryRendererNotification(GALLERY_RENDERER_NOTI_CANVAS_ANIMATION_CANCEL); + SysTryReturnVoidResult(NID_UI_CTRL, pRendererNoti != null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryRendererNotification."); + + GetRendererNotifier().Fire(*pRendererNoti); + + SetLastResult(E_SUCCESS); + return; +} + +void +_GalleryRenderer::SetControl(_Control& control) +{ + __pControl = &control; + return; +} + +_Control& +_GalleryRenderer::GetControl(void) const +{ + return *__pControl; +} + +void +_GalleryRenderer::SetCanvasManager(_GalleryCanvasManager& canvasManager) +{ + __pCanvasManager = &canvasManager; + return; +} + +_GalleryCanvasManager& +_GalleryRenderer::GetCanvasManager(void) const +{ + return (_GalleryCanvasManager&)*__pCanvasManager; +} + +void +_GalleryRenderer::SetRendererNotifier(_GalleryRendererNotifier& rendererNotifier) +{ + __pRendererNotifyer = &rendererNotifier; + return; +} + +_GalleryRendererNotifier& +_GalleryRenderer::GetRendererNotifier(void) const +{ + return (_GalleryRendererNotifier&)*__pRendererNotifyer; +} + +void +_GalleryRenderer::SetAnimationDelegator(_GalleryAnimationProvider& galleryVEDelegator) +{ + __pGalleryAnimationDelegator = &galleryVEDelegator; + return; +} + +_GalleryAnimationProvider& +_GalleryRenderer::GetAnimationDelegator(void) const +{ + return *__pGalleryAnimationDelegator; +} + +void +_GalleryRenderer::SetEmptyCanvasIndex(int emptyCanvasIndex) +{ + __emptyCanvasIndex = emptyCanvasIndex; + return; +} + +int +_GalleryRenderer::GetEmptyCanvasIndex(void) const +{ + return __emptyCanvasIndex; +} + +void +_GalleryRenderer::SetSlideShowPlayType(_GallerySlideShowType slideShowType) +{ + __slideShowPlayType = slideShowType; + return; +} + +_GallerySlideShowType +_GalleryRenderer::GetSlideShowPlayType(void) const +{ + return __slideShowPlayType; +} + +void +_GalleryRenderer::AddAnimationCount(void) +{ + __slideShowAnimationCount++; + return; +} + +void +_GalleryRenderer::ReleaseAnimationCount(void) +{ + __slideShowAnimationCount--; + return; +} + +void +_GalleryRenderer::ResetAnimationCount(void) +{ + __slideShowAnimationCount = 0; + return; +} + +int +_GalleryRenderer::GetAnimationCount(void) const +{ + return __slideShowAnimationCount; +} + +void +_GalleryRenderer::StopAllAnimation(void) +{ + _GalleryCanvas* pCanvas = null; + int canvasCount = GetCanvasManager().GetCanvasCount(); + result r = E_SUCCESS; + for (int i = 0; i < canvasCount; i++) + { + pCanvas = GetCanvasManager().GetCanvas(i); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas->GetImageVisualElement().RemoveAllAnimations(); + pCanvas->GetFrameVisualElement().RemoveAllAnimations(); + } + + Canvas* pRootCanvas = null; + if (__pEffect != null) + { + if (__pEffect->IsRunning() == true) + { + r = __pEffect->Stop(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + EffectManager::DestroyInstance(); + __pEffect = null; + + pRootCanvas = GetCanvasManager().GetRootCanvas().GetImageVisualElement()->GetCanvasN(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pRootCanvas != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pRootCanvas->SetBackgroundColor(GetCanvasManager().GetRootCanvas().GetBackgroundColor()); + r = pRootCanvas->Clear(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pRootCanvas; + } + ResetAnimationCount(); + + SetLastResult(E_SUCCESS); + return; + +CATCH: + if (__pEffect != null) + { + EffectManager::DestroyInstance(); + __pEffect = null; + } + + delete pRootCanvas; +} + +// 3d effect listener +void +_GalleryRenderer::OnEffectStarted(Effect& effect) +{ +} + +void +_GalleryRenderer::OnEffectFinished(Effect& effect, EffectResult effectResult, const IList& lastShownBitmapIds) +{ + Rectangle viewBounds = GetViewRect(); + int endCanvasIndex = GetEndCanvasOfPageCurling(); + result r = SetCanvasBounds(endCanvasIndex, viewBounds); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetCanvasVisibility(endCanvasIndex, true); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + int startCanvasIndex = GetStartCanvasOfPageCurling(); + r = SetCanvasVisibility(startCanvasIndex, false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pTransparentBitmap; + __pTransparentBitmap = null; + + delete __pPageCurlingBitmap; + __pPageCurlingBitmap = null; + + _GalleryRendererNotification* pRendererNotifier = null; + if (effectResult == EFFECT_RESULT_FINISHED) + { + pRendererNotifier = new (std::nothrow)_GalleryRendererNotification(GALLERY_RENDERER_NOTI_TRANSITION_COMPLETED); + SysTryReturnVoidResult(NID_UI_CTRL, pRendererNotifier != null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryRendererNotification."); + } + else + { + pRendererNotifier = new (std::nothrow)_GalleryRendererNotification(GALLERY_RENDERER_NOTI_TRANSITION_CANCEL); + SysTryReturnVoidResult(NID_UI_CTRL, pRendererNotifier != null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Failed to allocate the memory for the _GalleryRendererNotification."); + } + + GetRendererNotifier().Fire(*pRendererNotifier); + SetSlideShowPlayType(GALLERY_SLIDESHOW_NONE); + ResetAnimationCount(); +} + +// 3d effect provider +result +_GalleryRenderer::SetBitmap(Effect& effect, long bitmapId) +{ + int startCanvasIndex = GetStartCanvasOfPageCurling(); + int endCanvasIndex = GetEndCanvasOfPageCurling(); + + _GalleryCanvas* pStartCanvas = GetCanvasManager().GetCanvas(startCanvasIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pStartCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _GalleryCanvas* pEndCanvas = GetCanvasManager().GetCanvas(endCanvasIndex); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pEndCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (bitmapId == 0) + { + Canvas pageCurlingCanvas; + r = pageCurlingCanvas.Construct(GetViewRect()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pageCurlingCanvas.SetBackgroundColor(__pControl->GetBackgroundColor()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pageCurlingCanvas.Clear(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Rectangle imageBounds = pStartCanvas->GetImageBounds(); + r = pageCurlingCanvas.DrawBitmap(imageBounds, *pStartCanvas->GetImage()->GetInternalBitmap()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPageCurlingBitmap = new (std::nothrow) Bitmap(); + SysTryReturn(NID_UI_CTRL, __pPageCurlingBitmap != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pPageCurlingBitmap->Construct(pageCurlingCanvas, GetViewRect()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + effect.SetBitmap(bitmapId, *__pPageCurlingBitmap); + } + else if (bitmapId == 1) + { + Canvas transparentCanvas; + r = transparentCanvas.Construct(GetViewRect()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + transparentCanvas.SetBackgroundColor(__pControl->GetBackgroundColor()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = transparentCanvas.Clear(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Rectangle imageBounds = pEndCanvas->GetImageBounds(); + r = transparentCanvas.DrawBitmap(imageBounds, *pEndCanvas->GetImage()->GetInternalBitmap()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTransparentBitmap = new (std::nothrow) Bitmap(); + SysTryReturn(NID_UI_CTRL, __pTransparentBitmap != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pTransparentBitmap->Construct(transparentCanvas, GetViewRect()); + + //r = __pTransparentBitmap->Construct(viewBounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + effect.SetBitmap(bitmapId, *__pTransparentBitmap); + } + + return E_SUCCESS; +} + +void +_GalleryRenderer::SetStartCanvasOfPageCurling(int startCanvasIndex) +{ + __startCanvasOfPageCurling = startCanvasIndex; +} + +int +_GalleryRenderer::GetStartCanvasOfPageCurling(void) +{ + return __startCanvasOfPageCurling; +} + +void +_GalleryRenderer::SetEndCanvasOfPageCurling(int endCanvasIndex) +{ + __endCanvasOfPageCurling = endCanvasIndex; +} + +int +_GalleryRenderer::GetEndCanvasOfPageCurling(void) +{ + return __endCanvasOfPageCurling; +} + +void +_GalleryRenderer::SetEffect(Effect* pEffect) +{ + SysTryReturnVoidResult(NID_UI_CTRL, pEffect != null, E_INVALID_ARG, "[E_INVALID_ARG] The effect object is null."); + + pEffect->SetEffectEventListener(this); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + pEffect->SetResourceProvider(this); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pEffect = pEffect; + + SetLastResult(E_SUCCESS); +} + +Tizen::Ui::Effects::Effect* +_GalleryRenderer::GetEffect(void) +{ + return __pEffect; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_GalleryRendererNotifier.cpp b/src/ui/controls/FUiCtrl_GalleryRendererNotifier.cpp new file mode 100644 index 0000000..3ed93d5 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryRendererNotifier.cpp @@ -0,0 +1,70 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include "FUiCtrl_GalleryRendererNotifier.h" +#include "FUiCtrl_GalleryRendererNotification.h" +#include "FUiCtrl_IGalleryRendererNotiListener.h" + + +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryRendererNotifier::_GalleryRendererNotifier(void) +{ + // Do nothing +} + +_GalleryRendererNotifier::~_GalleryRendererNotifier(void) +{ + // Do nothing +} + +void +_GalleryRendererNotifier::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _IGalleryRendererNotiListener* pRendererNotiListener = dynamic_cast<_IGalleryRendererNotiListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pRendererNotiListener != null, E_INVALID_ARG, "[E_INVALID_ARG] IEventListener is invalid listener."); + + const _GalleryRendererNotification& rendererNotification = static_cast(arg); + + switch (rendererNotification.GetNotificationType()) + { + case GALLERY_RENDERER_NOTI_TRANSITION_CANCEL: + pRendererNotiListener->OnTransitionCancel(); + break; + case GALLERY_RENDERER_NOTI_TRANSITION_COMPLETED: + pRendererNotiListener->OnTransitionCompleted(); + break; + case GALLERY_RENDERER_NOTI_CANVAS_ANIMATION_CANCEL: + pRendererNotiListener->OnCanvasAnimationCancel(); + break; + case GALLERY_RENDERER_NOTI_CANVAS_ANIMATION_COMPLETED: + pRendererNotiListener->OnCanvasAnimationCompleted(); + break; + case GALLERY_RENDERER_NOTI_CANVAS_ANIMATION_STARTED: + pRendererNotiListener->OnCanvasAnimationStarted(); + break; + default: + SysTryReturnVoidResult(NID_UI_CTRL, false, E_INVALID_ARG, "[E_INVALID_ARG] The notification type is invalid."); + break; + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryViewEvent.cpp b/src/ui/controls/FUiCtrl_GalleryViewEvent.cpp new file mode 100644 index 0000000..6af9868 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryViewEvent.cpp @@ -0,0 +1,47 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include "FUiCtrl_GalleryViewEvent.h" +#include "FUiCtrl_GalleryViewEventInfo.h" + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryViewEvent::_GalleryViewEvent(GalleryViewEventType eventType, _GalleryViewEventInfo* eventInfo) + : __eventType(eventType) + , __pEventInfo(eventInfo) +{ + // Do nothing +} + +_GalleryViewEvent::~_GalleryViewEvent(void) +{ + // Do nothing +} + +GalleryViewEventType +_GalleryViewEvent::GetEventType(void) const +{ + return __eventType; +} + +_GalleryViewEventInfo* +_GalleryViewEvent::GetEventInfo(void) const +{ + return __pEventInfo; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_GalleryViewEventHandler.cpp b/src/ui/controls/FUiCtrl_GalleryViewEventHandler.cpp new file mode 100644 index 0000000..b744835 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryViewEventHandler.cpp @@ -0,0 +1,1100 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include "FUiCtrl_GalleryImageReader.h" +#include "FUiCtrl_GalleryPresenter.h" +#include "FUiCtrl_GalleryViewEventInfo.h" +#include "FUiCtrl_GalleryViewEventHandler.h" +#include "FUiCtrl_IGalleryRenderer.h" + + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls { + +namespace +{ + const int FLICK_ANIMATION_DURATION = 500; + const int ALIGH_ANIMATION_DURATION = 1000; + const int ZOOM_ANIMATION_DURATION = 1000; + const int PINCH_ZOOM_ANIMATION_DURATION = 500; + const int DOUBLE_PRESSE_ZOOM_DISTANCE = 1000; + const int FLICK_MOVE_ANIMATION_DURATION = 500; + const int FLICK_MOVE_DISTANCE = 200; + const float MAX_ZOOM_RATIO = 3.0; + const float MIN_ZOOM_RATIO = 0.3; + const int NO_CHANGE_ITEM_INDEX = -1; +} + +_GalleryViewEventHandler::_GalleryViewEventHandler(_GalleryPresenter& presenter, _IGalleryRenderer& galleryRenderer, + _GalleryImageReader& galleryImageReader) + : __galleryPresenter(presenter) + , __galleryRenderer(galleryRenderer) + , __galleryImageReader(galleryImageReader) + , __previousPosition(0, 0) + , __startPinchCenterPosition(0, 0) + , __flickingDirection(FLICK_DIRECTION_NONE) + , __pinchInitialArea(0) + , __pressed(false) + , __moving(false) + , __zoomMode(false) + , __zoomAnimationComplete(true) + , __pinchMode(false) + , __touchPointId(0) + , __currentItemIndex(NO_CHANGE_ITEM_INDEX) +{ + // Do nothing. +} + +_GalleryViewEventHandler::~_GalleryViewEventHandler(void) +{ + // Do nothing. +} + +result +_GalleryViewEventHandler::Construct(void) +{ + return __galleryRenderer.AddNotiListener(*this); +} + +bool +_GalleryViewEventHandler::OnTouchPressed(_GalleryViewEventInfo& eventInfo) +{ + SysTryReturn(NID_UI_CTRL, __pressed == false, true, E_SYSTEM, "[E_SYSTEM] Already pressed state."); + result r = SetVisibleCanvas(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pressed = true; + __previousPosition.SetPosition(eventInfo.GetCurrentPosition()); + + __touchPointId = eventInfo.GetPointId(); + + //SetLastResult(E_SUCCESS); + + return true; + +CATCH: + SetRollbackCanvas(); + return true; +} + +bool +_GalleryViewEventHandler::OnTouchDoublePressed(_GalleryViewEventInfo& eventInfo) +{ + _GalleryAnimationTiming animation = {ZOOM_ANIMATION_DURATION, GALLERY_ANIMATION_TIMING_FUNC_EASEOUT}; + Point center; + int distance = DOUBLE_PRESSE_ZOOM_DISTANCE; + if (__zoomMode == false) + { + center = __previousPosition; + __zoomMode = true; + } + else + { + Rectangle viewRect = __galleryRenderer.GetViewRect(); + center.SetPosition(viewRect.width / 2, viewRect.height / 2); + __zoomMode = false; + int currentCanvasIndex = __galleryPresenter.SearchCanvasIndex(__galleryPresenter.GetCurrentItemIndex()); + Rectangle canvasRect = __galleryRenderer.GetCanvasBounds(currentCanvasIndex); + distance = canvasRect.width - viewRect.width; + } + result r = ZoomCanvas(distance, center, __zoomMode, &animation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + __zoomAnimationComplete = false; + __pressed = false; + + r = RefreshView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + //SetLastResult(E_SUCCESS); + + return true; +} + +bool +_GalleryViewEventHandler::OnTouchMoved(_GalleryViewEventInfo& eventInfo) +{ + if (__pinchMode == true || __touchPointId != eventInfo.GetPointId()) + { + return true; + } + + Dimension distance; + distance.width = __previousPosition.x - eventInfo.GetCurrentPosition().x; + distance.height = __previousPosition.y - eventInfo.GetCurrentPosition().y; + + result r = MoveCanvas(distance); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = RefreshView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + __previousPosition.SetPosition(eventInfo.GetCurrentPosition()); + + //SetLastResult(E_SUCCESS); + + return true; +} + +bool +_GalleryViewEventHandler::OnTouchReleased(_GalleryViewEventInfo& eventInfo) +{ + result r = E_SUCCESS; + bool itemClickedSuccess = true; + if (__pressed == true) + { + if (__moving == true) + { + r = AlignCanvas(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + __moving = false; + } + else + { + itemClickedSuccess = __galleryPresenter.ClickedItem(); + } + __pressed = false; + } + + if (__pinchMode == true) + { + Rectangle viewRect = __galleryRenderer.GetViewRect(); + + int currentCanvasIndex = __galleryPresenter.SearchCanvasIndex(__galleryPresenter.GetCurrentItemIndex()); + Rectangle canvasRect = __galleryRenderer.GetCanvasBounds(currentCanvasIndex); + int distance = canvasRect.width - viewRect.width; + + if (distance < 0) + { + Point center(viewRect.width / 2, viewRect.height / 2); + _GalleryAnimationTiming animation = {PINCH_ZOOM_ANIMATION_DURATION, GALLERY_ANIMATION_TIMING_FUNC_EASEOUT}; + r = ZoomCanvas(distance, center, false, &animation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + //__zoomMode = false; + } + + r = AlignCanvas(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + __pinchInitialArea = 0; + __startPinchCenterPosition.SetPosition(0, 0); + __pinchMode = false; + } + + r = RefreshView(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + __flickingDirection = FLICK_DIRECTION_NONE; + + //SetLastResult(E_SUCCESS); + + return true; + +CATCH: + SetRollbackCanvas(); + __moving = false; + __pressed = false; + __pinchInitialArea = 0; + __pinchMode = false; + __flickingDirection = FLICK_DIRECTION_NONE; + return true; +} + +bool +_GalleryViewEventHandler::OnTouchPinchZoom(_GalleryViewEventInfo& eventInfo) +{ + if (__galleryPresenter.IsZoomingEnabled() == false) + { + return true; + } + + if (__moving == true) + { + return true; + } + + Point center = eventInfo.GetPinchCenterPosition(); + int currentCanvasIndex = __galleryPresenter.SearchCanvasIndex(__galleryPresenter.GetCurrentItemIndex()); + Rectangle canvasRect = __galleryRenderer.GetCanvasBounds(currentCanvasIndex); + Rectangle viewRect = __galleryRenderer.GetViewRect(); + + int area = eventInfo.GetPinchArea(); + + if (__pinchInitialArea == 0) + { + __pinchInitialArea = area; + area = 0; + } + else + { + area -= __pinchInitialArea; + __pinchInitialArea += area; + } + + //__zoomMode = true; + __pinchMode = true; + bool zoomIn = true; + if (area < 0) + { + zoomIn = false; + area = -area; + } + + if (__startPinchCenterPosition.x == 0 && __startPinchCenterPosition.y == 0) + { + float factor = (float)canvasRect.width / (float)viewRect.width; + __startPinchCenterPosition = center; + __startPinchCenterPosition.x = CalculateRound((__startPinchCenterPosition.x - canvasRect.x) / factor); + __startPinchCenterPosition.y = CalculateRound((__startPinchCenterPosition.y - canvasRect.y) / factor); + } + + //_GalleryAnimationTiming animation = {PINCH_ZOOM_ANIMATION_DURATION, GALLERY_ANIMATION_TIMING_FUNC_EASEOUT}; + //result r = ZoomCanvas(area, center, zoomIn, &animation); + result r = PinchZoomCanvas(area, center, zoomIn); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pressed = false; //??? + r = RefreshView(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return true; +} + +bool +_GalleryViewEventHandler::OnTouchFlicked(_GalleryViewEventInfo& eventInfo) +{ + if (__pinchMode == true) + { + return true; + } + + result r = E_SUCCESS; + if (__zoomMode == false) + { + if (eventInfo.GetFlickPosition().x > 0) + { + r = FlickToTheRight(); + } + else if (eventInfo.GetFlickPosition().x < 0) + { + r = FlickToTheLeft(); + } + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + _GalleryAnimationTiming animation = {FLICK_MOVE_ANIMATION_DURATION, GALLERY_ANIMATION_TIMING_FUNC_EASEOUT}; + + int moveX = 0; + int moveY = 0; + if (eventInfo.GetFlickPosition().x > 0) + { + moveX = -FLICK_MOVE_DISTANCE; + } + else + { + moveX = FLICK_MOVE_DISTANCE; + } + + if (eventInfo.GetFlickPosition().y > 0) + { + moveY = -FLICK_MOVE_DISTANCE; + } + else + { + moveY = FLICK_MOVE_DISTANCE; + } + + Dimension dim(moveX, moveY); + r = MoveCanvas(dim, &animation); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = RefreshView(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + //SetLastResult(E_SUCCESS); + + return true; + +CATCH: + SetRollbackCanvas(); + + return true; +} + +void +_GalleryViewEventHandler::OnTransitionCancel(void) +{ +} + +void +_GalleryViewEventHandler::OnTransitionCompleted(void) +{ +} + +void +_GalleryViewEventHandler::OnCanvasAnimationCancel(void) +{ + __zoomAnimationComplete = true; + __flickingDirection = FLICK_DIRECTION_NONE; + result r = CallChangeItemIndex(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = RefreshView(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + //SetLastResult(E_SUCCESS); +} + +void +_GalleryViewEventHandler::OnCanvasAnimationCompleted(void) +{ + result r = E_SUCCESS; + + if (__zoomAnimationComplete == false) + { + r = AlignCanvas(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + __zoomAnimationComplete = true; + } + + if (__zoomMode == true) + { + r = AlignCanvas(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryPresenter.SetPartialCanvasImage(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + __flickingDirection = FLICK_DIRECTION_NONE; + + r = CallChangeItemIndex(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = RefreshView(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + //SetLastResult(E_SUCCESS); +} + +void +_GalleryViewEventHandler::OnCanvasAnimationStarted(void) +{ + +} + +void +_GalleryViewEventHandler::SetZoomFlag(bool zoomMode) +{ + __zoomMode = zoomMode; +} + +bool +_GalleryViewEventHandler::IsZoomFlag(void) const +{ + return __zoomMode; +} + +result +_GalleryViewEventHandler::RefreshView(void) +{ + return __galleryRenderer.RefreshView(); +} + +result +_GalleryViewEventHandler::SetVisibleCanvas(void) +{ + int currentItemIndex = __galleryPresenter.GetCurrentItemIndex(); + SysTryReturn(NID_UI_CTRL, currentItemIndex >= 0 && currentItemIndex < __galleryPresenter.GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] This value(%d) is out of range(%d ~ %d)", currentItemIndex, 0, __galleryPresenter.GetItemCount()); + + Rectangle viewRect = __galleryRenderer.GetViewRect(); + Rectangle rect = viewRect; + + // current item + int currentCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex); + result r = E_SUCCESS; + if (currentCanvasIndex == NOT_EXIST_CANVAS) + { + r = __galleryPresenter.SetCanvasImage(currentItemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (__zoomMode == false) + { + r = __galleryRenderer.SetCanvasBounds(currentCanvasIndex, rect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + Rectangle currentCanvasRect = __galleryRenderer.GetCanvasBounds(currentCanvasIndex); + r = __galleryRenderer.SetCanvasBounds(currentCanvasIndex, currentCanvasRect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __galleryRenderer.SetCanvasVisibility(currentCanvasIndex, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Rectangle currentCanvasAlignBoundary = __galleryRenderer.GetCanvasAlignBoundary(currentCanvasIndex); + // left item + if (currentItemIndex - 1 >= 0 && currentItemIndex - 1 < __galleryPresenter.GetItemCount()) + { + int leftCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex - 1); + if (leftCanvasIndex == NOT_EXIST_CANVAS) + { + r = __galleryPresenter.SetCanvasImage(currentItemIndex - 1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + leftCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex - 1); + SysTryReturn(NID_UI_CTRL, leftCanvasIndex != NOT_EXIST_CANVAS, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + rect = viewRect; + rect.x = currentCanvasAlignBoundary.x - viewRect.width - __galleryPresenter.GetItemSpacing(); + r = __galleryRenderer.SetCanvasBounds(leftCanvasIndex, rect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasVisibility(leftCanvasIndex, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + // right item + if (currentItemIndex + 1 >= 0 && currentItemIndex + 1 < __galleryPresenter.GetItemCount()) + { + int rightCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex + 1); + if (rightCanvasIndex == NOT_EXIST_CANVAS) + { + r = __galleryPresenter.SetCanvasImage(currentItemIndex + 1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + rightCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex + 1); + SysTryReturn(NID_UI_CTRL, rightCanvasIndex != NOT_EXIST_CANVAS, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + rect = viewRect; + rect.x = currentCanvasAlignBoundary.x + currentCanvasAlignBoundary.width + __galleryPresenter.GetItemSpacing(); + r = __galleryRenderer.SetCanvasBounds(rightCanvasIndex, rect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasVisibility(rightCanvasIndex, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; +} + +result +_GalleryViewEventHandler::SetInvisibleCanvas(void) +{ + int currentItemIndex = __galleryPresenter.GetCurrentItemIndex(); + SysTryReturn(NID_UI_CTRL, currentItemIndex >= 0 && currentItemIndex < __galleryPresenter.GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] This value(%d) is out of range(%d ~ %d)", currentItemIndex, 0, __galleryPresenter.GetItemCount()); + + int leftCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex - 1); + int rightCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex + 1); + + result r = E_SUCCESS; + if (leftCanvasIndex != NOT_EXIST_CANVAS) + { + r = __galleryRenderer.SetCanvasVisibility(leftCanvasIndex, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + if (rightCanvasIndex != NOT_EXIST_CANVAS) + { + r = __galleryRenderer.SetCanvasVisibility(rightCanvasIndex, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; +} + +result +_GalleryViewEventHandler::FlickToTheRight(void) +{ + result r = E_SUCCESS; + Rectangle viewRect = __galleryRenderer.GetViewRect(); + Rectangle rect = viewRect; + int currentItemIndex = __galleryPresenter.GetCurrentItemIndex(); + int leftCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex - 1); + + __flickingDirection = FLICK_DIRECTION_RIGHT; + if (leftCanvasIndex == NOT_EXIST_CANVAS) + { + if (currentItemIndex - 1 < 0) + { + return E_SUCCESS; + } + else + { + r = __galleryPresenter.SetCanvasImage(currentItemIndex - 1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + leftCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex - 1); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, leftCanvasIndex != NOT_EXIST_CANVAS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + rect.x = viewRect.x - viewRect.width - __galleryPresenter.GetItemSpacing(); + r = __galleryRenderer.SetCanvasBounds(leftCanvasIndex, rect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasVisibility(leftCanvasIndex, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + int currentCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex); + int rightCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex + 1); + + _GalleryAnimationTiming animation = {FLICK_ANIMATION_DURATION, GALLERY_ANIMATION_TIMING_FUNC_EASEOUT}; + + rect.x = viewRect.x + viewRect.width + __galleryPresenter.GetItemSpacing(); + r = __galleryRenderer.SetCanvasBounds(currentCanvasIndex, rect, &animation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + rect.x = viewRect.x; + r = __galleryRenderer.SetCanvasBounds(leftCanvasIndex, rect, &animation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (rightCanvasIndex != NOT_EXIST_CANVAS) + { + rect.x = viewRect.x + viewRect.width * 2 + __galleryPresenter.GetItemSpacing(); + r = __galleryRenderer.SetCanvasBounds(rightCanvasIndex, rect, &animation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = SetCurrentItemIndex(__galleryPresenter.GetCurrentItemIndex() - 1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryViewEventHandler::FlickToTheLeft(void) +{ + result r = E_SUCCESS; + Rectangle viewRect = __galleryRenderer.GetViewRect(); + Rectangle rect = viewRect; + int currentItemIndex = __galleryPresenter.GetCurrentItemIndex(); + int rightCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex + 1); + + __flickingDirection = FLICK_DIRECTION_LEFT; + if (rightCanvasIndex == NOT_EXIST_CANVAS) + { + if (currentItemIndex + 1 >= __galleryPresenter.GetItemCount()) + { + return E_SUCCESS; + } + else + { + r = __galleryPresenter.SetCanvasImage(currentItemIndex + 1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + rightCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex + 1); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, rightCanvasIndex != NOT_EXIST_CANVAS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + rect.x = viewRect.x + viewRect.width + __galleryPresenter.GetItemSpacing(); + r = __galleryRenderer.SetCanvasBounds(rightCanvasIndex, rect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasVisibility(rightCanvasIndex, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + int currentCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex); + int leftCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex - 1); + _GalleryAnimationTiming animation = {FLICK_ANIMATION_DURATION, GALLERY_ANIMATION_TIMING_FUNC_EASEOUT}; + + rect.x = viewRect.x - viewRect.width - __galleryPresenter.GetItemSpacing(); + r = __galleryRenderer.SetCanvasBounds(currentCanvasIndex, rect, &animation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + rect.x = viewRect.x; + r = __galleryRenderer.SetCanvasBounds(rightCanvasIndex, rect, &animation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (leftCanvasIndex != NOT_EXIST_CANVAS) + { + rect.x = viewRect.x - viewRect.width * 2 - __galleryPresenter.GetItemSpacing(); + r = __galleryRenderer.SetCanvasBounds(leftCanvasIndex, rect, &animation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = SetCurrentItemIndex(__galleryPresenter.GetCurrentItemIndex() + 1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_GalleryViewEventHandler::ZoomCanvas(int distance, const Point& center, bool zoomIn, _GalleryAnimationTiming* pAnimation) +{ + if (__galleryPresenter.IsZoomingEnabled() == false || distance == 0) + { + __zoomMode = false; + return E_SUCCESS; + } + + int currentItemIndex = __galleryPresenter.GetCurrentItemIndex(); + int currentCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex); + if (__galleryRenderer.IsCanvasVisibility(currentCanvasIndex) == false) + { + result r = __galleryRenderer.SetCanvasVisibility(currentCanvasIndex, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + Rectangle canvasBounds = __galleryRenderer.GetCanvasBounds(currentCanvasIndex); + Rectangle imageBounds = __galleryRenderer.GetCanvasImageBounds(currentCanvasIndex); + Rectangle viewBounds = __galleryRenderer.GetViewRect(); + float factor = 1.0; + if (zoomIn == true) + { + factor = (float)(canvasBounds.width + distance) / (float)viewBounds.width; + canvasBounds.width = factor * viewBounds.width; + canvasBounds.height = factor * viewBounds.height; + canvasBounds.x = -(center.x * factor - viewBounds.width / 2); + canvasBounds.y = -(center.y * factor - viewBounds.height/ 2); + + imageBounds.x *= factor; + imageBounds.y *= factor; + imageBounds.width *= factor; + imageBounds.height *= factor; + + CorrectCanvasPosition(canvasBounds, imageBounds); + } + else + { + canvasBounds = viewBounds; + } + + result r = __galleryRenderer.SetCanvasBounds(currentCanvasIndex, canvasBounds, pAnimation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (canvasBounds.width > viewBounds.width) + { + __zoomMode = true; + } + else + { + __zoomMode = false; + } + + return E_SUCCESS; +} + +result +_GalleryViewEventHandler::PinchZoomCanvas(int area, const Point& center, bool zoomIn) +{ + if (__galleryPresenter.IsZoomingEnabled() == false || area == 0 || + __startPinchCenterPosition.x == 0 || __startPinchCenterPosition.y == 0) + { + return E_SUCCESS; + } + + int currentItemIndex = __galleryPresenter.GetCurrentItemIndex(); + int currentCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex); + + Rectangle bounds = __galleryRenderer.GetCanvasBounds(currentCanvasIndex); + Rectangle viewBounds = __galleryRenderer.GetViewRect(); + + float factor = 1.0f; + if (zoomIn == true) + { + factor = (float)(bounds.width + area) / (float)viewBounds.width; + if (factor > MAX_ZOOM_RATIO) + { + factor = MAX_ZOOM_RATIO; + } + } + else + { + factor = (float)(bounds.width - area) / (float)viewBounds.width; + if (factor < MIN_ZOOM_RATIO) + { + factor = MIN_ZOOM_RATIO; + } + } + + bounds.width = CalculateRound(factor * viewBounds.width); + if (bounds.width < 1) + { + bounds.width = 1; + } + + bounds.height = CalculateRound(factor * viewBounds.height); + if (bounds.height < 1) + { + bounds.height = 1; + } + + if (bounds.width > viewBounds.width || bounds.height > viewBounds.height) + { + bounds.x = center.x - CalculateRound(__startPinchCenterPosition.x * factor); + bounds.y = center.y - CalculateRound(__startPinchCenterPosition.y * factor); + + if (bounds.x > 0) + { + bounds.x = 0; + } + else if (bounds.x < -(bounds.width - viewBounds.width)) + { + bounds.x = -(bounds.width - viewBounds.width); + } + + if (bounds.y > 0) + { + bounds.y = 0; + } + else if (bounds.y < -(bounds.height- viewBounds.height)) + { + bounds.y = -(bounds.height - viewBounds.height); + } + } + else + { + bounds.x = (viewBounds.width / 2) - CalculateRound(viewBounds.width / 2 * factor); + bounds.y = (viewBounds.height / 2) - CalculateRound(viewBounds.height / 2 * factor); + } + + result r = __galleryRenderer.SetCanvasBounds(currentCanvasIndex, bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (bounds.width > viewBounds.width) + { + __zoomMode = true; + } + else + { + __zoomMode = false; + } + + return E_SUCCESS; +} + +result +_GalleryViewEventHandler::MoveCanvas(const Dimension& distance, _GalleryAnimationTiming* pAnimation) +{ + SysTryReturn(NID_UI_CTRL, __pressed == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] not pressed state."); + + int currentItemIndex = __galleryPresenter.GetCurrentItemIndex(); + int currentCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex); + int rightCanvasIndex = NOT_EXIST_CANVAS; + int leftCanvasIndex = NOT_EXIST_CANVAS; + + if (currentItemIndex != 0) + { + leftCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex - 1); + } + if (currentItemIndex < __galleryPresenter.GetItemCount()) + { + rightCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex + 1); + } + + Rectangle viewRect = __galleryRenderer.GetViewRect(); + Rectangle currentCanvasRect = __galleryRenderer.GetCanvasBounds(currentCanvasIndex); + Rectangle rect = currentCanvasRect; + + Rectangle canvasImageBounds = __galleryRenderer.GetCanvasImageBounds(currentCanvasIndex); + if (IsZoomFlag() == true) + { + if (canvasImageBounds.y + rect.y > 0) + { + rect.y -= (distance.height / 2); + } + else if (canvasImageBounds.y + canvasImageBounds.height + rect.y < viewRect.height) + { + rect.y -= (distance.height / 2); + } + else + { + rect.y -= distance.height; + } + + if (leftCanvasIndex == NOT_EXIST_CANVAS && canvasImageBounds.x + rect.x > 0 && distance.width < 0) + { + rect.x -= (distance.width / 2); + } + else if (rightCanvasIndex == NOT_EXIST_CANVAS + && canvasImageBounds.x + canvasImageBounds.width + rect.x < viewRect.width + && distance.width > 0) + { + rect.x -= (distance.width / 2); + } + else + { + rect.x -= distance.width; + } + } + else + { + rect.x -= distance.width; + } + + if (rect.x > 0 && leftCanvasIndex == NOT_EXIST_CANVAS && __zoomMode == false) + { + return E_SUCCESS; + } + else if (rect.x < 0 && rightCanvasIndex == NOT_EXIST_CANVAS && __zoomMode == false) + { + return E_SUCCESS; + } + + result r = __galleryRenderer.SetCanvasBounds(currentCanvasIndex, rect, pAnimation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (rightCanvasIndex != NOT_EXIST_CANVAS) + { + rect = __galleryRenderer.GetCanvasBounds(rightCanvasIndex); + //rect.x = currentCanvasRect.x - distance.width + currentCanvasRect.width + __galleryPresenter.GetItemSpacing(); + rect.x -= distance.width; + r = __galleryRenderer.SetCanvasBounds(rightCanvasIndex, rect, pAnimation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (leftCanvasIndex != NOT_EXIST_CANVAS) + { + rect = __galleryRenderer.GetCanvasBounds(leftCanvasIndex); + //rect.x = currentCanvasRect.x - distance.width - rect.width - __galleryPresenter.GetItemSpacing(); + rect.x -= distance.width; + r = __galleryRenderer.SetCanvasBounds(leftCanvasIndex, rect, pAnimation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __moving = true; + + return E_SUCCESS; +} + +result +_GalleryViewEventHandler::AlignCanvas(bool animation) +{ + int currentItemIndex = __galleryPresenter.GetCurrentItemIndex(); + int currentCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex); + int leftCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex - 1); + int rightCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex + 1); + + result r = E_SUCCESS; + Rectangle viewRect = __galleryRenderer.GetViewRect(); + Rectangle currentCanvasRect = __galleryRenderer.GetCanvasBounds(currentCanvasIndex); + Rectangle canvasImageBounds = __galleryRenderer.GetCanvasImageBounds(currentCanvasIndex); + + Rectangle rect = viewRect; + _GalleryAnimationTiming* pAnimationTimingFunction = null; + bool immediatePartialCanvasChange = false; + + if (animation == true) + { + pAnimationTimingFunction = new(std::nothrow) _GalleryAnimationTiming(); + SysTryCatch(NID_UI_CTRL, pAnimationTimingFunction != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + pAnimationTimingFunction->duration_ms = ALIGH_ANIMATION_DURATION; + pAnimationTimingFunction->timingFunction = GALLERY_ANIMATION_TIMING_FUNC_EASEOUT; + } + + if (canvasImageBounds.height > viewRect.height) // zoom mode + { + if (!(viewRect.y < canvasImageBounds.y && viewRect.height > canvasImageBounds.height + canvasImageBounds.y)) + { + immediatePartialCanvasChange = true; + } + } + + if ((IsZoomFlag() == true + && currentCanvasRect.x + canvasImageBounds.x > __galleryRenderer.GetViewRect().width / 2 + && (leftCanvasIndex != NOT_EXIST_CANVAS)) + || (IsZoomFlag() == false + && (canvasImageBounds.width / 2 + canvasImageBounds.x) < canvasImageBounds.x + currentCanvasRect.x)) // ----> align + { + r = __galleryRenderer.SetCanvasBounds(leftCanvasIndex, rect, pAnimationTimingFunction); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetCurrentItemIndex(currentItemIndex - 1); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + rect = viewRect; + rect.x = viewRect.width + __galleryPresenter.GetItemSpacing(); + r = __galleryRenderer.SetCanvasBounds(currentCanvasIndex, rect, pAnimationTimingFunction); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if ((IsZoomFlag() == true + && currentCanvasRect.x + (canvasImageBounds.x + canvasImageBounds.width) < __galleryRenderer.GetViewRect().width / 2 + && (rightCanvasIndex != NOT_EXIST_CANVAS)) + ||(IsZoomFlag() == false + && (canvasImageBounds.width / 2 + canvasImageBounds.x) > currentCanvasRect.x + currentCanvasRect.width)) // <---- align + { + r = __galleryRenderer.SetCanvasBounds(rightCanvasIndex, rect, pAnimationTimingFunction); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetCurrentItemIndex(currentItemIndex + 1); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + rect = viewRect; + rect.x = -viewRect.width - __galleryPresenter.GetItemSpacing(); + r = __galleryRenderer.SetCanvasBounds(currentCanvasIndex, rect, pAnimationTimingFunction); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (currentCanvasRect.x != 0 || currentCanvasRect.width != viewRect.width)// return align (before position) + { + if (currentCanvasIndex != NOT_EXIST_CANVAS) + { + rect = currentCanvasRect; + if (__zoomMode == true) + { + bool corrected = CorrectCanvasPosition(rect, canvasImageBounds); + if (corrected == false && immediatePartialCanvasChange == true && __zoomAnimationComplete == true) + { + r = __galleryPresenter.SetPartialCanvasImage(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r)); + } + } + else + { + rect = viewRect; + } + + r = __galleryRenderer.SetCanvasBounds(currentCanvasIndex, rect, pAnimationTimingFunction); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + Rectangle currentCanvasAlignBoundary = __galleryRenderer.GetCanvasAlignBoundary(currentCanvasIndex); + if (rightCanvasIndex != NOT_EXIST_CANVAS) + { + rect = viewRect; + rect.x = currentCanvasAlignBoundary.x + currentCanvasAlignBoundary.width + __galleryPresenter.GetItemSpacing(); + r = __galleryRenderer.SetCanvasBounds(rightCanvasIndex, rect, pAnimationTimingFunction); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + if (leftCanvasIndex != NOT_EXIST_CANVAS) + { + rect = viewRect; + rect.x = currentCanvasAlignBoundary.x - rect.width - __galleryPresenter.GetItemSpacing(); + r = __galleryRenderer.SetCanvasBounds(leftCanvasIndex, rect, pAnimationTimingFunction); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + delete pAnimationTimingFunction; + + return E_SUCCESS; + +CATCH: + delete pAnimationTimingFunction; + return r; +} + +void +_GalleryViewEventHandler::SetRollbackCanvas(void) +{ + int currentItemIndex = __galleryPresenter.GetCurrentItemIndex(); + int currentCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex); + int leftCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex - 1); + int rightCanvasIndex = __galleryPresenter.SearchCanvasIndex(currentItemIndex + 1); + + Rectangle viewRect = __galleryRenderer.GetViewRect(); + + result r = __galleryRenderer.SetCanvasBounds(currentCanvasIndex, viewRect); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasVisibility(leftCanvasIndex, false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __galleryRenderer.SetCanvasVisibility(rightCanvasIndex, false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + //SetLastResult(E_SUCCESS); +} + +int +_GalleryViewEventHandler::CalculateRound(float value) +{ + int returnValue = ((int)((value) * 10)) % 10 > 5 ? value + 0.5 : value; + return returnValue; +} + +bool +_GalleryViewEventHandler::CorrectCanvasPosition(Rectangle& canvasBounds, const Rectangle& imageBounds) +{ + if (IsZoomFlag() == false) + { + return false; + } + Rectangle viewBounds = __galleryRenderer.GetViewRect(); + bool corrected = false; + if (imageBounds.width > viewBounds.width) + { + if (viewBounds.x < imageBounds.x + canvasBounds.x) + { + canvasBounds.x = -imageBounds.x; + corrected = true; + } + else if (viewBounds.width > imageBounds.x + imageBounds.width + canvasBounds.x) + { + canvasBounds.x = (viewBounds.x + viewBounds.width) - (imageBounds.x + imageBounds.width); + corrected = true; + } + } + else + { + canvasBounds.x = viewBounds.width / 2 -((imageBounds.width / 2 + imageBounds.x)); + corrected = true; + } + + if (imageBounds.height > viewBounds.height) + { + if (viewBounds.y < imageBounds.y + canvasBounds.y) + { + canvasBounds.y = -imageBounds.y; + corrected = true; + } + else if (viewBounds.height > imageBounds.height + imageBounds.y + canvasBounds.y) + { + canvasBounds.y = (viewBounds.y + viewBounds.height) - (imageBounds.y + imageBounds.height); + corrected = true; + } + } + else + { + canvasBounds.y = viewBounds.height / 2 -((imageBounds.height / 2 + imageBounds.y)); + corrected = true; + } + + return corrected; +} + +result +_GalleryViewEventHandler::SetCurrentItemIndex(int index) +{ + __currentItemIndex = index; + + return __galleryPresenter.SetCurrentItemIndex(__currentItemIndex, false); +} + +result +_GalleryViewEventHandler::CallChangeItemIndex(void) +{ + result r = E_SUCCESS; + if (__currentItemIndex != NO_CHANGE_ITEM_INDEX) + { + r = __galleryPresenter.SetCurrentItemIndex(__currentItemIndex); + __currentItemIndex = NO_CHANGE_ITEM_INDEX; + __galleryPresenter.ChangedItem(); + } + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GalleryViewEventInfo.cpp b/src/ui/controls/FUiCtrl_GalleryViewEventInfo.cpp new file mode 100644 index 0000000..ff22c7a --- /dev/null +++ b/src/ui/controls/FUiCtrl_GalleryViewEventInfo.cpp @@ -0,0 +1,129 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include "FUiCtrl_GalleryViewEventInfo.h" + +namespace Tizen { namespace Ui { namespace Controls { + +_GalleryViewEventInfo::_GalleryViewEventInfo(void) + : __pTouchInfo(null) + , __flicked(false) + , __flickPosition(0, 0) + , __flickTime(0) + , __pinchCenterPosition(0, 0) + , __PinchArea(0) +{ + // Do nothing +} + +_GalleryViewEventInfo::_GalleryViewEventInfo(_TouchInfo& touchInfo) + : __pTouchInfo(&touchInfo) + , __flicked(false) + , __flickPosition(0, 0) + , __flickTime(0) + , __pinchCenterPosition(0, 0) + , __PinchArea(0) +{ + // Do nothing. +} + +_GalleryViewEventInfo::~_GalleryViewEventInfo(void) +{ + // Do nothing. +} + +_TouchStatus +_GalleryViewEventInfo::GetTouchStatus(void) const +{ + SysAssert(__pTouchInfo != null); + return __pTouchInfo->GetTouchStatus(); +} + +Tizen::Graphics::Point +_GalleryViewEventInfo::GetCurrentPosition(void) const +{ + SysAssert(__pTouchInfo != null); + return __pTouchInfo->GetCurrentPosition(); +} + +void +_GalleryViewEventInfo::SetFlicked(bool flicked) +{ + __flicked = flicked; +} + +bool +_GalleryViewEventInfo::IsFlicked(void) const +{ + return __flicked; +} + +void +_GalleryViewEventInfo::SetFlickPosition(Tizen::Graphics::Point flickPos) +{ + __flickPosition = flickPos; +} + +Tizen::Graphics::Point +_GalleryViewEventInfo::GetFlickPosition(void) const +{ + return __flickPosition; +} + +void +_GalleryViewEventInfo::SetFlickTime(int flickTime) +{ + __flickTime = flickTime; +} + +int +_GalleryViewEventInfo::GetFlickTime(void) const +{ + return __flickTime; +} + +void +_GalleryViewEventInfo::SetPinchCenterPosition(Tizen::Graphics::Point centerPos) +{ + __pinchCenterPosition = centerPos; +} + +Tizen::Graphics::Point +_GalleryViewEventInfo::GetPinchCenterPosition(void) const +{ + return __pinchCenterPosition; +} + +void +_GalleryViewEventInfo::SetPinchArea(int distance) +{ + __PinchArea = distance; +} + +int +_GalleryViewEventInfo::GetPinchArea(void) const +{ + return __PinchArea; +} + +unsigned long +_GalleryViewEventInfo::GetPointId(void) const +{ + return __pTouchInfo->GetPointId(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GroupItemImpl.cpp b/src/ui/controls/FUiCtrl_GroupItemImpl.cpp new file mode 100644 index 0000000..f123d00 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GroupItemImpl.cpp @@ -0,0 +1,247 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_GroupItemImpl.cpp + * @brief This is the implementation file for the GroupItemImpl class. + * + * This header file contains the declarations of the GroupItemImpl class. + */ + +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_GroupItemImpl.h" +#include "FUiCtrl_ListViewItem.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_GroupItemImpl* +_GroupItemImpl::GetInstance(GroupItem& groupItem) +{ + return groupItem._pImpl; +} + +const _GroupItemImpl* +_GroupItemImpl::GetInstance(const GroupItem& groupItem) +{ + return groupItem._pImpl; +} + +_GroupItemImpl::_GroupItemImpl(GroupItem* pPublic) + : _ListItemBaseImpl(null) +{ + GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __textSize); + GET_COLOR_CONFIG(LISTVIEW::GROUPITEM_TEXT_NORMAL, __textColor); +} + +_GroupItemImpl::~_GroupItemImpl(void) +{ + +} + +const char* +_GroupItemImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::GroupItem"; +} + +_GroupItemImpl* +_GroupItemImpl::CreateGroupItemImpN(GroupItem* pPublic, const Dimension& itemSize) +{ + result r = E_SUCCESS; + + _GroupItemImpl* pImpl = new (std::nothrow) _GroupItemImpl(pPublic); + SysTryReturn(NID_UI_CTRL, pImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = pImpl->Construct(itemSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; + +CATCH: + delete pImpl; + pImpl = null; + + return null; +} + +result +_GroupItemImpl::Construct(const Dimension& itemSize) +{ + result r = _ListItemBaseImpl::Construct(itemSize, LIST_ANNEX_STYLE_NORMAL); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _ListViewItem* pItem = GetListViewItem(); + + pItem->SetListViewItemType(LISTVIEW_ITEM_TYPE_GROUP); + pItem->SetItemDividerEnabled(false); + + r = SetBackgroundColor(GetBackgroundColor()); + + SetLastResultReturn(r); +} + +result +_GroupItemImpl::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + return _ListItemBaseImpl::SetBackgroundBitmap(LIST_ITEM_DRAWING_STATUS_NORMAL, pBitmap); +} + +result +_GroupItemImpl::SetBackgroundColor(const Color& color) +{ + result r = E_SUCCESS; + + r = _ListItemBaseImpl::SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, color); + r = _ListItemBaseImpl::SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED, color); + r = _ListItemBaseImpl::SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED, color); + + return r; +} + +Color +_GroupItemImpl::GetBackgroundColor(void) const +{ + return _ListItemBaseImpl::GetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL); +} + +result +_GroupItemImpl::SetTextColor(const Color& color) +{ + _ListViewItem* pItem = GetListViewItem(); + + if (pItem->HasElement(LIST_ITEM_RESERVED_ID_3)) + { + bool ret = false; + + ret = pItem->SetTextColor(LIST_ITEM_RESERVED_ID_3, color, LISTVIEW_ITEM_STATUS_NORMAL); + SysTryReturn(NID_UI_CTRL, ret == true, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + ret = pItem->SetTextColor(LIST_ITEM_RESERVED_ID_3, color, LISTVIEW_ITEM_STATUS_PRESSED); + SysTryReturn(NID_UI_CTRL, ret == true, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + ret = pItem->SetTextColor(LIST_ITEM_RESERVED_ID_3, color, LISTVIEW_ITEM_STATUS_HIGHLIGHTED); + SysTryReturn(NID_UI_CTRL, ret == true, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + } + + __textColor = color; + + return E_SUCCESS; +} + +Color +_GroupItemImpl::GetTextColor(void) const +{ + return __textColor; +} + +result +_GroupItemImpl::SetTextSize(int size) +{ + __textSize = size; + + _ListViewItem* pItem = GetListViewItem(); + if (pItem->HasElement(LIST_ITEM_RESERVED_ID_3)) + { + bool ret = pItem->SetTextSize(LIST_ITEM_RESERVED_ID_3, size); + + return (ret ? E_SUCCESS : E_SYSTEM); + } + + return E_SUCCESS; +} + +int +_GroupItemImpl::GetTextSize(void) const +{ + return __textSize; +} + +result +_GroupItemImpl::SetElement(const String& text, const Bitmap* pBitmap) +{ + bool ret = false; + _ListViewItem* pItem = GetListViewItem(); + + if (pItem->HasElement(LIST_ITEM_RESERVED_ID_2)) + { + ret = pItem->DeleteElement(LIST_ITEM_RESERVED_ID_2); + SysTryReturn(NID_UI_CTRL, (ret == true), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to delete bitmap element."); + } + + if (pItem->HasElement(LIST_ITEM_RESERVED_ID_3)) + { + ret = pItem->DeleteElement(LIST_ITEM_RESERVED_ID_3); + SysTryReturn(NID_UI_CTRL, (ret == true), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to delete text element."); + } + + Rectangle bitmapRect = Rectangle(0, 0, 0, 0); + Rectangle textRect = Rectangle(0, 0, 0, 0); + int leftMargin = 0; + int itemHeight = GetItemSize().height; + int elementSpacing = 0; + result r = E_SUCCESS; + + GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_ELEMENT_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + + // Add Bitmap element (optional) + if (pBitmap != null) + { + GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_ELEMENT_SPACING, _CONTROL_ORIENTATION_PORTRAIT, elementSpacing); + + int elementWidth = itemHeight * GROUP_ITEM_ELEMENT_BITMAP_SIZE_RATIO; + int elementHeight = elementWidth; + + bitmapRect.x = leftMargin; + bitmapRect.y = (itemHeight - elementHeight) / 2; + bitmapRect.width = elementWidth; + bitmapRect.height = elementHeight; + + r = pItem->AddElement(bitmapRect, LIST_ITEM_RESERVED_ID_2, pBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + + // Add Text element + textRect.x = leftMargin + bitmapRect.width + elementSpacing; + textRect.y = 0; + textRect.width = GetItemSize().width - textRect.x; + textRect.height = itemHeight; + + r = pItem->AddElement(textRect, LIST_ITEM_RESERVED_ID_3, text); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pItem->SetTextSize(LIST_ITEM_RESERVED_ID_3, __textSize); + pItem->SetTextAlignment(LIST_ITEM_RESERVED_ID_3, TEXT_OBJECT_ALIGNMENT_MIDDLE); + + pItem->SetTextColor(LIST_ITEM_RESERVED_ID_3, __textColor, LISTVIEW_ITEM_STATUS_NORMAL); + pItem->SetTextColor(LIST_ITEM_RESERVED_ID_3, __textColor, LISTVIEW_ITEM_STATUS_PRESSED); + pItem->SetTextColor(LIST_ITEM_RESERVED_ID_3, __textColor, LISTVIEW_ITEM_STATUS_HIGHLIGHTED); + + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GroupedListImpl.cpp b/src/ui/controls/FUiCtrl_GroupedListImpl.cpp new file mode 100644 index 0000000..62db032 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GroupedListImpl.cpp @@ -0,0 +1,1573 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_GroupedListImpl.cpp +* @brief This file contains implementation of _GroupedListImpl class +*/ + +#include +#include +#include +#include +#include "FUiCtrl_CustomListItemFormatImpl.h" +#include "FUiCtrl_CustomListItemImpl.h" +#include "FUiCtrl_GroupedListImpl.h" +#include "FUiCtrl_ListItemBaseImpl.h" +#include "FUiCtrl_CustomListElements.h" +#include "FUiCtrl_FastScroll.h" +#include "FUiCtrl_FastScrollIndex.h" +#include "FUiCtrl_ListListener.h" + +#include "FUi_UiBuilder.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; + + +namespace Tizen { namespace Ui { namespace Controls +{ + +static const int ID_FORMAT_STRING = 1; +static const int ID_FORMAT_MARGIN = 2; + +_GroupedListItemDataProvider::_GroupedListItemDataProvider(_GroupedListImpl* pGroupedListImpl) +{ + __pList = pGroupedListImpl; +} + +_GroupedListItemDataProvider::~_GroupedListItemDataProvider(void) +{ +} + +int +_GroupedListItemDataProvider::GetGroupCount() +{ + SysTryReturn(NID_UI_CTRL, __pList, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly."); + return __pList->GetGroupCount(); +} + +int +_GroupedListItemDataProvider::GetItemCount(int groupIndex) +{ + SysTryReturn(NID_UI_CTRL, __pList, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly."); + + return __pList->GetSubItemCountAt(groupIndex); +} + +TableViewGroupItem* +_GroupedListItemDataProvider::CreateGroupItem(int groupIndex, int itemWidth) +{ + result r = E_SUCCESS; + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = __pList->GetCustomListItemAt(groupIndex, -1); + tableViewItemParams.width = itemWidth; + tableViewItemParams.itemId = -1; + tableViewItemParams.groupIndex = groupIndex; + tableViewItemParams.itemIndex = -1; + tableViewItemParams.isDividerEnabled = false; + tableViewItemParams.pCheckBitmaps = null; + tableViewItemParams.annexStyle = __pList->_annexStyle; + + r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pList->GetTableViewGroupItemAt(groupIndex); +} + +TableViewItem* +_GroupedListItemDataProvider::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + result r = E_SUCCESS; + + CustomListItem* pCustomListItem = __pList->GetCustomListItemAt(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", itemIndex); + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = pCustomListItem; + tableViewItemParams.width = itemWidth; + tableViewItemParams.itemId = pCustomListItem->__pCustomListItemImpl->itemId; + tableViewItemParams.groupIndex = groupIndex; + tableViewItemParams.itemIndex = itemIndex; + tableViewItemParams.isDividerEnabled = __pList->_isDividerEnabled; + tableViewItemParams.pCheckBitmaps = __pList->_pCheckBitmaps; + tableViewItemParams.annexStyle = __pList->_annexStyle; + + r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCustomListItem->__pCustomListItemImpl->__pTableViewItemData->AddTouchEventListener(*__pList); + + TableViewItem* pItem = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData; + pItem->SetBackgroundColor(__pList->__bgColor); + + return pItem; +} + +int +_GroupedListItemDataProvider::GetDefaultGroupItemHeight(void) +{ + return __pList->__groupItemHeight; +} + +int +_GroupedListItemDataProvider::GetDefaultItemHeight(void) +{ + CustomListItem* pItem = __pList->GetCustomListItemAt(0, 0); + + if (pItem) + { + return pItem->__pCustomListItemImpl->height; + } + else + { + return __pList->_defaultItemHeight; + } +} + +bool +_GroupedListItemDataProvider::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + delete pItem; + + if (__pList->__directDelete == false) + { + CustomListItem* pCustomListItem = __pList->GetCustomListItemAt(groupIndex, -1); + pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData = null; + } + + return true; +} + +bool +_GroupedListItemDataProvider::IsReorderable(int groupIndexFrom, int groupIndexTo) +{ + return false; +} + +bool +_GroupedListItemDataProvider::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + delete pItem; + + if (__pList->__directDelete == false) + { + CustomListItem* pCustomListItem = __pList->GetCustomListItemAt(groupIndex, itemIndex); + pCustomListItem->__pCustomListItemImpl->__pTableViewItemData = null; + } + + return true; +} + +void +_GroupedListItemDataProvider::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ +} + +void +_GroupedListItemDataProvider::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + CustomListItem* pCustomListItem = __pList->GetCustomListItemAt(groupIndex, itemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d, %d).", groupIndex, itemIndex); + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = pCustomListItem; + updateParams.isDividerEnabled = __pList->_isDividerEnabled; + updateParams.pCheckBitmaps = __pList->_pCheckBitmaps; + updateParams.annexStyle = __pList->_annexStyle; + + result r = E_SUCCESS; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item."); + + pItem->SetEnabled(true); +} + +_GroupedListImpl* +_GroupedListImpl::GetInstance(GroupedList& groupedList) +{ + return static_cast<_GroupedListImpl*>(groupedList._pControlImpl); +} + +const _GroupedListImpl* +_GroupedListImpl::GetInstance(const GroupedList& groupedList) +{ + return static_cast(groupedList._pControlImpl); +} + +_GroupedListImpl::_GroupedListImpl(Control* pList, _TableView* pCore) + : _ListBaseImpl(pList, pCore) + , __pItemProvider(null) + , __pItemListener(null) + , __groupItemHeight(0) + , __groupItemTextFont(0) + , __directDelete(false) + , __pItemFormat(null) +{ +} + +_GroupedListImpl::~_GroupedListImpl(void) +{ + int count = GetItemCount(); + + for (int index = 0; index < count; index++) + { + RemoveFromSubItemsList(index); + } + + RemoveAllFromItemsList(); + + __itemListenersList.RemoveAll(true); + __fastScrollListenersList.RemoveAll(true); + + delete __pItemProvider; + + delete __pItemFormat; +} + +const char* +_GroupedListImpl::GetPublicClassName(void) const +{ + return "GroupedList"; +} + +const GroupedList& +_GroupedListImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +GroupedList& +_GroupedListImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _TableView& +_GroupedListImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_TableView& +_GroupedListImpl::GetCore(void) +{ + return static_cast<_TableView&>(_ControlImpl::GetCore()); +} + +_GroupedListImpl* +_GroupedListImpl::CreateGroupedListImplN(GroupedList* pControl, const Rectangle& bounds, bool itemDivider, bool fastScroll) +{ + result r = E_SUCCESS; + _TableView* pCore = null; + _GroupedListImpl* pImpl = null; + + r = GET_SIZE_INFO(GroupedList).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + if(fastScroll == true) + { + pCore = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_GROUPED, itemDivider, TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL); + } + else + { + pCore = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_GROUPED, itemDivider, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT); + } + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl = new (std::nothrow) _GroupedListImpl(pControl, pCore); + SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(GroupedList), bounds, pCore->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCore->SetItemDividerEnabled(itemDivider); + + return pImpl; + +CATCH: + delete pCore; + pCore = null; + + delete pImpl; + pImpl = null; + + return null; +} + +result +_GroupedListImpl::AddGroupedItemEventListener(const IGroupedItemEventListener& listener) +{ + _ListListener* pListenerData = new (std::nothrow) _ListListener(); + + SysTryReturn(NID_UI_CTRL, pListenerData, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pListenerData->pListener = const_cast(&listener); + __itemListenersList.Add(*pListenerData); + + return E_SUCCESS; +} + +result +_GroupedListImpl::RemoveGroupedItemEventListener(const IGroupedItemEventListener& listener) +{ + _ListListener* pListenerData = null; + int count = __itemListenersList.GetCount(); + result r = E_SYSTEM; + + for (int listenerCount = 0; listenerCount < count; listenerCount++) + { + pListenerData = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + + if ((pListenerData != null) && (pListenerData->pListener == &listener)) + { + r = E_SUCCESS; + __itemListenersList.RemoveAt(listenerCount, true); + break; + } + } + + return r; +} + +result +_GroupedListImpl::AddFastScrollEventListener(const IFastScrollEventListener& listener) +{ + _ListListener* pListenerData = new (std::nothrow) _ListListener(); + + SysTryReturn(NID_UI_CTRL, pListenerData, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pListenerData->pListener = const_cast(&listener); + __fastScrollListenersList.Add(*pListenerData); + + return E_SUCCESS; +} + +result +_GroupedListImpl::RemoveFastScrollEventListener(const IFastScrollEventListener& listener) +{ + _ListListener* pListenerData = null; + int count = __fastScrollListenersList.GetCount(); + + for (int listenerCount = 0; listenerCount < count; listenerCount++) + { + pListenerData = dynamic_cast<_ListListener*>(__fastScrollListenersList.GetAt(listenerCount)); + + if ((pListenerData != null) && (pListenerData->pListener == &listener)) + { + __fastScrollListenersList.RemoveAt(listenerCount, true); + break; + } + } + return E_SUCCESS; +} + +result +_GroupedListImpl::Initialize(void) +{ + __pItemProvider = new (std::nothrow) _GroupedListItemDataProvider(this); + SysTryReturn(NID_UI_CTRL, (__pItemProvider != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryReturn(NID_UI_CTRL, style == TABLE_VIEW_STYLE_GROUPED, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_GROUPED"); + + _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style); + SysTryReturn(NID_UI_CTRL, pItemProvider != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pItemProvider->SetGroupedStyleItemProvider(__pItemProvider); + if (r != E_SUCCESS) + { + delete pItemProvider; + SysTryReturn(NID_UI_CTRL, false, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = GetCore().SetItemProvider(pItemProvider); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetCore().AddGroupedTableViewItemEventListener(*this); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (GetCore().GetScrollStyle() == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL) + { + r = GetCore().AddFastScrollListener(*this); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_HEIGHT, GetCore().GetOrientation(), __groupItemHeight); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_FONT_SIZE, GetCore().GetOrientation(), __groupItemTextFont); + + __pItemFormat = new (std::nothrow) CustomListItemFormat(); + SysTryReturn(NID_UI_CTRL, __pItemFormat, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pItemFormat->Construct(); + + int leftMargin = 0; + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_LEFT_MARGIN, GetCore().GetOrientation(), leftMargin); + + __pItemFormat->AddElement(ID_FORMAT_MARGIN, Rectangle(0, 0, leftMargin, __groupItemHeight), __groupItemTextFont); + __pItemFormat->AddElement(ID_FORMAT_STRING, Rectangle(leftMargin, 0, GetCore().GetBounds().width, __groupItemHeight), __groupItemTextFont); + + __pItemFormat->SetElementEventEnabled(ID_FORMAT_MARGIN, true); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_STRING, true); + + return r; +} + +result +_GroupedListImpl::AddGroup(const String& text, const Bitmap* pBackgroundBitmap, int groupId) +{ + return InsertGroupAt(GetGroupCount(), text, pBackgroundBitmap, groupId); +} + +result +_GroupedListImpl::AddItem(int groupIndex, const CustomListItem& item, int itemId) +{ + SysTryReturnResult(NID_UI_CTRL, ((groupIndex >= 0) && (groupIndex < GetGroupCount())), + E_INVALID_ARG, "Invalid argument used. groupIndex = %d", groupIndex); + + return InsertItemAt(groupIndex, GetSubItemCountAt(groupIndex), item, itemId); +} + +result +_GroupedListImpl::SetItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, ((groupIndex >= 0) && (groupIndex < GetGroupCount())), + E_INVALID_ARG, "Invalid argument used. groupIndex = %d", groupIndex); + + SysTryReturnResult(NID_UI_CTRL, ((itemIndex >= 0) && (itemIndex < GetSubItemCountAt(groupIndex))), + E_INVALID_ARG, "Invalid argument used. groupIndex = %d", itemIndex); + + SysTryReturnResult(NID_UI_CTRL, (IsItemNew(item) == true), E_SYSTEM, "A system error has occurred. The item already exists."); + + CustomListItem* pOldCustomListItem = GetCustomListItemAt(groupIndex, itemIndex); + SysTryReturnResult(NID_UI_CTRL, pOldCustomListItem, E_SYSTEM, "A system error has occurred. Failed to get old CustomListItem"); + + _CheckElementModel* pOldCheckElement = GetCheckElementAt(groupIndex, itemIndex); + _CheckElementModel* pNewCheckElement = item.__pCustomListItemImpl->GetCheckElement(); + + if (pNewCheckElement && pOldCheckElement) + { + pNewCheckElement->SetCheckBoxStatus(pOldCheckElement->GetCheckBoxStatus()); + } + + item.__pCustomListItemImpl->__pTableViewItemData = pOldCustomListItem->__pCustomListItemImpl->__pTableViewItemData; + item.__pCustomListItemImpl->itemId = itemId; + + _TableViewGroupItemData* pGroupItem = GetTableViewGroupItemAt(groupIndex); + SysTryReturn(NID_UI_CTRL, pGroupItem, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get GroupItem at %d index.", groupIndex); + + r = SetInItemsList(item, groupIndex, itemIndex); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "A system error has occurred. Failed to insert an item."); + + r = GetCore().RefreshTableView(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "A system error has occurred. Failed to insert an item."); + + return r; +} + +result +_GroupedListImpl::InsertGroupAt(int groupIndex, const String& text, const Bitmap* pBackgroundBitmap, int groupId) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex <= GetGroupCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d", groupIndex); + + CustomListItem* pCustomListItem = new (std::nothrow) CustomListItem(); + SysTryReturn(NID_UI_CTRL, pCustomListItem, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pCustomListItem->Construct(__groupItemHeight); + pCustomListItem->SetItemFormat(*__pItemFormat); + pCustomListItem->SetElement(ID_FORMAT_STRING, text); + pCustomListItem->SetElement(ID_FORMAT_MARGIN, ""); + + if (pBackgroundBitmap != null) + { + pCustomListItem->SetNormalItemBackgroundBitmap(*pBackgroundBitmap); + } + + pCustomListItem->__pCustomListItemImpl->itemId = groupId; + + r = InsertIntoItemsList(*pCustomListItem, groupIndex, -1); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to insert an item."); + + r = GetCore().RefreshTableView(groupIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to insert an item."); + + return r; +} + +result +_GroupedListImpl::SetGroupAt(int groupIndex, const String& text, const Bitmap* pBackgroundBitmap, int groupId) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < GetGroupCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d", groupIndex); + + CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1); + SysTryReturn(NID_UI_CTRL, (pCustomListItem), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to insert an item."); + + _CustomListItemImpl* pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl; + SysTryReturn(NID_UI_CTRL, (pCustomListItemImpl), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to insert an item."); + + pCustomListItem->SetElement(ID_FORMAT_STRING, text); + if (pBackgroundBitmap != null) + { + pCustomListItem->SetNormalItemBackgroundBitmap(*pBackgroundBitmap); + } + + pCustomListItemImpl->itemId = groupId; + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = pCustomListItem; + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "A system error has occurred. Failed to refresh an item."); + + return r; +} + +result +_GroupedListImpl::InsertItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, ((groupIndex >= 0) && (groupIndex < GetGroupCount())), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d", groupIndex); + + SysTryReturn(NID_UI_CTRL, ((itemIndex >= 0) && (itemIndex <= GetSubItemCountAt(groupIndex))), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. itemIndex = %d", itemIndex); + + item.__pCustomListItemImpl->itemId = itemId; + + r = InsertIntoItemsList(item, groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to insert an item."); + + r = GetCore().RefreshTableView(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to insert an item."); + + return r; +} + +result +_GroupedListImpl::RemoveItemAt(int groupIndex, int itemIndex) +{ + int count = GetGroupCount(); + SysTryReturn(NID_UI_CTRL, ((groupIndex >= 0) && (groupIndex < count)), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d.", groupIndex); + + SysTryReturn(NID_UI_CTRL, ((itemIndex >= 0) && (itemIndex < GetSubItemCountAt(groupIndex))), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. itemIndex = %d", itemIndex); + + result r = E_SUCCESS; + + __directDelete = true; + + r = GetCore().RefreshTableView(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + + __directDelete = false; + + if (r != E_SUCCESS) + { + r = RemoveFromItemsList(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove item."); + } + + return r; +} + +result +_GroupedListImpl::RemoveAllItemsAt(int groupIndex) +{ + SysTryReturn(NID_UI_CTRL, ((groupIndex >= 0) && (groupIndex < GetGroupCount())), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d.", groupIndex); + + result r = E_SUCCESS; + + int count = GetSubItemCountAt(groupIndex) - 1; + for (int index = count; index >= 0; index--) + { + r = RemoveItemAt(groupIndex, 0); + } + + return r; +} + +result +_GroupedListImpl::RemoveGroupAt(int groupIndex) +{ + SysTryReturn(NID_UI_CTRL, ((groupIndex >= 0) && (groupIndex < GetGroupCount())), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d.", groupIndex); + + result r = E_SUCCESS; + + r = RemoveFromSubItemsList(groupIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = RemoveFromItemsList(groupIndex, -1); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __directDelete = true; + + r = GetCore().RefreshTableView(groupIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __directDelete = false; + + return E_SUCCESS; +} + +result +_GroupedListImpl::RemoveAllGroups(void) +{ + result r = E_SUCCESS; + int count = GetGroupCount(); + + for (int groupIndex = (count - 1); groupIndex >= 0; groupIndex--) + { + r = RemoveGroupAt(groupIndex); + } + + return r; +} + +result +_GroupedListImpl::RemoveAllItems(void) +{ + result r = E_SUCCESS; + int count = GetGroupCount(); + + for (int groupIndex = count - 1; groupIndex >= 0; groupIndex--) + { + r = RemoveAllItemsAt(groupIndex); + } + + return r; +} + +result +_GroupedListImpl::SetItemEnabled(int groupIndex, int itemIndex, bool enable) +{ + int count = GetGroupCount(); + SysTryReturnResult(NID_UI_CTRL, ((groupIndex >= 0) && (groupIndex < count)), E_INVALID_ARG, "Invalid argument used. groupIndex = %d.", groupIndex); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < GetSubItemCountAt(groupIndex)), E_INVALID_ARG, "Invalid argument used. itemIndex(%d)", itemIndex); + + _CheckElementModel* pCheckElementModel = GetCheckElementAt(groupIndex, itemIndex); + + if (pCheckElementModel) + { + if (enable) + { + if (pCheckElementModel->GetCheckBoxStatus() == CHECK_BOX_DISABLED) + { + pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_CHECKED); + } + } + else + { + if (pCheckElementModel->GetCheckBoxStatus() == CHECK_BOX_CHECKED) + { + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) + { + pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_DISABLED); + } + } + } + } + + result r = E_SUCCESS; + + r = GetCore().SetItemEnabled(groupIndex, itemIndex, enable); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + DrawItem(groupIndex, itemIndex); + + return r; +} + +bool +_GroupedListImpl::IsItemEnabled(int groupIndex, int itemIndex) const +{ + return GetCore().IsItemEnabled(groupIndex, itemIndex); +} + +result +_GroupedListImpl::SetItemChecked(int groupIndex, int itemIndex, bool check) +{ + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + SysTryReturn(NID_UI_CTRL, ((groupIndex >= 0) && (groupIndex < GetGroupCount())), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d", groupIndex); + + SysTryReturn(NID_UI_CTRL, ((itemIndex >= 0) && (itemIndex < GetSubItemCountAt(groupIndex))), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. itemIndex = %d", itemIndex); + + SysTryReturn(NID_UI_CTRL, (IsItemEnabled(groupIndex, itemIndex) == true), + E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The List item is not enabled at index %d %d.", groupIndex, itemIndex); + + if (IsItemChecked(groupIndex, itemIndex) == check) + { + return E_SUCCESS; + } + + _CheckElementModel* pCheckElement = GetCheckElementAt(groupIndex, itemIndex); + SysTryReturnResult(NID_UI_CTRL, (pCheckElement != null), E_SYSTEM, "A system error has occurred. Checkbox element not created"); + + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + { + if (check) + { + if (_currentRadioGroupIndex != -1) + { + _CheckElementModel* pOldCheckElement = GetCheckElementAt(_currentRadioGroupIndex, _currentRadioIndex); + SysTryReturnResult(NID_UI_CTRL, (pOldCheckElement != null), E_SYSTEM, "A system error has occurred. Checkbox element not created"); + + pOldCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED); + + DrawItem(_currentRadioGroupIndex, _currentRadioIndex); + } + + _currentRadioGroupIndex = groupIndex; + _currentRadioIndex = itemIndex; + + } + else + { + _currentRadioGroupIndex = -1; + _currentRadioIndex = -1; + } + } + + pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check); + + GetCore().Draw(); + + return E_SUCCESS; +} + +bool +_GroupedListImpl::IsItemChecked(int groupIndex, int itemIndex) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), + false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL."); + + const _CheckElementModel* pCheckElement = GetCheckElementAt(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, pCheckElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. CheckElement is not constructed properly."); + + return (bool)pCheckElement->GetCheckBoxStatus(); +} + +result +_GroupedListImpl::SetAllItemsChecked(int groupIndex, bool check) +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_RADIO"); + + SysTryReturn(NID_UI_CTRL, ((groupIndex >= 0) && (groupIndex < GetGroupCount())), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d", groupIndex); + + _CheckElementModel* pCheckElement = null; + + int groupItemCount = GetSubItemCountAt(groupIndex); + for (int indexItem = 0; indexItem < groupItemCount; indexItem++) + { + pCheckElement = GetCheckElementAt(groupIndex, indexItem); + SysTryReturnResult(NID_UI_CTRL, (pCheckElement != null), E_SYSTEM, "A system error has occurred. Checkbox element not created."); + + pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check); + } + + return E_SUCCESS; +} + +result +_GroupedListImpl::RemoveAllCheckedItems(void) +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_RADIO"); + + int count = GetGroupCount(); + + for (int groupIndex = (count - 1); groupIndex >= 0; groupIndex--) + { + if (RemoveAllCheckedItemsAt(groupIndex) != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Checked item with groupIndex=%d not removed successfully.", groupIndex); + } + } + + return E_SUCCESS; +} + +result +_GroupedListImpl::RemoveAllCheckedItemsAt(int groupIndex) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_RADIO"); + + SysTryReturn(NID_UI_CTRL, ((groupIndex >= 0) && (groupIndex < GetGroupCount())), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d", groupIndex); + + int count = GetSubItemCountAt(groupIndex); + for (int itemIndex = (count - 1) ; itemIndex >= 0; itemIndex--) + { + if (IsItemChecked(groupIndex, itemIndex)) + { + r = RemoveItemAt(groupIndex, itemIndex); + if (r != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Checked item with index %d %d not removed successfully.", groupIndex, itemIndex); + } + } + } + + return r; +} + +result +_GroupedListImpl::GetFirstCheckedItemIndex(int& groupIndex, int& itemIndex) const +{ + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + groupIndex = -1; + itemIndex = -1; + int count = GetGroupCount(); + for (int indexGroup = 0; indexGroup < count; indexGroup++) + { + int subItemCount = GetSubItemCountAt(indexGroup); + + for (int indexItem = 0; indexItem < subItemCount; indexItem++) + { + if (IsItemChecked(indexGroup, indexItem)) + { + itemIndex = indexItem; + groupIndex = indexGroup; + return E_SUCCESS; + } + } + } + + return E_SYSTEM; +} + +result +_GroupedListImpl::GetLastCheckedItemIndex(int& groupIndex, int& itemIndex) const +{ + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + groupIndex = -1; + itemIndex = -1; + int count = GetGroupCount(); + + for (int indexGroup = count - 1; indexGroup >= 0; indexGroup--) + { + int subItemCount = GetSubItemCountAt(indexGroup); + + for (int indexItem = subItemCount - 1; indexItem >= 0; indexItem--) + { + if (IsItemChecked(indexGroup, indexItem)) + { + itemIndex = indexItem; + groupIndex = indexGroup; + return E_SUCCESS; + } + } + } + + return E_SYSTEM; +} + +result +_GroupedListImpl::GetNextCheckedItemIndexAfter(int& groupIndex, int& itemIndex) const +{ + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + int count = GetGroupCount(); + + int subItemCount = GetSubItemCountAt(groupIndex); + + SysTryReturn(NID_UI_CTRL, ((groupIndex >= 0) && (groupIndex < count)), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d.", groupIndex); + + SysTryReturn(NID_UI_CTRL, ((itemIndex >= 0) && (itemIndex < subItemCount)), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. itemIndex = %d.", itemIndex); + + SysTryReturn(NID_UI_CTRL, (!((groupIndex == (count - 1)) && (itemIndex == (subItemCount - 1)))), + E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Input item is last item of last group") + + int itemStart = 0; + + for (int indexGroup = groupIndex; indexGroup < count; indexGroup++) + { + if (indexGroup == groupIndex) + { + itemStart = itemIndex + 1; + } + else + { + itemStart = 0; + } + + subItemCount = GetSubItemCountAt(groupIndex); + for (int indexItem = itemStart; indexItem < subItemCount; indexItem++) + { + if (IsItemChecked(indexGroup, indexItem)) + { + itemIndex = indexItem; + groupIndex = indexGroup; + return E_SUCCESS; + } + } + } + + return E_SYSTEM; +} + +int +_GroupedListImpl::GetGroupIndexFromGroupId(int groupId) const +{ + int count = GetGroupCount(); + + for (int indexGroup = 0; indexGroup < count; indexGroup++) + { + const CustomListItem* pCustomListItem = GetCustomListItemAt(indexGroup, -1); + SysTryReturn(NID_UI_CTRL, pCustomListItem, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", indexGroup); + + if (pCustomListItem->__pCustomListItemImpl->itemId == groupId) + { + return indexGroup; + } + } + SetLastResult(E_SUCCESS); + return -1; +} + +result +_GroupedListImpl::GetItemIndexFromItemId(int itemId, int& groupIndex, int& itemIndex) const +{ + groupIndex = -1; + itemIndex = -1; + + int count = GetGroupCount(); + + for (int indexGroup = 0; indexGroup < count; indexGroup++) + { + int subItemCount = GetSubItemCountAt(indexGroup); + for (int indexItem = 0; indexItem < subItemCount; indexItem++) + { + const CustomListItem* pSubListItem = GetCustomListItemAt(indexGroup, indexItem); + SysTryReturn(NID_UI_CTRL, pSubListItem, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", indexItem); + + if (pSubListItem->__pCustomListItemImpl->itemId == itemId) + { + itemIndex = indexItem; + groupIndex = indexGroup; + return E_SUCCESS; + } + } + } + + return E_SYSTEM; +} + +void +_GroupedListImpl::ScrollToBottom(void) +{ + int lastGroupIndex = GetGroupCount() - 1; + int lastItemIndex = GetSubItemCountAt(lastGroupIndex) - 1; + + GetCore().SetBottomDrawnItemIndex(lastGroupIndex, lastItemIndex); + GetCore().Draw(); + + return; +} +void +_GroupedListImpl::ScrollToTop(void) +{ + GetCore().SetTopDrawnItemIndex(0, -1); + + GetCore().Draw(); + + return; +} + +result +_GroupedListImpl::ScrollToTop(int groupIndex) +{ + SysTryReturn(NID_UI_CTRL, ((groupIndex < GetGroupCount()) && (groupIndex >= 0)), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d.", groupIndex); + + result r = E_SUCCESS; + + r = GetCore().SetTopDrawnItemIndex(groupIndex, -1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + return r; +} + +result +_GroupedListImpl::ScrollToTop(int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, ((groupIndex < GetGroupCount()) && (groupIndex >= 0)), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d.", groupIndex); + + SysTryReturn(NID_UI_CTRL, ((itemIndex >= 0) && (itemIndex < GetSubItemCountAt(groupIndex))), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. itemIndex = %d.", itemIndex); + + result r = E_SUCCESS; + + r = GetCore().SetTopDrawnItemIndex(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + return r; +} + +result +_GroupedListImpl::RefreshGroup(int groupIndex) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, ((groupIndex < GetGroupCount()) && (groupIndex >= 0)), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d.", groupIndex); + + int count = GetSubItemCountAt(groupIndex); + for (int indexItem = 0; indexItem < count; indexItem++) + { + r = RefreshItem(groupIndex, indexItem); + if (r != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Not able to refresh item with index %d %d.", groupIndex, indexItem); + } + } + + return E_SUCCESS; +} + +result +_GroupedListImpl::RefreshItem(int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, ((groupIndex < GetGroupCount()) && (groupIndex >= 0)), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d.", groupIndex); + + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, ((itemIndex >= 0) && (itemIndex < GetSubItemCountAt(groupIndex))), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. itemIndex = %d.", itemIndex); + + int topItemIndex = -1; + int bottomItemIndex = -1; + int groupItemIndex = -1; + + GetCore().GetTopDrawnItemIndex(groupItemIndex, topItemIndex); + GetCore().GetBottomDrawnItemIndex(groupItemIndex, bottomItemIndex); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= topItemIndex && itemIndex <= bottomItemIndex), E_INVALID_OPERATION, + "Index should be within drawn item range %d.", itemIndex); + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = GetCustomListItemAt(groupIndex, itemIndex); + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "A system error has occurred. Failed to refresh an item."); + + DrawItem(groupIndex, itemIndex); + + return E_SUCCESS; +} + +int +_GroupedListImpl::GetGroupIdAt(int groupIndex) const +{ + SysTryReturn(NID_UI_CTRL, ((groupIndex < GetGroupCount()) && (groupIndex >= 0)), + -1, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d.", groupIndex); + + const CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1); + SysTryReturn(NID_UI_CTRL, pCustomListItem, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex); + + SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex); + + return pCustomListItem->__pCustomListItemImpl->itemId; +} + +int +_GroupedListImpl::GetItemIdAt(int groupIndex, int itemIndex) const +{ + int count = GetGroupCount(); + SysTryReturn(NID_UI_CTRL, ((groupIndex >= 0) && (groupIndex < count)), + -1, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d.", groupIndex); + + SysTryReturn(NID_UI_CTRL, ((itemIndex >= 0) && (itemIndex < GetSubItemCountAt(groupIndex))), + -1, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. itemIndex = %d.", itemIndex); + + const CustomListItem* pItem = GetCustomListItemAt(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, pItem, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d %d).", groupIndex, itemIndex); + + return pItem->__pCustomListItemImpl->itemId; +} + +void +_GroupedListImpl::SetListBackgroundColor(const Color& bgColor) +{ + GetCore().SetBackgroundColor(bgColor); + return; +} + +void +_GroupedListImpl::OnTableViewItemStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + return; +} + +void +_GroupedListImpl::OnTableViewContextItemActivationStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_GroupedListImpl::OnTableViewItemReordered(_TableView& tableView, int itemIndexFrom, int itemIndexTo) +{ + return; +} + +void +_GroupedListImpl::OnGroupedTableViewGroupItemStateChanged(_TableView& tableView, int groupIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + return; +} + +void +_GroupedListImpl::OnGroupedTableViewItemStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + CustomListItemStatus customListItemStatus = CUSTOM_LIST_ITEM_STATUS_NORMAL; + ItemStatus itemStatus = ITEM_HIGHLIGHTED; + + switch (status) + { + case TABLE_VIEW_ITEM_STATUS_SELECTED: + itemStatus = ITEM_SELECTED; + customListItemStatus = CUSTOM_LIST_ITEM_STATUS_SELECTED; + break; + case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED: + itemStatus = ITEM_HIGHLIGHTED; + customListItemStatus = CUSTOM_LIST_ITEM_STATUS_FOCUSED; + break; + case TABLE_VIEW_ITEM_STATUS_CHECKED: + itemStatus = ITEM_CHECKED; + break; + case TABLE_VIEW_ITEM_STATUS_UNCHECKED: + itemStatus = ITEM_UNCHECKED; + break; + default: + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. item status is invalid(%d).", status); + SetLastResult(E_SYSTEM); + return; + } + + CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", itemIndex); + + LinkedList* pElements = &pCustomListItem->__pCustomListItemImpl->elements; + _ElementBaseModel* pElementBase = null; + + for (int i = 0; i < pElements->GetCount(); i++) + { + pElementBase = dynamic_cast<_ElementBaseModel*>(pElements->GetAt(i)); + SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get valid element at index %d.", i); + + if ((_isDividerEnabled && pElementBase->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX) || (!_isDividerEnabled)) + { + pElementBase->HandleElementEvent(customListItemStatus); + } + } + + if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL)) + { + bool isChecked = IsItemChecked(groupIndex, itemIndex); + + if (isChecked) + { + itemStatus = ITEM_UNCHECKED; + } + else + { + itemStatus = ITEM_CHECKED; + } + + SetItemChecked(groupIndex, itemIndex, !isChecked); + } + + ProcessItemStateChange(groupIndex, itemIndex, itemStatus); + + GetCore().Draw(); + return; +} + +void +_GroupedListImpl::OnGroupedTableViewContextItemActivationStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_GroupedListImpl::OnGroupedTableViewItemReordered(_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo) +{ + return; +} + +void +_GroupedListImpl::OnSectionTableViewItemStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + return; +} + +void +_GroupedListImpl::OnSectionTableViewContextItemActivationStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_GroupedListImpl::OnTableViewItemSwept(_TableView& tableView, int groupIndex, int itemIndex, TableViewSweepDirection direction) +{ + return; +} + +void +_GroupedListImpl::ProcessItemStateChange(int groupIndex, int itemIndex, int elementId, ItemStatus itemStatus) +{ + int itemId = GetItemIdAt(groupIndex, itemIndex); + _ListListener* pListenerData = null; + IGroupedItemEventListener* pGroupedItemEventListener = null; + int count = __itemListenersList.GetCount(); + + for (int listenerCount = 0; listenerCount < count; listenerCount++) + { + pListenerData = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + if (pListenerData != null) + { + pGroupedItemEventListener = dynamic_cast(pListenerData->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pGroupedItemEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get EventListener"); + + pGroupedItemEventListener->OnItemStateChanged(GetPublic(), groupIndex, itemIndex, itemId, elementId, itemStatus); + } + } + + return; +} + +void +_GroupedListImpl::ProcessItemStateChange(int groupIndex, int itemIndex, ItemStatus itemStatus) +{ + int itemId = GetItemIdAt(groupIndex, itemIndex); + _ListListener* pListenerData = null; + IGroupedItemEventListener* pGroupedItemEventListener = null; + int count = __itemListenersList.GetCount(); + + for (int listenerCount = 0; listenerCount < count; listenerCount++) + { + pListenerData = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + if (pListenerData != null) + { + pGroupedItemEventListener = dynamic_cast(pListenerData->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pGroupedItemEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get EventListener"); + pGroupedItemEventListener->OnItemStateChanged(GetPublic(), groupIndex, itemIndex, itemId, itemStatus); + } + } + SetLastResult(E_SUCCESS); + return; +} + +void +_GroupedListImpl::OnUiFastScrollIndexSelected(_Control& source, _FastScrollIndex& index) +{ + _ListListener* pListenerData = null; + IFastScrollEventListener* pFastScrollListener = null; + int listenerCount = __fastScrollListenersList.GetCount(); + + for (int listenerIndex = 0; listenerIndex < listenerCount; listenerIndex++) + { + pListenerData = dynamic_cast<_ListListener*>(__fastScrollListenersList.GetAt(listenerIndex)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerData != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get ScrollEventListener"); + + pFastScrollListener = dynamic_cast(pListenerData->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pFastScrollListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get ScrollEventListener"); + + wchar_t mch = L' '; + String* pIndexText = index.GetIndexText(); + if (pIndexText != null) + { + pIndexText->GetCharAt(0, mch); + } + const Control& control = GetPublic(); + _FastScrollIndex* __pMainIndex = index.GetParentIndex(); + if (__pMainIndex == GetCore().GetFastScrollBar()->GetIndex()) + { + Character mainIndex(mch); + pFastScrollListener->OnMainIndexChanged(control, mainIndex); + } + else + { + Character subIndex(mch); + pIndexText = __pMainIndex->GetIndexText(); + if (pIndexText != null) + { + pIndexText->GetCharAt(0, mch); + Character mainIndex(mch); + pFastScrollListener->OnSubIndexChanged(control, mainIndex, subIndex); + } + } + } + SetLastResult(E_SUCCESS); + return; +} + + +void +_GroupedListImpl::OnBoundsChanged(void) +{ + GetCore().OnBoundsChanged(); + return; +} + +result +_GroupedListImpl::SetFastScrollMainIndex(const String& text) +{ + SysTryReturn(NID_UI_CTRL, (text.GetLength() > 0), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Empty string"); + + result r = GetCore().SetFastScrollIndex(text, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + __mainIndexText = text; + + return E_SUCCESS; +} + +result +_GroupedListImpl::SetFastScrollSubIndex(const String& text, FastScrollIndexDigit indexDigit) +{ + SysTryReturn(NID_UI_CTRL, (text.GetLength() > 0), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Empty string"); + + SysTryReturn(NID_UI_CTRL, (indexDigit == SCROLL_INDEX_DIGIT_NUM_1), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. indexDigit is not SCROLL_INDEX_DIGIT_NUM_1"); + + _FastScroll* pFastScroll = GetCore().GetFastScrollBar(); + SysTryReturn(NID_UI_CTRL, pFastScroll, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. FastScroll doesn't exist."); + + SysTryReturn(NID_UI_CTRL, (__mainIndexText.GetLength() > 0), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Main index of the fast scroll isn't set"); + + _FastScrollIndex* pRootIndex = pFastScroll->GetIndex(); + SysTryReturn(NID_UI_CTRL, pRootIndex, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. RootIndex doesn't exist."); + + int subIndexDigit = 1 ; + String delim(L","); + StringTokenizer strTok(text, delim); + String token; + int i = 0; + + while (strTok.HasMoreTokens()) + { + strTok.GetNextToken(token); + _FastScrollIndex* pSecondaryIndex = pRootIndex->GetChildIndex(i++); + if (pSecondaryIndex != null) + { + pSecondaryIndex->AddChildTextIndexArray(0, token.GetPointer(), subIndexDigit, token.GetLength()); + } + } + pFastScroll->UpdateIndex(); + + return E_SUCCESS; +} + +class _GroupedListMaker + : public _UiBuilderControlMaker +{ +public: + _GroupedListMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_GroupedListMaker(){}; + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _GroupedListMaker* pGroupedListMaker = new (std::nothrow) _GroupedListMaker(uibuilder); + return pGroupedListMaker; + }; +protected: + virtual Tizen::Ui::Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + GroupedList* pGroupedList = null; + Rectangle rect; + Rectangle rectMin; + Dimension dimMin; + + Tizen::Base::String elementString; + CustomListStyle style = CUSTOM_LIST_STYLE_NORMAL; + bool isItemDivider = true; + bool isFastScroll = false; + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pGroupedList = new (std::nothrow) GroupedList(); + if (pGroupedList == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + + Tizen::Base::String styleString; + styleString = pControlProperty->GetStyle(); + + if (styleString.Equals(L"CUSTOM_LIST_STYLE_NORMAL", false)) + { + style = CUSTOM_LIST_STYLE_NORMAL; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO", false)) + { + style = CUSTOM_LIST_STYLE_RADIO; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK", false)) + { + style = CUSTOM_LIST_STYLE_MARK; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF", false)) + { + style = CUSTOM_LIST_STYLE_ONOFF; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER; + } + else + { + style = CUSTOM_LIST_STYLE_NORMAL; + } + + //Construct + if (pControl->GetElement("itemDivider", elementString)) + { + if (elementString.Equals(L"true", false)) + { + isItemDivider = true; + } + else + { + isItemDivider = false; + } + } + + if (pControl->GetElement("fastScroll", elementString)) + { + if (elementString.Equals(L"true", false)) + { + isFastScroll = true; + } + else + { + isFastScroll = false; + } + } + + r = pGroupedList->Construct(rect, style, isItemDivider, isFastScroll); + if (r != E_SUCCESS) + { + delete pGroupedList; + return null; + } + + if (pControl->GetElement("textOfEmptyList", elementString)) + { + pGroupedList->SetTextOfEmptyList(elementString); + } + + if (pControl->GetElement("colorOfEmptyListText", elementString)) + { + ConvertStringToColor(elementString, color); + pGroupedList->SetTextColorOfEmptyList(color); + } + + GET_DIMENSION_CONFIG(LIST::GROUPEDLIST_MIN_SIZE, _CONTROL_ORIENTATION_PORTRAIT, dimMin); + rectMin = (pControl->GetAttribute(0))->GetRect(); + (pControl->GetAttribute(0))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height); + + GET_DIMENSION_CONFIG(LIST::GROUPEDLIST_MIN_SIZE, _CONTROL_ORIENTATION_LANDSCAPE, dimMin); + rectMin = (pControl->GetAttribute(1))->GetRect(); + (pControl->GetAttribute(1))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height); + + return pGroupedList; + } + +private: +}; + +_GroupedListRegister::_GroupedListRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + if (pUiBuilderControlTableManager) + { + pUiBuilderControlTableManager->RegisterControl(L"GroupedList", _GroupedListMaker::GetInstance); + } +} +_GroupedListRegister::~_GroupedListRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + if (pUiBuilderControlTableManager) + { + pUiBuilderControlTableManager->UnregisterControl(L"GroupedList"); + } +} +static _GroupedListRegister GroupedListRegisterToUiBuilder; +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_GroupedListViewImpl.cpp b/src/ui/controls/FUiCtrl_GroupedListViewImpl.cpp new file mode 100644 index 0000000..31c1221 --- /dev/null +++ b/src/ui/controls/FUiCtrl_GroupedListViewImpl.cpp @@ -0,0 +1,1659 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_GroupedListViewImpl.cpp + * @brief This is the implementation file for + * _GroupedListViewImpl class. + * + * This file contains the implementation of _GroupedListViewImpl + * class. + */ + +#include +#include +#include +#include "FApp_AppInfo.h" +#include "FUi_ResourceManager.h" +#include "FUi_TouchManager.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_FastScrollEvent.h" +#include "FUiCtrl_FastScrollEventArg.h" +#include "FUiCtrl_Label.h" +#include "FUiCtrl_GroupedListViewImpl.h" +#include "FUiCtrl_GroupedListViewItemProviderAdaptor.h" +#include "FUiCtrl_ListItemEvent.h" +#include "FUiCtrl_ListItemEventArg.h" +#include "FUiCtrl_ListViewItem.h" +#include "FUiCtrl_PublicLinkEvent.h" +#include "FUiCtrl_ScrollEvent.h" +#include "FUiCtrl_ScrollEventArg.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_GroupedListViewImpl* +_GroupedListViewImpl::GetInstance(GroupedListView& groupedListView) +{ + return static_cast <_GroupedListViewImpl*>(groupedListView._pControlImpl); +} + +const _GroupedListViewImpl* +_GroupedListViewImpl::GetInstance(const GroupedListView& groupedListView) +{ + return static_cast (groupedListView._pControlImpl); +} + +_GroupedListViewImpl::_GroupedListViewImpl(GroupedListView* pGroupedList, _TableView* pCore) + : _ControlImpl(pGroupedList, pCore) + , __pListItemEvent(null) + , __pLinkEvent(null) + , __pScrollEvent(null) + , __pFastScrollEvent(null) + , __pEmptyBitmap(null) + , __pEmptyText(null) + , __redrawListView(true) + , __pItemNeedsLazyDeletion(null) + , __pItemSwept(null) +{ + GET_COLOR_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_NORMAL, __emptyTextColor); +} + +_GroupedListViewImpl::~_GroupedListViewImpl() +{ + if (__pListItemEvent != null) + { + delete __pListItemEvent; + __pListItemEvent = null; + } + + if (__pLinkEvent != null) + { + delete __pLinkEvent; + __pLinkEvent = null; + } + + if (__pScrollEvent != null) + { + delete __pScrollEvent; + __pScrollEvent = null; + } + + if (__pFastScrollEvent != null) + { + delete __pFastScrollEvent; + __pFastScrollEvent = null; + } + + if (__pEmptyBitmap != null) + { + GetCore().DetachChild(*__pEmptyBitmap); + + delete __pEmptyBitmap; + __pEmptyBitmap = null; + } + + if (__pEmptyText != null) + { + GetCore().DetachChild(*__pEmptyText); + + delete __pEmptyText; + __pEmptyText = null; + } +} + +const char* +_GroupedListViewImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::GroupedListView"; +} + +const GroupedListView& +_GroupedListViewImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +GroupedListView& +_GroupedListViewImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _TableView& +_GroupedListViewImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_TableView& +_GroupedListViewImpl::GetCore(void) +{ + return static_cast <_TableView&>(_ControlImpl::GetCore()); +} + +_GroupedListViewImpl* +_GroupedListViewImpl::CreateGroupedListViewImplN(GroupedListView* pControl, GroupedListViewStyle style, bool itemDivider, ListScrollStyle scrollStyle) +{ + result r = E_SUCCESS; + TableViewScrollBarStyle scrollBarStyle; + + switch (scrollStyle) + { + case SCROLL_STYLE_FADE_OUT: + scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT; + break; + case SCROLL_STYLE_FIXED: + scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FIXED; + break; + case SCROLL_STYLE_FAST_SCROLL: + scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL; + break; + case SCROLL_STYLE_JUMP_TO_TOP: + scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP; + break; + case SCROLL_STYLE_THUMB: + scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_THUMB; + break; + default: + scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_NONE; + break; + } + + TableViewStyle tableViewStyle = ((style == GROUPED_LIST_VIEW_STYLE_SECTION) ? TABLE_VIEW_STYLE_SECTION : TABLE_VIEW_STYLE_GROUPED); + + _TableView* pCore = _TableView::CreateTableViewN(tableViewStyle, itemDivider, scrollBarStyle); + SysTryReturn(NID_UI_CTRL, (pCore != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _GroupedListViewImpl* pImpl = new (std::nothrow) _GroupedListViewImpl(pControl, pCore); + + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return pImpl; +} + +result +_GroupedListViewImpl::SetItemProvider(IGroupedListViewItemProvider& provider) +{ + result r = E_SUCCESS; + int itemWidth = GetCore().GetBounds().width; + + if (GetCore().GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION) + { + int margin = 0; + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, margin); + + itemWidth -= (margin * 2); + } + + _GroupedListViewItemProviderAdaptor* pProviderAdaptor = + static_cast <_GroupedListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor()); + + if (pProviderAdaptor == null) + { + pProviderAdaptor = new (std::nothrow) _GroupedListViewItemProviderAdaptor(provider); + SysTryReturn(NID_UI_CTRL, (pProviderAdaptor != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pProviderAdaptor->SetListViewItemEventListener(*this); + + r = pProviderAdaptor->SetListWidth(itemWidth); + GetCore().SetItemProviderAdaptor(pProviderAdaptor); + } + else + { + pProviderAdaptor->SetItemProvider(provider); + r = pProviderAdaptor->SetListWidth(itemWidth); + + UpdateList(); + } + + __redrawListView = true; + + SetLastResultReturn(r); +} + +void +_GroupedListViewImpl::AddGroupedListViewItemEventListener(IGroupedListViewItemEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pListItemEvent == null) + { + __pListItemEvent = new (std::nothrow) _ListItemEvent(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pListItemEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pListItemEvent->Construct(GetPublic(), CLASSNAME_GROUPEDLISTVIEW); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct Item Event."); + } + + __pListItemEvent->AddListener(listener); + + r = GetCore().AddGroupedTableViewItemEventListener(*this); + + SetLastResult(r); +} + +void +_GroupedListViewImpl::RemoveGroupedListViewItemEventListener(IGroupedListViewItemEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pListItemEvent != null) + { + r = __pListItemEvent->RemoveListener(listener); + } + + SetLastResult(r); +} + +void +_GroupedListViewImpl::AddFastScrollListener(IFastScrollListener& listener) +{ + result r = E_SUCCESS; + + if (__pFastScrollEvent == null) + { + __pFastScrollEvent = new (std::nothrow) _FastScrollEvent(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pFastScrollEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pFastScrollEvent->Construct(GetPublic()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct FastScroll Event."); + } + + __pFastScrollEvent->AddListener(listener); + + r = GetCore().AddFastScrollListener(*this); + + SetLastResult(r); +} + +void +_GroupedListViewImpl::RemoveFastScrollListener(IFastScrollListener& listener) +{ + result r = E_SUCCESS; + + if (__pFastScrollEvent != null) + { + r = __pFastScrollEvent->RemoveListener(listener); + } + + SetLastResult(r); +} + +void +_GroupedListViewImpl::AddScrollEventListener(IScrollEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pScrollEvent == null) + { + __pScrollEvent = new (std::nothrow) _ScrollEvent(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pScrollEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pScrollEvent->Construct(GetPublic()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct Scroll Event."); + } + + __pScrollEvent->AddListener(listener); + + GetCore().AddScrollEventListener(*this); + + SetLastResult(r); +} + +void +_GroupedListViewImpl::RemoveScrollEventListener(IScrollEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pScrollEvent != null) + { + r = __pScrollEvent->RemoveListener(listener); + } + + SetLastResult(r); +} + +void +_GroupedListViewImpl::AddUiLinkEventListener(const IUiLinkEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pLinkEvent == null) + { + __pLinkEvent = _PublicLinkEvent::CreateInstanceN(GetPublic()); + SysTryReturnVoidResult(NID_UI, (__pLinkEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + + r = __pLinkEvent->AddListener(listener); + + SetLastResult(r); +} + +void +_GroupedListViewImpl::RemoveUiLinkEventListener(const IUiLinkEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pLinkEvent != null) + { + r = __pLinkEvent->RemoveListener(listener); + } + + SetLastResult(r); +} + +result +_GroupedListViewImpl::SetSweepEnabled(bool enable) +{ + GetCore().SetSweepEnabled(enable); + + SetLastResultReturn(E_SUCCESS); +} + +result +_GroupedListViewImpl::SetFastScrollIndex(const String& text, bool useSearchIcon) +{ + result r = GetCore().SetFastScrollIndex(text, useSearchIcon); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS) || (r == E_SYSTEM), E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] This instance is in an invalid state."); + + SetLastResultReturn(r); +} + +result +_GroupedListViewImpl::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + return GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex); +} + +result +_GroupedListViewImpl::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + return GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex); +} + +result +_GroupedListViewImpl::ScrollToItem(int groupIndex, int itemIndex, ListScrollItemAlignment itemAlignment) +{ + result r = E_SUCCESS; + + if (itemAlignment == LIST_SCROLL_ITEM_ALIGNMENT_TOP) + { + r = GetCore().SetTopDrawnItemIndex(groupIndex, itemIndex); + } + else if (itemAlignment == LIST_SCROLL_ITEM_ALIGNMENT_BOTTOM) + { + r = GetCore().SetBottomDrawnItemIndex(groupIndex, itemIndex); + } + else + { + SysTryReturn(NID_UI_CTRL, false, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified itemAlignment is out of range."); + } + + SetLastResultReturn(r); +} + +result +_GroupedListViewImpl::SetItemChecked(int groupIndex, int itemIndex, bool check) +{ + return GetCore().SetItemChecked(groupIndex, itemIndex, check); +} + +bool +_GroupedListViewImpl::IsItemChecked(int groupIndex, int itemIndex) const +{ + return GetCore().IsItemChecked(groupIndex, itemIndex); +} + +result +_GroupedListViewImpl::SetItemEnabled(int groupIndex, int itemIndex, bool enable) +{ + return GetCore().SetItemEnabled(groupIndex, itemIndex, enable); +} + +bool +_GroupedListViewImpl::IsItemEnabled(int groupIndex, int itemIndex) const +{ + return GetCore().IsItemEnabled(groupIndex, itemIndex); +} + +int +_GroupedListViewImpl::GetGroupCount(void) const +{ + return GetCore().GetGroupCount(); +} + +int +_GroupedListViewImpl::GetItemCountAt(int groupIndex) const +{ + return GetCore().GetItemCountAt(groupIndex); +} + +result +_GroupedListViewImpl::ShowItemDescriptionText(int groupIndex, int itemIndex) +{ + return SetItemDescriptionTextShowState(groupIndex, itemIndex, true); +} + +result +_GroupedListViewImpl::HideItemDescriptionText(int groupIndex, int itemIndex) +{ + return SetItemDescriptionTextShowState(groupIndex, itemIndex, false); +} + +result +_GroupedListViewImpl::SetItemDescriptionTextShowState(int groupIndex, int itemIndex, bool show) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0) && (groupIndex < GetGroupCount()), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified groupIndex is out of range."); + + SysTryReturn(NID_UI_CTRL, (itemIndex >= 0) && (itemIndex < GetItemCountAt(groupIndex)), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified itemIndex is out of range."); + + _GroupedListViewItemProviderAdaptor* pProviderAdaptor = + static_cast <_GroupedListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor()); + SysTryReturn(NID_UI_CTRL, (pProviderAdaptor != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] _GroupedListItemProviderAdaptor is not set."); + + // Save description text show state to provider adaptor + pProviderAdaptor->SetDescriptionTextShowState(groupIndex, itemIndex, show); + + if (GetCore().FindItem(groupIndex, itemIndex) != null) + { + r = GetCore().RefreshTableView(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } + + SetLastResultReturn(r); +} + +result +_GroupedListViewImpl::RefreshList(int groupIndex, int itemIndex, ListRefreshType type) +{ + result r = E_SUCCESS; + + int groupCount = GetCore().GetGroupCount(); + int itemCount = GetCore().GetItemCountAt(groupIndex); + + if ((groupIndex < 0) || (groupIndex > groupCount) || + (itemIndex < -1) || (itemIndex > itemCount) || + ((type != LIST_REFRESH_TYPE_ITEM_ADD) && (itemIndex == itemCount))) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range."); + return E_OUT_OF_RANGE; + } + + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex)); + + // for lazy delete item + if ((__pItemNeedsLazyDeletion != null) && (type != LIST_REFRESH_TYPE_ITEM_ADD)) + { + if (__pItemNeedsLazyDeletion == pListViewItem) + { + _GroupedListViewItemProviderAdaptor* pProviderAdaptor = + static_cast <_GroupedListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor()); + + if (pProviderAdaptor != null) + { + pProviderAdaptor->SetItemNeedsLazyDeletion(__pItemNeedsLazyDeletion); + } + } + } + + if ((__pItemSwept != null) && (type != LIST_REFRESH_TYPE_ITEM_ADD)) + { + if (__pItemSwept == pListViewItem) + { + GetCore().ResetSweepItem(); + } + } + + if (type == LIST_REFRESH_TYPE_ITEM_MODIFY) + { + int topGroupIndex = -1; + int topItemIndex = -1; + int bottomGroupIndex = -1; + int bottomItemIndex = -1; + + GetCore().GetFirstLoadedItemIndex(topGroupIndex, topItemIndex); + GetCore().GetLastLoadedItemIndex(bottomGroupIndex, bottomItemIndex); + + if ((topGroupIndex > groupIndex) || (bottomGroupIndex < groupIndex) + || ((topGroupIndex == groupIndex) && (topItemIndex > itemIndex)) + || ((bottomGroupIndex == groupIndex) && (bottomItemIndex < itemIndex))) + { + // not yet loaded item + SetLastResultReturn(r); + } + else + { + TableViewItemDrawingStatus itemDrawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + bool itemSelected = false; + Point touchPosition(-1, -1); + + if (pListViewItem != null) + { + itemDrawingStatus = pListViewItem->GetDrawingStatus(); + itemSelected = pListViewItem->GetSelectionState(); + touchPosition = pListViewItem->GetLastTouchPressedPosition(); + + pListViewItem = null; + } + + GetCore().UnloadItem(groupIndex, itemIndex); + GetCore().LoadItem(groupIndex, itemIndex); + + pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex)); + + if ((pListViewItem != null) && (itemDrawingStatus != TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)) + { + pListViewItem->SetDrawingStatus(itemDrawingStatus); + pListViewItem->SetSelectionState(itemSelected); + pListViewItem->SetLastTouchPressedPosition(touchPosition); + + // for create Annex + pListViewItem->Draw(); + pListViewItem->Show(); + + _Control* target = static_cast<_Control*>(pListViewItem); + + for (int i = 0; i < pListViewItem->GetChildCount(); i++) + { + if (pListViewItem->GetChild(i)->GetBounds().Contains(touchPosition)) + { + target = pListViewItem->GetChild(i); + } + } + + if (target != null) + { + target->SetChangingEventTarget(true); + } + else + { + pListViewItem->SetDrawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + pListViewItem->SetSelectionState(false); + } + } + } + } + else + { + r = GetCore().RefreshTableView(groupIndex, itemIndex, static_cast(type)); + } + + CheckEmptyListShowState(); + + Draw(); + Show(); + + SetLastResultReturn(r); +} + +result +_GroupedListViewImpl::RefreshList(int groupIndex, int itemIndex, int elementId) +{ + if ((groupIndex < 0) || (groupIndex >= GetCore().GetGroupCount()) || (itemIndex < 0) || (itemIndex >= GetCore().GetItemCountAt(groupIndex))) + { + return E_OUT_OF_RANGE; + } + + result r = E_SUCCESS; + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex)); + + if (pListViewItem != null) + { + r = (pListViewItem->RefreshElement(elementId)) ? E_SUCCESS : E_OUT_OF_RANGE; + } + + SetLastResultReturn(r); +} + +result +_GroupedListViewImpl::UpdateList(void) +{ + // for lazy delete item + if (__pItemNeedsLazyDeletion != null) + { + _GroupedListViewItemProviderAdaptor* pProviderAdaptor = + static_cast <_GroupedListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor()); + + if (pProviderAdaptor != null) + { + pProviderAdaptor->SetItemNeedsLazyDeletion(__pItemNeedsLazyDeletion); + } + } + + result r = GetCore().UpdateTableView(); + + CheckEmptyListShowState(); + + Invalidate(true); + + // API versioning for initial Show() operation + if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat()) + { + Show(); + } + + SetLastResultReturn(r); +} + +result +_GroupedListViewImpl::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const +{ + result r = GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] There is no item at the specified position."); + + SetLastResultReturn(r); +} + +result +_GroupedListViewImpl::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex, int& elementId) const +{ + elementId = -1; + + result r = GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] There is no item at the specified position."); + + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex)); + + if (pListViewItem != null) + { + Point originPosition = pListViewItem->GetPosition(); + originPosition.y -= GetCore().GetScrollPosition(); + + elementId = pListViewItem->GetElementIdFromPosition(Point(position.x - originPosition.x, position.y - originPosition.y)); + } + + SetLastResultReturn(r); +} + +result +_GroupedListViewImpl::SetSectionColor(const Color& color) +{ + return GetCore().SetSectionColor(color); +} + +Color +_GroupedListViewImpl::GetSectionColor(void) const +{ + return GetCore().GetSectionColor(); +} + +result +_GroupedListViewImpl::SetItemDividerColor(const Color& color) +{ + return GetCore().SetItemDividerColor(color); +} + +Color +_GroupedListViewImpl::GetItemDividerColor(void) const +{ + return GetCore().GetItemDividerColor(); +} + +void +_GroupedListViewImpl::SetListBackgroundColor(const Color& color) +{ + SetBackgroundColor(color); +} + +result +_GroupedListViewImpl::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + GetCore().SetBackgroundBitmap(const_cast(pBitmap)); + GetCore().SetBackgroundBitmapStretch(true); + + SetLastResultReturn(E_SUCCESS); +} + +result +_GroupedListViewImpl::SetBitmapOfEmptyList(const Bitmap* pBitmap) +{ + if (pBitmap == null) + { + if (__pEmptyBitmap != null) + { + GetCore().DetachChild(*__pEmptyBitmap); + + delete __pEmptyBitmap; + __pEmptyBitmap = null; + } + } + else + { + if (__pEmptyBitmap == null) + { + __pEmptyBitmap = _Label::CreateLabelN(); + SysTryReturn(NID_UI_CTRL, (__pEmptyBitmap != null), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pEmptyBitmap->SetVisibleState(false); + __pEmptyBitmap->SetMargin(0, 0); + + GetCore().AttachChild(*__pEmptyBitmap); + } + + Dimension bitmapSize(pBitmap->GetWidth(), pBitmap->GetHeight()); + Dimension listDimension = GetCore().GetSize(); + Dimension labelDimension; + + labelDimension.width = ((listDimension.width < bitmapSize.width) ? listDimension.width : bitmapSize.width); + labelDimension.height = ((listDimension.height < bitmapSize.height) ? listDimension.height : bitmapSize.height); + + __pEmptyBitmap->SetSize(labelDimension); + __pEmptyBitmap->SetBackgroundColor(Color(0, 0, 0, 0)); + __pEmptyBitmap->SetBackgroundBitmap(*pBitmap); + } + + AdjustLayoutOfEmptyList(); + + SetLastResultReturn(E_SUCCESS); +} + +result +_GroupedListViewImpl::SetTextOfEmptyList(const String& text) +{ + if (text.IsEmpty()) + { + if (__pEmptyText != null) + { + GetCore().DetachChild(*__pEmptyText); + + delete __pEmptyText; + __pEmptyText = null; + } + } + else + { + if (__pEmptyText == null) + { + __pEmptyText = _Label::CreateLabelN(); + SysTryReturn(NID_UI_CTRL, (__pEmptyText != null), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pEmptyText->SetVisibleState(false); + __pEmptyText->SetMargin(0, 0); + + GetCore().AttachChild(*__pEmptyText); + } + + TextObject* pText = new (std::nothrow) TextObject; + SysTryReturn(NID_UI_CTRL, (pText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pText->Construct(); + + TextSimple* pSimpleText = new (std::nothrow) TextSimple(const_cast (text.GetPointer()), text.GetLength()); + SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + pText->AppendElement(*pSimpleText); + + int fontSize = 0; + GET_SHAPE_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, fontSize); + + Font font; + font.Construct(GetFont(), FONT_STYLE_PLAIN, fontSize); + pText->SetFont(&font, 0, pText->GetTextLength()); + + Dimension listDimension = GetCore().GetSize(); + + pText->SetBounds(Rectangle(0, 0, listDimension.width, 1)); + pText->Compose(); + + Dimension labelDimension = pText->GetTextExtent(0, pText->GetTextLength()); + labelDimension.height = pText->GetTotalHeight(); + + if (labelDimension.width > listDimension.width) + { + pText->SetBounds(Rectangle(0, 0, listDimension.width, 1)); + pText->Compose(); + + int labelHeight = pText->GetTotalHeight(); + + labelDimension.width = listDimension.width; + labelDimension.height = ((listDimension.height < labelHeight) ? listDimension.height : labelHeight); + } + + delete pText; + + __pEmptyText->SetSize(labelDimension); + __pEmptyText->SetBackgroundColor(Color(0, 0, 0, 0)); + __pEmptyText->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL); + __pEmptyText->SetTextColor(__emptyTextColor); + __pEmptyText->SetText(text); + } + + AdjustLayoutOfEmptyList(); + + SetLastResultReturn(E_SUCCESS); +} + +String +_GroupedListViewImpl::GetTextOfEmptyList(void) const +{ + return ((__pEmptyText != null) ? __pEmptyText->GetText() : String()); +} + +result +_GroupedListViewImpl::SetTextColorOfEmptyList(const Color& color) +{ + __emptyTextColor = color; + + if (__pEmptyText != null) + { + __pEmptyText->SetTextColor(color); + } + + SetLastResultReturn(E_SUCCESS); +} + +Color +_GroupedListViewImpl::GetTextColorOfEmptyList(void) const +{ + return __emptyTextColor; +} + +result +_GroupedListViewImpl::ExpandGroup(int groupIndex) +{ + return GetCore().ExpandGroup(groupIndex); +} + +result +_GroupedListViewImpl::CollapseGroup(int groupIndex) +{ + return GetCore().CollapseGroup(groupIndex); +} + +bool +_GroupedListViewImpl::IsGroupExpanded(int groupIndex) const +{ + return GetCore().IsGroupExpanded(groupIndex); +} + +void +_GroupedListViewImpl::CheckEmptyListShowState(void) +{ + bool isEmpty = (GetGroupCount() == 0); + + if (__pEmptyBitmap != null) + { + __pEmptyBitmap->SetVisibleState(isEmpty); + } + if (__pEmptyText != null) + { + __pEmptyText->SetVisibleState(isEmpty); + } +} + + +void +_GroupedListViewImpl::AdjustLayoutOfEmptyList(void) +{ + Dimension listDimension = GetCore().GetSize(); + Dimension emptyBitmap; + Dimension emptyText; + Point bitmapPos; + Point textPos; + int totalHeight = 0; + + if (__pEmptyBitmap != null) + { + emptyBitmap = __pEmptyBitmap->GetSize(); + } + if (__pEmptyText != null) + { + emptyText = __pEmptyText->GetSize(); + } + + totalHeight = emptyBitmap.height + emptyText.height; + + if ((__pEmptyBitmap != null) && (__pEmptyText != null) && (totalHeight < listDimension.height)) + { + bitmapPos.x = ((listDimension.width == emptyBitmap.width) ? 0 : (listDimension.width - emptyBitmap.width) / 2); + bitmapPos.y = (listDimension.height - totalHeight) / 2; + + textPos.x = ((listDimension.width == emptyText.width) ? 0 : (listDimension.width - emptyText.width) / 2); + textPos.y = bitmapPos.y + emptyBitmap.height; + } + else + { + if (__pEmptyBitmap != null) + { + bitmapPos.x = ((listDimension.width == emptyBitmap.width) ? 0 : (listDimension.width - emptyBitmap.width) / 2); + bitmapPos.y = ((listDimension.height == emptyBitmap.height) ? 0 : (listDimension.height - emptyBitmap.height) / 2); + } + + if (__pEmptyText != null) + { + textPos.x = ((listDimension.width == emptyText.width) ? 0 : (listDimension.width - emptyText.width) / 2); + textPos.y = ((listDimension.height == emptyText.height) ? 0 : (listDimension.height - emptyText.height) / 2); + } + } + + if (__pEmptyBitmap != null) + { + __pEmptyBitmap->SetPosition(bitmapPos); + } + if (__pEmptyText != null) + { + __pEmptyText->SetPosition(textPos); + } + + CheckEmptyListShowState(); +} + +result +_GroupedListViewImpl::BeginReorderingMode(void) +{ + SysTryReturn(NID_UI_CTRL, (GetCore().GetTableViewStyle() == TABLE_VIEW_STYLE_GROUPED), E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] Reordering mode is supported only Indexed style."); + + result r = GetCore().SetReorderModeEnabled(true); + + SetLastResultReturn(r); +} + +result +_GroupedListViewImpl::EndReorderingMode(void) +{ + SysTryReturn(NID_UI_CTRL, (GetCore().GetTableViewStyle() == TABLE_VIEW_STYLE_GROUPED), E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] Reordering mode is supported only Indexed style."); + + result r = GetCore().SetReorderModeEnabled(false); + + SetLastResultReturn(r); +} + +bool +_GroupedListViewImpl::IsInReorderingMode(void) const +{ + return GetCore().IsReorderModeEnabled(); +} + +void +_GroupedListViewImpl::OnListViewContextItemStateChanged(_Control& source, int groupIndex, int itemIndex, int elementId, + ListContextItemStatus status) +{ + if (__pListItemEvent != null) + { + GetCore().ResetSweepItem(); + + __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex)); + + _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(groupIndex, itemIndex, elementId, 0, NOTIFY_TYPE_SELCTED_CONTEXT_ITEM); + __pListItemEvent->Fire(*pArg); + + __pItemNeedsLazyDeletion = null; + } +} + +void +_GroupedListViewImpl::OnListViewItemLongPressed(_Control& source, int groupIndex, int itemIndex, int elementId) +{ + if (__pListItemEvent != null) + { + __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex)); + + _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(groupIndex, itemIndex, elementId, 0, NOTIFY_TYPE_LONG_PRESSED_ITEM); + __pListItemEvent->Fire(*pArg); + + __pItemNeedsLazyDeletion = null; + } +} + +void +_GroupedListViewImpl::OnGroupedTableViewGroupItemStateChanged(_TableView& tableView, int groupIndex, _TableViewItem* pItem, + TableViewItemStatus status) +{ + FireListViewItemEvent(groupIndex, -1, pItem, status); +} + +void +_GroupedListViewImpl::OnGroupedTableViewItemStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pItem, + TableViewItemStatus status) +{ + FireListViewItemEvent(groupIndex, itemIndex, pItem, status); +} + +void +_GroupedListViewImpl::OnGroupedTableViewContextItemActivationStateChanged(_TableView& tableView, int groupIndex, int itemIndex, + _TableViewItem* pContextItem, bool activated) +{ + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex)); + + if (pListViewItem != null) + { + __pItemSwept = (activated ? pListViewItem : null); + + pListViewItem->SetContextItemActivationState(activated); + } +} + +void +_GroupedListViewImpl::OnGroupedTableViewItemReordered(_TableView& tableView, int groupIndexFrom, int itemIndexFrom, + int groupIndexTo, int itemIndexTo) +{ + if (__pListItemEvent != null) + { + _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(groupIndexFrom, itemIndexFrom, groupIndexTo, itemIndexTo, + NOTIFY_TYPE_REORDERED_ITEM); + __pListItemEvent->Fire(*pArg); + } +} + +void +_GroupedListViewImpl::OnSectionTableViewItemStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pItem, + TableViewItemStatus status) +{ + FireListViewItemEvent(sectionIndex, itemIndex, pItem, status); +} + +void +_GroupedListViewImpl::OnSectionTableViewContextItemActivationStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, + _TableViewItem* pContextItem, bool activated) +{ + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(sectionIndex, itemIndex)); + + if (pListViewItem != null) + { + __pItemSwept = (activated ? pListViewItem : null); + + pListViewItem->SetContextItemActivationState(activated); + } +} + +void +_GroupedListViewImpl::OnTableViewItemSwept(_TableView& tableView, int groupIndex, int itemIndex, TableViewSweepDirection direction) +{ + if (__pListItemEvent != null) + { + __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex)); + + _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(groupIndex, itemIndex, direction, 0, NOTIFY_TYPE_SWEPT_ITEM); + __pListItemEvent->Fire(*pArg); + + __pItemNeedsLazyDeletion = null; + } +} + +void +_GroupedListViewImpl::FireListViewItemEvent(int groupIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + if (__pListItemEvent != null) + { + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(pItem); + + __pItemNeedsLazyDeletion = pListViewItem; + + if (pListViewItem != null) + { + _ListViewItemStateChangedInfo itemInfo; + pListViewItem->GetLastStateChangedInfo(itemInfo); + + if ((__pLinkEvent != null) && (itemInfo.pUiLinkInfo != null)) + { + IEventArg* pLinkEventArg = _PublicLinkEvent::CreateLinkEventArgN(itemInfo.pUiLinkInfo->textInfo, + itemInfo.pUiLinkInfo->linkType, + itemInfo.pUiLinkInfo->linkInfo); + SysTryReturnVoidResult(NID_UI_CTRL, (pLinkEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + __pLinkEvent->Fire(*pLinkEventArg); + + } + else + { + _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(groupIndex, itemIndex, itemInfo.elementId, 0, + static_cast(status)); + __pListItemEvent->Fire(*pArg); + } + + pListViewItem->ClearLastStateChangedInfo(); + } + + __pItemNeedsLazyDeletion = null; + } +} + +void +_GroupedListViewImpl::OnScrollEndReached(_Control& source, ScrollEndEvent type) +{ + if (__pScrollEvent != null) + { + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), type); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + } +} + +void +_GroupedListViewImpl::OnScrollPositionChanged(_Control& source, int scrollPos) +{ + if (__pScrollEvent != null) + { + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), scrollPos); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + } +} + +void +_GroupedListViewImpl::OnScrollStopped(_Control& source) +{ + if (__pScrollEvent != null) + { + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic()); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + } +} +void +_GroupedListViewImpl::OnUiFastScrollIndexSelected(_Control& source, _FastScrollIndex& index) +{ + if (__pFastScrollEvent != null) + { + String* pIndexText = index.GetIndexText(); + if (pIndexText != null) + { + _FastScrollEventArg* pEventArg = new (std::nothrow) _FastScrollEventArg(GetPublic(), *pIndexText); + __pFastScrollEvent->Fire(*pEventArg); + } + } +} + +void +_GroupedListViewImpl::OnDraw(void) +{ + _ControlImpl::OnDraw(); + + if (__redrawListView) + { + CheckEmptyListShowState(); + __redrawListView = false; + } +} + +void +_GroupedListViewImpl::OnBoundsChanged(void) +{ + _ControlImpl::OnBoundsChanged(); + + if (__pEmptyBitmap != null) + { + SetBitmapOfEmptyList(__pEmptyBitmap->GetBackgroundBitmap()); + } + if (__pEmptyText != null) + { + SetTextOfEmptyList(__pEmptyText->GetText()); + } + + _GroupedListViewItemProviderAdaptor* pProviderAdaptor = + static_cast <_GroupedListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor()); + + if (pProviderAdaptor != null) + { + int itemWidth = GetCore().GetBounds().width; + + if (GetCore().GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION) + { + int margin = 0; + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, margin); + + itemWidth -= (margin * 2); + } + + pProviderAdaptor->SetListWidth(itemWidth); + } +} + +void +_GroupedListViewImpl::OnFontChanged(Font* pFont) +{ + String fontName = GetFont(); + _GroupedListViewItemProviderAdaptor* pProviderAdaptor = + static_cast <_GroupedListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor()); + + if (__pEmptyText != null) + { + __pEmptyText->SetFont(fontName); + SetTextOfEmptyList(__pEmptyText->GetText()); + } + + if (pProviderAdaptor != null) + { + pProviderAdaptor->SetItemFont(fontName); + } + + int firstGroup = -1; + int firstItem = -1; + int lastGroup = -1; + int lastItem = -1; + int currentItem = -1; + int lastItemInGroup = -1; + + GetCore().GetFirstLoadedItemIndex(firstGroup, firstItem); + GetCore().GetLastLoadedItemIndex(lastGroup, lastItem); + + for (int i = firstGroup; i <= lastGroup; i++) + { + currentItem = ((i == firstGroup) ? firstItem : -1); + lastItemInGroup = ((i == lastGroup) ? lastItem : GetCore().GetItemCountAt(i)); + + for (; currentItem <= lastItemInGroup; currentItem++) + { + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(i, currentItem)); + + if (pListViewItem != null) + { + pListViewItem->SetFont(fontName); + } + } + } +} + +void +_GroupedListViewImpl::OnFontInfoRequested(unsigned long& style, int& size) +{ + int textSize = 0; + GET_SHAPE_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, textSize); + + style = FONT_STYLE_PLAIN; + size = textSize; +} + +bool +_GroupedListViewImpl::OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + FirePublicTouchEvent(touchinfo); + return false; +} + +bool +_GroupedListViewImpl::OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + FirePublicTouchEvent(touchinfo); + return false; +} + +bool +_GroupedListViewImpl::OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + FirePublicTouchEvent(touchinfo); + return false; +} + +bool +_GroupedListViewImpl::OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + FirePublicTouchEvent(touchinfo); + return false; +} + +void +_GroupedListViewImpl::FirePublicTouchEvent(const _TouchInfo& touchInfo) +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + TouchEventInfo publicTouchInfo; + + _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo); + SysTryReturnVoidResult(NID_UI, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + publicTouchInfo.Construct(*pEventArg); + + _Control* pDraggedControl = pTouchManager->GetTouchControlSource(); + + IEnumeratorT* pEnumerator = GetTouchEventListener()->GetEnumeratorN(); + if (pEnumerator) + { + while (pEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + + ITouchEventListener* pTouchEventListener = dynamic_cast (pListener); + if (pTouchEventListener) + { + FirePublicListener(*pTouchEventListener, publicTouchInfo); + + if (touchInfo.GetTouchStatus() == _TOUCH_RELEASED) + { + if (pDraggedControl == null) //if exist dragged control, don't send focus event + { + FireFocusListener(*pTouchEventListener, publicTouchInfo); + } + } + else if (touchInfo.GetTouchStatus() == _TOUCH_MOVED) + { + FireFocusListener(*pTouchEventListener, publicTouchInfo); + } + } + } + + delete pEnumerator; + } + + delete pEventArg; +} + +void +_GroupedListViewImpl::FirePublicListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo) +{ + switch (touchEventInfo.GetTouchStatus()) + { + case TOUCH_PRESSED: + listener.OnTouchPressed(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_LONG_PRESSED: + listener.OnTouchLongPressed(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_RELEASED: + listener.OnTouchReleased(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_MOVED: + listener.OnTouchMoved(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_DOUBLE_PRESSED: + listener.OnTouchDoublePressed(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_FOCUS_IN: + listener.OnTouchFocusIn(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_FOCUS_OUT: + listener.OnTouchFocusOut(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_CANCELED: + listener.OnTouchCanceled(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + default: + break; + } +} + +void +_GroupedListViewImpl::FireFocusListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo) +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + Point screenPoint(pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).x, + pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).y); + + _Control* pTouchedControl = pControlManager->GetTopmostTouchedControl(screenPoint); + SysTryReturnVoidResult(NID_UI, pTouchedControl, E_INVALID_CONDITION, "[E_INVALID_CONDITION] pTouchedControl is null."); + + if (pTouchManager->GetFocusedControlSource() != pTouchedControl) + { + if (&(GetCore()) != pTouchedControl) + { + if (pTouchManager->GetFocusedControlSource() == &(GetCore())) + { + listener.OnTouchFocusOut(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + } + } + else + { + listener.OnTouchFocusIn(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + } + + pTouchManager->SetFocusedControlSource(*pTouchedControl); + } +} + +_TouchEventArg* +_GroupedListViewImpl::GetTouchEventArgN(const _TouchInfo& touchInfo) +{ + Point startPoint; + + _TouchEventArg* pEventArg = new (std::nothrow) _TouchEventArg(GetPublic(), touchInfo.GetTouchStatus()); + SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryCatch(NID_UI, pTouchManager, , E_SYSTEM, "[E_SYSTEM] System error occurred."); + + startPoint.SetPosition(pTouchManager->GetStartPoint(touchInfo.GetPointId()).x - GetCore().GetAbsoluteBounds().x, + pTouchManager->GetStartPoint(touchInfo.GetPointId()).y - GetCore().GetAbsoluteBounds().y); + + pEventArg->SetTouchPosition(touchInfo.GetPointId(), startPoint.x, startPoint.y, + touchInfo.GetCurrentPosition().x, touchInfo.GetCurrentPosition().y); + + // need to flick distance setting + + return pEventArg; + +CATCH: + delete pEventArg; + return null; +} + +class _GroupedListViewMaker + : public _UiBuilderControlMaker +{ +public: + _GroupedListViewMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + + virtual ~_GroupedListViewMaker(){}; + + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _GroupedListViewMaker* pGroupedListViewMaker = new (std::nothrow) _GroupedListViewMaker(uibuilder); + return pGroupedListViewMaker; + }; +protected: + virtual Tizen::Ui::Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + GroupedListView* pGroupedListView = null; + Rectangle rect; + + GroupedListViewStyle style = GROUPED_LIST_VIEW_STYLE_INDEXED; + String elementString; + bool itemDividerState = true; + bool fastScrollState = false; + int opacity = 100; + bool sweepEnabledState = false; + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pGroupedListView = new (std::nothrow) GroupedListView(); + if (pGroupedListView == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + + String styleString; + styleString = pControlProperty->GetStyle(); + + if (styleString.Equals(L"GROUPED_LIST_VIEW_STYLE_SECTION", false)) + { + style = GROUPED_LIST_VIEW_STYLE_SECTION; + } + else + { + style = GROUPED_LIST_VIEW_STYLE_INDEXED; + } + + //Construct + if (pControl->GetElement(L"itemDivider", elementString)) + { + if (elementString.Equals(L"true", false)) + { + itemDividerState = true; + } + else + { + itemDividerState = false; + } + } + + if (pControl->GetElement(L"fastScroll", elementString)) + { + if (elementString.Equals(L"true", false)) + { + fastScrollState = true; + } + else + { + fastScrollState = false; + } + } + + r = pGroupedListView->Construct(rect, style, itemDividerState, fastScrollState); + SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Set BackgroundsBitmap + if (pControl->GetElement("backgroundBitmapPath", elementString)) + { + Bitmap* pBackgroundBitmap = null; + pBackgroundBitmap = LoadBitmapN(elementString); + if (pBackgroundBitmap != null) + { + r = pGroupedListView->SetBackgroundBitmap(pBackgroundBitmap); + delete pBackgroundBitmap; + pBackgroundBitmap = null; + + SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + // Set Empty List + if (pControl->GetElement(L"textOfEmptyList", elementString)) + { + r = pGroupedListView->SetTextOfEmptyList(elementString); + SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (pControl->GetElement(L"colorOfEmptyListText", elementString)) + { + ConvertStringToColor(elementString, color); + r = pGroupedListView->SetTextColorOfEmptyList(color); + SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (pControl->GetElement(L"bitmapPathOfEmptyList", elementString)) + { + Bitmap* pBackgroundBitmap = null; + pBackgroundBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565); + if (pBackgroundBitmap != null) + { + r = pGroupedListView->SetBitmapOfEmptyList(pBackgroundBitmap); + delete pBackgroundBitmap; + pBackgroundBitmap = null; + + SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pGroupedListView->SetBackgroundColor(color); + SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (pControl->GetElement(L"itemDividerColor", elementString)) + { + ConvertStringToColor(elementString, color); + r = pGroupedListView->SetItemDividerColor(color); + SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (pControl->GetElement(L"sectionColor", elementString)) + { + ConvertStringToColor(elementString, color); + r = pGroupedListView->SetSectionColor(color); + SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (pControl->GetElement(L"sweepEnabled", elementString)) + { + { + if (elementString.Equals(L"true", false)) + { + sweepEnabledState = true; + } + else + { + sweepEnabledState = false; + } + } + r = pGroupedListView->SetSweepEnabled(sweepEnabledState); + SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pGroupedListView; + + CATCH: + delete pGroupedListView; + pGroupedListView = null; + return null; + } + +private: +}; // _GroupedListViewMaker + +_GroupedListViewRegister::_GroupedListViewRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"GroupedListView", _GroupedListViewMaker::GetInstance); +} + +_GroupedListViewRegister::~_GroupedListViewRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"GroupedListView"); +} +static _GroupedListViewRegister GroupedListViewRegisterToUIbuilder; +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_GroupedListViewItemProviderAdaptor.cpp b/src/ui/controls/FUiCtrl_GroupedListViewItemProviderAdaptor.cpp new file mode 100644 index 0000000..1e98f8e --- /dev/null +++ b/src/ui/controls/FUiCtrl_GroupedListViewItemProviderAdaptor.cpp @@ -0,0 +1,415 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_GroupedListViewItemProviderAdaptor.cpp + * @brief This is the implementation file for _GroupedListViewItemProviderAdaptor class. + * + * This file contains the implementation of _GroupedListViewItemProviderAdaptor class. + */ + +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_GroupedListViewItemProviderAdaptor.h" +#include "FUiCtrl_GroupItemImpl.h" +#include "FUiCtrl_IListItemCommon.h" +#include "FUiCtrl_ListItemBaseImpl.h" +#include "FUiCtrl_ListViewItem.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_GroupedListViewItemProviderAdaptor::_GroupedListViewItemProviderAdaptor(const IGroupedListViewItemProvider& provider) + : __pGroupedListViewProvider(const_cast(&provider)) + , __pEventListener(null) + , __fontName(L"") + , __groupItemAverageHeight(0) + , __itemAverageHeight(0) + , __groupItemLoadedCount(0) + , __itemLoadedCount(0) + , __countOfAllGroups(0) + , __countOfAllItems(0) + , __pItemNeedsLazyDeletion(null) +{ +} + +_GroupedListViewItemProviderAdaptor::~_GroupedListViewItemProviderAdaptor() +{ + __descriptionTextShowItem.clear(); + + SetItemNeedsLazyDeletion(null); +} + +void +_GroupedListViewItemProviderAdaptor::SetItemProvider(const IGroupedListViewItemProvider& provider) +{ + __pGroupedListViewProvider = const_cast(&provider); +} + +_IListItemCommon* +_GroupedListViewItemProviderAdaptor::LoadItem(int groupIndex, int itemIndex) +{ + ListItemBase* pItemBase = null; + GroupItem* pGroupItem = null; + _TableViewItem* pTableViewItem = null; + + if (itemIndex == -1) + { + pGroupItem = __pGroupedListViewProvider->CreateGroupItem(groupIndex, GetListWidth()); + if (pGroupItem == null) + { + pTableViewItem = GetDefaultItem(); + pTableViewItem->SetAppInfo(null); + + return pTableViewItem; + } + } + else + { + pItemBase = __pGroupedListViewProvider->CreateItem(groupIndex, itemIndex, GetListWidth()); + if (pItemBase == null) + { + pTableViewItem = GetDefaultItem(); + pTableViewItem->SetAppInfo(null); + + return pTableViewItem; + } + } + + _ListItemBaseImpl* pItemBaseImpl = null; + if (itemIndex == -1) + { + pItemBaseImpl = static_cast<_ListItemBaseImpl*>(_GroupItemImpl::GetInstance(*pGroupItem)); + } + else + { + pItemBaseImpl = _ListItemBaseImpl::GetInstance(*pItemBase); + } + SysAssert(pItemBaseImpl != null); + + // add ListViewItem event listener + pItemBaseImpl->AddListViewItemEventListener(*__pEventListener); + + _ListViewItem* pListViewItem = pItemBaseImpl->GetListViewItem(); + SysAssert(pListViewItem != null); + + pListViewItem->SetFont(__fontName); + pListViewItem->AddRef(); + pListViewItem->SetItemStyle(static_cast(pItemBaseImpl->GetListItemAnnexStyle())); + pListViewItem->SetItemWidth(GetListWidth()); + + if (itemIndex == -1) + { + pListViewItem->SetAppInfo(pGroupItem); + + if (__groupItemLoadedCount < __countOfAllGroups) + { + __groupItemAverageHeight = (__groupItemAverageHeight * __groupItemLoadedCount + pListViewItem->GetItemHeight()) / (__groupItemLoadedCount + 1); + __groupItemLoadedCount++; + } + } + else + { + pListViewItem->SetAppInfo(pItemBase); + + if (__itemLoadedCount < __countOfAllItems) + { + __itemAverageHeight = (__itemAverageHeight * __itemLoadedCount + pListViewItem->GetItemHeight()) / (__itemLoadedCount + 1); + __itemLoadedCount++; + } + } + + if (IsDescriptionTextShown(groupIndex, itemIndex) == true) + { + pListViewItem->SetDescriptionTextShowState(true); + } + + return pListViewItem; +} + +result +_GroupedListViewItemProviderAdaptor::UnloadItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, pListItem != null, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] pListItem is invalid argument."); + + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(pListItem); + if (pListViewItem->GetParent() != null) + { + pListViewItem->GetParent()->DetachChild(*pListViewItem); + } + + // default item case + if (pListViewItem == GetDefaultItem()) + { + return E_SUCCESS; + } + + if (pListViewItem == __pItemNeedsLazyDeletion) + { + pListViewItem->AddRef(); + } + + if (pListViewItem->Release() != 0) + { + if (itemIndex == -1) + { + GroupItem* pGroupItem = static_cast(pListViewItem->GetAppInfo()); + if (__pGroupedListViewProvider->DeleteGroupItem(groupIndex, pGroupItem, GetListWidth()) == false) + { + delete pGroupItem; + } + } + else + { + ListItemBase* pItemBase = static_cast(pListViewItem->GetAppInfo()); + if (__pGroupedListViewProvider->DeleteItem(groupIndex, itemIndex, pItemBase, GetListWidth()) == false) + { + delete pItemBase; + } + } + } + + return E_SUCCESS; +} + +result +_GroupedListViewItemProviderAdaptor::DeleteItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, pListItem != null, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] pListItem is invalid argument."); + + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(pListItem); + if (pListViewItem->GetParent() != null) + { + pListViewItem->GetParent()->DetachChild(*pListViewItem); + } + + // default item case + if (pListViewItem == GetDefaultItem()) + { + return E_SUCCESS; + } + + if (pListViewItem == __pItemNeedsLazyDeletion) + { + pListViewItem->AddRef(); + } + + if (pListViewItem->Release() != 0) + { + if (itemIndex == -1) + { + GroupItem* pGroupItem = static_cast(pListViewItem->GetAppInfo()); + delete pGroupItem; + } + else + { + ListItemBase* pItemBase = static_cast(pListViewItem->GetAppInfo()); + delete pItemBase; + } + } + + return E_SUCCESS; +} + +bool +_GroupedListViewItemProviderAdaptor::UpdateItem(_IListItemCommon* pItem, int groupIndex, int itemIndex) +{ + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(pItem); + + if (pListViewItem != null) + { + pListViewItem->SetDescriptionTextShowState(IsDescriptionTextShown(groupIndex, itemIndex)); + } + + return true; +} + +int +_GroupedListViewItemProviderAdaptor::GetItemCount(int groupIndex) const +{ + _GroupedListViewItemProviderAdaptor* pItemProviderAdaptor = const_cast<_GroupedListViewItemProviderAdaptor*>(this); + int itemCount = __pGroupedListViewProvider->GetItemCount(groupIndex); + + if (__groupItemLoadedCount <= groupIndex) + { + pItemProviderAdaptor->__countOfAllItems += itemCount; + } + + return itemCount; +} + +int +_GroupedListViewItemProviderAdaptor::GetGroupCount(void) const +{ + _GroupedListViewItemProviderAdaptor* pItemProviderAdaptor = const_cast<_GroupedListViewItemProviderAdaptor*>(this); + pItemProviderAdaptor->__countOfAllGroups = __pGroupedListViewProvider->GetGroupCount(); + + return __countOfAllGroups; +} + +int +_GroupedListViewItemProviderAdaptor::GetDefaultItemHeight(void) +{ + return __itemAverageHeight; +} + +int +_GroupedListViewItemProviderAdaptor::GetDefaultGroupItemHeight(void) +{ + return __groupItemAverageHeight; +} + +bool +_GroupedListViewItemProviderAdaptor::IsReorderable(int groupIndexFrom, int groupIndexTo) +{ + return __pGroupedListViewProvider->IsReorderable(groupIndexFrom, groupIndexTo); +} + +bool +_GroupedListViewItemProviderAdaptor::HasSectionHeader(int groupIndex) const +{ + return true; +} + +bool +_GroupedListViewItemProviderAdaptor::HasSectionFooter(int groupIndex) const +{ + return false; +} + +bool +_GroupedListViewItemProviderAdaptor::SetDescriptionTextShowState(int groupIndex, int itemIndex, bool show) +{ + _ListItemPos descriptionTextPos = {groupIndex, itemIndex}; + int idxDescriptionTextGroup = -1; + int idxDescriptionTextItem = -1; + + _LinkedList <_ListItemPos>::_Iterator theIter = __descriptionTextShowItem.begin(); + while (theIter != __descriptionTextShowItem.end()) + { + idxDescriptionTextGroup = theIter->groupIndex; + idxDescriptionTextItem = theIter->itemIndex; + + if (idxDescriptionTextGroup == groupIndex) + { + if (idxDescriptionTextItem == itemIndex) + { + if (show == false) + { + __descriptionTextShowItem.erase(theIter); + } + return true; + } + else if (idxDescriptionTextItem > itemIndex) + { + if (show == true) + { + __descriptionTextShowItem.insert(theIter, descriptionTextPos); + } + return true; + } + } + + if (idxDescriptionTextGroup > groupIndex) + { + if (show == true) + { + __descriptionTextShowItem.insert(theIter, descriptionTextPos); + } + return true; + } + + theIter++; + } + + if (show == true) + { + __descriptionTextShowItem.push_back(descriptionTextPos); + } + + return true; +} + +bool +_GroupedListViewItemProviderAdaptor::IsDescriptionTextShown(int groupIndex, int itemIndex) const +{ + int idxDescriptionTextGroup = -1; + int idxDescriptionTextItem = -1; + + _LinkedList <_ListItemPos>::_Iterator theIter = __descriptionTextShowItem.begin(); + while (theIter != __descriptionTextShowItem.end()) + { + idxDescriptionTextGroup = theIter->groupIndex; + idxDescriptionTextItem = theIter->itemIndex; + + if (idxDescriptionTextGroup == groupIndex) + { + if (idxDescriptionTextItem == itemIndex) + { + return true; + } + else if (idxDescriptionTextItem > itemIndex) + { + return false; + } + } + else if (idxDescriptionTextGroup > groupIndex) + { + return false; + } + + theIter++; + } + + return false; +} + +void +_GroupedListViewItemProviderAdaptor::SetListViewItemEventListener(_IUiListViewItemEventListener& listener) +{ + __pEventListener = &listener; +} + +void +_GroupedListViewItemProviderAdaptor::SetItemFont(const String& fontName) +{ + __fontName = fontName; +} + +void +_GroupedListViewItemProviderAdaptor::SetItemNeedsLazyDeletion(_ListViewItem* pItem) +{ + if (__pItemNeedsLazyDeletion != pItem) + { + if (__pItemNeedsLazyDeletion != null) + { + __pItemNeedsLazyDeletion->Release(); + } + + __pItemNeedsLazyDeletion = pItem; + } +} +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_HeaderImpl.cpp b/src/ui/controls/FUiCtrl_HeaderImpl.cpp new file mode 100644 index 0000000..944e20c --- /dev/null +++ b/src/ui/controls/FUiCtrl_HeaderImpl.cpp @@ -0,0 +1,2179 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_HeaderImpl.cpp + * @brief This is the implementation file for the _HeaderImpl class. + */ + +#include +#include +#include "FUi_Control.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EcoreEvas.h" +#include "FUi_ResourceManager.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_ButtonItemImpl.h" +#include "FUiCtrl_HeaderImpl.h" +#include "FUiCtrl_HeaderItemImpl.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_PanelImpl.h" +#include "FUiCtrl_PublicActionEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_HeaderImpl* +_HeaderImpl::CreateHeaderImplN(Header* pControl) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _Toolbar* pCore = null; + + pCore = _Toolbar::CreateToolbarN(true); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->InitializeLongPressGesture(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _HeaderImpl* pHeaderImpl = new (std::nothrow) _HeaderImpl(pControl, pCore); + + r = CheckConstruction(pCore, pHeaderImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pHeaderImpl; +} + +_HeaderImpl::_HeaderImpl(Header* pPublic, _Toolbar* pCore) + : _ControlImpl(pPublic, pCore) + , __style(HEADER_STYLE_TITLE) + , __pPublicActionEvent(null) + //, __calledBySetItemSelected(false) +{ + result r = GetLastResult(); // Check if _ControlImpl succeeded. + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCore->SetStyle(TOOLBAR_TITLE); + + Color tempColor = Color(0); + + GET_COLOR_CONFIG(HEADER::BG_NORMAL, tempColor); + pCore->SetColor(tempColor); +} + +_HeaderImpl::~_HeaderImpl(void) +{ + if (__pPublicActionEvent) + { + delete __pPublicActionEvent; + __pPublicActionEvent = null; + } +} + +Header* +_HeaderImpl::GetHeader(void) const +{ + return &const_cast (GetPublic()); +} + +const char* +_HeaderImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::Header"; +} + +const Header& +_HeaderImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +Header& +_HeaderImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _Toolbar& +_HeaderImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_Toolbar& +_HeaderImpl::GetCore(void) +{ + return static_cast<_Toolbar&>(_ControlImpl::GetCore()); +} + +const _HeaderImpl* +_HeaderImpl::GetInstance(const Header& header) +{ + return static_cast (header._pControlImpl); +} + +_HeaderImpl* +_HeaderImpl::GetInstance(Header& header) +{ + return static_cast<_HeaderImpl*> (header._pControlImpl); +} + +result +_HeaderImpl::AddItem(const HeaderItem& item) +{ + SysTryReturnResult(NID_UI_CTRL, (__style != HEADER_STYLE_TITLE), E_SYSTEM, "[E_SYSTEM] Unable to add the item because the current style does not support it."); + + result r = CheckItemValidate(item); + + if (IsFailed(r)) + { + return r; + } + + if (__style == HEADER_STYLE_TITLE_BUTTON && GetItemCount() >= 1) + { + SysLogException(NID_UI_CTRL, E_MAX_EXCEEDED, "[E_MAX_EXCEEDED] Only 1 HeaderItem can be added to HEADER_STYLE_TITLE_BUTTON "); + return E_MAX_EXCEEDED; + } + + _Button* pButton = ConvertHeaderItem(item); + + if (__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE + || __style == HEADER_STYLE_TAB || __style == HEADER_STYLE_TAB_WITH_TITLE) + { + pButton->SetButtonStyle(_BUTTON_STYLE_SEGMENT); + } + + return GetCore().AddItem(pButton); +} + +ButtonItemStatus +_HeaderImpl::GetButtonStatus(ButtonPosition position) const +{ + bool isButtonSet = IsButtonSet(position); + + SysTryReturn(NID_UI_CTRL, isButtonSet == true, BUTTON_ITEM_STATUS_NORMAL, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] No button item is set at the specified position."); + + _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL; + + if (position == BUTTON_POSITION_LEFT) + { + buttonStatus = GetCore().GetButtonStatus(LEFT_BUTTON); + } + else if (position == BUTTON_POSITION_RIGHT) + { + buttonStatus = GetCore().GetButtonStatus(RIGHT_BUTTON); + } + + return ConvertButtonItemStatus(buttonStatus); +} + +Color +_HeaderImpl::GetButtonColor(ButtonItemStatus status) const +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().GetButtonColor(tempStatus); +} + +Color +_HeaderImpl::GetButtonTextColor(ButtonItemStatus status) const +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().GetButtonTextColor(tempStatus); +} + +String +_HeaderImpl::GetDescriptionText(void) const +{ + return GetCore().GetDescriptionText(); +} + +Color +_HeaderImpl::GetDescriptionTextColor(void) const +{ + return GetCore().GetDescriptionTextColor(); +} + +Color +_HeaderImpl::GetItemColor(HeaderItemStatus status) const +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().GetItemColor(tempStatus); +} + +int +_HeaderImpl::GetItemCount(void) const +{ + return GetCore().GetItemCount(); +} + +result +_HeaderImpl::GetItemStatus(int itemIndex, HeaderItemStatus& status) const +{ + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex <= count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + _Button* pButton = GetCore().GetItem(itemIndex); + + SysTryReturnResult(NID_UI_CTRL, pButton, E_SYSTEM, "[E_SYSTEM] Unable to get the item status."); + + status = ConvertHeaderItemStatus(pButton->GetButtonStatus()); + + return E_SUCCESS; +} + +Color +_HeaderImpl::GetItemTextColor(HeaderItemStatus status) const +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().GetItemTextColor(tempStatus); +} + +HeaderStyle +_HeaderImpl::GetStyle(void) const +{ + return __style; +} + +int +_HeaderImpl::GetSelectedItemIndex(void) const +{ + SysTryReturn(NID_UI_CTRL, (__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE + || __style == HEADER_STYLE_TAB || __style == HEADER_STYLE_TAB_WITH_TITLE), -1, + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Unable to get the selected item index because the current style does not support it.") + + return GetCore().GetSelectedItemIndex(); +} + +String +_HeaderImpl::GetTitleText(void) const +{ + return GetCore().GetTitleText(); +} + +Color +_HeaderImpl::GetTitleTextColor(void) const +{ + return GetCore().GetTitleTextColor(); +} + +Color +_HeaderImpl::GetColor(void) const +{ + return GetCore().GetColor(); +} + +result +_HeaderImpl::InsertItemAt(int itemIndex, const HeaderItem& item) +{ + result r = CheckItemValidate(item); + + if (IsFailed(r)) + { + return r; + } + + SysTryReturnResult(NID_UI_CTRL, (__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE + || __style == HEADER_STYLE_TAB || __style == HEADER_STYLE_TAB_WITH_TITLE || __style == HEADER_STYLE_BUTTON), E_SYSTEM, + "[E_SYSTEM] Unable to add the item because the current style does not support it."); + + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex <= count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + _Button* pButton = ConvertHeaderItem(item); + + pButton->SetButtonStyle(_BUTTON_STYLE_SEGMENT); + + return GetCore().InsertItemAt(itemIndex, pButton); +} + +bool +_HeaderImpl::IsButtonSet(ButtonPosition position) const +{ + if (position == BUTTON_POSITION_LEFT) + { + return GetCore().IsButtonSet(LEFT_BUTTON); + } + else if (position == BUTTON_POSITION_RIGHT) + { + return GetCore().IsButtonSet(RIGHT_BUTTON); + } + + return false; +} + +result +_HeaderImpl::PlayWaitingAnimation(HeaderAnimationPosition animationPos) +{ + if ((__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_TITLE_BUTTON || __style == HEADER_STYLE_BUTTON || __style == HEADER_STYLE_TAB) + && animationPos == HEADER_ANIMATION_POSITION_TITLE) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Unable to pause the waiting animation because the current style does not support it."); + return E_INVALID_OPERATION; + } + + if ((IsButtonSet(BUTTON_POSITION_LEFT) == false && animationPos == HEADER_ANIMATION_POSITION_BUTTON_LEFT) + || (IsButtonSet(BUTTON_POSITION_RIGHT) == false && animationPos == HEADER_ANIMATION_POSITION_BUTTON_RIGHT)) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] Unable to play the waiting animation because no button is set at the specified position."); + return E_INVALID_OPERATION; + } + + ToolbarAnimationPosition toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_TITLE; + + if (animationPos == HEADER_ANIMATION_POSITION_TITLE) + { + toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_TITLE; + } + else if (animationPos == HEADER_ANIMATION_POSITION_BUTTON_LEFT) + { + toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT; + } + else if (animationPos == HEADER_ANIMATION_POSITION_BUTTON_RIGHT) + { + toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT; + } + + return GetCore().PlayWaitingAnimation(toolbarAnimPos); +} + +result +_HeaderImpl::StopWaitingAnimation(HeaderAnimationPosition animationPos) +{ + if ((__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_TITLE_BUTTON || __style == HEADER_STYLE_BUTTON || __style == HEADER_STYLE_TAB) + && animationPos == HEADER_ANIMATION_POSITION_TITLE) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] A Header in this style doesn't support title animation."); + return E_INVALID_OPERATION; + } + + SysTryReturnResult(NID_UI_CTRL, (GetWaitingAnimationStatus(animationPos) != ANIMATION_STOPPED), E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The animation is not playing currently."); + + ToolbarAnimationPosition toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_TITLE; + + if (animationPos == HEADER_ANIMATION_POSITION_TITLE) + { + toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_TITLE; + } + else if (animationPos == HEADER_ANIMATION_POSITION_BUTTON_LEFT) + { + toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT; + } + else if (animationPos == HEADER_ANIMATION_POSITION_BUTTON_RIGHT) + { + toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT; + } + + return GetCore().StopWaitingAnimation(toolbarAnimPos); +} + +result +_HeaderImpl::PauseWaitingAnimation(HeaderAnimationPosition animationPos) +{ + if ((__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_TITLE_BUTTON || __style == HEADER_STYLE_BUTTON || __style == HEADER_STYLE_TAB) + && animationPos == HEADER_ANIMATION_POSITION_TITLE) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Unable to pause the waiting animation because the current style does not support it."); + return E_INVALID_OPERATION; + } + + SysTryReturnResult(NID_UI_CTRL, (GetWaitingAnimationStatus(animationPos) != ANIMATION_STOPPED), E_INVALID_OPERATION, + "[E_INVALID_OPERATION] No waiting animation is in progress at the specified position."); + + SysTryReturnResult(NID_UI_CTRL, + (animationPos >= HEADER_ANIMATION_POSITION_TITLE && animationPos <= HEADER_ANIMATION_POSITION_BUTTON_RIGHT), + E_INVALID_ARG, "[E_INVALID_ARG] The animationPos is invalid"); + + ToolbarAnimationPosition toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_TITLE; + + if (animationPos == HEADER_ANIMATION_POSITION_TITLE) + { + toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_TITLE; + } + else if (animationPos == HEADER_ANIMATION_POSITION_BUTTON_LEFT) + { + toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT; + } + else if (animationPos == HEADER_ANIMATION_POSITION_BUTTON_RIGHT) + { + toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT; + } + + return GetCore().PauseWaitingAnimation(toolbarAnimPos); +} + +AnimationStatus +_HeaderImpl::GetWaitingAnimationStatus(HeaderAnimationPosition animationPos) const +{ + ToolbarAnimationPosition toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_TITLE; + + if (HEADER_ANIMATION_POSITION_TITLE == animationPos) + { + toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_TITLE; + } + else if (animationPos == HEADER_ANIMATION_POSITION_BUTTON_LEFT) + { + toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT; + } + else if (animationPos == HEADER_ANIMATION_POSITION_BUTTON_RIGHT) + { + toolbarAnimPos = TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT; + } + + return GetCore().GetWaitingAnimationStatus(toolbarAnimPos); +} + +result +_HeaderImpl::RemoveAllButtons(void) +{ + return GetCore().RemoveAllButtons(); +} + +result +_HeaderImpl::RemoveAllItems(void) +{ + return GetCore().RemoveAllItems(); +} + +result +_HeaderImpl::RemoveItemAt(int itemIndex) +{ + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex <= count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + + return GetCore().RemoveItemAt(itemIndex); +} + +result +_HeaderImpl::RemoveButtonAt(ButtonPosition position) +{ + if (BUTTON_POSITION_LEFT == position) + { + return GetCore().RemoveButtonAt(LEFT_BUTTON); + } + else if (BUTTON_POSITION_RIGHT == position) + { + return GetCore().RemoveButtonAt(RIGHT_BUTTON); + } + + return E_SUCCESS; +} + +result +_HeaderImpl::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + return GetCore().SetBackgroundBitmap(*pBitmap); +} + +result +_HeaderImpl::SetButton(ButtonPosition position, const ButtonItem& button) +{ + SysTryReturnResult(NID_UI_CTRL, (!(__style == HEADER_STYLE_TAB || __style == HEADER_STYLE_TAB_WITH_TITLE)), E_INVALID_OPERATION, + "[E_INVALID_OPERATION] This operation is not supported."); + + SysTryReturnResult(NID_UI_CTRL, (button.GetActionId() >= HEADER_ACTION_ID_MIN && button.GetActionId() <= HEADER_ACTION_ID_MAX), + E_INVALID_ARG, "[E_INVALID_ARG] The actionId is invalid."); + + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (count <= HEADER_MAX_ITEM_COUNT_WITH_BUTTON), E_SYSTEM, + "[E_SYSTEM] If the item count is larger then 4, no button can be set."); + + SysTryReturnResult(NID_UI_CTRL, (position == BUTTON_POSITION_LEFT || position == BUTTON_POSITION_RIGHT), E_INVALID_ARG, + "[E_INVALID_ARG] The position is invalid."); + + _Button* pButton = ConvertButtonItem(button); + + if (position == BUTTON_POSITION_LEFT) + { + return GetCore().SetButton(LEFT_BUTTON, pButton); + } + else if (position == BUTTON_POSITION_RIGHT) + { + return GetCore().SetButton(RIGHT_BUTTON, pButton); + } + + return E_SUCCESS; +} + +result +_HeaderImpl::SetButtonColor(ButtonItemStatus status, const Color& color) +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().SetButtonColor(tempStatus, color); +} + +result +_HeaderImpl::SetButtonEnabled(ButtonPosition position, bool enable) +{ + bool isButtonSet = IsButtonSet(position); + + SysTryReturnResult(NID_UI_CTRL, isButtonSet, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] No button item is set at the specified position."); + + if (position == BUTTON_POSITION_LEFT) + { + GetCore().SetButtonEnabled(LEFT_BUTTON, enable); + } + else if (position == BUTTON_POSITION_RIGHT) + { + GetCore().SetButtonEnabled(RIGHT_BUTTON, enable); + } + + return E_SUCCESS; +} + +result +_HeaderImpl::SetButtonTextColor(ButtonItemStatus status, const Color& color) +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().SetButtonTextColor(tempStatus, color); +} + +result +_HeaderImpl::SetButtonBadgeIcon(ButtonPosition position, const Bitmap* pBadgeIcon) +{ + SysTryReturnResult(NID_UI_CTRL, (position == BUTTON_POSITION_LEFT || position == BUTTON_POSITION_RIGHT), E_SYSTEM, + "[E_SYSTEM] The position is invalid."); + + bool isButtonSet = IsButtonSet(position); + + SysTryReturnResult(NID_UI_CTRL, isButtonSet, E_INVALID_STATE, + "[E_INVALID_STATE] No button item is set at the specified position."); + + if (position == BUTTON_POSITION_LEFT) + { + return GetCore().SetButtonBadgeIcon(LEFT_BUTTON, pBadgeIcon); + } + else + { + return GetCore().SetButtonBadgeIcon(RIGHT_BUTTON, pBadgeIcon); + } +} + +result +_HeaderImpl::SetButtonNumberedBadgeIcon(ButtonPosition position, int number) +{ + SysTryReturnResult(NID_UI_CTRL, (position == BUTTON_POSITION_LEFT || position == BUTTON_POSITION_RIGHT), E_SYSTEM, + "[E_SYSTEM] The position is invalid."); + + bool isButtonSet = IsButtonSet(position); + + SysTryReturnResult(NID_UI_CTRL, isButtonSet, E_INVALID_STATE, + "[E_INVALID_STATE] No button item is set at the specified position."); + + SysTryReturnResult(NID_UI_CTRL, (0 <= number && number <= HEADER_NUMBERD_BADGE_ICON_NUMBER_MAX), E_INVALID_ARG, + "[E_INVALID_ARG] The number is invalid."); + + if (position == BUTTON_POSITION_LEFT) + { + return GetCore().SetButtonNumberedBadgeIcon(LEFT_BUTTON, number); + } + else + { + return GetCore().SetButtonNumberedBadgeIcon(RIGHT_BUTTON, number); + } +} + +result +_HeaderImpl::SetItemAt(int itemIndex, const HeaderItem& item) +{ + SysTryReturnResult(NID_UI_CTRL, (item.GetActionId() != -1), E_INVALID_ARG, "[E_INVALID_ARG] The HeaderItem isn't constructed."); + + if (item.GetActionId() < HEADER_ACTION_ID_MIN || item.GetActionId() > HEADER_ACTION_ID_MAX) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] The actionId is invalid."); + return E_INVALID_ARG; + } + + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex <= count && __style != HEADER_STYLE_TITLE), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + _Button* pButton = ConvertHeaderItem(item); + + if (__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE + || __style == HEADER_STYLE_TAB || __style == HEADER_STYLE_TAB_WITH_TITLE) + { + pButton->SetButtonStyle(_BUTTON_STYLE_SEGMENT); + } + + return GetCore().SetItemAt(itemIndex, pButton); +} + +result +_HeaderImpl::SetItemBadgeIcon(int itemIndex, const Bitmap* pBadgeIcon) +{ + SysTryReturnResult(NID_UI_CTRL, (__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE + || __style == HEADER_STYLE_TAB || __style == HEADER_STYLE_TAB_WITH_TITLE || __style == HEADER_STYLE_BUTTON), + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Unable to set the badge icon because the current style does not support it."); + + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + return GetCore().SetItemBadgeIcon(itemIndex, pBadgeIcon); +} + +result +_HeaderImpl::SetItemNumberedBadgeIcon(int itemIndex, int number) +{ + SysTryReturnResult(NID_UI_CTRL, (__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE + || __style == HEADER_STYLE_TAB || __style == HEADER_STYLE_TAB_WITH_TITLE || __style == HEADER_STYLE_BUTTON), + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Unable to set the badge icon because the current style does not support it."); + + SysTryReturnResult(NID_UI_CTRL, (0 <= number && number <= HEADER_NUMBERD_BADGE_ICON_NUMBER_MAX), E_INVALID_ARG, + "[E_INVALID_ARG] The number is invalid."); + + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + return GetCore().SetItemNumberedBadgeIcon(itemIndex, number); +} + +result +_HeaderImpl::SetItemColor(HeaderItemStatus status, const Color& color) +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().SetItemColor(tempStatus, color); +} + +result +_HeaderImpl::SetItemEnabled(int itemIndex, bool enable) +{ + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (count != 0), E_SYSTEM, "[E_SYSTEM] No item to be enabled exists.") + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + // Selected item cannot be disabled. + int selectedItemIndex = GetSelectedItemIndex(); + + if (__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE || __style == HEADER_STYLE_TAB || __style == HEADER_STYLE_TAB_WITH_TITLE) + { + if ((selectedItemIndex == itemIndex && enable == false) || (selectedItemIndex == -1 && itemIndex == 0 && enable == false)) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The Selected item cannot be disabled."); + return E_INVALID_OPERATION; + } + } + + return GetCore().SetItemEnabled(itemIndex, enable); +} + +result +_HeaderImpl::SetItemTextColor(HeaderItemStatus status, const Color& color) +{ + _ButtonStatus tempStatus = ConvertButtonStatus(status); + + return GetCore().SetItemTextColor(tempStatus, color); +} + +result +_HeaderImpl::SetItemSelected(int itemIndex) +{ + SysTryReturnResult(NID_UI_CTRL, (__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE + || __style == HEADER_STYLE_TAB || __style == HEADER_STYLE_TAB_WITH_TITLE), + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Unable to select the item because the current style does not support it."); + + int count = GetItemCount(); + + SysTryReturnResult(NID_UI_CTRL, (count != 0 && itemIndex >= 0 && itemIndex < count), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + // Disabled items can not be selected. + HeaderItemStatus status; + + result r = GetItemStatus(itemIndex, status); + + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[E_INVALID_STATE] Failed to get item status."); + + SysTryReturnResult(NID_UI_CTRL, (status != HEADER_ITEM_STATUS_DISABLED), E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The disabled item can not be selected."); + + //__calledBySetItemSelected = true; + + return GetCore().SetItemSelected(itemIndex); +} + +result +_HeaderImpl::SetColor(const Color& color) +{ + return GetCore().SetColor(color); +} + +result +_HeaderImpl::SetStyle(HeaderStyle style) +{ + RemoveAllItems(); + RemoveAllButtons(); + + __style = style; + + return GetCore().SetStyle(ConvertHeaderStyle(__style)); +} + +result +_HeaderImpl::SetTitleIcon(const Bitmap* pIcon) +{ + SysTryReturnResult(NID_UI_CTRL, (__style == HEADER_STYLE_TITLE || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE + || __style == HEADER_STYLE_TAB_WITH_TITLE), + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Unable to set the title icon because the current style does not support it."); + + return GetCore().SetTitleIcon(*pIcon); +} + +result +_HeaderImpl::SetTitleText(const String& text) +{ + SysTryReturnResult(NID_UI_CTRL, (__style == HEADER_STYLE_TITLE || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE + || __style == HEADER_STYLE_TAB_WITH_TITLE), + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Unable to set the title icon because the current style does not support it."); + + return GetCore().SetTitleText(text); +} + +result +_HeaderImpl::SetTitleTextColor(const Color& color) +{ + SysTryReturnResult(NID_UI_CTRL, (__style == HEADER_STYLE_TITLE || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE + || __style == HEADER_STYLE_TAB_WITH_TITLE), + E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Unable to set the title icon because the current style does not support it."); + + return GetCore().SetTitleTextColor(color); +} + +result +_HeaderImpl::SetTransparent(bool transparent) +{ + return GetCore().SetTransparent(transparent); +} + +result +_HeaderImpl::SetDescriptionText(const String& text) +{ + SysTryReturnResult(NID_UI_CTRL, (__style == HEADER_STYLE_TITLE), E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] Unable to set the description text icon because the current style does not support it."); + + return GetCore().SetDescriptionText(text); +} + +result +_HeaderImpl::SetDescriptionTextColor(const Color& color) +{ + SysTryReturnResult(NID_UI_CTRL, (__style == HEADER_STYLE_TITLE), E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] Unable to set the description text icon because the current style does not support it."); + + return GetCore().SetDescriptionTextColor(color); +} + +bool +_HeaderImpl::IsTabEditModeEnabled(void) const +{ + return GetCore().IsTabEditModeEnabled(); +} + +result +_HeaderImpl::SetTabEditModeEnabled(bool enable) +{ + SysTryReturnResult(NID_UI_CTRL, (__style == HEADER_STYLE_TAB || __style == HEADER_STYLE_TAB_WITH_TITLE), E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] This operation is only for HEADER_STYLE_TAB."); + + return GetCore().SetTabEditModeEnabled(enable); +} + +result +_HeaderImpl::SetBackButton(void) +{ + SysTryReturnResult(NID_UI_CTRL, (__style == HEADER_STYLE_BUTTON), E_UNSUPPORTED_OPERATION, + "[E_UNSUPPORTED_OPERATION] The current Header style does not support the operation."); + + _Button* pButton = _Button::CreateButtonN(); + + int buttonHeight = 0; + int buttonWidth = 0; + + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_HEIGHT, GetCore().GetOrientation(), buttonHeight); + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetCore().GetOrientation(), buttonWidth); + + pButton->SetSize(Dimension(buttonWidth, buttonHeight)); + + Bitmap* pBackgroundBaseBitmap = null; + Bitmap* pPressedBitmap = null; + Bitmap* pColorReplacedBitmap = null; + Bitmap* pIconBaseBitmap = null; + Bitmap* pIconBaseEffectBitmap = null; + + GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBackgroundBaseBitmap); + GET_BITMAP_CONFIG_N(FOOTER::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedBitmap); + GET_BITMAP_CONFIG_N(FOOTER::BACK_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pIconBaseBitmap); + GET_BITMAP_CONFIG_N(FOOTER::BACK_ICON_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pIconBaseEffectBitmap); + + if (pBackgroundBaseBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBaseBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_NORMAL)); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBaseBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_HIGHLIGHTED)); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBaseBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_DISABLED)); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + delete pBackgroundBaseBitmap; + } + + //# if (pBackgroundEffectBitmap) + //# { + //# pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *pBackgroundEffectBitmap); + //# pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pBackgroundEffectBitmap); + //# pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_DISABLED, *pBackgroundEffectBitmap); + //# delete pBackgroundEffectBitmap; + //# } + + if (pPressedBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_PRESSED)); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + delete pPressedBitmap; + } + + //# if (pPressedEffectBitmap) + //# { + //# pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *pPressedEffectBitmap); + //# delete pPressedEffectBitmap; + //# } + + if (pIconBaseBitmap) + { + Color normalColor; + Color pressedColor; + Color disabledColor; + + GET_COLOR_CONFIG(FOOTER::BACK_ICON_NORMAL, normalColor); + GET_COLOR_CONFIG(FOOTER::BACK_ICON_PRESSED, pressedColor); + GET_COLOR_CONFIG(FOOTER::BACK_ICON_DISABLED, disabledColor); + + int iconSize = 0; + + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_ICON_SIZE, GetCore().GetOrientation(), iconSize); + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pIconBaseBitmap, Color::GetColor(COLOR_ID_MAGENTA), normalColor); + if (pColorReplacedBitmap) + { + pColorReplacedBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_NORMAL, + Point((buttonWidth - iconSize) / 2, (buttonHeight - iconSize) / 2), *pColorReplacedBitmap); + + delete pColorReplacedBitmap; + } + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pIconBaseBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedColor); + if (pColorReplacedBitmap) + { + pColorReplacedBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, + Point((buttonWidth - iconSize) / 2, (buttonHeight - iconSize) / 2), *pColorReplacedBitmap); + delete pColorReplacedBitmap; + } + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pIconBaseBitmap, Color::GetColor(COLOR_ID_MAGENTA), disabledColor); + if (pColorReplacedBitmap) + { + pColorReplacedBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, + Point((buttonWidth - iconSize) / 2, (buttonHeight - iconSize) / 2), *pColorReplacedBitmap); + delete pColorReplacedBitmap; + } + + delete pIconBaseBitmap; + } + + if (pIconBaseEffectBitmap) + { + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *pIconBaseEffectBitmap); + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *pIconBaseEffectBitmap); + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_SELECTED, *pIconBaseEffectBitmap); + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pIconBaseEffectBitmap); + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_DISABLED, *pIconBaseEffectBitmap); + + delete pIconBaseEffectBitmap; + } + + return GetCore().SetButton(BACK_BUTTON, pButton); +} + +bool +_HeaderImpl::IsBackButtonSet(void) const +{ + return GetCore().IsButtonSet(BACK_BUTTON); +} + +void +_HeaderImpl::RemoveBackButton(void) +{ + GetCore().RemoveButtonAt(BACK_BUTTON); + + return; +} + +result +_HeaderImpl::SetBackButtonEnabled(bool enable) +{ + return GetCore().SetButtonEnabled(BACK_BUTTON, enable); +} + +ButtonItemStatus +_HeaderImpl::GetBackButtonStatus(void) const +{ + SysTryReturn(NID_UI_CTRL, (IsBackButtonSet() == true), BUTTON_ITEM_STATUS_NORMAL, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] A Back button doesn't exist"); + + _ButtonStatus buttonStatus; + + buttonStatus = GetCore().GetButtonStatus(BACK_BUTTON); + + return ConvertButtonItemStatus(buttonStatus); +} + +Rectangle +_HeaderImpl::GetButtonBounds(ButtonPosition position) const +{ + bool isButtonSet = IsButtonSet(position); + + SysTryReturn(NID_UI_CTRL, isButtonSet, Rectangle(-1, -1, -1, -1), E_INVALID_OPERATION, "[E_INVALID_OPERATION] No button item is set at the specified position."); + + Rectangle rect; + + if (position == BUTTON_POSITION_LEFT) + { + rect = GetCore().GetButtonBounds(LEFT_BUTTON); + } + else if (position == BUTTON_POSITION_RIGHT) + { + rect = GetCore().GetButtonBounds(RIGHT_BUTTON); + } + + return rect; +} + +void +_HeaderImpl::AddActionEventListener(IActionEventListener& listener) +{ + if (__pPublicActionEvent == null) + { + __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + + if (IsFailed(GetLastResult())) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] System error occurred."); + delete __pPublicActionEvent; + + return; + } + } + + __pPublicActionEvent->AddListener(listener); + + GetCore().AddActionEventListener(*this); + + return; +} + +void +_HeaderImpl::RemoveActionEventListener(IActionEventListener& listener) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pPublicActionEvent, E_INVALID_STATE, "[E_INVALID_STATE] This instance isn't constructed."); + + // Todo : check fail case of RemoveListener + __pPublicActionEvent->RemoveListener(listener); + + GetCore().RemoveActionEventListener(*this); + + return; +} + +void +_HeaderImpl::OnActionPerformed(const _Control& source, int actionId) +{ + //if (__calledBySetItemSelected) + //{ + // __calledBySetItemSelected = false; + // return ; + //} + + if (GetCore().IsInitialDraw() == true && GetCore().GetSelectedItemIndex() == 0) + { + return; + } + + if (__pPublicActionEvent != null) + { + __pPublicActionEvent->Fire(*_PublicActionEvent::CreateActionEventArgN(actionId)); + } + + return; +} + +result +_HeaderImpl::CheckItemValidate(const HeaderItem& item) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (item.GetActionId() != -1), E_INVALID_ARG, "[E_INVALID_ARG] The HeaderItem isn't constructed."); + + int count = GetItemCount(); + + if (__style == HEADER_STYLE_TAB || __style == HEADER_STYLE_TAB_WITH_TITLE) + { + SysTryReturnResult(NID_UI_CTRL, (count < HEADER_TAB_STYLE_MAX_ITEM_COUNT), E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] The number of items have exceeded the maximum limit."); + } + else + { + SysTryReturnResult(NID_UI_CTRL, (count < HEADER_ITEM_MAX_COUNT), E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] The number of items have exceeded the maximum limit."); + } + + if ((HEADER_STYLE_TITLE_BUTTON == __style) && (HEADER_TITLE_BUTTON_STYLE_MAX_ITEM_COUNT <= count)) + { + SysLogException(NID_UI_CTRL, E_MAX_EXCEEDED, "[E_MAX_EXCEEDED] The number of items exceeded the maximum limit."); + r = E_MAX_EXCEEDED; + goto CATCH; + } + + if ((count >= HEADER_MAX_ITEM_COUNT_WITH_BUTTON) && + (true == IsButtonSet(BUTTON_POSITION_LEFT) || true == IsButtonSet(BUTTON_POSITION_RIGHT))) + { + SysLogException(NID_UI_CTRL, E_MAX_EXCEEDED, "[E_MAX_EXCEEDED] The number of items with button have exceeded the maximum limit."); + r = E_MAX_EXCEEDED; + goto CATCH; + } + + if (item.GetActionId() < HEADER_ACTION_ID_MIN || item.GetActionId() > HEADER_ACTION_ID_MAX) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] The actionId is invalid."); + r = E_INVALID_ARG; + goto CATCH; + } + + return (r); + +CATCH: + return (r); +} + +ToolbarStyle +_HeaderImpl::ConvertHeaderStyle(HeaderStyle style) +{ + ToolbarStyle viewStyle = TOOLBAR_TITLE; + + if (style == HEADER_STYLE_TITLE || style == HEADER_STYLE_TITLE_BUTTON) + { + viewStyle = TOOLBAR_TITLE; + } + else if (style == HEADER_STYLE_SEGMENTED) + { + viewStyle = TOOLBAR_HEADER_SEGMENTED; + } + else if (style == HEADER_STYLE_SEGMENTED_WITH_TITLE) + { + viewStyle = TOOLBAR_HEADER_SEGMENTED_WITH_TITLE; + } + else if (style == HEADER_STYLE_TAB) + { + viewStyle = TOOLBAR_TAB; + } + else if (style == HEADER_STYLE_TAB_WITH_TITLE) + { + viewStyle = TOOLBAR_TAB_WITH_TITLE; + } + else if (style == HEADER_STYLE_BUTTON) + { + viewStyle = TOOLBAR_TEXT; + } + + return viewStyle; +} + +_Button* +_HeaderImpl::ConvertButtonItem(const ButtonItem& buttonItem) +{ + _Button* pButton = _Button::CreateButtonN(); + + int buttonItemWidth = 0; + int buttonItemHeight = 0; + + if (__style == HEADER_STYLE_BUTTON) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetCore().GetOrientation(), buttonItemWidth); + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_HEIGHT, GetCore().GetOrientation(), buttonItemHeight); + } + else + { + if (__style == HEADER_STYLE_TITLE || __style == HEADER_STYLE_TITLE_BUTTON) + { + if (buttonItem.GetText() != L"") + { + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH_WITH_TEXT, GetCore().GetOrientation(), buttonItemWidth); + } + else + { + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH, GetCore().GetOrientation(), buttonItemWidth); + } + + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_HEIGHT, GetCore().GetOrientation(), buttonItemHeight); + } + else // Segmented or SegmentedTitle + { + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH_OF_SEGMENTED, GetCore().GetOrientation(), buttonItemWidth); + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_HEIGHT_OF_SEGMENTED, GetCore().GetOrientation(), buttonItemHeight); + } + } + + pButton->SetMargin(0, 0); + pButton->SetSize(Dimension(buttonItemWidth, buttonItemHeight)); + + pButton->SetActionId(buttonItem.GetActionId()); + + pButton->SetText(buttonItem.GetText()); + + pButton->SetTextMaxLine(2); + + result r = E_SUCCESS; + + int fontSize = 0; + + if (__style == HEADER_STYLE_BUTTON) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_FONT_SIZE, GetCore().GetOrientation(), fontSize); + } + else + { + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_FONT_SIZE, GetCore().GetOrientation(), fontSize); + } + + if (!IsFailed(r)) + { + pButton->SetTextSize(fontSize, FONT_STYLE_BOLD); + } + + int iconSize = 0; + + if (__style == HEADER_STYLE_BUTTON) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_ICON_SIZE, GetCore().GetOrientation(), iconSize); + } + else + { + if (__style == HEADER_STYLE_SEGMENTED_WITH_TITLE) + { + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_ICON_SIZE, GetCore().GetOrientation(), iconSize); + } + else + { + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_ICON_SIZE, GetCore().GetOrientation(), iconSize); + } + } + + Bitmap* pIconBitmap = null; + pIconBitmap = const_cast(buttonItem.__pImpl->GetIcon(BUTTON_ITEM_STATUS_NORMAL)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_NORMAL, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + } + + pIconBitmap = const_cast(buttonItem.__pImpl->GetIcon(BUTTON_ITEM_STATUS_PRESSED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + } + + pIconBitmap = const_cast(buttonItem.__pImpl->GetIcon(BUTTON_ITEM_STATUS_HIGHLIGHTED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + } + + pIconBitmap = const_cast(buttonItem.__pImpl->GetIcon(BUTTON_ITEM_STATUS_DISABLED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, + Point((buttonItemWidth - iconSize) / 2, (buttonItemHeight - iconSize) / 2), *pIconBitmap); + } + + Bitmap* pNormalBackgroundBitmap = null; + Bitmap* pColorReplacedBitmap = null; + + GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap); + + if (pNormalBackgroundBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_NORMAL)); + + if (GetCore().GetButtonColor(_BUTTON_STATUS_NORMAL).GetAlpha() != 0xFF) + { + pColorReplacedBitmap->SetAlphaConstant(GetCore().GetButtonColor(_BUTTON_STATUS_NORMAL).GetAlpha()); + } + + pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_PRESSED)); + + if (GetCore().GetButtonColor(_BUTTON_STATUS_PRESSED).GetAlpha() != 0xFF) + { + pColorReplacedBitmap->SetAlphaConstant(GetCore().GetButtonColor(_BUTTON_STATUS_PRESSED).GetAlpha()); + } + + pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_HIGHLIGHTED)); + + if (GetCore().GetButtonColor(_BUTTON_STATUS_HIGHLIGHTED).GetAlpha() != 0xFF) + { + pColorReplacedBitmap->SetAlphaConstant(GetCore().GetButtonColor(_BUTTON_STATUS_HIGHLIGHTED).GetAlpha()); + } + + pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), + GetCore().GetButtonColor(_BUTTON_STATUS_DISABLED)); + + if (GetCore().GetButtonColor(_BUTTON_STATUS_DISABLED).GetAlpha() != 0xFF) + { + pColorReplacedBitmap->SetAlphaConstant(GetCore().GetButtonColor(_BUTTON_STATUS_DISABLED).GetAlpha()); + } + + pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap); + + delete pColorReplacedBitmap; + + delete pNormalBackgroundBitmap; + } + + if (buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_NORMAL, + *buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL)); + } + if (buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_PRESSED, + *buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED)); + } + if (buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_HIGHLIGHTED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, + *buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_HIGHLIGHTED)); + } + if (buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_DISABLED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_DISABLED, + *buttonItem.__pImpl->GetBackgroundBitmap(BUTTON_ITEM_STATUS_DISABLED)); + } + + return pButton; +} + +_Button* +_HeaderImpl::ConvertHeaderItem(const HeaderItem& headerItem) +{ + _Button* pButton = _Button::CreateButtonN(); + + int minItemLength = 0; + + GET_SHAPE_CONFIG(HEADER::HEADER_ITEM_WIDTH_1_MIN, GetCore().GetOrientation(), minItemLength); + + pButton->SetSize(Dimension(minItemLength, minItemLength)); + + pButton->SetActionId(headerItem.GetActionId()); + + pButton->SetText(headerItem.GetText()); + + pButton->SetTextMaxLine(2); + + int fontSize = 0; + result r = E_SUCCESS; + + if (__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE || __style == HEADER_STYLE_TITLE_BUTTON) + { + r = GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_FONT_SIZE, GetCore().GetOrientation(), fontSize); + } + else if (__style == HEADER_STYLE_TAB || __style == HEADER_STYLE_TAB_WITH_TITLE) + { + r = GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE, GetCore().GetOrientation(), fontSize); + } + else // __style == HEADER_STYLE_BUTTON + { + r = GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_FONT_SIZE, GetCore().GetOrientation(), fontSize); + } + + if (!IsFailed(r)) + { + pButton->SetTextSize(fontSize, FONT_STYLE_BOLD); + } + + int iconSize = 0; + + if (__style == HEADER_STYLE_SEGMENTED || __style == HEADER_STYLE_SEGMENTED_WITH_TITLE || __style == HEADER_STYLE_TAB_WITH_TITLE + || __style == HEADER_STYLE_TAB) + { + if (headerItem.GetText() != L"") + { + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_ICON_SIZE_WITH_TEXT, GetCore().GetOrientation(), iconSize); + } + else + { + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_ICON_SIZE, GetCore().GetOrientation(), iconSize); + } + + Bitmap* pSelectedBitmap = null; + Bitmap* pColorReplacedBitmap = null; + Color selectedBitmapColor; + + GET_BITMAP_CONFIG_N(HEADER::TAB_ITEM_BG_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pSelectedBitmap); + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_PRESSED, selectedBitmapColor); + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSelectedBitmap, Color::GetColor(COLOR_ID_MAGENTA), selectedBitmapColor); + + if (pColorReplacedBitmap) + { + if (__style == HEADER_STYLE_SEGMENTED_WITH_TITLE || __style == HEADER_STYLE_TAB_WITH_TITLE) + { + pButton->SetToolbarSelectedBitmap(*pColorReplacedBitmap, true); + } + else + { + pButton->SetToolbarSelectedBitmap(*pColorReplacedBitmap, false); + } + + delete pColorReplacedBitmap; + + delete pSelectedBitmap; + } + } + else // __style == HEADER_STYLE_BUTTON + { + if (headerItem.GetText() != L"") + { + GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_BUTTON_STYLE_ICON_SIZE_WITH_TEXT, GetCore().GetOrientation(), iconSize); + } + else + { + GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_BUTTON_STYLE_ICON_SIZE, GetCore().GetOrientation(), iconSize); + } + } + + Bitmap* pIconBitmap = null; + + pIconBitmap = const_cast(headerItem.__pImpl->GetIcon(HEADER_ITEM_STATUS_NORMAL)); + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_NORMAL, Point(0, 0), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, Point(0, 0), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_SELECTED, Point(0, 0), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, Point(0, 0), *pIconBitmap); + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, Point(0, 0), *pIconBitmap); + } + + pIconBitmap = const_cast(headerItem.__pImpl->GetIcon(HEADER_ITEM_STATUS_PRESSED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, Point(0, 0), *pIconBitmap); + } + + pIconBitmap = const_cast(headerItem.__pImpl->GetIcon(HEADER_ITEM_STATUS_SELECTED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_SELECTED, Point(0, 0), *pIconBitmap); + } + + pIconBitmap = const_cast(headerItem.__pImpl->GetIcon(HEADER_ITEM_STATUS_HIGHLIGHTED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, Point(0, 0), *pIconBitmap); + } + + pIconBitmap = const_cast(headerItem.__pImpl->GetIcon(HEADER_ITEM_STATUS_DISABLED)); + + if (pIconBitmap) + { + pIconBitmap->Scale(Dimension(iconSize, iconSize)); + + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, Point(0, 0), *pIconBitmap); + } + + if (headerItem.__pImpl->GetBackgroundBitmap(HEADER_ITEM_STATUS_NORMAL) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_NORMAL, + *headerItem.__pImpl->GetBackgroundBitmap(HEADER_ITEM_STATUS_NORMAL)); + } + if (headerItem.__pImpl->GetBackgroundBitmap(HEADER_ITEM_STATUS_PRESSED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_PRESSED, + *headerItem.__pImpl->GetBackgroundBitmap(HEADER_ITEM_STATUS_PRESSED)); + } + if (headerItem.__pImpl->GetBackgroundBitmap(HEADER_ITEM_STATUS_SELECTED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_SELECTED, + *headerItem.__pImpl->GetBackgroundBitmap(HEADER_ITEM_STATUS_SELECTED)); + } + if (headerItem.__pImpl->GetBackgroundBitmap(HEADER_ITEM_STATUS_HIGHLIGHTED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, + *headerItem.__pImpl->GetBackgroundBitmap(HEADER_ITEM_STATUS_HIGHLIGHTED)); + } + if (headerItem.__pImpl->GetBackgroundBitmap(HEADER_ITEM_STATUS_DISABLED) != null) + { + pButton->SetToolbarItemBackgroundBitmap(_BUTTON_STATUS_DISABLED, + *headerItem.__pImpl->GetBackgroundBitmap(HEADER_ITEM_STATUS_DISABLED)); + } + + return pButton; +} + +ButtonItemStatus +_HeaderImpl::ConvertButtonItemStatus(_ButtonStatus status) const +{ + switch (status) + { + case _BUTTON_STATUS_NORMAL: + return BUTTON_ITEM_STATUS_NORMAL; + break; + + case _BUTTON_STATUS_DISABLED: + return BUTTON_ITEM_STATUS_DISABLED; + break; + + case _BUTTON_STATUS_PRESSED: + return BUTTON_ITEM_STATUS_PRESSED; + break; + + case _BUTTON_STATUS_HIGHLIGHTED: + return BUTTON_ITEM_STATUS_HIGHLIGHTED; + break; + + default: + return BUTTON_ITEM_STATUS_DISABLED; + break; + } +} + +HeaderItemStatus +_HeaderImpl::ConvertHeaderItemStatus(_ButtonStatus status) const +{ + switch (status) + { + case _BUTTON_STATUS_NORMAL: + return HEADER_ITEM_STATUS_NORMAL; + break; + + case _BUTTON_STATUS_DISABLED: + return HEADER_ITEM_STATUS_DISABLED; + break; + + case _BUTTON_STATUS_PRESSED: + return HEADER_ITEM_STATUS_PRESSED; + break; + + case _BUTTON_STATUS_HIGHLIGHTED: + return HEADER_ITEM_STATUS_HIGHLIGHTED; + break; + + case _BUTTON_STATUS_SELECTED: + return HEADER_ITEM_STATUS_SELECTED; + break; + + default: + return HEADER_ITEM_STATUS_DISABLED; + break; + } +} + +_ButtonStatus +_HeaderImpl::ConvertButtonStatus(ButtonItemStatus status) const +{ + switch (status) + { + case BUTTON_ITEM_STATUS_NORMAL: + return _BUTTON_STATUS_NORMAL; + break; + + case BUTTON_ITEM_STATUS_DISABLED: + return _BUTTON_STATUS_DISABLED; + break; + + case BUTTON_ITEM_STATUS_PRESSED: + return _BUTTON_STATUS_PRESSED; + break; + + case BUTTON_ITEM_STATUS_HIGHLIGHTED: + return _BUTTON_STATUS_HIGHLIGHTED; + break; + + default: + return _BUTTON_STATUS_DISABLED; + break; + } +} + +_ButtonStatus +_HeaderImpl::ConvertButtonStatus(HeaderItemStatus status) const +{ + switch (status) + { + case HEADER_ITEM_STATUS_NORMAL: + return _BUTTON_STATUS_NORMAL; + break; + + case HEADER_ITEM_STATUS_DISABLED: + return _BUTTON_STATUS_DISABLED; + break; + + case HEADER_ITEM_STATUS_PRESSED: + return _BUTTON_STATUS_PRESSED; + break; + + case HEADER_ITEM_STATUS_HIGHLIGHTED: + return _BUTTON_STATUS_HIGHLIGHTED; + break; + + case HEADER_ITEM_STATUS_SELECTED: + return _BUTTON_STATUS_SELECTED; + break; + + default: + return _BUTTON_STATUS_DISABLED; + break; + } +} + +class _HeaderMaker + : public _UiBuilderControlMaker +{ +public: + _HeaderMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_HeaderMaker(){}; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _HeaderMaker* pHeaderMaker = new (std::nothrow) _HeaderMaker(uibuilder); + return pHeaderMaker; + }; +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + Header* pHeader = null; + Rectangle rect(0, 0, 0, 0); + String elementString; + int opacity = 0; + Color color; + + //Construct + HeaderStyle hstyle = HEADER_STYLE_TITLE; + Form* pForm = static_cast(GetContainer()); + pHeader = pForm->GetHeader(); + + if (null == pHeader) + { + return null; + } + + if (pControl->GetElement(L"headerStyle", elementString)) + { + if (elementString.Equals(L"HEADER_STYLE_TITLE", false)) + { + hstyle = HEADER_STYLE_TITLE; + } + else if (elementString.Equals(L"HEADER_STYLE_SEGMENTED", false)) + { + hstyle = HEADER_STYLE_SEGMENTED; + } + else if (elementString.Equals(L"HEADER_STYLE_TITLE_BUTTON", false)) + { + hstyle = HEADER_STYLE_TITLE_BUTTON; + } + else if (elementString.Equals(L"HEADER_STYLE_SEGMENTED_WITH_TITLE", false)) + { + hstyle = HEADER_STYLE_SEGMENTED_WITH_TITLE; + } + else if (elementString.Equals(L"HEADER_STYLE_TAB", false)) + { + hstyle = HEADER_STYLE_TAB; + } + else if (elementString.Equals(L"HEADER_STYLE_TAB_WITH_TITLE", false)) + { + hstyle = HEADER_STYLE_TAB_WITH_TITLE; + } + else if (elementString.Equals(L"HEADER_STYLE_BUTTON", false)) + { + hstyle = HEADER_STYLE_BUTTON; + } + + pHeader->SetStyle(hstyle); + } + + if (pControl->GetElement(L"backgroundBitmapPath", elementString) || pControl->GetElement(L"BGBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + pHeader->SetBackgroundBitmap(pBitmap); + } + + // header color + if (pControl->GetElement(L"colorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"color", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pHeader->SetColor(color); + } + + if (HEADER_STYLE_TITLE == hstyle || HEADER_STYLE_SEGMENTED_WITH_TITLE == hstyle || HEADER_STYLE_TAB_WITH_TITLE == hstyle) + { + // title + if (pControl->GetElement(L"titleText", elementString)) + { + pHeader->SetTitleText(elementString); + } + + if (pControl->GetElement(L"titleTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + result r = pHeader->SetTitleTextColor(color); + SysLogException(NID_UI_CTRL, r, "[E_INVALID_STATE] Failed to set title text color"); + } + + if (pControl->GetElement(L"titleIconPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + result r = pHeader->SetTitleIcon(pBitmap); + SysLogException(NID_UI_CTRL, r, "[E_INVALID_STATE] Failed to set an icon"); + } + + // description + if (pControl->GetElement(L"descriptionText", elementString)) + { + result r = pHeader->SetDescriptionText(elementString); + SysLogException(NID_UI_CTRL, r, "[E_INVALID_STATE] Failed to set description text"); + } + + if (pControl->GetElement(L"descriptionTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + result r = pHeader->SetDescriptionTextColor(color); + SysLogException(NID_UI_CTRL, r, "[E_INVALID_STATE] Failed to set description text color"); + } + } + + // normal button + if (pControl->GetElement(L"normalButtonColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"normalButtonColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pHeader->SetButtonColor(BUTTON_ITEM_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"normalButtonTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pHeader->SetButtonTextColor(BUTTON_ITEM_STATUS_NORMAL, color); + } + + // pressed button + if (pControl->GetElement(L"pressedButtonColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"pressedButtonColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pHeader->SetButtonColor(BUTTON_ITEM_STATUS_PRESSED, color); + } + + if (pControl->GetElement(L"pressedButtonTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pHeader->SetButtonTextColor(BUTTON_ITEM_STATUS_PRESSED, color); + } + + // highlighted button + if (pControl->GetElement(L"highlightedButtonColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"highlightedButtonColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pHeader->SetButtonColor(BUTTON_ITEM_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"highlightedButtonTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pHeader->SetButtonTextColor(BUTTON_ITEM_STATUS_HIGHLIGHTED, color); + } + + // disabled button + if (pControl->GetElement(L"disabledButtonColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"disabledButtonColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pHeader->SetButtonColor(BUTTON_ITEM_STATUS_DISABLED, color); + } + + if (pControl->GetElement(L"disabledButtonTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pHeader->SetButtonTextColor(BUTTON_ITEM_STATUS_DISABLED, color); + } + + if (HEADER_STYLE_TITLE != hstyle) + { + // normal item + if (pControl->GetElement(L"normalItemColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"normalItemColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pHeader->SetItemColor(HEADER_ITEM_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"normalItemTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pHeader->SetItemTextColor(HEADER_ITEM_STATUS_NORMAL, color); + } + + // pressed item + if (pControl->GetElement(L"pressedItemColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"pressedItemColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pHeader->SetItemColor(HEADER_ITEM_STATUS_PRESSED, color); + } + + if (pControl->GetElement(L"pressedItemTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pHeader->SetItemTextColor(HEADER_ITEM_STATUS_PRESSED, color); + } + + if (hstyle == HEADER_STYLE_SEGMENTED || hstyle == HEADER_STYLE_SEGMENTED_WITH_TITLE + || hstyle == HEADER_STYLE_TAB || hstyle == HEADER_STYLE_TAB_WITH_TITLE) + { + // selected item + if (pControl->GetElement(L"selectedItemColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"selectedItemColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pHeader->SetItemColor(HEADER_ITEM_STATUS_SELECTED, color); + } + + if (pControl->GetElement(L"selectedItemTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pHeader->SetItemTextColor(HEADER_ITEM_STATUS_SELECTED, color); + } + } + + // highlighted item + if (pControl->GetElement(L"highlightedItemColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"highlightedItemColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pHeader->SetItemColor(HEADER_ITEM_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"highlightedItemTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pHeader->SetItemTextColor(HEADER_ITEM_STATUS_HIGHLIGHTED, color); + } + + // disabled item + if (pControl->GetElement(L"disabledItemColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"disabledItemColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pHeader->SetItemColor(HEADER_ITEM_STATUS_DISABLED, color); + } + + if (pControl->GetElement(L"disabledItemTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pHeader->SetItemTextColor(HEADER_ITEM_STATUS_DISABLED, color); + } + } + + int itemCnt = pControl->GetItemCount(); + ButtonItemStyle buttonItemStyle = BUTTON_ITEM_STYLE_TEXT; + ButtonPosition buttonPosition = BUTTON_POSITION_LEFT; + String headerItemString; + + for (int i = 0; i < itemCnt; i++) + { + headerItemString = pControl->GetItemName(i); + if ((HEADER_STYLE_TITLE != hstyle) && (headerItemString.Equals(L"headerItem", false))) + { + HeaderItem headerItem; + + // get Action Id + if (pControl->GetItemElement(i, "actionId", headerItemString)) + { + int actionId; + Base::Integer::Parse(headerItemString, actionId); + headerItem.Construct(actionId); + } + + // get text + if (pControl->GetItemElement(i, "text", headerItemString)) + { + headerItem.SetText(headerItemString); + } + + if (HEADER_STYLE_TITLE_BUTTON == hstyle) + { + // headeritem icon bitmap setting + // normal + if (pControl->GetItemElement(i, "normalIconPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + headerItem.SetIcon(HEADER_ITEM_STATUS_NORMAL, pBitmap); + } + + // pressed + if (pControl->GetItemElement(i, "pressedIconPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + headerItem.SetIcon(HEADER_ITEM_STATUS_PRESSED, pBitmap); + } + + // selected + if (pControl->GetItemElement(i, "selectedIconPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + headerItem.SetIcon(HEADER_ITEM_STATUS_SELECTED, pBitmap); + } + + // highlighted + if (pControl->GetItemElement(i, "highlightedIconPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + headerItem.SetIcon(HEADER_ITEM_STATUS_HIGHLIGHTED, pBitmap); + } + + // disabled + if (pControl->GetItemElement(i, "disabledIconPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + headerItem.SetIcon(HEADER_ITEM_STATUS_DISABLED, pBitmap); + } + } + + // headeritem background bitmap path setting + // normal bg bitmap + if (pControl->GetItemElement(i, "normalBGBitmapPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + headerItem.SetBackgroundBitmap(HEADER_ITEM_STATUS_NORMAL, pBitmap); + } + + // pressed bg bitmap + if (pControl->GetItemElement(i, "pressedBGBitmapPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + headerItem.SetBackgroundBitmap(HEADER_ITEM_STATUS_PRESSED, pBitmap); + } + + // selected bg bitmap + if (pControl->GetItemElement(i, "selectedBGBitmapPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + headerItem.SetBackgroundBitmap(HEADER_ITEM_STATUS_SELECTED, pBitmap); + } + + // highlighted bg bitmap + if (pControl->GetItemElement(i, "highlightedBGBitmapPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + headerItem.SetBackgroundBitmap(HEADER_ITEM_STATUS_HIGHLIGHTED, pBitmap); + } + + // disabled bg bitmap + if (pControl->GetItemElement(i, "disabledBGBitmapPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + headerItem.SetBackgroundBitmap(HEADER_ITEM_STATUS_DISABLED, pBitmap); + } + + pHeader->AddItem(headerItem); + } + else if (headerItemString.Equals(L"buttonItem", false)) + { + ButtonItem buttonItem; + + // set button style + if (pControl->GetItemElement(i, "style", headerItemString)) + { + if (headerItemString.Equals(L"BUTTON_ITEM_STYLE_TEXT", false)) + { + buttonItemStyle = BUTTON_ITEM_STYLE_TEXT; + } + else if (headerItemString.Equals(L"BUTTON_ITEM_STYLE_ICON", false)) + { + buttonItemStyle = BUTTON_ITEM_STYLE_ICON; + } + } + + // set button position + if (pControl->GetItemElement(i, "position", headerItemString)) + { + if (headerItemString.Equals(L"BUTTON_POSITION_LEFT", false)) + { + buttonPosition = BUTTON_POSITION_LEFT; + } + else if (headerItemString.Equals(L"BUTTON_POSITION_RIGHT", false)) + { + buttonPosition = BUTTON_POSITION_RIGHT; + } + } + + if (pControl->GetItemElement(i, "actionId", headerItemString)) + { + int actionId; + Base::Integer::Parse(headerItemString, actionId); + buttonItem.Construct(buttonItemStyle, actionId); + } + + if (pControl->GetItemElement(i, "text", headerItemString)) + { + buttonItem.SetText(headerItemString); + } + + // buttonitem background bitmap path setting + // normal bg bitmap + if (pControl->GetItemElement(i, "normalBGBitmapPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBitmap); + } + + // pressed bg bitmap + if (pControl->GetItemElement(i, "pressedBGBitmapPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBitmap); + } + + // highlighted bg bitmap + if (pControl->GetItemElement(i, "highlightedBGBitmapPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_HIGHLIGHTED, pBitmap); + } + + // disabled bg bitmap + if (pControl->GetItemElement(i, "disabledBGBitmapPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_DISABLED, pBitmap); + } + + // buttonitem icon bitmap setting + if (pControl->GetItemElement(i, "normalIconPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + buttonItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmap); + } + + if (pControl->GetItemElement(i, "pressedIconPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + buttonItem.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmap); + } + + if (pControl->GetItemElement(i, "highlightedIconPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + buttonItem.SetIcon(BUTTON_ITEM_STATUS_HIGHLIGHTED, pBitmap); + } + + if (pControl->GetItemElement(i, "disabledIconPath", headerItemString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(headerItemString); + buttonItem.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmap); + } + + pHeader->SetButton(buttonPosition, buttonItem); + } + + } + + return pHeader; + } + +private: + +}; + +_HeaderRegister::_HeaderRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"Header", _HeaderMaker::GetInstance); +} + +_HeaderRegister::~_HeaderRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"Header"); +} + +static _HeaderRegister HeaderRegisterToUiBuilder; + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_HeaderItemImpl.cpp b/src/ui/controls/FUiCtrl_HeaderItemImpl.cpp new file mode 100644 index 0000000..33a9900 --- /dev/null +++ b/src/ui/controls/FUiCtrl_HeaderItemImpl.cpp @@ -0,0 +1,160 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_HeaderItemImpl.cpp +* @brief This is the implementation file for _HeaderItemImpl class. +*/ + +#include +#include "FUiCtrl_HeaderItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_HeaderItemImpl::_HeaderItemImpl(HeaderItem* pPublic) + : __actionId(-1) + , __itemText(L"") +{ + for (int i = 0; i < HEADER_ITEM_MAX_STATE_COUNT; i++) + { + __pIconBitmap[i] = null; + __pHeaderItemBackgroundBitmap[i] = null; + } +} + +_HeaderItemImpl::~_HeaderItemImpl(void) +{ + for (int i = 0; i < HEADER_ITEM_MAX_STATE_COUNT; i++) + { + __pIconBitmap[i] = null; + __pHeaderItemBackgroundBitmap[i] = null; + } +} + +const _HeaderItemImpl* +_HeaderItemImpl::GetInstance(const HeaderItem& headerItem) +{ + return static_cast (headerItem.__pImpl); +} + +_HeaderItemImpl* +_HeaderItemImpl::GetInstance(HeaderItem& headerItem) +{ + return static_cast<_HeaderItemImpl*> (headerItem.__pImpl); +} + +result +_HeaderItemImpl::Construct(int actionId) +{ + SysTryReturnResult(NID_UI_CTRL, (actionId >= HEADER_ITEM_ACTION_ID_MIN && actionId <= HEADER_ITEM_ACTION_ID_MAX), + E_INVALID_ARG, "[E_INVALID_ARG] The actionId is invalid."); + + __actionId = actionId; + __itemText = String(L""); + + for (int i = 0; i < HEADER_ITEM_MAX_STATE_COUNT; i++) + { + __pIconBitmap[i] = null; + __pHeaderItemBackgroundBitmap[i] = null; + } + + return E_SUCCESS; +} + +int +_HeaderItemImpl::GetActionId(void) const +{ + ClearLastResult(); + + return __actionId; +} + +const Bitmap* +_HeaderItemImpl::GetBackgroundBitmap(HeaderItemStatus status) const +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, (status >= HEADER_ITEM_STATUS_NORMAL && status < HEADER_ITEM_MAX_STATE_COUNT), null, E_INVALID_ARG, + "[E_INVALID_ARG] status is invalid."); + + return __pHeaderItemBackgroundBitmap[status]; +} + +const Bitmap* +_HeaderItemImpl::GetIcon(HeaderItemStatus status) const +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, (status >= HEADER_ITEM_STATUS_NORMAL && status < HEADER_ITEM_MAX_STATE_COUNT), null, E_INVALID_ARG, + "[E_INVALID_ARG] status is invalid."); + + return __pIconBitmap[status]; +} + +String +_HeaderItemImpl::GetText(void) const +{ + ClearLastResult(); + + return __itemText; +} + +result +_HeaderItemImpl::SetActionId(int actionId) +{ + SysTryReturnResult(NID_UI_CTRL, (actionId >= HEADER_ITEM_ACTION_ID_MIN && actionId <= HEADER_ITEM_ACTION_ID_MAX), + E_INVALID_ARG, "[E_INVALID_ARG] The actionId is invalid."); + + __actionId = actionId; + + return E_SUCCESS; +} + +result +_HeaderItemImpl::SetBackgroundBitmap(HeaderItemStatus status, const Bitmap* pBitmap) +{ + SysTryReturnResult(NID_UI_CTRL, (status >= HEADER_ITEM_STATUS_NORMAL && status < HEADER_ITEM_MAX_STATE_COUNT), E_INVALID_ARG, + "[E_INVALID_ARG] status is invalid."); + + __pHeaderItemBackgroundBitmap[status] = pBitmap; + + return E_SUCCESS; +} + +result +_HeaderItemImpl::SetIcon(HeaderItemStatus status, const Bitmap* pIcon) +{ + SysTryReturnResult(NID_UI_CTRL, (status >= HEADER_ITEM_STATUS_NORMAL && status < HEADER_ITEM_MAX_STATE_COUNT), E_INVALID_ARG, + "[E_INVALID_ARG] status is invalid."); + + __pIconBitmap[status] = pIcon; + + return E_SUCCESS; +} + +result +_HeaderItemImpl::SetText(const String& text) +{ + __itemText = text; + + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IconListData.cpp b/src/ui/controls/FUiCtrl_IconListData.cpp new file mode 100644 index 0000000..4539d22 --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListData.cpp @@ -0,0 +1,122 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListData.cpp + * @brief This is the implementation file for _IconListData class + * + * This file contains the implementation of _IconListData class + */ + +#include "FUiCtrl_IconListData.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_IconListData::_IconListData(void) + : __pNormalBitmap(null) + , __pFocusedBitmap(null) + , __labelText() + , __itemId(-1) +{ +} + +_IconListData::~_IconListData(void) +{ + delete __pNormalBitmap; + __pNormalBitmap = null; + + delete __pFocusedBitmap; + __pFocusedBitmap = null; +} + +const Bitmap* +_IconListData::GetNormalBitmap(void) +{ + return __pNormalBitmap; +} + +const Bitmap* +_IconListData::GetFocusedBitmap(void) +{ + return __pFocusedBitmap; +} + +const String +_IconListData::GetLabelText(void) +{ + return __labelText; +} + +int +_IconListData::GetItemId(void) +{ + return __itemId; +} + +void +_IconListData::SetNormalBitmap(const Bitmap* pNormalBitmap) +{ + + if (pNormalBitmap != null) + { + __pNormalBitmap = new (std::nothrow) Bitmap(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pNormalBitmap != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = __pNormalBitmap->Construct(*pNormalBitmap, Rectangle(0, 0, pNormalBitmap->GetWidth(), pNormalBitmap->GetHeight())); + if (IsFailed(r)) + { + SysLogException(NID_UI_CTRL, r, "[E_SYSTEM]Bitmap construct failed"); + } + } + +} + +void +_IconListData::SetFocusedBitmap(const Bitmap* pFocusedBitmap) +{ + if (pFocusedBitmap != null) + { + __pFocusedBitmap = new (std::nothrow) Bitmap(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pFocusedBitmap != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = __pFocusedBitmap->Construct(*pFocusedBitmap, Rectangle(0, 0, pFocusedBitmap->GetWidth(), pFocusedBitmap->GetHeight())); + if (IsFailed(r)) + { + SysLogException(NID_UI_CTRL, r, "[E_SYSTEM]Bitmap construct failed"); + } + } +} + +void +_IconListData::SetLabelText(const String& labelText) +{ + __labelText = labelText; + +} + +void +_IconListData::SetItemId(int itemId) +{ + __itemId = itemId; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IconListImpl.cpp b/src/ui/controls/FUiCtrl_IconListImpl.cpp new file mode 100644 index 0000000..30eda9c --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListImpl.cpp @@ -0,0 +1,1024 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListImpl.cpp + * @brief This is the implementation file for _IconListImpl class + * + * This file contains the implementation of _IconListImpl class + */ + +#include +#include "FUiCtrl_IconListImpl.h" +#include "FUiCtrl_IconListItemProvider.h" +#include "FUiCtrl_IconListData.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_ListListener.h" +//UiBuilder +#include "FUi_UiBuilder.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_IconListImpl* +_IconListImpl::GetInstance(IconList& iconList) +{ + return static_cast< _IconListImpl* >(iconList._pControlImpl); +} + +const _IconListImpl* +_IconListImpl::GetInstance(const IconList& iconList) +{ + return static_cast< const _IconListImpl* >(iconList._pControlImpl); +} + +_IconListImpl::_IconListImpl(Control* pList, _IconListView* pCore) + : _ControlImpl(pList, pCore) + , __pIconListItemProvider(null) + , __annexStyle(ICON_LIST_VIEW_STYLE_NORMAL) +{ +} + +_IconListImpl::~_IconListImpl(void) +{ + __iconList.RemoveAll(true); + __iconListenersList.RemoveAll(true); + + delete __pIconListItemProvider; + __pIconListItemProvider = null; +} + +const char* +_IconListImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::IconList"; +} + +const IconList& +_IconListImpl::GetPublic(void) const +{ + return static_cast< const IconList& >(_ControlImpl::GetPublic()); +} + +IconList& +_IconListImpl::GetPublic(void) +{ + return static_cast< IconList& >(_ControlImpl::GetPublic()); +} + +const _IconListView& +_IconListImpl::GetCore(void) const +{ + return static_cast< const _IconListView& >(_ControlImpl::GetCore()); +} + +_IconListView& +_IconListImpl::GetCore(void) +{ + return static_cast< _IconListView& >(_ControlImpl::GetCore()); +} + +_IconListImpl* +_IconListImpl::CreateIconListImplN(IconList* pControl) +{ + _IconListView* pCore = _IconListView::CreateIconListViewN(); + SysTryReturn(NID_UI_CTRL, (pCore != null), null, GetLastResult(), "[%s] Creating iconListView instance failed", GetErrorMessage(GetLastResult())); + + _IconListImpl* pImpl = new (std::nothrow) _IconListImpl(pControl, pCore); + SysTryCatch(NID_UI_CTRL, (pImpl != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + return pImpl; + +CATCH: + delete pCore; + return null; +} + +result +_IconListImpl::SetIconListStyle(IconListStyle style) +{ + result r = E_SUCCESS; + + switch (style) + { + case ICON_LIST_STYLE_NORMAL: + __annexStyle = ICON_LIST_VIEW_STYLE_NORMAL; + break; + + case ICON_LIST_STYLE_RADIO: + __annexStyle = ICON_LIST_VIEW_STYLE_RADIO; + break; + + case ICON_LIST_STYLE_MARK: + __annexStyle = ICON_LIST_VIEW_STYLE_MARK; + break; + + default: + r = E_INVALID_ARG; + break; + } + + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Invalid Icon List style" ); + + r = GetCore().SetStyle(__annexStyle); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to set style", GetErrorMessage(r)); + + return r; +} + +result +_IconListImpl::InitializeIconList(int itemWidth, int itemHeight) +{ + result r = E_SUCCESS; + int initialTextSize = itemHeight >> 2; + int minSize = 0; + int topMargin = 0; + int rightMargin = 0; + int leftMargin = 0; + + GET_FIXED_VALUE_CONFIG(ICONLIST::MINIMUM_FONT_SIZE, GetCore().GetOrientation(), minSize); + GET_SHAPE_CONFIG(ICONLIST::LIST1X_TOP_MARGIN, GetCore().GetOrientation(), topMargin); + GET_SHAPE_CONFIG(ICONLIST::LIST1X_LEFT_MARGIN, GetCore().GetOrientation(), leftMargin); + GET_SHAPE_CONFIG(ICONLIST::LIST1X_RIGHT_MARGIN, GetCore().GetOrientation(), rightMargin); + + if (initialTextSize < minSize) + { + initialTextSize = minSize; + } + + r = GetCore().SetItemTextSize(initialTextSize); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to set item text size", GetErrorMessage(r)); + + r = GetCore().SetScrollDirection(ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to set scroll direction", GetErrorMessage(r)); + + r = GetCore().SetItemBitmapBounds(Rectangle(0, 0, itemWidth, itemHeight)); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to set bitmap bounds", GetErrorMessage(r)); + + r = GetCore().SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_OUTLINE); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to set border style", GetErrorMessage(r)); + + r = GetCore().SetItemSpacing(rightMargin, topMargin); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to set item spacing", GetErrorMessage(r)); + + r = GetCore().SetMargin(MARGIN_TYPE_TOP, topMargin); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to set top margin", GetErrorMessage(r)); + + r = GetCore().SetMargin(MARGIN_TYPE_LEFT, leftMargin); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to set left margin", GetErrorMessage(r)); + + r = GetCore().SetMargin(MARGIN_TYPE_RIGHT, rightMargin); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to set right margin", GetErrorMessage(r)); + + r = GetCore().SetMargin(MARGIN_TYPE_BOTTOM, 0); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to set bottom margin", GetErrorMessage(r)); + + return r; +} + +result +_IconListImpl::SetItemProvider(void) +{ + __pIconListItemProvider = new (std::nothrow) _IconListItemProvider(this); + SysTryReturnResult(NID_UI_CTRL, __pIconListItemProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + return GetCore().SetItemProvider(*__pIconListItemProvider); +} + +result +_IconListImpl::SetNonSlidable(void) +{ + return GetCore().SetNonSlidableList(); +} + +result +_IconListImpl::SetListener(void) +{ + result r = E_SUCCESS; + r = GetCore().AddIconListItemEventListener(*this); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to set IconListItemEvent listener", GetErrorMessage(r)); + + return r; +} + +void +_IconListImpl::AddItemEventListener(IItemEventListener& listener) +{ + _ListListener* pIconListListener = new (std::nothrow) _ListListener(); + SysTryReturnVoidResult(NID_UI_CTRL, pIconListListener, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pIconListListener->pListener = &listener; + + __iconListenersList.Add(*pIconListListener); +} + +void +_IconListImpl::RemoveItemEventListener(IItemEventListener& listener) +{ + _ListListener* pIconListListener = null; + + for (int listenerCount = 0; listenerCount < __iconListenersList.GetCount(); listenerCount++) + { + pIconListListener = dynamic_cast< _ListListener* >(__iconListenersList.GetAt(listenerCount)); + + if ((pIconListListener != null) && (pIconListListener->pListener == &listener)) + { + __iconListenersList.RemoveAt(listenerCount, true); + break; + } + } + +} + +void +_IconListImpl::SetBackgroundBitmap(const Bitmap& bitmap) +{ + result r = E_SUCCESS; + + r = GetCore().SetBackgroundBitmap(&bitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] SetBackgroundBitmap failed."); +} + +result +_IconListImpl::SetMargin(int topMargin, int leftMargin) +{ + result r = E_SUCCESS; + + r = GetCore().SetMargin(MARGIN_TYPE_TOP, topMargin); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[%s] Failed to set Margin", GetErrorMessage(r)); + + r = GetCore().SetMargin(MARGIN_TYPE_LEFT, leftMargin); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[%s] Failed to set Margin", GetErrorMessage(r)); + + return r; +} + +int +_IconListImpl::GetTopMargin(void) const +{ + return GetCore().GetMargin(MARGIN_TYPE_TOP); +} + +int +_IconListImpl::GetLeftMargin(void) const +{ + return GetCore().GetMargin(MARGIN_TYPE_LEFT); +} + +result +_IconListImpl::AddItem(const String* pText, const Bitmap* pNormalBitmap, const Bitmap* pFocusedBitmap, int itemId) +{ + result r = E_SUCCESS; + + _IconListData* pIconListData = CreateIconListItemN(pText, pNormalBitmap, pFocusedBitmap, itemId); + SysTryReturnResult(NID_UI_CTRL, pIconListData, E_SYSTEM, "[E_SYSTEM] This Item instance is null."); + + r = __iconList.Add(*pIconListData); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Add failed."); + + r = GetCore().RefreshList(__iconList.GetCount() - 1, LIST_REFRESH_TYPE_ITEM_ADD); + SysTryReturnResult(NID_UI_CTRL, E_SUCCESS == r, E_SYSTEM, "[E_SYSTEM] Could not able to Add an Item."); + + return r; + +CATCH: + delete pIconListData; + pIconListData = null; + return E_SYSTEM; +} + +result +_IconListImpl::InsertItemAt(int index, const String* pText, const Bitmap* pNormalBitmap, const Bitmap* pFocusedBitmap, int itemId) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index <= __iconList.GetCount()), + E_SYSTEM, "[E_INVALID_ARG] Index passed is invalid"); + + if (index == __iconList.GetCount()) + { + return AddItem(pText, pNormalBitmap, pFocusedBitmap, itemId); + } + + _IconListData* pIconListData = CreateIconListItemN(pText, pNormalBitmap, pFocusedBitmap, itemId); + SysTryReturnResult(NID_UI_CTRL, pIconListData, E_SYSTEM, "[E_SYSTEM] This Item instance is null."); + + r = __iconList.InsertAt(*pIconListData, index); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] InsertAt failed."); + + r = GetCore().RefreshList(index, LIST_REFRESH_TYPE_ITEM_ADD); + SysTryReturnResult(NID_UI_CTRL, E_SUCCESS == r, E_SYSTEM, "[E_SYSTEM] Item could not be inserted into list."); + + return r; + +CATCH: + delete pIconListData; + pIconListData = null; + return E_SYSTEM; +} + +result +_IconListImpl::SetItemAt(int index, const String* pText, const Bitmap* pNormalBitmap, const Bitmap* pFocusedBitmap, int itemId) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < __iconList.GetCount()), + E_SYSTEM, "[E_INVALID_ARG] The index should not be less than 0 and greater than ItemCount"); + + _IconListData* pIconListData = CreateIconListItemN(pText, pNormalBitmap, pFocusedBitmap, itemId); + SysTryReturnResult(NID_UI_CTRL, pIconListData, E_SYSTEM, "[E_SYSTEM] This Item instance is null."); + + r = __iconList.SetAt(*pIconListData, index, true); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] SetAt failed."); + + r = GetCore().RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY); + SysTryReturnResult(NID_UI_CTRL, E_SUCCESS == r, E_SYSTEM, "[E_SYSTEM] Item could not be modified."); + + return r; + +CATCH: + delete pIconListData; + pIconListData = null; + return E_SYSTEM; +} + +result +_IconListImpl::RemoveItemAt(int index) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < __iconList.GetCount()), + E_SYSTEM, "[E_INVALID_ARG] Index passed is invalid"); + + __iconList.RemoveAt(index, true); + + r = GetCore().RefreshList(index, LIST_REFRESH_TYPE_ITEM_REMOVE); + SysTryReturnResult(NID_UI_CTRL, E_SUCCESS == r, E_SYSTEM, "[E_SYSTEM] Could not able to Remove an Item."); + + return r; +} + +result +_IconListImpl::RemoveAllItems(void) +{ + result r = E_SUCCESS; + result finalResult = E_SUCCESS; + + for (int index = __iconList.GetCount() - 1; index >= 0; index--) + { + r = RemoveItemAt(index); + if (r != E_SUCCESS) + { + finalResult = r; + SysLog(NID_UI_CTRL, "[E_SYSTEM] Item at %d index not removed successfully", index); + } + } + + return finalResult; +} + +int +_IconListImpl::GetColumnCount(void) const +{ + return GetCore().GetItemCountPerAxis(); +} + +int +_IconListImpl::GetItemCount(void) const +{ + return __iconList.GetCount(); +} + +result +_IconListImpl::SetItemChecked(int index, bool check) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < __iconList.GetCount()), E_INVALID_ARG, "[E_INVALID_ARG] Index passed is invalid"); + SysTryReturnResult(NID_UI_CTRL, (__annexStyle != ICON_LIST_VIEW_STYLE_NORMAL), E_SYSTEM, "[E_SYSTEM] Invalid operation for ICON_LIST_VIEW_STYLE_NORMAL."); + + r = GetCore().SetItemChecked(index, check); + SysTryReturnResult(NID_UI_CTRL, E_SUCCESS == r, r, "SetItemChecked failed."); + + r = GetCore().RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY); + SysTryReturnResult(NID_UI_CTRL, E_SUCCESS == r, r, "[E_SYSTEM] Item Not removed SuccessFully."); + + return r; +} + +bool +_IconListImpl::IsItemChecked(int index) const +{ + SysTryReturn(NID_UI_CTRL, (__annexStyle != ICON_LIST_VIEW_STYLE_NORMAL), + false, E_SYSTEM, "[E_SYSTEM] list style should not be ICON_LIST_VIEW_STYLE_NORMAL."); + + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < __iconList.GetCount()), + false, "[E_INVALID_ARG] Index passed is invalid"); + + return GetCore().IsItemChecked(index); +} + +result +_IconListImpl::SetAllItemsChecked(bool check) +{ + SysTryReturnResult(NID_UI_CTRL, (__annexStyle != ICON_LIST_VIEW_STYLE_RADIO && __annexStyle != ICON_LIST_VIEW_STYLE_NORMAL), + E_SYSTEM, "[E_SYSTEM] Invalid Operation."); + + result r = E_SUCCESS; + + for (int index = 0; index < __iconList.GetCount(); index++) + { + r = GetCore().SetItemChecked(index, check); + if (r != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] Item Not checked Properly"); + } + GetCore().RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY); + } + + return r; +} + +result +_IconListImpl::RemoveAllCheckedItems(void) +{ + SysTryReturnResult(NID_UI_CTRL, (__annexStyle != ICON_LIST_VIEW_STYLE_RADIO && __annexStyle != ICON_LIST_VIEW_STYLE_NORMAL), + E_SYSTEM, "[E_SYSTEM] Invalid Operation."); + + result r = E_SUCCESS; + result finalResult = E_SUCCESS; + + for (int index = __iconList.GetCount() - 1; index >= 0 ; index--) + { + if (GetCore().IsItemChecked(index)) + { + r = RemoveItemAt(index); + if (r != E_SUCCESS) + { + finalResult = r; + SysLog(NID_UI_CTRL, "[E_SYSTEM] Item at %d index not removed successfully", index); + } + } + } + + return finalResult; +} + +int +_IconListImpl::GetFirstCheckedItemIndex(void) const +{ + const _Control& control = GetCore(); + _IconListView* pList = dynamic_cast< _IconListView* >(const_cast< _Control* >(&control)); + SysTryReturn(NID_UI_CTRL, (pList != null), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + SysTryReturn(NID_UI_CTRL, (__annexStyle != ICON_LIST_VIEW_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] Invalid operation for ICON_LIST_VIEW_STYLE_NORMAL."); + + for (int index = 0; index < __iconList.GetCount(); index++) + { + if (GetCore().IsItemChecked(index)) + { + return index; + } + } + + return INVALID_INDEX; +} + +int +_IconListImpl::GetLastCheckedItemIndex(void) const +{ + const _Control& control = GetCore(); + _IconListView* pList = dynamic_cast< _IconListView* >(const_cast< _Control* >(&control)); + SysTryReturn(NID_UI_CTRL, (pList != null), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + SysTryReturn(NID_UI_CTRL, (__annexStyle != ICON_LIST_VIEW_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] Invalid operation for ICON_LIST_VIEW_STYLE_NORMAL."); + + for (int index = __iconList.GetCount() - 1; index >= 0; index--) + { + if (GetCore().IsItemChecked(index)) + { + return index; + } + } + + return INVALID_INDEX; +} + +int +_IconListImpl::GetNextCheckedItemIndexAfter(int index) const +{ + const _Control& control = GetCore(); + _IconListView* pList = dynamic_cast< _IconListView* >(const_cast< _Control* >(&control)); + SysTryReturn(NID_UI_CTRL, (pList != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < __iconList.GetCount()), INVALID_INDEX, INVALID_INDEX, "[INVALID_INDEX] Invalid index(%d)", index); + + SysTryReturn(NID_UI_CTRL, (__annexStyle != ICON_LIST_VIEW_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] Invalid operation for ICON_LIST_VIEW_STYLE_NORMAL."); + + for (int i = index + 1; i < __iconList.GetCount(); i++) + { + if (GetCore().IsItemChecked(i)) + { + return i; + } + + } + + return INVALID_INDEX; +} + +int +_IconListImpl::GetItemIndexFromPosition(int x, int y) const +{ + SysTryReturn(NID_UI_CTRL, (x >= 0 && y >= 0), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid Co-ordinates"); + + return GetCore().GetItemIndexFromPosition(Point(x, y)); +} + +int +_IconListImpl::GetItemIndexFromPosition(const Point& position) const +{ + return GetCore().GetItemIndexFromPosition(position); +} + +void +_IconListImpl::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + if (!(alignment >= ALIGNMENT_LEFT && alignment <= ALIGNMENT_RIGHT)) + { + SetLastResult(E_INVALID_ARG); + //SetLastLog("[E_INVALID_ARG] Cannot set text Horizontal align"); + return; + } + + GetCore().SetTextHorizontalAlignment(alignment); +} + +void +_IconListImpl::SetTextVerticalAlignment(VerticalAlignment alignment) +{ + if (!(alignment >= ALIGNMENT_TOP && alignment <= ALIGNMENT_BOTTOM)) + { + SetLastResult(E_INVALID_ARG); + //SetLastLog("[E_INVALID_ARG] Cannot set text vertical align"); + return; + } + + switch (alignment) + { + case ALIGNMENT_TOP: + { + GetCore().SetTextVerticalAlignment(ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP); + } + break; + + case ALIGNMENT_MIDDLE: + { + GetCore().SetTextVerticalAlignment(ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_MIDDLE); + } + break; + + case ALIGNMENT_BOTTOM: + { + GetCore().SetTextVerticalAlignment(ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM); + } + break; + } +} + +HorizontalAlignment +_IconListImpl::GetTextHorizontalAlignment(void) const +{ + return GetCore().GetTextHorizontalAlignment(); + +} + +VerticalAlignment +_IconListImpl::GetTextVerticalAlignment(void) const +{ + switch (GetCore().GetTextVerticalAlignment()) + { + case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP: + { + return ALIGNMENT_TOP; + } + break; + + case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_MIDDLE: + { + return ALIGNMENT_MIDDLE; + } + break; + + case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM: + { + return ALIGNMENT_BOTTOM; + } + break; + + default: + { + return ALIGNMENT_TOP; + } + break; + } +} + +void +_IconListImpl::SetTextOfEmptyList(const String& text) +{ + GetCore().SetTextOfEmptyList(text); +} + +void +_IconListImpl::SetTextColorOfEmptyList(const Color& color) +{ + GetCore().SetTextColorOfEmptyList(color); +} + +Tizen::Graphics::Color +_IconListImpl::GetTextColorOfEmptyList(void) const +{ + return GetCore().GetTextColorOfEmptyList(); +} + +void +_IconListImpl::SetItemTextColor(const Color& textColor) +{ + GetCore().SetItemTextColor(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL, textColor); +} + +Tizen::Graphics::Color +_IconListImpl::GetItemTextColor(void) const +{ + return GetCore().GetItemTextColor(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL); +} + +void +_IconListImpl::SetTextSize(int size) +{ + GetCore().SetItemTextSize(size); +} + +int +_IconListImpl::GetTextSize(void) const +{ + return GetCore().GetItemTextSize(); +} + +int +_IconListImpl::GetItemIndexFromItemId(int itemId) const +{ + _IconListData* pIconListData = null; + + for (int index = 0; index < __iconList.GetCount(); index++) + { + pIconListData = dynamic_cast< _IconListData* >(const_cast< Object* >(__iconList.GetAt(index))); + if (pIconListData != null) + { + if (pIconListData->GetItemId() == itemId) + { + return index; + } + } + } + + return INVALID_INDEX; +} + +int +_IconListImpl::GetItemIdAt(int index) const +{ + SysTryReturn(NID_UI_CTRL, (index < __iconList.GetCount()), + INVALID_INDEX, E_INVALID_ARG, ("[E_INVALID_ARG] Index passed is invalid")); + + _IconListData* pIconListData = null; + pIconListData = dynamic_cast< _IconListData* >(const_cast< Object* >(__iconList.GetAt(index))); + if (pIconListData != null) + { + return pIconListData->GetItemId(); + } + + return INVALID_INDEX; +} + +void +_IconListImpl::SetCheckBoxPosition(IconListCheckBoxPosition position) +{ + SysTryReturnVoidResult(NID_UI_CTRL, (__annexStyle == ICON_LIST_VIEW_STYLE_RADIO || __annexStyle == ICON_LIST_VIEW_STYLE_MARK), + E_INVALID_OPERATION, "[E_INVALID_OPERATION] Can not set position of CheckBox."); + + if (!(position >= ICON_LIST_CHECK_BOX_POSITION_TOP_LEFT && position <= ICON_LIST_CHECK_BOX_POSITION_BOTTOM_RIGHT)) + { + SetLastResult(E_INVALID_ARG); + //SetLastLog("[E_INVALID_ARG] Cannot set text Horizontal align"); + return; + } + + switch (position) + { + case ICON_LIST_CHECK_BOX_POSITION_TOP_LEFT: + { + GetCore().SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT); + } + break; + + case ICON_LIST_CHECK_BOX_POSITION_TOP_RIGHT: + { + GetCore().SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT); + } + break; + + case ICON_LIST_CHECK_BOX_POSITION_BOTTOM_LEFT: + { + GetCore().SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_LEFT); + } + break; + + case ICON_LIST_CHECK_BOX_POSITION_BOTTOM_RIGHT: + { + GetCore().SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_RIGHT); + } + break; + } +} + +IconListCheckBoxPosition +_IconListImpl::GetCheckBoxPosition(void) const +{ + switch (GetCore().GetCheckBoxPosition()) + { + case ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT: + { + return ICON_LIST_CHECK_BOX_POSITION_TOP_LEFT; + } + break; + + case ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT: + { + return ICON_LIST_CHECK_BOX_POSITION_TOP_RIGHT; + } + break; + + case ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_LEFT: + { + return ICON_LIST_CHECK_BOX_POSITION_BOTTOM_LEFT; + } + break; + + case ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_RIGHT: + { + return ICON_LIST_CHECK_BOX_POSITION_BOTTOM_RIGHT; + } + break; + + default: + { + return ICON_LIST_CHECK_BOX_POSITION_TOP_RIGHT; + } + break; + } +} + +void +_IconListImpl::SetFocusAnimationEnabled(bool enable) +{ + GetCore().SetTouchAnimationEnabled(enable); +} + +void +_IconListImpl::ScrollToBottom(void) +{ + GetCore().ScrollToItem(__iconList.GetCount() - 1); +} + +void +_IconListImpl::ScrollToTop(void) +{ + GetCore().ScrollToItem(0); +} + +result +_IconListImpl::ScrollToTop(int itemIndex) +{ + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < __iconList.GetCount()), E_INVALID_ARG, "[E_INVALID_ARG] Invalid index(%d)", itemIndex); + + return GetCore().ScrollToItem(itemIndex); +} + +result +_IconListImpl::RefreshItem(int index) +{ + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < __iconList.GetCount()), E_INVALID_ARG, "[E_INVALID_ARG] Invalid index(%d)", index); + + return GetCore().RefreshList(index, LIST_REFRESH_TYPE_ITEM_MODIFY); +} + +void +_IconListImpl::OnIconListItemStateChanged(_IconListViewItemEventArg* pArg) +{ + SysTryReturnVoidResult(NID_UI_CTRL, (__iconListenersList.GetCount() > 0), E_SYSTEM, "[E_SYSTEM] No listeners added."); + int index = pArg->GetIndex(); + _IconListData* pIconListData = dynamic_cast< _IconListData* >(__iconList.GetAt(index)); + SysTryReturnVoidResult(NID_UI_CTRL, pIconListData != null, E_SYSTEM, "[E_SYSTEM] Failed to get IconListdata at %d index.", index); + + ItemStatus itemStatus = ITEM_HIGHLIGHTED; + + switch (pArg->GetStatus()) + { + case ICON_LIST_VIEW_ITEM_CHECKED: + { + itemStatus = ITEM_CHECKED; + } + break; + + case ICON_LIST_VIEW_ITEM_UNCHECKED: + { + itemStatus = ITEM_UNCHECKED; + } + break; + + case ICON_LIST_VIEW_ITEM_SELECTED: + { + itemStatus = ITEM_SELECTED; + } + break; + + case ICON_LIST_VIEW_ITEM_HIGHLIGHTED: + { + itemStatus = ITEM_HIGHLIGHTED; + } + break; + + default: + SysLog(NID_UI_CTRL, "IconListViewItemStatus is invalid."); + break; + } + + _ListListener* pIconListListener = null; + Tizen::Ui::IItemEventListener* pItemEventListener = null; + for (int listenerCount = 0; listenerCount < __iconListenersList.GetCount(); listenerCount++) + { + pIconListListener = dynamic_cast< _ListListener* >(__iconListenersList.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pIconListListener != null), E_SYSTEM, "[E_SYSTEM] Failed to get ListListener"); + + pItemEventListener = dynamic_cast< IItemEventListener* >(pIconListListener->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pItemEventListener != null), E_SYSTEM, "[E_SYSTEM] Failed to get EventListener"); + + pItemEventListener->OnItemStateChanged(GetPublic(), index, pIconListData->GetItemId(), itemStatus); + } + +} + +_IconListData* +_IconListImpl::CreateIconListItemN(const String* pText, const Bitmap* pNormalBitmap, const Bitmap* pFocusedBitmap, int itemId) +{ + SysTryReturn(NID_UI_CTRL, (pText != null), null, E_SYSTEM, "[E_SYSTEM] pText is null"); + + _IconListData* pIconListData = null; + pIconListData = new (std::nothrow) _IconListData(); + SysTryReturn(NID_UI_CTRL, pIconListData, null, E_SYSTEM, "[E_SYSTEM] This instance is not constructed."); + + pIconListData->SetLabelText(*pText); + pIconListData->SetItemId(itemId); + pIconListData->SetNormalBitmap(pNormalBitmap); + pIconListData->SetFocusedBitmap(pFocusedBitmap); + + return pIconListData; +} + + +class _IconListMaker + : public _UiBuilderControlMaker +{ +public: + _IconListMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_IconListMaker(){}; + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _IconListMaker* pIconListMaker = new (std::nothrow) _IconListMaker(uibuilder); + return pIconListMaker; + }; +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + IconList* pIconList = null; + Rectangle rect; + Rectangle rectMin; + Dimension dimMin; + + IconListStyle style = ICON_LIST_STYLE_NORMAL; + Tizen::Base::String elementString; + int tempItemWidth = 0; + int tempItemHeight = 0; + + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pIconList = new (std::nothrow) IconList(); + if (pIconList == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + + if (pControl->GetElement(L"itemWidth", elementString)) + { + Base::Integer::Parse(elementString, tempItemWidth); + } + + if (pControl->GetElement(L"itemHeight", elementString)) + { + Base::Integer::Parse(elementString, tempItemHeight); + } + + if (tempItemHeight < 1) + { + tempItemHeight = rect.height >> 2; + } + if (tempItemWidth < 1) + { + tempItemWidth = rect.width >> 2; + } + + Tizen::Base::String styleString; + styleString = pControlProperty->GetStyle(); + + if (styleString.Equals(L"ICON_LIST_STYLE_NORMAL", false)) + { + style = ICON_LIST_STYLE_NORMAL; + } + else if (styleString.Equals(L"ICON_LIST_STYLE_RADIO", false)) + { + style = ICON_LIST_STYLE_RADIO; + } + else if (styleString.Equals(L"ICON_LIST_STYLE_MARK", false)) + { + style = ICON_LIST_STYLE_MARK; + } + + r = pIconList->Construct(rect, style, tempItemWidth, tempItemHeight); + if (r != E_SUCCESS) + { + delete pIconList; + pIconList = null; + return null; + } + + if (pControl->GetElement(L"textOfEmptyList", elementString)) + { + pIconList->SetTextOfEmptyList(elementString); + } + + if (pControl->GetElement(L"colorOfEmptyListText", elementString)) + { + ConvertStringToColor(elementString, color); + pIconList->SetTextColorOfEmptyList(color); + } + + return pIconList; + } +private: +}; + +_IconListRegister::_IconListRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"IconList", _IconListMaker::GetInstance); +} +_IconListRegister::~_IconListRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"IconList"); +} +static _IconListRegister IconListRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IconListItem.cpp b/src/ui/controls/FUiCtrl_IconListItem.cpp new file mode 100644 index 0000000..1095299 --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListItem.cpp @@ -0,0 +1,973 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListItem.cpp + * @brief This is the implementation file for the _IconListItem class. + */ + +//Includes +#include +#include +#include +#include +#include +#include +#include + +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_IconListItem.h" +#include "FUiCtrl_IconListItemDrawingProperty.h" +#include "FUiCtrl_IconListUtils.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_IconListItem::_IconListItem(_VisualElement* pBase) + : _ListItemCommon() + , __itemIndex(0) + , __text(L"") + , __pBase(pBase) + , __pTextVE(null) + , __pCheckVE(null) + , __pProperty(null) + , __foreDrawnState(LIST_ITEM_STATE_NORMAL) + , __isDrawn(false) + , __pTextObject(null) +{ + __pBitmap[ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL] = null; + __pBitmap[ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED] = null; + __pBitmap[ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED] = null; +} + +_IconListItem::~_IconListItem(void) +{ + delete __pBitmap[ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL]; + __pBitmap[ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL] = null; + + delete __pBitmap[ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED]; + __pBitmap[ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED] = null; + + delete __pBitmap[ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED]; + __pBitmap[ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED] = null; + + __pProperty = null; + + delete __pTextObject; + __pTextObject = null; + + for (int i = 0, n = __overlayBitmaps.size() ; i < n ; i++) + { + _OverlayBitmap* pOverlayBitmap = __overlayBitmaps.at(i); + delete pOverlayBitmap->pBitmap; + pOverlayBitmap->pBitmap = null; + + if (pOverlayBitmap->pVE != null) + { + if (__pBase != null) + { + __pBase->DetachChild(*(pOverlayBitmap->pVE)); + } + + pOverlayBitmap->pVE->Destroy(); + pOverlayBitmap->pVE = null; + } + + delete pOverlayBitmap; + } + + if (__pTextVE != null) + { + if (__pBase != null) + { + __pBase->DetachChild(*__pTextVE); + } + + __pTextVE->Destroy(); + __pTextVE = null; + } + + if (__pCheckVE != null) + { + if (__pBase != null) + { + __pBase->DetachChild(*__pCheckVE); + } + + __pCheckVE->Destroy(); + __pCheckVE = null; + } + + if (__pBase != null) + { + VisualElement* pParent = __pBase->GetParent(); + if (pParent != null) + { + pParent->DetachChild(*__pBase); + } + __pBase->Destroy(); + __pBase = null; + } + + __overlayBitmaps.clear(); +} + +_IconListItem* +_IconListItem::CreateIconListItemN(IconListViewItem* pIconListViewItem) +{ + result r = E_SUCCESS; + _IconListItem* pItem = null; + _VisualElement* pBase = new (std::nothrow) _VisualElement; + SysTryReturn(NID_UI_CTRL, (pBase != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pBase->Construct(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + ClearLastResult(); + + pBase->SetSurfaceOpaque(false); + pBase->SetImplicitAnimationEnabled(false); + + pItem = new (std::nothrow) _IconListItem(pBase); + SysTryCatch(NID_UI_CTRL, pItem != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pItem->SetAppInfo(pIconListViewItem); + + return pItem; +CATCH: + pBase->Destroy(); + + return null; +} + +bool +_IconListItem::DrawItem(Rectangle& rcItem, ListItemState isFocused, bool itemDivider) +{ + SysAssertf(__pProperty != null, "Not yet initialized. SetDrawingProperty() should be called before use."); + + ClearLastResult(); + + if (!__pBase->GetShowState()) + { + __pBase->SetShowState(true); + } + + __pBase->SetBounds(FloatRectangle(rcItem.x, rcItem.y, rcItem.width, rcItem.height)); + + if (!__pProperty->IsChanged() && __isDrawn && __foreDrawnState == isFocused) + { + return true; + } + + Canvas* pCanvas = __pBase->GetCanvasN(Rectangle(0, 0, rcItem.width, rcItem.height)); + if (pCanvas == null) + { + return false; + } + + // Draw Background Color + IconListViewItemDrawingStatus status = _IconListUtils::EnumConverter::ConvertListItemStateToIconListViewItemDrawingStatus(isFocused); + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + int margin = __pProperty->GetSelectBackgroundMargin(); + pCanvas->FillRectangle(__pProperty->GetBackgroundColor(status), Rectangle(margin, margin, rcItem.width - margin, rcItem.height - margin)); + + // Draw Bitmap + Bitmap* pBitmap = (__pBitmap[isFocused] != null) ? __pBitmap[isFocused] : __pBitmap[ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL]; + if (pBitmap != null) + { + DrawBitmap(*pCanvas, *pBitmap, (status == ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED)); + } + + // Draw Text + DrawText(__pProperty->GetTextColor(status)); + + // Draw Check + if (__pProperty->IsItemCheckedStyle()) + { + DrawCheck(*pCanvas); + } + + // Draw Overlay Bitmap + if (__overlayBitmaps.size() > 0) + { + DrawOverlayBitmaps(); + } + + __pBase->SetFlushNeeded(); + __isDrawn = true; + __foreDrawnState = isFocused; + delete pCanvas; + + return true; +} + +result +_IconListItem::DrawItemTouchAnimation(Rectangle& rcItem, float ratio) +{ + SysAssertf(__pProperty != null, "Not yet initialized. SetDrawingProperty() should be called before use."); + + __pBase->SetBounds(FloatRectangle(rcItem.x, rcItem.y, rcItem.width, rcItem.height)); + + if (!__pBase->GetShowState()) + { + __pBase->SetShowState(true); + } + + Canvas* pCanvas = __pBase->GetCanvasN(Rectangle(0, 0, rcItem.width, rcItem.height)); + if (pCanvas == null) + { + result r = GetLastResult(); + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + + pCanvas->SetBackgroundColor(__pProperty->GetBackgroundColor(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL)); + pCanvas->Clear(); + + // Draw Bitmap + Bitmap* pBitmap = __pBitmap[ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL]; + if (pBitmap != null) + { + DrawBitmap(*pCanvas, *pBitmap, false, ratio); + } + + // Draw Text + DrawText(__pProperty->GetTextColor(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL)); + + // Draw Check + if (__pProperty->IsItemCheckedStyle()) + { + DrawCheck(*pCanvas); + } + + if (__overlayBitmaps.size() > 0) + { + DrawOverlayBitmaps(); + } + + __isDrawn = false; + delete pCanvas; + + return E_SUCCESS; +} + +result +_IconListItem::DrawItemCheckAnimation(Tizen::Graphics::Rectangle& rcItem, float ratio) +{ + SysAssertf(__pProperty != null, "Not yet initialized. SetDrawingProperty() should be called before use."); + + __pBase->SetBounds(FloatRectangle(rcItem.x, rcItem.y, rcItem.width, rcItem.height)); + + if (!__pBase->GetShowState()) + { + __pBase->SetShowState(true); + } + + Canvas* pCanvas = __pBase->GetCanvasN(Rectangle(0, 0, rcItem.width, rcItem.height)); + if (pCanvas == null) + { + result r = GetLastResult(); + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + + pCanvas->SetBackgroundColor(__pProperty->GetBackgroundColor(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL)); + pCanvas->Clear(); + + // Draw Bitmap + Bitmap* pBitmap = __pBitmap[ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL]; + if (pBitmap != null) + { + DrawBitmap(*pCanvas, *pBitmap); + } + + // Draw Text + DrawText(__pProperty->GetTextColor(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL)); + + // Draw Check + if (__pProperty->IsItemCheckedStyle()) + { + DrawCheck(*pCanvas, ratio); + } + + if (__overlayBitmaps.size() > 0) + { + DrawOverlayBitmaps(); + } + + __isDrawn = false; + delete pCanvas; + + return E_SUCCESS; +} + +result +_IconListItem::DrawBitmap(Canvas& canvas, Bitmap& bitmap, bool isFocused, float ratio) +{ + Rectangle rect = __pProperty->GetItemBitmapBounds(); + int borderWidth = __pProperty->GetDropShadowBorderWidth(); + int dropShadowSize = __pProperty->GetDropShadowMargin() + (borderWidth << 1); + if (__pProperty->GetBorderStyle() == ICON_LIST_VIEW_ITEM_BORDER_STYLE_SHADOW) + { + rect.x += borderWidth; + rect.y += borderWidth; + rect.width -= dropShadowSize; + rect.height -= dropShadowSize; + } + + int width = rect.width; + int height = rect.height; + + // Adjust Bitmap Ratio + if (__pProperty->IsItemBitmapAsAspectRatio()) + { + width = bitmap.GetWidth() * rect.height / bitmap.GetHeight(); + height = bitmap.GetHeight() * rect.width / bitmap.GetWidth(); + if (width > rect.width) + { + width = rect.width; + } + + if (height > rect.height) + { + height = rect.height; + } + } + + // Resize & Set Alpha by Ratio(ratio < 1.0f) + if (ratio < REFERENCE_FACTOR) + { + width = width * ratio; + height = height * ratio; + bitmap.SetAlphaConstant(OPAQUE_ALPHA * ratio); + } + + // Set Bitmap Rect + rect.x += (rect.width - width) >> 1; + rect.y += (rect.height - height) >> 1; + rect.SetSize(width, height); + + switch (__pProperty->GetBorderStyle()) + { + case ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE: + { + // Draw Bitmap + if (bitmap.IsNinePatchedBitmap()) + { + canvas.DrawNinePatchedBitmap(rect, bitmap); + } + else + { + canvas.DrawBitmap(rect, bitmap); + } + break; + } + + case ICON_LIST_VIEW_ITEM_BORDER_STYLE_OUTLINE: + { + // Draw Bitmap + if (bitmap.IsNinePatchedBitmap()) + { + canvas.DrawNinePatchedBitmap(rect, bitmap); + } + else + { + canvas.DrawBitmap(rect, bitmap); + } + + if (ratio >= REFERENCE_FACTOR) + { + // Draw Outline + canvas.SetForegroundColor(__pProperty->GetBorderColor(isFocused)); + canvas.SetLineWidth(1); + Dimension dim = __pProperty->GetItemSize(); + Rectangle rect(0, 0, dim.width, dim.height); + canvas.DrawRectangle(rect); + } + break; + } + + case ICON_LIST_VIEW_ITEM_BORDER_STYLE_SHADOW: + { + if (isFocused) + { + // Draw Drop-Shadow Effect + if (__pProperty->GetFocusDropShadowBitmap() != null && ratio >= REFERENCE_FACTOR) + { + const Bitmap* pShadowBitmap = __pProperty->GetFocusDropShadowBitmap(); + if (pShadowBitmap->IsNinePatchedBitmap()) + { + canvas.DrawNinePatchedBitmap(__pProperty->GetDropShadowBitmapBounds(), *pShadowBitmap); + } + else + { + canvas.DrawBitmap(__pProperty->GetDropShadowBitmapBounds(), *pShadowBitmap); + } + } + } + else + { + // Draw Drop-Shadow Effect + if (__pProperty->GetDropShadowBitmap() != null && ratio >= REFERENCE_FACTOR) + { + const Bitmap* pShadowBitmap = __pProperty->GetDropShadowBitmap(); + if (pShadowBitmap->IsNinePatchedBitmap()) + { + canvas.DrawNinePatchedBitmap(__pProperty->GetDropShadowBitmapBounds(), *pShadowBitmap); + } + else + { + canvas.DrawBitmap(__pProperty->GetDropShadowBitmapBounds(), *pShadowBitmap); + } + } + } + + // Draw Bitmap + if (bitmap.IsNinePatchedBitmap()) + { + canvas.DrawNinePatchedBitmap(rect, bitmap); + } + else + { + canvas.DrawBitmap(rect, bitmap); + } + break; + } + } + + if (ratio < REFERENCE_FACTOR) + { + bitmap.SetAlphaConstant(OPAQUE_ALPHA); + } + + return E_SUCCESS; +} + +result +_IconListItem::DrawText(const Color& color) +{ + if (__text.IsEmpty()) + { + return E_SUCCESS; + } + + if (__pTextObject == null) + { + __pTextObject = new (std::nothrow) TextObject; + wchar_t* pStr = const_cast (__text.GetPointer()); + __pTextObject->Construct(); + TextSimple* pSimpleText = new (std::nothrow)TextSimple(pStr, __text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + __pTextObject->AppendElement(*pSimpleText); + + __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + } + + + switch (__pProperty->GetTextHorizontalAlignment()) + { + case ALIGNMENT_LEFT: + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT); + break; + + case ALIGNMENT_CENTER: + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER); + break; + + case ALIGNMENT_RIGHT: + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT); + break; + } + + __pTextObject->SetForegroundColor(color, 0, __pTextObject->GetTextLength()); + + Font* pFont = __pProperty->GetFont(); + SysTryReturn(NID_UI_CTRL, pFont != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred."); + + int textVerticalMargin = __pProperty->GetTextVerticalMargin(); + int width = __pProperty->GetTextAreaWidth(); + + __pTextObject->SetFont(pFont, 0, __pTextObject->GetTextLength()); + __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + __pTextObject->SetBounds(Rectangle(0, 0, width, 1)); + __pTextObject->Compose(); + + int height = __pTextObject->GetTotalHeight(); + int leading = _FontImpl::GetInstance((*pFont))->GetLeading(); + int textYPos = __pProperty->GetTextYPosition(); + if (height >= leading * 2) + { + textYPos = __pProperty->GetTwoLineTextYPosition(); + height = (leading + textVerticalMargin) * 2; + } + else + { + height += (textVerticalMargin * 2); + } + + if (__pProperty->GetTextVerticalAlignment() == ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM) + { + Dimension itemSize = __pProperty->GetItemSize(); + textYPos = itemSize.height - height; + } + + if (__pTextVE == null) + { + __pTextVE = new (std::nothrow) _VisualElement(); + SysTryReturn(NID_UI_CTRL, __pTextVE != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = __pTextVE->Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTextVE->SetRedrawOnResizeEnabled(false); + __pTextVE->SetImplicitAnimationEnabled(false); + + __pBase->AttachChild(*__pTextVE); + } + + __pTextVE->SetBounds(FloatRectangle(__pProperty->GetTextXPosition(), textYPos, width, height)); + __pTextVE->SetShowState(true); + + Canvas* pCanvas = __pTextVE->GetCanvasN(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + Rectangle bounds(0, 0, width, height); + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + pCanvas->FillRectangle(__pProperty->GetTextBackgroundColor(), bounds); + + __pTextObject->SetBounds(bounds); + __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + delete pCanvas; + + return E_SUCCESS; +} + +result +_IconListItem::DrawCheck(Canvas& canvas, float ratio) +{ + const Bitmap* pBackgroundBitmap = null; + const Bitmap* pBitmap = null; + pBitmap = IsChecked() ? __pProperty->GetCheckBitmap() : null; + pBackgroundBitmap = IsItemEnabled() ? (IsChecked() ? __pProperty->GetCheckedBackgroundBitmap() : __pProperty->GetUnCheckedBackgroundBitmap()) : __pProperty->GetDisabledCheckBitmap(); + + if (pBackgroundBitmap == null) + { + return E_SYSTEM; + } + + int width = pBackgroundBitmap->GetWidth(); + int height = pBackgroundBitmap->GetHeight(); + int checkMargin = __pProperty->GetCheckMargin(); + + Rectangle bitmapBounds = __pProperty->GetItemBitmapBounds(); + Point checkPosition(bitmapBounds.x, bitmapBounds.y); + switch (__pProperty->GetCheckBoxPosition()) + { + case ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT: + checkPosition.x += checkMargin; + checkPosition.y += checkMargin; + break; + + case ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT: + checkPosition.x += bitmapBounds.width - checkMargin - width; + checkPosition.y += checkMargin; + break; + + case ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_LEFT: + checkPosition.x += checkMargin; + checkPosition.y += bitmapBounds.height - checkMargin - height; + break; + + case ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_RIGHT: + checkPosition.x += bitmapBounds.width - checkMargin - width; + checkPosition.y += bitmapBounds.height - checkMargin - height; + break; + } + + // draw background of check box + if (pBackgroundBitmap->IsNinePatchedBitmap()) + { + canvas.DrawNinePatchedBitmap(Rectangle(checkPosition.x, checkPosition.y, width, height), *pBackgroundBitmap); + } + else + { + canvas.DrawBitmap(checkPosition, *pBackgroundBitmap); + } + + // draw check image + if (__pCheckVE == null) + { + __pCheckVE = new (std::nothrow) _VisualElement(); + SysTryReturn(NID_UI_CTRL, __pCheckVE != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = __pCheckVE->Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pCheckVE->SetRedrawOnResizeEnabled(false); + __pCheckVE->SetImplicitAnimationEnabled(false); + __pBase->AttachChild(*__pCheckVE); + } + + FloatRectangle checkRect(checkPosition.x, checkPosition.y, width, height); + __pCheckVE->SetBounds(checkRect); + __pCheckVE->SetShowState(true); + + Canvas* pCanvas = __pCheckVE->GetCanvasN(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + if (pBitmap != null) + { + if (pBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()), *pBitmap); + } + else + { + Rectangle animationRect(0, 0, pBitmap->GetWidth() * ratio, pBitmap->GetHeight()); + pCanvas->DrawBitmap(animationRect, *pBitmap, animationRect); + } + } + delete pCanvas; + + return E_SUCCESS; +} + +result +_IconListItem::DrawOverlayBitmaps(void) +{ + result r = E_SUCCESS; + Rectangle bitmapBounds = __pProperty->GetItemBitmapBounds(); + Canvas* pCanvas = null; + for (int i = 0, n = __overlayBitmaps.size(); i < n; i++) + { + _OverlayBitmap* pOverlayBitmap = __overlayBitmaps.at(i); + int overlayMargin = __pProperty->GetOverlayMargin(); + if (pOverlayBitmap->pBitmap != null) + { + Rectangle rect = GetOverlayBitmapBounds(pOverlayBitmap, bitmapBounds, overlayMargin); + + _VisualElement* pVE = null; + if (pOverlayBitmap->pVE == null) + { + pVE = new (std::nothrow) _VisualElement(); + SysTryReturn(NID_UI_CTRL, pVE != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pVE->Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pVE->SetRedrawOnResizeEnabled(false); + pVE->SetImplicitAnimationEnabled(false); + + __pBase->AttachChild(*pVE); + pOverlayBitmap->pVE = pVE; + } + else + { + pVE = pOverlayBitmap->pVE; + } + + pVE->SetBounds(FloatRectangle(rect.x, rect.y, rect.width, rect.height)); + pVE->SetShowState(true); + + pCanvas = pVE->GetCanvasN(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + Bitmap* pBitmap = pOverlayBitmap->pBitmap; + if(pBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, rect.width, rect.height), *pBitmap); + } + else + { + pCanvas->DrawBitmap(Rectangle(0, 0, rect.width, rect.height), *pBitmap); + } + delete pCanvas; + } + } + return r; +} + +result +_IconListItem::SetText(const String* pText) +{ + if (pText == null) + { + __text = String(L""); + return E_SUCCESS; + } + + __text = *pText; + __isDrawn = false; + + return E_SUCCESS; +} + +const String& +_IconListItem::GetText(void) const +{ + return __text; +} + +result +_IconListItem::SetBitmap(IconListViewItemDrawingStatus status, const Bitmap* pBitmap) +{ + if (ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL > status + || ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED < status) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used."); + return E_INVALID_ARG; + } + + SysTryReturn(NID_UI_CTRL, (status != ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL || pBitmap != null), E_INVALID_ARG, + E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. The normal bitmap must not be null."); + + result r = E_SUCCESS; + Bitmap* pCopiedBitmap = null; + if (pBitmap != null) + { + pCopiedBitmap = _BitmapImpl::CloneN(*pBitmap); + r = GetLastResult(); + } + + if (r == E_SUCCESS) + { + delete __pBitmap[status]; + __pBitmap[status] = pCopiedBitmap; + } + + __isDrawn = false; + + return r; +} + +const Bitmap* +_IconListItem::GetBitmap(IconListViewItemDrawingStatus status) const +{ + SysTryReturn(NID_UI_CTRL, + (status > ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL && status < ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED), + null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used."); + + SetLastResult(E_SUCCESS); + return __pBitmap[status]; +} + +Tizen::Ui::Animations::_VisualElement* +_IconListItem::GetVisualElement(void) const +{ + return __pBase; +} + +void +_IconListItem::ClearVisualElement(void) +{ + __isDrawn = false; +} + +result +_IconListItem::SetDrawingProperty(_IconListItemDrawingProperty& property) +{ + __pProperty = &property; + + return E_SUCCESS; +} + +void +_IconListItem::SetChecked(bool checked) +{ + if (IsChecked() == checked) + { + return; + } + + _ListItemCommon::SetChecked(checked); + __isDrawn = false; +} + +void +_IconListItem::SetItemIndex(int groupIndex, int itemIndex) +{ + __itemIndex = itemIndex; +} + +void +_IconListItem::GetItemIndex(int& groupIndex, int& itemIndex) const +{ + groupIndex = DEFAULT_GROUP_INDEX; + itemIndex = __itemIndex; +} + +result +_IconListItem::SetOverlayBitmap(int overlayBitmapId, const Tizen::Graphics::Bitmap* pOverlayBitmap, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, horizontalAlignment >= ALIGNMENT_LEFT && horizontalAlignment <= ALIGNMENT_RIGHT, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The horizontal alignment is inappropriate."); + SysTryReturn(NID_UI_CTRL, verticalAlignment >= ALIGNMENT_TOP && verticalAlignment <= ALIGNMENT_BOTTOM, E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The vertical alignment is inappropriate."); + + bool found = false; + Bitmap* pCopiedBitmap = null; + for (int i = 0, n = __overlayBitmaps.size() ; i < n; i++) + { + _OverlayBitmap* pCurrentOverlayBitmap = __overlayBitmaps.at(i); + if (pCurrentOverlayBitmap->horizontalAlignment == horizontalAlignment && pCurrentOverlayBitmap->verticalAlignment == verticalAlignment) + { + found = true; + if (pOverlayBitmap == null) + { + // delete overlay bitmap + delete pCurrentOverlayBitmap->pBitmap; + pCurrentOverlayBitmap->pBitmap = null; + + if (pCurrentOverlayBitmap->pVE != null) + { + pCurrentOverlayBitmap->pVE->Destroy(); + pCurrentOverlayBitmap->pVE = null; + } + __overlayBitmaps.erase(__overlayBitmaps.begin() + i); + delete pCurrentOverlayBitmap; + } + else + { + // replace overlay bitmap + pCopiedBitmap = null; + pCopiedBitmap = _BitmapImpl::CloneN(*pOverlayBitmap); + r = GetLastResult(); + + if (r == E_SUCCESS) + { + delete pCurrentOverlayBitmap->pBitmap; + pCurrentOverlayBitmap->pBitmap = pCopiedBitmap; + pCurrentOverlayBitmap->id = overlayBitmapId; + } + } + break; + } + } + + if (!found) + { + if (pOverlayBitmap != null) + { + // add overlay bitmap + pCopiedBitmap = null; + pCopiedBitmap = _BitmapImpl::CloneN(*pOverlayBitmap); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _OverlayBitmap* pNewOverlayBitmap = new (std::nothrow) _OverlayBitmap(); + pNewOverlayBitmap->id = overlayBitmapId; + pNewOverlayBitmap->pBitmap = pCopiedBitmap; + pNewOverlayBitmap->horizontalAlignment = horizontalAlignment; + pNewOverlayBitmap->verticalAlignment = verticalAlignment; + pNewOverlayBitmap->pVE = null; + + __overlayBitmaps.push_back(pNewOverlayBitmap); + } + } + + SetLastResult(r); + return r; +} + +int +_IconListItem::GetOverlayBitmapIdFromPosition(Point& position) const +{ + if (__overlayBitmaps.size() <= 0) + { + return -1; + } + + Rectangle bitmapBounds = __pProperty->GetItemBitmapBounds(); + for (int i = __overlayBitmaps.size() - 1; i >= 0; i--) + { + _OverlayBitmap* pOverlayBitmap = __overlayBitmaps.at(i); + if (pOverlayBitmap != null) + { + int overlayMargin = __pProperty->GetOverlayMargin(); + if (pOverlayBitmap->pBitmap != null) + { + Rectangle rect = GetOverlayBitmapBounds(pOverlayBitmap, bitmapBounds, overlayMargin); + if (rect.Contains(position)) + { + return pOverlayBitmap->id; + } + } + } + } + + return -1; +} + +_VisualElement* +_IconListItem::GetItemVisualElement(void) const +{ + return __pBase; +} + +Rectangle +_IconListItem::GetOverlayBitmapBounds(_OverlayBitmap* pOverlayBitmap, const Rectangle& parentRect, int margin) const +{ + int x = parentRect.x; + int y = parentRect.y; + int width = pOverlayBitmap->pBitmap->GetWidth(); + int height = pOverlayBitmap->pBitmap->GetHeight(); + + switch (pOverlayBitmap->horizontalAlignment) + { + case ALIGNMENT_LEFT: + x += margin; + break; + case ALIGNMENT_CENTER: + x += (parentRect.width - width) / 2; + break; + case ALIGNMENT_RIGHT: + x += (parentRect.width - width - margin); + break; + } + + switch (pOverlayBitmap->verticalAlignment) + { + case ALIGNMENT_TOP: + y += margin; + break; + case ALIGNMENT_MIDDLE: + y += (parentRect.height - height) / 2; + break; + case ALIGNMENT_BOTTOM: + y += (parentRect.height - height - margin); + break; + } + + return Rectangle(x, y, width, height); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IconListItemDrawingProperty.cpp b/src/ui/controls/FUiCtrl_IconListItemDrawingProperty.cpp new file mode 100644 index 0000000..ecc7cf6 --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListItemDrawingProperty.cpp @@ -0,0 +1,743 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListItemDrawingProperty.cpp + * @brief This is the implementation file for the _IconListItemDrawingProperty class. + */ + +//Includes +#include +#include + +#include "FUi_ResourceManager.h" +#include "FUiCtrl_IconListItemDrawingProperty.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_IconListItemDrawingProperty::_IconListItemDrawingProperty(void) + : __textSize(0) + , __pFont(null) + , __normalTextColor(0) + , __pressedTextColor(0) + , __highlightedTextColor(0) + , __size(0, 0) + , __bitmapBounds(0, 0, 0, 0) + , __pDropShadowBitmap(null) + , __pFocusDropShadowBitmap(null) + , __pDropShadowBitmapWithReplacementColor(null) + , __dropShadowBorderWidth(0) + , __dropShadowMargin(0) + , __pCheckBitmap(null) + , __pCheckedBackgroundBitmap(null) + , __pUnCheckedBackgroundBitmap(null) + , __pDisabledCheckBitmap(null) + , __checkMargin(0) + , __overlayMargin(0) + , __pressedBackgroundColor(0) + , __normalBorderColor(0) + , __focusBorderColor(0) + , __inTextBackgroundColor(0) + , __textYPos(0) + , __2LineTextYPos(0) + , __checkBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT) + , __borderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE) + , __textHorizontalAlignment(ALIGNMENT_CENTER) + , __textVerticalAlignment(ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM) + , __refCount(1) + , __changed(true) + , __asAspectRatio(true) + , __checkedStyle(false) + , __verticalExtent(0) + , __insideOneLineTextHeight(0) + , __insideTwoLineTextHeight(0) + , __selectBackgroundMargin(0) + , __itemTextHorizontalMargin(0) + , __itemTextVerticalMargin(0) +{ + // Do nothing +} + +_IconListItemDrawingProperty::~_IconListItemDrawingProperty(void) +{ + delete __pDropShadowBitmap; + __pDropShadowBitmap = null; + + delete __pFocusDropShadowBitmap; + __pFocusDropShadowBitmap = null; + + delete __pDropShadowBitmapWithReplacementColor; + __pDropShadowBitmapWithReplacementColor = null; + + delete __pCheckBitmap; + __pCheckBitmap = null; + + delete __pCheckedBackgroundBitmap; + __pCheckedBackgroundBitmap = null; + + delete __pUnCheckedBackgroundBitmap; + __pUnCheckedBackgroundBitmap = null; + + delete __pDisabledCheckBitmap; + __pDisabledCheckBitmap = null; +} + +_IconListItemDrawingProperty* +_IconListItemDrawingProperty::CreateInstanceN(void) +{ + _IconListItemDrawingProperty* pProperty = new (std::nothrow) _IconListItemDrawingProperty; + SysTryReturn(NID_UI_CTRL, (pProperty != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pProperty->Initialize(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pProperty; + +CATCH: + delete pProperty; + + return null; +} + +result +_IconListItemDrawingProperty::Initialize(void) +{ + result r = E_SUCCESS; + + int width = 0; + int height = 0; + + // Load Drop Shadow Bitmap + GET_FIXED_VALUE_CONFIG(ICONLIST::DROP_SHADOW_BORDER, _CONTROL_ORIENTATION_PORTRAIT, __dropShadowBorderWidth); + GET_FIXED_VALUE_CONFIG(ICONLIST::DROP_SHADOW_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __dropShadowMargin); + GET_FIXED_VALUE_CONFIG(ICONLIST::DROP_SHADOW_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, width); + GET_FIXED_VALUE_CONFIG(ICONLIST::DROP_SHADOW_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, height); + + if (width > 0 && height > 0) + { + r = GET_BITMAP_CONFIG_N(ICONLIST::ITEM_BORDER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDropShadowBitmap); + if (r != E_SUCCESS) + { + delete __pDropShadowBitmap; + __pDropShadowBitmap = null; + + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + + r = GET_BITMAP_CONFIG_N(ICONLIST::ITEM_BORDER_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pFocusDropShadowBitmap); + if (r != E_SUCCESS) + { + delete __pFocusDropShadowBitmap; + __pFocusDropShadowBitmap = null; + + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + } + + // Load Check Bitmap + GET_FIXED_VALUE_CONFIG(ICONLIST::CHECKBOX_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __checkMargin); + + Dimension dimension(0, 0); + GET_DIMENSION_CONFIG(ICONLIST::CHECKBOX_SIZE, _CONTROL_ORIENTATION_PORTRAIT, dimension); + width = dimension.width; + height = dimension.height; + + if (width > 0 && height > 0) + { + r = GET_BITMAP_CONFIG_N(ICONLIST::CHECK_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pCheckBitmap); + if (r != E_SUCCESS) + { + delete __pCheckBitmap; + __pCheckBitmap = null; + + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + + r = GET_BITMAP_CONFIG_N(ICONLIST::CHECK_BG_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pCheckedBackgroundBitmap); + if (r != E_SUCCESS) + { + delete __pCheckedBackgroundBitmap; + __pCheckedBackgroundBitmap = null; + + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + + r = GET_BITMAP_CONFIG_N(ICONLIST::CHECK_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pUnCheckedBackgroundBitmap); + if (r != E_SUCCESS) + { + delete __pUnCheckedBackgroundBitmap; + __pUnCheckedBackgroundBitmap = null; + + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + } + + // Load overaly bitmap margin + GET_FIXED_VALUE_CONFIG(ICONLIST::OVERLAY_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __overlayMargin); + + // Load item press state background color + GET_COLOR_CONFIG(ICONLIST::ITEM_BG_PRESSED, __pressedBackgroundColor); + __pressedBackgroundColor.SetAlpha(0x80); + + // Load border color + GET_COLOR_CONFIG(ICONLIST::ITEM_BORDER_NORMAL, __normalBorderColor); + GET_COLOR_CONFIG(ICONLIST::ITEM_BORDER_HIGHLIGHTED, __focusBorderColor); + + // Load Drop Shadow Bitmap with Replacement Color + if (__pDropShadowBitmap != null) + { + __pDropShadowBitmapWithReplacementColor = _BitmapImpl::GetColorReplacedBitmapN(*__pDropShadowBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __normalBorderColor); + SysTryReturn(NID_UI_CTRL, (__pDropShadowBitmapWithReplacementColor != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + // Load Item Text Size & color + GET_SHAPE_CONFIG(ICONLIST::FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __textSize); + + GET_COLOR_CONFIG(ICONLIST::TEXT_NORMAL, __normalTextColor); + GET_COLOR_CONFIG(ICONLIST::TEXT_PRESSED, __pressedTextColor); + GET_COLOR_CONFIG(ICONLIST::TEXT_HIGHLIGHTED, __highlightedTextColor); + + GET_COLOR_CONFIG(ICONLIST::INNER_TEXT_BG_NORMAL, __inTextBackgroundColor); + __inTextBackgroundColor.SetAlpha(0x80); + + // Load Item text height + GET_SHAPE_CONFIG(ICONLIST::VERTICAL_EXTENT, _CONTROL_ORIENTATION_PORTRAIT, __verticalExtent); + GET_SHAPE_CONFIG(ICONLIST::INSIDE_ONE_LINE_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __insideOneLineTextHeight); + GET_SHAPE_CONFIG(ICONLIST::INSIDE_TWO_LINE_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __insideTwoLineTextHeight); + + // Load item margin + GET_FIXED_VALUE_CONFIG(ICONLIST::SELECT_BG_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __selectBackgroundMargin); + GET_FIXED_VALUE_CONFIG(ICONLIST::TEXT_HORIZONTAL_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __itemTextHorizontalMargin); + GET_FIXED_VALUE_CONFIG(ICONLIST::TEXT_VERTICAL_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __itemTextVerticalMargin); + + return r; +} + +const Color +_IconListItemDrawingProperty::GetBackgroundColor(IconListViewItemDrawingStatus status) const +{ + SysTryReturn(NID_UI_CTRL, + (status >= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL && status <= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED), + Color(0), E_INVALID_ARG, "[E_INVALID_ARG] Invalid value of drawing status is used."); + + ClearLastResult(); + if (status == ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED) + { + return __pressedBackgroundColor; + } + return Color(0, 0, 0, 0); +} + +result +_IconListItemDrawingProperty::SetTextSize(int size) +{ + int minSize = 0; + GET_FIXED_VALUE_CONFIG(ICONLIST::MINIMUM_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, minSize); + SysTryReturn(NID_UI_CTRL, (size >= minSize), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Font size should be greater than or equal to the minimum size."); + + if (__textSize != size) + { + __textSize = size; + } + + return E_SUCCESS; +} + +int +_IconListItemDrawingProperty::GetTextSize(void) const +{ + ClearLastResult(); + return __textSize; +} + +result +_IconListItemDrawingProperty::SetFont(Font* pFont) +{ + SysTryReturn(NID_UI_CTRL, pFont != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used."); + + if (pFont == __pFont) + { + return E_SUCCESS; + } + + __pFont = pFont; + + int oldVerticalExtent = __verticalExtent; + int defaultTextSize = 0; + GET_SHAPE_CONFIG(ICONLIST::FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, defaultTextSize); + + if (__textSize != defaultTextSize) + { + int leading = _FontImpl::GetInstance(*__pFont)->GetLeading(); + __insideOneLineTextHeight = leading + __itemTextVerticalMargin * 2; + __insideTwoLineTextHeight = (leading << 1) + __itemTextVerticalMargin * 2; + __verticalExtent = __insideTwoLineTextHeight; + } + else + { + GET_SHAPE_CONFIG(ICONLIST::VERTICAL_EXTENT, _CONTROL_ORIENTATION_PORTRAIT, __verticalExtent); + GET_SHAPE_CONFIG(ICONLIST::INSIDE_ONE_LINE_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __insideOneLineTextHeight); + GET_SHAPE_CONFIG(ICONLIST::INSIDE_TWO_LINE_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __insideTwoLineTextHeight); + } + + if (__textVerticalAlignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP) + { + __size.height -= oldVerticalExtent; + __size.height = __size.height + __insideTwoLineTextHeight; + } + + __changed = true; + + // Adjust layout of Item. + return SetItemLayout(); +} + +Font* +_IconListItemDrawingProperty::GetFont(void) const +{ + return __pFont; +} + +result +_IconListItemDrawingProperty::SetTextColor(IconListViewItemDrawingStatus status, const Color color) +{ + SysTryReturn(NID_UI_CTRL, + (status >= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL && status <= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED), + E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid value of drawing status."); + + if (status == ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL) + { + __normalTextColor = color; + } + else if (status == ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED) + { + __pressedTextColor = color; + } + else + { + __highlightedTextColor = color; + } + + __changed = true; + return E_SUCCESS; +} + +const Color +_IconListItemDrawingProperty::GetTextColor(IconListViewItemDrawingStatus status) const +{ + SysTryReturn(NID_UI_CTRL, + (status >= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL && status <= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED), + Color(0), E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid value of drawing status."); + + ClearLastResult(); + + if (status == ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL) + { + return __normalTextColor; + } + else if (status == ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED) + { + return __pressedTextColor; + } + else + { + return __highlightedTextColor; + } +} + +const Color +_IconListItemDrawingProperty::GetTextBackgroundColor(void) const +{ + if (__textVerticalAlignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP) + { + return Color(0, 0, 0, 0); + } + return __inTextBackgroundColor; +} + +const Color +_IconListItemDrawingProperty::GetBorderColor(bool isFocused) const +{ + return isFocused ? __focusBorderColor : __normalBorderColor; +} + +result +_IconListItemDrawingProperty::SetItemLayout(void) +{ + SysTryReturn( + NID_UI_CTRL, + (__textVerticalAlignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP && __textVerticalAlignment <= + ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_BOTTOM), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has been occurred. The current state of vertical text alignment is not valid."); + + switch (__textVerticalAlignment) + { + case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP: + __textYPos = 0; + __2LineTextYPos = __textYPos; + break; + + case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_MIDDLE: + __textYPos = (__size.height - __insideOneLineTextHeight) >> 1; + __2LineTextYPos = (__size.height - __insideTwoLineTextHeight) >> 1; + break; + + case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM: + __textYPos = __size.height - __insideOneLineTextHeight; + __2LineTextYPos = __size.height - __insideTwoLineTextHeight; + break; + + case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP: + __textYPos = __insideOneLineTextHeight - __itemTextVerticalMargin; + __2LineTextYPos = 0; + break; + + case ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_BOTTOM: + __textYPos = __size.height - __verticalExtent; + __2LineTextYPos = __textYPos; + break; + } + __changed = true; + + return E_SUCCESS; +} + +result +_IconListItemDrawingProperty::SetItemBitmapBounds(const Rectangle bounds) +{ + SysTryReturn(NID_UI_CTRL, (bounds.x >= 0 && bounds.y >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. X and Y must be a non negative integer."); + SysTryReturn(NID_UI_CTRL, (bounds.width > 0 && bounds.height > 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Width and Height size should be larger than 0."); + + __bitmapBounds = bounds; + __size.width = bounds.width; + __size.height = bounds.height; + + if (__textVerticalAlignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP) + { + __size.height += __insideTwoLineTextHeight; + + } + + return SetItemLayout(); +} + +const Rectangle +_IconListItemDrawingProperty::GetItemBitmapBounds(void) const +{ + ClearLastResult(); + + Rectangle bounds(__bitmapBounds); + if (__textVerticalAlignment == ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP) + { + bounds.y += __verticalExtent; + } + + return bounds; +} + +const Tizen::Graphics::Dimension +_IconListItemDrawingProperty::GetItemBitmapSize(void) const +{ + ClearLastResult(); + return Dimension(__bitmapBounds.width, __bitmapBounds.height); +} + +result +_IconListItemDrawingProperty::SetItemSize(const Tizen::Graphics::Dimension size) +{ + SysTryReturn(NID_UI_CTRL, (size.width > 0 && size.height > 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Width and Height size should be larger than 0."); + + __size = size; + return E_SUCCESS; +} + +const Tizen::Graphics::Dimension +_IconListItemDrawingProperty::GetItemSize(void) const +{ + ClearLastResult(); + return __size; +} + +const int +_IconListItemDrawingProperty::GetTextXPosition(void) const +{ + return __itemTextHorizontalMargin; +} + +const int +_IconListItemDrawingProperty::GetTextYPosition(void) const +{ + return __textYPos; +} + +const int +_IconListItemDrawingProperty::GetTwoLineTextYPosition(void) const +{ + return __2LineTextYPos; +} + +const int +_IconListItemDrawingProperty::GetTextAreaWidth(void) const +{ + return __bitmapBounds.width - __itemTextHorizontalMargin * 2; +} + +const int +_IconListItemDrawingProperty::GetTextVerticalMargin(void) const +{ + return __itemTextVerticalMargin; +} + +result +_IconListItemDrawingProperty::SetCheckBoxPosition(IconListViewCheckBoxPosition position) +{ + SysTryReturn( + NID_UI_CTRL, + (position >= ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT && position <= ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_RIGHT), + E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid position of CheckBox is used."); + + __checkBoxPosition = position; + __changed = true; + + return E_SUCCESS; +} + +IconListViewCheckBoxPosition +_IconListItemDrawingProperty::GetCheckBoxPosition(void) const +{ + return __checkBoxPosition; +} + +result +_IconListItemDrawingProperty::SetBorderStyle(IconListViewItemBorderStyle style) +{ + SysTryReturn(NID_UI_CTRL, (style >= ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE && style <= ICON_LIST_VIEW_ITEM_BORDER_STYLE_SHADOW), + E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid item border style is used."); + + __borderStyle = style; + __changed = true; + + return E_SUCCESS; +} + +IconListViewItemBorderStyle +_IconListItemDrawingProperty::GetBorderStyle(void) const +{ + ClearLastResult(); + return __borderStyle; +} + +result +_IconListItemDrawingProperty::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + SysTryReturn(NID_UI_CTRL, (alignment >= ALIGNMENT_LEFT && alignment <= ALIGNMENT_RIGHT), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has been occurred. Invalid horizontal text alignment is used."); + + __textHorizontalAlignment = alignment; + __changed = true; + + return E_SUCCESS; +} + +HorizontalAlignment +_IconListItemDrawingProperty::GetTextHorizontalAlignment(void) const +{ + return __textHorizontalAlignment; +} + +result +_IconListItemDrawingProperty::SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment) +{ + SysTryReturn( + NID_UI_CTRL, + (alignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP && alignment <= + ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_BOTTOM), + E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid vertical text alignment is used."); + + if (alignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP + && __textVerticalAlignment < ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP) + { + __size.height = __size.height + __verticalExtent; + } + else if (alignment < ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP + && __textVerticalAlignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP) + { + __size.height -= __verticalExtent; + } + + __textVerticalAlignment = alignment; + __changed = true; + + // Adjust layout of Item. + return SetItemLayout(); +} + +IconListViewItemTextVerticalAlignment +_IconListItemDrawingProperty::GetTextVerticalAlignment(void) const +{ + return __textVerticalAlignment; +} + +const Tizen::Graphics::Bitmap* +_IconListItemDrawingProperty::GetDropShadowBitmap(void) const +{ + return __pDropShadowBitmapWithReplacementColor; +} + +const Tizen::Graphics::Bitmap* +_IconListItemDrawingProperty::GetFocusDropShadowBitmap(void) const +{ + return __pFocusDropShadowBitmap; +} + +int +_IconListItemDrawingProperty::GetDropShadowBorderWidth(void) const +{ + return __dropShadowBorderWidth; +} + +int +_IconListItemDrawingProperty::GetDropShadowMargin(void) const +{ + return __dropShadowMargin; +} + +const Rectangle +_IconListItemDrawingProperty::GetDropShadowBitmapBounds(void) const +{ + Rectangle bounds(__bitmapBounds); + if (__textVerticalAlignment == ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP) + { + bounds.y += __verticalExtent; + } + + return bounds; +} + +const Tizen::Graphics::Bitmap* +_IconListItemDrawingProperty::GetCheckBitmap(void) const +{ + return __pCheckBitmap; +} + +const Tizen::Graphics::Bitmap* +_IconListItemDrawingProperty::GetCheckedBackgroundBitmap(void) const +{ + return __pCheckedBackgroundBitmap; +} + +const Tizen::Graphics::Bitmap* +_IconListItemDrawingProperty::GetUnCheckedBackgroundBitmap(void) const +{ + return __pUnCheckedBackgroundBitmap; +} + +const Tizen::Graphics::Bitmap* +_IconListItemDrawingProperty::GetDisabledCheckBitmap(void) const +{ + return __pDisabledCheckBitmap; +} + +void +_IconListItemDrawingProperty::SetItemCheckedStyle(bool checkStyle) +{ + __checkedStyle = checkStyle; +} + +bool +_IconListItemDrawingProperty::IsItemCheckedStyle(void) const +{ + return __checkedStyle; +} + +int +_IconListItemDrawingProperty::GetCheckMargin(void) const +{ + return __checkMargin; +} + +int +_IconListItemDrawingProperty::GetOverlayMargin(void) const +{ + return __overlayMargin; +} + +int +_IconListItemDrawingProperty::GetSelectBackgroundMargin(void) const +{ + return __selectBackgroundMargin; +} + +void +_IconListItemDrawingProperty::SetDrawingFlag(void) +{ + __changed = false; +} + +bool +_IconListItemDrawingProperty::IsChanged(void) const +{ + return __changed; +} + +int +_IconListItemDrawingProperty::AddRef(void) +{ + return ++__refCount; +} + +int +_IconListItemDrawingProperty::Release(void) +{ + --__refCount; + if (__refCount <= 0) + { + delete this; + return 0; + } + + return __refCount; +} + +void +_IconListItemDrawingProperty::SetItemBitmapAsAspectRatio(bool isAspect) +{ + __asAspectRatio = isAspect; +} + +bool +_IconListItemDrawingProperty::IsItemBitmapAsAspectRatio(void) const +{ + return __asAspectRatio; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IconListItemProvider.cpp b/src/ui/controls/FUiCtrl_IconListItemProvider.cpp new file mode 100644 index 0000000..6d0358d --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListItemProvider.cpp @@ -0,0 +1,95 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include "FUiCtrl_IconListItemProvider.h" +#include "FUiCtrl_IconListImpl.h" +#include "FUiCtrl_IconListData.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_IconListItemProvider::_IconListItemProvider(_IconListImpl* pIconList) + : __pIconListImpl(pIconList) +{ +} + +_IconListItemProvider::~_IconListItemProvider(void) +{ +} + +int +_IconListItemProvider::GetItemCount(void) +{ + if (__pIconListImpl) + { + return __pIconListImpl->__iconList.GetCount(); + } + + return 0; +} + +IconListViewItem* +_IconListItemProvider::CreateItem(int index) +{ + _IconListData* pIconListData = null; + pIconListData = dynamic_cast< _IconListData* >(__pIconListImpl->__iconList.GetAt(index)); + + if (pIconListData) + { + IconListViewItem* pIconListViewItem = null; + pIconListViewItem = new (std::nothrow) IconListViewItem(); + SysTryReturn(NID_UI_CTRL, pIconListViewItem, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + String labelText = pIconListData->GetLabelText(); + const Bitmap* pNormalBitmap = pIconListData->GetNormalBitmap(); + const Bitmap* pFocusedBitmap = pIconListData->GetFocusedBitmap(); + + if (pNormalBitmap != null && pFocusedBitmap != null) + { + pIconListViewItem->Construct(*pNormalBitmap, &labelText, pFocusedBitmap); + } + else if (pNormalBitmap != null) + { + pIconListViewItem->Construct(*pNormalBitmap, &labelText); + } + else + { + delete pIconListViewItem; + pIconListViewItem = null; + return null; + } + + return pIconListViewItem; + } + + return null; +} + +bool +_IconListItemProvider::DeleteItem(int index, Tizen::Ui::Controls::IconListViewItem* pItem) +{ + return false; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IconListItemProviderAdaptor.cpp b/src/ui/controls/FUiCtrl_IconListItemProviderAdaptor.cpp new file mode 100644 index 0000000..6e312cc --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListItemProviderAdaptor.cpp @@ -0,0 +1,264 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListItemProviderAdaptor.cpp + * @brief This is the implementation file for the _IconListItemProviderAdaptor class. + */ + +//Includes +#include +#include +#include + +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_IconListItem.h" +#include "FUiCtrl_IconListItemProviderAdaptor.h" +#include "FUiCtrl_IconListViewItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_IconListItemProviderAdaptor::_IconListItemProviderAdaptor(void) + : __pItemProvider(null) + , __pBlankItem(null) + , __pRoot(null) +{ + // Do nothing +} + +_IconListItemProviderAdaptor::~_IconListItemProviderAdaptor(void) +{ + __pItemProvider = null; + + delete __pBlankItem; + __pBlankItem = null; + + __pRoot = null; +} + +// Operation +_IListItemCommon* +_IconListItemProviderAdaptor::GetBlankItem(void) const +{ + if (__pBlankItem == null) + { + // Create Default Blank Item. + _IconListItem* pBlankItem = _IconListItem::CreateIconListItemN(null); + SysTryReturn(NID_UI_CTRL, (pBlankItem != null), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + const_cast<_IconListItemProviderAdaptor*>(this)->__pBlankItem = pBlankItem; + } + + return __pBlankItem; +} + +// Accessor +void +_IconListItemProviderAdaptor::SetItemProvider(void* pProvider) +{ + IIconListViewItemProvider* pItemProvider = static_cast(pProvider); + if (pItemProvider != null) + { + __pItemProvider = pItemProvider; + } +} + +_IListItemCommon* +_IconListItemProviderAdaptor::LoadItem(int groupIndex, int itemIndex) +{ + // Argument Check + SysTryReturn(NID_UI_CTRL, (groupIndex == DEFAULT_GROUP_INDEX), null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index of group must be 0."); + SysTryReturn(NID_UI_CTRL, (itemIndex >= GROUP_TITLE_INDEX), null, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Index must be a non-negative integer."); + + SysAssertf(__pItemProvider != null, "Not yet initialized. SetItemProvider() should be called before use."); + + ClearLastResult(); + // Return Group Item + if (itemIndex == GROUP_TITLE_INDEX) + { + return GetBlankItem(); + } + + // Valid Check + _IconListItem* pIconListItem = null; + IconListViewItem* pItem = __pItemProvider->CreateItem(itemIndex); + SysTryCatch(NID_UI_CTRL, (pItem != null), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Can't get new item."); + SysTryCatch(NID_UI_CTRL, (pItem->__pImpl != null), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Can't get new item."); + + pIconListItem = pItem->__pImpl->__pIconListItem; + SysTryCatch(NID_UI_CTRL, (pIconListItem != null), , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Can't get new item."); + + pIconListItem->ClearVisualElement(); + pIconListItem->AddRef(); + + // Attach _VisualElement + if (__pRoot != null) + { + _VisualElement* pBase = pIconListItem->GetVisualElement(); + if (pBase != null) + { + __pRoot->AttachChild(*pBase); + pBase->SetShowState(false); + pBase->SetClipToParent(true); + } + } + + return pIconListItem; + +CATCH: + if (pItem != null) + { + if (!__pItemProvider->DeleteItem(itemIndex, pItem)) + { + delete pItem; + } + } + + return GetBlankItem(); +} + +result +_IconListItemProviderAdaptor::UnloadItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex) +{ + // Argument Check + SysTryReturn(NID_UI_CTRL, (pListItem != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Item must not be null."); + SysTryReturn(NID_UI_CTRL, (groupIndex == DEFAULT_GROUP_INDEX), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index of group must be 0."); + SysTryReturn(NID_UI_CTRL, (itemIndex >= GROUP_TITLE_INDEX), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Index must be a non-negative integer."); + + // Group Item + if (itemIndex == GROUP_TITLE_INDEX) + { + return E_SUCCESS; + } + + // Is the Blank Item? + if (pListItem == GetBlankItem()) + { + return E_SUCCESS; + } + + _IconListItem* pIconListItem = dynamic_cast<_IconListItem*>(pListItem); + if (pIconListItem != null) + { + _VisualElement* pBase = pIconListItem->GetVisualElement(); + if (pBase != null) + { + pBase->SetShowState(false); + pIconListItem->ClearVisualElement(); + __pRoot->DetachChild(*pBase); + } + } + + IconListViewItem* pItem = static_cast(pIconListItem->GetAppInfo()); + pIconListItem->Release(); + if (pItem == null) + { + return E_SUCCESS; + } + + SysAssertf(__pItemProvider != null, "Not yet initialized. SetItemProvider() should be called before use."); + + if (!__pItemProvider->DeleteItem(itemIndex, pItem)) + { + delete pItem; + } + + return E_SUCCESS; +} + +result +_IconListItemProviderAdaptor::DeleteItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex) +{ + // Argument Check + SysTryReturn(NID_UI_CTRL, (pListItem != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Item must not be null."); + SysTryReturn(NID_UI_CTRL, (groupIndex == DEFAULT_GROUP_INDEX), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index of group must be 0."); + SysTryReturn(NID_UI_CTRL, (itemIndex >= GROUP_TITLE_INDEX), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Index must be a non-negative integer."); + + // Group Item + if (itemIndex == GROUP_TITLE_INDEX) + { + return E_SUCCESS; + } + + // Is the Blank Item? + if (pListItem == GetBlankItem()) + { + return E_SUCCESS; + } + + _IconListItem* pIconListItem = dynamic_cast <_IconListItem*>(pListItem); + if (pIconListItem != null) + { + _VisualElement* pBase = pIconListItem->GetVisualElement(); + if (pBase != null) + { + pBase->SetShowState(false); + pIconListItem->ClearVisualElement(); + __pRoot->DetachChild(*pBase); + } + } + + IconListViewItem* pItem = static_cast (pIconListItem->GetAppInfo()); + pIconListItem->Release(); + if (pItem != null) + { + delete pItem; + } + + return E_SUCCESS; +} + +int +_IconListItemProviderAdaptor::GetItemCount(int groupIndex) const +{ + // Argument Check + SysTryReturn(NID_UI_CTRL, (groupIndex == DEFAULT_GROUP_INDEX), -1, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index of group must be 0."); + + SysAssertf(__pItemProvider != null, "Not yet initialized. SetItemProvider() should be called before use."); + + ClearLastResult(); + + int itemCount = __pItemProvider->GetItemCount(); + return (itemCount < 0) ? 0 : itemCount; +} + +int +_IconListItemProviderAdaptor::GetGroupCount(void) const +{ + return DEFAULT_GROUP_COUNT; +} + +void +_IconListItemProviderAdaptor::SetVisualElement(Tizen::Ui::Animations::_VisualElement* pRoot) +{ + SysTryReturnVoidResult(NID_UI_CTRL, (pRoot != null), E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used."); + + ClearLastResult(); + + __pRoot = pRoot; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IconListPresenter.cpp b/src/ui/controls/FUiCtrl_IconListPresenter.cpp new file mode 100755 index 0000000..a91bcb2 --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListPresenter.cpp @@ -0,0 +1,4621 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListPresenter.cpp + * @brief This is the implementation file for the _IconListPresenter class. + */ + +//Includes +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityManager.h" +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_IconListItem.h" +#include "FUiCtrl_IconListItemDrawingProperty.h" +#include "FUiCtrl_IconListItemProviderAdaptor.h" +#include "FUiCtrl_IconListPresenter.h" +#include "FUiCtrl_IconListView.h" +#include "FUiCtrl_IconListViewItemEvent.h" +#include "FUiCtrl_ListViewModel.h" +#include "FUiCtrl_Scroll.h" +#include "FUiCtrl_UiIconListItemEvent.h" +#include "FUiCtrl_UiScrollEvent.h" +#include "FUiCtrl_UiScrollEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_IconListPresenter::_IconListPresenter(_IconListView* pIconListView, _ListViewModel* pListModel) + : __pListModel(pListModel) + , __pIconListView(pIconListView) + , __pItemProviderAdaptor(null) + , __backgroundColor(0) + , __currentTouchInfo() + , __selectedOverlayBitmapId(-1) + , __selectedIndex(-1) + , __checkedIndex(-1) + , __highlightedIndex(-1) + , __firstDrawnIndex(-1) + , __lastDrawnIndex(-1) + , __scrollDirection(ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + , __topMargin(0) + , __bottomMargin(0) + , __leftMargin(0) + , __rightMargin(0) + , __horizontalSpacing(0) + , __verticalSpacing(0) + , __magneticScrollSize(0) + , __itemCountPerAxis(0) + , __itemHorizontalAlignment(ALIGNMENT_LEFT) + , __itemVerticalAlignment(ALIGNMENT_TOP) + , __scrollPosition(0) + , __unitScrollLength(0) + , __scrollLength(0) + , __unitLengthOfAxis(0) + , __startPosOfAxis(0) + , __endPosOfAxis(0) + , __pItemDrawingProperty(null) + , __pSelectionAnimationTimer(null) + , __pCheckAnimationTimer(null) + , __pTouchActionTimer(null) + , __pFlickAnimationTimer(null) + , __pMagneticScrollTimer(null) + , __pAnimationTimer(null) + , __flickAnimation() + , __touchAnimation() + , __magneticScrollAnimation() + , __checkAnimation() + , __isTouchAnimationEnabled(true) + , __previousTouchAnimatinEnabled(true) + , __isLayoutChanged(true) + , __isTouchPressed(false) + , __onDrawing(false) + , __requireNextDrawing(false) + , __alreadyDrawn(false) + , __enableCustomItemProviderAdaptor(false) + , __listStatusChanged(false) + , __needBaseCanvas(false) + , __isSelectionDelayed(false) + , __pRemoveItemVE(null) + , __pEmptyListVE(null) + , __pVE(null) + , __onReordering(false) + , __reorderFromIndex(-1) + , __reorderToIndex(-1) + , __lastReorderedPosition(-1, -1) + , __lastReorderedDifferences(0, 0) + , __reorderItemBounds(0, 0, 0, 0) + , __pReorderScrollTimer(null) + , __reorderScrollAnimationDistance(0) + , __scrollPositionBeforeScrollAnimation(0) + , __flickCount(0) + , __isFlickDown(false) + , __animationItemIndex(-1) + , __addTransactionId(0) + , __removeTransactionId(0) + , __moveTransactionId(0) +{ +} + +_IconListPresenter::~_IconListPresenter(void) +{ + Dispose(); +} + +_IconListPresenter* +_IconListPresenter::CreateInstanceN(_IconListView& pIconListView) +{ + _IconListPresenter* pIconListPresenter = null; + _IconListItemDrawingProperty* pItemDrawingProperty = null; + + // Create _ListModel + _ListViewModel* pListModel = new (std::nothrow) _ListViewModel; + SysTryCatch(NID_UI_CTRL, (pListModel != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + // Create _IconListPresenter + pIconListPresenter = new (std::nothrow) _IconListPresenter(&pIconListView, pListModel); + SysTryCatch(NID_UI_CTRL, (pIconListPresenter != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + // Create _IconListItemDrawingProperty + pItemDrawingProperty = _IconListItemDrawingProperty::CreateInstanceN(); + SysTryCatch(NID_UI_CTRL, (pItemDrawingProperty != null), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + pIconListPresenter->__pItemDrawingProperty = pItemDrawingProperty; + + // Initialize _IconListPresenter + pIconListPresenter->Initialize(); + + return pIconListPresenter; + +CATCH: + delete pListModel; + delete pIconListPresenter; + + return null; +} + +result +_IconListPresenter::Dispose(void) +{ + delete __pListModel; + __pListModel = null; + + delete __pItemProviderAdaptor; + __pItemProviderAdaptor = null; + + __pIconListView = null; + + delete __pItemDrawingProperty; + __pItemDrawingProperty = null; + + delete __pSelectionAnimationTimer; + __pSelectionAnimationTimer = null; + + delete __pCheckAnimationTimer; + __pCheckAnimationTimer = null; + + delete __pTouchActionTimer; + __pTouchActionTimer = null; + + delete __pFlickAnimationTimer; + __pFlickAnimationTimer = null; + + delete __pMagneticScrollTimer; + __pMagneticScrollTimer = null; + + delete __pReorderScrollTimer; + __pReorderScrollTimer = null; + + delete __pAnimationTimer; + __pAnimationTimer = null; + + if (__pRemoveItemVE != null) + { + __pRemoveItemVE->Destroy(); + __pRemoveItemVE = null; + } + + if (__pEmptyListVE != null) + { + __pEmptyListVE->Destroy(); + __pEmptyListVE = null; + } + + return E_SUCCESS; +} + +result +_IconListPresenter::Initialize(void) +{ + __flickAnimation.SetSizeInformation(SCREEN_WIDTH, SCREEN_HEIGHT, DEVICE_SIZE_HORIZONTAL, DEVICE_SIZE_VERTICAL); + __flickAnimation.SetSensitivity(FLICK_ANIMATION_FPS_LIST, FLICK_ANIMATION_SENSITIVITY_LIST); + + SetItemBorderStyle(ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE); + SetTextHorizontalAlignment(ALIGNMENT_CENTER); + SetTextVerticalAlignment(ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM); + SetItemBitmapAsAspectRatio(true); + SetCheckBoxPosition(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT); + + __pVE = __pIconListView->GetVisualElement(); + __pVE->SetClipChildrenEnabled(true); + __pVE->SetSurfaceOpaque(false); + + // Default Margin & Spacing + _ControlOrientation orientation = __pIconListView->GetOrientation(); + GET_SHAPE_CONFIG(ICONLIST::TOP_MARGIN, orientation, __topMargin); + GET_SHAPE_CONFIG(ICONLIST::BOTTOM_MARGIN, orientation, __bottomMargin); + GET_SHAPE_CONFIG(ICONLIST::LEFT_MARGIN, orientation, __leftMargin); + GET_SHAPE_CONFIG(ICONLIST::RIGHT_MARGIN, orientation, __rightMargin); + GET_SHAPE_CONFIG(ICONLIST::HORIZONTAL_SPACING, orientation, __horizontalSpacing); + GET_SHAPE_CONFIG(ICONLIST::VERTICAL_SPACING, orientation, __verticalSpacing); + + return E_SUCCESS; +} + +result +_IconListPresenter::InitializeFont(void) +{ + Font* pFont = __pIconListView->GetFallbackFont(); + SysTryReturn(NID_UI_CTRL, (pFont != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return __pItemDrawingProperty->SetFont(pFont); +} + +result +_IconListPresenter::SetItemProvider(const IIconListViewItemProvider& provider) +{ + _IconListItemProviderAdaptor* pAdaptor = static_cast <_IconListItemProviderAdaptor*>(__pListModel->GetItemProviderAdaptor()); + + if (pAdaptor == null) + { + RegisterItemProviderAdaptor(null); + pAdaptor = dynamic_cast <_IconListItemProviderAdaptor*>(__pItemProviderAdaptor); + SysTryReturn(NID_UI_CTRL, (pAdaptor != null), E_SYSTEM, E_SYSTEM, "[ESYSTEM] A system error has been occurred."); + } + else + { + // Remove All Items + __pListModel->RemoveAllItem(); + } + + // Set Item Provider + pAdaptor->SetItemProvider(const_cast (&provider)); + + __isLayoutChanged = true; + __scrollPosition = 0; + + AdjustLayout(); + InitializeFont(); + + return E_SUCCESS; +} + +result +_IconListPresenter::RegisterItemProviderAdaptor(_IListItemProviderAdaptor* pItemProviderAdaptor) +{ + // Remove All Items + __pListModel->RemoveAllItem(); + __selectedIndex = INVALID_INDEX; + __highlightedIndex = INVALID_INDEX; + __isLayoutChanged = true; + __alreadyDrawn = false; + + _IconListItemProviderAdaptor* pAdaptor = null; + bool enableCustomItemProviderAdaptor = true; + if (pItemProviderAdaptor == null) + { + // Create Default _IconListItemProviderAdaptor + pAdaptor = new (std::nothrow) _IconListItemProviderAdaptor; + SysTryReturn(NID_UI_CTRL, (pAdaptor != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pAdaptor->SetVisualElement(__pIconListView->GetVisualElement()); + enableCustomItemProviderAdaptor = false; + pItemProviderAdaptor = pAdaptor; + } + + // Set _IconListItemProviderAdaptor + __pItemProviderAdaptor = null; + result r = __pListModel->RegisterItemProviderAdaptor(pItemProviderAdaptor); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (enableCustomItemProviderAdaptor) + { + __pListModel->AddGroup(0, __pIconListView->GetStyle() == ICON_LIST_VIEW_STYLE_RADIO); + } + + __pItemProviderAdaptor = pItemProviderAdaptor; + __enableCustomItemProviderAdaptor = enableCustomItemProviderAdaptor; + + return E_SUCCESS; + +CATCH: + delete pAdaptor; + + return r; +} + +result +_IconListPresenter::SetScrollDirection(IconListViewScrollDirection scrollDirection) +{ + SysTryReturn(NID_UI_CTRL, + (scrollDirection >= ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL && scrollDirection <= ICON_LIST_VIEW_SCROLL_DIRECTION_HORIZONTAL), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid scrollDirection is used."); + + int scrollBarWidth = 0; + _ControlOrientation orientation = __pIconListView->GetOrientation(); + GET_SHAPE_CONFIG(SCROLL::THUMB_MIN_WIDTH, orientation, scrollBarWidth); + + __scrollDirection = scrollDirection; + Rectangle bounds = __pIconListView->GetBounds(); + if (scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + GET_SHAPE_CONFIG(ICONLIST::LEFT_MARGIN, orientation, __leftMargin); + GET_SHAPE_CONFIG(ICONLIST::RIGHT_MARGIN, orientation, __rightMargin); + + SetItemLayoutHorizontalAlignment(ALIGNMENT_CENTER); + __pIconListView->SetScroll(Rectangle(bounds.width - scrollBarWidth, 0, scrollBarWidth, bounds.height), + SCROLL_DIRECTION_VERTICAL); + __flickAnimation.SetDirection(0x1); + } + else + { + GET_SHAPE_CONFIG(ICONLIST::OUTSIDE_TEXT_LEFT_MARGIN, orientation, __leftMargin); + GET_SHAPE_CONFIG(ICONLIST::OUTSIDE_TEXT_RIGHT_MARGIN, orientation, __rightMargin); + + SetItemLayoutVerticalAlignment(ALIGNMENT_MIDDLE); + __pIconListView->SetScroll(Rectangle(0, bounds.height - scrollBarWidth, bounds.width, scrollBarWidth), + SCROLL_DIRECTION_HORIZONTAL); + __flickAnimation.SetDirection(0x2); + } + + return E_SUCCESS; +} + +result +_IconListPresenter::SetTopMargin(int value) +{ + SysTryReturn(NID_UI_CTRL, (value >= 0), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. The value must be non negative integer."); + + if (__topMargin != value) + { + __topMargin = value; + AdjustLayout(); + } + + return E_SUCCESS; +} + +int +_IconListPresenter::GetTopMargin(void) const +{ + ClearLastResult(); + return __topMargin; +} + +result +_IconListPresenter::SetBottomMargin(int value) +{ + SysTryReturn(NID_UI_CTRL, (value >= 0), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. The value must be non negative integer."); + + if (__bottomMargin != value) + { + __bottomMargin = value; + AdjustLayout(); + } + + return E_SUCCESS; +} + +int +_IconListPresenter::GetBottomMargin(void) const +{ + ClearLastResult(); + return __bottomMargin; +} + +result +_IconListPresenter::SetLeftMargin(int value) +{ + SysTryReturn(NID_UI_CTRL, (value >= 0), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. The value must be non negative integer."); + + if (__leftMargin != value) + { + __leftMargin = value; + AdjustLayout(); + } + + return E_SUCCESS; +} + +int +_IconListPresenter::GetLeftMargin(void) const +{ + ClearLastResult(); + return __leftMargin; +} + +result +_IconListPresenter::SetRightMargin(int value) +{ + SysTryReturn(NID_UI_CTRL, (value >= 0), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. The value must be non negative integer."); + + if (__rightMargin != value) + { + __rightMargin = value; + AdjustLayout(); + } + + return E_SUCCESS; +} + +int +_IconListPresenter::GetRightMargin(void) const +{ + ClearLastResult(); + return __rightMargin; +} + +result +_IconListPresenter::SetItemSpacing(int horizontalSpacing, int verticalSpacing) +{ + SysTryReturn(NID_UI_CTRL, (horizontalSpacing >= 0 && verticalSpacing >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. The value must be non negative integer."); + + if (__horizontalSpacing != horizontalSpacing) + { + __horizontalSpacing = horizontalSpacing; + __isLayoutChanged = true; + } + + if (__verticalSpacing != verticalSpacing) + { + __verticalSpacing = verticalSpacing; + __isLayoutChanged = true; + } + + if (__isLayoutChanged) + { + AdjustLayout(); + } + + return E_SUCCESS; +} + +int +_IconListPresenter::GetItemHorizontalSpacing(void) const +{ + ClearLastResult(); + return __horizontalSpacing; +} + +int +_IconListPresenter::GetItemVerticalSpacing(void) const +{ + ClearLastResult(); + return __verticalSpacing; +} + +void +_IconListPresenter::SetUseCheckedStyle(bool checkedStyle) +{ + __pItemDrawingProperty->SetItemCheckedStyle(checkedStyle); +} + +result +_IconListPresenter::SetItemChecked(int index, bool check) +{ + if (__pListModel->GetAllGroupCount() == 0) + { + SysTryReturn(NID_UI_CTRL, (__pItemProviderAdaptor != null), E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] This instance isn't constructed."); + + int itemCount = __pItemProviderAdaptor->GetItemCount(); + if (itemCount < 0) + { + itemCount = 0; + } + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < itemCount), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Index must be non-negative integer, and less count of whole items."); + + // Add Group + result r = __pListModel->AddGroup(itemCount, __pIconListView->GetStyle() == ICON_LIST_VIEW_STYLE_RADIO); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < __pListModel->GetItemCountInGroup( + DEFAULT_GROUP_INDEX)), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Index must be non-negative integer, and less count of whole items."); + } + + return __pListModel->SetItemChecked(DEFAULT_GROUP_INDEX, index, check); +} + +bool +_IconListPresenter::IsItemChecked(int index) const +{ + ClearLastResult(); + return __pListModel->IsItemChecked(DEFAULT_GROUP_INDEX, index); +} + +int +_IconListPresenter::GetItemIndexFromPosition(int x, int y) const +{ + ClearLastResult(); + if (__unitLengthOfAxis <= 0 || __unitScrollLength <= 0) + { + return -1; + } + + ClearLastResult(); + + int row = 0; + int col = 0; + int modX = 0; + int modY = 0; + int index = -1; + + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + x -= __startPosOfAxis; + if (x < 0) + { + return -1; + } + + col = x / __unitLengthOfAxis; + if (col >= __itemCountPerAxis) + { + return -1; + } + + modX = x % __unitLengthOfAxis; + if (modX >= GetItemSize().width) + { + return -1; + } + + y += __scrollPosition - __topMargin; + if (y < 0) + { + return -1; + } + + modY = y % __unitScrollLength; + if (modY >= GetItemSize().height) + { + return -1; + } + + row = y / __unitScrollLength; + index = row * __itemCountPerAxis + col; + if (index >= __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX)) + { + return -1; + } + } + else + { + y -= __startPosOfAxis; + if (y < 0) + { + return -1; + } + + row = y / __unitLengthOfAxis; + if (row >= __itemCountPerAxis) + { + return -1; + } + + modY = y % __unitLengthOfAxis; + if (modY >= GetItemSize().height) + { + return -1; + } + + x += __scrollPosition - __leftMargin; + if (x < 0) + { + return -1; + } + + modX = x % __unitScrollLength; + if (modX >= GetItemSize().width) + { + return -1; + } + + col = x / __unitScrollLength; + index = col * __itemCountPerAxis + row; + if (index >= __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX)) + { + return -1; + } + } + + return index; +} + +int +_IconListPresenter::GetItemIndexFromPosition(const Point& position) const +{ + return GetItemIndexFromPosition(position.x, position.y); +} + +result +_IconListPresenter::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + return __pItemDrawingProperty->SetTextHorizontalAlignment(alignment); +} + +result +_IconListPresenter::SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment) +{ + int itemHeight = __pItemDrawingProperty->GetItemSize().height; + result r = __pItemDrawingProperty->SetTextVerticalAlignment(alignment); + if (alignment >= ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP) + { + _ControlOrientation orientation = __pIconListView->GetOrientation(); + GET_SHAPE_CONFIG(ICONLIST::OUTSIDE_TEXT_VERTICAL_SPACING, orientation, __verticalSpacing); + } + + if (itemHeight != __pItemDrawingProperty->GetItemSize().height) + { + AdjustLayout(); + } + + return r; +} + +HorizontalAlignment +_IconListPresenter::GetTextHorizontalAlignment(void) const +{ + ClearLastResult(); + return __pItemDrawingProperty->GetTextHorizontalAlignment(); +} + +IconListViewItemTextVerticalAlignment +_IconListPresenter::GetTextVerticalAlignment(void) const +{ + ClearLastResult(); + return __pItemDrawingProperty->GetTextVerticalAlignment(); +} + +result +_IconListPresenter::SetItemTextColor(IconListViewItemDrawingStatus status, const Color& color) +{ + SysTryReturn(NID_UI_CTRL, + (status >= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL && status <= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED), + E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid status is used."); + + return __pItemDrawingProperty->SetTextColor(status, color); +} + +const Color +_IconListPresenter::GetItemTextColor(IconListViewItemDrawingStatus status) const +{ + SysTryReturn(NID_UI_CTRL, + (status >= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL && status <= ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] status is invalid."); + + return __pItemDrawingProperty->GetTextColor(status); +} + +result +_IconListPresenter::SetItemTextSize(int size) +{ + int itemHeight = __pItemDrawingProperty->GetItemSize().height; + result r = __pItemDrawingProperty->SetTextSize(size); + + InitializeFont(); + + if (itemHeight != __pItemDrawingProperty->GetItemSize().height) + { + AdjustLayout(); + } + + return r; +} + +int +_IconListPresenter::GetItemTextSize(void) const +{ + return __pItemDrawingProperty->GetTextSize(); +} + +result +_IconListPresenter::SetCheckBoxPosition(IconListViewCheckBoxPosition position) +{ + return __pItemDrawingProperty->SetCheckBoxPosition(position); +} + +IconListViewCheckBoxPosition +_IconListPresenter::GetCheckBoxPosition(void) const +{ + ClearLastResult(); + return __pItemDrawingProperty->GetCheckBoxPosition(); +} + +result +_IconListPresenter::SetTouchAnimationEnabled(bool enable) +{ + __isTouchAnimationEnabled = enable; + __previousTouchAnimatinEnabled = enable; + + return E_SUCCESS; +} + +bool +_IconListPresenter::IsTouchAnimationEnabled(void) const +{ + ClearLastResult(); + return __onReordering ? __previousTouchAnimatinEnabled : __isTouchAnimationEnabled; +} + +result +_IconListPresenter::ScrollToItem(int index) +{ + int itemCount = __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX); + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < itemCount), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Index must be non-negative integer, and less count of whole items."); + + SysTryReturn(NID_UI_CTRL, (__itemCountPerAxis > 0), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Unable to get ItemCount per axis."); + + int scrollPosition = (index / __itemCountPerAxis) * __unitScrollLength; + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + scrollPosition += __topMargin; + } + else + { + scrollPosition += __leftMargin; + } + + if (SetScrollPosition(scrollPosition, false)) + { + ScrollFadeOut(true); + FireScrollEvent(); + } + + return E_SUCCESS; +} + +result +_IconListPresenter::ScrollByPixel(int pixel) +{ + if (pixel == 0) + { + return E_SUCCESS; + } + + if (SetScrollPosition(__scrollPosition + pixel, false)) + { + __pIconListView->Invalidate(); + ScrollFadeOut(true); + FireScrollEvent(); + + return E_SUCCESS; + } + + return E_OUT_OF_RANGE; +} + +result +_IconListPresenter::RefreshList(int index, ListRefreshType type) +{ + SysTryReturn(NID_UI_CTRL, (__pItemProviderAdaptor != null), E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] IconListViewItemProvider isn't added."); + + SysTryReturn(NID_UI_CTRL, __alreadyDrawn, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] Unable to refresh IconListView before first drawn."); + + int itemCount = __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX); + SysTryReturn(NID_UI_CTRL, (index >= 0 && index <= itemCount), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Index must be non-negative integer, and less count of whole items."); + + SysTryReturn(NID_UI_CTRL, (index < itemCount || type == LIST_REFRESH_TYPE_ITEM_ADD), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Index must be non-negative integer, and less count of whole items."); + + SysTryReturn(NID_UI_CTRL, (type >= LIST_REFRESH_TYPE_ITEM_ADD && type <= LIST_REFRESH_TYPE_ITEM_MODIFY), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has been occured. Refresh type is invalid."); + + if (__pAnimationTimer != null) + { + ResetAnimationTimer(); + Draw(); + } + + bool usingAnimation = false; + result r = E_SUCCESS; + switch (type) + { + case LIST_REFRESH_TYPE_ITEM_ADD: + { + if ((__firstDrawnIndex <= index) && (__lastDrawnIndex >= index)) + { + MoveBackward(index); + } + + if (__pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX) == 0) + { + __listStatusChanged = true; + } + + _IconListItem* pItem = dynamic_cast <_IconListItem*>(__pItemProviderAdaptor->LoadItem(DEFAULT_GROUP_INDEX, index)); + SysTryReturn(NID_UI_CTRL, (pItem != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + r = InsertItemAt(index, pItem); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__listStatusChanged) + { + __pIconListView->Invalidate(); + } + + if (((__firstDrawnIndex <= index) && (__lastDrawnIndex >= index)) || (index == (__lastDrawnIndex + 1))) + { + if (index < itemCount) + { + StartAnimationTimer(ITEM_ANIMATION_DELAY); + __animationItemIndex = index; + } + else + { + AddAnimation(*pItem, index); + } + + usingAnimation = true; + } + + break; + } + + case LIST_REFRESH_TYPE_ITEM_REMOVE: + { + _IconListItem* pItem = dynamic_cast <_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, index)); + SysTryReturn(NID_UI_CTRL, (pItem != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if ((__firstDrawnIndex <= index) && (__lastDrawnIndex >= index)) + { + RemoveAnimation(*pItem, index); + MoveForward(index + 1); + + usingAnimation = true; + } + + r = RemoveItemAt(index); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX) == 0) + { + __listStatusChanged = true; + __pIconListView->Invalidate(); + return r; + } + + break; + } + + case LIST_REFRESH_TYPE_ITEM_MODIFY: + { + _IconListItem* pItem = dynamic_cast <_IconListItem*>(__pItemProviderAdaptor->LoadItem(DEFAULT_GROUP_INDEX, index)); + SysTryReturn(NID_UI_CTRL, (pItem != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + r = SetItemAt(index, pItem); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + float ratio = 1.0f; + if (__isTouchAnimationEnabled) + { + ratio = __touchAnimation.GetCurrentAnimationFrame(); + } + RedrawItem(index, ratio); + return r; + } + } + + if (!usingAnimation) + { + if ((type == LIST_REFRESH_TYPE_ITEM_ADD) && (index < __firstDrawnIndex)) + { + int scrollPosition = __scrollPosition + __unitScrollLength; + if (SetScrollPosition(scrollPosition)) + { + ScrollFadeOut(); + } + } + else if ((type == LIST_REFRESH_TYPE_ITEM_REMOVE) && (index < __firstDrawnIndex)) + { + int scrollPosition = __scrollPosition - __unitScrollLength; + if (SetScrollPosition(scrollPosition)) + { + ScrollFadeOut(); + } + + } + __pIconListView->Invalidate(); + } + else + { + AdjustLayout(); + InitializeFont(); + + UpdateDrawnIndex(); + } + + return r; +} + +void +_IconListPresenter::UpdateDrawnIndex(void) +{ + int drawingLine = 0; + int itemCount = __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX); + Rectangle itemRect(0, 0, GetItemSize().height, GetItemSize().width); + + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + int endXPos = __endPosOfAxis; + int endYPos = __pIconListView->GetBounds().height; + + drawingLine = (__scrollPosition > __topMargin) ? + (__scrollPosition - __topMargin + __verticalSpacing) / __unitScrollLength : 0; + itemRect.y = __topMargin + drawingLine * __unitScrollLength - __scrollPosition; + + int index = drawingLine * __itemCountPerAxis; + __firstDrawnIndex = index; + while(itemRect.y < endYPos) + { + itemRect.x = __startPosOfAxis; + while ((itemRect.x < endXPos) && (index < itemCount)) + { + ++index; + itemRect.x += __unitLengthOfAxis; + } + itemRect.y += __unitScrollLength; + } + __lastDrawnIndex = index - 1; + } + else + { + int endXPos = __pIconListView->GetBounds().width; + int endYPos = __endPosOfAxis; + + drawingLine = (__scrollPosition > __leftMargin) ? + (__scrollPosition - __leftMargin + __horizontalSpacing) / __unitScrollLength : 0; + itemRect.x = __leftMargin + drawingLine * __unitScrollLength - __scrollPosition; + + int index = drawingLine * __itemCountPerAxis; + __firstDrawnIndex = index; + while(itemRect.x < endXPos) + { + itemRect.y = __startPosOfAxis; + while ((itemRect.y < endYPos) && (index < itemCount)) + { + ++index; + itemRect.y += __unitLengthOfAxis; + } + itemRect.x += __unitScrollLength; + } + __lastDrawnIndex = index - 1; + } +} + +result +_IconListPresenter::UpdateList(void) +{ + SysTryReturn(NID_UI_CTRL, (__pItemProviderAdaptor != null), E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] IconListViewItemProvider isn't added."); + + ResetFlickAnimationTimer(); + ResetTouchActionTimer(); + ResetAnimationTimer(); + ResetCheckAnimationTimer(); + + __pVE->RemoveAllAnimations(); + + result r = RemoveAllItems(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __selectedIndex = INVALID_INDEX; + __highlightedIndex = INVALID_INDEX; + __isLayoutChanged = true; + __alreadyDrawn = false; + __listStatusChanged = true; + + __pIconListView->Invalidate(); + + return E_SUCCESS; +} + +result +_IconListPresenter::SetItemBitmapBounds(const Rectangle& bounds) +{ + result r = __pItemDrawingProperty->SetItemBitmapBounds(bounds); + + if (r == E_SUCCESS) + { + __isLayoutChanged = true; + } + + return r; +} + +const Rectangle +_IconListPresenter::GetItemBitmapBounds(void) const +{ + return __pItemDrawingProperty->GetItemBitmapBounds(); +} + +result +_IconListPresenter::GetItemBitmapSize(int& width, int& height) const +{ + Dimension itemSize = __pItemDrawingProperty->GetItemBitmapSize(); + width = itemSize.width; + height = itemSize.height; + + return E_SUCCESS; +} + +const Dimension +_IconListPresenter::GetItemBitmapSize(void) const +{ + return __pItemDrawingProperty->GetItemBitmapSize(); +} + +result +_IconListPresenter::SetItemSize(const Dimension& size) +{ + SysTryReturn(NID_UI_CTRL, (__pItemDrawingProperty != null), E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] This instance isn't constructed."); + + SysTryReturn(NID_UI_CTRL, (size.width > 0 && size.height > 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Width and Height size should be larger than 0."); + + __isLayoutChanged = true; + return __pItemDrawingProperty->SetItemSize(size); +} + +result +_IconListPresenter::GetItemSize(int& width, int& height) const +{ + Dimension itemSize = __pItemDrawingProperty->GetItemSize(); + width = itemSize.width; + height = itemSize.height; + + return E_SUCCESS; +} + +const Dimension +_IconListPresenter::GetItemSize(void) const +{ + return __pItemDrawingProperty->GetItemSize(); +} + +result +_IconListPresenter::SetMagneticScrollSize(int scrollSize) +{ + SysTryReturn(NID_UI_CTRL, (__pItemProviderAdaptor != null), E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] This instance isn't constructed."); + + int rowCount = static_cast(Math::Ceiling(((double) __pItemProviderAdaptor->GetItemCount()) / ((double) __itemCountPerAxis))); + SysTryReturn(NID_UI_CTRL, ((scrollSize >= 0) && (scrollSize <= rowCount)), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. ScrollSize is a non-negative integer and less than the number of rows."); + + __magneticScrollSize = scrollSize; + + return E_SUCCESS; +} + +int +_IconListPresenter::GetMagneticScrollSize(void) const +{ + ClearLastResult(); + return __magneticScrollSize; +} + +void +_IconListPresenter::SetItemCountPerAxis(int itemCountPerAxis) +{ + SysTryReturnVoidResult(NID_UI_CTRL, (itemCountPerAxis >= 0), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argumet is used. itemCountPerAxis is a non-negative integer."); + + ClearLastResult(); + __itemCountPerAxis = itemCountPerAxis; +} + +int +_IconListPresenter::GetItemCountPerAxis(void) const +{ + ClearLastResult(); + return __itemCountPerAxis; +} + +result +_IconListPresenter::SetItemLayoutHorizontalAlignment(HorizontalAlignment alignment) +{ + SysTryReturn(NID_UI_CTRL, (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL), E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This isn't vertical scroll."); + + SysTryReturn(NID_UI_CTRL, (alignment >= ALIGNMENT_LEFT && alignment <= ALIGNMENT_RIGHT), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] alignment is invalid."); + + if (alignment != __itemHorizontalAlignment) + { + __itemHorizontalAlignment = alignment; + __isLayoutChanged = true; + } + + return E_SUCCESS; +} + +result +_IconListPresenter::SetItemLayoutVerticalAlignment(VerticalAlignment alignment) +{ + SysTryReturn(NID_UI_CTRL, (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_HORIZONTAL), E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This isn't horizontal scroll."); + + SysTryReturn(NID_UI_CTRL, (alignment >= ALIGNMENT_TOP && alignment <= ALIGNMENT_BOTTOM), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] alignment is invalid."); + + if (alignment != __itemVerticalAlignment) + { + __itemVerticalAlignment = alignment; + __isLayoutChanged = true; + } + + return E_SUCCESS; +} + +HorizontalAlignment +_IconListPresenter::GetItemLayoutHorizontalAlignment(void) const +{ + ClearLastResult(); + return __itemHorizontalAlignment; +} + +VerticalAlignment +_IconListPresenter::GetItemLayoutVerticalAlignment(void) const +{ + ClearLastResult(); + return __itemVerticalAlignment; +} + +result +_IconListPresenter::SetItemBorderStyle(IconListViewItemBorderStyle borderStyle) +{ + return __pItemDrawingProperty->SetBorderStyle(borderStyle); +} + +IconListViewItemBorderStyle +_IconListPresenter::GetItemBorderStyle(void) const +{ + return __pItemDrawingProperty->GetBorderStyle(); +} + +_IconListItemDrawingProperty* +_IconListPresenter::GetItemDrawingProperty(void) const +{ + return __pItemDrawingProperty; +} + +void +_IconListPresenter::ClearVisualElement(void) +{ + __listStatusChanged = true; +} + +result +_IconListPresenter::SetNonSlidableList(void) +{ + // Remove All Items & Register Adaptor + __pListModel->RemoveAllItem(); + + __firstDrawnIndex = INVALID_INDEX; + __lastDrawnIndex = INVALID_INDEX; + __selectedIndex = INVALID_INDEX; + __highlightedIndex = INVALID_INDEX; + __isLayoutChanged = true; + __alreadyDrawn = true; + + return __pListModel->AddGroup(0, __pIconListView->GetStyle() == ICON_LIST_VIEW_STYLE_RADIO); +} + +result +_IconListPresenter::AddItem(_IconListItem* pItem) +{ + result r = __pListModel->AddItemToGroup(pItem, DEFAULT_GROUP_INDEX); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pItem->ClearVisualElement(); + + // Attach _VisualElement + _VisualElement* pBase = pItem->GetVisualElement(); + if (pBase != null) + { + VisualElement* pParent = pBase->GetParent(); + if (pParent != null) + { + pParent->DetachChild(*pBase); + } + __pIconListView->GetVisualElement()->AttachChild(*pBase); + pBase->SetShowState(false); + pBase->SetClipToParent(true); + } + + __isLayoutChanged = true; + + return E_SUCCESS; +} + +result +_IconListPresenter::InsertItemAt(int index, _IconListItem* pItem) +{ + result r = __pListModel->InsertItemToGroup(pItem, DEFAULT_GROUP_INDEX, index); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pItem->ClearVisualElement(); + pItem->SetDrawingProperty(*__pItemDrawingProperty); + + // Attach _VisualElement + _VisualElement* pBase = pItem->GetVisualElement(); + if (pBase != null) + { + VisualElement* pParent = pBase->GetParent(); + if (pParent != null) + { + pParent->DetachChild(*pBase); + } + __pIconListView->GetVisualElement()->AttachChild(*pBase); + pBase->SetShowState(false); + pBase->SetClipToParent(true); + } + + __isLayoutChanged = true; + + return E_SUCCESS; +} + +result +_IconListPresenter::SetItemAt(int index, _IconListItem* pItem) +{ + SysTryReturn(NID_UI_CTRL, (pItem != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. pItem is null."); + + result r = __pListModel->SetItem(*pItem, DEFAULT_GROUP_INDEX, index); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pItem->ClearVisualElement(); + pItem->SetDrawingProperty(*__pItemDrawingProperty); + + // Attach _VisualElement + _VisualElement* pBase = pItem->GetVisualElement(); + if (pBase != null) + { + VisualElement* pParent = pBase->GetParent(); + if (pParent != null) + { + pParent->DetachChild(*pBase); + } + __pIconListView->GetVisualElement()->AttachChild(*pBase); + pBase->SetShowState(false); + pBase->SetClipToParent(true); + } + + return E_SUCCESS; +} + +result +_IconListPresenter::RemoveItemAt(int index) +{ + __isLayoutChanged = true; + + return __pListModel->RemoveItemAt(DEFAULT_GROUP_INDEX, index); +} + +result +_IconListPresenter::RemoveAllItems(void) +{ + __isLayoutChanged = true; + + return __pListModel->RemoveAllItem(false, true); +} + +void +_IconListPresenter::SetItemBitmapAsAspectRatio(bool isAspect) +{ + __pItemDrawingProperty->SetItemBitmapAsAspectRatio(isAspect); +} + +bool +_IconListPresenter::IsItemBitmapAsAspectRatio(void) const +{ + return __pItemDrawingProperty->IsItemBitmapAsAspectRatio(); +} + +result +_IconListPresenter::SetReorderModeEnabled(bool enable) +{ + __isLayoutChanged = true; + + if (__isTouchAnimationEnabled && enable) + { + __isTouchAnimationEnabled = false; + } + else if (!enable) + { + __isTouchAnimationEnabled = __previousTouchAnimatinEnabled; + } + + __pIconListView->Invalidate(); + return E_SUCCESS; +} + +result +_IconListPresenter::Draw(void) +{ + result r = E_SUCCESS; + int itemCount = 0; + + if (__onDrawing) + { + __requireNextDrawing = true; + return E_SUCCESS; + } + + // If it is first draw, + if (!__alreadyDrawn) + { + if (__pListModel->GetAllGroupCount() == 0) + { + int itemCount = (__pItemProviderAdaptor != null) ? __pItemProviderAdaptor->GetItemCount() : 0; + if (itemCount < 0) + { + itemCount = 0; + } + + // Add Group + r = __pListModel->AddGroup(itemCount, __pIconListView->GetStyle() == ICON_LIST_VIEW_STYLE_RADIO); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __isLayoutChanged = true; + + InitializeFont(); + } + + // Set Drawing Flag + __onDrawing = true; + + // Draw Background + Color backgroundColor = __pIconListView->GetBackgroundColor(); + if (__listStatusChanged) + { + const Bitmap* pBackgroundBitmap = __pIconListView->GetBackgroundBitmap(); + if (pBackgroundBitmap != null) + { + Rectangle bounds; + Canvas* pCanvas = __pVE->GetCanvasN(); + SysTryCatch(NID_UI_CTRL, (pCanvas!= null), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(backgroundColor); + pCanvas->Clear(); + bounds = __pIconListView->GetBounds(); + if (pBackgroundBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, bounds.width, bounds.height), *pBackgroundBitmap); + } + else + { + pCanvas->DrawBitmap(Rectangle(0, 0, bounds.width, bounds.height), *pBackgroundBitmap); + } + + delete pCanvas; + + __needBaseCanvas = true; + } + else + { + __pVE->SetBackgroundColor(_Colorf((float) backgroundColor.GetRed() / 255, (float) backgroundColor.GetGreen() / 255, (float) backgroundColor.GetBlue() / 255, (float) backgroundColor.GetAlpha() / 255)); + __needBaseCanvas = false; + } + + } + + itemCount = __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX); + if (itemCount <= 0) + { + r = DrawEmptyList(); + __onDrawing = false; + __alreadyDrawn = true; + if (__requireNextDrawing) + { + __requireNextDrawing = false; + return Draw(); + } + return r; + } + + // If layout is changed, adjust layout. + if (__isLayoutChanged) + { + AdjustLayout(); + } + + // Draw Items + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + // Vertical Scroll + r = DrawVerticalScrollList(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + // Horizontal Scroll + r = DrawHorizontalScrollList(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __pItemDrawingProperty->SetDrawingFlag(); + + if (!__alreadyDrawn) + { + __alreadyDrawn = true; + + // start timer for scroll fade out + _Scroll* pScroll = __pIconListView->GetScroll(); + if (pScroll != null) + { + int scrollViewRange = 0; + int scrollRange = 0; + pScroll->GetScrollRange(&scrollViewRange, &scrollRange); + if (scrollViewRange < scrollRange) + { + ScrollFadeOut(); + } + } + + InitializeAccessibilityElement(); + } + + if (__listStatusChanged) + { + if (__pEmptyListVE != null) + { + if (__needBaseCanvas) + { + __pEmptyListVE->Destroy(); + __pEmptyListVE = null; + } + else + { + __pEmptyListVE->SetShowState(false); + } + } + __listStatusChanged = false; + } + +CATCH: + __onDrawing = false; + if (__requireNextDrawing) + { + __requireNextDrawing = false; + return Draw(); + } + + return r; +} + +result +_IconListPresenter::DrawEmptyList(void) +{ + result r = E_SUCCESS; + + if (!__listStatusChanged) + { + return r; + } + + Canvas* pCanvas = null; + TextObject* pTextObject = null; + Dimension textDimension; + Rectangle bounds(0, 0, 0, 0); + Rectangle viewBounds = __pIconListView->GetBounds(); + viewBounds.x = 0; + viewBounds.y = 0; + + int emptyTextHeight = 0; + + Font* pFont = null; + const String emptyText = __pIconListView->GetTextOfEmptyList(); + + int gap = 0; + int bitmapXPosition = 0; + int bitmapHeight = 0; + int bitmapWidth = 0; + const Bitmap* pBitmap = __pIconListView->GetBitmapOfEmptyList(); + + + // set visual element or canvas for empty list + if (!__needBaseCanvas && __pEmptyListVE == null) + { + __pEmptyListVE = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI, __pEmptyListVE != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pEmptyListVE->Construct(); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pEmptyListVE->SetSurfaceOpaque(false); + __pEmptyListVE->SetImplicitAnimationEnabled(false); + + __pVE->AttachChild(*__pEmptyListVE); + } + else if (__needBaseCanvas) + { + pCanvas = __pVE->GetCanvasN(); + SysTryCatch(NID_UI, pCanvas != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + + GET_SHAPE_CONFIG(ICONLIST::EMPTY_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, emptyTextHeight); + + if (!emptyText.IsEmpty()) + { + pFont = __pIconListView->GetFallbackFont(); + SysTryCatch(NID_UI, pFont != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pTextObject = new (std::nothrow) TextObject; + SysTryCatch(NID_UI, pTextObject != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pTextObject->Construct(); + TextSimple* pSimpleText = new (std::nothrow)TextSimple(const_cast (emptyText.GetPointer()), emptyText.GetLength()); + SysTryCatch(NID_UI, pSimpleText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pTextObject->AppendElement(*pSimpleText); + pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + pTextObject->SetForegroundColor(__pIconListView->GetTextColorOfEmptyList(), 0, pTextObject->GetTextLength()); + pTextObject->SetFont(pFont, 0, pTextObject->GetTextLength()); + pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + pTextObject->SetBounds(Rectangle(0, 0, viewBounds.width, 1)); + pTextObject->Compose(); + textDimension.height = pTextObject->GetTotalHeight(); + textDimension.width = pTextObject->GetLineWidthAt(0); + + for (int i = 1; i < pTextObject->GetTotalLineCount(); i++) + { + int tempWidth = pTextObject->GetLineWidthAt(i); + textDimension.width = textDimension.width > tempWidth ? textDimension.width : tempWidth; + } + + // calculate bounds with text + if (viewBounds.width >= textDimension.width) + { + bounds.x = (viewBounds.width - textDimension.width) / 2; + bounds.width = textDimension.width; + } + else + { + bounds.width = viewBounds.width; + } + + if (viewBounds.height >= textDimension.height) + { + bounds.y = (viewBounds.height - textDimension.height) / 2; + bounds.height = textDimension.height; + } + else + { + bounds.height = viewBounds.height; + } + } + + if (pBitmap != null) + { + int originalHeight = pBitmap->GetHeight(); + bitmapHeight = originalHeight; + bitmapWidth = pBitmap->GetWidth(); + + // calculate bounds with bitmap + if (!emptyText.IsEmpty()) + { + gap = emptyTextHeight; + } + + if (bounds.height + bitmapHeight + gap < viewBounds.height) + { + bounds.height += (bitmapHeight + gap); + } + else + { + bitmapHeight = viewBounds.height - gap - textDimension.height; + if (bitmapHeight < 0) + { + bitmapHeight = 0; + bitmapWidth = 0; + } + else if (bitmapHeight != originalHeight) + { + bitmapWidth = bitmapWidth * (double)((double)bitmapHeight / (double)originalHeight); + } + + bounds.height = bitmapHeight + gap + textDimension.height; + } + + bounds.y = (viewBounds.height - bounds.height) / 2; + + if (bounds.width > bitmapWidth) + { + bitmapXPosition = (bounds.width - bitmapWidth) / 2; + } + else if (viewBounds.width > bitmapWidth) + { + bounds.x = (viewBounds.width - bitmapWidth) / 2; + bounds.width = bitmapWidth; + } + } + + // draw emtpy list + if (!__needBaseCanvas) + { + FloatRectangle visualElementBounds(bounds.x, bounds.y, bounds.width, bounds.height); + __pEmptyListVE->SetBounds(visualElementBounds); + __pEmptyListVE->SetShowState(true); + + pCanvas = __pEmptyListVE->GetCanvasN(); + SysTryCatch(NID_UI, pCanvas != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + Color backgroundColor = __pIconListView->GetBackgroundColor(); + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + bounds.x = 0; + bounds.y = 0; + } + + if (pBitmap != null) + { + if (pBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(Rectangle(bounds.x + bitmapXPosition, bounds.y, bitmapWidth, bitmapHeight), *pBitmap); + } + else + { + pCanvas->DrawBitmap(Rectangle(bounds.x + bitmapXPosition, bounds.y, bitmapWidth, bitmapHeight), *pBitmap); + } + } + + if (!emptyText.IsEmpty()) + { + pTextObject->SetBounds(Rectangle(bounds.x, bounds.y + gap + bitmapHeight, bounds.width, textDimension.height)); + pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + } + + __listStatusChanged = false; + + if (__needBaseCanvas && __pEmptyListVE != null) + { + __pEmptyListVE->Destroy(); + __pEmptyListVE = null; + } + + delete pCanvas; + delete pTextObject; + return r; + +CATCH: + if (__pEmptyListVE != null) + { + __pEmptyListVE->Destroy(); + __pEmptyListVE = null; + } + + delete pCanvas; + delete pTextObject; + return r; +} + +result +_IconListPresenter::DrawHorizontalScrollList(void) +{ + int itemCount = __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX); + int itemHeight = GetItemSize().height; + int itemWidth = GetItemSize().width; + Rectangle itemRect(0, 0, itemWidth, itemHeight); + int drawingLine = (__scrollPosition > __leftMargin) ? + (__scrollPosition - __leftMargin + __horizontalSpacing) / __unitScrollLength : 0; + int index = drawingLine * __itemCountPerAxis; + int endXPos = __pIconListView->GetBounds().width; + int endYPos = __endPosOfAxis; + int unitWidth = __unitScrollLength; + int unitHeight = __unitLengthOfAxis; + _IconListItem* pItem = null; + itemRect.x = __leftMargin + drawingLine * unitWidth - __scrollPosition; + + // Hide Items + if (__lastDrawnIndex >= 0) + { + int scroll = endXPos - itemRect.x; + int lastIndex = index + ((scroll - 1) / unitWidth + 1) * __itemCountPerAxis - 1; + if (lastIndex >= itemCount) + { + lastIndex = itemCount - 1; + } + + if (__lastDrawnIndex < index || __firstDrawnIndex > lastIndex) + { + HideItems(__firstDrawnIndex, __lastDrawnIndex); + } + else + { + HideItems(__firstDrawnIndex, index - 1); + HideItems(lastIndex + 1, __lastDrawnIndex); + } + } + + // Preload Items + if (__firstDrawnIndex > index) + { + int topIndex = __firstDrawnIndex - __itemCountPerAxis * (__pIconListView->GetBounds().width / __unitScrollLength + 1); + if (topIndex <= index) + { + while (--__firstDrawnIndex > index) + { + __pListModel->LoadItem(DEFAULT_GROUP_INDEX, __firstDrawnIndex); + } + } + } + + // Draw Items + __firstDrawnIndex = index; + while (itemRect.x < endXPos) + { + itemRect.y = __startPosOfAxis; + while (itemRect.y < endYPos && index < itemCount) + { + // Draw Item + pItem = dynamic_cast <_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, index)); + if (pItem != null) + { + pItem->SetDrawingProperty(*__pItemDrawingProperty); + if (__selectedIndex == index) + { + if (__isTouchAnimationEnabled && !__isTouchPressed) + { + float ratio = __touchAnimation.GetCurrentAnimationFrame(); + pItem->DrawItemTouchAnimation(itemRect, ratio); + } + else + { + pItem->DrawItem(itemRect, LIST_ITEM_STATE_PRESSED); + } + } + else if (__highlightedIndex == index) + { + pItem->DrawItem(itemRect, LIST_ITEM_STATE_HIGHLIGHTED); + } + else + { + pItem->DrawItem(itemRect, LIST_ITEM_STATE_NORMAL); + } + + if (pItem->GetVisualElement() != null) + { + pItem->GetVisualElement()->SetFlushNeeded(); + } + } + ++index; + itemRect.y += unitHeight; + } + itemRect.x += unitWidth; + } + __lastDrawnIndex = index - 1; + + return E_SUCCESS; +} + +result +_IconListPresenter::DrawVerticalScrollList(void) +{ + int itemCount = __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX); + int itemHeight = GetItemSize().height; + int itemWidth = GetItemSize().width; + Rectangle itemRect(0, 0, itemWidth, itemHeight); + int drawingLine = (__scrollPosition > __topMargin) ? + (__scrollPosition - __topMargin + __verticalSpacing) / __unitScrollLength : 0; + int index = drawingLine * __itemCountPerAxis; + int endXPos = __endPosOfAxis; + int endYPos = __pIconListView->GetBounds().height; + int unitWidth = __unitLengthOfAxis; + int unitHeight = __unitScrollLength; + _IconListItem* pItem = null; + itemRect.y = __topMargin + drawingLine * unitHeight - __scrollPosition; + + // Hide Items + if (__lastDrawnIndex >= 0) + { + int scroll = endYPos - itemRect.y; + int lastIndex = index + ((scroll - 1) / unitHeight + 1) * __itemCountPerAxis - 1; + if (lastIndex >= itemCount) + { + lastIndex = itemCount - 1; + } + + if (__lastDrawnIndex < index || __firstDrawnIndex > lastIndex) + { + HideItems(__firstDrawnIndex, __lastDrawnIndex); + } + else + { + HideItems(__firstDrawnIndex, index - 1); + HideItems(lastIndex + 1, __lastDrawnIndex); + } + } + + // Preload Items + if (__firstDrawnIndex > index) + { + int topIndex = __firstDrawnIndex - __itemCountPerAxis * (__pIconListView->GetBounds().height / __unitScrollLength + 1); + if (topIndex <= index) + { + while (--__firstDrawnIndex > index) + { + __pListModel->LoadItem(DEFAULT_GROUP_INDEX, __firstDrawnIndex); + } + } + } + + // Draw Items + __firstDrawnIndex = index; + while (itemRect.y < endYPos) + { + itemRect.x = __startPosOfAxis; + while (itemRect.x < endXPos && index < itemCount) + { + // Draw Item + pItem = dynamic_cast <_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, index)); + if (pItem != null) + { + pItem->SetDrawingProperty(*__pItemDrawingProperty); + if (__selectedIndex == index) + { + if (__isTouchAnimationEnabled && !__isTouchPressed) + { + float ratio = __touchAnimation.GetCurrentAnimationFrame(); + pItem->DrawItemTouchAnimation(itemRect, ratio); + } + else + { + pItem->DrawItem(itemRect, LIST_ITEM_STATE_PRESSED); + } + } + else if (__highlightedIndex == index) + { + pItem->DrawItem(itemRect, LIST_ITEM_STATE_HIGHLIGHTED); + } + else + { + pItem->DrawItem(itemRect, LIST_ITEM_STATE_NORMAL); + } + } + ++index; + itemRect.x += unitWidth; + } + itemRect.y += unitHeight; + } + __lastDrawnIndex = index - 1; + + return E_SUCCESS; +} + +void +_IconListPresenter::AdjustLayout(void) +{ + Dimension itemSize = __pIconListView->GetItemSize(); + Rectangle bounds = __pIconListView->GetBounds(); + int itemCount = __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX); + int oldScrollLength = __scrollLength; + + // Reset layout changed flag + __isLayoutChanged = false; + + // Calculate + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + // Unit Axis Length(= Item Width + Horizontal Spacing) + __unitLengthOfAxis = itemSize.width + __horizontalSpacing; + + // ItemCountPerAxis + __itemCountPerAxis = (bounds.width - __leftMargin - __rightMargin + __horizontalSpacing) / __unitLengthOfAxis; + + // Unit Scroll Length(= Item Height + Vertical Spacing) + __unitScrollLength = itemSize.height + __verticalSpacing; + + // ScrollLength + if (__itemCountPerAxis > 0) + { + __scrollLength = __topMargin + __bottomMargin - __verticalSpacing + __unitScrollLength * + ((itemCount - 1) / __itemCountPerAxis + 1) - bounds.height; + if (__scrollLength < 0) + { + __scrollLength = 0; + } + } + else + { + __itemCountPerAxis = 0; + __scrollLength = 0; + } + + // startPosOfAxis + switch (__itemHorizontalAlignment) + { + case ALIGNMENT_LEFT: + __startPosOfAxis = __leftMargin; + break; + + case ALIGNMENT_CENTER: + __startPosOfAxis = + (bounds.width + __leftMargin - __rightMargin - __itemCountPerAxis * __unitLengthOfAxis + + __horizontalSpacing) >> 1; + break; + + case ALIGNMENT_RIGHT: + __startPosOfAxis = bounds.width - __rightMargin - __itemCountPerAxis * __unitLengthOfAxis + __horizontalSpacing; + break; + } + + // endPosOfAxis + __endPosOfAxis = __startPosOfAxis + __itemCountPerAxis * __unitLengthOfAxis - __horizontalSpacing; + + if (__scrollLength != oldScrollLength) + { + // Set Scroll Range & Position + _Scroll* pScroll = __pIconListView->GetScroll(); + if (pScroll != null) + { + pScroll->SetScrollRange(bounds.height, __scrollLength + bounds.height); + + if (__scrollLength <= 0) + { + pScroll->EnableScrollingEffect(false); + } + else + { + pScroll->EnableScrollingEffect(true); + } + } + + if ((__scrollLength < oldScrollLength) && (__scrollPosition > __scrollLength)) + { + if (SetScrollPosition(__scrollLength)) + { + ScrollFadeOut(); + FireScrollEvent(); + + __pIconListView->Invalidate(); + } + } + } + + // CachingSize = # of items of view * ITEM_CACHE_SIZE_MULTIPLIER + __pListModel->SetMaxCachingSize( + (bounds.height / __unitScrollLength + 1) * __itemCountPerAxis * ITEM_CACHE_SIZE_MULTIPLIER); + } + else + { + // Unit Axis Length(= Item Height + Vertical Spacing) + __unitLengthOfAxis = itemSize.height + __verticalSpacing; + + // ItemCountPerAxis + __itemCountPerAxis = (bounds.height - __topMargin - __bottomMargin + __verticalSpacing) / __unitLengthOfAxis; + + // Unit Scroll Length(= Item Width + Horizontal Spacing) + __unitScrollLength = itemSize.width + __horizontalSpacing; + + // ScrollLength + if (__itemCountPerAxis > 0) + { + __scrollLength = __leftMargin + __rightMargin - __horizontalSpacing + __unitScrollLength * + ((itemCount - 1) / __itemCountPerAxis + 1) - bounds.width; + if (__scrollLength < 0) + { + __scrollLength = 0; + } + } + else + { + __itemCountPerAxis = 0; + __scrollLength = 0; + } + + // startPosOfAxis + switch (__itemVerticalAlignment) + { + case ALIGNMENT_TOP: + __startPosOfAxis = __topMargin; + break; + + case ALIGNMENT_MIDDLE: + __startPosOfAxis = + (bounds.height + __topMargin - __bottomMargin - __itemCountPerAxis * __unitLengthOfAxis + + __verticalSpacing) >> 1; + break; + + case ALIGNMENT_BOTTOM: + __startPosOfAxis = bounds.height - __bottomMargin - __itemCountPerAxis * __unitLengthOfAxis + __verticalSpacing; + break; + } + + // endPosOfAxis + __endPosOfAxis = __startPosOfAxis + __itemCountPerAxis * __unitLengthOfAxis - __verticalSpacing; + + if (__scrollLength != oldScrollLength) + { + // Set Scroll Range & Position + _Scroll* pScroll = __pIconListView->GetScroll(); + if (pScroll != null) + { + pScroll->SetScrollRange(bounds.width, __scrollLength + bounds.width); + + if (__scrollLength <= 0) + { + pScroll->EnableScrollingEffect(false); + } + else + { + pScroll->EnableScrollingEffect(true); + } + } + + if ((__scrollLength < oldScrollLength) && (__scrollPosition > __scrollLength)) + { + if (SetScrollPosition(__scrollLength)) + { + ScrollFadeOut(); + FireScrollEvent(); + + __pIconListView->Invalidate(); + } + } + } + + // CachingSize = # of items of view * ITEM_CACHE_SIZE_MULTIPLIER + __pListModel->SetMaxCachingSize((bounds.width / __unitScrollLength + 1) * __itemCountPerAxis * ITEM_CACHE_SIZE_MULTIPLIER); + } +} + +void +_IconListPresenter::HideItems(int startIndex, int endIndex) +{ + // Valid Check + if (startIndex < 0 || endIndex < 0) + { + return; + } + + if (endIndex >= __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX)) + { + endIndex = __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX) - 1; + } + + for (int index = startIndex; index <= endIndex; ++index) + { + _IconListItem* pItem = dynamic_cast <_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, index)); + if (pItem != null) + { + _VisualElement* pBase = pItem->GetVisualElement(); + if (pBase != null) + { + pBase->SetShowState(false); + } + } + } +} + +result +_IconListPresenter::RedrawItem(int index, float ratio, bool doShow, float checkRatio) +{ + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX)), E_OUT_OF_RANGE, + E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index must be non-negative integer, and less than count of whole items."); + + // Pre-Load Check + + _IconListItem* pItem = dynamic_cast <_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, index)); + SysTryReturn(NID_UI_CTRL, (pItem != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Unable to get item."); + + // Pre-draw check + if (index < __firstDrawnIndex || index > __lastDrawnIndex) + { + pItem->ClearVisualElement(); + return E_SUCCESS; + } + + Rectangle itemRect = GetItemBounds(index); + + pItem->SetDrawingProperty(*__pItemDrawingProperty); + pItem->ClearVisualElement(); + if (__selectedIndex == index) + { + if (__isTouchAnimationEnabled && !__isTouchPressed) + { + pItem->DrawItemTouchAnimation(itemRect, ratio); + } + else + { + pItem->DrawItem(itemRect, LIST_ITEM_STATE_PRESSED); + } + } + else if (__highlightedIndex == index) + { + pItem->DrawItem(itemRect, LIST_ITEM_STATE_HIGHLIGHTED); + } + else if (__checkedIndex == index) + { + pItem->DrawItemCheckAnimation(itemRect, checkRatio); + } + else + { + pItem->DrawItem(itemRect, LIST_ITEM_STATE_NORMAL); + } + + _VisualElement* pBase = pItem->GetVisualElement(); + FloatRectangle itemRectf(itemRect.x, itemRect.y, itemRect.width, itemRect.height); + pBase->InvalidateRectangle(&itemRectf); + pBase->Draw(); + + if (doShow) + { + pBase->SetFlushNeeded(); + } + + return E_SUCCESS; +} + +result +_IconListPresenter::FireIconListViewItemEvent(_IconListViewItemEventType eventType, int index, int arg) +{ + // Create EventArg + _IconListViewItemEventArg* pArg = new (std::nothrow) _IconListViewItemEventArg(index, eventType); + SysTryReturn(NID_UI_CTRL, (pArg != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memroy allcation failed."); + switch (eventType) + { + case EVENT_TYPE_ITEM_SELECTED: + pArg->SetStatus(static_cast(arg)); + break; + case EVENT_TYPE_OVERLAY_BITMAP_SELECTED: + pArg->SetOverlayBitmapId(arg); + break; + case EVENT_TYPE_ITEM_REORDERED: + pArg->SetToIndex(arg); + break; + } + + // Fire Event + return __pIconListView->GetIconListItemEvent()->Fire(*pArg); +} + +result +_IconListPresenter::FireScrollEndReachedEvent(ScrollEndEvent type) +{ + // Create EventArg + _UiScrollEventArg* pEventArg = _UiScrollEventArg::GetScrollEventArgN(*__pIconListView, type); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Fire Event + r = __pIconListView->GetScrollEvent()->Fire(*pEventArg); + return r; +CATCH: + delete pEventArg; + return r; +} + +result +_IconListPresenter::FireScrollPositionChangedEvent(int scrollPosition) +{ + // Create EventArg + _UiScrollEventArg* pEventArg = _UiScrollEventArg::GetScrollEventArgN(*__pIconListView, scrollPosition); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Fire Event + r = __pIconListView->GetScrollEvent()->Fire(*pEventArg); + return r; +CATCH: + delete pEventArg; + return r; +} + +result +_IconListPresenter::FireScrollStoppedEvent() +{ + // Create EventArg + _UiScrollEventArg* pEventArg = _UiScrollEventArg::GetScrollEventArgN(*__pIconListView); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Fire Event + r = __pIconListView->GetScrollEvent()->Fire(*pEventArg); + return r; +CATCH: + delete pEventArg; + return r; +} + +result +_IconListPresenter::FireScrollEvent() +{ + result r = E_SUCCESS; + + if ((__pFlickAnimationTimer != null) || (__pMagneticScrollTimer != null)) + { + return r; + } + + if (__scrollPosition == 0) + { + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + r = FireScrollEndReachedEvent(SCROLL_END_EVENT_END_TOP); + } + else + { + r = FireScrollEndReachedEvent(SCROLL_END_EVENT_END_LEFT); + } + + if (!__isTouchPressed) + { + ScrollFadeOut(); + } + } + else if (__scrollPosition == __scrollLength) + { + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + r = FireScrollEndReachedEvent(SCROLL_END_EVENT_END_BOTTOM); + } + else + { + r = FireScrollEndReachedEvent(SCROLL_END_EVENT_END_RIGHT); + } + + if (!__isTouchPressed) + { + ScrollFadeOut(); + } + } + else + { + r = FireScrollPositionChangedEvent(__scrollPosition); + } + return r; +} + +bool +_IconListPresenter::SetScrollPosition(int position, bool enableFadeEffect) +{ + if ((__scrollLength <= 0) && (position != 0)) + { + return false; + } + + if (__scrollPosition == position) + { + return false; + } + + if (position > __scrollLength) + { + __scrollPosition = __scrollLength; + } + else if (position < 0) + { + __scrollPosition = 0; + } + else + { + __scrollPosition = position; + } + + result r = E_SUCCESS; + _Scroll *pScroll =__pIconListView->GetScroll(); + if (pScroll != null) + { + pScroll->SetScrollingEffectVisibility(true); + + if (pScroll->IsEnabledFadeEffect()) + { + if (enableFadeEffect) + { + pScroll->SetScrollVisibility(true); + } + else + { + pScroll->EnableFadeEffect(false); + pScroll->SetScrollVisibility(true); + pScroll->EnableFadeEffect(true); + } + } + + r = pScroll->SetScrollPosition(position); + } + + return (r == E_SUCCESS); +} + +void +_IconListPresenter::ScrollFadeOut(bool showEffect) +{ + _Scroll* pScroll = __pIconListView->GetScroll(); + if (pScroll != null) + { + if (pScroll->IsEnabledFadeEffect()) + { + if (showEffect) + { + pScroll->EnableFadeEffect(false); + pScroll->SetScrollVisibility(true); + pScroll->SetScrollingEffectVisibility(true); + pScroll->EnableFadeEffect(true); + } + + pScroll->SetScrollVisibility(false); + } + + pScroll->SetScrollingEffectVisibility(false); + } +} + +int +_IconListPresenter::GetMagneticScrollPosition(void) const +{ + if (__magneticScrollSize <= 0) + { + return __scrollPosition; + } + + int scrollPosition = __scrollPosition; + int leftScrollLength = __scrollLength - scrollPosition; + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + if (scrollPosition < __topMargin) + { + return 0; + } + + scrollPosition -= __topMargin; + } + else + { + if (scrollPosition < __leftMargin) + { + return 0; + } + + scrollPosition -= __leftMargin; + } + + int unitMagneticScrollSize = __unitScrollLength * __magneticScrollSize; + scrollPosition %= unitMagneticScrollSize; + if (scrollPosition > leftScrollLength) + { + scrollPosition = __scrollLength + OVERSCROLLING_MAX_DISTANCE; + } + else if (scrollPosition > (unitMagneticScrollSize >> 1)) + { + scrollPosition = __scrollPosition - scrollPosition + unitMagneticScrollSize; + } + else + { + scrollPosition = __scrollPosition - scrollPosition; + } + + return scrollPosition; +} + +Rectangle +_IconListPresenter::GetItemBounds(int index) const +{ + // Absolute Coordinate Base + Rectangle rect(0, 0, GetItemSize().width, GetItemSize().height); + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + rect.x = __startPosOfAxis + __unitLengthOfAxis * (index % __itemCountPerAxis); + rect.y = __topMargin + __unitScrollLength * (index / __itemCountPerAxis) - __scrollPosition; + } + else + { + rect.x = __leftMargin + __unitScrollLength * (index / __itemCountPerAxis) - __scrollPosition; + rect.y = __startPosOfAxis + __unitLengthOfAxis * (index % __itemCountPerAxis); + } + + return rect; +} + +void +_IconListPresenter::InitializeAccessibilityElement(void) +{ + RemoveAllAccessibilityElements(); + + int itemCount = __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX); + if (itemCount < 0) + { + return; + } + + int firstIndex = INVALID_INDEX; + int endIndex = INVALID_INDEX; + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + int firstLine = (__scrollPosition > __topMargin) ? + (__scrollPosition - __topMargin + __verticalSpacing) / __unitScrollLength : 0; + + firstIndex = firstLine * __itemCountPerAxis; + endIndex = firstIndex + ((__pIconListView->GetBounds().height + __verticalSpacing) / __unitScrollLength) * __itemCountPerAxis; + } + else + { + int firstLine = (__scrollPosition > __leftMargin) ? + (__scrollPosition - __leftMargin + __horizontalSpacing) / __unitScrollLength : 0; + + firstIndex = firstLine * __itemCountPerAxis; + endIndex = firstIndex + ((__pIconListView->GetBounds().width + __horizontalSpacing) / __unitScrollLength) * __itemCountPerAxis; + } + + endIndex = itemCount > endIndex ? endIndex : (itemCount - 1); + + for (int i = firstIndex; i < endIndex; i++) + { + _IconListItem* pItem = static_cast<_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, i)); + if (pItem != null) + { + _VisualElement* pVE = pItem->GetItemVisualElement(); + if (pVE != null) + { + FloatRectangle floatRectangle = pVE->GetBounds(); + Rectangle rect(floatRectangle.x, floatRectangle.y, floatRectangle.width, floatRectangle.height); + AddAccessibilityElement(*pItem, rect); + } + } + } +} + +void +_IconListPresenter::AddAccessibilityElement(_IconListItem& item, const Tizen::Graphics::Rectangle& rect) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityContainer* pContainer = __pIconListView->GetAccessibilityContainer(); + if (pContainer != null) + { + _AccessibilityElement* pElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, (pElement != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memroy allocation failed."); + pElement->SetLabel(item.GetText()); + pElement->SetTrait(ACCESSIBILITY_TRAITS_IMAGE); + pElement->SetValue(item.IsChecked() ? L"selected" : L""); + pElement->SetBounds(rect); + pContainer->AddElement(*pElement); + } +} + +void +_IconListPresenter::RemoveAllAccessibilityElements(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityContainer* pContainer = __pIconListView->GetAccessibilityContainer(); + if (pContainer != null) + { + pContainer->RemoveAllElement(); + } +} + +void +_IconListPresenter::TranslateIconListItemPosition(int& x, int& y) +{ + if (__unitLengthOfAxis <= 0 || __unitScrollLength <= 0) + { + x = -1; + y = -1; + return; + } + + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + x -= __startPosOfAxis; + if (x < 0) + { + x = -1; + y = -1; + return; + } + + x = x % __unitLengthOfAxis; + + y += __scrollPosition - __topMargin; + if (y < 0) + { + x = -1; + y = -1; + return; + } + + y = y % __unitScrollLength; + } + else + { + y -= __startPosOfAxis; + if (y < 0) + { + x = -1; + y = -1; + return; + } + + y = y % __unitLengthOfAxis; + + x += __scrollPosition - __leftMargin; + if (x < 0) + { + x = -1; + y = -1; + return; + } + + x = x % __unitScrollLength; + } +} + +result +_IconListPresenter::StartSelectionAnimationTimer(void) +{ + result r = E_SUCCESS; + + if (__pSelectionAnimationTimer == null) + { + __pSelectionAnimationTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI_CTRL, (__pSelectionAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memroy allocation failed."); + + r = __pSelectionAnimationTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pSelectionAnimationTimer->Cancel(); + } + + if (__isSelectionDelayed) + { + r = __pSelectionAnimationTimer->Start(TOUCH_ACTION_TIMER_PERIOD); + } + else + { + r = __pSelectionAnimationTimer->Start(MAGNETIC_SCROLL_TIMER_PERIOD); + } + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + ResetSelectionAnimationTimer(); + return r; +} + +result +_IconListPresenter::ResetSelectionAnimationTimer(void) +{ + delete __pSelectionAnimationTimer; + __pSelectionAnimationTimer = null; + + if (__selectedIndex >= 0 || __isSelectionDelayed) + { + __isSelectionDelayed = false; + + int index = __selectedIndex; + __selectedIndex = INVALID_INDEX; + RedrawItem(index); + } + + return E_SUCCESS; +} + +result +_IconListPresenter::StartCheckAnimationTimer(void) +{ + result r = E_SUCCESS; + if (__pCheckAnimationTimer == null) + { + __pCheckAnimationTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI_CTRL, (__pCheckAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memroy allocation failed."); + + r = __pCheckAnimationTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pCheckAnimationTimer->Cancel(); + } + + __pCheckAnimationTimer->Start(SELECTION_ANIMATION_TIMER_PERIOD); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +CATCH: + ResetCheckAnimationTimer(); + return r; +} + +result +_IconListPresenter::ResetCheckAnimationTimer(void) +{ + delete __pCheckAnimationTimer; + __pCheckAnimationTimer = null; + + if (__checkedIndex >= 0) + { + int index = __checkedIndex; + __checkedIndex = INVALID_INDEX; + return RedrawItem(index); + } + + return E_SUCCESS; +} + +result +_IconListPresenter::StartTouchActionTimer(void) +{ + result r = E_SUCCESS; + + if (__pTouchActionTimer == null) + { + __pTouchActionTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI_CTRL, (__pTouchActionTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pTouchActionTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pTouchActionTimer->Cancel(); + } + + r = __pTouchActionTimer->Start(TOUCH_ACTION_TIMER_PERIOD); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + ResetTouchActionTimer(); + return r; +} + +result +_IconListPresenter::ResetTouchActionTimer(void) +{ + delete __pTouchActionTimer; + __pTouchActionTimer = null; + + return E_SUCCESS; +} + +result +_IconListPresenter::StartFlickAnimationTimer(void) +{ + result r = E_SUCCESS; + + if (__pFlickAnimationTimer == null) + { + __pFlickAnimationTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI_CTRL, (__pFlickAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pFlickAnimationTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pFlickAnimationTimer->Cancel(); + } + + r = __pFlickAnimationTimer->Start(FLICK_ANIMATION_TIMER_PERIOD); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + ResetFlickAnimationTimer(); + return r; +} + +result +_IconListPresenter::ResetFlickAnimationTimer(void) +{ + if (__pFlickAnimationTimer != null) + { + FireScrollStoppedEvent(); + } + + delete __pFlickAnimationTimer; + __pFlickAnimationTimer = null; + + return E_SUCCESS; +} + +result +_IconListPresenter::StartMagneticScrollTimer(void) +{ + result r = E_SUCCESS; + + if (__pMagneticScrollTimer == null) + { + __pMagneticScrollTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI_CTRL, (__pMagneticScrollTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pMagneticScrollTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pMagneticScrollTimer->Cancel(); + } + + r = __pMagneticScrollTimer->Start(MAGNETIC_SCROLL_TIMER_PERIOD); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + ResetMagneticScrollTimer(); + return r; +} + +result +_IconListPresenter::ResetMagneticScrollTimer(void) +{ + if (__pMagneticScrollTimer != null) + { + FireScrollStoppedEvent(); + } + + delete __pMagneticScrollTimer; + __pMagneticScrollTimer = null; + + return E_SUCCESS; +} + +result +_IconListPresenter::StartReorderScrollTimer(void) +{ + result r = E_SUCCESS; + + if (__pReorderScrollTimer == null) + { + __pReorderScrollTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI_CTRL, (__pReorderScrollTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pReorderScrollTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pReorderScrollTimer->Cancel(); + } + + r = __pReorderScrollTimer->Start(REORDER_SCROLL_TIMER_PERIOD); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + ResetReorderScrollTimer(); + return r; +} + +result +_IconListPresenter::ResetReorderScrollTimer(void) +{ + delete __pReorderScrollTimer; + __pReorderScrollTimer = null; + + return E_SUCCESS; +} + +result +_IconListPresenter::StartAnimationTimer(int delay) +{ + result r = E_SUCCESS; + + if (__pAnimationTimer == null) + { + __pAnimationTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI_CTRL, (__pAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pAnimationTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pAnimationTimer->Cancel(); + } + + r = __pAnimationTimer->Start(delay); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + ResetAnimationTimer(); + return r; + +} + +result +_IconListPresenter::ResetAnimationTimer(void) +{ + delete __pAnimationTimer; + __pAnimationTimer = null; + + __animationItemIndex = INVALID_INDEX; + + return E_SUCCESS; +} + +// Tizen::Ui::_ControlImpl +void +_IconListPresenter::OnBoundsChanged(void) +{ + __isLayoutChanged = true; + + if (__pIconListView->GetScroll() != null) + { + __pIconListView->GetScroll()->OnParentBoundsChanged(); + } +} + +void +_IconListPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = FONT_STYLE_PLAIN; + + if (__pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX) <= 0) + { + size = __pIconListView->GetTextSizeOfEmptyList(); + } + else + { + size = __pItemDrawingProperty->GetTextSize(); + } +} + +void +_IconListPresenter::OnFontChanged(Font* pFont) +{ + ClearVisualElement(); + __pItemDrawingProperty->SetFont(pFont); +} + +// Tizen::Ui::_IKeyEventPreviewer +bool +_IconListPresenter::OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo) +{ + return true; +} + +bool +_IconListPresenter::OnPreviewKeyReleased(const _Control& source, const _KeyInfo& keyInfo) +{ + return true; +} + +// Tizen::Ui::_IKeyEventListener +bool +_IconListPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) +{ + return true; +} + +bool +_IconListPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) +{ + return true; +} + +// Tizen::Ui::_INotificationEventPreviewer +bool +_IconListPresenter::OnPreviewNotifiedN(const _Control& source, IList* pArgs) +{ + delete pArgs; + return true; +} + +// Tizen::Ui::_INotificationEventListener +bool +_IconListPresenter::OnNotifiedN(const _Control& source, IList* pArgs) +{ + delete pArgs; + return true; +} + +// Tizen::Ui::_ITouchEventPreviewer +_UiTouchEventDelivery +_IconListPresenter::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__selectedIndex < 0) + { + // handle the event of touch release that occurred from thumb style scrollbar + _Scroll* pScroll = __pIconListView->GetScroll(); + if (pScroll != null && pScroll->IsEnabledHandler()) + { + // Trigger Magnetic Scroll Effect + if ((__pMagneticScrollTimer == null) && (__pFlickAnimationTimer == null) && (__magneticScrollSize > 0)) + { + int diff = GetMagneticScrollPosition() - __scrollPosition; + if (diff != 0) + { + ResetMagneticScrollTimer(); + + // Trigger Magnetic Scroll Effect + __magneticScrollAnimation.StartAnimation(diff); + StartMagneticScrollTimer(); + } + else + { + ScrollFadeOut(); + } + } + + if ((__pMagneticScrollTimer == null) && (__pFlickAnimationTimer == null)) + { + ScrollFadeOut(); + } + } + } + + return _UI_TOUCH_EVENT_DELIVERY_YES; +} + +// Tizen::Ui::_ITouchEventListener +bool +_IconListPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + __currentTouchInfo = touchinfo; + __isTouchPressed = true; + + _Scroll* pScroll = __pIconListView->GetScroll(); + if (pScroll != null) + { + int scrollPosition = pScroll->GetScrollPosition(); + if (scrollPosition != __scrollPosition) + { + pScroll->SetScrollPosition(__scrollPosition); + } + } + + // Reset Timer + ResetAnimationTimer(); + ResetSelectionAnimationTimer(); + ResetTouchActionTimer(); + ResetFlickAnimationTimer(); + ResetMagneticScrollTimer(); + ResetCheckAnimationTimer(); + + StartTouchActionTimer(); + + return true; +} + +bool +_IconListPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + __isTouchPressed = false; + + if (__onReordering) + { + FinishReordering(); + } + else + { + Point touchPressedPosition = touchinfo.GetCurrentPosition(); + if (__selectedIndex >= 0) + { + __isSelectionDelayed = true; + StartSelectionAnimationTimer(); + } + else if (__pTouchActionTimer != null) + { + ResetTouchActionTimer(); + OnTouchActionActivated(*__pIconListView, __currentTouchInfo); + + __isSelectionDelayed = true; + StartSelectionAnimationTimer(); + } + } + + // Trigger Magnetic Scroll Effect + if ((__pMagneticScrollTimer == null) && (__pFlickAnimationTimer == null) && (__magneticScrollSize > 0)) + { + int diff = GetMagneticScrollPosition() - __scrollPosition; + if (diff != 0) + { + ResetMagneticScrollTimer(); + + // Trigger Magnetic Scroll Effect + __magneticScrollAnimation.StartAnimation(diff); + StartMagneticScrollTimer(); + } + else + { + ScrollFadeOut(); + } + } + + if ((__pMagneticScrollTimer == null) && (__pFlickAnimationTimer == null)) + { + if (__pIconListView->GetScroll()->GetScrollVisibility()) + { + ScrollFadeOut(); + InitializeAccessibilityElement(); + } + } + + return true; +} + +void +_IconListPresenter::ProcessAfterTouchRelease(int index) +{ + if (index >= 0 && __pListModel->IsItemEnabled(DEFAULT_GROUP_INDEX, index)) + { + __flickCount = 0; + + if (__selectedOverlayBitmapId >= 0) + { + if (__isTouchAnimationEnabled) + { + // Touch Animation Start + StartSelectionAnimationTimer(); + __touchAnimation.StartAnimation(); + } + else + { + int revertIndex = __selectedIndex; + __selectedIndex = INVALID_INDEX; + RedrawItem(revertIndex); + + // Fire Event + FireIconListViewItemEvent(EVENT_TYPE_OVERLAY_BITMAP_SELECTED, index, __selectedOverlayBitmapId); + } + return; + } + + switch (__pIconListView->GetStyle()) + { + case ICON_LIST_VIEW_STYLE_NORMAL: + { + if (__isTouchAnimationEnabled) + { + // Touch Animation Start + StartSelectionAnimationTimer(); + __touchAnimation.StartAnimation(); + } + else + { + int revertIndex = __selectedIndex; + __selectedIndex = INVALID_INDEX; + RedrawItem(revertIndex); + + // Fire Event + FireIconListViewItemEvent(EVENT_TYPE_ITEM_SELECTED, index, ICON_LIST_VIEW_ITEM_SELECTED); + } + break; + } + + case ICON_LIST_VIEW_STYLE_RADIO: + { + if (__isTouchAnimationEnabled) + { + // Touch Animation Start + StartSelectionAnimationTimer(); + __touchAnimation.StartAnimation(); + } + else + { + // Checked To Normal + int checkedIndex = __pListModel->GetIndexOfRadioCheckedItem(0); + + // Normal To Checked + __pListModel->SetItemChecked(DEFAULT_GROUP_INDEX, index, true); + if (index != checkedIndex) + { + if (checkedIndex >= 0) + { + RedrawItem(checkedIndex); + } + + __checkedIndex = index; + __checkAnimation.StartAnimation(); + StartCheckAnimationTimer(); + } + + __selectedIndex = INVALID_INDEX; + InitializeAccessibilityElement(); + + + // Fire Event + FireIconListViewItemEvent(EVENT_TYPE_ITEM_SELECTED, index, ICON_LIST_VIEW_ITEM_CHECKED); + } + break; + } + + case ICON_LIST_VIEW_STYLE_MARK: + { + if (__isTouchAnimationEnabled) + { + // Touch Animation Start + StartSelectionAnimationTimer(); + __touchAnimation.StartAnimation(); + } + else + { + bool isChecked = __pListModel->IsItemChecked(DEFAULT_GROUP_INDEX, index); + __pListModel->SetItemChecked(DEFAULT_GROUP_INDEX, index, !isChecked); + + __selectedIndex = INVALID_INDEX; + InitializeAccessibilityElement(); + + // Fire Event + if (isChecked) + { + RedrawItem(index); + FireIconListViewItemEvent(EVENT_TYPE_ITEM_SELECTED, index, ICON_LIST_VIEW_ITEM_UNCHECKED); + } + else + { + __checkedIndex = index; + __checkAnimation.StartAnimation(); + StartCheckAnimationTimer(); + FireIconListViewItemEvent(EVENT_TYPE_ITEM_SELECTED, index, ICON_LIST_VIEW_ITEM_CHECKED); + } + } + break; + } + } + } +} + +void +_IconListPresenter::FireEventAfterTouchRelease(int index) +{ + if (index >= 0 && __pListModel->IsItemEnabled(DEFAULT_GROUP_INDEX, index)) + { + if (__selectedOverlayBitmapId >= 0) + { + FireIconListViewItemEvent(EVENT_TYPE_OVERLAY_BITMAP_SELECTED, index, __selectedOverlayBitmapId); + return; + } + + switch (__pIconListView->GetStyle()) + { + case ICON_LIST_VIEW_STYLE_NORMAL: + { + FireIconListViewItemEvent(EVENT_TYPE_ITEM_SELECTED, index, ICON_LIST_VIEW_ITEM_SELECTED); + break; + } + + case ICON_LIST_VIEW_STYLE_RADIO: + { + // Checked To Normal + int checkedIndex = __pListModel->GetIndexOfRadioCheckedItem(0); + + // Normal To Checked + __pListModel->SetItemChecked(DEFAULT_GROUP_INDEX, index, true); + if (index != checkedIndex) + { + if (checkedIndex >= 0) + { + RedrawItem(checkedIndex); + } + + __checkedIndex = index; + __checkAnimation.StartAnimation(); + StartCheckAnimationTimer(); + } + + + FireIconListViewItemEvent(EVENT_TYPE_ITEM_SELECTED, index, ICON_LIST_VIEW_ITEM_CHECKED); + InitializeAccessibilityElement(); + break; + } + + case ICON_LIST_VIEW_STYLE_MARK: + { + bool isChecked = __pListModel->IsItemChecked(DEFAULT_GROUP_INDEX, index); + __pListModel->SetItemChecked(DEFAULT_GROUP_INDEX, index, !isChecked); + + InitializeAccessibilityElement(); + + if (isChecked) + { + RedrawItem(index); + FireIconListViewItemEvent(EVENT_TYPE_ITEM_SELECTED, index, ICON_LIST_VIEW_ITEM_UNCHECKED); + } + else + { + __checkedIndex = index; + __checkAnimation.StartAnimation(); + StartCheckAnimationTimer(); + FireIconListViewItemEvent(EVENT_TYPE_ITEM_SELECTED, index, ICON_LIST_VIEW_ITEM_CHECKED); + } + break; + } + } + } +} + +bool +_IconListPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + const Point movedPosition = touchinfo.GetCurrentPosition(); + + if (__pTouchActionTimer != null) + { + ResetAnimationTimer(); + ResetSelectionAnimationTimer(); + ResetTouchActionTimer(); + ResetFlickAnimationTimer(); + ResetCheckAnimationTimer(); + + int revertIndex = __selectedIndex; + __selectedIndex = INVALID_INDEX; + __selectedOverlayBitmapId = -1; + RedrawItem(revertIndex); + } + + if (__pIconListView == null || !__isTouchPressed) + { + __currentTouchInfo = touchinfo; + return true; + } + + Point pressedPosition = __currentTouchInfo.GetCurrentPosition(); + + if (__onReordering) + { + DoReordering(movedPosition); + return true; + } + + int scrollPosition = __scrollPosition; + + _Scroll* pScroll = __pIconListView->GetScroll(); + if (pScroll != null) + { + scrollPosition = pScroll->GetScrollPosition(); + } + + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + scrollPosition += pressedPosition.y - movedPosition.y; + } + else + { + scrollPosition += pressedPosition.x - movedPosition.x; + } + + __currentTouchInfo = touchinfo; + + if (SetScrollPosition(scrollPosition)) + { + // Draw + __selectedIndex = INVALID_INDEX; + __pIconListView->Invalidate(); + + // Trigger ScrollEvent + FireScrollEvent(); + + return true; + } + + return false; +} + +bool +_IconListPresenter::OnTouchActionActivated(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__pListModel == null || __pIconListView == null) + { + return false; + } + + if (__pIconListView->IsInReorderingMode()) + { + __lastReorderedPosition = touchinfo.GetCurrentPosition(); + PrepareReordering(); + __lastReorderedDifferences.x = touchinfo.GetCurrentPosition().x - __reorderItemBounds.x; + __lastReorderedDifferences.y = touchinfo.GetCurrentPosition().y - __reorderItemBounds.y; + } + else + { + Point touchPressedPosition = touchinfo.GetCurrentPosition(); + int index = GetItemIndexFromPosition(touchPressedPosition); + if (index >= 0 && __pListModel->IsItemEnabled(DEFAULT_GROUP_INDEX, index)) + { + __selectedIndex = index; + __selectedOverlayBitmapId = -1; + _IconListItem* pItem = dynamic_cast<_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, index)); + if (pItem != null) + { + pItem->SetDrawingProperty(*__pItemDrawingProperty); + + TranslateIconListItemPosition(touchPressedPosition.x, touchPressedPosition.y); + if (touchPressedPosition.x >= 0 && touchPressedPosition.y >= 0) + { + __selectedOverlayBitmapId = pItem->GetOverlayBitmapIdFromPosition(touchPressedPosition); + } + } + + bool flag = __isTouchAnimationEnabled; + __isTouchAnimationEnabled = false; + + RedrawItem(index); + + if (flag) + { + __isTouchAnimationEnabled = true; + } + } + + } + + return true; +} + +bool +_IconListPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + ResetAnimationTimer(); + ResetSelectionAnimationTimer(); + ResetTouchActionTimer(); + ResetFlickAnimationTimer(); + ResetMagneticScrollTimer(); + ResetReorderScrollTimer(); + ResetCheckAnimationTimer(); + + __isTouchPressed = false; + ScrollFadeOut(); + + return true; +} + +bool +_IconListPresenter::OnFlickGestureDetected(bool isFlicked, const Point& flickPosition, int flickTime) +{ + if (isFlicked) + { + int velX = 0; + int velY = 0; + int moveX = 0; + int moveY = 0; + int scrollPosition = __pIconListView->GetScroll()->GetScrollPosition(); + if (flickTime < MINIMUM_FLICK_EFFECT_TIME) + { + flickTime = MINIMUM_FLICK_EFFECT_TIME; + } + + __flickAnimation.SetAlignInformation(__unitScrollLength, __unitScrollLength); + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL && flickPosition.y != 0) + { + __flickAnimation.CalculateInitializeVelocity(0, flickPosition.y, flickTime, &velX, &velY); + __flickAnimation.InitializeFlickAmount(velY); + __flickAnimation.CalculateNextMove(&moveX, &moveY); + scrollPosition -= moveY; + } + else if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_HORIZONTAL && flickPosition.x != 0) + { + __flickAnimation.CalculateInitializeVelocity(flickPosition.x, 0, flickTime, &velX, &velY); + __flickAnimation.InitializeFlickAmount(velX); + __flickAnimation.CalculateNextMove(&moveX, &moveY); + scrollPosition -= moveX; + } + + // 3-flicking move to top or bottom + if (__flickCount >= (NEEDED_FLICK_COUNT_FOR_FINGER_FASTSCROLL - 1)) + { + if ((__scrollPosition < scrollPosition) && __isFlickDown) + { + __flickCount = 0; + ResetAnimationTimer(); + ResetSelectionAnimationTimer(); + ResetTouchActionTimer(); + ResetMagneticScrollTimer(); + ResetFlickAnimationTimer(); + ResetCheckAnimationTimer(); + + __magneticScrollAnimation.StartAnimation(__scrollLength + OVERSCROLLING_MAX_DISTANCE - __scrollPosition); + StartMagneticScrollTimer(); + return true; + } + else if ((__scrollPosition > scrollPosition) && !__isFlickDown) + { + __flickCount = 0; + ResetAnimationTimer(); + ResetSelectionAnimationTimer(); + ResetTouchActionTimer(); + ResetMagneticScrollTimer(); + ResetFlickAnimationTimer(); + ResetCheckAnimationTimer(); + + __magneticScrollAnimation.StartAnimation((-1 * OVERSCROLLING_MAX_DISTANCE) - __scrollPosition); + StartMagneticScrollTimer(); + return true; + } + } + + int oldScrollPosition = __scrollPosition; + if (SetScrollPosition(scrollPosition)) + { + if (((oldScrollPosition < __scrollPosition) && __isFlickDown) || + ((oldScrollPosition > __scrollPosition) && !__isFlickDown)) + { + __flickCount++; + } + else + { + __flickCount = 1; + __isFlickDown = !__isFlickDown; + } + + ResetAnimationTimer(); + ResetSelectionAnimationTimer(); + ResetTouchActionTimer(); + ResetMagneticScrollTimer(); + ResetCheckAnimationTimer(); + StartFlickAnimationTimer(); + __pIconListView->Invalidate(); + + FireScrollPositionChangedEvent(__scrollPosition); + + return true; + } + } + return true; +} + +bool +_IconListPresenter::OnLongPressGestureDetected(void) +{ + return true; +} + +void +_IconListPresenter::OnTimerExpired(Timer& timer) +{ + if (&timer == __pSelectionAnimationTimer) + { + if (__isSelectionDelayed) + { + __isSelectionDelayed = false; + ProcessAfterTouchRelease(__selectedIndex); + } + else + { + float ratio = 0.0f; + if (__isTouchAnimationEnabled && __touchAnimation.GetTouchAnimationFrame(ratio)) + { + StartSelectionAnimationTimer(); + RedrawItem(__selectedIndex, ratio); + } + else + { + int index = __selectedIndex; + __selectedIndex = INVALID_INDEX; + RedrawItem(index); + + FireEventAfterTouchRelease(index); + } + } + } + else if (&timer == __pTouchActionTimer) + { + OnTouchActionActivated(*__pIconListView, __currentTouchInfo); + } + else if (&timer == __pFlickAnimationTimer) + { + StartFlickAnimation(); + } + else if (&timer == __pMagneticScrollTimer) + { + int scrollPosition = 0; + if (__magneticScrollAnimation.GetMagneticScrollAnimationFrame(scrollPosition)) + { + scrollPosition += __pIconListView->GetScroll()->GetScrollPosition(); + if (SetScrollPosition(scrollPosition)) + { + StartMagneticScrollTimer(); + __pIconListView->Invalidate(); + + FireScrollPositionChangedEvent(__scrollPosition); + } + } + else + { + ResetMagneticScrollTimer(); + + if (__pFlickAnimationTimer == null) + { + ScrollFadeOut(); + FireScrollEvent(); + FireScrollStoppedEvent(); + InitializeAccessibilityElement(); + } + } + } + else if (&timer == __pReorderScrollTimer) + { + StartReorderScrollAnimation(); + } + else if (&timer == __pAnimationTimer) + { + int index = __animationItemIndex; + ResetAnimationTimer(); + + // start add animation + _IconListItem* pItem = dynamic_cast <_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, index)); + SysTryReturnVoidResult(NID_UI_CTRL, (pItem != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + AddAnimation(*pItem, index); + } + else if (&timer == __pCheckAnimationTimer) + { + float ratio = 0.0f; + if ((__checkedIndex >= 0) && __checkAnimation.GetCheckAnimationFrame(ratio)) + { + StartCheckAnimationTimer(); + RedrawItem(__checkedIndex, 1.0f, false, ratio); + } + else + { + ResetCheckAnimationTimer(); + } + } +} + +void +_IconListPresenter::StartFlickAnimation(void) +{ + int moveX = 0; + int moveY = 0; + int movement = 0; + int scrollPosition = __pIconListView->GetScroll()->GetScrollPosition(); + + __flickAnimation.CalculateNextMove(&moveX, &moveY); + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + scrollPosition -= moveY; + movement = moveY; + } + else + { + scrollPosition -= moveX; + movement = moveX; + } + + if (SetScrollPosition(scrollPosition)) + { + if ((scrollPosition <= (OVERSCROLLING_MAX_DISTANCE * -1)) || + (scrollPosition >= (__scrollLength + OVERSCROLLING_MAX_DISTANCE)) || + ((movement <= 1) && (movement >= -1))) + { + ResetFlickAnimationTimer(); + __flickCount = 0; + + if (__magneticScrollSize > 0) + { + __magneticScrollAnimation.StartAnimation(GetMagneticScrollPosition() - __scrollPosition); + StartMagneticScrollTimer(); + } + else + { + ScrollFadeOut(); + + // Trigger ScrollEvent + FireScrollEvent(); + FireScrollStoppedEvent(); + } + } + else + { + StartFlickAnimationTimer(); + + __pIconListView->Invalidate(); + FireScrollPositionChangedEvent(__scrollPosition); + } + } +} + +void +_IconListPresenter::StartReorderScrollAnimation(void) +{ + + int scrollPosition = __scrollPosition; + scrollPosition += __reorderScrollAnimationDistance; + + if (SetScrollPosition(scrollPosition)) + { + __pIconListView->Invalidate(); + FireScrollPositionChangedEvent(__scrollPosition); + + if (__scrollPosition > 0 && __scrollPosition < __scrollLength) + { + StartReorderScrollTimer(); + } + } +} + +void +_IconListPresenter::OnVisibleStateChanged(void) +{ + ResetAnimationTimer(); + ResetSelectionAnimationTimer(); + ResetFlickAnimationTimer(); + ResetTouchActionTimer(); + ResetMagneticScrollTimer(); + ResetReorderScrollTimer(); + ResetCheckAnimationTimer(); +} + +// Tizen::Ui::_IScrollEventListener +void +_IconListPresenter::OnScrollEndReached(_Control& source, ScrollEndEvent type) +{ + ScrollFadeOut(); + FireScrollEndReachedEvent(type); +} + +void +_IconListPresenter::OnScrollPositionChanged(_Control& source, int scrollPos) +{ + if (__pFlickAnimationTimer != null) + { + ResetFlickAnimationTimer(); + } + + if (SetScrollPosition(scrollPos)) + { + __flickCount = 0; + __selectedIndex = INVALID_INDEX; + __pIconListView->Invalidate(); + + ScrollFadeOut(); + FireScrollEvent(); + } +} + +void +_IconListPresenter::OnScrollStopped(_Control& source) +{ + FireScrollStoppedEvent(); + InitializeAccessibilityElement(); +} + +// Tizen::Ui::Animations::IAnimationTransactionEventListener +void +_IconListPresenter::OnAnimationTransactionStarted(int transactionId) +{ +} + +void +_IconListPresenter::OnAnimationTransactionStopped(int transactionId) +{ + if (__addTransactionId == transactionId) + { + __addTransactionId = 0; + } + else if (__removeTransactionId == transactionId) + { + __removeTransactionId = 0; + + if (__pRemoveItemVE != null) + { + _VisualElement* pParent = __pIconListView->GetVisualElement(); + if (pParent != null) + { + pParent->DetachChild(*__pRemoveItemVE); + } + __pRemoveItemVE->Destroy(); + __pRemoveItemVE = null; + } + + } + else if (__moveTransactionId == transactionId) + { + __moveTransactionId = 0; + } + + ClearVisualElement(); + + if (__pIconListView != null) + { + __pIconListView->Invalidate(); + } +} + +void +_IconListPresenter::OnAnimationTransactionFinished(int transactionId) +{ + if (__addTransactionId == transactionId) + { + __addTransactionId = 0; + } + else if (__removeTransactionId == transactionId) + { + __removeTransactionId = 0; + + if (__pRemoveItemVE != null) + { + _VisualElement* pParent = __pIconListView->GetVisualElement(); + if (pParent != null) + { + pParent->DetachChild(*__pRemoveItemVE); + } + __pRemoveItemVE->Destroy(); + __pRemoveItemVE = null; + } + } + else if (__moveTransactionId == transactionId) + { + __moveTransactionId = 0; + } +} + +void +_IconListPresenter::PrepareReordering(void) +{ + int index = GetItemIndexFromPosition(__lastReorderedPosition); + if (__onReordering || index == INVALID_INDEX) + { + return; + } + + __onReordering = true; + __reorderFromIndex = index; + __reorderToIndex = index; + + if (__pListModel->IsValidItem(DEFAULT_GROUP_INDEX, __reorderToIndex)) + { + _IconListItem* pToItem = static_cast <_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, __reorderToIndex)); + if (pToItem != null) + { + _VisualElement* pItemVE = pToItem->GetItemVisualElement(); + if (pItemVE != null) + { + __reorderItemBounds = pItemVE->GetBounds(); + pItemVE->SetImplicitAnimationEnabled(false); + RedrawItem(__reorderToIndex); + } + } + else + { + ClearReorderingInformation(); + } + } + else + { + ClearReorderingInformation(); + } +} + +void +_IconListPresenter::DoReordering(const Point& movedPosition) +{ + if (__pListModel->IsValidItem(DEFAULT_GROUP_INDEX, __reorderToIndex)) + { + _IconListItem* pToItem = static_cast <_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, __reorderToIndex)); + if (pToItem != null) + { + _VisualElement* pItemVE = pToItem->GetItemVisualElement(); + if (pItemVE != null) + { + FloatRectangle rect = pItemVE->GetBounds(); + pItemVE->SetShowState(true); + pItemVE->SetImplicitAnimationEnabled(false); + pItemVE->SetBounds(FloatRectangle(movedPosition.x - __lastReorderedDifferences.x, movedPosition.y - __lastReorderedDifferences.y, rect.width, rect.height)); + + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + if (movedPosition.y < __topMargin) + { + __reorderScrollAnimationDistance = -REORDER_SCROLL_ANIMATION_DISTANCE; + if (__pReorderScrollTimer == null && __scrollPosition > 0) + { + __scrollPositionBeforeScrollAnimation = __scrollPosition; + StartReorderScrollTimer(); + } + } + else if ((movedPosition.y + __lastReorderedDifferences.y) > __pIconListView->GetBounds().height - __bottomMargin && __scrollPosition < __scrollLength) + { + __reorderScrollAnimationDistance = REORDER_SCROLL_ANIMATION_DISTANCE; + if (__pReorderScrollTimer == null) + { + __scrollPositionBeforeScrollAnimation = __scrollPosition; + StartReorderScrollTimer(); + } + } + else + { + if (__pReorderScrollTimer == null) + { + CheckAndReorderItem(movedPosition.x - __lastReorderedPosition.x, movedPosition.y - __lastReorderedPosition.y); + } + else + { + ResetReorderScrollTimer(); + int diff = __scrollPositionBeforeScrollAnimation - __scrollPosition; + int rowCount = diff / __unitScrollLength; + int index = __reorderToIndex - rowCount * __itemCountPerAxis; + __reorderItemBounds.y += diff; + SwapReorderedItems(index, false); + __lastReorderedPosition.y += rowCount * __itemCountPerAxis - __verticalSpacing; + } + } + } + else + { + if (movedPosition.x < __leftMargin && __scrollPosition > 0) + { + __reorderScrollAnimationDistance = -REORDER_SCROLL_ANIMATION_DISTANCE; + if (__pReorderScrollTimer == null) + { + __scrollPositionBeforeScrollAnimation = __scrollPosition; + StartReorderScrollTimer(); + } + } + else if ((movedPosition.x + __lastReorderedDifferences.x) > __pIconListView->GetBounds().width - __rightMargin && __scrollPosition < __scrollLength) + { + __reorderScrollAnimationDistance = REORDER_SCROLL_ANIMATION_DISTANCE; + if (__pReorderScrollTimer == null) + { + __scrollPositionBeforeScrollAnimation = __scrollPosition; + StartReorderScrollTimer(); + } + } + else + { + if (__pReorderScrollTimer == null) + { + CheckAndReorderItem(movedPosition.x - __lastReorderedPosition.x, movedPosition.y - __lastReorderedPosition.y); + } + else + { + ResetReorderScrollTimer(); + int diff = __scrollPositionBeforeScrollAnimation - __scrollPosition; + int rowCount = diff / __unitScrollLength; + int index = __reorderToIndex - rowCount * __itemCountPerAxis; + __reorderItemBounds.x += diff; + SwapReorderedItems(index, false); + __lastReorderedPosition.x += rowCount * __itemCountPerAxis - __horizontalSpacing; + } + } + } + } + } + } +} + +void +_IconListPresenter::CheckAndReorderItem(int movedX, int movedY) +{ + bool toUp = false; + bool toDown = false; + bool toLeft = false; + bool toRight = false; + + bool singleItemChanged = true; + + int horizontalThreshold = (GetItemSize().width + __verticalSpacing) / 2; + int verticalThreshold = (GetItemSize().height + __verticalSpacing) / 2; + + if (Math::Abs(movedX) > horizontalThreshold) + { + if (movedX > 0) + { + toRight = true; + } + else + { + toLeft = true; + } + } + + if (Math::Abs(movedY) > verticalThreshold) + { + if (movedY > 0) + { + toDown = true; + } + else + { + toUp = true; + } + } + + int toIndex = INVALID_INDEX; + + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + if (toLeft) + { + if (__reorderToIndex % __itemCountPerAxis != 0) + { + toIndex = __reorderToIndex - 1; + __lastReorderedPosition.x -= __unitLengthOfAxis; + } + } + else if (toRight) + { + if (__reorderToIndex % __itemCountPerAxis != __itemCountPerAxis - 1) + { + toIndex = __reorderToIndex + 1; + __lastReorderedPosition.x += __unitLengthOfAxis; + } + } + else if (toUp) + { + if (__reorderToIndex >= __itemCountPerAxis) + { + toIndex = __reorderToIndex - __itemCountPerAxis; + __lastReorderedPosition.y -= __unitScrollLength; + + singleItemChanged = false; + } + } + else if (toDown) + { + if (__reorderToIndex + __itemCountPerAxis < __pListModel->GetAllItemCount()) + { + toIndex = __reorderToIndex +__itemCountPerAxis; + __lastReorderedPosition.y += __unitScrollLength; + + singleItemChanged = false; + } + } + } + else + { + if (toUp) + { + if (__reorderToIndex % __itemCountPerAxis != 0) + { + toIndex = __reorderToIndex - 1; + __lastReorderedPosition.y -= __unitLengthOfAxis; + } + } + else if (toDown) + { + if (__reorderToIndex % __itemCountPerAxis != __itemCountPerAxis - 1) + { + toIndex = __reorderToIndex + 1; + __lastReorderedPosition.y += __unitLengthOfAxis; + } + } + else if (toLeft) + { + if (__reorderToIndex >= __itemCountPerAxis) + { + toIndex = __reorderToIndex - __itemCountPerAxis; + __lastReorderedPosition.x -= __unitScrollLength; + + singleItemChanged = false; + } + } + else if (toRight) + { + if (__reorderToIndex + __itemCountPerAxis < __pListModel->GetAllItemCount()) + { + toIndex = __reorderToIndex +__itemCountPerAxis; + __lastReorderedPosition.x += __unitScrollLength; + + singleItemChanged = false; + } + } + } + + if (toIndex != INVALID_INDEX) + { + SwapReorderedItems(toIndex, singleItemChanged); + } +} + +void +_IconListPresenter::SwapReorderedItems(int toIndex, bool singleItemChanged) +{ + if (toIndex < 0) + { + return; + } + else if (toIndex >= __pListModel->GetAllItemCount()) + { + toIndex -= __itemCountPerAxis; + } + + _ListItemPos from = { DEFAULT_GROUP_INDEX, __reorderToIndex }; + _ListItemPos to = { DEFAULT_GROUP_INDEX, toIndex }; + _IconListItem* pItem = null; + _IconListItem* pTempItem = null; + _VisualElement* pToItemVE = null; + _VisualElement* pToTempItemVE = null; + FloatRectangle tempBounds; + + if (singleItemChanged) + { + pItem = static_cast<_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, toIndex)); + if (pItem != null) + { + pToItemVE = pItem->GetItemVisualElement(); + } + if (pToItemVE != null) + { + FloatRectangle bounds = pToItemVE->GetBounds(); + if (bounds.IsEmpty()) + { + Rectangle rect = GetItemBounds(toIndex); + bounds.SetPosition(rect.x, rect.y); + bounds.SetSize(rect.width, rect.height); + + pToItemVE->SetImplicitAnimationEnabled(false); + pToItemVE->SetBounds(bounds); + } + + FloatRectangle temp = __reorderItemBounds; + __reorderItemBounds.SetPosition(bounds.x, bounds.y); + pToItemVE->SetImplicitAnimationEnabled(true); + pToItemVE->SetBounds(temp); + pToItemVE->SetImplicitAnimationEnabled(false); + } + } + else + { + if (__reorderToIndex > toIndex) + { + for (int i = toIndex; i < __reorderToIndex; i++) + { + pItem = static_cast<_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, i)); + pTempItem = static_cast<_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, i + 1)); + if (pItem != null && pTempItem != null) + { + pToItemVE = pItem->GetItemVisualElement(); + pToTempItemVE = pTempItem->GetItemVisualElement(); + } + + if (pToItemVE != null && pToTempItemVE != null) + { + FloatRectangle temp = pToTempItemVE->GetBounds(); + if (temp.IsEmpty()) + { + Rectangle rect = GetItemBounds(i + 1); + temp.SetPosition(rect.x, rect.y); + temp.SetSize(rect.width, rect.height); + + pToTempItemVE->SetImplicitAnimationEnabled(false); + pToTempItemVE->SetBounds(temp); + } + + if (i == toIndex) + { + tempBounds = pToItemVE->GetBounds(); + if (tempBounds.IsEmpty()) + { + Rectangle rect = GetItemBounds(toIndex); + tempBounds.SetPosition(rect.x, rect.y); + tempBounds.SetSize(rect.width, rect.height); + + pToItemVE->SetImplicitAnimationEnabled(false); + pToItemVE->SetBounds(tempBounds); + } + } + else if (i == __reorderToIndex -1) + { + temp = __reorderItemBounds; + __reorderItemBounds.SetPosition(tempBounds.x, tempBounds.y); + } + pToItemVE->SetImplicitAnimationEnabled(true); + pToItemVE->SetBounds(temp); + pToItemVE->SetImplicitAnimationEnabled(false); + } + } + } + else + { + for (int i = toIndex; i > __reorderToIndex; i--) + { + pItem = static_cast<_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, i)); + pTempItem = static_cast<_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, i - 1)); + if (pItem != null && pTempItem != null) + { + pToItemVE = pItem->GetItemVisualElement(); + pToTempItemVE = pTempItem->GetItemVisualElement(); + } + + if (pToItemVE != null && pToTempItemVE != null) + { + FloatRectangle temp = pToTempItemVE->GetBounds(); + if (temp.IsEmpty()) + { + Rectangle rect = GetItemBounds(i - 1); + temp.SetPosition(rect.x, rect.y); + temp.SetSize(rect.width, rect.height); + + pToTempItemVE->SetImplicitAnimationEnabled(false); + pToTempItemVE->SetBounds(temp); + } + + if (i == toIndex) + { + tempBounds = pToItemVE->GetBounds(); + if (tempBounds.IsEmpty()) + { + Rectangle rect = GetItemBounds(toIndex); + tempBounds.SetPosition(rect.x, rect.y); + tempBounds.SetSize(rect.width, rect.height); + + pToItemVE->SetImplicitAnimationEnabled(false); + pToItemVE->SetBounds(tempBounds); + } + } + else if (i == __reorderToIndex + 1) + { + temp = __reorderItemBounds; + __reorderItemBounds.SetPosition(tempBounds.x, tempBounds.y); + } + + pToItemVE->SetImplicitAnimationEnabled(true); + pToItemVE->SetBounds(temp); + pToItemVE->SetImplicitAnimationEnabled(false); + } + } + } + } + + __pListModel->MoveItem(from, to); + __reorderToIndex = toIndex; +} + +void +_IconListPresenter::FinishReordering(void) +{ + if (__pListModel->IsValidItem(DEFAULT_GROUP_INDEX, __reorderToIndex)) + { + if (__reorderFromIndex != __reorderToIndex) + { + FireIconListViewItemEvent(EVENT_TYPE_ITEM_REORDERED , __reorderFromIndex, __reorderToIndex); + for (int i = Math::Min(__reorderFromIndex, __reorderToIndex); i <= Math::Max(__reorderFromIndex, __reorderToIndex); i++) + { + RedrawItem(i); + } + } + else + { + RedrawItem(__reorderToIndex); + } + } + ResetReorderScrollTimer(); + ClearReorderingInformation(); +} + +void +_IconListPresenter::ClearReorderingInformation(void) +{ + __onReordering = false; + __reorderFromIndex = INVALID_INDEX; + __reorderToIndex = INVALID_INDEX; + __reorderItemBounds.SetBounds(0, 0, 0, 0); +} + +// visual interaction animation +void +_IconListPresenter::AddAnimation(_IconListItem& item, int index, int delay) +{ + _VisualElement* pVE = item.GetItemVisualElement(); + if (pVE != null) + { + pVE->SetImplicitAnimationEnabled(false); + + Rectangle rect = GetItemBounds(index); + FloatRectangle endRect(rect.x, rect.y, rect.width, rect.height); + FloatRectangle startRect = FloatRectangle(endRect.x + (endRect.width * 0.15f), endRect.y + (endRect.height * 0.15f), endRect.width * 0.7f, endRect.height * 0.7f); + + pVE->SetBounds(endRect); + + if (IsAnimationRunning(__addTransactionId)) + { + AnimationTransaction::Stop(__addTransactionId); + } + + AnimationTransaction::Begin(__addTransactionId); + + // opacity animation + VisualElementPropertyAnimation* pOpacityAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturnVoidResult(NID_UI_CTRL, (pOpacityAnimation != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pOpacityAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut")); + pOpacityAnimation->SetPropertyName(L"opacity"); + pOpacityAnimation->SetStartValue(Variant(0.0f)); + pOpacityAnimation->SetEndValue(Variant(1.0f)); + pOpacityAnimation->SetDuration(ITEM_ANIMATION_DURATION); + pOpacityAnimation->SetDelay(delay); + + String opacityAnimationName(L"AddItemOpacityAnimation"); + pVE->AddAnimation(opacityAnimationName, *pOpacityAnimation); + delete pOpacityAnimation; + + // scale animation + VisualElementPropertyAnimation* pScaleAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturnVoidResult(NID_UI_CTRL, (pScaleAnimation != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pScaleAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut")); + pScaleAnimation->SetPropertyName(L"bounds"); + pScaleAnimation->SetStartValue(Variant(startRect)); + pScaleAnimation->SetEndValue(Variant(endRect)); + pScaleAnimation->SetDuration(ITEM_ANIMATION_DURATION); + pScaleAnimation->SetDelay(delay); + + String scaleAnimationName(L"AddItemScaleAnimation"); + pVE->AddAnimation(scaleAnimationName, *pScaleAnimation); + delete pScaleAnimation; + + pVE->SetImplicitAnimationEnabled(true); + item.DrawItem(rect, LIST_ITEM_STATE_NORMAL); + pVE->SetImplicitAnimationEnabled(false); + + AnimationTransaction::Commit(); + } +} + +void +_IconListPresenter::RemoveAnimation(_IconListItem& item, int index) +{ + result r = E_SUCCESS; + Canvas* pCanvas = null; + _VisualElement* pItemVE = item.GetItemVisualElement(); + if (pItemVE != null) + { + if (__pRemoveItemVE != null) + { + __pRemoveItemVE->Destroy(); + __pRemoveItemVE = null; + } + + FloatRectangle startRect = pItemVE->GetBounds(); + FloatRectangle endRect = FloatRectangle(startRect.x + (startRect.width * 0.1f), startRect.y + (startRect.height * 0.1f), startRect.width * 0.8f, startRect.height * 0.8f); + + __pRemoveItemVE = new (std::nothrow) _VisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, __pRemoveItemVE != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pRemoveItemVE->Construct(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pRemoveItemVE->SetSurfaceOpaque(false); + __pRemoveItemVE->SetShowState(true); + __pRemoveItemVE->SetImplicitAnimationEnabled(false); + + r = __pRemoveItemVE->SetBounds(startRect); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + _VisualElement* pParent = __pIconListView->GetVisualElement(); + pParent->AttachChild(*__pRemoveItemVE); + + pCanvas = __pRemoveItemVE->GetCanvasN(); + SysTryCatch(NID_UI_CTRL, (pCanvas != null), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas->Clear(); + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + r = pItemVE->Capture(*pCanvas, FloatRectangle(0, 0, startRect.width, startRect.height), false); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + delete pCanvas; + + if (IsAnimationRunning(__removeTransactionId)) + { + AnimationTransaction::Stop(__removeTransactionId); + } + + AnimationTransaction::Begin(__removeTransactionId); + + // scale animation + VisualElementPropertyAnimation* pScaleAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturnVoidResult(NID_UI_CTRL, (pScaleAnimation != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pScaleAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut")); + pScaleAnimation->SetPropertyName(L"bounds"); + pScaleAnimation->SetStartValue(Variant(startRect)); + pScaleAnimation->SetEndValue(Variant(endRect)); + pScaleAnimation->SetDuration(ITEM_ANIMATION_DURATION); + + String scaleAnimationName(L"RemoveItemScaleAnimation"); + __pRemoveItemVE->AddAnimation(scaleAnimationName, *pScaleAnimation); + delete pScaleAnimation; + + // opacity animation + VisualElementPropertyAnimation* pOpacityAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturnVoidResult(NID_UI_CTRL, (pOpacityAnimation != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pOpacityAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut")); + pOpacityAnimation->SetPropertyName(L"opacity"); + pOpacityAnimation->SetStartValue(Variant(1.0f)); + pOpacityAnimation->SetEndValue(Variant(0.0f)); + pOpacityAnimation->SetDuration(ITEM_ANIMATION_DURATION); + + String opacityAnimationName(L"RemoveItemOpacityAnimation"); + __pRemoveItemVE->AddAnimation(opacityAnimationName, *pOpacityAnimation); + delete pOpacityAnimation; + + AnimationTransaction::Commit(); + } + + return; +CATCH: + delete pCanvas; +} + +void +_IconListPresenter::MoveAnimation(_IconListItem& item, FloatRectangle& bounds, int delay) +{ + _VisualElement* pVE = item.GetItemVisualElement(); + if (pVE != null) + { + pVE->SetImplicitAnimationEnabled(false); + pVE->SetShowState(true); + + // move animation + VisualElementPropertyAnimation* pMoveAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturnVoidResult(NID_UI_CTRL, (pMoveAnimation != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + FloatRectangle startRect = pVE->GetBounds(); + + pMoveAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut")); + pMoveAnimation->SetPropertyName(L"bounds"); + pMoveAnimation->SetStartValue(Variant(startRect)); + pMoveAnimation->SetEndValue(Variant(bounds)); + pMoveAnimation->SetDuration(MOVE_ITEM_ANIMATION_DURATION); + pMoveAnimation->SetDelay(delay); + + String moveAnimationName(L"MoveItemAnimation"); + pVE->AddAnimation(moveAnimationName, *pMoveAnimation); + delete pMoveAnimation; + } +} + +void +_IconListPresenter::MoveAnimation(_IconListItem& item, FloatRectangle& startBounds, FloatRectangle& endBounds, int delay) +{ + _VisualElement* pVE = item.GetItemVisualElement(); + if (pVE != null) + { + pVE->SetImplicitAnimationEnabled(false); + pVE->SetShowState(true); + + // move animation + VisualElementPropertyAnimation* pMoveAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturnVoidResult(NID_UI_CTRL, (pMoveAnimation != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + FloatRectangle startRect = pVE->GetBounds(); + + pMoveAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut")); + pMoveAnimation->SetPropertyName(L"bounds"); + pMoveAnimation->SetStartValue(Variant(startBounds)); + pMoveAnimation->SetEndValue(Variant(endBounds)); + pMoveAnimation->SetDuration(MOVE_ITEM_ANIMATION_DURATION); + pMoveAnimation->SetDelay(delay); + + String moveAnimationName(L"MoveItemAnimation"); + pVE->AddAnimation(moveAnimationName, *pMoveAnimation); + delete pMoveAnimation; + } + +} + +void +_IconListPresenter::MoveAnimation(_IconListItem& item, FloatRectangle& bounds, int delay, bool fadeIn) +{ + _VisualElement* pVE = item.GetItemVisualElement(); + if (pVE != null) + { + pVE->SetImplicitAnimationEnabled(false); + + // opacity animation + VisualElementPropertyAnimation* pOpacityAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturnVoidResult(NID_UI_CTRL, (pOpacityAnimation != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pOpacityAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut")); + pOpacityAnimation->SetPropertyName(L"opacity"); + + if (fadeIn) + { + pOpacityAnimation->SetStartValue(Variant(0.0f)); + pOpacityAnimation->SetEndValue(Variant(1.0f)); + } + else + { + pOpacityAnimation->SetStartValue(Variant(1.0f)); + pOpacityAnimation->SetEndValue(Variant(0.0f)); + } + + pOpacityAnimation->SetDuration(MOVE_ITEM_ANIMATION_DURATION); + + String opacityAnimationName(L"MoveItemOpacityAnimation"); + pVE->AddAnimation(opacityAnimationName, *pOpacityAnimation); + delete pOpacityAnimation; + + // move animation + VisualElementPropertyAnimation* pMoveAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturnVoidResult(NID_UI_CTRL, (pMoveAnimation != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + FloatRectangle startRect = pVE->GetBounds(); + + pMoveAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseInOut")); + pMoveAnimation->SetPropertyName(L"bounds"); + pMoveAnimation->SetStartValue(Variant(startRect)); + pMoveAnimation->SetEndValue(Variant(bounds)); + pMoveAnimation->SetDuration(MOVE_ITEM_ANIMATION_DURATION); + pMoveAnimation->SetDelay(delay); + + String moveAnimationName(L"MoveItemAnimation"); + pVE->AddAnimation(moveAnimationName, *pMoveAnimation); + delete pMoveAnimation; + } +} + +void +_IconListPresenter::RemoveAllAnimation(_IconListItem& item) +{ + _VisualElement* pVE = item.GetItemVisualElement(); + if (pVE != null) + { + pVE->RemoveAllAnimations(); + } +} + +void +_IconListPresenter::MoveForward(int index) +{ + int itemCount = __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX); + if (index < 0 || index >= itemCount) + { + return; + } + + int bottomLine = 0; + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + int bottomPosition = __scrollPosition + __pIconListView->GetBounds().height; + bottomLine = (bottomPosition - __topMargin + __verticalSpacing) / __unitScrollLength; + } + else + { + int bottomPosition = __scrollPosition + __pIconListView->GetBounds().width; + bottomLine = (bottomPosition - __leftMargin + __horizontalSpacing) / __unitScrollLength; + } + + int startIndex = index; + int endIndex = (bottomLine + 1) * __itemCountPerAxis; + endIndex = endIndex >= itemCount ? itemCount - 1 : endIndex; + if (startIndex > endIndex) + { + return; + } + + // move forward + _IconListItem* pItem = null; + _VisualElement* pItemVE = null; + + if (IsAnimationRunning(__moveTransactionId)) + { + AnimationTransaction::Stop(__moveTransactionId); + } + + AnimationTransaction::Begin(__moveTransactionId); + + Rectangle startRect; + Rectangle endRect; + for (int i = startIndex; i <= endIndex; i++) + { + startRect = GetItemBounds(i); + endRect = GetItemBounds(i - 1); + if (!endRect.IsEmpty() && !startRect.IsEmpty()) + { + pItem = static_cast<_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, i)); + if (pItem != null) + { + pItemVE = pItem->GetItemVisualElement(); + if (pItemVE != null) + { + FloatRectangle originalBounds(startRect.x, startRect.y, startRect.width, startRect.height); + FloatRectangle moveToBounds(endRect.x, endRect.y, endRect.width, endRect.height); + MoveAnimation(*pItem, originalBounds, moveToBounds, ITEM_ANIMATION_DELAY); + } + } + } + } + + AnimationTransaction::Commit(); +} + +void +_IconListPresenter::MoveBackward(int index) +{ + int itemCount = __pListModel->GetItemCountInGroup(DEFAULT_GROUP_INDEX); + if (index < 0 || index >= itemCount) + { + return; + } + + int bottomLine = 0; + if (__scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL) + { + int bottomPosition = __scrollPosition + __pIconListView->GetBounds().height; + bottomLine = (bottomPosition - __topMargin + __verticalSpacing) / __unitScrollLength; + } + else + { + int bottomPosition = __scrollPosition + __pIconListView->GetBounds().width; + bottomLine = (bottomPosition - __leftMargin + __horizontalSpacing) / __unitScrollLength; + } + + int endIndex = index; + int startIndex = (bottomLine + 1) * __itemCountPerAxis; + startIndex = startIndex >= itemCount ? itemCount - 1 : startIndex; + + if (startIndex < endIndex) + { + return; + } + + // move backward + _IconListItem* pItem = null; + _VisualElement* pItemVE = null; + + if (IsAnimationRunning(__moveTransactionId)) + { + AnimationTransaction::Stop(__moveTransactionId); + } + + AnimationTransaction::Begin(__moveTransactionId); + + Rectangle startRect; + Rectangle endRect; + for (int i = startIndex; i >= endIndex; i--) + { + startRect = GetItemBounds(i); + endRect = GetItemBounds(i + 1); + if (!startRect.IsEmpty() && !endRect.IsEmpty()) + { + pItem = static_cast<_IconListItem*>(__pListModel->LoadItem(DEFAULT_GROUP_INDEX, i)); + if (pItem != null) + { + pItemVE = pItem->GetItemVisualElement(); + if (pItemVE != null) + { + FloatRectangle originalBounds(startRect.x, startRect.y, startRect.width, startRect.height); + FloatRectangle moveToBounds(endRect.x, endRect.y, endRect.width, endRect.height); + MoveAnimation(*pItem, originalBounds, moveToBounds, 0); + } + } + } + } + + AnimationTransaction::Commit(); + +} + +bool +_IconListPresenter::IsAnimationRunning(int transactionId) +{ + if (AnimationTransaction::GetStatus(transactionId) == ANIMATION_TRANSACTION_STATUS_PLAYING) + { + return true; + } + + return false; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IconListUtils.cpp b/src/ui/controls/FUiCtrl_IconListUtils.cpp new file mode 100644 index 0000000..1b8cf01 --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListUtils.cpp @@ -0,0 +1,189 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListUtils.cpp + * @brief This is the implementation file for the _IconListUtils. + */ + +#include "FUiCtrl_IconListUtils.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +namespace _IconListUtils +{ + +const float TouchAnimation::FRAME_RATIO[TouchAnimation::FRAME_COUNT] = +{0.9375, 0.875, 0.8125, 0.75, 0.6875, 0.625, 0.5625, 0.5, 0.5625, 0.625, 0.6875, 0.75, 0.8125, 0.875, 0.9375, 1.0}; + +TouchAnimation::TouchAnimation(void) + : __frame(0) +{ + +} + +TouchAnimation::~TouchAnimation(void) +{ + +} + +bool +TouchAnimation::GetTouchAnimationFrame(float& ratio) +{ + ratio = FRAME_RATIO[__frame++]; + if (__frame >= FRAME_COUNT) + { + __frame = FRAME_COUNT - 1; + return false; + } + return true; +} + +float +TouchAnimation::GetCurrentAnimationFrame(void) const +{ + return FRAME_RATIO[__frame]; +} + +void +TouchAnimation::StartAnimation(void) +{ + __frame = 0; +} + +MagneticScrollAnimation::MagneticScrollAnimation(void) + : __scroll(0) +{ + +} + +MagneticScrollAnimation::~MagneticScrollAnimation(void) +{ + +} + +bool +MagneticScrollAnimation::GetMagneticScrollAnimationFrame(int& dif) +{ + if (__scroll == 0) + { + dif = 0; + return false; + } + else if (__scroll > 0) + { + dif = (__scroll - 1) / MAGNETIC_SCROLL_EFFECT_DIVIDER + 1; + } + else + { + dif = (__scroll + 1) / MAGNETIC_SCROLL_EFFECT_DIVIDER - 1; + } + + __scroll -= dif; + return true; +} + +void +MagneticScrollAnimation::StartAnimation(int scroll) +{ + __scroll = scroll; +} + +CheckAnimation::CheckAnimation(void) + : __frame(0) +{ +} + +CheckAnimation::~CheckAnimation(void) +{ +} + +bool +CheckAnimation::GetCheckAnimationFrame(float& ratio) +{ + __frame++; + ratio = (float)__frame / (float)FRAME_COUNT; + + if (__frame >= FRAME_COUNT) + { + return false; + } + + return true; +} + +float +CheckAnimation::GetCurrentAnimationFrame(void) const +{ + float frame = (float)__frame; + if (__frame <= 0) + { + frame = 1.0f; + } + + return frame / (float)FRAME_COUNT; +} + +void +CheckAnimation::StartAnimation(void) +{ + __frame = 0; +} + +ListItemState +EnumConverter::ConvertIconListViewItemDrawingStatusToListItemState(IconListViewItemDrawingStatus status) +{ + switch (status) + { + case ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL: + return LIST_ITEM_STATE_NORMAL; + + case ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED: + return LIST_ITEM_STATE_PRESSED; + + case ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED: + return LIST_ITEM_STATE_HIGHLIGHTED; + } + + return LIST_ITEM_STATE_NORMAL; +} + +IconListViewItemDrawingStatus +EnumConverter::ConvertListItemStateToIconListViewItemDrawingStatus(ListItemState state) +{ + switch (state) + { + case LIST_ITEM_STATE_NORMAL: + return ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL; + + case LIST_ITEM_STATE_PRESSED: + return ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED; + + case LIST_ITEM_STATE_HIGHLIGHTED: + return ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED; + + default: + return ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL; + } + + return ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL; +} + +} // Tizen::Ui::Controls::_IconListUtils + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IconListView.cpp b/src/ui/controls/FUiCtrl_IconListView.cpp new file mode 100644 index 0000000..59a0eaa --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListView.cpp @@ -0,0 +1,1236 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListView.cpp + * @brief This is the implementation file for the _IconListView class. + */ + +//Includes +#include +#include +#include + +#include "FUi_AccessibilityContainer.h" +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_IconListItem.h" +#include "FUiCtrl_IconListPresenter.h" +#include "FUiCtrl_IconListView.h" +#include "FUiCtrl_IconListViewItemEventArg.h" +#include "FUiCtrl_IIconListItemEventListener.h" +#include "FUiCtrl_IScrollEventListener.h" +#include "FUiCtrl_UiIconListItemEvent.h" +#include "FUiCtrl_UiScrollEvent.h" +#include "FUiCtrl_UiScrollEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_IconListView); + +_IconListView::_IconListView(void) + : _Control() + , __pIconListPresenter(null) + , __pScroll(null) + , __pIconListItemEvent(null) + , __pScrollEvent(null) + , __pGestureFlick(null) + , __pGestureLongPress(null) + , __style(ICON_LIST_VIEW_STYLE_NORMAL) + , __scrollStyle(ICON_LIST_SCROLL_STYLE_FADE_OUT) + , __pBackgroundBitmap(null) + , __textOfEmptyList(L"") + , __textColorOfEmptyList(0) + , __textSizeOfEmptyList(0) + , __pBitmapOfEmptyList(null) + , __reorderEnabled(false) +{ + SetControlDelegate(*this); + AddPropertyChangeEventListener(*this); + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer != null) + { + pContainer->Activate(true); + } +} + +_IconListView::~_IconListView(void) +{ + Dispose(); +} + +result +_IconListView::Dispose(void) +{ + AnimationTransaction::SetTransactionEventListener(null); + + delete __pIconListPresenter; + __pIconListPresenter = null; + + delete __pBackgroundBitmap; + __pBackgroundBitmap = null; + + delete __pBitmapOfEmptyList; + __pBitmapOfEmptyList = null; + + if (__pIconListItemEvent != null) + { + delete __pIconListItemEvent; + __pIconListItemEvent = null; + } + + if (__pScrollEvent != null) + { + delete __pScrollEvent; + __pScrollEvent = null; + } + + if (__pScroll != null) + { + DetachSystemChild(*__pScroll); + delete __pScroll; + __pScroll = null; + } + + if (__pGestureFlick != null) + { + _ITouchFlickGestureEventListener* pListener = dynamic_cast<_ITouchFlickGestureEventListener*>(this); + __pGestureFlick->RemoveGestureListener(*pListener); + RemoveGestureDetector(*__pGestureFlick); + delete __pGestureFlick; + __pGestureFlick = null; + } + + if (__pGestureLongPress != null) + { + _ITouchLongPressGestureEventListener* pListener = dynamic_cast<_ITouchLongPressGestureEventListener*>(this); + __pGestureLongPress->RemoveGestureListener(*pListener); + RemoveGestureDetector(*__pGestureLongPress); + delete __pGestureLongPress; + __pGestureLongPress = null; + } + + return E_SUCCESS; +} + +_IconListView* +_IconListView::CreateIconListViewN(IconListViewStyle style) +{ + result r = E_SUCCESS; + _IconListView* pCore = null; + _IconListPresenter* pIconListPresenter = null; + + ClearLastResult(); + + // Create _IconListView + pCore = new (std::nothrow) _IconListView; + SysTryReturn(NID_UI_CTRL, (pCore != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pCore->AcquireHandle(); + + // Create _IconListPresenter + pIconListPresenter = _IconListPresenter::CreateInstanceN(*pCore); + SysTryCatch(NID_UI_CTRL, (pIconListPresenter != null), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + r = pCore->Initialize(*pIconListPresenter); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->SetStyle(style); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCore->__pGestureFlick = new (std::nothrow) _TouchFlickGestureDetector(); + + pCore->AddGestureDetector(*(pCore->__pGestureFlick)); + SysTryCatch(NID_UI_CTRL, (GetLastResult() == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has been occurred. AddGestureDetector failed."); + + r = pCore->__pGestureFlick->AddGestureListener(*pCore); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has been occurred. AddGestureListener failed."); + + pCore->__pGestureLongPress = new (std::nothrow) _TouchLongPressGestureDetector(); + pCore->AddGestureDetector(*(pCore->__pGestureLongPress)); + SysTryCatch(NID_UI_CTRL, (GetLastResult() == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has been occurred. AddGestureDetector failed."); + + r = pCore->__pGestureLongPress->AddGestureListener(*pCore); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has been occurred. AddGestureListener failed."); + + return pCore; + +CATCH: + delete pCore; + + return null; +} + +result +_IconListView::Initialize(_IconListPresenter& presenter) +{ + result r = E_SUCCESS; + Color color; + int textSize = 0; + + // Set _IconListPresenter + __pIconListPresenter = &presenter; + + // Check _VisualElement + SysTryCatch(NID_UI_CTRL, (GetVisualElement() != null), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Unable to initialize IconList."); + + // Create _UiIconListItemEvent + __pIconListItemEvent = new (std::nothrow) _UiIconListItemEvent; + SysTryCatch(NID_UI_CTRL, (__pIconListItemEvent != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pIconListItemEvent->Construct(*this); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Unable to construct Event."); + + // Create _UiScrollEvent + __pScrollEvent = new (std::nothrow) _UiScrollEvent; + SysTryCatch(NID_UI_CTRL, (__pScrollEvent != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pScrollEvent->Construct(*this); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Unable to construct Scroll Event."); + + SetBackgroundColor(Color(0, 0, 0, 0)); + + // Load emtpy content properties + GET_SHAPE_CONFIG(ICONLIST::EMPTY_FONT_SIZE, GetOrientation(), textSize); + SetTextSizeOfEmptyList(textSize); + + GET_COLOR_CONFIG(ICONLIST::EMPTY_TEXT_NORMAL, color); + SetTextColorOfEmptyList(color); + + SetTextOfEmptyList(L"Empty List"); + + // Set Touch move allowance config + SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_NORMAL); + + AnimationTransaction::SetTransactionEventListener(this); + + return r; + +CATCH: + Dispose(); + return r; +} + +result +_IconListView::SetItemProvider(const IIconListViewItemProvider& provider) +{ + return __pIconListPresenter->SetItemProvider(provider); +} + +result +_IconListView::RegisterItemProviderAdaptor(_IListItemProviderAdaptor* pItemProviderAdaptor) +{ + return __pIconListPresenter->RegisterItemProviderAdaptor(pItemProviderAdaptor); +} + +result +_IconListView::AddIconListItemEventListener(const _IIconListItemEventListener& listener) +{ + result r = __pIconListItemEvent->AddListener(listener); + if (r == E_OBJ_ALREADY_EXIST) + { + SysLogException(NID_UI_CTRL, (r = E_SYSTEM), "[E_SYSTEM] A system error has been occurred. The same instance already exists in the event listener list."); + } + return r; +} + +result +_IconListView::RemoveIconListItemEventListener(const _IIconListItemEventListener& listener) +{ + return __pIconListItemEvent->RemoveListener(listener); +} + +result +_IconListView::AddScrollEventListener(const _IScrollEventListener& listener) +{ + result r = __pScrollEvent->AddListener(listener); + if (r == E_OBJ_ALREADY_EXIST) + { + SysLogException(NID_UI_CTRL, (r = E_SYSTEM), "[E_SYSTEM] A system error has been occurred. The same instance already exists in the event listener list."); + } + return r; +} + +result +_IconListView::RemoveScrollEventListener(const _IScrollEventListener& listener) +{ + return __pScrollEvent->RemoveListener(listener); +} + +result +_IconListView::SetStyle(IconListViewStyle style) +{ + SysTryReturn(NID_UI_CTRL, (style >= ICON_LIST_VIEW_STYLE_NORMAL && style <= ICON_LIST_VIEW_STYLE_MARK), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] Invalid style is used."); + + __style = style; + __pIconListPresenter->SetUseCheckedStyle(__style == ICON_LIST_VIEW_STYLE_NORMAL ? false : true); + + return E_SUCCESS; +} + +IconListViewStyle +_IconListView::GetStyle(void) const +{ + return __style; +} + +result +_IconListView::SetScrollDirection(IconListViewScrollDirection scrollDirection) +{ + return __pIconListPresenter->SetScrollDirection(scrollDirection); +} + +result +_IconListView::SetScrollStyle(IconListViewScrollStyle scrollStyle) +{ + SysTryReturn(NID_UI_CTRL, scrollStyle >= ICON_LIST_SCROLL_STYLE_FADE_OUT && scrollStyle <= ICON_LIST_SCROLL_STYLE_THUMB, + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid scrollStyle is used."); + + __scrollStyle = scrollStyle; + return E_SUCCESS; +} + +result +_IconListView::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + result r = E_SUCCESS; + + Bitmap* pCopiedBitmap = null; + if (pBitmap != null) + { + pCopiedBitmap = _BitmapImpl::CloneN(*pBitmap); + r = GetLastResult(); + } + + if (r == E_SUCCESS) + { + delete __pBackgroundBitmap; + __pBackgroundBitmap = pCopiedBitmap; + } + else + { + delete pCopiedBitmap; + } + + __pIconListPresenter->ClearVisualElement(); + + return r; +} + +const Bitmap* +_IconListView::GetBackgroundBitmap(void) const +{ + return __pBackgroundBitmap; +} + +result +_IconListView::SetMargin(MarginType type, int value) +{ + switch (type) + { + case MARGIN_TYPE_TOP: + return __pIconListPresenter->SetTopMargin(value); + + case MARGIN_TYPE_BOTTOM: + return __pIconListPresenter->SetBottomMargin(value); + + case MARGIN_TYPE_LEFT: + return __pIconListPresenter->SetLeftMargin(value); + + case MARGIN_TYPE_RIGHT: + return __pIconListPresenter->SetRightMargin(value); + } + + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid type is used."); + return E_INVALID_ARG; +} + +int +_IconListView::GetMargin(MarginType type) const +{ + switch (type) + { + case MARGIN_TYPE_TOP: + return __pIconListPresenter->GetTopMargin(); + + case MARGIN_TYPE_BOTTOM: + return __pIconListPresenter->GetBottomMargin(); + + case MARGIN_TYPE_LEFT: + return __pIconListPresenter->GetLeftMargin(); + + case MARGIN_TYPE_RIGHT: + return __pIconListPresenter->GetRightMargin(); + } + + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used."); + return -1; +} + +result +_IconListView::SetItemSpacing(int horizontalSpacing, int verticalSpacing) +{ + return __pIconListPresenter->SetItemSpacing(horizontalSpacing, verticalSpacing); +} + +int +_IconListView::GetItemHorizontalSpacing(void) const +{ + return __pIconListPresenter->GetItemHorizontalSpacing(); +} + +int +_IconListView::GetItemVerticalSpacing(void) const +{ + return __pIconListPresenter->GetItemVerticalSpacing(); +} + +result +_IconListView::SetItemChecked(int index, bool check) +{ + SysTryReturn(NID_UI_CTRL, (__style == ICON_LIST_VIEW_STYLE_RADIO || __style == ICON_LIST_VIEW_STYLE_MARK), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has been occurred. The style of IconListView is not available to check."); + + return __pIconListPresenter->SetItemChecked(index, check); +} + +bool +_IconListView::IsItemChecked(int index) const +{ + SysTryReturn(NID_UI_CTRL, (__style == ICON_LIST_VIEW_STYLE_RADIO || __style == ICON_LIST_VIEW_STYLE_MARK), false, E_SYSTEM, + "[E_SYSTEM] A system error has been occurred. The style of IconListView is not available to check."); + + return __pIconListPresenter->IsItemChecked(index); +} + +int +_IconListView::GetItemIndexFromPosition(int x, int y) const +{ + return __pIconListPresenter->GetItemIndexFromPosition(x, y); +} + +int +_IconListView::GetItemIndexFromPosition(const Point& position) const +{ + return __pIconListPresenter->GetItemIndexFromPosition(position); +} + +result +_IconListView::SetPropertyTextHorizontalAlignment(const Variant& alignment) +{ + return __pIconListPresenter->SetTextHorizontalAlignment(static_cast(alignment.ToInt())); +} + +result +_IconListView::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + return SetProperty("textHorizontalAlignment", Variant(static_cast(alignment))); +} + +result +_IconListView::SetPropertyTextVerticalAlignment(const Variant& alignment) +{ + return __pIconListPresenter->SetTextVerticalAlignment(static_cast(alignment.ToInt())); +} + +result +_IconListView::SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment) +{ + return SetProperty("textVerticalAlignment", Variant(static_cast(alignment))); +} + +Variant +_IconListView::GetPropertyTextHorizontalAlignment(void) const +{ + return Variant(static_cast(__pIconListPresenter->GetTextHorizontalAlignment())); +} + +HorizontalAlignment +_IconListView::GetTextHorizontalAlignment(void) const +{ + Variant alignment = GetProperty("textHorizontalAlignment"); + return static_cast (alignment.ToInt()); +} + +Variant +_IconListView::GetPropertyTextVerticalAlignment(void) const +{ + return Variant(static_cast(__pIconListPresenter->GetTextVerticalAlignment())); +} + +IconListViewItemTextVerticalAlignment +_IconListView::GetTextVerticalAlignment(void) const +{ + Variant alignment = GetProperty("textVerticalAlignment"); + return static_cast (alignment.ToInt()); +} + +result +_IconListView::SetPropertyTextOfEmptyList(const Variant& text) +{ + __textOfEmptyList = text.ToString(); + + if (__pIconListPresenter != null) + { + __pIconListPresenter->ClearVisualElement(); + } + + return E_SUCCESS; +} + +result +_IconListView::SetTextOfEmptyList(const String& text) +{ + return SetProperty("textOfEmptyList", Variant(text)); +} + +Variant +_IconListView::GetPropertyTextOfEmptyList(void) const +{ + ClearLastResult(); + return Variant(__textOfEmptyList); +} + +const String +_IconListView::GetTextOfEmptyList(void) const +{ + Variant text = GetProperty("textOfEmptyList"); + return text.ToString(); +} + +result +_IconListView::SetPropertyTextColorOfEmptyList(const Variant& color) +{ + __textColorOfEmptyList = color.ToColor(); + __pIconListPresenter->ClearVisualElement(); + + return E_SUCCESS; +} +result +_IconListView::SetTextColorOfEmptyList(const Color& color) +{ + return SetProperty("textColorOfEmptyList", Variant(color)); +} + +Variant +_IconListView::GetPropertyTextColorOfEmptyList(void) const +{ + ClearLastResult(); + return Variant(__textColorOfEmptyList); +} + +const Color +_IconListView::GetTextColorOfEmptyList(void) const +{ + Variant color = GetProperty("textColorOfEmptyList"); + return color.ToColor(); +} + +result +_IconListView::SetTextSizeOfEmptyList(int size) +{ + int minSize = 0; + GET_FIXED_VALUE_CONFIG(ICONLIST::MINIMUM_FONT_SIZE, GetOrientation(), minSize); + SysTryReturn(NID_UI_CTRL, (size >= minSize), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Font size should be greater than or equal to the minimum size."); + + __textSizeOfEmptyList = size; + + return E_SUCCESS; +} + +int +_IconListView::GetTextSizeOfEmptyList(void) const +{ + return __textSizeOfEmptyList; +} + +result +_IconListView::SetItemTextColor(IconListViewItemDrawingStatus status, const Color& color) +{ + return __pIconListPresenter->SetItemTextColor(status, color); +} + +const Color +_IconListView::GetItemTextColor(IconListViewItemDrawingStatus status) const +{ + return __pIconListPresenter->GetItemTextColor(status); +} + +result +_IconListView::SetPropertyItemTextSize(const Variant& size) +{ + return __pIconListPresenter->SetItemTextSize(size.ToInt()); +} + +result +_IconListView::SetItemTextSize(int size) +{ + return SetProperty("itemTextSize", Variant(size)); +} + +Variant +_IconListView::GetPropertyItemTextSize(void) const +{ + return Variant(__pIconListPresenter->GetItemTextSize()); +} + +int +_IconListView::GetItemTextSize(void) const +{ + Variant size = GetProperty("itemTextSize"); + return size.ToInt(); +} + +result +_IconListView::SetPropertyCheckBoxPosition(const Variant& position) +{ + SysTryReturn(NID_UI_CTRL, (__style == ICON_LIST_VIEW_STYLE_RADIO || __style == ICON_LIST_VIEW_STYLE_MARK), E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current style of IconListView is not available to check. So can not set position of checkbox."); + + return __pIconListPresenter->SetCheckBoxPosition(static_cast(position.ToInt())); +} + +result +_IconListView::SetCheckBoxPosition(IconListViewCheckBoxPosition position) +{ + return SetProperty("checkBoxPosition", Variant(static_cast(position))); +} + +Variant +_IconListView::GetPropertyCheckBoxPosition(void) const +{ + SysTryReturn(NID_UI_CTRL, (__style == ICON_LIST_VIEW_STYLE_RADIO || __style == ICON_LIST_VIEW_STYLE_MARK), + Variant(static_cast(ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT)), E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The current style of IconListView is not available to check. So can not get position of checkBox."); + + return Variant(static_cast(__pIconListPresenter->GetCheckBoxPosition())); +} + +IconListViewCheckBoxPosition +_IconListView::GetCheckBoxPosition(void) const +{ + Variant position = GetProperty("checkBoxPosition"); + return static_cast(position.ToInt()); +} + +result +_IconListView::SetPropertyTouchAnimationEnabled(const Variant& enabled) +{ + return __pIconListPresenter->SetTouchAnimationEnabled(enabled.ToBool()); +} + +result +_IconListView::SetTouchAnimationEnabled(bool enable) +{ + return SetProperty("touchAnimationEnabled", Variant(enable)); +} + +Variant +_IconListView::GetPropertyTouchAnimationEnabled(void) const +{ + return Variant(__pIconListPresenter->IsTouchAnimationEnabled()); +} + +bool +_IconListView::IsTouchAnimationEnabled(void) const +{ + Variant enabled = GetProperty("touchAnimationEnabled"); + return enabled.ToBool(); +} + +result +_IconListView::ScrollToItem(int index) +{ + return __pIconListPresenter->ScrollToItem(index); +} + +result +_IconListView::ScrollByPixel(int pixel) +{ + return __pIconListPresenter->ScrollByPixel(pixel); +} + +result +_IconListView::RefreshList(int index, ListRefreshType type) +{ + return __pIconListPresenter->RefreshList(index, type); +} + +result +_IconListView::UpdateList(void) +{ + return __pIconListPresenter->UpdateList(); +} + +result +_IconListView::SetItemBitmapBounds(const Rectangle& bounds) +{ + return __pIconListPresenter->SetItemBitmapBounds(bounds); +} + +const Rectangle +_IconListView::GetItemBitmapBounds(void) const +{ + return __pIconListPresenter->GetItemBitmapBounds(); +} + +result +_IconListView::GetItemBitmapSize(int& width, int& height) const +{ + return __pIconListPresenter->GetItemBitmapSize(width, height); +} + +const Dimension +_IconListView::GetItemBitmapSize(void) const +{ + return __pIconListPresenter->GetItemBitmapSize(); +} + +result +_IconListView::SetItemSize(const Dimension& size) +{ + return __pIconListPresenter->SetItemSize(size); +} + +result +_IconListView::GetItemSize(int& width, int& height) const +{ + return __pIconListPresenter->GetItemSize(width, height); +} + +const Dimension +_IconListView::GetItemSize(void) const +{ + return __pIconListPresenter->GetItemSize(); +} + +result +_IconListView::SetPropertyMagneticScrollSize(const Variant& size) +{ + return __pIconListPresenter->SetMagneticScrollSize(size.ToInt()); +} + +result +_IconListView::SetMagneticScrollSize(int scrollSize) +{ + return SetProperty("magneticScrollSize", Variant(scrollSize)); +} + +Variant +_IconListView::GetPropertyMagneticScrollSize(void) const +{ + return Variant(__pIconListPresenter->GetMagneticScrollSize()); +} + +int +_IconListView::GetMagneticScrollSize(void) const +{ + Variant size = GetProperty("magneticScrollSize"); + return size.ToInt(); +} + +int +_IconListView::GetItemCountPerAxis(void) const +{ + return __pIconListPresenter->GetItemCountPerAxis(); +} + +result +_IconListView::SetPropertyItemLayoutHorizontalAlignment(const Variant& alignment) +{ + return __pIconListPresenter->SetItemLayoutHorizontalAlignment(static_cast(alignment.ToInt())); +} + +result +_IconListView::SetItemLayoutHorizontalAlignment(HorizontalAlignment alignment) +{ + return SetProperty("itemLayoutHorizontalAlignment", Variant(static_cast(alignment))); +} + +result +_IconListView::SetPropertyItemLayoutVerticalAlignment(const Variant& alignment) +{ + return __pIconListPresenter->SetItemLayoutVerticalAlignment(static_cast(alignment.ToInt())); +} + +result +_IconListView::SetItemLayoutVerticalAlignment(VerticalAlignment alignment) +{ + return SetProperty("itemLayoutVerticalAlignment", Variant(static_cast(alignment))); +} + +Variant +_IconListView::GetPropertyItemLayoutHorizontalAlignment(void) const +{ + return Variant(static_cast(__pIconListPresenter->GetItemLayoutHorizontalAlignment())); +} + +HorizontalAlignment +_IconListView::GetItemLayoutHorizontalAlignment(void) const +{ + Variant alignment = GetProperty("itemLayoutHorizontalAlignment"); + return static_cast(alignment.ToInt()); +} + +Variant +_IconListView::GetPropertyItemLayoutVerticalAlignment(void) const +{ + return Variant(static_cast(__pIconListPresenter->GetItemLayoutVerticalAlignment())); +} + +VerticalAlignment +_IconListView::GetItemLayoutVerticalAlignment(void) const +{ + Variant alignment = GetProperty("itemLayoutVerticalAlignment"); + return static_cast(alignment.ToInt()); +} + +result +_IconListView::SetPropertyItemBorderStyle(const Variant& style) +{ + return __pIconListPresenter->SetItemBorderStyle(static_cast(style.ToInt())); +} + +result +_IconListView::SetItemBorderStyle(IconListViewItemBorderStyle borderStyle) +{ + return SetProperty("itemBorderStyle", Variant(static_cast(borderStyle))); +} + +Variant +_IconListView::GetPropertyItemBorderStyle(void) const +{ + return Variant(static_cast(__pIconListPresenter->GetItemBorderStyle())); +} + +IconListViewItemBorderStyle +_IconListView::GetItemBorderStyle(void) const +{ + Variant style = GetProperty("itemBorderStyle"); + return static_cast(style.ToInt()); +} + +result +_IconListView::SetBitmapOfEmptyList(const Bitmap* pBitmap) +{ + result r = E_SUCCESS; + Bitmap* pCopiedBitmap = null; + if (pBitmap != null) + { + pCopiedBitmap = _BitmapImpl::CloneN(*pBitmap); + r = GetLastResult(); + } + + if (r == E_SUCCESS) + { + delete __pBitmapOfEmptyList; + __pBitmapOfEmptyList = pCopiedBitmap; + } + else + { + delete pCopiedBitmap; + } + + __pIconListPresenter->ClearVisualElement(); + + return r; +} + +const Bitmap* +_IconListView::GetBitmapOfEmptyList(void) const +{ + return __pBitmapOfEmptyList; +} + +result +_IconListView::SetNonSlidableList(void) +{ + return __pIconListPresenter->SetNonSlidableList(); +} + +result +_IconListView::AddItem(_IconListItem* pItem) +{ + return __pIconListPresenter->AddItem(pItem); +} + +result +_IconListView::InsertItemAt(int index, _IconListItem* pItem) +{ + return __pIconListPresenter->InsertItemAt(index, pItem); +} + +result +_IconListView::SetItemAt(int index, _IconListItem* pItem) +{ + return __pIconListPresenter->SetItemAt(index, pItem); +} + +result +_IconListView::RemoveItemAt(int index) +{ + return __pIconListPresenter->RemoveItemAt(index); +} + +result +_IconListView::RemoveAllItems(void) +{ + return __pIconListPresenter->RemoveAllItems(); +} + +result +_IconListView::SetScroll(const Rectangle& bounds, _ScrollDirection scrollDirection) +{ + if (__pScroll == null) + { + __pScroll = _Scroll::CreateScrollN(*this, scrollDirection, + (((__scrollStyle == ICON_LIST_SCROLL_STYLE_FIXED) || (__scrollStyle == ICON_LIST_SCROLL_STYLE_THUMB)) ? false : true), + ((__scrollStyle == ICON_LIST_SCROLL_STYLE_JUMP_TO_TOP) ? true : false), + ((__scrollStyle == ICON_LIST_SCROLL_STYLE_THUMB) ? true : false), + (((__scrollStyle == ICON_LIST_SCROLL_STYLE_FIXED) || (__scrollStyle == ICON_LIST_SCROLL_STYLE_THUMB)) ? true : false), 1, 1, 0); + + SysTryReturn(NID_UI_CTRL, __pScroll != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pScroll->EnableScrollingEffect(true); + __pScroll->SetParentUsingViewport(false); + __pScroll->AddScrollEventListener(*__pIconListPresenter); + + AttachSystemChild(*__pScroll); + } + + return E_SUCCESS; +} + +_Scroll* +_IconListView::GetScroll(void) const +{ + return __pScroll; +} + +void +_IconListView::SetItemBitmapAsAspectRatio(bool isAspect) +{ + __pIconListPresenter->SetItemBitmapAsAspectRatio(isAspect); +} + +bool +_IconListView::IsItemBitmapAsAspectRatio(void) const +{ + return __pIconListPresenter->IsItemBitmapAsAspectRatio(); +} + +_UiIconListItemEvent* +_IconListView::GetIconListItemEvent(void) const +{ + return __pIconListItemEvent; +} + +_UiScrollEvent* +_IconListView::GetScrollEvent(void) const +{ + return __pScrollEvent; +} + +_TouchLongPressGestureDetector* +_IconListView::GetLongPressGesture(void) const +{ + return __pGestureLongPress; +} + +result +_IconListView::SetLongPressGesture(_TouchLongPressGestureDetector* pLongPress) +{ + __pGestureLongPress = pLongPress; + return E_SUCCESS; +} + +_TouchFlickGestureDetector* +_IconListView::GetFlickGesture(void) const +{ + return __pGestureFlick; +} + +result +_IconListView::SetFlickGesture(_TouchFlickGestureDetector* pFlick) +{ + __pGestureFlick = pFlick; + return E_SUCCESS; +} + +result +_IconListView::SetReorderModeEnabled(bool enable) +{ + if (__reorderEnabled != enable) + { + __reorderEnabled = enable; + return __pIconListPresenter->SetReorderModeEnabled(enable); + } + return E_SUCCESS; +} + +bool +_IconListView::IsInReorderingMode(void) const +{ + ClearLastResult(); + return __reorderEnabled; +} + +void +_IconListView::OnBoundsChanged(void) +{ + __pIconListPresenter->OnBoundsChanged(); +} + +void +_IconListView::OnDraw(void) +{ + __pIconListPresenter->Draw(); +} + +void +_IconListView::OnAncestorVisibleStateChanged(const _Control& control) +{ + _Control::OnAncestorVisibleStateChanged(control); + + OnVisibleStateChanged(); +} + +void +_IconListView::OnAncestorEnableStateChanged(const _Control& control) +{ + _Control::OnAncestorEnableStateChanged(control); + + OnVisibleStateChanged(); +} + +void +_IconListView::OnChangeLayout(_ControlOrientation orientation) +{ + _Control::OnChangeLayout(orientation); + + __pIconListPresenter->ClearVisualElement(); +} + +void +_IconListView::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pIconListPresenter->OnFontInfoRequested(style, size); +} + +void +_IconListView::OnFontChanged(Font* pFont) +{ + __pIconListPresenter->OnFontChanged(pFont); +} + +// Tizen::Ui::_IPreviewKeyEventListener +bool +_IconListView::OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo) +{ + return __pIconListPresenter->OnPreviewKeyPressed(source, keyInfo); +} + +bool +_IconListView::OnPreviewKeyReleased(const _Control& source, const _KeyInfo& keyInfo) +{ + return __pIconListPresenter->OnPreviewKeyReleased(source, keyInfo); +} + +// Tizen::Ui::_IKeyEventListener +bool +_IconListView::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) +{ + return __pIconListPresenter->OnKeyPressed(source, keyInfo); +} + +bool +_IconListView::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) +{ + return __pIconListPresenter->OnKeyReleased(source, keyInfo); +} + +// Tizen::Ui::_IPreviewNotificationEventListener +bool +_IconListView::OnPreviewNotifiedN(const _Control& source, Collection::IList* pArgs) +{ + return __pIconListPresenter->OnPreviewNotifiedN(source, pArgs); +} + +// Tizen::Ui::_INotificationEventListener +bool +_IconListView::OnNotifiedN(const _Control& source, Collection::IList* pArgs) +{ + return __pIconListPresenter->OnNotifiedN(source, pArgs); +} + +// Tizen::Ui::_ITouchEventPreviewer +_UiTouchEventDelivery +_IconListView::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pIconListPresenter->OnPreviewTouchReleased(source, touchinfo); +} + +// Tizen::Ui::_ITouchEventListener +bool +_IconListView::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pIconListPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_IconListView::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pIconListPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_IconListView::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pIconListPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_IconListView::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pIconListPresenter->OnTouchCanceled(source, touchinfo); +} + +bool +_IconListView::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) +{ + int xDistance = 0; + int yDistance = 0; + gesture.GetDistance(xDistance, yDistance); + Point flickPoint(xDistance, yDistance); + + return __pIconListPresenter->OnFlickGestureDetected(true, flickPoint, gesture.GetDuration()); +} + +bool +_IconListView::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture) +{ + return false; +} + +bool +_IconListView::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture) +{ + return __pIconListPresenter->OnLongPressGestureDetected(); +} + +bool +_IconListView::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture) +{ + return false; +} + +void +_IconListView::OnPropertyChanging(_PropertyBase& source, const String& name, const Variant& oldValue, const Variant& newValue) +{ + +} + +void +_IconListView::OnPropertyChanged(_PropertyBase& source, const String& name, const Variant& oldValue, const Variant& newValue) +{ + +} + +void +_IconListView::OnVisibleStateChanged(void) +{ + if (__pScroll != null) + { + bool enableFadeEffect = __pScroll->IsEnabledFadeEffect(); + if (GetVisibleState() == false) + { + if (enableFadeEffect) + { + __pScroll->SetScrollVisibility(false); + } + } + else if (enableFadeEffect) + { + int scrollViewRange = 0; + int scrollRange = 0; + __pScroll->GetScrollRange(&scrollViewRange, &scrollRange); + + if (scrollViewRange < scrollRange) + { + __pIconListPresenter->ScrollFadeOut(); + } + } + } + + __pIconListPresenter->OnVisibleStateChanged(); +} + +// Tizen::Ui::_IScrollEventListener +void +_IconListView::OnScrollEndReached(_Control& source, ScrollEndEvent type) +{ + __pIconListPresenter->OnScrollEndReached(source, type); +} + +void +_IconListView::OnScrollPositionChanged(_Control& source, int scrollPos) +{ + __pIconListPresenter->OnScrollPositionChanged(source, scrollPos); +} + +void +_IconListView::OnScrollStopped(_Control& source) +{ + __pIconListPresenter->OnScrollStopped(source); +} + +// Tizen::Ui::Animations::IAnimationTransactionEventListener +void +_IconListView::OnAnimationTransactionStarted(int transactionId) +{ +} + +void +_IconListView::OnAnimationTransactionStopped(int transactionId) +{ + if (__pIconListPresenter != null) + { + __pIconListPresenter->OnAnimationTransactionStopped(transactionId); + } +} + +void +_IconListView::OnAnimationTransactionFinished(int transactionId) +{ + if (__pIconListPresenter != null) + { + __pIconListPresenter->OnAnimationTransactionFinished(transactionId); + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IconListViewImpl.cpp b/src/ui/controls/FUiCtrl_IconListViewImpl.cpp new file mode 100644 index 0000000..eb347f0 --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListViewImpl.cpp @@ -0,0 +1,991 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListViewImpl.cpp + * @brief This is the implementation file for the _IconListViewImpl class. + */ + +//Includes +#include + +#include "FUi_UiBuilder.h" +#include "FUiCtrl_IconListView.h" +#include "FUiCtrl_IconListViewImpl.h" +#include "FUiCtrl_IconListViewItemEvent.h" +#include "FUiCtrl_IconListViewItemEventArg.h" +#include "FUiCtrl_ScrollEvent.h" +#include "FUiCtrl_ScrollEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_IconListViewImpl::_IconListViewImpl(IconListView* pIconListView, _IconListView* pCore) + : _ControlImpl(pIconListView, pCore) + , __pIconListView(pCore) + , __pIconListViewItemEvent(null) + , __pScrollEvent(null) +{ + // Do nothing +} + +_IconListViewImpl::~_IconListViewImpl(void) +{ + Dispose(); +} + +_IconListViewImpl* +_IconListViewImpl::CreateIconListViewImplN(IconListView* pIconListView) +{ + _IconListView* pCore = _IconListView::CreateIconListViewN(); + SysTryReturn(NID_UI_CTRL, (pCore != null), null , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _IconListViewImpl* pImpl = new (std::nothrow) _IconListViewImpl(pIconListView, pCore); + + result r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI, (r == E_SUCCESS), null , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; +} + +_IconListViewImpl* +_IconListViewImpl::GetInstance(IconListView& iconListView) +{ + return static_cast<_IconListViewImpl*>(iconListView._pControlImpl); +} + +const _IconListViewImpl* +_IconListViewImpl::GetInstance(const IconListView& iconListView) +{ + return static_cast(iconListView._pControlImpl); +} + +const char* +_IconListViewImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::IconListView"; +} + +IconListView& +_IconListViewImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +result +_IconListViewImpl::Dispose(void) +{ + __pIconListView = null; + + if (__pIconListViewItemEvent != null) + { + delete __pIconListViewItemEvent; + __pIconListViewItemEvent = null; + } + + if (__pScrollEvent != null) + { + delete __pScrollEvent; + __pScrollEvent = null; + } + + return E_SUCCESS; +} + +result +_IconListViewImpl::Initialize(IconListView* pIconListView, const Dimension& itemBitmapSize, IconListViewStyle style, + IconListViewScrollDirection scrollDirection, IconListViewScrollStyle scrollStyle) +{ + SysTryReturn(NID_UI_CTRL, (__pIconListView != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Unable to create IconListView."); + + result r = E_SUCCESS; + Rectangle itemBitmapBounds(0, 0, itemBitmapSize.width, itemBitmapSize.height); + + r = __pIconListView->SetStyle(style); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pIconListView->SetScrollStyle(scrollStyle); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pIconListView->SetScrollDirection(scrollDirection); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pIconListView->SetItemBitmapBounds(itemBitmapBounds); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pIconListViewItemEvent = new (std::nothrow) _IconListViewItemEvent; + SysTryCatch(NID_UI_CTRL, (__pIconListViewItemEvent != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pIconListViewItemEvent->Construct(*pIconListView); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pIconListView->AddIconListItemEventListener(*this); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent = new (std::nothrow) _ScrollEvent(); + SysTryCatch(NID_UI_CTRL, (__pScrollEvent != null), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed/"); + + r = __pScrollEvent->Construct(*pIconListView); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pIconListView->AddScrollEventListener(*this); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +CATCH: + Dispose(); + return r; +} + +result +_IconListViewImpl::SetItemProvider(IIconListViewItemProvider& provider) +{ + return __pIconListView->SetItemProvider(provider); +} + +void +_IconListViewImpl::AddIconListViewItemEventListener(IIconListViewItemEventListener& listener) +{ + result r = __pIconListViewItemEvent->AddListener(listener); + if (r == E_OBJ_ALREADY_EXIST) + { + SysLogException(NID_UI_CTRL, (r = E_SYSTEM), "[E_SYSTEM] A system error has been occurred. The same instance alerady exists in the event listener list."); + } + else + { + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + + SetLastResult(r); +} + +void +_IconListViewImpl::RemoveIconListViewItemEventListener(IIconListViewItemEventListener& listener) +{ + result r = __pIconListViewItemEvent->RemoveListener(listener); + if (r == E_OBJ_NOT_FOUND) + { + SysLogException(NID_UI_CTRL, (r = E_SYSTEM), "[E_SYSTEM] A system error has been occurred. The specified listener does not exist in the event listener list."); + } + else + { + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + + SetLastResult(r); +} + +void +_IconListViewImpl::AddScrollEventListener(IScrollEventListener& listener) +{ + result r = __pScrollEvent->AddListener(listener); + if (r == E_OBJ_ALREADY_EXIST) + { + SysLogException(NID_UI_CTRL, (r = E_SYSTEM), "[E_SYSTEM] A system error has been occurred. The same instance alerady exists in the event listener list."); + } + else + { + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + + SetLastResult(r); +} + +void +_IconListViewImpl::RemoveScrollEventListener(IScrollEventListener& listener) +{ + result r = __pScrollEvent->RemoveListener(listener); + if (r == E_OBJ_NOT_FOUND) + { + SysLogException(NID_UI_CTRL, (r = E_SYSTEM), "[E_SYSTEM] A system error has been occurred. The specified listener does not exist in the event listener list."); + } + else + { + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + } + + SetLastResult(r); +} + +result +_IconListViewImpl::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + return __pIconListView->SetBackgroundBitmap(pBitmap); +} + +result +_IconListViewImpl::SetMargin(MarginType type, int value) +{ + return __pIconListView->SetMargin(type, value); +} + +int +_IconListViewImpl::GetMargin(MarginType type) const +{ + return __pIconListView->GetMargin(type); +} + +result +_IconListViewImpl::SetItemSpacing(int horizontalSpacing, int verticalSpacing) +{ + return __pIconListView->SetItemSpacing(horizontalSpacing, verticalSpacing); +} + +int +_IconListViewImpl::GetItemHorizontalSpacing(void) const +{ + return __pIconListView->GetItemHorizontalSpacing(); +} + +int +_IconListViewImpl::GetItemVerticalSpacing(void) const +{ + return __pIconListView->GetItemVerticalSpacing(); +} + +result +_IconListViewImpl::SetItemChecked(int index, bool check) +{ + return __pIconListView->SetItemChecked(index, check); +} + +bool +_IconListViewImpl::IsItemChecked(int index) const +{ + return __pIconListView->IsItemChecked(index); +} + +int +_IconListViewImpl::GetItemIndexFromPosition(int x, int y) const +{ + return __pIconListView->GetItemIndexFromPosition(x, y); +} + +int +_IconListViewImpl::GetItemIndexFromPosition(const Point& position) const +{ + return __pIconListView->GetItemIndexFromPosition(position); +} + +result +_IconListViewImpl::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + return __pIconListView->SetTextHorizontalAlignment(alignment); +} + +result +_IconListViewImpl::SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment) +{ + return __pIconListView->SetTextVerticalAlignment(alignment); +} + +HorizontalAlignment +_IconListViewImpl::GetTextHorizontalAlignment(void) const +{ + ClearLastResult(); + return __pIconListView->GetTextHorizontalAlignment(); +} + +IconListViewItemTextVerticalAlignment +_IconListViewImpl::GetTextVerticalAlignment(void) const +{ + ClearLastResult(); + return __pIconListView->GetTextVerticalAlignment(); +} + +result +_IconListViewImpl::SetTextOfEmptyList(const String& text) +{ + return __pIconListView->SetTextOfEmptyList(text); +} + +String +_IconListViewImpl::GetTextOfEmptyList(void) const +{ + ClearLastResult(); + return __pIconListView->GetTextOfEmptyList(); +} + +result +_IconListViewImpl::SetTextColorOfEmptyList(const Color& color) +{ + return __pIconListView->SetTextColorOfEmptyList(color); +} + +Color +_IconListViewImpl::GetTextColorOfEmptyList(void) const +{ + ClearLastResult(); + return __pIconListView->GetTextColorOfEmptyList(); +} + +result +_IconListViewImpl::SetItemTextColor(IconListViewItemDrawingStatus status, const Color& color) +{ + return __pIconListView->SetItemTextColor(status, color); +} + +Color +_IconListViewImpl::GetItemTextColor(IconListViewItemDrawingStatus status) const +{ + return __pIconListView->GetItemTextColor(status); +} + +result +_IconListViewImpl::SetItemTextSize(int size) +{ + return __pIconListView->SetItemTextSize(size); +} + +int +_IconListViewImpl::GetItemTextSize(void) const +{ + ClearLastResult(); + return __pIconListView->GetItemTextSize(); +} + +result +_IconListViewImpl::SetCheckBoxPosition(IconListViewCheckBoxPosition position) +{ + return __pIconListView->SetCheckBoxPosition(position); +} + +IconListViewCheckBoxPosition +_IconListViewImpl::GetCheckBoxPosition(void) const +{ + ClearLastResult(); + return __pIconListView->GetCheckBoxPosition(); +} + +result +_IconListViewImpl::SetTouchAnimationEnabled(bool enable) +{ + return __pIconListView->SetTouchAnimationEnabled(enable); +} + +bool +_IconListViewImpl::IsTouchAnimationEnabled(void) const +{ + ClearLastResult(); + return __pIconListView->IsTouchAnimationEnabled(); +} + +result +_IconListViewImpl::ScrollToItem(int index) +{ + return __pIconListView->ScrollToItem(index); +} + +result +_IconListViewImpl::ScrollByPixel(int pixel) +{ + return __pIconListView->ScrollByPixel(pixel); +} + +result +_IconListViewImpl::RefreshList(int index, ListRefreshType type) +{ + return __pIconListView->RefreshList(index, type); +} + +result +_IconListViewImpl::UpdateList(void) +{ + return __pIconListView->UpdateList(); +} + +result +_IconListViewImpl::GetItemBitmapSize(int& width, int& height) const +{ + return __pIconListView->GetItemBitmapSize(width, height); +} + +Dimension +_IconListViewImpl::GetItemBitmapSize(void) const +{ + return __pIconListView->GetItemBitmapSize(); +} + +result +_IconListViewImpl::GetItemSize(int& width, int& height) const +{ + return __pIconListView->GetItemSize(width, height); +} + +Dimension +_IconListViewImpl::GetItemSize(void) const +{ + return __pIconListView->GetItemSize(); +} + +result +_IconListViewImpl::SetMagneticScrollSize(int scrollSize) +{ + return __pIconListView->SetMagneticScrollSize(scrollSize); +} + +int +_IconListViewImpl::GetMagneticScrollSize(void) const +{ + ClearLastResult(); + return __pIconListView->GetMagneticScrollSize(); +} + +int +_IconListViewImpl::GetItemCountPerAxis(void) const +{ + return __pIconListView->GetItemCountPerAxis(); +} + +result +_IconListViewImpl::SetItemLayoutHorizontalAlignment(HorizontalAlignment alignment) +{ + return __pIconListView->SetItemLayoutHorizontalAlignment(alignment); +} + +result +_IconListViewImpl::SetItemLayoutVerticalAlignment(VerticalAlignment alignment) +{ + return __pIconListView->SetItemLayoutVerticalAlignment(alignment); +} + +HorizontalAlignment +_IconListViewImpl::GetItemLayoutHorizontalAlignment(void) const +{ + ClearLastResult(); + return __pIconListView->GetItemLayoutHorizontalAlignment(); +} + +VerticalAlignment +_IconListViewImpl::GetItemLayoutVerticalAlignment(void) const +{ + ClearLastResult(); + return __pIconListView->GetItemLayoutVerticalAlignment(); +} + +result +_IconListViewImpl::SetItemBorderStyle(IconListViewItemBorderStyle borderStyle) +{ + return __pIconListView->SetItemBorderStyle(borderStyle); +} + +IconListViewItemBorderStyle +_IconListViewImpl::GetItemBorderStyle(void) const +{ + ClearLastResult(); + return __pIconListView->GetItemBorderStyle(); +} + +result +_IconListViewImpl::SetBitmapOfEmptyList(const Bitmap* pBitmap) +{ + return __pIconListView->SetBitmapOfEmptyList(pBitmap); +} + +result +_IconListViewImpl::BeginReorderingMode(void) +{ + return __pIconListView->SetReorderModeEnabled(true); +} + +result +_IconListViewImpl::EndReorderingMode(void) +{ + return __pIconListView->SetReorderModeEnabled(false); +} + +bool +_IconListViewImpl::IsInReorderingMode(void) const +{ + return __pIconListView->IsInReorderingMode(); +} + +void +_IconListViewImpl::OnIconListItemStateChanged(_IconListViewItemEventArg* pArg) +{ + if (__pIconListViewItemEvent != null && pArg != null) + { + _IconListViewItemEventArg* pEventArg = new (std::nothrow) _IconListViewItemEventArg(pArg->GetIndex(), pArg->GetEventType()); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memroy allcation failed."); + pEventArg->SetStatus(pArg->GetStatus()); + __pIconListViewItemEvent->Fire(*pEventArg); + } +} + +void +_IconListViewImpl::OnIconListViewOverlayBitmapSelected(_IconListViewItemEventArg* pArg) +{ + if (__pIconListViewItemEvent != null && pArg != null) + { + _IconListViewItemEventArg* pEventArg = new (std::nothrow) _IconListViewItemEventArg(pArg->GetIndex(), pArg->GetEventType()); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memroy allcation failed."); + pEventArg->SetOverlayBitmapId(pArg->GetOverlayBitmapId()); + __pIconListViewItemEvent->Fire(*pEventArg); + } +} + +void +_IconListViewImpl::OnIconListViewItemReordered(_IconListViewItemEventArg* pArg) +{ + if (__pIconListViewItemEvent != null && pArg != null) + { + _IconListViewItemEventArg* pEventArg = new (std::nothrow) _IconListViewItemEventArg(pArg->GetIndex(), pArg->GetEventType()); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memroy allcation failed."); + pEventArg->SetToIndex(pArg->GetToIndex()); + __pIconListViewItemEvent->Fire(*pEventArg); + } +} + +void +_IconListViewImpl::OnScrollEndReached(_Control& source, ScrollEndEvent type) +{ + if (__pScrollEvent == null) + { + return; + } + + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), type); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + + return; +CATCH: + delete pEventArg; +} + +void +_IconListViewImpl::OnScrollPositionChanged(_Control& source, int scrollPos) +{ + if (__pScrollEvent == null) + { + return; + } + + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), scrollPos); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + + return; +CATCH: + delete pEventArg; +} + +void +_IconListViewImpl::OnScrollStopped(_Control& source) +{ + if (__pScrollEvent == null) + { + return; + } + + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic()); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + + return; +CATCH: + delete pEventArg; +} + +class _IconListViewMaker + : public _UiBuilderControlMaker +{ +public: + _IconListViewMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder) + { + } + + virtual ~_IconListViewMaker() + { + } + + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _IconListViewMaker* pIconListViewMaker = new (std::nothrow) _IconListViewMaker(uibuilder); + + return pIconListViewMaker; + } + +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + SysTryReturn(NID_UI, (pControl != null), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invaild parameter is used."); + _UiBuilderControlLayout* pControlProperty = null; + GetProperty(pControl, &pControlProperty); + SysTryReturn(NID_UI, (pControlProperty != null), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Unable to read attributes."); + + IconListView* pIconListView = new (std::nothrow) IconListView; + SysTryReturn(NID_UI, (pIconListView != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + ClearLastResult(); + + Rectangle bounds; + Rectangle rect; + Dimension itemBitmapSize(100, 100); + IconListViewStyle style = ICON_LIST_VIEW_STYLE_NORMAL; + IconListViewScrollDirection scrollDirection = ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL; + + // Get Bounds + rect = pControlProperty->GetRect(); + bounds.SetBounds(rect.x, rect.y, rect.width, rect.height); + Tizen::Base::String elementString; + + // Get ItemBitmapSize(width) + if (pControl->GetElement("itemBitmapWidth", elementString)) + { + Base::Integer::Parse(elementString,itemBitmapSize.width); + } + + // Get ItemBitmapSize(height) + if (pControl->GetElement("itemBitmapHeight", elementString)) + { + Base::Integer::Parse(elementString,itemBitmapSize.height); + } + + // Get style + Tizen::Base::String styleString; + styleString = pControlProperty->GetStyle(); + if (styleString.IsEmpty() == false) + { + if (styleString.Equals(L"ICON_LIST_VIEW_STYLE_NORMAL", false)) + { + style = ICON_LIST_VIEW_STYLE_NORMAL; + } + else if (styleString.Equals(L"ICON_LIST_VIEW_STYLE_RADIO", false)) + { + style = ICON_LIST_VIEW_STYLE_RADIO; + } + else if (styleString.Equals(L"ICON_LIST_VIEW_STYLE_MARK", false)) + { + style = ICON_LIST_VIEW_STYLE_MARK; + } + } + + // Get scrollDirection + if (pControl->GetElement("scrollDirection", elementString)) + { + if (elementString.Equals(L"ICON_LIST_VIEW_SCROLL_DIRECTION_HORIZONTAL", false)) + { + scrollDirection = ICON_LIST_VIEW_SCROLL_DIRECTION_HORIZONTAL; + } + else if (elementString.Equals(L"ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL", false)) + { + scrollDirection = ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL; + } + } + + // Construct IconListView + result r = pIconListView->Construct(bounds, itemBitmapSize, style, scrollDirection); + SysTryCatch(NID_UI, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Set BackgroundsBitmap + if (pControl->GetElement("backgroundBitmapPath", elementString) || pControl->GetElement("BGBitmapPath", elementString)) + { + Bitmap* pBackgroundBitmap = null; + pBackgroundBitmap = LoadBitmapN(elementString); + if (pBackgroundBitmap) + { + pIconListView->SetBackgroundBitmap(pBackgroundBitmap); + delete pBackgroundBitmap; + } + } + + // Set BackgroundColor + if (pControl->GetElement("backgroundColor", elementString) || pControl->GetElement("BGColor", elementString)) + { + Color bgColor; + ConvertStringToColor(elementString, bgColor); + if (pControl->GetElement("backgroundColorOpacity", elementString) || pControl->GetElement("BGColorOpacity", elementString)) + { + int opacity =0; + Base::Integer::Parse(elementString, opacity); + bgColor.SetAlpha(ConvertOpacity100to255(opacity)); + } + pIconListView->SetBackgroundColor(bgColor); + } + + // Set CheckBoxPosition + if ((style == ICON_LIST_VIEW_STYLE_RADIO || style == ICON_LIST_VIEW_STYLE_MARK) + && pControl->GetElement("checkBoxPosition", elementString)) + { + IconListViewCheckBoxPosition checkBoxPosition = ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT; + if (elementString.Equals(L"ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT", false)) + { + checkBoxPosition = ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_LEFT; + } + else if (elementString.Equals(L"ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT", false)) + { + checkBoxPosition = ICON_LIST_VIEW_CHECK_BOX_POSITION_TOP_RIGHT; + } + else if (elementString.Equals(L"ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_LEFT", false)) + { + checkBoxPosition = ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_LEFT; + } + else if (elementString.Equals(L"ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_RIGHT", false)) + { + checkBoxPosition = ICON_LIST_VIEW_CHECK_BOX_POSITION_BOTTOM_RIGHT; + } + + pIconListView->SetCheckBoxPosition(checkBoxPosition); + } + + // Set BitmapOfEmptyList + if (pControl->GetElement("bitmapPathOfEmptyList", elementString)) + { + Bitmap* pBitmapOfEmptyList = null; + pBitmapOfEmptyList = LoadBitmapN(elementString); + if (pBitmapOfEmptyList) + { + pIconListView->SetBitmapOfEmptyList(pBitmapOfEmptyList); + delete pBitmapOfEmptyList; + } + } + + // Set TextOfEmptyList + if (pControl->GetElement("textOfEmptyList", elementString)) + { + pIconListView->SetTextOfEmptyList(elementString); + } + + // Set TextColorOfEmptyList + if (pControl->GetElement("colorOfEmptyListText", elementString)) + { + Color color; + ConvertStringToColor(elementString, color); + pIconListView->SetTextColorOfEmptyList(color); + } + + // Set ItemBorderStyle + if (pControl->GetElement("itemBorderStyle", elementString)) + { + IconListViewItemBorderStyle borderStyle = ICON_LIST_VIEW_ITEM_BORDER_STYLE_SHADOW; + if (elementString.Equals(L"ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE", false)) + { + borderStyle = ICON_LIST_VIEW_ITEM_BORDER_STYLE_NONE; + } + else if (elementString.Equals(L"ICON_LIST_VIEW_ITEM_BORDER_STYLE_OUTLINE", false)) + { + borderStyle = ICON_LIST_VIEW_ITEM_BORDER_STYLE_OUTLINE; + } + else if (elementString.Equals(L"ICON_LIST_VIEW_ITEM_BORDER_STYLE_SHADOW", false)) + { + borderStyle = ICON_LIST_VIEW_ITEM_BORDER_STYLE_SHADOW; + } + + pIconListView->SetItemBorderStyle(borderStyle); + } + + // Set ItemLayoutHorizontalAlignment + if (scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL + && pControl->GetElement("itemHorizontalAlignment", elementString)) + { + HorizontalAlignment alignment = ALIGNMENT_CENTER; + if (elementString.Equals(L"ALIGNMENT_LEFT", false)) + { + alignment = ALIGNMENT_LEFT; + } + else if (elementString.Equals(L"ALIGNMENT_CENTER", false)) + { + alignment = ALIGNMENT_CENTER; + } + else if (elementString.Equals(L"ALIGNMENT_RIGHT", false)) + { + alignment = ALIGNMENT_RIGHT; + } + + pIconListView->SetItemLayoutHorizontalAlignment(alignment); + } + + // Set ItemLayoutVerticalAlignment + if (scrollDirection == ICON_LIST_VIEW_SCROLL_DIRECTION_HORIZONTAL + && pControl->GetElement("itemVerticalAlignment", elementString)) + { + VerticalAlignment alignment = ALIGNMENT_MIDDLE; + if (elementString.Equals(L"ALIGNMENT_TOP", false)) + { + alignment = ALIGNMENT_TOP; + } + else if (elementString.Equals(L"ALIGNMENT_MIDDLE", false)) + { + alignment = ALIGNMENT_MIDDLE; + } + else if (elementString.Equals(L"ALIGNMENT_BOTTOM", false)) + { + alignment = ALIGNMENT_BOTTOM; + } + + pIconListView->SetItemLayoutVerticalAlignment(alignment); + } + + // Set TextHorizontalAlignment + if (pControl->GetElement("itemTextHorizontalAlignment", elementString)) + { + HorizontalAlignment alignment = ALIGNMENT_CENTER; + if (elementString.Equals(L"ALIGNMENT_LEFT", false)) + { + alignment = ALIGNMENT_LEFT; + } + else if (elementString.Equals(L"ALIGNMENT_CENTER", false)) + { + alignment = ALIGNMENT_CENTER; + } + else if (elementString.Equals(L"ALIGNMENT_RIGHT", false)) + { + alignment = ALIGNMENT_RIGHT; + } + + pIconListView->SetTextHorizontalAlignment(alignment); + } + + // Set TextVerticalAlignment + if (pControl->GetElement("itemTextVerticalAlignment", elementString)) + { + IconListViewItemTextVerticalAlignment alignment = ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM; + if (elementString.Equals(L"ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP", false)) + { + alignment = ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_TOP; + } + else if (elementString.Equals(L"ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_MIDDLE", false)) + { + alignment = ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_MIDDLE; + } + else if (elementString.Equals(L"ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM", false)) + { + alignment = ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_INSIDE_BOTTOM; + } + else if (elementString.Equals(L"ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP", false)) + { + alignment = ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_TOP; + } + else if (elementString.Equals(L"ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_BOTTOM", false)) + { + alignment = ICON_LIST_VIEW_ITEM_TEXT_VERTICAL_ALIGNMENT_OUTSIDE_BOTTOM; + } + + pIconListView->SetTextVerticalAlignment(alignment); + } + + // Set ItemHorizontalSpacing + if (pControl->GetElement("itemHorizontalSpacing", elementString)) + { + int spacing = 0; + Base::Integer::Parse(elementString, spacing); + pIconListView->SetItemSpacing(spacing, pIconListView->GetItemVerticalSpacing()); + } + + // Set ItemVerticalSpacing + if (pControl->GetElement("itemVerticalSpacing", elementString)) + { + int spacing = 0; + Base::Integer::Parse(elementString, spacing); + pIconListView->SetItemSpacing(pIconListView->GetItemHorizontalSpacing(), spacing); + } + + // Set ItemTextSize + if (pControl->GetElement("itemTextSize", elementString)) + { + int size = 0; + Base::Integer::Parse(elementString, size); + _ICoordinateSystemTransformer* pTransform = GetTransformer(); + if (pTransform) + { + size = pTransform->Transform(size); + } + pIconListView->SetItemTextSize(size); + } + + // Set NormalItemTextColor + if (pControl->GetElement("normalItemTextColor", elementString)) + { + Color color; + ConvertStringToColor(elementString, color); + pIconListView->SetItemTextColor(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL, color); + } + + // Set PressedItemTextColor + if (pControl->GetElement("pressedItemTextColor", elementString)) + { + Color color; + ConvertStringToColor(elementString, color); + pIconListView->SetItemTextColor(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED, color); + } + + // Set HighlightedItemTextColor + if (pControl->GetElement("highlightedItemTextColor", elementString)) + { + Color color; + ConvertStringToColor(elementString, color); + pIconListView->SetItemTextColor(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED, color); + } + + // Set TouchAnimationEnabled + if (pControl->GetElement("touchAnimationEnabled", elementString)) + { + bool enabled = true; + if (elementString.Equals(L"false", false) || elementString.Equals(L"FALSE", false)) + { + enabled = false; + } + + pIconListView->SetTouchAnimationEnabled(enabled); + } + + // Set MagneticScrollSize + if (pControl->GetElement("magneticScrollSize", elementString)) + { + int size = 0; + Base::Integer::Parse(elementString, size); + pIconListView->SetMagneticScrollSize(size); + } + + return pIconListView; + +CATCH: + delete pIconListView; + return null; + + } +}; + +_IconListViewRegister::_IconListViewRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"IconListView", _IconListViewMaker::GetInstance); +} + +_IconListViewRegister::~_IconListViewRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"IconListView"); +} +static _IconListViewRegister IconListViewRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IconListViewItemEvent.cpp b/src/ui/controls/FUiCtrl_IconListViewItemEvent.cpp new file mode 100644 index 0000000..7e68787 --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListViewItemEvent.cpp @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListViewItemEvent.cpp + * @brief This is the implementation file for the _IconListViewItemEvent class. + */ + +#include +#include +#include + +#include "FUiCtrl_IconListViewItemEvent.h" +#include "FUiCtrl_IconListViewItemEventArg.h" + +namespace Tizen +{ +namespace Ui +{ +namespace Controls +{ + +_IconListViewItemEvent::_IconListViewItemEvent(void) + : __pSource(null) +{ + // Do nothing +} + +_IconListViewItemEvent::~_IconListViewItemEvent(void) +{ + // Do nothing +} + +result +_IconListViewItemEvent::Construct(const IconListView& source) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = const_cast (&source); + } + + return r; +} + +const IconListView* +_IconListViewItemEvent::GetSource(void) const +{ + return __pSource; +} + +void +_IconListViewItemEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg) +{ + // cast to IIconListViewItemEventListener + IIconListViewItemEventListener* pItemListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, (pItemListener != null), E_INVALID_ARG, "[E_INVALID_ARG] Invalid listener is used."); + + // cast to _IconListViewItemEventArg + const _IconListViewItemEventArg* pItemEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, (pItemEventArg != null), E_INVALID_ARG, "[E_INVALID_ARG] Invalid event argument is used."); + + switch (pItemEventArg->GetEventType()) + { + case EVENT_TYPE_ITEM_SELECTED: + pItemListener->OnIconListViewItemStateChanged( + const_cast(*GetSource()), pItemEventArg->GetIndex(), pItemEventArg->GetStatus()); + break; + case EVENT_TYPE_OVERLAY_BITMAP_SELECTED: + pItemListener->OnIconListViewOverlayBitmapSelected( + const_cast(*GetSource()), pItemEventArg->GetIndex(), pItemEventArg->GetOverlayBitmapId()); + break; + case EVENT_TYPE_ITEM_REORDERED: + pItemListener->OnIconListViewItemReordered( + const_cast(*GetSource()), pItemEventArg->GetFromIndex(), pItemEventArg->GetToIndex()); + break; + + default: + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid event argument is used."); + return; + } + + SetLastResult(E_SUCCESS); +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_IconListViewItemEventArg.cpp b/src/ui/controls/FUiCtrl_IconListViewItemEventArg.cpp new file mode 100644 index 0000000..1c13997 --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListViewItemEventArg.cpp @@ -0,0 +1,97 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListViewItemEventArg.cpp + * @brief This is the implementation file for the _IconListViewItemEventArg class. + */ + +#include "FUiCtrl_IconListViewItemEventArg.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_IconListViewItemEventArg::_IconListViewItemEventArg(int index, _IconListViewItemEventType eventType) + : __itemIndex(index) + , __toIndex(-1) + , __overlayBitmapId(-1) + , __itemStatus(ICON_LIST_VIEW_ITEM_CHECKED) + , __eventType(eventType) +{ + // Do nothing +} + +_IconListViewItemEventArg::~_IconListViewItemEventArg(void) +{ + // Do nothing +} + +int +_IconListViewItemEventArg::GetIndex(void) const +{ + return __itemIndex; +} + +IconListViewItemStatus +_IconListViewItemEventArg::GetStatus(void) const +{ + return __itemStatus; +} + +void +_IconListViewItemEventArg::SetStatus(IconListViewItemStatus status) +{ + __itemStatus = status; +} + +int +_IconListViewItemEventArg::GetOverlayBitmapId(void) const +{ + return __overlayBitmapId; +} + +void +_IconListViewItemEventArg::SetOverlayBitmapId(const int overlayBitmapId) +{ + __overlayBitmapId = overlayBitmapId; +} + +int +_IconListViewItemEventArg::GetFromIndex(void) const +{ + return __itemIndex; +} + +int +_IconListViewItemEventArg::GetToIndex(void) const +{ + return __toIndex; +} + +void +_IconListViewItemEventArg::SetToIndex(int toIndex) +{ + __toIndex = toIndex; +} + +_IconListViewItemEventType +_IconListViewItemEventArg::GetEventType(void) const +{ + return __eventType; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IconListViewItemImpl.cpp b/src/ui/controls/FUiCtrl_IconListViewItemImpl.cpp new file mode 100644 index 0000000..ebc532b --- /dev/null +++ b/src/ui/controls/FUiCtrl_IconListViewItemImpl.cpp @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListViewItemImpl.cpp + * @brief This is the implementation file for the _IconListViewItemImpl class. + */ + +// Includes +#include + +#include "FUiCtrl_IconListItem.h" +#include "FUiCtrl_IconListViewItemImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_IconListViewItemImpl::_IconListViewItemImpl(IconListViewItem* pIconListViewItem, _IconListItem* pItem) + : __pIconListViewItem(pIconListViewItem) + , __pIconListItem(pItem) +{ + // nothing +} + +_IconListViewItemImpl::~_IconListViewItemImpl(void) +{ + __pIconListViewItem = null; + + __pIconListItem->SetAppInfo(null); + __pIconListItem->Release(); + __pIconListItem = null; +} + +_IconListViewItemImpl* +_IconListViewItemImpl::CreateIconListViewItemImplN(IconListViewItem& pIconListViewItem, const Bitmap& bitmap, + const String* pText, const Bitmap* pSelectedBitmap, const Bitmap* pHighlightedBitmap) +{ + _IconListItem* pItem = _IconListItem::CreateIconListItemN(&pIconListViewItem); + SysTryReturn(NID_UI_CTRL, (pItem != null), null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _IconListViewItemImpl* pImpl = null; + result r = E_SUCCESS; + r = pItem->SetBitmap(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_NORMAL, &bitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl = new (std::nothrow) _IconListViewItemImpl(&pIconListViewItem, pItem); + SysTryCatch(NID_UI_CTRL, (pImpl != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + ClearLastResult(); + + pItem->SetText(pText); + pItem->SetBitmap(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_PRESSED, pSelectedBitmap); + pItem->SetBitmap(ICON_LIST_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED, pHighlightedBitmap); + + return pImpl; +CATCH: + delete pItem; + pItem = null; + + return null; +} + +result +_IconListViewItemImpl::SetOverlayBitmap(int overlayBitmapId, const Tizen::Graphics::Bitmap* pOverlayBitmap, + HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) +{ + return __pIconListItem->SetOverlayBitmap(overlayBitmapId, pOverlayBitmap, horizontalAlignment, verticalAlignment); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Indicator.cpp b/src/ui/controls/FUiCtrl_Indicator.cpp new file mode 100644 index 0000000..b10a97e --- /dev/null +++ b/src/ui/controls/FUiCtrl_Indicator.cpp @@ -0,0 +1,362 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Indicator.cpp + * @brief This is the implementation file for the _Form class. + */ + +#include +#include +#include +#include "FUiAnim_VisualElement.h" +#include "FUiAnim_VisualElementImpl.h" +#include "FUiAnim_EflNode.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_EcoreEvas.h" +#include "FUi_ResourceManager.h" +#include "FUi_Window.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Indicator.h" +#include "FUiCtrl_IndicatorManager.h" + +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +static const char* pPortraitSvcName = "elm_indicator_portrait"; +static const char* pLandScapeSvcName = "elm_indicator_landscape"; +static const char* pPortPublicKey = "__Plug_Ecore_Evas_Port"; +static const char* pLandPublicKey = "__Plug_Ecore_Evas_Land"; +static const char* pIndicatorKey = "Inidcator_Manager_Object"; +static const int CONNECTION_INTERVAL = 1000; + +_Indicator* +_Indicator::CreateIndicator(void) +{ + _Indicator* pIndicator = new (std::nothrow) _Indicator; + SysTryReturn(NID_UI_CTRL, pIndicator, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + +CATCH: + delete pIndicator; + return null; +} + +_Indicator::_Indicator(void) + : __pPortraitIndicatorEvasObject(null) + , __pLandscapeIndicatorEvasObject(null) + , __pConnectionTimer(null) + , __pPortraitSurface(null) + , __pLandScapeSurface(null) + , __pCurrentSurface(null) + , __pVisualElement(null) + , __showstate(false) + , __opacity(_INDICATOR_OPACITY_OPAQUE) +{ + SetBackgroundColor(0xff343432); + + AcquireHandle(); +} + +_Indicator::~_Indicator(void) +{ + if (__pConnectionTimer != null) + { + __pConnectionTimer->Cancel(); + delete __pConnectionTimer; + __pConnectionTimer = null; + } + + __pPortraitSurface = null; + __pLandScapeSurface = null; + __pCurrentSurface = null; +} + +result +_Indicator::SetIndicatorShowState(bool state) +{ + result r = E_SUCCESS; + + _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); + SysTryReturnResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas"); + + _Window* pWindow = GetRootWindow(); + + if (pWindow) + { + r = pEcoreEvas->SetIndicatorShowState(*pWindow, state); + } + + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __showstate = state; + + SetVisibleState(state); + + if (state) + { + SetIndicatorOpacity(__opacity); + } + + return r; +} + +result +_Indicator::SetIndicatorOpacity(_IndicatorOpacity opacity) +{ + result r = E_SUCCESS; + + if (opacity == _INDICATOR_OPACITY_OPAQUE) + { + SetBackgroundColor(0xff343432); + } + else if (opacity == _INDICATOR_OPACITY_TRANSLUCENT) + { + SetBackgroundColor(0x7f000000); + } + + __opacity = opacity; + + return r; +} + +bool +_Indicator::GetIndicatorShowState(void) const +{ + return __showstate; +} + +_IndicatorOpacity +_Indicator::GetIndicatorOpacity(void) const +{ + return __opacity; +} + +Rectangle +_Indicator::GetIndicatorBounds(void) const +{ + const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize(); + const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width); + + _ControlOrientation orientation = GetOrientation(); + + Rectangle indicatorbounds(0, 0, 0, 0); + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + indicatorbounds.width = portraitSize.width; + } + else + { + indicatorbounds.width = landscapeSize.width; + } + GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorbounds.height); + + _CoordinateSystem* pCoordSystem = _CoordinateSystem::GetInstance(); + SysTryReturn(NID_UI_CTRL, pCoordSystem, Rectangle(-1, -1, -1, -1), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed."); + + _ICoordinateSystemTransformer* pXformer = pCoordSystem->GetTransformer(); + SysTryReturn(NID_UI_CTRL, pXformer, Rectangle(-1, -1, -1, -1), E_SYSTEM, "[E_SYSTEM] Coordinate system load failed."); + + indicatorbounds = pXformer->Transform(indicatorbounds); + + return indicatorbounds; +} + +result +_Indicator::AddEvasObject(_Form* pForm) +{ + result r = E_SUCCESS; + + _Window* pWindow = GetRootWindow(); + SysTryReturn(NID_UI_CTRL, pWindow, null, E_INVALID_STATE, "[E_INVALID_STATE] Indicator is not attached main tree."); + + __pPortraitSurface = _IndicatorManager::GetInstance()->GetSurface(pWindow, _INDICATOR_ORIENTATION_PORTRAIT, pForm); + SysTryReturn(NID_UI_CTRL, __pPortraitSurface, null, E_SYSTEM, "[E_SYSTEM] Indicator can not create the surface."); + __pLandScapeSurface = _IndicatorManager::GetInstance()->GetSurface(pWindow, _INDICATOR_ORIENTATION_LANDSCAPE, pForm); + SysTryReturn(NID_UI_CTRL, __pLandScapeSurface, null, E_SYSTEM, "[E_SYSTEM] Indicator can not create the surface."); + __pPortraitIndicatorEvasObject = _IndicatorManager::GetInstance()->GetEvasObject(pWindow, pForm, _INDICATOR_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, __pPortraitIndicatorEvasObject, null, E_SYSTEM, "[E_SYSTEM] Indicator can not get the Evas_Object."); + __pLandscapeIndicatorEvasObject = _IndicatorManager::GetInstance()->GetEvasObject(pWindow, pForm, _INDICATOR_ORIENTATION_LANDSCAPE); + SysTryReturn(NID_UI_CTRL, __pLandscapeIndicatorEvasObject, null, E_SYSTEM, "[E_SYSTEM] Indicator can not get the Evas_Object."); + + _ControlOrientation orientation = GetOrientation(); + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + __pCurrentSurface = __pPortraitSurface; + } + else + { + __pCurrentSurface = __pLandScapeSurface; + } + + if (!__pVisualElement) + { + __pVisualElement = new (std::nothrow) _VisualElement; + SysTryReturn(NID_UI_CTRL, __pVisualElement, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + r = __pVisualElement->Construct(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, E_SYSTEM, "[E_SYSTEM] System error occurred."); + __pVisualElement->SetImplicitAnimationEnabled(false); + __pVisualElement->SetShowState(true); + + _VisualElement* pIndicatorVisualElement = GetVisualElement(); + pIndicatorVisualElement->AttachChild(*__pVisualElement); + } + + r = SetSurface(__pCurrentSurface); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, GetErrorMessage(r)); + + Ecore_Evas *pEe = ecore_evas_object_ecore_evas_get(__pPortraitIndicatorEvasObject); + SysTryReturn(NID_UI_CTRL, pEe, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to get evas."); + + ecore_evas_data_set(pEe, pPortPublicKey, __pPortraitIndicatorEvasObject); + ecore_evas_data_set(pEe, pLandPublicKey, __pLandscapeIndicatorEvasObject); + ecore_evas_data_set(pEe, pIndicatorKey, this); + ecore_evas_callback_delete_request_set(pEe, _Indicator::OnDisconnected); + + return r; +} + +result +_Indicator::DeleteEvasObject(void) +{ + result r = E_SUCCESS; + + _Window* pWindow = GetRootWindow(); + SysTryReturn(NID_UI_CTRL, pWindow, null, E_INVALID_STATE, "[E_INVALID_STATE] Indicator is not attached main tree."); + + r = _IndicatorManager::GetInstance()->ReleaseSurface(pWindow, _INDICATOR_ORIENTATION_PORTRAIT, __pPortraitSurface); + r = _IndicatorManager::GetInstance()->ReleaseSurface(pWindow, _INDICATOR_ORIENTATION_LANDSCAPE, __pLandScapeSurface); + + r = SetSurface(null); + + __pPortraitIndicatorEvasObject = null; + __pLandscapeIndicatorEvasObject = null; + __pPortraitSurface = null; + __pLandScapeSurface = null; + __pCurrentSurface = null; + + return r; +} + +result +_Indicator::SetSurface(VisualElementSurface* pSurface) +{ + result r = E_SUCCESS; + + if (__pVisualElement) + { + r = __pVisualElement->SetBounds(FloatRectangle(0, 0, GetSize().width, GetSize().height)); + r = __pVisualElement->SetSurface(pSurface); + } + + return r; +} + +void +_Indicator::OnChangeLayout(_ControlOrientation orientation) +{ + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + __pCurrentSurface = __pPortraitSurface; + SetSurface(__pCurrentSurface); + + evas_object_smart_member_del(__pLandscapeIndicatorEvasObject); + evas_object_show(__pPortraitIndicatorEvasObject); + evas_object_hide(__pLandscapeIndicatorEvasObject); + } + else + { + __pCurrentSurface = __pLandScapeSurface; + SetSurface(__pCurrentSurface); + + evas_object_smart_member_del(__pPortraitIndicatorEvasObject); + evas_object_show(__pLandscapeIndicatorEvasObject); + evas_object_hide(__pPortraitIndicatorEvasObject); + } +} + +result +_Indicator::OnAttachedToMainTree(void) +{ + result r = E_SUCCESS; + + if (__pCurrentSurface) + { + r = SetSurface(__pCurrentSurface); + } + + return r; +} + +void +_Indicator::OnTimerExpired(Timer& timer) +{ + Eina_Bool result = EINA_TRUE; + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + result = ecore_evas_extn_plug_connect(__pPortraitIndicatorEvasObject, pPortraitSvcName, 0, EINA_FALSE); + } + else + { + result = ecore_evas_extn_plug_connect(__pLandscapeIndicatorEvasObject, pLandScapeSvcName, 0, EINA_FALSE); + } + + if (result == EINA_TRUE) + { + timer.Cancel(); + } + else + { + timer.Start(CONNECTION_INTERVAL); + } +} + +void +_Indicator::OnDisconnected(Ecore_Evas *pEe) +{ + _Indicator* pIndicator = (_Indicator*)ecore_evas_data_get(pEe, pIndicatorKey); + SysTryReturnVoidResult(NID_UI_CTRL, pIndicator, E_SYSTEM, "[E_SYSTEM] Unable to get Indicator Object"); + + if (pIndicator->__pConnectionTimer == null) + { + pIndicator->__pConnectionTimer = new (std::nothrow) Timer; + if (pIndicator->__pConnectionTimer == null) + { + return; + } + + result r = pIndicator->__pConnectionTimer->Construct(*pIndicator); + if (r != E_SUCCESS) + { + delete pIndicator->__pConnectionTimer; + pIndicator->__pConnectionTimer = null; + + return; + } + } + + pIndicator->__pConnectionTimer->Start(CONNECTION_INTERVAL); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_IndicatorManager.cpp b/src/ui/controls/FUiCtrl_IndicatorManager.cpp new file mode 100644 index 0000000..d057a1a --- /dev/null +++ b/src/ui/controls/FUiCtrl_IndicatorManager.cpp @@ -0,0 +1,382 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IndicatorManager.cpp + * @brief This is the implementation file for the _IndicatorManager class. + */ + +#include +#include +#include +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_EflLayer.h" +#include "FUi_EcoreEvas.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_Window.h" +#include "FUi_ControlManager.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_IndicatorManager.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Frame.h" + +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + + +namespace Tizen { namespace Ui { namespace Controls +{ + +static const char* pPortraitSvcName = "elm_indicator_portrait"; +static const char* pLandScapeSvcName = "elm_indicator_landscape"; +const int NUMBER_OF_OBJECT = 2; + +_IndicatorManager* _IndicatorManager::__pInstance = null; + +_IndicatorManager* +_IndicatorManager::GetInstance(void) +{ + return __pInstance; +} + +void +_IndicatorManager::Initialize(void) +{ + if (!__pInstance) + { + __pInstance = new (std::nothrow)_IndicatorManager; + SysAssert(__pInstance); + } +} + +void +_IndicatorManager::InitializeInstance(void) +{ + static pthread_once_t once_block = PTHREAD_ONCE_INIT; + + if (!__pInstance) + { + pthread_once(&once_block, Initialize); + } +} + +void +_IndicatorManager::ReleaseInstance(void) +{ + if (__pInstance) + { + delete __pInstance; + __pInstance = null; + } +} + +_IndicatorManager::_IndicatorManager(void) // [ToDo] exception check. +{ + __indicatorMap.Construct(); +} + +_IndicatorManager::~_IndicatorManager(void) +{ + IMapEnumeratorT<_Window*, IndicatorSurface*>* pEnumerator = __indicatorMap.GetMapEnumeratorN(); + if (pEnumerator) + { + while(pEnumerator->MoveNext() == E_SUCCESS) + { + IndicatorSurface* pIndicatorSurface = null; + pEnumerator->GetValue(pIndicatorSurface); + + if (pIndicatorSurface) + { + delete pIndicatorSurface[0].pPortraitSurface; + delete pIndicatorSurface[1].pPortraitSurface; + delete pIndicatorSurface[0].pLandscapeSurface; + delete pIndicatorSurface[1].pLandscapeSurface; + delete [] pIndicatorSurface; + } + } + delete pEnumerator; + } + + __indicatorMap.RemoveAll(); +} + +VisualElementSurface* +_IndicatorManager::GetSurface(_Window* pWindow, _IndicatorOrientation orientation, _Form* pForm) const +{ + result r = E_SUCCESS; + + IndicatorSurface* pIndicatorSurfaceArray = null; + r = __indicatorMap.GetValue(pWindow, pIndicatorSurfaceArray); + SysTryReturn(NID_UI_CTRL, pIndicatorSurfaceArray, null, E_SYSTEM, "[E_SYSTEM] Unable to get Indicator"); + + + for(int i = 0 ; i < NUMBER_OF_OBJECT ; i++) + { + if (pForm == pIndicatorSurfaceArray[i].pForm) + { + if ((orientation == _INDICATOR_ORIENTATION_PORTRAIT) && (pIndicatorSurfaceArray[i].portraitSurfaceUsed)) + { + return pIndicatorSurfaceArray[i].pPortraitSurface; + } + else if((orientation == _INDICATOR_ORIENTATION_LANDSCAPE) && (pIndicatorSurfaceArray[i].landscapeSurfaceUsed)) + { + return pIndicatorSurfaceArray[i].pLandscapeSurface; + } + } + } + + if (IsFull(pIndicatorSurfaceArray)) + { + _Frame* pFrame = dynamic_cast<_Frame*>(pWindow); + if (pFrame) + { + _Form* pCurrentForm = pFrame->GetCurrentForm(); + if (pCurrentForm == pForm) + { + int count = pFrame->GetChildCount(); + pCurrentForm = dynamic_cast<_Form*>(pFrame->GetChild(count-2)); + } + + if (pCurrentForm) + { + for(int i = 0 ; i < NUMBER_OF_OBJECT ; i++) + { + if (pIndicatorSurfaceArray[i].pForm != pCurrentForm) + { + pIndicatorSurfaceArray[i].pForm->DeleteIndicatorObject(); + break; + } + } + } + } + } + + VisualElementSurface* pSurface = null; + for(int i = 0 ; i < NUMBER_OF_OBJECT ; i++) + { + if (orientation == _INDICATOR_ORIENTATION_PORTRAIT) + { + if (!(pIndicatorSurfaceArray[i].portraitSurfaceUsed)) + { + pSurface = pIndicatorSurfaceArray[i].pPortraitSurface; + pIndicatorSurfaceArray[i].portraitSurfaceUsed = true; + pIndicatorSurfaceArray[i].pForm = pForm; + break; + } + } + else if(orientation == _INDICATOR_ORIENTATION_LANDSCAPE) + { + if (!(pIndicatorSurfaceArray[i].landscapeSurfaceUsed)) + { + pSurface = pIndicatorSurfaceArray[i].pLandscapeSurface; + pIndicatorSurfaceArray[i].landscapeSurfaceUsed = true; + pIndicatorSurfaceArray[i].pForm = pForm; + break; + } + } + } + + return pSurface; +} + +result +_IndicatorManager::ReleaseSurface(_Window* pWindow, _IndicatorOrientation orientation, VisualElementSurface* pSurface) +{ + result r = E_SUCCESS; + IndicatorSurface* pIndicatorSurfaceArray = null; + r = __indicatorMap.GetValue(pWindow, pIndicatorSurfaceArray); + + if (pIndicatorSurfaceArray) + { + for(int i = 0 ; i < NUMBER_OF_OBJECT ; i++) + { + if (orientation == _INDICATOR_ORIENTATION_PORTRAIT) + { + if (pIndicatorSurfaceArray[i].portraitSurfaceUsed) + { + if (pSurface == pIndicatorSurfaceArray[i].pPortraitSurface) + { + pIndicatorSurfaceArray[i].portraitSurfaceUsed = false; + pIndicatorSurfaceArray[i].pForm = null; + break; + } + } + } + else if(orientation == _INDICATOR_ORIENTATION_LANDSCAPE) + { + if (pSurface == pIndicatorSurfaceArray[i].pLandscapeSurface) + { + pIndicatorSurfaceArray[i].landscapeSurfaceUsed = false; + pIndicatorSurfaceArray[i].pForm = null; + break; + } + } + } + } + return r;; +} + +result +_IndicatorManager::AddWindow(_Window* pWindow) +{ + result r = E_SYSTEM; + + IndicatorSurface* pIndicatorSurfaceArray = MakeEvasSurfaceArrayN(pWindow); + + r = __indicatorMap.Add(pWindow, pIndicatorSurfaceArray); + + return r; +} + +result +_IndicatorManager::DeleteWindow(_Window* pWindow) +{ + result r = E_SUCCESS; + IndicatorSurface* pIndicatorSurfaceArray = null; + + r = __indicatorMap.GetValue(pWindow, pIndicatorSurfaceArray); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS && pIndicatorSurfaceArray, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The given binding ID is not registered."); + + delete [] pIndicatorSurfaceArray; + __indicatorMap.Remove(pWindow); + + return r; +} + +IndicatorSurface* +_IndicatorManager::MakeEvasSurfaceArrayN(_Window* pWindow) +{ + Eina_Bool result = EINA_TRUE; + + _Frame* pFrame = dynamic_cast<_Frame*>(pWindow); + if (!pFrame) + { + return null; + } + + IndicatorSurface* pIndicatorSurfaceArray = new IndicatorSurface[NUMBER_OF_OBJECT]; + + Dimension portraitsize = GetIndicatorSize(_INDICATOR_ORIENTATION_PORTRAIT); + Dimension landscapesize = GetIndicatorSize(_INDICATOR_ORIENTATION_LANDSCAPE); + + _RootVisualElement* pRootVisualElement = pWindow->GetRootVisualElement(); + _EflLayer* pEflLayer = static_cast<_EflLayer*>(pRootVisualElement->GetNativeLayer()); + Ecore_Evas* pEcore_Evas = pEflLayer->GetEcoreEvas(); + SysTryCatch(NID_UI_CTRL, pEcore_Evas, , E_SYSTEM, "[E_SYSTEM] Unable to get Ecore_Evas object"); + + //Get indicator Image Object + for(int i = 0 ; i < NUMBER_OF_OBJECT ; i++) + { + Evas_Object* pPortraitEvasObject = ecore_evas_extn_plug_new(pEcore_Evas); + SysTryCatch(NID_UI_CTRL, pPortraitEvasObject, , E_SYSTEM, "[E_SYSTEM] Unable to get evas object"); + + Evas_Object* pLandscapeEvasObject = ecore_evas_extn_plug_new(pEcore_Evas); + SysTryCatch(NID_UI_CTRL, pLandscapeEvasObject, , E_SYSTEM, "[E_SYSTEM] Unable to get evas object"); + + result = ecore_evas_extn_plug_connect(pPortraitEvasObject, pPortraitSvcName, 0, EINA_FALSE); + result = ecore_evas_extn_plug_connect(pLandscapeEvasObject, pLandScapeSvcName, 0, EINA_FALSE); + + evas_object_resize(pPortraitEvasObject, portraitsize.width, portraitsize.height); + evas_object_resize(pLandscapeEvasObject, landscapesize.width, landscapesize.height); + evas_object_move(pPortraitEvasObject, 0, 0); + evas_object_move(pLandscapeEvasObject, 0, 0); + + VisualElementSurface* pPortraitSurface = _VisualElementSurfaceImpl::CreateSurfaceUsingExistingObjectN(*pWindow->GetDisplayContext(), reinterpret_cast(pPortraitEvasObject), portraitsize); + VisualElementSurface* pLandScapeSurface = _VisualElementSurfaceImpl::CreateSurfaceUsingExistingObjectN(*pWindow->GetDisplayContext(), reinterpret_cast(pLandscapeEvasObject), landscapesize); + + pIndicatorSurfaceArray[i].pPortraitEvasObject = pPortraitEvasObject; + pIndicatorSurfaceArray[i].pLandscapeEvasObject = pLandscapeEvasObject; + pIndicatorSurfaceArray[i].pPortraitSurface = pPortraitSurface; + pIndicatorSurfaceArray[i].pLandscapeSurface = pLandScapeSurface; + pIndicatorSurfaceArray[i].portraitSurfaceUsed = false; + pIndicatorSurfaceArray[i].landscapeSurfaceUsed = false; + pIndicatorSurfaceArray[i].pForm = null; + } + + return pIndicatorSurfaceArray; + +CATCH: + delete [] pIndicatorSurfaceArray; + return null; +} + +bool +_IndicatorManager::IsFull(IndicatorSurface* pIndicatorSurfaceArray) const +{ + if (pIndicatorSurfaceArray[0].portraitSurfaceUsed && pIndicatorSurfaceArray[0].landscapeSurfaceUsed + && pIndicatorSurfaceArray[1].portraitSurfaceUsed && pIndicatorSurfaceArray[1].landscapeSurfaceUsed) + { + return true; + } + + return false; +} + +Evas_Object* +_IndicatorManager::GetEvasObject(_Window* pWindow, _Form* pForm, _IndicatorOrientation orientation) const +{ + Evas_Object* pEvasObject = null; + + result r = E_SUCCESS; + IndicatorSurface* pIndicatorSurfaceArray = null; + r = __indicatorMap.GetValue(pWindow, pIndicatorSurfaceArray); + SysTryReturn(NID_UI_CTRL, pIndicatorSurfaceArray, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + for(int i = 0 ; i < NUMBER_OF_OBJECT ; i++) + { + if (pForm == pIndicatorSurfaceArray[i].pForm) + { + if (orientation == _INDICATOR_ORIENTATION_PORTRAIT) + { + pEvasObject = pIndicatorSurfaceArray[i].pPortraitEvasObject; + } + else if(orientation == _INDICATOR_ORIENTATION_LANDSCAPE) + { + pEvasObject = pIndicatorSurfaceArray[i].pLandscapeEvasObject; + } + } + } + return pEvasObject; +} + +Dimension +_IndicatorManager::GetIndicatorSize(_IndicatorOrientation orientation) const +{ + const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize(); + const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width); + + Rectangle indicatorbounds(0, 0, 0, 0); + + if (orientation == _INDICATOR_ORIENTATION_PORTRAIT) + { + indicatorbounds.width = portraitSize.width; + } + else + { + indicatorbounds.width = landscapeSize.width; + } + GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, indicatorbounds.height); + + Dimension size(0, 0); + size.width = indicatorbounds.width; + size.height = indicatorbounds.height; + + return size; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_InputPad.cpp b/src/ui/controls/FUiCtrl_InputPad.cpp new file mode 100644 index 0000000..c8f5fd4 --- /dev/null +++ b/src/ui/controls/FUiCtrl_InputPad.cpp @@ -0,0 +1,324 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_InputPad.cpp + * @brief This is the implementation file for the _InputPad class. + */ + +#include + +#include "FUiCtrl_InputPad.h" +#include "FUiCtrl_InputPadPresenter.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +const int INPUTPAD_BUTTON_MAX = 12; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_InputPad::_InputPad(void) + : __pInputPadPresenter(null) +{ + ClearLastResult(); +} + +_InputPad::~_InputPad(void) +{ + delete __pInputPadPresenter; + __pInputPadPresenter = null; + + RemoveAllAccessibilityElement(); + + ClearLastResult(); +} + +result +_InputPad::Construct(const Rectangle& bounds) +{ + result r = E_SUCCESS; + + if(likely((_AccessibilityManager::IsActivated()))) + { + InitializeAccessebilityElementMonthNames(); + } + + SetBounds(bounds); + + __pInputPadPresenter = new (std::nothrow) _InputPadPresenter(this); + SysTryReturnResult(NID_UI_CTRL, __pInputPadPresenter, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pInputPadPresenter->Construct(bounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to construct the instance of presenter for Inputpad"); + + AcquireHandle(); + + if(likely((_AccessibilityManager::IsActivated()))) + { + if (GetAccessibilityContainer() != null) + { + GetAccessibilityContainer()->Activate(true); + } + } + + ClearLastResult(); + + return r; + +CATCH: + delete __pInputPadPresenter; + __pInputPadPresenter = null; + + return r; +} + +result +_InputPad::SetInputPadEventListener(const _IInputPadEventListener& listener) +{ + ClearLastResult(); + + SysAssertf((__pInputPadPresenter != null), "The instance of InputpadPresenter is not yet constructed."); + + __pInputPadPresenter->SetInputPadEventListener(listener); + + return E_SUCCESS; +} + +void +_InputPad::SetInputPadStyle(const _InputPadStyle style) +{ + SysTryReturnVoidResult(NID_UI_CTRL, (style >= INPUTPAD_STYLE_NORMAL), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The style provided is not present in the _InputPadStyle list."); + + SysTryReturnVoidResult(NID_UI_CTRL, (style < INPUTPAD_STYLE_MAX), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The style provided is not a valid _InputPadStyle value."); + + if (style == __pInputPadPresenter->GetInputPadStyle()) + { + if (HasAccessibilityElement() == true) + { + return; + } + } + else + { + RemoveAllAccessibilityElement(); + } + + __pInputPadPresenter->SetInputPadStyle(style); + SetAllAccessibilityElement(); + + return; +} + +String& +_InputPad::GetAccessebilityElementMonthName(int number) +{ + SysTryReturn(NID_UI_CTRL, (number >= 0), __pMonthNames[0], E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the month name."); + + return __pMonthNames[number]; +} + +void +_InputPad::SetFont(Font* pFont) +{ + __pInputPadPresenter->SetFont(pFont); + + return; +} + +void +_InputPad::OnBoundsChanged(void) +{ + if (__pInputPadPresenter != null) + { + __pInputPadPresenter->LoadProperties(GetOrientation()); + SetBoundsAllAccessibilityElement(); + } + + return; +} + +void +_InputPad::OnDraw(void) +{ + __pInputPadPresenter->Draw(); + + return; +} + +bool +_InputPad::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pInputPadPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_InputPad::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pInputPadPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_InputPad::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pInputPadPresenter->OnTouchCanceled(source, touchinfo); +} + +void +_InputPad::OnChangeLayout(_ControlOrientation orientation) +{ + if (__pInputPadPresenter != null) + { + __pInputPadPresenter->EnableLayoutChangedFlag(); + __pInputPadPresenter->LoadProperties(orientation); + __pInputPadPresenter->SetInputPadStyle(__pInputPadPresenter->GetInputPadStyle()); + SetBoundsAllAccessibilityElement(); + } + + return; +} + +bool +_InputPad::HasAccessibilityElement(void) +{ + return __accessibilityElements.GetCount() > 0; +} + +void +_InputPad::SetAllAccessibilityElement(void) +{ + if(likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer != null) + { + pContainer->RemoveAllElement(); + + for (int index = 0; index < INPUTPAD_BUTTON_MAX; index++) + { + int returnValue = __pInputPadPresenter->GetReturnValue(index); + if (returnValue >= 0) + { + _AccessibilityElement* pElement = new _AccessibilityElement(true); + if (pElement != null) + { + if (__pInputPadPresenter->GetInputPadStyle() == INPUTPAD_STYLE_ALPHA) + { + pElement->SetLabel(__pMonthNames[index]); + } + else + { + pElement->SetLabel(Integer::ToString(returnValue)); + } + pElement->SetTrait(ACCESSIBILITY_TRAITS_NONE); +// pElement->SetTrait(ACCESSIBILITY_TRAITS_INPUTPAD); + pElement->SetBounds(__pInputPadPresenter->GetButtonBounds(index)); + pContainer->AddElement(*pElement); + __accessibilityElements.Add(pElement); + } + } + } + } + + return; +} + +void +_InputPad::SetBoundsAllAccessibilityElement(void) +{ + if(likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityElement* pElement = null; + IEnumeratorT<_AccessibilityElement*>* pEnumerator = __accessibilityElements.GetEnumeratorN(); + int index = 0; + while (pEnumerator->MoveNext() == E_SUCCESS) + { + if (pEnumerator->GetCurrent(pElement) == E_SUCCESS) + { + while (__pInputPadPresenter->GetReturnValue(index) < 0) + { + index++; + } + pElement->SetBounds(__pInputPadPresenter->GetButtonBounds(index)); + } + index++; + } + delete pEnumerator; + + return; +} + +void +_InputPad::RemoveAllAccessibilityElement(void) +{ + if(likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityElement* pElement = null; + while (HasAccessibilityElement() == true) + { + if ((__accessibilityElements.GetAt(0, pElement)) == E_SUCCESS) + { + __accessibilityElements.RemoveAt(0); + pElement->GetParent()->RemoveElement(*pElement); + } + else + { + __accessibilityElements.RemoveAt(0); + } + } + + return; +} + +void +_InputPad::InitializeAccessebilityElementMonthNames(void) +{ + __pMonthNames[0] = L"January"; + __pMonthNames[1] = L"February"; + __pMonthNames[2] = L"March"; + __pMonthNames[3] = L"April"; + __pMonthNames[4] = L"May"; + __pMonthNames[5] = L"June"; + __pMonthNames[6] = L"July"; + __pMonthNames[7] = L"August"; + __pMonthNames[8] = L"September"; + __pMonthNames[9] = L"October"; + __pMonthNames[10] = L"November"; + __pMonthNames[11] = L"December"; + + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_InputPadPresenter.cpp b/src/ui/controls/FUiCtrl_InputPadPresenter.cpp new file mode 100644 index 0000000..7b7b927 --- /dev/null +++ b/src/ui/controls/FUiCtrl_InputPadPresenter.cpp @@ -0,0 +1,619 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_InputPadPresenter.cpp + * @brief This is the implementation file for the _InputPadPresenter class. + */ + +#include +#include +#include + +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_InputPad.h" +#include "FUiCtrl_InputPadPresenter.h" +#include "FUiCtrl_DateTimeUtils.h" + +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_InputPadPresenter::_InputPadPresenter(_InputPad* pInputPad) + : __pInputPad(pInputPad) + , __pInputPadEventListener(null) + , __pFont(null) + , __pKeypadBackgroundBitmap(null) + , __pKeypadButtonNormalPlainBitmap(null) + , __pKeypadButtonPressedPlainBitmap(null) + , __pKeypadButtonNormalEffectBitmap(null) + , __pKeypadButtonPressedEffectBitmap(null) + , __inputPadStyle(INPUTPAD_STYLE_NORMAL) + , __buttonWidth(0) + , __buttonHeight(0) + , __startX(0) + , __startY(0) + , __marginX(0) + , __marginY(0) + , __pressedIndex(-1) + , __isLayoutChanged(false) +{ +} + +_InputPadPresenter::~_InputPadPresenter(void) +{ + delete __pFont; + __pFont = null; + + delete __pKeypadBackgroundBitmap; + __pKeypadBackgroundBitmap = null; + + delete __pKeypadButtonNormalPlainBitmap; + __pKeypadButtonNormalPlainBitmap = null; + + delete __pKeypadButtonPressedPlainBitmap; + __pKeypadButtonPressedPlainBitmap = null; + + delete __pKeypadButtonNormalEffectBitmap; + __pKeypadButtonNormalEffectBitmap = null; + + delete __pKeypadButtonPressedEffectBitmap; + __pKeypadButtonPressedEffectBitmap = null; +} + +result +_InputPadPresenter::Construct(const Rectangle& bounds) +{ + result r = E_SUCCESS; + + r = LoadProperties(__pInputPad->GetOrientation()); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, + "A system error has occurred. Failed to load the properties for input pad."); + + r = LoadResource(); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, + "A system error has occurred. Failed to load the resource for input pad."); + + r = InitializeTextObjects(); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, + "A system error has occurred. Failed to initialize the text objects for input pad."); + + return r; +} + +result +_InputPadPresenter::LoadProperties(_ControlOrientation orientation) +{ + int marginTop = 0; + + GET_SHAPE_CONFIG(INPUTPAD::BUTTON_WIDTH, orientation, __buttonWidth); + GET_SHAPE_CONFIG(INPUTPAD::BUTTON_HEIGHT, orientation, __buttonHeight); + GET_SHAPE_CONFIG(INPUTPAD::BUTTON_HORIZONTAL_MARGIN, orientation, __marginX); + GET_SHAPE_CONFIG(INPUTPAD::BUTTON_VERTICAL_MARGIN, orientation, __marginY); + GET_SHAPE_CONFIG(INPUTPAD::TOP_MARGIN, orientation, marginTop); + + __startX = (__pInputPad->GetBounds().width - (__buttonWidth + __marginX) * INPUTPAD_BUTTON_COLUMN_MAX + __marginX) / 2; + __startY = marginTop; + + return E_SUCCESS; +} + +result +_InputPadPresenter::LoadResource(void) +{ + result r = E_SUCCESS; + + Color buttonNormalColor; + Color buttonPressedColor; + + Bitmap* pBgNormalBitmap = null; + Bitmap* pBgEffectBitmap = null; + + GET_COLOR_CONFIG(INPUTPAD::BUTTON_BG_NORMAL, buttonNormalColor); + GET_COLOR_CONFIG(INPUTPAD::BUTTON_BG_PRESSED, buttonPressedColor); + + r = GET_BITMAP_CONFIG_N(INPUTPAD::BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBgNormalBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = GET_BITMAP_CONFIG_N(INPUTPAD::BUTTON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBgEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(INPUTPAD::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pKeypadBackgroundBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pKeypadButtonNormalPlainBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBgNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalColor); + SysTryCatch(NID_UI_CTRL, (__pKeypadButtonNormalPlainBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pKeypadButtonPressedPlainBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBgNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonPressedColor); + SysTryCatch(NID_UI_CTRL, (__pKeypadButtonPressedPlainBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pKeypadButtonNormalEffectBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBgEffectBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonNormalColor); + SysTryCatch(NID_UI_CTRL, (__pKeypadButtonNormalEffectBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pKeypadButtonPressedEffectBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBgEffectBitmap, Color::GetColor(COLOR_ID_MAGENTA), buttonPressedColor); + SysTryCatch(NID_UI_CTRL, (__pKeypadButtonPressedEffectBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pBgNormalBitmap; + delete pBgEffectBitmap; + + return r; + +CATCH: + delete pBgNormalBitmap; + pBgNormalBitmap = null; + + delete pBgEffectBitmap; + pBgEffectBitmap = null; + + delete __pKeypadBackgroundBitmap; + __pKeypadBackgroundBitmap = null; + + delete __pKeypadButtonNormalPlainBitmap; + __pKeypadButtonNormalPlainBitmap = null; + + delete __pKeypadButtonPressedPlainBitmap; + __pKeypadButtonPressedPlainBitmap = null; + + delete __pKeypadButtonNormalEffectBitmap; + __pKeypadButtonNormalEffectBitmap = null; + + delete __pKeypadButtonPressedEffectBitmap; + __pKeypadButtonPressedEffectBitmap = null; + + return r; +} + +result +_InputPadPresenter::InitializeTextObjects(void) +{ + result r = E_SUCCESS; + + // Create TextObject + r = __textObject.Construct(); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + __textObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __textObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __textObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + r = __guideTextObject.Construct(); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + __guideTextObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT | TEXT_OBJECT_ALIGNMENT_TOP); + __guideTextObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __guideTextObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + return r; +} + +void +_InputPadPresenter::SetInputPadEventListener(const _IInputPadEventListener& listener) +{ + __pInputPadEventListener = const_cast <_IInputPadEventListener*>(&listener); + + return; +} + +result +_InputPadPresenter::SetInputPadStyle(const _InputPadStyle style) +{ + if (style != __inputPadStyle || __isLayoutChanged == true) + { + __isLayoutChanged = false; + + __inputPadStyle = style; + } + __pressedIndex = -1; + + return E_SUCCESS; +} + +_InputPadStyle +_InputPadPresenter::GetInputPadStyle(void) const +{ + return __inputPadStyle; +} + +Rectangle +_InputPadPresenter::GetButtonBounds(int index) const +{ + Rectangle buttonBounds; + + buttonBounds.x = __startX + (index % INPUTPAD_BUTTON_COLUMN_MAX) * (__buttonWidth + __marginX); + buttonBounds.y = __startY + (index / INPUTPAD_BUTTON_COLUMN_MAX) * (__buttonHeight + __marginY); + buttonBounds.width = __buttonWidth; + buttonBounds.height = __buttonHeight; + + return buttonBounds; +} + +result +_InputPadPresenter::Draw(void) +{ + result r = E_SUCCESS; + Rectangle bgBounds; + + Canvas* pCanvas = __pInputPad->GetCanvasN(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), r, "Propagating."); + + bgBounds = pCanvas->GetBounds(); + + if(__pKeypadBackgroundBitmap != null) + { + r = pCanvas->DrawNinePatchedBitmap(bgBounds, *__pKeypadBackgroundBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = DrawAllButtons(*pCanvas); + + delete pCanvas; + pCanvas = null; + + return r; + +CATCH: + delete pCanvas; + pCanvas = null; + + return r; +} + +void +_InputPadPresenter::EnableLayoutChangedFlag(void) +{ + __isLayoutChanged = true; + + return; +} + +void +_InputPadPresenter::SetFont(Font* pFont) +{ + if (__pFont != null) + { + delete __pFont; + __pFont = null; + } + + __pFont = _FontImpl::CloneN(*pFont); + SysTryReturnVoidResult(NID_UI_CTRL, __pFont != null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return; +} + +result +_InputPadPresenter::DrawAllButtons(Canvas& canvas) +{ + result r = E_SUCCESS; + + for (int i = 0; i < INPUTPAD_BUTTON_MAX; i++) + { + r |= DrawButton(canvas, i); + } + + if (r != E_SUCCESS) + { + return E_SYSTEM; + } + + return E_SUCCESS; +} + +result +_InputPadPresenter::DrawButton(Canvas& canvas, int index) +{ + result r = E_SUCCESS; + Color textColor; + + Rectangle buttonBounds = GetButtonBounds(index); + int returnValue = GetReturnValue(index); + + // Do not Draw Extra Buttons in case of Numeric Keypad + if (returnValue < 0) + { + return E_SUCCESS; + } + + if (__pressedIndex == index) + { + if (__pKeypadButtonPressedEffectBitmap != null) + { + r = canvas.DrawNinePatchedBitmap(buttonBounds, *__pKeypadButtonPressedEffectBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + } + + if (__pKeypadButtonPressedPlainBitmap != null) + { + r = canvas.DrawNinePatchedBitmap(buttonBounds, *__pKeypadButtonPressedPlainBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + } + } + else + { + if (__pKeypadButtonNormalEffectBitmap != null) + { + r = canvas.DrawNinePatchedBitmap(buttonBounds, *__pKeypadButtonNormalEffectBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + } + + if (__pKeypadButtonNormalPlainBitmap != null) + { + r = canvas.DrawNinePatchedBitmap(buttonBounds, *__pKeypadButtonNormalPlainBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + } + } + + if (__pressedIndex == index) + { + GET_COLOR_CONFIG(INPUTPAD::TEXT_PRESSED, textColor); + } + else + { + GET_COLOR_CONFIG(INPUTPAD::TEXT_NORMAL, textColor); + } + + // Draw text + if (__inputPadStyle == INPUTPAD_STYLE_ALPHA) + { + // Calculate text bounds + int textCorrectionY = 0; + GET_SHAPE_CONFIG(INPUTPAD::TEXT_CORRECTION_Y, __pInputPad->GetOrientation(), textCorrectionY); + + buttonBounds.y += textCorrectionY; + + _DateTimeUtils dateTimeUtils; + String text = dateTimeUtils.GetMonthString(returnValue); + + r = __textObject.RemoveAll(); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + TextSimple* pSimpleText = new (std::nothrow)TextSimple((wchar_t*)text.GetPointer(), text.GetLength(), + TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryReturnResult(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __textObject.AppendElement(*pSimpleText); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength()); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + int fontSize = 0; + GET_SHAPE_CONFIG(INPUTPAD::ALPHA_FONT_SIZE, __pInputPad->GetOrientation(), fontSize); + + r = _FontImpl::GetInstance(*__pFont)->SetStyle(FONT_STYLE_BOLD); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = _FontImpl::GetInstance(*__pFont)->SetSize(fontSize); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = __textObject.SetFont(__pFont, 0, __textObject.GetTextLength()); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = __textObject.SetBounds(buttonBounds); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = __textObject.Draw(*_CanvasImpl::GetInstance(canvas)); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + // Draw guide text + int guideTextCorrectionX = 0; + GET_SHAPE_CONFIG(INPUTPAD::GUIDE_CORRECTION_X, __pInputPad->GetOrientation(), guideTextCorrectionX); + + buttonBounds.width -= guideTextCorrectionX; + + Color guideTextColor; + GET_COLOR_CONFIG(INPUTPAD::GUIDE_TEXT_NORMAL, guideTextColor); + + String guideText = Integer::ToString(returnValue); + + r = __guideTextObject.RemoveAll(); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + TextSimple* pSimpleTextForGuideText = new (std::nothrow)TextSimple((wchar_t*)guideText.GetPointer(), + guideText.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryReturnResult(NID_UI_CTRL, (pSimpleTextForGuideText != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __guideTextObject.AppendElement(*pSimpleTextForGuideText); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = __guideTextObject.SetForegroundColor(guideTextColor, 0, __guideTextObject.GetTextLength()); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + GET_SHAPE_CONFIG(INPUTPAD::GUIDE_FONT_SIZE, __pInputPad->GetOrientation(), fontSize); + + r = _FontImpl::GetInstance(*__pFont)->SetStyle(FONT_STYLE_PLAIN); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = _FontImpl::GetInstance(*__pFont)->SetSize(fontSize); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = __guideTextObject.SetFont(__pFont, 0, __guideTextObject.GetTextLength()); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = __guideTextObject.SetBounds(buttonBounds); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = __guideTextObject.Draw(*_CanvasImpl::GetInstance(canvas)); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + } + else if (returnValue >= 0) + { + String text = Integer::ToString(returnValue); + + r = __textObject.RemoveAll(); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + TextSimple* pSimpleText = new (std::nothrow)TextSimple((wchar_t*)text.GetPointer(), + text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryReturnResult(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __textObject.AppendElement(*pSimpleText); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + result r = E_SUCCESS; + + r = __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength()); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + int fontSize = 0; + + GET_SHAPE_CONFIG(INPUTPAD::NUMERIC_FONT_SIZE, __pInputPad->GetOrientation(), fontSize); + + r = _FontImpl::GetInstance(*__pFont)->SetStyle(FONT_STYLE_BOLD); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = _FontImpl::GetInstance(*__pFont)->SetSize(fontSize); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = __textObject.SetFont(__pFont, 0, __textObject.GetTextLength()); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = __textObject.SetBounds(buttonBounds); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = __textObject.Draw(*_CanvasImpl::GetInstance(canvas)); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + } + + return E_SUCCESS; +} + +result +_InputPadPresenter::RefreshButton(int index) +{ + Canvas* pCanvas = __pInputPad->GetCanvasN(); + SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), GetLastResult(), "Propagating."); + + result r = DrawButton(*pCanvas, index); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to draw the keypad button."); + + delete pCanvas; + pCanvas = null; + + if (__pInputPad->GetVisualElement() != null) + { + __pInputPad->GetVisualElement()->SetFlushNeeded(); + } + + return r; + +CATCH: + delete pCanvas; + pCanvas = null; + + return r; +} + +int +_InputPadPresenter::GetIndexFromTouchedPosition(const Point& point) const +{ + int correctionValue = 0; + + GET_FIXED_VALUE_CONFIG(INPUTPAD::BUTTON_TOUCH_CORRECTION_Y, __pInputPad->GetOrientation(), correctionValue); + + if (point.x < (__startX - correctionValue) || point.y < (__startY - correctionValue)) + { + return -1; + } + + int row = (point.y - __startY + __marginY + correctionValue) / (__buttonHeight + __marginY); + int col = (point.x - __startX + __marginX) / (__buttonWidth + __marginX); + if (row >= INPUTPAD_BUTTON_ROW_MAX || col >= INPUTPAD_BUTTON_COLUMN_MAX) + { + return -1; + } + + return row * INPUTPAD_BUTTON_COLUMN_MAX + col; +} + +int +_InputPadPresenter::GetReturnValue(int index) const +{ + if (__inputPadStyle == INPUTPAD_STYLE_NORMAL) + { + if (index >= INPUTPAD_NUMBER_1 && index <= INPUTPAD_NUMBER_9) + { + return index + 1; + } + else if (index == INPUTPAD_NUMBER_0) + { + return 0; + } + } + else if (__inputPadStyle == INPUTPAD_STYLE_ALPHA) + { + return index + 1; + } + + return -1; +} + +bool +_InputPadPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pInputPad) + { + return false; + } + + __pressedIndex = GetIndexFromTouchedPosition(touchinfo.GetCurrentPosition()); + if (__pressedIndex >= 0) + { + RefreshButton(__pressedIndex); + if (__pInputPadEventListener != null) + { + __pInputPadEventListener->OnInputPadValueChanged(source, GetReturnValue(__pressedIndex)); + } + + return true; + } + + return false; +} + +bool +_InputPadPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pInputPad) + { + return false; + } + + if (__pressedIndex >= 0) + { + int refreshIndex = __pressedIndex; + __pressedIndex = -1; + RefreshButton(refreshIndex); + + return true; + } + + return false; +} + +bool +_InputPadPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return OnTouchReleased(source, touchinfo); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Keypad.cpp b/src/ui/controls/FUiCtrl_Keypad.cpp new file mode 100644 index 0000000..25ff3a8 --- /dev/null +++ b/src/ui/controls/FUiCtrl_Keypad.cpp @@ -0,0 +1,797 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_Keypad.cpp +* @brief This file contains implementation of _Keypad class +* +* This file contains implementation of _Keypad class. +*/ + +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_EcoreEvas.h" +#include "FUi_EcoreEvasMgr.h" +#include "FUi_CoordinateSystemUtils.h" +#include "FUiCtrlForm.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Keypad.h" +#include "FUiCtrl_Toolbar.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +namespace Tizen { namespace Ui { namespace Controls +{ +const int COMMAND_DONE_BUTTON_ID = 100; +const int COMMAND_CANCEL_BUTTON_ID = 101; + +IMPLEMENT_PROPERTY(_Keypad); + +_Keypad::_Keypad(void) + : __isInitialized(false) + , __isSingleLineEnabled(false) + , __pOwner(null) + , __pCallerEdit(null) + , __pChildEdit(null) + , __pHeaderForSIP(null) + , __text() + , __pTextEvent(null) + , __isCommandButtonPressed(false) + , __isPredictionWindowOpendInUSBMode(false) +{ + _AccessibilityContainer* pAccessibilityContainer = GetAccessibilityContainer(); + if(pAccessibilityContainer) + { + pAccessibilityContainer->Activate(true); + } +} + +_Keypad::~_Keypad(void) +{ + Dispose(); +} + +_Keypad* +_Keypad::CreateKeypadN(void) +{ + ClearLastResult(); + + _Keypad* pKeypad = new (std::nothrow) _Keypad; + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pKeypad, , r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + +#if defined(MULTI_WINDOW) + r = pKeypad->CreateRootVisualElement(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); +#endif + + pKeypad->AcquireHandle(); + + return pKeypad; + +CATCH: + delete pKeypad; + + return null; +} + +result +_Keypad::Initialize(int editStyle, _KeypadStyleInfo keypadStyleInfo, int limitLength, _Edit* pCallerEdit) +{ + result r = E_SUCCESS; + bool UsbKeyboardConnected = false; + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturnResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "Failed to get root."); + + if (GetOwner() == null) + { + _Frame* pFrame = dynamic_cast <_Frame*>(pControlManager->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] This instance is not constructed."); + + _Form* pForm = pFrame->GetCurrentForm(); + + if (pForm) + { + SetOwner(pForm); + __pOwner = pForm; + } + else + { + SetOwner(pFrame); + __pOwner = pFrame; + } + } + else + { + __pOwner = GetOwner(); + } + + __pHeaderForSIP = CreateHeaderForSIP(); + + if (pCallerEdit) + { + __pCallerEdit = pCallerEdit; + } + else + { + __pCallerEdit = null; + } + + if ( __pChildEdit == null) + { + __pChildEdit = _Edit::CreateEditN(); + SysTryReturnResult(NID_UI_CTRL, __pChildEdit, E_OUT_OF_MEMORY, "Unable to create Edit"); + + String doneText; + String cancelText; + _AccessibilityContainer* pAccessibilityContainer = null; + + GET_STRING_CONFIG(IDS_COM_SK_DONE, doneText); + GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelText); + + __pChildEdit->SetFullScreenKeypadEdit(true); + + r = __pChildEdit->Initialize(editStyle, INPUT_STYLE_OVERLAY, limitLength); + SysTryCatch(NID_UI_CTRL, __pChildEdit, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pChildEdit->SetTextPredictionEnabled(keypadStyleInfo.textPredictionEnabled); + __pChildEdit->SetKeypadNormalNumberStyle(keypadStyleInfo.isNormalNumberStyle); + __pChildEdit->SetKeypadStyle(keypadStyleInfo.keypadStyle); + if (!keypadStyleInfo.enterActionEnabled)//EditField Style + { + __pChildEdit->SetKeypadActionEnabled(false); + } + + __pChildEdit->SetLowerCaseModeEnabled(keypadStyleInfo.isLowerCaseModeEnabled); + + r = __pChildEdit->SetKeypadCommandButtonVisible(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pChildEdit->AddKeypadEventListener(*this); + + r = AttachChild(*__pChildEdit); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pAccessibilityContainer = GetAccessibilityContainer(); + if (pAccessibilityContainer) + { + _AccessibilityContainer* pAccessibilityEdit = __pChildEdit->GetAccessibilityContainer(); + if (pAccessibilityEdit) + { + pAccessibilityContainer->AddChildContainer(*pAccessibilityEdit); + } + } + } + + UsbKeyboardConnected = __pChildEdit->IsUsbKeyboardConnected(); + + r = ChangeLayoutInternal(); + + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pChildEdit->SetVisibleState(true); + + __isInitialized = true; + + return r; + +CATCH: + Dispose(); + return r; +} + +_Toolbar* +_Keypad::CreateHeaderForSIP(void) +{ + result r = E_SUCCESS; + + _Toolbar* pHeaderForSIP = null; + + if (!__pHeaderForSIP) + { + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI_CTRL, pControlManager, null, E_SYSTEM, "Fail to get ControlManager instance"); + + _Frame* pFrame = dynamic_cast <_Frame*>(pControlManager->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, pFrame, null, E_SYSTEM, "This instance is not constructed."); + + Bitmap* pNormalBackgroundBitmap = null; + Bitmap* pReplacementColorBackgroundBitmap = null; + Color commandBackgroundColor; + String doneText; + String cancelText; + Rectangle bounds(0,0,0,0); + + Dimension screenSize = pControlManager->GetScreenSize(); + + pHeaderForSIP = _Toolbar::CreateToolbarN(true); + SysTryReturn(NID_UI_CTRL, pHeaderForSIP, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance."); + + r = pHeaderForSIP->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap); + + if (pNormalBackgroundBitmap) + { + GET_COLOR_CONFIG(FOOTER::BG_NORMAL, commandBackgroundColor); + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), commandBackgroundColor); + + if (pReplacementColorBackgroundBitmap) + { + r = pHeaderForSIP->SetBackgroundBitmap(*pReplacementColorBackgroundBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pReplacementColorBackgroundBitmap; + pReplacementColorBackgroundBitmap = null; + } + delete pNormalBackgroundBitmap; + pNormalBackgroundBitmap = null; + } + + r = pHeaderForSIP->SetStyle(TOOLBAR_TEXT); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pHeaderForSIP->SetResizable(true); + pHeaderForSIP->SetMovable(true); + + _ControlOrientation orientation = GetOrientation(); + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + bounds.width = screenSize.width; + } + else + { + bounds.width = screenSize.height; + } + + GET_SHAPE_CONFIG(HEADER::HEIGHT, orientation, bounds.height); + + r = pHeaderForSIP->SetBounds(bounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pHeaderForSIP->SetResizable(false); + pHeaderForSIP->SetMovable(false); + + GET_STRING_CONFIG(IDS_COM_SK_DONE, doneText); + GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelText); + + r = pHeaderForSIP->AddItem(CreateButtonItemN(COMMAND_DONE_BUTTON_ID, doneText)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pHeaderForSIP->AddItem(CreateButtonItemN(COMMAND_CANCEL_BUTTON_ID, cancelText)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pHeaderForSIP->AddActionEventListener(*this); + + r = AttachChild(*pHeaderForSIP); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pHeaderForSIP; + + } + else + { + return __pHeaderForSIP; + } + +CATCH: + delete pHeaderForSIP; + return null; +} + +_Button* +_Keypad::CreateButtonItemN(int actionId, const String& text) +{ + result r = E_SUCCESS; + _Button* pButton = _Button::CreateButtonN(); + SysTryReturn(NID_UI_CTRL, pButton, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create instance."); + + Bitmap* pNormalBackgroundBitmap = null; + Bitmap* pPressedBackgroundBitmap = null; + Bitmap* pNormalBackgroundEffectBitmap = null; + Bitmap* pPressedBackgroundEffectBitmap = null; + Bitmap* pReplacementBitmap = null; + + int textSize = 0; + Color normalColor; + Color pressedColor; + + r = pButton->SetActionId(actionId); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pButton->SetText(text); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(FOOTER::ITEM_FONT_SIZE, GetOrientation(), textSize); + if (!IsFailed(r)) + { + r = pButton->SetTextSize(textSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap); + GET_BITMAP_CONFIG_N(FOOTER::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedBackgroundBitmap); + GET_BITMAP_CONFIG_N(FOOTER::BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundEffectBitmap); + GET_BITMAP_CONFIG_N(FOOTER::BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedBackgroundEffectBitmap); + + GET_COLOR_CONFIG(FOOTER::ITEM_BG_NORMAL, normalColor); + + pReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), normalColor); + + if (pReplacementBitmap) + { + r = pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pReplacementBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pReplacementBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pReplacementBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pReplacementBitmap; + pReplacementBitmap = null; + } + + if (pNormalBackgroundBitmap) + { + delete pNormalBackgroundBitmap; + pNormalBackgroundBitmap = null; + } + + GET_COLOR_CONFIG(FOOTER::BUTTON_BG_PRESSED, pressedColor); + + pReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedColor); + + if (pReplacementBitmap) + { + r = pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pReplacementBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + delete pReplacementBitmap; + pReplacementBitmap = null; + } + + if (pPressedBackgroundBitmap) + { + delete pPressedBackgroundBitmap; + pPressedBackgroundBitmap = null; + } + + if (pNormalBackgroundEffectBitmap) + { + r = pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *pNormalBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pNormalBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_DISABLED, *pNormalBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pNormalBackgroundEffectBitmap; + pNormalBackgroundEffectBitmap = null; + } + + if (pPressedBackgroundEffectBitmap) + { + r = pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *pPressedBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + delete pPressedBackgroundEffectBitmap; + pPressedBackgroundEffectBitmap = null; + } + + return pButton; + +CATCH: + delete pNormalBackgroundBitmap; + delete pPressedBackgroundBitmap; + delete pNormalBackgroundEffectBitmap; + delete pPressedBackgroundEffectBitmap; + delete pReplacementBitmap; + + delete pButton; + + return null; +} + +result +_Keypad::ChangeLayoutInternal(void) +{ + result r = E_SUCCESS; + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturnResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "Failed to get root."); + Dimension screenSize = pControlManager->GetScreenSize(); + _ControlOrientation orientation = GetOrientation(); + + _Frame* pFrame = dynamic_cast <_Frame*>(pControlManager->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, pFrame, null, E_SYSTEM, "This instance is not constructed."); + + Rectangle bounds; + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + bounds.width = screenSize.width; + bounds.height = screenSize.height; + } + else + { + bounds.width = screenSize.height; + bounds.height = screenSize.width; + } + + SetResizable(true); + SetMovable(true); + r = SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + SetResizable(false); + SetMovable(false); + + __pChildEdit->ChangeLayout(orientation); + + Rectangle editRect = bounds; + + editRect.y = 0;//_keypad's client doesn't include indicator + + int footerHeight = 0; + GET_SHAPE_CONFIG(HEADER::HEIGHT, orientation, footerHeight); + + editRect.y += footerHeight; + editRect.height -= footerHeight; + + Rectangle keypadRect; + if (__pChildEdit->IsKeypadExist()) + { + r = __pChildEdit->GetKeypadBounds(keypadRect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + editRect.height -= keypadRect.height; + } + r = __pChildEdit->SetBounds(editRect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Rectangle +_Keypad::GetIndicatorBounds(void) const +{ + int indicatorwidth = 0; + int indicatorheight = 0; + + GET_SHAPE_CONFIG(FORM::INDICATOR_WIDTH, GetOrientation(), indicatorwidth); + GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetOrientation(), indicatorheight); + + Rectangle rect (0, 0, indicatorwidth, indicatorheight); + + return rect; +} + +result +_Keypad::OnAttachedToMainTree(void) +{ + result r = E_SUCCESS; + + r = __pChildEdit->SetText(__text); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Invalidate(true); + + return r; +} + +void +_Keypad::OnNativeWindowActivated(void) +{ + __pChildEdit->SetFocused(); +} + +void +_Keypad::OnDraw(void) +{ + Canvas* pCanvas = GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + Color backgroundColor; + GET_COLOR_CONFIG(EDIT::BG_NORMAL, backgroundColor); + + pCanvas->SetBackgroundColor(backgroundColor); + pCanvas->Clear(); + delete pCanvas; + + return; +} + +#if defined(MULTI_WINDOW) +result +_Keypad::OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds) +{ + //Full-screen window + return E_SUCCESS; +} +bool +_Keypad::IsLayoutChangable(void) const +{ + //Full-screen window + return true; +} +#endif + +result +_Keypad::SetSingleLineEnabled(bool enabled) +{ + SetProperty("singleLineEnabled", Variant(enabled)); + return E_SUCCESS; +} + +bool +_Keypad::IsSingleLineEnabled(void) const +{ + Variant enabled = GetProperty("singleLineEnabled"); + + return enabled.ToBool(); +} + +result +_Keypad::SetPropertySingleLineEnabled(const Variant& enabled) +{ + __isSingleLineEnabled = enabled.ToBool(); + + return E_SUCCESS; +} + +Variant +_Keypad::GetPropertySingleLineEnabled(void) const +{ + return Variant(__isSingleLineEnabled); +} + +String +_Keypad::GetText(void) const +{ + Variant text = GetProperty("text"); + + return text.ToString(); +} + +void +_Keypad::SetText(const String& text) +{ + SetProperty("text", Variant(text)); + + return; +} + +result +_Keypad::SetPropertyText(const Variant& text) +{ + __text = text.ToString(); + + return E_SUCCESS; +} + +Variant +_Keypad::GetPropertyText(void) const +{ + return Variant(__text); +} + +result +_Keypad::AddTextEventListener(const _ITextEventListener& listener) +{ + if (__pTextEvent == null) + { + __pTextEvent = _TextEvent::CreateInstanceN(*this); + SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.\n"); + } + + return __pTextEvent->AddListener(listener); +} + +result +_Keypad::RemoveTextEventListener(const _ITextEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + __pTextEvent->RemoveListener(listener); + + return E_SUCCESS; +} + +void +_Keypad::OnActionPerformed(const _Control& source, int actionId) +{ + if ((actionId != COMMAND_DONE_BUTTON_ID) && (actionId != COMMAND_CANCEL_BUTTON_ID)) + { + return; + } + + __pChildEdit->HideKeypad(); + Close(); + + CoreTextEventStatus textEventStatus = CORE_TEXT_EVENT_CHANGED; + if (actionId == COMMAND_DONE_BUTTON_ID) + { + __text = __pChildEdit->GetText(); + textEventStatus = CORE_TEXT_EVENT_CHANGED; + } + else + { + textEventStatus = CORE_TEXT_EVENT_CANCELED; + } + + __isCommandButtonPressed = true; + + if (__pCallerEdit) + { + __pCallerEdit->SetText(__text); + _Control* pParent = __pCallerEdit->GetParent(); + if (pParent) + { + pParent->Invalidate(true); + } + + if (!__pCallerEdit->IsInputEnabled()) + { + __pCallerEdit->SetInputEnableState(true); + } + __pCallerEdit->SendTextEvent(textEventStatus); + } + else + { + __pOwner->Invalidate(true); + if (__pTextEvent) + { + IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(textEventStatus); + if (pEventArg) + { + __pTextEvent->Fire(*pEventArg); + } + } + } + + return; +} + +void +_Keypad::OnKeypadWillOpen(void) +{ + return; +} + +void +_Keypad::OnKeypadOpened(void) +{ + ChangeLayoutInternal();//usb off & bounded or usb on & prediction + if (__pChildEdit->IsUsbKeyboardConnected()) + { + __isPredictionWindowOpendInUSBMode = true; + } + return; +} + +void +_Keypad::OnKeypadClosed(void) +{ + if (__isCommandButtonPressed) + { + return; + } + + if (__pChildEdit->IsUsbKeyboardConnected()) + { + ChangeLayoutInternal(); + } + else + { + if (__isPredictionWindowOpendInUSBMode == true) + { + __isPredictionWindowOpendInUSBMode = false; + return; + } + + Close(); + + CoreTextEventStatus textEventStatus = CORE_TEXT_EVENT_CHANGED; + + __text = __pChildEdit->GetText(); + + if (__pCallerEdit) + { + __pCallerEdit->SetText(__text); + __pCallerEdit->SendTextEvent(textEventStatus); + _Control* pParent = __pCallerEdit->GetParent(); + if (pParent) + { + pParent->Invalidate(true); + } + if (!__pCallerEdit->IsInputEnabled()) + { + __pCallerEdit->SetInputEnableState(true); + } + } + else + { + __pOwner->Invalidate(true); + if (__pTextEvent) + { + IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(textEventStatus); + if (pEventArg) + { + __pTextEvent->Fire(*pEventArg); + } + } + } + } +} + +void +_Keypad::OnKeypadBoundsChanged(void) +{ + ChangeLayoutInternal();// predictive window show/hide +} + +void +_Keypad::OnKeypadActionPerformed(CoreKeypadAction keypadAction) +{ +} + +void +_Keypad::OnChangeLayout(_ControlOrientation orientation) +{ + if (__isInitialized) + { + ChangeLayoutInternal(); + } +} + +result +_Keypad::Dispose(void) +{ + result r = E_SUCCESS; + if (__pHeaderForSIP) + { + DetachChild(*__pHeaderForSIP); + delete __pHeaderForSIP; + __pHeaderForSIP = null; + } + if (__pChildEdit) + { + __pChildEdit->HideKeypad(); + DetachChild(*__pChildEdit); + delete __pChildEdit; + __pChildEdit = null; + } + __pCallerEdit = null; + + if (__pTextEvent) + { + delete __pTextEvent; + __pTextEvent = null; + } + return r; +} + +} } } // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_KeypadEvent.cpp b/src/ui/controls/FUiCtrl_KeypadEvent.cpp new file mode 100644 index 0000000..9552c27 --- /dev/null +++ b/src/ui/controls/FUiCtrl_KeypadEvent.cpp @@ -0,0 +1,210 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_KeypadEvent.cpp +* @brief This file contains implementation of _KeypadEvent class +* +* This file contains implementation of _KeypadEvent class. +*/ + +// Includes +#include +#include +#include +#include "FUiCtrl_KeypadEvent.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen {namespace Ui {namespace Controls +{ +/** + * @class + * @brief This class is used as the argument to change event listener. + * + * This class is used as the argument to change event listener. When an change event is generated + * (such as when a button is pressed) the TextSelectionEvent calls TextSelectionEventListener's OnTextd + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the change ID. + */ +class _OSP_EXPORT_ _KeypadEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Object instance which contains this instance. + */ + _KeypadEventArg(CoreKeypadAction actionId, CoreKeypadEventStatus status); + + /** + * This is the class destructor. + * + */ + virtual ~_KeypadEventArg(void); + + +// Access +public: + CoreKeypadAction GetKeypadActionId() const; + + CoreKeypadEventStatus GetStatus() const; + +// Attribute +private: + /** + * Event source. + */ + CoreKeypadAction __actionId; + + /** + * status. + */ + CoreKeypadEventStatus __status; +}; // _KeypadEventArg + +//////////////////////////////////////////////////////////////////////////////// +/// __TextSelectionEventArg class Lifecycle + +_KeypadEventArg::_KeypadEventArg(CoreKeypadAction actionId, CoreKeypadEventStatus status) +{ + __actionId = actionId; + __status = status; +} + +_KeypadEventArg::~_KeypadEventArg(void) +{ + // Nothing. +} + +CoreKeypadAction +_KeypadEventArg::GetKeypadActionId(void) const +{ + return __actionId; +} + +CoreKeypadEventStatus +_KeypadEventArg::GetStatus() const +{ + return __status; +} + +//////////////////////////////////////////////////////////////////////////////// +/// __TextSelectionEvent class Lifecycle +_KeypadEvent::_KeypadEvent(const _Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_KeypadEvent::~_KeypadEvent(void) +{ + // Nothing. +} + +_KeypadEvent* +_KeypadEvent::CreateInstanceN(const _Control& source) +{ + _KeypadEvent* pCoreKeypadEvent = new (std::nothrow) _KeypadEvent(source); + SysTryReturn(NID_UI_CTRL, pCoreKeypadEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pCoreKeypadEvent; +CATCH: + delete pCoreKeypadEvent; + return null; +} + +const _Control* +_KeypadEvent::GetSource(void) const +{ + return __pSource; +} + +// Operations + +void +_KeypadEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // param checking + _IKeypadEventListener* pKeypadEventListener = dynamic_cast <_IKeypadEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given.\n"); + + const _KeypadEventArg* pKeypadEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + CoreKeypadAction keypadAction = pKeypadEventArg->GetKeypadActionId(); + + CoreKeypadEventStatus status = pKeypadEventArg->GetStatus(); + switch (status) + { + case CORE_KEYPAD_EVENT_STATUS_CREATED: + pKeypadEventListener->OnKeypadWillOpen(); + break; + + case CORE_KEYPAD_EVENT_STATUS_OPEN: + pKeypadEventListener->OnKeypadOpened(); + break; + + case CORE_KEYPAD_EVENT_STATUS_CLOSE: + pKeypadEventListener->OnKeypadClosed(); + break; + + case CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED: + pKeypadEventListener->OnKeypadBoundsChanged(); + break; + + case CORE_KEYPAD_EVENT_STATUS_ENTERACTION: + pKeypadEventListener->OnKeypadActionPerformed(keypadAction); + break; + + default: + break; + } + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_KeypadEvent::CreateKeypadEventArgN(CoreKeypadAction actionId, CoreKeypadEventStatus status) +{ + _KeypadEventArg* pEventArg = new (std::nothrow) _KeypadEventArg(actionId, status); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_KeypadImpl.cpp b/src/ui/controls/FUiCtrl_KeypadImpl.cpp new file mode 100644 index 0000000..647cbf8 --- /dev/null +++ b/src/ui/controls/FUiCtrl_KeypadImpl.cpp @@ -0,0 +1,271 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_KeypadImpl.cpp +* @brief This file contains implementation of _KeypadImpl class +* +* This file contains implementation of _KeypadImpl class. +*/ + +#include "FUi_ControlImplManager.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_KeypadImpl.h" +#include "FUiCtrl_Keypad.h" +#include "FUiCtrl_PublicTextEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_KeypadImpl* +_KeypadImpl::GetInstance(Keypad& keypad) +{ + return (static_cast<_KeypadImpl*> (keypad._pControlImpl)); +} + +const _KeypadImpl* +_KeypadImpl::GetInstance(const Keypad& keypad) +{ + return (static_cast (keypad._pControlImpl)); +} + +_KeypadImpl::_KeypadImpl(Keypad* pPublic, _Keypad* pCore) + : _WindowImpl(pPublic, pCore) + , __pKeypad(pCore) + , __limitLength(0) + , __pTextEvent(null) + , __pPublicTextEvent(null) +{ + __keypadStyleInfo.keypadStyle = KEYPAD_STYLE_NORMAL; + __keypadStyleInfo.textPredictionEnabled = false; + __keypadStyleInfo.isNormalNumberStyle = false; + __keypadStyleInfo.enterActionEnabled = true; + __keypadStyleInfo.isLowerCaseModeEnabled = false; +} + +_KeypadImpl::~_KeypadImpl(void) +{ + if (__pPublicTextEvent) + { + delete __pPublicTextEvent; + __pPublicTextEvent = null; + } +} + +_KeypadImpl* +_KeypadImpl::CreateKeypadImplN(Keypad* pControl) +{ + ClearLastResult(); + result r = E_SUCCESS; + _Keypad* pCore = null; + + pCore = _Keypad::CreateKeypadN(); + SysTryReturn(NID_UI_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _KeypadImpl* pImpl = new (std::nothrow) _KeypadImpl(pControl, pCore); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; +} + +const char* +_KeypadImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::Keypad"; +} + +const Keypad& +_KeypadImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +Keypad& +_KeypadImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Keypad& +_KeypadImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Keypad& +_KeypadImpl::GetCore(void) +{ + return static_cast <_Keypad&>(_ControlImpl::GetCore()); +} + +result +_KeypadImpl::Initialize(KeypadStyle keypadStyle, KeypadInputModeCategory category, int limitLength, bool enabledTextPrediction) +{ + result r = E_SUCCESS; + ClearLastResult(); + + __keypadStyleInfo.keypadStyle = keypadStyle; + __keypadStyleInfo.textPredictionEnabled = enabledTextPrediction; + if ((keypadStyle == KEYPAD_STYLE_NORMAL) && (category & (KEYPAD_MODE_NUMERIC | KEYPAD_MODE_SYMBOL))) + { + __keypadStyleInfo.isNormalNumberStyle = true; + } + else + { + __keypadStyleInfo.isNormalNumberStyle = false; + } + + __limitLength = limitLength; + + __pKeypad->SetResizable(false); + __pKeypad->SetMovable(false); + + SysTryReturn(NID_UI_CTRL, (__pPublicTextEvent == null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance is already constructed."); + __pPublicTextEvent = _PublicTextEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] System error occurred."); + + r = __pKeypad->AddTextEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +_KeypadImpl::SetTextPredictionEnabled(bool enable) +{ + __keypadStyleInfo.textPredictionEnabled = enable; +} + +bool +_KeypadImpl::IsTextPredictionEnabled(void) const +{ + return __keypadStyleInfo.textPredictionEnabled; +} + +result +_KeypadImpl::SetSingleLineEnabled(bool enabled) +{ + ClearLastResult(); + + if ((__keypadStyleInfo.keypadStyle == KEYPAD_STYLE_PASSWORD) && (enabled == false)) + { + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The password style can't support multiline."); + return E_UNSUPPORTED_OPERATION; + } + SysTryReturnResult(NID_UI_CTRL, __pKeypad->IsActivated() == false, E_INVALID_OPERATION, "Keypad is already shown."); + + Variant var(enabled); + return __pKeypad->SetPropertySingleLineEnabled(var); +} + +bool +_KeypadImpl::IsSingleLineEnabled(void) const +{ + ClearLastResult(); + return __pKeypad->GetPropertySingleLineEnabled().ToBool(); +} + +result +_KeypadImpl::AddTextEventListener(ITextEventListener& listener) +{ + ClearLastResult(); + return __pPublicTextEvent->AddListener(listener); +} + +result +_KeypadImpl::RemoveTextEventListener(ITextEventListener& listener) +{ + ClearLastResult(); + return __pPublicTextEvent->RemoveListener(listener); +} + +result +_KeypadImpl::OnAttachedToMainTree(void) +{ + ClearLastResult(); + + result r = E_SUCCESS; + int editStyle = EDIT_STYLE_NORMAL; + + if (IsSingleLineEnabled()) + { + editStyle |= EDIT_STYLE_SINGLE_LINE; + } + + if (__keypadStyleInfo.keypadStyle == KEYPAD_STYLE_PASSWORD) + { + editStyle |= EDIT_STYLE_PASSWORD | EDIT_STYLE_SINGLE_LINE; + } + + String text = GetText(); + + r = __pKeypad->Initialize(editStyle, __keypadStyleInfo, __limitLength, null); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + + SetText(text); + + r = _WindowImpl::OnAttachedToMainTree(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +String +_KeypadImpl::GetText(void) const +{ + ClearLastResult(); + + return __pKeypad->GetPropertyText().ToString(); +} + +void +_KeypadImpl::SetText(const String& text) +{ + ClearLastResult(); + + Variant var(text); + __pKeypad->SetPropertyText(var); + return; +} + +void +_KeypadImpl::OnTextValueChanged(const _Control& source) +{ + IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CHANGED); + if (pEventArg) + { + __pPublicTextEvent->Fire(*pEventArg); + } +} + +void +_KeypadImpl::OnTextValueChangeCanceled(const _Control& source) +{ + IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CANCELED); + if (pEventArg) + { + __pPublicTextEvent->Fire(*pEventArg); + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Label.cpp b/src/ui/controls/FUiCtrl_Label.cpp new file mode 100644 index 0000000..e4fb939 --- /dev/null +++ b/src/ui/controls/FUiCtrl_Label.cpp @@ -0,0 +1,508 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Label.cpp + * @brief This is the implementation file for the _Label class. + */ + +#include +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityManager.h" +#include "FUi_ResourceManager.h" +#include "FUi_EflWindow.h" +#include "FUiCtrl_Label.h" +#include "FUiCtrl_LabelPresenter.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_Label); + +_Label::_Label(void) + : __pLabelPresenter(null) + , __text(L"") + , __textSize(0) + , __horizontalAlignment(ALIGNMENT_CENTER) + , __verticalAlignment(ALIGNMENT_MIDDLE) + , __pBackgroundBitmap(null) + , __pBackgroundEffectBitmap(null) + , __topMargin(0) + , __leftMargin(0) + , __pTextElement(null) +{ + result r = E_SUCCESS; + + _AccessibilityContainer* pContainer = null; + + GET_SHAPE_CONFIG(LABEL::TEXT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __textSize); + + _LabelPresenter* pPresenter = new (std::nothrow) _LabelPresenter(); + SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = SetPresenter(*pPresenter); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pPresenter->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pPresenter->Install(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + GET_COLOR_CONFIG(LABEL::TEXT_NORMAL, __textColor); + + GET_SHAPE_CONFIG(LABEL::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __topMargin); + GET_SHAPE_CONFIG(LABEL::LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __leftMargin); + + SetFocusable(false); + + pContainer = GetAccessibilityContainer(); + + if(pContainer) + { + pContainer->Activate(true); + } + + ClearLastResult(); + + return ; + +CATCH: + delete pPresenter; +} + +_Label* +_Label::CreateLabelN(void) +{ + _Label* pLabel = new (std::nothrow) _Label(); + SysTryReturn(NID_UI_CTRL, pLabel, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pLabel->AcquireHandle(); + + return pLabel; + +CATCH: + delete pLabel; + return null; +} + +_Label::~_Label(void) +{ + if (__pLabelPresenter) + { + delete __pLabelPresenter; + __pLabelPresenter = null; + } + + if (__pBackgroundBitmap) + { + delete __pBackgroundBitmap; + __pBackgroundBitmap = null; + } + + if (__pBackgroundEffectBitmap) + { + delete __pBackgroundEffectBitmap; + __pBackgroundEffectBitmap = null; + } + if (__pTextElement) + { + __pTextElement->Activate(false); + __pTextElement = null; + } + ClearLastResult(); +} + +result +_Label::SetPresenter(const _LabelPresenter& labelPresenter) +{ + __pLabelPresenter = const_cast <_LabelPresenter*>(&labelPresenter); + + return E_SUCCESS; +} + +void +_Label::OnDraw(void) +{ + __pLabelPresenter->Draw(); + + return; +} + +result +_Label::OnAttachedToMainTree(void) +{ + InitializeAccessibilityElement(); + + return E_SUCCESS; +} + +void +_Label::InitializeAccessibilityElement(void) +{ + if(__pTextElement) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if(pContainer) + { + __pTextElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pTextElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pTextElement->SetBounds(Rectangle(0,0, GetBounds().width, GetBounds().height)); + __pTextElement->SetLabel(GetText()); + __pTextElement->SetTrait(ACCESSIBILITY_TRAITS_LABEL); + __pTextElement->SetName(L"LabelText"); + + pContainer->AddElement(*__pTextElement); + } + + return; +} + +bool +_Label::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pLabelPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_Label::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pLabelPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_Label::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pLabelPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_Label::OnTouchCanceled(const _Control & source, const _TouchInfo & touchinfo) +{ + return __pLabelPresenter->OnTouchCanceled(source, touchinfo); +} + +void +_Label::OnTouchMoveHandled(const _Control& control) +{ + __pLabelPresenter->OnTouchMoveHandled(control); + + return; +} + +void +_Label::OnBoundsChanged(void) +{ + if(__pTextElement) + { + __pTextElement->SetBounds(Rectangle(0,0, GetBounds().width, GetBounds().height)); + } + + return; +} + +void +_Label::OnFontChanged(Font* pFont) +{ + __pLabelPresenter->OnFontChanged(pFont); + + return; +} + +void +_Label::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pLabelPresenter->OnFontInfoRequested(style, size); + + return; +} + +result +_Label::SetText(const String& text) +{ + return SetProperty("text", Variant(text)); +} + +result +_Label::SetPropertyText(const Variant& text) +{ + __text = text.ToString(); + + if(__pTextElement) + { + __pTextElement->SetLabel(__text); + } + + result r = __pLabelPresenter->InitTextObject(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_Label::SetTextColor(const Color& color) +{ + return SetProperty("textColor", Variant(color)); +} + +result +_Label::SetPropertyTextColor(const Variant& color) +{ + __textColor = color.ToColor(); + return E_SUCCESS; +} + +result +_Label::SetBackgroundBitmap(const Bitmap& bitmap) +{ + result r = E_SYSTEM; + + Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap); + + if (pClonedBitmap) + { + if (__pBackgroundBitmap != null) + { + delete __pBackgroundBitmap; + } + + __pBackgroundBitmap = pClonedBitmap; + + r = E_SUCCESS; + } + + return r; +} + +Bitmap* +_Label::GetBackgroundBitmap(void) const +{ + return __pBackgroundBitmap; +} + +result +_Label::SetBackgroundEffectBitmap(const Bitmap& bitmap) +{ + result r = E_SYSTEM; + + Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap); + + if (pClonedBitmap) + { + if (__pBackgroundEffectBitmap != null) + { + delete __pBackgroundEffectBitmap; + } + + __pBackgroundEffectBitmap = pClonedBitmap; + + r = E_SUCCESS; + } + + return r; +} + +Bitmap* +_Label::GetBackgroundEffectBitmap(void) const +{ + return __pBackgroundEffectBitmap; +} + + +result +_Label::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + __horizontalAlignment = alignment; + return E_SUCCESS; +} + +result +_Label::SetTextVerticalAlignment(VerticalAlignment alignment) +{ + __verticalAlignment = alignment; + return E_SUCCESS; +} + +result +_Label::SetTextConfig(int size, LabelTextStyle style) +{ + __pLabelPresenter->SetTextConfig(size, style); + + return SetProperty("textSize", Variant(size)); +} + +result +_Label::SetPropertyTextSize(const Variant& textSize) +{ + __textSize = textSize.ToInt(); + + return E_SUCCESS; +} + +String +_Label::GetText(void) const +{ + Variant text = GetProperty("text"); + + return text.ToString(); +} + +Variant +_Label::GetPropertyText(void) const +{ + return Variant(__text); +} + +HorizontalAlignment +_Label::GetTextHorizontalAlignment(void) const +{ + return __horizontalAlignment; +} + +VerticalAlignment +_Label::GetTextVerticalAlignment(void) const +{ + return __verticalAlignment; +} + +Color +_Label::GetTextColor(void) const +{ + Variant color = GetProperty("textColor"); + + return color.ToColor(); +} + +Variant +_Label::GetPropertyTextColor(void) const +{ + return Variant(__textColor); +} + +int +_Label::GetTextSize(void) const +{ + Variant size = GetProperty("textSize"); + + return size.ToInt(); +} + +Variant +_Label::GetPropertyTextSize(void) const +{ + return Variant(__textSize); +} + +LabelTextStyle +_Label::GetTextStyle(void) const +{ + return __pLabelPresenter->GetTextStyle(); +} + +result +_Label::SetMargin(int topMargin, int leftMargin) +{ + __topMargin = topMargin; + __leftMargin = leftMargin; + + return E_SUCCESS; +} + +int +_Label::GetTopMargin(void) const +{ + return __topMargin; +} + +int +_Label::GetLeftMargin(void) const +{ + return __leftMargin; +} + +Tizen::Graphics::Dimension +_Label::GetContentSize(void) const +{ + return GetContentSizeInternal(); +} + +Tizen::Graphics::Dimension +_Label::GetContentSizeInternal(void) const +{ + if (__text.IsEmpty() && __pBackgroundBitmap == null) + { + return Dimension(GetBounds().width, GetBounds().height); + } + + Dimension dimension(0,0); + Rectangle contentRect(0,0,0,0); + + TextObject* pTextObject = __pLabelPresenter->GetTextObject(); + + TextObjectActionType previousActionType = pTextObject->GetAction(); + TextObjectWrapType previousWrapType = pTextObject->GetWrap(); + Rectangle previousRect = pTextObject->GetBounds(); + + pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE); + pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + pTextObject->Compose(); + dimension = pTextObject->GetTextExtent(0, pTextObject->GetTextLength()); + + contentRect.width = _ControlManager::GetInstance()->GetScreenSize().width; + + if (dimension.width > contentRect.width - GetBounds().x) + { + dimension.width = contentRect.width - GetBounds().x; + + pTextObject->SetBounds(Rectangle(previousRect.x, previousRect.y, dimension.width, previousRect.height)); + pTextObject->Compose(); + } + + dimension.height = pTextObject->GetTotalHeight(); + + pTextObject->SetBounds(previousRect); + pTextObject->SetAction(previousActionType); + pTextObject->SetWrap(previousWrapType); + pTextObject->Compose(); + + dimension.width += __leftMargin * 2; + dimension.height += __topMargin * 2; + + if (__pBackgroundBitmap != null) + { + dimension.width = GetBounds().width; + dimension.height = GetBounds().height; + } + + return dimension; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_LabelImpl.cpp b/src/ui/controls/FUiCtrl_LabelImpl.cpp new file mode 100644 index 0000000..7e8ffb7 --- /dev/null +++ b/src/ui/controls/FUiCtrl_LabelImpl.cpp @@ -0,0 +1,468 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_LabelImpl.cpp + * @brief This is the implementation file for the _LabelImpl class. + */ + +#include +#include +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_LabelImpl.h" +#include "FUiCtrl_Label.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Dimension +_LabelImpl::LabelSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Dimension dimension(0, 0); + + r = GET_DIMENSION_CONFIG(LABEL::MIN_SIZE, orientation, dimension); + SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] A system error occurred.", GetErrorMessage(r)); + + SetLastResult(r); + + return dimension; +} + +_LabelImpl* +_LabelImpl::GetInstance(Label& label) +{ + return static_cast<_LabelImpl*> (label._pControlImpl); +} + +const _LabelImpl* +_LabelImpl::GetInstance(const Label& label) +{ + return static_cast (label._pControlImpl); +} + +_LabelImpl::_LabelImpl(Label* pPublic, _Label* pCore) + : _ControlImpl(pPublic, pCore) +{ + ClearLastResult(); + SetFocusableChangable(false); +} + +_LabelImpl::~_LabelImpl(void) +{ + ClearLastResult(); +} + +_LabelImpl* +_LabelImpl::CreateLabelImplN(Label* pControl, const Rectangle& bounds) +{ + result r = E_SUCCESS; + r = GET_SIZE_INFO(Label).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] The given size is not valid."); + + _Label* pCore = _Label::CreateLabelN(); + SysTryReturn(NID_UI_CTRL, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _LabelImpl* pImpl = new (std::nothrow) _LabelImpl(pControl, pCore); + r = _ControlImpl::CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Label), bounds, pCore->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl->SetBackgroundColor(Color(0, 0, 0, 0)); // for transparent + + ClearLastResult(); + + return pImpl; + +CATCH: + delete pImpl; + return null; +} + +Color +_LabelImpl::GetColorOnError(void) +{ + return Color(0XFFFFFFFF); +} + +const char* +_LabelImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::Label"; +} + +const Label& +_LabelImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +Label& +_LabelImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Label& +_LabelImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Label& +_LabelImpl::GetCore(void) +{ + return static_cast <_Label&>(_ControlImpl::GetCore()); +} + +result +_LabelImpl::OnBoundsChanged(const Rectangle& oldRect, const Rectangle& newRect) +{ + return E_SUCCESS; +} + +Tizen::Graphics::Dimension +_LabelImpl::GetContentSize(void) const +{ + return GetCore().GetContentSizeInternal(); +} + +result +_LabelImpl::SetText(const String& text) +{ + Variant var(text); + result r = GetCore().SetPropertyText(var); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_LabelImpl::SetTextColor(const Color& color) +{ + result r = GetCore().SetTextColor(color); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_LabelImpl::SetBackgroundBitmap(const Bitmap& bitmap) +{ + result r = GetCore().SetBackgroundBitmap(bitmap); + SetLastResultReturn(r); +} + +result +_LabelImpl::SetTextHorizontalAlignment(HorizontalAlignment alignment) +{ + result r = GetCore().SetTextHorizontalAlignment(alignment); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_LabelImpl::SetTextVerticalAlignment(VerticalAlignment alignment) +{ + result r = GetCore().SetTextVerticalAlignment(alignment); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_LabelImpl::SetTextConfig(int size, LabelTextStyle style) +{ + result r = GetCore().SetTextConfig(size, style); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_LabelImpl::SetMargin(int topMargin, int leftMargin) +{ + result r = GetCore().SetMargin(topMargin, leftMargin); + SetLastResultReturn(r); +} + +String +_LabelImpl::GetText(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyText().ToString(); +} + +HorizontalAlignment +_LabelImpl::GetTextHorizontalAlignment(void) const +{ + ClearLastResult(); + + return GetCore().GetTextHorizontalAlignment(); +} + +VerticalAlignment +_LabelImpl::GetTextVerticalAlignment(void) const +{ + ClearLastResult(); + + return GetCore().GetTextVerticalAlignment(); +} + +Color +_LabelImpl::GetTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetTextColor(); +} + +int +_LabelImpl::GetTextSize(void) const +{ + ClearLastResult(); + + return GetCore().GetTextSize(); +} + +LabelTextStyle +_LabelImpl::GetTextStyle(void) const +{ + ClearLastResult(); + + return GetCore().GetTextStyle(); +} + +int +_LabelImpl::GetTopMargin(void) const +{ + ClearLastResult(); + + return GetCore().GetTopMargin(); +} + +int +_LabelImpl::GetLeftMargin(void) const +{ + ClearLastResult(); + + return GetCore().GetLeftMargin(); +} + +class _LabelMaker + : public _UiBuilderControlMaker +{ +public: + _LabelMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_LabelMaker(){}; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _LabelMaker* pLabelMaker = new (std::nothrow) _LabelMaker(uibuilder); + return static_cast<_UiBuilderControlMaker*>(pLabelMaker); + }; +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { +// bool b = false; +// bool bText = false; +// bool bSoftkeyCount = false; + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + Label* pLabel = null; + Rectangle rect; + + AppResource* pAppResource = null; + UiApp* pUiApp = UiApp::GetInstance(); + if (pUiApp) + { + pAppResource = UiApp::GetInstance()->GetAppResource(); + } + + HorizontalAlignment horizontalAlignment; + VerticalAlignment verticalAlignment; + Tizen::Base::String elementString; + int opacity = 0; + int size = 0; + LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL; + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pLabel = new (std::nothrow) Label(); + rect = pControlProperty->GetRect(); + + //Construct + if (pControl->GetElement(L"text", elementString)) + { + r = pLabel->Construct(rect, elementString); + } + else + { + r = pLabel->Construct(rect, String(L"")); + } + + if (r != E_SUCCESS) + { + delete pLabel; + return null; + } + + //setting + if (pControl->GetElement(L"horizontalAlign", elementString) || pControl->GetElement(L"hAlign", elementString)) + { + if (ConvertHAlignToHorizontalAlignment(elementString, horizontalAlignment)) + { + pLabel->SetTextHorizontalAlignment(horizontalAlignment); + } + } + + if (pControl->GetElement(L"verticalAlign", elementString) || pControl->GetElement(L"vAlign", elementString)) + { + if (ConvertVAlignToVerticalAlignment(elementString, verticalAlignment)) + { + pLabel->SetTextVerticalAlignment(verticalAlignment); + } + } + + if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pLabel->SetBackgroundColor(color); + } + else + { + color = pLabel->GetBackgroundColor(); + color.SetAlpha(ConvertOpacity100to255(opacity)); + pLabel->SetBackgroundColor(color); + } + + if (pControl->GetElement(L"textColor", elementString)) + { + ConvertStringToColor(elementString, color); + pLabel->SetTextColor(color); + } + + if (pControl->GetElement(L"backgroundBitmapPath", elementString) || pControl->GetElement(L"BGBitmapPath", elementString)) + { + Bitmap* pBackgroundBitmap = null; + pBackgroundBitmap = pAppResource->GetBitmapN(elementString); + if (pBackgroundBitmap != null) + { + pLabel->SetBackgroundBitmap(*pBackgroundBitmap); + delete pBackgroundBitmap; + } + } + + if (pControl->GetElement(L"textSize", elementString)) + { + Base::Integer::Parse(elementString, size); + _ICoordinateSystemTransformer* pTransform = GetTransformer(); + if (pTransform) + { + size = pTransform->Transform(size); + } + + } + + if (pControl->GetElement(L"textStyle", elementString)) + { + if (elementString.Equals(L"LABEL_TEXT_STYLE_NORMAL", false)) + { + style = LABEL_TEXT_STYLE_NORMAL; + } + else if (elementString.Equals(L"LABEL_TEXT_STYLE_BOLD", false)) + { + style = LABEL_TEXT_STYLE_BOLD; + } + else if (elementString.Equals(L"LABEL_TEXT_STYLE_ITALIC", false)) + { + style = LABEL_TEXT_STYLE_ITALIC; + } + } + + if (size != 0) + { + pLabel->SetTextConfig(size, style); + } + else + { + pLabel->SetTextConfig(pLabel->GetTextSize(), style); + } + + //-------safety for Minimum size------------------- + rect = (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->GetRect(); + if (rect.width < 0) // LABEL_MIN_WIDTH = 0 + { + rect.width = 0; + } + + if (rect.height < 0) + { + rect.height = 0; + } + + (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(rect.x, rect.y, rect.width, rect.height); + + rect = (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->GetRect(); + if (rect.width < 0) + { + rect.width = 0; + } + + if (rect.height < 0) // LABEL_MIN_HEIGHT = 0 + { + rect.height = 0; + } + (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(rect.x, rect.y, rect.width, rect.height); + //---------end safety code------------------------ + + return pLabel; + } +private: +}; // _LabelMaker + +_LabelRegister::_LabelRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"Label", _LabelMaker::GetInstance); +} +_LabelRegister::~_LabelRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"Label"); +} +static _LabelRegister LabelRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_LabelModel.cpp b/src/ui/controls/FUiCtrl_LabelModel.cpp new file mode 100644 index 0000000..1f949c5 --- /dev/null +++ b/src/ui/controls/FUiCtrl_LabelModel.cpp @@ -0,0 +1,47 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_LabelModel.cpp + * @brief This is the implementation file for the _LabelModel class. + */ + +#include +#include +#include "FUiCtrl_LabelModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_LabelModel::_LabelModel(void) +{ + +} + +_LabelModel::~_LabelModel(void) +{ +} + +result +_LabelModel::Construct(void) +{ + result r = E_SUCCESS; + + return r; +} + + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_LabelPresenter.cpp b/src/ui/controls/FUiCtrl_LabelPresenter.cpp new file mode 100644 index 0000000..c6b6aac --- /dev/null +++ b/src/ui/controls/FUiCtrl_LabelPresenter.cpp @@ -0,0 +1,428 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_LabelPresenter.cpp + * @brief This is the implementation file for the _LabelPresenter class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_LabelPresenter.h" +#include "FUiCtrl_LabelModel.h" +#include "FUiCtrl_Label.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::App; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_LabelPresenter::_LabelPresenter(void) + : __pLabel(null) + , __pLabelModel(null) + , __previousEnabledState(false) + , __pFont(null) + , __pTextObject(null) + , __pBase(null) + , __textStyle(LABEL_TEXT_STYLE_NORMAL) + , __fontStyle(0) + , __fontSize(0) +{ + +} + +_LabelPresenter::~_LabelPresenter(void) +{ + if (__pLabelModel) + { + delete __pLabelModel; + __pLabelModel = null; + } + + if (__pTextObject) + { + delete __pTextObject; + __pTextObject = null; + } +} + +result +_LabelPresenter::Construct(const _Label& label) +{ + result r = E_SUCCESS; + + __pLabel = const_cast <_Label*>(&label); + + __fontStyle = FONT_STYLE_PLAIN; + __fontSize = __pLabel->GetTextSize(); + __pFont = __pLabel->GetFallbackFont(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pFont, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTextObject = new (std::nothrow) TextObject(); + SysTryCatch(NID_UI_CTRL, __pTextObject != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + return E_SUCCESS; + +CATCH: + delete __pTextObject; + __pTextObject = null; + + return r; +} + +result +_LabelPresenter::Install(void) +{ + result r = E_SUCCESS; + + __pBase = __pLabel->GetVisualElement(); + + _LabelModel* pModel = new (std::nothrow) _LabelModel(); + SysTryReturn(NID_UI_CTRL, pModel, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = SetModel(*pModel); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pModel->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return E_SUCCESS; + +CATCH: + delete pModel; + return r; +} + +result +_LabelPresenter::SetModel(const _LabelModel& labelModel) +{ + __pLabelModel = const_cast <_LabelModel*>(&labelModel); + + return E_SUCCESS; +} + +result +_LabelPresenter::InitTextObject(void) +{ + TextSimple* pSimpleText = null; + + pSimpleText = new (std::nothrow) TextSimple(const_cast(__pLabel->GetText().GetPointer()), __pLabel->GetText().GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryReturn(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + __pTextObject->Construct(); + __pTextObject->AppendElement(*pSimpleText); + __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __pTextObject->SetBounds(Rectangle(__pLabel->GetLeftMargin(), __pLabel->GetTopMargin(), + __pLabel->GetBounds().width - __pLabel->GetLeftMargin() * 2, __pLabel->GetBounds().height - __pLabel->GetTopMargin() * 2)); + __pTextObject->Compose(); + + return E_SUCCESS; +} + +void +_LabelPresenter::OnFontChanged(Font* pFont) +{ + __pFont = pFont; + + return; +} + +result +_LabelPresenter::SetTextConfig(int size, LabelTextStyle style) +{ + result r = E_SUCCESS; + + unsigned long fontStyle = FONT_STYLE_PLAIN; + bool isStrikeOut = __pFont->IsStrikeOut(); + bool isUnderLine = __pFont->IsUnderlined(); + + __textStyle = style; + + if (__textStyle == LABEL_TEXT_STYLE_ITALIC) + { + fontStyle |= FONT_STYLE_ITALIC; + } + + if (__textStyle == LABEL_TEXT_STYLE_BOLD) + { + fontStyle |= FONT_STYLE_BOLD; + } + + __fontStyle = fontStyle; + __fontSize = size; + + __pFont = __pLabel->GetFallbackFont(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pFont, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pFont->SetStrikeOut(isStrikeOut); + __pFont->SetUnderline(isUnderLine); + + return E_SUCCESS; +} + +LabelTextStyle +_LabelPresenter::GetTextStyle(void) const +{ + return __textStyle; +} + +void +_LabelPresenter::SetFontInfo(unsigned long style, int size) +{ + __fontStyle = style; + __fontSize = size; + + return; +} + +void +_LabelPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = __fontStyle; + size = __fontSize; + + return; +} + +TextObject* +_LabelPresenter::GetTextObject(void) const +{ + return __pTextObject; +} + +void +_LabelPresenter::Draw(void) +{ + DrawBackground(); + DrawText(); + + return; +} + +void +_LabelPresenter::DrawBackground(void) +{ + Bitmap* pBitmap = __pLabel->GetBackgroundBitmap(); + Bitmap* pEffectBitmap = __pLabel->GetBackgroundEffectBitmap(); + + Rectangle bounds(0, 0, __pLabel->GetBounds().width, __pLabel->GetBounds().height); + + Color bgColor = __pLabel->GetBackgroundColor(); + + Canvas* pCanvas = null; + + if (pBitmap != null) + { + pCanvas = __pLabel->GetCanvasN(); + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + + return; + } + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + if (pBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBitmap); + } + else + { + pCanvas->DrawBitmap(Rectangle(0, 0, bounds.width, bounds.height), *pBitmap); + } + + if (pEffectBitmap != null) + { + if (pEffectBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pEffectBitmap); + } + else + { + pCanvas->DrawBitmap(Rectangle(0, 0, bounds.width, bounds.height), *pEffectBitmap); + } + } + } + else + { + if (__pLabel->GetText().IsEmpty() && __pLabel->IsCalledGetCanvasN() == false) + { + __pBase->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255, (float)bgColor.GetGreen() / 255, (float)bgColor.GetBlue() / 255, (float)bgColor.GetAlpha() / 255)); + } + else + { + pCanvas = __pLabel->GetCanvasN(); + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + + return; + } + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + pCanvas->FillRectangle(__pLabel->GetBackgroundColor(), bounds); + } + } + + if (pCanvas) + { + delete pCanvas; + } + + return; +} + +void +_LabelPresenter::DrawText(void) +{ + if (__pLabel->GetText().IsEmpty()) + { + SysLog(NID_UI_CTRL, "Text is empty."); + + return; + } + + TextSimple* pSimpleText = null; + TextObjectAlignment horizontalAlign = TEXT_OBJECT_ALIGNMENT_CENTER; + TextObjectAlignment verticalAlign = TEXT_OBJECT_ALIGNMENT_MIDDLE; + + int topMargin = __pLabel->GetTopMargin(); + int leftMargin = __pLabel->GetLeftMargin(); + Rectangle rect(leftMargin, topMargin, __pLabel->GetBounds().width - leftMargin * 2, __pLabel->GetBounds().height - topMargin * 2 ); + if (rect.width <= 0 || rect.height <= 0) + { + SysLog(NID_UI_CTRL, "text display rectangle is wrong."); + + return; + } + + Canvas* pCanvas = __pLabel->GetCanvasN(); + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + + return; + } + + __pTextObject->RemoveAll(); + pSimpleText = new (std::nothrow) TextSimple(const_cast(__pLabel->GetText().GetPointer()), __pLabel->GetText().GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + __pTextObject->AppendElement(*pSimpleText); + + __pTextObject->SetForegroundColor(__pLabel->GetTextColor(), 0, __pTextObject->GetTextLength()); + __pTextObject->SetBounds(rect); + __pTextObject->Compose(); + + switch (__pLabel->GetTextHorizontalAlignment()) + { + case ALIGNMENT_LEFT: + horizontalAlign = TEXT_OBJECT_ALIGNMENT_LEFT; + break; + case ALIGNMENT_CENTER: + horizontalAlign = TEXT_OBJECT_ALIGNMENT_CENTER; + break; + default: + horizontalAlign = TEXT_OBJECT_ALIGNMENT_RIGHT; + } + + switch (__pLabel->GetTextVerticalAlignment()) + { + case ALIGNMENT_TOP: + verticalAlign = TEXT_OBJECT_ALIGNMENT_TOP; + break; + case ALIGNMENT_MIDDLE: + verticalAlign = TEXT_OBJECT_ALIGNMENT_MIDDLE; + break; + default: + verticalAlign = TEXT_OBJECT_ALIGNMENT_BOTTOM; + } + + __pTextObject->SetAlignment(horizontalAlign | verticalAlign); + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + __pTextObject->SetBounds(rect); + __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + + delete pCanvas; + + return; +} + +bool +_LabelPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_LabelPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_LabelPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return false; +} + +bool +_LabelPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return false; +} + +void +_LabelPresenter::OnTouchMoveHandled(const _Control& control) +{ + return; +} + +bool +_LabelPresenter::IsEnabledStateChanged(void) +{ + bool __currentEnabledState = __pLabel->GetEnableState(); + + if (__currentEnabledState != __previousEnabledState) + { + __previousEnabledState = __currentEnabledState; + return true; + } + else + { + return false; + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_LanguageEvent.cpp b/src/ui/controls/FUiCtrl_LanguageEvent.cpp new file mode 100644 index 0000000..b2e7bd0 --- /dev/null +++ b/src/ui/controls/FUiCtrl_LanguageEvent.cpp @@ -0,0 +1,187 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_LanguageEvent.cpp + * @brief This is the implementation for the _LanguageEvent class. + * @version 1.0 + */ + +// includes +#include +#include +#include +#include +#include "FUiCtrl_LanguageEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Locales; + +namespace Tizen { namespace Ui { namespace Controls +{ +/** +* @class _LanguageEventArg +* @brief This class is used as an argument of event listener's method. +* +* This class is used as an argument of event listener's method. When language event is generated, +* the @c languageEvent instance calls @c languageEventListener's method with instance of this class as an argument. +* +*/ +class _OSP_EXPORT_ _LanguageEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Window instance which contains this instance. + * @param[in] prevLanguageCode the key code of the event initially occurs. + * @param[in] currentLanguageCode the key state of the event initially occurs. + */ + _LanguageEventArg(LanguageCode prevLanguageCode, LanguageCode currentLanguageCode); + + + /** + * This is the class destructor. + * + */ + virtual ~_LanguageEventArg(void); + + +// Access +public: + /** + * This method returns a previous language code. + * + * @return See the comment above. + * + */ + LanguageCode GetPreviousLanguageCode(void) const; + + /** + * This method returns a current language code. + * + * @return See the comment above. + * + */ + LanguageCode GetCurrentLanguageCode(void) const; + +// Attribute +private: + LanguageCode __prevLanguageCode; + LanguageCode __currentLanguageCode; +}; // _LanguageEventArg + +_LanguageEventArg::_LanguageEventArg(LanguageCode prevLanguageCode, LanguageCode currentLanguageCode) + : __prevLanguageCode(prevLanguageCode) + , __currentLanguageCode(currentLanguageCode) +{ + +} + +_LanguageEventArg::~_LanguageEventArg(void) +{ + // Nothing. +} + +LanguageCode +_LanguageEventArg::GetCurrentLanguageCode(void) const +{ + return __currentLanguageCode; +} + +LanguageCode +_LanguageEventArg::GetPreviousLanguageCode(void) const +{ + return __prevLanguageCode; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _FocusEvent class Lifecycle + +_LanguageEvent::_LanguageEvent(const _Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + __pSource = &source; +} + + +_LanguageEvent::~_LanguageEvent() +{ + // NOTHING +} + +_LanguageEvent* +_LanguageEvent::CreateInstanceN(const _Control& source) +{ + _LanguageEvent* pCoreLanguageEvent = new (std::nothrow) _LanguageEvent(source); + SysTryReturn(NID_UI_CTRL, pCoreLanguageEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + goto CATCH; + + return pCoreLanguageEvent; + +CATCH: + delete pCoreLanguageEvent; + return null; +} + +const _Control* +_LanguageEvent::GetSource(void) const +{ + return (__pSource); +} + +void +_LanguageEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _ILanguageEventListener* pLanguageEventListener = dynamic_cast <_ILanguageEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pLanguageEventListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given.\n"); + + const _LanguageEventArg* pLanguageEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pLanguageEventArg != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + LanguageCode currentLanguageCode = pLanguageEventArg->GetCurrentLanguageCode(); + LanguageCode previousLanguageCode = pLanguageEventArg->GetPreviousLanguageCode(); + + pLanguageEventListener->OnLanguageChanged(currentLanguageCode, previousLanguageCode); + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_LanguageEvent::CreateLanguageEventArgN(LanguageCode prevLanguageCode, + LanguageCode currentLanguageCode) +{ + _LanguageEventArg* pLanguageEventArg = new (std::nothrow) _LanguageEventArg(prevLanguageCode, currentLanguageCode); + SysTryReturn(NID_UI_CTRL, pLanguageEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pLanguageEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_LinkEvent.cpp b/src/ui/controls/FUiCtrl_LinkEvent.cpp new file mode 100644 index 0000000..825e536 --- /dev/null +++ b/src/ui/controls/FUiCtrl_LinkEvent.cpp @@ -0,0 +1,185 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_LinkEvent.cpp +* @brief This is the implementation for the _LinkEvent class. +* @version 1.0 +*/ + +// includes +#include +#include +#include +#include "FUiCtrl_LinkEvent.h" + + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _LinkEventArg + * @brief This class is used as the argument to change event listener. + * + * This class is used as the argument to change event listener. When an change event is generated + * (such as when a button is pressed) the TextSelectionEvent calls TextSelectionEventListener's OnTextd + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the change ID. + */ +class _OSP_EXPORT_ _LinkEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _LinkEventArg(const String& text, LinkType linkType, const String& link); + + /** + * This is the class destructor. + * + */ + virtual ~_LinkEventArg(void); + + String GetText(void) const; + + LinkType GetLinkType(void) const; + + String GetLinkText(void) const; + + +private: + String __text; + + LinkType __linkType; + + String __linkText; +}; // _LinkEventArg + +//////////////////////////////////////////////////////////////////////////////// +/// _LinkEventArg class Lifecycle + +_LinkEventArg::_LinkEventArg(const String& text, LinkType linkType, const String& link) + : __text(text) + , __linkType(linkType) + , __linkText(link) +{ + // Nothing. +} + +_LinkEventArg::~_LinkEventArg(void) +{ + // Nothing. +} + +String +_LinkEventArg::GetText(void) const +{ + return __text; +} + +LinkType +_LinkEventArg::GetLinkType(void) const +{ + return __linkType; +} + +String +_LinkEventArg::GetLinkText(void) const +{ + return __linkText; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _LinkEvent class Lifecycle +_LinkEvent::_LinkEvent(const _Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // Set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_LinkEvent::~_LinkEvent(void) +{ + // Nothing. +} + +_LinkEvent* +_LinkEvent::CreateInstanceN(const _Control& source) +{ + _LinkEvent* pCoreLinkEvent = new (std::nothrow) _LinkEvent(source); + SysTryReturn(NID_UI_CTRL, pCoreLinkEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + goto CATCH; + + return pCoreLinkEvent; + +CATCH: + delete pCoreLinkEvent; + return null; +} + +const _Control* +_LinkEvent::GetSource(void) const +{ + return __pSource; +} + +void +_LinkEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _IUiLinkEventListener* pLinkEventListener = dynamic_cast <_IUiLinkEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pLinkEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n"); + + _LinkEventArg* pLinkEventArg = dynamic_cast <_LinkEventArg*>(const_cast (&arg)); + SysTryReturnVoidResult(NID_UI_CTRL, pLinkEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n"); + + const String text = pLinkEventArg->GetText(); + LinkType linkType = pLinkEventArg->GetLinkType(); + const String linkText = pLinkEventArg->GetLinkText(); + + pLinkEventListener->OnLinkClicked(const_cast <_Control&>(*__pSource), text, linkType, linkText); + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_LinkEvent::CreateLinkEventArgN(String text, LinkType linkType, String link) +{ + _LinkEventArg* pEventArg = new (std::nothrow) _LinkEventArg(text, linkType, link); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ListBaseImpl.cpp b/src/ui/controls/FUiCtrl_ListBaseImpl.cpp new file mode 100644 index 0000000..df1864c --- /dev/null +++ b/src/ui/controls/FUiCtrl_ListBaseImpl.cpp @@ -0,0 +1,805 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_ListBaseImpl.cpp +* @brief This file contains implementation of common classes used by 1.x Lists +*/ + +#include +#include +#include +#include "FUiCtrl_ListBaseImpl.h" +#include "FUiCtrl_CustomListElements.h" +#include "FUiCtrl_CustomListItemImpl.h" +#include "FUiCtrl_Label.h" + +using namespace Tizen::Base::Collection; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ListBaseImpl::_ListBaseImpl(Control* pList, _TableView* pCore) + : _ControlImpl(pList, pCore) + , _annexStyle(TABLE_VIEW_ANNEX_STYLE_NORMAL) + , _currentRadioIndex(-1) + , _currentRadioGroupIndex(-1) + , _isDividerEnabled(false) + , _itemsList(_CustomListItemImpl::DeleteCustomListItem) + , __pEmptyText(null) +{ + GET_SHAPE_CONFIG(LIST::LIST_DEFAULT_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, _defaultItemHeight); + GET_COLOR_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_NORMAL, __emptyTextColor); + + for (int i = 0; i < CHECK_BOX_MAX; i++) + { + _pCheckBitmaps[i] = null; + } + +} + +_ListBaseImpl::~_ListBaseImpl(void) +{ + for (int i = 0; i < CHECK_BOX_MAX; i++) + { + delete _pCheckBitmaps[i]; + } + + _TableView* pCore = static_cast<_TableView*>(&GetCore()); + SysTryReturnVoidResult(NID_UI_CTRL, (pCore != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get _TableView core object."); + + pCore->DetachAllChildren(); +} + +result +_ListBaseImpl::LoadDefaultBitmap(void) +{ + result r = E_SUCCESS; + + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + { + r = GET_BITMAP_CONFIG_N(LIST::BUTTON_RADIO_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_UNCHECKED]); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(LIST::BUTTON_RADIO_SELECTED_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_CHECKED]); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING) + { + r = GET_BITMAP_CONFIG_N(LIST::BUTTON_OFF_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_UNCHECKED]); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(LIST::BUTTON_ON_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_CHECKED]); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = GET_BITMAP_CONFIG_N(LIST::CHECK_BG_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_UNCHECKED]); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(LIST::CHECK_MARK_BG_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_CHECKED]); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(LIST::CHECK_DIM_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_DISABLED]); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +Tizen::Graphics::Bitmap** +_ListBaseImpl::GetCheckBitmaps(void) +{ + return _pCheckBitmaps; +} + +result +_ListBaseImpl::SetItemChecked(int groupIndex, int itemIndex, bool check) +{ + return E_SUCCESS; +} + +bool +_ListBaseImpl::IsItemChecked(int groupIndex, int itemIndex) const +{ + return false; +} + +void +_ListBaseImpl::OnTouchDoublePressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + return; +} + +void +_ListBaseImpl::OnTouchFocusIn(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + return; +} + +void +_ListBaseImpl::OnTouchFocusOut(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + OnTouchReleased(source, currentPosition, touchInfo); + return; +} + +void +_ListBaseImpl::OnTouchLongPressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + return; +} + +void +_ListBaseImpl::OnTouchMoved(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + return; +} + +void +_ListBaseImpl::OnTouchPressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + CustomListItem* pCustomListItem = GetItemFromControl(source); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item"); + + pCustomListItem->__pCustomListItemImpl->StartSliding(); + + UpdateElements(source, CUSTOM_LIST_ITEM_STATUS_FOCUSED); + return; +} + +void +_ListBaseImpl::OnTouchReleased(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) +{ + CustomListItem* pCustomListItem = GetItemFromControl(source); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item"); + + pCustomListItem->__pCustomListItemImpl->StopSliding(); + + UpdateElements(source, CUSTOM_LIST_ITEM_STATUS_NORMAL); + return; +} + +CustomListItem* +_ListBaseImpl::GetItemFromControl(const Control &source) +{ + _ITableViewBaseItemData* pBaseData = dynamic_cast<_ITableViewBaseItemData*>(const_cast(&source)); + SysTryReturn(NID_UI_CTRL, (pBaseData != null), null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + int groupIndex = -1; + int itemIndex = -1; + + pBaseData->GetIndex(groupIndex, itemIndex); + + return GetCustomListItemAt(groupIndex, itemIndex- GetTopItemIndex(groupIndex)); +} + +void +_ListBaseImpl::UpdateElements(const Control &source, CustomListItemStatus itemStatus) +{ + _ITableViewBaseItemData* pBaseData = dynamic_cast<_ITableViewBaseItemData*>(const_cast(&source)); + SysTryReturnVoidResult(NID_UI_CTRL, (pBaseData != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item."); + + int groupIndex = -1; + int itemIndex = -1; + + pBaseData->GetIndex(groupIndex, itemIndex); + + CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex - GetTopItemIndex(groupIndex)); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item"); + + LinkedList* pElements = &pCustomListItem->__pCustomListItemImpl->elements; + + int elementCount = pElements->GetCount(); + for (int i = 0; i < elementCount; i++) + { + _ElementBaseModel* pElementBase = dynamic_cast<_ElementBaseModel*>(pElements->GetAt(i)); + SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element."); + + if (pElementBase->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX) + { + pElementBase->HandleElementEvent(itemStatus); + } + } + + DrawItem(groupIndex, itemIndex); +} + +int +_ListBaseImpl::GetTopItemIndex(int groupIndex) const +{ + return 0; +} + +bool +_ListBaseImpl::IsItemNew(const CustomListItem& item) const +{ + for (int itemCount = 0; itemCount < _itemsList.GetCount(); itemCount++) + { + CustomListItem* pCustomListItem = dynamic_cast(const_cast(_itemsList.GetAt(itemCount))); + SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, + "A system error has occurred. Failed to get CustomList item at index %d.", itemCount); + + _CustomListItemImpl* pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl; + SysTryReturnResult(NID_UI_CTRL, pCustomListItemImpl, E_SYSTEM, "A system error has occurred. Failed to get an item at index(%d)", itemCount); + + if ((pCustomListItem == const_cast(&item)) && (pCustomListItemImpl->itemId == item.__pCustomListItemImpl->itemId)) + { + return false; + } + + for (int subItemCount = 0; subItemCount < GetSubItemCountAt(itemCount); subItemCount++) + { + CustomListItem* pCustomListItem = dynamic_cast(const_cast(pCustomListItemImpl->__pSubItemsList->GetAt(subItemCount))); + SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, + "A system error has occurred. Failed to get CustomList item at index %d.", itemCount); + + if ((pCustomListItem == const_cast(&item)) && (pCustomListItem->__pCustomListItemImpl->itemId == item.__pCustomListItemImpl->itemId)) + { + return false; + } + } + } + + return true; +} + +result +_ListBaseImpl::UpdateIndices(int groupIndex, int itemIndex, int updateBy) +{ + if (groupIndex == -1) + { + for (int index = itemIndex; index < _itemsList.GetCount(); index++) + { + _TableViewItemData* pTableViewItemData = GetTableViewItemAt(-1, index); + + if (pTableViewItemData) + { + pTableViewItemData->itemIndex += updateBy; + } + } + + if (_currentRadioIndex >= itemIndex) + { + _currentRadioIndex += updateBy; + } + } + else if (itemIndex == -1) + { + for (int index = groupIndex; index < _itemsList.GetCount(); index++) + { + _TableViewGroupItemData* pGroupItem = GetTableViewGroupItemAt(index); + + if (pGroupItem) + { + pGroupItem->groupIndex += updateBy; + } + } + + if (_currentRadioGroupIndex >= groupIndex) + { + _currentRadioGroupIndex += updateBy; + } + } + else + { + int subItemCount = GetSubItemCountAt(groupIndex); + + for (int index = itemIndex; index < subItemCount; index++) + { + _TableViewItemData* pTableViewItemData = GetTableViewItemAt(groupIndex, index); + + if (pTableViewItemData) + { + pTableViewItemData->itemIndex += updateBy; + } + } + + if (_currentRadioIndex >= itemIndex) + { + _currentRadioIndex += updateBy; + } + } + + return E_SUCCESS; +} + +result +_ListBaseImpl::InsertIntoItemsList(const CustomListItem& item, int groupIndex, int itemIndex, bool updateIndexes) +{ + result r = E_SUCCESS; + + if (GetCore().GetFirstDrawnFlag() == true) + { + updateIndexes = false; + } + + if (groupIndex == -1) + { + r = _itemsList.InsertAt(item, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (itemIndex == -1) + { + r = _itemsList.InsertAt(item, groupIndex); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to insert an item."); + } + else + { + CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1); + SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "A system error has occurred. Failed to get item at %d index.", groupIndex); + + if (pCustomListItem->__pCustomListItemImpl->__pSubItemsList == null) + { + pCustomListItem->__pCustomListItemImpl->__pSubItemsList = new (std::nothrow) ArrayList(_CustomListItemImpl::DeleteCustomListItem); + SysTryReturnResult(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl->__pSubItemsList, E_OUT_OF_MEMORY, "Memory allocation failed."); + + pCustomListItem->__pCustomListItemImpl->__pSubItemsList->Construct(1); + } + + pCustomListItem->__pCustomListItemImpl->__pSubItemsList->InsertAt(item, itemIndex); + } + + if (updateIndexes) + { + return UpdateIndices(groupIndex, itemIndex, 1); + } + else + { + return E_SUCCESS; + } +} + +result +_ListBaseImpl::RemoveFromItemsList(int groupIndex, int itemIndex, bool updateIndexes) +{ + result r = E_SUCCESS; + + if (GetCore().GetFirstDrawnFlag() == true) + { + updateIndexes = false; + } + + if (groupIndex == -1) + { + r = _itemsList.RemoveAt(itemIndex, true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "A system error has occurred. Failed to remove an item."); + } + else if (itemIndex == -1) + { + r = _itemsList.RemoveAt(groupIndex, true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to remove an item."); + } + else + { + CustomListItem* pCustomListGroupItem = dynamic_cast(const_cast(_itemsList.GetAt(groupIndex))); + SysTryReturnResult(NID_UI_CTRL, pCustomListGroupItem, E_SYSTEM, "A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex); + + ArrayList* pList = pCustomListGroupItem->__pCustomListItemImpl->__pSubItemsList; + SysTryReturnResult(NID_UI_CTRL, pList, E_SYSTEM, "A system error has occurred. Failed to get subItem at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex); + + r = pList->RemoveAt(itemIndex, true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "A system error has occurred. Failed to remove an item."); + } + + if (updateIndexes) + { + return UpdateIndices(groupIndex, itemIndex, -1); + } + else + { + return E_SUCCESS; + } + +} + +result +_ListBaseImpl::SetInItemsList(const CustomListItem& item, int groupIndex, int itemIndex) +{ + result r = E_SUCCESS; + + if (groupIndex == -1) + { + r = _itemsList.SetAt(item, itemIndex, true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "A system error has occurred. Failed to remove an item."); + } + else if (itemIndex == -1) + { + CustomListItem* pOldItem = GetCustomListItemAt(groupIndex, -1); + SysTryReturnResult(NID_UI_CTRL, pOldItem, E_SYSTEM, "A system error has occurred. Failed to get current item."); + + item.__pCustomListItemImpl->__pTableViewGroupItemData = pOldItem->__pCustomListItemImpl->__pTableViewGroupItemData; + item.__pCustomListItemImpl->__pSubItemsList = pOldItem->__pCustomListItemImpl->__pSubItemsList; + + r = _itemsList.SetAt(item, groupIndex, true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to remove an item."); + } + else + { + CustomListItem* pCustomListGroupItem = GetCustomListItemAt(groupIndex, -1); + SysTryReturnResult(NID_UI_CTRL, pCustomListGroupItem, E_SYSTEM, "A system error has occurred. Failed to get GroupItem at %d index.", groupIndex); + + ArrayList* pList = pCustomListGroupItem->__pCustomListItemImpl->__pSubItemsList; + SysTryReturnResult(NID_UI_CTRL, pList, E_SYSTEM, "A system error has occurred. Failed to get subItem at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex); + + pList->SetAt(item, itemIndex, true); + } + + return E_SUCCESS; +} + +void +_ListBaseImpl::RemoveAllFromItemsList(void) +{ + _itemsList.RemoveAll(true); +} + +CustomListItem* +_ListBaseImpl::GetCustomListItemAt(int groupIndex, int itemIndex) +{ + const CustomListItem* pItem = (static_cast(this))->GetCustomListItemAt(groupIndex, itemIndex); + return const_cast(pItem); +} + +const CustomListItem* +_ListBaseImpl::GetCustomListItemAt(int groupIndex, int itemIndex) const +{ + if (groupIndex == -1) + { + CustomListItem* pCustomListItem = dynamic_cast(const_cast(_itemsList.GetAt(itemIndex))); + SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. itemIndex = %d", itemIndex); + + return pCustomListItem; + } + else if (itemIndex == -1) + { + CustomListItem* pCustomListItem = dynamic_cast(const_cast(_itemsList.GetAt(groupIndex))); + SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d", groupIndex); + + return pCustomListItem; + } + else + { + CustomListItem* pCustomListGroupItem = dynamic_cast(const_cast(_itemsList.GetAt(groupIndex))); + SysTryReturn(NID_UI_CTRL, pCustomListGroupItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex); + + ArrayList* pList = pCustomListGroupItem->__pCustomListItemImpl->__pSubItemsList; + SysTryReturn(NID_UI_CTRL, pList, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get subItem at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex); + + CustomListItem* pCustomListItem = dynamic_cast(const_cast(pList->GetAt(itemIndex))); + SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex); + + return pCustomListItem; + } +} + +_TableViewItemData* +_ListBaseImpl::GetTableViewItemAt(int groupIndex, int itemIndex) +{ + const _TableViewItemData* pTableViewItemData = (static_cast(this))->GetTableViewItemAt(groupIndex, itemIndex); + return const_cast<_TableViewItemData*>(pTableViewItemData); +} + +const _TableViewItemData* +_ListBaseImpl::GetTableViewItemAt(int groupIndex, int itemIndex) const +{ + const CustomListItem* pCustomListGroupItem = (static_cast(this))->GetCustomListItemAt(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, pCustomListGroupItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex); + + SysTryReturn(NID_UI_CTRL, pCustomListGroupItem->__pCustomListItemImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex); + + return pCustomListGroupItem->__pCustomListItemImpl->__pTableViewItemData; +} + +_TableViewGroupItemData* +_ListBaseImpl::GetTableViewGroupItemAt(int groupIndex) +{ + const _TableViewGroupItemData* pTableViewGroupItemData = (static_cast(this))->GetTableViewGroupItemAt(groupIndex); + return const_cast<_TableViewGroupItemData*>(pTableViewGroupItemData); +} + +const _TableViewGroupItemData* +_ListBaseImpl::GetTableViewGroupItemAt(int groupIndex) const +{ + const CustomListItem* pCustomListGroupItem = (static_cast(this))->GetCustomListItemAt(groupIndex, -1); + SysTryReturn(NID_UI_CTRL, pCustomListGroupItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex); + + SysTryReturn(NID_UI_CTRL, pCustomListGroupItem->__pCustomListItemImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex); + + return pCustomListGroupItem->__pCustomListItemImpl->__pTableViewGroupItemData; +} + +_CheckElementModel* +_ListBaseImpl::GetCheckElementAt(int groupIndex, int itemIndex) +{ + const _CheckElementModel* pCheckElementModel = (static_cast(this))->GetCheckElementAt(groupIndex, itemIndex); + return const_cast<_CheckElementModel*>(pCheckElementModel); +} + +const _CheckElementModel* +_ListBaseImpl::GetCheckElementAt(int groupIndex, int itemIndex) const +{ + const CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d), itemIndex(%d)", groupIndex, itemIndex); + + SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d), itemIndex(%d)", groupIndex, itemIndex); + + return pCustomListItem->__pCustomListItemImpl->GetCheckElement(); +} + +void +_ListBaseImpl::DrawItem(int groupIndex, int itemIndex) +{ + if (itemIndex == -1) + { + _TableViewGroupItemData* pTableViewGroupItemData = GetTableViewGroupItemAt(groupIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pTableViewGroupItemData, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex); + + pTableViewGroupItemData->Invalidate(true); + } + else + { + _TableViewItemData* pTableViewItemData = GetTableViewItemAt(groupIndex, itemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pTableViewItemData, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d), itemIndex(%d)", groupIndex, itemIndex); + + pTableViewItemData->Invalidate(true); + } +} + +result +_ListBaseImpl::SetListStyle(CustomListStyle style) +{ + result r = E_SUCCESS; + + switch (style) + { + case CUSTOM_LIST_STYLE_NORMAL: + _annexStyle = TABLE_VIEW_ANNEX_STYLE_NORMAL; + break; + + case CUSTOM_LIST_STYLE_RADIO: + _annexStyle = TABLE_VIEW_ANNEX_STYLE_RADIO; + break; + + case CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER: + _annexStyle = TABLE_VIEW_ANNEX_STYLE_RADIO; + _isDividerEnabled = true; + break; + + case CUSTOM_LIST_STYLE_MARK: + _annexStyle = TABLE_VIEW_ANNEX_STYLE_MARK; + break; + + case CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER: + _annexStyle = TABLE_VIEW_ANNEX_STYLE_MARK; + _isDividerEnabled = true; + break; + + case CUSTOM_LIST_STYLE_ONOFF: + _annexStyle = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING; + break; + + case CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER: + _annexStyle = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING; + _isDividerEnabled = true; + break; + + default: + SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument used. style is invalid."); + r = E_INVALID_ARG; + break; + } + + return r; +} + +_TableView& +_ListBaseImpl::GetCore(void) +{ + return static_cast<_TableView&>(_ControlImpl::GetCore()); +} + +const _TableView& +_ListBaseImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +void +_ListBaseImpl::SetTextOfEmptyList(const String& text) +{ + if (text.IsEmpty()) + { + if (__pEmptyText != null) + { + GetCore().DetachChild(*__pEmptyText); + + delete __pEmptyText; + __pEmptyText = null; + } + } + else + { + if (__pEmptyText == null) + { + __pEmptyText = _Label::CreateLabelN(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pEmptyText != null), E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pEmptyText->SetVisibleState(false); + __pEmptyText->SetMargin(0, 0); + + GetCore().AttachChild(*__pEmptyText); + } + + TextObject* pText = new (std::nothrow) TextObject; + SysTryReturnVoidResult(NID_UI_CTRL, (pText != null), E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pText->Construct(); + + TextSimple* pSimpleText = new (std::nothrow) TextSimple(const_cast (text.GetPointer()), text.GetLength()); + SysTryReturnVoidResult(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pText->AppendElement(*pSimpleText); + + int textSize = 0; + GET_SHAPE_CONFIG(LIST::EMPTY_LIST_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, textSize); + + Font font; + font.Construct(GetFont(), FONT_STYLE_PLAIN, textSize); + pText->SetFont(&font, 0, pText->GetTextLength()); + + Dimension listDimension = GetCore().GetSize(); + + pText->SetBounds(Rectangle(0, 0, listDimension.width, 1)); + pText->Compose(); + + Dimension labelDimension = pText->GetTextExtent(0, pText->GetTextLength()); + labelDimension.height = pText->GetTotalHeight(); + + if (labelDimension.width > listDimension.width) + { + pText->SetBounds(Rectangle(0, 0, listDimension.width, 1)); + pText->Compose(); + + int labelHeight = pText->GetTotalHeight(); + + labelDimension.width = listDimension.width; + labelDimension.height = ((listDimension.height < labelHeight) ? listDimension.height : labelHeight); + } + + delete pText; + + Rectangle bounds = GetCore().GetBounds(); + + __pEmptyText->SetBounds(Rectangle((bounds.width - labelDimension.width)/2, (bounds.height - labelDimension.height)/2, labelDimension.width, labelDimension.height)); + __pEmptyText->SetBackgroundColor(Color(0, 0, 0, 0)); + __pEmptyText->SetTextColor(__emptyTextColor); + __pEmptyText->SetTextConfig(textSize, LABEL_TEXT_STYLE_NORMAL); + __pEmptyText->SetText(text); + } + + return; +} + +void +_ListBaseImpl::SetTextColorOfEmptyList(const Color& color) +{ + __emptyTextColor = color; + + if (__pEmptyText != null) + { + __pEmptyText->SetTextColor(color); + } + + return; +} + +Color +_ListBaseImpl::GetTextColorOfEmptyList(void) const +{ + return __emptyTextColor; +} + +result +_ListBaseImpl::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + result r = GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_ListBaseImpl::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + result r = GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_ListBaseImpl::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const +{ + return GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex); +} + +int +_ListBaseImpl::GetItemCount(void) const +{ + return _itemsList.GetCount(); +} + +int +_ListBaseImpl::GetGroupCount(void) const +{ + return _itemsList.GetCount(); +} + +int +_ListBaseImpl::GetSubItemCountAt(int groupIndex) const +{ + result r = E_SUCCESS; + + const CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + ArrayList* pList = pCustomListItem->__pCustomListItemImpl->__pSubItemsList; + SysTryReturn(NID_UI_CTRL, pList, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get subItemsList at groupIndex(%d)", groupIndex); + + return pList->GetCount(); +} + +result +_ListBaseImpl::RemoveFromSubItemsList(int groupIndex) +{ + result r = E_SUCCESS; + + const CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + ArrayList* pList = pCustomListItem->__pCustomListItemImpl->__pSubItemsList; + + if (pList) + { + pList->RemoveAll(); + delete pList; + pCustomListItem->__pCustomListItemImpl->__pSubItemsList = null; + } + + return E_SUCCESS; +} + +void +_ListBaseImpl::OnDraw(void) +{ + _ControlImpl::OnDraw(); + + bool isEmpty = (GetItemCount() <= 0); + + if (__pEmptyText != null) + { + __pEmptyText->SetVisibleState(isEmpty); + } +} + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ListContextItemImpl.cpp b/src/ui/controls/FUiCtrl_ListContextItemImpl.cpp new file mode 100644 index 0000000..7740e45 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ListContextItemImpl.cpp @@ -0,0 +1,189 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListContextItemImpl.cpp + * @brief This is the implementation file for _ListContextItemImpl class. + * + * This file contains the implementation of _ListContextItemImpl class. + */ + +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_ListContextItemImpl.h" +#include "FUiCtrl_ListViewContextItem.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ListContextItemImpl* +_ListContextItemImpl::GetInstance(ListContextItem& listContextItem) +{ + return listContextItem.__pImpl; +} + +const _ListContextItemImpl* +_ListContextItemImpl::GetInstance(const ListContextItem& listContextItem) +{ + return listContextItem.__pImpl; +} + +_ListContextItemImpl::_ListContextItemImpl(ListContextItem* pPublic) + : __pPublic(pPublic) + , __pContextItem(null) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pContextItem != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is not sufficient."); +} + +_ListContextItemImpl::~_ListContextItemImpl(void) +{ + if (__pContextItem != null) + { + __pContextItem->Release(); + } +} + +const char* +_ListContextItemImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::ListContextItem"; +} + +const ListContextItem& +_ListContextItemImpl::GetPublic(void) const +{ + return static_cast (*__pPublic); +} + +ListContextItem& +_ListContextItemImpl::GetPublic(void) +{ + return *__pPublic; +} + +_ListContextItemImpl* +_ListContextItemImpl::CreateListContextItemImplN(ListContextItem* pPublic) +{ + result r = E_SUCCESS; + + _ListContextItemImpl* pImpl = new (std::nothrow) _ListContextItemImpl(pPublic); + SysTryReturn(NID_UI_CTRL, pImpl != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = pImpl->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; + +CATCH: + delete pImpl; + pImpl = null; + + return null; +} + +result +_ListContextItemImpl::Construct(void) +{ + __pContextItem = _ListViewContextItem::CreateListViewContextItemN(0); + SysTryReturn(NID_UI_CTRL, (__pContextItem != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + Color bgColor(0, 0, 0, 0); + GET_COLOR_CONFIG(LISTVIEW::CONTEXTITEM_BG_NORMAL, bgColor); + SetBackgroundColor(bgColor); + + return E_SUCCESS; +} + +result +_ListContextItemImpl::AddElement(int elementId, const String& text, bool enable) +{ + SysTryReturn(NID_UI_CTRL, (elementId >= 0) && (elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] The element ID should not be less than 0.")); + + SysTryReturn(NID_UI_CTRL, (__pContextItem->AddElement(elementId, text, enable) == true), E_SYSTEM, E_SYSTEM, + ("[E_SYSTEM] Unable to add an element.")); + + return E_SUCCESS; +} + +result +_ListContextItemImpl::AddElement(int elementId, const Bitmap& normalBitmap, + const Bitmap& pressedBitmap, const Bitmap* pHighlightedBitmap, bool enable) +{ + SysTryReturn(NID_UI_CTRL, (elementId >= 0) && (elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] The element ID should not be less than 0.")); + + SysTryReturn(NID_UI_CTRL, (__pContextItem->AddElement(elementId, &normalBitmap, &pressedBitmap, pHighlightedBitmap, enable) == true), + E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to add an element."); + + return E_SUCCESS; +} + +result +_ListContextItemImpl::AddElement(int elementId, const String& text, const Bitmap& normalBitmap, + const Bitmap& pressedBitmap, const Bitmap* pHighlightedBitmap, bool enable) +{ + SysTryReturn(NID_UI_CTRL, (elementId >= 0 && elementId <= Integer::VALUE_MAX), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] The element ID should not be less than 0.")); + + SysTryReturn(NID_UI_CTRL, (__pContextItem->AddElement(elementId, text, &normalBitmap, &pressedBitmap, pHighlightedBitmap, enable) == true), + E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to add an element."); + + return E_SUCCESS; +} + +Color +_ListContextItemImpl::GetBackgroundColor(void) const +{ + return __pContextItem->GetItemBackgroundColor(LIST_ITEM_STATE_NORMAL); +} + +result +_ListContextItemImpl::SetBackgroundColor(const Color& color) +{ + __pContextItem->SetItemBackgroundColor(LIST_ITEM_STATE_NORMAL, color); + __pContextItem->SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, color); + __pContextItem->SetItemBackgroundColor(LIST_ITEM_STATE_HIGHLIGHTED, color); + __pContextItem->SetItemChanged(true); + + return E_SUCCESS; +} + +result +_ListContextItemImpl::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + __pContextItem->SetItemBackgroundBitmap(LIST_ITEM_STATE_NORMAL, pBitmap); + __pContextItem->SetItemChanged(true); + + return E_SUCCESS; +} + +_ListViewContextItem* +_ListContextItemImpl::GetContextItem(void) const +{ + return __pContextItem; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ListImpl.cpp b/src/ui/controls/FUiCtrl_ListImpl.cpp new file mode 100644 index 0000000..323e846 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ListImpl.cpp @@ -0,0 +1,2171 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListImpl.cpp + * @brief This is the implementation file for the _ListImpl class. + * + */ + +#include +#include +#include "FUiCtrl_ListImpl.h" +#include "FUiCtrl_ListListener.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_UiBuilder.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui { namespace Controls +{ + +extern const int INVALID_INDEX; + +_NumberElement::_NumberElement(void) + : index(-1) +{ +} + +_NumberElement::~_NumberElement(void) +{ +} + +_ListItemDataProvider::_ListItemDataProvider(_ListImpl* pListImpl) + : __pListImpl(pListImpl) +{ +} + +_ListItemDataProvider::~_ListItemDataProvider(void) +{ +} + +int +_ListItemDataProvider::GetItemCount(void) +{ + SysTryReturn(NID_UI_CTRL, __pListImpl, -1, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List instance is null."); + return __pListImpl->GetItemCount(); +} + +TableViewItem* +_ListItemDataProvider::CreateItem(int index, int itemWidth) +{ + SysTryReturn(NID_UI_CTRL, __pListImpl, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List instance is null."); + + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(-1, index); + SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", index); + + _CustomListItemImpl* pCustomListItemImpl = null; + pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl; + SysTryReturn(NID_UI_CTRL, pCustomListItemImpl, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. _CustomListItemImpl instance is null."); + + int height = __pListImpl->__row1Height + __pListImpl->__row2Height; + pCustomListItemImpl->height = height; + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = (const_cast(pCustomListItem)); + tableViewItemParams.width = itemWidth; + tableViewItemParams.itemId = pCustomListItemImpl->itemId; + tableViewItemParams.itemIndex = index; + tableViewItemParams.groupIndex = -1; + tableViewItemParams.isDividerEnabled = __pListImpl->_isDividerEnabled; + tableViewItemParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps; + tableViewItemParams.annexStyle = __pListImpl->_annexStyle; + + result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pCustomListItemImpl->__pTableViewItemData->AddTouchEventListener(*__pListImpl); + + return pCustomListItemImpl->__pTableViewItemData; +} + +bool +_ListItemDataProvider::DeleteItem(const int itemIndex, TableViewItem* pItem) +{ + _TableViewItemData* pTableViewItemData = dynamic_cast<_TableViewItemData*>(pItem); + delete pTableViewItemData; + + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(-1, itemIndex); + pCustomListItem->__pCustomListItemImpl->__pTableViewItemData = null; + + return true; +} + +int +_ListItemDataProvider::GetDefaultItemHeight(void) +{ + SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List instance is null."); + return (__pListImpl->__row1Height + __pListImpl->__row2Height); +} + +void +_ListItemDataProvider::UpdateItem(int itemIndex, TableViewItem* pItem) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pListImpl, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List instance is null."); + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(-1, itemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", itemIndex); + + _CustomListItemImpl* pCustomListItemImpl = null; + pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl; + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItemImpl, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. _CustomListItemImpl instance is null."); + + int height = __pListImpl->__row1Height + __pListImpl->__row2Height; + pCustomListItemImpl->height = height; + + SysTryReturnVoidResult(NID_UI_CTRL, pItem, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", itemIndex); + Rectangle rect = pItem->GetBounds(); + pItem->SetSize(rect.width, height); + + //return true; +} + +result +_NumberElement::DrawElement(const Canvas& canvas, const Rectangle& rect, CustomListItemStatus itemStatus) +{ + String text; + text.Append(index); + + Canvas* pCanvas = const_cast(&canvas); + SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), E_SYSTEM, + "A system error has occurred. Failed to get the canvas."); + + pCanvas->FillRectangle(Color::GetColor(COLOR_ID_MAGENTA), rect); + pCanvas->SetForegroundColor(Color::GetColor(COLOR_ID_WHITE)); + + Font font; + + font.Construct(FONT_STYLE_PLAIN, 18); + pCanvas->SetFont(font); + + if (pCanvas->DrawText(Point(rect.x + 5, rect.y + 5), String(text)) != E_SUCCESS) + { + return E_SYSTEM; + } + + return E_SUCCESS; +} + +_ListImpl* +_ListImpl::GetInstance(List& list) +{ + return static_cast<_ListImpl*>(list._pControlImpl); +} + +const _ListImpl* +_ListImpl::GetInstance(const List& list) +{ + return static_cast(list._pControlImpl); +} + +_ListImpl::_ListImpl(Control* pList, _TableView* pCore) + : _ListBaseImpl(pList, pCore) + , __row1Height(-1) + , __row2Height(-1) + , __column1Width(-1) + , __column2Width(-1) + , __text1SlideEnabled(true) + , __text2SlideEnabled(true) + , __listStyle(LIST_STYLE_NORMAL) + , __listItemFormat(LIST_ITEM_SINGLE_IMAGE) + , __pNormalBgBitmap(null) + , __pHighlightedBgBitmap(null) + , __pFocusedBgBitmap(null) + , __pNumberElements(null) + , __pItemFormat(null) + , __pItemProvider(null) + , maxCount(0) + , divider(false) +{ + +} + +_ListImpl::~_ListImpl(void) +{ + __itemListeners.RemoveAll(true); + + if (__pNumberElements != null) + { + __pNumberElements->RemoveAll(true); + delete __pNumberElements; + __pNumberElements = null; + } + + if (__pItemFormat != null) + { + delete __pItemFormat; + __pItemFormat = null; + } + + if (__pItemProvider) + { + delete __pItemProvider; + __pItemProvider = null; + } + + RemoveAllFromItemsList(); +} + +const char* +_ListImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::List"; +} + +const List& +_ListImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +List& +_ListImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _TableView& +_ListImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_TableView& +_ListImpl::GetCore(void) +{ + return static_cast<_TableView&>(_ControlImpl::GetCore()); +} + +_ListImpl* +_ListImpl::CreateListImplN(List* pControl, const Rectangle& bounds) +{ + result r = E_SUCCESS; + + r = GET_SIZE_INFO(List).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _TableView* pCore = null; + _ListImpl* pImpl = null; + + pCore = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_SIMPLE, true, TABLE_VIEW_SCROLL_BAR_STYLE_FIXED); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl = new (std::nothrow) _ListImpl(pControl, pCore); + SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + ClearLastResult(); + + return pImpl; + +CATCH: + delete pCore; + return null; +} + +result +_ListImpl::Initialize(ListItemFormat itemFormat, int row1Height, int row2Height, int column1Width, int column2Width) +{ + result r = E_SUCCESS; + + GET_FIXED_VALUE_CONFIG(LIST::LIST_ITEM_MAX_COUNT, GetCore().GetOrientation(), maxCount); + + __pItemProvider = new (std::nothrow) _ListItemDataProvider(this); + SysTryReturnResult(NID_UI_CTRL, (__pItemProvider != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryReturn(NID_UI_CTRL, style == TABLE_VIEW_STYLE_SIMPLE, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current style of TableView is not TABLE_VIEW_STYLE_SIMPLE"); + + _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style); + SysTryReturn(NID_UI_CTRL, pItemProvider != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pItemProvider->SetSimpleStyleItemProvider(__pItemProvider); + + if (r != E_SUCCESS) + { + delete pItemProvider; + SysTryReturn(NID_UI_CTRL, false, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = GetCore().SetItemProvider(pItemProvider); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetCore().AddTableViewItemEventListener(*this); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetListItemFormat(itemFormat); + + r = InitializeItemSizes(row1Height, row2Height, column1Width, column2Width); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = InitCustomListItemFormat(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_ListImpl::InitializeItemSizes(int row1Height, int row2Height, int column1Width, int column2Width) +{ + result r = E_SUCCESS; + + r = SetRow1Height(row1Height); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetRow2Height(row2Height); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetColumn1Width(column1Width); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetColumn2Width(column2Width); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_ListImpl::UpdateBounds(const Rectangle& rect) +{ + result r = E_SUCCESS; + + r = InitializeBoundsProperties(GET_SIZE_INFO(CustomList), rect, GetCore().GetOrientation()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_ListImpl::SetStyle(ListStyle style) +{ + __listStyle = style; + result r = E_SUCCESS; + + switch (style) + { + case LIST_STYLE_NORMAL: + case LIST_STYLE_NUMBER: + _annexStyle = TABLE_VIEW_ANNEX_STYLE_NORMAL; + break; + + case LIST_STYLE_RADIO_WITH_DIVIDER: + _isDividerEnabled = true; + _annexStyle = TABLE_VIEW_ANNEX_STYLE_RADIO; + break; + + case LIST_STYLE_RADIO: + divider = true; + _annexStyle = TABLE_VIEW_ANNEX_STYLE_RADIO; + break; + + case LIST_STYLE_MARK_WITH_DIVIDER: + _isDividerEnabled = true; + _annexStyle = TABLE_VIEW_ANNEX_STYLE_MARK; + break; + + case LIST_STYLE_MARK: + divider = true; + _annexStyle = TABLE_VIEW_ANNEX_STYLE_MARK; + break; + + case LIST_STYLE_ONOFF_WITH_DIVIDER: + _isDividerEnabled = true; + _annexStyle = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING; + break; + + case LIST_STYLE_ONOFF: + divider = true; + _annexStyle = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING; + break; + + default: + r = E_INVALID_ARG; + break; + } + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "The current value of List style is invalid."); + + if ((style == LIST_STYLE_NUMBER) && (__pNumberElements == null)) + { + __pNumberElements = new (std::nothrow) LinkedList(); + SysTryReturnResult(NID_UI_CTRL, __pNumberElements, E_OUT_OF_MEMORY, "Memory allocation failed."); + } + + return E_SUCCESS; + +} + +void +_ListImpl::SetListItemFormat(ListItemFormat itemFormat) +{ + __listItemFormat = itemFormat; + return; +} + +result +_ListImpl::InitCustomListItemFormat(void) +{ + __pItemFormat = new (std::nothrow) CustomListItemFormat(); + SysTryReturnResult(NID_UI_CTRL, (__pItemFormat != null), E_OUT_OF_MEMORY, "Memory allocation failed."); + + __pItemFormat->Construct(); + + Rectangle text1Rect; + Rectangle text2Rect; + Rectangle img1Rect; + Rectangle img2Rect; + GetElementRects(text1Rect, text2Rect, img1Rect, img2Rect); + + int textSize = 0; + int listStyleNumberX = 0; + int listStyleNumberWidth = 0; + int listStyleNumberHeight = 0; + int checkItemWidth = 0; + int checkItemHeight = 0; + + GET_SHAPE_CONFIG(LIST::LIST_ITEM_TEXT_SIZELIST, GetCore().GetOrientation(), textSize); + + GET_SHAPE_CONFIG(LIST::LIST_STYLE_NUMBER_X, GetCore().GetOrientation(), listStyleNumberX); + GET_SHAPE_CONFIG(LIST::LIST_STYLE_NUMBER_WIDTH, GetCore().GetOrientation(), listStyleNumberWidth); + GET_SHAPE_CONFIG(LIST::LIST_STYLE_NUMBER_HEIGHT, GetCore().GetOrientation(), listStyleNumberHeight); + + GET_SHAPE_CONFIG(LIST::LIST_CHECK_ITEM_WIDTH, GetCore().GetOrientation(), checkItemWidth); + GET_SHAPE_CONFIG(LIST::LIST_CHECK_ITEM_HEIGHT, GetCore().GetOrientation(), checkItemHeight); + + if (__listItemFormat != LIST_ITEM_SINGLE_IMAGE) + { + GET_COLOR_CONFIG(LIST::ELEMENT_TEXT_NORMAL, __text1Color); + } + if (__listItemFormat > LIST_ITEM_SINGLE_IMAGE_TEXT_IMAGE) + { + GET_COLOR_CONFIG(LIST::ELEMENT_TEXT_NORMAL, __text2Color); + } + + if (text1Rect.x > 0) + { + __pItemFormat->AddElement(ID_FORMAT_TEXT1, text1Rect); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_TEXT1, false); + } + + if (img1Rect.x > 0) + { + __pItemFormat->AddElement(ID_FORMAT_IMAGE1, img1Rect); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_IMAGE1, false); + } + + if (text2Rect.x > 0) + { + __pItemFormat->AddElement(ID_FORMAT_TEXT2, text2Rect); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_TEXT2, false); + } + + if (img2Rect.x > 0) + { + __pItemFormat->AddElement(ID_FORMAT_IMAGE2, img2Rect); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_IMAGE2, false); + } + + if (__listStyle == LIST_STYLE_NUMBER) + { + __pItemFormat->AddElement(ID_FORMAT_NUMBER, Rectangle(listStyleNumberX, GetItemHeight()/2 - 15, listStyleNumberWidth, listStyleNumberHeight)); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_NUMBER, false); + } + + if (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL) + { + __pItemFormat->AddElement(ID_FORMAT_CHECK, Rectangle(GetCore().GetBounds().width - 60, GetItemHeight() / 2 - 25, checkItemWidth , checkItemHeight)); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_CHECK, true); + } + + return E_SUCCESS; +} + +bool +_ListImpl::GetTextSlide(ListItemText textIndex) +{ + switch (textIndex) + { + case LIST_ITEM_TEXT1: + return __text1SlideEnabled; + + case LIST_ITEM_TEXT2: + return __text2SlideEnabled; + + default: + SysTryReturn(NID_UI_CTRL, false, false, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The ListItemText is invalid."); + } +} + +result +_ListImpl::AddItemEventListener(const IItemEventListener& listener) +{ + _ListListener* pListListener = new (std::nothrow) _ListListener; + SysTryReturn(NID_UI_CTRL, pListListener, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pListListener->pListener = const_cast(&listener); + __itemListeners.Add(*pListListener); + + return E_SUCCESS; +} + +result +_ListImpl::RemoveItemEventListener(const IItemEventListener& listener) +{ + _ListListener* pListListener = null; + result r = E_SYSTEM; + int count = __itemListeners.GetCount(); + + for (int listenerCount = 0; listenerCount < count; listenerCount++) + { + pListListener = dynamic_cast<_ListListener*>(__itemListeners.GetAt(listenerCount)); + + if ((pListListener != null) && (pListListener->pListener == &listener)) + { + r = E_SUCCESS; + __itemListeners.RemoveAt(listenerCount, true); + break; + } + } + + return r; +} + +result +_ListImpl::AddItem(const String* pText1, const String* pText2, + const Bitmap* pBitmap1, const Bitmap* pBitmap2, int itemId) +{ + if (__listStyle == LIST_STYLE_NUMBER) + { + SysTryReturnResult(NID_UI_CTRL, (GetItemCount() < maxCount), + E_MAX_EXCEEDED, "AddItem operation exceeds the maximum limit for this list style"); + } + + return InsertItemAt(GetItemCount(), pText1, pText2, pBitmap1, pBitmap2, itemId); +} + +result +_ListImpl::InsertItemAt(int index, const String* pText1, const String* pText2, + const Bitmap* pBitmap1, const Bitmap* pBitmap2, int itemId) +{ + result r = E_SUCCESS; + + if (__listStyle == LIST_STYLE_NUMBER) + { + SysTryReturnResult(NID_UI_CTRL, (GetItemCount() < maxCount), + E_MAX_EXCEEDED, "InsertItemAt operation exceeds the maximum limit for this list style"); + } + + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index <= GetItemCount()), + E_OUT_OF_RANGE, "The index(%d) is out of range.", index); + + CustomListItem *pItem = GetNewItemN(pText1, pText2, pBitmap1, pBitmap2, itemId, index); + SysTryReturnResult(NID_UI_CTRL, pItem, GetLastResult(), + "A system error has occurred. CustomListItem instance is null."); + + r = InsertIntoItemsList(*pItem, -1, index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Failed to insert an item.", GetErrorMessage(r)); + + if (GetCore().GetFirstDrawnFlag() == false) + { + r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] Propagating.",GetErrorMessage(r)); + } + + if (__listStyle == LIST_STYLE_NUMBER) + { + r = UpdateNumbers(index); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to update the numbers"); + } + GetCore().Draw(); + + return E_SUCCESS; + +CATCH: + RemoveFromItemsList(-1, index); + + if (__listStyle == LIST_STYLE_NUMBER) + { + __pNumberElements->RemoveAt(index, true); + } + return E_SYSTEM; +} + +result +_ListImpl::SetItemAt(int index, const String* pText1, const String* pText2, + const Bitmap* pBitmap1, const Bitmap* pBitmap2, int itemId) +{ + result r = E_SUCCESS; + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), + E_OUT_OF_RANGE, "The index(%d) is out of range.", index); + + if (__listStyle == LIST_STYLE_NUMBER) + { + __pNumberElements->RemoveAt(index, true); + } + + CustomListItem *pItem = GetNewItemN(pText1, pText2, pBitmap1, pBitmap2, itemId, index); + SysTryReturnResult(NID_UI_CTRL, pItem, GetLastResult(), + "A system error has occurred. CustomListItem instance is null."); + + pItem->__pCustomListItemImpl->__pTableViewItemData = GetTableViewItemAt(-1, index); + + _CheckElementModel* pCheckElement = null; + _CheckElementModel* pOldCheckElement = GetCheckElementAt(-1, index); + _CheckBoxStatus oldCheckStatus = (pOldCheckElement) ? (pOldCheckElement->GetCheckBoxStatus()) : CHECK_BOX_UNCHECKED; + + pItem->__pCustomListItemImpl->itemId = itemId; + + pCheckElement = GetCheckElementAt(-1, index); + + if (pCheckElement) + { + pCheckElement->SetCheckBoxStatus(oldCheckStatus); + } + + r = SetInItemsList(*pItem, -1, index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to perform SetAt operation.", GetErrorMessage(r)); + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = const_cast(pItem); + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), false, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to refresh an item."); + + if (GetCore().GetFirstDrawnFlag() == false) + { + r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.",GetErrorMessage(r)); + } + + r = GetCore().SetItemEnabled(0, index, true); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, + "A system error has occurred. Failed to enable an item."); + + return r; +} + +result +_ListImpl::RemoveItemAt(int index) +{ + result r = E_SUCCESS; + int groupIndex = 0; + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), + E_OUT_OF_RANGE, "The index(%d) is out of range.", index); + + if (GetCore().GetFirstDrawnFlag() == false) + { + r = GetCore().RefreshTableView(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Propagating."); + } + + r = RemoveFromItemsList(-1, index); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "Failed to perform RemoveAt operation"); + + if (__listStyle == LIST_STYLE_NUMBER) + { + __pNumberElements->RemoveAt(index, true); + r = UpdateNumbers(index - 1); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Failed to perform UpdateNumbers", GetErrorMessage(r)); + } + + GetCore().Draw(); + + return r; +} + +result +_ListImpl::RemoveAllItems(void) +{ + result r = E_SUCCESS; + int count = GetItemCount(); + int itemIndex = 0; + + result finalResult = E_SUCCESS; + + for (itemIndex = count - 1; itemIndex >= 0; itemIndex--) + { + r = RemoveItemAt(itemIndex); + if (r != E_SUCCESS) + { + finalResult = r; + SysLog(NID_UI_CTRL, "[%s] Failed to remove item at index(%d)", GetErrorMessage(r), itemIndex); + } + } + + return finalResult; +} + +result +_ListImpl::SetItemEnabled(int index, bool enable) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), E_SYSTEM, + "A system error has occurred. The current value of index(%d) is invalid.", index); + + _CheckElementModel* pCheckElementModel = GetCheckElementAt(-1, index); + + if (pCheckElementModel) + { + if (enable) + { + if (pCheckElementModel->GetCheckBoxStatus() == CHECK_BOX_DISABLED) + { + pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_CHECKED); + } + } + else + { + if (pCheckElementModel->GetCheckBoxStatus() == CHECK_BOX_CHECKED) + { + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) + { + pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_DISABLED); + } + } + } + } + + r = GetCore().SetItemEnabled(0, index, enable); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + DrawItem(-1, index); + + return r; +} + +bool +_ListImpl::IsItemEnabled(int index) const +{ + return GetCore().IsItemEnabled(0, index); +} + +void +_ListImpl::SetFocusedItemBackgroundBitmap(const Bitmap& bitmap) +{ + __pFocusedBgBitmap = const_cast(&bitmap); + SysTryReturnVoidResult(NID_UI_CTRL, __pFocusedBgBitmap, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the Bitmap"); + SetBitmap(TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED, bitmap); + + return; +} + +void +_ListImpl::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap) +{ + __pHighlightedBgBitmap = const_cast(&bitmap); + SysTryReturnVoidResult(NID_UI_CTRL, __pHighlightedBgBitmap, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the Bitmap"); + SetBitmap(TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED, bitmap); + + return; +} + +void +_ListImpl::SetNormalItemBackgroundBitmap(const Bitmap& bitmap) +{ + __pNormalBgBitmap = const_cast(&bitmap); + SysTryReturnVoidResult(NID_UI_CTRL, __pNormalBgBitmap, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the Bitmap"); + SetBitmap(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL, bitmap); + + return; +} + +void +_ListImpl::SetItemTextColor(ListItemText textIndex, const Color& textColor) +{ + int elementId = -1; + + SysTryReturnVoidResult(NID_UI_CTRL, (__listItemFormat != LIST_ITEM_SINGLE_IMAGE), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The current value of ListItemFormat is invalid."); + + switch (textIndex) + { + case LIST_ITEM_TEXT1: + __text1Color.SetRGB32(textColor.GetRGB32(), textColor.GetAlpha()); + elementId = ID_FORMAT_TEXT1; + break; + + case LIST_ITEM_TEXT2: + SysTryReturnVoidResult(NID_UI_CTRL, (__listItemFormat > LIST_ITEM_SINGLE_IMAGE_TEXT_IMAGE), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The current value of ListItemFormat is invalid."); + __text2Color.SetRGB32(textColor.GetRGB32(), textColor.GetAlpha()); + elementId = ID_FORMAT_TEXT2; + break; + + default: + SysTryReturnVoidResult(NID_UI_CTRL, (false), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The current value of ListItemText is invalid."); + } + + Rectangle text1Rect; + Rectangle text2Rect; + Rectangle img1Rect; + Rectangle img2Rect; + + GetElementRects(text1Rect, text2Rect, img1Rect, img2Rect); + + switch (textIndex) + { + case LIST_ITEM_TEXT1: + __pItemFormat->AddElement(elementId, text1Rect, 38, __text1Color, __text1Color, __text1Color); + break; + + case LIST_ITEM_TEXT2: + __pItemFormat->AddElement(elementId, text2Rect, 38, __text2Color, __text2Color, __text2Color); + break; + } + + int count = GetItemCount(); + for (int index = 0; index < count; index++) + { + Refresh(index); + } + + return; +} + +Color +_ListImpl::GetItemTextColor(ListItemText textIndex) const +{ + if (textIndex == LIST_ITEM_TEXT1) + { + return __text1Color; + } + else if(textIndex == LIST_ITEM_TEXT2) + { + return __text2Color; + } + else + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. The current value of ListItemText is invalid."); + } + + return Color(); +} + +void +_ListImpl::EnableTextSlide(ListItemText textIndex) +{ + int elementId = -1; + switch (textIndex) + { + case LIST_ITEM_TEXT1: + __text1SlideEnabled = true; + elementId = ID_FORMAT_TEXT1; + break; + + case LIST_ITEM_TEXT2: + __text2SlideEnabled = true; + elementId = ID_FORMAT_TEXT2; + break; + + default: + break; + } + SysTryReturnVoidResult(NID_UI_CTRL, (elementId != -1), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The ListItemText is invalid."); + + int maxCount = GetItemCount(); + + for (int itemCount = 0; itemCount < maxCount; itemCount++) + { + CustomListItem* pItem = GetCustomListItemAt(-1, itemCount); + SysTryReturnVoidResult(NID_UI_CTRL, (pItem), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get item at %d.", itemCount); + + _CustomListItemImpl *pItemImpl = pItem->__pCustomListItemImpl; + SysTryReturnVoidResult(NID_UI_CTRL, (pItemImpl), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get item at %d.", itemCount); + + pItemImpl->SetTextSliding(elementId, true); + } + + return; +} + +void +_ListImpl::DisableTextSlide(void) +{ + __text1SlideEnabled = false; + __text2SlideEnabled = false; + + int maxCount = GetItemCount(); + + for (int itemCount = 0; itemCount < maxCount; itemCount++) + { + CustomListItem* pItem = GetCustomListItemAt(-1, itemCount); + SysTryReturnVoidResult(NID_UI_CTRL, (pItem), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get item at %d.", itemCount); + + _CustomListItemImpl *pItemImpl = pItem->__pCustomListItemImpl; + SysTryReturnVoidResult(NID_UI_CTRL, (pItemImpl), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get item at %d.", itemCount); + + pItemImpl->SetTextSliding(ID_FORMAT_TEXT1, false); + pItemImpl->SetTextSliding(ID_FORMAT_TEXT2, false); + } + + return; +} + +int +_ListImpl::GetItemHeight(void) const +{ + if (__listItemFormat < LIST_ITEM_DOUBLE_IMAGE_TEXT_FULLTEXT) + { + return __row1Height; + } + + return __row1Height + __row2Height; +} + +int +_ListImpl::GetRow1Height(void) const +{ + return __row1Height; +} + +int +_ListImpl::GetRow2Height(void) const +{ + return __row2Height; +} + +int +_ListImpl::GetColumn1Width(void) const +{ + return __column1Width; +} + +int +_ListImpl::GetColumn2Width(void) const +{ + return __column2Width; +} + +result +_ListImpl::SetRow1Height(int row1Height) +{ + __row1Height = row1Height; + if (GetCore().GetFirstDrawnFlag() == false) + { + return ReDrawList(); + } + + return E_SUCCESS; +} + +result +_ListImpl::SetRow2Height(int row2Height) +{ + if (__listItemFormat < LIST_ITEM_DOUBLE_IMAGE_TEXT_FULLTEXT) + { + __row2Height = 0; + } + else + { + __row2Height = row2Height; + if (GetCore().GetFirstDrawnFlag() == false) + { + return ReDrawList(); + } + } + + return E_SUCCESS; +} + +result +_ListImpl::SetColumn1Width(int column1Width) +{ + __column1Width = column1Width; + if (GetCore().GetFirstDrawnFlag() == false) + { + return ReDrawList(); + } + + return E_SUCCESS; +} + +result +_ListImpl::SetColumn2Width(int column2Width) +{ + __column2Width = column2Width; + if (GetCore().GetFirstDrawnFlag() == false) + { + return ReDrawList(); + } + + return E_SUCCESS; +} + + +result +_ListImpl::SetItemChecked(int index, bool check) +{ + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), E_SYSTEM, + "A system error has occurred. The current value of index(%d) is invalid.", index); + + SysTryReturnResult(NID_UI_CTRL, (__listStyle != LIST_STYLE_NORMAL), E_SYSTEM, + "A system error has occurred. List style should not be LIST_STYLE_NORMAL"); + SysTryReturnResult(NID_UI_CTRL, (__listStyle != LIST_STYLE_NUMBER), E_SYSTEM, + "A system error has occurred. List style should not be LIST_STYLE_NUMBER"); + + if (IsItemChecked(index) == check) + { + return E_SUCCESS; + } + + SysTryReturnResult(NID_UI_CTRL, (IsItemEnabled(index)), E_SYSTEM, + "A system error has occurred. The List item is not enabled at index(%d).", index); + + _CheckElementModel* pCheckElementModel = GetCheckElementAt(-1, index); + SysTryReturnResult(NID_UI_CTRL, pCheckElementModel, E_SYSTEM, + "A system error has occurred. _CheckElementModel instance is null."); + + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + { + if (check) + { + if (_currentRadioIndex != -1) + { + _CheckElementModel* pOldCheckElementModel = GetCheckElementAt(-1, _currentRadioIndex); + SysTryReturnResult(NID_UI_CTRL, pOldCheckElementModel, E_SYSTEM, + "A system error has occurred. _CheckElementModel instance is null."); + + pOldCheckElementModel->SetCheckBoxStatus(CHECK_BOX_UNCHECKED); + DrawItem(-1, _currentRadioIndex); + } + _currentRadioIndex = index; + } + else + { + _currentRadioIndex = -1; + } + } + + pCheckElementModel->SetCheckBoxStatus((_CheckBoxBitmapType)check); + + DrawItem(-1, index); + + return E_SUCCESS; +} + +bool +_ListImpl::IsItemChecked(int index) const +{ + SysTryReturn(NID_UI_CTRL, (__listStyle != LIST_STYLE_NORMAL), false, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be LIST_STYLE_NORMAL."); + SysTryReturn(NID_UI_CTRL, (__listStyle != LIST_STYLE_NUMBER), false, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be LIST_STYLE_NUMBER."); + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), + false, E_INVALID_ARG, "[E_INVALID_ARG] The current value of index(%d) is invalid.", index); + + const _CheckElementModel* pCheckElement = GetCheckElementAt(-1, index); + SysTryReturn(NID_UI_CTRL, pCheckElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. CheckElement is not constructed properly."); + + return (bool)pCheckElement->GetCheckBoxStatus(); +} + +result +_ListImpl::SetAllItemsChecked(bool check) +{ + SysTryReturnResult(NID_UI_CTRL, (__listStyle != LIST_STYLE_NORMAL), E_SYSTEM, + "A system error has occurred. List style should not be LIST_STYLE_NORMAL"); + SysTryReturnResult(NID_UI_CTRL, (__listStyle != LIST_STYLE_NUMBER), E_SYSTEM, + "A system error has occurred. List style should not be LIST_STYLE_NUMBER"); + SysTryReturnResult(NID_UI_CTRL, (__listStyle != LIST_STYLE_RADIO), E_SYSTEM, + "A system error has occurred. List style should not be LIST_STYLE_RADIO"); + SysTryReturnResult(NID_UI_CTRL, (__listStyle != LIST_STYLE_RADIO_WITH_DIVIDER), E_SYSTEM, + "A system error has occurred. List style should not be LIST_STYLE_RADIO_WITH_DIVIDER"); + + _CheckElementModel* pCheckElement = null; + + for (int index = 0; index < GetItemCount(); index++) + { + if (IsItemEnabled(index)) + { + pCheckElement = GetCheckElementAt(-1, index); + SysTryReturnResult(NID_UI_CTRL, (pCheckElement != null), E_SYSTEM, + "A system error has occurred. _CheckElementModel instance is null."); + + pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check); + } + } + + GetCore().Draw(); + + return E_SUCCESS; +} + +result +_ListImpl::RemoveAllCheckedItems(void) +{ + SysTryReturnResult(NID_UI_CTRL, (__listStyle != LIST_STYLE_NORMAL), E_SYSTEM, + "A system error has occurred. List style should not be LIST_STYLE_NORMAL"); + SysTryReturnResult(NID_UI_CTRL, (__listStyle != LIST_STYLE_NUMBER), E_SYSTEM, + "A system error has occurred. List style should not be LIST_STYLE_NUMBER"); + SysTryReturnResult(NID_UI_CTRL, (__listStyle != LIST_STYLE_RADIO), E_SYSTEM, + "A system error has occurred. List style should not be LIST_STYLE_RADIO"); + SysTryReturnResult(NID_UI_CTRL, (__listStyle != LIST_STYLE_RADIO_WITH_DIVIDER), E_SYSTEM, + "A system error has occurred. List style should not be LIST_STYLE_RADIO_WITH_DIVIDER"); + + result r = E_SUCCESS; + result finalResult = E_SUCCESS; + + for (int index = GetItemCount() -1; index >= 0; index--) + { + if (IsItemChecked(index)) + { + r = RemoveItemAt(index); + + if (r != E_SUCCESS) + { + finalResult = r; + SysLog(NID_UI_CTRL, "[%s] Item at index(%d) is not removed successfully.", GetErrorMessage(r), index); + } + } + } + + return finalResult; +} + +int +_ListImpl::GetFirstCheckedItemIndex(void) const +{ + SysTryReturn(NID_UI_CTRL, (__listStyle != LIST_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be LIST_STYLE_NORMAL."); + SysTryReturn(NID_UI_CTRL, (__listStyle != LIST_STYLE_NUMBER), INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be LIST_STYLE_NUMBER."); + + for (int index = 0; index < GetItemCount(); index++) + { + if (IsItemChecked(index)) + { + SetLastResult(E_SUCCESS); + return index; + } + } + SetLastResult(E_SUCCESS); + return INVALID_INDEX; +} + +int +_ListImpl::GetLastCheckedItemIndex(void) const +{ + SysTryReturn(NID_UI_CTRL, (__listStyle != LIST_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be LIST_STYLE_NORMAL."); + SysTryReturn(NID_UI_CTRL, (__listStyle != LIST_STYLE_NUMBER), INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be LIST_STYLE_NUMBER."); + + for (int index = GetItemCount() - 1; index >= 0; index--) + { + if (IsItemChecked(index)) + { + SetLastResult(E_SUCCESS); + return index; + } + } + SetLastResult(E_SUCCESS); + + return INVALID_INDEX; +} + +int +_ListImpl::GetNextCheckedItemIndexAfter(int index) const +{ + SysTryReturn(NID_UI_CTRL, (__listStyle != LIST_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be LIST_STYLE_NORMAL."); + SysTryReturn(NID_UI_CTRL, (__listStyle != LIST_STYLE_NUMBER), INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be LIST_STYLE_NUMBER."); + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The current value of index(%d) is invalid.") ; + + for (int itemCount = index + 1; itemCount < GetItemCount(); itemCount++) + { + if (IsItemChecked(itemCount)) + { + SetLastResult(E_SUCCESS); + return itemCount; + } + } + SetLastResult(E_SUCCESS); + + return INVALID_INDEX; +} + +int +_ListImpl::GetItemIndexFromItemId(int itemId) const +{ + for (int index = 0; index < GetItemCount(); index++) + { + const CustomListItem* pCustomListItem = GetCustomListItemAt(-1, index); + SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", index); + + if (pCustomListItem->__pCustomListItemImpl->itemId == itemId) + { + SetLastResult(E_SUCCESS); + return index; + } + } + + SetLastResult(E_SUCCESS); + + return INVALID_INDEX; +} + +int +_ListImpl::GetItemIdAt(int index) const +{ + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), + -1, E_INVALID_ARG, "[E_INVALID_ARG] The current value of index(%d) is invalid.", index); + + const CustomListItem* pCustomListItem = GetCustomListItemAt(-1, index); + SysTryReturn(NID_UI_CTRL, pCustomListItem, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", index); + + SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", index); + + SetLastResult(E_SUCCESS); + return pCustomListItem->__pCustomListItemImpl->itemId; +} + +void +_ListImpl::ScrollToBottom(void) +{ + result r = E_SUCCESS; + + GetCore().SetBottomDrawnItemIndex(0, GetItemCount() - 1); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + GetCore().Draw(); + + return; +} + +void +_ListImpl::ScrollToTop(void) +{ + result r = E_SUCCESS; + r = GetCore().SetTopDrawnItemIndex(0,0); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + GetCore().Draw(); + + return; +} + +result +_ListImpl::ScrollToTop(int index) +{ + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), E_INVALID_ARG, "The current value of index(%d) is invalid.", index); + + result r = GetCore().SetTopDrawnItemIndex(0, index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + return r; +} + +result +_ListImpl::RefreshItem(int index) +{ + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < GetItemCount()), E_INVALID_ARG, "The current value of index(%d) is invalid.", index); + + int topItemIndex = -1; + int bottomItemIndex = -1; + int groupIndex = -1; + + GetCore().GetTopDrawnItemIndex(groupIndex, topItemIndex); + GetCore().GetBottomDrawnItemIndex(groupIndex, bottomItemIndex); + + SysTryReturnResult(NID_UI_CTRL, (index >= topItemIndex && index <= bottomItemIndex), E_INVALID_OPERATION, + "Index(%d) should be within drawn item range.", index); + + result r = E_SUCCESS; + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = GetCustomListItemAt(-1, index); + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, + "A system error has occurred. Failed to refresh an item."); + + DrawItem(-1, index); + + return E_SUCCESS; +} + +CustomListItem* +_ListImpl::GetNewItemN(const String* pText1, const String* pText2, const Bitmap* pBitmap1, const Bitmap* pBitmap2, int itemId, int index) +{ + SysTryReturn(NID_UI_CTRL, __pItemFormat, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Item Format must not be null."); + Dimension listSize = GetCore().GetSize(); + Rectangle text1Rect; + Rectangle text2Rect; + Rectangle img1Rect; + Rectangle img2Rect; + + GetElementRects(text1Rect, text2Rect, img1Rect, img2Rect); + + CustomListItem* pItem = new (std::nothrow) CustomListItem(); + SysTryReturn(NID_UI_CTRL, pItem, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pItem->Construct(GetItemHeight()); + pItem->SetItemFormat(*__pItemFormat); + pItem->__pCustomListItemImpl->itemId = itemId; + + if ((pText1 != null) && (text1Rect.x > 0)) + { + pItem->SetElement(ID_FORMAT_TEXT1, *pText1); + pItem->__pCustomListItemImpl->SetTextSliding(ID_FORMAT_TEXT1, __text1SlideEnabled); + } + + if ((pBitmap1 != null) && (img1Rect.x > 0)) + { + pItem->SetElement(ID_FORMAT_IMAGE1, *pBitmap1, pBitmap1); + } + + if ((pText2 != null) && (text2Rect.x > 0)) + { + pItem->SetElement(ID_FORMAT_TEXT2, *pText2); + pItem->__pCustomListItemImpl->SetTextSliding(ID_FORMAT_TEXT2, __text2SlideEnabled); + } + + if ((pBitmap2 != null) && (img2Rect.x > 0)) + { + pItem->SetElement(ID_FORMAT_IMAGE2, *pBitmap2, pBitmap2); + } + + _NumberElement *pNumberElement = null; + + if (__listStyle == LIST_STYLE_NUMBER) + { + pNumberElement = new (std::nothrow) _NumberElement(); + SysTryReturn(NID_UI_CTRL, pNumberElement, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + pNumberElement->index = index + 1; + __pNumberElements->InsertAt(*pNumberElement, index); + pItem->SetElement(ID_FORMAT_NUMBER, *(dynamic_cast(pNumberElement))); + } + + if (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL) + { + pItem->SetCheckBox(ID_FORMAT_CHECK); + } + + return pItem; +} + +void +_ListImpl::GetItemMargins(int& leftMargin, int& numberStyleMargin, int& dividerMargin, int& lowerMargin, int& upperMargin) +{ + if (__listStyle == LIST_STYLE_NUMBER) + { + GET_SHAPE_CONFIG(LIST::LIST_ITEM_NUMBER_STYLE_MARGIN, GetCore().GetOrientation(), numberStyleMargin); + } + + if (_isDividerEnabled == true || divider == true) + { + GET_SHAPE_CONFIG(LIST::LIST_ITEM_DIVIDER_MARGIN, GetCore().GetOrientation(), dividerMargin); + } + + GET_SHAPE_CONFIG(LIST::LIST_ITEM_LEFT_MARGIN, GetCore().GetOrientation(), leftMargin); + GET_SHAPE_CONFIG(LIST::LIST_ITEM_LOWER_MARGIN, GetCore().GetOrientation(), lowerMargin); + GET_SHAPE_CONFIG(LIST::LIST_ITEM_UPPER_MARGIN, GetCore().GetOrientation(), upperMargin); +} + +void +_ListImpl::GetElementRects(Rectangle& text1Rect, Rectangle& text2Rect, Rectangle& img1Rect, Rectangle& img2Rect) +{ + Dimension listSize = GetCore().GetSize(); + + int leftMargin = 0; + int numberStyleMargin = 0; + int dividerMargin = 0; + int lowerMargin = 0; + int upperMargin = 0; + + GetItemMargins(leftMargin, numberStyleMargin, dividerMargin, lowerMargin, upperMargin); + + switch (__listItemFormat) + { + case LIST_ITEM_SINGLE_IMAGE: + + img1Rect.x = leftMargin + numberStyleMargin; + img1Rect.y = upperMargin; + img1Rect.width = __column1Width - dividerMargin; + img1Rect.height = __row1Height - lowerMargin; + + break; + + case LIST_ITEM_SINGLE_TEXT: + + text1Rect.x = leftMargin + numberStyleMargin; + text1Rect.y = upperMargin; + text1Rect.width = __column1Width - dividerMargin - text1Rect.x; + text1Rect.height = __row1Height - lowerMargin; + + break; + + case LIST_ITEM_SINGLE_IMAGE_TEXT: + + img1Rect.x = leftMargin + numberStyleMargin; + img1Rect.y = upperMargin; + img1Rect.width = __column1Width; + img1Rect.height = __row1Height - lowerMargin; + + text1Rect.x = __column1Width + leftMargin + numberStyleMargin; + text1Rect.y = upperMargin; + text1Rect.width = (__column1Width + __column2Width + dividerMargin <= listSize.width) ? (__column2Width) : (__column2Width - dividerMargin); + text1Rect.height = __row1Height - lowerMargin; + + break; + + case LIST_ITEM_SINGLE_TEXT_IMAGE: + + img1Rect.x = __column1Width + leftMargin + numberStyleMargin; + img1Rect.y = upperMargin; + img1Rect.width = __column1Width; + img1Rect.height = __row1Height - lowerMargin; + + text1Rect.x = leftMargin + numberStyleMargin; + text1Rect.y = upperMargin; + text1Rect.width = (__column1Width + __column2Width + dividerMargin <= listSize.width) ? (__column2Width) : (__column2Width - dividerMargin); + text1Rect.height = __row1Height - lowerMargin; + + break; + + case LIST_ITEM_SINGLE_IMAGE_TEXT_IMAGE: + + img1Rect.x = leftMargin + numberStyleMargin; + img1Rect.y = upperMargin; + img1Rect.width = __column1Width; + img1Rect.height = __row1Height - lowerMargin; + + text1Rect.x = __column1Width + leftMargin + numberStyleMargin; + text1Rect.y = upperMargin; + text1Rect.width = __column2Width; + text1Rect.height = __row1Height - lowerMargin; + + img2Rect.x = text1Rect.x + __column2Width; + img2Rect.y = upperMargin; + img2Rect.width = (__column1Width + __column2Width + dividerMargin <= listSize.width) ? (__column2Width) : (__column2Width - dividerMargin); + img2Rect.height = __row1Height - lowerMargin; + + break; + + case LIST_ITEM_DOUBLE_IMAGE_TEXT_FULLTEXT: + + img1Rect.x = leftMargin + numberStyleMargin; + img1Rect.y = upperMargin; + img1Rect.width = __column1Width; + img1Rect.height = __row1Height - lowerMargin; + + text1Rect.x = __column1Width + leftMargin + numberStyleMargin; + text1Rect.y = upperMargin; + text1Rect.width = (__column1Width + __column2Width + dividerMargin <= listSize.width) ? (__column2Width) : (__column2Width - dividerMargin); + text1Rect.height = __row1Height - lowerMargin; + + text2Rect.x = leftMargin + numberStyleMargin; + text2Rect.y = __row1Height; + text2Rect.width = __column1Width; + text2Rect.height = __row2Height - lowerMargin; + + break; + + case LIST_ITEM_DOUBLE_FULLTEXT_IMAGE_TEXT: + + img1Rect.x = leftMargin + numberStyleMargin; + img1Rect.y = __row1Height; + img1Rect.width = __column1Width; + img1Rect.height = __row2Height; + + text1Rect.x = __column1Width + leftMargin + numberStyleMargin; + text1Rect.y = __row1Height; + text1Rect.width = (__column1Width + __column2Width + dividerMargin <= listSize.width) ? (__column2Width) : (__column2Width - dividerMargin); + text1Rect.height = __row2Height; + + text2Rect.x = leftMargin + numberStyleMargin; + text2Rect.y = upperMargin; + text2Rect.width = __column1Width; + text2Rect.height = __row1Height - lowerMargin; + + break; + + case LIST_ITEM_DOUBLE_TEXT_IMAGE_FULLTEXT: + + img1Rect.x = __column1Width + leftMargin + numberStyleMargin; + img1Rect.y = upperMargin; + img1Rect.width = (__column1Width + __column2Width + dividerMargin <= listSize.width) ? (__column2Width) : (__column2Width - dividerMargin); + img1Rect.height = __row1Height - lowerMargin; + + text1Rect.x = leftMargin + numberStyleMargin; + text1Rect.y = upperMargin; + text1Rect.width = __column1Width; + text1Rect.height = __row1Height - lowerMargin; + + text2Rect.x = leftMargin + numberStyleMargin; + text2Rect.y = __row1Height; + text2Rect.width = __column1Width; + text2Rect.height = __row2Height; + + break; + + case LIST_ITEM_DOUBLE_FULLTEXT_TEXT_IMAGE: + + img1Rect.x = __column1Width + leftMargin + numberStyleMargin; + img1Rect.y = __row1Height; + img1Rect.width = (__column1Width + __column2Width + dividerMargin <= listSize.width) ? (__column2Width) : (__column2Width - dividerMargin); + img1Rect.height = __row2Height; + + text1Rect.x = leftMargin + numberStyleMargin; + text1Rect.y = __row1Height; + text1Rect.width = __column1Width; + text1Rect.height = __row2Height; + + text2Rect.x = leftMargin + numberStyleMargin; + text2Rect.y = upperMargin; + text2Rect.width = __column1Width; + text2Rect.height = __row1Height - lowerMargin; + + break; + + case LIST_ITEM_DOUBLE_IMAGE_TEXT_TEXT: + + img1Rect.x = leftMargin + numberStyleMargin; + img1Rect.y = upperMargin; + img1Rect.width = __column1Width; + img1Rect.height = __row1Height + __row2Height - lowerMargin; + + text1Rect.x = __column1Width + leftMargin + numberStyleMargin; + text1Rect.y = upperMargin; + text1Rect.width = (__column1Width + __column2Width + dividerMargin <= listSize.width) ? (__column2Width) : (__column2Width - dividerMargin); + text1Rect.height = __row1Height - lowerMargin; + + text2Rect.x = __column1Width + leftMargin + numberStyleMargin; + text2Rect.y = __row1Height; + text2Rect.width = (__column1Width + __column2Width + dividerMargin <= listSize.width) ? (__column2Width) : (__column2Width - dividerMargin); + text2Rect.height = __row2Height; + + break; + + case LIST_ITEM_DOUBLE_TEXT_TEXT_IMAGE: + + img1Rect.x = __column1Width + leftMargin + numberStyleMargin; + img1Rect.y = upperMargin; + img1Rect.width = (__column1Width + __column2Width + dividerMargin <= listSize.width) ? (__column2Width) : (__column2Width - dividerMargin); + img1Rect.height = __row1Height + __row2Height - lowerMargin; + + text1Rect.x = leftMargin + numberStyleMargin; + text1Rect.y = upperMargin; + text1Rect.width = __column1Width; + text1Rect.height = __row2Height - lowerMargin; + + text2Rect.x = leftMargin + numberStyleMargin; + text2Rect.y = __row1Height; + text2Rect.width = __column1Width; + text2Rect.height = __row1Height; + + break; + } +} + +result +_ListImpl::ReDrawList(void) +{ + Rectangle text1Rect; + Rectangle text2Rect; + Rectangle img1Rect; + Rectangle img2Rect; + int groupIndex = -1; + int currIndex = -1; + + GetTopDrawnItemIndex(groupIndex, currIndex); + + GetElementRects(text1Rect, text2Rect, img1Rect, img2Rect); + + int textSize = 0; + int listStyleNumberX = 0; + int listStyleNumberWidth = 0; + int listStyleNumberHeight = 0; + int checkItemWidth = 0; + int checkItemHeight = 0; + + GET_SHAPE_CONFIG(LIST::LIST_ITEM_TEXT_SIZE, GetCore().GetOrientation(), textSize); + + GET_SHAPE_CONFIG(LIST::LIST_STYLE_NUMBER_X, GetCore().GetOrientation(), listStyleNumberX); + GET_SHAPE_CONFIG(LIST::LIST_STYLE_NUMBER_WIDTH, GetCore().GetOrientation(), listStyleNumberWidth); + GET_SHAPE_CONFIG(LIST::LIST_STYLE_NUMBER_HEIGHT, GetCore().GetOrientation(), listStyleNumberHeight); + + GET_SHAPE_CONFIG(LIST::LIST_CHECK_ITEM_WIDTH, GetCore().GetOrientation(), checkItemWidth); + GET_SHAPE_CONFIG(LIST::LIST_CHECK_ITEM_HEIGHT, GetCore().GetOrientation(), checkItemHeight); + + if (text1Rect.x > 0) + { + __pItemFormat->AddElement(ID_FORMAT_TEXT1, text1Rect); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_TEXT1, false); + } + + if (img1Rect.x > 0) + { + __pItemFormat->AddElement(ID_FORMAT_IMAGE1, img1Rect); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_IMAGE1, false); + } + + if (text2Rect.x > 0) + { + __pItemFormat->AddElement(ID_FORMAT_TEXT2, text2Rect); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_TEXT2, false); + } + + if (img2Rect.x > 0) + { + __pItemFormat->AddElement(ID_FORMAT_IMAGE2, img2Rect); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_IMAGE2, false); + } + + if (__listStyle == LIST_STYLE_NUMBER) + { + __pItemFormat->AddElement(ID_FORMAT_NUMBER, Rectangle(listStyleNumberX, GetItemHeight()/2 - 15, listStyleNumberWidth, listStyleNumberHeight)); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_NUMBER, false); + } + + if (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL) + { + __pItemFormat->AddElement(ID_FORMAT_CHECK, Rectangle(GetCore().GetBounds().width - 60, GetItemHeight()/2 - 25 , checkItemWidth , checkItemHeight)); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_CHECK, true); + } + + int count = GetItemCount(); + result r = E_SUCCESS; + + for (int index = 0; index < count; index++) + { + Refresh(index); + + r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.",GetErrorMessage(r)); + } + + ScrollToTop(currIndex); + SetLastResult(E_SUCCESS); + + return E_SUCCESS; +} + +void +_ListImpl::SetBitmap(TableViewItemDrawingStatus itemStatus, const Bitmap& bitmap) +{ + _TableViewItemData* pItem = null; + + int groupIndex = -1; + int topIndex = -1; + int bottomIndex = -1; + + GetTopDrawnItemIndex(groupIndex, topIndex); + GetBottomDrawnItemIndex(groupIndex, bottomIndex); + + int count = GetItemCount(); + for (int itemIndex = 0; itemIndex < count; itemIndex++) + { + pItem = GetTableViewItemAt(-1, itemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pItem, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. _TableViewItemData instance is null."); + + pItem->SetBackgroundBitmap(&bitmap, itemStatus); + if (itemIndex >= topIndex && itemIndex <= bottomIndex) + { + pItem->Invalidate(true); + } + } +} + +result +_ListImpl::UpdateNumbers(int index) +{ + SysTryReturnResult(NID_UI_CTRL, __listStyle == LIST_STYLE_NUMBER, E_SYSTEM, + "A system error has occurred. The current value of list style is invalid."); + + SysTryReturnResult(NID_UI_CTRL, __pNumberElements != null, E_SYSTEM, + "A system error has occured. Failed to update numbers"); + + _NumberElement* pNumberElement = null; + int count = __pNumberElements->GetCount(); + + for (int itemIndex = index + 1; itemIndex < count; itemIndex++) + { + pNumberElement = dynamic_cast<_NumberElement*>(__pNumberElements->GetAt(itemIndex)); + SysTryReturnResult(NID_UI_CTRL, pNumberElement, E_SYSTEM, + "A system error has occurred. Failed to get _NumberElement instance at index(%d).", index); + pNumberElement->index = itemIndex + 1; + + CustomListItem* pCustomListItem = GetCustomListItemAt(-1, itemIndex); + SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, + "A system error has occurred. Failed to get an item at index(%d).", itemIndex); + + pCustomListItem->SetElement(ID_FORMAT_NUMBER, *(dynamic_cast(pNumberElement))); + } + + return E_SUCCESS; +} + +result +_ListImpl::Refresh(int index) +{ + result r = E_SUCCESS; + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = GetCustomListItemAt(-1, index); + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, + "A system error has occurred. Failed to refresh an item."); + + DrawItem(-1, index); + + return E_SUCCESS; +} + +bool +_ListImpl::IsItemChecked(int groupIndex, int subIndex) const +{ + return IsItemChecked(subIndex); +} + +result +_ListImpl::SetItemChecked(int groupIndex, int itemIndex, bool check) +{ + return SetItemChecked(itemIndex, check); +} + +void +_ListImpl::OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) +{ + ItemStatus itemStatus = ITEM_HIGHLIGHTED; + + switch (status) + { + case TABLE_VIEW_ITEM_STATUS_SELECTED: + itemStatus = ITEM_SELECTED; + break; + case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED: + itemStatus = ITEM_HIGHLIGHTED; + break; + case TABLE_VIEW_ITEM_STATUS_CHECKED: + itemStatus = ITEM_CHECKED; + break; + case TABLE_VIEW_ITEM_STATUS_UNCHECKED: + itemStatus = ITEM_UNCHECKED; + break; + default: + SetLastResult(E_SYSTEM); + break; + } + + if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL)) + { + bool isChecked = IsItemChecked(itemIndex); + + if (isChecked) + { + itemStatus = ITEM_UNCHECKED; + } + else + { + itemStatus = ITEM_CHECKED; + } + + SetItemChecked(itemIndex, !isChecked); + } + + ProcessItemStateChange(-1, itemIndex, itemStatus); + + return; +} + +void +_ListImpl::OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo) +{ + +} + +void +_ListImpl::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) +{ + +} + +void +_ListImpl::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) +{ + +} + +void +_ListImpl::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) +{ + +} + +void +_ListImpl::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) +{ + +} + +void +_ListImpl::OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo) +{ +} + +void +_ListImpl::OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) +{ + +} + +void +_ListImpl::OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction) +{ + +} + +void +_ListImpl::OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) +{ + +} + +void +_ListImpl::ProcessItemStateChange(int groupIndex, int itemIndex, ItemStatus itemStatus) +{ + int itemId = GetItemIdAt(itemIndex); + + _ListListener* pListenerList = null; + IItemEventListener* pEventListener = null; + + int count = __itemListeners.GetCount(); + for (int listenerCount = 0; listenerCount < count; listenerCount++) + { + pListenerList = dynamic_cast<_ListListener*>(__itemListeners.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get Listener."); + + pEventListener = dynamic_cast(pListenerList->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get Listener."); + + pEventListener->OnItemStateChanged(GetPublic(), itemIndex, itemId, itemStatus); + } + SetLastResult(E_SUCCESS); + + return; +} + +void +_ListImpl::ProcessItemStateChange(int groupIndex, int itemIndex, int elementId, ItemStatus itemStatus) +{ + int itemId = GetItemIdAt(itemIndex); + + _ListListener* pListenerList = null; + IItemEventListener* pEventListener = null; + + int count = __itemListeners.GetCount(); + for (int listenerCount = 0; listenerCount < count; listenerCount++) + { + pListenerList = dynamic_cast<_ListListener*>(__itemListeners.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get Listener."); + + pEventListener = dynamic_cast(pListenerList->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get Listener."); + + pEventListener->OnItemStateChanged(GetPublic(), itemIndex, itemId, itemStatus); + } + SetLastResult(E_SUCCESS); + + return; +} + + + +class _ListMaker + : public _UiBuilderControlMaker +{ +public: + _ListMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_ListMaker(){}; + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _ListMaker* pListMaker = new (std::nothrow) _ListMaker(uibuilder); + return pListMaker; + }; +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + List* pList = null; + Rectangle rect; + Rectangle rectMin; + Dimension dimMin; + Tizen::Base::String elementString; + int tempRow1Height = 0; + int tempRow2Height = 0; + int tempColumn1Width = 0; + int tempColumn2Width = 0; + + ListStyle style = LIST_STYLE_NORMAL; + ListItemFormat format = LIST_ITEM_SINGLE_TEXT; + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pList = new (std::nothrow) List(); + if (pList == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + + if (pControl->GetElement(L"ListItemFormat", elementString)) + { + if (elementString.Equals(L"LIST_ITEM_SINGLE_IMAGE", false)) + { + format = LIST_ITEM_SINGLE_IMAGE; + } + else if (elementString.Equals(L"LIST_ITEM_SINGLE_TEXT", false)) + { + format = LIST_ITEM_SINGLE_TEXT; + } + else if (elementString.Equals(L"LIST_ITEM_SINGLE_IMAGE_TEXT", false)) + { + format = LIST_ITEM_SINGLE_IMAGE_TEXT; + } + else if (elementString.Equals(L"LIST_ITEM_SINGLE_TEXT_IMAGE", false)) + { + format = LIST_ITEM_SINGLE_TEXT_IMAGE; + } + else if (elementString.Equals(L"LIST_ITEM_SINGLE_IMAGE_TEXT_IMAGE", false)) + { + format = LIST_ITEM_SINGLE_IMAGE_TEXT_IMAGE; + } + else if (elementString.Equals(L"LIST_ITEM_DOUBLE_IMAGE_TEXT_FULLTEXT", false)) + { + format = LIST_ITEM_DOUBLE_IMAGE_TEXT_FULLTEXT; + } + else if (elementString.Equals(L"LIST_ITEM_DOUBLE_FULLTEXT_IMAGE_TEXT", false)) + { + format = LIST_ITEM_DOUBLE_FULLTEXT_IMAGE_TEXT; + } + else if (elementString.Equals(L"LIST_ITEM_DOUBLE_TEXT_IMAGE_FULLTEXT", false)) + { + format = LIST_ITEM_DOUBLE_TEXT_IMAGE_FULLTEXT; + } + else if (elementString.Equals(L"LIST_ITEM_DOUBLE_FULLTEXT_TEXT_IMAGE", false)) + { + format = LIST_ITEM_DOUBLE_FULLTEXT_TEXT_IMAGE; + } + else if (elementString.Equals(L"LIST_ITEM_DOUBLE_IMAGE_TEXT_TEXT", false)) + { + format = LIST_ITEM_DOUBLE_IMAGE_TEXT_TEXT; + } + else if (elementString.Equals(L"LIST_ITEM_DOUBLE_TEXT_TEXT_IMAGE", false)) + { + format = LIST_ITEM_DOUBLE_TEXT_TEXT_IMAGE; + } + else + { + format = LIST_ITEM_SINGLE_TEXT; + } + } + + if (pControl->GetElement(L"line1Height", elementString) || pControl->GetElement(L"row1Height", elementString)) + { + Base::Integer::Parse(elementString, tempRow1Height); + } + + if ((pControl->GetElement(L"line2Height", elementString) || pControl->GetElement(L"row2Height", elementString)) && (format > 4)) + { + Base::Integer::Parse(elementString,tempRow2Height); + } + else + { + tempRow2Height = 0; + } + + if (pControl->GetElement(L"column1Width", elementString)) + { + Base::Integer::Parse(elementString,tempColumn1Width); + } + + if ((pControl->GetElement(L"column2Width", elementString)) && (format > 1)) + { + Base::Integer::Parse(elementString,tempColumn2Width); + } + else + { + tempColumn2Width = 0; + } + + Tizen::Base::String styleString; + styleString = pControlProperty->GetStyle(); + + if (styleString.Equals(L"LIST_STYLE_NORMAL", false)) + { + style = LIST_STYLE_NORMAL; + } + else if (styleString.Equals(L"LIST_STYLE_NUMBER", false)) + { + style = LIST_STYLE_NUMBER; + } + else if (styleString.Equals(L"LIST_STYLE_RADIO", false)) + { + style = LIST_STYLE_RADIO; + } + else if (styleString.Equals(L"LIST_STYLE_RADIO_WITH_DIVIDER", false)) + { + style = LIST_STYLE_RADIO_WITH_DIVIDER; + } + else if (styleString.Equals(L"LIST_STYLE_MARK_WITH_DIVIDER", false)) + { + style = LIST_STYLE_MARK_WITH_DIVIDER; + } + else if (styleString.Equals(L"LIST_STYLE_ONOFF_WITH_DIVIDER", false)) + { + style = LIST_STYLE_ONOFF_WITH_DIVIDER; + } + else if (styleString.Equals(L"LIST_STYLE_MARK", false)) + { + style = LIST_STYLE_MARK; + } + else if (styleString.Equals(L"LIST_STYLE_ONOFF", false)) + { + style = LIST_STYLE_ONOFF; + } + else + { + style = LIST_STYLE_NORMAL; + } + + if (tempRow1Height < 0 || tempRow1Height > ((Tizen::Ui::Control*) GetContainer())->GetBounds().height) + { + tempRow1Height = ((Tizen::Ui::Control*) GetContainer())->GetBounds().height >> 2; + } + if (tempRow2Height < 0 || tempRow2Height > ((Tizen::Ui::Control*) GetContainer())->GetBounds().height) + { + tempRow2Height = ((Tizen::Ui::Control*) GetContainer())->GetBounds().height >> 2; + } + if (tempColumn1Width < 0 || tempColumn1Width > ((Tizen::Ui::Control*) GetContainer())->GetBounds().width) + { + tempColumn1Width = ((Tizen::Ui::Control*) GetContainer())->GetBounds().width >> 2; + } + if (tempColumn2Width < 0 || tempColumn2Width > ((Tizen::Ui::Control*) GetContainer())->GetBounds().width) + { + tempColumn2Width = ((Tizen::Ui::Control*) GetContainer())->GetBounds().width >> 2; + } + + r = pList->Construct(rect, style, format, tempRow1Height, tempRow2Height, tempColumn1Width, tempColumn2Width); + if (r != E_SUCCESS) + { + delete pList; + return null; + } + + if (pControl->GetElement(L"textOfEmptyList", elementString)) + { + pList->SetTextOfEmptyList(elementString); + } + + if (pControl->GetElement(L"colorOfEmptyListText", elementString)) + { + ConvertStringToColor(elementString, color); + pList->SetTextColorOfEmptyList(color); + } + + GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_PORTRAIT, dimMin); + rectMin = (pControl->GetAttribute(0))->GetRect(); + (pControl->GetAttribute(0))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height); + + GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_LANDSCAPE, dimMin); + rectMin = (pControl->GetAttribute(1))->GetRect(); + (pControl->GetAttribute(1))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height); + + return pList; + } + +private: +}; + +_ListRegister::_ListRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + if (pUiBuilderControlTableManager) + { + pUiBuilderControlTableManager->RegisterControl(L"List", _ListMaker::GetInstance); + } +} +_ListRegister::~_ListRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + if (pUiBuilderControlTableManager) + { + pUiBuilderControlTableManager->UnregisterControl(L"List"); + } +} + +static _ListRegister ListRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ListItemBaseImpl.cpp b/src/ui/controls/FUiCtrl_ListItemBaseImpl.cpp new file mode 100644 index 0000000..efe1526 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ListItemBaseImpl.cpp @@ -0,0 +1,421 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListItemBaseImpl.cpp + * @brief This is the implementation file for _ListItemBaseImpl class. + * + * This file contains the implementation of _ListItemBaseImpl class. + */ + +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_ListContextItemImpl.h" +#include "FUiCtrl_ListItemBaseImpl.h" +#include "FUiCtrl_ListViewContextItem.h" +#include "FUiCtrl_ListViewItem.h" +#include "FUiCtrl_UiListViewItemEvent.h" +#include "FUiCtrl_UiListViewItemEventArg.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ListItemBaseImpl* +_ListItemBaseImpl::GetInstance(ListItemBase& listItemBase) +{ + return listItemBase._pImpl; +} + +const _ListItemBaseImpl* +_ListItemBaseImpl::GetInstance(const ListItemBase& listItemBase) +{ + return listItemBase._pImpl; +} + +_ListItemBaseImpl::_ListItemBaseImpl(ListItemBase* pPublic) + : __pPublic(pPublic) + , __pListViewItem(null) + , __style(LIST_ANNEX_STYLE_NORMAL) + , __pEvent(null) +{ + +} + +_ListItemBaseImpl::~_ListItemBaseImpl(void) +{ + if (__pListViewItem != null) + { + __pListViewItem->RemoveTouchLongPressGestureEventListener(*this); + } + + if (__pListViewItem != null) + { + __pListViewItem->Release(); + } + + delete __pEvent; + __pEvent = null; +} + +const char* +_ListItemBaseImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::ListItemBase"; +} + +const ListItemBase& +_ListItemBaseImpl::GetPublic(void) const +{ + return static_cast (*__pPublic); +} + +ListItemBase& +_ListItemBaseImpl::GetPublic(void) +{ + return *__pPublic; +} + +_ListItemBaseImpl* +_ListItemBaseImpl::CreateListItemBaseImplN(ListItemBase* pPublic, const Dimension& itemSize, ListAnnexStyle style) +{ + _ListItemBaseImpl* pImpl = new (std::nothrow) _ListItemBaseImpl(pPublic); + SysTryReturn(NID_UI_CTRL, (pImpl != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = pImpl->Construct(itemSize, style); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; + +CATCH: + delete pImpl; + pImpl = null; + + return null; +} + +result +_ListItemBaseImpl::Construct(const Dimension& itemSize, ListAnnexStyle style) +{ + SysTryReturn(NID_UI_CTRL, (itemSize.width >= 0) && (itemSize.height >= 0), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] The item size should be greater than 0.")); + + __pListViewItem = _ListViewItem::CreateListViewItemN(itemSize.height); + SysTryReturn(NID_UI_CTRL, (__pListViewItem != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + __pListViewItem->SetSize(itemSize); + __pListViewItem->SetBounds(Rectangle(0, 0, itemSize.width, itemSize.height)); + __pListViewItem->SetBackgroundColor(Color(0, 0, 0, 0)); + __pListViewItem->SetProgressValue(-1); + __pListViewItem->AddTouchLongPressGestureEventListener(*this); + __pListViewItem->SetSelectionStyle(TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE); + + __itemSize = itemSize; + __style = style; + + return E_SUCCESS; +} + +_ListViewItem* +_ListItemBaseImpl::GetListViewItem(void) const +{ + return __pListViewItem; +} + +Dimension +_ListItemBaseImpl::GetItemSize(void) const +{ + return __itemSize; +} + +result +_ListItemBaseImpl::SetBackgroundBitmap(ListItemDrawingStatus status, const Bitmap* pBitmap) +{ + SysTryReturn(NID_UI_CTRL, (pBitmap != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] It is invalid argument."); + + ListItemState itemState; + + switch (status) + { + case LIST_ITEM_DRAWING_STATUS_NORMAL: + itemState = LIST_ITEM_STATE_NORMAL; + break; + + case LIST_ITEM_DRAWING_STATUS_PRESSED: + itemState = LIST_ITEM_STATE_PRESSED; + break; + + case LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED: + itemState = LIST_ITEM_STATE_HIGHLIGHTED; + break; + + default: + SysTryReturn(NID_UI_CTRL, false, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to set background image."); + } + + bool ret = __pListViewItem->SetItemBackgroundBitmap(itemState, pBitmap); + __pListViewItem->SetItemChanged(ret); + + return E_SUCCESS; +} + +result +_ListItemBaseImpl::SetBackgroundColor(ListItemDrawingStatus status, const Color& color) +{ + ListItemState itemState; + + switch (status) + { + case LIST_ITEM_DRAWING_STATUS_NORMAL: + itemState = LIST_ITEM_STATE_NORMAL; + break; + + case LIST_ITEM_DRAWING_STATUS_PRESSED: + itemState = LIST_ITEM_STATE_PRESSED; + break; + + case LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED: + itemState = LIST_ITEM_STATE_HIGHLIGHTED; + break; + + default: + SysTryReturn(NID_UI_CTRL, false, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to set background color."); + } + + __pListViewItem->SetItemBackgroundColor(itemState, color); + __pListViewItem->SetItemChanged(true); + + return E_SUCCESS; +} + +Color +_ListItemBaseImpl::GetBackgroundColor(ListItemDrawingStatus status) const +{ + ListItemState itemState; + + switch (status) + { + case LIST_ITEM_DRAWING_STATUS_NORMAL: + itemState = LIST_ITEM_STATE_NORMAL; + break; + + case LIST_ITEM_DRAWING_STATUS_PRESSED: + itemState = LIST_ITEM_STATE_PRESSED; + break; + + case LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED: + itemState = LIST_ITEM_STATE_HIGHLIGHTED; + break; + + default: + SysTryReturn(NID_UI_CTRL, false, Color(0), E_SYSTEM, "[E_SYSTEM] Unable to get background color."); + } + + return __pListViewItem->GetItemBackgroundColor(itemState); +} + +result +_ListItemBaseImpl::SetContextItem(const _ListContextItemImpl* pItem) +{ + if (pItem == null) + { + __pListViewItem->SetContextItem(null); + return E_SUCCESS; + } + + _ListViewContextItem* pContextItem = const_cast<_ListContextItemImpl*>(pItem)->GetContextItem(); + + if (pContextItem != null) + { + __pListViewItem->SetItemWidth(__itemSize.width); + __pListViewItem->SetContextItem(pContextItem); + __pListViewItem->SetContextItemEventListener(*this); + + return E_SUCCESS; + } + + return E_SYSTEM; +} + +result +_ListItemBaseImpl::SetDescriptionText(const String& text) +{ + SysTryReturn(NID_UI_CTRL, (__pListViewItem->SetDescriptionText(text) == true), E_SYSTEM, E_SYSTEM, + ("[E_SYSTEM] Unable to set description text.")); + + return E_SUCCESS; +} + +result +_ListItemBaseImpl::SetDescriptionTextColor(const Color& color) +{ + __pListViewItem->SetDescriptionTextColor(color); + + return E_SUCCESS; +} + +result +_ListItemBaseImpl::SetProgressValue(int value) +{ + SysTryReturn(NID_UI_CTRL, (__pListViewItem->SetProgressValue(value) == true), E_SYSTEM, E_SYSTEM, + ("[E_SYSTEM] Unable to set progress value.")); + + return E_SUCCESS; +} + +result +_ListItemBaseImpl::SetProgressMargins(int leftMargin, int rightMargin) +{ + SysTryReturn(NID_UI_CTRL, (leftMargin >= 0) && (rightMargin >= 0), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] It is invalid argument.")); + + SysTryReturn(NID_UI_CTRL, (leftMargin < (__itemSize.width - rightMargin)), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] It is invalid argument.")); + + SysTryReturn(NID_UI_CTRL, (__pListViewItem->SetProgressMargins(leftMargin, rightMargin) == true), E_SYSTEM, E_SYSTEM, + ("[E_SYSTEM] Unable to set progress bar margin.")); + + return E_SUCCESS; +} + +int +_ListItemBaseImpl::GetAnnexWidth(ListAnnexStyle style) +{ + int annexWidth = 0; + + switch (style) + { + case LIST_ANNEX_STYLE_NORMAL: + annexWidth = 0; + break; + + case LIST_ANNEX_STYLE_MARK: + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + break; + + case LIST_ANNEX_STYLE_RADIO: + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + break; + + case LIST_ANNEX_STYLE_ONOFF_SLIDING: + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + break; + + case LIST_ANNEX_STYLE_DETAILED: + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + break; + + default: + break; + } + + return annexWidth; +} + +ListAnnexStyle +_ListItemBaseImpl::GetListItemAnnexStyle(void) +{ + return __style; +} + +bool +_ListItemBaseImpl::SetTextColor(int elementId, Color textColor) +{ + bool ret = __pListViewItem->SetTextColor(elementId, textColor); + __pListViewItem->SetItemChanged(ret); + + return ret; +} + +bool +_ListItemBaseImpl::GetTextColor(int elementId, Color& textColor) const +{ + return __pListViewItem->GetTextColor(elementId, textColor); +} + +void +_ListItemBaseImpl::AddListViewItemEventListener(_IUiListViewItemEventListener& listener) +{ + if (__pEvent == null) + { + __pEvent = new (std::nothrow) _UiListViewItemEvent(); + SysTryReturnVoidResult(NID_UI_CTRL, __pEvent != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + + __pEvent->AddListener(listener); +} + +void +_ListItemBaseImpl::RemoveListViewItemEventListener(_IUiListViewItemEventListener& listener) +{ + if (__pEvent != null) + { + __pEvent->RemoveListener(listener); + } +} + +void +_ListItemBaseImpl::OnActionPerformed(const _Control& source, int actionId) +{ + if (__pEvent != null) + { + int groupIndex = -1; + int itemIndex = -1; + + __pListViewItem->GetItemIndex(groupIndex, itemIndex); + __pEvent->SetSource(__pListViewItem); + + _UiListViewItemEventArg* pArg = new (std::nothrow) _UiListViewItemEventArg(groupIndex, itemIndex, actionId, NOTIFY_TYPE_CONTEXTITEM_SELCTED); + __pEvent->Fire(*pArg); + } +} + +bool +_ListItemBaseImpl::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture) +{ + if (__pEvent != null) + { + int elementId = __pListViewItem->GetElementIdFromCurrentTouchPosition(); + int groupIndex = -1; + int itemIndex = -1; + + __pListViewItem->GetItemIndex(groupIndex, itemIndex); + __pEvent->SetSource(__pListViewItem); + + _UiListViewItemEventArg* pArg = new (std::nothrow) _UiListViewItemEventArg(groupIndex, itemIndex, elementId, NOTIFY_TYPE_ITEM_LONGPRESSED); + __pEvent->Fire(*pArg); + } + + return true; +} + +bool +_ListItemBaseImpl::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture) +{ + return true; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ListItemCommon.cpp b/src/ui/controls/FUiCtrl_ListItemCommon.cpp new file mode 100644 index 0000000..c8190e7 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ListItemCommon.cpp @@ -0,0 +1,158 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListItemCommon.cpp + * @brief This is the implementation file for _ListItemCommon class. + * + * This file contains the implementation of _ListItemCommon class. + */ + + +#include +#include "FUiCtrl_ListItemCommon.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ListItemCommon::_ListItemCommon(void) + : __pAppInfo(null) + , __refCount(1) + , __itemHeight(0) + , __checkedState(false) + , __enabledState(true) + , __itemChanged(true) + , __itemType(LIST_ITEM_TYPE_CUSTOM) + , __reorderMode(false) +{ + +} + +_ListItemCommon::~_ListItemCommon(void) +{ + __pAppInfo = null; +} + +int +_ListItemCommon::GetItemHeight(void) const +{ + return __itemHeight; +} + +void +_ListItemCommon::SetItemHeight(int itemHeight) +{ + __itemHeight = itemHeight; +} + +void +_ListItemCommon::SetChecked(bool checked) +{ + __checkedState = checked; +} + +bool +_ListItemCommon::IsChecked(void) const +{ + return __checkedState; +} + +void +_ListItemCommon::SetItemEnabled(bool enabled) +{ + __enabledState = enabled; +} + +bool +_ListItemCommon::IsItemEnabled(void) const +{ + return __enabledState; +} + +ListItemType +_ListItemCommon::GetItemType(void) const +{ + return __itemType; +} + +void +_ListItemCommon::SetItemType(ListItemType itemType) +{ + __itemType = itemType; +} + +bool +_ListItemCommon::IsReorderMode(void) const +{ + return __reorderMode; +} + +void +_ListItemCommon::SetReorderMode(bool enabled) +{ + __reorderMode = enabled; +} + +void +_ListItemCommon::SetAppInfo(const void* pAppInfo) +{ + __pAppInfo = const_cast(pAppInfo); +} + +void* +_ListItemCommon::GetAppInfo(void) const +{ + return __pAppInfo; +} + +void +_ListItemCommon::SetItemChanged(bool changed) +{ + __itemChanged = changed; +} + +bool +_ListItemCommon::IsItemChanged(void) const +{ + return __itemChanged; +} + +int +_ListItemCommon::AddRef(void) +{ + return ++__refCount; +} + +int +_ListItemCommon::Release(void) +{ + --__refCount; + if (__refCount <= 0) + { + delete this; + return 0; + } + + return __refCount; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_ListItemEvent.cpp b/src/ui/controls/FUiCtrl_ListItemEvent.cpp new file mode 100644 index 0000000..5fd6725 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ListItemEvent.cpp @@ -0,0 +1,284 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListItemEvent.cpp + * @brief This is the implementation file for _ListItemEvent class. + * + * This file contains the implementation of _ListItemEvent class. + */ + +#include +#include +#include +#include +#include +#include "FUiCtrl_ListItemEvent.h" +#include "FUiCtrl_ListItemEventArg.h" + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ListItemEvent::_ListItemEvent(void) + : __pSource(null) + , __invokeListViewItemCallback(true) + , __invokeGroupedListViewItemCallback(true) + , __className(CLASSNAME_NONE) +{ + // nothing +} + +_ListItemEvent::~_ListItemEvent(void) +{ + // nothing +} + +result +_ListItemEvent::Construct(Control& source, ListClassName name) +{ + // set event source + __pSource = &source; + __className = name; + + return E_SUCCESS; +} + +Control* +_ListItemEvent::GetSource(void) const +{ + return __pSource; +} + +ListClassName +_ListItemEvent::GetListClassName(void) const +{ + return __className; +} + +void +_ListItemEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to _ItemEventArg + _ListItemEventArg* pEventArg = dynamic_cast<_ListItemEventArg*>(const_cast(&arg)); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_INVALID_ARG, + ("[E_INVALID_ARG] event argument is invalid type.")); + + int index1 = -1; + int index2 = -1; + int index3 = -1; + int index4 = -1; + + pEventArg->GetEventArgs(index1, index2, index3, index4); + + bool tempInvokeListViewItemCallback = __invokeListViewItemCallback; + __invokeListViewItemCallback = true; + + bool tempInvokeGroupedListViewItemCallback = __invokeGroupedListViewItemCallback; + __invokeGroupedListViewItemCallback = true; + + if (__className == CLASSNAME_LISTVIEW) // ListView + { + IListViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, + ("[E_INVALID_ARG] invalid listener type.")); + + ListView* pListView = dynamic_cast(GetSource()); + SysAssertf(pListView != null, "Not yet constructed. Construct() should be called before use."); + + if (index2 < 0) + { + index2 = -1; + } + + switch (pEventArg->GetNotifyType()) + { + case NOTIFY_TYPE_SELECTED_ITEM: + if (tempInvokeListViewItemCallback == true) + { + pItemListener->OnListViewItemStateChanged(*pListView, index1, index2, LIST_ITEM_STATUS_SELECTED); + } + break; + + case NOTIFY_TYPE_HIGHLIGHED_ITEM: + if (tempInvokeListViewItemCallback == true) + { + pItemListener->OnListViewItemStateChanged(*pListView, index1, index2, LIST_ITEM_STATUS_HIGHLIGHTED); + } + break; + + case NOTIFY_TYPE_ANNEX_CHECK: + if (tempInvokeListViewItemCallback == true) + { + pItemListener->OnListViewItemStateChanged(*pListView, index1, index2, LIST_ITEM_STATUS_CHECKED); + } + break; + + case NOTIFY_TYPE_ANNEX_UNCHECK: + if (tempInvokeListViewItemCallback == true) + { + pItemListener->OnListViewItemStateChanged(*pListView, index1, index2, LIST_ITEM_STATUS_UNCHECKED); + } + break; + + case NOTIFY_TYPE_ANNEX_MORE: + if (tempInvokeListViewItemCallback == true) + { + pItemListener->OnListViewItemStateChanged(*pListView, index1, index2, LIST_ITEM_STATUS_MORE); + } + break; + + case NOTIFY_TYPE_SELCTED_CONTEXT_ITEM: + if (tempInvokeListViewItemCallback == true) + { + pItemListener->OnListViewContextItemStateChanged(*pListView, index1, index2, LIST_CONTEXT_ITEM_STATUS_SELECTED); + } + break; + + case NOTIFY_TYPE_SWEPT_ITEM: + if (tempInvokeListViewItemCallback == true) + { + if (index2 == SWEEP_DIRECTION_LEFT) + { + pItemListener->OnListViewItemSwept(*pListView, index1, SWEEP_DIRECTION_LEFT); + } + else + { + pItemListener->OnListViewItemSwept(*pListView, index1, SWEEP_DIRECTION_RIGHT); + } + } + break; + + case NOTIFY_TYPE_LONG_PRESSED_ITEM: + pItemListener->OnListViewItemLongPressed(*pListView, index1, index2, __invokeListViewItemCallback); + break; + + case NOTIFY_TYPE_REORDERED_ITEM: + if (tempInvokeListViewItemCallback == true) + { + pItemListener->OnListViewItemReordered(*pListView, index1, index2); + } + break; + + default: + return; + } + + } + else if (__className == CLASSNAME_GROUPEDLISTVIEW) // GroupedListView + { + IGroupedListViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, + ("[E_INVALID_ARG] invalid listener type.")); + + GroupedListView* pGroupedListView = dynamic_cast(GetSource()); + SysAssertf(pGroupedListView != null, "Not yet constructed. Construct() should be called before use."); + + if (index3 < 0) + { + index3 = -1; + } + + switch (pEventArg->GetNotifyType()) + { + case NOTIFY_TYPE_SELECTED_ITEM: + if (tempInvokeGroupedListViewItemCallback == true) + { + if (index2 == -1) + { + pItemListener->OnGroupedListViewGroupItemSelected(*pGroupedListView, index1); + break; + } + + pItemListener->OnGroupedListViewItemStateChanged(*pGroupedListView, index1, index2, index3, LIST_ITEM_STATUS_SELECTED); + } + break; + + case NOTIFY_TYPE_HIGHLIGHED_ITEM: + if (tempInvokeGroupedListViewItemCallback == true) + { + pItemListener->OnGroupedListViewItemStateChanged(*pGroupedListView, index1, index2, index3, LIST_ITEM_STATUS_HIGHLIGHTED); + } + break; + + case NOTIFY_TYPE_ANNEX_CHECK: + if (tempInvokeGroupedListViewItemCallback == true) + { + pItemListener->OnGroupedListViewItemStateChanged(*pGroupedListView, index1, index2, index3, LIST_ITEM_STATUS_CHECKED); + } + break; + + case NOTIFY_TYPE_ANNEX_UNCHECK: + if (tempInvokeGroupedListViewItemCallback == true) + { + pItemListener->OnGroupedListViewItemStateChanged(*pGroupedListView, index1, index2, index3, LIST_ITEM_STATUS_UNCHECKED); + } + break; + + case NOTIFY_TYPE_ANNEX_MORE: + if (tempInvokeGroupedListViewItemCallback == true) + { + pItemListener->OnGroupedListViewItemStateChanged(*pGroupedListView, index1, index2, index3, LIST_ITEM_STATUS_MORE); + } + break; + + case NOTIFY_TYPE_SELCTED_CONTEXT_ITEM: + if (tempInvokeGroupedListViewItemCallback == true) + { + pItemListener->OnGroupedListViewContextItemStateChanged(*pGroupedListView, index1, index2, index3, LIST_CONTEXT_ITEM_STATUS_SELECTED); + } + break; + + case NOTIFY_TYPE_SWEPT_ITEM: + if (tempInvokeGroupedListViewItemCallback == true) + { + if (index3 == SWEEP_DIRECTION_LEFT) + { + pItemListener->OnGroupedListViewItemSwept(*pGroupedListView, index1, index2, SWEEP_DIRECTION_LEFT); + } + else + { + pItemListener->OnGroupedListViewItemSwept(*pGroupedListView, index1, index2, SWEEP_DIRECTION_RIGHT); + } + } + break; + + case NOTIFY_TYPE_LONG_PRESSED_ITEM: + if (index2 != -1) + { + pItemListener->OnGroupedListViewItemLongPressed(*pGroupedListView, index1, index2, index3, __invokeGroupedListViewItemCallback); + } + break; + + case NOTIFY_TYPE_REORDERED_ITEM: + if (tempInvokeListViewItemCallback == true) + { + pItemListener->OnGroupedListViewItemReordered(*pGroupedListView, index1, index2, index3, index4); + } + break; + + default: + return; + } + } +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_ListItemEventArg.cpp b/src/ui/controls/FUiCtrl_ListItemEventArg.cpp new file mode 100644 index 0000000..09b7f35 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ListItemEventArg.cpp @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListItemEventArg.cpp + * @brief This is the implementation file for _ListItemEventArg class. + * + * This file contains the implementation of _ListItemEventArg class. + */ + +#include +#include "FUiCtrl_ListItemEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ListItemEventArg::_ListItemEventArg(int arg1, int arg2, int arg3, int arg4, NotifyType type) + : __arg1(arg1) + , __arg2(arg2) + , __arg3(arg3) + , __arg4(arg4) + , __type(type) +{ + // nothing +} + +_ListItemEventArg::~_ListItemEventArg(void) +{ + // nothing +} + +int +_ListItemEventArg::GetEventArg1(void) const +{ + return __arg1; +} + +int +_ListItemEventArg::GetEventArg2(void) const +{ + return __arg2; +} + +int +_ListItemEventArg::GetEventArg3(void) const +{ + return __arg3; +} + +int +_ListItemEventArg::GetEventArg4(void) const +{ + return __arg4; +} + +void +_ListItemEventArg::GetEventArgs(int& arg1, int& arg2, int& arg3, int& arg4) +{ + arg1 = __arg1; + arg2 = __arg2; + arg3 = __arg3; + arg4 = __arg4; +} + +NotifyType +_ListItemEventArg::GetNotifyType(void) const +{ + return __type; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ListViewContextItem.cpp b/src/ui/controls/FUiCtrl_ListViewContextItem.cpp new file mode 100644 index 0000000..23648d3 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ListViewContextItem.cpp @@ -0,0 +1,331 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListViewContextItem.cpp + * @brief This is the implementation file for _ListViewContextItem class. + * + * This file contains the implementation of _ListViewContextItem class. + */ + +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_ListViewContextItem.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ListViewContextItem::_ListViewContextItem(int itemHeight) + : _TableViewItem(itemHeight) +{ + GET_SHAPE_CONFIG(LISTVIEW::CONTEXTITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __margin); + GET_SHAPE_CONFIG(LISTVIEW::CONTEXTITEM_ELEMENT_SPACING, _CONTROL_ORIENTATION_PORTRAIT, __elementSpacing); + GET_SHAPE_CONFIG(LISTVIEW::CONTEXTITEM_ELEMENT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __elementHeight); + GET_SHAPE_CONFIG(LISTVIEW::CONTEXTITEM_ELEMENT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __textSize); + + SetBackgroundColor(Color(0, 0, 0, 0)); +} + +_ListViewContextItem::~_ListViewContextItem(void) +{ + for (int i = __elements.size() - 1; i >= 0; i--) + { + _ListViewContextItemElement element = __elements.at(i); + + DetachChild(*(element.pButton)); + + delete element.pButton; + element.pButton = null; + + __elements.pop_back(); + } + + __elements.clear(); +} + +_ListViewContextItem* +_ListViewContextItem::CreateListViewContextItemN(int itemHeight) +{ + _ListViewContextItem* pItem = new (std::nothrow) _ListViewContextItem(itemHeight); + SysTryReturn(NID_UI_CTRL, (pItem != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pItem->AcquireHandle(); + + result r = pItem->Initialize(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r = E_SYSTEM, "[E_SYSTEM] Unable to create TableView Item"); + + return pItem; + +CATCH: + delete pItem; + + return null; +} + +bool +_ListViewContextItem::AddElement(int elementId, const String& text, bool enable) +{ + if (text.IsEmpty() || HasElement(elementId)) + { + return false; + } + + _ListViewContextItemElement contextElement; + memset(&contextElement, 0, sizeof(_ListViewContextItemElement)); + + contextElement.elementId = elementId; + contextElement.pButton = _Button::CreateButtonN(); + SysTryReturn(NID_UI_CTRL, (contextElement.pButton != null), false, E_OUT_OF_MEMORY, "E_OUT_OF_MEMORY] The memory is insufficient."); + + __elements.push_back(contextElement); + + AdjustElementLayout(); + + contextElement.pButton->SetActionId(elementId); + contextElement.pButton->SetEnableState(enable); + //contextElement.pButton->SetMargin(0, 0); + contextElement.pButton->SetTextSize(__textSize); + contextElement.pButton->SetText(text); + + AttachChild(*(contextElement.pButton)); + + return true; +} + +bool +_ListViewContextItem::AddElement(int elementId, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap, + const Bitmap* pHighlightedBitmap, bool enable) +{ + if ((pNormalBitmap == null) || (pPressedBitmap == null) || HasElement(elementId)) + { + return false; + } + + _ListViewContextItemElement contextElement; + memset(&contextElement, 0, sizeof(_ListViewContextItemElement)); + + contextElement.elementId = elementId; + contextElement.pButton = _Button::CreateButtonN(); + SysTryReturn(NID_UI_CTRL, (contextElement.pButton != null), false, E_OUT_OF_MEMORY, "E_OUT_OF_MEMORY] The memory is insufficient."); + + __elements.push_back(contextElement); + + AdjustElementLayout(); + + contextElement.pButton->SetActionId(elementId); + contextElement.pButton->SetEnableState(enable); + contextElement.pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pNormalBitmap); + contextElement.pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pPressedBitmap); + + if (pHighlightedBitmap != null) + { + contextElement.pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pHighlightedBitmap); + } + + AttachChild(*(contextElement.pButton)); + + return true; +} + +bool +_ListViewContextItem::AddElement(int elementId, const String& text, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap, + const Bitmap* pHighlightedBitmap, bool enable) +{ + if (text.IsEmpty() || (pNormalBitmap == null) || (pPressedBitmap == null) || HasElement(elementId)) + { + return false; + } + + _ListViewContextItemElement contextElement; + memset(&contextElement, 0, sizeof(_ListViewContextItemElement)); + + contextElement.elementId = elementId; + contextElement.pButton = _Button::CreateButtonN(); + SysTryReturn(NID_UI_CTRL, (contextElement.pButton != null), false, E_OUT_OF_MEMORY, "E_OUT_OF_MEMORY] The memory is insufficient."); + + __elements.push_back(contextElement); + + AdjustElementLayout(); + + contextElement.pButton->SetActionId(elementId); + contextElement.pButton->SetEnableState(enable); + contextElement.pButton->SetMargin(0, 0); + contextElement.pButton->SetTextSize(__textSize); + contextElement.pButton->SetText(text); + contextElement.pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pNormalBitmap); + contextElement.pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pPressedBitmap); + + if (pHighlightedBitmap != null) + { + contextElement.pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pHighlightedBitmap); + } + + AttachChild(*(contextElement.pButton)); + + return true; +} + +void +_ListViewContextItem::AdjustElementLayout(void) +{ + if (__elements.size() == 0) + { + return; + } + + int elementCount = __elements.size(); + Rectangle itemBounds = GetBounds(); + Rectangle elementBounds; + + // Calculate horizontal value + if (elementCount == 1) + { + int margin = 0; + GET_SHAPE_CONFIG(LISTVIEW::CONTEXTITEM_LEFT_MARGIN_ONE, _CONTROL_ORIENTATION_PORTRAIT, margin); + + elementBounds.x = __margin + margin; + elementBounds.width = (itemBounds.width - ((__margin + margin) * 2)); + } + else + { + elementBounds.x = __margin; + elementBounds.width = ((itemBounds.width - __margin * 2) - (__elementSpacing * (elementCount - 1))) / elementCount; + } + + // Calculate vertical value + elementBounds.y = (itemBounds.height - __elementHeight) / 2; + elementBounds.height = __elementHeight; + + _LinkedList <_ListViewContextItemElement>::_Iterator iter; + + for (iter = __elements.begin(); iter != __elements.end(); iter++) + { + if (iter->pButton != null) + { + iter->pButton->SetBounds(elementBounds); + } + + elementBounds.x += (elementBounds.width + __elementSpacing); + } +} + +_ListViewContextItemElement* +_ListViewContextItem::GetElement(int elementId) const +{ + _LinkedList <_ListViewContextItemElement>::_Iterator iter; + + for (iter = __elements.begin(); iter != __elements.end(); iter++) + { + if (iter->elementId == elementId) + { + return &(*iter); + } + } + + return null; +} + +bool +_ListViewContextItem::HasElement(int elementId) +{ + _ListViewContextItemElement* pElement = GetElement(elementId); + + return (pElement != null); +} + +int +_ListViewContextItem::GetElementIdFromPosition(const Point& position) const +{ + _LinkedList <_ListViewContextItemElement>::_ReverseIterator reverseIter; + + for (reverseIter = __elements.rbegin(); reverseIter != __elements.rend(); reverseIter++) + { + if ((*reverseIter).pButton->GetBounds().Contains(position)) + { + return (*reverseIter).elementId; + } + } + + return -1; +} + +void +_ListViewContextItem::AddContextItemEventListener(_IActionEventListener& listener) +{ + if (__elements.size() > 0) + { + _LinkedList <_ListViewContextItemElement>::_Iterator iter; + + for (iter = __elements.begin(); iter != __elements.end(); iter++) + { + iter->pButton->AddActionEventListener(listener); + } + } +} + +void +_ListViewContextItem::RemoveContextItemEventListener(_IActionEventListener& listener) +{ + if (__elements.size() > 0) + { + _LinkedList <_ListViewContextItemElement>::_Iterator iter; + + for (iter = __elements.begin(); iter != __elements.end(); iter++) + { + iter->pButton->RemoveActionEventListener(listener); + } + } +} + +void +_ListViewContextItem::AdjustItemBounds(Rectangle& bounds) +{ + Rectangle newBounds = bounds; + Dimension itemDimension = GetSize(); + int margin = 0; + + GET_SHAPE_CONFIG(TABLEVIEW::CONTEXTITEM_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, margin); + newBounds.width -= margin; + + if ((itemDimension.width != newBounds.width) || (itemDimension.height != newBounds.height)) + { + SetBounds(Rectangle(0, 0,newBounds.width, newBounds.height)); + AdjustElementLayout(); + } +} + +void +_ListViewContextItem::OnFontChanged(Font* pFont) +{ + String fontName = GetFont(); + + _LinkedList <_ListViewContextItemElement>::_Iterator iter; + + for (iter = __elements.begin(); iter != __elements.end(); iter++) + { + iter->pButton->SetFont(fontName); + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ListViewImpl.cpp b/src/ui/controls/FUiCtrl_ListViewImpl.cpp new file mode 100644 index 0000000..b300f6e --- /dev/null +++ b/src/ui/controls/FUiCtrl_ListViewImpl.cpp @@ -0,0 +1,1543 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListViewImpl.cpp + * @brief This is the implementation file for _ListViewImpl class. + * + * This file contains the implementation of _ListViewImpl class. + */ + +#include +#include +#include "FApp_AppInfo.h" +#include "FUi_ResourceManager.h" +#include "FUi_TouchManager.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_FastScrollEvent.h" +#include "FUiCtrl_FastScrollEventArg.h" +#include "FUiCtrl_Label.h" +#include "FUiCtrl_ListItemEvent.h" +#include "FUiCtrl_ListItemEventArg.h" +#include "FUiCtrl_ListViewImpl.h" +#include "FUiCtrl_ListViewItem.h" +#include "FUiCtrl_ListViewItemProviderAdaptor.h" +#include "FUiCtrl_PublicLinkEvent.h" +#include "FUiCtrl_ScrollEvent.h" +#include "FUiCtrl_ScrollEventArg.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ListViewImpl* +_ListViewImpl::GetInstance(ListView& listView) +{ + return static_cast<_ListViewImpl*>(listView._pControlImpl); +} + +const _ListViewImpl* +_ListViewImpl::GetInstance(const ListView& listView) +{ + return static_cast(listView._pControlImpl); +} + +_ListViewImpl::_ListViewImpl(ListView* pList, _TableView* pCore) + : _ControlImpl(pList, pCore) + , __pListItemEvent(null) + , __pLinkEvent(null) + , __pScrollEvent(null) + , __pFastScrollEvent(null) + , __pEmptyBitmap(null) + , __pEmptyText(null) + , __redrawListView(true) + , __pItemNeedsLazyDeletion(null) + , __pItemSwept(null) +{ + GET_COLOR_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_NORMAL, __emptyTextColor); +} + +_ListViewImpl::~_ListViewImpl() +{ + if (__pListItemEvent != null) + { + //__pListItemEvent->RemoveListener(*this); + + delete __pListItemEvent; + __pListItemEvent = null; + } + + if (__pLinkEvent != null) + { + //__pLinkEvent->RemoveListener(*this); + + delete __pLinkEvent; + __pLinkEvent = null; + } + + if (__pScrollEvent != null) + { + //__pScrollEvent->RemoveListener(*this); + + delete __pScrollEvent; + __pScrollEvent = null; + } + + if (__pFastScrollEvent != null) + { + //__pFastScrollEvent->RemoveListener(*this); + + delete __pFastScrollEvent; + __pFastScrollEvent = null; + } + + if (__pEmptyBitmap != null) + { + GetCore().DetachChild(*__pEmptyBitmap); + + delete __pEmptyBitmap; + __pEmptyBitmap = null; + } + + if (__pEmptyText != null) + { + GetCore().DetachChild(*__pEmptyText); + + delete __pEmptyText; + __pEmptyText = null; + } +} + +const char* +_ListViewImpl::GetPublicClassName(void) const +{ + return "Controls::ListView"; +} + +const ListView& +_ListViewImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +ListView& +_ListViewImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _TableView& +_ListViewImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_TableView& +_ListViewImpl::GetCore(void) +{ + return static_cast <_TableView&>(_ControlImpl::GetCore()); +} + +_ListViewImpl* +_ListViewImpl::CreateListViewImplN(ListView* pControl, bool itemDivider, ListScrollStyle scrollStyle) +{ + result r = E_SUCCESS; + TableViewScrollBarStyle scrollBarStyle; + + switch (scrollStyle) + { + case SCROLL_STYLE_FADE_OUT: + scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT; + break; + case SCROLL_STYLE_FIXED: + scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FIXED; + break; + case SCROLL_STYLE_FAST_SCROLL: + scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL; + break; + case SCROLL_STYLE_JUMP_TO_TOP: + scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP; + break; + case SCROLL_STYLE_THUMB: + scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_THUMB; + break; + default: + scrollBarStyle = TABLE_VIEW_SCROLL_BAR_STYLE_NONE; + break; + } + + _TableView* pCore = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_SIMPLE, itemDivider, scrollBarStyle); + + SysTryReturn(NID_UI_CTRL, (pCore != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _ListViewImpl* pImpl = new (std::nothrow) _ListViewImpl(pControl, pCore); + + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return pImpl; +} + +result +_ListViewImpl::SetItemProvider(IListViewItemProvider& provider) +{ + result r = E_SUCCESS; + + _ListViewItemProviderAdaptor* pProviderAdaptor = + static_cast <_ListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor()); + + if (pProviderAdaptor == null) + { + pProviderAdaptor = new (std::nothrow) _ListViewItemProviderAdaptor(provider); + SysTryReturn(NID_UI_CTRL, (pProviderAdaptor != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pProviderAdaptor->SetListViewItemEventListener(*this); + + r = pProviderAdaptor->SetListWidth(GetCore().GetBounds().width); + GetCore().SetItemProviderAdaptor(pProviderAdaptor); + } + else + { + pProviderAdaptor->SetItemProvider(provider); + r = pProviderAdaptor->SetListWidth(GetCore().GetBounds().width); + + UpdateList(); + } + + __redrawListView = true; + + SetLastResultReturn(r); +} + +void +_ListViewImpl::AddListViewItemEventListener(IListViewItemEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pListItemEvent == null) + { + __pListItemEvent = new (std::nothrow) _ListItemEvent(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pListItemEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pListItemEvent->Construct(GetPublic(), CLASSNAME_LISTVIEW); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct Item Event."); + } + + __pListItemEvent->AddListener(listener); + + r = GetCore().AddTableViewItemEventListener(*this); + + SetLastResult(r); +} + +void +_ListViewImpl::RemoveListViewItemEventListener(IListViewItemEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pListItemEvent != null) + { + r = __pListItemEvent->RemoveListener(listener); + } + + SetLastResult(r); +} + +void +_ListViewImpl::AddFastScrollListener(IFastScrollListener& listener) +{ + result r = E_SUCCESS; + + if (__pFastScrollEvent == null) + { + __pFastScrollEvent = new (std::nothrow) _FastScrollEvent(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pFastScrollEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pFastScrollEvent->Construct(GetPublic()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct FastScroll Event."); + } + + __pFastScrollEvent->AddListener(listener); + + r = GetCore().AddFastScrollListener(*this); + + SetLastResult(r); +} + +void +_ListViewImpl::RemoveFastScrollListener(IFastScrollListener& listener) +{ + result r = E_SUCCESS; + + if (__pFastScrollEvent != null) + { + r = __pFastScrollEvent->RemoveListener(listener); + } + + SetLastResult(r); +} + +void +_ListViewImpl::AddScrollEventListener(IScrollEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pScrollEvent == null) + { + __pScrollEvent = new (std::nothrow) _ScrollEvent(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pScrollEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pScrollEvent->Construct(GetPublic()); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] Unable to construct Scroll Event."); + } + + __pScrollEvent->AddListener(listener); + + GetCore().AddScrollEventListener(*this); + + SetLastResult(r); +} + +void +_ListViewImpl::RemoveScrollEventListener(IScrollEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pScrollEvent != null) + { + r = __pScrollEvent->RemoveListener(listener); + } + + SetLastResult(r); +} + +void +_ListViewImpl::AddUiLinkEventListener(const IUiLinkEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pLinkEvent == null) + { + __pLinkEvent = _PublicLinkEvent::CreateInstanceN(GetPublic()); + SysTryReturnVoidResult(NID_UI_CTRL, (__pLinkEvent != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + } + + r = __pLinkEvent->AddListener(listener); + + SetLastResult(r); +} + + +void +_ListViewImpl::RemoveUiLinkEventListener(const IUiLinkEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pLinkEvent != null) + { + r = __pLinkEvent->RemoveListener(listener); + } + + SetLastResult(r); +} + +result +_ListViewImpl::SetSweepEnabled(bool enable) +{ + GetCore().SetSweepEnabled(enable); + + SetLastResultReturn(E_SUCCESS); +} + +result +_ListViewImpl::SetFastScrollIndex(const String& text, bool useSearchIcon) +{ + result r = GetCore().SetFastScrollIndex(text, useSearchIcon); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS) || (r == E_SYSTEM), E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] This instance is in an invalid state."); + + SetLastResultReturn(r); +} + +int +_ListViewImpl::GetTopDrawnItemIndex(void) const +{ + int groupIndex = -1; + int itemIndex = -1; + + GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex); + + return itemIndex; +} + +int +_ListViewImpl::GetBottomDrawnItemIndex(void) const +{ + int groupIndex = -1; + int itemIndex = -1; + + GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex); + + return itemIndex; +} + +result +_ListViewImpl::ScrollToItem(int index, ListScrollItemAlignment itemAlignment) +{ + result r = E_SUCCESS; + + if (itemAlignment == LIST_SCROLL_ITEM_ALIGNMENT_TOP) + { + r = GetCore().SetTopDrawnItemIndex(0, index); + } + else if (itemAlignment == LIST_SCROLL_ITEM_ALIGNMENT_BOTTOM) + { + r = GetCore().SetBottomDrawnItemIndex(0, index); + } + else + { + SysTryReturn(NID_UI_CTRL, false, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified itemAlignment is out of range."); + } + + SetLastResultReturn(r); +} + +result +_ListViewImpl::SetItemChecked(int index, bool check) +{ + return GetCore().SetItemChecked(0, index, check); +} + +bool +_ListViewImpl::IsItemChecked(int index) const +{ + return GetCore().IsItemChecked(0, index); +} + +result +_ListViewImpl::SetItemEnabled(int index, bool enable) +{ + return GetCore().SetItemEnabled(0, index, enable); +} + +bool +_ListViewImpl::IsItemEnabled(int index) const +{ + return GetCore().IsItemEnabled(0, index); +} + +int +_ListViewImpl::GetItemCount(void) const +{ + return GetCore().GetItemCountAt(0); +} + +result +_ListViewImpl::ShowItemDescriptionText(int index) +{ + return SetItemDescriptionTextShowState(index, true); +} + +result +_ListViewImpl::HideItemDescriptionText(int index) +{ + return SetItemDescriptionTextShowState(index, false); +} + +result +_ListViewImpl::SetItemDescriptionTextShowState(int index, bool show) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (index >= 0) && (index < GetItemCount()), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified index is out of range."); + + _ListViewItemProviderAdaptor* pProviderAdaptor = + static_cast <_ListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor()); + SysTryReturn(NID_UI_CTRL, (pProviderAdaptor != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] _ListItemProviderAdaptor is not set."); + + // Save description text show state to provider adaptor + pProviderAdaptor->SetDescriptionTextShowState(index, show); + + if (GetCore().FindItem(0, index) != null) + { + r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + } + + SetLastResultReturn(r); +} + +result +_ListViewImpl::RefreshList(int index, ListRefreshType type) +{ + result r = E_SUCCESS; + + int itemCount = GetCore().GetItemCountAt(0); + + if ((index < 0) || (index > itemCount) || + ((type != LIST_REFRESH_TYPE_ITEM_ADD) && (index == itemCount))) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range."); + return E_OUT_OF_RANGE; + } + + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, index)); + + // for lazy delete item + if ((__pItemNeedsLazyDeletion != null) && (type != LIST_REFRESH_TYPE_ITEM_ADD)) + { + if (__pItemNeedsLazyDeletion == pListViewItem) + { + _ListViewItemProviderAdaptor* pProviderAdaptor = static_cast <_ListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor()); + + if (pProviderAdaptor != null) + { + pProviderAdaptor->SetItemNeedsLazyDeletion(__pItemNeedsLazyDeletion); + } + } + } + + if ((__pItemSwept != null) && (type != LIST_REFRESH_TYPE_ITEM_ADD)) + { + if (__pItemSwept == pListViewItem) + { + GetCore().ResetSweepItem(); + } + } + + if (type == LIST_REFRESH_TYPE_ITEM_MODIFY) + { + int topGroupIndex = -1; + int topItemIndex = -1; + int bottomGroupIndex = -1; + int bottomItemIndex = -1; + + GetCore().GetFirstLoadedItemIndex(topGroupIndex, topItemIndex); + GetCore().GetLastLoadedItemIndex(bottomGroupIndex, bottomItemIndex); + + if ((topItemIndex <= index) && (bottomItemIndex >= index)) + { + TableViewItemDrawingStatus itemDrawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + bool itemSelected = false; + Point touchPosition(-1, -1); + + if (pListViewItem != null) + { + itemDrawingStatus = pListViewItem->GetDrawingStatus(); + itemSelected = pListViewItem->GetSelectionState(); + touchPosition = pListViewItem->GetLastTouchPressedPosition(); + + pListViewItem = null; + } + + GetCore().UnloadItem(0, index); + GetCore().LoadItem(0, index); + + pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, index)); + + if ((pListViewItem != null) && (itemDrawingStatus != TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)) + { + pListViewItem->SetDrawingStatus(itemDrawingStatus); + pListViewItem->SetSelectionState(itemSelected); + pListViewItem->SetLastTouchPressedPosition(touchPosition); + + // for create Annex + pListViewItem->Draw(); + pListViewItem->Show(); + + _Control* target = static_cast<_Control*>(pListViewItem); + + for (int i = 0; i < pListViewItem->GetChildCount(); i++) + { + if (pListViewItem->GetChild(i)->GetBounds().Contains(touchPosition)) + { + target = pListViewItem->GetChild(i); + } + } + + if (target != null) + { + target->SetChangingEventTarget(true); + } + else + { + pListViewItem->SetDrawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + pListViewItem->SetSelectionState(false); + } + } + } + else + { + // not yet loaded item + SetLastResultReturn(r); + } + } + else + { + r = GetCore().RefreshTableView(0, index, static_cast(type)); + } + + CheckEmptyListShowState(); + + Draw(); + Show(); + + SetLastResultReturn(r); +} + +result +_ListViewImpl::RefreshList(int index, int elementId) +{ + if ((index < 0) || (index >= GetCore().GetItemCountAt(0))) + { + return E_OUT_OF_RANGE; + } + + result r = E_SUCCESS; + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, index)); + + if (pListViewItem != null) + { + r = (pListViewItem->RefreshElement(elementId)) ? E_SUCCESS : E_OUT_OF_RANGE; + } + + SetLastResultReturn(r); +} + +result +_ListViewImpl::UpdateList(void) +{ + // for lazy delete item + if (__pItemNeedsLazyDeletion != null) + { + _ListViewItemProviderAdaptor* pProviderAdaptor = static_cast <_ListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor()); + + if (pProviderAdaptor != null) + { + pProviderAdaptor->SetItemNeedsLazyDeletion(__pItemNeedsLazyDeletion); + } + } + + result r = GetCore().UpdateTableView(); + + CheckEmptyListShowState(); + + Invalidate(true); + + // API versioning for initial Show() operation + if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat()) + { + Show(); + } + + SetLastResultReturn(r); +} + +int +_ListViewImpl::GetItemIndexFromPosition(const Point& position) const +{ + int groupIndex = -1; + int itemIndex = -1; + + GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex); + + return itemIndex; +} + +result +_ListViewImpl::GetItemIndexFromPosition(const Point& position, int& itemIndex, int& elementId) const +{ + int groupIndex = -1; + elementId = -1; + + result r = GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] There is no item at the specified position."); + + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, itemIndex)); + + if (pListViewItem != null) + { + Point originPosition = pListViewItem->GetPosition(); + originPosition.y -= GetCore().GetScrollPosition(); + + elementId = pListViewItem->GetElementIdFromPosition(Point(position.x - originPosition.x, position.y - originPosition.y)); + } + + SetLastResultReturn(r); +} + +result +_ListViewImpl::SetItemDividerColor(const Color& color) +{ + return GetCore().SetItemDividerColor(color); +} + +Color +_ListViewImpl::GetItemDividerColor(void) const +{ + return GetCore().GetItemDividerColor(); +} + +void +_ListViewImpl::AdjustLayoutOfEmptyList(void) +{ + Dimension listDimension = GetCore().GetSize(); + Dimension emptyBitmap; + Dimension emptyText; + Point bitmapPos; + Point textPos; + int totalHeight = 0; + + if (__pEmptyBitmap != null) + { + emptyBitmap = __pEmptyBitmap->GetSize(); + } + if (__pEmptyText != null) + { + emptyText = __pEmptyText->GetSize(); + } + + totalHeight = emptyBitmap.height + emptyText.height; + + if ((__pEmptyBitmap != null) && (__pEmptyText != null) && (totalHeight < listDimension.height)) + { + bitmapPos.x = ((listDimension.width == emptyBitmap.width) ? 0 : (listDimension.width - emptyBitmap.width) / 2); + bitmapPos.y = (listDimension.height - totalHeight) / 2; + + textPos.x = ((listDimension.width == emptyText.width) ? 0 : (listDimension.width - emptyText.width) / 2); + textPos.y = bitmapPos.y + emptyBitmap.height; + } + else + { + if (__pEmptyBitmap != null) + { + bitmapPos.x = ((listDimension.width == emptyBitmap.width) ? 0 : (listDimension.width - emptyBitmap.width) / 2); + bitmapPos.y = ((listDimension.height == emptyBitmap.height) ? 0 : (listDimension.height - emptyBitmap.height) / 2); + } + + if (__pEmptyText != null) + { + textPos.x = ((listDimension.width == emptyText.width) ? 0 : (listDimension.width - emptyText.width) / 2); + textPos.y = ((listDimension.height == emptyText.height) ? 0 : (listDimension.height - emptyText.height) / 2); + } + } + + if (__pEmptyBitmap != null) + { + __pEmptyBitmap->SetPosition(bitmapPos); + } + if (__pEmptyText != null) + { + __pEmptyText->SetPosition(textPos); + } + + CheckEmptyListShowState(); +} + +void +_ListViewImpl::CheckEmptyListShowState(void) +{ + bool isEmpty = (GetItemCount() <= 0); + + if (__pEmptyBitmap != null) + { + __pEmptyBitmap->SetVisibleState(isEmpty); + } + if (__pEmptyText != null) + { + __pEmptyText->SetVisibleState(isEmpty); + } +} + +result +_ListViewImpl::SetBitmapOfEmptyList(const Bitmap* pBitmap) +{ + if (pBitmap == null) + { + if (__pEmptyBitmap != null) + { + GetCore().DetachChild(*__pEmptyBitmap); + + delete __pEmptyBitmap; + __pEmptyBitmap = null; + } + } + else + { + if (__pEmptyBitmap == null) + { + __pEmptyBitmap = _Label::CreateLabelN(); + SysTryReturn(NID_UI_CTRL, (__pEmptyBitmap != null), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pEmptyBitmap->SetVisibleState(false); + __pEmptyBitmap->SetMargin(0, 0); + + GetCore().AttachChild(*__pEmptyBitmap); + } + + Dimension bitmapSize(pBitmap->GetWidth(), pBitmap->GetHeight()); + Dimension listDimension = GetCore().GetSize(); + Dimension labelDimension; + + labelDimension.width = ((listDimension.width < bitmapSize.width) ? listDimension.width : bitmapSize.width); + labelDimension.height = ((listDimension.height < bitmapSize.height) ? listDimension.height : bitmapSize.height); + + __pEmptyBitmap->SetSize(labelDimension); + __pEmptyBitmap->SetBackgroundColor(Color(0, 0, 0, 0)); + __pEmptyBitmap->SetBackgroundBitmap(*pBitmap); + } + + AdjustLayoutOfEmptyList(); + + SetLastResultReturn(E_SUCCESS); +} + +result +_ListViewImpl::SetTextOfEmptyList(const String& text) +{ + if (text.IsEmpty()) + { + if (__pEmptyText != null) + { + GetCore().DetachChild(*__pEmptyText); + + delete __pEmptyText; + __pEmptyText = null; + } + } + else + { + if (__pEmptyText == null) + { + __pEmptyText = _Label::CreateLabelN(); + SysTryReturn(NID_UI_CTRL, (__pEmptyText != null), E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pEmptyText->SetVisibleState(false); + __pEmptyText->SetMargin(0, 0); + + GetCore().AttachChild(*__pEmptyText); + } + + TextObject* pText = new (std::nothrow) TextObject; + SysTryReturn(NID_UI_CTRL, (pText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pText->Construct(); + + TextSimple* pSimpleText = new (std::nothrow) TextSimple(const_cast (text.GetPointer()), text.GetLength()); + SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pText->AppendElement(*pSimpleText); + + int textSize = 0; + GET_SHAPE_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, textSize); + + Font font; + font.Construct(GetFont(), FONT_STYLE_PLAIN, textSize); + pText->SetFont(&font, 0, pText->GetTextLength()); + + Dimension listDimension = GetCore().GetSize(); + + pText->SetBounds(Rectangle(0, 0, listDimension.width, 1)); + pText->Compose(); + + Dimension labelDimension = pText->GetTextExtent(0, pText->GetTextLength()); + labelDimension.height = pText->GetTotalHeight(); + + if (labelDimension.width > listDimension.width) + { + pText->SetBounds(Rectangle(0, 0, listDimension.width, 1)); + pText->Compose(); + + int labelHeight = pText->GetTotalHeight(); + + labelDimension.width = listDimension.width; + labelDimension.height = ((listDimension.height < labelHeight) ? listDimension.height : labelHeight); + } + + delete pText; + + __pEmptyText->SetSize(labelDimension); + __pEmptyText->SetBackgroundColor(Color(0, 0, 0, 0)); + __pEmptyText->SetTextColor(__emptyTextColor); + __pEmptyText->SetTextConfig(textSize, LABEL_TEXT_STYLE_NORMAL); + __pEmptyText->SetText(text); + } + + AdjustLayoutOfEmptyList(); + + SetLastResultReturn(E_SUCCESS); +} + +String +_ListViewImpl::GetTextOfEmptyList(void) const +{ + return ((__pEmptyText != null) ? __pEmptyText->GetText() : String()); +} + +result +_ListViewImpl::SetTextColorOfEmptyList(const Color& color) +{ + __emptyTextColor = color; + + if (__pEmptyText != null) + { + __pEmptyText->SetTextColor(color); + } + + SetLastResultReturn(E_SUCCESS); +} + +Color +_ListViewImpl::GetTextColorOfEmptyList(void) const +{ + return __emptyTextColor; +} + +result +_ListViewImpl::SetListBackgroundColor(const Color& color) +{ + SetBackgroundColor(color); + + SetLastResultReturn(E_SUCCESS); +} + +result +_ListViewImpl::SetBackgroundBitmap(const Bitmap* pBitmap) +{ + GetCore().SetBackgroundBitmap(const_cast(pBitmap)); + GetCore().SetBackgroundBitmapStretch(true); + + SetLastResultReturn(E_SUCCESS); +} + +result +_ListViewImpl::BeginReorderingMode(void) +{ + result r = GetCore().SetReorderModeEnabled(true); + + SetLastResultReturn(r); +} + +result +_ListViewImpl::EndReorderingMode(void) +{ + result r = GetCore().SetReorderModeEnabled(false); + + SetLastResultReturn(r); +} + +bool +_ListViewImpl::IsInReorderingMode(void) const +{ + return GetCore().IsReorderModeEnabled(); +} + +void +_ListViewImpl::OnListViewContextItemStateChanged(_Control& source, int groupIndex, int itemIndex, int elementId, + ListContextItemStatus status) +{ + if (__pListItemEvent != null) + { + GetCore().ResetSweepItem(); + + __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(0, itemIndex)); + + _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(itemIndex, elementId, 0, 0, NOTIFY_TYPE_SELCTED_CONTEXT_ITEM); + __pListItemEvent->Fire(*pArg); + + __pItemNeedsLazyDeletion = null; + } +} + +void +_ListViewImpl::OnListViewItemLongPressed(_Control& source, int groupIndex, int itemIndex, int elementId) +{ + if (__pListItemEvent != null) + { + __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(0, itemIndex)); + + _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(itemIndex, elementId, 0, 0, NOTIFY_TYPE_LONG_PRESSED_ITEM); + __pListItemEvent->Fire(*pArg); + + __pItemNeedsLazyDeletion = null; + } +} + +void +_ListViewImpl::OnTableViewItemStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + if (__pListItemEvent != null) + { + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(pItem); + + __pItemNeedsLazyDeletion = pListViewItem; + + if (pListViewItem != null) + { + _ListViewItemStateChangedInfo itemInfo; + pListViewItem->GetLastStateChangedInfo(itemInfo); + + if ((__pLinkEvent != null) && (itemInfo.pUiLinkInfo != null)) + { + IEventArg* pLinkEventArg = _PublicLinkEvent::CreateLinkEventArgN(itemInfo.pUiLinkInfo->textInfo, + itemInfo.pUiLinkInfo->linkType, + itemInfo.pUiLinkInfo->linkInfo); + + SysTryReturnVoidResult(NID_UI_CTRL, (pLinkEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + __pLinkEvent->Fire(*pLinkEventArg); + + } + else + { + _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(itemIndex, itemInfo.elementId, 0, 0, static_cast(status)); + __pListItemEvent->Fire(*pArg); + } + + pListViewItem->ClearLastStateChangedInfo(); + } + + __pItemNeedsLazyDeletion = null; + } +} + +void +_ListViewImpl::OnTableViewContextItemActivationStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(0, itemIndex)); + + if (pListViewItem != null) + { + __pItemSwept = (activated ? pListViewItem : null); + + pListViewItem->SetContextItemActivationState(activated); + } +} + +void +_ListViewImpl::OnTableViewItemReordered(_TableView& tableView, int itemIndexFrom, int itemIndexTo) +{ + if (__pListItemEvent != null) + { + _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(itemIndexFrom, itemIndexTo, 0, 0, NOTIFY_TYPE_REORDERED_ITEM); + __pListItemEvent->Fire(*pArg); + } +} + +void +_ListViewImpl::OnTableViewItemSwept(_TableView& tableView, int groupIndex, int itemIndex, TableViewSweepDirection direction) +{ + if (__pListItemEvent != null) + { + __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(0, itemIndex)); + + _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(itemIndex, direction, 0, 0, NOTIFY_TYPE_SWEPT_ITEM); + __pListItemEvent->Fire(*pArg); + + __pItemNeedsLazyDeletion = null; + } +} + +void +_ListViewImpl::OnScrollEndReached(_Control& source, ScrollEndEvent type) +{ + if (__pScrollEvent != null) + { + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), type); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + } +} + +void +_ListViewImpl::OnScrollPositionChanged(_Control& source, int scrollPos) +{ + if (__pScrollEvent != null) + { + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), scrollPos); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + } +} + +void +_ListViewImpl::OnScrollStopped(_Control& source) +{ + if (__pScrollEvent != null) + { + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic()); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + } +} + +void +_ListViewImpl::OnUiFastScrollIndexSelected(_Control& source, _FastScrollIndex& index) +{ + if (__pFastScrollEvent != null) + { + String* pIndexText = index.GetIndexText(); + if (pIndexText != null) + { + _FastScrollEventArg* pEventArg = new (std::nothrow) _FastScrollEventArg(GetPublic(), *pIndexText); + __pFastScrollEvent->Fire(*pEventArg); + } + } +} + +void +_ListViewImpl::OnDraw(void) +{ + _ControlImpl::OnDraw(); + + if (__redrawListView) + { + CheckEmptyListShowState(); + __redrawListView = false; + } +} + +void +_ListViewImpl::OnBoundsChanged(void) +{ + _ControlImpl::OnBoundsChanged(); + + if (__pEmptyBitmap != null) + { + SetBitmapOfEmptyList(__pEmptyBitmap->GetBackgroundBitmap()); + } + if (__pEmptyText != null) + { + SetTextOfEmptyList(__pEmptyText->GetText()); + } + + _ListViewItemProviderAdaptor* pProviderAdaptor = static_cast <_ListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor()); + + if (pProviderAdaptor != null) + { + pProviderAdaptor->SetListWidth(GetCore().GetBounds().width); + } +} + +void +_ListViewImpl::OnFontChanged(Font* pFont) +{ + String fontName = GetFont(); + _ListViewItemProviderAdaptor* pProviderAdaptor = static_cast <_ListViewItemProviderAdaptor*>(GetCore().GetItemProviderAdaptor()); + + if (__pEmptyText != null) + { + __pEmptyText->SetFont(fontName); + SetTextOfEmptyList(__pEmptyText->GetText()); + } + + if (pProviderAdaptor != null) + { + pProviderAdaptor->SetItemFont(fontName); + } + + int firstGroup = -1; + int firstItem = -1; + int lastGroup = -1; + int lastItem = -1; + int currentItem = -1; + int lastItemInGroup = -1; + + GetCore().GetFirstLoadedItemIndex(firstGroup, firstItem); + GetCore().GetLastLoadedItemIndex(lastGroup, lastItem); + + for (int i = firstGroup; i <= lastGroup; i++) + { + currentItem = ((i == firstGroup) ? firstItem : -1); + lastItemInGroup = ((i == lastGroup) ? lastItem : GetCore().GetItemCountAt(i)); + + for (; currentItem <= lastItemInGroup; currentItem++) + { + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(GetCore().FindItem(i, currentItem)); + + if (pListViewItem != null) + { + pListViewItem->SetFont(fontName); + } + } + } +} + +void +_ListViewImpl::OnFontInfoRequested(unsigned long& style, int& size) +{ + int textSize = 0; + GET_SHAPE_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, textSize); + + style = FONT_STYLE_PLAIN; + size = textSize; +} + +bool +_ListViewImpl::OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + FirePublicTouchEvent(touchinfo); + return false; +} + +bool +_ListViewImpl::OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + FirePublicTouchEvent(touchinfo); + return false; +} + +bool +_ListViewImpl::OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + FirePublicTouchEvent(touchinfo); + return false; +} + +bool +_ListViewImpl::OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo) +{ + FirePublicTouchEvent(touchinfo); + return false; +} + +void +_ListViewImpl::FirePublicTouchEvent(const _TouchInfo& touchInfo) +{ + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + TouchEventInfo publicTouchInfo; + + _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo); + SysTryReturnVoidResult(NID_UI, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + publicTouchInfo.Construct(*pEventArg); + + _Control* pDraggedControl = pTouchManager->GetTouchControlSource(); + + IEnumeratorT* pEnumerator = GetTouchEventListener()->GetEnumeratorN(); + if (pEnumerator) + { + while (pEnumerator->MoveNext() == E_SUCCESS) + { + IEventListener* pListener = null; + pEnumerator->GetCurrent(pListener); + + ITouchEventListener* pTouchEventListener = dynamic_cast (pListener); + if (pTouchEventListener) + { + FirePublicListener(*pTouchEventListener, publicTouchInfo); + + if (touchInfo.GetTouchStatus() == _TOUCH_RELEASED) + { + if (pDraggedControl == null) //if exist dragged control, don't send focus event + { + FireFocusListener(*pTouchEventListener, publicTouchInfo); + } + } + else if (touchInfo.GetTouchStatus() == _TOUCH_MOVED) + { + FireFocusListener(*pTouchEventListener, publicTouchInfo); + } + } + } + + delete pEnumerator; + } + + delete pEventArg; +} + +void +_ListViewImpl::FirePublicListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo) +{ + switch (touchEventInfo.GetTouchStatus()) + { + case TOUCH_PRESSED: + listener.OnTouchPressed(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_LONG_PRESSED: + listener.OnTouchLongPressed(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_RELEASED: + listener.OnTouchReleased(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_MOVED: + listener.OnTouchMoved(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_DOUBLE_PRESSED: + listener.OnTouchDoublePressed(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_FOCUS_IN: + listener.OnTouchFocusIn(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_FOCUS_OUT: + listener.OnTouchFocusOut(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + case TOUCH_CANCELED: + listener.OnTouchCanceled(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + break; + default: + break; + } +} + +void +_ListViewImpl::FireFocusListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo) +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + Point screenPoint(pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).x, + pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).y); + + _Control* pTouchedControl = pControlManager->GetTopmostTouchedControl(screenPoint); + SysTryReturnVoidResult(NID_UI, pTouchedControl, E_INVALID_CONDITION, "[E_INVALID_CONDITION] pTouchedControl is null."); + + if (pTouchManager->GetFocusedControlSource() != pTouchedControl) + { + if (&(GetCore()) != pTouchedControl) + { + if (pTouchManager->GetFocusedControlSource() == &(GetCore())) + { + listener.OnTouchFocusOut(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + } + } + else + { + listener.OnTouchFocusIn(GetPublic(), touchEventInfo.GetCurrentPosition(), touchEventInfo); + } + + pTouchManager->SetFocusedControlSource(*pTouchedControl); + } +} + +_TouchEventArg* +_ListViewImpl::GetTouchEventArgN(const _TouchInfo& touchInfo) +{ + Point startPoint; + + _TouchEventArg* pEventArg = new (std::nothrow) _TouchEventArg(GetPublic(), touchInfo.GetTouchStatus()); + SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + SysTryCatch(NID_UI, pTouchManager, , E_SYSTEM, "[E_SYSTEM] System error occurred."); + + startPoint.SetPosition(pTouchManager->GetStartPoint(touchInfo.GetPointId()).x - GetCore().GetAbsoluteBounds().x, + pTouchManager->GetStartPoint(touchInfo.GetPointId()).y - GetCore().GetAbsoluteBounds().y); + + pEventArg->SetTouchPosition(touchInfo.GetPointId(), startPoint.x, startPoint.y, + touchInfo.GetCurrentPosition().x, touchInfo.GetCurrentPosition().y); + + // need to flick distance setting + + return pEventArg; + +CATCH: + delete pEventArg; + return null; +} + +class _ListViewMaker + : public _UiBuilderControlMaker +{ +public: + _ListViewMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + + virtual ~_ListViewMaker(){}; + + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _ListViewMaker* pListViewMaker = new (std::nothrow) _ListViewMaker(uibuilder); + return pListViewMaker; + }; + +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + ListView* pListView = null; + Rectangle rect; + String elementString; + + bool hasItemDivider = true; + bool hasFastScroll = false; + int opacity = 100; + bool isSweepEnabled = false; + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pListView = new (std::nothrow) ListView(); + if (pListView == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + //Construct + if (pControl->GetElement(L"itemDivider", elementString)) + { + if (elementString.Equals(L"true", false)) + { + hasItemDivider = true; + } + else + { + hasItemDivider = false; + } + } + + if (pControl->GetElement(L"fastScroll", elementString)) + { + if (elementString.Equals(L"true", false)) + { + hasFastScroll = true; + } + else + { + hasFastScroll = false; + } + } + + r = pListView->Construct(rect, hasItemDivider, hasFastScroll); + if (r != E_SUCCESS) + { + delete pListView; + pListView = null; + + return null; + } + + // Set BackgroundsBitmap + if (pControl->GetElement("backgroundBitmapPath", elementString)) + { + Bitmap* pBackgroundBitmap = null; + pBackgroundBitmap = LoadBitmapN(elementString); + if (pBackgroundBitmap != null) + { + pListView->SetBackgroundBitmap(pBackgroundBitmap); + delete pBackgroundBitmap; + pBackgroundBitmap = null; + } + } + + // Set Empty List + if (pControl->GetElement(L"textOfEmptyList", elementString)) + { + pListView->SetTextOfEmptyList(elementString); + } + + if (pControl->GetElement(L"colorOfEmptyListText", elementString)) + { + ConvertStringToColor(elementString, color); + pListView->SetTextColorOfEmptyList(color); + } + + if (pControl->GetElement(L"bitmapPathOfEmptyList", elementString)) + { + Bitmap* pBackgroundBitmap = null; + pBackgroundBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565); + if (pBackgroundBitmap != null) + { + pListView->SetBitmapOfEmptyList(pBackgroundBitmap); + + delete pBackgroundBitmap; + pBackgroundBitmap = null; + } + } + + if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pListView->SetBackgroundColor(color); + } + + if (pControl->GetElement(L"itemDividerColor", elementString)) + { + ConvertStringToColor(elementString, color); + pListView->SetItemDividerColor(color); + } + + if (pControl->GetElement(L"sweepEnabled", elementString)) + { + if (elementString.Equals(L"true", false)) + { + isSweepEnabled = true; + } + else + { + isSweepEnabled = false; + } + + pListView->SetSweepEnabled(isSweepEnabled); + } + + return pListView; + } + +private: +}; // _ListViewMaker + +_ListViewRegister::_ListViewRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"ListView", _ListViewMaker::GetInstance); +} + +_ListViewRegister::~_ListViewRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"ListView"); +} + +static _ListViewRegister ListViewRegisterToUIbuilder; +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_ListViewItem.cpp b/src/ui/controls/FUiCtrl_ListViewItem.cpp new file mode 100644 index 0000000..aea29ae --- /dev/null +++ b/src/ui/controls/FUiCtrl_ListViewItem.cpp @@ -0,0 +1,1940 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListViewItem.cpp + * @brief This is the implementation file for _ListViewItem class. + * + * This file contains the implementation of _ListViewItem class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityManager.h" +#include "FUi_ITouchLongPressGestureEventListener.h" +#include "FUi_ResourceManager.h" +#include "FUi_TouchLongPressGestureDetector.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_Label.h" +#include "FUiCtrl_ListViewContextItem.h" +#include "FUiCtrl_ListViewItem.h" +#include "FUiCtrl_Progress.h" +#include "FUiCtrl_UiListViewItemEvent.h" +#include "FUiCtrl_UiListViewItemEventArg.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ListViewItem::_ListViewItem(int itemHeight) + : _TableViewItem(itemHeight) + , __touchPressed(false) + , __selectedElementId(-1) + , __progressLeftMargin(0) + , __progressRightMargin(0) + , __pProgress(null) + , __descriptionTextShowState(false) + , __pDescriptionText(null) + , __pDivider(null) + , __selectionEabled(false) + , __fontStyle(0) + , __fontSize(0) + , __fontName(L"") + , __prevTouchPos(-1, -1) + , __pTextSlideTimer(null) + , __pLongPressedGesture(null) +{ + GET_COLOR_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_NORMAL, __descriptionTextColor); + + ___stateChangedInfo.selectionType = LISTVIEW_ITEM_SELECTED; + ___stateChangedInfo.elementId = -1; + ___stateChangedInfo.pUiLinkInfo = null; +} + +_ListViewItem::~_ListViewItem(void) +{ + DeleteAllElement(); + + delete ___stateChangedInfo.pUiLinkInfo; + ___stateChangedInfo.pUiLinkInfo = null; + + delete __pTextSlideTimer; + __pTextSlideTimer = null; + + if (__pLongPressedGesture != null) + { + RemoveGestureDetector(*__pLongPressedGesture); + + delete __pLongPressedGesture; + __pLongPressedGesture = null; + } + + if (__pProgress != null) + { + DetachChild(*__pProgress); + + delete __pProgress; + __pProgress = null; + } + + if (__pDescriptionText != null) + { + DetachChild(*__pDescriptionText); + + delete __pDescriptionText; + __pDescriptionText = null; + } + + if (__pDivider != null) + { + DetachChild(*__pDivider); + + delete __pDivider; + __pDivider = null; + } +} + +_ListViewItem* +_ListViewItem::CreateListViewItemN(int itemHeight) +{ + _ListViewItem* pItem = new (std::nothrow) _ListViewItem(itemHeight); + SysTryReturn(NID_UI_CTRL, (pItem != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pItem->AcquireHandle(); + + result r = pItem->Initialize(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r = E_SYSTEM, "[E_SYSTEM] Unable to create _ListViewItem"); + + return pItem; + +CATCH: + delete pItem; + + return null; +} + +void +_ListViewItem::SetListViewItemType(ListViewItemType type) +{ + __itemType = type; +} + +void +_ListViewItem::AddTouchLongPressGestureEventListener(_ITouchLongPressGestureEventListener& listener) +{ + if (__pLongPressedGesture == null) + { + __pLongPressedGesture = new (std::nothrow) _TouchLongPressGestureDetector(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pLongPressedGesture != null), E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + + __pLongPressedGesture->SetDuration(TOUCH_LONGPRESSED_EVENT_DURATION); + AddGestureDetector(*__pLongPressedGesture); + } + + result r = __pLongPressedGesture->AddGestureListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to add gesture listener.", GetErrorMessage(r)); +} + +void +_ListViewItem::RemoveTouchLongPressGestureEventListener(_ITouchLongPressGestureEventListener& listener) +{ + if (__pLongPressedGesture != null) + { + __pLongPressedGesture->RemoveGestureListener(listener); + } +} + +result +_ListViewItem::AddElement(Rectangle& rect, int elementId, const String& text, bool textSliding) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (HasElement(elementId) == false), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] This elementId already exists.")); + + // Convert String to TextObject + TextObject* pText = new (std::nothrow) TextObject(); + pText->Construct(); + + if (text.IsEmpty() == false) + { + TextSimple* pSimpleText = new (std::nothrow) TextSimple(const_cast (text.GetPointer()), text.GetLength()); + pText->AppendElement(*pSimpleText); + + pText->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); + pText->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + } + + // Make element object + _ListViewItemElement element; + memset(&element, 0, sizeof(_ListViewItemElement)); + + element.elementId = elementId; + element.elementType = LISTVIEW_ITEM_ELEMENT_TEXT; + element.bounds = rect; + + element.pTextElement = new (std::nothrow) _ListViewItemElementText(); + SysTryReturn(NID_UI_CTRL, (element.pTextElement != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(r)); + + element.pTextElement->pTextObject = pText; + element.pTextElement->textSlidingEnabled = textSliding; + + GET_SHAPE_CONFIG(LISTVIEW::ITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, element.pTextElement->textSize); + GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_NORMAL, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_NORMAL]); + GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_PRESSED, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_PRESSED]); + GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_HIGHLIGHTED, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_HIGHLIGHTED]); + + // Set Visual element for this element + _VisualElement* pVE = new (std::nothrow) _VisualElement(); + pVE->Construct(); + pVE->SetImplicitAnimationEnabled(false); + pVE->SetContentProvider(&__hitTestVEDelegator); + element.pTextElement->pVE = pVE; + + __elements.push_back(element); + + return r; +} + +result +_ListViewItem::AddElement(Rectangle& rect, int elementId, const EnrichedText* pEnrichedText, bool textSliding) +{ + SysTryReturn(NID_UI_CTRL, (HasElement(elementId) == false), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] This elementId already exists.")); + + SysTryReturn(NID_GRP, (pEnrichedText != null) && (_EnrichedTextImpl::GetInstance(*pEnrichedText) != null), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This _EnrichedText element is null."); + + // Set Text element + _EnrichedTextImpl* pCloneText = _EnrichedTextImpl::GetInstance(*pEnrichedText)->GetCloneN(); + SysTryReturn(NID_GRP, (pCloneText != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This _EnrichedText element can not clone."); + + TextObject* pText = pCloneText->GetTextObject(); + + // Make element object + _ListViewItemElement element; + memset(&element, 0, sizeof(_ListViewItemElement)); + + element.elementId = elementId; + element.elementType = LISTVIEW_ITEM_ELEMENT_TEXT; + element.bounds = rect; + + element.pTextElement = new (std::nothrow) _ListViewItemElementText(); + SysTryReturn(NID_UI_CTRL, (element.pTextElement != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", + GetErrorMessage(GetLastResult())); + + element.pTextElement->pTextObject = pText; + element.pTextElement->pEnrichedText = pCloneText; + element.pTextElement->textSlidingEnabled = textSliding; + + GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_NORMAL, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_NORMAL]); + GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_PRESSED, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_PRESSED]); + GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_HIGHLIGHTED, element.pTextElement->textColor[LISTVIEW_ITEM_STATUS_HIGHLIGHTED]); + + // Set Visual element for this element + _VisualElement* pVE = new (std::nothrow) _VisualElement(); + pVE->Construct(); + pVE->SetImplicitAnimationEnabled(false); + pVE->SetContentProvider(&__hitTestVEDelegator); + element.pTextElement->pVE = pVE; + + __elements.push_back(element); + + return E_SUCCESS; +} + +result +_ListViewItem::AddElement(Rectangle& rect, int elementId, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap) +{ + SysTryReturn(NID_UI_CTRL, (HasElement(elementId) == false), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] This elementId already exists.")); + + SysTryReturn(NID_GRP, (pNormalBitmap != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This Bitmap element is null."); + + _ListViewItemElement element; + _VisualElement* pVE = null; + Bitmap* pClonePressedBitmap = null; + Bitmap* pCloneHighlightedBitmap = null; + result r = E_SUCCESS; + + Bitmap* pCloneNormalBitmap = _BitmapImpl::CloneN(*pNormalBitmap); + SysTryReturn(NID_UI_CTRL, (pCloneNormalBitmap != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (pPressedBitmap != null) + { + pClonePressedBitmap = _BitmapImpl::CloneN(*pPressedBitmap); + SysTryCatch(NID_UI_CTRL, (pClonePressedBitmap != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + + if (pHighlightedBitmap != null) + { + pCloneHighlightedBitmap = _BitmapImpl::CloneN(*pHighlightedBitmap); + SysTryCatch(NID_UI_CTRL, (pCloneHighlightedBitmap != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + + // Make element object + memset(&element, 0, sizeof(_ListViewItemElement)); + + element.elementId = elementId; + element.elementType = LISTVIEW_ITEM_ELEMENT_BITMAP; + element.bounds = rect; + + element.pBitmapElement = new (std::nothrow) _ListViewItemElementBitmap(); + SysTryCatch(NID_UI_CTRL, (element.pBitmapElement != null), (r = GetLastResult()), r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + element.pBitmapElement->pBitmap[LISTVIEW_ITEM_STATUS_NORMAL] = pCloneNormalBitmap; + element.pBitmapElement->pBitmap[LISTVIEW_ITEM_STATUS_PRESSED] = pClonePressedBitmap; + element.pBitmapElement->pBitmap[LISTVIEW_ITEM_STATUS_HIGHLIGHTED] = pCloneHighlightedBitmap; + + pVE = new (std::nothrow) _VisualElement(); + pVE->Construct(); + pVE->SetImplicitAnimationEnabled(false); + pVE->SetContentProvider(&__hitTestVEDelegator); + element.pBitmapElement->pVE = pVE; + + __elements.push_back(element); + + return E_SUCCESS; + +CATCH: + delete pCloneNormalBitmap; + delete pClonePressedBitmap; + delete pCloneHighlightedBitmap; + + return r; +} + +result +_ListViewItem::AddElement(Rectangle& rect, int elementId, const _ICustomElement* pCustom) +{ + SysTryReturn(NID_UI_CTRL, (HasElement(elementId) == false), E_INVALID_ARG, E_INVALID_ARG, + ("[E_INVALID_ARG] This elementId already exists.")); + + SysTryReturn(NID_GRP, (pCustom != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This Custom element is null."); + + // Make element object + _ListViewItemElement element; + memset(&element, 0, sizeof(_ListViewItemElement)); + + element.elementId = elementId; + element.elementType = LISTVIEW_ITEM_ELEMENT_OBJ; + element.bounds = rect; + + element.pCustomElement = new (std::nothrow) _ListViewItemElementCustom(); + SysTryReturn(NID_UI_CTRL, (element.pCustomElement != null), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + element.pCustomElement->pCustom = const_cast<_ICustomElement*>(pCustom); + + _VisualElement* pVE = new (std::nothrow) _VisualElement(); + pVE->Construct(); + pVE->SetImplicitAnimationEnabled(false); + pVE->SetContentProvider(&__hitTestVEDelegator); + element.pCustomElement->pVE = pVE; + + if (pVE->GetParent() == null) + { + GetVisualElement()->AttachChild(*(pVE)); + pVE->SetShowState(true); + pVE->SetBounds(FloatRectangle(rect.x, rect.y, rect.width, rect.height)); + } + + __elements.push_back(element); + + return E_SUCCESS; +} + +bool +_ListViewItem::DeleteElement(int elementId) +{ + _LinkedList <_ListViewItemElement>::_Iterator iter; + + for (iter = __elements.begin(); iter != __elements.end(); iter++) + { + if (iter->elementId == elementId) + { + DeleteElement(&(*iter)); + __elements.erase(iter); + + return true; + } + } + + return false; +} + +void +_ListViewItem::DeleteAllElement(void) +{ + _LinkedList <_ListViewItemElement>::_Iterator iter; + + for (iter = __elements.begin(); iter != __elements.end(); iter++) + { + DeleteElement(&(*iter)); + } + + __elements.clear(); +} + +void +_ListViewItem::DeleteElement(_ListViewItemElement* pElement) +{ + if (pElement->pTextElement != null) + { + if (pElement->pTextElement->pEnrichedText != null) + { + (pElement->pTextElement->pEnrichedText)->RemoveAllTextElements(true); + + delete pElement->pTextElement->pEnrichedText; + pElement->pTextElement->pEnrichedText = null; + + pElement->pTextElement->pTextObject = null; + } + else + { + delete pElement->pTextElement->pTextObject; + pElement->pTextElement->pTextObject = null; + } + + if (pElement->pTextElement->pVE != null) + { + pElement->pTextElement->pVE->Destroy(); + pElement->pTextElement->pVE = null; + } + + if (pElement->pTextElement->pAccessibilityElement) + { + pElement->pTextElement->pAccessibilityElement->Activate(false); + pElement->pTextElement->pAccessibilityElement = null; + } + + delete pElement->pTextElement; + pElement->pTextElement = null; + } + + if (pElement->pBitmapElement != null) + { + for (int i = 0; i < LISTVIEW_ITEM_STATUS_MAX; i++) + { + delete pElement->pBitmapElement->pBitmap[i]; + pElement->pBitmapElement->pBitmap[i] = null; + } + + if (pElement->pBitmapElement->pVE != null) + { + pElement->pBitmapElement->pVE->Destroy(); + pElement->pBitmapElement->pVE = null; + } + + delete pElement->pBitmapElement; + pElement->pBitmapElement = null; + } + + if (pElement->pCustomElement) + { + delete pElement->pCustomElement->pCustom; + pElement->pCustomElement->pCustom = null; + + if (pElement->pCustomElement->pVE != null) + { + pElement->pCustomElement->pVE->Destroy(); + pElement->pCustomElement->pVE = null; + } + + delete pElement->pCustomElement; + pElement->pCustomElement = null; + } +} + +bool +_ListViewItem::HasElement(int elementId) +{ + _ListViewItemElement* pElement = GetElement(elementId); + + return (pElement != null); +} + +bool +_ListViewItem::RefreshElement(int elementId) +{ + _ListViewItemElement* pElement = GetElement(elementId); + + if (pElement != null) + { + DrawElement(pElement); + } + + return (pElement != null); +} + +void +_ListViewItem::SetLastStateChangedInfo(void) +{ + ClearLastStateChangedInfo(); + + int elementId = GetElementIdFromCurrentTouchPosition(); + _ListViewItemElement* pElement = GetElement(elementId); + + if ((pElement != null) && (__itemType == LISTVIEW_ITEM_TYPE_CUSTOM)) + { + _ListViewItemUiLinkInfo* pInfo = null; + int cutlinkTextTouchedIndex = -1; + + if (IsCutlinkTextSelected(__prevTouchPos, &cutlinkTextTouchedIndex, &pInfo)) + { + if ((GetItemStyle() == TABLE_VIEW_ANNEX_STYLE_DETAILED) + && (pElement->actionElement == true) && (pElement->selectionEnabled == false)) + { + elementId = -1; + } + + if (cutlinkTextTouchedIndex >= 0) + { + ___stateChangedInfo.selectionType = LISTVIEW_ITEM_UILINK_SELECTED; + ___stateChangedInfo.elementId = elementId; + ___stateChangedInfo.pUiLinkInfo = pInfo; + } + else + { + ___stateChangedInfo.selectionType = LISTVIEW_ITEM_ELEMENT_SELECTED; + ___stateChangedInfo.elementId = elementId; + } + } + else + { + if ((GetItemStyle() == TABLE_VIEW_ANNEX_STYLE_DETAILED) + && (pElement->actionElement == true) && (pElement->selectionEnabled == false)) + { + elementId = -1; + } + + ___stateChangedInfo.selectionType = LISTVIEW_ITEM_ELEMENT_SELECTED; + ___stateChangedInfo.elementId = elementId; + } + } + else + { + ___stateChangedInfo.selectionType = LISTVIEW_ITEM_ELEMENT_SELECTED; + ___stateChangedInfo.elementId = -1; + } +} + +bool +_ListViewItem::GetLastStateChangedInfo(_ListViewItemStateChangedInfo& changedInfo) const +{ + changedInfo = ___stateChangedInfo; + + return (___stateChangedInfo.selectionType != LISTVIEW_ITEM_SELECTED); +} + +void +_ListViewItem::ClearLastStateChangedInfo(void) +{ + delete ___stateChangedInfo.pUiLinkInfo; + + ___stateChangedInfo.selectionType = LISTVIEW_ITEM_SELECTED; + ___stateChangedInfo.elementId = -1; + ___stateChangedInfo.pUiLinkInfo = null; +} + +int +_ListViewItem::GetElementIdFromPosition(const Point& position) const +{ + _LinkedList <_ListViewItemElement>::_ReverseIterator reverseIter; + + for (reverseIter = __elements.rbegin(); reverseIter != __elements.rend(); reverseIter++) + { + if ((*reverseIter).bounds.Contains(position)) + { + return (*reverseIter).elementId; + } + } + + return -1; +} + +int +_ListViewItem::GetElementIdFromCurrentTouchPosition(void) const +{ + return GetElementIdFromPosition(__prevTouchPos); +} + +_ListViewItemElement* +_ListViewItem::GetElement(int elementId) const +{ + _LinkedList <_ListViewItemElement>::_Iterator iter; + + for (iter = __elements.begin(); iter != __elements.end(); iter++) + { + if (iter->elementId == elementId) + { + return &(*iter); + } + } + + return null; +} + +ListViewItemElementType +_ListViewItem::GetElementType(int elementId) const +{ + _ListViewItemElement* pElement = GetElement(elementId); + + return ((pElement != null) ? pElement->elementType : LISTVIEW_ITEM_ELEMENT_INVALID); +} + +TextObject* +_ListViewItem::GetTextObjectInElement(int elementId) const +{ + _ListViewItemElementText* pElement = GetElementText(elementId); + + return ((pElement != null) ? pElement->pTextObject : null); +} + +_ListViewItemElementText* +_ListViewItem::GetElementText(int elementId) const +{ + _ListViewItemElement* pElement = GetElement(elementId); + + if ((pElement != null) && (pElement->elementType == LISTVIEW_ITEM_ELEMENT_TEXT) + && (pElement->pTextElement->pTextObject != null)) + { + return pElement->pTextElement; + } + + return null; +} + +_ListViewItemElementBitmap* +_ListViewItem::GetElementBitmap(int elementId) const +{ + _ListViewItemElement* pElement = GetElement(elementId); + + if ((pElement != null) && (pElement->elementType == LISTVIEW_ITEM_ELEMENT_BITMAP)) + { + return pElement->pBitmapElement; + } + + return null; +} + +bool +_ListViewItem::SetElementSelectionEnabled(int elementId, bool enable) +{ + _ListViewItemElement* pElement = GetElement(elementId); + + if (pElement == null) + { + return false; + } + + pElement->actionElement = true; + pElement->selectionEnabled = enable; + + return true; +} + +bool +_ListViewItem::GetElementSelectionEnabled(int elementId, bool& enable) +{ + _ListViewItemElement* pElement = GetElement(elementId); + + if ((pElement == null) || (pElement->actionElement == false)) + { + return false; + } + + enable = pElement->selectionEnabled; + + return true; +} + +bool +_ListViewItem::SetTextCutlinkMask(int elementId, unsigned long mask) +{ + _ListViewItemElementText* pElement = GetElementText(elementId); + + if (pElement == null) + { + return false; + } + + pElement->cutlinkMaskType = mask; + + return true; +} + +bool +_ListViewItem::SetTextCutlinkViewMode(int elementId, bool cutlinkViewMode, bool cutlinkParseEnable) +{ + _ListViewItemElementText* pElement = GetElementText(elementId); + + if (pElement == null) + { + return false; + } + + pElement->cutlinkViewModeEnabled = cutlinkViewMode; + pElement->cutlinkParseEnabled = cutlinkParseEnable; + pElement->cutlinkMaskType = LINK_TYPE_MAX; + + return true; +} + +bool +_ListViewItem::SetTextAlignment(int elementId, TextObjectAlignment textAlignment) +{ + TextObject* pTextObject = GetTextObjectInElement(elementId); + + if (pTextObject == null) + { + return false; + } + + TextObjectAlignment originAlign = pTextObject->GetAlignment(); + + // reset original alignment + if ((0x0007 & textAlignment) != 0x0000) // TextHorizontalAlignment + { + originAlign &= 0x0700; + } + else if ((0x0700 & textAlignment) != 0x0000) // TextVerticalAlignment + { + originAlign &= 0x0007; + } + + pTextObject->SetAlignment(originAlign | textAlignment); + + return true; +} + +bool +_ListViewItem::GetTextAlignment(int elementId, TextObjectAlignment& textAlignment) const +{ + TextObject* pTextObject = GetTextObjectInElement(elementId); + + if (pTextObject == null) + { + return false; + } + + textAlignment = pTextObject->GetAlignment(); + + return true; +} + +bool +_ListViewItem::SetTextWrapType(int elementId, TextObjectWrapType wrapType) +{ + TextObject* pTextObject = GetTextObjectInElement(elementId); + + if (pTextObject == null) + { + return false; + } + + pTextObject->SetWrap(wrapType); + + return true; +} + +bool +_ListViewItem::SetTextSize(int elementId, int textSize) +{ + _ListViewItemElementText* pElement = GetElementText(elementId); + + if ((pElement != null) && (textSize > 0)) + { + pElement->textSize = textSize; + + return true; + } + + return false; +} + +bool +_ListViewItem::SetTextColor(int elementId, Color textColor, ListViewItemDrawingStatus status) +{ + _ListViewItemElementText* pElement = GetElementText(elementId); + + if (pElement == null) + { + return false; + } + + pElement->textColor[status] = textColor; + + return true; +} + +bool +_ListViewItem::GetTextColor(int elementId, Color& textColor, ListViewItemDrawingStatus status) const +{ + _ListViewItemElementText* pElement = GetElementText(elementId); + + if (pElement == null) + { + return false; + } + + textColor = pElement->textColor[status]; + + return true; +} + +bool +_ListViewItem::SetProgressValue(int value) +{ + if ((value < 0) || (value > 100)) + { + if (__pProgress != null) + { + __pProgress->SetVisibleState(false); + } + + return false; + } + + if (__pProgress == null) + { + __pProgress = _Progress::CreateProgressN(); + SysTryReturn(NID_UI_CTRL, (__pProgress != null), false, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pProgress->SetRange(0, 100); + AttachChild(*__pProgress); + + AdjustProgressBounds(); + } + + __pProgress->SetValue(value); + __pProgress->SetVisibleState(true); + + return true; +} + +bool +_ListViewItem::SetProgressMargins(int leftMargin, int rightMargin) +{ + if ((leftMargin < 0) || (rightMargin < 0) || (GetBounds().width - leftMargin - rightMargin <= 0)) + { + return false; + } + + __progressLeftMargin = leftMargin; + __progressRightMargin = rightMargin; + + AdjustProgressBounds(); + + return true; +} + +void +_ListViewItem::AdjustProgressBounds(void) +{ + if (__pProgress != null) + { + Rectangle progressRect = GetBounds(); + int progressHeight = 0; + int bottomMargin = 0; + + // Calculate progress position + GET_SHAPE_CONFIG(SLIDER::BAR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, progressHeight); + GET_SHAPE_CONFIG(LISTVIEW::ITEM_PROGRESS_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, bottomMargin); + + progressRect.x = __progressLeftMargin; + progressRect.y = progressRect.height - progressHeight - bottomMargin; + progressRect.width = progressRect.width - __progressLeftMargin - __progressRightMargin; + progressRect.height = progressHeight; + + progressRect.y -= ((__descriptionTextShowState) ? GetDescriptionTextHeight() : 0); + + __pProgress->SetBounds(progressRect); + } +} + +bool +_ListViewItem::SetDescriptionText(const String& text) +{ + if (text.IsEmpty()) + { + if (__pDescriptionText != null) + { + DetachChild(*__pDescriptionText); + + delete __pDescriptionText; + __pDescriptionText = null; + } + + return true; + } + else + { + if (__pDescriptionText == null) + { + __pDescriptionText = _Label::CreateLabelN(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (__pDescriptionText != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pDescriptionText->SetVisibleState(false); + __pDescriptionText->SetMargin(0, 0); + __pDescriptionText->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + + SetAccessibilityElement(); + + AttachChild(*__pDescriptionText); + } + + Rectangle bounds = GetBounds(); + Rectangle textBounds; + int textSize = 0; + bool ret = true; + + GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, textBounds.x); + GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, textBounds.y); + GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, textSize); + + textBounds.width = bounds.width - (textBounds.x * 2); + + TextObject* pText = new (std::nothrow) TextObject(); + SysTryReturn(NID_UI_CTRL, (pText != null), false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pText->Construct(); + + TextSimple* pSimpleText = new (std::nothrow) TextSimple((const_cast(text.GetPointer())), text.GetLength()); + SysTryCatch(NID_UI_CTRL, (pSimpleText != null), (ret = false), E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pText->AppendElement(*pSimpleText); + pText->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_TOP); + pText->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + pText->SetFont(GetFont(FONT_STYLE_PLAIN, textSize), 0, pText->GetTextLength()); + pText->SetBounds(Rectangle(0, 0, textBounds.width, 1)); + pText->Compose(); + + textBounds.height = pText->GetTotalHeight(); + + __pDescriptionText->SetBounds(Rectangle(textBounds.x, bounds.height + textBounds.y, textBounds.width, textBounds.height)); + __pDescriptionText->SetBackgroundColor(Color(0, 0, 0, 0)); + __pDescriptionText->SetTextColor(__descriptionTextColor); + __pDescriptionText->SetTextConfig(textSize, LABEL_TEXT_STYLE_NORMAL); + __pDescriptionText->SetText(text); + +CATCH: + delete pText; + + return ret; + } +} + +void +_ListViewItem::SetDescriptionTextColor(const Color& color) +{ + __descriptionTextColor = color; +} + +int +_ListViewItem::GetDescriptionTextHeight(void) +{ + if (__pDescriptionText != null) + { + int margin = 0; + GET_SHAPE_CONFIG(LISTVIEW::ITEM_DESCRIPTION_TEXT_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, margin); + + return ((margin * 2) + __pDescriptionText->GetBounds().height); + } + + return 0; +} + +void +_ListViewItem::SetDescriptionTextShowState(bool show) +{ + if (__descriptionTextShowState != show) + { + __descriptionTextShowState = show; + + if (__pDescriptionText != null) + { + __pDescriptionText->SetVisibleState(__descriptionTextShowState); + + Dimension itemDimension = GetSize(); + int descriptionTextHeight = GetDescriptionTextHeight(); + + itemDimension.height += ((__descriptionTextShowState) ? (descriptionTextHeight) : (-descriptionTextHeight)); + + // Set position & item height + SetItemCustomHeight((__descriptionTextShowState ? (itemDimension.height - descriptionTextHeight) : 0)); + SetItemHeight(itemDimension.height); + + SetSize(itemDimension); + } + } +} + +void +_ListViewItem::SetContextItemEventListener(_IActionEventListener& listener) +{ + __pContextItemEventListener = &listener; +} + +void +_ListViewItem::SetContextItemActivationState(bool activate) +{ + _ListViewContextItem* pContextItem = static_cast<_ListViewContextItem*>(GetContextItem()); + + if ((pContextItem != null) && (__pContextItemEventListener != null)) + { + if (activate) + { + pContextItem->AddContextItemEventListener(*__pContextItemEventListener); + } + else + { + pContextItem->RemoveContextItemEventListener(*__pContextItemEventListener); + } + } +} + +bool +_ListViewItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + _TableViewItem::OnTouchPressed(source, touchinfo); + + if ((&source != this) && (source.GetParent() != this)) + { + return false; + } + + ClearLastStateChangedInfo(); + StopTextSlideTimer(); + + Point pos = touchinfo.GetCurrentPosition(); + __prevTouchPos.SetPosition(pos.x, pos.y); + + __selectedElementId = GetElementIdFromPosition(pos); + + _ListViewItemElement* pElement = GetElement(__selectedElementId); + + if (pElement != null) + { + if ((pElement->actionElement) && (pElement->selectionEnabled)) + { + __selectionEabledBgColor = GetItemBackgroundColor(LIST_ITEM_STATE_PRESSED); + SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, GetItemBackgroundColor(LIST_ITEM_STATE_NORMAL)); + + __selectionEabled = true; + } + + if (pElement->elementType == LISTVIEW_ITEM_ELEMENT_TEXT) + { + SetCutlinkTextFocus(pos); + + if (pElement->pTextElement->textSlidingEnabled) + { + pElement->pTextElement->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT); + pElement->pTextElement->pTextObject->Compose(); + + if (pElement->pTextElement->pTextObject->IsActionOn()) + { + StartTextSlideTimer(); + } + } + } + } + + __touchPressed = true; + + SetLastStateChangedInfo(); + Invalidate(); + + return false; +} + +bool +_ListViewItem::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + _TableViewItem::OnTouchReleased(source, touchinfo); + + if ((&source != this) && (source.GetParent() != this)) + { + return false; + } + + ResetTextSlide(); + ResetCutlinkFocus(); + + if (__selectionEabled) + { + SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, __selectionEabledBgColor); + __selectionEabled = false; + } + + __selectedElementId = -1; + __touchPressed = false; + + Invalidate(); + + return false; +} + +bool +_ListViewItem::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + _TableViewItem::OnTouchMoved(source, touchinfo); + + if (__touchPressed) + { + ClearLastStateChangedInfo(); + } + + ResetTextSlide(); + + __selectedElementId = -1; + __touchPressed = false; + + Invalidate(); + + return false; +} + +bool +_ListViewItem::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + _TableViewItem::OnTouchCanceled(source, touchinfo); + + ResetTextSlide(); + + if (__selectionEabled) + { + SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, __selectionEabledBgColor); + __selectionEabled = false; + } + + Invalidate(); + + return false; +} + +void +_ListViewItem::OnDraw(void) +{ + _TableViewItem::OnDraw(); + + DrawElements(); + DrawDivider(); +} + +void +_ListViewItem::OnBoundsChanged(void) +{ + _TableViewItem::OnBoundsChanged(); + + _ListViewContextItem* pContextItem = static_cast<_ListViewContextItem*>(GetContextItem()); + + if (pContextItem != null) + { + Rectangle bounds = GetBounds(); + pContextItem->AdjustItemBounds(bounds); + } +} + +ListViewItemDrawingStatus +_ListViewItem::GetItemDrawingStatus(void) +{ + TableViewItemDrawingStatus parentStatus = GetDrawingStatus(); + ListViewItemDrawingStatus status; + + switch (parentStatus) + { + case TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED: + status = LISTVIEW_ITEM_STATUS_PRESSED; + break; + + case TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED: + status = LISTVIEW_ITEM_STATUS_HIGHLIGHTED; + break; + + default: + status = LISTVIEW_ITEM_STATUS_NORMAL; + break; + } + + return status; +} + +void +_ListViewItem::DrawElement(_ListViewItemElement* pElement) +{ + // Get Current TableViewItem drawing status + ListViewItemDrawingStatus status = GetItemDrawingStatus(); + Rectangle elementRect; + + // Check element selection enabled + if (status != LISTVIEW_ITEM_STATUS_NORMAL) + { + if (__selectedElementId == -1) + { + if ((pElement->actionElement) && (pElement->selectionEnabled)) + { + status = LISTVIEW_ITEM_STATUS_NORMAL; + } + } + else if (__selectedElementId == pElement->elementId) + { + if ((pElement->actionElement) && (pElement->selectionEnabled)) + { + status = LISTVIEW_ITEM_STATUS_NORMAL; + } + } + else + { + bool enabled = false; + + if (GetElementSelectionEnabled(__selectedElementId, enabled) && enabled) + { + status = LISTVIEW_ITEM_STATUS_NORMAL; + } + } + } + + Canvas* pCanvas = null; + + switch (pElement->elementType) + { + case LISTVIEW_ITEM_ELEMENT_TEXT: + DrawText(pElement->bounds, status, pElement->pTextElement); + break; + + case LISTVIEW_ITEM_ELEMENT_BITMAP: + DrawBitmap(pElement->bounds, status, pElement->pBitmapElement); + break; + + case LISTVIEW_ITEM_ELEMENT_OBJ: + pCanvas = pElement->pCustomElement->pVE->GetCanvasN(); + + if (pCanvas != null) + { + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + elementRect.SetBounds(0, 0, pElement->bounds.width, pElement->bounds.height); + + pElement->pCustomElement->pCustom->DrawElement(pCanvas, elementRect, status); + } + break; + + default: + break; + } + + delete pCanvas; +} + +void +_ListViewItem::DrawElements(void) +{ + _LinkedList <_ListViewItemElement>::_Iterator iter; + + for (iter = __elements.begin(); iter != __elements.end(); iter++) + { + DrawElement(&(*iter)); + } +} + +bool +_ListViewItem::DrawText(Rectangle& rect, ListViewItemDrawingStatus status, _ListViewItemElementText* pText) +{ + SysTryReturn(NID_UI_CTRL, (pText != null), false, E_INVALID_ARG, "[E_INVALID_ARG] This Text element is null."); + + Rectangle bounds(rect.x, rect.y, rect.width, rect.height); + + if (pText->pVE->GetParent() == null) + { + GetVisualElement()->AttachChild(*(pText->pVE)); + pText->pVE->SetShowState(true); + } + + if (pText->textSize > 0) + { + pText->pTextObject->SetFont(GetFont(FONT_STYLE_PLAIN, pText->textSize), 0, pText->pTextObject->GetTextLength()); + } + + // Calculate Text element bounds + if (pText->pEnrichedText == null) + { + Dimension textDimension = pText->pTextObject->GetTextExtent(0, pText->pTextObject->GetTextLength()); + TextObjectAlignment textAlign = pText->pTextObject->GetAlignment(); + + if (__itemType == LISTVIEW_ITEM_TYPE_CUSTOM) + { + if (textDimension.width < bounds.width) + { + bounds.width = textDimension.width; + + if ((0x0007 & textAlign) == TEXT_OBJECT_ALIGNMENT_CENTER) + { + bounds.x = rect.x + ((rect.width - bounds.width) / 2); + } + else if ((0x0007 & textAlign) == TEXT_OBJECT_ALIGNMENT_RIGHT) + { + bounds.x = rect.x + (rect.width - bounds.width); + } + } + if (textDimension.height < bounds.height) + { + bounds.height = textDimension.height; + + if ((0x0700 & textAlign) == TEXT_OBJECT_ALIGNMENT_MIDDLE) + { + bounds.y = rect.y + ((rect.height - bounds.height) / 2); + } + else if ((0x0700 & textAlign) == TEXT_OBJECT_ALIGNMENT_BOTTOM) + { + bounds.y = rect.y + (rect.height - bounds.height); + } + } + } + else + { + if ((bounds.width != textDimension.width) || (bounds.height != textDimension.height)) + { + int itemWidth = GetBounds().width; + + bounds.x = rect.x; + bounds.y = rect.y + ((rect.height - textDimension.height) / 2); + bounds.width = ((itemWidth > bounds.x + textDimension.width) ? textDimension.width : (itemWidth - bounds.x)); + bounds.height = textDimension.height; + + rect = bounds; + } + } + } + + pText->pVE->SetBounds(FloatRectangle(bounds.x, bounds.y, bounds.width, bounds.height)); + + // Check to EnrichedText contains Cutlink + if ((pText->cutlinkViewModeEnabled == true) && (pText->cutlinkParseEnabled == true) + && (pText->pTextObject->GetTotalCutLinkElementCount() <= 0)) + { + if (ParseCutlinkText(pText) == true) + { + pText->pTextObject->SetCutLinkViewMode(true); + } + } + else if (pText->pEnrichedText == null) + { + if (IsItemEnabled() == true) + { + pText->pTextObject->SetForegroundColor(pText->textColor[status], 0, pText->pTextObject->GetTextLength()); + } + else + { + Color disableTextColor; + GET_COLOR_CONFIG(LISTVIEW::ITEM_TEXT_DISABLED, disableTextColor); + + pText->pTextObject->SetForegroundColor(disableTextColor, 0, pText->pTextObject->GetTextLength()); + } + } + + pText->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + pText->pTextObject->SetBounds(Rectangle(0, 0, bounds.width, bounds.height)); + + Canvas* pCanvas = pText->pVE->GetCanvasN(); + SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + pText->pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + + delete pCanvas; + + return true; +} + +bool +_ListViewItem::DrawBitmap(Rectangle& rect, ListViewItemDrawingStatus status, _ListViewItemElementBitmap* pBitmap) +{ + SysTryReturn(NID_UI_CTRL, (pBitmap != null), false, E_INVALID_ARG, "[E_INVALID_ARG] This Bitmap element is null."); + + Bitmap* pDrawBitmap = pBitmap->pBitmap[status]; + if ((pDrawBitmap == null) && (status != LISTVIEW_ITEM_STATUS_NORMAL)) + { + pDrawBitmap = pBitmap->pBitmap[LISTVIEW_ITEM_STATUS_NORMAL]; + } + + SysTryReturn(NID_UI_CTRL, (pDrawBitmap != null), false, E_INVALID_ARG, "[E_INVALID_ARG] This Bitmap element is null."); + + if (pBitmap->pVE->GetParent() == null) + { + GetVisualElement()->AttachChild(*(pBitmap->pVE)); + pBitmap->pVE->SetShowState(true); + } + + pBitmap->pVE->SetBounds(FloatRectangle(rect.x, rect.y, rect.width, rect.height)); + + Canvas* pCanvas = pBitmap->pVE->GetCanvasN(); + SysTryReturn(NID_UI_CTRL, (pCanvas != null), false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + if (pDrawBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, rect.width, rect.height), *pDrawBitmap); + } + else + { + pCanvas->DrawBitmap(Rectangle(0, 0, rect.width, rect.height), *pDrawBitmap); + } + + delete pCanvas; + + return true; +} + +void +_ListViewItem::DrawDivider(void) +{ + if ((__itemType == LISTVIEW_ITEM_TYPE_GROUP) && (GetItemBackgroundBitmap(LIST_ITEM_STATE_NORMAL) == null)) + { + int lineHeight = 0; + int lineLeftMargin = 0; + int lineBottomMargin = 0; + int lineTopMargin = 0; + GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight); + GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin); + GET_SHAPE_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineBottomMargin); + + Rectangle bounds = GetBounds(); + _ListViewItemElementText* pElementText = GetElementText(LIST_ITEM_RESERVED_ID_3); + if ((pElementText != null) && (pElementText->pVE != null)) + { + FloatRectangle textBounds = pElementText->pVE->GetBounds(); + lineTopMargin = (int)(textBounds.y + textBounds.height); + } + else + { + lineTopMargin = bounds.height - lineBottomMargin; + } + + if (bounds.height <= lineTopMargin) + { + return; + } + + if (__pDivider == null) + { + __pDivider = _Label::CreateLabelN(); + SysTryReturnVoidResult(NID_UI_CTRL, __pDivider != null, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + AttachSystemChild(*__pDivider); + } + + Color underLineColor; + GET_COLOR_CONFIG(LISTVIEW::GROUPITEM_DIVIDER_NORMAL, underLineColor); + + __pDivider->SetBounds(Rectangle(lineLeftMargin, lineTopMargin, bounds.width - lineLeftMargin * 2, lineHeight)); + __pDivider->SetBackgroundColor(underLineColor); + __pDivider->Invalidate(); + } +} + +void +_ListViewItem::StartTextSlideTimer(void) +{ + result r = E_SUCCESS; + + if (__pTextSlideTimer == null) + { + __pTextSlideTimer = new (std::nothrow) Timer(); + + r = __pTextSlideTimer->Construct(*this); + SysTryCatch(NID_UI, (r == E_SUCCESS), ,E_SYSTEM, ("[E_SYSTEM] Timer cannot construct.")); + } + else + { + __pTextSlideTimer->Cancel(); + } + + r = __pTextSlideTimer->Start(TEXT_SLIDING_TIMER_DURATION); + SysTryCatch(NID_UI, (r == E_SUCCESS), , E_SYSTEM, ("[E_SYSTEM] Timer Start failed.")); + + return; + +CATCH: + StopTextSlideTimer(); +} + +void +_ListViewItem::StopTextSlideTimer(void) +{ + delete __pTextSlideTimer; + __pTextSlideTimer = null; +} + +bool +_ListViewItem::IsTextSlideTimerRunning(void) +{ + return (__pTextSlideTimer != null); +} + +void +_ListViewItem::OnTextSlideTimerExpired(void) +{ + if (__selectedElementId != -1) + { + _ListViewItemElement* pElement = GetElement(__selectedElementId); + + if ((pElement != null) && (pElement->pTextElement->pTextObject != null)) + { + TextObject* pTextObject = pElement->pTextElement->pTextObject; + + Canvas* pCanvas = (pElement->pTextElement->pVE)->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, (pCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + pTextObject->SetForegroundColor(pElement->pTextElement->textColor[LISTVIEW_ITEM_STATUS_PRESSED], 0, pTextObject->GetTextLength()); + pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT); + pTextObject->Compose(); + pTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas)); + + pCanvas->Show(pElement->bounds); + StartTextSlideTimer(); + + delete pCanvas; + pCanvas = null; + } + } +} + +void +_ListViewItem::ResetTextSlide(void) +{ + if (IsTextSlideTimerRunning()) + { + StopTextSlideTimer(); + + _ListViewItemElement* pElement = GetElement(__selectedElementId); + + if ((pElement != null) && (pElement->pTextElement->pTextObject != null)) + { + pElement->pTextElement->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + pElement->pTextElement->pTextObject->SetForegroundColor(pElement->pTextElement->textColor[LISTVIEW_ITEM_STATUS_NORMAL], + 0, pElement->pTextElement->pTextObject->GetTextLength()); + } + } +} + +void +_ListViewItem::OnTimerExpired(Timer& timer) +{ + _TableViewItem::OnTimerExpired(timer); + + if (&timer == __pTextSlideTimer) + { + OnTextSlideTimerExpired(); + } +} + +bool +_ListViewItem::ParseCutlinkText(_ListViewItemElementText* pElementText) +{ + if ((pElementText == null) || (pElementText->pEnrichedText == null)) + { + return false; + } + + TextObject* pTextObject = pElementText->pTextObject; + unsigned long cutlinkMaskType = pElementText->cutlinkMaskType; + TextLinkInfo* pTextLinkInfo = null; + TextLinkInfo* pNextLinkInfo = null; + int currentOffset = 0; + bool isChangingCutlink = false; + wchar_t* pCutlinkString = null; + bool ret = true; + + int strLength = pTextObject->GetTextLength(); + wchar_t* pStr = new (std::nothrow) wchar_t[strLength + 1]; + SysTryReturn(NID_UI, (pStr != null), false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient.")); + + pTextObject->GetText(pStr, strLength); + + TextCutLinkParser* pParser = new (std::nothrow) TextCutLinkParser(); + SysTryCatch(NID_UI, (pParser != null), (ret = false), E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient.")); + + pParser->SetCutLinkMask(cutlinkMaskType); + + pTextLinkInfo = pParser->Parse(pStr, strLength, 0); + SysTryCatch(NID_UI, (pTextLinkInfo != null), (ret = false), E_SYSTEM, ("[E_SYSTEM] TextLinkInfo is not valid.")); + + // remove all text element in _EnrichedTextImpl + pElementText->pEnrichedText->RemoveAllTextElements(true); + + while (pTextLinkInfo != null) + { + isChangingCutlink = false; + + switch (pTextLinkInfo->linkType) + { + case LINK_TYPE_URL: + if (cutlinkMaskType & LINK_TYPE_URL) + { + isChangingCutlink = true; + } + break; + + case LINK_TYPE_EMAIL: + if (cutlinkMaskType & LINK_TYPE_EMAIL) + { + isChangingCutlink = true; + } + break; + + case LINK_TYPE_TEL_NUM: + if (cutlinkMaskType & LINK_TYPE_TEL_NUM) + { + isChangingCutlink = true; + } + break; + + case LINK_TYPE_APPCONTROL: + if (cutlinkMaskType & LINK_TYPE_APPCONTROL) + { + isChangingCutlink = true; + } + break; + + case LINK_TYPE_MIME: + if (cutlinkMaskType & LINK_TYPE_MIME) + { + isChangingCutlink = true; + } + break; + + default: + break; + } + + pCutlinkString = new (std::nothrow) wchar_t[pTextLinkInfo->length + 1]; + + if (pCutlinkString == null) + { + while (pTextLinkInfo != null) + { + pNextLinkInfo = pTextLinkInfo->pNextLinkInfo; + delete pTextLinkInfo; + pTextLinkInfo = pNextLinkInfo; + } + SysTryCatch(NID_UI, (pTextLinkInfo != null), (ret = false), E_SYSTEM, ("[E_SYSTEM] TextLinkInfo is not valid.")); + } + + for (int i = 0; i < pTextLinkInfo->length; i++) + { + pCutlinkString[i] = pStr[pTextLinkInfo->srcOffset + i]; + } + + pCutlinkString[pTextLinkInfo->length] = null; + + if (currentOffset < pTextLinkInfo->srcOffset) + { + TextSimple* pSimpleText = new (std::nothrow) TextSimple(pStr + currentOffset, pTextLinkInfo->srcOffset - currentOffset); + pTextObject->AppendElement(*pSimpleText); + } + + if (isChangingCutlink == true) + { + TextCutLink* pTextElement = new (std::nothrow) TextCutLink(false, pTextLinkInfo->linkType, pStr + pTextLinkInfo->srcOffset, + pTextLinkInfo->length); + pTextElement->SetEditModeEnable(true); + pTextObject->AppendElement(*pTextElement); + } + else + { + TextSimple* pSimpleText = new (std::nothrow) TextSimple(pCutlinkString, pTextLinkInfo->length); + pTextObject->AppendElement(*pSimpleText); + } + + currentOffset = pTextLinkInfo->srcOffset + pTextLinkInfo->length; + + pNextLinkInfo = pTextLinkInfo->pNextLinkInfo; + delete pTextLinkInfo; + pTextLinkInfo = pNextLinkInfo; + + delete[] pCutlinkString; + pCutlinkString = null; + } + + if (strLength != currentOffset) + { + TextSimple* pSimpleText = new (std::nothrow) TextSimple(pStr + currentOffset, strLength - currentOffset); + pTextObject->AppendElement(*pSimpleText); + } + + //pTextObject->SetRange(0, pTextObject->GetLength()); + //pTextObject->NotifyTextChanged(0, pTextObject->GetLength()); + pTextObject->Compose(); + +CATCH: + delete pParser; + pParser = null; + + if (pStr != null) + { + delete[] pStr; + pStr = null; + } + + return ret; +} + +bool +_ListViewItem::IsCutlinkTextSelected(const Point& position, int* index, _ListViewItemUiLinkInfo** ppInfo) const +{ + int elementId = GetElementIdFromPosition(position); + _ListViewItemElementText* pElement = GetElementText(elementId); + + if ((pElement != null) && (pElement->pTextObject) && (pElement->cutlinkViewModeEnabled)) + { + TextObject* pTextObject = pElement->pTextObject; + Rectangle displayRect = pTextObject->GetBounds(); + int selectedIndex = pTextObject->GetCutLinkIndexFromPositionData(position.x - displayRect.x, position.y - displayRect.y); + + if (selectedIndex >= 0) + { + *index = selectedIndex; + TextCutLink* pCutLinkObject = dynamic_cast(pTextObject->GetCutLinkElementAtCutLinkElementIndex(selectedIndex)); + if (pCutLinkObject == null) + { + return false; + } + + String cutLinkString(pCutLinkObject->GetText()); + LinkType baseLinkType = pCutLinkObject->GetCutLinkType(); + + if (baseLinkType & pElement->cutlinkMaskType) + { + _ListViewItemUiLinkInfo* pUiLinkInfo = new (std::nothrow) _ListViewItemUiLinkInfo(); + + pUiLinkInfo->textInfo = cutLinkString; + pUiLinkInfo->linkType = baseLinkType; + pUiLinkInfo->linkInfo = cutLinkString; + + *ppInfo = pUiLinkInfo; + } + } + + return true; + } + + return false; +} + +bool +_ListViewItem::SetCutlinkTextFocus(const Point& position) +{ + int elementId = GetElementIdFromPosition(position); + _ListViewItemElementText* pElement = GetElementText(elementId); + + if ((pElement != null) && (pElement->pTextObject != null) && (pElement->cutlinkViewModeEnabled)) + { + TextObject* pTextObject = pElement->pTextObject; + Rectangle displayRect = pTextObject->GetBounds(); + + int index = pTextObject->GetCutLinkIndexFromPositionData(position.x - displayRect.x, position.y - displayRect.y); + + if (index >= 0) + { + pTextObject->ChangeCutLinkState(index, true); + return true; + } + } + + return false; +} + +bool +_ListViewItem::ResetCutlinkFocus(void) +{ + _LinkedList <_ListViewItemElement>::_Iterator iter; + + for (iter = __elements.begin(); iter != __elements.end(); iter++) + { + if ((iter->elementType == LISTVIEW_ITEM_ELEMENT_TEXT) && (iter->pTextElement->pTextObject)) + { + iter->pTextElement->pTextObject->ResetAllCutLinkElementsState(); + } + } + + return true; +} + +Font* +_ListViewItem::GetFont(unsigned long fontStyle, int fontSize) +{ + __fontStyle = fontStyle; + __fontSize = fontSize; + + return GetFallbackFont(); +} + +void +_ListViewItem::OnFontChanged(Font* pFont) +{ + __fontName = _Control::GetFont(); + + if (__pDescriptionText != null) + { + __pDescriptionText->SetFont(__fontName); + } + + if (GetContextItem() != null) + { + GetContextItem()->SetFont(__fontName); + } +} + +void +_ListViewItem::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = __fontStyle; + size = __fontSize; +} + +void +_ListViewItem::OnAncestorEnableStateChanged(const _Control& control) +{ + _LinkedList <_ListViewItemElement>::_Iterator iter; + + for (iter = __elements.begin(); iter != __elements.end(); iter++) + { + if (iter->elementType == LISTVIEW_ITEM_ELEMENT_TEXT) + { + DrawText(iter->bounds, GetItemDrawingStatus(), iter->pTextElement); + } + } +} + +bool +CompareAccessibilityElement(_ListViewItemElement* a, _ListViewItemElement* b) +{ + if (a->bounds.y == b->bounds.y) + { + return (a->bounds.x < b->bounds.x); + } + + return (a->bounds.y < b->bounds.y); +} + +void +_ListViewItem::SetAccessibilityElement(void) +{ + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if (pContainer) + { + pContainer->RemoveAllElement(); + + _LinkedList <_ListViewItemElement*> accessibilityElementList; + + _LinkedList <_ListViewItemElement>::_Iterator iter; + + for (iter = __elements.begin(); iter != __elements.end(); iter++) + { + if (iter->elementType == LISTVIEW_ITEM_ELEMENT_TEXT) + { + accessibilityElementList.push_back(&(*iter)); + } + } + + accessibilityElementList.sort(CompareAccessibilityElement); + + _LinkedList <_ListViewItemElement*>::_Iterator accessibilityIter; + _ListViewItemElement* pElement = null; + + for (accessibilityIter = accessibilityElementList.begin(); accessibilityIter != accessibilityElementList.end(); accessibilityIter++) + { + pElement = *accessibilityIter; + + int textLength = pElement->pTextElement->pTextObject->GetTextLength(); + + wchar_t* pAccessibilityText = new (std::nothrow) wchar_t[textLength + 1]; + SysTryReturnVoidResult(NID_UI_CTRL, (pAccessibilityText != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pElement->pTextElement->pTextObject->GetText(pAccessibilityText, textLength); + + pElement->pTextElement->pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, (pElement->pTextElement->pAccessibilityElement != null), E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pElement->pTextElement->pAccessibilityElement->SetBounds(pElement->bounds); + pElement->pTextElement->pAccessibilityElement->SetLabel(String(pAccessibilityText)); + pElement->pTextElement->pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_LIST); + pElement->pTextElement->pAccessibilityElement->SetName(L"ListViewItemText"); + + pContainer->AddElement(*(pElement->pTextElement->pAccessibilityElement)); + + delete[] pAccessibilityText; + } + + accessibilityElementList.clear(); + + if (__pDivider != null) + { + _AccessibilityContainer* pDividerContainer = __pDivider->GetAccessibilityContainer(); + if (pDividerContainer != null) + { + pDividerContainer->Activate(false); + } + } + } +} + +_ListViewItemHitTestVEDelegator::_ListViewItemHitTestVEDelegator(void) +{ +} + +_ListViewItemHitTestVEDelegator::~_ListViewItemHitTestVEDelegator(void) +{ +} + +HitTestResult +_ListViewItemHitTestVEDelegator::HitTest(VisualElement& target, const FloatPoint& point) +{ + return HIT_TEST_NOWHERE; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ListViewItemProviderAdaptor.cpp b/src/ui/controls/FUiCtrl_ListViewItemProviderAdaptor.cpp new file mode 100644 index 0000000..a1c5d30 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ListViewItemProviderAdaptor.cpp @@ -0,0 +1,329 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListViewItemProviderAdaptor.cpp + * @brief This is the implementation file for _ListViewItemProviderAdaptor class. + * + * This file contains the implementation of _ListViewItemProviderAdaptor class. + */ + +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_IListItemCommon.h" +#include "FUiCtrl_ListItemBaseImpl.h" +#include "FUiCtrl_ListViewContextItem.h" +#include "FUiCtrl_ListViewImpl.h" +#include "FUiCtrl_ListViewItem.h" +#include "FUiCtrl_ListViewItemProviderAdaptor.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +using namespace Tizen::Graphics; +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ListViewItemProviderAdaptor::_ListViewItemProviderAdaptor(const IListViewItemProvider& provider) + : __pListViewProvider(const_cast(&provider)) + , __pEventListener(null) + , __fontName(L"") + , __itemAverageHeight(0) + , __itemLoadedCount(0) + , __countOfAllItems(0) + , __pItemNeedsLazyDeletion(null) +{ +} + +_ListViewItemProviderAdaptor::~_ListViewItemProviderAdaptor(void) +{ + __descriptionTextShowItem.clear(); + + SetItemNeedsLazyDeletion(null); +} + +void +_ListViewItemProviderAdaptor::SetItemProvider(const IListViewItemProvider& provider) +{ + __pListViewProvider = const_cast(&provider); +} + +_IListItemCommon* +_ListViewItemProviderAdaptor::LoadItem(int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, (groupIndex == 0), null, E_INVALID_ARG, + "[E_INVALID_ARG] parameter not available."); + + _TableViewItem* pTableViewItem = null; + if (itemIndex == -1) + { + pTableViewItem = GetDefaultItem(); + pTableViewItem->SetAppInfo(null); + + return pTableViewItem; + } + + ListItemBase* pItemBase = __pListViewProvider->CreateItem(itemIndex, GetListWidth()); + + if (pItemBase == null) + { + pTableViewItem = GetDefaultItem(); + pTableViewItem->SetAppInfo(null); + + return pTableViewItem; + } + + _ListItemBaseImpl* pItemBaseImpl = _ListItemBaseImpl::GetInstance(*pItemBase); + SysAssert(pItemBaseImpl != null); + + // add ListViewItem event listener + pItemBaseImpl->AddListViewItemEventListener(*__pEventListener); + + _ListViewItem* pListViewItem = pItemBaseImpl->GetListViewItem(); + SysAssert(pListViewItem != null); + + pListViewItem->SetFont(__fontName); + pListViewItem->AddRef(); + pListViewItem->SetAppInfo(pItemBase); + pListViewItem->SetItemStyle(static_cast(pItemBaseImpl->GetListItemAnnexStyle())); + pListViewItem->SetItemWidth(GetListWidth()); + + if (IsDescriptionTextShown(itemIndex) == true) + { + pListViewItem->SetDescriptionTextShowState(true); + } + + if (__itemLoadedCount < __countOfAllItems) + { + __itemAverageHeight = (__itemAverageHeight * __itemLoadedCount + pListViewItem->GetItemHeight()) / (__itemLoadedCount + 1); + __itemLoadedCount++; + } + + return pListViewItem; +} + +result +_ListViewItemProviderAdaptor::UnloadItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, pListItem != null, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG]pListItem is invalid argument"); + + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(pListItem); + if (pListViewItem->GetParent() != null) + { + pListViewItem->GetParent()->DetachChild(*pListViewItem); + } + + // default item case + if (pListViewItem == GetDefaultItem()) + { + return E_SUCCESS; + } + + if (pListViewItem == __pItemNeedsLazyDeletion) + { + pListViewItem->AddRef(); + } + + if (pListViewItem->Release() != 0) + { + ListItemBase* pItemBase = static_cast(pListViewItem->GetAppInfo()); + + _ListItemBaseImpl* pItemBaseImpl = _ListItemBaseImpl::GetInstance(*pItemBase); + SysAssert(pItemBaseImpl != null); + + // add ListViewItem event listener + //pItemBaseImpl->RemoveListViewItemEventListener(*__pEventListener); + + if (__pListViewProvider->DeleteItem(itemIndex, pItemBase, GetListWidth()) == false) + { + delete pItemBase; + } + } + + return E_SUCCESS; +} + +result +_ListViewItemProviderAdaptor::DeleteItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, pListItem != null, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] pListItem is invalid argument."); + + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(pListItem); + if (pListViewItem->GetParent() != null) + { + pListViewItem->GetParent()->DetachChild(*pListViewItem); + } + + // default item case + if (pListViewItem == GetDefaultItem()) + { + return E_SUCCESS; + } + + if (pListViewItem == __pItemNeedsLazyDeletion) + { + pListViewItem->AddRef(); + } + + if (pListViewItem->Release() != 0) + { + ListItemBase* pItemBase = static_cast(pListViewItem->GetAppInfo()); + delete pItemBase; + } + + return E_SUCCESS; +} + +bool +_ListViewItemProviderAdaptor::UpdateItem(_IListItemCommon* pItem, int groupIndex, int itemIndex) +{ + _ListViewItem* pListViewItem = static_cast<_ListViewItem*>(pItem); + + if (pListViewItem != null) + { + pListViewItem->SetDescriptionTextShowState(IsDescriptionTextShown(itemIndex)); + } + + return true; +} + +int +_ListViewItemProviderAdaptor::GetItemCount(int groupIndex) const +{ + _ListViewItemProviderAdaptor* pItemProviderAdaptor = const_cast<_ListViewItemProviderAdaptor*>(this); + + pItemProviderAdaptor->__countOfAllItems = __pListViewProvider->GetItemCount(); + + return __countOfAllItems; +} + +int +_ListViewItemProviderAdaptor::GetGroupCount(void) const +{ + return 1; +} + +int +_ListViewItemProviderAdaptor::GetDefaultItemHeight(void) +{ + return __itemAverageHeight; +} + +int +_ListViewItemProviderAdaptor::GetDefaultGroupItemHeight(void) +{ + return 0; +} + +bool +_ListViewItemProviderAdaptor::SetDescriptionTextShowState(int itemIndex, bool show) +{ + int index = -1; + _LinkedList ::_Iterator theIter = __descriptionTextShowItem.begin(); + + while (theIter != __descriptionTextShowItem.end()) + { + index = (int) (*theIter); + + if (index == itemIndex) + { + if (show == false) + { + __descriptionTextShowItem.erase(theIter); + } + + return true; + } + else if (index > itemIndex) + { + if (show == true) + { + __descriptionTextShowItem.insert(theIter, itemIndex); + } + + return true; + } + + theIter++; + } + + if (show == true) + { + __descriptionTextShowItem.push_back(itemIndex); + } + + return true; +} + +bool +_ListViewItemProviderAdaptor::IsDescriptionTextShown(int itemIndex) const +{ + int index = -1; + _LinkedList ::_Iterator theIter = __descriptionTextShowItem.begin(); + + while (theIter != __descriptionTextShowItem.end()) + { + index = (int) (*theIter); + + if (index == itemIndex) + { + return true; + } + else if (index > itemIndex) + { + return false; + + } + + theIter++; + } + + return false; +} + +void +_ListViewItemProviderAdaptor::SetListViewItemEventListener(_IUiListViewItemEventListener& listener) +{ + __pEventListener = &listener; +} + +void +_ListViewItemProviderAdaptor::SetItemFont(const String& fontName) +{ + __fontName = fontName; +} + +void +_ListViewItemProviderAdaptor::SetItemNeedsLazyDeletion(_ListViewItem* pItem) +{ + if (__pItemNeedsLazyDeletion != pItem) + { + if (__pItemNeedsLazyDeletion != null) + { + __pItemNeedsLazyDeletion->Release(); + } + + __pItemNeedsLazyDeletion = pItem; + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ListViewModel.cpp b/src/ui/controls/FUiCtrl_ListViewModel.cpp new file mode 100644 index 0000000..06184ec --- /dev/null +++ b/src/ui/controls/FUiCtrl_ListViewModel.cpp @@ -0,0 +1,1750 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListViewModel.cpp + * @brief This is the implementation file for _ListViewModel class. + * + * This file contains the implementation of _ListViewModel class. + */ + +#include +#include "FUiCtrl_IListItemProviderAdaptor.h" +#include "FUiCtrl_IListItemCommon.h" +#include "FUiCtrl_ListViewModel.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ListViewModel::_ListViewModel(void) + : __pListProviderAdaptor(null) + , __pTemporaryItemBuffer(null) + , __countOfAllGroups(0) + , __countOfAllItems(0) + , __indexOfFocusedGroup(-1) + , __indexOfFocusedItem(-1) + , __sizeOfCachingItems(CACHE_SIZE) + , __overflowItemsRemovingEnabled(true) +{ + +} + +_ListViewModel::~_ListViewModel(void) +{ + if (__pTemporaryItemBuffer != null) + { + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + __pTemporaryItemBuffer->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + __pListProviderAdaptor->DeleteItem(__pTemporaryItemBuffer, temporaryGroupIndex, temporaryItemIndex); + __pTemporaryItemBuffer = null; + } + + if (__backupGroupNodes.empty() == false) + { + _ListViewGroupNode* pBackupedListGroupNode = null; + for (int i = 0; i < __backupGroupNodes.size(); i++) + { + pBackupedListGroupNode = __backupGroupNodes.at(i); + + delete pBackupedListGroupNode; + } + + __backupGroupNodes.clear(); + } + + DeleteAllGroupAndItem(); +} + +_IListItemProviderAdaptor* +_ListViewModel::GetItemProviderAdaptor(void) const +{ + return __pListProviderAdaptor; +} + +result +_ListViewModel::RegisterItemProviderAdaptor(const _IListItemProviderAdaptor* pProviderAdaptor) +{ + SysTryReturn(NID_UI_CTRL, pProviderAdaptor != null, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] pProviderAdaptor is null."); + + if (__pListProviderAdaptor != null) + { + RemoveAllItem(false); + } + + __pListProviderAdaptor = const_cast<_IListItemProviderAdaptor*>(pProviderAdaptor); + + return E_SUCCESS; +} + +result +_ListViewModel::SetGroupExpandState(int groupIndex, bool state) +{ + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pListGroupNode->__itemExpanded = state; + + return E_SUCCESS; +} + +bool +_ListViewModel::IsGroupExpanded(int groupIndex) const +{ + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, false, GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return pListGroupNode->__itemExpanded; +} + +_IListItemCommon* +_ListViewModel::GetItemFromTemporaryBuffer(int groupIndex, int itemIndex) +{ + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + if (__pTemporaryItemBuffer != null) + { + __pTemporaryItemBuffer->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + if (groupIndex == temporaryGroupIndex && itemIndex == temporaryItemIndex) + { + return __pTemporaryItemBuffer; + } + } + + _IListItemCommon* pItem = GetItemFromContainer(groupIndex, itemIndex); + + if (pItem == null) + { + __pListProviderAdaptor->UnloadItem(__pTemporaryItemBuffer, temporaryGroupIndex, temporaryItemIndex); + __pTemporaryItemBuffer = __pListProviderAdaptor->LoadItem(groupIndex, itemIndex); + if (__pTemporaryItemBuffer != null) + { + __pTemporaryItemBuffer->SetItemIndex(groupIndex, itemIndex); + } + } + else if (__pTemporaryItemBuffer != null && __pTemporaryItemBuffer != pItem) + { + __pListProviderAdaptor->UnloadItem(__pTemporaryItemBuffer, temporaryGroupIndex, temporaryItemIndex); + __pTemporaryItemBuffer = null; + + return pItem; + } + else + { + __pTemporaryItemBuffer = null; + + return pItem; + } + + return __pTemporaryItemBuffer; +} + +_IListItemCommon* +_ListViewModel::GetItemFromContainer(int groupIndex, int itemIndex) const +{ + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), null, E_INVALID_ARG, + "[E_INVALID_ARG] The group index is not valid."); + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, null, GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin(); + + _IListItemCommon* pItem = null; + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + + while (theIter != pListGroupNode->__items.end()) + { + pItem = *theIter; + pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + if (temporaryItemIndex == itemIndex) + { + return pItem; + } + else if (temporaryItemIndex > itemIndex) + { + break; + } + + theIter++; + } + + return null; +} + +_IListItemCommon* +_ListViewModel::LoadItem(int groupIndex, int itemIndex) +{ + // check validation of groupIndex + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), null, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong group index.(%d)", groupIndex); + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, null, GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + // check validation of item index + if (itemIndex < -1 || itemIndex >= pListGroupNode->__itemCountInGroup) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] The item index is not valid."); + return null; + } + + // if loaded item, call GetItemFromContainer() + if (IsLoadedItem(groupIndex, itemIndex) == true) + { + return GetItemFromContainer(groupIndex, itemIndex); + } + + _IListItemCommon* pItemCommon = __pListProviderAdaptor->LoadItem(groupIndex, itemIndex); + if (pItemCommon != null) + { + if (IsItemChecked(groupIndex, itemIndex) == true) + { + pItemCommon->SetChecked(true); + } + + if (IsItemEnabled(groupIndex, itemIndex) == false) + { + pItemCommon->SetItemEnabled(false); + } + + // push item to container + pItemCommon->SetItemIndex(groupIndex, itemIndex); + LoadItemToContainer(groupIndex, itemIndex, *pItemCommon); + } + + return pItemCommon; +} + +result +_ListViewModel::LoadItemToContainer(int groupIndex, int itemIndex, _IListItemCommon& item) +{ + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin(); + + _IListItemCommon* pItem = null; + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + int overCount = 0; + bool pushToTopOrMiddle = true; + + if (pListGroupNode->__items.empty() == true) + { + int loadedGroups = GetAllGroupCount(); + _ListViewGroupNode* pTemporaryGroupNode = null; + for (int i = loadedGroups - 1; i >= 0; i--) + { + pTemporaryGroupNode = GetGroupNode(i); + if (pTemporaryGroupNode != null) + { + if (i > groupIndex) + { + if (pTemporaryGroupNode->__items.size() > 0) + { + break; + } + } + else + { + pushToTopOrMiddle = false; + break; + } + } + } + } + else + { + while (theIter != pListGroupNode->__items.end()) + { + pItem = *theIter; + pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + if (temporaryItemIndex == itemIndex) + { + return E_SUCCESS; + } + else if (temporaryItemIndex > itemIndex) + { + // push item to top or middle + pListGroupNode->__items.insert(theIter, &item); + + overCount = GetOverflowCount(); + if (overCount > 0) + { + RemoveOverflowItems(true, overCount); + } + + return E_SUCCESS; + } + + if (pItem == pListGroupNode->__items.back()) + { + int lastLoadedItemIndex = -1; + int lastLoadedGroupIndex = -1; + GetLastLoadedItemIndex(lastLoadedGroupIndex,lastLoadedItemIndex); + if (lastLoadedGroupIndex == temporaryGroupIndex && lastLoadedItemIndex == temporaryItemIndex) + { + pushToTopOrMiddle = false; + } + else + { + pushToTopOrMiddle = true; + } + + break; + } + + theIter++; + } + } + + // push item to bottom + pListGroupNode->__items.push_back(&item); + + overCount = GetOverflowCount(); + if (overCount > 0) + { + // if push item to end of list, RemoveOverflowItems() from top. + RemoveOverflowItems(pushToTopOrMiddle, overCount); + } + + return E_SUCCESS; +} + +bool +_ListViewModel::IsValidItem(int groupIndex, int itemIndex) const +{ + // check validation of groupIndex + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), false, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong group index(%d).", groupIndex); + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, false, GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + // check validation of item index + SysTryReturn(NID_UI_CTRL, (itemIndex >= -1 && itemIndex < pListGroupNode->__itemCountInGroup), false, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong item index(%d).", itemIndex); + + return true; +} + +bool +_ListViewModel::IsLoadedItem(int groupIndex, int itemIndex) const +{ + // check validation of groupIndex + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), false, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong group index(%d).", groupIndex); + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, false, GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + // check validation of item index + SysTryReturn(NID_UI_CTRL, (itemIndex < pListGroupNode->__itemCountInGroup), false, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong item index(%d).", itemIndex); + + _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin(); + + _IListItemCommon* pItem = null; + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + while (theIter != pListGroupNode->__items.end()) + { + pItem = *theIter; + pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + if (temporaryItemIndex == itemIndex) + { + return true; + } + else if (temporaryItemIndex > itemIndex) + { + return false; + } + + theIter++; + } + + return false; +} + +result +_ListViewModel::AddGroup(int itemCount, bool usingRadioStyle) +{ + SysTryReturn(NID_UI_CTRL, itemCount >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The itemCount is not valid."); + + //Create new GroupNode + _ListViewGroupNode* pListGroupNode = new (std::nothrow) _ListViewGroupNode(); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pListGroupNode->__itemCountInGroup = itemCount; + pListGroupNode->__usingRadioStyle = usingRadioStyle; + + __groupNodes.push_back(pListGroupNode); + + __countOfAllItems = __countOfAllItems + itemCount + 1; // include groupItem + __countOfAllGroups++; + + return E_SUCCESS; +} + +result +_ListViewModel::InsertGroup(int groupIndex, int itemCount, bool usingRadioStyle) +{ + // check validation of groupIndex + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex <= __countOfAllGroups), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong group index(%d).", groupIndex); + + SysTryReturn(NID_UI_CTRL, itemCount >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The itemCount is not valid."); + + if (__groupNodes.empty() == true || groupIndex == GetAllGroupCount()) + { + return AddGroup(itemCount); + } + + //Create new GroupNode + _ListViewGroupNode* pListGroupNode = new (std::nothrow) _ListViewGroupNode(); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pListGroupNode->__itemCountInGroup = itemCount; + pListGroupNode->__usingRadioStyle = usingRadioStyle; + + __groupNodes.insert(__groupNodes.begin() + groupIndex, pListGroupNode); + + __countOfAllItems = __countOfAllItems + itemCount + 1; // include groupItem + __countOfAllGroups++; + + // item index reordering + int groupCount = GetAllGroupCount(); + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + + pListGroupNode = null; + _IListItemCommon* pItem = null; + + for (int i = groupCount - 1; i > groupIndex; i--) + { + pListGroupNode = GetGroupNode(i); + if (pListGroupNode != null) + { + for (int j = pListGroupNode->__items.size() - 1; j >= 0; j--) + { + pItem = pListGroupNode->__items.at(j); + if (pItem != null) + { + pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + pItem->SetItemIndex(i, temporaryItemIndex); + } + } + } + } + + return E_SUCCESS; +} + +result +_ListViewModel::UnloadAllItem(void) +{ + if (__groupNodes.empty() == true) + { + return E_SUCCESS; + } + + int groupCount = GetAllGroupCount(); + int itemCount = 0; + + _ListViewGroupNode* pListGroupNode = null; + _IListItemCommon* pItem = null; + + int groupIndex = -1; + int itemIndex = -1; + for (int i = groupCount - 1; i >= 0; i--) + { + pListGroupNode = GetGroupNode(i); + if (pListGroupNode != null) + { + itemCount = pListGroupNode->__items.size(); + for (int j = itemCount - 1; j >= 0; j--) + { + pItem = pListGroupNode->__items.at(j); + pListGroupNode->__items.pop_back(); + + if (pItem != null) + { + pItem->GetItemIndex(groupIndex, itemIndex); + __pListProviderAdaptor->UnloadItem(pItem, groupIndex, itemIndex); + } + } + + pListGroupNode->__items.clear(); + } + } + + return E_SUCCESS; +} + +result +_ListViewModel::DeleteAllGroupAndItem(void) +{ + return RemoveAllItem(true); +} + +result +_ListViewModel::RemoveAllItem(bool internalDestroy, bool backupItemStatus) +{ + if (__groupNodes.empty() == true) + { + return E_SUCCESS; + } + + int groupCount = GetAllGroupCount(); + int itemCount = 0; + + _ListViewGroupNode* pListGroupNode = null; + _IListItemCommon* pItem = null; + + int groupIndex = -1; + int itemIndex = -1; + for (int i = groupCount - 1; i >= 0; i--) + { + pListGroupNode = GetGroupNode(i); + + if (pListGroupNode != null) + { + itemCount = pListGroupNode->__items.size(); + + for (int j = itemCount - 1; j >= 0; j--) + { + pItem = pListGroupNode->__items.at(j); + pListGroupNode->__items.pop_back(); + + if (pItem != null) + { + pItem->GetItemIndex(groupIndex, itemIndex); + + if (internalDestroy == false) + { + __pListProviderAdaptor->UnloadItem(pItem, groupIndex, itemIndex); + } + else + { + __pListProviderAdaptor->DeleteItem(pItem, groupIndex, itemIndex); + } + } + } + + pListGroupNode->__items.clear(); + pListGroupNode->__itemCountInGroup = 0; + + if (backupItemStatus == false) + { + __groupNodes.remove(pListGroupNode); + delete pListGroupNode; + pListGroupNode = null; + } + } + } + + __countOfAllGroups = 0; + __countOfAllItems = 0; + + if (backupItemStatus == false) + { + __groupNodes.clear(); + } + else + { + __backupGroupNodes = __groupNodes; + } + + return E_SUCCESS; +} + +void +_ListViewModel::RestoreItemStatus(void) +{ + if (__backupGroupNodes.empty() == true) + { + return; + } + + _ListViewGroupNode* pListGroupNode = null; + _ListViewGroupNode* pBackupedListGroupNode = null; + for (int i = 0; i < __backupGroupNodes.size(); i++) + { + pListGroupNode = GetGroupNode(i); + pBackupedListGroupNode = __backupGroupNodes.at(i); + + if (pListGroupNode != null) + { + pListGroupNode->__checkedItems = pBackupedListGroupNode->__checkedItems; + pListGroupNode->__disabledItems = pBackupedListGroupNode->__disabledItems; + pListGroupNode->__itemExpanded = pBackupedListGroupNode->__itemExpanded; + } + + delete pBackupedListGroupNode; + } + + __backupGroupNodes.clear(); +} + + +result +_ListViewModel::UnloadItem(int groupIndex, int itemIndex) +{ + // check validation of groupIndex + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong group index(%d).", groupIndex); + + if (IsLoadedItem(groupIndex, itemIndex) == false) + { + return E_SUCCESS; + } + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin(); + + _IListItemCommon* pItem = null; + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + while (theIter != pListGroupNode->__items.end()) + { + pItem = *theIter; + pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + if (temporaryItemIndex == itemIndex) + { + pListGroupNode->__items.erase(theIter); + + __pListProviderAdaptor->UnloadItem(pItem, groupIndex, itemIndex); + + return E_SUCCESS; + } + + theIter++; + } + + return E_SUCCESS; +} + +result +_ListViewModel::RemoveItemAt(int groupIndex, int itemIndex, bool internalDestroy) +{ + // check validation of groupIndex + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong group index(%d).", groupIndex); + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (itemIndex == -1) + { + return RemoveGroup(groupIndex); + } + + _IListItemCommon* pItem = GetItemFromContainer(groupIndex, itemIndex); + if (pItem != null) + { + pListGroupNode->__items.remove(pItem); + + if (internalDestroy == false) + { + __pListProviderAdaptor->UnloadItem(pItem, groupIndex, itemIndex); + } + else + { + __pListProviderAdaptor->DeleteItem(pItem, groupIndex, itemIndex); + } + } + + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin(); + while (theIter != pListGroupNode->__items.end()) + { + pItem = *theIter; + pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + if (temporaryItemIndex > itemIndex) + { + pItem->SetItemIndex(temporaryGroupIndex, temporaryItemIndex - 1); + } + + theIter++; + } + + pListGroupNode->__itemCountInGroup--; + __countOfAllItems--; + + MoveCheckedAndDisabledItemIndex(pListGroupNode, itemIndex, -1); + + return E_SUCCESS; +} + +result +_ListViewModel::RemoveGroup(int groupIndex) +{ + // check validation of groupIndex + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong group index(%d).", groupIndex); + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + // remove group + _IListItemCommon* pItem = null; + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + int itemCount = pListGroupNode->__items.size(); + + for (int i = itemCount - 1; i >= 0; i--) + { + pItem = pListGroupNode->__items.at(i); + pListGroupNode->__items.pop_back(); + + if (pItem != null) + { + pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + __pListProviderAdaptor->UnloadItem(pItem, temporaryGroupIndex, temporaryItemIndex); + } + } + pListGroupNode->__items.clear(); + + __countOfAllItems -= (pListGroupNode->__itemCountInGroup + 1); + __countOfAllGroups--; + + __groupNodes.erase(__groupNodes.begin() + groupIndex); + + delete pListGroupNode; + + // reset item index + int groupCount = GetAllGroupCount(); + for (int i = groupCount - 1; i >= groupIndex; i--) + { + pListGroupNode = GetGroupNode(i); + + if (pListGroupNode != null) + { + itemCount = pListGroupNode->__items.size(); + + for (int j = itemCount - 1; j >= 0; j--) + { + pItem = pListGroupNode->__items.at(j); + + if (pItem != null) + { + pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + pItem->SetItemIndex(temporaryGroupIndex - 1, temporaryItemIndex); + } + } + } + } + + return E_SUCCESS; +} + +result +_ListViewModel::SetMaxCachingSize(int cachingSize) +{ + SysTryReturn(NID_UI_CTRL, cachingSize > 0, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong cachingSize(%d).", cachingSize); + + __sizeOfCachingItems = cachingSize; + + return E_SUCCESS; +} + +int +_ListViewModel::GetMaxCachingSize(void) const +{ + return __sizeOfCachingItems; +} + +int +_ListViewModel::GetOverflowCount(void) const +{ + int loadedGroups = GetAllGroupCount(); + int loadedItems = 0; + + _ListViewGroupNode* pListGroupNode = null; + for (int i = 0; i < loadedGroups; i++) + { + pListGroupNode = GetGroupNode(i); + if (pListGroupNode != null) + { + loadedItems += pListGroupNode->__items.size(); + } + } + + if (__sizeOfCachingItems < loadedItems) + { + return loadedItems - __sizeOfCachingItems; + } + + return 0; +} + +result +_ListViewModel::RemoveOverflowItems(bool deleteFromEnd, int removeCount) +{ + SysTryReturn(NID_UI_CTRL, (removeCount > 0 && removeCount < __sizeOfCachingItems), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] removeCount should be greater than 0."); + + if (__overflowItemsRemovingEnabled == false) + { + return E_SUCCESS; + } + + int loadedGroups = GetAllGroupCount(); + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + int loadedItems = 0; + int i = 0; + int j = 0; + + _ListViewGroupNode* pListGroupNode = null; + _IListItemCommon* pItem = null; + + // remove priority : collapsed group items + for (i = 0; i < loadedGroups; i++) + { + pListGroupNode = GetGroupNode(i); + if (pListGroupNode != null) + { + if (pListGroupNode->__itemExpanded == false) + { + loadedItems = pListGroupNode->__items.size(); + for (j = 0; j < loadedItems; j++) + { + pItem = pListGroupNode->__items.back(); + pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + if (temporaryItemIndex == -1) + { + break; + } + + pListGroupNode->__items.pop_back(); + __pListProviderAdaptor->UnloadItem(pItem, temporaryGroupIndex, temporaryItemIndex); + + if (--removeCount <= 0) + { + return E_SUCCESS; + } + } + } + } + } + + if (deleteFromEnd == true) + { + for (i = loadedGroups - 1; i >= 0; i--) + { + pListGroupNode = GetGroupNode(i); + if (pListGroupNode != null) + { + loadedItems = pListGroupNode->__items.size(); + for (j = 0; j < loadedItems; j++) + { + pItem = pListGroupNode->__items.back(); + pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + pListGroupNode->__items.pop_back(); + __pListProviderAdaptor->UnloadItem(pItem, temporaryGroupIndex, temporaryItemIndex); + + if (--removeCount <= 0) + { + return E_SUCCESS; + } + } + } + } + } + else + { + for (i = 0; i < loadedGroups; i++) + { + pListGroupNode = GetGroupNode(i); + if (pListGroupNode != null) + { + loadedItems = pListGroupNode->__items.size(); + for (j = 0; j < loadedItems; j++) + { + pItem = pListGroupNode->__items.front(); + pItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + pListGroupNode->__items.pop_front(); + __pListProviderAdaptor->UnloadItem(pItem, temporaryGroupIndex, temporaryItemIndex); + + if (--removeCount <= 0) + { + return E_SUCCESS; + } + } + } + } + } + + return E_SUCCESS; +} + +int +_ListViewModel::GetAllItemCount(void) const +{ + return __countOfAllItems; +} + +int +_ListViewModel::GetItemCountInGroup(int groupIndex) const +{ + // check validation of groupIndex + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), -1, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong group index(%d).", groupIndex); + + int itemCount = -1; + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + + if (pListGroupNode == null) + { + itemCount = __pListProviderAdaptor->GetItemCount(groupIndex); + } + else + { + itemCount = pListGroupNode->__itemCountInGroup; + } + + return itemCount; +} + +int +_ListViewModel::GetAllGroupCount(void) const +{ + return __groupNodes.size(); +} + +void +_ListViewModel::GetFocusedItem(int& groupIndex, int& itemIndex) const +{ + groupIndex = __indexOfFocusedGroup; + itemIndex = __indexOfFocusedItem; +} + +void +_ListViewModel::SetFocusedItem(int groupIndex, int itemIndex) +{ + __indexOfFocusedGroup = groupIndex; + __indexOfFocusedItem = itemIndex; +} + +bool +_ListViewModel::IsFocusedItem(int groupIndex, int itemIndex) const +{ + if ((groupIndex == __indexOfFocusedGroup) && (itemIndex == __indexOfFocusedItem)) + { + return true; + } + + return false; +} + +result +_ListViewModel::SetItemEnabled(int groupIndex, int itemIndex, bool enable) +{ + // check validation + if (IsValidItem(groupIndex, itemIndex) == false) + { + return E_SYSTEM; + } + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + int disabledItem = itemIndex; + bool findItem = false; + + _LinkedList ::_Iterator theIter = pListGroupNode->__disabledItems.begin(); + + while (theIter != pListGroupNode->__disabledItems.end()) + { + if (*theIter == itemIndex) + { + if (enable == true) + { + pListGroupNode->__disabledItems.erase(theIter); + } + findItem = true; + break; + } + else if (*theIter > itemIndex) + { + if (enable == false) + { + pListGroupNode->__disabledItems.insert(theIter, disabledItem); + } + findItem = true; + break; + } + + theIter++; + } + + if (findItem == false && enable == false) + { + pListGroupNode->__disabledItems.push_back(disabledItem); + } + + if (IsLoadedItem(groupIndex, itemIndex) == false) + { + return E_SUCCESS; + } + + _IListItemCommon* pItem = GetItemFromContainer(groupIndex, itemIndex); + if (pItem != null) + { + pItem->SetItemEnabled(enable); + } + + return E_SUCCESS; +} + +bool +_ListViewModel::IsItemEnabled(int groupIndex, int itemIndex) const +{ + // check validation + if (IsValidItem(groupIndex, itemIndex) == false) + { + return false; + } + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, false, GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _LinkedList ::_Iterator theIter = pListGroupNode->__disabledItems.begin(); + + while (theIter != pListGroupNode->__disabledItems.end()) + { + if (*theIter == itemIndex) + { + return false; + } + else if (*theIter > itemIndex) + { + break; + } + + theIter++; + } + + return true; +} + +result +_ListViewModel::SetItemChecked(int groupIndex, int itemIndex, bool check) +{ + // check validation + if (IsValidItem(groupIndex, itemIndex) == false) + { + return E_SYSTEM; + } + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + //radio style + _IListItemCommon* pItem = null; + if (pListGroupNode->__usingRadioStyle == true) + { + if (check == true) + { + if (pListGroupNode->__radioCheckedItemIndex == itemIndex) + { + return E_SUCCESS; + } + + pItem = GetItemFromContainer(groupIndex, pListGroupNode->__radioCheckedItemIndex); + if (pItem != null) + { + pItem->SetChecked(false); + } + + pListGroupNode->__radioCheckedItemIndex = itemIndex; + + pItem = GetItemFromContainer(groupIndex, itemIndex); + if (pItem != null) + { + pItem->SetChecked(true); + } + + return E_SUCCESS; + } + else + { + if (pListGroupNode->__radioCheckedItemIndex == itemIndex) + { + pItem = GetItemFromContainer(groupIndex, pListGroupNode->__radioCheckedItemIndex); + if (pItem != null) + { + pItem->SetChecked(false); + } + + pListGroupNode->__radioCheckedItemIndex = -1; + } + + return E_SUCCESS; + } + } + + int checkedItem = itemIndex; + bool findItem = false; + + _LinkedList ::_Iterator theIter = pListGroupNode->__checkedItems.begin(); + while (theIter != pListGroupNode->__checkedItems.end()) + { + if (*theIter == itemIndex) + { + if (check == false) + { + pListGroupNode->__checkedItems.erase(theIter); + } + findItem = true; + break; + } + else if (*theIter > itemIndex) + { + if (check == true) + { + pListGroupNode->__checkedItems.insert(theIter, checkedItem); + } + findItem = true; + break; + } + + theIter++; + } + + if (findItem == false && check == true) + { + pListGroupNode->__checkedItems.push_back(checkedItem); + } + + if (IsLoadedItem(groupIndex, itemIndex) == false) + { + return E_SUCCESS; + } + + pItem = GetItemFromContainer(groupIndex, itemIndex); + if (pItem != null) + { + pItem->SetChecked(check); + } + + return E_SUCCESS; +} + +bool +_ListViewModel::IsItemChecked(int groupIndex, int itemIndex) const +{ + // check validation + if (IsValidItem(groupIndex, itemIndex) == false) + { + return false; + } + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, false, GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + //radio style + if (pListGroupNode->__usingRadioStyle == true) + { + if (pListGroupNode->__radioCheckedItemIndex == itemIndex) + { + return true; + } + + return false; + } + + _LinkedList ::_Iterator theIter = pListGroupNode->__checkedItems.begin(); + + while (theIter != pListGroupNode->__checkedItems.end()) + { + if (*theIter == itemIndex) + { + return true; + } + else if (*theIter > itemIndex) + { + break; + } + + theIter++; + } + + return false; +} + +int +_ListViewModel::GetIndexOfRadioCheckedItem(int groupIndex) const +{ + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, -1, GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return pListGroupNode->__radioCheckedItemIndex; +} + +void +_ListViewModel::SetAllLoadedItemStateChanged(bool state) +{ + if (__groupNodes.empty() == true) + { + return; + } + + int groupCount = GetAllGroupCount(); + _ListViewGroupNode* pListGroupNode = null; + _IListItemCommon* pItem = null; + + for (int i = 0; i < groupCount; i++) + { + pListGroupNode = GetGroupNode(i); + SysTryReturnVoidResult(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin(); + while (theIter != pListGroupNode->__items.end()) + { + pItem = *theIter; + pItem->SetItemChanged(state); + + theIter++; + } + } +} + +void +_ListViewModel::GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const +{ + int groupCount = GetAllGroupCount(); + _ListViewGroupNode* pListGroupNode = null; + _IListItemCommon* pItem = null; + + for (int i = 0; i < groupCount; i++) + { + pListGroupNode = GetGroupNode(i); + SysTryReturnVoidResult(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (pListGroupNode->__items.empty() == false) + { + pItem = pListGroupNode->__items.front(); + pItem->GetItemIndex(groupIndex, itemIndex); + break; + } + } +} + +void +_ListViewModel::GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const +{ + int groupCount = GetAllGroupCount(); + _ListViewGroupNode* pListGroupNode = null; + _IListItemCommon* pItem = null; + + for (int i = groupCount - 1; i >= 0; i--) + { + pListGroupNode = GetGroupNode(i); + SysTryReturnVoidResult(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (pListGroupNode->__items.empty() == false) + { + pItem = pListGroupNode->__items.back(); + pItem->GetItemIndex(groupIndex, itemIndex); + break; + } + } +} + +result +_ListViewModel::AddItemToGroup(_IListItemCommon* pItem, int groupIndex) +{ + return InsertItemToGroup(pItem, groupIndex, GetItemCountInGroup(groupIndex)); +} + + +result +_ListViewModel::InsertItemToGroup(_IListItemCommon* pItem, int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, pItem != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pItem is null."); + + // check validation of groupIndex + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong group index(%d).", groupIndex); + + if (itemIndex < -1 || itemIndex > GetItemCountInGroup(groupIndex)) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Item index is not valid."); + return E_INVALID_ARG; + } + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pItem->SetItemIndex(groupIndex, itemIndex); + + _IListItemCommon* pTemporaryItem = null; + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + int itemCount = pListGroupNode->__items.size(); + for (int i = itemCount - 1; i >= 0; i--) + { + pTemporaryItem = pListGroupNode->__items.at(i); + if (pTemporaryItem != null) + { + pTemporaryItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + if (temporaryItemIndex >= itemIndex) + { + pTemporaryItem->SetItemIndex(temporaryGroupIndex, ++temporaryItemIndex); + } + else + { + break; + } + } + } + + _LinkedList ::_Iterator theIter; + // checked(radio/check) item index + if (pListGroupNode->__usingRadioStyle == true) + { + //radio item + if (pListGroupNode->__radioCheckedItemIndex >= itemIndex) + { + pListGroupNode->__radioCheckedItemIndex++; + } + } + else + { + theIter = pListGroupNode->__checkedItems.begin(); + while (theIter != pListGroupNode->__checkedItems.end()) + { + if (*theIter >= itemIndex) + { + (*theIter) += 1; + } + + theIter++; + } + } + + // disabled item index + theIter = pListGroupNode->__disabledItems.begin(); + while (theIter != pListGroupNode->__disabledItems.end()) + { + if (*theIter >= itemIndex) + { + (*theIter) += 1; + } + + theIter++; + } + + pListGroupNode->__itemCountInGroup++; + __countOfAllItems++; + + return LoadItemToContainer(groupIndex, itemIndex, *pItem); +} + +result +_ListViewModel::SetItem(_IListItemCommon& item, int groupIndex, int itemIndex) +{ + // check validation of groupIndex + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __countOfAllGroups), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Wrong group index(%d).", groupIndex); + + if (itemIndex < -1 || itemIndex > GetItemCountInGroup(groupIndex)) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Item index is not valid."); + return E_INVALID_ARG; + } + + if (IsLoadedItem(groupIndex, itemIndex) == false) + { + return __pListProviderAdaptor->UnloadItem(&item, groupIndex, itemIndex); + } + + _ListViewGroupNode* pListGroupNode = GetGroupNode(groupIndex); + SysTryReturn(NID_UI_CTRL, pListGroupNode != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + item.SetItemIndex(groupIndex, itemIndex); + item.SetChecked(IsItemChecked(groupIndex, itemIndex)); + item.SetItemEnabled(IsItemEnabled(groupIndex, itemIndex)); + + _LinkedList <_IListItemCommon*>::_Iterator theIter = pListGroupNode->__items.begin(); + + _IListItemCommon* pPreviousItem = null; + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + while (theIter != pListGroupNode->__items.end()) + { + pPreviousItem = *theIter; + pPreviousItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + if (temporaryItemIndex == itemIndex) + { + *theIter = &item; + break; + } + else if (temporaryItemIndex > itemIndex) + { + return __pListProviderAdaptor->UnloadItem(&item, groupIndex, itemIndex); + } + + theIter++; + } + + return __pListProviderAdaptor->UnloadItem(pPreviousItem, groupIndex, itemIndex); +} + +// origin & destination item must be loaded +result +_ListViewModel::MoveItem(_ListItemPos originPosition, _ListItemPos destinationPosition) +{ + if (IsValidItem(originPosition.groupIndex, originPosition.itemIndex) == false + || IsValidItem(destinationPosition.groupIndex, destinationPosition.itemIndex - 1) == false) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Item index is not valid."); + return E_SYSTEM; + } + + _ListViewGroupNode* pOriginGroupNode = GetGroupNode(originPosition.groupIndex); + SysTryReturn(NID_UI_CTRL, pOriginGroupNode != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _ListViewGroupNode* pDestinationGroupNode = GetGroupNode(destinationPosition.groupIndex); + SysTryReturn(NID_UI_CTRL, pDestinationGroupNode != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _IListItemCommon* pItem = GetItemFromContainer(originPosition.groupIndex, originPosition.itemIndex); + SysTryReturn(NID_UI_CTRL, pItem != null, GetLastResult(), GetLastResult(), + "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _IListItemCommon* pTemporaryItem = null; + int temporaryGroupIndex = -1; + int temporaryItemIndex = -1; + int indexCount = 0; + bool isFound = false; + + if (originPosition.groupIndex != destinationPosition.groupIndex) // different group + { + pOriginGroupNode->__items.remove(pItem); + + _LinkedList <_IListItemCommon*>::_Iterator theIter = pOriginGroupNode->__items.begin(); + while (theIter != pOriginGroupNode->__items.end()) + { + pTemporaryItem = *theIter; + pTemporaryItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + if (temporaryItemIndex > originPosition.itemIndex) + { + pTemporaryItem->SetItemIndex(temporaryGroupIndex, temporaryItemIndex - 1); + } + + theIter++; + } + + pItem->SetItemIndex(destinationPosition.groupIndex, destinationPosition.itemIndex); + + _LinkedList <_IListItemCommon*>::_Iterator destinationIter = pDestinationGroupNode->__items.begin(); + while (destinationIter != pDestinationGroupNode->__items.end()) + { + pTemporaryItem = *destinationIter; + pTemporaryItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + if (temporaryItemIndex >= destinationPosition.itemIndex) + { + pTemporaryItem->SetItemIndex(temporaryGroupIndex, temporaryItemIndex + 1); + + if (temporaryItemIndex == destinationPosition.itemIndex) + { + pDestinationGroupNode->__items.insert(destinationIter, pItem); + isFound = true; + } + } + + destinationIter++; + } + + if (isFound == false) + { + pDestinationGroupNode->__items.push_back(pItem); + } + + // remove checked(radio/check) & disabled item index + MoveCheckedAndDisabledItemIndex(pOriginGroupNode, originPosition.itemIndex, -1, pItem->IsChecked(), pItem->IsItemEnabled()); + + // insert checked(radio/check) & disabled item index + MoveCheckedAndDisabledItemIndex(pDestinationGroupNode, -1, destinationPosition.itemIndex, pItem->IsChecked(), pItem->IsItemEnabled()); + + pOriginGroupNode->__itemCountInGroup--; + pDestinationGroupNode->__itemCountInGroup++; + } + else // same group + { + pOriginGroupNode->__items.remove(pItem); + + _LinkedList <_IListItemCommon*>::_Iterator theIter = pOriginGroupNode->__items.begin(); + while (theIter != pOriginGroupNode->__items.end()) + { + pTemporaryItem = *theIter; + pTemporaryItem->GetItemIndex(temporaryGroupIndex, temporaryItemIndex); + + if (temporaryItemIndex < originPosition.itemIndex && temporaryItemIndex >= destinationPosition.itemIndex) + { + pTemporaryItem->SetItemIndex(temporaryGroupIndex, temporaryItemIndex + 1); + } + else if (temporaryItemIndex > originPosition.itemIndex && temporaryItemIndex <= destinationPosition.itemIndex) + { + pTemporaryItem->SetItemIndex(temporaryGroupIndex, temporaryItemIndex - 1); + + if (temporaryItemIndex == destinationPosition.itemIndex) + { + indexCount++; + } + } + else if (temporaryItemIndex > originPosition.itemIndex && temporaryItemIndex > destinationPosition.itemIndex) + { + break; + } + + if (temporaryItemIndex < destinationPosition.itemIndex) + { + indexCount++; + } + + theIter++; + } + + if (indexCount < 0) + { + indexCount = 0; + } + + pItem->SetItemIndex(destinationPosition.groupIndex, destinationPosition.itemIndex); + pOriginGroupNode->__items.insert(pOriginGroupNode->__items.begin() + indexCount, pItem); + + // move checked(radio/check) & disabled item index + MoveCheckedAndDisabledItemIndex(pOriginGroupNode, originPosition.itemIndex, destinationPosition.itemIndex, pItem->IsChecked(), pItem->IsItemEnabled()); + } + + return E_SUCCESS; +} + +// insert mode : originItemIndex == -1 +// remove mode : destinationItemIndex == -1 +void +_ListViewModel::MoveCheckedAndDisabledItemIndex(_ListViewGroupNode* pListGroupNode, int originItemIndex, int destinationItemIndex, bool checked, bool enabled) +{ + int indexCount = 0; + int temporaryDestinationIndex = destinationItemIndex; + if (destinationItemIndex == -1) + { + temporaryDestinationIndex = pListGroupNode->__itemCountInGroup; + } + + // move checked(radio/check) item index + if (pListGroupNode->__usingRadioStyle == true) + { + //radio style + if (checked == true || (pListGroupNode->__radioCheckedItemIndex == originItemIndex && originItemIndex != -1)) // for insert mode + { + pListGroupNode->__radioCheckedItemIndex = destinationItemIndex; + } + else if (pListGroupNode->__radioCheckedItemIndex < originItemIndex && + pListGroupNode->__radioCheckedItemIndex >= temporaryDestinationIndex) + { + pListGroupNode->__radioCheckedItemIndex++; + } + else if (originItemIndex != -1 && + pListGroupNode->__radioCheckedItemIndex > originItemIndex && + pListGroupNode->__radioCheckedItemIndex < temporaryDestinationIndex) + { + pListGroupNode->__radioCheckedItemIndex--; + } + } + else + { + //checked style + int checkedItemIndex = -1; + _LinkedList ::_Iterator theIter = pListGroupNode->__checkedItems.begin(); + + while (theIter != pListGroupNode->__checkedItems.end()) + { + checkedItemIndex = (int)(*theIter); + if (originItemIndex == -1) // insert mode + { + if (checkedItemIndex >= temporaryDestinationIndex) + { + *theIter = checkedItemIndex + 1; + } + else + { + indexCount++; + } + } + else + { + if (checkedItemIndex < originItemIndex && checkedItemIndex >= temporaryDestinationIndex) + { + *theIter = checkedItemIndex + 1; + } + else if (checkedItemIndex > originItemIndex && checkedItemIndex < temporaryDestinationIndex) + { + *theIter = checkedItemIndex - 1; + } + else if (checkedItemIndex == originItemIndex) + { + pListGroupNode->__checkedItems.erase(theIter); + } + else if (checkedItemIndex > originItemIndex && checkedItemIndex > temporaryDestinationIndex) + { + break; + } + + if (checkedItemIndex <= temporaryDestinationIndex && checkedItemIndex != originItemIndex) + { + indexCount++; + } + } + + theIter++; + } + + if (destinationItemIndex != -1 && checked == true) + { + pListGroupNode->__checkedItems.insert(pListGroupNode->__checkedItems.begin() + + indexCount, destinationItemIndex); + } + } + + indexCount = 0; + + // move disabled + int disabledItemIndex = -1; + _LinkedList ::_Iterator theIter = pListGroupNode->__disabledItems.begin(); + + while (theIter != pListGroupNode->__disabledItems.end()) + { + disabledItemIndex = (int)(*theIter); + if (originItemIndex == -1) // insert mode + { + if (disabledItemIndex >= temporaryDestinationIndex) + { + *theIter = disabledItemIndex + 1; + } + else + { + indexCount++; + } + } + else + { + if (disabledItemIndex < originItemIndex && disabledItemIndex >= temporaryDestinationIndex) + { + *theIter = disabledItemIndex + 1; + } + else if (disabledItemIndex > originItemIndex && disabledItemIndex < temporaryDestinationIndex) + { + *theIter = disabledItemIndex - 1; + } + else if (disabledItemIndex == originItemIndex) + { + pListGroupNode->__disabledItems.erase(theIter); + } + else if (disabledItemIndex > originItemIndex && disabledItemIndex > temporaryDestinationIndex) + { + break; + } + + if (disabledItemIndex <= temporaryDestinationIndex && disabledItemIndex != originItemIndex) + { + indexCount++; + } + } + + theIter++; + } + + if (destinationItemIndex != -1 && enabled == false) + { + pListGroupNode->__disabledItems.insert(pListGroupNode->__disabledItems.begin() + + indexCount, destinationItemIndex); + } +} + +_ListViewGroupNode* +_ListViewModel::GetGroupNode(int groupIndex) const +{ + if (__groupNodes.empty() == true) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] GroupNode is Empty."); + return null; + } + + _ListViewGroupNode* pListGroupNode = __groupNodes.at(groupIndex); + if (pListGroupNode == null) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Failed to get _ListViewGroupNode."); + } + + return pListGroupNode; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_MessageBox.cpp b/src/ui/controls/FUiCtrl_MessageBox.cpp new file mode 100644 index 0000000..23df460 --- /dev/null +++ b/src/ui/controls/FUiCtrl_MessageBox.cpp @@ -0,0 +1,380 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_MessageBox.cpp + * @brief This is the implementation file for the _MessageBox class. + */ + +#include +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_MessageBox.h" +#include "FUiCtrl_MessageBoxPresenter.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +_MessageBox::_MessageBox(void) + : __pMsgboxPresenter(null) + , __msgboxStyle(MSGBOX_STYLE_NONE) + , __textColor(Color(0xFFFFFFFF)) + , __text(L"") + , __timeout(0) +{ + //empty statement +} + +_MessageBox::~_MessageBox(void) +{ + delete __pMsgboxPresenter; + __pMsgboxPresenter = null; + + delete _pBgBitmap; + _pBgBitmap = null; + + delete _pComposedBgBitmap; + _pComposedBgBitmap = null; + + delete _pOutlineBitmap; + _pOutlineBitmap = null; + + delete _pDimmingLayer; + _pDimmingLayer = null; + +} + +_MessageBox* +_MessageBox::CreateMessageBoxN(void) +{ + _MessageBox* pMsgbox = new (std::nothrow) _MessageBox(); + SysTryReturn(NID_UI, pMsgbox != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + +#if defined(MULTI_WINDOW) + result r = pMsgbox->CreateRootVisualElement(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); +#endif + + // for taking touch event + pMsgbox->AcquireHandle(); + + return pMsgbox; + +#if defined(MULTI_WINDOW) +CATCH: + delete pMsgbox; + + return null; +#endif +} + +result +_MessageBox::Initialize(const String& title, const String& text, MessageBoxStyle style, unsigned long timeout) +{ + result r = E_SUCCESS; + + int titleHeight = 0; + + _titleText = title; + _titleState = !(title.Equals(L"", false)); + + __text = text; + __msgboxStyle = style; + __timeout = timeout; + + _MessageBoxPresenter* pPresenter = new (std::nothrow) _MessageBoxPresenter(); + SysTryReturn(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + SetPresenter(*pPresenter); + + r = pPresenter->Initialize(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // for dim effect + _pDimmingLayer = new (std::nothrow) _DimmingLayer(); + SysTryReturn(NID_UI_CTRL, _pDimmingLayer != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = _pDimmingLayer->Construct(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_COLOR_CONFIG(MESSAGEBOX::BG_NORMAL, _bgColor); + GET_COLOR_CONFIG(MESSAGEBOX::TITLE_TEXT_NORMAL, _titleTextColor); + GET_COLOR_CONFIG(MESSAGEBOX::TEXT_NORMAL, __textColor); + + GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_HEIGHT, GetOrientation(), titleHeight); + + // MsgBox_Outline + GET_BITMAP_CONFIG_N(MESSAGEBOX::BG_OUTLINE_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, _pOutlineBitmap); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] failed to load MessageBox Outline Image."); + + // MsgBox BG + GET_BITMAP_CONFIG_N(MESSAGEBOX::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, _pBgBitmap); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] failed to load MessageBox BG Image."); + + _pComposedBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*_pBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), _bgColor); + + // for clearing canvas + if (GetVisualElement() != null) + { + GetVisualElement()->SetSurfaceOpaque(false); + } + + _AccessibilityContainer* pContainer = null; + + pContainer = GetAccessibilityContainer(); + if(pContainer != null) + { + pContainer->Activate(true); + } + + SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_NORMAL); + + return r; +} + +result +_MessageBox::SetPresenter(const _MessageBoxPresenter& msgboxPresenter) +{ + __pMsgboxPresenter = const_cast <_MessageBoxPresenter*>(&msgboxPresenter); + + return E_SUCCESS; +} + +void +_MessageBox::OnDraw() +{ + __pMsgboxPresenter->Draw(); + + return; +} + +void +_MessageBox::OnFontChanged(Font * pFont) +{ + __pMsgboxPresenter->OnFontChanged(pFont); +} + +void +_MessageBox::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pMsgboxPresenter->OnFontInfoRequested(style, size); +} + +void +_MessageBox::OnActivated(void) +{ + _Popup::OnActivated(); +} + +void +_MessageBox::OnDeactivated(void) +{ + _Popup::OnDeactivated(); +} + +result +_MessageBox::OnAttachedToMainTree(void) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, GetVisibleState() != false, E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control is not 'displayable'"); + + r = __pMsgboxPresenter->OnAttachedToMainTree(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_MessageBox::ShowAndWait(int& modalResult) +{ + __pMsgboxPresenter->ShowAndWait(modalResult); + + return E_SUCCESS; +} + +String +_MessageBox::GetText(void) const +{ + return __text; +} + +unsigned long +_MessageBox::GetTimeout(void) const +{ + return __timeout; +} + +void +_MessageBox::SetTextColor(const Color& color) +{ + __textColor = color; +} + +Color +_MessageBox::GetTextColor(void) const +{ + return __textColor; +} + +MessageBoxStyle +_MessageBox::GetMsgBoxStyle(void) const +{ + return __msgboxStyle; +} + +int +_MessageBox::GetTotalHeight(void) const +{ + int titleHeight = 0; + int btnHeight = 0; + + int textTopMargin = 0; + int textTopMarginNoButton = 0; + + int btnGap = 0; + int btnTopMargin = 0; + int btnBottomMargin = 0; + + int transTopMargin = 0; + int transBottomMargin = 0; + + GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_HEIGHT, GetOrientation(), titleHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, GetOrientation(), btnHeight); + + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN, GetOrientation(), textTopMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN_NO_BUTTON, GetOrientation(), textTopMarginNoButton); + + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_INTERNAL_GAP, GetOrientation(), btnGap); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_TOP_MARGIN, GetOrientation(), btnTopMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_BOTTOM_MARGIN, GetOrientation(), btnBottomMargin); + + GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_TOP_MARGIN, GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, GetOrientation(), transBottomMargin); + + if (HasTitle() == false) + { + titleHeight = 0; + } + + int totalH = titleHeight + + __pMsgboxPresenter->GetBodyTextHeight() + + transTopMargin + + transBottomMargin; + + switch (__msgboxStyle) + { + case MSGBOX_STYLE_NONE: + totalH += textTopMarginNoButton * 2; + break; + + case MSGBOX_STYLE_OK: + // fall through + case MSGBOX_STYLE_CANCEL: + // fall through + case MSGBOX_STYLE_OKCANCEL: + // fall through + case MSGBOX_STYLE_YESNO: + // fall through + case MSGBOX_STYLE_RETRYCANCEL: + // fall through + case MSGBOX_STYLE_YESNOCANCEL: + // fall through + case MSGBOX_STYLE_ABORTRETRYIGNORE: + // fall through + case MSGBOX_STYLE_CANCELTRYCONTINUE: + totalH += textTopMargin * 2 + + btnHeight + + btnTopMargin + + btnBottomMargin; + break; + } + + return totalH; +} + +void +_MessageBox::OnChangeLayout(_ControlOrientation orientation) +{ + SysTryReturnVoidResult(NID_UI_CTRL, _pDimmingLayer != null, E_SYSTEM, "[E_SYSTEM] There is no Dimming Layer."); + + result r = E_SUCCESS; + + r = _pDimmingLayer->Rearrange(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +_MessageBox::OnBoundsChanged(void) +{ + SetClientBounds(Rectangle(0, 0, GetBounds().width, GetBounds().height)); + + return; +} + +bool +_MessageBox::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + + return __pMsgboxPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_MessageBox::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + + return __pMsgboxPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_MessageBox::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + + return __pMsgboxPresenter->OnTouchMoved(source, touchinfo); +} + + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_MessageBoxImpl.cpp b/src/ui/controls/FUiCtrl_MessageBoxImpl.cpp new file mode 100644 index 0000000..9836a1e --- /dev/null +++ b/src/ui/controls/FUiCtrl_MessageBoxImpl.cpp @@ -0,0 +1,294 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_MessageBoxImpl.cpp + * @brief This is the implementation file for the _MessageBoxImpl class. + */ + + +// Includes +#include +#include "FUi_ControlImplManager.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_FrameImpl.h" +#include "FUiCtrl_MessageBoxImpl.h" +#include "FUiCtrl_Form.h" + + +using namespace Tizen::Graphics; +using namespace Tizen::Base; + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +_MessageBoxImpl* +_MessageBoxImpl::GetInstance(MessageBox& pMessageBox) +{ + return static_cast <_MessageBoxImpl*>(pMessageBox._pControlImpl); +} + +const _MessageBoxImpl* +_MessageBoxImpl::GetInstance(const MessageBox& pMessageBox) +{ + return static_cast (pMessageBox._pControlImpl); +} + +_MessageBoxImpl::_MessageBoxImpl(MessageBox* pPublic, _MessageBox* pCore) + : _WindowImpl(pPublic, pCore) +{ + // empty statement +} + +_MessageBoxImpl::~_MessageBoxImpl(void) +{ + // empty statement +} + +_MessageBoxImpl* +_MessageBoxImpl::CreateMessageBoxImplN(MessageBox* pControl) +{ + result r = E_SUCCESS; + + _MessageBox* pCore = null; + _MessageBoxImpl* pImpl = null; + + pCore = _MessageBox::CreateMessageBoxN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl = new (std::nothrow) _MessageBoxImpl(pControl, pCore); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; +} + +result +_MessageBoxImpl::Initialize(const Tizen::Base::String& title, const Tizen::Base::String& text, MessageBoxStyle style, unsigned long timeout) +{ + result r = E_SUCCESS; + + Rectangle bounds; + int totalH = -1; + + int maxHeight = 0; + int defaultWidth = 0; + + r = GetCore().Initialize(title, text, style, timeout); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, GetCore().GetOrientation(), maxHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, GetCore().GetOrientation(), defaultWidth); + + totalH = GetCore().GetTotalHeight(); + + if (totalH > maxHeight) + { + bounds = GetCenterAlignRect(defaultWidth, maxHeight); + } + else + { + bounds = GetCenterAlignRect(defaultWidth, totalH); + } + + r = SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetMovable(false); + SetResizable(false); + + return r; +} + +const char* +_MessageBoxImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::MessageBox"; +} + +const MessageBox& +_MessageBoxImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +MessageBox& +_MessageBoxImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _MessageBox& +_MessageBoxImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_MessageBox& +_MessageBoxImpl::GetCore(void) +{ + return static_cast <_MessageBox&>(_ControlImpl::GetCore()); +} + +result +_MessageBoxImpl::ShowAndWait(int& modalResult) +{ + SysTryReturn(NID_UI_CTRL, GetVisibleState() != false, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] This control is not visible"); + + return GetCore().ShowAndWait(modalResult); +} + +void +_MessageBoxImpl::SetColor(const Color& color) +{ + return GetCore().SetColor(color); +} + +Color +_MessageBoxImpl::GetColor() const +{ + return GetCore().GetColor(); +} + +void +_MessageBoxImpl::SetTitleTextColor(const Color& color) +{ + return GetCore().SetTitleTextColor(color); +} + +Color +_MessageBoxImpl::GetTitleTextColor() const +{ + return GetCore().GetTitleTextColor(); +} +void +_MessageBoxImpl::SetTextColor(const Color& color) +{ + return GetCore().SetTextColor(color); +} + +Color +_MessageBoxImpl::GetTextColor() const +{ + return GetCore().GetTextColor(); +} + +MessageBoxStyle +_MessageBoxImpl::GetMessageBoxStyle(void) const +{ + return GetCore().GetMsgBoxStyle(); +} + +String +_MessageBoxImpl::GetTitleText(void) const +{ + return GetCore().GetTitleText(); +} + +String +_MessageBoxImpl::GetText(void) const +{ + return GetCore().GetText(); +} + +unsigned long +_MessageBoxImpl::GetTimeout(void) const +{ + return GetCore().GetTimeout(); +} + +int +_MessageBoxImpl::GetMaxTextLength(void) const +{ + int maxLength = 0; + GET_FIXED_VALUE_CONFIG(MESSAGEBOX::TEXT_MAX_LENGTH, GetCore().GetOrientation(), maxLength); + + return maxLength; +} + +Rectangle +_MessageBoxImpl::GetCenterAlignRect(int width, int height) const +{ + int x = 0; + int y = 0; + + Dimension screenRect = _ControlManager::GetInstance()->GetScreenSize(); + + if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE) + { + int temp = screenRect.width; + screenRect.width = screenRect.height; + screenRect.height = temp; + } + + x = (screenRect.width - width) / 2; + y = (screenRect.height - height) / 2; + + return Rectangle(x, y, width, height); +} + + +void +_MessageBoxImpl::OnChangeLayout(_ControlOrientation orientation) +{ + result r = E_SUCCESS; + Dimension portraitSize; + Dimension landscapeSize; + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + portraitSize = Dimension(GetBounds().width, GetBounds().height); + landscapeSize = Dimension(portraitSize.height, portraitSize.width); + } + else + { + portraitSize = Dimension(GetBounds().height, GetBounds().width); + landscapeSize = Dimension(portraitSize.height, portraitSize.width); + } + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + SetResizable(true); + SetMovable(true); + + r = SetBounds(GetCenterAlignRect(portraitSize.width, portraitSize.height)); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetMovable(false); + SetResizable(false); + } + else + { + SetResizable(true); + SetMovable(true); + + r = SetBounds(GetCenterAlignRect(landscapeSize.width, landscapeSize.height)); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetMovable(false); + SetResizable(false); + } + + return GetCore().OnChangeLayout(orientation); +} + + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_MessageBoxPresenter.cpp b/src/ui/controls/FUiCtrl_MessageBoxPresenter.cpp new file mode 100755 index 0000000..2b3676c --- /dev/null +++ b/src/ui/controls/FUiCtrl_MessageBoxPresenter.cpp @@ -0,0 +1,1146 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_MessageBoxPresenter.cpp + * @brief This is the implementation file for the _MessageBoxPresenter class. + */ + +#include +#include +#include +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_ModalLoopManager.h" +#include "FUi_ResourceManager.h" +#include "FUi_TouchManager.h" +#include "FUiCtrl_ButtonImpl.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_Scroll.h" +#include "FUiCtrl_MessageBox.h" +#include "FUiCtrl_MessageBoxPresenter.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +_MessageBoxPresenter::_MessageBoxPresenter(void) + : __pMessageBox(null) + , __pButtonListener(null) + , __msgboxResult(MSGBOX_RESULT_CLOSE) + , __pTextAccessibilityElement(null) + , __pTitleTextObject(null) + , __pBodyTextObject(null) + , __titleBounds(0, 0, 0, 0) + , __textBounds(0, 0, 0, 0) + , __pScroll(null) + , __fontStyle(0) + , __fontSize(0) + , __scrollPos(0) + , __buttonNum(0) + , __prevPositionY(-1) + , __textObjHeight(0) + , __touchPressFlag(false) + , __scrollStart(false) + , __btnClickFlag(false) + , __bodyClickFlag(false) + , __touchOutBounds(false) +{ + for (int i = 0; i < 3; i++) + { + __pButtons[i] = null; + } +} + +_MessageBoxPresenter::~_MessageBoxPresenter(void) +{ + for (int i = 0; i < __buttonNum; i++) + { + delete __pButtons[i]; + __pButtons[i] = null; + } + + delete __pButtonListener; + __pButtonListener = null; + + if (__pTitleTextObject != null) + { + __pTitleTextObject->RemoveAll(); + delete __pTitleTextObject; + __pTitleTextObject = null; + } + + if (__pBodyTextObject != null) + { + __pBodyTextObject->RemoveAll(); + delete __pBodyTextObject; + __pBodyTextObject = null; + } + + if (__pScroll != null) + { + __pMessageBox->DetachSystemChild(*__pScroll); + delete __pScroll; + __pScroll = null; + } + + if (__pTextAccessibilityElement) + { + __pTextAccessibilityElement->Activate(false); + __pTextAccessibilityElement = null; + } +} + +result +_MessageBoxPresenter::Initialize(_MessageBox& msgbox) +{ + result r = E_SUCCESS; + String titleText = L""; + String bodyText = L""; + TextSimple* pSimpleTextForBodyText = null; + + int titleTextSize = 0; + int bodyTextSize = 0; + + int defaultWidth = 0; + int titleHeight = 0; + int bottomHeight = 0; + int maxHeight = 0; + + int btnBottomMargin = 0; + int textTopMargin = 0; + int textLeftMargin = 0; + int textRightMargin = 0; + + int titleTopMargin = 0; + int titleLeftMargin = 0; + int titleRightMargin = 0; + + int transTopMargin = 0; + int transBottomMargin = 0; + int transLeftMargin = 0; + int transRightMargin = 0; + + int totalHeightExceptTextObj = 0; + int tempHeight = 0; + + __pMessageBox = &msgbox; + + GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_SIZE, __pMessageBox->GetOrientation(), titleTextSize); + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_SIZE, __pMessageBox->GetOrientation(), bodyTextSize); + + GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, __pMessageBox->GetOrientation(), defaultWidth); + GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_HEIGHT, __pMessageBox->GetOrientation(), titleHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::BOTTOM_HEIGHT, __pMessageBox->GetOrientation(), bottomHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, __pMessageBox->GetOrientation(), maxHeight); + + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_BOTTOM_MARGIN, __pMessageBox->GetOrientation(), btnBottomMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN, __pMessageBox->GetOrientation(), textTopMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_LEFT_MARGIN, __pMessageBox->GetOrientation(), textLeftMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_RIGHT_MARGIN, __pMessageBox->GetOrientation(), textRightMargin); + + GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_TOP_MARGIN, __pMessageBox->GetOrientation(), titleTopMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_LEFT_MARGIN, __pMessageBox->GetOrientation(), titleLeftMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_RIGHT_MARGIN, __pMessageBox->GetOrientation(), titleRightMargin); + + GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pMessageBox->GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, __pMessageBox->GetOrientation(), transBottomMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, __pMessageBox->GetOrientation(), transLeftMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, __pMessageBox->GetOrientation(), transRightMargin); + + // TitleText + if (__pMessageBox->HasTitle() == true) + { + r = SetFontInfo(FONT_STYLE_PLAIN, titleTextSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to set font.", GetErrorMessage(r)); + + __pTitleTextObject = new (std::nothrow) TextObject(); + SysTryReturn(NID_UI_CTRL, __pTitleTextObject != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create TitleTextObject."); + + __pTitleTextObject->Construct(); + TextSimple* pSimpleTextForTitleText = new (std::nothrow) TextSimple(const_cast (__pMessageBox->GetTitleText().GetPointer()), + __pMessageBox->GetTitleText().GetLength(), + TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_UI_CTRL, pSimpleTextForTitleText != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTitleTextObject->AppendElement(*pSimpleTextForTitleText); + __pTitleTextObject->SetForegroundColor(__pMessageBox->GetTitleTextColor(), 0, __pTitleTextObject->GetTextLength()); + __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pTitleTextObject->SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL); + + __pTitleTextObject->SetFont(_pFont, 0, __pTitleTextObject->GetTextLength()); + __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT); + __pTitleTextObject->SetBounds(Rectangle(titleLeftMargin + transLeftMargin, + titleTopMargin + transTopMargin, + defaultWidth - (titleLeftMargin + titleRightMargin + transLeftMargin + transRightMargin), + titleHeight - titleTopMargin)); + __pTitleTextObject->Compose(); + + __titleBounds = Rectangle(titleLeftMargin + transLeftMargin, + titleTopMargin + transTopMargin, + defaultWidth - (titleLeftMargin + titleRightMargin + transLeftMargin + transRightMargin), + __pTitleTextObject->GetTotalHeight()); + + } + else + { + titleHeight = 0; + } + + // Text + r = SetFontInfo(FONT_STYLE_PLAIN, bodyTextSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r)); + + __pBodyTextObject = new (std::nothrow) TextObject(); + SysTryCatch(NID_UI_CTRL, __pBodyTextObject != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pBodyTextObject->Construct(); + + pSimpleTextForBodyText = new (std::nothrow) TextSimple(const_cast (__pMessageBox->GetText().GetPointer()), + __pMessageBox->GetText().GetLength(), + TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_UI_CTRL, pSimpleTextForBodyText != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pBodyTextObject->AppendElement(*pSimpleTextForBodyText); + __pBodyTextObject->SetForegroundColor(__pMessageBox->GetTextColor(), 0, __pBodyTextObject->GetTextLength()); + __pBodyTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + __pBodyTextObject->SetFont(_pFont, 0, __pBodyTextObject->GetTextLength()); + __pBodyTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT); + __pBodyTextObject->SetBounds(Rectangle(textLeftMargin + transLeftMargin, + titleHeight + textTopMargin + transTopMargin, + defaultWidth - (textLeftMargin + textRightMargin + transLeftMargin + transRightMargin), + maxHeight - titleHeight)); + __pBodyTextObject->Compose(); + + __textObjHeight = __pBodyTextObject->GetTotalHeight(); + + // Text bounds + totalHeightExceptTextObj = titleHeight + (textTopMargin * 2) + bottomHeight + (transTopMargin + transBottomMargin); + tempHeight = maxHeight - (totalHeightExceptTextObj + __textObjHeight); + + __textObjHeight = (tempHeight > 0) ? __textObjHeight : __textObjHeight + tempHeight; + + __textBounds.SetBounds(textLeftMargin+ transLeftMargin, + titleHeight + textTopMargin + transTopMargin, + defaultWidth - (textLeftMargin + textRightMargin + transLeftMargin + transRightMargin), + __textObjHeight); + + __pBodyTextObject->SetBounds(__textBounds); + + // Scroll in Text + if (__pBodyTextObject->GetTotalHeight() > __textObjHeight) + { + int maxH = __pBodyTextObject->GetTotalHeight(); + + __pScroll = _Scroll::CreateScrollN(*__pMessageBox, + SCROLL_DIRECTION_VERTICAL, + true, + true, + false, + false, + __textObjHeight, + maxH, + 0); + + SysTryCatch(NID_UI_CTRL, __pScroll != null, , E_OUT_OF_MEMORY, "[E_SYSTEM] Failed to create the scroll."); + + __pMessageBox->AttachSystemChild(*__pScroll); + } + + r = CreateButtons(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete __pTitleTextObject; + __pTitleTextObject = null; + + delete __pBodyTextObject; + __pBodyTextObject = null; + + delete pSimpleTextForBodyText; + + SetLastResult(r); + return r; +} + +void +_MessageBoxPresenter::OnFontChanged(Font* pFont) +{ + _pFont = pFont; +} + +void +_MessageBoxPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = __fontStyle; + size = __fontSize; +} + +result +_MessageBoxPresenter::SetFontInfo(unsigned long style, int size) +{ + __fontStyle = style; + __fontSize = size; + + _pFont = __pMessageBox->GetFallbackFont(); + SysTryReturnResult(NID_UI_CTRL, _pFont != null, GetLastResult(), "Failed to get a font."); + + return E_SUCCESS; +} + +void +_MessageBoxPresenter::Draw(void) +{ + result r = E_SUCCESS; + + int defaultWidth = 0; + int titleHeight = 0; + int titleTextSize = 0; + int titleTopMargin = 0; + + int btnHeight = 0; + int btnTopMargin = 0; + int btnBottomMargin = 0; + + int textSize = 0; + int textTopMarginNoButton = 0; + int textTopMargin = 0; + + int transTopMargin = 0; + int transBottomMargin = 0; + int transLeftMargin = 0; + int transRightMargin = 0; + + GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, __pMessageBox->GetOrientation(), defaultWidth); + GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_HEIGHT, __pMessageBox->GetOrientation(), titleHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_SIZE, __pMessageBox->GetOrientation(), titleTextSize); + GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_TEXT_TOP_MARGIN, __pMessageBox->GetOrientation(), titleTopMargin); + + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_SIZE, __pMessageBox->GetOrientation(), textSize); + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN, __pMessageBox->GetOrientation(), textTopMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN_NO_BUTTON, __pMessageBox->GetOrientation(), textTopMarginNoButton); + + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, __pMessageBox->GetOrientation(), btnHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_TOP_MARGIN, __pMessageBox->GetOrientation(), btnTopMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_BOTTOM_MARGIN, __pMessageBox->GetOrientation(), btnBottomMargin); + + GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pMessageBox->GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, __pMessageBox->GetOrientation(), transBottomMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, __pMessageBox->GetOrientation(), transLeftMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, __pMessageBox->GetOrientation(), transRightMargin); + + Canvas* pCanvas = __pMessageBox->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, (pCanvas != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create canvas."); + + pCanvas->SetBackgroundColor(Color(0x00000000)); + pCanvas->Clear(); + + bool hasBgBitmap = (__pMessageBox->GetBackgroundBitmap() != null); + + int totalH = __pMessageBox->GetTotalHeight(); + + // Draw BG + if (hasBgBitmap == true) + { + Rectangle bounds(0, 0, defaultWidth, totalH); + + const Bitmap* pBackgroundBitmap = __pMessageBox->GetBackgroundBitmap(); + if (pBackgroundBitmap->IsNinePatchedBitmap() == true) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap); + } + else + { + pCanvas->DrawBitmap(bounds, *pBackgroundBitmap); + } + } + + // Draw Title + if (__pTitleTextObject != null) + { + r = SetFontInfo(FONT_STYLE_PLAIN, titleTextSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTitleTextObject->SetFont(_pFont, 0, __pTitleTextObject->GetTextLength()); + __pTitleTextObject->SetBounds(__titleBounds); + __pTitleTextObject->SetForegroundColor(__pMessageBox->GetTitleTextColor(), 0, __pTitleTextObject->GetTextLength()); + + __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + } + + // Draw Text + if (__pBodyTextObject != null) + { + r = SetFontInfo(FONT_STYLE_PLAIN, textSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pBodyTextObject->SetFont(_pFont, 0, __pBodyTextObject->GetTextLength()); + __pBodyTextObject->SetForegroundColor(__pMessageBox->GetTextColor(), 0, __pBodyTextObject->GetTextLength()); + + __pBodyTextObject->SetBounds(__textBounds); + if ((__pMessageBox->HasTitle() == false) && (__pMessageBox->GetMsgBoxStyle() == MSGBOX_STYLE_NONE)) + { + __textBounds.y = transTopMargin + textTopMarginNoButton; + __pBodyTextObject->SetBounds(__textBounds); + } + + __pBodyTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + } + + //fall thtrough +CATCH: + delete pCanvas; + + return; +} + +result +_MessageBoxPresenter::ShowAndWait(int& modalResult) +{ + result r = E_SUCCESS; + + for (int i = 0; i < __buttonNum; i++) + { + _ControlImpl* pImpl = _ControlImpl::GetInstance(*__pButtons[i]); + __pMessageBox->AttachChild(pImpl->GetCore()); + } + + r = __pMessageBox->Open(); + + if (__pMessageBox->GetMsgBoxStyle() == MSGBOX_STYLE_NONE) + { + __pMessageBox->SetTouchCapture(true); + } + else + { + __pMessageBox->SetTouchCapture(); + } + + ProcessEvent(); + + __pMessageBox->ReleaseTouchCapture(); + + __pMessageBox->Close(); + + + modalResult = GetReturnValue(); + + return r; +} + +void +_MessageBoxPresenter::ProcessEvent(void) +{ + _ControlHandle handle; + + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + if (pTouchManager) + { + _Control* pControl = pTouchManager->GetTouchControlSource(); + if (pControl) + { + pControl->SetEventReceivable(false); + } + } + + _ModalLoopManager::GetInstance()->BeginMainLoop(__pMessageBox->GetTimeout(), MSGBOX_RESULT_CLOSE); + + int exitCode = _ModalLoopManager::GetInstance()->GetLastExitCode(); + switch (exitCode) + { + case MSGBOX_BUTTON_CLICKED: + if (__pButtonListener->IsButtonClicked()) + { + handle = __pButtonListener->GetClickedButtonHandle(); + FindButtonAndResult(handle); + break; + } + // fall through + case _ModalLoopManager::MODAL_LOOP_EXIT_CODE_APP_TERMINATION: + case _ModalLoopManager::MODAL_LOOP_EXIT_CODE_CONTINUOUS_TERMINATION: + _ModalLoopManager::GetInstance()->EndMainLoop(exitCode, false); + break; + } + } + +result +_MessageBoxPresenter::CreateButtons(void) +{ + String buttonText[3]; + + switch (__pMessageBox->GetMsgBoxStyle()) + { + case MSGBOX_STYLE_NONE: + __buttonNum = 0; + break; + + case MSGBOX_STYLE_OK: + __buttonNum = 1; + GET_STRING_CONFIG(IDS_COM_SK_OK, buttonText[0]); + break; + + case MSGBOX_STYLE_CANCEL: + __buttonNum = 1; + GET_STRING_CONFIG(IDS_COM_SK_CANCEL, buttonText[0]); + break; + + case MSGBOX_STYLE_OKCANCEL: + __buttonNum = 2; + GET_STRING_CONFIG(IDS_COM_SK_OK, buttonText[0]); + GET_STRING_CONFIG(IDS_COM_SK_CANCEL, buttonText[1]); + break; + + case MSGBOX_STYLE_YESNO: + __buttonNum = 2; + GET_STRING_CONFIG(IDS_COM_SK_YES, buttonText[0]); + GET_STRING_CONFIG(IDS_COM_SK_NO, buttonText[1]); + break; + + case MSGBOX_STYLE_YESNOCANCEL: + __buttonNum = 3; + GET_STRING_CONFIG(IDS_COM_SK_YES, buttonText[0]); + GET_STRING_CONFIG(IDS_COM_SK_NO, buttonText[1]); + GET_STRING_CONFIG(IDS_COM_SK_CANCEL, buttonText[2]); + break; + + case MSGBOX_STYLE_ABORTRETRYIGNORE: + __buttonNum = 3; + GET_STRING_CONFIG(IDS_COM_SK_ABORT, buttonText[0]); + GET_STRING_CONFIG(IDS_COM_SK_RETRY, buttonText[1]); + GET_STRING_CONFIG(IDS_COM_SK_IGNORE, buttonText[2]); + break; + + case MSGBOX_STYLE_CANCELTRYCONTINUE: + __buttonNum = 3; + GET_STRING_CONFIG(IDS_COM_SK_CANCEL, buttonText[0]); + GET_STRING_CONFIG(IDS_COM_SK_TRY, buttonText[1]); + GET_STRING_CONFIG(IDS_COM_BODY_CONTINUE, buttonText[2]); + break; + + case MSGBOX_STYLE_RETRYCANCEL: + __buttonNum = 2; + GET_STRING_CONFIG(IDS_COM_SK_RETRY, buttonText[0]); + GET_STRING_CONFIG(IDS_COM_SK_CANCEL, buttonText[1]); + break; + + default: + break; + } + + __pButtonListener = new (std::nothrow) _MessageBoxButtonListener(); + SysTryReturn(NID_UI_CTRL, __pButtonListener != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = E_SUCCESS; + + for (int i = 0; i < __buttonNum; i++) + { + _ControlImpl* pImpl = null; + _Button* pButtonCore = null; + + __pButtons[i] = new (std::nothrow) Button(); + SysTryCatch(NID_UI_CTRL, __pButtons[i] != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pButtons[i]->Construct(CalculateButtonPositionAndSize(i)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pButtons[i]->SetText(buttonText[i]); + __pButtons[i]->AddTouchEventListener(*__pButtonListener); + + pImpl = _ControlImpl::GetInstance(*__pButtons[i]); + pButtonCore = dynamic_cast<_Button*>(&pImpl->GetCore()); + + if (pButtonCore != null) + { + pButtonCore->SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_INSENSITIVE); + } + } + + return r; + +CATCH: + delete __pButtonListener; + __pButtonListener = null; + + for (int i = 0; i < __buttonNum; i++) + { + delete __pButtons[i]; + __pButtons[i] = null; + } + + return r; +} + +Rectangle +_MessageBoxPresenter::CalculateButtonPositionAndSize(int buttonIndex) +{ + int x = 0; + int y = 0; + int w = 0; + int h = 0; + + int defaultWidth = 0; + int btnHeight = 0; + + int btnSideMargin1 = 0; + int btnSideMargin2 = 0; + int btnSideMargin3 = 0; + int btnTopMargin = 0; + + int btnGap = 0; + int textTopMargin = 0; + + int titleHeight = 0; + int transTopMargin = 0; + + GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, __pMessageBox->GetOrientation(), defaultWidth); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, __pMessageBox->GetOrientation(), btnHeight); + + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_SIDE_MARGIN_01, __pMessageBox->GetOrientation(), btnSideMargin1); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_SIDE_MARGIN_02, __pMessageBox->GetOrientation(), btnSideMargin2); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_SIDE_MARGIN_03, __pMessageBox->GetOrientation(), btnSideMargin3); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_TOP_MARGIN, __pMessageBox->GetOrientation(), btnTopMargin); + + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_INTERNAL_GAP, __pMessageBox->GetOrientation(), btnGap); + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_TOP_MRAGIN, __pMessageBox->GetOrientation(), textTopMargin); + + GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_HEIGHT, __pMessageBox->GetOrientation(), titleHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pMessageBox->GetOrientation(), transTopMargin); + + if (__pMessageBox->HasTitle() == false) + { + titleHeight = 0; + } + + switch (__buttonNum) + { + case 1: + w = defaultWidth - (btnSideMargin1 * 2); + h = btnHeight; + x = btnSideMargin1; + y = transTopMargin + titleHeight + (textTopMargin * 2) + __textObjHeight + btnTopMargin; + break; + + case 2: + w = (defaultWidth - (btnSideMargin2 * 2) - btnGap) / 2; + h = btnHeight; + x = btnSideMargin2 + (buttonIndex * (w + btnGap)); + y = transTopMargin + titleHeight + (textTopMargin * 2) + __textObjHeight + btnTopMargin; + break; + + case 3: + { + switch (buttonIndex) + { + case 0: + // fall through + case 1: + // fall through + case 2: + w = (defaultWidth - ((btnSideMargin3 + btnGap) * 2)) / 3; + h = btnHeight; + x = btnSideMargin3 + (buttonIndex * (w + btnGap)); + y = transTopMargin + titleHeight + (textTopMargin * 2) + __textObjHeight + btnTopMargin; + break; + } + break; + } + default: + break; + } + + return Rectangle(x, y, w, h); +} + +void +_MessageBoxPresenter::FindButtonAndResult(const _ControlHandle handle) +{ + int btnPos = -1; + + for (int i = 0; i < __buttonNum; i++) + { + _ControlImpl* pImpl = _ControlImpl::GetInstance(*__pButtons[i]); + if (pImpl->GetCore().GetHandle() == handle) + { + btnPos = i; + break; + } + } + + switch (__pMessageBox->GetMsgBoxStyle()) + { + case MSGBOX_STYLE_NONE: + SetReturnValue(MSGBOX_RESULT_CLOSE); + break; + + case MSGBOX_STYLE_OK: + SetReturnValue(MSGBOX_RESULT_OK); + break; + + case MSGBOX_STYLE_CANCEL: + SetReturnValue(MSGBOX_RESULT_CANCEL); + break; + + case MSGBOX_STYLE_OKCANCEL: + switch (btnPos) + { + case 0: + SetReturnValue(MSGBOX_RESULT_OK); + break; + + case 1: + SetReturnValue(MSGBOX_RESULT_CANCEL); + break; + } + break; + + case MSGBOX_STYLE_YESNO: + switch (btnPos) + { + case 0: + SetReturnValue(MSGBOX_RESULT_YES); + break; + + case 1: + SetReturnValue(MSGBOX_RESULT_NO); + break; + } + break; + + case MSGBOX_STYLE_YESNOCANCEL: + switch (btnPos) + { + case 0: + SetReturnValue(MSGBOX_RESULT_YES); + break; + + case 1: + SetReturnValue(MSGBOX_RESULT_NO); + break; + + case 2: + SetReturnValue(MSGBOX_RESULT_CANCEL); + break; + } + break; + + case MSGBOX_STYLE_ABORTRETRYIGNORE: + switch (btnPos) + { + case 0: + SetReturnValue(MSGBOX_RESULT_ABORT); + break; + + case 1: + SetReturnValue(MSGBOX_RESULT_RETRY); + break; + + case 2: + SetReturnValue(MSGBOX_RESULT_IGNORE); + break; + } + break; + + case MSGBOX_STYLE_CANCELTRYCONTINUE: + switch (btnPos) + { + case 0: + SetReturnValue(MSGBOX_RESULT_CANCEL); + break; + + case 1: + SetReturnValue(MSGBOX_RESULT_TRY); + break; + + case 2: + SetReturnValue(MSGBOX_RESULT_CONTINUE); + break; + } + break; + + case MSGBOX_STYLE_RETRYCANCEL: + switch (btnPos) + { + case 0: + SetReturnValue(MSGBOX_RESULT_RETRY); + break; + + case 1: + SetReturnValue(MSGBOX_RESULT_CANCEL); + break; + } + break; + + default: + break; + } +} + +int +_MessageBoxPresenter::CalculateButtonAreaHeight(void) +{ + int btnHeight = 0; + + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, __pMessageBox->GetOrientation(), btnHeight); + + switch (__pMessageBox->GetMsgBoxStyle()) + { + case MSGBOX_STYLE_NONE: + return 0; + + case MSGBOX_STYLE_OK: + // fall through + case MSGBOX_STYLE_CANCEL: + // fall through + case MSGBOX_STYLE_OKCANCEL: + // fall through + case MSGBOX_STYLE_YESNO: + // fall through + case MSGBOX_STYLE_RETRYCANCEL: + // fall through + case MSGBOX_STYLE_YESNOCANCEL: + // fall through + case MSGBOX_STYLE_ABORTRETRYIGNORE: + // fall through + case MSGBOX_STYLE_CANCELTRYCONTINUE: + return btnHeight; + } + + return -1; +} + +int +_MessageBoxPresenter::GetBodyTextHeight(void) const +{ + return (__pBodyTextObject == null) ? 0 : __pBodyTextObject->GetTotalHeight(); +} + +Rectangle +_MessageBoxPresenter::GetTitleBounds(void) const +{ + return __titleBounds; +} + +Rectangle +_MessageBoxPresenter::GetTextBounds(void) const +{ + return __textBounds; +} + +void +_MessageBoxPresenter::SetReturnValue(MessageBoxModalResult rtn) +{ + __msgboxResult = rtn; +} + +int +_MessageBoxPresenter::GetReturnValue(void) const +{ + return (int) __msgboxResult; +} + +result +_MessageBoxPresenter::OnAttachedToMainTree(void) +{ + result r = E_SUCCESS; + _AccessibilityElement* pTitleTextAccessibility = null; + + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return r; + } + + pTitleTextAccessibility = __pMessageBox->GetTitleTextAccessibilityElement(); + if ((pTitleTextAccessibility != null) && (__pTextAccessibilityElement != null)) + { + return r; + } + + _AccessibilityContainer* pContainer = __pMessageBox->GetAccessibilityContainer(); + if (pContainer != null) + { + int titleHeight = 0; + GET_SHAPE_CONFIG(MESSAGEBOX::TITLE_HEIGHT, __pMessageBox->GetOrientation(), titleHeight); + + if (pTitleTextAccessibility == null) + { + pTitleTextAccessibility = new (std::nothrow) _AccessibilityElement(true); + SysTryReturn(NID_UI_CTRL, pTitleTextAccessibility != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[E_OUT_OF_MEMORY] Memory allocation failed."); + + pTitleTextAccessibility->Construct(L"MessageBoxTitleText", __titleBounds); + pTitleTextAccessibility->SetLabel(__pMessageBox->GetTitleText()); + pTitleTextAccessibility->SetTrait(ACCESSIBILITY_TRAITS_TEXT_FIELD); + + pContainer->AddElement(*pTitleTextAccessibility); + } + + if (__pTextAccessibilityElement == null) + { + __pTextAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturn(NID_UI_CTRL, __pTextAccessibilityElement != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTextAccessibilityElement->Construct(L"MessageBoxText", __textBounds); + __pTextAccessibilityElement->SetLabel(__pMessageBox->GetText()); + __pTextAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_TEXT_FIELD); + + pContainer->AddElement(*__pTextAccessibilityElement); + } + + if (__pMessageBox->GetMsgBoxStyle() != MSGBOX_STYLE_NONE) + { + for (int i = 0; i < __buttonNum; i++) + { + _ControlImpl* pImpl = null; + _Button* pButtonCore = null; + + pImpl = _ControlImpl::GetInstance(*__pButtons[i]); + + pButtonCore = dynamic_cast<_Button*>(&pImpl->GetCore()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pButtonCore != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _AccessibilityContainer* pButtonContainer = pButtonCore->GetAccessibilityContainer(); + if (pButtonContainer != null) + { + _AccessibilityElement* pButtonElement = pButtonContainer->GetChildElement(L"ButtonText"); + if (pButtonElement != null) + { + String numberString = null; + numberString = Integer::ToString(i + 1); + + String buttonName = L"MessageBoxButton"; + buttonName.Append(numberString); + + pButtonElement->SetName(buttonName); + } + + // Add Container + pContainer->AddChildContainer(*pButtonContainer); + } + } + } + } + + return r; + +} + +bool +_MessageBoxPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + Point point = touchinfo.GetCurrentPosition(); + + Rectangle rect(0, 0, __pMessageBox->GetBounds().width, __pMessageBox->GetBounds().height); + + // Touch-event's starting point is MessageBox's leftTop + if (rect.Contains(touchinfo.GetCurrentPosition()) == false) + { + __touchOutBounds = true; + } + else + { + __touchOutBounds = false; + } + + __touchPressFlag = true; + + if ((__pScroll != null) && (__textBounds.Contains(touchinfo.GetCurrentPosition()) == true)) + { + __pScroll->SetScrollVisibility(true); + + __scrollStart = true; + } + + return true; +} + +bool +_MessageBoxPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__touchOutBounds == true) + { + if (__pMessageBox->GetMsgBoxStyle() == MSGBOX_STYLE_NONE) + { + SetReturnValue(MSGBOX_RESULT_CLOSE); + _ModalLoopManager::GetInstance()->EndMainLoop(MSGBOX_RESULT_CLOSE, false); + } + } + + if (__touchPressFlag == false) + { + __prevPositionY = -1; + + __scrollStart = false; + } + + if (__pScroll != null) + { + __pScroll->SetScrollVisibility(false); + } + + return true; +} + +bool +_MessageBoxPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + __touchOutBounds = false; + + if ((__pScroll != null) && (__scrollStart == true)) + { + int scrollAmountView = -1; + int scrollAmountData = -1; + int currentPosition = touchinfo.GetCurrentPosition().y; + + // TextObject + if (__prevPositionY == -1) + { + __prevPositionY = touchinfo.GetCurrentPosition().y; + } + + int distance = __prevPositionY - currentPosition; + + int newFirstDspY = __pBodyTextObject->GetFirstDisplayPositionY(); + newFirstDspY += distance; + + if (newFirstDspY < 0) + { + newFirstDspY = 0; + } + + if (newFirstDspY > __textBounds.height) + { + newFirstDspY = __textBounds.height; + } + + int moveLine = __pBodyTextObject->GetLineIndexAtPositionY(newFirstDspY); + + __pBodyTextObject->SetFirstDisplayLineIndex(moveLine); + __pBodyTextObject->SetFirstDisplayPositionY(newFirstDspY); + + // _Scroll + __pScroll->GetScrollRange(&scrollAmountView, &scrollAmountData); + __scrollPos += distance; + + if (__scrollPos < 0) + { + __scrollPos = 0; + } + else if (__scrollPos > scrollAmountView) + { + __scrollPos = scrollAmountView; + } + + __pScroll->SetScrollPosition(__scrollPos); + + __prevPositionY = currentPosition; + + __touchPressFlag = false; + + Draw(); + __pMessageBox->Show(); + } + + return true; + +} + + +//////////////////////////////////////////////////////////////////////// +///////////////////////////MsgBoxButtonListener///////////////////////// +//////////////////////////////////////////////////////////////////////// + +_MessageBoxPresenter::_MessageBoxButtonListener::_MessageBoxButtonListener(void) + : __buttonHandle() + , __buttonPressFlag(false) + , __buttonReleaseState(false) + , __point(0, 0) +{ + // empty statement +} + +_MessageBoxPresenter::_MessageBoxButtonListener::~_MessageBoxButtonListener(void) +{ + // empty statement +} + +_ControlHandle +_MessageBoxPresenter::_MessageBoxButtonListener::GetClickedButtonHandle(void) const +{ + return __buttonHandle; +} + +bool +_MessageBoxPresenter::_MessageBoxButtonListener::IsButtonClicked(void) +{ + return __buttonReleaseState; +} + +void +_MessageBoxPresenter::_MessageBoxButtonListener::OnTouchPressed(const Control& source, const Point& currentPosition, + const TouchEventInfo& touchInfo) +{ + __buttonPressFlag = true; + __buttonReleaseState = false; + + Point point = touchInfo.GetCurrentPosition(); + __point = point; +} + +void +_MessageBoxPresenter::_MessageBoxButtonListener::OnTouchMoved(const Control& source, const Point& currentPosition, + const TouchEventInfo& touchInfo) +{ + Point point = touchInfo.GetCurrentPosition(); + + __buttonPressFlag = false; +} + +void +_MessageBoxPresenter::_MessageBoxButtonListener::OnTouchReleased(const Control& source, const Point& currentPosition, + const TouchEventInfo& touchInfo) +{ + if (__buttonPressFlag == true) + { + __buttonHandle = _ControlImpl::GetInstance(source)->GetCore().GetHandle(); + SysTryReturnVoidResult(NID_UI_CTRL, __buttonHandle.IsValid() == true, E_SYSTEM, "[E_SYSTEM] Button's Handle is invalid"); + + __buttonPressFlag = false; + __buttonReleaseState = true; + + _ModalLoopManager::GetInstance()->EndMainLoop(MSGBOX_BUTTON_CLICKED, false); + + return; + } +} + + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_OptionMenu.cpp b/src/ui/controls/FUiCtrl_OptionMenu.cpp new file mode 100644 index 0000000..5ef3ff9 --- /dev/null +++ b/src/ui/controls/FUiCtrl_OptionMenu.cpp @@ -0,0 +1,642 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OptionMenu.cpp + * @brief This is the implementation file for the _OptionMenu class. + */ + +#include + +#include "FUiCtrl_OptionMenu.h" +#include "FUiCtrl_OptionMenuPresenter.h" +#include "FUiCtrl_ActionEvent.h" +#include "FUiCtrl_ContextMenu.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_Form.h" +#include "FUiAnim_VisualElement.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_OptionMenu::_OptionMenu(void) + : _Window() + , __pOptionMenuPresenter(null) + , __pActionEvent(null) + , __pSubMenu(null) + , __subMenuIndex(-1) +{ +} + +_OptionMenu::~_OptionMenu(void) +{ + delete __pOptionMenuPresenter; + __pOptionMenuPresenter = null; + + if (__pActionEvent != null) + { + delete __pActionEvent; + __pActionEvent = null; + } + + if (__pSubMenu != null) + { + __pSubMenu->Close(); + delete __pSubMenu; + __pSubMenu = null; + } + + RemoveAllAccessibilityElement(); +} + +_OptionMenu* +_OptionMenu::CreateOptionMenuN(void) +{ + _OptionMenu* pOptionMenu = new (std::nothrow) _OptionMenu; + SysTryReturn(NID_UI_CTRL, (pOptionMenu != null), null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(r)); + +#if defined(MULTI_WINDOW) + r = pOptionMenu->CreateRootVisualElement(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); +#endif + + pOptionMenu->AcquireHandle(); + + SysTryCatch(NID_UI_CTRL, (pOptionMenu->GetVisualElement() != null), , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _VisualElement instance."); + + pOptionMenu->__pOptionMenuPresenter = _OptionMenuPresenter::CreateInstanceN(*pOptionMenu); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pOptionMenu->__pOptionMenuPresenter != null), , r, + "[%s] Propagating.", GetErrorMessage(r)); + + r = pOptionMenu->__pOptionMenuPresenter->InitializeTextObject(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pOptionMenu->__pOptionMenuPresenter->InitializeVisualElement(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pOptionMenu->__pActionEvent = _ActionEvent::CreateInstanceN(*pOptionMenu); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pOptionMenu->__pActionEvent != null), , r, + "[%s] Propagating.", GetErrorMessage(r)); + + // Set alpha merge to VisualElement + pOptionMenu->GetVisualElement()->SetSurfaceOpaque(false); + pOptionMenu->SetBackgroundColor(Color()); + + pOptionMenu->SetMovable(false); + pOptionMenu->SetResizable(false); + + if (pOptionMenu->GetAccessibilityContainer() != null) + { + pOptionMenu->GetAccessibilityContainer()->Activate(true); + } + + return pOptionMenu; +CATCH: + delete pOptionMenu; + return null; +} + +result +_OptionMenu::AddActionEventListener(const _IActionEventListener& listener) +{ + return __pActionEvent->AddListener(listener); +} + +result +_OptionMenu::RemoveActionEventListener(const _IActionEventListener& listener) +{ + return __pActionEvent->RemoveListener(listener); +} + +result +_OptionMenu::FireActionEvent(int actionId) +{ + IEventArg* pArg = _ActionEvent::CreateActionEventArgN(actionId); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pArg != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pActionEvent->Fire(*pArg); + + return r; +} + +result +_OptionMenu::AddItem(const String& text, int actionId) +{ + result r = __pOptionMenuPresenter->AddItem(text, actionId); + + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return r; + } + + if (r == E_SUCCESS) + { + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer != null) + { + _AccessibilityElement* pElement = new (std::nothrow) _AccessibilityElement(true); + if (pElement != null) + { + pElement->SetLabel(text); + pElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON); + pElement->SetHint(L"Double tap to select"); +// pElement->SetTrait(ACCESSIBILITY_TRAITS_OPTIONMENU); + pContainer->AddElement(*pElement); + __accessibilityElements.Add(pElement); + SetBoundsAllAccessibilityElement(); + } + } + } + + return r; +} + +result +_OptionMenu::InsertItemAt(int mainIndex, const String& text, int actionId) +{ + result r = __pOptionMenuPresenter->InsertItemAt(mainIndex, text, actionId); + + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return r; + } + + if (r == E_SUCCESS) + { + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer != null) + { + _AccessibilityElement* pElement = new (std::nothrow) _AccessibilityElement(true); + if (pElement != null) + { + pElement->SetLabel(text); + pElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON); + pElement->SetHint(L"Double tap to select"); +// pElement->SetTrait(ACCESSIBILITY_TRAITS_OPTIONMENU); + pContainer->InsertElement(*pElement, mainIndex); + __accessibilityElements.InsertAt(pElement, mainIndex); + SetBoundsAllAccessibilityElement(); + } + } + } + + return r; +} + +result +_OptionMenu::SetItemAt(int mainIndex, const String& text, int actionId) +{ + result r = __pOptionMenuPresenter->SetItemAt(mainIndex, text, actionId); + + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return r; + } + + if (r == E_SUCCESS) + { + _AccessibilityElement* pElement = GetAccessibilityElement(mainIndex); + if (pElement != null) + { + pElement->SetLabel(text); + } + } + + return r; +} + +result +_OptionMenu::RemoveItemAt(int mainIndex) +{ + result r = __pOptionMenuPresenter->RemoveItemAt(mainIndex); + + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return r; + } + + if (r == E_SUCCESS) + { + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer != null) + { + _AccessibilityElement* pElement = GetAccessibilityElement(mainIndex); + if (pElement != null) + { + pContainer->RemoveElement(*pElement); + __accessibilityElements.RemoveAt(mainIndex); + SetBoundsAllAccessibilityElement(); + } + } + } + + return r; +} + +int +_OptionMenu::GetItemCount(void) const +{ + return __pOptionMenuPresenter->GetItemCount(); +} + +int +_OptionMenu::GetItemIndexFromActionId(int actionId) const +{ + return __pOptionMenuPresenter->GetItemIndexFromActionId(actionId); +} + +int +_OptionMenu::GetItemActionIdAt(int mainIndex) const +{ + return __pOptionMenuPresenter->GetItemActionIdAt(mainIndex); +} + +result +_OptionMenu::AddSubItem(int mainIndex, const String& text, int actionId) +{ + result r = __pOptionMenuPresenter->AddSubItem(mainIndex, text, actionId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pSubMenu != null && mainIndex == __subMenuIndex) + { + __pSubMenu->AddItem(text, actionId, null, null, null); + } + return E_SUCCESS; +} + +result +_OptionMenu::InsertSubItemAt(int mainIndex, int subIndex, const String& text, int actionId) +{ + result r = __pOptionMenuPresenter->InsertSubItemAt(mainIndex, subIndex, text, actionId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pSubMenu != null && mainIndex == __subMenuIndex) + { + __pSubMenu->InsertItem(subIndex, text, actionId, null, null, null); + } + + return E_SUCCESS; +} + +result +_OptionMenu::SetSubItemAt(int mainIndex, int subIndex, const String& text, int actionId) +{ + result r = __pOptionMenuPresenter->SetSubItemAt(mainIndex, subIndex, text, actionId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pSubMenu != null && mainIndex == __subMenuIndex) + { + __pSubMenu->SetItem(subIndex, text, actionId, null, null, null); + } + + return E_SUCCESS; +} + +result +_OptionMenu::RemoveSubItemAt(int mainIndex, int subIndex) +{ + result r = __pOptionMenuPresenter->RemoveSubItemAt(mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pSubMenu != null && mainIndex == __subMenuIndex) + { + __pSubMenu->RemoveItemAt(subIndex); + } + + return E_SUCCESS; +} + +int +_OptionMenu::GetSubItemCount(int mainIndex) const +{ + return __pOptionMenuPresenter->GetSubItemCount(mainIndex); +} + +int +_OptionMenu::GetSubItemIndexFromActionId(int actionId) const +{ + return __pOptionMenuPresenter->GetSubItemIndexFromActionId(actionId); +} + +int +_OptionMenu::GetSubItemActionIdAt(int mainIndex, int subIndex) const +{ + return __pOptionMenuPresenter->GetSubItemActionIdAt(mainIndex, subIndex); +} + +bool +_OptionMenu::IsSubMenuShown(void) const +{ + return (__pSubMenu != null) && __pSubMenu->IsAttached(); +} + +result +_OptionMenu::ShowSubMenu(int mainIndex, _OptionMenuItem& item) +{ + if (__pSubMenu != null) + { + DestroySubMenu(); + } + + int textSize = 0; + Font* pFont = __pOptionMenuPresenter->GetFont(); + GET_SHAPE_CONFIG(OPTIONMENU::TEXT_SIZE, GetOrientation(), textSize); + + Rectangle itemBounds = __pOptionMenuPresenter->GetItemBounds(mainIndex); + Point anchorPosition(GetBounds().x + itemBounds.x + itemBounds.width / 2, + GetBounds().y + itemBounds.y + itemBounds.height / 2 - textSize / 2); + __pSubMenu = _ContextMenu::CreateContextMenuN(anchorPosition, + CONTEXT_MENU_CORE_STYLE_LIST, + CONTEXT_MENU_CORE_ALIGN_UP); + if (__pSubMenu == null) + { + return GetLastResult(); + } + + if (__pSubMenu->GetOwner() == null) + { + _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] This instance is not constructed."); + + _Form* pForm = pFrame->GetCurrentForm(); + if (pForm != null) + { + __pSubMenu->SetOwner(pForm); + } + else + { + __pSubMenu->SetOwner(pFrame); + } + } + + __pSubMenu->Initialize(); + __pSubMenu->AddActionEventListener(*this); + + _OptionMenuItem* pSubItem = null; + int subItemCount = item.GetSubItemCount(); + for (int subIndex = 0; subIndex < subItemCount; subIndex++) + { + pSubItem = item.GetSubItem(subIndex); + if (pSubItem != null) + { + __pSubMenu->AddItem(pSubItem->GetText(), pSubItem->GetActionId(), null, null, null); + } + } + + if (pFont != null) + { + __pSubMenu->SetFont(pFont->GetFaceName()); + } + + __pSubMenu->Open(); + SetTouchCapture(); + __subMenuIndex = mainIndex; + + return E_SUCCESS; +} + +result +_OptionMenu::DestroySubMenu(void) +{ + if (__pSubMenu == null) + { + return E_SYSTEM; + } + + __pSubMenu->Close(); + delete __pSubMenu; + __pSubMenu = null; + __subMenuIndex = -1; + + return E_SUCCESS; +} + +_AccessibilityElement* +_OptionMenu::GetAccessibilityElement(int mainIndex) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return null; + } + + _AccessibilityElement* pElement = null; + result r = E_SUCCESS; + + if(likely(!(_AccessibilityManager::IsActivated()))) + { + return null; + } + + r = __accessibilityElements.GetAt(mainIndex,pElement); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(r)); + return pElement; +} + +void +_OptionMenu::OnDraw() +{ + __pOptionMenuPresenter->Draw(); +} + +void +_OptionMenu::OnChangeLayout(_ControlOrientation orientation) +{ + __pOptionMenuPresenter->OnChangeLayout(orientation); +} + +void +_OptionMenu::OnBoundsChanged(void) +{ + SetBoundsAllAccessibilityElement(); +} + +result +_OptionMenu::OnAttachingToMainTree(const _Control* pParent) +{ + result r = __pOptionMenuPresenter->OnAttachingToMainTree(pParent); + if (r != E_SUCCESS) + { + return r; + } + + return _Window::OnAttachingToMainTree(pParent); +} + +result +_OptionMenu::OnAttachedToMainTree(void) +{ + __pOptionMenuPresenter->OnAttachedToMainTree(); + return E_SUCCESS; +} + +result +_OptionMenu::OnDetachingFromMainTree(void) +{ + __pOptionMenuPresenter->OnDetachingFromMainTree(); + + return _Window::OnDetachingFromMainTree(); +} + +void +_OptionMenu::OnVisibleStateChanged(void) +{ +#if defined(MULTI_WINDOW) + _Window::OnVisibleStateChanged(); +#endif + + __pOptionMenuPresenter->OnVisibleStateChanged(); +} + +void +_OptionMenu::OnActivated(void) +{ + _Window::OnActivated(); + + if (GetOwner() != null) + { + ChangeLayout(GetOwner()->GetOrientation()); + } + else + { + ChangeLayout(_ControlManager::GetInstance()->GetOrientation()); + } + + if (__pOptionMenuPresenter != null) + { + __pOptionMenuPresenter->CalculateBounds(); + + __pOptionMenuPresenter->PrepareAnimation(); + __pOptionMenuPresenter->SetOptionMenuVisibility(true); + } + + SetTouchCapture(); +} + +void +_OptionMenu::OnDeactivated(void) +{ + ReleaseTouchCapture(); + _Window::OnDeactivated(); +} + +void +_OptionMenu::OnFontChanged(Font* pFont) +{ + __pOptionMenuPresenter->OnFontChanged(pFont); + return; +} + +void +_OptionMenu::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pOptionMenuPresenter->OnFontInfoRequested(style, size); + return; +} + +bool +_OptionMenu::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pOptionMenuPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_OptionMenu::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pOptionMenuPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_OptionMenu::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pOptionMenuPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_OptionMenu::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pOptionMenuPresenter->OnTouchCanceled(source, touchinfo); +} + +void +_OptionMenu::OnActionPerformed(const _Control& source, int actionId) +{ + __pOptionMenuPresenter->OnActionPerformed(source, actionId); +} + +void +_OptionMenu::SetBoundsAllAccessibilityElement(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityElement* pElement = null; + IEnumeratorT<_AccessibilityElement*>* pEnumerator = __accessibilityElements.GetEnumeratorN(); + int index = 0; + while (pEnumerator->MoveNext() == E_SUCCESS) + { + if (pEnumerator->GetCurrent(pElement) == E_SUCCESS) + { + pElement->SetBounds(__pOptionMenuPresenter->GetItemBounds(index)); + } + index++; + } + delete pEnumerator; +} + +void +_OptionMenu::RemoveAllAccessibilityElement(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityElement* pElement = null; + while (__accessibilityElements.GetCount() > 0) + { + if ((__accessibilityElements.GetAt(0, pElement)) == E_SUCCESS) + { + __accessibilityElements.RemoveAt(0); + pElement->GetParent()->RemoveElement(*pElement); + } + else + { + __accessibilityElements.RemoveAt(0); + } + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_OptionMenuImpl.cpp b/src/ui/controls/FUiCtrl_OptionMenuImpl.cpp new file mode 100644 index 0000000..67898ca --- /dev/null +++ b/src/ui/controls/FUiCtrl_OptionMenuImpl.cpp @@ -0,0 +1,301 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OptionMenuImpl.cpp + * @brief This is the implementation file for the _OptionMenuImpl class. + */ + +#include +#include + +#include "FUiCtrl_OptionMenuImpl.h" +#include "FUiCtrl_PublicActionEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_OptionMenuImpl* +_OptionMenuImpl::GetInstance(OptionMenu& optionMenu) +{ + return static_cast<_OptionMenuImpl*>(optionMenu._pControlImpl); +} + +const _OptionMenuImpl* +_OptionMenuImpl::GetInstance(const OptionMenu& optionMenu) +{ + return static_cast(optionMenu._pControlImpl); +} + +_OptionMenuImpl::_OptionMenuImpl(OptionMenu* pPublic, _OptionMenu* pCore) + : _WindowImpl(pPublic, pCore) + , __pPublicActionEvent(null) +{ +} + +_OptionMenuImpl* +_OptionMenuImpl::CreateOptionMenuImplN(OptionMenu& control) +{ + ClearLastResult(); + + _OptionMenu* pCore = _OptionMenu::CreateOptionMenuN(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pCore != null), null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _OptionMenuImpl* pImpl = new (std::nothrow) _OptionMenuImpl(&control, pCore); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl->__pPublicActionEvent = _PublicActionEvent::CreateInstanceN(control); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pImpl->__pPublicActionEvent != null), , r, + "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddActionEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; + +CATCH: + delete pImpl; + return null; +} + +_OptionMenuImpl::~_OptionMenuImpl(void) +{ + if (__pPublicActionEvent != null) + { + delete __pPublicActionEvent; + __pPublicActionEvent = null; + } +} + +result +_OptionMenuImpl::AddActionEventListener(IActionEventListener& listener) +{ + ClearLastResult(); + + return __pPublicActionEvent->AddListener(listener); +} + +result +_OptionMenuImpl::RemoveActionEventListener(IActionEventListener& listener) +{ + ClearLastResult(); + + return __pPublicActionEvent->RemoveListener(listener); +} + +result +_OptionMenuImpl::AddItem(const String& text, int actionId) +{ + ClearLastResult(); + + return GetCore().AddItem(text, actionId); +} + +result +_OptionMenuImpl::InsertItemAt(int mainIndex, const String& text, int actionId) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex); + + return GetCore().InsertItemAt(mainIndex, text, actionId); +} + +result +_OptionMenuImpl::SetItemAt(int mainIndex, const String& text, int actionId) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex); + + return GetCore().SetItemAt(mainIndex, text, actionId); +} + +result +_OptionMenuImpl::RemoveItemAt(int mainIndex) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex); + + return GetCore().RemoveItemAt(mainIndex); +} + +int +_OptionMenuImpl::GetItemCount(void) const +{ + ClearLastResult(); + + return GetCore().GetItemCount(); +} + +int +_OptionMenuImpl::GetItemIndexFromActionId(int actionId) const +{ + ClearLastResult(); + + return GetCore().GetItemIndexFromActionId(actionId); +} + +int +_OptionMenuImpl::GetItemActionIdAt(int mainIndex) const +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex); + + return GetCore().GetItemActionIdAt(mainIndex); +} + +result +_OptionMenuImpl::AddSubItem(int mainIndex, const String& text, int actionId) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex); + + return GetCore().AddSubItem(mainIndex, text, actionId); +} + +result +_OptionMenuImpl::InsertSubItemAt(int mainIndex, int subIndex, const String& text, int actionId) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex); + SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified sub index (%d) is negative.", subIndex); + + return GetCore().InsertSubItemAt(mainIndex, subIndex, text, actionId); +} + +result +_OptionMenuImpl::SetSubItemAt(int mainIndex, int subIndex, const String& text, int actionId) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex); + SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified sub index (%d) is negative.", subIndex); + + return GetCore().SetSubItemAt(mainIndex, subIndex, text, actionId); +} + +result +_OptionMenuImpl::RemoveSubItemAt(int mainIndex, int subIndex) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex); + SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified sub index (%d) is negative.", subIndex); + + return GetCore().RemoveSubItemAt(mainIndex, subIndex); +} + +int +_OptionMenuImpl::GetSubItemCount(int mainIndex) const +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex); + + return GetCore().GetSubItemCount(mainIndex); +} + +int +_OptionMenuImpl::GetSubItemIndexFromActionId(int actionId) const +{ + ClearLastResult(); + + return GetCore().GetSubItemIndexFromActionId(actionId); +} + +int +_OptionMenuImpl::GetSubItemActionIdAt(int mainIndex, int subIndex) const +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex); + SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified sub index (%d) is negative.", subIndex); + + return GetCore().GetSubItemActionIdAt(mainIndex, subIndex); +} + +result +_OptionMenuImpl::OnAttachedToMainTree(void) +{ + SysTryReturn(NID_UI_CTRL, (GetCore().GetItemCount() > 0), E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] There is no item to show."); + + _WindowImpl::OnAttachedToMainTree(); + return E_SUCCESS; +} + +const char* +_OptionMenuImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::OptionMenu"; +} + +const OptionMenu& +_OptionMenuImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +OptionMenu& +_OptionMenuImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _OptionMenu& +_OptionMenuImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_OptionMenu& +_OptionMenuImpl::GetCore(void) +{ + return static_cast <_OptionMenu&>(_ControlImpl::GetCore()); +} + +void +_OptionMenuImpl::OnActionPerformed(const _Control& source, int actionId) +{ + if (__pPublicActionEvent != null) + { + IEventArg* pEventArg = _PublicActionEvent::CreateActionEventArgN(actionId); + if (pEventArg == null) + { + return; + } + + __pPublicActionEvent->Fire(*pEventArg); + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_OptionMenuItem.cpp b/src/ui/controls/FUiCtrl_OptionMenuItem.cpp new file mode 100644 index 0000000..c71816c --- /dev/null +++ b/src/ui/controls/FUiCtrl_OptionMenuItem.cpp @@ -0,0 +1,205 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OptionMenuItem.cpp + * @brief This is the implementation file for the _OptionMenuItem class. + */ + +#include +#include +#include + +#include "FUiCtrl_OptionMenuItem.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +const int MAX_SUB_ITEM_COUNT = 32; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_OptionMenuItem::_OptionMenuItem(void) + : __actionId(-1) + , __pSubItems(null) +{ +} + +_OptionMenuItem::~_OptionMenuItem(void) +{ + if (__pSubItems != null) + { + __pSubItems->RemoveAll(true); + delete __pSubItems; + __pSubItems = null; + } +} + +_OptionMenuItem* +_OptionMenuItem::CreateInstanceN(void) +{ + _OptionMenuItem* pItem = new (std::nothrow) _OptionMenuItem; + SysTryReturn(NID_UI_CTRL, (pItem != null), null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pItem; +} + +void +_OptionMenuItem::SetText(const String& text) +{ + __text = text; +} + +const String& +_OptionMenuItem::GetText(void) const +{ + return __text; +} + +void +_OptionMenuItem::SetActionId(int actionId) +{ + __actionId = actionId; +} + +int +_OptionMenuItem::GetActionId(void) const +{ + return __actionId; +} + +result +_OptionMenuItem::InsertSubItemAt(_OptionMenuItem& subItem, int index) +{ + if (__pSubItems == null) + { + __pSubItems = new (std::nothrow) ArrayList; + SysTryReturn(NID_UI_CTRL, (__pSubItems != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = __pSubItems->Construct(MAX_SUB_ITEM_COUNT); + if (r != E_SUCCESS) + { + delete __pSubItems; + __pSubItems = null; + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + } + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < MAX_SUB_ITEM_COUNT), null, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", index); + SysTryReturn(NID_UI_CTRL, (index <= __pSubItems->GetCount()), null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified index (%d) is greater than the available items count.", index); + + return __pSubItems->InsertAt(subItem, index); +} + +result +_OptionMenuItem::RemoveSubItemAt(int index) +{ + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < MAX_SUB_ITEM_COUNT), null, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", index); + SysTryReturn(NID_UI_CTRL, (__pSubItems != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The sub items list is null."); + SysTryReturn(NID_UI_CTRL, (index < __pSubItems->GetCount()), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified index (%d) is greater than the available items count.", index); + + return __pSubItems->RemoveAt(index, true); +} + +result +_OptionMenuItem::RemoveAllSubItem(void) +{ + SysTryReturn(NID_UI_CTRL, (__pSubItems != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The sub items list is null."); + + __pSubItems->RemoveAll(true); + return E_SUCCESS; +} + +_OptionMenuItem* +_OptionMenuItem::GetSubItem(int index) +{ + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < MAX_SUB_ITEM_COUNT), null, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", index); + SysTryReturn(NID_UI_CTRL, (__pSubItems != null), null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The sub items list is null.", index); + SysTryReturn(NID_UI_CTRL, (index < __pSubItems->GetCount()), null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified index (%d) is greater than the available items count.", index); + + return static_cast<_OptionMenuItem*>(__pSubItems->GetAt(index)); +} + +const _OptionMenuItem* +_OptionMenuItem::GetSubItem(int index) const +{ + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < MAX_SUB_ITEM_COUNT), null, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", index); + SysTryReturn(NID_UI_CTRL, (__pSubItems != null), null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The sub items list is null.", index); + SysTryReturn(NID_UI_CTRL, (index < __pSubItems->GetCount()), null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified index (%d) is greater than the available items count.", index); + + return static_cast(__pSubItems->GetAt(index)); +} + +int +_OptionMenuItem::GetSubItemCount(void) const +{ + if (__pSubItems == null) + { + return 0; + } + + return __pSubItems->GetCount(); +} + +int +_OptionMenuItem::GetSubItemIndexFromActionId(int actionId) const +{ + if (__pSubItems == null) + { + return -1; + } + + int index = 0; + int subItemCount = __pSubItems->GetCount(); + const _OptionMenuItem* pItem = null; + for (index = 0; index < subItemCount; index++) + { + pItem = static_cast(__pSubItems->GetAt(index)); + if (pItem != null) + { + if (pItem->__actionId == actionId) + { + return index; + } + } + } + + return -1; +} + +bool +_OptionMenuItem::HasSubItem(void) const +{ + return (__pSubItems != null && __pSubItems->GetCount() > 0); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_OptionMenuModel.cpp b/src/ui/controls/FUiCtrl_OptionMenuModel.cpp new file mode 100644 index 0000000..6a3178b --- /dev/null +++ b/src/ui/controls/FUiCtrl_OptionMenuModel.cpp @@ -0,0 +1,382 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OptionMenuModel.cpp + * @brief This is the implementation file for the _OptionMenuModel class. + */ + +#include +#include +#include + +#include "FUiCtrl_OptionMenuModel.h" +#include "FUiCtrl_OptionMenuItem.h" + +const int INVALID_INDEX = -1; +const int MAX_MAIN_ITEM_COUNT = 12; +const int MAX_SUB_ITEM_COUNT = 32; + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_OptionMenuModel::_OptionMenuModel(void) + : __items() +{ +} + +_OptionMenuModel::~_OptionMenuModel(void) +{ + __items.RemoveAll(true); +} + +_OptionMenuModel* +_OptionMenuModel::CreateInstanceN(void) +{ + _OptionMenuModel* pModel = new (std::nothrow) _OptionMenuModel; + SysTryReturn(NID_UI_CTRL, (pModel != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pModel->__items.Construct(MAX_MAIN_ITEM_COUNT); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pModel; + +CATCH: + delete pModel; + return null; +} + +result +_OptionMenuModel::AddItem(const String& text, int actionId, int mainIndex) +{ + SysTryReturn(NID_UI_CTRL, + (mainIndex >= INVALID_INDEX && mainIndex < MAX_MAIN_ITEM_COUNT), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", mainIndex); + SysTryReturn(NID_UI_CTRL, (mainIndex < __items.GetCount()), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified main index (%d) is greater than the available items count.", mainIndex); + + result r = E_SUCCESS; + _OptionMenuItem* pItem = null; + if (mainIndex == INVALID_INDEX) + { + // Add MainItem + SysTryReturn(NID_UI_CTRL, (__items.GetCount() < MAX_MAIN_ITEM_COUNT), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The option menu already has maximum number of items."); + SysTryReturn(NID_UI_CTRL, (GetItemIndexFromActionId(actionId) < 0), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The option menu already has an item with the same action id (%d).", actionId); + + pItem = _OptionMenuItem::CreateInstanceN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pItem->SetText(text); + pItem->SetActionId(actionId); + + r = __items.Add(*pItem); + if (r != E_SUCCESS) + { + delete pItem; + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + } + else + { + // Add SubItem + pItem = GetItem(mainIndex); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SysTryReturn(NID_UI_CTRL, (pItem->GetSubItemCount() < MAX_SUB_ITEM_COUNT), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The option menu already has maximum number of items."); + SysTryReturn(NID_UI_CTRL, (pItem->GetSubItemIndexFromActionId(actionId) < 0), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The option menu already has an item with the same action id (%d).", actionId); + + _OptionMenuItem* pSubItem = _OptionMenuItem::CreateInstanceN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pSubItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pSubItem->SetText(text); + pSubItem->SetActionId(actionId); + + r = pItem->InsertSubItemAt(*pSubItem, pItem->GetSubItemCount()); + if (r != E_SUCCESS) + { + delete pSubItem; + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + } + + return E_SUCCESS; +} + +result +_OptionMenuModel::InsertItemAt(const String& text, int actionId, int mainIndex, int subIndex) +{ + SysTryReturn(NID_UI_CTRL, + (mainIndex > INVALID_INDEX && mainIndex < MAX_MAIN_ITEM_COUNT), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", mainIndex); + SysTryReturn(NID_UI_CTRL, (mainIndex < __items.GetCount()), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified main index (%d) is greater than the available items count.", mainIndex); + + result r = E_SUCCESS; + _OptionMenuItem* pItem = null; + if (subIndex == INVALID_INDEX) + { + // Insert MainItem + SysTryReturn(NID_UI_CTRL, (__items.GetCount() < MAX_MAIN_ITEM_COUNT), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The option menu already has maximum number of items."); + SysTryReturn(NID_UI_CTRL, (GetItemIndexFromActionId(actionId) < 0), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The option menu already has an item with the same action id (%d).", actionId); + + pItem = _OptionMenuItem::CreateInstanceN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pItem->SetText(text); + pItem->SetActionId(actionId); + + r = __items.InsertAt(*pItem, mainIndex); + if (r != E_SUCCESS) + { + delete pItem; + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + } + else + { + // Insert SubItem + pItem = GetItem(mainIndex); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SysTryReturn(NID_UI_CTRL, (pItem->GetSubItemCount() < MAX_SUB_ITEM_COUNT), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The option menu already has maximum number of sub items."); + SysTryReturn(NID_UI_CTRL, + (subIndex > INVALID_INDEX && subIndex < MAX_SUB_ITEM_COUNT), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified sub index (%d) is out of range.", subIndex); + SysTryReturn(NID_UI_CTRL, (subIndex <= pItem->GetSubItemCount()), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified sub index (%d) is greater than the available items count.", subIndex); + SysTryReturn(NID_UI_CTRL, (pItem->GetSubItemIndexFromActionId(actionId) < 0), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The option menu already has an item with the same action id (%d).", actionId); + + _OptionMenuItem* pSubItem = _OptionMenuItem::CreateInstanceN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pSubItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pSubItem->SetText(text); + pSubItem->SetActionId(actionId); + + r = pItem->InsertSubItemAt(*pSubItem, subIndex); + if (r != E_SUCCESS) + { + delete pSubItem; + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + } + + return E_SUCCESS; +} + +result +_OptionMenuModel::SetItemAt(const String& text, int actionId, int mainIndex, int subIndex) +{ + _OptionMenuItem* pItem = GetItem(mainIndex, subIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (subIndex == INVALID_INDEX) + { + int index = GetItemIndexFromActionId(actionId); + SysTryReturn(NID_UI_CTRL, (index < 0 || mainIndex == index), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified actionId (%d) is not valid", actionId); + } + else + { + _OptionMenuItem* pMainItem = GetItem(mainIndex); + SysTryReturn(NID_UI_CTRL, (pMainItem != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified main index (%d) does not exists.", mainIndex); + int index = pMainItem->GetSubItemIndexFromActionId(actionId); + SysTryReturn(NID_UI_CTRL, (index < 0 || subIndex == index), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified actionId (%d) is not valid", actionId); + } + + pItem->SetText(text); + pItem->SetActionId(actionId); + + return E_SUCCESS; +} + +result +_OptionMenuModel::RemoveItemAt(int mainIndex, int subIndex) +{ + SysTryReturn(NID_UI_CTRL, + (mainIndex > INVALID_INDEX && mainIndex < MAX_MAIN_ITEM_COUNT), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is out of range.", mainIndex); + SysTryReturn(NID_UI_CTRL, (mainIndex < __items.GetCount()), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified main index (%d) is greater than the available items count.", mainIndex); + + if (subIndex == INVALID_INDEX) + { + // Remove MainItem + return __items.RemoveAt(mainIndex, true); + } + + // Remove SubItem + _OptionMenuItem* pItem = GetItem(mainIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SysTryReturn(NID_UI_CTRL, + (subIndex > INVALID_INDEX && subIndex < MAX_SUB_ITEM_COUNT), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified sub index (%d) is out of range.", subIndex); + SysTryReturn(NID_UI_CTRL, (subIndex < pItem->GetSubItemCount()), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified sub index (%d) is greater than the available sub items count.", subIndex); + + return pItem->RemoveSubItemAt(subIndex); +} + +result +_OptionMenuModel::RemoveAllItem(void) +{ + __items.RemoveAll(true); + return GetLastResult(); +} + +_OptionMenuItem* +_OptionMenuModel::GetItem(int mainIndex, int subIndex) +{ + SysTryReturn(NID_UI_CTRL, + (mainIndex > INVALID_INDEX && mainIndex < MAX_MAIN_ITEM_COUNT), null, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is out of range.", mainIndex); + SysTryReturn(NID_UI_CTRL, (mainIndex < __items.GetCount()), null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified main index (%d) is greater than the available items count.", mainIndex); + + _OptionMenuItem* pItem = static_cast <_OptionMenuItem*>(__items.GetAt(mainIndex)); + if (subIndex != INVALID_INDEX) + { + // Get SubItem + if (pItem == null) + { + return null; + } + + SysTryReturn(NID_UI_CTRL, + (subIndex > INVALID_INDEX && subIndex < MAX_SUB_ITEM_COUNT), null, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified sub index (%d) is out of range.", subIndex); + SysTryReturn(NID_UI_CTRL, (subIndex < pItem->GetSubItemCount()), null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified sub index (%d) is greater than the available sub items count.", subIndex); + + pItem = pItem->GetSubItem(subIndex); + } + + return pItem; +} + +const _OptionMenuItem* +_OptionMenuModel::GetItem(int mainIndex, int subIndex) const +{ + SysTryReturn(NID_UI_CTRL, + (mainIndex >= INVALID_INDEX && mainIndex < MAX_MAIN_ITEM_COUNT), null, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified main index (%d) is out of range.", mainIndex); + SysTryReturn(NID_UI_CTRL, (mainIndex < __items.GetCount()), null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified main index (%d) is greater than the available items count.", mainIndex); + + const _OptionMenuItem* pItem = static_cast (__items.GetAt(mainIndex)); + if (subIndex != INVALID_INDEX) + { + // Get SubItem + if (pItem == null) + { + return null; + } + + SysTryReturn(NID_UI_CTRL, + (subIndex > INVALID_INDEX && subIndex < MAX_SUB_ITEM_COUNT), null, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The specified sub index (%d) is out of range.", subIndex); + SysTryReturn(NID_UI_CTRL, (subIndex < pItem->GetSubItemCount()), null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The specified sub index (%d) is greater than the available sub items count.", subIndex); + + pItem = pItem->GetSubItem(subIndex); + } + + return pItem; +} + +int +_OptionMenuModel::GetItemCount(void) const +{ + return __items.GetCount(); +} + +int +_OptionMenuModel::GetItemIndexFromActionId(int actionId) const +{ + const _OptionMenuItem* pItem = null; + for (int mainIndex = 0; mainIndex < __items.GetCount(); mainIndex++) + { + pItem = static_cast(__items.GetAt(mainIndex)); + if (pItem != null) + { + if (pItem->GetActionId() == actionId) + { + return mainIndex; + } + } + } + + return -1; +} + +int +_OptionMenuModel::GetSubItemCount(int mainIndex) const +{ + const _OptionMenuItem* pItem = GetItem(mainIndex); + if (pItem == null) + { + return -1; + } + + return pItem->GetSubItemCount(); +} + +int +_OptionMenuModel::GetSubItemIndexFromActionId(int actionId, int& mainIndex) const +{ + const _OptionMenuItem* pMainItem = null; + int mainItemCount = __items.GetCount(); + for (int index = 0; index < mainItemCount; index++) + { + pMainItem = static_cast(__items.GetAt(index)); + if (pMainItem != null) + { + int subItemIndex = pMainItem->GetSubItemIndexFromActionId(actionId); + if (subItemIndex >= 0) + { + return subItemIndex; + } + } + } + + return -1; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_OptionMenuPresenter.cpp b/src/ui/controls/FUiCtrl_OptionMenuPresenter.cpp new file mode 100644 index 0000000..360583a --- /dev/null +++ b/src/ui/controls/FUiCtrl_OptionMenuPresenter.cpp @@ -0,0 +1,1426 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OptionMenuPresenter.cpp + * @brief This is the implementation file for the _OptionMenuPresenter class. + */ + +#include +#include +#include +#include +#include +#include +#include "FUiAnim_MatrixUtil.h" +#include "FUiCtrl_OptionMenuPresenter.h" +#include "FUiCtrl_OptionMenu.h" +#include "FUiCtrl_OptionMenuModel.h" +#include "FUiCtrl_OptionMenuItem.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_Form.h" +#include "FGrp_FontImpl.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_ControlManager.h" +#include "FUi_TouchManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +const int EFFECT_INTERVAL = 10; +const double EFFECT_CONSTANT = 0.075; + +namespace Tizen { namespace Ui { namespace Controls +{ + +float +SineThirtyThreeTimingFunction::CalculateProgress(float timeProgress) const +{ + const float segments[2][3] = {{0.0f, 0.050f, 0.495f}, {0.495f, 0.940f, 1.0f}}; + + float loc_5 = timeProgress; + int loc_6 = 2; //Length of the segments array + int loc_9 = (int)floor(loc_6 * loc_5); + + if (loc_9 >= loc_6) + { + loc_9 = loc_6 - 1; + } + + float loc_7 = (loc_5 - loc_9 * (1.0f / loc_6)) * loc_6; + + float loc_8[3]; + + for (int i = 0; i < 3; i++) + { + loc_8[i] = segments[loc_9][i]; + } + + float ret = 0 + 1 * (loc_8[0] + loc_7 * (2 * (1 - loc_7) * (loc_8[1] - loc_8[0]) + loc_7 * (loc_8[2] - loc_8[0]))); + + return ret; +} + +float +SineSixtyTimingFunction::CalculateProgress(float timeProgress) const +{ + const float segments[3][3] = {{0.0f, 0.01f, 0.37f}, {0.37f, 0.72f, 0.888f}, {0.888f, 0.9999f, 1.0f}}; + float loc_5 = timeProgress; + int loc_6 = 3; //Length of the segments array + int loc_9 = (int)floor(loc_6 * loc_5); + + if (loc_9 >= loc_6) + { + loc_9 = loc_6 - 1; + } + float loc_7 = (loc_5 - loc_9 * (1.0 / loc_6)) * loc_6; + float loc_8[3]; + + for (int i = 0; i < 3; i++) + { + loc_8[i] = segments[loc_9][i]; + } + + float ret = 0 + 1 * (loc_8[0] + loc_7 * (2 * (1 - loc_7) * (loc_8[1] - loc_8[0]) + loc_7 * (loc_8[2] - loc_8[0]))); + + return ret; +} + +_OptionMenuPresenter::_OptionMenuPresenter(_OptionMenu* optionMenu) + : __pOptionMenu(optionMenu) + , __pOptionMenuModel(null) + , __pItemBitmap(null) + , __pItemPressedBitmap(null) + , __pItemPressedEffectBitmap(null) + , __pArrowBitmap(null) + , __pArrowPressedBitmap(null) + , __pHandleBitmap(null) + , __pHandleEffectBitmap(null) + , __pHandlePressedBitmap(null) + , __pHandlePressedEffectBitmap(null) + , __pHandleArrowNormalBitmap(null) + , __pHandleArrowPressedBitmap(null) + , __textObject() + , __pFont(null) + , __maxColumnCount(0) + , __rowCount(0) + , __columnCount(0) + , __width(0) + , __handleHeight(0) + , __itemHeight(0) + , __lineWidth(0) + , __leftMargin(0) + , __rightMargin(0) + , __textSize(0) + , __textLeftMargin(0) + , __textRightMargin(0) + , __textTopMargin(0) + , __textBottomMargin(0) + , __arrowMargin(0) + , __selectedIndex(-1) + , __isHandlerPressed(false) + , __isClosing(false) + , __isAnimationStarted(true) + , __pOptionMenuVE(null) + , __pThirtyThreeTimingFunction(null) + , __pSixtyTimingFunction(null) +{ +} + +_OptionMenuPresenter::~_OptionMenuPresenter(void) +{ + __pOptionMenu = null; + + delete __pOptionMenuModel; + __pOptionMenuModel = null; + + delete __pItemBitmap; + __pItemBitmap = null; + + delete __pItemPressedBitmap; + __pItemPressedBitmap = null; + + delete __pItemPressedEffectBitmap; + __pItemPressedEffectBitmap = null; + + delete __pArrowBitmap; + __pArrowBitmap = null; + + delete __pArrowPressedBitmap; + __pArrowPressedBitmap = null; + + delete __pHandleBitmap; + __pHandleBitmap = null; + + delete __pHandleEffectBitmap; + __pHandleEffectBitmap = null; + + delete __pHandlePressedBitmap; + __pHandlePressedBitmap = null; + + delete __pHandlePressedEffectBitmap; + __pHandlePressedEffectBitmap = null; + + delete __pHandleArrowNormalBitmap; + __pHandleArrowNormalBitmap = null; + + delete __pHandleArrowPressedBitmap; + __pHandleArrowPressedBitmap = null; + + if (__pOptionMenuVE != null) + { + __pOptionMenuVE->RemoveAllAnimations(); + __pOptionMenuVE->SetAnimationProvider(null); + } + + delete __pThirtyThreeTimingFunction; + __pThirtyThreeTimingFunction = null; + + delete __pSixtyTimingFunction; + __pSixtyTimingFunction = null; +} + +_OptionMenuPresenter* +_OptionMenuPresenter::CreateInstanceN(_OptionMenu& optionMenu) +{ + result r = E_SUCCESS; + + _OptionMenuPresenter* pOptionMenuPresenter = new (std::nothrow) _OptionMenuPresenter(&optionMenu); + SysTryReturn(NID_UI_CTRL, (pOptionMenuPresenter != null), null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pOptionMenuPresenter->__pOptionMenuModel = _OptionMenuModel::CreateInstanceN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pOptionMenuPresenter->__pOptionMenuModel != null), , r, + "[%s] Propagating.", GetErrorMessage(r)); + + r = pOptionMenuPresenter->LoadBitmap(); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pOptionMenuPresenter->LoadShapeResource(optionMenu.GetOrientation()); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pOptionMenuPresenter; + +CATCH: + delete pOptionMenuPresenter; + return null; +} + +result +_OptionMenuPresenter::InitializeVisualElement(void) +{ + // matrix for scale-animation + _matrixOrigin.SetAsIdentity(); + _matrixScale.SetAsIdentity(); + + _MatrixUtilScale(_matrixScale, 1, 0.7, 1); + + __pOptionMenuVE = __pOptionMenu->GetVisualElement(); + + FloatPoint point(0.0f, 1.0f); + + __pOptionMenuVE->SetAnchor(point); + SysTryReturn(NID_UI_CTRL, __pOptionMenuVE != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get VisualElement."); + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::InitializeTextObject(void) +{ + result r = __textObject.Construct(); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + TextSimple* pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __textObject.AppendElement(*pSimpleText); + + // Create and initialize the Font. + __pFont = __pOptionMenu->GetFallbackFont(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pFont, r , r, "[%s] Propagating.", GetErrorMessage(r)); + + __textObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __textObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_CHARACTER); + __textObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __textObject.SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL); + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::AddItem(const String& text, int actionId) +{ + result r = __pOptionMenuModel->AddItem(text, actionId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::InsertItemAt(int mainIndex, const String& text, int actionId) +{ + result r = __pOptionMenuModel->InsertItemAt(text, actionId, mainIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::SetItemAt(int mainIndex, const String& text, int actionId) +{ + result r = __pOptionMenuModel->SetItemAt(text, actionId, mainIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::RemoveItemAt(int mainIndex) +{ + result r = __pOptionMenuModel->RemoveItemAt(mainIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +int +_OptionMenuPresenter::GetItemCount(void) const +{ + return __pOptionMenuModel->GetItemCount(); +} + +int +_OptionMenuPresenter::GetItemIndexFromActionId(int actionId) const +{ + return __pOptionMenuModel->GetItemIndexFromActionId(actionId); +} + +int +_OptionMenuPresenter::GetItemActionIdAt(int mainIndex) const +{ + _OptionMenuItem* pItem = __pOptionMenuModel->GetItem(mainIndex); + if (pItem == null) + { + return -1; + } + + return pItem->GetActionId(); +} + +result +_OptionMenuPresenter::AddSubItem(int mainIndex, const String& text, int actionId) +{ + result r = __pOptionMenuModel->AddItem(text, actionId, mainIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::InsertSubItemAt(int mainIndex, int subIndex, const String& text, int actionId) +{ + result r = __pOptionMenuModel->InsertItemAt(text, actionId, mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::SetSubItemAt(int mainIndex, int subIndex, const String& text, int actionId) +{ + result r = __pOptionMenuModel->SetItemAt(text, actionId, mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::RemoveSubItemAt(int mainIndex, int subIndex) +{ + result r = __pOptionMenuModel->RemoveItemAt(mainIndex, subIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +int +_OptionMenuPresenter::GetSubItemCount(int mainIndex) const +{ + return __pOptionMenuModel->GetSubItemCount(mainIndex); +} + +int +_OptionMenuPresenter::GetSubItemIndexFromActionId(int actionId) const +{ + int mainIndex = -1; + return __pOptionMenuModel->GetSubItemIndexFromActionId(actionId, mainIndex); +} + +int +_OptionMenuPresenter::GetSubItemActionIdAt(int mainIndex, int subIndex) const +{ + _OptionMenuItem* pItem = __pOptionMenuModel->GetItem(mainIndex, subIndex); + if (pItem == null) + { + return -1; + } + + return pItem->GetActionId(); +} + +result +_OptionMenuPresenter::Draw(void) +{ + CalculateBounds(); + + Canvas* pCanvas = __pOptionMenu->GetCanvasN(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pCanvas != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + DrawHandler(*pCanvas); + + // Draw Items + for (int index = __pOptionMenuModel->GetItemCount() - 1; index >= 0; index--) + { + DrawItem(*pCanvas, index); + } + DrawItemLine(*pCanvas); + + delete pCanvas; + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::DrawHandler(Canvas& canvas) +{ + result r = E_SUCCESS; + _ControlOrientation orientation = __pOptionMenu->GetOrientation(); + int arrowYPos = 0; + r = GET_SHAPE_CONFIG(OPTIONMENU::HANDLE_ARROW_Y_POSITION, orientation, arrowYPos); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Rectangle bounds = __pOptionMenu->GetBounds(); + bounds.x = 0; + bounds.y = 0; + + r = GET_SHAPE_CONFIG(OPTIONMENU::HANDLE_HEIGHT, orientation, bounds.height); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + canvas.SetBackgroundColor(Color(0x00000000)); + canvas.Clear(bounds); + + if (__isHandlerPressed == true) + { + // Draw Handle Pressed Bitmap + r = DrawResourceBitmap(canvas, bounds, __pHandlePressedBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Draw Handle Pressed Effect Bitmap + r = DrawResourceBitmap(canvas, bounds, __pHandlePressedEffectBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Draw Arrow for Handle + r = canvas.DrawBitmap(Point((bounds.width - __pHandleArrowPressedBitmap->GetWidth()) >> 1, arrowYPos), + *__pHandleArrowPressedBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + // Draw Handle Bitmap + r = DrawResourceBitmap(canvas, bounds, __pHandleBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Draw Handle Effect Bitmap + r = DrawResourceBitmap(canvas, bounds, __pHandleEffectBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Draw Arrow for Handle + r = canvas.DrawBitmap(Point((bounds.width - __pHandleArrowNormalBitmap->GetWidth()) >> 1, arrowYPos), + *__pHandleArrowNormalBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_OptionMenuPresenter::DrawItem(Canvas& canvas, int index) +{ + Rectangle bounds = GetItemBounds(index); + TextSimple* pSimpleText = null; + _OptionMenuItem* pItem = __pOptionMenuModel->GetItem(index); + SysTryReturn(NID_UI_CTRL, (pItem != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The item in specified index (%d) is null.", index); + + SysTryReturn (NID_UI_CTRL, (index != __selectedIndex || __pItemPressedBitmap != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to draw an item with index (%d).", index); + + // Draw Background of Item + SysTryReturn(NID_UI_CTRL, (__pItemBitmap != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to draw an item with index (%d).", index); + + result r = DrawResourceBitmap(canvas, bounds, __pItemBitmap); + if (r != E_SUCCESS) + { + return r; + } + + Color textColor; + _ControlOrientation orientation = __pOptionMenu->GetOrientation(); + if (index == __selectedIndex) + { + Rectangle pressedBounds = bounds; + int margin = 0; + + GET_FIXED_VALUE_CONFIG(OPTIONMENU::ITEM_PRESS_EDGE_MARGIN, orientation, margin); + if (pressedBounds.x == 0) + { + // Adjust left-edge + pressedBounds.x += margin; + pressedBounds.width -= margin; + } + + if ((pressedBounds.x + pressedBounds.width) == __width) + { + // Adjust right-edge + pressedBounds.width -= margin; + } + + GET_SHAPE_CONFIG(OPTIONMENU::ITEM_PRESS_LEFT_MARGIN, orientation, margin); + pressedBounds.x += margin; + pressedBounds.width -= margin; + + GET_SHAPE_CONFIG(OPTIONMENU::ITEM_PRESS_RIGHT_MARGIN, orientation, margin); + pressedBounds.width -= margin; + + GET_SHAPE_CONFIG(OPTIONMENU::ITEM_PRESS_TOP_MARGIN, orientation, margin); + pressedBounds.y += margin; + pressedBounds.height -= margin; + + GET_SHAPE_CONFIG(OPTIONMENU::ITEM_PRESS_BOTTOM_MARGIN, orientation, margin); + pressedBounds.height -= margin; + + DrawResourceBitmap(canvas, pressedBounds, __pItemPressedBitmap); + + DrawResourceBitmap(canvas, pressedBounds, __pItemPressedEffectBitmap); + + GET_COLOR_CONFIG(OPTIONMENU::ITEM_TEXT_PRESSED, textColor); + } + else + { + GET_COLOR_CONFIG(OPTIONMENU::ITEM_TEXT_NORMAL, textColor); + } + + __textObject.RemoveAll(); + pSimpleText = new (std::nothrow)TextSimple((wchar_t*)(pItem->GetText().GetPointer()), pItem->GetText().GetLength()); + if (pSimpleText != null) + { + __textObject.AppendElement(*pSimpleText); + } + __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength()); + __textObject.Compose(); + + int lineCount = __textObject.GetTotalLineCount(); + int textSize = __textSize; + + if (lineCount > 1) + { + textSize = textSize - 1; + } + + (_FontImpl::GetInstance(*__pFont))->SetSize(textSize); + + __textObject.SetFont(__pFont, 0, __textObject.GetTextLength()); + + // Draw Text + Rectangle textRect; + textRect.height = bounds.height - __textTopMargin - __textBottomMargin; + textRect.width = bounds.width - __leftMargin - __rightMargin - __textLeftMargin - __textRightMargin; + textRect.x = bounds.x + __leftMargin + __textLeftMargin; + textRect.y = bounds.y + ((bounds.height - textRect.height) / 2); + + if (pItem->HasSubItem() == true) + { + textRect.width -= __arrowMargin; + + // Draw Arrow if item has subItem + if (__pArrowBitmap != null) + { + Point arrowPosition(bounds.x + bounds.width - __arrowMargin - __rightMargin, + bounds.y + ((bounds.height - __pArrowBitmap->GetHeight()) / 2)); + + if (index == __selectedIndex) + { + canvas.DrawBitmap(arrowPosition, *__pArrowPressedBitmap); + } + else + { + canvas.DrawBitmap(arrowPosition, *__pArrowBitmap); + } + } + } + + __textObject.SetBounds(textRect); + __textObject.Draw(*_CanvasImpl::GetInstance(canvas)); + + _AccessibilityElement* pElement = __pOptionMenu->GetAccessibilityElement(index); + if (pElement != null) + { + pElement->SetBounds(bounds); + } + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::DrawItemLine(Canvas& canvas) +{ + if (__columnCount <= 0) + { + return E_SUCCESS; + } + + Color lineColor(0xFF8995AE); + int lineWidth = __lineWidth - 1; + Color lineColorEF(0xFFFFFFFF); + Color foreGroundColor = canvas.GetForegroundColor(); + GET_COLOR_CONFIG(OPTIONMENU::LINE, lineColor); + canvas.SetForegroundColor(lineColor); + canvas.SetLineStyle(LINE_STYLE_SOLID); + canvas.SetLineWidth(lineWidth); + + int rowHeight = __itemHeight + __lineWidth; + int x = 0; + int y = 0; + for (y = __handleHeight + (__rowCount - 1) * rowHeight - 1; y > __handleHeight; y -= rowHeight) + { + // Horizontal Line + canvas.SetForegroundColor(lineColor); + canvas.DrawLine(Point(0, y), Point(__width, y)); + canvas.SetForegroundColor(lineColorEF); + canvas.DrawLine(Point(0, y-1), Point(__width, y-1)); + + // Vertical Line + for (int column = 1; column < __columnCount; column++) + { + x = (__width - 1) * column / __columnCount; + canvas.SetForegroundColor(lineColor); + canvas.DrawLine(Point(x, y - __itemHeight), Point(x, y)); + canvas.SetForegroundColor(lineColorEF); + canvas.DrawLine(Point(x-1, y - __itemHeight), Point(x-1, y)); + } + } + + // Last-Row Vertical Line + int lastRowColumnCount = __pOptionMenuModel->GetItemCount() % __columnCount; + if (lastRowColumnCount == 0) + { + lastRowColumnCount = __columnCount; + } + + y = __handleHeight + (__rowCount - 1) * rowHeight - 1; + for (int column = 1; column < lastRowColumnCount; column++) + { + x = (__width - 1) * column / __columnCount; + canvas.SetForegroundColor(lineColor); + canvas.DrawLine(Point(x, y), Point(x, y + __itemHeight)); + canvas.SetForegroundColor(lineColorEF); + canvas.DrawLine(Point(x-1, y), Point(x-1, y + __itemHeight)); + + } + + canvas.SetForegroundColor(foreGroundColor); + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::RefreshItem(int index) +{ + if (index < 0 || index >= __pOptionMenuModel->GetItemCount()) + { + return E_OUT_OF_RANGE; + } + + Canvas* pCanvas = __pOptionMenu->GetCanvasN(); + if (pCanvas == null) + { + return GetLastResult(); + } + + result r = DrawItem(*pCanvas, index); + delete pCanvas; + + if (r == E_SUCCESS) + { + if (__pOptionMenu->GetVisualElement() != null) + { + __pOptionMenu->GetVisualElement()->SetFlushNeeded(); + } + } + + return r; +} + +result +_OptionMenuPresenter::LoadShapeResource(_ControlOrientation orientation) +{ + result r = E_SUCCESS; + + r = GET_FIXED_VALUE_CONFIG(OPTIONMENU::COLUMN_MAX, orientation, __maxColumnCount); + if (r != E_SUCCESS) + { + return r; + } + + r = GET_SHAPE_CONFIG(OPTIONMENU::HANDLE_HEIGHT, orientation, __handleHeight); + if (r != E_SUCCESS) + { + return r; + } + + r = GET_SHAPE_CONFIG(OPTIONMENU::ITEM_HEIGHT, orientation, __itemHeight); + if (r != E_SUCCESS) + { + return r; + } + + r = GET_FIXED_VALUE_CONFIG(OPTIONMENU::LINE_WIDTH, orientation, __lineWidth); + if (r != E_SUCCESS) + { + return r; + } + + r = GET_SHAPE_CONFIG(OPTIONMENU::LEFT_MARGIN, orientation, __leftMargin); + if (r != E_SUCCESS) + { + return r; + } + + r = GET_SHAPE_CONFIG(OPTIONMENU::RIGHT_MARGIN, orientation, __rightMargin); + if (r != E_SUCCESS) + { + return r; + } + + r = GET_SHAPE_CONFIG(OPTIONMENU::TEXT_SIZE, orientation, __textSize); + if (r != E_SUCCESS) + { + return r; + } + + r = GET_SHAPE_CONFIG(OPTIONMENU::TEXT_LEFT_MARGIN, orientation, __textLeftMargin); + if (r != E_SUCCESS) + { + return r; + } + + r = GET_SHAPE_CONFIG(OPTIONMENU::TEXT_RIGHT_MARGIN, orientation, __textRightMargin); + if (r != E_SUCCESS) + { + return r; + } + + r = GET_SHAPE_CONFIG(OPTIONMENU::TEXT_TOP_MARGIN, orientation, __textTopMargin); + if (r != E_SUCCESS) + { + return r; + } + + r = GET_SHAPE_CONFIG(OPTIONMENU::TEXT_BOTTOM_MARGIN, orientation, __textBottomMargin); + if (r != E_SUCCESS) + { + return r; + } + + r = GET_SHAPE_CONFIG(OPTIONMENU::ARROW_MARGIN, orientation, __arrowMargin); + if (r != E_SUCCESS) + { + return r; + } + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::CalculateBounds(void) +{ + _ControlManager *pManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI_CTRL, (pManager != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The _ControlManager instance is null."); + + Dimension screenSize = pManager->GetScreenSize(); + Rectangle bounds(0, 0, 0, __handleHeight); + + int itemCount = GetItemCount(); + if (itemCount > 0) + { + __rowCount = (itemCount - 1) / __maxColumnCount + 1; + if (__rowCount > 0) + { + __columnCount = itemCount / __rowCount; + if ((itemCount % __rowCount) > 0) + { + __columnCount++; + } + } + else + { + __rowCount = 0; + __columnCount = 0; + } + + bounds.height += (__itemHeight + __lineWidth) * __rowCount - __lineWidth; + } + + if ((__pOptionMenu != null) && (__pOptionMenu->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)) + { + bounds.width = screenSize.width; + bounds.y = screenSize.height - bounds.height; + } + else + { + bounds.width = screenSize.height; + bounds.y = screenSize.width - bounds.height; + } + __width = bounds.width; + + if ((__pOptionMenu != null) && (bounds.height != __pOptionMenu->GetBounds().height)) + { + __pOptionMenu->SetMovable(true); + __pOptionMenu->SetResizable(true); + + result r = __pOptionMenu->SetBounds(bounds); + if (r != E_SUCCESS) + { + return r; + } + + __pOptionMenu->SetMovable(false); + __pOptionMenu->SetResizable(false); + } + + + return E_SUCCESS; +} + +Rectangle +_OptionMenuPresenter::GetItemBounds(int index) const +{ + if (__columnCount <= 0) + { + return Rectangle(0, 0, 0, 0); + } + + int itemCount = __pOptionMenuModel->GetItemCount(); + int lastRowColumnCount = itemCount % __columnCount; + int row = index / __columnCount; + int column = index % __columnCount; + Rectangle bounds(0, __handleHeight + row * (__itemHeight + __lineWidth), 0, __itemHeight); + if ((row == (__rowCount - 1)) && (lastRowColumnCount != 0)) + { + // Calculate last row + bounds.x = column * __width / lastRowColumnCount; + column++; + bounds.width = column * __width / lastRowColumnCount - bounds.x; + + if (column < lastRowColumnCount) + { + bounds.width -= __lineWidth; + } + } + else + { + bounds.x = column * __width / __columnCount; + column++; + bounds.width = column * __width / __columnCount - bounds.x; + + if (column < __columnCount) + { + bounds.width -= __lineWidth; + } + } + + return bounds; +} + +int +_OptionMenuPresenter::GetItemIndexFromPosition(const Point& position) const +{ + if ((__columnCount <= 0) + || (__width <= 0) + || (position.y < __handleHeight) + || (position.y >= __pOptionMenu->GetBounds().height)) + { + return -1; + } + + int itemCount = __pOptionMenuModel->GetItemCount(); + int row = (position.y - __handleHeight) / (__itemHeight + __lineWidth); + if ((row == (__rowCount - 1)) && ((itemCount % __columnCount) != 0)) + { + return (row * __columnCount) + position.x * (itemCount % __columnCount) / __width; + } + + return (row * __columnCount) + position.x * __columnCount / __width; +} + +result +_OptionMenuPresenter::LoadBitmap(void) +{ + result r = E_SUCCESS; + Color color; + // Load Item Bitmap + r = GET_BITMAP_CONFIG_N(OPTIONMENU::ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pItemBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_COLOR_CONFIG(OPTIONMENU::ITEM_BG_NORMAL, color); + __pItemBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pItemBitmap, Color::GetColor(COLOR_ID_MAGENTA), color); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Load Item Pressed Bitmap + r = GET_BITMAP_CONFIG_N(OPTIONMENU::ITEM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pItemPressedBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_COLOR_CONFIG(OPTIONMENU::ITEM_BG_PRESSED, color); + __pItemPressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pItemPressedBitmap, Color::GetColor(COLOR_ID_MAGENTA), color); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Load Item Pressed + r = GET_BITMAP_CONFIG_N(OPTIONMENU::ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pItemPressedEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Load Arrow Bitmap + r = GET_BITMAP_CONFIG_N(OPTIONMENU::CONTEXTUAL_POPUP_ARROW, BITMAP_PIXEL_FORMAT_ARGB8888, __pArrowBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_COLOR_CONFIG(OPTIONMENU::ARROW_NORMAL, color); + __pArrowBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pArrowBitmap, Color::GetColor(COLOR_ID_MAGENTA), color); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + + // Load Arrow Pressed Bitmap + r = GET_BITMAP_CONFIG_N(OPTIONMENU::CONTEXTUAL_POPUP_ARROW, BITMAP_PIXEL_FORMAT_ARGB8888, __pArrowPressedBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + GET_COLOR_CONFIG(OPTIONMENU::ARROW_PRESSED, color); + __pArrowPressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pArrowPressedBitmap, Color::GetColor(COLOR_ID_MAGENTA), color); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Load Handle Bitmap + r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandleBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_COLOR_CONFIG(OPTIONMENU::HANDLE_NORMAL, color); + __pHandleBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pHandleBitmap, Color::GetColor(COLOR_ID_MAGENTA), color); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Load Handle Effect Bitmap + r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandleEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Load Handle Pressed Bitmap + r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlePressedBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_COLOR_CONFIG(OPTIONMENU::HANDLE_PRESSED, color); + __pHandlePressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pHandlePressedBitmap, Color::GetColor(COLOR_ID_MAGENTA), color); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + + // Load Handle Pressed Effect Bitmap + r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlePressedEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Load Handle Arrow Bitmap + r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_ARROW_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandleArrowNormalBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_ARROW_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandleArrowPressedBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +CATCH: + delete __pItemBitmap; + __pItemBitmap = null; + + delete __pItemPressedBitmap; + __pItemPressedBitmap = null; + + delete __pItemPressedEffectBitmap; + __pItemPressedEffectBitmap = null; + + delete __pArrowBitmap; + __pArrowBitmap = null; + + delete __pArrowPressedBitmap; + __pArrowPressedBitmap = null; + + delete __pHandleBitmap; + __pHandleBitmap = null; + + delete __pHandleEffectBitmap; + __pHandleEffectBitmap = null; + + delete __pHandlePressedBitmap; + __pHandlePressedBitmap = null; + + delete __pHandlePressedEffectBitmap; + __pHandlePressedEffectBitmap = null; + + return r; + +} + +result +_OptionMenuPresenter::PrepareAnimation(void) +{ + result r = E_SUCCESS; + + __pOptionMenuVE->SetAnimationProvider(this); + + r = __pOptionMenuVE->SetSurfaceOpaque(false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pOptionMenuVE->SetOpacity(0.0f); + __pOptionMenuVE->SetShowState(true); + + return r; +} + +result +_OptionMenuPresenter::SetOptionMenuVisibility(bool visibility) +{ + SysTryReturnResult(NID_UI_CTRL, __pOptionMenuVE != null, E_INVALID_STATE, "[E_INVALID_STATE] OptionMenu VisualElement instance is null."); + + result r = E_SUCCESS; + + if (visibility == true) + { + __pOptionMenuVE->SetTransformMatrix(_matrixScale); + + __pOptionMenuVE->SetImplicitAnimationEnabled(true); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pOptionMenuVE->SetTransformMatrix(_matrixOrigin); + __pOptionMenuVE->SetOpacity(1.0f); + + __pOptionMenuVE->SetImplicitAnimationEnabled(false); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pOptionMenuVE->SetTransformMatrix(_matrixOrigin); + __pOptionMenuVE->SetOpacity(1.0f); + + __pOptionMenuVE->SetImplicitAnimationEnabled(true); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pOptionMenuVE->SetTransformMatrix(_matrixScale); + __pOptionMenuVE->SetOpacity(0.0f); + + __pOptionMenuVE->SetImplicitAnimationEnabled(false); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; + +} + +VisualElementAnimation* +_OptionMenuPresenter::CreateAnimationForProperty(VisualElement& target, const String& property) +{ + VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property); + + if (pAnimation != null) + { + result r = E_SUCCESS; + + __isAnimationStarted = true; + + if (__pOptionMenuVE == (static_cast (&target))) + { + String opacity = L"opacity"; + + if (opacity == property) + { + r = pAnimation->SetDuration(333); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pThirtyThreeTimingFunction = new (std::nothrow) SineThirtyThreeTimingFunction(); + SysTryCatch(NID_UI_CTRL, (__pThirtyThreeTimingFunction != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pAnimation->SetTimingFunction(__pThirtyThreeTimingFunction); + } + else + { + r = pAnimation->SetDuration(333); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSixtyTimingFunction = new (std::nothrow) SineSixtyTimingFunction(); + SysTryCatch(NID_UI_CTRL, (__pSixtyTimingFunction != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pAnimation->SetTimingFunction(__pSixtyTimingFunction); + } + } + + pAnimation->SetVisualElementAnimationStatusEventListener(this); + } + + return pAnimation; + +CATCH: + delete pAnimation; + + return null; +} + +void +_OptionMenuPresenter::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target) +{ + return; +} + +void +_OptionMenuPresenter::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount) +{ + return; +} + +void +_OptionMenuPresenter::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pOptionMenuVE != null, E_INVALID_STATE, "[E_INVALID_STATE] OptionMenu VisualElement instance is null."); + + __isAnimationStarted = false; + + if (__pOptionMenuVE == (static_cast (&target))) + { + if (completedNormally == true) + { + __pOptionMenuVE->RemoveAllAnimations(); + __pOptionMenuVE->SetAnimationProvider(null); + + if (__isClosing) + { + __isClosing = false; + __pOptionMenu->Close(); + } + } + } + + return; +} + +void +_OptionMenuPresenter::Hide(void) +{ + __isClosing = true; + PrepareAnimation(); + SetOptionMenuVisibility(false); +} + +result +_OptionMenuPresenter::SetPosition(const Point& position) +{ + __pOptionMenu->SetMovable(true); + + result r = __pOptionMenu->SetPosition(position); + + __pOptionMenu->SetMovable(false); + + return r; +} + +void +_OptionMenuPresenter::OnChangeLayout(_ControlOrientation orientation) +{ + StopAnimation(); + LoadShapeResource(orientation); + CalculateBounds(); +} + +result +_OptionMenuPresenter::StopAnimation(void) +{ + if (__isAnimationStarted) + { + if (__isClosing) + { + __isClosing = false; + if (__pOptionMenu != null && __pOptionMenuVE != null) + { + __pOptionMenuVE->RemoveAllAnimations(); + __pOptionMenuVE->SetAnimationProvider(null); + + __pOptionMenu->Close(); + } + } + } + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::OnAttachingToMainTree(const _Control* pParent) +{ + if (__pOptionMenu->GetOwner() == null) + { + _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] This instance is not constructed."); + + _Form* pForm = pFrame->GetCurrentForm(); + if (pForm != null) + { + __pOptionMenu->SetOwner(pForm); + } + else + { + __pOptionMenu->SetOwner(pFrame); + } + } + + return E_SUCCESS; +} + +result +_OptionMenuPresenter::OnAttachedToMainTree(void) +{ + return E_SUCCESS; +} + +result +_OptionMenuPresenter::OnDetachingFromMainTree(void) +{ + __pOptionMenu->SetOwner(null); + return E_SUCCESS; +} + +void +_OptionMenuPresenter::OnVisibleStateChanged(void) +{ + if (__pOptionMenu->IsVisible() == true) + { + if (_ControlManager::GetInstance()->GetTopWindow() == __pOptionMenu) + { + __pOptionMenu->SetTouchCapture(); + } + } + else + { + _TouchManager* pManager = _TouchManager::GetInstance(); + if (pManager != null && pManager->GetCapturedControl() == __pOptionMenu) + { + __pOptionMenu->ReleaseTouchCapture(); + } + } +} + +bool +_OptionMenuPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pOptionMenu) + { + return false; + } + + if (__pOptionMenu->IsSubMenuShown() == true) + { + __pOptionMenu->DestroySubMenu(); + __pOptionMenu->SetTouchCapture(); + return true; + } + + Point position = touchinfo.GetCurrentPosition(); + __selectedIndex = GetItemIndexFromPosition(position); + if (__selectedIndex >= 0) + { + RefreshItem(__selectedIndex); + } + else if (__selectedIndex == -1 && position.y >= 0) + { + __isHandlerPressed = true; + __pOptionMenu->Draw(); + } + else + { + Hide(); + } + + return true; +} + +bool +_OptionMenuPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pOptionMenu) + { + return false; + } + + if (__isHandlerPressed == true) + { + __isHandlerPressed = false; + Hide(); + return true; + } + + if (__selectedIndex >= 0) + { + int selectedIndex = __selectedIndex; + __selectedIndex = -1; + RefreshItem(selectedIndex); + + _OptionMenuItem* pItem = __pOptionMenuModel->GetItem(selectedIndex); + if (pItem != null) + { + if (pItem->HasSubItem() == true) + { + // Show SubItem + __pOptionMenu->ShowSubMenu(selectedIndex, *pItem); + } + else + { + // Fire Action Event + Hide(); + __pOptionMenu->FireActionEvent(pItem->GetActionId()); + } + } + } + + return true; +} + +bool +_OptionMenuPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != __pOptionMenu) + { + return false; + } + + Point position = touchinfo.GetCurrentPosition(); + int selectedIndex = GetItemIndexFromPosition(position); + if (__isHandlerPressed == true) + { + if (selectedIndex >= 0 || position.y < 0) + { + __isHandlerPressed = false; + __pOptionMenu->Draw(); + } + return true; + } + + if (__selectedIndex >= 0) + { + if (selectedIndex != __selectedIndex) + { + selectedIndex = __selectedIndex; + __selectedIndex = -1; + RefreshItem(selectedIndex); + } + } + + return true; +} + +bool +_OptionMenuPresenter::OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo) +{ + if (&source != __pOptionMenu) + { + return false; + } + + __isHandlerPressed = false; + __selectedIndex = -1; + __pOptionMenu->Draw(); + + return true; +} + +void +_OptionMenuPresenter::OnActionPerformed(const _Control& source, int actionId) +{ + // for SubMenu Events + __pOptionMenu->DestroySubMenu(); + Hide(); + __pOptionMenu->FireActionEvent(actionId); +} + +void +_OptionMenuPresenter::OnFontChanged(Font* pFont) +{ + __pFont = pFont; + return; +} + +void +_OptionMenuPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = FONT_STYLE_PLAIN; + size = __textSize; + return; +} + +Font* +_OptionMenuPresenter::GetFont(void) const +{ + return __pFont; +} + +result +_OptionMenuPresenter::DrawResourceBitmap(Canvas& canvas, const Rectangle& bounds, Bitmap* pBitmap) +{ + result r = E_SUCCESS; + + if (pBitmap == null) + { + return r; + } + + if (pBitmap->IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = canvas.DrawBitmap(bounds, *pBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_OverlayAgent.cpp b/src/ui/controls/FUiCtrl_OverlayAgent.cpp new file mode 100644 index 0000000..0fd2472 --- /dev/null +++ b/src/ui/controls/FUiCtrl_OverlayAgent.cpp @@ -0,0 +1,1896 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OverlayAgent.cpp + * @brief This file contains implementation of _OverlayAgent class + */ + +#include +#include + +#define OVERLAY_PIXMAP_DUMP 0 + +#if OVERLAY_PIXMAP_DUMP + +extern "C" { + +#include +#include +#include + +#include +#include +#include +#define virtual UICTRL_INTERNAL_VIRTUAL_REDEFINE +#define private UICTRL_INTERNAL_PRIVATE_REDEFINE +#include +#undef virtual +#undef private +} +#endif + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "FUiCtrlOverlayRegion.h" +#include "FUi_CoordinateSystemUtils.h" +#include "FUi_Control.h" +#include "FUiCtrl_OverlayAgent.h" +#include "FUiAnim_EflNode.h" +#include "FUiAnim_ControlVisualElement.h" +#include "FUiAnim_VisualElementSurfaceImpl.h" +#include "FUiAnim_VisualElementImpl.h" + +#define B(c,s) ((((unsigned int)(c)) & 0xff) << (s)) +#define FOURCC(a,b,c,d) (B(d,24) | B(c,16) | B(b,8) | B(a,0)) + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::System; +using namespace Tizen::Media; +using namespace Tizen::Io; + +namespace +{ + +const int _ROTATION_0 = 0; +const int _ROTATION_90 = 90; +const int _ROTATION_180 = 180; +const int _ROTATION_270 = 270; +const int _ROTATION_360 = 360; + +const wchar_t* _UI_REGISTRY_PATH = L"/usr/etc/system-info.ini"; +const wchar_t* _UI_INFO_SESSION = L"UiControlInfo"; + +#if OVERLAY_PIXMAP_DUMP + +drm_slp_bufmgr gBufmgr = null; +int gFileCount = 0; + +static void +dump_bmp(const char* pFileName, const void* pData, int width, int height) +{ + int i = 0; + + struct + { + unsigned char magic[2]; + } bmpfile_magic = { {'B', 'M'} }; + + struct + { + unsigned int filesz; + unsigned short creator1; + unsigned short creator2; + unsigned int bmp_offset; + } bmpfile_header = { 0, 0, 0, 0x36 }; + + struct + { + unsigned int header_sz; + unsigned int width; + unsigned int height; + unsigned short nplanes; + unsigned short bitspp; + unsigned int compress_type; + unsigned int bmp_bytesz; + unsigned int hres; + unsigned int vres; + unsigned int ncolors; + unsigned int nimpcolors; + } bmp_dib_v3_header_t = { 0x28, 0, 0, 1, 24, 0, 0, 0, 0, 0, 0 }; + + unsigned int* pBlocks = null; + + FILE* pFile = fopen(pFileName, "w+"); + if (pFile == null) + { + SysLog(NID_UI_CTRL, "failed to fopen [%s]", pFileName); + return; + } + else + { + bmpfile_header.filesz = sizeof(bmpfile_magic) + sizeof(bmpfile_header) + sizeof(bmp_dib_v3_header_t) + width * height * 3; + bmp_dib_v3_header_t.header_sz = sizeof(bmp_dib_v3_header_t); + bmp_dib_v3_header_t.width = width; + bmp_dib_v3_header_t.height = -height; + bmp_dib_v3_header_t.nplanes = 1; + bmp_dib_v3_header_t.bmp_bytesz = width * height * 3; + + fwrite(&bmpfile_magic, sizeof(bmpfile_magic), 1, pFile); + fwrite(&bmpfile_header, sizeof(bmpfile_header), 1, pFile); + fwrite(&bmp_dib_v3_header_t, sizeof(bmp_dib_v3_header_t), 1, pFile); + + pBlocks = (unsigned int*)pData; + for (i = 0; i < (height * width); i++) + fwrite(&pBlocks[i], 3, 1, pFile); + + fclose(pFile); + } + + return; +} + +static drm_slp_bufmgr +bufmgr_get(Display* pDisplay, Pixmap pixmap) +{ + int screen; + int drm_fd; + drm_slp_bufmgr bufmgr; + int eventBase, errorBase; + int dri2Major, dri2Minor; + char* pDriverName, *pDeviceName; + drm_magic_t magic; + + screen = DefaultScreen(pDisplay); + + /* DRI2 */ + if (!DRI2QueryExtension (pDisplay, &eventBase, &errorBase)) + { + SysLog(NID_UI_CTRL, "!!Error : DRI2QueryExtension !!\n"); + return null; + } + + if (!DRI2QueryVersion (pDisplay, &dri2Major, &dri2Minor)) + { + SysLog(NID_UI_CTRL, "!!Error : DRI2QueryVersion !!\n"); + return null; + } + + if (!DRI2Connect (pDisplay, RootWindow(pDisplay, screen), &pDriverName, &pDeviceName)) + { + SysLog(NID_UI_CTRL, "!!Error : DRI2Connect !!\n"); + return null; + } + + SysLog(NID_UI_CTRL, "Open drm device : %s\n", pDeviceName); + + /* get the drm_fd though opening the deviceName */ + drm_fd = open (pDeviceName, O_RDWR); + if (drm_fd < 0) + { + SysLog(NID_UI_CTRL, "!!Error : cannot open drm device (%s)\n", pDeviceName); + return null; + } + + /* get the drm magic */ + drmGetMagic(drm_fd, &magic); + + if (!DRI2Authenticate(pDisplay, RootWindow(pDisplay, screen), magic)) + { + SysLog(NID_UI_CTRL, "!!Error : DRI2Authenticate !!\n"); + close (drm_fd); + return null; + } + + /* drm slp buffer manager init */ + bufmgr = drm_slp_bufmgr_init (drm_fd, null); + if (!bufmgr) + { + SysLog(NID_UI_CTRL, "!!Error : failed to init buffer manager \n"); + close (drm_fd); + return null; + } + + DRI2CreateDrawable (pDisplay, pixmap); + + return bufmgr; +} + +static void +pixmap_update (Display* pDisplay, drm_slp_bufmgr bufmgr, Pixmap pixmap, + int x, int y, int width, int height) +{ + DRI2Buffer* pDri2_buffers = null; + unsigned int attachments[1]; + int dri2_count, dri2_out_count; + int dri2_width, dri2_height, dri2_stride; + drm_slp_bo bo; + int opt; + void* pVirtualBuf = null; + char imgFile[100] = {0,}; + + attachments[0] = DRI2BufferFrontLeft; + dri2_count = 1; + pDri2_buffers = DRI2GetBuffers (pDisplay, pixmap, &dri2_width, &dri2_height, + attachments, dri2_count, &dri2_out_count); + + if (!pDri2_buffers) + { + SysLog(NID_UI_CTRL, "!!Error : failed to get buffers\n"); + goto update_done; + } + + if (!pDri2_buffers[0].name) + { + SysLog(NID_UI_CTRL, "!!Error : a handle of the dri2 buffer is null \n "); + goto update_done; + } + + SysLog(NID_UI_CTRL, "pDri2_buffers[0].name : %d", pDri2_buffers[0].name); + + bo = drm_slp_bo_import(bufmgr, pDri2_buffers[0].name); + if (!bo) + { + SysLog(NID_UI_CTRL, "!!Error : cannot import bo (key:%d)\n", pDri2_buffers[0].name); + goto update_done; + } + + dri2_stride = pDri2_buffers[0].pitch; + + opt = DRM_SLP_OPTION_READ|DRM_SLP_OPTION_WRITE; + pVirtualBuf = (void*)drm_slp_bo_map (bo, DRM_SLP_DEVICE_CPU, opt); + if (!pVirtualBuf) + { + SysLog(NID_UI_CTRL, "!!Error : failed to map \n"); + goto update_done; + } + + memset(imgFile, 0, sizeof(imgFile)); + sprintf(imgFile,"./dump%d.bmp", gFileCount++); + dump_bmp(imgFile, pVirtualBuf, dri2_width, dri2_height); + +update_done: + if (pVirtualBuf) + drm_slp_bo_unmap(bo, DRM_SLP_DEVICE_CPU); + if (bo) + drm_slp_bo_unref(bo); + if (pDri2_buffers) + free(pDri2_buffers); +} +#endif + +bool +_CheckXvExtension(Display* pDisplay, int* pFirstPort, int* pCountPort) +{ + unsigned int version = 0; + unsigned int release = 0; + unsigned int requestBase = 0; + unsigned int eventBase = 0; + unsigned int errorBase = 0; + unsigned int i = 0; + unsigned int adaptors = 0; + XvAdaptorInfo* pAdaptorInfo = null; + int ret = Success; + int port = -1; + + // query and print Xvideo properties + ret = XvQueryExtension(pDisplay, &version, &release, &requestBase, &eventBase, &errorBase); + if (ret != Success) + { + if (ret == XvBadExtension) + { + SysLog(NID_UI_CTRL, "XvBadExtension returned at XvQueryExtension!"); + } + else if (ret == XvBadAlloc) + { + SysLog(NID_UI_CTRL, "XvBadAlloc returned at XvQueryExtension!"); + } + else + { + SysLog(NID_UI_CTRL, "other error happened at XvQueryExtension!"); + } + + return false; + } + +// SysLog(NID_UI_CTRL, "========================================"); +// SysLog(NID_UI_CTRL, "XvQueryExtension returned the following:"); +// SysLog(NID_UI_CTRL, "version : %u", version); +// SysLog(NID_UI_CTRL, "release : %u", release); +// SysLog(NID_UI_CTRL, "request_base : %u", requestBase); +// SysLog(NID_UI_CTRL, "event_base : %u", eventBase); +// SysLog(NID_UI_CTRL, "error_base : %u", errorBase); +// SysLog(NID_UI_CTRL, "========================================"); + + ret = XvQueryAdaptors(pDisplay, DefaultRootWindow(pDisplay), &adaptors, &pAdaptorInfo); + if (ret != Success) + { + if (ret == XvBadExtension) + { + SysLog(NID_UI_CTRL, "XvBadExtension returned at XvQueryExtension."); + } + else if (ret == XvBadAlloc) + { + SysLog(NID_UI_CTRL, "XvBadAlloc returned at XvQueryExtension."); + } + else + { + SysLog(NID_UI_CTRL, "other error happaned at XvQueryAdaptors."); + } + + if (pAdaptorInfo != null) + { + XvFreeAdaptorInfo(pAdaptorInfo); + } + + return false; + } + +// SysLog(NID_UI_CTRL, "XvQueryAdaptors returned the following:"); +// SysLog(NID_UI_CTRL, "%d adaptors available.", adaptors); + + if (adaptors > 0 && pAdaptorInfo != null) + { + for (i = 0; i < adaptors; i++) + { + // SysLog(NID_UI_CTRL, " name: %s" + // " type: %s%s%s%s%s" + // " first port: %ld" + // " ports: %ld", + // pAdaptorInfo[i].name, + // (pAdaptorInfo[i].type & XvInputMask) ? "input | " : "", + // (pAdaptorInfo[i].type & XvOutputMask) ? "output | " : "", + // (pAdaptorInfo[i].type & XvVideoMask) ? "video | " : "", + // (pAdaptorInfo[i].type & XvStillMask) ? "still | " : "", + // (pAdaptorInfo[i].type & XvImageMask) ? "image | " : "", + // pAdaptorInfo[i].base_id, + // pAdaptorInfo[i].num_ports); + // + // SysLog(NID_UI_CTRL, " format list: %d", i); + + for (unsigned int j = 0; j < pAdaptorInfo[i].num_formats; j++) + { + SysLog(NID_UI_CTRL, "depth=%d, visual=%ld", + pAdaptorInfo[i].formats[j].depth, + pAdaptorInfo[i].formats[j].visual_id); + } + + } + + port = pAdaptorInfo[0].base_id; + + *pFirstPort = port; + *pCountPort = pAdaptorInfo[0].num_ports; + + SysLog(NID_UI_CTRL, "port : %d", port); + } + + if (pAdaptorInfo != null) + { + XvFreeAdaptorInfo(pAdaptorInfo); + } + + if (port == -1) + { + return false; + } + + return true; +} + +Tizen::Graphics::FloatRectangle +ConvertToFloat(const Rectangle& rect) +{ + return Tizen::Graphics::FloatRectangle((float) rect.x, (float) rect.y, (float) rect.width, (float) rect.height); +} + +Eina_Bool +OnPixmapDamaged(void* pData, int type, void* pEvent) +{ + Tizen::Ui::Controls::_OverlayAgent* pOverlayAgent = static_cast(pData); + + Ecore_X_Event_Damage* pDamageEvent = (Ecore_X_Event_Damage*)pEvent; + SysTryReturn(NID_UI_CTRL, pDamageEvent != null, ECORE_CALLBACK_PASS_ON, E_INVALID_DATA, "[E_INVALID_DATA] pDamageEvent is null."); + + Pixmap pixmap = pOverlayAgent->GetPixmap(); + if (pDamageEvent->drawable != pixmap) + { + SysLog(NID_UI_CTRL, "this drawable[%d] is not for my pixmap[%d]", pDamageEvent->drawable, pixmap); + return ECORE_CALLBACK_PASS_ON; + } + + int w = 0; + int h = 0; + Evas_Object* pImageObject = pOverlayAgent->GetPixmapImageObject(); + SysTryReturn(NID_UI_CTRL, pImageObject != null, ECORE_CALLBACK_PASS_ON, E_INVALID_DATA, "[E_INVALID_DATA] pImageObject is null."); + + evas_object_geometry_get(pImageObject, null, null, &w, &h); + //evas_object_image_pixels_dirty_set(pImageObject, 1); + evas_object_image_fill_set(pImageObject, 0, 0, w, h); + evas_object_image_data_update_add(pImageObject, 0, 0, w, h); + +#if OVERLAY_PIXMAP_DUMP + if (gBufmgr) + { + drm_slp_bufmgr_destroy(gBufmgr); + gBufmgr = null; + } + + if (gBufmgr == null) + gBufmgr = bufmgr_get((Display*)ecore_x_display_get(), pixmap); + + if (gBufmgr != null) + { + pixmap_update((Display*)ecore_x_display_get(), gBufmgr, pixmap, 0, 0, w, h); + } + else + SysLog(NID_UI_CTRL, "can't get pixmap gBufmgr"); + + SysLog(NID_UI_CTRL, "dump pixmap[%d]", pixmap); + +#endif + + return ECORE_CALLBACK_DONE; +} + +} // Anonymous + +namespace Tizen { namespace Ui { namespace Controls +{ + +int _OverlayAgent::overlayAgentcount = 0; +int _OverlayAgent::overlayAgentXvPortCount = 0; +int _OverlayAgent::baseXvPort = 0; +bool _OverlayAgent::isPortGrapped[]={false,}; + +int _OverlayAgent::dstRectMinWidth = -1; +int _OverlayAgent::dstRectMinHegith = -1; +int _OverlayAgent::srcRectMinWidth = -1; +int _OverlayAgent::srcRectMinHegith = -1; + +_OverlayAgent* +_OverlayAgent::CreateInstanceN(_OverlayAgentStyle style, const _Control& control, const Rectangle& phyBounds) +{ + _OverlayAgent* pOverlayAgent = new (std::nothrow) _OverlayAgent(style, control, phyBounds); + SysTryReturn(NID_UI_CTRL, pOverlayAgent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pOverlayAgent; + +CATCH: + delete pOverlayAgent; + return null; +} + +_OverlayAgent::_OverlayAgent(_OverlayAgentStyle style, const _Control& control, const Rectangle& bounds) + : __pImageObject(null) + , __pRenderImageObject(null) + , __pSmartObject(null) + , __pixmapDamageHandle(0) + , __pPixmapEventHandler(null) + , __pixmap(0) + , __pVisualElement(null) + , __bgColor(0xff000000) + , __xvPort(-1) + , __grabXvPort(false) + , __colorFormat(0) + , __userRotation(_ROTATION_0) + , __flushRotate(false) + , __udMirroring(0) + , __lrMirroring(0) + , __aspectRatio(false) + , __srcDimension(0, 0) + , __destDimension(0, 0) + , __pixmapPhyRect(0, 0, 0, 0) + , __resizeRect(0, 0, 0, 0) + , __style(style) + , __pXvImage(null) + , __newColorFormat(0) + , __pShmInfo(null) + , __overlayAgentColorFormat(_OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_ARGB8888) + , __pRefUserByteBuffer(null) + , __pOrgUserByteBuffer(null) + , __orgImgDimension(0, 0) +{ + result r = E_SUCCESS; + + switch(style) + { + case _OVERLAY_AGENT_STYLE_REGION_SW: + case _OVERLAY_AGENT_STYLE_REGION_GL: + r = CreateImageObjectForOverlayRegion(control, bounds); + break; + case _OVERLAY_AGENT_STYLE_PANEL_GL: + case _OVERLAY_AGENT_STYLE_PANEL_SW: + r = CreateImageObject(control, bounds); + break; + default: + r = E_INVALID_ARG; + } + + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_CTRL, __pVisualElement != null, E_SYSTEM, "[E_SYSTEM] __pVisualElement is null"); + + SetLastResult(E_SUCCESS); + + overlayAgentcount++; + + SysLog(NID_UI_CTRL, "Constructor: overlayAgentcount is [%d]", overlayAgentcount); +} + +_OverlayAgent::~_OverlayAgent(void) +{ + overlayAgentcount--; + + SysLog(NID_UI_CTRL, "Destructor: overlayAgentcount is [%d]", overlayAgentcount); + + UngrabXvPort(); + + if (__pPixmapEventHandler) + { + ecore_event_handler_del(__pPixmapEventHandler); + __pPixmapEventHandler = null; + } + + if (__pixmapDamageHandle) + { + ecore_x_damage_free(__pixmapDamageHandle); + __pixmapDamageHandle = 0; + } + + if (__pixmap != 0) + { + XFreePixmap((Display*)ecore_x_display_get(), __pixmap); + __pixmap = 0; + } + + if (__pShmInfo) + { + XShmDetach((Display*)ecore_x_display_get(), __pShmInfo); + shmdt(__pShmInfo->shmaddr); + shmctl(__pShmInfo->shmid, IPC_RMID, NULL); + __pShmInfo = null; + } + + if (__pXvImage) + { + XFree(__pXvImage); + __pXvImage = null; + } + + if (__pOrgUserByteBuffer) + { + delete __pOrgUserByteBuffer; + __pOrgUserByteBuffer = null; + } + + if (__pImageObject) + { + evas_object_smart_member_del(__pImageObject); + evas_object_del(__pImageObject); + __pImageObject = null; + } + + if (__pRenderImageObject) + { + evas_object_smart_member_del(__pRenderImageObject); + evas_object_del(__pRenderImageObject); + __pRenderImageObject = null; + } + + if ((__style == _OVERLAY_AGENT_STYLE_REGION_SW || __style == _OVERLAY_AGENT_STYLE_REGION_GL) + && (__pVisualElement != null)) + { + __pVisualElement->Destroy(); + __pVisualElement = null; + } + +#if OVERLAY_PIXMAP_DUMP + if (gBufmgr) + drm_slp_bufmgr_destroy (gBufmgr); +#endif + +} + +result +_OverlayAgent::Draw(void) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, __pRefUserByteBuffer->GetPointer() != null, r, "nothing to draw... userBuffer is null!"); + + if(__style == _OVERLAY_AGENT_STYLE_REGION_SW || __style == _OVERLAY_AGENT_STYLE_PANEL_SW) + r = PutEvasImage(); + else + r = PutXvImage(); + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r) ); + + return r; +} + + +result +_OverlayAgent::GetBufferInfo(BufferInfo& bufferInfo) const +{ + int w = 0, h = 0; + evas_object_geometry_get(__pImageObject, NULL, NULL, &w, &h); + + bufferInfo.width = w; + bufferInfo.pitch = w; + bufferInfo.height = h; + bufferInfo.bitsPerPixel = 32; + bufferInfo.pixelFormat = PIXEL_FORMAT_ARGB8888; + + _BufferInfoImpl* pBufferInfoImpl = _BufferInfoImpl::GetInstance(bufferInfo); + + if(__style == _OVERLAY_AGENT_STYLE_REGION_SW || __style == _OVERLAY_AGENT_STYLE_PANEL_SW) + { + pBufferInfoImpl->SetHandle(_BufferInfoImpl::HANDLE_TYPE_VE_SURFACE, reinterpret_cast(__pImageObject)); + SysLog(NID_UI_CTRL,"return evas image object"); + } + else + { + pBufferInfoImpl->SetHandle(_BufferInfoImpl::HANDLE_TYPE_OVERLAY_REGION, __pixmap); + SysLog(NID_UI_CTRL,"return pixmap ID"); + } + + pBufferInfoImpl->SetBounds(Rectangle(0, 0, w, h)); + + return E_SUCCESS; + +} + +result +_OverlayAgent::SetInputBuffer(const Dimension& destDim, const ByteBuffer& srcBuffer, + const Dimension& srcDim, _OverlayAgentBufferPixelFormat srcFormat) +{ + SysTryReturn(NID_UI_CTRL, srcBuffer.GetPointer() != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + SysTryReturn(NID_UI_CTRL, srcBuffer.GetCapacity() > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + SysTryReturn(NID_UI_CTRL, IsValidSourceDimension(srcDim), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + SysTryReturn(NID_UI_CTRL, IsValidDestinationDimension(destDim), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + + switch (srcFormat) + { + case _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_ARGB8888: + __newColorFormat = FOURCC('R','G','B','4'); + break; + case _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_RGB565: + __newColorFormat = FOURCC('R','G','B','P'); + break; + case _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR: + __newColorFormat = FOURCC('I','4','2','0'); + break; + case _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_NV12: + __newColorFormat = FOURCC('N','V','1','2'); + break; + case _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_UYVY: + __newColorFormat = FOURCC('U','Y','V','Y'); + break; + default: + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_FORMAT, "The specified pixel format is not supported."); + return E_UNSUPPORTED_FORMAT; + } + + __srcDimension.width = srcDim.width; + __srcDimension.height = srcDim.height; + + __destDimension.width = destDim.width; + __destDimension.height = destDim.height; + + __overlayAgentColorFormat = srcFormat; + __pRefUserByteBuffer = &srcBuffer; + + SysLog(NID_UI_CTRL,"pBuffer : %x, size : %d, __newColorFormat : %x", __pRefUserByteBuffer->GetPointer(), __pRefUserByteBuffer->GetCapacity(), __newColorFormat); + + return E_SUCCESS; +} + +result +_OverlayAgent::SetRotation(_OverlayAgentRotation rotation) +{ + SysTryReturn(NID_UI_CTRL, (rotation < _OVERLAY_AGENT_ROTATION_MAX), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG)] A specified input parameter [%d] is invalid.", rotation); + + int rotate = _ROTATION_0; + + switch (rotation) + { + case _OVERLAY_AGENT_ROTATION_NONE: + // fall through + case _OVERLAY_AGENT_ROTATION_NONE_LR: + // fall through + case _OVERLAY_AGENT_ROTATION_NONE_UD: + rotate = _ROTATION_0; + break; + case _OVERLAY_AGENT_ROTATION_90: + // fall through + case _OVERLAY_AGENT_ROTATION_90_LR: + // fall through + case _OVERLAY_AGENT_ROTATION_90_UD: + rotate = _ROTATION_90; + break; + case _OVERLAY_AGENT_ROTATION_180: + // fall through + case _OVERLAY_AGENT_ROTATION_180_LR: + // fall through + case _OVERLAY_AGENT_ROTATION_180_UD: + rotate = _ROTATION_180; + break; + case _OVERLAY_AGENT_ROTATION_270: + // fall through + case _OVERLAY_AGENT_ROTATION_270_LR: + // fall through + case _OVERLAY_AGENT_ROTATION_270_UD: + rotate = _ROTATION_270; + break; + default: + rotate = _ROTATION_0; + break; + } + + int udMirroring = 0; + int lrMirroring = 0; + + switch (rotation) + { + case _OVERLAY_AGENT_ROTATION_NONE_UD: + // fall through + case _OVERLAY_AGENT_ROTATION_90_UD: + // fall through + case _OVERLAY_AGENT_ROTATION_180_UD: + // fall through + case _OVERLAY_AGENT_ROTATION_270_UD: + udMirroring = 1; + lrMirroring = 0; + break; + case _OVERLAY_AGENT_ROTATION_NONE_LR: + // fall through + case _OVERLAY_AGENT_ROTATION_90_LR: + // fall through + case _OVERLAY_AGENT_ROTATION_180_LR: + // fall through + case _OVERLAY_AGENT_ROTATION_270_LR: + udMirroring = 0; + lrMirroring = 1; + break; + default: + udMirroring = 0; + lrMirroring = 0; + break; + } + + __userRotation = rotate; + __udMirroring = udMirroring; + __lrMirroring = lrMirroring; + __flushRotate = true; + + AdjustImageObject(); + + SysLog(NID_UI_CTRL, "__userRotation[%d], __udMirroring [%d] , __lrMirroring [%d]", __userRotation, __udMirroring, __lrMirroring); + + return E_SUCCESS; +} + +result +_OverlayAgent::SetDestination(const Dimension& dimension) +{ + SysTryReturn(NID_UI_CTRL, IsValidDestinationDimension(dimension), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + + Dimension phy = _CoordinateSystemUtils::Transform(Dimension(dimension.width, dimension.height)); + + __resizeRect.width = phy.width; + __resizeRect.height = phy.height; + + SysLog(NID_UI_CTRL, "resizeRect is [%d, %d, %d, %d]",__resizeRect.x, __resizeRect.y, __resizeRect.width, __resizeRect.height); + + AdjustImageObject(); + + return E_SUCCESS; +} + +result +_OverlayAgent::SetAspectRatio(bool enable) +{ + __aspectRatio = enable; + + return E_SUCCESS; +} + +result +_OverlayAgent::CreateImageObjectForOverlayRegion(const _Control& control, const Rectangle& phyBounds) +{ + _EflNode* pEflNode = null; + Evas_Object* pSmartObject = null; + Evas* pEvas = null; + Ecore_Evas* pEcoreEvas = null; + //Rectangle phyBounds(0,0,0,0); + Rectangle logBounds(0,0,0,0); + VisualElementSurface* pVisualElementSurface = null; + _VisualElementSurfaceImpl* pVisualElementSurfaceImpl = null; + Evas_Object* pTemp = null; + + // 1. make VE for OR + _VisualElement* pParentVE = control.GetVisualElement(); + SysTryReturn(NID_UI_CTRL, pParentVE != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pParentVE is null."); + + _VisualElementImpl* pVisualElementImpl = null; + _VisualElement* pVisualElement = new (std::nothrow) _VisualElement(); + + SysTryReturn(NID_UI_CTRL, pVisualElement != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pVisualElement : Memory shortage."); + + result r = pVisualElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r) ); + + pVisualElement->SetName("OverlayRegion"); + pVisualElement->SetShowState(true); +// pVisualElement->SetOpacity(1.0f); + pVisualElement->SetImplicitAnimationEnabled(false); +// pVisualElement->SetBackgroundColor(_Colorf(0.0f, 0.0f, 0.0f, 0.0f)); + + pVisualElementImpl = _VisualElementImpl::GetInstance(*pVisualElement); + + pVisualElementImpl->SetZOrderGroup(_CONTROL_LAYER_OVERLAY); + r = pParentVE->InsertChild(*pVisualElement, null, true); + + logBounds = _CoordinateSystemUtils::InverseTransform(phyBounds); + SysLog(NID_UI_CTRL, "logBounds [%d, %d, %d, %d]", logBounds.x, logBounds.y, logBounds.width, logBounds.height); + pVisualElement->SetBounds(ConvertToFloat(logBounds)); + + // 2. remove origin VE image object buffer + pVisualElementSurface = pVisualElementImpl->GetSurfaceN(); + SysTryCatch(NID_UI_CTRL, pVisualElementSurface != null, , E_SYSTEM, "[E_SYSTEM] pVisualElementSurface is null" ); + + pVisualElementSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pVisualElementSurface); + SysTryCatch(NID_UI_CTRL, pVisualElementSurfaceImpl != null, , E_SYSTEM, "[E_SYSTEM] pVisualElementSurfaceImpl is null" ); + + pTemp = (Evas_Object*)pVisualElementSurfaceImpl->GetNativeHandle(); + SysTryCatch(NID_UI_CTRL, pTemp != null, , E_SYSTEM, "[E_SYSTEM] pTemp is null" ); + + evas_object_image_data_set(pTemp, NULL); + delete pVisualElementSurface; + + // 3. create image object + pEflNode = dynamic_cast<_EflNode*>(pVisualElement->GetNativeNode()); + SysTryCatch(NID_UI_CTRL, pEflNode != null, , E_SYSTEM, "[E_SYSTEM] pEflNode is null" ); + + pSmartObject = (Evas_Object*)pEflNode->GetGroupContainer(); + SysTryCatch(NID_UI_CTRL, pSmartObject != null, , E_SYSTEM, "[E_SYSTEM] pSmartObject is null" ); + + __pSmartObject = pSmartObject; + + pEvas = evas_object_evas_get(pSmartObject); + SysTryCatch(NID_UI_CTRL, pEvas != null, , E_SYSTEM, "[E_SYSTEM] pEvas is null" ); + + pEcoreEvas = ecore_evas_ecore_evas_get(pEvas); + SysTryCatch(NID_UI_CTRL, pEcoreEvas != null, , E_SYSTEM, "[E_SYSTEM] pEcoreEvas is null" ); + + __pImageObject = evas_object_image_add(pEvas); + SysTryCatch(NID_UI_CTRL, __pImageObject != null, , E_SYSTEM, "[E_SYSTEM] __pImageObject is null" ); + + // 4. add image obj to smart object + evas_object_smart_member_add(__pImageObject, pSmartObject); + //evas_object_lower(__pImageObject); + + SysLog(NID_UI_CTRL, "phyBounds [%d, %d, %d, %d]", phyBounds.x, phyBounds.y, phyBounds.width, phyBounds.height); + + evas_object_image_size_set(__pImageObject, phyBounds.width, phyBounds.height); + evas_object_image_filled_set(__pImageObject, EINA_TRUE); + evas_object_image_alpha_set(__pImageObject, false); + evas_object_resize(__pImageObject, phyBounds.width, phyBounds.height); + evas_object_move(__pImageObject, phyBounds.x, phyBounds.y); + evas_object_show(__pImageObject); + + r = pVisualElement->SetFlushNeeded(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pVisualElement = pVisualElement; + + SysLog(NID_UI_CTRL, "ImageObjectForOverlayRegion SUCCESS __pImageObject : %x, pSmartObject : %x", __pImageObject, pSmartObject); + + return E_SUCCESS; + +CATCH: + if (__pImageObject) + { + evas_object_del(__pImageObject); + __pImageObject = null; + } + + if (pVisualElementSurface) + { + delete pVisualElementSurface; + pVisualElementSurface = null; + } + + if (pVisualElement) + { + pVisualElement->Destroy(); + pVisualElement = null; + } + + return E_SYSTEM; +} + +result +_OverlayAgent::CreateImageObject(const _Control& control, const Rectangle& phyBounds) +{ + VisualElementSurface* pVisualElementSurface = null; + _VisualElementSurfaceImpl* pVisualElementSurfaceImpl = null; + _VisualElement* pVisualElement = null; + _VisualElementImpl* pVisualElementImpl = null; + Evas* pEvas = null; + Evas_Object* pTemp = null; + + _EflNode* pEflNode = dynamic_cast<_EflNode*>(control.GetVisualElement()->GetNativeNode()); + SysTryReturn(NID_UI_CTRL, pEflNode != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] pEflNode is null."); + + Evas_Object* pSmartObject = (Evas_Object*)pEflNode->GetGroupContainer(); + SysTryReturn(NID_UI_CTRL, pSmartObject != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] pSmartObject is null."); + __pSmartObject = pSmartObject; + + pVisualElement = control.GetVisualElement(); + SysTryReturn(NID_UI_CTRL, pVisualElement != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] pVisualElement is null."); + + pVisualElementImpl = _VisualElementImpl::GetInstance(*pVisualElement); + SysTryReturn(NID_UI_CTRL, pVisualElementImpl != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] pVisualElementImpl is null."); + + pVisualElementSurface = pVisualElementImpl->GetSurfaceN(); + SysTryCatch(NID_UI_CTRL, pVisualElementSurface != null, , E_SYSTEM, "[E_SYSTEM] pVisualElementSurface is null" ); + + pVisualElementSurfaceImpl = _VisualElementSurfaceImpl::GetInstance(*pVisualElementSurface); + SysTryCatch(NID_UI_CTRL, pVisualElementSurfaceImpl != null, , E_SYSTEM, "[E_SYSTEM] pVisualElementSurfaceImpl is null" ); + + pTemp = (Evas_Object*)pVisualElementSurfaceImpl->GetNativeHandle(); + SysTryCatch(NID_UI_CTRL, pTemp != null, , E_SYSTEM, "[E_SYSTEM] pTemp is null" ); + + evas_object_image_data_set(pTemp, NULL); + delete pVisualElementSurface; + pVisualElementSurface = null; + + pEvas = evas_object_evas_get(pSmartObject); + SysTryReturn(NID_UI_CTRL, pEvas != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] pEvas is null" ); + + // create renderRect object + __pRenderImageObject = evas_object_rectangle_add(pEvas); + SysTryReturn(NID_UI_CTRL, __pRenderImageObject != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] __pRenderImageObject is null"); + evas_object_smart_member_add(__pRenderImageObject, pSmartObject); + evas_object_color_set(__pRenderImageObject, 0, 0, 0, 255); // 100% opaque black + evas_object_resize(__pRenderImageObject, phyBounds.width, phyBounds.height); + evas_object_move(__pRenderImageObject, phyBounds.x, phyBounds.y); + evas_object_show(__pRenderImageObject); + + // create image object + __pImageObject = evas_object_image_add(pEvas); + //__pImageObject = evas_object_image_filled_add(pEvas); + SysTryCatch(NID_UI_CTRL, __pImageObject != null, , E_SYSTEM, "[E_SYSTEM] __pImageObject is null"); + + evas_object_smart_member_add(__pImageObject, pSmartObject); + evas_object_image_size_set(__pImageObject, phyBounds.width, phyBounds.height); + evas_object_image_fill_set(__pImageObject, 0, 0, phyBounds.width, phyBounds.height); + evas_object_image_alpha_set(__pImageObject, false); + evas_object_image_filled_set(__pImageObject, EINA_TRUE); + evas_object_resize(__pImageObject, phyBounds.width, phyBounds.height); + evas_object_move(__pImageObject, phyBounds.x, phyBounds.y); + evas_object_show(__pImageObject); + + __pVisualElement = control.GetVisualElement(); + + SysLog(NID_UI_CTRL, "ImageObjectForOverlayPanel SUCCESS"); + + return E_SUCCESS; + +CATCH: + + if (pVisualElementSurface) + { + delete pVisualElementSurface; + pVisualElementSurface = null; + } + + if (__pRenderImageObject) + { + evas_object_del(__pRenderImageObject); + __pRenderImageObject = null; + } + + return E_SYSTEM; +} + +result +_OverlayAgent::CreatePixmap(void) +{ + SysTryReturnResult(NID_UI_CTRL, __pImageObject != null, E_SYSTEM, "[E_SYSTEM] __pImageObject is null"); + + int x = 0; + int y = 0; + int w = 0; + int h = 0; + + evas_object_geometry_get(__pImageObject, &x, &y, &w, &h); + SysLog(NID_UI_CTRL,"__pImageObject rect is [%d, %d, %d, %d]", x, y, w, h); + + Rectangle phyRect(x, y, w, h); + SysTryReturnResult(NID_UI_CTRL, (phyRect.width >= GetDstRectMinWidth()) && (phyRect.height >= GetDstRectMinHeight()), E_SYSTEM, "[E_SYSTEM] can't make a pixmap. dimension[%d, %d] is not proper",phyRect.width, phyRect.height); + +// Create pixmap. + Display *pDisplay = (Display*)ecore_x_display_get(); + SysTryReturnResult(NID_UI_CTRL, pDisplay != null, E_SYSTEM, "[E_SYSTEM] pDisplay is null"); + + __pixmap = XCreatePixmap(pDisplay, DefaultRootWindow(pDisplay), phyRect.width, phyRect.height, DefaultDepth(pDisplay, DefaultScreen(pDisplay))); + SysTryReturnResult(NID_UI_CTRL, __pixmap != 0, E_SYSTEM, "[E_SYSTEM] failed to create a pixmap"); + + GC gc = XCreateGC(pDisplay, __pixmap, 0,0); + SysTryReturnResult(NID_UI_CTRL, gc > 0, E_SYSTEM, "[E_SYSTEM] failed to create GC"); + + XSetForeground(pDisplay, gc, (long unsigned int)(__bgColor.GetRGB32())); + XFillRectangle(pDisplay, __pixmap, gc, 0, 0, phyRect.width, phyRect.height); + XSync(pDisplay, 0); + XFreeGC(pDisplay, gc); + +// Set native surface. + Evas_Native_Surface surf = {0,}; + + surf.version = EVAS_NATIVE_SURFACE_VERSION; + surf.type = EVAS_NATIVE_SURFACE_X11; + surf.data.x11.visual = ecore_x_default_visual_get(ecore_x_display_get(), ecore_x_default_screen_get()); + surf.data.x11.pixmap = __pixmap; + + evas_object_lower(__pImageObject); + if (__style == _OVERLAY_AGENT_STYLE_PANEL_SW || __style == _OVERLAY_AGENT_STYLE_PANEL_GL) + { + if(__pRenderImageObject) + { + evas_object_lower(__pRenderImageObject); + } + } + + evas_object_image_native_surface_set(__pImageObject, &surf); + +// Create damage. + __pixmapDamageHandle = ecore_x_damage_new(__pixmap, ECORE_X_DAMAGE_REPORT_RAW_RECTANGLES); + SysTryCatch(NID_UI_CTRL, __pixmapDamageHandle != 0, , E_SYSTEM, "[E_SYSTEM] failed to create a damage object"); + + __pPixmapEventHandler = ecore_event_handler_add(ECORE_X_EVENT_DAMAGE_NOTIFY, OnPixmapDamaged, (void*)this); + SysTryCatch(NID_UI_CTRL, __pPixmapEventHandler != null, , E_SYSTEM, "[E_SYSTEM] failed to add a pixmap damage event handle"); + + __pixmapPhyRect = Rectangle(0, 0, phyRect.width, phyRect.height); + + SysLog(NID_UI_CTRL, "__pixmap : %d.", __pixmap); + + return E_SUCCESS; + +CATCH: + if (__pPixmapEventHandler) + { + ecore_event_handler_del(__pPixmapEventHandler); + __pPixmapEventHandler = null; + } + + if (__pixmapDamageHandle) + { + ecore_x_damage_free(__pixmapDamageHandle); + __pixmapDamageHandle = 0; + } + + if (__pixmap) + { + XFreePixmap((Display*)ecore_x_display_get(), __pixmap); + __pixmap = 0; + } + + return E_SYSTEM; +} + +Pixmap +_OverlayAgent::GetPixmap(void) const +{ + return __pixmap; +} + +Evas_Object* +_OverlayAgent::GetPixmapImageObject(void) const +{ + return __pImageObject; +} + +result +_OverlayAgent::Show(void) const +{ + return E_SUCCESS; +} + +result +_OverlayAgent::GrabXvPort(void) +{ + int firstXvPort = -1; + int portCount = -1; + + Display* pDisplay = (Display*)ecore_x_display_get(); + SysTryReturn(NID_UI_CTRL, pDisplay != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + if (!_CheckXvExtension(pDisplay, &firstXvPort, &portCount)) + { + SysTryReturn(NID_UI_CTRL, false, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] _CheckXvExtension is failed."); + } + + SysTryReturn(NID_UI_CTRL, firstXvPort != -1, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] first XvPort[%d] is invalid.", firstXvPort); + SysTryReturn(NID_UI_CTRL, portCount >= 1 && portCount <= _OVERLAYAGENT_XV_PORT , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] portCount[%d] is invalid.", portCount); + + _OverlayAgent::baseXvPort = firstXvPort; + + int i, tempPort = 0; + for (i = 0; i < portCount; i++) + { + if(!isPortGrapped[i]) + { + tempPort = firstXvPort + i; + if (XvGrabPort(pDisplay, tempPort, 0) != Success) + { + SysLog(NID_UI_CTRL, "this port[%d] is alreadly used by another process", tempPort); + } + else + { + __xvPort = tempPort; + __grabXvPort = true; + isPortGrapped[i] = true; + break; + } + } + } + + SysTryReturn(NID_UI_CTRL, __xvPort != -1 , E_SYSTEM, E_SYSTEM, "XvGrabPort fail for pixmap : %d", __pixmap); + + SysLog(NID_UI_CTRL, "XvGrabPort port: %d pixmap: %d style: %d", __xvPort, __pixmap, __style); + + overlayAgentXvPortCount++; + + return E_SUCCESS; +} + +result +_OverlayAgent::PutXvImage(void) +{ + SysTryReturnResult(NID_UI_CTRL, __pixmap != 0, E_SYSTEM, "[E_SYSTEM] __pixmap is invalid. something wrong!"); + + Display* pDisplay = (Display*)ecore_x_display_get(); + SysTryReturn(NID_UI_CTRL, pDisplay != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] pDisplay is null."); + + GC gc = DefaultGCOfScreen(DefaultScreenOfDisplay(pDisplay)); + + bool needRealloc = false; + if (__pXvImage == null || __newColorFormat != __colorFormat /*|| __pXvImage->data_size != __pRefUserByteBuffer->GetCapacity()*/) + { + needRealloc = true; + + if (__xvPort != -1) + { + SysLog(NID_UI_CTRL, "Need to unGrap port[%d]!", __xvPort); + UngrabXvPort(); + } + + if(__pXvImage != null) + { + SysLog(NID_UI_CTRL,"pXvImage->data_size : %d, userBufferSize : %d", __pXvImage->data_size, __pRefUserByteBuffer->GetCapacity()); + SysLog(NID_UI_CTRL,"__newColorFormat : %x, __colorFormat : %x", __newColorFormat, __colorFormat); + + if (__pShmInfo) + { + XShmDetach(pDisplay, __pShmInfo); + shmdt(__pShmInfo->shmaddr); + shmctl(__pShmInfo->shmid, IPC_RMID, NULL); + delete __pShmInfo; + __pShmInfo = null; + } + + if (__pXvImage) + { + XFree(__pXvImage); + __pXvImage = null; + } + } + else + { + SysLog(NID_UI_CTRL, "__pXvImage is null!"); + } + } + + if (__xvPort == -1) + { + SysLog(NID_UI_CTRL, "port[%d] is invalid!", __xvPort); + result r = GrabXvPort(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r) ); + } + + if (needRealloc) + { + XvImage* pXvImage = null; + XShmSegmentInfo* pShmInfo = null; + + pShmInfo = new (std::nothrow) XShmSegmentInfo(); + if (pShmInfo == null) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM]pShmInfo is null."); + return E_SYSTEM; + } + + pXvImage = XvShmCreateImage(pDisplay, __xvPort, __newColorFormat, 0, __srcDimension.width, __srcDimension.height, pShmInfo); + SysTryReturn(NID_UI_CTRL, pXvImage != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] failed to create a XvImage."); + + pShmInfo->shmid = shmget(IPC_PRIVATE, pXvImage->data_size, IPC_CREAT | 0777); + pShmInfo->shmaddr = pXvImage->data = (char*)shmat(pShmInfo->shmid, 0, 0); + pShmInfo->readOnly = False; + + if (!XShmAttach(pDisplay, pShmInfo)) + { + XFree(pXvImage); + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] failed to XShmAttach."); + return E_SYSTEM; + } + + __pXvImage = pXvImage; + __pShmInfo = pShmInfo; + __colorFormat = __newColorFormat; + } + + memcpy(__pXvImage->data, __pRefUserByteBuffer->GetPointer(), __pXvImage->data_size); + __pRefUserByteBuffer = null; + + Atom rotation = XInternAtom(pDisplay, "_USER_WM_PORT_ATTRIBUTE_ROTATION", False); + XvSetPortAttribute(pDisplay, __xvPort, rotation, 0); + + XvShmPutImage(pDisplay, __xvPort, __pixmap, gc, __pXvImage, 0, 0, __srcDimension.width, __srcDimension.height, + __pixmapPhyRect.x, __pixmapPhyRect.y, __pixmapPhyRect.width, __pixmapPhyRect.height, False); + + XSync(pDisplay, 0); + + SysLog(NID_UI_CTRL, "colorFormat : %x, src[%d,%d,%d, %d], dst [%d,%d,%d,%d]", __colorFormat, 0, 0, __srcDimension.width, __srcDimension.height,__pixmapPhyRect.x, __pixmapPhyRect.y, __pixmapPhyRect.width, __pixmapPhyRect.height); + + return E_SUCCESS; +} + +result +_OverlayAgent::PutEvasImage(void) +{ + SysTryReturn(NID_UI_CTRL, __pImageObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] __pImageObject is null."); + SysTryReturn(NID_UI_CTRL, __pRefUserByteBuffer->GetPointer(), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] __pUserBuffer is null."); + + result r = E_SYSTEM; + + Dimension usrDim(__srcDimension.width,__srcDimension.height); + if(!usrDim.Equals(__orgImgDimension) + || __pOrgUserByteBuffer == null + || __pOrgUserByteBuffer->GetCapacity() != __pRefUserByteBuffer->GetCapacity()) + { + if(__pOrgUserByteBuffer) + { + __pOrgUserByteBuffer->SetPosition(0); + delete __pOrgUserByteBuffer; + __pOrgUserByteBuffer = null; + } + + int bufSize = __srcDimension.width *__srcDimension.height * 4; + __pOrgUserByteBuffer = new (std::nothrow) ByteBuffer; + SysTryReturn(NID_UI_CTRL, __pOrgUserByteBuffer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] __pOrgUserByteBuffer is null."); + + r = __pOrgUserByteBuffer->Construct(bufSize); + if(r != E_SUCCESS) + { + SysLogException(NID_UI_CTRL, r, "[%s] Failed to construct a __pOrgUserByteBuffer.", GetErrorMessage(r)); + delete __pOrgUserByteBuffer; + __pOrgUserByteBuffer = null; + return r; + } + } + + __pOrgUserByteBuffer->SetPosition(0); + + void* pImg = null; + if(__overlayAgentColorFormat == _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_ARGB8888) + { + r = __pOrgUserByteBuffer->SetArray(__pRefUserByteBuffer->GetPointer(), 0, __pOrgUserByteBuffer->GetCapacity()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r,"[%s] Propagating.", GetErrorMessage(r)); + + pImg = (void*)__pOrgUserByteBuffer->GetPointer(); + //_ImageUtil::ConvertPixelFormat(srcBuffer, MEDIA_PIXEL_FORMAT_RGBA8888, __srcDimension.width, __srcDimension.height, *pDstbuf, MEDIA_PIXEL_FORMAT_RGBA8888); + } + else + { + switch (__overlayAgentColorFormat) + { + case _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_RGB565: + r = _ImageUtil::ConvertPixelFormat(*__pRefUserByteBuffer, MEDIA_PIXEL_FORMAT_RGB565LE, __srcDimension.width, __srcDimension.height, *__pOrgUserByteBuffer, MEDIA_PIXEL_FORMAT_BGRA8888); + break; + case _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR: + r = _ImageUtil::ConvertPixelFormat(*__pRefUserByteBuffer, MEDIA_PIXEL_FORMAT_YUV420P, __srcDimension.width, __srcDimension.height, *__pOrgUserByteBuffer, MEDIA_PIXEL_FORMAT_BGRA8888); + break; + case _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_NV12: + r = _ImageUtil::ConvertPixelFormat(*__pRefUserByteBuffer, MEDIA_PIXEL_FORMAT_NV12, __srcDimension.width, __srcDimension.height, *__pOrgUserByteBuffer, MEDIA_PIXEL_FORMAT_BGRA8888); + break; + case _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_UYVY: + r = _ImageUtil::ConvertPixelFormat(*__pRefUserByteBuffer, MEDIA_PIXEL_FORMAT_UYVY422, __srcDimension.width, __srcDimension.height, *__pOrgUserByteBuffer, MEDIA_PIXEL_FORMAT_BGRA8888); + break; + default: + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_FORMAT, "The specified pixel format is not supported."); + return E_UNSUPPORTED_FORMAT; + } + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r,"[%s] Propagating.", GetErrorMessage(r)); + + pImg = (void*)(__pOrgUserByteBuffer->GetPointer()); + + } + + SysTryReturnResult(NID_UI_CTRL, pImg != null, E_SYSTEM, "[E_SYSTEM] converted image data is invalid."); + +// SysLog(NID_UI_CTRL, "__pUserBuffer : %x, size : %d", __pRefUserByteBuffer->GetPointer(), __pRefUserByteBuffer->GetCapacity()); +// SysLog(NID_UI_CTRL, "__pOrgBuffer : %x, size : %d", __pOrgUserByteBuffer->GetPointer(), __pOrgUserByteBuffer->GetCapacity()); +// SysLog(NID_UI_CTRL, "__srcDimension[%d, %d]",__srcDimension.width, __srcDimension.height); + + evas_object_image_size_set(__pImageObject, __srcDimension.width, __srcDimension.height); + evas_object_image_filled_set(__pImageObject, EINA_TRUE); + evas_object_image_alpha_set(__pImageObject, false); + evas_object_image_data_set(__pImageObject, pImg); + evas_object_image_data_update_add(__pImageObject, 0, 0, __srcDimension.width, __srcDimension.height); + evas_object_show(__pImageObject); + + AdjustImageObject(); + + __pVisualElement->SetFlushNeeded(); + + __orgImgDimension = usrDim; + __pRefUserByteBuffer = null; + + return E_SUCCESS; +} + +void +_OverlayAgent::UngrabXvPort(void) +{ + if (__grabXvPort) + { + Display* pDisplay = (Display*) ecore_x_display_get(); + Atom atom = XInternAtom(pDisplay, "_USER_WM_PORT_ATTRIBUTE_STREAM_OFF", False); + XvSetPortAttribute(pDisplay, __xvPort, atom, 1); + XvUngrabPort(pDisplay, __xvPort, 0); + + SysLog(NID_UI_CTRL, "UngrabXvPort port: %d pixmap: %d style: %d", __xvPort, __pixmap, __style); + + isPortGrapped[__xvPort-baseXvPort] = false; + __xvPort = -1; + __grabXvPort = false; + overlayAgentXvPortCount--; + } +} + +bool +_OverlayAgent::IsValidSourceDimension(const Dimension& dimension) const +{ + SysTryReturn(NID_UI_CTRL, dimension.width >= GetSrcRectMinWidth(), false, E_INVALID_ARG, "[E_INVALID_ARG] src width [%d] is invalid.", dimension.width); + SysTryReturn(NID_UI_CTRL, dimension.height >= GetSrcRectMinHeight(), false, E_INVALID_ARG, "[E_INVALID_ARG] src width [%d] is invalid.", dimension.height); + + SetLastResult(E_SUCCESS); + + return true; +} + +bool +_OverlayAgent::IsValidDestinationDimension(const Dimension& dimension) const +{ + Dimension phyDim = _CoordinateSystemUtils::Transform(dimension); + SysTryReturn(NID_UI_CTRL, (phyDim.width >= GetDstRectMinWidth() && phyDim.height >= GetDstRectMinHeight()), false, E_INVALID_ARG, + "[E_INVALID_ARG] Dimension L[%d, %d] P[%d,%d] is over minimun size.", dimension.width, dimension.height, phyDim.width, phyDim.height); + + SysTryReturn(NID_UI_CTRL, __pSmartObject != null, false, E_SYSTEM, "[E_SYSTEM] __pSmartObject is null"); + + FloatRectangle testRect = __pVisualElement->GetBounds(); + Dimension containerDim = _CoordinateSystemUtils::Transform(Dimension(static_cast(testRect.width), static_cast(testRect.height))); + + SysTryReturn(NID_UI_CTRL, (phyDim.width <= containerDim.width && phyDim.height <= containerDim.height), false, E_INVALID_ARG, + "[E_INVALID_ARG] RenderRect L[%d, %d] P[%d,%d] is bigger than container size [%d, %d]", dimension.width, dimension.height, phyDim.width, phyDim.height, containerDim.width, containerDim.height); + + return true; +} + +result +_OverlayAgent::AdjustImageObject(void) +{ + SysTryReturn(NID_UI_CTRL, __pSmartObject != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] __pSmartObject is null"); + SysTryReturn(NID_UI_CTRL, __pImageObject != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] __pImageObject is null"); + SysTryReturn(NID_UI_CTRL, __pVisualElement != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] __pVisualElement is null"); + + int x = 0; + int y = 0; + int w = 0; + int h = 0; + int resizeRectX = 0; + int resizeRectY = 0; + int resizeRectW = 0; + int resizeRectH = 0; + int noImage = false; + //int orgX, orgY, orgW, orgH; + + FloatRectangle curRect = __pVisualElement->GetBounds(); + SysLog(NID_UI_CTRL,"curRect [%f, %f, %f, %f]", curRect.x, curRect.y, curRect.width, curRect.height); + Rectangle curPhyRect = _CoordinateSystemUtils::Transform(Rectangle(static_cast(curRect.x), static_cast(curRect.y), static_cast(curRect.width), static_cast(curRect.height))); + + if (__srcDimension.width == 0 || __srcDimension.height == 0) + { + SysLog(NID_UI_CTRL, "src dimension[%d, %d] is an initialized state", __srcDimension.width, __srcDimension.height); + noImage = true; + } + + // 1. setting renderRect resize region + if(__resizeRect.width == 0 || __resizeRect.height == 0) + { + if (__pRenderImageObject) + { + evas_object_geometry_get(__pRenderImageObject, NULL, NULL, &resizeRectW, &resizeRectH); + } + else + { + resizeRectW = curPhyRect.width; + resizeRectH = curPhyRect.height; + } + } + else + { + resizeRectW = __resizeRect.width; + resizeRectH = __resizeRect.height; + } + + // 2. adjust RenderRect + x = curPhyRect.x; + y = curPhyRect.y; + w = curPhyRect.width; + h = curPhyRect.height; + SysLog(NID_UI_CTRL, "container [%d, %d, %d, %d]", x, y, w, h); + + if(__pRenderImageObject) + { +// evas_object_geometry_get(__pRenderImageObject, &orgX, &orgY, &orgW, &orgH); +// SysLog(NID_UI_CTRL, "renderRect before [%d, %d, %d, %d]", orgX, orgY, orgW, orgH); + + evas_object_resize(__pRenderImageObject, resizeRectW, resizeRectH); + + resizeRectX = x + ((w - resizeRectW)/2); + resizeRectY = y + ((h - resizeRectH)/2); + evas_object_move(__pRenderImageObject, resizeRectX, resizeRectY); + evas_object_show(__pRenderImageObject); + + SysLog(NID_UI_CTRL, "renderRect [%d, %d, %d, %d]", resizeRectX, resizeRectY, resizeRectW, resizeRectH); + +// evas_object_geometry_get(__pRenderImageObject, &orgX, &orgY, &orgW, &orgH); +// SysLog(NID_UI_CTRL, "renderRect after adjust [%d, %d, %d, %d]", orgX, orgY, orgW, orgH); + } + else + { + //evas_object_geometry_get(__pImageObject, &orgX, &orgY, &orgW, &orgH); + //SysLog(NID_UI_CTRL, "__pImageObject rect [%d, %d, %d, %d]", orgX, orgY, orgW, orgH); + + // set region base x, y + resizeRectX = x; + resizeRectY = y; + } + + SysLog(NID_UI_CTRL, "resizeRect is [%d, %d, %d, %d]", resizeRectX, resizeRectY, resizeRectW, resizeRectH); + + if (__flushRotate) + { + int finalX, finalY, finalW, finalH; + + SysLog(NID_UI_CTRL, "for rotate status operation"); + + // 3. image object rotate + Evas_Map* pMap = evas_map_new(4); + evas_map_util_points_populate_from_object(pMap, __pImageObject); + + SysLog(NID_UI_CTRL, "center [%d, %d]", resizeRectX + (resizeRectW/2), resizeRectY + (resizeRectH/2)); + evas_map_util_rotate(pMap, __userRotation, resizeRectX + (resizeRectW/2), resizeRectY + (resizeRectH/2)); + + evas_object_map_set(__pImageObject, pMap); + evas_object_map_enable_set(__pImageObject, EINA_TRUE); + + evas_object_image_filled_set(__pImageObject, EINA_TRUE); + evas_object_show(__pImageObject); + evas_map_free(pMap); + + SysLog(NID_UI_CTRL, "rotate value is [%d]",__userRotation); + + // 4. reset map coordinate + if (!noImage && __aspectRatio && __pRenderImageObject != null) + { + // don't do anything for a Render Rect, only adjust an image object coordination again + Dimension srcDim(__srcDimension.width, __srcDimension.height); + if (__userRotation == _ROTATION_90 || __userRotation == _ROTATION_270 ) + { + int tmp = srcDim.width; + srcDim.width = srcDim.height; + srcDim.height = tmp; +// SysLog(NID_UI_CTRL, "src dim is swapped"); + } + + SysLog(NID_UI_CTRL, "src dimension [%d, %d]", srcDim.width, srcDim.height); + + float srcRatio = ((float)srcDim.width) / ((float)srcDim.height); + + float tmpWidth = (float)resizeRectW; + float tmpHeight = tmpWidth / srcRatio; + + if (resizeRectH < (int)tmpHeight) + { + finalH = resizeRectH; + finalW = (int)((float)finalH * srcRatio); + } + else + { + finalW = resizeRectW; + finalH = (int)((float)finalW / srcRatio); + } + + finalX = resizeRectX + ((resizeRectW - finalW) / 2); + finalY = resizeRectY + ((resizeRectH - finalH) / 2); + } + else + { + finalX = resizeRectX; + finalY = resizeRectY; + finalW = resizeRectW; + finalH = resizeRectH; + } + + //int p1, p2, p3, p4; + //evas_object_geometry_get(__pImageObject, &p1, &p2, &p3, &p4); + //SysLog(NID_UI_CTRL, "__pImageObject after rotate [%d, %d, %d, %d]", p1, p2, p3, p4); + + SysLog(NID_UI_CTRL, "final image object [%d, %d, %d, %d]", finalX, finalY, finalW, finalH); + + + pMap = evas_map_new(4); + evas_map_util_points_populate_from_object(pMap, __pImageObject); + + int imgWidth = 0, imgHeight = 0; + evas_object_image_size_get(__pImageObject, &imgWidth, &imgHeight); + + switch(__userRotation) + { + case _ROTATION_0: + if(__lrMirroring) + { + evas_map_point_coord_set(pMap, 1, finalX, finalY, 0); + evas_map_point_coord_set(pMap, 0, finalX + finalW, finalY, 0); + evas_map_point_coord_set(pMap, 3, finalX + finalW, finalY + finalH, 0); + evas_map_point_coord_set(pMap, 2, finalX, finalY + finalH, 0); + } + else if(__udMirroring) + { + evas_map_point_coord_set(pMap, 3, finalX, finalY, 0); + evas_map_point_coord_set(pMap, 2, finalX + finalW, finalY, 0); + evas_map_point_coord_set(pMap, 1, finalX + finalW, finalY + finalH, 0); + evas_map_point_coord_set(pMap, 0, finalX, finalY + finalH, 0); + } + else + { + evas_map_point_coord_set(pMap, 0, finalX, finalY, 0); + evas_map_point_coord_set(pMap, 1, finalX + finalW, finalY, 0); + evas_map_point_coord_set(pMap, 2, finalX + finalW, finalY + finalH, 0); + evas_map_point_coord_set(pMap, 3, finalX, finalY + finalH, 0); + } + break; + case _ROTATION_90: + if(__lrMirroring) + { + evas_map_point_coord_set(pMap, 2, finalX, finalY, 0); + evas_map_point_coord_set(pMap, 1, finalX + finalW, finalY, 0); + evas_map_point_coord_set(pMap, 0, finalX + finalW, finalY + finalH, 0); + evas_map_point_coord_set(pMap, 3, finalX, finalY + finalH, 0); + } + else if(__udMirroring) + { + evas_map_point_coord_set(pMap, 0, finalX, finalY, 0); + evas_map_point_coord_set(pMap, 3, finalX + finalW, finalY, 0); + evas_map_point_coord_set(pMap, 2, finalX + finalW, finalY + finalH, 0); + evas_map_point_coord_set(pMap, 1, finalX, finalY + finalH, 0); + } + else + { + evas_map_point_coord_set(pMap, 3, finalX, finalY, 0); + evas_map_point_coord_set(pMap, 0, finalX + finalW, finalY, 0); + evas_map_point_coord_set(pMap, 1, finalX + finalW, finalY + finalH, 0); + evas_map_point_coord_set(pMap, 2, finalX, finalY + finalH, 0); + } + break; + case _ROTATION_180: + if(__lrMirroring) + { + evas_map_point_coord_set(pMap, 3, finalX, finalY, 0); + evas_map_point_coord_set(pMap, 2, finalX + finalW, finalY, 0); + evas_map_point_coord_set(pMap, 1, finalX + finalW, finalY + finalH, 0); + evas_map_point_coord_set(pMap, 0, finalX, finalY + finalH, 0); + } + else if(__udMirroring) + { + evas_map_point_coord_set(pMap, 1, finalX, finalY, 0); + evas_map_point_coord_set(pMap, 0, finalX + finalW, finalY, 0); + evas_map_point_coord_set(pMap, 3, finalX + finalW, finalY + finalH, 0); + evas_map_point_coord_set(pMap, 2, finalX, finalY + finalH, 0); + } + else + { + evas_map_point_coord_set(pMap, 2, finalX, finalY, 0); + evas_map_point_coord_set(pMap, 3, finalX + finalW, finalY, 0); + evas_map_point_coord_set(pMap, 0, finalX + finalW, finalY + finalH, 0); + evas_map_point_coord_set(pMap, 1, finalX, finalY + finalH, 0); + } + break; + case _ROTATION_270: + if(__lrMirroring) + { + evas_map_point_coord_set(pMap, 0, finalX, finalY, 0); + evas_map_point_coord_set(pMap, 3, finalX + finalW, finalY, 0); + evas_map_point_coord_set(pMap, 2, finalX + finalW, finalY + finalH, 0); + evas_map_point_coord_set(pMap, 1, finalX, finalY + finalH, 0); + } + else if(__udMirroring) + { + evas_map_point_coord_set(pMap, 2, finalX, finalY, 0); + evas_map_point_coord_set(pMap, 1, finalX + finalW, finalY, 0); + evas_map_point_coord_set(pMap, 0, finalX + finalW, finalY + finalH, 0); + evas_map_point_coord_set(pMap, 3, finalX, finalY + finalH, 0); + } + else + { + evas_map_point_coord_set(pMap, 1, finalX, finalY, 0); + evas_map_point_coord_set(pMap, 2, finalX + finalW, finalY, 0); + evas_map_point_coord_set(pMap, 3, finalX + finalW, finalY + finalH, 0); + evas_map_point_coord_set(pMap, 0, finalX, finalY + finalH, 0); + } + break; + default: + SysLog(NID_UI_CTRL, "__userRotation[%d] is invalid", __userRotation); + break; + } + + if(imgWidth > 0 && imgHeight > 0) + { + evas_map_point_image_uv_set(pMap, 0, 0, 0); + evas_map_point_image_uv_set(pMap, 1, imgWidth, 0); + evas_map_point_image_uv_set(pMap, 2, imgWidth, imgHeight); + evas_map_point_image_uv_set(pMap, 3, 0, imgHeight); + } + + evas_object_map_set(__pImageObject, pMap); + evas_object_map_enable_set(__pImageObject, EINA_TRUE); + evas_map_free(pMap); + + evas_object_image_filled_set(__pImageObject, EINA_TRUE); + evas_object_show(__pImageObject); + } + else + { + SysLog(NID_UI_CTRL, "not for rotate status operation"); + + if (!noImage && __aspectRatio && __pRenderImageObject != null) + { + Dimension srcDim(__srcDimension.width, __srcDimension.height); + SysLog(NID_UI_CTRL, "src dimension is [%d, %d]", srcDim.width, srcDim.height); + + float srcRatio = ((float)srcDim.width) / ((float)srcDim.height); + float tmpWidth = (float)resizeRectW; + float tmpHeight = tmpWidth / srcRatio; + + Rectangle lastDst; + if (resizeRectH < (int)tmpHeight) + { + lastDst.height = resizeRectH; + lastDst.width = (int)((float)lastDst.height * srcRatio); + } + else + { + lastDst.width = resizeRectW; + lastDst.height = (int)((float)lastDst.width / srcRatio); + } + + lastDst.x = resizeRectX + ((resizeRectW - lastDst.width) / 2); + lastDst.y = resizeRectY + ((resizeRectH - lastDst.height) / 2); + +// evas_object_geometry_get(__pImageObject, &orgX, &orgY, &orgW, &orgH); +// SysLog(NID_UI_CTRL, "__pImageObject before [%d, %d, %d, %d]", orgX, orgY, orgW, orgH); + + evas_object_resize(__pImageObject, lastDst.width, lastDst.height); + evas_object_move(__pImageObject, lastDst.x, lastDst.y); + +// evas_object_geometry_get(__pImageObject, &orgX, &orgY, &orgW, &orgH); +// SysLog(NID_UI_CTRL, "__pImageObject after [%d, %d, %d, %d]", orgX, orgY, orgW, orgH); + + SysLog(NID_UI_CTRL, "Ratio on / lastDst [%d, %d, %d, %d]",lastDst.x, lastDst.y, lastDst.width, lastDst.height); + } + else + { + SysLog(NID_UI_CTRL, "Ratio off"); + + Evas_Map* pMap = evas_map_new(4); + evas_map_util_points_populate_from_object(pMap, __pImageObject); + + evas_map_point_coord_set(pMap, 0, resizeRectX, resizeRectY, 0); + evas_map_point_coord_set(pMap, 1, resizeRectX+resizeRectW, resizeRectY, 0); + evas_map_point_coord_set(pMap, 2, resizeRectX+resizeRectW, resizeRectY+resizeRectH, 0); + evas_map_point_coord_set(pMap, 3, resizeRectX, resizeRectY+resizeRectH, 0); + + evas_object_map_set(__pImageObject, pMap); + evas_object_map_enable_set(__pImageObject, EINA_TRUE); + evas_map_free(pMap); + } + + evas_object_image_filled_set(__pImageObject, EINA_TRUE); + evas_object_show(__pImageObject); + } + + __pVisualElement->SetFlushNeeded(); + + return E_SUCCESS; +} + +int +_OverlayAgent::GetOverlayAgentCount(void) +{ + return overlayAgentcount; +} + +int +_OverlayAgent::GetDstRectMinWidth(void) +{ + ClearLastResult(); + + if (dstRectMinWidth == -1) + { + result r = E_SUCCESS; + _RegistryImpl _reg; + String value; + int val; + + r = _reg.Construct(_UI_REGISTRY_PATH, REG_OPEN_READ_ONLY, null); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] RegistryImpl construct Failed"); + + r = _reg.GetValue(_UI_INFO_SESSION, L"OverlayDstMinWidth", value); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Registry GetValue Failed"); + + r = Integer::Parse(value, val); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Parse Failed"); + + dstRectMinWidth = val; + + SysLog(NID_UI_CTRL, "overlayDstMinWidth : %d", dstRectMinWidth); + } + + SetLastResult(E_SUCCESS); + + return dstRectMinWidth; +} + +int +_OverlayAgent::GetDstRectMinHeight(void) +{ + ClearLastResult(); + + if (dstRectMinHegith == -1) + { + result r = E_SUCCESS; + _RegistryImpl _reg; + String value; + int val; + + r = _reg.Construct(_UI_REGISTRY_PATH, REG_OPEN_READ_ONLY, null); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] RegistryImpl construct Failed"); + + r = _reg.GetValue(_UI_INFO_SESSION, L"OverlayDstMinHeight", value); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Registry GetValue Failed"); + + r = Integer::Parse(value, val); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Parse Failed"); + + dstRectMinHegith = val; + + SysLog(NID_UI_CTRL, "overlayDstMinHeight: %d", dstRectMinHegith); + } + + SetLastResult(E_SUCCESS); + + return dstRectMinHegith; +} + +int +_OverlayAgent::GetSrcRectMinWidth(void) +{ + ClearLastResult(); + + if (srcRectMinWidth == -1) + { + result r = E_SUCCESS; + _RegistryImpl _reg; + String value; + int val; + + r = _reg.Construct(_UI_REGISTRY_PATH, REG_OPEN_READ_ONLY, null); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] RegistryImpl construct Failed"); + + r = _reg.GetValue(_UI_INFO_SESSION, L"OverlaySrcMinWidth", value); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Registry GetValue Failed"); + + r = Integer::Parse(value, val); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Parse Failed"); + + srcRectMinWidth = val; + + SysLog(NID_UI_CTRL, "overlayDstMinWidth : %d", srcRectMinWidth); + } + + SetLastResult(E_SUCCESS); + + return srcRectMinWidth; +} + +int +_OverlayAgent::GetSrcRectMinHeight(void) +{ + ClearLastResult(); + + if (srcRectMinHegith == -1) + { + result r = E_SUCCESS; + _RegistryImpl _reg; + String value; + int val; + + r = _reg.Construct(_UI_REGISTRY_PATH, REG_OPEN_READ_ONLY, null); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] RegistryImpl construct Failed"); + + r = _reg.GetValue(_UI_INFO_SESSION, L"OverlaySrcMinHeight", value); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Registry GetValue Failed"); + + r = Integer::Parse(value, val); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Parse Failed"); + + srcRectMinHegith = val; + + SysLog(NID_UI_CTRL, "overlaySrcMinHeight: %d", srcRectMinHegith); + } + + SetLastResult(E_SUCCESS); + + return srcRectMinHegith; +} + + +}}} // Tizen::Ui + diff --git a/src/ui/controls/FUiCtrl_OverlayPanel.cpp b/src/ui/controls/FUiCtrl_OverlayPanel.cpp new file mode 100644 index 0000000..9baf225 --- /dev/null +++ b/src/ui/controls/FUiCtrl_OverlayPanel.cpp @@ -0,0 +1,346 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_OverlayPanel.cpp +* @brief This file contains implementation of _OverlayPanel class +*/ + +#include + +#include + +#include +#include +#include + +#include "FUi_CoordinateSystemUtils.h" +#include "FUiCtrl_OverlayPanel.h" +#include "FUiCtrl_OverlayAgent.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_FormImpl.h" +#include "FUiAnim_ControlVisualElement.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_OverlayPanel* +_OverlayPanel::CreateOverlayPanelN(const Rectangle& bounds) +{ + _OverlayPanel* pOverlayPanel = new (std::nothrow) _OverlayPanel(bounds); + SysTryReturn(NID_UI_CTRL, pOverlayPanel != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pOverlayPanel->AcquireHandle(); + + SetLastResult(E_SUCCESS); + + return pOverlayPanel; + +CATCH: + delete pOverlayPanel; + + return null; +} + +_OverlayPanel::_OverlayPanel(const Rectangle& bounds) + : __pOverlayAgent(null) +{ + SetLastResult(E_SUCCESS); +} + +_OverlayPanel::~_OverlayPanel(void) +{ + SysLog(NID_UI_CTRL, "Destructor ~~~~~~"); + + if (__pOverlayAgent) + { + delete __pOverlayAgent; + __pOverlayAgent = null; + } +} + +result +_OverlayPanel::SetInputBuffer(const Dimension& destDim, const ByteBuffer& srcBuffer, const Dimension& srcDim, OverlayPanel::BufferPixelFormat srcFormat) +{ + result r = E_SYSTEM; + + SysTryReturnResult(NID_UI_CTRL, __pOverlayAgent != null, r, "[E_SYSTEM] __pOverlayAgent is null."); + + _OverlayAgentBufferPixelFormat format = _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_ARGB8888; + switch (srcFormat) + { + case OverlayPanel::BUFFER_PIXEL_FORMAT_ARGB8888: + format = _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_ARGB8888; + break; + case OverlayPanel::BUFFER_PIXEL_FORMAT_RGB565: + format = _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_RGB565; + break; + case OverlayPanel::BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR: + format = _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR; + break; + default: + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_FORMAT, "The specified pixel format is not supported."); + return E_UNSUPPORTED_FORMAT; + } + + r = __pOverlayAgent->SetInputBuffer(destDim, srcBuffer, srcDim, format); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pOverlayAgent->Draw(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pOverlayAgent->SetDestination(destDim); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_OverlayPanel::SetRendererRotation(OverlayPanel::Rotation rotation) +{ + result r = E_SYSTEM; + SysTryReturnResult(NID_UI_CTRL, __pOverlayAgent != null, r, "[E_SYSTEM] __pOverlayAgent is null."); + + r = __pOverlayAgent->SetRotation((_OverlayAgentRotation)rotation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_OverlayPanel::SetRendererAspectRatio(bool aspectRatio) +{ + result r = E_SYSTEM; + SysTryReturnResult(NID_UI_CTRL, __pOverlayAgent != null, r, "[E_SYSTEM] __pOverlayAgent is null."); + + r = __pOverlayAgent->SetAspectRatio(aspectRatio); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_OverlayPanel::SetRendererSize(const Dimension& dimension) +{ + result r = E_SYSTEM; + SysTryReturnResult(NID_UI_CTRL, __pOverlayAgent != null, r, "[E_SYSTEM] __pOverlayAgent is null."); + + r = __pOverlayAgent->SetDestination(dimension); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_OverlayPanel::GetBackgroundBufferInfo(BufferInfo& info) const +{ + SysTryReturnResult(NID_UI_CTRL, __pOverlayAgent != null, E_SYSTEM, "[E_SYSTEM] __pOverlayAgent is null."); + + return __pOverlayAgent->GetBufferInfo(info); +} + +Color +_OverlayPanel::GetMaskingColor(void) const +{ +// Suspend + return Color(0x00000000); +// --- +} + +void +_OverlayPanel::OnDraw(void) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pOverlayAgent != null, E_SYSTEM, "[E_SYSTEM] __pOverlayAgent is null."); + __pOverlayAgent->AdjustImageObject(); + + return; +} + +void +_OverlayPanel::OnVisibleStateChanged(void) +{ + if (IsVisible()) + { + SysLog(NID_UI_CTRL, " visible true"); + } + else + { + SysLog(NID_UI_CTRL, " visible false"); + } +} + +result +_OverlayPanel::OnAttachedToMainTree(void) +{ + byte* pBuf = null; + + int maxCount = OverlayRegion::GetMaxCount(); + SysTryReturn(NID_UI_CTRL, maxCount > 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] maxCount [%d] is invalid", maxCount); + + // 1. check for overlayAgent maximum count + SysTryReturn(NID_UI_CTRL, _OverlayAgent::GetOverlayAgentCount() < maxCount, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] already used permitted maximum number of OverlayAgent!"); + + _Control* pParent = GetParent(); + SysTryReturn(NID_UI_CTRL, pParent != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Parent is invalid"); + + _ControlImpl* pControlImpl = static_cast<_ControlImpl*>(pParent->GetUserData()); + SysTryReturn(NID_UI_CTRL, pControlImpl != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] pControlImpl is null"); + + _FormImpl* pFormImpl = dynamic_cast<_FormImpl*>(pControlImpl); + SysTryReturn(NID_UI_CTRL, pFormImpl != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] pFormImpl is null"); + + // 2. check for using OverlayRegion simutaneously in the same form + _Form& form = pFormImpl->GetCore(); + SysTryReturn(NID_UI_CTRL, form.GetOverlayRegionCount() == 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Using OverlayPanel mixed with OverlayRegion is not supported"); + + int idx, panelCount = 0;; + _OverlayPanel* pOverlayPanel = null; + + // 3. check for overlayPanel maximum count + for (idx = 0 ; idx < form.GetChildCount() ; idx++) + { + pOverlayPanel = dynamic_cast <_OverlayPanel*>(form.GetChild(idx)); + if(pOverlayPanel != null) + { + panelCount++; + pOverlayPanel = null; + } + } + + SysTryReturn(NID_UI_CTRL, panelCount <= maxCount, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] already used permitted maximum number of OverlayPanel"); + + // 4. make OverlayPanel object + Rectangle clientRect = pParent->GetClientBounds(); //GetClientBounds(); + Rectangle GeneralRect = GetBounds(); + Rectangle overlayRect(clientRect.x + GeneralRect.x, clientRect.y + GeneralRect.y, GeneralRect.width, GeneralRect.height); + + SysLog(NID_UI_CTRL,"clientRect is [%d, %d, %d, %d] userRect is [%d, %d, %d, %d]", + clientRect.x, clientRect.y, clientRect.width, clientRect.height, GeneralRect.x, GeneralRect.y, GeneralRect.width, GeneralRect.height); + SysLog(NID_UI_CTRL,"logical overlayRect is [%d, %d, %d, %d]", overlayRect.x, overlayRect.y, overlayRect.width, overlayRect.height); + + // 5. Adjust + Rectangle devBounds = _CoordinateSystemUtils::Transform(overlayRect); + if (devBounds.width % 2 != 0) + { + SysLog(NID_UI_CTRL,"physical overlayRect width is revised [%d]->[%d]", devBounds.width, devBounds.width - 1); + devBounds.width -= 1; + } + SysLog(NID_UI_CTRL, "physical overlayRect is [%d,%d,%d,%d]", devBounds.x, devBounds.y, devBounds.width, devBounds.height); + + // 6. create OverlayAgent Instance + _OverlayAgentStyle overlayAgentType = _OVERLAY_AGENT_STYLE_PANEL_SW; + String preferredEngineConfig(elm_config_preferred_engine_get()); + if(preferredEngineConfig.Equals("opengl_x11", true)) + { + overlayAgentType = _OVERLAY_AGENT_STYLE_PANEL_GL; + SysLog(NID_UI_CTRL,"xml : HwAcceleration was set to On"); + } + else if(preferredEngineConfig.Equals("software_x11", true)) + { + overlayAgentType = _OVERLAY_AGENT_STYLE_PANEL_SW; + SysLog(NID_UI_CTRL,"xml : HwAcceleration was set to Off"); + } + else + { + String engineConfig(elm_config_engine_get()); + if(engineConfig.Equals("opengl_x11", true)) + { + overlayAgentType = _OVERLAY_AGENT_STYLE_PANEL_GL; + SysLog(NID_UI_CTRL,"dev setting option : gl backend"); + } + } + + __pOverlayAgent = _OverlayAgent::CreateInstanceN(overlayAgentType, *this, devBounds); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS && __pOverlayAgent != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (overlayAgentType == _OVERLAY_AGENT_STYLE_PANEL_GL) + { + r = __pOverlayAgent->CreatePixmap(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + SysLog(NID_UI_CTRL, "not need to make a pixmap"); + + int i, j; + int size = devBounds.width * devBounds.height * 4; + pBuf = new (std::nothrow) byte[size]; + SysTryCatch(NID_UI_CTRL, pBuf != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pBuf is null."); + + unsigned long* pPos = (unsigned long*)pBuf; + for(i=0; iGetClientBounds(); //GetClientBounds(); + Rectangle GeneralRect = GetBounds(); + Rectangle overlayRect(clientRect.x + GeneralRect.x, clientRect.y + GeneralRect.y, GeneralRect.width, GeneralRect.height); + + SetRendererSize(Dimension(overlayRect.width, overlayRect.height)); + + return; +} + +void +_OverlayPanel::OnChildDetached(const _Control& child) +{ + return; +} + + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_OverlayPanelImpl.cpp b/src/ui/controls/FUiCtrl_OverlayPanelImpl.cpp new file mode 100644 index 0000000..cbb0c64 --- /dev/null +++ b/src/ui/controls/FUiCtrl_OverlayPanelImpl.cpp @@ -0,0 +1,338 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/* + * @file FUiCtrl_OverlayPanelImpl.cpp + * @brief This is the implementation file for _OverlayPanelImpl class. + * + */ + + +#include +#include + +#include +#include + +#include "FUi_UiBuilder.h" +#include "FUiCtrl_OverlayPanelImpl.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Io; +using namespace Tizen::System; + +#ifndef _OSP_EMUL_ +namespace +{ + const wchar_t* _UI_REGISTRY_PATH = L"/usr/etc/system-info.ini"; + const wchar_t* _UI_INFO_SESSION = L"UiControlInfo"; +} +#endif + +namespace Tizen { namespace Ui { namespace Controls +{ + +bool _OverlayPanelImpl::overlayPanelPixelFomatList[]= {false,}; + +Tizen::Graphics::Dimension +_OverlayPanelImpl::OverlayPanelSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + // [ToDo] + Dimension dimension(0, 0); + + int minimumSize = 0; + result r = GET_SHAPE_CONFIG("OVERLAYPANEL::MIN_RENDERER_SIZE", orientation, minimumSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, dimension, r, "[%s] Propagating.", GetErrorMessage(r)); + + dimension.width = minimumSize; + dimension.height = minimumSize; + + SetLastResult(E_SUCCESS); + + return dimension; +} + +_OverlayPanelImpl* +_OverlayPanelImpl::CreateOverlayPanelImplN(OverlayPanel* pPublic, const Rectangle& bounds) +{ + result r = GET_SIZE_INFO(OverlayPanel).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + + _OverlayPanel* pCore = _OverlayPanel::CreateOverlayPanelN(bounds); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _OverlayPanelImpl* pImpl = new (std::nothrow) _OverlayPanelImpl(pPublic, pCore); + r = _ControlImpl::CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(OverlayPanel), bounds, _CONTROL_ORIENTATION_PORTRAIT); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pImpl; + +CATCH: + delete pImpl; + return null; +} + +_OverlayPanelImpl::~_OverlayPanelImpl(void) +{ + +} + +void +_OverlayPanelImpl::SetRendererRotation(OverlayPanel::Rotation rotation) +{ + GetCore().SetRendererRotation(rotation); +} + +void +_OverlayPanelImpl::SetRendererAspectRatio(bool fix) +{ + GetCore().SetRendererAspectRatio(fix); +} + +void +_OverlayPanelImpl::SetRendererSize(const Dimension& dimension) +{ + GetCore().SetRendererSize(dimension); +} + +result +_OverlayPanelImpl::SetInputBuffer(const Dimension& destDim, const ByteBuffer& srcBuffer, const Dimension& srcDim, OverlayPanel::BufferPixelFormat srcFormat) +{ + if (!_OverlayPanelImpl::overlayPanelPixelFomatList[0]) + { + result r = _OverlayPanelImpl::SetPixelFormatList(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (!_OverlayPanelImpl::overlayPanelPixelFomatList[srcFormat]) + { + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] srcFormat [%d] is not supported!", srcFormat); + return E_UNSUPPORTED_FORMAT; + } + + result r = GetCore().SetInputBuffer(destDim, srcBuffer, srcDim, srcFormat); + + if ((r == E_INVALID_ARG) || (r == E_UNSUPPORTED_FORMAT) || (r == E_SYSTEM)) + { + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (r != E_SUCCESS) + { + r = E_SYSTEM; + SysLogException(NID_UI_CTRL, r, "[E_SYSTEM] A system error occurred."); + } + + return r; +} + +result +_OverlayPanelImpl::GetBackgroundBufferInfo(BufferInfo& bufferInfo) const +{ + result r = GetCore().GetBackgroundBufferInfo(bufferInfo); + + if (r == E_OPERATION_FAILED) + { + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (r != E_SUCCESS) + { + r = E_OPERATION_FAILED; + SysLogException(NID_UI_CTRL, r, "[E_OPERATION_FAILED] The operation has failed."); + } + + return r; +} + +_OverlayPanelImpl::_OverlayPanelImpl(OverlayPanel* pPublic, _OverlayPanel* pCore) + : _ContainerImpl(pPublic, pCore) +{ +} + +Color +_OverlayPanelImpl::GetMaskingColor(void) const +{ + return GetCore().GetMaskingColor(); +} + +const char* +_OverlayPanelImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::OverlayPanel"; +} + +const _OverlayPanel& +_OverlayPanelImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_OverlayPanel& +_OverlayPanelImpl::GetCore(void) +{ + return static_cast <_OverlayPanel&>(_ControlImpl::GetCore()); +} + +const OverlayPanel& +_OverlayPanelImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +OverlayPanel& +_OverlayPanelImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +_OverlayPanelImpl* +_OverlayPanelImpl::GetInstance(OverlayPanel& overlayPanel) +{ + return static_cast<_OverlayPanelImpl*> (overlayPanel._pControlImpl); +} + +const _OverlayPanelImpl* +_OverlayPanelImpl::GetInstance(const OverlayPanel& overlayPanel) +{ + return static_cast (overlayPanel._pControlImpl); +} + +result +_OverlayPanelImpl::SetPixelFormatList(void) +{ +#ifndef _OSP_EMUL_ + String formatList; + + result r = E_SUCCESS; + _RegistryImpl _reg; + + r = _reg.Construct(_UI_REGISTRY_PATH, REG_OPEN_READ_ONLY, null); + if (IsFailed(r)) + { + if (r == E_OUT_OF_MEMORY) + { + SysTryReturn(NID_UI_CTRL, r != E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + SysAssertf(0, "failed to Construct the _RegistryImpl"); + } + } + + r = _reg.GetValue(_UI_INFO_SESSION, L"OverlayRegionBufferPixelFormat", formatList); + SysAssertf(!IsFailed(r), "Failed to get a registry value"); + +#else + String formatList(L"ARGB8888/RGB565/YCbCr420P"); +#endif + + bool set = false; + if (formatList.Contains(L"ARGB8888")) + { + overlayPanelPixelFomatList[OverlayPanel::BUFFER_PIXEL_FORMAT_ARGB8888+1] = true; + set = true; + } + + if (formatList.Contains(L"RGB565")) + { + overlayPanelPixelFomatList[OverlayPanel::BUFFER_PIXEL_FORMAT_RGB565+1] = true; + set = true; + } + + if (formatList.Contains(L"YCbCr420P")) + { + overlayPanelPixelFomatList[OverlayPanel::BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR+1] = true; + set = true; + } + + SysAssertf(set, "registry file is something wrong"); + + overlayPanelPixelFomatList[0] = set; + + return E_SUCCESS; +} + +class _OverlayPanelMaker + : public _UiBuilderControlMaker +{ +public: + _OverlayPanelMaker(_UiBuilder* uibuilder) + :_UiBuilderControlMaker(uibuilder){}; + virtual ~_OverlayPanelMaker(){}; + + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _OverlayPanelMaker* _pOverlayPanelMaker = new (std::nothrow) _OverlayPanelMaker(uibuilder); + return _pOverlayPanelMaker; + }; + +protected: + virtual Tizen::Ui::Control* Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = NULL; + OverlayPanel* pOverlayPanel = NULL; + Tizen::Graphics::Rectangle rect; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + + pOverlayPanel = new (std::nothrow) OverlayPanel(); + if (pOverlayPanel == null) + { + return null; + } + + //Construct + r = pOverlayPanel->Construct(rect); + if (r != E_SUCCESS) + { + delete pOverlayPanel; + return null; + } + + return pOverlayPanel; + } +}; + +_OverlayPanelRegister::_OverlayPanelRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl("OverlayPanel", _OverlayPanelMaker::GetInstance); +} + +_OverlayPanelRegister::~_OverlayPanelRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl("OverlayPanel"); +} +static _OverlayPanelRegister OverlayPanelRegisterToUIbuilder; +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_OverlayRegionImpl.cpp b/src/ui/controls/FUiCtrl_OverlayRegionImpl.cpp new file mode 100644 index 0000000..47ba0d9 --- /dev/null +++ b/src/ui/controls/FUiCtrl_OverlayRegionImpl.cpp @@ -0,0 +1,976 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_OverlayRegionImpl.cpp + * @brief This is the implementation file for _OverlayRegionImpl class. + * + */ + +#include + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include "FUi_CoordinateSystemUtils.h" +#include "FUiCtrl_FormImpl.h" +#include "FUiCtrl_OverlayRegionImpl.h" +#include "FUiCtrl_OverlayAgent.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Media; +using namespace Tizen::Graphics; +using namespace Tizen::Io; +using namespace Tizen::System; + +namespace +{ + const int _ROTATION_COUNT = 4; + + const wchar_t* _UI_REGISTRY_PATH = L"/usr/etc/system-info.ini"; + const wchar_t* _UI_INFO_SESSION = L"UiControlInfo"; + + const char* _MEDIA_CAPABILITY_FILE_PATH = "/usr/etc/media-capability.xml"; + const char* _CAM_PRIMARY_DIRECTION = "Camera.Primary.Direction"; + const char* _CAM_PRIMARY_ROTATION = "Camera.Primary.Rotation"; + const char* _CAM_SECONDARY_DIRECTION = "Camera.Secondary.Direction"; + const char* _CAM_SECONDARY_ROTATION = "Camera.Secondary.Rotation"; + + class _OverlayRegionMediaCapability + { + public: + _OverlayRegionMediaCapability(void); + + virtual ~_OverlayRegionMediaCapability(void); + + result Construct(void); + result ParseCapability(const char* xmlBuffer, int length); + void ParseSection(xmlNodePtr pRoot, const Tizen::Base::String& section); + + int cameraPrimaryDirection; + int cameraPrimaryRotation; + int cameraSecondaryDirection; + int cameraSecondaryRotation; + }; //_OverlayRegionMediaCapability +} + +namespace Tizen { namespace Ui { namespace Controls +{ + +int _OverlayRegionImpl::overlayRegionWidthUnit = -1; +int _OverlayRegionImpl::overlayRegionHeightUnit = -1; +int _OverlayRegionImpl::overlayRegionMaxCount = -1; +bool _OverlayRegionImpl::overlayRegionPixelFomatList[]= {false,}; + +result +_IsValidSrcDim(const Tizen::Graphics::Dimension& srcDim, int multipleValueW, int multipleValueH) +{ + result r = E_SUCCESS; + + if (srcDim.width < 0 || srcDim.height < 0) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Source dimension has negative value [w : %4d, h : %4d].", + srcDim.width, srcDim.height); + r = E_INVALID_ARG; + } + + if (srcDim.width % multipleValueW || srcDim.height % multipleValueH) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] srcDim[%4d, %4d] should be multiple of [%4d, %4d].", + srcDim.width, srcDim.height, multipleValueW, multipleValueH); + r = E_INVALID_ARG; + } + + SysLog(NID_UI_CTRL, "srcDim w:%d h:%d, UnitW[%d], UnitH[%d]", srcDim.width, srcDim.height, multipleValueW, multipleValueH); + + return r; +} + +OverlayRegionRotate +_ConvertCamToOverlayRegionRotation(OverlayRegionType type, int camDir, int camRot, int formOrientation) +{ + OverlayRegionRotate rotation = OVERLAYREGION_ROTATE_NONE; + + int tempCamDir = 0; + int tempCamRot = 0; + int tempFormRot = 0; + + switch (camDir) + { + case 1://CAMERA_DIRECTION_FRONT: + tempCamDir = 1; + break; + case 2://CAMERA_DIRECTION_BACK: + tempCamDir = 2; + break; + default: + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] cameraRot [%d] is invalid", camRot); + return rotation; + } + + switch (camRot) + { + case 1://CAMERA_ROTATION_NONE: + tempCamRot = 0; + break; + case 2://CAMERA_ROTATION_90: + tempCamRot = 1; + break; + case 3://CAMERA_ROTATION_180: + tempCamRot = 2; + break; + case 4://CAMERA_ROTATION_270: + tempCamRot = 3; + break; + default: + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] cameraRot [%d] is invalid", camRot); + return rotation; + } + + switch (static_cast(formOrientation)) + { + case ORIENTATION_STATUS_PORTRAIT: + tempFormRot = 0; + break; + case ORIENTATION_STATUS_LANDSCAPE: + tempFormRot = 1; + break; + case ORIENTATION_STATUS_PORTRAIT_REVERSE: + tempFormRot = 2; + break; + case ORIENTATION_STATUS_LANDSCAPE_REVERSE: + tempFormRot = 3; + break; + default: + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] formOrientation [%d] is invalid", formOrientation); + return rotation; + } + + if (type == OVERLAY_REGION_TYPE_NORMAL) + { + rotation = OVERLAYREGION_ROTATE_0; + } + else if(type == OVERLAY_REGION_TYPE_PRIMARY_CAMERA) + { + rotation = static_cast((_ROTATION_COUNT - (tempFormRot - tempCamRot)) % _ROTATION_COUNT); + } + else if(type == OVERLAY_REGION_TYPE_SECONDARY_CAMERA) + { + rotation = static_cast((tempFormRot + tempCamRot) % _ROTATION_COUNT); + } + + SysLog(NID_UI_CTRL, "type : %d, rotation:%d, cameraDir : %d, camRot:%d, formOrientation:%d", type, rotation, tempCamDir, tempCamRot, tempFormRot); + + return rotation; +} + +_OverlayRegionImpl::_OverlayRegionImpl(void) + : __pParentForm(null) + , __pOverlayRegion(null) + , __destRect(0, 0, 0, 0) + , __overlayRegionType(OVERLAY_REGION_TYPE_MIN) + , __showState(true) + , __myIdx(-1) + , __cameraDirection(2/*CAMERA_DIRECTION_BACK*/) + , __cameraRotation(1/*CAMERA_ROTATION_NONE*/) + , __pOverlayAgent(null) +{ + +} + +_OverlayRegionImpl::~_OverlayRegionImpl(void) +{ + if (__pParentForm) + { + if (__myIdx != -1) + { + __pParentForm->__ppOverlayerRegionImplArray[__myIdx] = null; + } + + __pParentForm->__overlayRegionCount--; + } + + SysLog(NID_UI_CTRL, "destructor : __myIdx [%d], parentForm : [%x]", __myIdx, __pParentForm); + + if (__pOverlayAgent) + { + delete __pOverlayAgent; + } +} + +Tizen::Graphics::Rectangle +_OverlayRegionImpl::GetBounds(void) const +{ + return __destRect; +} + +void +_OverlayRegionImpl::GetBounds(int& x, int& y, int& width, int& height) const +{ + x = __destRect.x; + y = __destRect.y; + width = __destRect.width; + height = __destRect.height; +} + +int test = 1; + +result +_OverlayRegionImpl::SetInputBuffer(const Tizen::Base::ByteBuffer& srcBuffer, const Tizen::Graphics::Dimension& srcDim, OverlayRegionBufferPixelFormat srcFormat, bool isUserInput) +{ + result r = _IsValidSrcDim(srcDim, OverlayRegion::GetWidthUnit(), OverlayRegion::GetHeightUnit()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r) ); + + if (!_OverlayRegionImpl::overlayRegionPixelFomatList[0]) + { + result r = _OverlayRegionImpl::SetPixelFormatList(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + _OverlayAgentBufferPixelFormat format = _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_ARGB8888; + + switch (srcFormat) + { + case OVERLAY_REGION_BUFFER_PIXEL_FORMAT_ARGB8888: + format = _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_ARGB8888; + break; + case OVERLAY_REGION_BUFFER_PIXEL_FORMAT_RGB565: + format = _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_RGB565; + break; + case OVERLAY_REGION_BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR: + format = _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR; + break; + case OVERLAY_REGION_BUFFER_PIXEL_FORMAT_NV12: + format = _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_NV12; + break; + case OVERLAY_REGION_BUFFER_PIXEL_FORMAT_UYVY: + format = _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_UYVY; + break; + default: + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] srcFormat [%d] is not supported!", srcFormat); + return E_UNSUPPORTED_FORMAT; + } + + if (!_OverlayRegionImpl::overlayRegionPixelFomatList[srcFormat]) + { + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] srcFormat [%d] is not supported!", srcFormat); + return E_UNSUPPORTED_FORMAT; + } + + int size = srcBuffer.GetCapacity(); + SysTryReturnResult(NID_UI_CTRL, size > 0, E_INVALID_ARG, "[E_INVALID_ARG] source size[%d] is invalid!", size); + + r = __pOverlayAgent->SetInputBuffer(Dimension(__destRect.width, __destRect.height), srcBuffer, srcDim, format); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r) ); + + SysTryReturnResult(NID_UI_CTRL, __showState, E_SYSTEM, "[E_SYSTEM]__showState is false! don't draw now.."); + + r = __pOverlayAgent->Draw(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r) ); + + return E_SUCCESS; +} + +result +_OverlayRegionImpl::GetBackgroundBufferInfo(Tizen::Graphics::BufferInfo& info) const +{ + BufferInfo bgBufInfo; + _BufferInfoImpl* pBufInfoImpl = null; + + SysTryReturnResult(NID_UI_CTRL, __pOverlayAgent != null, E_INVALID_STATE, "[E_INVALID_STATE] __pOverlayAgent is null."); + __pOverlayAgent->GetBufferInfo(info); + + pBufInfoImpl = _BufferInfoImpl::GetInstance(info); + SysTryReturnResult(NID_UI_CTRL, pBufInfoImpl != null , E_SYSTEM, "[E_SYSTEM] pBufInfoImpl is null."); + + Tizen::Ui::Controls::_FormImpl* pFormImpl = static_cast<_FormImpl*>(__pParentForm->GetUserData()); + SysTryReturn(NID_UI_CTRL, pFormImpl != null, false, E_SYSTEM, "[E_SYSTEM] pParentForm impl is null."); + + Tizen::Ui::OrientationStatus formOrientationStatus = pFormImpl->GetOrientationStatus(); + switch (formOrientationStatus) + { + case ORIENTATION_STATUS_NONE: + // fall through + case ORIENTATION_STATUS_PORTRAIT: + pBufInfoImpl->SetOrientation(_BufferInfoImpl::ORIENTATION_PORTRAIT); + break; + case ORIENTATION_STATUS_LANDSCAPE : + pBufInfoImpl->SetOrientation(_BufferInfoImpl::ORIENTATION_LANDSCAPE); + break; + case ORIENTATION_STATUS_PORTRAIT_REVERSE: + pBufInfoImpl->SetOrientation(_BufferInfoImpl::ORIENTATION_PORTRAIT_REVERSE); + break; + case ORIENTATION_STATUS_LANDSCAPE_REVERSE: + pBufInfoImpl->SetOrientation(_BufferInfoImpl::ORIENTATION_LANDSCAPE_REVERSE); + break; + } + + switch (__cameraRotation) + { + case 1://CAMERA_ROTATION_NONE + pBufInfoImpl->SetRotation(_BufferInfoImpl::ROTATION_0); + break; + case 2://CAMERA_ROTATION_90: + pBufInfoImpl->SetRotation(_BufferInfoImpl::ROTATION_90); + break; + case 3://CAMERA_ROTATION_180: + pBufInfoImpl->SetRotation(_BufferInfoImpl::ROTATION_180); + break; + case 4://CAMERA_ROTATION_270: + pBufInfoImpl->SetRotation(_BufferInfoImpl::ROTATION_270); + break; + } + + return E_SUCCESS; +} + +result +_OverlayRegionImpl::Show(void) const +{ + SysTryReturnResult(NID_UI_CTRL, __pOverlayAgent != null, E_SYSTEM, "[E_SYSTEM] __pOverlayAgent is null."); + return __pOverlayAgent->Show(); +} + +result +_OverlayRegionImpl::Construct(_Form* pParentForm, OverlayRegionType overlayRegionType, const Point& leftTopPos, const Rectangle& userDestRect, const Rectangle& finalPhyRect) +{ + result r = E_SUCCESS; + byte* pBuf = null; + + switch (overlayRegionType) + { + case OVERLAY_REGION_TYPE_PRIMARY_CAMERA: + { + _OverlayRegionMediaCapability capability; + r = capability.Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r) ); + + __cameraDirection = capability.cameraPrimaryDirection; + __cameraRotation = capability.cameraPrimaryRotation; + + break; + } + case OVERLAY_REGION_TYPE_SECONDARY_CAMERA: + { + _OverlayRegionMediaCapability capability; + r = capability.Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r) ); + + __cameraDirection = capability.cameraSecondaryDirection; + __cameraRotation = capability.cameraSecondaryRotation; + + break; + } + case OVERLAY_REGION_TYPE_NORMAL: + break; + default: + SysLogException(NID_UI_CTRL, E_UNSUPPORTED_FORMAT, "[E_UNSUPPORTED_FORMAT] overlayRegionType [%d] is not supported!", overlayRegionType); + return E_UNSUPPORTED_FORMAT; + } + + SysTryReturnResult(NID_UI_CTRL, pParentForm != null, E_SYSTEM, "[E_SYSTEM] pParentForm impl is null."); + + Tizen::Ui::Controls::_FormImpl* pFormImpl = static_cast<_FormImpl*>(pParentForm->GetUserData()); + SysTryReturnResult(NID_UI_CTRL, pFormImpl != null, E_SYSTEM, "[E_SYSTEM] pFormImpl impl is null."); + + OverlayRegionRotate rotation = _ConvertCamToOverlayRegionRotation(overlayRegionType, __cameraDirection, __cameraRotation, pFormImpl->GetOrientationStatus()); + SysTryReturnResult(NID_UI_CTRL, rotation != OVERLAYREGION_ROTATE_NONE, E_SYSTEM, "[E_SYSTEM] __rotation is OVERLAYREGION_ROTATE_NONE."); + + //Rectangle overlayRect(leftTopPos.x, leftTopPos.y, destRect.width, destRect.height); + //SysLog(NID_UI_CTRL,"overlayAgentRect[%d, %d, %d, %d]", overlayRect.x, overlayRect.y, overlayRect.width, overlayRect.height); + + _OverlayAgentStyle overlayAgentType = _OVERLAY_AGENT_STYLE_REGION_SW; + String preferredEngineConfig(elm_config_preferred_engine_get()); + if(preferredEngineConfig.Equals("opengl_x11", true)) + { + overlayAgentType = _OVERLAY_AGENT_STYLE_REGION_GL; + SysLog(NID_UI_CTRL,"xml : HwAcceleration was set to On"); + } + else if(preferredEngineConfig.Equals("software_x11", true)) + { + overlayAgentType = _OVERLAY_AGENT_STYLE_REGION_SW; + SysLog(NID_UI_CTRL,"xml : HwAcceleration was set to Off"); + } + else + { + String engineConfig(elm_config_engine_get()); + if(engineConfig.Equals("opengl_x11", true)) + { + overlayAgentType = _OVERLAY_AGENT_STYLE_REGION_GL; + SysLog(NID_UI_CTRL,"dev setting option : gl backend"); + } + else + { + SysLog(NID_UI_CTRL,"dev setting option : sw backend"); + } + } + + __pOverlayAgent = _OverlayAgent::CreateInstanceN(overlayAgentType, *pParentForm, finalPhyRect); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS && __pOverlayAgent != null, r, r, "[%s] pPropagating.", GetErrorMessage(r)); + + __pParentForm = pParentForm; + __overlayRegionType = overlayRegionType; + __destRect = userDestRect; + + if(overlayAgentType == _OVERLAY_AGENT_STYLE_REGION_GL) + { + r = __pOverlayAgent->CreatePixmap(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + SysLog(NID_UI_CTRL,"not need to make a pixmap"); + } + + switch(rotation) + { + case OVERLAYREGION_ROTATE_0: + __pOverlayAgent->SetRotation(_OVERLAY_AGENT_ROTATION_NONE); + break; + case OVERLAYREGION_ROTATE_90: + __pOverlayAgent->SetRotation(_OVERLAY_AGENT_ROTATION_90); + break; + case OVERLAYREGION_ROTATE_180: + __pOverlayAgent->SetRotation(_OVERLAY_AGENT_ROTATION_180); + break; + case OVERLAYREGION_ROTATE_270: + __pOverlayAgent->SetRotation(_OVERLAY_AGENT_ROTATION_270); + break; + default: + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] rotate value[%d] is invalid.", rotation); + return E_SYSTEM; + } + + if (overlayAgentType == _OVERLAY_AGENT_STYLE_REGION_SW) + { + int i, j; + int size = finalPhyRect.width * finalPhyRect.height * 4; + pBuf = new (std::nothrow) byte[size]; + SysTryCatch(NID_UI_CTRL, pBuf != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pBuf is null."); + + unsigned long* pPos = (unsigned long*)pBuf; + for(i=0;i__pOverlayRegionImpl = this; + + return pOverlayRegion; +} + +void +_OverlayRegionImpl::SetFormArrayIndex(int index) +{ + __myIdx = index; + return; +} + +OverlayRegion* +_OverlayRegionImpl::GetOverlayRegion(void) const +{ + return __pOverlayRegion; +} + +void +_OverlayRegionImpl::GoForeground(void) +{ + __showState = true; + + SysTryReturnVoidResult(NID_UI_CTRL, __pOverlayAgent != null, E_SYSTEM, "[E_SYSTEM] __pOverlayAgent impl is null."); + SysLog(NID_UI_CTRL, "GoForeground pixmap : %d", __pOverlayAgent->GetPixmap()); + //__pOverlayAgent->AdjustImageObject(); + + return; +} + +void +_OverlayRegionImpl::GoBackground(void) +{ + __showState = false; + + SysTryReturnVoidResult(NID_UI_CTRL, __pOverlayAgent != null, E_SYSTEM, "[E_SYSTEM] __pOverlayAgent impl is null."); + __pOverlayAgent->UngrabXvPort(); + + SysLog(NID_UI_CTRL, "GoBackground pixmap : %d", __pOverlayAgent->GetPixmap()); + + return; +} + +result +_OverlayRegionImpl::IsValidOverlayRect(Tizen::Graphics::Rectangle& userRect, Tizen::Graphics::Rectangle& overlayPhysicalRect, const Tizen::Graphics::Rectangle& basePhysicalRect, bool& modified) +{ + result r = E_SUCCESS; + + if ((overlayPhysicalRect.width < _OverlayAgent::GetDstRectMinWidth()) || (overlayPhysicalRect.height < _OverlayAgent::GetDstRectMinHeight())) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] size of OverlayRegoin is invalid [w : %4d, h : %4d].", + overlayPhysicalRect.width, overlayPhysicalRect.height); + return E_INVALID_ARG; + } + + int base = overlayRegionWidthUnit / 2; + if (base != 0) + { + int modW = overlayPhysicalRect.width % overlayRegionWidthUnit; + if (modW != 0) + { + if (modW <= base) + { + overlayPhysicalRect.width -= modW; + } + else + { + overlayPhysicalRect.width += (overlayRegionWidthUnit - modW); + } + modified = true; + } + } + + base = overlayRegionHeightUnit / 2; + if (base != 0) + { + int modH = overlayPhysicalRect.height % overlayRegionHeightUnit; + if (modH != 0) + { + if (modH <= base) + { + overlayPhysicalRect.height -= modH; + } + else + { + overlayPhysicalRect.height += (overlayRegionHeightUnit - modH); + } + modified = true; + } + } + + Rectangle rect = _CoordinateSystemUtils::InverseTransform(overlayPhysicalRect); + if (rect.width != userRect.width || rect.height != userRect.height ) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] __InvR(overlayPhysicalRect [%d, %d, %d, %d]) (w : %4d, h : %4d) org (w : %4d, h : %4d) is not same", + overlayPhysicalRect.x, overlayPhysicalRect.y, overlayPhysicalRect.width, overlayPhysicalRect.height, rect.width, rect.height, userRect.width, userRect.height); + return E_INVALID_ARG; + } + + // First, overlayPhysicalRect's x, y position should be positive value or zero. + if (!((overlayPhysicalRect.x >= 0) && (overlayPhysicalRect.y >= 0) && + // Second, Check if it is clipping or not. (OverlayRegion cannot be clipped) + (overlayPhysicalRect.x + overlayPhysicalRect.width <= basePhysicalRect.x + basePhysicalRect.width) && + (overlayPhysicalRect.y + overlayPhysicalRect.height <= basePhysicalRect.y + basePhysicalRect.height))) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] The bounds of OverlayRegion is now outside of the current form " + "overlayPhysicalRect (x : %4d, y: %4d, w : %4d, h : %4d), " + "basePhysicalRect (x : %4d, y: %4d, w : %4d, h : %4d).", + overlayPhysicalRect.x, overlayPhysicalRect.y, overlayPhysicalRect.width, overlayPhysicalRect.height, + basePhysicalRect.x, basePhysicalRect.y, basePhysicalRect.width, basePhysicalRect.height); + r = E_INVALID_ARG; + } + +// SysLog(NID_UI_CTRL, " overlayPhysicalRect [%d, %d, %d, %d], basePhysicalRect [%d, %d, %d, %d] modified[%d]", +// overlayPhysicalRect.x, overlayPhysicalRect.y, overlayPhysicalRect.width, overlayPhysicalRect.height, +// basePhysicalRect.x, basePhysicalRect.y, basePhysicalRect.width, basePhysicalRect.height, modified ); + + return r; +} + +result +_OverlayRegionImpl::SetPixelFormatList(void) +{ +#ifndef _OSP_EMUL_ + String formatList; + + result r = E_SUCCESS; + _RegistryImpl _reg; + + r = _reg.Construct(_UI_REGISTRY_PATH, REG_OPEN_READ_ONLY, null); + if (IsFailed(r)) + { + if (r == E_OUT_OF_MEMORY) + { + SysTryReturn(NID_UI_CTRL, r != E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + SysAssertf(0, "failed to Construct the _RegistryImpl"); + } + } + + r = _reg.GetValue(_UI_INFO_SESSION, L"OverlayRegionBufferPixelFormat", formatList); + SysAssertf(!IsFailed(r), "Failed to get a registry value"); + + SysLog(NID_UI_CTRL,"FormatList: %ls", formatList.GetPointer()); +#else + String formatList(L"ARGB8888/RGB565/YCbCr420P"); +#endif + + bool set = false; + if (formatList.Contains(L"ARGB8888")) + { + overlayRegionPixelFomatList[OVERLAY_REGION_BUFFER_PIXEL_FORMAT_ARGB8888] = true; + set = true; + } + + if (formatList.Contains(L"RGB565")) + { + overlayRegionPixelFomatList[OVERLAY_REGION_BUFFER_PIXEL_FORMAT_RGB565] = true; + set = true; + } + + if (formatList.Contains(L"YCbCr420P")) + { + overlayRegionPixelFomatList[OVERLAY_REGION_BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR] = true; + set = true; + } + + if (formatList.Contains(L"NV12")) + { + overlayRegionPixelFomatList[OVERLAY_REGION_BUFFER_PIXEL_FORMAT_NV12] = true; + set = true; + } + + if (formatList.Contains(L"UYVY")) + { + overlayRegionPixelFomatList[OVERLAY_REGION_BUFFER_PIXEL_FORMAT_UYVY] = true; + set = true; + } + + SysAssertf(set, "registry file is something wrong"); + + overlayRegionPixelFomatList[0] = set; + + return E_SUCCESS; +} + +int +_OverlayRegionImpl::GetWidthUnit(void) +{ + ClearLastResult(); + + if (_OverlayRegionImpl::overlayRegionWidthUnit == -1) + { + result r = E_SUCCESS; + _RegistryImpl _reg; + String value; + int val; + + r = _reg.Construct(_UI_REGISTRY_PATH, REG_OPEN_READ_ONLY, null); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] RegistryImpl construct Failed"); + + r = _reg.GetValue(_UI_INFO_SESSION, L"OverlayRegionWidthUnit", value); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Registry GetValue Failed"); + + r = Integer::Parse(value, val); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Parse Failed"); + + _OverlayRegionImpl::overlayRegionWidthUnit = val; + + SysLog(NID_UI_CTRL, "overlayRegionWidthUnit : %d", _OverlayRegionImpl::overlayRegionWidthUnit); + } + + SetLastResult(E_SUCCESS); + + return _OverlayRegionImpl::overlayRegionWidthUnit; +} + +int +_OverlayRegionImpl::GetHeightUnit(void) +{ + ClearLastResult(); + + if (_OverlayRegionImpl::overlayRegionHeightUnit == -1) + { + result r = E_SUCCESS; + _RegistryImpl _reg; + String value; + int val; + + r = _reg.Construct(_UI_REGISTRY_PATH, REG_OPEN_READ_ONLY, null); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] RegistryImpl construct Failed"); + + r = _reg.GetValue(_UI_INFO_SESSION, L"OverlayRegionHeightUnit", value); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Registry GetValue Failed"); + + r = Integer::Parse(value, val); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Parse Failed"); + + _OverlayRegionImpl::overlayRegionHeightUnit = val; + + SysLog(NID_UI_CTRL, "overlayRegionHeightUnit : %d", _OverlayRegionImpl::overlayRegionHeightUnit); + } + + SetLastResult(E_SUCCESS); + + return _OverlayRegionImpl::overlayRegionHeightUnit; +} + +int +_OverlayRegionImpl::GetMaxCount(void) +{ + ClearLastResult(); + + if (_OverlayRegionImpl::overlayRegionMaxCount == -1) + { + result r = E_SUCCESS; + _RegistryImpl _reg; + String value; + int val; + + r = _reg.Construct(_UI_REGISTRY_PATH, REG_OPEN_READ_ONLY, null); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] RegistryImpl construct Failed"); + + r = _reg.GetValue(_UI_INFO_SESSION, L"MaxOverlayRegionCount", value); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Registry GetValue Failed"); + + r = Integer::Parse(value, val); + SysTryReturn(NID_UI_CTRL, !IsFailed(r), -1, E_SYSTEM, "[E_SYSTEM] Parse Failed"); + + _OverlayRegionImpl::overlayRegionMaxCount = val; + + SysLog(NID_UI_CTRL, "overlayRegionMaxCount : %d", _OverlayRegionImpl::overlayRegionMaxCount); + } + + SetLastResult(E_SUCCESS); + + return _OverlayRegionImpl::overlayRegionMaxCount; +} + + _OverlayRegionImpl* +_OverlayRegionImpl::GetInstance(OverlayRegion& overlayRegion) +{ + return (&overlayRegion != null) ? overlayRegion.__pOverlayRegionImpl : null; +} + +const _OverlayRegionImpl* +_OverlayRegionImpl::GetInstance(const OverlayRegion& overlayRegion) +{ + return (&overlayRegion != null) ? overlayRegion.__pOverlayRegionImpl : null; +} + +} } } // Tizen::Ui::Controls + + +////////////////////////////////////////////////////////////////////////////////////// +namespace +{ + +_OverlayRegionMediaCapability::_OverlayRegionMediaCapability(void) + : cameraPrimaryDirection(0) + , cameraPrimaryRotation(0) + , cameraSecondaryDirection(0) + , cameraSecondaryRotation(0) +{ +} + +_OverlayRegionMediaCapability::~_OverlayRegionMediaCapability(void) +{ +} + +result +_OverlayRegionMediaCapability::Construct(void) +{ + result r = E_SUCCESS; + long long length = 0; + int readLen = 0; + char* pXmlBuffer = null; + Tizen::Base::String key; + Tizen::Base::String fileName; + FileAttributes attributes; + File fileObj; + + fileName = _MEDIA_CAPABILITY_FILE_PATH; + SysLog(NID_UI_CTRL, "Capability XML path:%ls", fileName.GetPointer()); + + r = File::GetAttributes(fileName, attributes); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r) ); + + length = attributes.GetFileSize(); + SysTryReturnResult(NID_UI_CTRL, length > 0, E_SYSTEM, "[E_SYSTEM] the file[%s] size is zero.", fileName.GetPointer()); + + pXmlBuffer = new (std::nothrow) char[length]; + SysTryReturnResult(NID_UI_CTRL, pXmlBuffer != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pXmlBuffer is null"); + + r = fileObj.Construct(fileName, L"r"); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + +// read the capability xml file content as parse the capability + readLen = fileObj.Read(pXmlBuffer, length); + SysTryCatch(NID_UI_CTRL, readLen == length, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] length:%d, readLen:%d", length, readLen); + +// parse the capability file buffer all the parse key value pair shall be added in __pMap object + r = ParseCapability(pXmlBuffer, readLen); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (pXmlBuffer) + { + delete[] pXmlBuffer; + } + + return E_SUCCESS; + +CATCH: + if (pXmlBuffer) + { + delete[] pXmlBuffer; + } + + return r; +} + +void +_OverlayRegionMediaCapability::ParseSection(xmlNodePtr pRoot, const String& section) +{ + xmlNode* pNode = null; + + for (pNode = pRoot->children; pNode; pNode = pNode->next) + { + String name((char*)pNode->name); + String key(section); + + key += "." + name; + + if (pNode->type == XML_ELEMENT_NODE && pNode->children) + { + if (key.Equals(String(_CAM_PRIMARY_DIRECTION))) + { + //SysLog(NID_UI_CTRL,"@@@@@ key:%ls, %s", key.GetPointer(), (wchar_t*)pNode->children->content); + String direction((char*)pNode->children->content); + if (direction.Equals(String("Back"))) + cameraPrimaryDirection = 2;//CAMERA_DIRECTION_BACK; + else + cameraPrimaryDirection = 1;//CAMERA_DIRECTION_FRONT; + } + else if (key.Equals(String(_CAM_PRIMARY_ROTATION))) + { + //SysLog(NID_UI_CTRL,"@@@@@ key:%ls, %s", key.GetPointer(), (wchar_t*)pNode->children->content ); + String rot((char*)pNode->children->content); + int ret = 0 ; + Integer::Decode(rot, ret); + cameraPrimaryRotation = (ret / 90) + 1; + } + else if (key.Equals(String(_CAM_SECONDARY_DIRECTION))) + { + //SysLog(NID_UI_CTRL,"@@@@@ key:%ls, %s", key.GetPointer(), (wchar_t*)pNode->children->content ); + String direction((char*)pNode->children->content); + if (direction.Equals(String("Back"))) + cameraSecondaryDirection = 2;//CAMERA_DIRECTION_BACK; + else + cameraSecondaryDirection = 1;//CAMERA_DIRECTION_FRONT; + } + else if (key.Equals(String(_CAM_SECONDARY_ROTATION))) + { + //SysLog(NID_UI_CTRL,"@@@@@ key:%ls, %s", key.GetPointer(), (wchar_t*)pNode->children->content ); + String rot((char*)pNode->children->content); + int ret = 0 ; + Integer::Decode(rot, ret); + cameraSecondaryRotation = (ret / 90) + 1; + } + } + + ParseSection(pNode, key); + } +} + +result +_OverlayRegionMediaCapability::ParseCapability(const char* xmlBuffer, int length) +{ + xmlDoc* pDoc = null; + xmlNode* pRoot = null; + xmlNode* pNode = null; + + result r = E_SUCCESS; + String name; + + pDoc = xmlParseMemory(xmlBuffer, length); + SysTryReturnResult(NID_UI_CTRL, pDoc != null, E_SYSTEM, "[E_SYSTEM] xmlParseMemory failed %s %d", xmlBuffer, length); + + pRoot = xmlDocGetRootElement(pDoc); + SysTryCatch(NID_UI_CTRL, pRoot != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] xmlDocGetRootElement failed"); + + name = (const char*) (pRoot->name); + SysTryCatch(NID_UI_CTRL, name.Equals("MediaCapability", true), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Invalid Root Name %ls", name.GetPointer()); + + for (pNode = pRoot->children; pNode; pNode = pNode->next) + { + if (pNode->type == XML_ELEMENT_NODE) + { + String nodeName((char*)pNode->name); + ParseSection(pNode, nodeName); + } + } + + xmlFreeDoc(pDoc); + return E_SUCCESS; + +CATCH: + if (pDoc) + { + xmlFreeDoc(pDoc); + } + + return r; +} + +} diff --git a/src/ui/controls/FUiCtrl_Panel.cpp b/src/ui/controls/FUiCtrl_Panel.cpp new file mode 100644 index 0000000..c31ce86 --- /dev/null +++ b/src/ui/controls/FUiCtrl_Panel.cpp @@ -0,0 +1,345 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_Panel.cpp + * @brief This is the implementation file for the %_Panel class. + * + */ + +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_Panel.h" +#include "FUi_DataBindingContext.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_Panel::_Panel(void) + : _Control() + , __pPanelPresenter(null) + , __groupStyle(GROUP_STYLE_NONE) + , __pGroupStyleBitmap(null) + , __pGroupStyleBackgroundBitmap(null) + , __backgroundBitmapStretch(false) + , __backgroundBitmapHorizontalAlign(PANEL_BACKGROUND_BITMAP_HORIZONTAL_ALIGN_CENTER) + , __backgroundBitmapVerticalAlign(PANEL_BACKGROUND_BITMAP_VERTICAL_ALIGN_MIDDLE) + , __pBackgroundBitmap(null) +{ + // Nothing +} + +_Panel::~_Panel(void) +{ + delete __pBackgroundBitmap; + __pBackgroundBitmap = null; + + delete __pGroupStyleBackgroundBitmap; + __pGroupStyleBackgroundBitmap = null; + + delete __pGroupStyleBitmap; + __pGroupStyleBitmap = null; + + delete __pPanelPresenter; + __pPanelPresenter = null; +} + +_Panel* +_Panel::CreatePanelN(const Rectangle& rect, GroupStyle groupStyle) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _Panel* pPanel = new (std::nothrow) _Panel; + SysTryReturn(NID_UI_CTRL, pPanel != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + _PanelPresenter* pPresenter = new (std::nothrow) _PanelPresenter; + SysTryCatch(NID_UI_CTRL, pPresenter != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + r = pPresenter->Initialize(*pPanel); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pPanel->Initialize(*pPresenter); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pPanel->SetGroupStyle(groupStyle); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pPanel->AcquireHandle(); + + return pPanel; + +CATCH: + delete pPresenter; + pPanel->__pPanelPresenter = null; + + delete pPanel; + + SetLastResult(r); + return null; +} + +result +_Panel::Initialize(const _PanelPresenter& presenter) +{ + ClearLastResult(); + + SetPanelPresenter(&presenter); + + result r = GetVisualElement()->SetSurfaceOpaque(false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetBackgroundColor(Color(0, 0, 0, 0)); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // create data binding context + _DataBindingContext* pContext = new (std::nothrow) _DataBindingContext(*this); + SysTryCatch(NID_UI_CTRL, pContext != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetDataBindingContext(pContext); + + SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_NORMAL); + + return r; + +CATCH: + delete pContext; + + return r; +} + +result +_Panel::SetPanelPresenter(const _PanelPresenter* panelPresenter) +{ + ClearLastResult(); + + __pPanelPresenter = const_cast <_PanelPresenter*>(panelPresenter); + + return E_SUCCESS; +} + +void +_Panel::OnDraw(void) +{ + ClearLastResult(); + + if (__pPanelPresenter != null) + { + result r = __pPanelPresenter->Draw(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } +} + +void +_Panel::SetBackgroundColor(const Tizen::Graphics::Color& color) +{ + ClearLastResult(); + + _Control::SetBackgroundColor(color); + + if (__groupStyle != GROUP_STYLE_NONE) + { + Invalidate(); + } +} + +GroupStyle +_Panel::GetGroupStyle(void) const +{ + ClearLastResult(); + + return __groupStyle; +} + +void +_Panel::SetGroupStyle(GroupStyle groupStyle) +{ + ClearLastResult(); + + if (__groupStyle == groupStyle) + { + return; + } + __groupStyle = groupStyle; + + delete __pGroupStyleBackgroundBitmap; + __pGroupStyleBackgroundBitmap = null; + + delete __pGroupStyleBitmap; + __pGroupStyleBitmap = null; + + result r = E_SUCCESS; + switch (__groupStyle) + { + case GROUP_STYLE_TOP: + r = GET_BITMAP_CONFIG_N(Panel::GROUPED_TOP_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = GET_BITMAP_CONFIG_N(Panel::GROUPED_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBackgroundBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + break; + case GROUP_STYLE_MIDDLE: + r = GET_BITMAP_CONFIG_N(Panel::GROUPED_MIDDLE_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = GET_BITMAP_CONFIG_N(Panel::GROUPED_MIDDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBackgroundBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + break; + case GROUP_STYLE_BOTTOM: + r = GET_BITMAP_CONFIG_N(Panel::GROUPED_BOTTOM_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = GET_BITMAP_CONFIG_N(Panel::GROUPED_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBackgroundBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + break; + case GROUP_STYLE_SINGLE: + r = GET_BITMAP_CONFIG_N(Panel::GROUPED_SINGLE_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = GET_BITMAP_CONFIG_N(Panel::GROUPED_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBackgroundBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + break; + case GROUP_STYLE_NONE: + // fall through + default: + break; + } + + return; +CATCH: + delete __pGroupStyleBackgroundBitmap; + __pGroupStyleBackgroundBitmap = null; + delete __pGroupStyleBitmap; + __pGroupStyleBitmap = null; + + SetLastResult(r); +} + +Bitmap* +_Panel::GetGroupStyleBitmap(void) const +{ + ClearLastResult(); + + return __pGroupStyleBitmap; +} + +Bitmap* +_Panel::GetGroupStyleBackgroundBitmap(void) const +{ + ClearLastResult(); + + return __pGroupStyleBackgroundBitmap; +} + +bool +_Panel::IsBackgroundBitmapStretch(void) const +{ + ClearLastResult(); + + return __backgroundBitmapStretch; +} + +void +_Panel::SetBackgroundBitmapStretch(bool stretch) +{ + ClearLastResult(); + + __backgroundBitmapStretch = stretch; +} + +_PanelBackgroundBitmapHorizontalAlign +_Panel::GetBackgroundBitmapHorizontalAlign(void) const +{ + ClearLastResult(); + + return __backgroundBitmapHorizontalAlign; +} + +void +_Panel::SetBackgroundBitmapHorizontalAlign(_PanelBackgroundBitmapHorizontalAlign align) +{ + ClearLastResult(); + + __backgroundBitmapHorizontalAlign = align; +} + +_PanelBackgroundBitmapVerticalAlign +_Panel::GetBackgroundBitmapVerticalAlign(void) const +{ + ClearLastResult(); + + return __backgroundBitmapVerticalAlign; +} + +void +_Panel::SetBackgroundBitmapVerticalAlign(_PanelBackgroundBitmapVerticalAlign align) +{ + ClearLastResult(); + + __backgroundBitmapVerticalAlign = align; +} + +void +_Panel::SetBackgroundBitmapAlign(_PanelBackgroundBitmapHorizontalAlign horizontalAlign, _PanelBackgroundBitmapVerticalAlign verticalAlign) +{ + ClearLastResult(); + + SetBackgroundBitmapHorizontalAlign(horizontalAlign); + SetBackgroundBitmapVerticalAlign(verticalAlign); +} + +Bitmap* +_Panel::GetBackgroundBitmap(void) const +{ + ClearLastResult(); + + return __pBackgroundBitmap; +} + +void +_Panel::SetBackgroundBitmap(Bitmap* bitmap) +{ + ClearLastResult(); + + if (__pBackgroundBitmap != bitmap) + { + delete __pBackgroundBitmap; + __pBackgroundBitmap = null; + } + + if (bitmap == null) + { + return; + } + + __pBackgroundBitmap = _BitmapImpl::CloneN(*bitmap); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + Invalidate(); +} + + +}}} //Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_PanelImpl.cpp b/src/ui/controls/FUiCtrl_PanelImpl.cpp new file mode 100644 index 0000000..2d18939 --- /dev/null +++ b/src/ui/controls/FUiCtrl_PanelImpl.cpp @@ -0,0 +1,413 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_PanelImpl.cpp + * @brief This is the implementation file for the %_PanelImpl class. + * + */ + +#include +#include +#include +#include "FUi_LayoutImpl.h" +#include "FUi_DataBindingContextImpl.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_PanelImpl.h" +#include "FUiCtrl_FormImpl.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_PanelImpl::_PanelImpl(Control* pPublic, _Control* pCore, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout) + : _ContainerImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout) +{ + // nothing +} + +_PanelImpl::~_PanelImpl(void) +{ + // nothing +} + +_PanelImpl* +_PanelImpl::CreatePanelImplN(Panel* pControl, const Rectangle& rect, GroupStyle groupStyle, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout) +{ + ClearLastResult(); + + _PanelImpl* pImpl = null; + _Panel* pCore = null; + + if (pPublicPortraitLayout != null) + { + _LayoutImpl* pPortraitLayoutImpl = _LayoutImpl::GetInstance(*pPublicPortraitLayout); + SysTryReturn(NID_UI_CTRL, pPortraitLayoutImpl != null, null, E_INVALID_ARG, "[%s] Portrait layout is invalid object.", GetErrorMessage(E_INVALID_ARG)); + } + + if (pPublicLandscapeLayout != null) + { + _LayoutImpl* pLandscapeLayoutImpl = _LayoutImpl::GetInstance(*pPublicLandscapeLayout); + SysTryReturn(NID_UI_CTRL, pLandscapeLayoutImpl != null, null, E_INVALID_ARG, "[%s] Landscape layout is invalid object", GetErrorMessage(E_INVALID_ARG)); + } + + pCore = _Panel::CreatePanelN(rect, groupStyle); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl = new (std::nothrow) _PanelImpl(pControl, pCore, pPublicPortraitLayout, pPublicLandscapeLayout); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->SetBounds(rect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; + +CATCH: + delete pImpl; + + SetLastResult(r); + return null; +} + +const _PanelImpl* +_PanelImpl::GetInstance(const Panel& panel) +{ + return static_cast(_ControlImpl::GetInstance(panel)); +} + +_PanelImpl* +_PanelImpl::GetInstance(Panel& panel) +{ + return static_cast<_PanelImpl*>(_ControlImpl::GetInstance(panel)); +} + +const char* +_PanelImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::Panel"; +} + +const Panel& +_PanelImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +Panel& +_PanelImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Panel& +_PanelImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Panel& +_PanelImpl::GetCore(void) +{ + return static_cast <_Panel&>(_ControlImpl::GetCore()); +} + +void +_PanelImpl::SetBackgroundColor(const Tizen::Graphics::Color& color) +{ + if (!IsOpaque()) + { + GetCore().SetBackgroundColor(color); + } + else + { + byte r, g, b, a; + color.GetColorComponents(r, g, b, a); + GetCore().SetBackgroundColor(Color(r*a/ 255, g*a/255, b*a/ 255, 255)); + } +} + +bool +_PanelImpl::IsCompositeEnabled(void) const +{ + ClearLastResult(); + return true; +} + +result +_PanelImpl::SetCompositeEnabled(bool enabled) +{ + ClearLastResult(); + + if (enabled) + { + return E_SUCCESS; + } + + SysLogException(NID_UI, E_SYSTEM, "[%s] This method is not supported.", GetErrorMessage(E_SYSTEM)); + return E_SYSTEM; +} + +result +_PanelImpl::OnAttachedToMainTree(void) +{ + SetFocusable(false); + + Rectangle builderBounds; + _ControlOrientation controlOrientation = _CONTROL_ORIENTATION_PORTRAIT; + bool exist = GetBuilderBounds(controlOrientation, builderBounds); + + if (exist) + { + _ContainerImpl* pContainerImpl = this; + _FormImpl* pParentImpl = null; + + while(pContainerImpl) + { + pParentImpl = dynamic_cast<_FormImpl*>(pContainerImpl->GetParent()); + + if (pParentImpl != null) + { + break; + } + else + { + pContainerImpl = pContainerImpl->GetParent(); + } + } + + if (pParentImpl) + { + OrientationStatus orientation = pParentImpl->GetOrientationStatus(); + if (orientation == ORIENTATION_STATUS_LANDSCAPE + || orientation == ORIENTATION_STATUS_LANDSCAPE_REVERSE) + { + controlOrientation = _CONTROL_ORIENTATION_LANDSCAPE; + GetBuilderBounds(controlOrientation, builderBounds); + } + SetBounds(builderBounds); + SetChildBuilderBouds(this, controlOrientation); + } + } + + _ContainerImpl::OnAttachedToMainTree(); + + return E_SUCCESS; +} + +void +_PanelImpl::SetChildBuilderBouds(_ContainerImpl* pContainerImpl, _ControlOrientation controlOrientation) +{ + Rectangle builderBounds; + _ContainerImpl* pTempContainerImpl; + for(int i = 0; i < pContainerImpl->GetChildCount(); i++) + { + _ControlImpl* pControlImpl = pContainerImpl->GetChild(i); + pControlImpl->GetBuilderBounds(controlOrientation, builderBounds); + pControlImpl->SetBounds(builderBounds); + pTempContainerImpl = dynamic_cast<_ContainerImpl*>(pControlImpl); + if (pTempContainerImpl != null) + { + SetChildBuilderBouds(pTempContainerImpl, controlOrientation); + } + + } +} + + +DataBindingContext* +_PanelImpl::GetDataBindingContextN(void) const +{ + return _DataBindingContextImpl::GetDataBindingContextN(*this); +} + +class _PanelMaker + : public _UiBuilderControlMaker +{ +public: + _PanelMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_PanelMaker(void){}; + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _PanelMaker* pPanelMaker = new (std::nothrow) _PanelMaker(uibuilder); + SysTryReturn(NID_UI_CTRL, pPanelMaker != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + return pPanelMaker; + }; +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + Panel* pPanel = null; + Rectangle rect; + Tizen::Base::String elementString; + int opacity = 0; + Color color; + GroupStyle panelGroupStyle = GROUP_STYLE_NONE; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + if(pControl->GetParentWin().IsEmpty()) + { + pPanel = static_cast (GetContainer()); + } + else + { + pPanel = new (std::nothrow) Panel(); + } + SysTryReturn(NID_UI_CTRL, pPanel != null, null, E_OUT_OF_MEMORY, "[%s] UiBuilder failed to create Panel object.", GetErrorMessage(E_OUT_OF_MEMORY)); + rect = pControlProperty->GetRect(); + + if (pControl->GetElement(L"groupStyle", elementString) || pControl->GetElement(L"GroupStyle", elementString)) + { + if (elementString.Equals(L"GROUP_STYLE_NONE", false)) + { + panelGroupStyle = GROUP_STYLE_NONE; + } + if (elementString.Equals(L"GROUP_STYLE_SINGLE", false)) + { + panelGroupStyle = GROUP_STYLE_SINGLE; + } + if (elementString.Equals(L"GROUP_STYLE_TOP", false)) + { + panelGroupStyle = GROUP_STYLE_TOP; + } + if (elementString.Equals(L"GROUP_STYLE_MIDDLE", false)) + { + panelGroupStyle = GROUP_STYLE_MIDDLE; + } + if (elementString.Equals(L"GROUP_STYLE_BOTTOM", false)) + { + panelGroupStyle = GROUP_STYLE_BOTTOM; + } + } + + // Construct + _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE; + GetLayoutType(pControlProperty, layoutType); + if (layoutType == UIBUILDER_LAYOUT_NONE) + { + r = pPanel->Construct(rect, panelGroupStyle); + } + else + { + Layout* pPortraitLayout = null; + Layout* pLandscapeLayout = null; + result tempResult = E_SUCCESS; + tempResult = GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout); + if (E_SUCCESS == tempResult) + { + r = pPanel->Construct(*pPortraitLayout, *pLandscapeLayout, rect, panelGroupStyle); + } + else + { + r = tempResult; + } + _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE; + + if (GetLayoutType(pControlProperty, layoutType) == false) + { + delete pPanel; + return null; + } + + if ( layoutType == UIBUILDER_LAYOUT_GRID) + { + for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++) + { + GridLayout* pGridLayout = null; + pControlProperty = pControl->GetAttribute(i); + + if ( i == UIBUILDER_ATTRIBUTE_PORTRAIT) + { + pGridLayout = dynamic_cast(pPortraitLayout); + } + else + { + pGridLayout = dynamic_cast(pLandscapeLayout); + } + SetGridLayoutContainerProperty(pGridLayout, pControlProperty); + } + } + delete pPortraitLayout; + if (pPortraitLayout != pLandscapeLayout) + { + delete pLandscapeLayout; + } + //CONSTRUCT_WITH_LAYOUT_ARG2(pPanel, rect, gStyle); + } + if (r != E_SUCCESS) + { + delete pPanel; + return null; + } + + if (pControl->GetElement(L"backgroundOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString) || pControl->GetElement(L"backgroundColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pPanel->SetBackgroundColor(color); + } + else + { + color = pPanel->GetBackgroundColor(); + color.SetAlpha(ConvertOpacity100to255(opacity)); + pPanel->SetBackgroundColor(color); + } + + // set composite mode + if (pControl->GetElement(L"compositeEnabled", elementString)) + { + if (elementString.Equals(L"false", false)) + { + pPanel->SetCompositeEnabled(false); + } + } + + return pPanel; + } + + +private: +}; // _PanelMaker + +_PanelRegister::_PanelRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"Panel", _PanelMaker::GetInstance); +} +_PanelRegister::~_PanelRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"Panel"); +} +static _PanelRegister PanelRegisterToUiBuilder; +}}} //Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_PanelPresenter.cpp b/src/ui/controls/FUiCtrl_PanelPresenter.cpp new file mode 100644 index 0000000..104a9c3 --- /dev/null +++ b/src/ui/controls/FUiCtrl_PanelPresenter.cpp @@ -0,0 +1,244 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_PanelPresenter.cpp + * @brief This is the implementation file for the %_PanelPresenter class. + * + */ + +#include +#include +#include +#include +#include "FUiAnim_VisualElement.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_PanelPresenter.h" +#include "FUiCtrl_Panel.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_PanelPresenter::_PanelPresenter(void) + : __pPanel(null) +{ + // Nothing +} + +_PanelPresenter::~_PanelPresenter(void) +{ + // Nothing +} + +result +_PanelPresenter::Initialize(_Panel& panel) +{ + __pPanel = &panel; + + return E_SUCCESS; +} + +result +_PanelPresenter::Draw(void) +{ + if (__pPanel->GetBackgroundBitmap() == null + && (__pPanel->GetGroupStyle() == GROUP_STYLE_NONE || (__pPanel->GetGroupStyleBitmap() == null && __pPanel->GetGroupStyleBackgroundBitmap() == null))) + { + return E_SUCCESS; + } + + Canvas* pCanvas = __pPanel->GetVisualElement()->GetCanvasN(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pPanel->GetGroupStyle() == GROUP_STYLE_NONE) + { + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + } + else + { + Color panelGroupBackgroundColor; + GET_COLOR_CONFIG(Panel::BG_NORMAL, panelGroupBackgroundColor); + pCanvas->SetBackgroundColor(panelGroupBackgroundColor); + } + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->Clear(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + DrawGroupStyleBackgroundBitmap(pCanvas); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + DrawBackgrounBitmap(pCanvas); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + DrawGroupStyleBitmap(pCanvas); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + // fall throw +CATCH: + delete pCanvas; + + return r; +} + +void +_PanelPresenter::DrawBackgrounBitmap(Canvas* pCanvas) +{ + Bitmap* pBackgroundBitmap = __pPanel->GetBackgroundBitmap(); + + if (pBackgroundBitmap != null) + { + Rectangle bounds = __pPanel->GetBounds(); + bounds.x = 0; + bounds.y = 0; + + if (!__pPanel->IsBackgroundBitmapStretch()) + { + int bitmapWidth = pBackgroundBitmap->GetWidth(); + int bitmapHeight = pBackgroundBitmap->GetHeight(); + + switch (__pPanel->GetBackgroundBitmapHorizontalAlign()) + { + case PANEL_BACKGROUND_BITMAP_HORIZONTAL_ALIGN_RIGHT: + bounds.x = bounds.width - bitmapWidth; + break; + case PANEL_BACKGROUND_BITMAP_HORIZONTAL_ALIGN_CENTER: + bounds.x = (bounds.width / 2) - (bitmapWidth / 2); + break; + case PANEL_BACKGROUND_BITMAP_HORIZONTAL_ALIGN_LEFT: + // fall through + default: + break; + } + + switch (__pPanel->GetBackgroundBitmapVerticalAlign()) + { + case PANEL_BACKGROUND_BITMAP_VERTICAL_ALIGN_BOTTOM: + bounds.y = bounds.height - bitmapHeight; + break; + case PANEL_BACKGROUND_BITMAP_VERTICAL_ALIGN_MIDDLE: + bounds.y = (bounds.height / 2) - (bitmapHeight / 2); + break; + case PANEL_BACKGROUND_BITMAP_VERTICAL_ALIGN_TOP: + // fall through + default: + break; + } + + bounds.width = bitmapWidth; + bounds.height = bitmapHeight; + } + + if (pBackgroundBitmap->IsNinePatchedBitmap()) + { + result r = pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + result r = pCanvas->DrawBitmap(bounds, *pBackgroundBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + +} + +void +_PanelPresenter::DrawGroupStyleBitmap(Canvas* pCanvas) +{ + result r = E_SUCCESS; + + Bitmap* pColorReplacedBitmap = null; + Bitmap* pGroupStyleBitmap = __pPanel->GetGroupStyleBitmap(); + + if (pGroupStyleBitmap != null) + { + Rectangle bounds = __pPanel->GetBounds(); + bounds.x = 0; + bounds.y = 0; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pGroupStyleBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pPanel->GetBackgroundColor()); + if (pColorReplacedBitmap != null) + { + if (pGroupStyleBitmap->IsNinePatchedBitmap()) + { + r = pCanvas->DrawNinePatchedBitmap(bounds, *pColorReplacedBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = pCanvas->DrawBitmap(bounds, *pColorReplacedBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + } + + // fall through +CATCH: + delete pColorReplacedBitmap; + + SetLastResult(r); +} + +void +_PanelPresenter::DrawGroupStyleBackgroundBitmap(Tizen::Graphics::Canvas* pCanvas) +{ + result r = E_SUCCESS; + + Bitmap* pColorReplacedBitmap = null; + Bitmap* pGroupStyleBackgroundBitmap = __pPanel->GetGroupStyleBackgroundBitmap(); + + if (pGroupStyleBackgroundBitmap != null) + { + Rectangle bounds = __pPanel->GetBounds(); + bounds.x = 0; + bounds.y = 0; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pGroupStyleBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pPanel->GetBackgroundColor()); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pColorReplacedBitmap != null && r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (pGroupStyleBackgroundBitmap->IsNinePatchedBitmap()) + { + r = pCanvas->DrawNinePatchedBitmap(bounds, *pColorReplacedBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = pCanvas->DrawBitmap(bounds, *pColorReplacedBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + // fall through +CATCH: + delete pColorReplacedBitmap; + + SetLastResult(r); +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_Popup.cpp b/src/ui/controls/FUiCtrl_Popup.cpp new file mode 100644 index 0000000..4efb769 --- /dev/null +++ b/src/ui/controls/FUiCtrl_Popup.cpp @@ -0,0 +1,649 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_Popup.cpp + * @brief This is the implementation file for the _Popup class. + */ + +#include +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_ControlManager.h" +#include "FUi_ModalLoopManager.h" +#include "FUi_ResourceManager.h" +#include "FUi_DataBindingContext.h" +#include "FUiCtrl_Popup.h" +#include "FUiCtrl_PopupPresenter.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Frame.h" + + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui; +using namespace Tizen::Base; + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +_Popup::_Popup(void) + : _titleState(false) + , _ownerEnableState(false) + , _titleText(L"") + , _bgColor(Color(0xFFFFFFFF)) + , _titleTextColor(Color(0xFFFFFFFF)) + , _pBgBitmap(null) + , _pComposedBgBitmap(null) + , _pOutlineBitmap(null) + , _pDimmingLayer(null) + , _pTitleTextAccessibilityElement(null) + , __pPopupPresenter(null) + , __bounds(0, 0, 0, 0) + , __popupResult(POPUP_RESULT_NONE) +{ + // empty statement +} + +_Popup::~_Popup(void) +{ + _Control* pOwner = GetOwner(); + if (pOwner != null) + { + pOwner->SetInputEnableState(_ownerEnableState); + } + + ReleaseTouchCapture(); + + delete __pPopupPresenter; + __pPopupPresenter = null; + + delete _pBgBitmap; + _pBgBitmap = null; + + delete _pComposedBgBitmap; + _pComposedBgBitmap = null; + + delete _pOutlineBitmap; + _pOutlineBitmap = null; + + delete _pDimmingLayer; + _pDimmingLayer = null; + + if (_pTitleTextAccessibilityElement) + { + _pTitleTextAccessibilityElement->Activate(false); + _pTitleTextAccessibilityElement = null; + } +} + +_Popup* +_Popup::CreatePopupN(void) +{ + _Popup* pPopup = new (std::nothrow) _Popup(); + SysTryReturn(NID_UI_CTRL, pPopup != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + +#if defined(MULTI_WINDOW) + result r = pPopup->CreateRootVisualElement(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); +#endif + + // for taking touch event + pPopup->AcquireHandle(); + + return pPopup; + +#if defined(MULTI_WINDOW) +CATCH: + delete pPopup; + return null; +#endif +} + +result +_Popup::Initialize(bool hasTitle, const Tizen::Graphics::Rectangle& bounds) +{ + result r = E_SUCCESS; + + _AccessibilityContainer* pContainer = null; + + _titleState = hasTitle; + __bounds = bounds; + SetClientBounds(GetPopupClientArea()); + + _PopupPresenter* pPresenter = new (std::nothrow) _PopupPresenter(); + SysTryReturn(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + SetPresenter(*pPresenter); + pPresenter->Initialize(*this); + + _pDimmingLayer = new (std::nothrow) _DimmingLayer(); + SysTryReturn(NID_UI_CTRL, _pDimmingLayer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = _pDimmingLayer->Construct(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_COLOR_CONFIG(POPUP::BG_NORMAL, _bgColor); + GET_COLOR_CONFIG(POPUP::TITLE_TEXT_NORMAL, _titleTextColor); + + // Popup-Outline + GET_BITMAP_CONFIG_N(POPUP::BG_OUTLINE_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, _pOutlineBitmap); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // Popup BG + GET_BITMAP_CONFIG_N(POPUP::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, _pBgBitmap); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pComposedBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*_pBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), _bgColor); + + // for clearing canvas + r = GetVisualElement()->SetSurfaceOpaque(false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + //create data binding context + _DataBindingContext* pContext = new (std::nothrow) _DataBindingContext(*this); + SysTryCatch(NID_UI_CTRL, pContext != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetDataBindingContext(pContext); + + pContainer = GetAccessibilityContainer(); + if(pContainer != null) + { + pContainer->Activate(true); + } + + return r; + +CATCH: + delete pContext; + + return r; +} + +result +_Popup::SetPresenter(const _PopupPresenter& popupPresenter) +{ + __pPopupPresenter = const_cast <_PopupPresenter*>(&popupPresenter); + + return E_SUCCESS; +} + +result +_Popup::DoModal(int& modalResult) +{ + result r = E_SUCCESS; + + __pPopupPresenter->DoModal(modalResult); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_Popup::EndModal(int modalResult) +{ + _ModalLoopManager::GetInstance()->EndMainLoop(POPUP_RESULT_END_MODAL, false); + + SetReturnValue(static_cast (modalResult)); + + return E_SUCCESS; +} + +void +_Popup::SetReturnValue(PopupModalResult rtn) +{ + __popupResult = rtn; +} + +int +_Popup::GetPopupReturnValue(void) const +{ + return (int) __popupResult; +} + +bool +_Popup::HasTitle(void) const +{ + return _titleState; +} + +Point +_Popup::TranslateFromClientAreaPosition(const Point& clientPosition) const +{ + Rectangle leftTop = GetClientBounds(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Point(-1, -1), r, "[%s] Propagating.", GetErrorMessage(r)); + + return Point(clientPosition.x + leftTop.x, clientPosition.y + leftTop.y); +} + +Point +_Popup::TranslateToClientAreaPosition(const Point& position) const +{ + Rectangle leftTop = GetClientBounds(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Point(-1, -1), r, "[%s] Propagating.", GetErrorMessage(r)); + + return Point(position.x - leftTop.x, position.y - leftTop.y); +} + +Canvas* +_Popup::GetClientAreaCanvasN(void) const +{ + Canvas* pCanvas = GetCanvasN(GetClientBounds()); + if ((pCanvas == null) || (GetLastResult() != E_SUCCESS)) + { + SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + delete pCanvas; + return null; + } + + return pCanvas; +} + +void +_Popup::SetColor(const Color& color) +{ + if (_pComposedBgBitmap != null) + { + delete _pComposedBgBitmap; + _pComposedBgBitmap = null; + } + + _pComposedBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*_pBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), color); + + _bgColor = color; +} + +Color +_Popup::GetColor() const +{ + return _bgColor; +} + +void +_Popup::SetTitleTextColor(const Color& color) +{ + _titleTextColor = color; +} + +Color +_Popup::GetTitleTextColor() const +{ + return _titleTextColor; +} + +result +_Popup::SetTitleText(const String& title) +{ + if (HasTitle() == true) + { + _titleText = title; + + if (__pPopupPresenter != null) + { + result r = __pPopupPresenter->SetTitleTextObject(title); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (_pTitleTextAccessibilityElement != null) + { + _pTitleTextAccessibilityElement->SetLabel(title); + } + + return E_SUCCESS; + } + else + { + return E_SYSTEM; + } +} + +String +_Popup::GetTitleText(void) const +{ + return _titleText; +} + +const Bitmap* +_Popup::GetBackgroundBitmap(void) const +{ + return _pComposedBgBitmap; +} + +const Bitmap* +_Popup::GetOutlineBitmap(void) const +{ + return _pOutlineBitmap; +} + +Rectangle +_Popup::GetPopupClientArea(void) const +{ + int x = 0; + int y = 0; + int width = 0; + int height = 0; + + int titleHeight = 0; + int titleLetfMargin = 0; + int titleRightMargin = 0; + + int transTopMargin = 0; + int transBottomMargin = 0; + int transLeftMargin = 0; + int transRightMargin = 0; + + + GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, GetOrientation(), titleHeight); + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_LEFT_MARGIN, GetOrientation(), titleLetfMargin); + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_RIGHT_MARGIN, GetOrientation(), titleRightMargin); + + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, GetOrientation(), transBottomMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, GetOrientation(), transLeftMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, GetOrientation(), transRightMargin); + + x = titleLetfMargin; + width = GetBounds().width - (titleLetfMargin + titleRightMargin); + + if (HasTitle() == false) + { + titleHeight = 0; + } + + y = titleHeight; + height = GetBounds().height - y; + + return Rectangle(x, y, width, height); +} + +_AccessibilityElement* +_Popup::GetTitleTextAccessibilityElement(void) +{ + return _pTitleTextAccessibilityElement; +} + +void +_Popup::OnDraw(void) +{ + __pPopupPresenter->OnDraw(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +_Popup::OnFontChanged(Font * pFont) +{ + if (__pPopupPresenter != null) + { + __pPopupPresenter->OnFontChanged(pFont); + } +} + +void +_Popup::OnFontInfoRequested(unsigned long& style, int& size) +{ + if (__pPopupPresenter != null) + { + __pPopupPresenter->OnFontInfoRequested(style, size); + } +} + +void +_Popup::OnActivated(void) +{ + SysTryReturnVoidResult(NID_UI_CTRL, _pDimmingLayer != null, E_SYSTEM, "[E_SYSTEM] There is no Dimming Layer."); + + result r = E_SUCCESS; + + if (__pPopupPresenter != null) + { + __pPopupPresenter->OnActivated(); + } + + if (GetVisibleState()) + { + r = _pDimmingLayer->SetDimmingEnabled(true); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetTouchCapture(); + } + else + { + r = _pDimmingLayer->SetDimmingEnabled(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (GetOwner() == null) + { + _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame()); + SysTryReturnVoidResult(NID_UI_CTRL, pFrame != null, E_SYSTEM,"[E_SYSTEM] This instance is not constructed."); + + _Form* pForm = pFrame->GetCurrentForm(); + if (pForm != null) + { + SetOwner(pForm); + } + else + { + SetOwner(pFrame); + } + } + + _Control* pOwner = GetOwner(); + + if (pOwner != null) + { + _ownerEnableState = pOwner->GetInputEnableState(); + pOwner->SetInputEnableState(false); + } + + _Window::OnActivated(); +} + +void +_Popup::OnDeactivated(void) +{ + SysTryReturnVoidResult(NID_UI_CTRL, _pDimmingLayer != null, E_SYSTEM, "[E_SYSTEM] There is no Dimming Layer."); + +#if !defined(MULTI_WINDOW) + result r = E_SUCCESS; + + if (IsAttached() == false) + { + r = _pDimmingLayer->SetDimmingEnabled(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } +#endif + + _Control* pOwner = GetOwner(); + if (pOwner != null) + { + pOwner->SetInputEnableState(_ownerEnableState); + } + + ReleaseTouchCapture(); + + _Window::OnDeactivated(); +} + +void +_Popup::OnVisibleStateChanged(void) +{ + result r = E_SUCCESS; + + if (GetVisibleState() == true) + { + r = _pDimmingLayer->SetDimmingEnabled(true); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = _pDimmingLayer->SetDimmingEnabled(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + _Window::OnVisibleStateChanged(); +} + +result +_Popup::OnAttachingToMainTree(const _Control* pParent) +{ + return _Window::OnAttachingToMainTree(pParent); +} + +result +_Popup::OnAttachedToMainTree(void) +{ + SysTryReturn(NID_UI_CTRL, GetVisibleState() != false, E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control is not 'displayable'"); + + InitializeAccessibilityElement(); + + return E_SUCCESS; +} + +void +_Popup::InitializeAccessibilityElement(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + if (_pTitleTextAccessibilityElement != null) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer != null) + { + int titleHeight = 0; + GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, GetOrientation(), titleHeight); + + _pTitleTextAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, _pTitleTextAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + _pTitleTextAccessibilityElement->Construct(L"PopupTitleText", __pPopupPresenter->GetTitleTextBounds()); + _pTitleTextAccessibilityElement->SetLabel(GetTitleText()); + _pTitleTextAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_TEXT_FIELD); + + pContainer->AddElement(*_pTitleTextAccessibilityElement); + + _Label* pLabelCore = __pPopupPresenter->GetSystemLabel(); + _AccessibilityContainer* pLabelContainer = pLabelCore->GetAccessibilityContainer(); + if (pLabelContainer != null) + { + pLabelContainer->Activate(false); + } + } + + return; +} + +result +_Popup::OnDetachingFromMainTree(void) +{ + return _Window::OnDetachingFromMainTree(); +} + +void +_Popup::OnChangeLayout(_ControlOrientation orientation) +{ + SysTryReturnVoidResult(NID_UI_CTRL, _pDimmingLayer != null, E_SYSTEM, "[E_SYSTEM] There is no Dimming Layer."); + + result r = E_SUCCESS; + + r = _pDimmingLayer->Rearrange(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + return; +} + +void +_Popup::OnBoundsChanged(void) +{ + SetClientBounds(GetPopupClientArea()); + + if (__pPopupPresenter != null) + { + __pPopupPresenter->UpdateEffectBounds(); + } + + if (_pTitleTextAccessibilityElement != null) + { + int titleHeight = 0; + GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, GetOrientation(), titleHeight); + + _pTitleTextAccessibilityElement->SetBounds(Rectangle(0, 0, GetPopupClientArea().width, titleHeight)); + } +} + +#if defined(MULTI_WINDOW) +result +_Popup::OnBoundsChanging(const Rectangle& bounds) +{ + // Full-screen window + return E_SUCCESS; +} + +bool +_Popup::IsLayoutChangable(void) const +{ + // Full-screen window + return true; +} +#endif + +bool +_Popup::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + + return __pPopupPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_Popup::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + + return __pPopupPresenter->OnTouchReleased(source, touchinfo); +} + + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_PopupImpl.cpp b/src/ui/controls/FUiCtrl_PopupImpl.cpp new file mode 100644 index 0000000..d2203b4 --- /dev/null +++ b/src/ui/controls/FUiCtrl_PopupImpl.cpp @@ -0,0 +1,603 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_PopupImpl.cpp + * @brief This is the implementation file for the _PopupImpl class. + */ + + +#include +#include +#include "FUi_UiBuilder.h" +#include "FUi_DataBindingContextImpl.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUi_ControlImplManager.h" +#include "FUi_LayoutImpl.h" +#include "FUiCtrl_FrameImpl.h" +#include "FUiCtrl_PopupImpl.h" +#include "FUiCtrl_Popup.h" +#include "FUiCtrl_Form.h" + + +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +Dimension +_PopupImpl::PopupSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Dimension dimension(0, 0); + + r = GET_DIMENSION_CONFIG(POPUP::MIN_SIZE, orientation, dimension); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, dimension, r, "[%s] A system error occurred.", GetErrorMessage(r)); + SetLastResult(r); + + return dimension; +} + +Dimension +_PopupImpl::PopupSizeInfo::GetDefaultMaximumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Dimension dimension(0, 0); + + r = GET_DIMENSION_CONFIG(POPUP::MAX_SIZE, orientation, dimension); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, dimension, r, "[%s] A system error occurred.", GetErrorMessage(r)); + + SetLastResult(r); + + return dimension; +} + +_PopupImpl* +_PopupImpl::GetInstance(Popup& pPopup) +{ + return static_cast <_PopupImpl*>(pPopup._pControlImpl); +} + +const _PopupImpl* +_PopupImpl::GetInstance(const Popup& pPopup) +{ + return static_cast (pPopup._pControlImpl); +} + +_PopupImpl::_PopupImpl(Popup* pPublic, _Popup* pCore, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout) + : _WindowImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout) + , _isModal(false) + , __init(false) + , __centerAlign(false) + , __callBoundsChange(false) +{ + //empty statement +} + +_PopupImpl::~_PopupImpl(void) +{ + //empty statement +} + +_PopupImpl* +_PopupImpl::CreatePopupImplN(Popup* pControl, const Tizen::Graphics::Dimension& dim, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout) +{ + result r = E_SUCCESS; + + r = GET_SIZE_INFO(Popup).CheckInitialSizeValid(dim, _ControlManager::GetInstance()->GetOrientation()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] The given size is not valid."); + + _PopupImpl* pImpl = null; + _Popup* pCore = null; + + pCore = _Popup::CreatePopupN(); + SysTryReturn(NID_UI_CTRL, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pImpl = new (std::nothrow) _PopupImpl(pControl, pCore, pPublicPortraitLayout, pPublicLandscapeLayout); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Popup), dim, _ControlManager::GetInstance()->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + ClearLastResult(); + + return pImpl; + +CATCH: + delete pImpl; //This deletes pCore as well + + return null; +} + +result +_PopupImpl::Initialize(bool hasTitle, const Tizen::Graphics::Dimension& dim) +{ + result r = E_SUCCESS; + + if (hasTitle) + { + Dimension minSize(0, 0); + + r = GET_DIMENSION_CONFIG(POPUP::MIN_SIZE_WITH_TITLE, _ControlManager::GetInstance()->GetOrientation(), minSize); + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] A system error occurred.", GetErrorMessage(r)); + + SysTryReturn(NID_UI_CTRL, + (minSize.width <= dim.width && minSize.height <= dim.height), E_INVALID_ARG, + E_INVALID_ARG, "[E_INVALID_ARG] The size is out of minium size(%d, %d)", + minSize.width, minSize.width); + + r = GetCore().SetMinimumSize(minSize); + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] SetMinimumSize is failed.", GetErrorMessage(r)); + } + + Rectangle bounds = GetCenterAlignedRect(dim.width, dim.height); + __init = true; + __centerAlign = true; + + r = SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return GetCore().Initialize(hasTitle, bounds); +} + +const char* +_PopupImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::Popup"; +} + +const Popup& +_PopupImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +Popup& +_PopupImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Popup& +_PopupImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Popup& +_PopupImpl::GetCore(void) +{ + return static_cast <_Popup&>(_ControlImpl::GetCore()); +} + +Rectangle +_PopupImpl::GetCenterAlignedRect(int width, int height) const +{ + int x = 0; + int y = 0; + + Dimension screenRect = _ControlManager::GetInstance()->GetScreenSize(); + + if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE) + { + int temp = screenRect.width; + screenRect.width = screenRect.height; + screenRect.height = temp; + } + + x = (screenRect.width - width) / 2; + y = (screenRect.height - height) / 2; + + return Rectangle(x, y, width, height); +} + +Rectangle +_PopupImpl::GetClientAreaBounds(void) const +{ + return _ControlImpl::GetClientBounds(); +} + +Canvas* +_PopupImpl::GetClientAreaCanvasN(void) const +{ + return GetCore().GetClientAreaCanvasN(); +} + +Point +_PopupImpl::TranslateFromClientAreaPosition(const Point& clientPosition) const +{ + return GetCore().TranslateFromClientAreaPosition(clientPosition); +} + +Point +_PopupImpl::TranslateToClientAreaPosition(const Point& position) const +{ + return GetCore().TranslateToClientAreaPosition(position); +} + +result +_PopupImpl::DoModal(int& modalResult) +{ + SysTryReturn(NID_UI_CTRL, GetVisibleState() != false, E_INVALID_STATE, + E_INVALID_STATE, "[E_INVALID_STATE] The Popup is not visible"); + + _isModal = true; + + return GetCore().DoModal(modalResult); +} + +result +_PopupImpl::EndModal(int modalResult) +{ + SysTryReturn(NID_UI_CTRL, _isModal == true, E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] The method is not supported because this popup isn't running as a modal window."); + + return GetCore().EndModal(modalResult); +} + +result +_PopupImpl::SetColor(const Color& color) +{ + GetCore().SetColor(color); + + return E_SUCCESS; +} + +Color +_PopupImpl::GetColor(void) const +{ + return GetCore().GetColor(); +} + +result +_PopupImpl::SetTitleText(const Tizen::Base::String& title) +{ + return GetCore().SetTitleText(title); +} + +Tizen::Base::String +_PopupImpl::GetTitleText(void) const +{ + return GetCore().GetTitleText(); +} + +result +_PopupImpl::SetTitleTextColor(const Color& color) +{ + GetCore().SetTitleTextColor(color); + + return E_SUCCESS; +} + +Color +_PopupImpl::GetTitleTextColor() const +{ + return GetCore().GetTitleTextColor(); +} + +int +_PopupImpl::GetMinWidth(void) const +{ + Dimension dimMin(0, 0); + + GET_DIMENSION_CONFIG(POPUP::MIN_SIZE, GetCore().GetOrientation(), dimMin); + + return dimMin.width; +} + +int +_PopupImpl::GetMinHeight(void) const +{ + Dimension dimMin(0, 0); + + GET_DIMENSION_CONFIG(POPUP::MIN_SIZE, GetCore().GetOrientation(), dimMin); + + return dimMin.height; +} + +int +_PopupImpl::GetMaxWidth(void) const +{ + Dimension dimMax(0, 0); + + GET_DIMENSION_CONFIG(POPUP::MAX_SIZE, GetCore().GetOrientation(), dimMax); + + return dimMax.width; +} + +int +_PopupImpl::GetMaxHeight(void) const +{ + Dimension dimMax(0, 0); + + GET_DIMENSION_CONFIG(POPUP::MAX_SIZE, GetCore().GetOrientation(), dimMax); + + return dimMax.height; +} + +DataBindingContext* +_PopupImpl::GetDataBindingContextN(void) const +{ + return Tizen::Ui::_DataBindingContextImpl::GetDataBindingContextN(*this); +} + +void +_PopupImpl::OnChangeLayout(_ControlOrientation orientation) +{ + result r = E_SUCCESS; + + Dimension newMaxSize(0, 0); + Dimension maxSize = GetCore().GetMaximumSize(); + + r = GET_DIMENSION_CONFIG(POPUP::MAX_SIZE, orientation, newMaxSize); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] A system error occurred.", GetErrorMessage(r)); + + if (maxSize.width == newMaxSize.height && maxSize.height == newMaxSize.width) + { + r = GetCore().SetMaximumSize(newMaxSize); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] SetMinimumSize is failed.", GetErrorMessage(r)); + } + + if (!__callBoundsChange) + { + Rectangle bounds = GetCenterAlignedRect(GetBounds().width, GetBounds().height); + __centerAlign = true; + + r = SetBounds(bounds); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + } + + return GetCore().OnChangeLayout(orientation); +} + +void +_PopupImpl::OnBoundsChanged(void) +{ + Rectangle rect = GetBounds(); + + if (__init) + { + if (__centerAlign) + { + rect = GetCenterAlignedRect(GetSize().width, GetSize().height); + __centerAlign = false; + } + else + { + __callBoundsChange = true; + } + } + +#if !defined(MULTI_WINDOW) + result r = SetBounds(rect, false); +#else + result r = SetBounds(rect, true); +#endif + + if (IsFailed(r)) + { + // Error propagation fall through + ClearLastResult(); + } + + _ControlImpl::OnBoundsChanged(); +} + + +class _PopupMaker + : public _UiBuilderControlMaker +{ +public: + _PopupMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_PopupMaker(){}; + + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _PopupMaker* pPopupMaker = new (std::nothrow) _PopupMaker(uibuilder); + + return static_cast<_UiBuilderControlMaker*>(pPopupMaker); + }; + +protected: + virtual Tizen::Ui::Control* Make(_UiBuilderControl* pControl) + { + bool hasTitle = false; + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + Tizen::Base::String elementString; + Color color; + Tizen::Graphics::Dimension dim; + Tizen::Graphics::Rectangle rect; + + Popup* pPopup = dynamic_cast (GetContainer()); + SysTryReturn(NID_UI_CTRL, pPopup != null, null, E_SYSTEM, "[E_SYSTEM] This instance is not constructed."); + + SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL); + GetProperty(pControl, &pControlProperty); + + if (pControlProperty == null) + { + return null; + } + + if (pControl->GetElement("titleText", elementString)) + { + hasTitle = true; + } + else + { + hasTitle = false; + } + + //pPopup = new (std::nothrow) Popup(); + rect = pControlProperty->GetRect(); + + dim.width = rect.width; + dim.height = rect.height; + +// int sideMargin = 0; +// GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_SIDE_MARGIN, _ControlManager::GetInstance()->GetOrientation(), sideMargin); +// +// // To consider client's area +// dim.width += sideMargin * 2; +// +// if (hasTitle == true) +// { +// int titleHeight = 0; +// GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, _ControlManager::GetInstance()->GetOrientation(), titleHeight); +// +// dim.height += titleHeight; +// } + + _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE; + GetLayoutType(pControlProperty, layoutType); + + if (layoutType == UIBUILDER_LAYOUT_NONE) + { + r = pPopup->Construct(hasTitle, dim); + } + else + { + Layout* pPortraitLayout = null; + Layout* pLandscapeLayout = null; + result tempResult = E_SUCCESS; + + tempResult = GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout); + + if (E_SUCCESS == tempResult) + { + r = pPopup->Construct(*pPortraitLayout, *pLandscapeLayout, hasTitle, dim); + } + else + { + r = tempResult; + } + + _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE; + + if (GetLayoutType(pControlProperty, layoutType) == false) + { + return null; + } + + if ( layoutType == UIBUILDER_LAYOUT_GRID) + { + for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++) + { + GridLayout* pGridLayout = null; + pControlProperty = pControl->GetAttribute(i); + + if ( i == UIBUILDER_ATTRIBUTE_PORTRAIT) + { + pGridLayout = dynamic_cast(pPortraitLayout); + } + else + { + pGridLayout = dynamic_cast(pLandscapeLayout); + } + SetGridLayoutContainerProperty(pGridLayout, pControlProperty); + } + } + + delete pPortraitLayout; + + if (pPortraitLayout != pLandscapeLayout) + { + delete pLandscapeLayout; + } + // CONSTRUCT_WITH_LAYOUT_ARG2(pPopup, hasTitle, dim); + } + + if (r != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Failed to create Popup."); + return null; + } + + if (hasTitle == true) + { + pPopup->SetTitleText(elementString); + } + + //set property + if (pControl->GetElement("color", elementString)) + { + ConvertStringToColor(elementString, color); + pPopup->SetColor(color); + } + + if (pControl->GetElement("titleTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pPopup->SetTitleTextColor(color); + } + + //-------safety for Minimum size------------------- +// rect = (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->GetRect(); +// if (rect.width < __BaseProperty(PROPERTY_POPUP_MIN_WIDTH)) +// { +// rect.width = __BaseProperty(PROPERTY_POPUP_MIN_WIDTH); +// } +// if (rect.height < __BaseProperty(PROPERTY_POPUP_MIN_HEIGHT)) +// { +// rect.height = __BaseProperty(PROPERTY_POPUP_MIN_HEIGHT); +// } +// (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(rect.x,rect.y,rect.width,rect.height); +// +// rect = (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->GetRect(); +// if (rect.width < __BaseProperty(PROPERTY_POPUP_MIN_WIDTH)) +// { +// rect.width = __BaseProperty(PROPERTY_POPUP_MIN_WIDTH); +// } +// if (rect.height < __BaseProperty(PROPERTY_POPUP_MIN_HEIGHT)) +// { +// rect.height = __BaseProperty(PROPERTY_POPUP_MIN_HEIGHT); +// } +// (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(rect.x,rect.y,rect.width,rect.height); + //---------end safety code------------------------ + + return pPopup; + } + +private: + +}; // _PopupMaker + +_PopupRegister::_PopupRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"Popup", _PopupMaker::GetInstance); +} + +_PopupRegister::~_PopupRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"Popup"); +} +static _PopupRegister PopupRegisterToUiBuilder; + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PopupPresenter.cpp b/src/ui/controls/FUiCtrl_PopupPresenter.cpp new file mode 100644 index 0000000..fd84468 --- /dev/null +++ b/src/ui/controls/FUiCtrl_PopupPresenter.cpp @@ -0,0 +1,538 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_PopupPresenter.cpp + * @brief This is the implementation file for the _PopupPresenter class. + */ + + +#include +#include +#include +#include +#include +#include +#include "FUi_ControlManager.h" +#include "FUi_ModalLoopManager.h" +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUiAnim_RootVisualElement.h" +#include "FUiCtrl_Label.h" +#include "FUiCtrl_PopupPresenter.h" +#include "FUiCtrl_Popup.h" + + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +_PopupPresenter::_PopupPresenter(void) + : _pFont(null) + , __pPopup(null) + , __pPopupVE(null) + , __pBackgroundVE(null) + , __pTextObject(null) + , __pLabelCore(null) + , __titleBounds(0, 0, 0, 0) +{ + //empty statement +} + +_PopupPresenter::~_PopupPresenter(void) +{ + if (__pTextObject != null) + { + delete __pTextObject; + __pTextObject = null; + } + + delete __pLabelCore; + __pLabelCore = null; + + if (__pBackgroundVE != null) + { + __pBackgroundVE->Destroy(); + __pBackgroundVE = null; + } +} + +void +_PopupPresenter::UpdateEffectBounds(void) +{ + Dimension screenRect; + Rectangle bounds; + + int bgOutlineEffectTopMargin = 0; + int bgOutlineEffectBottomMargin = 0; + int bgOutlineEffectLeftMargin = 0; + int bgOutlineEffectRightMargin = 0; + int temp = 0; + + GET_SHAPE_CONFIG(POPUP::BG_OUTLINE_EFFECT_TOP_MARGIN, __pPopup->GetOrientation(), bgOutlineEffectTopMargin); + GET_SHAPE_CONFIG(POPUP::BG_OUTLINE_EFFECT_BOTTOM_MARGIN, __pPopup->GetOrientation(), bgOutlineEffectBottomMargin); + GET_SHAPE_CONFIG(POPUP::BG_OUTLINE_EFFECT_LEFT_MARGIN, __pPopup->GetOrientation(), bgOutlineEffectLeftMargin); + GET_SHAPE_CONFIG(POPUP::BG_OUTLINE_EFFECT_RIGHT_MARGIN, __pPopup->GetOrientation(), bgOutlineEffectRightMargin); + + bounds = __pPopup->GetBounds(); + + screenRect = _ControlManager::GetInstance()->GetScreenSize(); + if (__pPopup->GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE) + { + temp = screenRect.width; + screenRect.width = screenRect.height; + screenRect.height = temp; + } + + bounds.x = (screenRect.width - (bounds.width)) / 2 - bgOutlineEffectLeftMargin; + bounds.y = (screenRect.height - (bounds.height)) / 2 - bgOutlineEffectTopMargin; + + __pBackgroundVE->SetBounds(FloatRectangle((float)bounds.x, + (float)bounds.y, + (float)(bounds.width + bgOutlineEffectLeftMargin + bgOutlineEffectRightMargin), + (float)(bounds.height + bgOutlineEffectTopMargin + bgOutlineEffectBottomMargin))); +} + +void +_PopupPresenter::Initialize(_Popup& popup) +{ + result r = E_SUCCESS; + + Dimension screenRect; + Rectangle bounds; + int temp = 0; + + int transTopMargin = 0; + int transBottomMargin = 0; + int transLeftMargin = 0; + int transRightMargin = 0; + + int bgOutlineEffectTopMargin = 0; + int bgOutlineEffectBottomMargin = 0; + int bgOutlineEffectLeftMargin = 0; + int bgOutlineEffectRightMargin = 0; + + __pPopup = &popup; + + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pPopup->GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, __pPopup->GetOrientation(), transBottomMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, __pPopup->GetOrientation(), transLeftMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, __pPopup->GetOrientation(), transRightMargin); + + GET_SHAPE_CONFIG(POPUP::BG_OUTLINE_EFFECT_TOP_MARGIN, __pPopup->GetOrientation(), bgOutlineEffectTopMargin); + GET_SHAPE_CONFIG(POPUP::BG_OUTLINE_EFFECT_BOTTOM_MARGIN, __pPopup->GetOrientation(), bgOutlineEffectBottomMargin); + GET_SHAPE_CONFIG(POPUP::BG_OUTLINE_EFFECT_LEFT_MARGIN, __pPopup->GetOrientation(), bgOutlineEffectLeftMargin); + GET_SHAPE_CONFIG(POPUP::BG_OUTLINE_EFFECT_RIGHT_MARGIN, __pPopup->GetOrientation(), bgOutlineEffectRightMargin); + + // system label to cover non-client area + __pLabelCore = _Label::CreateLabelN(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, __pLabelCore != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLabelCore->SetBackgroundColor(Color(0, 0 ,0, 0)); + + r = __pPopup->AttachSystemChild(*__pLabelCore); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pBackgroundVE = new (std::nothrow) _VisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, __pBackgroundVE != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pBackgroundVE->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + bounds = __pPopup->GetBounds(); + + screenRect = _ControlManager::GetInstance()->GetScreenSize(); + if (__pPopup->GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE) + { + temp = screenRect.width; + screenRect.width = screenRect.height; + screenRect.height = temp; + } + + bounds.x = (screenRect.width - (bounds.width)) / 2 - bgOutlineEffectLeftMargin; + bounds.y = (screenRect.height - (bounds.height)) / 2 - bgOutlineEffectTopMargin; + + __pBackgroundVE->SetBounds(FloatRectangle((float)bounds.x, + (float)bounds.y, + (float)(bounds.width + bgOutlineEffectLeftMargin + bgOutlineEffectRightMargin), + (float)(bounds.height + bgOutlineEffectTopMargin + bgOutlineEffectBottomMargin))); + + r = __pBackgroundVE->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pBackgroundVE->SetShowState(true); + + __pPopupVE = __pPopup->GetVisualElement(); + SysTryCatch(NID_UI_CTRL, (__pPopupVE != null), r = E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the Popup visual element."); + + return; + +CATCH: + delete __pLabelCore; + __pLabelCore = null; + + __pBackgroundVE->Destroy(); + __pBackgroundVE = null; + + return; +} + +_Label* +_PopupPresenter::GetSystemLabel(void) const +{ + return __pLabelCore; +} + +void +_PopupPresenter::OnFontChanged(Font* pFont) +{ + _pFont = pFont; +} + +void +_PopupPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + int textSize = 0; + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_SIZE, __pPopup->GetOrientation(), textSize); + + style = FONT_STYLE_PLAIN; + size = textSize; +} + +result +_PopupPresenter::SetTitleTextObject(const String &title) +{ + result r = E_SUCCESS; + TextSimple* pSimpleText = null; + + int textSize = 0; + int titleHeight = 0; + int titleTopMargin = 0; + int titleLeftMargin = 0; + int titleRightMargin = 0; + int transTopMargin = 0; + int transLeftMargin = 0; + int transRightMargin = 0; + + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_SIZE, __pPopup->GetOrientation(), textSize); + GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, __pPopup->GetOrientation(), titleHeight); + + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_TOP_MARGIN, __pPopup->GetOrientation(), titleTopMargin); + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_LEFT_MARGIN, __pPopup->GetOrientation(), titleLeftMargin); + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_RIGHT_MARGIN, __pPopup->GetOrientation(), titleRightMargin); + + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pPopup->GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, __pPopup->GetOrientation(), transLeftMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, __pPopup->GetOrientation(), transRightMargin); + + // Title font + _pFont = __pPopup->GetFallbackFont(); + SysTryReturn(NID_UI_CTRL, _pFont != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (__pTextObject != null) + { + delete __pTextObject; + } + + // Title text + __pTextObject = new (std::nothrow) TextObject(); + SysTryReturn(NID_UI_CTRL, __pTextObject != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTextObject->Construct(); + + pSimpleText = new (std::nothrow) TextSimple(const_cast (title.GetPointer()), + title.GetLength(), + TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_UI_CTRL, pSimpleText != null , r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTextObject->AppendElement(*pSimpleText); + __pTextObject->SetForegroundColor(__pPopup->GetTitleTextColor(), 0, __pTextObject->GetTextLength()); + __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pTextObject->SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL); + + __pTextObject->SetFont(_pFont, 0, __pTextObject->GetTextLength()); + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT); + + __pTextObject->SetBounds(Rectangle(titleLeftMargin + transLeftMargin, + titleTopMargin, + __pPopup->GetBounds().width - (titleLeftMargin + titleRightMargin + transLeftMargin + transRightMargin), + titleHeight - titleTopMargin)); + __pTextObject->Compose(); + + // After TextObject::Compose(), we can get text-object's height. + __titleBounds.SetBounds(titleLeftMargin + transLeftMargin, + titleTopMargin, + __pPopup->GetBounds().width - (titleLeftMargin + titleRightMargin + transLeftMargin + transRightMargin), + __pTextObject->GetTotalHeight()); + + __pTextObject->SetBounds(__titleBounds); + + return r; + +CATCH: + delete __pTextObject; + __pTextObject = null; + + return r; +} + +void +_PopupPresenter::OnDraw(void) +{ + DrawSystemLabel(); + Draw(); +} + +Rectangle +_PopupPresenter::GetTitleTextBounds(void) const +{ + return __titleBounds; +} + +void +_PopupPresenter::DrawSystemLabel(void) +{ + result r = E_SUCCESS; + + int titleHeight = 0; + int transTopMargin = 0; + int transBottomMargin = 0; + + GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, __pPopup->GetOrientation(), titleHeight); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pPopup->GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, __pPopup->GetOrientation(), transBottomMargin); + + Rectangle systemBounds; + Rectangle clientBounds = __pPopup->GetPopupClientArea(); + Rectangle bounds = __pPopup->GetBounds(); + + systemBounds.x = clientBounds.x + clientBounds.width; + + if (__pPopup->HasTitle() == false) + { + titleHeight = 0; + } + systemBounds.y = clientBounds.y + POPUP_LABEL_GAP; + + systemBounds.width = (bounds.width - systemBounds.x) - POPUP_LABEL_GAP / 2; + systemBounds.height = clientBounds.height -POPUP_LABEL_GAP * 2; + + r = __pLabelCore->SetBounds(systemBounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLabelCore->SetBackgroundColor(__pPopup->GetColor()); + + __pLabelCore->Draw(); + + return; + +CATCH: + delete __pLabelCore; + __pLabelCore = null; + + return; +} + +void +_PopupPresenter::Draw(void) +{ + result r = E_SUCCESS; + + int transTopMargin = 0; + int transBottomMargin = 0; + int transLeftMargin = 0; + int transRightMargin = 0; + + int bgOutlineEffectTopMargin = 0; + int bgOutlineEffectBottomMargin = 0; + int bgOutlineEffectLeftMargin = 0; + int bgOutlineEffectRightMargin = 0; + + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pPopup->GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, __pPopup->GetOrientation(), transBottomMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, __pPopup->GetOrientation(), transLeftMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, __pPopup->GetOrientation(), transRightMargin); + + GET_SHAPE_CONFIG(POPUP::BG_OUTLINE_EFFECT_TOP_MARGIN, __pPopup->GetOrientation(), bgOutlineEffectTopMargin); + GET_SHAPE_CONFIG(POPUP::BG_OUTLINE_EFFECT_BOTTOM_MARGIN, __pPopup->GetOrientation(), bgOutlineEffectBottomMargin); + GET_SHAPE_CONFIG(POPUP::BG_OUTLINE_EFFECT_LEFT_MARGIN, __pPopup->GetOrientation(), bgOutlineEffectLeftMargin); + GET_SHAPE_CONFIG(POPUP::BG_OUTLINE_EFFECT_RIGHT_MARGIN, __pPopup->GetOrientation(), bgOutlineEffectRightMargin); + + // Get canvas + Canvas* pCanvas = __pPopup->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + Canvas* pBackgroundCanvas = __pBackgroundVE->GetCanvasN(); + SysTryCatch(NID_UI_CTRL, pBackgroundCanvas != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pBackgroundCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pBackgroundCanvas->Clear(); + + // Draw BG + if (__pPopup->GetBackgroundBitmap() != null) + { + Rectangle bounds(-transLeftMargin, + -transTopMargin, + __pPopup->GetBounds().width + transLeftMargin + transRightMargin, + __pPopup->GetBounds().height + transTopMargin + transBottomMargin); + + const Bitmap* pBackgroundBitmap = __pPopup->GetBackgroundBitmap(); + if (pBackgroundBitmap->IsNinePatchedBitmap() == true) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap); + } + else + { + pCanvas->DrawBitmap(bounds, *pBackgroundBitmap); + } + } + + // Draw Title + if (__pPopup->HasTitle()) + { + if (__pTextObject != null) + { + _pFont = __pPopup->GetFallbackFont(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, _pFont != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTextObject->SetFont(_pFont, 0, __pTextObject->GetTextLength()); + __pTextObject->SetBounds(__titleBounds); + __pTextObject->SetForegroundColor(__pPopup->GetTitleTextColor(), 0, __pTextObject->GetTextLength()); + + __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + } + } + + + // Draw Outline + if (__pPopup->GetOutlineBitmap() != null) + { + Rectangle bounds(0, + 0, + __pPopup->GetBounds().width + bgOutlineEffectLeftMargin + bgOutlineEffectRightMargin, + __pPopup->GetBounds().height + bgOutlineEffectTopMargin + bgOutlineEffectBottomMargin); + + const Bitmap* pOutlineBitmap = __pPopup->GetOutlineBitmap(); + + if (pOutlineBitmap->IsNinePatchedBitmap() == true) + { + pBackgroundCanvas->DrawNinePatchedBitmap(bounds, *pOutlineBitmap); + } + else + { + pBackgroundCanvas->DrawBitmap(bounds, *pOutlineBitmap); + } + } + + //fall thtrough +CATCH: + delete pCanvas; + delete pBackgroundCanvas; + + return; +} + +void +_PopupPresenter::OnActivated(void) +{ + result r = E_SUCCESS; + +#if !defined(MULTI_WINDOW) + VisualElement* pParent = __pPopupVE->GetParent(); +#else + _Window* pWindow = __pPopup->GetRootWindow(); + _RootVisualElement* pParent = pWindow->GetRootVisualElement(); +#endif + + if (pParent) + { + r = pParent->InsertChild(*__pBackgroundVE, __pPopupVE, false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + + return; +} + +result +_PopupPresenter::DoModal(int& modalResult) +{ + result r = E_SUCCESS; + + r = __pPopup->Open(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + ProcessEvent(); + + __pPopup->Close(); + + modalResult = __pPopup->GetPopupReturnValue(); + + return r; +} + +void +_PopupPresenter::ProcessEvent(void) +{ + _ModalLoopManager::GetInstance()->BeginMainLoop(); + + int exitCode = _ModalLoopManager::GetInstance()->GetLastExitCode(); + switch (exitCode) + { + case _ModalLoopManager::MODAL_LOOP_EXIT_CODE_APP_TERMINATION: + case _ModalLoopManager::MODAL_LOOP_EXIT_CODE_CONTINUOUS_TERMINATION: + _ModalLoopManager::GetInstance()->EndMainLoop(exitCode, false); + break; + default: + break; + } +} + +bool +_PopupPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + Point point = touchinfo.GetCurrentPosition(); + + return true; +} + +bool +_PopupPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + Point point = touchinfo.GetCurrentPosition(); + + return true; +} + + +}}} // Tizen::Ui::Controls + + diff --git a/src/ui/controls/FUiCtrl_Progress.cpp b/src/ui/controls/FUiCtrl_Progress.cpp new file mode 100644 index 0000000..e11e6ee --- /dev/null +++ b/src/ui/controls/FUiCtrl_Progress.cpp @@ -0,0 +1,352 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Progress.cpp + * @brief This is the implementation file for the _Progress class. + */ + +#include +#include +#include "FUiAnim_VisualElement.h" +#include "FUi_ResourceManager.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUiCtrl_Progress.h" +#include "FUiCtrl_ProgressPresenter.h" + +using namespace Tizen::Ui; +using namespace Tizen::Graphics; +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_Progress); + +_Progress::_Progress(void) + : __pProgressPresenter(null) + , __pAccessibilityElement(null) +{ + Tizen::Ui::Animations::_VisualElement* pBase = GetVisualElement(); + + if (pBase != null) + { + pBase->SetSurfaceOpaque(false); + } + + if(likely((_AccessibilityManager::IsActivated()))) + { + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer) + { + pContainer->Activate(true); + } + } +} + +_Progress::~_Progress(void) +{ + delete __pProgressPresenter; + __pProgressPresenter = null; + if (__pAccessibilityElement) + { + __pAccessibilityElement->Activate(false); + __pAccessibilityElement = null; + } +} + +_Progress* +_Progress::CreateProgressN() +{ + result r = E_SUCCESS; + + _Progress* pProgress = new (std::nothrow) _Progress; + SysTryReturn(NID_UI_CTRL, pProgress, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pProgress->__pProgressPresenter = _ProgressPresenter::CreateInstanceN(*pProgress); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pProgress->__pProgressPresenter != null, , r, + "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::BAR_NORMAL, pProgress->__barColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to get progress colorconfig", GetErrorMessage(r)); + + pProgress->AcquireHandle(); + pProgress->SetFocusable(false); + + return pProgress; + +CATCH: + delete pProgress; + pProgress = null; + + return null; +} + +result +_Progress::InitializeAccessibilityElement(void) +{ + result r = E_SUCCESS; + + if(likely(!(_AccessibilityManager::IsActivated()))) + { + return r; + } + + if (__pAccessibilityElement) + { + return r; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer) + { + __pAccessibilityElement = new _AccessibilityElement(true); + SysTryReturn(NID_UI_CTRL, __pAccessibilityElement, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + __pAccessibilityElement->SetBounds(Rectangle(0, 0, GetBounds().width, GetBounds().height)); + + __pAccessibilityElement->SetLabel(L"Progressing"); + + String string; + string.Append(GetPercentComplete()); + __pAccessibilityElement->SetValue(string + L" percent"); + + r = pContainer->AddElement(*__pAccessibilityElement); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_Progress::OnAttachedToMainTree(void) +{ + InitializeAccessibilityElement(); + return E_SUCCESS; +} + +void +_Progress::OnBoundsChanged(void) +{ + if (__pAccessibilityElement) + { + __pAccessibilityElement->SetBounds(Rectangle(0, 0, GetBounds().width, GetBounds().height)); + } + + return; +} + +result +_Progress::SetValue(int value) +{ + return SetProperty("value", Variant(value)); +} + +result +_Progress::SetPropertyValue(const Variant& value) +{ + result r = E_SUCCESS; + + int tempValue = value.ToInt(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pProgressPresenter->SetValue(tempValue); + + r = InitializeAccessibilityElement(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pAccessibilityElement) + { + String string; + string.Append(GetPercentComplete()); + __pAccessibilityElement->SetValue(string + L" percent"); + } + + return r; +} + +int +_Progress::GetValue(void) const +{ + Variant value = GetProperty("value"); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + return value.ToInt(); +} + +Variant +_Progress::GetPropertyValue(void) const +{ + return Variant(__pProgressPresenter->GetValue()); +} + +result +_Progress::SetRange(int minValue, int maxValue) +{ + SysTryReturn(NID_UI_CTRL, minValue >= 0 && maxValue >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Values can not be negative."); + SysTryReturn(NID_UI_CTRL, minValue < maxValue, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The minimum value is greater than maximum value."); + + result r = E_SUCCESS; + + Variant oldMinValue = GetProperty("minValue"); + Variant value = GetProperty("value"); + + r = SetProperty("minValue", Variant(minValue)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to set minimum value.", GetErrorMessage(r)); + + r = SetProperty("maxValue", Variant(maxValue)); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_CTRL, r, "[%s] Failed to set maximum value.", GetErrorMessage(r)); + + result nestedResult = SetPropertyMinValue(oldMinValue); + if (nestedResult != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Failed to recover original minimum value"); + return r; + } + + nestedResult = SetPropertyValue(value); + if (nestedResult != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Failed to recover original value"); + } + } + + if (__pAccessibilityElement) + { + String string; + string.Append(GetPercentComplete()); + __pAccessibilityElement->SetValue(string + L" percent"); + } + + return r; +} + +result +_Progress::SetPropertyMinValue(const Variant& minValue) +{ + result r = E_SUCCESS; + + int tempMinValue = minValue.ToInt(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pProgressPresenter->SetMinValue(tempMinValue); + + return r; +} + +result +_Progress::SetPropertyMaxValue(const Variant& maxValue) +{ + result r = E_SUCCESS; + + int tempMaxValue = maxValue.ToInt(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pProgressPresenter->SetMaxValue(tempMaxValue); + + return r; +} + +result +_Progress::GetRange(int& minValue, int& maxValue) const +{ + result r = E_SUCCESS; + + Variant minimum = GetProperty("minValue"); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Variant maximum = GetProperty("maxValue"); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + minValue = minimum.ToInt(); + maxValue = maximum.ToInt(); + + return r; +} + +Variant +_Progress::GetPropertyMinValue(void) const +{ + return Variant(__pProgressPresenter->GetMinValue()); +} + +Variant +_Progress::GetPropertyMaxValue(void) const +{ + return Variant(__pProgressPresenter->GetMaxValue()); +} + +int +_Progress::GetPercentComplete(void) const +{ + return __pProgressPresenter->GetPercentComplete(); +} + +result +_Progress::SetBarColor(const Color& color) +{ + return SetProperty("barColor", Variant(color)); +} + +result +_Progress::SetPropertyBarColor(const Variant& barColor) +{ + result r = E_SUCCESS; + + Color tempColor = barColor.ToColor(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __barColor = tempColor; + + return r; +} + +Color +_Progress::GetBarColor(void) const +{ + Variant barColor = GetProperty("barColor"); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r)); + + return barColor.ToColor(); +} + +Variant +_Progress::GetPropertyBarColor(void) const +{ + return Variant(__barColor); +} + +void +_Progress::OnDraw(void) +{ + __pProgressPresenter->Draw(); + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ProgressImpl.cpp b/src/ui/controls/FUiCtrl_ProgressImpl.cpp new file mode 100644 index 0000000..75ffec8 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ProgressImpl.cpp @@ -0,0 +1,283 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ProgressImpl.cpp + * @brief This is the implementation file for the _ProgressImpl class. + */ + +#include +#include +#include "FUi_UiBuilder.h" +#include "FUi_ResourceManager.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUiCtrl_ProgressImpl.h" +#include "FUiCtrl_Progress.h" + +using namespace Tizen::Ui; +using namespace Tizen::Graphics; + +const int _DEFAULT_MINIMUM = 0; +const int _DEFAULT_MAXIMUM = 100; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ProgressImpl* +_ProgressImpl::GetInstance(Progress& progress) +{ + return static_cast<_ProgressImpl*> (progress._pControlImpl); +} + +const _ProgressImpl* +_ProgressImpl::GetInstance(const Progress& progress) +{ + return static_cast (progress._pControlImpl); +} + +_ProgressImpl::_ProgressImpl(Progress* pPublic, _Progress* pCore) + : _ControlImpl(pPublic, pCore) +{ + SetFocusableChangable(false); +} + +_ProgressImpl::~_ProgressImpl(void) +{ +} + +_ProgressImpl* +_ProgressImpl::CreateProgressImplN(Progress* pControl, const Rectangle& bounds) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + r = GET_SIZE_INFO(Progress).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Progress* pCore = _Progress::CreateProgressN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _ProgressImpl* pImpl = new (std::nothrow) _ProgressImpl(pControl, pCore); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Progress), bounds, pCore->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; + +CATCH: + delete pImpl; //This deletes pCore as well + pImpl = null; + + return null; +} + +result +_ProgressImpl::SetValue(int value) +{ + ClearLastResult(); + + Variant newValue(value); + + return GetCore().SetPropertyValue(newValue); +} + +result +_ProgressImpl::SetRange(int minValue, int maxValue) +{ + ClearLastResult(); + + return GetCore().SetRange(minValue, maxValue); +} + +int +_ProgressImpl::GetValue(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyValue().ToInt(); +} + +result +_ProgressImpl::GetRange(int& minValue, int& maxValue) const +{ + ClearLastResult(); + + return GetCore().GetRange(minValue, maxValue); +} + +int +_ProgressImpl::GetPercentComplete(void) const +{ + ClearLastResult(); + + return GetCore().GetPercentComplete(); +} + +result +_ProgressImpl::SetBarColor(const Color& color) +{ + ClearLastResult(); + + Variant barColor(color); + + return GetCore().SetPropertyBarColor(barColor); +} + +Color +_ProgressImpl::GetBarColor() const +{ + ClearLastResult(); + + return GetCore().GetPropertyBarColor().ToColor(); +} + +const char* +_ProgressImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::Progress"; +} + +const Progress& +_ProgressImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +Progress& +_ProgressImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Progress& +_ProgressImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Progress& +_ProgressImpl::GetCore(void) +{ + return static_cast <_Progress&>(_ControlImpl::GetCore()); +} + + +class _ProgressMaker + : public _UiBuilderControlMaker +{ + +public: + _ProgressMaker(_UiBuilder* pUiBuilder) + : _UiBuilderControlMaker(pUiBuilder){} + virtual ~_ProgressMaker(void){} + + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* pUiBuilder) + { + _ProgressMaker* pProgressMaker = new (std::nothrow) _ProgressMaker(pUiBuilder); + return pProgressMaker; + } + +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SUCCESS; + _UiBuilderControlLayout* pControlProperty = null; + Progress* pProgress = null; + Tizen::Base::String elementString; + Tizen::Base::String elementString1; + Color color; + int tempMin = 0; + int tempMax = 0; + int temp = 0; + + Rectangle rect; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pProgress = new (std::nothrow) Progress; + if (pProgress == null) + { + return null; + } + rect = pControlProperty->GetRect(); + + if (pControl->GetElement(L"min", elementString) && pControl->GetElement(L"max", elementString1)) + { + Base::Integer::Parse(elementString, tempMin); + Base::Integer::Parse(elementString1, tempMax); + if (tempMin > tempMax) + { + temp = tempMin; + tempMin = tempMax; + tempMax = tempMin; + } + } + else + { + tempMin = _DEFAULT_MINIMUM; + tempMax = _DEFAULT_MAXIMUM; + } + + r = pProgress->Construct(rect, tempMin, tempMax); + if (r != E_SUCCESS) + { + delete pProgress; + pProgress = null; + + return null; + } + + if (pControl->GetElement(L"value", elementString)) + { + int tempValue = 0; + Base::Integer::Parse(elementString, tempValue); + pProgress->SetValue(tempValue); + } + + if (pControl->GetElement(L"barColor", elementString)) + { + ConvertStringToColor(elementString, color); + pProgress->SetBarColor(color); + } + + return pProgress; + } + +}; // _ProgressMaker + +_ProgressRegister::_ProgressRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"Progress", _ProgressMaker::GetInstance); +} + +_ProgressRegister::~_ProgressRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"Progress"); +} +static _ProgressRegister ProgressRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ProgressModel.cpp b/src/ui/controls/FUiCtrl_ProgressModel.cpp new file mode 100644 index 0000000..007b980 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ProgressModel.cpp @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ProgressModel.cpp + * @brief This is the implementation file for the _ProgressModel class. + */ + +#include "FUiCtrl_ProgressModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ProgressModel::_ProgressModel(void) + : __minValue(0) + , __maxValue(0) + , __currentValue(0) +{ +} + +_ProgressModel::~_ProgressModel(void) +{ +} + +void +_ProgressModel::SetValue(int value) +{ + __currentValue = value; + return; +} + +int +_ProgressModel::GetValue() const +{ + return __currentValue; +} + +void +_ProgressModel::SetMinValue(int minValue) +{ + __minValue = minValue; + return; +} + +int +_ProgressModel::GetMinValue(void) const +{ + return __minValue; +} + +void +_ProgressModel::SetMaxValue(int maxValue) +{ + __maxValue = maxValue; + return; +} + +int +_ProgressModel::GetMaxValue(void) const +{ + return __maxValue; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ProgressPopup.cpp b/src/ui/controls/FUiCtrl_ProgressPopup.cpp new file mode 100644 index 0000000..d136c38 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ProgressPopup.cpp @@ -0,0 +1,671 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ProgressPopup.cpp + * @brief This is the implementation file for the _ProgressPopup class. + */ + +#include +#include +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_ResourceManager.h" +#include "FUi_DataBindingContext.h" +#include "FUiCtrl_ButtonImpl.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_ProgressPopup.h" +#include "FUiCtrl_ProgressPopupPresenter.h" + + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base; + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +_ProgressPopup::_ProgressPopup(void) + : __pProgressPopupPresenter(null) + , __pProgressPopupEvent(null) + , __pButton(null) + , __text(L"") + , __textColor(Color(0xFFFFFFFF)) + , __animationRect(0, 0, 0, 0) + , __pTextAccessibilityElement(null) + , __textState(false) + , __buttonState(false) + , __isTranslucent(false) +{ + // empty statement +} + +_ProgressPopup::~_ProgressPopup(void) +{ + delete __pProgressPopupPresenter; + __pProgressPopupPresenter = null; + + if (__pProgressPopupEvent != null) + { + delete __pProgressPopupEvent; + __pProgressPopupEvent = null; + } + + delete _pBgBitmap; + _pBgBitmap = null; + + delete _pComposedBgBitmap; + _pComposedBgBitmap = null; + + delete _pOutlineBitmap; + _pOutlineBitmap = null; + + delete _pDimmingLayer; + _pDimmingLayer = null; + + delete __pButton; + __pButton = null; + + if (__pTextAccessibilityElement) + { + __pTextAccessibilityElement->Activate(false); + __pTextAccessibilityElement = null; + } +} + +_ProgressPopup* +_ProgressPopup::CreateProgressPopupN(void) +{ + _ProgressPopup* pProgressPopup = new (std::nothrow) _ProgressPopup(); + SysTryReturn(NID_UI_CTRL, pProgressPopup != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + +#if defined(MULTI_WINDOW) + result r = pProgressPopup->CreateRootVisualElement(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); +#endif + + // for taking touch event + pProgressPopup->AcquireHandle(); + + return pProgressPopup; + +#if defined(MULTI_WINDOW) +CATCH: + delete pProgressPopup; + + return null; +#endif +} + +result +_ProgressPopup::Initialize(bool cancelButton, bool translucent, const Rectangle& animationRect) +{ + result r = E_SUCCESS; + + _AccessibilityContainer* pContainer = null; + + __animationRect = animationRect; + __buttonState = cancelButton; + __isTranslucent = translucent; + + _ProgressPopupPresenter* pPresenter = new (std::nothrow) _ProgressPopupPresenter(); + SysTryReturn(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + SetPresenter(*pPresenter); + + r = pPresenter->Initialize(*this, cancelButton, translucent, animationRect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_COLOR_CONFIG(POPUP::TITLE_TEXT_NORMAL, _titleTextColor); + GET_COLOR_CONFIG(MESSAGEBOX::TEXT_NORMAL, __textColor); + + GET_BITMAP_CONFIG_N(POPUP::BG_OUTLINE_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, _pOutlineBitmap); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Color bgColor; + GET_COLOR_CONFIG(POPUP::BG_NORMAL, bgColor); + + GET_BITMAP_CONFIG_N(POPUP::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, _pBgBitmap); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pComposedBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*_pBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), bgColor); + + // for clearing canvas + if (GetVisualElement() != null) + { + GetVisualElement()->SetSurfaceOpaque(false); + } + + if (__isTranslucent) + { + GetVisualElement()->SetOpacity(0.6f); // FIXME : temp + } + + _pDimmingLayer = new (std::nothrow) _DimmingLayer(); + SysTryReturn(NID_UI_CTRL, _pDimmingLayer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = _pDimmingLayer->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__buttonState && !__isTranslucent) + { + __pButton = new (std::nothrow) Button(); + SysTryCatch(NID_UI_CTRL, __pButton != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pButton->Construct(pPresenter->GetButtonBounds(), L"Cancel"); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + _ControlImpl* pImpl = _ControlImpl::GetInstance(*__pButton); + r = AttachChild(pImpl->GetCore()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + _Button* pButtonCore = dynamic_cast <_Button*>(&pImpl->GetCore()); + SysTryCatch(NID_UI_CTRL, pButtonCore != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pButtonCore->SetActionId(ID_PROGRESS_POPUP_CANCEL_BUTTON); + pButtonCore->AddActionEventListener(*this); + } + + pContainer = GetAccessibilityContainer(); + if(pContainer != null) + { + pContainer->Activate(true); + } + + return r; + +CATCH: + delete _pDimmingLayer; + _pDimmingLayer = null; + + delete __pButton; + __pButton = null; + + return r; +} + +result +_ProgressPopup::SetPresenter(const _ProgressPopupPresenter& ProgressPopupPresenter) +{ + __pProgressPopupPresenter = const_cast <_ProgressPopupPresenter*>(&ProgressPopupPresenter); + + return E_SUCCESS; +} + +result +_ProgressPopup::DoModal(int& modalResult) +{ + result r = E_SUCCESS; + + r = __pProgressPopupPresenter->DoModal(modalResult); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_ProgressPopup::AddProgressPopupEventListener(const Tizen::Ui::Controls::_IProgressPopupEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pProgressPopupEvent == null) + { + __pProgressPopupEvent = _ProgressPopupEvent::CreateInstanceN(*this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pProgressPopupEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_ProgressPopup::SetTitleText(const String& title) +{ + result r = E_SUCCESS; + + _titleText = title; + _titleState = true; + + if (_pTitleTextAccessibilityElement != null) + { + _pTitleTextAccessibilityElement->SetLabel(title); + } + + __pProgressPopupPresenter->SetTitleTextObject(); + + return r; +} + +result +_ProgressPopup::SetText(const String& text) +{ + result r = E_SUCCESS; + + __text = text; + __textState = true; + + if (__pTextAccessibilityElement != null) + { + __pTextAccessibilityElement->SetLabel(text); + } + + __pProgressPopupPresenter->SetTextObject(); + + return r; +} + +result +_ProgressPopup::UpdateBounds(void) +{ + result r = E_SUCCESS; + + // create button with new position + if (HasButton()) + { + _ControlImpl* pImpl = null; + _Button* pButtonCore = null; + + if (__pButton != null) + { + pImpl = _ControlImpl::GetInstance(*__pButton); + r = DetachChild(pImpl->GetCore()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pButton; + __pButton = null; + } + + __pButton = new (std::nothrow) Button(); + SysTryReturn(NID_UI_CTRL, __pButton != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pButton->Construct(__pProgressPopupPresenter->GetButtonBounds(), L"Cancel"); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl = _ControlImpl::GetInstance(*__pButton); + r = AttachChild(pImpl->GetCore()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pButtonCore = dynamic_cast <_Button*>(&pImpl->GetCore()); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pButtonCore != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pButtonCore->SetActionId(ID_PROGRESS_POPUP_CANCEL_BUTTON); + pButtonCore->AddActionEventListener(*this); + } + + // update total height -> GetTotalHeight (called by Impl) + // update process-animation rect position -> GetAnimationRect (called by UpdateProcessAnimationVE) + // update process-animation VE +// r = __pProgressPopupPresenter->UpdateProcessAnimationVE(); +// SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete __pButton; + __pButton = null; + + return r; +} + +String +_ProgressPopup::GetText(void) const +{ + return __text; +} + +int +_ProgressPopup::GetTotalHeight(void) const +{ + int transTopMargin = 0; + int transBottomMargin = 0; + int titleHeight = 0; + int noTitleHeigth = 0; + int animationWidth = 0; + int textTopGap = 0; + int textBottomGap = 0; + int bottomHeight = 0; + + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, GetOrientation(), transBottomMargin); + GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_NO_TITLE_TOP_MARGIN, GetOrientation(), noTitleHeigth); + GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_WIDTH, GetOrientation(), animationWidth); + GET_SHAPE_CONFIG(POPUP::PROCESS_TEXT_TOP_MARGIN, GetOrientation(), textTopGap); + GET_SHAPE_CONFIG(POPUP::PROCESS_TEXT_BOTTOM_MARGIN, GetOrientation(), textBottomGap); + GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, GetOrientation(), titleHeight); + + GET_SHAPE_CONFIG(MESSAGEBOX::BOTTOM_HEIGHT, GetOrientation(), bottomHeight); + + if (HasTitle()) + { + noTitleHeigth = 0; + } + else + { + titleHeight = 0; + } + + if (!HasText()) + { + textTopGap = 0; + textBottomGap = 0; + } + + if (!HasButton()) + { + bottomHeight = 0; + } + + int totalH = transTopMargin + + transBottomMargin + + titleHeight + + noTitleHeigth + + animationWidth + + textTopGap + + textBottomGap + + __pProgressPopupPresenter->GetBodyTextHeight() + + bottomHeight; + + return totalH; +} + +result +_ProgressPopup::SetTextColor(const Color& color) +{ + __textColor = color; + + return E_SUCCESS; +} + +Color +_ProgressPopup::GetTextColor() const +{ + return __textColor; +} + +Rectangle +_ProgressPopup::GetAnimationRect(void) const +{ + Rectangle animationBounds; + + int defaultWidth = 0; + int titleHeight = 0; + int animationWidth = 0; + int noTitleProcessTop = 0; + int transTopMargin = 0; + + GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, GetOrientation(), defaultWidth); + + GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, GetOrientation(), titleHeight); + GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_WIDTH, GetOrientation(), animationWidth); + GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_NO_TITLE_TOP_MARGIN, GetOrientation(), noTitleProcessTop); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, GetOrientation(), transTopMargin); + + if (HasTitle()) + { + animationBounds = Rectangle((defaultWidth - animationWidth) / 2, titleHeight + transTopMargin, animationWidth, animationWidth); + } + else if (HasText() || HasButton()) + { + animationBounds = Rectangle((defaultWidth - animationWidth) / 2, noTitleProcessTop + transTopMargin, animationWidth, animationWidth); + } + else + { + animationBounds = __animationRect; + } + + return animationBounds; +} + +bool +_ProgressPopup::HasText(void) const +{ + return __textState; +} + +bool +_ProgressPopup::HasButton(void) const +{ + return (__buttonState && !__isTranslucent); +} + +bool +_ProgressPopup::IsTranslucent(void) const +{ + return __isTranslucent; +} + +void +_ProgressPopup::FireProgressPopupEvent(void) +{ + if (__pProgressPopupEvent != null) + { + Tizen::Base::Runtime::IEventArg* pEventArg = _ProgressPopupEvent::CreateProgressPopupEventArgN(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pProgressPopupEvent->Fire(*pEventArg); + } +} + +void +_ProgressPopup::OnDraw(void) +{ + __pProgressPopupPresenter->Draw(); +} + +void +_ProgressPopup::OnFontChanged(Font * pFont) +{ + __pProgressPopupPresenter->OnFontChanged(pFont); +} + +void +_ProgressPopup::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pProgressPopupPresenter->OnFontInfoRequested(style, size); +} + +void +_ProgressPopup::OnActionPerformed(const Tizen::Ui::_Control& source, int actionId) +{ + switch (actionId) + { + case ID_PROGRESS_POPUP_CANCEL_BUTTON: + { + FireProgressPopupEvent(); + _Popup::SetReturnValue(POPUP_RESULT_CANCEL); + break; + } + + default: + break; + } +} + +void +_ProgressPopup::OnBoundsChanged(void) +{ + SetClientBounds(Rectangle(0, 0, GetBounds().width, GetBounds().height)); + + return; +} + +void +_ProgressPopup::OnVisibleStateChanged(void) +{ + _Popup::OnVisibleStateChanged(); +} + +result +_ProgressPopup::OnAttachedToMainTree(void) +{ + + SysTryReturn(NID_UI_CTRL, GetVisibleState() != false, E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control is not 'displayable'"); + + InitializeAccessibilityElement(); + + return E_SUCCESS; +} + +void +_ProgressPopup::OnActivated(void) +{ + __pProgressPopupPresenter->PlayProcessAnimation(); + + _Popup::OnActivated(); +} + +void +_ProgressPopup::OnDeactivated(void) +{ + __pProgressPopupPresenter->StopProcessAnimation(); + + _Popup::OnDeactivated(); +} + +void +_ProgressPopup::InitializeAccessibilityElement(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + if ((_pTitleTextAccessibilityElement != null) && (__pTextAccessibilityElement != null)) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer != null) + { + if (_pTitleTextAccessibilityElement == null) + { + _pTitleTextAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, _pTitleTextAccessibilityElement != null, E_OUT_OF_MEMORY,"[E_OUT_OF_MEMORY] Memory allocation failed."); + + _pTitleTextAccessibilityElement->Construct(L"ProgressPopupTitleText", __pProgressPopupPresenter->GetTitleBounds()); + _pTitleTextAccessibilityElement->SetLabel(GetTitleText()); + _pTitleTextAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_TEXT_FIELD); + + pContainer->AddElement(*_pTitleTextAccessibilityElement); + } + + if (__pTextAccessibilityElement == null) + { + __pTextAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pTextAccessibilityElement != null, E_OUT_OF_MEMORY,"[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTextAccessibilityElement->Construct(L"ProgressPopupText", __pProgressPopupPresenter->GetTextBounds()); + __pTextAccessibilityElement->SetLabel(GetText()); + __pTextAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_TEXT_FIELD); + + pContainer->AddElement(*__pTextAccessibilityElement); + } + + if (HasButton() == true) + { + _ControlImpl* pImpl = null; + _Button* pButtonCore = null; + + pImpl = _ControlImpl::GetInstance(*__pButton); + + pButtonCore = dynamic_cast<_Button*>(&pImpl->GetCore()); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pButtonCore != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _AccessibilityContainer* pButtonContainer = pButtonCore->GetAccessibilityContainer(); + if (pButtonContainer != null) + { + _AccessibilityElement* pButtonElement = pButtonContainer->GetChildElement(L"ButtonText"); + if (pButtonElement != null) + { + pButtonElement->SetName(L"ProgressPopupButton1"); + } + + // Add Container + pContainer->AddChildContainer(*pButtonContainer); + } + } + + } + + return; +} + + +void +_ProgressPopup::OnChangeLayout(_ControlOrientation orientation) +{ + SysTryReturnVoidResult(NID_UI_CTRL, _pDimmingLayer != null, E_SYSTEM, "[E_SYSTEM] There is no Dimming Layer."); + + result r = E_SUCCESS; + + r = _pDimmingLayer->Rearrange(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +bool +_ProgressPopup::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + + return __pProgressPopupPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_ProgressPopup::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + + return __pProgressPopupPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_ProgressPopup::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + + return __pProgressPopupPresenter->OnTouchReleased(source, touchinfo); +} + + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_ProgressPopupEvent.cpp b/src/ui/controls/FUiCtrl_ProgressPopupEvent.cpp new file mode 100644 index 0000000..ebfdb6a --- /dev/null +++ b/src/ui/controls/FUiCtrl_ProgressPopupEvent.cpp @@ -0,0 +1,123 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_ProgressPopupEvent.cpp +* @brief This is the implementation for the ActionEvent class. +*/ + +#include +#include +#include +#include "FUiCtrl_IProgressPopupEventListener.h" +#include "FUiCtrl_ProgressPopupEvent.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +class _OSP_EXPORT_ _ProgressPopupEventArg + : public Object + , public IEventArg +{ +public: + _ProgressPopupEventArg(void); + + virtual ~_ProgressPopupEventArg(void); + +}; // _ProgressPopupEventArg + + +_ProgressPopupEventArg::_ProgressPopupEventArg(void) +{ + // empty statement +} + +_ProgressPopupEventArg::~_ProgressPopupEventArg(void) +{ + // empty statement +} + + +_ProgressPopupEvent::_ProgressPopupEvent(const _Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + SetLastResult(E_SUCCESS); + } +} + +_ProgressPopupEvent::~_ProgressPopupEvent(void) +{ + // empty statement +} + +_ProgressPopupEvent* +_ProgressPopupEvent::CreateInstanceN(const _Control& source) +{ + _ProgressPopupEvent* pProgressPopupEvent = new (std::nothrow) _ProgressPopupEvent(source); + SysTryReturn(NID_UI_CTRL, pProgressPopupEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pProgressPopupEvent; + +CATCH: + delete pProgressPopupEvent; + return null; +} + +const _Control* +_ProgressPopupEvent::GetSource(void) const +{ + return __pSource; +} + +void +_ProgressPopupEvent::FireImpl(IEventListener& pListener, const IEventArg& arg) +{ + // cast to _IProgressPopupEventListener + _IProgressPopupEventListener* pProgressPopupListener = dynamic_cast <_IProgressPopupEventListener*>(&pListener); + SysTryReturnVoidResult(NID_UI_CTRL, pProgressPopupListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given.\n"); + + // call progresspopup event listener method + pProgressPopupListener->OnProgressPopupCanceled(); +} + +IEventArg* +_ProgressPopupEvent::CreateProgressPopupEventArgN(void) +{ + _ProgressPopupEventArg* pEventArg = new (std::nothrow) _ProgressPopupEventArg(); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ProgressPopupImpl.cpp b/src/ui/controls/FUiCtrl_ProgressPopupImpl.cpp new file mode 100644 index 0000000..fc1a3a8 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ProgressPopupImpl.cpp @@ -0,0 +1,431 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ProgressPopupImpl.cpp + * @brief This is the implementation file for the _ProgressPopupImpl class. + */ + + +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_ControlImplManager.h" +#include "FUiCtrl_FrameImpl.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_ProgressPopupImpl.h" + + +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Base; + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +_ProgressPopupImpl* +_ProgressPopupImpl::GetInstance(ProgressPopup& pProgressPopup) +{ + return static_cast <_ProgressPopupImpl*>(pProgressPopup._pControlImpl); +} + +const _ProgressPopupImpl* +_ProgressPopupImpl::GetInstance(const ProgressPopup& pProgressPopup) +{ + return static_cast (pProgressPopup._pControlImpl); +} + +_ProgressPopupImpl::_ProgressPopupImpl(ProgressPopup* pPublic, _ProgressPopup* pCore) + : _PopupImpl(pPublic, pCore) + , __pPublicProgressPopupEvent(null) +{ + //empty statement +} + +_ProgressPopupImpl::~_ProgressPopupImpl(void) +{ + if (__pPublicProgressPopupEvent != null) + { + delete __pPublicProgressPopupEvent; + __pPublicProgressPopupEvent = null; + } +} + +_ProgressPopupImpl* +_ProgressPopupImpl::CreateProgressPopupImplN(ProgressPopup* pControl) +{ + result r = E_SUCCESS; + + _ProgressPopupImpl* pImpl = null; + _ProgressPopup* pCore = null; + + pCore = _ProgressPopup::CreateProgressPopupN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl = new (std::nothrow) _ProgressPopupImpl(pControl, pCore); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; +} + +result +_ProgressPopupImpl::Initialize(bool cancelButton, bool translucent) +{ + result r = E_SUCCESS; + + int animationWidth = 0; + GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_WIDTH, GetCore().GetOrientation(), animationWidth); + + Rectangle animationRect; + animationRect = GetCenterAlignedRect(animationWidth, animationWidth); + + r = GetCore().Initialize(cancelButton, translucent, animationRect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (!cancelButton || translucent) + { + r = SetBounds(animationRect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + int maxHeight = 0; + int defaultWidth = 0; + + GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, GetCore().GetOrientation(), maxHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, GetCore().GetOrientation(), defaultWidth); + + int totalH = -1; + totalH = GetCore().GetTotalHeight(); + + Rectangle bounds; + if (totalH > maxHeight) + { + bounds = GetCenterAlignedRect(defaultWidth, maxHeight); + } + else + { + bounds = GetCenterAlignedRect(defaultWidth, totalH); + } + + r = SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + SetMovable(false); + SetResizable(false); + + return r; +} + +const char* +_ProgressPopupImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::ProgressPopup"; +} + +const ProgressPopup& +_ProgressPopupImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +ProgressPopup& +_ProgressPopupImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _ProgressPopup& +_ProgressPopupImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_ProgressPopup& +_ProgressPopupImpl::GetCore(void) +{ + return static_cast <_ProgressPopup&>(_ControlImpl::GetCore()); +} + +result +_ProgressPopupImpl::AddProgressPopupEventListener(IProgressPopupEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pPublicProgressPopupEvent == null) + { + __pPublicProgressPopupEvent = _PublicProgressPopupEvent::CreateInstanceN(GetPublic()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pPublicProgressPopupEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return GetCore().AddProgressPopupEventListener(*this); +} + +result +_ProgressPopupImpl::RemoveProgressPopupEventListener(IProgressPopupEventListener & listener) +{ + result r = E_SUCCESS; + + if (__pPublicProgressPopupEvent != null) + { + r = __pPublicProgressPopupEvent->RemoveListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_ProgressPopupImpl::OnAttachedToMainTree(void) +{ + if (GetOwner() == null) + { + _FrameImpl* pFrameImpl = static_cast <_FrameImpl*>(_ControlImplManager::GetInstance()->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, pFrameImpl != null, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] This instance is not constructed."); + + _Form* pForm = pFrameImpl->GetCore().GetCurrentForm(); + + _Window* pWindow = static_cast <_Window*>(&GetCore()); + SysTryReturn(NID_UI_CTRL, pWindow != null, E_SYSTEM, + E_SYSTEM, "[E_SYSTEM] This instance is not constructed."); + + if (pForm != null) + { + pWindow->SetOwner(pForm); + } + else + { + pWindow->SetOwner(&pFrameImpl->GetCore()); + } + } + + _WindowImpl::OnAttachedToMainTree(); + return GetCore().Open(); +} + +result +_ProgressPopupImpl::SetTitleText(const String& title) +{ + result r = E_SUCCESS; + + r = GetCore().SetTitleText(title); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int maxHeight = 0; + int defaultWidth = 0; + + GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, GetCore().GetOrientation(), maxHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, GetCore().GetOrientation(), defaultWidth); + + int totalH = -1; + totalH = GetCore().GetTotalHeight(); + + Rectangle bounds; + if (totalH > maxHeight) + { + bounds = GetCenterAlignedRect(defaultWidth, maxHeight); + } + else + { + bounds = GetCenterAlignedRect(defaultWidth, totalH); + } + + SetMovable(true); + SetResizable(true); + + r = SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetMovable(false); + SetResizable(false); + + r = GetCore().UpdateBounds(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +} + +result +_ProgressPopupImpl::SetText(const String& text) +{ + result r = E_SUCCESS; + int maxLength = 0; + + maxLength = GetMaxTextLength(); + SysTryReturn(NID_UI_CTRL, text.GetLength() <= maxLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] Text length is too long to create ProgressPopup."); + + r = GetCore().SetText(text); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int maxHeight = 0; + int defaultWidth = 0; + + GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, GetCore().GetOrientation(), maxHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, GetCore().GetOrientation(), defaultWidth); + + int totalH = -1; + totalH = GetCore().GetTotalHeight(); + + Rectangle bounds; + if (totalH > maxHeight) + { + bounds = GetCenterAlignedRect(defaultWidth, maxHeight); + } + else + { + bounds = GetCenterAlignedRect(defaultWidth, totalH); + } + + SetMovable(true); + SetResizable(true); + + r = SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetMovable(false); + SetResizable(false); + + r = GetCore().UpdateBounds(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + + return r; + +} + +String +_ProgressPopupImpl::GetText(void) const +{ + return GetCore().GetText(); +} + +result +_ProgressPopupImpl::SetTextColor(const Color& color) +{ + GetCore().SetTextColor(color); + + return E_SUCCESS; +} + +Color +_ProgressPopupImpl::GetTextColor() const +{ + return GetCore().GetTextColor(); +} + +int +_ProgressPopupImpl::GetMaxTextLength(void) const +{ + int maxLength = 0; + GET_FIXED_VALUE_CONFIG(MESSAGEBOX::TEXT_MAX_LENGTH, GetCore().GetOrientation(), maxLength); + + return maxLength; +} + +Rectangle +_ProgressPopupImpl::GetCenterAlignedRect(int width, int height) const +{ + int x = 0; + int y = 0; + + Dimension screenRect = _ControlManager::GetInstance()->GetScreenSize(); + + if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE) + { + int temp = screenRect.width; + screenRect.width = screenRect.height; + screenRect.height = temp; + } + + x = (screenRect.width - width) / 2; + y = (screenRect.height - height) / 2; + + return Rectangle(x, y, width, height); +} + +void +_ProgressPopupImpl::OnProgressPopupCanceled(void) +{ + if (__pPublicProgressPopupEvent != null) + { + Tizen::Base::Runtime::IEventArg* pEventArg = _PublicProgressPopupEvent::CreateProgressPopupEventArgN(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicProgressPopupEvent->Fire(*pEventArg); + } +} + +void +_ProgressPopupImpl::OnChangeLayout(_ControlOrientation orientation) +{ + result r = E_SUCCESS; + Dimension portraitSize; + Dimension landscapeSize; + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + portraitSize = Dimension(GetBounds().width, GetBounds().height); + landscapeSize = Dimension(portraitSize.height, portraitSize.width); + } + else + { + portraitSize = Dimension(GetBounds().height, GetBounds().width); + landscapeSize = Dimension(portraitSize.height, portraitSize.width); + } + + if (orientation == _CONTROL_ORIENTATION_PORTRAIT) + { + SetResizable(true); + SetMovable(true); + + r = SetBounds(GetCenterAlignedRect(portraitSize.width, portraitSize.height)); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetMovable(false); + SetResizable(false); + } + else + { + SetResizable(true); + SetMovable(true); + + r = SetBounds(GetCenterAlignedRect(landscapeSize.width, landscapeSize.height)); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetMovable(false); + SetResizable(false); + } + + return GetCore().OnChangeLayout(orientation); +} + + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ProgressPopupPresenter.cpp b/src/ui/controls/FUiCtrl_ProgressPopupPresenter.cpp new file mode 100644 index 0000000..e9cc938 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ProgressPopupPresenter.cpp @@ -0,0 +1,763 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ProgressPopupPresenter.cpp + * @brief This is the implementation file for the _ProgressPopupPresenter class. + */ + + +#include +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUiCtrl_ProgressPopupPresenter.h" +#include "FUiCtrl_ProgressPopup.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +_ProgressPopupPresenter::_ProgressPopupPresenter(void) + : __pProgressPopup(null) + , __pTitleTextObject(null) + , __pBodyTextObject(null) + , __titleBounds(0, 0, 0, 0) + , __textBounds(0, 0, 0, 0) + , __animationBounds(0, 0, 0, 0) + , __pAnimation(null) + , __pAnimationFrameList(null) + , __fontStyle(0) + , __fontSize(0) + , __textObjectHeight(0) + , __currentIndex(0) + , __buttonPressState(false) + , __cancelButton(false) + , __translucent(false) +{ + for (int i = 0; i < MAX_PROCESS_IMAGE_COUNT; i++) + { + __pProcessImage[i] = null; + } +} + +_ProgressPopupPresenter::~_ProgressPopupPresenter(void) +{ + for (int i = 0; i < MAX_PROCESS_IMAGE_COUNT; i++) + { + delete __pProcessImage[i]; + __pProcessImage[i] = null; + } + + if (__pTitleTextObject != null) + { + __pTitleTextObject->RemoveAll(); + delete __pTitleTextObject; + __pTitleTextObject = null; + } + + if (__pBodyTextObject != null) + { + __pBodyTextObject->RemoveAll(); + delete __pBodyTextObject; + __pBodyTextObject = null; + } + + if (__pAnimationFrameList != null) + { + __pAnimationFrameList->RemoveAll(true); + delete __pAnimationFrameList; + __pAnimationFrameList = null; + } + + if (__pAnimation != null) + { + delete __pAnimation; + __pAnimation = null; + } + +} + +result +_ProgressPopupPresenter::Initialize(_ProgressPopup& ProgressPopup, bool cancelButton, bool translucent, const Rectangle& animationRect) +{ + result r = E_SUCCESS; + + __cancelButton = cancelButton; + __translucent = translucent; + __pProgressPopup = &ProgressPopup; + + return r; +} + +void +_ProgressPopupPresenter::SetTitleTextObject(void) +{ + int titleTextSize = 0; + int defaultWidth = 0; + int titleHeight = 0; + int titleTopMargin = 0; + int titleLeftMargin = 0; + int titleRightMargin = 0; + + int transTopMargin = 0; + int transLeftMargin = 0; + int transRightMargin = 0; + + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_SIZE, __pProgressPopup->GetOrientation(), titleTextSize); + GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, __pProgressPopup->GetOrientation(), defaultWidth); + GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, __pProgressPopup->GetOrientation(), titleHeight); + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_TOP_MARGIN, __pProgressPopup->GetOrientation(), titleTopMargin); + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_LEFT_MARGIN, __pProgressPopup->GetOrientation(), titleLeftMargin); + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_RIGHT_MARGIN, __pProgressPopup->GetOrientation(), titleRightMargin); + + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pProgressPopup->GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, __pProgressPopup->GetOrientation(), transLeftMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, __pProgressPopup->GetOrientation(), transRightMargin); + + if (__pProgressPopup->HasTitle()) + { + result r = E_SUCCESS; + + __pTitleTextObject = new (std::nothrow) TextObject(); + SysTryReturnVoidResult(NID_UI_CTRL, __pTitleTextObject != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = SetFontInfo(FONT_STYLE_PLAIN, titleTextSize); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r)); + + __pTitleTextObject->Construct(); + TextSimple* pSimpleTextForTitleText = new (std::nothrow) TextSimple(const_cast (__pProgressPopup->GetTitleText().GetPointer()), + __pProgressPopup->GetTitleText().GetLength(), + TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_UI_CTRL, pSimpleTextForTitleText != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTitleTextObject->AppendElement(*pSimpleTextForTitleText); + __pTitleTextObject->SetForegroundColor(__pProgressPopup->GetTitleTextColor(), 0, __pTitleTextObject->GetTextLength()); + __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pTitleTextObject->SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL); + + __pTitleTextObject->SetFont(_pFont, 0, __pTitleTextObject->GetTextLength()); + __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT); + __pTitleTextObject->SetBounds(Rectangle(titleLeftMargin + transLeftMargin, + titleTopMargin, + defaultWidth - (titleLeftMargin + titleRightMargin + transLeftMargin + transRightMargin), + titleHeight - titleTopMargin)); + __pTitleTextObject->Compose(); + + __titleBounds = Rectangle(titleLeftMargin + transLeftMargin, + titleTopMargin, + defaultWidth - (titleLeftMargin + titleRightMargin + transLeftMargin + transRightMargin), + titleHeight - titleTopMargin); + + } + + return; +CATCH: + delete __pTitleTextObject; + __pTitleTextObject = null; + + return; +} + +void +_ProgressPopupPresenter::SetTextObject(void) +{ + int bodyTextSize = 0; + int defaultWidth = 0; + int titleHeight = 0; + int maxHeight = 0; + int btnBottomMargin = 0; + int textLeftMargin = 0; + int textRightMargin = 0; + int bottomHeight = 0; + int transTopMargin = 0; + int transBottomMargin = 0; + int transLeftMargin = 0; + int transRightMargin = 0; + int animationWidth = 0; + int textTopMargin = 0; + int textBottomMargin = 0; + int noTitleHeight = 0; + + GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, __pProgressPopup->GetOrientation(), titleHeight); + GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_NO_TITLE_TOP_MARGIN, __pProgressPopup->GetOrientation(), noTitleHeight); + GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_WIDTH, __pProgressPopup->GetOrientation(), animationWidth); + + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pProgressPopup->GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, __pProgressPopup->GetOrientation(), transBottomMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_LEFT_MARGIN, __pProgressPopup->GetOrientation(), transLeftMargin); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, __pProgressPopup->GetOrientation(), transRightMargin); + + GET_SHAPE_CONFIG(MESSAGEBOX::PROCESS_TEXT_TOP_MARGIN, __pProgressPopup->GetOrientation(), textTopMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::PROCESS_TEXT_BOTTOM_MARGIN, __pProgressPopup->GetOrientation(), textBottomMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_LEFT_MARGIN, __pProgressPopup->GetOrientation(), textLeftMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_RIGHT_MARGIN, __pProgressPopup->GetOrientation(), textRightMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_SIZE, __pProgressPopup->GetOrientation(), bodyTextSize); + + GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, __pProgressPopup->GetOrientation(), maxHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, __pProgressPopup->GetOrientation(), defaultWidth); + GET_SHAPE_CONFIG(MESSAGEBOX::BOTTOM_HEIGHT, __pProgressPopup->GetOrientation(), bottomHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_BOTTOM_MARGIN, __pProgressPopup->GetOrientation(), btnBottomMargin); + + + if (__pProgressPopup->HasTitle()) + { + noTitleHeight = 0; + } + else + { + titleHeight = 0; + } + + if (__pProgressPopup->HasText()) + { + result r = E_SUCCESS; + + __pBodyTextObject = new (std::nothrow) TextObject(); + SysTryReturnVoidResult(NID_UI_CTRL, __pBodyTextObject != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (__pProgressPopup->HasButton()) + { + GET_SHAPE_CONFIG(MESSAGEBOX::BOTTOM_HEIGHT, __pProgressPopup->GetOrientation(), bottomHeight); + } + + r = SetFontInfo(FONT_STYLE_PLAIN, bodyTextSize); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r)); + + __pBodyTextObject->Construct(); + TextSimple* pSimpleTextForBodyText = new (std::nothrow) TextSimple(const_cast (__pProgressPopup->GetText().GetPointer()), + __pProgressPopup->GetText().GetLength(), + TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_UI_CTRL, pSimpleTextForBodyText != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pBodyTextObject->AppendElement(*pSimpleTextForBodyText); + __pBodyTextObject->SetForegroundColor(__pProgressPopup->GetTextColor(), 0, __pBodyTextObject->GetTextLength()); + __pBodyTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + __pBodyTextObject->SetFont(_pFont, 0, __pBodyTextObject->GetTextLength()); + __pBodyTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT); + __pBodyTextObject->SetBounds(Rectangle(textLeftMargin + transLeftMargin, + titleHeight + animationWidth + noTitleHeight, + defaultWidth - (textLeftMargin + textRightMargin + transLeftMargin + transRightMargin), + maxHeight - titleHeight - bottomHeight - animationWidth)); + __pBodyTextObject->Compose(); + + // Calculate Text bounds + __textObjectHeight = __pBodyTextObject->GetTotalHeight(); + + int totalHeightExceptTextObj = titleHeight + animationWidth + textTopMargin + textBottomMargin + bottomHeight + (transTopMargin + transBottomMargin); + int tmpH = maxHeight - (totalHeightExceptTextObj + __textObjectHeight); + + __textObjectHeight = (tmpH > 0) ? __textObjectHeight : __textObjectHeight + tmpH; + + __textBounds.SetBounds(textLeftMargin + transLeftMargin, + titleHeight + textTopMargin + transTopMargin + animationWidth + noTitleHeight, + defaultWidth - (textLeftMargin + textRightMargin + transLeftMargin + transRightMargin), + __textObjectHeight); + + __pBodyTextObject->SetBounds(__textBounds); + } + + return; + +CATCH: + delete __pBodyTextObject; + __pBodyTextObject = null; + + return; +} + +result +_ProgressPopupPresenter::PlayProcessAnimation(void) +{ + if (__pAnimation != null) + { + if (__pAnimation->GetStatus() == ANIMATION_PLAYING) + { + return E_SUCCESS; + } + } + else + { + SetProcessAnimation(); + } + + if (__pAnimation != null) + { + __pAnimation->Play(); + } + + return E_SUCCESS; + +} + +result +_ProgressPopupPresenter::StopProcessAnimation(void) +{ + __pAnimation->Stop(); + + __pProgressPopup->DetachChild(*__pAnimation); + + delete __pAnimation; + __pAnimation = null; + + return E_SUCCESS; +} + +result +_ProgressPopupPresenter::SetProcessAnimation(void) +{ + result r = E_SUCCESS; + + if (__pAnimation != null) + { + if (__pAnimation->GetStatus() == ANIMATION_PLAYING) + { + return r; + } + } + + // Create AnimationFrames + long duration = 1500 / 30; + Rectangle animationBounds; + AnimationFrame* pAniFrame[MAX_PROCESS_IMAGE_COUNT]; + + r = LoadImages(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + for (int i = 0; i < MAX_PROCESS_IMAGE_COUNT; i++) + { + pAniFrame[i] = null; + + pAniFrame[i] = new (std::nothrow) AnimationFrame(*__pProcessImage[i], duration); + SysTryCatch(NID_UI_CTRL, pAniFrame[i] != null, ,E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + } + + __pAnimationFrameList = new (std::nothrow) ArrayList(); + SysTryCatch(NID_UI_CTRL, __pAnimationFrameList != null, ,E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (__pAnimationFrameList != null) + { + __pAnimationFrameList->Construct(); + + for (int i = 0; i < MAX_PROCESS_IMAGE_COUNT; i++) + { + r = __pAnimationFrameList->Add(*pAniFrame[i]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + delete __pAnimation; + __pAnimation = null; + + __pAnimation = _Animation::CreateAnimationN(); + + if (__pAnimation) + { + if (__pAnimationFrameList) + { + __pAnimation->SetAnimationFrames(*__pAnimationFrameList); + } + + __pAnimation->SetImageCount(MAX_PROCESS_IMAGE_COUNT); + __pAnimation->SetRepeatCount(ANIMATION_REPEAT_COUNT); + __pAnimation->AddAnimationEventListener(*this); + + animationBounds = __pProgressPopup->GetAnimationRect(); + if (__pProgressPopup->HasTitle() || __pProgressPopup->HasText() || __pProgressPopup->HasButton()) + { + __pAnimation->SetBounds(FloatRectangle(animationBounds.x, animationBounds.y, animationBounds.width, animationBounds.height)); + } + else + { + __pAnimation->GetVisualElement()->SetOpacity(0.6f); + __pAnimation->SetBounds(FloatRectangle(0, 0, animationBounds.width, animationBounds.height)); + } + + __pProgressPopup->AttachChild(*__pAnimation); + } + + return r; + +CATCH: + for (int i = 0; i < MAX_PROCESS_IMAGE_COUNT; i++) + { + delete __pProcessImage[i]; + __pProcessImage[i] = null; + } + + return r; +} + +void +_ProgressPopupPresenter::OnAnimationStopped(const _Control & source) +{ + if (&source == __pAnimation) + { + __pAnimation->Play(); + } +} + +void +_ProgressPopupPresenter::OnFontChanged(Font* pFont) +{ + _pFont = pFont; +} + +void +_ProgressPopupPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = __fontStyle; + size = __fontSize; +} + +result +_ProgressPopupPresenter::SetFontInfo(unsigned long style, int size) +{ + __fontStyle = style; + __fontSize = size; + + _pFont = __pProgressPopup->GetFallbackFont(); + SysTryReturnResult(NID_UI_CTRL, _pFont != null, GetLastResult(), "Failed to get a font."); + + return E_SUCCESS; +} + +void +_ProgressPopupPresenter::Draw(void) +{ + result r = E_SUCCESS; + + int titleTextSize = 0; + int bodyTextSize = 0; + int defaultWidth = 0; + int titleHeight = 0; + + int btnHeight = 0; + int btnTopMargin = 0; + int btnBottomMargin = 0; + + int transTopMargin = 0; + int titleTopMargin = 0; + int animationWidth = 0; + + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_SIZE, __pProgressPopup->GetOrientation(), titleTextSize); + GET_SHAPE_CONFIG(MESSAGEBOX::TEXT_SIZE, __pProgressPopup->GetOrientation(), bodyTextSize); + + GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, __pProgressPopup->GetOrientation(), titleHeight); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pProgressPopup->GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(POPUP::TITLE_TEXT_TOP_MARGIN, __pProgressPopup->GetOrientation(), titleTopMargin); + GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_WIDTH, __pProgressPopup->GetOrientation(), animationWidth); + + GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, __pProgressPopup->GetOrientation(), defaultWidth); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, __pProgressPopup->GetOrientation(), btnHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_TOP_MARGIN, __pProgressPopup->GetOrientation(), btnTopMargin); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_BOTTOM_MARGIN, __pProgressPopup->GetOrientation(), btnBottomMargin); + + Canvas* pCanvas = __pProgressPopup->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, (pCanvas != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create canvas."); + + pCanvas->SetBackgroundColor(Color(0x00000000)); + pCanvas->Clear(); + + bool hasBgBitmap = (__pProgressPopup->GetBackgroundBitmap() != null); + + int totalH = __pProgressPopup->GetTotalHeight(); + + // Draw BG + if (hasBgBitmap && (__pProgressPopup->HasTitle() || __pProgressPopup->HasText() || __pProgressPopup->HasButton())) + { + Rectangle bounds(0, 0, defaultWidth, totalH); + + const Bitmap* pBackgroundBitmap = __pProgressPopup->GetBackgroundBitmap(); + if (pBackgroundBitmap->IsNinePatchedBitmap() == true) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap); + } + else + { + pCanvas->DrawBitmap(bounds, *pBackgroundBitmap); + } + } + + // Draw Title text + if (__pTitleTextObject != null) + { + r = SetFontInfo(FONT_STYLE_PLAIN, titleTextSize); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r)); + + __pTitleTextObject->SetFont(_pFont, 0, __pTitleTextObject->GetTextLength()); + __pTitleTextObject->SetBounds(__titleBounds); + __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + } + + // Draw Body text + if (__pBodyTextObject != null) + { + r = SetFontInfo(FONT_STYLE_PLAIN, bodyTextSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pBodyTextObject->SetFont(_pFont, 0, __pBodyTextObject->GetTextLength()); + + __pBodyTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + } + + //fall thtrough +CATCH: + delete pCanvas; + + return; +} + +result +_ProgressPopupPresenter::DoModal(int& modalResult) +{ + __pProgressPopup->Open(); + + ProcessEvent(); + + __pProgressPopup->Close(); + + modalResult = __pProgressPopup->GetPopupReturnValue(); + + return E_SUCCESS; +} + +int +_ProgressPopupPresenter::GetBodyTextHeight(void) const +{ + return (__pBodyTextObject == null) ? 0 : __pBodyTextObject->GetTotalHeight(); +} + +Rectangle +_ProgressPopupPresenter::GetTitleBounds(void) const +{ + return __titleBounds; +} + +Rectangle +_ProgressPopupPresenter::GetTextBounds(void) const +{ + return __textBounds; +} + +Rectangle +_ProgressPopupPresenter::GetButtonBounds(void) const +{ + int width = 0; + int height = 0; + int x = 0; + int y = 0; + + int defaultWidth = 0; + int titleHeight = 0; + int btnHeight = 0; + int btnSideMargin1 = 0; + int btnTopMargin = 0; + int transTopMargin = 0; + int animationWidth = 0; + int noTitleHeight = 0; + int textTopMargin = 0; + int textBottomMargin = 0; + + GET_SHAPE_CONFIG(POPUP::TITLE_HEIGHT, __pProgressPopup->GetOrientation(), titleHeight); + GET_SHAPE_CONFIG(POPUP::BG_IMAGE_TRANSPARENT_TOP_MARGIN, __pProgressPopup->GetOrientation(), transTopMargin); + GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_WIDTH, __pProgressPopup->GetOrientation(), animationWidth); + GET_SHAPE_CONFIG(POPUP::PROCESS_ANIMATION_NO_TITLE_TOP_MARGIN, __pProgressPopup->GetOrientation(), noTitleHeight); + GET_SHAPE_CONFIG(POPUP::PROCESS_TEXT_TOP_MARGIN, __pProgressPopup->GetOrientation(), textTopMargin); + GET_SHAPE_CONFIG(POPUP::PROCESS_TEXT_BOTTOM_MARGIN, __pProgressPopup->GetOrientation(), textBottomMargin); + + GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, __pProgressPopup->GetOrientation(), defaultWidth); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_HEIGHT, __pProgressPopup->GetOrientation(), btnHeight); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_SIDE_MARGIN_01, __pProgressPopup->GetOrientation(), btnSideMargin1); + GET_SHAPE_CONFIG(MESSAGEBOX::BUTTON_TOP_MARGIN, __pProgressPopup->GetOrientation(), btnTopMargin); + + if (!__pProgressPopup->HasButton()) + { + return Rectangle(0, 0, 0, 0); + } + + if (__pProgressPopup->HasTitle()) + { + noTitleHeight = 0; + } + else + { + titleHeight = 0; + } + + if (!__pProgressPopup->HasText()) + { + textTopMargin = 0; + textBottomMargin = 0; + } + + width = defaultWidth - (btnSideMargin1 * 2); + height = btnHeight; + x = btnSideMargin1; + + y = transTopMargin + + titleHeight + + noTitleHeight + + animationWidth + + textTopMargin + + textBottomMargin + + GetBodyTextHeight() + + btnTopMargin; + + return Rectangle(x, y, width, height); +} + +bool +_ProgressPopupPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + __buttonPressState = true; + + return true; +} + +bool +_ProgressPopupPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + __buttonPressState = false; + + return true; +} + +bool +_ProgressPopupPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + Point touchPoint = touchinfo.GetCurrentPosition(); + + return true; +} + +result +_ProgressPopupPresenter::LoadImages(void) +{ + result r = E_SUCCESS; + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_01, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[0]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_02, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[1]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_03, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[2]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_04, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[3]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_05, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[4]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_06, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[5]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_07, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[6]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_08, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[7]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_09, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[8]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_10, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[9]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_11, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[10]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_12, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[11]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_13, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[12]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_14, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[13]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_15, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[14]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_16, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[15]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_17, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[16]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_18, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[17]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_19, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[18]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_20, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[19]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_21, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[20]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_22, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[21]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_23, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[22]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_24, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[23]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_25, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[24]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_26, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[25]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_27, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[26]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_28, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[27]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_29, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[28]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(POPUP::PROCESS_ICON_IMAGE_NORMAL_30, BITMAP_PIXEL_FORMAT_ARGB8888, __pProcessImage[29]); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + + +}}} // Tizen::Ui::Controls + + diff --git a/src/ui/controls/FUiCtrl_ProgressPresenter.cpp b/src/ui/controls/FUiCtrl_ProgressPresenter.cpp new file mode 100644 index 0000000..5e76678 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ProgressPresenter.cpp @@ -0,0 +1,377 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ProgressPresenter.cpp + * @brief This is the implementation file for the _ProgressPresenter class. + */ + +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_ProgressPresenter.h" +#include "FUiCtrl_ProgressModel.h" +#include "FUiCtrl_Progress.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ProgressPresenter::_ProgressPresenter(void) + : __pProgress(null) + , __pProgressModel(null) + , __pResourceBitmap(null) + , __pBarResourceEffectBitmap(null) + , __pBarBgResourceEffectBitmap(null) + , __pBarColorReplacementBitmap(null) + , __pBarBgColorReplacementBitmap(null) +{ +} + +_ProgressPresenter::~_ProgressPresenter(void) +{ + delete __pProgressModel; + __pProgressModel = null; + + delete __pResourceBitmap; + __pResourceBitmap = null; + + delete __pBarResourceEffectBitmap; + __pBarResourceEffectBitmap = null; + + delete __pBarBgResourceEffectBitmap; + __pBarBgResourceEffectBitmap = null; + + delete __pBarColorReplacementBitmap; + __pBarColorReplacementBitmap = null; + + delete __pBarBgColorReplacementBitmap; + __pBarBgColorReplacementBitmap = null; +} + +_ProgressPresenter* +_ProgressPresenter::CreateInstanceN(const _Progress& progress) +{ + result r = E_SUCCESS; + _ProgressPresenter* pProgressPresenter = new (std::nothrow) _ProgressPresenter; + SysTryReturn(NID_UI_CTRL, pProgressPresenter != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pProgressPresenter->__pProgress = const_cast <_Progress*>(&progress); + SysTryCatch(NID_UI_CTRL, pProgressPresenter->__pProgress != null, , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The Progress control core is null"); + + pProgressPresenter->__pProgressModel = new (std::nothrow) _ProgressModel; + SysTryCatch(NID_UI_CTRL, pProgressPresenter->__pProgressModel != null, , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pProgressPresenter->LoadResource(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. The loading of resource failed"); + + return pProgressPresenter; + +CATCH: + delete pProgressPresenter; + pProgressPresenter = null; + + return null; +} + +void +_ProgressPresenter::SetValue(int value) +{ + int maxValue = __pProgressModel->GetMaxValue(); + int minValue = __pProgressModel->GetMinValue(); + + if (value > maxValue) + { + value = maxValue; + } + else if (value < minValue) + { + value = minValue; + } + + __pProgressModel->SetValue(value); + + return; +} + +void +_ProgressPresenter::SetMinValue(int minValue) +{ + __pProgressModel->SetMinValue(minValue); + + if (__pProgressModel->GetValue() < minValue) + { + __pProgressModel->SetValue(minValue); + } + + return; +} + +void +_ProgressPresenter::SetMaxValue(int maxValue) +{ + __pProgressModel->SetMaxValue(maxValue); + + if (__pProgressModel->GetValue() > maxValue) + { + __pProgressModel->SetValue(maxValue); + } + return; +} + +int +_ProgressPresenter::GetValue(void) const +{ + return __pProgressModel->GetValue(); +} + +int +_ProgressPresenter::GetMinValue(void) const +{ + return __pProgressModel->GetMinValue(); +} + +int +_ProgressPresenter::GetMaxValue(void) const +{ + return __pProgressModel->GetMaxValue(); +} + +int +_ProgressPresenter::GetPercentComplete(void) const +{ + int percentValue = 0; + int span = __pProgressModel->GetMaxValue() - __pProgressModel->GetMinValue(); + + if (span != 0) + { + percentValue = (int) ((((double) __pProgressModel->GetValue() - __pProgressModel->GetMinValue()) / span) * 100); + } + + return percentValue; +} + +result +_ProgressPresenter::LoadResource(void) +{ + result r = E_SUCCESS; + + int opacity = 0; + + Color bgColor; + Color barColor; + + r = GET_COLOR_CONFIG(SLIDER::BAR_BG_NORMAL, bgColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::BAR_NORMAL, barColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(SLIDER::BAR_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pResourceBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pBarBgColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBitmap,Color::GetColor(COLOR_ID_MAGENTA), bgColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pResourceBitmap; + __pResourceBitmap = null; + + r = GET_BITMAP_CONFIG_N(SLIDER::PROGRESS_BAR_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pResourceBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pBarColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBitmap,Color::GetColor(COLOR_ID_MAGENTA), barColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(SLIDER::BAR_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pBarBgResourceEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(SLIDER::PROGRESS_BAR_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pBarResourceEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + opacity = barColor.GetAlpha(); + __pBarColorReplacementBitmap->SetAlphaConstant(opacity); + + __currentBarColor = barColor; + + return r; + +CATCH: + + delete __pResourceBitmap; + __pResourceBitmap = null; + + delete __pBarResourceEffectBitmap; + __pBarResourceEffectBitmap = null; + + delete __pBarBgResourceEffectBitmap; + __pBarBgResourceEffectBitmap = null; + + delete __pBarColorReplacementBitmap; + __pBarColorReplacementBitmap = null; + + delete __pBarBgColorReplacementBitmap; + __pBarBgColorReplacementBitmap = null; + + return r; +} + +result +_ProgressPresenter::DrawBitmap(Canvas& canvas, const Rectangle& bounds, Bitmap* pBitmap) +{ + result r = E_SUCCESS; + + if (pBitmap->IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = canvas.DrawBitmap(bounds, *pBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + return r; +} + +result +_ProgressPresenter::Draw(void) +{ + result r = E_SUCCESS; + + Rectangle bounds = __pProgress->GetBounds(); + Canvas* pCanvas = __pProgress->GetCanvasN(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get a canvas."); + + int minValue = __pProgressModel->GetMinValue(); + int maxValue = __pProgressModel->GetMaxValue(); + int width = 0; + int height = 0; + int opacity = 0; + int leftMargin = 0; + int topMargin = 0; + int minimumWidth = 0; + int minimumHeight = 0; + int offset = 0; + Bitmap* pReplacementBitmap = null; + + GET_SHAPE_CONFIG(SLIDER::BAR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, height); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_SHAPE_CONFIG(SLIDER::BAR_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::MINIMUM_SIZE_WITHOUT_ICON, _CONTROL_ORIENTATION_PORTRAIT, minimumWidth); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::BAR_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, topMargin); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::BAR_OFFSET, _CONTROL_ORIENTATION_PORTRAIT, offset); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + minimumHeight = 2 * topMargin + height; + + if (bounds.width < minimumWidth) + { + bounds.width = minimumWidth; + } + + if (bounds.height < minimumHeight) + { + bounds.height = minimumHeight; + } + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + width = bounds.width - (2 * leftMargin) - (2 * offset); + if (maxValue == __pProgressModel->GetValue()) + { + width = bounds.width - (2 * leftMargin) - (2 * offset); + } + else + { + width = (width) * ((__pProgressModel->GetValue() - minValue) * 100 / (maxValue - minValue)) / 100; + } + + if (__pProgress->IsEnabled() == false) // disabled + { + __pBarBgColorReplacementBitmap->SetAlphaConstant(0x4C); + } + else + { + opacity = __pProgress->GetBarColor().GetAlpha(); + __pBarBgColorReplacementBitmap->SetAlphaConstant(opacity); + } + + r = DrawBitmap(*pCanvas, Rectangle(leftMargin, (bounds.height - height) / 2, (bounds.width - (2 * leftMargin)), height), __pBarBgColorReplacementBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawBitmap(*pCanvas, Rectangle(leftMargin, (bounds.height - height) / 2, (bounds.width - (2 * leftMargin)), height), __pBarBgResourceEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (width > 0) + { + if (__pProgress->GetBarColor() != __currentBarColor) + { + pReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pProgress->GetBarColor()); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to get replacement color.", GetErrorMessage(r)); + delete __pBarColorReplacementBitmap; + __pBarColorReplacementBitmap = null; + + __pBarColorReplacementBitmap = pReplacementBitmap; + __currentBarColor = __pProgress->GetBarColor(); + } + if (__pProgress->IsEnabled() == false) // disabled + { + __pBarColorReplacementBitmap->SetAlphaConstant(0x4C); + } + else + { + opacity = __pProgress->GetBarColor().GetAlpha(); + __pBarColorReplacementBitmap->SetAlphaConstant(opacity); + } + + r = DrawBitmap(*pCanvas, Rectangle((leftMargin + offset), (bounds.height - height) / 2, width, height), __pBarColorReplacementBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawBitmap(*pCanvas, Rectangle((leftMargin + offset), (bounds.height - height) / 2, width, height), __pBarResourceEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + } + + delete pCanvas; + pCanvas = null; + + return r; + +CATCH: + + delete pCanvas; + pCanvas = null; + + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicActionEvent.cpp b/src/ui/controls/FUiCtrl_PublicActionEvent.cpp new file mode 100644 index 0000000..62f6f98 --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicActionEvent.cpp @@ -0,0 +1,166 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicActionEvent.cpp +* @brief This is the implementation for the _PublicActionEvent class. +*/ + +#include +#include +#include +#include +#include "FUiCtrl_PublicActionEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _PublicActionEventArg + * @brief This class is used as the argument to action event listener. + * + * This class is used as the argument to action event listener. When an action event is generated + * (such as when a button is pressed) the ActionEvent calls ActionEventListener's OnActionPerformed + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the action ID. + */ +class _OSP_EXPORT_ _PublicActionEventArg + : public IEventArg + , public Object +{ +public: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Object instance which contains this instance. + * @param[in] actionId Action Id. + */ + _PublicActionEventArg(int actionId); + + /** + * This is the class destructor. + * + */ + virtual ~_PublicActionEventArg(void); + +public: + /** + * This method returns the actionId which the event initially occurred. + * + * @return See the comment above. + */ + int GetActionId(void) const; + +private: + /** + * Action Id. + */ + int __actionId; +}; // _PublicActionEventArg + +_PublicActionEventArg::_PublicActionEventArg(int actionId) + : __actionId(actionId) +{ + // nothing +} + +_PublicActionEventArg::~_PublicActionEventArg(void) +{ + // nothing +} + +int +_PublicActionEventArg::GetActionId(void) const +{ + return __actionId; +} + +_PublicActionEvent::_PublicActionEvent(const Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + SetLastResult(E_SUCCESS); + } +} + +_PublicActionEvent::~_PublicActionEvent(void) +{ + // nothing +} + +_PublicActionEvent* +_PublicActionEvent::CreateInstanceN(const Control& source) +{ + _PublicActionEvent* pPublicActionEvent = new (std::nothrow) _PublicActionEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicActionEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pPublicActionEvent; + +CATCH: + delete pPublicActionEvent; + return null; +} + +const Control* +_PublicActionEvent::GetSource(void) const +{ + return __pSource; +} + +void +_PublicActionEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to IActionEventListener + IActionEventListener* pActionListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pActionListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given.\n"); + + // cast to _PublicActionEventArg + const _PublicActionEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + // call cursor change event listener method + pActionListener->OnActionPerformed(*__pSource, pArg->GetActionId()); + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_PublicActionEvent::CreateActionEventArgN(int actionId) +{ + _PublicActionEventArg* pEventArg = new (std::nothrow) _PublicActionEventArg(actionId); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicAdjustmentEvent.cpp b/src/ui/controls/FUiCtrl_PublicAdjustmentEvent.cpp new file mode 100644 index 0000000..8496a9b --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicAdjustmentEvent.cpp @@ -0,0 +1,142 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicAdjustmentEvent.cpp + * @brief This is the implementation for the _AdjustmentEvent class. + * + * This file contains the implementation of _AdjustmentEvent class. @n + */ + +#include +#include +#include +#include +#include "FUiCtrl_PublicAdjustmentEvent.h" + +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _OSP_EXPORT_ _PublicAdjustmentEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + _PublicAdjustmentEventArg(int adjustment); + virtual ~_PublicAdjustmentEventArg(void); + +// Access +public: + int GetAdjustment(void) const; + +// Attribute +private: + int __adjustment; + +}; // _PublicAdjustmentEventArg + +_PublicAdjustmentEventArg::_PublicAdjustmentEventArg(int adjustment) + : __adjustment(adjustment) +{ +} + +_PublicAdjustmentEventArg::~_PublicAdjustmentEventArg(void) +{ +} + +int +_PublicAdjustmentEventArg::GetAdjustment(void) const +{ + return __adjustment; +} + + +_PublicAdjustmentEvent::_PublicAdjustmentEvent(const Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_PublicAdjustmentEvent::~_PublicAdjustmentEvent(void) +{ +} + +_PublicAdjustmentEvent* +_PublicAdjustmentEvent::CreateInstanceN(const Control& source) +{ + _PublicAdjustmentEvent* pPublicAdjustmentEvent = new (std::nothrow) _PublicAdjustmentEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicAdjustmentEvent != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pPublicAdjustmentEvent; + +CATCH: + delete pPublicAdjustmentEvent; + pPublicAdjustmentEvent = null; + + return null; +} + +const Control* +_PublicAdjustmentEvent::GetSource(void) const +{ + return __pSource; +} + +void +_PublicAdjustmentEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to IAdjustmentEventListener + IAdjustmentEventListener* pAdjustmentListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pAdjustmentListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given."); + + // cast to _PublicAdjustmentEventArg + const _PublicAdjustmentEventArg* pAdjustmentEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pAdjustmentEventArg != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid Event Argument was given."); + + // call cursor change event listener method + pAdjustmentListener->OnAdjustmentValueChanged(*__pSource, pAdjustmentEventArg->GetAdjustment()); + SetLastResult(E_SUCCESS); + return; +} + +IEventArg* +_PublicAdjustmentEvent::CreateAdjustmentEventArgN(int adjustment) +{ + _PublicAdjustmentEventArg* pEventArg = new (std::nothrow) _PublicAdjustmentEventArg(adjustment); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicAnimationEvent.cpp b/src/ui/controls/FUiCtrl_PublicAnimationEvent.cpp new file mode 100644 index 0000000..ca1a2f3 --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicAnimationEvent.cpp @@ -0,0 +1,116 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicAnimationEvent.cpp +* @brief This is the implementation for the AnimationEvent class. +*/ + +#include +#include +#include +#include +#include "FUiCtrl_PublicAnimationEvent.h" + +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _PublicAnimationEventArg + : public IEventArg + , public Object +{ +public: + _PublicAnimationEventArg(void); + virtual ~_PublicAnimationEventArg(void); +}; // _PublicAnimationEventArg + +_PublicAnimationEventArg::_PublicAnimationEventArg(void) +{ +} + +_PublicAnimationEventArg::~_PublicAnimationEventArg(void) +{ +} + + +_PublicAnimationEvent::_PublicAnimationEvent(const Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_PublicAnimationEvent::~_PublicAnimationEvent(void) +{ +} + +_PublicAnimationEvent* +_PublicAnimationEvent::CreateInstanceN(const Control& source) +{ + _PublicAnimationEvent* pPublicAnimationEvent = new (std::nothrow) _PublicAnimationEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicAnimationEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pPublicAnimationEvent; + +CATCH: + delete pPublicAnimationEvent; + pPublicAnimationEvent = null; + + return null; +} + +const Control* +_PublicAnimationEvent::GetSource(void) const +{ + return __pSource; +} + +void +_PublicAnimationEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + IAnimationEventListener* pAnimationListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pAnimationListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid listener was given."); + + pAnimationListener->OnAnimationStopped(*__pSource); + + SetLastResult(E_SUCCESS); + return; +} + +IEventArg* +_PublicAnimationEvent::CreateAnimationEventArgN(void) +{ + _PublicAnimationEventArg* pEventArg = new (std::nothrow) _PublicAnimationEventArg(); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicClipboardPopupEvent.cpp b/src/ui/controls/FUiCtrl_PublicClipboardPopupEvent.cpp new file mode 100644 index 0000000..ecf708c --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicClipboardPopupEvent.cpp @@ -0,0 +1,128 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicClipboardPopupEvent.cpp + * @brief This is the implementation for the _PublicClipboardPopupEvent class. + * @version 1.0 + */ +#include +#include +#include +#include +#include "FUiCtrl_PublicClipboardPopupEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _PublicClipboardPopupEventArg + * @brief This class is used as the argument to clipboard-popup event listener. + * + */ +class _PublicClipboardPopupEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +public: + _PublicClipboardPopupEventArg(const ClipboardItem* pClipboardItem); + + virtual ~_PublicClipboardPopupEventArg(void); + + const ClipboardItem* GetClipboardItem(void) const; + +private: + _PublicClipboardPopupEventArg(const _PublicClipboardPopupEventArg& rhs); + _PublicClipboardPopupEventArg& operator =(const _PublicClipboardPopupEventArg& rhs); + +private: + ClipboardItem* __pClipboardItem; +}; // _PublicClipboardPopupEventArg + +_PublicClipboardPopupEventArg::_PublicClipboardPopupEventArg(const ClipboardItem* pClipboardItem) + : __pClipboardItem(const_cast (pClipboardItem)) +{ +} + +_PublicClipboardPopupEventArg::~_PublicClipboardPopupEventArg(void) +{ +} + +const ClipboardItem* +_PublicClipboardPopupEventArg::GetClipboardItem(void) const +{ + return __pClipboardItem; +} + +_PublicClipboardPopupEvent* +_PublicClipboardPopupEvent::CreateInstanceN(void) +{ + _PublicClipboardPopupEvent* pPublicClipboardPopupEvent = new (std::nothrow) _PublicClipboardPopupEvent(); + SysTryReturn(NID_UI_CTRL, pPublicClipboardPopupEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + + return pPublicClipboardPopupEvent; + +CATCH: + delete pPublicClipboardPopupEvent; + return null; +} + +IEventArg* +_PublicClipboardPopupEvent::CreateClipboardPopupEventArgN(const ClipboardItem* pClipboardItem) +{ + _PublicClipboardPopupEventArg* pEventArg = new (std::nothrow) _PublicClipboardPopupEventArg(pClipboardItem); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + SetLastResult(E_SUCCESS); + + return pEventArg; +} + +_PublicClipboardPopupEvent::~_PublicClipboardPopupEvent(void) +{ +} + +void +_PublicClipboardPopupEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + IClipboardPopupEventListener* pEventListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pEventListener, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + + const _PublicClipboardPopupEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid."); + + pEventListener->OnClipboardPopupClosed(pArg->GetClipboardItem()); + + SetLastResult(E_SUCCESS); +} + +_PublicClipboardPopupEvent::_PublicClipboardPopupEvent(void) +{ + result r = _Event::Initialize(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicColorChangeEvent.cpp b/src/ui/controls/FUiCtrl_PublicColorChangeEvent.cpp new file mode 100644 index 0000000..c826f7d --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicColorChangeEvent.cpp @@ -0,0 +1,130 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicColorChangeEvent.cpp + * @brief This is the implementation for the _PublicColorChangeEvent class. + * + * This file contains the implementation of _PublicColorChangeEvent class. @n + */ + +#include +#include +#include +#include +#include +#include "FUiCtrl_PublicColorChangeEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _OSP_EXPORT_ _PublicColorChangeEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +public: + _PublicColorChangeEventArg(const Color& color) + : __color(color) + { + } + + virtual ~_PublicColorChangeEventArg(void) + { + } + + const Tizen::Graphics::Color GetColor(void) const + { + return __color; + } + +private: + Color __color; +}; // _PublicColorChangeEventArg + +_PublicColorChangeEvent::_PublicColorChangeEvent(const Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_PublicColorChangeEvent::~_PublicColorChangeEvent(void) +{ +} + +const Control* +_PublicColorChangeEvent::GetSource(void) const +{ + return (__pSource); +} + +void +_PublicColorChangeEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + IColorChangeEventListener* pColorChangeListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, (pColorChangeListener != null), E_INVALID_ARG, + "[E_INVALID_ARG] The event argument is invalid type.\n."); + + const _PublicColorChangeEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, (pArg != null), E_INVALID_ARG, + "[E_INVALID_ARG] The event argument is invalid type.\n."); + + pColorChangeListener->OnColorChanged(*__pSource, Color(pArg->GetColor())); + + return; +} + +_PublicColorChangeEvent* +_PublicColorChangeEvent::CreateInstanceN(const Control& source) +{ + _PublicColorChangeEvent* pCoreColorChangeEvent = new (std::nothrow) _PublicColorChangeEvent(source); + SysTryReturn(NID_UI_CTRL, (pCoreColorChangeEvent != null), null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pCoreColorChangeEvent; + +CATCH: + delete pCoreColorChangeEvent; + return null; + +} + +IEventArg* +_PublicColorChangeEvent::CreateColorChangeEventArgN(const Color& color) +{ + _PublicColorChangeEventArg* pEventArg = new (std::nothrow) _PublicColorChangeEventArg(color); + SysTryReturn(NID_UI_CTRL, (pEventArg != null), null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicDateTimeChangeEvent.cpp b/src/ui/controls/FUiCtrl_PublicDateTimeChangeEvent.cpp new file mode 100644 index 0000000..13399f4 --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicDateTimeChangeEvent.cpp @@ -0,0 +1,214 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicDateTimeChangeEvent.cpp + * @brief This is the implementation file for the _PublicDateTimeChangeEvent and _PublicDateTimeChangeEventArg classes. + */ + +#include +#include +#include +#include +#include +#include +#include "FUiCtrl_PublicDateTimeChangeEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::System; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_PublicDateTimeChangeEventArg::_PublicDateTimeChangeEventArg(DateTimePublicChangeStatus status) + : __status(status) + , __year(1) + , __month(1) + , __day(1) + , __hour(0) + , __minute(0) +{ + SystemTime::GetCurrentTime(WALL_TIME, __dateTime1); +} + +_PublicDateTimeChangeEventArg::~_PublicDateTimeChangeEventArg(void) +{ + // Nothing. +} + +void +_PublicDateTimeChangeEventArg::SetDateTime(const Tizen::Base::DateTime& dateTime) +{ + __dateTime1 = dateTime; + + return; +} + +int +_PublicDateTimeChangeEventArg::GetYear(void) const +{ + return __year; +} + +int +_PublicDateTimeChangeEventArg::GetMonth(void) const +{ + return __month; +} + +int +_PublicDateTimeChangeEventArg::GetDay(void) const +{ + return __day; +} + +int +_PublicDateTimeChangeEventArg::GetHour(void) const +{ + return __hour; +} + +int +_PublicDateTimeChangeEventArg::GetMinute(void) const +{ + return __minute; +} + +Tizen::Base::DateTime +_PublicDateTimeChangeEventArg::GetDateTime(void) const +{ + return __dateTime1; +} + +DateTimePublicChangeStatus +_PublicDateTimeChangeEventArg::GetStatus(void) const +{ + return __status; +} + +void +_PublicDateTimeChangeEventArg::SetTime(int hour, int minute) +{ + __hour = hour; + __minute = minute; + + return; +} + +void +_PublicDateTimeChangeEventArg::SetDate(int year, int month, int day) +{ + __year = year; + __month = month; + __day = day; + + return; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicDateTimeChangeEventArg class end + +_PublicDateTimeChangeEvent::_PublicDateTimeChangeEvent(const Tizen::Ui::Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + if (r == E_SUCCESS) + { + __pSource = const_cast(&source); + } +} + +_PublicDateTimeChangeEvent::~_PublicDateTimeChangeEvent(void) +{ + // Nothing. +} + +void +_PublicDateTimeChangeEvent::FireImpl(IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg) +{ + const _PublicDateTimeChangeEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, (pArg != null), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The instance of _PublicDateTimeChangeEventArg is null."); + + DateTimePublicChangeStatus status = pArg->GetStatus(); + if ((status == DATETIME_PUBLIC_CHANGE_SAVED) || (status == DATETIME_PUBLIC_CHANGE_CANCELED)) + { + IDateTimeChangeEventListener* pChangeEventListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, (pChangeEventListener != null), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The instance of IDateTimeChangeEventListener is null."); + + if (status == DATETIME_PUBLIC_CHANGE_SAVED) + { + pChangeEventListener->OnDateTimeChanged(*__pSource, pArg->GetYear(), pArg->GetMonth(), pArg->GetDay(), + pArg->GetHour(), pArg->GetMinute()); + } + else + { + pChangeEventListener->OnDateTimeChangeCanceled(*__pSource); + } + } + else if ((status == DATE_PUBLIC_CHANGE_SAVED) || (status == DATE_PUBLIC_CHANGE_CANCELED)) + { + IDateChangeEventListener* pChangeEventListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, (pChangeEventListener != null), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The instance of IDateChangeEventListener is null."); + + if (status == DATE_PUBLIC_CHANGE_SAVED) + { + pChangeEventListener->OnDateChanged(*__pSource, pArg->GetYear(), pArg->GetMonth(), pArg->GetDay()); + } + else + { + pChangeEventListener->OnDateChangeCanceled(*__pSource); + } + } + else if ((status == TIME_PUBLIC_CHANGE_SAVED) || (status == TIME_PUBLIC_CHANGE_CANCELED)) + { + ITimeChangeEventListener* pChangeEventListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, (pChangeEventListener != null), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The instance of ITimeChangeEventListener is null."); + + if (status == TIME_PUBLIC_CHANGE_SAVED) + { + pChangeEventListener->OnTimeChanged(*__pSource, pArg->GetHour(), pArg->GetMinute()); + } + else + { + pChangeEventListener->OnTimeChangeCanceled(*__pSource); + } + } + SetLastResult(E_SUCCESS); + return; +} + +const Tizen::Ui::Control* +_PublicDateTimeChangeEvent::GetSource(void) const +{ + return __pSource; +} + +Tizen::Base::Runtime::IEventArg* +_PublicDateTimeChangeEvent::CreateDateTimeChangeEventArgN(DateTimePublicChangeStatus status) +{ + _PublicDateTimeChangeEventArg* pEventArg = new (std::nothrow) _PublicDateTimeChangeEventArg(status); + SysTryReturn(NID_UI_CTRL, (pEventArg != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicExpandableEditAreaEvent.cpp b/src/ui/controls/FUiCtrl_PublicExpandableEditAreaEvent.cpp new file mode 100644 index 0000000..1611db4 --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicExpandableEditAreaEvent.cpp @@ -0,0 +1,203 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicExpandableEditAreaEvent.cpp +* @brief This is the implementation for the _PublicExpandableEditAreaEvent class. +* +* This file contains implementation of _PublicExpandableEditAreaEvent class. +*/ + +// includes +#include +#include +#include +#include +#include "FUiCtrl_PublicExpandableEditAreaEvent.h" + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen {namespace Ui {namespace Controls +{ +/** + * @class _PublicExpandableEditAreaEventArg + * @brief This class is used as the argument to action event listener. + * + * This class is used as the argument to action event listener. When an action event is generated + * (such as when a button is pressed) the ExpandableEditAreaEvent calls ExpandableEditAreaEventListener's OnActionPerformed + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the action ID. + */ +class _OSP_EXPORT_ _PublicExpandableEditAreaEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Object instance which contains this instance. + * @param[in] actionId Action Id. + */ + _PublicExpandableEditAreaEventArg(ExpandableEditAreaEventStatus status, int selectedTokenIndex = -1); + + /** + * This is the class destructor. + * + */ + virtual ~_PublicExpandableEditAreaEventArg(void); + + +// Access +public: + /** + * This method returns the ExpandableEditAreaEventStatus which the event initially occurred. + * + * @return See the comment above. + */ + ExpandableEditAreaEventStatus GetStatus(void) const; + + int GetSelectedTokenIndex(void) const; + + +// Attribute +private: + /** + * ExpandableEditAreaEventStatus. + */ + ExpandableEditAreaEventStatus __status; + + int __selecteTokenIndex; +}; // _PublicExpandableEditAreaEventArg + +_PublicExpandableEditAreaEventArg::_PublicExpandableEditAreaEventArg(ExpandableEditAreaEventStatus status, int selectedTokenIndex) + : __status(status) + , __selecteTokenIndex(selectedTokenIndex) +{ + // nothing +} + +_PublicExpandableEditAreaEventArg::~_PublicExpandableEditAreaEventArg(void) +{ + // nothing +} + +//////////////////////////////////////////////////////////////////////////////// +/// _ExpandableEditAreaEventArg class Access +ExpandableEditAreaEventStatus +_PublicExpandableEditAreaEventArg::GetStatus(void) const +{ + return __status; +} + +int +_PublicExpandableEditAreaEventArg::GetSelectedTokenIndex(void) const +{ + return __selecteTokenIndex; +} + + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicExpandableEditAreaEvent class Lifecycle +_PublicExpandableEditAreaEvent::_PublicExpandableEditAreaEvent(const Tizen::Ui::Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_PublicExpandableEditAreaEvent::~_PublicExpandableEditAreaEvent(void) +{ + // nothing +} + +_PublicExpandableEditAreaEvent* +_PublicExpandableEditAreaEvent::CreateInstanceN(const Tizen::Ui::Control& source) +{ + _PublicExpandableEditAreaEvent* pPublicExpandableEditAreaEvent = new (std::nothrow) _PublicExpandableEditAreaEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicExpandableEditAreaEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pPublicExpandableEditAreaEvent; + +CATCH: + delete pPublicExpandableEditAreaEvent; + return null; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _WindowEvent class Accessor + +const Tizen::Ui::Control* +_PublicExpandableEditAreaEvent::GetSource(void) const +{ + return __pSource; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicExpandableEditAreaEvent class Operation + +void +_PublicExpandableEditAreaEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg) +{ + // cast to IExpandableEditAreaEventListener + IExpandableEditAreaEventListener* pExpandableEditAreaEventListener = + dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pExpandableEditAreaEventListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given.\n"); + + // cast to _PublicExpandableEditAreaEventArg + const _PublicExpandableEditAreaEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + // call cursor change event listener method + ExpandableEditAreaEventStatus status = pArg->GetStatus(); + if (status == EXPANDABLE_EDITAREA_EVENT_ADDED) + { + pExpandableEditAreaEventListener->OnExpandableEditAreaLineAdded(*dynamic_cast (const_cast (__pSource)), 0); + } + else if (status == EXPANDABLE_EDITAREA_EVENT_REMOVED) + { + pExpandableEditAreaEventListener->OnExpandableEditAreaLineRemoved(*dynamic_cast (const_cast (__pSource)), 0); + } + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_PublicExpandableEditAreaEvent::CreateExpandableEditAreaEventArgN(ExpandableEditAreaEventStatus status, int index) +{ + _PublicExpandableEditAreaEventArg* pEventArg = new (std::nothrow) _PublicExpandableEditAreaEventArg(status, index); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicFrameEvent.cpp b/src/ui/controls/FUiCtrl_PublicFrameEvent.cpp new file mode 100644 index 0000000..d62649b --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicFrameEvent.cpp @@ -0,0 +1,188 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicFrameEvent.cpp + * @brief This is the implementation for the _PublicFrameEvent class. + * @version 1.0 + */ + +#include +#include +#include +#include +#include +#include "FUiCtrl_PublicFrameEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _PublicFrameEventArg + * @brief This class is used as an argument of event listener's method. + * + * This class is used as an argument of event listener's method. When frame event is generated, + * the @c _PublicFrameEvent instance calls WindowEventListener's method with instance of this class as an argument. + */ +class _PublicFrameEventArg + : public Tizen::Base::Object + , public Tizen::Base::Runtime::IEventArg +{ +public: +// Lifecycle + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Frame instance which contains this instance. + * @param[in] frameState The frame event type. + */ + _PublicFrameEventArg(const Frame& source, int frameState); + + /** + * This is the class destructor. + * + */ + virtual ~_PublicFrameEventArg(void); + +// Accessor + /** + * This method returns the Window object which the event initially occurred. + * + * @return See the comment above. + * + */ + const Frame* GetSource(void) const; + + /** + * This method returns the event type of frame event. + * + * @return See the comment above. + */ + int GetType(void) const; + +private: +// Attribute + Frame* __pSource; + int __frameState; +}; // _PublicFrameEventArg + +_PublicFrameEventArg::_PublicFrameEventArg(const Frame& source, int frameState) + : __pSource(const_cast (&source)) + , __frameState(frameState) +{ +} + +_PublicFrameEventArg::~_PublicFrameEventArg(void) +{ +} + +const Frame* +_PublicFrameEventArg::GetSource(void) const +{ + return __pSource; +} + +int +_PublicFrameEventArg::GetType(void) const +{ + return __frameState; +} + +_PublicFrameEvent* +_PublicFrameEvent::CreateInstanceN(const Frame& source) +{ + _PublicFrameEvent* pPublicFrameEvent = new (std::nothrow) _PublicFrameEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicFrameEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + SetLastResult(E_SUCCESS); + + return pPublicFrameEvent; + +CATCH: + delete pPublicFrameEvent; + return null; +} + +IEventArg* +_PublicFrameEvent::CreateFrameEventArgN(const Frame& source, int frameState) +{ + _PublicFrameEventArg* pEventArg = new (std::nothrow) _PublicFrameEventArg(source, frameState); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + SetLastResult(E_SUCCESS); + + return pEventArg; +} + +_PublicFrameEvent::~_PublicFrameEvent(void) +{ +} + +const Frame* +_PublicFrameEvent::GetSource(void) const +{ + return __pSource; +} + +void +_PublicFrameEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + IFrameEventListener* pFrameListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pFrameListener, E_INVALID_ARG, "[E_INVALID_ARG] The invalid listener was given."); + + const _PublicFrameEventArg* pArg = static_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_INVALID_ARG, "[E_INVALID_ARG] The invalid event argument was given."); + + int type = pArg->GetType(); + switch (type) + { + case FRAME_STATE_TERMINATING : + pFrameListener->OnFrameTerminating(*pArg->GetSource()); + break; + case FRAME_STATE_ACTIVATED : + pFrameListener->OnFrameActivated(*pArg->GetSource()); + break; + case FRAME_STATE_DEACTIVATED : + pFrameListener->OnFrameDeactivated(*pArg->GetSource()); + break; + default : + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] The invalid event argument was given."); + break; + } + + SetLastResult(E_SUCCESS); + + return; +} + +_PublicFrameEvent::_PublicFrameEvent(const Frame& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSource = &source; + ClearLastResult(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicKeypadEvent.cpp b/src/ui/controls/FUiCtrl_PublicKeypadEvent.cpp new file mode 100644 index 0000000..5de4e1f --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicKeypadEvent.cpp @@ -0,0 +1,221 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicKeypadEvent.cpp +* @brief This is the implementation for the _PublicKeypadEvent class. +* +* This file contains implementation of _PublicKeypadEvent class. +*/ + +// Includes +#include +#include +#include +#include "FUiCtrl_PublicKeypadEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen {namespace Ui {namespace Controls +{ + +/** + * @class + * @brief This class is used as the argument to change event listener. + * + * This class is used as the argument to change event listener. When an change event is generated + * (such as when a button is pressed) the TextSelectionEvent calls TextSelectionEventListener's OnTextd + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the change ID. + */ +class _OSP_EXPORT_ _PublicKeypadEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Object instance which contains this instance. + */ + _PublicKeypadEventArg(const Control& source, KeypadAction actionId, KeypadEventStatus status); + + /** + * This is the class destructor. + * + */ + virtual ~_PublicKeypadEventArg(void); + + +// Access +public: + /** + * This method returns the object which the event initially occurred. + * + * @return The object which the event initially occurred. + */ + const Control* GetSource(void) const; + + KeypadAction GetKeypadActionId() const; + + KeypadEventStatus GetStatus() const; + +// Attribute +private: + /** + * Event source. + */ + const Control* __pSource; + + /** + * Event source. + */ + KeypadAction __actionId; + + /** + * status. + */ + KeypadEventStatus __status; +}; // _PublicKeypadEventArg + +//////////////////////////////////////////////////////////////////////////////// +/// __TextSelectionEventArg class Lifecycle + +_PublicKeypadEventArg::_PublicKeypadEventArg(const Control& source, KeypadAction actionId, Controls::KeypadEventStatus status) +{ + __pSource = &source; + __actionId = actionId; + __status = status; +} + +_PublicKeypadEventArg::~_PublicKeypadEventArg(void) +{ + // Nothing. +} + +const Control* +_PublicKeypadEventArg::GetSource(void) const +{ + return __pSource; +} + +KeypadAction +_PublicKeypadEventArg::GetKeypadActionId(void) const +{ + return __actionId; +} + +KeypadEventStatus +_PublicKeypadEventArg::GetStatus() const +{ + return __status; +} + +//////////////////////////////////////////////////////////////////////////////// +/// __TextSelectionEvent class Lifecycle +_PublicKeypadEvent::_PublicKeypadEvent(const Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + __pSource = &source; +} + +_PublicKeypadEvent::~_PublicKeypadEvent(void) +{ + // Nothing. +} + +_PublicKeypadEvent* +_PublicKeypadEvent::CreateInstanceN(const Control& source) +{ + _PublicKeypadEvent* pPublicKeypadEvent = new (std::nothrow) _PublicKeypadEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicKeypadEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pPublicKeypadEvent; +} + +const Control* +_PublicKeypadEvent::GetSource(void) const +{ + return __pSource; +} + +// Operations + +void +_PublicKeypadEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + IKeypadEventListener* pKeypadEventListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given.\n"); + + const _PublicKeypadEventArg* pKeypadEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pKeypadEventArg != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + Control* tempSource = null; + tempSource = const_cast (pKeypadEventArg->GetSource()); + KeypadAction keypadAction = pKeypadEventArg->GetKeypadActionId(); + + Controls::KeypadEventStatus status = pKeypadEventArg->GetStatus(); + switch (status) + { + case KEYPAD_EVENT_STATUS_CREATED: + pKeypadEventListener->OnKeypadWillOpen(*tempSource); + break; + + case KEYPAD_EVENT_STATUS_OPEN: + pKeypadEventListener->OnKeypadOpened(*tempSource); + break; + + case KEYPAD_EVENT_STATUS_CLOSE: + pKeypadEventListener->OnKeypadClosed(*tempSource); + break; + + case KEYPAD_EVENT_STATUS_BOUNDS_CHANGED: + pKeypadEventListener->OnKeypadBoundsChanged(*tempSource); + break; + + case KEYPAD_EVENT_STATUS_ENTERACTION: + pKeypadEventListener->OnKeypadActionPerformed(*tempSource, keypadAction); + break; + + default: + break; + } + + SetLastResult(E_SUCCESS); + + return; +} + +Tizen::Base::Runtime::IEventArg* +_PublicKeypadEvent::CreateKeypadEventArgN(const Tizen::Ui::Control& source, Tizen::Ui::KeypadAction actionId, + KeypadEventStatus status) +{ + _PublicKeypadEventArg* pEventArg = new (std::nothrow) _PublicKeypadEventArg(source, actionId, status); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicLanguageEvent.cpp b/src/ui/controls/FUiCtrl_PublicLanguageEvent.cpp new file mode 100644 index 0000000..1f5591d --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicLanguageEvent.cpp @@ -0,0 +1,200 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicLanguageEvent.cpp + * @brief This is the implementation for the _LanguageEvent class. + * @version 1.0 + */ + +// includes +#include +#include +#include +#include +#include "FUiCtrl_PublicLanguageEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Locales; + +namespace Tizen { namespace Ui { namespace Controls +{ +/** +* @class _LanguageEventArg +* @brief This class is used as an argument of event listener's method. +* +* This class is used as an argument of event listener's method. When language event is generated, +* the @c languageEvent instance calls @c languageEventListener's method with instance of this class as an argument. +* +*/ +class _OSP_EXPORT_ _PublicLanguageEventArg + : public Object + , public IEventArg +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Window instance which contains this instance. + * @param[in] prevLanguageCode the key code of the event initially occurs. + * @param[in] currentLanguageCode the key state of the event initially occurs. + */ + _PublicLanguageEventArg(const Control& source, LanguageCode prevLanguageCode, LanguageCode currentLanguageCode); + + + /** + * This is the class destructor. + * + */ + virtual ~_PublicLanguageEventArg(void); + + +// Access +public: + /** + * This method returns the object which the event initially occurs. + * + * @return The object which the event initially occurs. + */ + const Control* GetSource(void) const; + + + /** + * This method returns a previous language code. + * + * @return See the comment above. + * + */ + LanguageCode GetPreviousLanguageCode(void) const; + + /** + * This method returns a current language code. + * + * @return See the comment above. + * + */ + LanguageCode GetCurrentLanguageCode(void) const; + +// Attribute +private: + const Control* __pSource; + LanguageCode __prevLanguageCode; + LanguageCode __currentLanguageCode; +}; // _PublicLanguageEventArg + +_PublicLanguageEventArg::_PublicLanguageEventArg(const Control& source, LanguageCode prevLanguageCode, LanguageCode currentLanguageCode) + : __pSource(&source) + , __prevLanguageCode(prevLanguageCode) + , __currentLanguageCode(currentLanguageCode) +{ + +} + +_PublicLanguageEventArg::~_PublicLanguageEventArg(void) +{ + // Nothing. +} + +const Control* +_PublicLanguageEventArg::GetSource(void) const +{ + return __pSource; +} + +LanguageCode +_PublicLanguageEventArg::GetCurrentLanguageCode(void) const +{ + return __currentLanguageCode; +} + +LanguageCode +_PublicLanguageEventArg::GetPreviousLanguageCode(void) const +{ + return __prevLanguageCode; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _FocusEvent class Lifecycle + +_PublicLanguageEvent::_PublicLanguageEvent(const Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + __pSource = &source; +} + + +_PublicLanguageEvent::~_PublicLanguageEvent() +{ + // NOTHING +} + +_PublicLanguageEvent* +_PublicLanguageEvent::CreateInstanceN(const Control& source) +{ + _PublicLanguageEvent* pPublicLanguageEvent = new (std::nothrow) _PublicLanguageEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicLanguageEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pPublicLanguageEvent; +} + +const Control* +_PublicLanguageEvent::GetSource(void) const +{ + return __pSource; +} + +void +_PublicLanguageEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + ILanguageEventListener* pLanguageEventListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pLanguageEventListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given.\n"); + + const _PublicLanguageEventArg* pLanguageEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pLanguageEventArg != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + Control* tempSource = null; + tempSource = const_cast (pLanguageEventArg->GetSource()); + + LanguageCode currentLanguageCode = pLanguageEventArg->GetCurrentLanguageCode(); + LanguageCode previousLanguageCode = pLanguageEventArg->GetPreviousLanguageCode(); + + pLanguageEventListener->OnLanguageChanged(*tempSource, currentLanguageCode, previousLanguageCode); + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_PublicLanguageEvent::CreateLanguageEventArgN(const Control& source, LanguageCode prevLanguageCode, + LanguageCode currentLanguageCode) +{ + _PublicLanguageEventArg* pLanguageEventArg = new (std::nothrow) _PublicLanguageEventArg(source, prevLanguageCode, + currentLanguageCode); + SysTryReturn(NID_UI_CTRL, pLanguageEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pLanguageEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicLinkEvent.cpp b/src/ui/controls/FUiCtrl_PublicLinkEvent.cpp new file mode 100644 index 0000000..1dcf91b --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicLinkEvent.cpp @@ -0,0 +1,201 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicLinkEvent.cpp +* @brief This is the implementation for the _PublicLinkEvent class. +* @version 1.0 +*/ + +// includes +#include +#include +#include +#include "FUiCtrl_PublicLinkEvent.h" + + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _PublicLinkEventArg + * @brief This class is used as the argument to change event listener. + * + * This class is used as the argument to change event listener. When an change event is generated + * (such as when a button is pressed) the TextSelectionEvent calls TextSelectionEventListener's OnTextd + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the change ID. + */ +class _OSP_EXPORT_ _PublicLinkEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _PublicLinkEventArg(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link); + + /** + * This is the class destructor. + * + */ + virtual ~_PublicLinkEventArg(void); + + /** + * Gets the text. + * + * @return The text. + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets the link type. + * + * @return The link type. + */ + Tizen::Base::Utility::LinkType GetLinkType(void) const; + + /** + * Gets the link text. + * + * @return The link text. + */ + Tizen::Base::String GetLinkText(void) const; + + +private: + /** + * The text. + */ + Tizen::Base::String __text; + + /** + * The linktype. + */ + Tizen::Base::Utility::LinkType __linkType; + + /** + * The link text. + */ + Tizen::Base::String __linkText; +}; // _PublicLinkEventArg + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicLinkEventArg class Lifecycle + +_PublicLinkEventArg::_PublicLinkEventArg(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link) + : __text(text) + , __linkType(linkType) + , __linkText(link) +{ + // Nothing. +} + +_PublicLinkEventArg::~_PublicLinkEventArg(void) +{ + // Nothing. +} + +Tizen::Base::String +_PublicLinkEventArg::GetText(void) const +{ + return __text; +} + +Tizen::Base::Utility::LinkType +_PublicLinkEventArg::GetLinkType(void) const +{ + return __linkType; +} + +Tizen::Base::String +_PublicLinkEventArg::GetLinkText(void) const +{ + return __linkText; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicLinkEvent class Lifecycle +_PublicLinkEvent::_PublicLinkEvent(const Tizen::Ui::Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // Set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_PublicLinkEvent::~_PublicLinkEvent(void) +{ + // Nothing. +} + +_PublicLinkEvent* +_PublicLinkEvent::CreateInstanceN(const Tizen::Ui::Control& source) +{ + _PublicLinkEvent* pPublicLinkEvent = new (std::nothrow) _PublicLinkEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicLinkEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pPublicLinkEvent; +} + +const Tizen::Ui::Control* +_PublicLinkEvent::GetSource(void) const +{ + return __pSource; +} + +void +_PublicLinkEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg) +{ + IUiLinkEventListener* pLinkEventListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pLinkEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n"); + + _PublicLinkEventArg* pLinkEventArg = dynamic_cast <_PublicLinkEventArg*>(const_cast (&arg)); + SysTryReturnVoidResult(NID_UI_CTRL, pLinkEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n"); + + const Tizen::Base::String text = pLinkEventArg->GetText(); + Tizen::Base::Utility::LinkType linkType = pLinkEventArg->GetLinkType(); + const Tizen::Base::String linkText = pLinkEventArg->GetLinkText(); + + pLinkEventListener->OnLinkClicked(const_cast (*__pSource), text, linkType, linkText); + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_PublicLinkEvent::CreateLinkEventArgN(Tizen::Base::String text, Tizen::Base::Utility::LinkType linkType, Tizen::Base::String link) +{ + _PublicLinkEventArg* pEventArg = new (std::nothrow) _PublicLinkEventArg(text, linkType, link); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicProgressPopupEvent.cpp b/src/ui/controls/FUiCtrl_PublicProgressPopupEvent.cpp new file mode 100644 index 0000000..de9e548 --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicProgressPopupEvent.cpp @@ -0,0 +1,131 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicProgressPopupEvent.cpp + * @brief This is the implementation for the _PublicProgressPopupEvent class. + */ + +#include +#include +#include +#include +#include "FUiCtrl_PublicProgressPopupEvent.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _PublicProgressPopupEventArg + * @brief This class is used as the argument to progresspopup event listener. + * + */ +class _OSP_EXPORT_ _PublicProgressPopupEventArg + : public Object + , public IEventArg +{ +public: + _PublicProgressPopupEventArg(void); + virtual ~_PublicProgressPopupEventArg(void); + +}; // _PublicProgressPopupEventArg + + +_PublicProgressPopupEventArg::_PublicProgressPopupEventArg(void) +{ + // empty statement +} + +_PublicProgressPopupEventArg::~_PublicProgressPopupEventArg(void) +{ + // empty statement +} + + + +_PublicProgressPopupEvent::_PublicProgressPopupEvent(const Tizen::Ui::Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + SetLastResult(E_SUCCESS); + } +} + +_PublicProgressPopupEvent::~_PublicProgressPopupEvent(void) +{ + // empty statement +} + +_PublicProgressPopupEvent* +_PublicProgressPopupEvent::CreateInstanceN(const Control& source) +{ + _PublicProgressPopupEvent* pPublicProgressPopupEvent = new (std::nothrow) _PublicProgressPopupEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicProgressPopupEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pPublicProgressPopupEvent; + +CATCH: + delete pPublicProgressPopupEvent; + return null; +} + +const Control* +_PublicProgressPopupEvent::GetSource(void) const +{ + return __pSource; +} + +void +_PublicProgressPopupEvent::FireImpl(IEventListener& pListener, const IEventArg& arg) +{ + // cast to IProgressPopupEventListener + IProgressPopupEventListener* pProgressPopupListener = dynamic_cast (&pListener); + SysTryReturnVoidResult(NID_UI_CTRL, pProgressPopupListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given."); + + // cast to _PublicProgressPopupEventArg +// const _PublicProgressPopupEventArg* pArg = dynamic_cast (&arg); +// SysTryReturn(NID_UI_CTRL, pArg != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given."); + + // call progresspopup event listener method + pProgressPopupListener->OnProgressPopupCanceled(); +} + +IEventArg* +_PublicProgressPopupEvent::CreateProgressPopupEventArgN(void) +{ + _PublicProgressPopupEventArg* pEventArg = new (std::nothrow) _PublicProgressPopupEventArg(); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicScrollPanelEvent.cpp b/src/ui/controls/FUiCtrl_PublicScrollPanelEvent.cpp new file mode 100644 index 0000000..bc844da --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicScrollPanelEvent.cpp @@ -0,0 +1,180 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicScrollPanelEvent.cpp +* @brief This is the implementation for the _PublicScrollPanelEvent class. +* @version 1.0 +*/ + +// includes +#include +#include +#include +#include +#include "FUiCtrl_PublicScrollPanelEvent.h" + + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _PublicScrollPanelEventArg + * @brief This class is used as the argument to change event listener. + * + * This class is used as the argument to change event listener. When an change event is generated + * (such as when a button is pressed) the ScrollPanelEvent calls ScrollPanelEventListener's OnTextd + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the change ID. + */ +class _OSP_EXPORT_ _PublicScrollPanelEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _PublicScrollPanelEventArg(ScrollPanelStatus status); + + /** + * This is the class destructor. + * + */ + virtual ~_PublicScrollPanelEventArg(void); + + +// Access +public: + ScrollPanelStatus GetStatus(void) const; + +// Attribute +private: + /** + * Status + */ + ScrollPanelStatus __status; +}; // _PublicScrollPanelEventArg + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicScrollPanelEventArg class Lifecycle + +_PublicScrollPanelEventArg::_PublicScrollPanelEventArg(ScrollPanelStatus status) + : __status(status) +{ + // Nothing +} + +_PublicScrollPanelEventArg::~_PublicScrollPanelEventArg(void) +{ + // Nothing. +} + +ScrollPanelStatus +_PublicScrollPanelEventArg::GetStatus(void) const +{ + return __status; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicScrollPanelEvent class Lifecycle +_PublicScrollPanelEvent::_PublicScrollPanelEvent(const Tizen::Ui::Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // Set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_PublicScrollPanelEvent::~_PublicScrollPanelEvent(void) +{ + // Nothing. +} + +_PublicScrollPanelEvent* +_PublicScrollPanelEvent::CreateInstanceN(const Tizen::Ui::Control& source) +{ + _PublicScrollPanelEvent* pPublicScrollPanelEvent = new (std::nothrow) _PublicScrollPanelEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicScrollPanelEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pPublicScrollPanelEvent; +} + +// Accessors + +const Tizen::Ui::Control* +_PublicScrollPanelEvent::GetSource(void) const +{ + return __pSource; +} + +// Operations + +void +_PublicScrollPanelEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg) +{ + IScrollPanelEventListener* pScrollPanelEventListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pScrollPanelEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n"); + + const _PublicScrollPanelEventArg* pScrollPanelEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pScrollPanelEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n"); + + switch (pScrollPanelEventArg->GetStatus()) + { + case OVERLAY_CONTROL_CREATED: + pScrollPanelEventListener->OnOverlayControlCreated(*GetSource()); + break; + + case OVERLAY_CONTROL_OPENED: + pScrollPanelEventListener->OnOverlayControlOpened(*GetSource()); + break; + + case OVERLAY_CONTROL_CLOSED: + pScrollPanelEventListener->OnOverlayControlClosed(*GetSource()); + break; + + case OTHER_CONTROL_SELECTED: + pScrollPanelEventListener->OnOtherControlSelected(*GetSource()); + break; + } + + SetLastResult(E_SUCCESS); + + return; + +} + +IEventArg* +_PublicScrollPanelEvent::CreateScrollPanelEventArgN(ScrollPanelStatus status) +{ + _PublicScrollPanelEventArg* pEventArg = new (std::nothrow) _PublicScrollPanelEventArg(status); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicSearchBarEvent.cpp b/src/ui/controls/FUiCtrl_PublicSearchBarEvent.cpp new file mode 100644 index 0000000..39bb3c0 --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicSearchBarEvent.cpp @@ -0,0 +1,190 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_PublicSearchBarEvent.cpp +* @brief This is the implementation for the PublicSearcBarEvent class. +* @version 1.0 +*/ + +#include +#include +#include +#include +#include "FUiCtrl_PublicSearchBarEvent.h" + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _PublicSearchBarEventArg + * @brief This class is used as the argument to searchbar event listener. + * + * This class is used as the argument to searchbar event listener. When an searchbar event is generated + * (such as when a searchbar is pressed) the SearchBarEvent calls SearchBarEventListener's OnSearchBarModeChanged + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the action ID. + */ +class _OSP_EXPORT_ _PublicSearchBarEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] status + */ + _PublicSearchBarEventArg(SearchBarEventStatus status); + + /** + * This is the class destructor. + * + */ + virtual ~_PublicSearchBarEventArg(void); + + +// Access +public: + /** + * This method returns the actionId which the event initially occurred. + * + * @return See the comment above. + */ + SearchBarEventStatus GetStatus(void) const; + + +// Attribute +private: + /** + * Event status. + */ + SearchBarEventStatus __status; +}; + +_PublicSearchBarEventArg::_PublicSearchBarEventArg(SearchBarEventStatus status) + : __status(status) +{ + // nothing +} + +_PublicSearchBarEventArg::~_PublicSearchBarEventArg(void) +{ + // nothing +} + +//////////////////////////////////////////////////////////////////////////////// +/// _SearchBarEventArg class Access +SearchBarEventStatus +_PublicSearchBarEventArg::GetStatus(void) const +{ + return __status; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicSearchBarEvent class Lifecycle +_PublicSearchBarEvent::_PublicSearchBarEvent(const SearchBar& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_PublicSearchBarEvent::~_PublicSearchBarEvent(void) +{ + // nothing +} + +_PublicSearchBarEvent* +_PublicSearchBarEvent::CreateInstanceN(const SearchBar& source) +{ + _PublicSearchBarEvent* pPublicSearchBarEvent = new (std::nothrow) _PublicSearchBarEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicSearchBarEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pPublicSearchBarEvent; + +CATCH: + delete pPublicSearchBarEvent; + return null; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _WindowEvent class Accessor + +const SearchBar* +_PublicSearchBarEvent::GetSource(void) const +{ + return __pSource; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicActionEvent class Operation + +void +_PublicSearchBarEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg) + +{ + // cast to IActionEventListener + ISearchBarEventListener* pSearchBarListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pSearchBarListener != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid listener was given."); + + // cast to _PublicSearchBarEventArg + const _PublicSearchBarEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given."); + + SearchBar* pSource = null; + pSource = const_cast (__pSource); + SysTryReturnVoidResult(NID_UI_CTRL, pSource != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given."); + + // call cursor change event listener method + SearchBarEventStatus status = pArg->GetStatus(); + if (status == SEARCH_BAR_EVENT_MODE_CHANGE) + { + pSearchBarListener->OnSearchBarModeChanged(*pSource, pSource->GetMode()); + } + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_PublicSearchBarEvent::CreateSearchBarEventArgN(SearchBarEventStatus status) +{ + _PublicSearchBarEventArg* pEventArg = new (std::nothrow) _PublicSearchBarEventArg(status); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicSliderEvent.cpp b/src/ui/controls/FUiCtrl_PublicSliderEvent.cpp new file mode 100644 index 0000000..4ab77c1 --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicSliderEvent.cpp @@ -0,0 +1,142 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicSliderEvent.cpp + * @brief This is the implementation for the _PublicSliderEvent class. + * + * This file contains the implementation of _PublicSliderEvent class. @n + */ + +#include +#include +#include +#include +#include "FUiCtrl_PublicSliderEvent.h" + +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _OSP_EXPORT_ _PublicSliderEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + _PublicSliderEventArg(int value); + virtual ~_PublicSliderEventArg(void); + +// Access +public: + int GetValue(void) const; + +// Attribute +private: + int __value; + +}; // _PublicSliderEventArg + +_PublicSliderEventArg::_PublicSliderEventArg(int value) + : __value(value) +{ +} + +_PublicSliderEventArg::~_PublicSliderEventArg(void) +{ +} + +int +_PublicSliderEventArg::GetValue(void) const +{ + return __value; +} + + +_PublicSliderEvent::_PublicSliderEvent(const Controls::Slider& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = const_cast (&source); + } +} + +_PublicSliderEvent::~_PublicSliderEvent(void) +{ +} + +_PublicSliderEvent* +_PublicSliderEvent::CreateInstanceN(const Controls::Slider& source) +{ + _PublicSliderEvent* pPublicSliderEvent = new (std::nothrow) _PublicSliderEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicSliderEvent != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pPublicSliderEvent; + +CATCH: + delete pPublicSliderEvent; + pPublicSliderEvent = null; + + return null; +} + +const Controls::Slider* +_PublicSliderEvent::GetSource(void) const +{ + return __pSource; +} + +void +_PublicSliderEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to ISliderEventListener + ISliderEventListener* pSliderListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pSliderListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given."); + + // cast to _PublicSliderEventArg + const _PublicSliderEventArg* pSliderEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pSliderEventArg != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid Event Argument was given."); + + // call cursor change event listener method + pSliderListener->OnSliderBarMoved(*__pSource, pSliderEventArg->GetValue()); + SetLastResult(E_SUCCESS); + return; +} + +IEventArg* +_PublicSliderEvent::CreateSliderEventArgN(int value) +{ + _PublicSliderEventArg* pEventArg = new (std::nothrow) _PublicSliderEventArg(value); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicSplitPanelEvent.cpp b/src/ui/controls/FUiCtrl_PublicSplitPanelEvent.cpp new file mode 100644 index 0000000..5d9510a --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicSplitPanelEvent.cpp @@ -0,0 +1,176 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicSplitPanelEvent.cpp +* @brief This is the implementation for the _PublicSplitPanelEvent class. +* @version 1.0 +*/ + +// includes +#include +#include +#include +#include +#include +#include "FUiCtrl_PublicSplitPanelEvent.h" +#include "FUiCtrl_SplitPanelImpl.h" + + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _PublicSplitPanelEventArg + * @brief This class is used as the argument to change event listener. + * + * This class is used as the argument to change event listener. When an change event is generated + * (such as when a button is pressed) the SplitPanelEvent calls SplitPanelEventListener's OnTextd + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the change ID. + */ +class _OSP_EXPORT_ _PublicSplitPanelEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] status + */ + _PublicSplitPanelEventArg(SplitPanelEventStatus status); + + /** + * This is the class destructor. + * + */ + virtual ~_PublicSplitPanelEventArg(void); + + +// Access +public: + SplitPanelEventStatus GetStatus(void) const; + +// Attribute +private: + /** + * Status + */ + SplitPanelEventStatus __status; +}; // _PublicSplitPanelEventArg + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicSplitPanelEventArg class Lifecycle + +_PublicSplitPanelEventArg::_PublicSplitPanelEventArg(SplitPanelEventStatus status) + : __status(status) +{ + // Nothing +} + +_PublicSplitPanelEventArg::~_PublicSplitPanelEventArg(void) +{ + // Nothing. +} + +SplitPanelEventStatus +_PublicSplitPanelEventArg::GetStatus(void) const +{ + return __status; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicSplitPanelEvent class Lifecycle +_PublicSplitPanelEvent::_PublicSplitPanelEvent(const SplitPanel& source) + : __pSource(null) +{ + //result r = Event::Construct(); + result r = _Event::Initialize(); + + // Set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_PublicSplitPanelEvent::~_PublicSplitPanelEvent(void) +{ + // Nothing. +} + +_PublicSplitPanelEvent* +_PublicSplitPanelEvent::CreateInstanceN(const SplitPanel& source) +{ + _PublicSplitPanelEvent* pPublicSplitPanelEvent = new (std::nothrow) _PublicSplitPanelEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicSplitPanelEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pPublicSplitPanelEvent; +} + +// Accessors + +const SplitPanel* +_PublicSplitPanelEvent::GetSource(void) const +{ + return __pSource; +} + +// Operations + +void +_PublicSplitPanelEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg) +{ + // cast to IActionEventListener + ISplitPanelEventListener* pSplitPanelEventListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pSplitPanelEventListener != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid listener was given."); + + // cast to _PublicSplitPanelEventArg + const _PublicSplitPanelEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given."); + + SplitPanel* pSource = null; + pSource = const_cast (__pSource); + + // call cursor change event listener method + SplitPanelEventStatus status = pArg->GetStatus(); + if (status == SPLIT_PANEL_EVENT_DIVIDER_POSITION_CHANGE) + { + pSplitPanelEventListener->OnDividerPositionChanged(*pSource, pSource->GetDividerPosition()); + } + else + { + pSplitPanelEventListener->OnDividerDoublePressed(*pSource); + } +} + +IEventArg* +_PublicSplitPanelEvent::CreateSplitPanelEventArgN(SplitPanelEventStatus status) +{ + _PublicSplitPanelEventArg* pEventArg = new (std::nothrow) _PublicSplitPanelEventArg(status); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicTextBlockEvent.cpp b/src/ui/controls/FUiCtrl_PublicTextBlockEvent.cpp new file mode 100644 index 0000000..d51ffd7 --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicTextBlockEvent.cpp @@ -0,0 +1,188 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicTextBlockEvent.cpp +* @brief This is the implementation for the _PublicTextBlockEvent class. +* +* This file contains implementation of _PublicTextBlockEvent class. +*/ + +// includes +#include +#include +#include +#include +#include "FUiCtrl_PublicTextBlockEvent.h" + + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _PublicTextBlockEventArg + * @brief This class is used as the argument to change event listener. + * + * This class is used as the argument to change event listener. When an change event is generated + * (such as when a button is pressed) the TextBlockEvent calls TextBlockEventListener's OnTextd + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the change ID. + */ +class _OSP_EXPORT_ _PublicTextBlockEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _PublicTextBlockEventArg(int start, int end); + + /** + * This is the class destructor. + * + */ + virtual ~_PublicTextBlockEventArg(void); + + +// Access +public: + /** + * Gets the start position of text block. + * + * @return the start position of text block. + */ + const int GetStartPosition(void) const; + + /** + * Gets the end position of text block. + * + * @return the end position of text block. + */ + const int GetEndPosition(void) const; + +// Attribute +private: + /** + * Start position. + */ + int __start; + + /** + * End position. + */ + int __end; +}; // _PublicTextBlockEventArg + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicTextBlockEventArg class Lifecycle + +_PublicTextBlockEventArg::_PublicTextBlockEventArg(int start, int end) + : __start(start) + , __end(end) +{ + // Nothing +} + +_PublicTextBlockEventArg::~_PublicTextBlockEventArg(void) +{ + // Nothing. +} + +const int +_PublicTextBlockEventArg::GetStartPosition(void) const +{ + return __start; +} + +const int +_PublicTextBlockEventArg::GetEndPosition(void) const +{ + return __end; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicTextBlockEvent class Lifecycle +_PublicTextBlockEvent::_PublicTextBlockEvent(const Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // Set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_PublicTextBlockEvent::~_PublicTextBlockEvent(void) +{ + // Nothing. +} + +_PublicTextBlockEvent* +_PublicTextBlockEvent::CreateInstanceN(const Control& source) +{ + _PublicTextBlockEvent* pPublicTextBlockEvent = new (std::nothrow) _PublicTextBlockEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicTextBlockEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pPublicTextBlockEvent; +} + +// Accessors + +const Control* +_PublicTextBlockEvent::GetSource(void) const +{ + return __pSource; +} + +// Operations + +void +_PublicTextBlockEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + ITextBlockEventListener* pTextBlockEventListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n"); + + const _PublicTextBlockEventArg* pTextBlockEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n"); + + pTextBlockEventListener->OnTextBlockSelected(const_cast (*__pSource), + pTextBlockEventArg->GetStartPosition(), pTextBlockEventArg->GetEndPosition()); + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_PublicTextBlockEvent::CreateTextBlockEventArgN(int start, int end) +{ + _PublicTextBlockEventArg* pEventArg = new (std::nothrow) _PublicTextBlockEventArg(start, end); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_PublicTextEvent.cpp b/src/ui/controls/FUiCtrl_PublicTextEvent.cpp new file mode 100644 index 0000000..a5275ed --- /dev/null +++ b/src/ui/controls/FUiCtrl_PublicTextEvent.cpp @@ -0,0 +1,184 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicTextEvent.cpp +* @brief This is the implementation for the _PublicTextEvent class. +* +* This file contains implementation of _PublicTextEvent class. +*/ + +// includes +#include +#include +#include +#include +#include "FUiCtrl_PublicTextEvent.h" + + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _PublicTextEventArg + * @brief This class is used as the argument to action event listener. + * + * This class is used as the argument to action event listener. When an action event is generated + * (such as when a button is pressed) the TextEvent calls TextEventListener's OnActionPerformed + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the action ID. + */ +class _OSP_EXPORT_ _PublicTextEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Object instance which contains this instance. + * @param[in] actionId Action Id. + */ + _PublicTextEventArg(TextEventStatus status); + + /** + * This is the class destructor. + * + */ + virtual ~_PublicTextEventArg(void); + + +// Access +public: + /** + * This method returns the TextEventStatus which the event initially occurred. + * + * @return See the comment above. + */ + TextEventStatus GetStatus(void) const; + + +// Attribute +private: + /** + * Action Id. + */ + TextEventStatus __status; +}; // _PublicTextEventArg + +_PublicTextEventArg::_PublicTextEventArg(TextEventStatus status) + : __status(status) +{ + // nothing +} + +_PublicTextEventArg::~_PublicTextEventArg(void) +{ + // nothing +} + +//////////////////////////////////////////////////////////////////////////////// +/// _TextEventArg class Access +TextEventStatus +_PublicTextEventArg::GetStatus(void) const +{ + return __status; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicTextEvent class Lifecycle +_PublicTextEvent::_PublicTextEvent(const Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_PublicTextEvent::~_PublicTextEvent(void) +{ + // nothing +} + +_PublicTextEvent* +_PublicTextEvent::CreateInstanceN(const Control& source) +{ + _PublicTextEvent* pPublicTextEvent = new (std::nothrow) _PublicTextEvent(source); + SysTryReturn(NID_UI_CTRL, pPublicTextEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pPublicTextEvent; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _WindowEvent class Accessor + +const Control* +_PublicTextEvent::GetSource(void) const +{ + return __pSource; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _PublicTextEvent class Operation + +void +_PublicTextEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to ITextEventListener + ITextEventListener* pTextListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pTextListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given.\n"); + + // cast to _PublicTextEventArg + const _PublicTextEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + // call cursor change event listener method + TextEventStatus stauts = pArg->GetStatus(); + if (stauts == TEXT_EVENT_CHANGED) + { + pTextListener->OnTextValueChanged(*__pSource); + } + else if (stauts == TEXT_EVENT_CANCELED) + { + pTextListener->OnTextValueChangeCanceled(*__pSource); + } + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_PublicTextEvent::CreateTextEventArgN(TextEventStatus status) +{ + _PublicTextEventArg* pEventArg = new (std::nothrow) _PublicTextEventArg(status); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_RadioGroup.cpp b/src/ui/controls/FUiCtrl_RadioGroup.cpp new file mode 100644 index 0000000..6b8dac6 --- /dev/null +++ b/src/ui/controls/FUiCtrl_RadioGroup.cpp @@ -0,0 +1,248 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_RadioGroup.cpp + * @brief This is the implementation file for the _RadioGroup class. + */ + +#include +#include +#include "FUiCtrl_RadioGroup.h" +#include "FUiCtrl_RadioGroupPresenter.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_RadioGroup::_RadioGroup(void) + : __pRadioGroupPresenter(null) + , __checkList(null) +{ + result r = E_SUCCESS; + + _RadioGroupPresenter* pPresenter = new (std::nothrow) _RadioGroupPresenter(); + SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = SetPresenter(*pPresenter); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pPresenter->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pPresenter->Install(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + SetMovable(false); + SetResizable(false); + SetFocusable(false); + + ClearLastResult(); + + return; + +CATCH: + delete pPresenter; +} + +_RadioGroup* +_RadioGroup::CreateRadioGroupN(void) +{ + _RadioGroup* pRadioGroup = new (std::nothrow) _RadioGroup(); + SysTryReturn(NID_UI_CTRL, pRadioGroup, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + pRadioGroup->AcquireHandle(); + + pRadioGroup->CreateCheckList(); + + return pRadioGroup; + +CATCH: + delete pRadioGroup; + return null; +} + +_RadioGroup::~_RadioGroup(void) +{ + if (__pRadioGroupPresenter) + { + delete __pRadioGroupPresenter; + __pRadioGroupPresenter = null; + } + + if (__checkList) + { + delete __checkList; + __checkList = null; + } + + ClearLastResult(); +} + +result +_RadioGroup::SetPresenter(const _RadioGroupPresenter& radioGroupPresenter) +{ + __pRadioGroupPresenter = const_cast <_RadioGroupPresenter*>(&radioGroupPresenter); + + return E_SUCCESS; +} + +result +_RadioGroup::CreateCheckList(void) +{ + result r = E_SUCCESS; + + __checkList = new (std::nothrow) ArrayList(); + SysTryReturn(NID_UI_CTRL, __checkList, E_INVALID_STATE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + r = __checkList->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[E_SYSTEM] System error occurred."); + + return E_SUCCESS; + +CATCH: + delete __checkList; + return E_SYSTEM; +} + +result +_RadioGroup::Add(_CheckButton& checkButton) +{ + result r = E_SUCCESS; + + if ((checkButton.__checkButtonStyle != CHECK_BUTTON_STYLE_RADIO) && + (checkButton.__checkButtonStyle != CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER) + && (checkButton.__checkButtonStyle != CHECK_BUTTON_STYLE_RADIO_WITH_DETAILED_BUTTON)) + { + SysTryReturn(NID_UI_CTRL, 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The CheckButton style is invalid.\n"); + } + + r = checkButton.AddRadioGroup(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The CheckButton is already belonged to a RadioGroup.\n"); + + r = __checkList->Add(checkButton); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The CheckButton is already belonged to a RadioGroup.\n"); + + return E_SUCCESS; +} + +result +_RadioGroup::Remove(_CheckButton& checkButton) +{ + result r = E_SUCCESS; + + r = checkButton.RemoveRadioGroup(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, + "[E_OBJ_NOT_FOUND] Unable to find the CheckButton.\n"); + + r = __checkList->Remove(checkButton); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, + "[E_OBJ_NOT_FOUND] Unable to find the CheckButton.\n"); + + return E_SUCCESS; +} + +bool +_RadioGroup::OnNotifiedN(const _Control& source, IList* pArgs) +{ + SysTryReturn(NID_UI_CTRL, pArgs != null, false, E_SYSTEM, "[E_SYSTEM] The argument is invalid."); + + String checkButtonReleasedEvent(L"CheckButtonReleasedEvent"); + String* pType = dynamic_cast (pArgs->GetAt(0)); + + const _CheckButton* pSelectedCheckButton = dynamic_cast (pArgs->GetAt(1)); + SysTryReturn(NID_UI_CTRL, pSelectedCheckButton, false, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed."); + + if (pType) + { + if (*pType == checkButtonReleasedEvent) + { + SetSelectedItem(*pSelectedCheckButton); + } + delete pArgs; + } + + return true; +} + +result +_RadioGroup::SetSelectedItem(const _CheckButton& checkButton) +{ + _CheckButton* pCurrentRB = null; + _CheckButton* pTarget = const_cast <_CheckButton*>(&checkButton); + + int count = __checkList->GetCount(); + + for (int i = 0; i < count; i++) + { + pCurrentRB = dynamic_cast<_CheckButton*>(__checkList->GetAt(i)); + + if (pCurrentRB) + { + if (pTarget == pCurrentRB) + { + pCurrentRB->SetSelected(true); + } + else + { + pCurrentRB->SetSelected(false); + } + pCurrentRB->Draw(); + } + } + + return E_SUCCESS; +} + +int +_RadioGroup::GetItemCount(void) const +{ + return __checkList->GetCount(); +} + +const _CheckButton* +_RadioGroup::GetSelectedItem(void) const +{ + const _CheckButton* pCurrentRB = null; + int count = __checkList->GetCount(); + + for (int i = 0; i < count; i++) + { + pCurrentRB = dynamic_cast<_CheckButton*>(__checkList->GetAt(i)); + + if (pCurrentRB) + { + if (pCurrentRB->IsSelected() == true) + { + break; + } + else + { + pCurrentRB = null; + } + } + } + + return pCurrentRB; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_RadioGroupImpl.cpp b/src/ui/controls/FUiCtrl_RadioGroupImpl.cpp new file mode 100644 index 0000000..c91c640 --- /dev/null +++ b/src/ui/controls/FUiCtrl_RadioGroupImpl.cpp @@ -0,0 +1,203 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_RadioGroupImpl.cpp + * @brief This is the implementation file for the _RadioGroupImpl class. + */ + +#include +#include +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_RadioGroupImpl.h" +#include "FUiCtrl_CheckButtonImpl.h" +#include "FUiCtrl_RadioGroup.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Dimension +_RadioGroupImpl::RadioGroupSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Dimension dimension(0, 0); + + r = GET_DIMENSION_CONFIG(RADIOGROUP::MIN_SIZE, orientation, dimension); + SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] A system error occurred.", GetErrorMessage(r)); + + SetLastResult(r); + + return dimension; +} + +_RadioGroupImpl* +_RadioGroupImpl::GetInstance(RadioGroup& radioGroup) +{ + return static_cast<_RadioGroupImpl*> (radioGroup._pControlImpl); +} + +const _RadioGroupImpl* +_RadioGroupImpl::GetInstance(const RadioGroup& radioGroup) +{ + return static_cast (radioGroup._pControlImpl); +} + +_RadioGroupImpl::_RadioGroupImpl(RadioGroup* pPublic, _RadioGroup* pCore) + : _ControlImpl(pPublic, pCore) +{ + ClearLastResult(); + SetFocusableChangable(false); +} + +_RadioGroupImpl::~_RadioGroupImpl(void) +{ + ClearLastResult(); +} + +_RadioGroupImpl* +_RadioGroupImpl::CreateRadioGroupImplN(RadioGroup* pControl) +{ + result r = E_SUCCESS; + + _RadioGroup* pCore = _RadioGroup::CreateRadioGroupN(); + SysTryReturn(NID_UI_CTRL, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _RadioGroupImpl* pImpl = new (std::nothrow) _RadioGroupImpl(pControl, pCore); + r = _ControlImpl::CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + ClearLastResult(); + + return pImpl; +} + +Color +_RadioGroupImpl::GetColorOnError(void) +{ + return Color(0XFFFFFFFF); +} + +const char* +_RadioGroupImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::RadioGroup"; +} + +const RadioGroup& +_RadioGroupImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +RadioGroup& +_RadioGroupImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _RadioGroup& +_RadioGroupImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_RadioGroup& +_RadioGroupImpl::GetCore(void) +{ + return static_cast <_RadioGroup&>(_ControlImpl::GetCore()); +} + +result +_RadioGroupImpl::OnAttachedToMainTree(void) +{ + result r = SetFocusable(false); + _ControlImpl::OnAttachedToMainTree(); + + return r; +} + +result +_RadioGroupImpl::Add(const CheckButton& checkButton) +{ + const _CheckButton& _checkButton = _CheckButtonImpl::GetInstance(checkButton)->GetCore(); + + result r = GetCore().Add(const_cast<_CheckButton&>(_checkButton)); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} +result +_RadioGroupImpl::Remove(const CheckButton& checkButton) +{ + const _CheckButton& _checkButton = _CheckButtonImpl::GetInstance(checkButton)->GetCore(); + + result r = GetCore().Remove(const_cast<_CheckButton&>(_checkButton)); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +_RadioGroupImpl::GetItemCount(void) const +{ + ClearLastResult(); + + return GetCore().GetItemCount(); +} + +result +_RadioGroupImpl::SetSelectedItem(const CheckButton& checkButton) +{ + const _CheckButton& _checkButton = _CheckButtonImpl::GetInstance(checkButton)->GetCore(); + + result r = GetCore().SetSelectedItem(const_cast<_CheckButton&>(_checkButton)); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +const CheckButton* +_RadioGroupImpl::GetSelectedItem(void) const +{ + ClearLastResult(); + + const _CheckButton* _pCheckButton = GetCore().GetSelectedItem(); + + if (!_pCheckButton) + { + return null; + } + + _CheckButtonImpl* pCheckButtonImpl = static_cast<_CheckButtonImpl*>(_pCheckButton->GetUserData()); + if (!pCheckButtonImpl) + { + return null; + } + + const CheckButton* pCheckButton = dynamic_cast(&(pCheckButtonImpl->GetPublic())); + if (!pCheckButton) + { + return null; + } + + return pCheckButton; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_RadioGroupModel.cpp b/src/ui/controls/FUiCtrl_RadioGroupModel.cpp new file mode 100644 index 0000000..c9bfa6e --- /dev/null +++ b/src/ui/controls/FUiCtrl_RadioGroupModel.cpp @@ -0,0 +1,47 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_RadioGroupModel.cpp + * @brief This is the implementation file for the _RadioGroupModel class. + */ + +#include +#include +#include "FUiCtrl_RadioGroupModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_RadioGroupModel::_RadioGroupModel(void) +{ + +} + +_RadioGroupModel::~_RadioGroupModel(void) +{ + +} + +result +_RadioGroupModel::Construct(void) +{ + result r = E_SUCCESS; + + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_RadioGroupPresenter.cpp b/src/ui/controls/FUiCtrl_RadioGroupPresenter.cpp new file mode 100644 index 0000000..c5c7f50 --- /dev/null +++ b/src/ui/controls/FUiCtrl_RadioGroupPresenter.cpp @@ -0,0 +1,98 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_RadioGroupPresenter.cpp + * @brief This is the implementation file for the _RadioGroupPresenter class. + */ + +#include +#include +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_RadioGroupPresenter.h" +#include "FUiCtrl_RadioGroupModel.h" +#include "FUiCtrl_RadioGroup.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_RadioGroupPresenter::_RadioGroupPresenter(void) + : __pRadioGroup(null) + , __pRadioGroupModel(null) + , __pRoot(null) +{ + +} + +_RadioGroupPresenter::~_RadioGroupPresenter(void) +{ + if (__pRadioGroupModel) + { + delete __pRadioGroupModel; + __pRadioGroupModel = null; + } +} + +result +_RadioGroupPresenter::Construct(const _RadioGroup& radioGroup) +{ + result r = E_SUCCESS; + + __pRadioGroup = const_cast <_RadioGroup*>(&radioGroup); + + __pRoot = __pRadioGroup->GetVisualElement(); + + if (__pRoot) + { + __pRoot->SetSurfaceOpaque(false); + } + + return r; +} + +result +_RadioGroupPresenter::Install(void) +{ + result r = E_SUCCESS; + + _RadioGroupModel* pModel = new (std::nothrow) _RadioGroupModel(); + SysTryReturn(NID_UI_CTRL, pModel, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = SetModel(*pModel); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pModel->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + return E_SUCCESS; + +CATCH: + delete pModel; + return r; +} + +result +_RadioGroupPresenter::SetModel(const _RadioGroupModel& radioGroupModel) +{ + __pRadioGroupModel = const_cast <_RadioGroupModel*>(&radioGroupModel); + + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Scroll.cpp b/src/ui/controls/FUiCtrl_Scroll.cpp new file mode 100644 index 0000000..18716b1 --- /dev/null +++ b/src/ui/controls/FUiCtrl_Scroll.cpp @@ -0,0 +1,309 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_Scroll.cpp + * @brief This is the implementation file for the _Scroll class. + */ + +#include +#include "FUiCtrl_Scroll.h" +#include "FUiCtrl_ScrollPresenter.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_Scroll::_Scroll(void) + : __pPresenter(null) +{ +} + +_Scroll::~_Scroll(void) +{ + delete __pPresenter; + __pPresenter = null; +} + +_Scroll* +_Scroll::CreateScrollN(Tizen::Ui::_Control& parentCtrl, + _ScrollDirection scrollDir, + bool enableFadeEffect, + bool enableJumpToTop, + bool enableHandler, + bool visibility, + int viewRange, + int scrollRange, + int scrollPosition) +{ + result r = E_SUCCESS; + ClearLastResult(); + + _Scroll* pScroll = new (std::nothrow) _Scroll(); + SysTryReturn(NID_UI_CTRL, pScroll, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + + r = pScroll->Construct(parentCtrl, + scrollDir, + enableFadeEffect, + enableJumpToTop, + enableHandler, + visibility, + viewRange, + scrollRange, + scrollPosition); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r)); + + return pScroll; + +CATCH: + delete pScroll; + return null; +} + +result +_Scroll::Construct(Tizen::Ui::_Control& parentCtrl, + _ScrollDirection scrollDir, + bool enableFadeEffect, + bool enableJumpToTop, + bool enableHandler, + bool visibility, + int viewRange, + int scrollRange, + int scrollPosition) +{ + _ScrollPresenter* pPresenter = _ScrollPresenter::CreateScrollPresenterN(parentCtrl, + *this, + scrollDir, + enableFadeEffect, + enableJumpToTop, + enableHandler, + visibility, + viewRange, + scrollRange, + scrollPosition); + SysTryReturnResult(NID_UI_CTRL, pPresenter, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + SetPresenter((_ScrollPresenter &)*pPresenter); + + AcquireHandle(); + + return E_SUCCESS; +} + +void +_Scroll::SetPresenter(_ScrollPresenter& scrollPresenter) +{ + __pPresenter = &scrollPresenter; +} + +_ScrollPresenter& +_Scroll::GetPresenter(void) const +{ + return *__pPresenter; +} + +result +_Scroll::SetScrollDirection(_ScrollDirection scrollDir) +{ + return GetPresenter().SetScrollDirection(scrollDir); +} + +_ScrollDirection +_Scroll::GetScrollDirection(void) const +{ + return GetPresenter().GetScrollDirection(); +} + +result +_Scroll::SetScrollRange(int viewRange, int scrollRange) +{ + return GetPresenter().SetScrollRange(viewRange, scrollRange); +} + +void +_Scroll::GetScrollRange(int* pViewRange, int* pScrollRange) const +{ + GetPresenter().GetScrollRange(pViewRange, pScrollRange); +} + +result +_Scroll::SetScrollPosition(int scrollPosition) +{ + return GetPresenter().SetScrollPosition(scrollPosition); +} + +int +_Scroll::GetScrollPosition(void) const +{ + return GetPresenter().GetScrollPosition(); +} + +void +_Scroll::EnableFadeEffect(bool enable) +{ + GetPresenter().EnableFadeEffect(enable); +} + +bool +_Scroll::IsEnabledFadeEffect(void) const +{ + return GetPresenter().IsEnabledFadeEffect(); +} + +bool +_Scroll::IsOnFadeEffect(void) const +{ + return GetPresenter().IsOnFadeEffect(); +} + +void +_Scroll::EnableScrollingEffect(bool enable) +{ + GetPresenter().EnableScrollingEffect(enable); +} + +bool +_Scroll::IsEnabledScrollingEffect(void) const +{ + return GetPresenter().IsEnabledScrollingEffect(); +} + +void +_Scroll::EnableOverScrollingEffect(bool enable) +{ + GetPresenter().EnableOverScrollingEffect(enable); +} + +bool +_Scroll::IsEnabledOverScrollingEffect(void) const +{ + return GetPresenter().IsEnabledOverScrollingEffect(); +} + +void +_Scroll::SetParentUsingViewport(bool useViewport) +{ + GetPresenter().SetParentUsingViewport(useViewport); +} + +bool +_Scroll::IsParentUsingViewport(void) const +{ + return GetPresenter().IsParentUsingViewport(); +} + +result +_Scroll::SetScrollVisibility(bool visibility) +{ + return GetPresenter().SetScrollVisibility(visibility); +} + +bool +_Scroll::GetScrollVisibility(void) const +{ + return GetPresenter().GetScrollVisibility(); +} + +void +_Scroll::CancelFadeEffect(void) +{ + GetPresenter().CancelFadeEffect(); +} + +result +_Scroll::SetScrollingEffectVisibility(bool visibility) +{ + return GetPresenter().SetScrollingEffectVisibility(visibility); +} + +result +_Scroll::EnableJumpToTop(bool enable) +{ + return GetPresenter().EnableJumpToTop(enable); +} + +bool +_Scroll::IsEnabledJumpToTop(void) const +{ + return GetPresenter().IsEnabledJumpToTop(); +} + +result +_Scroll::EnableHandler(bool enable) +{ + return GetPresenter().EnableHandler(enable); +} + +bool +_Scroll::IsEnabledHandler(void) const +{ + return GetPresenter().IsEnabledHandler(); +} + +void +_Scroll::AddScrollEventListener(const Tizen::Ui::Controls::_IScrollEventListener& listener) +{ + GetPresenter().AddScrollEventListener(listener); +} + +void +_Scroll::RemoveScrollEventListener(const Tizen::Ui::Controls::_IScrollEventListener& listener) +{ + GetPresenter().RemoveScrollEventListener(listener); +} + +void +_Scroll::OnParentBoundsChanged(void) +{ + GetPresenter().OnParentBoundsChanged(); +} + +void +_Scroll::OnDraw(void) +{ + GetPresenter().OnDraw(); +} + +bool +_Scroll::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return GetPresenter().OnTouchPressed(source, touchinfo); +} + +bool +_Scroll::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return GetPresenter().OnTouchReleased(source, touchinfo); +} + +bool +_Scroll::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return GetPresenter().OnTouchMoved(source, touchinfo); +} + +HitTestResult +_Scroll::HitTest(const Tizen::Graphics::FloatPoint& point) +{ + return GetPresenter().HitTest(point); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ScrollEvent.cpp b/src/ui/controls/FUiCtrl_ScrollEvent.cpp new file mode 100644 index 0000000..a14c325 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ScrollEvent.cpp @@ -0,0 +1,101 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_ScrollEvent.cpp +* @brief This is the implementation for the _ScrollEvent class. +*/ + +#include +#include +#include +#include "FUiCtrl_ScrollEvent.h" +#include "FUiCtrl_ScrollEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +//////////////////////////////////////////////////////////////////////////////// +/// _ScrollEvent class Lifecycle + +_ScrollEvent::_ScrollEvent(void) + : __pSource(null) +{ + // nothing +} + +_ScrollEvent::~_ScrollEvent(void) +{ + // nothing +} + +result +_ScrollEvent::Construct(const Tizen::Ui::Control& source) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = const_cast (&source); + } + + return r; +} + +//////////////////////////////////////////////////////////////////////////////// +/// __WindowEvent class Accessor + +Tizen::Ui::Control* +_ScrollEvent::GetSource(void) const +{ + return __pSource; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _ScrollEvent class Operation + +void +_ScrollEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + IScrollEventListener* pScrollEventListener = dynamic_cast (&listener); + SysTryReturnVoidResult(NID_UI_CTRL, (pScrollEventListener != null), E_INVALID_ARG, "[%s] The invalid listener was given.", GetErrorMessage(E_INVALID_ARG)); + + const _ScrollEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, (pArg != null), E_INVALID_ARG, "[%s] The invalid Event Argument was given.", GetErrorMessage(E_INVALID_ARG)); + + switch (pArg->GetEventType()) + { + case SCROLL_EVENT_ON_SCROLL_STOPPED: + pScrollEventListener->OnScrollStopped(*pArg->GetSource()); + break; + case SCROLL_EVENT_ON_SCROLL_POSITION_CHANGED: + pScrollEventListener->OnScrollPositionChanged(*pArg->GetSource(), pArg->GetScrollPosition()); + break; + case SCROLL_EVENT_ON_SCROLL_END_REACHED: + pScrollEventListener->OnScrollEndReached(*pArg->GetSource(), pArg->GetScrollType()); + break; + default: + SysTryReturnVoidResult(NID_UI_CTRL, false, E_INVALID_ARG, "[%s] The invalid Event Argument was given.", GetErrorMessage(E_INVALID_ARG)); + break; + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ScrollEventArg.cpp b/src/ui/controls/FUiCtrl_ScrollEventArg.cpp new file mode 100644 index 0000000..c6c4c8e --- /dev/null +++ b/src/ui/controls/FUiCtrl_ScrollEventArg.cpp @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_ScrollEventArg.cpp +* @brief This is the implementation for the _ScrollEventArg class. +*/ + +#include +#include "FUiCtrl_ScrollEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +//////////////////////////////////////////////////////////////////////////////// +/// _ScrollEventArg class Lifecycle + +_ScrollEventArg::_ScrollEventArg(_ScrollEventType eventType, const Control& source, int scrollPosition, ScrollEndEvent scrollType) + : __eventType(eventType) + , __pSource(const_cast (&source)) + , __scrollPosition(scrollPosition) + , __scrollType(scrollType) +{ + // nothing +} + +_ScrollEventArg::~_ScrollEventArg(void) +{ + // nothing +} + +_ScrollEventArg* +_ScrollEventArg::GetScrollEventArgN(const Control& source) +{ + _ScrollEventArg* pEventArg = new (std::nothrow) _ScrollEventArg(SCROLL_EVENT_ON_SCROLL_STOPPED, source); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + return pEventArg; +} + +_ScrollEventArg* +_ScrollEventArg::GetScrollEventArgN(const Control& source, int scrollPosition) +{ + _ScrollEventArg* pEventArg = new (std::nothrow) _ScrollEventArg(SCROLL_EVENT_ON_SCROLL_POSITION_CHANGED, source, scrollPosition); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + return pEventArg; +} + +_ScrollEventArg* +_ScrollEventArg::GetScrollEventArgN(const Control& source, ScrollEndEvent scrollType) +{ + _ScrollEventArg* pEventArg = new (std::nothrow) _ScrollEventArg(SCROLL_EVENT_ON_SCROLL_END_REACHED, source, -1, scrollType); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + return pEventArg; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _ScrollEventArg class Access + +_ScrollEventType +_ScrollEventArg::GetEventType(void) const +{ + return __eventType; +} + +Control* +_ScrollEventArg::GetSource(void) const +{ + return __pSource; +} + +int +_ScrollEventArg::GetScrollPosition(void) const +{ + return __scrollPosition; +} + +ScrollEndEvent +_ScrollEventArg::GetScrollType(void) const +{ + return __scrollType; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ScrollPanel.cpp b/src/ui/controls/FUiCtrl_ScrollPanel.cpp new file mode 100644 index 0000000..55ce022 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ScrollPanel.cpp @@ -0,0 +1,1037 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollPanel.cpp + * @brief This is the implementation file for the %_ScrollPanel class. + * + */ + +#include +#include +#include +#include +#include +#include "FUiAnim_VisualElement.h" +#include "FUi_TouchFlickGestureDetector.h" +#include "FUiCtrl_UiScrollEvent.h" +#include "FUiCtrl_UiScrollEventArg.h" +#include "FUiCtrl_Scroll.h" +#include "FUiCtrl_ScrollPanelPresenter.h" +#include "FUiCtrl_ScrollPanel.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; + +namespace +{ +const int SCROLL_PANEL_ANIMATION_DEFAULT_REPEAT_COUNT = 1; +} + +namespace Tizen { namespace Ui { namespace Controls +{ +_ScrollPanel::_ScrollPanel(void) + : _Panel() + , __pScrollPanelPresenter(null) + , __pScrollEvent(null) + , __pCoreScrollPanelEvent(null) + , __pGestureFlick(null) + , __pKeyPadBindingControl(null) + , __scrollDirection(SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL) + , __scrollInputMode(SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION) + , __autoResizingEnable(true) + , __pageScrollEnabled(false) + , __pageScrollAlignSize(Dimension(0, 0)) + , __pageScrollMoveOnlyOnePageOnFlick(true) + , __scrollBarVisible(true) + , __pHorizontalScrollBar(null) + , __pVerticalScrollBar(null) + , __pScrollingAnimation(null) + , __fixingClientBoundsEnable(true) +{ + // nothing +} + + +_ScrollPanel::~_ScrollPanel(void) +{ + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturnVoidResult(NID_UI_CTRL, pControlManager, E_SYSTEM, "[%s] System error occurred.", GetErrorMessage(E_SYSTEM)); + + if (GetVisualElement() != null) + { + __pScrollingAnimation->SetVisualElementAnimationTickEventListener(null); + __pScrollingAnimation->SetVisualElementAnimationStatusEventListener(null); + GetVisualElement()->RemoveAllAnimations(); + } + + if (__pGestureFlick != null) + { + __pGestureFlick->RemoveGestureListener(*this); + pControlManager->RemoveGestureDetector(*__pGestureFlick); + RemoveGestureDetector(*__pGestureFlick); + delete __pGestureFlick; + __pGestureFlick = null; + } + + delete __pScrollEvent; + __pScrollEvent = null; + + if (__pVerticalScrollBar != null && IsAncestorOf(*__pVerticalScrollBar)) + { + DetachSystemChild(*__pVerticalScrollBar); + } + delete __pVerticalScrollBar; + __pVerticalScrollBar = null; + + if (__pHorizontalScrollBar != null && IsAncestorOf(*__pHorizontalScrollBar)) + { + DetachSystemChild(*__pHorizontalScrollBar); + } + delete __pHorizontalScrollBar; + __pHorizontalScrollBar = null; + + delete __pScrollingAnimation; + __pScrollingAnimation = null; + + _Panel::SetPanelPresenter(null); + delete __pScrollPanelPresenter; + __pScrollPanelPresenter = null; +} + +_ScrollPanel* +_ScrollPanel::CreateScrollPanelN(const Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable, bool pageScrollEnabled) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _Scroll* pHorizontalScrollBar = null; + _Scroll* pVerticalScrollBar = null; + + Rectangle areaBounds = const_cast(rect); + + _ScrollPanel* pScrollPanel = new (std::nothrow) _ScrollPanel; + SysTryReturn(NID_UI_CTRL, pScrollPanel != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + pScrollPanel->SetScrollDirection(scrollDirection); + pScrollPanel->SetScrollAreaAutoResizingEnabled(autoResizingEnable); + pScrollPanel->SetPageScrollEnabled(pageScrollEnabled); + + _ScrollPanelPresenter* pPresenter = new (std::nothrow) _ScrollPanelPresenter; + SysTryCatch(NID_UI_CTRL, pPresenter != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + r = pPresenter->Initialize(*pScrollPanel); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pScrollPanel->Initialize(*pPresenter); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pPresenter->SetScrollAreaBoundsInternal(areaBounds); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL && rect.height > 0) + { + pVerticalScrollBar = _Scroll::CreateScrollN(*pScrollPanel, + SCROLL_DIRECTION_VERTICAL, + true, + false, + false, + false, + rect.height, + rect.height, + 0); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r ==E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pVerticalScrollBar->EnableScrollingEffect(true); + + pVerticalScrollBar->AddScrollEventListener(*pScrollPanel); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r ==E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pScrollPanel->AttachSystemChild(*pVerticalScrollBar); + SysTryCatch(NID_UI_CTRL, r ==E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pScrollPanel->SetVerticalScrollBar(pVerticalScrollBar); + } + + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL && rect.width > 0) + { + pHorizontalScrollBar = _Scroll::CreateScrollN(*pScrollPanel, + SCROLL_DIRECTION_HORIZONTAL, + true, + false, + false, + false, + rect.width, + rect.width, + 0); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r ==E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pHorizontalScrollBar->EnableScrollingEffect(true); + + pHorizontalScrollBar->AddScrollEventListener(*pScrollPanel); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r ==E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pScrollPanel->AttachSystemChild(*pHorizontalScrollBar); + SysTryCatch(NID_UI_CTRL, r ==E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pScrollPanel->SetHorizontalScrollBar(pHorizontalScrollBar); + } + + return pScrollPanel; + +CATCH: + if (pHorizontalScrollBar != null && pScrollPanel->IsAncestorOf(*pHorizontalScrollBar)) + { + pScrollPanel->DetachSystemChild(*pHorizontalScrollBar); + } + delete pHorizontalScrollBar; + pScrollPanel->__pHorizontalScrollBar = null; + + if (pVerticalScrollBar != null && pScrollPanel->IsAncestorOf(*pVerticalScrollBar)) + { + pScrollPanel->DetachSystemChild(*pVerticalScrollBar); + } + delete pVerticalScrollBar; + pScrollPanel->__pVerticalScrollBar = null; + + delete pPresenter; + pScrollPanel->__pScrollPanelPresenter = null; + + delete pScrollPanel; + + SetLastResult(r); + return null; +} + +result +_ScrollPanel::Initialize(const _ScrollPanelPresenter& presenter) +{ + ClearLastResult(); + + result r = _Panel::Initialize(presenter); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetScrollPanelPresenter(&presenter); + + __pScrollingAnimation = new (std::nothrow) VisualElementValueAnimation; + SysTryReturn(NID_UI_CTRL, __pScrollingAnimation != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __pScrollingAnimation->SetRepeatCount(SCROLL_PANEL_ANIMATION_DEFAULT_REPEAT_COUNT); + __pScrollingAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName("EaseOut")); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollingAnimation->SetVisualElementAnimationTickEventListener(this); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollingAnimation->SetVisualElementAnimationStatusEventListener(this); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pGestureFlick = new (std::nothrow) _TouchFlickGestureDetector; + SysTryCatch(NID_UI_CTRL, __pGestureFlick != null, , E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + AcquireHandle(); + + r = AddGestureDetector(*__pGestureFlick); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pGestureFlick->AddGestureListener(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + delete __pGestureFlick; + __pGestureFlick = null; + + delete __pScrollingAnimation; + __pScrollingAnimation = null; + + SetLastResult(r); + return r; +} + +result +_ScrollPanel::SetScrollPanelPresenter(const _ScrollPanelPresenter* presenter) +{ + ClearLastResult(); + + _Panel::SetPanelPresenter(presenter); + __pScrollPanelPresenter = const_cast <_ScrollPanelPresenter*>(presenter); + + return E_SUCCESS; +} + +void +_ScrollPanel::OnDraw(void) +{ + ClearLastResult(); + + if (__pScrollPanelPresenter == null) + { + return; + } + + result r = __pScrollPanelPresenter->Draw(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +_ScrollPanel::OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnBoundsChanging(bounds); +} + +void +_ScrollPanel::OnBoundsChanged(void) +{ + ClearLastResult(); + + if (__pScrollPanelPresenter == null) + { + return; + } + + __pScrollPanelPresenter->OnBoundsChanged(); +} + +void +_ScrollPanel::OnChildAttached(const _Control& child) +{ + ClearLastResult(); + + if (__pScrollPanelPresenter == null) + { + return; + } + + __pScrollPanelPresenter->OnChildAttached(child); +} + +void +_ScrollPanel::OnChildDetached(const _Control& child) +{ + ClearLastResult(); + + if (__pScrollPanelPresenter == null) + { + return; + } + + __pScrollPanelPresenter->OnChildDetached(child); +} + +void +_ScrollPanel::OnChildBoundsChanged(const _Control& child) +{ + ClearLastResult(); + + if (__pScrollPanelPresenter == null) + { + return; + } + + __pScrollPanelPresenter->OnChildBoundsChanged(child); +} + +bool +_ScrollPanel::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnFlickGestureDetected(gesture); +} + +bool +_ScrollPanel::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnFlickGestureCanceled(gesture); +} + +bool +_ScrollPanel::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnAccessibilityFocusMovedNext(control, element); +} + +bool +_ScrollPanel::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnAccessibilityFocusMovedPrevious(control, element); +} + +bool +_ScrollPanel::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnAccessibilityReadElement(control, element); +} + +bool +_ScrollPanel::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnAccessibilityFocusIn(control, element); +} + +bool +_ScrollPanel::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnAccessibilityFocusOut(control, element); +} + +bool +_ScrollPanel::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnAccessibilityActionPerformed(control, element); +} +bool +_ScrollPanel::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return true; +} +bool +_ScrollPanel::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return true; +} +_UiTouchEventDelivery +_ScrollPanel::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnPreviewTouchPressed(source, touchinfo); +} + +_UiTouchEventDelivery +_ScrollPanel::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnPreviewTouchMoved(source, touchinfo); +} + +_UiTouchEventDelivery +_ScrollPanel::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnPreviewTouchReleased(source, touchinfo); +} + +_UiTouchEventDelivery +_ScrollPanel::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnPreviewTouchCanceled(source, touchinfo); +} + +bool +_ScrollPanel::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_ScrollPanel::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_ScrollPanel::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_ScrollPanel::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnTouchCanceled(source, touchinfo); +} + +void +_ScrollPanel::OnTouchMoveHandled(const _Control& control) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->OnTouchMoveHandled(control); +} + +void +_ScrollPanel::OnScrollEndReached(_Control& source, ScrollEndEvent type) +{ + ClearLastResult(); + + __pScrollPanelPresenter->OnScrollEndReached(source, type); +} + +void +_ScrollPanel::OnScrollPositionChanged(_Control& source, int scrollPos) +{ + ClearLastResult(); + + __pScrollPanelPresenter->OnScrollPositionChanged(source, scrollPos); +} + +void +_ScrollPanel::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) +{ + ClearLastResult(); + + if (__pScrollPanelPresenter == null) + { + return; + } + + __pScrollPanelPresenter->OnVisualElementAnimationStarted(animation, keyName, target); +} + +void +_ScrollPanel::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) +{ + ClearLastResult(); + + if (__pScrollPanelPresenter == null) + { + return; + } + + __pScrollPanelPresenter->OnVisualElementAnimationRepeated(animation, keyName, target, currentRepeatCount); +} + +void +_ScrollPanel::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally) +{ + ClearLastResult(); + + if (__pScrollPanelPresenter == null) + { + return; + } + + __pScrollPanelPresenter->OnVisualElementAnimationFinished(animation, keyName, target, completedNormally); +} + +void +_ScrollPanel::OnTickOccurred(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, const Variant& currentValue) +{ + ClearLastResult(); + + __pScrollPanelPresenter->OnTickOccurred(animation, keyName, target, currentValue); +} + +bool +_ScrollPanel::IsScrollAreaAutoResizingEnabled(void) const +{ + ClearLastResult(); + + return __autoResizingEnable; +} + +void +_ScrollPanel::SetScrollAreaAutoResizingEnabled(bool autoResizingEnable) +{ + ClearLastResult(); + + __autoResizingEnable = autoResizingEnable; +} + +Rectangle +_ScrollPanel::GetScrollAreaBounds(void) const +{ + ClearLastResult(); + + return __pScrollPanelPresenter->GetScrollAreaBounds(); +} + +result +_ScrollPanel::SetClientAreaHeight(int height) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->SetClientAreaHeight(height); +} + +result +_ScrollPanel::SetClientAreaWidth(int width) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->SetClientAreaWidth(width); +} + +result +_ScrollPanel::SetScrollAreaBounds(Rectangle& bounds) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->SetScrollAreaBounds(bounds); +} + +bool +_ScrollPanel::IsPageScrollEnabled(void) const +{ + ClearLastResult(); + + return __pageScrollEnabled; +} + +void +_ScrollPanel::SetPageScrollEnabled(bool enable) +{ + ClearLastResult(); + + __pageScrollEnabled = enable; +} + +Dimension +_ScrollPanel::GetPageScrollAlignSize(void) const +{ + ClearLastResult(); + + return __pageScrollAlignSize; +} + +void +_ScrollPanel::SetPageScrollAlignSize(Dimension size) +{ + ClearLastResult(); + + __pageScrollAlignSize = size; +} + +bool +_ScrollPanel::IsPageScrollFlickMoveLimitedOnePage(void) const +{ + return __pageScrollMoveOnlyOnePageOnFlick; +} + +void +_ScrollPanel::SetScrollPosition(int position, bool withAnimation) +{ + ClearLastResult(); + + __pScrollPanelPresenter->SetScrollPosition(position, withAnimation); +} + +int +_ScrollPanel::GetScrollPosition(void) const +{ + ClearLastResult(); + + return __pScrollPanelPresenter->GetScrollPosition(); +} + +int +_ScrollPanel::GetVerticalScrollPosition(void) const +{ + ClearLastResult(); + + return __pScrollPanelPresenter->GetVerticalScrollPosition(); +} + +void +_ScrollPanel::SetVerticalScrollPosition(int position) +{ + ClearLastResult(); + + __pScrollPanelPresenter->SetVerticalScrollPosition(position); +} + +int +_ScrollPanel::GetHorizontalScrollPosition(void) const +{ + ClearLastResult(); + + return __pScrollPanelPresenter->GetHorizontalScrollPosition(); +} + +void +_ScrollPanel::SetHorizontalScrollPosition(int position) +{ + ClearLastResult(); + + __pScrollPanelPresenter->SetHorizontalScrollPosition(position); +} + +bool +_ScrollPanel::ScrollToControl(const _Control& source) +{ + ClearLastResult(); + + return __pScrollPanelPresenter->ScrollToControl(source); +} + +void +_ScrollPanel::ScrollToTop(void) const +{ + ClearLastResult(); + + __pScrollPanelPresenter->ScrollToTop(); +} + +void +_ScrollPanel::ScrollToBottom(void) const +{ + ClearLastResult(); + + __pScrollPanelPresenter->ScrollToBottom(); +} + +void +_ScrollPanel::ScrollToLeft(void) const +{ + ClearLastResult(); + + __pScrollPanelPresenter->ScrollToLeft(); +} + +void +_ScrollPanel::ScrollToRight(void) const +{ + ClearLastResult(); + + __pScrollPanelPresenter->ScrollToRight(); +} + +void +_ScrollPanel::AddScrollEventListener(const _IScrollEventListener& listener) +{ + ClearLastResult(); + result r = E_SUCCESS; + + if (__pScrollEvent == null) + { + // Create scroll event + __pScrollEvent = new (std::nothrow) _UiScrollEvent; + SysTryReturnVoidResult(NID_UI_CTRL, __pScrollEvent != null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + r = __pScrollEvent->Construct(*this); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pScrollEvent->AddListener((const Tizen::Base::Runtime::IEventListener &)listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_ScrollPanel::RemoveScrollEventListener(const _IScrollEventListener& listener) +{ + ClearLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, __pScrollEvent != null, E_SYSTEM, "[%s] __pScrollEvent is invalid pointer.", GetErrorMessage(E_SYSTEM)); + + result r = __pScrollEvent->RemoveListener((const Tizen::Base::Runtime::IEventListener &)listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_ScrollPanel::SetScrollPanelEvent(const _ScrollPanelEvent* pScrollPanelEvent) +{ + ClearLastResult(); + + __pCoreScrollPanelEvent = const_cast<_ScrollPanelEvent*>(pScrollPanelEvent); +} + +_ScrollPanelEvent* +_ScrollPanel::GetScrollPanelEvent(void) const +{ + ClearLastResult(); + + return __pCoreScrollPanelEvent; +} + +const _Control* +_ScrollPanel::GetControlKeypadBinding(void) const +{ + ClearLastResult(); + + return __pKeyPadBindingControl; +} + +void +_ScrollPanel::SetControlKeypadBinding(const _Control* pControl) +{ + ClearLastResult(); + + // pControl can be null + __pKeyPadBindingControl = pControl; +} + +ScrollPanelScrollDirection +_ScrollPanel::GetScrollDirection(void) const +{ + ClearLastResult(); + + return __scrollDirection; +} + +void +_ScrollPanel::SetScrollDirection(ScrollPanelScrollDirection direction) +{ + ClearLastResult(); + + __scrollDirection = direction; +} + +ScrollInputMode +_ScrollPanel::GetScrollInputMode(void) const +{ + ClearLastResult(); + + return __scrollInputMode; +} + +void +_ScrollPanel::SetScrollInputMode(ScrollInputMode mode) +{ + ClearLastResult(); + + __scrollInputMode = mode; +} + +bool +_ScrollPanel::IsScrollBarVisible(void) const +{ + ClearLastResult(); + + return __scrollBarVisible; +} + +void +_ScrollPanel::SetScrollBarVisible(bool scrollBarVisible) +{ + ClearLastResult(); + + __scrollBarVisible = scrollBarVisible; +} + +_Scroll* +_ScrollPanel::GetScrollBar(void) const +{ + ClearLastResult(); + + ScrollPanelScrollDirection direction = GetScrollDirection(); + if (direction == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + return GetHorizontalScrollBar(); + } + else + { + return GetVerticalScrollBar(); + } +} +void +_ScrollPanel::SetScrollBar(const _Scroll* pScrollBar) +{ + ClearLastResult(); + + ScrollPanelScrollDirection direction = GetScrollDirection(); + if (direction == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + SetHorizontalScrollBar(pScrollBar); + } + else + { + SetVerticalScrollBar(pScrollBar); + } +} + +_Scroll* +_ScrollPanel::GetVerticalScrollBar(void) const +{ + ClearLastResult(); + + return __pVerticalScrollBar; +} + +void +_ScrollPanel::SetVerticalScrollBar(const _Scroll* pVerticalScrollBar) +{ + ClearLastResult(); + + __pVerticalScrollBar = const_cast<_Scroll*>(pVerticalScrollBar); +} + +_Scroll* +_ScrollPanel::GetHorizontalScrollBar(void) const +{ + ClearLastResult(); + + return __pHorizontalScrollBar; +} + +void +_ScrollPanel::SetHorizontalScrollBar(const _Scroll* pHorizontalScrollBar) +{ + ClearLastResult(); + + __pHorizontalScrollBar = const_cast<_Scroll*>(pHorizontalScrollBar); +} + +bool +_ScrollPanel::IsFixingClientBoundsEnable(void) const +{ + return __fixingClientBoundsEnable; +} + +void +_ScrollPanel::SetFixingClientBoundsEnable(bool enable) +{ + __fixingClientBoundsEnable = enable; +} + +result +_ScrollPanel::FireOnScrollEndEvent(ScrollEndEvent scrollEndEventType) +{ + ClearLastResult(); + + if (__pScrollEvent == null) + { + return E_SUCCESS; + } + + _UiScrollEventArg* pEventArg = _UiScrollEventArg::GetScrollEventArgN(*this, scrollEndEventType); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + + return E_SUCCESS; +CATCH: + delete pEventArg; + + return E_SUCCESS; +} + +result +_ScrollPanel::FireOnScrollPositionChangedEvent(void) +{ + ClearLastResult(); + + return FireOnScrollPositionChangedEvent(__pScrollPanelPresenter->GetScrollPosition()); +} + +result +_ScrollPanel::FireOnScrollPositionChangedEvent(int scrollPosition) +{ + ClearLastResult(); + + if (__pScrollEvent == null) + { + return E_SUCCESS; + } + + _UiScrollEventArg* pEventArg = _UiScrollEventArg::GetScrollEventArgN(*this, scrollPosition); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + + return E_SUCCESS; +CATCH: + delete pEventArg; + + return E_SUCCESS; +} + +result +_ScrollPanel::FireOnScrollStoppedEvent(void) +{ + ClearLastResult(); + + if (__pScrollEvent == null) + { + return E_SUCCESS; + } + + _UiScrollEventArg* pEventArg = _UiScrollEventArg::GetScrollEventArgN(*this); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + + return E_SUCCESS; +CATCH: + delete pEventArg; + + return E_SUCCESS; +} + +VisualElementValueAnimation* +_ScrollPanel::GetScrollingAnimation(void) const +{ + ClearLastResult(); + + return __pScrollingAnimation; +} + +result +_ScrollPanel::FireScrollPanelEvent(const _Control& source, CoreScrollPanelStatus scrollPanelStatus) +{ + ClearLastResult(); + + if (GetControlKeypadBinding() != &source) + { + if (__pCoreScrollPanelEvent != null) + { + Tizen::Base::Runtime::IEventArg* pEventArg = _ScrollPanelEvent::CreateScrollPanelEventArgN(scrollPanelStatus); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pEventArg != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pCoreScrollPanelEvent->Fire(*pEventArg); + } + } + + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_ScrollPanelEvent.cpp b/src/ui/controls/FUiCtrl_ScrollPanelEvent.cpp new file mode 100644 index 0000000..7da9030 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ScrollPanelEvent.cpp @@ -0,0 +1,189 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_ScrollPanelEvent.cpp +* @brief This is the implementation for the _ScrollPanelEvent class. +* @version 1.0 +*/ + +// includes +#include +#include +#include +#include "FUiCtrl_IScrollPanelEventListener.h" +#include "FUiCtrl_ScrollPanelEvent.h" + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _ScrollPanelEventArg + * @brief This class is used as the argument to change event listener. + * + * This class is used as the argument to change event listener. When an change event is generated + * (such as when a button is pressed) the ScrollPanelEvent calls ScrollPanelEventListener's OnTextd + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the change ID. + */ +class _ScrollPanelEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _ScrollPanelEventArg(CoreScrollPanelStatus status); + + /** + * This is the class destructor. + * + */ + virtual ~_ScrollPanelEventArg(void); + + +// Access +public: + CoreScrollPanelStatus GetStatus(void) const; + +// Attribute +private: + /** + * Status + */ + CoreScrollPanelStatus __status; +}; // _ScrollPanelEventArg + +//////////////////////////////////////////////////////////////////////////////// +/// _ScrollPanelEventArg class Lifecycle + +_ScrollPanelEventArg::_ScrollPanelEventArg(CoreScrollPanelStatus status) + : __status(status) +{ + // Nothing +} + +_ScrollPanelEventArg::~_ScrollPanelEventArg(void) +{ + // Nothing. +} + +CoreScrollPanelStatus +_ScrollPanelEventArg::GetStatus(void) const +{ + return __status; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _ScrollPanelEvent class Lifecycle +_ScrollPanelEvent::_ScrollPanelEvent(const Tizen::Ui::_Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // Set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_ScrollPanelEvent::~_ScrollPanelEvent(void) +{ + // Nothing. +} + +_ScrollPanelEvent* +_ScrollPanelEvent::CreateScrollPanelEventN(const Tizen::Ui::_Control& source) +{ + _ScrollPanelEvent* pCoreScrollPanelEvent = new (std::nothrow) _ScrollPanelEvent(source); + SysTryReturn(NID_UI_CTRL, pCoreScrollPanelEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pCoreScrollPanelEvent; + +CATCH: + delete pCoreScrollPanelEvent; + return null; +} + +// Accessors + +const Tizen::Ui::_Control* +_ScrollPanelEvent::GetSource(void) const +{ + return __pSource; +} + +// Operations + +void +_ScrollPanelEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg) +{ + _IScrollPanelEventListener* pScrollPanelEventListener = dynamic_cast <_IScrollPanelEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pScrollPanelEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n"); + + const _ScrollPanelEventArg* pScrollPanelEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pScrollPanelEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n"); + + switch (pScrollPanelEventArg->GetStatus()) + { + case CORE_OVERLAY_CONTROL_CREATED: + // notify listener + pScrollPanelEventListener->OnOverlayControlCreated(*GetSource()); + break; + + case CORE_OVERLAY_CONTROL_OPENED: + pScrollPanelEventListener->OnOverlayControlOpened(*GetSource()); + break; + + case CORE_OVERLAY_CONTROL_CLOSED: + pScrollPanelEventListener->OnOverlayControlClosed(*GetSource()); + break; + + case CORE_OTHER_CONTROL_SELECTED: + pScrollPanelEventListener->OnOtherControlSelected(*GetSource()); + break; + } + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_ScrollPanelEvent::CreateScrollPanelEventArgN(CoreScrollPanelStatus status) +{ + _ScrollPanelEventArg* pEventArg = new (std::nothrow) _ScrollPanelEventArg(status); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ScrollPanelImpl.cpp b/src/ui/controls/FUiCtrl_ScrollPanelImpl.cpp new file mode 100644 index 0000000..0310536 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ScrollPanelImpl.cpp @@ -0,0 +1,567 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollPanelImpl.cpp + * @brief This is the implementation file for the %_ScrollPanelImpl class. + * + */ + +#include +#include +#include +#include +#include "FApp_AppInfo.h" +#include "FUi_LayoutImpl.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_ScrollEvent.h" +#include "FUiCtrl_ScrollEventArg.h" +#include "FUiCtrl_ScrollPanelImpl.h" + +using namespace Tizen::App; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ScrollPanelImpl::_ScrollPanelImpl(Control* pPublic, _Control* pCore, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout) + : _PanelImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout) + , __pScrollEvent(null) +{ + // nothing +} + +_ScrollPanelImpl::~_ScrollPanelImpl(void) +{ + GetCore().RemoveScrollEventListener(*this); + + delete __pScrollEvent; + __pScrollEvent = null; +} + +_ScrollPanelImpl* +_ScrollPanelImpl::CreateScrollPanelImplN(ScrollPanel* pControl, const Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout) +{ + ClearLastResult(); + + _ScrollPanelImpl* pImpl = null; + _ScrollPanel* pCore = null; + + if (pPublicPortraitLayout != null) + { + _LayoutImpl* pPortraitLayoutImpl = _LayoutImpl::GetInstance(*pPublicPortraitLayout); + SysTryReturn(NID_UI_CTRL, pPortraitLayoutImpl != null, null, E_INVALID_ARG, "[%s] Portrait layout is invalid object", GetErrorMessage(E_INVALID_ARG)); + } + if (pPublicLandscapeLayout != null) + { + _LayoutImpl* pLandscapeLayoutImpl = _LayoutImpl::GetInstance(*pPublicLandscapeLayout); + SysTryReturn(NID_UI_CTRL, pLandscapeLayoutImpl != null, null, E_INVALID_ARG, "[%s] Landscape layout is invalid object", GetErrorMessage(E_INVALID_ARG)); + } + + pCore = _ScrollPanel::CreateScrollPanelN(rect, scrollDirection, autoResizingEnable); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl = new (std::nothrow) _ScrollPanelImpl(pControl, pCore, pPublicPortraitLayout, pPublicLandscapeLayout); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->SetBounds(rect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCore->SetFixingClientBoundsEnable(!_AppInfo::IsOspCompat()); + + return pImpl; + +CATCH: + delete pImpl; + + SetLastResult(r); + return null; +} + +const _ScrollPanelImpl* +_ScrollPanelImpl::GetInstance(const ScrollPanel& scrollPanel) +{ + return static_cast(_ControlImpl::GetInstance(scrollPanel)); +} + +_ScrollPanelImpl* +_ScrollPanelImpl::GetInstance(ScrollPanel& scrollPanel) +{ + return static_cast<_ScrollPanelImpl*>(_ControlImpl::GetInstance(scrollPanel)); +} + +const char* +_ScrollPanelImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::ScrollPanel"; +} + +const ScrollPanel& +_ScrollPanelImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +ScrollPanel& +_ScrollPanelImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _ScrollPanel& +_ScrollPanelImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_ScrollPanel& +_ScrollPanelImpl::GetCore(void) +{ + return static_cast <_ScrollPanel&>(_ControlImpl::GetCore()); +} + +void +_ScrollPanelImpl::AddScrollEventListener(IScrollEventListener& listener) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + if (__pScrollEvent == null) + { + __pScrollEvent = new (std::nothrow) _ScrollEvent(); + SysTryReturnVoidResult(NID_UI_CTRL, __pScrollEvent != null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient", GetErrorMessage(E_OUT_OF_MEMORY)); + + r = __pScrollEvent->Construct(GetPublic()); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pScrollEvent->AddListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().AddScrollEventListener(*this); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_ScrollPanelImpl::RemoveScrollEventListener(IScrollEventListener& listener) +{ + ClearLastResult(); + + if (__pScrollEvent != null) + { + result r = __pScrollEvent->RemoveListener(listener); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } +} + +void +_ScrollPanelImpl::OnScrollEndReached(_Control& source, ScrollEndEvent type) +{ + if (__pScrollEvent == null) + { + return; + } + + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), type); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + + return; +CATCH: + delete pEventArg; +} + +void +_ScrollPanelImpl::OnScrollPositionChanged(_Control& source, int scrollPosition) +{ + if (__pScrollEvent == null) + { + return; + } + + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), scrollPosition); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + + return; +CATCH: + delete pEventArg; +} + +void +_ScrollPanelImpl::OnScrollStopped(_Control& source) +{ + if (__pScrollEvent == null) + { + return; + } + + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic()); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + + return; +CATCH: + delete pEventArg; +} + +int +_ScrollPanelImpl::GetScrollPosition(void) const +{ + return GetCore().GetScrollPosition(); +} + +void +_ScrollPanelImpl::SetScrollPosition(int position, bool withAnimation) +{ + GetCore().SetScrollPosition(position, withAnimation); +} + +void +_ScrollPanelImpl::ScrollToBottom(void) const +{ + const _ScrollPanel& scrollPanel = GetCore(); + if (scrollPanel.GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + scrollPanel.ScrollToRight(); + } + else + { + scrollPanel.ScrollToBottom(); + } +} + +void +_ScrollPanelImpl::ScrollToTop(void) const +{ + const _ScrollPanel& scrollPanel = GetCore(); + if (scrollPanel.GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + scrollPanel.ScrollToLeft(); + } + else + { + scrollPanel.ScrollToTop(); + } +} + +result +_ScrollPanelImpl::CloseOverlayWindow(void) +{ + ClearLastResult(); + + const _Control* pControl = GetCore().GetControlKeypadBinding(); + + _Edit* pKeypadBindingEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(pControl)); + + if (pKeypadBindingEdit == null) + { + return E_SUCCESS; + } + + result r = pKeypadBindingEdit->HideKeypad(); + SysTryReturn(NID_UI_CTRL, r != E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +Rectangle +_ScrollPanelImpl::GetClientAreaBounds(void) const +{ + return GetCore().GetScrollAreaBounds(); +} + +result +_ScrollPanelImpl::SetClientAreaHeight(int height) +{ + return GetCore().SetClientAreaHeight(height); +} + +result +_ScrollPanelImpl::SetClientAreaWidth(int width) +{ + return GetCore().SetClientAreaWidth(width); +} + +ScrollPanelScrollDirection +_ScrollPanelImpl::GetScrollDirection(void) const +{ + return GetCore().GetScrollDirection(); +} + +bool +_ScrollPanelImpl::IsScrollAreaAutoResizingEnabled(void) const +{ + return GetCore().IsScrollAreaAutoResizingEnabled(); +} + +void +_ScrollPanelImpl::SetPageScrollEnabled(bool enable) +{ + return GetCore().SetPageScrollEnabled(enable); +} + +bool +_ScrollPanelImpl::IsPageScrollEnabled(void) const +{ + return GetCore().IsPageScrollEnabled(); +} + +void +_ScrollPanelImpl::SetScrollBarVisible(bool visible) +{ + GetCore().SetScrollBarVisible(visible); +} + +bool +_ScrollPanelImpl::IsScrollBarVisible(void) const +{ + return GetCore().IsScrollBarVisible(); +} + +void +_ScrollPanelImpl::SetScrollInputMode(ScrollInputMode mode) +{ + GetCore().SetScrollInputMode(mode); +} + +ScrollInputMode +_ScrollPanelImpl::GetScrollInputMode(void) const +{ + return GetCore().GetScrollInputMode(); +} + +class _ScrollPanelMaker + : public _UiBuilderControlMaker +{ +public: + _ScrollPanelMaker(_UiBuilder* pUibuilder) + : _UiBuilderControlMaker(pUibuilder) {}; + virtual ~_ScrollPanelMaker(void) {}; + + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* pUibuilder) + { + _ScrollPanelMaker* pScrollPanelMaker = new (std::nothrow) _ScrollPanelMaker(pUibuilder); + SysTryReturn(NID_UI_CTRL, pScrollPanelMaker != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + return pScrollPanelMaker; + }; + +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + + ScrollPanel* pScrollPanel = null; + Rectangle rect; + + _UiBuilderControlLayout* pControlProperty = null; + _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE; + + Color color; + + int opacity = 100; + ScrollPanelScrollDirection scrollDirection = SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL; + bool autoResizingEnabled = true; + + Tizen::Base::String elementString; + GetProperty(pControl, &pControlProperty); + SysTryReturn(NID_UI_CTRL, pControlProperty != null, null, E_SYSTEM, "[%s] pControlProperty is invalid pointer.", GetErrorMessage(E_SYSTEM)); + + if(pControl->GetParentWin().IsEmpty()) + { + pScrollPanel = static_cast (GetContainer()); + } + else + { + pScrollPanel = new (std::nothrow) ScrollPanel; + } + SysTryReturn(NID_UI_CTRL, pScrollPanel != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + rect = pControlProperty->GetRect(); + + // Construct + GetLayoutType(pControlProperty, layoutType); + + // ScrollDirection + if (pControl->GetElement(L"scrollDirection", elementString) || pControl->GetElement(L"ScrollDirection", elementString)) + { + if (elementString.Equals(L"SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL", false)) + { + scrollDirection = SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL; + } + else if (elementString.Equals(L"SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL", false)) + { + scrollDirection = SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL; + } + } + + // AutoResizingEnabled + if (pControl->GetElement(L"autoResizingEnabled", elementString) || pControl->GetElement(L"AutoResizingEnabled", elementString)) + { + if (elementString.Equals(L"false", false)) + { + autoResizingEnabled = false; + } + else if (elementString.Equals(L"true", false)) + { + autoResizingEnabled = true; + } + } + + if (layoutType == UIBUILDER_LAYOUT_NONE) + { + r = pScrollPanel->Construct(rect, scrollDirection, autoResizingEnabled); + } + else + { + Layout* pPortraitLayout = null; + Layout* pLandscapeLayout = null; + result tempResult = E_SUCCESS; + tempResult = GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout); + if (E_SUCCESS == tempResult) + { + //CONSTRUCT_WITH_LAYOUT_ARG1(pScrollPanel, rect); + r = pScrollPanel->Construct(*pPortraitLayout, *pLandscapeLayout, rect, scrollDirection, autoResizingEnabled); + } + else + { + r = tempResult; + } + delete pPortraitLayout; + if (pPortraitLayout != pLandscapeLayout) + { + delete pLandscapeLayout; + } + } + if (r != E_SUCCESS) + { + delete pScrollPanel; + return null; + } + + if (pControl->GetElement("backgroundColorOpacity", elementString) || pControl->GetElement("BGColorOpacity", elementString) || pControl->GetElement("backgroundOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement("backgroundColor", elementString) || pControl->GetElement("BGColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pScrollPanel->SetBackgroundColor(color); + } + else + { + color = pScrollPanel->GetBackgroundColor(); + color.SetAlpha(ConvertOpacity100to255(opacity)); + pScrollPanel->SetBackgroundColor(color); + } + + if (!autoResizingEnabled) + { + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + // ClientAreaWidth + if (pControl->GetElement(L"clientAreaWidth", elementString) || pControl->GetElement(L"ClientAreaWidth", elementString)) + { + int width = 0; + Base::Integer::Parse(elementString, width); + pScrollPanel->SetClientAreaWidth(width); + } + } + else if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL) + { + // ClientAreaHeight + if (pControl->GetElement(L"clientAreaHeight", elementString) || pControl->GetElement(L"ClientAreaHeight", elementString)) + { + int height = 0; + Base::Integer::Parse(elementString, height); + pScrollPanel->SetClientAreaWidth(height); + } + } + } + + // PageScrollEnabled + if (pControl->GetElement(L"pageScrollEnabled", elementString) || pControl->GetElement(L"PageScrollEnabled", elementString)) + { + if (elementString.Equals(L"false", false)) + { + pScrollPanel->SetPageScrollEnabled(false); + } + else if (elementString.Equals(L"true", false)) + { + pScrollPanel->SetPageScrollEnabled(true); + } + } + + // ScrollBarVisible + if (pControl->GetElement(L"scrollBarVisible", elementString) || pControl->GetElement(L"ScrollBarVisible", elementString)) + { + if (elementString.Equals(L"false", false)) + { + pScrollPanel->SetScrollBarVisible(false); + } + else if (elementString.Equals(L"true", false)) + { + pScrollPanel->SetScrollBarVisible(true); + } + } + + // ScrollInputMode + if (pControl->GetElement(L"scrollInputMode", elementString) || pControl->GetElement(L"ScrollInputMode", elementString)) + { + if (elementString.Equals(L"SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION", false)) + { + pScrollPanel->SetScrollInputMode(SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION); + } + else if (elementString.Equals(L"SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION", false)) + { + pScrollPanel->SetScrollInputMode(SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION); + } + } + + return pScrollPanel; + } + +private: +}; // _ScrollPanelMaker + +_ScrollPanelRegister::_ScrollPanelRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"ScrollPanel", _ScrollPanelMaker::GetInstance); +} +_ScrollPanelRegister::~_ScrollPanelRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"ScrollPanel"); +} +static _ScrollPanelRegister ScrollPanelRegisterToUiBuilder; +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_ScrollPanelModel.cpp b/src/ui/controls/FUiCtrl_ScrollPanelModel.cpp new file mode 100644 index 0000000..85b407f --- /dev/null +++ b/src/ui/controls/FUiCtrl_ScrollPanelModel.cpp @@ -0,0 +1,102 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollPanelModel.cpp + * @brief This is the implementation file for the %_ScrollPanelModel class. + * + */ + +#include +#include +#include +#include "FUiCtrl_ScrollPanelModel.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ScrollPanelModel::_ScrollPanelModel(void) + : __currentScrollPosition(Point(0, 0)) + , __scrollAreaBounds(Rectangle(0, 0, 0, 0)) +{ + // nothing +} + +_ScrollPanelModel::~_ScrollPanelModel(void) +{ + // nothing +} + +void +_ScrollPanelModel::SetCurrentScrollPosition(int currentScrollHorizontalPosition, int currentScrollVerticalPosition) +{ + SetCurrentHorizontalScrollPosition(currentScrollHorizontalPosition); + SetCurrentVerticalScrollPosition(currentScrollVerticalPosition); +} + +void +_ScrollPanelModel::SetCurrentScrollPosition(Point& currentScrollPosition) +{ + __currentScrollPosition = currentScrollPosition; +} + +Point +_ScrollPanelModel::GetCurrentScrollPosition(void) const +{ + return __currentScrollPosition; +} + +void +_ScrollPanelModel::SetCurrentVerticalScrollPosition(int currentVerticalScrollPosition) +{ + __currentScrollPosition.y = currentVerticalScrollPosition; +} + +int +_ScrollPanelModel::GetCurrentVerticalScrollPosition(void) const +{ + return __currentScrollPosition.y; +} + +void +_ScrollPanelModel::SetCurrentHorizontalScrollPosition(int currentHorizontalScrollPosition) +{ + __currentScrollPosition.x = currentHorizontalScrollPosition; +} + +int +_ScrollPanelModel::GetCurrentHorizontalScrollPosition(void) const +{ + return __currentScrollPosition.x; +} + +void +_ScrollPanelModel::SetScrollAreaBounds(Rectangle& areaBounds) +{ + __scrollAreaBounds = areaBounds; +} + +Rectangle +_ScrollPanelModel::GetScrollAreaBounds(void) const +{ + return __scrollAreaBounds; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_ScrollPanelPresenter.cpp b/src/ui/controls/FUiCtrl_ScrollPanelPresenter.cpp new file mode 100644 index 0000000..d346973 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ScrollPanelPresenter.cpp @@ -0,0 +1,1915 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollPanelPresenter.cpp + * @brief This is the implementation file for the %_ScrollPanelPresenter class. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_IAccessibilityListener.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_Scroll.h" +#include "FUiCtrl_ScrollPanel.h" +#include "FUiCtrl_ScrollPanelImpl.h" +#include "FUiCtrl_ScrollPanelPresenter.h" +#include "FUiCtrl_ScrollPanelModel.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; + +namespace +{ +const int SCROLL_PANEL_SCROLLING_ANIMATION_DURATION = 1000; +const int SCROLL_PANEL_OVERSCROLLING_MAX_DISTANCCE = 100; + +const int SCROLL_PANEL_FLICK_IN_PIXEL_UNIT = 1000; +const int SCROLL_PANEL_FLICK_WEIGHT_VELOCITY = 1; +const int SCROLL_PANEL_FLICK_WEIGHT_DISTANCE = 5; +const int SCROLL_PANEL_FLICK_ALPHA_PER_PIXEL = 3; + +const int SCROLL_PANEL_SCROLL_BAR_LOAD_EFFECT_TIMER_DURATION = 1000; +const int SCROLL_PANEL_FLICK_SCROLL_EFFECT_TIMER_DURATION = 2000; + +const String SCROLLING_ANIMATION_NAME(L"SCROLL_PANEL_SCROLLING_ANIMATION"); +} + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ScrollPanelPresenter::_ScrollPanelPresenter(void) + : __pScrollPanel(null) + , __pScrollPanelModel(null) + , __pPressedControl(null) + , __subControlMoved(false) + , __touchPressed(false) + , __scrollOccured(false) + , __scrollAnimationRunning(false) + , __flickRunning(false) + , __pFlickScrollEffectTimer(null) + , __flickDirection(_FLICK_DIRECTION_NONE) + , __flickCount(0) + , __pScrollBarLoadEffectTimer(null) + , __scrollBarFirstLoaded(true) + , __bouncing(false) + , __firstTouchMove(true) + , __firstScrollMoveDirection(SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL) +{ + // nothing +} + +_ScrollPanelPresenter::~_ScrollPanelPresenter(void) +{ + delete __pScrollBarLoadEffectTimer; + __pScrollBarLoadEffectTimer = null; + + delete __pFlickScrollEffectTimer; + __pFlickScrollEffectTimer = null; + + delete __pScrollPanelModel; + __pScrollPanelModel = null; +} + +result +_ScrollPanelPresenter::Initialize(_ScrollPanel& scrollPanel) +{ + result r = _PanelPresenter::Initialize(scrollPanel); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollPanel = &scrollPanel; + + // create model + _ScrollPanelModel* pModel = new (std::nothrow) _ScrollPanelModel; + SysTryReturn(NID_UI_CTRL, pModel != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] The memory is insufficient", GetErrorMessage(E_OUT_OF_MEMORY)); + + __pScrollPanelModel = pModel; + + return E_SUCCESS; +} + +result +_ScrollPanelPresenter::Draw(void) +{ + if (__pScrollPanel->GetBackgroundBitmap() == null) + { + return E_SUCCESS; + } + + Canvas* pCanvas = __pScrollPanel->GetVisualElement()->GetCanvasN(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCanvas->Clear(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + DrawBackgrounBitmap(pCanvas); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + // fall throw +CATCH: + delete pCanvas; + + return r; +} + +result +_ScrollPanelPresenter::OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds) +{ + ScrollPanelScrollDirection scrollDirection = __pScrollPanel->GetScrollDirection(); + Rectangle scrollArea = GetScrollAreaBounds(); + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + if (scrollArea.width < bounds.width) + { + scrollArea.width = bounds.width; + } + } + else + { + if (scrollArea.height < bounds.height) + { + scrollArea.height = bounds.height; + } + } + int scrollPosition = GetScrollPosition(); + int fixedScrollPosition = FixScrollPositionIntoScrollAreaBounds(scrollPosition, bounds, scrollArea); + if (scrollPosition != fixedScrollPosition) + { + ScrollTo(fixedScrollPosition, false); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return E_SUCCESS; +} + +void +_ScrollPanelPresenter::OnBoundsChanged(void) +{ + AdjustModel(); +} + +void +_ScrollPanelPresenter::OnChildAttached(const _Control& child) +{ + if (&child != __pScrollPanel->GetVerticalScrollBar() + && &child != __pScrollPanel->GetHorizontalScrollBar()) + { + if (__pScrollPanel->IsScrollAreaAutoResizingEnabled()) + { + UpdateLayout(); + } + + AdjustModel(); + + _AccessibilityContainer* pChildAccessibilityContainer = (const_cast<_Control&>(child)).GetAccessibilityContainer(); + pChildAccessibilityContainer->AddListener(*__pScrollPanel); + } + +} + +void +_ScrollPanelPresenter::OnChildDetached(const _Control& child) +{ + if (&child != __pScrollPanel->GetVerticalScrollBar() + && &child != __pScrollPanel->GetHorizontalScrollBar()) + { + if (__pScrollPanel->IsScrollAreaAutoResizingEnabled()) + { + UpdateLayout(); + } + + AdjustModel(); + + _AccessibilityContainer* pChildAccessibilityContainer = (const_cast<_Control&>(child)).GetAccessibilityContainer(); + pChildAccessibilityContainer->RemoveListener(*__pScrollPanel); + } + +} + +void +_ScrollPanelPresenter::OnChildBoundsChanged(const _Control& child) +{ + if (&child != __pScrollPanel->GetVerticalScrollBar() + && &child != __pScrollPanel->GetHorizontalScrollBar()) + { + AdjustModel(); + } +} + +void +_ScrollPanelPresenter::SetScrollPosition(int position, bool withAnimation) +{ + // change scroll position + if (withAnimation) + { + FadeInScrollBar(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + position = FixScrollPositionIntoScrollAreaBounds(position); + ScrollTo(position, withAnimation); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +int +_ScrollPanelPresenter::GetScrollPosition(void) const +{ + int scrollPosition = GetScrollPositionInternal(); + return FixScrollPositionIntoScrollAreaBounds(scrollPosition); +} + +int +_ScrollPanelPresenter::GetVerticalScrollPosition(void) const +{ + int scrollPosition = GetVerticalScrollPositionInternal(); + return FixScrollPositionIntoScrollAreaBounds(scrollPosition); +} + +void +_ScrollPanelPresenter::SetVerticalScrollPosition(int position) +{ + SetScrollPosition(position, true); +} + +int +_ScrollPanelPresenter::GetHorizontalScrollPosition(void) const +{ + int scrollPosition = GetHorizontalScrollPositionInternal(); + return FixScrollPositionIntoScrollAreaBounds(scrollPosition); +} + +void +_ScrollPanelPresenter::SetHorizontalScrollPosition(int position) +{ + SetScrollPosition(position, true); +} + +int +_ScrollPanelPresenter::GetScrollPositionInternal(void) const +{ + ScrollPanelScrollDirection scrollDirection = __pScrollPanel->GetScrollDirection(); + + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + return GetHorizontalScrollPositionInternal(); + } + else + { + return GetVerticalScrollPositionInternal(); + } +} + +void +_ScrollPanelPresenter::SetScrollPositionInternal(int position) +{ + ScrollPanelScrollDirection scrollDirection = __pScrollPanel->GetScrollDirection(); + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + SetHorizontalScrollPositionInternal(position); + } + else + { + SetVerticalScrollPositionInternal(position); + } +} + +int +_ScrollPanelPresenter::GetVerticalScrollPositionInternal(void) const +{ + return __pScrollPanelModel->GetCurrentVerticalScrollPosition(); +} + +void +_ScrollPanelPresenter::SetVerticalScrollPositionInternal(int position) +{ + __pScrollPanelModel->SetCurrentVerticalScrollPosition(position); +} + +int +_ScrollPanelPresenter::GetHorizontalScrollPositionInternal(void) const +{ + return __pScrollPanelModel->GetCurrentHorizontalScrollPosition(); +} + +void +_ScrollPanelPresenter::SetHorizontalScrollPositionInternal(int position) +{ + __pScrollPanelModel->SetCurrentHorizontalScrollPosition(position); +} + +void +_ScrollPanelPresenter::StopScrollingAnimation(void) +{ + __scrollAnimationRunning = false; + __pScrollPanel->GetVisualElement()->RemoveAnimation(SCROLLING_ANIMATION_NAME); +} + +int +_ScrollPanelPresenter::FixScrollPositionIntoScrollAreaBounds(int position) const +{ + return FixScrollPositionIntoScrollAreaBounds(position, __pScrollPanel->GetBounds(), GetScrollAreaBounds()); +} + +int +_ScrollPanelPresenter::FixScrollPositionIntoScrollAreaBounds(int position, Rectangle bounds, Rectangle scrollArea) const +{ + int minScrollPos = 0; + int maxScrollPos = 0; + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + minScrollPos = scrollArea.x; + maxScrollPos = scrollArea.x + scrollArea.width - bounds.width; + } + else + { + minScrollPos = scrollArea.y; + maxScrollPos = scrollArea.y + scrollArea.height - bounds.height; + } + position = position < minScrollPos ? minScrollPos : position; + position = position > maxScrollPos ? maxScrollPos : position; + + return position; +} + +void +_ScrollPanelPresenter::ScrollToTop(void) +{ + SetVerticalScrollPosition(GetScrollAreaBounds().y); +} + +void +_ScrollPanelPresenter::ScrollToBottom(void) +{ + SetVerticalScrollPosition(GetScrollAreaBounds().height - __pScrollPanel->GetBounds().height); +} + +void +_ScrollPanelPresenter::ScrollToLeft(void) +{ + SetHorizontalScrollPosition(GetScrollAreaBounds().x); +} + +void +_ScrollPanelPresenter::ScrollToRight(void) +{ + SetHorizontalScrollPosition(GetScrollAreaBounds().width - __pScrollPanel->GetBounds().width); +} + +result +_ScrollPanelPresenter::RunPreviewTouchPressed(const _Control& source, const _TouchInfo& touchInfo) +{ + result r = E_SUCCESS; + + // stop flick, stop scroll animation + if (__flickRunning || __scrollAnimationRunning) + { + StopScrollingAnimation(); + } + + __currentMovedPosition = touchInfo.GetCurrentPosition(); + __previousTouchedPosition = __currentMovedPosition; + __pPressedControl = &(const_cast<_Control&>(source)); + __subControlMoved = false; + __touchPressed = true; + __firstTouchMove = true; + + return r; +} + +result +_ScrollPanelPresenter::RunPreviewTouchMoved(const _Control& source, const _TouchInfo& touchInfo) +{ + if (__pPressedControl == &source && __touchPressed) + { + __previousTouchedPosition = __currentMovedPosition; + __currentMovedPosition = touchInfo.GetCurrentPosition(); + + if (__pScrollPanel != &source) + { + __subControlMoved = true; + } + + if (__firstTouchMove) + { + ScrollPanelScrollDirection scrollDirection = __pScrollPanel->GetScrollDirection(); + int scrollDistanceX = __previousTouchedPosition.x - __currentMovedPosition.x; + int scrollDistanceY = __previousTouchedPosition.y - __currentMovedPosition.y; + + if (abs(scrollDistanceY) < abs(scrollDistanceX)) + { + __firstScrollMoveDirection = SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL; + } + else if (abs(scrollDistanceY) > abs(scrollDistanceX)) + { + __firstScrollMoveDirection = SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL; + } + else + { + __firstScrollMoveDirection = scrollDirection; + } + + __firstTouchMove = false; + } + } + + return E_SUCCESS; +} + +result +_ScrollPanelPresenter::RunPreviewTouchReleased(const _Control& source, const _TouchInfo& touchInfo) +{ + result r = E_SUCCESS; + + if (__pPressedControl != &source) + { + return r; + } + + __touchPressed = false; + __firstTouchMove = true; + + if (__pScrollPanel->IsPageScrollEnabled() && !__flickRunning) + { + int currentPosition = 0; + int maxPosition = 0; + int pageSize = 0; + + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + pageSize = __pScrollPanel->GetPageScrollAlignSize().width; + maxPosition = GetScrollAreaBounds().width - pageSize; + currentPosition = GetHorizontalScrollPosition(); + } + else + { + pageSize = __pScrollPanel->GetPageScrollAlignSize().height; + maxPosition = GetScrollAreaBounds().height - pageSize; + currentPosition = GetVerticalScrollPosition(); + } + + int targetPosition = 0; + int pageGap = currentPosition % pageSize; + int lowerPageIndex = currentPosition / pageSize; + int currentPageMin = pageSize * lowerPageIndex; + int currentPageMax = currentPageMin + pageSize; + currentPageMin = currentPageMax > maxPosition ? (maxPosition / pageSize) * pageSize : currentPageMin; + currentPageMax = currentPageMax > maxPosition ? maxPosition : currentPageMax; + + if (pageGap <= currentPageMax - currentPageMin - pageGap) + { + targetPosition = currentPageMin; + } + else + { + targetPosition = currentPageMax; + } + + if (targetPosition != currentPosition) + { + SetScrollPosition(targetPosition, true); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + // scrollpanel child control touch released + if (__pScrollPanel != &source) + { + // for ScrollPanelEventListener + if (__subControlMoved) + { + __pScrollPanel->FireScrollPanelEvent(source, CORE_OTHER_CONTROL_SELECTED); + } + } + + __pPressedControl = null; + __subControlMoved = false; + + if (!__scrollAnimationRunning) + { + RollbackBouncing(true); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + FadeOutScrollBar(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__scrollOccured) + { + __scrollOccured = false; + __pScrollPanel->FireOnScrollStoppedEvent(); + } + } + + return r; +} + +result +_ScrollPanelPresenter::RunPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + result r = E_SUCCESS; + + if (__pPressedControl != &source) + { + return r; + } + + __touchPressed = false; + __firstTouchMove = true; + + __pPressedControl = null; + __subControlMoved = false; + + if (!__scrollAnimationRunning) + { + RollbackBouncing(true); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + FadeOutScrollBar(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (__scrollOccured && !__scrollAnimationRunning) + { + __scrollOccured = false; + __pScrollPanel->FireOnScrollStoppedEvent(); + } + + return r; +} + +_UiTouchEventDelivery +_ScrollPanelPresenter::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchInfo) +{ + result r = RunPreviewTouchPressed(source, touchInfo); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, _UI_TOUCH_EVENT_DELIVERY_YES, r, "[%s] Propagating.", GetErrorMessage(r)); + + return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES; +} + +_UiTouchEventDelivery +_ScrollPanelPresenter::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchInfo) +{ + RunPreviewTouchMoved(source, touchInfo); + + return _UI_TOUCH_EVENT_DELIVERY_YES; +} + +_UiTouchEventDelivery +_ScrollPanelPresenter::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchInfo) +{ + result r = RunPreviewTouchReleased(source, touchInfo); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, _UI_TOUCH_EVENT_DELIVERY_YES, r, "[%s] Propagating.", GetErrorMessage(r)); + + return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES; +} + +_UiTouchEventDelivery +_ScrollPanelPresenter::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchInfo) +{ + result r = RunPreviewTouchCanceled(source, touchInfo); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, _UI_TOUCH_EVENT_DELIVERY_YES, r, "[%s] Propagating.", GetErrorMessage(r)); + + return _UI_TOUCH_EVENT_DELIVERY_YES; +} + +bool +_ScrollPanelPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) +{ + if (__pScrollPanel != &source) + { + return false; + } + + result r = RunPreviewTouchPressed(source, touchInfo); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + return true; +} + +bool +_ScrollPanelPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) +{ + if (__pPressedControl != &source) + { + return false; + } + + if (!__touchPressed) + { + return false; + } + + if (!IsScrollable()) + { + return false; + } + + if (__currentMovedPosition != touchInfo.GetCurrentPosition()) + { + RunPreviewTouchMoved(source, touchInfo); + } + + // calculate move distance + ScrollPanelScrollDirection scrollDirection = __pScrollPanel->GetScrollDirection(); + ScrollInputMode scrollInputMode = __pScrollPanel->GetScrollInputMode(); + int scrollDistance = 0; + int scrollDistanceX = __previousTouchedPosition.x - __currentMovedPosition.x; + int scrollDistanceY = __previousTouchedPosition.y - __currentMovedPosition.y; + + if (scrollInputMode == SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION) + { + if (scrollDirection == __firstScrollMoveDirection) + { + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + scrollDistance = scrollDistanceX; + } + else if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL) + { + scrollDistance = scrollDistanceY; + } + } + else + { + RollbackBouncing(true); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + FadeOutScrollBar(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + if ((__firstScrollMoveDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL && abs(scrollDistanceY) > abs(scrollDistanceX)) + || (__firstScrollMoveDirection == SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL && abs(scrollDistanceY) < abs(scrollDistanceX))) + { + return true; + } + else + { + return false; + } + } + } + else + { + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + if (abs(scrollDistanceY) <= abs(scrollDistanceX)) + { + scrollDistance = scrollDistanceX; + } + else + { + return false; + } + } + else if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL) + { + if (abs(scrollDistanceY) >= abs(scrollDistanceX)) + { + scrollDistance = scrollDistanceY; + } + else + { + return false; + } + } + } + + if (scrollDistance != 0) + { + FadeInScrollBar(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + int realMoveDistance = ScrollTo(scrollDistance + GetScrollPositionInternal()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (realMoveDistance == 0) + { + // not moved and bubbling + if (scrollInputMode == SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION) + { + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + if (abs(scrollDistanceY) < abs(scrollDistanceX)) + { + return false; + } + else + { + return true; + } + } + else if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL) + { + if (abs(scrollDistanceY) > abs(scrollDistanceX)) + { + return false; + } + else + { + return true; + } + } + } + else + { + return false; + } + } + } + else + { + return true; + } + + return true; +} + +bool +_ScrollPanelPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) +{ + if (__pPressedControl != &source) + { + return false; + } + + if (__pScrollPanel != &source) + { + return false; + } + + result r = RunPreviewTouchReleased(source, touchInfo); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + return true; +} + +bool +_ScrollPanelPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo) +{ + if (__pPressedControl != &source) + { + return false; + } + + if (__pScrollPanel != &source) + { + return false; + } + + result r = RunPreviewTouchCanceled(source, touchInfo); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + return true; +} + +void +_ScrollPanelPresenter::OnTouchMoveHandled(const _Control& control) +{ + RollbackBouncing(true); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + FadeOutScrollBar(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_ScrollPanelPresenter::OnScrollEndReached(_Control& source, ScrollEndEvent type) +{ +} + +void +_ScrollPanelPresenter::OnScrollPositionChanged(_Control& source, int scrollPos) +{ + if (&source != __pScrollPanel->GetScrollBar()) + { + return; + } + + // JumpToTop + if (scrollPos == 0) + { + SetScrollPosition(scrollPos, true); + } + else + { + FadeInScrollBar(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetScrollPosition(scrollPos, false); + } +} + +bool +_ScrollPanelPresenter::DoFlickGestureRecognized(_TouchFlickGestureDetector& gesture) +{ + if (!IsScrollable()) + { + return false; + } + + Rectangle scrollArea = GetScrollAreaBounds(); + Rectangle scrollPanelBounds = __pScrollPanel->GetBounds(); + + int distanceX = 0; + int distanceY = 0; + gesture.GetDistance(distanceX, distanceY); + _FlickDirection moveDirection = gesture.GetDirection(); + + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + if (moveDirection != _FLICK_DIRECTION_RIGHT && moveDirection != _FLICK_DIRECTION_LEFT) + { + return false; + } + + if (distanceX < 0) + { + moveDirection = _FLICK_DIRECTION_LEFT; + } + else if (distanceX > 0) + { + moveDirection = _FLICK_DIRECTION_RIGHT; + } + } + else + { + if (moveDirection != _FLICK_DIRECTION_DOWN && moveDirection != _FLICK_DIRECTION_UP) + { + return false; + } + + if (distanceY < 0) + { + moveDirection = _FLICK_DIRECTION_UP; + } + else if (distanceY > 0) + { + moveDirection = _FLICK_DIRECTION_DOWN; + } + } + + if (__pScrollPanel->IsPageScrollEnabled() && __pScrollPanel->IsPageScrollFlickMoveLimitedOnePage()) + { + int targetPosition = 0; + int currentScrollPosition = GetScrollPosition(); + + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + int pageSize = __pScrollPanel->GetPageScrollAlignSize().width; + + // to right page + if (distanceX < 0) + { + targetPosition = currentScrollPosition - (currentScrollPosition % pageSize) + pageSize; + } + // to left page + else if (distanceX > 0) + { + targetPosition = currentScrollPosition - (currentScrollPosition % pageSize); + } + } + else + { + int pageSize = __pScrollPanel->GetPageScrollAlignSize().height; + + // to up page + if (distanceX < 0) + { + targetPosition = currentScrollPosition - (currentScrollPosition % pageSize) + pageSize; + } + // to down page + else if (distanceX > 0) + { + targetPosition = currentScrollPosition - (currentScrollPosition % pageSize); + } + } + + targetPosition = FixScrollPositionIntoScrollAreaBounds(targetPosition); + if (targetPosition == currentScrollPosition) + { + return false; + } + + __flickRunning = true; + + ScrollTo(targetPosition, true); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + FadeInScrollBar(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + return true; + } + else + { + int moveAmount = 0; + int flickAmount = 0; + + // calculate flick amount + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + flickAmount = CalculateFlickAmount(distanceX, gesture.GetDuration()); + } + else + { + flickAmount = CalculateFlickAmount(distanceY, gesture.GetDuration()); + } + + moveAmount = -flickAmount; + + // page align + if (__pScrollPanel->IsPageScrollEnabled()) + { + int scrollPosition = 0; + int maxPosition = 0; + int pageSize = 0; + + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + pageSize = __pScrollPanel->GetPageScrollAlignSize().width; + maxPosition = scrollArea.width - pageSize; + scrollPosition = __pScrollPanelModel->GetCurrentHorizontalScrollPosition(); + } + else + { + pageSize = __pScrollPanel->GetPageScrollAlignSize().height; + maxPosition = scrollArea.height - pageSize; + scrollPosition = __pScrollPanelModel->GetCurrentVerticalScrollPosition(); + } + + int pageGap = (scrollPosition + moveAmount) % pageSize; + int lowerPageIndex = (scrollPosition + moveAmount) / pageSize; + int targetPageMin = pageSize * lowerPageIndex; + int targetPageMax = targetPageMin + pageSize; + targetPageMin = targetPageMax > maxPosition ? (maxPosition / pageSize) * pageSize : targetPageMin; + targetPageMax = targetPageMax > maxPosition ? maxPosition : targetPageMax; + + if (pageGap <= targetPageMax - targetPageMin - pageGap) + { + moveAmount = targetPageMin - scrollPosition; + } + else + { + moveAmount = targetPageMax - scrollPosition; + } + } + + if (moveAmount != 0) + { + // scroll with animation + __flickRunning = true; + + __flickCount++; + if (__flickCount >= 3) + { + // flick finger gesture + if (__flickDirection != moveDirection) + { + StopFlickScrollEffectTimer(); + __flickCount++; + } + else + { + switch (__flickDirection) + { + case _FLICK_DIRECTION_UP: + ScrollToBottom(); + break; + case _FLICK_DIRECTION_DOWN: + ScrollToTop(); + break; + case _FLICK_DIRECTION_LEFT: + ScrollToRight(); + break; + case _FLICK_DIRECTION_RIGHT: + ScrollToLeft(); + break; + default: + break; + } + + return true; + } + } + + // normal flick + if (__flickCount == 1) + { + __flickDirection = moveDirection; + StartFlickScrollEffectTimer(); + } + else + { + if (__flickDirection != moveDirection) + { + StopFlickScrollEffectTimer(); + __flickCount++; + + __flickDirection = moveDirection; + StartFlickScrollEffectTimer(); + } + } + + // limited flick amount + int targetPosition = moveAmount + GetScrollPositionInternal(); + int scrollToPosition = FixScrollPositionIntoScrollAreaBounds(targetPosition); + if (abs(scrollToPosition - targetPosition) > SCROLL_PANEL_OVERSCROLLING_MAX_DISTANCCE) + { + switch (moveDirection) + { + case _FLICK_DIRECTION_UP: + targetPosition = scrollArea.height - scrollPanelBounds.height + SCROLL_PANEL_OVERSCROLLING_MAX_DISTANCCE; + break; + case _FLICK_DIRECTION_DOWN: + targetPosition = scrollArea.y - SCROLL_PANEL_OVERSCROLLING_MAX_DISTANCCE; + break; + case _FLICK_DIRECTION_LEFT: + targetPosition = scrollArea.width - scrollPanelBounds.width + SCROLL_PANEL_OVERSCROLLING_MAX_DISTANCCE; + break; + case _FLICK_DIRECTION_RIGHT: + targetPosition = scrollArea.x - SCROLL_PANEL_OVERSCROLLING_MAX_DISTANCCE; + break; + default: + break; + } + } + + ScrollTo(targetPosition, true); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + FadeInScrollBar(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + return true; + } + else + { + StopFlickScrollEffectTimer(); + + return false; + } + } +} + +bool +_ScrollPanelPresenter::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) +{ + return DoFlickGestureRecognized(gesture); +} + +bool +_ScrollPanelPresenter::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture) +{ + StopScrollingAnimation(); + RollbackBouncing(true); + + return false; +} + +bool +_ScrollPanelPresenter::IsControlOutOfView(const _Control& control) const +{ + Rectangle controlBounds = control.GetBounds(); + int scrollPos = __pScrollPanel->GetScrollPosition(); + + // is control out of view area + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + if (controlBounds.x < scrollPos || controlBounds.x + controlBounds.width > scrollPos + __pScrollPanel->GetBounds().width) + { + return true; + } + } + else + { + if (controlBounds.y < scrollPos || controlBounds.y + controlBounds.height > scrollPos + __pScrollPanel->GetBounds().height) + { + return true; + } + } + + return false; +} + +void +_ScrollPanelPresenter::ScrollToControlWhenOutOfView(const _Control& control) +{ + if (IsControlOutOfView(control)) + { + ScrollToControl(const_cast(control)); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } +} + +void +_ScrollPanelPresenter::RollbackBouncing(bool withAnimation) +{ + if (!IsScrollable()) + { + return; + } + + int scrollPosition = GetScrollPositionInternal(); + int fixedScrollPosition = FixScrollPositionIntoScrollAreaBounds(scrollPosition); + if (scrollPosition != fixedScrollPosition) + { + FadeInScrollBar(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + ScrollTo(fixedScrollPosition, withAnimation); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } +} + +bool +_ScrollPanelPresenter::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + const _Control& controlObj = control.GetOwner(); + ScrollToControlWhenOutOfView(controlObj); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + return false; +} + +bool +_ScrollPanelPresenter::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + const _Control& controlObj = control.GetOwner(); + ScrollToControlWhenOutOfView(controlObj); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + return false; +} + +bool +_ScrollPanelPresenter::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_ScrollPanelPresenter::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_ScrollPanelPresenter::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_ScrollPanelPresenter::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +void +_ScrollPanelPresenter::OnTimerExpired(Tizen::Base::Runtime::Timer& timer) +{ + if (&timer == __pScrollBarLoadEffectTimer) + { + __scrollBarFirstLoaded = false; + + StopScrollBarLoadEffectTimer(); + + FadeOutScrollBar(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (&timer == __pFlickScrollEffectTimer) + { + StopFlickScrollEffectTimer(); + } +} + +int +_ScrollPanelPresenter::CalculateFlickAmount(int flickDistance, int flickDuration) +{ + int flickAmount = ((((flickDistance * SCROLL_PANEL_FLICK_IN_PIXEL_UNIT) / flickDuration) * SCROLL_PANEL_FLICK_WEIGHT_VELOCITY) + (flickDistance * SCROLL_PANEL_FLICK_WEIGHT_DISTANCE)) / SCROLL_PANEL_FLICK_ALPHA_PER_PIXEL; + + return flickAmount; +} + +void +_ScrollPanelPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) +{ + // nothing +} + +void +_ScrollPanelPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) +{ + // nothing +} + +void +_ScrollPanelPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally) +{ + __scrollAnimationRunning = false; + __flickRunning = false; + + if (__scrollOccured) + { + __scrollOccured = false; + __pScrollPanel->FireOnScrollStoppedEvent(); + } + + if (completedNormally) + { + RollbackBouncing(true); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + int scrollPosition = GetScrollPositionInternal(); + int targetPosition = GetScrollPosition(); + if (scrollPosition != targetPosition) + { + ChangeScrollBarPosition(targetPosition); + SetScrollPositionInternal(targetPosition); + } + } + + FadeOutScrollBar(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_ScrollPanelPresenter::OnTickOccurred(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, const Variant& currentValue) +{ + _VisualElement* pVisualElement = __pScrollPanel->GetVisualElement(); + + if (&target != pVisualElement) + { + return; + } + + if (keyName == SCROLLING_ANIMATION_NAME) + { + if (!__scrollAnimationRunning) + { + return; + } + + ScrollToInternal(currentValue.ToInt()); + } +} + +void +_ScrollPanelPresenter::UpdateLayout(void) +{ + __pScrollPanel->PartialUpdateLayout(); +} + +void +_ScrollPanelPresenter::AdjustModel() +{ + _Scroll* pHorizontalScrollBar = __pScrollPanel->GetHorizontalScrollBar(); + _Scroll* pVerticalScrollBar = __pScrollPanel->GetVerticalScrollBar(); + + Rectangle scrollPanelBounds = __pScrollPanel->GetBounds(); + ScrollPanelScrollDirection scrollDirection = __pScrollPanel->GetScrollDirection(); + + + Rectangle scrollArea = Rectangle(0, 0, scrollPanelBounds.width, scrollPanelBounds.height); + + if (__pScrollPanel->IsScrollAreaAutoResizingEnabled()) + { + int count = __pScrollPanel->GetChildCount(); + + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL) + { + for (int i = 0; i < count; i++) + { + _Control* pControl = __pScrollPanel->GetChild(i); + SysTryReturnVoidResult(NID_UI_CTRL, pControl != null, E_SYSTEM, "[%s] pControl(child) is invalid pointer.", GetErrorMessage(E_SYSTEM)); + + if (pControl == pVerticalScrollBar || pControl == pHorizontalScrollBar) + { + continue; + } + + int targetMaxPos = pControl->GetBounds().GetBottomRight().y; + scrollArea.height = (scrollArea.height < targetMaxPos) ? targetMaxPos : scrollArea.height; + } + } + else if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + for (int i = 0; i < count; i++) + { + _Control* pControl = __pScrollPanel->GetChild(i); + SysTryReturnVoidResult(NID_UI_CTRL, pControl != null, E_SYSTEM, "[%s] pControl(child) is invalid pointer.", GetErrorMessage(E_SYSTEM)); + + if (pControl == pVerticalScrollBar || pControl == pHorizontalScrollBar) + { + continue; + } + + int targetMaxPos = pControl->GetBounds().GetBottomRight().x; + scrollArea.width = (scrollArea.width < targetMaxPos) ? targetMaxPos : scrollArea.width; + } + } + } + else + { + scrollArea = GetScrollAreaBounds(); + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + scrollArea.width = scrollArea.width < scrollPanelBounds.width ? scrollPanelBounds.width : scrollArea.width; + scrollArea.height = scrollPanelBounds.height; + } + else + { + scrollArea.width = scrollPanelBounds.width; + scrollArea.height = scrollArea.height < scrollPanelBounds.height ? scrollPanelBounds.height : scrollArea.height; + } + } + + // before change model ScrollPosition fix + int scrollPosition = GetScrollPosition(); + int fixedScrollPosition = FixScrollPositionIntoScrollAreaBounds(scrollPosition, scrollPanelBounds, scrollArea); + if (scrollPosition != fixedScrollPosition) + { + ScrollTo(fixedScrollPosition, false); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + // change model values + SetScrollAreaBoundsInternal(scrollArea); + Dimension alignSize = Dimension(scrollPanelBounds.width, scrollPanelBounds.height); + __pScrollPanel->SetPageScrollAlignSize(alignSize); + + // Adjust ScrollBar + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + if (scrollPanelBounds.width > 0 && scrollArea.width > scrollPanelBounds.width) + { + if (pHorizontalScrollBar != null) + { + pHorizontalScrollBar->OnParentBoundsChanged(); + + // update scrollbar range + ChangeScrollBarRange(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + SetScrollPosition(scrollArea.x, false); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + if (scrollPanelBounds.height > 0 && scrollArea.height > scrollPanelBounds.height) + { + if (pVerticalScrollBar != null) + { + pVerticalScrollBar->OnParentBoundsChanged(); + + // update scrollbar range + ChangeScrollBarRange(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + SetScrollPosition(scrollArea.y, false); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + if (!__scrollAnimationRunning) + { + FadeOutScrollBar(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } +} + +bool +_ScrollPanelPresenter::ScrollToControl(const _Control& source) +{ + if (__pScrollPanel->GetChildCount() == 0) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[%s] ScrollPanel have no child control.", GetErrorMessage(E_INVALID_ARG)); + return false; + } + + int validNum = __pScrollPanel->GetChildIndex(source); + + if (validNum == -1) + { + SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[%s] source is not a child control.", GetErrorMessage(E_INVALID_ARG)); + return false; + } + + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + //align source control to left position. + SetHorizontalScrollPosition(source.GetBounds().x); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + //align source control to top position. + SetVerticalScrollPosition(source.GetBounds().y); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return true; +} + +int +_ScrollPanelPresenter::ScrollTo(int targetPosition) +{ + return ScrollTo(targetPosition, false); +} + + +int +_ScrollPanelPresenter::ScrollTo(int targetPosition, bool withAnimation) +{ + StopScrollingAnimation(); + + if (withAnimation) + { + // Calculate real move distance + int scrollToPosition = FixScrollPositionIntoScrollAreaBounds(targetPosition); + + int oldPosition = GetScrollPositionInternal(); + VisualElementValueAnimation* pScrollingAnimation = __pScrollPanel->GetScrollingAnimation(); + pScrollingAnimation->SetStartValue(Variant(oldPosition)); + pScrollingAnimation->SetEndValue(Variant(targetPosition)); + pScrollingAnimation->SetDuration(SCROLL_PANEL_SCROLLING_ANIMATION_DURATION); + _VisualElement* pVisualElement = __pScrollPanel->GetVisualElement(); + __scrollAnimationRunning = true; + pVisualElement->AddAnimation(SCROLLING_ANIMATION_NAME, *pScrollingAnimation); + + return scrollToPosition - oldPosition; + } + else + { + return ScrollToInternal(targetPosition); + } +} + + +int +_ScrollPanelPresenter::ScrollToInternal(int targetPosition) +{ + ScrollPanelScrollDirection scrollDirection = __pScrollPanel->GetScrollDirection(); + _VisualElement* pVisualElement = __pScrollPanel->GetVisualElement(); + int previousScrollPosition = GetScrollPositionInternal(); + int distance = 0; + FloatPoint floatPointDistance; + + int scrollToPosition = FixScrollPositionIntoScrollAreaBounds(targetPosition); + + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + distance = scrollToPosition - FixScrollPositionIntoScrollAreaBounds(previousScrollPosition); + floatPointDistance.SetPosition(-distance, 0.0f); + } + else + { + distance = scrollToPosition - FixScrollPositionIntoScrollAreaBounds(previousScrollPosition); + floatPointDistance.SetPosition(0.0f, -distance); + } + + if (distance != 0) + { + result r = pVisualElement->ScrollByPoint(floatPointDistance, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, 0, r, "[%s] Propagating.", GetErrorMessage(r)); + + __scrollOccured = true; + } + + ChangeScrollBarPosition(targetPosition); + SetScrollPositionInternal(targetPosition); + + if (distance != 0) + { + Rectangle scrollPanelBounds = __pScrollPanel->GetBounds(); + Rectangle scrollArea = GetScrollAreaBounds(); + + if (scrollDirection == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + if (scrollArea.width > scrollPanelBounds.width) + { + int minScrollPos = scrollArea.x; + int maxScrollPos = scrollArea.width - scrollPanelBounds.width; + + if ((targetPosition >= minScrollPos && targetPosition <= maxScrollPos) + || (previousScrollPosition > minScrollPos || previousScrollPosition < maxScrollPos)) + { + __pScrollPanel->FireOnScrollPositionChangedEvent(); + } + + if (previousScrollPosition > minScrollPos && previousScrollPosition < maxScrollPos) + { + if (targetPosition <= minScrollPos) + { + __pScrollPanel->FireOnScrollEndEvent(SCROLL_END_EVENT_END_LEFT); + } + else if (targetPosition >= maxScrollPos) + { + __pScrollPanel->FireOnScrollEndEvent(SCROLL_END_EVENT_END_RIGHT); + } + } + } + } + else + { + if (scrollArea.height > scrollPanelBounds.height) + { + int minScrollPos = scrollArea.y; + int maxScrollPos = scrollArea.height - scrollPanelBounds.height; + + if ((targetPosition >= minScrollPos && targetPosition <= maxScrollPos) + || (previousScrollPosition > minScrollPos || previousScrollPosition < maxScrollPos)) + { + __pScrollPanel->FireOnScrollPositionChangedEvent(); + } + + if (previousScrollPosition > minScrollPos && previousScrollPosition < maxScrollPos) + { + if (targetPosition <= minScrollPos) + { + __pScrollPanel->FireOnScrollEndEvent(SCROLL_END_EVENT_END_TOP); + } + else if (targetPosition >= maxScrollPos) + { + __pScrollPanel->FireOnScrollEndEvent(SCROLL_END_EVENT_END_BOTTOM); + } + } + } + } + } + + return distance; +} + +void +_ScrollPanelPresenter::ChangeScrollBarPosition(int position) +{ + _Scroll* pScrollBar = __pScrollPanel->GetScrollBar(); + + if (pScrollBar != null && __pScrollPanel->IsAncestorOf(*pScrollBar)) + { + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + result r = pScrollBar->SetScrollPosition(position); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + result r = pScrollBar->SetScrollPosition(position); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } +} + +void +_ScrollPanelPresenter::ChangeScrollBarRange(void) +{ + _Scroll* pScrollBar = __pScrollPanel->GetScrollBar(); + + if (pScrollBar != null) + { + int viewRange = 0; + int scrollRange = 0; + + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + viewRange = __pScrollPanel->GetBounds().width; + scrollRange = GetScrollAreaBounds().width; + } + else + { + viewRange = __pScrollPanel->GetBounds().height; + scrollRange = GetScrollAreaBounds().height; + } + + if (viewRange <= scrollRange) + { + result r = pScrollBar->SetScrollRange(viewRange, scrollRange); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (viewRange != scrollRange && __scrollBarFirstLoaded) + { + FadeInScrollBar(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + StartScrollBarLoadEffectTimer(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + } +} + +void +_ScrollPanelPresenter::StartScrollBarLoadEffectTimer(void) +{ + result r = E_SUCCESS; + + if (__pScrollBarLoadEffectTimer == null) + { + __pScrollBarLoadEffectTimer = new (std::nothrow) Tizen::Base::Runtime::Timer; + SysTryReturnVoidResult(NID_UI_CTRL, __pScrollBarLoadEffectTimer != null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient", GetErrorMessage(E_OUT_OF_MEMORY)); + + r = __pScrollBarLoadEffectTimer->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pScrollBarLoadEffectTimer->Start(SCROLL_PANEL_SCROLL_BAR_LOAD_EFFECT_TIMER_DURATION); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return; + +CATCH: + delete __pScrollBarLoadEffectTimer; + __pScrollBarLoadEffectTimer = null; + + SetLastResult(r); +} + +void +_ScrollPanelPresenter::StopScrollBarLoadEffectTimer(void) +{ + delete __pScrollBarLoadEffectTimer; + __pScrollBarLoadEffectTimer = null; +} + +void +_ScrollPanelPresenter::StartFlickScrollEffectTimer(void) +{ + result r = E_SUCCESS; + + if (__pFlickScrollEffectTimer == null) + { + __pFlickScrollEffectTimer = new (std::nothrow) Tizen::Base::Runtime::Timer; + SysTryReturnVoidResult(NID_UI_CTRL, __pFlickScrollEffectTimer != null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient", GetErrorMessage(E_OUT_OF_MEMORY)); + + r = __pFlickScrollEffectTimer->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pFlickScrollEffectTimer->Start(SCROLL_PANEL_FLICK_SCROLL_EFFECT_TIMER_DURATION); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return; + +CATCH: + delete __pFlickScrollEffectTimer; + __pFlickScrollEffectTimer = null; + + SetLastResult(r); +} + +void +_ScrollPanelPresenter::StopFlickScrollEffectTimer(void) +{ + __flickCount = 0; + __flickDirection = _FLICK_DIRECTION_NONE; + + delete __pFlickScrollEffectTimer; + __pFlickScrollEffectTimer = null; +} + +void +_ScrollPanelPresenter::FadeOutScrollBar(void) +{ + if (!__scrollAnimationRunning && !__scrollBarFirstLoaded) + { + _Scroll* pScrollBar = __pScrollPanel->GetScrollBar(); + if (pScrollBar != null) + { + if (!pScrollBar->IsEnabledHandler()) + { + result r = pScrollBar->SetScrollVisibility(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + result r = pScrollBar->SetScrollingEffectVisibility(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } +} + +void +_ScrollPanelPresenter::StopFadeOutScrollBar(void) +{ + _Scroll* pScrollBar = __pScrollPanel->GetScrollBar(); + + if (pScrollBar != null) + { + pScrollBar->CancelFadeEffect(); + } +} + +void +_ScrollPanelPresenter::FadeInScrollBar(void) +{ + if (!IsScrollable()) + { + return; + } + + _Scroll* pScrollBar = __pScrollPanel->GetScrollBar(); + + if (pScrollBar != null) + { + if (__pScrollPanel->IsScrollBarVisible()) + { + result r = pScrollBar->SetScrollVisibility(true); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + result r = pScrollBar->SetScrollingEffectVisibility(true); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } +} + +bool +_ScrollPanelPresenter::IsScrollable(void) const +{ + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + return __pScrollPanel->GetBounds().width >0 && __pScrollPanel->GetBounds().width < GetScrollAreaBounds().width; + } + else + { + return __pScrollPanel->GetBounds().height > 0 && __pScrollPanel->GetBounds().height < GetScrollAreaBounds().height; + } +} + +Rectangle +_ScrollPanelPresenter::GetScrollAreaBounds(void) const +{ + return __pScrollPanelModel->GetScrollAreaBounds(); +} + +result +_ScrollPanelPresenter::SetClientAreaHeight(int height) +{ + SysTryReturn(NID_UI_CTRL, __pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] The height of the client area cannot be set when the scroll direction is horizontal.", GetErrorMessage(E_INVALID_OPERATION)); + Rectangle bounds = GetScrollAreaBounds(); + bounds.height = height; + + return SetScrollAreaBounds(bounds); +} + +result +_ScrollPanelPresenter::SetClientAreaWidth(int width) +{ + SysTryReturn(NID_UI_CTRL, __pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL, E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] The width of the client area cannot be set when the scroll direction is vertical.", GetErrorMessage(E_INVALID_OPERATION)); + Rectangle bounds = GetScrollAreaBounds(); + bounds.width = width; + + return SetScrollAreaBounds(bounds); +} + +void +_ScrollPanelPresenter::SetScrollAreaBoundsInternal(Rectangle& bounds) +{ + if (__pScrollPanel->IsFixingClientBoundsEnable()) + { + __pScrollPanel->SetClientBounds(bounds); + } + __pScrollPanelModel->SetScrollAreaBounds(bounds); +} + +result +_ScrollPanelPresenter::SetScrollAreaBounds(Rectangle& bounds) +{ + SysTryReturn(NID_UI_CTRL, !__pScrollPanel->IsScrollAreaAutoResizingEnabled(), E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] The width of the client area cannot be set when auto resizing of the client area is off.", GetErrorMessage(E_INVALID_OPERATION)); + + bounds.x = 0; + bounds.y = 0; + + if (__pScrollPanel->GetScrollDirection() == SCROLL_PANEL_SCROLL_DIRECTION_HORIZONTAL) + { + SysTryReturn(NID_UI_CTRL, __pScrollPanel->GetBounds().width <= bounds.width, E_INVALID_ARG, E_INVALID_ARG, "[%s] width is less than the width of ScrollPanel", GetErrorMessage(E_INVALID_ARG)); + bounds.height = __pScrollPanel->GetBounds().height; + } + else + { + SysTryReturn(NID_UI_CTRL, __pScrollPanel->GetBounds().height <= bounds.height, E_INVALID_ARG, E_INVALID_ARG, "[%s] height is less than the height of ScrollPanel", GetErrorMessage(E_INVALID_ARG)); + bounds.width = __pScrollPanel->GetBounds().width; + } + + // before change model ScrollPosition fix + Rectangle scrollPanelBounds = __pScrollPanel->GetBounds(); + int scrollPosition = GetScrollPosition(); + int fixedScrollPosition = FixScrollPositionIntoScrollAreaBounds(scrollPosition, scrollPanelBounds, bounds); + if (scrollPosition != fixedScrollPosition) + { + ScrollTo(fixedScrollPosition, false); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + SetScrollAreaBoundsInternal(bounds); + + AdjustModel(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +const _Control* +_ScrollPanelPresenter::GetPressedControl(void) const +{ + return __pPressedControl; +} + +Point +_ScrollPanelPresenter::GetPreviousTouchPosition(void) const +{ + return __previousTouchedPosition; +} + +Point +_ScrollPanelPresenter::GetCurrentTouchPosition(void) const +{ + return __currentMovedPosition; +} + +bool +_ScrollPanelPresenter::IsScrollAnimationRunning(void) const +{ + return __scrollAnimationRunning; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_ScrollPresenter.cpp b/src/ui/controls/FUiCtrl_ScrollPresenter.cpp new file mode 100644 index 0000000..5bf0861 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ScrollPresenter.cpp @@ -0,0 +1,2548 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollPresenter.cpp + * @brief This is the implementation file for the %_ScrollPresenter class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUiAnim_TransformMatrix3Df.h" +#include "FUiAnim_MatrixUtil.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_ScrollPresenter.h" +#include "FUiCtrl_UiScrollEvent.h" +#include "FUiCtrl_UiScrollEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace +{ +const float SCROLL_OPACITY_ON = 1.0f; +const float SCROLL_OPACITY_DARK_DIM =0.6f; +const float SCROLL_OPACITY_LIGHT_DIM = 0.3f; +const float SCROLL_OPACITY_OFF = 0.0f; +const float SCROLLING_EFFECT_MAX_POSITION = 100.0f; +const float SCROLLING_EFFECT_MIN_SCALE_RATE = 0.95f; +} + +namespace Tizen { namespace Ui { namespace Controls +{ + +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +_ScrollPresenter::_ScrollPresenter(void) + : __pParentCtrl(null) + , __pScrollCtrl(null) + , __scrollDirection(SCROLL_DIRECTION_VERTICAL) + , __enableFadeEffect(false) + , __enableJumpToTop(false) + , __enableHandler(false) + , __enableScrollingEffect(false) + , __enableOverScrollingEffect(false) + , __parentUsingViewport(true) + , __positionMin(0) + , __positionMax(0) + , __viewRange(0) + , __scrollRange(0) + , __scrollPositionCurr(0) + , __scrollPositionPrev(0) + , __fadeIn(false) + , __fadeOut(false) + , __scrollVisibility(false) + , __scrollingEffectVisibility(false) + , __parentBouncingRate(0.0f) + , __fadeEffectDuration_ms(5000) + , __needUpdateThumb(false) + , __needUpdateJumpTopTop(false) + , __needUpdateHandler(false) + , __needUpdateScrollingEffect(false) + , __handlerTouched(false) + , __handlerTouchedPosition(0) + , __jumpToTopPressed(false) + , __pScrollEvent(null) + , __pCtrlVe(null) + , __pThumbVe(null) + , __pJumpToTopVe(null) + , __pHandlerVe(null) + , __pFrontScrollingEffectVe(null) + , __pReerScrollingEffectVe(null) + , __thumbColor(0x00000000) + , __jumpToTopBgColor(0x00000000) + , __jumpToTopColor(0x00000000) + , __jumpToTopColorPressed(0x00000000) + , __buttonColor(0x00000000) + , __buttonColorPressed(0x00000000) + , __pThumbBitmap(null) + , __pThumbEffectBitmap(null) + , __pJumpToTopBitmap(null) + , __pJumpToTopEfBitmap(null) + , __pJumpToTopLeftBitmap(null) + , __pJumpToTopLeftEfBitmap(null) + , __pButtonBitmap(null) + , __pButtonEfBitmap(null) + , __pButtonPressBitmap(null) + , __pHandlerBgBitmap(null) + , __pHandlerBgEffectBitmap(null) + , __pHandlerBitmap(null) + , __pFrontScrollingEffectBitmap(null) + , __pReerScrollingEffectBitmap(null) + , __thumbSizeMin(0, 0) + , __thumbMargin(0) + , __jumpToTopSize(0, 0) + , __jumpToTopMarginRight(0) + , __jumpToTopMarginTop(0) + , __handlerSizeMin(0, 0) + , __handlerMarginLeft(0) + , __handlerMarginRight(0) + , __handlerMarginTop(0) + , __handlerMarginBottom(0) + , __scrollingEffectWidthLeft(0) + , __scrollingEffectWidthRight(0) + , __scrollingEffectHeightTop(0) + , __scrollingEffectHeightBottom(0) + , __beforeBouncingMatrixHash() +{ +} + +_ScrollPresenter::~_ScrollPresenter(void) +{ + delete __pScrollEvent; + __pScrollEvent = null; + + __beforeBouncingMatrixHash.RemoveAll(true); + + if (__pThumbVe != null) + { + __pThumbVe->Destroy(); + __pThumbVe = null; + } + + if (__pJumpToTopVe != null) + { + __pJumpToTopVe->Destroy(); + __pJumpToTopVe = null; + } + + if (__pHandlerVe != null) + { + __pHandlerVe->Destroy(); + __pHandlerVe = null; + } + + if (__pFrontScrollingEffectVe != null) + { + __pFrontScrollingEffectVe->RemoveAllAnimations(); + __pFrontScrollingEffectVe->Destroy(); + __pFrontScrollingEffectVe = null; + } + + if (__pReerScrollingEffectVe != null) + { + __pReerScrollingEffectVe->RemoveAllAnimations(); + __pReerScrollingEffectVe->Destroy(); + __pReerScrollingEffectVe = null; + } + + if (__pCtrlVe != null) + { + __pCtrlVe->RemoveAllAnimations(); + __pCtrlVe->SetAnimationProvider(null); + __pCtrlVe->Destroy(); + __pCtrlVe = null; + } + + ReleaseBitmapResources(); +} + +_ScrollPresenter* +_ScrollPresenter::CreateScrollPresenterN(_Control& parentCtrl, + _Scroll& scrollCtrl, + _ScrollDirection scrollDirection, + bool enableFadeEffect, + bool enableJumpToTop, + bool enableHandler, + bool visibility, + int viewRange, + int scrollRange, + int scrollPosition) +{ + SysTryReturn(NID_UI_CTRL, ((scrollRange >= viewRange) && (scrollRange != 0)), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid arguments"); + SysTryReturn(NID_UI_CTRL, scrollPosition >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid arguments"); + + _ScrollPresenter* pPresenter = new (std::nothrow) _ScrollPresenter(); + SysTryReturn(NID_UI_CTRL, pPresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pPresenter->Construct(parentCtrl, + scrollCtrl, + scrollDirection, + enableFadeEffect, + enableJumpToTop, + enableHandler, + visibility, + viewRange, + scrollRange, + scrollPosition); + + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetLastResult(E_SUCCESS); + return pPresenter; + +CATCH: + delete pPresenter; + + return null; +} + +result +_ScrollPresenter::SetScrollDirection(_ScrollDirection scrollDirection) +{ + result r = E_SUCCESS; + + // load color/shape configuration and bitmap resources + r = LoadResources(scrollDirection, _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to load resources."); + + // reset attributes + __scrollDirection = scrollDirection; + + // reset the bounds of scroll control + Rectangle bounds = GetParentCtrl().GetBounds(); + bounds.SetPosition(0, 0); + r = GetControl().SetBounds(bounds); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _Scroll."); + + // relayout scroll children. + r = RelayoutScrollChildren(__scrollDirection); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to relayout scroll chilren"); + + return E_SUCCESS; +} + +_ScrollDirection +_ScrollPresenter::GetScrollDirection(void) const +{ + return __scrollDirection; +} + +result +_ScrollPresenter::SetScrollRange(int viewRange, int scrollRange) +{ + SysTryReturn(NID_UI_CTRL, ((scrollRange >= viewRange) && (scrollRange != 0)), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid arguments"); + + result r = E_SUCCESS; + + // reset scroll range. + __viewRange = viewRange; + __scrollRange = scrollRange; + + // relayout scroll children. + r = RelayoutScrollChildren(__scrollDirection); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to relayout scroll chilren"); + + return E_SUCCESS; + +} + +void +_ScrollPresenter::GetScrollRange(int* pViewRange, int* pScrollRange) const +{ + SysTryReturnVoidResult(NID_UI_CTRL, + !((pViewRange == null) && (pScrollRange == null)), + E_INVALID_ARG,"[E_INVALID_ARG] Input parameter is invalid."); + + *pViewRange = __viewRange; + *pScrollRange = __scrollRange; + + return; +} + +result +_ScrollPresenter::SetScrollPosition(int scrollPosition) +{ + result r = E_SUCCESS; + + if (scrollPosition != __scrollPositionCurr) + { + + if (!__enableScrollingEffect) + { + if (scrollPosition < 0) + { + scrollPosition = 0; + } + else if (scrollPosition > (__scrollRange - __viewRange)) + { + scrollPosition = (__scrollRange -__viewRange); + } + } + __scrollPositionPrev = __scrollPositionCurr; + __scrollPositionCurr = scrollPosition; + + if (__enableJumpToTop) + { + if ((__scrollPositionCurr <= 0) && (__pJumpToTopVe->GetOpacity() > 0.0f)) + { + __pCtrlVe->SetImplicitAnimationEnabled(true); + __pJumpToTopVe->SetImplicitAnimationEnabled(true); + + __pJumpToTopVe->SetOpacity(SCROLL_OPACITY_OFF); + + __pJumpToTopVe->SetImplicitAnimationEnabled(false); + __pCtrlVe->SetImplicitAnimationEnabled(false); + } + else if ((__scrollPositionCurr > 0) && (__pJumpToTopVe->GetOpacity() < 1.0f)) + { + __pCtrlVe->SetImplicitAnimationEnabled(true); + __pJumpToTopVe->SetImplicitAnimationEnabled(true); + + __pJumpToTopVe->SetOpacity(SCROLL_OPACITY_ON); + + __pJumpToTopVe->SetImplicitAnimationEnabled(false); + __pCtrlVe->SetImplicitAnimationEnabled(false); + } + // else keep up current visibility. + + } + + if (__enableHandler) + { + Point handlerPosition = CalculateHandlerPosition(__scrollDirection); + Rectangle handlerBounds(handlerPosition.x, handlerPosition.y, __pHandlerVe->GetBounds().width, __pHandlerVe->GetBounds().height); + FloatRectangle scrollCtrlBounds = __pCtrlVe->GetBounds(); + if (__scrollDirection == SCROLL_DIRECTION_HORIZONTAL) + { + if (handlerPosition.x < 0) + { + handlerBounds.x = 0; + } + else if (handlerPosition.x > scrollCtrlBounds.width - handlerBounds.width) + { + handlerBounds.x =scrollCtrlBounds.width - handlerBounds.width; + } + } + else + { + if (handlerPosition.y < 0) + { + handlerBounds.y = 0; + } + else if (handlerPosition.y > scrollCtrlBounds.height - handlerBounds.height) + { + handlerBounds.y = scrollCtrlBounds.height - handlerBounds.height; + } + } + + r = SetScrollChildBounds(*__pHandlerVe, handlerBounds); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of the __pHandlerVe"); + } + else + { + Point thumbPosition = CalculateThumbPosition(__scrollDirection); + Rectangle thumbBounds(thumbPosition.x, thumbPosition.y, __pThumbVe->GetBounds().width, __pThumbVe->GetBounds().height); + FloatRectangle scrollCtrlBounds = __pCtrlVe->GetBounds(); + if (__scrollDirection == SCROLL_DIRECTION_HORIZONTAL) + { + if (thumbPosition.x < 0) + { + thumbBounds.x = 0; + } + else if (thumbPosition.x > scrollCtrlBounds.width - thumbBounds.width) + { + thumbBounds.x = scrollCtrlBounds.width - thumbBounds.width; + } + } + else + { + if (thumbPosition.y < 0) + { + thumbBounds.y = 0; + } + else if (thumbPosition.y > scrollCtrlBounds.height - thumbBounds.height) + { + thumbBounds.y = scrollCtrlBounds.height - thumbBounds.height; + } + } + + r = SetScrollChildBounds(*__pThumbVe, thumbBounds); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of the __pThumbVe"); + } + + if (__enableScrollingEffect || __enableOverScrollingEffect) + { + float ratio = 0.0f; + if (__scrollPositionCurr < 0) + { + ratio = -__scrollPositionCurr / SCROLLING_EFFECT_MAX_POSITION; + ratio = ratio > 1.0f ? 1.0f : ratio; + + if (__enableScrollingEffect) + { + SetScrollingEffectOpacity(*__pFrontScrollingEffectVe, true, ratio); + SetScrollingEffectOpacity(*__pReerScrollingEffectVe, false, ratio); + } + + __scrollingEffectVisibility = true; + } + else if (__scrollPositionCurr > (__scrollRange - __viewRange)) + { + ratio = (__scrollPositionCurr - (__scrollRange - __viewRange)) / SCROLLING_EFFECT_MAX_POSITION; + ratio = ratio > 1.0f ? 1.0f : ratio; + + if (__enableScrollingEffect) + { + SetScrollingEffectOpacity(*__pFrontScrollingEffectVe, false, ratio); + SetScrollingEffectOpacity(*__pReerScrollingEffectVe, true, ratio); + } + + __scrollingEffectVisibility = true; + } + + if (__enableOverScrollingEffect) + { + r = SetParentBouncing(ratio); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + } + + return r; +} + +int +_ScrollPresenter::GetScrollPosition(void) const +{ + return __scrollPositionCurr; +} + +void +_ScrollPresenter::EnableFadeEffect(bool enable) +{ + __enableFadeEffect = enable; + + return; +} + +bool +_ScrollPresenter::IsEnabledFadeEffect(void) const +{ + return __enableFadeEffect; +} + +bool +_ScrollPresenter::IsOnFadeEffect(void) const +{ + return (__fadeIn || __fadeOut); +} + +void +_ScrollPresenter::EnableScrollingEffect(bool enable) +{ + __enableScrollingEffect = enable; +} + +bool +_ScrollPresenter::IsEnabledScrollingEffect(void) const +{ + return __enableScrollingEffect; +} + +void +_ScrollPresenter::EnableOverScrollingEffect(bool enable) +{ + __enableOverScrollingEffect = enable; +} + +bool +_ScrollPresenter::IsEnabledOverScrollingEffect(void) const +{ + return __enableOverScrollingEffect; +} + +void +_ScrollPresenter::SetParentUsingViewport(bool useViewPort) +{ + __parentUsingViewport = useViewPort; +} + +bool +_ScrollPresenter::IsParentUsingViewport(void) const +{ + return __parentUsingViewport; +} + +result +_ScrollPresenter::SetScrollVisibility(bool visibility) +{ + if (GetScrollVisibility() == visibility) + { + // keep up current visibility. + return E_SUCCESS; + } + + __pCtrlVe->RemoveAllAnimations(); + if (visibility) + { + if (__enableFadeEffect) + { + __fadeIn = true; + __fadeOut = false; + + __pCtrlVe->SetImplicitAnimationEnabled(true); + } + + __pCtrlVe->SetOpacity(SCROLL_OPACITY_ON); + + if (__enableFadeEffect) + { + __pCtrlVe->SetImplicitAnimationEnabled(false); + } + else + { + __fadeIn = false; + __fadeOut = false; + } + } + else + { + if (__enableFadeEffect) + { + __fadeIn = false; + __fadeOut = true; + + __pCtrlVe->SetImplicitAnimationEnabled(true); + } + + __pCtrlVe->SetOpacity(SCROLL_OPACITY_OFF); + + if (__enableFadeEffect) + { + __pCtrlVe->SetImplicitAnimationEnabled(false); + } + else + { + __fadeIn = false; + __fadeOut = false; + } + } + + __scrollVisibility = visibility; + + return E_SUCCESS; +} + +bool +_ScrollPresenter::GetScrollVisibility(void) const +{ + if (__enableFadeEffect) + { + if (__scrollVisibility) + { + return true; + } + } + else if (__pCtrlVe->GetOpacity() > SCROLL_OPACITY_OFF) + { + return true; + } + + return false; +} + +void +_ScrollPresenter::CancelFadeEffect(void) +{ + if (__fadeIn) + { + __fadeIn = false; + __scrollVisibility = false; + __pCtrlVe->SetOpacity(SCROLL_OPACITY_OFF); + } + else if (__fadeOut) + { + __fadeOut = false; + __scrollVisibility = true; + __pCtrlVe->SetOpacity(SCROLL_OPACITY_ON); + } + + return; +} + +result +_ScrollPresenter::EnableJumpToTop(bool enable) +{ + result r = E_SUCCESS; + + if (__enableJumpToTop != enable) + { + if (enable) + { + if (__enableFadeEffect) + { + __pCtrlVe->SetImplicitAnimationEnabled(true); + } + + r = AttachScrollChild(&__pJumpToTopVe, CalculateJumpToTopBounds(__scrollDirection), true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to attach the __pJumpToTopVe to _Scroll"); + + if (__scrollPositionCurr != 0) + { + __pJumpToTopVe->SetOpacity(SCROLL_OPACITY_ON); + } + else + { + __pJumpToTopVe->SetOpacity(SCROLL_OPACITY_OFF); + } + + if (__enableFadeEffect) + { + __pCtrlVe->SetImplicitAnimationEnabled(false); + } + } + else + { + DetachScrollChild(&__pJumpToTopVe, true); + } + + __enableJumpToTop = enable; + } + + return E_SUCCESS; + +} + +bool +_ScrollPresenter::IsEnabledJumpToTop(void) const +{ + return __enableJumpToTop; +} + +result +_ScrollPresenter::EnableHandler(bool enable) +{ + result r = E_SUCCESS; + + if (__enableHandler != enable) + { + if (__enableFadeEffect) + { + __pCtrlVe->SetImplicitAnimationEnabled(true); + } + + if (enable) + { + r = AttachScrollChild(&__pHandlerVe, CalculateHandlerBounds(__scrollDirection), true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to attach the __pHandlerVe to _Scroll"); + + DetachScrollChild(&__pThumbVe, true); + } + else + { + r = AttachScrollChild(&__pThumbVe, CalculateThumbBounds(__scrollDirection), true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to attach the __pThumbVe to _Scroll"); + + DetachScrollChild(&__pHandlerVe, true); + } + __enableHandler = enable; + + if (__enableFadeEffect) + { + __pCtrlVe->SetImplicitAnimationEnabled(false); + } + } + + return E_SUCCESS; +} + +bool +_ScrollPresenter::IsEnabledHandler(void) const +{ + return __enableHandler; +} + +result +_ScrollPresenter::SetScrollingEffectVisibility(bool visibility) +{ + if (!__enableScrollingEffect) + { + visibility = false; + } + + if (__scrollingEffectVisibility == visibility) + { + // keep up current visibility. + return E_SUCCESS; + } + + if (__pFrontScrollingEffectVe == null || __pReerScrollingEffectVe == null) + { + return E_SUCCESS; + } + + __pFrontScrollingEffectVe->RemoveAllAnimations(); + __pReerScrollingEffectVe->RemoveAllAnimations(); + + if (visibility) + { + if (__enableFadeEffect) + { + __pFrontScrollingEffectVe->SetImplicitAnimationEnabled(true); + __pReerScrollingEffectVe->SetImplicitAnimationEnabled(true); + } + + SetScrollingEffectOpacity(SCROLL_OPACITY_DARK_DIM); + + if (__enableFadeEffect) + { + __pFrontScrollingEffectVe->SetImplicitAnimationEnabled(false); + __pReerScrollingEffectVe->SetImplicitAnimationEnabled(false); + } + } + else + { + if (__enableFadeEffect) + { + __pFrontScrollingEffectVe->SetImplicitAnimationEnabled(true); + __pReerScrollingEffectVe->SetImplicitAnimationEnabled(true); + } + + SetScrollingEffectOpacity(SCROLL_OPACITY_OFF); + + if (__enableFadeEffect) + { + __pFrontScrollingEffectVe->SetImplicitAnimationEnabled(false); + __pReerScrollingEffectVe->SetImplicitAnimationEnabled(false); + } + } + + __scrollingEffectVisibility = visibility; + + return E_SUCCESS; +} + +void +_ScrollPresenter::SetScrollingEffectOpacity(float opacity) +{ + __pFrontScrollingEffectVe->SetOpacity(opacity); + __pReerScrollingEffectVe->SetOpacity(opacity); +} + +void +_ScrollPresenter::SetScrollingEffectOpacity(_VisualElement& Ve, bool isActive, float ratio) +{ + float baseOpacity = (isActive) ? SCROLL_OPACITY_ON : SCROLL_OPACITY_LIGHT_DIM; + Ve.SetOpacity(SCROLL_OPACITY_DARK_DIM + ((baseOpacity - SCROLL_OPACITY_DARK_DIM) * ratio)); +} + +bool +_ScrollPresenter::IsScrollVisible(void) const +{ + return (__fadeIn || __fadeOut || __scrollVisibility); +} + +void +_ScrollPresenter::AddScrollEventListener(const Controls::_IScrollEventListener& listener) +{ + if (__pScrollEvent == null) + { + __pScrollEvent = new (std::nothrow) _UiScrollEvent(); + SysTryReturnVoidResult(NID_UI_CTRL, __pScrollEvent, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + __pScrollEvent->Construct(GetControl()); + } + + __pScrollEvent->AddListener(listener); + + return; +} + +void +_ScrollPresenter::RemoveScrollEventListener(const Controls::_IScrollEventListener& listener) +{ + ClearLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, __pScrollEvent, E_SYSTEM, "[E_SYSTEM] __pScrollEvent must not be null."); + + __pScrollEvent->RemoveListener(listener); + + return; +} + +void +_ScrollPresenter::OnParentBoundsChanged(void) +{ + // reset the bounds of scroll control + Rectangle bounds = GetParentCtrl().GetBounds(); + bounds.SetPosition(0, 0); + GetControl().SetBounds(bounds); + + // relayout scroll children. + RelayoutScrollChildren(__scrollDirection); + + return; +} + +void +_ScrollPresenter::OnDraw(void) +{ + DrawThumb(); + DrawJumpToTop(); + DrawHandler(); + DrawScrollingEffect(); + + return; +} + +bool +_ScrollPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + bool ret = false; + + ret |= OnTouchPressedHandler(source, touchinfo); + ret |= OnTouchPressedJumpToTop(source, touchinfo); + + return ret; +} + +bool +_ScrollPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + bool ret = false; + + ret |= OnTouchReleasedHandler(source, touchinfo); + ret |= OnTouchReleasedJumpToTop(source, touchinfo); + + return ret; +} + +bool +_ScrollPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + bool ret = false; + + ret |= OnTouchMovedHandler(source, touchinfo); + ret |= OnTouchMovedJumpToTop(source, touchinfo); + + return ret; +} + +HitTestResult +_ScrollPresenter::HitTest(const FloatPoint& point) +{ + FloatRectangle ctrlBounds = __pCtrlVe->GetBounds(); + + if (__enableJumpToTop && IsScrollVisible()) + { + Rectangle jumpToTopBounds = GetScrollChildBounds(*__pJumpToTopVe); + jumpToTopBounds.x += ctrlBounds.x; + jumpToTopBounds.y += ctrlBounds.y; + if (jumpToTopBounds.Contains(Point(point.x, point.y))) + { + return HIT_TEST_MATCH; + } + } + + if (__enableHandler) + { + Rectangle handlerBounds = GetScrollChildBounds(*__pHandlerVe); + handlerBounds.x += ctrlBounds.x; + handlerBounds.y += ctrlBounds.y; + if (handlerBounds.Contains(Point(point.x, point.y))) + { + return HIT_TEST_MATCH; + } + } + + return HIT_TEST_NOWHERE; +} + +VisualElementAnimation* +_ScrollPresenter::CreateAnimationForProperty(VisualElement& target, const String& property) +{ + VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property); + SysTryReturn(NID_UI_CTRL, pAnimation, null, GetLastResult(), "[%s] Failed to create a VisualElementAnimation.", GetErrorMessage(GetLastResult())); + + pAnimation->SetVisualElementAnimationStatusEventListener(this); + SetLastResult(E_SUCCESS); + + return pAnimation; +} + +void +_ScrollPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) +{ + return; +} + +void +_ScrollPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) +{ + return; +} + +void +_ScrollPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally) +{ + if (__pCtrlVe == (static_cast <_VisualElement*>(&target))) + { + __fadeIn = false; + __fadeOut = false; + } + + return; +} + +result +_ScrollPresenter::Construct(_Control& parentCtrl, + _Scroll& scrollCtrl, + _ScrollDirection scrollDirection, + bool enableFadeEffect, + bool enableJumpToTop, + bool enableHandler, + bool visibility, + int viewRange, + int scrollRange, + int scrollPosition) +{ + result r = E_SUCCESS; + + // load color/shape configuration and bitmap resources + r = LoadResources(scrollDirection, _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to load resources."); + + // set attributes + SetParentCtrl(parentCtrl); + SetControl(scrollCtrl); + __scrollDirection = scrollDirection; + __enableFadeEffect = enableFadeEffect; + __enableJumpToTop = enableJumpToTop; + __enableHandler = enableHandler; + __viewRange = viewRange; + __scrollRange = scrollRange; + __scrollPositionCurr = scrollPosition; + + _VisualElement* pVe = null; + + // initialize the scroll control + Rectangle bounds = GetParentCtrl().GetBounds(); + bounds.SetPosition(0, 0); + GetControl().SetBounds(bounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the bounds of _Scroll.", GetErrorMessage(r)); + + scrollCtrl.SetBackgroundColor(Color(0, 0, 0, 0)); + + // initialize visual elements + pVe = scrollCtrl.GetVisualElement(); + SysTryCatch(NID_UI_CTRL, pVe, , GetLastResult(), "[%s] Failed to get VisualElement of the _Scroll.", GetErrorMessage(GetLastResult())); + + __pCtrlVe = new (std::nothrow) _VisualElement(); + SysTryReturnResult(NID_UI_CTRL, __pCtrlVe != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pCtrlVe->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct Visual Element.", GetErrorMessage(r)); + + r = __pCtrlVe->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set surface opaque.", GetErrorMessage(r)); + + __pCtrlVe->SetImplicitAnimationEnabled(false); + + r = pVe->AttachChild(*__pCtrlVe); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach child to the control VisualElement.", GetErrorMessage(r)); + + r = SetScrollChildBounds(*__pCtrlVe, CalculateScrollCtrlBounds(scrollDirection)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds.", GetErrorMessage(r)); + + __pCtrlVe->SetAnimationProvider(this); + __pCtrlVe->SetShowState(true); + + if (visibility) + { + __pCtrlVe->SetOpacity(SCROLL_OPACITY_ON); + } + else + { + __pCtrlVe->SetOpacity(SCROLL_OPACITY_OFF); + } + + // initialize jumpToTopVe + if (enableJumpToTop) + { + r = AttachScrollChild(&__pJumpToTopVe, CalculateJumpToTopBounds(scrollDirection), true); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the __pJumpToTopVe to _Scroll.", GetErrorMessage(r)); + + if ((scrollDirection != SCROLL_DIRECTION_VERTICAL) || (scrollPosition == 0)) + { + __pJumpToTopVe->SetOpacity(SCROLL_OPACITY_OFF); + } + + __needUpdateJumpTopTop = true; + } + + // initialize thumbVe and handlerVe + if (enableHandler) + { + r = AttachScrollChild(&__pHandlerVe, CalculateHandlerBounds(scrollDirection), true); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the __pHandlerVe to _Scroll.", GetErrorMessage(r)); + + DetachScrollChild(&__pThumbVe, true); + + __needUpdateHandler = true; + } + else + { + r = AttachScrollChild(&__pThumbVe, CalculateThumbBounds(scrollDirection), true); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the __pThumbVe to _Scroll.", GetErrorMessage(r)); + + DetachScrollChild(&__pHandlerVe, true); + + __needUpdateThumb = true; + } + + // initialize scrolling effect front VE + __pFrontScrollingEffectVe = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_CTRL, __pFrontScrollingEffectVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pFrontScrollingEffectVe->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct pFrontScrollingEffectVe.", GetErrorMessage(r)); + + r = __pFrontScrollingEffectVe->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set surface opaque.", GetErrorMessage(r)); + + __pFrontScrollingEffectVe->SetImplicitAnimationEnabled(false); + + r = pVe->AttachChild(*__pFrontScrollingEffectVe); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach child to the control VisualElement.", GetErrorMessage(r)); + + r = SetScrollChildBounds(*__pFrontScrollingEffectVe, CalculateScrollingEffectFrontBounds(scrollDirection)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds.", GetErrorMessage(r)); + + __pFrontScrollingEffectVe->SetShowState(true); + __pFrontScrollingEffectVe->SetOpacity(SCROLL_OPACITY_OFF); + + // initialize scrolling effect reer VE + __pReerScrollingEffectVe = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_CTRL, __pReerScrollingEffectVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pReerScrollingEffectVe->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct pReerScrollingEffectVe.", GetErrorMessage(r)); + + r = __pReerScrollingEffectVe->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set surface opaque.", GetErrorMessage(r)); + + __pReerScrollingEffectVe->SetImplicitAnimationEnabled(false); + + r = pVe->AttachChild(*__pReerScrollingEffectVe); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach child to the control VisualElement.", GetErrorMessage(r)); + + r = SetScrollChildBounds(*__pReerScrollingEffectVe, CalculateScrollCtrlBounds(scrollDirection)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds.", GetErrorMessage(r)); + + __pReerScrollingEffectVe->SetShowState(true); + __pReerScrollingEffectVe->SetOpacity(SCROLL_OPACITY_OFF); + + __needUpdateScrollingEffect = true; + + __scrollVisibility = visibility; + + r = __beforeBouncingMatrixHash.Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + // set attributes + __pParentCtrl = null; + __pScrollCtrl = null; + __scrollDirection = SCROLL_DIRECTION_VERTICAL; + __enableFadeEffect = false; + __enableJumpToTop = false; + __enableHandler = false; + __enableScrollingEffect = false; + __enableOverScrollingEffect = false; + + __positionMin = 0; + __positionMax = 0; + __viewRange = 0; + __scrollRange = 0; + + __scrollPositionCurr = 0; + __needUpdateThumb = false; + __needUpdateJumpTopTop = false; + __needUpdateHandler = false; + __needUpdateScrollingEffect = false; + __jumpToTopPressed = false; + + __thumbColor = 0x00000000; + __jumpToTopBgColor = 0x00000000; + __jumpToTopColor = 0x00000000; + __jumpToTopColorPressed = 0x00000000; + __buttonColor= 0x00000000; + __buttonColorPressed = 0x00000000; + + ReleaseBitmapResources(); + + __thumbSizeMin.SetSize(0, 0); + __thumbMargin = 0; + __jumpToTopSize.SetSize(0, 0); + __jumpToTopMarginRight = 0; + __jumpToTopMarginTop = 0; + __handlerSizeMin.SetSize(0, 0); + __handlerMarginLeft = 0; + __handlerMarginRight = 0; + __handlerMarginTop = 0; + __handlerMarginBottom = 0; + __scrollingEffectWidthLeft = 0; + __scrollingEffectWidthRight = 0; + __scrollingEffectHeightTop = 0; + __scrollingEffectHeightBottom = 0; + + if (__pThumbVe != null) + { + __pThumbVe->Destroy(); + __pThumbVe = null; + } + + if (__pJumpToTopVe != null) + { + __pJumpToTopVe->Destroy(); + __pJumpToTopVe = null; + } + + if (__pHandlerVe != null) + { + __pHandlerVe->Destroy(); + __pHandlerVe = null; + } + + if (__pFrontScrollingEffectVe != null) + { + __pFrontScrollingEffectVe->RemoveAllAnimations(); + __pFrontScrollingEffectVe->Destroy(); + __pFrontScrollingEffectVe = null; + } + + if (__pReerScrollingEffectVe != null) + { + __pReerScrollingEffectVe->RemoveAllAnimations(); + __pReerScrollingEffectVe->Destroy(); + __pReerScrollingEffectVe = null; + } + + if (__pCtrlVe != null) + { + __pCtrlVe->RemoveAllAnimations(); + __pCtrlVe->SetAnimationProvider(null); + __pCtrlVe->Destroy(); + __pCtrlVe = null; + } + + return r; +} + +result +_ScrollPresenter::LoadResources(_ScrollDirection scrollDirection, _ControlOrientation orientation) +{ + result r = E_SUCCESS; + + r = LoadColorConfig(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to get resource.", GetErrorMessage(r)); + + r = LoadBitmapResources(scrollDirection); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to get resource.", GetErrorMessage(r)); + + r = LoadShapeConfig(scrollDirection, orientation); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to get resource.", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + __thumbColor = 0x00000000; + __jumpToTopBgColor = 0x00000000; + __jumpToTopColor = 0x00000000; + __jumpToTopColorPressed = 0x00000000; + __buttonColor= 0x00000000; + __buttonColorPressed = 0x00000000; + + ReleaseBitmapResources(); + + __thumbSizeMin.SetSize(0, 0); + __thumbMargin = 0; + __jumpToTopSize.SetSize(0, 0); + __jumpToTopMarginRight = 0; + __jumpToTopMarginTop = 0; + __handlerSizeMin.SetSize(0, 0); + __handlerMarginLeft = 0; + __handlerMarginRight = 0; + __handlerMarginTop = 0; + __handlerMarginBottom = 0; + __scrollingEffectWidthLeft = 0; + __scrollingEffectWidthRight = 0; + __scrollingEffectHeightTop = 0; + __scrollingEffectHeightBottom = 0; + + return r; + +} + +result +_ScrollPresenter::LoadColorConfig(void) +{ + result r = E_SUCCESS; + + // load color configuration + r = GET_COLOR_CONFIG(SCROLL::THUMB, __thumbColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(SCROLL::JUMP_TO_TOP_BG, __jumpToTopBgColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(SCROLL::JUMP_TO_TOP_NORMAL, __jumpToTopColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(SCROLL::JUMP_TO_TOP_PRESSED, __jumpToTopColorPressed); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(SCROLL::BUTTON_BG, __buttonColor); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_COLOR_CONFIG(SCROLL::BUTTON_BG_PRESSED, __buttonColorPressed); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + return E_SUCCESS; + +CATCH: + __thumbColor = 0x00000000; + __jumpToTopBgColor = 0x00000000; + __jumpToTopColor = 0x00000000; + __jumpToTopColorPressed = 0x00000000; + __buttonColor= 0x00000000; + __buttonColorPressed = 0x00000000; + + return E_SYSTEM; + +} + +result +_ScrollPresenter::LoadBitmapResources(_ScrollDirection scrollDirection) +{ + result r = E_SUCCESS; + + // release allocated resources. + ReleaseBitmapResources(); + + // load bitmap resources + r = GET_BITMAP_CONFIG_N(SCROLL::THUMB, BITMAP_PIXEL_FORMAT_ARGB8888, __pThumbBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + r = GET_BITMAP_CONFIG_N(SCROLL::THUMB_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pThumbEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + r = GET_BITMAP_CONFIG_N(SCROLL::JUMP_TO_TOP, BITMAP_PIXEL_FORMAT_ARGB8888, __pJumpToTopBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + GET_BITMAP_CONFIG_N(SCROLL::JUMP_TO_TOP_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pJumpToTopEfBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + r = GET_BITMAP_CONFIG_N(SCROLL::JUMP_TO_TOP_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888, __pJumpToTopLeftBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + GET_BITMAP_CONFIG_N(SCROLL::JUMP_TO_TOP_LEFT_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pJumpToTopLeftEfBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + r = GET_BITMAP_CONFIG_N(SCROLL::BUTTON_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pButtonBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + r = GET_BITMAP_CONFIG_N(SCROLL::BUTTON_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pButtonEfBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + r = GET_BITMAP_CONFIG_N(SCROLL::BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pButtonPressBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + r = GET_BITMAP_CONFIG_N(SCROLL::HANDLER_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBgBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + r = GET_BITMAP_CONFIG_N(SCROLL::HANDLER_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBgEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + if (scrollDirection == SCROLL_DIRECTION_HORIZONTAL) + { + r = GET_BITMAP_CONFIG_N(SCROLL::HANDLER_HORIZONTAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + r = GET_BITMAP_CONFIG_N(SCROLL::OVERSCROLLING_LEFT_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pFrontScrollingEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + r = GET_BITMAP_CONFIG_N(SCROLL::OVERSCROLLING_RIGHT_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pReerScrollingEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + } + else // if (__scrollDirection == SCROLL_DIRECTION_VERTICAL) + { + r = GET_BITMAP_CONFIG_N(SCROLL::HANDLER_VERTICAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlerBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + r = GET_BITMAP_CONFIG_N(SCROLL::OVERSCROLLING_TOP_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pFrontScrollingEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + + r = GET_BITMAP_CONFIG_N(SCROLL::OVERSCROLLING_BOTTOM_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pReerScrollingEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] failed to load image."); + } + + return E_SUCCESS; + +CATCH: + ReleaseBitmapResources(); + + return E_SYSTEM; +} + +result +_ScrollPresenter::LoadShapeConfig(_ScrollDirection scrollDirection, _ControlOrientation orientation) +{ + result r = E_SUCCESS; + + // load shape configuration + if (scrollDirection == SCROLL_DIRECTION_VERTICAL) + { + r = GET_SHAPE_CONFIG(SCROLL::VERTICAL_THUMB_MIN_WIDTH, orientation, __thumbSizeMin.width); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(SCROLL::VERTICAL_THUMB_MIN_HEIGHT, orientation, __thumbSizeMin.height); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(SCROLL::VERTICAL_THUMB_MARGIN, orientation, __thumbMargin); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + } + else + { + r = GET_SHAPE_CONFIG(SCROLL::HORIZONTAL_THUMB_MIN_WIDTH, orientation, __thumbSizeMin.width); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(SCROLL::HORIZONTAL_THUMB_MIN_HEIGHT, orientation, __thumbSizeMin.height); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(SCROLL::HORIZONTAL_THUMB_MARGIN, orientation, __thumbMargin); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + } + + r = GET_SHAPE_CONFIG(SCROLL::JUMP_TO_TOP_RIGHT_MARGIN, orientation, __jumpToTopMarginRight); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(SCROLL::JUMP_TO_TOP_TOP_MARGIN, orientation, __jumpToTopMarginTop); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_FIXED_VALUE_CONFIG(SCROLL::JUMP_TO_TOP_WIDTH, orientation, __jumpToTopSize.width); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_FIXED_VALUE_CONFIG(SCROLL::JUMP_TO_TOP_HEIGHT, orientation, __jumpToTopSize.height); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(SCROLL::HANDLER_MARGIN, orientation, __handlerMarginLeft); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(SCROLL::HANDLER_MIN_WIDTH, orientation, __handlerSizeMin.width); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + r = GET_SHAPE_CONFIG(SCROLL::HANDLER_MIN_HEIGHT, orientation, __handlerSizeMin.height); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + GET_SHAPE_CONFIG(SCROLL::OVERSCROLLING_LEFT_WIDTH, orientation, __scrollingEffectWidthLeft); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + GET_SHAPE_CONFIG(SCROLL::OVERSCROLLING_RIGHT_WIDTH, orientation, __scrollingEffectWidthRight); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + GET_SHAPE_CONFIG(SCROLL::OVERSCROLLING_TOP_HEIGHT, orientation, __scrollingEffectHeightTop); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + GET_SHAPE_CONFIG(SCROLL::OVERSCROLLING_BOTTOM_HEIGHT, orientation, __scrollingEffectHeightBottom); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource."); + + __handlerMarginRight = __handlerMarginLeft; + __handlerMarginTop = __handlerMarginLeft; + __handlerMarginBottom = __handlerMarginLeft; + + return E_SUCCESS; + +CATCH: + __thumbSizeMin.SetSize(0, 0); + __thumbMargin = 0; + __jumpToTopSize.SetSize(0, 0); + __jumpToTopMarginRight = 0; + __jumpToTopMarginTop = 0; + __handlerSizeMin.SetSize(0, 0); + __handlerMarginLeft = 0; + __handlerMarginRight = 0; + __handlerMarginTop = 0; + __handlerMarginBottom = 0; + __scrollingEffectWidthLeft = 0; + __scrollingEffectWidthRight = 0; + __scrollingEffectHeightTop = 0; + __scrollingEffectHeightBottom = 0; + + return E_SYSTEM; + +} + +void +_ScrollPresenter::ReleaseBitmapResources(void) +{ + delete __pThumbBitmap; + __pThumbBitmap = null; + + delete __pThumbEffectBitmap; + __pThumbEffectBitmap = null; + + delete __pJumpToTopBitmap; + __pJumpToTopBitmap = null; + + delete __pJumpToTopEfBitmap; + __pJumpToTopEfBitmap = null; + + delete __pJumpToTopLeftBitmap; + __pJumpToTopLeftBitmap = null; + + delete __pJumpToTopLeftEfBitmap; + __pJumpToTopLeftEfBitmap = null; + + delete __pButtonBitmap; + __pButtonBitmap = null; + + delete __pButtonEfBitmap; + __pButtonEfBitmap = null; + + delete __pButtonPressBitmap; + __pButtonPressBitmap = null; + + delete __pHandlerBgBitmap; + __pHandlerBgBitmap = null; + + delete __pHandlerBgEffectBitmap; + __pHandlerBgEffectBitmap = null; + + delete __pHandlerBitmap; + __pHandlerBitmap = null; + + delete __pFrontScrollingEffectBitmap; + __pFrontScrollingEffectBitmap = null; + + delete __pReerScrollingEffectBitmap; + __pReerScrollingEffectBitmap = null; + + return; +} + +Rectangle +_ScrollPresenter::CalculateScrollCtrlBounds(_ScrollDirection scrollDirection) +{ + Rectangle scrollCtrlBounds; + Rectangle parentBounds = GetParentCtrl().GetBounds(); + + if (scrollDirection == SCROLL_DIRECTION_VERTICAL) + { + scrollCtrlBounds.width = MAX(scrollCtrlBounds.width, (__thumbSizeMin.width + __thumbMargin)); + scrollCtrlBounds.width = MAX(scrollCtrlBounds.width, (__handlerSizeMin.width + __handlerMarginRight + __handlerMarginLeft)); + scrollCtrlBounds.width = MAX(scrollCtrlBounds.width, (__jumpToTopSize.width + __jumpToTopMarginRight)); + scrollCtrlBounds.width = MIN(scrollCtrlBounds.width, (parentBounds.width)); + scrollCtrlBounds.height = parentBounds.height; + } + else + { + scrollCtrlBounds.height = MAX(scrollCtrlBounds.height, (__thumbSizeMin.width + __thumbMargin)); + scrollCtrlBounds.height = MAX(scrollCtrlBounds.height, (__handlerSizeMin.width + __handlerMarginRight + __handlerMarginLeft)); + scrollCtrlBounds.height = MAX(scrollCtrlBounds.height, (__jumpToTopSize.width + __jumpToTopMarginRight)); + scrollCtrlBounds.height = MIN(scrollCtrlBounds.height, (parentBounds.height)); + scrollCtrlBounds.width = parentBounds.width; + } + + scrollCtrlBounds.x = parentBounds.width - scrollCtrlBounds.width; + scrollCtrlBounds.y = parentBounds.height - scrollCtrlBounds.height; + + return scrollCtrlBounds; +} + +Rectangle +_ScrollPresenter::CalculateThumbBounds(_ScrollDirection scrollDirection) +{ + Dimension thumbSize = CalculateThumbSize(scrollDirection); + Point thumbPosition = CalculateThumbPosition(scrollDirection); + + FloatRectangle scrollCtrlBounds = __pCtrlVe->GetBounds(); + if (scrollDirection == SCROLL_DIRECTION_HORIZONTAL) + { + if (thumbPosition.x < 0) + { + thumbPosition.x = 0; + } + else if (thumbPosition.x > scrollCtrlBounds.width - thumbSize.width) + { + thumbPosition.x = scrollCtrlBounds.width - thumbSize.width; + } + } + else + { + if (thumbPosition.y < 0) + { + thumbPosition.y = 0; + } + else if (thumbPosition.y > scrollCtrlBounds.height - thumbSize.height) + { + thumbPosition.y = scrollCtrlBounds.height - thumbSize.height; + } + } + + return Rectangle(thumbPosition.x, thumbPosition.y, thumbSize.width, thumbSize.height); +} + +Point +_ScrollPresenter::CalculateThumbPosition(_ScrollDirection scrollDirection) +{ + Point thumbPosition; + FloatRectangle scrollCtrlBounds = __pCtrlVe->GetBounds(); + + if (scrollDirection == SCROLL_DIRECTION_VERTICAL) + { + thumbPosition.x = scrollCtrlBounds.width - (__thumbSizeMin.width + __thumbMargin); + if (thumbPosition.x < 0) + { + thumbPosition.x = 0; + } + + if (__scrollRange > 0) + { + thumbPosition.y = (int)((scrollCtrlBounds.height * __scrollPositionCurr) / __scrollRange); + if (__scrollPositionCurr < 0) + { + thumbPosition.y = 0; + } + } + else + { + thumbPosition.y = 0; + } + } + else + { + thumbPosition.y = scrollCtrlBounds.height - (__thumbSizeMin.height + __thumbMargin); + if (thumbPosition.y < 0) + { + thumbPosition.y = 0; + } + + if (__scrollRange > 0) + { + thumbPosition.x = (int)((scrollCtrlBounds.width * __scrollPositionCurr) / __scrollRange); + if (__scrollPositionCurr < 0) + { + thumbPosition.x = 0; + } + } + else + { + thumbPosition.x = 0; + } + } + + return thumbPosition; +} + +Dimension +_ScrollPresenter::CalculateThumbSize(_ScrollDirection scrollDirection) +{ + Dimension thumbSize; + FloatRectangle scrollCtrlBounds = __pCtrlVe->GetBounds(); + + if (scrollDirection == SCROLL_DIRECTION_VERTICAL) + { + thumbSize.width = MIN(__thumbSizeMin.width, scrollCtrlBounds.width); + if (__scrollRange > 0) + { + thumbSize.height = (int)((scrollCtrlBounds.height * __viewRange) / __scrollRange); + thumbSize.height = MAX(__thumbSizeMin.height, thumbSize.height); + thumbSize.height = MIN(scrollCtrlBounds.height, thumbSize.height); + } + else + { + thumbSize.height = 0; + } + } + else + { + thumbSize.height = MIN(__thumbSizeMin.height, scrollCtrlBounds.height); + if (__scrollRange > 0) + { + thumbSize.width = (int)((scrollCtrlBounds.width * __viewRange) / __scrollRange); + thumbSize.width = MAX(__thumbSizeMin.width, thumbSize.width); + thumbSize.width = MIN(scrollCtrlBounds.width, thumbSize.width); + } + else + { + thumbSize.width = 0; + } + } + + return thumbSize; +} + +Rectangle +_ScrollPresenter::CalculateHandlerBounds(_ScrollDirection scrollDirection) +{ + Dimension handlerSize = CalculateHandlerSize(scrollDirection); + Point handlerPosition = CalculateHandlerPosition(scrollDirection); + + FloatRectangle scrollCtrlBounds = __pCtrlVe->GetBounds(); + if (scrollDirection == SCROLL_DIRECTION_HORIZONTAL) + { + if (handlerPosition.x < 0) + { + handlerPosition.x = 0; + } + else if (handlerPosition.x > scrollCtrlBounds.width - handlerSize.width) + { + handlerPosition.x =scrollCtrlBounds.width - handlerSize.width; + } + } + else + { + if (handlerPosition.y < 0) + { + handlerPosition.y = 0; + } + else if (handlerPosition.y > scrollCtrlBounds.height - handlerSize.height) + { + handlerPosition.y = scrollCtrlBounds.height - handlerSize.height; + } + } + + return Rectangle(handlerPosition.x, handlerPosition.y, handlerSize.width, handlerSize.height); +} + +Point +_ScrollPresenter::CalculateHandlerPosition(_ScrollDirection scrollDirection) +{ + Point handlerPosition; + FloatRectangle scrollCtrlBounds = __pCtrlVe->GetBounds(); + + if (scrollDirection == SCROLL_DIRECTION_VERTICAL) + { + handlerPosition.x = scrollCtrlBounds.width - (__handlerSizeMin.width + __handlerMarginRight); + if (handlerPosition.x < 0) + { + handlerPosition.x = 0; + } + if (__scrollRange > 0) + { + handlerPosition.y = (int)((scrollCtrlBounds.height * __scrollPositionCurr) / __scrollRange); + } + else + { + handlerPosition.y = 0; + } + } + else + { + handlerPosition.y = scrollCtrlBounds.height - (__handlerSizeMin.width + __handlerMarginRight); + if (handlerPosition.y < 0) + { + handlerPosition.y = 0; + } + if (__scrollRange > 0) + { + handlerPosition.x = (int)((scrollCtrlBounds.width * __scrollPositionCurr) / __scrollRange); + } + else + { + handlerPosition.x = 0; + } + } + + return handlerPosition; +} + +Dimension +_ScrollPresenter::CalculateHandlerSize(_ScrollDirection scrollDirection) +{ + Dimension handlerSize; + FloatRectangle scrollCtrlBounds = __pCtrlVe->GetBounds(); + + if (scrollDirection == SCROLL_DIRECTION_VERTICAL) + { + handlerSize.width = MIN(__handlerSizeMin.width, scrollCtrlBounds.width); + if (__scrollRange > 0) + { + handlerSize.height = (int)((scrollCtrlBounds.height * __viewRange) / __scrollRange); + } + else + { + handlerSize.height = 0; + } + } + else + { + handlerSize.height = MIN(__handlerSizeMin.width, scrollCtrlBounds.height); + if (__scrollRange > 0) + { + handlerSize.width = (int)((scrollCtrlBounds.width * __viewRange) / __scrollRange); + } + else + { + handlerSize.width = 0; + } + } + + return handlerSize; +} + +Rectangle +_ScrollPresenter::CalculateJumpToTopBounds(_ScrollDirection scrollDirection) +{ + FloatRectangle scrollCtrlBounds = __pCtrlVe->GetBounds(); + Rectangle jumpToTopBounds(0, 0, 0, 0); + + if (scrollDirection == SCROLL_DIRECTION_VERTICAL) + { + jumpToTopBounds.width = MIN(__jumpToTopSize.width, scrollCtrlBounds.width); + jumpToTopBounds.height = MIN(__jumpToTopSize.height, scrollCtrlBounds.height); + jumpToTopBounds.x = scrollCtrlBounds.width - (__jumpToTopSize.width + __jumpToTopMarginRight); + if (jumpToTopBounds.x < 0) + { + jumpToTopBounds.x = 0; + } + jumpToTopBounds.y = __jumpToTopMarginTop; + } + else + { + jumpToTopBounds.width = MIN(__jumpToTopSize.width, scrollCtrlBounds.width); + jumpToTopBounds.height = MIN(__jumpToTopSize.height, scrollCtrlBounds.height); + jumpToTopBounds.y = scrollCtrlBounds.height - (__jumpToTopSize.height + __jumpToTopMarginRight); + if (jumpToTopBounds.y < 0) + { + jumpToTopBounds.y = 0; + } + jumpToTopBounds.x = __jumpToTopMarginTop; + } + + return jumpToTopBounds; +} + +Rectangle +_ScrollPresenter::CalculateScrollingEffectFrontBounds(_ScrollDirection scrollDirection) +{ + Rectangle scrollCtrlBounds = GetControl().GetBounds(); + Rectangle scrollEffectFrontBounds(0, 0, 0, 0); + + if (scrollDirection == SCROLL_DIRECTION_HORIZONTAL) + { + scrollEffectFrontBounds.width = __scrollingEffectWidthLeft; + scrollEffectFrontBounds.height = scrollCtrlBounds.height; + } + else + { + scrollEffectFrontBounds.width = scrollCtrlBounds.width; + scrollEffectFrontBounds.height = __scrollingEffectHeightTop; + } + + return scrollEffectFrontBounds; +} + +Rectangle +_ScrollPresenter::CalculateScrollingEffectReerBounds(_ScrollDirection scrollDirection) +{ + Rectangle scrollCtrlBounds = GetControl().GetBounds(); + Rectangle scrollEffectReerBounds(0, 0, 0, 0); + + if (scrollDirection == SCROLL_DIRECTION_HORIZONTAL) + { + scrollEffectReerBounds.x = scrollCtrlBounds.width - __scrollingEffectWidthRight; + scrollEffectReerBounds.width = __scrollingEffectWidthRight; + scrollEffectReerBounds.height = scrollCtrlBounds.height; + } + else + { + scrollEffectReerBounds.y = scrollCtrlBounds.height - __scrollingEffectHeightBottom; + scrollEffectReerBounds.width = scrollCtrlBounds.width; + scrollEffectReerBounds.height = __scrollingEffectHeightBottom; + } + + return scrollEffectReerBounds; +} + +result +_ScrollPresenter::AttachScrollChild(_VisualElement** ppScrollVe, const Rectangle& bounds, bool visibility) +{ + result r = E_SUCCESS; + _VisualElement* pScrollVe = *ppScrollVe; + + if (pScrollVe == null) + { + pScrollVe = new (std::nothrow) _VisualElement(); + SysTryReturnResult(NID_UI_CTRL, pScrollVe, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = pScrollVe->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct pScrollVe.", GetErrorMessage(r)); + + r = pScrollVe->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set surface opaque.", GetErrorMessage(r)); + + pScrollVe->SetImplicitAnimationEnabled(false); + + r = __pCtrlVe->AttachChild(*pScrollVe); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach child to the __pCtrlVe.", GetErrorMessage(r)); + + *ppScrollVe = pScrollVe; + } + + r = SetScrollChildBounds(*pScrollVe, bounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds.", GetErrorMessage(r)); + + pScrollVe->SetShowState(visibility); + + return E_SUCCESS; + +CATCH: + if (pScrollVe) + { + pScrollVe->Destroy(); + pScrollVe = null; + *ppScrollVe = pScrollVe; + } + + return r; +} + +void +_ScrollPresenter::DetachScrollChild(_VisualElement** ppScrollVe, bool destroy) +{ + _VisualElement* pScrollVe = *ppScrollVe; + + if (pScrollVe) + { + if (destroy) + { + pScrollVe->Destroy(); + pScrollVe = null; + *ppScrollVe = null; + } + else + { + pScrollVe->SetShowState(false); + } + } +} + +Rectangle +_ScrollPresenter::GetScrollChildBounds(_VisualElement& scrollVe) const +{ + FloatRectangle veBounds = scrollVe.GetBounds(); + return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height); +} + +result +_ScrollPresenter::SetScrollChildBounds(_VisualElement& scrollVe, const Rectangle& bounds) +{ + FloatRectangle veBounds(bounds.x, bounds.y, bounds.width, bounds.height); + return scrollVe.SetBounds(veBounds); +} + +result +_ScrollPresenter::RelayoutScrollChildren(_ScrollDirection scrollDirection) +{ + result r = E_SUCCESS; + + r = SetScrollChildBounds(*__pCtrlVe, CalculateScrollCtrlBounds(scrollDirection)); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds the __pCtrlVe."); + + if (__enableJumpToTop) + { + r = SetScrollChildBounds(*__pJumpToTopVe, CalculateJumpToTopBounds(scrollDirection)); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds the __pJumpToTopVe."); + + __needUpdateJumpTopTop = true; + } + + if (__enableHandler) + { + r = SetScrollChildBounds(*__pHandlerVe, CalculateHandlerBounds(scrollDirection)); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds the __pHandlerVe."); + + __needUpdateHandler = true; + } + else + { + r = SetScrollChildBounds(*__pThumbVe, CalculateThumbBounds(scrollDirection)); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds the __pThumbVe."); + + __needUpdateThumb = true; + } + + r = SetScrollChildBounds(*__pFrontScrollingEffectVe, CalculateScrollingEffectFrontBounds(scrollDirection)); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds the __pFrontScrollingEffectVe."); + + r = SetScrollChildBounds(*__pReerScrollingEffectVe, CalculateScrollingEffectReerBounds(scrollDirection)); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds the __pReerScrollingEffectVe."); + + __needUpdateScrollingEffect = true; + + r = (GetControl().GetVisualElement())->InvalidateRectangle(null); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to invalidate Control Ve."); + + return E_SUCCESS; +} + +result +_ScrollPresenter::SetParentBouncing(float rate) +{ + if (rate == __parentBouncingRate) + { + return E_SUCCESS; + } + + _VisualElement* pParentVe = __pParentCtrl->GetVisualElement(); + IList* pChildrenVeList = null; + result r = E_SUCCESS; + + if (__parentBouncingRate <= 0.0f) + { + __beforeBouncingMatrixHash.RemoveAll(true); + + pChildrenVeList = pParentVe->GetChildrenN(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + for (int i = 0; i < pChildrenVeList->GetCount(); i++) + { + VisualElement* pChildVe = static_cast(pChildrenVeList->GetAt(i)); + bool isSystemChild = false; + for (int j = 0; j < __pParentCtrl->GetChildCount(); j++) + { + _Control* pChild = __pParentCtrl->GetChild(j); + _VisualElement* pChildControlVe = pChild->GetVisualElement(); + + if (pChildControlVe == pChildVe && pChild->GetArea() == _CONTROL_AREA_SYSTEM) + { + isSystemChild = true; + break; + } + } + + if (isSystemChild) + { + continue; + } + + Integer* pChildHashCode = new (std::nothrow) Integer(pChildVe->GetHashCode()); + SysTryCatch(NID_UI_CTRL, pChildHashCode, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + FloatMatrix4* pOriginChildMatrix = new (std::nothrow) FloatMatrix4; + SysTryCatch(NID_UI_CTRL, pOriginChildMatrix, delete pChildHashCode, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + *pOriginChildMatrix = pChildVe->GetTransformMatrix(); + + r = __beforeBouncingMatrixHash.Add(*pChildHashCode, *pOriginChildMatrix); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, (delete pChildHashCode, delete pOriginChildMatrix), r, "[%s] Propagating.", + GetErrorMessage(r)); + } + delete pChildrenVeList; + pChildrenVeList = null; + } + + __parentBouncingRate = rate; + + if (rate > 0.0f) + { + float scaleRate = 1.0f - (rate * (1.0f - SCROLLING_EFFECT_MIN_SCALE_RATE)); + float centerX = 0.0f; + float centerY = 0.0f; + Rectangle parentBounds = __pParentCtrl->GetBounds(); + int fixedScrollPosition = __scrollPositionCurr; + + if (__parentUsingViewport) + { + if (fixedScrollPosition < 0) + { + fixedScrollPosition = 0; + } + else if (fixedScrollPosition > (__scrollRange - __viewRange)) + { + fixedScrollPosition = (__scrollRange -__viewRange); + } + } + else + { + fixedScrollPosition = 0; + } + + if (__scrollDirection == SCROLL_DIRECTION_HORIZONTAL) + { + centerX = parentBounds.width / 2.0f + fixedScrollPosition; + centerY = parentBounds.height / 2.0f; + } + else + { + centerX = parentBounds.width / 2.0f; + centerY = parentBounds.height / 2.0f + fixedScrollPosition; + } + + pChildrenVeList = pParentVe->GetChildrenN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + for (int i = 0; i < pChildrenVeList->GetCount(); i++) + { + VisualElement* pChildVe = static_cast(pChildrenVeList->GetAt(i)); + bool isSystemChild = false; + + for (int j = 0; j < __pParentCtrl->GetChildCount(); j++) + { + _Control* pChild = __pParentCtrl->GetChild(j); + _VisualElement* pChildControlVe = pChild->GetVisualElement(); + + if (pChildControlVe == pChildVe && pChild->GetArea() == _CONTROL_AREA_SYSTEM) + { + isSystemChild = true; + break; + } + } + + if (isSystemChild) + { + continue; + } + + Integer* pChildHashCode = new (std::nothrow) Integer(pChildVe->GetHashCode()); + SysTryCatch(NID_UI_CTRL, pChildHashCode, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + Object* pMatrixObject = __beforeBouncingMatrixHash.GetValue(*pChildHashCode); + delete pChildHashCode; + if (pMatrixObject == null) + { + continue; + } + FloatMatrix4* pOriginChildMatrix = static_cast(pMatrixObject); + + FloatRectangle childBounds = pChildVe->GetBounds(); + _TransformMatrix3Df transformMatrix; + transformMatrix.SetTransformMatrix(*pOriginChildMatrix); + transformMatrix.SetScaleAnchor(centerX - (childBounds.x + (childBounds.width / 2.0f)), centerY - (childBounds.y + (childBounds.height / 2.0f)), 0.0f); + transformMatrix.SetScaleFactors(scaleRate, scaleRate, 1.0f); + + pChildVe->SetTransformMatrix(transformMatrix.GetTransformMatrix()); + } + delete pChildrenVeList; + pChildrenVeList = null; + } + else + { + pChildrenVeList = pParentVe->GetChildrenN(); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + for (int i = 0; i < pChildrenVeList->GetCount(); i++) + { + VisualElement* pChildVe = static_cast(pChildrenVeList->GetAt(i)); + bool isSystemChild = false; + for (int j = 0; j < __pParentCtrl->GetChildCount(); j++) + { + _Control* pChild = __pParentCtrl->GetChild(j); + _VisualElement* pChildControlVe = pChild->GetVisualElement(); + + if (pChildControlVe == pChildVe && pChild->GetArea() == _CONTROL_AREA_SYSTEM) + { + isSystemChild = true; + break; + } + } + + if (isSystemChild) + { + continue; + } + + Integer* pChildHashCode = new (std::nothrow) Integer(pChildVe->GetHashCode()); + SysTryCatch(NID_UI_CTRL, pChildHashCode != null, , E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(E_OUT_OF_MEMORY)); + + Object* pMatrixObject = __beforeBouncingMatrixHash.GetValue(*pChildHashCode); + delete pChildHashCode; + if (pMatrixObject == null) + { + continue; + } + FloatMatrix4* pOriginChildMatrix = static_cast(pMatrixObject); + + pChildVe->SetTransformMatrix(*pOriginChildMatrix); + } + delete pChildrenVeList; + pChildrenVeList = null; + } + + return r; + +CATCH: + delete pChildrenVeList; + + return r; +} + +void +_ScrollPresenter::DrawThumb(void) +{ + if (__needUpdateThumb != true) + { + return; + } + + Canvas* pCanvas = null; + Bitmap* pThumbBitmap = null; + result r = E_SUCCESS; + + if (__enableHandler != true) + { + pCanvas = __pThumbVe->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "Failed to get the canvas of __pThumbVe"); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + pThumbBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pThumbBitmap, + Color::GetColor(COLOR_ID_MAGENTA), + __thumbColor); + SysTryCatch(NID_UI_CTRL, pThumbBitmap, , GetLastResult(), "[%s] Failed to draw bitmap.", + GetErrorMessage(GetLastResult())); + + Rectangle thumbBounds = GetScrollChildBounds(*__pThumbVe); + thumbBounds.SetPosition(0, 0); + r = DrawBitmap(*pCanvas, thumbBounds, *__pThumbEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw bitmap.", GetErrorMessage(r)); + + r = DrawBitmap(*pCanvas, thumbBounds, *pThumbBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw bitmap.", GetErrorMessage(r)); + } + + __needUpdateThumb = false; + //fall through +CATCH: + delete pCanvas; + delete pThumbBitmap; + + return; +} + +void +_ScrollPresenter::DrawJumpToTop(void) +{ + if (__needUpdateJumpTopTop != true) + { + return; + } + + Canvas* pCanvas = null; + Bitmap* pColorReplacedBitmap = null; + result r = E_SUCCESS; + + if (__enableJumpToTop) + { + Bitmap* pBitmap = __pJumpToTopBitmap; + Bitmap* pEfBitmap = __pJumpToTopEfBitmap; + if (__scrollDirection == SCROLL_DIRECTION_HORIZONTAL) + { + pBitmap = __pJumpToTopLeftBitmap; + pEfBitmap = __pJumpToTopLeftEfBitmap; + } + + Color jumpToTopColor = (__jumpToTopPressed) ? __jumpToTopColorPressed : __jumpToTopColor; + Color buttonColor = (__jumpToTopPressed) ? __buttonColorPressed : __buttonColor; + Bitmap* pButtonEfBitmap = (__jumpToTopPressed) ? __pButtonPressBitmap : __pButtonEfBitmap; + + pCanvas = __pJumpToTopVe->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "Failed to get the canvas of __pJumpToTopVe"); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + Rectangle jumpToTopBounds = GetScrollChildBounds(*__pJumpToTopVe); + jumpToTopBounds.SetPosition(0, 0); + + //Draw Button + r = DrawBitmap(*pCanvas, jumpToTopBounds, *pButtonEfBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw bitmap.", GetErrorMessage(r)); + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pButtonBitmap, + Color::GetColor(COLOR_ID_MAGENTA), + buttonColor); + SysTryCatch(NID_UI_CTRL, pColorReplacedBitmap, , GetLastResult(), "[%s] Failed to draw bitmap.", GetErrorMessage(GetLastResult())); + + r = DrawBitmap(*pCanvas, jumpToTopBounds, *pColorReplacedBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw bitmap.", GetErrorMessage(r)); + + r = DrawBitmap(*pCanvas, jumpToTopBounds, *pEfBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw bitmap.", GetErrorMessage(r)); + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, + Color::GetColor(COLOR_ID_MAGENTA), + jumpToTopColor); + SysTryCatch(NID_UI_CTRL, pColorReplacedBitmap, , GetLastResult(), "[%s] Failed to draw bitmap.", GetErrorMessage(GetLastResult())); + + r = DrawBitmap(*pCanvas, jumpToTopBounds, *pColorReplacedBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw bitmap.", GetErrorMessage(r)); + } + + __needUpdateJumpTopTop = false; + //fall through +CATCH: + delete pCanvas; + delete pColorReplacedBitmap; + + return; +} + +void +_ScrollPresenter::DrawHandler(void) +{ + if (__needUpdateHandler != true) + { + return; + } + + Canvas* pCanvas = null; + Bitmap* pHandlerBgBitmap = null; + result r = E_SUCCESS; + + if (__enableHandler) + { + // handler bounds setting + pCanvas = __pHandlerVe->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "Failed to get the canvas of __pHandlerVe"); + + // clear background + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + // draw handler bg bitmap + pHandlerBgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pHandlerBgBitmap, + Color::GetColor(COLOR_ID_MAGENTA), + __thumbColor); + SysTryCatch(NID_UI_CTRL, pHandlerBgBitmap, , GetLastResult(), "[%s] Failed to draw bitmap.", GetErrorMessage(GetLastResult())); + + Rectangle handlerBounds = GetScrollChildBounds(*__pHandlerVe); + handlerBounds.SetPosition(0, 0); + + r = DrawBitmap(*pCanvas, handlerBounds, *__pHandlerBgEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw bitmap.", GetErrorMessage(r)); + + r = DrawBitmap(*pCanvas, handlerBounds, *pHandlerBgBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw bitmap.", GetErrorMessage(r)); + + r = DrawBitmap(*pCanvas, handlerBounds, *__pHandlerBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw bitmap.", GetErrorMessage(r)); + } + + __needUpdateHandler = false; + //fall through +CATCH: + delete pCanvas; + delete pHandlerBgBitmap; + + return; +} + +void +_ScrollPresenter::DrawScrollingEffect(void) +{ + if (__needUpdateScrollingEffect != true) + { + return; + } + + Canvas* pCanvas = null; + result r = E_SUCCESS; + + if (__pFrontScrollingEffectBitmap != null) + { + pCanvas = __pFrontScrollingEffectVe->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of __pFrontScrollingEffectVe", GetErrorMessage(GetLastResult())); + + // clear background + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + Rectangle effectBounds = GetScrollChildBounds(*__pFrontScrollingEffectVe); + effectBounds.SetPosition(0, 0); + r = DrawBitmap(*pCanvas, effectBounds, *__pFrontScrollingEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw bitmap.", GetErrorMessage(r)); + + delete pCanvas; + } + + if (__pReerScrollingEffectBitmap != null) + { + pCanvas = __pReerScrollingEffectVe->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of __pReerScrollingEffectVe", GetErrorMessage(GetLastResult())); + + // clear background + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + Rectangle effectBounds = GetScrollChildBounds(*__pReerScrollingEffectVe); + effectBounds.SetPosition(0, 0); + r = DrawBitmap(*pCanvas, effectBounds, *__pReerScrollingEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw bitmap.", GetErrorMessage(r)); + + delete pCanvas; + } + + __needUpdateScrollingEffect = false; + + return; + +CATCH: + delete pCanvas; +} + +result +_ScrollPresenter::DrawBitmap(Canvas& canvas, const Rectangle& bounds, const Bitmap& bitmap) +{ + result r = E_SUCCESS; + if (bitmap.IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap"); + } + else + { + Point pos((bounds.width - bitmap.GetWidth()) / 2, (bounds.height - bitmap.GetHeight()) / 2); + r = canvas.DrawBitmap(pos, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap"); + } + + return E_SUCCESS; +} + +bool +_ScrollPresenter::OnTouchPressedJumpToTop(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__enableJumpToTop && IsScrollVisible()) + { + FloatRectangle ctrlBounds = __pCtrlVe->GetBounds(); + Rectangle jumpToTopBounds = GetScrollChildBounds(*__pJumpToTopVe); + jumpToTopBounds.x += ctrlBounds.x; + jumpToTopBounds.y += ctrlBounds.y; + if (jumpToTopBounds.Contains(touchinfo.GetCurrentPosition())) + { + __needUpdateJumpTopTop = true; + __jumpToTopPressed = true; + (GetControl().GetVisualElement())->InvalidateRectangle(null); + + if (__pScrollEvent) + { + _UiScrollEventArg* pEventArg = _UiScrollEventArg::GetScrollEventArgN(*__pScrollCtrl, 0); + SysTryReturn(NID_UI_CTRL, pEventArg, true, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pScrollEvent->Fire(*pEventArg); + } + + return true; + } + } + + return false; +} + +bool +_ScrollPresenter::OnTouchReleasedJumpToTop(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__jumpToTopPressed) + { + __needUpdateJumpTopTop = true; + } + + __jumpToTopPressed = false; + (GetControl().GetVisualElement())->InvalidateRectangle(null); + return false; +} + +bool +_ScrollPresenter::OnTouchMovedJumpToTop(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__jumpToTopPressed) + { + FloatRectangle ctrlBounds = __pCtrlVe->GetBounds(); + Rectangle jumpToTopBounds = GetScrollChildBounds(*__pJumpToTopVe); + jumpToTopBounds.x += ctrlBounds.x; + jumpToTopBounds.y += ctrlBounds.y; + if (!(jumpToTopBounds.Contains(touchinfo.GetCurrentPosition()))) + { + __needUpdateJumpTopTop = true; + __jumpToTopPressed = false; + (GetControl().GetVisualElement())->InvalidateRectangle(null); + } + } + + return false; +} + +bool +_ScrollPresenter::OnTouchPressedHandler(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__enableHandler) + { + FloatRectangle ctrlBounds = __pCtrlVe->GetBounds(); + Rectangle handlerBounds = GetScrollChildBounds(*__pHandlerVe); + handlerBounds.x += ctrlBounds.x; + handlerBounds.y += ctrlBounds.y; + if (handlerBounds.Contains(touchinfo.GetCurrentPosition())) + { + __handlerTouched = true; + if (__scrollDirection == SCROLL_DIRECTION_VERTICAL) + { + __handlerTouchedPosition = touchinfo.GetCurrentPosition().y; + } + else + { + __handlerTouchedPosition = touchinfo.GetCurrentPosition().x; + } + return true; + } + } + + return false; +} + +bool +_ScrollPresenter::OnTouchReleasedHandler(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__enableHandler) + { + __handlerTouched = false; + __handlerTouchedPosition = 0; + + return true; + } + + // forwarding OnTouchReleased event to parent control + return false; +} + +bool +_ScrollPresenter::OnTouchMovedHandler(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__enableHandler && __handlerTouched) + { + int scrollPosition = GetScrollPosition(); + Rectangle scrollCtrlBounds = GetControl().GetBounds(); + int touchPosition = 0; + int scrollBoundsRange = 0; + + if (__scrollDirection == SCROLL_DIRECTION_VERTICAL) + { + touchPosition = touchinfo.GetCurrentPosition().y; + scrollBoundsRange = scrollCtrlBounds.height; + } + else + { + touchPosition = touchinfo.GetCurrentPosition().x; + scrollBoundsRange = scrollCtrlBounds.width; + } + + //1. move handler + int touchDistance = touchPosition - __handlerTouchedPosition; + int scrollDistance = (int)(( __scrollRange * touchDistance) / scrollBoundsRange); + + scrollPosition += scrollDistance; + + int scrollType = -1; + if (scrollPosition <= 0) + { + scrollType = (__scrollDirection == SCROLL_DIRECTION_VERTICAL) ? SCROLL_END_EVENT_END_TOP : SCROLL_END_EVENT_END_LEFT; + scrollPosition = 0; + } + else if (scrollPosition >= __scrollRange - __viewRange) + { + scrollType = (__scrollDirection == SCROLL_DIRECTION_VERTICAL) ? SCROLL_END_EVENT_END_BOTTOM : + SCROLL_END_EVENT_END_RIGHT; + scrollPosition = __scrollRange - __viewRange; + } + + result r = SetScrollPosition(scrollPosition); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to set scroll position.", GetErrorMessage(r)); + + __handlerTouchedPosition = touchPosition; + + //2. fire event + if (__pScrollEvent) + { + _UiScrollEventArg* pEventArg = null; + if (scrollType >= 0) + { + pEventArg = _UiScrollEventArg::GetScrollEventArgN(*__pScrollCtrl, (ScrollEndEvent)scrollType); + SysTryReturn(NID_UI_CTRL, pEventArg, true, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + else + { + pEventArg = _UiScrollEventArg::GetScrollEventArgN(*__pScrollCtrl, GetScrollPosition()); + SysTryReturn(NID_UI_CTRL, pEventArg, true, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + + __pScrollEvent->Fire(*pEventArg); + } + + return true; + } + + // forwarding OnTouchMoved event to parent control + return false; +} + +void +_ScrollPresenter::SetParentCtrl(_Control& parentCtrl) +{ + __pParentCtrl = &parentCtrl; +} + +_Control& +_ScrollPresenter::GetParentCtrl(void) const +{ + return *__pParentCtrl; +} + +void +_ScrollPresenter::SetControl(_Scroll& scrollCtrl) +{ + __pScrollCtrl = &scrollCtrl; +} + +_Scroll& +_ScrollPresenter::GetControl(void) const +{ + return *__pScrollCtrl; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SearchBar.cpp b/src/ui/controls/FUiCtrl_SearchBar.cpp new file mode 100644 index 0000000..e5673c0 --- /dev/null +++ b/src/ui/controls/FUiCtrl_SearchBar.cpp @@ -0,0 +1,2454 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SearchBar.cpp + * @brief This is the implementation file for the _SearchBar class. + */ + +#include +#include +#include +#include "FUiAnim_VisualElement.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_SearchBar.h" +#include "FUiCtrl_SearchBarPresenter.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_Panel.h" +#include "FUiCtrl_OverlayPanel.h" +#include "FUiCtrl_Keypad.h" +#include "FUiCtrl_ColorPicker.h" +#include "FUiCtrl_ActionEvent.h" +#include "FUiCtrl_TextBlockEvent.h" +#include "FUiCtrl_TextEvent.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityManager.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Locales; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_SearchBar); + +_SearchBar::_SearchBar(void) + : __pSearchBarPresenter(null) + , __pClippedGroupControl(null) + , __pEdit(null) + , __pCancelButton(null) + , __pContainer(null) + , __pContentControl(null) + , __actionId(0) + , __searchBarStyle(0) + , __isButtonEnabled(true) + , __isUsableCancelButton(false) + , __isUserContainerBounds(false) + , __isCancelActionInProgress(false) + , __keypadAction(CORE_KEYPAD_ACTION_SEARCH) + , __pBackgroundBitmap(null) + , __backgroundColor(Color()) + , __contentColor(Color()) + , __pActionEvent(null) + , __pKeypadEvent(null) + , __pTextBlockEvent(null) + , __pTextEvent(null) + , __pSearchBarEvent(null) + , __pLanguageEvent(null) +{ + for (int i = 0; i < SEARCHBAR_BUTTON_COLOR_MAX; i++) + { + __buttonColor[i] = Color(0); + __buttonTextColor[i] = Color(0); + } + + for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++) + { + __color[i] = Color(0); + __textColor[i] = Color(0); + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer) + { + pContainer->Activate(true); + } +} + +_SearchBar::~_SearchBar(void) +{ + + delete __pSearchBarPresenter; + __pSearchBarPresenter = null; + + if (__pEdit) + { + __pEdit->HideKeypad(); + + __pClippedGroupControl->DetachChild(*__pEdit); + + delete __pEdit; + __pEdit = null; + } + + if (__pCancelButton) + { + __pClippedGroupControl->DetachChild(*__pCancelButton); + + delete __pCancelButton; + __pCancelButton = null; + } + + if (__pClippedGroupControl) + { + DetachChild(*__pClippedGroupControl); + + delete __pClippedGroupControl; + __pClippedGroupControl = null; + } + + if (__pContainer) + { + DetachChild(*__pContainer); + + delete __pContainer; + __pContainer = null; + } + + if (__pActionEvent) + { + delete __pActionEvent; + __pActionEvent = null; + } + + if (__pKeypadEvent) + { + delete __pKeypadEvent; + __pKeypadEvent = null; + } + + if (__pTextBlockEvent) + { + delete __pTextBlockEvent; + __pTextBlockEvent = null; + } + + if (__pTextEvent) + { + delete __pTextEvent; + __pTextEvent = null; + } + + if (__pSearchBarEvent) + { + delete __pSearchBarEvent; + __pSearchBarEvent = null; + } + + delete __pBackgroundBitmap; + __pBackgroundBitmap = null; +} + +_SearchBar* +_SearchBar::CreateSearchBarN(void) +{ + _SearchBar* pSearchBar = new (std::nothrow) _SearchBar; + SysTryReturn(NID_UI_CTRL, pSearchBar, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + if (GetLastResult() != E_SUCCESS) + { + delete pSearchBar; + return null; + } + + pSearchBar->AcquireHandle(); + + return pSearchBar; +} + +result +_SearchBar::Initialize(bool enableSearchBarButton, CoreKeypadAction keypadAction) +{ + result r = E_SUCCESS; + + // Setting Button color + GET_COLOR_CONFIG(SEARCHBAR::BUTTON_BG_NORMAL, __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(SEARCHBAR::BUTTON_PRESSED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(SEARCHBAR::BUTTON_HIGHLIGHTED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]); + GET_COLOR_CONFIG(SEARCHBAR::BUTTON_DISABLED, __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]); + + GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_NORMAL, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_PRESSED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]); + GET_COLOR_CONFIG(SEARCHBAR::BUTTON_TEXT_DISABLED, __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]); + + GET_COLOR_CONFIG(SEARCHBAR::CONTENT_AREA_BG_NORMAL, __contentColor); + + for (int i = 0; i < SEARCHBAR_COLOR_MAX; i++) + { + switch(i) + { + case SEARCH_FIELD_STATUS_DISABLED: + GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_DISABLED, __color[i]); + GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_DISABLED, __textColor[i]); + break; + + case SEARCH_FIELD_STATUS_HIGHLIGHTED: + GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]); + GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_HIGHLIGHTED, __textColor[i]); + break; + default: + GET_COLOR_CONFIG(SEARCHBAR::EDIT_BG_NORMAL, __color[i]); + GET_COLOR_CONFIG(SEARCHBAR::EDIT_TEXT_NORMAL, __textColor[i]); + break; + } + } + + __isUsableCancelButton = enableSearchBarButton; + __keypadAction = keypadAction; + + GetVisualElement()->SetClipChildrenEnabled(false); + + r = CreateClippedGroupControl(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The construction of parent control for clipped group control failed."); + + r = CreateSearchField(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit construction failed."); + r = CreateCancelButton(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button construction failed."); + + SetContentsArea(); + r = CreateContentsArea(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The construction of parent for content failed."); + + _SearchBarPresenter* pPresenter = new (std::nothrow) _SearchBarPresenter; + SysTryReturn(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pPresenter->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pPresenter->Install(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSearchBarPresenter = pPresenter; + + return r; + +CATCH: + delete pPresenter; + pPresenter = null; + + return r; +} + +result +_SearchBar::CreateSearchField(void) +{ + result r = E_SUCCESS; + + Rectangle editBounds; + int horizontalMargin = 0; + int verticalMargin = 0; + int iconHorizontalMargin = 0; + int textHorizontalMargin = 0; + int iconWidth = 0; + int textSize = 0; + int searchFieldMinWidth = 0; + int searchFieldMinHeight = 0; + + Rectangle searchBarBounds = GetBounds(); + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + _AccessibilityContainer* pSearchBarContainer = null; + + GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin); + GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin); + GET_SHAPE_CONFIG(SEARCHBAR::ICON_HORIZONTAL_MARGIN, orientation, iconHorizontalMargin); + GET_SHAPE_CONFIG(SEARCHBAR::ICON_WIDTH, orientation, iconWidth); + GET_SHAPE_CONFIG(SEARCHBAR::TEXT_HORIZONTAL_MARGIN, orientation, textHorizontalMargin); + GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth); + GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_HEIGHT, orientation, searchFieldMinHeight); + + editBounds.x = horizontalMargin; + editBounds.y = verticalMargin; + editBounds.width = searchBarBounds.width - (editBounds.x * 2); + editBounds.height = searchBarBounds.height - (editBounds.y * 2); + + editBounds.width = (editBounds.width > searchFieldMinWidth) ? editBounds.width : searchFieldMinWidth; + editBounds.height = (editBounds.height > searchFieldMinHeight) ? editBounds.height : searchFieldMinHeight; + + + __pEdit = _Edit::CreateEditN(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = __pEdit->Initialize(EDIT_STYLE_NORMAL | EDIT_STYLE_SINGLE_LINE | EDIT_STYLE_CLEAR | EDIT_STYLE_NOSCROLL, INPUT_STYLE_OVERLAY, + SEARCHBAR_TEXT_LENGTH_MAX); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pEdit->SetKeypadCommandButtonVisible(false); + __pEdit->SetBounds(editBounds); + + __pEdit->AddKeypadEventListener(*this); + __pEdit->AddTextBlockEventListener(*this); + __pEdit->AddTextEventListener(*this); + + GET_SHAPE_CONFIG(SEARCHBAR::EDIT_TEXT_SIZE, orientation, textSize); + __pEdit->SetTextSize(textSize); + + __pEdit->SetHorizontalMargin(iconHorizontalMargin + iconWidth + textHorizontalMargin, EDIT_TEXT_LEFT_MARGIN); + __pEdit->SetHorizontalMargin(textHorizontalMargin, EDIT_TEXT_RIGHT_MARGIN); + __pEdit->SetLimitLength(SEARCHBAR_TEXT_LENGTH_MAX); + + for (int status = 0; status < SEARCHBAR_COLOR_MAX; status++) + { + EditStatus editStatus = ConvertSearchBarStatus((SearchFieldStatus) status); + __pEdit->SetColor(editStatus, __color[status]); + } + + __pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, __textColor[SEARCH_FIELD_STATUS_NORMAL]); + __pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, __textColor[SEARCH_FIELD_STATUS_DISABLED]); + __pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]); + + __pEdit->ReplaceDefaultBackgroundBitmapForSearchBar(); + + __pEdit->SetKeypadAction(__keypadAction); + + r = __pClippedGroupControl->AttachChild(*__pEdit); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to attach edit as child."); + + if(likely(!(_AccessibilityManager::IsActivated()))) + { + return E_SUCCESS; + } + + pSearchBarContainer = GetAccessibilityContainer(); + if (pSearchBarContainer) + { + _AccessibilityContainer* pSearchFieldContainer = __pEdit->GetAccessibilityContainer(); + if (pSearchFieldContainer) + { + pSearchBarContainer->AddChildContainer(*pSearchFieldContainer); + } + } + + return E_SUCCESS; + +CATCH: + delete __pEdit; + __pEdit = null; + + return r; +} + +result +_SearchBar::CreateCancelButton(void) +{ + result r = E_SUCCESS; + + int textSize = 0; + String cancelButtonText; + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + _AccessibilityContainer* pSearchBarContainer = null; + + __pCancelButton = _Button::CreateButtonN(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = ResizeCancelButton(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelButtonText); + r = __pCancelButton->SetText(cancelButtonText); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_TEXT_SIZE, orientation, textSize); + r = __pCancelButton->SetTextSize(textSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pCancelButton->SetTextHorizontalAlignment(ALIGNMENT_CENTER); + __pCancelButton->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + + r = __pCancelButton->SetActionId(__actionId); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pCancelButton->AddActionEventListener(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pCancelButton->SetVisibleState(false); + + for (int status = 0; status < SEARCHBAR_BUTTON_COLOR_MAX; status++) + { + _ButtonStatus buttonStatus = ConvertSearchBarButtonStatus((SearchBarButtonStatus) status); + + r = __pCancelButton->SetColor(buttonStatus, __buttonColor[status]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pCancelButton->SetTextColor(buttonStatus, __buttonTextColor[status]); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pClippedGroupControl->AttachChild(*__pCancelButton); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to attach button as child."); + + if(likely(!(_AccessibilityManager::IsActivated()))) + { + return E_SUCCESS; + } + + pSearchBarContainer = GetAccessibilityContainer(); + if (pSearchBarContainer) + { + _AccessibilityContainer* pButtonContainer = __pCancelButton->GetAccessibilityContainer(); + if (pButtonContainer) + { + pSearchBarContainer->AddChildContainer(*pButtonContainer); + } + } + + return E_SUCCESS; + +CATCH: + delete __pCancelButton; + __pCancelButton = null; + + return r; +} + +result +_SearchBar::CreateContentsArea(void) +{ + result r = E_SUCCESS; + + __pContainer = _Control::CreateControlN(); + + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + __pContainer->SetVisibleState(false); + + r = AttachChild(*__pContainer); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to attach the parent of content."); + + return E_SUCCESS; + +CATCH: + delete __pContainer; + __pContainer = null; + + return r; +} + +void +_SearchBar::SetContentsArea(void) +{ + if (__isUserContainerBounds) + { + return; + } + + Dimension screenSize = _ControlManager::GetInstance()->GetScreenSize(); + int width = screenSize.width; + int height = screenSize.height; + _Control* pParent = GetParentForm(); + if (pParent != null) + { + width = pParent->GetClientBounds().width; + height = pParent->GetClientBounds().height; + } + + __contentAreaBounds = GetBounds(); + __contentAreaBounds.x = 0; + __contentAreaBounds.y = __contentAreaBounds.height; + __contentAreaBounds.width = width; + __contentAreaBounds.height = height - __contentAreaBounds.height; + + if (__pContainer) + { + result r = E_SUCCESS; + r = __pContainer->SetBounds(__contentAreaBounds); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (pParent) + { + _Form* pForm = dynamic_cast<_Form*>(pParent); + if (pForm) + { + pForm->Invalidate(true); + } + } + } + return; +} + +_Control* +_SearchBar::GetContent(void) const +{ + return __pContentControl; +} + +result +_SearchBar::SetContent(const _Control* pContent) +{ + __pContentControl = const_cast <_Control*>(pContent); + result r = E_SUCCESS; + + if (__pContainer) + { + r = __pContainer->AttachChild(*__pContentControl); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating"); + } + + return r; +} + +result +_SearchBar::UpdateContentArea(bool invalidate) +{ + return __pSearchBarPresenter->UpdateContentArea(invalidate); +} + +result +_SearchBar::SetContentAreaVisible(bool visible) +{ + SysTryReturn(NID_UI_CTRL, __pContainer, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The instance of parent to content is null."); + + SearchBarMode searchBarMode = GetMode(); + if (searchBarMode == SEARCH_BAR_MODE_INPUT) + { + __pContainer->SetVisibleState(visible); + } + + return __pSearchBarPresenter->SetContentAreaVisible(visible); +} + +bool +_SearchBar::IsContentAreaVisible(void) const +{ + return __pSearchBarPresenter->IsContentAreaVisible(); +} + +result +_SearchBar::SetContentAreaSize(const Dimension& size) +{ + return SetProperty("contentAreaSize", Variant(size)); +} + +Dimension +_SearchBar::GetContentAreaSize(void) const +{ + Variant size = GetProperty("contentAreaSize"); + + return size.ToDimension(); +} + +SearchBarMode +_SearchBar::GetMode(void) const +{ + return __pSearchBarPresenter->GetMode(); +} + +bool +_SearchBar::IsModeLocked(void) const +{ + return __pSearchBarPresenter->IsModeLocked(); +} + +result +_SearchBar::SetMode(SearchBarMode mode) +{ + return __pSearchBarPresenter->SetMode(mode); +} + +result +_SearchBar::SetModeLocked(bool modeLocked) +{ + return __pSearchBarPresenter->SetModeLocked(modeLocked); +} + +int +_SearchBar::GetButtonActionId(void) const +{ + Variant actionId = GetProperty("buttonActionId"); + + return actionId.ToInt(); +} + +Color +_SearchBar::GetButtonColor(SearchBarButtonStatus status) const +{ + Variant buttonColor; + + switch (status) + { + case SEARCH_BAR_BUTTON_STATUS_NORMAL: + buttonColor = GetProperty("buttonNormalColor"); + break; + case SEARCH_BAR_BUTTON_STATUS_PRESSED: + buttonColor = GetProperty("buttonPressedColor"); + break; + case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED: + buttonColor = GetProperty("buttonHighlightedColor"); + break; + case SEARCH_BAR_BUTTON_STATUS_DISABLED: + buttonColor = GetProperty("buttonDisabledColor"); + break; + default: + break; + } + + return buttonColor.ToColor(); +} + +Color +_SearchBar::GetButtonTextColor(SearchBarButtonStatus status) const +{ + Variant buttonTextColor; + + switch (status) + { + case SEARCH_BAR_BUTTON_STATUS_NORMAL: + buttonTextColor = GetProperty("buttonNormalTextColor"); + break; + case SEARCH_BAR_BUTTON_STATUS_PRESSED: + buttonTextColor = GetProperty("buttonPressedTextColor"); + break; + case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED: + buttonTextColor = GetProperty("buttonHighlightedTextColor"); + break; + case SEARCH_BAR_BUTTON_STATUS_DISABLED: + buttonTextColor = GetProperty("buttonDisabledTextColor"); + break; + default: + break; + } + + return buttonTextColor.ToColor(); +} + +SearchBarButtonStatus +_SearchBar::GetButtonStatus(void) const +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, SEARCH_BAR_BUTTON_STATUS_NORMAL, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + SearchBarButtonStatus buttonStatus = SEARCH_BAR_BUTTON_STATUS_NORMAL; + + if (__isButtonEnabled == false) + { + buttonStatus = SEARCH_BAR_BUTTON_STATUS_DISABLED; + } + + return buttonStatus; +} + +result +_SearchBar::SetButtonText(const String& text) +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + result r = E_SUCCESS; + + r = __pCancelButton->SetText(text); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set text."); + + return r; +} + +result +_SearchBar::SetButtonActionId(int actionId) +{ + return SetProperty("buttonActionId", Variant(actionId)); +} + +result +_SearchBar::SetButtonEnabled(bool enabled) +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + __pCancelButton->SetEnableState(enabled); + + __isButtonEnabled = enabled; + + return E_SUCCESS; +} + +result +_SearchBar::SetButtonColor(SearchBarButtonStatus status, const Color& color) +{ + result r = E_SUCCESS; + + switch (status) + { + case SEARCH_BAR_BUTTON_STATUS_NORMAL: + r = SetProperty("buttonNormalColor", Variant(color)); + break; + case SEARCH_BAR_BUTTON_STATUS_PRESSED: + r = SetProperty("buttonPressedColor", Variant(color)); + break; + case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED: + r = SetProperty("buttonHighlightedColor", Variant(color)); + break; + case SEARCH_BAR_BUTTON_STATUS_DISABLED: + r = SetProperty("buttonDisabledColor", Variant(color)); + break; + default: + break; + } + + return r; +} + +result +_SearchBar::SetButtonTextColor(SearchBarButtonStatus status, const Color& color) +{ + result r = E_SUCCESS; + + switch (status) + { + case SEARCH_BAR_BUTTON_STATUS_NORMAL: + r = SetProperty("buttonNormalTextColor", Variant(color)); + break; + case SEARCH_BAR_BUTTON_STATUS_PRESSED: + r = SetProperty("buttonPressedTextColor", Variant(color)); + break; + case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED: + r = SetProperty("buttonHighlightedTextColor", Variant(color)); + break; + case SEARCH_BAR_BUTTON_STATUS_DISABLED: + r = SetProperty("buttonDisabledTextColor", Variant(color)); + break; + default: + break; + } + + return r; +} + +result +_SearchBar::AppendCharacter(const Character& character) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The character is null."); + + result r = E_SUCCESS; + + r = __pEdit->AppendCharacter(character); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set character."); + + return r; +} + +result +_SearchBar::AppendText(const String& text) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + SysTryReturn(NID_UI_CTRL, text.IsEmpty() == false, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The text is empty."); + + result r = E_SUCCESS; + + r = __pEdit->AppendText(text); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set text."); + + return r; +} + +result +_SearchBar::SetText(const String& text) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + result r = E_SUCCESS; + + int limitLength = __pEdit->GetTextLimitLength(); + int textLength = text.GetLength(); + SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength); + + r = __pEdit->SetText(text); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set text."); + + return r; +} + +result +_SearchBar::InsertCharacterAt(int index, const Character& character) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] index(%d) is out of range.", index); + SysTryReturn(NID_UI_CTRL, character.CompareTo(null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The character is null."); + + result r = E_SUCCESS; + + int textLength = 0; + int limitLength = 0; + limitLength = __pEdit->GetTextLimitLength(); + textLength = __pEdit->GetTextLength() + 1; + + SysTryReturn(NID_UI_CTRL, limitLength > textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength); + + SysTryReturn(NID_UI_CTRL, textLength >= index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] index(%d) is out of range textLength(%d).", index, textLength); + + r = __pEdit->InsertCharacterAt(index, character); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set text."); + + return r; +} + +result +_SearchBar::InsertTextAt(int index, const String& text) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] index(%d) is out of range.", index); + + int textLength = 0; + int limitLength = 0; + limitLength = __pEdit->GetTextLimitLength(); + textLength = __pEdit->GetTextLength() + text.GetLength(); + + SysTryReturn(NID_UI_CTRL, limitLength > textLength, E_MAX_EXCEEDED, E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] limitLength(%d) exceeds the maximum limit textLength(%d).", limitLength, textLength); + SysTryReturn(NID_UI_CTRL, textLength >= index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] index(%d) is out of range textLength(%d).", index, textLength); + + return __pEdit->InsertTextAt(index, text); +} + +result +_SearchBar::DeleteCharacterAt(int index) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + SysTryReturn(NID_UI_CTRL, index > -1, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. index = %d", index); + + int textLength = 0; + textLength = __pEdit->GetTextLength(); + + SysTryReturn(NID_UI_CTRL, textLength > index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] index(%d) is out of range. textLength(%d)", index, textLength); + + return __pEdit->DeleteCharacterAt(index); +} + +result +_SearchBar::Clear(void) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->ClearText(); +} + +int +_SearchBar::GetTextLength(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->GetTextLength(); +} + +String +_SearchBar::GetText(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->GetText(); +} + +String +_SearchBar::GetText(int start, int end) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->GetText(start, end); +} + +int +_SearchBar::GetLimitLength(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->GetTextLimitLength(); +} + +result +_SearchBar::SetLimitLength(int limitLength) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used.limitLength = %d", limitLength); + + String tempString = GetText(); + + int textLength = tempString.GetLength(); + SysTryReturn(NID_UI_CTRL, limitLength >= textLength, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. limitLength = %d, textLength = %d", limitLength, textLength); + + result r = __pEdit->SetLimitLength(limitLength); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetText(tempString); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_SearchBar::ShowKeypad(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + SearchBarMode mode = __pSearchBarPresenter->GetMode(); + SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] The SearchBar is currently in Normal mode."); + return __pEdit->ShowKeypad(); +} + +result +_SearchBar::HideKeypad(void) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + SearchBarMode mode = __pSearchBarPresenter->GetMode(); + SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The SearchBar is currently in Normal mode."); + + result r = __pEdit->HideKeypad(); + + SetContentsArea(); + + return r; +} + +int +_SearchBar::GetSearchFieldTextSize(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->GetTextSize(); +} + +result +_SearchBar::SetSearchFieldTextSize(int size) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->SetTextSize(size); +} + +result +_SearchBar::GetBlockRange(int& start, int& end) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + int startIndex = -1; + int endIndex = -1; + + __pEdit->GetBlockRange(startIndex, endIndex); + SysTryReturn(NID_UI_CTRL, (startIndex > -1 && endIndex > -1), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get text block range."); + + start = startIndex; + end = endIndex; + + return E_SUCCESS; +} + +result +_SearchBar::ReleaseBlock(void) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + result r = E_SUCCESS; + + int start = 0; + int end = 0; + + r = GetBlockRange(start, end); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pEdit->ReleaseTextBlock(); +} + +result +_SearchBar::SetBlockRange(int start, int end) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + result r = E_SUCCESS; + + int textLength = 0; + textLength = __pEdit->GetTextLength(); + SysTryReturn(NID_UI_CTRL, (textLength > start && textLength > end), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. textLength = %d, start = %d, end = %d", start, end); + SysTryReturn(NID_UI_CTRL, (start <= end && start >= 0), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. start = %d, end = %d", start, end); + + r = SetCursorPosition(start); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = __pEdit->BeginTextBlock(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set text block range."); + + r = SetCursorPosition(end); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set cursor position."); + + return E_SUCCESS; +} + +result +_SearchBar::RemoveTextBlock(void) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + result r = E_SUCCESS; + + int start = 0; + int end = 0; + + r = GetBlockRange(start, end); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + for (int index = start; index < end; index++) + { + r = __pEdit->DeleteCharacterAt(start); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + + return r; +} + +Color +_SearchBar::GetColor(void) const +{ + Variant backgroundColor = GetProperty("color"); + + return backgroundColor.ToColor(); +} + +Color +_SearchBar::GetSearchFieldColor(SearchFieldStatus status) const +{ + Variant searchFieldColor; + + switch (status) + { + case SEARCH_FIELD_STATUS_NORMAL: + searchFieldColor = GetProperty("searchFieldNormalColor"); + break; + case SEARCH_FIELD_STATUS_HIGHLIGHTED: + searchFieldColor = GetProperty("searchFieldHighlightedColor"); + break; + case SEARCH_FIELD_STATUS_DISABLED: + searchFieldColor = GetProperty("searchFieldDisabledColor"); + break; + default: + break; + } + + return searchFieldColor.ToColor(); +} + + +Color +_SearchBar::GetSearchFieldTextColor(SearchFieldStatus status) const +{ + Variant searchFieldTextColor; + + switch (status) + { + case SEARCH_FIELD_STATUS_NORMAL: + searchFieldTextColor = GetProperty("searchFieldNormalTextColor"); + break; + case SEARCH_FIELD_STATUS_HIGHLIGHTED: + searchFieldTextColor = GetProperty("searchFieldHighlightedTextColor"); + break; + case SEARCH_FIELD_STATUS_DISABLED: + searchFieldTextColor = GetProperty("searchFieldDisabledTextColor"); + break; + default: + break; + } + + return searchFieldTextColor.ToColor(); +} + + +result +_SearchBar::SetBackgroundBitmap(const Bitmap& bitmap) +{ + Bitmap* pNewBitmap = _BitmapImpl::CloneN(bitmap); + SysTryReturn(NID_UI_CTRL, pNewBitmap, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The creation of bitmap failed."); + + delete __pBackgroundBitmap; + __pBackgroundBitmap = null; + + __pBackgroundBitmap = pNewBitmap; + + return E_SUCCESS; +} + +Bitmap* +_SearchBar::GetBackgroundBitmap(void) const +{ + return __pBackgroundBitmap; +} + +result +_SearchBar::SetColor(const Color& color) +{ + return SetProperty("color", Variant(color)); +} + +result +_SearchBar::SetSearchFieldColor(SearchFieldStatus status, const Color& color) +{ + result r = E_SUCCESS; + + switch (status) + { + case SEARCH_FIELD_STATUS_NORMAL: + r = SetProperty("searchFieldNormalColor", Variant(color)); + break; + case SEARCH_FIELD_STATUS_HIGHLIGHTED: + r = SetProperty("searchFieldHighlightedColor", Variant(color)); + break; + case SEARCH_FIELD_STATUS_DISABLED: + r = SetProperty("searchFieldDisabledColor", Variant(color)); + break; + default: + break; + } + + return r; +} + + +result +_SearchBar::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color) +{ + result r = E_SUCCESS; + + switch (status) + { + case SEARCH_FIELD_STATUS_NORMAL: + r = SetProperty("searchFieldNormalTextColor", Variant(color)); + break; + case SEARCH_FIELD_STATUS_HIGHLIGHTED: + r = SetProperty("searchFieldHighlightedTextColor", Variant(color)); + break; + case SEARCH_FIELD_STATUS_DISABLED: + r = SetProperty("searchFieldDisabledTextColor", Variant(color)); + break; + default: + break; + } + + return r; +} + + +String +_SearchBar::GetGuideText(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, String(), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->GetGuideText(); +} + +result +_SearchBar::SetGuideText(const String& guideText) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + __pEdit->SetGuideText(guideText); + + return E_SUCCESS; +} + +Color +_SearchBar::GetGuideTextColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->GetGuideTextColor(); +} + +result +_SearchBar::SetGuideTextColor(const Color& color) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->SetGuideTextColor(color); +} + +int +_SearchBar::GetCursorPosition(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, -1, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->GetCursorPosition(); +} + +result +_SearchBar::SetCursorPosition(int index) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + SysTryReturn(NID_UI_CTRL, index > -1, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] index(%d) is out of range.", GetErrorMessage(E_OUT_OF_RANGE), index); + + int textLength = -1; + textLength = __pEdit->GetTextLength(); + + SysTryReturn(NID_UI_CTRL, (index > -1 && index <= textLength), E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] index(%d) is out of range.", index); + + return __pEdit->SetCursorPosition(index); +} + +bool +_SearchBar::IsLowerCaseModeEnabled(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->IsLowerCaseModeEnabled(); +} + +void +_SearchBar::SetLowerCaseModeEnabled(bool enable) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pEdit, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + __pEdit->SetLowerCaseModeEnabled(enable); +} + +EllipsisPosition +_SearchBar::GetEllipsisPosition(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, ELLIPSIS_POSITION_START, ELLIPSIS_POSITION_START, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return __pEdit->GetEllipsisPosition(); +} + +result +_SearchBar::SetEllipsisPosition(EllipsisPosition position) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + __pEdit->SetEllipsisPosition(position); + + return E_SUCCESS; +} + +CoreKeypadAction +_SearchBar::GetKeypadAction(void) const +{ + return __keypadAction; +} + +bool +_SearchBar::IsTextPredictionEnabled(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, false, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + return __pEdit->IsTextPredictionEnabled(); +} + +result +_SearchBar::SetTextPredictionEnabled(bool enable) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + return __pEdit->SetTextPredictionEnabled(enable); +} + +result +_SearchBar::SetCurrentLanguage(LanguageCode languageCode) +{ + return __pEdit->SetCurrentLanguage(languageCode); +} + +result +_SearchBar::GetCurrentLanguage(LanguageCode& language) const +{ + return __pEdit->GetCurrentLanguage(language); +} + +result +_SearchBar::AddActionEventListener(const _IActionEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pActionEvent == null) + { + __pActionEvent = _ActionEvent::CreateInstanceN(*this); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + __pActionEvent->AddListener(listener); + } + + return r; +} + +result +_SearchBar::RemoveActionEventListener(const _IActionEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The action event instance is null."); + result r = E_SUCCESS; + + r = __pActionEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +result +_SearchBar::AddKeypadEventListener(const _IKeypadEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pKeypadEvent == null) + { + __pKeypadEvent = _KeypadEvent::CreateInstanceN(*this); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = __pKeypadEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + + return r; +} + +result +_SearchBar::RemoveKeypadEventListener(const _IKeypadEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pKeypadEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The keypad event instance is null."); + result r = E_SUCCESS; + + r = __pKeypadEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +result +_SearchBar::AddTextBlockEventListener(const _ITextBlockEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pTextBlockEvent == null) + { + __pTextBlockEvent = _TextBlockEvent::CreateInstanceN(*this); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = __pTextBlockEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + } + + return r; +} + +result +_SearchBar::RemoveTextBlockEventListener(const _ITextBlockEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pTextBlockEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The text block event instance is null."); + result r = E_SUCCESS; + + r = __pTextBlockEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + + +result +_SearchBar::AddTextEventListener(const _ITextEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pTextEvent == null) + { + __pTextEvent = _TextEvent::CreateInstanceN(*this); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = __pTextEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + + return r; +} + +result +_SearchBar::RemoveTextEventListener(const _ITextEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pTextEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The text event instance is null."); + result r = E_SUCCESS; + + r = __pTextEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +result +_SearchBar::AddSearchBarEventListener(const _ISearchBarEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pSearchBarEvent == null) + { + __pSearchBarEvent = _SearchBarEvent::CreateInstanceN(*this); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = __pSearchBarEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + + return r; +} + +result +_SearchBar::RemoveSearchBarEventListener(const _ISearchBarEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pSearchBarEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The searchbar event instance is null."); + result r = E_SUCCESS; + + r = __pSearchBarEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +result +_SearchBar::AddLanguageEventListener(const _ILanguageEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pLanguageEvent == null) + { + __pLanguageEvent = _LanguageEvent::CreateInstanceN(*this); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = __pLanguageEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + + return r; +} + +result +_SearchBar::RemoveLanguageEventListener(const _ILanguageEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pLanguageEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + result r = E_SUCCESS; + + __pLanguageEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +void +_SearchBar::OnBoundsChanged(void) +{ + if (__pSearchBarPresenter != null) + { + __pSearchBarPresenter->OnBoundsChanged(); + } + return; +} + +void +_SearchBar::OnDraw(void) +{ + __pSearchBarPresenter->Draw(); + return; +} + +_UiTouchEventDelivery +_SearchBar::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + _Edit* pEdit = dynamic_cast <_Edit*>(const_cast <_Control*>(&source)); + if (pEdit == null) + { + return _UI_TOUCH_EVENT_DELIVERY_YES; + } + + if (GetMode() == SEARCH_BAR_MODE_INPUT) + { + return _UI_TOUCH_EVENT_DELIVERY_YES; + } + + SetMode(SEARCH_BAR_MODE_INPUT); + + return _UI_TOUCH_EVENT_DELIVERY_YES; +} + +void +_SearchBar::OnActionPerformed(const _Control& source, int actionId) +{ + if (__actionId == actionId) + { + __isCancelActionInProgress = true; + SetMode(SEARCH_BAR_MODE_NORMAL); + + if (__pActionEvent) + { + IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pActionEvent->Fire(*pEventArg); + } + __isCancelActionInProgress = false; + } + return; +} + +// Keypad callbacks +void +_SearchBar::OnKeypadWillOpen(void) +{ + if (__pKeypadEvent) + { + IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CREATED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pKeypadEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBar::OnKeypadOpened(void) +{ + if (__pKeypadEvent) + { + IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_OPEN); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pKeypadEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBar::OnKeypadClosed(void) +{ + if (__pKeypadEvent) + { + IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_CLOSE); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pKeypadEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBar::OnKeypadBoundsChanged(void) +{ + if (__pKeypadEvent) + { + IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(CORE_KEYPAD_ACTION_SEARCH, CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pKeypadEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBar::OnKeypadActionPerformed(CoreKeypadAction keypadAction) +{ + if (__pKeypadEvent) + { + IEventArg* pEventArg = _KeypadEvent::CreateKeypadEventArgN(keypadAction, CORE_KEYPAD_EVENT_STATUS_ENTERACTION); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pKeypadEvent->Fire(*pEventArg); + } + return; +} + +// TextBlock callbacks +void +_SearchBar::OnTextBlockSelected(_Control& source, int start, int end) +{ + if (__pTextBlockEvent) + { + IEventArg* pEventArg = _TextBlockEvent::CreateTextBlockEventArgN(start, end); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTextBlockEvent->Fire(*pEventArg); + } + return; +} + +// Text callbacks +void +_SearchBar::OnTextValueChanged(const _Control& source) +{ + if (!__isCancelActionInProgress) + { + SetContentDimming(); + if (__pTextEvent != null) + { + IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CHANGED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTextEvent->Fire(*pEventArg); + } + } + return; +} + +void +_SearchBar::OnTextValueChangeCanceled(const _Control& source) +{ + if (__pTextEvent != null) + { + IEventArg* pEventArg = _TextEvent::CreateTextEventArgN(CORE_TEXT_EVENT_CANCELED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTextEvent->Fire(*pEventArg); + } + return; +} + +result +_SearchBar::OnAttachedToMainTree(void) +{ + SetContentsArea(); + + return E_SUCCESS; +} + +void +_SearchBar::OnFontChanged(Font* pFont) +{ + __pCancelButton->SetFont(pFont->GetFaceName()); + __pEdit->SetFont(*pFont); + return; +} + +void +_SearchBar::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = FONT_STYLE_PLAIN; + size = __pCancelButton->GetTextSize(); + + return; +} + +bool +_SearchBar::OnFocusGained(const _Control& source) +{ + SetMode(SEARCH_BAR_MODE_INPUT); + __pEdit->SetFocused(); + return false; +} + +bool +_SearchBar::OnFocusLost(const _Control& source) +{ + return false; +} + +_Control* +_SearchBar::GetParentForm(void) const +{ + _Form* pForm = null; + _Control* pControlCore = GetParent(); + + while (true) + { + if (pControlCore == null) + { + SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null."); + + return null; + } + + pForm = dynamic_cast <_Form*>(pControlCore); + + if (pForm != null) + { + break; + } + + pControlCore = pControlCore->GetParent(); + } + + return pControlCore; +} + +_Button* +_SearchBar::GetSearchBarButton(void) const +{ + return __pCancelButton; +} + +_Edit* +_SearchBar::GetSearchField(void) +{ + return __pEdit; +} + +_Control* +_SearchBar::GetSearchBarContainer(void) const +{ + return __pContainer; +} + +_Control* +_SearchBar::GetClippedGroupControl(void) const +{ + return __pClippedGroupControl; +} + +bool +_SearchBar::IsUsableCancelButton(void) const +{ + return __isUsableCancelButton; +} + +EditStatus +_SearchBar::ConvertSearchBarStatus(SearchFieldStatus status) +{ + EditStatus editStatus = EDIT_STATUS_NORMAL; + switch (status) + { + case SEARCH_FIELD_STATUS_NORMAL: + editStatus = EDIT_STATUS_NORMAL; + break; + + case SEARCH_FIELD_STATUS_DISABLED: + editStatus = EDIT_STATUS_DISABLED; + break; + + case SEARCH_FIELD_STATUS_HIGHLIGHTED: + editStatus = EDIT_STATUS_HIGHLIGHTED; + break; + default: + break; + } + + return editStatus; +} + +_ButtonStatus +_SearchBar::ConvertSearchBarButtonStatus(SearchBarButtonStatus status) +{ + _ButtonStatus buttonStatus = _BUTTON_STATUS_NORMAL; + + switch (status) + { + case SEARCH_BAR_BUTTON_STATUS_NORMAL: + buttonStatus = _BUTTON_STATUS_NORMAL; + break; + + case SEARCH_BAR_BUTTON_STATUS_PRESSED: + buttonStatus = _BUTTON_STATUS_PRESSED; + break; + + case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED: + buttonStatus = _BUTTON_STATUS_HIGHLIGHTED; + break; + + case SEARCH_BAR_BUTTON_STATUS_DISABLED: + buttonStatus = _BUTTON_STATUS_DISABLED; + break; + default: + break; + } + + return buttonStatus; +} + +result +_SearchBar::SendSearchBarEvent(_SearchBarEventStatus status) +{ + result r = E_SUCCESS; + if (__pSearchBarEvent) + { + IEventArg* pEventArg = _SearchBarEvent::CreateSearchBarEventArgN(status); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (IsContentAreaVisible() == false) + { + SetContentAreaVisible(false); + } + + __pSearchBarEvent->Fire(*pEventArg); + } + + return E_SUCCESS; +} + +void +_SearchBar::SetHeaderVisibleState(bool visible) +{ + if (__pSearchBarPresenter != null) + { + __pSearchBarPresenter->SetHeaderVisibleState(visible); + } + return; +} + +result +_SearchBar::SetPropertyButtonActionId(const Variant& actionId) +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + SysTryReturn(NID_UI_CTRL, actionId.ToInt() > -1, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. actionId.ToInt() = %d", actionId.ToInt()); + + result r = E_SUCCESS; + + r = __pCancelButton->SetPropertyActionId(actionId); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[%s] A system error has occurred. Failed to set actionId.", GetErrorMessage(E_SYSTEM)); + + __actionId = actionId.ToInt(); + + return r; +} + +Variant +_SearchBar::GetPropertyButtonActionId(void) const +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(-1), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + return Variant(__actionId); +} + +result +_SearchBar::SetPropertyButtonDisabledColor(const Variant& color) +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + result r = E_SUCCESS; + + r = __pCancelButton->SetPropertyDisabledColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set button color."); + + __buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = color.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertyButtonDisabledColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]); +} + +result +_SearchBar::SetPropertyButtonHighlightedColor(const Variant& color) +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + result r = E_SUCCESS; + + r = __pCancelButton->SetPropertyHighlightedColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set button color."); + + __buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertyButtonHighlightedColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]); +} + +result +_SearchBar::SetPropertyButtonNormalColor(const Variant& color) +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + result r = E_SUCCESS; + + r = __pCancelButton->SetPropertyNormalColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set button color."); + + __buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = color.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertyButtonNormalColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]); +} + +result +_SearchBar::SetPropertyButtonPressedColor(const Variant& color) +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + result r = E_SUCCESS; + + r = __pCancelButton->SetPropertyPressedColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set button color."); + + __buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = color.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertyButtonPressedColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + return Variant(__buttonColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]); +} + +result +_SearchBar::SetPropertyButtonDisabledTextColor(const Variant& textColor) +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + result r = E_SUCCESS; + + r = __pCancelButton->SetPropertyDisabledTextColor(textColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set button text color."); + + __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED] = textColor.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertyButtonDisabledTextColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_DISABLED]); +} + +result +_SearchBar::SetPropertyButtonHighlightedTextColor(const Variant& textColor) +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM]] A system error has occurred. The cancel button instance is null."); + + result r = E_SUCCESS; + + r = __pCancelButton->SetPropertyHighlightedTextColor(textColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set button text color."); + + __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED] = textColor.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertyButtonHighlightedTextColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED]); +} + +result +_SearchBar::SetPropertyButtonNormalTextColor(const Variant& textColor) +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + result r = E_SUCCESS; + + r = __pCancelButton->SetPropertyNormalTextColor(textColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set button text color."); + + __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL] = textColor.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertyButtonNormalTextColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_NORMAL]); +} + +result +_SearchBar::SetPropertyButtonPressedTextColor(const Variant& textColor) +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + result r = E_SUCCESS; + + r = __pCancelButton->SetPropertyPressedTextColor(textColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set button text color."); + + __buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED] = textColor.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertyButtonPressedTextColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pCancelButton, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + return Variant(__buttonTextColor[SEARCH_BAR_BUTTON_STATUS_PRESSED]); +} + +result +_SearchBar::SetPropertySearchFieldDisabledColor(const Variant& color) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + result r = E_SUCCESS; + + r = __pEdit->SetPropertyDisabledColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set the edit disabled color."); + + __color[SEARCH_FIELD_STATUS_DISABLED] = color.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertySearchFieldDisabledColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return Variant(__color[SEARCH_FIELD_STATUS_DISABLED]); +} + +result +_SearchBar::SetPropertySearchFieldHighlightedColor(const Variant& color) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + result r = E_SUCCESS; + + r = __pEdit->SetPropertyHighlightedColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set the edit highlighted color."); + + __color[SEARCH_FIELD_STATUS_HIGHLIGHTED] = color.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertySearchFieldHighlightedColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return Variant(__color[SEARCH_FIELD_STATUS_HIGHLIGHTED]); +} + +result +_SearchBar::SetPropertySearchFieldNormalColor(const Variant& color) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + result r = E_SUCCESS; + + r = __pEdit->SetPropertyNormalColor(color); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set edit normal color."); + + __color[SEARCH_FIELD_STATUS_NORMAL] = color.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertySearchFieldNormalColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return Variant(__color[SEARCH_FIELD_STATUS_NORMAL]); +} + +result +_SearchBar::SetPropertySearchFieldDisabledTextColor(const Variant& textColor) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + result r = E_SUCCESS; + + r = __pEdit->SetPropertyDisabledTextColor(textColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set edit disabled text color."); + + __textColor[SEARCH_FIELD_STATUS_DISABLED] = textColor.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertySearchFieldDisabledTextColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return Variant(__textColor[SEARCH_FIELD_STATUS_DISABLED]); +} + +result +_SearchBar::SetPropertySearchFieldHighlightedTextColor(const Variant& textColor) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + result r = E_SUCCESS; + + r = __pEdit->SetPropertyHighlightedTextColor(textColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set edit highlighted text color."); + + __textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED] = textColor.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertySearchFieldHighlightedTextColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return Variant(__textColor[SEARCH_FIELD_STATUS_HIGHLIGHTED]); +} + +result +_SearchBar::SetPropertySearchFieldNormalTextColor(const Variant& textColor) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + result r = E_SUCCESS; + + r = __pEdit->SetPropertyNormalTextColor(textColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set edit normal text color."); + + __textColor[SEARCH_FIELD_STATUS_NORMAL] = textColor.ToColor(); + + return r; +} + +Variant +_SearchBar::GetPropertySearchFieldNormalTextColor(void) const +{ + SysTryReturn(NID_UI_CTRL, __pEdit, Variant(Color()), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + return Variant(__textColor[SEARCH_FIELD_STATUS_NORMAL]); +} + +result +_SearchBar::SetPropertyColor(const Variant& color) +{ + __backgroundColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_SearchBar::GetPropertyColor(void) const +{ + return Variant(__backgroundColor); +} + +result +_SearchBar::SetPropertyContentAreaSize(const Variant& size) +{ + Dimension contentAreaSize = size.ToDimension(); + SysTryReturn(NID_UI_CTRL, contentAreaSize.width >= 0 && contentAreaSize.height >= 0, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. contentAreaSize.width = %d, contenAreaSize.height = %d", + contentAreaSize.width, contentAreaSize.height); + + result r = E_SUCCESS; + + // Todo + Rectangle bounds = GetBounds(); + Rectangle contentAreaBounds(0, 0, 0, 0); + + contentAreaBounds.x = 0; + contentAreaBounds.y = bounds.height; + contentAreaBounds.width = contentAreaSize.width; + contentAreaBounds.height = contentAreaSize.height; + + __contentAreaBounds = contentAreaBounds; + __isUserContainerBounds = true; + + // set bounds + if (__pContainer) + { + r = __pContainer->SetBounds(__contentAreaBounds); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + + return r; +} + +Variant +_SearchBar::GetPropertyContentAreaSize(void) const +{ + Dimension contentAreaSize(__contentAreaBounds.width, __contentAreaBounds.height); + + return Variant(contentAreaSize); +} + +result +_SearchBar::CreateClippedGroupControl(void) +{ + result r = E_SUCCESS; + Rectangle clippedGroupControlBounds(Point(0, 0), GetSize()); + + __pClippedGroupControl = _Control::CreateControlN(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = AttachChild(*__pClippedGroupControl); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to attach the parent of clipped control."); + + r = __pClippedGroupControl->SetBounds(clippedGroupControlBounds); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pClippedGroupControl->SetBackgroundColor(Color(0)); + + __pClippedGroupControl->SetClipChildrenEnabled(true); + + return r; + +CATCH: + delete __pClippedGroupControl; + __pClippedGroupControl = null; + + return r; + +} + +void +_SearchBar::SetContentDimming(void) +{ + if(__pContainer != NULL) + { + if (!GetTextLength()) + { + __contentColor.SetAlpha(_SEARCH_CONTENT_DIM_OPACITY); + } + else + { + __contentColor.SetAlpha(0); + } + __pContainer->SetBackgroundColor(__contentColor); + } + return; +} + +bool +_SearchBar::IsContentAttachable(const _Control* pContent) +{ + const _Window* pWindow = dynamic_cast (pContent); + const _ColorPicker* pColorPicker = dynamic_cast (pContent); + const _Form* pForm = dynamic_cast (pContent); + const _Keypad* pKeypad = dynamic_cast (pContent); + const _OverlayPanel* pOverlayPanel = dynamic_cast (pContent); + + bool isContentAttachable = true; + + isContentAttachable = ((pWindow == null) && (pColorPicker == null) && + (pForm == null) && (pKeypad == null) && (pOverlayPanel == null)); + return isContentAttachable; +} + +result +_SearchBar::ResizeCancelButton(void) +{ + result r = E_SUCCESS; + + int horizontalMargin = 0; + int buttonLeftMargin = 0; + int buttonRightMargin = 0; + int buttonMinWidth = 0; + int searchFieldMinWidth = 0; + + Rectangle cancelButtonBounds; + Rectangle searchBarBounds = GetBounds(); + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, cancelButtonBounds.width); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_HEIGHT, orientation, cancelButtonBounds.height); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_MIN_WIDTH, orientation, buttonMinWidth); + GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth); + + int buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth + + cancelButtonBounds.width + buttonLeftMargin + buttonRightMargin); + + if(searchBarBounds.width < buttonResizableSearchBarWidth) + { + cancelButtonBounds.width = searchBarBounds.width -(searchFieldMinWidth + buttonLeftMargin + + buttonRightMargin + horizontalMargin); + } + + cancelButtonBounds.x = searchBarBounds.width - cancelButtonBounds.width - buttonRightMargin; + cancelButtonBounds.y = (searchBarBounds.height - cancelButtonBounds.height)/2; + + + if(cancelButtonBounds.width < buttonMinWidth) + { + cancelButtonBounds.width = buttonMinWidth; + } + + cancelButtonBounds.width = (cancelButtonBounds.width > 0) ? cancelButtonBounds.width : 0; + cancelButtonBounds.height = (cancelButtonBounds.height > 0) ? cancelButtonBounds.height : 0; + + r = __pCancelButton->SetBounds(cancelButtonBounds); + + return r; + +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SearchBarEvent.cpp b/src/ui/controls/FUiCtrl_SearchBarEvent.cpp new file mode 100644 index 0000000..8f7e287 --- /dev/null +++ b/src/ui/controls/FUiCtrl_SearchBarEvent.cpp @@ -0,0 +1,192 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include "FUiCtrl_ISearchBarEventListener.h" +#include "FUiCtrl_SearchBarEvent.h" +#include "FUiCtrl_SearchBar.h" + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _SearchBarEventArg + * @brief This class is used as the argument to action event listener. + * + * This class is used as the argument to searchbar event listener. When an searchbar event is generated + * (such as when a searchbar is pressed) the SearchBarEvent calls SearchBarEventListener's OnActionPerformed + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the action ID. + */ +class _OSP_EXPORT_ _SearchBarEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] status + */ + _SearchBarEventArg(_SearchBarEventStatus status); + + /** + * This is the class destructor. + * + */ + virtual ~_SearchBarEventArg(void); + + +// Access +public: + /** + * This method returns the status which the event initially occurred. + * + * @return See the comment above. + */ + _SearchBarEventStatus GetStatus(void) const; + + +// Attribute +private: + /** + * Event status. + */ + _SearchBarEventStatus __status; +}; + +_SearchBarEventArg::_SearchBarEventArg(_SearchBarEventStatus status) + : __status(status) +{ + // nothing +} + +_SearchBarEventArg::~_SearchBarEventArg(void) +{ + // nothing +} + +//////////////////////////////////////////////////////////////////////////////// +/// _SearchBarEventArg class Access + +_SearchBarEventStatus +_SearchBarEventArg::GetStatus(void) const +{ + return __status; +} + + +//////////////////////////////////////////////////////////////////////////////// +/// _SearchBarEvent class Lifecycle + +_SearchBarEvent::_SearchBarEvent(const _SearchBar& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_SearchBarEvent::~_SearchBarEvent(void) +{ + // nothing +} + +_SearchBarEvent* +_SearchBarEvent::CreateInstanceN(const _SearchBar& source) +{ + _SearchBarEvent* pSearchBarEvent = new (std::nothrow) _SearchBarEvent(source); + SysTryReturn(NID_UI_CTRL, pSearchBarEvent, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pSearchBarEvent; + +CATCH: + delete pSearchBarEvent; + return null; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _WindowEvent class Accessor + +const _SearchBar* +_SearchBarEvent::GetSource(void) const +{ + return __pSource; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _SearchBarEvent class Operation + +void +_SearchBarEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg) +{ + // cast to _IActionEventListener + _ISearchBarEventListener* pSearchBarListener = dynamic_cast <_ISearchBarEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pSearchBarListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The searchbar listener instance is null."); + + // cast to _SearchBarEventArg + const _SearchBarEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The argument to searchbar event listener is null."); + + _SearchBar* pSource = null; + pSource = const_cast <_SearchBar*>(__pSource); + SysTryReturnVoidResult(NID_UI_CTRL, pSource != null, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used.The searchbar instance is null."); + + // call cursor change event listener method + _SearchBarEventStatus status = pArg->GetStatus(); + if (status == _SEARCH_BAR_EVENT_MODE_CHANGE) + { + pSearchBarListener->OnSearchBarModeChanged(*pSource, pSource->GetMode()); + } + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_SearchBarEvent::CreateSearchBarEventArgN(_SearchBarEventStatus status) +{ + _SearchBarEventArg* pEventArg = new (std::nothrow) _SearchBarEventArg(status); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SearchBarImpl.cpp b/src/ui/controls/FUiCtrl_SearchBarImpl.cpp new file mode 100644 index 0000000..7a76d8d --- /dev/null +++ b/src/ui/controls/FUiCtrl_SearchBarImpl.cpp @@ -0,0 +1,1700 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SearchBarImpl.cpp + * @brief This is the implementation file for _SearchBarImpl class. + */ + +#include +#include +#include +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_PublicActionEvent.h" +#include "FUiCtrl_PublicTextBlockEvent.h" +#include "FUiCtrl_PublicTextEvent.h" +#include "FUiCtrl_SearchBarImpl.h" + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Locales; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_SearchBarImpl::_SearchBarImpl(SearchBar* pPublic, _SearchBar* pCore) + : _ControlImpl(pPublic, pCore) + , __pSearchBar(pCore) + , __pContentControl(null) + , __pPublicActionEvent(null) + , __pPublicKeypadEvent(null) + , __pPublicTextBlockEvent(null) + , __pPublicTextEvent(null) + , __pPublicSearchBarEvent(null) + , __pPublicLanguageEvent(null) +{ + ClearLastResult(); +} + +_SearchBarImpl::~_SearchBarImpl(void) +{ + if (__pSearchBar) + { + SetContent(null); + } + + if (__pPublicActionEvent) + { + delete __pPublicActionEvent; + __pPublicActionEvent = null; + } + + if (__pPublicKeypadEvent) + { + delete __pPublicKeypadEvent; + __pPublicKeypadEvent = null; + } + + if (__pPublicTextBlockEvent) + { + delete __pPublicTextBlockEvent; + __pPublicTextBlockEvent = null; + } + + if (__pPublicTextEvent) + { + delete __pPublicTextEvent; + __pPublicTextEvent = null; + } + + if (__pPublicSearchBarEvent) + { + delete __pPublicSearchBarEvent; + __pPublicSearchBarEvent = null; + } +} + +_SearchBarImpl* +_SearchBarImpl::CreateSearchBarImplN(SearchBar* pControl, const Rectangle& bounds, bool enableSearchBarButton, KeypadAction keypadAction) +{ + ClearLastResult(); + result r = E_SUCCESS; + + r = GET_SIZE_INFO(SearchBar).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The given size is not valid."); + + _SearchBar* pCore = _SearchBar::CreateSearchBarN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _SearchBarImpl* pImpl = new (std::nothrow) _SearchBarImpl(pControl, pCore); + + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(SearchBar), bounds, pCore->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->Initialize(enableSearchBarButton, keypadAction); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; +CATCH: + delete pImpl; + return null; +} + +const char* +_SearchBarImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::SearchBar"; +} + +const SearchBar& +_SearchBarImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +SearchBar& +_SearchBarImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _SearchBar& +_SearchBarImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_SearchBar& +_SearchBarImpl::GetCore(void) +{ + return static_cast <_SearchBar&>(_ControlImpl::GetCore()); +} + +_SearchBarImpl* +_SearchBarImpl::GetInstance(SearchBar& searchBar) +{ + return (static_cast<_SearchBarImpl*>(searchBar._pControlImpl)); +} + +const _SearchBarImpl* +_SearchBarImpl::GetInstance(const SearchBar& searchBar) +{ + return (static_cast(searchBar._pControlImpl)); +} + + +result +_SearchBarImpl::Initialize(bool enableSearchBarButton, KeypadAction keypadAction) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + CoreKeypadAction coreKeypadAction = CORE_KEYPAD_ACTION_SEARCH; + switch (keypadAction) + { + case KEYPAD_ACTION_ENTER: + coreKeypadAction = CORE_KEYPAD_ACTION_ENTER; + break; + + case KEYPAD_ACTION_GO: + coreKeypadAction = CORE_KEYPAD_ACTION_GO; + break; + + case KEYPAD_ACTION_NEXT: + coreKeypadAction = CORE_KEYPAD_ACTION_NEXT; + break; + + case KEYPAD_ACTION_SEND: + coreKeypadAction = CORE_KEYPAD_ACTION_SEND; + break; + + case KEYPAD_ACTION_SEARCH: + coreKeypadAction = CORE_KEYPAD_ACTION_SEARCH; + break; + + case KEYPAD_ACTION_LOGIN: + coreKeypadAction = CORE_KEYPAD_ACTION_LOGIN; + break; + + case KEYPAD_ACTION_SIGN_IN: + coreKeypadAction = CORE_KEYPAD_ACTION_SIGN_IN; + break; + + case KEYPAD_ACTION_JOIN: + coreKeypadAction = CORE_KEYPAD_ACTION_JOIN; + break; + + case KEYPAD_ACTION_DONE: + coreKeypadAction = CORE_KEYPAD_ACTION_DONE; + break; + + default: + break; + } + + r = __pSearchBar->Initialize(enableSearchBarButton, coreKeypadAction); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pSearchBar->AddActionEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent = _PublicKeypadEvent::CreateInstanceN(GetPublic()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pSearchBar->AddKeypadEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTextBlockEvent = _PublicTextBlockEvent::CreateInstanceN(GetPublic()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pSearchBar->AddTextBlockEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTextEvent = _PublicTextEvent::CreateInstanceN(GetPublic()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pSearchBar->AddTextEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicSearchBarEvent = _PublicSearchBarEvent::CreateInstanceN(GetPublic()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicSearchBarEvent, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pSearchBar->AddSearchBarEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicLanguageEvent = _PublicLanguageEvent::CreateInstanceN(GetPublic()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pPublicLanguageEvent, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pSearchBar->AddLanguageEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Control* +_SearchBarImpl::GetContent(void) const +{ + ClearLastResult(); + + return __pContentControl; +} + +result +_SearchBarImpl::SetContent(const Control* pContent) +{ + ClearLastResult(); + + result r = E_SUCCESS; + if (pContent != null) + { + const _Control& content = _ControlImpl::GetInstance(*pContent)->GetCore(); + bool isContentAttachable = __pSearchBar->IsContentAttachable(&content); + SysTryReturn(NID_UI_CTRL, isContentAttachable, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The content cannot be set."); + } + + if (__pContentControl != null) + { + _Control& contentControl = _ControlImpl::GetInstance(*__pContentControl)->GetCore(); + + if (pContent != null) + { + const _Control& content = _ControlImpl::GetInstance(*pContent)->GetCore(); + + if (contentControl.GetHandle() == content.GetHandle()) + { + return r; + } + } + + _Control* pContainer = __pSearchBar->GetSearchBarContainer(); + + if (pContainer) + { + pContainer->DetachChild(contentControl); + + if(_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + delete __pContentControl; + } + __pContentControl = null; + } + } + + if (pContent != null && __pContentControl == null) + { + __pContentControl = const_cast (pContent); + _Control& control = _ControlImpl::GetInstance(*__pContentControl)->GetCore(); + + r = __pSearchBar->SetContent(&control); + } + + return r; +} + +result +_SearchBarImpl::UpdateContentArea(bool invalidate) +{ + ClearLastResult(); + + return __pSearchBar->UpdateContentArea(invalidate); +} + +result +_SearchBarImpl::SetContentAreaVisible(bool visible) +{ + ClearLastResult(); + + return __pSearchBar->SetContentAreaVisible(visible); +} + +bool +_SearchBarImpl::IsContentAreaVisible(void) const +{ + ClearLastResult(); + + return __pSearchBar->IsContentAreaVisible(); +} + +result +_SearchBarImpl::SetContentAreaSize(const Dimension& size) +{ + ClearLastResult(); + + Variant var(size); + + return __pSearchBar->SetPropertyContentAreaSize(var); +} + +Dimension +_SearchBarImpl::GetContentAreaSize(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetPropertyContentAreaSize().ToDimension(); +} + +SearchBarMode +_SearchBarImpl::GetMode(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetMode(); +} + +bool +_SearchBarImpl::IsModeLocked(void) const +{ + ClearLastResult(); + + return __pSearchBar->IsModeLocked(); +} + +result +_SearchBarImpl::SetMode(SearchBarMode mode) +{ + ClearLastResult(); + + return __pSearchBar->SetMode(mode); +} + +result +_SearchBarImpl::SetModeLocked(bool modeLocked) +{ + ClearLastResult(); + + return __pSearchBar->SetModeLocked(modeLocked); +} + +int +_SearchBarImpl::GetButtonActionId(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetPropertyButtonActionId().ToInt(); +} + +Color +_SearchBarImpl::GetButtonColor(SearchBarButtonStatus status) const +{ + ClearLastResult(); + + Variant buttonColor; + + switch (status) + { + case SEARCH_BAR_BUTTON_STATUS_NORMAL: + buttonColor = __pSearchBar->GetPropertyButtonNormalColor(); + break; + case SEARCH_BAR_BUTTON_STATUS_PRESSED: + buttonColor = __pSearchBar->GetPropertyButtonPressedColor(); + break; + case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED: + buttonColor = __pSearchBar->GetPropertyButtonHighlightedColor(); + break; + case SEARCH_BAR_BUTTON_STATUS_DISABLED: + buttonColor = __pSearchBar->GetPropertyButtonDisabledColor(); + break; + default: + break; + } + + return buttonColor.ToColor(); +} + +Color +_SearchBarImpl::GetButtonTextColor(SearchBarButtonStatus status) const +{ + ClearLastResult(); + + Variant buttonTextColor; + + switch (status) + { + case SEARCH_BAR_BUTTON_STATUS_NORMAL: + buttonTextColor = __pSearchBar->GetPropertyButtonNormalTextColor(); + break; + case SEARCH_BAR_BUTTON_STATUS_PRESSED: + buttonTextColor = __pSearchBar->GetPropertyButtonPressedTextColor(); + break; + case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED: + buttonTextColor = __pSearchBar->GetPropertyButtonHighlightedTextColor(); + break; + case SEARCH_BAR_BUTTON_STATUS_DISABLED: + buttonTextColor = __pSearchBar->GetPropertyButtonDisabledTextColor(); + break; + default: + break; + } + + return buttonTextColor.ToColor(); +} + +SearchBarButtonStatus +_SearchBarImpl::GetButtonStatus(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetButtonStatus(); +} + +result +_SearchBarImpl::SetButton(const String& text, int actionId) +{ + ClearLastResult(); + + result r = E_SUCCESS; + Variant var(actionId); + + r = __pSearchBar->SetButtonText(text); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pSearchBar->SetPropertyButtonActionId(var); + + return r; +} + +result +_SearchBarImpl::SetButtonEnabled(bool enabled) +{ + ClearLastResult(); + + return __pSearchBar->SetButtonEnabled(enabled); +} + +result +_SearchBarImpl::SetButtonColor(SearchBarButtonStatus status, const Color& color) +{ + ClearLastResult(); + + result r = E_SUCCESS; + Variant var(color); + + switch (status) + { + case SEARCH_BAR_BUTTON_STATUS_NORMAL: + r = __pSearchBar->SetPropertyButtonNormalColor(var); + break; + case SEARCH_BAR_BUTTON_STATUS_PRESSED: + r = __pSearchBar->SetPropertyButtonPressedColor(var); + break; + case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED: + r = __pSearchBar->SetPropertyButtonHighlightedColor(var); + break; + case SEARCH_BAR_BUTTON_STATUS_DISABLED: + r = __pSearchBar->SetPropertyButtonDisabledColor(var); + break; + default: + break; + } + + return r; +} + +result +_SearchBarImpl::SetButtonTextColor(SearchBarButtonStatus status, const Color& color) +{ + ClearLastResult(); + + result r = E_SUCCESS; + Variant var(color); + + switch (status) + { + case SEARCH_BAR_BUTTON_STATUS_NORMAL: + r = __pSearchBar->SetPropertyButtonNormalTextColor(var); + break; + case SEARCH_BAR_BUTTON_STATUS_PRESSED: + r = __pSearchBar->SetPropertyButtonPressedTextColor(var); + break; + case SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED: + r = __pSearchBar->SetPropertyButtonHighlightedTextColor(var); + break; + case SEARCH_BAR_BUTTON_STATUS_DISABLED: + r = __pSearchBar->SetPropertyButtonDisabledTextColor(var); + break; + default: + break; + } + + return r; +} + +result +_SearchBarImpl::AppendCharacter(const Character& character) +{ + ClearLastResult(); + + return __pSearchBar->AppendCharacter(character); +} + +result +_SearchBarImpl::AppendText(const String& text) +{ + ClearLastResult(); + + return __pSearchBar->AppendText(text); +} + +result +_SearchBarImpl::SetText(const String& text) +{ + ClearLastResult(); + + return __pSearchBar->SetText(text); +} + +result +_SearchBarImpl::InsertCharacterAt(int index, const Character& character) +{ + ClearLastResult(); + + return __pSearchBar->InsertCharacterAt(index, character); +} + +result +_SearchBarImpl::InsertTextAt(int index, const String& text) +{ + ClearLastResult(); + + return __pSearchBar->InsertTextAt(index, text); +} + +result +_SearchBarImpl::DeleteCharacterAt(int index) +{ + ClearLastResult(); + + return __pSearchBar->DeleteCharacterAt(index); +} + +result +_SearchBarImpl::Clear(void) +{ + ClearLastResult(); + + return __pSearchBar->Clear(); +} + +int +_SearchBarImpl::GetTextLength(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetTextLength(); +} + +String +_SearchBarImpl::GetText(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetText(); +} + +String +_SearchBarImpl::GetText(int start, int end) const +{ + ClearLastResult(); + + return __pSearchBar->GetText(start, end); +} + +int +_SearchBarImpl::GetLimitLength(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetLimitLength(); +} + +result +_SearchBarImpl::SetLimitLength(int limitLength) +{ + ClearLastResult(); + + return __pSearchBar->SetLimitLength(limitLength); +} + +result +_SearchBarImpl::ShowKeypad(void) const +{ + ClearLastResult(); + + return __pSearchBar->ShowKeypad(); +} + +result +_SearchBarImpl::HideKeypad(void) const +{ + ClearLastResult(); + + return __pSearchBar->HideKeypad(); +} + +int +_SearchBarImpl::GetSearchFieldTextSize(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetSearchFieldTextSize(); +} + +result +_SearchBarImpl::SetSearchFieldTextSize(int size) +{ + ClearLastResult(); + + return __pSearchBar->SetSearchFieldTextSize(size); +} + +result +_SearchBarImpl::GetBlockRange(int& start, int& end) const +{ + ClearLastResult(); + + return __pSearchBar->GetBlockRange(start, end); +} + +result +_SearchBarImpl::ReleaseBlock(void) +{ + ClearLastResult(); + + return __pSearchBar->ReleaseBlock(); +} + +result +_SearchBarImpl::SetBlockRange(int start, int end) +{ + ClearLastResult(); + + int tempTextLength = 0; + + tempTextLength = __pSearchBar->GetTextLength(); + SysTryReturnResult(NID_UI_CTRL, tempTextLength > start && tempTextLength > end, E_INVALID_ARG, + "Invalid argument(s) is used. tempTextLength(%d),start(%d), end(%d)", + tempTextLength, start, end); + + SysTryReturnResult(NID_UI_CTRL, (start <= end && start >= 0), E_INVALID_ARG, + "Invalid argument(s) is used. start(%d), end(%d)", start, end); + + return __pSearchBar->SetBlockRange(start, end); +} + +result +_SearchBarImpl::RemoveTextBlock(void) +{ + ClearLastResult(); + result r = __pSearchBar->RemoveTextBlock(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occured. Unable to remove the text block.") + + return r; +} + +Color +_SearchBarImpl::GetColor(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetPropertyColor().ToColor(); +} + +Color +_SearchBarImpl::GetSearchFieldColor(SearchFieldStatus status) const +{ + ClearLastResult(); + + Variant searchFieldColor; + + switch (status) + { + case SEARCH_FIELD_STATUS_NORMAL: + searchFieldColor = __pSearchBar->GetPropertySearchFieldNormalColor(); + break; + case SEARCH_FIELD_STATUS_HIGHLIGHTED: + searchFieldColor = __pSearchBar->GetPropertySearchFieldHighlightedColor(); + break; + case SEARCH_FIELD_STATUS_DISABLED: + searchFieldColor = __pSearchBar->GetPropertySearchFieldDisabledColor(); + break; + default: + break; + } + + return searchFieldColor.ToColor(); +} + +Color +_SearchBarImpl::GetSearchFieldTextColor(SearchFieldStatus status) const +{ + ClearLastResult(); + + Color color; + _Edit* pEdit = __pSearchBar->GetSearchField(); + if (pEdit) + { + switch (status) + { + case SEARCH_FIELD_STATUS_NORMAL: + color = pEdit->GetTextColor(EDIT_TEXT_COLOR_NORMAL); + break; + case SEARCH_FIELD_STATUS_HIGHLIGHTED: + color = pEdit->GetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED); + break; + case SEARCH_FIELD_STATUS_DISABLED: + color = pEdit->GetTextColor(EDIT_TEXT_COLOR_DISABLED); + break; + default: + break; + } + } + return color; +} + +result +_SearchBarImpl::SetBackgroundBitmap(const Bitmap& bitmap) +{ + ClearLastResult(); + + return __pSearchBar->SetBackgroundBitmap(bitmap); +} + +result +_SearchBarImpl::SetColor(const Color& color) +{ + ClearLastResult(); + + Variant var(color); + + return __pSearchBar->SetPropertyColor(var); +} + +result +_SearchBarImpl::SetSearchFieldColor(SearchFieldStatus status, const Color& color) +{ + ClearLastResult(); + + result r = E_SUCCESS; + Variant var(color); + + switch (status) + { + case SEARCH_FIELD_STATUS_NORMAL: + r = __pSearchBar->SetPropertySearchFieldNormalColor(var); + break; + case SEARCH_FIELD_STATUS_HIGHLIGHTED: + r = __pSearchBar->SetPropertySearchFieldHighlightedColor(var); + break; + case SEARCH_FIELD_STATUS_DISABLED: + r = __pSearchBar->SetPropertySearchFieldDisabledColor(var); + break; + default: + break; + } + + return r; +} + +result +_SearchBarImpl::SetSearchFieldTextColor(SearchFieldStatus status, const Color& color) +{ + ClearLastResult(); + + result r = E_SUCCESS; + _Edit* pEdit = __pSearchBar->GetSearchField(); + if (pEdit) + { + switch (status) + { + case SEARCH_FIELD_STATUS_NORMAL: + r = pEdit->SetTextColor(EDIT_TEXT_COLOR_NORMAL, color); + break; + case SEARCH_FIELD_STATUS_HIGHLIGHTED: + r = pEdit->SetTextColor(EDIT_TEXT_COLOR_HIGHLIGHTED, color); + break; + case SEARCH_FIELD_STATUS_DISABLED: + r = pEdit->SetTextColor(EDIT_TEXT_COLOR_DISABLED, color); + break; + default: + break; + } + } + + return r; +} + +String +_SearchBarImpl::GetGuideText(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetGuideText(); +} + +result +_SearchBarImpl::SetGuideText(const String& guideText) +{ + ClearLastResult(); + + return __pSearchBar->SetGuideText(guideText); +} + +Color +_SearchBarImpl::GetGuideTextColor(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetGuideTextColor(); +} + +result +_SearchBarImpl::SetGuideTextColor(const Color& color) +{ + ClearLastResult(); + + return __pSearchBar->SetGuideTextColor(color); +} + +int +_SearchBarImpl::GetCursorPosition(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetCursorPosition(); +} + +result +_SearchBarImpl::SetCursorPosition(int index) +{ + ClearLastResult(); + + return __pSearchBar->SetCursorPosition(index); +} + +bool +_SearchBarImpl::IsLowerCaseModeEnabled(void) const +{ + ClearLastResult(); + + return __pSearchBar->IsLowerCaseModeEnabled(); +} + +void +_SearchBarImpl::SetLowerCaseModeEnabled(bool enable) +{ + ClearLastResult(); + + return __pSearchBar->SetLowerCaseModeEnabled(enable); +} + +EllipsisPosition +_SearchBarImpl::GetEllipsisPosition(void) const +{ + ClearLastResult(); + + return __pSearchBar->GetEllipsisPosition(); +} + +result +_SearchBarImpl::SetEllipsisPosition(EllipsisPosition position) +{ + ClearLastResult(); + + return __pSearchBar->SetEllipsisPosition(position); +} + +KeypadAction +_SearchBarImpl::GetKeypadAction(void) const +{ + ClearLastResult(); + + CoreKeypadAction coreKeypadAction = __pSearchBar->GetKeypadAction(); + KeypadAction publicKeypadAction = ConvertKeypadAction(coreKeypadAction); + + return publicKeypadAction; +} + +bool +_SearchBarImpl::IsTextPredictionEnabled(void) const +{ + return __pSearchBar->IsTextPredictionEnabled(); +} + +result +_SearchBarImpl::SetTextPredictionEnabled(bool enable) +{ + return __pSearchBar->SetTextPredictionEnabled(enable); +} + +result +_SearchBarImpl::SetCurrentLanguage(LanguageCode languageCode) +{ + return __pSearchBar->SetCurrentLanguage(languageCode); +} + +result +_SearchBarImpl::GetCurrentLanguage(LanguageCode& language) const +{ + return __pSearchBar->GetCurrentLanguage(language); +} + +result +_SearchBarImpl::AddActionEventListener(IActionEventListener& listener) +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred."); + + result r = __pPublicActionEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, + "A system error has occurred. The same listener instance already exists in the event listener list."); + return r; +} + +result +_SearchBarImpl::RemoveActionEventListener(IActionEventListener& listener) +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred."); + + result r = __pPublicActionEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, + "A system error has occurred. The specified listener does not exist in the event listener list."); + return r; +} + +result +_SearchBarImpl::AddKeypadEventListener(IKeypadEventListener& listener) +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred."); + + result r = __pPublicKeypadEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, + "A system error has occurred. The same listener instance already exists in the event listener list."); + + return r; +} + + +result +_SearchBarImpl::RemoveKeypadEventListener(IKeypadEventListener& listener) +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, __pPublicKeypadEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred."); + + result r = __pPublicKeypadEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, + "A system error has occurred. The specified listener does not exist in the event listener list."); + + return r; +} + +result +_SearchBarImpl::AddTextBlockEventListener(ITextBlockEventListener& listener) +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred."); + + result r = __pPublicTextBlockEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, + "A system error has occurred. The same listener instance already exists in the event listener list."); + + return r; +} + +result +_SearchBarImpl::RemoveTextBlockEventListener(ITextBlockEventListener& listener) +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred."); + + result r = __pPublicTextBlockEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, + "A system error has occurred. The specified listener does not exist in the event listener list."); + + return r; +} + + +result +_SearchBarImpl::AddTextEventListener(ITextEventListener& listener) +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred."); + + result r = __pPublicTextEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, + "A system error has occurred. The same listener instance already exists in the event listener list."); + + return r; +} + +result +_SearchBarImpl::RemoveTextEventListener(ITextEventListener& listener) +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, __pPublicTextEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred."); + + result r = __pPublicTextEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, + "A system error has occurred. The specified listener does not exist in the event listener list."); + + return r; +} + +result +_SearchBarImpl::AddSearchBarEventListener(const ISearchBarEventListener& listener) +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, __pPublicSearchBarEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred."); + + result r = __pPublicSearchBarEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, + "A system error has occurred. The same listener instance already exists in the event listener list."); + + return r; +} + +result +_SearchBarImpl::RemoveSearchBarEventListener(const ISearchBarEventListener& listener) +{ + ClearLastResult(); + + SysTryReturn(NID_UI_CTRL, __pPublicSearchBarEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred."); + + result r = __pPublicSearchBarEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, + "A system error has occurred. The specified listener does not exist in the event listener list."); + + return r; +} + +result +_SearchBarImpl::AddLanguageEventListener(ILanguageEventListener& listener) +{ + ClearLastResult(); + + SysAssertf(__pPublicLanguageEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicLanguageEvent->AddListener(listener); +} + +result +_SearchBarImpl::RemoveLanguageEventListener(ILanguageEventListener& listener) +{ + ClearLastResult(); + + SysAssertf(__pPublicLanguageEvent != null, "Not yet constructed. Construct() should be called before use."); + + return __pPublicLanguageEvent->RemoveListener(listener); +} + +void +_SearchBarImpl::OnActionPerformed(const _Control& source, int actionId) +{ + ClearLastResult(); + + if (__pPublicActionEvent != null) + { + IEventArg* pEventArg = _PublicActionEvent::CreateActionEventArgN(actionId); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicActionEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBarImpl::OnKeypadWillOpen(void) +{ + ClearLastResult(); + + if (__pPublicKeypadEvent != null) + { + IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_SEARCH, KEYPAD_EVENT_STATUS_CREATED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBarImpl::OnKeypadOpened(void) +{ + ClearLastResult(); + + if (__pPublicKeypadEvent != null) + { + IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_SEARCH, KEYPAD_EVENT_STATUS_OPEN); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent->Fire(*pEventArg); + } + return; +} + + +void +_SearchBarImpl::OnKeypadClosed(void) +{ + ClearLastResult(); + + if (__pPublicKeypadEvent != null) + { + IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_SEARCH, KEYPAD_EVENT_STATUS_CLOSE); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBarImpl::OnKeypadBoundsChanged(void) +{ + ClearLastResult(); + + if (__pPublicKeypadEvent != null) + { + IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), KEYPAD_ACTION_SEARCH, KEYPAD_EVENT_STATUS_BOUNDS_CHANGED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBarImpl::OnKeypadActionPerformed(CoreKeypadAction keypadAction) +{ + ClearLastResult(); + + if (__pPublicKeypadEvent != null) + { + KeypadAction publicKeypadAction = ConvertKeypadAction(keypadAction); + + IEventArg* pEventArg = _PublicKeypadEvent::CreateKeypadEventArgN( + GetPublic(), publicKeypadAction, KEYPAD_EVENT_STATUS_ENTERACTION); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicKeypadEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBarImpl::OnTextBlockSelected(_Control& source, int start, int end) +{ + ClearLastResult(); + + if (__pPublicTextBlockEvent != null) + { + IEventArg* pEventArg = _PublicTextBlockEvent::CreateTextBlockEventArgN(start, end); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTextBlockEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBarImpl::OnTextValueChanged(const _Control& source) +{ + ClearLastResult(); + + if (__pPublicTextEvent != null) + { + IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CHANGED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTextEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBarImpl::OnTextValueChangeCanceled(const _Control& source) +{ + ClearLastResult(); + + if (__pPublicTextEvent != null) + { + IEventArg* pEventArg = _PublicTextEvent::CreateTextEventArgN(TEXT_EVENT_CANCELED); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicTextEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBarImpl::OnSearchBarModeChanged(_SearchBar& source, SearchBarMode mode) +{ + ClearLastResult(); + + if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) && __pSearchBar != null) + { + if (mode == SEARCH_BAR_MODE_NORMAL) + { + __pSearchBar->SetHeaderVisibleState(true); + } + else + { + __pSearchBar->SetHeaderVisibleState(false); + } + __pSearchBar->SetContentsArea(); + } + + if (__pPublicSearchBarEvent != null) + { + IEventArg* pEventArg = _PublicSearchBarEvent::CreateSearchBarEventArgN(SEARCH_BAR_EVENT_MODE_CHANGE); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicSearchBarEvent->Fire(*pEventArg); + } + return; +} + +void +_SearchBarImpl::OnLanguageChanged(LanguageCode oldLanguage, LanguageCode newLanguage) +{ + if (__pPublicLanguageEvent) + { + IEventArg* pKLanguageEventArg = _PublicLanguageEvent::CreateLanguageEventArgN(GetPublic(), oldLanguage, newLanguage); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pKLanguageEventArg, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicLanguageEvent->Fire(*pKLanguageEventArg); + } + else + { + SysLog(NID_UI_CTRL, "Event is not created."); + } + return; +} + +KeypadAction +_SearchBarImpl::ConvertKeypadAction(CoreKeypadAction keypadAction) const +{ + KeypadAction publicKeypadAction = KEYPAD_ACTION_SEARCH; + switch (keypadAction) + { + case CORE_KEYPAD_ACTION_ENTER: + publicKeypadAction = KEYPAD_ACTION_ENTER; + break; + + case CORE_KEYPAD_ACTION_GO: + publicKeypadAction = KEYPAD_ACTION_GO; + break; + + case CORE_KEYPAD_ACTION_NEXT: + publicKeypadAction = KEYPAD_ACTION_NEXT; + break; + + case CORE_KEYPAD_ACTION_SEND: + publicKeypadAction = KEYPAD_ACTION_SEND; + break; + + case CORE_KEYPAD_ACTION_SEARCH: + publicKeypadAction = KEYPAD_ACTION_SEARCH; + break; + + case CORE_KEYPAD_ACTION_LOGIN: + publicKeypadAction = KEYPAD_ACTION_LOGIN; + break; + + case CORE_KEYPAD_ACTION_SIGN_IN: + publicKeypadAction = KEYPAD_ACTION_SIGN_IN; + break; + + case CORE_KEYPAD_ACTION_JOIN: + publicKeypadAction = KEYPAD_ACTION_JOIN; + break; + + case CORE_KEYPAD_ACTION_DONE: + publicKeypadAction = KEYPAD_ACTION_DONE; + break; + + default: + break; + } + + return publicKeypadAction; +} + +class _SearchBarMaker + : public _UiBuilderControlMaker +{ +public: + _SearchBarMaker(_UiBuilder* pUibuilder) + : _UiBuilderControlMaker(pUibuilder){} + virtual ~_SearchBarMaker(void){} + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* pUibuilder) + { + _SearchBarMaker* pSearchBarMaker = new (std::nothrow) _SearchBarMaker(pUibuilder); + return pSearchBarMaker; + }; + +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SUCCESS; + + Rectangle rect; + SearchBar* pSearchBar = null; + _UiBuilderControlLayout* pControlProperty = null; + bool showSearchBarButton = true; + KeypadAction keypadAction = KEYPAD_ACTION_ENTER; + Color color; + int opacity = SEARCHBAR_DEFAULT_OPACITY; + EllipsisPosition ellipsisPosition = ELLIPSIS_POSITION_END; + String text; + String guideText; + int limitLength = SEARCHBAR_TEXT_LENGTH_MAX; + int buttonActionId = -1; + String buttonText; + int searchFieldTextSize = 0; + bool lowercaseEnable = false; + String elementString; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pSearchBar = new (std::nothrow) SearchBar; + if (pSearchBar == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + if (pControl->GetElement("showSearchBarButton", elementString)) + { + if (elementString.Equals(L"false", false)) + { + showSearchBarButton = false; + } + } + + if (pControl->GetElement("keypadAction", elementString)) + { + if (elementString.Equals(L"KEYPAD_ACTION_ENTER", false)) + { + keypadAction = KEYPAD_ACTION_ENTER; + } + else if (elementString.Equals(L"KEYPAD_ACTION_GO", false)) + { + keypadAction = KEYPAD_ACTION_GO; + } + else if (elementString.Equals(L"KEYPAD_ACTION_NEXT", false)) + { + keypadAction = KEYPAD_ACTION_NEXT; + } + else if (elementString.Equals(L"KEYPAD_ACTION_SEND", false)) + { + keypadAction = KEYPAD_ACTION_SEND; + } + else if (elementString.Equals(L"KEYPAD_ACTION_SEARCH", false)) + { + keypadAction = KEYPAD_ACTION_SEARCH; + } + else if (elementString.Equals(L"KEYPAD_ACTION_LOGIN", false)) + { + keypadAction = KEYPAD_ACTION_LOGIN; + } + else if (elementString.Equals(L"KEYPAD_ACTION_SIGN_IN", false)) + { + keypadAction = KEYPAD_ACTION_SIGN_IN; + } + else if (elementString.Equals(L"KEYPAD_ACTION_JOIN", false)) + { + keypadAction = KEYPAD_ACTION_JOIN; + } + else if (elementString.Equals(L"KEYPAD_ACTION_DONE", false)) + { + keypadAction = KEYPAD_ACTION_DONE; + } + } + + r = pSearchBar->Construct(rect, showSearchBarButton, keypadAction); + if (r != E_SUCCESS) + { + delete pSearchBar; + return null; + } + + if (showSearchBarButton) + { + if (pControl->GetElement("buttonActionId", elementString)) + { + Base::Integer::Parse(elementString, buttonActionId); + } + + if (pControl->GetElement("buttonText", elementString)) + { + r = pSearchBar->SetButton(elementString, buttonActionId); + } + } + + if (pControl->GetElement("text", elementString)) + { + r = pSearchBar->SetText(elementString); + } + + if (pControl->GetElement("guideText", elementString)) + { + r = pSearchBar->SetGuideText(elementString); + } + + if (pControl->GetElement("searchFieldTextSize", elementString)) + { + Base::Integer::Parse(elementString, searchFieldTextSize); + _ICoordinateSystemTransformer* pTransform = GetTransformer(); + if (pTransform) + { + searchFieldTextSize = pTransform->Transform(searchFieldTextSize); + } + r = pSearchBar->SetSearchFieldTextSize(searchFieldTextSize); + } + + if (pControl->GetElement("limitLength", elementString)) + { + Base::Integer::Parse(elementString, limitLength); + r = pSearchBar->SetLimitLength(limitLength); + } + + if (pControl->GetElement("lowerCaseMode", elementString)) + { + if (elementString.Equals(L"true", false)) + { + lowercaseEnable = true; + } + else + { + lowercaseEnable = false; + } + + pSearchBar->SetLowerCaseModeEnabled(lowercaseEnable); + } + + if (pControl->GetElement("ellipsisPosition", elementString)) + { + if (elementString.Equals(L"ELLIPSIS_POSITION_START", false)) + { + ellipsisPosition = ELLIPSIS_POSITION_START; + } + else if (elementString.Equals(L"ELLIPSIS_POSITION_MIDDLE", false)) + { + ellipsisPosition = ELLIPSIS_POSITION_MIDDLE; + } + else + { + ellipsisPosition = ELLIPSIS_POSITION_END; + } + + r = pSearchBar->SetEllipsisPosition(ellipsisPosition); + } + + if (pControl->GetElement("backgroundBitmapPath", elementString)) + { + Bitmap* pBackgroundBitmap = null; + pBackgroundBitmap = LoadBitmapN(elementString); + if (pBackgroundBitmap != null) + { + pSearchBar->SetBackgroundBitmap(*pBackgroundBitmap); + delete pBackgroundBitmap; + } + } + + if (pControl->GetElement("colorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement("color", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetColor(color); + } + + opacity = SEARCHBAR_DEFAULT_OPACITY; + if (pControl->GetElement("normalButtonColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetButtonColor(SEARCH_BAR_BUTTON_STATUS_NORMAL, color); + } + + if (pControl->GetElement("normalButtonTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetButtonTextColor(SEARCH_BAR_BUTTON_STATUS_NORMAL, color); + } + + if (pControl->GetElement("normalSearchFieldColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_NORMAL, color); + } + + if (pControl->GetElement("normalSearchFieldTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetSearchFieldTextColor(SEARCH_FIELD_STATUS_NORMAL, color); + } + + if (pControl->GetElement("disabledButtonColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetButtonColor(SEARCH_BAR_BUTTON_STATUS_DISABLED, color); + } + + if (pControl->GetElement("disabledButtonTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetButtonTextColor(SEARCH_BAR_BUTTON_STATUS_DISABLED, color); + } + + if (pControl->GetElement("disabledSearchFieldColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_DISABLED, color); + } + + if (pControl->GetElement("disabledSearchFieldTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_DISABLED, color); + } + + if (pControl->GetElement("highlightedButtonColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetButtonColor(SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement("highlightedButtonTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetButtonTextColor(SEARCH_BAR_BUTTON_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement("highlightedSearchFieldColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement("highlightedSearchFieldTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetSearchFieldColor(SEARCH_FIELD_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement("pressedButtonColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetButtonColor(SEARCH_BAR_BUTTON_STATUS_PRESSED, color); + } + + if (pControl->GetElement("pressedButtonTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetButtonTextColor(SEARCH_BAR_BUTTON_STATUS_PRESSED, color); + } + + if (pControl->GetElement("guideTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + r = pSearchBar->SetGuideTextColor(color); + } + + return pSearchBar; + } +}; + +_SearchBarRegister::_SearchBarRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"SearchBar", _SearchBarMaker::GetInstance); +} + +_SearchBarRegister::~_SearchBarRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"SearchBar"); +} +static _SearchBarRegister SearchBarRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SearchBarModel.cpp b/src/ui/controls/FUiCtrl_SearchBarModel.cpp new file mode 100644 index 0000000..5f68f83 --- /dev/null +++ b/src/ui/controls/FUiCtrl_SearchBarModel.cpp @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SearchBarModel.cpp + * @brief This is the implementation file for the _SearchBarModel class. + */ + +#include +#include "FUiCtrl_SearchBarModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_SearchBarModel::_SearchBarModel(void) + : __isContentAreaVisible(true) + , __isModeLocked(false) + , __searchBarMode(SEARCH_BAR_MODE_NORMAL) +{ +} + +_SearchBarModel::~_SearchBarModel(void) +{ +} + +result +_SearchBarModel::Construct(void) +{ + return E_SUCCESS; +} + +result +_SearchBarModel::SetContentAreaVisible(bool visible) +{ + __isContentAreaVisible = visible; + + return E_SUCCESS; +} + +bool +_SearchBarModel::IsContentAreaVisible(void) const +{ + return __isContentAreaVisible; +} + +SearchBarMode +_SearchBarModel::GetMode(void) const +{ + return __searchBarMode; +} + +bool +_SearchBarModel::IsModeLocked(void) const +{ + return __isModeLocked; +} + +result +_SearchBarModel::SetMode(SearchBarMode mode) +{ + __searchBarMode = mode; + + return E_SUCCESS; +} + +result +_SearchBarModel::SetModeLocked(bool modeLocked) +{ + __isModeLocked = modeLocked; + + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SearchBarPresenter.cpp b/src/ui/controls/FUiCtrl_SearchBarPresenter.cpp new file mode 100644 index 0000000..b8b551a --- /dev/null +++ b/src/ui/controls/FUiCtrl_SearchBarPresenter.cpp @@ -0,0 +1,608 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SearchBarPresenter.cpp + * @brief This is the implementation file for the _SearchBarPresenter class. + */ + +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_SearchBar.h" +#include "FUiCtrl_SearchBarModel.h" +#include "FUiCtrl_SearchBarPresenter.h" +#include "FUiCtrl_Toolbar.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls { + +_SearchBarPresenter::_SearchBarPresenter(void) + : __pSearchBar(null) + , __pSearchBarModel(null) + , __pCancelButton(null) + , __pEdit(null) + , __pContainer(null) + , __searchFieldBounds(Rectangle()) + , __pIconElement(null) + , __pReplacedSearchFieldNormalBitmap(null) + , __pReplacedSearchFieldDisabledBitmap(null) + , __pSearchFieldEffectBitmap(null) +{ +} + +_SearchBarPresenter::~_SearchBarPresenter(void) +{ + delete __pSearchBarModel; + __pSearchBarModel = null; + + if (__pIconElement) + { + __pIconElement->Destroy(); + __pIconElement = null; + } + + if (__pReplacedSearchFieldNormalBitmap) + { + delete __pReplacedSearchFieldNormalBitmap; + __pReplacedSearchFieldNormalBitmap = null; + } + + if (__pReplacedSearchFieldDisabledBitmap) + { + delete __pReplacedSearchFieldDisabledBitmap; + __pReplacedSearchFieldDisabledBitmap = null; + } + + if (__pSearchFieldEffectBitmap) + { + delete __pSearchFieldEffectBitmap; + __pSearchFieldEffectBitmap = null; + } +} + +result +_SearchBarPresenter::Construct(const _SearchBar& searchBar) +{ + result r = E_SUCCESS; + _VisualElement* pSearchBarElement = null; + + __pSearchBar = const_cast <_SearchBar*>(&searchBar); + SysTryReturn(NID_UI_CTRL, __pSearchBar, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The searchbar instance is null."); + + __pCancelButton = __pSearchBar->GetSearchBarButton(); + SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The cancel button instance is null."); + + __pEdit = __pSearchBar->GetSearchField(); + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The edit instance is null."); + + __pContainer = __pSearchBar->GetSearchBarContainer(); + SysTryReturn(NID_UI_CTRL, __pContainer, E_SYSTEM, E_SYSTEM, + " [E_SYSTEM] A system error has occurred. Failed to get the content."); + + r = LoadSearchFieldIcon(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _VisualElement* pEditElement = __pEdit->GetVisualElement(); + SysTryReturn(NID_UI_CTRL, pEditElement, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get edit visual element."); + + __pIconElement = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_CTRL, __pIconElement, , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pIconElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pIconElement->SetShowState(true); + + r = __pIconElement->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pIconElement->SetImplicitAnimationEnabled(false); + + r = pEditElement->AttachChild(*__pIconElement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pSearchBarElement = __pSearchBar->GetVisualElement(); + SysTryCatch(NID_UI_CTRL, pSearchBarElement, , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get searchbar's visual element."); + + return r; + +CATCH: + if (__pIconElement) + { + __pIconElement->Destroy(); + __pIconElement = null; + } + + return r; +} + +result +_SearchBarPresenter::LoadSearchFieldIcon() +{ + result r = E_SUCCESS; + Color searchFieldIconColor; + Bitmap* pSearchFieldBitmap; + + + r = GET_BITMAP_CONFIG_N(SEARCHBAR::ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSearchFieldBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + r = GET_BITMAP_CONFIG_N(SEARCHBAR::ICON_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pSearchFieldEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r,"[%s] Propagating.", GetErrorMessage(r)); + + GET_COLOR_CONFIG(SEARCHBAR::ICON_COLOR_NORMAL, searchFieldIconColor); + + __pReplacedSearchFieldNormalBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSearchFieldBitmap, Color::GetColor(COLOR_ID_MAGENTA), searchFieldIconColor); + SysTryCatch(NID_UI_CTRL, __pReplacedSearchFieldNormalBitmap != null, r = GetLastResult(), GetLastResult(),"[%s] Propagating.", + GetErrorMessage(GetLastResult())); + + GET_COLOR_CONFIG(SEARCHBAR::ICON_COLOR_DISABLED, searchFieldIconColor); + + __pReplacedSearchFieldDisabledBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSearchFieldBitmap, Color::GetColor(COLOR_ID_MAGENTA), searchFieldIconColor); + SysTryCatch(NID_UI_CTRL, __pReplacedSearchFieldDisabledBitmap != null, r = GetLastResult(), GetLastResult(),"[%s] Propagating.", + GetErrorMessage(GetLastResult())); + + delete pSearchFieldBitmap; + pSearchFieldBitmap = null; + + return r; + +CATCH: + delete pSearchFieldBitmap; + pSearchFieldBitmap = null; + + delete __pSearchFieldEffectBitmap; + __pSearchFieldEffectBitmap = null; + + delete __pReplacedSearchFieldNormalBitmap; + __pReplacedSearchFieldNormalBitmap = null; + + return r; +} + +result +_SearchBarPresenter::Install(void) +{ + result r = E_SUCCESS; + + _SearchBarModel* pModel = new (std::nothrow) _SearchBarModel; + SysTryReturn(NID_UI_CTRL, pModel, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pModel->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The searchbar model construction failed."); + + __pSearchBarModel = pModel; + + return E_SUCCESS; + +CATCH: + delete pModel; + return E_SYSTEM; +} + +result +_SearchBarPresenter::UpdateContentArea(bool invalidate) +{ + SearchBarMode mode = __pSearchBarModel->GetMode(); + SysTryReturn(NID_UI_CTRL, mode == SEARCH_BAR_MODE_INPUT, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The searchbar mode cannot be updated."); + + __pSearchBar->Invalidate(invalidate); + + return E_SUCCESS; +} + +result +_SearchBarPresenter::SetContentAreaVisible(bool visible) +{ + return __pSearchBarModel->SetContentAreaVisible(visible); +} + +bool +_SearchBarPresenter::IsContentAreaVisible(void) const +{ + return __pSearchBarModel->IsContentAreaVisible(); +} + +SearchBarMode +_SearchBarPresenter::GetMode(void) const +{ + return __pSearchBarModel->GetMode(); +} + +bool +_SearchBarPresenter::IsModeLocked(void) const +{ + return __pSearchBarModel->IsModeLocked(); +} + +result +_SearchBarPresenter::SetMode(SearchBarMode mode) +{ + SysTryReturn(NID_UI_CTRL, IsModeLocked() == false, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The searchbar mode is locked."); + + if (GetMode() == mode) + { + return E_SUCCESS; + } + + __pSearchBarModel->SetMode(mode); + + result r = ChangeMode(mode); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to change the mode of searchbar."); + + return r; +} + +result +_SearchBarPresenter::SetModeLocked(bool modeLocked) +{ + return __pSearchBarModel->SetModeLocked(modeLocked); +} + +result +_SearchBarPresenter::Draw(void) +{ + result r = E_SUCCESS; + + Color bgColor = __pSearchBar->GetColor(); + + Rectangle bounds(0, 0, __pSearchBar->GetBounds().width, __pSearchBar->GetBounds().height); + __pSearchBar->SetBackgroundColor(__pSearchBar->GetColor()); + + Bitmap* pBackgroundBitmap = __pSearchBar->GetBackgroundBitmap(); + + if (pBackgroundBitmap) + { + Canvas* pCanvas = __pSearchBar->GetCanvasN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pCanvas != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (pBackgroundBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap); + } + else + { + pCanvas->DrawBitmap(Point(0, 0), *pBackgroundBitmap); + } + + delete pCanvas; + } + + r = DrawIcon(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +_SearchBarPresenter::SetCancelButtonVisible(bool visible) +{ + if ((__pSearchBar->IsUsableCancelButton() == false) && visible) + { + return; + } + + if (__pCancelButton == null) + { + return; + } + + __pCancelButton->SetVisibleState(visible); + + return; +} + +void +_SearchBarPresenter::SetContainerVisible(bool visible) +{ + if (__pContainer == null) + { + return; + } + + __pContainer->SetVisibleState(visible); + + return; +} + + +result +_SearchBarPresenter::DrawIcon(void) +{ + SysTryReturn(NID_UI_CTRL, __pEdit, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get edit instance."); + SysTryReturn(NID_UI_CTRL, __pIconElement, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get edit visual element."); + + result r = E_SUCCESS; + + Canvas* pIconCanvas = null; + Rectangle iconBounds; + + int iconMarginH = 0; + int iconWidth = 0; + int iconHeight = 0; + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + GET_SHAPE_CONFIG(SEARCHBAR::ICON_HORIZONTAL_MARGIN, orientation, iconMarginH); + GET_SHAPE_CONFIG(SEARCHBAR::ICON_WIDTH, orientation, iconWidth); + GET_SHAPE_CONFIG(SEARCHBAR::ICON_HEIGHT, orientation, iconHeight); + + iconBounds.x = iconMarginH; + iconBounds.y = (__pEdit->GetBounds().height - iconWidth) / 2; + iconBounds.width = iconWidth; + iconBounds.height = iconHeight; + + __pIconElement->SetBounds(FloatRectangle(iconBounds.x, iconBounds.y, iconBounds.width, iconBounds.height)); + + pIconCanvas = __pIconElement->GetCanvasN(Rectangle(0, 0, iconBounds.width, iconBounds.height)); + SysTryReturnResult(NID_UI_CTRL, pIconCanvas != null, GetLastResult(), "Propagating."); + + pIconCanvas->SetBackgroundColor(Color(0)); + pIconCanvas->Clear(); + if(__pSearchBar->IsEnabled()) + { + if (__pReplacedSearchFieldNormalBitmap != null) + { + if (__pReplacedSearchFieldNormalBitmap->IsNinePatchedBitmap()) + { + pIconCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, iconBounds.width, iconBounds.height), *__pReplacedSearchFieldNormalBitmap); + } + else + { + pIconCanvas->DrawBitmap(Rectangle(0, 0, iconBounds.width, iconBounds.height), *__pReplacedSearchFieldNormalBitmap); + } + } + } + else + { + if (__pReplacedSearchFieldDisabledBitmap != null) + { + if (__pReplacedSearchFieldDisabledBitmap->IsNinePatchedBitmap()) + { + pIconCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, iconBounds.width, iconBounds.height), *__pReplacedSearchFieldDisabledBitmap); + } + else + { + pIconCanvas->DrawBitmap(Rectangle(0, 0, iconBounds.width, iconBounds.height), *__pReplacedSearchFieldDisabledBitmap); + } + } + } + + if (__pSearchFieldEffectBitmap != null) + { + if (__pSearchFieldEffectBitmap->IsNinePatchedBitmap()) + { + pIconCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, iconBounds.width, iconBounds.height), *__pSearchFieldEffectBitmap); + } + else + { + pIconCanvas->DrawBitmap(Rectangle(0, 0, iconBounds.width, iconBounds.height), *__pSearchFieldEffectBitmap); + } + } + + delete pIconCanvas; + pIconCanvas = null; + + return r; +} + + +result +_SearchBarPresenter::ChangeMode(SearchBarMode mode) +{ + result r = E_SUCCESS; + + if (mode == SEARCH_BAR_MODE_NORMAL) + { + InitializeViewModeLayout(); + SetCancelButtonVisible(false); + SetContainerVisible(false); + + if (__pEdit) + { + __pEdit->ClearText(); + __pEdit->SetCursorDisabled(true); + __pEdit->SetBounds(__searchFieldBounds); + __pEdit->HideKeypad(); + } + + r = __pSearchBar->SendSearchBarEvent(_SEARCH_BAR_EVENT_MODE_CHANGE); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to fire the searchbar event."); + } + else + { + r = __pSearchBar->SendSearchBarEvent(_SEARCH_BAR_EVENT_MODE_CHANGE); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to fire the searchbar event."); + + InitializeInputModeLayout(); + SetCancelButtonVisible(true); + __pSearchBar->SetContentDimming(); + __pSearchBar->SetContentsArea(); + SetContainerVisible(true); + + __pSearchBar->Invalidate(); + + if (__pEdit) + { + __pEdit->SetCursorDisabled(false); + __pEdit->SetBounds(__searchFieldBounds); + __pEdit->ShowKeypad(); + } + } + + return E_SUCCESS; +} + +void +_SearchBarPresenter::InitializeInputModeLayout(void) +{ + InitializeViewModeLayout(); + + if (__pSearchBar->IsUsableCancelButton() == false) + { + return; + } + + int horizontalMargin = 0; + int buttonRightMargin = 0; + int buttonLeftMargin = 0; + int buttonWidth = 0; + int searchFieldMinWidth = 0; + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_LEFT_MARGIN, orientation, buttonLeftMargin); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_RIGHT_MARGIN, orientation, buttonRightMargin); + GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth); + GET_SHAPE_CONFIG(SEARCHBAR::BUTTON_WIDTH, orientation, buttonWidth); + int buttonResizableSearchBarWidth = (horizontalMargin + searchFieldMinWidth + + buttonWidth + buttonLeftMargin + buttonRightMargin); + + if(__pSearchBar->GetBounds().width < buttonResizableSearchBarWidth) + { + __searchFieldBounds.width = searchFieldMinWidth; + } + + else + { + __searchFieldBounds.width = __pSearchBar->GetBounds().width - (buttonRightMargin + + buttonWidth + buttonLeftMargin + horizontalMargin); + } + + __searchFieldBounds.width = (__pSearchBar->GetBounds().width > searchFieldMinWidth) ? __searchFieldBounds.width : searchFieldMinWidth; + + return; +} + +void +_SearchBarPresenter::InitializeViewModeLayout(void) +{ + int horizontalMargin = 0; + int verticalMargin = 0; + int searchFieldMinWidth = 0; + int searchFieldMinHeight = 0; + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + GET_SHAPE_CONFIG(SEARCHBAR::HORIZONTAL_MARGIN, orientation, horizontalMargin); + GET_SHAPE_CONFIG(SEARCHBAR::VERTICAL_MARGIN, orientation, verticalMargin); + GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_WIDTH, orientation, searchFieldMinWidth); + GET_SHAPE_CONFIG(SEARCHBAR::SEARCH_FIELD_MIN_HEIGHT, orientation, searchFieldMinHeight); + + __searchFieldBounds.x = horizontalMargin; + __searchFieldBounds.y = verticalMargin; + __searchFieldBounds.width = __pSearchBar->GetBounds().width - (horizontalMargin * 2); + __searchFieldBounds.height = __pSearchBar->GetBounds().height - (verticalMargin * 2); + + __searchFieldBounds.width = (__searchFieldBounds.width > searchFieldMinWidth) ? __searchFieldBounds.width : searchFieldMinWidth; + __searchFieldBounds.height = (__searchFieldBounds.height > searchFieldMinHeight) ? __searchFieldBounds.height : searchFieldMinHeight; + + return; +} + +void +_SearchBarPresenter::OnBoundsChanged(void) +{ + _Control* pClippedGroupControl = __pSearchBar->GetClippedGroupControl(); + + if(pClippedGroupControl != null) + { + pClippedGroupControl->SetBounds(Rectangle(Point(0, 0), __pSearchBar->GetSize())); + } + + if (GetMode() == SEARCH_BAR_MODE_NORMAL) + { + InitializeViewModeLayout(); + } + else + { + InitializeInputModeLayout(); + } + + result r = E_SUCCESS; + + if (__pCancelButton != null) + { + r = __pSearchBar->ResizeCancelButton(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.",GetErrorMessage(r)); + } + + r = __pEdit->SetBounds(__searchFieldBounds); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.",GetErrorMessage(r)); + + __pSearchBar->SetContentsArea(); + + return; +} + +void +_SearchBarPresenter::SetHeaderVisibleState(bool visible) +{ + _Form* pForm = null; + _Control* pControlCore = __pEdit->GetParent(); + + while (true) + { + if (pControlCore == null) + { + SysLog(NID_UI_CTRL,"[E_SYSTEM] The parent form is null."); + + return; + } + + pForm = dynamic_cast<_Form*>(pControlCore); + if (pForm != null) + { + break; + } + + pControlCore = pControlCore->GetParent(); + } + + _Toolbar* pHeader = pForm->GetHeader(); + if (pHeader == null) + { + return; + } + + pHeader->SetVisibleState(visible); + + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SimpleItemImpl.cpp b/src/ui/controls/FUiCtrl_SimpleItemImpl.cpp new file mode 100644 index 0000000..fd016d5 --- /dev/null +++ b/src/ui/controls/FUiCtrl_SimpleItemImpl.cpp @@ -0,0 +1,174 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SimpleItemImpl.cpp + * @brief This is the implementation file for _SimpleItemImpl class. + * + * This file contains the implementation of _SimpleItemImpl class. + */ + +#include +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_ListViewItem.h" +#include "FUiCtrl_SimpleItemImpl.h" + +#ifdef MEMORY_LEAK_CHECK +#include "mem_leak_check.h" +#endif + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_SimpleItemImpl::_SimpleItemImpl(SimpleItem* pPublic) + : _ListItemBaseImpl(pPublic) +{ + +} + +_SimpleItemImpl::~_SimpleItemImpl(void) +{ + +} + +SimpleItem& +_SimpleItemImpl::GetPublic(void) +{ + return static_cast (_ListItemBaseImpl::GetPublic()); +} + +const SimpleItem& +_SimpleItemImpl::GetPublic(void) const +{ + return static_cast (_ListItemBaseImpl::GetPublic()); +} + +const char* +_SimpleItemImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::SimpleItem"; +} + +_SimpleItemImpl* +_SimpleItemImpl::CreateSimpleItemImplN(SimpleItem* pPublic, const Dimension& itemSize, ListAnnexStyle style) +{ + result r = E_SUCCESS; + + _SimpleItemImpl* pImpl = new (std::nothrow) _SimpleItemImpl(pPublic); + SysTryReturn(NID_UI_CTRL, pImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = pImpl->Construct(itemSize, style); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[E_SYSTEM] Unable to construct _SimpleItemImpl."); + + return pImpl; + +CATCH: + delete pImpl; + pImpl = null; + + return null; +} + +result +_SimpleItemImpl::Construct(const Dimension& itemSize, ListAnnexStyle style) +{ + result r = _ListItemBaseImpl::Construct(itemSize, style); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetListViewItem()->SetListViewItemType(LISTVIEW_ITEM_TYPE_SIMPLE); + + SetLastResultReturn(r); +} + +result +_SimpleItemImpl::SetElement(const String& text, const Bitmap* pBitmap) +{ + bool ret = false; + _ListViewItem* pItem = GetListViewItem(); + + if (pItem->HasElement(LIST_ITEM_RESERVED_ID_2)) + { + ret = pItem->DeleteElement(LIST_ITEM_RESERVED_ID_2); + SysTryReturn(NID_UI_CTRL, (ret == true), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to delete bitmap element."); + } + + if (pItem->HasElement(LIST_ITEM_RESERVED_ID_3)) + { + ret = pItem->DeleteElement(LIST_ITEM_RESERVED_ID_3); + SysTryReturn(NID_UI_CTRL, (ret == true), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to delete text element."); + } + + Rectangle bitmapRect = Rectangle(0, 0, 0, 0); + Rectangle textRect = Rectangle(0, 0, 0, 0); + ListAnnexStyle style = GetListItemAnnexStyle(); + int leftMargin = 0; + int itemHeight = GetItemSize().height; + int annexWidth = GetAnnexWidth(style); + int elementSpacing = 0; + int textSize = 0; + result r = E_SUCCESS; + + GET_SHAPE_CONFIG(LISTVIEW::ITEM_ELEMENT_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + GET_SHAPE_CONFIG(LISTVIEW::ITEM_ELEMENT_SPACING, _CONTROL_ORIENTATION_PORTRAIT, elementSpacing); + GET_SHAPE_CONFIG(LISTVIEW::ITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, textSize); + + bitmapRect.x += leftMargin; + + if (style == LIST_ANNEX_STYLE_MARK || style == LIST_ANNEX_STYLE_RADIO) + { + bitmapRect.x += GetAnnexWidth(style) + elementSpacing; + } + + // Add Bitmap element (optional) + if (pBitmap != null) + { + int elementWidth = itemHeight * SIMPLE_ITEM_ELEMENT_BITMAP_SIZE_RATIO; + int elementHeight = elementWidth; + + bitmapRect.y = (itemHeight - elementHeight) / 2; + bitmapRect.width = elementWidth; + bitmapRect.height = elementHeight; + + r = pItem->AddElement(bitmapRect, LIST_ITEM_RESERVED_ID_2, pBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + else + { + elementSpacing = 0; + } + + // Add Text element + textRect.x = bitmapRect.x + bitmapRect.width + elementSpacing; + textRect.y = 0; + textRect.width = GetItemSize().width - textRect.x - ((annexWidth > 0) ? (annexWidth + leftMargin) : 0); + textRect.height = itemHeight; + + r = pItem->AddElement(textRect, LIST_ITEM_RESERVED_ID_3, text); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pItem->SetTextSize(LIST_ITEM_RESERVED_ID_3, textSize); + pItem->SetTextAlignment(LIST_ITEM_RESERVED_ID_3, TEXT_OBJECT_ALIGNMENT_MIDDLE); + + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SlidableGroupedListImpl.cpp b/src/ui/controls/FUiCtrl_SlidableGroupedListImpl.cpp new file mode 100644 index 0000000..e487acd --- /dev/null +++ b/src/ui/controls/FUiCtrl_SlidableGroupedListImpl.cpp @@ -0,0 +1,2426 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SlidableGroupedListImpl.cpp + * @brief This is the implementation file for the _SlidableGroupedListImpl class. + */ + +#include +#include +#include "FUiCtrl_CustomListItemFormatImpl.h" +#include "FUiCtrl_CustomListItemImpl.h" +#include "FUiCtrl_SlidableGroupedListImpl.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_ListListener.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_TableViewPresenter.h" +#include "FUiCtrl_FastScroll.h" +#include "FUiCtrl_FastScrollIndex.h" +#include "FUi_ResourceSizeInfo.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; + +namespace Tizen { namespace Ui { namespace Controls { + +static const int ID_FORMAT_STRING = 1; +static const int ID_FORMAT_MARGIN = 2; +extern const int INVALID_INDEX; + +_SlidableGroupedListItemProvider::_SlidableGroupedListItemProvider(_SlidableGroupedListImpl* pListImpl) + : firstTime(true) + , __pListImpl(pListImpl) + , __bottomListenerIndex(0) + , __topListenerIndex(0) +{ + if (__pListImpl != null) + { + __topListenerIndex = __pListImpl->__slidableListenersList.GetCount() - 1; + } +} + +int +_SlidableGroupedListItemProvider::GetGroupCount(void) +{ + if (__pListImpl == null) + { + return 0; + } + + if (__pListImpl->__slidableListenersList.GetCount() > 0) + { + if (firstTime == true) + { + _ListListener* pListenerData = null; + ISlidableGroupedListEventListener* pSlidableGroupedListener = null; + int listenerCount = 0; + + for (listenerCount = 0; listenerCount < __pListImpl->__slidableListenersList.GetCount(); listenerCount++) + { + pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(listenerCount)); + SysTryReturn(NID_UI_CTRL, (pListenerData != null), -1, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _ListListener"); + + pSlidableGroupedListener = dynamic_cast(pListenerData->pListener); + SysTryReturn(NID_UI_CTRL, (pSlidableGroupedListener != null), -1, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get ISlidableGroupedListEventListener"); + + pSlidableGroupedListener->OnListPropertyRequested(__pListImpl->GetPublic()); + } + + firstTime = false; + } + } + + return __pListImpl->GetGroupCount(); +} + +int +_SlidableGroupedListItemProvider::GetItemCount(int groupIndex) +{ + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, 0, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + return pGroupObject->__itemCount; +} + +TableViewGroupItem* +_SlidableGroupedListItemProvider::CreateGroupItem(int groupIndex, int itemWidth) +{ + result r = E_SUCCESS; + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = __pListImpl->GetCustomListItemAt(groupIndex, -1); + tableViewItemParams.width = itemWidth; + tableViewItemParams.itemId = -1; + tableViewItemParams.groupIndex = groupIndex; + tableViewItemParams.itemIndex = -1; + tableViewItemParams.isDividerEnabled = false; + tableViewItemParams.pCheckBitmaps = null; + tableViewItemParams.annexStyle = __pListImpl->_annexStyle; + + r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pListImpl->GetTableViewGroupItemAt(groupIndex); +} + +bool +_SlidableGroupedListItemProvider::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + if (__pListImpl->__directDelete == false) + { + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, -1); + pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData = null; + } + + delete pItem; + + return true; +} + +bool +_SlidableGroupedListItemProvider::IsReorderable(int groupIndexFrom, int groupIndexTo) +{ + return false; +} + +int +_SlidableGroupedListItemProvider::GetDefaultGroupItemHeight(void) +{ + return __pListImpl->__groupItemHeight; +} + +int +_SlidableGroupedListItemProvider::GetDefaultItemHeight(void) +{ + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(0, 0); + + if (!pCustomListItem) + { + return __pListImpl->_defaultItemHeight; + } + else + { + return pCustomListItem->__pCustomListItemImpl->height; + } +} + +void +_SlidableGroupedListItemProvider::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ +} + +void +_SlidableGroupedListItemProvider::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + _TableViewItemUpdateParams updateParams; + updateParams.pItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex); + updateParams.isDividerEnabled = __pListImpl->_isDividerEnabled; + updateParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps; + updateParams.annexStyle = __pListImpl->_annexStyle; + + result r = E_SUCCESS; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item."); + + pItem->SetEnabled(true); +} + +result +_SlidableGroupedListItemProvider::CallLoadToTopCb(int groupIndex, int itemIndex) +{ + _ListListener* pListenerData = null; + ISlidableGroupedListEventListener* pSlidableListener = null; + + pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(__topListenerIndex)); + SysTryReturn(NID_UI_CTRL, (pListenerData != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _ListListener at index (%d)", __topListenerIndex); + + pSlidableListener = dynamic_cast(pListenerData->pListener); + SysTryReturn(NID_UI_CTRL, (pSlidableListener != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get ISlidableGroupedListEventListener"); + + pSlidableListener->OnLoadToTopRequested(__pListImpl->GetPublic(), groupIndex, itemIndex, 1); + + if (--__topListenerIndex < 0) + { + __topListenerIndex = __pListImpl->__slidableListenersList.GetCount() - 1; + } + + return E_SUCCESS; +} + +result +_SlidableGroupedListItemProvider::UpdateCheckStatus(_TableViewItemData* pTableViewItemData, int groupIndex, int itemIndex) +{ + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + if (pTableViewItemData && pGroupObject->__pCheckedList) + { + Boolean* pChecked = dynamic_cast(pGroupObject->__pCheckedList->GetAt(itemIndex)); + SysTryReturn(NID_UI_CTRL, pChecked, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + _CheckElementModel* pCheckElement = __pListImpl->GetCheckElementAt(groupIndex, 0); + SysTryReturn(NID_UI_CTRL, pCheckElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get check element"); + + pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)pChecked->ToBool()); + } + + return E_SUCCESS; +} + +result +_SlidableGroupedListItemProvider::ModifyIndicesAfterTopLoad(void) +{ + if (__pListImpl->GetCurrentLoadedCount() > __pListImpl->__itemCacheSize) + { + int subItemCount = __pListImpl->GetSubItemCountAt(__pListImpl->__bottomGroup); + + result r = E_SUCCESS; + r = __pListImpl->RemoveFromItemsList(__pListImpl->__bottomGroup, subItemCount - 1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pListImpl->CallUnloadItemCb(__pListImpl->__bottomGroup, subItemCount - 1); + + if ((subItemCount == 1) && (__pListImpl->__bottomGroup > 0)) + { + __pListImpl->__bottomGroup--; + } + } + + if (__pListImpl->GetCurrentLoadedCount() == 2) + { + for (int index = __pListImpl->__topGroup + 1; index < __pListImpl->__groupsList.GetCount(); index++) + { + _SlidableGroupObject* pTempGroup = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(index)); + SysTryReturn(NID_UI_CTRL, (pTempGroup != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get SlidableGroupObject at index (%d).", index); + + pTempGroup->__topIndex = 0; + } + } + return E_SUCCESS; +} + +_TableViewItemData* +_SlidableGroupedListItemProvider::LoadAtTop(int groupIndex, int itemIndex) +{ + _TableViewItemData* pTableViewItemData = null; + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + __pListImpl->__topGroup = groupIndex; + + result r = E_SUCCESS; + CustomListItem* pCustomListItem = null; + + if (itemIndex >= pGroupObject->__topIndex) + { + pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex); + } + + pGroupObject->__topIndex = itemIndex; + + if (!pCustomListItem) + { + r = CallLoadToTopCb(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(__pListImpl->__topGroup)); + SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __pListImpl->__topGroup); + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = (const_cast(pCustomListItem)); + tableViewItemParams.width = __pListImpl->GetCore().GetBounds().width; + tableViewItemParams.itemIndex = pGroupObject->__topIndex; + tableViewItemParams.groupIndex = __pListImpl->__topGroup; + tableViewItemParams.isDividerEnabled = __pListImpl->_isDividerEnabled; + tableViewItemParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps; + tableViewItemParams.annexStyle = __pListImpl->_annexStyle; + + result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + pTableViewItemData = __pListImpl->GetTableViewItemAt(groupIndex, 0); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pTableViewItemData, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = UpdateCheckStatus(pTableViewItemData, groupIndex, pGroupObject->__topIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = ModifyIndicesAfterTopLoad(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return pTableViewItemData; +} + +result +_SlidableGroupedListItemProvider::CallLoadToBottomCb(int groupIndex, int itemIndex) +{ + _ListListener* pListenerData = null; + ISlidableGroupedListEventListener* pSlidableListener = null; + + pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(__bottomListenerIndex)); + SysTryReturn(NID_UI_CTRL, (pListenerData != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _ListListener at index (%d)", __bottomListenerIndex); + + pSlidableListener = dynamic_cast(pListenerData->pListener); + SysTryReturn(NID_UI_CTRL, (pSlidableListener != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get ISlidableGroupedListEventListener"); + + pSlidableListener->OnLoadToBottomRequested(__pListImpl->GetPublic(), groupIndex, itemIndex, 1); + + if (++__bottomListenerIndex == __pListImpl->__slidableListenersList.GetCount()) + { + __bottomListenerIndex = 0; + } + + return E_SUCCESS; +} + +result +_SlidableGroupedListItemProvider::ModifyIndicesAfterBottomLoad(int groupIndex, int itemIndex) +{ + if (__pListImpl->GetCurrentLoadedCount() > __pListImpl->__itemCacheSize) + { + _SlidableGroupObject* pTopGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(__pListImpl->__topGroup)); + SysTryReturn(NID_UI_CTRL, pTopGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __pListImpl->__topGroup); + + if (__pListImpl->__topGroup != __pListImpl->__bottomGroup) + { + pTopGroupObject->__topIndex++; + } + + if (__pListImpl->GetSubItemCountAt(__pListImpl->__topGroup) == 0) + { + __pListImpl->__topGroup++; + } + } + else if (__pListImpl->GetCurrentLoadedCount() == 1) + { + __pListImpl->__topGroup = groupIndex; + __pListImpl->__bottomGroup = groupIndex; + + _SlidableGroupObject* pTopGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(__pListImpl->__topGroup)); + SysTryReturn(NID_UI_CTRL, pTopGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __pListImpl->__topGroup); + + pTopGroupObject->__topIndex = itemIndex; + + for (int index = 0; index < groupIndex; index++) + { + _SlidableGroupObject* pTempGroup = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(index)); + SysTryReturn(NID_UI_CTRL, (pTempGroup != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get SlidableGroupObject at index (%d).", index); + + pTempGroup->__topIndex = pTempGroup->__itemCount - 1; + } + } + + return E_SUCCESS; +} + +_TableViewItemData* +_SlidableGroupedListItemProvider::LoadAtBottom(int groupIndex, int itemIndex) +{ + _TableViewItemData* pTableViewItemData = null; + result r = E_SUCCESS; + + __pListImpl->__bottomGroup = groupIndex; + + CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex - __pListImpl->GetTopItemIndex(groupIndex)); + + if (!pCustomListItem) + { + r = CallLoadToBottomCb(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = (const_cast(pCustomListItem)); + tableViewItemParams.width = __pListImpl->GetCore().GetBounds().width; + tableViewItemParams.groupIndex = __pListImpl->__bottomGroup; + tableViewItemParams.itemIndex = itemIndex; + tableViewItemParams.isDividerEnabled = __pListImpl->_isDividerEnabled; + tableViewItemParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps; + tableViewItemParams.annexStyle = __pListImpl->_annexStyle; + + result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + int subItemCount = __pListImpl->GetSubItemCountAt(groupIndex); + + if (subItemCount > __pListImpl->__itemCacheSize) + { + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + pGroupObject->__topIndex++; + } + + pTableViewItemData = __pListImpl->GetTableViewItemAt(groupIndex, subItemCount - 1); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = UpdateCheckStatus(pTableViewItemData, groupIndex, subItemCount - 1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = ModifyIndicesAfterBottomLoad(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return pTableViewItemData; +} + +TableViewItem* +_SlidableGroupedListItemProvider::CreateItem(int groupIndex, int itemIndex, int itemWidth) +{ + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + _TableViewItemData* pTableViewItem = null; + result r = E_SUCCESS; + + if (groupIndex == __pListImpl->__topGroup) + { + pTableViewItem = __pListImpl->GetTableViewItemAt(groupIndex, itemIndex - pGroupObject->__topIndex); + } + else + { + pTableViewItem = __pListImpl->GetTableViewItemAt(groupIndex, itemIndex); + } + + __pListImpl->__isCreating = true; + + if (pTableViewItem == null) + { + // load at top + if (groupIndex <= __pListImpl->__topGroup && itemIndex <= pGroupObject->__topIndex) + { + pTableViewItem = LoadAtTop(groupIndex, itemIndex); + } + else // load at bottom + { + pTableViewItem = LoadAtBottom(groupIndex, itemIndex); + } + + SysTryReturn(NID_UI_CTRL, pTableViewItem, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + + __pListImpl->__isCreating = false; + + return pTableViewItem; +} + +bool +_SlidableGroupedListItemProvider::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem) +{ + if (__pListImpl->__directDelete == false) + { + if (((groupIndex == __pListImpl->__topGroup) && (itemIndex <= __pListImpl->GetTopItemIndex(__pListImpl->__topGroup))) || (__pListImpl->__forceScroll == true)) + { + __pListImpl->RemoveFromItemsList(groupIndex, 0); + } + else + { + __pListImpl->RemoveFromItemsList(groupIndex, itemIndex); + } + + __pListImpl->CallUnloadItemCb(groupIndex, itemIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, false, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + // adjust top/bottom group indices + if (__pListImpl->GetSubItemCountAt(groupIndex) == 0) + { + if (groupIndex <= __pListImpl->__topGroup) + { + if (__pListImpl->__topGroup < __pListImpl->__bottomGroup) + { + __pListImpl->__topGroup++; + } + } + else + { + if (__pListImpl->__bottomGroup > __pListImpl->__topGroup) + { + __pListImpl->__bottomGroup--; + } + } + } + } + + delete pItem; + pItem = null; + + return true; +} + +_SlidableGroupObject::_SlidableGroupObject(void) + : __itemCount(0) + , __groupHeight(0) + , __topIndex(0) + , __pCheckedList(null) +{ +} + +_SlidableGroupObject::~_SlidableGroupObject(void) +{ + if (__pCheckedList) + { + __pCheckedList->RemoveAll(true); + delete __pCheckedList; + __pCheckedList = null; + } +} + +_SlidableGroupedListImpl* +_SlidableGroupedListImpl::GetInstance(SlidableGroupedList& slidableGroupedList) +{ + return static_cast<_SlidableGroupedListImpl*>(slidableGroupedList._pControlImpl); +} + +const _SlidableGroupedListImpl* +_SlidableGroupedListImpl::GetInstance(const SlidableGroupedList& slidableGroupedList) +{ + return static_cast(slidableGroupedList._pControlImpl); +} + +_SlidableGroupedListImpl::_SlidableGroupedListImpl(Control* pList, _TableView* pCore) + : _ListBaseImpl(pList, pCore) + , __pFastScrollListener(null) + , __bottomGroup(0) + , __topGroup(0) + , __loadedCount(0) + , __pItemProvider(null) + , __directDelete(false) + , __forceScroll(false) + , __isCreating(false) + , __groupItemTextFont(0) + , __groupItemHeight(0) + , __itemCacheSize(0) + , __pItemFormat(null) +{ +} + +_SlidableGroupedListImpl::~_SlidableGroupedListImpl(void) +{ + if (__pItemProvider && __pItemProvider->firstTime == true) + { + for (int groupIndex = 0; groupIndex < __groupsList.GetCount(); groupIndex++) + { + RemoveFromSubItemsList(groupIndex); + } + } + + RemoveAllFromItemsList(); + + __groupsList.RemoveAll(true); + __slidableListenersList.RemoveAll(true); + __itemListenersList.RemoveAll(true); + + delete __pItemProvider; + + delete __pItemFormat; +} + +_SlidableGroupedListImpl* +_SlidableGroupedListImpl::CreateSlidableGroupedListImplN(SlidableGroupedList* pControl, bool itemDivider, bool fastScroll) +{ + TableViewScrollBarStyle scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_NONE; + + if (fastScroll == true) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL; + } + else + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT; + } + + _TableView* pTableView = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_GROUPED, itemDivider, scrollStyle); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pTableView, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _SlidableGroupedListImpl* pImpl = new (std::nothrow) _SlidableGroupedListImpl(pControl, pTableView); + SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pImpl; + +CATCH: + delete pTableView; + return null; +} + +void +_SlidableGroupedListImpl::AddSlidableGroupedListEventListener(ISlidableGroupedListEventListener& listener) +{ + _ListListener* pSlidableListener = new (std::nothrow) _ListListener(); + SysTryReturnVoidResult(NID_UI_CTRL, pSlidableListener, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pSlidableListener->pListener = &listener; + __slidableListenersList.Add(*pSlidableListener); +} + +void +_SlidableGroupedListImpl::RemoveSlidableGroupedListEventListener(ISlidableGroupedListEventListener& listener) +{ + _ListListener* pListenerData = null; + + IEventListener* pEventListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get IEventListener."); + + ISlidableGroupedListEventListener* pSlidableListener = null; + + for (int listenerCount = 0; listenerCount < __slidableListenersList.GetCount(); listenerCount++) + { + pListenerData = dynamic_cast<_ListListener*>(__slidableListenersList.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerData != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _ListListener at index (%d).", listenerCount); + + pSlidableListener = dynamic_cast(pListenerData->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pSlidableListener != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get ISlidableGroupedListEventListener."); + + if (pSlidableListener == pEventListener) + { + __slidableListenersList.RemoveAt(listenerCount, true); + break; + } + } + + RemoveAllGroups(); +} + +void +_SlidableGroupedListImpl::AddFastScrollEventListener(IFastScrollEventListener& listener) +{ + __pFastScrollListener = &listener; + + GetCore().AddFastScrollListener(*this); +} + +result +_SlidableGroupedListImpl::AddGroup(const String& text, const Bitmap* pBackgroundBitmap, int itemCount, int groupHeight, int groupId) +{ + return InsertGroupAt(GetGroupCount(), text, pBackgroundBitmap, itemCount, groupHeight, groupId); +} + +void +_SlidableGroupedListImpl::AddGroupedItemEventListener(IGroupedItemEventListener& listener) +{ + _ListListener* pListenersList = new (std::nothrow) _ListListener(); + SysTryReturnVoidResult(NID_UI_CTRL, pListenersList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pListenersList->pListener = &listener; + + __itemListenersList.Add(*pListenersList); +} + +result +_SlidableGroupedListImpl::AddItem(int groupIndex, const CustomListItem& item, int itemId) +{ + SysTryReturnResult(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, "Invalid argument is used. groupIndex (%d)", groupIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex)); + SysTryReturnResult(NID_UI_CTRL, (pGroupObject != null), E_SYSTEM, + "A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + return InsertItemAt(groupIndex, GetTopItemIndex(groupIndex) + GetSubItemCountAt(groupIndex), item, itemId); +} + +result +_SlidableGroupedListImpl::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + return GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex); +} + +result +_SlidableGroupedListImpl::GetFirstCheckedItemIndex(int& groupIndex, int& itemIndex) const +{ + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, + "A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL."); + + _SlidableGroupObject* pGroupObject = null; + Boolean* pChecked = null; + + for (int groupCount = 0; groupCount < GetGroupCount(); groupCount++) + { + pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast(__groupsList.GetAt(groupCount))); + SysTryReturnResult(NID_UI_CTRL, (pGroupObject != null), E_SYSTEM, + "A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupCount); + + for (int checkCount = 0; checkCount < pGroupObject->__pCheckedList->GetCount(); checkCount++) + { + pChecked = dynamic_cast(const_cast(pGroupObject->__pCheckedList->GetAt(checkCount))); + SysTryReturnResult(NID_UI_CTRL, (pChecked != null), E_SYSTEM, "A system error has occurred."); + + if (pChecked->ToBool()) + { + groupIndex = groupCount; + itemIndex = checkCount; + return E_SUCCESS; + } + } + } + + return E_SYSTEM; +} + +int +_SlidableGroupedListImpl::GetGroupIdAt(int groupIndex) const +{ + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d)", groupIndex); + + const CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1); + SysTryReturn(NID_UI_CTRL, pCustomListItem, 0, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at index (%d).", groupIndex); + + return pCustomListItem->__pCustomListItemImpl->itemId; +} + +int +_SlidableGroupedListImpl::GetGroupIndexFromGroupId(int groupId) const +{ + for (int groupCount = 0; groupCount < __groupsList.GetCount(); groupCount++) + { + const CustomListItem* pCustomItem = GetCustomListItemAt(groupCount, -1); + SysTryReturn(NID_UI_CTRL, pCustomItem, INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at index (%d).", groupCount); + + if (pCustomItem->__pCustomListItemImpl->itemId == groupId) + { + return groupCount; + } + } + + return INVALID_INDEX; +} + +result +_SlidableGroupedListImpl::GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const +{ + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast(__groupsList.GetAt(__topGroup))); + SysTryReturnResult(NID_UI_CTRL, pGroupObject, E_SYSTEM, + "A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __topGroup); + + groupIndex = __topGroup; + itemIndex = pGroupObject->__topIndex; + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const +{ + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast(__groupsList.GetAt(__bottomGroup))); + SysTryReturnResult(NID_UI_CTRL, pGroupObject, E_SYSTEM, + "A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __bottomGroup); + + itemIndex = GetSubItemCountAt(__bottomGroup) - 1 + pGroupObject->__topIndex; + groupIndex = __bottomGroup; + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::SetFastScrollMainIndex(const String& text) +{ + SysTryReturn(NID_UI_CTRL, (text.GetLength() > 0), E_SYSTEM, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Text is empty."); + + SysTryReturn(NID_UI_CTRL, (GetCore().GetScrollStyle() == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Scroll bar not enabled"); + + result r = GetCore().SetFastScrollIndex(text, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r)); + + __mainScrollIndex = text; + + return E_SUCCESS; +} + + +result +_SlidableGroupedListImpl::SetFastScrollSubIndex(const String& text, FastScrollIndexDigit indexDigit) +{ + SysTryReturn(NID_UI_CTRL, (text.GetLength() > 0), E_SYSTEM, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Text is empty."); + + SysTryReturn(NID_UI_CTRL, (indexDigit == SCROLL_INDEX_DIGIT_NUM_1), E_SYSTEM, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. indexDigit is not SCROLL_INDEX_DIGIT_NUM_1."); + + _FastScroll* pFastScroll = GetCore().GetFastScrollBar(); + SysTryReturn(NID_UI_CTRL, pFastScroll, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get FastScroll Object."); + + SysTryReturn(NID_UI_CTRL, (__mainScrollIndex.GetLength() > 0), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Main index of the fast scroll is not set."); + + _FastScrollIndex* pRootIndex = pFastScroll->GetIndex(); + SysTryReturn(NID_UI_CTRL, pRootIndex, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get rootIndex."); + + int subIndexDigit = 1; + String delim(L","); + StringTokenizer strTok(text, delim); + String token; + int i = 0; + + while (strTok.HasMoreTokens()) + { + strTok.GetNextToken(token); + _FastScrollIndex* pSecondaryIndex = pRootIndex->GetChildIndex(i++); + if (pSecondaryIndex != null) + { + pSecondaryIndex->AddChildTextIndexArray(0, token.GetPointer(), subIndexDigit, token.GetLength()); + } + } + + pFastScroll->UpdateIndex(); + return E_SUCCESS; +} + + +result +_SlidableGroupedListImpl::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const +{ + return GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex); +} + +result +_SlidableGroupedListImpl::GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex) const +{ + return GetCore().GetItemIndexFromPosition(Point(x, y), groupIndex, itemIndex); +} + +CustomListItem* +_SlidableGroupedListImpl::CreateGroupItemN(const String& text, const Bitmap* pBackgroundBitmap, int groupId) +{ + CustomListItem* pCustomListItem = new (std::nothrow) CustomListItem(); + SysTryReturn(NID_UI_CTRL, pCustomListItem != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pCustomListItem->Construct(__groupItemHeight); + pCustomListItem->SetItemFormat(*__pItemFormat); + pCustomListItem->SetElement(ID_FORMAT_STRING, text); + pCustomListItem->SetElement(ID_FORMAT_MARGIN, ""); + + if (pBackgroundBitmap != null) + { + pCustomListItem->SetNormalItemBackgroundBitmap(*pBackgroundBitmap); + } + + pCustomListItem->__pCustomListItemImpl->itemId = groupId; + + return pCustomListItem; +} + +result +_SlidableGroupedListImpl::CreateGroupObject(int groupIndex, int itemCount, int groupHeight) +{ + _SlidableGroupObject* pGroupObject = new (std::nothrow) _SlidableGroupObject(); + SysTryReturn(NID_UI_CTRL, pGroupObject != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __groupsList.InsertAt(*pGroupObject, groupIndex); + + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || _annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + { + pGroupObject->__pCheckedList = new (std::nothrow) ArrayList(); + SysTryReturn(NID_UI_CTRL, pGroupObject->__pCheckedList, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed"); + + pGroupObject->__pCheckedList->Construct(itemCount); + + Boolean* pChecked = null; + + for (int count = 0; count < itemCount; count++) + { + pChecked = new (std::nothrow) Boolean(false); + SysTryReturn(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed"); + pGroupObject->__pCheckedList->Add(*pChecked); + } + } + + pGroupObject->__groupHeight = groupHeight; + pGroupObject->__itemCount = itemCount; + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::InsertGroupAt(int groupIndex, const String& text, const Bitmap* pBackgroundBitmap, int itemCount, int groupHeight, int groupId) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex <= __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d)", groupIndex); + + r = CreateGroupObject(groupIndex, itemCount, groupHeight); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + CustomListItem* pCustomListItem = CreateGroupItemN(text, pBackgroundBitmap, groupId); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = InsertIntoItemsList(*pCustomListItem, groupIndex, -1); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __loadedCount += itemCount; + + if (__slidableListenersList.GetCount() == 0) + { + return E_SUCCESS; + } + + if (groupIndex <= __topGroup) + { + __topGroup++; + __bottomGroup++; + } + + if (__pItemProvider == null) + { + r = CreateItemProvider(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + _ListBaseImpl::OnDraw(); + } + else + { + r = GetCore().RefreshTableView(groupIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to insert a group."); + } + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::GetLastCheckedItemIndex(int& groupIndex, int& itemIndex) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL."); + + for (int groupCount = __groupsList.GetCount() - 1; groupCount >= 0; groupCount--) + { + int subItemCount = GetSubItemCountAt(groupCount); + + for (int itemCount = subItemCount - 1; itemCount >= 0; itemCount--) + { + if (IsItemChecked(groupCount, itemCount)) + { + itemIndex = itemCount; + groupIndex = groupCount; + return E_SUCCESS; + } + } + } + + return E_SYSTEM; +} + +const CustomListItem* +_SlidableGroupedListImpl::GetLoadedItemAt(int groupIndex, int index) const +{ + SysTryReturn(NID_UI_CTRL, (groupIndex >= __topGroup && groupIndex <= __bottomGroup), null, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d) is not loaded or invalid.", groupIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast(__groupsList.GetAt(groupIndex))); + SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < GetSubItemCountAt(groupIndex)), + null, E_INVALID_ARG, "[E_INVALID_ARG] invalid index(%d)", index); + + const CustomListItem* pSubListItem = GetCustomListItemAt(groupIndex, index); + SysTryReturn(NID_UI_CTRL, pSubListItem, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at index (%d).", index); + + return pSubListItem; +} + +int +_SlidableGroupedListImpl::GetLoadedItemIdAt(int groupIndex, int index) const +{ + const CustomListItem* pCustomListItem = GetLoadedItemAt(groupIndex, index - GetTopItemIndex(groupIndex)); + SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. "); + + return pCustomListItem->__pCustomListItemImpl->itemId; +} + +result +_SlidableGroupedListImpl::GetNextCheckedItemIndexAfter(int& groupIndex, int& index) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL."); + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), E_SYSTEM, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + int subItemCount = GetSubItemCountAt(groupIndex); + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < subItemCount), + E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. index (%d).", index); + + int itemStart = 0; + + for (int groupCount = groupIndex; groupCount < __groupsList.GetCount(); groupCount++) + { + if (groupCount == groupIndex) + { + itemStart = index + 1; + } + else + { + itemStart = 0; + } + + subItemCount = GetSubItemCountAt(groupIndex); + for (int checkCount = itemStart; checkCount < subItemCount; checkCount++) + { + if (IsItemChecked(groupCount, checkCount)) + { + groupIndex = groupCount; + index = checkCount; + return E_SUCCESS; + } + } + + itemStart = 0; + } + + return E_SUCCESS; +} + +Color +_SlidableGroupedListImpl::GetTextColorOfEmptyList(void) const +{ + return GetCore().GetTextColorOfEmptyTableView(); +} + +result +_SlidableGroupedListImpl::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + return GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex); +} + +bool +_SlidableGroupedListImpl::IsItemChecked(int groupIndex, int index) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), false, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL."); + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast(__groupsList.GetAt(groupIndex))); + SysTryReturn(NID_UI_CTRL, pGroupObject, false, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < GetSubItemCountAt(groupIndex)), + false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. index (%d).", index); + + Boolean* pChecked = dynamic_cast(const_cast(pGroupObject->__pCheckedList->GetAt(index))); + SysTryReturn(NID_UI_CTRL, pChecked, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + return pChecked->ToBool(); +} + +bool +_SlidableGroupedListImpl::IsItemLoaded(int groupIndex, int itemIndex) const +{ + if (groupIndex < __topGroup || groupIndex > __bottomGroup) + { + return false; + } + + else if (groupIndex == __topGroup) + { + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast(__groupsList.GetAt(groupIndex))); + SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + if (itemIndex >= pGroupObject->__topIndex && itemIndex <= pGroupObject->__itemCount) + { + return true; + } + + return false; + } + else if (groupIndex == __bottomGroup) + { + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast(__groupsList.GetAt(groupIndex))); + SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + if (itemIndex >= 0 && itemIndex < pGroupObject->__itemCount) + { + return true; + } + + return false; + } + + return true; +} + +result +_SlidableGroupedListImpl::RemoveAllGroups(void) +{ + for (int groupCount = __groupsList.GetCount() - 1; groupCount >= 0; groupCount--) + { + RemoveGroupAt(groupCount); + } + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::InsertItemAt(int groupIndex, int index, const CustomListItem& item, int itemId) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index <= GetSubItemCountAt(groupIndex)), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. index (%d).", index); + + item.__pCustomListItemImpl->itemId = itemId; + + r = InsertIntoItemsList(item, groupIndex, index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast(__groupsList.GetAt(groupIndex))); + SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + pGroupObject->__itemCount++; + + if (pGroupObject->__pCheckedList) + { + Boolean* pChecked = new (std::nothrow) Boolean(false); + SysTryCatch(NID_UI_CTRL, pChecked, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pGroupObject->__pCheckedList->InsertAt(*pChecked, index); + } + + if (GetCore().GetFirstDrawnFlag() == false) + { + r = GetCore().RefreshTableView(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to perform InsertItemAt groupIndex (%d), index (%d).", groupIndex, index); + } + + return E_SUCCESS; + +CATCH: + if (pGroupObject->__pCheckedList) + { + pGroupObject->__pCheckedList->RemoveAt(index, true); + } + RemoveFromItemsList(groupIndex, index); + + return E_SYSTEM; +} + +int +_SlidableGroupedListImpl::GetItemCountAt(int groupIndex) const +{ + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + 0, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast(__groupsList.GetAt(groupIndex))); + SysTryReturn(NID_UI_CTRL, pGroupObject, 0, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + return pGroupObject->__itemCount; +} + +result +_SlidableGroupedListImpl::RefreshItem(int groupIndex, int index) +{ + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + int topItemIndex = -1; + int bottomItemIndex = -1; + int groupTopIndex = -1; + + GetCore().GetTopDrawnItemIndex(groupTopIndex, topItemIndex); + GetCore().GetBottomDrawnItemIndex(groupTopIndex, bottomItemIndex); + + SysTryReturn(NID_UI_CTRL, (index >= topItemIndex && index <= bottomItemIndex), E_INVALID_OPERATION, E_INVALID_OPERATION, + "Index (%d) should be within drawn item range.", index); + + result r = E_SUCCESS; + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = GetCustomListItemAt(groupIndex, index); + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, + "A system error has occurred. Failed to perform RefreshItem at groupIndex (%d), index (%d).", groupIndex, index); + + DrawItem(groupIndex, index); + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::RefreshGroup(int groupIndex) +{ + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + int topIndex = GetTopItemIndex(groupIndex); + int subItemCount = GetSubItemCountAt(groupIndex); + + for (int itemCount = topIndex; itemCount < topIndex + subItemCount; itemCount++) + { + RefreshItem(groupIndex, itemCount); + } + + return E_SUCCESS; + +} + +bool +_SlidableGroupedListImpl::IsLoadedItemEnabled(int groupIndex, int index) const +{ + if (IsItemLoaded(groupIndex, index) == false) + { + return false; + } + + return GetCore().IsItemEnabled(groupIndex, index); +} + +result +_SlidableGroupedListImpl::LoadItemToBottom(const CustomListItem& item, int itemId) +{ + SysTryReturn(NID_UI_CTRL, __isCreating == true, E_SUCCESS, E_SUCCESS, + "[E_SUCCESS] This operation is ignored during creation of list."); + + int itemIndex = GetSubItemCountAt(__bottomGroup); + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = (const_cast(&item)); + tableViewItemParams.width = GetCore().GetBounds().width; + tableViewItemParams.groupIndex = __bottomGroup; + tableViewItemParams.itemIndex = itemIndex; + tableViewItemParams.isDividerEnabled = _isDividerEnabled; + tableViewItemParams.pCheckBitmaps = _pCheckBitmaps; + tableViewItemParams.itemId = itemId; + tableViewItemParams.annexStyle = _annexStyle; + + result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + item.__pCustomListItemImpl->itemId = itemId; + + r = InsertIntoItemsList(item, __bottomGroup, itemIndex, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::LoadItemToTop(const CustomListItem& item, int itemId) +{ + SysTryReturn(NID_UI_CTRL, __isCreating == true, E_SUCCESS, E_SUCCESS, + "[E_SUCCESS] This operation is ignored during creation of list."); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(__topGroup)); + SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __topGroup); + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = (const_cast(&item)); + tableViewItemParams.width = GetCore().GetBounds().width; + tableViewItemParams.itemId = itemId; + tableViewItemParams.itemIndex = pGroupObject->__topIndex; + tableViewItemParams.groupIndex = __topGroup; + tableViewItemParams.isDividerEnabled = _isDividerEnabled; + tableViewItemParams.pCheckBitmaps = _pCheckBitmaps; + tableViewItemParams.annexStyle = _annexStyle; + + result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + item.__pCustomListItemImpl->itemId = itemId; + + r = InsertIntoItemsList(item, __topGroup, 0, false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::GetLoadedItemIndexFromItemId(int itemId, int& groupIndex, int& itemIndex) const +{ + for (int groupCount = __topGroup; groupCount <= __bottomGroup; groupCount++) + { + for (int itemCount = 0; itemCount < GetSubItemCountAt(groupCount); itemCount++) + { + const CustomListItem* pItem = GetCustomListItemAt(groupCount, itemCount); + if (!pItem) + { + continue; + } + + if (pItem->__pCustomListItemImpl->itemId == itemId) + { + groupIndex = groupCount; + itemIndex = itemCount; + return E_SUCCESS; + } + } + } + + groupIndex = -1; + itemIndex = -1; + + return E_SYSTEM; +} + +result +_SlidableGroupedListImpl::UnloadAllItems(void) +{ + result r = E_SUCCESS; + int itemCount = 0; + int groupCount = 0; + int itemIndex = 0; + + SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. ISlidableGroupedListEventListener not set."); + + __directDelete = true; + + for (groupCount = __groupsList.GetCount() - 1; groupCount >= 0; groupCount--) + { + itemCount = GetSubItemCountAt(groupCount); + + for (itemIndex = itemCount - 1; itemIndex >= 0; itemIndex--) + { + RemoveFromItemsList(groupCount, itemIndex); + + r = GetCore().RefreshTableView(groupCount, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + if (r != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Group item with index %d not removed successFully.", groupCount); + } + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupCount)); + SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupCount); + + if (pGroupObject->__pCheckedList != null) + { + pGroupObject->__pCheckedList->RemoveAt(itemIndex, true); + } + + CallUnloadItemCb(groupCount, itemIndex); + } + } + + __directDelete = false; + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::RemoveAllCheckedItemsAt(int groupIndex, int itemHeight) +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL."); + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_RADIO."); + + SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. ISlidableGroupedListEventListener not set."); + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + result r = E_SUCCESS; + Boolean* pChecked = null; + int itemIndex = 0; + + for (; itemIndex < pGroupObject->__itemCount; itemIndex++) + { + pChecked = dynamic_cast(const_cast(pGroupObject->__pCheckedList->GetAt(itemIndex))); + SysTryReturn(NID_UI_CTRL, pChecked, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred."); + + if (pChecked->ToBool() == true) + { + r = RemoveItemAt(groupIndex, itemIndex, itemHeight); + if (r != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Failed to remove the itme at groupIndex (%d), itemIndex (%d).", groupIndex, itemIndex); + } + itemIndex--; + } + } + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::RemoveAllCheckedItems(int itemHeight) +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL."); + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_RADIO."); + + SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. ISlidableGroupedListEventListener not set."); + + int groupCount = 0; + + for (; groupCount < __groupsList.GetCount(); groupCount++) + { + RemoveAllCheckedItemsAt(groupCount, itemHeight); + } + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::RemoveAllItemsAt(int groupIndex) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + __directDelete = true; + + for (int itemCount = 0; itemCount < GetSubItemCountAt(groupIndex);) + { + r = RemoveItemAt(groupIndex, 0, 0); + if (r != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Group item with index %d not removed successFully.", groupIndex); + } + } + + __directDelete = false; + + if (pGroupObject->__pCheckedList != null) + { + pGroupObject->__pCheckedList->RemoveAll(true); + } + + pGroupObject->__itemCount = 0; + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::RemoveAllItems(void) +{ + SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. ISlidableGroupedListEventListener not set."); + + int groupCount = 0; + + for (groupCount = 0; groupCount < __groupsList.GetCount(); groupCount++) + { + RemoveAllItemsAt(groupCount); + } + + __pItemProvider->firstTime = true; + + return E_SUCCESS; +} + +void +_SlidableGroupedListImpl::RemoveFastScrollEventListener(IFastScrollEventListener& listener) +{ + __pFastScrollListener = null; +} + +void +_SlidableGroupedListImpl::RemoveGroupedItemEventListener(IGroupedItemEventListener& listener) +{ + _ListListener* pListenerList = null; + + for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++) + { + pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + + if ((pListenerList != null) && (pListenerList->pListener == &listener)) + { + __itemListenersList.RemoveAt(listenerCount, true); + break; + } + } +} + +result +_SlidableGroupedListImpl::RemoveItemAt(int groupIndex, int index, int itemHeight) +{ + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + int subItemCount = GetSubItemCountAt(groupIndex); + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < subItemCount), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. index (%d).", index); + + if (!(index < pGroupObject->__topIndex + subItemCount)) + { + pGroupObject->__itemCount--; + return E_SUCCESS; + } + + __directDelete = true; + + RemoveFromItemsList(groupIndex, index); + + result r = GetCore().RefreshTableView(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + if (r != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Group item with index %d not removed successFully.", groupIndex); + } + + if (pGroupObject->__pCheckedList != null) + { + pGroupObject->__pCheckedList->RemoveAt(index, true); + } + + __directDelete = false; + + CallUnloadItemCb(groupIndex, index); + pGroupObject->__itemCount--; + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::RemoveGroupAt(int groupIndex) +{ + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + result r = E_SUCCESS; + + r = RemoveFromSubItemsList(groupIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = RemoveFromItemsList(groupIndex, -1); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r)); + + __groupsList.RemoveAt(groupIndex, true); + + __directDelete = true; + + if (GetCore().GetFirstDrawnFlag() == false) + { + r = GetCore().RefreshTableView(groupIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __directDelete = false; + + return E_SUCCESS; +} + +void +_SlidableGroupedListImpl::ScrollToBottom(void) +{ + SysTryReturnVoidResult(NID_UI_CTRL, (__slidableListenersList.GetCount() > 0), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. No listeners available."); + + __forceScroll = true; + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(__groupsList.GetCount() - 1)); + SysTryReturnVoidResult(NID_UI_CTRL, pGroupObject, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __groupsList.GetCount() - 1); + + result r = GetCore().SetBottomDrawnItemIndex(__groupsList.GetCount() - 1, pGroupObject->__itemCount - 1); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __forceScroll = false; + + GetCore().Draw(); +} + +result +_SlidableGroupedListImpl::ScrollToTop(int groupIndex) +{ + SysTryReturnResult(NID_UI_CTRL, (__slidableListenersList.GetCount() > 0), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. No listeners available."); + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + result r = E_SUCCESS; + + __forceScroll = true; + + r = GetCore().SetTopDrawnItemIndex(groupIndex, -1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + __forceScroll = false; + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::ScrollToTop(int groupIndex, int itemIndex) +{ + SysTryReturnResult(NID_UI_CTRL, (__slidableListenersList.GetCount() > 0), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. No listeners available."); + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex); + + SysTryReturn(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < pGroupObject->__itemCount), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. itemIndex (%d).", itemIndex); + + result r = E_SUCCESS; + + __forceScroll = true; + + r = GetCore().SetTopDrawnItemIndex(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + __forceScroll = false; + + return E_SUCCESS; +} + +void +_SlidableGroupedListImpl::ScrollToTop(void) +{ + SysTryReturnVoidResult(NID_UI_CTRL, (__slidableListenersList.GetCount() > 0), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. No listeners available."); + + __forceScroll = true; + + result r = GetCore().SetTopDrawnItemIndex(0, -1); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + __forceScroll = false; +} + +result +_SlidableGroupedListImpl::SetAllItemsChecked(int groupIndex, bool check) +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL."); + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_RADIO."); + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < GetGroupCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM]"); + + for (int indexItem = 0; indexItem < pGroupObject->__itemCount; indexItem++) + { + Boolean* pChecked = new (std::nothrow) Boolean(check); + SysTryReturn(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed"); + + pGroupObject->__pCheckedList->SetAt(*pChecked, indexItem, true); + + _CheckElementModel*pCheckElement = GetCheckElementAt(groupIndex, indexItem); + SysTryReturnResult(NID_UI_CTRL, (pCheckElement != null), E_SYSTEM, "A system error has occurred."); + + pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check); + } + + GetCore().Invalidate(true); + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::SetItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId) +{ + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + SysTryReturn(NID_UI_CTRL, ((itemIndex >= 0) && (itemIndex < GetSubItemCountAt(groupIndex))), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. itemIndex (%d).", itemIndex); + + SysTryReturnResult(NID_UI_CTRL, (IsItemNew(item) == true), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The item already exists."); + + _CheckElementModel* pOldCheckElement = GetCheckElementAt(groupIndex, itemIndex - GetTopItemIndex(groupIndex)); + _CheckElementModel* pNewCheckElement = item.__pCustomListItemImpl->GetCheckElement(); + + if (pNewCheckElement && pOldCheckElement) + { + pNewCheckElement->SetCheckBoxStatus(pOldCheckElement->GetCheckBoxStatus()); + } + + item.__pCustomListItemImpl->__pTableViewItemData = GetTableViewItemAt(groupIndex, itemIndex); + item.__pCustomListItemImpl->itemId = itemId; + + result r = SetInItemsList(item, groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetCore().RefreshTableView(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::UpdateCheckedList(int groupIndex, int index, bool check) +{ + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, (pGroupObject != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at groupIndex (%d).", groupIndex); + + SysTryReturn(NID_UI_CTRL, (pGroupObject->__pCheckedList != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get checked list at groupIndex (%d).", groupIndex); + + Boolean* pChecked = new (std::nothrow) Boolean(check); + SysTryReturn(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + pGroupObject->__pCheckedList->SetAt(*pChecked, index, true); + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::SetItemCheckedRadio(int groupIndex, int index, bool check) +{ + if (check) + { + if (_currentRadioIndex != -1) + { + _CheckElementModel* pOldCheckElement = GetCheckElementAt(_currentRadioGroupIndex, _currentRadioIndex); + SysTryReturnResult(NID_UI_CTRL, (pOldCheckElement != null), E_SYSTEM, "A system error has occurred."); + + pOldCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED); + + UpdateCheckedList(_currentRadioGroupIndex, _currentRadioIndex, false); + + DrawItem(_currentRadioGroupIndex, _currentRadioIndex); + } + + _currentRadioGroupIndex = groupIndex; + _currentRadioIndex = index; + + UpdateCheckedList(groupIndex, index, true); + } + else + { + UpdateCheckedList(groupIndex, index, false); + + _currentRadioGroupIndex = -1; + _currentRadioIndex = -1; + } + + DrawItem(groupIndex, index); + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::SetItemCheckedMarkOnOff(int groupIndex, int index, bool check) +{ + _CheckElementModel* pCheckElement = GetCheckElementAt(groupIndex, index); + SysTryReturnResult(NID_UI_CTRL, (pCheckElement != null), E_SYSTEM, "A system error has occurred."); + + pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check); + + UpdateCheckedList(groupIndex, index, check); + + DrawItem(groupIndex, index); + + return E_SUCCESS; +} + +result +_SlidableGroupedListImpl::SetItemChecked(int groupIndex, int index, bool check) +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL."); + + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, (pGroupObject != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at groupIndex (%d).", groupIndex); + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < pGroupObject->__itemCount), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. index (%d).", index); + + if (IsItemChecked(groupIndex, index) == check) + { + return E_SUCCESS; + } + + SysTryReturnResult(NID_UI_CTRL, (GetCore().IsItemEnabled(groupIndex, index)), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The list item is not enabled."); + + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + { + return SetItemCheckedRadio(groupIndex, index, check); + } + else + { + return SetItemCheckedMarkOnOff(groupIndex, index, check); + } +} + +result +_SlidableGroupedListImpl::SetLoadedItemEnabled(int groupIndex, int index, bool enable) +{ + SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex); + + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at groupIndex (%d).", groupIndex); + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < pGroupObject->__itemCount), + E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. index (%d).", index); + + return GetCore().SetItemEnabled(groupIndex, index, enable); +} + +void +_SlidableGroupedListImpl::SetTextColorOfEmptyList(const Color& color) +{ + GetCore().SetTextColorOfEmptyTableView(color); +} + +void +_SlidableGroupedListImpl::SetTextOfEmptyList(const String& text) +{ + GetCore().SetTextOfEmptyTableView(text); +} + +result +_SlidableGroupedListImpl::SetGroupAt(int groupIndex, const String& text, const Bitmap* pBackgroundBitmap, int groupId) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), + E_INVALID_ARG, "Invalid argument is used. groupIndex (%d).", groupIndex); + + _SlidableGroupObject* pOldGroup = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex)); + SysTryReturn(NID_UI_CTRL, pOldGroup, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at groupIndex (%d).", groupIndex); + + CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1); + SysTryReturn(NID_UI_CTRL, (pCustomListItem), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at groupIndex (%d).", groupIndex); + + pCustomListItem->SetElement(ID_FORMAT_STRING, text); + + if (pBackgroundBitmap != null) + { + pCustomListItem->SetNormalItemBackgroundBitmap(*pBackgroundBitmap); + } + + pCustomListItem->__pCustomListItemImpl->itemId = groupId; + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = pCustomListItem; + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "A system error has occurred. Failed to update an item."); + + return E_SUCCESS; +} + +void +_SlidableGroupedListImpl::OnTableViewItemStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + return; +} + +void +_SlidableGroupedListImpl::OnTableViewContextItemActivationStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_SlidableGroupedListImpl::OnTableViewItemReordered(_TableView& tableView, int itemIndexFrom, int itemIndexTo) +{ + return; +} + +void +_SlidableGroupedListImpl::OnGroupedTableViewGroupItemStateChanged(_TableView& tableView, int groupIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + return; +} + +void +_SlidableGroupedListImpl::OnGroupedTableViewItemStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex - GetTopItemIndex(groupIndex)); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at itemIndex (%d).", itemIndex); + + CustomListItemStatus customListItemStatus = CUSTOM_LIST_ITEM_STATUS_NORMAL; + ItemStatus itemStatus = ITEM_HIGHLIGHTED; + + switch (status) + { + case TABLE_VIEW_ITEM_STATUS_SELECTED: + itemStatus = ITEM_SELECTED; + customListItemStatus = CUSTOM_LIST_ITEM_STATUS_SELECTED; + break; + case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED: + itemStatus = ITEM_HIGHLIGHTED; + customListItemStatus = CUSTOM_LIST_ITEM_STATUS_FOCUSED; + break; + case TABLE_VIEW_ITEM_STATUS_CHECKED: + itemStatus = ITEM_CHECKED; + break; + case TABLE_VIEW_ITEM_STATUS_UNCHECKED: + itemStatus = ITEM_UNCHECKED; + break; + default: + SetLastResult(E_INVALID_ARG); + SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument is used. ListItemStatus is invalid"); + return; + } + + LinkedList* pElements = &pCustomListItem->__pCustomListItemImpl->elements; + _ElementBaseModel* pElementBase = null; + + for (int i = 0; i < pElements->GetCount(); i++) + { + pElementBase = dynamic_cast<_ElementBaseModel*>(pElements->GetAt(i)); + SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "Invalid element."); + + if ((_isDividerEnabled && pElementBase->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX) || (!_isDividerEnabled)) + { + pElementBase->HandleElementEvent(customListItemStatus); + } + } + + if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL)) + { + bool isChecked = IsItemChecked(groupIndex, itemIndex); + + if (isChecked) + { + itemStatus = ITEM_UNCHECKED; + } + else + { + itemStatus = ITEM_CHECKED; + } + + SetItemChecked(groupIndex, itemIndex, !isChecked); + } + + ProcessItemStateChange(groupIndex, itemIndex, itemStatus); + + GetCore().Draw(); + return; +} + +void +_SlidableGroupedListImpl::OnGroupedTableViewContextItemActivationStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_SlidableGroupedListImpl::OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo) +{ + return; +} + +void +_SlidableGroupedListImpl::OnSectionTableViewItemStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status) +{ + return; +} + +void +_SlidableGroupedListImpl::OnSectionTableViewContextItemActivationStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_SlidableGroupedListImpl::OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction) +{ + return; +} + +void +_SlidableGroupedListImpl::OnDraw(void) +{ + if (__pItemProvider == null) + { + result r = E_SUCCESS; + + r = CreateItemProvider(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + _ListBaseImpl::OnDraw(); +} + +result +_SlidableGroupedListImpl::CreateItemProvider(void) +{ + if (__pItemProvider == null) + { + __pItemProvider = new (std::nothrow) _SlidableGroupedListItemProvider(this); + SysTryReturnResult(NID_UI_CTRL, __pItemProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryReturnResult(NID_UI_CTRL, style == TABLE_VIEW_STYLE_GROUPED, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_GROUPED"); + + _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style); + result r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pItemProvider != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pItemProvider->SetGroupedStyleItemProvider(__pItemProvider); + + GetCore().SetItemProvider(pItemProvider); + } + + return E_SUCCESS; +} + +void +_SlidableGroupedListImpl::Initialize(void) +{ + GetCore().AddGroupedTableViewItemEventListener(*this); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_HEIGHT, GetCore().GetOrientation(), __groupItemHeight); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_FONT_SIZE, GetCore().GetOrientation(), __groupItemTextFont); + + __itemCacheSize = GetCore().GetMaxItemCachingSize(); + + __pItemFormat = new (std::nothrow) CustomListItemFormat(); + SysTryReturnVoidResult(NID_UI_CTRL, __pItemFormat, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pItemFormat->Construct(); + + int leftMargin = 0; + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_LEFT_MARGIN, GetCore().GetOrientation(), leftMargin); + + __pItemFormat->AddElement(ID_FORMAT_MARGIN, Rectangle(0, 0, leftMargin, __groupItemHeight), __groupItemTextFont); + __pItemFormat->AddElement(ID_FORMAT_STRING, Rectangle(leftMargin, 0, GetCore().GetBounds().width, __groupItemHeight), __groupItemTextFont); + + __pItemFormat->SetElementEventEnabled(ID_FORMAT_MARGIN, true); + __pItemFormat->SetElementEventEnabled(ID_FORMAT_STRING, true); + + return; +} + +void +_SlidableGroupedListImpl::OnUiFastScrollIndexSelected(_Control& source, _FastScrollIndex& index) +{ + int groupIndex = 0; + mchar mch = L' '; + String* pIndexText = index.GetIndexText(); + if (pIndexText != null) + { + pIndexText->GetCharAt(0, mch); + result r = __mainScrollIndex.IndexOf(*pIndexText, 0, groupIndex); + if (!IsFailed(r)) + { + const Control& control = GetPublic(); + _FastScrollIndex* pMainIndex = index.GetParentIndex(); + if (pMainIndex == GetCore().GetFastScrollBar()->GetIndex()) + { + Character mainIndex(mch); + __pFastScrollListener->OnMainIndexChanged(control, mainIndex); + } + else + { + Character subIndex(mch); + pIndexText = pMainIndex->GetIndexText(); + if (pIndexText != null) + { + pIndexText->GetCharAt(0, mch); + Character mainIndex(mch); + __pFastScrollListener->OnSubIndexChanged(control, mainIndex, subIndex); + } + } + } + } + SetLastResult(E_SUCCESS); +} + +const char* +_SlidableGroupedListImpl::GetPublicClassName(void) const +{ + return "SlidableGroupedList"; +} + +const SlidableGroupedList& +_SlidableGroupedListImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +SlidableGroupedList& +_SlidableGroupedListImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _TableView& +_SlidableGroupedListImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_TableView& +_SlidableGroupedListImpl::GetCore(void) +{ + return static_cast<_TableView&>(_ControlImpl::GetCore()); +} + +void +_SlidableGroupedListImpl::ProcessItemStateChange(int groupIndex, int itemIndex, int elementId, ItemStatus itemStatus) +{ + CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex - GetTopItemIndex(groupIndex)); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at itemIndex (%d).", itemIndex); + + int itemId = pCustomListItem->__pCustomListItemImpl->itemId; + + _ListListener* pListenerList = null; + IGroupedItemEventListener* pEventListener = null; + + for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++) + { + pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _ListListener."); + + pEventListener = dynamic_cast(pListenerList->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get IGroupedItemEventListener."); + + pEventListener->OnItemStateChanged(GetPublic(), groupIndex, itemIndex, itemId, elementId, itemStatus); + } +} + +void +_SlidableGroupedListImpl::ProcessItemStateChange(int groupIndex, int itemIndex, ItemStatus itemStatus) +{ + CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex - GetTopItemIndex(groupIndex)); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at itemIndex (%d).", itemIndex); + + int itemId = pCustomListItem->__pCustomListItemImpl->itemId; + + _ListListener* pListenerList = null; + IGroupedItemEventListener* pEventListener = null; + + for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++) + { + pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _ListListener."); + + pEventListener = dynamic_cast(pListenerList->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get IGroupedItemEventListener."); + + pEventListener->OnItemStateChanged(GetPublic(), groupIndex, itemIndex, itemId, itemStatus); + } +} + +void +_SlidableGroupedListImpl::CallUnloadItemCb(int groupIndex, int itemIndex) +{ + _ListListener* pListenerData = null; + ISlidableGroupedListEventListener* pSlidableListener = null; + + for (int listenerCount = 0; listenerCount < __slidableListenersList.GetCount(); listenerCount++) + { + pListenerData = dynamic_cast<_ListListener*>(__slidableListenersList.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerData != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _ListListener."); + + pSlidableListener = dynamic_cast(pListenerData->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pSlidableListener != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get IGroupedItemEventListener."); + + pSlidableListener->OnUnloadItemRequested(GetPublic(), groupIndex, itemIndex); + } +} + +int +_SlidableGroupedListImpl::GetCurrentLoadedCount(void) +{ + int count = 0; + + for (int groupIndex = __topGroup; groupIndex <= __bottomGroup; groupIndex++) + { + _TableViewGroupItemData* pTableViewGroupItemData = GetTableViewGroupItemAt(groupIndex); + + if (pTableViewGroupItemData) + { + count++; + } + + count += GetSubItemCountAt(groupIndex); + } + + return count; +} + +int +_SlidableGroupedListImpl::GetTopItemIndex(int groupIndex) const +{ + _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast(__groupsList.GetAt(groupIndex))); + SysTryReturn(NID_UI_CTRL, pGroupObject, INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at groupIndex (%d).", groupIndex); + + return pGroupObject->__topIndex; +} + +class _SlidableGroupedListMaker + : public _UiBuilderControlMaker +{ +public: + _SlidableGroupedListMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_SlidableGroupedListMaker(){}; + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _SlidableGroupedListMaker* pSlidableListMaker = new (std::nothrow) _SlidableGroupedListMaker(uibuilder); + return pSlidableListMaker; + }; +protected: + virtual Tizen::Ui::Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + SlidableGroupedList* pSlidableGroupedList = null; + Tizen::Graphics::Rectangle rect; + Tizen::Graphics::Rectangle rectMin; + Dimension dimMin; + Tizen::Base::String elementString; + CustomListStyle style = CUSTOM_LIST_STYLE_NORMAL; + bool isItemDivider = true; + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pSlidableGroupedList = new (std::nothrow) SlidableGroupedList(); + if (pSlidableGroupedList == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + + Tizen::Base::String styleString; + styleString = pControlProperty->GetStyle(); + + if (styleString.Equals(L"CUSTOM_LIST_STYLE_NORMAL", false)) + { + style = CUSTOM_LIST_STYLE_NORMAL; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO", false)) + { + style = CUSTOM_LIST_STYLE_RADIO; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK", false)) + { + style = CUSTOM_LIST_STYLE_MARK; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF", false)) + { + style = CUSTOM_LIST_STYLE_ONOFF; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER; + } + else + { + style = CUSTOM_LIST_STYLE_NORMAL; + } + + //Construct + if (pControl->GetElement(L"itemDivider", elementString)) + { + if (elementString.Equals(L"true", false)) + { + isItemDivider = true; + } + else + { + isItemDivider = false; + } + } + + r = pSlidableGroupedList->Construct(rect, style, isItemDivider); + if (r != E_SUCCESS) + { + delete pSlidableGroupedList; + return null; + } + + if (pControl->GetElement(L"textOfEmptyList", elementString)) + { + pSlidableGroupedList->SetTextOfEmptyList(elementString); + } + + if (pControl->GetElement(L"colorOfEmptyListText", elementString)) + { + ConvertStringToColor(elementString, color); + pSlidableGroupedList->SetTextColorOfEmptyList(color); + } + + GET_DIMENSION_CONFIG(LIST::GROUPEDLIST_MIN_SIZE, _CONTROL_ORIENTATION_PORTRAIT, dimMin); + rectMin = (pControl->GetAttribute(0))->GetRect(); + (pControl->GetAttribute(0))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height); + + GET_DIMENSION_CONFIG(LIST::GROUPEDLIST_MIN_SIZE, _CONTROL_ORIENTATION_LANDSCAPE, dimMin); + rectMin = (pControl->GetAttribute(1))->GetRect(); + (pControl->GetAttribute(1))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height); + + return pSlidableGroupedList; + } + +private: +}; + +_SlidableGroupedListRegister::_SlidableGroupedListRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + if (pUiBuilderControlTableManager) + { + pUiBuilderControlTableManager->RegisterControl(L"SlidableGroupedList", _SlidableGroupedListMaker::GetInstance); + } +} +_SlidableGroupedListRegister::~_SlidableGroupedListRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + if (pUiBuilderControlTableManager) + { + pUiBuilderControlTableManager->UnregisterControl(L"SlidableGroupedList"); + } +} +static _SlidableGroupedListRegister SlidableGroupedListRegisterToUiBuilder; +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SlidableListImpl.cpp b/src/ui/controls/FUiCtrl_SlidableListImpl.cpp new file mode 100644 index 0000000..169e3d5 --- /dev/null +++ b/src/ui/controls/FUiCtrl_SlidableListImpl.cpp @@ -0,0 +1,1888 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SlidableListImpl.cpp + * @brief This is the implementation file for the _SlidableListImpl class. + */ + +#include +#include +#include "FUiCtrl_CustomListItemFormatImpl.h" +#include "FUiCtrl_CustomListItemImpl.h" +#include "FUiCtrl_SlidableListImpl.h" +#include "FUiCtrl_ListListener.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_ListItemBaseImpl.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_TableViewItemProvider.h" +#include "FUiCtrl_TableViewPresenter.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Graphics; +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Graphics; +using namespace Tizen::Media; +using namespace Tizen::Base::Collection; + + +namespace Tizen { namespace Ui { namespace Controls +{ + +extern const int INVALID_INDEX; + +_SlidableListItemProvider::_SlidableListItemProvider(_SlidableListImpl* pList) + : firstTime(true) + , bottomListenerIndex(0) + , topListenerIndex(0) + , __pListImpl(pList) +{ + if (__pListImpl) + { + topListenerIndex = __pListImpl->__slidableListenersList.GetCount() - 1; + } +} + +int +_SlidableListItemProvider::GetItemCount(void) +{ + SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly."); + + if (__pListImpl->__slidableListenersList.GetCount() > 0) + { + if (firstTime == true) + { + _ListListener* pListenerData = null; + ISlidableListEventListener* pSlidableListener = null; + int listenerCount = 0; + + for (listenerCount = 0; listenerCount < __pListImpl->__slidableListenersList.GetCount(); listenerCount++) + { + pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(listenerCount)); + + if (pListenerData) + { + pSlidableListener = dynamic_cast(pListenerData->pListener); + SysTryReturn(NID_UI_CTRL, (pSlidableListener != null), -1, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get EventListener."); + + pSlidableListener->OnListPropertyRequested(__pListImpl->GetPublic()); + } + } + + firstTime = false; + } + + return __pListImpl->__totalItemCount; + } + else + { + return 0; + } +} + +result +_SlidableListItemProvider::CallLoadToTopCb(int index) +{ + _ListListener* pListenerData = null; + ISlidableListEventListener* pSlidableListener = null; + + pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(topListenerIndex)); + SysTryReturn(NID_UI_CTRL, pListenerData, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the listener."); + + pSlidableListener = dynamic_cast(pListenerData->pListener); + SysTryReturn(NID_UI_CTRL, pSlidableListener, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the listener."); + + pSlidableListener->OnLoadToTopRequested(__pListImpl->GetPublic(), index, 1); + + if (--topListenerIndex < 0) + { + topListenerIndex = __pListImpl->__slidableListenersList.GetCount() - 1; + } + + return E_SUCCESS; +} + +result +_SlidableListItemProvider::UpdateCheckStatus(_TableViewItemData* pTableViewItemData, int index) +{ + if (pTableViewItemData && __pListImpl->__pCheckedList) + { + Boolean* pChecked = dynamic_cast(__pListImpl->__pCheckedList->GetAt(index)); + SysTryReturn(NID_UI_CTRL, pChecked, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get Check status"); + + _CheckElementModel* pCheckElement = __pListImpl->GetCheckElementAt(-1, index - __pListImpl->__topIndex); + SysTryReturn(NID_UI_CTRL, pCheckElement, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get CheckElement. "); + + pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)pChecked->ToBool()); + } + + return E_SUCCESS; +} + +_TableViewItemData* +_SlidableListItemProvider::LoadAtTop(int index) +{ + _TableViewItemData* pTableViewItemData = null; + result r = E_SUCCESS; + + r = CallLoadToTopCb(index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + __pListImpl->__topIndex = index; + + pTableViewItemData = __pListImpl->GetTableViewItemAt(-1, 0); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = UpdateCheckStatus(pTableViewItemData, index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return pTableViewItemData; +} + +result +_SlidableListItemProvider::CallLoadToBottomCb(int index) +{ + _ListListener* pListenerData = null; + ISlidableListEventListener* pSlidableListener = null; + + pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(bottomListenerIndex)); + SysTryReturn(NID_UI_CTRL, pListenerData, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the listener."); + + pSlidableListener = dynamic_cast(pListenerData->pListener); + SysTryReturn(NID_UI_CTRL, pSlidableListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the listener."); + + pSlidableListener->OnLoadToBottomRequested(__pListImpl->GetPublic(), index, 1); + + if (++bottomListenerIndex == __pListImpl->__slidableListenersList.GetCount()) + { + bottomListenerIndex = 0; + } + + return E_SUCCESS; +} + +_TableViewItemData* +_SlidableListItemProvider::LoadAtBottom(int index) +{ + _TableViewItemData* pTableViewItemData = null; + result r = E_SUCCESS; + + r = CallLoadToBottomCb(index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pListImpl->_itemsList.GetCount() > __pListImpl->__itemCacheSize) + { + __pListImpl->__topIndex++; + } + else if (__pListImpl->_itemsList.GetCount() == 1) + { + __pListImpl->__topIndex = index; + } + + pTableViewItemData = __pListImpl->GetTableViewItemAt(-1, __pListImpl->_itemsList.GetCount() - 1); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = UpdateCheckStatus(pTableViewItemData, index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return pTableViewItemData; +} + +TableViewItem* +_SlidableListItemProvider::CreateItem(int index, int itemWidth) +{ + SysTryReturn(NID_UI_CTRL, __pListImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly."); + + _TableViewItemData* pItem = null; + pItem = __pListImpl->GetTableViewItemAt(-1, index - __pListImpl->__topIndex); + + result r = E_SUCCESS; + + __pListImpl->__isCreating = true; + + if (pItem == null) + { + if (index < __pListImpl->__topIndex) // load at top + { + pItem = LoadAtTop(index); + } + else // load at bottom + { + pItem = LoadAtBottom(index); + } + + SysTryReturn(NID_UI_CTRL, pItem, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + + __pListImpl->__isCreating = false; + + return pItem; +} + +bool +_SlidableListItemProvider::DeleteItem(int index, TableViewItem* pItem) +{ + SysTryReturn(NID_UI_CTRL, __pListImpl, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly."); + + result r = E_SUCCESS; + + if (__pListImpl->__isDirectDelete == true) + { + r = __pListImpl->_itemsList.RemoveAt(0, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove an item."); + } + else if (__pListImpl->_itemsList.GetCount() >= __pListImpl->__itemCacheSize) + { + if (index <= __pListImpl->__topIndex) + { + r = __pListImpl->_itemsList.RemoveAt(0, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove an item."); + } + else + { + r = __pListImpl->_itemsList.RemoveAt(__pListImpl->_itemsList.GetCount() - 1, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove an item."); + } + } + + __pListImpl->CallUnloadItemCb(index); + + _TableViewItemData* pTableViewItemData = dynamic_cast<_TableViewItemData*>(pItem); + delete pTableViewItemData; + + return true; +} + +void +_SlidableListItemProvider::UpdateItem(int itemIndex, TableViewItem* pItem) +{ + //return true; +} + +int +_SlidableListItemProvider::GetDefaultItemHeight() +{ + SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List instance must not be null."); + + CustomListItem* pCustomListItem = dynamic_cast(__pListImpl->_itemsList.GetAt(0)); + + if (pCustomListItem) + { + _CustomListItemImpl* pCustomListItemImpl = null; + pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl; + SysTryReturn(NID_UI_CTRL, pCustomListItemImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item instance must not be null"); + return pCustomListItemImpl->height; + } + else + { + return __pListImpl->LISTVIEW_ITEM_HEIGHT; + } +} + +_SlidableListImpl* +_SlidableListImpl::GetInstance(SlidableList& slidableList) +{ + return static_cast<_SlidableListImpl*>(slidableList._pControlImpl); +} + +const _SlidableListImpl* +_SlidableListImpl::GetInstance(const SlidableList& slidableList) +{ + return static_cast(slidableList._pControlImpl); +} + +_SlidableListImpl::_SlidableListImpl(Control* pList, _TableView* pCore) + : _ListBaseImpl(pList, pCore) + , __pCheckedList(null) + , __totalItemCount(-1) + , __topIndex(-1) + , __pItemProvider(null) + , __isDirectDelete(false) + , __isCreating(false) + , __itemCacheSize(0) +{ +} + +_SlidableListImpl::~_SlidableListImpl(void) +{ + if (__pItemProvider && __pItemProvider->firstTime == true) + { + _itemsList.RemoveAll(true); + } + else + { + _itemsList.RemoveAll(false); + } + + __slidableListenersList.RemoveAll(true); + __itemListenersList.RemoveAll(true); + + if (__pCheckedList) + { + __pCheckedList->RemoveAll(true); + delete __pCheckedList; + } + + if (__pItemProvider) + { + delete __pItemProvider; + __pItemProvider = null; + } +} + +const char* +_SlidableListImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::SlidableList"; +} + +const SlidableList& +_SlidableListImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +SlidableList& +_SlidableListImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _TableView& +_SlidableListImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_TableView& +_SlidableListImpl::GetCore(void) +{ + return static_cast<_TableView&>(_ControlImpl::GetCore()); +} + +_SlidableListImpl* +_SlidableListImpl::CreateSlidableListImplN(SlidableList* pControl, const Rectangle& bounds, bool itemDivider) +{ + result r = E_SUCCESS; + + r = GET_SIZE_INFO(SlidableList).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + if (IsFailed(r)) + { + return null; + } + + _TableView* pList = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_SIMPLE, itemDivider, TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pList, null, r, "[%s] Failed to create ListView instance", GetErrorMessage(r)); + + _SlidableListImpl* pImpl = new (std::nothrow) _SlidableListImpl(pControl, pList); + SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pImpl; + +CATCH: + delete pList; + return null; +} + +result +_SlidableListImpl::UpdateBounds(const Rectangle& rect) +{ + result r = E_SUCCESS; + + r = InitializeBoundsProperties(GET_SIZE_INFO(SlidableList), rect, GetCore().GetOrientation()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +_SlidableListImpl::AddSlidableListEventListener(const ISlidableListEventListener& listener) +{ + _ListListener* pListenerData = new (std::nothrow) _ListListener; + SysTryReturnVoidResult(NID_UI_CTRL, pListenerData, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pListenerData->pListener = const_cast(&listener); + __slidableListenersList.Add(*pListenerData); +} + +void +_SlidableListImpl::RemoveSlidableListEventListener(const ISlidableListEventListener& listener) +{ + _ListListener* pListenerData = null; + + for (int listenerCount = 0; listenerCount < __slidableListenersList.GetCount(); listenerCount++) + { + pListenerData = dynamic_cast<_ListListener*>(__slidableListenersList.GetAt(listenerCount)); + + if ((pListenerData != null) && (pListenerData->pListener == &listener)) + { + __slidableListenersList.RemoveAt(listenerCount, true); + break; + } + } +} + +void +_SlidableListImpl::AddCustomItemEventListener(const ICustomItemEventListener& listener) +{ + _ListListener* pListenersList = new (std::nothrow) _ListListener; + SysTryReturnVoidResult(NID_UI_CTRL, pListenersList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pListenersList->pListener = const_cast(&listener); + + __itemListenersList.Add(*pListenersList); +} + +result +_SlidableListImpl::AddItem(const CustomListItem& item, int itemId) +{ + return InsertItemAt((_itemsList.GetCount() + __topIndex), item, itemId); +} + +int +_SlidableListImpl::GetBottomDrawnItemIndex(void) const +{ + int itemIndex = -1; + int groupIndex = -1; + result r = E_SUCCESS; + r = GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the bottom drawn item index."); + + return itemIndex; +} + +int +_SlidableListImpl::GetFirstCheckedItemIndex(void) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + for (int itemIndex = 0; itemIndex < __totalItemCount; itemIndex++) + { + if (IsItemChecked(itemIndex)) + { + SetLastResult(E_SUCCESS); + return itemIndex; + } + } + + SetLastResult(E_SUCCESS); + return INVALID_INDEX; +} + +int +_SlidableListImpl::GetFirstLoadedItemIndex(void) const +{ + result r = E_SUCCESS; + int itemIndex = -1; + int groupIndex = -1; + + r = GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, r, "[%s] Propagating.", GetErrorMessage(r)); + + return itemIndex; +} + +int +_SlidableListImpl::GetLastLoadedItemIndex(void) const +{ + result r = E_SUCCESS; + int itemIndex = -1; + int groupIndex = -1; + + r = GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, r, "[%s] Propagating.", GetErrorMessage(r)); + + return itemIndex; +} + +int +_SlidableListImpl::GetItemCount(void) const +{ + return __totalItemCount; +} + +int +_SlidableListImpl::GetItemIndexFromItemId(int itemId) const +{ + _TableViewItemData* pTableViewItemData = null; + CustomListItem* pCustomListItem = null; + + for (int index = 0; index < _itemsList.GetCount(); index++) + { + pCustomListItem = dynamic_cast(const_cast(_itemsList.GetAt(index))); + SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", index); + + SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Item instance must not be null."); + + pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData; + SysTryReturn(NID_UI_CTRL, pTableViewItemData, INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. ItemData must not be null."); + + if ((pTableViewItemData != null) && (pCustomListItem->__pCustomListItemImpl->itemId == itemId)) + { + SetLastResult(E_SUCCESS); + return index; + } + } + SetLastResult(E_SUCCESS); + return INVALID_INDEX; +} + +int +_SlidableListImpl::GetItemIndexFromPosition(const Point& position) const +{ + int itemIndex = -1; + int groupIndex = -1; + + result r = GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return itemIndex; + +} + +int +_SlidableListImpl::GetItemIndexFromPosition(int x, int y) const +{ + int itemIndex = -1; + int groupIndex = -1; + + result r = GetCore().GetItemIndexFromPosition(Tizen::Graphics::Point(x, y), groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + return itemIndex; +} + +int +_SlidableListImpl::GetLastCheckedItemIndex(void) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + for (int itemIndex = __totalItemCount - 1; itemIndex > 0; itemIndex--) + { + if (IsItemChecked(itemIndex)) + { + SetLastResult(E_SUCCESS); + return itemIndex; + } + } + SetLastResult(E_SUCCESS); + return INVALID_INDEX; +} + +const CustomListItem* +_SlidableListImpl::GetLoadedItemAt(int index) const +{ + SysTryReturn(NID_UI_CTRL, (index >= __topIndex && index < _itemsList.GetCount() + __topIndex), null, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, _itemsList.GetCount()); + + CustomListItem* pCustomListItem = dynamic_cast(const_cast(_itemsList.GetAt(index - __topIndex))); + SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", (index - __topIndex)); + + SetLastResult(E_SUCCESS); + return pCustomListItem; +} + +int +_SlidableListImpl::GetLoadedItemIdAt(int index) const +{ + SysTryReturn(NID_UI_CTRL, (index >= __topIndex && index < _itemsList.GetCount() + __topIndex), INVALID_INDEX, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, _itemsList.GetCount()); + + CustomListItem* pCustomListItem = dynamic_cast(const_cast(_itemsList.GetAt(index - __topIndex))); + SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", (index - __topIndex)); + + SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Item instance must not be null."); + + SetLastResult(E_SUCCESS); + return pCustomListItem->__pCustomListItemImpl->itemId; +} + +int +_SlidableListImpl::GetNextCheckedItemIndexAfter(int index) const +{ + SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL."); + + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < __totalItemCount), INVALID_INDEX, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, __totalItemCount); + + for (int itemIndex = index + 1; itemIndex < __totalItemCount; itemIndex++) + { + if (IsItemChecked(itemIndex)) + { + SetLastResult(E_SUCCESS); + return itemIndex; + } + } + SetLastResult(E_SUCCESS); + return INVALID_INDEX; +} + +Tizen::Graphics::Color +_SlidableListImpl::GetTextColorOfEmptyList(void) const +{ + return GetCore().GetTextColorOfEmptyTableView(); +} + +int +_SlidableListImpl::GetTopDrawnItemIndex(void) const +{ + int topItemIndex = -1; + int groupIndex = -1; + result r = E_SUCCESS; + + r = GetCore().GetTopDrawnItemIndex(groupIndex, topItemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the top drawn item index."); + + return topItemIndex; +} + +result +_SlidableListImpl::InsertItemAt(int index, const CustomListItem& item, int itemId) +{ + SysTryReturnResult(NID_UI_CTRL, (index >= __topIndex && index <= (_itemsList.GetCount() + __topIndex)), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than or equal to (%d).", + index, (_itemsList.GetCount() + __topIndex)); + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = (const_cast(&item)); + tableViewItemParams.width = GetCore().GetBounds().width; + tableViewItemParams.itemIndex = index; + tableViewItemParams.groupIndex = -1; + tableViewItemParams.isDividerEnabled = _isDividerEnabled; + tableViewItemParams.pCheckBitmaps = _pCheckBitmaps; + tableViewItemParams.annexStyle = _annexStyle; + + item.__pCustomListItemImpl->itemId = itemId; + + result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[%s] A system error has occurred. Failed to create an item.", GetErrorMessage(r)); + + r = InsertIntoItemsList(item, -1, index - __topIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[%s] A system error has occurred. Failed to insert an item at index %d.", GetErrorMessage(r), (index)); + + if (__pCheckedList) + { + Boolean *pChecked = new (std::nothrow) Boolean(false); + SysTryReturn(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pCheckedList->InsertAt(*pChecked, index); + } + + if (GetCore().GetFirstDrawnFlag() == false) + { + r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, + "[%s] A system error has occurred. Failed to insert an item at index %d.", GetErrorMessage(r), index); + } + + __totalItemCount++; + + return r; + +CATCH: + RemoveFromItemsList(-1, index - __topIndex); + return E_SYSTEM; +} + +bool +_SlidableListImpl::IsItemChecked(int groupIndex, int subIndex) const +{ + return IsItemChecked(subIndex); +} + +bool +_SlidableListImpl::IsItemChecked(int index) const +{ + switch(_annexStyle) + { + case TABLE_VIEW_ANNEX_STYLE_MARK: + // fall through + case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING: + { + Boolean* pChecked = dynamic_cast(__pCheckedList->GetAt(index)); + SysTryReturn(NID_UI_CTRL, (pChecked != null), false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get boolean pointer at %d index.", index); + + return pChecked->ToBool(); + } + break; + + case TABLE_VIEW_ANNEX_STYLE_RADIO: + { + if (index == _currentRadioIndex) + { + return true; + } + else + { + return false; + } + } + break; + + case TABLE_VIEW_ANNEX_STYLE_NORMAL: + // fall through + default: + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. This list style does not support Checked items"); + SetLastResult(E_SYSTEM); + return false; + } +} + +bool +_SlidableListImpl::IsItemLoaded(int index) const +{ + if (_itemsList.GetCount() == 0) + { + return false; + } + else + { + int min = ((__totalItemCount > __itemCacheSize) ? __itemCacheSize : __totalItemCount); + return (index >= __topIndex && index < __topIndex + min) ? true : false; + } +} + +bool +_SlidableListImpl::IsLoadedItemEnabled(int index) const +{ + int itemIndex = -1; + int groupIndex = -1; + GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex); + int topDrawnItemIndex = itemIndex; + GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex); + int bottomDrawnItemIndex = itemIndex; + + if (index < __topIndex || index > __topIndex + _itemsList.GetCount()) + { + return false; + } + else + { + if ((index >= topDrawnItemIndex && index <= bottomDrawnItemIndex)) + { + return GetCore().IsItemEnabled(0, index); + } + else + { + return false; + } + } +} + +int +_SlidableListImpl::GetTopItemIndex(void) +{ + return __topIndex; +} + +result +_SlidableListImpl::LoadItemToBottom(const CustomListItem& item, int itemId) +{ + SysTryReturn(NID_UI_CTRL, __isCreating == true, E_SUCCESS, E_SUCCESS, "[E_SUCCESS] Not during creation. Can be ignored."); + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = (const_cast(&item)); + tableViewItemParams.width = GetCore().GetBounds().width; + tableViewItemParams.itemIndex = _itemsList.GetCount() + __topIndex; + tableViewItemParams.groupIndex = -1; + tableViewItemParams.isDividerEnabled = _isDividerEnabled; + tableViewItemParams.pCheckBitmaps = _pCheckBitmaps; + tableViewItemParams.annexStyle = _annexStyle; + + result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, + "[%s] A system error has occurred. Failed to create an item at index %d.", GetErrorMessage(r), (_itemsList.GetCount() + __topIndex)); + item.__pCustomListItemImpl->itemId = itemId; + + r = _itemsList.Add(item); +// r = InsertIntoItemsList(item, -1, _itemsList.GetCount()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, + "[%s] A system error has occurred. Failed to insert an item at index 0.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_SlidableListImpl::LoadItemToTop(const CustomListItem& item, int itemId) +{ + SysTryReturn(NID_UI_CTRL, __isCreating == true, E_SUCCESS, E_SUCCESS, "[E_SUCCESS] Not during creation. Can be ignored."); + + _TableViewItemParams tableViewItemParams; + tableViewItemParams.pItem = (const_cast(&item)); + tableViewItemParams.width = GetCore().GetBounds().width; + tableViewItemParams.itemIndex = (__topIndex - 1); + tableViewItemParams.groupIndex = -1; + tableViewItemParams.isDividerEnabled = _isDividerEnabled; + tableViewItemParams.pCheckBitmaps = _pCheckBitmaps; + tableViewItemParams.annexStyle = _annexStyle; + + result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, + "[%s] A system error has occurred. Failed to create an item at index %d.", GetErrorMessage(r), (__topIndex - 1)); + item.__pCustomListItemImpl->itemId = itemId; + +// r = InsertIntoItemsList(item, -1, 0); + r = _itemsList.InsertAt(item, 0); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, + "[%s] A system error has occurred. Failed to insert an item at index 0.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +_SlidableListImpl::SetItemCountAndHeight(int count, int listHeight) +{ + SysTryReturnVoidResult(NID_UI_CTRL, (count > 0 && listHeight > 0), E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Count (%d) and listHeight (%d) must be greater than 0.", + count, listHeight); + + __totalItemCount = count; + + if (__pCheckedList) + { + __pCheckedList->RemoveAll(true); + delete __pCheckedList; + __pCheckedList = null; + } + + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)//(IsCheckedStyle() == true) + { + __pCheckedList = new (std::nothrow) ArrayList(); + SysTryReturnVoidResult(NID_UI_CTRL, __pCheckedList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pCheckedList->Construct(count); + + Boolean* pChecked = null; + + for (int itemIndex = 0; itemIndex < count; itemIndex++) + { + pChecked = new (std::nothrow) Boolean(false); + SysTryCatch(NID_UI_CTRL, pChecked, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pCheckedList->Add(*pChecked); + } + } + + if (!(__pItemProvider && __pItemProvider->firstTime == true)) + { + _itemsList.RemoveAll(true); + + result r = GetCore().UpdateTableView(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + + return; + +CATCH: + if (__pCheckedList) + { + __pCheckedList->RemoveAll(true); + delete __pCheckedList; + __pCheckedList = null; + } + _itemsList.RemoveAll(true); +} + +int +_SlidableListImpl::GetLoadedItemIndexFromItemId(int itemId) const +{ + _TableViewItemData* pTableViewItemData = null; + CustomListItem* pCustomListItem = null; + + result r = E_SUCCESS; + int topItemIndex = -1; + int bottomItemIndex = -1; + int groupIndex = -1; + + r = GetCore().GetTopDrawnItemIndex(groupIndex, topItemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, r, + "[%s] Propagating. Failed to get the index of top item", GetErrorMessage(r)); + r = GetCore().GetBottomDrawnItemIndex(groupIndex, bottomItemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, r, + "[%s]Propagating. Failed to get the index of bottom item", GetErrorMessage(r)); + + for (int index = 0; index < _itemsList.GetCount(); index++) + { + pCustomListItem = dynamic_cast(const_cast(_itemsList.GetAt(index))); + SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", index); + + SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, INVALID_INDEX, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Item instance must not be null."); + + pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData; + SysTryReturn(NID_UI_CTRL, pTableViewItemData, INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. ItemData must not be null."); + + if ((pTableViewItemData != null) && (pCustomListItem->__pCustomListItemImpl->itemId == itemId)) + { + SetLastResult(E_SUCCESS); + + if ((index + __topIndex >= topItemIndex) && (index + __topIndex <= bottomItemIndex)) + { + return index + __topIndex; + } + } + } + + SetLastResult(E_SUCCESS); + return INVALID_INDEX; +} + +result +_SlidableListImpl::UnloadAllItems(void) +{ + SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. SlidableListener not set."); + + result r = E_SUCCESS; + + for (int itemIndex = _itemsList.GetCount() - 1; itemIndex >= 0; itemIndex--) + { + r = RemoveFromItemsList(-1, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[%s] A system error has occurred. Failed to remove item at index %d", GetErrorMessage(r), itemIndex); + + r = GetCore().RefreshTableView(0, itemIndex + __topIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[%s] A system error has occurred. Failed to remove item at index %d", GetErrorMessage(r), (itemIndex + __topIndex)); + + + if (__pCheckedList) + { + r = __pCheckedList->RemoveAt(itemIndex + __topIndex, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[%s] A system error has occurred. Failed to remove Check item at index %d", GetErrorMessage(r), (itemIndex + __topIndex)); + } + + CallUnloadItemCb(itemIndex + __topIndex); + } + + return E_SUCCESS; +} + +result +_SlidableListImpl::RefreshItem(int index) +{ + SysTryReturnResult(NID_UI_CTRL, (index >= __topIndex && index <= (__topIndex + _itemsList.GetCount())), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than or equal to (%d).", + index, (__topIndex + _itemsList.GetCount())); + + result r = E_SUCCESS; + + int topItemIndex = -1; + int bottomItemIndex = -1; + int groupIndex = -1; + + r = GetCore().GetTopDrawnItemIndex(groupIndex, topItemIndex); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, + "[%s] A system error has occurred. Failed to get the index of top item", GetErrorMessage(r)); + + r = GetCore().GetBottomDrawnItemIndex(groupIndex, bottomItemIndex); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, + "[%s] A system error has occurred. Failed to get the index of bottom item", GetErrorMessage(r)); + + SysTryReturnResult(NID_UI_CTRL, (index >= topItemIndex && index <= bottomItemIndex), E_OUT_OF_RANGE, + "Index %d must be greater than or equal to top index %d and less than or equal to bottom index %d", + index, topItemIndex, bottomItemIndex); + + CustomListItem* pCustomListItem = dynamic_cast(_itemsList.GetAt(index - __topIndex)); + SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", (index - __topIndex)); + + SysTryReturnResult(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Item instance must not be null."); + + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = pCustomListItem; + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item."); + + _TableViewItemData* pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData; + SysTryReturnResult(NID_UI_CTRL, (pTableViewItemData != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. ItemData must not be null."); + + pTableViewItemData->Invalidate(true); + return E_SUCCESS; +} + +result +_SlidableListImpl::RemoveAllCheckedItems(int itemHeight) +{ + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL."); + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_RADIO."); + + SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. SlidableListener not set."); + + result r = E_SUCCESS; + int itemIndex = 0; + Boolean* pChecked = null; + + for (itemIndex = _itemsList.GetCount() + __topIndex; itemIndex < __totalItemCount; itemIndex++) + { + pChecked = dynamic_cast(__pCheckedList->GetAt(itemIndex)); + if ((pChecked != null) && pChecked->ToBool() == true) + { + __pCheckedList->RemoveAt(itemIndex, true); + __totalItemCount--; + } + } + + for (itemIndex = 0; itemIndex < __topIndex; itemIndex++) + { + pChecked = dynamic_cast(__pCheckedList->GetAt(itemIndex)); + if ((pChecked != null) && pChecked->ToBool() == true) + { + __pCheckedList->RemoveAt(itemIndex, true); + __totalItemCount--; + } + } + + for (itemIndex = 0; itemIndex < _itemsList.GetCount(); itemIndex++) + { + if (IsItemChecked(itemIndex) == true) + { + r = RemoveFromItemsList(-1, itemIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove an item."); + + __pCheckedList->RemoveAt(itemIndex, true); + + r = GetCore().RefreshTableView(0, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + + if (r != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "[%s] Failed to remove item at index %d.", GetErrorMessage(r), itemIndex); + } + + CallUnloadItemCb(itemIndex); + itemIndex--; + __totalItemCount--; + } + } + + return r; +} + +result +_SlidableListImpl::RemoveAllItems(void) +{ + __totalItemCount = 0; + _itemsList.RemoveAll(true); + + GetCore().UpdateTableView(); + + if(__pCheckedList) + { + __pCheckedList->RemoveAll(true); + } + + return E_SUCCESS; +} + +void +_SlidableListImpl::RemoveCustomItemEventListener(const ICustomItemEventListener& listener) +{ + _ListListener* pListenerList = null; + + for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++) + { + pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + + if ((pListenerList != null) && (pListenerList->pListener == &listener)) + { + __itemListenersList.RemoveAt(listenerCount, true); + break; + } + } +} + +result +_SlidableListImpl::RemoveItemAt(int index, int itemHeight) +{ + result r = E_SUCCESS; + + if (!(index >= __topIndex && index < __topIndex + _itemsList.GetCount())) + { + if (index >= 0 && index < __totalItemCount) + { + return E_SUCCESS; + } + else + { + return E_SYSTEM; + } + } + + r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[%s] A system error has occurred. Failed to remove item at %d", GetErrorMessage(r), index); + + r = RemoveFromItemsList(-1, (index - __topIndex)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to remove an item."); + + if (__pCheckedList) + { + __pCheckedList->RemoveAt(index, true); + } + + + __totalItemCount--; + CallUnloadItemCb(index); + + return E_SUCCESS; +} + +void +_SlidableListImpl::ScrollToBottom(void) +{ + __isDirectDelete = true; + + result r = E_SUCCESS; + + r = GetCore().SetBottomDrawnItemIndex(0, __totalItemCount - 1); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + __isDirectDelete = false; +} + +result +_SlidableListImpl::ScrollToTop(int index) +{ + SysTryReturn(NID_UI_CTRL, (index >= 0 && index < __totalItemCount), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, __totalItemCount); + + result r = E_SUCCESS; + + __isDirectDelete = true; + + r = GetCore().SetTopDrawnItemIndex(0, index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + __isDirectDelete = false; + + return E_SUCCESS; +} + +void +_SlidableListImpl::ScrollToTop(void) +{ + result r = E_SUCCESS; + + __isDirectDelete = true; + + r = GetCore().SetTopDrawnItemIndex(0, 0); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().Draw(); + + __isDirectDelete = false; +} + +result +_SlidableListImpl::SetAllItemsChecked(bool check) +{ + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_RADIO"); + + CustomListItem* pCustomListItem = null; + _TableViewItemData* pTableViewItemData = null; + _CheckElementModel* pCheckElement = null; + + Boolean* pChecked = null; + int itemIndex = 0; + + for (itemIndex = 0; itemIndex < __totalItemCount; itemIndex++) + { + pChecked = new (std::nothrow) Boolean(check); + SysTryReturn(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pCheckedList->SetAt(*pChecked, itemIndex, true); + } + + for (int index = 0; index < _itemsList.GetCount(); index++) + { + pCustomListItem = dynamic_cast(_itemsList.GetAt(index)); + SysTryCatch(NID_UI_CTRL, pCustomListItem, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index %d.", index); + + SysTryCatch(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item instance must not be null"); + + pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData; + SysTryCatch(NID_UI_CTRL, pTableViewItemData != null, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. ItemData must not be null."); + + pCheckElement = pCustomListItem->__pCustomListItemImpl->GetCheckElement(); + SysTryCatch(NID_UI_CTRL, (pCheckElement != null), , E_SYSTEM, "[E_SYSTEM] A system error has occurred. CheckElement instance must not be null"); + + if (check) + { + pCheckElement->SetCheckBoxStatus(CHECK_BOX_CHECKED); + } + else + { + pCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED); + } + } + + return E_SUCCESS; +CATCH: + delete pChecked; + + return E_SYSTEM; +} + +result +_SlidableListImpl::SetItemAt(int index, const CustomListItem& item, int itemId) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (index >= __topIndex && index <= (__topIndex + _itemsList.GetCount())), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than or equal to (%d).", + index, (__topIndex + _itemsList.GetCount())); + + SysTryReturnResult(NID_UI_CTRL, (IsItemNew(item) == true), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The item already exists."); + + _CheckElementModel* pCheckElement = null; + _CheckElementModel* pOldCheckElement = GetCheckElementAt(-1, index - __topIndex); + _CheckBoxStatus oldCheckStatus = (pOldCheckElement) ? (pOldCheckElement->GetCheckBoxStatus()) : CHECK_BOX_UNCHECKED; + + item.__pCustomListItemImpl->itemId = itemId; + item.__pCustomListItemImpl->__pTableViewItemData = GetTableViewItemAt(-1, index - __topIndex); + + r = _itemsList.SetAt(item, index, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to set an item at index %d.", index); + + _TableViewItemUpdateParams updateParams; + updateParams.pItem = (const_cast(&item));; + updateParams.isDividerEnabled = _isDividerEnabled; + updateParams.pCheckBitmaps = _pCheckBitmaps; + updateParams.annexStyle = _annexStyle; + + r = _CustomListItemImpl::UpdateTableViewItem(updateParams); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, + "[%s] A system error has occurred. Failed to update an item.", GetErrorMessage(r)); + + if (GetCore().GetFirstDrawnFlag() == false) + { + r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + + pCheckElement = item.__pCustomListItemImpl->GetCheckElement(); + + if (pCheckElement) + { + pCheckElement->SetCheckBoxStatus(oldCheckStatus); + } + + return r; +} + +result +_SlidableListImpl::SetItemChecked(int groupindex, int index, bool check) +{ + return SetItemChecked(index, check); +} + +result +_SlidableListImpl::SetItemChecked(int index, bool check) +{ + SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL"); + + SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < __totalItemCount), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, __totalItemCount); + + if (IsItemChecked(index) == check) + { + return E_SUCCESS; + } + + _CheckElementModel* pCheckElementModel = GetCheckElementAt(-1, index - __topIndex); + SysTryReturnResult(NID_UI_CTRL, pCheckElementModel, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. CheckElement instance must not be null."); + + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + { + if (_currentRadioIndex != -1) + { + _CheckElementModel* pOldCheckElement = GetCheckElementAt(-1, _currentRadioIndex - __topIndex); + SysTryReturnResult(NID_UI_CTRL, pOldCheckElement, E_SYSTEM, "[E_SYSTEM] A system error has occurred. CheckElement instance must not be null."); + + pOldCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED); + DrawItem(-1, _currentRadioIndex); + + _currentRadioIndex = index; + } + else + { + _currentRadioIndex = -1; + } + + if (check) + { + pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_CHECKED); + _currentRadioIndex = index; + } + else + { + pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_UNCHECKED); + _currentRadioIndex = -1; + } + } + else + { + Boolean* pChecked = new (std::nothrow) Boolean(check); + SysTryReturnResult(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pCheckedList->SetAt(*pChecked, index, true); + + pCheckElementModel->SetCheckBoxStatus((_CheckBoxBitmapType)check); + } + + DrawItem(-1, index); + + return E_SUCCESS; +} + +result +_SlidableListImpl::SetLoadedItemEnabled(int index, bool enable) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, (index >= __topIndex && index < _itemsList.GetCount() + __topIndex), + E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", + index, _itemsList.GetCount()); + + CustomListItem* pCustomListItem = dynamic_cast(_itemsList.GetAt(index - __topIndex)); + SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at %d index.", index); + + _CustomListItemImpl* pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl; + SysTryReturnResult(NID_UI_CTRL, pCustomListItemImpl, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item instance must not be null."); + + _TableViewItemData* pTableViewItemData = pCustomListItemImpl->__pTableViewItemData; + SysTryReturnResult(NID_UI_CTRL, pTableViewItemData, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at %d index.", index); + + _CheckElementModel* pCheckElementModel = pCustomListItem->__pCustomListItemImpl->GetCheckElement(); + SysTryReturnResult(NID_UI_CTRL, pCheckElementModel, E_SYSTEM, "[E_SYSTEM] A system error has occurred. CheckElement instance must not be null."); + + if (pCheckElementModel) + { + if (enable) + { + if (pCheckElementModel->GetCheckBoxStatus() == CHECK_BOX_DISABLED) + { + pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_CHECKED); + } + } + else + { + if (pCheckElementModel->GetCheckBoxStatus() == CHECK_BOX_CHECKED) + { + if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) + { + pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_DISABLED); + } + } + } + } + + r = GetCore().SetItemEnabled(0, index, enable); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Failed to set an item enabled at index %d.", GetErrorMessage(r), index); + + pTableViewItemData->Invalidate(true); + + return r; +} + +void +_SlidableListImpl::SetTextColorOfEmptyList(const Color& color) +{ + result r = GetCore().SetTextColorOfEmptyTableView(color); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_SlidableListImpl::SetTextOfEmptyList(const String& text) +{ + result r = GetCore().SetTextOfEmptyTableView(text); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +_SlidableListImpl::Initalize(void) +{ + result r = E_SUCCESS; + + r = GetCore().AddTableViewItemEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add item event listener.", GetErrorMessage(r)); + + __totalItemCount = 0; + __topIndex = 0; + + __itemCacheSize = GetCore().GetMaxItemCachingSize(); + + return E_SUCCESS; +} + +void +_SlidableListImpl::CallUnloadItemCb(int index) +{ + _ListListener* pListenerData = null; + ISlidableListEventListener* pSlidableListener = null; + + for (int listenerCount = 0; listenerCount < __slidableListenersList.GetCount(); listenerCount++) + { + pListenerData = dynamic_cast<_ListListener*>(__slidableListenersList.GetAt(listenerCount)); + + if (pListenerData) + { + pSlidableListener = dynamic_cast(pListenerData->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pSlidableListener != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get EventListener"); + pSlidableListener->OnUnloadItemRequested(GetPublic(), index); + } + } + + return; +} + +bool +_SlidableListImpl::IsCheckedStyle(void) +{ + if (((_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || _annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO))) + { + return true; + } + else + { + return false; + } +} + +const bool +_SlidableListImpl::IsCheckedStyle(void) const +{ + if (((_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || _annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO))) + { + return true; + } + else + { + return false; + } +} +void +_SlidableListImpl::OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* itemTag, Tizen::Ui::Controls::TableViewItemStatus status) +{ + CustomListItem* pCustomListItem = dynamic_cast(_itemsList.GetAt(itemIndex - __topIndex)); + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get an item at %d index.", (itemIndex - __topIndex)); + + SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item instance must not be null"); + + _TableViewItemData* pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData; + SysTryReturnVoidResult(NID_UI_CTRL, (pTableViewItemData != null), E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get an item at %d index.", (itemIndex - __topIndex)); + + ItemStatus itemStatus = ITEM_HIGHLIGHTED; + + switch (status) + { + case TABLE_VIEW_ITEM_STATUS_SELECTED: + itemStatus = ITEM_SELECTED; + break; + case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED: + itemStatus = ITEM_HIGHLIGHTED; + break; + case TABLE_VIEW_ITEM_STATUS_CHECKED: + itemStatus = ITEM_CHECKED; + break; + case TABLE_VIEW_ITEM_STATUS_UNCHECKED: + itemStatus = ITEM_UNCHECKED; + break; + default: + SetLastResult(E_SYSTEM); + break; + } + + if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL)) + { + bool isChecked = IsItemChecked(itemIndex + __topIndex); + + if (isChecked) + { + itemStatus = ITEM_UNCHECKED; + } + else + { + itemStatus = ITEM_CHECKED; + } + + SetItemChecked(itemIndex, !isChecked); + } + + ProcessItemStateChange(0, itemIndex, itemStatus); + return; +} + +void +_SlidableListImpl::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_SlidableListImpl::OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo) +{ + return; +} + +void +_SlidableListImpl::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) +{ + return; +} + +void +_SlidableListImpl::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) +{ + return; +} + +void +_SlidableListImpl::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_SlidableListImpl::OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo) +{ + return; +} + +void +_SlidableListImpl::OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) +{ + return; +} + +void +_SlidableListImpl::OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) +{ + return; +} + +void +_SlidableListImpl::OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction) +{ + return; +} + +void +_SlidableListImpl::ProcessItemStateChange(int groupIndex, int index, int elementId, ItemStatus itemStatus) +{ + int itemId = GetLoadedItemIdAt(index); + _ListListener* pListenerList = null; + ICustomItemEventListener* pEventListener = null; + + int count = __itemListenersList.GetCount(); + for (int listenerCount = 0; listenerCount < count; listenerCount++) + { + pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Listener instance is not available."); + + pEventListener = dynamic_cast(pListenerList->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Listener instance is not available."); + + pEventListener->OnItemStateChanged(GetPublic(), index, itemId, elementId, itemStatus); + } + SetLastResult(E_SUCCESS); +} + +void +_SlidableListImpl::ProcessItemStateChange(int groupIndex, int index, ItemStatus itemStatus) +{ + int itemId = GetLoadedItemIdAt(index); + _ListListener* pListenerList = null; + ICustomItemEventListener* pEventListener = null; + + int count = __itemListenersList.GetCount(); + for (int listenerCount = 0; listenerCount < count; listenerCount++) + { + pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount)); + SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "Failed to get Listener."); + + pEventListener = dynamic_cast(pListenerList->pListener); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "Failed to get Listener."); + + pEventListener->OnItemStateChanged(GetPublic(), index, itemId, itemStatus); + } + SetLastResult(E_SUCCESS); +} + +result +_SlidableListImpl::CreateItemProvider(void) +{ + if (__pItemProvider == null) + { + __pItemProvider = new (std::nothrow) _SlidableListItemProvider(this); + SysTryReturnResult(NID_UI_CTRL, __pItemProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryCatch(NID_UI_CTRL, style == TABLE_VIEW_STYLE_SIMPLE, , E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The current list cannot support the given style."); + + result r = E_SUCCESS; + + _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pItemProvider != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pItemProvider->SetSimpleStyleItemProvider(__pItemProvider); + + GetCore().SetItemProvider(pItemProvider); + } + + return E_SUCCESS; + +CATCH: + if (__pItemProvider) + { + delete __pItemProvider; + __pItemProvider = null; + } + + return E_SYSTEM; +} + +void +_SlidableListImpl::OnDraw(void) +{ + if (__pItemProvider == null) + { + __pItemProvider = new (std::nothrow) _SlidableListItemProvider(this); + SysTryReturnVoidResult(NID_UI_CTRL, __pItemProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryCatch(NID_UI_CTRL, style == TABLE_VIEW_STYLE_SIMPLE, , E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The current list cannot support the given style."); + + _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style); + result r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pItemProvider != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pItemProvider->SetSimpleStyleItemProvider(__pItemProvider); + + GetCore().SetItemProvider(pItemProvider); + } + + _ListBaseImpl::OnDraw(); + return; + +CATCH: + if (__pItemProvider) + { + delete __pItemProvider; + __pItemProvider = null; + } +} + +class _SlidableListMaker + : public _UiBuilderControlMaker +{ +public: + _SlidableListMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_SlidableListMaker(){}; + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _SlidableListMaker* pSlidableListMaker = new (std::nothrow) _SlidableListMaker(uibuilder); + return pSlidableListMaker; + }; +protected: + virtual Tizen::Ui::Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + SlidableList* pSlidableList = null; + Tizen::Graphics::Rectangle rect; + Tizen::Graphics::Rectangle rectMin; + Dimension dimMin; + + Tizen::Ui::Controls::CustomListStyle style = CUSTOM_LIST_STYLE_NORMAL; + Tizen::Base::String elementString; + bool isItemDivider = true; + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pSlidableList = new (std::nothrow) SlidableList(); + if (pSlidableList == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + + Tizen::Base::String styleString; + styleString = pControlProperty->GetStyle(); + + + if (styleString.Equals(L"CUSTOM_LIST_STYLE_NORMAL", false)) + { + style = CUSTOM_LIST_STYLE_NORMAL; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO", false)) + { + style = CUSTOM_LIST_STYLE_RADIO; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK", false)) + { + style = CUSTOM_LIST_STYLE_MARK; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF", false)) + { + style = CUSTOM_LIST_STYLE_ONOFF; + } + else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER", false)) + { + style = CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER; + } + else + { + style = CUSTOM_LIST_STYLE_NORMAL; + } + + //Construct + if (pControl->GetElement("itemDivider", elementString)) + { + if (elementString.Equals(L"true", false)) + { + isItemDivider = true; + } + else + { + isItemDivider = false; + } + } + + r = pSlidableList->Construct(rect, style, isItemDivider); + if (r != E_SUCCESS) + { + delete pSlidableList; + return null; + } + + if (pControl->GetElement("textOfEmptyList", elementString)) + { + pSlidableList->SetTextOfEmptyList(elementString); + } + + if (pControl->GetElement("colorOfEmptyListText", elementString)) + { + ConvertStringToColor(elementString, color); + pSlidableList->SetTextColorOfEmptyList(color); + } + + GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_PORTRAIT, dimMin); + rectMin = (pControl->GetAttribute(0))->GetRect(); + (pControl->GetAttribute(0))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height); + + GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_LANDSCAPE, dimMin); + rectMin = (pControl->GetAttribute(1))->GetRect(); + (pControl->GetAttribute(1))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height); + + return pSlidableList; + } + +private: +}; + + +_SlidableListRegister::_SlidableListRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + + if (pUiBuilderControlTableManager) + { + pUiBuilderControlTableManager->RegisterControl(L"SlidableList", _SlidableListMaker::GetInstance); + } +} +_SlidableListRegister::~_SlidableListRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + + if (pUiBuilderControlTableManager) + { + pUiBuilderControlTableManager->UnregisterControl(L"SlidableList"); + } +} +static _SlidableListRegister SlidableListRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Slider.cpp b/src/ui/controls/FUiCtrl_Slider.cpp new file mode 100644 index 0000000..d2bb97c --- /dev/null +++ b/src/ui/controls/FUiCtrl_Slider.cpp @@ -0,0 +1,830 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Slider.cpp + * @brief This is the implementation file for the _Slider class. + */ + +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_Slider.h" +#include "FUiCtrl_SliderPresenter.h" +#include "FUiCtrl_IAdjustmentEventListener.h" +#include "FUiCtrl_ISliderEventListener.h" + +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ +IMPLEMENT_PROPERTY(_Slider); + +_Slider::_Slider(void) + : __pSliderPresenter(null) + , __pAdjustmentEvent(null) + , __pSliderEvent(null) + , __titleText() + , __pLeftBitmap(null) + , __pRightBitmap(null) + , __bgColor() + , __barColor() + , __titleTextColor() + , __sliderStyle(_SLIDER_STYLE_OVERLAY) + , __pBase(null) + , __pHandle(null) + , __pAccessibilityElement(null) +{ + __pBase = GetVisualElement(); + + if (__pBase != null) + { + __pBase->SetSurfaceOpaque(false); + __pBase->SetClipChildrenEnabled(false); + } + + if (likely((_AccessibilityManager::IsActivated()))) + { + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer) + { + pContainer->Activate(true); + } + } +} + +_Slider::~_Slider(void) +{ + if (__pAdjustmentEvent != null) + { + delete __pAdjustmentEvent; + __pAdjustmentEvent = null; + } + + if (__pSliderEvent != null) + { + delete __pSliderEvent; + __pSliderEvent = null; + } + + delete __pLeftBitmap; + __pLeftBitmap = null; + + delete __pRightBitmap; + __pRightBitmap = null; + + delete __pSliderPresenter; + __pSliderPresenter = null; + + if (__pAccessibilityElement) + { + __pAccessibilityElement->Activate(false); + __pAccessibilityElement = null; + } + + if (__pBase != null && __pHandle != null) + { + __pBase->DetachChild(*__pHandle); + __pHandle->Destroy(); + } + + __pHandle = null; + __pBase = null; +} + +_Slider* +_Slider::CreateSliderN(void) +{ + result r = E_SUCCESS; + + _Slider* pSlider = new (std::nothrow) _Slider; + SysTryReturn(NID_UI_CTRL, pSlider, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pSlider->__pSliderPresenter = _SliderPresenter::CreateInstanceN(*pSlider); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pSlider->__pSliderPresenter != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pSlider->Initialize(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pSlider->AcquireHandle(); + + return pSlider; + +CATCH: + delete pSlider; + pSlider = null; + + return null; +} + +result +_Slider::Initialize(void) +{ + result r = E_SUCCESS; + + Rectangle handleRect(0, 0, 0, 0); + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + r = GET_COLOR_CONFIG(SLIDER::BG_DEFAULT_NORMAL, __bgColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::BAR_NORMAL, __barColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::TITLE_TEXT_NORMAL, __titleTextColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::HANDLE_WIDTH, orientation, handleRect.width); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::HANDLE_HEIGHT, orientation, handleRect.height); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHandle = new (std::nothrow) Tizen::Ui::Animations::_VisualElement; + SysTryReturn(NID_UI_CTRL, __pHandle != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pHandle->Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHandle->SetBounds(FloatRectangle(handleRect.x, handleRect.y, handleRect.width, handleRect.height)); + + __pHandle->SetShowState(true); + + __pBase->SetClipChildrenEnabled(true); + __pHandle->SetClipToParent(true); + + + r = __pHandle->SetSurfaceOpaque(false); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHandle->SetImplicitAnimationEnabled(false); + + r = __pBase->AttachChild(*__pHandle); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pAdjustmentEvent = _AdjustmentEvent::CreateInstanceN(*this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pAdjustmentEvent, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSliderEvent = _SliderEvent::CreateInstanceN(*this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pSliderEvent, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_Slider::InitializeAccessibilityElement(void) +{ + result r = E_SUCCESS; + + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return r; + } + + if (__pAccessibilityElement) + { + return r; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer) + { + __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturn(NID_UI_CTRL, __pAccessibilityElement, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + __pAccessibilityElement->SetBounds(Rectangle(0, 0, GetBounds().width, GetBounds().height)); + __pAccessibilityElement->SetLabel(__titleText); + __pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_SLIDER); + __pAccessibilityElement->SetHint(L"double tap and drag to adjust"); + SetAccessibilityElementValue(); + r = pContainer->AddElement(*__pAccessibilityElement); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pContainer->AddListener(*this); + } + + return r; +} + +void +_Slider::OnDraw(void) +{ + __pSliderPresenter->Draw(); + return; +} + +result +_Slider::OnAttachedToMainTree(void) +{ + InitializeAccessibilityElement(); + return E_SUCCESS; +} + +void +_Slider::SetStyle(int style) +{ + __sliderStyle = style; + return; +} + +int +_Slider::GetStyle(void) const +{ + return __sliderStyle; +} + +Canvas* +_Slider::GetHandleCanvasN(void) const +{ + return __pHandle->GetCanvasN(); +} + +_VisualElement* +_Slider::GetHandle(void) const +{ + return __pHandle; +} + +void +_Slider::SetGroupStyle(GroupStyle groupStyle) +{ + __pSliderPresenter->SetGroupStyle(groupStyle); + return; +} + +result +_Slider::UpdateHandle(const Rectangle& handleRect) +{ + __pHandle->SetBounds(FloatRectangle(handleRect.x, handleRect.y, handleRect.width, handleRect.height)); + + return __pHandle->SetFlushNeeded(); +} + +bool +_Slider::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pSliderPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_Slider::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pSliderPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_Slider::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pSliderPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_Slider::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pSliderPresenter->OnTouchCanceled(source, touchinfo); +} + +void +_Slider::OnBoundsChanged(void) +{ + __pSliderPresenter->OnBoundsChanged(); + + if (__pAccessibilityElement) + { + __pAccessibilityElement->SetBounds(Rectangle(0, 0, GetBounds().width, GetBounds().height)); + } + + return; +} + +result +_Slider::SetRange(int minValue, int maxValue) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (minValue >= _SLIDER_MINIMUM_VALUE && maxValue >= _SLIDER_MINIMUM_VALUE), + E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The minimum value %d is out of range [-99 to 999].", minValue); + SysTryReturn(NID_UI_CTRL, (minValue <= _SLIDER_MAXIMUM_VALUE && maxValue <= _SLIDER_MAXIMUM_VALUE), + E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The maximum value %d is out of range [-99 to 999].", maxValue); + SysTryReturn(NID_UI_CTRL, (minValue < maxValue), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] The minimum value is greater than maximum value."); + + Variant oldMinValue = GetProperty("minValue"); + Variant value = GetProperty("value"); + + r = SetProperty("minValue", Variant(minValue)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to set minimum value.", GetErrorMessage(r)); + + r = SetProperty("maxValue", Variant(maxValue)); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_CTRL, r, "[%s] Failed to set maximum value.", GetErrorMessage(r)); + + result nestedResult = SetPropertyMinValue(oldMinValue); + if (nestedResult != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Failed to recover original minimum value"); + return r; + } + + nestedResult = SetPropertyValue(value); + if (nestedResult != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Failed to recover original value"); + } + } + + SetAccessibilityElementValue(); + + return r; +} + +result +_Slider::SetPropertyMinValue(const Variant& minValue) +{ + result r = E_SUCCESS; + + int tempMinValue = minValue.ToInt(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSliderPresenter->SetMinValue(tempMinValue); + + return r; +} + +result +_Slider::SetPropertyMaxValue(const Variant& maxValue) +{ + result r = E_SUCCESS; + + int tempMaxValue = maxValue.ToInt(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSliderPresenter->SetMaxValue(tempMaxValue); + + return r; +} + +result +_Slider::GetRange(int& minValue, int& maxValue) const +{ + result r = E_SUCCESS; + + Variant minimum = GetProperty("minValue"); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Variant maximum = GetProperty("maxValue"); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + minValue = minimum.ToInt(); + maxValue = maximum.ToInt(); + + return r; +} + +Variant +_Slider::GetPropertyMinValue(void) const +{ + return Variant(__pSliderPresenter->GetMinValue()); +} + +Variant +_Slider::GetPropertyMaxValue(void) const +{ + return Variant(__pSliderPresenter->GetMaxValue()); +} + +result +_Slider::SetValue(int value) +{ + return SetProperty("value", Variant(value)); +} + +result +_Slider::SetPropertyValue(const Variant& value) +{ + result r = E_SUCCESS; + + int tempValue = value.ToInt(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSliderPresenter->SetValue(tempValue); + + SetAccessibilityElementValue(); + + return r; +} + +void +_Slider::SetAccessibilityElementValue() +{ + if (__pAccessibilityElement) + { + String string; + string.Append(__pSliderPresenter->GetValue()); + string.Append(L" of "); + string.Append(__pSliderPresenter->GetMaxValue()); + __pAccessibilityElement->SetValue(string); + } + + return; +} +int +_Slider::GetValue(void) const +{ + result r = E_SUCCESS; + + Variant value = GetProperty("value"); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + return value.ToInt(); +} + +Variant +_Slider::GetPropertyValue(void) const +{ + return Variant(__pSliderPresenter->GetValue()); +} + +result +_Slider::SetIcon(IconPosition position, const Bitmap& icon) +{ + result r = E_SUCCESS; + + int iconWidth = 0; + int iconHeight = 0; + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + Bitmap* pNewBitmap = null; + + r = GET_SHAPE_CONFIG(SLIDER::ICON_WIDTH, orientation, iconWidth); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::ICON_HEIGHT, orientation, iconHeight); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (position == ICON_POSITION_LEFT) + { + pNewBitmap = _BitmapImpl::CloneN(icon); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pNewBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pNewBitmap->Scale(Dimension(iconWidth, iconHeight)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pLeftBitmap; + __pLeftBitmap = pNewBitmap; + + } + else //(position == ICON_POSITION_RIGHT) + { + pNewBitmap = _BitmapImpl::CloneN(icon); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pNewBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pNewBitmap->Scale(Dimension(iconWidth, iconHeight)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pRightBitmap; + __pRightBitmap = pNewBitmap; + + } + + __pSliderPresenter->SetNeedUpdate(); + + return E_SUCCESS; +CATCH: + delete pNewBitmap; + pNewBitmap = null; + + return E_SYSTEM; +} + +Bitmap* +_Slider::GetIcon(IconPosition position) const +{ + if (position == ICON_POSITION_LEFT) + { + return __pLeftBitmap; + } + else //(position == ICON_POSITION_RIGHT) + { + return __pRightBitmap; + } +} + +result +_Slider::SetTitleText(const String& title) +{ + return SetProperty("titleText", Variant(title)); +} + +result +_Slider::SetPropertyTitleText(const Variant& titleText) +{ + result r = E_SUCCESS; + String title = titleText.ToString(); + + int titleTextLengthMax = 0; + r = GET_FIXED_VALUE_CONFIG(SLIDER::TITLE_TEXT_LENGTH_MAX, _ControlManager::GetInstance()->GetOrientation(), titleTextLengthMax); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (!(GetStyle() & _SLIDER_STYLE_TITLE_TEXT)) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The current Slider style does not support title text."); + return E_SYSTEM; + } + + if (title.GetLength() > titleTextLengthMax) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The title text length is too long."); + return E_SYSTEM; + } + + __titleText = title; + + __pSliderPresenter->SetNeedUpdate(); + + r = InitializeAccessibilityElement(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pAccessibilityElement != null) + { + __pAccessibilityElement->SetLabel(__titleText); + } + + return r; +} + +String +_Slider::GetTitleText(void) const +{ + result r = E_SUCCESS; + + Variant titleText = GetProperty("titleText"); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, String(), r, "[%s] Propagating.", GetErrorMessage(r)); + + return titleText.ToString(); +} + +Variant +_Slider::GetPropertyTitleText(void) const +{ + return Variant(__titleText); +} + +result +_Slider::SetTitleTextColor(const Color& color) +{ + return SetProperty("titleTextColor", Variant(color)); +} + +result +_Slider::SetPropertyTitleTextColor(const Variant& titleTextColor) +{ + result r = E_SUCCESS; + + Color tempColor = titleTextColor.ToColor(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __titleTextColor = tempColor; + __pSliderPresenter->SetNeedUpdate(); + + return r; +} + +Color +_Slider::GetTitleTextColor(void) const +{ + result r = E_SUCCESS; + + Variant titleTexColor = GetProperty("titleTextColor"); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r)); + + return titleTexColor.ToColor(); +} + +Variant +_Slider::GetPropertyTitleTextColor(void) const +{ + return Variant(__titleTextColor); +} + +result +_Slider::AddAdjustmentEventListener(const _IAdjustmentEventListener& listener) +{ + return __pAdjustmentEvent->AddListener(listener); +} + +result +_Slider::RemoveAdjustmentEventListener(const _IAdjustmentEventListener& listener) +{ + return __pAdjustmentEvent->RemoveListener(listener); +} + +result +_Slider::AddSliderEventListener(const _ISliderEventListener& listener) +{ + return __pSliderEvent->AddListener(listener); +} + +result +_Slider::RemoveSliderEventListener(const _ISliderEventListener& listener) +{ + return __pSliderEvent->RemoveListener(listener); +} + +result +_Slider::SetBarColor(const Color& color) +{ + return SetProperty("barColor", Variant(color)); +} + +result +_Slider::SetPropertyBarColor(const Variant& barColor) +{ + result r = E_SUCCESS; + + Color tempBarColor = barColor.ToColor(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __barColor = tempBarColor; + + __pSliderPresenter->SetNeedUpdate(); + + return r; +} + +Color +_Slider::GetBarColor(void) const +{ + result r = E_SUCCESS; + + Variant barColor = GetProperty("barColor"); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r)); + + return barColor.ToColor(); +} + +Variant +_Slider::GetPropertyBarColor(void) const +{ + return Variant(__barColor); +} + +result +_Slider::SetColor(const Color& color) +{ + return SetProperty("color", Variant(color)); +} + +result +_Slider::SetPropertyColor(const Variant& color) +{ + if (__sliderStyle & _SLIDER_STYLE_NO_BG) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current Slider style does not support background color."); + return E_INVALID_OPERATION; + } + + result r = E_SUCCESS; + + Color tempBgColor = color.ToColor(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __bgColor = tempBgColor; + + __pSliderPresenter->SetNeedUpdate(); + + return r; +} + +Color +_Slider::GetColor(void) const +{ + result r = E_SUCCESS; + + Variant color = GetProperty("color"); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r)); + + return color.ToColor(); +} + +Variant +_Slider::GetPropertyColor(void) const +{ + if (__sliderStyle & _SLIDER_STYLE_NO_BG) + { + SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current Slider style does not support background color."); + return Variant(Color()); + } + else + { + return Variant(__bgColor); + } +} + +Tizen::Base::Runtime::_Event* +_Slider::GetAdjustmentEvent(void) const +{ + return __pAdjustmentEvent; +} + +_SliderEvent* +_Slider::GetSliderEvent(void) const +{ + return __pSliderEvent; +} + +result +_Slider::SetThumbBitmap(SliderThumbStatus status, const Bitmap& bitmap) +{ + return __pSliderPresenter->SetThumbBitmap(status, bitmap); +} + +void +_Slider::SetThumbTextColor(SliderThumbStatus status, const Color& color) +{ + __pSliderPresenter->SetThumbTextColor(status, color); + return; +} + +void +_Slider::OnFontChanged(Font* pFont) +{ + __pSliderPresenter->OnFontChanged(pFont); + return; +} + +void +_Slider::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pSliderPresenter->OnFontInfoRequested(style, size); + return; +} + +bool +_Slider::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + SetValue(GetValue() + 1); + String string; + string.Append(__pSliderPresenter->GetValue()); + string.Append(L" of "); + string.Append(__pSliderPresenter->GetMaxValue()); + _AccessibilityManager::GetInstance()->ReadContent(string); + + Invalidate(); + return true; +} + +bool +_Slider::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + SetValue(GetValue() - 1); + + String string; + string.Append(__pSliderPresenter->GetValue()); + string.Append(L" of "); + string.Append(__pSliderPresenter->GetMaxValue()); + _AccessibilityManager::GetInstance()->ReadContent(string); + + Invalidate(); + return true; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SliderEvent.cpp b/src/ui/controls/FUiCtrl_SliderEvent.cpp new file mode 100644 index 0000000..f3a3a78 --- /dev/null +++ b/src/ui/controls/FUiCtrl_SliderEvent.cpp @@ -0,0 +1,141 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SliderEvent.cpp + * @brief This is the implementation for the _SliderEvent class. + * + * This file contains the implementation of _SliderEvent class. @n + */ + +#include +#include +#include +#include "FUiCtrl_ISliderEventListener.h" +#include "FUiCtrl_SliderEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _OSP_EXPORT_ _SliderEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + _SliderEventArg(int value); + virtual ~_SliderEventArg(void); + +// Access +public: + int GetValue(void) const; + +// Attribute +private: + int __value; + +}; // _SliderEventArg + +_SliderEventArg::_SliderEventArg(int value) + : __value(value) +{ +} + +_SliderEventArg::~_SliderEventArg(void) +{ +} + +int +_SliderEventArg::GetValue(void) const +{ + return __value; +} + + +_SliderEvent::_SliderEvent(const _Slider& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = const_cast <_Slider*>(&source); + } +} + +_SliderEvent::~_SliderEvent(void) +{ +} + +_SliderEvent* +_SliderEvent::CreateInstanceN(const _Slider& source) +{ + _SliderEvent* pSliderEvent = new (std::nothrow) _SliderEvent(source); + SysTryReturn(NID_UI_CTRL, pSliderEvent != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pSliderEvent; + +CATCH: + delete pSliderEvent; + pSliderEvent = null; + + return null; +} + +const _Slider* +_SliderEvent::GetSource(void) const +{ + return __pSource; +} + +void +_SliderEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to ISliderEventListener + _ISliderEventListener* pSliderListener = dynamic_cast <_ISliderEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pSliderListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The _ISliderEventListener is null"); + + // cast to _SliderEventArg + const _SliderEventArg* pSliderEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pSliderEventArg != null, E_INVALID_ARG, + "[E_INVALID_ARG] Invalid argument(s) is used. The _SliderEventArg is null"); + + // call cursor change event listener method + pSliderListener->OnSliderBarMoved(*__pSource, pSliderEventArg->GetValue()); + SetLastResult(E_SUCCESS); + return ; +} + +IEventArg* +_SliderEvent::CreateSliderEventArgN(int value) +{ + _SliderEventArg* pEventArg = new (std::nothrow) _SliderEventArg(value); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SliderImpl.cpp b/src/ui/controls/FUiCtrl_SliderImpl.cpp new file mode 100644 index 0000000..a408e81 --- /dev/null +++ b/src/ui/controls/FUiCtrl_SliderImpl.cpp @@ -0,0 +1,696 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SliderImpl.cpp + * @brief This is the implementation file for the _SliderImpl class. + */ + +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_UiBuilder.h" +#include "FUiCtrl_SliderImpl.h" +#include "FUiCtrl_PublicAdjustmentEvent.h" +#include "FUiCtrl_PublicSliderEvent.h" + +using namespace Tizen::Ui; +using namespace Tizen::Graphics; +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_SliderImpl* +_SliderImpl::GetInstance(Slider& slider) +{ + return static_cast<_SliderImpl*> (slider._pControlImpl); +} + +const _SliderImpl* +_SliderImpl::GetInstance(const Slider& slider) +{ + return static_cast (slider._pControlImpl); +} + +_SliderImpl::_SliderImpl(Slider* pPublic, _Slider* pCore) + : _ControlImpl(pPublic, pCore) + , __pPublicAdjustmentEvent(null) + , __pPublicSliderEvent(null) +{ +} + +_SliderImpl::~_SliderImpl(void) +{ + if (__pPublicAdjustmentEvent != null) + { + delete __pPublicAdjustmentEvent; + __pPublicAdjustmentEvent = null; + } + + if (__pPublicSliderEvent != null) + { + delete __pPublicSliderEvent; + __pPublicSliderEvent = null; + } +} + +_SliderImpl* +_SliderImpl::CreateSliderImplN(Slider* pControl, const Rectangle& rect, int sliderStyle) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + r = FUNC_SIZE_INFO(Slider)(sliderStyle).CheckInitialSizeValid(Dimension(rect.width, rect.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _Slider* pCore = _Slider::CreateSliderN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _SliderImpl* pImpl = new (std::nothrow) _SliderImpl(pControl, pCore); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->InitializeBoundsProperties(FUNC_SIZE_INFO(Slider)(sliderStyle), rect, pCore->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl->__pPublicAdjustmentEvent = _PublicAdjustmentEvent::CreateInstanceN(*pControl); + SysTryCatch(NID_UI_CTRL, pImpl->__pPublicAdjustmentEvent != null, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to construct an AdjustmentEvent instance"); + + pImpl->__pPublicSliderEvent = _PublicSliderEvent::CreateInstanceN(*pControl); + SysTryCatch(NID_UI_CTRL, pImpl->__pPublicSliderEvent != null, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to construct a SliderEvent instance"); + + r = pCore->AddAdjustmentEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddSliderEventListener(*pImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; + +CATCH: + delete pImpl; + pImpl = null; + + return null; +} + +result +_SliderImpl::Initialize(int minValue, int maxValue, BackgroundStyle bgStyle, int sliderStyle, GroupStyle groupStyle) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + int style = _SLIDER_STYLE_NONE; + + if (sliderStyle & SLIDER_STYLE_BUBBLE) + { + style |= _SLIDER_STYLE_OVERLAY; + } + + if (bgStyle == BACKGROUND_STYLE_NONE) + { + SysTryReturn(NID_UI_CTRL, groupStyle == GROUP_STYLE_NONE, E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The current Slider style does not support given group style."); + + style |= _SLIDER_STYLE_NO_BG; + } + if (sliderStyle & SLIDER_STYLE_TITLE) + { + style |= _SLIDER_STYLE_TITLE_TEXT; + } + + r = SetRange(minValue, maxValue); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().SetStyle(style); + GetCore().SetGroupStyle(groupStyle); + + return r; +} + +result +_SliderImpl::SetRange(int minValue, int maxValue) +{ + ClearLastResult(); + + return GetCore().SetRange(minValue, maxValue); +} + +result +_SliderImpl::GetRange(int& minValue, int& maxValue) const +{ + ClearLastResult(); + + return GetCore().GetRange(minValue, maxValue); +} + +result +_SliderImpl::SetValue(int value) +{ + ClearLastResult(); + + Variant varValue(value); + + return GetCore().SetPropertyValue(varValue); +} + +int +_SliderImpl::GetValue(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyValue().ToInt(); +} + +result +_SliderImpl::SetIcon(IconPosition position, const Bitmap& icon) +{ + ClearLastResult(); + + return GetCore().SetIcon(position, icon); +} + +result +_SliderImpl::SetTitleText(const String& title) +{ + ClearLastResult(); + + Variant varTitleText(title); + + return GetCore().SetPropertyTitleText(varTitleText); +} + +String +_SliderImpl::GetTitleText(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyTitleText().ToString(); +} + +result +_SliderImpl::SetTitleTextColor(const Color& color) +{ + ClearLastResult(); + + Variant varTitleTextColor(color); + + return GetCore().SetPropertyTitleTextColor(varTitleTextColor); +} + +Color +_SliderImpl::GetTitleTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyTitleTextColor().ToColor(); +} + +result +_SliderImpl::AddAdjustmentEventListener(IAdjustmentEventListener& listener) +{ + ClearLastResult(); + + result r = __pPublicAdjustmentEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, "A system error has occurred. The IAdjustmentEventListener instance already exists in the event listener list."); + + return r; +} + +result +_SliderImpl::RemoveAdjustmentEventListener(IAdjustmentEventListener& listener) +{ + ClearLastResult(); + + result r = __pPublicAdjustmentEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, "A system error has occurred. The IAdjustmentEventListener instance does not exist"); + + return r; +} + +result +_SliderImpl::AddSliderEventListener(const ISliderEventListener& listener) +{ + ClearLastResult(); + + result r = __pPublicSliderEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_ALREADY_EXIST, E_SYSTEM, "A system error has occurred. The ISliderEventListener instance already exists in the event listener list."); + + return r; +} + +result +_SliderImpl::RemoveSliderEventListener(const ISliderEventListener& listener) +{ + ClearLastResult(); + + result r = __pPublicSliderEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r != E_OBJ_NOT_FOUND, E_SYSTEM, "A system error has occurred. The ISliderEventListener does not exist in the event listener list."); + + return r; +} + +result +_SliderImpl::SetBarColor(const Color& color) +{ + ClearLastResult(); + + Variant varBarColor(color); + + return GetCore().SetPropertyBarColor(varBarColor); +} + +Color +_SliderImpl::GetBarColor(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyBarColor().ToColor(); +} + +result +_SliderImpl::SetColor(const Color& color) +{ + ClearLastResult(); + + Variant varColor(color); + + return GetCore().SetPropertyColor(varColor); +} + +Color +_SliderImpl::GetColor(void) const +{ + ClearLastResult(); + + return GetCore().GetPropertyColor().ToColor(); +} + +result +_SliderImpl::SetThumbBitmap(SliderThumbStatus status, const Bitmap& bitmap) +{ + ClearLastResult(); + + return GetCore().SetThumbBitmap(status, bitmap); +} + +void +_SliderImpl::SetThumbTextColor(SliderThumbStatus status, const Color& color) +{ + ClearLastResult(); + + GetCore().SetThumbTextColor(status, color); + + return; +} + +const char* +_SliderImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::Slider"; +} + +const Slider& +_SliderImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +Slider& +_SliderImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Slider& +_SliderImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Slider& +_SliderImpl::GetCore(void) +{ + return static_cast <_Slider&>(_ControlImpl::GetCore()); +} + +void +_SliderImpl::OnAdjustmentValueChanged(const _Control& source, int adjustment) +{ + ClearLastResult(); + + Runtime::IEventArg* pEventArg = _PublicAdjustmentEvent::CreateAdjustmentEventArgN(adjustment); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicAdjustmentEvent->Fire(*pEventArg); + return; +} + +void +_SliderImpl::OnSliderBarMoved(_Slider& source, int value) +{ + ClearLastResult(); + + Runtime::IEventArg* pEventArg = _PublicSliderEvent::CreateSliderEventArgN(value); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pPublicSliderEvent->Fire(*pEventArg); + return; +} + +class _SliderMaker + : public _UiBuilderControlMaker +{ +public: + _SliderMaker(_UiBuilder* pUiBuilder) + : _UiBuilderControlMaker(pUiBuilder){} + virtual ~_SliderMaker(void){} + + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* pUiBuilder) + { + _SliderMaker* pSliderMaker = new (std::nothrow) _SliderMaker(pUiBuilder); + return pSliderMaker; + } + +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SUCCESS; + _UiBuilderControlLayout* pControlProperty = null; + Slider* pSlider = null; + Tizen::Base::String elementString; + Tizen::Base::String elementString1; + Rectangle rect; + int tempMin = 0; + int tempMax = 0; + int temp = 0; + int sliderStyle = SLIDER_STYLE_NONE; + bool isShowTitle = false; + bool isGroupStyle = false; + BackgroundStyle backgroundStyleEnum = BACKGROUND_STYLE_DEFAULT; + GroupStyle groupStyleEmum = GROUP_STYLE_NONE; + + Color color; + int opacity = 0; + + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pSlider = new (std::nothrow) Slider; + if (pSlider == null) + { + return null; + } + rect = pControlProperty->GetRect(); + + if (pControl->GetElement(L"backgroundStyle", elementString) || pControl->GetElement(L"BackgroundStyle", elementString)) + { + if (elementString.Equals(L"BACKGROUND_STYLE_NONE", false)) + { + backgroundStyleEnum = BACKGROUND_STYLE_NONE; + } + } + + if (pControl->GetElement(L"showTitleText", elementString) || pControl->GetElement(L"bShowtitleText", elementString)) + { + if (elementString.Equals(L"true", false)) + { + isShowTitle = true; + } + } + + if (pControl->GetElement(L"groupStyle", elementString) || pControl->GetElement(L"GroupStyle", elementString)) + { + isGroupStyle = true; + + if (elementString.Equals(L"GROUP_STYLE_NONE", false)) + { + groupStyleEmum = GROUP_STYLE_NONE; + } + if (elementString.Equals(L"GROUP_STYLE_SINGLE", false)) + { + groupStyleEmum = GROUP_STYLE_SINGLE; + } + if (elementString.Equals(L"GROUP_STYLE_TOP", false)) + { + groupStyleEmum = GROUP_STYLE_TOP; + } + if (elementString.Equals(L"GROUP_STYLE_MIDDLE", false)) + { + groupStyleEmum = GROUP_STYLE_MIDDLE; + } + if (elementString.Equals(L"GROUP_STYLE_BOTTOM", false)) + { + groupStyleEmum = GROUP_STYLE_BOTTOM; + } + } + if (isGroupStyle == true) + { + if (pControl->GetElement(L"min", elementString) && pControl->GetElement(L"max", elementString1)) + { + Base::Integer::Parse(elementString, tempMin); + Base::Integer::Parse(elementString1, tempMax); + + if (tempMin > tempMax) + { + temp = tempMin; + tempMin = tempMax; + tempMax = tempMin; + } + + r = pSlider->Construct(rect, backgroundStyleEnum, isShowTitle, tempMin, tempMax, groupStyleEmum); + } + else + { + r = pSlider->Construct(rect, backgroundStyleEnum, isShowTitle, 0, 10, groupStyleEmum); + } + } + + else + { + if (pControl->GetElement(L"sliderStyleBubble", elementString)) + { + if (elementString.Equals(L"true", false)) + { + sliderStyle |= SLIDER_STYLE_BUBBLE; + } + } + + if (pControl->GetElement(L"sliderStyleTitle", elementString)) + { + if (elementString.Equals(L"true", false)) + { + isShowTitle = true; + sliderStyle |= SLIDER_STYLE_TITLE; + } + } + + if (pControl->GetElement(L"min", elementString) && pControl->GetElement(L"max", elementString1)) + { + Base::Integer::Parse(elementString, tempMin); + Base::Integer::Parse(elementString1, tempMax); + + if (tempMin > tempMax) + { + temp = tempMin; + tempMin = tempMax; + tempMax = tempMin; + } + + r = pSlider->Construct(rect, sliderStyle, tempMin, tempMax); + } + else + { + r = pSlider->Construct(rect, sliderStyle, 0, 10); + } + } + + if (r != E_SUCCESS) + { + delete pSlider; + pSlider = null; + + return null; + } + + if (pControl->GetElement(L"value", elementString)) + { + Base::Integer::Parse(elementString, temp); + if (temp > tempMax || temp < tempMin) + { + temp = (tempMin + tempMax) >> 1; + } + pSlider->SetValue(temp); + } + else + { + pSlider->SetValue((tempMin + tempMax) >> 1); + } + + if (isShowTitle) + { + if (pControl->GetElement(L"titleText", elementString)) + { + pSlider->SetTitleText(elementString); + } + if (pControl->GetElement(L"colorOfTitleText", elementString)) + { + ConvertStringToColor(elementString, color); + pSlider->SetTitleTextColor(color); + } + } + + if (pControl->GetElement(L"normalThumbBitmap", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + if (pBitmap != null) + { + pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_NORMAL, *pBitmap); + delete pBitmap; + pBitmap = null; + } + } + + if (pControl->GetElement(L"pressedThumbBitmap", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + if (pBitmap != null) + { + pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_PRESSED, *pBitmap); + delete pBitmap; + pBitmap = null; + } + } + + if (pControl->GetElement(L"disabledThumbBitmap", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + if (pBitmap != null) + { + pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_DISABLED, *pBitmap); + delete pBitmap; + pBitmap = null; + } + } + + if (pControl->GetElement(L"highlightedThumbBitmap", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + if (pBitmap != null) + { + pSlider->SetThumbBitmap(SLIDER_THUMB_STATUS_HIGHLIGHTED, *pBitmap); + delete pBitmap; + pBitmap = null; + } + } + + if (pControl->GetElement(L"leftIconBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + if (pBitmap != null) + { + pSlider->SetIcon(ICON_POSITION_LEFT, *pBitmap); + delete pBitmap; + pBitmap = null; + } + } + + if (pControl->GetElement(L"rightIconBitmapPath", elementString)) + { + Bitmap* pBitmap = null; + pBitmap = LoadBitmapN(elementString); + if (pBitmap != null) + { + pSlider->SetIcon(ICON_POSITION_RIGHT, *pBitmap); + delete pBitmap; + pBitmap = null; + } + } + + if (pControl->GetElement(L"normalThumbTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"pressedThumbTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_PRESSED, color); + } + + if (pControl->GetElement(L"disabledThumbTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_DISABLED, color); + } + + if (pControl->GetElement(L"highlightedThumbTextColor", elementString)) + { + ConvertStringToColor(elementString, color); + pSlider->SetThumbTextColor(SLIDER_THUMB_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement(L"barColor", elementString)) + { + ConvertStringToColor(elementString, color); + pSlider->SetBarColor(color); + } + if (pControl->GetElement(L"colorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement(L"color", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pSlider->SetColor(color); + } + + return pSlider; + } + +}; // _SliderMaker + +_SliderRegister::_SliderRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"Slider", _SliderMaker::GetInstance); +} +_SliderRegister::~_SliderRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"Slider"); +} +static _SliderRegister SliderRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SliderModel.cpp b/src/ui/controls/FUiCtrl_SliderModel.cpp new file mode 100644 index 0000000..18850d0 --- /dev/null +++ b/src/ui/controls/FUiCtrl_SliderModel.cpp @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SliderModel.cpp + * @brief This is the implementation file for the _SliderModel class. + */ + +#include "FUiCtrl_SliderModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_SliderModel::_SliderModel(void) + : __minValue(0) + , __maxValue(0) + , __currentValue(0) +{ +} + +_SliderModel::~_SliderModel(void) +{ +} + +void +_SliderModel::SetMinValue(int minValue) +{ + __minValue = minValue; + return; +} + +int +_SliderModel::GetMinValue(void) const +{ + return __minValue; +} + +void +_SliderModel::SetMaxValue(int maxValue) +{ + __maxValue = maxValue; + return; +} + +int +_SliderModel::GetMaxValue(void) const +{ + return __maxValue; +} + +void +_SliderModel::SetValue(int value) +{ + __currentValue = value; + return; +} + +int +_SliderModel::GetValue(void) const +{ + return __currentValue; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SliderOverlay.cpp b/src/ui/controls/FUiCtrl_SliderOverlay.cpp new file mode 100644 index 0000000..63ee173 --- /dev/null +++ b/src/ui/controls/FUiCtrl_SliderOverlay.cpp @@ -0,0 +1,319 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SliderOverlay.cpp + * @brief This is the implementation file for the _SliderOverlay class. + */ + +#include +#include +#include +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_SliderOverlay.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_SliderOverlay::_SliderOverlay(void) + : __pOverlayBgBitmap(null) + , __pOverlayBgEffectBitmap(null) + , __pOverlayBottomBgBitmap(null) + , __pOverlayBottomBgEffectBitmap(null) + , __overlayBgColor(0) + , __overlayTextColor(0) + , __pFont(null) +{ + Tizen::Ui::Animations::_VisualElement* pBase = GetVisualElement(); + + if (pBase != null) + { + pBase->SetSurfaceOpaque(false); + } +} + +_SliderOverlay::~_SliderOverlay(void) +{ + delete __pOverlayBgBitmap; + __pOverlayBgBitmap = null; + + delete __pOverlayBgEffectBitmap; + __pOverlayBgEffectBitmap = null; + + delete __pOverlayBottomBgBitmap; + __pOverlayBgBitmap = null; + + delete __pOverlayBottomBgEffectBitmap; + __pOverlayBgEffectBitmap = null; + +} + + +result +_SliderOverlay::Construct(void) +{ + result r = E_SUCCESS; + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + +#if defined(MULTI_WINDOW) + r = CreateRootVisualElement(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + SetActivationEnabled(false); +#endif + + AcquireHandle(); + + r = GET_COLOR_CONFIG(SLIDER::OVERLAY_BG_NORMAL, __overlayBgColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::OVERLAY_TEXT_NORMAL, __overlayTextColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Dimension dim(0, 0); + r = GET_SHAPE_CONFIG(SLIDER::OVERLAY_WIDTH, orientation, dim.width); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::OVERLAY_HEIGHT, orientation, dim.height); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = LoadBitmaps(dim); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_SliderOverlay::SetSliderRect(Rectangle& sliderRect, Rectangle& sliderTouchRect) +{ + __sliderRect = sliderRect; + __sliderTouchRect = sliderTouchRect; + + return E_SUCCESS; +} + +void +_SliderOverlay::SetFont(Tizen::Graphics::Font* pFont) +{ + __pFont = pFont; + return; +} + +result +_SliderOverlay::LoadBitmaps(Dimension& dim) +{ + result r = E_SUCCESS; + + Bitmap* pBitmap = null; + Bitmap* pReplacementBitmap = null; + + r = GET_BITMAP_CONFIG_N(SLIDER::UPWARD_OVERLAY_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + pReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, Color::GetColor(COLOR_ID_MAGENTA), __overlayBgColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pReplacementBitmap != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pOverlayBgBitmap; + __pOverlayBgBitmap = pReplacementBitmap; + + delete pBitmap; + pBitmap = null; + + r = GET_BITMAP_CONFIG_N(SLIDER::DOWNWARD_OVERLAY_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating."); + + pReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, Color::GetColor(COLOR_ID_MAGENTA), __overlayBgColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, pReplacementBitmap != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pOverlayBottomBgBitmap; + __pOverlayBottomBgBitmap = pReplacementBitmap; + + delete pBitmap; + pBitmap = null; + + + r = GET_BITMAP_CONFIG_N(SLIDER::UPWARD_OVERLAY_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + delete __pOverlayBgEffectBitmap; + __pOverlayBgEffectBitmap = pBitmap; + + r = GET_BITMAP_CONFIG_N(SLIDER::DOWNWARD_OVERLAY_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + delete __pOverlayBottomBgEffectBitmap; + __pOverlayBottomBgEffectBitmap = pBitmap; + + return r; + +CATCH: + delete pBitmap; + pBitmap = null; + + return r; +} + +result +_SliderOverlay::DrawSliderOverlay(int positionX, int handleWidth, int value) +{ + result r = E_SUCCESS; + + int overlayWidth = 0; + int overlayHeight = 0; + int overlayBottomMargin = 0; + int overlayTextSize = 0; + int overlayBodyHeight = 0; + int overlayY = 0; + int overlayOffset = 0; + Point textPoint(0, 0); + + Bitmap* pBgBitmap = __pOverlayBgBitmap; + Bitmap* pEffectBgBitmap = __pOverlayBgEffectBitmap; + + Tizen::Base::String text; + text.Append(value); + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + r = GET_SHAPE_CONFIG(SLIDER::OVERLAY_WIDTH, orientation, overlayWidth); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::OVERLAY_HEIGHT, orientation, overlayHeight); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::OVERLAY_BOTTOM_MARGIN, orientation, overlayBottomMargin); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::OVERLAY_HEIGHT_WITHOUT_ARROW, orientation, overlayBodyHeight); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (text.GetLength() == SLIDER_OVERLAY_THREE_DIGIT) + { + r = GET_SHAPE_CONFIG(SLIDER::OVERLAY_TEXT_SIZE_THREE_CHARACTERS, orientation, overlayTextSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (text.GetLength() == SLIDER_OVERLAY_TWO_DIGIT) + { + r = GET_SHAPE_CONFIG(SLIDER::OVERLAY_TEXT_SIZE_TWO_CHARACTERS, orientation, overlayTextSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = GET_SHAPE_CONFIG(SLIDER::OVERLAY_TEXT_SIZE_ONE_CHARACTER, orientation, overlayTextSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (__sliderTouchRect.y > 0) + { + overlayY = __sliderTouchRect.y; + } + + __sliderOverlayRect = Rectangle(__sliderRect.x + positionX + (handleWidth - overlayWidth) / 2, + __sliderRect.y + overlayY - (overlayHeight + overlayBottomMargin), + overlayWidth, overlayHeight); + + if (__sliderOverlayRect.y <= 0) + { + if (__sliderRect.height < (__sliderTouchRect.y + __sliderTouchRect.height)) + { + overlayOffset = __sliderRect.height; + } + else + { + overlayOffset = __sliderTouchRect.y + __sliderTouchRect.height; + } + __sliderOverlayRect.y = __sliderRect.y + overlayOffset + overlayBottomMargin; + pBgBitmap = __pOverlayBottomBgBitmap; + pEffectBgBitmap = __pOverlayBottomBgEffectBitmap; + textPoint.y = overlayHeight - overlayBodyHeight; + } + + // Check SliderOverlay Position + if (__sliderOverlayRect.x < __sliderRect.x) + { + __sliderOverlayRect.x = __sliderRect.x; + } + if (__sliderOverlayRect.x + __sliderOverlayRect.width > __sliderRect.x + __sliderRect.width) + { + __sliderOverlayRect.x = __sliderRect.x + __sliderRect.width - __sliderOverlayRect.width; + } + SetBounds(__sliderOverlayRect); + + // Get canvas & Clear BG + Canvas* pCanvas = GetCanvasN(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + pCanvas->SetBackgroundColor(Color(0x00000000)); + pCanvas->Clear(); + + (_FontImpl::GetInstance(*__pFont))->SetSize(overlayTextSize); + + pCanvas->SetFont(*__pFont); + + // Draw BG + Rectangle overlayRect = Rectangle(0, 0, __sliderOverlayRect.width, __sliderOverlayRect.height); + Dimension textDim(0, 0); + + + __pFont->GetTextExtent(text, text.GetLength(), textDim); + + if (pBgBitmap->IsNinePatchedBitmap()) + { + r = pCanvas->DrawNinePatchedBitmap(overlayRect, *pBgBitmap); + } + else + { + r = pCanvas->DrawBitmap(overlayRect, *pBgBitmap); + } + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (pEffectBgBitmap->IsNinePatchedBitmap()) + { + r = pCanvas->DrawNinePatchedBitmap(overlayRect, *pEffectBgBitmap); + } + else + { + r = pCanvas->DrawBitmap(overlayRect, *pEffectBgBitmap); + } + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + // Draw Value Text + __pFont->GetTextExtent(text, text.GetLength(), textDim); + textPoint.x = (__sliderOverlayRect.width - textDim.width) / 2; + textPoint.y = textPoint.y + ((overlayBodyHeight - textDim.height) / 2); + pCanvas->SetForegroundColor(__overlayTextColor); + pCanvas->DrawText(textPoint, text); + + delete pCanvas; + pCanvas = null; + + return r; +CATCH: + delete pCanvas; + return E_SYSTEM; +} + +bool +_SliderOverlay::IsActivatedOnOpen(void) const +{ + return false; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SliderPresenter.cpp b/src/ui/controls/FUiCtrl_SliderPresenter.cpp new file mode 100644 index 0000000..a380570 --- /dev/null +++ b/src/ui/controls/FUiCtrl_SliderPresenter.cpp @@ -0,0 +1,1726 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SliderPresenter.cpp + * @brief This is the implementation file for the _SliderPresenter class. + */ + +#include +#include +#include +#include +#include +#include +#include "FUi_UiTouchEvent.h" +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_Slider.h" +#include "FUiCtrl_SliderModel.h" +#include "FUiCtrl_SliderOverlay.h" + +#include "FUiCtrl_SliderPresenter.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_SliderPresenter::_SliderPresenter(void) + : __pSlider(null) + , __pSliderModel(null) + , __pSliderOverlay(null) + , __pResourceBgTopBitmap(null) + , __pResourceBgMiddleBitmap(null) + , __pResourceBgBottomBitmap(null) + , __pResourceBgSingleBitmap(null) + , __pBgTopBitmap(null) + , __pBgMiddleBitmap(null) + , __pBgBottomBitmap(null) + , __pBgSingleBitmap(null) + , __pBgGrpStyleNoneBitmap(null) + , __pBgTopEffectBitmap(null) + , __pBgMiddleEffectBitmap(null) + , __pBgBottomEffectBitmap(null) + , __pBgSingleEffectBitmap(null) + , __pResourceBarBitmap(null) + , __pBarResourceEffectBitmap(null) + , __pBarBgResourceEffectBitmap(null) + , __pBarColorReplacementBitmap(null) + , __pBarBgColorReplacementBitmap(null) + , __pHandleNormalBitmap(null) + , __pHandlePressedBitmap(null) + , __pHandleDisabledBitmap(null) + , __pHandleHighlightedBitmap(null) + , __pHandleNormalEffectBitmap(null) + , __pHandlePressedEffectBitmap(null) + , __pHandleDisabledEffectBitmap(null) + , __pHandleHighlightedEffectBitmap(null) + , __currentBarColor(0) + , __currentBgColor(0) + , __pFont(null) + , __pTitleTextObject(null) + , __sliderX(0) + , __handleX(0) + , __isSliderPressed(false) + , __isNeedToBeUpdated(true) + , __isBubblingBlocked(false) + , __isResourceLoaded(false) + , __isCustomHandle(false) + , __isCustomPressedTextColor(false) + , __groupStyle(GROUP_STYLE_NONE) + , __fontSize(0) +{ +} + +_SliderPresenter::~_SliderPresenter(void) +{ + delete __pSliderModel; + __pSliderModel = null; + + delete __pSliderOverlay; + __pSliderOverlay = null; + + delete __pResourceBgTopBitmap; + __pResourceBgTopBitmap = null; + + delete __pResourceBgMiddleBitmap; + __pResourceBgMiddleBitmap = null; + + delete __pResourceBgBottomBitmap; + __pResourceBgBottomBitmap = null; + + delete __pResourceBgSingleBitmap; + __pResourceBgSingleBitmap = null; + + delete __pBgTopBitmap; + __pBgTopBitmap = null; + + delete __pBgMiddleBitmap; + __pBgMiddleBitmap = null; + + delete __pBgBottomBitmap; + __pBgBottomBitmap = null; + + delete __pBgSingleBitmap; + __pBgSingleBitmap = null; + + delete __pBgGrpStyleNoneBitmap; + __pBgGrpStyleNoneBitmap = null; + + delete __pBgTopEffectBitmap; + __pBgTopEffectBitmap = null; + + delete __pBgMiddleEffectBitmap; + __pBgMiddleEffectBitmap = null; + + delete __pBgBottomEffectBitmap; + __pBgBottomEffectBitmap = null; + + delete __pBgSingleEffectBitmap; + __pBgSingleEffectBitmap = null; + + delete __pResourceBarBitmap; + __pResourceBarBitmap = null; + + delete __pBarResourceEffectBitmap; + __pBarResourceEffectBitmap = null; + + delete __pBarBgResourceEffectBitmap; + __pBarBgResourceEffectBitmap = null; + + delete __pBarColorReplacementBitmap; + __pBarColorReplacementBitmap = null; + + delete __pBarBgColorReplacementBitmap; + __pBarBgColorReplacementBitmap = null; + + delete __pHandleNormalBitmap; + __pHandleNormalBitmap = null; + + delete __pHandlePressedBitmap; + __pHandlePressedBitmap = null; + + delete __pHandleDisabledBitmap; + __pHandleDisabledBitmap = null; + + delete __pHandleHighlightedBitmap; + __pHandleHighlightedBitmap = null; + + delete __pHandleNormalEffectBitmap; + __pHandleNormalEffectBitmap = null; + + delete __pHandlePressedEffectBitmap; + __pHandlePressedEffectBitmap = null; + + delete __pHandleDisabledEffectBitmap; + __pHandleDisabledEffectBitmap = null; + + delete __pHandleHighlightedEffectBitmap; + __pHandleHighlightedEffectBitmap = null; + + delete __pTitleTextObject; + __pTitleTextObject = null; + +} + +_SliderPresenter* +_SliderPresenter::CreateInstanceN(const _Slider& slider) +{ + result r = E_SUCCESS; + + _SliderPresenter* pSliderPresenter = new (std::nothrow) _SliderPresenter; + SysTryReturn(NID_UI_CTRL, pSliderPresenter != null, null, E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pSliderPresenter->__pSlider = const_cast <_Slider*>(&slider); + SysTryCatch(NID_UI_CTRL, pSliderPresenter->__pSlider != null, , E_SYSTEM, + "[E_SYSTEM] A system error has occurred. The Slider control core is null."); + + pSliderPresenter->__pSliderModel = new (std::nothrow) _SliderModel; + SysTryCatch(NID_UI_CTRL, pSliderPresenter->__pSliderModel != null, , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (pSliderPresenter->__pSlider->GetStyle() & _SLIDER_STYLE_OVERLAY) + { + pSliderPresenter->__pSliderOverlay = new (std::nothrow) _SliderOverlay; + SysTryCatch(NID_UI_CTRL, pSliderPresenter->__pSliderOverlay != null, , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pSliderPresenter->__pSliderOverlay->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return pSliderPresenter; + +CATCH: + delete pSliderPresenter; + pSliderPresenter = null; + + return null; +} + +result +_SliderPresenter::Resize(void) +{ + result r = E_SUCCESS; + + int barHeight = 0; + int barLeftMargin = 0; + int barRightMargin = 0; + int sliderY = 0; + int iconWidth = 0; + int iconSideMargin = 0; + int offset = 0; + int minimumHeight = 0; + int minimumWidth = 0; + int topMargin = 0; + int iconRightMargin = 0; + Rectangle titleTextBounds; + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + if (__isResourceLoaded == false) + { + r = LoadBitmap(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + __isResourceLoaded = true; + + r = GET_SHAPE_CONFIG(SLIDER::HANDLE_ONE_DIGIT_TEXT_SIZE, orientation, __fontSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pFont = __pSlider->GetFallbackFont(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::HANDLE_NUMBER_TEXT_NORMAL, __handleTextColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::HANDLE_NUMBER_TEXT_DISABLED, __handleTextDisabledColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __handleTextPressedColor = __handleTextColor; + __handleTextHighlightedColor = __handleTextColor; + + } + + + r = GET_SHAPE_CONFIG(SLIDER::BAR_HEIGHT, orientation, barHeight); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::BAR_LEFT_MARGIN, orientation, barLeftMargin); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + barRightMargin = barLeftMargin; + + r = GET_SHAPE_CONFIG(SLIDER::ICON_WIDTH, orientation, iconWidth); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + + if (!__isCustomHandle) + { + r = GET_SHAPE_CONFIG(SLIDER::HANDLE_OFFSET, orientation, offset); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::HANDLE_WIDTH, orientation, __handleRect.width); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::HANDLE_HEIGHT, orientation, __handleRect.height); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + __rect = Rectangle(0, 0, __pSlider->GetBounds().width, __pSlider->GetBounds().height); + + r = GET_SHAPE_CONFIG(SLIDER::BAR_TOP_MARGIN, orientation, topMargin); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::ICON_RIGHT_MARGIN, orientation, iconRightMargin); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if ((__pSlider->GetIcon(ICON_POSITION_LEFT) != null) || (__pSlider->GetIcon(ICON_POSITION_RIGHT) != null)) + { + r = GET_SHAPE_CONFIG(SLIDER::MINIMUM_SIZE_WITH_ICON, orientation, minimumWidth); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__rect.width < minimumWidth) + { + __rect.width = minimumWidth; + } + } + else + { + r = GET_SHAPE_CONFIG(SLIDER::MINIMUM_SIZE_WITHOUT_ICON, orientation, minimumWidth); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__rect.width < minimumWidth) + __rect.width = minimumWidth; + } + + if (__pSlider->GetStyle() & _SLIDER_STYLE_TITLE_TEXT) + { + r = GET_SHAPE_CONFIG(SLIDER::TITLE_TEXT_SIZE, orientation, minimumHeight); + minimumHeight = minimumHeight + (2 * topMargin) + barHeight; + if (__rect.height < minimumHeight ) + __rect.height = minimumHeight; + } + else + { + minimumHeight = (2 * topMargin) + barHeight; + if (__rect.height < minimumHeight) + __rect.height = minimumHeight; + } + + if (__pSlider->GetStyle() & _SLIDER_STYLE_TITLE_TEXT) + { + titleTextBounds = GetTitleTextBounds(); + sliderY = titleTextBounds.y + titleTextBounds.height; + __touchRect = Rectangle(barLeftMargin - offset, sliderY + (__rect.height - (sliderY + __handleRect.height)) / 2, + __rect.width - (barLeftMargin + barRightMargin) + (2 * offset), __handleRect.height); + } + else + { + __touchRect = Rectangle(barLeftMargin - offset, (__rect.height - __handleRect.height) / 2, + (__rect.width - (barLeftMargin + barRightMargin)) + (2 * offset), __handleRect.height); + } + + if (__pSlider->GetIcon(ICON_POSITION_LEFT) != null) + { + __touchRect.x = __touchRect.x + iconWidth + iconRightMargin; + __touchRect.width = __touchRect.width - (iconWidth + iconRightMargin); + } + + if (__pSlider->GetIcon(ICON_POSITION_RIGHT) != null) + { + __touchRect.width = __touchRect.width - (iconWidth + iconSideMargin + iconRightMargin); + } + + __barBgRect = Rectangle(__touchRect.x + offset, __touchRect.y + + ((__handleRect.height - barHeight) / 2), __touchRect.width - (2 * offset), barHeight); + + Rectangle absBounds = __pSlider->GetAbsoluteBounds(); + __pSliderOverlay->SetSliderRect(absBounds, __touchRect); + + return r; +} + +result +_SliderPresenter::LoadBitmap(void) +{ + result r = E_SUCCESS; + + int opacity = 0; + Bitmap* pBitmap = null; + Bitmap* pNormalBitmap = null; + Bitmap* pPressedBitmap = null; + Bitmap* pDisabledBitmap = null; + Bitmap* pHighlightedBitmap = null; + Bitmap* pReplacementBitmap = null; + Color barBgColor; + Color handleNormalColor; + Color handlePressedColor; + Color handleDisabledColor; + Color handleHighlightedColor; + + r = GET_COLOR_CONFIG(SLIDER::BG_OTHERS_NORMAL, __currentBgColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::BG_DEFAULT_NORMAL, __currentGrpStyleNoneColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::BAR_NORMAL, __currentBarColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::BAR_BG_NORMAL, barBgColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::HANDLE_BG_NORMAL, handleNormalColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::HANDLE_BG_PRESSED, handlePressedColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::HANDLE_BG_DISABLED, handleDisabledColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_COLOR_CONFIG(SLIDER::HANDLE_BG_HIGHLIGHTED, handleHighlightedColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // for GROUP_STYLE_TOP + r = GET_BITMAP_CONFIG_N(SLIDER::GROUP_TOP_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pResourceBgTopBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Propagating."); + + __pBgTopBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBgTopBitmap,Color::GetColor(COLOR_ID_MAGENTA), __currentBgColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(SLIDER::GROUP_TOP_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pBgTopEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + + // for GROUP_STYLE_MIDDLE + r = GET_BITMAP_CONFIG_N(SLIDER::GROUP_MIDDLE_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pResourceBgMiddleBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pBgMiddleBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBgMiddleBitmap,Color::GetColor(COLOR_ID_MAGENTA), __currentBgColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(SLIDER::GROUP_MIDDLE_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pBgMiddleEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + + // for GROUP_STYLE_BOTTOM + r = GET_BITMAP_CONFIG_N(SLIDER::GROUP_BOTTOM_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pResourceBgBottomBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pBgBottomBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBgBottomBitmap,Color::GetColor(COLOR_ID_MAGENTA), __currentBgColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(SLIDER::GROUP_BOTTOM_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pBgBottomEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + // for GROUP_STYLE_SINGLE and GROUP_STYLE_NONE + r = GET_BITMAP_CONFIG_N(SLIDER::GROUP_SINGLE_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pResourceBgSingleBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pBgSingleBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBgSingleBitmap, Color::GetColor(COLOR_ID_MAGENTA), __currentBgColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pBgGrpStyleNoneBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBgSingleBitmap, Color::GetColor(COLOR_ID_MAGENTA), __currentGrpStyleNoneColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + + r = GET_BITMAP_CONFIG_N(SLIDER::GROUP_SINGLE_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pBgSingleEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + opacity = __currentBgColor.GetAlpha(); + + __pBgTopBitmap->SetAlphaConstant(opacity); + __pBgMiddleBitmap->SetAlphaConstant(opacity); + __pBgBottomBitmap->SetAlphaConstant(opacity); + __pBgSingleBitmap->SetAlphaConstant(opacity); + __pBgGrpStyleNoneBitmap->SetAlphaConstant(__currentGrpStyleNoneColor.GetAlpha()); + + + __pBgTopEffectBitmap->SetAlphaConstant(opacity); + __pBgMiddleEffectBitmap->SetAlphaConstant(opacity); + __pBgBottomEffectBitmap->SetAlphaConstant(opacity); + __pBgSingleEffectBitmap->SetAlphaConstant(opacity); + + + // Bar Resources + r = GET_BITMAP_CONFIG_N(SLIDER::BAR_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pResourceBarBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pBarBgColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBarBitmap,Color::GetColor(COLOR_ID_MAGENTA), barBgColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pResourceBarBitmap; + __pResourceBarBitmap = null; + + r = GET_BITMAP_CONFIG_N(SLIDER::BAR_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pResourceBarBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pBarColorReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBarBitmap,Color::GetColor(COLOR_ID_MAGENTA), __currentBarColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(SLIDER::BAR_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pBarBgResourceEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(SLIDER::BAR_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pBarResourceEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + opacity = __currentBarColor.GetAlpha(); + __pBarColorReplacementBitmap->SetAlphaConstant(opacity); + + // Handle Resources + r = GET_BITMAP_CONFIG_N(SLIDER::HANDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pHandleNormalBitmap == null) + { + pReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), handleNormalColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pReplacementBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHandleNormalBitmap = pReplacementBitmap; + } + + r = GET_BITMAP_CONFIG_N(SLIDER::HANDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pHandlePressedBitmap == null) + { + pReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedBitmap, Color::GetColor(COLOR_ID_MAGENTA), handlePressedColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pReplacementBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHandlePressedBitmap = pReplacementBitmap; + } + + r = GET_BITMAP_CONFIG_N(SLIDER::HANDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDisabledBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pHandleDisabledBitmap == null) + { + pReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDisabledBitmap, Color::GetColor(COLOR_ID_MAGENTA), handleDisabledColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pReplacementBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHandleDisabledBitmap = pReplacementBitmap; + } + + r = GET_BITMAP_CONFIG_N(SLIDER::HANDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pHighlightedBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pHandleHighlightedBitmap == null) + { + pReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pHighlightedBitmap, Color::GetColor(COLOR_ID_MAGENTA), handleHighlightedColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pReplacementBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHandleHighlightedBitmap = pReplacementBitmap; + } + + if (__pHandleNormalEffectBitmap == null) + { + r = GET_BITMAP_CONFIG_N(SLIDER::HANDLE_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHandleNormalEffectBitmap = pBitmap; + } + + if (__pHandlePressedEffectBitmap == null) + { + r = GET_BITMAP_CONFIG_N(SLIDER::HANDLE_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHandlePressedEffectBitmap = pBitmap; + } + + if (__pHandleDisabledEffectBitmap == null) + { + r = GET_BITMAP_CONFIG_N(SLIDER::HANDLE_BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHandleDisabledEffectBitmap = pBitmap; + } + + if (__pHandleHighlightedEffectBitmap == null) + { + r = GET_BITMAP_CONFIG_N(SLIDER::HANDLE_BG_EFFECT_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHandleHighlightedEffectBitmap = pBitmap; + } + + delete pNormalBitmap; + delete pPressedBitmap; + delete pDisabledBitmap; + delete pHighlightedBitmap; + + return r; + +CATCH: + + delete pNormalBitmap; + delete pPressedBitmap; + delete pDisabledBitmap; + delete pHighlightedBitmap; + + delete pBitmap; + + delete __pResourceBgTopBitmap; + __pResourceBgTopBitmap = null; + + delete __pResourceBgMiddleBitmap; + __pResourceBgMiddleBitmap = null; + + delete __pResourceBgBottomBitmap; + __pResourceBgBottomBitmap = null; + + delete __pResourceBgSingleBitmap; + __pResourceBgSingleBitmap = null; + + delete __pBgTopBitmap; + __pBgTopBitmap = null; + + delete __pBgMiddleBitmap; + __pBgMiddleBitmap = null; + + delete __pBgBottomBitmap; + __pBgBottomBitmap = null; + + delete __pBgSingleBitmap; + __pBgSingleBitmap = null; + + delete __pBgGrpStyleNoneBitmap; + __pBgGrpStyleNoneBitmap = null; + + delete __pBgTopEffectBitmap; + __pBgTopEffectBitmap = null; + + delete __pBgMiddleEffectBitmap; + __pBgMiddleEffectBitmap = null; + + delete __pBgBottomEffectBitmap; + __pBgBottomEffectBitmap = null; + + delete __pBgSingleEffectBitmap; + __pBgSingleEffectBitmap = null; + + delete __pResourceBarBitmap; + __pResourceBarBitmap = null; + + delete __pBarResourceEffectBitmap; + __pBarResourceEffectBitmap = null; + + delete __pBarBgResourceEffectBitmap; + __pBarBgResourceEffectBitmap = null; + + delete __pBarColorReplacementBitmap; + __pBarColorReplacementBitmap = null; + + delete __pBarBgColorReplacementBitmap; + __pBarBgColorReplacementBitmap = null; + + delete __pHandleNormalBitmap; + __pHandleNormalBitmap = null; + + delete __pHandlePressedBitmap; + __pHandlePressedBitmap = null; + + delete __pHandleDisabledBitmap; + __pHandleDisabledBitmap = null; + + delete __pHandleHighlightedBitmap; + __pHandleHighlightedBitmap = null; + + delete __pHandleNormalEffectBitmap; + __pHandleNormalEffectBitmap = null; + + delete __pHandlePressedEffectBitmap; + __pHandlePressedEffectBitmap = null; + + delete __pHandleDisabledEffectBitmap; + __pHandleDisabledEffectBitmap = null; + + delete __pHandleHighlightedEffectBitmap; + __pHandleHighlightedEffectBitmap = null; + + return r; +} + +int +_SliderPresenter::CalculateSliderValue(int positionX, int offsetX) +{ + int minValue = __pSliderModel->GetMinValue(); + int maxValue = __pSliderModel->GetMaxValue(); + + if (positionX <= __touchRect.x + offsetX) + { + __sliderX = 0; + __handleX = 0; + return minValue; + } + + if (positionX >= (__touchRect.x + __touchRect.width) - offsetX) + { + __sliderX = __barBgRect.width - __handleRect.width; + __handleX = __touchRect.width - __handleRect.width; + return maxValue; + } + + if ((maxValue - minValue) == 0) + { + return minValue; + } + + __sliderX = positionX - (__barBgRect.x + offsetX); + __handleX = positionX - (__touchRect.x + offsetX); + + __handleRect.x = __touchRect.x + __handleX; + __handleRect.y = __touchRect.y; + + if (__handleRect.x < __touchRect.x ) + { + __handleRect.x = __touchRect.x; + } + + if (__handleRect.x + __handleRect.width > __touchRect.x + __touchRect.width ) + { + __handleRect.x = __touchRect.x + __touchRect.width - __handleRect.width; + } + + return minValue + (int) ((float) (__handleX * (maxValue - minValue)) / (float)(__touchRect.width - __handleRect.width) + 0.5); // current value = current width * range / bar bg width +} + +result +_SliderPresenter::Draw(void) +{ + if (__isNeedToBeUpdated == true) + { + Resize(); + } + + return DrawSlider(); +} + +result +_SliderPresenter::DrawSlider(void) +{ + result r = E_SUCCESS; + int sliderY = 0; + Rectangle titleTextBounds; + + int style = __pSlider->GetStyle(); + + Canvas* pCanvas = __pSlider->GetCanvasN(); + SysTryReturn(NID_UI_CTRL, pCanvas != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + if (__isNeedToBeUpdated == true) + { + r = DrawBackground(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawIcon(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (style & _SLIDER_STYLE_TITLE_TEXT) + { + r = DrawTitleText(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __isNeedToBeUpdated = false; + } + + if (style & _SLIDER_STYLE_TITLE_TEXT) + { + titleTextBounds = GetTitleTextBounds(); + sliderY = titleTextBounds.y + titleTextBounds.height; + } + + if(sliderY < __rect.height) + { + r = DrawSliderBar(*pCanvas); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__isSliderPressed == true) + { + if (style & _SLIDER_STYLE_OVERLAY) + { + r = DrawSliderOverlay(__pSliderModel->GetValue()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = DrawSliderBarNumber(__pSliderModel->GetValue()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + r = DrawSliderBarNumber(__pSliderModel->GetValue()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + delete pCanvas; + pCanvas = null; + + return r; + +CATCH: + delete pCanvas; + pCanvas = null; + + return r; +} + +result +_SliderPresenter::DrawBackground(Canvas& canvas) +{ + Bitmap* pBgBitmap = null; + Bitmap* pBgEffectBitmap = null; + Bitmap* pBgGroupBitmap = null; + + int opacity = 0; + result r = E_SUCCESS; + canvas.SetBackgroundColor(Color(0x00000000)); + canvas.Clear(); + + if (!(__pSlider->GetStyle() & _SLIDER_STYLE_NO_BG)) + { + switch (__groupStyle) + { + case GROUP_STYLE_TOP: + pBgEffectBitmap = __pBgTopEffectBitmap; + if (__pSlider->GetColor() == __currentBgColor) + { + pBgBitmap = __pBgTopBitmap; + } + else + { + pBgGroupBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBgTopBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pSlider->GetColor()); + r = GetLastResult(); + if (!pBgGroupBitmap) + { + SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + else + { + delete __pBgTopBitmap; + __pBgTopBitmap = null; + __pBgTopBitmap = pBgGroupBitmap; + + pBgBitmap = pBgGroupBitmap; + opacity = __pSlider->GetColor().GetAlpha(); + pBgBitmap->SetAlphaConstant(opacity); + __currentBgColor = __pSlider->GetColor(); + } + } + break; + + case GROUP_STYLE_MIDDLE: + pBgEffectBitmap = __pBgMiddleEffectBitmap; + if (__pSlider->GetColor() == __currentBgColor) + { + pBgBitmap = __pBgMiddleBitmap; + } + else + { + pBgGroupBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBgMiddleBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pSlider->GetColor()); + r = GetLastResult(); + if (!pBgGroupBitmap) + { + SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + else + { + delete __pBgMiddleBitmap; + __pBgMiddleBitmap = null; + __pBgMiddleBitmap = pBgGroupBitmap; + + pBgBitmap = __pBgMiddleBitmap; + opacity = __pSlider->GetColor().GetAlpha(); + pBgBitmap->SetAlphaConstant(opacity); + __currentBgColor = __pSlider->GetColor(); + } + } + break; + + case GROUP_STYLE_BOTTOM: + pBgEffectBitmap = __pBgBottomEffectBitmap; + if (__pSlider->GetColor() == __currentBgColor) + { + pBgBitmap = __pBgBottomBitmap; + } + else + { + pBgGroupBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBgBottomBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pSlider->GetColor()); + r = GetLastResult(); + if (!pBgGroupBitmap) + { + SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + else + { + delete __pBgBottomBitmap; + __pBgBottomBitmap = null; + __pBgBottomBitmap = pBgGroupBitmap; + + pBgBitmap = __pBgBottomBitmap; + opacity = __pSlider->GetColor().GetAlpha(); + pBgBitmap->SetAlphaConstant(opacity); + __currentBgColor = __pSlider->GetColor(); + } + } + break; + + case GROUP_STYLE_SINGLE: + pBgEffectBitmap = __pBgSingleEffectBitmap; + if (__pSlider->GetColor() == __currentBgColor) + { + pBgBitmap = __pBgSingleBitmap; + } + else + { + pBgGroupBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBgSingleBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pSlider->GetColor()); + r = GetLastResult(); + if (!pBgGroupBitmap) + { + SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + else + { + + delete __pBgSingleBitmap; + __pBgSingleBitmap = null; + __pBgSingleBitmap = pBgGroupBitmap; + + pBgBitmap = __pBgSingleBitmap; + opacity = __pSlider->GetColor().GetAlpha(); + pBgBitmap->SetAlphaConstant(opacity); + __currentBgColor = __pSlider->GetColor(); + } + } + break; + + case GROUP_STYLE_NONE: + //fall through + default: + if (__pSlider->GetColor() == __currentBgColor) + { + pBgBitmap = __pBgGrpStyleNoneBitmap; + } + else + { + pBgGroupBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBgSingleBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pSlider->GetColor()); + r = GetLastResult(); + if (!pBgGroupBitmap) + { + SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + else + { + delete __pBgGrpStyleNoneBitmap; + __pBgGrpStyleNoneBitmap = null; + __pBgGrpStyleNoneBitmap = pBgGroupBitmap; + + pBgBitmap = __pBgGrpStyleNoneBitmap; + opacity = __pSlider->GetColor().GetAlpha(); + pBgBitmap->SetAlphaConstant(opacity); + __currentBgColor = __pSlider->GetColor(); + } + } + break; + } + + DrawBitmap(canvas, __rect, pBgBitmap); + if ( __groupStyle != GROUP_STYLE_NONE) + { + DrawBitmap(canvas, __rect, pBgEffectBitmap); + } + } + return E_SUCCESS; +} + +result +_SliderPresenter::DrawSliderBar(Canvas& canvas) +{ + result r = E_SUCCESS; + int bitmapHeight = 0; + int bitmapWidth = 0; + int bitmapPositionX = 0; + int bitmapPositionY = 0; + int opacity = 0; + int offset = 0; + Bitmap* pReplacementBitmap = null; + Bitmap* pHandleBitmap = null; + Bitmap* pHandleEffectBitmap = null; + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + r = GET_SHAPE_CONFIG(SLIDER::HANDLE_OFFSET, orientation, offset); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pSlider->IsEnabled() == false) // disabled + { + pHandleBitmap = __pHandleDisabledBitmap; + pHandleEffectBitmap = __pHandleDisabledEffectBitmap; + if(__isSliderPressed == true) + { + __isSliderPressed = false; + if (__pSlider->GetStyle() & _SLIDER_STYLE_OVERLAY) + { + __pSliderOverlay->Close(); + } + } + } + else if (__isSliderPressed == true) // pressed + { + pHandleBitmap = __pHandlePressedBitmap; + pHandleEffectBitmap = __pHandlePressedEffectBitmap; + } + else if (__pSlider->IsFocused() == true) + { + pHandleBitmap = __pHandleHighlightedBitmap; + pHandleEffectBitmap = __pHandleHighlightedEffectBitmap; + } + else //(__isSliderPressed == false) // normal state + { + pHandleBitmap = __pHandleNormalBitmap; + pHandleEffectBitmap = __pHandleNormalEffectBitmap; + } + + int minValue = __pSliderModel->GetMinValue(); + int maxValue = __pSliderModel->GetMaxValue(); + + __barRect = Rectangle(__barBgRect.x, __barBgRect.y, __sliderX, __barBgRect.height); + + if (__isSliderPressed == false && (maxValue - minValue) != 0) + { + __barRect.width = ((__barBgRect.width - __handleRect.width) * (__pSliderModel->GetValue() - minValue)) / (maxValue - minValue); + __handleX = ((__touchRect.width - __handleRect.width) * (__pSliderModel->GetValue() - minValue)) / (maxValue - minValue); + } + + if (__pSlider->GetBarColor() != __currentBarColor) + { + pReplacementBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pResourceBarBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pSlider->GetBarColor()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pReplacementBitmap != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pBarColorReplacementBitmap; + __pBarColorReplacementBitmap = null; + + __pBarColorReplacementBitmap = pReplacementBitmap; + __currentBarColor = __pSlider->GetBarColor(); + } + + // Redrawing twice is required because, when slider is disabled we are applying alpha channel to the bar + // which will show the previously drawn portion. + + __pBarBgColorReplacementBitmap->SetAlphaConstant(0xFF); + __pBarColorReplacementBitmap->SetAlphaConstant(0xFF); + + DrawBitmap(canvas, __barBgRect, __pBarBgColorReplacementBitmap); + DrawBitmap(canvas, __barBgRect, __pBarBgResourceEffectBitmap); + + + if (__pSlider->IsEnabled() == false) // disabled + { + __pBarBgColorReplacementBitmap->SetAlphaConstant(0x4C); + __pBarColorReplacementBitmap->SetAlphaConstant(0x4C); + } + else + { + opacity = __pSlider->GetBarColor().GetAlpha(); + __pBarBgColorReplacementBitmap->SetAlphaConstant(opacity); + __pBarColorReplacementBitmap->SetAlphaConstant(opacity); + } + + DrawBitmap(canvas, __barBgRect, __pBarBgColorReplacementBitmap); + DrawBitmap(canvas, __barBgRect, __pBarBgResourceEffectBitmap); + + DrawBitmap(canvas, Rectangle(__barRect.x, __barRect.y, (__barRect.width + __handleRect.width / 2), __barRect.height), __pBarColorReplacementBitmap); + DrawBitmap(canvas, Rectangle(__barRect.x, __barRect.y, (__barRect.width + __handleRect.width / 2), __barRect.height), __pBarResourceEffectBitmap); + + __handleRect.x = __touchRect.x + __handleX; + __handleRect.y = __touchRect.y; + + if (__handleRect.x < __touchRect.x ) + { + __handleRect.x = __touchRect.x; + } + + if (__handleRect.x + __handleRect.width > __touchRect.x + __touchRect.width ) + { + __handleRect.x = __touchRect.x + __touchRect.width - __handleRect.width; + } + + Canvas* pHandleCanvas = __pSlider->GetHandleCanvasN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pHandleCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pHandleCanvas->SetBackgroundColor(0x00000000); + pHandleCanvas->Clear(); + + if (pHandleEffectBitmap != null) // drawing the default bitmap + { + r = DrawBitmap(*pHandleCanvas, Rectangle(0, 0, __handleRect.width, __handleRect.height), pHandleBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = DrawBitmap(*pHandleCanvas, Rectangle(0, 0, __handleRect.width, __handleRect.height), pHandleEffectBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + bitmapWidth = pHandleBitmap->GetWidth(); + bitmapHeight = pHandleBitmap->GetHeight(); + + if (pHandleBitmap->IsNinePatchedBitmap() == false) + { + // to clip the center portion of the larger bitmap. + if( bitmapWidth > __handleRect.width ) + { + bitmapPositionX = (bitmapWidth / 2) - (__handleRect.width / 2); + bitmapWidth = __handleRect.width; + } + + if( bitmapHeight > __handleRect.height ) + { + bitmapPositionY = (bitmapHeight / 2) - (__handleRect.height / 2); + bitmapHeight = __handleRect.height; + } + + r = pHandleCanvas->DrawBitmap(Rectangle(0, 0, __handleRect.width, __handleRect.height), *pHandleBitmap, Rectangle(bitmapPositionX, bitmapPositionY, bitmapWidth, bitmapHeight)); + } + else + { + r = pHandleCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, __handleRect.width, __handleRect.height), *pHandleBitmap); + } + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pSlider->UpdateHandle(__handleRect); + if (r != E_SUCCESS) + { + SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + delete pHandleCanvas; + pHandleCanvas = null; + + return r; + +CATCH: + delete pHandleCanvas; + pHandleCanvas = null; + + return r; +} + +result +_SliderPresenter::DrawSliderBarNumber(int value) +{ + result r = E_SUCCESS; + int handleNumberSize = 0; + Color textColor; + String text; + int valueLength = 0; + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + if (__pSlider->IsEnabled() == false) // disabled + { + textColor = __handleTextDisabledColor; + } + else if (__pSlider->IsFocused() == true) + { + textColor = __handleTextHighlightedColor; + } + else if ((__isSliderPressed == true) && !(__pSlider->GetStyle() & _SLIDER_STYLE_OVERLAY)) + { + if(!__isCustomPressedTextColor) + { + r = GET_COLOR_CONFIG(SLIDER::OVERLAY_TEXT_NORMAL, __handleTextPressedColor); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + textColor = __handleTextPressedColor; + } + else + { + textColor = __handleTextColor; + } + + Dimension textDim(0, 0); + text.Append(value); + valueLength = text.GetLength(); + + if (valueLength == SLIDER_HANDLE_THREE_DIGIT) + { + r = GET_SHAPE_CONFIG(SLIDER::HANDLE_THREE_DIGIT_TEXT_SIZE, orientation, handleNumberSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else if (valueLength == SLIDER_HANDLE_TWO_DIGIT) + { + r = GET_SHAPE_CONFIG(SLIDER::HANDLE_TWO_DIGIT_TEXT_SIZE, orientation, handleNumberSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = GET_SHAPE_CONFIG(SLIDER::HANDLE_ONE_DIGIT_TEXT_SIZE, orientation, handleNumberSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + (_FontImpl::GetInstance(*__pFont))->SetSize(handleNumberSize); + + Canvas* pHandleCanvas = __pSlider->GetHandleCanvasN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pHandleCanvas != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pHandleCanvas->SetFont(*__pFont); + __pFont->GetTextExtent(text, valueLength, textDim); + + Point textPoint; + textPoint.x = (__handleRect.width - textDim.width) / 2; + textPoint.y = (__handleRect.height - textDim.height) / 2; + + pHandleCanvas->SetForegroundColor(textColor); + pHandleCanvas->DrawText(textPoint, text); + + delete pHandleCanvas; + pHandleCanvas = null; + + return r; +} + +result +_SliderPresenter::DrawTitleText(Canvas& canvas) +{ + result r = E_SUCCESS; + + TextSimple* pSimpleTitleText = null; + int titleTextSize = 0; + int titleLength = 0; + Rectangle titleTextBounds; + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + titleLength = __pSlider->GetTitleText().GetLength(); + SysTryReturn(NID_UI_CTRL, titleLength != 0, E_SUCCESS, E_SUCCESS, "Title text is empty"); + + r = GET_SHAPE_CONFIG(SLIDER::TITLE_TEXT_SIZE, orientation, titleTextSize); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + (_FontImpl::GetInstance(*__pFont))->SetSize(titleTextSize); + + titleTextBounds = GetTitleTextBounds(); + + if (__pTitleTextObject == null) + { + __pTitleTextObject = new (std::nothrow) TextObject(); + SysTryReturn(NID_UI_CTRL, __pTitleTextObject != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + __pTitleTextObject->Construct(); + } + + pSimpleTitleText = new (std::nothrow) TextSimple(const_cast(__pSlider->GetTitleText().GetPointer()), __pSlider->GetTitleText().GetLength()); + + __pTitleTextObject->RemoveAll(); + __pTitleTextObject->AppendElement(*pSimpleTitleText); + __pTitleTextObject->SetForegroundColor(__pSlider->GetTitleTextColor(), 0, __pTitleTextObject->GetTextLength()); + __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pTitleTextObject->SetBounds(GetTitleTextBounds()); + __pTitleTextObject->Compose(); + + __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __pTitleTextObject->SetFont(__pFont, 0, __pTitleTextObject->GetTextLength()); + __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(canvas)); + + return r; +} + +result +_SliderPresenter::DrawIcon(Canvas& canvas) +{ + result r = E_SUCCESS; + + Bitmap* pLeftBitmap = __pSlider->GetIcon(ICON_POSITION_LEFT); + Bitmap* pRightBitmap = __pSlider->GetIcon(ICON_POSITION_RIGHT); + + if (pLeftBitmap != null) + { + r = DrawBitmap(canvas, GetIconBounds(ICON_POSITION_LEFT), pLeftBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (pRightBitmap != null) + { + r = DrawBitmap(canvas, GetIconBounds(ICON_POSITION_RIGHT), pRightBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_SliderPresenter::DrawSliderOverlay(int value) +{ + result r = E_SUCCESS; + + Rectangle absBounds = __pSlider->GetAbsoluteBounds(); + r = __pSliderOverlay->SetSliderRect(absBounds, __touchRect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pSliderOverlay->DrawSliderOverlay(__touchRect.x + __handleX, __handleRect.width, value); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_SliderPresenter::DrawBitmap(Canvas& canvas, const Rectangle& bounds, Bitmap* pBitmap) +{ + result r = E_SUCCESS; + + if (pBitmap->IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = canvas.DrawBitmap(bounds, *pBitmap); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + return r; +} + + +Rectangle +_SliderPresenter::GetTitleTextBounds(void) const +{ + Rectangle titleTextBounds; + int topMargin = 0; + + result r = E_SUCCESS; + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + r = GET_SHAPE_CONFIG(SLIDER::TITLE_TEXT_POSITION_X, orientation, titleTextBounds.x); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Rectangle(), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::TITLE_TEXT_POSITION_Y, orientation, titleTextBounds.y); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Rectangle(), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::BAR_TOP_MARGIN, orientation, topMargin); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Rectangle(), r, "[%s] Propagating.", GetErrorMessage(r)); + + titleTextBounds.y = titleTextBounds.y + topMargin; + + r = GET_SHAPE_CONFIG(SLIDER::TITLE_TEXT_HEIGHT, orientation, titleTextBounds.height); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Rectangle(), r, "[%s] Propagating.", GetErrorMessage(r)); + + titleTextBounds.width = __pSlider->GetBounds().width - titleTextBounds.x; + + return titleTextBounds; +} + +Rectangle +_SliderPresenter::GetTouchBounds(void) const +{ + return __touchRect; +} + +Rectangle +_SliderPresenter::GetIconBounds(IconPosition iconPosition) const +{ + result r = E_SUCCESS; + + Rectangle iconBounds; + int iconSideMargin = 0; + int barHeight = 0; + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + r = GET_SHAPE_CONFIG(SLIDER::ICON_WIDTH, orientation, iconBounds.width); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Rectangle(), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::ICON_HEIGHT, orientation, iconBounds.height); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Rectangle(), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::ICON_LEFT_MARGIN, orientation, iconSideMargin); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Rectangle(), r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_SHAPE_CONFIG(SLIDER::BAR_HEIGHT, orientation, barHeight);; + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Rectangle(), r, "[%s] Propagating.", GetErrorMessage(r)); + + iconBounds.y = __barBgRect.y + ((barHeight - iconBounds.height) / 2); + + if (iconPosition == ICON_POSITION_LEFT) + { + iconBounds.x = iconSideMargin; + } + else + { + iconBounds.x = __rect.width - (iconSideMargin + iconBounds.width); + } + + return iconBounds; +} + +bool +_SliderPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__pSlider != &source) + { + return false; + } + + Point point = touchinfo.GetCurrentPosition(); + + __isBubblingBlocked = false; + + if (__pSlider->IsEnabled() == true && __handleRect.Contains(point) == true) + { + int candidateValue = CalculateSliderValue(point.x, point.x - __handleRect.x); + + __pSliderModel->SetValue(candidateValue); + __pSlider->SetAccessibilityElementValue(); + + __isSliderPressed = true; + __isBubblingBlocked = true; + + if (__pSlider->GetStyle() & _SLIDER_STYLE_OVERLAY) + { + __pSliderOverlay->Open(false); + } + + __pSlider->Invalidate(); + } + + return __isBubblingBlocked; +} + +bool +_SliderPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__pSlider != &source) + { + return false; + } + + Point point = touchinfo.GetCurrentPosition(); + bool isBubblingBlocked = __isBubblingBlocked; + + if (__isSliderPressed == true) + { + __isSliderPressed = false; + + int candidateValue = CalculateSliderValue(point.x, point.x - __handleRect.x); + + __pSliderModel->SetValue(candidateValue); + __pSlider->SetAccessibilityElementValue(); + __pSlider->Invalidate(); + + if (__pSlider->GetStyle() & _SLIDER_STYLE_OVERLAY) + { + __pSliderOverlay->Close(); + } + + // Adjustment Event Fire + _AdjustmentEvent* pAdjustmentEvent = dynamic_cast <_AdjustmentEvent*>(__pSlider->GetAdjustmentEvent()); + if (pAdjustmentEvent != null) + { + Tizen::Base::Runtime::IEventArg* pEventArg = _AdjustmentEvent::CreateAdjustmentEventArgN(candidateValue); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pEventArg != null, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + pAdjustmentEvent->Fire(*pEventArg); + } + } + + return isBubblingBlocked; +} + +bool +_SliderPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__pSlider != &source) + { + return false; + } + + Point point = touchinfo.GetCurrentPosition(); + bool isBubblingBlocked = __isBubblingBlocked; + + if (__isSliderPressed == false) + { + return false; + } + + if (__pSlider->IsEnabled() == false) + { + __isSliderPressed = false; + return false; + } + + int handleHalfWidth = __handleRect.width / 2; + int oldValue = __pSliderModel->GetValue(); + int candidateValue = CalculateSliderValue(point.x, handleHalfWidth); + + __pSliderModel->SetValue(candidateValue); + __pSlider->SetAccessibilityElementValue(); + + __pSlider->Invalidate(); + + if (oldValue != candidateValue) + { + // Slider Event Fire + _SliderEvent* pSliderEvent = dynamic_cast <_SliderEvent*>(__pSlider->GetSliderEvent()); + if (pSliderEvent != null) + { + Tizen::Base::Runtime::IEventArg* pEventArg = _SliderEvent::CreateSliderEventArgN(candidateValue); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pEventArg != null, true, r, "[%s] Propagating.", GetErrorMessage(r)); + + pSliderEvent->Fire(*pEventArg); + } + } + + return isBubblingBlocked; +} + +bool +_SliderPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return OnTouchReleased(source, touchinfo); +} + +void +_SliderPresenter::OnBoundsChanged(void) +{ + __isNeedToBeUpdated = true; + Resize(); + + return; +} + +void +_SliderPresenter::OnFontChanged(Font* pFont) +{ + __pFont = pFont; + __isNeedToBeUpdated = true; + + if(__pSliderOverlay != null) + __pSliderOverlay->SetFont(pFont); + + return; +} + +void +_SliderPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = FONT_STYLE_BOLD; + size = __fontSize; + return; +} + +void +_SliderPresenter::SetMinValue(int minValue) +{ + __pSliderModel->SetMinValue(minValue); + + if (__pSliderModel->GetValue() < minValue) + { + __pSliderModel->SetValue(minValue); + } + + return; +} + +void +_SliderPresenter::SetMaxValue(int maxValue) +{ + __pSliderModel->SetMaxValue(maxValue); + + if (__pSliderModel->GetValue() > maxValue) + { + __pSliderModel->SetValue(maxValue); + } + + return; +} + +int +_SliderPresenter::GetMinValue(void) const +{ + return __pSliderModel->GetMinValue(); +} + +int +_SliderPresenter::GetMaxValue(void) const +{ + return __pSliderModel->GetMaxValue(); +} + +void +_SliderPresenter::SetValue(int value) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __isSliderPressed == false, E_SYSTEM, "[E_SYSTEM] Failed to set value of slider."); + + int minValue = __pSliderModel->GetMinValue(); + int maxValue = __pSliderModel->GetMaxValue(); + + if (value > maxValue) + { + value = maxValue; + } + else if (value < minValue) + { + value = minValue; + } + + __pSliderModel->SetValue(value); + + return; +} + +int +_SliderPresenter::GetValue(void) const +{ + return __pSliderModel->GetValue(); +} + +void +_SliderPresenter::SetNeedUpdate(void) +{ + __isNeedToBeUpdated = true; + return; +} + +void +_SliderPresenter::SetGroupStyle(GroupStyle groupStyle) +{ + __groupStyle = groupStyle; + return; +} + +result +_SliderPresenter::SetThumbBitmap(SliderThumbStatus status, const Bitmap& bitmap) +{ + Bitmap* pThumbBitmap = null; + result r = E_SUCCESS; + + pThumbBitmap = _BitmapImpl::CloneN(bitmap); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pThumbBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + switch (status) + { + case SLIDER_THUMB_STATUS_PRESSED: + + delete __pHandlePressedEffectBitmap; + __pHandlePressedEffectBitmap = null; + + delete __pHandlePressedBitmap; + __pHandlePressedBitmap = pThumbBitmap; + break; + + case SLIDER_THUMB_STATUS_DISABLED: + + delete __pHandleDisabledEffectBitmap; + __pHandleDisabledEffectBitmap = null; + + delete __pHandleDisabledBitmap; + __pHandleDisabledBitmap = pThumbBitmap; + break; + + case SLIDER_THUMB_STATUS_HIGHLIGHTED: + + delete __pHandleHighlightedEffectBitmap; + __pHandleHighlightedEffectBitmap = null; + + delete __pHandleHighlightedEffectBitmap; + __pHandleHighlightedEffectBitmap = pThumbBitmap; + break; + + case SLIDER_THUMB_STATUS_NORMAL: + // fall through + default: + + delete __pHandleNormalEffectBitmap; + __pHandleNormalEffectBitmap = null; + + delete __pHandleNormalBitmap; + __pHandleNormalBitmap = pThumbBitmap; + + __handleRect.width = __pHandleNormalBitmap->GetWidth(); + __handleRect.height = __pHandleNormalBitmap->GetHeight(); + + _VisualElement* pHandle = __pSlider->GetHandle(); + pHandle->SetBounds(FloatRectangle(__handleRect.x, __handleRect.y, __handleRect.width, __handleRect.height)); + + __isCustomHandle = true; + break; + + } + + Resize(); + return r; +} + +void +_SliderPresenter::SetThumbTextColor(SliderThumbStatus status, const Color& color) +{ + switch (status) + { + case SLIDER_THUMB_STATUS_PRESSED: + __handleTextPressedColor = color; + __isCustomPressedTextColor = true; + break; + + case SLIDER_THUMB_STATUS_DISABLED: + __handleTextDisabledColor = color; + break; + + case SLIDER_THUMB_STATUS_HIGHLIGHTED: + __handleTextHighlightedColor = color; + break; + + case SLIDER_THUMB_STATUS_NORMAL: + // fall through + default: + __handleTextColor = color; + break; + } + + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SplitPanel.cpp b/src/ui/controls/FUiCtrl_SplitPanel.cpp new file mode 100644 index 0000000..d121bde --- /dev/null +++ b/src/ui/controls/FUiCtrl_SplitPanel.cpp @@ -0,0 +1,888 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SplitPanel.cpp + * @brief This is the implementation file for the _SplitPanel class. + */ + +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_TouchTapGestureDetector.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUiCtrl_SplitPanel.h" +#include "FUiCtrl_SplitPanelPresenter.h" + +using namespace Tizen::Ui; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_SplitPanel::_SplitPanel() + : __pSplitPanelPresenter(null) + , __pTapGesture(null) + , __pFirstPane(null) + , __pSecondPane(null) + , __splitPanelDividerDirection(SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + , __pSplitPanelEvent(null) + , __dividerTapCount(0) + , __pAccessibilityElement(null) + , __pDividerVisualElement(null) + , __isDividerPositionInitialized(false) + , __isDividerMaximumPositionInitialized(false) + , __isDividerMinimumPositionInitialized(false) + , __isFirstTimeOrientationChanged(true) +{ + for (int i=0; i < _SPLIT_PANEL_DIVIDER_STATE; i++) + { + __dividerPosition[i] = 0; + __minimumDividerPosition[i] = 0; + __maximumDividerPosition[i] = 0; + } +} + +_SplitPanel* +_SplitPanel::CreateSplitPanelN(const Rectangle& rect, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection) +{ + result r = E_SUCCESS; + + _SplitPanel* pSplitPanel = new (std::nothrow) _SplitPanel; + SysTryReturn(NID_UI_CTRL, pSplitPanel, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = pSplitPanel->Construct(splitPanelDividerStyle, splitPanelDividerDirection); + if (r != E_SUCCESS) + { + delete pSplitPanel; + pSplitPanel = null; + return null; + } + pSplitPanel->AcquireHandle(); + pSplitPanel->SetDividerDirection(splitPanelDividerDirection); + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + int dividerThickness = 0; + GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, dividerThickness); + + pSplitPanel->__maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = rect.width - dividerThickness; + pSplitPanel->__maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = rect.width - dividerThickness; + pSplitPanel->__maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = rect.height - dividerThickness; + pSplitPanel->__maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = rect.width - dividerThickness; + + pSplitPanel->__dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = rect.width / 2; + pSplitPanel->__dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = rect.width / 2; + pSplitPanel->__dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = rect.height / 2; + pSplitPanel->__dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = rect.height / 2; + + pSplitPanel->__pTapGesture = new (std::nothrow) _TouchTapGestureDetector; + SysTryCatch(NID_UI_CTRL, pSplitPanel->__pTapGesture, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pSplitPanel->AddGestureDetector(*(pSplitPanel->__pTapGesture)); + r = pSplitPanel->__pTapGesture->AddGestureListener(*pSplitPanel); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pSplitPanel->SetBackgroundColor(Color(0,0,0,0)); + + if (likely(_AccessibilityManager::IsActivated()) && pSplitPanel->GetAccessibilityContainer()) + { + pSplitPanel->GetAccessibilityContainer()->Activate(true); + } + + return pSplitPanel; + +CATCH: + if (pSplitPanel->__pTapGesture != null) + { + pSplitPanel->__pTapGesture->RemoveGestureListener(*pSplitPanel); + pSplitPanel->RemoveGestureDetector(*pSplitPanel->__pTapGesture); + + delete pSplitPanel->__pTapGesture; + pSplitPanel->__pTapGesture = null; + } + + delete pSplitPanel; + return null; +} + +result +_SplitPanel::Construct(SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection) +{ + result r = E_SUCCESS; + + __pDividerVisualElement = new (std::nothrow) VisualElement(); + SysTryReturnResult(NID_UI_CTRL, __pDividerVisualElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + r = __pDividerVisualElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct divider visual element.", GetErrorMessage(r)); + + __pDividerVisualElement->SetShowState(true); + __pDividerVisualElement->SetImplicitAnimationEnabled(false); + __pDividerVisualElement->SetClipChildrenEnabled(false); + + r = GetVisualElement()->AttachChild(*__pDividerVisualElement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach divider visual element.", GetErrorMessage(r)); + + __pSplitPanelPresenter = new (std::nothrow) _SplitPanelPresenter; + SysTryCatch(NID_UI_CTRL, __pSplitPanelPresenter != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pSplitPanelPresenter->Construct(*this, splitPanelDividerStyle, splitPanelDividerDirection); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct presenter.", GetErrorMessage(r)); + + return r; + +CATCH: + if (__pDividerVisualElement) + { + __pDividerVisualElement->Destroy(); + __pDividerVisualElement = null; + } + + delete __pSplitPanelPresenter; + __pSplitPanelPresenter = null; + + return r; +} + +_SplitPanel::~_SplitPanel(void) +{ + if (__pSplitPanelPresenter) + { + delete __pSplitPanelPresenter; + __pSplitPanelPresenter = null; + } + + if (__pSplitPanelEvent) + { + delete __pSplitPanelEvent; + __pSplitPanelEvent = null; + } + + if (__pTapGesture) + { + __pTapGesture->RemoveGestureListener(*this); + RemoveGestureDetector(*__pTapGesture); + + delete __pTapGesture; + __pTapGesture = null; + } + + if (__pAccessibilityElement) + { + __pAccessibilityElement->Activate(false); + __pAccessibilityElement = null; + } + + if (__pDividerVisualElement) + { + __pDividerVisualElement->Destroy(); + __pDividerVisualElement = null; + } + + ClearLastResult(); +} + +result +_SplitPanel::SetPresenter(const _SplitPanelPresenter& splitPanelPresenter) +{ + __pSplitPanelPresenter = const_cast<_SplitPanelPresenter*>(&splitPanelPresenter); + return E_SUCCESS; +} + +result +_SplitPanel::AddSplitPanelEventListener(const _ISplitPanelEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pSplitPanelEvent == null) + { + __pSplitPanelEvent = _SplitPanelEvent::CreateInstanceN(*this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pSplitPanelEvent, r, r, "[%s] Propagating.", GetErrorMessage(r)) + + __pSplitPanelEvent->AddListener(listener); + } + + return r; +} + +result +_SplitPanel::RemoveSplitPanelEventListener(const _ISplitPanelEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pSplitPanelEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] System error occurred.") + + __pSplitPanelEvent->RemoveListener(listener); + + return E_SUCCESS; +} + +void +_SplitPanel::OnDraw(void) +{ + __pSplitPanelPresenter->Draw(); + + return; +} + +void +_SplitPanel::OnChangeLayout(_ControlOrientation orientation) +{ + if (__isFirstTimeOrientationChanged) + { + Rectangle bounds = GetBounds(); + + int dividerThickness = 0; + GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, dividerThickness); + + if (!__isDividerMaximumPositionInitialized) + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = bounds.width - dividerThickness; + __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = bounds.width - dividerThickness; + } + else + { + __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = bounds.width - dividerThickness; + __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = bounds.width - dividerThickness; + } + } + + if (!__isDividerPositionInitialized) + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = bounds.width / 2; + __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = bounds.height / 2; + } + else + { + __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = bounds.width / 2; + __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = bounds.height / 2; + } + } + + __isFirstTimeOrientationChanged = false; + } + + __pSplitPanelPresenter->OnChangeLayout(orientation); + + return; +} + +void +_SplitPanel::OnBoundsChanged(void) +{ + Rectangle bounds = GetBounds(); + + int dividerThickness = 0; + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, dividerThickness); + + if (GetMaximumDividerPosition() > (bounds.width - dividerThickness)) + { + SetMaximumDividerPosition(bounds.width - dividerThickness); + } + + __pSplitPanelPresenter->OnBoundsChanged(); + + return; +} + +bool +_SplitPanel::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + return __pSplitPanelPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_SplitPanel::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + return __pSplitPanelPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_SplitPanel::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + return __pSplitPanelPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_SplitPanel::OnTouchCanceled(const _Control & source, const _TouchInfo & touchinfo) +{ + return __pSplitPanelPresenter->OnTouchCanceled(source, touchinfo); +} + +bool +_SplitPanel::OnTapGestureDetected(_TouchTapGestureDetector& gesture) +{ + if (__pSplitPanelPresenter == null) + { + return true; + } + + return __pSplitPanelPresenter->OnTapGestureDetected(gesture); +} + +bool +_SplitPanel::OnTapGestureCanceled(_TouchTapGestureDetector& gesture) +{ + return __pSplitPanelPresenter->OnTapGestureCanceled(gesture); +} + +result +_SplitPanel::SetPane(_Control* pControl, SplitPanelPaneOrder paneOrder) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, __pSplitPanelPresenter != null, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error occurred."); + + if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST) + { + __pFirstPane = pControl; + } + else + { + __pSecondPane = pControl; + } + + r = AttachChild(*pControl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return E_SUCCESS; +} + +_Control* +_SplitPanel::GetPane(SplitPanelPaneOrder paneOrder) const +{ + SysTryReturn(NID_UI_CTRL, __pSplitPanelPresenter != null, null, E_SYSTEM, + "[E_SYSTEM] System error occurred."); + + if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST) + { + return const_cast <_Control*>(__pFirstPane); + } + else + { + return const_cast <_Control*>(__pSecondPane); + } +} + +result +_SplitPanel::SetDividerStyle(SplitPanelDividerStyle splitPanelDividerStyle) +{ + SysTryReturn(NID_UI_CTRL, __pSplitPanelPresenter != null, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] System error occurred."); + + __pSplitPanelPresenter->SetDividerStyle(splitPanelDividerStyle); + + return E_SUCCESS; +} + +SplitPanelDividerStyle +_SplitPanel::GetDividerStyle(void) const +{ + return __pSplitPanelPresenter->GetDividerStyle(); +} + +result +_SplitPanel::SetDividerPosition(int position) +{ + const int width = GetBounds().width; + + if ((0 > position) || (width < position)) + { + return E_OUT_OF_RANGE; + } + + if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE) + { + if ((GetMinimumDividerPosition() > position) || (GetMaximumDividerPosition() < position)) + { + return E_OUT_OF_RANGE; + } + } + + if (!__isDividerPositionInitialized) + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = position; + __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = position; + } + else + { + __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = position; + __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = position; + } + + __isDividerPositionInitialized = true; + } + else + { + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = position; + } + else + { + __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = position; + } + } + else + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = position; + } + else + { + __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = position; + } + } + } + + __pSplitPanelPresenter->RecalcSplitPanel(); + + return E_SUCCESS; +} + +int +_SplitPanel::GetDividerPosition(void) const +{ + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + return __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE]; + } + else + { + return __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE]; + } + } + else + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + return __dividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT]; + } + else + { + return __dividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT]; + } + } +} + +result +_SplitPanel::SetMaximumDividerPosition(int position) +{ + if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_FIXED) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] System error occurred. This functionality is not supported for divider style fixed"); + return E_SUCCESS; + } + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + const int width = GetBounds().width; + int margin = 0; + GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER, orientation, margin); + + if ((0 > position) || ((width - margin) < position) || (position < GetMinimumDividerPosition())) + { + return E_OUT_OF_RANGE; + } + + if (!__isDividerMaximumPositionInitialized) + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = position; + __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = position; + } + else + { + __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = position; + __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = position; + } + + __isDividerMaximumPositionInitialized = true; + } + else + { + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = position; + } + else + { + __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = position; + } + } + else + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = position; + } + else + { + __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = position; + } + } + } + + if (GetDividerPosition() > position) + { + SetDividerPosition(position); + } + + return E_SUCCESS; +} + +int +_SplitPanel::GetMaximumDividerPosition(void) const +{ + if (GetDividerStyle() != SPLIT_PANEL_DIVIDER_STYLE_FIXED) + { + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + return __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE]; + } + else + { + return __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE]; + } + } + else + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + return __maximumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT]; + } + else + { + return __maximumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT]; + } + } + + } + + return GetBounds().width; +} + +result +_SplitPanel::SetMinimumDividerPosition(int position) +{ + if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_FIXED) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] System error occurred. This functionality is not supported for divider style fixed"); + return E_SUCCESS; + } + + const int width = GetBounds().width; + + if ((0 > position) || (width < position) || (position > GetMaximumDividerPosition())) + { + return E_OUT_OF_RANGE; + } + + if (!__isDividerMinimumPositionInitialized) + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = position; + __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = position; + } + else + { + __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = position; + __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = position; + } + + __isDividerMinimumPositionInitialized = true; + } + else + { + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE] = position; + } + else + { + __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE] = position; + } + } + else + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT] = position; + } + else + { + __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT] = position; + } + } + } + + if (GetDividerPosition() < position) + { + SetDividerPosition(position); + } + + return E_SUCCESS; +} + +int +_SplitPanel::GetMinimumDividerPosition(void) const +{ + if (GetDividerStyle() != SPLIT_PANEL_DIVIDER_STYLE_FIXED) + { + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + return __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE]; + } + else + { + return __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE]; + } + } + else + { + if (GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + return __minimumDividerPosition[_SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT]; + } + else + { + return __minimumDividerPosition[_SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT]; + } + } + + } + + return 0; +} + +void +_SplitPanel::SetDividerDirection(SplitPanelDividerDirection dividerDirection) +{ + __splitPanelDividerDirection = dividerDirection; + + return; +} + +SplitPanelDividerDirection +_SplitPanel::GetDividerDirection(void) const +{ + SetLastResult(E_SUCCESS); + + return __splitPanelDividerDirection; +} + +result +_SplitPanel::MaximizePane(SplitPanelPaneOrder paneOrder) +{ + SysTryReturn(NID_UI_CTRL, __pSplitPanelPresenter != null, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] System error occurred."); + + __pSplitPanelPresenter->MaximizePane(paneOrder); + + return E_SUCCESS; +} + +bool +_SplitPanel::IsPaneMaximized(SplitPanelPaneOrder paneOrder) const +{ + SysTryReturn(NID_UI_CTRL, __pSplitPanelPresenter != null, false, E_SYSTEM, + "[E_SYSTEM] System error occurred."); + + return __pSplitPanelPresenter->IsPaneMaximized(paneOrder); +} + +result +_SplitPanel::RestorePane(void) +{ + SysTryReturn(NID_UI_CTRL, __pSplitPanelPresenter != null, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] System error occurred."); + + __pSplitPanelPresenter->RestorePane(); + + return E_SUCCESS; +} + +result +_SplitPanel::SendSplitPanelEvent(_SplitPanelEventStatus status) +{ + result r = E_SUCCESS; + + if (__pSplitPanelEvent) + { + IEventArg* pEventArg = _SplitPanelEvent::CreateSplitPanelEventArgN(status); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pEventArg, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSplitPanelEvent->Fire(*pEventArg); + } + + return r; +} + +void +_SplitPanel::SetTapCount(int count) +{ + __dividerTapCount = count; + + return; +} + +int +_SplitPanel::GetTapCount(void) const +{ + return __dividerTapCount; +} + +result +_SplitPanel::OnAttachedToMainTree(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return E_SUCCESS; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if (pContainer) + { + if (__pDividerVisualElement) + { + Rectangle dividerRect = __pSplitPanelPresenter->GetDividerRectangle(); + String hintText = L""; + + if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_FIXED) + { + hintText = String(L"Drag scroll Fixed"); + } + else + { + hintText = String(L"Drag scroll, double tap and move to adjust split area"); + } + + __pAccessibilityElement = new _AccessibilityElement(true); + SysTryReturn(NID_UI_CTRL, __pAccessibilityElement, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pAccessibilityElement->SetBounds(dividerRect); + __pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_NONE); + __pAccessibilityElement->SetHint(hintText); + __pAccessibilityElement->SetLabel(L""); + __pAccessibilityElement->SetName(L"SplitPanelDivider"); + + pContainer->AddElement(*__pAccessibilityElement); + pContainer->AddListener(*this); + } + } + + return E_SUCCESS; +} + +VisualElement* +_SplitPanel::GetDividerVisualElement(void) +{ + return __pDividerVisualElement; +} + +void +_SplitPanel::SetDividerVisualElementBounds(Rectangle& bounds) +{ + if (__pDividerVisualElement) + { + __pDividerVisualElement->SetBounds(FloatRectangle(bounds.x, bounds.y, bounds.width, bounds.height)); + + if (likely(_AccessibilityManager::IsActivated()) && __pAccessibilityElement) + { + __pAccessibilityElement->SetBounds(bounds); + } + } + + return; +} + +bool +_SplitPanel::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + SetDividerPosition(GetDividerPosition() + 5); + + Invalidate(); + return true; +} + +bool +_SplitPanel::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + + SetDividerPosition(GetDividerPosition() - 5); + + Invalidate(); + return true; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_SplitPanelEvent.cpp b/src/ui/controls/FUiCtrl_SplitPanelEvent.cpp new file mode 100644 index 0000000..37c9195 --- /dev/null +++ b/src/ui/controls/FUiCtrl_SplitPanelEvent.cpp @@ -0,0 +1,175 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include "FUiCtrl_ISplitPanelEventListener.h" +#include "FUiCtrl_SplitPanelEvent.h" +#include "FUiCtrl_SplitPanel.h" + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _SplitPanelEventArg + * @brief This class is used as the argument to action event listener. + * + * This class is used as the argument to splitpanel event listener. When an splitpanel event is generated + * (such as when a splitpanel is pressed) the SplitPanelEvent calls SplitPanelEventListener's OnActionPerformed + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the action ID. + */ +class _OSP_EXPORT_ _SplitPanelEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] status + */ + _SplitPanelEventArg(_SplitPanelEventStatus status); + + /** + * This is the class destructor. + * + */ + virtual ~_SplitPanelEventArg(void); + + +// Access +public: + /** + * This method returns the status which the event initially occurred. + * + * @return See the comment above. + */ + _SplitPanelEventStatus GetStatus(void) const; + + +// Attribute +private: + /** + * Event status. + */ + _SplitPanelEventStatus __status; +}; + +_SplitPanelEventArg::_SplitPanelEventArg(_SplitPanelEventStatus status) + : __status(status) +{ + +} + +_SplitPanelEventArg::~_SplitPanelEventArg(void) +{ + +} + +_SplitPanelEventStatus +_SplitPanelEventArg::GetStatus(void) const +{ + return __status; +} + +_SplitPanelEvent::_SplitPanelEvent(const _SplitPanel& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_SplitPanelEvent::~_SplitPanelEvent(void) +{ + +} + +_SplitPanelEvent* +_SplitPanelEvent::CreateInstanceN(const _SplitPanel& source) +{ + _SplitPanelEvent* pSplitPanelEvent = new (std::nothrow) _SplitPanelEvent(source); + SysTryReturn(NID_UI_CTRL, pSplitPanelEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pSplitPanelEvent; + +CATCH: + delete pSplitPanelEvent; + return null; +} + +const _SplitPanel* +_SplitPanelEvent::GetSource(void) const +{ + return __pSource; +} + +void +_SplitPanelEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to _IActionEventListener + _ISplitPanelEventListener* pSplitPanelListner = dynamic_cast <_ISplitPanelEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pSplitPanelListner != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid listener was given.\n"); + + // cast to _SplitPanelEventArg + const _SplitPanelEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + _SplitPanel* pSource = null; + pSource = const_cast <_SplitPanel*>(__pSource); + SysTryReturnVoidResult(NID_UI_CTRL, pSource != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + // call cursor change event listener method + _SplitPanelEventStatus status= pArg->GetStatus(); + + if (status == _SPLIT_PANEL_EVENT_DIVIDER_POSITION_CHANGE) + { + pSplitPanelListner->OnDividerPositionChanged(*pSource, pSource->GetDividerPosition()); + } + else + { + pSplitPanelListner->OnDividerDoublePressed(*pSource); + } +} + +IEventArg* +_SplitPanelEvent::CreateSplitPanelEventArgN(_SplitPanelEventStatus status) +{ + _SplitPanelEventArg* pEventArg = new (std::nothrow) _SplitPanelEventArg(status); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SplitPanelImpl.cpp b/src/ui/controls/FUiCtrl_SplitPanelImpl.cpp new file mode 100644 index 0000000..5d58d08 --- /dev/null +++ b/src/ui/controls/FUiCtrl_SplitPanelImpl.cpp @@ -0,0 +1,435 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SplitPanelImpl.cpp + * @brief This is the implementation file for the _SplitPanelImpl class. + */ + +#include +#include +#include +#include +#include +#include +#include "FUiCtrl_SplitPanelImpl.h" +#include "FUiCtrl_SplitPanel.h" +#include "FUi_UiBuilder.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Runtime; +using namespace Tizen::App; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_SplitPanelImpl* +_SplitPanelImpl::GetInstance(SplitPanel& pSplitPanel) +{ + return static_cast<_SplitPanelImpl*> (pSplitPanel._pControlImpl); +} + +const _SplitPanelImpl* +_SplitPanelImpl::GetInstance(const SplitPanel& pSplitPanel) +{ + return static_cast (pSplitPanel._pControlImpl); +} + +_SplitPanelImpl::_SplitPanelImpl(SplitPanel* pPublic, _SplitPanel* pCore) + : _ControlImpl(pPublic, pCore) + , __pSplitPanel(pCore) + , __pPublicSplitPanelEvent(null) +{ + ClearLastResult(); +} + +_SplitPanelImpl::~_SplitPanelImpl(void) +{ + __pSplitPanel->RemoveSplitPanelEventListener(*this); + + if(__pPublicSplitPanelEvent) + { + delete __pPublicSplitPanelEvent; + __pPublicSplitPanelEvent = null; + } + + ClearLastResult(); +} + +_SplitPanelImpl* +_SplitPanelImpl::CreateSplitPanelImplN(SplitPanel* pControl, const Rectangle& rect, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _SplitPanel* pCore = _SplitPanel::CreateSplitPanelN(rect, splitPanelDividerStyle, splitPanelDividerDirection); + SysTryReturn(NID_UI_CTRL, pCore != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _SplitPanelImpl* pImpl = new (std::nothrow) _SplitPanelImpl(pControl, pCore); + r = _ControlImpl::CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; +} + +result +_SplitPanelImpl::Initialize(const Rectangle& rect) +{ + ClearLastResult(); + result r = E_SUCCESS; + + r = SetBounds(rect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pPublicSplitPanelEvent = _PublicSplitPanelEvent::CreateInstanceN(GetPublic()); + SysTryReturn(NID_UI_CTRL, __pPublicSplitPanelEvent, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + r = GetCore().AddSplitPanelEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +const char* +_SplitPanelImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::SplitPanel"; +} + +const SplitPanel& +_SplitPanelImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +SplitPanel& +_SplitPanelImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _SplitPanel& +_SplitPanelImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_SplitPanel& +_SplitPanelImpl::GetCore(void) +{ + return static_cast <_SplitPanel&>(_ControlImpl::GetCore()); +} + +void +_SplitPanelImpl::OnDividerPositionChanged(_SplitPanel& source, int position) +{ + ClearLastResult(); + + if (__pPublicSplitPanelEvent != null) + { + IEventArg* pEventArg = _PublicSplitPanelEvent::CreateSplitPanelEventArgN(SPLIT_PANEL_EVENT_DIVIDER_POSITION_CHANGE); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + __pPublicSplitPanelEvent->Fire(*pEventArg); + } +} + +void +_SplitPanelImpl::OnDividerDoublePressed(_SplitPanel& source) +{ + ClearLastResult(); + + if (__pPublicSplitPanelEvent != null) + { + IEventArg* pEventArg = _PublicSplitPanelEvent::CreateSplitPanelEventArgN(SPLIT_PANEL_EVENT_DIVIDER_DOUBLE_PRESSED); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + __pPublicSplitPanelEvent->Fire(*pEventArg); + } +} + +result +_SplitPanelImpl::AddSplitPanelEventListener(ISplitPanelEventListener& listener) +{ + return __pPublicSplitPanelEvent->AddListener(listener); +} + +result +_SplitPanelImpl::RemoveSplitPanelEventListener(ISplitPanelEventListener& listener) +{ + return __pPublicSplitPanelEvent->RemoveListener(listener); +} + +result +_SplitPanelImpl::SetPane(_ControlImpl* pControl, SplitPanelPaneOrder paneOrder) +{ + result r = E_SUCCESS; + + if (pControl == null) + { + r = GetCore().SetPane(null, paneOrder); + } + else + { + r = GetCore().SetPane(&(pControl->GetCore()), paneOrder); + } + + SetLastResultReturn(r); +} + +_ControlImpl* +_SplitPanelImpl::GetPane(SplitPanelPaneOrder paneOrder) const +{ + _Control* pControl = GetCore().GetPane(paneOrder); + if (pControl == null) + { + return null; + } + + return static_cast<_ControlImpl*>(pControl->GetUserData()); +} + +result +_SplitPanelImpl::SetDividerPosition(int position) +{ + result r = GetCore().SetDividerPosition(position); + SetLastResultReturn(r); +} + +int +_SplitPanelImpl::GetDividerPosition(void) const +{ + ClearLastResult(); + return GetCore().GetDividerPosition(); +} + +result +_SplitPanelImpl::SetMaximumDividerPosition(int position) +{ + result r = GetCore().SetMaximumDividerPosition(position); + SetLastResultReturn(r); +} + +int +_SplitPanelImpl::GetMaximumDividerPosition(void) const +{ + ClearLastResult(); + return GetCore().GetMaximumDividerPosition(); +} + +result +_SplitPanelImpl::SetMinimumDividerPosition(int position) +{ + result r = GetCore().SetMinimumDividerPosition(position); + SetLastResultReturn(r); +} + +int +_SplitPanelImpl::GetMinimumDividerPosition(void) const +{ + ClearLastResult(); + return GetCore().GetMinimumDividerPosition(); +} + +result +_SplitPanelImpl::MaximizePane(SplitPanelPaneOrder paneOrder) +{ + result r = GetCore().MaximizePane(paneOrder); + SetLastResultReturn(r); +} + +bool +_SplitPanelImpl::IsPaneMaximized(SplitPanelPaneOrder paneOrder) const +{ + ClearLastResult(); + return GetCore().IsPaneMaximized(paneOrder); +} + +result +_SplitPanelImpl::RestorePane(void) +{ + result r = GetCore().RestorePane(); + SetLastResultReturn(r); +} + +class _SplitPanelMaker + : public _UiBuilderControlMaker +{ +public: + _SplitPanelMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_SplitPanelMaker(void){}; + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _SplitPanelMaker* pSplitPanelMaker = new (std::nothrow) _SplitPanelMaker(uibuilder); + + return pSplitPanelMaker; + }; + +protected: + virtual Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + SplitPanel* pSplitPanel = null; + Tizen::Graphics::Rectangle rect; + Tizen::Base::String elementString; + Tizen::Base::String xmlLink; + int minDividerPosition = 0; + int maxDividerPosition = 0; + int dividerPosition = 0; + + SplitPanelDividerStyle splitPanelDividerStyle = SPLIT_PANEL_DIVIDER_STYLE_MOVABLE; + SplitPanelDividerDirection splitPanelDividerDirection = SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL; + + GetProperty(pControl, &pControlProperty); + + if (pControlProperty == null) + { + return null; + } + + pSplitPanel = new (std::nothrow) SplitPanel(); + SysTryReturn(NID_UI_CTRL, pSplitPanel, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + rect = pControlProperty->GetRect(); + + // Set Style + if (pControl->GetElement("dividerStyle", elementString) || pControl->GetElement("DividerStyle", elementString)) + { + if (elementString.Equals(L"SPLIT_PANEL_DIVIDER_STYLE_FIXED", false)) + { + splitPanelDividerStyle = SPLIT_PANEL_DIVIDER_STYLE_FIXED; + } + if (elementString.Equals(L"SPLIT_PANEL_DIVIDER_STYLE_MOVABLE", false)) + { + splitPanelDividerStyle = SPLIT_PANEL_DIVIDER_STYLE_MOVABLE; + } + } + + if (pControl->GetElement("dividerDirection", elementString) || pControl->GetElement("DividerDirection", elementString)) + { + if (elementString.Equals(L"SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL", false)) + { + splitPanelDividerDirection = SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL; + } + if (elementString.Equals(L"SPLIT_PANEL_DIVIDER_DIRECTION_HORIZONTAL", false)) + { + splitPanelDividerDirection = SPLIT_PANEL_DIVIDER_DIRECTION_HORIZONTAL; + } + } + + // Construct + r = pSplitPanel->Construct(rect, splitPanelDividerStyle, splitPanelDividerDirection); + + if (r != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "Failed to create SplitPanel."); + delete pSplitPanel; + pSplitPanel = null; + + return null; + } + + if (pControl->GetElement("minDividerPosition", elementString)) + { + Base::Integer::Parse(elementString, minDividerPosition); + pSplitPanel->SetMinimumDividerPosition(minDividerPosition); + } + + if (pControl->GetElement("maxDividerPosition", elementString)) + { + Base::Integer::Parse(elementString, maxDividerPosition); + pSplitPanel->SetMaximumDividerPosition(maxDividerPosition); + } + + if (pControl->GetElement("dividerPosition", elementString)) + { + Base::Integer::Parse(elementString, dividerPosition); + pSplitPanel->SetDividerPosition(dividerPosition); + } + + //Set pane + if (pControl->GetElement("firstPane", elementString)) + { + if (pControl->GetElement("firstPaneXmlLink", xmlLink)) + { + if (elementString.Equals(L"panel", false)) + { + Panel* pFirstPanel = new (std::nothrow) Panel(); + pFirstPanel->Construct(xmlLink); + pSplitPanel->SetPane(pFirstPanel, SPLIT_PANEL_PANE_ORDER_FIRST); + } + else if (elementString.Equals(L"form", false)) + { + Form* pFirstForm = new (std::nothrow) Form(); + pFirstForm->Construct(xmlLink); + pSplitPanel->SetPane(pFirstForm, SPLIT_PANEL_PANE_ORDER_FIRST); + } + else if (elementString.Equals(L"scrollpanel", false)) + { + ScrollPanel* pFirstScrollPanel = new (std::nothrow) ScrollPanel(); + pFirstScrollPanel->Construct(xmlLink); + pSplitPanel->SetPane(pFirstScrollPanel, SPLIT_PANEL_PANE_ORDER_FIRST); + } + } + } + + if (pControl->GetElement("secondPane", elementString)) + { + if (pControl->GetElement("secondPaneXmlLink", xmlLink)) + { + if (elementString.Equals(L"panel", false)) + { + Panel* pFirstPanel = new (std::nothrow) Panel(); + pFirstPanel->Construct(xmlLink); + pSplitPanel->SetPane(pFirstPanel, SPLIT_PANEL_PANE_ORDER_SECOND); + } + else if (elementString.Equals(L"form", false)) + { + Form* pFirstForm = new (std::nothrow) Form(); + pFirstForm->Construct(xmlLink); + pSplitPanel->SetPane(pFirstForm, SPLIT_PANEL_PANE_ORDER_SECOND); + } + else if (elementString.Equals(L"scrollpanel", false)) + { + ScrollPanel* pFirstScrollPanel = new (std::nothrow) ScrollPanel(); + pFirstScrollPanel->Construct(xmlLink); + pSplitPanel->SetPane(pFirstScrollPanel, SPLIT_PANEL_PANE_ORDER_SECOND); + } + } + } + + return pSplitPanel; + } +}; // _SplitPanelMaker + +_SplitPanelRegister::_SplitPanelRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"SplitPanel", _SplitPanelMaker::GetInstance); +} +_SplitPanelRegister::~_SplitPanelRegister(void) +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"SplitPanel"); +} +static _SplitPanelRegister SplitPanelRegisterToUIbuilder; +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_SplitPanelModel.cpp b/src/ui/controls/FUiCtrl_SplitPanelModel.cpp new file mode 100644 index 0000000..dce362f --- /dev/null +++ b/src/ui/controls/FUiCtrl_SplitPanelModel.cpp @@ -0,0 +1,83 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SplitPanelModel.cpp + * @brief This is the implementation file for the _SplitPanelModel class. + */ + +#include +#include +#include "FUiCtrl_SplitPanelModel.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +_SplitPanelModel::_SplitPanelModel(void) + : __dividerStyle(SPLIT_PANEL_DIVIDER_STYLE_FIXED) + , __isPaneMaximized(false) + , __maximizedPaneOrder(SPLIT_PANEL_PANE_ORDER_FIRST) +{ +} + +_SplitPanelModel::~_SplitPanelModel(void) +{ +} + +result +_SplitPanelModel::Construct(void) +{ + return E_SUCCESS; +} + +void +_SplitPanelModel::SetDividerStyle(SplitPanelDividerStyle splitPanelDividerStyle) +{ + __dividerStyle = splitPanelDividerStyle; +} + +SplitPanelDividerStyle +_SplitPanelModel::GetDividerStyle(void) const +{ + return __dividerStyle; +} + +void +_SplitPanelModel::SetPaneMaximumState(bool bMaximum) +{ + __isPaneMaximized = bMaximum; +} + +bool +_SplitPanelModel::GetPaneMaximumState(void) const +{ + return __isPaneMaximized; +} + +void +_SplitPanelModel::SetMaximizedPaneOrder(SplitPanelPaneOrder paneOrder) +{ + __maximizedPaneOrder = paneOrder; +} + +SplitPanelPaneOrder +_SplitPanelModel::GetMaximizedPaneOrder(void) const +{ + return __maximizedPaneOrder; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_SplitPanelPresenter.cpp b/src/ui/controls/FUiCtrl_SplitPanelPresenter.cpp new file mode 100644 index 0000000..cc3a65b --- /dev/null +++ b/src/ui/controls/FUiCtrl_SplitPanelPresenter.cpp @@ -0,0 +1,1203 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SplitPanelPresenter.cpp + * @brief This is the header file for the _SplitPanelPresenter class. + * + * This header file contains the declarations of the %_SplitPanelPresenter class. + */ + +#include +#include +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUiCtrl_SplitPanelPresenter.h" +#include "FUiCtrl_SplitPanel.h" +#include "FUiCtrl_SplitPanelImpl.h" + +using namespace Tizen::Ui; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_SplitPanelPresenter::_SplitPanelPresenter(void) + : __pSplitPanel(null) + , __pSplitPanelModel(null) + , __dividerMaximumPosition(0) + , __dividerMinimumPosition(0) + , __splitPanelDividerPressed(false) + , __setFirstDividerPositionChangeEvent(true) + , __dividerRectangle(0,0,0,0) + , __dividerThumbRectangle(0,0,0,0) + , __pDividerPressedBackgroundBitmap(null) + , __pDividerBackgroundBitmap(null) + , __pDividerBackgroundEffectBitmap(null) + , __pDividerThumbBitmap(null) + , __transactionIdMaximize(0) + , __transactionIdRestore(0) + , __controlAnimatorAnimationInterpolator(ANIMATION_INTERPOLATOR_LINEAR) + , __visualElementAnimationInterpolator(L"Linear") +{ + GET_COLOR_CONFIG(SPLITPANEL::DIVIDER_BG_NORMAL, __dividerBackgroundColor); + GET_COLOR_CONFIG(SPLITPANEL::DIVIDER_BG_PRESSED, __dividerPressedBackgroundColor); +} + +_SplitPanelPresenter::~_SplitPanelPresenter(void) +{ + delete __pSplitPanelModel; + __pSplitPanelModel = null; + + delete __pDividerPressedBackgroundBitmap; + __pDividerPressedBackgroundBitmap = null; + + delete __pDividerBackgroundBitmap; + __pDividerBackgroundBitmap = null; + + delete __pDividerThumbBitmap; + __pDividerThumbBitmap = null; + + delete __pDividerBackgroundEffectBitmap; + __pDividerBackgroundEffectBitmap = null; +} + +result +_SplitPanelPresenter::Construct(const _SplitPanel& splitPanel, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection) +{ + result r = E_SUCCESS; + + _SplitPanelModel* pModel = new (std::nothrow) _SplitPanelModel; + SysTryReturnResult(NID_UI_CTRL, pModel, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = SetModel(*pModel); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to set the model."); + + r = pModel->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to construct _SplitPanelModel instance."); + + __pSplitPanel = const_cast <_SplitPanel*>(&splitPanel); + SysTryCatch(NID_UI_CTRL, __pSplitPanel != null, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. _SplitPanel instance is null."); + + __pSplitPanelModel->SetDividerStyle(splitPanelDividerStyle); + + r = LoadBitmap(splitPanelDividerDirection); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to load bitmap.", GetErrorMessage(r)); + + AdjustDividerRectangle(); + + __controlAnimatorAnimationInterpolator = ANIMATION_INTERPOLATOR_EASE_IN; + __visualElementAnimationInterpolator = L"EaseIn"; + + return E_SUCCESS; + +CATCH: + delete pModel; + pModel = null; + + return r; +} + +bool +_SplitPanelPresenter::CheckDividerTouchRegion(int positionX, int positionY) +{ + int dividerPosition = __pSplitPanel->GetDividerPosition(); + + if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + Bitmap* pThumbBitmap = __pDividerThumbBitmap; + if ((positionX >= dividerPosition) + && (positionX <= dividerPosition + pThumbBitmap->GetWidth())) + { + return true; + } + } + else + { + Bitmap* pThumbBitmap = __pDividerThumbBitmap; + if ((positionY >= dividerPosition) + && (positionY <= dividerPosition + pThumbBitmap->GetHeight())) + { + return true; + } + } + + return false; +} + +bool +_SplitPanelPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + Point point = touchinfo.GetCurrentPosition(); + + if (CheckDividerTouchRegion(point.x, point.y) == true) + { + __splitPanelDividerPressed = true; + } + + Draw(); + + return E_SUCCESS; +} + +bool +_SplitPanelPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__splitPanelDividerPressed == true) + { + __splitPanelDividerPressed = false; + Draw(); + } + + return E_SUCCESS; +} + +bool +_SplitPanelPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__pSplitPanel != &source || __splitPanelDividerPressed == false ) + { + return false; + } + + if (__pSplitPanelModel->GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_FIXED) + { + return false; + } + + Point point = touchinfo.GetCurrentPosition(); + + if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + // Min, Max Position Check. + if ((__pSplitPanel->GetMinimumDividerPosition() > point.x) + || (__pSplitPanel->GetMaximumDividerPosition() < point.x)) + { + return false; + } + + Bitmap* pThumbBitmap = __pDividerThumbBitmap; + + if (point.x <= __pSplitPanel->GetBounds().width - pThumbBitmap->GetWidth()) + { + __pSplitPanel->SetDividerPosition(point.x); + } + } + else + { + // Min, Max Position Check. + if ((__pSplitPanel->GetMinimumDividerPosition() > point.y) + || (__pSplitPanel->GetMaximumDividerPosition() < point.y)) + { + return false; + } + + Bitmap* pThumbBitmap = __pDividerThumbBitmap; + + if (point.y <= __pSplitPanel->GetBounds().height - pThumbBitmap->GetHeight()) + { + __pSplitPanel->SetDividerPosition(point.y); + } + } + + __pSplitPanel->SendSplitPanelEvent(_SPLIT_PANEL_EVENT_DIVIDER_POSITION_CHANGE); + + Draw(); + + return true; +} + +bool +_SplitPanelPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__splitPanelDividerPressed == true) + { + __splitPanelDividerPressed = false; + Draw(); + } + + return E_SUCCESS; +} + +bool +_SplitPanelPresenter::OnTapGestureDetected(_TouchTapGestureDetector& gesture) +{ + if (__pSplitPanelModel->GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_FIXED) + { + return false; + } + + __pSplitPanel->SendSplitPanelEvent(_SPLIT_PANEL_EVENT_DIVIDER_DOUBLE_PRESSED); + + return true; +} + +bool +_SplitPanelPresenter::OnTapGestureCanceled(_TouchTapGestureDetector& gesture) +{ + return false; +} + +result +_SplitPanelPresenter::SetDividerStyle(SplitPanelDividerStyle splitPanelDividerStyle) +{ + __pSplitPanelModel->SetDividerStyle(splitPanelDividerStyle); + + return E_SUCCESS; +} + +SplitPanelDividerStyle +_SplitPanelPresenter::GetDividerStyle(void) const +{ + return __pSplitPanelModel->GetDividerStyle(); +} + +Rectangle +_SplitPanelPresenter::GetDividerRectangle(void) const +{ + return __dividerRectangle; +} + +result +_SplitPanelPresenter::MaximizePane(SplitPanelPaneOrder paneOrder) +{ + result r = E_SUCCESS; + + if (IsPaneMaximized(paneOrder)) + { + return E_SUCCESS; + } + else if (GetAnimationStatus() == ANIMATOR_STATUS_PLAYING) + { + AnimationTransaction::Stop(__transactionIdMaximize); + AnimationTransaction::Stop(__transactionIdRestore); + } + + RecalcSplitPanel(); + + ChangePaneOrder(paneOrder); + + AnimationTransaction::Begin(__transactionIdMaximize); + + if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST) + { + r = AnimateDivider(_SPLIT_PANEL_ANIMATION_RIGHT); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = AnimatePane(_SPLIT_PANEL_ANIMATION_RIGHT); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = AnimateDivider(_SPLIT_PANEL_ANIMATION_LEFT); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = AnimatePane(_SPLIT_PANEL_ANIMATION_LEFT); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + else + { + if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST) + { + r = AnimateDivider(_SPLIT_PANEL_ANIMATION_BOTTOM); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = AnimatePane(_SPLIT_PANEL_ANIMATION_BOTTOM); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = AnimateDivider(_SPLIT_PANEL_ANIMATION_TOP); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = AnimatePane(_SPLIT_PANEL_ANIMATION_TOP); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + AnimationTransaction::Commit(); + + __pSplitPanelModel->SetPaneMaximumState(true); + __pSplitPanelModel->SetMaximizedPaneOrder(paneOrder); + + return E_SUCCESS; + +CATCH: + AnimationTransaction::Discard(); + + return r; +} + +bool +_SplitPanelPresenter::IsPaneMaximized(SplitPanelPaneOrder paneOrder) const +{ + if ((__pSplitPanelModel->GetPaneMaximumState() == true) + && (__pSplitPanelModel->GetMaximizedPaneOrder() == paneOrder)) + { + return true; + } + + return false; +} + +result +_SplitPanelPresenter::RestorePane(void) +{ + result r = E_SUCCESS; + + if (__pSplitPanelModel->GetPaneMaximumState() == false) + { + return E_SUCCESS; + } + else if (GetAnimationStatus() == ANIMATOR_STATUS_PLAYING) + { + AnimationTransaction::Stop(__transactionIdMaximize); + AnimationTransaction::Stop(__transactionIdRestore); + } + + RecalcSplitPanel(); + + AnimationTransaction::Begin(__transactionIdRestore); + + if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + r = AnimateDivider(_SPLIT_PANEL_ANIMATION_RESTORE_VERTICAL); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = AnimatePane(_SPLIT_PANEL_ANIMATION_RESTORE_VERTICAL); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = AnimateDivider(_SPLIT_PANEL_ANIMATION_RESTORE_HORIZONTAL); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = AnimatePane(_SPLIT_PANEL_ANIMATION_RESTORE_HORIZONTAL); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + AnimationTransaction::Commit(); + + __pSplitPanelModel->SetPaneMaximumState(false); + + return E_SUCCESS; + +CATCH: + AnimationTransaction::Discard(); + + return r; +} + +result +_SplitPanelPresenter::Draw(void) +{ + if (__pSplitPanelModel->GetPaneMaximumState() == false && GetAnimationStatus() == ANIMATOR_STATUS_STOPPED) + { + //adjust divider rectangle + AdjustDividerRectangle(); + + Canvas* pCanvas = __pSplitPanel->GetDividerVisualElement()->GetCanvasN(); + SysTryReturnResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "Propagating."); + + pCanvas->Clear(); + + //resize pane + SetPaneBounds(); + + Rectangle dividerBounds = __dividerRectangle; + dividerBounds.x = 0; + dividerBounds.y = 0; + + if (__splitPanelDividerPressed == true) + { + pCanvas->DrawNinePatchedBitmap(dividerBounds, *__pDividerPressedBackgroundBitmap); + } + else + { + pCanvas->DrawNinePatchedBitmap(dividerBounds, *__pDividerBackgroundBitmap); + } + + //draw divider + pCanvas->DrawNinePatchedBitmap(dividerBounds, *__pDividerBackgroundEffectBitmap); + + //draw divider thumb + if (__pSplitPanelModel->GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE) + { + Rectangle dividerThumbBounds = __dividerThumbRectangle; + if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + dividerThumbBounds.x = 0; + } + else + { + dividerThumbBounds.y = 0; + } + + pCanvas->DrawBitmap(dividerThumbBounds, *__pDividerThumbBitmap); + } + + delete pCanvas; + } + + return E_SUCCESS; +} + +result +_SplitPanelPresenter::LoadBitmap(SplitPanelDividerDirection splitPanelDividerDirection) +{ + result r = E_SUCCESS; + Bitmap *pDividerBackgroundBitmap = null; + + // Modified - Changeable Color / Resource ( Fixed Style ) + r = GET_BITMAP_CONFIG_N(SPLITPANEL::DIVIDER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDividerBackgroundBitmap); + SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Failed to load bitmap."); + + if (splitPanelDividerDirection == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + r = GET_BITMAP_CONFIG_N(SPLITPANEL::VERTICAL_DIVIDER_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDividerBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Failed to load bitmap.", GetErrorMessage(r)); + r = GET_BITMAP_CONFIG_N(SPLITPANEL::VERTICAL_DIVIDER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDividerThumbBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Failed to load bitmap.", GetErrorMessage(r)); + } + else + { + r = GET_BITMAP_CONFIG_N(SPLITPANEL::HORIZONTAL_DIVIDER_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pDividerBackgroundEffectBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Failed to load bitmap.", GetErrorMessage(r)); + r = GET_BITMAP_CONFIG_N(SPLITPANEL::HORIZONTAL_DIVIDER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pDividerThumbBitmap); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Failed to load bitmap.", GetErrorMessage(r)); + } + + __pDividerPressedBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDividerBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), __dividerPressedBackgroundColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (__pDividerPressedBackgroundBitmap != null), , r, "[%s] Failed to get replacement color bitmap.", GetErrorMessage(r)); + + __pDividerBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDividerBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), __dividerBackgroundColor); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (__pDividerBackgroundBitmap != null), , r, "[%s] Failed to get replacement color bitmap.", GetErrorMessage(r)); + + delete pDividerBackgroundBitmap; + + return r; + +CATCH: + delete pDividerBackgroundBitmap; + delete __pDividerBackgroundEffectBitmap; + delete __pDividerPressedBackgroundBitmap; + delete __pDividerThumbBitmap; + + return r; +} + +void +_SplitPanelPresenter::RecalcSplitPanel(void) +{ + //adjust divider rectangle + AdjustDividerRectangle(); + + //resize pane + SetPaneBounds(); + + return; +} + +void +_SplitPanelPresenter::OnChangeLayout(_ControlOrientation orientation) +{ + AnimationTransaction::Stop(__transactionIdMaximize); + AnimationTransaction::Stop(__transactionIdRestore); + + return; +} + +void +_SplitPanelPresenter::OnBoundsChanged(void) +{ + RecalcSplitPanel(); + return; +} + +result +_SplitPanelPresenter::SetModel(const _SplitPanelModel& splitPanelModel) +{ + __pSplitPanelModel = const_cast<_SplitPanelModel*>(&splitPanelModel); + + return E_SUCCESS; +} + +result +_SplitPanelPresenter::SetPaneBounds(void) +{ + result r = E_SUCCESS; + Rectangle firstPaneBounds(0, 0, 0, 0); + Rectangle secondPaneBounds(0, 0, 0, 0); + + Rectangle clientBounds = __pSplitPanel->GetBounds(); + + _Control* pFirstPane = __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_FIRST); + + _Control* pSecondPane = __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_SECOND); + + clientBounds.x = clientBounds.y = 0; + + if (IsPaneMaximized(SPLIT_PANEL_PANE_ORDER_FIRST)) + { + firstPaneBounds = clientBounds; + + if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + secondPaneBounds = Rectangle(clientBounds.width + __dividerRectangle.width, 0, clientBounds.width - __dividerRectangle.x - __dividerRectangle.width,clientBounds.height); + } + else + { + secondPaneBounds = Rectangle(0, clientBounds.height + __dividerRectangle.height, clientBounds.width, clientBounds.height - __dividerRectangle.y - __dividerRectangle.height); + } + } + else if (IsPaneMaximized(SPLIT_PANEL_PANE_ORDER_SECOND)) + { + secondPaneBounds = clientBounds; + + if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + firstPaneBounds = Rectangle(clientBounds.x -__dividerRectangle.x - __dividerRectangle.width, 0, __dividerRectangle.x, clientBounds.height); + } + else + { + firstPaneBounds = Rectangle(0, clientBounds.y -__dividerRectangle.y - __dividerRectangle.height, clientBounds.width, __dividerRectangle.y); + } + } + else + { + if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + firstPaneBounds = Rectangle(0, 0, __dividerRectangle.x, clientBounds.height); + secondPaneBounds = Rectangle(__dividerRectangle.x + __dividerRectangle.width, 0, clientBounds.width - __dividerRectangle.x - __dividerRectangle.width,clientBounds.height); + } + else + { + firstPaneBounds = Rectangle(0, 0, clientBounds.width, __dividerRectangle.y); + secondPaneBounds = Rectangle(0, __dividerRectangle.y + __dividerRectangle.height, clientBounds.width, clientBounds.height - __dividerRectangle.y - __dividerRectangle.height); + } + } + + bool movable = true; + bool resizable = true; + + //set Pane bounds + if (pFirstPane != null) + { + movable = pFirstPane->IsMovable(); + resizable = pFirstPane->IsResizable(); + + pFirstPane->SetMovable(true); + pFirstPane->SetResizable(true); + + r = pFirstPane->SetBounds(firstPaneBounds); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + pFirstPane->SetMovable(movable); + pFirstPane->SetResizable(resizable); + } + + if (pSecondPane != null) + { + movable = pSecondPane->IsMovable(); + resizable = pSecondPane->IsResizable(); + + pSecondPane->SetMovable(true); + pSecondPane->SetResizable(true); + + r = pSecondPane->SetBounds(secondPaneBounds); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + pSecondPane->SetMovable(movable); + pSecondPane->SetResizable(resizable); + } + + if ((pFirstPane != null) && (pSecondPane != null)) + { + if (__setFirstDividerPositionChangeEvent == true) + { + __setFirstDividerPositionChangeEvent = false; + __pSplitPanel->SendSplitPanelEvent(_SPLIT_PANEL_EVENT_DIVIDER_POSITION_CHANGE); + } + } + + return r; +} + +void +_SplitPanelPresenter::AdjustDividerRectangle(void) +{ + int dividerPosition = __pSplitPanel->GetDividerPosition(); + // Check - Divider Postion. ( Screen Size Over / Maximum Divider Position ) + + Rectangle clientBounds = __pSplitPanel->GetBounds(); + int width = 0; + int height = 0; + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + Bitmap* pThumbBitmap = __pDividerThumbBitmap; + + if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE) + { + GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, width); + } + else + { + GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, width); + } + + height = clientBounds.height; + + if (height > 0) + { + __dividerRectangle = Rectangle(dividerPosition, 0, width, height); + __dividerThumbRectangle = Rectangle(dividerPosition, ((height - pThumbBitmap->GetHeight()) / 2), pThumbBitmap->GetWidth(), pThumbBitmap->GetHeight()); + } + } + else + { + Bitmap* pThumbBitmap = __pDividerThumbBitmap; + + width = clientBounds.width; + + if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE) + { + GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, height); + } + else + { + GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, height); + } + + if (width > 0) + { + __dividerRectangle = Rectangle(0, dividerPosition, width, height); + __dividerThumbRectangle = Rectangle(((width - pThumbBitmap->GetWidth()) / 2), dividerPosition, pThumbBitmap->GetWidth(), pThumbBitmap->GetHeight()); + } + } + + __pSplitPanel->SetDividerVisualElementBounds(__dividerRectangle); +} + +void +_SplitPanelPresenter::ChangePaneOrder(SplitPanelPaneOrder paneOrder) +{ + result r = E_SUCCESS; + + if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST) + { + _Control* pFirstPane = __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_FIRST); + SysTryReturnVoidResult(NID_UI_CTRL, pFirstPane != null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pSplitPanel->DetachChild(*pFirstPane); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pSplitPanel->AttachChild(*pFirstPane); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + _Control* pSecondPane = __pSplitPanel->GetPane(SPLIT_PANEL_PANE_ORDER_SECOND); + SysTryReturnVoidResult(NID_UI_CTRL, pSecondPane != null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pSplitPanel->DetachChild(*pSecondPane); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pSplitPanel->AttachChild(*pSecondPane); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return; +} + +result +_SplitPanelPresenter::AnimateDivider(int destination) +{ + result r = E_SUCCESS; + + FloatRectangle dividerBoundsStartF(0.0f, 0.0f, 0.0f, 0.0f); + FloatRectangle dividerBoundsEndF(0.0f, 0.0f, 0.0f, 0.0f); + + Control* pFirstPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_FIRST); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pFirstPanelControl != null, r, "Propagating."); + + VisualElement* pVisualElementDivider = __pSplitPanel->GetDividerVisualElement(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pVisualElementDivider != null, r, "Propagating."); + + pVisualElementDivider->RemoveAllAnimations(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + FloatRectangle dividerBoundsF = pVisualElementDivider->GetBounds(); + Rectangle clientBounds = __pSplitPanel->GetBounds(); + Rectangle firstPaneBounds = pFirstPanelControl->GetBounds(); + + const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(__visualElementAnimationInterpolator); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pTimingFunction != null, r, "Propagating."); + + VisualElementPropertyAnimation* pAnimationDivider = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturnResult(NID_UI_CTRL, pAnimationDivider != null, E_OUT_OF_MEMORY, " Memory allocation failed.") + + r = pAnimationDivider->SetPropertyName(L"bounds"); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating."); + + r = pAnimationDivider->SetDuration(ANIMATION_DURATION); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating."); + + pAnimationDivider->SetTimingFunction(pTimingFunction); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating."); + + dividerBoundsF = pVisualElementDivider->GetBounds(); + dividerBoundsStartF = dividerBoundsF; + + clientBounds.x = clientBounds.y = 0; + + switch (destination) + { + case _SPLIT_PANEL_ANIMATION_RIGHT: + { + dividerBoundsStartF.x = firstPaneBounds.x + firstPaneBounds.width; + + dividerBoundsEndF = dividerBoundsF; + dividerBoundsEndF.x = (float)clientBounds.width; + } + break; + case _SPLIT_PANEL_ANIMATION_LEFT: + { + dividerBoundsStartF.x = firstPaneBounds.x + firstPaneBounds.width; + + dividerBoundsEndF = dividerBoundsF; + dividerBoundsEndF.x = (float)clientBounds.x - dividerBoundsF.width; + } + break; + case _SPLIT_PANEL_ANIMATION_TOP: + { + dividerBoundsStartF.y = firstPaneBounds.y + firstPaneBounds.height; + + dividerBoundsEndF = dividerBoundsF; + dividerBoundsEndF.y = (float)clientBounds.y - dividerBoundsF.height; + } + break; + case _SPLIT_PANEL_ANIMATION_BOTTOM: + { + dividerBoundsStartF.y = firstPaneBounds.y + firstPaneBounds.height; + + dividerBoundsEndF = dividerBoundsF; + dividerBoundsEndF.y = (float)clientBounds.height; + } + break; + case _SPLIT_PANEL_ANIMATION_RESTORE_HORIZONTAL: + { + dividerBoundsF = FloatRectangle((float)__dividerRectangle.x, (float)__dividerRectangle.y, + (float)__dividerRectangle.width, (float)__dividerRectangle.height); + + dividerBoundsStartF = dividerBoundsF; + dividerBoundsEndF = dividerBoundsF; + + if (__pSplitPanelModel->GetMaximizedPaneOrder() == SPLIT_PANEL_PANE_ORDER_FIRST) + { + dividerBoundsStartF.y = (float)clientBounds.height; + } + else + { + dividerBoundsStartF.y = (float)clientBounds.y - dividerBoundsF.height; + } + } + break; + case _SPLIT_PANEL_ANIMATION_RESTORE_VERTICAL: + { + dividerBoundsF = FloatRectangle((float)__dividerRectangle.x, (float)__dividerRectangle.y, + (float)__dividerRectangle.width, (float)__dividerRectangle.height); + + dividerBoundsStartF = dividerBoundsF; + dividerBoundsEndF = dividerBoundsF; + + if (__pSplitPanelModel->GetMaximizedPaneOrder() == SPLIT_PANEL_PANE_ORDER_FIRST) + { + dividerBoundsStartF.x = (float)clientBounds.width; + } + else + { + dividerBoundsStartF.x = (float)clientBounds.x - dividerBoundsF.width; + } + } + break; + } + + r = pAnimationDivider->SetStartValue(dividerBoundsStartF); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating."); + + r = pAnimationDivider->SetEndValue(dividerBoundsEndF); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating."); + + pVisualElementDivider->AddAnimation(L"Bounds", *pAnimationDivider); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Propagating."); + +CATCH: + + delete pAnimationDivider; + return r; + +} + +result +_SplitPanelPresenter::AnimatePane(int destination) +{ + result r = E_SUCCESS; + + Control* pFirstPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_FIRST); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pFirstPanelControl != null, r, "Propagating."); + + Control* pSecondPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_SECOND); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pSecondPanelControl != null, r, "Propagating."); + + ControlAnimator* pControlAnimatorFirstPane = pFirstPanelControl->GetControlAnimator(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pControlAnimatorFirstPane != null, r, "Propagating."); + + ControlAnimator* pControlAnimatorSecondPane = pSecondPanelControl->GetControlAnimator(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pControlAnimatorSecondPane != null, r, "Propagating."); + + Rectangle clientBounds = __pSplitPanel->GetBounds(); + Rectangle firstPaneBounds = pFirstPanelControl->GetBounds(); + Rectangle secondPaneBounds = pSecondPanelControl->GetBounds(); + + FloatAnimation animationHidePane(ANIMATION_ALPHA_SHOW, ANIMATION_ALPHA_HIDE, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + FloatAnimation animationShowPane(ANIMATION_ALPHA_HIDE, ANIMATION_ALPHA_SHOW, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + + clientBounds.x = clientBounds.y = 0; + + switch (destination) + { + case _SPLIT_PANEL_ANIMATION_RIGHT: + { + Rectangle secondPaneEndBounds = secondPaneBounds; + secondPaneEndBounds.x = clientBounds.x + clientBounds.width + __dividerRectangle.width; + + RectangleAnimation animationMaximizeFirstPane = RectangleAnimation(firstPaneBounds, clientBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + RectangleAnimation animationMinimizeSecondPane = RectangleAnimation(secondPaneBounds, secondPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMaximizeFirstPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationMaximizeFirstPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMinimizeSecondPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationHidePane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + if (pFirstPanelControl->GetShowState() == false) + { + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + break; + case _SPLIT_PANEL_ANIMATION_LEFT: + { + Rectangle firstPaneEndBounds = firstPaneBounds; + firstPaneEndBounds.x = clientBounds.x - firstPaneBounds.width - __dividerRectangle.width; + + RectangleAnimation animationMaximizeSecondPane = RectangleAnimation(secondPaneBounds, clientBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + RectangleAnimation animationMinimizeFirstPane = RectangleAnimation(firstPaneBounds, firstPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMaximizeSecondPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationMaximizeSecondPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMinimizeFirstPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationHidePane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + if (pSecondPanelControl->GetShowState() == false) + { + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + break; + case _SPLIT_PANEL_ANIMATION_TOP: + { + Rectangle firstPaneEndBounds = firstPaneBounds; + firstPaneEndBounds.y = clientBounds.y - firstPaneBounds.height - __dividerRectangle.height; + + RectangleAnimation animationMaximizeSecondPane = RectangleAnimation(secondPaneBounds, clientBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + RectangleAnimation animationMinimizeFirstPane = RectangleAnimation(firstPaneBounds, firstPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMaximizeSecondPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationMaximizeSecondPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMinimizeFirstPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationHidePane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + if (pSecondPanelControl->GetShowState() == false) + { + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + break; + case _SPLIT_PANEL_ANIMATION_BOTTOM: + { + Rectangle secondPaneEndBounds = secondPaneBounds; + secondPaneEndBounds.y = clientBounds.y + clientBounds.height + __dividerRectangle.height; + + RectangleAnimation animationMaximizeFirstPane = RectangleAnimation(firstPaneBounds, clientBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + RectangleAnimation animationMinimizeSecondPane = RectangleAnimation(secondPaneBounds, secondPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMaximizeFirstPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationMaximizeFirstPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationMinimizeSecondPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationHidePane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + if (pFirstPanelControl->GetShowState() == false) + { + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + break; + case _SPLIT_PANEL_ANIMATION_RESTORE_HORIZONTAL: + { + Rectangle firstPaneEndBounds = GetRestorePaneBounds(SPLIT_PANEL_PANE_ORDER_FIRST); + Rectangle secondPaneEndBounds = GetRestorePaneBounds(SPLIT_PANEL_PANE_ORDER_SECOND); + + RectangleAnimation animationRestoreFirstPane = RectangleAnimation(firstPaneBounds, firstPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + RectangleAnimation animationRestoreSecondPane = RectangleAnimation(secondPaneBounds, secondPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + + // Restore Pane 1 + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationRestoreFirstPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationRestoreFirstPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + // Restore Pane 2 + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationRestoreSecondPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationRestoreSecondPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + if (__pSplitPanelModel->GetMaximizedPaneOrder() == SPLIT_PANEL_PANE_ORDER_FIRST) + { + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + else + { + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + break; + case _SPLIT_PANEL_ANIMATION_RESTORE_VERTICAL: + { + Rectangle firstPaneEndBounds = GetRestorePaneBounds(SPLIT_PANEL_PANE_ORDER_FIRST); + Rectangle secondPaneEndBounds = GetRestorePaneBounds(SPLIT_PANEL_PANE_ORDER_SECOND); + + RectangleAnimation animationRestoreFirstPane = RectangleAnimation(firstPaneBounds, firstPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + RectangleAnimation animationRestoreSecondPane = RectangleAnimation(secondPaneBounds, secondPaneEndBounds, ANIMATION_DURATION, __controlAnimatorAnimationInterpolator); + + // Restore Pane 1 + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationRestoreFirstPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationRestoreFirstPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + // Restore Pane 2 + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_SIZE, animationRestoreSecondPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_POSITION, animationRestoreSecondPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + if (__pSplitPanelModel->GetMaximizedPaneOrder() == SPLIT_PANEL_PANE_ORDER_FIRST) + { + r = pControlAnimatorSecondPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + else + { + r = pControlAnimatorFirstPane->StartUserAnimation(ANIMATION_TARGET_ALPHA, animationShowPane); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + break; + } + + return E_SUCCESS; +} + +Control* +_SplitPanelPresenter::GetPaneControl(SplitPanelPaneOrder paneOrder) +{ + _ControlImpl* pControlImpl = static_cast<_ControlImpl*>(__pSplitPanel->GetUserData()); + SysTryReturn(NID_UI_CTRL, pControlImpl != null, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. _ControlImpl is null."); + + _SplitPanelImpl* pSplitPanelImpl = dynamic_cast<_SplitPanelImpl*>(pControlImpl); + SysTryReturn(NID_UI_CTRL, pSplitPanelImpl != null, null, E_SYSTEM, "[E_SYSTEM]A system error has occurred. _SplitPanelImpl is null."); + + SplitPanel& splitPanelPublic = pSplitPanelImpl->GetPublic(); + + Control* pControl = splitPanelPublic.GetPane(paneOrder); + SysTryReturn(NID_UI_CTRL, pControl != null, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return pControl; +} + +AnimatorStatus +_SplitPanelPresenter::GetAnimationStatus(void) +{ + result r = E_SUCCESS; + + Control* pFirstPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_FIRST); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pFirstPanelControl != null, ANIMATOR_STATUS_STOPPED, r, "[%s] Propagating.", GetErrorMessage(r)); + + Control* pSecondPanelControl = GetPaneControl(SPLIT_PANEL_PANE_ORDER_SECOND); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pSecondPanelControl != null, ANIMATOR_STATUS_STOPPED, r, "[%s] Propagating.", GetErrorMessage(r)); + + ControlAnimator* pControlAnimatorFirstPane = pFirstPanelControl->GetControlAnimator(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, ANIMATOR_STATUS_STOPPED, r, "[%s] Propagating.", GetErrorMessage(r)); + + ControlAnimator* pControlAnimatorSecondPane = pSecondPanelControl->GetControlAnimator(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, ANIMATOR_STATUS_STOPPED, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (pControlAnimatorFirstPane->GetStatus() == ANIMATOR_STATUS_STOPPED && pControlAnimatorSecondPane->GetStatus() == ANIMATOR_STATUS_STOPPED) + { + return ANIMATOR_STATUS_STOPPED; + } + + return ANIMATOR_STATUS_PLAYING; +} + +Rectangle +_SplitPanelPresenter::GetRestorePaneBounds(SplitPanelPaneOrder paneOrder) +{ + int width = 0; + int height = 0; + + Rectangle firstPaneBounds(0, 0, 0, 0); + Rectangle secondPaneBounds(0, 0, 0, 0); + + int dividerPosition = __pSplitPanel->GetDividerPosition(); + + Rectangle clientBounds = __pSplitPanel->GetBounds(); + + _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation(); + + if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE) + { + GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, width); + } + else + { + GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, width); + } + + height = clientBounds.height; + + if (height > 0) + { + __dividerRectangle = Rectangle(dividerPosition, 0, width, height); + } + } + else + { + width = clientBounds.width; + + if (GetDividerStyle() == SPLIT_PANEL_DIVIDER_STYLE_MOVABLE) + { + GET_SHAPE_CONFIG(SPLITPANEL::MOVABLE_DIVIDER_THICKNESS, orientation, height); + } + else + { + GET_SHAPE_CONFIG(SPLITPANEL::FIXED_DIVIDER_THICKNESS, orientation, height); + } + + if (width > 0) + { + __dividerRectangle = Rectangle(0, dividerPosition, width, height); + } + } + + if (__pSplitPanel->GetDividerDirection() == SPLIT_PANEL_DIVIDER_DIRECTION_VERTICAL) + { + firstPaneBounds = Rectangle(0, 0, __dividerRectangle.x, clientBounds.height); + secondPaneBounds = Rectangle(__dividerRectangle.x + __dividerRectangle.width, 0, clientBounds.width - __dividerRectangle.x - __dividerRectangle.width,clientBounds.height); + } + else + { + firstPaneBounds = Rectangle(0, 0, clientBounds.width, __dividerRectangle.y); + secondPaneBounds = Rectangle(0, __dividerRectangle.y + __dividerRectangle.height, clientBounds.width, clientBounds.height - __dividerRectangle.y - __dividerRectangle.height); + } + + if (paneOrder == SPLIT_PANEL_PANE_ORDER_FIRST) + { + return firstPaneBounds; + } + + return secondPaneBounds; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Tab.cpp b/src/ui/controls/FUiCtrl_Tab.cpp new file mode 100644 index 0000000..44de206 --- /dev/null +++ b/src/ui/controls/FUiCtrl_Tab.cpp @@ -0,0 +1,1388 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Tab.cpp + * @brief This is the implementation file for the _Tab class. + */ + +#include +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_TouchLongPressGestureDetector.h" +#include "FUiCtrl_Tab.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls { + +_Tab::_Tab(void) + : __pTabPresenter(null) + , __style(_TAB_STYLE_TEXT) + , __tabStatus(_TAB_STATUS_NORMAL) + , __pActionEvent(null) + , __pGestureLongPress(null) + , __pFlickGesture(null) + , __pBackgroundBitmap(null) + , __pPressedItemBackgroundBitmap(null) + , __pSelectedItemBackgroundBitmap(null) + , __pHighlightedItemBackgroundBitmap(null) +{ + ClearLastResult(); + result r = E_SUCCESS; + + __tabItems.Construct(); + + GET_COLOR_CONFIG(TAB::ITEM_BG_NORMAL, __itemBgColor[_TAB_STATUS_NORMAL]); + GET_COLOR_CONFIG(TAB::ITEM_BG_PRESSED, __itemBgColor[_TAB_STATUS_PRESSED]); + GET_COLOR_CONFIG(TAB::ITEM_BG_SELECTED, __itemBgColor[_TAB_STATUS_SELECTED]); + GET_COLOR_CONFIG(TAB::ITEM_BG_HIGHLIGHTED, __itemBgColor[_TAB_STATUS_HIGHLIGHTED]); + GET_COLOR_CONFIG(TAB::ITEM_BG_DISABLED, __itemBgColor[_TAB_STATUS_DISABLED]); + + GET_COLOR_CONFIG(TAB::ITEM_TEXT_NORMAL, __itemTextColor[_TAB_STATUS_NORMAL]); + GET_COLOR_CONFIG(TAB::ITEM_TEXT_PRESSED, __itemTextColor[_TAB_STATUS_PRESSED]); + GET_COLOR_CONFIG(TAB::ITEM_TEXT_SELECTED, __itemTextColor[_TAB_STATUS_SELECTED]); + GET_COLOR_CONFIG(TAB::ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_TAB_STATUS_HIGHLIGHTED]); + GET_COLOR_CONFIG(TAB::ITEM_TEXT_DISABLED, __itemTextColor[_TAB_STATUS_DISABLED]); + + r = LoadBitmap(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to load bitmap."); + + _Control::SetResizable(false); + _Control::SetMovable(false); + + _TabPresenter* pPresenter = new (std::nothrow) _TabPresenter; + SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = SetPresenter(*pPresenter); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _TabPresenter instance could not be set."); + + r = pPresenter->Construct(*this); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _TabPresenter instance construct failed."); + +} + +_Tab::~_Tab(void) +{ + delete __pTabPresenter; + __pTabPresenter = null; + + if (__pActionEvent) + { + delete __pActionEvent; + __pActionEvent = null; + } + + __tabItems.RemoveAll(true); + + if (__pFlickGesture != null) + { + __pFlickGesture->RemoveGestureListener(*this); + RemoveGestureDetector(*__pFlickGesture); + + delete __pFlickGesture; + __pFlickGesture = null; + } + + if (__pGestureLongPress != null) + { + __pGestureLongPress->RemoveGestureListener(*this); + RemoveGestureDetector(*__pGestureLongPress); + + delete __pGestureLongPress; + __pGestureLongPress = null; + } + + if (__pBackgroundBitmap) + { + delete __pBackgroundBitmap; + __pBackgroundBitmap = null; + } + + if (__pPressedItemBackgroundBitmap) + { + delete __pPressedItemBackgroundBitmap; + __pPressedItemBackgroundBitmap = null; + } + + if (__pSelectedItemBackgroundBitmap) + { + delete __pSelectedItemBackgroundBitmap; + __pSelectedItemBackgroundBitmap = null; + } + + if (__pHighlightedItemBackgroundBitmap) + { + delete __pHighlightedItemBackgroundBitmap; + __pHighlightedItemBackgroundBitmap = null; + } + + RemoveAllAccessibilityElement(); +} + +_Tab* +_Tab::CreateTabN(void) +{ + result r = E_SUCCESS; + + _Tab* pTab = new (std::nothrow) _Tab; + SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + pTab->AcquireHandle(); + + pTab->__pGestureLongPress = new (std::nothrow) _TouchLongPressGestureDetector; + SysTryCatch(NID_UI_CTRL, pTab->__pGestureLongPress, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pTab->__pGestureLongPress->SetDuration(300); + pTab->AddGestureDetector(*(pTab->__pGestureLongPress)); + r = pTab->__pGestureLongPress->AddGestureListener(*pTab); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _ITouchGestureEventListener instance could not be set."); + + pTab->__pFlickGesture = new (std::nothrow) _TouchFlickGestureDetector; + SysTryCatch(NID_UI_CTRL, pTab->__pFlickGesture, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pTab->AddGestureDetector(*(pTab->__pFlickGesture)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r)); + + r = pTab->__pFlickGesture->AddGestureListener(*pTab); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _ITouchGestureEventListener instance could not be set."); + + return pTab; + +CATCH: + if (pTab->__pGestureLongPress != null) + { + pTab->__pGestureLongPress->RemoveGestureListener(*pTab); + pTab->RemoveGestureDetector(*pTab->__pGestureLongPress); + + delete pTab->__pGestureLongPress; + pTab->__pGestureLongPress = null; + } + if (pTab->__pFlickGesture != null) + { + pTab->__pFlickGesture->RemoveGestureListener(*pTab); + pTab->RemoveGestureDetector(*pTab->__pFlickGesture); + + delete pTab->__pFlickGesture; + pTab->__pFlickGesture = null; + } + + delete pTab; + return null; +} + +result +_Tab::SetPresenter(const _TabPresenter& tabPresenter) +{ + ClearLastResult(); + __pTabPresenter = const_cast<_TabPresenter*>(&tabPresenter); + + return E_SUCCESS; +} + +result +_Tab::AddItem(const Bitmap& icon, const String& text, int actionId) +{ + if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX) + { + SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId); + return E_OUT_OF_RANGE; + } + + if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT))) + { + return E_SYSTEM; + } + + __style = _TAB_STYLE_ICON_TEXT; + + bool isDuplicate = CheckDuplicatedActionId(actionId); + SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred. The tab already has an item with same action id (%d).", actionId); + + int itemCount = __tabItems.GetCount(); + + SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items."); + + _TabItem *pItem = new (std::nothrow) _TabItem; + SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + pItem->SetIcon(icon); + pItem->SetText(text); + pItem->SetActionId(actionId); + pItem->SetUpdateState(true); + + if (itemCount > 0) + { + pItem->SetStatus(_TABITEM_STATUS_NORMAL); + } + else + { + pItem->SetStatus(_TABITEM_STATUS_SELECTED); + } + + __pTabPresenter->SetReCalculateItemBounds(true); + + return __tabItems.Add(*pItem); +} + +result +_Tab::AddItem(const Bitmap& icon, int actionId) +{ + if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX) + { + SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId); + return E_OUT_OF_RANGE; + } + + if (__style != _TAB_STYLE_ICON) + { + return E_SYSTEM; + } + + bool isDuplicate = CheckDuplicatedActionId(actionId); + SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred. The tab already has an item with same action id (%d).", actionId); + + int itemCount = __tabItems.GetCount(); + + SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items."); + + _TabItem *pItem = new (std::nothrow) _TabItem; + SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + pItem->SetIcon(icon); + pItem->SetActionId(actionId); + pItem->SetUpdateState(true); + + if (itemCount > 0) + { + pItem->SetStatus(_TABITEM_STATUS_NORMAL); + } + else + { + pItem->SetStatus(_TABITEM_STATUS_SELECTED); + } + + __pTabPresenter->SetReCalculateItemBounds(true); + + return __tabItems.Add(*pItem); +} + +result +_Tab::AddItem(const String& text, int actionId) +{ + if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX) + { + SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId); + return E_OUT_OF_RANGE; + } + + if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT))) + { + return E_SYSTEM; + } + + bool isDuplicate = CheckDuplicatedActionId(actionId); + SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred. The tab already has an item with same action id (%d).", actionId); + + int itemCount = __tabItems.GetCount(); + + SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items."); + + _TabItem *pItem = new (std::nothrow) _TabItem; + SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + pItem->SetText(text); + pItem->SetActionId(actionId); + pItem->SetUpdateState(true); + + if (itemCount > 0) + { + pItem->SetStatus(_TABITEM_STATUS_NORMAL); + } + else + { + pItem->SetStatus(_TABITEM_STATUS_SELECTED); + } + + __pTabPresenter->SetReCalculateItemBounds(true); + + + return __tabItems.Add(*pItem); +} + +result +_Tab::InsertItemAt(int index, const Bitmap& icon, const String& text, int actionId) +{ + result r = E_SUCCESS; + bool selected = false; + + if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX) + { + SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId); + return E_OUT_OF_RANGE; + } + + if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT))) + { + return E_SYSTEM; + } + + __style = _TAB_STYLE_ICON_TEXT; + + bool isDuplicate = CheckDuplicatedActionId(actionId); + SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred.The tab already has an item with same action id (%d).", actionId); + + int itemCount = __tabItems.GetCount(); + + SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items."); + + _TabItem *pItem = new (std::nothrow) _TabItem; + SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + pItem->SetIcon(icon); + pItem->SetText(text); + pItem->SetActionId(actionId); + pItem->SetUpdateState(true); + + int i = GetSelectedItemIndex(); + + if (i >= index) + { + _TabItem *pSelectedItem = null; + pSelectedItem = GetItemAt(i); + if (pSelectedItem != null) + { + selected = true; + pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL); + } + } + else + { + pItem->SetStatus(_TABITEM_STATUS_NORMAL); + } + + __pTabPresenter->SetReCalculateItemBounds(true); + + r = __tabItems.InsertAt(*pItem, index); + + if (selected) + { + SetSelectedItemIndex(i); + } + + return r; +} + +result +_Tab::InsertItemAt(int index, const Bitmap& icon, int actionId) +{ + result r = E_SUCCESS; + bool selected = false; + + if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX) + { + SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId); + return E_OUT_OF_RANGE; + } + + if (__style != _TAB_STYLE_ICON) + { + return E_SYSTEM; + } + + bool isDuplicate = CheckDuplicatedActionId(actionId); + SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred.The tab already has an item with same action id (%d).", actionId); + + int itemCount = __tabItems.GetCount(); + + SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items."); + + _TabItem *pItem = new (std::nothrow) _TabItem; + SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + pItem->SetIcon(icon); + pItem->SetActionId(actionId); + pItem->SetUpdateState(true); + int i = GetSelectedItemIndex(); + + if (i >= index) + { + _TabItem *pSelectedItem = null; + pSelectedItem = GetItemAt(i); + if (pSelectedItem != null) + { + selected = true; + pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL); + } + } + else + { + pItem->SetStatus(_TABITEM_STATUS_NORMAL); + } + + __pTabPresenter->SetReCalculateItemBounds(true); + + r = __tabItems.InsertAt(*pItem, index); + + if (selected) + { + SetSelectedItemIndex(i); + } + + return r; +} + +result +_Tab::InsertItemAt(int index, const String& text, int actionId) +{ + result r = E_SUCCESS; + bool selected = false; + + if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX) + { + SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId); + return E_OUT_OF_RANGE; + } + + bool isDuplicate = CheckDuplicatedActionId(actionId); + SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred.The tab already has an item with same action id (%d).", actionId); + + if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT))) + { + return E_SYSTEM; + } + + int itemCount = __tabItems.GetCount(); + + SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items."); + + _TabItem *pItem = new (std::nothrow) _TabItem; + SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + pItem->SetText(text); + pItem->SetActionId(actionId); + pItem->SetUpdateState(true); + int i = GetSelectedItemIndex(); + + if (i >= index) + { + _TabItem *pSelectedItem = null; + pSelectedItem = GetItemAt(i); + if (pSelectedItem != null) + { + selected = true; + pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL); + } + } + else + { + pItem->SetStatus(_TABITEM_STATUS_NORMAL); + } + + __pTabPresenter->SetReCalculateItemBounds(true); + + r = __tabItems.InsertAt(*pItem, index); + + if (selected) + { + SetSelectedItemIndex(i); + } + + return r; +} + +result +_Tab::SetItemAt(int index, const Bitmap& icon, const String& text, int actionId) +{ + if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX) + { + SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId); + return E_OUT_OF_RANGE; + } + + if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT))) + { + return E_SYSTEM; + } + + __style = _TAB_STYLE_ICON_TEXT; + + int itemCount = __tabItems.GetCount(); + + if ((index < 0) || (index >= itemCount)) + { + return E_OUT_OF_RANGE; + } + + SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items."); + + if (GetItemIndex(actionId) != index) + { + return E_SYSTEM; + } + + _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index)); + result r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pItem->SetIcon(icon); + pItem->SetText(text); + pItem->SetActionId(actionId); + pItem->SetUpdateState(true); + + return E_SUCCESS; +} + +result +_Tab::SetItemAt(int index, const Bitmap& icon, int actionId) +{ + if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX) + { + SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId); + return E_OUT_OF_RANGE; + } + + if (__style != _TAB_STYLE_ICON) + { + return E_SYSTEM; + } + + int itemCount = __tabItems.GetCount(); + + if ((index < 0) || (index >= itemCount)) + { + return E_OUT_OF_RANGE; + } + + SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items."); + + if (GetItemIndex(actionId) != index) + { + return E_SYSTEM; + } + + _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index)); + result r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pItem->SetIcon(icon); + pItem->SetActionId(actionId); + pItem->SetUpdateState(true); + + return E_SUCCESS; +} + +result +_Tab::SetItemAt(int index, const String& text, int actionId) +{ + if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX) + { + SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId); + return E_OUT_OF_RANGE; + } + + if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT))) + { + return E_SYSTEM; + } + + int itemCount = __tabItems.GetCount(); + + if ((index < 0) || (index >= itemCount)) + { + return E_OUT_OF_RANGE; + } + + SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items."); + + if (GetItemIndex(actionId) != index) + { + return E_SYSTEM; + } + + _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index)); + result r = GetLastResult(); + SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pItem->SetText(text); + pItem->SetActionId(actionId); + pItem->SetUpdateState(true); + + return E_SUCCESS; +} + +result +_Tab::RemoveItemAt(int index) +{ + result r = E_SUCCESS; + int i = GetSelectedItemIndex(); + + if (i >= index) + { + _TabItem *pSelectedItem = null; + pSelectedItem = GetItemAt(i); + if (pSelectedItem != null) + { + pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL); + } + } + __pTabPresenter->SetReCalculateItemBounds(true); + + r = __tabItems.RemoveAt(index, true); + + SetSelectedItemIndex(0); + + return r; +} + +result +_Tab::RemoveAllItems(void) +{ + __pTabPresenter->SetReCalculateItemBounds(true); + SetSelectedItemIndex(0); + SetFirstDrawnItemIndex(-1); + + __tabItems.RemoveAll(true); + + return E_SUCCESS; +} + +bool +_Tab::ChangeItemAt(const int srcIndex, const int destIndex) +{ + _TabItem* pItem = null; + pItem = GetItemAt(srcIndex); + + __tabItems.InsertAt(*pItem, destIndex); + + if (srcIndex > destIndex) + { + __tabItems.RemoveAt((srcIndex + 1), false); + } + else + { + __tabItems.RemoveAt(srcIndex, false); + } + + return true; +} + +int +_Tab::GetItemIndex(int actionId) +{ + int itemCount = __tabItems.GetCount(); + + _TabItem* pItem = null; + + for (int i = 0; i < itemCount; i++) + { + pItem = GetItemAt(i); + + if ((pItem != null) && (actionId == pItem->GetActionId())) + { + return i; + } + } + + return -1; +} + +bool +_Tab::CheckDuplicatedActionId(int actionId) +{ + int itemIndex = GetItemIndex(actionId); + + if (itemIndex >= 0) + { + return true; + } + + return false; +} + +result +_Tab::LoadBitmap(void) +{ + result r = E_SUCCESS; + + r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pPressedItemBackgroundBitmap); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate pressed item background bitmap."); + + if (__pPressedItemBackgroundBitmap) + { + __pPressedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(__pPressedItemBackgroundBitmap), Color::GetColor(COLOR_ID_MAGENTA), GetPressedItemBackgroundColor()); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate pressed item background bitmap."); + } + + r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_EFFECT_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pHighlightedItemBackgroundBitmap); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate highlighted item background bitmap."); + + if (__pHighlightedItemBackgroundBitmap) + { + __pHighlightedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(__pHighlightedItemBackgroundBitmap), Color::GetColor(COLOR_ID_MAGENTA), GetHighlightedItemBackgroundColor()); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate highlighted item background bitmap."); + } + return r; +} + +result +_Tab::SetBadgeIcon(int actionId, const Bitmap* pBadgeIcon) +{ + result r = E_SUCCESS; + + if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX) + { + SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId); + return E_OUT_OF_RANGE; + } + + int itemIndex = GetItemIndexFromActionId(actionId); + + _TabItem *pItem = null; + + if (itemIndex < 0) + { + SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument(s) is used. The specified actionId is not found."); + return E_INVALID_ARG; + } + + pItem = dynamic_cast<_TabItem*>(__tabItems.GetAt(itemIndex)); + + if (pItem != null) + { + pItem->SetBadgeIcon(*pBadgeIcon); + + r = __tabItems.SetAt(*pItem, itemIndex, false); + } + + return r; +} + +int +_Tab::GetItemCount(void) const +{ + return __tabItems.GetCount(); +} + +int +_Tab::GetItemIndexFromActionId(int actionId) const +{ + if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX) + { + SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId); + return -1; + } + + int index = 0; + int itemCount = __tabItems.GetCount(); + + for (index = 0; index < itemCount; index++) + { + const _TabItem *pItem = dynamic_cast(__tabItems.GetAt(index)); + + if (pItem != null) + { + if (pItem->GetActionId() == actionId) + { + return index; + } + } + } + + return -1; +} + +int +_Tab::GetItemActionIdAt(int index) const +{ + if (__tabItems.GetAt(index) == null ) + { + return -1; + } + + const _TabItem *pItem = dynamic_cast(__tabItems.GetAt(index)); + SysTryReturn(NID_UI_CTRL, pItem != null, E_SYSTEM, E_SYSTEM,"[E_SYSTEM] A system error has occurred. Failed to get an item at index (%d).", index); + + return pItem->GetActionId(); +} + +_TabItem* +_Tab::GetItemAt(int index) +{ + if (__tabItems.GetAt(index) == null ) + { + return null; + } + + _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index)); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pItem != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pItem; +} + +void +_Tab::SetSelectedItemIndex(int index) +{ + __pTabPresenter->SetSelectedItemIndex(index); + return; +} + +int +_Tab::GetSelectedItemIndex(void) const +{ + return __pTabPresenter->GetSelectedItemIndex(); +} + +void +_Tab::SetFirstDrawnItemIndex(int index) +{ + __pTabPresenter->SetFirstDrawnItemIndex(index); + return; +} + +int +_Tab::GetFirstDrawnItemIndex(void) const +{ + return __pTabPresenter->GetFirstDrawnItemIndex(); +} + +void +_Tab::SetEditModeEnabled(bool enable) +{ + return __pTabPresenter->SetEditModeEnabled(enable); +} + +bool +_Tab::IsEditModeEnabled(void) const +{ + return __pTabPresenter->IsEditModeEnabled(); +} + +result +_Tab::SetBackgroundBitmap(const Bitmap& bitmap) +{ + ClearLastResult(); + + Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap); + + SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (__pBackgroundBitmap) + { + delete __pBackgroundBitmap; + __pBackgroundBitmap = null; + } + + __pBackgroundBitmap = pBitmap; + + return E_SUCCESS; +} + +Bitmap* +_Tab::GetBackgroundBitmap(void) const +{ + return __pBackgroundBitmap; +} + + +result +_Tab::SetPressedItemBackgroundBitmap(const Bitmap& bitmap) +{ + ClearLastResult(); + + Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap); + + SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (__pPressedItemBackgroundBitmap) + { + delete __pPressedItemBackgroundBitmap; + __pPressedItemBackgroundBitmap = null; + } + + __pPressedItemBackgroundBitmap = pBitmap; + return E_SUCCESS; +} + +Bitmap* +_Tab::GetPressedItemBackgroundBitmap(void) const +{ + return __pPressedItemBackgroundBitmap; +} + +result +_Tab::SetSelectedItemBackgroundBitmap(const Bitmap& bitmap) +{ + ClearLastResult(); + + Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap); + + SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (__pSelectedItemBackgroundBitmap) + { + delete __pSelectedItemBackgroundBitmap; + __pSelectedItemBackgroundBitmap = null; + } + __pSelectedItemBackgroundBitmap = pBitmap; + __pTabPresenter->FreeHorizontalLineBitmap(); + + return E_SUCCESS; +} + + +Bitmap* +_Tab::GetSelectedItemBackgroundBitmap(void) const +{ + return __pSelectedItemBackgroundBitmap; +} + +result +_Tab::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap) +{ + ClearLastResult(); + + Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap); + + SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (__pHighlightedItemBackgroundBitmap) + { + delete __pHighlightedItemBackgroundBitmap; + __pHighlightedItemBackgroundBitmap = null; + } + + __pHighlightedItemBackgroundBitmap = pBitmap; + + return E_SUCCESS; +} + +Bitmap* +_Tab::GetHighlightedItemBackgroundBitmap(void) const +{ + return __pHighlightedItemBackgroundBitmap; +} + +void +_Tab::SetItemBackgroundColor(Color color) +{ + __itemBgColor[_TAB_STATUS_NORMAL] = color; + return; +} + +Color +_Tab::GetItemBackgroundColor(void) const +{ + return __itemBgColor[_TAB_STATUS_NORMAL]; +} + +void +_Tab::SetPressedItemBackgroundColor(Color color) +{ + __itemBgColor[_TAB_STATUS_PRESSED] = color; + return; +} + +Color +_Tab::GetPressedItemBackgroundColor(void) const +{ + return __itemBgColor[_TAB_STATUS_PRESSED]; +} + +void +_Tab::SetSelectedItemBackgroundColor(Color color) +{ + __itemBgColor[_TAB_STATUS_SELECTED] = color; + return; +} + +Color +_Tab::GetSelectedItemBackgroundColor(void) const +{ + return __itemBgColor[_TAB_STATUS_SELECTED]; +} + +void +_Tab::SetHighlightedItemBackgroundColor(Color color) +{ + __itemBgColor[_TAB_STATUS_HIGHLIGHTED] = color; + return; +} + +Color +_Tab::GetHighlightedItemBackgroundColor(void) const +{ + return __itemBgColor[_TAB_STATUS_HIGHLIGHTED]; +} + +void +_Tab::SetTextColor(const Color& textColor) +{ + __itemTextColor[_TAB_STATUS_NORMAL] = textColor; + return; +} + +Color +_Tab::GetTextColor(void) const +{ + return __itemTextColor[_TAB_STATUS_NORMAL]; +} + +void +_Tab::SetPressedTextColor(const Color& textColor) +{ + __itemTextColor[_TAB_STATUS_PRESSED] = textColor; + return; +} + +Color +_Tab::GetPressedTextColor(void) const +{ + return __itemTextColor[_TAB_STATUS_PRESSED]; +} + +void +_Tab::SetSelectedTextColor(const Color& textColor) +{ + __itemTextColor[_TAB_STATUS_SELECTED] = textColor; + return; +} + +Color +_Tab::GetSelectedTextColor(void) const +{ + return __itemTextColor[_TAB_STATUS_SELECTED]; +} + +void +_Tab::SetHighlightedTextColor(const Color& color) +{ + __itemTextColor[_TAB_STATUS_HIGHLIGHTED] = color; + return; +} + +Color +_Tab::GetHighlightedTextColor(void) const +{ + return __itemTextColor[_TAB_STATUS_HIGHLIGHTED]; +} + +void +_Tab::SetStyle(int style) +{ + __style = style; + return; +} + +_TabStyle +_Tab::GetStyle(void) const +{ + return _TabStyle(__style); +} + +void +_Tab::AddActionEventListener(const _IActionEventListener& listener) +{ + ClearLastResult(); + + if (__pActionEvent == null) + { + __pActionEvent = _ActionEvent::CreateInstanceN(*this); + + if (__pActionEvent == null || IsFailed(GetLastResult())) + { + SetLastResult(E_SYSTEM); + delete __pActionEvent; + return; + } + } + __pActionEvent->AddListener(listener); + return; +} + +void +_Tab::RemoveActionEventListener(const _IActionEventListener& listener) +{ + ClearLastResult(); + + __pActionEvent->RemoveListener(listener); + return; +} + +bool +_Tab::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (this != &source) + { + return true; + } + + return __pTabPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_Tab::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (this != &source) + { + return true; + } + + __pTabPresenter->OnTouchReleased(source, touchinfo); + + int index = __pTabPresenter->GetItemIndexFromPosition(touchinfo.GetCurrentPosition()); + + _TabItem* pItem = __pTabPresenter->GetItemAt(index); + + if (pItem == null) + { + return true; + } + + if (__pActionEvent) + { + IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(pItem->GetActionId()); + SysTryReturn(NID_UI_CTRL, pEventArg, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pActionEvent->Fire(*pEventArg); + } + + return true; +} + +bool +_Tab::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (this != &source) + { + return true; + } + + return __pTabPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_Tab::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture) +{ + return __pTabPresenter->OnLongPressGestureDetected(); +} + +bool +_Tab::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture) +{ + return false; +} + +bool +_Tab::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) +{ + + return __pTabPresenter->OnFlickGestureDetected(gesture); +} + +bool +_Tab::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture) +{ + return false; +} + +void +_Tab::OnDraw(void) +{ + ClearLastResult(); + __pTabPresenter->Draw(); + return; + +} + +void +_Tab::OnBoundsChanged(void) +{ + __pTabPresenter->OnBoundsChanged(); +} + +result +_Tab::OnAttachedToMainTree(void) +{ + _AccessibilityContainer* pContainer = null; + + if (likely((_AccessibilityManager::IsActivated()))) + { + pContainer = GetAccessibilityContainer(); + + if (pContainer) + { + pContainer->Activate(true); + pContainer->AddListener(*this); + } + } + + return E_SUCCESS; +} + +void +_Tab::OnFontChanged(Font* pFont) +{ + __pTabPresenter->OnFontChanged(pFont); + return; +} + +void +_Tab::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pTabPresenter->OnFontInfoRequested(style, size); + return; +} + +void +_Tab::AddAccessibilityElement(const Rectangle& itemBounds, const String& itemText, _TabItemStatus status) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if (pContainer != null) + { + _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_TAB); + pAccessibilityElement->SetHint(L"Double tap to move to contents"); + pAccessibilityElement->SetBounds(itemBounds); + + if (GetStyle() != _TAB_STYLE_ICON) + { + pAccessibilityElement->SetLabel(itemText); + } + + if (status == _TABITEM_STATUS_SELECTED) + { + pAccessibilityElement->SetStatus("Selected"); + } + else + { + pAccessibilityElement->SetStatus(""); + } + + pContainer->AddElement(*pAccessibilityElement); + __accessibilityElements.Add(pAccessibilityElement); + } + + return; +} + +void +_Tab::RemoveAllAccessibilityElement(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if (pContainer == null) + { + return; + } + + _AccessibilityElement* pAccessibilityElement = null; + + while (__accessibilityElements.GetCount() > 0) + { + if ((__accessibilityElements.GetAt(0, pAccessibilityElement)) == E_SUCCESS) + { + pContainer->RemoveElement(*pAccessibilityElement); + __accessibilityElements.RemoveAt(0); + } + else + { + __accessibilityElements.RemoveAt(0); + } + } + + return; +} + +bool +_Tab::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + ClearLastResult(); + + return __pTabPresenter->OnAccessibilityFocusMovedNext(control, element); +} + +bool +_Tab::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + ClearLastResult(); + + return __pTabPresenter->OnAccessibilityFocusMovedPrevious(control, element); +} + +bool +_Tab::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_Tab::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_Tab::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_Tab::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_Tab::OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&) +{ + return false; +} + +bool +_Tab::OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&) +{ + return false; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_TabBar.cpp b/src/ui/controls/FUiCtrl_TabBar.cpp new file mode 100644 index 0000000..f4e1868 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TabBar.cpp @@ -0,0 +1,569 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabBar.cpp + * @brief This is the implementation file for the _TabBar class. + */ + + +#include +#include +#include "FUi_UiTouchEvent.h" +#include "FUi_ResourceManager.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUiCtrl_TabBar.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_TabBar); + +_TabBar::_TabBar() + : __pTabBarPresenter(null) + , __pActionEvent(null) +{ + GET_COLOR_CONFIG(TABBAR::BG_NORMAL, __color); + + GET_COLOR_CONFIG(TABBAR::ITEM_BG_NORMAL, __itemColor[ITEM_STATUS_NORMAL]); + GET_COLOR_CONFIG(TABBAR::ITEM_BG_PRESSED, __itemColor[ITEM_STATUS_SELECTED]); + GET_COLOR_CONFIG(TABBAR::ITEM_BG_HIGHLIGHTED, __itemColor[ITEM_STATUS_HIGHLIGHTED]); + + GET_COLOR_CONFIG(TABBAR::ITEM_TEXT_NORMAL, __itemTextColor[ITEM_STATUS_NORMAL]); + GET_COLOR_CONFIG(TABBAR::ITEM_TEXT_PRESSED, __itemTextColor[ITEM_STATUS_SELECTED]); + GET_COLOR_CONFIG(TABBAR::ITEM_TEXT_HIGHLIGHTED, __itemTextColor[ITEM_STATUS_HIGHLIGHTED]); +} + +_TabBar::~_TabBar(void) +{ + delete __pTabBarPresenter; + __pTabBarPresenter = null; + + if (__pActionEvent) + { + delete __pActionEvent; + __pActionEvent = null; + } + + RemoveAllAccessibilityElement(); +} + +_TabBar* +_TabBar::CreateTabBarN(void) +{ + _TabBar* pTabBar = new (std::nothrow) _TabBar(); + SysTryReturn(NID_UI_CTRL, pTabBar != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = pTabBar->Initialize(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Initialize.", GetErrorMessage(r)); + + pTabBar->AcquireHandle(); + pTabBar->SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_NORMAL); + + if (pTabBar->GetAccessibilityContainer() != null) + { + pTabBar->GetAccessibilityContainer()->Activate(true); + } + + return pTabBar; + +CATCH: + delete pTabBar; + + return null; +} + +result +_TabBar::Initialize(void) +{ + result r; + + _TabBarPresenter* pTabBarPresenter = new (std::nothrow) _TabBarPresenter(*this); + SysTryReturn(NID_UI_CTRL, pTabBarPresenter != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pTabBarPresenter->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = SetPresenter(*pTabBarPresenter); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTabBarPresenter->InitializeFont(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + __pTabBarPresenter = null; + + delete pTabBarPresenter; + + return r; +} + +result +_TabBar::SetPresenter(const _TabBarPresenter& tabBarPresenter) +{ + __pTabBarPresenter = const_cast<_TabBarPresenter*>(&tabBarPresenter); + + return E_SUCCESS; +} + +result +_TabBar::AddItem(const Tizen::Base::String& text, int actionId) +{ + return __pTabBarPresenter->AddItem(text, actionId); +} + +result +_TabBar::InsertItemAt(int index, const Tizen::Base::String& text, int actionId) +{ + return __pTabBarPresenter->InsertItemAt(index, text, actionId); +} + +result +_TabBar::SetItemAt(int index, const Tizen::Base::String& text, int actionId) +{ + return __pTabBarPresenter->SetItemAt(index, text, actionId); +} + +result +_TabBar::RemoveItemAt(int index) +{ + return __pTabBarPresenter->RemoveItemAt(index); +} + +result +_TabBar::RemoveAllItems(void) +{ + return __pTabBarPresenter->RemoveAllItems(); +} + +result +_TabBar::SetPropertyColor(const Variant& color) +{ + result r = E_SUCCESS; + + r = __pTabBarPresenter->SetReplacementColor(color.ToColor()); + + if (r == E_SUCCESS) + { + __color = color.ToColor(); + } + + return r; +} + +Variant +_TabBar::GetPropertyColor(void) const +{ + return Tizen::Ui::Variant(__color); +} + +result +_TabBar::SetColor(Tizen::Graphics::Color color) +{ + return SetProperty("color", Variant(color)); +} + +Tizen::Graphics::Color +_TabBar::GetColor(void) const +{ + Variant color = GetProperty("color"); + + return color.ToColor(); +} + +result +_TabBar::SetPropertyNormalItemColor(const Variant& color) +{ + result r = E_SUCCESS; + + r = __pTabBarPresenter->SetItemReplacementColor(ITEM_STATUS_NORMAL, color.ToColor()); + if (r == E_SUCCESS) + { + __itemColor[ITEM_STATUS_NORMAL] = color.ToColor(); + } + + return r; +} + +Variant +_TabBar::GetPropertyNormalItemColor(void) const +{ + return Tizen::Ui::Variant(__itemColor[ITEM_STATUS_NORMAL]); +} + +result +_TabBar::SetPropertySelectedItemColor(const Variant& color) +{ + result r = E_SUCCESS; + + r = __pTabBarPresenter->SetItemReplacementColor(ITEM_STATUS_SELECTED, color.ToColor()); + if (r == E_SUCCESS) + { + __itemColor[ITEM_STATUS_SELECTED] = color.ToColor(); + } + + return r; +} + +Variant +_TabBar::GetPropertySelectedItemColor(void) const +{ + return Tizen::Ui::Variant(__itemColor[ITEM_STATUS_SELECTED]); +} + +result +_TabBar::SetPropertyHighlightedItemColor(const Variant& color) +{ + result r = E_SUCCESS; + + r = __pTabBarPresenter->SetItemReplacementColor(ITEM_STATUS_HIGHLIGHTED, color.ToColor()); + if (r == E_SUCCESS) + { + __itemColor[ITEM_STATUS_HIGHLIGHTED] = color.ToColor(); + } + + return r; +} + +Variant +_TabBar::GetPropertyHighlightedItemColor(void) const +{ + return Tizen::Ui::Variant(__itemColor[ITEM_STATUS_HIGHLIGHTED]); +} + +result +_TabBar::SetItemColor(_TabBarItemStatus itemStatus, Tizen::Graphics::Color color) +{ + result r = E_SUCCESS; + + if (itemStatus == ITEM_STATUS_NORMAL) + { + r = SetProperty("normalItemColor", Variant(color)); + } + else if (itemStatus == ITEM_STATUS_SELECTED) + { + r = SetProperty("selectedItemColor", Variant(color)); + } + else + { + r = SetProperty("highlightedItemColor", Variant(color)); + } + + return r; +} + +Tizen::Graphics::Color +_TabBar::GetItemColor(_TabBarItemStatus itemStatus) const +{ + Color itemColor; + + if (itemStatus == ITEM_STATUS_NORMAL) + { + Variant color = GetProperty("normalItemColor"); + itemColor = color.ToColor(); + } + else if (itemStatus == ITEM_STATUS_SELECTED) + { + Variant color = GetProperty("selectedItemColor"); + itemColor = color.ToColor(); + } + else + { + Variant color = GetProperty("highlightedItemColor"); + itemColor = color.ToColor(); + } + + return itemColor; +} + +result +_TabBar::SetPropertyNormalItemTextColor(const Variant & color) +{ + __itemTextColor[ITEM_STATUS_NORMAL] = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_TabBar::GetPropertyNormalItemTextColor(void) const +{ + return Tizen::Ui::Variant(__itemTextColor[ITEM_STATUS_NORMAL]); +} + +result +_TabBar::SetPropertySelectedItemTextColor(const Variant & color) +{ + __itemTextColor[ITEM_STATUS_SELECTED] = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_TabBar::GetPropertySelectedItemTextColor(void) const +{ + return Tizen::Ui::Variant(__itemTextColor[ITEM_STATUS_SELECTED]); +} + +result +_TabBar::SetPropertyHighlightedItemTextColor(const Variant & color) +{ + __itemTextColor[ITEM_STATUS_HIGHLIGHTED] = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_TabBar::GetPropertyHighlightedItemTextColor(void) const +{ + return Tizen::Ui::Variant(__itemTextColor[ITEM_STATUS_HIGHLIGHTED]); +} + + +void +_TabBar::SetItemTextColor(_TabBarItemStatus status, Tizen::Graphics::Color color) +{ + Color itemTextColor; + result r = E_SUCCESS; + + if (status == ITEM_STATUS_NORMAL) + { + r = SetProperty("normalItemTextColor", Variant(color)); + } + else if (status == ITEM_STATUS_SELECTED) + { + r = SetProperty("selectedItemTextColor", Variant(color)); + } + else + { + r = SetProperty("highlightedItemTextColor", Variant(color)); + } + + if (r != E_SUCCESS) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "Color is invalid."); + } + +} + +Tizen::Graphics::Color +_TabBar::GetItemTextColor(_TabBarItemStatus status) const +{ + Color itemTextColor; + + if (status == ITEM_STATUS_NORMAL) + { + Variant color = GetProperty("normalItemTextColor"); + itemTextColor = color.ToColor(); + } + else if (status == ITEM_STATUS_SELECTED) + { + Variant color = GetProperty("selectedItemTextColor"); + itemTextColor = color.ToColor(); + } + else + { + Variant color = GetProperty("highlightedItemTextColor"); + itemTextColor = color.ToColor(); + } + + return itemTextColor; +} + +result +_TabBar::SetItemSelected(int index) +{ + return __pTabBarPresenter->SetItemSelected(index); +} + +int +_TabBar::GetSelectedItemIndex(void) const +{ + return __pTabBarPresenter->GetSelectedItemIndex(); +} + +int +_TabBar::GetItemCount(void) const +{ + return __pTabBarPresenter->GetItemCount(); +} + +_TabBarItem* +_TabBar::GetItemFromPosition(const Tizen::Graphics::Point& position) const +{ + return __pTabBarPresenter->GetItemFromPosition(position); +} + +result +_TabBar::SetTopDrawnItemIndex(int index) +{ + return __pTabBarPresenter->SetTopDrawnItemIndex(index); +} + +result +_TabBar::SetWidth(int width) +{ + result r; + int height = 0; + + GET_SHAPE_CONFIG(TABBAR::HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, height); + r = SetSize(Dimension(width, height)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + __pTabBarPresenter->InitItemPositionX(); + + return r; +} + +void +_TabBar::AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener) +{ + ClearLastResult(); + + if (__pActionEvent == null) + { + __pActionEvent = _ActionEvent::CreateInstanceN(*this); + + if (__pActionEvent == null || IsFailed(GetLastResult())) + { + SysLog(NID_UI_CTRL, "[E_INVALID_STATE] System error occured."); + SetLastResult(E_INVALID_STATE); + delete __pActionEvent; + return; + } + } + + SetLastResult(E_SUCCESS); + __pActionEvent->AddListener(listener); +} + +void +_TabBar::RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pActionEvent != null, E_INVALID_STATE, "[E_INVALID_STATE] This instance isn't constructed.") + // Todo : check fail case of RemoveListener + __pActionEvent->RemoveListener(listener); +} + +bool +_TabBar::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pTabBarPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_TabBar::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + bool eventFire = __pTabBarPresenter->OnTouchReleased(source, touchinfo); + if (eventFire == true) + { + int index = __pTabBarPresenter->GetItemIndexFromPosition(touchinfo.GetCurrentPosition()); + _TabBarItem* pItem = __pTabBarPresenter->GetItemAt(index); + if (pItem != null) + { + if (__pActionEvent) + { + IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(pItem->GetActionId()); + SysTryReturn(NID_UI_CTRL, pEventArg != null, E_INVALID_STATE, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pActionEvent->Fire(*pEventArg); + } + } + } + + return true; +} + +bool +_TabBar::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pTabBarPresenter->OnTouchMoved(source, touchinfo); +} + +void +_TabBar::OnFontChanged(Font * pFont) +{ + __pTabBarPresenter->OnFontChanged(pFont); +} + +void +_TabBar::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pTabBarPresenter->OnFontInfoRequested(style, size); +} + +void +_TabBar::OnDraw(void) +{ + __pTabBarPresenter->Draw(); + _Control::Show(); + SetAllAccessibilityElement(); +} + +void +_TabBar::OnBoundsChanged(void) +{ + __pTabBarPresenter->OnBoundsChanged(); +} + +_AccessibilityElement* +_TabBar::GetAccessibilityElement(const int mainIndex) const +{ + _AccessibilityElement* pElement = null; + result r = __accessibilityElements.GetAt(mainIndex, pElement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed at AccessibiltyElement.", GetErrorMessage(r)); + + return pElement; + +CATCH: + delete pElement; + + return null; +} + +void +_TabBar::AddAccessibilityElement(const _AccessibilityElement& element) +{ + __accessibilityElements.Add(const_cast<_AccessibilityElement*>(&element)); +} + +void +_TabBar::SetAllAccessibilityElement(void) +{ + RemoveAllAccessibilityElement(); + __pTabBarPresenter->SetAllAccessibilityElement(); +} + +void +_TabBar::RemoveAllAccessibilityElement(void) +{ + while (__accessibilityElements.GetCount() > 0) + { + _AccessibilityElement* pElement = null; + if (__accessibilityElements.GetAt(0, pElement) == E_SUCCESS) + { + pElement->GetParent()->RemoveElement(*pElement); + __accessibilityElements.RemoveAt(0); + } + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TabBarImpl.cpp b/src/ui/controls/FUiCtrl_TabBarImpl.cpp new file mode 100644 index 0000000..a6927c2 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TabBarImpl.cpp @@ -0,0 +1,446 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include "FUiCtrl_TabBarImpl.h" +#include "FUiCtrl_TabBarItem.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" + +//UiBuilder +#include +#include "FUi_UiBuilder.h" + +using namespace Tizen::Ui; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Tizen::Graphics::Dimension +_TabBarImpl::TabBarSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + + Tizen::Graphics::Dimension dimension(0, 0); + + GET_SHAPE_CONFIG(TABBAR::MIN_WIDTH, orientation, dimension.width); + + SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] System Error.", GetErrorMessage(r)); + return dimension; +} + +_TabBarImpl* +_TabBarImpl::GetInstance(TabBar& tabBar) +{ + return static_cast<_TabBarImpl*> (tabBar._pControlImpl); +} + +const _TabBarImpl* +_TabBarImpl::GetInstance(const TabBar& tabBar) +{ + return static_cast (tabBar._pControlImpl); +} + +_TabBarImpl::_TabBarImpl(TabBar* pTabBar, _TabBar* pCore) + : _ControlImpl(pTabBar, pCore) + , __pPublicActionEvent(null) +{ +} + +_TabBarImpl::~_TabBarImpl(void) +{ + if (__pPublicActionEvent) + { + delete __pPublicActionEvent; + __pPublicActionEvent = null; + } +} + +_TabBarImpl* +_TabBarImpl::CreateTabBarImplN(TabBar* pTabBar, const Tizen::Graphics::Rectangle& bounds) +{ + ClearLastResult(); + SysTryReturn(NID_UI_CTRL, bounds.width >= 0 && bounds.height >= 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified width is smaller than minimum size."); + + int minWidth = 0; + int maxWidth = 0; + int height = 0; + GET_SHAPE_CONFIG(TABBAR::MIN_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, minWidth); + GET_SHAPE_CONFIG(TABBAR::MAX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, maxWidth); + GET_SHAPE_CONFIG(TABBAR::HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, height); + + result r = E_SUCCESS; + //r = GET_SIZE_INFO(TabBar).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified width is smaller than minimum size."); + + _TabBar* pCore = _TabBar::CreateTabBarN(); + SysTryReturn(NID_UI_CTRL, pCore != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] _TabBar is not constructed."); + + _TabBarImpl* pImpl = new (std::nothrow) _TabBarImpl(pTabBar, pCore); + r = CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->SetBounds(Rectangle(bounds.x, bounds.y, bounds.width, height)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] SetBounds is failed.", GetErrorMessage(r)); + + r = pImpl->SetMinimumSize(Dimension(minWidth, height)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] SetMinimumSize is failed.", GetErrorMessage(r)); + + r = pImpl->SetMaximumSize(Dimension(maxWidth, height)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] SetMaximumSize is failed.", GetErrorMessage(r)); + + return pImpl; + +CATCH: + delete pImpl; + + return null; +} + +result +_TabBarImpl::AddItem(const Tizen::Base::String& text, int actionId) +{ + int itemMaxCnt = 0; + GET_SHAPE_CONFIG(TABBAR::ITEM_COUNT_MAX, GetCore().GetOrientation(), itemMaxCnt); + SysTryReturn(NID_UI_CTRL, GetCore().GetItemCount() < itemMaxCnt, E_MAX_EXCEEDED, E_MAX_EXCEEDED, "[E_MAX_EXCEEDED] The item is not added more than %d.", itemMaxCnt); + + return GetCore().AddItem(text, actionId); +} + +result +_TabBarImpl::InsertItemAt(int index, const Tizen::Base::String& text, int actionId) +{ + int itemMaxCnt = 0; + GET_SHAPE_CONFIG(TABBAR::ITEM_COUNT_MAX, GetCore().GetOrientation(), itemMaxCnt); + SysTryReturn(NID_UI_CTRL, GetCore().GetItemCount() < itemMaxCnt, E_MAX_EXCEEDED, E_MAX_EXCEEDED, "[E_MAX_EXCEEDED] The item is not added more than %d.", itemMaxCnt); + SysTryReturn(NID_UI_CTRL, index >= 0 && index <= GetCore().GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] This index(%d) is invalid.", index); + + return GetCore().InsertItemAt(index, text, actionId); +} + +Tizen::Graphics::Color +_TabBarImpl::GetColor(void) const +{ + return GetCore().GetColor(); +} + +int +_TabBarImpl::GetItemCount(void) const +{ + return GetCore().GetItemCount(); +} + +Tizen::Graphics::Color +_TabBarImpl::GetSelectedItemColor(void) const +{ + return GetCore().GetItemColor(ITEM_STATUS_SELECTED); +} + +Tizen::Graphics::Color +_TabBarImpl::GetItemTextColor(TabBarItemStatus status) const +{ + if (status == TAB_BAR_ITEM_STATUS_NORMAL) + { + return GetCore().GetItemTextColor(ITEM_STATUS_NORMAL); + } + else if (status == TAB_BAR_ITEM_STATUS_SELECTED) + { + return GetCore().GetItemTextColor(ITEM_STATUS_SELECTED); + } + + return Tizen::Graphics::Color(0); +} + +int +_TabBarImpl::GetSelectedItemIndex(void) const +{ + return GetCore().GetSelectedItemIndex(); +} + +result +_TabBarImpl::RemoveItemAt(int index) +{ + SysTryReturn(NID_UI_CTRL, index >= 0 && index < GetCore().GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] This index(%d) is invalid.", index); + + return GetCore().RemoveItemAt(index); +} + +result +_TabBarImpl::RemoveAllItems(void) +{ + return GetCore().RemoveAllItems(); +} + +result +_TabBarImpl::SetColor(const Tizen::Graphics::Color& color) +{ + return GetCore().SetColor(color); +} + +result +_TabBarImpl::SetItemAt(int index, const Tizen::Base::String& text, int actionId) +{ + SysTryReturn(NID_UI_CTRL, index >= 0 && index < GetCore().GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] This index(%d) is invalid.", index); + + return GetCore().SetItemAt(index, text, actionId); +} + +result +_TabBarImpl::SetItemSelected(int index) +{ + SysTryReturn(NID_UI_CTRL, index >= 0 && index < GetCore().GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] This index(%d) is invalid.", index); + + return GetCore().SetItemSelected(index); +} + +result +_TabBarImpl::SetItemTextColor(TabBarItemStatus status, const Tizen::Graphics::Color& color) +{ + if (status == TAB_BAR_ITEM_STATUS_NORMAL) + { + GetCore().SetItemTextColor(ITEM_STATUS_NORMAL, color); + } + else if (status == TAB_BAR_ITEM_STATUS_SELECTED) + { + GetCore().SetItemTextColor(ITEM_STATUS_SELECTED, color); + } + + return E_SUCCESS; +} + +result +_TabBarImpl::SetSelectedItemColor(const Tizen::Graphics::Color& color) +{ + return GetCore().SetItemColor(ITEM_STATUS_SELECTED, color); +} + +result +_TabBarImpl::SetWidth(int width) +{ + return GetCore().SetWidth(width); +} + +void +_TabBarImpl::AddActionEventListener(Tizen::Ui::IActionEventListener& listener) +{ + ClearLastResult(); + + if (__pPublicActionEvent == null) + { + __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + + if (__pPublicActionEvent == null || IsFailed(GetLastResult())) + { + SysLogException(NID_UI_CTRL, E_INVALID_STATE, "[E_INVALID_STATE] System error occurred."); + SetLastResult(E_INVALID_STATE); + delete __pPublicActionEvent; + return; + } + } + + SetLastResult(E_SUCCESS); + + __pPublicActionEvent->AddListener(listener); + + GetCore().AddActionEventListener(*this); +} + +void +_TabBarImpl::RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pPublicActionEvent, E_INVALID_STATE, "[E_INVALID_STATE] This instance isn't constructed.") + + // Todo : check fail case of RemoveListener + __pPublicActionEvent->RemoveListener(listener); + + GetCore().RemoveActionEventListener(*this); +} + +TabBar& +_TabBarImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const TabBar& +_TabBarImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const char* +_TabBarImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::TabBar"; +} + +const _TabBar& +_TabBarImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_TabBar& +_TabBarImpl::GetCore(void) +{ + return static_cast <_TabBar&>(_ControlImpl::GetCore()); +} + +void +_TabBarImpl::OnActionPerformed(const Tizen::Ui::_Control& source, int actionId) +{ + if (__pPublicActionEvent != null) + { + __pPublicActionEvent->Fire(*_PublicActionEvent::CreateActionEventArgN(actionId)); + } +} + +class _TabBarMaker + : public _UiBuilderControlMaker +{ +public: + _TabBarMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_TabBarMaker(){}; + + static _UiBuilderControlMaker* + GetInstance(_UiBuilder* uibuilder) + { + _TabBarMaker* pTabBarMaker = new (std::nothrow) _TabBarMaker(uibuilder); + SysTryReturn(NID_UI_CTRL, pTabBarMaker != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + return pTabBarMaker; + }; +protected: + virtual Tizen::Ui::Control* + Make(_UiBuilderControl* pControl) + { + result r = E_SUCCESS; + _UiBuilderControlLayout* pControlProperty = null; + TabBar* pTabBar = null; + Tizen::Graphics::Rectangle rect; + Tizen::Base::String elementString; + int opacity = 0; + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + + //Construct + pTabBar = new (std::nothrow) TabBar(); + SysTryReturn(NID_UI_CTRL, pTabBar != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pTabBar->Construct(rect.x, rect.y, rect.width); + if (r != E_SUCCESS) + { + delete pTabBar; + return null; + } + //tabBar item.. + rect = pTabBar->GetBounds(); + + if (pControl->GetElement(L"BGColorOpacity", elementString) == true) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"BGColor", elementString) == true) + { + ConvertStringToColor32(elementString, opacity, color); + pTabBar->SetColor(color); + } + + if (pControl->GetElement(L"backgroundColorOpacity", elementString) == true) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement(L"backgroundColor", elementString) == true) + { + ConvertStringToColor32(elementString, opacity, color); + pTabBar->SetColor(color); + } + + if (pControl->GetElement(L"normalItemTextColor", elementString) == true) + { + ConvertStringToColor(elementString, color); + pTabBar->SetItemTextColor(TAB_BAR_ITEM_STATUS_NORMAL, color); + } + + if (pControl->GetElement(L"selectedItemTextColor", elementString) == true) + { + ConvertStringToColor(elementString, color); + pTabBar->SetItemTextColor(TAB_BAR_ITEM_STATUS_SELECTED, color); + } + + if (pControl->GetElement(L"selectedItemColor", elementString) == true) + { + ConvertStringToColor(elementString, color); + pTabBar->SetSelectedItemColor(color); + } + + int itemCnt = pControl->GetItemCount(); + for (int i = 0; i < itemCnt; i++) + { + TabBarItem tabBarItem; + int actionId = 0; + if (pControl->GetItemElement(i, "actionId", elementString)) + { + Base::Integer::Parse(elementString, actionId); + } + + if (pControl->GetItemElement(i, "text", elementString)) + { + tabBarItem.Construct(elementString, actionId); + } + pTabBar->AddItem(tabBarItem); + } + + rect = (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->GetRect(); + (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(rect.x, rect.y, rect.width, rect.height); + + rect = (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->GetRect(); + (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(rect.x, rect.y, rect.width, rect.height); + + /*r = AddControl(pControl, pTabBar); + if (r != E_SUCCESS) + { + delete pTabBar; + return null; + } +*/ + return pTabBar; + } +}; + +_TabBarRegister::_TabBarRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"TabBar", _TabBarMaker::GetInstance); +} +_TabBarRegister::~_TabBarRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"TabBar"); +} +static _TabBarRegister TabBarRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TabBarItem.cpp b/src/ui/controls/FUiCtrl_TabBarItem.cpp new file mode 100644 index 0000000..5deee4b --- /dev/null +++ b/src/ui/controls/FUiCtrl_TabBarItem.cpp @@ -0,0 +1,126 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabBarItem.cpp + * @brief This is the implementation file for the _TabBarItem class. + */ + + +#include +#include +#include "FUiCtrl_TabBarItem.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_TabBarItem::_TabBarItem(_ControlOrientation orientation) + : __actionId(-1) + , __text(L"") + , __status(ITEM_STATUS_MAX) +{ + __bounds.x = 0; + GET_SHAPE_CONFIG(TABBAR::ITEM_MIN_WIDTH, orientation, __bounds.width); + GET_SHAPE_CONFIG(TABBAR::ITEM_HEIGHT, orientation, __bounds.height); + GET_SHAPE_CONFIG(TABBAR::TOP_MARGIN, orientation, __bounds.y); +} + + +_TabBarItem::~_TabBarItem(void) +{ +} + + +void +_TabBarItem::SetActionId(int actionId) +{ + __actionId = actionId; +} + +int +_TabBarItem::GetActionId(void) const +{ + return __actionId; +} + +void +_TabBarItem::SetText(const Tizen::Base::String& text, _ControlOrientation orientation) +{ + int fontSize = 0; + GET_SHAPE_CONFIG(TABBAR::FONT_SIZE, orientation, fontSize); + Dimension bounds(0, 0); + + int minWidth = 0; + int maxWidth = 0; + int fontMargin = 0; + GET_SHAPE_CONFIG(TABBAR::ITEM_MIN_WIDTH, orientation, minWidth); + GET_SHAPE_CONFIG(TABBAR::ITEM_MAX_WIDTH, orientation, maxWidth); + GET_SHAPE_CONFIG(TABBAR::FONT_MARGIN, orientation, fontMargin); + + Font font; + font.Construct(FONT_STYLE_BOLD, fontSize); + font.GetTextExtent(text, text.GetLength(), bounds); + + bounds.width += 2 * fontMargin; + __bounds.width = bounds.width; + + if (bounds.width < minWidth) + { + __bounds.width = minWidth; + } + + if (bounds.width > maxWidth) + { + __bounds.width = maxWidth; + } + + __text = text; +} + +Tizen::Base::String +_TabBarItem::GetText(void) const +{ + return __text; +} + +void +_TabBarItem::SetStatus(_TabBarItemStatus status) +{ + __status = status; +} + +_TabBarItemStatus +_TabBarItem::GetStatus(void) const +{ + return __status; +} + +void +_TabBarItem::SetBounds(const Tizen::Graphics::Rectangle& bounds) +{ + __bounds = bounds; +} + +Tizen::Graphics::Rectangle +_TabBarItem::GetBounds(void) const +{ + return __bounds; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TabBarItemImpl.cpp b/src/ui/controls/FUiCtrl_TabBarItemImpl.cpp new file mode 100644 index 0000000..6d627a4 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TabBarItemImpl.cpp @@ -0,0 +1,67 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_TabBarItemImpl.cpp +* @brief This file contains implementation of _TabBarItemImpl class +*/ + +#include "FUiCtrl_TabBarItemImpl.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +_TabBarItemImpl::_TabBarItemImpl(void) + : __text(L"") + , __actionId(-1) +{ + // Do nothing + +} + +_TabBarItemImpl::~_TabBarItemImpl(void) +{ + // Do nothing + +} + +void +_TabBarItemImpl::SetText(const Tizen::Base::String& text) +{ + __text = text; +} + +Tizen::Base::String +_TabBarItemImpl::GetText(void) const +{ + return __text; +} + +void +_TabBarItemImpl::SetActionId(int actionId) +{ + __actionId = actionId; +} + +int +_TabBarItemImpl::GetActionId(void) const +{ + return __actionId; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TabBarModel.cpp b/src/ui/controls/FUiCtrl_TabBarModel.cpp new file mode 100644 index 0000000..cc9570b --- /dev/null +++ b/src/ui/controls/FUiCtrl_TabBarModel.cpp @@ -0,0 +1,244 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabBarModel.cpp + * @brief This is the implementation file for the _TabBarModel class. + */ + +#include +#include +#include "FUiCtrl_TabBarModel.h" + + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_TabBarModel::_TabBarModel(void) + : __selectedItemIndex(0) + , __firstDrawnItemIndex(0) + , __widthOfAllItems(0) +{ + __tabBarItems.Construct(); +} + +_TabBarModel::~_TabBarModel(void) +{ + __tabBarItems.RemoveAll(true); +} + +void +_TabBarModel::SetSelectedItemIndex(int index) +{ + __selectedItemIndex = index; +} + +int +_TabBarModel::GetSelectedItemIndex(void) const +{ + return __selectedItemIndex; +} + +void +_TabBarModel::SetFirstDrawnItemIndex(int index) +{ + __firstDrawnItemIndex = index; +} + +int +_TabBarModel::GetFirstDrawnItemIndex(void) const +{ + return __firstDrawnItemIndex; +} + +int +_TabBarModel::GetItemCount(void) const +{ + return __tabBarItems.GetCount(); +} + +int +_TabBarModel::GetWidthOfAllItems(void) const +{ + return __widthOfAllItems; +} + +result +_TabBarModel::AddItem(const Tizen::Base::String& text, int actionId, _ControlOrientation orientation) +{ + _TabBarItem* pItem = new (std::nothrow) _TabBarItem(orientation); + SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pItem->SetText(text, orientation); + pItem->SetActionId(actionId); + int itemCount = __tabBarItems.GetCount(); + + if (itemCount > 0) + { + pItem->SetStatus(ITEM_STATUS_NORMAL); + } + else + { + pItem->SetStatus(ITEM_STATUS_SELECTED); + } + + _TabBarItem* pPreviousItem = GetItemAt(itemCount - 1); + Rectangle itemBounds = pItem->GetBounds(); + if (pPreviousItem != null) + { + Rectangle previousItemBounds = pPreviousItem->GetBounds(); + int itemMargin = 0; + GET_SHAPE_CONFIG(TABBAR::ITEM_MARGIN, orientation, itemMargin); + itemBounds.x = previousItemBounds.x + previousItemBounds.width + itemMargin; + __widthOfAllItems += itemMargin; + } + else + { + int arrowMargin = 0; + GET_SHAPE_CONFIG(TABBAR::ARROW_MARGIN, orientation, arrowMargin); + itemBounds.x += arrowMargin; + } + pItem->SetBounds(itemBounds); + __widthOfAllItems += itemBounds.width; + + return __tabBarItems.Add(*pItem); +} + +result +_TabBarModel::InsertItemAt(int index, const Tizen::Base::String& text, int actionId, _ControlOrientation orientation) +{ + SysTryReturn(NID_UI_CTRL, index >= 0 && index <= GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The argument(%d) is out of range.", index); + if (GetItemCount() == 0) + { + return AddItem(text, actionId, orientation); + } + + _TabBarItem* pItem = new (std::nothrow) _TabBarItem(orientation); + SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pItem->SetText(text, orientation); + pItem->SetActionId(actionId); + + _TabBarItem* pPreviousItem = GetItemAt(index - 1); + Rectangle itemBounds = pItem->GetBounds(); + if (pPreviousItem != null) + { + Rectangle previousItemBounds = pPreviousItem->GetBounds(); + int itemMargin = 0; + GET_SHAPE_CONFIG(TABBAR::ITEM_MARGIN, orientation, itemMargin); + itemBounds.x = previousItemBounds.x + previousItemBounds.width + itemMargin; + pItem->SetBounds(itemBounds); + } + + result r = __tabBarItems.InsertAt(*pItem, index); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = ReCalculateItemPosition(index + 1, orientation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_TabBarModel::SetItemAt(int index, const Tizen::Base::String& text, int actionId, _ControlOrientation orientation) +{ + _TabBarItem* pItem = static_cast <_TabBarItem*>(__tabBarItems.GetAt(index)); + SysTryReturn(NID_UI_CTRL, pItem != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The %d index item is not exist.", index); + + pItem->SetText(text, orientation); + pItem->SetActionId(actionId); + + result r = ReCalculateItemPosition(index + 1, orientation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_TabBarModel::RemoveItemAt(int index, _ControlOrientation orientation) +{ + _TabBarItem* pItem = static_cast <_TabBarItem*>(__tabBarItems.GetAt(index)); + SysTryReturn(NID_UI_CTRL, pItem != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The %d index item is not exist.", index); + + int itemMargin = 0; + GET_SHAPE_CONFIG(TABBAR::ITEM_MARGIN, orientation, itemMargin); + + result r = __tabBarItems.RemoveAt(index, true); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = ReCalculateItemPosition(index, orientation); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +void +_TabBarModel::RemoveAllItems(void) +{ + __widthOfAllItems = 0; + __tabBarItems.RemoveAll(true); +} + +_TabBarItem* +_TabBarModel::GetItemAt(int index) const +{ + const _TabBarItem* pItem = static_cast (__tabBarItems.GetAt(index)); + + return const_cast<_TabBarItem*>(pItem); +// return static_cast <_TabBarItem*>(__tabBarItems.GetAt(index)); +} + +result +_TabBarModel::ReCalculateItemPosition(int itemIndex, _ControlOrientation orientation) +{ + SysTryReturn(NID_UI_CTRL, itemIndex >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The itemIndex(%d) is negative."); + int itemCount = __tabBarItems.GetCount(); + int itemMargin = 0; + GET_SHAPE_CONFIG(TABBAR::ITEM_MARGIN, orientation, itemMargin); + + _TabBarItem* pPreviousItem = null; + _TabBarItem* pCurrentItem = null; + Rectangle previousItemBounds; + Rectangle currentItemBounds; + for (int i = itemIndex; i < itemCount; i++) + { + pPreviousItem = GetItemAt(i - 1); + pCurrentItem = GetItemAt(i); + if (pCurrentItem == null) + { + break; + } + if (pPreviousItem == null) + { + previousItemBounds.SetBounds(0, 0, 0, 0); + } + else + { + previousItemBounds = pPreviousItem->GetBounds(); + } + currentItemBounds = pCurrentItem->GetBounds(); + currentItemBounds.x = previousItemBounds.x + previousItemBounds.width + itemMargin; + + pCurrentItem->SetBounds(currentItemBounds); + } + __widthOfAllItems = currentItemBounds.x + currentItemBounds.width; + + return E_SUCCESS; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TabBarPresenter.cpp b/src/ui/controls/FUiCtrl_TabBarPresenter.cpp new file mode 100644 index 0000000..3e2cab9 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TabBarPresenter.cpp @@ -0,0 +1,964 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabBarPresenter.cpp + * @brief This is the implementation file for the _TabBarPresenter class. + */ + + +#include +#include +#include +#include +#include +#include "FUi_UiTouchEvent.h" +#include "FUi_ResourceManager.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUiCtrl_TabBarPresenter.h" + + +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_TabBarPresenter::_TabBarPresenter(_TabBar& tabBar) + : __tabBar(tabBar) + , __pTabBarModel(null) + , __pFont(null) + , __pTextObject(null) + , __highlightedItemIndex(-1) + , __touchMoved(false) + , __touchBubblingBlocked(true) + , __pBgBitmapCached(null) + , __pLeftArrowBgBitmapCached(null) + , __pRightArrowBgBitmapCached(null) + , __pLeftArrowBitmapCached(null) + , __pRightArrowBitmapCached(null) +{ + __startPosition = Point(0, 0); + for (int i = 0; i < ITEM_STATUS_MAX; i++) + { + __pItemBgBitmapCached[i] = null; + } +} + +_TabBarPresenter::~_TabBarPresenter(void) +{ + delete __pTabBarModel; + __pTabBarModel = null; + + if (__pTextObject) + { + __pTextObject->RemoveAll(); + delete __pTextObject; + __pTextObject = null; + } + + delete __pBgBitmapCached; + __pBgBitmapCached = null; + + for (int i = 0; i < ITEM_STATUS_MAX; i++) + { + delete __pItemBgBitmapCached[i]; + __pItemBgBitmapCached[i] = null; + } + + delete __pLeftArrowBgBitmapCached; + __pLeftArrowBgBitmapCached = null; + + delete __pRightArrowBgBitmapCached; + __pRightArrowBgBitmapCached = null; + + delete __pLeftArrowBitmapCached; + __pLeftArrowBitmapCached = null; + + delete __pRightArrowBitmapCached; + __pRightArrowBitmapCached = null; +} + +result +_TabBarPresenter::Construct() +{ + __pTabBarModel = new (std::nothrow) _TabBarModel; + SysTryReturn(NID_UI_CTRL, __pTabBarModel != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + result r = E_SUCCESS; + + r = LoadBitmap(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return r; + +CATCH: + delete __pTabBarModel; + __pTabBarModel = null; + + return r; +} + +result +_TabBarPresenter::InitializeFont(void) +{ + result r = E_SUCCESS; + __pFont = __tabBar.GetFallbackFont(); + SysTryCatch(NID_UI_CTRL, __pFont != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTextObject = new (std::nothrow) TextObject(); + SysTryCatch(NID_UI_CTRL, __pTextObject != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + __pTextObject->Construct(); + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + + return E_SUCCESS; + +CATCH: + delete __pTextObject; + __pTextObject = null; + + return r; +} + +void +_TabBarPresenter::OnFontChanged(Font* pFont) +{ + __pFont = pFont; +} + +void +_TabBarPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + int fontSize = 0; + GET_SHAPE_CONFIG(TABBAR::FONT_SIZE, __tabBar.GetOrientation(), fontSize); + + style = FONT_STYLE_PLAIN; + size = fontSize; +} + +result +_TabBarPresenter::LoadBitmap(void) +{ + Bitmap* pBitmap = null; + + Color arrowColor; + GET_COLOR_CONFIG(TABBAR::ARROW_NORMAL, arrowColor); + + if (__pBgBitmapCached != null) + { + delete __pBgBitmapCached; + __pBgBitmapCached = null; + } + + if (__pLeftArrowBgBitmapCached != null) + { + delete __pLeftArrowBgBitmapCached; + __pLeftArrowBgBitmapCached = null; + } + + if (__pLeftArrowBitmapCached != null) + { + delete __pLeftArrowBitmapCached; + __pLeftArrowBitmapCached = null; + } + + if (__pRightArrowBgBitmapCached == null) + { + delete __pRightArrowBgBitmapCached; + __pRightArrowBgBitmapCached = null; + } + + if (__pRightArrowBitmapCached == null) + { + delete __pRightArrowBitmapCached; + __pRightArrowBitmapCached = null; + } + + for (int i = 0; i < ITEM_STATUS_MAX; i++) + { + if (__pItemBgBitmapCached[i] != null) + { + delete __pItemBgBitmapCached[i]; + __pItemBgBitmapCached[i] = null; + } + } + + result r; + r = GET_BITMAP_CONFIG_N(TABBAR::ARROW_BG_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888, __pLeftArrowBgBitmapCached); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + + r = GET_BITMAP_CONFIG_N(TABBAR::ARROW_BG_RIGHT, BITMAP_PIXEL_FORMAT_ARGB8888, __pRightArrowBgBitmapCached); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + + r = GET_BITMAP_CONFIG_N(TABBAR::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap."); + __pBgBitmapCached = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, Color::GetColor(COLOR_ID_MAGENTA), __tabBar.GetColor()); + delete pBitmap; + pBitmap = null; + + r = GET_BITMAP_CONFIG_N(TABBAR::ARROW_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + __pLeftArrowBitmapCached = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, Color::GetColor(COLOR_ID_MAGENTA), arrowColor); + SysTryCatch(NID_UI_CTRL, __pLeftArrowBitmapCached != null, , E_OUT_OF_MEMORY, "Failed to load bitmap."); + delete pBitmap; + pBitmap = null; + + r = GET_BITMAP_CONFIG_N(TABBAR::ARROW_RIGHT, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + __pRightArrowBitmapCached = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, Color::GetColor(COLOR_ID_MAGENTA), arrowColor); + SysTryCatch(NID_UI_CTRL, __pRightArrowBitmapCached != null, , E_OUT_OF_MEMORY, "Failed to load bitmap."); + delete pBitmap; + pBitmap = null; + + r = GET_BITMAP_CONFIG_N(TABBAR::ITEM_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + __pItemBgBitmapCached[ITEM_STATUS_SELECTED] = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, Color::GetColor(COLOR_ID_MAGENTA), __tabBar.GetItemColor(ITEM_STATUS_SELECTED)); + SysTryCatch(NID_UI_CTRL, __pItemBgBitmapCached[ITEM_STATUS_SELECTED] != null, , E_OUT_OF_MEMORY, "Failed to load bitmap."); + delete pBitmap; + pBitmap = null; + + r = GET_BITMAP_CONFIG_N(TABBAR::ITEM_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + __pItemBgBitmapCached[ITEM_STATUS_HIGHLIGHTED] = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, Color::GetColor(COLOR_ID_MAGENTA), __tabBar.GetItemColor(ITEM_STATUS_HIGHLIGHTED)); + SysTryCatch(NID_UI_CTRL, __pItemBgBitmapCached[ITEM_STATUS_HIGHLIGHTED] != null, , E_OUT_OF_MEMORY, "Failed to load bitmap."); + delete pBitmap; + pBitmap = null; + + return E_SUCCESS; + +CATCH: + delete pBitmap; + + delete __pBgBitmapCached; + __pBgBitmapCached = null; + + delete __pLeftArrowBgBitmapCached; + __pLeftArrowBgBitmapCached = null; + + delete __pLeftArrowBitmapCached; + __pLeftArrowBitmapCached = null; + + delete __pRightArrowBgBitmapCached; + __pRightArrowBgBitmapCached = null; + + delete __pRightArrowBitmapCached; + __pRightArrowBitmapCached = null; + + for (int i = 0; i < ITEM_STATUS_MAX; i++) + { + delete __pItemBgBitmapCached[i]; + __pItemBgBitmapCached[i] = null; + } + + return E_OUT_OF_MEMORY; +} + +result +_TabBarPresenter::AddItem(const Tizen::Base::String& text, int actionId) +{ + return __pTabBarModel->AddItem(text, actionId, _CONTROL_ORIENTATION_PORTRAIT); +} + +result +_TabBarPresenter::InsertItemAt(int index, const Tizen::Base::String& text, int actionId) +{ + if (index <= __pTabBarModel->GetSelectedItemIndex()) + { + if (__pTabBarModel->GetItemCount() != 0) + { + __pTabBarModel->SetSelectedItemIndex(GetSelectedItemIndex() + 1); + } + } + + result r = __pTabBarModel->InsertItemAt(index, text, actionId, _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_TabBarPresenter::SetItemAt(int index, const Tizen::Base::String& text, int actionId) +{ + return __pTabBarModel->SetItemAt(index, text, actionId, _CONTROL_ORIENTATION_PORTRAIT); +} + +_TabBarItem* +_TabBarPresenter::GetItemAt(int index) const +{ + _TabBarItem* pItem = __pTabBarModel->GetItemAt(index); + return pItem; +} + +result +_TabBarPresenter::RemoveItemAt(int index) +{ + if (index <= GetSelectedItemIndex()) + { + if (__pTabBarModel->GetItemCount() != 0 && GetSelectedItemIndex() != 0) + { + __pTabBarModel->SetSelectedItemIndex(GetSelectedItemIndex() - 1); + } + } + + result r = __pTabBarModel->RemoveItemAt(index, _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (GetItemCount() != 0) + { + r = SetItemSelected(0); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pTabBarModel->SetSelectedItemIndex(0); + } + + return E_SUCCESS; +} + +result +_TabBarPresenter::RemoveAllItems(void) +{ + __pTabBarModel->RemoveAllItems(); + return E_SUCCESS; +} + +result +_TabBarPresenter::SetItemSelected(int index) +{ + + SysTryReturn(NID_UI_CTRL, index >= 0 && index < GetItemCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The argument is out of range."); + + int oldSelectedItemIndex = GetSelectedItemIndex(); + if (index == oldSelectedItemIndex) + { + return E_SUCCESS; + } + _TabBarItem* pItem = GetItemAt(oldSelectedItemIndex); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pItem->SetStatus(ITEM_STATUS_NORMAL); + + pItem = GetItemAt(index); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + pItem->SetStatus(ITEM_STATUS_SELECTED); + + __pTabBarModel->SetSelectedItemIndex(index); + return E_SUCCESS; +} + +int +_TabBarPresenter::GetSelectedItemIndex(void) const +{ + return __pTabBarModel->GetSelectedItemIndex(); +} + +int +_TabBarPresenter::GetItemCount(void) const +{ + return __pTabBarModel->GetItemCount(); +} + +int +_TabBarPresenter::GetItemIndexFromPosition(const Tizen::Graphics::Point& point) const +{ + Rectangle clientBounds = __tabBar.GetBounds(); + int topMargin = 0; + int sideMargin = 0; + GET_SHAPE_CONFIG(TABBAR::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, topMargin); + GET_SHAPE_CONFIG(TABBAR::SIDE_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sideMargin); + + if (point.x < sideMargin + || point.x > clientBounds.width - sideMargin + || point.y < topMargin + || point.y > clientBounds.height - topMargin) + { + return -1; + } + + int itemIndex = __pTabBarModel->GetFirstDrawnItemIndex(); + _TabBarItem* pItem = __pTabBarModel->GetItemAt(itemIndex); + + while (pItem != null) + { + Rectangle itemBounds = pItem->GetBounds(); + + if (point.x - sideMargin > itemBounds.x + && point.x - sideMargin < itemBounds.x + itemBounds.width + && point.y - topMargin > itemBounds.y + && point.y - topMargin < itemBounds.y + itemBounds.height) + { + return itemIndex; + } + itemIndex++; + pItem = __pTabBarModel->GetItemAt(itemIndex); + } + return -1; +} + +_TabBarItem* +_TabBarPresenter::GetItemFromPosition(const Tizen::Graphics::Point& position) const +{ + SetLastResult(E_SUCCESS); + int index = GetItemIndexFromPosition(position); + SysTryReturn(NID_UI_CTRL, index != -1, null, E_SYSTEM, "[E_SYSTEM] Item not found."); + + return __pTabBarModel->GetItemAt(index); +} + +result +_TabBarPresenter::SetTopDrawnItemIndex(int index) +{ + SysTryReturn(NID_UI_CTRL, index >= 0 && index < GetItemCount(), + E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The argument(%d) is out of range.", index); + + _TabBarItem* pTopItem = GetItemAt(index); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int distance = pTopItem->GetBounds().x; + + _TabBarItem* pBottomItem = GetItemAt(GetItemCount() - 1); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Rectangle clientBounds = __tabBar.GetBounds(); + int sideMargin = 0; + GET_SHAPE_CONFIG(TABBAR::SIDE_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sideMargin); + + if ((pBottomItem->GetBounds().x + pBottomItem->GetBounds().width - distance) < clientBounds.width - sideMargin * 2) + { + distance = (pBottomItem->GetBounds().x + pBottomItem->GetBounds().width) - (clientBounds.width - sideMargin * 2); + } + + r = AdjustItemPositionX(-distance); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_TabBarPresenter::SetItemStatus(int index, _TabBarItemStatus status) +{ + _TabBarItem* pItem = __pTabBarModel->GetItemAt(index); + SysTryReturn(NID_UI_CTRL, pItem, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Item(%d) not exists.", index); + + pItem->SetStatus(status); + + return E_SUCCESS; +} + +_TabBarItemStatus +_TabBarPresenter::GetItemStatus(int index) const +{ + _TabBarItem* pItem = __pTabBarModel->GetItemAt(index); + SysTryReturn(NID_UI_CTRL, pItem, ITEM_STATUS_NORMAL, E_SYSTEM, "[E_SYSTEM] Item(%d) not exists.", index); + + _TabBarItemStatus status = pItem->GetStatus(); + + return status; +} + +result +_TabBarPresenter::AdjustItemPositionX(int distance) +{ + int index = 0; + + while (index < GetItemCount()) + { + _TabBarItem* pItem = __pTabBarModel->GetItemAt(index); + SysTryReturn(NID_UI_CTRL, pItem, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Item(%d) not exists.", index); + Rectangle bounds = pItem->GetBounds(); + bounds.x += distance; + pItem->SetBounds(bounds); + index++; + } + + return E_SUCCESS; +} + +result +_TabBarPresenter::SetReplacementColor(const Tizen::Graphics::Color& color) +{ + Bitmap* pBitmap = null; + Bitmap* pColorReplcedBitmap = null; + + result r; + r = GET_BITMAP_CONFIG_N(TABBAR::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryReturn(NID_UI_CTRL, pBitmap != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Image loading fail."); + + pColorReplcedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, Color::GetColor(COLOR_ID_MAGENTA), color); + delete pBitmap; + + if (__pBgBitmapCached != null) + { + delete __pBgBitmapCached; + } + __pBgBitmapCached = pColorReplcedBitmap; + + return E_SUCCESS; +} + +result +_TabBarPresenter::SetItemReplacementColor(_TabBarItemStatus itemStatus, const Tizen::Graphics::Color& color) +{ + Bitmap* pBitmap = null; + Bitmap* pColorReplcedBitmap = null; + + result r; + if (itemStatus == ITEM_STATUS_SELECTED) + { + r = GET_BITMAP_CONFIG_N(TABBAR::ITEM_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryReturn(NID_UI_CTRL, pBitmap != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Image loading fail."); + } + else if (itemStatus == ITEM_STATUS_HIGHLIGHTED) + { + r = GET_BITMAP_CONFIG_N(TABBAR::ITEM_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryReturn(NID_UI_CTRL, pBitmap != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Image loading fail."); + } + else + { + return E_SUCCESS; + } + + pColorReplcedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, Color::GetColor(COLOR_ID_MAGENTA), color); + delete pBitmap; + + if (__pItemBgBitmapCached[itemStatus] != null) + { + delete __pItemBgBitmapCached[itemStatus]; + } + __pItemBgBitmapCached[itemStatus] = pColorReplcedBitmap; + + return E_SUCCESS; +} + +void +_TabBarPresenter::Draw(void) +{ + Canvas* pCanvas = __tabBar.GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, E_SYSTEM, "[E_SYSTEM] It can not get canvas."); + + int sideMargin = 0; + GET_SHAPE_CONFIG(TABBAR::SIDE_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sideMargin); + + Rectangle clientBounds = __tabBar.GetBounds(); + + pCanvas->Clear(); + DrawBackground(pCanvas); + DrawArrow(pCanvas); + delete pCanvas; + + Rectangle rect(sideMargin, 0, clientBounds.width - sideMargin * 2, clientBounds.height); + Canvas* pSubCanvas = __tabBar.GetCanvasN(rect); + + if (pSubCanvas != null) + { + DrawItem(pSubCanvas); + delete pSubCanvas; + } +} + +void +_TabBarPresenter::InitItemPositionX(void) +{ + int itemCount = GetItemCount(); + if (itemCount < 1) + { + return; + } + + int sideMargin = 0; + GET_SHAPE_CONFIG(TABBAR::SIDE_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sideMargin); + + _TabBarItem* pFirstItem = __pTabBarModel->GetItemAt(0); + _TabBarItem* pLastItem = __pTabBarModel->GetItemAt(itemCount - 1); + SysTryReturnVoidResult(NID_UI_CTRL, pFirstItem != null && pLastItem != null, E_SYSTEM, "[E_SYSTEM] Item not found."); + + Rectangle clientBounds = __tabBar.GetBounds(); + Rectangle firstItemBounds = pFirstItem->GetBounds(); + Rectangle lastItemBounds = pLastItem->GetBounds(); + + if (firstItemBounds.x != 0 && lastItemBounds.x + lastItemBounds.width - firstItemBounds.x < clientBounds.width - sideMargin * 2) + { + AdjustItemPositionX(-firstItemBounds.x); + } + + return; +} + +void +_TabBarPresenter::OnBoundsChanged(void) +{ + return InitItemPositionX(); +} + +void +_TabBarPresenter::DrawItem(Tizen::Graphics::Canvas* pCanvas) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pTextObject != null, E_INVALID_STATE, "[E_INVALID_STATE] TextObject is not constructed."); + + Rectangle clientBounds = pCanvas->GetBounds(); + + _TabBarItem* pDrawItem = null; + Rectangle itemBounds(0, 0, 0, 0); + + String drawText(L""); + Rectangle textRect(0, 0, 0, 0); + TextSimple* pSimpleText = null; + + _TabBarItemStatus itemStatus = ITEM_STATUS_NORMAL; + + int itemCount = GetItemCount(); + for (int i = 0; i < itemCount; i++) + { + pDrawItem = __pTabBarModel->GetItemAt(i); + if (pDrawItem == null) + { + break; + } + + itemBounds = pDrawItem->GetBounds(); + + if (itemBounds.x + itemBounds.width < 0) + { + continue; + } + + if (itemBounds.x > clientBounds.width) + { + break; + } + + itemStatus = pDrawItem->GetStatus(); + + // draw item BG + if (__pItemBgBitmapCached[itemStatus] != null) + { + pCanvas->DrawNinePatchedBitmap(itemBounds, *__pItemBgBitmapCached[itemStatus]); + } + + // draw item text + textRect = Rectangle(itemBounds.x, itemBounds.y, itemBounds.width, itemBounds.height); + if (textRect.x < 0) + { + textRect.width += textRect.x; + textRect.x = 0; + } + + if (textRect.x + textRect.width > clientBounds.width) + { + textRect.width = clientBounds.width - textRect.x; + } + + drawText = pDrawItem->GetText(); + __pTextObject->RemoveAll(); + pSimpleText = new (std::nothrow)TextSimple(const_cast (drawText.GetPointer()), drawText.GetLength()); + SysTryReturnVoidResult(NID_UI_CTRL, pSimpleText != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] TextSimple is not constructed."); + + __pFont = __tabBar.GetFallbackFont(); + SysTryReturnVoidResult(NID_UI_CTRL, __pFont != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pTextObject->AppendElement(*pSimpleText); + + __pTextObject->SetForegroundColor(__tabBar.GetItemTextColor(itemStatus), 0, __pTextObject->GetTextLength()); + __pTextObject->SetBounds(textRect); + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + } // end for loop +} + +void +_TabBarPresenter::DrawBackground(Tizen::Graphics::Canvas* pCanvas) +{ + Rectangle clientBounds = __tabBar.GetBounds(); + + if (__pBgBitmapCached != null) + { + pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, clientBounds.width, clientBounds.height), *__pBgBitmapCached); + } +} + +void +_TabBarPresenter::DrawArrow(Tizen::Graphics::Canvas* pCanvas) +{ + Rectangle clientBounds = __tabBar.GetBounds(); + + _TabBarItem* pFirstItem = __pTabBarModel->GetItemAt(0); + if (pFirstItem == null) + { + return; + } + + Rectangle firstItemBounds = pFirstItem->GetBounds(); + int sideMargin = 0; + int arrowMargin = 0; + GET_SHAPE_CONFIG(TABBAR::SIDE_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sideMargin); + GET_SHAPE_CONFIG(TABBAR::ARROW_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, arrowMargin); + + Rectangle drawRect(0, 0, 0, 0); + drawRect.width = sideMargin; + drawRect.height = clientBounds.height; + + // draw left arrow + if (firstItemBounds.x < 0) + { + drawRect.width = __pLeftArrowBitmapCached->GetWidth(); + drawRect.height = __pLeftArrowBitmapCached->GetHeight(); + drawRect.x = (sideMargin - __pLeftArrowBitmapCached->GetWidth()) / 2; + drawRect.y = (clientBounds.height - __pLeftArrowBitmapCached->GetHeight()) / 2; + DrawBitmap(*pCanvas, drawRect, *__pLeftArrowBitmapCached); + } + + int itemCount = __pTabBarModel->GetItemCount(); + _TabBarItem* pLastItem = __pTabBarModel->GetItemAt(itemCount - 1); + if (pLastItem == null) + { + return; + } + + Rectangle lastItemBounds = pLastItem->GetBounds(); + + drawRect.SetBounds(0, 0, 0, 0); + drawRect.x = clientBounds.width - sideMargin; + drawRect.width = sideMargin; + drawRect.height = clientBounds.height; + + // draw right arrow + if (lastItemBounds.x + lastItemBounds.width > clientBounds.width - sideMargin * 2) + { + drawRect.x += (sideMargin - __pRightArrowBitmapCached->GetWidth()) / 2; + drawRect.y = (clientBounds.height - __pRightArrowBitmapCached->GetHeight()) / 2; + drawRect.width = __pRightArrowBitmapCached->GetWidth(); + drawRect.height = __pRightArrowBitmapCached->GetHeight(); + DrawBitmap(*pCanvas, drawRect, *__pRightArrowBitmapCached); + } +} + +bool +_TabBarPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + __startPosition = touchinfo.GetCurrentPosition(); + __touchBubblingBlocked = true; + + int index = GetItemIndexFromPosition(touchinfo.GetCurrentPosition()); + if (index == -1) + { + return true; + } + + __highlightedItemIndex = index; + if (GetItemStatus(index) == ITEM_STATUS_SELECTED) + { + return true; + } + + result r = SetItemStatus(index, ITEM_STATUS_HIGHLIGHTED); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] propagating.", GetErrorMessage(r)); + + Draw(); + + return true; +} + +bool +_TabBarPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + int index = GetItemIndexFromPosition(touchinfo.GetCurrentPosition()); + int selectedItemIndex = GetSelectedItemIndex(); + bool eventFire = false; + result r = E_SUCCESS; + + + if (index != -1 && GetItemStatus(index) != ITEM_STATUS_NORMAL && __touchMoved == false) + { + if (GetItemStatus(index) == ITEM_STATUS_HIGHLIGHTED) + { + r = SetItemStatus(index, ITEM_STATUS_SELECTED); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] propagating.", GetErrorMessage(r)); + SetItemSelected(index); + SetItemStatus(selectedItemIndex, ITEM_STATUS_NORMAL); + eventFire = true; + } + } + else + { + for (int i = 0; i < GetItemCount(); i++) + { + if (GetItemStatus(i) == ITEM_STATUS_HIGHLIGHTED) + { + r = SetItemStatus(i, ITEM_STATUS_NORMAL); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] propagating.", GetErrorMessage(r)); + } + } + } + __highlightedItemIndex = -1; + __touchMoved = false; + + Draw(); + + return eventFire; +} + +bool +_TabBarPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != &__tabBar) + { + return false; + } + + int sideMargin = 0; + GET_SHAPE_CONFIG(TABBAR::SIDE_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sideMargin); + int arrowMargin = 0; + GET_SHAPE_CONFIG(TABBAR::ARROW_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, arrowMargin); + + Rectangle clientBounds = __tabBar.GetBounds(); + if (__pTabBarModel->GetWidthOfAllItems() + (sideMargin * 2) <= clientBounds.width + arrowMargin * 2) + { + return true; + } + + if (__touchMoved == false) + { + int distanceX = abs((touchinfo.GetCurrentPosition()).x - __startPosition.x); + int distanceY = abs((touchinfo.GetCurrentPosition()).y - __startPosition.y); + + if (distanceY > distanceX) + { + __touchBubblingBlocked = false; + } + } + + __touchMoved = true; + + int distance = (touchinfo.GetCurrentPosition()).x - __startPosition.x; + + __startPosition = touchinfo.GetCurrentPosition(); + _TabBarItem* pItem = null; + Rectangle itemBounds; + int itemCount = GetItemCount(); + + if (distance > 0) // right move + { + pItem = __pTabBarModel->GetItemAt(0); + if (pItem == null) + { + return true; + } + + itemBounds = pItem->GetBounds(); + + if (itemBounds.x == arrowMargin) + { + return true; + } + + if (itemBounds.x + distance >= arrowMargin) + { + distance = arrowMargin - itemBounds.x; + } + } + else // left move + { + pItem = __pTabBarModel->GetItemAt(itemCount - 1); + if (pItem == null) + { + return true; + } + + itemBounds = pItem->GetBounds(); + if (itemBounds.x + itemBounds.width + (arrowMargin * 2) == clientBounds.width - (sideMargin * 2)) + { + return true; + } + + if (itemBounds.x + itemBounds.width + distance + (arrowMargin * 2) <= clientBounds.width - (sideMargin * 2)) + { + distance = (clientBounds.width - (sideMargin * 2)) - (itemBounds.x + itemBounds.width + (arrowMargin * 2)); + } + } + + AdjustItemPositionX(distance); + + Draw(); + + return __touchBubblingBlocked; +} + +result +_TabBarPresenter::DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap) +{ + result r = E_SUCCESS; + if (bitmap.IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw ninepatched bitmap.") + } + else + { + r = canvas.DrawBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw bitmap.") + } + + return r; +} + +void +_TabBarPresenter::SetAllAccessibilityElement(void) +{ + _AccessibilityContainer* pContainer = __tabBar.GetAccessibilityContainer(); + int sideMargin = 0; + GET_SHAPE_CONFIG(TABBAR::SIDE_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sideMargin); + + if (pContainer != null) + { + int itemCount = __pTabBarModel->GetItemCount(); + for (int i = 0; i < itemCount; i++) + { + _TabBarItem* pItem = __pTabBarModel->GetItemAt(i); + _AccessibilityElement* pElement = new (std::nothrow) _AccessibilityElement(true); + if (pItem != null && pElement != null) + { + pElement->SetLabel(pItem->GetText()); +// pElement->SetTrait(ACCESSIBILITY_TRAITS_TABBAR); + pElement->SetTrait(ACCESSIBILITY_TRAITS_TAB); // not yet + Rectangle itemBounds = pItem->GetBounds(); + itemBounds.x += sideMargin; + pElement->SetBounds(itemBounds); + + if (i == 0) + { + pElement->SetHint(L"The first of TabBar"); + } + else if(i == itemCount - 1) + { + pElement->SetHint(L"The last of TabBar"); + } + pContainer->AddElement(*pElement); + __tabBar.AddAccessibilityElement(*pElement); + } + else + { + delete pElement; + } + } + } + +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TabImpl.cpp b/src/ui/controls/FUiCtrl_TabImpl.cpp new file mode 100644 index 0000000..6d666c5 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TabImpl.cpp @@ -0,0 +1,531 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabImpl.cpp + * @brief This is the implementation file for the _TabImpl class. + */ + + +#include +#include "FUi_ResourceManager.h" +#include "FUiCtrl_TabImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls { + +_TabImpl::_TabImpl(Tab* pPublic, _Tab* pCore) + : _ControlImpl(pPublic, pCore) + , __pActionEvent(null) +{ +} + +_TabImpl::~_TabImpl(void) +{ + if (__pActionEvent) + { + delete __pActionEvent; + __pActionEvent = null; + } +} + +_TabImpl* +_TabImpl::CreateTabImplN(Tab* pPublic) +{ + ClearLastResult(); + result r = E_SUCCESS; + + Rectangle rect(0, 0, 0, 0); + + _Tab* pCore = null; + pCore = _Tab::CreateTabN(); + r = GetLastResult(); + + _TabImpl* pTabImpl = new (std::nothrow) _TabImpl(pPublic, pCore); + SysTryCatch(NID_UI_CTRL, pTabImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pTabImpl; + +CATCH: + delete pCore; + return null; +} + + +Tab* +_TabImpl::GetTab(void) +{ + return dynamic_cast(&(_ControlImpl::GetPublic())); +} + + +const char* +_TabImpl::GetPublicClassName(void) const +{ + return "Controls::Tab"; +} + + +const Tab& +_TabImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + + +Tab& +_TabImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + + +const _Tab& +_TabImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + + +_Tab& +_TabImpl::GetCore(void) +{ + return static_cast<_Tab&>(_ControlImpl::GetCore()); +} + + +_TabImpl* +_TabImpl::GetInstance(Tab& pTab) +{ + return static_cast<_TabImpl*>(pTab._pControlImpl); +} + + +const _TabImpl* +_TabImpl::GetInstance(const Tab& pTab) +{ + return static_cast(pTab._pControlImpl); +} + + +Tab* +_TabImpl::CreateTabN(void) +{ + result r = E_SUCCESS; + + Tab* pTab = new (std::nothrow) Tab; + SysTryReturn(NID_UI_CTRL, (pTab != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pTab->Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to construct Tab instance."); + + return pTab; +} + +void +_TabImpl::DeleteTab(Tab* pTab) +{ + if (pTab != null) + { + delete pTab; + pTab = null; + } +} + + +bool +_TabImpl::IsMovable(void) const +{ + return false; +} + +bool +_TabImpl::IsResizable(void) const +{ + return false; +} + + +result +_TabImpl::AddItem(const Bitmap& icon, const String& text, int actionId) +{ + ClearLastResult(); + + result r = GetCore().AddItem(icon, text, actionId); + + if (r == E_SYSTEM) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Failed to add item to tab."); + return E_SYSTEM; + } + + return r; +} + + +result +_TabImpl::AddItem(const Bitmap& icon, int actionId) +{ + ClearLastResult(); + + result r = GetCore().AddItem(icon, actionId); + + if (r == E_SYSTEM) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Failed to add item to tab."); + return E_SYSTEM; + } + + return r; +} + +result +_TabImpl::AddItem(const String& text, int actionId) +{ + ClearLastResult(); + + result r = GetCore().AddItem(text, actionId); + + if (r == E_SYSTEM) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Failed to add item to tab."); + return E_SYSTEM; + } + + return r; +} + + +result +_TabImpl::InsertItemAt(int index, const Bitmap& icon, const String& text, int actionId) +{ + ClearLastResult(); + + result r = GetCore().InsertItemAt(index, icon, text, actionId); + + if (r == E_SYSTEM) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Failed to insert item to tab."); + return E_SYSTEM; + } + + return r; +} + + +result +_TabImpl::InsertItemAt(int index, const Bitmap& icon, int actionId) +{ + ClearLastResult(); + + result r = GetCore().InsertItemAt(index, icon, actionId); + + if (r == E_SYSTEM) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Failed to insert item to tab."); + return E_SYSTEM; + } + + return r; +} + + +result +_TabImpl::InsertItemAt(int index, const String& text, int actionId) +{ + ClearLastResult(); + + result r = GetCore().InsertItemAt(index, text, actionId); + + if (r == E_SYSTEM) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Failed to insert item to tab."); + return E_SYSTEM; + } + + return r; +} + + +result +_TabImpl::SetItemAt(int index, const Bitmap& icon, const String& text, int actionId) +{ + ClearLastResult(); + + result r = GetCore().SetItemAt(index, icon, text, actionId); + + if (r == E_SYSTEM) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Failed to set item to tab."); + return E_SYSTEM; + } + + return r; +} + + +result +_TabImpl::SetItemAt(int index, const Bitmap& icon, int actionId) +{ + ClearLastResult(); + + result r = GetCore().SetItemAt(index, icon, actionId); + + if (r == E_SYSTEM) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Failed to set item to tab."); + return E_SYSTEM; + } + + return r; +} + + +result +_TabImpl::SetItemAt(int index, const String& text, int actionId) +{ + ClearLastResult(); + + result r = GetCore().SetItemAt(index, text, actionId); + + if (r == E_SYSTEM) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Failed to set item to tab."); + return E_SYSTEM; + } + + return r; +} + + +result +_TabImpl::RemoveItemAt(int index) +{ + ClearLastResult(); + + return GetCore().RemoveItemAt(index); +} + + +result +_TabImpl::RemoveAllItems(void) +{ + ClearLastResult(); + + return GetCore().RemoveAllItems(); +} + + +result +_TabImpl::SetBadgeIcon(int actionId, const Bitmap* pBadgeIcon) +{ + ClearLastResult(); + + return GetCore().SetBadgeIcon(actionId, pBadgeIcon); +} + + +int +_TabImpl::GetItemCount(void) const +{ + ClearLastResult(); + + return GetCore().GetItemCount(); +} + + +int +_TabImpl::GetItemIndexFromActionId(int actionId) const +{ + ClearLastResult(); + + return GetCore().GetItemIndexFromActionId(actionId); +} + + +int +_TabImpl::GetItemActionIdAt(int index) const +{ + ClearLastResult(); + + return GetCore().GetItemActionIdAt(index); +} + + +void +_TabImpl::SetSelectedItem(int index) +{ + ClearLastResult(); + + GetCore().SetSelectedItemIndex(index); +} + + +int +_TabImpl::GetSelectedItemIndex(void) const +{ + ClearLastResult(); + + return GetCore().GetSelectedItemIndex(); +} + + +void +_TabImpl::SetEditModeEnabled(bool enable) +{ + ClearLastResult(); + + GetCore().SetEditModeEnabled(enable); +} + + +bool +_TabImpl::IsEditModeEnabled(void) const +{ + ClearLastResult(); + + return GetCore().IsEditModeEnabled(); +} + + +result +_TabImpl::SetBackgroundBitmap(const Bitmap& bitmap) +{ + ClearLastResult(); + + return GetCore().SetBackgroundBitmap(bitmap); +} + + +result +_TabImpl::SetFocusedItemBackgroundBitmap(const Bitmap& bitmap) +{ + ClearLastResult(); + + return GetCore().SetSelectedItemBackgroundBitmap(bitmap); +} + + +void +_TabImpl::SetTextColor(const Color& textColor) +{ + ClearLastResult(); + + GetCore().SetTextColor(textColor); +} + + +Color +_TabImpl::GetTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetTextColor(); +} + + +void +_TabImpl::SetSelectedTextColor(const Color& textColor) +{ + ClearLastResult(); + + GetCore().SetSelectedTextColor(textColor); +} + + +Color +_TabImpl::GetSelectedTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetSelectedTextColor(); +} + + +result +_TabImpl::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap) +{ + ClearLastResult(); + + return GetCore().SetHighlightedItemBackgroundBitmap(bitmap); +} + + +void +_TabImpl::SetHighlightedTextColor(const Color& color) +{ + ClearLastResult(); + + GetCore().SetHighlightedTextColor(color); +} + + +Color +_TabImpl::GetHighlightedTextColor(void) const +{ + ClearLastResult(); + + return GetCore().GetHighlightedTextColor(); +} + + +void +_TabImpl::AddActionEventListener(IActionEventListener& listener) +{ + ClearLastResult(); + + if (__pActionEvent == null) + { + __pActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic()); + + if (__pActionEvent == null || IsFailed(GetLastResult())) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Failed to construct a _PublicActionEvent instance."); + SetLastResult(E_SYSTEM); + delete __pActionEvent; + return; + } + } + + __pActionEvent->AddListener(listener); + + GetCore().AddActionEventListener(*this); +} + + +void +_TabImpl::RemoveActionEventListener(IActionEventListener& listener) +{ + __pActionEvent->RemoveListener(listener); + + GetCore().RemoveActionEventListener(*this); +} + + +void +_TabImpl::OnActionPerformed(const _Control& source, int actionId) +{ + if (__pActionEvent != null) + { + __pActionEvent->Fire(*_PublicActionEvent::CreateActionEventArgN(actionId)); + } +} + + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TabItem.cpp b/src/ui/controls/FUiCtrl_TabItem.cpp new file mode 100644 index 0000000..f86a976 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TabItem.cpp @@ -0,0 +1,190 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabItem.cpp + * @brief This is the header file for the _TabItem class. + * + */ + +#include +#include "FUi_Control.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_TabItem.h" + + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls { + +_TabItem::_TabItem(void) + : __actionId(-1) + , __bUpdate(false) + , __style(_TABITEM_STYLE_TEXT) + , __text(L"") + , __pbmIcon(null) + , __pbmBadge(null) + , __status(_TABITEM_STATUS_NORMAL) +{ + __bounds.x = 0; + __bounds.y = 0; + __bounds.width = 10; + __bounds.height = 10; +} + + +_TabItem::~_TabItem(void) +{ + if (__pbmIcon) + { + delete __pbmIcon; + __pbmIcon = null; + } + + if (__pbmBadge) + { + delete __pbmBadge; + __pbmBadge = null; + } +} + + +void +_TabItem::SetActionId(int actionId) +{ + __actionId = actionId; +} + + +int +_TabItem::GetActionId(void) const +{ + return __actionId; +} + + +void +_TabItem::SetUpdateState(bool bUpdate) +{ + __bUpdate = bUpdate; +} + + +int +_TabItem::GetUpdateState(void) const +{ + return __bUpdate; +} + + +void +_TabItem::SetText(const Tizen::Base::String& text) +{ + __text = text; +} + + +Tizen::Base::String +_TabItem::GetText(void) const +{ + return __text; +} + + +void +_TabItem::SetIcon(const Bitmap& icon) +{ + + Tizen::Graphics::Bitmap* __pBitmap = _BitmapImpl::CloneN(icon); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pBitmap), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pbmIcon = __pBitmap; + + __pBitmap = null; +} + + +Bitmap* +_TabItem::GetIcon(void) const +{ + return __pbmIcon; +} + + +void +_TabItem::SetBadgeIcon(const Bitmap& icon) +{ + Tizen::Graphics::Bitmap* __pBitmap = _BitmapImpl::CloneN(icon); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, (__pBitmap), r, "[%s] Propagating.", GetErrorMessage(r)); + + __pbmBadge = __pBitmap; + + __pBitmap = null; +} + + +Bitmap* +_TabItem::GetBadgeIcon(void) const +{ + return __pbmBadge; +} + + +void +_TabItem::SetItemBounds(Rectangle bounds) +{ + __bounds = bounds; +} + + +Rectangle +_TabItem::GetItemBounds(void) const +{ + return __bounds; +} + + +void +_TabItem::SetStatus(_TabItemStatus status) +{ + __status = status; +} + + +_TabItemStatus +_TabItem::GetStatus(void) const +{ + return __status; +} + + +void +_TabItem::SetStyle(int style) +{ + __style = style; +} + + +_TabItemStyle +_TabItem::GetStyle(void) const +{ + return _TabItemStyle(__style); +} + + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TabModel.cpp b/src/ui/controls/FUiCtrl_TabModel.cpp new file mode 100644 index 0000000..199a3b2 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TabModel.cpp @@ -0,0 +1,107 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabModel.cpp + * @brief This is the implementation file for the _TabModel class. + */ + + +#include +#include +#include "FUiCtrl_TabModel.h" + +namespace Tizen { namespace Ui { namespace Controls { + +_TabModel::_TabModel(void) + : __selectedItemIndex(0) + , __pressedItemIndex(-1) + , __firstDrawnItemIndex(-1) + , __isEditModeEnabled(true) +{ +} + + +_TabModel::~_TabModel(void) +{ +} + + +result +_TabModel::Construct(void) +{ + ClearLastResult(); + + return E_SUCCESS; +} + + +void +_TabModel::SetSelectedItemIndex(int index) +{ + __selectedItemIndex = index; +} + + +int +_TabModel::GetSelectedItemIndex(void) const +{ + return __selectedItemIndex; +} + + +void +_TabModel::SetPressedItemIndex(int index) +{ + __pressedItemIndex = index; +} + + +int +_TabModel::GetPressedItemIndex(void) const +{ + return __pressedItemIndex; +} + + +void +_TabModel::SetFirstDrawnItemIndex(int index) +{ + __firstDrawnItemIndex = index; +} + + +int +_TabModel::GetFirstDrawnItemIndex(void) const +{ + return __firstDrawnItemIndex; +} + + +void +_TabModel::SetEditModeEnabled(bool enable) +{ + __isEditModeEnabled = enable; +} + + +bool +_TabModel::IsEditModeEnabled(void) const +{ + return __isEditModeEnabled; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TabPresenter.cpp b/src/ui/controls/FUiCtrl_TabPresenter.cpp new file mode 100644 index 0000000..e66d027 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TabPresenter.cpp @@ -0,0 +1,2444 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabPresenter.cpp + * @brief This is the implementation file for the _TabPresenter class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_AccessibilityElement.h" +#include "FUi_IAccessibilityListener.h" +#include "FUi_AccessibilityContainer.h" +#include "FUiAnim_VisualElement.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_TabPresenter.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Ui { namespace Controls { + +struct ReorderAnimationInfo{ + + int xPosition; + int index; + int totalDistance; + float move; + int reorderValue; +}; + +struct TimerInfo{ + + int index; + Timer* pReorderTimer; +}; + +_TabPresenter::_TabPresenter(void) + : __pTab(null) + , __pTabModel(null) + , __pFont(null) + , __pTextObject(null) + , __recalc(false) + , __editMode(false) + , __editItemIndex(-1) + , __pVerticalLineBitmap(null) + , __pHorizontalLineBitmap(null) + , __pFrontScrollingEffectBitmap(null) + , __pRearScrollingEffectBitmap(null) + , __pScrollingEffectBitmap(null) + , __pScrollingEffectVe(null) + , __pFlickAnimationTimer(null) + , __pScrollAnimationTimer(null) + , __flickAnimation() + , __showItemCount(0) + , __width(0) + , __height(0) + , __moveDistance(0) + , __isFlickEnabled(false) + , __itemMaxCount(0) + , __itemWidth(0) + , __itemHeight(0) + , __rearIndex(0) + , __isRightScrolable(false) + , __isLeftScrolable(false) + , __isDirectionRight(true) + , __isTimerCanceled(false) + , __flickMove(0.0) + , __flickDistance(0) + , __flickFlag(0) + , __reorderDist(0) + , __firstItemIndex(0) + , __lastItemIndex(0) + , __selectedLineLeftMargin(0) + , __selectedLineRightMargin(0) + , __isScrollEffectEnded(false) + , __isScrollEffectStarted(false) + , __timerCount(0) + , __isTouchMove(false) + , __scrollFlag(0) + , __tabMinimumSize(0) + +{ + __currentTouchPosition = Point(0, 0); + __dividerLine = Rectangle(0, 0, 0, 0); + __selectedLine = Rectangle(0, 0, 0, 0); + + for (int i = 0; i < (_TIMER_COUNT); i++) + { + __pTimerInfo[i] = null; + } + + for (int i = 0; i < _TAB_ITEM_MAXCOUNT; i++) + { + __pAnimInfo[i] = null; + } +} + + +_TabPresenter::~_TabPresenter(void) +{ + if (__pTabModel) + { + delete __pTabModel; + __pTabModel = null; + } + + if (__pTextObject) + { + delete __pTextObject; + __pTextObject = null; + } + + if (__pVerticalLineBitmap) + { + delete __pVerticalLineBitmap; + __pVerticalLineBitmap = null; + } + + if (__pHorizontalLineBitmap) + { + delete __pHorizontalLineBitmap; + __pHorizontalLineBitmap = null; + } + + if (__pFlickAnimationTimer) + { + delete __pFlickAnimationTimer; + __pFlickAnimationTimer = null; + } + + for (int i = 0; i < (_TIMER_COUNT); i++) + { + if (__pTimerInfo[i]) + { + if (__pTimerInfo[i]->pReorderTimer) + { + delete __pTimerInfo[i]->pReorderTimer; + __pTimerInfo[i]->pReorderTimer = null; + } + delete __pTimerInfo[i]; + __pTimerInfo[i] = null; + } + } + + for (int i = 0; i < _TAB_ITEM_MAXCOUNT; i++) + { + if (__pAnimInfo[i]) + { + delete __pAnimInfo[i]; + __pAnimInfo[i] = null; + } + } + + if (__pScrollAnimationTimer) + { + delete __pScrollAnimationTimer; + __pScrollAnimationTimer = null; + } + + if (__pFrontScrollingEffectBitmap) + { + delete __pFrontScrollingEffectBitmap; + __pFrontScrollingEffectBitmap = null; + } + + if (__pRearScrollingEffectBitmap) + { + delete __pRearScrollingEffectBitmap; + __pRearScrollingEffectBitmap = null; + } + + if (__pScrollingEffectBitmap) + { + __pScrollingEffectBitmap = null; + } + + if (__pScrollingEffectVe) + { + __pScrollingEffectVe->RemoveAllAnimations(); + __pScrollingEffectVe->Destroy(); + __pScrollingEffectVe = null; + } +} + +result +_TabPresenter::Construct(const _Tab& tab) +{ + result r = E_SUCCESS; + + __pTab = const_cast<_Tab*>(&tab); + + __pFont = __pTab->GetFallbackFont(); + SysTryReturn(NID_UI_CTRL, __pFont, E_SYSTEM , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to retrive Font."); + + _TabModel* pModel = new (std::nothrow) _TabModel; + SysTryReturn(NID_UI_CTRL, pModel, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = SetModel(*pModel); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to set _TabModel instance."); + + r = pModel->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to construct _TabModel instance."); + + __pTextObject = new (std::nothrow) TextObject; + SysTryCatch(NID_UI_CTRL, __pTextObject, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTextObject->Construct(); + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + + r = LoadBitmap(); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate bitmap."); + + GET_FIXED_VALUE_CONFIG(TAB::ITEM_MAX_COUNT, __pTab->GetOrientation(), __itemMaxCount); + GET_SHAPE_CONFIG(TAB::SCREEN_WIDTH, __pTab->GetOrientation(), __width); + GET_SHAPE_CONFIG(TAB::SCREEN_HEIGHT, __pTab->GetOrientation(), __height); + + GET_SHAPE_CONFIG(TAB::DIVIDER_WIDTH, __pTab->GetOrientation(), __dividerLine.width); + GET_SHAPE_CONFIG(TAB::DIVIDER_HEIGHT, __pTab->GetOrientation(), __dividerLine.height); + + GET_SHAPE_CONFIG(TAB::TAB_MINIMUM_SIZE, __pTab->GetOrientation(), __tabMinimumSize); + + GET_SHAPE_CONFIG(TAB::SELECTED_LINE_LEFT_MARGIN, __pTab->GetOrientation(), __selectedLineLeftMargin); + GET_SHAPE_CONFIG(TAB::SELECTED_LINE_RIGHT_MARGIN, __pTab->GetOrientation(), __selectedLineRightMargin); + GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), __selectedLine.height); + + __flickAnimation.SetSizeInformation(__width, __height, DEVICE_SIZE_HORIZONTAL, DEVICE_SIZE_VERTICAL); + __flickAnimation.SetSensitivity(FLICK_ANIMATION_FPS_TAB, FLICK_ANIMATION_SENSITIVITY_TAB); + __flickAnimation.SetDirection(FD_HORIZONTAL); + + for (int i = 0; i < _TIMER_COUNT; i++) + { + __pTimerInfo[i] = new (std::nothrow) TimerInfo(); + SysTryCatch(NID_UI_CTRL, __pTimerInfo[i], , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTimerInfo[i]->index = -1; + __pTimerInfo[i]->pReorderTimer = null; + } + + return r; + +CATCH: + delete pModel; + pModel = null; + + delete __pTextObject; + __pTextObject = null; + + return r; +} + +result +_TabPresenter::LoadBitmap(void) +{ + result r = E_SUCCESS; + Tizen::Graphics::Bitmap* pBitmap = null; + r = GET_BITMAP_CONFIG_N(TAB::VERTICAL_DIVIDER_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pVerticalLineBitmap); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate divider line bitmap."); + + r = GET_BITMAP_CONFIG_N(TAB::ITEM_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate horizontal line bitmap."); + + if (pBitmap) + { + __pHorizontalLineBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pBitmap), Color::GetColor(COLOR_ID_MAGENTA), __pTab->GetPressedTextColor()); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate focus item line bitmap."); + } + r = GET_BITMAP_CONFIG_N(TAB::TAB_BOUNCE_EFFECT_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888, __pFrontScrollingEffectBitmap); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate overscrolling left bitmap."); + + r = GET_BITMAP_CONFIG_N(TAB::TAB_BOUNCE_EFFECT_RIGHT, BITMAP_PIXEL_FORMAT_ARGB8888, __pRearScrollingEffectBitmap); + SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate overscrolling right bitmap."); + + delete pBitmap; + return r; +} + +void +_TabPresenter::DrawResourceBitmap(Canvas& canvas, const Rectangle& bounds, Bitmap* pBitmap) +{ + result r = E_SUCCESS; + + if (pBitmap == null) + { + return; + } + + if (pBitmap->IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = canvas.DrawBitmap(bounds, *pBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return; +} + +result +_TabPresenter::SetModel(const _TabModel& tabModel) +{ + __pTabModel = const_cast<_TabModel*>(&tabModel); + + return E_SUCCESS; +} + +void +_TabPresenter::SetSelectedItemIndex(int index) +{ + int i = GetSelectedItemIndex(); + SetItemStatus(i, _TABITEM_STATUS_NORMAL); + __pTabModel->SetSelectedItemIndex(index); + SetItemStatus(index, _TABITEM_STATUS_SELECTED); + return; +} + +int +_TabPresenter::GetSelectedItemIndex(void) const +{ + return __pTabModel->GetSelectedItemIndex(); +} + +void +_TabPresenter::SetPressedItemIndex(int index) +{ + __pTabModel->SetPressedItemIndex(index); + return; +} + +int +_TabPresenter::GetPressedItemIndex(void) const +{ + return __pTabModel->GetPressedItemIndex(); +} + +void +_TabPresenter::SetFirstDrawnItemIndex(int index) +{ + __pTabModel->SetFirstDrawnItemIndex(index); + return; +} + +int +_TabPresenter::GetFirstDrawnItemIndex(void) const +{ + + return __pTabModel->GetFirstDrawnItemIndex(); +} + +void +_TabPresenter::SetEditModeEnabled(bool enable) +{ + + return __pTabModel->SetEditModeEnabled(enable); +} + +bool +_TabPresenter::IsEditModeEnabled(void) const +{ + return __pTabModel->IsEditModeEnabled(); +} + +int +_TabPresenter::GetItemCount(void) const +{ + + return __pTab->GetItemCount(); +} + +_TabItem* +_TabPresenter::GetItemAt(int index) +{ + return __pTab->GetItemAt(index); +} + +result +_TabPresenter::SetItemStatus(int index, _TabItemStatus status) +{ + _TabItem *pItem = GetItemAt(index); + SysTryReturn(NID_UI_CTRL, pItem, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pItem->SetUpdateState(true); + pItem->SetStatus(status); + + return E_SUCCESS; +} + +_TabItemStatus +_TabPresenter::GetItemStatus(int index) const +{ + + _TabItem *pItem = __pTab->GetItemAt(index); + + if (pItem == null) + { + return _TABITEM_STATUS_NORMAL; + } + + return pItem->GetStatus(); +} + +int +_TabPresenter::GetItemIndexFromPosition(const Point& point) const +{ + + Rectangle itemBounds(0, 0, 0, 0); + + int itemIndex = GetFirstDrawnItemIndex(); + + if ((point.x < 0) || (point.x > __pTab->GetBounds().width) + || (point.y < 0 ) || (point.y > __pTab->GetBounds().height)) + { + return -1; + } + + _TabItem* pItem = __pTab->GetItemAt(itemIndex); + if (pItem == null) + { + return -1; + } + + while (pItem != null) + { + itemBounds = pItem->GetItemBounds(); + + if ((point.x > itemBounds.x) && (point.x < itemBounds.x + itemBounds.width) + && (point.y > itemBounds.y) && (point.y < itemBounds.y + itemBounds.height)) + { + return itemIndex; + } + + itemIndex++; + pItem = __pTab->GetItemAt(itemIndex); + if (pItem == null) + { + break; + } + } + + return -1; +} + +void +_TabPresenter::Draw(void) +{ + ClearLastResult(); + + SysTryReturnVoidResult(NID_UI_CTRL, __pTab, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Tab instance is null."); + GET_COLOR_CONFIG(TAB::ITEM_BG_NORMAL, backgroundColor); + if (__recalc) + { + __recalc = false; + CalcItemBounds(); + } + else if (__isFlickEnabled ) + { + DrawHorizontal(); + } + Canvas* pCanvas = __pTab->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(backgroundColor); + pCanvas->Clear(); + + if (__pTab->GetStyle() == _TAB_STYLE_TEXT) + { + DrawTextItem(pCanvas); + } + else if (__pTab->GetStyle() == _TAB_STYLE_ICON) + { + DrawIconItem(pCanvas); + } + else // _TAB_STYLE_ICON_TEXT + { + DrawItem(pCanvas); + } + + RefreshAccessibilityElement(); + + delete pCanvas; + return; +} + +void +_TabPresenter::SetReCalculateItemBounds(bool reCalculationRequired) +{ + __recalc = reCalculationRequired; + return; +} + +void +_TabPresenter::DrawTextItem(Canvas* pCanvas) +{ + ClearLastResult(); + TextSimple* pSimpleText = null; + Rectangle bounds = __pTab->GetBounds(); + + _TabItem* pDrawItem = null; + String itemText(L""); + Rectangle itemDrawRect(0, 0, 0, 0); + + const int itemCount = GetItemCount(); + + _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL; + + bool multiline = false; + int fontChangeItemCount = 0; + GET_FIXED_VALUE_CONFIG(TAB::FONT_CHANGE_ITEM_COUNT, __pTab->GetOrientation(), fontChangeItemCount); + + int topMargin = 0; + int bottomMargin = 0; + int leftMargin = 0; + int rightMargin = 0; + GET_SHAPE_CONFIG(TAB::TOP_MARGIN, __pTab->GetOrientation(), topMargin); + GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin); + GET_SHAPE_CONFIG(TAB::ITEM_LEFT_MARGIN, __pTab->GetOrientation(), leftMargin); + GET_SHAPE_CONFIG(TAB::ITEM_RIGHT_MARGIN, __pTab->GetOrientation(), rightMargin); + + for (int i = 0; i < itemCount; i++) + { + pDrawItem = GetItemAt(i); + + SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + SetFirstDrawnItemIndex(0); + + // Item Rect + itemDrawRect = pDrawItem->GetItemBounds(); + __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width)/2); + __dividerLine.y = ((itemDrawRect.height - __dividerLine.height)/2); + + // Item Status + itemStatus = pDrawItem->GetStatus(); + + // Status + if (itemStatus == _TABITEM_STATUS_SELECTED) + { + DrawSelectedItemBackground(pCanvas, itemDrawRect); + __selectedLine.width = __itemWidth - __selectedLineLeftMargin - __selectedLineRightMargin; + __selectedLine.x = itemDrawRect.x + __selectedLineLeftMargin; + } + else if (itemStatus == _TABITEM_STATUS_PRESSED) + { + DrawFocusItemBackground(pCanvas, itemDrawRect); + } + else + { + DrawItemBackground(pCanvas, itemDrawRect); + } + + // Draw Text + itemText = pDrawItem->GetText(); + + __pTextObject->RemoveAll(); + pSimpleText = new (std::nothrow)TextSimple(const_cast (itemText.GetPointer()), itemText.GetLength()); + SysTryReturnVoidResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTextObject->AppendElement(*pSimpleText); + __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + // Margin - Item Rect. + itemDrawRect.x = itemDrawRect.x + leftMargin; + itemDrawRect.y = itemDrawRect.y + topMargin; + itemDrawRect.width = itemDrawRect.width - leftMargin - rightMargin; + itemDrawRect.height = itemDrawRect.height - topMargin - bottomMargin; + + __pTextObject->SetBounds(itemDrawRect); + __pTextObject->Compose(); + + const int textRowCount = __pTextObject->GetTotalLineCount(); + + // Init. + multiline = false; + + if (textRowCount >= 2) + { + multiline = true; + } + + // Font Size Change + if (__pFont != null ) + { + int fontSize = 0; + + if (__showItemCount < fontChangeItemCount) + { + if (multiline == false) + { + GET_SHAPE_CONFIG(TAB::FONT_SIZE_01, __pTab->GetOrientation(), fontSize); + } + else + { + GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_01, __pTab->GetOrientation(), fontSize); + } + } + else if (__showItemCount == fontChangeItemCount) + { + if (multiline == false) + { + GET_SHAPE_CONFIG(TAB::FONT_SIZE_02, __pTab->GetOrientation(), fontSize); + } + else + { + GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_02, __pTab->GetOrientation(), fontSize); + } + } + else + { + if (multiline == false) + { + GET_SHAPE_CONFIG(TAB::FONT_SIZE_03, __pTab->GetOrientation(), fontSize); + } + else + { + GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_03, __pTab->GetOrientation(), fontSize); + } + } + + (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize); + } + + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + + if (itemStatus == _TABITEM_STATUS_SELECTED) + { + __pTextObject->SetForegroundColor(__pTab->GetSelectedTextColor(), 0, __pTextObject->GetTextLength()); + __selectedLine.y = itemDrawRect.y + itemDrawRect.height; + if (__pTab->GetSelectedItemBackgroundBitmap() == null) + { + DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap); + } + + } + else if (itemStatus == _TABITEM_STATUS_PRESSED) + { + __pTextObject->SetForegroundColor(__pTab->GetPressedTextColor(), 0, __pTextObject->GetTextLength()); + } + else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED) + { + __pTextObject->SetForegroundColor(__pTab->GetHighlightedTextColor(), 0, __pTextObject->GetTextLength()); + } + else + { + __pTextObject->SetForegroundColor(__pTab->GetTextColor(), 0, __pTextObject->GetTextLength()); + } + + __pTextObject->SetBounds(itemDrawRect); + __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + if (i < (itemCount - 1)) + { + DrawItemDivisionVerticalLine(pCanvas, __dividerLine); + } + + DrawBadgeIcon(pDrawItem, pCanvas); + + } + return; +} + +void +_TabPresenter::DrawItemBackground(Canvas* pCanvas, Rectangle& itemRect) +{ + Bitmap* pBackgroundBitmap = __pTab->GetBackgroundBitmap(); + + DrawResourceBitmap(*pCanvas, itemRect, pBackgroundBitmap); + + return; +} + +void +_TabPresenter::DrawFocusItemBackground(Canvas* pCanvas, Rectangle& itemRect) +{ + Bitmap* pBackgroundBitmap = __pTab->GetPressedItemBackgroundBitmap(); + + DrawResourceBitmap(*pCanvas, itemRect, pBackgroundBitmap); + + return; +} + +void +_TabPresenter::DrawSelectedItemBackground(Canvas* pCanvas, Rectangle& itemRect) +{ + Bitmap* pBackgroundBitmap = __pTab->GetSelectedItemBackgroundBitmap(); + + DrawResourceBitmap(*pCanvas, itemRect, pBackgroundBitmap); + + return; +} + +void +_TabPresenter::DrawIconItem(Canvas* pCanvas) +{ + ClearLastResult(); + Rectangle bounds = __pTab->GetBounds(); + + _TabItem* pDrawItem = null; + String itemText(L""); + Rectangle itemDrawRect(0, 0, 0, 0); + const int itemCount = GetItemCount(); + + _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL; + + int iconWidth = 0; + int iconHeight = 0; + int bottomMargin = 0; + + GET_SHAPE_CONFIG(TAB::ICON_WIDTH, __pTab->GetOrientation(), iconWidth); + GET_SHAPE_CONFIG(TAB::ICON_HEIGHT, __pTab->GetOrientation(), iconHeight); + GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin); + + for (int i = 0; i < itemCount; i++) + { + pDrawItem = GetItemAt(i); + SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + SetFirstDrawnItemIndex(0); + + // Item Rect + itemDrawRect = pDrawItem->GetItemBounds(); + __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width)/2); + __dividerLine.y = ((itemDrawRect.height - __dividerLine.height)/2); + + // Item Status + itemStatus = pDrawItem->GetStatus(); + + // Status + if (itemStatus == _TABITEM_STATUS_SELECTED) + { + DrawSelectedItemBackground(pCanvas, itemDrawRect); + __selectedLine.width = __itemWidth - __selectedLineLeftMargin - __selectedLineRightMargin; + __selectedLine.x = itemDrawRect.x + __selectedLineLeftMargin; + __selectedLine.y = itemDrawRect.height - (bottomMargin/2); + + if (__pTab->GetSelectedItemBackgroundBitmap() == null) + { + DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap); + } + } + else if (itemStatus == _TABITEM_STATUS_PRESSED) + { + DrawFocusItemBackground(pCanvas, itemDrawRect); + } + else + { + DrawItemBackground(pCanvas, itemDrawRect); + } + // Disable / Normal + + // Margin - Item Rect. + itemDrawRect.x = itemDrawRect.x + ((itemDrawRect.width - iconWidth) / 2); + itemDrawRect.y = itemDrawRect.y + ((itemDrawRect.height - iconHeight) / 2); + itemDrawRect.width = iconWidth; + itemDrawRect.height = iconHeight; + + Bitmap* pIconBitmap = pDrawItem->GetIcon(); + + DrawResourceBitmap(*pCanvas, itemDrawRect, pIconBitmap); + + if (i < itemCount - 1) + { + DrawItemDivisionVerticalLine(pCanvas, __dividerLine); + } + DrawBadgeIcon(pDrawItem, pCanvas); + } + return; + +} + +void +_TabPresenter::DrawItem(Canvas* pCanvas) +{ + ClearLastResult(); + + Rectangle bounds = __pTab->GetBounds(); + + TextSimple* pSimpleText = null; + _TabItem* pDrawItem = null; + Rectangle buttonBounds(0, 0, 0, 0); + String itemText(L""); + Rectangle itemDrawRect(0, 0, 0, 0); + Rectangle itemDrawIconRect(0, 0, 0, 0); + Rectangle itemDrawTextRect(0, 0, 0, 0); + int iconTextGap = 0; + const int itemCount = GetItemCount(); + + _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL; + + bool multiline = false; + int fontChangeItemCount = 0; + GET_FIXED_VALUE_CONFIG(TAB::FONT_CHANGE_ITEM_COUNT, __pTab->GetOrientation(), fontChangeItemCount); + GET_FIXED_VALUE_CONFIG(TAB::ICON_TEXT_GAP, __pTab->GetOrientation(), iconTextGap); + + int topMargin = 0; + int bottomMargin = 0; + int leftMargin = 0; + int rightMargin = 0; + int topMarginTextOnly = 0; + int textLength = 0; + int bottomMarginTextOnly = 0; + GET_SHAPE_CONFIG(TAB::TOP_MARGIN, __pTab->GetOrientation(), topMarginTextOnly); + GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMarginTextOnly); + + GET_SHAPE_CONFIG(TAB::ICON_TEXT_TOP_MARGIN, __pTab->GetOrientation(), topMargin); + GET_SHAPE_CONFIG(TAB::ICON_TEXT_BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin); + GET_SHAPE_CONFIG(TAB::ITEM_LEFT_MARGIN, __pTab->GetOrientation(), leftMargin); + GET_SHAPE_CONFIG(TAB::ITEM_RIGHT_MARGIN, __pTab->GetOrientation(), rightMargin); + int iconWidth = 0; + int iconHeight = 0; + GET_SHAPE_CONFIG(TAB::ICON_TEXT_ICON_WIDTH, __pTab->GetOrientation(), iconWidth); + GET_SHAPE_CONFIG(TAB::ICON_TEXT_ICON_HEIGHT, __pTab->GetOrientation(), iconHeight); + int iconGap = 0; + GET_FIXED_VALUE_CONFIG(TAB::ICON_TEXT_GAP, __pTab->GetOrientation(), iconGap); + + for (int i = 0; i < itemCount; i++) + { + pDrawItem = GetItemAt(i); + SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + SetFirstDrawnItemIndex(0); + + itemDrawRect = pDrawItem->GetItemBounds(); + __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width)/2); + __dividerLine.y = ((itemDrawRect.height - __dividerLine.height)/2); + + itemStatus = pDrawItem->GetStatus(); + + if (itemStatus == _TABITEM_STATUS_SELECTED) + { + DrawSelectedItemBackground(pCanvas, itemDrawRect); + __selectedLine.width = __itemWidth - __selectedLineLeftMargin - __selectedLineRightMargin; + __selectedLine.x = itemDrawRect.x + __selectedLineLeftMargin; + } + else if (itemStatus == _TABITEM_STATUS_PRESSED) + { + DrawFocusItemBackground(pCanvas, itemDrawRect); + } + else + { + DrawItemBackground(pCanvas, itemDrawRect); + } + + + itemText = pDrawItem->GetText(); + + __pTextObject->RemoveAll(); + pSimpleText = new (std::nothrow)TextSimple(const_cast (itemText.GetPointer()), itemText.GetLength()); + SysTryReturnVoidResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pTextObject->AppendElement(*pSimpleText); + + __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + textLength = __pTextObject->GetTextLength(); + + if ((pDrawItem->GetIcon()) == null) + { + topMargin = topMarginTextOnly; + bottomMargin = bottomMarginTextOnly; + } + Dimension textDim(0,0); + + // Font Size Change + if (__pFont != null ) + { + int fontSize = 0; + + if (__showItemCount < fontChangeItemCount) + { + if (multiline == false) + { + GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_01, __pTab->GetOrientation(), fontSize); + } + else + { + GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize); + } + } + else if (__showItemCount == fontChangeItemCount) + { + if (multiline == false) + { + GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize); + } + else + { + GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize); + } + } + else + { + if (multiline == false) + { + GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_03, __pTab->GetOrientation(), fontSize); + } + else + { + GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_03, __pTab->GetOrientation(), fontSize); + } + } + + (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize); + + __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength()); + + __pFont->GetTextExtent(itemText, itemText.GetLength(), textDim); + } + + itemDrawTextRect = itemDrawRect; + itemDrawTextRect.x = itemDrawRect.x + leftMargin; + multiline = false; + if (textDim.width > (__itemWidth/2)) + { + multiline = true; + textDim.width = (__itemWidth/2); + textDim.height = textDim.height * 2; + } + itemDrawTextRect.width = textDim.width; + itemDrawTextRect.x = itemDrawRect.x + leftMargin; + itemDrawTextRect.x = itemDrawTextRect.x + ((itemDrawRect.width - leftMargin - rightMargin) - (iconWidth + iconGap + itemDrawTextRect.width))/2; + itemDrawTextRect.height = textDim.height; + itemDrawIconRect = itemDrawTextRect; + itemDrawTextRect.x = itemDrawIconRect.x + iconWidth + iconGap; + + if ((pDrawItem->GetIcon()) != null) + { + itemDrawIconRect.height = itemDrawRect.height - topMargin - bottomMargin; + itemDrawIconRect.y = itemDrawIconRect.y +topMargin+ (itemDrawIconRect.height - iconHeight)/2; + + itemDrawIconRect.width = iconWidth; + itemDrawIconRect.height = iconHeight; + Bitmap* pIconBitmap = pDrawItem->GetIcon(); + + DrawResourceBitmap(*pCanvas, itemDrawIconRect, pIconBitmap); + + } + else + { + itemDrawTextRect.x = itemDrawRect.x + leftMargin + (itemDrawRect.width - leftMargin - rightMargin - itemDrawTextRect.width)/2; + } + + + if (multiline == false) + { + itemDrawTextRect.y = itemDrawRect.y + topMargin + (itemDrawRect.height - topMargin - bottomMargin - itemDrawTextRect.height)/2; + } + else + { + itemDrawTextRect.y = itemDrawRect.y + topMargin + (itemDrawRect.height - topMargin - bottomMargin - itemDrawTextRect.height)/2; + } + __pTextObject->SetBounds(itemDrawTextRect); + __pTextObject->Compose(); + if (itemStatus == _TABITEM_STATUS_SELECTED) + { + __pTextObject->SetForegroundColor(__pTab->GetSelectedTextColor(), 0, __pTextObject->GetTextLength()); + __selectedLine.y = itemDrawRect.height - bottomMargin; + if (__pTab->GetSelectedItemBackgroundBitmap() == null) + { + DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap); + } + } + else if (itemStatus == _TABITEM_STATUS_PRESSED) + { + __pTextObject->SetForegroundColor(__pTab->GetPressedTextColor(), 0, __pTextObject->GetTextLength()); + } + else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED) + { + __pTextObject->SetForegroundColor(__pTab->GetHighlightedTextColor(), 0, __pTextObject->GetTextLength()); + } + else + { + __pTextObject->SetForegroundColor(__pTab->GetTextColor(), 0, __pTextObject->GetTextLength()); + } + + __pTextObject->SetBounds(itemDrawTextRect); + + __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + + if (i < itemCount - 1) + { + DrawItemDivisionVerticalLine(pCanvas, __dividerLine); + } + DrawBadgeIcon(pDrawItem, pCanvas); + + } + return; +} + +void +_TabPresenter::DrawEditItem(const Point& point) +{ + + _TabItem *pTabItem = null; + Rectangle editRect(0, 0, 0, 0); + pTabItem = GetItemAt(__editItemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + editRect = pTabItem->GetItemBounds(); + + editRect.x = point.x - (__itemWidth / 2); + pTabItem->SetItemBounds(editRect); + + return; + +} + +void +_TabPresenter::DrawItemDivisionVerticalLine(Canvas* pCanvas, Rectangle& lineRect) +{ + DrawResourceBitmap(*pCanvas, lineRect, __pVerticalLineBitmap); + + return; +} + +void +_TabPresenter::DrawHorizontal() +{ + ClearLastResult(); + + int itemCount = GetItemCount(); + int boundItemIndex = 0; + if (__moveDistance == 0) + { + return; + } + if (itemCount == 0) + { + SysLog(NID_UI_CTRL, "itemCount is 0."); + return; + } + //Bound beyond which the item shouldnt move when flicked + boundItemIndex = itemCount - __itemMaxCount; + + _TabItem* pItem = null; + pItem = GetItemAt(boundItemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + Rectangle bounds = pItem->GetItemBounds(); + Rectangle itemBounds(0, 0, 0, 0); + if ((bounds.x + __moveDistance) < 0) + { + __moveDistance = -bounds.x; + ResetFlickAnimationTimer(); + } + + pItem = GetItemAt(0); + SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + bounds = pItem->GetItemBounds(); + + if ((bounds.x + __moveDistance) > 0) + { + CalcItemBounds(); + ResetFlickAnimationTimer(); + return; + } + + for (int i = 0; i < itemCount; i++) + { + pItem = GetItemAt(i); + SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + itemBounds = pItem->GetItemBounds(); + + itemBounds.x = itemBounds.x + __moveDistance; + pItem->SetItemBounds(itemBounds); + } + return; +} + +void +_TabPresenter::DrawBadgeIcon(_TabItem* pDrawItem, Canvas* pCanvas) +{ + Bitmap* pBadgeIcon = null; + int badgeMargin = 0; + GET_SHAPE_CONFIG(TAB::BADGE_ICON_MARGIN, __pTab->GetOrientation(), badgeMargin); + // Badge. + pBadgeIcon = pDrawItem->GetBadgeIcon(); + + if (pBadgeIcon != null) + { + Rectangle badgeRect = pDrawItem->GetItemBounds(); + + badgeRect.x = (badgeRect.x + badgeRect.width) - pBadgeIcon->GetWidth() - badgeMargin; + badgeRect.y = badgeMargin; + badgeRect.width = pBadgeIcon->GetWidth(); + badgeRect.height = pBadgeIcon->GetHeight(); + + DrawResourceBitmap(*pCanvas, badgeRect, pBadgeIcon); + + pBadgeIcon = null; + } + return; +} + +void +_TabPresenter::CalcItemBounds(void) +{ + ClearLastResult(); + + const int itemCount = GetItemCount(); + + if (itemCount == 0) + { + return; + } + + CalcTabBounds(true); + + Rectangle bounds = __pTab->GetBounds(); + + _TabItem* pItem = null; + Rectangle itemBounds(0, 0, 0, 0); + + if (__itemMaxCount > itemCount) + { + __showItemCount = itemCount; + } + else + { + __showItemCount = __itemMaxCount; + } + + itemBounds.width = bounds.width / __showItemCount; + itemBounds.height = bounds.height; + __itemWidth = itemBounds.width; + __itemHeight = bounds.height; + + + for (int i = 0; i < itemCount; i++) + { + pItem = GetItemAt(i); + SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pAnimInfo[i]->xPosition = itemBounds.x; + __pAnimInfo[i]->totalDistance = __itemWidth; + pItem->SetItemBounds(itemBounds); + itemBounds.x = itemBounds.x + itemBounds.width; + } + return; +} + +void +_TabPresenter::CalcTabBounds(bool bReset) +{ + Rectangle bounds = __pTab->GetBounds(); + + bool movable = __pTab->IsMovable(); + bool resizable = __pTab->IsResizable(); + + int lineHeight = 0; + int tabLeftMargin = 0; + int tabRightMargin = 0; + GET_SHAPE_CONFIG(TAB::LEFT_MARGIN, __pTab->GetOrientation(), tabLeftMargin); + GET_SHAPE_CONFIG(TAB::RIGHT_MARGIN, __pTab->GetOrientation(), tabRightMargin); + + if (__pTab->GetStyle() == _TAB_STYLE_ICON_TEXT) + { + GET_SHAPE_CONFIG(TAB::ICON_TEXT_HEIGHT, __pTab->GetOrientation(), lineHeight); + } + else + { + GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight); + } + __lastItemIndex = (__pTab->GetItemCount() - 1); + // Only 1 line + bounds.height = lineHeight; + + for (int i = 0; i < (__pTab->GetItemCount()); i++) + { + if (__pAnimInfo[i] == null) + { + __pAnimInfo[i] = new (std::nothrow) ReorderAnimationInfo(); + SysTryReturnVoidResult(NID_UI_CTRL, __pAnimInfo[i], E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pAnimInfo[i]->totalDistance = 0; + __pAnimInfo[i]->move = 0; + __pAnimInfo[i]->reorderValue = 0; + } + } + + __pTab->SetMovable(true); + __pTab->SetResizable(true); + + __pTab->SetBounds(bounds); + + __pTab->SetMovable(movable); + __pTab->SetResizable(resizable); + + return; + +} + +bool +_TabPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (GetItemCount() == 0) + { + return true; + } + __currentTouchPosition = touchinfo.GetCurrentPosition(); + SetFirstLoadedItemIndex(); + SetLastLoadedItemIndex(); + SetItemFitToLeft(); + ResetScrollAnimationTimer(); + SetReCalculateItemBounds(false); + ResetFlickAnimationTimer(); + + Point point = touchinfo.GetCurrentPosition(); + + const int index = GetItemIndexFromPosition(touchinfo.GetCurrentPosition()); + if (index == -1) + { + return false; + } + if (GetItemStatus(index) != _TABITEM_STATUS_SELECTED) + { + SetItemStatus(index, _TABITEM_STATUS_PRESSED); + SetPressedItemIndex(index); + } + + __pTab->Invalidate(); + + return true; +} + +bool +_TabPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (GetItemCount() == 0) + { + return true; + } + Point point = touchinfo.GetCurrentPosition(); + __scrollFlag = 0; + CancelReorderTimer(); + ResetScrollAnimationTimer(); + Rectangle itemBounds(0, 0, 0, 0); + _TabItem* pItem = null; + int index = GetItemIndexFromPosition(touchinfo.GetCurrentPosition()); + if (__pScrollingEffectVe) + { + __pScrollingEffectVe->RemoveAllAnimations(); + __pTab->GetVisualElement()->DetachChild(*__pScrollingEffectVe); + __pScrollingEffectVe->Destroy(); + __pScrollingEffectVe = null; + __isScrollEffectEnded = false; + __isScrollEffectStarted = false; + } + int pressedIndex = GetPressedItemIndex(); + __isRightScrolable = false; + if (index == -1 && !__isFlickEnabled) + { + SetFirstLoadedItemIndex(); + if (GetItemStatus(pressedIndex) == _TABITEM_STATUS_PRESSED) + { + SetItemStatus(pressedIndex, _TABITEM_STATUS_NORMAL); + } + CalcItemBounds(); + __moveDistance = -(GetItemAt(__firstLoadedItemIndex)->GetItemBounds().x); + DrawHorizontal(); + __pTab->Invalidate(); + __rearIndex = 0; + __editMode = false; + return false; + } + if (__editMode && __editItemIndex == __rearIndex) + { + Rectangle bounds(0,0,0,0); + if(__editItemIndex > 0) + { + pItem = GetItemAt((__editItemIndex - 1)); + SysTryReturn(NID_UI_CTRL, pItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + bounds = pItem->GetItemBounds(); + bounds.x = bounds.x + __itemWidth; + GetItemAt(__editItemIndex)->SetItemBounds(bounds); + } + else + { + CalcItemBounds(); + } + + } + // Edit Mode - Item Insert + if (__editMode && (__editItemIndex != __rearIndex)) + { + index = __rearIndex; + int i = GetSelectedItemIndex(); + SetItemStatus(i, _TABITEM_STATUS_NORMAL); + + if (__isDirectionRight) + { + index = index + 1; + } + + __pTab->ChangeItemAt(__editItemIndex, (index)); + if (__editItemIndex < index) + { + SetItemStatus((index-1), _TABITEM_STATUS_SELECTED); + SetSelectedItemIndex((index-1)); + } + else if (__editItemIndex > index) + { + SetItemStatus(index, _TABITEM_STATUS_SELECTED); + SetSelectedItemIndex(index); + } + + SetFirstLoadedItemIndex(); + SetLastLoadedItemIndex(); + + + CalcItemBounds(); + __moveDistance = -(__firstLoadedItemIndex * __itemWidth); + DrawHorizontal(); + } + else + { + // Pressed -> Selected or Normal + if (GetItemStatus(index) == _TABITEM_STATUS_PRESSED && !__isFlickEnabled && !__isTouchMove) + { + int i = GetSelectedItemIndex(); + SetItemStatus(i, _TABITEM_STATUS_NORMAL); + + SetItemStatus(index, _TABITEM_STATUS_SELECTED); + SetSelectedItemIndex(index); + } + else + { + int i = GetPressedItemIndex(); + if (GetItemStatus(i) == _TABITEM_STATUS_PRESSED) + { + SetItemStatus(i, _TABITEM_STATUS_NORMAL); + } + } + + } + + __pTab->Invalidate(); + __isTouchMove = false; + __editMode = false; + __editItemIndex = -1; + __rearIndex = -1; + + if (__firstItemIndex > 0) + { + __firstItemIndex--; + } + + if (__lastItemIndex < (__pTab->GetItemCount() - 1)) + { + __lastItemIndex++; + } + + return true; +} + +bool +_TabPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (GetItemCount() == 0) + { + return true; + } + _TabItem *pTabItem = null; + _TabItem *pNextItem = null; + _TabItem *pPrevItem = null; + Point movedPosition = touchinfo.GetCurrentPosition(); + + int index = GetNextItemIndexFromPosition(movedPosition, __editItemIndex); + SetFirstLoadedItemIndex(); + SetLastLoadedItemIndex(); + //Remove the Pressed Bitmap during Touch Move + int i = GetPressedItemIndex(); + if (!__editMode) + { + if (GetItemStatus(i) == _TABITEM_STATUS_PRESSED) + { + SetItemStatus(i, _TABITEM_STATUS_NORMAL); + Draw(); + } + } + + int distance; + distance = movedPosition.x - __currentTouchPosition.x; + __currentTouchPosition.x = movedPosition.x; + if (!__editMode && distance > 0) //Move right i.e Bounce at leftEnd + { + __isTouchMove = true; + if (!__isDirectionRight) + { + if (__pScrollingEffectVe) + { + __pScrollingEffectVe->RemoveAllAnimations(); + __pTab->GetVisualElement()->DetachChild(*__pScrollingEffectVe); + __pScrollingEffectVe->Destroy(); + __pScrollingEffectVe = null; + } + __isScrollEffectEnded = false; + __isScrollEffectStarted = false; + } + __isDirectionRight = true; + SetFirstLoadedItemIndex(); + if ( GetItemAt(0)->GetItemBounds().x >= 0) + { + if (!__isScrollEffectStarted) + { + __pScrollingEffectBitmap = __pFrontScrollingEffectBitmap; + SetOpacityVisualElement(0); + StartScrollingEffect(); + } + __isScrollEffectStarted = true; + } + __moveDistance = distance; + DrawHorizontal(); + Draw(); + __moveDistance = 0; + + + return true; + } + if (!__editMode && distance < 0)//Move left i.e Bounce at RightEnd + { + __isTouchMove = true; + if (__isDirectionRight) + { + if (__pScrollingEffectVe) + { + __pScrollingEffectVe->RemoveAllAnimations(); + __pTab->GetVisualElement()->DetachChild(*__pScrollingEffectVe); + __pScrollingEffectVe->Destroy(); + __pScrollingEffectVe = null; + } + __isScrollEffectEnded = false; + __isScrollEffectStarted = false; + } + __isDirectionRight = false; + SetLastLoadedItemIndex(); + + if ( __lastLoadedItemIndex == (GetItemCount() - 1) && ((GetItemAt(__lastLoadedItemIndex)->GetItemBounds().x + __itemWidth) <= (__width))) + { + if (!__isScrollEffectStarted) + { + int index = (GetItemCount() - 1); + int xPosition = (GetItemAt(index)->GetItemBounds().x + (__itemWidth/2)); + __pScrollingEffectBitmap = __pRearScrollingEffectBitmap; + SetOpacityVisualElement(xPosition); + StartScrollingEffect(); + + } + __isScrollEffectStarted = true; + } + __moveDistance = distance; + DrawHorizontal(); + Draw(); + __moveDistance = 0; + + return true; + } + if (!__editMode) + { + return false; + } + + if (distance > 0) + { + if (!__isDirectionRight) + { + __isTimerCanceled = true; + __isRightScrolable = false; + __isLeftScrolable = false; + CancelReorderTimer(); + } + __isDirectionRight = true; + } + else + { + if (__isDirectionRight) + { + __isTimerCanceled = true; + __isLeftScrolable = false; + __isRightScrolable = false; + CancelReorderTimer(); + } + __isDirectionRight = false; + } + pTabItem = GetItemAt(__editItemIndex); + SysTryReturn(NID_UI_CTRL, pTabItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + Rectangle bounds = pTabItem->GetItemBounds(); + if (index != -1) + { + if (__isDirectionRight) + { + pNextItem = GetItemAt(index); + SysTryReturn(NID_UI_CTRL, pNextItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + Rectangle boundsNext = pNextItem->GetItemBounds(); + if ((bounds.x + (__itemWidth / 2) ) > (boundsNext.x) && ((bounds.x + __itemWidth) < (boundsNext.x + boundsNext.width))) + { + __pTimerInfo[__timerCount]->index = index; + StartReorderTimer(__timerCount); + __timerCount++; + if (__timerCount >= (__itemMaxCount - 1)) + { + __timerCount = 0; + } + __isTimerCanceled = false; + __rearIndex = index; + + } + } + else + { + pPrevItem = GetItemAt(index); + SysTryReturn(NID_UI_CTRL, pPrevItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + Rectangle boundsPrev = pPrevItem->GetItemBounds(); + if ((bounds.x + 100) > (boundsPrev.x + 100) && ((bounds.x + 100) < (boundsPrev.x + boundsPrev.width))) + { + __pTimerInfo[__timerCount]->index = index; + StartReorderTimer(__timerCount); + __timerCount++; + if (__timerCount >= (__itemMaxCount - 1)) + { + __timerCount = 0; + } + __isTimerCanceled = false; + __rearIndex = index; + + } + } + } + else //Scroll the entire tab when item moves beyond boundary + { + if ((bounds.x + __itemWidth) > (__width - (__itemWidth / 2))) + { + if (__isDirectionRight) + { + _TabItem *pLastItem = GetItemAt(__lastItemIndex); + SysTryReturn(NID_UI_CTRL, pLastItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if ((pLastItem->GetItemBounds().x + pLastItem->GetItemBounds().width) > __width) + { + __isRightScrolable = true; + StartScrollAnimationTimer(); + } + } + } + + if (bounds.x < 0) + { + if (!__isDirectionRight) + { + if (GetItemAt(__firstItemIndex)->GetItemBounds().x < __itemWidth) + { + __isLeftScrolable = true; + StartScrollAnimationTimer(); + } + } + } + } + + DrawEditItem(movedPosition); + __pTab->Invalidate(); + + return true; +} + +void +_TabPresenter::ShiftItems(void) +{ + Point pt = Point(0,0); + int itemCount = GetItemCount(); + int fitDistance = 0; + _TabItem* pTabItem = null; + Rectangle bounds(0,0,0,0); + pTabItem = GetItemAt(0); + SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + bounds = pTabItem->GetItemBounds(); + + for (int i = 0; i < itemCount; i++) + { + if (i == __editItemIndex) + { + continue; + } + if (__isRightScrolable) + { + + if (i == __rearIndex + 1) + { + fitDistance = -(2 * __itemWidth); + + } + else + { + fitDistance = -__itemWidth; + } + } + else + { + if (i == __rearIndex - 1) + { + fitDistance = (2 * __itemWidth); + + } + else + { + fitDistance = __itemWidth; + } + } + + pTabItem = GetItemAt(i); + SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + bounds = pTabItem->GetItemBounds(); + bounds.x = bounds.x + fitDistance; + if ( i == __firstItemIndex && ( bounds.x ) >= (2 * __itemWidth)) + { + return; + } + pTabItem->SetItemBounds(bounds); + + } + + if (__isRightScrolable) + { + __rearIndex++; + } + + if (__isLeftScrolable) + { + __rearIndex--; + } + Draw(); + return; +} + +bool +_TabPresenter::OnLongPressGestureDetected(void) +{ + if (!__pTabModel->IsEditModeEnabled()) + { + return true; + } + const int index = GetItemIndexFromPosition(__currentTouchPosition); + + if (index == -1) + { + return false; + } + + if (GetItemStatus(index) == _TABITEM_STATUS_PRESSED && GetSelectedItemIndex() != index) + { + SetItemStatus(index, _TABITEM_STATUS_NORMAL); + } + __editMode = true; + + __editItemIndex = index; + if (__editItemIndex == __firstItemIndex) + { + __firstItemIndex = __firstItemIndex + 1; + } + + if (__editItemIndex == __lastItemIndex) + { + __lastItemIndex = __lastItemIndex - 1; + } + + __rearIndex = index; + __pTab->Invalidate(); + + return true; +} + +bool +_TabPresenter::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) +{ + if (GetItemCount() == 0) + { + return true; + } + + if (__editMode) + { + return true; + } + if (gesture.GetDirection() != _FLICK_DIRECTION_RIGHT && gesture.GetDirection() != _FLICK_DIRECTION_LEFT) + { + return false; + } + int distanceX = 0; + int distanceY = 0; + gesture.GetDistance(distanceX, distanceY); + SetFirstLoadedItemIndex(); + SetLastLoadedItemIndex(); + int xPosition = 0; + int itemsBeyondScreen = 0; + int itemCount = GetItemCount(); + if (distanceX < 0) //left + { + itemsBeyondScreen = (itemCount - 1) - __lastLoadedItemIndex; + xPosition = GetItemAt(__lastLoadedItemIndex)->GetItemBounds().x; + if (xPosition < (3 * __itemWidth)) + { + __flickDistance = xPosition - (4 * __itemWidth); + } + } + else //Right + { + itemsBeyondScreen = __firstLoadedItemIndex; + xPosition = GetItemAt(__firstLoadedItemIndex)->GetItemBounds().x; + if (xPosition < 0) + { + __flickDistance = -xPosition; + } + + } + if (itemsBeyondScreen >= (__itemMaxCount - 1)) + { + __flickDistance = (3 * __itemWidth); + } + else + { + __flickDistance = (itemsBeyondScreen * __itemWidth); + } + if (distanceX < 0) //Left flick + { + __flickMove = 0.006; + __flickFlag = 0; + } + else if (distanceX > 0) //Right flick + { + __flickMove = 0.006; + __flickDistance = -(__flickDistance); + __flickFlag = 0; + } + else + { + __flickMove = 0; + __flickDistance = 0; + __flickFlag = 0; + __moveDistance =0; + } + __isFlickEnabled = true; + + StartFlickAnimationTimer(); + + return true; +} + +void +_TabPresenter::StartFlickAnimation(void) +{ + + float distance = CalculateProgress(__flickMove); + __moveDistance = -(__flickDistance * distance); + + __flickDistance = (__flickDistance + __moveDistance); + __flickMove = __flickMove + 0.006; + __flickFlag++; + if (__flickFlag <= 400) + { + StartFlickAnimationTimer(); + } + else + { + ResetFlickAnimationTimer(); + } + + Draw(); + return; +} + +result +_TabPresenter::StartFlickAnimationTimer(void) +{ + result r = E_SUCCESS; + + if (__pFlickAnimationTimer == null) + { + __pFlickAnimationTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI_CTRL, (__pFlickAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pFlickAnimationTimer->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pFlickAnimationTimer->Cancel(); + } + + r = __pFlickAnimationTimer->Start(FLICK_ANIMATION_TIMER_PERIOD); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + ResetFlickAnimationTimer(); + return r; +} + +result +_TabPresenter::StartScrollAnimationTimer(void) +{ + result r = E_SUCCESS; + ResetReorderTimer(); + if (__pScrollAnimationTimer == null) + { + __pScrollAnimationTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI_CTRL, (__pScrollAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pScrollAnimationTimer->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pScrollAnimationTimer->Cancel(); + } + + r = __pScrollAnimationTimer->Start(SCROLL_ANIMATION_TIMER_PERIOD); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + ResetScrollAnimationTimer(); + return r; +} + +result +_TabPresenter::ResetScrollAnimationTimer(void) +{ + if (__pScrollAnimationTimer) + { + delete __pScrollAnimationTimer; + __pScrollAnimationTimer = null; + } + return E_SUCCESS; +} + +result +_TabPresenter::ResetFlickAnimationTimer(void) +{ + if (__pFlickAnimationTimer) + { + delete __pFlickAnimationTimer; + __pFlickAnimationTimer = null; + } + + __isFlickEnabled = false; + __moveDistance =0; + return E_SUCCESS; +} + +void +_TabPresenter::SetItemFit(int index) +{ + Point pt = Point(0,0); + int itemCount = GetItemCount(); + int fitDistance = 0; + _TabItem* pTabItem = null; + Rectangle bounds(0,0,0,0); + pTabItem = GetItemAt(index); + SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + bounds = pTabItem->GetItemBounds(); + fitDistance = -bounds.x; + for (int i = 0; i < itemCount; i++) + { + pTabItem = GetItemAt(i); + SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + bounds = pTabItem->GetItemBounds(); + bounds.x = bounds.x + fitDistance; + pTabItem->SetItemBounds(bounds); + } + return; +} + +void +_TabPresenter::SetItemFitToLeft(void) +{ + SetItemFit(__firstLoadedItemIndex); + return; +} + +void +_TabPresenter::SetItemFitToRight(void) +{ + SetItemFit(__lastLoadedItemIndex); + return; +} + +void +_TabPresenter::OnTimerExpired(Timer& timer) +{ + if (&timer == __pFlickAnimationTimer) + { + StartFlickAnimation(); + } + for (int i = 0; i < _TIMER_COUNT; i++) + { + + if (!__isTimerCanceled) + { + if (&timer == __pTimerInfo[i]->pReorderTimer) + { + StartReorderAnimation(__pTimerInfo[i]->index, i); + } + } + } + if (&timer == __pScrollAnimationTimer) + { + _TabItem* pLastItem = GetItemAt(__lastItemIndex); + SysTryReturnVoidResult(NID_UI_CTRL, pLastItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if ((GetItemAt(__firstItemIndex)->GetItemBounds().x >= __itemWidth)) + { + __isRightScrolable = false; + __isLeftScrolable = false; + } + if ((pLastItem->GetItemBounds().x + pLastItem->GetItemBounds().width) <= __width && __isDirectionRight) + { + __isRightScrolable = false; + __isLeftScrolable = false; + } + if (__isRightScrolable || __isLeftScrolable) + { + if ((__rearIndex - 1) == __editItemIndex && !__isDirectionRight) + { + if (__isLeftScrolable) + { + __rearIndex--; + } + } + if ((__rearIndex + 1) == __editItemIndex && __isDirectionRight) + { + if (__isRightScrolable) + { + __rearIndex++; + } + } + ShiftItems(); + StartScrollAnimationTimer(); + + } + else + { + ResetScrollAnimationTimer(); + } + } + return; +} + +float +_TabPresenter::CalculateProgress(float timeProgress) const +{ + const float segments[3][3] = {{0.0f, 0.01f, 0.45f}, {0.45f, 0.80f, 0.908f}, {0.908f, 0.9999f, 1.0f}}; + float loc_5 = timeProgress / 1; + int loc_6 = 3; //Length of the segments array + int loc_9 = (int)floor(loc_6 * loc_5); + if (loc_9 >= loc_6) + { + loc_9 = loc_6 - 1; + } + float loc_7 = (loc_5 - loc_9 * (1.0 / loc_6)) * loc_6; + float loc_8[3]; + for (int i = 0; i < 3; i++) + { + loc_8[i] = segments[loc_9][i]; + } + float ret = 0 + 1 * (loc_8[0] + loc_7 * (2 * (1 - loc_7) * (loc_8[1] - loc_8[0]) + loc_7 * (loc_8[2] - loc_8[0]))); + return ret; +} + +result +_TabPresenter::StartReorderTimer(int index) +{ + + result r = E_SUCCESS; + if (__pTimerInfo[index]->pReorderTimer == null) + { + __pTimerInfo[index]->pReorderTimer = new (std::nothrow) Timer; + SysTryReturn(NID_UI_CTRL, (__pTimerInfo[index]->pReorderTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pTimerInfo[index]->pReorderTimer->Construct(*this); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + __pTimerInfo[index]->pReorderTimer->Cancel(); + } + + r = __pTimerInfo[index]->pReorderTimer->Start(REORDER_TIMER_PERIOD); + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + ResetReorderTimer(); + return r; +} + +void +_TabPresenter::FreeHorizontalLineBitmap() +{ + if (__pHorizontalLineBitmap != null) + { + delete __pHorizontalLineBitmap; + __pHorizontalLineBitmap = null; + } + return; +} + + +result +_TabPresenter::CancelReorderTimer() +{ + + for (int index = 0; index < (__pTab->GetItemCount()); index++) + { + if (index < _TIMER_COUNT && __pTimerInfo[index]) + { + if (__pTimerInfo[index]->pReorderTimer) + { + __pTimerInfo[index]->pReorderTimer->Cancel(); + } + } + + __pAnimInfo[index]->totalDistance = __itemWidth; + __pAnimInfo[index]->move = 0.5; + __pAnimInfo[index]->reorderValue =0; + } + return E_SUCCESS; +} + +result +_TabPresenter::ResetReorderTimer(int index) +{ + __pAnimInfo[index]->totalDistance = __itemWidth; + __pAnimInfo[index]->move = 0.5; + __pAnimInfo[index]->reorderValue =0; + + for (int i = 0; i <_TIMER_COUNT; i++) + { + if (__pTimerInfo[i]) + { + if (__pTimerInfo[i]->pReorderTimer) + { + __pTimerInfo[i]->pReorderTimer->Cancel(); + } + } + } + return E_SUCCESS; +} + +result +_TabPresenter::StopReorderTimer() +{ + for (int i = 0 ; i < _TIMER_COUNT; i++) + { + if (__pTimerInfo[i]) + { + delete __pTimerInfo[i]->pReorderTimer; + __pTimerInfo[i]->pReorderTimer = null; + } + } + + return E_SUCCESS; +} + +void +_TabPresenter::StartReorderAnimation(int index, int timerIndex) +{ + + float dist = CalculateProgress(__pAnimInfo[index]->move); + __reorderDist = -(__pAnimInfo[index]->totalDistance * dist); + + __pAnimInfo[index]->move = __pAnimInfo[index]->move + 0.5; + __pAnimInfo[index]->totalDistance = (__pAnimInfo[index]->totalDistance + __reorderDist); + + if (!__isDirectionRight) + { + __reorderDist = -__reorderDist; + } + __pAnimInfo[index]->reorderValue++; + + if (__pAnimInfo[index]->reorderValue <= 50) + { + SwapItems(index, __reorderDist); + StartReorderTimer(timerIndex); + + } + else + { + ResetReorderTimer(index); + } + + + Draw(); + return; + +} + +void +_TabPresenter::SwapItems(int indexDest, int distance) +{ + _TabItem *pItem; + Rectangle itemBounds(0,0,0,0); + pItem = GetItemAt(indexDest); + SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + itemBounds = pItem->GetItemBounds(); + itemBounds.x = itemBounds.x + distance; + SetFirstLoadedItemIndex(); + SetLastLoadedItemIndex(); + int animIndex; + int index; + index = GetNextItemIndexFromPosition(Point(itemBounds.x,itemBounds.y), __editItemIndex); + if (distance < 0) //Moving Left + { + animIndex = indexDest - __lastLoadedItemIndex; + if (__pTab->GetItemCount() >= __itemMaxCount) + { + animIndex = animIndex + (__itemMaxCount - 1); + } + else + { + animIndex = animIndex + (__pTab->GetItemCount() - 1); + } + if ((__lastLoadedItemIndex > __editItemIndex) && (indexDest < __editItemIndex)) + { + animIndex++; + } + if ((itemBounds.x <= __pAnimInfo[animIndex]->xPosition) && (itemBounds.x >= __pAnimInfo[animIndex-1]->xPosition)) + { + if (index == -1 || index == indexDest) //to avoid overlaping of items on each other + { + pItem->SetItemBounds(itemBounds); + } + } + } + if (distance > 0) + { + animIndex = indexDest - __firstLoadedItemIndex; + if ((__firstLoadedItemIndex < __editItemIndex) && (indexDest > __editItemIndex)) + { + animIndex--; + } + if ((itemBounds.x >= __pAnimInfo[animIndex]->xPosition) && (itemBounds.x <= __pAnimInfo[animIndex+1]->xPosition)) + { + if (index == -1 || index == indexDest) + { + pItem->SetItemBounds(itemBounds); + } + } + } + Draw(); + return; + +} + +int +_TabPresenter::GetNextItemIndexFromPosition(const Point& point, int curIndex) const +{ + + Rectangle itemBounds(0, 0, 0, 0); + + int itemIndex = GetFirstDrawnItemIndex(); + + if ((point.x < 0) || (point.x > __pTab->GetBounds().width)) + { + return -1; + } + + _TabItem* pItem = __pTab->GetItemAt(itemIndex); + if (pItem == null) + { + return -1; + } + + while (pItem != null) + { + itemBounds = pItem->GetItemBounds(); + + if ((point.x > itemBounds.x) && (point.x < itemBounds.x + itemBounds.width)) + { + if (curIndex != itemIndex) + return itemIndex; + } + + itemIndex++; + pItem = __pTab->GetItemAt(itemIndex); + if (pItem == null) + { + break; + } + } + + return -1; +} + +void +_TabPresenter::SetFirstLoadedItemIndex() +{ + for (int i = 0; i < __pTab->GetItemCount(); i++) + { + if (__editItemIndex == i) + { + continue; + } + if ((GetItemAt(i)->GetItemBounds().x + 50) <= __itemWidth) + { + __firstLoadedItemIndex = i; + } + } + return; +} + +void +_TabPresenter::SetLastLoadedItemIndex() +{ + for (int i = 0; i < __pTab->GetItemCount(); i++) + { + int X = GetItemAt(i)->GetItemBounds().x; + if (__editItemIndex == i) + { + continue; + } + if ((X + 50) < __width) + { + __lastLoadedItemIndex = i; + } + } + return; +} + +void +_TabPresenter::RefreshAccessibilityElement(void) +{ + if (likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + __pTab->RemoveAllAccessibilityElement(); + + for (int index = 0; index < GetItemCount(); index++) + { + _TabItem* pItem = GetItemAt(index); + + if (pItem != null) + { + __pTab->AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus()); + } + } + + return; +} + + +void +_TabPresenter::OnFontChanged(Font* pFont) +{ + __pFont = pFont; + return; +} + +void +_TabPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = FONT_STYLE_BOLD; + GET_SHAPE_CONFIG(TAB::FONT_SIZE_01, __pTab->GetOrientation(), size); + return; +} + +void +_TabPresenter::OnBoundsChanged() +{ + Rectangle bounds = __pTab->GetBounds(); + if (bounds.width <= __tabMinimumSize) + { + bounds.width = __tabMinimumSize; + } + __pTab->SetBounds(bounds); + SetReCalculateItemBounds(true); + return; +} + + +bool +_TabPresenter::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + if (element.GetBounds().x < 0) + { + SetReCalculateItemBounds(true); + Draw(); + } + + if ((element.GetBounds().x + element.GetBounds().width) > __pTab->GetBounds().width) + { + __moveDistance = (element.GetBounds().width) * (-1); + DrawHorizontal(); + Draw(); + } + + return true; +} + +bool +_TabPresenter::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + if (element.GetBounds().x > (__pTab->GetBounds().x + __pTab->GetBounds().width)) + { + int noOfItems = GetItemCount(); + __moveDistance = (noOfItems - __itemMaxCount) * element.GetBounds().width * (-1); + DrawHorizontal(); + Draw(); + } + + if (element.GetBounds().x < 0) + { + __moveDistance = element.GetBounds().width; + DrawHorizontal(); + Draw(); + } + + return true; +} + +void +_TabPresenter::SetOpacityVisualElement(int xPosition) +{ + Canvas * pCanvas = null; + int bounceWidth = (__itemWidth / 2); + if (__pScrollingEffectVe == null) + { + __pScrollingEffectVe = new (std::nothrow) _VisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, __pScrollingEffectVe, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pScrollingEffectVe->Construct(); + __pScrollingEffectVe->SetName(L"Opacity"); + } + __pScrollingEffectVe->SetBounds(FloatRectangle(xPosition, 0, bounceWidth, __itemHeight)); + __pScrollingEffectVe->SetShowState(true); + __pScrollingEffectVe->SetImplicitAnimationEnabled(true); + __pTab->GetVisualElement()->AttachChild(*__pScrollingEffectVe); + pCanvas = __pScrollingEffectVe->GetCanvasN(); + if (!pCanvas) + { + __pScrollingEffectVe->Destroy(); + __pScrollingEffectVe = null; + + SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + return; + } + Color backgroundColor(0,0,0,0); + pCanvas->SetBackgroundColor(backgroundColor); + pCanvas->Clear(); + Rectangle rect(0, 0, bounceWidth, __itemHeight); + + DrawResourceBitmap(*pCanvas, rect, __pScrollingEffectBitmap); + + delete pCanvas; + return; +} + +void +_TabPresenter::StartScrollingEffect(void) +{ + float __startOpacity = 0.0f; + float __endOpacity = 1.0f; + VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturnVoidResult(NID_UI_CTRL, pAnimation, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pAnimation->SetPropertyName(L"opacity"); + pAnimation->SetStartValue(Variant(__startOpacity)); + pAnimation->SetEndValue(Variant(__endOpacity)); + pAnimation->SetDuration(500); + pAnimation->SetVisualElementAnimationStatusEventListener(this); + + String animationName3(L"opacity"); + __pScrollingEffectVe->AddAnimation(animationName3, *pAnimation); + + delete pAnimation; + __isScrollEffectStarted = true; + return; + +} + +void +_TabPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target) +{ + return; +} + +void +_TabPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount) +{ + return; +} + +void +_TabPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally) +{ + + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TableView.cpp b/src/ui/controls/FUiCtrl_TableView.cpp new file mode 100644 index 0000000..c189ceb --- /dev/null +++ b/src/ui/controls/FUiCtrl_TableView.cpp @@ -0,0 +1,1150 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableView.cpp + * @brief This file implements the _TableView class. + * @version 3.0 + */ + +#include +#include "FUi_ControlManager.h" +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_ListViewModel.h" +#include "FUiCtrl_FastScroll.h" +#include "FUiCtrl_Scroll.h" +#include "FUiCtrl_TableView.h" +#include "FUiCtrl_TableViewPresenter.h" +#include "FUiCtrl_TableViewItem.h" +#include "FUiCtrl_TableViewItemProvider.h" +#include "FUiCtrl_TableViewItemProviderAdaptor.h" +#include "FUiCtrl_UiTableViewItemEvent.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_TableView); + +_TableView::_TableView(void) + : __pTableViewPresenter(null) + , __pFastScroll(null) + , __pTableViewItemEvent(null) + , __itemDividerEnabled(false) + , __sweepEnabled(false) + , __reorderEnabled(false) + , __sectionStyle(false) + , __groupedLookEnable(false) + , __tableViewStyle(TABLE_VIEW_STYLE_SIMPLE) + , __scrollStyle(TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT) + , __pBitmapOfEmptyTableView(null) + , __pBackgroundBitmap(null) + , __textOfEmptyTableView(L"Empty TableView") +{ + Color bgColor; + + GET_COLOR_CONFIG(TABLEVIEW::BG_NORMAL, bgColor); + GET_COLOR_CONFIG(TABLEVIEW::SECTIONITEM_BG_NORMAL, __sectionStyleColor); + GET_COLOR_CONFIG(TABLEVIEW::ITEM_DIVIDER_BOTTOM_BG_NORMAL, __itemDividerColor); + + SetBackgroundColor(bgColor); +} + +_TableView::~_TableView(void) +{ + GetVisualElement()->RemoveAllAnimations(); + + __pTableViewPresenter = null; + + if (__pFastScroll != null) + { + DetachSystemChild(*__pFastScroll); + + delete __pFastScroll; + __pFastScroll = null; + } + + delete __pTableViewItemEvent; + __pTableViewItemEvent = null; +} + +_TableView* +_TableView::CreateTableViewN(TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _TableView* pTableView = null; + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturn(NID_UI_CTRL, pControlManager, null, E_SYSTEM, "[E_SYSTEM] System error occurred."); + + pTableView = new (std::nothrow) _TableView; + SysTryCatch(NID_UI_CTRL, pTableView != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] Propagating", GetErrorMessage(r)); + + pTableView->AcquireHandle(); + + r = pTableView->Initialize(style, itemDivider, scrollStyle); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Failed to Initialize", GetErrorMessage(r)); + + return pTableView; + +CATCH: + delete pTableView; + return null; +} + +result +_TableView::Initialize(TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle) +{ + result r = E_SUCCESS; + + _TableViewPresenter* pPresenter = new (std::nothrow) _TableViewPresenter(); + SysTryReturn(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + r = pPresenter->Construct(this); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = _ScrollPanel::Initialize(*pPresenter); + SetTableViewPresenter(pPresenter); + SetScrollAreaAutoResizingEnabled(false); + + Rectangle rect = GetBounds(); + SetScrollAreaBounds(rect); + + SetTableViewStyle(style); + SetScrollStyle(scrollStyle); + SetItemDividerEnabled(itemDivider); + + return r; +} + +_TableViewPresenter* +_TableView::GetTableViewPresenter(void) const +{ + return __pTableViewPresenter; +} + +void +_TableView::SetTableViewPresenter(const _TableViewPresenter* pPresenter) +{ + _ScrollPanel::SetScrollPanelPresenter(pPresenter); + + __pTableViewPresenter = const_cast<_TableViewPresenter*>(pPresenter); +} + +result +_TableView::SetItemProvider(const _TableViewItemProvider* pProvider) +{ + return __pTableViewPresenter->SetItemProvider(pProvider); +} + +void +_TableView::SetItemProviderAdaptor(_TableViewItemProviderAdaptor* pProviderAdaptor) +{ + __pTableViewPresenter->SetTableViewItemProviderAdaptor(pProviderAdaptor); +} + +_TableViewItemProviderAdaptor* +_TableView::GetItemProviderAdaptor(void) const +{ + return __pTableViewPresenter->GetTableViewItemProviderAdaptor(); +} + +void +_TableView::SetSweepEnabled(bool enable) +{ + __sweepEnabled = enable; +} + +bool +_TableView::IsSweepEnabled(void) const +{ + return __sweepEnabled; +} + +bool +_TableView::IsReorderModeEnabled(void) const +{ + return __reorderEnabled; +} + +result +_TableView::SetReorderModeEnabled(bool enable) +{ + if (__reorderEnabled != enable) + { + __reorderEnabled = enable; + + __pTableViewPresenter->SetReorderMode(enable); + } + + return E_SUCCESS; +} + +result +_TableView::SetItemChecked(int groupIndex, int itemIndex, bool check) +{ + if (IsOnProcessing()) + { + return E_INVALID_OPERATION; + } + return __pTableViewPresenter->SetItemChecked(groupIndex, itemIndex, check); +} + +bool +_TableView::IsItemChecked(int groupIndex, int itemIndex) const +{ + return __pTableViewPresenter->IsItemChecked(groupIndex, itemIndex); +} + +result +_TableView::SetItemEnabled(int groupIndex, int itemIndex, bool enable) +{ + if (IsOnProcessing()) + { + return E_INVALID_OPERATION; + } + return __pTableViewPresenter->SetItemEnabled(groupIndex, itemIndex, enable); +} + +void +_TableView::CheckItemHeightAndRefreshLayout(int groupIndex, int itemIndex) +{ + TableViewItemTag itemTag = {groupIndex, itemIndex}; + __pTableViewPresenter->CheckItemHeightAndRefreshLayout(itemTag, true); +} + +_TableViewItem* +_TableView::FindItem(int groupIndex, int itemIndex) const +{ + TableViewItemTag itemTag = {groupIndex, itemIndex}; + + return __pTableViewPresenter->FindItem(itemTag); +} + +void +_TableView::UnloadItem(int groupIndex, int itemIndex) +{ + if (IsOnProcessing()) + { + return; + } + return __pTableViewPresenter->UnloadItem(groupIndex, itemIndex); +} + +_TableViewItem* +_TableView::LoadItem(int groupIndex, int itemIndex) +{ + if (IsOnProcessing()) + { + return null; + } + return __pTableViewPresenter->LoadItem(groupIndex, itemIndex); +} + +void +_TableView::RefreshItemLayout(int groupIndex, int itemIndex) +{ + __pTableViewPresenter->RefreshItemLayout(groupIndex, itemIndex); +} + +void +_TableView::GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const +{ + __pTableViewPresenter->GetFirstLoadedItemIndex(groupIndex, itemIndex); +} + +void +_TableView::GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const +{ + __pTableViewPresenter->GetLastLoadedItemIndex(groupIndex, itemIndex); +} + +void +_TableView::ResetSweepItem(void) +{ + __pTableViewPresenter->ResetSweepItem(); +} + +int +_TableView::GetPressedItemCount(void) +{ + return __pTableViewPresenter->GetPressedItemCount(); +} + +int +_TableView::GetTopMargin(void) const +{ + return __pTableViewPresenter->GetTopMargin(); +} + +result +_TableView::SetTopMargin(int topMargin) +{ + return __pTableViewPresenter->SetTopMargin(topMargin); +} + +int +_TableView::GetBottomMargin(void) const +{ + return __pTableViewPresenter->GetBottomMargin(); +} + +result +_TableView::SetBottomMargin(int bottomMargin) +{ + return __pTableViewPresenter->SetBottomMargin(bottomMargin); +} + +bool +_TableView::IsItemEnabled(int groupIndex, int itemIndex) const +{ + return __pTableViewPresenter->IsItemEnabled(groupIndex, itemIndex); +} + +result +_TableView::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + groupIndex = -1; + itemIndex = -1; + + return __pTableViewPresenter->GetTopDrawnItemIndex(groupIndex, itemIndex); +} + +result +_TableView::SetTopDrawnItemIndex(int groupIndex, int itemIndex) +{ + if (IsOnProcessing()) + { + return E_INVALID_OPERATION; + } + return __pTableViewPresenter->SetTopDrawnItemIndex(groupIndex, itemIndex); +} + +result +_TableView::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + groupIndex = -1; + itemIndex = -1; + + return __pTableViewPresenter->GetBottomDrawnItemIndex(groupIndex, itemIndex); +} + +result +_TableView::SetBottomDrawnItemIndex(int groupIndex, int itemIndex) +{ + if (IsOnProcessing()) + { + return E_INVALID_OPERATION; + } + return __pTableViewPresenter->SetBottomDrawnItemIndex(groupIndex, itemIndex); +} + +result +_TableView::ScrollByPixel(int scrollDistance) +{ + return __pTableViewPresenter->ScrollByPixel(scrollDistance); +} + +void +_TableView::SetScrollEnabled(bool enable) +{ + __pTableViewPresenter->SetScrollEnabled(enable); +} + +bool +_TableView::IsScrollEnabled(void) const +{ + return __pTableViewPresenter->IsScrollEnabled(); +} + +result +_TableView::AddTableViewItemEventListener(const _ITableViewItemEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pTableViewItemEvent == null) + { + __pTableViewItemEvent = new (std::nothrow) _UiTableViewItemEvent(); + SysTryReturn(NID_UI_CTRL, __pTableViewItemEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pTableViewItemEvent->Construct(this, TABLE_VIEW_STYLE_SIMPLE); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to construct Item Event."); + } + + r = __pTableViewItemEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return E_SUCCESS; +} + +result +_TableView::RemoveTableViewItemEventListener(const _ITableViewItemEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pTableViewItemEvent != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This instance isn't constructed."); + + return __pTableViewItemEvent->RemoveListener(listener); +} + +result +_TableView::AddGroupedTableViewItemEventListener(const _ITableViewItemEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pTableViewItemEvent == null) + { + __pTableViewItemEvent = new (std::nothrow) _UiTableViewItemEvent(); + SysTryReturn(NID_UI_CTRL, __pTableViewItemEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pTableViewItemEvent->Construct(this, TABLE_VIEW_STYLE_GROUPED); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to construct Item Event."); + } + + r = __pTableViewItemEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return E_SUCCESS; +} + +result +_TableView::RemoveGroupedTableViewItemEventListener(const _ITableViewItemEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pTableViewItemEvent != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This instance isn't constructed."); + + return __pTableViewItemEvent->RemoveListener(listener); +} + +result +_TableView::AddSectionTableViewItemEventListener(const _ITableViewItemEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pTableViewItemEvent == null) + { + __pTableViewItemEvent = new (std::nothrow) _UiTableViewItemEvent(); + SysTryReturn(NID_UI_CTRL, __pTableViewItemEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pTableViewItemEvent->Construct(this, TABLE_VIEW_STYLE_SECTION); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to construct Item Event."); + } + + r = __pTableViewItemEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return E_SUCCESS; +} + +result +_TableView::RemoveSectionTableViewItemEventListener(const _ITableViewItemEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pTableViewItemEvent != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This instance isn't constructed."); + + return __pTableViewItemEvent->RemoveListener(listener); +} + +result +_TableView::AddFastScrollListener(const _IUiFastScrollListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pFastScroll != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This instance isn't constructed."); + __pFastScroll->AddFastScrollEventListener(listener); + + return E_SUCCESS; +} + +result +_TableView::RemoveFastScrollListener(const _IUiFastScrollListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pFastScroll != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This instance isn't constructed."); + __pFastScroll->RemoveFastScrollEventListener(listener); + + return E_SUCCESS; +} + +_FastScroll* +_TableView::GetFastScrollBar(void) const +{ + return __pFastScroll; +} + +result +_TableView::SetFastScrollIndex(const String& text, bool useSearchIcon) +{ + SysTryReturn(NID_UI_CTRL, __scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView scroll is not TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL"); + SysTryReturn(NID_UI_CTRL, __pFastScroll != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] This instance isn't constructed."); + result r = E_SUCCESS; + + const wchar_t* pIndexTextArray = text.GetPointer(); + int indexLenth = 1; + int indexCount = text.GetLength(); + int childOrder = 0; + + // Set the primary index. + _FastScrollIndex* pRootIndex = __pFastScroll->GetIndex(); + if (pRootIndex == null) + { + pRootIndex = _FastScrollIndex::CreateFastScrollIndexN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pRootIndex != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pFastScroll->SetIndex(pRootIndex); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + pRootIndex->RemoveChildren(true); + } + + if (useSearchIcon == true) + { + Bitmap* pSearchIcon = null; + String fastScrollSearchIconIndex(L"[SEARCH_ICON_INDEX]"); + + r = GET_BITMAP_CONFIG_N(TABLEVIEW::SEARCH_ICON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSearchIcon); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] SearchIcon image load failed"); + + r = pRootIndex->AddChildIndex(&fastScrollSearchIconIndex, pSearchIcon); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Failed to add text array to the primary index."); + + childOrder++; + } + + r = pRootIndex->AddChildTextIndexArray(childOrder, pIndexTextArray, indexLenth, indexCount); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pFastScroll->UpdateIndex(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return E_SUCCESS; +} + +result +_TableView::SetScrollStyle(TableViewScrollBarStyle scrollStyle) +{ + __scrollStyle = scrollStyle; + + return E_SUCCESS; +} + +TableViewStyle +_TableView::GetTableViewStyle(void) const +{ + return __tableViewStyle; +} + +void +_TableView::SetTableViewStyle(TableViewStyle style) +{ + __tableViewStyle = style; + + if (__tableViewStyle == TABLE_VIEW_STYLE_SECTION) + { + int topMargin = 0; + GET_FIXED_VALUE_CONFIG(TABLEVIEW::SECTIONITEM_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, topMargin); + SetTopMargin(topMargin); + + int x = 0; + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, x); + __pTableViewPresenter->SetLeftMargin(x); + + __groupedLookEnable = true; + } +} + +TableViewScrollBarStyle +_TableView::GetScrollStyle(void) const +{ + return __scrollStyle; +} + +int +_TableView::GetGroupCount(void) const +{ + return __pTableViewPresenter->GetGroupCount(); +} + +int +_TableView::GetItemCountAt(int groupIndex) const +{ + SysTryReturn(NID_UI_CTRL, groupIndex >= 0 && groupIndex < GetGroupCount(), -1, E_INVALID_ARG, "[E_INVALID_ARG] Invalid group index."); + + int itemCount = __pTableViewPresenter->GetItemCountAt(groupIndex); + + if (GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION) + { + // sub section footer + if (__pTableViewPresenter->HasSectionFooter(groupIndex) == true) + { + itemCount--; + if (itemCount < 0) + { + itemCount = 0; + } + } + } + + return itemCount; +} + +result +_TableView::RefreshTableView(int groupIndex, int itemIndex, TableViewRefreshType type, bool animation) +{ + if (IsOnProcessing()) + { + return E_INVALID_OPERATION; + } + return __pTableViewPresenter->RefreshTableView(groupIndex, itemIndex, type, animation); +} + +result +_TableView::UpdateTableView(void) +{ + if (IsOnProcessing()) + { + return E_INVALID_OPERATION; + } + return __pTableViewPresenter->UpdateTableView(); +} + +result +_TableView::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const +{ + return __pTableViewPresenter->GetItemIndexFromPosition(position, groupIndex, itemIndex); +} + +result +_TableView::SetPropertySectionColor(const Variant& sectionColor) +{ + __sectionStyleColor = sectionColor.ToColor(); + + return E_SUCCESS; +} + +result +_TableView::SetSectionColor(const Color& color) +{ + if (GetTableViewStyle() != TABLE_VIEW_STYLE_SECTION) + { + SysLog(NID_UI_CTRL, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SECTION."); + return E_INVALID_OPERATION; + } + + if (__sectionStyleColor == color) + { + return E_SUCCESS; + } + + result r = SetProperty("sectionColor", Variant(color)); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pTableViewPresenter->SetStatusChanged(true); +} + +Variant +_TableView::GetPropertySectionColor(void) const +{ + return Variant(__sectionStyleColor); +} + +Color +_TableView::GetSectionColor(void) const +{ + if (GetTableViewStyle() != TABLE_VIEW_STYLE_SECTION) + { + SetLastResult(E_SUCCESS); + return Color(0); + } + + Variant sectionColor = GetProperty("sectionColor"); + + return sectionColor.ToColor(); +} + +Variant +_TableView::GetPropertyItemDividerColor(void) const +{ + return Variant(__itemDividerColor); +} + +Color +_TableView::GetItemDividerColor(void) const +{ + Variant itemDividerColor = GetProperty("itemDividerColor"); + + return itemDividerColor.ToColor(); +} + +result +_TableView::SetPropertyItemDividerColor(const Variant& itemDividerColor) +{ + __itemDividerColor = itemDividerColor.ToColor(); + + return E_SUCCESS; +} + +result +_TableView::SetItemDividerColor(const Color& color) +{ + return SetProperty("itemDividerColor", Variant(color)); +} + +bool +_TableView::IsItemDividerEnabled(void) const +{ + return __itemDividerEnabled; +} + +void +_TableView::SetItemDividerEnabled(bool enable) +{ + __itemDividerEnabled = enable; +} + +Bitmap* +_TableView::GetBitmapOfEmptyTableView(void) const +{ + return __pBitmapOfEmptyTableView; +} + +result +_TableView::SetBitmapOfEmptyTableView(const Bitmap* pBitmap) +{ + Bitmap* pCloneBitmap = null; + + if (pBitmap == null) + { + delete __pBitmapOfEmptyTableView; + __pBitmapOfEmptyTableView = null; + + return E_SUCCESS; + } + else + { + pCloneBitmap = _BitmapImpl::CloneN(*pBitmap); + SysTryReturn(NID_UI_CTRL, pCloneBitmap != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + delete __pBitmapOfEmptyTableView; + __pBitmapOfEmptyTableView = pCloneBitmap; + } + + return __pTableViewPresenter->SetStatusChanged(true); +} + +Variant +_TableView::GetPropertyTextColorOfEmptyTableView(void) const +{ + return Variant(__textColorOfEmptyTableView); +} + +Color +_TableView::GetTextColorOfEmptyTableView(void) const +{ + Variant textColorOfEmptyTableView = GetProperty("textColorOfEmptyTableView"); + + return textColorOfEmptyTableView.ToColor(); +} + +result +_TableView::SetPropertyTextColorOfEmptyTableView(const Variant& textColorOfEmptyTableView) +{ + __textColorOfEmptyTableView = textColorOfEmptyTableView.ToColor(); + + return E_SUCCESS; +} + +result +_TableView::SetTextColorOfEmptyTableView(const Color& color) +{ + if (__textColorOfEmptyTableView == color) + { + return E_SUCCESS; + } + + result r = SetProperty("textColorOfEmptyTableView", Variant(color)); + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pTableViewPresenter->SetStatusChanged(true); +} + +Variant +_TableView::GetPropertyTextOfEmptyTableView(void) const +{ + return Variant(__textOfEmptyTableView); +} + +String +_TableView::GetTextOfEmptyTableView(void) const +{ + Variant textOfEmptyTableView = GetProperty("textOfEmptyTableView"); + + return textOfEmptyTableView.ToString(); +} + +result +_TableView::SetPropertyTextOfEmptyTableView(const Variant& textOfEmptyTableView) +{ + __textOfEmptyTableView = textOfEmptyTableView.ToString(); + + return E_SUCCESS; +} + +result +_TableView::SetTextOfEmptyTableView(const String& text) +{ + if (__textOfEmptyTableView == text) + { + return E_SUCCESS; + } + + result r = SetProperty("textOfEmptyTableView", Variant(text)); + + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return __pTableViewPresenter->SetStatusChanged(true); +} + +void +_TableView::FireTableViewItemEvent(int groupIndex, int itemIndex, TableViewNotifyType type, _TableViewItem* pItem) +{ + if (type == TABLEVIEW_NOTIFY_TYPE_ANNEX_CHECK) + { + __pTableViewPresenter->GetModel()->SetItemChecked(groupIndex, itemIndex, true); + } + else if (type == TABLEVIEW_NOTIFY_TYPE_ANNEX_UNCHECK) + { + __pTableViewPresenter->GetModel()->SetItemChecked(groupIndex, itemIndex, false); + } + + if (__pTableViewItemEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndex, itemIndex, 0, 0, pItem, type); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewItemEvent->Fire(*pArg); + } +} + +void +_TableView::FireTableViewItemSweepEvent(int groupIndex, int itemIndex, TableViewSweepDirection directioin) +{ + if (__pTableViewItemEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndex, itemIndex, directioin, 0, null, TABLEVIEW_NOTIFY_TYPE_ITEM_SWEPT); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewItemEvent->Fire(*pArg); + } +} + +void +_TableView::FireTableViewItemReorderEvent(int fromItemIndex, int toItemIndex) +{ + if (__pTableViewItemEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(fromItemIndex, toItemIndex, 0, 0, null, TABLEVIEW_NOTIFY_TYPE_REORDERED_ITEM); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewItemEvent->Fire(*pArg); + } +} +void +_TableView::FireTableViewItemReorderEvent(int fromGroupIndex, int fromItemIndex, int toGroupIndex, int toItemIndex) +{ + if (__pTableViewItemEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(fromGroupIndex, fromItemIndex, toGroupIndex, toItemIndex, null, TABLEVIEW_NOTIFY_TYPE_REORDERED_ITEM); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewItemEvent->Fire(*pArg); + } +} + +void +_TableView::FireTableViewContextItemActivationEvent(int groupIndex, int itemIndex, _TableViewItem* pItem, bool activated) +{ + if (__pTableViewItemEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndex, itemIndex, 0, 0, pItem, TABLEVIEW_NOTIFY_TYPE_CONTEXT_ITEM_ACTIVATION, activated); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewItemEvent->Fire(*pArg); + } +} + +result +_TableView::ExpandGroup(int groupIndex) +{ + if (IsOnProcessing()) + { + return E_INVALID_OPERATION; + } + return __pTableViewPresenter->ExpandGroup(groupIndex, true); +} + +result +_TableView::CollapseGroup(int groupIndex) +{ + if (IsOnProcessing()) + { + return E_INVALID_OPERATION; + } + return __pTableViewPresenter->CollapseGroup(groupIndex, true); +} + +bool +_TableView::IsGroupExpanded(int groupIndex) const +{ + return __pTableViewPresenter->IsGroupExpanded(groupIndex); +} + +result +_TableView::ExpandAllGroup(bool animation) +{ + if (IsOnProcessing()) + { + return E_INVALID_OPERATION; + } + + int groupCount = GetGroupCount(); + + for (int i = 0; i < groupCount; i++) + { + __pTableViewPresenter->ExpandGroup(i, false); + } + + return E_SUCCESS; +} + +result +_TableView::CollapseAllGroup(bool animation) +{ + if (IsOnProcessing()) + { + return E_INVALID_OPERATION; + } + + int groupCount = GetGroupCount(); + + for (int i = 0; i < groupCount; i++) + { + __pTableViewPresenter->CollapseGroup(i, false); + } + + return E_SUCCESS; +} + +void +_TableView::SetGroupedLookEnabled(bool enable) +{ + __groupedLookEnable = enable; + + if (__tableViewStyle == TABLE_VIEW_STYLE_SECTION && !__groupedLookEnable) + { + __pTableViewPresenter->SetLeftMargin(0); + } +} + +bool +_TableView::IsGroupedLookEnabled(void) const +{ + return __groupedLookEnable; +} + +bool +_TableView::GetFirstDrawnFlag(void) const +{ + return __pTableViewPresenter->GetFirstDrawnFlag(); +} + +int +_TableView::GetMaxItemCachingSize(void) const +{ + return __pTableViewPresenter->GetMaxItemCachingSize(); +} + +void +_TableView::OnDraw(void) +{ + __pTableViewPresenter->Draw(); +} + +void +_TableView::OnChildAttached(const _Control& child) +{ + _ScrollPanel::OnChildAttached(child); +} + +void +_TableView::OnChildDetached(const _Control& child) +{ + _ScrollPanel::OnChildDetached(child); +} + +void +_TableView::OnBoundsChanged(void) +{ + if (__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL || __scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_NONE) + { + _Scroll* pScroll = _ScrollPanel::GetScrollBar(); + if (pScroll == null) + { + Rectangle bounds = GetBounds(); + + pScroll = _Scroll::CreateScrollN(*this, + SCROLL_DIRECTION_VERTICAL, + false, + false, + false, + false, + bounds.height, + bounds.height, + 0); + SysTryReturnVoidResult(NID_UI_CTRL, pScroll != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pScroll->EnableScrollingEffect(false); + pScroll->SetVisibleState(false); + _ScrollPanel::SetScrollBar(pScroll); + + pScroll->AddScrollEventListener(*this); + AttachSystemChild(*pScroll); + } + + if (__pFastScroll == null && __scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL) + { + __pFastScroll = _FastScroll::CreateFastScrollN(*this); + if (__pFastScroll != null) + { + AttachSystemChild(*__pFastScroll); + } + } + } + else + { + _Scroll* pScroll = _ScrollPanel::GetScrollBar(); + + if (pScroll == null) + { + Rectangle bounds = GetBounds(); + + pScroll = _Scroll::CreateScrollN(*this, + SCROLL_DIRECTION_VERTICAL, + ((__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FIXED) ? false : true), + ((__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP) ? true : false), + ((__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_THUMB) ? true : false), + ((__scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FIXED) ? true : false), + bounds.height, + bounds.height, + 0); + SysTryReturnVoidResult(NID_UI_CTRL, pScroll != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pScroll->EnableScrollingEffect(true); + _ScrollPanel::SetScrollBar(pScroll); + + pScroll->AddScrollEventListener(*this); + AttachSystemChild(*pScroll); + } + } + + _ScrollPanel::OnBoundsChanged(); +} + +_UiTouchEventDelivery +_TableView::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pTableViewPresenter->OnPreviewTouchPressed(source, touchinfo); +} + +_UiTouchEventDelivery +_TableView::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pTableViewPresenter->OnPreviewTouchMoved(source, touchinfo); +} + +_UiTouchEventDelivery +_TableView::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pTableViewPresenter->OnPreviewTouchReleased(source, touchinfo); +} + +_UiTouchEventDelivery +_TableView::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pTableViewPresenter->OnPreviewTouchCanceled(source, touchinfo); +} + +bool +_TableView::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pTableViewPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_TableView::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pTableViewPresenter->OnTouchMoved(source, touchinfo); +} + +bool +_TableView::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pTableViewPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_TableView::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + return __pTableViewPresenter->OnTouchCanceled(source, touchinfo); +} + +bool +_TableView::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) +{ + return __pTableViewPresenter->OnFlickGestureDetected(gesture); +} + +bool +_TableView::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture) +{ + return __pTableViewPresenter->OnFlickGestureCanceled(gesture); +} + +result +_TableView::SetTableViewStatusChanged(bool changed) +{ + return __pTableViewPresenter->SetStatusChanged(changed); +} + +bool +_TableView::IsOnProcessing(void) +{ + _TableViewItemProviderAdaptor* pProviderAdapter = __pTableViewPresenter->GetTableViewItemProviderAdaptor(); + if (pProviderAdapter != null) + { + if (pProviderAdapter->IsOnProcessing()) + { + return true; + } + } + + return false; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TableViewImpl.cpp b/src/ui/controls/FUiCtrl_TableViewImpl.cpp new file mode 100644 index 0000000..c436fd8 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TableViewImpl.cpp @@ -0,0 +1,1385 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_TableViewImpl.cpp +* @brief This file contains implementation of _TableViewImpl class +*/ + +#include +#include +#include +#include +#include +#include +#include +#include "FUiCtrl_TableViewImpl.h" +#include "FUiCtrl_TableViewItemEventArg.h" +#include "FUiCtrl_TableViewItemProvider.h" +#include "FUiCtrlTableViewItem.h" +#include "FUiCtrlTableViewGroupItem.h" +#include "FUiCtrlTableViewContextItem.h" +#include "FUiCtrl_FastScrollEvent.h" +#include "FUiCtrl_FastScrollEventArg.h" +#include "FUiCtrl_ScrollEvent.h" +#include "FUiCtrl_ScrollEventArg.h" +#include "FUi_UiBuilder.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Tizen::Graphics::Dimension +_TableViewImpl::TableViewSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + result r = E_SUCCESS; + Tizen::Graphics::Dimension dimension(0, 0); + r = GET_DIMENSION_CONFIG(TABLEVIEW::MIN_SIZE, orientation, dimension); + SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] System Error", GetErrorMessage(r)); + return dimension; +} + +_TableViewImpl* +_TableViewImpl::GetInstance(TableView& tableView) +{ + return static_cast <_TableViewImpl*>(tableView._pControlImpl); +} + +const _TableViewImpl* +_TableViewImpl::GetInstance(const TableView& tableView) +{ + return static_cast (tableView._pControlImpl); +} + + +_TableViewImpl* +_TableViewImpl::GetInstance(GroupedTableView& tableView) +{ + return static_cast <_TableViewImpl*>(tableView._pControlImpl); +} + +const _TableViewImpl* +_TableViewImpl::GetInstance(const GroupedTableView& tableView) +{ + return static_cast (tableView._pControlImpl); +} + + +_TableViewImpl* +_TableViewImpl::GetInstance(SectionTableView& tableView) +{ + return static_cast <_TableViewImpl*>(tableView._pControlImpl); +} + +const _TableViewImpl* +_TableViewImpl::GetInstance(const SectionTableView& tableView) +{ + return static_cast (tableView._pControlImpl); +} + +_TableViewImpl::_TableViewImpl(Container* pTableView, _TableView* pCore) + : _ContainerImpl(pTableView, pCore) + , __pTableViewEvent(null) + , __pScrollEvent(null) + , __pFastScrollEvent(null) + , __useSearchIcon(false) + , __tableViewPublic() +{ +} + +_TableViewImpl::~_TableViewImpl() +{ + if (__pScrollEvent != null) + { + delete __pScrollEvent; + __pScrollEvent = null; + } + + if (__pFastScrollEvent != null) + { + delete __pFastScrollEvent; + __pFastScrollEvent = null; + } + + if (__pTableViewEvent != null) + { + delete __pTableViewEvent; + __pTableViewEvent = null; + } +} + +const char* +_TableViewImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::TableView"; +} + +const _TableView& +_TableViewImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_TableView& +_TableViewImpl::GetCore(void) +{ + return static_cast <_TableView&>(_ControlImpl::GetCore()); +} + +_TableViewImpl* +_TableViewImpl::CreateTableViewImplN(Container* pPublic, Rectangle bounds, TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle) +{ + result r = E_SUCCESS; + ClearLastResult(); + + r = GET_SIZE_INFO(TableView).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _TableView* pCore = _TableView::CreateTableViewN(style, itemDivider, scrollStyle); + SysTryReturn(NID_UI_CTRL, pCore, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _TableViewImpl* pImpl = new (std::nothrow) _TableViewImpl(pPublic, pCore); + SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pImpl->SetPublic(style, pPublic); + + SetLastResult(r); + + return pImpl; + +CATCH: + delete pCore; + + return null; +} + +_TableViewImpl* +_TableViewImpl::CreateTableViewImplN(TableView* pPublic, Tizen::Graphics::Rectangle bounds, TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle) +{ + return _TableViewImpl::CreateTableViewImplN(static_cast(pPublic), bounds, style, itemDivider, scrollStyle); +} +_TableViewImpl* +_TableViewImpl::CreateGroupedTableViewImplN(GroupedTableView* pPublic, Tizen::Graphics::Rectangle bounds, TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle) +{ + return _TableViewImpl::CreateTableViewImplN(static_cast(pPublic), bounds, style, itemDivider, scrollStyle); +} +_TableViewImpl* +_TableViewImpl::CreateSectionTableViewImplN(SectionTableView* pPublic, Tizen::Graphics::Rectangle bounds, TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle) +{ + return _TableViewImpl::CreateTableViewImplN(static_cast(pPublic), bounds, style, itemDivider, scrollStyle); +} + + +void +_TableViewImpl::SetPublic(TableViewStyle style, Container *pPublic) +{ + __tableViewPublic.style = style; + + if (style == TABLE_VIEW_STYLE_SIMPLE) + { + __tableViewPublic.pTableView = static_cast (pPublic); + } + else if (style == TABLE_VIEW_STYLE_GROUPED) + { + __tableViewPublic.pGroupedTableView = static_cast (pPublic); + } + else + { + __tableViewPublic.pSectionTableView = static_cast (pPublic); + } +} + + +result +_TableViewImpl::SetSimpleStyleItemProvider(ITableViewItemProvider* pProvider) +{ + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryReturn(NID_UI_CTRL, style == TABLE_VIEW_STYLE_SIMPLE, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SIMPLE"); + + _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style); + SysTryReturn(NID_UI_CTRL, pItemProvider != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = pItemProvider->SetSimpleStyleItemProvider(pProvider); + if (r != E_SUCCESS) + { + delete pItemProvider; + SysTryReturn(NID_UI_CTRL, false, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return GetCore().SetItemProvider(pItemProvider); +} + +result +_TableViewImpl::SetGroupedStyleItemProvider(IGroupedTableViewItemProvider* pProvider) +{ + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryReturn(NID_UI_CTRL, style == TABLE_VIEW_STYLE_GROUPED, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_GROUPED"); + + _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style); + SysTryReturn(NID_UI_CTRL, pItemProvider != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = pItemProvider->SetGroupedStyleItemProvider(pProvider); + if (r != E_SUCCESS) + { + delete pItemProvider; + SysTryReturn(NID_UI_CTRL, false, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return GetCore().SetItemProvider(pItemProvider); +} +// +result +_TableViewImpl::SetSectionStyleItemProvider(ISectionTableViewItemProvider* pProvider) +{ + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryReturn(NID_UI_CTRL, style == TABLE_VIEW_STYLE_SECTION, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SECTION"); + + _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style); + SysTryReturn(NID_UI_CTRL, pItemProvider != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = pItemProvider->SetSectionStyleItemProvider(pProvider); + if (r != E_SUCCESS) + { + delete pItemProvider; + SysTryReturn(NID_UI_CTRL, false, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return GetCore().SetItemProvider(pItemProvider); +} + +result +_TableViewImpl::AddTableViewItemEventListener(ITableViewItemEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pTableViewEvent == null) + { + __pTableViewEvent = new (std::nothrow) _TableViewItemEvent(); + SysTryReturn(NID_UI_CTRL, __pTableViewEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pTableViewEvent->Construct(&GetPublic(), TABLE_VIEW_STYLE_SIMPLE); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pTableViewEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetCore().AddTableViewItemEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_TableViewImpl::RemoveTableViewItemEventListener(ITableViewItemEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pTableViewEvent != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The listener is not found"); + + return __pTableViewEvent->RemoveListener(listener); +} + +result +_TableViewImpl::AddGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pTableViewEvent == null) + { + __pTableViewEvent = new (std::nothrow) _TableViewItemEvent(); + SysTryReturn(NID_UI_CTRL, __pTableViewEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pTableViewEvent->Construct(&GetPublic(), TABLE_VIEW_STYLE_GROUPED); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pTableViewEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetCore().AddGroupedTableViewItemEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_TableViewImpl::RemoveGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pTableViewEvent != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The listener is not found"); + + return __pTableViewEvent->RemoveListener(listener); +} + +result +_TableViewImpl::AddSectionTableViewItemEventListener(ISectionTableViewItemEventListener& listener) +{ + result r = E_SUCCESS; + + if (__pTableViewEvent == null) + { + __pTableViewEvent = new (std::nothrow) _TableViewItemEvent(); + SysTryReturn(NID_UI_CTRL, __pTableViewEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pTableViewEvent->Construct(&GetPublic(), TABLE_VIEW_STYLE_SECTION); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = __pTableViewEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetCore().AddSectionTableViewItemEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_TableViewImpl::RemoveSectionTableViewItemEventListener(ISectionTableViewItemEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pTableViewEvent != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The listener is not found"); + + return __pTableViewEvent->RemoveListener(listener); +} + +result +_TableViewImpl::AddFastScrollListener(IFastScrollListener& listener) +{ + ClearLastResult(); + + TableViewScrollBarStyle style = GetCore().GetScrollStyle(); + SysTryReturn(NID_UI_CTRL, style == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView scroll is not TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL"); + + if (__pFastScrollEvent == null) + { + __pFastScrollEvent = new (std::nothrow) _FastScrollEvent(); + SysTryReturn(NID_UI_CTRL, __pFastScrollEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = __pFastScrollEvent->Construct(GetPublic()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __pFastScrollEvent->AddListener(listener); + + return GetCore().AddFastScrollListener(*this); +} + +result +_TableViewImpl::RemoveFastScrollListener(IFastScrollListener& listener) +{ + ClearLastResult(); + + if (__pFastScrollEvent == null) + { + return E_INVALID_OPERATION; + } + + return __pFastScrollEvent->RemoveListener(listener); +} + +result +_TableViewImpl::AddScrollEventListener(IScrollEventListener& listener) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + if (__pScrollEvent == null) + { + __pScrollEvent = new (std::nothrow) _ScrollEvent(); + SysTryReturn(NID_UI_CTRL, __pScrollEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __pScrollEvent->Construct(GetPublic()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + r = __pScrollEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + GetCore().AddScrollEventListener(*this); + + return GetLastResult(); +} + +result +_TableViewImpl::RemoveScrollEventListener(IScrollEventListener& listener) +{ + ClearLastResult(); + + if (__pScrollEvent == null) + { + return E_INVALID_OPERATION; + } + + return __pScrollEvent->RemoveListener(listener); +} + +result +_TableViewImpl::SetSweepEnabled(bool enable) +{ + GetCore().SetSweepEnabled(enable); + + return E_SUCCESS; +} + +result +_TableViewImpl::SetFastScrollIndex(const String& text, bool useSearchIcon) +{ + __useSearchIcon = useSearchIcon; + + return GetCore().SetFastScrollIndex(text, useSearchIcon); +} + +result +_TableViewImpl::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + return GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex); +} + +result +_TableViewImpl::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + return GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex); +} + +result +_TableViewImpl::ScrollToItem(int groupIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment) +{ + if (itemAlignment == TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP) + { + return GetCore().SetTopDrawnItemIndex(groupIndex, itemIndex); + } + else if (itemAlignment == TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM) + { + return GetCore().SetBottomDrawnItemIndex(groupIndex, itemIndex); + } + + return E_OUT_OF_RANGE; +} + +result +_TableViewImpl::ScrollByPixel(int scrollDistance) +{ + return GetCore().ScrollByPixel(scrollDistance); +} + +int +_TableViewImpl::GetCurrentScrollPosition(void) const +{ + return GetCore().GetScrollPosition(); +} + +void +_TableViewImpl::SetScrollEnabled(bool enable) +{ + GetCore().SetScrollEnabled(enable); +} + +bool +_TableViewImpl::IsScrollEnabled(void) const +{ + return GetCore().IsScrollEnabled(); +} + +result +_TableViewImpl::SetItemChecked(int groupIndex, int itemIndex, bool check) +{ + return GetCore().SetItemChecked(groupIndex, itemIndex, check); +} + +bool +_TableViewImpl::IsItemChecked(int groupIndex, int itemIndex) const +{ + return GetCore().IsItemChecked(groupIndex, itemIndex); +} + +result +_TableViewImpl::SetItemEnabled(int groupIndex, int itemIndex, bool enable) +{ + return GetCore().SetItemEnabled(groupIndex, itemIndex, enable); +} + +bool +_TableViewImpl::IsItemEnabled(int groupIndex, int itemIndex) const +{ + return GetCore().IsItemEnabled(groupIndex, itemIndex); +} + +int +_TableViewImpl::GetGroupCount(void) const +{ + return GetCore().GetGroupCount(); +} + +int +_TableViewImpl::GetItemCountAt(int groupIndex) const +{ + return GetCore().GetItemCountAt(groupIndex); +} + +result +_TableViewImpl::RefreshTableView(int groupIndex, int itemIndex, TableViewRefreshType type) +{ + return GetCore().RefreshTableView(groupIndex, itemIndex, type); +} + +result +_TableViewImpl::UpdateTableView(void) +{ + return GetCore().UpdateTableView(); +} + +result +_TableViewImpl::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const +{ + return GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex); +} + +result +_TableViewImpl::SetSectionColor(const Color& color) +{ + return GetCore().SetSectionColor(color); +} + +Color +_TableViewImpl::GetSectionColor(void) const +{ + return GetCore().GetSectionColor(); +} + +result +_TableViewImpl::SetItemDividerColor(const Color& color) +{ + return GetCore().SetItemDividerColor(color); +} + +Color +_TableViewImpl::GetItemDividerColor(void) const +{ + return GetCore().GetItemDividerColor(); +} + +result +_TableViewImpl::SetBitmapOfEmptyTableView(const Bitmap* pBitmap) +{ + return GetCore().SetBitmapOfEmptyTableView(pBitmap); +} + +result +_TableViewImpl::SetTextOfEmptyTableView(const String& text) +{ + return GetCore().SetTextOfEmptyTableView(text); +} + +String +_TableViewImpl::GetTextOfEmptyTableView(void) const +{ + return GetCore().GetTextOfEmptyTableView(); +} + +result +_TableViewImpl::SetTextColorOfEmptyTableView(const Color& color) +{ + return GetCore().SetTextColorOfEmptyTableView(color); +} + +Color +_TableViewImpl::GetTextColorOfEmptyTableView(void) const +{ + return GetCore().GetTextColorOfEmptyTableView(); +} + +// Item Expand / Collapse +result +_TableViewImpl::ExpandGroup(int groupIndex) +{ + return GetCore().ExpandGroup(groupIndex); +} + +result +_TableViewImpl::CollapseGroup(int groupIndex) +{ + return GetCore().CollapseGroup(groupIndex); +} + +bool +_TableViewImpl::IsGroupExpanded(int groupIndex) const +{ + return GetCore().IsGroupExpanded(groupIndex); +} + +result +_TableViewImpl::ExpandAllGroup(void) +{ + return GetCore().ExpandAllGroup(true); +} + +result +_TableViewImpl::CollapseAllGroup(void) +{ + return GetCore().CollapseAllGroup(true); +} + +result +_TableViewImpl::SetGroupedLookEnabled(bool enable) +{ + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryReturn(NID_UI_CTRL, style != TABLE_VIEW_STYLE_SIMPLE, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is TABLE_VIEW_STYLE_SIMPLE"); + + GetCore().SetGroupedLookEnabled(enable); + + return E_SUCCESS; +} + +bool +_TableViewImpl::IsGroupedLookEnabled(void) const +{ + return GetCore().IsGroupedLookEnabled(); +} + +result +_TableViewImpl::BeginReorderingMode(void) +{ + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryReturn(NID_UI_CTRL, style != TABLE_VIEW_STYLE_SECTION, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is TABLE_VIEW_STYLE_SECTION"); + + return GetCore().SetReorderModeEnabled(true); +} + +result +_TableViewImpl::EndReorderingMode(void) +{ + TableViewStyle style = GetCore().GetTableViewStyle(); + SysTryReturn(NID_UI_CTRL, style != TABLE_VIEW_STYLE_SECTION, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is TABLE_VIEW_STYLE_SECTION"); + + return GetCore().SetReorderModeEnabled(false); +} + +bool +_TableViewImpl::IsInReorderingMode(void) const +{ + return GetCore().IsReorderModeEnabled(); +} + + +void +_TableViewImpl::OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) +{ + if (__pTableViewEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(itemIndex, 0, 0, 0, pItem, static_cast(status)); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewEvent->Fire(*pArg); + } +} + +void +_TableViewImpl::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) +{ + if (__pTableViewEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(itemIndex, 0, 0, 0, pContextItem, TABLEVIEW_NOTIFY_TYPE_CONTEXT_ITEM_ACTIVATION, activated); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewEvent->Fire(*pArg); + } +} + +void +_TableViewImpl::OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo) +{ + if (__pTableViewEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(itemIndexFrom, itemIndexTo, 0, 0, null, TABLEVIEW_NOTIFY_TYPE_REORDERED_ITEM); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewEvent->Fire(*pArg); + } +} + +void +_TableViewImpl::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) +{ + if (__pTableViewEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndex, -1, 0, 0, pItem, static_cast(status)); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewEvent->Fire(*pArg); + } +} + +void +_TableViewImpl::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) +{ + if (__pTableViewEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndex, itemIndex, 0, 0, pItem, static_cast(status)); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewEvent->Fire(*pArg); + } +} + +void +_TableViewImpl::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) +{ + if (__pTableViewEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndex, itemIndex, 0, 0, pContextItem, TABLEVIEW_NOTIFY_TYPE_CONTEXT_ITEM_ACTIVATION, activated); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewEvent->Fire(*pArg); + } +} + +void +_TableViewImpl::OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo) +{ + if (__pTableViewEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(groupIndexFrom, itemIndexFrom, groupIndexTo, itemIndexTo, null, TABLEVIEW_NOTIFY_TYPE_REORDERED_ITEM); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewEvent->Fire(*pArg); + } +} + + +void +_TableViewImpl::OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) +{ + if (__pTableViewEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(sectionIndex, itemIndex, 0, 0, pItem, static_cast(status)); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewEvent->Fire(*pArg); + } +} + +void +_TableViewImpl::OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) +{ + if (__pTableViewEvent != null) + { + _TableViewItemEventArg* pArg = new (std::nothrow) _TableViewItemEventArg(sectionIndex, itemIndex, 0, 0, pContextItem, TABLEVIEW_NOTIFY_TYPE_CONTEXT_ITEM_ACTIVATION, activated); + SysTryReturnVoidResult(NID_UI_CTRL, pArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + __pTableViewEvent->Fire(*pArg); + } +} + +void +_TableViewImpl::OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& TableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction) +{ + // It's not used public method. +} + +void +_TableViewImpl::OnScrollEndReached(_Control& source, ScrollEndEvent type) +{ + if (__pScrollEvent != null) + { + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), type); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + } +} + +void +_TableViewImpl::OnScrollPositionChanged(_Control& source, int scrollPosition) +{ + if (__pScrollEvent != null) + { + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic(), scrollPosition); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + } +} + +void +_TableViewImpl::OnScrollStopped(_Control& source) +{ + if (__pScrollEvent != null) + { + _ScrollEventArg* pEventArg = _ScrollEventArg::GetScrollEventArgN(GetPublic()); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pScrollEvent->Fire(*pEventArg); + } +} + +void +_TableViewImpl::OnUiFastScrollIndexSelected(_Control& source, Tizen::Ui::Controls::_FastScrollIndex& index) +{ + if (__pFastScrollEvent != null) + { + Tizen::Base::String* pIndexText = index.GetIndexText(); + if (pIndexText != null) + { + _FastScrollEventArg* pEventArg = new (std::nothrow) _FastScrollEventArg(GetPublic(), *pIndexText); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create _FastScrollEventArg."); + __pFastScrollEvent->Fire(*pEventArg); + } + } +} + +void +_TableViewImpl::SetScrollInputMode(ScrollInputMode mode) +{ + GetCore().SetScrollInputMode(mode); +} + +ScrollInputMode +_TableViewImpl::GetScrollInputMode(void) const +{ + return GetCore().GetScrollInputMode(); +} + + +class _TableViewMaker + : public _UiBuilderControlMaker +{ +public: + _TableViewMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_TableViewMaker(){}; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _TableViewMaker* pTableViewMaker = new (std::nothrow) _TableViewMaker(uibuilder); + SysTryReturn(NID_UI_CTRL, pTableViewMaker, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + return pTableViewMaker; + }; +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + TableView* pTableView = null; + Rectangle rect; + + Tizen::Base::String elementString; + bool itemDividerState = true; + TableViewScrollBarStyle scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT; + int opacity = 100; + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pTableView = new (std::nothrow) TableView(); + SysTryReturn(NID_UI_CTRL, pTableView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + rect = pControlProperty->GetRect(); + + //Construct + if (pControl->GetElement("itemDivider", elementString)) + { + if (elementString.Equals(L"true", false)) + { + itemDividerState = true; + } + else + { + itemDividerState = false; + } + } + + if (pControl->GetElement("scrollBarStyle", elementString)) + { + if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT; + } + else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FIXED", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FIXED; + } + else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP; + } + else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_THUMB", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_THUMB; + } + else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL; + } + else + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_NONE; + } + } + + r = pTableView->Construct(rect, itemDividerState, scrollStyle); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL) + { + Tizen::Base::String fastScrollIndex; + bool useSearchIcon = false; + + if (pControl->GetElement("fastScrollIndex", elementString)) + { + fastScrollIndex = elementString; + } + + if (pControl->GetElement("useSearchIcon", elementString)) + { + if (elementString.Equals(L"true", false)) + { + useSearchIcon = true; + } + } + + r = pTableView->SetFastScrollIndex(fastScrollIndex, useSearchIcon); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (pControl->GetElement("backgroundColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement("backgroundColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pTableView->SetBackgroundColor(color); + } + + if (pControl->GetElement("itemDividerColor", elementString)) + { + ConvertStringToColor(elementString, color); + pTableView->SetItemDividerColor(color); + } + + if (pControl->GetElement("scrollInputMode", elementString)) + { + ScrollInputMode scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION; + + if (elementString.Equals(L"SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION", false)) + { + scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION; + } + else if (elementString.Equals(L"SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION", false)) + { + scrollInputMode = SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION; + } + + pTableView->SetScrollInputMode(scrollInputMode); + } + + return pTableView; + + CATCH: + delete pTableView; + + return null; + } + +}; // _TableViewMaker + +class _GroupedTableViewMaker + : public _UiBuilderControlMaker +{ +public: + _GroupedTableViewMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_GroupedTableViewMaker(){}; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _GroupedTableViewMaker* pTableViewMaker = new (std::nothrow) _GroupedTableViewMaker(uibuilder); + SysTryReturn(NID_UI_CTRL, pTableViewMaker, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + return pTableViewMaker; + }; +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + GroupedTableView* pTableView = null; + Rectangle rect; + + Tizen::Base::String elementString; + bool itemDividerState = true; + TableViewScrollBarStyle scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT; + int opacity = 100; + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pTableView = new (std::nothrow) GroupedTableView(); + SysTryReturn(NID_UI_CTRL, pTableView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + rect = pControlProperty->GetRect(); + + //Construct + if (pControl->GetElement("itemDivider", elementString)) + { + if (elementString.Equals(L"true", false)) + { + itemDividerState = true; + } + else + { + itemDividerState = false; + } + } + + if (pControl->GetElement("scrollBarStyle", elementString)) + { + if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT; + } + else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FIXED", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FIXED; + } + else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP; + } + else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_THUMB", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_THUMB; + } + else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL; + } + else + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_NONE; + } + } + + r = pTableView->Construct(rect, itemDividerState, scrollStyle); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL) + { + Tizen::Base::String fastScrollIndex; + bool useSearchIcon = false; + + if (pControl->GetElement("fastScrollIndex", elementString)) + { + fastScrollIndex = elementString; + } + + if (pControl->GetElement("useSearchIcon", elementString)) + { + if (elementString.Equals(L"true", false)) + { + useSearchIcon = true; + } + else + { + useSearchIcon = false; + } + } + + r = pTableView->SetFastScrollIndex(fastScrollIndex, useSearchIcon); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (pControl->GetElement("backgroundColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement("backgroundColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pTableView->SetBackgroundColor(color); + } + + if (pControl->GetElement("itemDividerColor", elementString)) + { + ConvertStringToColor(elementString, color); + pTableView->SetItemDividerColor(color); + } + + if (pControl->GetElement("groupedLookEnabled", elementString)) + { + bool groupedLookEnabled = false; + + if (elementString.Equals(L"true", false)) + { + groupedLookEnabled = true; + } + + pTableView->SetGroupedLookEnabled(groupedLookEnabled); + } + + if (pControl->GetElement("collapseByPinchEnabled", elementString)) + { + bool collapseByPinchEnabled = false; + + if (elementString.Equals(L"true", false)) + { + collapseByPinchEnabled = true; + } + + pTableView->SetCollapseByPinchGestureEnabled(collapseByPinchEnabled); + } + + if (pControl->GetElement("scrollInputMode", elementString)) + { + ScrollInputMode scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION; + + if (elementString.Equals(L"SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION", false)) + { + scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION; + } + else if (elementString.Equals(L"SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION", false)) + { + scrollInputMode = SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION; + } + + pTableView->SetScrollInputMode(scrollInputMode); + } + + return pTableView; + + CATCH: + delete pTableView; + + return null; + } + +}; // _GroupedTableViewMaker + +class _SectionTableViewMaker + : public _UiBuilderControlMaker +{ +public: + _SectionTableViewMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_SectionTableViewMaker(){}; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _SectionTableViewMaker* pTableViewMaker = new (std::nothrow) _SectionTableViewMaker(uibuilder); + SysTryReturn(NID_UI_CTRL, pTableViewMaker, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + return pTableViewMaker; + }; +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + result r = E_SYSTEM; + _UiBuilderControlLayout* pControlProperty = null; + SectionTableView* pTableView = null; + Rectangle rect; + + Tizen::Base::String elementString; + bool itemDividerState = true; + TableViewScrollBarStyle scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT; + int opacity = 100; + Color color; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pTableView = new (std::nothrow) SectionTableView(); + SysTryReturn(NID_UI_CTRL, pTableView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + rect = pControlProperty->GetRect(); + + //Construct + if (pControl->GetElement("itemDivider", elementString)) + { + if (elementString.Equals(L"true", false)) + { + itemDividerState = true; + } + else + { + itemDividerState = false; + } + } + + if (pControl->GetElement("scrollBarStyle", elementString)) + { + if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT; + } + else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FIXED", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FIXED; + } + else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_JUMP_TO_TOP; + } + else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_THUMB", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_THUMB; + } + else if (elementString.Equals(L"TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL", false)) + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL; + } + else + { + scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_NONE; + } + } + + r = pTableView->Construct(rect, itemDividerState, scrollStyle); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL) + { + Tizen::Base::String fastScrollIndex; + bool useSearchIcon = false; + + if (pControl->GetElement("fastScrollIndex", elementString)) + { + fastScrollIndex = elementString; + } + + if (pControl->GetElement("useSearchIcon", elementString)) + { + if (elementString.Equals(L"true", false)) + { + useSearchIcon = true; + } + else + { + useSearchIcon = false; + } + } + + r = pTableView->SetFastScrollIndex(fastScrollIndex, useSearchIcon); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + } + + if (pControl->GetElement("backgroundColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + + if (pControl->GetElement("backgroundColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pTableView->SetBackgroundColor(color); + } + + if (pControl->GetElement("itemDividerColor", elementString)) + { + ConvertStringToColor(elementString, color); + pTableView->SetItemDividerColor(color); + } + + if (pControl->GetElement("groupedLookEnabled", elementString)) + { + bool groupedLookEnabled = false; + + if (elementString.Equals(L"true", false)) + { + groupedLookEnabled = true; + } + + pTableView->SetGroupedLookEnabled(groupedLookEnabled); + } + + if (pControl->GetElement("sectionColor", elementString)) + { + ConvertStringToColor(elementString, color); + pTableView->SetSectionColor(color); + } + + if (pControl->GetElement("scrollInputMode", elementString)) + { + ScrollInputMode scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION; + + if (elementString.Equals(L"SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION", false)) + { + scrollInputMode = SCROLL_INPUT_MODE_ALLOW_ANY_DIRECTION; + } + else if (elementString.Equals(L"SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION", false)) + { + scrollInputMode = SCROLL_INPUT_MODE_RESTRICT_TO_INITIAL_DIRECTION; + } + + pTableView->SetScrollInputMode(scrollInputMode); + } + + return pTableView; + + CATCH: + delete pTableView; + + return null; + } + +}; // _SectionTableViewMaker + + +_TableViewRegister::_TableViewRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"TableView", _TableViewMaker::GetInstance); +} +_TableViewRegister::~_TableViewRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"TableView"); +} + +_GroupedTableViewRegister::_GroupedTableViewRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"GroupedTableView", _GroupedTableViewMaker::GetInstance); +} +_GroupedTableViewRegister::~_GroupedTableViewRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"GroupedTableView"); +} + +_SectionTableViewRegister::_SectionTableViewRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"SectionTableView", _SectionTableViewMaker::GetInstance); +} +_SectionTableViewRegister::~_SectionTableViewRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"SectionTableView"); +} + + +static _TableViewRegister TableViewRegisterToUiBuilder; +static _GroupedTableViewRegister GroupedTableViewRegisterToUiBuilder; +static _SectionTableViewRegister SectionTableViewRegisterToUiBuilder; + + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TableViewItem.cpp b/src/ui/controls/FUiCtrl_TableViewItem.cpp new file mode 100644 index 0000000..ed9be1a --- /dev/null +++ b/src/ui/controls/FUiCtrl_TableViewItem.cpp @@ -0,0 +1,2925 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewItem.cpp + * @brief This is the implementation file for _TableViewItem class. + * + * This file contains the implementation of _TableViewItem class. + */ + +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUiAnim_VisualElement.h" +#include "FUiAnim_ControlVisualElement.h" +#include "FUiCtrl_TableViewItem.h" +#include "FUiCtrl_TableView.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_TableViewItem::_TableViewItem(int itemHeight) + : _Control() + , __pAppInfo(null) + , __refCount(1) + , __itemHeight(itemHeight) + , __itemGroupIndex(-1) + , __itemIndex(-1) + , __checkedState(false) + , __enabledState(true) + , __itemChanged(true) + , __reorderMode(false) + , __itemSelected(false) + , __childMarginState(false) + , __annexStyle(TABLE_VIEW_ANNEX_STYLE_NORMAL) + , __drawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL) + , __selectionStyle(TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE) + , __itemType(TABLE_VIEW_ITEM_TYPE_NONE) + , __pContextItem(null) + , __isContextItem(false) + , __isContextItemActivated(false) + , __checkItemHeightNeeded(false) + , __pItemDivider(null) + , __pItemTopDivider(null) + , __pItemAnnex(null) + , __itemWidth(0) + , __pDrawingProperty(null) + , __itemDividerEnabled(true) + , __pSimpleItemText(null) + , __pSimpleItemBitmap(null) + , __simpleItemTextSize(0) + , __pDimLayer(null) + , __touchStartPosition(0, 0) + , __isTouchMoved(false) + , __childControlCenterAlign(false) + , __customHeight(0) + , __animationCount(0) + , __pAccessibilityElement(null) + , __pCheckedTimer(null) + , __isCheckedTimerEnabled(false) + , __isCheckedAnimationEnabled(false) + , __checkedCount(0) + , __checkedBounds(Rectangle(0, 0, 0, 0)) + , __pHighlightVisualElement(null) +{ + for (int i = 0; i < 3; i++) + { + __pItemBgBitmap[i] = null; + } + + GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_NORMAL, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]); // for support opacity 0x00 + GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_PRESSED, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED]); + GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_HIGHLIGHTED, __colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED]); + + GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_NORMAL, __simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]); + GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_PRESSED, __simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED]); + GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_HIGHLIGHTED, __simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED]); + GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_TEXT_NORMAL, __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL]); + GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_TEXT_PRESSED, __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED]); + GET_COLOR_CONFIG(TABLEVIEW::ITEM_TEXT_DISABLED, __simpleItemTextColor[TABLE_VIEW_SIMPLEITEM_DRAWING_STATUS_DISABLED]); + + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if (pContainer) + { + pContainer->Activate(true); + pContainer->AddListener(*this); + } +} + +_TableViewItem::~_TableViewItem() +{ + _VisualElement* pVisualElement = GetVisualElement(); + if (pVisualElement != null) + { + pVisualElement->RemoveAllAnimations(); + } + + for (int j = 0; j < 3; j++) + { + delete __pItemBgBitmap[j]; + __pItemBgBitmap[j] = null; + } + + if (__pHighlightVisualElement != null) + { + __pHighlightVisualElement->RemoveAllAnimations(); + __pHighlightVisualElement->SetAnimationProvider(null); + __pHighlightVisualElement->Destroy(); + __pHighlightVisualElement = null; + } + + DetachAllChildren(); + + if (GetParent() != null && __isContextItem == true) + { + GetParent()->DetachChild(*this); + } + + delete __pItemDivider; + __pItemDivider = null; + + delete __pItemTopDivider; + __pItemTopDivider = null; + + delete __pItemAnnex; + __pItemAnnex = null; + + delete __pDimLayer; + __pDimLayer = null; + + if (__isCheckedTimerEnabled) + { + __pCheckedTimer->Cancel(); + } + + delete __pCheckedTimer; + __pCheckedTimer = null; + + if (__pAccessibilityElement) + { + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if(pContainer) + { + pContainer->RemoveAllElement(); + } + __pAccessibilityElement = null; + } +} + +_TableViewItem* +_TableViewItem::CreateTableViewItemN(int itemHeight) +{ + result r = E_SUCCESS; + + _TableViewItem* pItem = null; + pItem = new (std::nothrow) _TableViewItem(itemHeight); + SysTryReturn(NID_UI_CTRL, pItem, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pItem->AcquireHandle(); + + r = pItem->Initialize(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r = E_SYSTEM, "[E_SYSTEM] Unable to create TableView Item"); + + return pItem; + +CATCH: + delete pItem; + + return null; +} + +result +_TableViewItem::Initialize(void) +{ + GetVisualElement()->SetSurfaceOpaque(false); + + result r = E_SUCCESS; + + __pHighlightVisualElement = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_CTRL, __pHighlightVisualElement != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pHighlightVisualElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct Visual Element.", GetErrorMessage(r)); + + r = __pHighlightVisualElement->SetSurfaceOpaque(false); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set surface opaque.", GetErrorMessage(r)); + + __pHighlightVisualElement->SetImplicitAnimationEnabled(false); + + r = GetVisualElement()->AttachChild(*__pHighlightVisualElement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach child to the control VisualElement.", GetErrorMessage(r)); + + r = SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds.", GetErrorMessage(r)); + + __pHighlightVisualElement->SetBackgroundColor(_Colorf(0.0f, 0.0f, 0.0f, 0.0f)); + __pHighlightVisualElement->SetShowState(true); + + r = __individualSelectionControls.Construct(DEFAULT_CAPTURED_CONTROL_COUNT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to construct ArrayList", GetErrorMessage(r)); + + SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_INSENSITIVE); + + return r; + +CATCH: + if (__pHighlightVisualElement != null) + { + __pHighlightVisualElement->RemoveAllAnimations(); + __pHighlightVisualElement->SetAnimationProvider(null); + __pHighlightVisualElement->Destroy(); + __pHighlightVisualElement = null; + } + + return r; +} + +_TableViewItem* +_TableViewItem::GetContextItem(void) const +{ + return __pContextItem; +} + +void +_TableViewItem::SetContextItem(_TableViewItem* pContextItem) +{ + if (pContextItem != null) + { + pContextItem->__isContextItem = true; + } + + __pContextItem = pContextItem; +} + +bool +_TableViewItem::IsContextItem(void) const +{ + return __isContextItem; +} + +void +_TableViewItem::SetContextItemActivation(bool activated) +{ + __isContextItemActivated = activated; +} + +bool +_TableViewItem::IsContextItemActivated(void) const +{ + return __isContextItemActivated; +} + +result +_TableViewItem::CreateItemDimLayer(void) +{ + result r = E_SUCCESS; + + if (__pDimLayer == null) + { + __pDimLayer = _Label::CreateLabelN(); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pDimLayer != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pDimLayer->SetBackgroundColor(Color(0, 0, 0, BACKGROUND_DIMMED_OPACITY * 0xff)); + __pDimLayer->SetVisibleState(false); + + AttachSystemChild(*__pDimLayer); + } + + return r; +} + +void +_TableViewItem::ExposeContextItem(Rectangle itemBounds, int targetWidth) +{ + DrawItemDivider(); + if (__pDimLayer == null) + { + if (CreateItemDimLayer() != E_SUCCESS) + { + return; + } + } + + SetBounds(itemBounds); + + bool visible = true; + + if ((itemBounds.width <= 0) || (itemBounds.width >= targetWidth)) + { + visible = false; + } + + if (visible) + { + int rightMargin = 0; + float dimLayerOpacity = 0.0f; + + GET_SHAPE_CONFIG(TABLEVIEW::CONTEXTITEM_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, rightMargin); + dimLayerOpacity = BACKGROUND_DIMMED_OPACITY - ((itemBounds.width * BACKGROUND_DIMMED_OPACITY) / (targetWidth - rightMargin)); + dimLayerOpacity = ((dimLayerOpacity < 0) ? 0 : dimLayerOpacity); + + __pDimLayer->SetBounds(Rectangle(0, 0, itemBounds.width, itemBounds.height)); + __pDimLayer->SetBackgroundColor(Color(0, 0, 0, dimLayerOpacity * 0xff)); + } + + __pDimLayer->SetVisibleState(visible); + +} + +void +_TableViewItem::DrawItemDimLayer(bool visible) +{ + if (__pDimLayer == null) + { + if (CreateItemDimLayer() != E_SUCCESS) + { + return; + } + } + + if (visible) + { + Dimension itemSize = GetSize(); + __pDimLayer->SetBounds(Rectangle(0, 0, itemSize.width, itemSize.height)); + __pDimLayer->SetBackgroundColor(Color(0, 0, 0, BACKGROUND_DISABLED_OPACITY * 0xff)); + } + + __pDimLayer->SetVisibleState(visible); +} + +void +_TableViewItem::SetItemWidth(int width) +{ + __itemWidth = width; +} + +bool +_TableViewItem::SetItemBackgroundBitmap(ListItemState itemState, const Bitmap* pBitmap) +{ + Bitmap* pCopyBitmap = null; + + pCopyBitmap = _BitmapImpl::CloneN(*pBitmap); + SysTryReturn(NID_UI_CTRL, pCopyBitmap != null, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient.")); + + delete __pItemBgBitmap[itemState]; + __pItemBgBitmap[itemState] = pCopyBitmap; + + SetItemChanged(true); + + return true; +} + +Tizen::Graphics::Bitmap* +_TableViewItem::GetItemBackgroundBitmap(ListItemState itemState) const +{ + return __pItemBgBitmap[itemState]; +} + +void +_TableViewItem::SetItemBackgroundColor(ListItemState itemState, const Color bgColor) +{ + __colorItemBg[itemState] = bgColor; + + SetItemChanged(true); +} + +Color +_TableViewItem::GetItemBackgroundColor(ListItemState itemState) const +{ + return __colorItemBg[itemState]; +} + +void +_TableViewItem::SetItemStyle(TableViewAnnexStyle style) +{ + if (__annexStyle == style) + { + return; + } + + __annexStyle = style; +} + +result +_TableViewItem::SetSelectionStyle(TableViewItemSelectionStyle style) +{ + __selectionStyle = style; + + return E_SUCCESS; +} + +TableViewItemSelectionStyle +_TableViewItem::GetSelectionStyle(void) const +{ + return __selectionStyle; +} + +int +_TableViewItem::GetItemHeight(void) const +{ + return GetSize().height; +} + +void +_TableViewItem::SetItemHeight(int itemHeight) +{ + SetSize(Dimension(GetSize().width, itemHeight)); +} + +void +_TableViewItem::SetChecked(bool checked) +{ + if (__checkedState == checked) + { + return; + } + + __checkedState = checked; + + SetItemChanged(true); +} + +bool +_TableViewItem::IsChecked(void) const +{ + return __checkedState; +} + +void +_TableViewItem::SetCheckedAnimationEnabled(bool enabled) +{ + __isCheckedAnimationEnabled = enabled; + + if (__isCheckedAnimationEnabled == false) + { + StopCheckBoxAnimation(); + } +} + +void +_TableViewItem::SetItemEnabled(bool enabled) +{ + if (__enabledState == enabled) + { + return; + } + + __enabledState = enabled; + + SetEnableState(enabled); + + SetItemChanged(true); + + Invalidate(); + + return; +} + +bool +_TableViewItem::IsItemEnabled(void) const +{ + return __enabledState; +} + +void +_TableViewItem::SetItemType(const TableViewItemType itemType) +{ + __itemType = itemType; + + if (__pContextItem != null) + { + __pContextItem->SetItemType(__itemType); + } +} + +void +_TableViewItem::SetItemIndex(int groupIndex, int itemIndex) +{ + __itemGroupIndex = groupIndex; + __itemIndex = itemIndex; +} + +void +_TableViewItem::GetItemIndex(int& groupIndex, int& itemIndex) const +{ + groupIndex = __itemGroupIndex; + itemIndex = __itemIndex; +} + + +TableViewItemType +_TableViewItem::GetItemType(void) const +{ + return __itemType; +} + +bool +_TableViewItem::IsReorderMode(void) const +{ + return __reorderMode; +} + +void +_TableViewItem::SetReorderMode(bool enabled) +{ + __reorderMode = enabled; + + if (GetItemStyle() != TABLE_VIEW_ANNEX_STYLE_NORMAL) + { + if (__pItemAnnex != null) + { + __pItemAnnex->SetVisibleState(!enabled); + } + else + { + SetItemChanged(true); + Invalidate(); + } + } +} + +void +_TableViewItem::SetAppInfo(const void* pAppInfo) +{ + __pAppInfo = const_cast(pAppInfo); +} + +void* +_TableViewItem::GetAppInfo(void) const +{ + return __pAppInfo; +} + +void +_TableViewItem::SetItemChanged(bool changed) +{ + __itemChanged = changed; +} + +bool +_TableViewItem::IsItemChanged(void) const +{ + return __itemChanged; +} + +TableViewAnnexStyle +_TableViewItem::GetItemStyle(void) const +{ + return __annexStyle; +} + +bool +_TableViewItem::DrawItem(Rectangle& rcItem, ListItemState itemState, bool itemDivider) +{ + return true; +} + +void +_TableViewItem::FireItemEvent(bool selectedBody) +{ + if (HasParent() == false) + { + return; + } + + if (IsContextItem()) + { + return; + } + + _TableView* pParent = dynamic_cast<_TableView*>(GetParent()); + if (pParent == null) + { + return; + } + + TableViewNotifyType eventType = TABLEVIEW_NOTIFY_TYPE_SELECTED_ITEM; + + if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) + || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)) + { + if (IsChecked()) + { + eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_CHECK; + } + else + { + eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_UNCHECK; + } + } + else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED) + { + if (!selectedBody) + { + eventType = TABLEVIEW_NOTIFY_TYPE_ANNEX_MORE; + } + } + + __checkItemHeightNeeded = true; + + int groupIndex = -1; + int itemIndex = -1; + + GetItemIndex(groupIndex, itemIndex); + pParent->FireTableViewItemEvent(groupIndex, itemIndex, eventType, this); +} + +void +_TableViewItem::FireItemSweepEvent(TableViewSweepDirection direction) +{ + if (HasParent() == false) + { + return; + } + + _TableView* pParent = dynamic_cast<_TableView*>(GetParent()); + if (pParent == null) + { + return; + } + + int groupIndex = -1; + int itemIndex = -1; + GetItemIndex(groupIndex, itemIndex); + + pParent->FireTableViewItemSweepEvent(groupIndex, itemIndex, direction); +} + +bool +_TableViewItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this || IsAnimationPlaying()) + { + return false; + } + + if (IsContextItem() || __isContextItemActivated) + { + return true; + } + + __isTouchMoved = false; + __touchStartPosition = touchinfo.GetCurrentPosition(); + + __itemSelected = true; + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED; + + SetItemChanged(true); + Invalidate(); + + return true; +} + +bool +_TableViewItem::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + + bool fireEvent = false; + + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + + if (__itemSelected == true) + { + if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) + || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)) + { + bool checked = IsChecked(); + SetChecked(!checked); + SetCheckedAnimationEnabled(!checked); + } + + fireEvent = true; + } + + SetItemChanged(true); + Invalidate(); + + __itemSelected = false; + + if (fireEvent) + { + FireItemEvent(true); + } + + return true; +} + +bool +_TableViewItem::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__itemSelected == true) + { + Point touchPosition = touchinfo.GetCurrentPosition(); + + __isTouchMoved = true; + + __itemSelected = false; + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + + SetItemChanged(true); + Invalidate(); + } + + return false; +} + +bool +_TableViewItem::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + + __isTouchMoved = false; + + __itemSelected = false; + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + + if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED) + { + SetChecked(false); + } + + SetItemChanged(true); + Invalidate(); + + return true; +} + +_UiTouchEventDelivery +_TableViewItem::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__isContextItemActivated || IsAnimationPlaying() || !IsValidSelectionState()) + { + return _UI_TOUCH_EVENT_DELIVERY_YES; + } + + __itemSelected = true; + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED; + + __isTouchMoved = false; + __touchStartPosition = touchinfo.GetCurrentPosition(); + + if (__selectionStyle == TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE && !IsIndividualSelectionEnabled(source)) + { + if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED) && (&source == __pItemAnnex)) + { + SetChecked(true); + DrawAnnexStyle(); + } + else + { + SetItemChanged(true); + Invalidate(); + } + } + else + { + if (&source == __pItemAnnex) + { + if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED) + { + SetChecked(true); + DrawAnnexStyle(); + } + else + { + SetItemChanged(true); + Invalidate(); + } + } + } + + return _UI_TOUCH_EVENT_DELIVERY_YES; +} + +_UiTouchEventDelivery +_TableViewItem::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__isContextItemActivated) + { + return _UI_TOUCH_EVENT_DELIVERY_YES; + } + + int selectedBody = true; + bool fireItemEvent = false; + + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + + if (__itemSelected == true) + { + if (__selectionStyle == TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE && !IsIndividualSelectionEnabled(source)) + { + if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) + || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)) + { + bool checked = IsChecked(); + SetChecked(!checked); + SetCheckedAnimationEnabled(!checked); + } + else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED) + { + if (&source == __pItemAnnex) + { + SetChecked(!IsChecked()); + + selectedBody = false; + } + } + + SetItemChanged(true); + Invalidate(); + + fireItemEvent = true; + } + else + { + if (&source == __pItemAnnex) + { + bool checked = IsChecked(); + SetChecked(!checked); + SetCheckedAnimationEnabled(!checked); + + if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED) + { + DrawAnnexStyle(); + selectedBody = false; + } + else + { + Invalidate(); + } + + fireItemEvent = true; + } + } + } + + __itemSelected = false; + + if (fireItemEvent) + { + FireItemEvent(selectedBody); + } + + return _UI_TOUCH_EVENT_DELIVERY_YES; +} + +_UiTouchEventDelivery +_TableViewItem::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (__itemSelected == true) + { + Point touchPosition = touchinfo.GetCurrentPosition(); + + __isTouchMoved = true; + + __itemSelected = false; + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + + SetItemChanged(true); + Invalidate(); + } + else + { + if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED && IsChecked()) + { + SetChecked(false); + DrawAnnexStyle(); + } + } + return _UI_TOUCH_EVENT_DELIVERY_YES; +} + +_UiTouchEventDelivery +_TableViewItem::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + __isTouchMoved = false; + + __itemSelected = false; + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + + if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED) + { + SetChecked(false); + } + + SetItemChanged(true); + Invalidate(); + + return _UI_TOUCH_EVENT_DELIVERY_YES; +} + +void +_TableViewItem::OnDraw(void) +{ + if (IsItemChanged() == true) + { + DrawItemBackground(); + DrawAnnexStyle(); + DrawItemDivider(); + DrawSimpleItem(); + + SetAccessibilityElement(); + SetItemChanged(false); + } +} + +void +_TableViewItem::OnChildAttached(const _Control& child) +{ + _AccessibilityContainer* pContainer = const_cast<_Control*>(&child)->GetAccessibilityContainer(); + pContainer->Activate(false); + + _Control* pControl = const_cast<_Control*>(&child); + pControl->SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_INSENSITIVE); + + if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)) + { + if (__pItemAnnex == &child) + { + return; + } + + Rectangle bounds = child.GetBounds(); + int leftMargin = 0; + int annexWidth = 0; + + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + + bounds.x += (leftMargin * 2) + annexWidth; + pControl->SetBounds(bounds); + } +} + +void +_TableViewItem::OnChildDetached(const _Control& child) +{ + if (__individualSelectionControls.Contains(child)) + { + __individualSelectionControls.Remove(child, false); + } + + if (&child == __pSimpleItemText) + { + __pSimpleItemText = null; + } + if (&child == __pSimpleItemBitmap) + { + __pSimpleItemBitmap = null; + } +} + +void +_TableViewItem::OnTimerExpired(Tizen::Base::Runtime::Timer& timer) +{ + result r = E_SUCCESS; + + if (&timer == __pCheckedTimer) + { + if (__checkedCount < MAX_CHECKED_COUNT) + { + r = __pCheckedTimer->Start(CHECKED_ANIMATION_DURATION); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + r = PlayCheckBoxAnimation(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__checkedCount < MAX_CHECKED_COUNT) + { + __checkedCount++; + } + else + { + __checkedCount = 0; + __isCheckedAnimationEnabled = false; + __isCheckedTimerEnabled = false; + } + } +} + +result +_TableViewItem::StartCheckBoxAnimation(void) +{ + result r = E_SUCCESS; + + if (__pCheckedTimer == null) + { + __pCheckedTimer = new (std::nothrow) Timer(); + SysTryCatch(NID_UI_CTRL, __pCheckedTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pCheckedTimer->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage); + } + + if (__isCheckedTimerEnabled == false) + { + r = __pCheckedTimer->Start(CHECKED_ANIMATION_DURATION); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage); + + __isCheckedTimerEnabled = true; + } + + return r; + +CATCH: + if (__isCheckedTimerEnabled) + { + __pCheckedTimer->Cancel(); + } + + delete __pCheckedTimer; + __pCheckedTimer = null; + + return r; +} + +void +_TableViewItem::StopCheckBoxAnimation(void) +{ + result r = E_SUCCESS; + + SysTryReturnVoidResult(NID_UI_CTRL, __pCheckedTimer != null, E_SYSTEM, "[E_SYSTEM] Timer is invalid."); + + if (__isCheckedTimerEnabled) + { + r = __pCheckedTimer->Cancel(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __checkedCount = 0; + __isCheckedAnimationEnabled = false; + __isCheckedTimerEnabled = false; + + return; +} + +result +_TableViewItem::PlayCheckBoxAnimation(void) +{ + Bitmap* pCheckBox = null; + Bitmap* pCheckBoxBg = null; + Bitmap* pMergeBitmap = null; + Canvas* pCanvas = null; + result r = E_SUCCESS; + + Rectangle bounds; + int annexWidth = 0, annexHeight = 0; + + if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg); + } + else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED)) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg); + } + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox); + SysTryCatch(NID_UI_CTRL,(r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight); + bounds.SetBounds(0, 0, annexWidth, annexHeight); + + pCanvas = new (std::nothrow) Canvas(); + SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + if (pCanvas != null) + { + r = pCanvas->Construct(bounds); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBoxBg), *pCheckBoxBg); + + __checkedBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBox); + if (IsChecked() == true) + { + if (pCheckBox->IsNinePatchedBitmap()) + { + r = pCanvas->DrawNinePatchedBitmap(Rectangle(__checkedBounds.x, __checkedBounds.y, __checkedBounds.width, __checkedBounds.height), *pCheckBox); + } + else + { + Rectangle bitmapSourceRect(0, 0, pCheckBox->GetWidth()*__checkedCount * 0.1, pCheckBox->GetHeight()); + Rectangle drawingRect(__checkedBounds.x, __checkedBounds.y, __checkedBounds.width * __checkedCount * 0.1, __checkedBounds.height); + r = pCanvas->DrawBitmap(drawingRect, *pCheckBox, bitmapSourceRect); + } + } + } + + pMergeBitmap = new (std::nothrow) Bitmap(); + SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + if (pMergeBitmap != null) + { + pMergeBitmap->Construct(*pCanvas, bounds); + } + + if (__pItemAnnex == null) + { + __pItemAnnex = _Label::CreateLabelN(); + + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, __pItemAnnex != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + int leftMargin = 0; + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + + int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height); + __pItemAnnex->SetBounds(Rectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); + __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); + + AttachSystemChild(*__pItemAnnex); + } + + __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap); + __pItemAnnex->Invalidate(); + +CATCH: + delete pCheckBox; + delete pCheckBoxBg; + delete pMergeBitmap; + delete pCanvas; + + return r; +} + +void +_TableViewItem::OnBoundsChanged(void) +{ + if (__checkItemHeightNeeded && HasParent()) + { + _TableView* pParent = dynamic_cast<_TableView*>(GetParent()); + if (pParent != null) + { + int groupIndex = -1; + int itemIndex = -1; + GetItemIndex(groupIndex, itemIndex); + + pParent->CheckItemHeightAndRefreshLayout(groupIndex, itemIndex); + } + + __checkItemHeightNeeded = false; + } + + AdjustAnnexBounds(); + + SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds()); +} + +void +_TableViewItem::SetDrawingProperty(_ItemDrawingProperty* pDrawingProperty) +{ + __pDrawingProperty = pDrawingProperty; +} + +_ItemDrawingProperty* +_TableViewItem::GetDrawingProperty(void) +{ + return __pDrawingProperty; +} + +void +_TableViewItem::DrawItemBackground(void) +{ + Canvas* pCanvas = null; + Bitmap* pDrawBitmap = __pItemBgBitmap[__drawingStatus]; + Color bgColor = __colorItemBg[__drawingStatus]; + Rectangle bounds = GetBounds(); + + SetItemHighlightBounds(*__pHighlightVisualElement, CalculateItemHighlightBounds()); + + if (pDrawBitmap != null) + { + const _BitmapImpl* pBitmapImpl = _BitmapImpl::GetInstance(*pDrawBitmap); + SysTryReturnVoidResult(NID_UI_CTRL, pBitmapImpl != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas = GetVisualElement()->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + if (__enabledState) + { + pCanvas->SetBackgroundColor(bgColor); + } + else + { + GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor); + pCanvas->SetBackgroundColor(bgColor); + } + pCanvas->Clear(); + DrawBitmap(*pCanvas, Rectangle(0, 0, bounds.width, bounds.height), *pDrawBitmap); + + delete pCanvas; + pCanvas = null; + } + else if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE) + { + if (__enabledState) + { + SetBackgroundColor(__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]); + __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f)); + } + else + { + GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor); + SetBackgroundColor(bgColor); + } + } + else if (__itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER) + { + if (__enabledState) + { + SetBackgroundColor(Color(0, 0, 0, 0)); + __pHighlightVisualElement->SetBackgroundColor(_Colorf(0.0f, 0.0f, 0.0f, 0.0f)); + } + else + { + GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor); + SetBackgroundColor(bgColor); + } + } + else if (IsContextItem()) + { + if (__enabledState) + { + SetBackgroundColor(__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]); + __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f)); + } + else + { + GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor); + SetBackgroundColor(bgColor); + } + } + else if (__pDrawingProperty->sectionStyleEnabled == true) + { + DrawSectionStyleBackground(); + } + else + { + if (__enabledState) + { + SetBackgroundColor(__colorItemBg[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]); + __pHighlightVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255.0f, (float)bgColor.GetGreen() / 255.0f, (float)bgColor.GetBlue() / 255.0f, (float)bgColor.GetAlpha() / 255.0f)); + } + else + { + GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor); + SetBackgroundColor(bgColor); + } + + if (__pDrawingProperty->groupedLookEnabled == true) + { + DrawGroupedLook(); + } + } +} + +void +_TableViewItem::DrawGroupedLook(void) +{ + if (IsTitleStyleItem()) + { + return; + } + + Color barColor; + Color outlineColor = __pDrawingProperty->dividerColor; + int barWidth = 0; + + Canvas* pCanvas = GetVisualElement()->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + Rectangle bounds = GetBounds(); + pCanvas->SetBackgroundColor(GetBackgroundColor()); + pCanvas->Clear(); + + GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_BAR_NORMAL, barColor); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, barWidth); + + pCanvas->FillRectangle(barColor, Rectangle(0, 0, barWidth, bounds.height)); + + if (__pDrawingProperty->sectionStyleEnabled == true) + { + pCanvas->FillRectangle(outlineColor, Rectangle(bounds.width - 1, 0, 1, bounds.height)); + + if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP || __itemType == TABLE_VIEW_ITEM_TYPE_ONE) + { + pCanvas->FillRectangle(outlineColor, Rectangle(0, 0, bounds.width, 1)); + } + } + + delete pCanvas; +} + +void +_TableViewItem::DrawSectionStyleBackground(void) +{ + Canvas* pCanvas = null; + Bitmap* pSectionBg = null; + Bitmap* pSectionPressedBg = null; + Bitmap* pReplacementSectionBg = null; + Rectangle bounds = GetBounds(); + result r = E_SUCCESS; + + pCanvas = GetVisualElement()->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg); + } + else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg); + } + else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg); + } + else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionBg); + } + else + { + r = E_SYSTEM; + } + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] SectionStyle image load failed"); + + if (__enabledState) + { + pReplacementSectionBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), __pDrawingProperty->sectionStyleBgColor); + } + else + { + Color bgColor; + GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_DISABLED, bgColor); + pReplacementSectionBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), bgColor); + } + DrawBitmap(*pCanvas, Rectangle(0, 0, bounds.width, bounds.height), *pReplacementSectionBg); + + if (__drawingStatus != TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL) + { + if (__itemType == TABLE_VIEW_ITEM_TYPE_ONE) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_SINGLE_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressedBg); + } + else if (__itemType == TABLE_VIEW_ITEM_TYPE_TOP) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_TOP_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressedBg); + } + else if (__itemType == TABLE_VIEW_ITEM_TYPE_MIDDLE) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_CENTER_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressedBg); + } + else if (__itemType == TABLE_VIEW_ITEM_TYPE_BOTTOM) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::SECTIONITEM_BOTTOM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pSectionPressedBg); + } + } + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] SectionStyle image load failed"); + + if (__drawingStatus != TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL) + { + Color pressColor; + int dividerHeight; + + GET_COLOR_CONFIG(TABLEVIEW::ITEM_BG_PRESSED, pressColor); + pSectionPressedBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pSectionBg, Color::GetColor(COLOR_ID_MAGENTA), pressColor); + GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, dividerHeight); + DrawBitmap(*pCanvas, Rectangle(0, dividerHeight, bounds.width, bounds.height-dividerHeight*2), *pSectionPressedBg); + } + + if (__pDrawingProperty->groupedLookEnabled == true) + { + Color barColor; + int barWidth = 0, barMargin = 0; + + GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_BAR_NORMAL, barColor); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, barWidth); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, barMargin); + + pCanvas->FillRectangle(barColor, Rectangle(0, barMargin, barWidth, bounds.height-barMargin)); + } + +CATCH: + delete pSectionBg; + delete pSectionPressedBg; + delete pReplacementSectionBg; + delete pCanvas; +} + +void +_TableViewItem::DrawAnnexStyle(void) +{ + if (__reorderMode) + { + return; + } + + switch (__annexStyle) + { + case TABLE_VIEW_ANNEX_STYLE_MARK: + DrawCheckBox(); + break; + case TABLE_VIEW_ANNEX_STYLE_RADIO: + DrawRadioBox(); + break; + case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING: + DrawOnOffButton(); + break; + case TABLE_VIEW_ANNEX_STYLE_DETAILED: + DrawDetailButton(); + break; + default: + break; + } +} + +void +_TableViewItem::DrawCheckBox(void) +{ + Bitmap* pCheckBox = null; + Bitmap* pCheckBoxBg = null; + Bitmap* pMergeBitmap = null; + Canvas* pCanvas = null; + result r = E_SUCCESS; + + Rectangle bounds; + int annexWidth = 0, annexHeight = 0; + + if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg); + } + else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED)) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBoxBg); + } + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBoxBg != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight); + bounds.SetBounds(0, 0, annexWidth, annexHeight); + + pCanvas = new (std::nothrow) Canvas(); + SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + if (pCanvas != null) + { + pCanvas->Construct(bounds); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBoxBg), *pCheckBoxBg); + + if (IsChecked() == true) + { + if (__isCheckedAnimationEnabled == true) + { + StartCheckBoxAnimation(); + } + else + { + if (pCheckBox != null) + { + DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pCheckBox), *pCheckBox); + } + } + } + } + + pMergeBitmap = new (std::nothrow) Bitmap(); + SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + if (pMergeBitmap != null) + { + pMergeBitmap->Construct(*pCanvas, bounds); + } + + if (__pItemAnnex == null) + { + __pItemAnnex = _Label::CreateLabelN(); + + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, __pItemAnnex != null, , r, "[%s] Propagating.", GetErrorMessage(r)); + + int leftMargin = 0; + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + + int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height); + __pItemAnnex->SetBounds(Rectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); + __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); + + AttachSystemChild(*__pItemAnnex); + } + + __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap); + __pItemAnnex->Invalidate(); + +CATCH: + delete pCheckBox; + delete pCheckBoxBg; + delete pMergeBitmap; + delete pCanvas; + + return; +} + +void +_TableViewItem::DrawRadioBox(void) +{ + Bitmap* pRadioButton = null; + Bitmap* pRadioButtonBg = null; + Bitmap* pMergeBitmap = null; + Canvas* pCanvas = null; + result r = E_SUCCESS; + + Rectangle bounds; + int annexWidth = 0, annexHeight = 0; + + if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButtonBg); + } + else if ((__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) || (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED)) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButtonBg); + } + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pRadioButtonBg != null), , E_SYSTEM, "[E_SYSTEM] RadioButtonBg image load failed"); + + r = GET_BITMAP_CONFIG_N(TABLEVIEW::RADIOBUTTON_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pRadioButton); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pRadioButton != null), , E_SYSTEM, "[E_SYSTEM] CheckBox image load failed"); + + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight); + bounds.SetBounds(0, 0, annexWidth, annexHeight); + + pCanvas = new (std::nothrow) Canvas(); + SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + if (pCanvas != null) + { + pCanvas->Construct(bounds); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pRadioButtonBg), *pRadioButtonBg); + + if (IsChecked() == true) + { + DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pRadioButton), *pRadioButton); + } + } + + pMergeBitmap = new (std::nothrow) Bitmap(); + SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + if (pMergeBitmap != null) + { + pMergeBitmap->Construct(*pCanvas, bounds); + } + + if (__pItemAnnex == null) + { + __pItemAnnex = _Label::CreateLabelN(); + SysTryReturnVoidResult(NID_UI_CTRL, __pItemAnnex, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + int leftMargin = 0; + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + + int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height); + __pItemAnnex->SetBounds(Rectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); + __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); + + AttachSystemChild(*__pItemAnnex); + } + + __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap); + __pItemAnnex->Invalidate(); + +CATCH: + delete pRadioButton; + delete pRadioButtonBg; + delete pMergeBitmap; + delete pCanvas; + + return; +} + +void +_TableViewItem::DrawOnOffButton(void) +{ + Bitmap* pOnOffButton = null; + Bitmap* pOnOffButtonHandler = null; + Bitmap* pMergeBitmap = null; + Canvas* pCanvas = null; + result r = E_SUCCESS; + + Rectangle bounds; + Rectangle backgroundBounds; + int annexWidth = 0, annexHeight = 0; + + r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_HANDLER, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButtonHandler); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pOnOffButtonHandler != null), , E_SYSTEM, "[E_SYSTEM] OnOffHandlerButton button image load failed"); + + if (IsChecked() == true) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_ON, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButton); + } + else + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::ONOFFBUTTON_OFF, BITMAP_PIXEL_FORMAT_ARGB8888, pOnOffButton); + } + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pOnOffButton != null), , E_SYSTEM, "[E_SYSTEM] OnOffButton image load failed"); + + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight); + bounds.SetBounds(0, 0, annexWidth, annexHeight); + + pCanvas = new (std::nothrow) Canvas(); + SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pCanvas->Construct(bounds); + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + backgroundBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButton); + DrawBitmap(*pCanvas, backgroundBounds, *pOnOffButton); + + if (IsChecked() == true) + { + Rectangle handlerBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButtonHandler); + handlerBounds.x = backgroundBounds.width - handlerBounds.width; + handlerBounds.y = backgroundBounds.y; + DrawBitmap(*pCanvas, handlerBounds, *pOnOffButtonHandler); + } + else + { + Rectangle handlerBounds = CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pOnOffButtonHandler); + handlerBounds.x = backgroundBounds.x; + handlerBounds.y = backgroundBounds.y; + DrawBitmap(*pCanvas, handlerBounds, *pOnOffButtonHandler); + } + + pMergeBitmap = new (std::nothrow) Bitmap(); + SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pMergeBitmap->Construct(*pCanvas, bounds); + + if (__pItemAnnex == null) + { + __pItemAnnex = _Label::CreateLabelN(); + SysTryReturnVoidResult(NID_UI_CTRL, __pItemAnnex, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + int leftMargin = 0; + int annexWidth = 0, annexHeight = 0; + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight); + + leftMargin += __pDrawingProperty->scrollMargin; + + int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height); + __pItemAnnex->SetBounds(Rectangle((GetBounds().width - annexWidth - leftMargin), ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); + __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); + + AttachSystemChild(*__pItemAnnex); + } + + __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap); + __pItemAnnex->Invalidate(); + +CATCH: + delete pOnOffButton; + delete pOnOffButtonHandler; + delete pMergeBitmap; + delete pCanvas; + + return; +} + +void +_TableViewItem::DrawDetailButton(void) +{ + Bitmap* pDetail = null; + Bitmap* pDetailBg = null; + Bitmap* pDetailBgEffect = null; + Bitmap* pReplacementDetail = null; + Bitmap* pReplacementDetailBg = null; + Bitmap* pMergeBitmap = null; + Canvas* pCanvas = null; + Color replacementNewColor; + Color replacementNewBgColor; + result r = E_SUCCESS; + + Rectangle bounds; + int annexWidth = 0, annexHeight = 0; + + r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBg); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBg != null), , E_SYSTEM, "[E_SYSTEM] Detail button image load failed"); + + if (IsChecked() != true) + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBgEffect); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBgEffect != null), , E_SYSTEM, "[E_SYSTEM] Detail button image load failed"); + + GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_NORMAL, replacementNewColor); + GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_BG_NORMAL, replacementNewBgColor); + } + else + { + r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pDetailBgEffect); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetailBgEffect != null), , E_SYSTEM, "[E_SYSTEM] Detail button image load failed"); + + GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_PRESSED, replacementNewColor); + GET_COLOR_CONFIG(TABLEVIEW::ITEM_ANNEX_DETAIL_BG_PRESSED, replacementNewBgColor); + } + + pReplacementDetailBg = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pDetailBg, Color::GetColor(COLOR_ID_MAGENTA), replacementNewBgColor); + SysTryCatch(NID_UI_CTRL, pReplacementDetailBg != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Detail button image load failed"); + + r = GET_BITMAP_CONFIG_N(TABLEVIEW::CIRCLE_BUTTON_REVEAL, BITMAP_PIXEL_FORMAT_ARGB8888, pDetail); + SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pDetail != null), , E_SYSTEM, "[E_SYSTEM] Detail button image load failed"); + + pReplacementDetail = Tizen::Graphics::_BitmapImpl::GetColorReplacedBitmapN(*pDetail, Color::GetColor(COLOR_ID_MAGENTA), replacementNewColor); + SysTryCatch(NID_UI_CTRL, pReplacementDetail != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Detail button image load failed"); + + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight); + bounds.SetBounds(0, 0, annexWidth, annexHeight); + + pCanvas = new (std::nothrow) Canvas(); + SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pCanvas->Construct(bounds); + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pReplacementDetailBg), *pReplacementDetailBg); + DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pDetailBgEffect), *pDetailBgEffect); + DrawBitmap(*pCanvas, CalculateAnnexBitmapBounds(annexWidth, annexHeight, *pReplacementDetail), *pReplacementDetail); + + pMergeBitmap = new (std::nothrow) Bitmap(); + SysTryCatch(NID_UI_CTRL, pMergeBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pMergeBitmap->Construct(*pCanvas, bounds); + + if (__pItemAnnex == null) + { + __pItemAnnex = _Label::CreateLabelN(); + SysTryReturnVoidResult(NID_UI_CTRL, __pItemAnnex, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + int leftMargin = 0; + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + + leftMargin += __pDrawingProperty->scrollMargin; + int itemHeight = ((__customHeight > 0) ? __customHeight : GetBounds().height); + __pItemAnnex->SetBounds(Rectangle((GetBounds().width - annexWidth - leftMargin), ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); + __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); + + AttachSystemChild(*__pItemAnnex); + } + + __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap); + __pItemAnnex->Invalidate(); + +CATCH: + delete pDetail; + delete pDetailBg; + delete pDetailBgEffect; + delete pReplacementDetail; + delete pReplacementDetailBg; + delete pMergeBitmap; + delete pCanvas; + + return; +} + +void +_TableViewItem::DrawItemDivider(void) +{ + if (__pDrawingProperty->itemDividerEnabled == false || __itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER || __itemDividerEnabled == false) + { + if (__pItemDivider != null) + { + __pItemDivider->SetVisibleState(false); + } + + if (__pItemTopDivider != null) + { + __pItemTopDivider->SetVisibleState(false); + } + } + else if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE) + { + if (__pItemDivider == null) + { + __pItemDivider = _Label::CreateLabelN(); + SysTryReturnVoidResult(NID_UI_CTRL, __pItemDivider, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + AttachSystemChild(*__pItemDivider); + } + + Color underLineColor; + Rectangle bounds = GetBounds(); + int lineHeight = 0, lineLeftMargin = 0, lineBottomMargin = 0; + + if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL) + { + GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_NORMAL, underLineColor); + } + else + { + GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_PRESSED, underLineColor); + } + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineBottomMargin); + + __pItemDivider->SetBounds(Rectangle(lineLeftMargin, bounds.height - lineBottomMargin, bounds.width - lineLeftMargin * 2, lineHeight)); + __pItemDivider->SetBackgroundColor(underLineColor); + __pItemDivider->Invalidate(); + } + else + { + if (__pItemDivider == null) + { + __pItemDivider = _Label::CreateLabelN(); + SysTryReturnVoidResult(NID_UI_CTRL, __pItemDivider, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + AttachSystemChild(*__pItemDivider); + } + + Color dividerColor; + Rectangle bounds = GetBounds(); + int lineLeftMargin = 0, lineHeight = 0; + int groupIndex = -1, itemIndex = -1; + + GET_COLOR_CONFIG(TABLEVIEW::ITEM_DIVIDER_TOP_BG_NORMAL, dividerColor); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, lineLeftMargin); + GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, lineHeight); + + __pItemDivider->SetBounds(Rectangle(lineLeftMargin, (bounds.height - lineHeight), bounds.width - lineLeftMargin * 2, lineHeight)); + __pItemDivider->SetBackgroundColor(__pDrawingProperty->dividerColor); + __pItemDivider->Invalidate(); + + GetItemIndex(groupIndex, itemIndex); + if (itemIndex != 0) + { + if (__pItemTopDivider == null) + { + __pItemTopDivider = _Label::CreateLabelN(); + SysTryReturnVoidResult(NID_UI_CTRL, __pItemTopDivider, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + AttachSystemChild(*__pItemTopDivider); + } + __pItemTopDivider->SetBounds(Rectangle(lineLeftMargin, 0, bounds.width - lineLeftMargin * 2, lineHeight)); + __pItemTopDivider->SetBackgroundColor(dividerColor); + __pItemTopDivider->Invalidate(); + } + } + + if (__pItemDivider != null) + { + _AccessibilityContainer* pContainer = __pItemDivider->GetAccessibilityContainer(); + pContainer->Activate(false); + } + + if (__pItemTopDivider != null) + { + _AccessibilityContainer* pContainer = __pItemTopDivider->GetAccessibilityContainer(); + pContainer->Activate(false); + } +} + +result +_TableViewItem::DrawBitmap(Canvas& canvas, const Rectangle& bounds, const Bitmap& bitmap) +{ + result r = E_SUCCESS; + if (bitmap.IsNinePatchedBitmap()) + { + r = canvas.DrawNinePatchedBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Fail to draw ninepatched bitmap.", GetErrorMessage(r)) + } + else + { + r = canvas.DrawBitmap(bounds, bitmap); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Fail to draw bitmap.", GetErrorMessage(r)) + } + + return r; +} + +result +_TableViewItem::SetItemHighlightBounds(_VisualElement& highlightVisualElement, const Rectangle& bounds) +{ + FloatRectangle veBounds(bounds.x, bounds.y, bounds.width, bounds.height); + return highlightVisualElement.SetBounds(veBounds); +} + +Rectangle +_TableViewItem::CalculateItemHighlightBounds(void) +{ + int itemHighlightMargin = 0; + Rectangle itemBounds = GetBounds(); + Rectangle bounds; + + if (IsTitleStyleItem() == false) + { + GET_FIXED_VALUE_CONFIG(TABLEVIEW::ITEM_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, itemHighlightMargin); + } + bounds.SetBounds(0, itemHighlightMargin, itemBounds.width, itemBounds.height - itemHighlightMargin *2); + + return bounds; +} + +Rectangle +_TableViewItem::CalculateAnnexBitmapBounds(int annexWidth, int annexHeight, const Bitmap& bitmap) +{ + Rectangle bounds; + int width = 0, height = 0; + int leftMargin = 0, topMargin = 0; + + if (annexWidth > bitmap.GetWidth()) + { + leftMargin = (annexWidth - bitmap.GetWidth()) / 2; + width = bitmap.GetWidth(); + } + else + { + width = annexWidth; + } + + if(annexHeight > bitmap.GetHeight()) + { + topMargin = (annexHeight - bitmap.GetHeight()) / 2; + height = bitmap.GetHeight(); + } + else + { + height = annexHeight; + } + + bounds.SetBounds(leftMargin, topMargin, width, height); + + return bounds; +} + +bool +_TableViewItem::IsTitleStyleItem(void) const +{ + if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE || __itemType == TABLE_VIEW_ITEM_TYPE_HEADER || __itemType == TABLE_VIEW_ITEM_TYPE_FOOTER) + { + return true; + } + + return false; +} + +bool +_TableViewItem::IsValidSelectionState(void) +{ + _TableView* pParent = dynamic_cast<_TableView*>(GetParent()); + if (pParent == null) + { + return true; + } + + if (pParent->GetPressedItemCount() > 0) + { + return false; + } + + return true; +} + +void +_TableViewItem::DrawSimpleItem(void) +{ + if (__pSimpleItemText != null) + { + Color textColor = __simpleItemTextColor[__drawingStatus]; + if (!IsEnabled()) + { + textColor = __simpleItemTextColor[TABLE_VIEW_SIMPLEITEM_DRAWING_STATUS_DISABLED]; + } + + if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE) + { + if (__drawingStatus == TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL) + { + textColor = __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL]; + } + else + { + textColor = __simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED]; + } + } + + __pSimpleItemText->SetTextColor(textColor); + __pSimpleItemText->Invalidate(); + } +} +result +_TableViewItem::SetSimpleItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap, bool groupType) +{ + result r = E_SUCCESS; + bool textOnly = true; + + if (pBitmap != null) + { + textOnly = false; + } + + r = CreateSimpleItemContents(textOnly); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + Rectangle bitmapRect = Rectangle(0, 0, 0, 0); + Rectangle textRect = Rectangle(0, 0, 0, 0); + int elementWidth = 0; + int elementHeight = 0; + int leftMargin = 0; + int itemHeight = __itemHeight; + int annexWidth = GetAnnexWidth(__annexStyle); + + if (groupType) + { + if (__simpleItemTextSize == 0) + { + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __simpleItemTextSize); + } + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + } + else + { + if (__simpleItemTextSize == 0) + { + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __simpleItemTextSize); + } + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + } + + if (!textOnly) + { + elementWidth = itemHeight * SIMPLE_ITEM_ELEMENT_BITMAP_SIZE_RATIO; + elementHeight = elementWidth; + + bitmapRect.x = leftMargin; + bitmapRect.y = (itemHeight - elementHeight) / 2; + bitmapRect.width = elementWidth; + bitmapRect.height = elementHeight; + } + +// if (annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) +// { +// bitmapRect.x += annexWidth + leftMargin; +// } + + textRect.x = bitmapRect.x + elementWidth + leftMargin; + + if (annexWidth > 0) + { + elementWidth = __itemWidth - textRect.x - annexWidth - leftMargin; + } + else + { + elementWidth = __itemWidth - textRect.x; + } + + textRect.y = 0; + textRect.width = elementWidth; + textRect.height = itemHeight; + + if (__pSimpleItemBitmap != null && pBitmap != null) + { + __pSimpleItemBitmap->SetBackgroundBitmap(*pBitmap); + __pSimpleItemBitmap->SetBounds(bitmapRect); + + if (!__pSimpleItemBitmap->HasParent()) + { + r = AttachChild(*__pSimpleItemBitmap); + SysTryReturn(NID_UI_CTRL, __pSimpleItemBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + if (__pSimpleItemText != null) + { + __pSimpleItemText->SetTextConfig(__simpleItemTextSize, LABEL_TEXT_STYLE_NORMAL); + __pSimpleItemText->SetText(text); + __pSimpleItemText->SetBounds(textRect); + + if (!__pSimpleItemText->HasParent()) + { + r = AttachChild(*__pSimpleItemText); + SysTryReturn(NID_UI_CTRL, __pSimpleItemText != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + return E_SUCCESS; +} + +result +_TableViewItem::CreateSimpleItemContents(bool textOnly) +{ + result r = E_SUCCESS; + + if (__pSimpleItemText == null) + { + __pSimpleItemText = _Label::CreateLabelN(); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pSimpleItemText != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSimpleItemText->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + __pSimpleItemText->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + if (__itemType == TABLE_VIEW_ITEM_TYPE_TITLE) + { + __pSimpleItemText->SetTextColor(__simpleItemTextColor[TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL]); + } + else + { + __pSimpleItemText->SetTextColor(__simpleItemTextColor[TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL]); + } + __pSimpleItemText->SetBackgroundColor(Color(0, 0, 0, 0)); + + } + + if (!textOnly) + { + if (__pSimpleItemBitmap == null) + { + __pSimpleItemBitmap = _Label::CreateLabelN(); + SysTryReturn(NID_UI_CTRL, __pSimpleItemBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSimpleItemText->SetBackgroundColor(Color(0, 0, 0, 0)); + } + + } + else + { + if (__pSimpleItemBitmap != null) + { + delete __pSimpleItemBitmap; + __pSimpleItemBitmap = null; + } + } + + return E_SUCCESS; +} + +result +_TableViewItem::SetSimpleTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status) +{ + __simpleItemTextColor[status] = color; + + return E_SUCCESS; +} + +Tizen::Graphics::Color +_TableViewItem::GetSimpleItemTextColor(TableViewItemDrawingStatus status) const +{ + return __simpleItemTextColor[status]; +} + +result +_TableViewItem::SetSimpleItemTextSize(int size) +{ + __simpleItemTextSize = size; + + if (__pSimpleItemText != null) + { + __pSimpleItemText->SetTextConfig(__simpleItemTextSize, LABEL_TEXT_STYLE_NORMAL); + } + return E_SUCCESS; +} + +int +_TableViewItem::GetSimpleItemTextSize(void) const +{ + return __simpleItemTextSize; +} + +int +_TableViewItem::GetAnnexWidth(TableViewAnnexStyle style) +{ + int annexWidth = 0; + + switch (style) + { + case TABLE_VIEW_ANNEX_STYLE_NORMAL: + annexWidth = 0; + break; + + case TABLE_VIEW_ANNEX_STYLE_MARK: + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + break; + + case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING: + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + break; + + case TABLE_VIEW_ANNEX_STYLE_DETAILED: + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + break; + + case TABLE_VIEW_ANNEX_STYLE_RADIO: + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + break; + + default: + break; + } + + return annexWidth; +} + +void +_TableViewItem::SetDrawingStatus(TableViewItemDrawingStatus status) +{ + __drawingStatus = status; +} + +TableViewItemDrawingStatus +_TableViewItem::GetDrawingStatus(void) +{ + return __drawingStatus; +} + +void +_TableViewItem::AdjustChildControlMargin(void) +{ + if (__childMarginState) + { + return; + } + + if (IsTitleStyleItem()) + { + return; + } + + __childMarginState = true; + + int margin = 0; + + if (__pDrawingProperty->groupedLookEnabled) + { + int groupedBarMargin = 0; + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_BAR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, groupedBarMargin); + + margin = margin + groupedBarMargin; + } + + if (margin > 0) + { + _VisualElement* pVisualElement = GetVisualElement(); + + if (pVisualElement != null) + { + FloatPoint position; + + position.SetPosition(margin, 0.0f); + pVisualElement->ScrollByPoint(position, false); + } + } +} + +void +_TableViewItem::AdjustContextItemBounds(void) +{ + _TableViewItem* pContextItem = GetContextItem(); + + if (pContextItem == null) + { + return; + } + + Dimension contextItemSize = pContextItem->GetSize(); + Dimension itemSize = GetSize(); + + if (contextItemSize.height != itemSize.height) + { + contextItemSize.height = itemSize.height; + + pContextItem->SetSize(contextItemSize); + } + + pContextItem->AdjustChildControlCenterAlign(); +} + +void +_TableViewItem::AdjustAnnexBounds(void) +{ + if (__pItemAnnex == null) + { + return; + } + + // h align + if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || __annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED) + { + if (__pItemAnnex->HasParent()) + { + Rectangle annexBounds = __pItemAnnex->GetBounds(); + int annexPositionX = annexBounds.x; + int leftMargin = 0; + + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + leftMargin += __pDrawingProperty->scrollMargin; + + annexPositionX = GetBounds().width - annexBounds.width - leftMargin; + + if (annexPositionX != annexBounds.x) + { + __pItemAnnex->SetPosition(Point(annexPositionX, annexBounds.y)); + } + } + } + + // v align + Rectangle itemBounds = GetBounds(); + Rectangle annexBounds = __pItemAnnex->GetBounds(); + + if (__customHeight > 0) + { + itemBounds.height = __customHeight; + } + + annexBounds.y = (itemBounds.height - annexBounds.height) / 2; + __pItemAnnex->SetPosition(Point(annexBounds.x, annexBounds.y)); +} + +void +_TableViewItem::SetItemCustomHeight(int height) +{ + __customHeight = height; +} + +void +_TableViewItem::AdjustChildControlCenterAlign(void) +{ + if (__childControlCenterAlign) + { + Dimension itemSize = GetSize(); + + int childControlCount = GetChildCount(); + + for (int i = 0; i < childControlCount; i++) + { + _Control* pChildControl = GetChild(i); + + if (pChildControl == null) + { + continue; + } + + if (__pItemDivider == pChildControl) + { + int positionX = pChildControl->GetPosition().x; + pChildControl->SetPosition(Point(positionX, itemSize.height - 1)); + continue; + } + + if (__pItemTopDivider == pChildControl) + { + int positionX = pChildControl->GetPosition().x; + pChildControl->SetPosition(Point(positionX, 0)); + continue; + } + + Rectangle itemBounds = pChildControl->GetBounds(); + + itemBounds.y = (itemSize.height - itemBounds.height) / 2; + + pChildControl->SetPosition(Point(itemBounds.x, itemBounds.y)); + } + } +} + +void +_TableViewItem::SetChildControlCenterAlign(bool centerAlign) +{ + __childControlCenterAlign = centerAlign; +} + +Point +_TableViewItem::GetLastTouchPressedPosition(void) +{ + return __touchStartPosition; +} + +void +_TableViewItem::SetLastTouchPressedPosition(Point position) +{ + // This function was made to modify of ListView::RefreshList(). + // This function could adversely affect touch event handling. So, you should be used with caution. + __touchStartPosition = position; +} + +bool +_TableViewItem::GetSelectionState(void) +{ + return __itemSelected; +} + +void +_TableViewItem::SetSelectionState(bool selected) +{ + // This function was made to modify of ListView::RefreshList(). + // This function could adversely affect touch event handling. So, you should be used with caution. + __itemSelected = selected; +} + +bool +_TableViewItem::MoveItem(Point position, int duration, int delay, Tizen::Base::String* pName) +{ + _VisualElement* pVisualElement = GetVisualElement(); + + String animationName = L"MoveTableViewItem"; + + VisualElementValueAnimation* pAnimation = dynamic_cast(pVisualElement->GetAnimationN(animationName)); + + if (pAnimation != null) + { + pVisualElement->RemoveAnimation(animationName); + } + + pAnimation = new (std::nothrow) VisualElementValueAnimation(); + SysTryReturn(NID_UI_CTRL, pAnimation, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pAnimation->SetDuration(duration); + pAnimation->SetDelay(delay); + pAnimation->SetStartValue(Variant(GetPosition())); + pAnimation->SetEndValue(Variant(position)); + pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseInOut")); + pAnimation->SetVisualElementAnimationStatusEventListener(this); + pAnimation->SetVisualElementAnimationTickEventListener(this); + if (pName != null) + { + String* pUserData = new (std::nothrow) String(*pName); + SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + if (pUserData != null) + { + pAnimation->SetUserData((void*)pUserData); + } + } + + if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS) + { + return false; + } + + delete pAnimation; + + __animationCount++; + + return true; + +CATCH: + delete pAnimation; + + return false; +} + +bool +_TableViewItem::ZoomInOutItem(bool zoomOut, int duration, int delay, Tizen::Base::String* pName) +{ + _VisualElement* pVisualElement = GetVisualElement(); + + String animationName = L"ZoomInOutTableViewItem"; + + VisualElementValueAnimation* pAnimation = dynamic_cast(pVisualElement->GetAnimationN(animationName)); + + if (pAnimation != null) + { + pVisualElement->RemoveAnimation(animationName); + } + + pAnimation = new (std::nothrow) VisualElementValueAnimation(); + SysTryReturn(NID_UI_CTRL, pAnimation, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + Dimension itemSize = GetSize(); + Dimension startValue; + Dimension endValue; + + if (zoomOut) + { + startValue = itemSize; + endValue = Dimension(itemSize.width, itemSize.height / 2); + pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseOut")); + } + else + { + startValue = Dimension(itemSize.width, itemSize.height / 2); + endValue = itemSize; + pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseIn")); + } + + pAnimation->SetDuration(duration); + pAnimation->SetDelay(delay); + pAnimation->SetStartValue(Variant(startValue)); + pAnimation->SetEndValue(Variant(endValue)); + pAnimation->SetVisualElementAnimationStatusEventListener(this); + pAnimation->SetVisualElementAnimationTickEventListener(this); + + if (pName != null) + { + String* pUserData = new (std::nothrow) String(*pName); + SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + if (pUserData != null) + { + pAnimation->SetUserData((void*)pUserData); + } + } + + if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS) + { + return false; + } + + delete pAnimation; + + __animationCount++; + + return true; + +CATCH: + delete pAnimation; + + return false; +} + +bool +_TableViewItem::FadeInOutItem(bool fadeOut, int duration, int delay, Tizen::Base::String* pName) +{ + _VisualElement* pVisualElement = GetVisualElement(); + + String animationName = L"FadeInOutTableViewItem";; + + VisualElementValueAnimation* pAnimation = dynamic_cast(pVisualElement->GetAnimationN(animationName)); + + if (pAnimation != null) + { + pVisualElement->RemoveAnimation(animationName); + } + + pAnimation = new (std::nothrow) VisualElementValueAnimation(); + SysTryReturn(NID_UI_CTRL, pAnimation, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + float startValue = 0.0f; + float endValue = 1.0f; + + if (fadeOut) + { + startValue = 1.0f; + endValue = 0.0f; + pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseOut")); + } + else + { + pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseIn")); + } + + pAnimation->SetDuration(duration); + pAnimation->SetDelay(delay); + pAnimation->SetStartValue(Variant(startValue)); + pAnimation->SetEndValue(Variant(endValue)); + pAnimation->SetVisualElementAnimationStatusEventListener(this); + pAnimation->SetVisualElementAnimationTickEventListener(this); + if (pName != null) + { + String* pUserData = new (std::nothrow) String(*pName); + SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + if (pUserData != null) + { + pAnimation->SetUserData((void*)pUserData); + } + } + + if (pVisualElement->AddAnimation(animationName, *pAnimation) != E_SUCCESS) + { + return false; + } + + delete pAnimation; + + __animationCount++; + + return true; + +CATCH: + delete pAnimation; + + return false; +} + +result +_TableViewItem::SetIndividualSelectionEnabled(const _Control& control, bool enable) +{ + result r = E_SUCCESS; + if (enable) + { + if (!__individualSelectionControls.Contains(control)) + { + r = __individualSelectionControls.Add(control); + } + + _AccessibilityContainer* pContainer = const_cast<_Control*>(&control)->GetAccessibilityContainer(); + pContainer->Activate(true); + } + else + { + if (__individualSelectionControls.Contains(control)) + { + r = __individualSelectionControls.Remove(control, false); + } + } + return r; +} + +bool +_TableViewItem::IsIndividualSelectionEnabled(const _Control& control) +{ + return __individualSelectionControls.Contains(control); +} + +int +_TableViewItem::AddRef(void) +{ + return ++__refCount; +} + +int +_TableViewItem::Release(void) +{ + --__refCount; + if (__refCount <= 0) + { + delete this; + return 0; + } + + return __refCount; +} + +bool +_TableViewItem::IsAnimationPlaying(void) +{ + if (__animationCount > 0) + { + return true; + } + + return false; +} + +void +_TableViewItem::StopAllAnimation(void) +{ + _VisualElement* pVisualElement = GetVisualElement(); + + pVisualElement->RemoveAllAnimations(); +} + +void +_TableViewItem::SetItemDividerEnabled(bool enable) +{ + __itemDividerEnabled = enable; +} + +void +_TableViewItem::OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue) +{ + if (keyName == L"MoveTableViewItem") + { + Point position = currentValue.ToPoint(); + SetPosition(position); + } + else if (keyName == L"FadeInOutTableViewItem") + { + float opacity = currentValue.ToFloat(); + + _VisualElement* pVisualElement = GetVisualElement(); + + if (pVisualElement != null) + { + pVisualElement->SetOpacity(opacity); + } + } + else if (keyName == L"ZoomInOutTableViewItem") + { + Dimension size = currentValue.ToDimension(); + + SetSize(size); + } +} + +void +_TableViewItem::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target) +{ +} + +void +_TableViewItem::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount) +{ +} + +void +_TableViewItem::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally) +{ + if (!completedNormally) + { + __animationCount--; + return; + } + + bool tableViewItemAnimation = true; + const VisualElementValueAnimation *pAnimation = dynamic_cast(&(animation)); + + if (keyName == L"MoveTableViewItem") + { + if (pAnimation != null) + { + Point position = pAnimation->GetEndValue().ToPoint(); + + SetPosition(position); + } + } + else if (keyName == L"FadeInOutTableViewItem") + { + if (pAnimation != null) + { + float opacity = pAnimation->GetEndValue().ToFloat(); + + _VisualElement* pVisualElement = GetVisualElement(); + + if (pVisualElement != null) + { + pVisualElement->SetOpacity(opacity); + Invalidate(); + } + } + } + else if (keyName == L"ZoomInOutTableViewItem") + { + if (pAnimation != null) + { + Dimension size = pAnimation->GetEndValue().ToDimension(); + + SetSize(size); + } + } + else + { + tableViewItemAnimation = false; + } + + if (tableViewItemAnimation) + { + __animationCount--; + } + + return; +} + +void +_TableViewItem::SetAccessibilityElement(void) +{ + if(__pAccessibilityElement) + { + return ; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + + if(pContainer) + { + __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + __pAccessibilityElement->SetBounds(Rectangle(0,0, GetBounds().width, GetBounds().height)); + __pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_NONE); + __pAccessibilityElement->SetName(L"TableViewItem"); + + pContainer->AddElement(*__pAccessibilityElement); + } +} + +bool +_TableViewItem::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_TableViewItem::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_TableViewItem::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + String accessibilityLable; + int childControlCount = GetChildCount(); + + for (int i = 0; i < childControlCount; i++) + { + _Control* pChildControl = GetChild(i); + + if (pChildControl == null) + { + continue; + } + + if (__pItemDivider == pChildControl || __pItemTopDivider == pChildControl) + { + continue; + } + + if (!IsIndividualSelectionEnabled(*pChildControl)) + { + _AccessibilityContainer* pContainer = pChildControl->GetAccessibilityContainer(); + LinkedListT<_AccessibilityElement*> accessibilityElements; + _AccessibilityElement* pElement = null; + + pContainer->GetElements(accessibilityElements); + pContainer->Activate(false); + int elementCount = accessibilityElements.GetCount(); + + for (int i = 0; i < elementCount; i++) + { + if (accessibilityElements.GetAt(i, pElement) == E_SUCCESS) + { + accessibilityLable += pElement->GetLabel(); + } + } + } + } + + __pAccessibilityElement->SetLabel(accessibilityLable); + + return false; +} + +bool +_TableViewItem::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_TableViewItem::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} + +bool +_TableViewItem::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} +bool +_TableViewItem::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} +bool +_TableViewItem::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) +{ + return false; +} +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_TableViewItemEvent.cpp b/src/ui/controls/FUiCtrl_TableViewItemEvent.cpp new file mode 100644 index 0000000..99e534a --- /dev/null +++ b/src/ui/controls/FUiCtrl_TableViewItemEvent.cpp @@ -0,0 +1,485 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUiCtrl_TableViewItem.h" +#include "FUiCtrl_TableViewItemEvent.h" +#include "FUiCtrl_TableViewItemEventArg.h" + + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_TableViewItemEvent::_TableViewItemEvent(void) + : __pSource(null) + , __invokeTableViewItemCallback(true) + , __style(TABLE_VIEW_STYLE_SIMPLE) +{ + // nothing +} + +_TableViewItemEvent::~_TableViewItemEvent(void) +{ + // nothing +} + +result +_TableViewItemEvent::Construct(Tizen::Ui::Control* pSource, TableViewStyle style) +{ + result r = _Event::Initialize(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Could not construct TableViewItemEvent!"); + + __pSource = pSource; + + __style = style; + + return r; +} + +Tizen::Ui::Control* +_TableViewItemEvent::GetSource(void) const +{ + return __pSource; +} + +void +_TableViewItemEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to _ItemEventArg + _TableViewItemEventArg* pEventArg = dynamic_cast<_TableViewItemEventArg*>(const_cast(&arg)); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_INVALID_ARG, ("[E_INVALID_ARG] event argument is invalid type.")); + + int index1 = pEventArg->GetArg1(); + int index2 = pEventArg->GetArg2(); +// int index3 = pEventArg->GetArg3(); +// int index4 = pEventArg->GetArg4(); + + bool activated = pEventArg->GetActivated(); + bool tempInvokeTableViewItemCallback = __invokeTableViewItemCallback; + __invokeTableViewItemCallback = true; + + if (index2 < 0) + { + index2 = -1; + } + + switch (pEventArg->GetNotifyType()) + { + case TABLEVIEW_NOTIFY_TYPE_SELECTED_ITEM: + if (tempInvokeTableViewItemCallback == true) + { + _TableViewItem* pItem = pEventArg->GetItem(); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_ARG, ("[E_INVALID_ARG] event argument is invalid type.")); + TableViewItemBase* pItemBase = static_cast(pItem->GetAppInfo()); + + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + ITableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + TableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnTableViewItemStateChanged(*pTableView, index1, pItem, TABLE_VIEW_ITEM_STATUS_SELECTED); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + IGroupedTableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + GroupedTableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (index2 == -1) + { + TableViewGroupItem* pGroupItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pGroupItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnGroupedTableViewGroupItemStateChanged(*pTableView, index1, pGroupItem, TABLE_VIEW_ITEM_STATUS_SELECTED); + } + else + { + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnGroupedTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_SELECTED); + } + } + else + { + ISectionTableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + SectionTableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnSectionTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_SELECTED); + } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_HIGHLIGHED_ITEM: + if (tempInvokeTableViewItemCallback == true) + { + _TableViewItem* pItem = pEventArg->GetItem(); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_ARG, ("[E_INVALID_ARG] event argument is invalid type.")); + TableViewItemBase* pItemBase = static_cast(pItem->GetAppInfo()); + + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + ITableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + TableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnTableViewItemStateChanged(*pTableView, index1, pItem, TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + IGroupedTableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + GroupedTableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (index2 == -1) + { + TableViewGroupItem* pGroupItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pGroupItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnGroupedTableViewGroupItemStateChanged(*pTableView, index1, pGroupItem, TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED); + } + else + { + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnGroupedTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED); + } + } + else + { + ISectionTableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + SectionTableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnSectionTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED); + } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_ANNEX_CHECK: + if (tempInvokeTableViewItemCallback == true) + { + _TableViewItem* pItem = pEventArg->GetItem(); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_ARG, ("[E_INVALID_ARG] event argument is invalid type.")); + TableViewItemBase* pItemBase = static_cast(pItem->GetAppInfo()); + + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + ITableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + TableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnTableViewItemStateChanged(*pTableView, index1, pItem, TABLE_VIEW_ITEM_STATUS_CHECKED); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + IGroupedTableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + GroupedTableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (index2 == -1) + { + TableViewGroupItem* pGroupItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pGroupItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnGroupedTableViewGroupItemStateChanged(*pTableView, index1, pGroupItem, TABLE_VIEW_ITEM_STATUS_CHECKED); + } + else + { + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnGroupedTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_CHECKED); + } + } + else + { + ISectionTableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + SectionTableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnSectionTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_CHECKED); + } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_ANNEX_UNCHECK: + if (tempInvokeTableViewItemCallback == true) + { + _TableViewItem* pItem = pEventArg->GetItem(); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_ARG, ("[E_INVALID_ARG] event argument is invalid type.")); + TableViewItemBase* pItemBase = static_cast(pItem->GetAppInfo()); + + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + ITableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + TableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnTableViewItemStateChanged(*pTableView, index1, pItem, TABLE_VIEW_ITEM_STATUS_UNCHECKED); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + IGroupedTableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + GroupedTableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (index2 == -1) + { + TableViewGroupItem* pGroupItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pGroupItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + pItemListener->OnGroupedTableViewGroupItemStateChanged(*pTableView, index1, pGroupItem, TABLE_VIEW_ITEM_STATUS_UNCHECKED); + } + else + { + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnGroupedTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_UNCHECKED); + } + } + else + { + ISectionTableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + SectionTableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnSectionTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_UNCHECKED); + } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_ANNEX_MORE: + if (tempInvokeTableViewItemCallback == true) + { + _TableViewItem* pItem = pEventArg->GetItem(); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_ARG, ("[E_INVALID_ARG] event argument is invalid type.")); + TableViewItemBase* pItemBase = static_cast(pItem->GetAppInfo()); + + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + ITableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + TableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnTableViewItemStateChanged(*pTableView, index1, pItem, TABLE_VIEW_ITEM_STATUS_MORE); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + IGroupedTableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + GroupedTableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (index2 == -1) + { + TableViewGroupItem* pGroupItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pGroupItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnGroupedTableViewGroupItemStateChanged(*pTableView, index1, pGroupItem, TABLE_VIEW_ITEM_STATUS_MORE); + } + else + { + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnGroupedTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_MORE); + } + } + else + { + ISectionTableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + SectionTableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + TableViewItem* pItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnSectionTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_MORE); + } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_ITEM_SWEPT: +// if (tempInvokeTableViewItemCallback == true) +// { +// if (index3 == TABLE_VIEW_SWEEP_DIRECTION_LEFT) +// { +// pItemListener->OnTableViewItemSwept(*pTableView, itemTag, TABLE_VIEW_SWEEP_DIRECTION_LEFT); +// } +// else +// { +// pItemListener->OnTableViewItemSwept(*pTableView, itemTag, TABLE_VIEW_SWEEP_DIRECTION_RIGHT); +// } +// } + break; + + case TABLEVIEW_NOTIFY_TYPE_TOUCH_LONG_PRESSED: +// pItemListener->OnTableViewItemLongPressed(*pTableView, itemTag, __invokeTableViewItemCallback); + break; + + case TABLEVIEW_NOTIFY_TYPE_REORDERED_ITEM: + if (tempInvokeTableViewItemCallback == true) + { + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + ITableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + TableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnTableViewItemReordered(*pTableView, index1, index2); + } +// else if (__style == TABLE_VIEW_STYLE_GROUPED) +// { +// IGroupedTableViewItemEventListener* pItemListener = dynamic_cast(&listener); +// SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); +// +// GroupedTableView* pTableView = dynamic_cast(GetSource()); +// SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); +// +// pItemListener->OnGroupedTableViewItemReordered(*pTableView, index1, index2, index3, index4); +// } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_CONTEXT_ITEM_ACTIVATION: + if (tempInvokeTableViewItemCallback == true) + { + _TableViewItem* pItem = pEventArg->GetItem(); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_ARG, ("[E_INVALID_ARG] event argument is invalid type.")); + TableViewItemBase* pItemBase = static_cast(pItem->GetAppInfo()); + + TableViewContextItem* pContextItem = dynamic_cast(pItemBase); + SysTryReturnVoidResult(NID_UI_CTRL, pContextItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + ITableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + TableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnTableViewContextItemActivationStateChanged(*pTableView, index1, pContextItem, activated); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + IGroupedTableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + GroupedTableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnGroupedTableViewContextItemActivationStateChanged(*pTableView, index1, index2, pContextItem, activated); + } + else + { + ISectionTableViewItemEventListener* pItemListener = dynamic_cast(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + SectionTableView* pTableView = dynamic_cast(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + pItemListener->OnSectionTableViewContextItemActivationStateChanged(*pTableView, index1, index2, pContextItem, activated); + } + } + break; + + default: + return; + } + + return; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_TableViewItemEventArg.cpp b/src/ui/controls/FUiCtrl_TableViewItemEventArg.cpp new file mode 100644 index 0000000..fb54901 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TableViewItemEventArg.cpp @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include "FUiCtrl_TableViewItemEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_TableViewItemEventArg::_TableViewItemEventArg(int arg1, int arg2, int arg3, int arg4, _TableViewItem* pItem, TableViewNotifyType type, bool activated) + : __arg1(arg1) + , __arg2(arg2) + , __arg3(arg3) + , __arg4(arg4) + , __pItem(pItem) + , __type(type) + , __activated(activated) +{ + // nothing +} + +_TableViewItemEventArg::~_TableViewItemEventArg(void) +{ + // nothing +} + +int +_TableViewItemEventArg::GetArg1(void) const +{ + return __arg1; +} + +int +_TableViewItemEventArg::GetArg2(void) const +{ + return __arg2; +} + +int +_TableViewItemEventArg::GetArg3(void) const +{ + return __arg3; +} + +int +_TableViewItemEventArg::GetArg4(void) const +{ + return __arg4; +} + +_TableViewItem* +_TableViewItemEventArg::GetItem(void) const +{ + return __pItem; +} + +TableViewNotifyType +_TableViewItemEventArg::GetNotifyType(void) const +{ + return __type; +} + +bool +_TableViewItemEventArg::GetActivated(void) const +{ + return __activated; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TableViewItemImpl.cpp b/src/ui/controls/FUiCtrl_TableViewItemImpl.cpp new file mode 100644 index 0000000..db80d76 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TableViewItemImpl.cpp @@ -0,0 +1,343 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewItemImpl.cpp + * @brief This is the implementation file for _TableViewItemImpl class. + * + * This file contains the implementation of _TableViewItemImpl class. + */ + +#include +#include +#include "FUiCtrl_TableViewItemImpl.h" +#include "FUiCtrl_TableViewItem.h" +#include "FUi_LayoutImpl.h" +#include "FUi_ResourceManager.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Tizen::Graphics::Dimension +_TableViewItemImpl::TableViewItemSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + return Dimension(0, 0); +} + +_TableViewItemImpl* +_TableViewItemImpl::GetInstance(TableViewItemBase& tableViewItem) +{ + return static_cast <_TableViewItemImpl*>(tableViewItem._pControlImpl); +} + +const _TableViewItemImpl* +_TableViewItemImpl::GetInstance(const TableViewItemBase& tableViewItem) +{ + return static_cast (tableViewItem._pControlImpl); +} + +_TableViewItemImpl::_TableViewItemImpl(TableViewItemBase* pPublic, _TableViewItem* pCore, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout) + : _ContainerImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout) +{ +} + +_TableViewItemImpl::~_TableViewItemImpl(void) +{ + +} + +const char* +_TableViewItemImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::TableViewItem"; +} + +const TableViewItem& +_TableViewItemImpl::GetPublic(void) const +{ + return static_cast (_ContainerImpl::GetPublic()); +} + +TableViewItem& +_TableViewItemImpl::GetPublic(void) +{ + return static_cast (_ContainerImpl::GetPublic()); +} + +const _TableViewItem& +_TableViewItemImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_TableViewItem& +_TableViewItemImpl::GetCore(void) +{ + return static_cast <_TableViewItem&>(_ControlImpl::GetCore()); +} + +_TableViewItemImpl* +_TableViewItemImpl::CreateTableViewItemImplN(TableViewItemBase* pPublic, const Dimension& itemSize, const TableViewAnnexStyle style, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout) +{ + result r = E_SUCCESS; + + r = GET_SIZE_INFO(TableViewItem).CheckInitialSizeValid(Dimension(itemSize.width, itemSize.height), _CONTROL_ORIENTATION_PORTRAIT); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (pPublicPortraitLayout != null) + { + _LayoutImpl* pPortraitLayoutImpl = _LayoutImpl::GetInstance(*pPublicPortraitLayout); + SysTryReturn(NID_UI_CTRL, pPortraitLayoutImpl != null, null, E_INVALID_ARG, "[E_INVALID_ARG] Portrait layout is invalid object"); + } + + if (pPublicLandscapeLayout != null) + { + _LayoutImpl* pLandscapeLayoutImpl = _LayoutImpl::GetInstance(*pPublicLandscapeLayout); + SysTryReturn(NID_UI_CTRL, pLandscapeLayoutImpl != null, null, E_INVALID_ARG, "[E_INVALID_ARG] Landscape layout is invalid object"); + } + + _TableViewItem* pCore = _TableViewItem::CreateTableViewItemN(itemSize.height); + SysTryReturn(NID_UI_CTRL, pCore != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _TableViewItemImpl* pImpl = new (std::nothrow) _TableViewItemImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout); + SysTryReturn(NID_UI_CTRL, pImpl != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = pImpl->Construct(itemSize, style); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pImpl->SetSize(itemSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; + +CATCH: + delete pImpl; + delete pCore; + return null; +} + + +result +_TableViewItemImpl::Construct(const Dimension& itemSize, const TableViewAnnexStyle style) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, (itemSize.width >= 0 && itemSize.height >= 0), E_INVALID_ARG, E_INVALID_ARG, ("[E_INVALID_ARG] The item size should be greater than 0")); + + GetCore().SetItemStyle(style); + GetCore().SetItemWidth(itemSize.width); + + return r; +} + +result +_TableViewItemImpl::SetContextItem(_TableViewItemImpl* pItem) +{ + if (pItem == null) + { + GetCore().SetContextItem(null); + return E_SUCCESS; + } + + GetCore().SetContextItem(&pItem->GetCore()); + + _TableViewItemImpl* pItemImpl = pItem; + + TableViewContextItem* pContextItem = static_cast (&pItemImpl->_ContainerImpl::GetPublic()); + pItemImpl->GetCore().SetAppInfo(pContextItem); + + return E_SUCCESS; +} + +result +_TableViewItemImpl::SetSelectionStyle(TableViewItemSelectionStyle style) +{ + return GetCore().SetSelectionStyle(style); +} + +TableViewItemSelectionStyle +_TableViewItemImpl::GetSelectionStyle(void) const +{ + return GetCore().GetSelectionStyle(); +} + +result +_TableViewItemImpl::SetBackgroundBitmap(TableViewItemDrawingStatus status, const Bitmap* pBitmap) +{ + SysTryReturn(NID_UI_CTRL, pBitmap, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] It is invalid argument"); + + ListItemState itemState; + + switch (status) + { + case TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL: + itemState = LIST_ITEM_STATE_NORMAL; + break; + + case TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED: + itemState = LIST_ITEM_STATE_PRESSED; + break; + + case TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED: + itemState = LIST_ITEM_STATE_HIGHLIGHTED; + break; + + default: + return E_SYSTEM; + } + + GetCore().SetItemBackgroundBitmap(itemState, pBitmap); + + return E_SUCCESS; +} + +result +_TableViewItemImpl::SetBackgroundColor(TableViewItemDrawingStatus status, const Color& color) +{ + ListItemState itemState; + + switch (status) + { + case TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL: + itemState = LIST_ITEM_STATE_NORMAL; + break; + + case TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED: + itemState = LIST_ITEM_STATE_PRESSED; + break; + + case TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED: + itemState = LIST_ITEM_STATE_HIGHLIGHTED; + break; + + default: + return E_SYSTEM; + } + + GetCore().SetItemBackgroundColor(itemState, color); + + return E_SUCCESS; +} + +Color +_TableViewItemImpl::GetBackgroundColor(TableViewItemDrawingStatus status) const +{ + ListItemState itemState; + switch (status) + { + case TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL: + itemState = LIST_ITEM_STATE_NORMAL; + break; + + case TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED: + itemState = LIST_ITEM_STATE_PRESSED; + break; + + case TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED: + itemState = LIST_ITEM_STATE_HIGHLIGHTED; + break; + + default: + return Color(0); + } + + return GetCore().GetItemBackgroundColor(itemState); +} + +result +_TableViewItemImpl::SetSimpleItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap, bool groupType) +{ + return GetCore().SetSimpleItemContents(text, pBitmap, groupType); +} + +result +_TableViewItemImpl::SetSimpleItemTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status) +{ + return GetCore().SetSimpleTextColor(color, status); +} + +Tizen::Graphics::Color +_TableViewItemImpl::GetSimpleItemTextColor(TableViewItemDrawingStatus status) const +{ + return GetCore().GetSimpleItemTextColor(status); +} + +result +_TableViewItemImpl::SetSimpleItemTextSize(int size) +{ + return GetCore().SetSimpleItemTextSize(size); +} + +int +_TableViewItemImpl::GetSimpleItemTextSize(void) const +{ + return GetCore().GetSimpleItemTextSize(); +} + +int +_TableViewItemImpl::GetAnnexWidth(TableViewAnnexStyle style) +{ + int annexWidth = 0; + + switch (style) + { + case TABLE_VIEW_ANNEX_STYLE_NORMAL: + annexWidth = 0; + break; + + case TABLE_VIEW_ANNEX_STYLE_MARK: + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + break; + + case TABLE_VIEW_ANNEX_STYLE_RADIO: + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + break; + + case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING: + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + break; + + case TABLE_VIEW_ANNEX_STYLE_DETAILED: + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + break; + + default: + break; + } + + return annexWidth; +} + +result +_TableViewItemImpl::SetIndividualSelectionEnabled(const Tizen::Ui::_ControlImpl& controlImpl, bool enable) +{ + return GetCore().SetIndividualSelectionEnabled(controlImpl.GetCore(), enable); +} + +bool +_TableViewItemImpl::IsIndividualSelectionEnabled(const Tizen::Ui::_ControlImpl& controlImpl) +{ + return GetCore().IsIndividualSelectionEnabled(controlImpl.GetCore()); +} + + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TableViewItemProvider.cpp b/src/ui/controls/FUiCtrl_TableViewItemProvider.cpp new file mode 100644 index 0000000..61569bc --- /dev/null +++ b/src/ui/controls/FUiCtrl_TableViewItemProvider.cpp @@ -0,0 +1,440 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewItemProvider.cpp + * @brief This file implements the _TableViewItemProvider class. + * @version 3.0 + */ + +#include +#include +#include +#include +#include +#include +#include "FUiCtrl_TableViewItemProvider.h" +#include "FUi_ResourceManager.h" + +using namespace Tizen::Base; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_TableViewItemProvider::_TableViewItemProvider(TableViewStyle style) + : __pSimpleProvider(null) + , __pGroupedProvider(null) + , __pSectionProvider(null) + , __style(style) + , __onProcessing(false) +{ + +} + +_TableViewItemProvider::~_TableViewItemProvider(void) +{ + __pSimpleProvider = null; + __pGroupedProvider = null; + __pSectionProvider = null; +} + +_TableViewItemProvider* +_TableViewItemProvider::CreateTableViewItemProviderN(TableViewStyle style) +{ + ClearLastResult(); + + _TableViewItemProvider* pProvider = new (std::nothrow) _TableViewItemProvider(style); + SysTryReturn(NID_UI_CTRL, pProvider != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pProvider; +} + +result +_TableViewItemProvider::SetSimpleStyleItemProvider(ITableViewItemProvider* pProvider) +{ + SysTryReturn(NID_UI_CTRL, __style == TABLE_VIEW_STYLE_SIMPLE, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SECTION"); + + __pSimpleProvider = pProvider; + + return E_SUCCESS; +} + +result +_TableViewItemProvider::SetGroupedStyleItemProvider(IGroupedTableViewItemProvider* pProvider) +{ + SysTryReturn(NID_UI_CTRL, __style == TABLE_VIEW_STYLE_GROUPED, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SECTION"); + + __pGroupedProvider = pProvider; + + return E_SUCCESS; +} + +result +_TableViewItemProvider::SetSectionStyleItemProvider(ISectionTableViewItemProvider* pProvider) +{ + SysTryReturn(NID_UI_CTRL, __style == TABLE_VIEW_STYLE_SECTION, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SECTION"); + + __pSectionProvider = pProvider; + + return E_SUCCESS; +} + +int +_TableViewItemProvider::GetGroupCount(void) +{ + int count = 0; + __onProcessing = true; + + switch (__style) + { + case TABLE_VIEW_STYLE_SIMPLE: + count = 1; + break; + + case TABLE_VIEW_STYLE_GROUPED: + count = __pGroupedProvider->GetGroupCount(); + break; + + case TABLE_VIEW_STYLE_SECTION: + count = __pSectionProvider->GetSectionCount(); + break; + } + + __onProcessing = false; + + return count; +} + +int +_TableViewItemProvider::GetItemCount(int groupIndex) +{ + int count = 0; + + __onProcessing = true; + + switch (__style) + { + case TABLE_VIEW_STYLE_SIMPLE: + count = __pSimpleProvider->GetItemCount(); + break; + + case TABLE_VIEW_STYLE_GROUPED: + count = __pGroupedProvider->GetItemCount(groupIndex); + break; + + case TABLE_VIEW_STYLE_SECTION: + count = __pSectionProvider->GetItemCount(groupIndex); + break; + } + + __onProcessing = false; + + return count; +} + +int +_TableViewItemProvider::GetGroupItemHeight(int groupIndex) +{ + return GetDefaultGroupItemHeight(); +} + +int +_TableViewItemProvider::GetItemHeight(const TableViewItemTag& itemTag) +{ + return GetDefaultItemHeight(); +} + +int +_TableViewItemProvider::GetDefaultItemHeight(void) +{ + int height = 0; + + __onProcessing = true; + + switch (__style) + { + case TABLE_VIEW_STYLE_SIMPLE: + height = __pSimpleProvider->GetDefaultItemHeight(); + break; + + case TABLE_VIEW_STYLE_GROUPED: + height = __pGroupedProvider->GetDefaultItemHeight(); + break; + + case TABLE_VIEW_STYLE_SECTION: + height = __pSectionProvider->GetDefaultItemHeight(); + break; + } + + __onProcessing = false; + + return height; +} +int +_TableViewItemProvider::GetDefaultGroupItemHeight(void) +{ + int height = 0; + + __onProcessing = true; + + switch (__style) + { + case TABLE_VIEW_STYLE_SIMPLE: + height = 0; + break; + + case TABLE_VIEW_STYLE_GROUPED: + height = __pGroupedProvider->GetDefaultGroupItemHeight(); + break; + + case TABLE_VIEW_STYLE_SECTION: + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, height); + break; + } + + __onProcessing = false; + + return height; +} + + +TableViewGroupItem* +_TableViewItemProvider::CreateGroupItem(int groupIndex, int itemWidth) +{ + TableViewGroupItem* pItem = null; + + __onProcessing = true; + + switch (__style) + { + case TABLE_VIEW_STYLE_SIMPLE: + pItem = null; + break; + + case TABLE_VIEW_STYLE_GROUPED: + pItem = __pGroupedProvider->CreateGroupItem(groupIndex, itemWidth); + break; + + case TABLE_VIEW_STYLE_SECTION: + pItem = null; + break; + } + + __onProcessing = false; + + return pItem; +} + +bool +_TableViewItemProvider::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem) +{ + bool value = false; + + __onProcessing = true; + + switch (__style) + { + case TABLE_VIEW_STYLE_SIMPLE: + delete pItem; + value = true; + break; + + case TABLE_VIEW_STYLE_GROUPED: + value = __pGroupedProvider->DeleteGroupItem(groupIndex, pItem); + break; + + case TABLE_VIEW_STYLE_SECTION: + delete pItem; + value = true; + break; + } + __onProcessing = false; + + return value; +} + +TableViewItem* +_TableViewItemProvider::CreateItem(const TableViewItemTag& itemTag, int itemWidth) +{ + TableViewItem* pItem = null; + + __onProcessing = true; + + switch (__style) + { + case TABLE_VIEW_STYLE_SIMPLE: + pItem = __pSimpleProvider->CreateItem(itemTag.itemIndex, itemWidth); + break; + + case TABLE_VIEW_STYLE_GROUPED: + pItem = __pGroupedProvider->CreateItem(itemTag.groupIndex, itemTag.itemIndex, itemWidth); + break; + + case TABLE_VIEW_STYLE_SECTION: + pItem = __pSectionProvider->CreateItem(itemTag.groupIndex, itemTag.itemIndex, itemWidth); + break; + } + + __onProcessing = false; + + return pItem; +} + +bool +_TableViewItemProvider::DeleteItem(const TableViewItemTag& itemTag, TableViewItem* pItem) +{ + bool value = false; + + __onProcessing = true; + + switch (__style) + { + case TABLE_VIEW_STYLE_SIMPLE: + value = __pSimpleProvider->DeleteItem(itemTag.itemIndex, pItem); + break; + + case TABLE_VIEW_STYLE_GROUPED: + value = __pGroupedProvider->DeleteItem(itemTag.groupIndex, itemTag.itemIndex, pItem); + break; + + case TABLE_VIEW_STYLE_SECTION: + value = __pSectionProvider->DeleteItem(itemTag.groupIndex, itemTag.itemIndex, pItem); + break; + } + + __onProcessing = false; + + return value; +} + +bool +_TableViewItemProvider::UpdateItem(const TableViewItemTag& itemTag, TableViewItem *pItem) +{ + __onProcessing = true; + + switch (__style) + { + case TABLE_VIEW_STYLE_SIMPLE: + __pSimpleProvider->UpdateItem(itemTag.itemIndex, pItem); + break; + + case TABLE_VIEW_STYLE_GROUPED: + __pGroupedProvider->UpdateItem(itemTag.groupIndex, itemTag.itemIndex, pItem); + break; + + case TABLE_VIEW_STYLE_SECTION: + __pSectionProvider->UpdateItem(itemTag.groupIndex, itemTag.itemIndex, pItem); + break; + } + + __onProcessing = false; + + return true; +} + +bool +_TableViewItemProvider::UpdateGroupItem(int groupIndex, TableViewGroupItem *pItem) +{ + bool value = false; + __onProcessing = true; + + switch (__style) + { + case TABLE_VIEW_STYLE_SIMPLE: + value = false; + break; + + case TABLE_VIEW_STYLE_GROUPED: + __pGroupedProvider->UpdateGroupItem(groupIndex, pItem); + value = true; + break; + + case TABLE_VIEW_STYLE_SECTION: + value = false; + break; + } + + __onProcessing = false; + + return value; +} + +bool +_TableViewItemProvider::IsReorderable(int groupIndexFrom, int groupIndexTo) +{ + bool value = false; + + switch (__style) + { + case TABLE_VIEW_STYLE_SIMPLE: + value = false; + break; + + case TABLE_VIEW_STYLE_GROUPED: + //value = __pGroupedProvider->IsReorderable(groupIndexFrom, groupIndexTo); + value = false; + break; + + case TABLE_VIEW_STYLE_SECTION: + value = false; + break; + } + + return value; +} + +bool +_TableViewItemProvider::IsOnProcessing() +{ + return __onProcessing; +} + +Tizen::Base::String +_TableViewItemProvider::GetSectionHeader(int groupIndex) +{ + SysTryReturn(NID_UI_CTRL, __style == TABLE_VIEW_STYLE_SECTION, String(""), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SECTION"); + + return __pSectionProvider->GetSectionHeader(groupIndex); +} + +bool +_TableViewItemProvider::HasSectionHeader(int groupIndex) +{ + SysTryReturn(NID_UI_CTRL, __style == TABLE_VIEW_STYLE_SECTION, false, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SECTION"); + + return __pSectionProvider->HasSectionHeader(groupIndex); +} + +Tizen::Base::String +_TableViewItemProvider::GetSectionFooter(int groupIndex) +{ + SysTryReturn(NID_UI_CTRL, __style == TABLE_VIEW_STYLE_SECTION, String(""), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SECTION"); + + return __pSectionProvider->GetSectionFooter(groupIndex); +} + +bool +_TableViewItemProvider::HasSectionFooter(int groupIndex) +{ + SysTryReturn(NID_UI_CTRL, __style == TABLE_VIEW_STYLE_SECTION, false, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_SECTION"); + + return __pSectionProvider->HasSectionFooter(groupIndex); +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_TableViewItemProviderAdaptor.cpp b/src/ui/controls/FUiCtrl_TableViewItemProviderAdaptor.cpp new file mode 100644 index 0000000..b0fcc28 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TableViewItemProviderAdaptor.cpp @@ -0,0 +1,558 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewItemProviderAdaptor.cpp + * @brief This is the implementation file for _TableViewItemProviderAdaptor class. + * + * This file contains the implementation of _TableViewItemProviderAdaptor class. + */ + +#include + +#include +#include +#include "FUiCtrl_TableViewItem.h" +#include "FUiCtrl_TableViewItemImpl.h" +#include "FUiCtrl_TableViewItemProviderAdaptor.h" +//#include "FUiCtrl_TableViewItemFormat.h" + +#include "FUiCtrl_ListViewModel.h" +#include "FUiCtrl_IListItemCommon.h" +//#include "FUiCtrl_ListItemBaseImpl.h" +//#include "FUiCtrl_ListItemFormat.h" + +#include "FUiCtrl_LabelImpl.h" + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_TableViewItemProviderAdaptor::_TableViewItemProviderAdaptor() + : __pTableViewProvider(null) + , __pDefaultItem(null) + , __listWidth(0) + , __style(0) +{ +} + +_TableViewItemProviderAdaptor::~_TableViewItemProviderAdaptor() +{ + delete __pDefaultItem; + __pDefaultItem = null; + + delete __pTableViewProvider; + __pTableViewProvider = null; +} + +void +_TableViewItemProviderAdaptor::SetItemProvider(_TableViewItemProvider* pProvider) +{ + __pTableViewProvider = pProvider; +} + +bool +_TableViewItemProviderAdaptor::IsItemProvider() const +{ + if (__pTableViewProvider != null) + { + return true; + } + else + { + return false; + } +} + +int +_TableViewItemProviderAdaptor::GetItemCount(int groupIndex) const +{ + if (__style == TABLE_VIEW_STYLE_SECTION) + { + if (__pTableViewProvider->HasSectionFooter(groupIndex) == true) + { + return __pTableViewProvider->GetItemCount(groupIndex) + 1; + } + } + + return __pTableViewProvider->GetItemCount(groupIndex); +} + +int +_TableViewItemProviderAdaptor::GetGroupCount(void) const +{ + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + return 1; + } + + return __pTableViewProvider->GetGroupCount(); +} + +_IListItemCommon* +_TableViewItemProviderAdaptor::LoadItem(int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, __pTableViewProvider, null, E_SYSTEM, "[E_SYSTEM] This instance isn't constructed."); + + TableViewItem* pItem = null; + TableViewGroupItem* pGroupItem = null; + TableViewItemTag index = {groupIndex, itemIndex}; + + Label* pLabel = null; + + if (itemIndex == -1) + { + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + GetDefaultItem()->SetItemHeight(0); + return GetDefaultItem(); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + pGroupItem = __pTableViewProvider->CreateGroupItem(groupIndex, __listWidth); + + if (pGroupItem == null) + { + GetDefaultItem()->SetAppInfo(null); + return __pDefaultItem; + } + } + else // (__style == TABLE_VIEW_STYLE_SECTION) + { + if (!HasSectionHeader(groupIndex)) + { + _TableViewItem* pHeaderItem = _TableViewItem::CreateTableViewItemN(0); + if (pHeaderItem == null) + { + GetDefaultItem()->SetAppInfo(null); + return __pDefaultItem; + } + + return pHeaderItem; + } + + pGroupItem = new (std::nothrow) TableViewGroupItem(); + if (pGroupItem == null) + { + GetDefaultItem()->SetAppInfo(null); + return __pDefaultItem; + } + + int itemHeight = 0, titleHeight = 0; + Color textColor; + GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_TEXT_NORMAL, textColor); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, itemHeight); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, titleHeight); + + pGroupItem->Construct(Dimension(__listWidth, itemHeight)); + //pGroupItem->SetBackgroundColor(Color(0, 0, 255)); + + pLabel = new (std::nothrow) Label(); + pLabel->Construct(Rectangle(0, itemHeight - titleHeight, __listWidth, titleHeight), __pTableViewProvider->GetSectionHeader(groupIndex)); + pLabel->SetBackgroundColor(Color(0, 0, 0, 0)); + pLabel->SetTextColor(textColor); + pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + + pGroupItem->AddControl(*pLabel); + } + } + else if ((__style == TABLE_VIEW_STYLE_SECTION) && (itemIndex == GetItemCount(groupIndex) - 1) && HasSectionFooter(groupIndex)) + { + pItem = new (std::nothrow) TableViewItem(); + if (pItem == null) + { + GetDefaultItem()->SetAppInfo(null); + return __pDefaultItem; + } + + int itemHeight = 0, titleHeight = 0; + Color textColor; + GET_COLOR_CONFIG(TABLEVIEW::GROUPITEM_TEXT_NORMAL, textColor); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, itemHeight); + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, titleHeight); + + pItem->Construct(Dimension(__listWidth, itemHeight)); + //pItem->SetBackgroundColor(Color(0, 0, 255), TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + + pLabel = new (std::nothrow) Label(); + pLabel->Construct(Rectangle(0, 0, __listWidth, titleHeight), __pTableViewProvider->GetSectionFooter(groupIndex)); + pLabel->SetBackgroundColor(Color(0, 0, 0, 0)); + pLabel->SetTextColor(textColor); + pLabel->SetTextHorizontalAlignment(ALIGNMENT_RIGHT); + + pItem->AddControl(*pLabel); + } + else + { + pItem = __pTableViewProvider->CreateItem(index, __listWidth); + + if (pItem == null) + { + GetDefaultItem()->SetAppInfo(null); + return __pDefaultItem; + } + } + + _TableViewItem* pItemCore = null; + _TableViewItemImpl* pImpl = null; + if (itemIndex == -1) + { + if ((pImpl = _TableViewItemImpl::GetInstance(*pGroupItem)) == null) + { + if (!(__pTableViewProvider->DeleteGroupItem(groupIndex, pGroupItem))) + { + delete pGroupItem; + pGroupItem = null; + } + + GetDefaultItem()->SetAppInfo(null); + return __pDefaultItem; + } + else + { + pItemCore = &pImpl->GetCore(); + } + } + else + { + if ((pImpl = _TableViewItemImpl::GetInstance(*pItem)) == null) + { + if (!(__pTableViewProvider->DeleteItem(index, pItem))) + { + delete pItem; + pItem = null; + } + + GetDefaultItem()->SetAppInfo(null); + return __pDefaultItem; + } + else + { + pItemCore = &pImpl->GetCore(); + } + } + + if (pItemCore == null) + { + if (itemIndex == -1) + { + if ((__pTableViewProvider->DeleteGroupItem(groupIndex, pGroupItem)) == false) + { + delete pGroupItem; + pGroupItem = null; + } + } + else + { + if ((__pTableViewProvider->DeleteItem(index, pItem)) == false) + { + delete pItem; + pItem = null; + } + } + + GetDefaultItem()->SetAppInfo(null); + return __pDefaultItem; + } + + if (itemIndex == -1) + { + pItemCore->SetAppInfo(pGroupItem); + } + else + { + pItemCore->SetAppInfo(pItem); + } + + return pItemCore; +} + +result +_TableViewItemProviderAdaptor::UnloadItem(_IListItemCommon* pItemCore, int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, __pTableViewProvider, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] This instance has not provider."); + SysTryReturn(NID_UI_CTRL, pItemCore != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pItemCore is invalid argument."); + + TableViewItem* pItem = static_cast (pItemCore->GetAppInfo()); + TableViewItemTag index = {groupIndex, itemIndex}; + + _TableViewItem* pCoreItem = static_cast <_TableViewItem*>(pItemCore); + if (pCoreItem->GetParent() != null) + { + pCoreItem->GetParent()->DetachChild(*pCoreItem); + } + + // default item case + if (pItem == null) + { + return E_SUCCESS; + } + +// if (pItem->GetParent() != null) +// { +// pItem->GetParent()->RemoveControl(*pItem); +// } + +// pItemCore->Release(); + + pItemCore->SetAppInfo(null); + if (itemIndex == -1) + { + if (__pTableViewProvider->DeleteGroupItem(groupIndex, (TableViewGroupItem*) pItem) == false) + { + delete pItem; + pItem = null; + } + } + else + { + if (__pTableViewProvider->DeleteItem(index, pItem) == false) + { + delete pItem; + pItem = null; + } + } + + return E_SUCCESS; +} + +result +_TableViewItemProviderAdaptor::DeleteItem(_IListItemCommon* pItemCore, int groupIndex, int itemIndex) +{ + SysTryReturn(NID_UI_CTRL, __pTableViewProvider, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] This instance has not provider."); + SysTryReturn(NID_UI_CTRL, pItemCore != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] pItemCore is invalid argument."); + + TableViewItem* pItem = static_cast (pItemCore->GetAppInfo()); + + _TableViewItem* pCoreItem = static_cast <_TableViewItem*>(pItemCore); + if (pCoreItem->GetParent() != null) + { + pCoreItem->GetParent()->DetachChild(*pCoreItem); + } + + // default item case + if (pItem == null) + { + return E_SUCCESS; + } + +// pItemCore->Release(); + + delete pItem; + pItem = null; + + return E_SUCCESS; +} + +bool +_TableViewItemProviderAdaptor::UpdateItem(_IListItemCommon* pItemCore, int groupIndex, int itemIndex) +{ + TableViewItemTag itemTag = {groupIndex, itemIndex}; + bool ret = false; + + if (itemIndex == -1) + { + TableViewGroupItem* pItem = static_cast (pItemCore->GetAppInfo()); + + if (pItem != null) + { + ret = __pTableViewProvider->UpdateGroupItem(itemTag.groupIndex, pItem); + } + } + else + { + TableViewItem* pItem = static_cast (pItemCore->GetAppInfo()); + + if (pItem != null) + { + ret = __pTableViewProvider->UpdateItem(itemTag, pItem); + } + } + + return ret; +} + +result +_TableViewItemProviderAdaptor::SetListWidth(int width) +{ + __listWidth = width; + + return E_SUCCESS; +} + +int +_TableViewItemProviderAdaptor::GetListWidth(void) +{ + return __listWidth; +} + +result +_TableViewItemProviderAdaptor::SetTableViewStyle(int style) +{ + __style = style; + + return E_SUCCESS; +} + +bool +_TableViewItemProviderAdaptor::HasSectionHeader(int groupIndex) const +{ + return __pTableViewProvider->HasSectionHeader(groupIndex); +} + +bool +_TableViewItemProviderAdaptor::HasSectionFooter(int groupIndex) const +{ + return __pTableViewProvider->HasSectionFooter(groupIndex); +} + +int +_TableViewItemProviderAdaptor::GetItemHeight(int groupIndex, int itemIndex) +{ + int itemHeight = 0; + + if (itemIndex == -1) + { + itemHeight = __pTableViewProvider->GetGroupItemHeight(groupIndex); + } + else + { + TableViewItemTag itemTag = {groupIndex, itemIndex}; + itemHeight = __pTableViewProvider->GetItemHeight(itemTag); + } + + return itemHeight; +} + +int +_TableViewItemProviderAdaptor::GetDefaultItemHeight(void) +{ + return __pTableViewProvider->GetDefaultItemHeight(); +} +int +_TableViewItemProviderAdaptor::GetDefaultGroupItemHeight(void) +{ + return __pTableViewProvider->GetDefaultGroupItemHeight(); +} + +bool +_TableViewItemProviderAdaptor::IsReorderable(int groupIndexFrom, int groupIndexTo) +{ + return __pTableViewProvider->IsReorderable(groupIndexFrom, groupIndexTo); +} + +bool +_TableViewItemProviderAdaptor::IsOnProcessing() +{ + if (__pTableViewProvider != null) + { + return __pTableViewProvider->IsOnProcessing(); + } + return false; +} + +void +_TableViewItemProviderAdaptor::SetAnnexToItem(TableViewItem* pItem) +{ + int leftMargin = 0; + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + Rectangle annexRect = Rectangle(0, 0, 0, 0); + + _TableViewItemImpl* pImpl = _TableViewItemImpl::GetInstance(*pItem); + + _TableViewItem* pTableViewItem = null; + pTableViewItem = &pImpl->GetCore(); + + int itemHeight = pTableViewItem->GetItemHeight(); + int annexWidth = TableViewItem::GetAnnexWidth(pTableViewItem->GetItemStyle()); + + switch (pTableViewItem->GetItemStyle()) + { + case TABLE_VIEW_ANNEX_STYLE_MARK: + annexRect.x = __listWidth - annexWidth - leftMargin; + annexRect.y = 0; + annexRect.width = annexWidth; + annexRect.height = itemHeight; + + if (annexRect.x < 0 || annexRect.y < 0) + { + return; + } + + //pTableViewItem->AddCheckBox(annexRect); + break; + + case TABLE_VIEW_ANNEX_STYLE_RADIO: + annexRect.x = __listWidth - annexWidth - leftMargin; + annexRect.y = 0; + annexRect.width = annexWidth; + annexRect.height = itemHeight; + + if (annexRect.x < 0 || annexRect.y < 0) + { + return; + } + + //pTableViewItem->AddCheckBox(annexRect, LIST_RADIO); + break; + + case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING: + annexRect.x = __listWidth - annexWidth - leftMargin; + annexRect.y = 0; + annexRect.width = annexWidth + leftMargin; + annexRect.height = itemHeight; + + if (annexRect.x < 0 || annexRect.y < 0) + { + return; + } + + //pTableViewItem->AddCheckBox(annexRect); + break; + + case TABLE_VIEW_ANNEX_STYLE_DETAILED: + annexRect.x = __listWidth - annexWidth - leftMargin; + annexRect.y = 0; + annexRect.width = annexWidth; + annexRect.height = itemHeight; + + if (annexRect.x < 0 || annexRect.y < 0) + { + return; + } + + //pTableViewItem->AddDetailButton(annexRect); + break; + + default: + break; + } +} + +_TableViewItem* +_TableViewItemProviderAdaptor::GetDefaultItem(void) +{ + if (__pDefaultItem == null) + { + __pDefaultItem = _TableViewItem::CreateTableViewItemN(0); + } + + return __pDefaultItem; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TableViewPresenter.cpp b/src/ui/controls/FUiCtrl_TableViewPresenter.cpp new file mode 100644 index 0000000..eace4df --- /dev/null +++ b/src/ui/controls/FUiCtrl_TableViewPresenter.cpp @@ -0,0 +1,4408 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewPresenter.cpp + * @brief This is the header file for the _TableViewPresenter class. + * + * This file contains the declarations of the _TableViewPresenter class. + */ + +#include +#include +#include "FUi_ResourceManager.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_ResourceManager.h" +#include "FUiAnim_VisualElement.h" +#include "FUiCtrl_FastScroll.h" +#include "FUiCtrl_ListViewModel.h" +#include "FUiCtrl_Scroll.h" +#include "FUiCtrl_TableView.h" +#include "FUiCtrl_TableViewItem.h" +#include "FUiCtrl_TableViewPresenter.h" +#include "FUiCtrl_TableViewItemProviderAdaptor.h" + +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ +_TableViewPresenter::_TableViewPresenter() + : __pTableView(null) + , __pListModel(null) + , __pProviderAdaptor(null) + , __topMargin(0) + , __bottomMargin(0) + , __leftMargin(0) + , __modelInitialized(false) + , __firstDrawnFlag(true) + , __statusChangedFlag(true) + , __scrolling(true) + , __movedPos(0) + , __pItemDrawingProperty(null) + , __pBaseVisualElement(null) + , __sweepOccured(false) + , __sweptItemPosition() + , __reservedScrollItemAlignment(TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP) + , __firstTouchMoved(0) + , __pReorderScrollTimer(null) + , __reorderInfo() + , __itemTotalHeight(0) + , __pFastScrollTimer(null) + , __isFastScrollTimerEnabled(false) +{ + __sweptItemTag.itemIndex = -1; + __sweptItemTag.groupIndex = -1; + + __reservedScrollItemIndex.itemIndex = -1; + __reservedScrollItemIndex.groupIndex = -1; +} + +_TableViewPresenter::~_TableViewPresenter() +{ + Dispose(); +} + +_TableView* +_TableViewPresenter::GetView() const +{ + return __pTableView; +} + +_ListViewModel* +_TableViewPresenter::GetModel(void) const +{ + return __pListModel; +} + +bool +_TableViewPresenter::Initialize(_TableView* pTableView) +{ + _ScrollPanelPresenter::Initialize(*pTableView); + + __pTableView = pTableView; + __pBaseVisualElement = __pTableView->GetVisualElement(); + __pBaseVisualElement->SetClipChildrenEnabled(true); + __pBaseVisualElement->SetSurfaceOpaque(false); + + result r = __itemHeightList.Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient.")); + + // Create Model + __pListModel = new (std::nothrow) _ListViewModel(); + SysTryReturn(NID_UI_CTRL, __pListModel != null, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient.")); + + __pItemDrawingProperty = new (std::nothrow) _ItemDrawingProperty(); + SysTryReturn(NID_UI_CTRL, __pItemDrawingProperty != null, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient.")); + + // Timer + __pFastScrollTimer = new (std::nothrow) Timer(); + SysTryCatch(NID_UI_CTRL, __pFastScrollTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pFastScrollTimer->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return true; + +CATCH: + if (__isFastScrollTimerEnabled) + { + __pFastScrollTimer->Cancel(); + } + + delete __pFastScrollTimer; + __pFastScrollTimer = null; + + return false; +} + +result +_TableViewPresenter::Construct(_TableView* pTableView) +{ + result r = E_SUCCESS; + + // Create Model + if (!Initialize(pTableView)) + { + goto CATCH; + } + + return r; + +CATCH: + Dispose(); + return r; +} + +void +_TableViewPresenter::Dispose(void) +{ + DeleteItemHeightList(); + DetachContextItem(__sweptItemTag); + + delete __pListModel; + __pListModel = null; + + delete __pProviderAdaptor; + __pProviderAdaptor = null; + + delete __pItemDrawingProperty; + __pItemDrawingProperty = null; + + delete __pReorderScrollTimer; + __pReorderScrollTimer = null; + + if (__isFastScrollTimerEnabled) + { + __pFastScrollTimer->Cancel(); + } + + delete __pFastScrollTimer; + __pFastScrollTimer = null; +} + +result +_TableViewPresenter::SetItemProvider(const _TableViewItemProvider* pProvider) +{ + result r = E_SUCCESS; + + _TableViewItemProviderAdaptor* pProviderAdaptor = null; + pProviderAdaptor = static_cast <_TableViewItemProviderAdaptor*>(__pListModel->GetItemProviderAdaptor()); + + if (pProviderAdaptor == null) + { + pProviderAdaptor = new (std::nothrow) _TableViewItemProviderAdaptor(); + SysTryReturn(NID_UI_CTRL, pProviderAdaptor != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient.")); + } + + r = __pListModel->RegisterItemProviderAdaptor(pProviderAdaptor); + + pProviderAdaptor->SetItemProvider(const_cast <_TableViewItemProvider*>(pProvider)); + pProviderAdaptor->SetListWidth(__pTableView->GetBounds().width - (GetLeftMargin() * 2)); + pProviderAdaptor->SetTableViewStyle(__pTableView->GetTableViewStyle()); + + SetTableViewItemProviderAdaptor(pProviderAdaptor); + + return r; +} + +result +_TableViewPresenter::GetItemFromPosition(const Tizen::Graphics::Point& position, TableViewItemTag& itemPos) const +{ + _TableViewItem* pItem = null; + TableViewItemTag lastItemPos = {-1, -1}; + + __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex); + __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex); + + do + { + pItem = static_cast <_TableViewItem*>(__pListModel->LoadItem(itemPos.groupIndex, itemPos.itemIndex)); + SysTryCatch(NID_UI_CTRL, pItem != null, , E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range."); + + Rectangle itemBounds = pItem->GetBounds(); + if (itemBounds.Contains(position)) + { + return E_SUCCESS; + } + + if ((itemPos.itemIndex == lastItemPos.itemIndex) && (itemPos.groupIndex == lastItemPos.groupIndex)) + { + break; + } + + } while (GetNextItemPosition(itemPos, itemPos) == true); + +CATCH: + itemPos.itemIndex = -1; + itemPos.groupIndex = -1; + + return E_OUT_OF_RANGE; +} + +result +_TableViewPresenter::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + result r = E_SUCCESS; + + TableViewItemTag itemPos; + r = GetTopDrawnItem(itemPos); + + groupIndex = itemPos.groupIndex; + itemIndex = itemPos.itemIndex; + + return r; +} + +result +_TableViewPresenter::SetTopDrawnItemIndex(int groupIndex, int itemIndex) +{ + if (IsEmpty()) + { + return E_INVALID_ARG; + } + + if ((groupIndex < 0) || (groupIndex >= GetGroupCount()) || (itemIndex < -1) || (itemIndex >= GetItemCountAt(groupIndex))) + { + return E_OUT_OF_RANGE; + } + + ScrollToItem(groupIndex, itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP); + + return E_SUCCESS; +} + +result +_TableViewPresenter::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const +{ + result r = E_SUCCESS; + + TableViewItemTag itemPos; + r = GetBottomDrawnItem(itemPos); + + groupIndex = itemPos.groupIndex; + itemIndex = itemPos.itemIndex; + + return r; +} + +result +_TableViewPresenter::SetBottomDrawnItemIndex(int groupIndex, int itemIndex) +{ + if (IsEmpty()) + { + return E_INVALID_ARG; + } + + if ((groupIndex < 0) || (groupIndex >= GetGroupCount()) || (itemIndex < -1) || (itemIndex >= GetItemCountAt(groupIndex))) + { + return E_OUT_OF_RANGE; + } + + ScrollToItem(groupIndex, itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM); + + return E_SUCCESS; +} + +int +_TableViewPresenter::GetGroupCount(void) const +{ + return __pListModel->GetAllGroupCount(); +} + + +int +_TableViewPresenter::GetItemCountAt(int groupIndex) const +{ + return __pListModel->GetItemCountInGroup(groupIndex); +} + +bool +_TableViewPresenter::HasSectionFooter(int groupIndex) const +{ + if (__pProviderAdaptor == null) + { + return false; + } + + return __pProviderAdaptor->HasSectionFooter(groupIndex); +} + +int +_TableViewPresenter::GetItemCount(void) const +{ + return __pListModel->GetAllItemCount(); +} + +result +_TableViewPresenter::RefreshTableView(int groupIndex, int itemIndex, TableViewRefreshType type, bool animation) +{ + _TableViewItemProviderAdaptor* pProviderAdaptor = __pProviderAdaptor; + + SysTryReturn(NID_UI_CTRL, pProviderAdaptor != null, E_INVALID_STATE, E_INVALID_STATE, + ("[E_INVALID_STATE] This instance isn't constructed.")); + + if ((groupIndex < 0) || (groupIndex > GetGroupCount()) || (itemIndex < -1) || (itemIndex > GetItemCountAt(groupIndex))) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range."); + return E_OUT_OF_RANGE; + } + + if (groupIndex == GetGroupCount() && itemIndex != -1 && type != TABLE_VIEW_REFRESH_TYPE_ITEM_ADD) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range."); + return E_OUT_OF_RANGE; + } + + if (IsEmpty() && type == TABLE_VIEW_REFRESH_TYPE_ITEM_ADD && __pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE) + { + UpdateTableView(); + } + + _IListItemCommon* pItem = null; + TableViewItemTag topDrawnItemPos = {-1, -1}; + TableViewItemTag refreshItemPos = {groupIndex, itemIndex}; + int itemHeight = 0; + + GetTopDrawnItem(topDrawnItemPos); + + if (__sweptItemTag.groupIndex == groupIndex && __sweptItemTag.itemIndex == itemIndex) + { + ResetSweepItem(); + } + + switch (type) + { + case TABLE_VIEW_REFRESH_TYPE_ITEM_ADD: + if (itemIndex == -1) + { + bool emptyState = IsEmpty(); + + int itemCount = pProviderAdaptor->GetItemCount(groupIndex); + if (__pListModel->InsertGroup(groupIndex, itemCount, false) != E_SUCCESS) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to add Group item."); + return E_SYSTEM; + } + + if (emptyState) + { + GetFirstItem(topDrawnItemPos); + } + else if (groupIndex <= topDrawnItemPos.groupIndex) + { + topDrawnItemPos.groupIndex++; + } + } + else + { + pItem = pProviderAdaptor->LoadItem(groupIndex, itemIndex); + SysTryReturn(NID_UI_CTRL, pItem != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Unable to load item."); + + if (__pListModel->InsertItemToGroup(pItem, groupIndex, itemIndex) != E_SUCCESS) + { + pProviderAdaptor->UnloadItem(pItem, groupIndex, itemIndex); + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to add item."); + return E_SYSTEM; + } + + itemHeight = pItem->GetItemHeight(); + + if (!IsValidDrawnItem(groupIndex, itemIndex)) + { + if (__pListModel->UnloadItem(groupIndex, itemIndex) != E_SUCCESS) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to unload item."); + } + } + } + + RefreshItemHeightList(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD); + + if (itemIndex != -1) + { + SetItemHeight(refreshItemPos, itemHeight); + } + + if (__pListModel->GetAllItemCount() == 1) + { + SetStatusChanged(true); + } + + break; + + case TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE: + if (itemIndex == -1) + { + if (groupIndex == GetGroupCount()) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range."); + return E_OUT_OF_RANGE; + } + + if (__pListModel->RemoveGroup(groupIndex) != E_SUCCESS) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to remove group."); + return E_SYSTEM; + } + + if (groupIndex < topDrawnItemPos.groupIndex) + { + topDrawnItemPos.groupIndex--; + } + + if ((groupIndex == topDrawnItemPos.groupIndex) && (GetItemCountAt(groupIndex) < topDrawnItemPos.itemIndex)) + { + topDrawnItemPos.itemIndex = -1; + } + + RefreshItemHeightList(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + } + else + { + if (itemIndex == GetItemCountAt(groupIndex)) + { + SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range."); + return E_OUT_OF_RANGE; + } + + if (__pListModel->RemoveItemAt(groupIndex, itemIndex) != E_SUCCESS) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to remove item."); + return E_SYSTEM; + } + + if ((groupIndex == topDrawnItemPos.groupIndex) && (itemIndex < topDrawnItemPos.itemIndex)) + { + GetPreviousItemPosition(topDrawnItemPos, topDrawnItemPos); + } + + RefreshItemHeightList(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE); + } + + if (GetModel()->IsValidItem(topDrawnItemPos.groupIndex, topDrawnItemPos.itemIndex) == false) + { + GetPreviousItemPosition(topDrawnItemPos, topDrawnItemPos); + } + + if (__pListModel->GetAllItemCount() == 0) + { + SetStatusChanged(true); + } + + break; + + case TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY: + { + TableViewItemTag itemTag = {groupIndex, itemIndex}; + _TableViewItem* pTableViewItem = FindItem(itemTag); + + if (pTableViewItem == null) + { + return E_SUCCESS; + } + + if (pProviderAdaptor->UpdateItem(pTableViewItem, itemTag.groupIndex, itemTag.itemIndex)) + { + CheckItemHeightAndRefreshLayout(itemTag, true); + + if (__sweptItemTag.groupIndex != itemTag.groupIndex || __sweptItemTag.itemIndex != itemTag.itemIndex) + { + ResetSweptItem(); + } + + pTableViewItem->SetItemChanged(true); + pTableViewItem->Invalidate(); + pTableViewItem->AdjustContextItemBounds(); + + return E_SUCCESS; + } + } + break; + + default: + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to refresh list."); + return E_SYSTEM; + break; + } + + AdjustClientAreaBounds(true); + + RefreshItemLayout(topDrawnItemPos, refreshItemPos, type, animation); + + return E_SUCCESS; +} + +result +_TableViewPresenter::UpdateTableView(void) +{ + if (__modelInitialized == false) + { + SetItemDrawingProperty(); + + PreloadItem(); + + __modelInitialized = true; + } + else + { + TableViewItemTag topDrawnTag = {-1, -1}; + int shiftingDistance = 0; + + ResetSweepItem(); + + GetTopDrawnItem(topDrawnTag); + + if (__pListModel->IsValidItem(topDrawnTag.groupIndex, topDrawnTag.itemIndex)) + { + _TableViewItem* pItem = FindItem(topDrawnTag); + + if (pItem != null) + { + shiftingDistance = GetScrollPosition() - pItem->GetBounds().y; + } + } + + __pListModel->RemoveAllItem(false, true); + + SetScrollPosition(0, false); + + __statusChangedFlag = true; + + PreloadItem(); + + if (__pListModel->IsValidItem(topDrawnTag.groupIndex, topDrawnTag.itemIndex)) + { + ScrollToItem(topDrawnTag.groupIndex, topDrawnTag.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP, shiftingDistance); + } + } + + return E_SUCCESS; +} + +void +_TableViewPresenter::AdjustLayoutItems(int scrollPosition) +{ + TableViewItemTag lastLoadedItemPos = {-1, -1}; + TableViewItemTag firstLoadedItemPos = {-1, -1}; + TableViewItemTag currentItemPos = {-1, -1}; + _TableViewItem* pItem = null; + + __pListModel->GetFirstLoadedItemIndex(firstLoadedItemPos.groupIndex, firstLoadedItemPos.itemIndex); + __pListModel->GetLastLoadedItemIndex(lastLoadedItemPos.groupIndex, lastLoadedItemPos.itemIndex); + + pItem = FindItem(firstLoadedItemPos); + + if (pItem != null) + { + int positionY = pItem->GetPosition().y; + + currentItemPos = firstLoadedItemPos; + + while (positionY > scrollPosition && GetPreviousItemPosition(currentItemPos, currentItemPos)) + { + pItem = LoadItem(currentItemPos.groupIndex, currentItemPos.itemIndex); + + if (pItem == null) + { + break; + } + + positionY = pItem->GetPosition().y; + } + } + + pItem = FindItem(lastLoadedItemPos); + + if (pItem != null) + { + int positionY = pItem->GetPosition().y; + int itemHeight = pItem->GetBounds().height; + int limitScreenArea = scrollPosition + __pTableView->GetBounds().height; + currentItemPos = lastLoadedItemPos; + + while (positionY + itemHeight < limitScreenArea && GetNextItemPosition(currentItemPos, currentItemPos)) + { + pItem = LoadItem(currentItemPos.groupIndex, currentItemPos.itemIndex); + + if (pItem == null) + { + break; + } + + positionY = pItem->GetPosition().y; + itemHeight = pItem->GetBounds().height; + } + } +} + +void +_TableViewPresenter::ResetItemLayout(TableViewItemTag& topDrawnItemTag) +{ + if (__pListModel->IsValidItem(topDrawnItemTag.groupIndex, topDrawnItemTag.itemIndex) == false) + { + return; + } + + DetachAllItem(true); + + _TableViewItem* pItem = LoadItem(topDrawnItemTag.groupIndex, topDrawnItemTag.itemIndex); + + if (pItem == null) + { + return; + } + + TableViewItemTag currentItem = topDrawnItemTag; + TableViewItemTag itemPos = topDrawnItemTag; + int screenAreaHeight = __pTableView->GetBounds().height; + int loadedItemTotalHeight = 0; + Rectangle itemBounds = pItem->GetBounds(); + + itemBounds.y = CalculateItemPositionY(itemPos.groupIndex, itemPos.itemIndex); + pItem->SetBounds(itemBounds); + CheckItemHeightAndRefreshLayout(itemPos, true); + + loadedItemTotalHeight += itemBounds.height; + + while (loadedItemTotalHeight < screenAreaHeight && GetNextItemPosition(currentItem, itemPos)) + { + pItem = LoadItem(itemPos.groupIndex, itemPos.itemIndex); + + if (pItem == null) + { + break; + } + + currentItem = itemPos; + loadedItemTotalHeight += pItem->GetBounds().height; + } + + if (loadedItemTotalHeight < screenAreaHeight) + { + __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex); + currentItem = itemPos; + + while (loadedItemTotalHeight < screenAreaHeight && GetPreviousItemPosition(currentItem, itemPos)) + { + pItem = LoadItem(itemPos.groupIndex, itemPos.itemIndex); + + if (pItem == null) + { + break; + } + + currentItem = itemPos; + loadedItemTotalHeight += pItem->GetBounds().height; + } + } +} + +void +_TableViewPresenter::GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const +{ + __pListModel->GetFirstLoadedItemIndex(groupIndex, itemIndex); +} + +void +_TableViewPresenter::GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const +{ + __pListModel->GetLastLoadedItemIndex(groupIndex, itemIndex); +} + +void +_TableViewPresenter::RefreshItemLayout(int groupIndex, int itemIndex) +{ + TableViewItemTag itemTag = {groupIndex, itemIndex}; + + ResetSweepItem(); + + RefreshItemLayout(itemTag, itemTag, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY, false); +} + +void +_TableViewPresenter::RefreshItemLayout(TableViewItemTag& topDrawnItemTag, TableViewItemTag& refreshItemTag, TableViewRefreshType type, bool animation) +{ + if (!__pListModel->IsValidItem(topDrawnItemTag.groupIndex, topDrawnItemTag.itemIndex)) + { + return; + } + + if (refreshItemTag.itemIndex == -1) + { + animation = false; + } + + _TableViewItem* pItem = null; + + TableViewItemTag itemPos = {-1, -1}; + TableViewItemTag currentItem = {-1, -1}; + + int loadItemCount = 0; + int maxLoadItemCount = GetMaxItemCachingSize(); + Rectangle itemBounds(0, 0, 0, 0); + + __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex); + + currentItem = itemPos; + + int itemPositionY = CalculateItemPositionY(itemPos.groupIndex, itemPos.itemIndex); + + do + { + pItem = LoadItem(itemPos.groupIndex, itemPos.itemIndex); + + if (pItem == null) + { + break; + } + + if (pItem->HasParent()) + { + pItem->SetDrawingProperty(__pItemDrawingProperty); + SetItemType(pItem, itemPos); + } + + itemBounds = pItem->GetBounds(); + itemBounds.y = itemPositionY; + + pItem->StopAllAnimation(); + + if (animation) + { + if (type == TABLE_VIEW_REFRESH_TYPE_ITEM_ADD) + { + if (itemPos.groupIndex == refreshItemTag.groupIndex && itemPos.itemIndex == refreshItemTag.itemIndex) + { + pItem->SetBounds(itemBounds); + pItem->FadeInOutItem(false, ADD_ITEM_ANIMATION_DURATION, REFRESH_ITEM_ANIMATION_DELAY); + pItem->ZoomInOutItem(false, ADD_ITEM_ANIMATION_DURATION, REFRESH_ITEM_ANIMATION_DELAY); + } + else + { + if (!pItem->MoveItem(Point(itemBounds.x, itemBounds.y), ADD_ITEM_ANIMATION_DURATION, 0)) + { + pItem->SetBounds(itemBounds); + } + } + } + else + { + if (!pItem->MoveItem(Point(itemBounds.x, itemBounds.y), REMOVE_ITEM_MOVE_ANIMATION_DURATION, REFRESH_ITEM_ANIMATION_DELAY)) + { + pItem->SetBounds(itemBounds); + } + } + } + else + { + pItem->SetBounds(itemBounds); + } + + currentItem = itemPos; + itemPositionY = itemBounds.y + itemBounds.height; + + loadItemCount++; + + } while (loadItemCount < maxLoadItemCount && GetNextItemPosition(currentItem, itemPos)); + + if (loadItemCount < maxLoadItemCount) + { + __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex); + currentItem = itemPos; + + while (loadItemCount < maxLoadItemCount && GetPreviousItemPosition(currentItem, itemPos)) + { + pItem = LoadItem(itemPos.groupIndex, itemPos.itemIndex); + + if (pItem == null) + { + break; + } + + currentItem = itemPos; + + loadItemCount++; + } + } + + if (refreshItemTag.itemIndex == -1) + { + ScrollToItem(topDrawnItemTag.groupIndex, topDrawnItemTag.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP); + } +} + +void +_TableViewPresenter::RefreshItemBounds(_TableViewItem* pItem, TableViewItemTag& itemPos) +{ + Rectangle itemBounds; + + if (pItem == null) + { + return; + } + + itemBounds = pItem->GetBounds(); + + itemBounds.y = CalculateItemPositionY(itemPos.groupIndex, itemPos.itemIndex); + + if (itemPos.itemIndex != -1) + { + int itemMargin = GetLeftMargin(); + itemBounds.x = itemMargin; + itemBounds.width = __pItemDrawingProperty->width - itemBounds.x - itemMargin; + } + else + { + itemBounds.x = 0; + itemBounds.width = __pItemDrawingProperty->width; + } + + pItem->SetBounds(itemBounds); +} + +result +_TableViewPresenter::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const +{ + result r = E_SUCCESS; + TableViewItemTag itemPos; + + Point targetPosition = position; + int scrollPosition = GetScrollPosition(); + targetPosition.y += scrollPosition; + + r = GetItemFromPosition(targetPosition, itemPos); + + if (r != E_SUCCESS) + { + groupIndex = -1; + itemIndex = -1; + return r; + } + + groupIndex = itemPos.groupIndex; + itemIndex = itemPos.itemIndex; + + return r; +} + + +void +_TableViewPresenter::PreloadItem(void) +{ + if (GetModel() == null || __pProviderAdaptor == null) + { + return; + } + + if (__pListModel->GetAllGroupCount() == 0 && (__pProviderAdaptor != null)) + { + int itemCount = 0; + int groupCount = __pProviderAdaptor->GetGroupCount(); + + for (int i = 0; i < groupCount; i++) + { + itemCount = __pProviderAdaptor->GetItemCount(i); + __pListModel->AddGroup(itemCount, false); + } + } + + __pListModel->RestoreItemStatus(); + + CreateItemHeightList(); + AdjustClientAreaBounds(true); + + int cachingSize = 0; + + if (GetItemCount() > TABLEVIEW_MAX_ITEM_COUNT) + { + cachingSize = TABLEVIEW_MAX_ITEM_COUNT; + } + else if (__pListModel->GetMaxCachingSize() < TABLEVIEW_MAX_ITEM_COUNT) + { + cachingSize = __pListModel->GetMaxCachingSize(); + } + else + { + cachingSize = GetItemCount(); + } + + TableViewItemTag itemPos = {-1, -1}; + GetFirstItem(itemPos); + + _TableViewItem* pItem = null; + for (int i = 0; i < cachingSize; i++) + { + pItem = LoadItem(itemPos.groupIndex, itemPos.itemIndex); + + if (pItem == null) + { + break; + } + + if (GetNextItemPosition(itemPos, itemPos) == false) + { + break; + } + } + + if (__pTableView->GetScrollStyle() == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL) + { + _FastScroll* pFastScroll = __pTableView->GetFastScrollBar(); + if (pFastScroll != null) + { + pFastScroll->UpdateIndex(); + pFastScroll->SetScrollVisibility(IsScrollable()); + } + } +} + +bool +_TableViewPresenter::IsItemChecked(int groupIndex, int itemIndex) const +{ + if ((groupIndex < 0) || (groupIndex >= GetGroupCount()) || (itemIndex < -1) || (itemIndex >= GetItemCountAt(groupIndex))) + { + return false; + } + + return __pListModel->IsItemChecked(groupIndex, itemIndex); +} + +result +_TableViewPresenter::SetItemChecked(int groupIndex, int itemIndex, bool checked) +{ + if ((groupIndex < 0) || (groupIndex >= GetGroupCount()) || (itemIndex < -1) || (itemIndex >= GetItemCountAt(groupIndex))) + { + return E_OUT_OF_RANGE; + } + + if (__modelInitialized == false) + { + return E_INVALID_STATE; + } + + TableViewItemTag itemPos = {groupIndex, itemIndex}; + + bool enabled = __pListModel->IsItemEnabled(itemPos.groupIndex, itemPos.itemIndex); + SysTryReturn(NID_UI_CTRL, (enabled == true), E_INVALID_OPERATION, E_INVALID_OPERATION, + "[E_INVALID_OPERATION] The item is disabled."); + + if (__pListModel->IsItemChecked(itemPos.groupIndex, itemPos.itemIndex) == checked) + { + return E_SUCCESS; + } + + TableViewItemTag itemTag = {groupIndex, itemIndex}; + _TableViewItem *pItem = FindItem(itemTag); + if (pItem != null) + { + pItem->SetCheckedAnimationEnabled(checked); + } + + result r = __pListModel->SetItemChecked(itemPos.groupIndex, itemPos.itemIndex, checked); + + return r; +} + +bool +_TableViewPresenter::IsItemEnabled(int groupIndex, int itemIndex) const +{ + if ((groupIndex < 0) || (groupIndex >= GetGroupCount()) || (itemIndex < -1) || (itemIndex >= GetItemCountAt(groupIndex))) + { + return false; + } + + return __pListModel->IsItemEnabled(groupIndex, itemIndex); +} + +result +_TableViewPresenter::SetItemEnabled(int groupIndex, int itemIndex, bool enabled) +{ + if ((groupIndex < 0) || (groupIndex >= GetGroupCount()) || (itemIndex < -1) || (itemIndex >= GetItemCountAt(groupIndex))) + { + return E_OUT_OF_RANGE; + } + + TableViewItemTag itemPos = {groupIndex, itemIndex}; + + if (__pListModel->IsItemEnabled(itemPos.groupIndex, itemPos.itemIndex) == enabled) + { + return E_SUCCESS; + } + + result r = __pListModel->SetItemEnabled(itemPos.groupIndex, itemPos.itemIndex, enabled); + + return r; +} + +result +_TableViewPresenter::SetStatusChanged(bool changed) +{ + __statusChangedFlag = changed; + + if (__statusChangedFlag == true) + { + SetItemDrawingProperty(); + + if ((__pItemDrawingProperty != null) && (__pItemDrawingProperty->propertyChanged == true)) + { + __pListModel->SetAllLoadedItemStateChanged(true); + } + } + + return E_SUCCESS; +} + +bool +_TableViewPresenter::IsStatusChanged(void) const +{ + return __statusChangedFlag; +} + +int +_TableViewPresenter::GetTopMargin(void) const +{ + return __topMargin; +} + +result +_TableViewPresenter::SetTopMargin(int topMargin) +{ + __topMargin = topMargin; + + return E_SUCCESS; +} + +int +_TableViewPresenter::GetBottomMargin(void) const +{ + return __bottomMargin; +} + +result +_TableViewPresenter::SetBottomMargin(int bottomMargin) +{ + __bottomMargin = bottomMargin; + + return E_SUCCESS; +} + +int +_TableViewPresenter::GetLeftMargin(void) const +{ + return __leftMargin; +} + +result +_TableViewPresenter::SetLeftMargin(int leftMargin) +{ + __leftMargin = leftMargin; + + return E_SUCCESS; +} + +void +_TableViewPresenter::SetItemType(_TableViewItem* pItem, TableViewItemTag itemPosition) +{ + TableViewStyle style = __pTableView->GetTableViewStyle(); + + int lastItem = GetItemCountAt(itemPosition.groupIndex) - 1; + + if (style == TABLE_VIEW_STYLE_SECTION) + { + if (HasSectionFooter(itemPosition.groupIndex)) + { + lastItem--; + } + } + + if (itemPosition.itemIndex == -1) + { + if (style == TABLE_VIEW_STYLE_SECTION) + { + pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_HEADER); + } + else + { + pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_TITLE); + } + } + else if (style == TABLE_VIEW_STYLE_SECTION || (itemPosition.groupIndex != GetGroupCount() - 1)) + { + if (lastItem == 0) + { + pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_ONE); + } + else + { + if (itemPosition.itemIndex == 0) + { + pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_TOP); + } + else if (itemPosition.itemIndex == lastItem) + { + pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_BOTTOM); + } + else if (itemPosition.itemIndex == lastItem + 1) + { // this case is for TABLE_VIEW_STYLE_SECTION only + pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_FOOTER); + } + else + { + pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_MIDDLE); + } + } + } +} + +void +_TableViewPresenter::SetItemLayout(_TableViewItem* pItem, TableViewItemTag& itemPos) +{ + _TableViewItem* pSeriesItem = null; + TableViewItemTag seriesItemPos = {-1, -1}; + Rectangle seriesItemBounds; + Rectangle itemBounds; + bool validBounds = false; + bool downScroll = true; + + if (itemPos.itemIndex != -1) + { + int itemMargin = GetLeftMargin(); + itemBounds.x = itemMargin; + itemBounds.width = __pItemDrawingProperty->width - itemBounds.x - itemMargin; + } + else + { + itemBounds.x = 0; + itemBounds.width = __pItemDrawingProperty->width; + } + + //itemBounds.height = pItem->GetItemHeight(); + itemBounds.height = pItem->GetSize().height; + + if (itemPos.groupIndex == 0 && itemPos.itemIndex == -1) + { + itemBounds.y = GetTopMargin(); + validBounds = true; + } + else + { + if (GetPreviousItemPosition(itemPos, seriesItemPos)) + { + if (__pListModel->IsLoadedItem(seriesItemPos.groupIndex, seriesItemPos.itemIndex)) + { + pSeriesItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(seriesItemPos.groupIndex, seriesItemPos.itemIndex)); + if ((pSeriesItem != null) && pSeriesItem->HasParent()) + { + if (__pTableView->IsReorderModeEnabled() && (__reorderInfo.groupIndex == seriesItemPos.groupIndex && __reorderInfo.itemIndex == seriesItemPos.itemIndex)) + { + seriesItemBounds = __reorderInfo.itemBounds; + } + else + { + seriesItemBounds = pSeriesItem->GetBounds(); + } + + itemBounds.y = seriesItemBounds.y + seriesItemBounds.height; + + validBounds = true; + } + } + } + + if ((!validBounds) && GetNextItemPosition(itemPos, seriesItemPos)) + { + if (__pListModel->IsLoadedItem(seriesItemPos.groupIndex, seriesItemPos.itemIndex)) + { + pSeriesItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(seriesItemPos.groupIndex, seriesItemPos.itemIndex)); + if ((pSeriesItem != null) && pSeriesItem->HasParent()) + { + if (__pTableView->IsReorderModeEnabled() && (__reorderInfo.groupIndex == seriesItemPos.groupIndex && __reorderInfo.itemIndex == seriesItemPos.itemIndex)) + { + seriesItemBounds = __reorderInfo.itemBounds; + } + else + { + seriesItemBounds = pSeriesItem->GetBounds(); + } + + itemBounds.y = seriesItemBounds.y - itemBounds.height; + + validBounds = true; + downScroll = false; + } + } + } + } + + if (validBounds) + { + pItem->SetBounds(itemBounds); + + CheckItemHeightAndRefreshLayout(itemPos, downScroll); + } +} + +_TableViewItem* +_TableViewPresenter::LoadItem(int groupIndex, int itemIndex) +{ + _TableViewItem* pItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(groupIndex, itemIndex)); + + if ((pItem != null) && !pItem->HasParent()) + { + pItem->SetDrawingProperty(__pItemDrawingProperty); + + TableViewItemTag itemPosition = {groupIndex, itemIndex}; + SetItemType(pItem, itemPosition); + SetItemLayout(pItem, itemPosition); + pItem->SetReorderMode(__pTableView->IsReorderModeEnabled()); + pItem->AdjustChildControlMargin(); + + __pTableView->AttachChild(*pItem); + + } + return pItem; +} + +_TableViewItem* +_TableViewPresenter::FindItem(TableViewItemTag& itemTag) +{ + if (__pListModel->IsLoadedItem(itemTag.groupIndex, itemTag.itemIndex)) + { + return static_cast<_TableViewItem*>(__pListModel->LoadItem(itemTag.groupIndex, itemTag.itemIndex)); + } + return null; +} + +void +_TableViewPresenter::UnloadItem(int groupIndex, int itemIndex) +{ + __pListModel->UnloadItem(groupIndex, itemIndex); +} + +void +_TableViewPresenter::UnloadItem(TableViewItemTag& itemTag) +{ + __pListModel->UnloadItem(itemTag.groupIndex, itemTag.itemIndex); + + return; +} + +void +_TableViewPresenter::DetachItem(TableViewItemTag& itemTag) +{ + _TableViewItem *pItem = FindItem(itemTag); + + if (pItem != null && pItem->HasParent()) + { + pItem->GetParent()->DetachChild(*pItem); + } +} + +void +_TableViewPresenter::DetachContextItem(TableViewItemTag& itemTag) +{ + _TableViewItem *pItem = FindItem(itemTag); + if (pItem == null) + { + return; + } + + _TableViewItem* contextItem = pItem->GetContextItem(); + if (contextItem != null && contextItem->HasParent()) + { + contextItem->GetParent()->DetachChild(*pItem); + } +} + +void +_TableViewPresenter::DetachAllItem(bool removeItem) +{ + TableViewItemTag itemPos = {-1, -1}; + TableViewItemTag lastItemPos = {-1, -1}; + + __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex); + __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex); + + if (itemPos.groupIndex == -1 && itemPos.itemIndex == -1) + { + return; + } + + do + { + DetachItem(itemPos); + + if (removeItem) + { + UnloadItem(itemPos); + } + + if (itemPos.itemIndex == lastItemPos.itemIndex && itemPos.groupIndex == lastItemPos.groupIndex) + { + break; + } + } while (GetNextItemPosition(itemPos, itemPos)); +} + +void +_TableViewPresenter::SetItemDrawingProperty(void) +{ + if (__pItemDrawingProperty != null) + { + __pItemDrawingProperty->propertyChanged = false; + + if (__pItemDrawingProperty->itemDividerEnabled != __pTableView->IsItemDividerEnabled()) + { + __pItemDrawingProperty->itemDividerEnabled = __pTableView->IsItemDividerEnabled(); + __pItemDrawingProperty->propertyChanged = true; + } + + if (__pItemDrawingProperty->dividerColor != __pTableView->GetItemDividerColor()) + { + __pItemDrawingProperty->dividerColor = __pTableView->GetItemDividerColor(); + __pItemDrawingProperty->propertyChanged = true; + } + + if (__pItemDrawingProperty->sectionStyleEnabled != (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION)) + { + __pItemDrawingProperty->sectionStyleEnabled = (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION); + __pItemDrawingProperty->propertyChanged = true; + } + + if (__pItemDrawingProperty->sectionStyleBgColor != __pTableView->GetSectionColor()) + { + __pItemDrawingProperty->sectionStyleBgColor = __pTableView->GetSectionColor(); + __pItemDrawingProperty->propertyChanged = true; + } + + if (__pTableView->GetTableViewStyle() != TABLE_VIEW_STYLE_SIMPLE) + { + if (__pItemDrawingProperty->groupedLookEnabled != __pTableView->IsGroupedLookEnabled()) + { + __pItemDrawingProperty->groupedLookEnabled = __pTableView->IsGroupedLookEnabled(); + __pItemDrawingProperty->propertyChanged = true; + } + } + + if (__pItemDrawingProperty->reorderMode != __pTableView->IsReorderModeEnabled()) + { + __pItemDrawingProperty->reorderMode = __pTableView->IsReorderModeEnabled(); + __pItemDrawingProperty->propertyChanged = true; + } + + if (__pItemDrawingProperty->leftMargin != __leftMargin) + { + __pItemDrawingProperty->leftMargin = __leftMargin; + __pItemDrawingProperty->propertyChanged = true; + } + + if (__pTableView->GetScrollStyle() == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL) + { + GET_SHAPE_CONFIG(TABLEVIEW::FASTSCROLL_INDEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __pItemDrawingProperty->scrollMargin); + } + else + { + __pItemDrawingProperty->scrollMargin = 0; + } + + if (__pItemDrawingProperty->width != __pTableView->GetBounds().width) + { + __pItemDrawingProperty->width = __pTableView->GetBounds().width; + __pItemDrawingProperty->propertyChanged = true; + } + } +} + +void +_TableViewPresenter::OnBoundsChanged(void) +{ + _ScrollPanelPresenter::OnBoundsChanged(); + + if (__pProviderAdaptor != null && __modelInitialized) + { + int listWidth = __pTableView->GetBounds().width - (GetLeftMargin() * 2); + + if (listWidth != __pProviderAdaptor->GetListWidth()) + { + __pProviderAdaptor->SetListWidth(listWidth); + SetItemDrawingProperty(); + + AdjustLoadedItemWidth(); + } + + ResetSweepItem(); + SetClientAreaHeight(__itemTotalHeight); + + AdjustLayoutItems(GetScrollPosition()); + } +} + +result +_TableViewPresenter::Draw(void) +{ + result r = _ScrollPanelPresenter::Draw(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__modelInitialized == false) + { + SetItemDrawingProperty(); + + PreloadItem(); + + __modelInitialized = true; + + if (__reservedScrollItemIndex.groupIndex != -1 && __reservedScrollItemIndex.itemIndex != -1) + { + ScrollToItem(__reservedScrollItemIndex.groupIndex, __reservedScrollItemIndex.itemIndex, __reservedScrollItemAlignment); + + __reservedScrollItemIndex.groupIndex = -1; + __reservedScrollItemIndex.itemIndex = -1; + + return E_SUCCESS; + } + + } + + __firstDrawnFlag = false; + + // Draw empty list + if (IsEmpty() == true) + { + return DrawEmptyTableView(); + } + + return E_SUCCESS; +} + +_UiTouchEventDelivery +_TableViewPresenter::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchInfo) +{ + _UiTouchEventDelivery response = _ScrollPanelPresenter::OnPreviewTouchPressed(source, touchInfo); + + __firstTouchMoved = true; + __sweepOccured = false; + + _TableViewItem* pItem = GetTableViewItemFromControl(source); + if (pItem == null) + { + return response; + } + + TableViewItemTag itemPos = {-1, -1}; + + pItem->GetItemIndex(itemPos.groupIndex, itemPos.itemIndex); + + if (itemPos.groupIndex == -1 && itemPos.itemIndex == -1) + { + return response; + } + + if (__pTableView->IsReorderModeEnabled()) + { + if (SelectReorderItem(itemPos.groupIndex, itemPos.itemIndex)) + { + __reorderInfo.touchPressedPositionY = touchInfo.GetCurrentPosition().y; + + return _UI_TOUCH_EVENT_DELIVERY_NO; + } + } + else + { + if (!(pItem == null + || pItem->IsContextItem() + || pItem->IsItemEnabled() == false + || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_TITLE + || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_HEADER + || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_FOOTER) + && ((itemPos.groupIndex != __sweptItemTag.groupIndex) + || (itemPos.itemIndex != __sweptItemTag.itemIndex))) + { + ResetSweptItem(); + } + } + + _VisualElement* pVisualElement = __pTableView->GetVisualElement(); + String animationName(L"EXPAND_GROUP_ANIMATION"); + VisualElementValueAnimation* pExpandGroupAnimation = dynamic_cast(pVisualElement->GetAnimationN(animationName)); + if (pExpandGroupAnimation != null) + { + pVisualElement->RemoveAnimation(animationName); + + //return _UI_TOUCH_EVENT_DELIVERY_NO; + } + + animationName = L"COLLAPSE_GROUP_ANIMATION"; + VisualElementValueAnimation* pCollapseGroupAnimation = dynamic_cast(pVisualElement->GetAnimationN(animationName)); + if (pCollapseGroupAnimation != null) + { + pVisualElement->RemoveAnimation(animationName); + + //return _UI_TOUCH_EVENT_DELIVERY_NO; + } + + return response; +} + +_UiTouchEventDelivery +_TableViewPresenter::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchInfo) +{ + if (__pTableView->IsReorderModeEnabled() && __reorderInfo.itemIndex != -1) + { + if (!DragSelectedItem(touchInfo.GetCurrentPosition().y - __reorderInfo.touchPressedPositionY, true)) + { + ResetReorderItem(__reorderInfo.groupIndex, __reorderInfo.itemIndex); + } + + return _UI_TOUCH_EVENT_DELIVERY_NO; + } + + _TableViewItem* pItem = GetTableViewItemFromControl(source); + + _UiTouchEventDelivery response = _ScrollPanelPresenter::OnPreviewTouchMoved(source, touchInfo); + if (pItem == null + || pItem->IsItemEnabled() == false + || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_TITLE + || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_HEADER + || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_FOOTER) + { + return response; + } + + if (__firstTouchMoved) + { + Point prevTouchPosition = GetPreviousTouchPosition(); + Point currTouchPosition = GetCurrentTouchPosition(); + int moveDistanceX = currTouchPosition.x - prevTouchPosition.x; + int moveDistanceY = currTouchPosition.y - prevTouchPosition.y; + + if ((pItem->GetContextItem() != null && abs(moveDistanceX) > abs(moveDistanceY * 2)) || pItem->IsContextItem()) + { + if (!pItem->IsContextItem()) + { + pItem->GetItemIndex(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex); + __sweptItemPosition = pItem->GetPosition(); + + pItem->AdjustContextItemBounds(); + } + + __sweepOccured = true; + + SweepItem(moveDistanceX); + } + else + { + ResetSweptItem(); + } + } + + __firstTouchMoved = false; + + return response; +} + +_UiTouchEventDelivery +_TableViewPresenter::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchInfo) +{ + if (__pTableView->IsReorderModeEnabled() && __reorderInfo.itemIndex != -1) + { + ResetReorderItem(__reorderInfo.groupIndex, __reorderInfo.itemIndex); + + if (__reorderInfo.blockedTouchReleaseState) + { + __reorderInfo.blockedTouchReleaseState = false; + + return _UI_TOUCH_EVENT_DELIVERY_NO; + } + } + + _UiTouchEventDelivery response = _ScrollPanelPresenter::OnPreviewTouchReleased(source, touchInfo); + + _TableViewItem* pItem = GetTableViewItemFromControl(source); + + if (pItem == null + || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_TITLE + || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_HEADER + || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_FOOTER) + { + return response; + } + + if (pItem->IsContextItem()) + { + pItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex)); + } + + _TableViewItem* pContextItem = pItem->GetContextItem(); + + if (__sweepOccured) + { + // Swept event fire + if (pContextItem == null && __pTableView->IsSweepEnabled()) + { + Point prevPos = _ScrollPanelPresenter::GetPreviousTouchPosition(); + + if (prevPos.x > touchInfo.GetCurrentPosition().x) + { + pItem->FireItemSweepEvent(TABLE_VIEW_SWEEP_DIRECTION_LEFT); + } + else if (prevPos.x < touchInfo.GetCurrentPosition().x) + { + pItem->FireItemSweepEvent(TABLE_VIEW_SWEEP_DIRECTION_RIGHT); + } + + ResetSweptItem(); + } + else if (pContextItem != null) + { + AdjustSweptItemPosition(true); + } + } + + return response; +} + +_UiTouchEventDelivery +_TableViewPresenter::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchInfo) +{ + return _ScrollPanelPresenter::OnPreviewTouchCanceled(source, touchInfo); +} + +bool +_TableViewPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) +{ + return _ScrollPanelPresenter::OnTouchPressed(source, touchInfo); +} + +bool +_TableViewPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) +{ + if (!__sweepOccured || __pTableView->IsReorderModeEnabled()) + { + return _ScrollPanelPresenter::OnTouchMoved(source, touchInfo); + } + + if (__sweepOccured) + { + Point prevTouchPosition = GetPreviousTouchPosition(); + Point currTouchPosition = GetCurrentTouchPosition(); + SweepItem(currTouchPosition.x - prevTouchPosition.x); + } + + return true; +} + +bool +_TableViewPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) +{ + return _ScrollPanelPresenter::OnTouchReleased(source, touchInfo); +} + +bool +_TableViewPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo) +{ + if (__pTableView->IsReorderModeEnabled() && __reorderInfo.itemIndex != -1) + { + ResetReorderItem(__reorderInfo.groupIndex, __reorderInfo.itemIndex); + return true; + } + + return _ScrollPanelPresenter::OnTouchCanceled(source, touchInfo); +} + +bool +_TableViewPresenter::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) +{ + if (__pTableView->IsReorderModeEnabled() && __reorderInfo.itemIndex != -1) + { + return true; + } + + _FlickDirection flickDirection = gesture.GetDirection(); + + if (flickDirection != _FLICK_DIRECTION_RIGHT && flickDirection != _FLICK_DIRECTION_LEFT) + { + return _ScrollPanelPresenter::OnFlickGestureDetected(gesture); + } + + _Control* gestureControl = gesture.GetControl(); + + if (gestureControl == null) + { + return _ScrollPanelPresenter::OnFlickGestureDetected(gesture); + } + + _TableViewItem* pItem = GetTableViewItemFromControl(*gestureControl); + + if (pItem == null) + { + return _ScrollPanelPresenter::OnFlickGestureDetected(gesture); + } + + if (flickDirection == _FLICK_DIRECTION_RIGHT) + { + // event fire + if (pItem->GetContextItem() == null && __pTableView->IsSweepEnabled()) + { + pItem->FireItemSweepEvent(TABLE_VIEW_SWEEP_DIRECTION_RIGHT); + } + else + { + if (pItem->GetContextItem() != null) + { + AdjustSweptItemPosition(); + } + } + } + else if (flickDirection == _FLICK_DIRECTION_LEFT) + { + // event fire + if (pItem->GetContextItem() == null && __pTableView->IsSweepEnabled()) + { + pItem->FireItemSweepEvent(TABLE_VIEW_SWEEP_DIRECTION_LEFT); + } + else + { + if (pItem->GetContextItem() != null) + { + AdjustSweptItemPosition(); + } + } + } + + return true; +} + +bool +_TableViewPresenter::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture) +{ + return _ScrollPanelPresenter::OnFlickGestureCanceled(gesture); +} + +bool +_TableViewPresenter::OnPreviewFlickGestureDetected(_TouchFlickGestureDetector& gesture) +{ + if (__pTableView->IsReorderModeEnabled() && __reorderInfo.itemIndex != -1) + { + return true; + } + + _FlickDirection flickDirection = gesture.GetDirection(); + if (flickDirection != _FLICK_DIRECTION_RIGHT && flickDirection != _FLICK_DIRECTION_LEFT) + { + return _ScrollPanelPresenter::OnFlickGestureDetected(gesture); + } + + return true; +} + +void +_TableViewPresenter::OnTimerExpired(Tizen::Base::Runtime::Timer& timer) +{ + _ScrollPanelPresenter::OnTimerExpired(timer); + + if (&timer == __pReorderScrollTimer) + { + int distance = 0; + + if (__reorderInfo.isScrollDirectionUp) + { + distance = -REORDER_SCROLL_ANIMATION_DISTANCE; + } + else + { + distance = REORDER_SCROLL_ANIMATION_DISTANCE; + } + + DragSelectedItem(distance, false); + + distance = ScrollTo(distance + GetScrollPosition()); + + StartReorderScrollTimer(); + } + else if (&timer == __pFastScrollTimer) + { + __isFastScrollTimerEnabled = false; + + _FastScroll* pFastScroll = __pTableView->GetFastScrollBar(); + + if (pFastScroll != null && !_ScrollPanelPresenter::IsScrollAnimationRunning()) + { + pFastScroll->SetScrollVisibility(false); + } + } +} + +result +_TableViewPresenter::StartFastScrollTimer(void) +{ + result r = E_SUCCESS; + + SysTryReturn(NID_UI_CTRL, __pFastScrollTimer != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Timer is not created."); + + r = __pFastScrollTimer->Start(FAST_SCROLL_FADE_OUT_DURATION); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __isFastScrollTimerEnabled = true; + + return r; +} + +void +_TableViewPresenter::StopFastScrollTimer(void) +{ + result r = E_SUCCESS; + + SysTryReturnVoidResult(NID_UI_CTRL, __pFastScrollTimer != null, E_INVALID_STATE, "[E_INVALID_STATE] Timer is invalid."); + + r = __pFastScrollTimer->Cancel(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __isFastScrollTimerEnabled = false; + + return; +} + +bool +_TableViewPresenter::IsEmpty(void) const +{ + if (GetItemCount() <= 0) + { + return true; + } + + return false; +} + +result +_TableViewPresenter::DrawEmptyTableView(void) +{ + return E_SUCCESS; +} + +bool +_TableViewPresenter::GetFirstItem(TableViewItemTag& firstItem) const +{ + if (IsEmpty()) + { + firstItem.groupIndex = -1; + firstItem.itemIndex = -1; + } + else + { + firstItem.groupIndex = 0; + firstItem.itemIndex = -1; + } + + return true; +} + +result +_TableViewPresenter::GetTopDrawnItem(TableViewItemTag& itemPos) const +{ + _TableViewItem* pItem = null; + TableViewItemTag lastItemPos = {-1, -1}; + int scrollPosition = 0; + + scrollPosition = GetScrollPosition(); + + __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex); + __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex); + + do + { + pItem = static_cast <_TableViewItem*>(__pListModel->LoadItem(itemPos.groupIndex, itemPos.itemIndex)); + if (pItem == null) + { + break; + } + + Rectangle itemBounds = pItem->GetBounds(); + + if (scrollPosition < (itemBounds.y + itemBounds.height)) + { + return E_SUCCESS; + } + + if ((itemPos.itemIndex == lastItemPos.itemIndex) && (itemPos.groupIndex == lastItemPos.groupIndex)) + { + break; + } + + } while (GetNextItemPosition(itemPos, itemPos) == true); + + + itemPos.itemIndex = -1; + itemPos.groupIndex = -1; + + return E_OUT_OF_RANGE; +} + +result +_TableViewPresenter::GetBottomDrawnItem(TableViewItemTag& itemPos) const +{ + _TableViewItem* pItem = null; + TableViewItemTag lastItemPos = {-1, -1}; + + if (IsEmpty()) + { + itemPos.itemIndex = -1; + itemPos.groupIndex = -1; + + return E_INVALID_STATE; + } + + int scrollPosition = GetScrollPosition() + __pTableView->GetBounds().height; + + __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex); + __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex); + + do + { + static bool onProcessingByProvider = true; + pItem = static_cast <_TableViewItem*>(__pListModel->LoadItem(itemPos.groupIndex, itemPos.itemIndex)); + onProcessingByProvider = false; + if (pItem == null) + { + break; + } + + Rectangle itemBounds = pItem->GetBounds(); + + if (itemBounds.y <= scrollPosition && scrollPosition <= (itemBounds.y + itemBounds.height)) + { + break; + } + + if ((itemPos.itemIndex == lastItemPos.itemIndex) && (itemPos.groupIndex == lastItemPos.groupIndex)) + { + break; + } + + } while (GetNextItemPosition(itemPos, itemPos) == true); + + return E_SUCCESS; +} + +bool +_TableViewPresenter::GetPreviousItemPosition(const TableViewItemTag& currentItemPos, TableViewItemTag& prevItem) const +{ + if (IsEmpty()) + { + return false; + } + + // check validation of group index + if ((currentItemPos.groupIndex < 0) || (currentItemPos.groupIndex >= __pListModel->GetAllGroupCount())) + { + return false; + } + + // if the current item is the first item + if (currentItemPos.groupIndex == 0 && currentItemPos.itemIndex == -1) + { + return false; + } + + if (currentItemPos.itemIndex == -1) + { + if (__pListModel->IsGroupExpanded(currentItemPos.groupIndex - 1) == false) + { + prevItem.groupIndex = currentItemPos.groupIndex - 1; + prevItem.itemIndex = -1; + + return true; + } + } + + if (__pListModel->IsGroupExpanded(currentItemPos.groupIndex) == false) + { + if (currentItemPos.groupIndex == 0 && currentItemPos.itemIndex == -1) + { + return false; + } + + prevItem.groupIndex = currentItemPos.groupIndex - 1; + prevItem.itemIndex = __pListModel->GetItemCountInGroup(prevItem.groupIndex) - 1; + + return true; + } + + if (currentItemPos.itemIndex == -1) // group title item + { + prevItem.groupIndex = currentItemPos.groupIndex - 1; + prevItem.itemIndex = __pListModel->GetItemCountInGroup(prevItem.groupIndex) - 1; + } + else + { + prevItem.groupIndex = currentItemPos.groupIndex; + prevItem.itemIndex = currentItemPos.itemIndex - 1; + } + + return true; +} + +bool +_TableViewPresenter::GetNextItemPosition(const TableViewItemTag& currentItem, TableViewItemTag& nextItem) const +{ + if (IsEmpty()) + { + return false; + } + + int lastGroup = __pListModel->GetAllGroupCount() - 1; + int lastItemInCurrentGroup = __pListModel->GetItemCountInGroup(currentItem.groupIndex) - 1; + int lastItem = __pListModel->GetItemCountInGroup(lastGroup) - 1; + + // check validation of group index + if ((currentItem.groupIndex < 0) || (currentItem.groupIndex > lastGroup)) + { + return false; + } + + // if the current item is the last item. + if ((currentItem.groupIndex == lastGroup) && (currentItem.itemIndex == lastItem)) + { + return false; + } + + if (__pListModel->IsGroupExpanded(currentItem.groupIndex) == false) + { + if (currentItem.groupIndex == lastGroup) + { + return false; + } + + nextItem.groupIndex = currentItem.groupIndex + 1; + nextItem.itemIndex = -1; + + return true; + } + + if (lastItemInCurrentGroup == currentItem.itemIndex) + { + nextItem.groupIndex = currentItem.groupIndex + 1; + nextItem.itemIndex = -1; + } + else + { + nextItem.groupIndex = currentItem.groupIndex; + nextItem.itemIndex = currentItem.itemIndex + 1; + } + + return true; +} + +int +_TableViewPresenter::GetHeightOfAllItems(void) const +{ + int groupCount = GetGroupCount(); + int totalHeight = 0; + + for (int i = 0; i < groupCount; i++) + { + TableViewItemTag itemTag = {i, -1}; + + totalHeight += GetItemHeight(itemTag); + + if (!IsGroupExpanded(i)) + { + continue; + } + + int itemCount = GetItemCountAt(i); + + for (int j = 0; j < itemCount; j++) + { + itemTag.itemIndex = j; + + totalHeight += GetItemHeight(itemTag); + } + } + + return totalHeight; +} + +void +_TableViewPresenter::SetTableViewItemProviderAdaptor(_TableViewItemProviderAdaptor* pProviderAdaptor) +{ + __pListModel->RegisterItemProviderAdaptor(pProviderAdaptor); + + __pProviderAdaptor = pProviderAdaptor; +} + +_TableViewItemProviderAdaptor* +_TableViewPresenter::GetTableViewItemProviderAdaptor(void) const +{ + return __pProviderAdaptor; +} + +result +_TableViewPresenter::ExpandGroup(int groupIndex, bool withAnimation) +{ + if ((groupIndex < 0) || (groupIndex >= GetGroupCount())) + { + return E_OUT_OF_RANGE; + } + + if (__modelInitialized == false) + { + return E_INVALID_STATE; + } + + if (IsGroupExpanded(groupIndex) == true) + { + return E_SUCCESS; + } + + TableViewItemTag topTag; + GetTopDrawnItem(topTag); + + TableViewItemTag bottomTag; + GetBottomDrawnItem(bottomTag); + + int screenPosition = GetScrollPosition(); + + __pListModel->SetGroupExpandState(groupIndex, true); + + int groupTotalHeight = 0; + int itemCount = GetItemCountAt(groupIndex); + _IListItemCommon* pItem = null; + for (int i = 0; i < itemCount; i++) + { + pItem = __pListModel->GetItemFromTemporaryBuffer(groupIndex, i); + groupTotalHeight += pItem->GetItemHeight(); + } + + AdjustClientAreaBounds(false, groupTotalHeight); + + if (groupIndex < topTag.groupIndex || groupIndex > bottomTag.groupIndex) + { + int firstLoadedGroupIndex = -1; + int firstLoadedItemIndex = -1; + __pListModel->GetFirstLoadedItemIndex(firstLoadedGroupIndex, firstLoadedItemIndex); + + TableViewItemTag firstLoadedItemTag = {firstLoadedGroupIndex, firstLoadedItemIndex}; + _TableViewItem* pItem = FindItem(firstLoadedItemTag); + if (pItem != null) + { + int itemPositionY = CalculateItemPositionY(firstLoadedItemTag.groupIndex, firstLoadedItemTag.itemIndex); + + Rectangle itemBounds = pItem->GetBounds(); + itemBounds.y = itemPositionY; + pItem->SetBounds(itemBounds); + + AttachNextItemsToBottom(firstLoadedItemTag); + if (groupIndex < topTag.groupIndex) + { + _ScrollPanelPresenter::ScrollTo(screenPosition + groupTotalHeight); + } + } + + return E_SUCCESS; + } + + TableViewItemTag itemTag; + itemTag.groupIndex = groupIndex; + itemTag.itemIndex = -1; + + if (withAnimation) + { + _VisualElement* pVisualElement = __pTableView->GetVisualElement(); + String animationName(L"EXPAND_GROUP_ANIMATION"); + VisualElementValueAnimation* pExpandGroupAnimation = dynamic_cast(pVisualElement->GetAnimationN(animationName)); + + if (pExpandGroupAnimation != null) + { + pVisualElement->RemoveAnimation(animationName); + } + + pExpandGroupAnimation = new (std::nothrow) VisualElementValueAnimation(); + SysTryReturn(NID_UI_CTRL, pExpandGroupAnimation != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + _TableViewItem *pItem = FindItem(itemTag); + if (pItem == null) + { + delete pExpandGroupAnimation; + + return E_SUCCESS; + } + Rectangle itemBounds = pItem->GetBounds(); + int startPosition = itemBounds.y + itemBounds.height; + + int endPosition = startPosition + groupTotalHeight; + + if (endPosition > screenPosition + __pTableView->GetBounds().height) + { + endPosition = screenPosition + __pTableView->GetBounds().height; + } + + pExpandGroupAnimation->SetStartValue(Variant(startPosition)); + pExpandGroupAnimation->SetEndValue(Variant(endPosition)); + pExpandGroupAnimation->SetDuration(EXPAND_GROUP_ANIMATION_DURATION); + pExpandGroupAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseInOut")); + pExpandGroupAnimation->SetVisualElementAnimationStatusEventListener(this); + pExpandGroupAnimation->SetVisualElementAnimationTickEventListener(this); + __expandableItemTag.groupIndex = groupIndex; + __expandableItemTag.itemIndex = -1; + pVisualElement->AddAnimation(animationName, *pExpandGroupAnimation); + + delete pExpandGroupAnimation; + } + else + { + LoadItemsToBeVisible(itemTag); + AttachNextItemsToBottom(itemTag); + SetLoadedItemsVisibleInGroup(groupIndex, true); + + int currentGroupIndex = -1; + int currentItemIndex = -1; + GetBottomDrawnItemIndex(currentGroupIndex, currentItemIndex); + + int lastLoadedGroupIndex = -1; + int lastLoadedItemIndex = -1; + __pListModel->GetLastLoadedItemIndex(lastLoadedGroupIndex, lastLoadedItemIndex); + + for (int j = currentGroupIndex; j <= lastLoadedGroupIndex; j++) + { + int itemCount = GetItemCountAt(j); + + for (int i = -1; i < itemCount; i++) + { + if (i <= currentItemIndex && j == currentGroupIndex) + { + continue; + } + + UnloadItem(j, i); + } + } + } + + return E_SUCCESS; +} + +result +_TableViewPresenter::CollapseGroup(int groupIndex, bool withAnimation) +{ + if ((groupIndex < 0) || (groupIndex >= GetGroupCount())) + { + return E_OUT_OF_RANGE; + } + + if (__modelInitialized == false) + { + return E_INVALID_STATE; + } + + if (IsGroupExpanded(groupIndex) == false) + { + return E_SUCCESS; + } + + TableViewItemTag itemTag; + GetTopDrawnItem(itemTag); + + TableViewItemTag bottomTag; + GetBottomDrawnItem(bottomTag); + int screenPosition = GetScrollPosition(); + + __pListModel->SetGroupExpandState(groupIndex, false); + + ResetSweepItem(); + + int groupTotalHeight = 0; + int itemCount = GetItemCountAt(groupIndex); + _IListItemCommon* pItem = null; + for (int i = 0; i < itemCount; i++) + { + pItem = __pListModel->GetItemFromTemporaryBuffer(groupIndex, i); + groupTotalHeight += pItem->GetItemHeight(); + } + + if (groupIndex < itemTag.groupIndex || groupIndex > bottomTag.groupIndex) + { + TableViewItemTag firstLoadedItemTag; + __pListModel->GetFirstLoadedItemIndex(firstLoadedItemTag.groupIndex, firstLoadedItemTag.itemIndex); + + if (firstLoadedItemTag.groupIndex == groupIndex) + { + SetLoadedItemsVisibleInGroup(groupIndex, false); + firstLoadedItemTag.groupIndex = groupIndex + 1; + firstLoadedItemTag.itemIndex = -1; + } + + _TableViewItem* pItem = FindItem(firstLoadedItemTag); + if (pItem != null) + { + int itemPositionY = CalculateItemPositionY(firstLoadedItemTag.groupIndex, firstLoadedItemTag.itemIndex); + + Rectangle itemBounds = pItem->GetBounds(); + itemBounds.y = itemPositionY; + pItem->SetBounds(itemBounds); + + AttachNextItemsToBottom(firstLoadedItemTag); + if (groupIndex < itemTag.groupIndex) + { + _ScrollPanelPresenter::ScrollTo(screenPosition - groupTotalHeight); + } + } + + for (int i = 0; i < itemCount; i++) + { + UnloadItem(groupIndex, i); + } + AdjustClientAreaBounds(false, -groupTotalHeight); + + return E_SUCCESS; + } + + if (itemTag.groupIndex < groupIndex) + { + itemTag.groupIndex = groupIndex; + itemTag.itemIndex = -1; + } + + if(__firstDrawnFlag) + { + withAnimation = false; + } + + if (withAnimation) + { + _TableViewItem *pItem = FindItem(itemTag); + if (pItem == null) + { + return E_SUCCESS; + } + + _VisualElement* pVisualElement = __pTableView->GetVisualElement(); + String animationName(L"COLLAPSE_GROUP_ANIMATION"); + VisualElementValueAnimation* pCollapseGroupAnimation = dynamic_cast(pVisualElement->GetAnimationN(animationName)); + + if (pCollapseGroupAnimation != null) + { + pVisualElement->RemoveAnimation(animationName); + } + + pCollapseGroupAnimation = new (std::nothrow) VisualElementValueAnimation(); + SysTryReturn(NID_UI_CTRL, pCollapseGroupAnimation != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + Rectangle itemBounds = pItem->GetBounds(); + int startPosition = 0; + if (itemTag.itemIndex == -1) + { + startPosition = itemBounds.y + itemBounds.height; + } + else + { + startPosition = GetScrollPosition(); + } + + if (bottomTag.groupIndex > groupIndex) + { + bottomTag.groupIndex = groupIndex+1; + bottomTag.itemIndex = -1; + } + + pItem = FindItem(bottomTag); + if (pItem == null) + { + delete pCollapseGroupAnimation; + + return E_SUCCESS; + } + + itemBounds = pItem->GetBounds(); + int endPosition = itemBounds.y; + if (bottomTag.groupIndex != groupIndex +1) + { + endPosition += itemBounds.height; + } + if (endPosition > screenPosition + __pTableView->GetBounds().height) + { + endPosition = screenPosition + __pTableView->GetBounds().height; + } + + pCollapseGroupAnimation->SetStartValue(Variant(endPosition)); + pCollapseGroupAnimation->SetEndValue(Variant(startPosition)); + pCollapseGroupAnimation->SetDuration(COLLAPSE_GROUP_ANIMATION_DURATION); + pCollapseGroupAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseInOut")); + pCollapseGroupAnimation->SetVisualElementAnimationStatusEventListener(this); + pCollapseGroupAnimation->SetVisualElementAnimationTickEventListener(this); + __expandableItemTag.groupIndex = itemTag.groupIndex; + __expandableItemTag.itemIndex = itemTag.itemIndex; + pVisualElement->AddAnimation(animationName, *pCollapseGroupAnimation); + + delete pCollapseGroupAnimation; + } + else + { + TableViewItemTag nextTag = {groupIndex + 1, -1}; + + if (itemTag.itemIndex != -1) + { + int itemPositionY = CalculateItemPositionY(nextTag.groupIndex, nextTag.itemIndex); + _TableViewItem* pNextItem = LoadItem(nextTag.groupIndex, nextTag.itemIndex); + + Rectangle itemBounds = pNextItem->GetBounds(); + itemBounds.y = itemPositionY; + pNextItem->SetBounds(itemBounds); + + AttachNextItemsToBottom(nextTag); + + _ScrollPanelPresenter::ScrollTo(itemPositionY); + } + else + { + AttachNextItemsToBottom(itemTag); + } + + LoadItemsToBeVisible(nextTag); + SetLoadedItemsVisibleInGroup(groupIndex, false); + } + + AdjustClientAreaBounds(false, -groupTotalHeight); + + return E_SUCCESS; +} + +bool +_TableViewPresenter::IsGroupExpanded(int groupIndex) const +{ + return __pListModel->IsGroupExpanded(groupIndex); +} + +int +_TableViewPresenter::LoadAllItemsInGroup(int groupIndex, bool downward) +{ + int itemCountInGroup = __pListModel->GetItemCountInGroup(groupIndex); + _TableViewItem* pItem = null; + + if (downward) + { + for (int i = 0; i < itemCountInGroup; i++) + { + pItem = LoadItem(groupIndex, i); + + if (pItem == null) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to load item."); + } + } + } + else + { + for (int i = itemCountInGroup-1; i >= 0; i--) + { + pItem = LoadItem(groupIndex, i); + + if (pItem == null) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to load item."); + } + } + } + + return itemCountInGroup; +} + +void +_TableViewPresenter::SetLoadedItemsVisibleInGroup(int groupIndex, bool visible) +{ + int itemCountInGroup = __pListModel->GetItemCountInGroup(groupIndex); + _TableViewItem* pItem = null; + TableViewItemTag itemTag; + itemTag.groupIndex = groupIndex; + + int firstLoadedGroupIndex = -1; + int firstLoadedItemIndex = -1; + __pListModel->GetFirstLoadedItemIndex(firstLoadedGroupIndex, firstLoadedItemIndex); + + if (firstLoadedGroupIndex > groupIndex) + { + return; + } + + int startIndex = 0; + if (groupIndex == firstLoadedGroupIndex && firstLoadedItemIndex > 0) + { + startIndex = firstLoadedItemIndex; + } + + for (int i = startIndex; i < itemCountInGroup; i++) + { + itemTag.itemIndex = i; + pItem = FindItem(itemTag); + if (pItem == null) + { + continue; + } + + pItem->SetVisibleState(visible); + } +} + +TableViewItemTag +_TableViewPresenter::LoadItemsToBeVisible(const TableViewItemTag& from) +{ + TableViewItemTag bottomTag = from; + TableViewItemTag current; + TableViewItemTag next; + + _TableViewItem *pItem = LoadItem(from.groupIndex, from.itemIndex); + + if (pItem == null) + { + return from; + } + + Rectangle itemBounds = pItem->GetBounds(); + int viewHeight = __pTableView->GetBounds().height; + int scrollPosition = GetScrollPosition(); + int itemPosition = itemBounds.y + itemBounds.height - scrollPosition; + + while (viewHeight >= itemPosition) + { + current.groupIndex = bottomTag.groupIndex; + current.itemIndex = bottomTag.itemIndex; + if (!GetNextItemPosition(current, next)) + { + break; + } + + pItem = LoadItem(next.groupIndex, next.itemIndex); + bottomTag.groupIndex = next.groupIndex; + bottomTag.itemIndex = next.itemIndex; + itemPosition += pItem->GetBounds().height; + } + + return bottomTag; +} + +void +_TableViewPresenter::AttachNextItemsToBottom(const TableViewItemTag& anchor) +{ + TableViewItemTag itemTag = anchor; + TableViewItemTag current; + TableViewItemTag next; + + _TableViewItem *pItem = FindItem(itemTag); + if (pItem == null) + { + return; + } + + Rectangle itemBounds = pItem->GetBounds(); + int itemPosition = itemBounds.y + itemBounds.height; + + current.groupIndex = itemTag.groupIndex; + current.itemIndex = itemTag.itemIndex; + while (GetNextItemPosition(current, next)) + { + pItem = FindItem(next); + if (pItem == null) + { + current = next; + continue; + } + + itemBounds = pItem->GetBounds(); + itemBounds.y = itemPosition; + pItem->SetBounds(itemBounds); + itemPosition += itemBounds.height; + current = next; + } +} + +bool +_TableViewPresenter::IsAnyItemInGroupLoaded(int groupIndex) const +{ + int startGroupIndex = 0; + int endGroupIndex = 0; + int index = 0; + + __pListModel->GetFirstLoadedItemIndex(startGroupIndex, index); + __pListModel->GetLastLoadedItemIndex(endGroupIndex, index); + + return groupIndex >= startGroupIndex && groupIndex <= endGroupIndex; +} + +void +_TableViewPresenter::ScrollToHideNonClientArea(TableViewItemTag& bottomTag) +{ + _TableViewItem* pItem = FindItem(bottomTag); + if (pItem == null) + { + return ; + } + + Rectangle itemBounds = pItem->GetBounds(); + int viewHeight = __pTableView->GetBounds().height; + int scrollPosition = GetScrollPosition(); + int itemBottom = itemBounds.y + itemBounds.height - scrollPosition; + + if (itemBottom < viewHeight) + { + scrollPosition -= viewHeight - itemBottom; + if (scrollPosition < 0) + { + scrollPosition = 0; + } + + SetScrollPosition(scrollPosition, false); + } +} + +void +_TableViewPresenter::AdjustClientAreaBounds(bool reset, int dist) +{ + int clientHeight = 0; + + if (reset) + { + __itemTotalHeight = GetHeightOfAllItems(); + clientHeight = __itemTotalHeight; + } + else + { + __itemTotalHeight = __itemTotalHeight + dist; + clientHeight = __itemTotalHeight; + } + + SetClientAreaHeight(clientHeight); +} + +void +_TableViewPresenter::SetClientAreaHeight(int height) +{ + Rectangle screenBounds = __pTableView->GetBounds(); + Rectangle clientBounds = screenBounds; + + clientBounds.height = height; + + if (clientBounds.height < screenBounds.height) + { + clientBounds.height = screenBounds.height; + } + + SetScrollAreaBounds(clientBounds); + + _Scroll* pScroll = __pTableView->GetScrollBar(); + if (pScroll != null) + { + pScroll->SetScrollRange(__pTableView->GetBounds().height, clientBounds.height); + } +} + +void +_TableViewPresenter::UnloadInvisibleItems(void) +{ + int scrollPosition = GetScrollPosition(); + TableViewItemTag itemTag; + __pListModel->GetFirstLoadedItemIndex(itemTag.groupIndex, itemTag.itemIndex); + + _TableViewItem* pItem = null; + Rectangle bounds; + + while ((pItem = FindItem(itemTag)) != null) + { + if (itemTag.itemIndex != -1) + { + bounds = pItem->GetBounds(); + if (bounds.y + bounds.height < scrollPosition) + { + UnloadItem(itemTag); + } + else + { + break; + } + } + __pListModel->GetFirstLoadedItemIndex(itemTag.groupIndex, itemTag.itemIndex); + } + + __pListModel->GetLastLoadedItemIndex(itemTag.groupIndex, itemTag.itemIndex); + scrollPosition += __pTableView->GetBounds().height; + + while ((pItem = FindItem(itemTag)) != null) + { + if (itemTag.itemIndex != -1) + { + bounds = pItem->GetBounds(); + if (bounds.y > scrollPosition) + { + UnloadItem(itemTag); + } + else + { + break; + } + } + __pListModel->GetLastLoadedItemIndex(itemTag.groupIndex, itemTag.itemIndex); + } + +} + +int +_TableViewPresenter::ScrollToInternal(int newPosition) +{ + if (!IsScrollEnabled()) + { + return 0; + } + + int previousScrollPosition = _ScrollPanelPresenter::GetScrollPosition(); + int scrollAreaHeight = _ScrollPanelPresenter::GetScrollAreaBounds().height; + int currentScrollPosition = (newPosition < 0) ? 0 : (newPosition > scrollAreaHeight ? scrollAreaHeight : newPosition); + + LoadItemWithScrollPosition(previousScrollPosition, currentScrollPosition); + + return _ScrollPanelPresenter::ScrollToInternal(newPosition); +} + +void +_TableViewPresenter::LoadItemWithScrollPosition(int previousScrollPosition, int currentScrollPos) +{ + ClearLastResult(); + + TableViewItemTag lastLoadedItemPos = {-1, -1}; + TableViewItemTag firstLoadedItemPos = {-1, -1}; + __pListModel->GetLastLoadedItemIndex(lastLoadedItemPos.groupIndex, lastLoadedItemPos.itemIndex); + __pListModel->GetFirstLoadedItemIndex(firstLoadedItemPos.groupIndex, firstLoadedItemPos.itemIndex); + + if (currentScrollPos > previousScrollPosition && lastLoadedItemPos.groupIndex != -1) + { + _TableViewItem* lastItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(lastLoadedItemPos.groupIndex, lastLoadedItemPos.itemIndex)); + if (lastItem == null) + { + return; + } + + while (lastItem->GetBounds().y <= currentScrollPos + __pTableView->GetBounds().height) + { + TableViewItemTag nextItemPos = {-1, -1}; + if (GetNextItemPosition(lastLoadedItemPos, nextItemPos)) + { + if (nextItemPos.itemIndex == -1) + { + LoadItem(nextItemPos.groupIndex, nextItemPos.itemIndex); + + if (!GetNextItemPosition(nextItemPos, nextItemPos)) + { + break; + } + } + + if (nextItemPos.groupIndex != -1) + { + _TableViewItem* item = LoadItem(nextItemPos.groupIndex, nextItemPos.itemIndex); + + Rectangle scrollAreaBounds = _ScrollPanelPresenter::GetScrollAreaBounds(); + if (item->GetBounds().y + item->GetBounds().height >= scrollAreaBounds.height) + { + AdjustClientAreaBounds(true); + } + } + } + else + { + break; + } + + lastLoadedItemPos = nextItemPos; + lastItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(lastLoadedItemPos.groupIndex, lastLoadedItemPos.itemIndex)); + } + } + + if (currentScrollPos < previousScrollPosition && firstLoadedItemPos.groupIndex != -1) + { + _TableViewItem* firstItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(firstLoadedItemPos.groupIndex, firstLoadedItemPos.itemIndex)); + if (firstItem == null) + { + return; + } + + while (firstItem->GetBounds().y + firstItem->GetBounds().height >= currentScrollPos) + { + TableViewItemTag prevItemPos = {-1, -1}; + if (GetPreviousItemPosition(firstLoadedItemPos, prevItemPos)) + { + if (prevItemPos.itemIndex == -1) + { + LoadItem(prevItemPos.groupIndex, prevItemPos.itemIndex); + + if (!GetPreviousItemPosition(prevItemPos, prevItemPos)) + { + break; + } + } + + if (prevItemPos.groupIndex != -1) + { + LoadItem(prevItemPos.groupIndex, prevItemPos.itemIndex); + } + } + else + { + break; + } + + firstLoadedItemPos = prevItemPos; + firstItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(firstLoadedItemPos.groupIndex, firstLoadedItemPos.itemIndex)); + } + } +} + +void +_TableViewPresenter::ScrollToItem(int groupIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment, int shiftingDistance) +{ + TableViewItemTag itemPos = {groupIndex, itemIndex}; + + if (!__pListModel->IsLoadedItem(groupIndex, itemIndex)) + { + ResetItemLayout(itemPos); + } + + _TableViewItem* pItem = FindItem(itemPos); + + if (pItem == null) + { + return; + } + + int scrollPosition = pItem->GetBounds().y; + + scrollPosition = scrollPosition + shiftingDistance; + + SetScrollPosition(scrollPosition, false); + + if (itemAlignment == TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM) + { + SetScrollPosition(scrollPosition - (__pTableView->GetBounds().height - pItem->GetBounds().height), false); + } +} + +result +_TableViewPresenter::ScrollByPixel(int scrollDistance) +{ + FadeInScrollBar(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + ScrollTo(scrollDistance + GetScrollPosition()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + RollbackBouncing(true); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + FadeOutScrollBar(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +_TableViewPresenter::SetScrollEnabled(bool enable) +{ + __scrolling = enable; +} + +bool +_TableViewPresenter::IsScrollEnabled(void) const +{ + return __scrolling; +} + +bool +_TableViewPresenter::GetFirstDrawnFlag(void) const +{ + return __firstDrawnFlag; +} + +int +_TableViewPresenter::GetMaxItemCachingSize(void) const +{ + return __pListModel->GetMaxCachingSize(); +} + +void +_TableViewPresenter::ResetSweepItem(void) +{ + if (__sweptItemTag.groupIndex != -1 && __sweptItemTag.itemIndex != -1) + { + ResetSweptItem(); + } +} + +int +_TableViewPresenter::GetPressedItemCount(void) +{ + _TableViewItem* pItem = null; + TableViewItemTag itemPos = {-1, -1}; + TableViewItemTag lastItemPos = {-1, -1}; + int count = 0; + + __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex); + __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex); + + do + { + pItem = static_cast <_TableViewItem*>(__pListModel->LoadItem(itemPos.groupIndex, itemPos.itemIndex)); + if (pItem == null) + { + continue; + } + + if (pItem->GetDrawingStatus() == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) + { + count++; + } + + if ((itemPos.itemIndex == lastItemPos.itemIndex) && (itemPos.groupIndex == lastItemPos.groupIndex)) + { + break; + } + } while (GetNextItemPosition(itemPos, itemPos) == true); + + return count; +} + +int +_TableViewPresenter::CalculateItemPositionY(int groupIndex, int itemIndex) +{ + TableViewItemTag itemPos = {-1, -1}; + TableViewItemTag currentItemPos = {-1, -1}; + int positionY = 0; + + GetFirstItem(itemPos); + + if (itemPos.groupIndex == -1 && itemPos.itemIndex == -1) + { + return 0; + } + + if (__pProviderAdaptor == null) + { + return -1; + } + + positionY = GetTopMargin(); + + while ((itemPos.groupIndex < groupIndex) || ((itemPos.groupIndex == groupIndex) && (itemPos.itemIndex < itemIndex))) + { + currentItemPos = itemPos; + + int itemHeight = GetItemHeight(itemPos); + + positionY += itemHeight; + + if (!GetNextItemPosition(currentItemPos, itemPos)) + { + break; + } + } + + return positionY; +} + +void +_TableViewPresenter::FadeInScrollBar(void) +{ + TableViewScrollBarStyle scrollStyle = __pTableView->GetScrollStyle(); + + if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_NONE) + { + _Scroll* pScroll = __pTableView->GetScrollBar(); + + if (pScroll != null) + { + pScroll->SetVisibleState(false); + } + } + else if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL) + { + _Scroll* pScroll = __pTableView->GetScrollBar(); + + if (pScroll != null) + { + pScroll->SetVisibleState(false); + } + + _FastScroll* pFastScroll = __pTableView->GetFastScrollBar(); + + if (pFastScroll != null) + { + pFastScroll->SetScrollVisibility(true); + } + } + else + { + _ScrollPanelPresenter::FadeInScrollBar(); + } +} + +void +_TableViewPresenter::FadeOutScrollBar(void) +{ + TableViewScrollBarStyle scrollStyle = __pTableView->GetScrollStyle(); + if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL) + { + StopFastScrollTimer(); + + if (!_ScrollPanelPresenter::IsScrollAnimationRunning()) + { + StartFastScrollTimer(); + } + } + else if (scrollStyle != TABLE_VIEW_SCROLL_BAR_STYLE_FIXED) + { + _ScrollPanelPresenter::FadeOutScrollBar(); + } +} + +void +_TableViewPresenter::SweepItem(int x) +{ + if (x != 0) + { + _TableViewItem* pItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex)); + + if (pItem != null) + { + _TableViewItem* pContextItem = pItem->GetContextItem(); + + if (pContextItem != null) + { + int currentPosition = __sweptItemPosition.x + x; + int sweepDistance = __pTableView->GetBounds().width; + int sweepMargin = 0; + int contextItemWidth = pItem->GetBounds().width; + bool activated = pItem->IsContextItemActivated(); + bool needToFireEvent = false; + + GET_SHAPE_CONFIG(TABLEVIEW::CONTEXTITEM_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sweepMargin); + + if (currentPosition >= (sweepDistance - sweepMargin)) + { + currentPosition = (sweepDistance - sweepMargin); + needToFireEvent = !activated; + } + else if (currentPosition <= __leftMargin) + { + currentPosition = __leftMargin; + needToFireEvent = activated; + } + + __sweptItemPosition.x = currentPosition; + + // Set TableViewItem bounds + pItem->SetPosition(__sweptItemPosition); + + // Set TableViewContextItem bounds + if (!__pTableView->IsAncestorOf(*pContextItem)) + { + pContextItem->SetDrawingProperty(__pItemDrawingProperty); + __pTableView->InsertChildToBottom(*pContextItem); + } + + contextItemWidth = ((contextItemWidth > (__sweptItemPosition.x - __leftMargin)) ? (__sweptItemPosition.x - __leftMargin) : contextItemWidth); + + pContextItem->ExposeContextItem(Rectangle(__leftMargin, __sweptItemPosition.y, contextItemWidth, pContextItem->GetSize().height), pItem->GetSize().width); + + if (needToFireEvent) + { + activated = !activated; // ContextItem Activation State Changed + + __pTableView->FireTableViewContextItemActivationEvent(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex, pContextItem, activated); + pItem->SetContextItemActivation(activated); + + if (!activated) + { + ResetSweepItem(); + } + } + } + } + } +} + +void +_TableViewPresenter::ResetSweptItem(void) +{ + _TableViewItem* pItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex)); + + if (pItem != null) + { + pItem->SetPosition(Point(__leftMargin, __sweptItemPosition.y)); + + _TableViewItem* pContextItem = pItem->GetContextItem(); + if (pContextItem != null) + { + if (__pTableView->IsAncestorOf(*pContextItem)) + { + __pTableView->DetachChild(*pContextItem); + } + + if (pItem->IsContextItemActivated()) + { + __pTableView->FireTableViewContextItemActivationEvent(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex, pContextItem, false); + pItem->SetContextItemActivation(false); + } + } + } + + __sweptItemTag.itemIndex = -1; + __sweptItemTag.groupIndex = -1; + + __sweptItemPosition.SetPosition(-1, -1); + __sweepOccured = false; +} + +void +_TableViewPresenter::AdjustSweptItemPosition(bool withAnimation) +{ + int itemWidth = __pTableView->GetBounds().width; + int sweepDistance = 0; + + if (__sweptItemPosition.x == __leftMargin) + { + ResetSweptItem(); + return; + } + + int sweepMargin = 0; + GET_SHAPE_CONFIG(TABLEVIEW::CONTEXTITEM_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sweepMargin); + + if (__sweptItemPosition.x > (itemWidth - sweepMargin) / 2) + { + sweepDistance = itemWidth - __sweptItemPosition.x; + } + else + { + sweepDistance = -__sweptItemPosition.x; + } + + if (!withAnimation) + { + SweepItem(sweepDistance); + } + else + { + _TableViewItem* pItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex)); + + if (pItem != null) + { + VisualElementValueAnimation* pAnimation = null; + _VisualElement* pVisualElement = __pTableView->GetVisualElement(); + + if (pVisualElement != null) + { + int startValue = __sweptItemPosition.x; + int endValue = ((sweepDistance > 0) ? (itemWidth - sweepMargin) : __leftMargin); + + pVisualElement->SetImplicitAnimationEnabled(false); + + String animationName(L"SWEEP_ITEM_ANIMATION"); + pAnimation = dynamic_cast(pVisualElement->GetAnimationN(animationName)); + + if (pAnimation != null) + { + pVisualElement->RemoveAnimation(animationName); + } + + pAnimation = new (std::nothrow) VisualElementValueAnimation(); + SysTryReturnVoidResult(NID_UI_CTRL, pAnimation != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pAnimation->SetStartValue(Variant(startValue)); + pAnimation->SetEndValue(Variant(endValue)); + pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseInOut")); + pAnimation->SetDuration(SWEEP_ITEM_ANIMATION_DURATION); + pAnimation->SetVisualElementAnimationStatusEventListener(this); + pAnimation->SetVisualElementAnimationTickEventListener(this); + + pVisualElement->AddAnimation(animationName, *pAnimation); + + delete pAnimation; + } + } + } +} + +void +_TableViewPresenter::AdjustLoadedItemWidth(void) +{ + TableViewItemTag lastLoadedItemPos = {-1, -1}; + TableViewItemTag firstLoadedItemPos = {-1, -1}; + __pListModel->GetLastLoadedItemIndex(lastLoadedItemPos.groupIndex, lastLoadedItemPos.itemIndex); + __pListModel->GetFirstLoadedItemIndex(firstLoadedItemPos.groupIndex, firstLoadedItemPos.itemIndex); + + do + { + _TableViewItem* pItem = FindItem(firstLoadedItemPos); + + if (pItem == null) + { + continue; + } + + Dimension itemSize = pItem->GetSize(); + itemSize.width = __pProviderAdaptor->GetListWidth(); + + pItem->SetItemChanged(true); + pItem->SetSize(itemSize); + + if ((firstLoadedItemPos.itemIndex == lastLoadedItemPos.itemIndex) && (firstLoadedItemPos.groupIndex == lastLoadedItemPos.groupIndex)) + { + break; + } + } while (GetNextItemPosition(firstLoadedItemPos, firstLoadedItemPos)); +} + +bool +_TableViewPresenter::IsValidDrawnItem(int groupIndex, int itemIndex) +{ + TableViewItemTag currentItemTag = {groupIndex, itemIndex}; + TableViewItemTag itemTag = {-1, -1}; + + if (GetNextItemPosition(currentItemTag, itemTag)) + { + if (__pListModel->IsLoadedItem(itemTag.groupIndex, itemTag.itemIndex)) + { + return true; + } + } + + if (GetPreviousItemPosition(currentItemTag, itemTag)) + { + if (__pListModel->IsLoadedItem(itemTag.groupIndex, itemTag.itemIndex)) + { + return true; + } + } + + return false; +} + + +bool +_TableViewPresenter::GetTableViewItemPosition(_TableViewItem& item, TableViewItemTag& itemTag) +{ + TableViewItemTag lastLoadedItemPos = {-1, -1}; + TableViewItemTag firstLoadedItemPos = {-1, -1}; + __pListModel->GetLastLoadedItemIndex(lastLoadedItemPos.groupIndex, lastLoadedItemPos.itemIndex); + __pListModel->GetFirstLoadedItemIndex(firstLoadedItemPos.groupIndex, firstLoadedItemPos.itemIndex); + + _TableViewItem* pCurrentItem = null; + do + { + pCurrentItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(firstLoadedItemPos.groupIndex, firstLoadedItemPos.itemIndex)); + if (pCurrentItem == &item) + { + itemTag.groupIndex = firstLoadedItemPos.groupIndex; + itemTag.itemIndex = firstLoadedItemPos.itemIndex; + return true; + } + + if ((firstLoadedItemPos.itemIndex == lastLoadedItemPos.itemIndex) && (firstLoadedItemPos.groupIndex == lastLoadedItemPos.groupIndex)) + { + break; + } + } while (GetNextItemPosition(firstLoadedItemPos, firstLoadedItemPos)); + + return false; +} + +int +_TableViewPresenter::GetItemHeight(TableViewItemTag itemTag) const +{ + int itemHeight = 0; + + if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION && itemTag.itemIndex != -1) + { + if (HasSectionFooter(itemTag.groupIndex)) + { + if (itemTag.itemIndex == GetItemCountAt(itemTag.groupIndex) - 1) + { + GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, itemHeight); + + return itemHeight; + } + } + } + + if (__pProviderAdaptor == null) + { + return -1; + } + + int startIndex = 0; + for (int i = 0; i < itemTag.groupIndex; i++) + { + int itemCount = GetItemCountAt(i); + + startIndex = startIndex + itemCount + 1; + } + + itemTag.itemIndex++; + itemTag.itemIndex = startIndex + itemTag.itemIndex; + + __itemHeightList.GetAt(itemTag.itemIndex, itemHeight); + + return itemHeight; +} + +int +_TableViewPresenter::SetItemHeight(TableViewItemTag itemTag, int height) +{ + int startIndex = 0; + + for (int i = 0; i < itemTag.groupIndex; i++) + { + int itemCount = GetItemCountAt(i); + + startIndex = startIndex + itemCount + 1; + } + + itemTag.itemIndex++; + itemTag.itemIndex = startIndex + itemTag.itemIndex; + + int oldHeight = 0; + __itemHeightList.GetAt(itemTag.itemIndex, oldHeight); + __itemHeightList.SetAt(height, itemTag.itemIndex); + + return oldHeight; +} + + +result +_TableViewPresenter::SetReorderMode(bool enabled) +{ + ResetSweepItem(); + + __reorderInfo.itemIndex = -1; + __reorderInfo.groupIndex = -1; + + _TableViewItem* pItem = null; + TableViewItemTag itemPos = {-1, -1}; + TableViewItemTag lastItemPos = {-1, -1}; + + __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex); + __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex); + + do + { + pItem = FindItem(itemPos); + + if (pItem != null) + { + pItem->SetReorderMode(enabled); + + if (pItem->GetDrawingStatus() == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED) + { + if (SelectReorderItem(itemPos.groupIndex, itemPos.itemIndex)) + { + Point itemPosition = pItem->GetPosition(); + Point touchPosition = pItem->GetLastTouchPressedPosition(); + + __reorderInfo.touchPressedPositionY = itemPosition.y + touchPosition.y - GetScrollPosition(); + __reorderInfo.blockedTouchReleaseState = true; + } + } + } + + if ((itemPos.itemIndex == lastItemPos.itemIndex) && (itemPos.groupIndex == lastItemPos.groupIndex)) + { + break; + } + + } while (GetNextItemPosition(itemPos, itemPos) == true); + + return E_SUCCESS; +} + +bool +_TableViewPresenter::SelectReorderItem(int groupIndex, int itemIndex) +{ + if (itemIndex == -1 || GetPressedItemCount() > 0) + { + return false; + } + + TableViewItemTag itemPos = {groupIndex, itemIndex}; + _TableViewItem* pItem = FindItem(itemPos); + + if (pItem == null) + { + return false; + } + + pItem->SetDrawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED); + pItem->SetItemChanged(true); + pItem->Invalidate(); + + __reorderInfo.itemBounds = pItem->GetBounds(); + __reorderInfo.itemIndex = itemIndex; + __reorderInfo.groupIndex = groupIndex; + __reorderInfo.originGroupIndex = groupIndex; + __reorderInfo.originItemIndex = itemIndex; + __reorderInfo.itemBasisPositionY = __reorderInfo.itemBounds.y; + + Tizen::System::SystemTime::GetTicks(__reorderInfo.touchPressedTick); + + pItem->GetVisualElement()->SetZOrder(null, true); + + if (GetScrollAreaBounds().height < __pTableView->GetBounds().height) + { + int itemHeight = pItem->GetBounds().height; + + __pListModel->GetLastLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex); + + pItem = FindItem(itemPos); + + if (pItem != null) + { + Rectangle itemBounds = pItem->GetBounds(); + __reorderInfo.nonScrollableLimitArea = itemBounds.y + itemBounds.height - itemHeight; + } + } + else + { + __reorderInfo.nonScrollableLimitArea = 0; + } + + return true; +} + +bool +_TableViewPresenter::ResetReorderItem(int groupIndex, int itemIndex) +{ + TableViewItemTag itemPos = {groupIndex, itemIndex}; + _TableViewItem* pItem = FindItem(itemPos); + + if (pItem == null) + { + return false; + } + + pItem->SetDrawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + pItem->SetItemChanged(true); + pItem->Invalidate(); + + Point position = Point(__reorderInfo.itemBounds.x, __reorderInfo.itemBounds.y); + pItem->SetPosition(position); + + if (__reorderInfo.originGroupIndex != __reorderInfo.groupIndex || __reorderInfo.originItemIndex != __reorderInfo.itemIndex) + { + if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE) + { + __pTableView->FireTableViewItemReorderEvent(__reorderInfo.originItemIndex, __reorderInfo.itemIndex); + } + else if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_GROUPED) + { + __pTableView->FireTableViewItemReorderEvent(__reorderInfo.originGroupIndex, __reorderInfo.originItemIndex, __reorderInfo.groupIndex, __reorderInfo.itemIndex); + } + } + + __reorderInfo.groupIndex = -1; + __reorderInfo.itemIndex = -1; + __reorderInfo.originGroupIndex = -1; + __reorderInfo.originItemIndex = -1; + __reorderInfo.nonScrollableLimitArea = 0; + + StopReorderScrollTimer(); + + return true; +} + +bool +_TableViewPresenter::CheckReorderItemScrollAnimation(_TableViewItem *pItem) +{ + int currentScrollPosition = GetScrollPosition(); + int limitTopPositionY = currentScrollPosition; + int limitBottomPositionY = currentScrollPosition + __pTableView->GetBounds().height - __reorderInfo.itemBounds.height; + + int itemPositionY = pItem->GetPosition().y; + + if (itemPositionY < limitTopPositionY) + { + if (__pReorderScrollTimer == null) + { + __reorderInfo.isScrollDirectionUp = true; + + return true; + } + } + else if (itemPositionY > limitBottomPositionY) + { + if (__pReorderScrollTimer == null) + { + __reorderInfo.isScrollDirectionUp = false; + + return true; + } + } + + return false; +} + +bool +_TableViewPresenter::DragSelectedItem(int distance, bool relativeCoordinate) +{ + TableViewItemTag itemPos = {__reorderInfo.groupIndex, __reorderInfo.itemIndex}; + _TableViewItem* pItem = FindItem(itemPos); + + if (pItem == null) + { + return false; + } + + if (__firstTouchMoved) + { + long long currentTick = 0; + Tizen::System::SystemTime::GetTicks(currentTick); + + if (currentTick - __reorderInfo.touchPressedTick < REORDER_TOUCH_UIACTIVATE_DURATION) + { + return false; + } + + __firstTouchMoved = false; + } + + Point itemPosition = pItem->GetPosition(); + + if (relativeCoordinate) + { + itemPosition.y = __reorderInfo.itemBasisPositionY + distance; + } + else + { + itemPosition.y += distance; + + __reorderInfo.itemBasisPositionY += distance; + } + + if (itemPosition.y < 0) + { + itemPosition.y = 0; + } + + int scrollAreaHeight = GetScrollAreaBounds().height; + int screenHeight = __pTableView->GetBounds().height; + int limitBottomPositionY = 0; + + if (scrollAreaHeight < screenHeight) + { + limitBottomPositionY = __reorderInfo.nonScrollableLimitArea; + } + else + { + limitBottomPositionY = scrollAreaHeight - __reorderInfo.itemBounds.height; + } + + if (itemPosition.y > limitBottomPositionY) + { + itemPosition.y = limitBottomPositionY; + } + + pItem->SetPosition(itemPosition); + + // check scroll + if (CheckReorderItemScrollAnimation(pItem)) + { + if (__pReorderScrollTimer == null) + { + StartReorderScrollTimer(); + } + } + else + { + if (__pReorderScrollTimer != null) + { + StopReorderScrollTimer(); + } + } + + // check swap + TableViewItemTag moveItemTag = {-1, -1}; + + if (CheckReorderItemPosition(pItem, moveItemTag)) + { + if (moveItemTag.itemIndex == -1) + { + int destGroupIndex = moveItemTag.groupIndex; + + if (destGroupIndex != 0 && destGroupIndex == __reorderInfo.groupIndex) + { + destGroupIndex--; + } + + if (moveItemTag.groupIndex == 0 || !__pProviderAdaptor->IsReorderable(__reorderInfo.groupIndex, destGroupIndex)) + { +// ResetReorderItem(__reorderInfo.groupIndex, __reorderInfo.itemIndex); +// itemPosition = pItem->GetPosition(); +// +// _TableViewItem* pGroupItem = FindItem(moveItemTag); +// +// if (pGroupItem == null) +// { +// return false; +// } +// +// Rectangle groupItemBounds = pGroupItem->GetBounds(); +// +// if (__reorderInfo.groupIndex < moveItemTag.groupIndex) +// { +// itemPosition.y = groupItemBounds.y - pItem->GetItemHeight(); +// } +// else +// { +// itemPosition.y = groupItemBounds.y + groupItemBounds.height; +// } + + return false; + } + } + + ReorderItem(moveItemTag.groupIndex, moveItemTag.itemIndex); + } + + return true; +} + +bool +_TableViewPresenter::CheckReorderItemPosition(_TableViewItem* pItem, TableViewItemTag& reorderItemTag) +{ + TableViewItemTag currentItemTag = {__reorderInfo.groupIndex, __reorderInfo.itemIndex}; + TableViewItemTag previousItemTag = {-1, -1}; + TableViewItemTag nextItemTag = {-1, -1}; + + Rectangle itemBounds = pItem->GetBounds(); + + if (GetPreviousItemPosition(currentItemTag, previousItemTag)) + { + _TableViewItem* pPreviousItem = FindItem(previousItemTag); + + if (pPreviousItem != null) + { + Rectangle previousItemBounds = pPreviousItem->GetBounds(); + + if (itemBounds.y < previousItemBounds.y + (previousItemBounds.height / 2)) + { + //return previousItemIndex; + reorderItemTag.groupIndex = previousItemTag.groupIndex; + reorderItemTag.itemIndex = previousItemTag.itemIndex; + + return true; + } + } + } + + if (GetNextItemPosition(currentItemTag, nextItemTag)) + { + _TableViewItem* pNextItem = FindItem(nextItemTag); + + if (pNextItem != null) + { + Rectangle nextItemBounds = pNextItem->GetBounds(); + + if (itemBounds.y + itemBounds.height > nextItemBounds.y + (nextItemBounds.height / 2)) + { + //return nextItemIndex; + reorderItemTag.groupIndex = nextItemTag.groupIndex; + reorderItemTag.itemIndex = nextItemTag.itemIndex; + + return true; + } + } + } + + reorderItemTag.groupIndex = -1; + reorderItemTag.itemIndex = -1; + + return false; +} + +bool +_TableViewPresenter::ReorderItem(int destinationGroupIndex, int destinationItemIndex) +{ + TableViewItemTag itemPos = {destinationGroupIndex, destinationItemIndex}; + + _TableViewItem* pItem = FindItem(itemPos); + + if (pItem == null) + { + return false; + } + + if (pItem->IsAnimationPlaying()) + { + return false; + } + + Rectangle destinationItemBounds = pItem->GetBounds(); + + Point destinationItemPosition = Point(destinationItemBounds.x, 0); + + if ( __reorderInfo.itemIndex > destinationItemIndex && __reorderInfo.groupIndex == destinationGroupIndex) + { + destinationItemPosition.y = __reorderInfo.itemBounds.y + __reorderInfo.itemBounds.height - destinationItemBounds.height; + __reorderInfo.itemBounds.y = destinationItemBounds.y; + + if (destinationItemIndex == -1) + { + destinationGroupIndex--; + int itemCount = GetItemCountAt(destinationGroupIndex); + destinationItemIndex = itemCount; + } + } + else + { + destinationItemPosition.y = __reorderInfo.itemBounds.y; + __reorderInfo.itemBounds.y = destinationItemBounds.y + destinationItemBounds.height - __reorderInfo.itemBounds.height; + + if (destinationItemIndex == -1) + { + destinationItemIndex = 0; + } + } + + _ListItemPos originPosition = {__reorderInfo.groupIndex, __reorderInfo.itemIndex}; + _ListItemPos destinationPosition = {destinationGroupIndex, destinationItemIndex}; + + __pListModel->MoveItem(originPosition, destinationPosition); + + if (!pItem->MoveItem(destinationItemPosition, REORDER_ITEM_MOVE_ANIMATION_DURATION, 0)) + { + pItem->SetPosition(destinationItemPosition); + } + + __reorderInfo.itemIndex = destinationItemIndex; + __reorderInfo.groupIndex = destinationGroupIndex; + + return true; +} + +void +_TableViewPresenter::StartReorderScrollTimer(void) +{ + StopReorderScrollTimer(); + + __pReorderScrollTimer = new (std::nothrow) Tizen::Base::Runtime::Timer; + SysTryReturnVoidResult(NID_UI_CTRL, __pReorderScrollTimer != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + result r = __pReorderScrollTimer->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pReorderScrollTimer->Start(REORDER_SCROLL_ANIMATION_TIMER_DURATION); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return; + +CATCH: + StopReorderScrollTimer(); +} + +void +_TableViewPresenter::StopReorderScrollTimer(void) +{ + delete __pReorderScrollTimer; + __pReorderScrollTimer = null; + +} + +void +_TableViewPresenter::UpdateLayout(void) +{ + // nothing +} + +bool +_TableViewPresenter::CheckItemHeightAndRefreshLayout(TableViewItemTag itemTag, bool downScroll) +{ + _TableViewItem* pItem = FindItem(itemTag); + + if (pItem == null) + { + return false; + } + + if (pItem->IsAnimationPlaying()) + { + return false; + } + + Rectangle itemBounds = pItem->GetBounds(); + + if (GetItemHeight(itemTag) == itemBounds.height) + { + return false; + } + + int newHeight = itemBounds.height; + int originHeight = SetItemHeight(itemTag, newHeight); + int dist = newHeight - originHeight; + + AdjustClientAreaBounds(false, dist); + + if (!downScroll) + { + itemBounds.y += dist; + pItem->SetBounds(itemBounds); + } + + AttachNextItemsToBottom(itemTag); + + return true; +} + +bool +_TableViewPresenter::CreateItemHeightList(void) +{ + int groupCount = GetGroupCount(); + int defaultItemHeight = __pProviderAdaptor->GetDefaultItemHeight(); + int defaultGroupItemHeight = __pProviderAdaptor->GetDefaultGroupItemHeight(); + + result r = __itemHeightList.SetCapacity(GetItemCount()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + for (int i = 0; i < groupCount; i++) + { + int itemCount = GetItemCountAt(i); + + if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE) + { + __itemHeightList.Add(0); + } + else + { + __itemHeightList.Add(defaultGroupItemHeight); + } + + for (int j = 1; j <= itemCount; j++) + { + __itemHeightList.Add(defaultItemHeight); + } + } + + return true; + +CATCH: + DeleteItemHeightList(); + + return false; +} + +bool +_TableViewPresenter::RefreshItemHeightList(int groupIndex, int itemIndex, TableViewRefreshType refreshType) +{ + int defaultItemHeight = __pProviderAdaptor->GetDefaultItemHeight(); + int defaultGroupItemHeight = __pProviderAdaptor->GetDefaultGroupItemHeight(); + + int startIndex = 0; + for (int i = 0; i < groupIndex; i++) + { + int itemCount = GetItemCountAt(i); + startIndex = startIndex + itemCount + 1; + } + + int targetIndex = startIndex + itemIndex + 1; + + if (refreshType == TABLE_VIEW_REFRESH_TYPE_ITEM_ADD) + { + if (itemIndex == -1) + { + result r = __itemHeightList.SetCapacity(GetItemCount()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + int itemCount = GetItemCountAt(groupIndex); + for (int i = 0; i < itemCount; i++) + { + __itemHeightList.InsertAt(defaultItemHeight, targetIndex); + } + + __itemHeightList.InsertAt(defaultGroupItemHeight, targetIndex); + + } + else + { + __itemHeightList.InsertAt(defaultItemHeight, targetIndex); + } + } + else if (refreshType == TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE) + { + if (itemIndex == -1) + { + int itemCount = GetItemCountAt(groupIndex) + 1; + + for (int i = 0; i < itemCount; i++) + { + __itemHeightList.RemoveAt(targetIndex); + } + } + else + { + __itemHeightList.RemoveAt(targetIndex); + } + } + + return true; +} + +void +_TableViewPresenter::CaptureAndStartRemoveItemAnimation(int groupIndex, int itemIndex) +{ + TableViewItemTag itemTag = {groupIndex, itemIndex}; + _TableViewItem* pItem = FindItem(itemTag); + + if (pItem == null) + { + return; + } + + Rectangle itemBounds = pItem->GetBounds(); + result r = E_SUCCESS; + + _VisualElement* pVisualElement = null; + VisualElementValueAnimation* pAnimation = null; + Canvas* pCanvas = null; + + Dimension startValue(100, itemBounds.height); + Dimension endValue(0, 0); + + Tizen::Graphics::Bitmap* pBitmap = pItem->GetCapturedBitmapN(true); + + if (pBitmap == null) + { + return; + } + + pCanvas = null; + pVisualElement = new (std::nothrow) _VisualElement(); + SysTryCatch(NID_UI_CTRL, pVisualElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = pVisualElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pVisualElement->SetImplicitAnimationEnabled(false); + pVisualElement->SetSurfaceOpaque(false); + pVisualElement->SetBounds(FloatRectangle(itemBounds.x, itemBounds.y, itemBounds.width, itemBounds.height)); + pVisualElement->SetShowState(true); + + GetView()->GetVisualElement()->AttachChild(*pVisualElement); + + pCanvas = pVisualElement->GetCanvasN(); + SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pCanvas->Clear(); + pCanvas->DrawBitmap(Rectangle(0, 0, itemBounds.width, itemBounds.height), *pBitmap); + + pAnimation = new (std::nothrow) VisualElementValueAnimation(); + SysTryCatch(NID_UI_CTRL, pAnimation != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + pAnimation->SetTimingFunction(VisualElementAnimation::GetTimingFunctionByName(L"EaseIn")); + pAnimation->SetDuration(REMOVE_ITEM_MOVE_ANIMATION_DURATION); + pAnimation->SetDelay(0); + pAnimation->SetStartValue(Variant(startValue)); + pAnimation->SetEndValue(Variant(endValue)); + pAnimation->SetVisualElementAnimationStatusEventListener(GetView()); + pAnimation->SetVisualElementAnimationTickEventListener(GetView()); + + r = pVisualElement->AddAnimation(L"RemoveTableViewItem", *pAnimation); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pAnimation; + delete pCanvas; + delete pBitmap; + + return; + +CATCH: + delete pCanvas; + delete pBitmap; + pVisualElement->Destroy(); +} + +void +_TableViewPresenter::DeleteItemHeightList(void) +{ + __itemHeightList.RemoveAll(); +} + +_TableViewItem* +_TableViewPresenter::GetTableViewItemFromControl(const _Control& source) +{ + _Control* currentControl = const_cast<_Control*>(&source); + _TableViewItem* pItem = null; + + while (__pTableView != currentControl) + { + pItem = dynamic_cast<_TableViewItem*>(currentControl); + + if ((pItem != null) || (currentControl == null)) + { + break; + } + + currentControl = currentControl->GetParent(); + } + + return pItem; +} + +void +_TableViewPresenter::SetLoadedItemsVisibleFromPosition(int position, bool visible) +{ + _TableViewItem* pItem; + Rectangle itemBounds; + TableViewItemTag current; + current.groupIndex = __expandableItemTag.groupIndex; + current.itemIndex = __expandableItemTag.itemIndex; + + int itemCountInGroup = __pListModel->GetItemCountInGroup(__expandableItemTag.groupIndex); + + for (int i = 0; i < itemCountInGroup; i++) + { + current.itemIndex = i; + + if (visible) + { + pItem = LoadItem(current.groupIndex, current.itemIndex); + } + else + { + pItem = FindItem(current); + } + + if (pItem == null) + { + break; + } + + itemBounds = pItem->GetBounds(); + + if (visible) + { + pItem->SetVisibleState(visible); + pItem->GetVisualElement()->SetZOrder(null, false); + + if (position < itemBounds.y + itemBounds.height) + { + break; + } + } + else + { + if (position < itemBounds.y) + { + UnloadItem(current); + } + } + } +} + +void +_TableViewPresenter::MoveLoadedItemsFromPosition(int position) +{ + Rectangle itemBounds; + int itemPosition = position; + + TableViewItemTag current; + TableViewItemTag next; + + current.groupIndex = __expandableItemTag.groupIndex; + current.itemIndex = __pListModel->GetItemCountInGroup(__expandableItemTag.groupIndex) -1; + + int screenPosition = GetScrollPosition(); + Rectangle screenBounds = __pTableView->GetBounds(); + screenPosition += screenBounds.height; + + _TableViewItem* pItem = null; + while (GetNextItemPosition(current, next)) + { + if (screenPosition > itemPosition) + { + pItem = LoadItem(next.groupIndex, next.itemIndex); + } + else + { + pItem = FindItem(next); + } + + if (pItem == null) + { + break; + } + + itemBounds = pItem->GetBounds(); + itemBounds.y = itemPosition; + pItem->SetBounds(itemBounds); + itemPosition += itemBounds.height; + + current = next; + } +} + +void +_TableViewPresenter::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target) +{ + if (keyName == L"RemoveTableViewItem") + { + return; + } + _ScrollPanelPresenter::OnVisualElementAnimationStarted(animation, keyName, target); +} + +void +_TableViewPresenter::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount) +{ + if (keyName == L"RemoveTableViewItem") + { + return; + } + _ScrollPanelPresenter::OnVisualElementAnimationRepeated(animation, keyName, target, currentRepeatCount); +} + +void +_TableViewPresenter::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally) +{ + if (keyName == L"RemoveTableViewItem") + { + _VisualElement* pVisualElement = GetView()->GetVisualElement(); + + pVisualElement->DetachChild(target); + + target.Destroy(); + return; + } + else if (keyName == L"EXPAND_GROUP_ANIMATION") + { + if (completedNormally == false) + { + TableViewItemTag current; + TableViewItemTag next; + + current.groupIndex = __expandableItemTag.groupIndex; + current.itemIndex = -1; + + _TableViewItem* pNextItem = null; + _TableViewItem* pCurrentItem = null; + pCurrentItem = LoadItem(current.groupIndex, current.itemIndex); + + Rectangle itemBounds; + Rectangle screenBounds = __pTableView->GetBounds(); + int screenPosition = GetScrollPosition() + screenBounds.height; + int nextItemPositionY = pCurrentItem->GetBounds().y + pCurrentItem->GetBounds().height; + + while (GetNextItemPosition(current, next)) + { + if (screenPosition >= nextItemPositionY) + { + pCurrentItem = LoadItem(current.groupIndex, current.itemIndex); + if (pCurrentItem == null) + { + break; + } + pNextItem = LoadItem(next.groupIndex, next.itemIndex); + if (pNextItem == null) + { + break; + } + + itemBounds = pNextItem->GetBounds(); + itemBounds.y = pCurrentItem->GetBounds().y + pCurrentItem->GetBounds().height; + pNextItem->SetBounds(itemBounds); + nextItemPositionY = itemBounds.y + itemBounds.height; + } + else + { + UnloadItem(next.groupIndex, next.itemIndex); + } + + current = next; + } + } + else + { + int currentGroupIndex = -1; + int currentItemIndex = -1; + GetBottomDrawnItemIndex(currentGroupIndex, currentItemIndex); + + int lastLoadedGroupIndex = -1; + int lastLoadedItemIndex = -1; + __pListModel->GetLastLoadedItemIndex(lastLoadedGroupIndex, lastLoadedItemIndex); + + for (int j = currentGroupIndex; j <= lastLoadedGroupIndex; j++) + { + int itemCount = GetItemCountAt(j); + + for (int i = -1; i < itemCount; i++) + { + if (i <= currentItemIndex && j == currentGroupIndex) + { + continue; + } + + UnloadItem(j, i); + } + } + } + return; + } + else if (keyName == L"COLLAPSE_GROUP_ANIMATION") + { + if (completedNormally == false) + { + TableViewItemTag current; + TableViewItemTag next; + + current.groupIndex = __expandableItemTag.groupIndex; + current.itemIndex = -1; + + _TableViewItem* pCurrentItem = null; + int itemCountInGroup = __pListModel->GetItemCountInGroup(__expandableItemTag.groupIndex); + + for (int i = 0; i < itemCountInGroup; i++) + { + UnloadItem(__expandableItemTag.groupIndex, i); + } + + pCurrentItem = FindItem(current); + if (pCurrentItem == null) + { + SysTryReturnVoidResult(NID_UI_CTRL, pCurrentItem != null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.") + } + + Rectangle itemBounds; + int nextItemPositionY = pCurrentItem->GetBounds().y + pCurrentItem->GetBounds().height; + + Rectangle screenBounds = __pTableView->GetBounds(); + int screenPosition = GetScrollPosition() + screenBounds.height; + + while (GetNextItemPosition(current, next)) + { + current = next; + if (screenPosition >= nextItemPositionY) + { + pCurrentItem = LoadItem(current.groupIndex, current.itemIndex); + if (pCurrentItem == null) + { + break; + } + + itemBounds = pCurrentItem->GetBounds(); + itemBounds.y = nextItemPositionY; + pCurrentItem->SetBounds(itemBounds); + + nextItemPositionY = pCurrentItem->GetBounds().y + pCurrentItem->GetBounds().height; + } + else + { + UnloadItem(current.groupIndex, current.itemIndex); + } + } + } + else + { + int scrollPosition = GetScrollPosition(); + + int groupItemsHeight = 0; + _IListItemCommon* pItem = null; + for (int i = 0; i < __expandableItemTag.itemIndex; i++) + { + pItem = __pListModel->GetItemFromTemporaryBuffer(__expandableItemTag.groupIndex, i); + groupItemsHeight += pItem->GetItemHeight(); + } + + _TableViewItem* pTableViewItem = static_cast<_TableViewItem*>(__pListModel->GetItemFromTemporaryBuffer(__expandableItemTag.groupIndex, __expandableItemTag.itemIndex)); + Rectangle itemBounds = pTableViewItem->GetBounds(); + groupItemsHeight += (scrollPosition - itemBounds.y); + + int currentGroupIndex = -1; + int currentItemIndex = -1; + GetTopDrawnItemIndex(currentGroupIndex, currentItemIndex); + + int firstLoadedGroupIndex = -1; + int firstLoadedItemIndex = -1; + __pListModel->GetFirstLoadedItemIndex(firstLoadedGroupIndex, firstLoadedItemIndex); + + for (int j = firstLoadedGroupIndex; j <= currentGroupIndex; j++) + { + int itemCount = GetItemCountAt(j); + + for (int i = -1; i < itemCount; i++) + { + if (i >= currentItemIndex && j == currentGroupIndex) + { + break; + } + + UnloadItem(j, i); + } + } + + int itemCount = GetItemCountAt(__expandableItemTag.groupIndex); + for (int i = 0; i < itemCount; i++) + { + UnloadItem(__expandableItemTag.groupIndex, i); + } + } + + return; + } + + _ScrollPanelPresenter::OnVisualElementAnimationFinished(animation, keyName, target, completedNormally); +} + +void +_TableViewPresenter::OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue) +{ + _VisualElement* pVisualElement = __pTableView->GetVisualElement(); + + if (&target != pVisualElement) + { + return; + } + + if (keyName == L"RemoveTableViewItem") + { + Dimension value = currentValue.ToDimension(); + target.SetOpacity(value.width); + + FloatRectangle bounds = target.GetBounds(); + bounds.height = value.height; + target.SetBounds(bounds); + + target.SetFlushNeeded(); + + return; + } + else if (keyName == L"EXPAND_GROUP_ANIMATION") + { + int currentPosition = currentValue.ToInt(); + SetLoadedItemsVisibleFromPosition(currentPosition, true); + MoveLoadedItemsFromPosition(currentPosition); + + return; + } + else if (keyName == L"COLLAPSE_GROUP_ANIMATION") + { + int currentPosition = currentValue.ToInt(); + SetLoadedItemsVisibleFromPosition(currentPosition, false); + MoveLoadedItemsFromPosition(currentPosition); + + return; + } + else if (keyName == L"SWEEP_ITEM_ANIMATION") + { + int currentPosition = currentValue.ToInt(); + int moveDestance = currentPosition - __sweptItemPosition.x; + SweepItem(moveDestance); + + return; + } + + _ScrollPanelPresenter::OnTickOccurred(animation, keyName, target, currentValue); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TextBlockEvent.cpp b/src/ui/controls/FUiCtrl_TextBlockEvent.cpp new file mode 100644 index 0000000..e5d3043 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TextBlockEvent.cpp @@ -0,0 +1,185 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_TextBlockEvent.cpp +* @brief This is the implementation for the _TextBlockEvent class. +* @version 1.0 +*/ + +// includes +#include +#include +#include +#include "FUiCtrl_TextBlockEvent.h" +#include "FUiCtrl_ITextBlockEventListener.h" + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _TextBlockEventArg + * @brief This class is used as the argument to change event listener. + * + * This class is used as the argument to change event listener. When an change event is generated + * (such as when a button is pressed) the TextBlockEvent calls TextBlockEventListener's OnTextd + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the change ID. + */ +class _OSP_EXPORT_ _TextBlockEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _TextBlockEventArg(int start, int end); + + /** + * This is the class destructor. + * + */ + virtual ~_TextBlockEventArg(void); + + +// Access +public: + const int GetStartPosition(void) const; + + const int GetEndPosition(void) const; + +// Attribute +private: + /** + * Start position. + */ + int __start; + + /** + * End position. + */ + int __end; +}; // _TextBlockEventArg + +//////////////////////////////////////////////////////////////////////////////// +/// _TextBlockEventArg class Lifecycle + +_TextBlockEventArg::_TextBlockEventArg(int start, int end) + : __start(start) + , __end(end) +{ + // Nothing +} + +_TextBlockEventArg::~_TextBlockEventArg(void) +{ + // Nothing. +} + +const int +_TextBlockEventArg::GetStartPosition(void) const +{ + return __start; +} + +const int +_TextBlockEventArg::GetEndPosition(void) const +{ + return __end; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _TextBlockEvent class Lifecycle +_TextBlockEvent::_TextBlockEvent(const _Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // Set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_TextBlockEvent::~_TextBlockEvent(void) +{ + // Nothing. +} + +_TextBlockEvent* +_TextBlockEvent::CreateInstanceN(const _Control& source) +{ + _TextBlockEvent* pCoreTextBlockEvent = new (std::nothrow) _TextBlockEvent(source); + SysTryReturn(NID_UI_CTRL, pCoreTextBlockEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pCoreTextBlockEvent; + +CATCH: + delete pCoreTextBlockEvent; + return null; +} + +// Accessors + +const _Control* +_TextBlockEvent::GetSource(void) const +{ + return __pSource; +} + +// Operations + +void +_TextBlockEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _ITextBlockEventListener* pTextBlockEventListener = dynamic_cast <_ITextBlockEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventListener != null, E_INVALID_ARG, "The Invalid listener is given.\n"); + + const _TextBlockEventArg* pTextBlockEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventArg != null, E_INVALID_ARG, "The Invalid Event Argument is given.\n"); + + pTextBlockEventListener->OnTextBlockSelected(const_cast <_Control&>(*__pSource), + pTextBlockEventArg->GetStartPosition(), pTextBlockEventArg->GetEndPosition()); + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_TextBlockEvent::CreateTextBlockEventArgN(int start, int end) +{ + _TextBlockEventArg* pEventArg = new (std::nothrow) _TextBlockEventArg(start, end); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TextBoxImpl.cpp b/src/ui/controls/FUiCtrl_TextBoxImpl.cpp new file mode 100644 index 0000000..7c7f50a --- /dev/null +++ b/src/ui/controls/FUiCtrl_TextBoxImpl.cpp @@ -0,0 +1,794 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_TextBoxImpl.cpp +* @brief This is the implementation file for _TextBoxImpl class. +*/ + +#include +#include +#include "FUi_UiBuilder.h" +#include "FUiCtrl_TextBoxImpl.h" +#include "FUiCtrl_PublicTextBlockEvent.h" +#include "FUiCtrl_PublicLinkEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +const int TEXTBOX_LENGTH_MAX = 2048; + +_TextBoxImpl::_TextBoxImpl(TextBox* pPublic, _Edit* pCore) + : _ControlImpl(pPublic, pCore) + , __pEdit(pCore) + , __pPublicTextBlockEvent(null) + , __pPublicLinkEvent(null) + , __autoLinkMask(LINK_TYPE_NONE) +{ +} + +_TextBoxImpl::~_TextBoxImpl(void) +{ + if (__pPublicTextBlockEvent) + { + delete __pPublicTextBlockEvent; + __pPublicTextBlockEvent = null; + } + + if (__pPublicLinkEvent) + { + delete __pPublicLinkEvent; + __pPublicLinkEvent = null; + } +} + +_TextBoxImpl* +_TextBoxImpl::CreateTextBoxImplN(TextBox* pPublic) +{ + ClearLastResult(); + result r = E_SUCCESS; + + _Edit* pCore = _Edit::CreateEditN(); + SysTryReturn(NID_UI_CTRL, pCore, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(r)); + + _TextBoxImpl* pImpl = new (std::nothrow) _TextBoxImpl(pPublic, pCore); + + r = _ControlImpl::CheckConstruction(pCore, pImpl); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl; + +CATCH: + delete pCore; + delete pImpl; + return null; +} + +const char* +_TextBoxImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::TextBox"; +} + +const TextBox& +_TextBoxImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +TextBox& +_TextBoxImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _Edit& +_TextBoxImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_Edit& +_TextBoxImpl::GetCore(void) +{ + return static_cast <_Edit&>(_ControlImpl::GetCore()); +} + +result +_TextBoxImpl::Initialize(TextBoxBorder border) +{ + result r = E_SUCCESS; + + r = __pEdit->Initialize(EDIT_STYLE_VIEWER, INPUT_STYLE_OVERLAY, TEXTBOX_LENGTH_MAX); + + if (border == TEXT_BOX_BORDER_ROUNDED) + { + __pEdit->SetBorderRoundStyleEnabled(true); + } + else + { + __pEdit->SetBorderRoundStyleEnabled(false); + } + + if (r != E_SUCCESS) + { + goto CATCH; + } + + __pEdit->SetAutoLinkMask(LINK_TYPE_URL | LINK_TYPE_EMAIL | LINK_TYPE_TEL_NUM); + + return r; + +CATCH: + Dispose(); + return r; +} + +result +_TextBoxImpl::Dispose(void) +{ + result r = E_SUCCESS; + + if (__pEdit) + { + delete __pEdit; + __pEdit = null; + } + + return r; +} + +result +_TextBoxImpl::SetAutoLinkMask(unsigned long autoLinks) +{ + __autoLinkMask = autoLinks; + + return __pEdit->SetAutoLinkMask(autoLinks); +} + +unsigned long +_TextBoxImpl::GetAutoLinkMask(void) const +{ + return __autoLinkMask; +} + +result +_TextBoxImpl::AddUiLinkEventListener(IUiLinkEventListener& listener) +{ + if (__pPublicLinkEvent == null) + { + __pPublicLinkEvent = _PublicLinkEvent::CreateInstanceN(GetPublic()); + + if (IsFailed(GetLastResult())) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] System error occurred."); + delete __pPublicLinkEvent; + return E_SYSTEM; + } + } + + __pPublicLinkEvent->AddListener(listener); + __pEdit->AddUiLinkEventListener(*this); + + return E_SUCCESS; +} + +result +_TextBoxImpl::RemoveUiLinkEventListener(IUiLinkEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pPublicLinkEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] This instance isn't constructed.") + + __pPublicLinkEvent->RemoveListener(listener); + __pEdit->RemoveUiLinkEventListener(*this); + + return E_SUCCESS; +} + +result +_TextBoxImpl::AppendCharacter(const Character& character) +{ + return __pEdit->AppendCharacter(character); +} + +result +_TextBoxImpl::AppendText(const String& text) +{ + return __pEdit->AppendText(text); +} + +result +_TextBoxImpl::Clear(void) +{ + return __pEdit->ClearText(); +} + +int +_TextBoxImpl::GetLineCount(void) const +{ + return __pEdit->GetTextLineCount(); +} + +String +_TextBoxImpl::GetText(void) const +{ + return __pEdit->GetText(); +} + +String +_TextBoxImpl::GetText(int start, int end) const +{ + return __pEdit->GetText(start, end); +} + +int +_TextBoxImpl::GetTextLength(void) const +{ + return __pEdit->GetTextLength(); +} + +result +_TextBoxImpl::InsertCharacterAt(int index, const Character& character) +{ + result r = __pEdit->InsertCharacterAt(index, character); + + if (r == E_INVALID_ARG) + { + r = E_OUT_OF_RANGE; + } + + return r; +} + +result +_TextBoxImpl::InsertTextAt(int index, const String& text) +{ + result r = __pEdit->InsertTextAt(index, text); + + if (r == E_INVALID_ARG) + { + r = E_OUT_OF_RANGE; + } + + return r; +} + +result +_TextBoxImpl::SetText(const String& text) +{ + return __pEdit->SetText(text); +} + +int +_TextBoxImpl::GetLineSpacing(void) const +{ + return __pEdit->GetLineSpacing(); +} + +result +_TextBoxImpl::SetLineSpacing(int multiplier, int extra) +{ + SysTryReturn(NID_UI_CTRL, multiplier >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + SysTryReturn(NID_UI_CTRL, extra >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given."); + + return __pEdit->SetLineSpacing(DEFAULT_LINE_SPACE * multiplier + extra); +} + +HorizontalAlignment +_TextBoxImpl::GetTextAlignment(void) const +{ + return __pEdit->GetTextAlignment(); +} + +result +_TextBoxImpl::SetTextAlignment(HorizontalAlignment alignment) +{ + return __pEdit->SetTextAlignment(alignment); +} + +int +_TextBoxImpl::GetTextSize(void) const +{ + return __pEdit->GetTextSize(); +} + +result +_TextBoxImpl::SetTextSize(int size) +{ + return __pEdit->SetTextSize(size); +} + +int +_TextBoxImpl::GetTextTotalHeight(void) const +{ + return __pEdit->GetTextTotalHeight(); +} + +result +_TextBoxImpl::GetFontType(String& typefaceName, unsigned long& styleMask) const +{ + __pEdit->GetFontType(typefaceName, styleMask); + + return E_SUCCESS; +} + +unsigned long +_TextBoxImpl::GetTextStyle(void) const +{ + return __pEdit->GetTextStyle(); +} + +result +_TextBoxImpl::SetFontType(const String& typefaceName, unsigned long styleMask) +{ + return __pEdit->SetFontType(typefaceName, styleMask); +} + +result +_TextBoxImpl::SetTextStyle(unsigned long style) +{ + return __pEdit->SetTextStyle(style); +} + +result +_TextBoxImpl::SetFont(const Font& font) +{ + return __pEdit->SetFont(font); +} + +result +_TextBoxImpl::ReleaseBlock(void) +{ + return __pEdit->ReleaseTextBlock(); +} + +result +_TextBoxImpl::GetBlockRange(int& start, int& end) const +{ + __pEdit->GetBlockRange(start, end); + + return E_SUCCESS; +} + +result +_TextBoxImpl::SetBlockRange(int start, int end) +{ + SysTryReturnResult(NID_UI_CTRL, (start > -1 && end > -1), E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given.\n"); + SysTryReturnResult(NID_UI_CTRL, (end > start), E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given.\n"); + + int tempTextLength = 0; + tempTextLength = __pEdit->GetTextLength(); + SysTryReturnResult(NID_UI_CTRL, (tempTextLength > start && tempTextLength > end), E_INVALID_ARG, + "[E_INVALID_ARG] The invalid argument is given.\n"); + + return __pEdit->SetBlockRange(start, end); +} + +result +_TextBoxImpl::AddTextBlockEventListener(ITextBlockEventListener& listener) +{ + if (__pPublicTextBlockEvent == null) + { + __pPublicTextBlockEvent = _PublicTextBlockEvent::CreateInstanceN(GetPublic()); + + if (IsFailed(GetLastResult())) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] System error occurred."); + delete __pPublicTextBlockEvent; + return E_SYSTEM; + } + } + + __pPublicTextBlockEvent->AddListener(listener); + __pEdit->AddTextBlockEventListener(*this); + + return E_SUCCESS; +} + +result +_TextBoxImpl::RemoveTextBlockEventListener(ITextBlockEventListener& listener) +{ + SysTryReturn(NID_UI_CTRL, __pPublicTextBlockEvent, E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] This instance isn't constructed.") + + __pPublicTextBlockEvent->RemoveListener(listener); + __pEdit->RemoveTextBlockEventListener(*this); + + return E_SUCCESS; +} + +Color +_TextBoxImpl::GetColor(TextBoxStatus status) const +{ + return __pEdit->GetColor(ConvertStatus(status)); +} + +Color +_TextBoxImpl::GetTextColor(TextBoxTextColor type) const +{ + if (type == TEXT_BOX_TEXT_COLOR_BLOCKED) + { + return __pEdit->GetBlockTextColor(); + } + else + { + return __pEdit->GetTextColor(ConvertTextColorType(type)); + } +} + +result +_TextBoxImpl::SetColor(TextBoxStatus status, const Color& color) +{ + if (status == TEXT_BOX_STATUS_HIGHLIGHTED) + { + __pEdit->SetColor(EDIT_STATUS_PRESSED, color); + } + + return __pEdit->SetColor(ConvertStatus(status), color); +} + +result +_TextBoxImpl::SetTextColor(TextBoxTextColor type, const Color& color) +{ + if (type == TEXT_BOX_TEXT_COLOR_BLOCKED) + { + return __pEdit->SetBlockTextColor(color); + } + else + { + return __pEdit->SetTextColor(ConvertTextColorType(type), color); + } +} + +result +_TextBoxImpl::SetBackgroundBitmap(TextBoxStatus status, const Bitmap& bitmap) +{ + if (status == TEXT_BOX_STATUS_HIGHLIGHTED) + { + __pEdit->SetBackgroundBitmap(EDIT_STATUS_PRESSED, bitmap); + } + + return __pEdit->SetBackgroundBitmap(ConvertStatus(status), bitmap); +} + +EditTextColor +_TextBoxImpl::ConvertTextColorType(TextBoxTextColor type) const +{ + EditTextColor editTextColorType = EDIT_TEXT_COLOR_NORMAL; + + switch (type) + { + case TEXT_BOX_TEXT_COLOR_NORMAL: + editTextColorType = EDIT_TEXT_COLOR_NORMAL; + break; + + case TEXT_BOX_TEXT_COLOR_HIGHLIGHTED: + editTextColorType = EDIT_TEXT_COLOR_HIGHLIGHTED; + break; + + case TEXT_BOX_TEXT_COLOR_DISABLED: + editTextColorType = EDIT_TEXT_COLOR_DISABLED; + break; + + case TEXT_BOX_TEXT_COLOR_LINK: + editTextColorType = EDIT_TEXT_COLOR_LINK; + break; + + case TEXT_BOX_TEXT_COLOR_BLOCKED: + default: + editTextColorType = EDIT_TEXT_COLOR_NORMAL; + break; + } + + return editTextColorType; +} + +EditStatus +_TextBoxImpl::ConvertStatus(TextBoxStatus status) const +{ + EditStatus editStatus = EDIT_STATUS_NORMAL; + + switch (status) + { + case TEXT_BOX_STATUS_NORMAL: + editStatus = EDIT_STATUS_NORMAL; + break; + + case TEXT_BOX_STATUS_HIGHLIGHTED: + editStatus = EDIT_STATUS_HIGHLIGHTED; + break; + + case TEXT_BOX_STATUS_DISABLED: + editStatus = EDIT_STATUS_DISABLED; + break; + + default: + editStatus = EDIT_STATUS_NORMAL; + break; + } + + return editStatus; +} + +result +_TextBoxImpl::OnBoundsChanged(const Rectangle& oldRect, const Rectangle& newRect) +{ + return E_SUCCESS; +} + +void +_TextBoxImpl::OnLinkClicked(_Control& source, const String& text, LinkType linkType, + const String& link) +{ + if (__pPublicLinkEvent != null) + { + IEventArg* pLinkEventArg = _PublicLinkEvent::CreateLinkEventArgN(text, linkType, link); + SysTryReturnVoidResult(NID_UI_CTRL, pLinkEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _LinkEventArg."); + + __pPublicLinkEvent->Fire(*pLinkEventArg); + } +} + +void +_TextBoxImpl::OnTextBlockSelected(_Control& source, int start, int end) +{ + if (__pPublicTextBlockEvent != null) + { + IEventArg* pTextBlockEventArg = _PublicTextBlockEvent::CreateTextBlockEventArgN(start, end); + SysTryReturnVoidResult(NID_UI_CTRL, pTextBlockEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create _TextBlockEventArg."); + + __pPublicTextBlockEvent->Fire(*pTextBlockEventArg); + } +} + +Dimension +_TextBoxImpl::GetContentSize(void) const +{ + return __pEdit->GetContentSizeInternal(); +} + + +_TextBoxImpl* +_TextBoxImpl::GetInstance(TextBox& textBox) +{ + return static_cast<_TextBoxImpl*> (textBox._pControlImpl); +} + +const _TextBoxImpl* +_TextBoxImpl::GetInstance(const TextBox& textBox) +{ + return static_cast (textBox._pControlImpl); +} + +class _TextBoxMaker + : public _UiBuilderControlMaker +{ +public: + _TextBoxMaker(_UiBuilder* uibuilder) + : _UiBuilderControlMaker(uibuilder){}; + virtual ~_TextBoxMaker(){}; + static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder) + { + _TextBoxMaker* pTextBoxMaker = new (std::nothrow) _TextBoxMaker(uibuilder); + return pTextBoxMaker; + }; + +protected: + virtual Control* Make(_UiBuilderControl* pControl) + { + result r = E_SUCCESS; + + Rectangle rect; + + TextBox* pTextBox = null; + _UiBuilderControlLayout* pControlProperty = null; + HorizontalAlignment textAlignment = ALIGNMENT_LEFT; + TextBoxBorder textboxBorder = TEXT_BOX_BORDER_ROUNDED; + String text; + Color color; + int opacity = 100; + int textSize = 0; + int lineSpacingExtra = 0; + int lineSpacingMultiplier = 1; + String elementString; + + GetProperty(pControl, &pControlProperty); + if (pControlProperty == null) + { + return null; + } + + pTextBox = new (std::nothrow) TextBox(); + if (pTextBox == null) + { + return null; + } + + rect = pControlProperty->GetRect(); + if (pControl->GetElement("textboxBorder", elementString)) + { + if (elementString.Equals(L"TEXT_BOX_BORDER_NONE", false)) + { + textboxBorder = TEXT_BOX_BORDER_NONE; + } + else if (elementString.Equals(L"TEXT_BOX_BORDER_ROUNDED", false)) + { + textboxBorder = TEXT_BOX_BORDER_ROUNDED; + } + else if (elementString.Equals(L"TEXT_BOX_BORDER_LINE", false)) + { + textboxBorder = TEXT_BOX_BORDER_ROUNDED; + } + } + + r = pTextBox->Construct(rect, textboxBorder); + if (r != E_SUCCESS) + { + return null; + } + + if (pControl->GetElement("textAlignment", elementString)) + { + if (elementString.Equals(L"ALIGNMENT_LEFT", false)) + { + textAlignment = ALIGNMENT_LEFT; + } + else if (elementString.Equals(L"ALIGNMENT_RIGHT", false)) + { + textAlignment = ALIGNMENT_RIGHT; + } + else if (elementString.Equals(L"ALIGNMENT_CENTER", false)) + { + textAlignment = ALIGNMENT_CENTER; + } + + r = pTextBox->SetTextAlignment(textAlignment); + } + + if (pControl->GetElement("textSize", elementString)) + { + Base::Integer::Parse(elementString, textSize); + _ICoordinateSystemTransformer* pTransform = GetTransformer(); + if (pTransform) + { + textSize = pTransform->Transform(textSize); + } + r = pTextBox->SetTextSize(textSize); + } + + if (pControl->GetElement("lineSpacingExtra", elementString)) + { + Base::Integer::Parse(elementString, lineSpacingExtra); + + if (pControl->GetElement("lineSpacingMultiplier", elementString)) + { + Base::Integer::Parse(elementString, lineSpacingMultiplier); + r = pTextBox->SetLineSpacing(lineSpacingMultiplier, lineSpacingExtra); + } + } + + if (pControl->GetElement("text", elementString)) + { + r = pTextBox->SetText(elementString); + } + + if (pControl->GetElement("disabledBackgroundBitmapPath", elementString)) + { + Bitmap* pBackGroundBitmap = null; + pBackGroundBitmap = LoadBitmapN(elementString); + if (pBackGroundBitmap != null) + { + pTextBox->SetBackgroundBitmap(TEXT_BOX_STATUS_DISABLED, *pBackGroundBitmap); + delete pBackGroundBitmap; + } + } + + if (pControl->GetElement("highlightedBackgroundBitmapPath", elementString)) + { + Bitmap* pBackGroundBitmap = null; + pBackGroundBitmap = LoadBitmapN(elementString); + if (pBackGroundBitmap != null) + { + pTextBox->SetBackgroundBitmap(TEXT_BOX_STATUS_HIGHLIGHTED, *pBackGroundBitmap); + delete pBackGroundBitmap; + } + } + + if (pControl->GetElement("normalBackgroundBitmapPath", elementString)) + { + Bitmap* pBackGroundBitmap = null; + pBackGroundBitmap = LoadBitmapN(elementString); + if (pBackGroundBitmap != null) + { + pTextBox->SetBackgroundBitmap(TEXT_BOX_STATUS_NORMAL, *pBackGroundBitmap); + delete pBackGroundBitmap; + } + } + + if (pControl->GetElement("disabledTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pTextBox->SetTextColor(TEXT_BOX_TEXT_COLOR_DISABLED, color); + } + + if (pControl->GetElement("highlightedTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pTextBox->SetTextColor(TEXT_BOX_TEXT_COLOR_HIGHLIGHTED, color); + } + + if (pControl->GetElement("normalTextColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pTextBox->SetTextColor(TEXT_BOX_TEXT_COLOR_NORMAL, color); + } + + if (pControl->GetElement("disabledColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement("disabledColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pTextBox->SetColor(TEXT_BOX_STATUS_DISABLED, color); + } + + if (pControl->GetElement("highlightedColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement("highlightedColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pTextBox->SetColor(TEXT_BOX_STATUS_HIGHLIGHTED, color); + } + + if (pControl->GetElement("normalColorOpacity", elementString)) + { + Base::Integer::Parse(elementString, opacity); + } + if (pControl->GetElement("normalColor", elementString)) + { + ConvertStringToColor32(elementString, opacity, color); + pTextBox->SetColor(TEXT_BOX_STATUS_NORMAL, color); + } + + return pTextBox; + } +}; + +_TextBoxRegister::_TextBoxRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->RegisterControl(L"TextBox", _TextBoxMaker::GetInstance); +} +_TextBoxRegister::~_TextBoxRegister() +{ + _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance(); + pUiBuilderControlTableManager->UnregisterControl(L"TextBox"); +} +static _TextBoxRegister TextBoxRegisterToUiBuilder; +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TextEvent.cpp b/src/ui/controls/FUiCtrl_TextEvent.cpp new file mode 100644 index 0000000..b305a49 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TextEvent.cpp @@ -0,0 +1,194 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_TextEvent.cpp +* @brief This is the implementation for the TextEvent class. +* @version 1.0 +*/ + +// includes +#include +#include +#include +#include "FUiCtrl_ITextEventListener.h" +#include "FUiCtrl_TextEvent.h" + + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _TextEventArg + * @brief This class is used as the argument to action event listener. + * + * This class is used as the argument to action event listener. When an action event is generated + * (such as when a button is pressed) the TextEvent calls TextEventListener's OnActionPerformed + * with an instance of this class as an argument. + * + * From this class, one can find out, the (event) source object and the action ID. + */ +class _OSP_EXPORT_ _TextEventArg + : public IEventArg + , public Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Object instance which contains this instance. + * @param[in] actionId Action Id. + */ + _TextEventArg(CoreTextEventStatus status); + + /** + * This is the class destructor. + * + */ + virtual ~_TextEventArg(void); + + +// Access +public: + /** + * This method returns the TextEventStatus which the event initially occurred. + * + * @return See the comment above. + */ + CoreTextEventStatus GetStatus(void) const; + + +// Attribute +private: + /** + * Action Id. + */ + CoreTextEventStatus __status; +}; // _TextEventArg + +_TextEventArg::_TextEventArg(CoreTextEventStatus status) + : __status(status) +{ + // nothing +} + +_TextEventArg::~_TextEventArg(void) +{ + // nothing +} + +//////////////////////////////////////////////////////////////////////////////// +/// _TextEventArg class Access + +CoreTextEventStatus +_TextEventArg::GetStatus(void) const +{ + return __status; +} + + +//////////////////////////////////////////////////////////////////////////////// +/// _TextEvent class Lifecycle + +_TextEvent::_TextEvent(const _Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = &source; + } +} + +_TextEvent::~_TextEvent(void) +{ + // nothing +} + +_TextEvent* +_TextEvent::CreateInstanceN(const _Control& source) +{ + _TextEvent* pCoreTextEvent = new (std::nothrow) _TextEvent(source); + SysTryReturn(NID_UI_CTRL, pCoreTextEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + if (IsFailed(GetLastResult())) + { + goto CATCH; + } + + return pCoreTextEvent; + +CATCH: + delete pCoreTextEvent; + return null; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _WindowEvent class Accessor + +const _Control* +_TextEvent::GetSource(void) const +{ + return __pSource; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _TextEvent class Operation + +void +_TextEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to _ITextEventListener + _ITextEventListener* pTextListener = dynamic_cast <_ITextEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pTextListener != null, E_INVALID_ARG, + "[E_INVALID_ARG] The invalid listener was given.\n"); + + // cast to _TextEventArg + const _TextEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + CoreTextEventStatus stauts = pArg->GetStatus(); + if (stauts == CORE_TEXT_EVENT_CHANGED) + { + pTextListener->OnTextValueChanged(*__pSource); + } + else if (stauts == CORE_TEXT_EVENT_CANCELED) + { + pTextListener->OnTextValueChangeCanceled(*__pSource); + } + + SetLastResult(E_SUCCESS); + + return; +} + +IEventArg* +_TextEvent::CreateTextEventArgN(CoreTextEventStatus status) +{ + _TextEventArg* pEventArg = new (std::nothrow) _TextEventArg(status); + SysTryReturn(NID_UI_CTRL, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TimePickerImpl.cpp b/src/ui/controls/FUiCtrl_TimePickerImpl.cpp new file mode 100644 index 0000000..638d91d --- /dev/null +++ b/src/ui/controls/FUiCtrl_TimePickerImpl.cpp @@ -0,0 +1,370 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TimePickerImpl.cpp + * @brief This is the implementation file for the _TimePickerImpl class. + */ + +#include +#include "FUiCtrl_DateTimePicker.h" +#include "FUiCtrl_TimePickerImpl.h" +#include "FUiCtrl_FrameImpl.h" +#include "FUi_ControlImplManager.h" +#include "FUi_ResourceSizeInfo.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_Form.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ + +Dimension +_TimePickerImpl::TimePickerSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const +{ + Dimension pickerSize(0, 0); + Dimension screenSize(0, 0); + + screenSize = _ControlManager::GetInstance()->GetScreenSize(); + pickerSize = screenSize; + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + pickerSize.width = screenSize.height; + pickerSize.height = screenSize.width; + } + + return pickerSize; +} + +Dimension +_TimePickerImpl::TimePickerSizeInfo::GetDefaultMaximumSize(_ControlOrientation orientation) const +{ + Dimension pickerSize(0, 0); + Dimension screenSize(0, 0); + + screenSize = _ControlManager::GetInstance()->GetScreenSize(); + pickerSize = screenSize; + if (orientation == _CONTROL_ORIENTATION_LANDSCAPE) + { + pickerSize.width = screenSize.height; + pickerSize.height = screenSize.width; + } + + return pickerSize; +} + +_TimePickerImpl::_TimePickerImpl(TimePicker* pPublic, _DateTimePicker* pCore) + : _WindowImpl(pPublic, pCore) + , __pPublicDateTimeChangeEvent(null) +{ +} + +_TimePickerImpl::~_TimePickerImpl(void) +{ + if (__pPublicDateTimeChangeEvent != null) + { + delete __pPublicDateTimeChangeEvent; + __pPublicDateTimeChangeEvent = null; + } +} + +_TimePickerImpl* +_TimePickerImpl::CreateTimePickerImplN(TimePicker* pControl, const String& title) +{ + ClearLastResult(); + + result r = E_SUCCESS; + + _DateTimePicker* pCore = _DateTimePicker::CreateDateTimePickerN(DATETIME_OUTPUT_STYLE_TIME, title); + SysTryReturn(NID_UI_CTRL, (pCore != null), null, r, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + _TimePickerImpl* pPickerImpl = new (std::nothrow) _TimePickerImpl(pControl, pCore); + r = CheckConstruction(pCore, pPickerImpl); + SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pPickerImpl->__pPublicDateTimeChangeEvent = new (std::nothrow) _PublicDateTimeChangeEvent(*pControl); + SysTryCatch(NID_UI_CTRL, (pPickerImpl->__pPublicDateTimeChangeEvent != null), , E_OUT_OF_MEMORY, + "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pPickerImpl->InitializeBoundsProperties(GET_SIZE_INFO(TimePicker), pCore->GetOrientation()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pCore->AddDateTimeChangeEventListener(*pPickerImpl); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return pPickerImpl; + +CATCH: + delete pPickerImpl; + + return null; +} + +const char* +_TimePickerImpl::GetPublicClassName(void) const +{ + return "Tizen::Ui::Controls::TimePicker"; +} + +const TimePicker& +_TimePickerImpl::GetPublic(void) const +{ + return static_cast (_ControlImpl::GetPublic()); +} + +TimePicker& +_TimePickerImpl::GetPublic(void) +{ + return static_cast (_ControlImpl::GetPublic()); +} + +const _DateTimePicker& +_TimePickerImpl::GetCore(void) const +{ + return static_cast (_ControlImpl::GetCore()); +} + +_DateTimePicker& +_TimePickerImpl::GetCore(void) +{ + return static_cast <_DateTimePicker&>(_ControlImpl::GetCore()); +} + +_TimePickerImpl* +_TimePickerImpl::GetInstance(TimePicker& timePicker) +{ + return static_cast<_TimePickerImpl*> (_ControlImpl::GetInstance(timePicker)); +} + +const _TimePickerImpl* +_TimePickerImpl::GetInstance(const TimePicker& timePicker) +{ + return static_cast (_ControlImpl::GetInstance(timePicker)); +} + +result +_TimePickerImpl::AddTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, (__pPublicDateTimeChangeEvent != null), E_SYSTEM, + "A system error has occurred. The _PublicDateTimeChangeEvent instance is null."); + + result r = __pPublicDateTimeChangeEvent->AddListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +result +_TimePickerImpl::RemoveTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener) +{ + ClearLastResult(); + + SysTryReturnResult(NID_UI_CTRL, (__pPublicDateTimeChangeEvent != null), E_SYSTEM, + "A system error has occurred. The _PublicDateTimeChangeEvent instance is null."); + + result r = __pPublicDateTimeChangeEvent->RemoveListener(listener); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +int +_TimePickerImpl::GetHour(void) const +{ + ClearLastResult(); + + Variant hourValue = GetCore().GetPropertyHour(); + + return hourValue.ToInt(); +} + +int +_TimePickerImpl::GetMinute(void) const +{ + ClearLastResult(); + + Variant minuteValue = GetCore().GetPropertyMinute(); + + return minuteValue.ToInt(); +} + +DateTime +_TimePickerImpl::GetTime(void) const +{ + ClearLastResult(); + + Variant dateTimeValue = GetCore().GetPropertyDateTime(); + + return dateTimeValue.ToDateTime(); +} + +void +_TimePickerImpl::Set24HourNotationEnabled(bool enable) +{ + ClearLastResult(); + + Variant envaluedValue(enable); + + GetCore().SetProperty24HourNotation(envaluedValue); +} + +result +_TimePickerImpl::SetHour(int hour) +{ + ClearLastResult(); + + Variant hourValue(hour); + + return GetCore().SetPropertyHour(hourValue); +} + + +result +_TimePickerImpl::SetMinute(int minute) +{ + ClearLastResult(); + + Variant minuteValue(minute); + + return GetCore().SetPropertyMinute(minuteValue); +} + +void +_TimePickerImpl::SetTime(const DateTime& time) +{ + ClearLastResult(); + + Variant dateTimeValue(time); + + GetCore().SetPropertyDateTime(dateTimeValue); + + SetYear(0); + SetMonth(0); + SetDay(0); +} + +void +_TimePickerImpl::SetCurrentTime(void) +{ + ClearLastResult(); + + GetCore().SetCurrentDateTime(); + + SetYear(0); + SetMonth(0); + SetDay(0); +} + +result +_TimePickerImpl::SetYear(int year) +{ + Variant yearValue(year); + + return GetCore().SetPropertyYear(yearValue); +} + +result +_TimePickerImpl::SetMonth(int month) +{ + Variant monthValue(month); + + return GetCore().SetPropertyMonth(monthValue); +} + +result +_TimePickerImpl::SetDay(int day) +{ + Variant dayValue(day); + + return GetCore().SetPropertyDay(dayValue); +} + +void +_TimePickerImpl::OnDateTimeChanged(const Tizen::Ui::_Control& source, int year, int month, int day, int hour, int minute) +{ + ClearLastResult(); + + if (__pPublicDateTimeChangeEvent == null) + { + return; + } + + _PublicDateTimeChangeEventArg* pEventArg = new (std::nothrow) _PublicDateTimeChangeEventArg(TIME_PUBLIC_CHANGE_SAVED); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pEventArg->SetDate(year, month, day); + pEventArg->SetTime(hour, minute); + + __pPublicDateTimeChangeEvent->Fire(*pEventArg); +} + +void +_TimePickerImpl::OnDateTimeChangeCanceled(const Tizen::Ui::_Control& source) +{ + ClearLastResult(); + + if (__pPublicDateTimeChangeEvent == null) + { + return; + } + + _PublicDateTimeChangeEventArg* pEventArg = new (std::nothrow) _PublicDateTimeChangeEventArg(TIME_PUBLIC_CHANGE_CANCELED); + SysTryReturnVoidResult(NID_UI_CTRL, (pEventArg != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pPublicDateTimeChangeEvent->Fire(*pEventArg); +} + +void +_TimePickerImpl::OnChangeLayout(Tizen::Ui::_ControlOrientation orientation) +{ + ClearLastResult(); + + InitializeBoundsProperties(GET_SIZE_INFO(TimePicker), orientation); + _ControlImpl::OnChangeLayout(orientation); +} + +result +_TimePickerImpl::OnAttachedToMainTree(void) +{ + result r = E_SUCCESS; + + if (GetOwner() == null) + { + _FrameImpl* pFrameImpl = dynamic_cast <_FrameImpl*>(_ControlImplManager::GetInstance()->GetCurrentFrame()); + SysTryReturn(NID_UI_CTRL, (pFrameImpl != null), E_SYSTEM, E_SYSTEM, + "[E_SYSTEM] A system error has occurred. Failed to get frame instance."); + + _Form* pForm = pFrameImpl->GetCore().GetCurrentForm(); + if (pForm != null) + { + GetCore().SetOwner(pForm); + } + else + { + GetCore().SetOwner(&pFrameImpl->GetCore()); + } + } + SetVisibleState(true); + + _WindowImpl::OnAttachedToMainTree(); + return r; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TokenEdit.cpp b/src/ui/controls/FUiCtrl_TokenEdit.cpp new file mode 100644 index 0000000..29c2868 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TokenEdit.cpp @@ -0,0 +1,539 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TokenEdit.cpp + * @brief This is the implementation file for the _TokenEdit class. + */ + +#include +#include "FUiCtrl_TokenEdit.h" +#include "FUiCtrl_TokenEditPresenter.h" + +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_TokenEdit); + +_TokenEdit::_TokenEdit(void) + : _Edit() + , __pTokenEditPresenter(null) + , __isSelectedTokenTextColorSet(false) + , __pTokenFilter(null) + , __pDescriptionTextAccessibilityElement(null) + , __pHiddenTokenCountAccessibilityElement(null) + , __pExpandableButtonAccessibilityElement(null) +{ + GET_COLOR_CONFIG(TOKENEDIT::TOKEN_BG_NORMAL, __tokenColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL]); + GET_COLOR_CONFIG(TOKENEDIT::TOKEN_BG_SELECTED, __tokenColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED]); + + GET_COLOR_CONFIG(TOKENEDIT::TOKEN_TEXT_NORMAL, __tokenTextColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL]); + GET_COLOR_CONFIG(TOKENEDIT::TOKEN_TEXT_SELECTED, __tokenTextColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED]); + + _AccessibilityContainer* pContainer = null; + pContainer = GetAccessibilityContainer(); + if (pContainer) + { + pContainer->Activate(true); + } +} + +_TokenEdit::~_TokenEdit(void) +{ + +} + +_TokenEdit* +_TokenEdit::CreateTokenEditN(void) +{ + _TokenEditPresenter* pPresenter = _TokenEditPresenter::CreateTokenEditPresenterN(); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pPresenter != null, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + _TokenEdit* pTokenEdit = new (std::nothrow) _TokenEdit(); + SysTryCatch(NID_UI_CTRL, pTokenEdit != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pTokenEdit->AcquireHandle(); + + pTokenEdit->SetPresenter(*pPresenter); + pTokenEdit->__pTokenEditPresenter = pPresenter; + + return pTokenEdit; + +CATCH: + delete pPresenter; + delete pTokenEdit; + return null; +} + +void +_TokenEdit::OnDraw(void) +{ + result r = E_SUCCESS; + + if (__pTokenEditPresenter == null) + { + return; + } + + Canvas* pCanvas = GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + r = __pTokenEditPresenter->Draw(*pCanvas); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pCanvas; +} + +result +_TokenEdit::SetTokenFilter(const _ITokenFilter* pFilter) +{ + result r = E_SUCCESS; + + __pTokenFilter = const_cast <_ITokenFilter*>(pFilter); + + return r; +} + +_ITokenFilter* +_TokenEdit::GetTokenFilter(void) const +{ + return __pTokenFilter; +} + +result +_TokenEdit::AppendToken(const String& token) +{ + result r = E_SUCCESS; + + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + r = __pTokenEditPresenter->MakeToken(token); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +result +_TokenEdit::InsertTokenAt(int index, const String& token) +{ + result r = E_SUCCESS; + + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + r = __pTokenEditPresenter->InsertTokenAt(index, token, true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +String +_TokenEdit::GetTokenAt(int index) const +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + return __pTokenEditPresenter->GetTokenAt(index); +} + +int +_TokenEdit::GetTokenCount(void) const +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + return __pTokenEditPresenter->GetTokenCount(); +} + +int +_TokenEdit::GetSelectedTokenIndex(void) const +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + return __pTokenEditPresenter->GetSelectedTokenIndex(); +} + +bool +_TokenEdit::IsTokenEditModeEnabled(void) const +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + Variant var = GetProperty("tokenEditModeEnabled"); + + return var.ToBool(); +} + +result +_TokenEdit::RemoveTokenAt(int index) +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + return __pTokenEditPresenter->RemoveTokenAt(index, true); +} + +result +_TokenEdit::SetTokenSelected(int index, bool selected) +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + return __pTokenEditPresenter->SetTokenSelected(index, selected); +} + +result +_TokenEdit::SetTokenEditModeEnabled(bool enable) +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + Variant var(enable); + + return SetProperty("tokenEditModeEnabled", var); +} + +Color +_TokenEdit::GetTokenColor(ExpandableEditAreaTokenStatus status) const +{ + Variant var; + + switch (status) + { + case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL : + var = GetProperty("normalTokenColor"); + break; + + case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED : + var = GetProperty("selectedTokenColor"); + break; + + default : + break; + } + + return var.ToColor(); +} + +Color +_TokenEdit::GetTokenTextColor(void) const +{ + Variant var = GetProperty("tokenTextColor"); + + return var.ToColor(); +} + +result +_TokenEdit::SetTokenColor(ExpandableEditAreaTokenStatus status, const Color& color) +{ + result r = E_SUCCESS; + Variant var(color); + + switch (status) + { + case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL : + r = SetProperty("normalTokenColor", var); + break; + + case EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED : + r = SetProperty("selectedTokenColor", var); + break; + + default : + break; + } + + return r; +} + +result +_TokenEdit::SetTokenTextColor(const Color& color) +{ + Variant var(color); + return SetProperty("tokenTextColor", var); +} + +Color +_TokenEdit::GetSelectedTokenTextColor(void) const +{ + Variant var = GetProperty("selectedTokenTextColor"); + + return var.ToColor(); +} + +result +_TokenEdit::SetSelectedTokenTextColor(const Color& color) +{ + Variant var(color); + + return SetProperty("selectedTokenTextColor", var); +} + +result +_TokenEdit::SetTitleText(const String& title) +{ + result r = E_SUCCESS; + + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + __pTokenEditPresenter->SetDescriptionText(title); + + r = __pTokenEditPresenter->CalculateDescriptionTextRect(title); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = __pTokenEditPresenter->CalculateTokenPositionFromIndex(0); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = __pTokenEditPresenter->SetInitialBounds(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + return r; +} + +String +_TokenEdit::GetTitleText(void) const +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + return __pTokenEditPresenter->GetDescriptionText(); +} + +void +_TokenEdit::SetAutoShrinkModeEnabled(bool enable) +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + __pTokenEditPresenter->SetAutoShrinkModeEnabled(enable); +} + +bool +_TokenEdit::IsAutoShrinkModeEnabled(void) const +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + return __pTokenEditPresenter->IsAutoShrinkModeEnabled(); +} + +result +_TokenEdit::ProcessTokenFiltering(const String& inputString, String& replaceString, bool& enable) +{ + if (__pTokenFilter) + { + enable = __pTokenFilter->ReplaceToken(inputString, replaceString); + } + + return E_SUCCESS; +} + +bool +_TokenEdit::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + + if (__pTokenEditPresenter == null) + { + return false; + } + return __pTokenEditPresenter->OnTouchPressed(source, touchinfo); +} + +bool +_TokenEdit::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + if (__pTokenEditPresenter == null) + { + return false; + } + return __pTokenEditPresenter->OnTouchReleased(source, touchinfo); +} + +bool +_TokenEdit::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (&source != this) + { + return false; + } + if (__pTokenEditPresenter == null) + { + return false; + } + return __pTokenEditPresenter->OnTouchMoved(source, touchinfo); +} + +result +_TokenEdit::SetPropertyNormalTokenColor(const Variant& color) +{ + ClearLastResult(); + + __tokenColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL] = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_TokenEdit::GetPropertyNormalTokenColor(void) const +{ + ClearLastResult(); + + return Variant(__tokenColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL]); +} + +result +_TokenEdit::SetPropertySelectedTokenColor(const Variant& color) +{ + ClearLastResult(); + + __tokenColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED] = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_TokenEdit::GetPropertySelectedTokenColor(void) const +{ + ClearLastResult(); + + return Variant(__tokenColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED]); +} + +result +_TokenEdit::SetPropertyTokenTextColor(const Variant& color) +{ + ClearLastResult(); + + __tokenTextColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL] = color.ToColor(); + if(!__isSelectedTokenTextColorSet) + __tokenTextColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED] = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_TokenEdit::GetPropertyTokenTextColor(void) const +{ + ClearLastResult(); + + return Variant(__tokenTextColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL]); +} + +result +_TokenEdit::SetPropertySelectedTokenTextColor(const Variant& color) +{ + ClearLastResult(); + + __isSelectedTokenTextColorSet = true; + + __tokenTextColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED] = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_TokenEdit::GetPropertySelectedTokenTextColor(void) const +{ + ClearLastResult(); + + return Variant(__tokenTextColor[EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED]); +} + + +result +_TokenEdit::SetPropertyTokenEditModeEnabled(const Variant& enable) +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + ClearLastResult(); + + return __pTokenEditPresenter->SetTokenEditModeEnabled(enable.ToBool()); +} + +Variant +_TokenEdit::GetPropertyTokenEditModeEnabled(void) const +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + ClearLastResult(); + + bool enabled = __pTokenEditPresenter->IsTokenEditModeEnabled(); + + return Variant(enabled); +} + +result +_TokenEdit::OnAttachedToMainTree(void) +{ + _AccessibilityContainer* pContainer = null; + pContainer = GetAccessibilityContainer(); + if (pContainer) + { + if (__pDescriptionTextAccessibilityElement) + { + return E_SUCCESS; + } + + if (GetEditStyle() & EDIT_STYLE_TITLE_LEFT) + { + __pDescriptionTextAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + if (__pDescriptionTextAccessibilityElement) + { + __pDescriptionTextAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_TEXT_FIELD); + pContainer->AddElement(*__pDescriptionTextAccessibilityElement); + } + } + + if (IsAutoShrinkModeEnabled()) + { + __pHiddenTokenCountAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + if (__pHiddenTokenCountAccessibilityElement) + { + __pHiddenTokenCountAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_TEXT_FIELD); + pContainer->AddElement(*__pHiddenTokenCountAccessibilityElement); + } + + __pExpandableButtonAccessibilityElement = new (std::nothrow) _AccessibilityElement(true); + if (__pExpandableButtonAccessibilityElement) + { + __pExpandableButtonAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_EXPAND_BUTTON); + pContainer->AddElement(*__pExpandableButtonAccessibilityElement); + } + } + } + + return E_SUCCESS; +} + +void +_TokenEdit::OnBoundsChanged(void) +{ + SysAssertf(__pTokenEditPresenter != null, "_TokenEditPresenter instance is null"); + + __pTokenEditPresenter->OnBoundsChanged(); + + return; +} + +}}} //Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_TokenEditModel.cpp b/src/ui/controls/FUiCtrl_TokenEditModel.cpp new file mode 100644 index 0000000..0ebc617 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TokenEditModel.cpp @@ -0,0 +1,39 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TokenEditModel.cpp + * @brief This is the implementation file for the _TokenEditModel class. + */ + +#include "FUiCtrl_TokenEditModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_TokenEditModel::_TokenEditModel(void) +{ + +} + +_TokenEditModel::~_TokenEditModel(void) +{ + +} + +}; +}; +}; diff --git a/src/ui/controls/FUiCtrl_TokenEditPresenter.cpp b/src/ui/controls/FUiCtrl_TokenEditPresenter.cpp new file mode 100644 index 0000000..2699751 --- /dev/null +++ b/src/ui/controls/FUiCtrl_TokenEditPresenter.cpp @@ -0,0 +1,3628 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TokenEditPresenter.cpp + * @brief This is the implementation file for the _TokenEditPresenter class. + */ +#include +#include +#include +#include "FUiAnim_VisualElement.h" +#include "FUi_UiTouchEvent.h" +#include "FUiCtrl_TokenEdit.h" +#include "FUiCtrl_TokenEditPresenter.h" +#include "FUiCtrl_Scroll.h" + +using namespace Tizen::Base; +using namespace Tizen::Media; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +float +SineTimingFunction::CalculateProgress(float timeProgress) const +{ + const float segments[3][3] = {{0.0f, 0.01f, 0.37f}, {0.37f, 0.72f, 0.888f}, {0.888f, 0.9999f, 1.0f}}; + float timeProgressValue = timeProgress; + int segmentsLength = 3; //Length of the segments array + int index = (int)floor(segmentsLength * timeProgressValue); + if (index >= segmentsLength) + { + index = segmentsLength - 1; + } + + float progressValue = (timeProgressValue - index * (1.0 / segmentsLength)) * segmentsLength; + float segmentAtIndex[3]; + for(int i = 0; i < 3; i++) + { + segmentAtIndex[i] = segments[index][i]; + } + float ret = 0 + 1 * (segmentAtIndex[0] + progressValue * (2 * (1 - progressValue) * (segmentAtIndex[1] - segmentAtIndex[0]) + progressValue * (segmentAtIndex[2] - segmentAtIndex[0]))); + + return ret; +} + +class _Token + : public Object +{ +public: + _Token(const String& text, Font* pEditFont); + virtual ~_Token(void); + int GetTextPixelWidth(void) const; + wchar_t* GetText(void) const; + result ResetToken(const String& text); + result SetBounds(Rectangle bounds); + _VisualElement* GetVisualElement(void) const; + _Token(const _Token& src); + _Token& operator =(const _Token& value); + +public: + Rectangle displayRect; + TextObject* pTextObject; + Font* pFont; + int currTokenLength; + bool isImplicitAnimation; + bool isTextCut; +private: + wchar_t* __pTextBuffer; + int __textPixelWidth; + int __textPixelHeight; + _VisualElement* __pVisualElement; +}; // _Token + +_Token::_Token(const String& text, Font* pEditFont) + : pTextObject(null) + , pFont(null) + , currTokenLength(0) + , isImplicitAnimation(true) + , isTextCut(false) + , __pTextBuffer(null) + , __textPixelWidth(0) + , __textPixelHeight(0) + , __pVisualElement(null) +{ + result r = E_SUCCESS; + + currTokenLength = text.GetLength(); + int tokenFontSize = 0; + + pTextObject = new (std::nothrow) TextObject; + SysTryReturnVoidResult(NID_UI_CTRL, pTextObject != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + // for default initialize. + r = pTextObject->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, tokenFontSize); + + pFont = new (std::nothrow) Font; + SysTryCatch(NID_UI_CTRL, pFont != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pFont->Construct(pEditFont->GetFaceName(), FONT_STYLE_PLAIN, tokenFontSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTextObject->SetFont(pFont, 0, pTextObject->GetTextLength()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = ResetToken(text); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pVisualElement = new (std::nothrow) _VisualElement; + SysTryCatch(NID_UI_CTRL, __pVisualElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pVisualElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct _VisualElement.", GetErrorMessage(r)); + + __pVisualElement->SetImplicitAnimationEnabled(false); + + return; + +CATCH: + delete pTextObject; + pTextObject = null; + + if (__pVisualElement) + { + __pVisualElement->Destroy(); + __pVisualElement = null; + } + + delete pFont; + pFont = null; + + return; +} + +result +_Token::ResetToken(const String& text) +{ + result r = E_SUCCESS; + Dimension textSize; + + if (__pTextBuffer) + { + delete[] __pTextBuffer; + __pTextBuffer = null; + } + + int length = text.GetLength(); + wchar_t* pTempString = const_cast (text.GetPointer()); + SysTryReturnResult(NID_UI_CTRL, pTempString != null, E_SYSTEM, "A system error has occurred. Token text string is null."); + + __pTextBuffer = new (std::nothrow) wchar_t[(length + 1) * (sizeof(wchar_t))]; + SysTryReturnResult(NID_UI_CTRL, __pTextBuffer != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + for (int i = 0; i < length; i++) + { + __pTextBuffer[i] = pTempString[i]; + } + __pTextBuffer[length] = 0; + + pTextObject->RemoveAll(); + + TextSimple* pSimpleText = new (std::nothrow)TextSimple(__pTextBuffer, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, pFont); + SysTryCatch(NID_UI_CTRL, pSimpleText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pTextObject->AppendElement(*pSimpleText); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + textSize = pTextObject->GetTextExtent(0, length); + __textPixelWidth = textSize.width; + __textPixelHeight = textSize.height; + + r = pTextObject->Compose(); + + currTokenLength = length; + + return E_SUCCESS; + +CATCH: + delete[] __pTextBuffer; + __pTextBuffer = null; + + delete pSimpleText; + pSimpleText = null; + + return E_SYSTEM; +} + +result +_Token::SetBounds(Rectangle bounds) +{ + result r = E_SUCCESS; + displayRect = bounds; + if (__pVisualElement) + { + __pVisualElement->SetBounds(FloatRectangle(bounds.x, bounds.y, bounds.width, bounds.height)); + } + return r; +} + +_VisualElement* +_Token::GetVisualElement(void) const +{ + return __pVisualElement; +} + +_Token::~_Token(void) +{ + delete pTextObject; + pTextObject = null; + + delete pFont; + pFont = null; + + delete[] __pTextBuffer; + __pTextBuffer = null; + + if (__pVisualElement) + { + __pVisualElement->Destroy(); + __pVisualElement = null; + } +} + +int +_Token::GetTextPixelWidth(void) const +{ + return __textPixelWidth; +} + +wchar_t* +_Token::GetText(void) const +{ + return __pTextBuffer; +} + +_TokenEditPresenter::_TokenEditPresenter(void) + : __pTokenEdit(null) + , __pTokenList(null) + , __pTokenBgBitmap(null) + , __pressedTokenIndex(-1) + , __isEditingToken(false) + , __edittingTokenIndex(-1) + , __clientRect(Rectangle(0, 0, 0, 0)) + , __initTextRect(Rectangle(0, 0, 0, 0)) + , __isEditModeEnabled(true) + , __pDescriptionTextVisualElement(null) + , __pDescriptionTextTextObject(null) + , __pDescriptionTextFont(null) + , __isTokenEditingFinished(false) + , __prevScrollValue(0) + , __scrollValue(0) + , __isTokenScrolling(false) + , __isNeedToScroll(false) + , __maxScrollValue(0) + , __autoShrink(false) + , __hiddenTokenDisplayCountBounds(Rectangle()) + , __pHiddenTokenCountVisualElement(null) + , __autoShrinkAlignmentValue(0) + , __pHiddenTokenCountTextObject(null) + , __descriptionText(String()) + , __isPopupVisible(false) + , __isLongPressed(false) + , __lineSpacing(0) + , __animatingIndex(-1) + , __lastTokenIndex(-1) + , __pTimingFunction(null) + , __descriptionTextRectForScroll(Rectangle(0, 0, 0, 0)) + , __previousTitleWidth(-1) + , __previousEditBounds(Rectangle(0, 0, 0, 0)) + , __isTokenEditPresenterInitialized(false) + , __isFocus(false) + , __previousCursorPosition(0) + , __isScrollValueChanged(false) + , __lineAdded(0) + , __isScrollValueModified(false) +{ +} + +result +_TokenEditPresenter::InitializeDescriptionText(void) +{ + result r = E_SUCCESS; + int descriptionTextSize = 0; + + __pDescriptionTextTextObject = new (std::nothrow) TextObject(); + SysTryReturnResult(NID_UI_CTRL, __pDescriptionTextTextObject != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + // for default initialize. + r = __pDescriptionTextTextObject->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pDescriptionTextTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT | TEXT_OBJECT_ALIGNMENT_MIDDLE); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pDescriptionTextTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + GET_SHAPE_CONFIG(TOKENEDIT::DESCRIPTION_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, descriptionTextSize); + + __pDescriptionTextFont = new (std::nothrow) Font(); + SysTryCatch(NID_UI_CTRL, __pDescriptionTextFont != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pDescriptionTextFont->Construct(GetTitleFontFaceName(), FONT_STYLE_PLAIN, descriptionTextSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = __pDescriptionTextTextObject->SetFont(__pDescriptionTextFont, 0, __pDescriptionTextTextObject->GetTextLength()); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + + delete __pDescriptionTextTextObject; + __pDescriptionTextTextObject = null; + + delete __pDescriptionTextFont; + __pDescriptionTextFont = null; + + return r; +} + +_TokenEditPresenter::~_TokenEditPresenter(void) +{ + DisposeTokenEditPresenter(); +} + +result +_TokenEditPresenter::DisposeTokenEditPresenter(void) +{ + _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); + _VisualElement* pCursorVisualElement = GetCursorVisualElement(); + + if (pEditVisualElement && pCursorVisualElement) + { + VisualElement* pCursorParent = pCursorVisualElement->GetParent(); + if (pCursorParent != pEditVisualElement) + { + if (pCursorParent) + { + pCursorParent->DetachChild(*pCursorVisualElement); + pEditVisualElement->AttachChild(*pCursorVisualElement); + } + } + } + + if (__pTokenList) + { + __pTokenList->RemoveAll(true); + delete __pTokenList; + __pTokenList = null; + } + + delete __pTokenBgBitmap; + __pTokenBgBitmap = null; + + if (__pDescriptionTextVisualElement) + { + __pDescriptionTextVisualElement->Destroy(); + __pDescriptionTextVisualElement = null; + } + + delete __pDescriptionTextTextObject; + __pDescriptionTextTextObject = null; + + if (__pDescriptionTextFont) + { + delete __pDescriptionTextFont; + __pDescriptionTextFont = null; + } + + if (__pHiddenTokenCountVisualElement) + { + __pHiddenTokenCountVisualElement->Destroy(); + __pHiddenTokenCountVisualElement = null; + } + + delete __pHiddenTokenCountTextObject; + __pHiddenTokenCountTextObject = null; + + if (__pTimingFunction) + { + delete __pTimingFunction; + __pTimingFunction = null; + } + + return E_SUCCESS; +} + +_TokenEditPresenter* +_TokenEditPresenter::CreateTokenEditPresenterN(void) +{ + _TokenEditPresenter* pPresenter = new (std::nothrow) _TokenEditPresenter(); + SysTryReturn(NID_UI_CTRL, pPresenter != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + return pPresenter; +} + +result +_TokenEditPresenter::Initialize(const _Control& control) +{ + result r = E_SUCCESS; + + r = _EditPresenter::Initialize(control); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = InitializeDescriptionText(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + TextObject* pTextObject = GetTextObject(); + if (pTextObject) + { + pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + pTextObject->SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL); + } + + __pTokenEdit = dynamic_cast <_TokenEdit*>(GetEditView()); + SysTryReturnResult(NID_UI_CTRL, __pTokenEdit != null, E_SYSTEM, "A system error has occurred. The _Token instance is null."); + + _TokenEditModel* pTokenEditModel = new (std::nothrow) _TokenEditModel(); + SysTryReturnResult(NID_UI_CTRL, pTokenEditModel != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + SetModel(*pTokenEditModel); + + SetKeypadEnabled(true); + + int tokenLeftMargin = 0; + int tokenRightMargin = 0; + int tokenTopMargin = 0; + int tokenBottomMargin = 0; + int tokenHeight = 0; + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + + GET_SHAPE_CONFIG(TOKENEDIT::LEFT_MARGIN, orientation, tokenLeftMargin); + GET_SHAPE_CONFIG(TOKENEDIT::RIGHT_MARGIN, orientation, tokenRightMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin); + GET_SHAPE_CONFIG(TOKENEDIT::BOTTOM_MARGIN, orientation, tokenBottomMargin); + GET_SHAPE_CONFIG(TOKEN_HEIGHT, orientation, tokenHeight); + + // For drawing token in specific area + __clientRect.x = tokenLeftMargin; + __clientRect.y = tokenTopMargin; + __clientRect.width = __pTokenEdit->GetBounds().width - tokenLeftMargin - tokenRightMargin; + __clientRect.height = __pTokenEdit->GetBounds().height - tokenTopMargin - tokenBottomMargin; + + __initTextRect = GetTextBounds(); + + Rectangle tempDspRect(__initTextRect.x, __initTextRect.y, __clientRect.width, tokenHeight); + SetTextBounds(tempDspRect); + + int textSize = 0; + GET_SHAPE_CONFIG(TOKENEDIT::TEXT_SIZE, orientation, textSize); + + Font* pFont = new (std::nothrow) Font(); + SysTryCatch(NID_UI_CTRL, pFont != null, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pFont->Construct(FONT_STYLE_PLAIN, textSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SetFont(*pFont); + + delete pFont; + pFont = null; + + __pTokenList = new (std::nothrow) Collection::LinkedList(); + SysTryCatch(NID_UI_CTRL, __pTokenList != null, , r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __delimiter = L"\n"; + GET_BITMAP_CONFIG_N(TOKENEDIT::TOKEN_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pTokenBgBitmap); + + __previousEditBounds = __pTokenEdit->GetBounds(); + + __isTokenEditPresenterInitialized = true; + + __previousCursorPosition = GetCursorPosition(); + + return r; + +CATCH: + + delete pTokenEditModel; + pTokenEditModel = null; + + delete pFont; + pFont = null; + + return r; +} + +result +_TokenEditPresenter::Draw(Canvas& canvas) +{ + if (!IsInitialized()) + { + InitializeAtFirstDrawing(); + + if (IsFocused() == true) + { + ShowKeypad(false); + } + } + + canvas.SetBackgroundColor(Color(0, 0, 0, 0)); + canvas.Clear(); + + DrawBackground(canvas); + + DrawScrollBar(); + + if (__pDescriptionTextTextObject->GetTextLength() != 0) + { + DrawDescriptionText(); + } + + if (GetTokenCount() != 0) + { + DrawToken(); + } + + if (__autoShrink) + { + DrawHiddenTokenCount(); + } + + _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pEditVisualElement != null, E_SYSTEM, "A system error has occurred. Failed to get root visual element."); + + _VisualElement* pCursorVisualElement = GetCursorVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pCursorVisualElement != null, E_SYSTEM, "A system error has occurred. Failed to get cursor visual element."); + + _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + + if (pToken) + { + _VisualElement* pTokenVisualElement = pToken->GetVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pTokenVisualElement != null, E_SYSTEM, "A system error has occurred. Failed to get visual element of token."); + + if (__isEditingToken) + { + Canvas* pTokenCanvas = pTokenVisualElement->GetCanvasN(); + SysTryReturnResult(NID_UI_CTRL, pTokenCanvas != null, E_SYSTEM, "A system error has occurred. Failed to get canvas of the token."); + + _EditPresenter::SetFont(*(pToken->pFont)); + + DrawText(*pTokenCanvas); + InitializeCursor(); + + delete pTokenCanvas; + pTokenCanvas = null; + } + else + { + //DrawText(canvas); + DrawText(); + InitializeCursor(); + } + } + else + { + SysTryReturnResult(NID_UI_CTRL, !__isEditingToken, E_SYSTEM, "An invalid argument is given."); + + //DrawText(canvas); + DrawText(); + InitializeCursor(); + } + + if (__isTokenEditingFinished) + { + _EditPresenter::SetDefaultFont(); + + __isEditingToken = false; + __edittingTokenIndex = -1; + __isTokenEditingFinished = false; + } + + return E_SUCCESS; +} + +bool +_TokenEditPresenter::DrawToken(int count) +{ + int drawStartIndex = 0; + int tokenCount = 0; + int tokenTextLeftMargin = 0; + + SysTryReturn(NID_UI_CTRL, __pTokenEdit != null, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); + + if (count == -1) + { + tokenCount = __pTokenList->GetCount(); + } + else + { + tokenCount = count; + } + + Color normalTokenColor; + Color selectedTokenColor; + + for (int i = drawStartIndex; i < tokenCount; i++) + { + Bitmap* pReplacementColorBackgroundBitmap = null; + + _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + if (pToken == null || pToken->pTextObject == null) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] The _Token instance is null"); + break; + } + + normalTokenColor = GetTokenEditColor(EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL); + selectedTokenColor = GetTokenEditColor(EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED); + + _VisualElement* pTokenElement = pToken->GetVisualElement(); + if (pTokenElement == null) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. The _VisualElement instance is null"); + break; + } + + bool isSelected = false; + Canvas* pTokenCanvas = pTokenElement->GetCanvasN(); + if (pTokenCanvas == null) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. The Canvas instance is null"); + break; + } + Rectangle tokenRect(0, 0 , pToken->displayRect.width, pToken->displayRect.height); + + if (__pressedTokenIndex == i && IsFocused()) + { + if (__pTokenBgBitmap) + { + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pTokenBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), selectedTokenColor); + + if (pReplacementColorBackgroundBitmap->IsNinePatchedBitmap()) + { + pTokenCanvas->DrawNinePatchedBitmap(tokenRect, *pReplacementColorBackgroundBitmap); + } + else + { + pTokenCanvas->DrawBitmap(tokenRect, *pReplacementColorBackgroundBitmap); + } + } + else + { + pTokenCanvas->FillRectangle(selectedTokenColor, tokenRect); + } + + isSelected = true; + } + else + { + if (__pTokenBgBitmap) + { + pReplacementColorBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pTokenBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), normalTokenColor); + + if (pReplacementColorBackgroundBitmap->IsNinePatchedBitmap()) + { + pTokenCanvas->DrawNinePatchedBitmap(tokenRect, *pReplacementColorBackgroundBitmap); + } + else + { + pTokenCanvas->DrawBitmap(tokenRect, *pReplacementColorBackgroundBitmap); + } + } + else + { + pTokenCanvas->FillRectangle(normalTokenColor, tokenRect); + } + } + + pTokenElement->SetAnimationProvider(null); + if (pToken->isImplicitAnimation) + { + VisualElementAnimation* pAnimation = CreateAnimationN(*pTokenElement, true); + pTokenElement->AddAnimation(*pAnimation); + delete pAnimation; + pToken->isImplicitAnimation = false; + } + + if (!__isEditingToken || __pressedTokenIndex != i) + { + Color textColor; + Rectangle textRect(0, 0, pToken->displayRect.width - ((tokenTextLeftMargin * 2)), pToken->displayRect.height); + + textRect.x += tokenTextLeftMargin; + if (pToken->displayRect.width > pToken->GetTextPixelWidth()) + { + textRect.width = pToken->GetTextPixelWidth() + 1; + } + + if (isSelected) + { + textColor = GetTokenEditTextColor(EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED); + } + else + { + textColor = GetTokenEditTextColor(EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL); + } + + pToken->pTextObject->SetForegroundColor(textColor, 0, pToken->pTextObject->GetTextLength()); + pToken->pTextObject->SetBounds(textRect); + pToken->pTextObject->Compose(); + pToken->pTextObject->Draw(*_CanvasImpl::GetInstance(*pTokenCanvas)); + } + + pTokenElement->SetFlushNeeded(); + delete pTokenCanvas; + + delete pReplacementColorBackgroundBitmap; + pReplacementColorBackgroundBitmap = null; + } + return true; +} + +Color +_TokenEditPresenter::GetTokenEditColor(const ExpandableEditAreaTokenStatus status) const +{ + SysTryReturn(NID_UI_CTRL, __pTokenEdit != null, Color(0, 0, 0, 0), E_INVALID_STATE, "[E_INVALID_STATE] _TokenEdit is in an invalid state."); + + Color color; + + if (status == EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL) + color = __pTokenEdit->GetTokenColor(EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL); + else + color = __pTokenEdit->GetTokenColor(EXPANDABLE_EDIT_AREA_TOKEN_STATUS_SELECTED); + + return color; +} + +Color +_TokenEditPresenter::GetTokenEditTextColor(const ExpandableEditAreaTokenStatus status) const +{ + SysTryReturn(NID_UI_CTRL, __pTokenEdit != null, Color(0, 0, 0, 0), E_INVALID_STATE, "[E_INVALID_STATE] _TokenEdit is in an invalid state."); + + Color color; + + if (status == EXPANDABLE_EDIT_AREA_TOKEN_STATUS_NORMAL) + color = __pTokenEdit->GetTokenTextColor(); + else + color = __pTokenEdit->GetSelectedTokenTextColor(); + + return color; +} + +result +_TokenEditPresenter::MakeToken(const String& tokenString) +{ + SysTryReturnResult(NID_UI_CTRL, __pTokenEdit != null, E_INVALID_STATE, "_TokenEdit is in an invalid state."); + result r = E_SUCCESS; + + int tokenCount = 0; + int index = -1; + int tokenLength = tokenString.GetLength(); + SysTryReturnResult(NID_UI_CTRL, tokenLength, E_INVALID_ARG, "Invalid argument is used. Token length is (%d)", tokenLength); + + String inputTokenString = tokenString; + String replacementString = inputTokenString; + bool enable = false; + + __pTokenEdit->ProcessTokenFiltering(inputTokenString, replacementString, enable); + + if (enable) + { + inputTokenString = replacementString; + } + + if (inputTokenString.GetLength() <= 0) + { + r = ClearText(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to clear text object.", GetErrorMessage(r)); + + SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument is used. Token length is (%d)", inputTokenString.GetLength()); + return E_INVALID_ARG; + } + + _Token* pToken = new (std::nothrow) _Token(inputTokenString, GetFont()); + SysTryReturnResult(NID_UI_CTRL, pToken != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pTokenList->Add(static_cast (*pToken)); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + tokenCount = __pTokenList->GetCount(); + index = tokenCount - 1; + + r = CalculateTokenPositionFromIndex(index); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to calculate token position.", GetErrorMessage(r)); + + r = TrimTokenAndAdjustEllipsisAt(index); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to trim token.", GetErrorMessage(r)); + + r = InitializeTokenVisibilityAt(index); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to initialize token visibility.", GetErrorMessage(r)); + + r = SetInitialBounds(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds.", GetErrorMessage(r)); + + r = ClearText(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to clear text object.", GetErrorMessage(r)); + + r = AdjustFlexibleHeight(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to process to resize.", GetErrorMessage(r)); + + r = CheckTokenScrolling(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to process scroll.", GetErrorMessage(r)); + + return r; + +CATCH: + delete pToken; + pToken = null; + + return r; +} + +result +_TokenEditPresenter::MakeToken(void) +{ + result r = E_SUCCESS; + + String tempToken(GetText()); + r = MakeToken(tempToken); + + return r; +} + +result +_TokenEditPresenter::InsertTokenAt(int index, const String& token, bool isUser) +{ + SysTryReturnResult(NID_UI_CTRL, index >= 0, E_INVALID_ARG, "Invalid argument is used. index is (%d).", index); + SysTryReturnResult(NID_UI_CTRL, token.GetLength() > 0, E_INVALID_ARG, "Invalid argument is used. Token length is (%d).", token.GetLength()); + + result r = E_SUCCESS; + + _Token* pToken = new (std::nothrow) _Token(token, GetFont()); + SysTryReturnResult(NID_UI_CTRL, pToken != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __pTokenList->InsertAt(*pToken, index); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to insert token.", GetErrorMessage(r)); + + if (__isEditingToken) + { + _EditPresenter::SetFont(*(pToken->pFont)); + } + + r = ClearText(); + + r = CalculateTokenPositionFromIndex(index); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to calculate token position.", GetErrorMessage(r)); + + r = TrimTokenAndAdjustEllipsisAt(index); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to trim token.", GetErrorMessage(r)); + + r = InitializeTokenVisibilityAt(index); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to initialize token visibility.", GetErrorMessage(r)); + + r = SetInitialBounds(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds.", GetErrorMessage(r)); + + r = AdjustFlexibleHeight(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to process to resize.", GetErrorMessage(r)); + + r = CheckTokenScrolling(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to process scroll.", GetErrorMessage(r)); + + for (int i = 0; i < GetTokenCount(); i++) + { + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + SysTryCatch(NID_UI_CTRL, pToken != null, ,r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null"); + + r = pToken->SetBounds(pToken->displayRect); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds", GetErrorMessage(r)); + } + + if (isUser) + { + if (__edittingTokenIndex >= 0) + { + if (index <= __edittingTokenIndex) + { + __edittingTokenIndex++; + } + __pressedTokenIndex = __edittingTokenIndex; + + SetEditingTokenTextBounds(__edittingTokenIndex); + _EditPresenter::SetCursorPosition(__previousCursorPosition); + } + else if (__pressedTokenIndex >= index) + { + __pressedTokenIndex++; + } + } + + return r; + +CATCH: + + delete pToken; + pToken = null; + + return r; +} + +String +_TokenEditPresenter::GetTokenAt(int index) const +{ + String tempString; + SysTryReturn(NID_UI_CTRL, index >= 0 && index < __pTokenList->GetCount(), tempString, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] index (%d) is out of range.", index); + + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(index)); + if (pToken) + { + tempString = pToken->GetText(); + } + + return tempString; +} + +int +_TokenEditPresenter::GetTokenCount(void) const +{ + return __pTokenList->GetCount(); +} + +int +_TokenEditPresenter::GetSelectedTokenIndex(void) const +{ + return __pressedTokenIndex; +} + +bool +_TokenEditPresenter::IsTokenEditModeEnabled(void) const +{ + return __isEditModeEnabled; +} + +result +_TokenEditPresenter::RemoveTokenAt(int index, bool isClearText) +{ + result r = E_SUCCESS; + SysTryReturnResult(NID_UI_CTRL, index >= 0 && index < __pTokenList->GetCount(), E_OUT_OF_RANGE, "index (%d) is out of range.", index); + + if (index == __edittingTokenIndex && isClearText) + { + _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pEditVisualElement, E_SYSTEM, "A system error has occurred. Failed to get root visual element."); + + _VisualElement* pCursorVisualElement = GetCursorVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pCursorVisualElement, E_SYSTEM, "A system error has occurred. Failed to get cursor visual element."); + + r = pCursorVisualElement->GetParent()->DetachChild(*pCursorVisualElement); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pEditVisualElement->AttachChild(*pCursorVisualElement); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + __edittingTokenIndex = -1; + __isEditingToken = false; + __pressedTokenIndex = -1; + __isTokenEditingFinished = true; + + r = ClearText(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Failed to clear text object."); + + _EditPresenter::SetDefaultFont(); + } + + r = __pTokenList->RemoveAt(index, true); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove token."); + + r = CalculateTokenPositionFromIndex(index); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to calculate token position."); + + r = SetInitialBounds(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds."); + + _Token* pToken = null; + + for (int i = 0; i < GetTokenCount(); i++) + { + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + SysTryReturnResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "A system error has occurred. The _Token instance is null"); + + r = pToken->SetBounds(pToken->displayRect); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds"); + } + + r = AdjustFlexibleHeight(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to process to resize."); + + r = CheckTokenScrolling(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to process scroll."); + + if (isClearText) + { + if (index < __edittingTokenIndex) + { + if (__edittingTokenIndex > 0) + { + __edittingTokenIndex--; + __pressedTokenIndex = __edittingTokenIndex; + + SetEditingTokenTextBounds(__edittingTokenIndex); + _EditPresenter::SetCursorPosition(__previousCursorPosition); + } + } + else if (index == __pressedTokenIndex) + { + __pressedTokenIndex = -1; + } + else if (index >= 0 && index < __pressedTokenIndex) + { + __pressedTokenIndex--; + } + } + else if (index == __pressedTokenIndex) + { + __pressedTokenIndex = -1; + } + + return r; +} + +result +_TokenEditPresenter::SetTokenSelected(int index, bool selected) +{ + result r = E_SUCCESS; + + SysTryReturnResult(NID_UI_CTRL, index >= 0 && index < __pTokenList->GetCount(), E_OUT_OF_RANGE, "index (%d) is out of range."); + + if (selected == false) + { + __pressedTokenIndex = -1; + } + else + { + __pressedTokenIndex = index; + } + + return r; +} + +result +_TokenEditPresenter::SetTokenEditModeEnabled(bool enable) +{ + result r = E_SUCCESS; + + __isEditModeEnabled = enable; + + return r; +} + +result +_TokenEditPresenter::CalculateTokenPositionFromIndex(int startIndex, bool leftWard) +{ + result r = E_SUCCESS; + + int tokenCount = __pTokenList->GetCount(); + + int tokenLeftMargin = 0; + int tokenRighttMargin = 0; + int tokenTopMargin = 0; + int tokenBottomMargin = 0; + int tokenHeight = 0; + int tokenVerticalSpacing = 0; + int tokenHorizontalSpacing = 0; + int tokenTextLeftMargin = 0; + int tokenTextRightMargin = 0; + int descriptionTextRightMargin = 0; + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + + GET_SHAPE_CONFIG(TOKENEDIT::LEFT_MARGIN, orientation, tokenLeftMargin); + GET_SHAPE_CONFIG(TOKENEDIT::RIGHT_MARGIN, orientation, tokenRighttMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin); + GET_SHAPE_CONFIG(TOKENEDIT::BOTTOM_MARGIN, orientation, tokenBottomMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HEIGHT, orientation, tokenHeight); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenVerticalSpacing); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HORIZONTAL_SPACING, orientation, tokenHorizontalSpacing); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin); + GET_SHAPE_CONFIG(TOKENEDIT::DESCRIPTION_TEXT_RIGHT_MARGIN, orientation, descriptionTextRightMargin); + + SysTryReturn(NID_UI_CTRL, startIndex >= 0 && startIndex <= tokenCount, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. startIndex = (%d)", startIndex); + + _Token* pToken = null; + _Token* pPreviousToken = null; + + int index = startIndex; + + Rectangle tokenEditBounds = __pTokenEdit->GetBounds(); + String titleText = __pTokenEdit->GetTitleText(); + + if (GetDescriptionTextRect().width != __previousTitleWidth) + { + __descriptionTextRectForScroll = GetDescriptionTextRect(); + __previousTitleWidth = GetDescriptionTextRect().width; + } + + bool findPrevTokenLoopFlag = true; + for (; index < tokenCount; index++) + { + pToken = static_cast <_Token*>(__pTokenList->GetAt(index)); + SysTryReturn(NID_UI_CTRL, pToken, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + if (index == 0) + { + // TODO : description text (title style inner) + if (titleText.GetLength()) + { + pToken->displayRect.x = __descriptionTextRectForScroll.x + __descriptionTextRectForScroll.width + descriptionTextRightMargin; + pToken->displayRect.y = __descriptionTextRectForScroll.y + __scrollValue; + } + else // Set description text. + { + pToken->displayRect.x = tokenTextLeftMargin + __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + pToken->displayRect.y = tokenTopMargin + __scrollValue + __pTokenEdit->GetVerticalMargin(EDIT_TEXT_TOP_MARGIN) + __lineSpacing; + + } + pToken->displayRect.width = tokenTextLeftMargin + pToken->GetTextPixelWidth() + tokenTextRightMargin; + + } + else + { + if (findPrevTokenLoopFlag) + { + pPreviousToken = static_cast <_Token*>(__pTokenList->GetAt(index - 1)); + findPrevTokenLoopFlag = false; + } + + int tempTextWidth = tokenEditBounds.width - pPreviousToken->displayRect.x - pPreviousToken->displayRect.width - tokenHorizontalSpacing - __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN); + if (tokenTextLeftMargin + pToken->GetTextPixelWidth() + tokenTextRightMargin > tempTextWidth) // Line change + { + pToken->displayRect.x = tokenTextLeftMargin + __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + pToken->displayRect.y = pPreviousToken->displayRect.y + tokenHeight + tokenVerticalSpacing + __lineSpacing; + __lineAdded++; + } + else + { + pToken->displayRect.x = pPreviousToken->displayRect.x + pPreviousToken->displayRect.width + + tokenHorizontalSpacing; + pToken->displayRect.y = pPreviousToken->displayRect.y; + } + + pToken->displayRect.width = tokenTextLeftMargin + pToken->GetTextPixelWidth() + tokenTextRightMargin; + } + + pToken->displayRect.height = tokenHeight; + + pPreviousToken = pToken; + } + + for (int i = 0; i < __pTokenList->GetCount(); i++) + { + TrimTokenAndAdjustEllipsisAt(i); + InitializeTokenVisibilityAt(i); + } + return r; +} + +result +_TokenEditPresenter::InitializeTokenVisibilityAt(int ndex) +{ + result r = E_SUCCESS; + + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(ndex)); + SysTryReturn(NID_UI_CTRL, pToken, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + r = pToken->SetBounds(pToken->displayRect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to set bounds", GetErrorMessage(r)); + + _VisualElement* pRootElement = __pTokenEdit->GetVisualElement(); + SysTryReturn(NID_UI_CTRL, pRootElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element."); + + _VisualElement* pVisualElement = pToken->GetVisualElement(); + SysTryReturn(NID_UI_CTRL, pVisualElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get visual element."); + + pVisualElement->SetShowState(true); + + r = pRootElement->AttachChild(*pVisualElement); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add child", GetErrorMessage(r)); + + return r; +} + +result +_TokenEditPresenter::SetInitialBounds(void) +{ + result r = E_SUCCESS; + + int tokenTopMargin = 0; + int tokenHeight = 0; + int tokenMinWidth = 0; + int tokenVerticalSpacing = 0; + int tokenHorizontalSpacing = 0; + int tokenTextLeftMargin = 0; + int tokenTextRightMargin = 0; + _ControlOrientation orientation = GetEditView()->GetOrientation(); + + GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HEIGHT, orientation, tokenHeight); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_MIN_WIDTH, orientation, tokenMinWidth); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenVerticalSpacing); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HORIZONTAL_SPACING, orientation, tokenHorizontalSpacing); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin); + + if (__pTokenList) + { + int tokenCount = __pTokenList->GetCount(); + + Rectangle tokenEditBounds = __pTokenEdit->GetBounds(); + Rectangle tokenTextRect = tokenEditBounds; + + if (tokenCount == 0) + { + if (__pTokenEdit->GetTitleText().GetLength()) + { + Rectangle descriptionTextRect = GetDescriptionTextRect(); + + tokenTextRect.x = descriptionTextRect.x + descriptionTextRect.width + tokenVerticalSpacing; + tokenTextRect.width -= (tokenTextLeftMargin + tokenTextRightMargin + descriptionTextRect.width + 2 * __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN)); + } + else + { + tokenTextRect.x = tokenTextLeftMargin + __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + tokenTextRect.width -= (tokenTextLeftMargin + tokenTextRightMargin + 2 * __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN)); + } + + tokenTextRect.y = tokenTopMargin + __pTokenEdit->GetVerticalMargin(EDIT_TEXT_TOP_MARGIN); + tokenTextRect.height = __pTokenEdit->GetTextSize() + (2 * tokenTopMargin); + + SetTextBounds(tokenTextRect); + + return r; + } + + _Token* pToken = null; + // SetTextBounds from last token + pToken = static_cast <_Token*>(__pTokenList->GetAt(tokenCount - 1)); + SysTryReturn(NID_UI_CTRL, pToken, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null"); + + int tempTextRectWidth = 0; + tempTextRectWidth = tokenEditBounds.width - pToken->displayRect.x - pToken->displayRect.width - tokenHorizontalSpacing - __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN); + if (tokenMinWidth > tempTextRectWidth) // Line change + { + tokenTextRect.x = tokenTextLeftMargin + __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN); + tokenTextRect.y = pToken->displayRect.y + tokenHeight + tokenVerticalSpacing + __lineSpacing; + tokenTextRect.width = tokenEditBounds.width - tokenTextLeftMargin - tokenTextRightMargin - 2 * __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN); + } + else + { + tokenTextRect.x = pToken->displayRect.x + pToken->displayRect.width + tokenHorizontalSpacing; + tokenTextRect.y = pToken->displayRect.y; + tokenTextRect.width = tokenEditBounds.width - pToken->displayRect.x - pToken->displayRect.width - + tokenTextRightMargin - __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN) - tokenTextLeftMargin; + } + + tokenTextRect.height = __pTokenEdit->GetTextSize() + (2 * tokenTopMargin); + + SetTextBounds(tokenTextRect); + } + else + { + r = _EditPresenter::SetInitialBounds(); + } + + return r; +} + +result +_TokenEditPresenter::SetDescriptionTextRect(const Rectangle& rect) +{ + result r = E_SUCCESS; + + __descriptionTextRect = rect; + + return r; +} + +Rectangle +_TokenEditPresenter::GetDescriptionTextRect() const +{ + return __descriptionTextRect; +} + +Rectangle +_TokenEditPresenter::GetTextBounds(void) const +{ + if ((__isPopupVisible == true || __isLongPressed == true) && __pressedTokenIndex >= 0) + { + _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(__pressedTokenIndex)); + SysTryReturn(NID_UI_CTRL, pToken, Rectangle(), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Unable to get valid token."); + + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + int tokenTextLeftMargin = 0; + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); + + Rectangle textBounds(pToken->displayRect.x + tokenTextLeftMargin, pToken->displayRect.y, pToken->displayRect.width, pToken->displayRect.height); + return textBounds; + } + else + { + return _EditPresenter::GetTextBounds(); + } +} + +result +_TokenEditPresenter::CutText(void) +{ + if (__isEditingToken) + { + _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + SysTryReturnResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "A system error has occurred. The _Token instance is null"); + + pToken->isTextCut = true; + } + return _EditPresenter::CutText(); +} + +result +_TokenEditPresenter::SetLineSpacing(int linePixelGap) +{ + __lineSpacing = linePixelGap; + + return E_SUCCESS; +} + +int +_TokenEditPresenter::GetLineSpacing(void) const +{ + return __lineSpacing; +} + +VisualElementAnimation* +_TokenEditPresenter::CreateAnimationN(VisualElement& source, bool create) +{ + VisualElementAnimation* pAnimation = null; + VisualElementAnimationGroup* pAnimationGroup = new (std::nothrow) VisualElementAnimationGroup(); + SysTryReturn(NID_UI_CTRL, pAnimationGroup, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pAnimationGroup->SetDuration(ANIMATION_DURATION_BOUNDS); + if (__pTimingFunction == null) + { + __pTimingFunction = new (std::nothrow) SineTimingFunction(); + SysTryReturn(NID_UI_CTRL, __pTimingFunction, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + } + + if (pAnimationGroup != null) + { + VisualElementPropertyAnimation* pOpacityAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturn(NID_UI_CTRL, pOpacityAnimation, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pOpacityAnimation->SetPropertyName("opacity"); + if (!create) + { + pOpacityAnimation->SetStartValue(Variant(1.0f)); + pOpacityAnimation->SetEndValue(Variant(0.0f)); + } + else + { + pOpacityAnimation->SetStartValue(Variant(0.0f)); + pOpacityAnimation->SetEndValue(Variant(1.0f)); + } + + pOpacityAnimation->SetDuration(ANIMATION_DURATION_OPACITY); + pOpacityAnimation->SetTimingFunction(__pTimingFunction); + pAnimationGroup->AddAnimation(*pOpacityAnimation); + delete pOpacityAnimation; + + VisualElementPropertyAnimation* pBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation(); + SysTryReturn(NID_UI_CTRL, pBoundsAnimation, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + pBoundsAnimation->SetPropertyName("bounds"); + FloatRectangle startValue = source.GetBounds(); + startValue.x = startValue.x + startValue.width * 0.05; + startValue.y = startValue.y + startValue.height * 0.05; + startValue.width = startValue.width * 0.9; + startValue.height = startValue.height * 0.9; + + if (!create) + { + pBoundsAnimation->SetStartValue(Variant(source.GetBounds())); + pBoundsAnimation->SetEndValue(Variant(startValue)); + pBoundsAnimation->SetVisualElementAnimationStatusEventListener(this); + } + else + { + pBoundsAnimation->SetStartValue(Variant(startValue)); + pBoundsAnimation->SetEndValue(Variant(source.GetBounds())); + } + + pBoundsAnimation->SetDuration(ANIMATION_DURATION_BOUNDS); + pBoundsAnimation->SetTimingFunction(__pTimingFunction); + pAnimationGroup->AddAnimation(*pBoundsAnimation); + + delete pBoundsAnimation; + + pAnimation = pAnimationGroup; + } + return pAnimation; +} + +result +_TokenEditPresenter::CalculateDescriptionTextRect(const String& descriptionText) +{ + result r = E_SUCCESS; + + TextSimple* pSimpleText = null; + int tokenTopMargin = 0; + int tokenHeight = 0; + int tokenVerticalSpacing = 0; + int tokenTextLeftMargin = 0; + int tokenTextRightMargin = 0; + int tokenTitleWidth = 0; + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + + GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HEIGHT, orientation, tokenHeight); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenVerticalSpacing); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TITLE_RECT_WIDTH, orientation, tokenTitleWidth); + + int length = descriptionText.GetLength(); + Dimension textSize; + + wchar_t* pTempString = const_cast (descriptionText.GetPointer()); + + SysAssertf(__pDescriptionTextTextObject != null, "The TextObject instance is null."); + + __pDescriptionTextTextObject->RemoveAll(); + pSimpleText = new (std::nothrow)TextSimple(pTempString, length, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL); + __pDescriptionTextTextObject->AppendElement(*pSimpleText); + + textSize = __pDescriptionTextTextObject->GetTextExtent(0, length); + r = __pDescriptionTextTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + r = __pDescriptionTextTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + + __descriptionTextRect.x = tokenTextLeftMargin + __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_LEFT_MARGIN);; + __descriptionTextRect.y = tokenTopMargin + __pTokenEdit->GetVerticalMargin(EDIT_TEXT_TOP_MARGIN);; + if (textSize.width > tokenTitleWidth) + { + textSize.width = tokenTitleWidth; + __pDescriptionTextTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pDescriptionTextTextObject->SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL); + } + __descriptionTextRect.width = tokenTextLeftMargin + textSize.width + tokenTextRightMargin; + __descriptionTextRect.height = tokenHeight; + __pDescriptionTextTextObject->SetBounds(__descriptionTextRect); + + r = __pDescriptionTextTextObject->Compose(); + + return r; +} + +bool +_TokenEditPresenter::DrawDescriptionText(void) +{ + result r = E_SUCCESS; + Rectangle tempDescriptionTextRect; + Canvas* pDescriptionTextCanvas = null; + + Font* pDescriptionFont = null; + + if (__pDescriptionTextTextObject->GetFont(0)->GetFaceName() != GetTitleFontFaceName()) + { + int descriptionTextSize = 0; + GET_SHAPE_CONFIG(TOKENEDIT::DESCRIPTION_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, descriptionTextSize); + + pDescriptionFont = new (std::nothrow) Font(); + SysTryReturn(NID_UI_CTRL, pDescriptionFont != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pDescriptionFont->Construct(GetTitleFontFaceName(), FONT_STYLE_PLAIN, descriptionTextSize); + if (r != E_SUCCESS) + { + delete pDescriptionFont; + pDescriptionFont = null; + } + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pDescriptionTextTextObject->SetFont(pDescriptionFont, 0, __pDescriptionTextTextObject->GetTextLength()); + if (r != E_SUCCESS) + { + delete pDescriptionFont; + pDescriptionFont = null; + } + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete __pDescriptionTextFont; + __pDescriptionTextFont = null; + + __pDescriptionTextFont = pDescriptionFont; + } + + _VisualElement* pRootElement = __pTokenEdit->GetVisualElement(); + SysTryReturn(NID_UI_CTRL, pRootElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element."); + + if (__pDescriptionTextVisualElement) + { + __pDescriptionTextVisualElement->Destroy(); + __pDescriptionTextVisualElement = null; + } + __pDescriptionTextVisualElement = new (std::nothrow) _VisualElement(); + SysTryReturn(NID_UI_CTRL, __pDescriptionTextVisualElement, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + r = __pDescriptionTextVisualElement->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[E_SYSTEM] A system error has occurred. Failed to construct _VisualElement"); + __pDescriptionTextVisualElement->SetImplicitAnimationEnabled(false); + __pDescriptionTextVisualElement->SetBounds(FloatRectangle(__descriptionTextRect.x, __descriptionTextRect.y, __descriptionTextRect.width, __descriptionTextRect.height)); // TBD. + __pDescriptionTextVisualElement->SetShowState(true); + + r = pRootElement->AttachChild(*__pDescriptionTextVisualElement); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pDescriptionTextCanvas = __pDescriptionTextVisualElement->GetCanvasN(); + if (pDescriptionTextCanvas == null) + { + SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Failed to get canvas of an instance of _VisualElement."); + return true; + } + + tempDescriptionTextRect = __descriptionTextRect; + tempDescriptionTextRect.x = 0; + tempDescriptionTextRect.y = 0; + + __pDescriptionTextTextObject->SetForegroundColor(__pTokenEdit->GetTitleTextColor(GetCurrentStatus()), 0, __pDescriptionTextTextObject->GetTextLength()); + + pDescriptionTextCanvas->FillRectangle(__pTokenEdit->GetColor(GetCurrentStatus()), tempDescriptionTextRect); + __pDescriptionTextTextObject->SetBounds(tempDescriptionTextRect); + __pDescriptionTextTextObject->Compose(); + __pDescriptionTextTextObject->Draw(*_CanvasImpl::GetInstance(*pDescriptionTextCanvas)); + __pDescriptionTextVisualElement->SetFlushNeeded(); + + delete pDescriptionTextCanvas; + + return true; +CATCH: + __pDescriptionTextVisualElement->Destroy(); + __pDescriptionTextVisualElement = null; + + return false; +} + +result +_TokenEditPresenter::TrimTokenAndAdjustEllipsisAt(int index) +{ + result r = E_SUCCESS; + + int tokenTextRightMargin = 0; + int tokenMinimumSize = 0; + + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_MIN_WIDTH, orientation, tokenMinimumSize); + + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(index)); + SysTryReturn(NID_UI_CTRL, pToken, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null"); + + Rectangle tokenEditBounds = __pTokenEdit->GetBounds(); + Rectangle tokenRect = pToken->displayRect; + + int remainWidth = tokenEditBounds.width - tokenTextRightMargin - __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN);; + int dspTokenWidth = tokenRect.x + tokenRect.width; + int dspTokenGap = dspTokenWidth - remainWidth; + + if (dspTokenGap > 0) + { + if (pToken->displayRect.width >= tokenMinimumSize) + { + if ((pToken->displayRect.width - dspTokenGap) < tokenMinimumSize) + { + pToken->displayRect.width = tokenMinimumSize; + } + else + { + pToken->displayRect.width -= dspTokenGap; + } + } + + // Adjust ellipsis + pToken->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + pToken->pTextObject->SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL); + } + + return r; +} + +int +_TokenEditPresenter::GetTokenIndexFromCoordinate(const Point point) const +{ + int tokenIndex = -1; + + int tokenCount = __pTokenList->GetCount(); + for (int i = 0; i < tokenCount; i++) + { + _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + if (pToken) + { + Rectangle tokenRect = pToken->displayRect; + if (tokenRect.Contains(point)) + { + tokenIndex = i; + break; + } + } + } + return tokenIndex; +} + +result +_TokenEditPresenter::SetEditingTokenTextBounds(int index, bool isSetText) +{ + result r = E_SUCCESS; + + int tokenHeight = 0; + int tokenVerticalSpacing = 0; + int tokenTextLeftMargin = 0; + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HEIGHT, orientation, tokenHeight); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenVerticalSpacing); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); + + _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(index)); + SysTryReturnResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "A system error has occurred. The _Token instance is null"); + + Rectangle tempTextDspRect; + tempTextDspRect.x += tokenTextLeftMargin; + tempTextDspRect.y += tokenVerticalSpacing / 2; + tempTextDspRect.width = pToken->GetTextPixelWidth(); + tempTextDspRect.height = tokenHeight; + + if (isSetText) + { + if (!pToken->isTextCut) + { + SetText(pToken->GetText()); + } + pToken->pTextObject->RemoveAll(); + } + + SetTextBounds(tempTextDspRect); + + return r; +} + +result +_TokenEditPresenter::RecalculateTokenBounds(int position) +{ + result r = E_SUCCESS; + + __scrollValue = -position; + + int tokenCount = GetTokenCount(); + CalculateTokenPositionFromIndex(0); + + for (int i = 0; i < tokenCount; i++) + { + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + + if (pToken) + { + pToken->SetBounds(pToken->displayRect); + } + TrimTokenAndAdjustEllipsisAt(i); + InitializeTokenVisibilityAt(i); + } + + if (__pDescriptionTextTextObject->GetTextLength() != 0) + { + __descriptionTextRect.y = __descriptionTextRectForScroll.y + __scrollValue; + } + + __pTokenEdit->Draw(); + __pTokenEdit->Show(); + + r = SetInitialBounds(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds."); + + return r; +} + +result +_TokenEditPresenter::SetTokenBoundsByTouchInfo(const _TouchInfo& touchinfo) +{ + result r = E_SUCCESS; + int currentYPosition = touchinfo.GetCurrentPosition().y; + + if (__prevScrollValue == 0) + { + __prevScrollValue = currentYPosition; + } + else // Adjust moved y position to all tokens. + { + if (__isNeedToScroll) // Need to scroll + { + int tempDefference = __prevScrollValue - currentYPosition; + + __prevScrollValue = currentYPosition; + __scrollValue -= tempDefference; + + if (__scrollValue < -__maxScrollValue) + { + __scrollValue = -__maxScrollValue; + + return E_SUCCESS; + } + + if (__scrollValue > 0) + { + __scrollValue = 0; + + return E_SUCCESS; + } + + int tokenCount = GetTokenCount(); + CalculateTokenPositionFromIndex(0); + for (int i = 0; i < tokenCount; i++) + { + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + + if (pToken) + { + pToken->SetBounds(pToken->displayRect); + } + TrimTokenAndAdjustEllipsisAt(i); + InitializeTokenVisibilityAt(i); + } + + if (__pDescriptionTextTextObject->GetTextLength() != 0) + { + __descriptionTextRect.y = __descriptionTextRectForScroll.y + __scrollValue; + } + + __pTokenEdit->Draw(); + __pTokenEdit->Show(); + } + else + { + __prevScrollValue = 0; + __scrollValue = 0; + } + } + + r = SetInitialBounds(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds."); + + return r; +} + +result +_TokenEditPresenter::ProcessTokeningByTouchEvent(const _Control& source, const _TouchInfo& touchinfo) +{ + int tokenIndex = GetTokenIndexFromCoordinate(touchinfo.GetCurrentPosition()); + int prevPressedTokenIndex = __pressedTokenIndex; + + result r = E_SUCCESS; + if (IsFocused()) + { + if (__isEditModeEnabled && __pressedTokenIndex != -1 && __pressedTokenIndex == tokenIndex) + { + /*__edittingTokenIndex = __pressedTokenIndex; + __isEditingToken = true; + SetEditingTokenTextBounds(__edittingTokenIndex); + SetCursorDisabled(false);*/ + } + __pressedTokenIndex = tokenIndex; + } + + if (__pressedTokenIndex != -1) + { + if (__isEditingToken && (prevPressedTokenIndex != __pressedTokenIndex)) // Selected another token while editing. + { + __isPopupVisible = false; + __isLongPressed = false; + + _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pEditVisualElement, E_SYSTEM, "A system error has occurred. Failed to get root visual element."); + + _VisualElement* pCursorVisualElement = GetCursorVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pCursorVisualElement, E_SYSTEM, "A system error has occurred. Failed to get cursor visual element."); + + _Token* pToken = null; + _VisualElement* pTokenVisualElement = null; + + pToken = static_cast <_Token*>(__pTokenList->GetAt(prevPressedTokenIndex)); + + bool isParentChanged = false; + if (pToken) + { + pTokenVisualElement = pToken->GetVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pTokenVisualElement, E_SYSTEM, "A system error has occurred. Failed to get token visual element."); + + if (pCursorVisualElement->GetParent() == pTokenVisualElement) + { + isParentChanged = true; + result r = E_SUCCESS; + r = pTokenVisualElement->DetachChild(*pCursorVisualElement); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pEditVisualElement->AttachChild(*pCursorVisualElement); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + + r = RemoveTokenAt(prevPressedTokenIndex); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + if (GetText().GetLength() > 0) + { + r = InsertTokenAt(prevPressedTokenIndex, GetText()); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + pToken = static_cast <_Token*>(__pTokenList->GetAt(prevPressedTokenIndex)); + if (pToken) + { + pToken->currTokenLength = GetText().GetLength(); + } + } + + __edittingTokenIndex = -1; + __isTokenEditingFinished = true; + __isEditingToken = false; + SetCursorDisabled(true); + } + else + { + if (GetText().GetLength() > 0 && __pressedTokenIndex != prevPressedTokenIndex) + { + r = MakeToken(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + + if ((__isEditingToken == true) && (__pressedTokenIndex != -1)) + { + _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pEditVisualElement, E_SYSTEM, "A system error has occurred. Failed to get root visual element."); + + _VisualElement* pCursorVisualElement = GetCursorVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pCursorVisualElement, E_SYSTEM, "A system error has occurred. Failed to get cursor visual element."); + + _Token* pToken = null; + _VisualElement* pTokenVisualElement = null; + + pToken = static_cast <_Token*>(__pTokenList->GetAt(__pressedTokenIndex)); + + bool isParentChanged = false; + if (pToken) + { + pTokenVisualElement = pToken->GetVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pTokenVisualElement, E_SYSTEM, "A system error has occurred. Failed to get token visual element."); + + if (pCursorVisualElement->GetParent() != pTokenVisualElement) + { + isParentChanged = true; + result r = E_SUCCESS; + r = (pCursorVisualElement->GetParent())->DetachChild(*pCursorVisualElement); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pTokenVisualElement->AttachChild(*pCursorVisualElement); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + } + + if (__isEditingToken == false) + { + SetCursorDisabled(true); + } + } + } + else + { + __isPopupVisible = false; + __isLongPressed = false; + + _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pEditVisualElement, E_SYSTEM, "A system error has occurred. Failed to get root visual element."); + + _VisualElement* pCursorVisualElement = GetCursorVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pCursorVisualElement, E_SYSTEM, "A system error has occurred. Failed to get cursor visual element."); + + if (__isEditingToken) + { + _Token* pToken = null; + _VisualElement* pTokenVisualElement = null; + + pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + + bool isParentChanged = false; + if (pToken) + { + pTokenVisualElement = pToken->GetVisualElement(); + SysTryReturnResult(NID_UI_CTRL, pTokenVisualElement, E_SYSTEM, "A system error has occurred. Failed to get token visual element."); + + if (pCursorVisualElement->GetParent() == pTokenVisualElement) + { + isParentChanged = true; + result r = E_SUCCESS; + r = pTokenVisualElement->DetachChild(*pCursorVisualElement); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pEditVisualElement->AttachChild(*pCursorVisualElement); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + + String inputTokenString = GetText(); + String replacementString = inputTokenString; + bool enable = false; + + __pTokenEdit->ProcessTokenFiltering(inputTokenString, replacementString, enable); + if (enable) + { + inputTokenString = replacementString; + } + + RemoveTokenAt(__edittingTokenIndex); + + if (inputTokenString.GetLength() > 0) + { + InsertTokenAt(__edittingTokenIndex, inputTokenString); + + if (isParentChanged) + { + pToken->currTokenLength = inputTokenString.GetLength(); + } + __isTokenEditingFinished = true; + __isEditingToken = false; + __edittingTokenIndex = -1; + } + else + { + __isTokenEditingFinished = true; + __isEditingToken = false; + __edittingTokenIndex = -1; + + SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument is used. Token length is (%d)", inputTokenString.GetLength()); + return E_INVALID_ARG; + } + + DrawText(); + } + else + { + if (pCursorVisualElement->GetParent() != pEditVisualElement) + { + r = (pCursorVisualElement->GetParent())->DetachChild(*pCursorVisualElement); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + + r = pEditVisualElement->AttachChild(*pCursorVisualElement); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating."); + } + } + + SetCursorDisabled(false); + } + + for (int i = 0; i < __pTokenList->GetCount(); i++) + { + TrimTokenAndAdjustEllipsisAt(i); + InitializeTokenVisibilityAt(i); + } + + return E_SUCCESS; +} + +result +_TokenEditPresenter::CheckTokenScrolling(bool scrollToCursorPosition) +{ + bool needToScroll = false; + int tokenTopMargin = 0; + int tokenBottomMargin = 0; + int tokenVerticalSpacing = 0; + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + + GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin); + GET_SHAPE_CONFIG(TOKENEDIT::BOTTOM_MARGIN, orientation, tokenBottomMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenVerticalSpacing); + + int tokenCount = GetTokenCount(); + if (tokenCount == 0) // There is no token to scroll + { + __isNeedToScroll = false; + __maxScrollValue = 0; + __isTokenScrolling = false; + + return E_SUCCESS; + } + + _Token* pToken = static_cast<_Token*>(__pTokenList->GetAt(tokenCount - 1)); + SysTryReturn(NID_UI_CTRL, pToken, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + int newScrollValue = 0; + + if (scrollToCursorPosition) + { + Rectangle cursorBounds; + GetCursorBounds(false, cursorBounds); + newScrollValue = cursorBounds.y + cursorBounds.height - __scrollValue + tokenBottomMargin - __pTokenEdit->GetBounds().height; + __isScrollValueModified = true; + } + else + { + newScrollValue = GetTextBounds().y + GetTextBounds().height - __scrollValue + tokenBottomMargin - __pTokenEdit->GetBounds().height; + __isScrollValueModified = true; + } + + needToScroll = (newScrollValue > 0) ? (true) : (false); + + __isNeedToScroll = needToScroll; + + if (__isNeedToScroll) + { + __maxScrollValue = newScrollValue; + __isTokenScrolling = true; + + RecalculateTokenBounds(__maxScrollValue); + } + else + { + if (__scrollValue != 0) + { + __scrollValue = 0; + __maxScrollValue = 0; // To prevent unnecessary token scrolling. + RecalculateTokenBounds(__scrollValue); + __isTokenScrolling = false; + } + } + + return E_SUCCESS; +} + +result +_TokenEditPresenter::SetTokenVisualElementBounds(int index, const Rectangle& bounds) +{ + _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(index)); + SysTryReturnResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "A system error has occurred. The _Token instance is null."); + + return pToken->SetBounds(pToken->displayRect); +} + +result +_TokenEditPresenter::AdjustFlexibleHeight(void) +{ + result r = E_SUCCESS; + + Rectangle editRect = __pTokenEdit->GetBounds(); + Rectangle displayScrollBounds = GetDisplayScrollBounds(); + int calcHeight = CalculateFlexibleHeight(); + + if (editRect.height != calcHeight) + { + displayScrollBounds.height = calcHeight; + SetScrollBarBounds(displayScrollBounds); + + editRect.height = calcHeight; + if (!__isEditingToken) + { + r = SetFlexBounds(editRect); + } + } + + return r; +} + +int +_TokenEditPresenter::CalculateFlexibleHeight(void) +{ + int tokenHeight = 0; + int tokenVerticalSpacing = 0; + int tokenTopMargin =0; + int tokenBottomMargin = 0; + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HEIGHT, orientation, tokenHeight); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenVerticalSpacing); + GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin); + GET_SHAPE_CONFIG(TOKENEDIT::BOTTOM_MARGIN, orientation, tokenBottomMargin); + + int height = 0; + int maxLinecount = GetMaxLineCount(); + int expectedEditHeight = GetTextBounds().y + GetTextBounds().height - __scrollValue + tokenBottomMargin; + int initialHeight = GetInitialBounds().height; + int maximumLineHeight = tokenTopMargin + maxLinecount * tokenHeight + tokenVerticalSpacing * (maxLinecount - 1) + tokenBottomMargin; + + if (initialHeight < expectedEditHeight) + { + if (expectedEditHeight > maximumLineHeight) + { + height = maximumLineHeight; + } + else + { + height = expectedEditHeight; + } + } + else + { + height = initialHeight; + } + + return height; +} + +result +_TokenEditPresenter::DrawScrollBar(void) +{ + result r = E_SUCCESS; + + _Scroll* pScroll = GetScrollBar(); + if (pScroll == null) + { + return E_SYSTEM; + } + + if (IsFocused() == false) + { + pScroll->SetScrollVisibility(false); + return E_SUCCESS; + } + + _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(GetTokenCount() - 1)); + if (pToken == null) + { + return E_SUCCESS; + } + + int tokenBottomMargin = 0; + GET_SHAPE_CONFIG(TOKENEDIT::BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, tokenBottomMargin); + + int totalHeight = GetTextBounds().y + GetTextBounds().height - __scrollValue + tokenBottomMargin; + int dspHeight = __pTokenEdit->GetBounds().height; + int firstDspY = -__scrollValue; + + if (totalHeight <= dspHeight) + { + pScroll->SetScrollVisibility(false); + pScroll->SetScrollRange(1, 1); + pScroll->SetScrollPosition(0); + + SetScrollBarVisible(false); + SetPreviousScrollBarPosition(0); + SetMaximumPreviousScrollBarPosition(0); + } + else + { + pScroll->SetScrollVisibility(true); +// if (_pScroll->IsVisible()) +// { + if (firstDspY > 0) + { + pScroll->SetScrollRange(dspHeight, totalHeight); + pScroll->SetScrollPosition(firstDspY); + + SetScrollBarVisible(true); + SetMaximumPreviousScrollBarPosition(totalHeight - dspHeight); + } + else + { + pScroll->SetScrollRange(dspHeight, totalHeight); + pScroll->SetScrollPosition(0); + + SetScrollBarVisible(true); + SetMaximumPreviousScrollBarPosition(0); + } + + SetScrollBarVisible(true); +// } + + SetPreviousScrollBarPosition(firstDspY); + } + + return r; +} + +void +_TokenEditPresenter::SetAutoShrinkModeEnabled(bool enable) +{ + __autoShrink = enable; +} + +bool +_TokenEditPresenter::IsAutoShrinkModeEnabled(void) const +{ + return __autoShrink; +} + +void +_TokenEditPresenter::SetDescriptionText(String descriptionText) +{ + __descriptionText = descriptionText; +} + +String +_TokenEditPresenter::GetDescriptionText(void) const +{ + return __descriptionText; +} + +int +_TokenEditPresenter::CalculateVisibleTokenCount(void) +{ + int visibleTokenCount = 0; + + Rectangle intialBounds = GetInitialBounds(); + Rectangle tempInitialBounds = intialBounds; + Rectangle hiddenTokenDisplayBounds; + int tokenCount = GetTokenCount(); + + for (int i = 0; i < tokenCount; i++) + { + tempInitialBounds = intialBounds; + + hiddenTokenDisplayBounds = CalculateHiddenTokenCountDisplayBounds(tokenCount - i - 1); + tempInitialBounds.width -= hiddenTokenDisplayBounds.width; + + Point leftTop(hiddenTokenDisplayBounds.x, hiddenTokenDisplayBounds.y); + Point rightBottom(hiddenTokenDisplayBounds.x + hiddenTokenDisplayBounds.width, hiddenTokenDisplayBounds.y + hiddenTokenDisplayBounds.height); + + if (tempInitialBounds.Contains(leftTop) == false || tempInitialBounds.Contains(rightBottom) == false) + { + break; + } + visibleTokenCount++; + } + return visibleTokenCount; +} + +Rectangle +_TokenEditPresenter::CalculateHiddenTokenCountDisplayBounds(int hiddenTokenCount) +{ + result r = E_SUCCESS; + Rectangle displayBounds; + + int textSize = 0; + int margin = 0; + int height = 0; + int horizontalSpace = 0; + Dimension textDim; + TextSimple* pSimpleText = null; + Font* pFont = null; + + GET_SHAPE_CONFIG(TOKENEDIT::HIDDEN_TOKEN_COUNT_DISPLAY_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, textSize); + GET_SHAPE_CONFIG(TOKENEDIT::HIDDEN_TOKEN_COUNT_DISPLAY_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, margin); + GET_SHAPE_CONFIG(TOKENEDIT::HIDDEN_TOKEN_COUNT_DISPLAY_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, height); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HORIZONTAL_SPACING, _CONTROL_ORIENTATION_PORTRAIT, horizontalSpace); + + int tokenIndex = GetTokenCount() - hiddenTokenCount - 1; + _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(tokenIndex)); + SysTryReturn(NID_UI_CTRL, pToken != null && pToken->pTextObject != null, Rectangle(), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + displayBounds.x = pToken->displayRect.x + pToken->displayRect.width + margin; + displayBounds.y = pToken->displayRect.y; + displayBounds.height = height; + + String hiddenTokenCountString("+"); + hiddenTokenCountString.Append(hiddenTokenCount); + + int length = hiddenTokenCountString.GetLength(); + wchar_t* pTempString = const_cast (hiddenTokenCountString.GetPointer()); + + if (__pHiddenTokenCountTextObject) + { + delete __pHiddenTokenCountTextObject; + __pHiddenTokenCountTextObject = null; + } + + __pHiddenTokenCountTextObject = new (std::nothrow) TextObject; + SysTryReturn(NID_UI_CTRL, __pHiddenTokenCountTextObject != null, Rectangle(), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = __pHiddenTokenCountTextObject->Construct(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pSimpleText = new (std::nothrow) TextSimple(pTempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_UI_CTRL, pSimpleText != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pHiddenTokenCountTextObject->AppendElement(*pSimpleText); + __pHiddenTokenCountTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __pHiddenTokenCountTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + + pFont = new (std::nothrow) Font; + SysTryCatch(NID_UI_CTRL, pFont != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + r = pFont->Construct(FONT_STYLE_PLAIN, textSize); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pHiddenTokenCountTextObject->SetFont(pFont, 0, __pHiddenTokenCountTextObject->GetTextLength()); + + textDim = __pHiddenTokenCountTextObject->GetTextExtent(0, length); + displayBounds.width = margin + textDim.width + margin; + + delete pFont; + pFont = null; + + return displayBounds; + +CATCH: + + delete __pHiddenTokenCountTextObject; + __pHiddenTokenCountTextObject = null; + + delete pSimpleText; + pSimpleText = null; + + delete pFont; + pFont = null; + + return Rectangle(); +} + +int +_TokenEditPresenter::CalculateAutoShrinkAlignmentValue(int visibleTokenCount) const +{ + int value = 0; + + _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(visibleTokenCount - 1)); + SysTryReturn(NID_UI_CTRL, pToken != null && pToken->pTextObject != null, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null"); + + value = pToken->displayRect.y; + + pToken = static_cast <_Token*>(__pTokenList->GetAt(0)); + SysTryReturn(NID_UI_CTRL, pToken != null && pToken->pTextObject != null, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + value = pToken->displayRect.y + pToken->displayRect.height - value; + + int initialHeight = GetInitialBounds().height; + + value = (initialHeight - value) / 2; + + int topMargin = 0; + GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, topMargin); + + value -= topMargin; + + if (value < 0) + { + value = 0; + } + + return value; +} + +result +_TokenEditPresenter::DrawHiddenTokenCount(void) +{ + result r = E_SUCCESS; + + if (__pHiddenTokenCountVisualElement) + { + Canvas* pHiddenTokenCountCanvas = __pHiddenTokenCountVisualElement->GetCanvasN(); + + if (pHiddenTokenCountCanvas) + { + __pHiddenTokenCountTextObject->SetForegroundColor(Color::GetColor(COLOR_ID_WHITE), 0, __pHiddenTokenCountTextObject->GetTextLength()); + __pHiddenTokenCountTextObject->Compose(); + __pHiddenTokenCountTextObject->SetBounds(__hiddenTokenDisplayCountBounds); + __pHiddenTokenCountTextObject->Draw(*_CanvasImpl::GetInstance(*pHiddenTokenCountCanvas)); + + delete pHiddenTokenCountCanvas; + pHiddenTokenCountCanvas = null; + } + + __pHiddenTokenCountVisualElement->SetFlushNeeded(); + } + + return r; +} + +bool +_TokenEditPresenter::OnFocusGained(void) +{ + if (__autoShrink) + { + int tempHeight = CalculateFlexibleHeight(); + Rectangle tempRect = GetInitialBounds(); + tempRect.height = tempHeight; + + _Token* pToken = null; + int tokenCount = GetTokenCount(); + + for (int i = 0; i < tokenCount; i++) + { + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + + if (pToken) + { + _VisualElement* pTokenVisualElement = pToken->GetVisualElement(); + if (pTokenVisualElement) + { + pTokenVisualElement->SetShowState(true); + } + } + } + + if (__autoShrink) + { + _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); + SysTryReturn(NID_UI_CTRL, pEditVisualElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element."); + + if (__pHiddenTokenCountVisualElement) + { + pEditVisualElement->DetachChild(*__pHiddenTokenCountVisualElement); + __pHiddenTokenCountVisualElement->Destroy(); + __pHiddenTokenCountVisualElement = null; + } + + __scrollValue = -__autoShrinkAlignmentValue; + __autoShrinkAlignmentValue = 0; + CalculateTokenPositionFromIndex(0); + } + + SetFlexBounds(tempRect); + + SetEditingTokenTextBounds(__edittingTokenIndex, false); + + if (!__isFocus) + { + __descriptionTextRect.y = __descriptionTextRectForScroll.y + __scrollValue; + __isFocus = true; + } + + if (__isScrollValueChanged && !__isScrollValueModified) + { + __maxScrollValue = __maxScrollValue - (__pTokenEdit->GetBounds().height - GetInitialBounds().height); + __isScrollValueChanged = false; + } + } + return _EditPresenter::OnFocusGained(); +} + +bool +_TokenEditPresenter::OnFocusLost(void) +{ + result r = E_SUCCESS; + + __isFocus = false; + + if (__edittingTokenIndex >= 0) + { + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + if (pToken) + { + if (GetText().GetLength() > 0) + { + OnTextCommitted(L"\n"); + } + } + } + else + { + if (GetText().GetLength() > 0) + { + OnTextCommitted(L"\n"); + } + } + + if (__autoShrink) + { + _Scroll* pScroll = GetScrollBar(); + if (pScroll) + { + pScroll->SetScrollVisibility(false); + } + __scrollValue = 0; + + int tokenCount = GetTokenCount(); + _Token* pToken = null; + for (int i = 0; i < tokenCount; i++) + { + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + if (pToken) + { + pToken->SetBounds(pToken->displayRect); + } + } + + r = SetInitialBounds(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating", GetErrorMessage(r)); + + int visibleTokenCount = CalculateVisibleTokenCount(); + __hiddenTokenDisplayCountBounds = CalculateHiddenTokenCountDisplayBounds(tokenCount - visibleTokenCount); + + __autoShrinkAlignmentValue = CalculateAutoShrinkAlignmentValue(visibleTokenCount); + + if (visibleTokenCount > 0) + { + _Token* pToken = null; + for (int i = visibleTokenCount; i < tokenCount; i++) + { + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + if (pToken) + { + _VisualElement* pTokenVisualElement = pToken->GetVisualElement(); + if (pTokenVisualElement) + { + pTokenVisualElement->SetShowState(false); + } + } + } + + _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); + SysTryReturn(NID_UI_CTRL, pEditVisualElement != null, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element."); + + if (__pHiddenTokenCountVisualElement) + { + pEditVisualElement->DetachChild(*__pHiddenTokenCountVisualElement); + __pHiddenTokenCountVisualElement->Destroy(); + __pHiddenTokenCountVisualElement = null; + } + + __pHiddenTokenCountVisualElement = new (std::nothrow) _VisualElement; + if (__pHiddenTokenCountVisualElement) + { + r = __pHiddenTokenCountVisualElement->Construct(); + __pHiddenTokenCountVisualElement->SetShowState(true); + // Draw hidden token count + __pHiddenTokenCountVisualElement->SetBounds(FloatRectangle(__hiddenTokenDisplayCountBounds.x, + __hiddenTokenDisplayCountBounds.y, __hiddenTokenDisplayCountBounds.width, __hiddenTokenDisplayCountBounds.height)); + + pEditVisualElement->AttachChild(*__pHiddenTokenCountVisualElement); + } + } + + __scrollValue = __autoShrinkAlignmentValue; + r = CalculateTokenPositionFromIndex(0); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r)); + + int totalScrollValue = __maxScrollValue + (__pTokenEdit->GetBounds().height - GetInitialBounds().height); + + if (totalScrollValue > 0) + { + __isNeedToScroll = true; + __maxScrollValue = totalScrollValue; + __isTokenScrolling = true; + if (__lineAdded > 0) + { + __isScrollValueChanged = true; + __isScrollValueModified = false; + } + } + + Rectangle intialWindowBounds = GetInitialBounds(); + SetFlexBounds(intialWindowBounds); + + SetEditingTokenTextBounds(__edittingTokenIndex, false); + + __descriptionTextRect.y = __descriptionTextRectForScroll.y + __scrollValue; + } + + return _EditPresenter::OnFocusLost(); +} + +result +_TokenEditPresenter::SetFlexBounds(const Rectangle& bounds) +{ + if (__pTokenEdit->GetBounds().height > bounds.height) + { + if (__lineAdded > 0) + { + __lineAdded--; + } + } + return _EditPresenter::SetFlexBounds(bounds); +} + +bool +_TokenEditPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + int tokenIndex = GetTokenIndexFromCoordinate(touchinfo.GetCurrentPosition()); + + if (tokenIndex != -1) + { + return false; + } + + return _EditPresenter::OnTouchPressed(source, touchinfo); +} + +bool +_TokenEditPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + ProcessTokeningByTouchEvent(source, touchinfo); + + if (__prevScrollValue) + { + __prevScrollValue = 0; + __isTokenScrolling = false; + } + + _TouchInfo TouchInfo(touchinfo); + _Token* pToken = null; + if (__edittingTokenIndex >= 0) + { + pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + if (pToken) + { + Point point(touchinfo.GetCurrentPosition().x - pToken->displayRect.x, touchinfo.GetCurrentPosition().y - pToken->displayRect.y); + TouchInfo.SetTouchInfo(touchinfo.GetPointId(), touchinfo.GetTouchStatus(), point, touchinfo.IsFlicked(), touchinfo.GetTimeStamp()); + } + _EditPresenter::OnTouchReleased(source, TouchInfo); + __previousCursorPosition = GetCursorPosition(); + } + else + { + _EditPresenter::OnTouchReleased(source, touchinfo); + } + + return false; +} + +void +_TokenEditPresenter::OnInputConnectionTextCommitted(InputConnection& source, const String& committedText) +{ + OnTextCommitted(committedText); +} + +void +_TokenEditPresenter::OnTextCommitted(const String& commitText) +{ + result r = E_SUCCESS; + char enterText[2] = {'\n', }; + if (commitText == enterText) + { + if (__edittingTokenIndex != -1) + { + _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pEditVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element."); + + _VisualElement* pCursorVisualElement = GetCursorVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pCursorVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get cursor visual element."); + + _Token* pToken = null; + _VisualElement* pTokenVisualElement = null; + + pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + + if (pToken) + { + pTokenVisualElement = pToken->GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pTokenVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get token visual element."); + + if (pCursorVisualElement->GetParent() != pEditVisualElement) + { + r = pCursorVisualElement->GetParent()->DetachChild(*pCursorVisualElement); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + + r = pEditVisualElement->AttachChild(*pCursorVisualElement); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + String inputTokenString = GetText(); + String replacementString = inputTokenString; + bool enable = false; + + __pTokenEdit->ProcessTokenFiltering(inputTokenString, replacementString, enable); + if (enable) + { + inputTokenString = replacementString; + } + + r = RemoveTokenAt(__edittingTokenIndex); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (inputTokenString.GetLength() > 0) + { + r = InsertTokenAt(__edittingTokenIndex, inputTokenString); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + SysTryReturnVoidResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + pToken->currTokenLength = inputTokenString.GetLength(); + } + + CalculateTokenPositionFromIndex(0); + int lastTokenIndex = GetTokenCount() - 1; + for (int i = 0; i < lastTokenIndex + 1; i++) + { + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + + if (pToken) + { + pToken->SetBounds(pToken->displayRect); + } + } + + __pressedTokenIndex = -1; + __isTokenEditingFinished = true; + __edittingTokenIndex = -1; + __isEditingToken = false; + + SetCursorDisabled(false); + + if (inputTokenString.GetLength() <= 0) + { + SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument is used. Token length is (%d)", inputTokenString.GetLength()); + return; + } + + } + + if (GetText().GetLength() > 0) + { + MakeToken(); + } + + for (int i = 0; i < __pTokenList->GetCount(); i++) + { + TrimTokenAndAdjustEllipsisAt(i); + InitializeTokenVisibilityAt(i); + } + + SetCursorDisabled(true); + __pTokenEdit->Draw(); + SetCursorDisabled(false); + StartCursorTimer(); + + return; + } + + _EditPresenter::OnTextCommitted(commitText); + __previousCursorPosition = GetCursorPosition(); + + _Token* pToken = null; + if (__edittingTokenIndex >= 0) + { + pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + SysTryReturnVoidResult(NID_UI_CTRL, pToken, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null"); + + pToken->ResetToken(GetText()); + TrimTokenAndAdjustEllipsisAt(__edittingTokenIndex); + + int tokenHeight = 0; + int tokenVerticalSpacing = 0; + int tokenTextLeftMargin = 0; + + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HEIGHT, orientation, tokenHeight); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenVerticalSpacing); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); + + Rectangle tempTextDspRect; + tempTextDspRect.x += tokenTextLeftMargin; + tempTextDspRect.y += tokenVerticalSpacing / 2; + tempTextDspRect.width = pToken->GetTextPixelWidth(); + tempTextDspRect.height = tokenHeight; + + if (pToken->GetTextPixelWidth() > (pToken->displayRect.width - tokenTextLeftMargin - 20)) + { + tempTextDspRect.width = pToken->displayRect.width - tokenTextLeftMargin - 20; + } + SetTextBounds(tempTextDspRect); + + if (GetCursorPosition() > pToken->currTokenLength) + { + _EditPresenter::SetCursorPosition(pToken->currTokenLength); + } + else + { + _EditPresenter::SetCursorPosition(GetCursorPosition()); + } + } + else + { + if (__isEditingToken == false) + { + __pressedTokenIndex = -1; + SetCursorDisabled(false); + } + + int tokenTopMargin = 0; + + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + GET_SHAPE_CONFIG(TOKENEDIT::TOP_MARGIN, orientation, tokenTopMargin); + + Rectangle textBounds = GetTextBounds(); + textBounds.height = __pTokenEdit->GetTextSize() + (2 * tokenTopMargin); + + SetTextBounds(textBounds); + } + + CheckTokenScrolling(true); + __pTokenEdit->Draw(); + + return; +} + +void +_TokenEditPresenter::DeleteSurroundingText(InputConnection& source, int offset, int charCount) +{ + OnSurroundingTextDeleted(offset, charCount); +} + +void +_TokenEditPresenter::OnSurroundingTextDeleted(int offset, int charCount) +{ + __lastTokenIndex = GetTokenCount() - 1; + int cursorPosition = 0; + int start = 0; + int end = 0; + + if ((offset == -1) && (charCount == 1)) + { + if (GetTextLength() == 0 && GetTokenCount()) // There is no candidate token. + { + if (__isEditingToken == true) + { + _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pEditVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element."); + + _VisualElement* pCursorVisualElement = GetCursorVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pCursorVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get cursor visual element."); + + _Token* pToken = null; + _VisualElement* pTokenVisualElement = null; + + pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + + if (pToken) + { + pTokenVisualElement = pToken->GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pTokenVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get token visual element."); + + if (pCursorVisualElement->GetParent() != pEditVisualElement) + { + result r = E_SUCCESS; + r = pCursorVisualElement->GetParent()->DetachChild(*pCursorVisualElement); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating", GetErrorMessage(r)); + + r = pEditVisualElement->AttachChild(*pCursorVisualElement); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating", GetErrorMessage(r)); + } + } + + RemoveTokenAt(__edittingTokenIndex); + + CalculateTokenPositionFromIndex(__edittingTokenIndex); + for (int i = __edittingTokenIndex; i < __lastTokenIndex + 1; i++) + { + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + if (pToken) + { + pToken->SetBounds(pToken->displayRect); + } + } + + __pressedTokenIndex = -1; + __edittingTokenIndex = -1; + __isEditingToken = false; + __isTokenEditingFinished = true; + } + else if (__pressedTokenIndex != -1) + { + _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pEditVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element."); + + _VisualElement* pCursorVisualElement = GetCursorVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pCursorVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get cursor visual element."); + + _Token* pToken = null; + _VisualElement* pTokenVisualElement = null; + + pToken = static_cast <_Token*>(__pTokenList->GetAt(__pressedTokenIndex)); + + if (pToken) + { + pTokenVisualElement = pToken->GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pTokenVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get token visual element."); + + if (pCursorVisualElement->GetParent() != pEditVisualElement) + { + result r = E_SUCCESS; + r = pCursorVisualElement->GetParent()->DetachChild(*pCursorVisualElement); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating", GetErrorMessage(r)); + + r = pEditVisualElement->AttachChild(*pCursorVisualElement); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating", GetErrorMessage(r)); + } + } + + RemoveTokenAt(__pressedTokenIndex); + + CalculateTokenPositionFromIndex(__pressedTokenIndex); + for (int i = __pressedTokenIndex; i < __lastTokenIndex + 1; i++) + { + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + + if (pToken) + { + pToken->SetBounds(pToken->displayRect); + } + } + } + else + { + _VisualElement* pEditVisualElement = __pTokenEdit->GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pEditVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get root visual element."); + + _VisualElement* pCursorVisualElement = GetCursorVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pCursorVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get cursor visual element."); + + _Token* pToken = null; + _VisualElement* pTokenVisualElement = null; + if (__animatingIndex == (GetTokenCount() - 1)) + { + pToken = static_cast <_Token*>(__pTokenList->GetAt(GetTokenCount() - 1)); + if (pToken) + { + pTokenVisualElement = pToken->GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pTokenVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get token visual element."); + pTokenVisualElement->RemoveAnimation(L"TokenAnimation"); + } + } + pToken = static_cast <_Token*>(__pTokenList->GetAt(GetTokenCount() - 1)); + if (pToken) + { + pTokenVisualElement = pToken->GetVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pTokenVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get token visual element."); + + if (pCursorVisualElement->GetParent() != pEditVisualElement) + { + result r = E_SUCCESS; + r = pCursorVisualElement->GetParent()->DetachChild(*pCursorVisualElement); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating", GetErrorMessage(r)); + + r = pEditVisualElement->AttachChild(*pCursorVisualElement); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating", GetErrorMessage(r)); + } + } + + __animatingIndex = GetTokenCount() - 1; + + if (pTokenVisualElement && __animatingIndex >= 0) + { + VisualElementAnimation* pAnimation = CreateAnimationN(*pTokenVisualElement, false); + pTokenVisualElement->AddAnimation(L"TokenAnimation", *pAnimation); + delete pAnimation; + } + } + DrawText(); + __pTokenEdit->Invalidate(); + return; + } + } + + if (__pressedTokenIndex >= 0 && __edittingTokenIndex < 0 && !__isEditingToken) + { + RemoveTokenAt(__pressedTokenIndex); + __pTokenEdit->Invalidate(); + return; + } + + //Backspace on Blocked text, delete full block + if (IsBlocked() == true) + { + GetBlockRange(start, end); + } + else + { + cursorPosition = GetCursorPosition(); + start = cursorPosition + offset; + if (start < 0) + { + return; + } + end = start + charCount; + if (end > GetTextLength()) + { + return; + } + } + + DeleteText(start, end); + __previousCursorPosition = start; + + if (IsCopyPastePopupVisible()) + { + InitializeCopyPasteManager(); + } + if (IsBlocked() == true) + { + ReleaseTextBlock(); + } + if (__isEditingToken != true) + { + DrawText(); + } + + __pTokenEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED); + +#if 0 //ORIGINAL + cursorPosition = GetCursorPosition(); + start = cursorPosition + offset; + if (start < 0) + { + return; + } + end = start + charCount; + if (end > GetTextLength()) + { + return; + } + + Rectangle currBounds = __pTokenEdit->GetBounds(); + DeleteText(start, end); + __previousCursorPosition = start; + if (__isEditingToken != true) + { + DrawText(); + } +#endif + + _Token* pToken = null; + + if (__edittingTokenIndex >= 0 && __isEditingToken) + { + pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + + if (pToken) + { + int tokenHeight = 0; + int tokenVerticalSpacing = 0; + int tokenTextLeftMargin = 0; + + SetText(GetText()); + SetCursorPosition(__previousCursorPosition); + + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_HEIGHT, orientation, tokenHeight); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_VERTICAL_SPACING, orientation, tokenVerticalSpacing); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); + + Rectangle tempTextDspRect; + tempTextDspRect.x += tokenTextLeftMargin; + tempTextDspRect.y += tokenVerticalSpacing/2; + tempTextDspRect.width = pToken->GetTextPixelWidth(); + tempTextDspRect.height = tokenHeight; + + SetTextBounds(tempTextDspRect); + _EditPresenter::SetCursorPosition(start); + + pToken->ResetToken(GetText()); + TrimTokenAndAdjustEllipsisAt(__edittingTokenIndex); + } + } + + __pTokenEdit->Draw(); +} + +bool +_TokenEditPresenter::OnTapGestureDetected(void) +{ + __isPopupVisible = true; + + if (__pressedTokenIndex != -1) + { + return true; + } + return _EditPresenter::OnTapGestureDetected(); +} + +bool +_TokenEditPresenter::OnLongPressGestureDetected(void) +{ + __isLongPressed = true; + if (__pressedTokenIndex != -1) + { + return true; + } + return _EditPresenter::OnLongPressGestureDetected(); +} + +void +_TokenEditPresenter::OnCursorTimerExpired(void) +{ + if (__edittingTokenIndex != -1) + { + if (!IsFocused()) + { + StopCursorTimer(); + return; + } + + Rectangle cursorRect; + + _Token* pToken = static_cast <_Token*>(__pTokenList->GetAt(__edittingTokenIndex)); + SysTryReturnVoidResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null"); + + Rectangle cursorDspRect = pToken->displayRect; + cursorDspRect.x = 12; + cursorDspRect.y = 10; + if (CalculateCursorBounds(cursorDspRect, cursorRect) != E_SUCCESS) + { + StartCursorTimer(); + return; + } + + _VisualElement* pCursorVisualElement = GetCursorVisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, pCursorVisualElement != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get cursor visual element."); + + Canvas* pCursorCanvas = pCursorVisualElement->GetCanvasN(); + SysTryReturnVoidResult(NID_UI_CTRL, pCursorCanvas != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get canvas of cursor visual element."); + + bool cursorEnable = IsCursorEnabled(); + + pCursorVisualElement->SetBounds(FloatRectangle(cursorRect.x, cursorRect.y, cursorRect.width, cursorRect.height)); + DrawCursor(*pCursorCanvas, cursorRect, cursorEnable); + + if (cursorEnable) + { + cursorEnable = false; + } + else + { + cursorEnable = true; + } + SetCursorEnabled(cursorEnable); + + pCursorCanvas->Show(); + delete pCursorCanvas; + + StartCursorTimer(); + } + else + { + _EditPresenter::OnCursorTimerExpired(); + } +} + +bool +_TokenEditPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (GetTokenCount()) + { + SetTokenBoundsByTouchInfo(touchinfo); + return false; // Event through + } + else + { + return _EditPresenter::OnTouchMoved(source, touchinfo); + } + +} + +void +_TokenEditPresenter::OnVisualElementAnimationFinished (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, bool completedNormally) +{ + RemoveTokenAt(GetTokenCount() - 1); + CalculateTokenPositionFromIndex(GetTokenCount() - 1); + + for (int i = GetTokenCount() - 1; i < GetTokenCount() - 1 + 1; i++) + { + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + + if (pToken) + { + pToken->SetBounds(pToken->displayRect); + } + } + if (__lastTokenIndex == __pressedTokenIndex) + { + __pressedTokenIndex--; + } + + __animatingIndex = -1; + InitializeCursor(); + + DrawToken(); + + return; +} + +int +_TokenEditPresenter::ResizeTokenAndAdjustEllipsis(int index, int value, bool isTokenShrink) +{ + if (isTokenShrink) + { + int trimValue = value; + int extraTrimValue = 0; + + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(index)); + SysTryReturn(NID_UI_CTRL, pToken != null, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + int tokenMinimumSize = 0; + + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_MIN_WIDTH, orientation, tokenMinimumSize); + + if ((pToken->displayRect.width - trimValue) >= tokenMinimumSize) + { + pToken->displayRect.width -= trimValue; + } + else + { + extraTrimValue = (tokenMinimumSize - (pToken->displayRect.width - trimValue)); + pToken->displayRect.width = tokenMinimumSize; + } + + InitializeTokenVisibilityAt(index); + + pToken->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + pToken->pTextObject->SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL); + + return extraTrimValue; + } + else + { + int expandValue = value; + int extraExpandValue = 0; + + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(index)); + SysTryReturn(NID_UI_CTRL, pToken != null, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + int tokenTextLeftMargin = 0; + int tokenTextRightMargin = 0; + + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin); + + int tokenTextWidth = pToken->GetTextPixelWidth(); + + int tokenDisplayRectWidth = tokenTextLeftMargin + tokenTextWidth + tokenTextRightMargin; + if ((pToken->displayRect.width + expandValue) <= tokenDisplayRectWidth) + { + pToken->displayRect.width += expandValue; + } + else + { + extraExpandValue = ((pToken->displayRect.width + expandValue) - tokenDisplayRectWidth); + pToken->displayRect.width = tokenDisplayRectWidth; + } + + InitializeTokenVisibilityAt(index); + + pToken->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + pToken->pTextObject->SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL); + + return extraExpandValue; + } + + return -1; +} + +int +_TokenEditPresenter::PickToken(int index, Rectangle tokenDispRect, bool isTokenShrink) +{ + int tokenCount = __pTokenList->GetCount(); + + int tokenMinimumSize = 0; + int tokenTextLeftMargin = 0; + int tokenTextRightMargin = 0; + + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_MIN_WIDTH, orientation, tokenMinimumSize); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_LEFT_MARGIN, orientation, tokenTextLeftMargin); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin); + + if (isTokenShrink) + { + if (index < tokenCount) + { + for (int i = index; i >= 0; i--) + { + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + SysTryReturn(NID_UI_CTRL, pToken != null, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + Rectangle tokenRect = pToken->displayRect; + if (tokenDispRect.y == tokenRect.y) + { + if (tokenRect.width > tokenMinimumSize) + { + return i; + } + } + } + } + } + else + { + for (int i = index; i < tokenCount; i++) + { + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + SysTryReturn(NID_UI_CTRL, pToken != null, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + Rectangle tokenRect = pToken->displayRect; + if (tokenDispRect.y == tokenRect.y) + { + int tokenTextWidth = pToken->GetTextPixelWidth(); + + if (tokenRect.width < (tokenTextLeftMargin + tokenTextWidth + tokenTextRightMargin)) + { + return i; + } + } + } + } + + return -1; +} + +void +_TokenEditPresenter::RepositionToken(int currentTokenIndex, int moveDistance, bool isTokenShrink) +{ + int tokenCount = __pTokenList->GetCount(); + + _Token* pCurrentToken = null; + pCurrentToken = static_cast <_Token*>(__pTokenList->GetAt(currentTokenIndex)); + SysTryReturnVoidResult(NID_UI_CTRL, pCurrentToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + Rectangle currentTokenRect = pCurrentToken->displayRect; + + if (currentTokenIndex < (tokenCount - 1)) + { + for (int i = currentTokenIndex + 1; i < tokenCount; i++) + { + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + SysTryReturnVoidResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + if (pToken) + { + Rectangle tokenRect = pToken->displayRect; + if (currentTokenRect.y == tokenRect.y) + { + if (isTokenShrink) + { + pToken->displayRect.x -= moveDistance; + } + else + { + pToken->displayRect.x += moveDistance; + } + + InitializeTokenVisibilityAt(i); + } + else + { + break; + } + } + } + } + + return; +} + +void +_TokenEditPresenter::ShrinkTokens() +{ + int tokenTextRightMargin = 0; + + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin); + + int tokenCount = __pTokenList->GetCount(); + Rectangle currentEditBounds = __pTokenEdit->GetBounds(); + + for (int i = 0; i < tokenCount; i++) + { + bool isTokenPicked = false; + _Token* pToken = null; + _Token* pNextToken = null; + + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + SysTryReturnVoidResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + Rectangle tokenRect = pToken->displayRect; + + Rectangle nextTokenRect; + if (i < tokenCount - 1) + { + pNextToken = static_cast <_Token*>(__pTokenList->GetAt(i + 1)); + SysTryReturnVoidResult(NID_UI_CTRL, pNextToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + nextTokenRect = pNextToken->displayRect; + } + + if (pNextToken) + { + if (nextTokenRect.y > tokenRect.y) + { + isTokenPicked = true; + } + } + else + { + isTokenPicked = true; + } + + //"pToken" (isTokenPicked = true) is the last token in a row + if (isTokenPicked == false) + { + continue; + } + + int tokenEndPoint = tokenRect.x + tokenRect.width + tokenTextRightMargin + __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN); + if (tokenEndPoint <= currentEditBounds.width) + { + continue; + } + + //Trimming Token required + int trimValue = tokenEndPoint - currentEditBounds.width; + + while (trimValue > 0) + { + int tokenIndex = PickToken(i, tokenRect, true); + if (tokenIndex >= 0) + { + int extraTrimValue = ResizeTokenAndAdjustEllipsis(tokenIndex, trimValue, true); + if (extraTrimValue < 0) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + break; + } + + if ((trimValue - extraTrimValue) > 0) + { + RepositionToken(tokenIndex, (trimValue - extraTrimValue), true); + } + + trimValue = extraTrimValue; + } + else + { + break; + } + } + } + + return; +} + +int +_TokenEditPresenter::GetPickedTokenEndPoint(int index, Tizen::Graphics::Rectangle tokenDispRect) +{ + int tokenTextRightMargin = 0; + int endValue = 0; + + _ControlOrientation orientation = __pTokenEdit->GetOrientation(); + GET_SHAPE_CONFIG(TOKENEDIT::TOKEN_TEXT_RIGHT_MARGIN, orientation, tokenTextRightMargin); + + int marginValue = tokenTextRightMargin + __pTokenEdit->GetHorizontalMargin(EDIT_TEXT_RIGHT_MARGIN);; + + Rectangle lastTokenRect(0,0,0,0); + + int tokenCount = __pTokenList->GetCount(); + for (int i = index; i < tokenCount; i++) + { + _Token* pToken = null; + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + SysTryReturn(NID_UI_CTRL, pToken != null, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + Rectangle tokenRect = pToken->displayRect; + if (tokenDispRect.y == tokenRect.y) + { + lastTokenRect = tokenRect; + } + else + { + break; + } + } + + endValue = marginValue + lastTokenRect.x + lastTokenRect.width; + + return endValue; +} + +void +_TokenEditPresenter::ExpandTokens() +{ + int tokenCount = __pTokenList->GetCount(); + Rectangle currentEditBounds = __pTokenEdit->GetBounds(); + + for (int i = tokenCount - 1; i >= 0; i--) + { + bool isTokenPicked = false; + _Token* pToken = null; + _Token* pPrevToken = null; + + pToken = static_cast <_Token*>(__pTokenList->GetAt(i)); + SysTryReturnVoidResult(NID_UI_CTRL, pToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + Rectangle tokenRect = pToken->displayRect; + + Rectangle prevTokenRect; + if (i > 0) + { + pPrevToken = static_cast <_Token*>(__pTokenList->GetAt(i - 1)); + SysTryReturnVoidResult(NID_UI_CTRL, pPrevToken != null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + + prevTokenRect = pPrevToken->displayRect; + } + + if (pPrevToken) + { + if (prevTokenRect.y < tokenRect.y) + { + isTokenPicked = true; + } + } + else + { + isTokenPicked = true; + } + + //"pToken" (isTokenPicked = true) is the first token in a row + if (isTokenPicked == false) + { + continue; + } + + int tokenEndPoint = GetPickedTokenEndPoint(i, tokenRect);; + + if ((tokenEndPoint == 0) || (tokenEndPoint >= currentEditBounds.width)) + { + continue; + } + + //Expanding Token required + int expandValue = currentEditBounds.width - tokenEndPoint; + + while (expandValue > 0) + { + int tokenIndex = PickToken(i, tokenRect, false); + if (tokenIndex >= 0) + { + int extraExpandValue = ResizeTokenAndAdjustEllipsis(tokenIndex, expandValue, false); + if (extraExpandValue < 0) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Token instance is null."); + break; + } + + if ((expandValue - extraExpandValue) > 0) + { + RepositionToken(tokenIndex, (expandValue - extraExpandValue), false); + } + + expandValue = extraExpandValue; + } + else + { + break; + } + } + } + + return; +} + +void +_TokenEditPresenter::OnBoundsChanged(void) +{ + if (!__isTokenEditPresenterInitialized) + { + return; + } + + int tokenCount = __pTokenList->GetCount(); + SysTryReturnVoidResult(NID_UI_CTRL, tokenCount > 0, E_SUCCESS, "No Tokens available."); + + Rectangle tokenEditBounds = __pTokenEdit->GetBounds(); + + if (tokenEditBounds.width < __previousEditBounds.width) + { + ShrinkTokens(); + } + else if (tokenEditBounds.width > __previousEditBounds.width) + { + ExpandTokens(); + } + + __previousEditBounds = tokenEditBounds; + + return; +} + + +}}} //Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Toolbar.cpp b/src/ui/controls/FUiCtrl_Toolbar.cpp new file mode 100644 index 0000000..5c49457 --- /dev/null +++ b/src/ui/controls/FUiCtrl_Toolbar.cpp @@ -0,0 +1,5251 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Toolbar.cpp + * @brief This is the implementation file for the _Toolbar class. + */ + +#include +#include +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityManager.h" +#include "FUi_TouchLongPressGestureDetector.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_ActionEvent.h" +#include "FUiCtrl_Toolbar.h" +#include "FUiCtrl_ToolbarPresenter.h" +#include "FUiCtrl_Label.h" +#include "FUiCtrl_Form.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +IMPLEMENT_PROPERTY(_Toolbar); + +_Toolbar::_Toolbar(void) + : __header(false) + , __pToolbarPresenter(null) + , __pActionEventListener(null) + , __pBackEventListener(null) + , __pLongPressGesture(null) + , __pToolbarBackgroundBitmap(null) + , __pTitleIcon(null) + , __titleText(L"") + , __descriptionText(L"") + , __titleTextAlignment(ALIGNMENT_LEFT) + , __pItems(null) + , __pAnimationFrameList(null) + , __backActionId(-1) + , __itemCount(0) + , __style(TOOLBAR_TITLE) + , __transparent(false) + , __isUserBackgroundBitmap(false) + , __titleTextArea(Rectangle(0, 0, 0, 0)) + , __itemArea(Rectangle(0, 0, 0, 0)) + , __pTitleTextElement(null) +{ + _AccessibilityContainer* pContainer = null; + + __pButtonItems[LEFT_BUTTON] = null; + __pButtonItems[RIGHT_BUTTON] = null; + __pButtonItems[BACK_BUTTON] = null; + __pButtonItems[MIDDLE_BUTTON] = null; + + for (int i = 0; i < TOOLBAR_ANIMATION_POSITION_MAX; i++) + { + __pAnimation[i] = null; + } + + Color bgColor; + + GET_COLOR_CONFIG(FOOTER::BG_NORMAL, bgColor); + + SetColor(bgColor); + + _Control::SetResizable(false); + + _Control::SetMovable(false); + + _ToolbarPresenter* pPresenter = new (std::nothrow) _ToolbarPresenter(); + + SetPresenter(*pPresenter); + + pPresenter->Construct(*this); + + pPresenter->Install(); + + pContainer = GetAccessibilityContainer(); + + if(pContainer) + { + pContainer->Activate(true); + } + + for (int i = 0; i < TOOLBAR_ITEM_MAX_STATE_COUNT; i++) + { + __isItemBgColorSetByUser[i] = false; + __isItemTextColorSetByUser[i] = false; + } + + for (int i = 0; i < TOOLBAR_BUTTON_MAX_STATE_COUNT; i++) + { + __isButtonBgColorSetByUser[i] = false; + __isButtonTextColorSetByUser[i] = false; + } +} + +_Toolbar::~_Toolbar(void) +{ + RemoveAllItems(); //__pMoreButton would be deleted in this function + RemoveAllButtons(); + + if (__pToolbarPresenter) + { + delete __pToolbarPresenter; + __pToolbarPresenter = null; + } + + if (__pActionEventListener) + { + __pActionEventListener = null; + } + + if (__pBackEventListener) + { + __pBackEventListener = null; + } + + if (__pLongPressGesture != null) + { + __pLongPressGesture->RemoveGestureListener(*this); + RemoveGestureDetector(*__pLongPressGesture); + + delete __pLongPressGesture; + __pLongPressGesture = null; + } + + if (__pToolbarBackgroundBitmap) + { + delete __pToolbarBackgroundBitmap; + __pToolbarBackgroundBitmap = null; + } + + if (__pTitleIcon) + { + delete __pTitleIcon; + __pTitleIcon = null; + } + + if (__pAnimationFrameList) + { + delete __pAnimationFrameList; + __pAnimationFrameList = null; + } + + if (__pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE]) + { + DetachChild(*__pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE]); + delete __pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE]; + __pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE] = null; + } + + if (__pTitleTextElement) + { + __pTitleTextElement->Activate(false); + __pTitleTextElement = null; + } + + ClearLastResult(); +} + +_Toolbar* +_Toolbar::CreateToolbarN(bool header) +{ + _Toolbar* pToolbar = new (std::nothrow) _Toolbar(); + SysTryReturn(NID_UI_CTRL, pToolbar, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + pToolbar->Initialize(header); + pToolbar->AcquireHandle(); + + return pToolbar; +} + +result +_Toolbar::Initialize(bool header) +{ + __header = header; + + return E_SUCCESS; +} + +result +_Toolbar::InitToolbarColor(void) +{ + if (__header == true) + { + if (__transparent) // header && transparent + { + GET_COLOR_CONFIG(HEADER::TRANSLUCENT_TITLE_TEXT_NORMAL, __transTitleTextColor); + GET_COLOR_CONFIG(HEADER::TRANSLUCENT_DESCRIPTION_TEXT_NORMAL, __transDescriptionTextColor); + + if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_NORMAL, __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_DISABLED, __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_PRESSED, __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_HIGHLIGHTED, __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + //GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_SELECTED, __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED]); + + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_NORMAL, __itemTransTextColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_DISABLED, __itemTransTextColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_PRESSED, __itemTransTextColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_HIGHLIGHTED, __itemTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + //GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_SELECTED, __itemTransTextColor[_BUTTON_STATUS_SELECTED]); + } + else + { + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_BG_NORMAL, __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_BG_DISABLED, __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_BG_PRESSED, __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_BG_HIGHLIGHTED, __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_BG_SELECTED, __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED]); + + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_NORMAL, __itemTransTextColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_DISABLED, __itemTransTextColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_PRESSED, __itemTransTextColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_HIGHLIGHTED, __itemTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_SELECTED, __itemTransTextColor[_BUTTON_STATUS_SELECTED]); + } + + __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL].SetAlpha(0x00); + __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED].SetAlpha(0x00); + __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED].SetAlpha(0xFF); + __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED].SetAlpha(0x00); + __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED].SetAlpha(0x00); + + GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_BG_NORMAL, __buttonTransBackgroundColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_BG_DISABLED, __buttonTransBackgroundColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_BG_PRESSED, __buttonTransBackgroundColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_BG_HIGHLIGHTED, __buttonTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + + __buttonTransBackgroundColor[_BUTTON_STATUS_NORMAL].SetAlpha(0x00); + __buttonTransBackgroundColor[_BUTTON_STATUS_DISABLED].SetAlpha(0x00); + __buttonTransBackgroundColor[_BUTTON_STATUS_PRESSED].SetAlpha(0x00); + __buttonTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED].SetAlpha(0x00); + + GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_TEXT_NORMAL, __buttonTransTextColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_TEXT_DISABLED, __buttonTransTextColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_TEXT_PRESSED, __buttonTransTextColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(HEADER::BUTTON_TRANSLUCENT_TEXT_HIGHLIGHTED, __buttonTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + else // header && not transparent + { + GET_COLOR_CONFIG(HEADER::TITLE_TEXT_NORMAL, __titleTextColor); + GET_COLOR_CONFIG(HEADER::TITLE_TEXT_NORMAL, __descriptionTextColor); + + + if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT) + { + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + //if (!__isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED]) + //{ + // GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED]); + //} + + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + //if (!__isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED]) + //{ + // GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]); + //} + } + else + { + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL]) + { + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED]) + { + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED]) + { + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED]) + { + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED]) + { + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_BG_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED]); + } + + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL]) + { + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED]) + { + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED]) + { + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED]) + { + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED]) + { + GET_COLOR_CONFIG(HEADER::SEGMENTED_ITEM_TEXT_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]); + } + } + + if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_NORMAL]) + { + GET_COLOR_CONFIG(HEADER::BUTTON_BG_NORMAL, __buttonBackgroundColor[_BUTTON_STATUS_NORMAL]); + } + if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_DISABLED]) + { + GET_COLOR_CONFIG(HEADER::BUTTON_BG_DISABLED, __buttonBackgroundColor[_BUTTON_STATUS_DISABLED]); + } + if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_PRESSED]) + { + GET_COLOR_CONFIG(HEADER::BUTTON_BG_PRESSED, __buttonBackgroundColor[_BUTTON_STATUS_PRESSED]); + } + if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED]) + { + GET_COLOR_CONFIG(HEADER::BUTTON_BG_HIGHLIGHTED, __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + + if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_NORMAL]) + { + GET_COLOR_CONFIG(HEADER::BUTTON_TEXT_NORMAL, __buttonTextColor[_BUTTON_STATUS_NORMAL]); + } + if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_DISABLED]) + { + GET_COLOR_CONFIG(HEADER::BUTTON_TEXT_DISABLED, __buttonTextColor[_BUTTON_STATUS_DISABLED]); + } + if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_PRESSED]) + { + GET_COLOR_CONFIG(HEADER::BUTTON_TEXT_PRESSED, __buttonTextColor[_BUTTON_STATUS_PRESSED]); + } + if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED]) + { + GET_COLOR_CONFIG(HEADER::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + } + } + else + { + if (__transparent) // footer && transparent + { + if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_NORMAL, __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_DISABLED, __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_PRESSED, __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_HIGHLIGHTED, __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + //GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_BG_SELECTED, __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED]); + + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_NORMAL, __itemTransTextColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_DISABLED, __itemTransTextColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_PRESSED, __itemTransTextColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_HIGHLIGHTED, __itemTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + //GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TRANSLUCENT_TEXT_SELECTED, __itemTransTextColor[_BUTTON_STATUS_SELECTED]); + } + else + { + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_BG_NORMAL, __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_BG_DISABLED, __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_BG_PRESSED, __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_BG_HIGHLIGHTED, __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_BG_SELECTED, __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED]); + + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_NORMAL, __itemTransTextColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_DISABLED, __itemTransTextColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_PRESSED, __itemTransTextColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_HIGHLIGHTED, __itemTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TRANSLUCENT_TEXT_SELECTED, __itemTransTextColor[_BUTTON_STATUS_SELECTED]); + } + + __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL].SetAlpha(0x00); + __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED].SetAlpha(0x00); + __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED].SetAlpha(0xFF); + __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED].SetAlpha(0x00); + __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED].SetAlpha(0x00); + + + GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_BG_NORMAL, __buttonTransBackgroundColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_BG_DISABLED, __buttonTransBackgroundColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_BG_PRESSED, __buttonTransBackgroundColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_BG_HIGHLIGHTED, __buttonTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + + __buttonTransBackgroundColor[_BUTTON_STATUS_NORMAL].SetAlpha(0x00); + __buttonTransBackgroundColor[_BUTTON_STATUS_DISABLED].SetAlpha(0x00); + __buttonTransBackgroundColor[_BUTTON_STATUS_PRESSED].SetAlpha(0x00); + __buttonTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED].SetAlpha(0x00); + + GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_TEXT_NORMAL, __buttonTransTextColor[_BUTTON_STATUS_NORMAL]); + GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_TEXT_DISABLED, __buttonTransTextColor[_BUTTON_STATUS_DISABLED]); + GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_TEXT_PRESSED, __buttonTransTextColor[_BUTTON_STATUS_PRESSED]); + GET_COLOR_CONFIG(FOOTER::BUTTON_TRANSLUCENT_TEXT_HIGHLIGHTED, __buttonTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + else // footer && not transparent + { + if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT) + { + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + //if (!__isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED]) + //{ + // GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_BG_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED]); + //} + + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + //if (!__isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED]) + //{ + // GET_COLOR_CONFIG(FOOTER::BUTTON_ITEM_TEXT_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]); + //} + } + else + { + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL]) + { + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED]) + { + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED]) + { + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED]) + { + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + if (!__isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED]) + { + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_BG_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED]); + } + + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL]) + { + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED]) + { + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED]) + { + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED]) + { + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + if (!__isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED]) + { + GET_COLOR_CONFIG(FOOTER::SEGMENTED_ITEM_TEXT_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]); + } + } + + if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_NORMAL]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_BG_NORMAL, __buttonBackgroundColor[_BUTTON_STATUS_NORMAL]); + } + if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_DISABLED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_BG_DISABLED, __buttonBackgroundColor[_BUTTON_STATUS_DISABLED]); + } + if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_PRESSED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_BG_PRESSED, __buttonBackgroundColor[_BUTTON_STATUS_PRESSED]); + } + if (!__isButtonBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_BG_HIGHLIGHTED, __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + + if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_NORMAL]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_TEXT_NORMAL, __buttonTextColor[_BUTTON_STATUS_NORMAL]); + } + if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_DISABLED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_TEXT_DISABLED, __buttonTextColor[_BUTTON_STATUS_DISABLED]); + } + if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_PRESSED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_TEXT_PRESSED, __buttonTextColor[_BUTTON_STATUS_PRESSED]); + } + if (!__isButtonTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED]) + { + GET_COLOR_CONFIG(FOOTER::BUTTON_TEXT_HIGHLIGHTED, __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + } + } + + return E_SUCCESS; +} + +result +_Toolbar::InitializeLongPressGesture(void) +{ + result r = E_SUCCESS; + + __pLongPressGesture = new (std::nothrow) _TouchLongPressGestureDetector(); + SysTryReturn(NID_UI_CTRL, __pLongPressGesture, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create touch long press gesture."); + + __pLongPressGesture->SetDuration(300); + + r = AddGestureDetector(*__pLongPressGesture); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add gesture detector", GetErrorMessage(r)); + + r = __pLongPressGesture->AddGestureListener(*(dynamic_cast<_ITouchLongPressGestureEventListener*>(this))); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add gesture listener", GetErrorMessage(r)); + + return r; +} + +result +_Toolbar::Construct(void) +{ + result r = E_SUCCESS; + + return r; +} + +result +_Toolbar::AddItem(_Button* pButton) +{ + SysTryReturnResult(NID_UI_CTRL, (__itemCount < TAB_ITEM_MAX), E_MAX_EXCEEDED, + "[E_MAX_EXCEEDED] The number of items have exceeded the maximum limit."); + + if (__pActionEventListener != null) + { + pButton->AddActionEventListener(*__pActionEventListener); + } + + __pItems.push_back(pButton); + __itemCount++; + + AttachChild(*pButton); + + ApplyUserGUI(TOOLBAR_ITEM, pButton); + + RearrangeItems(); + + AddAccessibilityItem(pButton); + + return E_SUCCESS; +} + +Bitmap* +_Toolbar::GetBackgroundBitmap(void) const +{ + result r = E_SUCCESS; + + _Toolbar* pToolbar = const_cast<_Toolbar*>(this); + + if (!pToolbar->__pToolbarBackgroundBitmap) + { + if(__header == true) + { + r = GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pToolbar->__pToolbarBackgroundBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pToolbar->__pToolbarBackgroundBitmap); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + + return pToolbar->__pToolbarBackgroundBitmap; +} + +_Button* +_Toolbar::GetButton(ToolbarButton position) const +{ + SysTryReturn(NID_UI_CTRL, (position >= LEFT_BUTTON && position < BUTTON_MAX), null, E_OUT_OF_RANGE, + ("[E_OUT_OF_RANGE] The position is out of range.")); + + return __pButtonItems[position]; +} + +Color +_Toolbar::GetButtonColor(_ButtonStatus status) const +{ + Variant color; + + switch (status) + { + case _BUTTON_STATUS_NORMAL: + color = GetProperty("normalButtonColor"); + break; + case _BUTTON_STATUS_DISABLED: + color = GetProperty("disabledButtonColor"); + break; + case _BUTTON_STATUS_PRESSED: + color = GetProperty("pressedButtonColor"); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + color = GetProperty("highlightedButtonColor"); + break; + default: + color = GetProperty("normalButtonColor"); + break; + } + + return color.ToColor(); +} + +_ButtonStatus +_Toolbar::GetButtonStatus(ToolbarButton position) const +{ + return __pButtonItems[position]->GetButtonStatus(); +} + +Color +_Toolbar::GetButtonTextColor(_ButtonStatus status) const +{ + Variant color; + + switch (status) + { + case _BUTTON_STATUS_NORMAL: + color = GetProperty("normalButtonTextColor"); + break; + case _BUTTON_STATUS_DISABLED: + color = GetProperty("disabledButtonTextColor"); + break; + case _BUTTON_STATUS_PRESSED: + color = GetProperty("pressedButtonTextColor"); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + color = GetProperty("highlightedButtonTextColor"); + break; + default: + color = GetProperty("normalButtonTextColor"); + break; + } + + return color.ToColor(); +} + +Color +_Toolbar::GetColor(void) const +{ + Variant color = GetProperty("color"); + + return color.ToColor(); +} + +String +_Toolbar::GetDescriptionText(void) const +{ + Variant text = GetProperty("descriptionText"); + + return text.ToString(); +} + +Color +_Toolbar::GetDescriptionTextColor(void) const +{ + Variant color = GetProperty("descriptionTextColor"); + + return color.ToColor(); +} + +int +_Toolbar::GetFirstEnabledItemIndex(void) const +{ + int firstEnabledItemIndex = -1; + + for (int i = 0; i < __itemCount; i++) + { + if(__pItems.at(i)->GetButtonStatus() != _BUTTON_STATUS_DISABLED) + { + firstEnabledItemIndex = i; + break; + } + } + + return firstEnabledItemIndex; +} + +_Button* +_Toolbar::GetItem(int itemIndex) const +{ + if (__pItems.at(itemIndex) == null) + { + SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to get item."); + return null; + } + + return __pItems.at(itemIndex); +} + +Color +_Toolbar::GetItemColor(_ButtonStatus status) const +{ + Variant color; + + switch (status) + { + case _BUTTON_STATUS_NORMAL: + color = GetProperty("normalItemColor"); + break; + case _BUTTON_STATUS_DISABLED: + color = GetProperty("disabledItemColor"); + break; + case _BUTTON_STATUS_PRESSED: + color = GetProperty("pressedItemColor"); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + color = GetProperty("highlightedItemColor"); + break; + case _BUTTON_STATUS_SELECTED: + color = GetProperty("selectedItemColor"); + break; + default: + color = GetProperty("normalItemColor"); + break; + } + + return color.ToColor(); +} + +int +_Toolbar::GetItemCount(void) const +{ + return __itemCount; +} + +int +_Toolbar::GetItemIndexFromPosition(const Point& point) const +{ + if (__itemCount <= 0) + { + return -1; + } + + for (int i = 0; i < __itemCount; i++) + { + Rectangle bounds = __pItems.at(i)->GetBounds(); + + if (bounds.Contains(point) && __pItems.at(i)->GetVisibleState() == true) + { + return i; + } + } + + return -1; +} + +result +_Toolbar::GetItemStatus(int itemIndex, _ButtonStatus& status) const +{ + status = _BUTTON_STATUS_NORMAL; + + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex <= __itemCount), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + status = __pItems.at(itemIndex)->GetButtonStatus(); + + return E_SUCCESS; +} + +Color +_Toolbar::GetItemTextColor(_ButtonStatus status) const +{ + Variant color; + + switch (status) + { + case _BUTTON_STATUS_NORMAL: + color = GetProperty("normalItemTextColor"); + break; + case _BUTTON_STATUS_DISABLED: + color = GetProperty("disabledItemTextColor"); + break; + case _BUTTON_STATUS_PRESSED: + color = GetProperty("pressedItemTextColor"); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + color = GetProperty("highlightedItemTextColor"); + break; + case _BUTTON_STATUS_SELECTED: + color = GetProperty("selectedItemTextColor"); + break; + default: + color = GetProperty("normalItemTextColor"); + break; + } + + return color.ToColor(); +} + +int +_Toolbar::GetSelectedItemIndex(void) const +{ + if (__pToolbarPresenter) + { + return __pToolbarPresenter->GetSelectedItemIndex(); + } + + return 0; +} + +ToolbarStyle +_Toolbar::GetStyle(void) const +{ + return ToolbarStyle(__style); +} + +Bitmap* +_Toolbar::GetTitleIcon(void) const +{ + return __pTitleIcon; +} + +String +_Toolbar::GetTitleText(void) const +{ + Variant text = GetProperty("titleText"); + return text.ToString(); +} + +Color +_Toolbar::GetTitleTextColor(void) const +{ + Variant color = GetProperty("titleTextColor"); + return color.ToColor(); +} + +HorizontalAlignment +_Toolbar::GetTitleTextHorizontalAlignment(void) const +{ + return __titleTextAlignment; +} + +bool +_Toolbar::IsInitialDraw(void) const +{ + if (__pToolbarPresenter) + return __pToolbarPresenter->IsInitialDraw(); + else + return false; +} + +bool +_Toolbar::IsTabEditModeEnabled(void) const +{ + if (__pToolbarPresenter) + { + return __pToolbarPresenter->IsTabEditModeEnabled(); + } + + return false; +} + +bool +_Toolbar::IsTransparent(void) const +{ + return __transparent; +} + + +AnimationStatus +_Toolbar::GetWaitingAnimationStatus(ToolbarAnimationPosition animationPos) const +{ + if (animationPos < TOOLBAR_ANIMATION_POSITION_TITLE || animationPos >= TOOLBAR_ANIMATION_POSITION_MAX) + { + return ANIMATION_STOPPED; + } + + if (__pAnimation[animationPos] == null) + { + return ANIMATION_STOPPED; + } + + return __pAnimation[animationPos]->GetStatus(); +} + +result +_Toolbar::InsertItemAt(int itemIndex, _Button* pButton) +{ + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex <= __itemCount), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + if (__pActionEventListener != null) + { + pButton->AddActionEventListener(*__pActionEventListener); + } + + __pItems.insert(__pItems.begin() + itemIndex, pButton); + __itemCount++; + + AttachChild(*pButton); + + ApplyUserGUI(TOOLBAR_ITEM, pButton); + + RearrangeItems(); + AddAccessibilityItem(pButton); + + return E_SUCCESS; +} + +bool +_Toolbar::IsButtonSet(ToolbarButton position) const +{ + if (__pButtonItems[position] != null) + { + return true; + } + + return false; +} + +result +_Toolbar::MoveItem(const int srcIndex, const int destIndex) +{ + if (srcIndex == destIndex) + { + SetItemSelected(destIndex, true); + + return E_SUCCESS; + } + + if (srcIndex < 0 || destIndex < 0 || srcIndex > __itemCount || destIndex > __itemCount) + { + return E_INVALID_OPERATION; + } + + _Button* pSrcButton = null; + pSrcButton = GetItem(srcIndex); + + _Button* pDestButton = null; + pDestButton = GetItem(destIndex); + + __pItems.erase(__pItems.begin() + destIndex); + __pItems.insert(__pItems.begin() + destIndex, pSrcButton); + + __pItems.erase(__pItems.begin() + srcIndex); + __pItems.insert(__pItems.begin() + srcIndex, pDestButton); + + for (int i = 0; i < __itemCount; i++) + { + __pItems.at(i)->SetButtonStatus(_BUTTON_STATUS_NORMAL); + } + + SetItemSelected(destIndex, true); + + RearrangeItems(); + + Invalidate(true); + + return E_SUCCESS; +} + +result +_Toolbar::PauseWaitingAnimation(ToolbarAnimationPosition animationPos) +{ + SysTryReturnResult(NID_UI_CTRL, + (TOOLBAR_ANIMATION_POSITION_TITLE <= animationPos && animationPos < TOOLBAR_ANIMATION_POSITION_MAX), E_INVALID_ARG, + "[E_INVALID_ARG] The animationPos is invalid."); + SysTryReturnResult(NID_UI_CTRL, (__pAnimation[animationPos]), E_INVALID_STATE, + "[E_INVALID_STATE] __pAnimation isn't constructed."); + + __pAnimation[animationPos]->Pause(); + + return E_SUCCESS; +} + +result +_Toolbar::PlayWaitingAnimation(ToolbarAnimationPosition animationPos) +{ + SysTryReturnResult(NID_UI_CTRL, + (TOOLBAR_ANIMATION_POSITION_TITLE <= animationPos && animationPos < TOOLBAR_ANIMATION_POSITION_MAX), E_INVALID_ARG, + "[E_INVALID_ARG] The animationPos is invalid."); + + if ((animationPos == TOOLBAR_ANIMATION_POSITION_TITLE && __style != TOOLBAR_TITLE) + || (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT && __pButtonItems[LEFT_BUTTON] == null) + || (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT && __pButtonItems[RIGHT_BUTTON] == null)) + { + return E_UNSUPPORTED_OPERATION; + } + + if (__pAnimation[animationPos]) + { + if (__pAnimation[animationPos]->GetStatus() == ANIMATION_PLAYING) + { + return E_SUCCESS; + } + } + else + { + SetAnimation(animationPos); + } + + if (__pAnimation[animationPos]) + { + __pAnimation[animationPos]->Play(); + } + + return E_SUCCESS; +} + +result +_Toolbar::RemoveAllButtons(void) +{ + for (int i = 0; i < BUTTON_MAX; i++) + { + _Button* pButtonItem = __pButtonItems[i]; + + if (pButtonItem != null) + { + if (i == LEFT_BUTTON) + { + StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT); + } + else if (i == RIGHT_BUTTON) + { + StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT); + } + + if (pButtonItem->GetChildCount() != 0) + { + _Label* pTempBadgeIcon = dynamic_cast<_Label*>(pButtonItem->GetChild(0)); + SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon."); + + pButtonItem->DetachChild(*pTempBadgeIcon); + + delete pTempBadgeIcon; + pTempBadgeIcon = null; + } + + DetachChild(*pButtonItem); + delete pButtonItem; + pButtonItem = null; + + __pButtonItems[i] = null; + } + } + + return E_SUCCESS; +} + +result +_Toolbar::RemoveAllItems(void) +{ + __itemCount = 0; + + int itemCount = __pItems.size(); + + _Button* pItem = null; + + // frees item nodes from the memory + if (itemCount > 0) + { + for (int i = itemCount - 1; i >= 0; i--) + { + pItem = __pItems.at(i); + + if (pItem != null) + { + if (pItem->GetChildCount() != 0) + { + _Label* pTempBadgeIcon = dynamic_cast<_Label*>(pItem->GetChild(0)); + SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon."); + + pItem->DetachChild(*pTempBadgeIcon); + + delete pTempBadgeIcon; + pTempBadgeIcon = null; + } + + DetachChild(*pItem); + delete pItem; + + pItem = null; + } + } + } + + // clears vector + __pItems.clear(); + + if (__pToolbarPresenter) + { + __pToolbarPresenter->SetInitialDrawState(true); + } + + SetItemSelected(-1); + + return E_SUCCESS; +} + +result +_Toolbar::RemoveButtonAt(ToolbarButton position) +{ + if (__pButtonItems[position] != null) + { + if (position == LEFT_BUTTON) + { + StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT); + } + else if (position == RIGHT_BUTTON) + { + StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT); + } + + DetachChild(*__pButtonItems[position]); + delete __pButtonItems[position]; + __pButtonItems[position] = null; + } + + return E_SUCCESS; +} + +result +_Toolbar::RemoveItemAt(int itemIndex) +{ + SysTryReturnResult(NID_UI_CTRL, (__itemCount > 0 && itemIndex < __itemCount && itemIndex >= 0), E_INVALID_ARG, + "[E_INVALID_ARG] itemIndex is invalid."); + + _Button* pItem = __pItems.at(itemIndex); + + SysTryReturnResult(NID_UI_CTRL, (pItem != null), E_INVALID_STATE, "[E_INVALID_ARG] No item at the designated index."); + + if (pItem->GetChildCount() != 0) + { + _Label* pTempBadgeIcon = dynamic_cast<_Label*>(pItem->GetChild(0)); + SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon."); + + pItem->DetachChild(*pTempBadgeIcon); + + delete pTempBadgeIcon; + pTempBadgeIcon = null; + } + + // Free 'pItem' from the item nodes + DetachChild(*pItem); + delete pItem; + pItem = null; + + __itemCount--; + + __pItems.erase(__pItems.begin() + itemIndex); + + return E_SUCCESS; +} + +result +_Toolbar::SetBackgroundBitmap(const Bitmap& bitmap) +{ + result r = E_SYSTEM; + + Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap); + + if (pClonedBitmap) + { + if (__pToolbarBackgroundBitmap) + { + delete __pToolbarBackgroundBitmap; + } + + __pToolbarBackgroundBitmap = pClonedBitmap; + __isUserBackgroundBitmap = true; + + r = E_SUCCESS; + } + + return r; +} + +bool +_Toolbar::IsUserBackgroundBitmap() const +{ + return __isUserBackgroundBitmap; +} + +result +_Toolbar::SetButton(ToolbarButton position, _Button* pButton) +{ + SysTryReturnResult(NID_UI_CTRL, (pButton), E_INVALID_ARG, "[E_INVALID_ARG] The pButton is invalid."); + + int buttonWidth = pButton->GetSize().width; + + int toolbarWidth = GetBounds().width; + + if (CalculateMinimumToolbarWidth() > toolbarWidth) + { + toolbarWidth = CalculateMinimumToolbarWidth(); + } + + int horizontalMargin = 0; + int verticalMargin = 0; + + if (__header == true && __style != TOOLBAR_TEXT) + { + int buttonItemGap = 0; + int buttonTopMargin = 0; + + if (__style == TOOLBAR_TITLE) + { + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN, GetOrientation(), buttonTopMargin); + } + else if (__style == TOOLBAR_HEADER_SEGMENTED) + { + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN_OF_SEGMENTED, GetOrientation(), buttonTopMargin); + } + + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_GAP, GetOrientation(), buttonItemGap); + + + switch (position) + { + case RIGHT_BUTTON: + if (__pButtonItems[LEFT_BUTTON]) + { + pButton->SetPosition(Point(toolbarWidth - buttonWidth , buttonTopMargin)); + __pButtonItems[LEFT_BUTTON]->SetPosition(Point(toolbarWidth - buttonWidth *2 - buttonItemGap, buttonTopMargin)); + } + else + { + pButton->SetPosition(Point(toolbarWidth - buttonWidth , buttonTopMargin)); + } + break; + case LEFT_BUTTON: + if (__pButtonItems[RIGHT_BUTTON]) + { + pButton->SetPosition(Point(toolbarWidth - buttonWidth * 2 - buttonItemGap, buttonTopMargin)); + } + else + { + pButton->SetPosition(Point(toolbarWidth - buttonWidth, buttonTopMargin)); + } + break; + + default: + break; + } + } + else // footer or HEADER_STYLE_BUTTON + { + switch (position) + { + case LEFT_BUTTON: + pButton->SetPosition(Point(horizontalMargin, verticalMargin)); + break; + + case RIGHT_BUTTON: + pButton->SetPosition(Point(toolbarWidth - buttonWidth - horizontalMargin, verticalMargin)); + break; + + case BACK_BUTTON: + pButton->SetPosition(Point(toolbarWidth - buttonWidth, 0)); + if (__pBackEventListener) + { + pButton->AddActionEventListener(*__pBackEventListener); + pButton->SetActionId(__backActionId); + } + break; + + case MIDDLE_BUTTON: + pButton->SetPosition(Point((toolbarWidth - buttonWidth - horizontalMargin)/2, verticalMargin)); + break; + + default: + break; + } + } + + if (position != BACK_BUTTON && __pActionEventListener != null) + { + pButton->AddActionEventListener(*__pActionEventListener); + } + + if (__pButtonItems[position]) + { + if (position == LEFT_BUTTON) + { + StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT); + } + else if (position == RIGHT_BUTTON) + { + StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT); + } + + if (__pButtonItems[position]->GetChildCount() != 0) + { + _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pButtonItems[position]->GetChild(0)); + SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon."); + + __pButtonItems[position]->DetachChild(*pTempBadgeIcon); + + delete pTempBadgeIcon; + pTempBadgeIcon = null; + } + + DetachChild(*__pButtonItems[position]); + + delete __pButtonItems[position]; + __pButtonItems[position] = null; + } + + __pButtonItems[position] = pButton; + + AttachChild(*pButton); + + if (__style != TOOLBAR_SOFTKEY) + { + ApplyUserGUI(TOOLBAR_BUTTON, __pButtonItems[position]); + } + + RearrangeItems(); + + return E_SUCCESS; +} + +result +_Toolbar::SetButtonColor(_ButtonStatus status, const Color& color) +{ + switch (status) + { + case _BUTTON_STATUS_NORMAL: + __isButtonBgColorSetByUser[_BUTTON_STATUS_NORMAL] = true; + return SetProperty("normalButtonColor", Variant(color)); + break; + case _BUTTON_STATUS_DISABLED: + __isButtonBgColorSetByUser[_BUTTON_STATUS_DISABLED] = true; + return SetProperty("disabledButtonColor", Variant(color)); + break; + case _BUTTON_STATUS_PRESSED: + __isButtonBgColorSetByUser[_BUTTON_STATUS_PRESSED] = true; + return SetProperty("pressedButtonColor", Variant(color)); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + __isButtonBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED] = true; + return SetProperty("highlightedButtonColor", Variant(color)); + break; + default: + __isButtonBgColorSetByUser[_BUTTON_STATUS_NORMAL] = true; + return SetProperty("normalButtonColor", Variant(color)); + break; + } +} + +result +_Toolbar::SetButtonEnabled(ToolbarButton position, bool enabled) +{ + SysTryReturnResult(NID_UI_CTRL, __pButtonItems[position], E_INVALID_OPERATION, + "[E_INVALID_OPERATION] No button item is at the position."); + + if (enabled) + { + __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL); + } + else + { + __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_DISABLED); + } + + return E_SUCCESS; +} + +result +_Toolbar::SetButtonTextColor(_ButtonStatus status, const Color& color) +{ + switch (status) + { + case _BUTTON_STATUS_NORMAL: + __isButtonTextColorSetByUser[_BUTTON_STATUS_NORMAL] = true; + return SetProperty("normalButtonTextColor", Variant(color)); + break; + case _BUTTON_STATUS_DISABLED: + __isButtonTextColorSetByUser[_BUTTON_STATUS_DISABLED] = true; + return SetProperty("disabledButtonTextColor", Variant(color)); + break; + case _BUTTON_STATUS_PRESSED: + __isButtonTextColorSetByUser[_BUTTON_STATUS_PRESSED] = true; + return SetProperty("pressedButtonTextColor", Variant(color)); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + __isButtonTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED] = true; + return SetProperty("highlightedButtonTextColor", Variant(color)); + break; + default: + __isButtonTextColorSetByUser[_BUTTON_STATUS_NORMAL] = true; + return SetProperty("normalButtonTextColor", Variant(color)); + break; + } +} + +result +_Toolbar::SetButtonBadgeIcon(ToolbarButton position, const Bitmap* pBadgeIcon) +{ + int childCount = 0; + + childCount = __pButtonItems[position]->GetChildCount(); + + if (childCount != 0) + { + for(int i = 0; i < childCount; i++) + { + _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pButtonItems[position]->GetChild(i)); + + if (pTempBadgeIcon) + { + __pButtonItems[position]->DetachChild(*pTempBadgeIcon); + + delete pTempBadgeIcon; + pTempBadgeIcon = null; + } + } + } + + if (pBadgeIcon == null) + { + return E_SUCCESS; + } + + Rectangle bounds = __pButtonItems[position]->GetBounds(); + + _Label* pBadgeIconLabel = _Label::CreateLabelN(); + + if (pBadgeIconLabel) + { + pBadgeIconLabel->SetBounds(Rectangle((bounds.width - pBadgeIcon->GetWidth()), 0, + pBadgeIcon->GetWidth(), pBadgeIcon->GetHeight())); + pBadgeIconLabel->SetBackgroundBitmap(*pBadgeIcon); + + __pButtonItems[position]->AttachChild(*pBadgeIconLabel); + __pButtonItems[position]->SetChildAlwaysOnTop(*pBadgeIconLabel); + } + + return E_SUCCESS; +} + +result +_Toolbar::SetButtonNumberedBadgeIcon(ToolbarButton position, int number) +{ + int childCount = 0; + + childCount = __pButtonItems[position]->GetChildCount(); + + _Label* existingBadgeIcon = null; + + if (number == 0) + { + if (childCount != 0) + { + for(int i = 0; i < childCount; i++) + { + existingBadgeIcon = dynamic_cast<_Label*>(__pButtonItems[position]->GetChild(i)); + + if (existingBadgeIcon) + { + __pButtonItems[position]->DetachChild(*existingBadgeIcon); + + delete existingBadgeIcon; + existingBadgeIcon = null; + } + } + } + else + { + return E_SUCCESS; + } + } + else + { + bool needToCreateNewIcon = true; + + if (childCount != 0) + { + for(int i = 0; i < childCount; i++) + { + existingBadgeIcon = dynamic_cast<_Label*>(__pButtonItems[position]->GetChild(i)); + + if (existingBadgeIcon) + { + if (existingBadgeIcon->GetText() == L"") + { + __pButtonItems[position]->DetachChild(*existingBadgeIcon); + + delete existingBadgeIcon; + existingBadgeIcon = null; + + needToCreateNewIcon = true; + } + else + { + needToCreateNewIcon = false; + } + } + } + } + + if (needToCreateNewIcon) + { + _Label* pLabel = _Label::CreateLabelN(); + + SysTryReturnResult(NID_UI_CTRL, pLabel, E_INVALID_STATE, + "[E_INVALID_STATE] The badge icon instance isn't constructed."); + + Bitmap* pNumberedBadgeIconBitmap = null; + Bitmap* pNumberedBadgeIconEffectBitmap = null; + Bitmap* pColorReplacedBitmap = null; + Color badgeIconBgColor; + Color badgeIconTextColor; + + GET_BITMAP_CONFIG_N(HEADER::BADGE_ICON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNumberedBadgeIconBitmap); + GET_BITMAP_CONFIG_N(HEADER::BADGE_ICON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNumberedBadgeIconEffectBitmap); + + GET_COLOR_CONFIG(HEADER::BADGE_ICON_BG_NORMAL, badgeIconBgColor); + GET_COLOR_CONFIG(HEADER::BADGE_ICON_TEXT_NORMAL, badgeIconTextColor); + + if (pNumberedBadgeIconBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNumberedBadgeIconBitmap, + Color::GetColor(COLOR_ID_MAGENTA), badgeIconBgColor); + + pLabel->SetBackgroundBitmap(*pColorReplacedBitmap); + + delete pColorReplacedBitmap; + delete pNumberedBadgeIconBitmap; + } + + if (pNumberedBadgeIconEffectBitmap) + { + pLabel->SetBackgroundEffectBitmap(*pNumberedBadgeIconEffectBitmap); + + delete pNumberedBadgeIconEffectBitmap; + } + + pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER); + pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pLabel->SetTextColor(badgeIconTextColor); + pLabel->SetMargin(0, 0); + + __pButtonItems[position]->AttachChild(*pLabel); + __pButtonItems[position]->SetChildAlwaysOnTop(*pLabel); + + existingBadgeIcon = pLabel; + } + + SysTryReturnResult(NID_UI_CTRL, (existingBadgeIcon), E_INVALID_STATE, "[E_INVALID_STATE] Failed to set a BadgeIcon."); + + Rectangle bounds = __pButtonItems[position]->GetBounds(); + + Integer tempNumber(number); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetText(tempNumber.ToString()); + + int fontSize = 0; + int height = 0; + int width = 0; + + GET_SHAPE_CONFIG(HEADER::BADGE_FONT_SIZE, GetOrientation(), fontSize); + GET_SHAPE_CONFIG(HEADER::BADGE_HEIGHT, GetOrientation(), height); + + existingBadgeIcon->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL); + + if (number < 10) + { + GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_1DIGIT, GetOrientation(), width); + existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height)); + } + else if (number < 100) + { + GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_2DIGIT, GetOrientation(), width); + existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height)); + } + else if (number < 1000) + { + GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_3DIGIT, GetOrientation(), width); + existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height)); + } + else if (number < 10000) + { + GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_4DIGIT, GetOrientation(), width); + existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height)); + } + else + { + GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_5DIGIT, GetOrientation(), width); + existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height)); + } + } + } + + return E_SUCCESS; +} + +result +_Toolbar::SetColor(const Color& color) +{ + return SetProperty("color", Variant(color)); +} + +result +_Toolbar::SetDescriptionText(const String& text) +{ + return SetProperty("descriptionText", Variant(text)); +} + +result +_Toolbar::SetDescriptionTextColor(const Color& color) +{ + return SetProperty("descriptionTextColor", Variant(color)); +} + +result +_Toolbar::SetItemAt(int itemIndex, const _Button* pButton) +{ + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < __itemCount), E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] The itemIndex is out of range."); + + if (pButton->GetActionId() < TOOLBAR_ACTION_ID_MIN || pButton->GetActionId() > TOOLBAR_ACTION_ID_MAX) + { + SysLog(NID_UI_CTRL, "[E_INVALID_ARG] The actionId is invalid."); + return E_OUT_OF_RANGE; + } + + SysTryReturnResult(NID_UI_CTRL, (null != __pItems.at(itemIndex)), E_INVALID_OPERATION, + "[E_INVALID_OPERATION] No button item is at the position."); + + if (__pItems.at(itemIndex)->GetChildCount() != 0) + { + _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pItems.at(itemIndex)->GetChild(0)); + SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon."); + + __pItems.at(itemIndex)->DetachChild(*pTempBadgeIcon); + + delete pTempBadgeIcon; + pTempBadgeIcon = null; + } + + __pItems.at(itemIndex)->SetText(pButton->GetText()); + __pItems.at(itemIndex)->SetActionId(pButton->GetActionId()); + + Bitmap* pIconBitmap = null; + Point iconPosition = Point(0,0); + + pIconBitmap = const_cast(pButton->GetBitmap(_BUTTON_STATUS_NORMAL)); + + if (pIconBitmap) + { + iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_NORMAL); + + __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_NORMAL, iconPosition, *pIconBitmap); + __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_PRESSED, iconPosition, *pIconBitmap); + __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_SELECTED, iconPosition, *pIconBitmap); + __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, iconPosition, *pIconBitmap); + __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_DISABLED, iconPosition, *pIconBitmap); + } + + pIconBitmap = const_cast(pButton->GetBitmap(_BUTTON_STATUS_PRESSED)); + + if (pIconBitmap) + { + iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_PRESSED); + + __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_PRESSED, iconPosition, *pIconBitmap); + } + + pIconBitmap = const_cast(pButton->GetBitmap(_BUTTON_STATUS_SELECTED)); + + if (pIconBitmap) + { + iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_SELECTED); + + __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_SELECTED, iconPosition, *pIconBitmap); + } + + pIconBitmap = const_cast(pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED)); + + if (pIconBitmap) + { + iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_HIGHLIGHTED); + + __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, iconPosition, *pIconBitmap); + } + + pIconBitmap = const_cast(pButton->GetBitmap(_BUTTON_STATUS_DISABLED)); + + if (pIconBitmap) + { + iconPosition = pButton->GetBitmapPosition(_BUTTON_STATUS_DISABLED); + + __pItems.at(itemIndex)->SetBitmap(_BUTTON_STATUS_DISABLED, iconPosition, *pIconBitmap); + } + + ApplyUserGUI(TOOLBAR_ITEM, __pItems.at(itemIndex)); + + RearrangeItems(); + + RealignIcon(__pItems.at(itemIndex)); + + delete pButton; + + return E_SUCCESS; +} + +result +_Toolbar::SetItemBadgeIcon(int itemIndex, const Bitmap* pBadgeIcon) +{ + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < __itemCount), E_INVALID_ARG, + "[E_INVALID_ARG] The itemIndex is invalid."); + + SysTryReturnResult(NID_UI_CTRL, (__pItems.at(itemIndex)), E_INVALID_STATE, + "[E_INVALID_STATE] The badge icon instance isn't constructed."); + + if (__pItems.at(itemIndex)->GetChildCount() != 0) + { + _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pItems.at(itemIndex)->GetChild(0)); + + if (pTempBadgeIcon) + { + __pItems.at(itemIndex)->DetachChild(*pTempBadgeIcon); + + delete pTempBadgeIcon; + pTempBadgeIcon = null; + } + } + + if (pBadgeIcon == null) + { + return E_SUCCESS; + } + + Rectangle bounds = __pItems.at(itemIndex)->GetBounds(); + + _Label* pBadgeIconLabel = _Label::CreateLabelN(); + + if (pBadgeIconLabel) + { + pBadgeIconLabel->SetBounds(Rectangle((bounds.width - pBadgeIcon->GetWidth()), 0, + pBadgeIcon->GetWidth(), pBadgeIcon->GetHeight())); + pBadgeIconLabel->SetBackgroundBitmap(*pBadgeIcon); + + __pItems.at(itemIndex)->AttachChild(*pBadgeIconLabel); + __pItems.at(itemIndex)->SetChildAlwaysOnTop(*pBadgeIconLabel); + } + + return E_SUCCESS; +} + +result +_Toolbar::SetItemColor(_ButtonStatus status, const Color& color) +{ + switch (status) + { + case _BUTTON_STATUS_NORMAL: + __isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL] = true; + return SetProperty("normalItemColor", Variant(color)); + break; + case _BUTTON_STATUS_DISABLED: + __isItemBgColorSetByUser[_BUTTON_STATUS_DISABLED] = true; + return SetProperty("disabledItemColor", Variant(color)); + break; + case _BUTTON_STATUS_PRESSED: + __isItemBgColorSetByUser[_BUTTON_STATUS_PRESSED] = true; + return SetProperty("pressedItemColor", Variant(color)); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + __isItemBgColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED] = true; + return SetProperty("highlightedItemColor", Variant(color)); + break; + case _BUTTON_STATUS_SELECTED: + __isItemBgColorSetByUser[_BUTTON_STATUS_SELECTED] = true; + return SetProperty("selectedItemColor", Variant(color)); + break; + default: + __isItemBgColorSetByUser[_BUTTON_STATUS_NORMAL] = true; + return SetProperty("normalItemColor", Variant(color)); + break; + } +} + +result +_Toolbar::SetItemEnabled(int itemIndex, bool enabled) +{ + SysTryReturnResult(NID_UI_CTRL, (null != __pItems.at(itemIndex)), E_INVALID_OPERATION, + "[E_INVALID_OPERATION] No button item is at the position."); + + if (enabled) + { + return __pItems.at(itemIndex)->SetButtonStatus(_BUTTON_STATUS_NORMAL); + } + else + { + return __pItems.at(itemIndex)->SetButtonStatus(_BUTTON_STATUS_DISABLED); + } + + return E_SUCCESS; +} + +result +_Toolbar::SetItemNumberedBadgeIcon(int itemIndex, int number) +{ + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < __itemCount), E_INVALID_ARG, + "[E_INVALID_ARG] The itemIndex is invalid."); + + SysTryReturnResult(NID_UI_CTRL, (number >= 0 && number < 100000), E_INVALID_ARG, + "[E_INVALID_ARG] The number is out of bounds."); + + SysTryReturnResult(NID_UI_CTRL, (__pItems.at(itemIndex)), E_INVALID_STATE, + "[E_INVALID_STATE] The badge icon instance isn't constructed."); + + if (number == 0) + { + if (__pItems.at(itemIndex)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(itemIndex)->GetChild(0)); + + if (existingBadgeIcon) + { + __pItems.at(itemIndex)->DetachChild(*existingBadgeIcon); + + delete existingBadgeIcon; + existingBadgeIcon = null; + } + } + else + { + return E_SUCCESS; + } + } + else + { + if (__pItems.at(itemIndex)->GetChildCount() == 0) + { + _Label* pLabel = _Label::CreateLabelN(); + + SysTryReturnResult(NID_UI_CTRL, pLabel, E_INVALID_STATE, + "[E_INVALID_STATE] The badge icon instance isn't constructed."); + + Bitmap* pNumberedBadgeIconBitmap = null; + Bitmap* pNumberedBadgeIconEffectBitmap = null; + Bitmap* pColorReplacedBitmap = null; + Color badgeIconBgColor; + Color badgeIconTextColor; + + GET_BITMAP_CONFIG_N(HEADER::BADGE_ICON_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNumberedBadgeIconBitmap); + GET_BITMAP_CONFIG_N(HEADER::BADGE_ICON_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNumberedBadgeIconEffectBitmap); + + GET_COLOR_CONFIG(HEADER::BADGE_ICON_BG_NORMAL, badgeIconBgColor); + GET_COLOR_CONFIG(HEADER::BADGE_ICON_TEXT_NORMAL, badgeIconTextColor); + + if (pNumberedBadgeIconBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNumberedBadgeIconBitmap, + Color::GetColor(COLOR_ID_MAGENTA), badgeIconBgColor); + + pLabel->SetBackgroundBitmap(*pColorReplacedBitmap); + + delete pColorReplacedBitmap; + delete pNumberedBadgeIconBitmap; + } + + if (pNumberedBadgeIconEffectBitmap) + { + pLabel->SetBackgroundEffectBitmap(*pNumberedBadgeIconEffectBitmap); + + delete pNumberedBadgeIconEffectBitmap; + } + + pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER); + pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE); + pLabel->SetTextColor(badgeIconTextColor); + pLabel->SetMargin(0, 0); + + __pItems.at(itemIndex)->AttachChild(*pLabel); + __pItems.at(itemIndex)->SetChildAlwaysOnTop(*pLabel); + } + + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(itemIndex)->GetChild(0)); + + Rectangle bounds = __pItems.at(itemIndex)->GetBounds(); + + Integer tempNumber(number); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetText(tempNumber.ToString()); + + int fontSize = 0; + int height = 0; + int width = 0; + + GET_SHAPE_CONFIG(HEADER::BADGE_FONT_SIZE, GetOrientation(), fontSize); + GET_SHAPE_CONFIG(HEADER::BADGE_HEIGHT, GetOrientation(), height); + + existingBadgeIcon->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL); + + if (number < 10) + { + GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_1DIGIT, GetOrientation(), width); + existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height)); + } + else if (number < 100) + { + GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_2DIGIT, GetOrientation(), width); + existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height)); + } + else if (number < 1000) + { + GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_3DIGIT, GetOrientation(), width); + existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height)); + } + else if (number < 10000) + { + GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_4DIGIT, GetOrientation(), width); + existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height)); + } + else + { + GET_SHAPE_CONFIG(HEADER::BADGE_WIDTH_5DIGIT, GetOrientation(), width); + existingBadgeIcon->SetBounds(Rectangle(bounds.width - width, 0, width, height)); + } + } + } + + return E_SUCCESS; +} + +result +_Toolbar::SetItemSelected(int itemIndex, bool fire) +{ + SysTryReturnResult(NID_UI_CTRL, (itemIndex >= -1 && itemIndex < __itemCount), E_INVALID_STATE, + "[E_INVALID_STATE] Failed to process SetItemSelected()"); + + result r = E_SUCCESS; + + int currentSelectedItemIndex = 0; + currentSelectedItemIndex = GetSelectedItemIndex(); + + if (__pToolbarPresenter) + { + r = __pToolbarPresenter->SetItemSelected(itemIndex); + } + + if (itemIndex != -1 && itemIndex == currentSelectedItemIndex && __pItems.at(itemIndex) != null) + { + __pItems.at(itemIndex)->SetButtonStatus(_BUTTON_STATUS_SELECTED, fire); + __pItems.at(itemIndex)->Draw(); + + return r; + } + + if (__itemCount == 0 || __itemCount > TAB_ITEM_MAX || itemIndex == -1) + { + return r; + } + + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_INVALID_STATE, "[E_INVALID_STATE] Failed to process SetItemSelected()"); + + if (__pItems.at(itemIndex) != null) + { + __pItems.at(itemIndex)->SetButtonStatus(_BUTTON_STATUS_SELECTED, fire); + } + + if (__itemCount == 0 || __itemCount > TAB_ITEM_MAX || itemIndex == -1) + { + return r; + } + + if (currentSelectedItemIndex != -1 && __pItems.at(currentSelectedItemIndex) != null) + { + __pItems.at(currentSelectedItemIndex)->SetButtonStatus(_BUTTON_STATUS_NORMAL); + __pItems.at(currentSelectedItemIndex)->Draw(); + } + + if (__pItems.at(itemIndex) != null) + { + __pItems.at(itemIndex)->Draw(); + } + + return r; +} + +result +_Toolbar::SetItemTextColor(_ButtonStatus status, const Color& color) +{ + switch(status) + { + case _BUTTON_STATUS_NORMAL: + __isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL] = true; + return SetProperty("normalItemTextColor", Variant(color)); + break; + case _BUTTON_STATUS_DISABLED: + __isItemTextColorSetByUser[_BUTTON_STATUS_DISABLED] = true; + return SetProperty("disabledItemTextColor", Variant(color)); + break; + case _BUTTON_STATUS_PRESSED: + __isItemTextColorSetByUser[_BUTTON_STATUS_PRESSED] = true; + return SetProperty("pressedItemTextColor", Variant(color)); + break; + case _BUTTON_STATUS_HIGHLIGHTED: + __isItemTextColorSetByUser[_BUTTON_STATUS_HIGHLIGHTED] = true; + return SetProperty("highlightedItemTextColor", Variant(color)); + break; + case _BUTTON_STATUS_SELECTED: + __isItemTextColorSetByUser[_BUTTON_STATUS_SELECTED] = true; + return SetProperty("selectedItemTextColor", Variant(color)); + break; + default: + __isItemTextColorSetByUser[_BUTTON_STATUS_NORMAL] = true; + return SetProperty("normalItemTextColor", Variant(color)); + break; + } +} + +result +_Toolbar::SetStyle(ToolbarStyle style) +{ + __style = style; + + if (__pToolbarPresenter) + { + __pToolbarPresenter->SetInitialDrawState(true); + } + + if (__style == TOOLBAR_TAB || __style == TOOLBAR_TAB_WITH_TITLE) + { + SetTabEditModeEnabled(true); + } + + AdjustToolbarBounds(); + + InitToolbarColor(); + + __titleText = L""; + + __descriptionText = L""; + + if(__pTitleTextElement) + { + __pTitleTextElement->SetLabel(L""); + } + + + return E_SUCCESS; +} + +result +_Toolbar::AdjustToolbarBounds(void) +{ + int width = 0; + int height = 0; + + SetResizable(true); + + if (__header == true) + { + if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE) + { + GET_SHAPE_CONFIG(HEADER::WIDTH, GetOrientation(), width); + GET_SHAPE_CONFIG(HEADER::TITLE_TOTAL_HEIGHT_WITH_SEGMENTED_ITEM, GetOrientation(), height); + SetSize(Dimension(width, height)); + } + else + { + GET_SHAPE_CONFIG(HEADER::WIDTH, GetOrientation(), width); + GET_SHAPE_CONFIG(HEADER::HEIGHT, GetOrientation(), height); + SetSize(Dimension(width, height)); + } + } + else + { + GET_SHAPE_CONFIG(FOOTER::WIDTH, GetOrientation(), width); + + if (__style == TOOLBAR_SOFTKEY) + { + GET_SHAPE_CONFIG(FOOTER::SOFTKEY_HEIGHT, GetOrientation(), height); + } + else + { + GET_SHAPE_CONFIG(FOOTER::HEIGHT, GetOrientation(), height); + } + + SetSize(Dimension(width, height)); + } + + SetResizable(false); + + _Form* pParent = dynamic_cast<_Form*>(GetParent()); + + if (pParent != null) + { + pParent->AdjustClientBounds(); + + if (__header == false) + { + Rectangle bounds(0, pParent->GetBounds().height - height, width, height); + + pParent->SetFooterBounds(bounds); + } + } + + return E_SUCCESS; +} + +result +_Toolbar::SetTabEditModeEnabled(bool enable) +{ + if (__pToolbarPresenter) + { + return __pToolbarPresenter->SetTabEditModeEnabled(enable); + } + + return E_SUCCESS; +} + +result +_Toolbar::SetTitleIcon(const Bitmap& bitmap) +{ + result r = E_SYSTEM; + + Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap); + + if (pClonedBitmap) + { + if (__pTitleIcon) + { + delete __pTitleIcon; + } + + __pTitleIcon = pClonedBitmap; + + r = E_SUCCESS; + } + + return r; +} + +result +_Toolbar::SetTitleText(const String& text, HorizontalAlignment alignment) +{ + __titleText = text; + __titleTextAlignment = alignment; + + RearrangeItems(); + + if (__pToolbarPresenter) + { + return __pToolbarPresenter->SetTitleText(__titleText, __titleTextAlignment); + } + + if(__pTitleTextElement) + { + __pTitleTextElement->SetLabel(__titleText + L", " + __descriptionText); + } + return E_SUCCESS; +} + +result +_Toolbar::SetTitleTextColor(const Color& color) +{ + __titleTextColor = color; + + return E_SUCCESS; +} + +result +_Toolbar::SetTransparent(bool transparent) +{ + if (__style == TOOLBAR_SOFTKEY) + { + return E_SUCCESS; + } + + __transparent = transparent; + + InitToolbarColor(); + + __isUserBackgroundBitmap = true; + + + Bitmap* pMagentaBackgroundBitmap = null; + + if (__pToolbarBackgroundBitmap) + { + delete __pToolbarBackgroundBitmap; + __pToolbarBackgroundBitmap = null; + } + + GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pMagentaBackgroundBitmap); + + if (__transparent) + { + Color tempColor; + + GET_COLOR_CONFIG(HEADER::TRANSLUCENT_BG_NORMAL, tempColor); + + if (pMagentaBackgroundBitmap) + { + __pToolbarBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pMagentaBackgroundBitmap), + Color::GetColor(COLOR_ID_MAGENTA), tempColor); + + if (__pToolbarBackgroundBitmap) + { + __pToolbarBackgroundBitmap->SetAlphaConstant(0x7F); + } + } + + SetTitleTextColor(__transTitleTextColor); + SetDescriptionTextColor(__transDescriptionTextColor); + + for (int i = 0; i < __itemCount ; i ++) + { + if (__pItems.at(i) != null) + { + ApplyUserGUI(TOOLBAR_ITEM, __pItems.at(i)); + } + } + + for (int i = 0; i < BUTTON_MAX; i++) + { + if (__pButtonItems[i] != null) + { + ApplyUserGUI(TOOLBAR_BUTTON, __pButtonItems[i]); + } + } + } + else // not transparent + { + __pToolbarBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pMagentaBackgroundBitmap), + Color::GetColor(COLOR_ID_MAGENTA), GetColor()); + + SetTitleTextColor(__titleTextColor); + SetDescriptionTextColor(__descriptionTextColor); + + for (int i = 0; i < __itemCount ; i ++) + { + if (__pItems.at(i) != null) + { + ApplyUserGUI(TOOLBAR_ITEM, __pItems.at(i)); + } + } + + for (int i = 0; i < BUTTON_MAX; i++) + { + if (__pButtonItems[i] != null) + { + ApplyUserGUI(TOOLBAR_BUTTON, __pButtonItems[i]); + } + } + } + + delete pMagentaBackgroundBitmap; + + return E_SUCCESS; +} + +result +_Toolbar::SetWaitingAnimationPosition(ToolbarAnimationPosition animationPos, int x, int y) +{ + if (__pAnimation[animationPos]) + { + __pAnimation[animationPos]->SetPosition(Point(x, y)); + } + + return E_SUCCESS; +} + +result +_Toolbar::StopWaitingAnimation(ToolbarAnimationPosition animationPos) +{ + SysTryReturnResult(NID_UI_CTRL, + (TOOLBAR_ANIMATION_POSITION_TITLE <= animationPos && animationPos < TOOLBAR_ANIMATION_POSITION_MAX), E_INVALID_ARG, + "[E_INVALID_ARG] The animationPos is invalid."); + SysTryReturnResult(NID_UI_CTRL, (__pAnimation[animationPos]), E_INVALID_STATE, + "[E_INVALID_STATE] __pAnimation isn't constructed."); + + __pAnimation[animationPos]->Stop(); + + if (animationPos == TOOLBAR_ANIMATION_POSITION_TITLE) + { + DetachChild(*__pAnimation[animationPos]); + } + else if (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT && __pButtonItems[LEFT_BUTTON] != null) + { + __pButtonItems[LEFT_BUTTON]->DetachChild(*__pAnimation[animationPos]); + } + else if (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT && __pButtonItems[RIGHT_BUTTON] != null) + { + __pButtonItems[RIGHT_BUTTON]->DetachChild(*__pAnimation[animationPos]); + } + + delete __pAnimation[animationPos]; + __pAnimation[animationPos] = null; + + return E_SUCCESS; +} + +void +_Toolbar::OnAnimationStopped(const _Control& source) +{ + ClearLastResult(); + + if (&source == __pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT]) + { + __pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT]->Play(); + } + else if (&source == __pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT]) + { + __pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT]->Play(); + } + else if (__pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE]) + { + __pAnimation[TOOLBAR_ANIMATION_POSITION_TITLE]->Play(); + } + + return; +} + +result +_Toolbar::OnAttachedToMainTree(void) +{ + InitializeAccessibilityElement(); + + return E_SUCCESS; +} + +void +_Toolbar::InitializeAccessibilityElement(void) +{ + if(likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + _AccessibilityElement* pButtonElement = null; + if(pContainer == null) + { + return; + } + int priorty = 0; + if(__header) + { + priorty = ACCESSIBILITY_PRIORTY_TOP; + } + else + { + priorty = ACCESSIBILITY_PRIORTY_BOTTOM; + } + pContainer->SetPriority(priorty); + + ToolbarStyle style = GetStyle(); + if(style == TOOLBAR_TITLE || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE) + { + if (__pTitleTextElement == null) + { + __pTitleTextElement = new (std::nothrow) _AccessibilityElement(true); + SysTryReturnVoidResult(NID_UI_CTRL, __pTitleTextElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + pContainer->AddElement(*__pTitleTextElement); + } + + __pTitleTextElement->SetBounds(__pToolbarPresenter->GetTitleTextBounds()); + if( __descriptionText.IsEmpty()) + { + __pTitleTextElement->SetLabel(__titleText); + } + else + { + __pTitleTextElement->SetLabel(__titleText + L"," + __descriptionText); + } + __pTitleTextElement->SetTrait(L"Title"); + __pTitleTextElement->SetName(L"HeaderTitleText"); + } + else + { + if(__pTitleTextElement) + { + pContainer->RemoveElement(*__pTitleTextElement); + __pTitleTextElement = null; + } + } + + if (__pButtonItems[LEFT_BUTTON]) + { + _AccessibilityContainer* pButtonContainer = __pButtonItems[LEFT_BUTTON]->GetAccessibilityContainer(); + + if (pButtonContainer) + { + pButtonContainer->SetPriority(priorty); + pContainer->AddChildContainer(*pButtonContainer); + pButtonElement = pButtonContainer->GetChildElement(L"ButtonText"); + } + + if(pButtonElement) + { + pButtonElement->SetName(L"LeftButton"); + pButtonElement->SetTrait(L"Button"); + pButtonElement = null; + } + } + + if (__pButtonItems[RIGHT_BUTTON]) + { + _AccessibilityContainer* pButtonContainer = __pButtonItems[RIGHT_BUTTON]->GetAccessibilityContainer(); + + if (pButtonContainer) + { + pButtonContainer->SetPriority(priorty); + pContainer->AddChildContainer(*pButtonContainer); + pButtonElement = pButtonContainer->GetChildElement(L"ButtonText"); + } + + if(pButtonElement) + { + pButtonElement->SetName(L"RightButton"); + pButtonElement->SetTrait(L"Button"); + pButtonElement = null; + } + } + + if (__pButtonItems[BACK_BUTTON]) + { + _AccessibilityContainer* pButtonContainer = __pButtonItems[BACK_BUTTON]->GetAccessibilityContainer(); + + if (pButtonContainer) + { + pButtonContainer->SetPriority(priorty); + pContainer->AddChildContainer(*pButtonContainer); + pButtonElement = pButtonContainer->GetChildElement(L"ButtonText"); + } + + if(pButtonElement) + { + pButtonElement->SetName(L"BackButton"); + pButtonElement->SetLabel(L"Back"); + pButtonElement->SetTrait(L"Back button"); + pButtonElement = null; + } + } + + if (__pButtonItems[MIDDLE_BUTTON]) + { + _AccessibilityContainer* pButtonContainer = __pButtonItems[MIDDLE_BUTTON]->GetAccessibilityContainer(); + + if (pButtonContainer) + { + pButtonContainer->SetPriority(priorty); + pContainer->AddChildContainer(*pButtonContainer); + pButtonElement = pButtonContainer->GetChildElement(L"ButtonText"); + } + + if(pButtonElement) + { + pButtonElement->SetName(L"MiddleButton"); + pButtonElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON); + pButtonElement = null; + } + } + + return; +} + +void +_Toolbar::AddAccessibilityItem(_Button* pButton) +{ + if(likely(!(_AccessibilityManager::IsActivated()))) + { + return; + } + + _AccessibilityContainer* pContainer = GetAccessibilityContainer(); + if(pContainer == null) + { + return; + } + + int priorty = 0; + if(__header) + { + priorty = ACCESSIBILITY_PRIORTY_TOP; + } + else + { + priorty = ACCESSIBILITY_PRIORTY_BOTTOM; + } + pContainer->SetPriority(priorty); + + ToolbarStyle style = GetStyle(); + AccessibilityTraits trait = ACCESSIBILITY_TRAITS_BUTTON; + String name = L"Button" + Integer::ToString(__itemCount); + + switch (style) + { + case TOOLBAR_HEADER_SEGMENTED_WITH_TITLE: + //fall through + case TOOLBAR_SEGMENTED: + name = L"Segment" + Integer::ToString(__itemCount); + trait = ACCESSIBILITY_TRAITS_SEGMENT; + break; + case TOOLBAR_TAB: + name = L"Tab" + Integer::ToString(__itemCount); + trait = ACCESSIBILITY_TRAITS_TAB; + break; + default: + break; + } + + if (pButton != null) + { + _AccessibilityElement* pElement = null; + _AccessibilityContainer* pButtonContainer = pButton->GetAccessibilityContainer(); + + if (pButtonContainer) + { + pButtonContainer->SetPriority(priorty); + pContainer->AddChildContainer(*pButtonContainer); + pElement = pButtonContainer->GetChildElement(L"ButtonText"); + } + + if(pElement) + { + pElement->SetName(name); + pElement->SetTrait(trait); + pElement->SetHint(L"Double tap to move to contents"); + } + } + + return; +} + +void +_Toolbar::OnBoundsChanged(void) +{ + if(__pTitleTextElement) + { + __pTitleTextElement->SetBounds(__pToolbarPresenter->GetTitleTextBounds()); + } + + RearrangeItems(); + + return; +} + +void +_Toolbar::OnFontChanged(Font* pFont) +{ + __pToolbarPresenter->OnFontChanged(pFont); + + return; +} + +void +_Toolbar::OnFontInfoRequested(unsigned long& style, int& size) +{ + __pToolbarPresenter->OnFontInfoRequested(style, size); + + return; +} + +void +_Toolbar::OnChangeLayout(_ControlOrientation orientationStatus) +{ + int toolbarWidth = GetBounds().width; + + if (CalculateMinimumToolbarWidth() > toolbarWidth) + { + toolbarWidth = CalculateMinimumToolbarWidth(); + } + + AdjustToolbarBounds(); + + RearrangeItems(); + + return; +} + +void +_Toolbar::OnDraw(void) +{ + ClearLastResult(); + + if (__pToolbarPresenter) + { + __pToolbarPresenter->Draw(); + + InitializeAccessibilityElement(); + } + + return; +} + +bool +_Toolbar::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture) +{ + //if (__tabExpanded != true) + //{ + // return true; + //} + + //if (__pToolbarPresenter) + //{ + // return __pToolbarPresenter->OnLongPressGestureDetected(); + //} + + return true; +} + +bool +_Toolbar::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture) +{ + return false; +} + +bool +_Toolbar::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + if (__pToolbarPresenter) + { + return __pToolbarPresenter->OnTouchPressed(source, touchinfo); + } + + return true; +} + +bool +_Toolbar::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + if (__pToolbarPresenter) + { + return __pToolbarPresenter->OnTouchReleased(source, touchinfo); + } + + return true; +} + +bool +_Toolbar::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + if (__pToolbarPresenter) + { + return __pToolbarPresenter->OnTouchMoved(source, touchinfo); + } + + return true; +} + +bool +_Toolbar::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + ClearLastResult(); + + if (__pToolbarPresenter) + { + return __pToolbarPresenter->OnTouchCanceled(source, touchinfo); + } + + return true; +} + +void +_Toolbar::AddActionEventListener(const Controls::_IActionEventListener& listener) +{ + __pActionEventListener = const_cast(&listener); + + for (int i = 0; i < __itemCount; i++) + { + __pItems.at(i)->AddActionEventListener(listener); + } + + for (int j = 0; j < BUTTON_MAX; j++) + { + if (__pButtonItems[j]) + { + __pButtonItems[j]->AddActionEventListener(listener); + } + } + + return; +} + +void +_Toolbar::RemoveActionEventListener(const Controls::_IActionEventListener& listener) +{ + __pActionEventListener = null; + + for (int i = 0; i < __itemCount; i++) + { + __pItems.at(i)->RemoveActionEventListener(listener); + } + + for (int j = 0; j < MIDDLE_BUTTON; j++) + { + if (__pButtonItems[j]) + { + __pButtonItems[j]->RemoveActionEventListener(listener); + } + } + + return; + +} + +void +_Toolbar::SetBackEventListener(const Controls::_IActionEventListener& listener, int actionId) +{ + __backActionId = actionId; + __pBackEventListener = const_cast<_IActionEventListener*>(&listener); + + return; +} + +result +_Toolbar::SetPresenter(const _ToolbarPresenter& toolbarPresenter) +{ + __pToolbarPresenter = const_cast<_ToolbarPresenter*>(&toolbarPresenter); + + return E_SUCCESS; +} + +result +_Toolbar::ApplyUserGUI(ButtonType buttonType, _Button* pButton) +{ + SysTryReturnResult(NID_UI_CTRL, pButton, E_INVALID_ARG, "[E_INVALID_ARG] The pButton is invalid."); + + if (TOOLBAR_BUTTON == buttonType) + { + Bitmap* pNormalBackgroundBitmap = null; + Bitmap* pColorReplacedBitmap = null; + + if (__header) + { + GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap); + } + else + { + GET_BITMAP_CONFIG_N(FOOTER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap); + } + + if (__transparent) + { + pButton->SetTextColor(_BUTTON_STATUS_NORMAL, __buttonTransTextColor[_BUTTON_STATUS_NORMAL]); + pButton->SetTextColor(_BUTTON_STATUS_PRESSED, __buttonTransTextColor[_BUTTON_STATUS_PRESSED]); + pButton->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __buttonTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + pButton->SetTextColor(_BUTTON_STATUS_DISABLED, __buttonTransTextColor[_BUTTON_STATUS_DISABLED]); + + if (pNormalBackgroundBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __buttonTransBackgroundColor[_BUTTON_STATUS_NORMAL]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __buttonTransBackgroundColor[_BUTTON_STATUS_PRESSED]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __buttonTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __buttonTransBackgroundColor[_BUTTON_STATUS_DISABLED]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + delete pNormalBackgroundBitmap; + } + } + else + { + pButton->SetTextColor(_BUTTON_STATUS_NORMAL, __buttonTextColor[_BUTTON_STATUS_NORMAL]); + pButton->SetTextColor(_BUTTON_STATUS_PRESSED, __buttonTextColor[_BUTTON_STATUS_PRESSED]); + pButton->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + pButton->SetTextColor(_BUTTON_STATUS_DISABLED, __buttonTextColor[_BUTTON_STATUS_DISABLED]); + + if (pNormalBackgroundBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __buttonBackgroundColor[_BUTTON_STATUS_NORMAL]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __buttonBackgroundColor[_BUTTON_STATUS_PRESSED]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __buttonBackgroundColor[_BUTTON_STATUS_DISABLED]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + delete pNormalBackgroundBitmap; + } + } + } + else if (TOOLBAR_ITEM == buttonType) + { + Bitmap* pNormalBackgroundBitmap = null; + Bitmap* pPressedBackgroundBitmap = null; + Bitmap* pNormalBackgroundEffectBitmap = null; + Bitmap* pPressedBackgroundEffectBitmap = null; + Bitmap* pColorReplacedBitmap = null; + + if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT) + { + GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap); + GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedBackgroundBitmap); + GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundEffectBitmap); + GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedBackgroundEffectBitmap); + } + else + { + GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pNormalBackgroundBitmap); + GET_BITMAP_CONFIG_N(HEADER::TAB_ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedBackgroundBitmap); + } + + if (pNormalBackgroundEffectBitmap) + { + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_NORMAL, *pNormalBackgroundEffectBitmap); + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pNormalBackgroundEffectBitmap); + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_DISABLED, *pNormalBackgroundEffectBitmap); + delete pNormalBackgroundEffectBitmap; + } + + if (pPressedBackgroundEffectBitmap) + { + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_PRESSED, *pPressedBackgroundEffectBitmap); + pButton->SetBackgroundEffectBitmap(_BUTTON_STATUS_SELECTED, *pPressedBackgroundEffectBitmap); + delete pPressedBackgroundEffectBitmap; + } + + if (__transparent) + { + pButton->SetTextColor(_BUTTON_STATUS_NORMAL, __itemTransTextColor[_BUTTON_STATUS_NORMAL]); + pButton->SetTextColor(_BUTTON_STATUS_PRESSED, __itemTransTextColor[_BUTTON_STATUS_PRESSED]); + pButton->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __itemTransTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + pButton->SetTextColor(_BUTTON_STATUS_DISABLED, __itemTransTextColor[_BUTTON_STATUS_DISABLED]); + pButton->SetTextColor(_BUTTON_STATUS_SELECTED, __itemTransTextColor[_BUTTON_STATUS_SELECTED]); + + if (pNormalBackgroundBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __itemTransBackgroundColor[_BUTTON_STATUS_NORMAL]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __itemTransBackgroundColor[_BUTTON_STATUS_SELECTED]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_SELECTED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __itemTransBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __itemTransBackgroundColor[_BUTTON_STATUS_DISABLED]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + delete pNormalBackgroundBitmap; + } + + if (pPressedBackgroundBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __itemTransBackgroundColor[_BUTTON_STATUS_PRESSED]); + + pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + delete pPressedBackgroundBitmap; + } + } + else + { + pButton->SetTextColor(_BUTTON_STATUS_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]); + pButton->SetTextColor(_BUTTON_STATUS_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]); + pButton->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + pButton->SetTextColor(_BUTTON_STATUS_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]); + pButton->SetTextColor(_BUTTON_STATUS_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]); + + if (pNormalBackgroundBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __itemBackgroundColor[_BUTTON_STATUS_NORMAL]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __itemBackgroundColor[_BUTTON_STATUS_SELECTED]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_SELECTED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pNormalBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __itemBackgroundColor[_BUTTON_STATUS_DISABLED]); + pButton->SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + delete pNormalBackgroundBitmap; + } + + if (pPressedBackgroundBitmap) + { + pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedBackgroundBitmap, + Color::GetColor(COLOR_ID_MAGENTA), __itemBackgroundColor[_BUTTON_STATUS_PRESSED]); + + pButton->SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, *pColorReplacedBitmap); + delete pColorReplacedBitmap; + + delete pPressedBackgroundBitmap; + } + } + } + + return E_SUCCESS; +} + +int +_Toolbar::CalculateMinimumToolbarWidth(void) +{ + int totalWidth = 0; + int itemMinimumWidth = 0; + int horizontalMargin = 0; + + if (__header == true && __style == TOOLBAR_TEXT) + { + if (IsButtonSet(LEFT_BUTTON)) + { + //if (__pButtonItems[LEFT_BUTTON]->GetText().IsEmpty()) + //{ + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth); + //} + //else + //{ + // GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH_WITH_TEXT, GetOrientation(), itemMinimumWidth); + //} + + totalWidth += itemMinimumWidth; + } + if (IsButtonSet(RIGHT_BUTTON)) + { + //if (__pButtonItems[RIGHT_BUTTON]->GetText().IsEmpty()) + //{ + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth); + //} + //else + //{ + // GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH_WITH_TEXT, GetOrientation(), itemMinimumWidth); + //} + + totalWidth += itemMinimumWidth; + } + } + else // footer or HEADER_TITLE_BUTTON + { + if (IsButtonSet(LEFT_BUTTON)) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth); + totalWidth += itemMinimumWidth; + } + if (IsButtonSet(RIGHT_BUTTON)) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth); + totalWidth += itemMinimumWidth; + } + else if (IsButtonSet(BACK_BUTTON)) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetOrientation(), itemMinimumWidth); + totalWidth += itemMinimumWidth; + } + } + + if (__style == TOOLBAR_TITLE) + { + GET_SHAPE_CONFIG(HEADER::TITLE_MINIMUM_WIDTH, GetOrientation(), itemMinimumWidth); + totalWidth += itemMinimumWidth; + } + else if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_HEADER_SEGMENTED) + { + GET_SHAPE_CONFIG(HEADER::ITEM_MINIMUM_WIDTH, GetOrientation(), itemMinimumWidth); + GET_SHAPE_CONFIG(HEADER::COMMON_MINIMUM_MARGIN, GetOrientation(), horizontalMargin); + totalWidth += itemMinimumWidth * __itemCount + horizontalMargin * 2; + } + else if (__style == TOOLBAR_SEGMENTED) + { + GET_SHAPE_CONFIG(FOOTER::ITEM_MINIMUM_WIDTH, GetOrientation(), itemMinimumWidth); + GET_SHAPE_CONFIG(FOOTER::COMMON_MINIMUM_MARGIN, GetOrientation(), horizontalMargin); + totalWidth += itemMinimumWidth * __itemCount + horizontalMargin * 2; + } + else + { + GET_SHAPE_CONFIG(FOOTER::ITEM_MINIMUM_WIDTH, GetOrientation(), itemMinimumWidth); + + if ((__style == TOOLBAR_TAB || __style == TOOLBAR_TAB_WITH_TITLE) && __itemCount > 4) + { + totalWidth += itemMinimumWidth * 4; + } + else + { + totalWidth += itemMinimumWidth * __itemCount; + } + } + + return totalWidth; +} + +result +_Toolbar::RealignIcon(_Button* pButton) +{ + SysTryReturnResult(NID_UI_CTRL, pButton, E_INVALID_STATE, "[E_INVALID_STATE] pButton doesn't exist."); + + int buttonItemWidth = pButton->GetSize().width; + int buttonItemHeight = pButton->GetSize().height; + int sideMargin = 0; + int buttonTextTopMargin = 0; + int iconTextGap = 0; + int contentLength = 0; + int textExtentSize = pButton->GetTextExtentSize(); + int segmentedTextAreaHeight = 0; + int revisedTopMargin = 5; + + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_LEFT_MARGIN, GetOrientation(), sideMargin); + GET_SHAPE_CONFIG(HEADER::ICON_TEXT_GAP, GetOrientation(), iconTextGap); + GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, GetOrientation(), segmentedTextAreaHeight); + + if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT) + { + GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_BUTTON_STYLE_SIDE_MARGIN, GetOrientation(), sideMargin); + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_TOP_MARGIN, GetOrientation(), buttonTextTopMargin); + } + else if (__style == TOOLBAR_HEADER_SEGMENTED || __style == TOOLBAR_SEGMENTED || __style == TOOLBAR_TAB) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_LEFT_MARGIN, GetOrientation(), sideMargin); + + buttonTextTopMargin = (buttonItemHeight - segmentedTextAreaHeight) / 2 - revisedTopMargin; + } + else if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_LEFT_MARGIN, GetOrientation(), sideMargin); + + buttonTextTopMargin = 0; + } + + if (pButton->GetText() != L"") + { + int iconAreaWidth = 0; + + if (pButton->GetBitmap(_BUTTON_STATUS_NORMAL) != null) + { + iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_NORMAL)->GetWidth(); + contentLength = iconAreaWidth + iconTextGap + textExtentSize; + + if (contentLength > buttonItemWidth - sideMargin * 2) + { + contentLength = buttonItemWidth - sideMargin * 2; + } + + pButton->SetBitmap(_BUTTON_STATUS_NORMAL, + Point((buttonItemWidth - contentLength) / 2, (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_NORMAL))->GetHeight()) / 2), + *(pButton->GetBitmap(_BUTTON_STATUS_NORMAL))); + } + if (pButton->GetBitmap(_BUTTON_STATUS_PRESSED) != null) + { + iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_PRESSED)->GetWidth(); + contentLength = iconAreaWidth + iconTextGap + textExtentSize; + + if (contentLength > buttonItemWidth - sideMargin * 2) + { + contentLength = buttonItemWidth - sideMargin * 2; + } + + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, + Point((buttonItemWidth - contentLength) / 2, (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_PRESSED))->GetHeight()) / 2), + *(pButton->GetBitmap(_BUTTON_STATUS_PRESSED))); + } + if (pButton->GetBitmap(_BUTTON_STATUS_SELECTED) != null) + { + iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_SELECTED)->GetWidth(); + contentLength = iconAreaWidth + iconTextGap + textExtentSize; + + if (contentLength > buttonItemWidth - sideMargin * 2) + { + contentLength = buttonItemWidth - sideMargin * 2; + } + + pButton->SetBitmap(_BUTTON_STATUS_SELECTED, + Point((buttonItemWidth - contentLength) / 2, (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_SELECTED))->GetHeight()) / 2), + *(pButton->GetBitmap(_BUTTON_STATUS_SELECTED))); + } + if (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED) != null) + { + iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED)->GetWidth(); + contentLength = iconAreaWidth + iconTextGap + textExtentSize; + + if (contentLength > buttonItemWidth - sideMargin * 2) + { + contentLength = buttonItemWidth - sideMargin * 2; + } + + pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, + Point((buttonItemWidth - contentLength) / 2, (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED))->GetHeight()) / 2), + *(pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED))); + } + if (pButton->GetBitmap(_BUTTON_STATUS_DISABLED) != null) + { + iconAreaWidth = pButton->GetBitmap(_BUTTON_STATUS_DISABLED)->GetWidth(); + contentLength = iconAreaWidth + iconTextGap + textExtentSize; + + if (contentLength > buttonItemWidth - sideMargin * 2) + { + contentLength = buttonItemWidth - sideMargin * 2; + } + + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, + Point((buttonItemWidth - contentLength) / 2, (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_DISABLED))->GetHeight()) / 2), + *(pButton->GetBitmap(_BUTTON_STATUS_DISABLED))); + } + + if (iconAreaWidth != 0) + { + pButton->SetTextHorizontalAlignment(ALIGNMENT_LEFT); + pButton->SetUserDefinedTextArea(Rectangle((buttonItemWidth - contentLength) / 2 + iconAreaWidth + iconTextGap, buttonTextTopMargin, buttonItemWidth - iconAreaWidth - iconTextGap - sideMargin * 2, buttonItemHeight - buttonTextTopMargin * 2)); + } + else + { + pButton->SetUserDefinedTextArea(Rectangle(sideMargin, buttonTextTopMargin, buttonItemWidth - sideMargin * 2, buttonItemHeight - buttonTextTopMargin * 2)); + } + } + else + { + if (pButton->GetBitmap(_BUTTON_STATUS_NORMAL) != null) + { + pButton->SetBitmap(_BUTTON_STATUS_NORMAL, + Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_NORMAL))->GetWidth()) / 2, + (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_NORMAL))->GetHeight()) / 2), + *(pButton->GetBitmap(_BUTTON_STATUS_NORMAL))); + } + if (pButton->GetBitmap(_BUTTON_STATUS_PRESSED) != null) + { + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, + Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_PRESSED))->GetWidth()) / 2, + (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_PRESSED))->GetHeight()) / 2), + *(pButton->GetBitmap(_BUTTON_STATUS_PRESSED))); + } + if (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED) != null) + { + pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, + Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED))->GetWidth()) / 2, + (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED))->GetHeight()) / 2), + *(pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED))); + } + if (pButton->GetBitmap(_BUTTON_STATUS_DISABLED) != null) + { + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, + Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_DISABLED))->GetWidth()) / 2, + (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_DISABLED))->GetHeight()) / 2), + *(pButton->GetBitmap(_BUTTON_STATUS_DISABLED))); + } + if (pButton->GetBitmap(_BUTTON_STATUS_SELECTED) != null) + { + pButton->SetBitmap(_BUTTON_STATUS_SELECTED, + Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_SELECTED))->GetWidth()) / 2, + (buttonItemHeight - (pButton->GetBitmap(_BUTTON_STATUS_SELECTED))->GetHeight()) / 2), + *(pButton->GetBitmap(_BUTTON_STATUS_SELECTED))); + } + + pButton->SetMargin(buttonTextTopMargin, sideMargin); + } + + return E_SUCCESS; +} + +result +_Toolbar::RealignButtonIcon(_Button* pButton) +{ + SysTryReturnResult(NID_UI_CTRL, pButton, E_INVALID_STATE, "[E_INVALID_STATE] pButton doesn't exist."); + + int buttonItemWidth = pButton->GetSize().width; + int iconTopMargin = 0; + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_ICON_TOP_MARGIN, GetOrientation(), iconTopMargin); + + if (pButton->GetBitmap(_BUTTON_STATUS_NORMAL) != null) + { + pButton->SetBitmap(_BUTTON_STATUS_NORMAL, + Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_NORMAL))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_NORMAL))); + } + if (pButton->GetBitmap(_BUTTON_STATUS_PRESSED) != null) + { + pButton->SetBitmap(_BUTTON_STATUS_PRESSED, + Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_PRESSED))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_PRESSED))); + } + if (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED) != null) + { + pButton->SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, + Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED))); + } + if (pButton->GetBitmap(_BUTTON_STATUS_DISABLED) != null) + { + pButton->SetBitmap(_BUTTON_STATUS_DISABLED, + Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_DISABLED))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_DISABLED))); + } + if (pButton->GetBitmap(_BUTTON_STATUS_SELECTED) != null) + { + pButton->SetBitmap(_BUTTON_STATUS_SELECTED, + Point((buttonItemWidth - (pButton->GetBitmap(_BUTTON_STATUS_SELECTED))->GetWidth()) / 2, iconTopMargin), *(pButton->GetBitmap(_BUTTON_STATUS_SELECTED))); + } + + return E_SUCCESS; +} + +result +_Toolbar::RearrangeItems(void) +{ + __titleTextArea = _Control::GetBounds(); + + const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize(); + const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width); + + if (CalculateMinimumToolbarWidth() > __titleTextArea.width) + { + __titleTextArea.width = CalculateMinimumToolbarWidth(); + } + + if (GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) + { + if (__titleTextArea.width > portraitSize.width) + { + __titleTextArea.width = portraitSize.width; + } + } + else + { + if (__titleTextArea.width > landscapeSize.width) + { + __titleTextArea.width = landscapeSize.width; + } + } + + __itemArea = __titleTextArea; + + if (__header == true && __style != TOOLBAR_TEXT) + { + int headerLeftButtonWidth = 0; + int headerRightButtonWidth = 0; + int headerTopMargin = 0; + int vmargin = 0; + int buttonItemGap = 0; + int headerButtonItemHeight = 0; + int headerLeftMargin = 0; + int headerRightMargin = 0; + int segmentedButtonWidth = 0; + int segmentedButtonWidth2 = 0; + int tabLeftMargin = 0; + + GET_SHAPE_CONFIG(HEADER::TOP_MARGIN, GetOrientation(), headerTopMargin); + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_GAP, GetOrientation(), buttonItemGap); + GET_SHAPE_CONFIG(HEADER::LEFT_MARGIN, GetOrientation(), headerLeftMargin); + GET_SHAPE_CONFIG(HEADER::RIGHT_MARGIN, GetOrientation(), headerRightMargin); + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH_OF_SEGMENTED, GetOrientation(), segmentedButtonWidth); + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_WIDTH_OF_SEGMENTED_2, GetOrientation(), segmentedButtonWidth2); + GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, GetOrientation(), tabLeftMargin); + + if (__pButtonItems[LEFT_BUTTON]) + { + headerLeftButtonWidth = __pButtonItems[LEFT_BUTTON]->GetSize().width; + } + + if (__pButtonItems[RIGHT_BUTTON]) + { + headerRightButtonWidth = __pButtonItems[RIGHT_BUTTON]->GetSize().width; + } + + if (__style == TOOLBAR_HEADER_SEGMENTED || __style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE) + { + if (__pButtonItems[LEFT_BUTTON]) + { + if (__pButtonItems[RIGHT_BUTTON]) + { + headerLeftButtonWidth = segmentedButtonWidth2; + headerRightButtonWidth = segmentedButtonWidth2; + } + else + { + headerLeftButtonWidth = segmentedButtonWidth; + } + + GET_SHAPE_CONFIG(HEADER::RIGHT_MARGIN_WITH_SEGMENTED_BUTTON, GetOrientation(), headerRightMargin); + } + else + { + if (__pButtonItems[RIGHT_BUTTON]) + { + headerRightButtonWidth = segmentedButtonWidth; + + GET_SHAPE_CONFIG(HEADER::RIGHT_MARGIN_WITH_SEGMENTED_BUTTON, GetOrientation(), headerRightMargin); + } + } + } + + if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE) + { + GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, GetOrientation(), vmargin); + GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, GetOrientation(), headerButtonItemHeight); + } + else + { + if (__style == TOOLBAR_TITLE) + { + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN, GetOrientation(), vmargin); + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_HEIGHT, GetOrientation(), headerButtonItemHeight); + } + else if(__style == TOOLBAR_HEADER_SEGMENTED) + { + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN_OF_SEGMENTED, GetOrientation(), vmargin); + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_HEIGHT_OF_SEGMENTED, GetOrientation(), headerButtonItemHeight); + } + } + + __titleTextArea.x = headerLeftMargin; + __titleTextArea.y = headerTopMargin; + + if (__pButtonItems[RIGHT_BUTTON]) + { + if (__pButtonItems[LEFT_BUTTON]) + { + __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__titleTextArea.width - headerRightButtonWidth - headerRightMargin, vmargin, + headerRightButtonWidth, headerButtonItemHeight)); + __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(__titleTextArea.width - headerRightButtonWidth - headerLeftButtonWidth - buttonItemGap - headerRightMargin, vmargin, + headerLeftButtonWidth, headerButtonItemHeight)); + + if (!(__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE)) + { + __titleTextArea.width -= (headerLeftButtonWidth + headerRightButtonWidth + buttonItemGap + headerLeftMargin); + } + } + else + { + __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__titleTextArea.width - headerRightButtonWidth - headerRightMargin, vmargin, + headerRightButtonWidth, headerButtonItemHeight)); + + if (!(__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE)) + { + __titleTextArea.width -= (headerRightButtonWidth + headerLeftMargin); + } + } + } + else if (__pButtonItems[LEFT_BUTTON]) + { + __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(__titleTextArea.width - headerLeftButtonWidth - headerRightMargin, vmargin, + headerLeftButtonWidth, headerButtonItemHeight)); + + if (!(__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE)) + { + __titleTextArea.width -= (headerLeftButtonWidth + headerLeftMargin); + } + } + + if (!(__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __style == TOOLBAR_TAB_WITH_TITLE)) + { + __titleTextArea.width -= (headerLeftMargin + headerRightMargin); + } + else // TOOLBAR_HEADER_SEGMENTED_WITH_TITLE or TOOLBAR_TAB_WITH_TITLE + { + __titleTextArea.width -= (headerLeftMargin + tabLeftMargin); + } + + if (__style == TOOLBAR_HEADER_SEGMENTED) + { + if (__pButtonItems[RIGHT_BUTTON]) + { + RealignButtonIcon(__pButtonItems[RIGHT_BUTTON]); + } + if (__pButtonItems[LEFT_BUTTON]) + { + RealignButtonIcon(__pButtonItems[LEFT_BUTTON]); + } + } + else if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE) + { + if (__pButtonItems[RIGHT_BUTTON]) + { + RealignIcon(__pButtonItems[RIGHT_BUTTON]); + } + if (__pButtonItems[LEFT_BUTTON]) + { + RealignIcon(__pButtonItems[LEFT_BUTTON]); + } + } + } + else // footer or edit or HEADER_STYLE_BUTTON + { + int footerButtonItemWidth = 0; + int footerButtonItemHeight = 0; + int sipButtonItemTopMargin = 0; + int footerLeftMargin = 0; + Dimension softkeyDimension(0, 0); + + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, GetOrientation(), footerButtonItemWidth); + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_HEIGHT, GetOrientation(), footerButtonItemHeight); + GET_SHAPE_CONFIG(HEADER::SIP_BUTTON_ITEM_TOP_MARGIN, GetOrientation(), sipButtonItemTopMargin); + GET_SHAPE_CONFIG(FOOTER::LEFT_MARGIN, GetOrientation(), footerLeftMargin); + GET_DIMENSION_CONFIG(FOOTER::SOFTKEY_RECT_WITH_TEXT, GetOrientation(), softkeyDimension); + + if (__pButtonItems[MIDDLE_BUTTON]) + { + __pButtonItems[MIDDLE_BUTTON]->SetPosition(Point((__itemArea.width - __pButtonItems[MIDDLE_BUTTON]->GetSize().width) / 2, + __itemArea.height - __pButtonItems[MIDDLE_BUTTON]->GetSize().height)); + } + + if (__pButtonItems[RIGHT_BUTTON]) + { + if (__pButtonItems[LEFT_BUTTON]) + { + if (__pButtonItems[BACK_BUTTON]) //321 + { + if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip + { + __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin, + sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight)); + + __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, sipButtonItemTopMargin, + footerButtonItemWidth, footerButtonItemHeight)); + } + else + { + __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin, + (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight)); + + __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, (__itemArea.height - footerButtonItemHeight) / 2, + footerButtonItemWidth, footerButtonItemHeight)); + } + } + else //21 + { + if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip + { + __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin, + sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight)); + + __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, sipButtonItemTopMargin, + footerButtonItemWidth, footerButtonItemHeight)); + } + else + { + if (__style != TOOLBAR_SOFTKEY) + { + __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin, + (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight)); + } + else + { + if (__pButtonItems[RIGHT_BUTTON]->GetText() == L"") + { + __pButtonItems[RIGHT_BUTTON]->SetPosition(Point(__itemArea.width - __pButtonItems[RIGHT_BUTTON]->GetSize().width, + __itemArea.height - __pButtonItems[RIGHT_BUTTON]->GetSize().height)); + } + else + { + __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - softkeyDimension.width, 0, + softkeyDimension.width, softkeyDimension.height)); + } + } + + if (__style != TOOLBAR_SOFTKEY) + { + __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, (__itemArea.height - footerButtonItemHeight) / 2, + footerButtonItemWidth, footerButtonItemHeight)); + } + else + { + if (__pButtonItems[LEFT_BUTTON]->GetText() == L"") + { + __pButtonItems[LEFT_BUTTON]->SetPosition(Point(0, __itemArea.height - __pButtonItems[LEFT_BUTTON]->GetSize().height)); + } + else + { + __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(0, 0, softkeyDimension.width, softkeyDimension.height)); + } + } + } + } + } + else + { + if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip + { + if (__pButtonItems[BACK_BUTTON])//31 + { + __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin, + sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight)); + } + else //1 + { + __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin, + sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight)); + } + } + else + { + if (__pButtonItems[BACK_BUTTON])//31 + { + __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin, + (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight)); + } + else //1 + { + if (__style != TOOLBAR_SOFTKEY) + { + __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin, + (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight)); + } + else + { + if (__pButtonItems[RIGHT_BUTTON]->GetText() == L"") + { + __pButtonItems[RIGHT_BUTTON]->SetPosition(Point(__itemArea.width - __pButtonItems[RIGHT_BUTTON]->GetSize().width, + __itemArea.height - __pButtonItems[RIGHT_BUTTON]->GetSize().height)); + } + else + { + __pButtonItems[RIGHT_BUTTON]->SetBounds(Rectangle(__itemArea.width - softkeyDimension.width, 0, + softkeyDimension.width, softkeyDimension.height)); + } + } + } + } + } + } + else if (__pButtonItems[LEFT_BUTTON]) + { + if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip + { + if (__pButtonItems[BACK_BUTTON]) //32 + { + __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin, + sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight)); + + __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, sipButtonItemTopMargin, + footerButtonItemWidth, footerButtonItemHeight)); + } + else //2 + { + __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, sipButtonItemTopMargin, + footerButtonItemWidth, footerButtonItemHeight)); + } + } + else + { + if (__pButtonItems[BACK_BUTTON]) //32 + { + __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin, + (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight)); + + __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, (__itemArea.height - footerButtonItemHeight) / 2, + footerButtonItemWidth, footerButtonItemHeight)); + } + else //2 + { + if (__style != TOOLBAR_SOFTKEY) + { + __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(footerLeftMargin, (__itemArea.height - footerButtonItemHeight) / 2, + footerButtonItemWidth, footerButtonItemHeight)); + } + else + { + if (__pButtonItems[LEFT_BUTTON]->GetText() == L"") + { + __pButtonItems[LEFT_BUTTON]->SetPosition(Point(0, __itemArea.height - __pButtonItems[LEFT_BUTTON]->GetSize().height)); + } + else + { + __pButtonItems[LEFT_BUTTON]->SetBounds(Rectangle(0, 0, softkeyDimension.width, softkeyDimension.height)); + } + } + } + } + } + else + { + if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip + { + if (__pButtonItems[BACK_BUTTON]) + { + __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin, + sipButtonItemTopMargin, footerButtonItemWidth, footerButtonItemHeight)); + } + } + else + { + if (__pButtonItems[BACK_BUTTON]) + { + __pButtonItems[BACK_BUTTON]->SetBounds(Rectangle(__itemArea.width - footerButtonItemWidth - footerLeftMargin, + (__itemArea.height - footerButtonItemHeight) / 2, footerButtonItemWidth, footerButtonItemHeight)); + } + } + } + } + + + if (__pToolbarPresenter) + { + __pToolbarPresenter->SetUsableAreaBounds(__titleTextArea); + } + + if (0 == __itemCount) + { + return E_SUCCESS; + } + + switch (__style) + { + case TOOLBAR_HEADER_SEGMENTED: + //fall through + case TOOLBAR_HEADER_SEGMENTED_WITH_TITLE: + RearrangeHeaderSegmentedItems(); + break; + + case TOOLBAR_SEGMENTED: + RearrangeFooterSegmentedItems(); + break; + + case TOOLBAR_TAB: + //fall through + case TOOLBAR_TAB_WITH_TITLE: + RearrangeTabItmes(); + break; + + default: + RearrangeButtonItems(); + break; + } + + return E_SUCCESS; +} + +result +_Toolbar::RearrangeHeaderSegmentedItems(void) +{ + int segmentedItemHeight = 0; + int tabLeftMargin = 0; + int separatorWidth = 0; + int segmentedRightMarginWithButton = 0; + int vmargin = 0; + int blockWidth[__itemCount]; + int fontSize = 0; + + GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, GetOrientation(), tabLeftMargin); + GET_SHAPE_CONFIG(HEADER::SEPARATOR_WIDTH, GetOrientation(), separatorWidth); + GET_SHAPE_CONFIG(HEADER::RIGHT_MARGIN_WITH_SEGMENTED_BUTTON, GetOrientation(), segmentedRightMarginWithButton); + + if (__style == TOOLBAR_HEADER_SEGMENTED) + { + segmentedItemHeight = __titleTextArea.height; + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN_OF_SEGMENTED, GetOrientation(), vmargin); + } + else if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE) + { + GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, GetOrientation(), segmentedItemHeight); + GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, GetOrientation(), vmargin); + } + + if (__pButtonItems[LEFT_BUTTON]) + { + if (__pButtonItems[RIGHT_BUTTON]) + { + __itemArea.width -= (tabLeftMargin + tabLeftMargin + __pButtonItems[LEFT_BUTTON]->GetSize().width + separatorWidth + + __pButtonItems[RIGHT_BUTTON]->GetSize().width + segmentedRightMarginWithButton); + } + else + { + __itemArea.width -= (tabLeftMargin + tabLeftMargin + __pButtonItems[LEFT_BUTTON]->GetSize().width + segmentedRightMarginWithButton); + } + } + else + { + if (__pButtonItems[RIGHT_BUTTON]) + { + __itemArea.width -= (tabLeftMargin + tabLeftMargin + __pButtonItems[RIGHT_BUTTON]->GetSize().width + segmentedRightMarginWithButton); + } + else + { + __itemArea.width -= tabLeftMargin * 2; + } + } + + if (__itemCount == 1 || __itemCount == 2) + { + blockWidth[0] = blockWidth[1] = (__itemArea.width - separatorWidth) / 2; + + for (int i = 0; i < __itemCount ; i++) + { + __pItems.at(i)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] * i + separatorWidth * i, vmargin, blockWidth[i], segmentedItemHeight)); + + if (__pItems.at(i)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0)); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetPosition(Point(blockWidth[1] - existingBadgeIcon->GetSize().width, 0)); + existingBadgeIcon = null; + } + } + } + } + else if (__itemCount == 3) + { + blockWidth[0] = blockWidth[1] = blockWidth[2] = (__itemArea.width - separatorWidth * 2) / 3; + + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, blockWidth[0], segmentedItemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, vmargin, blockWidth[1], segmentedItemHeight)); + __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2, + vmargin, blockWidth[2], segmentedItemHeight)); + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0)); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0)); + existingBadgeIcon = null; + } + } + } + } + else if (__itemCount == 4) + { + blockWidth[0] = blockWidth[1] = blockWidth[2] = blockWidth[3] = (__itemArea.width - separatorWidth * 3) / 4; + + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, blockWidth[0], segmentedItemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, vmargin, blockWidth[1], segmentedItemHeight)); + __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2, + vmargin, blockWidth[2], segmentedItemHeight)); + __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + separatorWidth * 3, + vmargin, blockWidth[3], segmentedItemHeight)); + + for (int i = 0; i < __itemCount ; i++) + { + if (__pItems.at(i)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0)); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0)); + existingBadgeIcon = null; + } + } + } + } + + for (int i = 0; i < __itemCount; i++) + { + if (__style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE) + { + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize); + + __pItems.at(i)->SetTextSize(fontSize, FONT_STYLE_BOLD); + } + + RealignIcon(__pItems.at(i)); + } + + return E_SUCCESS; +} + +result +_Toolbar::RearrangeFooterSegmentedItems(void) +{ + int segmentedItemHeight = __itemArea.height; + + int tabLeftMargin = 0; + int tabRightMargin = 0; + int footerLeftMargin = 0; + int iconSize = 0; + int separatorWidth = 0; + int blockWidth[__itemCount]; + int fontSize = 0; + + int itemButtonLeftGap = 0; + int itemButtonRightGap = 0; + + GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, GetOrientation(), tabLeftMargin); + GET_SHAPE_CONFIG(FOOTER::LEFT_MARGIN, GetOrientation(), footerLeftMargin); + GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_ICON_SIZE, GetOrientation(), iconSize); + GET_SHAPE_CONFIG(HEADER::SEPARATOR_WIDTH, GetOrientation(), separatorWidth); + + tabRightMargin = tabLeftMargin; + + if (__itemCount == 1 || __itemCount == 2) + { + tabLeftMargin = footerLeftMargin; + itemButtonLeftGap = footerLeftMargin; + __itemArea.width -= ((tabLeftMargin + iconSize + itemButtonLeftGap) * 2); + + blockWidth[0] = blockWidth[1] = (__itemArea.width - separatorWidth) / 2; + + for (int i = 0; i < __itemCount ; i++) + { + __pItems.at(i)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] * i + separatorWidth * i, + (GetSize().height - segmentedItemHeight) / 2, blockWidth[i], segmentedItemHeight)); + + if (__pItems.at(i)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0)); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0)); + existingBadgeIcon = null; + } + } + } + + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize); + } + else if (__itemCount == 3) + { + if (__pButtonItems[LEFT_BUTTON]) + { + if (__pButtonItems[RIGHT_BUTTON] || __pButtonItems[BACK_BUTTON]) + { + tabLeftMargin = footerLeftMargin; + itemButtonLeftGap = footerLeftMargin; + __itemArea.width -= ((tabLeftMargin + iconSize + itemButtonLeftGap) * 2); + } + else + { + tabLeftMargin = footerLeftMargin; + itemButtonLeftGap = footerLeftMargin; + __itemArea.width -= (tabLeftMargin + iconSize + itemButtonLeftGap + tabRightMargin); + } + } + else + { + if (__pButtonItems[RIGHT_BUTTON] || __pButtonItems[BACK_BUTTON]) + { + tabRightMargin = footerLeftMargin; + itemButtonRightGap = footerLeftMargin; + __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin); + } + else + { + __itemArea.width -= tabLeftMargin * 2; + } + + iconSize = 0; + } + + blockWidth[0] = blockWidth[1] = blockWidth[2] = (__itemArea.width - separatorWidth * 2) / 3; + + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap, (GetSize().height - segmentedItemHeight) / 2, blockWidth[0], segmentedItemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + separatorWidth, (GetSize().height - segmentedItemHeight) / 2, blockWidth[1], segmentedItemHeight)); + __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + blockWidth[1] + separatorWidth * 2, + (GetSize().height - segmentedItemHeight) / 2, blockWidth[2], segmentedItemHeight)); + + for (int i = 0; i < __itemCount ; i++) + { + if (__pItems.at(i)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0)); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0)); + existingBadgeIcon = null; + } + } + } + + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize); + } + else if (__itemCount == 4) + { + if (__pButtonItems[BACK_BUTTON]) + { + tabRightMargin = footerLeftMargin; + itemButtonRightGap = footerLeftMargin; + __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin); + } + else + { + __itemArea.width -= tabLeftMargin * 2; + } + + blockWidth[0] = blockWidth[1] = blockWidth[2] = blockWidth[3] = (__itemArea.width - separatorWidth * 3) / 4; + + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, (GetSize().height - segmentedItemHeight) / 2, blockWidth[0], segmentedItemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, (GetSize().height - segmentedItemHeight) / 2, blockWidth[1], segmentedItemHeight)); + __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2, + (GetSize().height - segmentedItemHeight) / 2, blockWidth[2], segmentedItemHeight)); + __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + separatorWidth * 3, + (GetSize().height - segmentedItemHeight) / 2, blockWidth[3], segmentedItemHeight)); + + for (int i = 0; i < __itemCount ; i++) + { + if (__pItems.at(i)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0)); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0)); + existingBadgeIcon = null; + } + } + } + + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize); + } + + for (int i = 0; i < __itemCount ; i++) + { + __pItems.at(i)->SetTextSize(fontSize, FONT_STYLE_BOLD); + + RealignIcon(__pItems.at(i)); + } + + return E_SUCCESS; +} + +result +_Toolbar::RearrangeTabItmes(void) +{ + int itemWidth[__itemCount]; + int fontSize = 0; + int segmentedItemHeight = 0; + int tabLeftMargin = 0; + int vmargin = 0; + int separatorWidth = 0; + + GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, GetOrientation(), tabLeftMargin); + GET_SHAPE_CONFIG(HEADER::SEPARATOR_WIDTH, GetOrientation(), separatorWidth); + + if (__style == TOOLBAR_TAB) + { + segmentedItemHeight = __itemArea.height; + } + else if (__style == TOOLBAR_TAB_WITH_TITLE) + { + GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, GetOrientation(), segmentedItemHeight); + GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, GetOrientation(), vmargin); + } + + if (__itemCount == 1) + { + itemWidth[0] = __itemArea.width - tabLeftMargin * 2; + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, itemWidth[0], segmentedItemHeight)); + + if (__style == TOOLBAR_TAB) + { + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize); + } + else if (__style == TOOLBAR_TAB_WITH_TITLE) + { + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize); + } + } + else if (__itemCount == 2) + { + itemWidth[0] = itemWidth[1] = (__itemArea.width - tabLeftMargin * 2 - separatorWidth) / 2; + + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, itemWidth[0], segmentedItemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + itemWidth[0] + separatorWidth, vmargin, itemWidth[1], segmentedItemHeight)); + + if (__style == TOOLBAR_TAB) + { + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize); + } + else if (__style == TOOLBAR_TAB_WITH_TITLE) + { + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize); + } + } + else if (__itemCount == 3) + { + itemWidth[0] = itemWidth[1] = itemWidth[2] = (__itemArea.width - tabLeftMargin * 2 - separatorWidth * 2) / 3; + + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, itemWidth[0], segmentedItemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + itemWidth[0] + separatorWidth, vmargin, itemWidth[1], segmentedItemHeight)); + __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + itemWidth[0] + itemWidth[1] + separatorWidth * 2, vmargin, itemWidth[2], segmentedItemHeight)); + + if (__style == TOOLBAR_TAB) + { + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize); + } + else if (__style == TOOLBAR_TAB_WITH_TITLE) + { + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize); + } + } + else + { + itemWidth[0] = itemWidth[1] = itemWidth[2] = itemWidth[3] = (__itemArea.width - tabLeftMargin * 2 - separatorWidth * 3) / 4; + + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, vmargin, itemWidth[0], segmentedItemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + itemWidth[0] + separatorWidth, vmargin, itemWidth[1], segmentedItemHeight)); + __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + itemWidth[0] + itemWidth[1] + separatorWidth * 2, + vmargin, itemWidth[2], segmentedItemHeight)); + __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + itemWidth[0] + itemWidth[1] + itemWidth[2] + separatorWidth * 3, + vmargin, itemWidth[3], segmentedItemHeight)); + + GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_4_ITEM, GetOrientation(), fontSize); + } + + for (int i = 4; i < __itemCount ; i++) + { + itemWidth[i] = itemWidth[0]; + + __pItems.at(i)->SetBounds(Rectangle(__pItems.at(i-1)->GetBounds().x + separatorWidth + itemWidth[i], vmargin, itemWidth[i], segmentedItemHeight)); + } + + for (int i = 0; i < __itemCount ; i++) + { + __pItems.at(i)->SetTextSize(fontSize, FONT_STYLE_BOLD); + + if (__pItems.at(i)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0)); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetPosition(Point(__pItems.at(i)->GetSize().width - existingBadgeIcon->GetSize().width, 0)); + existingBadgeIcon = null; + } + } + + RealignIcon(__pItems.at(i)); + } + + return E_SUCCESS; +} + +result +_Toolbar::RearrangeButtonItems(void) +{ + int itemHeight = 0; + int maxItemLength = 0; + int minItemLength = 0; + int iconSizeWithText = 0; + int sideMargin = 0; + int vmargin = 0; + int itemButtonLeftGap = 0; + int itemButtonRightGap = 0; + int tabLeftMargin = 0; + int tabRightMargin = 0; + int sipFooterItemTopMargin = 0; + int separatorWidth = 0; + int iconSize = 0; + int footerLeftMargin = 0; + int headerButtonItemHeight = 0; + int headerLeftMargin = 0; + int blockWidth[__itemCount]; + + GET_SHAPE_CONFIG(HEADER::SIP_FOOTER_ITEM_TOP_MARGIN, GetOrientation(), sipFooterItemTopMargin); + GET_SHAPE_CONFIG(HEADER::SEPARATOR_WIDTH, GetOrientation(), separatorWidth); + GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_ICON_SIZE, GetOrientation(), iconSize); + GET_SHAPE_CONFIG(FOOTER::LEFT_MARGIN, GetOrientation(), footerLeftMargin); + GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, GetOrientation(), tabLeftMargin); + GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_WIDTH_1_MAX, GetOrientation(), maxItemLength); + GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_WIDTH_1_MIN, GetOrientation(), minItemLength); + GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_BUTTON_STYLE_SIDE_MARGIN, GetOrientation(), sideMargin); + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN, GetOrientation(), vmargin); + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_HEIGHT, GetOrientation(), headerButtonItemHeight); + GET_SHAPE_CONFIG(HEADER::LEFT_MARGIN, GetOrientation(), headerLeftMargin); + + tabRightMargin = tabLeftMargin; + + if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_HEIGHT, GetOrientation(), itemHeight); + } + else + { + itemHeight = GetSize().height; + } + + if (__itemCount == 1) + { + if (__style == TOOLBAR_TITLE) // item 1, HEADER_STYLE_TITLE_BUTTON + { + blockWidth[0] = __titleTextArea.width; + itemHeight = headerButtonItemHeight; + __pItems.at(0)->SetBounds(Rectangle(headerLeftMargin, vmargin, blockWidth[0], itemHeight)); + __pItems.at(0)->SetMargin(0,0); + } + else + { + if (!(__pItems.at(0)->GetBitmap(_BUTTON_STATUS_NORMAL) == null + && __pItems.at(0)->GetBitmap(_BUTTON_STATUS_DISABLED) == null + && __pItems.at(0)->GetBitmap(_BUTTON_STATUS_PRESSED) == null + && __pItems.at(0)->GetBitmap(_BUTTON_STATUS_SELECTED) == null + && __pItems.at(0)->GetBitmap(_BUTTON_STATUS_HIGHLIGHTED) == null)) // at least 1 bitmap + { + GET_SHAPE_CONFIG(FOOTER::FOOTER_ITEM_BUTTON_STYLE_ICON_SIZE_WITH_TEXT, GetOrientation(), iconSizeWithText); + } + + blockWidth[0] = __pItems.at(0)->GetTextExtentSize() + iconSizeWithText + sideMargin * 3; + + if (blockWidth[0] > maxItemLength) + { + blockWidth[0] = maxItemLength; + } + if (blockWidth[0] < minItemLength) + { + blockWidth[0] = minItemLength; + } + + if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip + { + __pItems.at(0)->SetBounds(Rectangle((GetSize().width - blockWidth[0]) / 2, sipFooterItemTopMargin, blockWidth[0], itemHeight)); + } + else + { + __pItems.at(0)->SetBounds(Rectangle((GetSize().width - blockWidth[0]) / 2, (GetSize().height - itemHeight) / 2, blockWidth[0], itemHeight)); + } + } + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0)); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0)); + existingBadgeIcon = null; + } + } + } + } + else if(__itemCount == 2) + { + tabLeftMargin = footerLeftMargin; + itemButtonLeftGap = footerLeftMargin; + __itemArea.width -= ((tabLeftMargin + iconSize + itemButtonLeftGap) * 2); + + blockWidth[0] = blockWidth[1] = (__itemArea.width - separatorWidth) / 2; + + if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip + { + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap, sipFooterItemTopMargin, blockWidth[0], itemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + separatorWidth, sipFooterItemTopMargin, blockWidth[1], itemHeight)); + } + else + { + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap, (GetSize().height - itemHeight) / 2, blockWidth[0], itemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + separatorWidth, (GetSize().height - itemHeight) / 2, blockWidth[1], itemHeight)); + } + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0)); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0)); + existingBadgeIcon = null; + } + } + } + } + else if (__itemCount == 3) + { + if (__pButtonItems[LEFT_BUTTON]) + { + if (__pButtonItems[RIGHT_BUTTON] || __pButtonItems[BACK_BUTTON]) + { + tabLeftMargin = footerLeftMargin; + itemButtonLeftGap = footerLeftMargin; + __itemArea.width -= ((tabLeftMargin + iconSize + itemButtonLeftGap) * 2); + } + else + { + tabLeftMargin = footerLeftMargin; + itemButtonLeftGap = footerLeftMargin; + __itemArea.width -= (tabLeftMargin + iconSize + itemButtonLeftGap + tabRightMargin); + } + } + else + { + if (__pButtonItems[RIGHT_BUTTON] || __pButtonItems[BACK_BUTTON]) + { + tabRightMargin = footerLeftMargin; + itemButtonRightGap = footerLeftMargin; + __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin); + } + else + { + __itemArea.width -= tabLeftMargin * 2; + } + + iconSize = 0; + } + + blockWidth[0] = blockWidth[1] = blockWidth[2] = (__itemArea.width - separatorWidth * 2) / 3; + + if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip + { + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap, sipFooterItemTopMargin, blockWidth[0], itemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + separatorWidth, sipFooterItemTopMargin, blockWidth[1], itemHeight)); + __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + blockWidth[1] + separatorWidth * 2, + sipFooterItemTopMargin, blockWidth[2], itemHeight)); + } + else + { + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap, (GetSize().height - itemHeight) / 2, blockWidth[0], itemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + separatorWidth, (GetSize().height - itemHeight) / 2, blockWidth[1], itemHeight)); + __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + blockWidth[1] + separatorWidth * 2, + (GetSize().height - itemHeight) / 2, blockWidth[2], itemHeight)); + } + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0)); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0)); + existingBadgeIcon = null; + } + } + } + } + else if (__itemCount == 4) + { + if (__pButtonItems[BACK_BUTTON]) + { + tabRightMargin = footerLeftMargin; + itemButtonRightGap = footerLeftMargin; + __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin); + } + else + { + __itemArea.width -= tabLeftMargin * 2; + } + + blockWidth[0] = blockWidth[1] = blockWidth[2] = blockWidth[3] = (__itemArea.width - separatorWidth * 3) / 4; + + if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip + { + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, sipFooterItemTopMargin, blockWidth[0], itemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, sipFooterItemTopMargin, blockWidth[1], itemHeight)); + __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2, + sipFooterItemTopMargin, blockWidth[2], itemHeight)); + __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + separatorWidth * 3, + sipFooterItemTopMargin, blockWidth[3], itemHeight)); + } + else + { + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, (GetSize().height - itemHeight) / 2, blockWidth[0], itemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, (GetSize().height - itemHeight) / 2, blockWidth[1], itemHeight)); + __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2, + (GetSize().height - itemHeight) / 2, blockWidth[2], itemHeight)); + __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + separatorWidth * 3, + (GetSize().height - itemHeight) / 2, blockWidth[3], itemHeight)); + } + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0)); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0)); + existingBadgeIcon = null; + } + } + } + } + else if (__itemCount == 5) + { + if (__pButtonItems[BACK_BUTTON]) + { + tabRightMargin = footerLeftMargin; + itemButtonRightGap = footerLeftMargin; + __itemArea.width -= (tabLeftMargin + itemButtonRightGap + iconSize + tabRightMargin); + } + else + { + __itemArea.width -= tabLeftMargin * 2; + } + + blockWidth[0] = blockWidth[1] = blockWidth[2] = blockWidth[3] = blockWidth[4] = (__itemArea.width - separatorWidth * 4) / 5; + + if (__header == true && __style == TOOLBAR_TEXT && GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) // sip + { + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, sipFooterItemTopMargin, blockWidth[0], itemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, sipFooterItemTopMargin, blockWidth[1], itemHeight)); + __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2, + sipFooterItemTopMargin, blockWidth[2], itemHeight)); + __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + separatorWidth * 3, + sipFooterItemTopMargin, blockWidth[3], itemHeight)); + __pItems.at(4)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + blockWidth[3] + separatorWidth * 4, + sipFooterItemTopMargin, blockWidth[4], itemHeight)); + } + else + { + __pItems.at(0)->SetBounds(Rectangle(tabLeftMargin, (GetSize().height - itemHeight) / 2, blockWidth[0], itemHeight)); + __pItems.at(1)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + separatorWidth, (GetSize().height - itemHeight) / 2, blockWidth[1], itemHeight)); + __pItems.at(2)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + separatorWidth * 2, + (GetSize().height - itemHeight) / 2, blockWidth[2], itemHeight)); + __pItems.at(3)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + separatorWidth * 3, + (GetSize().height - itemHeight) / 2, blockWidth[3], itemHeight)); + __pItems.at(4)->SetBounds(Rectangle(tabLeftMargin + blockWidth[0] + blockWidth[1] + blockWidth[2] + blockWidth[3] + separatorWidth * 4, + (GetSize().height - itemHeight) / 2, blockWidth[4], itemHeight)); + } + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i)->GetChildCount() != 0) + { + _Label* existingBadgeIcon = dynamic_cast<_Label*>(__pItems.at(i)->GetChild(0)); + + if (existingBadgeIcon) + { + existingBadgeIcon->SetPosition(Point(blockWidth[i] - existingBadgeIcon->GetSize().width, 0)); + existingBadgeIcon = null; + } + } + } + } + + int buttonTextFontSize = 0; + + for (int i = 0; i < __itemCount; i++) + { + if (__style == TOOLBAR_ICON_TEXT && (__pItems.at(i)->GetBitmap(_BUTTON_STATUS_NORMAL) || __pItems.at(i)->GetBitmap(_BUTTON_STATUS_PRESSED))) + { + if (__itemCount == 1 || __itemCount == 2) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3_WITH_ICON, GetOrientation(), buttonTextFontSize); + } + else if (__itemCount == 3) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3_WITH_ICON, GetOrientation(), buttonTextFontSize); + } + else if (__itemCount == 4) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_4_WITH_ICON, GetOrientation(), buttonTextFontSize); + } + else if (__itemCount == 5) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_5_WITH_ICON, GetOrientation(), buttonTextFontSize); + } + } + else + { + if (__itemCount == 1 || __itemCount == 2) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3, GetOrientation(), buttonTextFontSize); + } + else if (__itemCount == 3) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3, GetOrientation(), buttonTextFontSize); + } + else if (__itemCount == 4) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_4, GetOrientation(), buttonTextFontSize); + } + else if (__itemCount == 5) + { + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_5, GetOrientation(), buttonTextFontSize); + } + } + + __pItems.at(i)->SetTextSize(buttonTextFontSize, FONT_STYLE_BOLD); + + RealignIcon(__pItems.at(i)); + } + + return E_SUCCESS; +} + +result +_Toolbar::SetAnimation(ToolbarAnimationPosition animationPos) +{ + SysTryReturnResult(NID_UI_CTRL, (0 <= animationPos && animationPos < 3), E_INVALID_ARG, + "[E_INVALID_ARG] The animationPos is invalid."); + + if (__pAnimation[animationPos]) + { + if (__pAnimation[animationPos]->GetStatus() == ANIMATION_PLAYING) + { + return E_SUCCESS; + } + } + + Bitmap* pProcessingBitmap[PROCESSING_ANIMATION_COUNT]; + + for (int i = 0; i < PROCESSING_ANIMATION_COUNT ; i++) + { + pProcessingBitmap[i] = null; + } + + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_01, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[0]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_02, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[1]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_03, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[2]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_04, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[3]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_05, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[4]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_06, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[5]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_07, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[6]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_08, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[7]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_09, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[8]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_10, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[9]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_11, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[10]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_12, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[11]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_13, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[12]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_14, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[13]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_15, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[14]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_16, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[15]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_17, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[16]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_18, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[17]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_19, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[18]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_20, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[19]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_21, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[20]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_22, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[21]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_23, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[22]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_24, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[23]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_25, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[24]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_26, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[25]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_27, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[26]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_28, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[27]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_29, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[28]); + GET_BITMAP_CONFIG_N(HEADER::PROCESSING_ANIMATION_30, BITMAP_PIXEL_FORMAT_ARGB8888, pProcessingBitmap[29]); + + // Create AnimationFrames + long duration = 500 / PROCESSING_ANIMATION_COUNT; + + AnimationFrame* pAniFrame[PROCESSING_ANIMATION_COUNT]; + + for (int i = 0; i < PROCESSING_ANIMATION_COUNT ; i++) + { + pAniFrame[i] = new (std::nothrow) AnimationFrame(*pProcessingBitmap[i], duration); + } + + __pAnimationFrameList = new (std::nothrow) ArrayList(); + if (__pAnimationFrameList) + { + __pAnimationFrameList->Construct(); + + for (int i = 0; i < PROCESSING_ANIMATION_COUNT ; i++) + { + __pAnimationFrameList->Add(*pAniFrame[i]); + } + } + + // Deallocate a Bitmap. + for (int i = 0 ; i < PROCESSING_ANIMATION_COUNT ; i++) + { + delete pProcessingBitmap[i]; + pProcessingBitmap[i] = null; + } + + delete __pAnimation[animationPos]; + __pAnimation[animationPos] = null; + + __pAnimation[animationPos] = _Animation::CreateAnimationN(); + + int processingAnimationIconSize = 0; + + GET_SHAPE_CONFIG(HEADER::PROCESSING_ANIMATION_ICON_SIZE, GetOrientation(), processingAnimationIconSize); + + if (__pAnimation[animationPos]) + { + __pAnimation[animationPos]->SetSize(Dimension(processingAnimationIconSize, processingAnimationIconSize)); + + if (__pAnimationFrameList) + { + __pAnimation[animationPos]->SetAnimationFrames(*__pAnimationFrameList); + } + __pAnimation[animationPos]->SetImageCount(PROCESSING_ANIMATION_COUNT); + __pAnimation[animationPos]->SetRepeatCount(100); + __pAnimation[animationPos]->AddAnimationEventListener(*this); + + + if (animationPos == TOOLBAR_ANIMATION_POSITION_TITLE) + { + AttachChild(*__pAnimation[animationPos]); + } + else if (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT) + { + __pButtonItems[LEFT_BUTTON]->AttachChild(*__pAnimation[animationPos]); + + SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT, + (__pButtonItems[LEFT_BUTTON]->GetSize().width - processingAnimationIconSize) / 2, + (__pButtonItems[LEFT_BUTTON]->GetSize().height - processingAnimationIconSize) / 2); + } + else if (animationPos == TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT) + { + __pButtonItems[RIGHT_BUTTON]->AttachChild(*__pAnimation[animationPos]); + + SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT, + (__pButtonItems[RIGHT_BUTTON]->GetSize().width - processingAnimationIconSize) / 2, + (__pButtonItems[RIGHT_BUTTON]->GetSize().height - processingAnimationIconSize) / 2); + } + } + + return E_SUCCESS; +} + +result +_Toolbar::SetColorReplacedBitmap(_Button* pButton, const _ButtonStatus status, + const Color& color, const Bitmap* pBitmap) +{ + SysTryReturnResult(NID_UI_CTRL, pButton, E_INVALID_ARG, "[E_INVALID_ARG] The button pointer is null."); + SysTryReturnResult(NID_UI_CTRL, pBitmap, E_INVALID_ARG, "[E_INVALID_ARG] The bitmap pointer is null."); + + Bitmap* __pColorReplacedBitmap = null; + + __pColorReplacedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pBitmap, Color::GetColor(COLOR_ID_MAGENTA), color); + + if (__pColorReplacedBitmap) + { + if (color.GetAlpha() != 0xFF) + { + __pColorReplacedBitmap->SetAlphaConstant(color.GetAlpha()); + } + + pButton->SetBackgroundBitmap(status, *__pColorReplacedBitmap); + delete __pColorReplacedBitmap; + } + + return E_SUCCESS; +} + +result +_Toolbar::SetPropertyColor(const Variant& color) +{ + result r = E_SUCCESS; + + _Control::SetBackgroundColor(color.ToColor()); + + return r; +} + +Variant +_Toolbar::GetPropertyColor(void) const +{ + return Variant(_Control::GetBackgroundColor()); +} + +result +_Toolbar::SetPropertyDescriptionText(const Variant& text) +{ + __descriptionText = text.ToString(); + + result r = E_SUCCESS; + + if (__pToolbarPresenter) + { + r = __pToolbarPresenter->SetDescriptionText(__descriptionText); + } + + if(__pTitleTextElement) + { + if (text.IsEmpty()) + { + __pTitleTextElement->SetLabel(__titleText); + } + else + { + __pTitleTextElement->SetLabel(__titleText + L", " + __descriptionText); + } + } + + return r; +} + +Variant +_Toolbar::GetPropertyDescriptionText(void) const +{ + return Variant(__descriptionText); +} + +result +_Toolbar::SetPropertyDescriptionTextColor(const Variant& color) +{ + __descriptionTextColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyDescriptionTextColor(void) const +{ + return Variant(__descriptionTextColor); +} + +result +_Toolbar::SetPropertyTitleText(const Variant& text) +{ + __titleText = text.ToString(); + + if(__pTitleTextElement) + { + __pTitleTextElement->SetLabel(__titleText); + } + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyTitleText(void) const +{ + return Variant(__titleText); +} + +result +_Toolbar::SetPropertyTitleTextColor(const Variant& color) +{ + __titleTextColor = color.ToColor(); + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyTitleTextColor(void) const +{ + return Variant(__titleTextColor); +} + +result +_Toolbar::SetPropertyDisabledButtonColor(const Variant& color) +{ + __buttonBackgroundColor[_BUTTON_STATUS_DISABLED] = color.ToColor(); + + Bitmap* __pBaseBackgroundBitmap = null; + + GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + + for (int i = 0; i < BUTTON_MAX; i++) + { + if (__pButtonItems[i] != null) + { + if (__pBaseBackgroundBitmap) + { + SetColorReplacedBitmap(__pButtonItems[i], _BUTTON_STATUS_DISABLED, __buttonBackgroundColor[_BUTTON_STATUS_DISABLED], __pBaseBackgroundBitmap); + } + } + } + + delete __pBaseBackgroundBitmap; + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyDisabledButtonColor(void) const +{ + return Variant(__buttonBackgroundColor[_BUTTON_STATUS_DISABLED]); +} + +result +_Toolbar::SetPropertyDisabledButtonTextColor(const Variant& color) +{ + __buttonTextColor[_BUTTON_STATUS_DISABLED] = color.ToColor(); + + for (int i = 0; i < BUTTON_MAX; i++) + { + if (__pButtonItems[i] != null) + { + __pButtonItems[i]->SetTextColor(_BUTTON_STATUS_DISABLED, __buttonTextColor[_BUTTON_STATUS_DISABLED]); + } + } + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyDisabledButtonTextColor(void) const +{ + return Variant(__buttonTextColor[_BUTTON_STATUS_DISABLED]); +} + +result +_Toolbar::SetPropertyHighlightedButtonColor(const Variant& color) +{ + __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor(); + + Bitmap* __pBaseBackgroundBitmap = null; + + GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + + for (int i = 0; i < BUTTON_MAX; i++) + { + if (__pButtonItems[i] != null) + { + if (__pBaseBackgroundBitmap) + { + SetColorReplacedBitmap(__pButtonItems[i], _BUTTON_STATUS_HIGHLIGHTED, __buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED], __pBaseBackgroundBitmap); + } + } + } + + delete __pBaseBackgroundBitmap; + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyHighlightedButtonColor(void) const +{ + return Variant(__buttonBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); +} + +result +_Toolbar::SetPropertyHighlightedButtonTextColor(const Variant& color) +{ + __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor(); + + for (int i = 0; i < BUTTON_MAX; i++) + { + if (__pButtonItems[i] != null) + { + __pButtonItems[i]->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + } + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyHighlightedButtonTextColor(void) const +{ + return Variant(__buttonTextColor[_BUTTON_STATUS_HIGHLIGHTED]); +} + +result +_Toolbar::SetPropertyNormalButtonColor(const Variant& color) +{ + __buttonBackgroundColor[_BUTTON_STATUS_NORMAL] = color.ToColor(); + + Bitmap* __pBaseBackgroundBitmap = null; + + GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + + for (int i = 0; i < BUTTON_MAX; i++) + { + if (__pButtonItems[i] != null) + { + if (__pBaseBackgroundBitmap) + { + SetColorReplacedBitmap(__pButtonItems[i], _BUTTON_STATUS_NORMAL, __buttonBackgroundColor[_BUTTON_STATUS_NORMAL], __pBaseBackgroundBitmap); + } + } + } + + delete __pBaseBackgroundBitmap; + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyNormalButtonColor(void) const +{ + return Variant(__buttonBackgroundColor[_BUTTON_STATUS_NORMAL]); +} + +result +_Toolbar::SetPropertyNormalButtonTextColor(const Variant& color) +{ + __buttonTextColor[_BUTTON_STATUS_NORMAL] = color.ToColor(); + + for (int i = 0; i < BUTTON_MAX; i++) + { + if (__pButtonItems[i] != null) + { + __pButtonItems[i]->SetTextColor(_BUTTON_STATUS_NORMAL, __buttonTextColor[_BUTTON_STATUS_NORMAL]); + } + } + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyNormalButtonTextColor(void) const +{ + return Variant(__buttonTextColor[_BUTTON_STATUS_NORMAL]); +} + +result +_Toolbar::SetPropertyPressedButtonColor(const Variant& color) +{ + __buttonBackgroundColor[_BUTTON_STATUS_PRESSED] = color.ToColor(); + + Bitmap* __pBaseBackgroundBitmap = null; + + GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + + for (int i = 0; i < BUTTON_MAX; i++) + { + if (__pButtonItems[i] != null) + { + if (__pBaseBackgroundBitmap) + { + SetColorReplacedBitmap(__pButtonItems[i], _BUTTON_STATUS_PRESSED, __buttonBackgroundColor[_BUTTON_STATUS_PRESSED], __pBaseBackgroundBitmap); + } + } + } + + delete __pBaseBackgroundBitmap; + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyPressedButtonColor(void) const +{ + return Variant(__buttonBackgroundColor[_BUTTON_STATUS_PRESSED]); +} + +result +_Toolbar::SetPropertyPressedButtonTextColor(const Variant& color) +{ + __buttonTextColor[_BUTTON_STATUS_PRESSED] = color.ToColor(); + + for (int i = 0; i < BUTTON_MAX; i++) + { + if (__pButtonItems[i] != null) + { + __pButtonItems[i]->SetTextColor(_BUTTON_STATUS_PRESSED, __buttonTextColor[_BUTTON_STATUS_PRESSED]); + } + } + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyPressedButtonTextColor(void) const +{ + return Variant(__buttonTextColor[_BUTTON_STATUS_PRESSED]); +} + +result +_Toolbar::SetPropertyDisabledItemColor(const Variant& color) +{ + __itemBackgroundColor[_BUTTON_STATUS_DISABLED] = color.ToColor(); + + Bitmap* __pBaseBackgroundBitmap = null; + + if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT) + { + GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + } + else + { + GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + } + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i) != null) + { + if (__pBaseBackgroundBitmap) + { + SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_DISABLED, __itemBackgroundColor[_BUTTON_STATUS_DISABLED], __pBaseBackgroundBitmap); + } + } + } + + delete __pBaseBackgroundBitmap; + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyDisabledItemColor(void) const +{ + return Variant(__itemBackgroundColor[_BUTTON_STATUS_DISABLED]); +} + +result +_Toolbar::SetPropertyDisabledItemTextColor(const Variant& color) +{ + __itemTextColor[_BUTTON_STATUS_DISABLED] = color.ToColor(); + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i) != null) + { + __pItems.at(i)->SetTextColor(_BUTTON_STATUS_DISABLED, __itemTextColor[_BUTTON_STATUS_DISABLED]); + } + } + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyDisabledItemTextColor(void) const +{ + return Variant(__itemTextColor[_BUTTON_STATUS_DISABLED]); +} + +result +_Toolbar::SetPropertyHighlightedItemColor(const Variant& color) +{ + __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor(); + + Bitmap* __pBaseBackgroundBitmap = null; + + if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT) + { + GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + } + else + { + GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + } + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i) != null) + { + if (__pBaseBackgroundBitmap) + { + SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_HIGHLIGHTED, __itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED], __pBaseBackgroundBitmap); + } + } + } + + delete __pBaseBackgroundBitmap; + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyHighlightedItemColor(void) const +{ + return Variant(__itemBackgroundColor[_BUTTON_STATUS_HIGHLIGHTED]); +} + +result +_Toolbar::SetPropertyHighlightedItemTextColor(const Variant& color) +{ + __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor(); + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i) != null) + { + __pItems.at(i)->SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, __itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]); + } + } + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyHighlightedItemTextColor(void) const +{ + return Variant(__itemTextColor[_BUTTON_STATUS_HIGHLIGHTED]); +} + +result +_Toolbar::SetPropertyNormalItemColor(const Variant& color) +{ + __itemBackgroundColor[_BUTTON_STATUS_NORMAL] = color.ToColor(); + + Bitmap* __pBaseBackgroundBitmap = null; + + if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT) + { + GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + } + else + { + GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + } + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i) != null) + { + if (__pBaseBackgroundBitmap) + { + SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_NORMAL, __itemBackgroundColor[_BUTTON_STATUS_NORMAL], __pBaseBackgroundBitmap); + } + } + } + + delete __pBaseBackgroundBitmap; + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyNormalItemColor(void) const +{ + return Variant(__itemBackgroundColor[_BUTTON_STATUS_NORMAL]); +} + +result +_Toolbar::SetPropertyNormalItemTextColor(const Variant& color) +{ + __itemTextColor[_BUTTON_STATUS_NORMAL] = color.ToColor(); + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i) != null) + { + __pItems.at(i)->SetTextColor(_BUTTON_STATUS_NORMAL, __itemTextColor[_BUTTON_STATUS_NORMAL]); + } + } + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyNormalItemTextColor(void) const +{ + return Variant(__itemTextColor[_BUTTON_STATUS_NORMAL]); +} + +result +_Toolbar::SetPropertyPressedItemColor(const Variant& color) +{ + __itemBackgroundColor[_BUTTON_STATUS_PRESSED] = color.ToColor(); + + Bitmap* __pBaseBackgroundBitmap = null; + + if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT) + { + GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + } + else + { + GET_BITMAP_CONFIG_N(HEADER::TAB_ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + } + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i) != null) + { + if (__pBaseBackgroundBitmap) + { + SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_PRESSED, __itemBackgroundColor[_BUTTON_STATUS_PRESSED], __pBaseBackgroundBitmap); + } + } + } + + delete __pBaseBackgroundBitmap; + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyPressedItemColor(void) const +{ + return Variant(__itemBackgroundColor[_BUTTON_STATUS_PRESSED]); +} + +result +_Toolbar::SetPropertyPressedItemTextColor(const Variant& color) +{ + __itemTextColor[_BUTTON_STATUS_PRESSED] = color.ToColor(); + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i) != null) + { + __pItems.at(i)->SetTextColor(_BUTTON_STATUS_PRESSED, __itemTextColor[_BUTTON_STATUS_PRESSED]); + } + } + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertyPressedItemTextColor(void) const +{ + return Variant(__itemTextColor[_BUTTON_STATUS_PRESSED]); +} + +result +_Toolbar::SetPropertySelectedItemColor(const Variant& color) +{ + __itemBackgroundColor[_BUTTON_STATUS_SELECTED] = color.ToColor(); + + Bitmap* __pBaseBackgroundBitmap = null; + + if (__style == TOOLBAR_TEXT || __style == TOOLBAR_ICON || __style == TOOLBAR_ICON_TEXT) + { + GET_BITMAP_CONFIG_N(FOOTER::BUTTON_ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + } + else + { + GET_BITMAP_CONFIG_N(HEADER::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pBaseBackgroundBitmap); + } + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i) != null) + { + if (__pBaseBackgroundBitmap) + { + SetColorReplacedBitmap(__pItems.at(i), _BUTTON_STATUS_SELECTED, __itemBackgroundColor[_BUTTON_STATUS_SELECTED], __pBaseBackgroundBitmap); + } + } + } + + delete __pBaseBackgroundBitmap; + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertySelectedItemColor(void) const +{ + return Variant(__itemBackgroundColor[_BUTTON_STATUS_SELECTED]); +} + +result +_Toolbar::SetPropertySelectedItemTextColor(const Variant& color) +{ + __itemTextColor[_BUTTON_STATUS_SELECTED] = color.ToColor(); + + for (int i = 0; i < __itemCount; i++) + { + if (__pItems.at(i) != null) + { + __pItems.at(i)->SetTextColor(_BUTTON_STATUS_SELECTED, __itemTextColor[_BUTTON_STATUS_SELECTED]); + } + } + + return E_SUCCESS; +} + +Variant +_Toolbar::GetPropertySelectedItemTextColor(void) const +{ + return Variant(__itemTextColor[_BUTTON_STATUS_SELECTED]); +} + +Rectangle +_Toolbar::GetButtonBounds(ToolbarButton position) const +{ + return __pButtonItems[position]->GetBounds(); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ToolbarModel.cpp b/src/ui/controls/FUiCtrl_ToolbarModel.cpp new file mode 100644 index 0000000..3efbfca --- /dev/null +++ b/src/ui/controls/FUiCtrl_ToolbarModel.cpp @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ToolbarModel.cpp + * @brief This is the implementation file for the _ToolbarModel class. + */ + +#include +#include +#include "FUiCtrl_ToolbarModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + + +_ToolbarModel::~_ToolbarModel(void) +{ +} + +result +_ToolbarModel::Construct(void) +{ + return E_SUCCESS; +} + +int +_ToolbarModel::GetSelectedItemIndex(void) const +{ + return __selectedIndex; +} + +result +_ToolbarModel::SetSelectedItemIndex(int itemIndex) +{ + __selectedIndex = itemIndex; + + return E_SUCCESS; +} + +_ToolbarModel::_ToolbarModel(void) + : __selectedIndex(-1) +{ +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_ToolbarPresenter.cpp b/src/ui/controls/FUiCtrl_ToolbarPresenter.cpp new file mode 100644 index 0000000..af6abb1 --- /dev/null +++ b/src/ui/controls/FUiCtrl_ToolbarPresenter.cpp @@ -0,0 +1,1497 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ToolbarPresenter.cpp + * @brief This is the implementation file for the _ToolbarPresenter class. + */ + +#include +#include +#include +#include +#include +#include +#include "FUi_UiTouchEvent.h" +#include "FUi_ResourceManager.h" +#include "FUiCtrl_Label.h" +#include "FUiCtrl_ToolbarPresenter.h" +#include "FUiCtrl_ToolbarModel.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_ToolbarPresenter::_ToolbarPresenter(void) + : __pToolbar(null) + , __pToolbarModel(null) + , __initialDraw(true) + , __tabEditEnabled(false) + , __beingEdited(false) + , __touchInitiatedInToolbar(false) + , __editItemIndex(-1) + , __initialPressedItemIndex(-1) + , __initialPressesItemStatus(_BUTTON_STATUS_NORMAL) + , __pEditItem(null) + , __pTitleBackgroundBitmap(null) + , __pTitleSlideTimer(null) + , __titleRect(Rectangle(0, 0, 0, 0)) + , __descriptionRect(Rectangle(0, 0, 0, 0)) + , __titleText(L"") + , __pTitleTextFont(null) + , __pTextFont(null) + , __pDescriptionTextObject(null) + , __pTitleTextObject(null) + , __titleSlidingAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT) + , __fontStyle(0) + , __fontSize(0) + , __touchMoveHandled(false) +{ + __currentTouchPosition = Point(0, 0); +} + +_ToolbarPresenter::~_ToolbarPresenter(void) +{ + if (__pToolbarModel) + { + delete __pToolbarModel; + __pToolbarModel = null; + } + + if (__pEditItem) + { + __pToolbar->DetachChild(*__pEditItem); + delete __pEditItem; + __pEditItem = null; + } + + if (__pTitleBackgroundBitmap) + { + delete __pTitleBackgroundBitmap; + __pTitleBackgroundBitmap = null; + } + + if (__pTitleSlideTimer) + { + delete __pTitleSlideTimer; + __pTitleSlideTimer = null; + } + + if (__pDescriptionTextObject) + { + delete __pDescriptionTextObject; + __pDescriptionTextObject = null; + } + + if (__pTitleTextObject) + { + delete __pTitleTextObject; + __pTitleTextObject = null; + } +} + +result +_ToolbarPresenter::Construct(const _Toolbar& toolbar) +{ + __pToolbar = const_cast<_Toolbar*>(&toolbar); + + __fontStyle = FONT_STYLE_BOLD; + + return E_SUCCESS; +} + +result +_ToolbarPresenter::Install(void) +{ + _ToolbarModel* pModel = new (std::nothrow) _ToolbarModel(); + + _SetModel(*pModel); + + result r = pModel->Construct(); + + return r; +} + +result +_ToolbarPresenter::Draw(void) +{ + result r = E_SUCCESS; + + ToolbarStyle toolbarStyle = __pToolbar->GetStyle(); + + DrawBackground(); + + DrawItems(); + + Canvas* pCanvas = __pToolbar->GetCanvasN(); + + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + + return E_SYSTEM; + } + + int buttonItemGap = 0; + int headerButtonItemHeight = 0; + int separatorHeight = 0; + int rightMargin = 0; + + int footerButtonItemWidth = 0; + int footerButtonItemHeight = 0; + int fontSize; + + Rectangle bounds(0, 0, __pToolbar->GetBounds().width, __pToolbar->GetBounds().height); + + const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize(); + const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width); + + if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) + { + if (bounds.width > portraitSize.width) + { + bounds.width = portraitSize.width; + } + } + else + { + if (bounds.width > landscapeSize.width) + { + bounds.width = landscapeSize.width; + } + } + + int segmentedTitleTextAreaHeight = 0; + + if (toolbarStyle == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || toolbarStyle == TOOLBAR_TAB_WITH_TITLE) + { + GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, __pToolbar->GetOrientation(), headerButtonItemHeight); + GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), segmentedTitleTextAreaHeight); + } + else + { + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_HEIGHT, __pToolbar->GetOrientation(), headerButtonItemHeight); + GET_SHAPE_CONFIG(HEADER::BUTTON_ITEM_TOP_MARGIN, __pToolbar->GetOrientation(), segmentedTitleTextAreaHeight); + } + + GET_SHAPE_CONFIG(HEADER::SEPARATOR_WIDTH, __pToolbar->GetOrientation(), buttonItemGap); + GET_SHAPE_CONFIG(HEADER::SEPARATOR_HEIGHT, __pToolbar->GetOrientation(), separatorHeight); + GET_SHAPE_CONFIG(HEADER::RIGHT_MARGIN, __pToolbar->GetOrientation(), rightMargin); + + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, __pToolbar->GetOrientation(), footerButtonItemWidth); + GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_HEIGHT, __pToolbar->GetOrientation(), footerButtonItemHeight); + + if ((toolbarStyle == TOOLBAR_TITLE || toolbarStyle == TOOLBAR_HEADER_SEGMENTED || toolbarStyle == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE + || toolbarStyle == TOOLBAR_TAB || toolbarStyle == TOOLBAR_TAB_WITH_TITLE || toolbarStyle == TOOLBAR_TEXT)) + { + if (__pTitleBackgroundBitmap) + { + delete __pTitleBackgroundBitmap; + __pTitleBackgroundBitmap = null; + } + + if (toolbarStyle == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || toolbarStyle == TOOLBAR_TAB_WITH_TITLE) + { + GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE_WITH_SEGMENTED, __pToolbar->GetOrientation(), fontSize); + + if (!__titleText.IsEmpty()) + { + __fontSize = fontSize; + + __pTitleTextFont = __pToolbar->GetFallbackFont(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pTitleTextFont, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength()); + } + } + else if (toolbarStyle == TOOLBAR_TITLE && __pToolbar->GetDescriptionText() != L"" + && __pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) == ANIMATION_STOPPED) + { + GET_SHAPE_CONFIG(HEADER::TITLE_TOP_MARGIN_WITH_DESCRIPTION, __pToolbar->GetOrientation(), __titleRect.y); + GET_SHAPE_CONFIG(HEADER::TITLE_DISPLAY_HEIGHT_WITH_DESCRIPTION, __pToolbar->GetOrientation(), __titleRect.height); + GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE_WITH_DESCRIPTION, __pToolbar->GetOrientation(), fontSize); + + DrawDescriptionText(); + + if(!__titleText.IsEmpty()) + { + __fontSize = fontSize; + + __pTitleTextFont = __pToolbar->GetFallbackFont(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pTitleTextFont, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength()); + } + } + + __pTitleBackgroundBitmap = new (std::nothrow) Bitmap(); + __pTitleBackgroundBitmap->Construct(*pCanvas, __titleRect); + + DrawTitleText(pCanvas); + } + + if (toolbarStyle == TOOLBAR_TITLE || toolbarStyle == TOOLBAR_HEADER_SEGMENTED || toolbarStyle == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE) + { + if (__pToolbar->GetButton(RIGHT_BUTTON)) + { + if (__pToolbar->GetButton(LEFT_BUTTON)) + { + if (__pToolbar->GetButton(LEFT_BUTTON)->GetText() != L"" && __pToolbar->GetButton(RIGHT_BUTTON)->GetText() != L"") + { + DrawSeparator(TOOLBAR_SEPARATOR_HEADER_BUTTON, Point(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBounds().width - buttonItemGap - rightMargin, + segmentedTitleTextAreaHeight + (headerButtonItemHeight - separatorHeight) / 2), pCanvas); + } + } + } + } + + + int itemCount = __pToolbar->GetItemCount(); + + if (itemCount == 1) + { + //DrawSeparator(TOOLBAR_SEPARATOR_FOOTER_BUTTON, Point(__pToolbar->GetItem(0)->GetBounds().x + __pToolbar->GetItem(0)->GetBounds().width, + // (__pToolbar->GetBounds().height - separatorHeight) / 2), pCanvas); + } + else + { + if (toolbarStyle == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || toolbarStyle == TOOLBAR_TAB_WITH_TITLE) + { + for (int i = 0; i < itemCount - 1 ; i++) + { + DrawSeparator(TOOLBAR_SEPARATOR_FOOTER_BUTTON, Point(__pToolbar->GetItem(i)->GetBounds().x + __pToolbar->GetItem(i)->GetBounds().width, + segmentedTitleTextAreaHeight + (headerButtonItemHeight - separatorHeight) / 2), pCanvas); + } + } + else + { + for (int i = 0; i < itemCount - 1 ; i++) + { + if (!(toolbarStyle == TOOLBAR_TEXT || toolbarStyle == TOOLBAR_ICON || toolbarStyle == TOOLBAR_ICON_TEXT)) + { + DrawSeparator(TOOLBAR_SEPARATOR_FOOTER_BUTTON, Point(__pToolbar->GetItem(i)->GetBounds().x + __pToolbar->GetItem(i)->GetBounds().width, + (__pToolbar->GetBounds().height - separatorHeight) / 2), pCanvas); + } + } + } + } + + + if (__initialDraw) + { + if ((toolbarStyle == TOOLBAR_TAB || toolbarStyle == TOOLBAR_TAB_WITH_TITLE + || toolbarStyle == TOOLBAR_SEGMENTED || toolbarStyle == TOOLBAR_HEADER_SEGMENTED || toolbarStyle == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE) + && __pToolbar->GetItemCount() > 0 && __pToolbarModel->GetSelectedItemIndex() == -1) + { + int firstEnabledItemIndex = __pToolbar->GetFirstEnabledItemIndex(); + + if(firstEnabledItemIndex != -1) + { + __pToolbar->SetItemSelected(firstEnabledItemIndex, true); + } + } + + __initialDraw = false; + } + + delete pCanvas; + + return E_SUCCESS; +} + +void +_ToolbarPresenter::DrawBackground(void) +{ + Canvas* pCanvas = __pToolbar->GetCanvasN(); + + if (pCanvas == null) + { + SysLog(NID_UI_CTRL, "Cannot get a canvas."); + + return; + } + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + + ToolbarStyle style = __pToolbar->GetStyle(); + + if (style == TOOLBAR_SOFTKEY) + { + delete pCanvas; + + return; + } + + Bitmap* pReplacementColorBackgroundBitmap = null; + Bitmap* pBackgroundBitmap = null; + + Rectangle bounds(0, 0, __pToolbar->GetBounds().width, __pToolbar->GetBounds().height); + + const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize(); + const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width); + + if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) + { + if (bounds.width > portraitSize.width) + { + bounds.width = portraitSize.width; + } + } + else + { + if (bounds.width > landscapeSize.width) + { + bounds.width = landscapeSize.width; + } + } + + pBackgroundBitmap = __pToolbar->GetBackgroundBitmap(); + + pReplacementColorBackgroundBitmap = + _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pToolbar->GetColor()); + + if (__pToolbar->IsUserBackgroundBitmap()) + { + if (pBackgroundBitmap) + { + if (pBackgroundBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap); + } + else + { + pCanvas->DrawBitmap(bounds, *pBackgroundBitmap, Rectangle(0, 0, pBackgroundBitmap->GetWidth(), pBackgroundBitmap->GetHeight())); + } + } + else + { + pCanvas->FillRectangle(__pToolbar->GetColor(), bounds); + } + } + else + { + if (pReplacementColorBackgroundBitmap) + { + if (pReplacementColorBackgroundBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pReplacementColorBackgroundBitmap); + } + else + { + pCanvas->DrawBitmap(bounds, *pReplacementColorBackgroundBitmap, Rectangle(0, 0, pReplacementColorBackgroundBitmap->GetWidth(), + pReplacementColorBackgroundBitmap->GetHeight())); + } + } + else + { + pCanvas->FillRectangle(__pToolbar->GetColor(), bounds); + } + } + + delete pCanvas; + delete pReplacementColorBackgroundBitmap; + + return; +} + +void +_ToolbarPresenter::DrawDescriptionText(void) +{ + result r = E_SUCCESS; + + int textAreaHeight = 0; + int fontSize = 0; + int titleIconWidth = 0; + + GET_SHAPE_CONFIG(HEADER::DESCRIPTION_TEXT_HEIGHT, __pToolbar->GetOrientation(), textAreaHeight); + GET_SHAPE_CONFIG(HEADER::DESCRIPTION_TEXT_FONT_SIZE, __pToolbar->GetOrientation(), fontSize); + GET_SHAPE_CONFIG(HEADER::ICON_WIDTH, __pToolbar->GetOrientation(), titleIconWidth); + + __fontSize = fontSize; + + __pTextFont = __pToolbar->GetFallbackFont(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, __pTextFont, r, "[%s] Propagating.", GetErrorMessage(r)); + + if (__pToolbar->GetTitleIcon() != null) + { + __descriptionRect.x = __toolbarUsableArea.x + titleIconWidth + __toolbarUsableArea.x; + } + else + { + __descriptionRect.x = __toolbarUsableArea.x; + } + + __descriptionRect.y = __titleRect.y + __titleRect.height; + + if(__titleText.IsEmpty()) + { + __descriptionRect.width = __toolbarUsableArea.width; + } + else + { + __descriptionRect.width = __titleRect.width; + } + + __descriptionRect.height = textAreaHeight; + + Canvas* pCanvas = __pToolbar->GetCanvasN(); + + if (__pDescriptionTextObject) + { + __pDescriptionTextObject->SetFont(__pTextFont, 0, __pDescriptionTextObject->GetTextLength()); + __pDescriptionTextObject->SetForegroundColor(__pToolbar->GetDescriptionTextColor(), 0, __pDescriptionTextObject->GetTextLength()); + __pDescriptionTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pDescriptionTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT); + __pDescriptionTextObject->SetBounds(__descriptionRect); + __pDescriptionTextObject->Compose(); + __pDescriptionTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + } + + delete pCanvas; + + return; +} + +void +_ToolbarPresenter::DrawEditItem(const Point& point) +{ + if (__pEditItem == null ) + { + return; + } + + Point anchor = Point(0,0); + + anchor.x = point.x - (__pEditItem->GetSize().width / 2); + anchor.y = point.y - (__pEditItem->GetSize().width / 2); + + __pEditItem->SetPosition(anchor); + + __pToolbar->Invalidate(true); + + return; +} + +void +_ToolbarPresenter::DrawSeparator(ToolbarSeparatorType type, const Point& point, Canvas* pCanvas) +{ + if (__pToolbar->GetStyle() == TOOLBAR_SOFTKEY) + { + return ; + } + + int separatorWidth = 0; + int separatorHeight = 0; + + GET_SHAPE_CONFIG(HEADER::SEPARATOR_WIDTH, __pToolbar->GetOrientation(), separatorWidth); + GET_SHAPE_CONFIG(HEADER::SEPARATOR_HEIGHT, __pToolbar->GetOrientation(), separatorHeight); + + if (!__pToolbar->IsTransparent()) + { + Bitmap* pSeparatorBitmap = null; + GET_BITMAP_CONFIG_N(HEADER::DIVIDER_LINE_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pSeparatorBitmap); + + if (pSeparatorBitmap) + { + if (pSeparatorBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(Rectangle(point.x, point.y, separatorWidth, separatorHeight), *pSeparatorBitmap); + } + else + { + pCanvas->DrawBitmap(Point(point.x, point.y), *pSeparatorBitmap); + } + + delete pSeparatorBitmap; + } + } + else + { + Bitmap* pTranslucentSeparatorBitmap = null; + GET_BITMAP_CONFIG_N(HEADER::DIVIDER_LINE_TRANSLUCENT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTranslucentSeparatorBitmap); + + if (pTranslucentSeparatorBitmap) + { + if (pTranslucentSeparatorBitmap->IsNinePatchedBitmap()) + { + pCanvas->DrawNinePatchedBitmap(Rectangle(point.x, point.y, separatorWidth, separatorHeight), *pTranslucentSeparatorBitmap); + } + else + { + pCanvas->DrawBitmap(Point(point.x, point.y), *pTranslucentSeparatorBitmap); + } + + delete pTranslucentSeparatorBitmap; + } + } + + return; +} + +void +_ToolbarPresenter::DrawItems(void) +{ + result r = E_SUCCESS; + + Canvas* pCanvas = __pToolbar->GetCanvasN(); + + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, E_INVALID_STATE, "[E_INVALID_STATE] System error occurred."); + + Rectangle usableArea = __toolbarUsableArea; + + Bitmap* pTitleIcon = __pToolbar->GetTitleIcon(); + + int iconWidth = 0; + int titleDisplayHeight = 0; + int iconAreaHeight = 0; + int leftMargin = 0; + int headerTopMargin = 0; + int processingAnimationIconSize = 0; + int processingAnimationIconGap = 0; + int titleCharacterCount = 0; + int fontSize = 0; + Dimension titleTextDimension(0, 0); + int totalWidth = 0; + int titleHeight = 0; + + ToolbarStyle toolbarStyle = __pToolbar->GetStyle(); + + GET_SHAPE_CONFIG(HEADER::LEFT_MARGIN, __pToolbar->GetOrientation(), leftMargin); // 16 + GET_SHAPE_CONFIG(HEADER::PROCESSING_ANIMATION_ICON_SIZE, __pToolbar->GetOrientation(), processingAnimationIconSize); // 32 + GET_SHAPE_CONFIG(HEADER::PROCESSING_ANIMATION_ICON_GAP, __pToolbar->GetOrientation(), processingAnimationIconGap); // 32 + + if (__pToolbar->GetStyle() == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || __pToolbar->GetStyle() == TOOLBAR_TAB_WITH_TITLE) + { + GET_SHAPE_CONFIG(HEADER::TITLE_TOP_MARGIN_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), headerTopMargin); // 18, 17 + GET_SHAPE_CONFIG(HEADER::TITLE_DISPLAY_HEIGHT_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), titleDisplayHeight); // 60 + } + else + { + GET_SHAPE_CONFIG(HEADER::TOP_MARGIN, __pToolbar->GetOrientation(), headerTopMargin); // 34, 17 + GET_SHAPE_CONFIG(HEADER::TITLE_DISPLAY_HEIGHT, __pToolbar->GetOrientation(), titleDisplayHeight); //64, 64 + } + + GET_SHAPE_CONFIG(HEADER::ICON_WIDTH, __pToolbar->GetOrientation(), iconWidth); // 38 + + GET_SHAPE_CONFIG(HEADER::TITLE_DISPLAY_HEIGHT_WITH_DESCRIPTION, __pToolbar->GetOrientation(), iconAreaHeight);//50, 42 + + + if (!__titleText.IsEmpty()) + { + titleCharacterCount = __titleText.GetLength(); // alphabet count + + if (toolbarStyle == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || toolbarStyle == TOOLBAR_TAB_WITH_TITLE) + { + r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE_WITH_SEGMENTED, __pToolbar->GetOrientation(), fontSize); + } + else if (toolbarStyle == TOOLBAR_TITLE && __pToolbar->GetDescriptionText() != L"" + && __pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) == ANIMATION_STOPPED) + { + r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE_WITH_DESCRIPTION, __pToolbar->GetOrientation(), fontSize); + } + else + { + r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE, __pToolbar->GetOrientation(), fontSize); + } + + if (IsFailed(r)) + { + delete pCanvas; + + return; + } + + __fontSize = fontSize; + + __pTitleTextFont = __pToolbar->GetFallbackFont(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, __pTitleTextFont, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength()); + + __pTitleTextFont->GetTextExtent(__titleText, titleCharacterCount, titleTextDimension); + + totalWidth = titleTextDimension.width; // pixel + titleHeight = titleTextDimension.height; // pixel + + __titleRect.height = _FontImpl::GetInstance(*__pTitleTextFont)->GetLeading(); + + + if (pTitleIcon) + { + pTitleIcon->Scale(Dimension(iconWidth, iconWidth)); + } + + if (pTitleIcon) + { + totalWidth += (pTitleIcon->GetWidth() + usableArea.x); + } + + if ((__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE)) != ANIMATION_STOPPED) + { + totalWidth += processingAnimationIconSize + processingAnimationIconGap; + } + + if (totalWidth > usableArea.width) + { + __titleRect.width = titleTextDimension.width - (totalWidth - usableArea.width);; + + if (pTitleIcon) + { + pCanvas->DrawBitmap(Point(usableArea.x, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeight()) / 2), *(pTitleIcon)); + + __titleRect.x = usableArea.x + pTitleIcon->GetWidth() + usableArea.x; + __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2; + + if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED) + { + __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE, + usableArea.x + (pTitleIcon->GetWidth() + processingAnimationIconGap) + __titleRect.width + processingAnimationIconGap, + headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2); + } + } + else + { + __titleRect.x = usableArea.x; + __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2; + + if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED) + { + __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE, + usableArea.x + __titleRect.width + processingAnimationIconGap, + headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2); + } + } + } + else + { + __titleRect.width = usableArea.width; + + if (pTitleIcon) + { + __titleRect.x = leftMargin + pTitleIcon->GetWidth() + leftMargin; + __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2; + + if(__pTitleTextObject->GetAlignment() & TEXT_OBJECT_ALIGNMENT_CENTER) + { + leftMargin = (__titleRect.width - titleTextDimension.width) / 2; + } + else if(__pTitleTextObject->GetAlignment() & TEXT_OBJECT_ALIGNMENT_RIGHT) + { + leftMargin = __titleRect.width - titleTextDimension.width - leftMargin * 2; + } + + pCanvas->DrawBitmap(Point(leftMargin, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeight()) / 2), *(pTitleIcon)); + + if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED) + { + __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE, + usableArea.x + (pTitleIcon->GetWidth() + processingAnimationIconGap) + titleTextDimension.width + processingAnimationIconGap, + headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2); + } + + __titleRect.width -= (pTitleIcon->GetWidth() + usableArea.x); + } + else + { + __titleRect.x = leftMargin; + __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2; + + if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED) + { + __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE, + leftMargin + titleTextDimension.width + processingAnimationIconGap, + headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2); + } + } + } + } + else // empty title + { + if (pTitleIcon && __pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED) + { + pTitleIcon->Scale(Dimension(iconWidth, iconWidth)); + + if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_CENTER) + { + leftMargin = (leftMargin + usableArea.width - (pTitleIcon->GetWidth() + processingAnimationIconGap + processingAnimationIconSize)) / 2; + } + else if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_RIGHT) + { + leftMargin = leftMargin + usableArea.width - (pTitleIcon->GetWidth() + processingAnimationIconGap + processingAnimationIconSize); + } + + pCanvas->DrawBitmap(Point(leftMargin, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeight()) / 2), *(pTitleIcon)); + + __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE, + leftMargin + processingAnimationIconGap + processingAnimationIconSize, + headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2); + } + else if (pTitleIcon) + { + pTitleIcon->Scale(Dimension(iconWidth, iconWidth)); + + if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_CENTER) + { + leftMargin = usableArea.width / 2; + } + else if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_RIGHT) + { + leftMargin = usableArea.width - pTitleIcon->GetWidth(); + } + + pCanvas->DrawBitmap(Point(leftMargin, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeight()) / 2), *(pTitleIcon)); + } + else + { + if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_CENTER) + { + leftMargin = (usableArea.width - (processingAnimationIconGap + processingAnimationIconSize))/ 2; + } + else if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_RIGHT) + { + leftMargin = usableArea.width - (processingAnimationIconGap + processingAnimationIconSize); + } + + __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE, + leftMargin, headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2); + } + } + + delete pCanvas; + + return; +} + +result +_ToolbarPresenter::DrawTitleText(Canvas* pCanvas) +{ + TimerForTitleSlideInit(); + + if (__titleText.IsEmpty()) + { + return E_SUCCESS; + } + + __pTitleTextObject->SetForegroundColor(__pToolbar->GetTitleTextColor(), 0, __pTitleTextObject->GetTextLength()); + __pTitleTextObject->SetBounds(__titleRect); + __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE); + __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT); + __pTitleTextObject->Compose(); + __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas)); + + if (__pTitleTextObject->IsActionOn() == true) + { + TimerForTitleSlideStart(); + } + + return E_SUCCESS; +} + +int +_ToolbarPresenter::GetSelectedItemIndex(void) const +{ + return __pToolbarModel->GetSelectedItemIndex(); +} + +bool +_ToolbarPresenter::IsInitialDraw(void) const +{ + return __initialDraw; +} + +bool +_ToolbarPresenter::IsTabEditModeEnabled(void) const +{ + return __tabEditEnabled; +} + +result +_ToolbarPresenter::SetDescriptionText(const String& description) +{ + result r = E_SUCCESS; + + int length = description.GetLength(); + int fontSize = 0; + + wchar_t* tempString = const_cast(description.GetPointer()); + + // description text + if (__pDescriptionTextObject != null) + { + delete __pDescriptionTextObject; + __pDescriptionTextObject = null; + } + + __pDescriptionTextObject = new (std::nothrow) TextObject(); + + if (__pDescriptionTextObject == null) + { + return E_OUT_OF_MEMORY; + } + __pDescriptionTextObject->Construct(); + TextSimple* pSimpleText = new (std::nothrow) TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + __pDescriptionTextObject->AppendElement(*pSimpleText); + __pDescriptionTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + __pDescriptionTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER); + + GET_SHAPE_CONFIG(HEADER::DESCRIPTION_TEXT_FONT_SIZE, __pToolbar->GetOrientation(), fontSize); + + __fontSize = fontSize; + + __pTextFont = __pToolbar->GetFallbackFont(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pTextFont, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pDescriptionTextObject->SetFont(__pTextFont, 0, __pDescriptionTextObject->GetTextLength()); + + return r; +} + +result +_ToolbarPresenter::SetItemSelected(int itemIndex) +{ + return __pToolbarModel->SetSelectedItemIndex(itemIndex); +} + +result +_ToolbarPresenter::SetInitialDrawState(bool state) +{ + DrawBackground(); + __initialDraw = state; + __titleText = L""; + + return E_SUCCESS; +} + +result +_ToolbarPresenter::SetTabEditModeEnabled(bool enable) +{ + __tabEditEnabled = enable; + + return E_SUCCESS; +} + +result +_ToolbarPresenter::SetTitleText(const String& title, HorizontalAlignment alignment) +{ + result r = E_SUCCESS; + + int length = title.GetLength(); + + __titleText = String(title); + wchar_t* tempString = const_cast(__titleText.GetPointer()); + + // title text + if (__pTitleTextObject != null) + { + delete __pTitleTextObject; + __pTitleTextObject = null; + } + + __pTitleTextObject = new (std::nothrow) TextObject(); + + if (__pTitleTextObject == null) + { + return E_OUT_OF_MEMORY; + } + __pTitleTextObject->Construct(); + TextSimple* pSimpleText = new (std::nothrow) TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + __pTitleTextObject->AppendElement(*pSimpleText); + + __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT); + + switch (alignment) + { + case ALIGNMENT_LEFT: + __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT); + break; + case ALIGNMENT_CENTER: + __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER); + break; + case ALIGNMENT_RIGHT: + __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT); + break; + default: + __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT); + break; + } + + int fontSize; + + r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE, __pToolbar->GetOrientation(), fontSize); + + __fontSize = fontSize; + + __pTitleTextFont = __pToolbar->GetFallbackFont(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pTitleTextFont, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength()); + + return r; +} + +result +_ToolbarPresenter::SetUsableAreaBounds(const Rectangle& rect) +{ + __toolbarUsableArea = rect; + + return E_SUCCESS; +} + +bool +_ToolbarPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) +{ + __touchInitiatedInToolbar = true; + + __currentTouchPosition = touchinfo.GetCurrentPosition(); + + __initialPressedItemIndex = __pToolbar->GetItemIndexFromPosition(__currentTouchPosition); + + if (__initialPressedItemIndex == -1) + { + return true; + } + else + { + _Button* pPressedButton = __pToolbar->GetItem(__initialPressedItemIndex); + + __initialPressesItemStatus = pPressedButton->GetButtonStatus(); + + if (__initialPressesItemStatus == _BUTTON_STATUS_DISABLED) + { + return true; + } + + pPressedButton->SetButtonStatus(_BUTTON_STATUS_PRESSED); + } + + __pToolbar->Invalidate(true); + + return true; +} + +bool +_ToolbarPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) +{ + if (!__touchInitiatedInToolbar) + { + return false; + } + + __touchInitiatedInToolbar = false; + + Point touchPoint = touchinfo.GetCurrentPosition(); + + int currentItemIndex = __pToolbar->GetItemIndexFromPosition(touchPoint); + + if ((__pToolbar->GetStyle() == TOOLBAR_TAB || __pToolbar->GetStyle() == TOOLBAR_TAB_WITH_TITLE)&& __beingEdited == true) + { + __beingEdited = false; + + if (currentItemIndex == -1) + { + if (__pEditItem) + { + __pToolbar->DetachChild(*__pEditItem); + delete __pEditItem; + __pEditItem = null; + } + + if (__initialPressedItemIndex != -1) + { + __pToolbar->GetItem(__initialPressedItemIndex)->SetButtonStatus(__initialPressesItemStatus); + } + } + else + { + __pToolbar->MoveItem(__editItemIndex, currentItemIndex); + + if (__pEditItem) + { + __pToolbar->DetachChild(*__pEditItem); + delete __pEditItem; + __pEditItem = null; + } + } + } + else + { + if ((__pToolbar->GetStyle() == TOOLBAR_TAB || __pToolbar->GetStyle() == TOOLBAR_TAB_WITH_TITLE) + && __pToolbar->GetItemCount() > 4)// && pMoreButton != null) + { + if (__initialPressedItemIndex != -1) + { + if (currentItemIndex == __initialPressedItemIndex) + { + if (__initialPressesItemStatus != _BUTTON_STATUS_DISABLED && __touchMoveHandled != true) + { + __pToolbar->SetItemSelected(currentItemIndex, true); + } + else + { + __pToolbar->GetItem(__initialPressedItemIndex)->SetButtonStatus(__initialPressesItemStatus, false); + } + } + else + { + __pToolbar->GetItem(__initialPressedItemIndex)->SetButtonStatus(__initialPressesItemStatus, false); + } + } + } + else + { + if (__initialPressedItemIndex != -1 && (currentItemIndex != __initialPressedItemIndex)) + { + __pToolbar->GetItem(__initialPressedItemIndex)->SetButtonStatus(__initialPressesItemStatus, false); + } + else + { + if (__initialPressedItemIndex != -1 && __initialPressesItemStatus != _BUTTON_STATUS_DISABLED) + { + __pToolbar->SetItemSelected(currentItemIndex, true); + } + + return true; + } + } + } + + __touchMoveHandled = false; + + // Restore status of other buttons to _BUTTON_STATUS_NORMAL // this can be removed + int itemCount = __pToolbar->GetItemCount(); + + for (int j = 0; j < itemCount; j++) + { + if (__pToolbar->GetItem(j) != null && __pToolbar->GetItem(j)->GetButtonStatus() == _BUTTON_STATUS_PRESSED) + { + __pToolbar->GetItem(j)->SetButtonStatus(_BUTTON_STATUS_NORMAL); + } + } + + // Update children + __pToolbar->Invalidate(true); + + return true; +} + +bool +_ToolbarPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) +{ + if (!__touchInitiatedInToolbar) + { + return false; + } + + if ((__pToolbar->GetStyle() == TOOLBAR_TAB || __pToolbar->GetStyle() == TOOLBAR_TAB_WITH_TITLE) + && __pToolbar->GetItemCount() > 4) + { + __touchMoveHandled = true; + } + + Point touchPoint = touchinfo.GetCurrentPosition(); + + if ((__pToolbar->GetStyle() == TOOLBAR_TAB || __pToolbar->GetStyle() == TOOLBAR_TAB_WITH_TITLE) + && __beingEdited == true) + { + DrawEditItem(touchinfo.GetCurrentPosition()); + } + else if (__initialPressedItemIndex != -1) + { + if (__initialPressesItemStatus == _BUTTON_STATUS_DISABLED) + { + return false; + } + + _Button* pCurrentButton = __pToolbar->GetItem(__initialPressedItemIndex); + + if (pCurrentButton == null) + { + return false; + } + + Rectangle itemBounds = pCurrentButton->GetBounds(); + + if (__touchMoveHandled) + { + pCurrentButton->SetButtonStatus(_BUTTON_STATUS_NORMAL); + } + else if (itemBounds.Contains(touchPoint)) + { + pCurrentButton->SetButtonStatus(_BUTTON_STATUS_PRESSED); + } + else + { + pCurrentButton->SetButtonStatus(__initialPressesItemStatus, false); + } + + pCurrentButton->Invalidate(false); + } + + if ((__pToolbar->GetStyle() == TOOLBAR_TAB || __pToolbar->GetStyle() == TOOLBAR_TAB_WITH_TITLE) + && __pToolbar->GetItemCount() > 4) + { + int distance = (touchinfo.GetCurrentPosition()).x - __currentTouchPosition.x; + int sideMargin = 0; + + GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, __pToolbar->GetOrientation(), sideMargin); + + Rectangle clientBounds = __pToolbar->GetBounds(); + + const Dimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSize(); + const Dimension landscapeSize = Dimension(portraitSize.height, portraitSize.width); + + if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) + { + if (clientBounds.width > portraitSize.width) + { + clientBounds.width = portraitSize.width; + } + } + else + { + if (clientBounds.width > landscapeSize.width) + { + clientBounds.width = landscapeSize.width; + } + } + + __currentTouchPosition = touchinfo.GetCurrentPosition(); + + _Button* pItem = null; + Rectangle itemBounds; + int itemCount = __pToolbar->GetItemCount(); + + if (distance > 0) // right move + { + pItem = __pToolbar->GetItem(0); + if (pItem == null) + { + return true; + } + + itemBounds = pItem->GetBounds(); + + if (itemBounds.x == 0) + { + return true; + } + + if (itemBounds.x + distance >= sideMargin) + { + distance = sideMargin - itemBounds.x; + } + } + else + { + pItem = __pToolbar->GetItem(itemCount - 1); + + if (pItem == null) + { + return true; + } + + itemBounds = pItem->GetBounds(); + + if (itemBounds.x + itemBounds.width == clientBounds.width - sideMargin) + { + return true; + } + + if (itemBounds.x + itemBounds.width + distance <= clientBounds.width - sideMargin) + { + distance = (clientBounds.width - sideMargin) - (itemBounds.x + itemBounds.width); + } + } + + AdjustItemPositionX(distance); + + Draw(); + } + + return false; +} + +bool +_ToolbarPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) +{ + __touchInitiatedInToolbar = false; + + // Restore status of other buttons to _BUTTON_STATUS_NORMAL // this can be removed + int itemCount = __pToolbar->GetItemCount(); + + for (int i = 0; i < itemCount; i++) + { + if (__pToolbar->GetItem(i) != null && __pToolbar->GetItem(i)->GetButtonStatus() == _BUTTON_STATUS_PRESSED) + { + __pToolbar->GetItem(i)->SetButtonStatus(_BUTTON_STATUS_NORMAL); + } + } + + // Update children + __pToolbar->Invalidate(true); + + return true; +} + +bool +_ToolbarPresenter::OnLongPressGestureDetected(void) +{ + if (__pToolbar->IsTabEditModeEnabled() == true) + { + int longPressedItemIndex = __pToolbar->GetItemIndexFromPosition(__currentTouchPosition); + + if (longPressedItemIndex == -1) + { + return false; + } + + __editItemIndex = longPressedItemIndex; + + __beingEdited = true; + + _Button* pButton = null; + pButton = __pToolbar->GetItem(__editItemIndex); + SysTryReturn(NID_UI_CTRL, pButton, true, E_INVALID_STATE, "[E_INVALID_STATE] Unable to retrieve a button"); + + pButton->SetButtonStatus(_BUTTON_STATUS_NORMAL); + + Rectangle itemBounds = pButton->GetBounds(); + + if (__pEditItem) + { + __pToolbar->DetachChild(*__pEditItem); + delete __pEditItem; + __pEditItem = null; + } + + __pEditItem = _Label::CreateLabelN(); + SysTryCatch(NID_UI_CTRL, __pEditItem, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + Canvas* pCanvas = pButton->GetCanvasN(); + SysTryCatch(NID_UI_CTRL, pCanvas, , E_INVALID_STATE, "[E_INVALID_STATE] Unable to retrieve a Canvas."); + + Bitmap* pEditItemBitmap = new (std::nothrow) Bitmap(); + result r = pEditItemBitmap->Construct(*pCanvas, Rectangle(0, 0, itemBounds.width, itemBounds.height)); + + if (IsFailed(r)) + { + delete pEditItemBitmap; + pEditItemBitmap = null; + + delete pCanvas; + + goto CATCH; + } + + __pEditItem->SetBounds(itemBounds); + __pEditItem->SetBackgroundBitmap(*pEditItemBitmap); + + delete pCanvas; + delete pEditItemBitmap; + + __pToolbar->AttachChild(*__pEditItem); + __pToolbar->SetChildAlwaysOnTop(*__pEditItem); + + __pToolbar->Draw(); + } + + return true; + +CATCH: + if (__pEditItem) + { + delete __pEditItem; + __pEditItem = null; + } + + return true; +} + +void +_ToolbarPresenter::OnTimerExpired(Timer& timer) +{ + Timer* onTimer = &timer; + + if (onTimer == __pTitleSlideTimer) + { + TimerForTitleSlideTimeout(); + } + + return; +} + +result +_ToolbarPresenter::TimerForTitleSlideInit(void) +{ + result r = E_SUCCESS; + + if (__pTitleSlideTimer != null) + { + delete __pTitleSlideTimer; + __pTitleSlideTimer = null; + } + + return r; +} + +result +_ToolbarPresenter::TimerForTitleSlideStart(void) +{ + result r = E_SUCCESS; + + if (__pTitleSlideTimer == null) + { + __pTitleSlideTimer = new (std::nothrow) Timer(); + if (__pTitleSlideTimer == null) + { + r = E_OUT_OF_MEMORY; + goto CATCH; + } + + r = __pTitleSlideTimer->Construct(*this); + if (IsFailed(r)) + { + delete __pTitleSlideTimer; + goto CATCH; + } + } + + r = __pTitleSlideTimer->Start(100); + if (IsFailed(r)) + { + goto CATCH; + } + +CATCH: + return r; +} + +result +_ToolbarPresenter::TimerForTitleSlideTimeout(void) +{ + result r = E_SUCCESS; + + Canvas* pCanvas = __pToolbar->GetCanvasN(); + SysTryReturnResult(NID_UI_CTRL, pCanvas, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pCanvas is invalid!"); + + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(__titleRect); + + if (__pTitleBackgroundBitmap) + { + pCanvas->DrawBitmap(__titleRect, *__pTitleBackgroundBitmap); + } + + if (__pTitleTextObject->IsChanged()) + { + DrawTitleText(pCanvas); + } + + __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas)); + + delete pCanvas; + + r = TimerForTitleSlideStart(); + + return r; +} + +result +_ToolbarPresenter::AdjustItemPositionX(int distance) +{ + int index = 0; + int itemCount = __pToolbar->GetItemCount(); + _Button* pItem = __pToolbar->GetItem(index); + + while (pItem != null) + { + Rectangle bounds = pItem->GetBounds(); + bounds.x += distance; + pItem->SetBounds(bounds); + index++; + + if (index < itemCount) + { + pItem = __pToolbar->GetItem(index); + } + else + { + break; + } + } + + return E_SUCCESS; +} + +Rectangle +_ToolbarPresenter::GetTitleTextBounds(void) const +{ + return __titleRect; +} + +Rectangle +_ToolbarPresenter::GetDescriptionBounds(void) const +{ + return __descriptionRect; +} + +result +_ToolbarPresenter::_SetModel(const _ToolbarModel& toolbarModel) +{ + __pToolbarModel = const_cast<_ToolbarModel*>(&toolbarModel); + + return E_SUCCESS; +} + +void +_ToolbarPresenter::OnFontChanged(Font* pFont) +{ + __pTextFont = pFont; + __pTitleTextFont = pFont; + + return; +} + +void +_ToolbarPresenter::OnFontInfoRequested(unsigned long& style, int& size) +{ + style = __fontStyle; + size = __fontSize; + + return; +} + +void +_ToolbarPresenter::SetFontInfo(unsigned long style, int size) +{ + __fontStyle = style; + __fontSize = size; + + return; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_UiFastScrollEvent.cpp b/src/ui/controls/FUiCtrl_UiFastScrollEvent.cpp new file mode 100644 index 0000000..ce7b0c1 --- /dev/null +++ b/src/ui/controls/FUiCtrl_UiFastScrollEvent.cpp @@ -0,0 +1,90 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_UiFastScrollEvent.cpp +* @brief This is the implementation for the _UiFastScrollEvent class. +*/ + +// includes +#include +#include "FUiCtrl_UiFastScrollEvent.h" +#include "FUiCtrl_UiFastScrollEventArg.h" +#include "FUiCtrl_IFastScrollListener.h" + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +//////////////////////////////////////////////////////////////////////////////// +/// __ExpandableItemEvent class Lifecycle + +_UiFastScrollEvent::_UiFastScrollEvent(void) + : __pSource(null) +{ + // nothing +} + +_UiFastScrollEvent::~_UiFastScrollEvent(void) +{ + // nothing +} + +result +_UiFastScrollEvent::Construct(const Tizen::Ui::_Control& source) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = const_cast <_Control*>(&source); + } + + return r; +} + + +//////////////////////////////////////////////////////////////////////////////// +/// __WindowEvent class Accessor + +const Tizen::Ui::_Control* +_UiFastScrollEvent::GetSource(void) const +{ + return __pSource; +} + +//////////////////////////////////////////////////////////////////////////////// +/// __ExpandableItemEvent class Operation + +void +_UiFastScrollEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to IFastScrollListener + _IUiFastScrollListener* pFastScrollListener = dynamic_cast <_IUiFastScrollListener*>(&listener); + SysTryReturnVoidResult(NID_UI, pFastScrollListener, E_INVALID_ARG, "[E_INVALID_ARG] listener type is invalid."); + + // cast to __UiFastScrollEventArg + _UiFastScrollEventArg* pArg = (_UiFastScrollEventArg*) const_cast (&arg); + SysTryReturnVoidResult(NID_UI, pArg, E_INVALID_ARG, "[E_INVALID_ARG] Event argument type is invalid."); + + pFastScrollListener->OnUiFastScrollIndexSelected(*pArg->GetSource(), const_cast (pArg->GetIndex())); +} +}}} diff --git a/src/ui/controls/FUiCtrl_UiFastScrollEventArg.cpp b/src/ui/controls/FUiCtrl_UiFastScrollEventArg.cpp new file mode 100644 index 0000000..106939d --- /dev/null +++ b/src/ui/controls/FUiCtrl_UiFastScrollEventArg.cpp @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_UiFastScrollEventArg.cpp +* @brief This is the implementation for the _UiFastScrollEventArg class. +*/ + +// includes +#include "FUiCtrl_UiFastScrollEventArg.h" + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_UiFastScrollEventArg::_UiFastScrollEventArg(const Tizen::Ui::_Control& source, const Tizen::Ui::Controls::_FastScrollIndex& index) + : __pSource(const_cast <_Control*>(&source)) + , __index(index) +{ + // nothing +} + +_UiFastScrollEventArg::~_UiFastScrollEventArg(void) +{ + // nothing +} + +_Control* +_UiFastScrollEventArg::GetSource(void) +{ + return __pSource; +} + +const Tizen::Ui::Controls::_FastScrollIndex& +_UiFastScrollEventArg::GetIndex(void) +{ + return __index; +} + +}}} diff --git a/src/ui/controls/FUiCtrl_UiIconListItemEvent.cpp b/src/ui/controls/FUiCtrl_UiIconListItemEvent.cpp new file mode 100644 index 0000000..05c2daa --- /dev/null +++ b/src/ui/controls/FUiCtrl_UiIconListItemEvent.cpp @@ -0,0 +1,90 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_UiIconListItemEvent.cpp + * @brief This is the implementation file for the _UiIconListItemEvent class. + */ + +#include + +#include "FUiCtrl_IconListView.h" +#include "FUiCtrl_IconListViewItemEventArg.h" +#include "FUiCtrl_IIconListItemEventListener.h" +#include "FUiCtrl_UiIconListItemEvent.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +_UiIconListItemEvent::_UiIconListItemEvent(void) + : __pSource(null) +{ +} + +_UiIconListItemEvent::~_UiIconListItemEvent(void) +{ +} + +result +_UiIconListItemEvent::Construct(const _IconListView& source) +{ + result r = _Event::Initialize(); + + // set event source + if (r == E_SUCCESS) + { + __pSource = const_cast <_IconListView*>(&source); + } + + return r; +} + +const _IconListView* +_UiIconListItemEvent::GetSource(void) const +{ + return __pSource; +} + +void +_UiIconListItemEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg) +{ + // cast to IIconListItemEventListener + _IIconListItemEventListener* pItemListener = dynamic_cast<_IIconListItemEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, (pItemListener != null), E_INVALID_ARG, "[E_INVALID_ARG] Invalid listener is used."); + + // cast to _UiIconListItemEventArg + const _IconListViewItemEventArg* pItemEventArg = dynamic_cast(&arg); + SysTryReturnVoidResult(NID_UI_CTRL, (pItemEventArg != null), E_INVALID_ARG, + "[E_INVALID_ARG] Invalid event argument is used."); + + switch (pItemEventArg->GetEventType()) + { + case EVENT_TYPE_ITEM_SELECTED: + pItemListener->OnIconListItemStateChanged(const_cast<_IconListViewItemEventArg*>(pItemEventArg)); + break; + case EVENT_TYPE_OVERLAY_BITMAP_SELECTED: + pItemListener->OnIconListViewOverlayBitmapSelected(const_cast<_IconListViewItemEventArg*>(pItemEventArg)); + break; + case EVENT_TYPE_ITEM_REORDERED: + pItemListener->OnIconListViewItemReordered(const_cast<_IconListViewItemEventArg*>(pItemEventArg)); + break; + } + + SetLastResult(E_SUCCESS); +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_UiListViewItemEvent.cpp b/src/ui/controls/FUiCtrl_UiListViewItemEvent.cpp new file mode 100644 index 0000000..f07c0f4 --- /dev/null +++ b/src/ui/controls/FUiCtrl_UiListViewItemEvent.cpp @@ -0,0 +1,92 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_UiListViewItemEvent.cpp + * @brief This is the implementation file for _UiListViewItemEvent class. + * + * This file contains the implementation of _UiListViewItemEvent class. + */ + +#include +#include +#include "FUiCtrl_IUiListViewItemEventListener.h" +#include "FUiCtrl_UiListViewItemEvent.h" +#include "FUiCtrl_UiListViewItemEventArg.h" + +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_UiListViewItemEvent::_UiListViewItemEvent(void) +{ + +} + +_UiListViewItemEvent::~_UiListViewItemEvent(void) +{ + +} + +void +_UiListViewItemEvent::SetSource(_Control* pSource) // temporary code +{ + __pSource = pSource; +} + +void +_UiListViewItemEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to _ItemEventArg + _UiListViewItemEventArg* pEventArg = dynamic_cast<_UiListViewItemEventArg*>(const_cast(&arg)); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_INVALID_ARG, ("[E_INVALID_ARG] event argument is invalid type.")); + + int index1 = pEventArg->GetArg1(); + int index2 = pEventArg->GetArg2(); + int index3 = pEventArg->GetArg3(); + + if (index3 < 0) + { + index3 = -1; + } + + _IUiListViewItemEventListener* pListener = dynamic_cast<_IUiListViewItemEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + switch (pEventArg->GetNotifyType()) + { + case NOTIFY_TYPE_ITEM_LONGPRESSED: + pListener->OnListViewItemLongPressed(*__pSource, index1, index2, index3); + break; + + case NOTIFY_TYPE_CONTEXTITEM_SELCTED: + pListener->OnListViewContextItemStateChanged(*__pSource, index1, index2, index3, LIST_CONTEXT_ITEM_STATUS_SELECTED); + break; + + case NOTIFY_TYPE_CONTEXTITEM_HIGHLIGHTED: + pListener->OnListViewContextItemStateChanged(*__pSource, index1, index2, index3, LIST_CONTEXT_ITEM_STATUS_HIGHLIGHTED); + break; + + default: + return; + } +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/controls/FUiCtrl_UiListViewItemEventArg.cpp b/src/ui/controls/FUiCtrl_UiListViewItemEventArg.cpp new file mode 100644 index 0000000..5f4cdd0 --- /dev/null +++ b/src/ui/controls/FUiCtrl_UiListViewItemEventArg.cpp @@ -0,0 +1,72 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_UiListViewItemEventArg.cpp + * @brief This is the implementation file for _UiListViewItemEventArg class. + * + * This file contains the implementation of _UiListViewItemEventArg class. + */ + +#include +#include "FUiCtrl_UiListViewItemEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_UiListViewItemEventArg::_UiListViewItemEventArg(int arg1, int arg2, int arg3, ListViewItemEventNotifyType type) + : __arg1(arg1) + , __arg2(arg2) + , __arg3(arg3) + , __type(type) +{ + +} + +_UiListViewItemEventArg::~_UiListViewItemEventArg(void) +{ + +} + +int +_UiListViewItemEventArg::GetArg1(void) const +{ + return __arg1; +} + +int +_UiListViewItemEventArg::GetArg2(void) const +{ + return __arg2; +} + +int +_UiListViewItemEventArg::GetArg3(void) const +{ + return __arg3; +} + +ListViewItemEventNotifyType +_UiListViewItemEventArg::GetNotifyType(void) const +{ + return __type; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_UiScrollEvent.cpp b/src/ui/controls/FUiCtrl_UiScrollEvent.cpp new file mode 100644 index 0000000..bf532dd --- /dev/null +++ b/src/ui/controls/FUiCtrl_UiScrollEvent.cpp @@ -0,0 +1,102 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_UiScrollEvent.cpp +* @brief This is the implementation for the _UiScrollEvent class. +*/ + +#include +#include +#include "FUiCtrl_UiScrollEvent.h" +#include "FUiCtrl_UiScrollEventArg.h" +#include "FUiCtrl_IScrollEventListener.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +//////////////////////////////////////////////////////////////////////////////// +/// _UiScrollEvent class Lifecycle + +_UiScrollEvent::_UiScrollEvent(void) + : __pSource(null) +{ + // nothing +} + +_UiScrollEvent::~_UiScrollEvent(void) +{ + // nothing +} + +result +_UiScrollEvent::Construct(const Tizen::Ui::_Control& source) +{ + ClearLastResult(); + result r = _Event::Initialize(); + SysTryReturn(NID_UI, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + // set event source + __pSource = const_cast <_Control*>(&source); + + return r; +} + +//////////////////////////////////////////////////////////////////////////////// +/// __WindowEvent class Accessor + +Tizen::Ui::_Control* +_UiScrollEvent::GetSource(void) const +{ + ClearLastResult(); + return __pSource; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _UiScrollEvent class Operation + +void +_UiScrollEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + _IScrollEventListener* pScrollEventListener = dynamic_cast <_IScrollEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, (pScrollEventListener != null), E_INVALID_ARG, "The invalid listener was given."); + + // cast Argument + const _UiScrollEventArg* pArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, (pArg != null), E_INVALID_ARG, "The invalid Event Argument was given."); + + switch (pArg->GetEventType()) + { + case SCROLL_EVENT_ON_SCROLL_STOPPED: + pScrollEventListener->OnScrollStopped(*pArg->GetSource()); + break; + case SCROLL_EVENT_ON_SCROLL_POSITION_CHANGED: + pScrollEventListener->OnScrollPositionChanged(*pArg->GetSource(), pArg->GetScrollPosition()); + break; + case SCROLL_EVENT_ON_SCROLL_END_REACHED: + pScrollEventListener->OnScrollEndReached(*pArg->GetSource(), pArg->GetScrollType()); + break; + default: + SysTryReturnVoidResult(NID_UI_CTRL, false, E_INVALID_ARG, "The invalid Event Argument was given."); + break; + } +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_UiScrollEventArg.cpp b/src/ui/controls/FUiCtrl_UiScrollEventArg.cpp new file mode 100644 index 0000000..a52c7bc --- /dev/null +++ b/src/ui/controls/FUiCtrl_UiScrollEventArg.cpp @@ -0,0 +1,106 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_UiScrollEventArg.cpp +* @brief This is the implementation for the _UiScrollEventArg class. +*/ + +#include +#include "FUiCtrl_UiScrollEventArg.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +//////////////////////////////////////////////////////////////////////////////// +/// _UiScrollEventArg class Lifecycle + +_UiScrollEventArg::_UiScrollEventArg(_ScrollEventType eventType, const _Control& source, int scrollPosition, ScrollEndEvent scrollType) + : __eventType(eventType) + , __pSource(const_cast <_Control*>(&source)) + , __scrollPosition(scrollPosition) + , __scrollType(scrollType) +{ + // nothing +} + +_UiScrollEventArg::~_UiScrollEventArg(void) +{ + // nothing +} + +_UiScrollEventArg* +_UiScrollEventArg::GetScrollEventArgN(const _Control& source) +{ + _UiScrollEventArg* pEventArg = new (std::nothrow) _UiScrollEventArg(SCROLL_EVENT_ON_SCROLL_STOPPED, source); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + return pEventArg; +} + +_UiScrollEventArg* +_UiScrollEventArg::GetScrollEventArgN(const _Control& source, int scrollPosition) +{ + _UiScrollEventArg* pEventArg = new (std::nothrow) _UiScrollEventArg(SCROLL_EVENT_ON_SCROLL_POSITION_CHANGED, source, scrollPosition); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + return pEventArg; +} + +_UiScrollEventArg* +_UiScrollEventArg::GetScrollEventArgN(const _Control& source, ScrollEndEvent scrollType) +{ + _UiScrollEventArg* pEventArg = new (std::nothrow) _UiScrollEventArg(SCROLL_EVENT_ON_SCROLL_END_REACHED, source, -1, scrollType); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY)); + + return pEventArg; +} + +//////////////////////////////////////////////////////////////////////////////// +/// _UiScrollEventArg class Access +_ScrollEventType +_UiScrollEventArg::GetEventType(void) const +{ + ClearLastResult(); + return __eventType; +} + +_Control* +_UiScrollEventArg::GetSource(void) const +{ + ClearLastResult(); + return __pSource; +} + +ScrollEndEvent +_UiScrollEventArg::GetScrollType(void) const +{ + ClearLastResult(); + return __scrollType; +} + +int +_UiScrollEventArg::GetScrollPosition(void) const +{ + ClearLastResult(); + return __scrollPosition; +} + +}}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_UiTableViewItemEvent.cpp b/src/ui/controls/FUiCtrl_UiTableViewItemEvent.cpp new file mode 100644 index 0000000..b70c390 --- /dev/null +++ b/src/ui/controls/FUiCtrl_UiTableViewItemEvent.cpp @@ -0,0 +1,298 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include +#include +#include "FUiCtrl_ITableViewItemEventListener.h" +#include "FUiCtrl_UiTableViewItemEvent.h" +#include "FUiCtrl_TableViewItemEventArg.h" + + +// using namespace +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Ui { namespace Controls +{ + +_UiTableViewItemEvent::_UiTableViewItemEvent(void) + : __pSource(null) + , __invokeTableViewItemCallback(true) + , __style(TABLE_VIEW_STYLE_SIMPLE) +{ + // nothing +} + +_UiTableViewItemEvent::~_UiTableViewItemEvent(void) +{ + // nothing +} + +result +_UiTableViewItemEvent::Construct(Tizen::Ui::_Control* pSource, TableViewStyle style) +{ + result r = _Event::Initialize(); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "Could not construct TableViewItemEvent!"); + + // set event source + __pSource = pSource; + + __style = style; + + return r; +} + +Tizen::Ui::_Control* +_UiTableViewItemEvent::GetSource(void) const +{ + return __pSource; +} + +void +_UiTableViewItemEvent::FireImpl(IEventListener& listener, const IEventArg& arg) +{ + // cast to _ItemEventArg + _TableViewItemEventArg* pEventArg = dynamic_cast<_TableViewItemEventArg*>(const_cast(&arg)); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_INVALID_ARG, ("[E_INVALID_ARG] event argument is invalid type.")); + + int index1 = pEventArg->GetArg1(); + int index2 = pEventArg->GetArg2(); + int index3 = pEventArg->GetArg3(); + int index4 = pEventArg->GetArg4(); + bool activated = pEventArg->GetActivated(); + + bool tempInvokeTableViewItemCallback = __invokeTableViewItemCallback; + __invokeTableViewItemCallback = true; + + _ITableViewItemEventListener* pItemListener = dynamic_cast<_ITableViewItemEventListener*>(&listener); + SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG, ("[E_INVALID_ARG] invalid listener type.")); + + _TableView* pTableView = dynamic_cast<_TableView*>(GetSource()); + SysTryReturnVoidResult(NID_UI_CTRL, pTableView != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (index2 < 0) + { + index2 = -1; + } + + switch (pEventArg->GetNotifyType()) + { + case TABLEVIEW_NOTIFY_TYPE_SELECTED_ITEM: + if (tempInvokeTableViewItemCallback == true) + { + _TableViewItem* pItem =pEventArg->GetItem(); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + pItemListener->OnTableViewItemStateChanged(*pTableView, index2, pItem, TABLE_VIEW_ITEM_STATUS_SELECTED); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + if (index2 == -1) + { + pItemListener->OnGroupedTableViewGroupItemStateChanged(*pTableView, index1, pItem, TABLE_VIEW_ITEM_STATUS_SELECTED); + } + else + { + pItemListener->OnGroupedTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_SELECTED); + } + } + else + { + pItemListener->OnSectionTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_SELECTED); + } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_HIGHLIGHED_ITEM: + if (tempInvokeTableViewItemCallback == true) + { + _TableViewItem* pItem =pEventArg->GetItem(); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + pItemListener->OnTableViewItemStateChanged(*pTableView, index2, pItem, TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + if (index2 == -1) + { + pItemListener->OnGroupedTableViewGroupItemStateChanged(*pTableView, index1, pItem, TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED); + } + else + { + pItemListener->OnGroupedTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED); + } + } + else + { + pItemListener->OnSectionTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED); + } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_ANNEX_CHECK: + if (tempInvokeTableViewItemCallback == true) + { + _TableViewItem* pItem =pEventArg->GetItem(); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + pItemListener->OnTableViewItemStateChanged(*pTableView, index2, pItem, TABLE_VIEW_ITEM_STATUS_CHECKED); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + if (index2 == -1) + { + pItemListener->OnGroupedTableViewGroupItemStateChanged(*pTableView, index1, pItem, TABLE_VIEW_ITEM_STATUS_CHECKED); + } + else + { + pItemListener->OnGroupedTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_CHECKED); + } + } + else + { + pItemListener->OnSectionTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_CHECKED); + } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_ANNEX_UNCHECK: + if (tempInvokeTableViewItemCallback == true) + { + _TableViewItem* pItem =pEventArg->GetItem(); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + pItemListener->OnTableViewItemStateChanged(*pTableView, index2, pItem, TABLE_VIEW_ITEM_STATUS_UNCHECKED); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + if (index2 == -1) + { + pItemListener->OnGroupedTableViewGroupItemStateChanged(*pTableView, index1, pItem, TABLE_VIEW_ITEM_STATUS_UNCHECKED); + } + else + { + pItemListener->OnGroupedTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_UNCHECKED); + } + } + else + { + pItemListener->OnSectionTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_UNCHECKED); + } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_ANNEX_MORE: + if (tempInvokeTableViewItemCallback == true) + { + _TableViewItem* pItem =pEventArg->GetItem(); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + pItemListener->OnTableViewItemStateChanged(*pTableView, index2, pItem, TABLE_VIEW_ITEM_STATUS_MORE); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + if (index2 == -1) + { + pItemListener->OnGroupedTableViewGroupItemStateChanged(*pTableView, index1, pItem, TABLE_VIEW_ITEM_STATUS_MORE); + } + else + { + pItemListener->OnGroupedTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_MORE); + } + } + else + { + pItemListener->OnSectionTableViewItemStateChanged(*pTableView, index1, index2, pItem, TABLE_VIEW_ITEM_STATUS_MORE); + } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_ITEM_SWEPT: + if (tempInvokeTableViewItemCallback == true) + { + if (index3 == TABLE_VIEW_SWEEP_DIRECTION_LEFT) + { + pItemListener->OnTableViewItemSwept(*pTableView, index1, index2, TABLE_VIEW_SWEEP_DIRECTION_LEFT); + } + else + { + pItemListener->OnTableViewItemSwept(*pTableView, index1, index2, TABLE_VIEW_SWEEP_DIRECTION_RIGHT); + } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_TOUCH_LONG_PRESSED: +// pItemListener->OnTableViewItemLongPressed(*pTableView, itemTag, __invokeTableViewItemCallback); + break; + + case TABLEVIEW_NOTIFY_TYPE_REORDERED_ITEM: + if (tempInvokeTableViewItemCallback == true) + { + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + pItemListener->OnTableViewItemReordered(*pTableView, index1, index2); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + pItemListener->OnGroupedTableViewItemReordered(*pTableView, index1, index2, index3, index4); + } + } + break; + + case TABLEVIEW_NOTIFY_TYPE_CONTEXT_ITEM_ACTIVATION: + if (tempInvokeTableViewItemCallback == true) + { + _TableViewItem* pItem =pEventArg->GetItem(); + SysTryReturnVoidResult(NID_UI_CTRL, pItem != null, E_INVALID_STATE, ("[E_INVALID_STATE] This instance isn't constructed.")); + + if (__style == TABLE_VIEW_STYLE_SIMPLE) + { + pItemListener->OnTableViewContextItemActivationStateChanged(*pTableView, index2, pItem, activated); + } + else if (__style == TABLE_VIEW_STYLE_GROUPED) + { + pItemListener->OnGroupedTableViewContextItemActivationStateChanged(*pTableView, index1, index2, pItem, activated); + } + else + { + pItemListener->OnSectionTableViewContextItemActivationStateChanged(*pTableView, index1, index2, pItem, activated); + } + } + break; + + default: + return; + } + + return; +} + +}}} // Tizen::Ui::Controls + diff --git a/src/ui/effects/FUiEffectsEffect.cpp b/src/ui/effects/FUiEffectsEffect.cpp new file mode 100644 index 0000000..d577c53 --- /dev/null +++ b/src/ui/effects/FUiEffectsEffect.cpp @@ -0,0 +1,316 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffectsEffect.cpp + * @brief This file contains implementation of Effect class. + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "FUiEffects_EffectManagerImpl.h" +#include +#include "FUiEffects_EffectErrorMessages.h" +#include +#include +#include + +using namespace Tizen::Ui::Controls; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; +using namespace Tizen::Base::Collection; + +using namespace Tizen::Ui::Effects::_Runtime; +using namespace Tizen::Ui::Effects::_Renderer; +using namespace Tizen::Ui::Effects::_Parser; +using namespace Tizen::Ui::Effects; +using namespace Tizen::Ui::Effects::_Utils; +using namespace std; + +using namespace Tizen::Graphics; +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Effects +{ + +result +Effect::Start(void) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + + ArrayList emptyList; + result r = emptyList.Construct(); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pEffectImpl->Start(emptyList); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +Effect::Start(const Tizen::Base::Collection::IList& effectStartInfo) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + result r = __pEffectImpl->Start(effectStartInfo); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +Effect::Stop(void) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + result r = __pEffectImpl->Stop(); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +Effect::SetRenderTarget(Tizen::Ui::Control* pControl) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + result r = __pEffectImpl->SetRenderTarget(pControl); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +Effect::FeedTouchPressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Point& offset) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + result r = __pEffectImpl->FeedTouchPressEvent(touchEventInfo, offset); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +Effect::FeedTouchPressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + result r = __pEffectImpl->FeedTouchPressEvent(touchEventInfo, Point(0, 0)); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +Effect::FeedTouchMoveEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Point& offset) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + result r = __pEffectImpl->FeedTouchMoveEvent(touchEventInfo, offset); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +Effect::FeedTouchMoveEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + result r = __pEffectImpl->FeedTouchMoveEvent(touchEventInfo, Point(0, 0)); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +Effect::FeedTouchReleaseEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Point& offset) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + result r = __pEffectImpl->FeedTouchReleaseEvent(touchEventInfo, offset); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +Effect::FeedTouchReleaseEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + result r = __pEffectImpl->FeedTouchReleaseEvent(touchEventInfo, Point(0, 0)); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +Effect::FeedTouchDoublePressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Point& offset) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + result r = __pEffectImpl->FeedTouchDoublePressEvent(touchEventInfo, offset); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +Effect::FeedTouchDoublePressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + result r = __pEffectImpl->FeedTouchDoublePressEvent(touchEventInfo, Point(0, 0)); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +Effect::SetBitmap(long bitmapId, const Tizen::Graphics::Bitmap& bitmap) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + result r = __pEffectImpl->SetBitmap(bitmapId, bitmap); + SysTryReturn(NID_UI_EFFECT, !(r == E_OUT_OF_MEMORY), E_OPERATION_FAILED, E_OPERATION_FAILED, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +bool +Effect::IsRunning(void) const +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + bool isRunning = __pEffectImpl->IsRunning(); + result r = GetLastResult(); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, isRunning, r, "[%s] Propagating.", GetErrorMessage(r)); + return isRunning; +} + +EffectType +Effect::GetType(void) const +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + EffectType effectType = __pEffectImpl->GetType(); + result r = GetLastResult(); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, effectType, r, "[%s] Propagating.", GetErrorMessage(r)); + return effectType; +} + +String +Effect::GetName(void) const +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + String effectName = __pEffectImpl->GetName(); + result r = GetLastResult(); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, effectName, r, "[%s] Propagating.", GetErrorMessage(r)); + return effectName; +} + +void +Effect::SetEffectEventListener(IEffectEventListener* pListener) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + __pEffectImpl->SetEffectEventListener(pListener); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +IEffectEventListener* +Effect::GetEffectEventListener(void) const +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + IEffectEventListener* listener = null; + listener = __pEffectImpl->GetEffectEventListener(); + result r = GetLastResult(); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, listener, r, "[%s] Propagating.", GetErrorMessage(r)); + return listener; +} + +void +Effect::SetResourceProvider(IEffectResourceProvider* pProvider) +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + __pEffectImpl->SetResourceProvider(pProvider); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +IEffectResourceProvider* +Effect::GetResourceProvider(void) const +{ + SysAssertf(__pEffectImpl != null, _UiEffectError::INTERNAL_ERROR); + + SetLastResult(E_SUCCESS); + IEffectResourceProvider* provider = null; + provider = __pEffectImpl->GetResourceProvider(); + result r = GetLastResult(); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, provider, r, "[%s] Propagating.", GetErrorMessage(r)); + return provider; +} + +Effect::Effect(void) + : __pEffectImpl(null) +{ + __pEffectImpl = new (std::nothrow) _EffectImpl(*this); + SysTryReturnVoidResult(NID_UI_EFFECT, __pEffectImpl != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __pEffectImpl->InitializeEffect(); +} + + +Effect::~Effect(void) +{ + if (__pEffectImpl != null) + { + delete __pEffectImpl; + __pEffectImpl = null; + } +} + +}}} // Tizen::Ui::Effects diff --git a/src/ui/effects/FUiEffectsEffectManager.cpp b/src/ui/effects/FUiEffectsEffectManager.cpp new file mode 100644 index 0000000..8a5d75f --- /dev/null +++ b/src/ui/effects/FUiEffectsEffectManager.cpp @@ -0,0 +1,90 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffectsEffectManager.cpp + * @brief This is the source file for the EffectManager class + */ + +#include + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects +{ + +EffectManager* +EffectManager::GetInstance(void) +{ + return _EffectManagerImpl::GetInstance().first; +} + +void +EffectManager::DestroyInstance(void) +{ + _EffectManagerImpl::DestroyInstance(); + return; +} + +Effect* +EffectManager::CreateEffect(const Tizen::Base::String& filePath) +{ + //Get and store current locale: + char* pCurrentLocale = setlocale(LC_ALL, null); + char* pCurrentLocaleDuplicated = null; + if (pCurrentLocale != null) + { + pCurrentLocaleDuplicated = strdup(pCurrentLocale); + //Set minimal "C" locale: + setlocale(LC_ALL,"C"); + } + + Effect* pEffect = _EffectManagerImpl::GetInstance().second->CreateEffect(filePath); + + if (pCurrentLocaleDuplicated != null) + { + //Restore previously saved locale: + setlocale(LC_ALL, pCurrentLocaleDuplicated); + free(pCurrentLocaleDuplicated); + } + + return pEffect; +} + +void +EffectManager::DestroyEffect(Effect& effect) +{ + _EffectManagerImpl::GetInstance().second->DestroyEffect(effect); +} + +// This default constructor is intentionally declared as private to implement the Singleton semantic. +EffectManager::EffectManager(void) + : __pEffectManagerImpl(null) +{ + +} + +// This destructor is intentionally declared as private to implement the Singleton semantic. +EffectManager::~EffectManager(void) +{ + +} + +}}} // Tizen::Ui::Effects diff --git a/src/ui/effects/FUiEffectsEffectTouchInfo.cpp b/src/ui/effects/FUiEffectsEffectTouchInfo.cpp new file mode 100644 index 0000000..f875625 --- /dev/null +++ b/src/ui/effects/FUiEffectsEffectTouchInfo.cpp @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffectsEffectTouchInfo.cpp + * @brief This file contains implementation of EffectTouchInfo class + */ + +#include +#include +#include + +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Effects +{ + +EffectTouchInfo::EffectTouchInfo(Point currentPosition, + Point startPosition, + unsigned long touchId) + : __currentPosition(currentPosition) + , __startPosition(startPosition) + , __touchId(touchId) +{ + return; +} + +EffectTouchInfo::EffectTouchInfo(void) + : __currentPosition() + , __startPosition() + , __touchId(std::numeric_limits::max()) +{ + return; +} + +EffectTouchInfo::~EffectTouchInfo(void) +{ + return; +} + +void +EffectTouchInfo::SetCurrentPosition(const Point& curPos) +{ + __currentPosition = curPos; + return; +} + +void +EffectTouchInfo::SetStartPosition(const Point& startPos) +{ + __startPosition = startPos; + return; +} + +Point +EffectTouchInfo::GetCurrentPosition(void) const +{ + return __currentPosition; +} + +Point +EffectTouchInfo::GetStartPosition(void) const +{ + return __startPosition; +} + +void +EffectTouchInfo::SetTouchId(unsigned long touchId) +{ + __touchId = touchId; + return; +} + +unsigned long +EffectTouchInfo::GetTouchId(void) const +{ + return __touchId; +} + +}}} // Tizen::Ui::Effects diff --git a/src/ui/effects/FUiEffectsEffectTouchInfo.h b/src/ui/effects/FUiEffectsEffectTouchInfo.h new file mode 100644 index 0000000..511c170 --- /dev/null +++ b/src/ui/effects/FUiEffectsEffectTouchInfo.h @@ -0,0 +1,150 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffectsEffectTouchInfo.h + * @brief This is the header file for the EffectTouchInfo class + */ +#ifndef _FUI_EFFECTS_EFFECTTOUCHINFO_H_ +#define _FUI_EFFECTS_EFFECTTOUCHINFO_H_ + +#include + +namespace Tizen { namespace Graphics { + class Point; +} } // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Effects +{ + +/** +* @class EffectTouchInfo +* @brief This class is used for construction touch event extended info +* +* @since 2.0 +* +*/ +class EffectTouchInfo +{ +public: + /** + * Constructor + * + * @since 2.0 + * + */ + EffectTouchInfo(void); + + /** + * Constructor + * + * @since 2.0 + * + */ + EffectTouchInfo(Tizen::Graphics::Point currentPosition, + Tizen::Graphics::Point startPosition, + unsigned long touchId); + + /** + * Destructor + * + * @since 2.0 + * + */ + virtual ~EffectTouchInfo(void); + + /** + * Sets current position of touch + * + * @since 2.0 + * + */ + void SetCurrentPosition(const Tizen::Graphics::Point& currentPosition); + + /** + * Sets start position of touch + * + * @since 2.0 + * + */ + void SetStartPosition(const Tizen::Graphics::Point& startPosition); + + /** + * Gets current position of touch + * + * @since 2.0 + * + */ + Tizen::Graphics::Point GetCurrentPosition(void) const; + + /** + * Returns start position of touch + * + * @since 2.0 + * + */ + Tizen::Graphics::Point GetStartPosition(void) const; + + /** + * Sets touch id + * + * @since 2.0 + * + */ + void SetTouchId(unsigned long touchId); + + /** + * Gets touch id + * + * @since 2.0 + * + */ + unsigned long GetTouchId(void) const; + +protected: + +private: + + /** + * Hidden copy constructor + * + * @since 2.0 + * + */ + EffectTouchInfo(const EffectTouchInfo &rhs); + + /** + * Hidden assignment operator + * + * @since 2.0 + * + */ + EffectTouchInfo &operator=(const EffectTouchInfo &rhs); + + +public: + +protected: + +private: + Tizen::Graphics::Point __currentPosition; /**< means the current point of some touch event */ + Tizen::Graphics::Point __startPosition; /**< means the start (first) point of some touch event */ + unsigned long __touchId; +}; + +} } } // Tizen::Ui::Effects + +#endif //_FUI_EFFECTS_EFFECTTOUCHINFO_H_ diff --git a/src/ui/effects/FUiEffects_EffectErrorMessages.cpp b/src/ui/effects/FUiEffects_EffectErrorMessages.cpp new file mode 100644 index 0000000..213c016 --- /dev/null +++ b/src/ui/effects/FUiEffects_EffectErrorMessages.cpp @@ -0,0 +1,46 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_EffectErrorMessages.cpp + * @brief This is the source file for the _UiEffectError class + */ +#include "FUiEffects_EffectErrorMessages.h" + +namespace Tizen { namespace Ui { namespace Effects +{ +const char* _UiEffectError::NOT_CONSTRUCTED_MANAGER = "Effect Manager is not fully constructed"; +const char* _UiEffectError::NO_EFFECT_FILE = "Specified Effect file doesn't exist: %s"; +const char* _UiEffectError::EFFECT_FILE_ERROR = "Error in Effect File \"%s\" in Line %i: %s"; +const char* _UiEffectError::FEED_TOUCH_IS_BLOCKED = "For effect [%i, %s] TOUCH_EVENTs are blocked"; +const char* _UiEffectError::OUT_OF_MEMORY = "Memory is insufficient"; +const char* _UiEffectError::NO_EFFECT = "Effect with specified name [%s] doesn't exist"; +const char* _UiEffectError::LISTENER_IS_NOT_ASSIGNED = "For Effect with name [%s] EventListener is not assigned"; +const char* _UiEffectError::PROVIDER_IS_NOT_ASSIGNED = "For Effect with name [%s] ResourceProvider is not assigned"; + +const char* _UiEffectError::INTERNAL_ERROR = "Effects_internal_error"; +const char* _UiEffectError::LUA_INTERNAL_ERROR = "Lua runtime internal error in effect [%i, %s]"; +const char* _UiEffectError::LUA_RUNTIME_ERROR = "There are some errors in lua script"; +const char* _UiEffectError::NURBSGS_INTERNAL_ERROR = "NURBS Graphical Surface runtime internal error"; + +const char* _UiEffectError::EP_XML_PARSING_FAILED = "Parsing of an xml file hasn't finished successfully"; +const char* _UiEffectError::EP_EXTRACTING_MODEL_FILES_FAILED = "Failed to unzip an effect file"; +const char* _UiEffectError::EP_ATTRIBUTE_NOT_FOUND = "Missing one of expected attributes in an xml model file"; +const char* _UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE = "Attribute value doesn't match the predefined range"; +const char* _UiEffectError::EP_MEMBER_NOT_INITIALIZED = "A member variable of effect parser is not initialized"; +const char* _UiEffectError::EP_ERROR_IN_LOGIC = "An error in the logic of effect parser occurred"; +} } } // Tizen::Ui::Effects diff --git a/src/ui/effects/FUiEffects_EffectErrorMessages.h b/src/ui/effects/FUiEffects_EffectErrorMessages.h new file mode 100644 index 0000000..10132c4 --- /dev/null +++ b/src/ui/effects/FUiEffects_EffectErrorMessages.h @@ -0,0 +1,64 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_EffectErrorMessages.h + * @brief This is the header file for the _UiEffectError + */ + +#ifndef _FUI_EFFECRTS_INTERNAL_EFFECT_ERROR_MESSAGES_H_ +#define _FUI_EFFECRTS_INTERNAL_EFFECT_ERROR_MESSAGES_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects +{ + +/** +* @class _UiEffectError +* @brief Class for message texts +* +* @since 2.0 +* +*/ +class _UiEffectError + : public Tizen::Ui::_UiError +{ +public: + static const char* NOT_CONSTRUCTED_MANAGER; + static const char* NO_EFFECT_FILE; + static const char* EFFECT_FILE_ERROR; + static const char* NO_EFFECT; + static const char* FEED_TOUCH_IS_BLOCKED; + static const char* OUT_OF_MEMORY; + static const char* INTERNAL_ERROR; + static const char* LUA_INTERNAL_ERROR; + static const char* LUA_RUNTIME_ERROR; + static const char* NURBSGS_INTERNAL_ERROR; + static const char* LISTENER_IS_NOT_ASSIGNED; + static const char* PROVIDER_IS_NOT_ASSIGNED; + + static const char* EP_XML_PARSING_FAILED; + static const char* EP_EXTRACTING_MODEL_FILES_FAILED; + static const char* EP_ATTRIBUTE_NOT_FOUND; + static const char* EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE; + static const char* EP_MEMBER_NOT_INITIALIZED; + static const char* EP_ERROR_IN_LOGIC; +}; + +} } } // Tizen::Ui::Effects + +#endif // _FUI_EFFECRTS_INTERNAL_EFFECT_ERROR_MESSAGES_H_ diff --git a/src/ui/effects/FUiEffects_EffectImpl.cpp b/src/ui/effects/FUiEffects_EffectImpl.cpp new file mode 100644 index 0000000..f365833 --- /dev/null +++ b/src/ui/effects/FUiEffects_EffectImpl.cpp @@ -0,0 +1,653 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_EffectImpl.cpp + * @brief This is the source file for the _EffectImpl class + */ + +#include "FUiEffects_EffectImpl.h" + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "FUiEffects_EffectManagerImpl.h" +#include +#include "FUiEffects_EffectErrorMessages.h" +#include +#include + +#include "FUiEffects_RuntimeRenderDataScene.h" + +using namespace Tizen::Ui::Controls; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Collection; + +using namespace Tizen::Ui::Effects::_Runtime; +using namespace Tizen::Ui::Effects::_Renderer; +using namespace Tizen::Ui::Effects::_Parser; +using namespace Tizen::Ui::Effects; +using namespace Tizen::Ui::Effects::_Utils; +using namespace std; + +namespace Tizen { namespace Ui { namespace Effects +{ + +EffectsSet _EffectImpl::__effects = EffectsSet(); +RenderControlsMap _EffectImpl::__renderControls = RenderControlsMap(); +EffectsControlsMap _EffectImpl::__effectsControlsMapRegistered = EffectsControlsMap(); +ControlsSet _EffectImpl::__controlsSetPerforming = ControlsSet(); +long _EffectImpl::__effectsCount = 0; + +_EffectImpl::_EffectImpl(Effect& effect) + : __pEffect(&effect) + , __pModel(null) + , __pRenderer(null) + , __pEventListener(null) + , __pResourceProvider(null) + , __modelTimer() + , __renderTargetSet(false) +{ + ++__effectsCount; + __pEffect->__pEffectImpl = this; +} + +_EffectImpl::~_EffectImpl(void) +{ + Stop(); // <-- checking for result is not necessary (Effect must be stopped before deleting) + + __effects.erase(__pEffect); + --__effectsCount; + + //surface deleting if it is not used in other effects + EffectsControlsMap::const_iterator itEffectControl; + itEffectControl = __effectsControlsMapRegistered.find(__pEffect); + + //if render target is set then release render target (delete GLSurface and pointers) + if (itEffectControl != __effectsControlsMapRegistered.end()) + { + ReleaseRenderTarget(*(itEffectControl->second)); + } +} + +void +_EffectImpl::ReleaseRenderTarget(const Control& control) +{ + RenderControlsMap::const_iterator itRenderControl = __renderControls.find(&control); + SysAssertf(itRenderControl != __renderControls.end(), _UiEffectError::INTERNAL_ERROR); + __effectsControlsMapRegistered.erase(__pEffect); + bool isDelete = true; + if (!__effectsControlsMapRegistered.empty()) + { + for (EffectsControlsMap::const_iterator itEffectControl = __effectsControlsMapRegistered.begin(); + itEffectControl != __effectsControlsMapRegistered.end(); + ++itEffectControl) + { + if (itEffectControl->second == itRenderControl->first) + { + isDelete = false; + break; + } + } + } + if (isDelete) + { + __pRenderer->ReleaseCache(); + __pRenderer->surface = EGL_NO_SURFACE; + EffectRenderer::DeleteSurface(itRenderControl->second); + __renderControls.erase(itRenderControl->first); + } +} + +result +_EffectImpl::SetRenderTarget(const Tizen::Ui::Control* pControl) +{ + SysTryLogReturn(NID_UI_EFFECT, __pRenderer != null, E_OPERATION_FAILED, "Rendering is unavailable for this effect"); + + //checking for effect running + SysTryReturn(NID_UI_EFFECT, !IsRunning(), E_IN_PROGRESS, E_IN_PROGRESS, + "Effects. [E_IN_PROGRESS] Effect is running now"); + + //if render target was set earlier + EffectsControlsMap::const_iterator itEffectsControlsMap = __effectsControlsMapRegistered.find(__pEffect); + if (itEffectsControlsMap != __effectsControlsMapRegistered.end()) + { + const Control* pControlOld = itEffectsControlsMap->second; + if (pControl == null) + { + ReleaseRenderTarget(*pControlOld); + return E_SUCCESS; + } + //if new and old controls are the same + if (pControlOld == pControl) + { + return E_SUCCESS; + } + return SetRenderTargetInternal(*pControl, *pControlOld); + } + else//if render target wasn't set earlier + { + if (pControl == null) + { + return E_SUCCESS; + } + else + { + return SetRenderTargetInternal(*pControl, *pControl); + } + } +} + +result +_EffectImpl::SetRenderTargetInternal(const Control& control, const Control& controlOld) +{ + __pRenderer->surface = FindGlesSurface(&control); + + if (__pRenderer->surface == EGL_NO_SURFACE) + { + __pRenderer->surface = EffectRenderer::CreateSurface((EGLNativeWindowType)&control); + SysTryReturn(NID_UI_EFFECT, __pRenderer->surface != EGL_NO_SURFACE, E_OPERATION_FAILED, E_OPERATION_FAILED, "Creation of OpenGL surface for effect \"%s\" failed", __pModel->GetName().c_str()); + SysLog(NID_UI_EFFECT, "Effects. EGL surface is created successfully"); + if (&controlOld != &control) + { + ReleaseRenderTarget(controlOld); + } + __renderControls.insert(RenderControlsMapPair(&control, __pRenderer->surface)); + } + + __pRenderer->SetScreen(control); + + //Reserve memory for texture for less latency on bitmap upload + Dimension realControlSize = _CoordinateSystemUtils::Transform(control.GetSize()); + const RenderDataSurfaceCollection& renderData = __pModel->GetRenderingData()->GetRenderDataSurfaceCollection(); + RenderDataSurfaceCollection::const_iterator it = renderData.begin(); + RenderDataSurfaceCollection::const_iterator itend = renderData.end(); + for (; it != itend; ++it) + { + __pRenderer->SetBitmap((*it)->bitmapId, null, realControlSize.width, realControlSize.height); + } + + __pRenderer->BuildCache(); + + __effectsControlsMapRegistered.insert(std::make_pair(__pEffect, &control)); + + return E_SUCCESS; +} + +result +_EffectImpl::Start(const Tizen::Base::Collection::IList& effectStartInfo) +{ + START_PROFILER(PROFLOG_StartEffect) + + int countCollection = effectStartInfo.GetCount(); + EffectsVector effectStartInfoVector(countCollection); + for (int i = 0; i < countCollection; ++i) + { + effectStartInfoVector[i] = static_cast(effectStartInfo.GetAt(i))->ToFloat(); + } + + SysAssertf(__pModel != null, _UiEffectError::INTERNAL_ERROR); + + if (__pEventListener == null) + { + SysLog(NID_UI_EFFECT, _UiEffectError::LISTENER_IS_NOT_ASSIGNED, __pModel->GetName().c_str()); + } + if (__pResourceProvider == null) + { + SysLog(NID_UI_EFFECT, _UiEffectError::PROVIDER_IS_NOT_ASSIGNED, __pModel->GetName().c_str()); + } + + _EffectState effState = __pModel->GetState(); + SysTryReturn(NID_UI_EFFECT, effState != _EFFECT_STATE_RUNTIME_ERROR, E_OPERATION_FAILED, E_OPERATION_FAILED, "Attempt to Start an Effect with RUNTIME_ERROR state, effect \"%s\"", __pModel->GetName().c_str()); + SysTryReturn(NID_UI_EFFECT, effState != _EFFECT_STATE_RUNNING, E_INVALID_STATE, E_INVALID_STATE, "Attempt to Start an Effect that is currently running, effect \"%s\"", __pModel->GetName().c_str()); + SysTryReturn(NID_UI_EFFECT, effState == _EFFECT_STATE_RUNNABLE, E_OPERATION_FAILED, E_OPERATION_FAILED, "Attempt to Start an Effect that is not runnable, effect \"%s\"", __pModel->GetName().c_str()); + + EffectsControlsMap::iterator iterRegistered = __effectsControlsMapRegistered.find(__pEffect); + + __renderTargetSet = __pRenderer != null && iterRegistered != __effectsControlsMapRegistered.end(); + if (!__renderTargetSet) + { + SysLog(NID_UI_EFFECT, "Effect has no attached surface for rendering, effect \"%s\" ", __pModel->GetName().c_str()); + } + else + { + for (ControlsSet::iterator iterPerforming = __controlsSetPerforming.begin(); iterPerforming != __controlsSetPerforming.end(); ++iterPerforming) + { + SysTryReturn(NID_UI_EFFECT, iterRegistered->second != *iterPerforming, E_ALREADY_SET, E_ALREADY_SET, "Attempt to Start more than one Effect on the same Control, effect \"%s\" ", __pModel->GetName().c_str()); + } + __controlsSetPerforming.insert(iterRegistered->second); + } + + int startResult = 0; + SysTryCatch(NID_UI_EFFECT, SETJMP == 0, , GetLastResult(), "[%s] Propagating", GetErrorMessage(GetLastResult())); + + startResult = __pModel->Start(effectStartInfoVector); + switch (startResult) + { + case 0: + SysLog(NID_UI_EFFECT, "Effect [%i, %s] was started successfully", __pModel->GetId(), __pModel->GetName().c_str()); + break; + case 1: + SysLogException(NID_UI_EFFECT, E_OPERATION_FAILED, "The effect [%i, %s] is not runnable", __pModel->GetId(), __pModel->GetName().c_str()); + return E_OPERATION_FAILED; + case 2: + SysLogException(NID_UI_EFFECT, E_OPERATION_FAILED, _UiEffectError::LUA_INTERNAL_ERROR, __pModel->GetId(), __pModel->GetName().c_str()); + return E_OPERATION_FAILED; + case 3: + SysLogException(NID_UI_EFFECT, E_OPERATION_FAILED, "Some error was appeared in function SetBitmap of resources provider for effect [%i, %s]", __pModel->GetId(), __pModel->GetName().c_str()); + return E_OPERATION_FAILED; + default: + SysLogException(NID_UI_EFFECT, E_OPERATION_FAILED, "Unknown error in effect [%i, %s]", __pModel->GetId(), __pModel->GetName().c_str()); + return E_OPERATION_FAILED; + } + + __modelTimer.Reset(); + __modelTimer.Start(1); + + END_PROFILER(PROFLOG_StartEffect) + + return E_SUCCESS; + + CATCH: + { + __pModel->Stop(true, false); + return E_OPERATION_FAILED; + } +} + +result +_EffectImpl::Stop(void) +{ + if (__pModel == null) + { + return E_SUCCESS; + } + + if (__pModel->GetState() == _EFFECT_STATE_RUNNING) + { + __pModel->Stop(false, true); + EffectModelTimerStop(); + + return E_SUCCESS; + } + else + { + return E_INVALID_STATE; + } +} + +result +_EffectImpl::FeedTouchPressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Tizen::Graphics::Point& offset) +{ + SysAssertf(__pModel != null, _UiEffectError::INTERNAL_ERROR); + + SysTryLogReturn(NID_UI_EFFECT, __pRenderer != null, E_OPERATION_FAILED, "Rendering is unavailable for this effect"); + + TouchEventScript touchEventScript = {__pRenderer->TransformScreenToWorld(Vec2f(touchEventInfo.GetCurrentPosition().x, touchEventInfo.GetCurrentPosition().y)), + __pRenderer->TransformScreenToWorld(Vec2f(touchEventInfo.GetStartPosition().x, touchEventInfo.GetStartPosition().y)), + touchEventInfo.GetPointId()}; + + __pModel->FeedTouchPressEvent(touchEventScript); + return GetLastResult(); +} + +result +_EffectImpl::FeedTouchMoveEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Tizen::Graphics::Point& offset) +{ + SysAssertf(__pModel != null, _UiEffectError::INTERNAL_ERROR); + + SysTryLogReturn(NID_UI_EFFECT, __pRenderer != null, E_OPERATION_FAILED, "Rendering is unavailable for this effect"); + + TouchEventScript touchEventScript = {__pRenderer->TransformScreenToWorld(Vec2f(touchEventInfo.GetCurrentPosition().x, touchEventInfo.GetCurrentPosition().y)), + __pRenderer->TransformScreenToWorld(Vec2f(touchEventInfo.GetStartPosition().x, touchEventInfo.GetStartPosition().y)), + touchEventInfo.GetPointId()}; + + __pModel->FeedTouchMoveEvent(touchEventScript); + return GetLastResult(); +} + +result +_EffectImpl::FeedTouchReleaseEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Tizen::Graphics::Point& offset) +{ + SysAssertf(__pModel != null, _UiEffectError::INTERNAL_ERROR); + + SysTryLogReturn(NID_UI_EFFECT, __pRenderer != null, E_OPERATION_FAILED, "Rendering is unavailable for this effect"); + + TouchEventScript touchEventScript = {__pRenderer->TransformScreenToWorld(Vec2f(touchEventInfo.GetCurrentPosition().x, touchEventInfo.GetCurrentPosition().y)), + __pRenderer->TransformScreenToWorld(Vec2f(touchEventInfo.GetStartPosition().x, touchEventInfo.GetStartPosition().y)), + touchEventInfo.GetPointId()}; + + __pModel->FeedTouchReleaseEvent(touchEventScript); + return GetLastResult(); +} + +result +_EffectImpl::FeedTouchDoublePressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Tizen::Graphics::Point& offset) +{ + SysAssertf(__pModel != null, _UiEffectError::INTERNAL_ERROR); + + SysTryLogReturn(NID_UI_EFFECT, __pRenderer != null, E_OPERATION_FAILED, "Rendering is unavailable for this effect"); + + TouchEventScript touchEventScript = {__pRenderer->TransformScreenToWorld(Vec2f(touchEventInfo.GetCurrentPosition().x, touchEventInfo.GetCurrentPosition().y)), + __pRenderer->TransformScreenToWorld(Vec2f(touchEventInfo.GetStartPosition().x, touchEventInfo.GetStartPosition().y)), + touchEventInfo.GetPointId()}; + + __pModel->FeedTouchDoublePressEvent(touchEventScript); + return GetLastResult(); +} + +result +_EffectImpl::SetBitmap(long bitmapId, const Bitmap& bitmap) +{ + SysTryLogReturn(NID_UI_EFFECT, __pRenderer != null, E_OPERATION_FAILED, "Rendering is unavailable for this effect"); + + bool resOk = false; + + // Analysing non existing bitmap ID in Effect Project [with E_OBJ_NOT_FOUND] + const RenderDataSurfaceCollection& renderData = __pModel->GetRenderingData()->GetRenderDataSurfaceCollection(); + RenderDataSurfaceCollection::const_iterator it = renderData.begin(); + RenderDataSurfaceCollection::const_iterator itend = renderData.end(); + for (; it != itend; ++it) + { + if ((*it)->bitmapId == bitmapId) + { + resOk = true; + break; + } + } + SysTryReturn(NID_UI_EFFECT, resOk, E_OPERATION_FAILED, E_OPERATION_FAILED, "Bitmap with specified id does not exist"); + + resOk = __pRenderer->SetBitmap(bitmapId, const_cast(bitmap)); + return (resOk ? E_SUCCESS : E_OPERATION_FAILED); +} + +bool +_EffectImpl::IsRunning(void) const +{ + SysAssertf(__pModel != null, _UiEffectError::INTERNAL_ERROR); + + _EffectState effectState = __pModel->GetState(); + return (effectState == _EFFECT_STATE_RUNNING); +} + +EffectType +_EffectImpl::GetType(void) const +{ + SysAssertf(__pModel != null, _UiEffectError::INTERNAL_ERROR); + return __pModel->GetType(); +} + +String +_EffectImpl::GetName(void) const +{ + return String(__pModel->GetName().c_str()); +} + +void +_EffectImpl::SetEffectEventListener(IEffectEventListener* pListener) +{ + __pEventListener = pListener; + return; +} + +IEffectEventListener* +_EffectImpl::GetEffectEventListener(void) const +{ + return __pEventListener; +} + +void +_EffectImpl::SetResourceProvider(IEffectResourceProvider* pProvider) +{ + __pResourceProvider = pProvider; + return; +} + +IEffectResourceProvider* +_EffectImpl::GetResourceProvider(void) const +{ + return __pResourceProvider; +} + +EGLSurface +_EffectImpl::FindGlesSurface(const Control* pControl) const +{ + RenderControlsMap::const_iterator it = __renderControls.find(pControl); + + if (it != __renderControls.end()) + { + return it->second; + } + + return EGL_NO_SURFACE; +} + +void +_EffectImpl::EffectModelTimerStop(void) +{ + __modelTimer.Stop(); + + return; +} + +void +_EffectImpl::OnTimerExpired(Timer& timer) +{ + _EffectTimer* pEffectTimer = dynamic_cast<_EffectTimer*>(&timer); + SysAssertf(pEffectTimer != null, _UiEffectError::INTERNAL_ERROR); + SysAssertf(__pModel != null, _UiEffectError::INTERNAL_ERROR); + + if (__pModel->GetState() == _EFFECT_STATE_RUNNING) + { + __modelTimer.Start(); + __pModel->Calculate(pEffectTimer->CalculationTimeStep()); // actual time period between calls OnTimerExpied function + + if (__pModel->GetState() != _EFFECT_STATE_RUNNING) + { + __modelTimer.Stop(); + } + + if ((__renderTargetSet) && (__pModel->GetState() == _EFFECT_STATE_RUNNING)) + { + __pModel->UpdateGraphicalSurfaces(); + if (SETJMP == 0) + { + __pRenderer->Update(); + + UpdateScreen(); + __pRenderer->Draw(); + } + else + { + __pModel->Stop(true, false); + __modelTimer.Stop(); + SysLogException(NID_UI_EFFECT, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + } + } + } + else + { + __modelTimer.Stop(); + } + + return; +} + +void +_EffectImpl::UpdateScreen(void) +{ + EffectsControlsMap::const_iterator itEffCtrl = __effectsControlsMapRegistered.find(__pEffect); + SysAssertf(itEffCtrl != __effectsControlsMapRegistered.end(), _UiEffectError::INTERNAL_ERROR); + + __pRenderer->TrackScreenSizeChanges(*itEffCtrl->second); + + return; +} + +void +_EffectImpl::OnEffectStarted(void) +{ + if (__renderTargetSet) + { + __pModel->UpdateGraphicalSurfaces(); + __pRenderer->Update(); + + UpdateScreen(); + __pRenderer->Draw(); + } + + if (__pEventListener != null) + { + __pEventListener->OnEffectStarted(*__pEffect); + } + else + { + ; + } + + return; +} + +void +_EffectImpl::OnEffectFinished(EffectResult effectResult, const LastShownBitmapIdCollection& bitmapsTargetId) +{ + SysAssertf(__pModel != null, _UiEffectError::INTERNAL_ERROR); + + if (__renderTargetSet && __pModel->GetState() != _EFFECT_STATE_RUNTIME_ERROR) + { + __pModel->UpdateGraphicalSurfaces(); + __pRenderer->Update(); + + UpdateScreen(); + __pRenderer->Draw(); + } + + EffectsControlsMap::iterator it = __effectsControlsMapRegistered.find(__pEffect); + if (it != __effectsControlsMapRegistered.end()) + { + __controlsSetPerforming.erase(it->second); + } + + if (__pEventListener != null) + { + ArrayList lastShownBitmapId; + result res = lastShownBitmapId.Construct(); + SysAssertf(res != E_INVALID_ARG, _UiEffectError::INTERNAL_ERROR); + + if (res == E_SUCCESS) + { + for (LastShownBitmapIdCollection::const_iterator it = bitmapsTargetId.begin(); it != bitmapsTargetId.end(); ++it) + { + Long* pLong = new (std::nothrow) Long(*it); + if (pLong != null) + { + lastShownBitmapId.Add(*pLong); + } + else + { + SetLastResult(E_OUT_OF_MEMORY); + break; + } + } + } + + __pEventListener->OnEffectFinished(*__pEffect, effectResult, lastShownBitmapId); + + lastShownBitmapId.RemoveAll(true); + } + else + { + ; + } + + return; +} + +bool +_EffectImpl::OnBitmapRequested(long bitmapId) +{ + if (__pResourceProvider != null) + { + return __pResourceProvider->SetBitmap(*__pEffect, bitmapId) == E_SUCCESS; + } + else + { + return true; + } +} + +void +_EffectImpl::InitializeEffect(void) +{ + Tizen::App::App* pApp = Tizen::App::App::GetInstance(); + SysTryReturnVoidResult(NID_UI_EFFECT, pApp != null, E_FILE_NOT_FOUND, "Effects. The pointer to application instance equals null"); + std::wstring tempWStr = std::wstring((pApp->GetAppRootPath()).GetPointer()); + tempWStr += L"data/"; + std::string dataDirStr(tempWStr.begin(), tempWStr.end()); + + SysAssertf(_EffectManagerImpl::__pPathToEffectFile != null, _UiEffectError::INTERNAL_ERROR); + + int modelTimerTimeout; + IEffectModelManager* pModelTemp; + EffectRenderer* pRendererTemp; + result res = EffectParser::ParseEffectFileLoadModel(_EffectManagerImpl::__pPathToEffectFile, dataDirStr.c_str(), this, __effectsCount, pModelTemp, pRendererTemp, modelTimerTimeout); + _EffectManagerImpl::__pPathToEffectFile = null; + + //E_OUT_OF_MEMORY or E_PARSING_FAILED: + if ((res != E_SUCCESS) && (res != E_OUT_OF_MEMORY)) + { + res = E_PARSING_FAILED; + } + SysTryReturnVoidResult(NID_UI_EFFECT, res == E_SUCCESS, res, "[%s] Propagating", GetErrorMessage(res)); + + __pModel.reset(pModelTemp); + __pRenderer.reset(pRendererTemp); + + SysAssertf(__pModel != null, _UiEffectError::INTERNAL_ERROR); + SysAssertf(modelTimerTimeout > 0, _UiEffectError::INTERNAL_ERROR); + + res = __modelTimer.Construct(*this, __pModel->GetId(), modelTimerTimeout); + res = (res == E_SYSTEM ? E_PARSING_FAILED : res); + SysTryReturnVoidResult(NID_UI_EFFECT, res == E_SUCCESS, res, "[%s] Propagating", GetErrorMessage(res)); + + std::pair resultInsert = __effects.insert(__pEffect); + SysAssertf(resultInsert.second == true, _UiEffectError::INTERNAL_ERROR); + + bool isLuaError = (__pModel->GetState() != _EFFECT_STATE_RUNNABLE); + SysTryReturnVoidResult(NID_UI_EFFECT, !isLuaError, E_PARSING_FAILED, _UiEffectError::LUA_RUNTIME_ERROR); +} + +}}} // Tizen::Ui::Effects diff --git a/src/ui/effects/FUiEffects_EffectImpl.h b/src/ui/effects/FUiEffects_EffectImpl.h new file mode 100644 index 0000000..0557113 --- /dev/null +++ b/src/ui/effects/FUiEffects_EffectImpl.h @@ -0,0 +1,454 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_EffectImpl.h + * @brief This is the header file for the _EffectImpl class. + */ + +#ifndef _FUI_EFFECTS_INTERNAL_EFFECT_IMPL_H_ +#define _FUI_EFFECTS_INTERNAL_EFFECT_IMPL_H_ + +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { +class Control; +class TouchEventInfo; +}} // Tizen::Ui + +namespace Tizen { namespace Base { namespace Collection { +class IList; +}}} // Tizen::Base::Collection + +namespace Tizen { namespace Graphics { +class Point; +class Bitmap; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Effects +{ + +class Effect; +class IEffectEventListener; +class IEffectResourceProvider; +class _EffectInstance; +class _EffectImpl; + +typedef std::set EffectsSet; + +typedef void* EGLSurface; +typedef std::map RenderControlsMap; +typedef std::pair RenderControlsMapPair; + +typedef std::map EffectsControlsMap; +typedef std::set ControlsSet; + +class _EffectImpl + : public Tizen::Base::Runtime::ITimerEventListener + , public Tizen::Ui::Effects::_Runtime::IEffectModelListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + + /** + * Binds the effect to Tizen::UI::Control for rendering effect. + * + * @since 2.0 + * + * @return An error code + * @param [in] control Tizen::UI::Control whose content is filled by the effect + * @exception E_SUCCESS The specified effect is bound with @c control successfully. + * @exception E_OPERATION_FAILED The system has failed to initialize the 3D system. + * @exception E_INVALID_STATE The specified effect has already started. + */ + result SetRenderTarget(const Tizen::Ui::Control* pControl); + + /** + * Starts Effect + * + * @since 2.0 + * + * @return An error code + * @param [in] effectStartInfo List of input arguments to be passed to OnEffectStarted function of the scripts. + * All arguments should be represented in float data type + * @exception E_INVALID_STATE The effect specified started already + * @exception E_OPERATION_FAILED The system failed to start the effect specified. + * The effect has a runtime error in script or the render target for this effect is not available + * @exception E_SUCCESS The effect specified was successfully started + * + */ + result Start(const Tizen::Base::Collection::IList& effectStartInfo); + + /** + * Stops Effect + * + * @since 2.0 + * + * @return An error code + * @exception E_INVALID_STATE The effect specified didn't start yet + * @exception E_SUCCESS The effect specified was successfully stopped + * + */ + result Stop(void); + + /** + * Informs an effect of a TouchPress event + * + * @since 2.0 + * + * @return An error code + * @param [in] touchEventInfo The touch event information + * @param [in] offset The effect manager will regard the touch position in @c touchEventInfo translated by the @c offset + * @exception E_INVALID_STATE The effect specified didn't start yet + * @exception E_OPERATION_FAILED There was a runtime error in the OnTouchPressed script function or the effect is time-based + * @exception E_SUCCESS Effect with such ID was successfully fed with TouchPress + * + */ + result FeedTouchPressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Tizen::Graphics::Point& offset); + + /** + * Informs an effect of a TouchMove event + * + * @since 2.0 + * + * @return An error code + * @param [in] touchEventInfo The touch event information + * @param [in] offset The effect manager will regard the touch position in @c touchEventInfo translated by the @c offset + * @exception E_INVALID_STATE The effect specified didn't start yet + * @exception E_OPERATION_FAILED There was a runtime error in the OnTouchPressed script function or the effect is time-based + * @exception E_SUCCESS Effect with such ID was successfully fed with TouchMove + * + */ + result FeedTouchMoveEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Tizen::Graphics::Point& offset); + + /** + * Informs an effect of a TouchRelease event + * + * @since 2.0 + * + * @return An error code + * @param [in] touchEventInfo The touch event information + * @param [in] offset The effect manager will regard the touch position in @c touchEventInfo translated by the @c offset + * @exception E_INVALID_STATE The effect specified didn't start yet + * @exception E_OPERATION_FAILED There was a runtime error in the OnTouchPressed script function or the effect is time-based + * @exception E_SUCCESS Effect with such ID was successfully fed with TouchRelease + * + */ + result FeedTouchReleaseEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Tizen::Graphics::Point& offset); + + /** + * Informs an effect of a TouchDoublePress event + * + * @since 2.0 + * + * @return An error code + * @param [in] touchEventInfo The touch event information + * @param [in] offset The effect manager will regard the touch position in @c touchEventInfo translated by the @c offset + * @exception E_INVALID_STATE The effect specified didn't start yet + * @exception E_OPERATION_FAILED There was a runtime error in the OnTouchPressed script function or the effect is time-based + * @exception E_SUCCESS Effect with such ID was successfully fed with TouchDoublePress + * + */ + result FeedTouchDoublePressEvent(const Tizen::Ui::TouchEventInfo& touchEventInfo, const Tizen::Graphics::Point& offset); + + /** + * Updates the effect's bitmap which is used as a graphical surface in scripts + * + * @since 2.0 + * + * @return An error code + * @param [in] bitmapId Id of a bitmap to be updated + * @param [in] bitmap Bitmap content + * @exception E_OPERATION_FAILED Updating bitmap contents failed + * @exception E_SUCCESS Bitmap was successfully updated + * + */ + result SetBitmap(long bitmapId, const Tizen::Graphics::Bitmap& bitmap); + + /** + * Gets the current state of the effect specified + * + * @since 2.0 + * + * @return @c true if the effect is running; @c false, otherwise + * @exception E_SUCCESS The effect state is successfully retrieved + * + */ + bool IsRunning(void) const; + + /** + * Gets Effect type + * + * @since 2.0 + * + * @return Type of effect + * @exception E_SUCCESS The effect type is successfully retrieved + * + */ + EffectType GetType(void) const; + + /** + * Gets the name of an effect + * + * @since 2.0 + * + * @return The name of the effect specified + * @exception E_SUCCESS The effect name is successfully retrieved + * + */ + Tizen::Base::String GetName(void) const; + + /** + * Sets the IEffectsEventListener instance to get notified when the state of the effect is changed + * + * @since 2.0 + * + * @return An error code + * @param [in] pListener The event listener to be set + * @exception E_SUCCESS The effect listener was successfully set + * + */ + void SetEffectEventListener(IEffectEventListener* pListener); + + /** + * Gets the IEffectsEventListener instance. + * + * @since 2.0 + * + * @return The event listener for specified effect. + */ + IEffectEventListener* GetEffectEventListener(void) const; + + /** + * Sets the IEffectsResourceProvider instance to get notified when resources are needed by the effect + * + * @since 2.0 + * + * @return An error code + * @param [in] pProvider The resource provider to provide the effect with bitmap resources + * @exception E_SUCCESS The effect resource provider was successfully set + * + */ + void SetResourceProvider(IEffectResourceProvider* pProvider); + + /** + * Gets the IEffectsResourceProvider instance. + * + * @since 2.0 + * + * @return The resource provider for specified effect. + */ + IEffectResourceProvider* GetResourceProvider(void) const; + +private: + + /** + * The constructor + * + * @since 2.0 + */ + _EffectImpl(Effect& effect); + + /** + * The destructor + * + * @since 2.0 + */ + virtual ~_EffectImpl(void); + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + _EffectImpl(const _EffectImpl& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + _EffectImpl& operator=(const _EffectImpl& rhs); + + /** + * Finds OpenGLES surface by Control's pointer + * + * @since 2.0 + * + * @return EGLSurface OpenGL surface created for given control, EGL_NO_SURFACE if not found + * @param [in] Control UI Control + * + */ + EGLSurface FindGlesSurface(const Tizen::Ui::Control* pControl) const; + + /** + * Stops Effect Computing + * + * @since 2.0 + * + * @param [in] effect Effect instance + * @exception E_SYSTEM + * + */ + void EffectModelTimerStop(void); + + /** + * Implementation of ITimerEventListener::OnTimerExpired method - Triggering Effect Computing and Rendering + * + * @since 2.0 + * + * @param [in] timer Tizen::Ui::Runtime::Timer instance + * @exception E_FILE_NOT_FOUND Effect with such ID doesn't exist + * @exception E_SYSTEM + * + */ + void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + /** + * Implementation of IEffectModelListener::OnEffectStarted method + * + * @since 2.0 + * + * @param [in] effectId Id of an effect that requires handling + * @exception E_FILE_NOT_FOUND Effect with such ID doesn't exist + * @exception E_NOT_JOINED EventListener is not assigned + * @exception E_SYSTEM + * @see IEffectModelListener in "FUiEffects_RuntimeIEffectModelListener.h" + * + */ + void OnEffectStarted(void); + + /** + * Implementation of IEffectModelListener::OnEffectFinished method + * + * @since 2.0 + * + * @param [in] effectId Id of an effect that requires handling + * @param [in] effectResult One of possible options of Effect finishing + * @param [in] bitmapId Bitmap(s) which acts as Target after Effect finishing + * @exception E_FILE_NOT_FOUND Effect with such ID doesn't exist + * @exception E_NOT_JOINED EventListener is not assigned + * @exception E_SYSTEM + * @see IEffectModelListener in "FUiEffects_RuntimeIEffectModelListener.h" + * + */ + void OnEffectFinished(EffectResult effectResult, const Tizen::Ui::Effects::_Runtime::LastShownBitmapIdCollection& bitmapsTargetId); //TODO: List of bitmaps + + /** + * Implementation of IEffectModelListener::OnBitmapRequested method + * + * @since 2.0 + * + * @return true If User in C++ Application in IEffectResourceProvider::OnBitmapRequested implementation returns E_SUCCESS + * false If User in C++ Application in IEffectResourceProvider::OnBitmapRequested implementation doesn't return E_SUCCESS + * @param [in] effectId Id of an effect that requires handling + * @param [in] bitmapId Bitmap that has to be updated + * @exception E_FILE_NOT_FOUND Effect with such ID doesn't exist + * @exception E_NOT_JOINED ResourceProvider is not assigned + * @exception E_SYSTEM + * @see IEffectModelListener in "FUiEffects_RuntimeIEffectModelListener.h" + * + */ + bool OnBitmapRequested(long bitmapId); + + /** + * Creates a new effect from specialised effect file + * + * @since 2.0 + * + * @return True if effect was initialised successfully and false otherwise + * @see EffectManager::CreateEffect() + * + */ + void InitializeEffect(void); + + /** + * Updates information about screen size if it was changed + * + * @since 2.0 + * + * @see SetScreen() + * + */ + void UpdateScreen(void); + + /** + * Removes a pair (effect*, control*) from a accordingly container and deletes GL surface if it does not need more + * + * @since 2.0 + * + */ + void ReleaseRenderTarget(const Control& control); + + /** + * Tries set a new render target for an effect. + * Releases old render target if successful (calls function ReleaseRenderTarget) + * + * @since 2.0 + * + */ + result SetRenderTargetInternal(const Tizen::Ui::Control& control, const Tizen::Ui::Control& controlOld); + +private: + Effect* __pEffect; + + static EffectsSet __effects; + static RenderControlsMap __renderControls; + static EffectsControlsMap __effectsControlsMapRegistered; + static ControlsSet __controlsSetPerforming; + static long __effectsCount; + + /** + * @brief Model instance + * + */ + std::unique_ptr<_Runtime::IEffectModelManager> __pModel; + + + /** + * @brief Renderer instance + * + */ + _Renderer::EffectRendererUniquePtr __pRenderer; + + /** + * @brief Event Listener + * + */ + IEffectEventListener* __pEventListener; + + /** + * @brief Resource Provider + * + */ + IEffectResourceProvider* __pResourceProvider; + + /** + * @brief Timer for model updates + * + */ + _EffectTimer __modelTimer; + + /** + * @brief Internal usage + * + */ + bool __renderTargetSet; + + friend class _EffectManagerImpl; + friend class Effect; +}; // _EffectImpl + +}}} // Tizen::Ui::Effects + +#endif // _FUI_EFFECTS_INTERNAL_EFFECT_IMPL_H_ diff --git a/src/ui/effects/FUiEffects_EffectManagerImpl.cpp b/src/ui/effects/FUiEffects_EffectManagerImpl.cpp new file mode 100644 index 0000000..5ba19ba --- /dev/null +++ b/src/ui/effects/FUiEffects_EffectManagerImpl.cpp @@ -0,0 +1,201 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_EffectManagerImpl.cpp + * @brief This is the source file for the _EffectManagerImpl class + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include "FUiEffects_EffectImpl.h" +#include "FUiEffects_EffectManagerImpl.h" +#include +#include +#include +#include "FUiEffects_EffectErrorMessages.h" + +using namespace Tizen::Ui::Controls; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Base::Collection; + +using namespace Tizen::Ui::Effects::_Runtime; +using namespace Tizen::Ui::Effects::_Renderer; +using namespace Tizen::Ui::Effects::_Parser; +using namespace Tizen::Ui::Effects; +using namespace Tizen::Ui::Effects::_Utils; +using namespace std; + +using namespace Tizen::Ui::Effects::_Parser; + +namespace Tizen { namespace Ui { namespace Effects +{ + +_EffectManagerImpl* pEffectManagerImpl = null; +EffectManager* pEffectManager = null; +pthread_once_t once_block = PTHREAD_ONCE_INIT; + +const char* _EffectManagerImpl::__pPathToEffectFile = null; + +Effect* +_EffectManagerImpl::CreateEffect(const Tizen::Base::String& filePath) +{ + SetLastResult(E_SUCCESS); + + bool fileExists = false; + std::fstream fin; + + std::wstring tempWStr(filePath.GetPointer()); + std::string filePathStr(tempWStr.begin(), tempWStr.end()); + fin.open(filePathStr.c_str(), std::ios::in); + fileExists = fin.is_open(); + fin.close(); + + SysTryReturn(NID_UI_EFFECT, fileExists, null, E_FILE_NOT_FOUND, _UiEffectError::NO_EFFECT_FILE, filePathStr.c_str()); + + __pPathToEffectFile = filePathStr.c_str(); + + Effect* pEffect = new (std::nothrow) Effect(); + SysTryReturn(NID_UI_EFFECT, pEffect != null, null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + result r = GetLastResult(); + SysTryCatch(NID_UI_EFFECT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SysLog(NID_UI_EFFECT, "Effect from file '%ls' is loaded successfully", filePath.GetPointer()); + return pEffect; + +CATCH: + delete pEffect; + return null; +} + +void +_EffectManagerImpl::DestroyEffect(Effect& effect) +{ + SetLastResult(E_SUCCESS); + + if (_EffectImpl::__effects.find(&effect) != _EffectImpl::__effects.end()) + { + SysLog(NID_UI_EFFECT, "The effect [%ls] is destroying now", effect.GetName().GetPointer()); + delete &effect; + SysLog(NID_UI_EFFECT, "The effect is destroyed successfully"); + } + else + { + SysLog(NID_UI_EFFECT, "The effect was destroyed before"); + } + + return; +} + +_EffectManagerImpl::_EffectManagerImpl(void) +{ + if (EffectRenderer::InitOpenGL()) + { + SysLog(NID_UI_EFFECT, "Effects. OpenGL initialization is successful!"); + } + else + { + SysLogException(NID_UI_EFFECT, E_OPERATION_FAILED, "[E_OPERATION_FAILED] OpenGL initialization failed"); + } +} + +_EffectManagerImpl::~_EffectManagerImpl(void) +{ + // destroy all effects + // operator while is here because in Effect class destuctor we erase element from container __effects + while (true) + { + if (_EffectImpl::__effects.empty()) + { + break; + } + delete *(_EffectImpl::__effects.begin()); + } + + _EffectImpl::__renderControls.clear(); + _EffectImpl::__controlsSetPerforming.clear(); + + EffectRenderer::CloseOpenGL(); +} + +void +_EffectManagerImpl::InitSingleton(void) +{ + SysAssertf(pEffectManagerImpl == null, _UiEffectError::INTERNAL_ERROR); + SysAssertf(pEffectManager == null, _UiEffectError::INTERNAL_ERROR); + + std::unique_ptr<_EffectManagerImpl> pEffectManagerImplTemp(new (std::nothrow) _EffectManagerImpl()); + SysTryReturnVoidResult(NID_UI_EFFECT, pEffectManagerImplTemp.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + pEffectManager = new (std::nothrow) EffectManager(); + SysTryReturnVoidResult(NID_UI_EFFECT, pEffectManager != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + pEffectManagerImpl = pEffectManagerImplTemp.release(); +} + +_EffectManagerImpl::ManagerAndImplPair +_EffectManagerImpl::GetInstance(void) +{ + SetLastResult(E_SUCCESS); + + if (pEffectManagerImpl == null) + { + SysAssertf(pEffectManager == null, _UiEffectError::INTERNAL_ERROR); + pthread_once(&once_block, InitSingleton); + result res = GetLastResult(); + SysTryReturn(NID_UI_EFFECT, res == E_SUCCESS, std::make_pair(static_cast(null), static_cast<_EffectManagerImpl*>(null)), res, "[%s] Propagating.", GetErrorMessage(res)); + } + + return std::make_pair(pEffectManager, pEffectManagerImpl); +} + +void +_EffectManagerImpl::DestroyInstance(void) +{ + SetLastResult(E_SUCCESS); + if (pEffectManagerImpl != null) + { + SysAssertf(pEffectManager != null, _UiEffectError::INTERNAL_ERROR); + delete pEffectManagerImpl; + delete pEffectManager; + pEffectManagerImpl = null; + pEffectManager = null; + once_block = PTHREAD_ONCE_INIT; + } + return; +} + +} } } //Tizen::Ui::Effects diff --git a/src/ui/effects/FUiEffects_EffectManagerImpl.h b/src/ui/effects/FUiEffects_EffectManagerImpl.h new file mode 100644 index 0000000..cbf7960 --- /dev/null +++ b/src/ui/effects/FUiEffects_EffectManagerImpl.h @@ -0,0 +1,123 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_EffectManagerImpl.h + * @brief This is the header file for the _EffectManagerImpl class + */ + +#ifndef _FUI_EFFECTS_INTERNAL_EFFECTS_MANAGER_IMPL_H_ +#define _FUI_EFFECTS_INTERNAL_EFFECTS_MANAGER_IMPL_H_ + +#include +#include + +namespace Tizen { namespace Base { +class String; +}} // Tizen::Base + +namespace Tizen { namespace Ui { namespace Effects +{ + +class Effect; +class EffectManager; + +class _EffectManagerImpl +{ + typedef std::pair ManagerAndImplPair; +public: + + /** + * Gets the effect manager instance. + * + * @since 2.0 + * + * @return A pointer to the %EffectManager instance + * @exception E_SUCCESS The %EffectManager instance is constructed successfully. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_OPERATION_FAILED The system has failed to initialize the 3D system. + */ + static ManagerAndImplPair GetInstance(void); + + /** + * Destroys all previously created effects and their resources. @n + * Application can use OpenGL APIs only after invoking this method. + * + * @since 2.0 + */ + static void DestroyInstance(void); + + /** + * Creates a new effect from specialised effect file + * + * @since 2.0 + * + * @return If success - pointer to effect; if failed - null + * @param [in] filePath The file path of the effect + * @exception E_OUT_OF_MEMORY Insufficient memory + * @exception E_FILE_NOT_FOUND The effect file specified doesn't exist + * @exception E_PARSING_FAILED Syntax Error in the effect file (structure or script) + * @see UnregisterEffectFile() + * + */ + Effect* CreateEffect(const Tizen::Base::String& filePath); + + /** + * Deletes an effect specified + * + * @since 2.0 + * + * @return An error code + * @param [in] effect Reference to effect to be destroyed + * @exception E_SUCCESS The effect specified was successfully destroyed + * @see RegisterEffectFile() + * + */ + void DestroyEffect(Effect& effect); + +private: + /** + * Constructor + * + * @since 2.0 + * + * @exception E_OUT_OF_MEMORY _EffectManagerImpl instance can not be created + * + */ + _EffectManagerImpl(void); + + /** + * Destructor for _EffectManagerImpl + * + * @since 2.0 + * + * + */ + ~_EffectManagerImpl(void); + + static void InitSingleton(void); + +private: + + static const char* __pPathToEffectFile; + + friend class _EffectImpl; // <-- for access to private area of class _EffectManagerImpl from class Effect + friend class boost::default_delete<_EffectManagerImpl>; //for deleting unique_ptr<_EffectManagerImpl> instance in InitSingleton function +}; + +} } } //Tizen::Ui::Effects + +#endif // _FUI_EFFECTS_INTERNAL_EFFECTS_MANAGER_IMPL_H_ diff --git a/src/ui/effects/FUiEffects_EffectTimer.h b/src/ui/effects/FUiEffects_EffectTimer.h new file mode 100644 index 0000000..b4b389f --- /dev/null +++ b/src/ui/effects/FUiEffects_EffectTimer.h @@ -0,0 +1,206 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_EffectTimer.h + * @brief This is the header file for the _EffectTimer class + */ + +#ifndef FUI_EFFECTS_INTERNAL_EFFECTTIMER_H_ +#define FUI_EFFECTS_INTERNAL_EFFECTTIMER_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects +{ + +/** + * @class _EffectTimer + * @brief Class for effect timer + * + * @since 2.0 + */ +class _EffectTimer + : public Tizen::Base::Runtime::Timer +{ +public: + + /** + * Constructor + * + * @since 2.0 + * + * @param [in] _type Set type of this timer + * + */ + _EffectTimer(void): __effectID(-1), __timeout(-1), __t1(-1), __countGreater(0), __count(0) + { + + } + + /** + * Timer Initialisation + * + * @since 2.0 + * + * @param [in] TimerEventListener OnTimerExpired event listener + * @param [in] _effectID id of effect assigned to this timer + * @param [in] _timeout A __timeout interval in milliseconds + * + */ + result Construct(Tizen::Base::Runtime::ITimerEventListener &TimerEventListener, long effectID, int timeout) + { + __effectID = effectID; + __timeout = timeout; + return Tizen::Base::Runtime::Timer::Construct(TimerEventListener); + } + + /** + * Gets Id of Effect assigned to this timer + * + * @since 2.0 + * + * @return EffectIDType Effect id + */ + long GetEffectIdType(void) + { + return __effectID; + } + + /** + * Stores current system time for next realtime interval calculation + * + * @since 2.0 + * + * @see _EffectTimer::CalculationTimeStep + */ + void Reset(void) + { + Tizen::System::SystemTime::GetTicks(__t1); + __countGreater = 0; + __count = 0; + + return; + } + + /** + * Starts the timer + * + * @since 2.0 + * + */ + void Start(int t = 0) + { + if (t == 0) + { + Timer::Start(__timeout); + } + else + { + Timer::Start(t); + } + IncreaseCount(); + + return; + } + + /** + * Increases the variable count means a number of calling function OnTimerExpired + * + * @since 2.0 + * + */ + void IncreaseCount() + { + __count++; + + return; + } + + /** + * Stops the timer + * + * @since 2.0 + * + */ + void Stop() + { + if (__countGreater != 0) + { + int c = (int)(__countGreater * 1.f / __count * 100); + SysLog(NID_UI_EFFECT, "Timer timeout for effect with %i ID is greater than a threshold in %i%% of cases.", __effectID, c); + } + Tizen::Base::Runtime::Timer::Cancel(); + return; + } + + + /** + * Resets and then starts. Use this method for first run + * + * @since 2.0 + * + */ + void Restart() + { + Reset(); + Start(); + + return; + } + + + /** + * Precise realtime interval calculation. + * + * @since 2.0 + * + * @return float + */ + float CalculationTimeStep(void) + { + const long long t0 = __t1; + Tizen::System::SystemTime::GetTicks(__t1); + + int sub = __t1 - t0; + + if (sub > 3*__timeout) + { + sub = 3*__timeout; + if (__countGreater == 0) + { + SysLogException(NID_UI_EFFECT, E_TIMEOUT, "Timer timeout for effect with %i ID is too small! Your device is too slow for specified timeout. You may increase the timer time.", __effectID); + } + __countGreater++; + } + + return sub * 0.001f; + } + +private: + long __effectID; /**< id of parent effect */ + int __timeout; /**< period in milliseconds */ + long long __t1; /**< internal use */ + long __countGreater; + long __count; +}; + +} } } // Tizen::Ui::Effects + +#endif //FUI_EFFECTS_INTERNAL_EFFECTTIMER_H_ diff --git a/src/ui/effects/inc/FUiEffects_LoggingProfiler.h b/src/ui/effects/inc/FUiEffects_LoggingProfiler.h new file mode 100644 index 0000000..7feee18 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_LoggingProfiler.h @@ -0,0 +1,135 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_LoggingProfiler.h + * @brief This is the header file for the profiling defines + */ + +#ifndef FUIEXTEFF3D_ELOGPROFILER_H_ +#define FUIEXTEFF3D_ELOGPROFILER_H_ + +#ifdef USE_PROFILER + +#include + +#ifdef __linux__ +#include +#ifndef CLOCK_MONOTONIC_RAW +#error Undefined CLOCK_MONOTONIC_RAW +#endif +#define HIRES_COUNTER_ID CLOCK_MONOTONIC_RAW +#else +#error Unknown platform +#endif + +namespace Tizen { namespace Ui { namespace Effects { namespace _EffectsLogging +{ +//instant measure +#define START_PROFILER(Name)\ + static timespec Name##_prof_t1, Name##_prof_t2;\ + static long Name##_prof_dt = 0;\ + clock_gettime(HIRES_COUNTER_ID, &Name##_prof_t1); + +#define END_PROFILER(Name) \ + clock_gettime(HIRES_COUNTER_ID, &Name##_prof_t2); \ + Name##_prof_dt = (Name##_prof_t2.tv_sec - Name##_prof_t1.tv_sec) * 1000000 + (Name##_prof_t2.tv_nsec - Name##_prof_t1.tv_nsec) / 1000; \ + SysLog(NID_UI_EFFECT, #Name" = %.3f ms", (float) Name##_prof_dt * 0.001f); + +#define PROFILER_EXPR(expression, Name) \ + START_PROFILER(Name) \ + expression \ + END_PROFILER(Name) + +#define PROFILER_EXPR0(expression, Name) expression + +//average measure +#define START_PROFILER_AV(Name, N) \ + static timespec Name##_prof_av_t1, Name##_prof_av_t2; \ + static long Name##_prof_av_tmin = 999999999, Name##_prof_av_tmax = -1;\ + static long Name##_prof_av_dt = 0;\ + static unsigned int Name##_prof_av_count = N, Name##_prof_av_N = N; \ + clock_gettime(HIRES_COUNTER_ID, &Name##_prof_av_t1); + +#define END_PROFILER_AV(Name) \ + if (Name##_prof_av_count > 0) \ + { \ + clock_gettime(HIRES_COUNTER_ID, &Name##_prof_av_t2); \ + long dt = (Name##_prof_av_t2.tv_sec - Name##_prof_av_t1.tv_sec) * 1000000 + (Name##_prof_av_t2.tv_nsec - Name##_prof_av_t1.tv_nsec) / 1000;\ + if(dt > Name##_prof_av_tmax) Name##_prof_av_tmax = dt; \ + if(dt < Name##_prof_av_tmin) Name##_prof_av_tmin = dt; \ + Name##_prof_av_dt += dt; \ + Name##_prof_av_count--; \ + } \ + else \ + {\ + SysLog(NID_UI_EFFECT, #Name" = %.3f ms (min = %.3f, max = %.3f)", float(Name##_prof_av_dt / Name##_prof_av_N) * 0.001f, (float) Name##_prof_av_tmin * 0.001f, (float) Name##_prof_av_tmax * 0.001f);\ + Name##_prof_av_count = Name##_prof_av_N;\ + Name##_prof_av_dt = 0; \ + Name##_prof_av_tmin = 999999999; \ + Name##_prof_av_tmax = -1;\ + } + +#define PROFILER_EXPR_AV(expression, Name, N) \ + START_PROFILER_AV(Name, N) \ + expression \ + END_PROFILER_AV(Name) + +#define PROFILER_EXPR_AV0(expression, Name, N) expression + +//checkpoint entrance +#define PROFILER_CHECKPOINT(Name, N) \ + static timespec Name##_prof_checkp_t1, Name##_prof_checkp_t2;\ + static long Name##_prof_checkp_tmin = 999999999, Name##_prof_checkp_tmax = -1;\ + static long Name##_prof_checkp_dt = 0;\ + static unsigned int Name##_prof_checkp_count = 0, Name##_prof_checkp_N = N;\ + \ + if (Name##_prof_checkp_count > 0) \ + { \ + clock_gettime(HIRES_COUNTER_ID, &Name##_prof_checkp_t2); \ + long dt = (Name##_prof_checkp_t2.tv_sec - Name##_prof_checkp_t1.tv_sec) * 1000000 + (Name##_prof_checkp_t2.tv_nsec - Name##_prof_checkp_t1.tv_nsec) / 1000; \ + clock_gettime(HIRES_COUNTER_ID, &Name##_prof_checkp_t1); \ + if(dt > Name##_prof_checkp_tmax) Name##_prof_checkp_tmax = dt; \ + if(dt < Name##_prof_checkp_tmin) Name##_prof_checkp_tmin = dt; \ + Name##_prof_checkp_dt += dt; \ + Name##_prof_checkp_count--; \ + } \ + else \ + {\ + clock_gettime(HIRES_COUNTER_ID, &Name##_prof_checkp_t1); \ + SysLog(NID_UI_EFFECT, #Name" = %.3f ms (min = %.3f, max = %.3f)", float(Name##_prof_checkp_dt / Name##_prof_checkp_N) * 0.001f, (float) Name##_prof_checkp_tmin * 0.001f, (float) Name##_prof_checkp_tmax * 0.001f);\ + Name##_prof_checkp_count = Name##_prof_checkp_N;\ + Name##_prof_checkp_dt = 0;\ + Name##_prof_checkp_tmin = 999999999; \ + Name##_prof_checkp_tmax = -1;\ + } + +} } } } // Tizen::Ui::Effects::_EffectsLogging +#else //USE_PROFILER +#define START_PROFILER(Name) +#define END_PROFILER(Name) +#define PROFILER_EXPR(expression, Name) expression +#define PROFILER_EXPR0(expression, Name) expression + +#define START_PROFILER_AV(Name, N) +#define END_PROFILER_AV(Name) +#define PROFILER_EXPR_AV(expression, Name, N) expression +#define PROFILER_EXPR_AV0(expression, Name, N) expression + +#define PROFILER_CHECKPOINT(Name, N) +#endif //USE_PROFILER + +#endif // FUIEXTEFF3D_ELOGPROFILER_H_ diff --git a/src/ui/effects/inc/FUiEffects_Parser.h b/src/ui/effects/inc/FUiEffects_Parser.h new file mode 100644 index 0000000..e214a4b --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_Parser.h @@ -0,0 +1,28 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiEffects_Parser.h +* @brief This is the header file for the Tizen::Ui::Ext::Effects3d::_Parser namespace. +*/ + +#ifndef FUI_EFFECTS_INTERNAL_PARSER_H_ +#define FUI_EFFECTS_INTERNAL_PARSER_H_ + +#include "FUiEffects_ParserEffectParser.h" +#include "FUiEffects_ParserXMLParser.h" + +#endif //FUI_EFFECTS_INTERNAL_PARSER_H_ diff --git a/src/ui/effects/inc/FUiEffects_ParserEffectParser.h b/src/ui/effects/inc/FUiEffects_ParserEffectParser.h new file mode 100644 index 0000000..d6d1c41 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_ParserEffectParser.h @@ -0,0 +1,290 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_ParserEffectParser.h + * @brief This file contains a declaration of EffectParser class + */ + +#ifndef _FUI_EFFECTS_INTERNAL_PARSER_EFFECTPARSER_H_ +#define _FUI_EFFECTS_INTERNAL_PARSER_EFFECTPARSER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { +class EffectRenderer; +} } } } + +/** + * @namespace _Parser + * @brief This namespace contains classes that provide methods for parsing an effect file + * and building the effect +*/ +namespace Tizen { namespace Ui { namespace Effects { namespace _Parser +{ + +/** + * @class EffectParser + * @brief A static method only class that performs unzipping of an effect file, + * parsing of xml-files of the model and may create or not the model itself + * + * @since 2.0 + * + */ +class EffectParser +{ +public: + /** + * Handles an open-tag of an XML-element in a file being parsed by XMLParser + * + * @since 2.0 + * + * @param [in] elementName - the name of the XML-element + * @exception E_OUT_OF_MEMORY Insufficient memory + * @remarks Can only be called from XMLParser and from friends + */ + void StartElement(const char* pElementName); + + /** + * Handles an close-tag of an XML-element in a file being parsed by XMLParser + * + * @since 2.0 + * + * @param[in] elementName the name of the XML-element + * @exception E_INVALID_STATE The instance buffers occurred to be in an invalid state + * @exception E_INVALID_ARG An unexpected argument passed + * @remarks Can only be called from XMLParser and from friends + */ + void EndElement(const char* pElementName); + + /** + * Handles presence of an attribute in an XML-element + * in a file being parsed by XMLParser + * + * @since 2.0 + * + * @param[in] attributeName - the name of the attribute of an XML-element + * @param[in] attributeValue - the value of the attribute of an XML-element + * @exception E_INVALID_STATE The instance buffers occurred to be in an invalid state + * @remarks Can only be called from XMLParser and from friends + */ + void Attribute(const char* pAttributeName, const char* pAttributeValue); + + /** + * Unzips and checks content of an effect file, performs XML-parsing + * of the corresponding files + * + * @since 2.0 + * + * @return A boolean result of both: effect file parsing and XML-parsing + * @param[in] path a full path to the input effect file (a zip-archive) + * @exception OUT_OF_MEMORY Insufficient memory + * @exception E_INVALID_ARG An invalid argument passed to the XmlParser instantiator + * @exception E_ALREADY_BOUND The passed parent doesn't match the current parent + * of a created XmlParser singleton object + * @exception E_OPERATION_FAILED Extraction of model files from an effect file hasn't finished successfully + */ + static bool ParseEffectFile(const char* pEffectFilePath, const char* pModelFilesDirectoryPath); + + /** + * Performs unziping of an effect file, checks out its content,performs + * XML-parsing and constructs according to the effect file EffectInstance object + * + * @since 2.0 + * + * @return A pointer to the constructed _EffectInstance or null if parsing failed + * at some point + * @param[in] path - a full path to the input effect file (a zip-archive) + * @param[in] effectsManager a pointer to the object that should call this method + * @param[in] effectModelID an ID of the effect to be constructed + * @exception OUT_OF_MEMORY Insufficient memory + * @exception E_INVALID_ARG An invalid argument passed to the XmlParser instantiator + * @exception E_ALREADY_BOUND The passed parent doesn't match the current parent + * of a created XmlParser singleton object + * @exception E_OPERATION_FAILED Extraction of model files from an effect file hasn't finished successfully + * @exception E_PARSING_FAILED XML parsing hasn't been successful + * @exception E_KEY_NOT_FOUND Missing an attribute or an error model attributes + * @exception E_INVALID_CONDITION A member variable of effect parser was not initialized + * @exception E_INVALID_FORMAT An error in the logic of effect parser occurred + */ + static result ParseEffectFileLoadModel(const char* pEffectFilePath, const char* pModelFilesDirectoryPath, + Tizen::Ui::Effects::_Runtime::IEffectModelListener* pEffectManager, long effectModelID, + Tizen::Ui::Effects::_Runtime::IEffectModelManager*& pEffectModel, Tizen::Ui::Effects::_Renderer::EffectRenderer*& pEffectRenderer, int& modelTimerTimeout); + +private: + /** + * @brief class constructor + * @remarks accessible only from static methods and from friends + */ + EffectParser(void); + + /** + * @brief class destructor + * @remarks accessible only from static methods and from friends + */ + ~EffectParser(void); + + // Hidden copy constructor + EffectParser(const EffectParser& rhs); + + // Hidden assignment operator + EffectParser& operator=(const EffectParser& rhs); + + // Container of attibutes of an xml element + typedef std::map TypeXmlElementAttributes; + + // type of an xml element containing its name and attributes + struct XmlElement + { + std::string name; + TypeXmlElementAttributes attributes; + }; + + struct SceneData + { + unsigned int timerTimeout; + Tizen::Ui::Effects::_Utils::Vec3f ambientColor; + float intensity; + float attenuation; + SceneData(); + }; + + struct ViewportData + { + float x; + float y; + float z; + float width; + float height; + float near; + float far; + float angle; + bool perspective; + ViewportData(); + }; + + // Container of pointers to objects of ElementSurface + typedef std::vector TypePElementSurfaceCollection; + + // Container of pointers to objects of UnitLight + typedef std::vector TypePUnitLightCollection; + + // Container of objects of XmlElement + typedef std::vector TypeXmlElementCollection; + + // Container that maps indices of PointSurfaceNurbs objects in the model file to indices of those in + // the appropriate container of this class + typedef std::map, unsigned int> TypeNurbsPointIndexDistributor; + + // Container of pointers to objects of ModelSurface + typedef std::vector TypePModelSurfaceCollection; + + bool ExtractModelFiles(const char* pPath); + void ClearModelFiles(void); + void ClearBuffers(void); + + Tizen::Ui::Effects::_PhysicsEngine::PointSurface* FindPointSurfaceById(long pointId) const; + Tizen::Ui::Effects::_PhysicsEngine::PointSurfaceNurbs* FindPointSurfaceNurbsByIndices(unsigned int row, unsigned int col) const; + + bool CreatePointLight(XmlElement&); + bool CreateSpotLight(XmlElement&); + bool CreateDirectionalLight(XmlElement&); + bool CreatePointSurface(XmlElement&); + bool CreateSpringSurface(XmlElement&); + bool CreateRodSurface(XmlElement&); + bool CreateRodSurfaceNurbs(XmlElement&); + bool CreateGraphicalSurface(XmlElement&); + bool CreatePointSurfaceNurbs(XmlElement&); + bool CreateGraphicalSurfaceKnot(XmlElement&); + bool PriorReadModelSurfaceData(void); + bool PriorReadGraphicalSurfaceData(void); + bool CreateModelSurface(XmlElement&); + bool CreateEffectModel(XmlElement&); + bool CreateGravityForce(XmlElement&); + bool ReadViewportData(XmlElement&); + bool PriorReadSceneData(void); + bool ReadManifestData(XmlElement&); + Tizen::Ui::Effects::_Utils::Vec3f StringHexToRgb(const std::string&); + +private: + + static EffectParser* __pInstance; + std::unique_ptr __pXmlParser; + + std::string __currentModelFilesDirectoryPath; + static const std::string __MANIFEST_FILE_NAME; + static const std::string __SCENE_FILE_NAME; + static const std::string __SCRIPT_FILE_NAME; + + TypeXmlElementCollection __elementBuffer; + TypeNurbsPointIndexDistributor __pointSurfaceNurbsIndices; + TypePElementSurfaceCollection __elementSurfaceBuffer; + TypePUnitLightCollection __unitLightBuffer; + std::unique_ptr __pCurrentGraphicalSurface; + Tizen::Ui::Effects::_Utils::Vec3f __currentGravityForce; + float __currentGravityForceValue; + std::unique_ptr __pCurrentVectorXBuffer; + std::unique_ptr __pCurrentVectorYBuffer; + TypePModelSurfaceCollection __modelSurfaceBuffer; + + int __lastSceneXMLElementIndex; + int __lastModelSurfaceXMLElementIndex; + int __lastGraphicalSurfaceXMLElementIndex; + std::unique_ptr __pCurrentEffectModel; + Tizen::Ui::Effects::_Runtime::IEffectModelListener* __pCurrentEffectManager; //agrigation pointer + + long __currentEffectId; + Tizen::Ui::Effects::EffectType __currentModelBehaviourType; + Tizen::Ui::Effects::_Runtime::TypeTimeEffect __currentEffectDuration; + std::string __currentEffectInstanceName; + + SceneData __currentSceneData; + ViewportData __currentViewportData; + + float __currentModelSurfaceX; + float __currentModelSurfaceY; + unsigned int __currentGraphicalSurfaceDimCtrlX; + unsigned int __currentGraphicalSurfaceDimCtrlY; + + bool __insideGraphicalSurface; + bool __rightAfterSceneStart; + bool __rightAfterModelSurfaceStart; + bool __rightAfterGraphicalSurfaceStart; + bool __insideVectorX; + bool __insideVectorY; + bool __buildingModelFailed; + bool __insideElementsPool; +}; // EffectParser + +} } } } // Tizen::Ui::Effects::_Parser + +#endif // _FUI_EFFECTS_INTERNAL_PARSER_EFFECTPARSER_H_ diff --git a/src/ui/effects/inc/FUiEffects_ParserXMLParser.h b/src/ui/effects/inc/FUiEffects_ParserXMLParser.h new file mode 100644 index 0000000..4509124 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_ParserXMLParser.h @@ -0,0 +1,119 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_ParserXMLParser.h + * @brief This file contains a declaration of XmlParser class + */ + +#ifndef _FUI_EFFECTS_INTERNAL_PARSER_XMLPARSER_H_ +#define _FUI_EFFECTS_INTERNAL_PARSER_XMLPARSER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Parser +{ + +class EffectParser; + +/** + * @class XmlParser + * @brief An intermediate functionality between tizen's xmlSAXHandler and EffectParser class + * Uses the former for parsing an .xml file and sends information to the latter + * Implemented according to the singleton pattern + * + * @since 2.0 + * + */ +class XmlParser +{ +public: + + /** + * Class constructor + * + * @since 2.0 + * + */ + XmlParser(EffectParser* pParent); + + /** + * Class destructor + * + * @since 2.0 + * + */ + virtual ~XmlParser(void); + + /** + * Performs a complete parsing of an .xml file by usage xmlSAXHandler + * + * @since 2.0 + * + * @return A boolean result of XML-parsing only + * @param[in] pFilePath - a full path to the input file + * @param[in] sendcallbacks - determines whether to send information to EffectParser + * or just to parse the input file + * @exception E_PARSING_FAILED XML parsing hasn't been successful + */ + bool Parse(const char* pFilePath, bool sendCallbacks); + + /** + * Unzips a .zip-archive + * + * @since 2.0 + * + * @param[in] pArchivePath - a full path to the archive + * @param[in] pDestinationPath - a path to the directory for the archive + * to be extracted to + */ + static bool ExtractFromArchive(const char* pArchivePath, const char* pDestinationPath); + +protected: + +private: + + // Hidden copy constructor + XmlParser(const XmlParser& rhs); + + // Hidden assignment operator + XmlParser& operator=(const XmlParser& rhs); + + // SAX callback that handles an opening tag of a new element + static void StartElementNs(void * pCtx, const xmlChar* pLocalName, const xmlChar* pPrefix, const xmlChar* pUri, + int namespaceCount, const xmlChar** ppNamespaces, int attributeCount, int defaultedCount, const xmlChar** ppAttributes); + + // SAX callback that handles a closing tag of an element + static void EndElementNs(void* pCtx, const xmlChar* pLocalName, const xmlChar* pPrefix, const xmlChar* pUri); + + // SAX callback that handles precense of a text line inside some element + static void CharactersM(void* pCtx, const xmlChar* pCh, int len); + + // SAX callback that handles a sax error message + static void Error(void* pCtx, const char* pMsg, ... ); + + // SAX callback that handles a sax warning + static void Warning(void* pCtx, const char* pMsg, ... ); + +private: + + static EffectParser* __pCurrentParent; + static bool __justParse; +}; + +} } } } // Tizen::Ui::Effects::_Parser + +#endif //_FUI_EFFECTS_INTERNAL_PARSER_XMLPARSER_H_ diff --git a/src/ui/effects/inc/FUiEffects_Pe.h b/src/ui/effects/inc/FUiEffects_Pe.h new file mode 100644 index 0000000..a01919f --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_Pe.h @@ -0,0 +1,32 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiEffects_Pe.h +* @brief This is the header file for the %_PhysicsEngine namespace +*/ + +#ifndef _FUI_EFFECTS_INTERNAL_PE_H_ +#define _FUI_EFFECTS_INTERNAL_PE_H_ + +#include "FUiEffects_PeElementSurface.h" +#include "FUiEffects_PePointSurface.h" +#include "FUiEffects_PePointSurfaceNURBS.h" +#include "FUiEffects_PeRodSurface.h" +#include "FUiEffects_PeRodSurfaceNURBS.h" +#include "FUiEffects_PeSpringSurface.h" + +#endif //_FUI_EFFECTS_INTERNAL_PE_H_ diff --git a/src/ui/effects/inc/FUiEffects_PeElementSurface.h b/src/ui/effects/inc/FUiEffects_PeElementSurface.h new file mode 100644 index 0000000..f8f2f27 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_PeElementSurface.h @@ -0,0 +1,187 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiEffects_PeElementSurface.h +* @brief This is the header file for the ElementSurface class +*/ + +#ifndef _FUI_EFFECTS_INTERNAL_PE_ELEMENTSURFACE_H_ +#define _FUI_EFFECTS_INTERNAL_PE_ELEMENTSURFACE_H_ + +#include +#include "FUiEffects_RuntimeModel.h" +#include "FUiEffects_RuntimePropertyCast.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ + +/** + * @class ElementSurface + * @brief Abstract class for all physics model elements + * + * @since 2.0 + * + */ +class ElementSurface +{ +public: + /** + * Class constructor + * + * @since 2.0 + * + * @param[in] objId physical element's id. Must be unique for all objects + * + */ + ElementSurface(long objId); + + /** + * Class destructor + * + * @since 2.0 + * + */ + virtual ~ElementSurface(void); + + /** + * Sets object into the initial state + * + * @since 2.0 + * + */ + virtual void Initialize(void) = 0; + + /** + * Performs calculation step with given delta time + * + * @since 2.0 + * + * @param[in] timeStep simulation time step + * + */ + virtual void Calculate(float timeStep) = 0; + + /** + * Gets object's id + * + * @since 2.0 + * + * @return object's id + * + */ + long GetId(void) const; + + /** + * Gets object's type + * + * @since 2.0 + * + * @return enum value that corresponds to object's type + * + */ + virtual Tizen::Ui::Effects::_Runtime::ESurface GetType(void) const = 0; + + /** + * Gets element property value + * + * @since 2.0 + * + * @return struct that contains property type and value + * @param[in] property enum value for necessary property + * + */ + virtual Tizen::Ui::Effects::_Runtime::PropertyCast GetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property + ) const; + + /** + * Sets element bool property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] boolValue new bool value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + bool boolValue + ); + + /** + * Sets element numeric property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] numericValue new numeric value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + LUA_NUMBER numericValue + ); + + /** + * Sets element vector property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] vectorValue new vector value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + const Tizen::Ui::Effects::_Utils::Vec3f &vectorValue + ); + +protected: + /** + * Hidden copy constructor + * + * @since 2.0 + * + */ + ElementSurface(const ElementSurface &rhs) : __objId(0) + { } + +private: + /** + * Hidden assignment operator + * + * @since 2.0 + * + */ + ElementSurface& operator=(const ElementSurface &rhs) ; + +public: + +protected: + +private: + // object's id + const long __objId; + +}; // ElementSurface + +} } } } // Tizen::Ui::Effects::_PhysicsEngine + +#endif // _FUI_EFFECTS_INTERNAL_PE_ELEMENTSURFACE_H_ diff --git a/src/ui/effects/inc/FUiEffects_PePointSurface.h b/src/ui/effects/inc/FUiEffects_PePointSurface.h new file mode 100644 index 0000000..8871746 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_PePointSurface.h @@ -0,0 +1,264 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiEffects_PePointSurface.h +* @brief This is the header file for the pointSurface class +*/ + +#ifndef _FUI_EFFECTS_INTERNAL_PE_POINTSURFACE_H_ +#define _FUI_EFFECTS_INTERNAL_PE_POINTSURFACE_H_ +#pragma once + +#include "FUiEffects_PeElementSurface.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ + +/** + * @class PointSurface + * @brief Class for physical element: point(node) + * + * @since 2.0 + * + */ +class PointSurface + : public ElementSurface +{ + +// Member functions + +public: + /** + * PointSurface class constructor + * + * @since 2.0 + * + * @param[in] objId physical element's id + * @param[in] positionInit point initial position + * @param[in] massInit point initial mass + * @param[in] fixed point fixation setting + * + */ + PointSurface( + long objId, + Tizen::Ui::Effects::_Utils::Vec3f& positionInit, + float massInit, + float pointEnvResist, + bool fixed + ); + + /** + * Class destructor + * + * @since 2.0 + * + */ + virtual ~PointSurface(void); + + /** + * Gets object's type + * + * @since 2.0 + * + * @return enum value that corresponds to object's type + * + */ + virtual Tizen::Ui::Effects::_Runtime::ESurface GetType(void) const; + + /** + * Sets object into the initial state + * + * @since 2.0 + * + */ + virtual void Initialize(void); + + /** + * Binds point with model parameters + * + * @since 2.0 + * + * @return binding result, successful - true, failed - false + * @exception E_SYSTEM One of pointers (pEnvResist, pGravAcc, pGroundLevel) is null + * @param[in] pEnvResist pointer to environmental resistance value + * @param[in] pGravAcc pointer to gravity acceleration vector + * @param[in] pGroundLevel pointer to model ground level value + * + */ + virtual bool Construct( + const float* pEnvResist, + const Tizen::Ui::Effects::_Utils::Vec3f* pGravAcc, + const float* pGroundLevel + ); + + /** + * Performs simulation step with given delta time + * + * @since 2.0 + * + * @param[in] timeStep simulation time step + * + */ + virtual void Calculate(float timeStep); + + /** + * Gives info on whether the point is fixed + * + * @since 2.0 + * + * @return fixed point returns true, non fixed - false + * + */ + bool IsFixed(void) const; + + /** + * Gets element property value + * + * @since 2.0 + * + * @return struct that contains property type and value + * @param[in] property enum value for necessary property + * + */ + virtual Tizen::Ui::Effects::_Runtime::PropertyCast GetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property + ) const; + + /** + * Sets element bool property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] boolValue new bool value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + bool boolValue + ); + + /** + * Sets element numeric property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] numericValue new numeric value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + LUA_NUMBER numericValue + ); + + /** + * Sets element vector property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] vectorValue new vector value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + const Tizen::Ui::Effects::_Utils::Vec3f& vectorValue + ); + + /** + * Gets current position of the point + * + * @since 2.0 + * + * @return vector value - current position + * + */ + const Tizen::Ui::Effects::_Utils::Vec3f& GetPosition(void) const; + + /** + * Gets current velocity of the point + * + * @since 2.0 + * + * @return vector value - current velocity + * + */ + const Tizen::Ui::Effects::_Utils::Vec3f& GetVelocity(void) const; + + /** + * Adds force vector to point on current timestep + * + * @since 2.0 + * + * @param[in] appliedForce vector of force applied + * + */ + void AddForce(Tizen::Ui::Effects::_Utils::Vec3f appliedForce); + + /** + * Adds velocity vector to point on current timestep + * + * @since 2.0 + * + * @param[in] newVelocity vector of velocity added + * + */ + void AddVelocity(Tizen::Ui::Effects::_Utils::Vec3f newVelocity); + +protected: + +private: + // internal initialize function + void InitPoint(void); + +public: + +protected: + +private: + // initial values + const Tizen::Ui::Effects::_Utils::Vec3f __positionInit; + const float __massInit; + + // simulation values + Tizen::Ui::Effects::_Utils::Vec3f __position; + Tizen::Ui::Effects::_Utils::Vec3f __positionPrev; + Tizen::Ui::Effects::_Utils::Vec3f __velocity; + + Tizen::Ui::Effects::_Utils::Vec3f __force; + Tizen::Ui::Effects::_Utils::Vec3f __forceUser; + + float __mass; + float __pointEnvResist; + + // simulation values from model + const float *__pEnvResist; + const Tizen::Ui::Effects::_Utils::Vec3f *__pGravityAcc; + + const float *__pGroundLevel; + + bool __fixed; + +}; // PointSurface + +} } } } // Tizen::Ui::Effects::_PhysicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_PE_POINTSURFACE_H_ diff --git a/src/ui/effects/inc/FUiEffects_PePointSurfaceNURBS.h b/src/ui/effects/inc/FUiEffects_PePointSurfaceNURBS.h new file mode 100644 index 0000000..6204ac0 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_PePointSurfaceNURBS.h @@ -0,0 +1,234 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiEffects_PePointSurfaceNURBS.h +* @brief This is the header file for the PointSurfaceNurbs class +*/ + +#ifndef _FUI_EFFECTS_INTERNAL_PE_POINTSURFACENURBS_H_ +#define _FUI_EFFECTS_INTERNAL_PE_POINTSURFACENURBS_H_ +#pragma once + +#include "FUiEffects_PePointSurface.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ + +/** + * @class PointSurfaceNURBS + * @brief Class for graphical element: nurbs point + * + * @since 2.0 + * + */ +class PointSurfaceNurbs + : public PointSurface +{ + +public: + + /** + * PointSurfaceNURBS class constructor + * + * simce 3.0 + * + * @param[in] objId physical element's id + * @param[in] positionInit point initial position + * @param[in] massInit point initial mass + * @param[in] weightInit NURBS initial weight + * @param[in] fixed point fixation setting + * @param[in] row row number in grid + * @param[in] col column number in grid + * + */ + PointSurfaceNurbs( + long objId, + Tizen::Ui::Effects::_Utils::Vec3f positionInit, + float massInit, + float pointEnvResist, + float weightInit, + bool fixed, + unsigned int row, + unsigned int col + ); + + /** + * Class destructor + * + * @since 2.0 + * + */ + virtual ~PointSurfaceNurbs(); + + /** + * Gets object's type + * + * @since 2.0 + * + * @return enum value that corresponds to object's type + * + */ + virtual Tizen::Ui::Effects::_Runtime::ESurface GetType(void) const; + + /** + * Sets object into the initial state + * + * @since 2.0 + * + */ + virtual void Initialize(void); + + /** + * Binds point with model parameters + * + * @since 2.0 + * + * @return binding result, successful - true, failed - false + * @param[in] pEnvResist pointer to environmental resistance value + * @param[in] pGravAcc pointer to gravity acceleration vector + * @param[in] pGroundLevel pointer to model ground level value + * + */ + virtual bool Construct( + const float* pEnvResist, + const Tizen::Ui::Effects::_Utils::Vec3f* pGravAcc, + const float* pGroundLevel + ); + + /** + * Performs simulation step with given delta time + * + * @since 2.0 + * + * @param[in] timeStep simulation time step + * + */ + virtual void Calculate(float timeStep); + + /** + * Gets element property value + * + * @since 2.0 + * + * @return struct that contains property type and value + * @param[in] property enum value for necessary property + * + */ + virtual Tizen::Ui::Effects::_Runtime::PropertyCast GetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property + ) const; + + /** + * Sets element bool property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] boolValue new bool value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + bool boolValue + ); + + /** + * Sets element numeric property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] numericValue new numeric value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + LUA_NUMBER numericValue + ); + + /** + * Sets element vector property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] vectorValue new vector value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + const Tizen::Ui::Effects::_Utils::Vec3f & vectorValue + ); + + /** + * Gets NURBS weight + * + * @since 2.0 + * + * @return NURBS weight value + * + */ + float GetWeight(void) const; + + /** + * Gets grid row which contains this point + * + * @since 2.0 + * + * @return grid row number + * + */ + unsigned int GetRow(void) const; + + /** + * Gets grid column which contains this point + * + * @since 2.0 + * + * @return grid column number + * + */ + unsigned int GetCol(void) const; + +protected: + +private: + // internal initialize function + void InitPointNurbs(void); + +public: + +protected: + +private: + // initial values + const float __nurbsWeightInit; + + // current simulation values + float __nurbsWeight; + + unsigned int __row; + unsigned int __col; + +}; // PointSurfaceNURBS + +} } } } // Tizen::Ui::Effects::_PhysicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_PE_POINTSURFACENURBS_H_ diff --git a/src/ui/effects/inc/FUiEffects_PeRodSurface.h b/src/ui/effects/inc/FUiEffects_PeRodSurface.h new file mode 100644 index 0000000..d17f47d --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_PeRodSurface.h @@ -0,0 +1,191 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiEffects_PeRodSurface.h +* @brief This is the header file for the RodSurface class +*/ + +#ifndef _FUI_EFFECTS_INTERNAL_PE_RODSURFACE_H_ +#define _FUI_EFFECTS_INTERNAL_PE_RODSURFACE_H_ +#pragma once + +#include "FUiEffects_PeElementSurface.h" +#include "FUiEffects_PePointSurface.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ + +/** + * @class RodSurface + * @brief Class for physical element: rod + * + * @since 2.0 + * + */ +class RodSurface + : public ElementSurface +{ + +public: + /** + * RodSurface class constructor + * + * @since 2.0 + * + * @param[in] objId physical element's id + * @param[in] stiffness rod coefficient of rigidity + * @param[in] pPoint1 pointer to connected point 1 (edge) + * @param[in] pPoint2 pointer to connected point 2 (center) + * @param[in] pPoint3 pointer to connected point 3 (edge) + * + */ + RodSurface( + long objId, + float stiffness, + PointSurface* pPoint1, + PointSurface* pPoint2, + PointSurface* pPoint3 + ); + + /** + * Class destructor + * + * @since 2.0 + * + */ + virtual ~RodSurface(void); + + /** + * Gets object's type + * + * @since 2.0 + * + * @return enum value that corresponds to object's type + * + */ + virtual Tizen::Ui::Effects::_Runtime::ESurface GetType(void) const; + + /** + * Sets object into the initial state + * + * @since 2.0 + * + */ + virtual void Initialize(void); + + /** + * Performs simulation step with given delta time + * + * @since 2.0 + * + * @param[in] timeStep simulation time step + * + */ + virtual void Calculate(float timeStep); + + /** + * Gets element property value + * + * @since 2.0 + * + * @return struct that contains property type and value + * @param[in] property enum value for necessary property + * + */ + virtual Tizen::Ui::Effects::_Runtime::PropertyCast GetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property + ) const; + + /** + * Sets element bool property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] boolValue new bool value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + bool boolValue + ); + + /** + * Sets element numeric property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] numericValue new numeric value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + LUA_NUMBER numericValue + ); + + /** + * Sets element vector property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] vectorValue new vector value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + const Tizen::Ui::Effects::_Utils::Vec3f & vectorValue + ); + +protected: + +private: + // internal init method + void InitRod(void); + + // internal calculate methods + // (may implement different models) + void UseStretchModel(float timeStep); + void UseUnbendModel(float timeStep); + +public: + +protected: + // points that are connected by rod + PointSurface* _pPoint1; // edge point 1 + PointSurface* _pPoint2; // center point + PointSurface* _pPoint3; // edge point 2 + + float _deformationAngle; + +private: + // initial values + const float __stiffnessInit; // Initial rod coefficient of rigidity + + // simulation values + float __stiffness; // Rod coefficient of rigidity + + +}; // RodSurface + +} } } } // Tizen::Ui::Effects::_PhysicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_PE_RODSURFACE_H_ diff --git a/src/ui/effects/inc/FUiEffects_PeRodSurfaceNURBS.h b/src/ui/effects/inc/FUiEffects_PeRodSurfaceNURBS.h new file mode 100644 index 0000000..5f35818 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_PeRodSurfaceNURBS.h @@ -0,0 +1,179 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiEffects_PeRodSurfaceNURBS.h +* @brief This is the header file for the ElementSurface class +*/ + +#ifndef _FUI_EFFECTS_INTERNAL_PE_RODSURFACENURBS_H_ +#define _FUI_EFFECTS_INTERNAL_PE_RODSURFACENURBS_H_ +#pragma once + +#include "FUiEffects_PePointSurfaceNURBS.h" +#include "FUiEffects_PeRodSurface.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ + +/** + * @class RodSurfaceNURBS + * @brief Class for graphical element: nurbs rod (for regular grid) + * + * @since 2.0 + * + */ +class RodSurfaceNurbs + : public RodSurface +{ + +public: + /** + * RodSurfaceNURBS class constructor + * + * @since 2.0 + * + * @param [in] objId physical element's id + * @param [in] stiffness rod coefficient of rigidity + * @param [in] pPoint1 pointer to connected point 1 (edge) + * @param [in] pPoint2 pointer to connected point 2 (center) + * @param [in] pPoint3 pointer to connected point 3 (edge) + * @param [in] pPointN pointer to neighbor point + * + */ + RodSurfaceNurbs( + long objId, + float stiffness, + PointSurfaceNurbs* pPoint1, + PointSurfaceNurbs* pPoint2, + PointSurfaceNurbs* pPoint3, + PointSurfaceNurbs* pPointN + ); + + /** + * Class destructor + * + * @since 2.0 + * + */ + virtual ~RodSurfaceNurbs(void); + + /** + * Gets object's type + * @return enum value that corresponds to object's type + * + * @since 2.0 + * + */ + virtual Tizen::Ui::Effects::_Runtime::ESurface GetType(void) const; + + /** + * Sets object into the initial state + * + * @since 2.0 + * + */ + virtual void Initialize(void); + + /** + * Performs simulation step with given delta time + * @param [in] timeStep simulation time step + * + * @since 2.0 + * + */ + virtual void Calculate(float timeStep); + + /** + * Gets element property value + * + * @since 2.0 + * + * @return struct that contains property type and value + * @param [in] property enum value for necessary property + * + */ + virtual Tizen::Ui::Effects::_Runtime::PropertyCast GetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property + ) const; + + /** + * Sets element bool property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param [in] property property name + * @param [in] boolValue new bool value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + bool boolValue + ); + + /** + * Sets element numeric property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param [in] property property name + * @param [in] numericValue new numeric value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + LUA_NUMBER numericValue + ); + + /** + * Sets element vector property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param [in] property property name + * @param [in] vectorValue new vector value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + const Tizen::Ui::Effects::_Utils::Vec3f& vectorValue + ); + +protected: + +private: + // internal init method + void InitRodNurbs(void); + + // method to get approximate normal to surface at middle point + const Tizen::Ui::Effects::_Utils::Vec3f GetSurfaceNormal(void) const; + +public: + +protected: + +private: + // neighbor point + PointSurfaceNurbs* __pPointNeighb; + +}; // RodSurfaceNURBS + +} } } }//Tizen::Ui::Ext::Effects3d::_PhysicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_PE_RODSURFACENURBS_H_ diff --git a/src/ui/effects/inc/FUiEffects_PeSpringSurface.h b/src/ui/effects/inc/FUiEffects_PeSpringSurface.h new file mode 100644 index 0000000..d0f7daf --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_PeSpringSurface.h @@ -0,0 +1,179 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiEffects_PeSpringSurface.h +* @brief This is the header file for the SpringSurface class +*/ + +#ifndef _FUI_EFFECTS_INTERNAL_PE_SPRINGSURFACE_H_ +#define _FUI_EFFECTS_INTERNAL_PE_SPRINGSURFACE_H_ +#pragma once + +#include "FUiEffects_PeElementSurface.h" +#include "FUiEffects_PePointSurface.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ + +/** + * @class SpringSurface + * @brief Class for physical element: spring + * + * @since 2.0 + * + */ +class SpringSurface + : public ElementSurface +{ + +public: + /** + * SpringSurface class constructor + * + * @since 2.0 + * + * @param[in] objId physical element's id + * @param[in] stiffness spring coefficient of rigidity + * @param[in] pPoint1 pointer to connected point 1 + * @param[in] pPoint2 pointer to connected point 2 + * + */ + SpringSurface( + long objId, + float stiffness, + PointSurface* pPoint1, + PointSurface* pPoint2 + ); + + /** + * Class destructor + * + * @since 2.0 + * + */ + virtual ~SpringSurface(void); + + /** + * @brief Gets object's type + * @return enum value that corresponds to object's type + * + */ + virtual Tizen::Ui::Effects::_Runtime::ESurface GetType(void) const; + + /** + * Sets object into the initial state + * + * @since 2.0 + * + */ + virtual void Initialize(void); + + /** + * Performs simulation step with given delta time + * + * @since 2.0 + * + * @param[in] timeStep simulation time step + * + */ + virtual void Calculate(float timeStep); + + /** + * Gets element property value + * + * @since 2.0 + * + * @return struct that contains property type and value + * @param[in] property enum value for necessary property + * + */ + virtual Tizen::Ui::Effects::_Runtime::PropertyCast GetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property + ) const; + + /** + * Sets element bool property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] boolValue new bool value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + bool boolValue + ); + + /** + * Sets element numeric property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] numericValue new numeric value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + LUA_NUMBER numericValue + ); + + /** + * Sets element vector property values + * + * @since 2.0 + * + * @return true if set successful, false if failed + * @param[in] property property name + * @param[in] vectorValue new vector value for property + * + */ + virtual bool SetProperty( + Tizen::Ui::Effects::_Runtime::ElementProperty property, + const Tizen::Ui::Effects::_Utils::Vec3f& vectorValue + ); + +protected: + +private: + // internal init method + void InitSpring(void); + +public: + +protected: + +private: + // initial values + const float __stiffnessInit; // Initial spring coefficient of rigidity + + // simulation values + float __restLength; // Length of the unstrained spring + float __stiffness; // Spring coefficient of rigidity + + // points that are connected by spring + PointSurface* __pPoint1; + PointSurface* __pPoint2; + +}; // SpringSurface + +} } } } // Tizen::Ui::Effects::_PhysicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_PE_SPRINGSURFACE_H_ diff --git a/src/ui/effects/inc/FUiEffects_Renderer.h b/src/ui/effects/inc/FUiEffects_Renderer.h new file mode 100644 index 0000000..116a848 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_Renderer.h @@ -0,0 +1,34 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiEffects_Renderer.h +* @brief This is the header file for the Tizen::Ui::Ext::Effects3d::_EffectRenderer namespace. +*/ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_H_ + +#include "FUiEffects_RendererDirectionalLight.h" +#include "FUiEffects_RendererEffectRenderer.h" +#include "FUiEffects_RendererEffectShader.h" +#include "FUiEffects_RendererMemoryTexture2DProperty.h" +#include "FUiEffects_RendererRendererGeometry.h" +#include "FUiEffects_RendererRendererObject.h" +#include "FUiEffects_RendererLog.h" +#include "FUiEffects_RendererViewport.h" + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_H_ diff --git a/src/ui/effects/inc/FUiEffects_RendererDirectionalLight.h b/src/ui/effects/inc/FUiEffects_RendererDirectionalLight.h new file mode 100644 index 0000000..d140878 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RendererDirectionalLight.h @@ -0,0 +1,195 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RendererDirectionalLight.h + * @brief This is the header file for the DirectionalLight class + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_DIRECTIONALLIGHT_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_DIRECTIONALLIGHT_H_ + +#include + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +/** + * @class DirectionalLight + * @brief This class contains data for directional light in scene + * + */ +class DirectionalLight +{ +public: + + /** + * Constructor + * + * @remark Sets default values for members + */ + DirectionalLight(void) + { + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __direction = EngineModel::Vector3fPropertyHolderPtr(new (std::nothrow) EngineModel::Vector3fPropertyHolder); + __colorI = EngineModel::Vector3fPropertyHolderPtr(new (std::nothrow) EngineModel::Vector3fPropertyHolder); + + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__direction) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__colorI) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __direction->Set(Math::Vector3f(0.f, 0.f, -1.f)); + __color.set(1.f, 0.f, 0.f); + __intensity = 1.f; + __enabled = true; + + UpdateColorI(); + } + + /** + * Sets direction vector property + * + * @param [in] direction New direction vector + * + * @return void + */ + void SetDirection(const Tizen::Ui::Effects::_Utils::Vec3f& direction) + { + __direction->Set(Math::Vector3f(direction.x, direction.y, direction.z).Normalize()); + + return; + } + + /** + * Sets color property + * + * @param [in] color New color value + * + * @return void + */ + void SetColor(const Tizen::Ui::Effects::_Utils::Vec3f& color) + { + __color = color; + UpdateColorI(); + + return; + } + + /** + * Sets intensity property + * + * @param [in] intensity New intensity value + * + * @return void + */ + void SetIntensity(float intensity) + { + __intensity = intensity; + UpdateColorI(); + + return; + } + + /** + * Sets enabled value + * + * @param [in] enabled New enabled value + * + * @return void + */ + void SetEnabled(bool enabled) + { + __enabled = enabled; + + return; + } + + /** + * Gets direction vector property + * + * @return direction vector property + */ + EngineModel::Vector3fPropertyHolderPtr GetDirectionHolder(void) const + { + return __direction; + } + + /** + * Gets color*intensity value property + * + * @return color*intensity value property + */ + EngineModel::Vector3fPropertyHolderPtr GetColorIHolder(void) const + { + return __colorI; + } + + /** + * Gets enabled value + * + * @return enabled value + */ + bool GetEnabled(void) const + { + return __enabled; + } + +private: + + /** + * Hidden copy constructor + */ + DirectionalLight(const DirectionalLight &rhs); + + + /** + * Hidden assignment operator + */ + DirectionalLight& operator=(const DirectionalLight &rhs); + + /** + * Sets colorI property which is premultiplied color x intensity for use in shader + * + * @return void + */ + void UpdateColorI(void) + { + __colorI->Set(__color.x * __intensity, __color.y * __intensity, __color.z * __intensity); + + return; + } + +private: + _Utils::Vec3f __color; + float __intensity; + bool __enabled; + + EngineModel::Vector3fPropertyHolderPtr __direction; + EngineModel::Vector3fPropertyHolderPtr __colorI; /**< __color x __intensity */ +}; // DirectionalLight + +typedef System::SmartPtr DirectionalLightPtr; + +} } } } // Tizen::Ui::Effects::_EffectRenderer + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_DIRECTIONALLIGHT_H_ diff --git a/src/ui/effects/inc/FUiEffects_RendererEffectRenderer.h b/src/ui/effects/inc/FUiEffects_RendererEffectRenderer.h new file mode 100644 index 0000000..5493ae8 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RendererEffectRenderer.h @@ -0,0 +1,380 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RendererEffectRenderer.h + * @brief This is the header file for the EffectRenderer class + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_EFFECTRENDERER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_EFFECTRENDERER_H_ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "FUiEffects_RendererViewport.h" +#include "FUiEffects_RuntimeRenderDataScene.h" +#include "FUiEffects_RendererRendererObject.h" +#include "FUiEffects_RendererPointLight.h" +#include "FUiEffects_RendererSpotLight.h" +#include "FUiEffects_RendererDirectionalLight.h" +#include "FUiEffects_RendererLightingParameters.h" +#include "FUiEffects_RendererMemoryTexture2DProperty.h" + +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +extern const EGLint RENDERER_EGL_DEFAULT_CONFIG_ATTRIBS[]; + +/** + * @class EffectRenderer + * @brief This class for model visualization + * + */ +class EffectRenderer +{ +public: + + /** + * Constructor + */ + EffectRenderer(void); + + /** + * Destructor + */ + ~EffectRenderer(void); + + /** + * Initializes OpenGL for this device + * + * @param [in] config Specifies attributes required to match by configs + * @return bool true on success, otherwise false + */ + static bool InitOpenGL(const EGLint* pConfig = RENDERER_EGL_DEFAULT_CONFIG_ATTRIBS); + + /** + * Closes OpenGL for this device + * + * @return void + */ + static void CloseOpenGL(void); + + /** + * OpenGL status + * + * @return bool true on success, otherwise false + */ + static bool CheckOpenGlesInitialized(void); + + /** + * Creates OpenGL surface + * + * @param [in] wnd Specifies the native window + * @return EGLSurface Result of eglCreateWindowSurface (EGL_NO_SURFACE if failed) + */ + static EGLSurface CreateSurface(EGLNativeWindowType wnd); + + /** + * Deletes OpenGL surface + * + * @param [in] surface Surface to delete + * @return void + */ + static void DeleteSurface(EGLSurface surface); + + /** + * Creates OpenGL context + * + * @param [in] ShareContext Sharable context + * @return EGLContext Result of eglCreateContext (EGL_NO_CONTEXT if failed) + */ + static EGLContext CreateContext(EGLContext shareContext = EGL_NO_CONTEXT); + + /** + * Deletes OpenGL context + * + * @param [in] context Surface to delete + * @return void + */ + static void DeleteContext(EGLContext context); + + /** + * Initializes renderer from data: scene graph, objects etc. Clears previous content. + * + * @param [in] _renderDataCollection Array of data pointers + * @return void + * + * @remark It saves pointer to EffectRenderer::renderDataCollection for further updates (see EffectRenderer::Update). @n + * @remark So it's assumed that content of _renderDataCollection (pointers values and their order in array) @n + * @remark is constant through all the life cycle of the renderer + */ + void Construct(Tizen::Ui::Effects::_Runtime::RenderDataScene &renderDataCollection); + + /** + * Updates renderer objects + * + * @return void + * + * @remark The source for updates is EffectRenderer::renderDataCollection. See comments for EffectRenderer::Construct + */ + void Update(void); + + /** + * Initialize OpenGL context state (Clear color etc) + * + * @return void + */ + void InitializeContext(void) const; + + /** + * Draw scene + * + * @return void + */ + void Draw(void); + + /** + * Sets borders of visible scene (in model (world) space) for coordinates calculation + * + * @param [in] worldLeft, worldRight, worldBottom, worldTop - coordinates of world sides related to screen + * @param [in] worldZ - Z level of screen viewport + * @param [in] worldNearDist, worldFarDist - distances to camera clipping planes in world coordinates + * @param [in] FOV_Y_deg - Full angle, in degrees, in the vertical direction + * @param [in] perspectiveProjection - true = use perspective projection, false = use orthographic projection + * + * @return bool true on valid arguments and success execution + * @see SetScreen + */ + bool SetWorld(float worldLeft, float worldRight, float worldBottom, float worldTop, float worldZ, float worldNearDist, float worldFarDist, float FOV_Y_deg, bool perspectiveProjection); + + /** + * Transforms window coordinates to model space + * + * @param [in] p point on screen + * + * @return Vec3f Point in model space + * @see SetScreen, SetWorld + */ + Tizen::Ui::Effects::_Utils::Vec3f TransformScreenToWorld(Tizen::Ui::Effects::_Utils::Vec2f p) const; + + /** + * Sets image for texture + * + * @param [in] bitmapID id of image + * @param [in] bitmap Image bitmap + * + * @return bool True on success, otherwise false + */ + bool SetBitmap(long bitmapID, Tizen::Graphics::Bitmap &bitmap); + + /** + * Sets image for texture + * + * @param [in] ptr pointer to bitmap data + * @param [in] width width in pixels + * @param [in] height height in pixels + * + * @return bool True on success, otherwise false + * + * @remark If ptr = null empty texture of width*height size will be allocated in memory for faster response on next call to this method + */ + bool SetBitmap(long bitmapID, const void* ptr, size_t width, size_t height); + + /** + * Sets borders of native screen (in pixels) for coordinates calculation + * + * @return void + */ + void SetScreen(const Tizen::Ui::Control& control); + + /** + * Tracks screen size changes + * + * @return void + */ + void TrackScreenSizeChanges(const Tizen::Ui::Control& control); + + /** + * Prebuild OpenGL data caches for fast response on Draw() method + * + * @return void + */ + void BuildCache(); + + /** + * Frees OpenGL related data + * + * @return void + */ + void ReleaseCache(); + +private: + + /** + * Hidden copy constructor + */ + EffectRenderer(const EffectRenderer &rhs); + + /** + * Hidden assignment operator + */ + EffectRenderer& operator=(const EffectRenderer &rhs); + + /** + * Initializes renderer lighting data: point, spot and directional lights, ambient parameters, etc. + * + * @param [in] _renderDataCollection Array of data pointers + * @return void + * + * @remark It saves pointer to EffectRenderer::renderDataCollection for further updates (see EffectRenderer::Update). @n + * @remark So it's assumed that content of _renderDataCollection (pointers values and their order in array) @n + * @remark is constant through all the life cycle of the renderer + */ + void ConstructLighting(void); + + /** + * Updates scene lighting + * + * @return void + */ + void UpdateLighting(void); + + /** + * Initializes renderer object from given data + * + * @param [in] index object index in EffectRenderer::objects + * @param [in] rdata Data for initialization + * @return void + * + * @remark This method is for internal use only + */ + void InitRObjectFromData(Tizen::Ui::Effects::_Runtime::RenderDataSurfaceCollection::size_type index, Tizen::Ui::Effects::_Runtime::RenderDataSurface &rdata); + + /** + * Updates renderer object + * + * @param [in] index object index in EffectRenderer::objects + * @param [in] rdata Data for update + * @return void + * + * @remark This method is for internal use only + */ + void UpdateRObject(Tizen::Ui::Effects::_Runtime::RenderDataSurfaceCollection::size_type index, Tizen::Ui::Effects::_Runtime::RenderDataSurface &rdata); + + /** + * Looks for texture in EffectRenderer::textures by its id. + * + * @param [in] bitmapID ID of texture + * @return MemoryTexture2DPropertyPtr Texture object + * + * @remark If ID not found method creates and returns empty texture for further usage filled with some noticeable color (violet [255 0 128]) + */ + MemoryTexture2DPropertyPtr FindTexture(long bitmapID); + + /** + * Sets borders of native screen (in pixels) for coordinates calculation + * + * @param [in] screenLeft, screenRight, screenBottom, screenTop - coordinates of screen sides in pixels. @n + * Used for screen-to-world transformation in touch events handlers. For example commonly screenTop = 0, screenBottom = window height + * + * @return void + */ + void SetScreen(float screenLeft, float screenRight, float screenBottom, float screenTop, int displayWidth, int displayHeight); + + /** + * (Re)Creates shader considering scene lighting parameters and count of different light types + * + * @return void + */ + void CreateShader(); + + /** + * Makes this renderer context current + * + * @return void + */ + void MakeCurrent(void); + + /** + * Restores initial OpenGL context saved in MakeCurrent method + * + * @return void + */ + void RestorePreviousContext(void); + +public: + + EGLSurface surface; /**< OpenGL surface */ + +private: + typedef std::map TexturesMap; + typedef std::map PointLightsList; + typedef std::map SpotLightsList; + typedef std::map DirectionalLightsList; + + static EGLDisplay __eglDisplay; + static EGLConfig __eglConfig; + static EGLint __glMajorVer; + static EGLint __glMinorVer; + static bool __OpenGLInitialized; + EGLContext __context, __previousContext; + bool __previousContextSaved; + Viewport __viewport; + float __FOV_Y_deg; + bool __perspectiveProjection; + + TexturesMap __textures; + std::vector __objects; + Tizen::Ui::Effects::_Runtime::RenderDataScene* __renderDataScene; + Tizen::Ui::Effects::_Runtime::RenderDataSurfaceCollection* __pRenderDataSurfaceCollection; + + // 3DFx + GraphicsEngine::RenderPtr __renderer; + EngineModel::GroupPtr __root; + EngineModel::CameraPtr __camera; + EngineModel::ShaderHolderProgramPropertyPtr __program; + + Tizen::Graphics::Dimension __dimensionPreviousControl; + + // Lighting + LightingParameters __lightingParameters; + PointLightsList __pointLights; + SpotLightsList __spotLights; + DirectionalLightsList __directionalLights; + + +}; // EffectRenderer + +typedef std::unique_ptr EffectRendererUniquePtr; + +} } } } // Tizen::Ui::Effects::_EffectRenderer + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_EFFECTRENDERER_H_ diff --git a/src/ui/effects/inc/FUiEffects_RendererEffectShader.h b/src/ui/effects/inc/FUiEffects_RendererEffectShader.h new file mode 100644 index 0000000..75e99ce --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RendererEffectShader.h @@ -0,0 +1,124 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RendererEffectShader.h + * @brief This is the header file for the effects library shaders + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_EFFECTSHADER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_EFFECTSHADER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +#ifdef _DEBUG +#define PRINT_DEBUG(name, str) printstring(name, str) +#else +#define PRINT_DEBUG(name, str) +#endif + +/** + * Replaces all occurrences of string "what" in "str" with new string "with" + * + * @return void + */ +void replace(std::string &str, const std::string what, const std::string with); + +/** + * Prints string "str" to log output line by line. Each line is prefixed with "name" @n + * Works only in debug mode + * + * @return void + */ +void printstring(const std::string name, const std::string &str); + +#define SHADER_IN_POSITION_STR "in_Position" +#define SHADER_IN_NORMAL_STR "in_Normal" +#define SHADER_IN_TEXCOORDS_STR "in_TexCoords" +#define MAIN_TEX_STR "TEX_MAIN" + +#define LIGHTING_AMBIENTCOLORI_STR "lightingParameters.ambientColorI" +#define LIGHTING_ATTENUATION_STR "lightingParameters.attenuation" + +#define POINTLIGHT_DEFPOS_STR "/*POINTL DEF*/ \n" +#define POINTLIGHT_SRCPOS_STR "/*POINTL SRC*/ \n" +#define POINTLIGHT_DEF_STR "uniform PointLight pointLight%n;\n" +#define POINTLIGHT_ATTSRC_STR " lightdir = pointLight%n.position - Position; \n" \ + " att = 1.0 - length(lightdir) * pointLight%n.Rk; \n" \ + " if(att > 0.0) \n" \ + " color += pointLight%n.colorI * max(0.0, dot(normalize(lightdir), normal)) * att; \n" \ + " \n" +#define POINTLIGHT_NOATTSRC_STR " color += pointLight%n.colorI * max(0.0, dot(normalize(pointLight%n.position - Position), normal)); \n" \ + " \n" +#define POINTLIGHT_STR "pointLight" +#define POINTLIGHT_POSITION_STR ".position" +#define POINTLIGHT_COLORI_STR ".colorI" +#define POINTLIGHT_RK_STR ".Rk" + + +#define SPOTLIGHT_DEFPOS_STR "/*SPOTL DEF*/ \n" +#define SPOTLIGHT_SRCPOS_STR "/*SPOTL SRC*/ \n" +#define SPOTLIGHT_DEF_STR "uniform SpotLight spotLight%n;\n" +#define SPOTLIGHT_ATTSRC_STR " lightdir = normalize(Position - spotLight%n.position); \n" \ + " att = min((dot(spotLight%n.direction, lightdir) - spotLight%n.k1) * spotLight%n.k2, 1.0) * (1.0 - length(Position - spotLight%n.position) * spotLight%n.Rk); \n" \ + " if(att > 0.0) \n" \ + " color += spotLight%n.colorI * att * max(0.0, dot(-lightdir, normal)); \n" \ + " \n" +#define SPOTLIGHT_NOATTSRC_STR " lightdir = normalize(Position - spotLight%n.position); \n" \ + " att = min((dot(spotLight%n.direction, lightdir) - spotLight%n.k1) * spotLight%n.k2, 1.0); \n" \ + " if(att > 0.0) \n" \ + " color += spotLight%n.colorI * att * max(0.0, dot(-lightdir, normal)); \n" \ + " \n" +#define SPOTLIGHT_STR "spotLight" +#define SPOTLIGHT_POSITION_STR ".position" +#define SPOTLIGHT_DIRECTION_STR ".direction" +#define SPOTLIGHT_K1_STR ".k1" +#define SPOTLIGHT_K2_STR ".k2" +#define SPOTLIGHT_COLORI_STR ".colorI" +#define SPOTLIGHT_RK_STR ".Rk" + + +#define DIRECTIOALLIGHT_DEFPOS_STR "/*DIRL DEF*/ \n" +#define DIRECTIOALLIGHT_SRCPOS_STR "/*DIRL SRC*/ \n" +#define DIRECTIOALLIGHT_DEF_STR "uniform DirectionalLight directionalLight%n;\n" +#define DIRECTIOALLIGHT_SRC_STR " color += directionalLight%n.colorI * max(0.0, dot(-directionalLight%n.direction, normal)); \n" \ + " \n" +#define DIRECTIOALLIGHT_STR "directionalLight" +#define DIRECTIOALLIGHT_DIRECTION_STR ".direction" +#define DIRECTIOALLIGHTLIGHT_COLORI_STR ".colorI" + +#define MODEL_MTR_STR "ModelMtr" +#define NORMAL_MTR_STR "NormalMtr" +#define OPACITY_STR "opacity" + +#define BLUR_WEIGHTS_N 20 + +extern const char* const EFFECT_VERTEX_SHADER_STR; +extern const char* const EFFECT_FRAGMENT_SHADER_STR; +extern const char* const EFFECT_DUMMY_FRAGMENT_SHADER_STR; + +extern const char* const BLUR_VS; +extern const char* const BLUR_HORIZ_FS; +extern const char* const BLUR_VERT_FS; + + + +} } } } // Tizen::Ui::Effects::_EffectRenderer + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_EFFECTSHADER_H_ diff --git a/src/ui/effects/inc/FUiEffects_RendererLightingParameters.h b/src/ui/effects/inc/FUiEffects_RendererLightingParameters.h new file mode 100644 index 0000000..6e64d16 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RendererLightingParameters.h @@ -0,0 +1,157 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RendererLightingParameters.h + * @brief This is the header file for the LightingParameters class + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_LIGHTINGPARAMETERS_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_LIGHTINGPARAMETERS_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +/** + * @class LightingParameters + * @brief This class contains data for ambient light in scene + * + */ +class LightingParameters +{ +public: + + /** + * Constructor + * + * @remark Sets default values for members + */ + LightingParameters(void) + { + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __ambientColorI = EngineModel::Vector3fPropertyHolderPtr(new (std::nothrow) EngineModel::Vector3fPropertyHolder); + __attenuation = System::FloatPtr(new (std::nothrow) float); + + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__ambientColorI) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__attenuation) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __ambientColor.set(1.f, 0.f, 0.f); + __ambientIntensity = 1.f; + *__attenuation = 0.08f; + + UpdateAmbientColorI(); + } + + /** + * Sets ambient color value + * + * @param [in] color New color ambient color value + * + * @return void + */ + void SetAmbientColor(const Tizen::Ui::Effects::_Utils::Vec3f& ambientColor) + { + __ambientColor = ambientColor; + UpdateAmbientColorI(); + + return; + } + + /** + * Sets ambient intensity value + * + * @param [in] intensity New ambient intensity value + * + * @return void + */ + void SetAmbientIntensity(float ambientIntensity) + { + __ambientIntensity = ambientIntensity; + UpdateAmbientColorI(); + + return; + } + + void SetAttenuation(float attenuation) + { + *__attenuation = attenuation; + + return; + } + + /** + * Gets ambient color*intensity value property + * + * @return ambient color*intensity value property + */ + EngineModel::Vector3fPropertyHolderPtr GetAmbientColorIHolder(void) const + { + return __ambientColorI; + } + + System::FloatPtr GetAttenuation(void) const + { + return __attenuation; + } + +private: + + /** + * Hidden copy constructor + */ + LightingParameters(const LightingParameters &rhs); + + + /** + * Hidden assignment operator + */ + LightingParameters& operator=(const LightingParameters &rhs); + + /** + * Sets ambient colorI property which is premultiplied color x intensity for use in shader + * + * @return void + */ + void UpdateAmbientColorI(void) + { + __ambientColorI->Set(__ambientColor.x * __ambientIntensity, __ambientColor.y * __ambientIntensity, __ambientColor.z * __ambientIntensity); + + return; + } + +private: + _Utils::Vec3f __ambientColor; + float __ambientIntensity; + + EngineModel::Vector3fPropertyHolderPtr __ambientColorI; /**< __ambientColor * __ambientIntensity */ + System::FloatPtr __attenuation; +}; // LightingParameters + +typedef System::SmartPtr LightingParametersPtr; + +} } } } // Tizen::Ui::Effects::_EffectRenderer + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_LIGHTINGPARAMETERS_H_ diff --git a/src/ui/effects/inc/FUiEffects_RendererLog.h b/src/ui/effects/inc/FUiEffects_RendererLog.h new file mode 100644 index 0000000..23e4f08 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RendererLog.h @@ -0,0 +1,67 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererLog.h + * @brief This is the header file for renderer logging definitions + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_LOG_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_LOG_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +/** + * Checks whether there was EGL operation errors + * + * @return true on success othrwise false + */ +bool CheckEglNoErrors(void); + +/** + * Checks whether there was GL operation errors + * + * @return true on success othrwise false + */ +bool CheckGlNoErrors(void); + +#ifdef _DEBUG +#define EGL_ASSERT_NOERRORS \ + { \ + if (!CheckEglNoErrors()) \ + { \ + SysAssertf(false, "Execution stopped on CheckEglNoErrors fail"); \ + } \ + } + +#define GL_ASSERT_NOERRORS \ + { \ + if (!CheckGlNoErrors()) \ + { \ + SysLog(NID_UI_EFFECT, "%s::%d", __PRETTY_FUNCTION__, __LINE__);\ + SysAssertf(false, "Execution stopped on CheckGlNoErrors fail"); \ + } \ + } +#else // #ifdef _DEBUG +#define EGL_ASSERT_NOERRORS +#define GL_ASSERT_NOERRORS +#endif + +} } } } // Tizen::Ui::Effects::_EffectRenderer + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_LOG_H_*/ diff --git a/src/ui/effects/inc/FUiEffects_RendererMemoryTexture2DProperty.h b/src/ui/effects/inc/FUiEffects_RendererMemoryTexture2DProperty.h new file mode 100644 index 0000000..caa7f09 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RendererMemoryTexture2DProperty.h @@ -0,0 +1,161 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RendererMemoryTexture2DProperty.h + * @brief This is the header file for the MemoryTexture2DProperty class + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MEMORYTEXTURE2DPROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MEMORYTEXTURE2DPROPERTY_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +/** + * @class MemoryTexture2DProperty + * @brief This class for texture material property, constructed from bitmap located in memory. Only BGRA pixel format. + * + */ +class MemoryTexture2DProperty + : public EngineModel::Texture2dProperty +{ +public: + + /** + * Constructor + */ + MemoryTexture2DProperty(void); + + + /** + * Destructor + */ + ~MemoryTexture2DProperty(void); + + EngineModel::TextureProperty::InternalFormat::Value GetInternalFormat(void) const + { + return EngineModel::TextureProperty::InternalFormat::RGBA; + } + + EngineModel::TextureProperty::DataFormat::Value GetDataFormat(void) const + { + return EngineModel::TextureProperty::DataFormat::RGBA; + } + + EngineModel::TextureProperty::DataType::Value GetDataType(void) const + { + return EngineModel::TextureProperty::DataType::UNSIGNED_BYTE; + } + + EngineModel::TextureProperty::FilterType::Value GetMinFilter(void) const + { + return EngineModel::TextureProperty::FilterType::LINEAR; + } + + EngineModel::TextureProperty::FilterType::Value GetMagFilter(void) const + { + return EngineModel::TextureProperty::FilterType::LINEAR; + } + + EngineModel::TextureProperty::WrapType::Value GetWrapS(void) const + { + return EngineModel::TextureProperty::WrapType::CLAMP_TO_EDGE; + } + + EngineModel::TextureProperty::WrapType::Value GetWrapT(void) const + { + return EngineModel::TextureProperty::WrapType::CLAMP_TO_EDGE; + } + + EngineModel::TextureProperty::WrapType::Value GetWrapR(void) const + { + return EngineModel::TextureProperty::WrapType::CLAMP_TO_EDGE; + } + + size_t GetNumMipmaps(void) const + { + return 1; + } + + void* GetData(size_t aMipNumber) + { + return &__data[0]; + } + + size_t GetWidth(size_t aMipNumber) const + { + return __width; + } + + size_t GetHeight(size_t aMipNumber) const + { + return __height; + } + + bool GenerateMipmaps(void) const + { + return false; + } + + + /** + * Copies bitmap data from specified location + * + * @param [in] ptr Pointer to data location. BGRA format. + * @param [in] width Width in pixels + * @param [in] height Height in pixels + * + * @return void + */ + void SetData(const void* ptr, size_t width, size_t height); + +private: + + /** + * Hidden copy constructor + */ + MemoryTexture2DProperty(const MemoryTexture2DProperty &rhs); + + + /** + * Hidden assignment operator + */ + MemoryTexture2DProperty& operator =(const MemoryTexture2DProperty &rhs); + + + /** + * Gets count of bytes per pixel for current format + * + * @return int Count of bytes per pixel + */ + int GetFormatSize(void); + +private: + System::Data __data; + size_t __width; + size_t __height; +}; + +typedef System::SmartPtr MemoryTexture2DPropertyPtr; + +} } } } // Tizen::Ui::Effects::_EffectRenderer + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MEMORYTEXTURE2DPROPERTY_H_ diff --git a/src/ui/effects/inc/FUiEffects_RendererPointLight.h b/src/ui/effects/inc/FUiEffects_RendererPointLight.h new file mode 100644 index 0000000..0540b69 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RendererPointLight.h @@ -0,0 +1,256 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RendererPointLight.h + * @brief This is the header file for the PointLight class + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_POINTLIGHT_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_POINTLIGHT_H_ + +#include + +#include + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +/** + * @class PointLight + * @brief This class contains data for point light in scene + * + */ +class PointLight +{ +public: + + /** + * Constructor + * + * @param [in] attenuation Global attenuation pointer + * + * @remark Sets default values for members + */ + PointLight(System::FloatPtr attenuation) + { + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(attenuation) != null, E_INVALID_ARG, "[E_INVALID_ARG] PointLight attenuation equals null"); + + __position = EngineModel::Vector3fPropertyHolderPtr(new (std::nothrow) EngineModel::Vector3fPropertyHolder); + __colorI = EngineModel::Vector3fPropertyHolderPtr(new (std::nothrow) EngineModel::Vector3fPropertyHolder); + __Rk = EngineModel::FloatPropertyHolderPtr(new (std::nothrow) EngineModel::FloatPropertyHolder); + + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__position) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__colorI) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__Rk) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __position->Set(0.f, 0.f, 0.f); + __color.set(1.f, 0.f, 0.f); + __intensity = 1.f; + __enabled = true; + __attenuation = attenuation; + __maxCi = 0.0f; + + UpdateColorI(); + } + + /** + * Sets position property + * + * @param [in] position New position + * + * @return void + */ + void SetPosition(const Tizen::Ui::Effects::_Utils::Vec3f& position) + { + __position->Set(position.x, position.y, position.z); + + return; + } + + /** + * Sets color property + * + * @param [in] color New color value + * + * @return void + */ + void SetColor(const Tizen::Ui::Effects::_Utils::Vec3f& color) + { + __color = color; + UpdateColorI(); + + return; + } + + /** + * Sets intensity property + * + * @param [in] intensity New intensity value + * + * @return void + */ + void SetIntensity(float intensity) + { + __intensity = intensity; + UpdateColorI(); + + return; + } + + /** + * Sets enabled value + * + * @param [in] enabled New enabled value + * + * @return void + */ + void SetEnabled(bool enabled) + { + __enabled = enabled; + + return; + } + + /** + * Gets position property + * + * @return position property + */ + EngineModel::Vector3fPropertyHolderPtr GetPositionHolder(void) const + { + return __position; + } + + /** + * Gets color*intensity value property + * + * @return color*intensity value property + */ + EngineModel::Vector3fPropertyHolderPtr GetColorIHolder(void) const + { + return __colorI; + } + + + /** + * Gets Rk value holder + * + * @return Rk value holder + */ + EngineModel::FloatPropertyHolderPtr GetRkHolder(void) const + { + return __Rk; + } + + /** + * Gets enabled value + * + * @return enabled value + */ + bool GetEnabled(void) const + { + return __enabled; + } + + /** + * Does source emitt any light? + * + * @return true if color*intensity = 0 + */ + bool IsBlack(void) const + { + return __maxCi <= std::numeric_limits::epsilon() || __Rk->Get() <= std::numeric_limits::epsilon(); + } + + /** + * Updates precalculated values related to Attenuation + * + * @return void + */ + void UpdateAttenuation(void) + { + UpdateRk(); + } + +private: + + /** + * Hidden copy constructor + */ + PointLight(const PointLight &rhs); + + + /** + * Hidden assignment operator + */ + PointLight& operator=(const PointLight &rhs); + + /** + * Sets colorI property which is premultiplied color x intensity for use in shader. @n + * Also calculates 1 / Rmax, where Rmax is maxim distance light value is >= 1/255 + * + * @return void + */ + void UpdateColorI(void) + { + __colorI->Set(__color.x * __intensity, __color.y * __intensity, __color.z * __intensity); + __maxCi = Math::EffectsAbs((float)__intensity * Math::EffectsMax(__color.x, Math::EffectsMax(__color.y, __color.z))); + + UpdateRk(); + + return; + } + + /** + * Updates precalculated values related to light emission radius + * + * @return void + */ + void UpdateRk(void) + { + if(__maxCi > std::numeric_limits::epsilon()) + { + __Rk->Set(Math::EffectsSqrt(*__attenuation * (1.0f/255.f) / __maxCi)); + } + } + +private: + _Utils::Vec3f __color; + float __intensity; + bool __enabled; + float __maxCi; + + EngineModel::Vector3fPropertyHolderPtr __position; + EngineModel::Vector3fPropertyHolderPtr __colorI; /**< __color * __intensity */ + EngineModel::FloatPropertyHolderPtr __Rk; + System::FloatPtr __attenuation; +}; // PointLight + +typedef System::SmartPtr PointLightPtr; + +} } } } // Tizen::Ui::Effects::_EffectRenderer + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_POINTLIGHT_H_ diff --git a/src/ui/effects/inc/FUiEffects_RendererRendererGeometry.h b/src/ui/effects/inc/FUiEffects_RendererRendererGeometry.h new file mode 100644 index 0000000..eb4c5c0 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RendererRendererGeometry.h @@ -0,0 +1,294 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RendererRendererGeometry.h + * @brief This is the header file for the RendererGeometry class + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_RENDERERGEOMETRY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_RENDERERGEOMETRY_H_ + +#include +#include +#include +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +/** + * @class RendererGeometry + * @brief Class for renderer object geometry. Holds pointers to pData locations in memory. + * + */ +class RendererGeometry + : public EngineModel::Geometry +{ +public: + + /** + * Constructor + */ + RendererGeometry(void); + + + /** + * Destructor + */ + ~RendererGeometry(void); + + EngineModel::BufferPtr GetBuffer(const std::string& aName) const; + + EngineModel::BufferPtr GetIndexBuffer(void) const + { + return __indexTriangles; + } + + EngineModel::IndexBuffer::PrimitiveType::Value GetPrimitiveType(void) const + { + return __indexTriangles->GetPrimitiveType(); + } + + const EngineModel::Aabb& GetBoundBox(void) const + { + return __bBox; + } + + + /** + * Set vertex pData pointer + * + * @param [in] newdata Vertex pData + * + * @return void + */ + void SetVertData(Tizen::Ui::Effects::_Runtime::VertexDataCollection& newdata) + { + __composite->pData = &newdata; + InvalidateVertexData(); + + return; + } + + + /** + * Set indices pData pointer + * + * @param [in] newdata Indices pData + * + * @return void + */ + void SetIndices(Tizen::Ui::Effects::_Runtime::IndicesCollection& newdata) + { + __indexTriangles->pData = &newdata; + InvalidateIndices(); + + return; + } + + + /** + * Invalidates vertex pData + * + * @return void + */ + void InvalidateVertexData(void) + { + if (__composite->GetCache() != 0) + { + __composite->GetCache()->Invalidate(); + } + + return; + } + + + /** + * Invalidates indices pData + * + * @return void + */ + void InvalidateIndices(void) + { + if(__indexTriangles->GetCache() != 0) + { + __indexTriangles->GetCache()->Invalidate(); + } + + return; + } + +private: + + /** + * Hidden copy constructor + */ + RendererGeometry(const RendererGeometry &rhs); + + + /** + * Hidden assignment operator + */ + RendererGeometry& operator=(const RendererGeometry &rhs); + +private: + class _Buffer_UShortIndex + : public EngineModel::IndexBuffer + { + public: + _Buffer_UShortIndex(void) + : pData(null) + { + } + + ~_Buffer_UShortIndex(void) + { + } + + EngineModel::TypedBufferStrategy::DataType::Value GetDataType(void) const + { + return EngineModel::TypedBufferStrategy::DataType::UNSIGNED_SHORT; + } + + void* GetData(void) + { + return &(*pData)[0]; + } + + size_t GetSize(void) const + { + return pData->size() * sizeof(Tizen::Ui::Effects::_Runtime::IndicesCollection::value_type); + } + + EngineModel::SolidBufferStrategy::BufferUsage::Value GetUsage(void) const + { + return EngineModel::SolidBufferStrategy::BufferUsage::STATIC_DRAW; + } + + EngineModel::IndexBuffer::PrimitiveType::Value GetPrimitiveType(void) const + { + return EngineModel::IndexBuffer::PrimitiveType::TRIANGLES; + } + + Tizen::Ui::Effects::_Runtime::IndicesCollection* pData; + }; + typedef System::SmartPtr<_Buffer_UShortIndex> Buffer_UIntIndexPtr; + + class _Buffer_CompositeFloatVertex + : public EngineModel::CompositeVertexBuffer + { + public: + _Buffer_CompositeFloatVertex(void) + : pData(null) + { + } + + ~_Buffer_CompositeFloatVertex(void) + { + } + + EngineModel::TypedBufferStrategy::DataType::Value GetDataType(void) const + { + return EngineModel::TypedBufferStrategy::DataType::FLOAT; + } + + void* GetData(void) + { + return &(*pData)[0]; + } + + size_t GetSize(void) const + { + return pData->size() * sizeof(Tizen::Ui::Effects::_Runtime::VertexData); + } + + EngineModel::SolidBufferStrategy::BufferUsage::Value GetUsage(void) const + { + return EngineModel::SolidBufferStrategy::BufferUsage::DYNAMIC_DRAW; + } + + Tizen::Ui::Effects::_Runtime::VertexDataCollection* pData; + }; + typedef System::SmartPtr<_Buffer_CompositeFloatVertex> Buffer_CompositeFloatVertexPtr; + + + class _Buffer_VertexAttribute + : public EngineModel::PartVertexBuffer + { + public: + _Buffer_VertexAttribute(EngineModel::CompositeVertexBufferPtr aBuffer, size_t aComponents, size_t aOffset, size_t aStride): + __stride(aStride), __offset(aOffset), __components(aComponents), __buffer(aBuffer) + { + } + + ~_Buffer_VertexAttribute(void) + { + } + + EngineModel::TypedBufferStrategy::DataType::Value GetDataType(void) const + { + return __buffer->GetDataType(); + } + + size_t GetStride(void) const + { + return __stride; + } + + size_t GetOffset(void) const + { + return __offset; + } + + EngineModel::CompositeVertexBufferPtr GetCompositeBuffer(void) const + { + return __buffer; + } + + size_t GetComponentsPerElement(void) const + { + return __components; + } + + private: + size_t __stride; + size_t __offset; + size_t __components; + EngineModel::CompositeVertexBufferPtr __buffer; + }; + typedef System::SmartPtr<_Buffer_VertexAttribute> Buffer_VertexAttributePtr; + + +private: + Buffer_CompositeFloatVertexPtr __composite; + Buffer_VertexAttributePtr __partVertex; + Buffer_VertexAttributePtr __partNormal; + Buffer_VertexAttributePtr __partTexCoords; + Buffer_UIntIndexPtr __indexTriangles; + + EngineModel::Aabb __bBox; +}; + + +typedef System::SmartPtr RendererGeometryPtr; + +} } } } // Tizen::Ui::Effects::_EffectRenderer + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_RENDERERGEOMETRY_H_ diff --git a/src/ui/effects/inc/FUiEffects_RendererRendererObject.h b/src/ui/effects/inc/FUiEffects_RendererRendererObject.h new file mode 100644 index 0000000..f9410c2 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RendererRendererObject.h @@ -0,0 +1,166 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RendererRendererObject.h + * @brief This is the header file for the RendererObject class + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_RENDEREROBJECT_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_RENDEREROBJECT_H_ + +#include +#include +#include +#include +#include +#include + +#include "FUiEffects_RendererEffectShader.h" +#include "FUiEffects_RendererRendererGeometry.h" +#include "FUiEffects_RendererMemoryTexture2DProperty.h" + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +/** + * @class RendererObject + * @brief This class represents renderer object + * + */ +class RendererObject + : public EngineModel::Drawable +{ +public: + + /** + * Constructor + */ + RendererObject(void) + { + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + opacity = EngineModel::FloatPropertyHolderPtr(new (std::nothrow) EngineModel::FloatPropertyHolder); + alphablend = EngineModel::AlphaBlendPropertyPtr(new (std::nothrow) EngineModel::AlphaBlendProperty); + normalMtr = EngineModel::Matrix4fPropertyHolderPtr(new (std::nothrow) EngineModel::Matrix4fPropertyHolder); + modelMtr = EngineModel::Matrix4fPropertyHolderPtr(new (std::nothrow) EngineModel::Matrix4fPropertyHolder); + setMaterial(EngineModel::PropertyHolderMaterialPtr(new (std::nothrow) EngineModel::PropertyHolderMaterial)); + + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(opacity) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(alphablend) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(normalMtr) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(modelMtr) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__mat) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + + normalMtr->Set(Math::Matrix4f::GetIdentity()); + modelMtr->Set(Math::Matrix4f::GetIdentity()); + + __mat->AddProperty(OPACITY_STR, opacity); + __mat->AddProperty("AlphaBlendProp", alphablend); + __mat->AddProperty(MODEL_MTR_STR, modelMtr); + __mat->AddProperty(NORMAL_MTR_STR, normalMtr); + } + + + /** + * Destructor + */ + ~RendererObject(void) + { + } + + + /** + * Sets new geometry for drawable + * + * @param [in] aGeom New geometry + * + * @return void + */ + void setGeometry(RendererGeometryPtr aGeom) + { + EngineModel::Drawable::SetGeometry(aGeom); + __geom = aGeom; + } + + /** + * Sets new material for drawable + * + * @param [in] aGeom New material + * + * @return void + */ + void setMaterial(EngineModel::PropertyHolderMaterialPtr aMat) + { + EngineModel::Drawable::SetMaterial(aMat); + __mat = aMat; + } + + /** + * Gets current geometry of drawable + * + * @return RendererGeometryPtr + */ + RendererGeometryPtr GetGeom(void) const + { + return __geom; + } + + /** + * Gets current material of drawable + * + * @return EngineModel::PropertyHolderMaterialPtr + */ + EngineModel::PropertyHolderMaterialPtr GetMat(void) const + { + return __mat; + } + +private: + + /** + * Hidden copy constructor + */ + RendererObject(const RendererObject &rhs); + + /** + * Hidden assignment operator + */ + RendererObject& operator=(const RendererObject &rhs); + +public: + EngineModel::Matrix4fPropertyHolderPtr normalMtr; + EngineModel::Matrix4fPropertyHolderPtr modelMtr; + + EngineModel::FloatPropertyHolderPtr opacity; + EngineModel::AlphaBlendPropertyPtr alphablend; + +private: + RendererGeometryPtr __geom; + EngineModel::PropertyHolderMaterialPtr __mat; +}; + +typedef System::SmartPtr RendererObjectPtr; + +} } } } // Tizen::Ui::Effects::_EffectRenderer + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_RENDEREROBJECT_H_ diff --git a/src/ui/effects/inc/FUiEffects_RendererSpotLight.h b/src/ui/effects/inc/FUiEffects_RendererSpotLight.h new file mode 100644 index 0000000..c9a6a0c --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RendererSpotLight.h @@ -0,0 +1,359 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RendererSpotLight.h + * @brief This is the header file for the SpotLight class + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SPOTLIGHT_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SPOTLIGHT_H_ + +#include + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +/** + * @class SpotLight + * @brief This class contains data for spot light in scene + * + */ +class SpotLight +{ +public: + + /** + * Constructor + * + * * @param [in] attenuation Global attenuation pointer + * + * @remark Sets default values for members + */ + SpotLight(System::FloatPtr attenuation) + { + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(attenuation) != null, E_INVALID_ARG, "[E_INVALID_ARG] PointLight attenuation equals null"); + + __position = EngineModel::Vector3fPropertyHolderPtr(new (std::nothrow) EngineModel::Vector3fPropertyHolder); + __direction = EngineModel::Vector3fPropertyHolderPtr(new (std::nothrow) EngineModel::Vector3fPropertyHolder); + __k1 = EngineModel::FloatPropertyHolderPtr(new (std::nothrow) EngineModel::FloatPropertyHolder); + __k2 = EngineModel::FloatPropertyHolderPtr(new (std::nothrow) EngineModel::FloatPropertyHolder); + __colorI = EngineModel::Vector3fPropertyHolderPtr(new (std::nothrow) EngineModel::Vector3fPropertyHolder); + __Rk = EngineModel::FloatPropertyHolderPtr(new (std::nothrow) EngineModel::FloatPropertyHolder); + + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__position) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__direction) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__k1) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__k2) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__colorI) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__Rk) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __position->Set(0.f, 0.f, 0.f); + __target.set(0.f, 0.f, -1.f); + __direction->Set(0.f, 0.f, -1.f); + __halfOpeningAngle = 0.6f; + __fadeOutAngle = 0.1f; + __color.set(1.f, 0.f, 0.f); + __intensity = 1.f; + __enabled = true; + __attenuation = attenuation; + __maxCi = 0.0f; + + UpdateColorI(); + UpdateK1K2(); + } + + /** + * Sets position property + * + * @param [in] position New position + * + * @return void + */ + void SetPosition(const Tizen::Ui::Effects::_Utils::Vec3f& position) + { + __position->Set(position.x, position.y, position.z); + __direction->Set(Math::Vector3f(__target.x - __position->Get().X(), __target.y - __position->Get().Y(), __target.z - __position->Get().Z()).Normalize()); + + return; + } + + /** + * Sets target property + * + * @param [in] target New target + * + * @return void + */ + void SetTarget(const Tizen::Ui::Effects::_Utils::Vec3f& target) + { + __target = target; + __direction->Set(Math::Vector3f(__target.x - __position->Get().X(), __target.y - __position->Get().Y(), __target.z - __position->Get().Z()).Normalize()); + + return; + } + + /** + * Sets opening angle value + * + * @param [in] openingAngle New opening angle + * + * @return void + */ + void SetOpeningAngle(float openingAngle) + { + __halfOpeningAngle = openingAngle * 0.5f; + UpdateK1K2(); + + return; + } + + /** + * Sets fadeout angle value + * + * @param [in] fadeOutAngle New fadeout angle + * + * @return void + */ + void SetFadeOutAngle(float fadeOutAngle) + { + __fadeOutAngle = fadeOutAngle; + UpdateK1K2(); + + return; + } + + /** + * Sets color property + * + * @param [in] color New color value + * + * @return void + */ + void SetColor(const Tizen::Ui::Effects::_Utils::Vec3f& color) + { + __color = color; + UpdateColorI(); + + return; + } + + /** + * Sets intensity property + * + * @param [in] intensity New intensity value + * + * @return void + */ + void SetIntensity(float intensity) + { + __intensity = intensity; + UpdateColorI(); + + return; + } + + /** + * Sets enabled value + * + * @param [in] enabled New enabled value + * + * @return void + */ + void SetEnabled(bool enabled) + { + __enabled = enabled; + + return; + } + + /** + * Gets position property + * + * @return position property + */ + EngineModel::Vector3fPropertyHolderPtr GetPositionHolder(void) const + { + return __position; + } + + /** + * Gets direction vector property + * + * @return direction vector property + */ + EngineModel::Vector3fPropertyHolderPtr GetDirectionHolder(void) const + { + return __direction; + } + + /** + * Gets k1 property + * + * @return k1 property + */ + EngineModel::FloatPropertyHolderPtr GetK1Holder(void) const + { + return __k1; + } + + /** + * Gets k2 property + * + * @return k2 property + */ + EngineModel::FloatPropertyHolderPtr GetK2Holder(void) const + { + return __k2; + } + + /** + * Gets color*intensity value property + * + * @return color*intensity value property + */ + EngineModel::Vector3fPropertyHolderPtr GetColorIHolder(void) const + { + return __colorI; + } + + /** + * Gets enabled value + * + * @return enabled value + */ + bool GetEnabled(void) const + { + return __enabled; + } + + /** + * Gets Rk value holder + * + * @return Rk value holder + */ + EngineModel::FloatPropertyHolderPtr GetRkHolder(void) const + { + return __Rk; + } + + /** + * Does source emitt any light? + * + * @return true if color*intensity = 0 + */ + bool IsBlack(void) const + { + return __maxCi <= std::numeric_limits::epsilon() || __Rk->Get() <= std::numeric_limits::epsilon(); + } + + /** + * Updates precalculated values related to Attenuation + * + * @return void + */ + void UpdateAttenuation(void) + { + UpdateRk(); + } + +private: + + /** + * Hidden copy constructor + */ + SpotLight(const SpotLight &rhs); + + + /** + * Hidden assignment operator + */ + SpotLight& operator=(const SpotLight &rhs); + + /** + * Calculates parameters for shader + * + * @return void + */ + void UpdateK1K2(void) + { + __k1->Set(Math::EffectsCos(__halfOpeningAngle + __fadeOutAngle)); + __k2->Set(1.0f / (Math::EffectsCos(__halfOpeningAngle) - __k1->Get())); + + return; + } + + /** + * Sets colorI property which is premultiplied color x intensity for use in shader. @n + * Also calculates 1 / Rmax, where Rmax is maxim distance light value is >= 1/255 + * + * @return void + */ + void UpdateColorI(void) + { + __colorI->Set(__color.x * __intensity, __color.y * __intensity, __color.z * __intensity); + __maxCi = Math::EffectsAbs(__intensity * Math::EffectsMax(__color.x, Math::EffectsMax(__color.y, __color.z))); + + UpdateRk(); + + return; + } + + /** + * Updates precalculated values related to light emission radius + * + * @return void + */ + void UpdateRk(void) + { + if(__maxCi > std::numeric_limits::epsilon()) + { + __Rk->Set(Math::EffectsSqrt(*__attenuation * (1.0f/255.f) / __maxCi)); + } + } + +private: + Tizen::Ui::Effects::_Utils::Vec3f __target; + float __halfOpeningAngle; + float __fadeOutAngle; + _Utils::Vec3f __color; + float __intensity; + bool __enabled; + float __maxCi; + + EngineModel::Vector3fPropertyHolderPtr __position; + EngineModel::Vector3fPropertyHolderPtr __direction; + EngineModel::FloatPropertyHolderPtr __k1; /**< precalculated parameter = cos(OpeningAngle/2 + FadeOutAngle) */ + EngineModel::FloatPropertyHolderPtr __k2; /**< precalculated parameter = 1 / (cos(OpeningAngle/2) - __k1) */ + EngineModel::Vector3fPropertyHolderPtr __colorI; /**< __color * __intensity */ + EngineModel::FloatPropertyHolderPtr __Rk; + System::FloatPtr __attenuation; +}; // SpotLight + +typedef System::SmartPtr SpotLightPtr; + +} } } } // Tizen::Ui::Effects::_EffectRenderer + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_DIRECTIONALLIGHT_H_ diff --git a/src/ui/effects/inc/FUiEffects_RendererViewport.h b/src/ui/effects/inc/FUiEffects_RendererViewport.h new file mode 100644 index 0000000..49d2a31 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RendererViewport.h @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RendererViewport.h + * @brief This is the header file for the Viewport class + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_VIEWPORT_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_VIEWPORT_H_ + +#include +#include "FUiEffects_RendererLog.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +/** + * @class Viewport + * @brief This class for scene viewport and coordinates transformations. Currently for orto projection ONLY!!!!!!, Z = 0 + * + */ +struct Viewport +{ + /** + * Transforms window coordinates to model space + * + * @param [in] p point on screen + * + * @return Vec3f Point in model space + */ + Tizen::Ui::Effects::_Utils::Vec3f TransformScreenToWorld(Tizen::Ui::Effects::_Utils::Vec2f p) const + { + if ((fabsf(screenRight - screenLeft) > std::numeric_limits::epsilon()) && (fabsf(screenTop - screenBottom) > std::numeric_limits::epsilon())) + { + return Tizen::Ui::Effects::_Utils::Vec3f((p.x - screenLeft) * (worldRight - worldLeft) / (screenRight - screenLeft) + worldLeft, + p.y * (worldTop - worldBottom) / (screenBottom - screenTop) + worldBottom, + 0.0f); + } + else + { + return Tizen::Ui::Effects::_Utils::Vec3f(0.0f, 0.0f, 0.0f); + } + } + + float screenLeft; + float screenRight; + float screenTop; + float screenBottom; + float worldLeft; + float worldRight; + float worldTop; + float worldBottom; + float worldZ; + float worldNearDist; + float worldFarDist; + + int displayWidth; + int displayHeight; +}; + +} } } } // Tizen::Ui::Effects::_EffectRenderer + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_VIEWPORT_H_ diff --git a/src/ui/effects/inc/FUiEffects_Runtime.h b/src/ui/effects/inc/FUiEffects_Runtime.h new file mode 100644 index 0000000..9975934 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_Runtime.h @@ -0,0 +1,40 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiEffects_Runtime.h +* @brief This is the header file for the Tizen::Ui::Ext::Effects3d::_Runtime namespace. +*/ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_H_ + +#include "FUiEffects_RuntimeEffectModel.h" +#include "FUiEffects_RuntimeEffectModelScript.h" +#include "FUiEffects_RuntimeGraphicalSurface.h" +#include "FUiEffects_RuntimeIEffectModelListener.h" +#include "FUiEffects_RuntimeIEffectModelManager.h" +#include "FUiEffects_RuntimeIEffectModelScript.h" +#include "FUiEffects_RuntimeIScriptProcessing.h" +#include "FUiEffects_RuntimeLuaProcessing.h" +#include "FUiEffects_RuntimeModel.h" +#include "FUiEffects_RuntimeModelSurface.h" +#include "FUiEffects_RuntimeGraphicalSurfaceNurbs.h" +#include "FUiEffects_RuntimePropertyCast.h" +#include "FUiEffects_RuntimeRenderDataSurface.h" +#include "FUiEffects_RuntimeScriptProcessing.h" + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeDirectionalLight.h b/src/ui/effects/inc/FUiEffects_RuntimeDirectionalLight.h new file mode 100644 index 0000000..9b3ffae --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeDirectionalLight.h @@ -0,0 +1,165 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeDirectionalLight.h + * @brief This is the header file for a directional light + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_DIRECTIONAL_LIGHT_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_DIRECTIONAL_LIGHT_H_ + +#include +#include +#include "FUiEffects_RuntimeUnitLight.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +//tolua_begin <--(!do not edit!)the beginning of export part to lua +class DirectionalLight + : public UnitLight +{ +//tolua_end <--(!do not edit!)the ending of export part to lua +public: + + /** + * Returns a pointer to created directional light + * + * @since 2.0 + * + */ + static DirectionalLight* CreateDirectionalLight(const std::string& name); +#if 0 + static DirectionalLight* CreateDirectionalLight(const string& name); //tolua_export <--(!do not edit!)the exporting line to lua +#endif + + /** + * Returns a pointer to created directional light + * + * @since 2.0 + * + */ + static DirectionalLight* CreateDirectionalLight(bool enabled, + const std::string& name, + const Tizen::Ui::Effects::_Utils::Vec3f& colour, + float intensity, + const Tizen::Ui::Effects::_Utils::Vec3f& direction + ); + + /** + * Returns a direction of a directional light + * + * @since 2.0 + * + */ + const Tizen::Ui::Effects::_Utils::Vec3f& GetDirection(void) const; +#if 0 + const Vector3& GetDirection(void) const; //tolua_export <--(!do not edit!)the exporting line to lua +#endif + + /** + * Sets a direction of a directional light + * + * @since 2.0 + * + */ + void SetDirection(const Tizen::Ui::Effects::_Utils::Vec3f& direction); +#if 0 + void SetDirection(const Vector3& direction); //tolua_export <--(!do not edit!)the exporting line to lua +#endif + + /** + * Sets a direction of a directional light + * + * @since 2.0 + * + */ + void SetDirection(float x, float y, float z); //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Returns a type of a directional light as variable of enumeration type + * + * @since 2.0 + * + */ + virtual TypeUnitLight GetType(void) const; + + /** + * Resets all signs for this instance of class (e.g. isDirectionChanged, isColourChanged) + * + * @since 2.0 + * + */ + virtual void ResetSigns(void); + +protected: + + /** + * Class constructor + * + * @since 2.0 + * + * @remarks Clients of this class can create DirectionalLight objects with using Create methods only + * + */ + DirectionalLight(const std::string& name); + + /** + * Class constructor + * + * @since 2.0 + * + * @remarks Clients of this class can create DirectionalLight objects with using Create methods only + * + */ + DirectionalLight(bool isEnabled, + const std::string& name, + const Tizen::Ui::Effects::_Utils::Vec3f& colour, + float intensity, + const Tizen::Ui::Effects::_Utils::Vec3f& direction + ); + + /** + * Class destructor + * + * @since 2.0 + * + * @remarks Clients of this class can not destroy instances of this class (for purpose to avoid the sending an invalid unit light into scene) + * + */ + ~DirectionalLight(void); + +private: + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + DirectionalLight(const DirectionalLight& rhs); + // The implementation of this assignment operator is intentionally blank and declared as private to prohibit copying of objects. + DirectionalLight& operator=(const DirectionalLight& rhs); + +public: + + bool isDirectionChanged; + +private: + + Tizen::Ui::Effects::_Utils::Vec3f __direction; /**< a direction for a directional light*/ + +}; //DirectionalLight //tolua_export <--(!do not edit!)the exporting line to lua + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_DIRECTIONAL_LIGHT_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeEffectModel.h b/src/ui/effects/inc/FUiEffects_RuntimeEffectModel.h new file mode 100644 index 0000000..76872a0 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeEffectModel.h @@ -0,0 +1,531 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeEffectModel.h + * @brief This is the header file for the EffectModel class. + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_EFFECT_MODEL_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_EFFECT_MODEL_H_ + +#include +#include +#include +#include +#include +#include +#include "FUiEffects_RuntimeIScriptProcessing.h" +#include "FUiEffects_RuntimeScriptProcessing.h" +#include "FUiEffects_RuntimeIEffectModelListener.h" +#include "FUiEffects_RuntimeModel.h" +#include "FUiEffects_RuntimePropertyCast.h" +#include "FUiEffects_RuntimeRenderDataSurface.h" +#include "FUiEffects_RuntimeIEffectModelScript.h" +#include "FUiEffects_RuntimeIEffectModelManager.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +class GraphicalSurface; +class ModelSurface; +class UnitLight; + +/** +* The map type for pointers to ElementSurface abstract class. +* +*/ +typedef std::map TypeMapElements; + +/** +* The map type for pointers to GraphicalSurface abstract class. +* +*/ +typedef std::map TypeMapGSurface; + +/** +* The list type for pointers to model surfaces. +* +*/ +typedef std::list TypeMSurfacesCollection; + +/** +* The type for denoting the time in model runtime (seconds). +* +*/ +typedef float TypeTimeEffect; + +struct ModelSurfacesCollectionDeleter +{ + void operator()(TypeMSurfacesCollection* pMSurfacesCollection); +}; + +/** + * @class EffectModel + * @brief This class contains the collection of model surfaces, transmits events to relevant classes. + * + * @since 2.0 + * + */ +class EffectModel + : public IEffectModelScript + , public IEffectModelManager +{ +public: + /** + * EffectModel class constructor + * + * @since 2.0 + * + */ + EffectModel(long effectID, const std::string& name, const char* pPathToScript, IEffectModelListener* pEMListener, ::Tizen::Ui::Effects::EffectType effectType, TypeTimeEffect effectDuration); + + /** + * Class destructor + * + * @since 2.0 + * + */ + virtual ~EffectModel(void); + + /** + * Adds a pointer to model surface into model surfaces collection + * + * @since 2.0 + * + * @remarks It is called from parser + */ + void AddModelSurface(ModelSurface* pMSurface); + + /** + * Links classes after creating effect by parser (constructs the elements map and render data collection) + * + * @since 2.0 + * + * @remarks It is called from up level (by parser or effects manager); + * after linking calls script function Initialize + */ + void Construct(void); + + /** + * Calls script function OnEffectStart, prepares effect to starting + * + * @since 2.0 + * + * @remarks For example, script function OnEffectStart fixes cover points for PTE effect + */ + virtual int Start(const EffectsVector& effectStartInfo); + + /** + * Stops effect performing and initializes (if not breakdown) + * + * @since 2.0 + * + * @remarks Sends to up level about effect stop; + * it is called from up level in case of forced stop + */ + virtual void Stop(bool isBreakdown, bool isInterruptedFromApplication); + + /** + * Calculating effect's elements + * + * @since 2.0 + * + * @remarks It is called from up level by timer; + * calls script function OnEffectCalculate + * and after calls function Calculate of all model surfaces, + * and then, if effect is EFFECT_TYPE_INTERACTIVE, + * calls script function IsEffectFinished + */ + virtual void Calculate(float dt); + + virtual long GetId(void) const; + virtual std::string GetName(void) const; + + /** + * Event touch pressed handler + * + * @since 2.0 + * + * @remarks It is called from up level by corresponding event handler, + * transmits event to script + */ + virtual void FeedTouchPressEvent(const TouchEventScript &pos3); + + /** + * Event touch moved handler + * + * @since 2.0 + * + * @remarks It is called from up level by corresponding event handler, + * transmits event to script + */ + virtual void FeedTouchMoveEvent(const TouchEventScript &pos3); + + /** + * Event touch released handler + * + * @since 2.0 + * + * @remarks It is called from up level by corresponding event handler, + * transmits event to script + */ + virtual void FeedTouchReleaseEvent(const TouchEventScript &pos3); + + /** + * Event touch double pressed handler + * + * @since 2.0 + * + * @remarks It is called from up level by corresponding event handler, + * transmits event to script + */ + virtual void FeedTouchDoublePressEvent(const TouchEventScript &pos3); + + /** + * Returns time passed from the effect beginning + * + * @since 2.0 + * + */ + virtual float GetCalculationPeriodForTimer(void) const; + + /** + * Returns current effect state (see enumeration _EffectState) + * + * @since 2.0 + * + */ + virtual _EffectState GetState(void) const; + + /** + * Returns effect behaviour type (see enumeration EffectType) + * + * @since 2.0 + * + */ + virtual EffectType GetType(void) const; + + /** + * Returns the pointer to the collection of structure RenderData elements to up level (to renderer) + * + * @since 2.0 + * + * @remarks The size of this collection is equal to quantity of graphical surfaces; + * this function is called once from up level for renderer + */ + virtual RenderDataScene* GetRenderingData(void) const; + + /** + * Updates all graphical surfaces + * + * @since 2.0 + * + * @remarks It is called for updating graphical points based on physical points + */ + virtual void UpdateGraphicalSurfaces(void); + + /** + * Transmits event SetProperty for boolean values from script to class-inheritor of ElementSurface interface + * + * @since 2.0 + * + * @remarks Function is inherited from IEffectModelScript class + */ + virtual bool ScriptSetProperty(long objID, ElementProperty property, bool value); + + /** + * Transmits event SetProperty for lua_Number values (floating point or integer) + * from script to class-inheritor of ElementSurface interface + * + * @since 2.0 + * + * @remarks Function is inherited from IEffectModelScript class + */ + virtual bool ScriptSetProperty(long objID, ElementProperty property, LUA_NUMBER value); + + /** + * Transmits event SetProperty for Vec3f values from script to class-inheritor of ElementSurface interface + * + * @since 2.0 + * + * @remarks Function is inherited from IEffectModelScript class + */ + virtual bool ScriptSetProperty(long objID, ElementProperty property, const Tizen::Ui::Effects::_Utils::Vec3f &value); + + /** + * Transmits event SetPropertyGroup for some group of elements from script to specified model surface + * + * @since 2.0 + * + */ + virtual bool ScriptSetPropertyGroup(long objID, GroupElements group, ElementProperty property, LUA_NUMBER value); + + /** + * Transmits event GetProperty from script to class-inheritor of ElementSurface interface + * + * @since 2.0 + * + * @remarks Function is inherited from IEffectModelScript class; + * if ID is equals 0, then the owner of property is EffectModel + */ + virtual PropertyCast ScriptGetProperty(long objID, ElementProperty property) const; + + /** + * Transmits event UpdateBitmap from script to up level (to class-inheritor of IEffectModelListener interface) + * + * @since 2.0 + * + * @remarks Function is inherited from IEffectModelScript class + */ + virtual bool ScriptUpdateBitmap(long graphicalSurfaceID, long bitmapID); + + /** + * Transmits event GetNearestGPoint from script to corresponding graphical surface; + * finds the vector of vectors of nearest points to specified point of graphical surface + * + * since 3.0 + * + */ + virtual PropertyCast ScriptGetNearestPointsIds(long graphicalSurfaceID, Tizen::Ui::Effects::_Utils::Vec3f &position) const; + + /** + * Transmits event RotateModelMatrix from script to corresponding graphical surface; + * rotates model matrix of corresponding graphical surface + * + * @since 2.0 + * + */ + virtual bool ScriptRotateSurface(long graphicalSurfaceID, float angle, _Axis axis, _Point point, + float ax, float ay, float az, float x0, float y0, float z0); + + /** + * Transmits event ScaleModelMatrix from script to corresponding graphical surface; + * scales model matrix of corresponding graphical surface + * + * @since 2.0 + * + */ + virtual bool ScriptScaleSurface(long graphicalSurfaceID, float ax, float ay, float az, _Point point, + float x0, float y0, float z0); + + /** + * Transmits event TranslateModelMatrix from script to corresponding graphical surface; + * translates model matrix of corresponding graphical surface + * + * @since 2.0 + * + */ + virtual bool ScriptMoveSurface(long graphicalSurfaceID, float x0, float y0, float z0); + + /** + * Transmits event ResetModelMatrix from script to corresponding graphical surface; + * sets identity model matrix for corresponding graphical surface + * + * @since 2.0 + * + */ + virtual bool ScriptResetSurfaceTransformation(long graphicalSurfaceID); + + /** + * Transmits event DistanceFromGround from script to corresponding model surface + * + * @since 2.0 + * + */ + virtual PropertyCast ScriptGetDistanceFromGround(long modelSurfaceID) const; + + /** + * Transmits event SetModelMatrix from script to corresponding graphical surface; + * sets model matrix for corresponding graphical surface + * + * @since 2.0 + * + */ + virtual bool ScriptSetTransformationMatrix(long graphicalSurfaceID, const Tizen::Ui::Effects::_Utils::LuaMatrix4& luaMatrix4); + + /** + * Adds new unit light to scene + * + * @since 2.0 + * + * @remarks Returns true if addition was succeeded and false otherwise + */ + virtual bool ScriptAddUnitLight(UnitLight& unitLight); + + /** + * Excludes specified unit light from scene with using unique name of it + * + * @since 2.0 + * + * @remarks Returns true if addition was succeeded and false otherwise + */ + virtual bool ScriptRemoveUnitLight(const std::string& name); + + /** + * Excludes all units light of specified type from scene + * + * @since 2.0 + * + * @remarks Returns true if addition was succeeded and false otherwise + */ + virtual bool ScriptRemoveAllUnitsLightType(TypeUnitLight typeUnitLight); + + /** + * Returns specified unit light with using unique name of it + * + * @since 2.0 + * + */ + virtual PropertyCast ScriptGetUnitLight(const std::string& name) const; + + /** + * Sets ambient colour for scene + * + * @since 2.0 + * + */ + virtual void ScriptSetLightAmbientColour(const Tizen::Ui::Effects::_Utils::Vec3f& ambientColour); + + /** + * Sets ambient colour for scene + * + * @since 2.0 + * + */ + virtual void ScriptSetLightAmbientColour(float red, float green, float blue); + + /** + * Sets light intensity for scene + * + * @since 2.0 + * + */ + virtual void ScriptSetLightIntensity(float intensity); + + /** + * Sets attenuation for units light on scene + * + * @since 2.0 + * + */ + virtual void ScriptSetLightAttenuation(float attenuation); + + /** + * Returns ambient colour of scene + * + * @since 2.0 + * + */ + virtual const Tizen::Ui::Effects::_Utils::Vec3f& ScriptGetLightAmbientColour(void) const; + + /** + * Returns light intensity of scene + * + * @since 2.0 + * + */ + virtual float ScriptGetLightIntensity(void) const; + + /** + * Returns attenuation for units light on scene + * + * @since 2.0 + * + */ + virtual float ScriptGetLightAttenuation(void) const; + +protected: + +private: + /** + * Hidden copy constructor + * + * @since 2.0 + * + */ + EffectModel(const EffectModel& rhs); + + /** + * Hidden assignment operator + * + * @since 2.0 + * + */ + EffectModel &operator=(const EffectModel& rhs); + + /** + * Finds an element in elements map by index + * + * @since 2.0 + * + * @remarks If element with specified index not exists, the function returns false + */ + bool FindElement(long objID, TypeMapElements::iterator& it) const; + + /** + * Finds an element in graphical surfaces map by index + * + * @since 2.0 + * + * @remarks If graphical surface with specified index not exists, the function returns false + */ + bool FindGraphicalSurface(long objID, TypeMapGSurface::iterator& it) const; + + /** + * Initializes some class parameters and calls function Initialize from script + * + * @since 2.0 + * + */ + void InitEffectModel(void); + + /** + * Initializes all effect parameters + * + * @since 2.0 + * + * @remarks Effect's initialization after finishing + */ + void EffectInitialize(void); + +private: + + std::unique_ptr __pScript; /**< pointer to script processing (for performing some functions in scripts)*/ + + IEffectModelListener* __pEMListener; /**< pointer to effect model listener (for sending events to up level)*/ + _EffectState __state; /**< current effect state*/ + ::Tizen::Ui::Effects::EffectType __effectType; /**< effect behaviour type*/ + EffectResultS __effectResult; /**< result of effect performing*/ + + std::unique_ptr __pMapElements; /**< elements map (for quick searching the element by index)*/ + std::unique_ptr __pMapGSurface; /**< graphical surfaces map (for quick searching the graphical surface by index and access from effect model instance to graphical surface directly)*/ + + std::unique_ptr __pMSurfacesCollection; /**< model surfaces collection*/ + + const long __effectID; /**< ID of effect (for sending event to up level with ID of effect which generates this event)*/ + const std::string __name; + + TypeTimeEffect __effectTimePassed; /**< elapsed time from effect beginning (in seconds)*/ + TypeTimeEffect __effectDuration; /**< the effect duration (is needed for time based effect) (in seconds)*/ + + std::unique_ptr __pRenderDataScene; /**< a pointer to render data for scene */ + +}; // EffectModel + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_EFFECT_MODEL_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeEffectModelScript.h b/src/ui/effects/inc/FUiEffects_RuntimeEffectModelScript.h new file mode 100644 index 0000000..bf5dd99 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeEffectModelScript.h @@ -0,0 +1,429 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeEffectModelScript.h + * @brief This is the header file for the EffectModelScript class. + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_EFFECT_MODEL_SCRIPT_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_EFFECT_MODEL_SCRIPT_H_ + +#include "utils/FUiEffects_UtilsLuaMat4.h" +#include "FUiEffects_RuntimeModel.h" +#include "FUiEffects_RuntimeEffectModel.h" +#include "FUiEffects_RuntimePropertyCast.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +class EffectModel; +class IEffectModelScript; +class UnitLight; + +/** + * @class EffectModelScript + * @brief This class is used by toLua subsystem for binding Lua with EffectModel + * + * @since 2.0 + * + */ + +//tolua_begin <--(!do not edit!)the beginning of export part to lua +class EffectModelScript +{ +//tolua_end <--(!do not edit!)the ending of export part to lua + +public: + /** + * EffectModelScript class constructor + * + * @since 2.0 + * + */ + EffectModelScript(IEffectModelScript* pEModel); + + /** + * EffectModelScript class destructor + * + * @since 2.0 + * + */ + ~EffectModelScript(void); + +//tolua_begin <--(!do not edit!)the beginning of export part to lua + /** + * Returns EffectModel's element's property + * + * @since 2.0 + * + * @remarks Transmits event GetProperty from script functions to up level + * via interface IEffectModelScript + */ + PropertyCast GetProperty(long objID, ElementProperty property) const; + + /** + * Sets EffectModel's element's property of boolean type. + * + * @since 2.0 + * + * @remarks Transmits event SetProperty from script functions to up level + * via interface IEffectModelScript + */ + bool SetProperty(long objID, ElementProperty property, bool value); + + /** + * Sets EffectModel's element's property of lua_Number type (floating point or integer). + * + * @since 2.0 + * + * @remarks Transmits event SetProperty from script functions to up level + * via interface IEffectModelScript + */ + bool SetProperty(long objID, ElementProperty property, LUA_NUMBER value); + + /** + * Sets EffectModel's element's property of Vec3f type. + * + * @since 2.0 + * + * @remarks Transmits event SetProperty from script functions to up level + * via interface IEffectModelScript + */ + //tolua_end <--(!do not edit!)the ending of export part to lua + bool SetProperty(long objID, ElementProperty property, const Tizen::Ui::Effects::_Utils::Vec3f &value); + //tolua_begin <--(!do not edit!)the beginning of export part to lua +#if 0 + bool SetProperty(long objID, ElementProperty property, const Vector3 &value); //for export to lua, should be ignored by c++ compiler +#endif + + /** + * Sets property's value for elements group + * + * @since 2.0 + * + */ + bool SetPropertyGroup(long modelSurfaceID, GroupElements group, ElementProperty property, LUA_NUMBER value); + + /** + * Calculates distance from specified model surface to its ground level + * + * @since 2.0 + * + */ + PropertyCast GetDistanceFromGround(long modelSurfaceID) const; + + /** + * Generates request for bitmap updating. + * + * @since 2.0 + * + * @remarks Transmits event UpdateBitmap from script functions to up level + * via interface IEffectModelScript + */ + bool UpdateBitmap(long graphicalSurfaceID, long bitmapID); + + /** + * Returns a vector of vectors of nearest points ID to specified point of graphical surface + * + * @since 2.0 + * + * @remarks Transmits event GetNearestGPoint from script functions to up level + * via interface IEffectModelScript + */ + //tolua_end <--(!do not edit!)the ending of export part to lua + PropertyCast GetNearestPointsIds(long graphicalSurfaceID, Tizen::Ui::Effects::_Utils::Vec3f &position) const; + //tolua_begin <--(!do not edit!)the beginning of export part to lua +#if 0 + PropertyCast GetNearestPointsIds(long graphicalSurfaceID, Vector3 &position) const; //for export to lua, should be ignored by c++ compiler +#endif + + /** + * Returns a vector of vectors of nearest points ID to specified point of graphical surface + * + * @since 2.0 + * + * @remarks Transmits event GetNearestGPoint from script functions to up level + * via interface IEffectModelScript + */ + PropertyCast GetNearestPointsIds(long graphicalSurfaceID, float posX, float posY, float posZ) const; + + /** + * Rotates model matrix by the Angle around Axis drawn from the Point + * + * @since 2.0 + * + * @return Returns true if model matrix was changed successfully and false otherwise + * @param [in] GraphicalSurfaceID: ID of graphical surface which matrix has to be rotated + * @param [in] Angle: The angle of rotation (radians) + * @param [in] Axis: One of the axes (X, Y, Z, ARBITRARY) around which rotation will be performed + * @param [in] Point: Base point on graphical surface which coordinates are not change + * @param [in] ax, ay, az: The coordinates of axis around which rotation will be performed (in case Axis=AXIS_ARBITRARY) + * @param [in] x0, y0, z0: Base point which coordinates are not change (in case Point=POINT_ARBITRARY) + * + */ + bool RotateSurfaceN(long graphicalSurfaceID, float angle, _Axis axis, _Point point, + float ax = 0.f, float ay = 0.f, float az = 1.f, float x0 = 0.f, float y0 = 0.f, float z0 = 0.f); + + /** + * Rotates model matrix by the Angle around Axis drawn from the Point + * + * @since 2.0 + * + * @return Returns true if model matrix was changed successfully and false otherwise + * @param [in] GraphicalSurfaceID: ID of graphical surface which matrix has to be rotated + * @param [in] Angle: The angle of rotation (radians) + * @param [in] Axis: One of the axes (X, Y, Z, ARBITRARY) around which rotation will be performed + * @param [in] Point: Base point on graphical surface which coordinates are not change + * @param [in] vAxis: The axis as vector around which rotation will be performed (in case Axis=AXIS_ARBITRARY) + * @param [in] vBasePoint0: Base point which coordinates are not change (in case Point=POINT_ARBITRARY) + * + */ + //tolua_end <--(!do not edit!)the ending of export part to lua + bool RotateSurfaceV(long graphicalSurfaceID, float angle, _Axis axis, _Point point, + const Tizen::Ui::Effects::_Utils::Vec3f &axisArbit = Tizen::Ui::Effects::_Utils::Vec3f(0.f, 0.f, 1.f), const Tizen::Ui::Effects::_Utils::Vec3f &basePointArbit = Tizen::Ui::Effects::_Utils::Vec3f(0.f, 0.f, 0.f)); + //tolua_begin <--(!do not edit!)the beginning of export part to lua +#if 0 + bool RotateSurfaceV(long graphicalSurfaceID, float angle, _Axis axis, _Point point, + const Vector3 &axisArbit = Vector3(0.f, 0.f, 1.f), const Vector3 &basePointArbit = Vector3(0.f, 0.f, 0.f)); //for export to lua, should be ignored by c++ compiler +#endif + + /** + * Scales model matrix by the factors ax, ay, az relative to the axes + * + * @since 2.0 + * + * @return Returns true if model matrix was changed successfully and false otherwise + * @param [in] GraphicalSurfaceID: ID of graphical surface which matrix has to be scaled + * @param [in] ax, ay, az: Multipliers for scaling along the axes + * @param [in] Point: Base point on graphical surface which coordinates are not change + * @param [in] x0, y0, z0: Base point which coordinates are not change (in case point=POINT_ARBITRARY) + * + */ + bool ScaleSurface(long graphicalSurfaceID, float ax, float ay, float az, _Point point, + float x0 = 0.f, float y0 = 0.f, float z0 = 0.f); + + /** + * Scales model matrix by the factors encapsulated in vector vMultiplier + * + * @since 2.0 + * + * @return Returns true if model matrix was changed successfully and false otherwise + * @param [in] GraphicalSurfaceID: ID of graphical surface which matrix has to be scaled + * @param [in] vMultiplier: Vector of multipliers for scaling along the axes + * @param [in] Point: Base point on graphical surface which coordinates are not change (the coordinates of this point do not change) + * @param [in] vBasePopint0: Base point which coordinates are not change (if case point=POINT_ARBITRARY) + * + */ + //tolua_end <--(!do not edit!)the ending of export part to lua + bool ScaleSurface(long graphicalSurfaceID, const Tizen::Ui::Effects::_Utils::Vec3f &multipliers, _Point point, + const ::Tizen::Ui::Effects::_Utils::Vec3f &basePoint = Tizen::Ui::Effects::_Utils::Vec3f(0.f, 0.f, 0.f)); + //tolua_begin <--(!do not edit!)the beginning of export part to lua +#if 0 + bool ScaleSurface(long graphicalSurfaceID, const Vector3 &multipliers, _Point point, + const Vector3 &basePoint = Vector3(0.f, 0.f, 0.f)); //for export to lua, should be ignored by c++ compiler +#endif + + /** + * Translates model matrix by values x0, y0 and z0 relative to the axes + * + * @since 2.0 + * + * @return Returns true if model matrix was changed successfully and false otherwise + * @param [in] GraphicalSurfaceID: ID of graphical surface which matrix has to be translated + * @param [in] x0, y0, z0: the coordinates of destination point + * + */ + bool MoveSurface(long graphicalSurfaceID, float x0, float y0, float z0); + + /** + * Translates model matrix by vector vPointTarget + * + * @since 2.0 + * + * @return Returns true if model matrix was changed successfully and false otherwise + * @param [in] GraphicalSurfaceID: ID of graphical surface which matrix has to be translated + * @param [in] vPointTarget: destination point + * + */ + //tolua_end <--(!do not edit!)the ending of export part to lua + bool MoveSurface(long graphicalSurfaceID, const Tizen::Ui::Effects::_Utils::Vec3f &pointTarget); + //tolua_begin <--(!do not edit!)the beginning of export part to lua +#if 0 + bool MoveSurface(long graphicalSurfaceID, const Vector3 &pointTarget); //for export to lua, should be ignored by c++ compiler +#endif + + /** + * Sets identity model matrix + * + * @since 2.0 + * + * @return Returns true if model matrix was changed successfully and false otherwise + */ + bool ResetSurfaceTransformation(long graphicalSurfaceID); + + /** + * Function for redirection of lua print information + * + * @since 2.0 + * + * @remarks Is called from lua function print(...) + */ + static void PrintLuaInfo(const char* pStr); + + /** + * Sets the model matrix for specified graphical surface + * + * @since 2.0 + */ + // tolua_end <--(!do not edit!)the ending of export part to lua + bool SetTransformationMatrix(long graphicalSurfaceID, const Tizen::Ui::Effects::_Utils::LuaMatrix4& luaMatrix4); + // tolua_begin <--(!do not edit!)the beginning of export part to lua +#if 0 + bool SetTransformationMatrix(long graphicalSurfaceID, const LuaMatrix4& luaMatrix4); +#endif + +// tolua_end <--(!do not edit!)the ending of export part to lua + + /** + * Adds new unit light to scene + * + * @since 2.0 + * + * @remarks Returns true if addition was succeeded and false otherwise + */ + bool AddUnitLight(UnitLight& unitLight); //tolua_export + + /** + * Excludes specified unit light from scene with using unique name of it + * + * @since 2.0 + * + * @remarks Returns true if addition was succeeded and false otherwise + */ + bool RemoveUnitLight(const std::string& name); +#if 0 + bool RemoveUnitLight(const string& name); //tolua_export +#endif + + /** + * Excludes all units light of specified type from scene + * + * @since 2.0 + * + * @remarks Returns true if addition was succeeded and false otherwise + */ + bool RemoveAllUnitsLightType(TypeUnitLight typeUnitLight); //tolua_export + + /** + * Returns specified unit light with using unique name of it + * + * @since 2.0 + * + */ + PropertyCast GetUnitLight(const std::string& name) const; +#if 0 + PropertyCast GetUnitLight(const string& name) const; //tolua_export +#endif + + /** + * Sets ambient colour for scene + * + * @since 2.0 + * + */ + void SetLightAmbientColour(const Tizen::Ui::Effects::_Utils::Vec3f& ambientColour); +#if 0 + void SetLightAmbientColour(const Vector3& ambientColour); //tolua_export +#endif + + /** + * Sets ambient colour for scene + * + * @since 2.0 + * + */ + void SetLightAmbientColour(float red, float green, float blue); //tolua_export + + /** + * Sets light intensity for scene + * + * @since 2.0 + * + */ + void SetLightIntensity(float intensity); //tolua_export + + /** + * Sets attenuation for units light on scene + * + * @since 2.0 + * + */ + void SetLightAttenuation(float attenuation); //tolua_export + + /** + * Returns ambient colour of scene + * + * @since 2.0 + * + */ + const Tizen::Ui::Effects::_Utils::Vec3f& GetLightAmbientColour(void) const; +#if 0 + const Vector3& GetLightAmbientColour(void) const; //tolua_export +#endif + + /** + * Returns intensity of units light in a scene (as property of entire scene) + * + * @since 2.0 + * + */ + float GetLightIntensity(void) const; //tolua_export + + /** + * Returns attenuation for units light on scene + * + * @since 2.0 + * + */ + float GetLightAttenuation(void) const; //tolua_export + +private: + /** + * Hidden copy constructor + * + * @since 2.0 + * + */ + EffectModelScript(const EffectModelScript &rhs); + + /** + * Hidden assignment operator + * + * @since 2.0 + * + */ + EffectModelScript &operator=(const EffectModelScript &rhs); + +private: + + IEffectModelScript* __pEModel; /**< pointer to interface IEffectModelScript (for transmitting events from script to up level)*/ + +}; // EffectModelScript //tolua_export <--(!do not edit!)exporting one line to lua + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_EFFECT_MODEL_SCRIPT_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeGraphicalSurface.h b/src/ui/effects/inc/FUiEffects_RuntimeGraphicalSurface.h new file mode 100644 index 0000000..64834bf --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeGraphicalSurface.h @@ -0,0 +1,270 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeGraphicalSurface.h + * @brief This is the header file for the GraphicalSurface class. + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_GRAPHICAL_SURFACE_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_GRAPHICAL_SURFACE_H_ + +#include +#include +#include "FUiEffects_RuntimeModelSurface.h" +#include "FUiEffects_RuntimeRenderDataSurface.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +/** + * @class GraphicalSurface + * @brief This class is an abstract for any graphical surface + * + * @since 2.0 + * + */ +class GraphicalSurface + : public ::Tizen::Ui::Effects::_PhysicsEngine::ElementSurface +{ +public: + /** + * GraphicalSurface class constructor + * + * @since 2.0 + * + */ + GraphicalSurface(long objId, long bitmapID_, float transpar_); + + /** + * GraphicalSurface class destructor + * + * @since 2.0 + * + */ + virtual ~GraphicalSurface(void); + + /** + * Initializes GraphicalSurface's internal parameters and resets accumulated parameters to zero + * + * @since 2.0 + * + * @remarks Function is inherited from ElementSurface interface + */ + virtual void Initialize(void); + + /** + * Updates graphical points based on physical points + * + * @since 2.0 + * + */ + virtual void Update(void) = 0; + + /** + * Constructs render data collection + * + * @since 2.0 + * + */ + virtual void Construct(TypeElemSurfaceCollection* pElemSurfaceCollection, RenderDataSurfaceCollection* pRenderDataSurfaceCollection); + + /** + * Constructs z-coordinate of position + * based on intersection point of the ray (from camera to point with coordinates (position.x, position.y)) with some triangle of the surface + * + * @since 2.0 + * + * @remarks The algorithm consists of several steps: + * 1. Finds triangles from RenderData structure which are crossed by the ray (position.x, position.y) + * 2. Builds planes passing through 3 vertexes triangles which were found on previous step + * 3. Finds z-coordinate of ray with coordinates (position.x, position.y) + * which crosses planes which were built on previous step (for receive maximal z-coordinate) + */ + virtual PropertyCast GetNearestPointsIds(Tizen::Ui::Effects::_Utils::Vec3f &position) const; + + /** + * Returns the ID of current bitmap for this graphical surface + * + * @since 2.0 + * + */ + long GetBitmapId(void) const; + + /** + * Sets the bitmap ID for this graphical surface + * + * @since 2.0 + * + */ + void SetBitmapId(long bitmapID); + + /** + * Provides reading access to GraphicalSurface's properties values from user's scripts + * + * @since 2.0 + * + */ + virtual PropertyCast GetProperty(ElementProperty propName) const; + + /** + * Provides writing access to GraphicalSurface's properties values of + * boolean type from user's scripts + * + * @since 2.0 + * + */ + virtual bool SetProperty(ElementProperty propName, bool PropValue); + + /** + * Provides writing access to GraphicalSurface's properties values of + * lua_Number type (double or float, or integer etc) from user's scripts + * + * @since 2.0 + * + */ + virtual bool SetProperty(ElementProperty propName, LUA_NUMBER propValue); + + /** + * Provides writing access to GraphicalSurface's properties values of + * Vec3f type from user's scripts + * + * @since 2.0 + * + */ + virtual bool SetProperty(ElementProperty propName, const Tizen::Ui::Effects::_Utils::Vec3f &propValue); + + /** + * Rotates model matrix by Angle around Axis or (ax, ay, az) in case Axis=AXIS_ARBITRARY + * + * @since 2.0 + * + * @param [in] Point: Base point for rotation (the coordinates of this point are not changed) + * @param [in] ax, ay, az: The coordinates of axis around which rotation is performed (in case Axis=AXIS_ARBITRARY) + * @param [in] x0, y0, z0: Base point coordinates in case point=POINT_ARBITRARY + */ + virtual bool RotateSurface(float angle, _Axis axis, _Point point, + float ax, float ay, float az, float x0, float y0, float z0) = 0; + + /** + * Scales model matrix by multipliers ax, ay, az on the relevant axes + * with base Point or (x0, y0, z0) in case Point = POINT_ARBITRARY + * + * @since 2.0 + * + * @remarks Note that the base point coordinates do not change + */ + virtual bool ScaleSurface(float ax, float ay, float az, _Point point, + float x0, float y0, float z0) = 0; + + /** + * Translates model matrix to position (x0, y0, z0) + * + * @since 2.0 + * + */ + void MoveSurface(float x0, float y0, float z0); + + /** + * Sets identity model matrix + * + * @since 2.0 + * + */ + void ResetSurfaceTransformation(void); + + /** + * Sets model matrix for this graphical surface + * + * @since 2.0 + * + */ + void SetTransformationMatrix(const Tizen::Ui::Effects::_Utils::LuaMatrix4& luaMatrix4); + +protected: + /** + * Rotates model matrix by Angle around Axis or (ax, ay, az) in case Axis=AXIS_ARBITRARY + * + * @since 2.0 + * + * @remarks Differs from previous function that do not uses variable Point + * (it variable already taken into account in variables x0, y0, z0) + */ + bool RotateSurface(float angle, _Axis axis, + float ax, float ay, float az, float x0, float y0, float z0); + + /** + * Scales model matrix by multipliers ax, ay, az on the relevant axes + * with base point (x0, y0, z0) + * + * @since 2.0 + * + * @remarks Note that the base point coordinates are not changed + */ + bool ScaleSurface(float ax, float ay, float az, float x0, float y0, float z0); + +private: + /** + * Hidden copy constructor + * + * @since 2.0 + * + */ + GraphicalSurface(const GraphicalSurface& rhs); + + /** + * Hidden assignment operator + * + * @since 2.0 + * + */ + GraphicalSurface &operator=(const GraphicalSurface& rhs); + + /** + * Determines whether a point lies inside the triangle with vertexes which are specified by indices + * + * @since 2.0 + * + * @param [in] pos The point Cartesian coordinates + * @param [in] i1, i2, i3 The triangle vertex indices + * (is represented in RenderData::IndicesCollection) + * @return Returns true if point pos lies in the triangle and false otherwise + */ + bool InTriangle(const Tizen::Ui::Effects::_Utils::Vec3f& pos, short i1, short i2, short i3) const; + + /** + * Finds the the z-coordinate of the point pos on + * the plane passing through the points with indices i1, i2, i3 + * + * @since 2.0 + * + */ + float ZInPlane(const Tizen::Ui::Effects::_Utils::Vec3f& pos, short i1, short i2, short i3) const; + +protected: + + std::unique_ptr _pRenderData; /**< pointer to data for rendering (for this concrete surface)*/ + +private: + float __initTransparency; /**< initial value of surface transparency*/ + long __initBitmapID; /**< initial value of bitmap ID*/ + Tizen::Ui::Effects::_Utils::Mat4f __initModelMtr; + +}; // GraphicalSurface + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_GRAPHICAL_SURFACE_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeGraphicalSurfaceNurbs.h b/src/ui/effects/inc/FUiEffects_RuntimeGraphicalSurfaceNurbs.h new file mode 100644 index 0000000..99fd426 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeGraphicalSurfaceNurbs.h @@ -0,0 +1,364 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeGraphicalSurfaceNurbs.h + * @brief This is the header file for the GraphicalSurfaceNurbs class. + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_GRAPHICAL_SURFACE_NURBS_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_GRAPHICAL_SURFACE_NURBS_H_ + +#include +#include "FUiEffects_RuntimeGraphicalSurface.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +/** +* Weight assignment for every control point of NURBS +* +* @since 2.0 +* +*/ +struct _DataPointWeight +{ + float weight; /**< the weight of control point (physical point of effect model) in NURBS algorithm (influence of it on corresponding graphical point) */ + const Tizen::Ui::Effects::_Utils::Vec3f* pPoint; /**< the pointer to physical point (control point in accordance NURBS theory)*/ +}; + +/** +* The vector type for storing knots for NURBS algorithm. +* +* @since 2.0 +* +*/ +typedef std::vector TypeKnots; + +/** +* The vector type for storing PointSurfaceNURBS pointers. +* +* @since 2.0 +* +*/ +typedef std::vector TypePSurfaceNURBSCollection; + +/** +* The vector type for storing NURBS coefficients. +* +* @since 2.0 +* +*/ +typedef std::vector<_DataPointWeight> TypeNURBSCoeffsCollection; + +/** +* The vector type for storing a coordinates of graphical surface corners (as rectangle). +* +* @since 2.0 +* +*/ +typedef std::vector TypeCornerGrapSurPointsCollection; + +/** +* The vector type for storing a coordinates of "physical" surface corners (as rectangle). +* +* @since 2.0 +* +*/ +typedef std::vector TypeCornerPhysSurPointsCollection; + +/** +* The type for storing vector of vectors of ID (is needed for finding nearest points algorithm). +* +* @since 2.0 +* +*/ +typedef EffectsVector > TypeNearestPointsCollection; + +/** + * @class GraphicalSurfaceNurbs + * @brief This class specifies graphical surface as mesh of Graphical Points, + * which are controlled by NURBS algorithm + * + * @since 2.0 + * + */ +class GraphicalSurfaceNurbs + : public GraphicalSurface +{ +public: + /** + * GraphicalSurfaceNurbs class constructor + * + * @since 2.0 + * + */ + GraphicalSurfaceNurbs(long objID, + long bitmapID_, + int dimCtrlX_, + int dimCtrlY_, + int orderX_, + int orderY_, + int dimGraphX_, + int dimGraphY_, + std::unique_ptr pKnotsX_, + std::unique_ptr pKnotsY_, + float transparency_); + + /** + * GraphicalSurfaceNurbs class destructor + * + * @since 2.0 + * + */ + virtual ~GraphicalSurfaceNurbs(void); + + /** + * Empty function for this class (should be implemented because it is abstract in base class) + * + * @since 2.0 + * + */ + virtual void Calculate(float timeStep); + + /** + * Provides reading access to GraphicalSurfaceNurbs's properties values from user's scripts + * + * @since 2.0 + * + */ + virtual PropertyCast GetProperty(ElementProperty propName) const; + + /** + * Provides writing access to GraphicalSurfaceNurbs's properties values of + * boolean type from user's scripts + * + * @since 2.0 + * + */ + virtual bool SetProperty(ElementProperty propName, bool propValue); + + /** + * Provides writing access to GraphicalSurfaceNurbs's properties values of + * lua_Number type (floating point or integer) from user's scripts + * + * @since 2.0 + * + */ + virtual bool SetProperty(ElementProperty propName, LUA_NUMBER propValue); + + /** + * Provides writing access to GraphicalSurfaceNurbs's properties values of + * Vec3f type from user's scripts + * + * @since 2.0 + * + */ + virtual bool SetProperty(ElementProperty propName, const Tizen::Ui::Effects::_Utils::Vec3f &propValue); + + /** + * Initializes GraphicalSurfaceNurbs's internal parameters and resets accumulated parameters to zero + * + * @since 2.0 + * + */ + virtual void Initialize(void); + + /** + * Synchronizes the render data (vertexes and normals) and physical (PointSurfaceNURBS) points; + * recalculates the normals for vertexes + * + * @since 2.0 + * + * @remarks Must be called after CalcIndices and CalcNURBSCoeffs functions + */ + virtual void Update(void); + + /** + * It is performed after building objects for creating links between them; prepares class instance to work + * + * @since 2.0 + * + * @remarks Specifies connections with pointSurfaceNURBS objects, + * performs indexes, NURBS coefficients, texture coordinates calculation, + * constructs render data collection + */ + virtual void Construct(TypeElemSurfaceCollection* pElemSurfaceCollection, RenderDataSurfaceCollection* pRenderDataSurfaceCollection); + + /** + * Gets object's type + * + * @since 2.0 + * + */ + virtual ESurface GetType(void) const; + + /** + * Returns the vector of vectors of nearest points to specified point of graphical surface + * + * @since 2.0 + * + */ + virtual PropertyCast GetNearestPointsIds(Tizen::Ui::Effects::_Utils::Vec3f &position) const; + + /** + * Rotates model matrix by Angle around Axis or (ax, ay, az) in case Axis=AXIS_ARBITRARY + * + * @since 2.0 + * + * @param [in] Point: Base point for rotation (the coordinates of this point are not changed) + * @param [in] ax, ay, az: The coordinates of axis around which rotation is performed (in case Axis=AXIS_ARBITRARY) + * @param [in] x0, y0, z0: Base point coordinates in case point=POINT_ARBITRARY + */ + virtual bool RotateSurface(float angle, _Axis axis, _Point point, + float ax, float ay, float az, float x0, float y0, float z0); + + /** + * Scales model matrix by multipliers ax, ay, az on the relevant axes + * with base Point or (x0, y0, z0) in case Point = POINT_ARBITRARY + * + * @since 2.0 + * + * @remarks Note that the base point coordinates do not change + */ + virtual bool ScaleSurface(float ax, float ay, float az, _Point point, + float x0, float y0, float z0); + +protected: + +private: + /** + * Hidden copy constructor + * + * @since 2.0 + * + */ + GraphicalSurfaceNurbs(const GraphicalSurfaceNurbs& rhs); + + /** + * Hidden assignment operator + * + * @since 2.0 + * + */ + GraphicalSurfaceNurbs &operator=(const GraphicalSurfaceNurbs& rhs); + + /** + * Basis function of rational B-spline (NURBS) to the relevant direction + * + * @since 2.0 + * + */ + float NurbsSingleBasisFunction(long i, long order, float u, const TypeKnots& knots) const; + + /** + * Denominator in formula for NURBS coefficients calculation (see NURBS theory) + * + * @since 2.0 + * + */ + float SummaryForNurbs(float u, float w) const; + + /** + * NURBS coefficients calculation + * + * @since 2.0 + * + * @remarks Is performed once in construct function + */ + void CalculationNurbsCoefficients(void); + + /** + * Applying the threshold to NURBS coefficients: + * if the absolute value of some coefficient less or equals to threshold, + * then this coefficient is not involved in calculation (is needed for optimization) + * + * @since 2.0 + * + * @remarks Is performed once in construct function after calculation NURBS coefficients + */ + void WeightsApplyThreshold(float threshold); + + /** + * Calculation of triangle indices (is needed for rendering surface) + * + * @since 2.0 + * + * @remarks Is performed once in construct function + */ + void CalcIndices(void); + + /** + * Calculations of normals for vertexes (is needed for surface lighting) + * + * @since 2.0 + * + * @remarks Is performed in update function after points position recalculation + */ + void CalcNormals(void); + + /** + * Calculations of textures coordinates (is needed for surface lighting) + * + * @since 2.0 + * + * @remarks Is performed once in construct function after update + */ + void CalcTexCoords(void); + + /** + * Calculates the point pointOnModel base on value of _Point enumeration. + * + * @since 2.0 + * + * @remarks If _Point is POINT_ARBITRARY then PointOnModel = (x0, y0, z0) + */ + bool DefinePointOnModel(_Point point, Tizen::Ui::Effects::_Utils::Vec3f &pointOnModel, + float x0, float y0, float z0) const; + +private: + int __dimGraphX; /**< number of graphical points on X-direction*/ + int __dimGraphY; /**< number of graphical points on Y-direction*/ + + int __dimCtrlX; /**< number of control points on X-direction*/ + int __dimCtrlY; /**< number of control points on Y-direction*/ + + int __orderX; /**< surface order on X-direction*/ + int __orderY; /**< surface order on Y-direction*/ + + //pointers to knots vectors (see NURBS theory) + //the size of these vectors is equal to the sum of order and control points quantity for corresponding direction + std::unique_ptr __pKnotsX; + std::unique_ptr __pKnotsY; + + std::unique_ptr __pNURBSCoeffsCollection; /**< collection of NURBS coefficients (see NURBS theory) */ + + std::unique_ptr __pPSurfaceNURBSCollection; /**< pointers collection on control points (PointSurfaceNURBS objects) */ + + std::unique_ptr __pCornerPointsGraphSurface; /**< pointers to four corner points of graphical surface */ + std::unique_ptr __pCornerPointsPhysicalSurface; /**< pointers to four corner points of "physical" surface */ + + //pointers collection for returning into scripts; + //[0][0] is a nearest point to specified point, + //[1][...] -- first zone, + //[2][...] -- second zone, etc. + std::unique_ptr __pNearestPointsCollection; + +}; // GraphicalSurfaceNurbs + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_GRAPHICAL_SURFACE_NURBS_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeIEffectModelListener.h b/src/ui/effects/inc/FUiEffects_RuntimeIEffectModelListener.h new file mode 100644 index 0000000..5672c81 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeIEffectModelListener.h @@ -0,0 +1,81 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeIEffectModelListener.h + * @brief This is the header file for the IEffectModelListener class. + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_IEFFECT_MODEL_LISTENER_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_IEFFECT_MODEL_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +/** + * @class IEffectModelListener + * @brief This class is an interface between EffectModel and _EffectImpl + * for handling EffectModel events by _EffectImpl + * + * @since 2.0 + * + */ +class IEffectModelListener +{ +public: + /** + * Class destructor + * + * @since 2.0 + * + */ + virtual ~IEffectModelListener(void) + { + } + + /** + * Informs effect impl about effect model started + * + * @since 2.0 + * + */ + virtual void OnEffectStarted(void) = 0; + + /** + * Informs effect impl about effect model finished and it's results + * + * @since 2.0 + * + */ + virtual void OnEffectFinished(Tizen::Ui::Effects::EffectResult result, const LastShownBitmapIdCollection& bitmapTargetId) = 0; + + /** + * Request to effect impl for bitmap resource updating + * + * @since 2.0 + * + * @return bool true on success and false otherwise + */ + virtual bool OnBitmapRequested(long bitmapId) = 0; + +}; // IEffectModelListener + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_IEFFECT_MODEL_LISTENER_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeIEffectModelManager.h b/src/ui/effects/inc/FUiEffects_RuntimeIEffectModelManager.h new file mode 100644 index 0000000..78ab462 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeIEffectModelManager.h @@ -0,0 +1,162 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeIEffectModelManager.h + * @brief This is the header file for the IEffectModelManager class. + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_IEFFECT_MODEL_MANAGER_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_IEFFECT_MODEL_MANAGER_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +class RenderDataScene; + +/** + * @class IEffectModelManager + * @brief This class is an interface between EffectModel and _EffectImpl + * for handling _EffectImpl events by EffectModel + * + * @since 2.0 + */ +class IEffectModelManager +{ +public: + /** + * Virtual interface destructor + * + * @since 2.0 + * + */ + virtual ~IEffectModelManager(void) + { + } + + /** + * Calls script function OnEffectStart, preparing effect to starting + * + * @since 2.0 + * + */ + virtual int Start(const EffectsVector& effectStartInfo) = 0; + + /** + * Stops effect performing and initializes it + * + * @since 2.0 + * + */ + virtual void Stop(bool isBreakdown, bool isInterruptedFromApplication) = 0; + + /** + * Calculates effect + * + * @since 2.0 + * + */ + virtual void Calculate(float dt) = 0; + + /** + * Event touch pressed handler + * + * @since 2.0 + * + * @remarks It is called from up level from corresponding event handler + */ + virtual void FeedTouchPressEvent(const TouchEventScript &pos3) = 0; + + /** + * Event touch moved handler + * + * @since 2.0 + * + * @remarks It is called from up level from corresponding event handler, + */ + virtual void FeedTouchMoveEvent(const TouchEventScript &pos3) = 0; + + /** + * Event touch released handler + * + * @since 2.0 + * + * @remarks It is called from up level from corresponding event handler, + */ + virtual void FeedTouchReleaseEvent(const TouchEventScript &pos3) = 0; + + /** + * Event touch double pressed handler + * + * @since 2.0 + * + * @remarks It is called from up level from corresponding event handler, + */ + virtual void FeedTouchDoublePressEvent(const TouchEventScript &pos3) = 0; + + /** + * Returns time passed from the effect beginning + * + * @since 2.0 + * + */ + virtual float GetCalculationPeriodForTimer(void) const = 0; + + /** + * Returns current effect state (see enumeration _EffectState) + * + * @since 2.0 + * + */ + virtual _EffectState GetState(void) const = 0; + + /** + * Returns effect behaviour type (see enumeration EffectType) + * + * @since 2.0 + * + */ + virtual EffectType GetType(void) const = 0; + + /** + * Returns the pointer to collection of structure RenderData elements + * to up level (to renderer) + * + * @since 2.0 + * + * @remarks The size of this collection is equal to quantity of graphical surfaces; + * this function is called once from up level for renderer + */ + virtual RenderDataScene* GetRenderingData(void) const = 0; + + /** + * Updates all graphical surfaces + * + * @since 2.0 + * + * @remarks It is called by renderer timer + * for updating graphical points + */ + virtual void UpdateGraphicalSurfaces(void) = 0; + + virtual long GetId(void) const = 0; + virtual std::string GetName(void) const = 0; + +}; // IEffectModelManager + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_IEFFECT_MODEL_MANAGER_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeIEffectModelScript.h b/src/ui/effects/inc/FUiEffects_RuntimeIEffectModelScript.h new file mode 100644 index 0000000..ec138dd --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeIEffectModelScript.h @@ -0,0 +1,260 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeIEffectModelScript.h + * @brief This is the header file for the IEffectModelScript class. + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_IEFFECT_MODEL_SCRIPT_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_IEFFECT_MODEL_SCRIPT_H_ + +#include "utils/FUiEffects_Utils.h" + +namespace _Utils { template class LuaMat4; } + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +class UnitLight; + +/** + * @class IEffectModelScript + * @brief This class is an interface between ScriptProcessing and EffectModel – + * API for EffectModel access from user's scripts + * + * @since 2.0 + * + */ +class IEffectModelScript +{ + +public: + /** + * Class destructor + * + * @since 2.0 + * + */ + virtual ~IEffectModelScript(void) + { + } + + /** + * Called by ScriptProcessing to modify the element's property of boolean type + * + * @since 2.0 + * + */ + virtual bool ScriptSetProperty(long objID, ElementProperty property, bool value) = 0; + + /** + * Called by ScriptProcessing to modify the element's property of lua_Number type + * (floating point or integer) + * + * @since 2.0 + * + */ + virtual bool ScriptSetProperty(long objID, ElementProperty property, LUA_NUMBER value) = 0; + + /** + * Called by ScriptProcessing to modify the element's property of Vec3f type + * + * @since 2.0 + * + */ + virtual bool ScriptSetProperty(long objID, ElementProperty property, const Tizen::Ui::Effects::_Utils::Vec3f &value) = 0; + + /** + * Called by ScriptProcessing to modify some group of elements + * for specified model surface + * + * @since 2.0 + * + */ + virtual bool ScriptSetPropertyGroup(long modelSurfaceID, GroupElements group, ElementProperty property, LUA_NUMBER value) = 0; + + /** + * Called by ScriptProcessing to get distance from ground for model surface + * + * @since 2.0 + * + */ + virtual PropertyCast ScriptGetDistanceFromGround(long modelSurfaceID) const = 0; + + /** + * Called by ScriptProcessing to get the element's property of any type, + * specified in class PropertyCast + * + * @since 2.0 + * + */ + virtual PropertyCast ScriptGetProperty(long objID, ElementProperty property) const = 0; + + /** + * Called by ScriptProcessing to modify bitmap resource + * + * @since 2.0 + * + */ + virtual bool ScriptUpdateBitmap(long graphicalSurfaceID, long bitmapID) = 0; + + /** + * Called by ScriptProcessing to get the IDs of vector of vectors of nearest points for specified GraphicalSurface + * + * @since 2.0 + * + */ + virtual PropertyCast ScriptGetNearestPointsIds(long graphicalSurfaceID, Tizen::Ui::Effects::_Utils::Vec3f &position) const = 0; + + /** + * Called by ScriptProcessing to modify model matrix (rotation) + * + * @since 2.0 + * + */ + virtual bool ScriptRotateSurface(long graphicalSurfaceID, float angle, _Axis axis, _Point point, + float ax, float ay, float az, float x0, float y0, float z0) = 0; + + /** + * Called by ScriptProcessing to modify model matrix (scaling) + * + * @since 2.0 + * + */ + virtual bool ScriptScaleSurface(long graphicalSurfaceID, float ax, float ay, float az, _Point point, + float x0, float y0, float z0) = 0; + + /** + * Called by ScriptProcessing to modify model matrix (translating) + * + * @since 2.0 + * + */ + virtual bool ScriptMoveSurface(long graphicalSurfaceID, float x0, float y0, float z0) = 0; + + /** + * Called by ScriptProcessing to modify model matrix (sets identity matrix) + * + * @since 2.0 + * + */ + virtual bool ScriptResetSurfaceTransformation(long graphicalSurfaceID) = 0; + + /** + * Called by ScriptProcessing to modify model matrix + * + * @since 2.0 + * + */ + virtual bool ScriptSetTransformationMatrix(long graphicalSurfaceID, const Tizen::Ui::Effects::_Utils::LuaMatrix4& luaMatrix4) = 0; + + /** + * Adds new unit light to scene + * + * @since 2.0 + * + * @remarks Returns true if addition was succeeded and false otherwise + */ + virtual bool ScriptAddUnitLight(UnitLight& unitLight) = 0; + + /** + * Excludes specified unit light from scene with using unique name of it + * + * @since 2.0 + * + * @remarks Returns true if addition was succeeded and false otherwise + */ + virtual bool ScriptRemoveUnitLight(const std::string& name) = 0; + + /** + * Excludes all units light of specified type from scene + * + * @since 2.0 + * + * @remarks Returns true if addition was succeeded and false otherwise + */ + virtual bool ScriptRemoveAllUnitsLightType(TypeUnitLight typeUnitLight) = 0; + + /** + * Returns specified unit light with using unique name of it + * + * @since 2.0 + * + */ + virtual PropertyCast ScriptGetUnitLight(const std::string& name) const = 0; + + /** + * Sets ambient colour for scene + * + * @since 2.0 + * + */ + virtual void ScriptSetLightAmbientColour(const Tizen::Ui::Effects::_Utils::Vec3f& ambientColour) = 0; + + /** + * Sets ambient colour for scene + * + * @since 2.0 + * + */ + virtual void ScriptSetLightAmbientColour(float red, float green, float blue) = 0; + + /** + * Sets light intensity for scene + * + * @since 2.0 + * + */ + virtual void ScriptSetLightIntensity(float intensity) = 0; + + /** + * Sets attenuation for units light on scene + * + * @since 2.0 + * + */ + virtual void ScriptSetLightAttenuation(float attenuation) = 0; + + /** + * Returns ambient colour of scene + * + * @since 2.0 + * + */ + virtual const Tizen::Ui::Effects::_Utils::Vec3f& ScriptGetLightAmbientColour(void) const = 0; + + /** + * Returns light intensity of scene + * + * @since 2.0 + * + */ + virtual float ScriptGetLightIntensity(void) const = 0; + + /** + * Returns attenuation for units light on scene + * + * @since 2.0 + * + */ + virtual float ScriptGetLightAttenuation(void) const = 0; + +}; // IEffectModelScript + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_IEFFECT_MODEL_SCRIPT_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeIScriptProcessing.h b/src/ui/effects/inc/FUiEffects_RuntimeIScriptProcessing.h new file mode 100644 index 0000000..b9fa799 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeIScriptProcessing.h @@ -0,0 +1,124 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeIScriptProcessing.h + * @brief This is the header file for the IScriptProcessing class. + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_ISCRIPT_PROCESSING_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_ISCRIPT_PROCESSING_H_ + +#include +#include +#include "FUiEffects_RuntimeModel.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +/** + * @class IScriptProcessing + * @brief This class is an interface between EffectModel and ScriptProcessing module - + * for calling script functions by EffectModel + * + * @since 2.0 + * + */ +class IScriptProcessing +{ + +public: + /** + * Class destructor + * + * @since 2.0 + * + * @remarks In case if in the future be needed do the memory allocation of + * class-inheritor under the pointer to base class (memory leak prevention) + */ + virtual ~IScriptProcessing(void) + { + } + + /** + * Calls Initialize script function for Initialize event handling + * + * @since 2.0 + * + */ + virtual bool Initialize(void) = 0; + + /** + * Calls OnEffectStart script function for OnEffectStart event handling + * + * @since 2.0 + * + */ + virtual bool OnEffectStart(const EffectsVector& effectStartInfo) = 0; + + /** + * Calls OnEffectCalculate script function for OnEffectCalculate event handling + * + * @since 2.0 + * + */ + virtual bool OnEffectCalculate(float dt) = 0; + + /** + * Calls OnTouchPressed script function for OnTouchPressed event handling + * + * @since 2.0 + * + */ + virtual bool OnTouchPressed(const TouchEventScript &position) = 0; + + /** + * Calls OnTouchDoublePressed script function for OnTouchDoublePressed event handling + * + * @since 2.0 + * + */ + virtual bool OnTouchDoublePressed(const TouchEventScript &position) = 0; + + /** + * Calls OnTouchMoved script function for OnTouchMoved event handling + * + * @since 2.0 + * + */ + virtual bool OnTouchMoved(const TouchEventScript &position) = 0; + + /** + * Calls OnTouchReleased script function for OnTouchReleased event handling + * + * @since 2.0 + * + */ + virtual bool OnTouchReleased(const TouchEventScript &position) = 0; + + /** + * Calls IsEffectFinished script function for IsEffectFinished event handling + * + * @since 2.0 + * + */ + virtual ::Tizen::Ui::Effects::_Runtime::EffectResultS IsEffectFinished(void) = 0; + +}; // IScriptProcessing + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_ISCRIPT_PROCESSING_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeLuaProcessing.h b/src/ui/effects/inc/FUiEffects_RuntimeLuaProcessing.h new file mode 100644 index 0000000..1466d5c --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeLuaProcessing.h @@ -0,0 +1,215 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeLuaProcessing.h + * @brief This is the header file for the LuaProcessing class. + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_LUA_PROCESSING_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_LUA_PROCESSING_H_ + +#include +#include +#include +#include +#include +#include +#include "FUiEffects_RuntimeIScriptProcessing.h" +#include "FUiEffects_RuntimeModel.h" +#include "FUiEffects_RuntimeEffectModelScript.h" +#include "FUiEffects_RuntimeIEffectModelScript.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +struct LuaClose +{ + void operator()(lua_State* pLua) const + { + lua_close(pLua); + } +}; + +class EffectModel; +class EffectModelScript; + +/** + * @class LuaProcessing + * @brief This class executes relevant lua script functions + * + * @since 2.0 + * + */ +class LuaProcessing + : public IScriptProcessing +{ + +public: + /** + * LuaProcessing default class constructor + * + * @since 2.0 + * + */ + LuaProcessing(void); + + /** + * LuaProcessing class constructor + * + * @since 2.0 + * + */ + LuaProcessing(const char* pPathToScript, IEffectModelScript* pEModel); + + /** + * LuaProcessing class destructor + * + * @since 2.0 + * + */ + virtual ~LuaProcessing(void); + + /** + * Calls OnEffectStart function from script + * + * @since 2.0 + * + * @remarks Function is inherited from IScriptProcessing interface; + * if script function performs successfully (with no errors), + * the function returns true, otherwise returns false + */ + virtual bool OnEffectStart(const EffectsVector& effectStartInfo); + + /** + * Calls OnEffectCalculate function from script + * + * @since 2.0 + * + * @remarks Function is inherited from IScriptProcessing interface; + * if script function performs successfully (with no errors), + * the function returns true, otherwise returns false + */ + virtual bool OnEffectCalculate(float dt); + + /** + * Calls OnTouchPressed function from script for handling touch pressed event + * + * @since 2.0 + * + * @remarks Function is inherited from IScriptProcessing interface; + * if script function performs successfully (with no errors), + * the function returns true, otherwise returns false + */ + virtual bool OnTouchPressed(const TouchEventScript& position); + + /** + * Calls OnTouchDoublePressed function from script for handling touch double pressed event + * + * @since 2.0 + * + * @remarks Function is inherited from IScriptProcessing interface; + * if script function performs successfully (with no errors), + * the function returns true, otherwise returns false + */ + virtual bool OnTouchDoublePressed(const TouchEventScript& position); + + /** + * Calls OnTouchMoved function from script for handling touch moved event + * + * @since 2.0 + * + * @remarks Function is inherited from IScriptProcessing interface; + * if script function performs successfully (with no errors), + * the function returns true, otherwise returns false + */ + virtual bool OnTouchMoved(const TouchEventScript& position); + + /** + * Calls OnTouchReleased function from script for handling touch released event + * + * @since 2.0 + * + * @remarks Function is inherited from IScriptProcessing interface; + * if script function performs successfully (with no errors), + * the function returns true, otherwise returns false + */ + virtual bool OnTouchReleased(const TouchEventScript& position); + + /** + * Calls IsEffectFinished function from script + * + * @since 2.0 + * + */ + virtual ::Tizen::Ui::Effects::_Runtime::EffectResultS IsEffectFinished(void); + + /** + * Calls Initialize function from script + * + * @since 2.0 + * + * @remarks Function is inherited from IScriptProcessing interface; + * if script function performs successfully (with no errors), + * the function returns true, otherwise returns false + */ + virtual bool Initialize(void); + +private: + /** + * Hidden copy constructor + * + * @since 2.0 + * + */ + LuaProcessing(const LuaProcessing& rhs); + + /** + * Hidden assignment operator + * + * @since 2.0 + * + */ + LuaProcessing &operator=(const LuaProcessing& rhs); + + /** + * Auxiliary function for calling touch events handling script functions + * + * @since 2.0 + * + */ + bool OnTouchEvent(const char* pFunName, const TouchEventScript& position); + + /** + * Function for calling lua script function + * + * @since 2.0 + * + */ + static int CallFunction(const char* pFunctionName, int argsCount, int resultsCount, lua_State* pLua); + +private: + + std::unique_ptr __pLua; /**< pointer to structure that keeps the whole state of a Lua interpreter*/ + std::unique_ptr __pEMScript; /**< pointer to instance of class EffectModelScript (for calling C++ functions from scripts)*/ + + static const char* __pStringLua; /**< contains a simple lua code for transmitting to lua-global variable the pointer to EffectModelScript (performs once in constructor)*/ + +}; // LuaProcessing + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_LUA_PROCESSING_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeModel.h b/src/ui/effects/inc/FUiEffects_RuntimeModel.h new file mode 100644 index 0000000..56f05bf --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeModel.h @@ -0,0 +1,273 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeModel.h + * @brief This file contains the basic enumerations and structures for working with model + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_MODEL_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_MODEL_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +const float EFFECT_EPSILONF = std::numeric_limits::epsilon(); + +//tolua_begin <--(!do not edit!)the beginning of export part to lua + +enum TypeUnitLight +{ + TYPE_UNIT_LIGHT_POINT, + TYPE_UNIT_LIGHT_SPOT, + TYPE_UNIT_LIGHT_DIRECTIONAL +}; + +/** +* @enum _EffectResult +* +* Defines possible options of Effect finishing +* @since 2.0 +*/ +enum _EffectResult +{ + EFFECT_CONTINUED = 1, // Effect continued + EFFECT_FINISHED // Effect finished +}; //_EffectResult + +/** +* @enum ElementProperty +* +* For access to Effect's objects property (read, write) from scripts +* @since 2.0 +* +*/ +enum ElementProperty +{ + //PointSurface property: + B_IS_FIXED, /**< Boolean property is involved into physics calculation*/ + N_POS_X, /**< Numeric property: the X coordinate of point*/ + N_POS_Y, /**< Numeric property: the Y coordinate of point*/ + N_POS_Z, /**< Numeric property: the Z coordinate of point*/ + N_POS_X_INIT, /**< Numeric property: the initial X coordinate of point*/ + N_POS_Y_INIT, /**< Numeric property: the initial Y coordinate of point*/ + N_POS_Z_INIT, /**< Numeric property: the initial Z coordinate of point*/ + N_MASS, /**< Numeric property: the mass of point*/ + N_FUSER_X, /**< Numeric property: the X coordinate of user force*/ + N_FUSER_Y, /**< Numeric property: the Y coordinate of user force*/ + N_FUSER_Z, /**< Numeric property: the Z coordinate of user force*/ + N_POINT_RESISTANCE, /**< Numeric property: the resistance of point movement*/ + V_POS, /**< Userdata property (Vector3): the position of point*/ + V_POS_INIT, /**< Userdata property (Vector3): the initial position of point*/ + V_FUSER, /**< Userdata property (Vector3): the user force vector*/ + + //PointSurfaceNURBS property: + N_NURBS_WEIGHT, /**< Numeric property: the weight of point (for rendering)*/ + + //RodSurface and SpringSurface property: + N_STIFFNESS, /**< Numeric property: the stiffness of spring or rod*/ + + //ModelSurface property: + N_ENV_RESISTANCE, /**< Numeric property: the environment resistance to movement*/ + N_NUMBER_ITERATIONS, /**< Numeric property: number of iterations per one calculation event (not change speed, but more stability)*/ + N_MODEL_SPEED, /**< Numeric property: model speed as animation multiplier*/ + N_GRAVITY_ACCEL_VALUE, /**< Numeric property: the length of gravity acceleration vector*/ + V_GRAVITY_ACCELERATION, /**< Numeric property: gravity acceleration*/ + + //GraphicalSurface property: + N_TRANSPARENCY, /**< Numeric property: the surface transparency (from 0 (no transparency) to 1)*/ + + //EffectModel property + N_EFFECT_TIME_PASSED, /**< Numeric property: time passed from effect beginning*/ + N_EFFECT_DURATION /**< Numeric property: effect duration time*/ + +}; // ElementProperty + + +/** +* @enum GroupElements +* +* Enumeration for choosing specified group of elements. @n +* For example, is used in function SetPropertyGroup for denoting of group +* @since 2.0 +*/ +enum GroupElements +{ + ALL_POINTS, /**< means that property will be applied for all points in the model*/ + ALL_SPRINGS, /**< means that property will be applied for all springs in the model*/ + ALL_RODS /**< means that property will be applied for all rods in the model*/ +}; // GroupElements + +/** +* @enum _Axis +* +* enumeration for choosing specified axis for rotation around it +* @since 2.0 +*/ +enum _Axis +{ + AXIS_X, /**< denote the X axis */ + AXIS_Y, /**< denote the Y axis */ + AXIS_Z, /**< denote the Z axis */ + AXIS_ARBITRARY /**< for denoting arbitrary axis (in case then user may set own arbitrary axis) */ +}; // _Axis + +/** +* @enum _Point +* +* Enumeration for base point on graphical surface specification @n +* for using in various transformations such as rotation and scaling +* @since 2.0 +* +*/ +enum _Point +{ + POINT_LEFT_TOP, /**< left of horizontal and top of vertical point on a rectangular graphical surface */ + POINT_CENTER_TOP, /**< center of horizontal and top of vertical point on a rectangular graphical surface */ + POINT_RIGHT_TOP, /**< right of horizontal and top of vertical point on a rectangular graphical surface */ + POINT_LEFT_CENTER, /**< left of horizontal and center of vertical point on a rectangular graphical surface */ + POINT_CENTER_CENTER, /**< center of horizontal and center of vertical point on a rectangular graphical surface */ + POINT_RIGHT_CENTER, /**< right of horizontal and center of vertical point on a rectangular graphical surface */ + POINT_LEFT_BOTTOM, /**< left of horizontal and bottom of vertical point on a rectangular graphical surface */ + POINT_CENTER_BOTTOM, /**< center of horizontal and bottom of vertical point on a rectangular graphical surface */ + POINT_RIGHT_BOTTOM, /**< right of horizontal and bottom of vertical point on a rectangular graphical surface */ + POINT_ARBITRARY /**< means that user may specify arbitrary point by it's coordinates */ +}; // _Point + + +/** +* @class TouchEventScript +* +* Structure for working in scripts-handlers of user's touch events +* +* @since 2.0 +* +*/ +struct TouchEventScript +{ + //tolua_end + Tizen::Ui::Effects::_Utils::Vec3f currentPosition; /**< current position in touch event info */ + Tizen::Ui::Effects::_Utils::Vec3f startPosition; /**< first position in touch event info */ + unsigned long touchId; + //tolua_begin +#if 0 + Vector3 currentPosition; // for export to lua, must be ignored by c++ compiler + Vector3 startPosition; // for export to lua, must be ignored by c++ compiler + unsigned long touchId; // for export to lua, must be ignored by c++ compiler +#endif +}; // TouchEventScript +//tolua_end <--(!do not edit!)the ending of export part to lua + +/** +* @enum _EffectState +* +* Defines all possible states of an effect +* @since 2.0 +* +*/ +enum _EffectState +{ + _EFFECT_STATE_RUNNABLE, /**< Ready to start */ + _EFFECT_STATE_RUNNING, /**< Running */ + _EFFECT_STATE_RUNTIME_ERROR, /**< Runtime error occurred */ + _EFFECT_STATE_INITIALIZING, /**< Being initialized */ + _EFFECT_STATE_STARTING, /**< Starting */ + _EFFECT_STATE_FINISHING /**< Finishing */ +}; // _EffectState + +/** +* @enum ESurface +* +* Enumeration for denoting element surface (returning value by function ElementSurface::GetType). @n +* The value sequence is important (see ModelSurface::Construct) +* @since 2.0 +* +*/ +enum ESurface +{ + ESURFACE_MODEL_SURFACE = 0, + ESURFACE_GRAPHICAL_SURFACE, + ESURFACE_GRAPHICAL_SURFACE_NURBS, + ESURFACE_SPRING_SURFACE, + ESURFACE_ROD_SURFACE, + ESURFACE_POINT_SURFACE, + ESURFACE_POINT_SURFACE_NURBS +}; // ESurface + + +typedef std::list LastShownBitmapIdCollection; + +/** +* @class EffectResultS +* +* Structure is used in EffectModel instances for runtime result storage +* +* @since 2.0 +* +*/ +struct EffectResultS +{ + EffectResultS(Tizen::Ui::Effects::EffectResult effectResult_ = static_cast(0), + LastShownBitmapIdCollection lastShownBitmapsId_ = LastShownBitmapIdCollection(1, -1)) + : effectResult(effectResult_) + , lastShownBitmapsId(lastShownBitmapsId_) + { + } + + Tizen::Ui::Effects::EffectResult effectResult; + LastShownBitmapIdCollection lastShownBitmapsId; +}; + +template class EffectsVector + : public std::vector +{ +public: + explicit EffectsVector(void) : std::vector() + { + } + + explicit EffectsVector(long n, const T& value = T()) : std::vector(n, value) + { + } + + EffectsVector(const EffectsVector& rhs) :std::vector(rhs) + { + } + + template + EffectsVector(InputIterator first, InputIterator last) : std::vector(first, last) + { + } + + virtual ~EffectsVector(void) + { + } + + long GetSize(void) const + { + return this->size(); + } +}; + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_MODEL_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeModelSurface.h b/src/ui/effects/inc/FUiEffects_RuntimeModelSurface.h new file mode 100644 index 0000000..1010833 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeModelSurface.h @@ -0,0 +1,275 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeModelSurface.h + * @brief This is the header file for the ModelSurface class. + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_MODEL_SURFACE_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_MODEL_SURFACE_H_ + +#include +#include +#include "FUiEffects_RuntimeEffectModel.h" +#include "FUiEffects_RuntimeRenderDataSurface.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ +class PointSurface; +class SpringSurface; +class RodSurface; +} } } } // Tizen::Ui::Effects:_PhysicsEngine + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +class GraphicalSurface; + +/** + * The list type for storing ElementSurface pointers. + * + * @since 2.0 + * + */ +typedef std::list TypeElemSurfaceCollection; + +/** + * The list type for storing PointSurface pointers. + * + * @since 2.0 + * + */ +typedef std::list TypePointSurfaceCollection; + +/** + * The list type for storing SpringSurface pointers. + * + * @since 2.0 + * + */ +typedef std::list TypeSpringSurfaceCollection; + +/** + * The list type for storing RodSurface pointers. + * + * @since 2.0 + * + */ +typedef std::list TypeRodSurfaceCollection; + +struct ElementsSurfaceContainerDeleter +{ + void operator()(TypeElemSurfaceCollection* pElemSurfaceCollection); +}; + +/** + * @class ModelSurface + * @brief This class contains one 3D object + * + * @since 2.0 + */ +class ModelSurface + : public ::Tizen::Ui::Effects::_PhysicsEngine::ElementSurface +{ +public: + /** + * ModelSurface class constructor + * + * @since 2.0 + * + */ + ModelSurface(long objId, + unsigned short iterationCount_, + unsigned short modelSpeed_, + float envResistance_, + const Tizen::Ui::Effects::_Utils::Vec3f &gravityAccelerationIdentity_, + float gravityAccelerationValue_, + float groundLevel_); + + /** + * ModelSurface class destructor + * + * @since 2.0 + * + */ + virtual ~ModelSurface(void); + + /** + * Sends to all element surfaces event Calculate + * + * @since 2.0 + * + */ + virtual void Calculate(float timeStep); + + /** + * Returns specified property value of any type (see class PropertyCast) + * + * @since 2.0 + * + */ + virtual PropertyCast GetProperty(ElementProperty propName) const; + + /** + * Sets ModelSurface's property which is specified in enumeration ElementProperty + * of boolean type + * + * @since 2.0 + * + */ + virtual bool SetProperty(ElementProperty propName, bool propValue); + + /** + * Sets ModelSurface's property which is specified in enumeration ElementProperty + * of floating point type (float or integer) + * + * @since 2.0 + * + */ + virtual bool SetProperty(ElementProperty propName, LUA_NUMBER propValue); + + /** + * Sets ModelSurface's property which is specified in enumeration ElementProperty + * of Vector3 type + * + * @since 2.0 + * + */ + virtual bool SetProperty(ElementProperty propName, const Tizen::Ui::Effects::_Utils::Vec3f &propValue); + + /** + * Sets specified property value for group of elements + * + * @since 2.0 + * + * @remarks Returns true if setting was successful and false otherwise + */ + bool SetPropertyGroup(GroupElements group, ElementProperty property, LUA_NUMBER value); + + /** + * Sends event Initialize to all elements of the surface + * + * @since 2.0 + * + */ + virtual void Initialize(void); + + /** + * Gets object's type + * + * @since 2.0 + * + */ + virtual ESurface GetType(void) const; + + /** + * GraphicalSurface object assigning during register effect file procedure + * + * @since 2.0 + * + */ + void AddGraphicalSurface(std::unique_ptr pGraphicalSurface); + + /** + * ElementSurface object addition during register effect file procedure + * + * @since 2.0 + * + */ + void AddElementSurface(::Tizen::Ui::Effects::_PhysicsEngine::ElementSurface* pElementSurface); + + /** + * Constructs the elements map for fast searching object in EffectModel, + * constructs RenderDataSurfaceCollection object, + * links the ModelSurface and PointSurface instances + * + * @since 2.0 + * + * @remarks Must be called after parser performing + */ + bool Construct(TypeMapElements* pMapElements, TypeMapGSurface* pMapGSurface, RenderDataSurfaceCollection* pRenderDataSurfaceCollection); + + /** + * Transmits event UpdateGraphicalSurface from EffectModel to GraphicalSurface + * + * @since 2.0 + * + * @remarks It is called from EffectModel by timer + * for building graphical points based on physical points + */ + void UpdateGraphicalSurface(void); + + /** + * Calculates distance from this model surface to its ground level + * + * @since 2.0 + * + */ + float GetDistanceFromGround(void) const; + +private: + /** + * Hidden copy constructor + * + * @since 2.0 + * + */ + ModelSurface(const ModelSurface& rhs); + + /** + * Hidden assignment operator + * + * @since 2.0 + * + */ + ModelSurface &operator=(const ModelSurface& rhs); + + /** + * Sets specified property value for group of elements + * + * @since 2.0 + * + * @return Returns true if setting was successful and false otherwise + * @remarks Is needed for internal use only + */ + template + bool SetPropertyGroup(T* pDataPointer, ElementProperty property, LUA_NUMBER value); + +private: + + std::unique_ptr __pElemSurfaceCollection; /**< collection of surface elements (3D object)*/ + + std::unique_ptr __pGraphicalSurface; /**< pointer to graphical surface*/ + + unsigned short __iterationCount; /**< number of iterations per one calculation event (no speed change, but more stability)*/ + unsigned short __modelSpeed; /**< model speed as animation multiplier*/ + + float __envResistance; /**< environment resistance (for physics calculation)*/ + Tizen::Ui::Effects::_Utils::Vec3f __gravityAccelerationIdentity; /**< identity vector (length of vector equals 1) of gravity acceleration (for physics calculation)*/ + float __gravityAccelerationValue; /**< length of gravity acceleration vector (for physics calculation)*/ + Tizen::Ui::Effects::_Utils::Vec3f __gravityAccelerationVector; /**< gravity acceleration vector (for physics calculation)*/ + float __groundLevel; + + std::unique_ptr __pPointsCollection; /**< pointers collection to model surface points*/ + std::unique_ptr __pSpringsCollection; /**< pointers collection to model surface springs*/ + std::unique_ptr __pRodsCollection; /**< pointers collection to model surface rods*/ + +}; // ModelSurface + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_MODEL_SURFACE_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimePointLight.h b/src/ui/effects/inc/FUiEffects_RuntimePointLight.h new file mode 100644 index 0000000..a402761 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimePointLight.h @@ -0,0 +1,164 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimePointLight.h + * @brief This is the header file for a point light + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_POINT_LIGHT_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_POINT_LIGHT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +//tolua_begin <--(!do not edit!)the beginning of export part to lua +class PointLight + : public UnitLight +{ +//tolua_end <--(!do not edit!)the ending of export part to lua +public: + + /** + * Returns a pointer to created point light + * + * @since 2.0 + * + */ + static PointLight* CreatePointLight(const std::string& name); +#if 0 + static PointLight* CreatePointLight(const string& name); //tolua_export <--(!do not edit!)the exporting line to lua +#endif + + /** + * Returns a pointer to created point light + * + * @since 2.0 + * + */ + static PointLight* CreatePointLight(bool enabled, + const std::string& name, + const Tizen::Ui::Effects::_Utils::Vec3f& colour, + float intensity, + const Tizen::Ui::Effects::_Utils::Vec3f& position); + + /** + * Returns a position of a point light + * + * @since 2.0 + * + */ + const Tizen::Ui::Effects::_Utils::Vec3f& GetPosition(void) const; +#if 0 + const Vector3& GetPosition(void) const; //tolua_export <--(!do not edit!)the exporting line to lua +#endif + + /** + * Sets a position for a point light + * + * @since 2.0 + * + */ + void SetPosition(const Tizen::Ui::Effects::_Utils::Vec3f& position); +#if 0 + void SetPosition(const Vector3& position); //tolua_export <--(!do not edit!)the exporting line to lua +#endif + + /** + * Sets a position for a point light + * + * @since 2.0 + * + */ + void SetPosition(float x, float y, float z); //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Returns a type of a point light as variable of enumeration type + * + * @since 2.0 + * + */ + virtual TypeUnitLight GetType(void) const; + + /** + * Resets all signs for this instance of class (e.g. isPositionChanged, isColourChanged) + * + * @since 2.0 + * + */ + virtual void ResetSigns(void); + +protected: + + /** + * Class constructor + * + * @since 2.0 + * + * @remarks Clients of this class can create PointLight objects with using Create methods only + * + */ + PointLight(const std::string& name); + + /** + * Class constructor + * + * @since 2.0 + * + * @remarks Clients of this class can create PointLight objects with using Create methods only + * + */ + PointLight(bool enabled, + const std::string& name, + const Tizen::Ui::Effects::_Utils::Vec3f& colour, + float intensity, + const Tizen::Ui::Effects::_Utils::Vec3f& position + ); + + /** + * Class destructor + * + * @since 2.0 + * + * @remarks Clients of this class can not destroy instances of this class (for purpose to avoid the sending an invalid unit light into scene) + * + */ + virtual ~PointLight(void); + +private: + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + PointLight(const PointLight& rhs); + // The implementation of this assignment operator is intentionally blank and declared as private to prohibit copying of objects. + PointLight& operator=(const PointLight& rhs); + +public: + + bool isPositionChanged; + +private: + + Tizen::Ui::Effects::_Utils::Vec3f __position; /**< position of a point light on a scene (scene's coordinates) */ + +}; //PointLight //tolua_export <--(!do not edit!)the exporting line to lua + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif // _FUI_EFFECTS_INTERNAL_RUNTIME_POINT_LIGHT_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimePropertyCast.h b/src/ui/effects/inc/FUiEffects_RuntimePropertyCast.h new file mode 100644 index 0000000..c88fc8f --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimePropertyCast.h @@ -0,0 +1,91 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimePropertyCast.h + * @brief This is the header file for the PropertyCast structure. + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_PROPERTY_CAST_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_PROPERTY_CAST_H_ + +#include +#include +#include + + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +class PointLight; +class SpotLight; +class DirectionalLight; +template class EffectsVector; + +/** + * @struct PropertyCast + * @brief The instances of this structure are needed for + * returning a property value from model to lua + * + * @since 2.0 + * + */ +// tolua_begin <--(!do not edit!)the beginning of export part to lua +struct PropertyCast +{ + enum + { + NO_PROPERTY, /**< means absence property*/ + NUMBER, /**< for parameters of float, double, integer and similar types*/ + BOOL, /**< for parameters of boolean type*/ + VEC3, /**< for parameters of vector3 type*/ + VECTOR_VECTOR, /**< for vector > type from algorithm of finding nearest points to specified*/ + POINT_LIGHT, + SPOT_LIGHT, + DIRECTIONAL_LIGHT + } type; + + union TypeValue + { + LUA_NUMBER numberValue; /**< stores a parameter of float or double, or integer, or similar type*/ + bool boolValue; +// tolua_end <--(!do not edit!)the ending of export part to lua + const _Utils::Vec3f* vec3Value; + const EffectsVector >* vecVecValue; /**< for vector > type from algorithm of finding nearest points to specified*/ +// tolua_begin <--(!do not edit!)the beginning of export part to lua +#if 0 + tolua_readonly Vector3* vec3Value; /**< for lua code, should be ignored by c++ compiler*/ + tolua_readonly EffectsVector >* vecVecValue; /**< for lua code, should be ignored by c++ compiler*/ +#endif +// tolua_end + const PointLight* pPointLight; + const SpotLight* pSpotLight; + const DirectionalLight* pDirectionalLight; +// tolua_begin +#if 0 + PointLight* pPointLight; + SpotLight* pSpotLight; + DirectionalLight* pDirectionalLight; +#endif + }; + + TypeValue value; +}; // PropertyCast +// tolua_end <--(!do not edit!)the ending of export part to lua + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_PROPERTY_CAST_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeRenderDataScene.h b/src/ui/effects/inc/FUiEffects_RuntimeRenderDataScene.h new file mode 100644 index 0000000..ba31695 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeRenderDataScene.h @@ -0,0 +1,322 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeRenderDataScene.h + * @brief This is the header file for the render structures for all scene (for EffectModel instance entire) + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_RENDER_DATA_SCENE_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_RENDER_DATA_SCENE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +class UnitLight; + +class RenderDataScene +{ +public: + + /** + * Adds specified unit light into scene + * + * @since 2.0 + * + * @remarks For using in lua also + * + */ + bool AddUnitLight(UnitLight& unitLight); + + /** + * Excludes specified unit light from scene with using unique unit light name + * + * @since 2.0 + * + * @remarks For using in lua also + * + */ + bool RemoveUnitLight(const std::string& name); + + /** + * Excludes all units light of specified type from scene + * + * @since 2.0 + * + * @remarks For using in lua also + * + */ + bool RemoveAllUnitsLightType(TypeUnitLight typeUnitLight); + + /** + * Returns specified unit light to a client with using unique unit light name + * + * @since 2.0 + * + * @remarks For using in lua also + * + */ + PropertyCast GetUnitLight(const std::string& name) const; + + /** + * Sets ambient colour for entire scene + * + * @since 2.0 + * + * @remarks For using in lua also + * + */ + void SetLightAmbientColour(const Tizen::Ui::Effects::_Utils::Vec3f& ambientColour); + + /** + * Sets ambient colour for entire scene + * + * @since 2.0 + * + * @remarks For using in lua also + * + */ + void SetLightAmbientColour(float red, float green, float blue); + + /** + * Sets light intensity for entire scene + * + * @since 2.0 + * + * @remarks For using in lua also + * + */ + void SetLightIntensity(float intensity); + + /** + * Sets attenuation for units light as environment variable (How far does unit light can light?) + * + * @since 2.0 + * + * @remarks For using in lua also + * + */ + void SetLightAttenuation(float attenuation); + + /** + * Returns attenuation for units light as environment variable + * + * @since 2.0 + * + * @remarks For using in lua also + * + */ + const Tizen::Ui::Effects::_Utils::Vec3f& GetLightAmbientColour(void) const; + + /** + * Returns intensity for units light as environment variable + * + * @since 2.0 + * + * @remarks For using in lua also + * + */ + float GetLightIntensity(void) const; + + /** + * Returns attenuation for units light as environment variable + * + * @since 2.0 + * + * @remarks For using in lua also + * + */ + float GetLightAttenuation(void) const; + + /** + * Returns size of units light container + * + * @since 2.0 + * + * @remarks For working with units light collection + * + */ + long GetSizeUnitLightContainer(void) const; + + /** + * Returns type of current units light from units light container + * + * @since 2.0 + * + * @remarks For working with units light collection + * + */ + TypeUnitLight GetTypeOfCurrentUnitLight(void) const; + + /** + * Returns a pointer to current units light from units light container + * + * @since 2.0 + * + * @remarks For working with units light collection + * + */ + template const T* GetCurrentUnitLight(void) const; + + /** + * Assignments next value for internal iterator for access to next unit light in units light container + * + * @since 2.0 + * + * @remarks For working with units light collection + * Returns true if transition was succeeded and false otherwise + * + */ + bool GoToNextUnitLight(void); + + /** + * Locks units light container for future work with units light from it + * + * @since 2.0 + * + * @remarks For working with units light collection + * Return true if the locking was succeeded and false otherwise + * Without performing this function client can not performs any action on units light from units light container + * + */ + bool LockUnitsLightContainer(void); + + /** + * Unlocks units light container with purpose to prohibit any future actions on units light container + * + * @since 2.0 + * + * @remarks For working with units light collection + * This function calls automatically when client adds or removes some unit light from scene + * + */ + void UnlockUnitsLightContainer(void); + + /** + * Returns true if units light container is locked and false otherwise + * + * @since 2.0 + * + * @remarks For working with units light collection + * + */ + bool GetIsLockedUnitsLightContainer(void) const; + + /** + * Resets all signs for current unit light (e.g. isIntensityChanged, isColourChanged) + * + * @since 2.0 + * + */ + bool ResetSignsCurrentUnitLight(void); + + /** + * Returns a reference to collection of render data for each graphical surface + * + * @since 2.0 + * + */ + RenderDataSurfaceCollection& GetRenderDataSurfaceCollection(void); + +private: + + /** + * Class constructor + * + * @since 2.0 + * + */ + RenderDataScene(void); + + /** + * Class destructor + * + * @since 2.0 + * + */ + ~RenderDataScene(void); + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + RenderDataScene(const RenderDataScene& rhs); + // The implementation of this assignment operator is intentionally blank and declared as private to prohibit copying of objects. + RenderDataScene& operator=(const RenderDataScene& rhs); + + /** + * For internal purposes only + * + * @since 2.0 + * + */ + template const T* GetCurrentUnitLightInternal(void) const; + + /** + * For internal purposes only + * + * @since 2.0 + * + */ + PropertyCast GetConcreteUnitLight(const UnitLight& unitLight) const; + + /** + * For internal purposes only + * + * @since 2.0 + * + */ + void RemoveUnitLight(UnitLight& unitLight); + +public: + + bool isAmbientColourChanged; + bool isIntensityChanged; + bool isAttenuationChanged; + bool isSomethingChanged; + +private: + + typedef std::map UnitLightNameTree; + typedef std::list UnitLightCollection; + + RenderDataSurfaceCollection __renderDataSurfaceCollection; /**< a container of pointers to graphical surfaces render data*/ + + UnitLightCollection __unitsLight; /**< units light container*/ + UnitLightCollection::iterator __iteratorCurrentUnitLight; /**< an iterator to point to current units light*/ + bool __isLockedUnitsLightContainer; /**< is units light container locked or not*/ + + UnitLightNameTree __unitLightNameTree; /*< a map for quick search need unit light with using a name of it */ + + Tizen::Ui::Effects::_Utils::Vec3f __ambientColour; /**< ambient colour*/ + float __intensity; /**< intensity for units light as environment variable*/ + float __attenuation; /**< attenuation for units light as environment variable (this variable has no influence on directionals light)*/ + + friend class EffectModel; //for building the container __renderDataSurfaceCollection + friend class boost::default_delete;//for deleting RenderDataScene instance +}; + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif // _FUI_EFFECTS_INTERNAL_RUNTIME_RENDER_DATA_SCENE_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeRenderDataSurface.h b/src/ui/effects/inc/FUiEffects_RuntimeRenderDataSurface.h new file mode 100644 index 0000000..bf2422d --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeRenderDataSurface.h @@ -0,0 +1,135 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeRenderDataSurface.h + * @brief This is the header file for the RenderData structure + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_RENDER_DATA_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_RENDER_DATA_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +/** + * @struct VertexData + * @brief Structure of vertex attributes + * + * @since 2.0 + * + */ +struct VertexData +{ + static inline unsigned int Stride(void) + { + return sizeof(VertexData); + } + static inline unsigned int OffsetPos(void) + { + return 0; + } + static inline unsigned int OffsetNorm(void) + { + // pos + return sizeof(Tizen::Ui::Effects::_Utils::Vec3f); + } + static inline unsigned int OffsetTexCoords(void) + { + // pos norm + return sizeof(Tizen::Ui::Effects::_Utils::Vec3f) + sizeof(Tizen::Ui::Effects::_Utils::Vec3f); + } + + Tizen::Ui::Effects::_Utils::Vec3f pos; + Tizen::Ui::Effects::_Utils::Vec3f norm; + Tizen::Ui::Effects::_Utils::Vec2f texcoords; +}; // VertexData + +/** +* The vector type for storing position, normal and texture coordinates for point. +* +* @since 2.0 +* +*/ +typedef std::vector VertexDataCollection; + +/** +* The vector type for storing indexes (is needed for triangles rendering by OpenGL). +* +* @since 2.0 +* +*/ +typedef std::vector IndicesCollection; + + +/** + * @struct RenderData + * @brief Data for renderer object. Set value of member XXXChanged to true to indicate, that appropriate @n + * data member had been changed and should be updated. As soon as data becomes updated XXXChanged is set to false by updater + * + * @since 2.0 + * + */ +struct RenderDataSurface +{ + RenderDataSurface(unsigned int sizeVnt, unsigned int sizeIndices): + vertexDataChanged(false), + indicesChanged(false), + modelMtr(Tizen::Ui::Effects::_Utils::Mat4f::getIdentity()), + modelMtrChanged(false), + bitmapId(-1), + bitmapIdChanged(false), + transparency(0.0f), + transparencyChanged(false) + { + VertexData vertexData = {Tizen::Ui::Effects::_Utils::Vec3f(0.f, 0.f, 0.f), + Tizen::Ui::Effects::_Utils::Vec3f(0.f, 0.f, 0.f), + Tizen::Ui::Effects::_Utils::Vec2f(0.f, 0.f)}; + vnt.resize(sizeVnt, vertexData); + indices.resize(sizeIndices, 0); + } + + VertexDataCollection vnt; /**< VertexCoords-Normal-TexCoords per vertex */ + IndicesCollection indices; /**< for triangles construction */ + + bool vertexDataChanged; /**< Indicates changes in vnt data */ + bool indicesChanged; /**< Indicates changes in Indices data */ + + Tizen::Ui::Effects::_Utils::Mat4f modelMtr; /**< Model matrix of an object */ + bool modelMtrChanged; + + long bitmapId; /**< Texture id */ + bool bitmapIdChanged; + + float transparency; /**< Transparency level = [0 .. 1] */ + bool transparencyChanged; +}; // RenderData + +/** +* The vector type for storing RenderData pointers for each graphical surface in model. +* +* @since 2.0 +* +*/ +typedef std::vector RenderDataSurfaceCollection; + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_RENDER_DATA_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeScriptProcessing.h b/src/ui/effects/inc/FUiEffects_RuntimeScriptProcessing.h new file mode 100644 index 0000000..5f24c36 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeScriptProcessing.h @@ -0,0 +1,37 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeScriptProcessing.h + * @brief This file is needed for including in EffectModel.h file + * with an aim to abstracting from usage lua scripts + * (EffectModel may uses any script language) + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_SCRIPT_PROCESSING_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_SCRIPT_PROCESSING_H_ + +#include "FUiEffects_RuntimeLuaProcessing.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +typedef class LuaProcessing ScriptProcessing; + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_SCRIPT_PROCESSING_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeSpotLight.h b/src/ui/effects/inc/FUiEffects_RuntimeSpotLight.h new file mode 100644 index 0000000..202d9b6 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeSpotLight.h @@ -0,0 +1,209 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeSpotLight.h + * @brief This is the header file for a spot light + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_SPOT_LIGHT_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_SPOT_LIGHT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +//tolua_begin <--(!do not edit!)the beginning of export part to lua +class SpotLight + : public PointLight +{ +//tolua_end <--(!do not edit!)the ending of export part to lua +public: + + /** + * Returns a pointer to created spot light + * + * @since 2.0 + * + */ + static SpotLight* CreateSpotLight(const std::string& name); +#if 0 + static SpotLight* CreateSpotLight(const string& name); //tolua_export <--(!do not edit!)the exporting line to lua +#endif + + /** + * Returns a pointer to created spot light + * + * @since 2.0 + * + */ + static SpotLight* CreateSpotLight(bool enabled, + const std::string& name, + const Tizen::Ui::Effects::_Utils::Vec3f& colour, + float intensity, + const Tizen::Ui::Effects::_Utils::Vec3f& position, + const Tizen::Ui::Effects::_Utils::Vec3f& target, + float angleOpening, + float angleFadeOut + ); + + /** + * Returns a target point of a spot (Where does spot shine?) + * + * @since 2.0 + * + */ + const Tizen::Ui::Effects::_Utils::Vec3f& GetTarget(void) const; +#if 0 + const Vector3& GetTarget(void) const; //tolua_export <--(!do not edit!)the exporting line to lua +#endif + + /** + * Returns an opening angle of spot (an angle between opposite forming lines of a spot cone) + * + * @since 2.0 + * + */ + float GetAngleOpening(void) const; //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Returns an angle of fade out for spot + * (an angle between some forming line of a spot cone and a some ray from a position of spot which not lies in spot cone) + * + * @since 2.0 + * + * @remarks This angle determines how spot light attenuates with angle growing if angle is great than angle opening + * + */ + float GetAngleFadeOut(void) const; //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Sets a target point for a spot + * + * @since 2.0 + * + */ + void SetTarget(const Tizen::Ui::Effects::_Utils::Vec3f& target); +#if 0 + void SetTarget(const Vector3& target); //tolua_export <--(!do not edit!)the exporting line to lua +#endif + + /** + * Sets target point for spot + * + * @since 2.0 + * + */ + void SetTarget(float x, float y, float z); //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Sets an angle opening for a spot + * + * @since 2.0 + * + */ + bool SetAngleOpening(float angleOpening); //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Sets an angle of fade out for a spot + * + * @since 2.0 + * + */ + bool SetAngleFadeOut(float angleFadeOut); //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Returns a type of a spot light as variable of enumeration type + * + * @since 2.0 + * + */ + virtual TypeUnitLight GetType(void) const; + + /** + * Resets all signs for this instance of class (e.g. isTargetChanged, isColourChanged) + * + * @since 2.0 + * + */ + virtual void ResetSigns(void); + +protected: + + /** + * Class constructor + * + * @since 2.0 + * + * @remarks Clients of this class can create SpotLight objects with using Create methods only + * + */ + SpotLight(const std::string& name); + + /** + * Class constructor + * + * @since 2.0 + * + * @remarks Clients of this class can create SpotLight objects with using Create methods only + * + */ + SpotLight(bool enabled, + const std::string& name, + const Tizen::Ui::Effects::_Utils::Vec3f& colour, + float intensity, + const Tizen::Ui::Effects::_Utils::Vec3f& position, + const Tizen::Ui::Effects::_Utils::Vec3f& target, + float angleOpening, + float angleFadeOut + ); + + /** + * Class destructor + * + * @since 2.0 + * + * @remarks Clients of this class can not destroy instances of this class (for purpose to avoid the sending an invalid unit light into scene) + * + */ + virtual ~SpotLight(void); + +private: + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + SpotLight(const SpotLight& rhs); + // The implementation of this assignment operator is intentionally blank and declared as private to prohibit copying of objects. + SpotLight& operator=(const SpotLight& rhs); + +public: + + bool isTargetChanged; + bool isAngleOpeningChanged; + bool isAngleFadeOutChanged; + +private: + + Tizen::Ui::Effects::_Utils::Vec3f __target; /**< a target point for a spot (Where does spot shine?) */ + float __angleOpening; /**< an angle opening for a spot */ + float __angleFadeOut; /**< an angle of fade out for a spot */ +}; //SpotLight //tolua_export <--(!do not edit!)the exporting line to lua + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_SPOT_LIGHT_H_ diff --git a/src/ui/effects/inc/FUiEffects_RuntimeUnitLight.h b/src/ui/effects/inc/FUiEffects_RuntimeUnitLight.h new file mode 100644 index 0000000..d0df6f3 --- /dev/null +++ b/src/ui/effects/inc/FUiEffects_RuntimeUnitLight.h @@ -0,0 +1,194 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeUnitLight.h + * @brief This is the header file for a unit light + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_UNIT_LIGHT_H_ +#define _FUI_EFFECTS_INTERNAL_RUNTIME_UNIT_LIGHT_H_ + +#include +#include +#include +#include "FUiEffects_RuntimeModel.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +//tolua_begin <--(!do not edit!)the beginning of export part to lua +class UnitLight +{ +//tolua_end <--(!do not edit!)the ending of export part to lua +public: + + /** + * Returns current state of an unit light (is it turned on or turned off) + * + * @since 2.0 + * + */ + bool GetEnabled(void) const; //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Returns a colour of an unit light + * + * @since 2.0 + * + */ + const Tizen::Ui::Effects::_Utils::Vec3f& GetColour(void) const; +#if 0 + const Vector3& GetColour(void) const; //tolua_export <--(!do not edit!)the exporting line to lua +#endif + + /** + * Returns an intensity of an unit light + * + * @since 2.0 + * + */ + float GetIntensity(void) const; //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Returns a name of an unit light + * + * @since 2.0 + * + */ + const std::string& GetName(void) const; //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Turns on or turns off a unit light + * + * @since 2.0 + * + */ + void SetEnabled(bool isEnabled); //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Sets a colour for a unit light + * + * @since 2.0 + * + */ + void SetColour(const Tizen::Ui::Effects::_Utils::Vec3f& colour); +#if 0 + void SetColour(const Vector3& colour); //tolua_export <--(!do not edit!)the exporting line to lua +#endif + + /** + * Sets a colour for a unit light + * + * @since 2.0 + * + */ + void SetColour(float red, float green, float blue); //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Sets an intensity for a unit light + * + * @since 2.0 + * + */ + void SetIntensity(float intensity); //tolua_export <--(!do not edit!)the exporting line to lua + + /** + * Returns type of an unit light + * + * @since 2.0 + * + */ + virtual TypeUnitLight GetType(void) const = 0; + + /** + * Resets all signs for this instance of class (e.g. isColourChanged, isIntensityChanged) + * + * @since 2.0 + * + */ + virtual void ResetSigns(void); + + static void ReleaseObjectsPool(void); + +protected: + + /** + * UnitLight class constructor + * + * @since 2.0 + * + */ + UnitLight(const std::string& name); + + /** + * UnitLight class constructor + * + * @since 2.0 + * + */ + UnitLight(bool enabled, + const std::string& name, + const Tizen::Ui::Effects::_Utils::Vec3f& colour, + float intensity + ); + + /** + * Class destructor + * + * @since 2.0 + * + */ + virtual ~UnitLight(void); + + typedef std::list ObjectsPool; + + static void AddUnitLightToPool(UnitLight* unitLigth); + +private: + + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + UnitLight(const UnitLight& rhs); + // The implementation of this assignment operator is intentionally blank and declared as private to prohibit copying of objects. + UnitLight& operator=(const UnitLight& rhs); + + typedef std::pair DoesExistsInPool; + + static DoesExistsInPool IsUnitLightInPool(UnitLight& unitLight); + static void RemoveUnitLightFromPool(ObjectsPool::iterator it); + +public: + + bool isEnabledChanged; + bool isColourChanged; + bool isIntensityChanged; + bool isSomethingChanged; + +private: + + bool __enabled; /**< is an unit light turned on or turned off*/ + std::string __name; /**< a name of an unit light*/ + Tizen::Ui::Effects::_Utils::Vec3f __colour; /**< a colour of an unit light*/ + float __intensity; /**< an intensity of an unit light*/ + + friend class RenderDataScene; //for deleting UnitLight's objects + + static ObjectsPool __objectsPool; +}; //UnitLight //tolua_export <--(!do not edit!)the exporting line to lua + +} } } } // Tizen::Ui::Effects::_Runtime + +#endif //_FUI_EFFECTS_INTERNAL_RUNTIME_UNIT_LIGHT_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelAabb.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelAabb.h new file mode 100644 index 0000000..19ed21f --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelAabb.h @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelAabb.h + * @brief Class of Axis-Aligned Bounding Box for efficient geometry objects occlusion culling + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_AABB_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_AABB_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Aabb //DUMMY +{ +public: + void Identity(void) + { + minimum.Set(0.0f); + maximum.Set(0.0f); + return; + } + + void Extend(const Aabb& other) + { + minimum.X() = Math::EffectsMin(minimum.X(), other.minimum.X()); + minimum.Y() = Math::EffectsMin(minimum.Y(), other.minimum.Y()); + minimum.Z() = Math::EffectsMin(minimum.Z(), other.minimum.Z()); + + maximum.X() = Math::EffectsMax(maximum.X(), other.maximum.X()); + maximum.Y() = Math::EffectsMax(maximum.Y(), other.maximum.Y()); + maximum.Z() = Math::EffectsMax(maximum.Z(), other.maximum.Z()); + + return; + } + + Aabb GetTransformed(const Math::Matrix4f& tran) const + { + Aabb result; + + result.minimum = minimum * tran; + result.maximum = maximum * tran; + if (result.minimum.X() > result.maximum.X()) + { + std::swap(result.minimum.X(), result.maximum.X()); + } + if (result.minimum.Y() > result.maximum.Y()) + { + std::swap(result.minimum.Y(), result.maximum.Y()); + } + if (result.minimum.Z() > result.maximum.Z()) + { + std::swap(result.minimum.Z(), result.maximum.Z()); + } + + return result; + } + + Math::Vector3f minimum; + Math::Vector3f maximum; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_AABB_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelAlphaBlendProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelAlphaBlendProperty.h new file mode 100644 index 0000000..cd33acb --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelAlphaBlendProperty.h @@ -0,0 +1,90 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelAlphaBlendProperty.h + * @brief Alpha blending properties class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_ALPHA_BLEND_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_ALPHA_BLEND_PROPERTY_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ +class PropertyVisitor; + +class AlphaBlendProperty: + public Property +{ +public: + class BlendFactor + { + public: + enum BlendFactorEnum + { + ZERO = 0 , + ONE , + SRC_COLOR , + ONE_MINUS_SRC_COLOR , + DST_COLOR , + ONE_MINUS_DST_COLOR , + SRC_ALPHA , + ONE_MINUS_SRC_ALPHA , + DST_ALPHA , + ONE_MINUS_DST_ALPHA , + CONSTANT_COLOR , + ONE_MINUS_CONSTANT_COLOR , + CONSTANT_ALPHA , + ONE_MINUS_CONSTANT_ALPHA , + SRC_ALPHA_SATURATE + }; + typedef BlendFactorEnum Value; + }; + + AlphaBlendProperty(void); + virtual ~AlphaBlendProperty(void); + + virtual void Visit(PropertyVisitor& v); + + virtual bool IsEnable(void); + virtual BlendFactor::Value GetSourceFactor(void); + virtual BlendFactor::Value GetDestinationFactor(void); + + virtual void SetFactors(BlendFactor::Value source, BlendFactor::Value destination); + virtual void Enable(bool isEnabled); + + virtual CachePtr GetCache(void); + virtual void SetCache(CachePtr cache); + virtual void TouchCache(void); + +private: + CachePtr __cache; + BlendFactor::Value __source; + BlendFactor::Value __destination; + bool __isEnabled; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr AlphaBlendPropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_ALPHA_BLEND_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelAttribute.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelAttribute.h new file mode 100644 index 0000000..15d3e02 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelAttribute.h @@ -0,0 +1,37 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelAttribute.h + * @brief Common class for shader attributes + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_ATTRIBUTE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_ATTRIBUTE_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ +template struct Attribute +{ + T value; + bool invalid; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_ATTRIBUTE_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelBuffer.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelBuffer.h new file mode 100644 index 0000000..5639b00 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelBuffer.h @@ -0,0 +1,235 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelBuffer.h + * @brief Shaders attributes data buffers + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_BUFFER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_BUFFER_H_ + +#include +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ +class Buffer +{ +public: + Buffer(void); + virtual ~Buffer(void); + + virtual void Visit(BufferVisitor& v) + { + v.OnBuffer(*this); + return; + } +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr BufferPtr; + +class SolidBufferStrategy +{ +public: + class BufferUsage + { + public: + enum BufferUsageEnum + { + STREAM_DRAW = 0, + STREAM_READ , + STREAM_COPY , + STATIC_DRAW , + STATIC_READ , + STATIC_COPY , + DYNAMIC_DRAW , + DYNAMIC_READ , + DYNAMIC_COPY + }; + typedef BufferUsageEnum Value; + }; + + SolidBufferStrategy(void) {} + virtual ~SolidBufferStrategy(void) + { + if (_pCache) + { + _pCache->Die(); + } + } + + virtual void* GetData(void) = 0; + virtual size_t GetSize(void) const = 0; + virtual BufferUsage::Value GetUsage(void) const = 0; + virtual CachePtr GetCache(void) + { + return _pCache; + } + virtual void SetCache(CachePtr aCache) + { + if (_pCache) + { + _pCache->Die(); + } + _pCache = aCache; + } + +protected: + CachePtr _pCache; +}; + +class TypedBufferStrategy +{ +public: + class DataType + { + public: + enum DataTypeEnum + { + BYTE = 0 , + UNSIGNED_BYTE , + SHORT , + UNSIGNED_SHORT , + INT , + UNSIGNED_INT , + FLOAT , + DOUBLE + }; + typedef DataTypeEnum Value; + }; + + TypedBufferStrategy(void) {} + virtual ~TypedBufferStrategy(void) {} + + virtual DataType::Value GetDataType(void) const = 0; +}; + +class VertexBuffer: public Buffer, public SolidBufferStrategy, public TypedBufferStrategy +{ +public: + VertexBuffer(void) {} + virtual ~VertexBuffer(void) {} + + virtual void Visit(BufferVisitor& v) { v.OnVertexBuffer(*this); } + virtual size_t GetComponentsPerElement(void) const = 0; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr VertexBufferPtr; + +class IndexBuffer: + public Buffer, + public SolidBufferStrategy, + public TypedBufferStrategy +{ +public: + class PrimitiveType + { + public: + enum PrimitiveTypeEnum + { + POINTS = 0 , + LINE_STRIP , + LINE_LOOP , + LINES , + TRIANGLE_STRIP , + TRIANGLE_FAN , + TRIANGLES , + QUAD_STRIP , + QUADS , + POLYGON + }; + typedef PrimitiveTypeEnum Value; + }; + + IndexBuffer(void) {} + virtual ~IndexBuffer(void) {} + + virtual void Visit(BufferVisitor& v) { v.OnIndexBuffer(*this); } + virtual PrimitiveType::Value GetPrimitiveType() const = 0; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr IndexBufferPtr; + +class CompositeVertexBuffer: + public Buffer, + public SolidBufferStrategy, + public TypedBufferStrategy +{ +public: + CompositeVertexBuffer(void) {} + virtual ~CompositeVertexBuffer(void) {} + + virtual void Visit(BufferVisitor& v) + { + v.OnCompositeVertexBuffer(*this); + return; + } +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr CompositeVertexBufferPtr; + +class PartVertexBuffer: + public Buffer, + public TypedBufferStrategy +{ +public: + PartVertexBuffer(void) {} + virtual ~PartVertexBuffer(void) + { + if (_pCache) + { + _pCache->Die(); + } + } + + virtual void Visit(BufferVisitor& v) + { + v.OnPartVertexBuffer(*this); + return; + } + + virtual CachePtr GetCache(void) {return _pCache;} + + virtual void SetCache(CachePtr pCache) + { + if (_pCache) + { + _pCache->Die(); + } + _pCache = pCache; + return; + } + + virtual size_t GetStride(void) const = 0; + virtual size_t GetOffset(void) const = 0; + virtual CompositeVertexBufferPtr GetCompositeBuffer(void) const = 0; + virtual size_t GetComponentsPerElement(void) const = 0; + +protected: + CachePtr _pCache; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr PartVertexBufferPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_BUFFER_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelBufferVisitor.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelBufferVisitor.h new file mode 100644 index 0000000..ac04525 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelBufferVisitor.h @@ -0,0 +1,51 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelBufferVisitor.h + * @brief Base class for buffer visitor + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_BUFFER_VISITOR_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_BUFFER_VISITOR_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Buffer; +class VertexBuffer; +class CompositeVertexBuffer; +class PartVertexBuffer; +class IndexBuffer; + +class BufferVisitor +{ +public: + BufferVisitor(void) {} + virtual ~BufferVisitor(void) {} + + virtual void OnBuffer(Buffer&) {} + virtual void OnVertexBuffer(VertexBuffer&) {} + virtual void OnCompositeVertexBuffer(CompositeVertexBuffer&) {} + virtual void OnPartVertexBuffer(PartVertexBuffer&) {} + virtual void OnIndexBuffer(IndexBuffer&) {} +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_BUFFER_VISITOR_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelCache.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelCache.h new file mode 100644 index 0000000..19c6ad3 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelCache.h @@ -0,0 +1,48 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelCache.h + * @brief Base class for caches implementations + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_CACHE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_CACHE_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ +class Cache: + private Tizen::Ui::Effects::_Renderer::System::NonCopyable +{ +public: + Cache(void): _invalid(true) {} + virtual ~Cache(void) {} + + virtual void Invalidate() { _invalid = true; } + virtual bool Valid(void) { return !_invalid; } + + virtual void Die(void) = 0; + +protected: + bool _invalid; +}; +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_CACHE_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelCamera.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelCamera.h new file mode 100644 index 0000000..5e2496a --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelCamera.h @@ -0,0 +1,75 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelCamera.h + * @brief Camera class defines onscreen projection of 3D data + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_CAMERA_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_CAMERA_H_ + +#include +#include +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ +class Camera: + public Node +{ +public: + Camera(void); + virtual ~Camera(void); + + virtual void Visit(Visitor& v); + + virtual const Math::Matrix4f& GetProj(void); + virtual void SetProj(const Math::Matrix4f& arg); + virtual void SetLocal(const Math::Matrix4f& arg); + virtual void SetWorld(const Math::Matrix4f& arg); + + virtual void SetViewport(const Math::Vector2f& minPos, const Math::Vector2f& maxPos); + virtual const Math::Vector2f& GetViewportMin(void); + virtual const Math::Vector2f& GetViewportMax(void); + + virtual void SetClearColor(const Math::Vector4f& color); + virtual const Math::Vector4f& GetClearColor(void); + + virtual bool AttachedToParent(Group* pParent); + virtual bool RemoveFromParent(Group* pParent); + virtual void ParentMoved(Group* pParent); + + virtual const Frustum& GetFrustum(void); + +protected: + virtual void ValidateFrustum(void); + + Math::Vector4f _clearColor; + Math::Vector2f _minPos; + Math::Vector2f _maxPos; + Attribute _proj; + Attribute _frustum; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_CAMERA_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelDrawable.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelDrawable.h new file mode 100644 index 0000000..530a7ec --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelDrawable.h @@ -0,0 +1,71 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelDrawable.h + * @brief Class of single graphical object which will be displayed on screen. + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_DRAWABLE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_DRAWABLE_H_ + +#include +#include +#include +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Drawable: + public Node +{ +public: + Drawable(void); + virtual ~Drawable(void); + + virtual void Visit(Visitor& v) { v.OnDrawable(*this); } + + virtual void SetGeometry(GeometryPtr pGeom); + virtual GeometryPtr GetGeometry(void); + + virtual void SetMaterial(MaterialPtr pMat); + virtual MaterialPtr GetMaterial(void); + + virtual const Aabb& GetBoundBox(void); + virtual void InvalidateCache(void); + virtual void InvalidateBoundBox(void); + + virtual CachePtr GetCache(void); + virtual void SetCache(CachePtr pCache); + +protected: + virtual void ValidateBoundBox(void); + + GeometryPtr _pGeometry; + MaterialPtr _pMaterial; + + CachePtr _pCache; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_DRAWABLE_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelExternalRenderInterface.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelExternalRenderInterface.h new file mode 100644 index 0000000..77071f4 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelExternalRenderInterface.h @@ -0,0 +1,42 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelExternalRenderInterface.h + * @brief Parent class for external (offscreen) rendering + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_EXTERNAL_RENDER_INTERFACE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_EXTERNAL_RENDER_INTERFACE_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class ExternalRenderInterface +{ +public: + ExternalRenderInterface(void) {} + virtual ~ExternalRenderInterface(void) {} + + virtual bool NeedRedraw(void) = 0; + virtual void Draw(void) = 0; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_EXTERNAL_RENDER_INTERFACE_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelFloatArrayProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelFloatArrayProperty.h new file mode 100644 index 0000000..60e6059 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelFloatArrayProperty.h @@ -0,0 +1,45 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelFloatArrayProperty.h + * @brief Array of float shader property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FLOAT_ARRAY_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FLOAT_ARRAY_PROPERTY_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class FloatArrayProperty: + public TypedArrayProperty +{ +public: + virtual void Visit(PropertyVisitor& v); +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr FloatArrayPropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FLOAT_ARRAY_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelFloatProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelFloatProperty.h new file mode 100644 index 0000000..02572e7 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelFloatProperty.h @@ -0,0 +1,52 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelFloatProperty.h + * @brief Float shader property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FLOAT_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FLOAT_PROPERTY_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ +class FloatProperty: + public Property +{ +public: + virtual void Visit(PropertyVisitor& v) + { + v.OnFloatProperty(*this); + return; + } + + FloatProperty(void) {} + virtual ~FloatProperty(void) {} + + virtual float Get(void) const = 0; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr FloatPropertyPtr; +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FLOAT_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelFloatPropertyHolder.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelFloatPropertyHolder.h new file mode 100644 index 0000000..08db2a7 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelFloatPropertyHolder.h @@ -0,0 +1,52 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelFloatPropertyHolder.h + * @brief Class with data for float shader property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FLOAT_PROPERTY_HOLDER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FLOAT_PROPERTY_HOLDER_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class FloatPropertyHolder: + public FloatProperty +{ +public: + FloatPropertyHolder(void); + virtual ~FloatPropertyHolder(void); + + virtual float Get(void) const; + void Set(float value); + +private: + float __value; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr FloatPropertyHolderPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FLOAT_PROPERTY_HOLDER_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelForwardDeclaration.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelForwardDeclaration.h new file mode 100644 index 0000000..942c44c --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelForwardDeclaration.h @@ -0,0 +1,75 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelForwardDeclaration.h + * @brief Forward declarations of engine model classes + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FORWARD_DECLARATION_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FORWARD_DECLARATION_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Visitor; + +class Node; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr NodePtr; + +class Group; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr GroupPtr; + +class Camera; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr CameraPtr; + +class Drawable; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr DrawablePtr; + +class Cache; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr CachePtr; + +class DrawableCache; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr DrawableCachePtr; + +class BufferCache; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr BufferCachePtr; + +class MaterialCache; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr MaterialCachePtr; + +class PropertyCache; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr PropertyCachePtr; + +class Material; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr MaterialPtr; + +class Property; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr PropertyPtr; + +class Geometry; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr GeometryPtr; + +class Buffer; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr BufferPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FORWARD_DECLARATION_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelFrustum.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelFrustum.h new file mode 100644 index 0000000..3bb5a82 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelFrustum.h @@ -0,0 +1,47 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelFrustum.h + * @brief Class of frusrum for viewing camera + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FRUSTUM_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FRUSTUM_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Frustum +{ +public: + Frustum(void) {} + void Build(const Math::Matrix4f& proj, const Math::Matrix4f& world) { return; } + bool InIn(const Math::Vector3f& point) { return true; } + bool InIn(const Aabb& boundBox) { return true; } +protected: + Math::Vector4f _planes[6]; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_FRUSTUM_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelGeometry.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelGeometry.h new file mode 100644 index 0000000..2d7c2e5 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelGeometry.h @@ -0,0 +1,64 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelGeometry.h + * @brief Class with geometry data for rendering + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_GEOMETRY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_GEOMETRY_H_ + +#include +#include +#include +#include + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Geometry +{ +public: + Geometry(void) {} + virtual ~Geometry(void) {} + + virtual BufferPtr GetBuffer(const std::string& name) const = 0; + virtual BufferPtr GetIndexBuffer(void) const = 0; + virtual IndexBuffer::PrimitiveType::Value GetPrimitiveType(void) const = 0; + virtual const Aabb& GetBoundBox(void) const = 0; + + virtual void AttachedToDrawable(Drawable*); + virtual void RemovedFromDrawable(Drawable*); + virtual void TouchDrawables(void); + virtual void TouchDrawablesBoundBox(void); + +protected: + typedef std::vector DrawablesListType; + typedef DrawablesListType::iterator DrawablesListIteratorType; + typedef DrawablesListType::size_type DrawablesListSizeType; + + DrawablesListType _drawables; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_GEOMETRY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelGroup.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelGroup.h new file mode 100644 index 0000000..48bb8df --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelGroup.h @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelGroup.h + * @brief Class represents Node which can hold child nodes + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_GROUP_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_GROUP_H_ + +#include +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Group: + public Node +{ +public: + typedef std::vector ChildrenListType; + typedef ChildrenListType::size_type ChildrenListSizeType; + + Group(void); + + virtual ~Group(void); + + virtual void Visit(Visitor& v); + + virtual bool AddChild(NodePtr pChild); + virtual bool RemoveChild(NodePtr pChild); + virtual void Clear(void); + virtual ChildrenListSizeType ChildrenCount(); + virtual bool RemoveChild(ChildrenListSizeType index); + virtual NodePtr GetChild(ChildrenListSizeType index); + + virtual void InvalidateBoundBox(void); //called to inform that child bounds or position changed + virtual const Aabb& GetBoundBox(void); + + virtual void SetWorld(const Math::Matrix4f& arg); + virtual void SetLocal(const Math::Matrix4f& arg); + + virtual bool AttachedToParent(Group* pParent); + virtual bool RemoveFromParent(Group* pParent); + virtual void ParentMoved(Group* pParent); + +protected: + virtual void ValidateBoundBox(void); + +private: + void InternalRemoveChild(ChildrenListSizeType index); + +protected: + bool _invalidBoundBox; + ChildrenListType _children; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_GROUP_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelIntProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelIntProperty.h new file mode 100644 index 0000000..fc2fefe --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelIntProperty.h @@ -0,0 +1,52 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelIntProperty.h + * @brief Int shader property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_INT_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_INT_PROPERTY_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ +class IntProperty: + public Property +{ +public: + virtual void Visit(PropertyVisitor& v) + { + v.OnIntProperty(*this); + return; + } + + IntProperty(void) {} + virtual ~IntProperty(void) {} + + virtual long Get(void) const = 0; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr IntPropertyPtr; +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_INT_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelIntPropertyHolder.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelIntPropertyHolder.h new file mode 100644 index 0000000..bf51036 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelIntPropertyHolder.h @@ -0,0 +1,69 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelIntPropertyHolder.h + * @brief Class with data for long shader property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_INT_PROPERTY_HOLDER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_INT_PROPERTY_HOLDER_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class IntPropertyHolder: + public IntProperty +{ +public: + IntPropertyHolder(void) + : __value(0.0f) + { + + } + + virtual ~IntPropertyHolder(void) + { + + } + + virtual long Get(void) const + { + return __value; + } + + void Set(long value) + { + __value = value; + + return; + } + +private: + long __value; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr IntPropertyHolderPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_INT_PROPERTY_HOLDER_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelMaterial.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelMaterial.h new file mode 100644 index 0000000..0be1652 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelMaterial.h @@ -0,0 +1,60 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelMaterial.h + * @brief Represents shader with its properties for rendering drawable objects in scene + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_MATERIAL_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_MATERIAL_H_ + +#include +#include + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Material +{ +public: + Material(void) {} + virtual ~Material(void) {} + + virtual PropertyPtr GetProperty(const std::string&) = 0; + virtual PropertyPtr GetProperty(size_t index) = 0; + virtual size_t GetNumProperties(void) = 0; + + virtual void AttachedToDrawable(Drawable*); + virtual void RemovedFromDrawable(Drawable*); + virtual void TouchDrawables(void); + +protected: + typedef std::vector DrawablesListType; + typedef DrawablesListType::iterator DrawablesListIteratorType; + typedef DrawablesListType::size_type DrawablesListSizeType; + + DrawablesListType _drawables; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_MATERIAL_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelMatrix4fProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelMatrix4fProperty.h new file mode 100644 index 0000000..357e26c --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelMatrix4fProperty.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelMatrix4fProperty.h + * @brief mat4 shader property class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_MATRIX4F_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_MATRIX4F_PROPERTY_H_ + +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Matrix4fProperty: + public Property +{ +public: + typedef Math::Matrix4f MatrixType; + + virtual void Visit(PropertyVisitor& v) + { + v.OnMatrix4fProperty(*this); + return; + } + + Matrix4fProperty(void) {} + virtual ~Matrix4fProperty(void) {} + + virtual const MatrixType& Get(void) const = 0; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr MatrixPropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_MATRIX4F_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelMatrix4fPropertyHolder.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelMatrix4fPropertyHolder.h new file mode 100644 index 0000000..3f297b5 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelMatrix4fPropertyHolder.h @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelMatrix4fPropertyHolder.h + * @brief Class with data for Matrix4fProperty + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_MATRIX4F_PROPERTY_HOLDER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_MATRIX4F_PROPERTY_HOLDER_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Matrix4fPropertyHolder: + public Matrix4fProperty +{ +public: + typedef Matrix4fProperty::MatrixType MatrixType; + + Matrix4fPropertyHolder(void); + virtual ~Matrix4fPropertyHolder(void); + + virtual const MatrixType& Get(void) const; + + void Set(const MatrixType& matrix); + void Set(const float a11, const float a12, const float a13, const float a14, + const float a21, const float a22, const float a23, const float a24, + const float a31, const float a32, const float a33, const float a34, + const float a41, const float a42, const float a43, const float a44); + +private: + MatrixType __matrix; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr Matrix4fPropertyHolderPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_MATRIX4F_PROPERTY_HOLDER_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelNode.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelNode.h new file mode 100644 index 0000000..d2d8864 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelNode.h @@ -0,0 +1,90 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelNode.h + * @brief Base class for single object in scene tree for rendering. Has its own transformation matrix; + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_NODE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_NODE_H_ + +#include + +#include +#include +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Node: + private Tizen::Ui::Effects::_Renderer::System::NonCopyable +{ +public: + class TransformationType + { + public: + enum TransformationTypeEnum + { + WORLD = 0, + RELATED + }; + typedef TransformationTypeEnum Value; + }; + + Node(void); + virtual ~Node(void); + + virtual void Visit(Visitor& visitor); + + virtual const Math::Matrix4f& GetLocal(void); + virtual void SetLocal(const Math::Matrix4f& arg); + + virtual const Math::Matrix4f& GetWorld(void); + virtual void SetWorld(const Math::Matrix4f& arg); + + virtual const Aabb& GetBoundBox(void); + virtual Aabb GetBoundBoxInParentSpace(void); //get bound box transformed in _pParent space + + virtual bool AttachedToParent(Group* pParent); //called when inserted in _pParent (call from _pParent) + virtual bool RemoveFromParent(Group* pParent); //called when removed from _pParent (call from _pParent) + virtual void ParentMoved(Group* pParent); //called when _pParent position changed (call from _pParent) + + virtual void TouchParentBoundBox(); //call when position or bound box changed + +protected: + virtual void ValidateLocal(void); + virtual void ValidateWorld(void); + + Group* _pParent; + + Attribute _relatedTransform; + Attribute _worldTransform; + Attribute _boundBox; + + TransformationType::Value _transformType; + Math::Matrix4f _transformMatrix; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_NODE_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelProgramProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelProgramProperty.h new file mode 100644 index 0000000..ab548c52 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelProgramProperty.h @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelProgramProperty.h + * @brief Shader property for material + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_PROGRAM_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_PROGRAM_PROPERTY_H_ + +#include +#include +#include +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class ProgramProperty: + public Property +{ +public: + virtual void Visit(PropertyVisitor& v) {v.OnProgramProperty(*this);} + + ProgramProperty(void) {} + virtual ~ProgramProperty() + { + if (__pCache) + { + __pCache->Die(); + } + } + + virtual ShaderPropertyPtr GetShader(ShaderProperty::ShaderType::Value type) = 0; + + virtual CachePtr GetCache(void) + { + return __pCache; + } + virtual void SetCache(CachePtr pCache) + { + if (__pCache) + { + __pCache->Die(); + } + __pCache = pCache; + return; + } + +private: + CachePtr __pCache; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr ProgramPropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_PROGRAM_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelProperty.h new file mode 100644 index 0000000..2802ad5 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelProperty.h @@ -0,0 +1,49 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelProperty.h + * @brief Base class for material property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_PROPERTY_H_ + +#include +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Property +{ +public: + Property(void); + virtual ~Property(void); + + virtual void Visit(PropertyVisitor& v); +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr PropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelPropertyHolderMaterial.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelPropertyHolderMaterial.h new file mode 100644 index 0000000..da58986 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelPropertyHolderMaterial.h @@ -0,0 +1,61 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelPropertyHolderMaterial.h + * @brief Class which holds _properties of material + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_PROPERTY_HOLDER_MATERIAL_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_PROPERTY_HOLDER_MATERIAL_H_ + +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class PropertyHolderMaterial: + public Material +{ +public: + typedef std::vector > PropertyListType; + typedef PropertyListType::size_type PropertyListSizeType; + + PropertyHolderMaterial(void); + virtual ~PropertyHolderMaterial(void); + + virtual PropertyPtr GetProperty(const std::string&); + virtual PropertyPtr GetProperty(PropertyListSizeType index); + virtual PropertyListSizeType GetNumProperties(); + + void AddProperty(const std::string& name, PropertyPtr pProperty); + void RemoveProperty(const std::string& name); + void RemoveProperty(PropertyListSizeType index); + +protected: + PropertyListType _properties; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr PropertyHolderMaterialPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_PROPERTY_HOLDER_MATERIAL_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelPropertyVisitor.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelPropertyVisitor.h new file mode 100644 index 0000000..8c4d9ca --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelPropertyVisitor.h @@ -0,0 +1,75 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelPropertyVisitor.h + * @brief Base class for property visitor + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_PROPERTY_VISITOR_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_PROPERTY_VISITOR_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Property; +class TextureProperty; +class Texture2dProperty; +class Texture2dAttachmentProperty; +class Texture2DNativeProperty; +class Texture2DVideoProperty; +class ShaderProperty; +class ProgramProperty; +class Matrix4fProperty; +class Vector2fProperty; +class Vector3fProperty; +class Vector4fProperty; +class IntProperty; +class FloatProperty; +class AlphaBlendProperty; +class Texture2DNativeSwitcherProperty; +class FloatArrayProperty; + +class PropertyVisitor +{ +public: + PropertyVisitor(void) {} + virtual ~PropertyVisitor(void) {} + + virtual void OnProperty(Property&) {} + virtual void OnTextureProperty(TextureProperty&) {} + virtual void OnTexture2DProperty(Texture2dProperty&) {} + virtual void OnTexture2DAttachmentProperty(Texture2dAttachmentProperty&) {} + virtual void OnTexture2DNativeProperty(Texture2DNativeProperty&) {} + virtual void OnTexture2DVideoProperty(Texture2DVideoProperty&) {} + virtual void OnShaderProperty(ShaderProperty&) {} + virtual void OnProgramProperty(ProgramProperty&) {} + virtual void OnMatrix4fProperty(Matrix4fProperty&) {} + virtual void OnVector2fProperty(Vector2fProperty&) {} + virtual void OnVector3fProperty(Vector3fProperty&) {} + virtual void OnVector4fProperty(Vector4fProperty&) {} + virtual void OnIntProperty(IntProperty&) {} + virtual void OnFloatProperty(FloatProperty&) {} + virtual void OnAlphaBlendProperty(AlphaBlendProperty&) {} + virtual void OnTexture2DNativeSwitcherProperty(Texture2DNativeSwitcherProperty&) {} + virtual void OnFloatArrayProperty(FloatArrayProperty&) {} +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_PROPERTY_VISITOR_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelRenderTarget.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelRenderTarget.h new file mode 100644 index 0000000..24538b5 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelRenderTarget.h @@ -0,0 +1,129 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelRenderTarget.h + * @brief Base class for representing renderer output instance e.g. for offscreen rendering + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_RENDER_TARGET_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_RENDER_TARGET_H_ + +#include +#include +#include + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class RenderTargetVisitor; + +class RenderTarget +{ +public: + class Attachment + { + public: + enum AttachmentEnum + { + COLOR_0 = 0 , + COLOR_1 , + COLOR_2 , + COLOR_3 , + COLOR_4 , + COLOR_5 , + COLOR_6 , + COLOR_7 , + DEPTH , + STENCIL , + ATTACHMENT_MAX + }; + typedef AttachmentEnum Value; + }; + + struct AttachInfo: private Tizen::Ui::Effects::_Renderer::System::NonCopyable + { + public: + enum TextureType {TEXTURE_2D = 0, STUB}; + AttachInfo(void) {} + + void Set(Texture2dAttachmentProperty* pTexture, size_t mipLevel) + { + textureType = TEXTURE_2D; + textureInfo.texture2D.pTexture = pTexture; + textureInfo.texture2D.mipLevel = mipLevel; + return; + } + + void Set(StubAttachment* pStub) + { + textureType = STUB; + textureInfo.stub.pStub = pStub; + return; + } + + TextureType textureType; + union _textureInfo + { + struct _Texture2D + { + Texture2dAttachmentProperty* pTexture; + size_t mipLevel; + } texture2D; + struct _Stub + { + StubAttachment* pStub; + } stub; + } textureInfo; + }; + + RenderTarget(void); + virtual ~RenderTarget(void); + + virtual void Visit(RenderTargetVisitor& v); + + virtual void AttachTexture2D(Attachment::Value attachment, Texture2DAttachmentPropertyPtr pTexture, size_t mipLevel); + virtual void AttachStub(Attachment::Value attachment, StubAttachmentPtr pStub); + virtual void Detach(Attachment::Value attachment); + virtual AttachInfo* GetAttachment(Attachment::Value attachment); + + unsigned int GetWidth(void); + unsigned int GetHeight(void); + void SetSize(unsigned int width, unsigned int height); + + virtual CachePtr GetCache(void); + virtual void SetCache(CachePtr pCache); + +protected: + unsigned int _width; + unsigned int _height; + AttachInfo _attachments[RenderTarget::Attachment::ATTACHMENT_MAX]; + TextureAttachmentPtr _pTextures[RenderTarget::Attachment::ATTACHMENT_MAX]; + +private: + CachePtr __pCache; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderTargetPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_RENDER_TARGET_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelRenderTargetExternalRender.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelRenderTargetExternalRender.h new file mode 100644 index 0000000..9086d9b --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelRenderTargetExternalRender.h @@ -0,0 +1,53 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelRenderTargetExternalRender.h + * @brief Class for rendering with external renderer + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_RENDER_TARGET_EXTERNAL_RENDER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_RENDER_TARGET_EXTERNAL_RENDER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class RenderTargetExternalRender: + public RenderTarget +{ +public: + RenderTargetExternalRender(void); + virtual ~RenderTargetExternalRender(void); + + virtual void Visit(RenderTargetVisitor& v); + + virtual void SetExternalRender(ExternalRenderInterface* pExternalRender); + virtual ExternalRenderInterface* GetExternalRender(void); + +protected: + ExternalRenderInterface* _pExternalRender; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderTargetExternalRenderPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_RENDER_TARGET_EXTERNAL_RENDER_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelRenderTargetVisitor.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelRenderTargetVisitor.h new file mode 100644 index 0000000..ed273c9 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelRenderTargetVisitor.h @@ -0,0 +1,46 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelRenderTargetVisitor.h + * @brief Base class for renderer target visitor + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_RENDER_TARGET_VISITOR_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_RENDER_TARGET_VISITOR_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class RenderTarget; +class RenderTargetExternalRender; +class RenderTargetFromCamera; + +class RenderTargetVisitor +{ +public: + RenderTargetVisitor(void) {} + virtual ~RenderTargetVisitor(void) {} + + virtual void OnRenderTarget(RenderTarget&) {} + virtual void OnRenderTargetExternalRender(RenderTargetExternalRender&) {} +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_RENDER_TARGET_VISITOR_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelShaderHolderProgramProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelShaderHolderProgramProperty.h new file mode 100644 index 0000000..4d25728 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelShaderHolderProgramProperty.h @@ -0,0 +1,52 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelShaderHolderProgramProperty.h + * @brief Class for particular shader (vertex, fragment, ...) of rendering program ("shader") + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_SHADER_HOLDER_PROGRAM_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_SHADER_HOLDER_PROGRAM_PROPERTY_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class ShaderHolderProgramProperty: + public ProgramProperty +{ +public: + ShaderHolderProgramProperty(ShaderPropertyPtr pVertexShader, ShaderPropertyPtr pFragmentShader); + virtual ~ShaderHolderProgramProperty(void); + + virtual ShaderPropertyPtr GetShader(ShaderProperty::ShaderType::Value type); + +protected: + ShaderPropertyPtr _pVertexShader; + ShaderPropertyPtr _pFragmentShader; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr ShaderHolderProgramPropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_SHADER_HOLDER_PROGRAM_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelShaderProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelShaderProperty.h new file mode 100644 index 0000000..28230b6 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelShaderProperty.h @@ -0,0 +1,105 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelShaderProperty.h + * @brief Class for shader source property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_SHADER_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_SHADER_PROPERTY_H_ + +#include +#include +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class ShaderProperty: + public Property +{ +public: + class DataType + { + public: + enum DataTypeEnum + { + SOURCE_CODE = 0, + BINARY_DATA + }; + typedef DataTypeEnum Value; + }; + + class ShaderType + { + public: + enum ShaderTypeEnum + { + VERTEX = 0, + FRAGMENT + }; + typedef ShaderTypeEnum Value; + }; + + virtual void Visit(PropertyVisitor& v) + { + v.OnShaderProperty(*this); + return; + } + + ShaderProperty(void) {} + virtual ~ShaderProperty(void) + { + if (__pCache) + { + __pCache->Die(); + } + } + + virtual const void* GetData(void) = 0; + virtual DataType::Value GetDataType(void) = 0; + virtual ShaderType::Value GetShaderType(void) = 0; + + virtual CachePtr GetCache(void) + { + return __pCache; + } + + virtual void SetCache(CachePtr pCache) + { + if (__pCache) + { + __pCache->Die(); + } + __pCache = pCache; + return; + } + +private: + CachePtr __pCache; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr ShaderPropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_SHADER_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelStringShaderProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelStringShaderProperty.h new file mode 100644 index 0000000..858bfd8 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelStringShaderProperty.h @@ -0,0 +1,56 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelStringShaderProperty.h + * @brief Class for shader string _source property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_STRING_SHADER_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_STRING_SHADER_PROPERTY_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class StringShaderProperty: + public ShaderProperty +{ +public: + StringShaderProperty(ShaderProperty::ShaderType::Value shaderType, const std::string& source); + virtual ~StringShaderProperty(void); + + virtual const void* GetData(void); + std::string GetSource(void) const; + void SetSource(std::string source); + virtual DataType::Value GetDataType(void); + virtual ShaderType::Value GetShaderType(void); + +protected: + ShaderProperty::ShaderType::Value _shaderType; + std::string _source; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr StringShaderPropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_STRING_SHADER_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelStubAttachment.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelStubAttachment.h new file mode 100644 index 0000000..bfed342 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelStubAttachment.h @@ -0,0 +1,58 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelStubAttachment.h + * @brief Stub texture for renderer target + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_STUB_ATTACHMENT_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_STUB_ATTACHMENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class StubAttachment: + public TextureAttachment +{ +public: + StubAttachment(TextureProperty::InternalFormat::Value internalFormat = TextureProperty::InternalFormat::DEPTH_COMPONENT_16); + virtual ~StubAttachment(void); + + virtual CachePtr GetCache(void); + virtual void SetCache(CachePtr pCache); + virtual void TouchCache(void); + + virtual TextureProperty::InternalFormat::Value GetInternalFormat(void); + +protected: + TextureProperty::InternalFormat::Value _internalFormat; + +private: + CachePtr __pCache; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr StubAttachmentPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_STUB_ATTACHMENT_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DAttachmentProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DAttachmentProperty.h new file mode 100644 index 0000000..14ff900 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DAttachmentProperty.h @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelTexture2DAttachmentProperty.h + * @brief Texture property for renderer target + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TEXTURE2D_ATTACHMENT_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TEXTURE2D_ATTACHMENT_PROPERTY_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Texture2dAttachmentProperty: + public TextureProperty, + public TextureAttachment +{ +public: + virtual void Visit(PropertyVisitor& v); + + Texture2dAttachmentProperty( + bool generateMipmaps = false, + InternalFormat::Value internalFormat = InternalFormat::RGB, + DataFormat::Value dataFormat = DataFormat::RGB, + DataType::Value dataType = DataType::UNSIGNED_BYTE, + FilterType::Value minFilter = FilterType::LINEAR, + FilterType::Value magFilter = FilterType::LINEAR, + WrapType::Value wrapS = WrapType::CLAMP_TO_EDGE, + WrapType::Value wrapT = WrapType::CLAMP_TO_EDGE); + + virtual ~Texture2dAttachmentProperty(void); + + void SetMipmapGeneration(bool generateMipmaps); + + bool GetGenerateMipmaps(void) const; + + virtual InternalFormat::Value GetInternalFormat(void) const; + virtual DataFormat::Value GetDataFormat(void) const; + virtual DataType::Value GetDataType(void) const; + virtual FilterType::Value GetMinFilter(void) const; + virtual FilterType::Value GetMagFilter(void) const; + virtual WrapType::Value GetWrapS(void) const; + virtual WrapType::Value GetWrapT(void) const; + virtual WrapType::Value GetWrapR(void) const; + + virtual CachePtr GetCache(void); + virtual void SetCache(CachePtr pCache); + virtual void TouchCache(void); + +protected: + bool _generateMipmaps; + InternalFormat::Value _internalFormat; + DataFormat::Value _dataFormat; + DataType::Value _dataType; + FilterType::Value _minFilter; + FilterType::Value _magFilter; + WrapType::Value _wrapS; + WrapType::Value _wrapT; + +private: + CachePtr __pCache; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr Texture2DAttachmentPropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TEXTURE2D_ATTACHMENT_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DProperty.h new file mode 100644 index 0000000..9520bd2 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DProperty.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelTexture2DProperty.h + * @brief 2D texture property in material + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TEXTURE2D_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TEXTURE2D_PROPERTY_H_ + +#include +#include +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ +class Texture2dProperty: + public TextureProperty +{ +public: + virtual void Visit(PropertyVisitor& v); + + Texture2dProperty(void); + virtual ~Texture2dProperty(void); + + virtual size_t GetNumMipmaps(void) const = 0; + virtual void* GetData(size_t mipNumber) = 0; + virtual size_t GetWidth(size_t mipNumber) const = 0; + virtual size_t GetHeight(size_t mipNumber) const = 0; + virtual bool GenerateMipmaps(void) const = 0; + + virtual CachePtr GetCache(void); + virtual void SetCache(CachePtr pCache); + virtual void TouchCache(void); + +private: + CachePtr __pCache; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr Texture2DPropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TEXTURE2D_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTextureAttachment.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTextureAttachment.h new file mode 100644 index 0000000..ee74190 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTextureAttachment.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelTextureAttachment.h + * @brief Texture attachment for renderer target + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TEXTURE_ATTACHMENT_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TEXTURE_ATTACHMENT_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class RenderTarget; + +class TextureAttachment +{ +public: + TextureAttachment(void) {} + virtual ~TextureAttachment(void) {} + + typedef std::vector RenderTargetListType; + typedef RenderTargetListType::size_type RenderTargetListSizeType; + + virtual bool AttachedToRenderTarget(RenderTarget* pRenderTarget); + virtual bool RemovedFromRenderTarget(RenderTarget* pRenderTarget); + virtual RenderTargetListSizeType GetNumRenderTargets(void); + virtual RenderTarget* GetRenderTarget(RenderTargetListSizeType index); + +protected: + RenderTargetListType _targets; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr TextureAttachmentPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TEXTURE_ATTACHMENT_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTextureProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTextureProperty.h new file mode 100644 index 0000000..adba0ae --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTextureProperty.h @@ -0,0 +1,139 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelTextureProperty.h + * @brief Texture property in material + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TEXTURE_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TEXTURE_PROPERTY_H_ + +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class TextureProperty: + public Property +{ +public: + virtual void Visit(PropertyVisitor& v); + + class InternalFormat + { + public: + enum InternalFormatEnum //Number of colour components + { + ONE_COMPONENT = 0 , + TWO_COMPONENTS , + THREE_COMPONENTS , + FOUR_COMPONENTS , + DEPTH_COMPONENT , + DEPTH_COMPONENT_16 , + DEPTH_COMPONENT_24 , + DEPTH_COMPONENT_32 , + RGB , + RGBA , + BGRA + }; + typedef InternalFormatEnum Value; + }; + + class DataFormat + { + public: + enum DataFormatEnum //Format of the pixel data + { + RGB = 0 , + BGR , + RGBA , + BGRA , + LUMINANCE , + LUMINANCE_ALPHA + }; + typedef DataFormatEnum Value; + }; + + class DataType + { + public: + enum DataTypeEnum //Data type of pixel data + { + UNSIGNED_BYTE = 0 , + BYTE , + UNSIGNED_SHORT , + SHORT , + UNSIGNED_INT , + INT , + FLOAT , + UNSIGNED_SHORT_565 + }; + typedef DataTypeEnum Value; + }; + + class FilterType + { + public: + enum FilterTypeEnum + { + NEAREST = 0 , + LINEAR , + NEAREST_MIPMAP_NEAREST , + LINEAR_MIPMAP_NEAREST , + NEAREST_MIPMAP_LINEAR , + LINEAR_MIPMAP_LINEAR + }; + typedef FilterTypeEnum Value; + }; + + class WrapType + { + public: + enum WrapTypeEnum + { + CLAMP = 0 , + CLAMP_TO_BORDER , + CLAMP_TO_EDGE , + MIRRORED_REPEAT , + REPEAT + }; + typedef WrapTypeEnum Value; + }; + + TextureProperty(void); + virtual ~TextureProperty(void); + + virtual InternalFormat::Value GetInternalFormat(void) const = 0; + virtual DataFormat::Value GetDataFormat(void) const = 0; + virtual DataType::Value GetDataType(void) const = 0; + virtual FilterType::Value GetMinFilter(void) const = 0; + virtual FilterType::Value GetMagFilter(void) const = 0; + virtual WrapType::Value GetWrapS(void) const = 0; + virtual WrapType::Value GetWrapT(void) const = 0; + virtual WrapType::Value GetWrapR(void) const = 0; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr TexturePropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TEXTURE_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTypedArrayProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTypedArrayProperty.h new file mode 100644 index 0000000..09f4285 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTypedArrayProperty.h @@ -0,0 +1,49 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelTypedArrayProperty.h + * @brief Array of some type property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TYPED_ARRAY_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TYPED_ARRAY_PROPERTY_H_ + +#include + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +template +class TypedArrayProperty: + public Property +{ +public: + typedef T HoldedType; + typedef unsigned int SizeType; + + virtual T* GetData(void) = 0; + virtual SizeType GetNumElements(void) = 0; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TYPED_ARRAY_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTypedArrayPropertyHolder.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTypedArrayPropertyHolder.h new file mode 100644 index 0000000..693ae95 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelTypedArrayPropertyHolder.h @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelTypedArrayPropertyHolder.h + * @brief Class with data for array of some type property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TYPED_ARRAY_PROPERTY_HOLDER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TYPED_ARRAY_PROPERTY_HOLDER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +template +class TypedArrayPropertyHolder: + public Base +{ +public: + typedef typename Base::HoldedType ValueType; + typedef typename Base::SizeType SizeType; + typedef typename SmartPtr> BufferPtr; + + TypedArrayPropertyHolder(SizeType elementsCount): + _elementsMaxCount(elementsCount), + _elementsCount(elementsCount), + bufferPtr(new (std::nothrow) BufferPtr) + { + _TryJmp(GetImpl(bufferPtr) != null, E_OUT_OF_MEMORY, "TypedArrayPropertyHolder buffer = null"); + + bufferPtr->resize(_elementsMaxCount); + } + + virtual ~TypedArrayPropertyHolder(void) + { + + } + + virtual ValueType* GetData(void) + { + return &(*bufferPtr)[0]; + } + + virtual SizeType GetNumElements(void) + { + return _elementsCount; + } + + virtual void SetActualSize(SizeType elementsCount) + { + _elementsCount = elementsCount > _elementsMaxCount ? _elementsMaxCount : elementsCount; + } + +protected: + SizeType _elementsMaxCount; + SizeType _elementsCount; + BufferPtr bufferPtr; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_TYPED_ARRAY_PROPERTY_HOLDER_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector2fProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector2fProperty.h new file mode 100644 index 0000000..a52d4a0 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector2fProperty.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelVector2fProperty.h + * @brief vec2 shader property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR2F_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR2F_PROPERTY_H_ + +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Vector2fProperty: + public Property +{ +public: + typedef Math::Vector2f VectorType; + + virtual void Visit(PropertyVisitor& v) + { + v.OnVector2fProperty(*this); + return; + } + + Vector2fProperty(void) {} + virtual ~Vector2fProperty(void) {} + + virtual const VectorType& Get(void) const = 0; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr Vector2fPropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR2F_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector2fPropertyHolder.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector2fPropertyHolder.h new file mode 100644 index 0000000..3073e66 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector2fPropertyHolder.h @@ -0,0 +1,56 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelVector2fPropertyHolder.h + * @brief Class with data for vec2 shader property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR2F_PROPERTY_HOLDER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR2F_PROPERTY_HOLDER_H_ + +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Vector2fPropertyHolder: + public Vector2fProperty +{ +public: + typedef Vector2fProperty::VectorType VectorType; + + Vector2fPropertyHolder(void); + virtual ~Vector2fPropertyHolder(void); + + virtual const VectorType& Get(void) const; + void Set(const VectorType& vector); + void Set(float x, float y); + +private: + VectorType __vector; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr Vector2fPropertyHolderPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR2F_PROPERTY_HOLDER_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector3fProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector3fProperty.h new file mode 100644 index 0000000..29e2fa6 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector3fProperty.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelVector3fProperty.h + * @brief vec3 shader property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR3F_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR3F_PROPERTY_H_ + +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Vector3fProperty: + public Property +{ +public: + typedef Math::Vector3f VectorType; + + virtual void Visit(PropertyVisitor& v) + { + v.OnVector3fProperty(*this); + return; + } + + Vector3fProperty(void) {} + virtual ~Vector3fProperty(void) {} + + virtual const VectorType& Get(void) const = 0; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr Vector3fPropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR3F_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector3fPropertyHolder.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector3fPropertyHolder.h new file mode 100644 index 0000000..4be360a --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector3fPropertyHolder.h @@ -0,0 +1,56 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelVector3fPropertyHolder.h + * @brief Class with data for vec3 shader property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR3F_PROPERTY_HOLDER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR3F_PROPERTY_HOLDER_H_ + +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Vector3fPropertyHolder: + public Vector3fProperty +{ +public: + typedef Vector3fProperty::VectorType VectorType; + + Vector3fPropertyHolder(void); + virtual ~Vector3fPropertyHolder(void); + + virtual const VectorType& Get(void) const; + void Set(const VectorType& vector); + void Set(float x, float y, float z); + +private: + VectorType __vector; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr Vector3fPropertyHolderPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR3F_PROPERTY_HOLDER_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector4fProperty.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector4fProperty.h new file mode 100644 index 0000000..d92b278 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector4fProperty.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelVector4fProperty.h + * @brief vec3 shader property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR4F_PROPERTY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR4F_PROPERTY_H_ + +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Vector4fProperty: + public Property +{ +public: + typedef Math::Vector4f VectorType; + + virtual void Visit(PropertyVisitor& v) + { + v.OnVector4fProperty(*this); + return; + } + + Vector4fProperty(void) {} + virtual ~Vector4fProperty(void) {} + + virtual const VectorType& Get(void) const = 0; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr Vector4fPropertyPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR4F_PROPERTY_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector4fPropertyHolder.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector4fPropertyHolder.h new file mode 100644 index 0000000..4b614b2 --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVector4fPropertyHolder.h @@ -0,0 +1,56 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelVector4fPropertyHolder.h + * @brief Class with data for vec4 shader property + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR4F_PROPERTY_HOLDER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR4F_PROPERTY_HOLDER_H_ + +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Vector4fPropertyHolder: + public Vector4fProperty +{ +public: + typedef Vector4fProperty::VectorType VectorType; + + Vector4fPropertyHolder(void); + virtual ~Vector4fPropertyHolder(void); + + virtual const VectorType& Get(void) const; + void Set(const VectorType& vector); + void Set(float x, float y, float z, float w); + +private: + VectorType __vector; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr Vector4fPropertyHolderPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VECTOR4F_PROPERTY_HOLDER_H_ diff --git a/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVisitor.h b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVisitor.h new file mode 100644 index 0000000..d57c6dd --- /dev/null +++ b/src/ui/effects/inc/renderer/engine-model/FUiEffects_RendererEngineModelVisitor.h @@ -0,0 +1,46 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelVisitor.h + * @brief Base visitor class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VISITOR_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VISITOR_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +class Visitor +{ +public: + Visitor(void) {} + virtual ~Visitor(void) {} + + virtual void OnNode(Node&) {} + virtual void OnGroup(Group&) {} + virtual void OnCamera(Camera&) {} + virtual void OnDrawable(Drawable&) {} +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_ENGINE_MODEL_VISITOR_H_ diff --git a/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineOpenGLImplementation.h b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineOpenGLImplementation.h new file mode 100644 index 0000000..320c2fa --- /dev/null +++ b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineOpenGLImplementation.h @@ -0,0 +1,67 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineOpenGLImplementation.h + * @brief OpenGL platform defines + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_OPENGL_IMPLEMENTATION_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_OPENGL_IMPLEMENTATION_H_ + +#include + +#if defined(_EFFECTS_SYSTEM_WINDOWS_) || defined(_EFFECTS_SYSTEM_LINUX_) +#define _EFFECTS_GRAPHICSENGINE_OPENGL_DESKTOP_ 1 +#ifndef GLEW_NO_GLU +#define GLEW_NO_GLU +#endif +#include +#if defined(_EFFECTS_SYSTEM_WINDOWS_) +#include +#elif defined(_EFFECTS_SYSTEM_LINUX_) +#include +#endif +#elif defined(_EFFECTS_SYSTEM_ANDROID_) || defined(_EFFECTS_SYSTEM_SLP_) +#define _EFFECTS_GRAPHICSENGINE_OPENGL_ES_ 1 +#ifndef GL_GLEXT_PROTOTYPES +#define GL_GLEXT_PROTOTYPES +#endif +#ifndef EGL_EGLEXT_PROTOTYPES +#define EGL_EGLEXT_PROTOTYPES +#endif +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_EXT_texture_format_BGRA8888 +#endif + +#include +#include +#include +#include +#include +#include + +#elif defined(_EFFECTS_SYSTEM_TIZEN_) // ps +#define _EFFECTS_GRAPHICSENGINE_OPENGL_ES_ 1 +#include +using namespace Tizen::Graphics::Opengl; + +#define GL_BGRA_EXT GL_BGRA +#endif + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_OPENGL_IMPLEMENTATION_H_ diff --git a/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRender.h b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRender.h new file mode 100644 index 0000000..0106043 --- /dev/null +++ b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRender.h @@ -0,0 +1,146 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRender.h + * @brief Class for rendering scene tree + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_H_ + +#include +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +class RenderDrawableCache; + +class Render: + public Tizen::Ui::Effects::_Renderer::EngineModel::Visitor +{ +public: + Render(void); + virtual ~Render(void); + + virtual void Draw(Tizen::Ui::Effects::_Renderer::EngineModel::Node& root, Tizen::Ui::Effects::_Renderer::EngineModel::Camera& camera); + virtual void Draw(Tizen::Ui::Effects::_Renderer::EngineModel::Node& root); + + virtual void ContextLost(void); + virtual void KillCache(RenderCacheImpl* pCache); + + GLenum& GetAlphaBlendSource() { return __alphaBlendSource; } + GLenum& GetAlphaBlendDestination() { return __alphaBlendDestination; } + void SetDefaultDepthTestState(bool isEnable); + + + //implementation dependent functions + virtual void OnGroup(Tizen::Ui::Effects::_Renderer::EngineModel::Group&); + virtual void OnDrawable(Tizen::Ui::Effects::_Renderer::EngineModel::Drawable&); + + void BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::Drawable&); + void BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::VertexBuffer&); + void BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::IndexBuffer&); + void BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::CompositeVertexBuffer&); + void BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::PartVertexBuffer&); + + void BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::Texture2dProperty&, GLuint); + void BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::ShaderProperty&); + void BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::ProgramProperty&); + + void BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::RenderTargetExternalRender&); + void BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::Texture2dAttachmentProperty&, GLuint); + void BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::StubAttachment&); + + void BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::AlphaBlendProperty&); + + void ManageCache(RenderCacheImplPtr pCache); + + RenderCommandPtr GetDefaultRenderCommand(const RenderProgramCache::UniformListValueType*); + + const Math::Matrix4f& GetWorldViewProjection(void); + + void InternalCollectInfo(Tizen::Ui::Effects::_Renderer::EngineModel::Node&); + +private: + void InternalKillDeadCaches(void); + void InternalPreDraw(void); + void InternalDraw(void); + void InternalPostDraw(void); + void InternalFindCameras(Tizen::Ui::Effects::_Renderer::EngineModel::Node&); + + Math::Matrix4f __worldViewProjection; + + typedef std::vector DrawableListType; + typedef std::map ExternalRenderTargetListType; + + ExternalRenderTargetListType __externalRenderTargets; + DrawableListType __drawables; + DrawableListType __blendDrawables; + Tizen::Ui::Effects::_Renderer::EngineModel::Camera* __pCamera; + bool __findCameraPass; + + typedef std::vector CacheListType; + typedef CacheListType::size_type CacheListSizeType; + CacheListType __caches; + + typedef std::vector DeadCacheListType; + typedef DeadCacheListType::size_type DeadCacheListSizeType; + DeadCacheListType __deadCaches; + + //States + GLenum __alphaBlendSource; + GLenum __alphaBlendDestination; + + bool __depthTestState; + + GLint __currentFrameBuffer; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderPtr; + +class SetWorldViewProjection: + public RenderCommand +{ +public: + SetWorldViewProjection(GLuint aLocation); + virtual ~SetWorldViewProjection() {} + + virtual void Apply(Render*); +private: + GLuint __location; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::GraphicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_H_ + diff --git a/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderBufferCache.h b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderBufferCache.h new file mode 100644 index 0000000..3b4c421 --- /dev/null +++ b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderBufferCache.h @@ -0,0 +1,165 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderBufferCache.h + * @brief Class for buffer caching + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_BUFFER_CACHE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_BUFFER_CACHE_H_ + +#include +#include +#include + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +class Render; + +class IBufferCache: + public RenderCache +{ +public: + IBufferCache(Render* pRender); + virtual ~IBufferCache(void); + + static GLenum GetGlUsage(Tizen::Ui::Effects::_Renderer::EngineModel::SolidBufferStrategy::BufferUsage::Value usage); + static GLenum GetGlDataType(Tizen::Ui::Effects::_Renderer::EngineModel::TypedBufferStrategy::DataType::Value dataType); + static GLsizei GetGlDataTypeSize(Tizen::Ui::Effects::_Renderer::EngineModel::TypedBufferStrategy::DataType::Value dataType); + + virtual void DropCache(void); + virtual void DestroyCache(void); + +protected: + GLuint _bufferId; + GLenum _dataType; +}; + +class IndexBufferCache: + public IBufferCache +{ +public: + IndexBufferCache(Render* pRender, Tizen::Ui::Effects::_Renderer::EngineModel::IndexBuffer* pBuffer); + virtual ~IndexBufferCache(void); + + static GLenum GetGlPrimitiveType(Tizen::Ui::Effects::_Renderer::EngineModel::IndexBuffer::PrimitiveType::Value primitiveType); + + virtual void Die(void); + virtual void Validate(Render*); + virtual void DestroyCache(void); + + void DrawElements(Render*); + +private: + GLsizei __elementsCount; + GLenum __primitiveType; + Tizen::Ui::Effects::_Renderer::EngineModel::IndexBuffer* __pBuffer; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr IndexBufferCachePtr; + +class VertexBufferCache: + public IBufferCache +{ +public: + VertexBufferCache(Render* pRender): IBufferCache(pRender) {} + virtual ~VertexBufferCache(void) {} + + virtual void BindToAttrib(Render*, GLuint index) = 0; + virtual void BindAsVertices(Render*) = 0; + virtual void BindAsColor(Render*) = 0; + virtual void BindAsTexCoord(Render*, GLuint stage) = 0; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr VertexBufferCachePtr; + +class SolidVertexBufferCache: + public VertexBufferCache +{ +public: + SolidVertexBufferCache(Render *pRender, Tizen::Ui::Effects::_Renderer::EngineModel::VertexBuffer* pBuffer); + virtual ~SolidVertexBufferCache(void); + + virtual void Die(void); + virtual void Validate(Render*); + virtual void DestroyCache(); + + void BindToAttrib(Render*, GLuint index); + void BindAsVertices(Render*); + void BindAsColor(Render*); + void BindAsTexCoord(Render*, GLuint stage); + +private: + GLint __componentsPerElement; + Tizen::Ui::Effects::_Renderer::EngineModel::VertexBuffer* __pBuffer; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr SolidVertexBufferCachePtr; + +class PartVertexBufferCache: + public VertexBufferCache +{ +public: + PartVertexBufferCache(Render *pRender, Tizen::Ui::Effects::_Renderer::EngineModel::PartVertexBuffer* pBuffer); + virtual ~PartVertexBufferCache(void); + + virtual void Die(void); + virtual void Validate(Render*); + virtual void DestroyCache(void); + + void BindToAttrib(Render*, GLuint index); + void BindAsVertices(Render*); + void BindAsColor(Render*); + void BindAsTexCoord(Render*, GLuint stage); + +private: + GLint __componentsPerElement; + GLsizei __stride; + GLvoid* __pOffset; + Tizen::Ui::Effects::_Renderer::EngineModel::PartVertexBuffer* __pBuffer; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr PartVertexBufferCachePtr; + +class CompositeVertexBufferCache: + public IBufferCache +{ +public: + CompositeVertexBufferCache(Render *pRender, Tizen::Ui::Effects::_Renderer::EngineModel::CompositeVertexBuffer* pBuffer); + virtual ~CompositeVertexBufferCache(void); + + virtual void Die(void); + virtual void Validate(Render*); + virtual void DestroyCache(void); + + void Bind(Render*); + +private: + Tizen::Ui::Effects::_Renderer::EngineModel::CompositeVertexBuffer* __pBuffer; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr CompositeVertexBufferCachePtr; + +}}}}} // Tizen::Ui::Effects::_Renderer::GraphicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_BUFFER_CACHE_H_ diff --git a/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderCache.h b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderCache.h new file mode 100644 index 0000000..a47ab77 --- /dev/null +++ b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderCache.h @@ -0,0 +1,91 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderCache.h + * @brief Class for rendering cache + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_CACHE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_CACHE_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +class Render; + +class RenderCacheImpl +{ +public: + RenderCacheImpl(Render* pRender): __pCreator(pRender), __cacheIndex(static_cast(0)) {} + virtual ~RenderCacheImpl(void) {} + +protected: + void InternalForceToDie(void); //need to be called when cache stops to be need + virtual void Validate(Render*) = 0; //called by renderer to validate / rebuild cache + bool InternalAlive(void) { return null != __pCreator; } + + virtual void InvalidateImpl(void) = 0; + + void InternalDestroyCache(void); + void InternalDropCache(void); + + virtual void DropCache(void) {} //called by renderer when cache must be dropped (not destroyed). On this call all 3D handlers must be forgotten. + virtual void DestroyCache(void) {} //called by renderer when cache must be destroyed. All 3D handlers must be destroyed correctly. + +private: + friend class Render; + + Render* __pCreator; + size_t __cacheIndex; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderCacheImplPtr; + +template +class RenderCacheMix: + public RenderCacheImpl, public ConcreteModelCache +{ +public: + RenderCacheMix(Render* pRender) : RenderCacheImpl(pRender) {} + virtual ~RenderCacheMix(void) {} + + virtual void Die(void) + { + RenderCacheImpl::InternalForceToDie(); + return; + } + +protected: + virtual void InvalidateImpl(void) + { + ConcreteModelCache::Invalidate(); + return; + } +}; + +typedef RenderCacheMix RenderCache; +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderCachePtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::GraphicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_CACHE_H_ diff --git a/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderCommand.h b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderCommand.h new file mode 100644 index 0000000..9bbf5a6 --- /dev/null +++ b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderCommand.h @@ -0,0 +1,47 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderCommand.h + * @brief Base class for render command (single OpenGL command) + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_COMMAND_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_COMMAND_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +class Render; + +class RenderCommand +{ +public: + RenderCommand(void) {} + virtual ~RenderCommand(void) {} + + virtual void Apply(Render*) = 0; +}; + +typedef System::SmartPtr RenderCommandPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::GraphicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_COMMAND_H_ diff --git a/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderDrawableCache.h b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderDrawableCache.h new file mode 100644 index 0000000..0cfc177 --- /dev/null +++ b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderDrawableCache.h @@ -0,0 +1,294 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderDrawableCache.h + * @brief Class for drawable objects cache + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_DRAWABLE_CACHE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_DRAWABLE_CACHE_H_ + +#include +#include + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +class Render; +class IndexBufferCache; +class VertexBufferCache; +class VertexBufferCache; +class VertexBufferCache; +class CompositeVertexBufferCache; +class CompositeVertexBufferCache; +class CompositeVertexBufferCache; +class RenderTexture2dCache; +class RenderProgramCache; + +class UseProgram: + public RenderCommand +{ +public: + UseProgram(RenderProgramCache* pProgram); + virtual ~UseProgram(void) {} + + virtual void Apply(Render*); + +private: + RenderProgramCache* __pProgram; +}; + +class DisableProgramAttributers: + public RenderCommand +{ +public: + DisableProgramAttributers(RenderProgramCache* pProgram); + virtual ~DisableProgramAttributers(void) {} + + virtual void Apply(Render*); + +private: + RenderProgramCache* __pProgram; +}; + +class Sampler2dUniform: + public RenderCommand +{ +public: + Sampler2dUniform(RenderTexture2dCache* pTexture, GLuint unit); + virtual ~Sampler2dUniform(void) {} + + virtual void Apply(Render*); + +private: + RenderTexture2dCache* __pTexture; + GLuint __stage; +}; + +class Sampler2dAttachmentUniform: + public RenderCommand +{ +public: + Sampler2dAttachmentUniform(Texture2dAttachmentCache* pTexture, GLuint unit); + virtual ~Sampler2dAttachmentUniform(void) {} + +virtual void Apply(Render*); + +private: + Texture2dAttachmentCache* __pTexture; + GLuint __stage; +}; + +class Matrix4fUniform: + public RenderCommand +{ +public: + Matrix4fUniform(Tizen::Ui::Effects::_Renderer::EngineModel::Matrix4fProperty* pUniform, GLuint location); + virtual ~Matrix4fUniform(void) {} + + virtual void Apply(Render*); + +private: + Tizen::Ui::Effects::_Renderer::EngineModel::Matrix4fProperty* __pUniform; + GLuint __location; +}; + +class IntUniform: + public RenderCommand +{ +public: + IntUniform(Tizen::Ui::Effects::_Renderer::EngineModel::IntProperty* pUniform, GLuint location); + virtual ~IntUniform(void) {} + + virtual void Apply(Render*); + +private: + Tizen::Ui::Effects::_Renderer::EngineModel::IntProperty* __pUniform; + GLuint __location; +}; + +class FloatUniform: + public RenderCommand +{ +public: + FloatUniform(Tizen::Ui::Effects::_Renderer::EngineModel::FloatProperty* pUniform, GLuint location); + virtual ~FloatUniform(void) {} + + virtual void Apply(Render*); + +private: + Tizen::Ui::Effects::_Renderer::EngineModel::FloatProperty* __pUniform; + GLuint __location; +}; + +class FloatArrayUniform: + public RenderCommand +{ +public: + FloatArrayUniform(Tizen::Ui::Effects::_Renderer::EngineModel::FloatArrayProperty* pUniform, GLuint location); + virtual ~FloatArrayUniform(void) {} + + virtual void Apply(Render*); + +private: + Tizen::Ui::Effects::_Renderer::EngineModel::FloatArrayProperty* __pUniform; + GLuint __location; +}; + +class Vector2fUniform: + public RenderCommand +{ +public: + Vector2fUniform(Tizen::Ui::Effects::_Renderer::EngineModel::Vector2fProperty* pUniform, GLuint location); + virtual ~Vector2fUniform(void) {} + + virtual void Apply(Render*); + +private: + Tizen::Ui::Effects::_Renderer::EngineModel::Vector2fProperty* __pUniform; + GLuint __location; +}; + +class Vector3fUniform: + public RenderCommand +{ +public: + Vector3fUniform(Tizen::Ui::Effects::_Renderer::EngineModel::Vector3fProperty* pUniform, GLuint location); + virtual ~Vector3fUniform(void) {} + + virtual void Apply(Render*); + +private: + Tizen::Ui::Effects::_Renderer::EngineModel::Vector3fProperty* __pUniform; + GLuint __location; +}; + +class Vector4fUniform: + public RenderCommand +{ +public: + Vector4fUniform(Tizen::Ui::Effects::_Renderer::EngineModel::Vector4fProperty* pUniform, GLuint location); + virtual ~Vector4fUniform(void) {} + + virtual void Apply(Render*); + +private: + Tizen::Ui::Effects::_Renderer::EngineModel::Vector4fProperty* _pUniform; + GLuint __location; +}; + +class ProgramAttribute: + public RenderCommand +{ +public: + ProgramAttribute(VertexBufferCache* pAttribute, GLuint location); + virtual ~ProgramAttribute(void) {} + + virtual void Apply(Render*); + +private: + VertexBufferCache* __pAttribute; + GLuint __location; +}; + +class BindBuffer: + public RenderCommand +{ +public: + BindBuffer(CompositeVertexBufferCache* pBuffer); + virtual ~BindBuffer(void) {} + + virtual void Apply(Render*); + +private: + CompositeVertexBufferCache* __pBuffer; +}; + +class DrawIndexed: + public RenderCommand +{ +public: + DrawIndexed(IndexBufferCache* pBuffer); + virtual ~DrawIndexed(void) {} + + virtual void Apply(Render*); + +private: + IndexBufferCache* __pBuffer; +}; + +class SetState: + public RenderCommand +{ +public: + SetState(RenderStateCache* pState); + virtual ~SetState(void) {} + + virtual void Apply(Render*); + +private: + RenderStateCache* __pState; +}; + +class RenderDrawableCache: + public RenderCache +{ +public: + typedef std::vector RenderCommandsListType; + typedef RenderCommandsListType::size_type RenderCommandsListSizeType; + + typedef std::vector ExternalTexturesListType; + typedef ExternalTexturesListType::size_type ExternalTexturesListSizeType; + + RenderDrawableCache(Render* pRender, Tizen::Ui::Effects::_Renderer::EngineModel::Drawable* pDrawable); + virtual ~RenderDrawableCache(void); + + virtual void Die(void); + virtual void DropCache(void); + virtual void DestroyCache(void); + + virtual void Validate(Render*); + + void Draw(Render*); + const Math::Matrix4f& GetWorld(void); + bool HasAlphaBlend(Render*); + + ExternalTexturesListSizeType NumExternalTextures(void); + Tizen::Ui::Effects::_Renderer::EngineModel::TextureAttachment* GetExternalTexture(ExternalTexturesListSizeType index); + +private: + RenderCommandsListType __commands; + RenderCommandsListType __ownCommands; + Tizen::Ui::Effects::_Renderer::EngineModel::Drawable* __pDrawable; + ExternalTexturesListType __externalTextures; + + RenderStateCache* __pAlphaBlend; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderDrawableCachePtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::GraphicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_DRAWABLE_CACHE_H_ diff --git a/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderRenderTargetCache.h b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderRenderTargetCache.h new file mode 100644 index 0000000..3f9e56c --- /dev/null +++ b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderRenderTargetCache.h @@ -0,0 +1,117 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderRenderTargetCache.h + * @brief Class for render targets cache + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_RENDER_TARGET_CACHE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_RENDER_TARGET_CACHE_H_ + +#include +#include +#include +#include + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +class Render; + +class StubAttachmentCache: + public RenderCache +{ +public: + StubAttachmentCache(Render *pRender, Tizen::Ui::Effects::_Renderer::EngineModel::StubAttachment* pStubAttachment); + virtual ~StubAttachmentCache(void); + + void AttachToFrameBuffer(Render* pRender, GLenum attachment, GLuint width, GLuint height); + + virtual void Die(void); + virtual void DropCache(void); + virtual void DestroyCache(void); + + virtual void Validate(Render* pRender); + +protected: + GLuint _width; + GLuint _height; + Tizen::Ui::Effects::_Renderer::EngineModel::StubAttachment* _pStubAttachment; + GLuint _id; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr StubAttachmentCachePtr; + +class Texture2dAttachmentCache: + public RenderCache +{ +public: + Texture2dAttachmentCache(Render *pRender, Tizen::Ui::Effects::_Renderer::EngineModel::Texture2dAttachmentProperty* pTexture2DAttachmentProperty); + virtual ~Texture2dAttachmentCache(); + + void AttachToFrameBuffer(Render* pRender, GLenum attachment, GLuint width, GLuint height, GLuint mipmap); + void Bind(Render* pRender, GLuint stage); + + virtual void Die(void); + virtual void DropCache(void); + virtual void DestroyCache(void); + + virtual void Validate(Render*); + void Validate(Render* aRender, GLuint aStage); + +protected: + GLuint _width; + GLuint _height; + Tizen::Ui::Effects::_Renderer::EngineModel::Texture2dAttachmentProperty* _pTexture2DAttachmentProperty; + GLuint _id; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr Texture2DAttachmentCachePtr; + +class RenderTargetExternalRenderCache: + public RenderCache +{ +public: + RenderTargetExternalRenderCache(Render *pRender, Tizen::Ui::Effects::_Renderer::EngineModel::RenderTargetExternalRender* pRenderTargetExternalRender); + virtual ~RenderTargetExternalRenderCache(void); + + void Draw(Render* pRender); + + virtual void Die(void); + virtual void DropCache(void); + virtual void DestroyCache(void); + + virtual void Validate(Render* pRender); + +protected: + Tizen::Ui::Effects::_Renderer::EngineModel::RenderTargetExternalRender* _pRenderTargetExternalRender; + GLuint _id; + int _ppp; + GLuint _numColorBuffers; + GLenum _colorBuffers[EngineModel::RenderTarget::Attachment::ATTACHMENT_MAX]; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderTargetExternalRenderCachePtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::GraphicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_RENDER_TARGET_CACHE_H_ diff --git a/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderShaderCache.h b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderShaderCache.h new file mode 100644 index 0000000..b33c8da --- /dev/null +++ b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderShaderCache.h @@ -0,0 +1,116 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderShaderCache.h + * @brief Class for render shaders cache + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_SHADER_CACHE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_SHADER_CACHE_H_ + +#include +#include +#include +#include + +#include +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +class Render; + +class RenderShaderCache: + public RenderCache +{ +public: + RenderShaderCache(Render *pRender, Tizen::Ui::Effects::_Renderer::EngineModel::ShaderProperty* pShader); + virtual ~RenderShaderCache(void); + + static GLenum GetShaderType(Tizen::Ui::Effects::_Renderer::EngineModel::ShaderProperty::ShaderType::Value shaderType); + static bool IsBinary(Tizen::Ui::Effects::_Renderer::EngineModel::ShaderProperty::DataType::Value dataType); + + virtual void Die(void); + virtual void DropCache(void); + virtual void DestroyCache(void); + + virtual void Validate(Render*); + + void AttachToProgram(Render*, GLuint programId); + +protected: + GLuint _shaderId; + Tizen::Ui::Effects::_Renderer::EngineModel::ShaderProperty* _pShader; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderShaderCachePtr; + +class RenderProgramCache: + public RenderCache +{ +public: + struct GlInfo + { + GLuint location; + GLenum type; + GLint size; + }; + + typedef std::vector > AttribuleListType; + typedef AttribuleListType UniformListType; + typedef AttribuleListType::size_type AttribuleListSizeType; + typedef AttribuleListSizeType UniformListSizeType; + typedef AttribuleListType::value_type AttribuleListValueType; + typedef AttribuleListValueType UniformListValueType; + + RenderProgramCache(Render *pRender, Tizen::Ui::Effects::_Renderer::EngineModel::ProgramProperty* pProgram); + virtual ~RenderProgramCache(void); + + virtual void Die(void); + virtual void DropCache(void); + virtual void DestroyCache(void); + + virtual void Validate(Render*); + + void UseProgram(Render*); + void DisableAttributes(Render*); + void EnableAttributes(Render*); + const AttribuleListValueType& GetAttribute(AttribuleListSizeType index); + AttribuleListSizeType GetNumAttributes(void); + const UniformListValueType& GetUniform(UniformListSizeType index); + UniformListSizeType GetNumUniforms(void); + +protected: + AttribuleListType _attributes; + UniformListType _uniforms; + + GLuint _programId; + RenderShaderCache* _pVertexShader; + RenderShaderCache* _pFragmentShader; + Tizen::Ui::Effects::_Renderer::EngineModel::ProgramProperty* _pProgram; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderProgramCachePtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::GraphicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_SHADER_CACHE_H_ diff --git a/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderStateCache.h b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderStateCache.h new file mode 100644 index 0000000..3612324 --- /dev/null +++ b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderStateCache.h @@ -0,0 +1,74 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderStateCache.h + * @brief Class for render states cache + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_STATE_CACHE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_STATE_CACHE_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +class Render; + +class RenderStateCache: + public RenderCache +{ +public: + RenderStateCache(Render* pRender): RenderCache(pRender) {} + virtual ~RenderStateCache(void) {} + + virtual bool IsEnable(Render*) = 0; + virtual void Set(Render*) = 0; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderStateCachePtr; + +class RenderAlphaBlendCache: + public RenderStateCache +{ +public: + static GLenum GetGlBlendFactor(Tizen::Ui::Effects::_Renderer::EngineModel::AlphaBlendProperty::BlendFactor::Value value); + + RenderAlphaBlendCache(Render* pRender, Tizen::Ui::Effects::_Renderer::EngineModel::AlphaBlendProperty* pState); + virtual ~RenderAlphaBlendCache(void); + + virtual void Validate(Render*); + + bool IsEnable(Render*); + void Set(Render*); + +private: + Tizen::Ui::Effects::_Renderer::EngineModel::AlphaBlendProperty* __pState; + GLenum __source; + GLenum __destination; + bool __isEnabled; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderAlphaBlendCachePtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::GraphicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_STATE_CACHE_H_ diff --git a/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderTextureCache.h b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderTextureCache.h new file mode 100644 index 0000000..d0763bf --- /dev/null +++ b/src/ui/effects/inc/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderTextureCache.h @@ -0,0 +1,85 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderTextureCache.h + * @brief Class for render textures cache + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_TEXTURE_CACHE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_TEXTURE_CACHE_H_ + +#include +#include +#include +#include + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +class RenderTextureCache: + public RenderCache +{ +public: + RenderTextureCache(Render* pRender); + virtual ~RenderTextureCache(void); + + static GLenum GetGlInternalFormat(Tizen::Ui::Effects::_Renderer::EngineModel::TextureProperty::InternalFormat::Value internalFormat); + static GLenum GetGlDataFormat(Tizen::Ui::Effects::_Renderer::EngineModel::TextureProperty::DataFormat::Value dataFormat); + static GLenum GetGlDataType(Tizen::Ui::Effects::_Renderer::EngineModel::TextureProperty::DataType::Value dataType); + static GLenum GetGlFilterType(Tizen::Ui::Effects::_Renderer::EngineModel::TextureProperty::FilterType::Value filterType); + static GLenum GetGlWrapType(Tizen::Ui::Effects::_Renderer::EngineModel::TextureProperty::WrapType::Value wrapType); + + virtual void DropCache(void); + virtual void DestroyCache(void); + + virtual void Bind(Render*, GLuint stage) = 0; + +protected: + GLuint _textureId; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderTextureCachePtr; + +class RenderTexture2dCache: + public RenderTextureCache +{ +public: + RenderTexture2dCache(Render* pRender, Tizen::Ui::Effects::_Renderer::EngineModel::Texture2dProperty* pTexture); + virtual ~RenderTexture2dCache(void); + + virtual void Validate(Render*); + void Validate(Render*, GLuint stage); + + virtual void Bind(Render*, GLuint stage); + + virtual void Die(void); + virtual void DestroyCache(void); + +private: + Tizen::Ui::Effects::_Renderer::EngineModel::Texture2dProperty* __pTexture; +}; + +typedef Tizen::Ui::Effects::_Renderer::System::SmartPtr RenderTexture2DCachePtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::GraphicsEngine + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_GRAPHICS_ENGINE_RENDER_TEXTURE_CACHE_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathAdapterFunctions.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathAdapterFunctions.h new file mode 100644 index 0000000..0fbc288 --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathAdapterFunctions.h @@ -0,0 +1,290 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathAdapterFunctions.h + * @brief The adapter math functions for user types + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_ADAPTER_FUNCTIONS_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_ADAPTER_FUNCTIONS_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ + +inline float EffectsSqrt(float value); +inline double EffectsSqrt(double value); + +inline float EffectsCos(float angle); +inline double EffectsCos(double angle); +inline float EffectsAcos(float angle); +inline double EffectsAcos(double angle); + +inline float EffectsSin(float angle); +inline double EffectsSin(double angle); +inline float EffectsAsin(float angle); +inline double EffectsAsin(double angle); + +template inline T EffectsAbs(const T& value); +inline float EffectsAbs(const float& value); +inline double EffectsAbs(const double& value); + +inline float EffectsAtan2(float x, float y); +inline double EffectsAtan2(double x, double y); + +inline float EffectsAtan(float value); +inline double EffectsAtan(double value); + +template struct EffectsEpsilon +{ + static inline const T& Epsilon(void) + { + return get_epsilon(static_cast(0)); + } +}; + +template<> struct EffectsEpsilon +{ + static inline const float& Epsilon(void) + { + return F_EPS; + } +}; + +template<> struct EffectsEpsilon +{ + static inline const double& Epsilon(void) + { + return D_EPS; + } +}; + +inline bool EffectsEqual(const float& lhv, const float& rhv, const float& epsilon = F_EPS); +inline bool EffectsEqual(const double& lhv, const double& rhv, const double& epsilon = D_EPS); + +template inline void EffectsSwap(T& lhv, T& rhv); +inline void EffectsSwap(float& lhv, float& rhv); +inline void EffectsSwap(double& lhv, double& rhv); + +template inline T EffectsClamp(const T& value, const T& min, const T& max); +inline float EffectsClamp(const float& value, const float& min, const float& max); +inline double EffectsClamp(const double& value, const double& min, const double& max); + +template inline T EffectsLerp(const T& from, const T& to, const T& coeff); +inline float EffectsLerp(const float& from, const float& to, const float& coeff); +inline double EffectsLerp(const double& from, const double& to, const double& coeff); +inline int EffectsLerp(const int& from, const int& to, const int& coeff); +inline unsigned int EffectsLerp(const unsigned int& from, const unsigned int& to, const unsigned int& coeff); + +template inline T EffectsMin(const T& a1, const T& a2); +template inline T EffectsMin3(const T& a1, const T& a2, const T& a3); +template inline T EffectsMax(const T& a1, const T& a2); +template inline T EffectsMax3(const T& a1, const T& a2, const T& a3); + +inline float EffectsSqrt(float value) +{ + return sqrtf(value); +} +inline double EffectsSqrt(double value) +{ + return sqrt(value); +} + +template inline bool EffectsEqual(const T& lhv, const T& rhv, const T& epsilon = EffectsEpsilon::epsilon()) +{ + return lhv == rhv; +} +inline bool EffectsEqual(const float& lhv, const float& rhv, const float& epsilon) +{ + return (lhv + epsilon >= rhv) && (lhv - epsilon <= rhv); +} +inline bool EffectsEqual(const double& lhv, const double& rhv, const double& epsilon) +{ + return (lhv + epsilon >= rhv) && (lhv - epsilon <= rhv); +} + +inline float EffectsCos(float angle) +{ + return cosf(angle); +} +inline double EffectsCos(double angle) +{ + return cos(angle); +} +inline float EffectsAcos(float angle) +{ + return acosf(angle); +} +inline double EffectsAcos(double angle) +{ + return acos(angle); +} + +inline float EffectsSin(float angle) +{ + return sinf(angle); +} +inline double EffectsSin(double angle) +{ + return sin(angle); +} + +inline float EffectsAsin(float angle) +{ + return asinf(angle); +} +inline double EffectsAsin(double angle) +{ + return asin(angle); +} + +template inline T EffectsAbs(const T& value) +{ + return abs(value); +} +inline float EffectsAbs(const float &value) +{ + return fabsf(value); +} +inline double EffectsAbs(const double &value) +{ + return fabs(value); +} + +inline float EffectsAtan2(float x, float y) +{ + return atan2f(x, y); +} +inline double EffectsAtan2(double x, double y) +{ + return atan2(x, y); +} + +inline float EffectsAtan(float value) +{ + return atanf(value); +} +inline double EffectsAtan(double value) +{ + return atan(value); +} + +template inline void EffectsSwap(T& lhv, T& rhv) +{ + T temp(lhv); + lhv = rhv; + rhv = temp; +} +inline void EffectsSwap(float& lhv, float& rhv) +{ + std::swap(lhv, rhv); +} +inline void EffectsSwap(double& lhv, double& rhv) +{ + std::swap(lhv, rhv); +} + +template inline T EffectsClamp(const T& value, const T& min, const T& max) +{ + if (value < min) + { + return min; + } + if (value > max) + { + return max; + } + return value; +} +inline float EffectsClamp(const float& value, const float& min, const float& max) +{ + if (value < min) + { + return min; + } + if (value > max) + { + return max; + } + return value; +} +inline double EffectsClamp(const double& value, const double& min, const double& max) +{ + if (value < min) + { + return min; + } + if (value > max) + { + return max; + } + return value; +} + +template inline T EffectsLerp(const T& from, const T& to, const T& coeff) +{ + return from + (to - from) * coeff; +} +inline float EffectsLerp(const float& from, const float& to, const float& coeff) +{ + return from + (to - from) * coeff; +} +inline double EffectsLerp(const double& from, const double& to, const double& coeff) +{ + return from + (to - from) * coeff; +} +inline int EffectsLerp(const int& from, const int& to, const int& coeff) +{ + return from + (((to - from) * coeff) >> 8); +} +inline unsigned int EffectsLerp(const unsigned int& from, const unsigned int& to, const unsigned int& coeff) +{ + return from + (((to - from) * coeff) >> 8); +} + +template inline T EffectsMin(const T& a1, const T& a2) +{ + if (a1 < a2) + { + return a1; + } + return a2; +} +template inline T EffectsMin3(const T& a1, const T& a2, const T& a3) +{ + return EffectsMin(EffectsMin(a1, a2), a3); +} +template inline T EffectsMax(const T& a1, const T& a2) +{ + if (a1 < a2) + { + return a2; + } + + return a1; +} +template inline T EffectsMax3(const T& a1, const T& a2, const T& a3) +{ + return EffectsMax(EffectsMax(a1, a2), a3); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_ADAPTER_FUNCTIONS_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathCommon.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathCommon.h new file mode 100644 index 0000000..8b53d2d --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathCommon.h @@ -0,0 +1,61 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathCommon.h + * @brief The common math functions and constants + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_COMMON_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_COMMON_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ + +const float F_EPS = std::numeric_limits::epsilon(); +const double D_EPS = std::numeric_limits::epsilon(); + +const double D_PI_2 = 6.283185307179586232; +const double D_PI = D_PI_2 * 0.5; +const float F_PI_2 = float(D_PI_2); +const float F_PI = float(D_PI); + +const double D_DEG_2_RAD_COEFF = D_PI / 180.0; +const double D_RAD_2_DEG_COEFF = 180.0 / D_PI; +const float F_DEG_2_RAD_COEFF = float(D_DEG_2_RAD_COEFF); +const float F_RAD_2_DEG_COEFF = float(D_RAD_2_DEG_COEFF); + +inline double D_Deg_2_Rad(double deg) { return deg * D_DEG_2_RAD_COEFF; } +inline float F_Deg_2_Rad(float deg) { return deg * F_DEG_2_RAD_COEFF; } +inline double D_Rad_2_Deg(double rad) { return rad * D_RAD_2_DEG_COEFF; } +inline float F_Rad_2_Deg(float rad) { return rad * F_RAD_2_DEG_COEFF; } + +enum RotationOrder3 {ROTATION_XYZ = 0, ROTATION_XZY, ROTATION_YXZ, ROTATION_YZX, ROTATION_ZXY, ROTATION_ZYX, ROTATION3_MAX}; + +template inline bool IsPowerOf2(T value) //only for positive integers +{ + return (value & (value - T(1))) == T(0); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_COMMON_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrix.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrix.h new file mode 100644 index 0000000..e1662f4 --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrix.h @@ -0,0 +1,1088 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathMatrix.h + * @brief The Matrix class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX_H_ + +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ +template +class Matrix : + public MatrixTraits +{ +public: + typedef Matrix MatrixType; + typedef Vector VectorType; + typedef MatrixTraitsBase MatrixTraitsBaseType; + typedef typename MatrixTraitsBaseType::TypeReference TypeReference; + + using MatrixTraitsBaseType::data; + using MatrixTraits::Set; + using MatrixTraits::CreateScale; + using MatrixTraits::MakeScale; + using MatrixTraits::Scale; + using MatrixTraits::SetScale; + using MatrixTraits::ApplyTransform; + using MatrixTraits::GetAppliedTransform; + + inline Matrix(void); + inline explicit Matrix(const TypeReference value); + inline Matrix(const TypeReference a11, const TypeReference a12, + const TypeReference a21, const TypeReference a22); + + inline Matrix(const TypeReference a11, const TypeReference a12, const TypeReference a13, + const TypeReference a21, const TypeReference a22, const TypeReference a23, + const TypeReference a31, const TypeReference a32, const TypeReference a33); + + inline Matrix(const TypeReference a11, const TypeReference a12, const TypeReference a13, const TypeReference a14, + const TypeReference a21, const TypeReference a22, const TypeReference a23, const TypeReference a24, + const TypeReference a31, const TypeReference a32, const TypeReference a33, const TypeReference a34, + const TypeReference a41, const TypeReference a42, const TypeReference a43, const TypeReference a44); + + inline Matrix(const VectorType& i, const VectorType& j); + inline Matrix(const VectorType& i, const VectorType& j, const VectorType& k); + inline Matrix(const VectorType& i, const VectorType& j, const VectorType& k, const VectorType& c); + + inline Matrix(const MatrixType& other); + + inline MatrixType& operator = (const MatrixType& rhv); + + inline MatrixType& Set(const MatrixType& other); + inline MatrixType& Set(const TypeReference value); + + inline MatrixType& FillFromArray(const T* pArray); + static inline MatrixType MakeFromArray(const T* pArray); + + inline MatrixType& Identity(void); + inline bool IsIdentity(void) const; + + inline MatrixType operator-(void) const; + inline MatrixType& Inverse(void); + inline MatrixType GetInversed(void) const; + + inline MatrixType& Transpose(void); + inline MatrixType GetTransposed(void) const; + + inline MatrixType& operator+=(const MatrixType& rhv); + inline MatrixType& operator+=(const TypeReference rhv); + inline MatrixType& operator-=(const MatrixType& rhv); + inline MatrixType& operator-=(const TypeReference rhv); + inline MatrixType& operator*=(const MatrixType& rhv); + inline MatrixType& operator*=(const TypeReference rhv); + inline MatrixType& operator/=(const TypeReference rhv); + inline MatrixType GetMultipliedByMember(const MatrixType& rhv) const; + inline MatrixType& MultiplyByMember(const MatrixType& rhv); + static inline MatrixType CreateMultipliedByMember(const MatrixType& lhv, const MatrixType& rhv); + inline MatrixType GetDividedByMember(const MatrixType& rhv) const; + inline MatrixType& DivideByMember(const MatrixType& rhv); + static inline MatrixType CreateDividedByMember(const MatrixType& lhv, const MatrixType& rhv); + + inline T* GetPointer(void); + inline const T* GetPointer(void) const; + inline TypeReference Get(unsigned int row, unsigned int column); + inline const TypeReference Get(unsigned int row, unsigned int column) const; + inline TypeReference Get(unsigned int absIndex); + inline const TypeReference Get(unsigned int absIndex) const; + inline MatrixType& Set(unsigned int row, unsigned int column, const TypeReference value); + inline MatrixType& Set(unsigned int absIndex, const TypeReference value); + inline VectorType GetColumn(unsigned int column) const; + inline MatrixType& SetColumn(unsigned int column, const VectorType& value); + inline VectorType& GetRow(unsigned int row); + inline const VectorType& GetRow(unsigned int row) const; + inline MatrixType& SetRow(unsigned int row, const VectorType& value); + inline TypeReference operator()(unsigned int row, unsigned int column); + inline const TypeReference operator()(unsigned int row, unsigned int column) const; + inline TypeReference operator()(unsigned int absIndex); + inline const TypeReference operator()(unsigned int absIndex) const; + inline TypeReference operator[](unsigned int absIndex); + inline const TypeReference operator[](unsigned int absIndex) const; + + inline MatrixType& Lerp(const MatrixType& to, const TypeReference coeff); + inline MatrixType GetLerped(const MatrixType& to, const TypeReference coeff) const; + inline MatrixType& MakeLerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff); + static inline MatrixType CreateLerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff); + + inline TypeReference Magnitude(void) const; + inline TypeReference MagnitudeSqr(void) const; + inline TypeReference Trace(void) const; + inline Matrix MinorMatrix(unsigned int row, unsigned int column) const; + + inline TypeReference Determinant(void) const; + + inline VectorType& ApplyTransform(VectorType& vector) const; + inline VectorType GetAppliedTransform(const VectorType& vector) const; + + template + inline MatrixType& MakeScale(const Vector& scale); + template + inline MatrixType& SetScale(const Vector& scale); + template + static inline MatrixType CreateScale(const Vector& scale); + template + inline MatrixType& Scale(const Vector& scale); + + inline bool IsEqual(const Matrix& rhv, const TypeReference epsilon = EffectsEpsilon::epsilon()) const; +}; + +template +inline bool IsEqual(const Matrix& lhv, const Matrix& rhv, const typename Matrix::TypeReference epsilon); +template inline Matrix operator+(const Matrix& lhv, const Matrix& rhv); +template inline Matrix operator+(const Matrix& lhv, const typename Matrix::TypeReference rhv); +template inline Matrix operator+(const typename Matrix::TypeReference lhv, const Matrix& rhv); +template inline Matrix operator-(const Matrix& lhv, const Matrix& rhv); +template inline Matrix operator-(const Matrix& lhv, const typename Matrix::TypeReference rhv); +template inline Matrix operator-(const typename Matrix::TypeReference lhv, const Matrix& rhv); +template inline Matrix operator*(const Matrix& lhv, const Matrix& rhv); +template inline Matrix operator*(const Matrix& lhv, const typename Matrix::TypeReference rhv); +template inline Matrix operator*(const typename Matrix::TypeReference lhv, const Matrix& rhv); +template inline Vector operator*(const Matrix& lhv, const Vector& rhv); +template inline Vector operator*(const Vector& lhv, const Matrix& rhv); +template inline Vector operator*(const Matrix& lhv, const Vector& rhv); +template inline Vector operator*(const Vector& lhv, const Matrix& rhv); +template inline Matrix operator/(const Matrix& lhv, const typename Matrix::TypeReference rhv); +template inline Matrix operator/(const typename Matrix::TypeReference lhv, const Matrix& rhv); +template inline bool operator==(const Matrix& lhv, const Matrix& rhv); +template inline bool operator==(const Matrix& lhv, const typename Matrix::TypeReference rhv); +template inline bool operator==(const typename Matrix::TypeReference lhv, const Matrix& rhv); +template inline bool operator!=(const Matrix& lhv, const Matrix& rhv); +template inline bool operator!=(const Matrix& lhv, const typename Matrix::TypeReference rhv); +template inline bool operator!=(const typename Matrix::TypeReference lhv, const Matrix& rhv); + +typedef Matrix Matrix1f; +typedef Matrix Matrix1d; +typedef Matrix Matrix2f; +typedef Matrix Matrix2d; +typedef Matrix Matrix3f; +typedef Matrix Matrix3d; +typedef Matrix Matrix4f; +typedef Matrix Matrix4d; + +template +Matrix::Matrix(void) +{ + +} + +template +Matrix::Matrix(const TypeReference value) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] = VectorType(value); + } +} + +template +Matrix::Matrix(const TypeReference a11, const TypeReference a12, + const TypeReference a21, const TypeReference a22) +{ + EffectsStaticAssert(Dimension == 2); + + data[0].Set(a11, a12); + data[1].Set(a21, a22); +} + +template +Matrix::Matrix(const TypeReference a11, const TypeReference a12, const TypeReference a13, + const TypeReference a21, const TypeReference a22, const TypeReference a23, + const TypeReference a31, const TypeReference a32, const TypeReference a33) +{ + EffectsStaticAssert(Dimension == 3); + + data[0].Set(a11, a12, a13); + data[1].Set(a21, a22, a23); + data[2].Set(a31, a32, a33); +} + +template +Matrix::Matrix(const TypeReference a11, const TypeReference a12, const TypeReference a13, const TypeReference a14, + const TypeReference a21, const TypeReference a22, const TypeReference a23, const TypeReference a24, + const TypeReference a31, const TypeReference a32, const TypeReference a33, const TypeReference a34, + const TypeReference a41, const TypeReference a42, const TypeReference a43, const TypeReference a44) +{ + EffectsStaticAssert(Dimension == 4); + + data[0].Set(a11, a12, a13, a14); + data[1].Set(a21, a22, a23, a24); + data[2].Set(a31, a32, a33, a34); + data[3].Set(a41, a42, a43, a44); +} + +template +Matrix::Matrix(const VectorType& i, const VectorType& j) +{ + EffectsStaticAssert(Dimension == 2); + data[0] = i; + data[1] = j; +} + +template +Matrix::Matrix(const VectorType& i, const VectorType& j, const VectorType& k) +{ + EffectsStaticAssert(Dimension == 3); + data[0] = i; + data[1] = j; + data[2] = k; +} + +template +Matrix::Matrix(const VectorType& i, const VectorType& j, const VectorType& k, const VectorType& c) +{ + EffectsStaticAssert(Dimension == 4); + + data[0] = i; + data[1] = j; + data[2] = k; + data[3] = c; +} + +template +Matrix::Matrix(const MatrixType& other) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] = other.data[i]; + } +} + +template +Matrix& Matrix::operator=(const MatrixType& rhv) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] = rhv.data[i]; + } + return *this; +} + +template +typename Matrix::MatrixType& Matrix::Set(const MatrixType& other) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] = other.data[i]; + } + return *this; +} + +template +typename Matrix::MatrixType& Matrix::Set(const TypeReference value) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] = VectorType(value); + } + return *this; +} + +template +typename Matrix::MatrixType& Matrix::FillFromArray(const T* pValue) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] = VectorType::MakeFromArray(&pValue[Dimension * i]); + } + + return *this; +} + +template +typename Matrix::MatrixType Matrix::MakeFromArray(const T* pValue) +{ + MatrixType result; + result.FillFromArray(pValue); + return result; +} + +template +typename Matrix::MatrixType& Matrix::Identity(void) +{ + *this = MatrixType::GetIdentity(); + return *this; +} + +template +bool Matrix::IsIdentity(void) const +{ + return *this == MatrixType::GetIdentity(); +} + +template +typename Matrix::MatrixType Matrix::operator-(void) const +{ + MatrixType result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = -data[i]; + } + return result; +} + +template +typename Matrix::MatrixType& Matrix::Inverse(void) +{ + static const T t0(0.0f); + static const T t1(1.0f); + + T det = Determinant(); + if (EffectsEqual(det, t0)) return *this; + + det = t1 / det; + MatrixType result; + for (int i = 0; i < Dimension; ++i) + { + for (int j = 0; j < Dimension; ++j) + { + result.data[i].data[j] = ((i+j) % 2 == 0 ? 1 : -1) * det * MinorMatrix(j, i).Determinant(); + } + } + return *this = result; +} + +template +typename Matrix::MatrixType Matrix::GetInversed(void) const +{ + MatrixType result(*this); + return result.Inverse(); +} + +template +typename Matrix::MatrixType& Matrix::Transpose(void) +{ + for (int i = 0; i < Dimension; ++i) + { + for (int j = i + 1; j < Dimension; ++j) + { + EffectsSwap(data[j].data[i], data[i].data[j]); + } + } + return *this; +} + +template +typename Matrix::MatrixType Matrix::GetTransposed(void) const +{ + MatrixType trasposed = *this; + return trasposed.Transpose(); +} + +template +typename Matrix::MatrixType& Matrix::operator+=(const MatrixType& rhv) +{ + for (int i = 0; i < Dimension; ++i) + { + data[i] += rhv.data[i]; + } + return *this; +} + +template +typename Matrix::MatrixType& Matrix::operator+=(const TypeReference rhv) +{ + for (int i = 0; i < Dimension; ++i) + { + data[i] += rhv; + } + return *this; +} + +template +typename Matrix::MatrixType& Matrix::operator-=(const MatrixType& rhv) +{ + for (int i = 0; i < Dimension; ++i) + { + data[i] -= rhv.data[i]; + } + return *this; +} + +template +typename Matrix::MatrixType& Matrix::operator-=(const TypeReference rhv) +{ + for (int i = 0; i < Dimension; ++i) + { + data[i] -= rhv; + } + return *this; +} + +template +typename Matrix::MatrixType& Matrix::operator*=(const MatrixType& rhv) +{ + MatrixType result(T(0.0f)); + for (int i = 0; i < Dimension; ++i) + { + for (int j = 0; j < Dimension; ++j) + { + for (int k = 0; k < Dimension; ++k) + result.data[i].data[j] += data[i].data[k] * rhv.data[k].data[j]; + } + } + *this = result; + return *this; +} + +template +typename Matrix::MatrixType& Matrix::operator*=(const TypeReference rhv) +{ + for (int i = 0; i < Dimension; ++i) + { + data[i] *= rhv; + } + return *this; +} + +template +typename Matrix::MatrixType& Matrix::operator/=(const TypeReference rhv) +{ + for (int i = 0; i < Dimension; ++i) + { + data[i] /= rhv; + } + return *this; +} + +template +typename Matrix::MatrixType Matrix::GetMultipliedByMember(const MatrixType& rhv) const +{ + MatrixType result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i].Set(data[i] * rhv.data[i]); + } + return result; +} + +template +typename Matrix::MatrixType& Matrix::MultiplyByMember(const MatrixType& rhv) +{ + for (int i = 0; i < Dimension; ++i) + { + data[i] = data[i] * rhv.data[i]; + } + return *this; +} + +template +typename Matrix::MatrixType Matrix::CreateMultipliedByMember(const MatrixType& lhv, const MatrixType& rhv) +{ + MatrixType temp(lhv); + temp.MultiplyByMember(rhv); + return temp; +} + +template +typename Matrix::MatrixType Matrix::GetDividedByMember(const MatrixType& rhv) const +{ + MatrixType result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i].Set(data[i] / rhv.data[i]); + } + return result; +} + +template +typename Matrix::MatrixType& Matrix::DivideByMember(const MatrixType& rhv) +{ + for (int i = 0; i < Dimension; ++i) + { + data[i] = data[i] / rhv.data[i]; + } + return *this; +} + +template +typename Matrix::MatrixType Matrix::CreateDividedByMember(const MatrixType& lhv, const MatrixType& rhv) +{ + MatrixType temp(lhv); + temp.DivideByMember(rhv); + return temp; +} + +template +T* Matrix::GetPointer(void) +{ + return data[0].GetPointer(); +} + +template +const T* Matrix::GetPointer(void) const +{ + return data[0].GetPointer(); +} + +template +typename Matrix::TypeReference Matrix::Get(unsigned int row, unsigned int column) +{ + return operator()(row, column); +} + +template +const typename Matrix::TypeReference Matrix::Get(unsigned int row, unsigned int column) const +{ + return operator()(row, column); +} + +template +typename Matrix::TypeReference Matrix::Get(unsigned int absIndex) +{ + return operator()(absIndex); +} + +template +const typename Matrix::TypeReference Matrix::Get(unsigned int absIndex) const +{ + return operator()(absIndex); +} + +template +typename Matrix::MatrixType& Matrix::Set(unsigned int row, unsigned int column, const TypeReference value) +{ + data[row].data[column] = value; + return *this; +} + +template +typename Matrix::MatrixType& Matrix::Set(unsigned int absIndex, const TypeReference value) +{ + data[absIndex / Dimension].data[absIndex % Dimension] = value; + return *this; +} + +template +typename Matrix::VectorType Matrix::GetColumn(unsigned int column) const +{ + VectorType result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = data[i].data[column]; + } + return result; +} + +template +typename Matrix::MatrixType& Matrix::SetColumn(unsigned int column, const VectorType& value) +{ + for (int i = 0; i < Dimension; ++i) + { + data[i].data[column] = value.data[i]; + } + + return *this; +} + +template +typename Matrix::VectorType& Matrix::GetRow(unsigned int row) +{ + return data[row]; +} + +template +const typename Matrix::VectorType& Matrix::GetRow(unsigned int row) const +{ + return data[row]; +} + +template +typename Matrix::MatrixType& Matrix::SetRow(unsigned int row, const VectorType& value) +{ + data[row] = value; + return *this; +} + +template +typename Matrix::TypeReference Matrix::operator()(unsigned int row, unsigned int column) +{ + return data[row].data[column]; +} + +template +const typename Matrix::TypeReference Matrix::operator()(unsigned int row, unsigned int column) const +{ + return data[row].data[column]; +} + +template +typename Matrix::TypeReference Matrix::operator()(unsigned int absIndex) +{ + return operator[](absIndex); +} + +template +const typename Matrix::TypeReference Matrix::operator()(unsigned int absIndex) const +{ + return operator[](absIndex); +} + +template +typename Matrix::TypeReference Matrix::operator[](unsigned int absIndex) +{ + return data[absIndex / Dimension].data[absIndex % Dimension]; +} + +template +const typename Matrix::TypeReference Matrix::operator[](unsigned int absIndex) const +{ + return data[absIndex / Dimension].data[absIndex % Dimension]; +} + +template +typename Matrix::MatrixType& Matrix::Lerp(const MatrixType& to, const TypeReference coeff) +{ + for (int i = 0; i < Dimension; ++i) + { + data[i].Lerp(to.data[i], coeff); + } + return *this; +} + +template +typename Matrix::MatrixType Matrix::GetLerped(const MatrixType& to, const TypeReference coeff) const +{ + MatrixType result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = data[i].GetLerped(to.data[i], coeff); + } + return result; +} + +template +typename Matrix::MatrixType& Matrix::MakeLerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff) +{ + for (int i = 0; i < Dimension; ++i) + { + data[i] = VectorType().MakeLerped(from.data[i], to.data[i], coeff); + } + return *this; +} + +template +typename Matrix::MatrixType Matrix::CreateLerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff) +{ + MatrixType result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = VectorType().MakeLerped(from.data[i], to.data[i], coeff); + } + return result; +} + +template +typename Matrix::TypeReference Matrix::Magnitude(void) const +{ + return effects_sqrt(MagnitudeSqr()); +} + +template +typename Matrix::TypeReference Matrix::MagnitudeSqr(void) const +{ + T result = T(0.0f); + for (int i = 0; i < Dimension; ++i) + { + result += data[i].dot(data[i]); + } + return result; +} + +template +typename Matrix::TypeReference Matrix::Trace(void) const +{ + T result = T(0.0f); + for (int i = 0; i < Dimension; ++i) + { + result += data[i].data[i]; + } + return result; +} + +template +Matrix Matrix::MinorMatrix(unsigned int row, unsigned int column) const +{ + Matrix result; + + int columnCounter = 0; + for (unsigned int i = 0; i < Dimension; ++i) + { + if (i != column) + { + int rowCounter = 0; + for (unsigned int j = 0; j < Dimension; ++j) + { + if (j != row) + { + result.data[rowCounter].data[columnCounter] = data[j].data[i]; + ++rowCounter; + } + } + ++columnCounter; + } + } + return result; +} + +template +typename Matrix::TypeReference Matrix::Determinant(void) const +{ + if (Dimension == 1) + { + return data[0].data[0]; + } + + T result = T(0.0f); + for (int i = 0; i < Dimension; ++i) + { + result += (i % 2 == 0 ? 1 : -1) * data[i].data[0] * MinorMatrix(i, 0).Determinant(); + } + return result; +} + +template +typename Matrix::VectorType& Matrix::ApplyTransform(VectorType& vector) const +{ + VectorType temp(vector); + for (int i = 0; i < Dimension; ++i) + { + vector.data[i] = data[i].dot(temp); + } + return vector; +} + +template +typename Matrix::VectorType Matrix::GetAppliedTransform(const VectorType& vector) const +{ + VectorType result(vector); + return ApplyTransform(result); +} + +template +template +typename Matrix::MatrixType& Matrix::MakeScale(const Vector& scale) +{ + Identity(); + for (int i = 0; i < VectorDimension; ++i) + { + if (i < Dimension) + { + data[i].data[i] = scale.data[i]; + } + } + return *this; +}; + +template +template +typename Matrix::MatrixType& Matrix::SetScale(const Vector& scale) +{ + for (int i = 0; i < VectorDimension; ++i) + { + for (int j = 0; j < VectorDimension; ++j) + { + if (i < Dimension && j < Dimension) + { + if (i == j) + data[i].data[i] = scale.data[i]; + else + data[i].data[j] = T(0.0f); + } + } + } + return *this; +}; + +template +template +typename Matrix::MatrixType Matrix::CreateScale(const Vector& scale) +{ + return MatrixType().MakeScale(scale); +}; + +template +template +typename Matrix::MatrixType& Matrix::Scale(const Vector& scale) +{ + for (int i = 0; i < VectorDimension; ++i) + { + for (int j = 0; j < VectorDimension; ++j) + { + if (i < Dimension && j < Dimension) + { + data[i].data[j] *= scale.data[i]; + } + } + } + return *this; +}; + +template +bool Matrix::IsEqual(const MatrixType& rhv, const TypeReference epsilon) const +{ + for (int i = 0; i < Dimension; ++i) + { + if (!data[i].IsEqual(rhv.data[i], epsilon)) + { + return false; + } + } + return true; +} + +template +bool IsEqual(const Matrix& lhv, const Matrix& rhv, const typename Matrix::TypeReference epsilon) +{ + return lhv.IsEqual(rhv, epsilon); +} + +template +Matrix operator+(const Matrix& lhv, const Matrix& rhv) +{ + Matrix result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = lhv.data[i] + rhv.data[i]; + } + + return result; +} + +template +Matrix operator+(const Matrix& lhv, const typename Matrix::TypeReference rhv) +{ + Matrix result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = lhv.data[i] + rhv; + } + + return result; +} + +template +Matrix operator+(const typename Matrix::TypeReference lhv, const Matrix& rhv) +{ + Matrix result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = lhv + rhv.data[i]; + } + + return result; +} + +template +Matrix operator-(const Matrix& lhv, const Matrix& rhv) +{ + Matrix result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = lhv.data[i] - rhv.data[i]; + } + + return result; +} + +template Matrix operator-(const Matrix& lhv, const typename Matrix::TypeReference rhv) +{ + Matrix result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = lhv.data[i] - rhv; + } + + return result; +} + +template +Matrix operator-(const typename Matrix::TypeReference lhv, const Matrix& rhv) +{ + Matrix result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = lhv - rhv.data[i]; + } + + return result; +} + +template +Matrix operator*(const Matrix& lhv, const Matrix& rhv) +{ + Matrix result(lhv); + return result *= rhv; +} + +template +Matrix operator*(const Matrix& lhv, const typename Matrix::TypeReference rhv) +{ + Matrix result(lhv); + return result *= rhv; +} + +template +Matrix operator*(const typename Matrix::TypeReference lhv, const Matrix& rhv) +{ + Matrix result(rhv); + return result *= lhv; +} + +template +Vector operator*(const Matrix& lhv, const Vector& rhv) +{ + Vector result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = lhv.data[i].dot(rhv); + } + + return result; +} + +template +Vector operator*(const Vector& lhv, const Matrix& rhv) +{ + Vector temp; + for (int i = 0; i < Dimension; ++i) + { + temp.data[i] = rhv.GetColumn(i).Dot(lhv); + } + return temp; +} + +template +Vector operator*(const Matrix& lhv, const Vector& rhv) +{ + Matrix minor = lhv.MinorMatrix(Dimension - 1, Dimension - 1); + Vector result = minor * rhv; + for (int i = 0; i < Dimension - 1; ++i) + { + result.data[i] += lhv.data[i].data[Dimension - 1]; + } + + return result; +} + +template +Vector operator*(const Vector& lhv, const Matrix& rhv) +{ + Matrix minor = rhv.MinorMatrix(Dimension - 1, Dimension - 1); + Vector result = lhv * minor; + for (int i = 0; i < Dimension - 1; ++i) + { + result.data[i] += rhv.data[i].data[Dimension - 1]; + } + return result; +} + +template +Matrix operator/(const Matrix& lhv, const typename Matrix::TypeReference rhv) +{ + Matrix result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = lhv.data[i] / rhv; + } + + return result; +} + +template +Matrix operator/(const typename Matrix::TypeReference lhv, const Matrix& rhv) +{ + Matrix result; + for (int i = 0; i < Dimension; ++i) + { + result.data[i] = lhv / rhv.data[i]; + } + + return result; +} + +template +bool operator==(const Matrix& lhv, const Matrix& rhv) +{ + for (int i = 0; i < Dimension; ++i) + { + if (lhv.data[i] != rhv.data[i]) + { + return false; + } + } + return true; +} + +template +bool operator==(const Matrix& lhv, const typename Matrix::TypeReference rhv) +{ + for (int i = 0; i < Dimension; ++i) + { + if (lhv.data[i] != rhv) + { + return false; + } + } + return true; +} + +template +bool operator==(const typename Matrix::TypeReference lhv, const Matrix& rhv) +{ + for (int i = 0; i < Dimension; ++i) + { + if (lhv != rhv.data[i]) + { + return false; + } + } + return true; +} + +template +bool operator!=(const Matrix& lhv, const Matrix& rhv) +{ + return !(lhv == rhv); +} + +template +bool operator!=(const Matrix& lhv, const typename Matrix::TypeReference rhv) +{ + return !(lhv == rhv); +} + +template +bool operator!=(const typename Matrix::TypeReference lhv, const Matrix& rhv) +{ + return !(lhv == rhv); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrix1Traits.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrix1Traits.h new file mode 100644 index 0000000..870ede4 --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrix1Traits.h @@ -0,0 +1,99 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathMatrix1Traits.h + * @brief The Matrix1Traits class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX1_TRAITS_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX1_TRAITS_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ + +template +class MatrixTraits : + public MatrixTraitsBase +{ +public: + typedef Matrix MatrixType; + typedef Vector VectorType; + typedef MatrixTraitsBase MatrixTraitsBaseType; + typedef typename MatrixTraitsBaseType::TypeReference TypeReference; + + using MatrixTraitsBaseType::data; + + inline VectorType& I(void); + inline const VectorType& I(void) const; + + inline MatrixType& Set(const VectorType& i); + inline MatrixType& Set(const TypeReference a0); + + inline static MatrixType& GetIdentity(void); + + inline VectorType& ApplyTransform(void) const; + inline VectorType GetAppliedTransform(void) const; + + inline MatrixType& MakeScale(const TypeReference x, const TypeReference y); + inline MatrixType& SetScale(const TypeReference x, const TypeReference y); + static inline MatrixType CreateScale(const TypeReference x, const TypeReference y); + inline MatrixType& Scale(const TypeReference x, const TypeReference y); +}; + +template +typename MatrixTraits::VectorType& MatrixTraits::I(void) +{ + return data[0]; +} + +template +const typename MatrixTraits::VectorType& MatrixTraits::I(void) const +{ + return data[0]; +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Set(const VectorType& i) +{ + data[0] = i; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Set(const TypeReference a0) +{ + data[0].Set(a0); + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::GetIdentity(void) +{ + static MatrixType identityMatrix = MatrixType(T(1.0f)); + return identityMatrix; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX1_TRAITS_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrix2Traits.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrix2Traits.h new file mode 100644 index 0000000..9a4a34a --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrix2Traits.h @@ -0,0 +1,251 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathMatrix2Traits.h + * @brief The Matrix2Traits class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX2_TRAITS_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX2_TRAITS_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ + +template +class MatrixTraits : + public MatrixTraitsBase +{ +public: + typedef Matrix MatrixType; + typedef Vector VectorType; + typedef MatrixTraitsBase MatrixTraitsBaseType; + typedef typename MatrixTraitsBaseType::TypeReference TypeReference; + + using MatrixTraitsBaseType::data; + + inline VectorType& I(void); + inline const VectorType& I(void) const; + + inline VectorType& J(void); + inline const VectorType& J(void) const; + + inline MatrixType& Set(const VectorType& i, const VectorType& j); + inline MatrixType& Set(const TypeReference a11, const TypeReference a12, + const TypeReference a21, const TypeReference a22); + + inline static MatrixType& GetIdentity(void); + + inline VectorType& ApplyTransform(void) const; + inline VectorType GetAppliedTransform(void) const; + + inline MatrixType& Slerp(const MatrixType& to, const TypeReference coeff); + inline MatrixType GetSlerped(const MatrixType& to, const TypeReference coeff) const; + inline MatrixType& MakeSlerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff); + static inline MatrixType CreateSlerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff); + + inline MatrixType& MakeRotation(const TypeReference angleRad); + inline MatrixType& Rotate(const TypeReference angleRad); + static inline MatrixType CreateRotation(const TypeReference angleRad); + inline TypeReference GetRotationAngle(void) const; + + inline MatrixType& MakeScale(const TypeReference x, const TypeReference y); + inline MatrixType& SetScale(const TypeReference x, const TypeReference y); + static inline MatrixType CreateScale(const TypeReference x, const TypeReference y); + inline MatrixType& Scale(const TypeReference x, const TypeReference y); +}; + +template +typename MatrixTraits::VectorType& MatrixTraits::I(void) +{ + return data[0]; +} + +template +const typename MatrixTraits::VectorType& MatrixTraits::I(void) const +{ + return data[0]; +} + +template +typename MatrixTraits::VectorType& MatrixTraits::J(void) +{ + return data[1]; +} + +template +const typename MatrixTraits::VectorType& MatrixTraits::J(void) const +{ + return data[1]; +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Set(const VectorType& i, const VectorType& j) +{ + data[0] = i; + data[1] = j; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Set(const TypeReference a11, const TypeReference a12, + const TypeReference a21, const TypeReference a22) +{ + data[0].Set(a11, a12); + data[1].Set(a21, a22); + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::GetIdentity(void) +{ + static MatrixType identityMatrix = MatrixType(T(1.0f), T(0.0f), + T(0.0f), T(1.0f)); + return identityMatrix; +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Slerp(const MatrixType& to, const TypeReference coeff) +{ + MakeRotation(effects_lerp(GetRotationAngle(), to.GetRotationAngle(), coeff)); + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::GetSlerped(const MatrixType& to, const TypeReference coeff) const +{ + MatrixType result; + result.MakeRotation(effects_lerp(GetRotationAngle(), to.GetRotationAngle(), coeff)); + return result; +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeSlerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff) +{ + MakeRotation(effects_lerp(from.GetRotationAngle(), to.GetRotationAngle(), coeff)); + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateSlerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff) +{ + return MatrixType().MakeSlerped(from, to, coeff); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotation(const TypeReference angleRad) +{ + const T s = effects_sin(angleRad); + const T c = effects_cos(angleRad); + data[0].data[0] = c; + data[0].data[1] = -s; + data[1].data[0] = s; + data[1].data[1] = c; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Rotate(const TypeReference angleRad) +{ + const T s = effects_sin(angleRad); + const T c = effects_cos(angleRad); + const T ix = data[0].data[0] * c - data[1].data[0] * s; + const T iy = data[0].data[1] * c - data[1].data[1] * s; + const T jx = data[0].data[0] * s + data[1].data[0] * c; + const T jy = data[0].data[1] * s + data[1].data[1] * c; + data[0].data[0] = ix; + data[0].data[1] = iy; + data[1].data[0] = jx; + data[1].data[1] = jy; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotation(const TypeReference angleRad) +{ + return MatrixType().MakeRotation(angleRad); +} + +template +typename MatrixTraits::TypeReference MatrixTraits::GetRotationAngle(void) const +{ + static const T t0(0.0f); + static const T t1(1.0f); + + static const VectorType orig_vector = VectorType(t1, t0); + static const VectorType orig_vector_cross = VectorType(t0, t1); + + VectorType rotated = VectorType(orig_vector.data[0] * data[0].data[0] + orig_vector.data[1] * data[0].data[1], + orig_vector.data[0] * data[1].data[0] + orig_vector.data[1] * data[1].data[1]).normalize(); + + const T angleCos = effects_clamp(rotated.dot(orig_vector), -t1, t1); + const T angleCosCross = effects_clamp(rotated.dot(orig_vector_cross), -t1, t1); + + if (angleCosCross > t0) + { + return effects_acos(angleCos); + } + + return -effects_acos(angleCos); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeScale(const TypeReference x, const TypeReference y) +{ + data[0].data[0] = x; + data[1].data[1] = y; + data[0].data[1] = T(0.0f); + data[1].data[0] = T(0.0f); + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetScale(const TypeReference x, const TypeReference y) +{ + data[0].data[0] = x; + data[1].data[1] = y; + data[0].data[1] = T(0.0f); + data[1].data[0] = T(0.0f); + return *this; +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateScale(const TypeReference x, const TypeReference y) +{ + return MatrixType().MakeScale(x, y); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Scale(const TypeReference x, const TypeReference y) +{ + data[0].data[0] *= x; + data[0].data[1] *= x; + data[1].data[0] *= y; + data[1].data[1] *= y; + + return *(static_cast(this)); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX2_TRAITS_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrix3Traits.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrix3Traits.h new file mode 100644 index 0000000..d839590 --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrix3Traits.h @@ -0,0 +1,533 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathMatrix3Traits.h + * @brief The Matrix3Traits class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX3_TRAITS_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX3_TRAITS_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ + +template +class MatrixTraits : + public MatrixTraitsBase +{ +public: + typedef Matrix MatrixType; + typedef Vector VectorType; + typedef MatrixTraitsBase MatrixTraitsBaseType; + typedef typename MatrixTraitsBaseType::TypeReference TypeReference; + + using MatrixTraitsBaseType::data; + + inline VectorType& I(void); + inline const VectorType& I(void) const; + + inline VectorType& J(void); + inline const VectorType& J(void) const; + + inline VectorType& K(void); + inline const VectorType& K(void) const; + + inline MatrixType& Set(const VectorType& i, const VectorType& j, const VectorType& k); + + inline MatrixType& Set(const TypeReference a11, const TypeReference a12, const TypeReference a13, + const TypeReference a21, const TypeReference a22, const TypeReference a23, + const TypeReference a31, const TypeReference a32, const TypeReference a33); + + inline static MatrixType& GetIdentity(void); + + inline MatrixType& Slerp(const MatrixType& to, const TypeReference coeff); + inline MatrixType GetSlerped(const MatrixType& to, const TypeReference coeff) const; + inline MatrixType& MakeSlerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff); + static inline MatrixType CreateSlerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff); + + inline VectorType& ApplyRotation(VectorType& vector) const; + inline VectorType GetAppliedRotation(const VectorType& vector) const; + inline VectorType& ApplyTranslate(VectorType& vector) const; + inline VectorType GetAppliedTranslate(const VectorType& vector) const; + + inline Vector& ApplyTransform(Vector& vector) const; + inline Vector GetAppliedTransform(const Vector& vector) const; + inline Vector& ApplyRotation(Vector& vector) const; + inline Vector GetAppliedRotation(const Vector& vector) const; + inline Vector& ApplyTranslate(Vector& vector) const; + inline Vector GetAppliedTranslate(const Vector& vector) const; + + inline MatrixType& SetRotation(const TypeReference angleRad); + inline MatrixType& SetRotation(const Matrix& rotation); + inline MatrixType& SetRotation(const MatrixType& rotation); + inline MatrixType& MakeRotation(const TypeReference angleRad); + inline MatrixType& MakeRotation(const Matrix& rotation); + inline MatrixType& MakeRotation(const MatrixType& rotation); + inline MatrixType& Rotate(const TypeReference angleRad); + inline MatrixType& Rotate(const Matrix& rotation); + inline MatrixType& Rotate(const MatrixType& rotation); + static inline MatrixType CreateRotation(const TypeReference angleRad); + static inline MatrixType CreateRotation(const Matrix& rotation); + static inline MatrixType CreateRotation(const MatrixType& rotation); + inline Matrix GetRotation(void) const; + inline TypeReference GetRotationAngle(void) const; + + inline MatrixType& MakeScale(const TypeReference x, const TypeReference y); + inline MatrixType& SetScale(const TypeReference x, const TypeReference y); + static inline MatrixType CreateScale(const TypeReference x, const TypeReference y); + inline MatrixType& Scale(const TypeReference x, const TypeReference y); + + inline MatrixType& SetTranslation(const TypeReference x, const TypeReference y); + inline MatrixType& SetTranslation(const Vector& tran); + inline MatrixType& MakeTranslation(const TypeReference x, const TypeReference y); + inline MatrixType& MakeTranslation(const Vector& tran); + inline MatrixType& Translate(const TypeReference x, const TypeReference y); + inline MatrixType& Translate(const Vector& tran); + static inline MatrixType CreateTranslation(const TypeReference x, const TypeReference y); + static inline MatrixType CreateTranslation(const Vector& tran); + inline Vector GetTranslation(void) const; + inline VectorType GetFullTranslation(void) const; +}; + +template +typename MatrixTraits::VectorType& MatrixTraits::I(void) +{ + return data[0]; +} + +template +const typename MatrixTraits::VectorType& MatrixTraits::I(void) const +{ + return data[0]; +} + +template +typename MatrixTraits::VectorType& MatrixTraits::J(void) +{ + return data[1]; +} + +template +const typename MatrixTraits::VectorType& MatrixTraits::J(void) const +{ + return data[1]; +} + +template +typename MatrixTraits::VectorType& MatrixTraits::K(void) +{ + return data[2]; +} + +template +const typename MatrixTraits::VectorType& MatrixTraits::K(void) const +{ + return data[2]; +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Set(const VectorType& i, const VectorType& j, const VectorType& k) +{ + data[0] = i; + data[1] = j; + data[2] = k; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Set(const TypeReference a11, const TypeReference a12, const TypeReference a13, + const TypeReference a21, const TypeReference a22, const TypeReference a23, + const TypeReference a31, const TypeReference a32, const TypeReference a33) +{ + data[0].Set(a11, a12, a13); + data[1].Set(a21, a22, a23); + data[2].Set(a31, a32, a33); + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::GetIdentity(void) +{ + static MatrixType identityMatrix = MatrixType(T(1.0f), T(0.0f), T(0.0f), + T(0.0f), T(1.0f), T(0.0f), + T(0.0f), T(0.0f), T(1.0f)); + return identityMatrix; +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Slerp(const MatrixType& to, const TypeReference coeff) +{ + SetRotation(effects_lerp(GetRotationAngle(), to.GetRotationAngle(), coeff)); + VectorType column = VectorType(data[0].data[2], data[1].data[2], data[2].data[2]); + column.lerp(VectorType(to.data[0].data[2], to.data[1].data[2], to.data[2].data[2]), coeff); + data[0].data[2] = column.data[0]; + data[1].data[2] = column.data[1]; + data[2].data[2] = column.data[2]; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::GetSlerped(const MatrixType& to, const TypeReference coeff) const +{ + MatrixType result; + result.MakeRotation(effects_lerp(GetRotationAngle(), to.GetRotationAngle(), coeff)); + VectorType column = VectorType(data[0].data[2], data[1].data[2], data[2].data[2]); + column.lerp(VectorType(to.data[0].data[2], to.data[1].data[2], to.data[2].data[2]), coeff); + result.data[0].data[2] = column.data[0]; + result.data[1].data[2] = column.data[1]; + result.data[2].data[2] = column.data[2]; + return result; +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeSlerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff) +{ + *this = from; + Slerp(to, coeff); + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateSlerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff) +{ + return MatrixType().MakeSlerped(from, to, coeff); +} + +template +typename MatrixTraits::VectorType& MatrixTraits::ApplyRotation(VectorType& vector) const +{ + return vector.Set(data[0].data[0] * vector.data[0] + data[0].data[1] * vector.data[1], + data[1].data[0] * vector.data[0] + data[1].data[1] * vector.data[1], + vector.data[2]); +} + +template +typename MatrixTraits::VectorType MatrixTraits::GetAppliedRotation(const VectorType& vector) const +{ + return VectorType(data[0].data[0] * vector.data[0] + data[0].data[1] * vector.data[1], + data[1].data[0] * vector.data[0] + data[1].data[1] * vector.data[1], + vector.data[2]); +} + +template +typename MatrixTraits::VectorType& MatrixTraits::ApplyTranslate(VectorType& vector) const +{ + return vector.Set(vector.data[0] + data[0].data[2] * vector.data[2], + vector.data[1] + data[1].data[2] * vector.data[2], + vector.data[2]); +} + +template +typename MatrixTraits::VectorType MatrixTraits::GetAppliedTranslate(const VectorType& vector) const +{ + return VectorType(vector.data[0] + data[0].data[2] * vector.data[2], + vector.data[1] + data[1].data[2] * vector.data[2], + vector.data[2]); +} + +template +Vector& MatrixTraits::ApplyTransform(Vector& vector) const +{ + return vector.Set(data[0].data[0] * vector.data[0] + data[0].data[1] * vector.data[1] + data[0].data[2], + data[1].data[0] * vector.data[0] + data[1].data[1] * vector.data[1] + data[1].data[2]); +} + +template +Vector MatrixTraits::GetAppliedTransform(const Vector& vector) const +{ + return Vector(data[0].data[0] * vector.data[0] + data[0].data[1] * vector.data[1] + data[0].data[2], + data[1].data[0] * vector.data[0] + data[1].data[1] * vector.data[1] + data[1].data[2]); +} + +template +Vector& MatrixTraits::ApplyRotation(Vector& vector) const +{ + return vector.Set(data[0].data[0] * vector.data[0] + data[0].data[1] * vector.data[1], + data[1].data[0] * vector.data[0] + data[1].data[1] * vector.data[1]); +} + +template +Vector MatrixTraits::GetAppliedRotation(const Vector& vector) const +{ + return Vector(data[0].data[0] * vector.data[0] + data[0].data[1] * vector.data[1], + data[1].data[0] * vector.data[0] + data[1].data[1] * vector.data[1]); +} + +template +Vector& MatrixTraits::ApplyTranslate(Vector& vector) const +{ + return vector.Set(vector.data[0] + data[0].data[2], + vector.data[1] + data[1].data[2]); +} + +template +Vector MatrixTraits::GetAppliedTranslate(const Vector& vector) const +{ + return Vector(vector.data[0] + data[0].data[2], + vector.data[1] + data[1].data[2]); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetRotation(const TypeReference angleRad) +{ + const T s = effects_sin(angleRad); + const T c = effects_cos(angleRad); + data[0].data[0] = c; + data[0].data[1] = -s; + data[1].data[0] = s; + data[1].data[1] = c; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetRotation(const Matrix& rotation) +{ + data[0].data[0] = rotation.data[0].data[0]; + data[0].data[1] = rotation.data[0].data[1]; + data[1].data[0] = rotation.data[1].data[0]; + data[1].data[1] = rotation.data[1].data[1]; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetRotation(const MatrixType& rotation) +{ + data[0].data[0] = rotation.data[0].data[0]; + data[0].data[1] = rotation.data[0].data[1]; + data[1].data[0] = rotation.data[1].data[0]; + data[1].data[1] = rotation.data[1].data[1]; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotation(const TypeReference angleRad) +{ + *this = GetIdentity(); + return SetRotation(angleRad); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotation(const Matrix& rotation) +{ + *this = GetIdentity(); + return SetRotation(rotation); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotation(const MatrixType& rotation) +{ + *this = GetIdentity(); + return SetRotation(rotation); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Rotate(const TypeReference angleRad) +{ + const T s = effects_sin(angleRad); + const T c = effects_cos(angleRad); + const T ix = data[0].data[0] * c - data[1].data[0] * s; + const T iy = data[0].data[1] * c - data[1].data[1] * s; + const T jx = data[0].data[0] * s + data[1].data[0] * c; + const T jy = data[0].data[1] * s + data[1].data[1] * c; + data[0].data[0] = ix; + data[0].data[1] = iy; + data[1].data[0] = jx; + data[1].data[1] = jy; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Rotate(const Matrix& rotation) +{ + const T ix = data[0].data[0] * rotation.data[0].data[0] + data[1].data[0] * rotation.data[0].data[1]; + const T iy = data[0].data[1] * rotation.data[0].data[0] + data[1].data[1] * rotation.data[0].data[1]; + const T jx = data[0].data[0] * rotation.data[1].data[0] + data[1].data[0] * rotation.data[1].data[1]; + const T jy = data[0].data[1] * rotation.data[1].data[0] + data[1].data[1] * rotation.data[1].data[1]; + data[0].data[0] = ix; + data[0].data[1] = iy; + data[1].data[0] = jx; + data[1].data[1] = jy; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Rotate(const MatrixType& rotation) +{ + const T ix = data[0].data[0] * rotation.data[0].data[0] + data[1].data[0] * rotation.data[0].data[1]; + const T iy = data[0].data[1] * rotation.data[0].data[0] + data[1].data[1] * rotation.data[0].data[1]; + const T jx = data[0].data[0] * rotation.data[1].data[0] + data[1].data[0] * rotation.data[1].data[1]; + const T jy = data[0].data[1] * rotation.data[1].data[0] + data[1].data[1] * rotation.data[1].data[1]; + data[0].data[0] = ix; + data[0].data[1] = iy; + data[1].data[0] = jx; + data[1].data[1] = jy; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotation(const TypeReference angleRad) +{ + return MatrixType().MakeRotation(angleRad); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotation(const Matrix& rotation) +{ + return MatrixType().MakeRotation(rotation); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotation(const MatrixType& rotation) +{ + return MatrixType().MakeRotation(rotation); +} + +template +Matrix MatrixTraits::GetRotation() const +{ + return Matrix(data[0].data[0], data[0].data[1], data[1].data[0], data[1].data[1]); +} + +template +typename MatrixTraits::TypeReference MatrixTraits::GetRotationAngle() const +{ + static const T t0(0.0f); + static const T t1(1.0f); + + static const Vector orig_vector = Vector(t1, t0); + static const Vector orig_vector_cross = Vector(t0, t1); + + Vector rotated(GetAppliedRotation(orig_vector).normalize()); + const T angleCos = effects_clamp(rotated.dot(orig_vector), -t1, t1); + const T angleCosCross = effects_clamp(rotated.dot(orig_vector_cross), -t1, t1); + + if (angleCosCross > t0) + { + return effects_acos(angleCos); + } + return -effects_acos(angleCos); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeScale(const TypeReference x, const TypeReference y) +{ + *this = GetIdentity(); + return SetScale(x, y); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetScale(const TypeReference x, const TypeReference y) +{ + data[0].data[0] = x; + data[1].data[1] = y; + + data[0].data[1] = data[1].data[0] = T(0.0f); + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateScale(const TypeReference x, const TypeReference y) +{ + return MatrixType().MakeScale(x, y); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Scale(const TypeReference x, const TypeReference y) +{ + data[0].data[0] *= x; + data[0].data[1] *= x; + data[1].data[0] *= y; + data[1].data[1] *= y; + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetTranslation(const TypeReference x, const TypeReference y) +{ + data[0].data[2] = x; + data[1].data[2] = y; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetTranslation(const Vector& tran) +{ + return SetTranslation(tran.data[0], tran.data[1]); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeTranslation(const TypeReference x, const TypeReference y) +{ + *this = GetIdentity(); + return SetTranslation(x, y); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeTranslation(const Vector& tran) +{ + return MakeTranslation(tran.data[0], tran.data[1]); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Translate(const TypeReference x, const TypeReference y) +{ + data[0].data[2] += x; + data[1].data[2] += y; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Translate(const Vector& tran) +{ + return Translate(tran.data[0], tran.data[1]); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateTranslation(const TypeReference x, const TypeReference y) +{ + return MatrixType().MakeTranslation(x, y); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateTranslation(const Vector& tran) +{ + return MatrixType().MakeTranslation(tran); +} + +template +Vector MatrixTraits::GetTranslation(void) const +{ + return Vector().Set(data[0].data[2], data[1].data[2]); +} + +template +typename MatrixTraits::VectorType MatrixTraits::GetFullTranslation(void) const +{ + return VectorType().Set(data[0].data[2], data[1].data[2], data[2].data[2]); +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX3_TRAITS_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrixTraits.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrixTraits.h new file mode 100644 index 0000000..3dfdccb --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrixTraits.h @@ -0,0 +1,1413 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathMatrixTraits.h + * @brief The MatrixTraits class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX_TRAITS_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX_TRAITS_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ + +template +class Vector; +template +class Quaternion; + +template +class MatrixTraits : + public MatrixTraitsBase +{ +public: + typedef Matrix MatrixType; + typedef Vector VectorType; + typedef Vector Vector3; + typedef Matrix Matrix3; + typedef Matrix Matrix2; + + typedef MatrixTraitsBase MatrixTraitsBaseType; + typedef typename MatrixTraitsBaseType::TypeReference TypeReference; + + using MatrixTraitsBaseType::data; + + inline VectorType& I(void); + inline const VectorType& I(void) const; + + inline VectorType& J(void); + inline const VectorType& J(void) const; + + inline VectorType& K(void); + inline const VectorType& K(void) const; + + inline VectorType& C(void); + inline const VectorType& C(void) const; + + inline MatrixType& Set(const VectorType& i, const VectorType& j, const VectorType& k, const VectorType& c); + inline MatrixType& Set(const TypeReference a11, const TypeReference a12, const TypeReference a13, const TypeReference a14, + const TypeReference a21, const TypeReference a22, const TypeReference a23, const TypeReference a24, + const TypeReference a31, const TypeReference a32, const TypeReference a33, const TypeReference a34, + const TypeReference a41, const TypeReference a42, const TypeReference a43, const TypeReference a44); + + inline static const MatrixType& GetIdentity(void); + + inline MatrixType& Slerp(const MatrixType& to, const TypeReference coeff); + inline MatrixType GetSlerped(const MatrixType& to, const TypeReference coeff) const; + inline MatrixType& MakeSlerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff); + static inline MatrixType CreateSlerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff); + + inline VectorType& ApplyRotation(VectorType& vector) const; + inline VectorType GetAppliedRotation(const VectorType& vector) const; + inline VectorType& ApplyTranslate(VectorType& vector) const; + inline VectorType GetAppliedTranslate(const VectorType& vector) const; + + inline Vector3& ApplyTransform(Vector3& vector) const; + inline Vector3 GetAppliedTransform(const Vector3& vector) const; + inline Vector3& ApplyRotation(Vector3& vector) const; + inline Vector3 GetAppliedRotation(const Vector3& vector) const; + inline Vector3& ApplyTranslate(Vector3& vector) const; + inline Vector3 GetAppliedTranslate(const Vector3& vector) const; + + inline Quaternion& ApplyRotation(Quaternion& quaternion) const; + inline Quaternion GetAppliedRotation(const Quaternion& quaternion) const; + + inline MatrixType& SetRotation(const TypeReference xAngleRad, const TypeReference yAngleRad, const TypeReference zAngleRad, RotationOrder3 order = ROTATION_XYZ); + inline MatrixType& SetRotation(const Vector3& anglesRad, RotationOrder3 order = ROTATION_XYZ); + inline MatrixType& SetRotationX(const TypeReference angleRad); + inline MatrixType& SetRotationY(const TypeReference angleRad); + inline MatrixType& SetRotationZ(const TypeReference angleRad); + inline MatrixType& SetRotationAxis(const Vector3& axis, const TypeReference angleRad); + inline MatrixType& SetRotationAxis(const TypeReference xAxis, const TypeReference yAxis, const TypeReference zAxis, const TypeReference angleRad); + inline MatrixType& SetRotation(const Quaternion& rotation); + inline MatrixType& SetRotation(const Matrix3& rotation); + inline MatrixType& MakeRotation(const TypeReference xAngleRad, const TypeReference yAngleRad, const TypeReference zAngleRad, RotationOrder3 order = ROTATION_XYZ); + inline MatrixType& MakeRotation(const Vector3& anglesRad, RotationOrder3 order = ROTATION_XYZ); + inline MatrixType& MakeRotationX(const TypeReference angleRad); + inline MatrixType& MakeRotationY(const TypeReference angleRad); + inline MatrixType& MakeRotationZ(const TypeReference angleRad); + inline MatrixType& MakeRotationAxis(const Vector3& axis, const TypeReference angleRad); + inline MatrixType& MakeRotationAxis(const TypeReference xAxis, const TypeReference yAxis, const TypeReference zAxis, const TypeReference angleRad); + inline MatrixType& MakeRotation(const Quaternion& rotation); + inline MatrixType& MakeRotation(const Matrix3& rotation); + inline MatrixType& Rotate(const TypeReference xAngleRad, const TypeReference yAngleRad, const TypeReference zAngleRad, RotationOrder3 order = ROTATION_XYZ); + inline MatrixType& Rotate(const Vector3& anglesRad, RotationOrder3 order3 = ROTATION_XYZ); + inline MatrixType& RotateX(const TypeReference angleRad); + inline MatrixType& RotateY(const TypeReference angleRad); + inline MatrixType& RotateZ(const TypeReference angleRad); + inline MatrixType& RotateAxis(const Vector3& axis, const TypeReference angleRad); + inline MatrixType& RotateAxis(const TypeReference xAxis, const TypeReference yAxis, const TypeReference zAxis, const TypeReference angleRad); + inline MatrixType& Rotate(const Quaternion& rotation); + inline MatrixType& Rotate(const Matrix3& rotation); + inline MatrixType& Rotate(const MatrixType& rotation); + static inline MatrixType CreateRotation(const TypeReference xAngleRad, const TypeReference yAngleRad, const TypeReference zAngleRad, RotationOrder3 order = ROTATION_XYZ); + static inline MatrixType CreateRotation(const Vector3& anglesRad, RotationOrder3 order = ROTATION_XYZ); + static inline MatrixType CreateRotationX(const TypeReference angleRad); + static inline MatrixType CreateRotationY(const TypeReference angleRad); + static inline MatrixType CreateRotationZ(const TypeReference angleRad); + static inline MatrixType CreateRotationAxis(const Vector3& axis, const TypeReference angleRad); + static inline MatrixType CreateRotationAxis(const TypeReference xAxis, const TypeReference yAxis, const TypeReference zAxis, const TypeReference angleRad); + static inline MatrixType CreateRotation(const Quaternion& rotation); + static inline MatrixType CreateRotation(const Matrix3& rotation); + inline MatrixType& GetRotationAngles(T& xAngleRad, T& yAngeRad, T& zAngleRad, unsigned int solutionNumber = 1); + inline Quaternion GetQuaternion(void) const; + inline Quaternion& GetQuaternion(Quaternion& rotation) const; + inline Matrix3 GetRotation(void) const; + inline Matrix3& GetRotation(Matrix3& rotation) const; + + inline MatrixType& MakeScale(const TypeReference x, const TypeReference y, const TypeReference z); + inline MatrixType& SetScale(const TypeReference x, const TypeReference y, const TypeReference z); + static inline MatrixType CreateScale(const TypeReference x, const TypeReference y, const TypeReference z); + inline MatrixType& Scale(const TypeReference x, const TypeReference y, const TypeReference z); + + inline MatrixType& SetTranslation(const TypeReference x, const TypeReference y, const TypeReference z); + inline MatrixType& SetTranslation(const Vector3& tran); + inline MatrixType& MakeTranslation(const TypeReference x, const TypeReference y, const TypeReference z); + inline MatrixType& MakeTranslation(const Vector3& tran); + inline MatrixType& Translate(const TypeReference x, const TypeReference y, const TypeReference z); + inline MatrixType& Translate(const Vector3& tran); + static inline MatrixType CreateTranslation(const TypeReference x, const TypeReference y, const TypeReference z); + static inline MatrixType CreateTranslation(const Vector3& tran); + inline Vector3 GetTranslation(void) const; + inline VectorType GetFullTranslation(void) const; + + inline MatrixType& MakeLookAtLH(const Vector3& eye, const Vector3& at, const Vector3& up); + inline MatrixType& MakeLookAtRH(const Vector3& eye, const Vector3& at, const Vector3& up); + inline MatrixType& MakeOrthoRH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar); + inline MatrixType& MakeOrthoLH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar); + inline MatrixType& MakeOrthoRH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar); + inline MatrixType& MakeOrthoLH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar); + inline MatrixType& MakePerspectiveLH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar); + inline MatrixType& MakePerspectiveRH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar); + inline MatrixType& MakePerspectiveLH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar); + inline MatrixType& MakePerspectiveRH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar); + inline MatrixType& MakePerspectiveFovLH(const TypeReference fovY, const TypeReference aspect, const TypeReference zNear, const TypeReference zFar); + inline MatrixType& MakePerspectiveFovRH(const TypeReference fovY, const TypeReference aspect, const TypeReference zNear, const TypeReference zFar); + static inline MatrixType CreateLookAtLH(const Vector3& eye, const Vector3& at, const Vector3& up); + static inline MatrixType CreateLookAtRH(const Vector3& eye, const Vector3& at, const Vector3& up); + static inline MatrixType CreateOrthoRH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar); + static inline MatrixType CreateOrthoLH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar); + static inline MatrixType CreateOrthoRH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar); + static inline MatrixType CreateOrthoLH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar); + static inline MatrixType CreatePerspectiveLH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar); + static inline MatrixType CreatePerspectiveRH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar); + static inline MatrixType CreatePerspectiveLH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar); + static inline MatrixType CreatePerspectiveRH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar); + static inline MatrixType CreatePerspectiveFovLH(const TypeReference fovY, const TypeReference aspect, const TypeReference zNear, const TypeReference zFar); + static inline MatrixType CreatePerspectiveFovRH(const TypeReference fovY, const TypeReference aspect, const TypeReference zNear, const TypeReference zFar); + + inline bool GetOrthoParamsRH(T& left, T& right, T& top, T& bottom, T& zNear, T& zFar) const; + inline bool GetPerspectiveParamsRH(T& left, T& right, T& top, T& bottom, T& zNear, T& zFar) const; + inline bool GetPerspectiveParamsRH(T& fovY, T& aspect, T& zNear, T& zFar) const; + inline bool GetViewParams(Vector3& position, Vector3& direction, Vector3& up, Vector3& right) const; +}; + +template +typename MatrixTraits::VectorType& MatrixTraits::I(void) +{ + return data[0]; +} + +template +const typename MatrixTraits::VectorType& MatrixTraits::I(void) const +{ + return data[0]; +} + +template +typename MatrixTraits::VectorType& MatrixTraits::J(void) +{ + return data[1]; +} + +template +const typename MatrixTraits::VectorType& MatrixTraits::J(void) const +{ + return data[1]; +} + +template +typename MatrixTraits::VectorType& MatrixTraits::K(void) +{ + return data[2]; +} + +template +const typename MatrixTraits::VectorType& MatrixTraits::K(void) const +{ + return data[2]; +} + +template +typename MatrixTraits::VectorType& MatrixTraits::C(void) +{ + return data[3]; +} + +template +const typename MatrixTraits::VectorType& MatrixTraits::C(void) const +{ + return data[3]; +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Set(const VectorType& i, const VectorType& j, const VectorType& k, const VectorType& c) +{ + data[0] = i; + data[1] = j; + data[2] = k; + data[3] = c; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Set(const TypeReference a11, const TypeReference a12, const TypeReference a13, const TypeReference a14, + const TypeReference a21, const TypeReference a22, const TypeReference a23, const TypeReference a24, + const TypeReference a31, const TypeReference a32, const TypeReference a33, const TypeReference a34, + const TypeReference a41, const TypeReference a42, const TypeReference a43, const TypeReference a44) +{ + data[0].Set(a11, a12, a13, a14); + data[1].Set(a21, a22, a23, a24); + data[2].Set(a31, a32, a33, a34); + data[3].Set(a41, a42, a43, a44); + return *(static_cast(this)); +} + +template +const typename MatrixTraits::MatrixType& MatrixTraits::GetIdentity(void) +{ + static const MatrixType identityMatrix = MatrixType(T(1.0f), T(0.0f), T(0.0f), T(0.0f), + T(0.0f), T(1.0f), T(0.0f), T(0.0f), + T(0.0f), T(0.0f), T(1.0f), T(0.0f), + T(0.0f), T(0.0f), T(0.0f), T(1.0f)); + return identityMatrix; +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Slerp(const MatrixType& to, const TypeReference coeff) +{ + SetRotation(GetQuaternion().Slerp(to.GetQuaternion(), coeff)); + + VectorType column = VectorType(data[0].data[3], data[1].data[3], data[2].data[3], data[3].data[3]); + column.lerp(VectorType(to.data[0].data[3], to.data[1].data[3], to.data[2].data[3], to.data[3].data[3]), coeff); + data[0].data[3] = column.data[0]; + data[1].data[3] = column.data[1]; + data[2].data[3] = column.data[2]; + data[3].data[3] = column.data[3]; + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::GetSlerped(const MatrixType& to, const TypeReference coeff) const +{ + MatrixType result; + result.MakeRotation(GetQuaternion().Slerp(to.GetQuaternion(), coeff)); + + VectorType column = VectorType(data[0].data[3], data[1].data[3], data[2].data[3], data[3].data[3]); + column.lerp(VectorType(to.data[0].data[3], to.data[1].data[3], to.data[2].data[3], to.data[3].data[3]), coeff); + result.data[0].data[3] = column.data[0]; + result.data[1].data[3] = column.data[1]; + result.data[2].data[3] = column.data[2]; + result.data[3].data[3] = column.data[3]; + + return result; +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeSlerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff) +{ + *this = from; + Slerp(to, coeff); + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateSlerped(const MatrixType& from, const MatrixType& to, const TypeReference coeff) +{ + return MatrixType().MakeSlerped(from, to, coeff); +} + +template +typename MatrixTraits::VectorType& MatrixTraits::ApplyRotation(VectorType& vector) const +{ + return vector.Set(vector.data[0] * data[0].data[0] + vector.data[1] * data[0].data[1] + vector.data[2] * data[0].data[2], + vector.data[0] * data[1].data[0] + vector.data[1] * data[1].data[1] + vector.data[2] * data[1].data[2], + vector.data[0] * data[2].data[0] + vector.data[1] * data[2].data[1] + vector.data[2] * data[2].data[2], + vector.data[3]); +} + +template +typename MatrixTraits::VectorType MatrixTraits::GetAppliedRotation(const VectorType& vector) const +{ + return VectorType(vector.data[0] * data[0].data[0] + vector.data[1] * data[0].data[1] + vector.data[2] * data[0].data[2], + vector.data[0] * data[1].data[0] + vector.data[1] * data[1].data[1] + vector.data[2] * data[1].data[2], + vector.data[0] * data[2].data[0] + vector.data[1] * data[2].data[1] + vector.data[2] * data[2].data[2], + vector.data[3]); +} + +template +typename MatrixTraits::VectorType& MatrixTraits::ApplyTranslate(VectorType& vector) const +{ + return vector.Set(vector.data[0] + vector.data[3] * data[3].data[0], + vector.data[1] + vector.data[3] * data[3].data[1], + vector.data[2] + vector.data[3] * data[3].data[2], + vector.data[3]); +} + +template +typename MatrixTraits::VectorType MatrixTraits::GetAppliedTranslate(const VectorType& vector) const +{ + return VectorType(vector.data[0] + vector.data[3] * data[3].data[0], + vector.data[1] + vector.data[3] * data[3].data[1], + vector.data[2] + vector.data[3] * data[3].data[2], + vector.data[3]); +} + +template +typename MatrixTraits::Vector3& MatrixTraits::ApplyTransform(Vector3& vector) const +{ + return vector.Set(vector.data[0] * data[0].data[0] + vector.data[1] * data[0].data[1] + vector.data[2] * data[0].data[2] + data[0].data[3], + vector.data[0] * data[1].data[0] + vector.data[1] * data[1].data[1] + vector.data[2] * data[1].data[2] + data[1].data[3], + vector.data[0] * data[2].data[0] + vector.data[1] * data[2].data[1] + vector.data[2] * data[2].data[2] + data[2].data[3]); +} + +template +typename MatrixTraits::Vector3 MatrixTraits::GetAppliedTransform(const Vector3& vector) const +{ + return Vector3().Set(vector.data[0] * data[0].data[0] + vector.data[1] * data[0].data[1] + vector.data[2] * data[0].data[2] + data[0].data[3], + vector.data[0] * data[1].data[0] + vector.data[1] * data[1].data[1] + vector.data[2] * data[1].data[2] + data[1].data[3], + vector.data[0] * data[2].data[0] + vector.data[1] * data[2].data[1] + vector.data[2] * data[2].data[2] + data[2].data[3]); +} + +template +typename MatrixTraits::Vector3& MatrixTraits::ApplyRotation(Vector3& vector) const +{ + return vector.Set(vector.data[0] * data[0].data[0] + vector.data[1] * data[0].data[1] + vector.data[2] * data[0].data[2], + vector.data[0] * data[1].data[0] + vector.data[1] * data[1].data[1] + vector.data[2] * data[1].data[2], + vector.data[0] * data[2].data[0] + vector.data[1] * data[2].data[1] + vector.data[2] * data[2].data[2]); +} + +template +typename MatrixTraits::Vector3 MatrixTraits::GetAppliedRotation(const Vector3& vector) const +{ + return Vector3().Set(vector.data[0] * data[0].data[0] + vector.data[1] * data[0].data[1] + vector.data[2] * data[0].data[2], + vector.data[0] * data[1].data[0] + vector.data[1] * data[1].data[1] + vector.data[2] * data[1].data[2], + vector.data[0] * data[2].data[0] + vector.data[1] * data[2].data[1] + vector.data[2] * data[2].data[2]); +} + +template +typename MatrixTraits::Vector3& MatrixTraits::ApplyTranslate(Vector3& vector) const +{ + return vector.Set(vector.data[0] + data[0].data[3], + vector.data[1] + data[1].data[3], + vector.data[2] + data[2].data[3]); +} + +template +typename MatrixTraits::Vector3 MatrixTraits::GetAppliedTranslate(const Vector3& vector) const +{ + return Vector3(vector.data[0] + data[0].data[3], + vector.data[1] + data[1].data[3], + vector.data[2] + data[2].data[3]); +} + +template +Quaternion& MatrixTraits::ApplyRotation(Quaternion& quaternion) const +{ + return quaternion.Set(GetQuaternion() * quaternion); +} + +template +Quaternion MatrixTraits::GetAppliedRotation(const Quaternion& quaternion) const +{ + return GetQuaternion() * quaternion; +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetRotation(const TypeReference xAngleRad, const TypeReference yAngleRad, const TypeReference zAngleRad, RotationOrder3 order) +{ + MatrixType result; + result.MakeRotation(xAngleRad, yAngleRad, zAngleRad, order); + data[0].data[0] = result.data[0].data[0]; + data[0].data[1] = result.data[0].data[1]; + data[0].data[2] = result.data[0].data[2]; + data[1].data[0] = result.data[1].data[0]; + data[1].data[1] = result.data[1].data[1]; + data[1].data[2] = result.data[1].data[2]; + data[2].data[0] = result.data[2].data[0]; + data[2].data[1] = result.data[2].data[1]; + data[2].data[2] = result.data[2].data[2]; + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetRotation(const Vector3& anglesRad, RotationOrder3 order) +{ + return SetRotation(anglesRad.data[0], anglesRad.data[1], anglesRad.data[2], order); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetRotationX(const TypeReference angleRad) +{ + const T c = effects_cos(angleRad); + const T s = effects_sin(angleRad); + data[0].data[0] = T(1.0f); + data[0].data[1] = data[0].data[2] = data[1].data[0] = data[2].data[0] = T(0.0f); + data[1].data[1] = c; + data[1].data[2] = -s; + data[2].data[1] = s; + data[2].data[2] = c; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetRotationY(const TypeReference angleRad) +{ + const T c = effects_cos(angleRad); + const T s = effects_sin(angleRad); + data[1].data[1] = T(1.0f); + data[0].data[1] = data[1].data[0] = data[1].data[2] = data[2].data[1] = T(0.0f); + data[0].data[0] = c; + data[0].data[2] = s; + data[2].data[0] = -s; + data[2].data[2] = c; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetRotationZ(const TypeReference angleRad) +{ + const T c = effects_cos(angleRad); + const T s = effects_sin(angleRad); + data[2].data[2] = T(1.0f); + data[0].data[2] = data[2].data[0] = data[1].data[2] = data[2].data[1] = T(0.0f); + data[0].data[0] = c; + data[0].data[1] = -s; + data[1].data[0] = s; + data[1].data[1] = c; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetRotationAxis(const Vector3& axis, const TypeReference angleRad) +{ + return SetRotationAxis(axis.data[0], axis.data[1], axis.data[2], angleRad); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetRotationAxis(const TypeReference xAxis, const TypeReference yAxis, const TypeReference zAxis, const TypeReference angleRad) +{ + MatrixType result; + result.MakeRotationAxis(xAxis, yAxis, zAxis, angleRad); + data[0].data[0] = result.data[0].data[0]; + data[0].data[1] = result.data[0].data[1]; + data[0].data[2] = result.data[0].data[2]; + data[1].data[0] = result.data[1].data[0]; + data[1].data[1] = result.data[1].data[1]; + data[1].data[2] = result.data[1].data[2]; + data[2].data[0] = result.data[2].data[0]; + data[2].data[1] = result.data[2].data[1]; + data[2].data[2] = result.data[2].data[2]; + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetRotation(const Quaternion& rotation) +{ + T wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2; + T s = T(2.0f) / rotation.lengthSqr(); // 4 mul 3 add 1 div + x2 = rotation.x * s; + y2 = rotation.y * s; + z2 = rotation.z * s; + xx = rotation.x * x2; + xy = rotation.x * y2; + xz = rotation.x * z2; + yy = rotation.y * y2; + yz = rotation.y * z2; + zz = rotation.z * z2; + wx = rotation.w * x2; + wy = rotation.w * y2; + wz = rotation.w * z2; + + const T t1(1.0f); + data[0].data[0] = t1 - (yy + zz); + data[0].data[1] = xy - wz; + data[0].data[2] = xz + wy; + + data[1].data[0] = xy + wz; + data[1].data[1] = t1 - (xx + zz); + data[1].data[2] = yz - wx; + + data[2].data[0] = xz - wy; + data[2].data[1] = yz + wx; + data[2].data[2] = t1 - (xx + yy); + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetRotation(const Matrix3& rotation) +{ + data[0].data[0] = rotation.data[0].data[0]; + data[0].data[1] = rotation.data[0].data[1]; + data[0].data[2] = rotation.data[0].data[2]; + data[1].data[0] = rotation.data[1].data[0]; + data[1].data[1] = rotation.data[1].data[1]; + data[1].data[2] = rotation.data[1].data[2]; + data[2].data[0] = rotation.data[2].data[0]; + data[2].data[1] = rotation.data[2].data[1]; + data[2].data[2] = rotation.data[2].data[2]; + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotation(const TypeReference xAngleRad, const TypeReference yAngleRad, const TypeReference zAngleRad, RotationOrder3 order) +{ + switch (order) + { + case ROTATION_XYZ: + MakeRotationX(xAngleRad); + RotateY(yAngleRad); + RotateZ(zAngleRad); + break; + case ROTATION_XZY: + MakeRotationX(xAngleRad); + RotateZ(zAngleRad); + RotateY(yAngleRad); + break; + case ROTATION_YXZ: + MakeRotationY(yAngleRad); + RotateX(xAngleRad); + RotateZ(zAngleRad); + break; + case ROTATION_YZX: + MakeRotationY(yAngleRad); + RotateZ(zAngleRad); + RotateX(xAngleRad); + break; + case ROTATION_ZXY: + MakeRotationZ(zAngleRad); + RotateX(xAngleRad); + RotateY(yAngleRad); + break; + case ROTATION_ZYX: + MakeRotationZ(zAngleRad); + RotateY(yAngleRad); + RotateX(xAngleRad); + break; + default: + break; + }; + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotation(const Vector3& anglesRad, RotationOrder3 order) +{ + return MakeRotation(anglesRad.data[0], anglesRad.data[1], anglesRad.data[2], order); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotationX(const TypeReference angleRad) +{ + *this = GetIdentity(); + const T c = effects_cos(angleRad); + const T s = effects_sin(angleRad); + data[1].data[1] = c; + data[1].data[2] = -s; + data[2].data[1] = s; + data[2].data[2] = c; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotationY(const TypeReference angleRad) +{ + *this = GetIdentity(); + const T c = effects_cos(angleRad); + const T s = effects_sin(angleRad); + data[0].data[0] = c; + data[0].data[2] = s; + data[2].data[0] = -s; + data[2].data[2] = c; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotationZ(const TypeReference angleRad) +{ + *this = GetIdentity(); + const T c = effects_cos(angleRad); + const T s = effects_sin(angleRad); + data[0].data[0] = c; + data[0].data[1] = -s; + data[1].data[0] = s; + data[1].data[1] = c; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotationAxis(const Vector3& axis, const TypeReference angleRad) +{ + return MakeRotationAxis(axis.data[0], axis.data[1], axis.data[2], angleRad); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotationAxis(const TypeReference xAxis, const TypeReference yAxis, const TypeReference zAxis, const TypeReference angleRad) +{ + static const T t1(1.0f); + + Vector3 v = Vector3(xAxis, yAxis, zAxis); + v.normalize(); + const T sa = effects_sin(angleRad); + const T ca = effects_cos(angleRad); + const T inv_ca = t1 - ca; + + *this = GetIdentity(); + + data[0].data[0] = ca + inv_ca * v.x() * v.x(); + data[0].data[1] = inv_ca * v.x() * v.y() - sa * v.z(); + data[0].data[2] = inv_ca * v.z() * v.x() + sa * v.y(); + + data[1].data[0] = inv_ca * v.x()* v.y()+ sa * v.z(); + data[1].data[1] = ca + inv_ca * v.y()* v.y(); + data[1].data[2] = inv_ca * v.y()* v.z()- sa * v.x(); + + data[2].data[0] = inv_ca * v.z()* v.x()- sa * v.y(); + data[2].data[1] = inv_ca * v.y()* v.z()+ sa * v.x(); + data[2].data[2] = ca + inv_ca * v.z()* v.z(); + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotation(const Quaternion& rotation) +{ + *this = GetIdentity(); + return SetRotation(rotation); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeRotation(const Matrix3& rotation) +{ + *this = GetIdentity(); + return SetRotation(rotation); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Rotate(const TypeReference xAngleRad, const TypeReference yAngleRad, const TypeReference zAngleRad, RotationOrder3 order) +{ + return Rotate(MatrixType().MakeRotation(xAngleRad, yAngleRad, zAngleRad, order)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Rotate(const Vector3& anglesRad, RotationOrder3 order3) +{ + return Rotate(MatrixType().MakeRotation(anglesRad, order3)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::RotateX(const TypeReference angleRad) +{ + return Rotate(MatrixType().MakeRotationX(angleRad)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::RotateY(const TypeReference angleRad) +{ + return Rotate(MatrixType().MakeRotationY(angleRad)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::RotateZ(const TypeReference angleRad) +{ + return Rotate(MatrixType().MakeRotationZ(angleRad)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::RotateAxis(const Vector3& axis, const TypeReference angleRad) +{ + return Rotate(MatrixType().MakeRotationAxis(axis, angleRad)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::RotateAxis(const TypeReference xAxis, const TypeReference yAxis, const TypeReference zAxis, const TypeReference angleRad) +{ + return Rotate(MatrixType().MakeRotationAxis(xAxis, yAxis, zAxis, angleRad)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Rotate(const Quaternion& rotation) +{ + return Rotate(MatrixType().MakeRotation(rotation)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Rotate(const Matrix3& rotation) +{ + const T _11 = rotation.data[0].data[0] * data[0].data[0] + rotation.data[0].data[1] * data[1].data[0] + rotation.data[0].data[2] * data[2].data[0]; + const T _12 = rotation.data[0].data[0] * data[0].data[1] + rotation.data[0].data[1] * data[1].data[1] + rotation.data[0].data[2] * data[2].data[1]; + const T _13 = rotation.data[0].data[0] * data[0].data[2] + rotation.data[0].data[1] * data[1].data[2] + rotation.data[0].data[2] * data[2].data[2]; + + const T _21 = rotation.data[1].data[0] * data[0].data[0] + rotation.data[1].data[1] * data[1].data[0] + rotation.data[1].data[2] * data[2].data[0]; + const T _22 = rotation.data[1].data[0] * data[0].data[1] + rotation.data[1].data[1] * data[1].data[1] + rotation.data[1].data[2] * data[2].data[1]; + const T _23 = rotation.data[1].data[0] * data[0].data[2] + rotation.data[1].data[1] * data[1].data[2] + rotation.data[1].data[2] * data[2].data[2]; + + const T _31 = rotation.data[2].data[0] * data[0].data[0] + rotation.data[2].data[1] * data[1].data[0] + rotation.data[2].data[2] * data[2].data[0]; + const T _32 = rotation.data[2].data[0] * data[0].data[1] + rotation.data[2].data[1] * data[1].data[1] + rotation.data[2].data[2] * data[2].data[1]; + const T _33 = rotation.data[2].data[0] * data[0].data[2] + rotation.data[2].data[1] * data[1].data[2] + rotation.data[2].data[2] * data[2].data[2]; + + data[0].data[0] = _11; + data[0].data[1] = _12; + data[0].data[2] = _13; + data[1].data[0] = _21; + data[1].data[1] = _22; + data[1].data[2] = _23; + data[2].data[0] = _31; + data[2].data[1] = _32; + data[2].data[2] = _33; + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Rotate(const MatrixType& rotation) +{ + const T _11 = rotation.data[0].data[0] * data[0].data[0] + rotation.data[0].data[1] * data[1].data[0] + rotation.data[0].data[2] * data[2].data[0]; + const T _12 = rotation.data[0].data[0] * data[0].data[1] + rotation.data[0].data[1] * data[1].data[1] + rotation.data[0].data[2] * data[2].data[1]; + const T _13 = rotation.data[0].data[0] * data[0].data[2] + rotation.data[0].data[1] * data[1].data[2] + rotation.data[0].data[2] * data[2].data[2]; + + const T _21 = rotation.data[1].data[0] * data[0].data[0] + rotation.data[1].data[1] * data[1].data[0] + rotation.data[1].data[2] * data[2].data[0]; + const T _22 = rotation.data[1].data[0] * data[0].data[1] + rotation.data[1].data[1] * data[1].data[1] + rotation.data[1].data[2] * data[2].data[1]; + const T _23 = rotation.data[1].data[0] * data[0].data[2] + rotation.data[1].data[1] * data[1].data[2] + rotation.data[1].data[2] * data[2].data[2]; + + const T _31 = rotation.data[2].data[0] * data[0].data[0] + rotation.data[2].data[1] * data[1].data[0] + rotation.data[2].data[2] * data[2].data[0]; + const T _32 = rotation.data[2].data[0] * data[0].data[1] + rotation.data[2].data[1] * data[1].data[1] + rotation.data[2].data[2] * data[2].data[1]; + const T _33 = rotation.data[2].data[0] * data[0].data[2] + rotation.data[2].data[1] * data[1].data[2] + rotation.data[2].data[2] * data[2].data[2]; + + data[0].data[0] = _11; + data[0].data[1] = _12; + data[0].data[2] = _13; + data[1].data[0] = _21; + data[1].data[1] = _22; + data[1].data[2] = _23; + data[2].data[0] = _31; + data[2].data[1] = _32; + data[2].data[2] = _33; + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotation(const TypeReference xAngleRad, const TypeReference yAngleRad, const TypeReference zAngleRad, RotationOrder3 order) +{ + return MatrixType().MakeRotation(xAngleRad, yAngleRad, zAngleRad, order); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotation(const Vector3& anglesRad, RotationOrder3 order) +{ + return MatrixType().MakeRotation(anglesRad, order); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotationX(const TypeReference angleRad) +{ + return MatrixType().MakeRotationX(angleRad); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotationY(const TypeReference angleRad) +{ + return MatrixType().MakeRotationY(angleRad); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotationZ(const TypeReference angleRad) +{ + return MatrixType().MakeRotationZ(angleRad); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotationAxis(const Vector3& axis, const TypeReference angleRad) +{ + return MatrixType().MakeRotationAxis(axis, angleRad); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotationAxis(const TypeReference xAxis, const TypeReference yAxis, const TypeReference zAxis, const TypeReference angleRad) +{ + return MatrixType().MakeRotationAxis(xAxis, yAxis, zAxis, angleRad); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotation(const Quaternion& rotation) +{ + return MatrixType().MakeRotation(rotation); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateRotation(const Matrix3& rotation) +{ + return MatrixType().MakeRotation(rotation); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::GetRotationAngles(T& xAngleRad, T& yAngeRad, T& zAngleRad, unsigned int solutionNumber) +{ + static const T t0(0.0f); + static const T t2(2.0f); + static const T pi(F_PI); + + T& yaw = zAngleRad; + T& pitch = yAngeRad; + T& roll = xAngleRad; + + struct Euler + { + T yaw; + T pitch; + T roll; + }; + + Euler euler_out; + Euler euler_out2; //second solution + + // Check that pitch is not at a singularity + if (EffectsAbs(data[0].data[2]) >= T(1.0f)) + { + euler_out.yaw = t0; + euler_out2.yaw = t0; + + // From difference of angles formula + T delta = effects_atan2(data[0].data[0], data[2].data[0]); + if (data[0].data[2] > 0) //gimbal locked up + { + euler_out.pitch = pi / t2; + euler_out2.pitch = pi / t2; + euler_out.roll = euler_out.pitch + delta; + euler_out2.roll = euler_out.pitch + delta; + } + else // gimbal locked down + { + euler_out.pitch = -pi / t2; + euler_out2.pitch = -pi / t2; + euler_out.roll = -euler_out.pitch + delta; + euler_out2.roll = -euler_out.pitch + delta; + } + } + else + { + euler_out.pitch = - effects_asin(data[0].data[2]); + euler_out2.pitch = pi - euler_out.pitch; + + euler_out.roll = effects_atan2(data[1].data[2] / effects_cos(euler_out.pitch), data[2].data[2] / effects_cos(euler_out.pitch)); + + euler_out2.roll = effects_atan2(data[1].data[2] / effects_cos(euler_out2.pitch), data[2].data[2] / effects_cos(euler_out2.pitch)); + + euler_out.yaw = effects_atan2(data[0].data[1] / effects_cos(euler_out.pitch), data[0].data[0] / effects_cos(euler_out.pitch)); + + euler_out2.yaw = effects_atan2(data[0].data[1] / effects_cos(euler_out2.pitch), data[0].data[0] / effects_cos(euler_out2.pitch)); + } + + if (solutionNumber == 1) + { + yaw = euler_out.yaw; + pitch = euler_out.pitch; + roll = euler_out.roll; + } + else + { + yaw = euler_out2.yaw; + pitch = euler_out2.pitch; + roll = euler_out2.roll; + } + + return *(static_cast(this)); +} + +template +Quaternion MatrixTraits::GetQuaternion(void) const +{ + Quaternion result; + return GetQuaternion(result); +} + +template +Quaternion& MatrixTraits::GetQuaternion(Quaternion& rotation) const +{ + static const T t0(0.0f); + static const T thalf(0.5f); + static const T t1(1.0f); + + Quaternion& result = rotation; + + T tr = data[0].data[0] + data[1].data[1] + data[2].data[2]; // trace of martix + if (tr > t0) + { // if trace positive than "w" is biggest component + result.Set(data[2].data[1] - data[1].data[2], data[0].data[2] - data[2].data[0], data[1].data[0] - data[0].data[1], tr + t1); + result *= (thalf / effects_sqrt(result.w)); // "w" contain the "norm * 4" + + } + else // Some of vector components is bigger + { + if ((data[0].data[0] > data[1].data[1]) && (data[0].data[0] > data[2].data[2])) + { + result.Set(t1 + data[0].data[0] - data[1].data[1] - data[2].data[2], data[0].data[1] + data[1].data[0], data[0].data[2] + data[2].data[0], data[2].data[1] - data[1].data[2]); + result *= (thalf / effects_sqrt(result.x)); + + } + else + { + if (data[1].data[1] > data[2].data[2]) + { + result.Set(data[0].data[1] + data[1].data[0], t1 + data[1].data[1] - data[0].data[0] - data[2].data[2], data[1].data[2] + data[2].data[1], data[0].data[2] - data[2].data[0]); + result *= (thalf / effects_sqrt(result.y)); + + } + else + { + result.Set(data[0].data[2] + data[2].data[0], data[1].data[2] + data[2].data[1], t1 + data[2].data[2] - data[0].data[0] - data[1].data[1], data[1].data[0] - data[0].data[1]); + result *= (thalf / effects_sqrt(result.z)); + + } + } + } + + return result.normalize(); +} + +template +typename MatrixTraits::Matrix3 MatrixTraits::GetRotation(void) const +{ + return Matrix3(data[0].data[0], data[0].data[1], data[0].data[2], + data[1].data[0], data[1].data[1], data[1].data[2], + data[2].data[0], data[2].data[1], data[2].data[2]); +} + +template +typename MatrixTraits::Matrix3& MatrixTraits::GetRotation(Matrix3& rotation) const +{ + return rotation = GetRotation(); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeScale(const TypeReference x, const TypeReference y, const TypeReference z) +{ + *this = GetIdentity(); + return SetScale(x, y, z); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetScale(const TypeReference x, const TypeReference y, const TypeReference z) +{ + data[0].data[0] = x; + data[1].data[1] = y; + data[2].data[2] = z; + + data[0].data[1] = data[0].data[2] = data[1].data[0] = data[1].data[2] = data[2].data[0] = data[2].data[1] = T(0.0f); + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateScale(const TypeReference x, const TypeReference y, const TypeReference z) +{ + return MatrixType().MakeScale(x, y, z); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Scale(const TypeReference x, const TypeReference y, const TypeReference z) +{ + data[0].data[0] *= x; + data[1].data[0] *= y; + data[2].data[0] *= z; + data[0].data[1] *= x; + data[1].data[1] *= y; + data[2].data[1] *= z; + data[0].data[2] *= x; + data[1].data[2] *= y; + data[2].data[2] *= z; + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetTranslation(const TypeReference x, const TypeReference y, const TypeReference z) +{ + data[0].data[3] = x; + data[1].data[3] = y; + data[2].data[3] = z; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::SetTranslation(const Vector3& tran) +{ + return SetTranslation(tran.data[0], tran.data[1], tran.data[2]); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeTranslation(const TypeReference x, const TypeReference y, const TypeReference z) +{ + *this = GetIdentity(); + return SetTranslation(x, y, z); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeTranslation(const Vector3& tran) +{ + return MakeTranslation(tran.data[0], tran.data[1], tran.data[2]); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Translate(const TypeReference x, const TypeReference y, const TypeReference z) +{ + data[0].data[3] += x; + data[1].data[3] += y; + data[2].data[3] += z; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::Translate(const Vector3& tran) +{ + return Translate(tran.data[0], tran.data[1], tran.data[2]); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateTranslation(const TypeReference x, const TypeReference y, const TypeReference z) +{ + return MatrixType().MakeTranslation(x, y, z); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateTranslation(const Vector3& tran) +{ + return MatrixType().MakeTranslation(tran); +} + +template +typename MatrixTraits::Vector3 MatrixTraits::GetTranslation(void) const +{ + return Vector3().Set(data[0].data[3], data[1].data[3], data[2].data[3]); +} + +template +typename MatrixTraits::VectorType MatrixTraits::GetFullTranslation(void) const +{ + return VectorType().Set(data[0].data[3], data[1].data[3], data[2].data[3], data[3].data[3]); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeLookAtLH(const Vector3& eye, const Vector3& at, const Vector3& up) +{ + static const T t0(0.0f); + static const T t1(1.0f); + + Vector3 z((at - eye).normalize()); + Vector3 x; + x.makeCrossed(up, z).normalize(); + Vector3 y; + y.makeCrossed(z, x); + + data[0].data[0] = x.x(); + data[1].data[0] = y.x(); + data[2].data[0] = z.x(); + data[3].data[0] = t0; + data[0].data[1] = x.y(); + data[1].data[1] = y.y(); + data[2].data[1] = z.y(); + data[3].data[1] = t0; + data[0].data[2] = x.z(); + data[1].data[2] = y.z(); + data[2].data[2] = z.z(); + data[3].data[2] = t0; + + data[0].data[3] = -x.dot(eye); + data[1].data[3] = -y.dot(eye); + data[2].data[3] = -z.dot(eye); + data[3].data[3] = t1; + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeLookAtRH(const Vector3& eye, const Vector3& at, const Vector3& up) +{ + static const T t0(0.0f); + static const T t1(1.0f); + + Vector3 z((eye - at).normalize()); + Vector3 x; + x.makeCrossed(up, z).normalize(); + Vector3 y; + y.makeCrossed(z, x); + + data[0].data[0] = x.x(); + data[1].data[0] = y.x(); + data[2].data[0] = z.x(); + data[3].data[0] = t0; + data[0].data[1] = x.y(); + data[1].data[1] = y.y(); + data[2].data[1] = z.y(); + data[3].data[1] = t0; + data[0].data[2] = x.z(); + data[1].data[2] = y.z(); + data[2].data[2] = z.z(); + data[3].data[2] = t0; + + data[0].data[3] = -x.dot(eye); + data[1].data[3] = -y.dot(eye); + data[2].data[3] = -z.dot(eye); + data[3].data[3] = t1; + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeOrthoRH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar) +{ + static const T t2(2.0f); + + *this = GetIdentity(); + data[0].data[0] = t2 / width; + data[1].data[1] = t2 / height; + data[2].data[2] = t2 / (zNear - zFar); + data[2].data[3] = (zFar + zNear) / (zNear - zFar); + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeOrthoLH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar) +{ + MakeOrthoRH(width, height, zNear, zFar); + data[2].data[2] = -data[2].data[2]; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeOrthoRH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar) +{ + static const T t2(2.0f); + + *this = GetIdentity(); + + data[0].data[0] = t2 / (right - left); + data[1].data[1] = t2 / (top - bottom); + data[2].data[2] = t2 / (zNear - zFar); + + data[0].data[3] = (left + right) / (left - right); + data[1].data[3] = (top + bottom) / (bottom - top); + data[2].data[3] = (zFar + zNear) / (zNear - zFar); + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakeOrthoLH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar) +{ + MakeOrthoRH(left, right, top, bottom, zNear, zFar); + data[2].data[2] = -data[2].data[2]; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakePerspectiveLH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar) +{ + MakePerspectiveRH(left, right, top, bottom, zNear, zFar); + data[2].data[2] = -data[2].data[2]; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakePerspectiveRH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar) +{ + static const T t0(0.0f); + static const T t1(1.0f); + static const T t2(2.0f); + + *this = GetIdentity(); + data[0].data[0] = t2 * zNear / (right - left); + data[1].data[1] = t2 * zNear / (top - bottom); + data[2].data[2] = (zFar + zNear) / (zNear - zFar); + data[3].data[3] = t0; + + data[3].data[2] = -t1; + data[0].data[2] = (left + right) / (right - left); + data[1].data[2] = (top + bottom) / (top - bottom); + data[2].data[3] = t2 * zNear * zFar / (zNear - zFar); + + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakePerspectiveLH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar) +{ + MakePerspectiveRH(width, height, zNear, zFar); + data[2].data[2] = -data[2].data[2]; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakePerspectiveRH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar) +{ + static const T t0(0.0f); + static const T t1(1.0f); + static const T t2(2.0f); + + *this = GetIdentity(); + data[0].data[0] = t2 * zNear / width; + data[1].data[1] = t2 * zNear / height; + data[2].data[2] = (zFar + zNear) / (zNear - zFar); + + data[2].data[3] = t2 * zNear * zFar / (zNear - zFar); + data[3].data[2] = -t1; + data[3].data[3] = t0; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakePerspectiveFovLH(const TypeReference fovY, const TypeReference aspect, const TypeReference zNear, const TypeReference zFar) +{ + MakePerspectiveFovRH(fovY, aspect, zNear, zFar); + data[2].data[2] = -data[2].data[2]; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType& MatrixTraits::MakePerspectiveFovRH(const TypeReference fovY, const TypeReference aspect, const TypeReference zNear, const TypeReference zFar) +{ + static const T t0(0.0f); + static const T t1(1.0f); + static const T t2(2.0f); + + *this = GetIdentity(); + data[1].data[1] = t1 / tan(fovY / t2); + data[0].data[0] = data[1].data[1] / aspect; + data[2].data[2] = (zFar + zNear) / (zNear - zFar); + + data[3].data[2] = -t1; + data[2].data[3] = t2 * (zNear * zFar / (zNear - zFar)); + data[3].data[3] = t0; + return *(static_cast(this)); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateLookAtLH(const Vector3& eye, const Vector3& at, const Vector3& up) +{ + return MatrixType().MakeLookAtLH(eye, at, up); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateLookAtRH(const Vector3& eye, const Vector3& at, const Vector3& up) +{ + return MatrixType().MakeLookAtRH(eye, at, up); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateOrthoRH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar) +{ + return MatrixType().MakeOrthoRH(width, height, zNear, zFar); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateOrthoLH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar) +{ + return MatrixType().MakeOrthoLH(width, height, zNear, zFar); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateOrthoRH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar) +{ + return MatrixType().MakeOrthoRH(left, right, top, bottom, zNear, zFar); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreateOrthoLH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar) +{ + return MatrixType().MakeOrthoLH(left, right, top, bottom, zNear, zFar); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreatePerspectiveLH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar) +{ + return MatrixType().MakePerspectiveLH(left, right, top, bottom, zNear, zFar); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreatePerspectiveRH(const TypeReference left, const TypeReference right, const TypeReference top, const TypeReference bottom, const TypeReference zNear, const TypeReference zFar) +{ + return MatrixType().MakePerspectiveRH(left, right, top, bottom, zNear, zFar); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreatePerspectiveLH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar) +{ + return MatrixType().MakePerspectiveLH(width, height, zNear, zFar); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreatePerspectiveRH(const TypeReference width, const TypeReference height, const TypeReference zNear, const TypeReference zFar) +{ + return MatrixType().MakePerspectiveRH(width, height, zNear, zFar); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreatePerspectiveFovLH(const TypeReference fovY, const TypeReference aspect, const TypeReference zNear, const TypeReference zFar) +{ + return MatrixType().MakePerspectiveFovLH(fovY, aspect, zNear, zFar); +} + +template +typename MatrixTraits::MatrixType MatrixTraits::CreatePerspectiveFovRH(const TypeReference fovY, const TypeReference aspect, const TypeReference zNear, const TypeReference zFar) +{ + return MatrixType().MakePerspectiveFovRH(fovY, aspect, zNear, zFar); +} + +template +bool MatrixTraits::GetOrthoParamsRH(T& left, T& right, T& top, T& bottom, T& zNear, T& zFar) const +{ + static const T t1(1.0f); + + zNear = (data[2].data[3] + t1) / data[2].data[2]; + zFar = (data[2].data[3] - t1) / data[2].data[2]; + + left = -(t1 + data[0].data[3]) / data[0].data[0]; + right = (t1 - data[0].data[3]) / data[0].data[0]; + + bottom = -(t1 + data[1].data[3]) / data[1].data[1]; + top = (t1 - data[1].data[3]) / data[1].data[1]; + + return true; +} + +template +bool MatrixTraits::GetPerspectiveParamsRH(T& left, T& right, T& top, T& bottom, T& zNear, T& zFar) const +{ + static const T t1(1.0f); + + zNear = data[2].data[3] / (data[2].data[2] - t1); + zFar = data[2].data[3] / (t1 + data[2].data[2]); + + left = zNear * (data[0].data[2] - t1) / data[0].data[0]; + right = zNear * (t1 + data[0].data[2]) / data[0].data[0]; + + top = zNear * (t1 + data[1].data[2]) / data[1].data[1]; + bottom = zNear * (data[1].data[2] - t1) / data[1].data[1]; + + return true; +} + +template +bool MatrixTraits::GetPerspectiveParamsRH(T& fovY, T& aspect, T& zNear, T& zFar) const +{ + T left, right, bottom, top; + bool result = GetPerspectiveParamsRH(left, right, top, bottom, zNear, zFar); + if (result) + { + T height = top - bottom; + T width = right - left; + aspect = width / height; + fovY = T(2.0f) * effects_atan(height / zNear * T(0.5f)); + } + return result; +} + +template +bool MatrixTraits::GetViewParams(Vector3& position, Vector3& direction, Vector3& up, Vector3& right) const +{ + right.Set(data[0].data[0], data[0].data[1], data[0].data[2]); + up.Set(data[1].data[0], data[1].data[1], data[1].data[2]); + direction.Set(-data[2].data[0], -data[2].data[1], -data[2].data[2]); + position = direction * data[2].data[3] - right * data[0].data[3] - up * data[1].data[3]; + return true; +} + + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX_TRAITS_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrixTraitsBase.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrixTraitsBase.h new file mode 100644 index 0000000..6e5253e --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathMatrixTraitsBase.h @@ -0,0 +1,55 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathMatrixTraitsBase.h + * @brief The MatrixTraitsBase class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX_TRAITS_BASE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX_TRAITS_BASE_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ +template +class Matrix; +template +class Vector; + +template +class MatrixTraitsBase +{ +public: + MatrixTraitsBase(void) : data() {} + + typedef Matrix MatrixType; + + typedef typename Tizen::Ui::Effects::_Renderer::System::SelectType::isFundamental, T, T&>::Result TypeReference; + typedef const TypeReference ConstTypeReference; + + typedef Vector ItemType; + typedef ItemType DataType[Dimension]; + + DataType data; +}; +}}}}} //Tizen::Ui::Effects::_Renderer::Math + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_MATRIX_TRAITS_BASE_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVector.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVector.h new file mode 100644 index 0000000..3b3e955 --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVector.h @@ -0,0 +1,686 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathVector.h + * @brief The Vector class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR_H_ + +#include + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ + +template +class Vector : + public VectorTraits +{ +public: + typedef Vector VectorType; + typedef VectorTraitsBase VectorTraitsBaseType; + typedef typename VectorTraitsBaseType::TypeReference TypeReference; + + using VectorTraitsBaseType::data; + using VectorTraits::Set; + + inline Vector(void); + inline explicit Vector(const TypeReference value); + inline Vector(const TypeReference x, const TypeReference y); + inline Vector(const TypeReference x, const TypeReference y, const TypeReference z); + inline Vector(const TypeReference x, const TypeReference y, const TypeReference z, const TypeReference w); + inline Vector(const VectorType& other); + + inline VectorType& operator = (const VectorType& rhv); + + inline VectorType& Set(const VectorType& other); + inline VectorType& Set(const TypeReference value); + + inline VectorType& FillFromArray(const T* array); + static inline VectorType MakeFromArray(const T* array); + + inline VectorType operator - (void) const; + inline VectorType& Inverse(void); + inline VectorType GetInversed(void) const; + + inline VectorType& operator += (const VectorType& rhv); + inline VectorType& operator += (const TypeReference rhv); + inline VectorType& operator -= (const VectorType& rhv); + inline VectorType& operator -= (const TypeReference rhv); + inline VectorType& operator *= (const VectorType& rhv); + inline VectorType& operator *= (const TypeReference rhv); + inline VectorType& operator /= (const VectorType& rhv); + inline VectorType& operator /= (const TypeReference rhv); + + inline T* GetPointer(void); + inline const T* GetPointer(void) const; + + inline VectorType& Normalize(void); + inline VectorType GetNormalized(void) const; + + inline VectorType& Lerp(const VectorType& to, const TypeReference coeff); + inline VectorType GetLerped(const VectorType& to, const TypeReference) const; + inline VectorType& MakeLerped(const VectorType& from, const VectorType& to, const TypeReference); + static inline VectorType CreateLerped(const VectorType& from, const VectorType& to, const TypeReference); + + inline T Dot(const VectorType& other) const; + + inline T LengthSqr(void) const; + inline T Length(void) const; + inline T DistanceSqr(const VectorType& other) const; + inline T Distance(const VectorType& other) const; + + inline Vector Swizzle(unsigned int x, unsigned int y) const; + inline Vector Swizzle(unsigned int x, unsigned int y, unsigned int z) const; + inline Vector Swizzle(unsigned int x, unsigned int y, unsigned int z, unsigned int w) const; + + inline bool IsEqual(const Vector& rhv, const TypeReference epsilon = EffectsEpsilon::epsilon()) const; +}; + +template +inline bool IsEqual(const Vector& lhv, const Vector& rhv, const typename Vector::TypeReference epsilon); + +template inline Vector operator + (const Vector& lhv, const Vector& rhv); +template inline Vector operator + (const Vector& lhv, const typename Vector::TypeReference rhv); +template inline Vector operator + (const typename Vector::TypeReference lhv, const Vector& rhv); +template inline Vector operator - (const Vector& lhv, const Vector& rhv); +template inline Vector operator - (const Vector& lhv, const typename Vector::TypeReference rhv); +template inline Vector operator - (const typename Vector::TypeReference lhv, const Vector& rhv); +template inline Vector operator * (const Vector& lhv, const Vector& rhv); +template inline Vector operator * (const Vector& lhv, const typename Vector::TypeReference rhv); +template inline Vector operator * (const typename Vector::TypeReference lhv, const Vector& rhv); +template inline Vector operator / (const Vector& lhv, const Vector& rhv); +template inline Vector operator / (const Vector& lhv, const typename Vector::TypeReference rhv); +template inline Vector operator / (const typename Vector::TypeReference lhv, const Vector& rhv); +template inline bool operator == (const Vector& lhv, const Vector& rhv); +template inline bool operator == (const Vector& lhv, const typename Vector::TypeReference rhv); +template inline bool operator == (const typename Vector::TypeReference lhv, const Vector& rhv); +template inline bool operator != (const Vector& lhv, const Vector& rhv); +template inline bool operator != (const Vector& lhv, const typename Vector::TypeReference rhv); +template inline bool operator != (const typename Vector::TypeReference lhv, const Vector& rhv); + +typedef Vector Vector1f; +typedef Vector Vector1d; +typedef Vector Vector2f; +typedef Vector Vector2d; +typedef Vector Vector3f; +typedef Vector Vector3d; +typedef Vector Vector4f; +typedef Vector Vector4d; + +template +Vector::Vector(void) +{ +} + +template +Vector::Vector(const TypeReference value) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] = value; + } +} + +template +Vector::Vector(const TypeReference x, const TypeReference y) +{ + EffectsStaticAssert(Dimension >= 2); + data[0] = x; + data[1] = y; +} + +template +Vector::Vector(const TypeReference x, const TypeReference y, const TypeReference z) +{ + EffectsStaticAssert(Dimension >= 3); + data[0] = x; + data[1] = y; + data[2] = z; +} + +template +Vector::Vector(const TypeReference x, const TypeReference y, const TypeReference z, const TypeReference w) +{ + EffectsStaticAssert(Dimension >= 4); + data[0] = x; + data[1] = y; + data[2] = z; + data[3] = w; +} + +template +Vector::Vector(const VectorType& other) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] = other.data[i]; + } +} + +template +Vector& Vector::operator=(const VectorType& rhv) +{ + if (this != &rhv) + { + for (int i = 0; i < Dimension; i++) + { + data[i] = rhv.data[i]; + } + } + return *this; +} + +template +typename Vector::VectorType& Vector::Set(const VectorType& other) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] = other.data[i]; + } + return *this; +} + +template +typename Vector::VectorType& Vector::Set(const TypeReference value) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] = value; + } + return *this; +} + +template +typename Vector::VectorType& Vector::FillFromArray(const T* value) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] = value[i]; + } + return *this; +} + +template +typename Vector::VectorType Vector::MakeFromArray(const T* value) +{ + VectorType result; + result.FillFromArray(value); + return result; +} + + +template +Vector Vector::operator - (void) const +{ + return GetInversed(); +} + +template +Vector& Vector::Inverse(void) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] = -data[i]; + } + return *this; +} + +template +Vector Vector::GetInversed(void) const +{ + VectorType result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = -data[i]; + } + return result; +} + +template +Vector& Vector::operator += (const Vector& rhv) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] += rhv.data[i]; + } + return *this; +} + +template +Vector& Vector::operator += (const TypeReference rhv) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] += rhv; + } + return *this; +} + +template +Vector& Vector::operator -= (const VectorType& rhv) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] -= rhv.data[i]; + } + return *this; +} + +template +Vector& Vector::operator -= (const TypeReference rhv) +{ + for (int i = 0; i < Dimension; i++) + data[i] -= rhv; + return *this; +} + +template +Vector& Vector::operator *= (const VectorType& rhv) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] *= rhv.data[i]; + } + return *this; +} + +template +Vector& Vector::operator *= (const TypeReference rhv) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] *= rhv; + } + return *this; +} + +template +Vector& Vector::operator /= (const VectorType& rhv) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] /= rhv.data[i]; + } + return *this; +} + +template +Vector& Vector::operator /= (const TypeReference rhv) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] /= rhv; + } + return *this; +} + +template +T* Vector::GetPointer(void) +{ + return &(data[0]); +} + +template +const T* Vector::GetPointer(void) const +{ + return &(data[0]); +} + +template +Vector& Vector::Normalize(void) +{ + const static T t0(0.0f); + + const TypeReference dist = Length(); + if (EffectsEqual(t0, dist)) + { + return *this; + } + + return operator /= (dist); +} + +template +Vector Vector::GetNormalized(void) const +{ + const static T t0(0.0f); + + const T dist = Length(); + if (EffectsEqual(t0, dist)) + { + return *this; + } + + return *this / dist; +} + +template +Vector& Vector::Lerp(const VectorType& to, const TypeReference coeff) +{ + for (int i = 0; i < Dimension; i++) + { + data[i] += (to.data[i] - data[i]) * coeff; + } + return *this; +} + +template +Vector Vector::GetLerped(const VectorType& to, const TypeReference coeff) const +{ + VectorType result(*this); + return result.Lerp(to, coeff); +} + +template +Vector& Vector::MakeLerped(const VectorType& from, const VectorType& to, const TypeReference coeff) +{ + *this = from; + return Lerp(to, coeff); +} + +template +Vector Vector::CreateLerped(const VectorType& from, const VectorType& to, const TypeReference coeff) +{ + return VectorType().MakeLerped(from, to, coeff); +} + +template +T Vector::Dot(const VectorType& other) const +{ + T result = T(); + for (int i = 0; i < Dimension; i++) + { + result += data[i] * other.data[i]; + } + return result; +} + +template +T Vector::LengthSqr(void) const +{ + T result = T(); + for (int i = 0; i < Dimension; i++) + { + result += data[i] * data[i]; + } + return result; +} + +template +T Vector::Length(void) const +{ + return EffectsSqrt(LengthSqr()); +} + +template +T Vector::DistanceSqr(const VectorType& other) const +{ + T result = T(); + for (int i = 0; i < Dimension; i++) + { + T t = data[i] - other.data[i]; + result += t * t; + } + return result; +} + +template +T Vector::Distance(const VectorType& other) const +{ + return effects_sqrt(DistanceSqr(other)); +} + +template +Vector Vector::Swizzle(unsigned int x, unsigned int y) const +{ + return Vector(data[x], data[y]); +} + +template +Vector Vector::Swizzle(unsigned int x, unsigned int y, unsigned int z) const +{ + return Vector(data[x], data[y], data[z]); +} + +template +Vector Vector::Swizzle(unsigned int x, unsigned int y, unsigned int z, unsigned int w) const +{ + return Vector(data[x], data[y], data[z], data[w]); +} + +template +bool Vector::IsEqual(const Vector& rhv, const TypeReference epsilon) const +{ + for (int i = 0; i < Dimension; i++) + { + if (!EffectsEqual(data[i], rhv.data[i], epsilon)) + { + return false; + } + } + + return true; +} + +template +bool IsEqual(const Vector& lhv, const Vector& rhv, const typename Vector::TypeReference epsilon) +{ + return lhv.IsEqual(rhv, epsilon); +} + +template +Vector operator + (const Vector& lhv, const Vector& rhv) +{ + Vector result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = lhv.data[i] + rhv.data[i]; + } + return result; +} + +template +Vector operator + (const Vector& lhv, const typename Vector::TypeReference rhv) +{ + Vector result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = lhv.data[i] + rhv; + } + return result; +} + +template +Vector operator + (const typename Vector::TypeReference lhv, const Vector& rhv) +{ + Vector result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = lhv + rhv.data[i]; + } + return result; +} + +template +Vector operator - (const Vector& lhv, const Vector& rhv) +{ + Vector result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = lhv.data[i] - rhv.data[i]; + } + return result; +} + +template +Vector operator - (const Vector& lhv, const typename Vector::TypeReference rhv) +{ + Vector result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = lhv.data[i] - rhv; + } + return result; +} + +template +Vector operator - (const typename Vector::TypeReference lhv, const Vector& rhv) +{ + Vector result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = lhv - rhv.data[i]; + } + return result; +} + +template +Vector operator * (const Vector& lhv, const Vector& rhv) +{ + Vector result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = lhv.data[i] * rhv.data[i]; + } + return result; +} + +template +Vector operator * (const Vector& lhv, const typename Vector::TypeReference rhv) +{ + Vector result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = lhv.data[i] * rhv; + } + return result; +} + +template +Vector operator * (const typename Vector::TypeReference lhv, const Vector& rhv) +{ + Vector result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = lhv * rhv.data[i]; + } + return result; +} + +template +Vector operator / (const Vector& lhv, const Vector& rhv) +{ + Vector result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = lhv.data[i] / rhv.data[i]; + } + return result; +} + +template +Vector operator / (const Vector& lhv, const typename Vector::TypeReference rhv) +{ + Vector result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = lhv.data[i] / rhv; + } + return result; +} + +template +inline Vector operator / (const typename Vector::TypeReference lhv, const Vector& rhv) +{ + Vector result; + for (int i = 0; i < Dimension; i++) + { + result.data[i] = lhv / rhv.data[i]; + } + return result; +} + +template +bool operator == (const Vector& lhv, const Vector& rhv) +{ + for (int i = 0; i < Dimension; i++) + { + if (!EffectsEqual(lhv.data[i], rhv.data[i])) + { + return false; + } + } + return true; +} + +template +bool operator == (const Vector& lhv, const typename Vector::TypeReference rhv) +{ + for (int i = 0; i < Dimension; i++) + { + if (!EffectsEqual(lhv.data[i], rhv)) + { + return false; + } + } + return true; +} + +template +bool operator == (const typename Vector::TypeReference lhv, const Vector& rhv) +{ + for (int i = 0; i < Dimension; i++) + { + if (!EffectsEqual(lhv, rhv.data[i])) + { + return false; + } + } + return true; +} + +template +inline bool operator != (const Vector& lhv, const Vector& rhv) +{ + return !(lhv == rhv); +} + +template +bool operator != (const Vector& lhv, const typename Vector::TypeReference rhv) +{ + return !(lhv == rhv); +} + +template +bool operator != (const typename Vector::TypeReference lhv, const Vector& rhv) +{ + return !(lhv == rhv); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVector1Traits.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVector1Traits.h new file mode 100644 index 0000000..296edf7 --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVector1Traits.h @@ -0,0 +1,69 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathVector1Traits.h + * @brief The Vector1Traits class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR1_TRAITS_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR1_TRAITS_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ + +template +class VectorTraits : + public VectorTraitsBase +{ +public: + typedef Vector VectorType; + typedef VectorTraitsBase VectorTraitsBaseType; + typedef typename VectorTraitsBaseType::TypeReference TypeReference; + + using VectorTraitsBaseType::data; + + inline T& X(void); + inline const TypeReference X(void) const; + + inline VectorType& Set(void); +}; + +template +T& VectorTraits::X(void) +{ + return data[0]; +} + +template +const typename VectorTraits::TypeReference VectorTraits::X(void) const +{ + return data[0]; +} + +template +typename VectorTraits::VectorType& VectorTraits::Set(void) +{ + return *(static_cast(this)); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR1_TRAITS_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVector2Traits.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVector2Traits.h new file mode 100644 index 0000000..c81d4eb --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVector2Traits.h @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathVector2Traits.h + * @brief The Vector2Traits class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR2_TRAITS_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR2_TRAITS_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ + +template +class VectorTraits : + public VectorTraitsBase +{ +public: + typedef Vector VectorType; + typedef VectorTraitsBase VectorTraitsBaseType; + typedef typename VectorTraitsBaseType::TypeReference TypeReference; + + using VectorTraitsBaseType::data; + + inline T& X(void); + inline const TypeReference X(void) const; + + inline T& Y(void); + inline const TypeReference Y(void) const; + + inline VectorType& Set(const TypeReference x, const TypeReference y); +}; + +template +T& VectorTraits::X(void) +{ + return data[0]; +} + +template +const typename VectorTraits::TypeReference VectorTraits::X(void) const +{ + return data[0]; +} + +template +T& VectorTraits::Y(void) +{ + return data[1]; +} + +template +const typename VectorTraits::TypeReference VectorTraits::Y(void) const +{ + return data[1]; +} + +template +typename VectorTraits::VectorType& VectorTraits::Set(const TypeReference x, const TypeReference y) +{ + data[0] = x; + data[1] = y; + return *(static_cast(this)); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR2_TRAITS_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVector3Traits.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVector3Traits.h new file mode 100644 index 0000000..b30c31e --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVector3Traits.h @@ -0,0 +1,133 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathVector3Traits.h + * @brief The Vector3Traits class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR3_TRAITS_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR3_TRAITS_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ + +template +class VectorTraits : + public VectorTraitsBase +{ +public: + typedef Vector VectorType; + typedef VectorTraitsBase VectorTraitsBaseType; + typedef typename VectorTraitsBaseType::TypeReference TypeReference; + + using VectorTraitsBaseType::data; + + inline T& X(void); + inline const TypeReference X(void) const; + + inline T& Y(void); + inline const TypeReference Y(void) const; + + inline T& Z(void); + inline const TypeReference Z(void) const; + + inline VectorType& Set(const TypeReference x, const TypeReference y, const TypeReference z); + + inline VectorType& Cross(const VectorType& other); + inline VectorType GetCrossed(const VectorType& other) const; + inline VectorType& MakeCrossed(const VectorType& first, const VectorType& second); + static inline VectorType CreateCrossed(const VectorType& first, const VectorType& second); +}; + +template +T& VectorTraits::X(void) +{ + return data[0]; +} + +template +const typename VectorTraits::TypeReference VectorTraits::X(void) const +{ + return data[0]; +} + +template +T& VectorTraits::Y(void) +{ + return data[1]; +} + +template +const typename VectorTraits::TypeReference VectorTraits::Y(void) const +{ + return data[1]; +} + +template +T& VectorTraits::Z(void) +{ + return data[2]; +} + +template +const typename VectorTraits::TypeReference VectorTraits::Z(void) const +{ + return data[2]; +} + +template +typename VectorTraits::VectorType& VectorTraits::Set(const TypeReference x, const TypeReference y, const TypeReference z) +{ + data[0] = x; + data[1] = y; + data[2] = z; + return *(static_cast(this)); +} + +template +typename VectorTraits::VectorType& VectorTraits::Cross(const VectorType& other) +{ + return Set((Y() * other.Z() - Z() * other.Y()), (Z() * other.X() - X() * other.Z()), (X() * other.Y() - Y() * other.X())); +} + +template +typename VectorTraits::VectorType VectorTraits::GetCrossed(const VectorType& other) const +{ + VectorType result(X(), Y(), Z()); + return result.Cross(other); +} + +template +typename VectorTraits::VectorType& VectorTraits::MakeCrossed(const VectorType& first, const VectorType& second) +{ + *this = first; + return Cross(second); +} + +template +typename VectorTraits::VectorType VectorTraits::CreateCrossed(const VectorType& first, const VectorType& second) +{ + return VectorTraits().MakeCrossed(first, second); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR3_TRAITS_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVectorTraits.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVectorTraits.h new file mode 100644 index 0000000..adec1aa --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVectorTraits.h @@ -0,0 +1,119 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathVectorTraits.h + * @brief The VectorTraits class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR_TRAITS_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR_TRAITS_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ + +template +class VectorTraits : + public VectorTraitsBase +{ +public: + typedef Vector VectorType; + typedef VectorTraitsBase VectorTraitsBaseType; + typedef typename VectorTraitsBaseType::TypeReference TypeReference; + + using VectorTraitsBaseType::data; + + inline T& X(void); + inline const TypeReference X(void) const; + + inline T& Y(void); + inline const TypeReference Y(void) const; + + inline T& Z(void); + inline const TypeReference Z(void) const; + + inline T& W(void); + inline const TypeReference W(void) const; + + inline VectorType& Set(const TypeReference x, const TypeReference y, const TypeReference z, const TypeReference w); +}; + +template +T& VectorTraits::X(void) +{ + return data[0]; +} + +template +const typename VectorTraits::TypeReference VectorTraits::X(void) const +{ + return data[0]; +} + +template +T& VectorTraits::Y(void) +{ + return data[1]; +} + +template +const typename VectorTraits::TypeReference VectorTraits::Y(void) const +{ + return data[1]; +} + +template +T& VectorTraits::Z(void) +{ + return data[2]; +} + +template +const typename VectorTraits::TypeReference VectorTraits::Z(void) const +{ + return data[2]; +} + +template +T& VectorTraits::W(void) +{ + return data[3]; +} + +template +const typename VectorTraits::TypeReference VectorTraits::W(void) const +{ + return data[3]; +} + +template +typename VectorTraits::VectorType& VectorTraits::Set(const TypeReference x, const TypeReference y, const TypeReference z, const TypeReference w) +{ + data[0] = x; + data[1] = y; + data[2] = z; + data[3] = w; + return *(static_cast(this)); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR_TRAITS_H_ diff --git a/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVectorTraitsBase.h b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVectorTraitsBase.h new file mode 100644 index 0000000..6ea52e8 --- /dev/null +++ b/src/ui/effects/inc/renderer/math/FUiEffects_RendererMathVectorTraitsBase.h @@ -0,0 +1,51 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererMathVectorTraitsBase.h + * @brief The VectorTraitsBase class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR_TRAITS_BASE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR_TRAITS_BASE_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace Math +{ + +template +class Vector; + +template +class VectorTraitsBase +{ +public: + typedef Vector VectorType; + + typedef typename Tizen::Ui::Effects::_Renderer::System::SelectType::isFundamental, T, T&>::Result TypeReference; + typedef const TypeReference ConstTypeReference; + + typedef T DataType[Dimension]; + DataType data; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::Math + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_MATH_VECTOR_TRAITS_BASE_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemConstnessPolicy.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemConstnessPolicy.h new file mode 100644 index 0000000..5d8c85d --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemConstnessPolicy.h @@ -0,0 +1,44 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemConstnessPolicy.h + * @brief The ConstnessPolicy template + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_CONSTNESS_POLICY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_CONSTNESS_POLICY_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +template +struct ConstnessPolicyDontConst +{ + typedef T Type; +}; + +template +struct ConstnessPolicyConst +{ + typedef const T Type; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_CONSTNESS_POLICY_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemData.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemData.h new file mode 100644 index 0000000..49efbca --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemData.h @@ -0,0 +1,459 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemData.h + * @brief The Data class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_DATA_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_DATA_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +/** + * @brief This class represents the data + */ +template +class Data +{ +public: + typedef ITEM_TYPE ItemType; + typedef std::vector ListType; + + typedef typename ListType::reference reference; + typedef typename ListType::const_reference const_reference; + typedef typename ListType::iterator iterator; + typedef typename ListType::const_iterator const_iterator; + typedef typename ListType::size_type size_type; + typedef typename ListType::difference_type difference_type; + typedef typename ListType::value_type value_type; + typedef typename ListType::allocator_type allocator_type; + typedef typename ListType::pointer pointer; + typedef typename ListType::const_pointer const_pointer; + typedef typename ListType::reverse_iterator reverse_iterator; + typedef typename ListType::const_reverse_iterator const_reverse_iterator; + +private: + ListType __list; + +public: + Data(void); + Data(const Data& data); + explicit Data(size_type size, const ItemType value); + explicit Data(size_type size); + + template + Data(InputIterator firstIterator, InputIterator lastIterator); + + virtual ~Data(void); + + Data& operator = (const Data& data); + bool operator == (const Data& data) const; + bool operator != (const Data& data) const; + + iterator Begin(void); + const_iterator Begin(void) const; + iterator End(void); + const_iterator End(void) const; + + reverse_iterator Rbegin(void); + const_reverse_iterator Rbegin(void) const; + reverse_iterator Rend(void); + const_reverse_iterator Rend(void) const; + + size_type Size(void) const; + size_type MaxSize(void) const; + void Resize(size_type size, ItemType value); + void Resize(size_type size); + size_type Capacity(void) const; + bool Empty(void) const; + void Reserve(size_type size); + + reference operator[](size_type position); + const_reference operator[](size_type position) const; + reference At(size_type position); + const_reference At(size_type position) const; + reference Front(void); + const_reference Front(void) const; + reference Back(void); + const_reference Back(void) const; + + template + void Assign(InputIterator firstIterator, InputIterator lastIterator); + + void Assign(size_type size, const ItemType value); + void PushBack(const ItemType value); + void PopBack(void); + iterator Insert(iterator position, const ItemType value); + void Insert(iterator position, size_type size, const ItemType value); + + template + void Insert(iterator position, InputIterator firstIterator, InputIterator lastIterator); + + void Copy(const Data& sourceData, size_type sourcePosition, size_type size, size_type destinationPosition); + void Copy(const void* pSourceData, size_type size, size_type destinationPosition); + + void CopyTo(value_type* pDestination, size_type position, size_type size) const; + + iterator Erase(iterator position); + iterator Erase(iterator firstIterator, iterator lastIterator); + void Swap(Data& data); + void Clear(void); + + allocator_type GetAllocator() const; +}; + +template +template +Data::Data(InputIterator firstIterator, InputIterator lastIterator) : __list(firstIterator, lastIterator) +{ + +} + +template +template +void Data::Assign(InputIterator firstIterator, InputIterator lastIterator) +{ + __list.assign(firstIterator, lastIterator); +} + +template +template +void Data::Insert(iterator position, InputIterator firstIterator, InputIterator lastIterator) +{ + __list.insert(position, firstIterator, lastIterator); +} + +template +Data::Data(void) : __list() +{ + +} + +template +Data::Data(const Data& data) : __list(data.__list) +{ + +} + +template +Data::Data(size_type size, const ItemType value ) : __list(size, value) +{ + +} + +template +Data::Data(size_type size) : __list(size) +{ + +} + +template +Data::~Data(void) +{ + +} + +template +Data& +Data::operator = (const Data& data) +{ + if (this != &data) + { + __list = data.__list; + } + return* this; +} + +template +bool +Data::operator == (const Data& data) const +{ + return __list == data.__list; +} + +template +bool +Data::operator != (const Data& data) const +{ + return __list != data.__list; +} + +template +typename Data::iterator +Data::Begin(void) +{ + return __list.begin(); +} + +template +typename Data::const_iterator +Data::Begin(void) const +{ + return __list.begin(); +} + +template +typename Data::iterator +Data::End(void) +{ + return __list.end(); +} + +template +typename Data::const_iterator +Data::End(void) const +{ + return __list.end(); +} + +template +typename Data::reverse_iterator +Data::Rbegin(void) +{ + return __list.rbegin(); +} + +template +typename Data::const_reverse_iterator +Data::Rbegin(void) const +{ + return __list.rbegin(); +} + +template +typename Data::reverse_iterator +Data::Rend(void) +{ + return __list.rend(); +} + +template +typename Data::const_reverse_iterator +Data::Rend(void) const +{ + return __list.rend(); +} + +template +typename Data::size_type +Data::Size(void) const +{ + return __list.size(); +} + +template +typename Data::size_type +Data::MaxSize(void) const +{ + return __list.max_size(); +} + +template +void +Data::Resize(size_type size, ItemType value) +{ + __list.resize(size, value); +} + +template +void +Data::Resize(size_type size) +{ + __list.resize(size); +} + +template +typename Data::size_type +Data::Capacity(void) const +{ + return __list.capacity(); +} + +template +bool +Data::Empty(void) const +{ + return __list.empty(); +} + +template +void +Data::Reserve(size_type size) +{ + __list.reserve(size); +} + +template +typename Data::reference +Data::operator[](size_type position) +{ + return __list[position]; +} + +template +typename Data::const_reference +Data::operator[](size_type position) const +{ + return __list[position]; +} + +template +typename Data::const_reference +Data::At(size_type position) const +{ + return __list.at(position); +} + +template +typename Data::reference +Data::At(size_type position) +{ + return __list[position]; +} + +template +typename Data::reference +Data::Front(void) +{ + return __list.front(); +} + +template +typename Data::const_reference +Data::Front(void) const +{ + return __list.front(); +} + +template +typename Data::reference +Data::Back(void) +{ + return __list.back(); +} + +template +typename Data::const_reference +Data::Back(void) const +{ + return __list.back(); +} + +template +void +Data::Assign(size_type size, const ItemType value) +{ + __list.assign(size, value); +} + +template +void +Data::PushBack(const ItemType value) +{ + __list.push_back(value); +} + +template +void +Data::PopBack(void) +{ + __list.pop_back(); +} + +template +typename Data::iterator +Data::Insert(iterator position, const ItemType value) +{ + return __list.insert(position, value); +} + +template +void +Data::Insert(iterator position, size_type size, const ItemType value) +{ + __list.insert(position, size, value); +} + +template +void +Data::Copy(const Data& sourceData, size_type sourcePosition, size_type size, size_type destinationPosition) +{ + memcpy(&(operator[](destinationPosition)),& sourceData[sourcePosition], size); +} + +template +void +Data::Copy(const void* pSourceData, size_type size, size_type destinationPosition) +{ + memcpy(&(operator[](destinationPosition)), pSourceData, size); +} + +template +void +Data::CopyTo(value_type* pDestination, size_type position, size_type size) const +{ + memcpy(pDestination,& __list[position], size); +} + +template +typename Data::iterator +Data::Erase(iterator position) +{ + return __list.erase(position); +} + +template +typename Data::iterator +Data::Erase(iterator firstIterator, iterator fastIterator) +{ + return __list.erase(firstIterator, fastIterator); +} + +template +void +Data::Swap(Data& data) +{ + __list.swap(data.__list); +} + +template +void +Data::Clear(void) +{ + __list.clear(); +} + +template +typename Data::allocator_type +Data::GetAllocator(void) const +{ + return __list.get_allocator(); +} + + + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_DATA_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemDataType.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemDataType.h new file mode 100644 index 0000000..eb6dcf9 --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemDataType.h @@ -0,0 +1,46 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemDataType.h + * @brief The define base data types + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_DATA_TYPE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_DATA_TYPE_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + typedef char int8; + typedef unsigned char uint8; + + typedef short int16; + typedef unsigned short uint16; + + typedef int int32; + typedef unsigned int uint32; + + typedef long long int64; + typedef unsigned long long uint64; + + typedef float float32; + typedef double float64; + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_DATA_TYPE_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemException.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemException.h new file mode 100644 index 0000000..1374ee7 --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemException.h @@ -0,0 +1,51 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemException.h + * @brief Exceptions + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_EXCEPTION_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_EXCEPTION_H_ + +#include +#include +#include + +#define SETJMP setjmp(::Tizen::Ui::Effects::_Renderer::System::jumpBuffer) +#define JMP(exceptionCode) longjmp(::Tizen::Ui::Effects::_Renderer::System::jumpBuffer, exceptionCode) + +#define _TryJmp(condition, exceptionCode, exceptionMessage) \ + if (!condition) \ + { \ + SysLogException(NID_UI_EFFECT, exceptionCode, exceptionMessage); \ + JMP(exceptionCode); \ + } + +#define ThrowJmp(exceptionMessage) _TryJmp(false, E_SYSTEM, exceptionMessage) + + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + + extern jmp_buf jumpBuffer; + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_EXCEPTION_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemNonCopyable.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemNonCopyable.h new file mode 100644 index 0000000..d41aaeb --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemNonCopyable.h @@ -0,0 +1,46 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemNonCopyable.h + * @brief The NonCopyable class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_NONCOPYABLE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_NONCOPYABLE_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +/** + * @brief An object to disable copy constructor and assignment operator + */ +class NonCopyable +{ +private: + NonCopyable(const NonCopyable& nonCopyable); + NonCopyable& operator = (const NonCopyable& nonCopyable); + +public: + NonCopyable(void) { } + virtual ~NonCopyable(void) { } +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_NONCOPYABLE_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemPlatformDefine.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemPlatformDefine.h new file mode 100644 index 0000000..9c8a6a4 --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemPlatformDefine.h @@ -0,0 +1,48 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemPlatformDefine.h + * @brief The platform's defines + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_PLATFORMDEFINE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_PLATFORMDEFINE_H_ + +#if defined(_WIN32) && !defined(__TIZEN__) +#define _EFFECTS_SYSTEM_WINDOWS_ 1 +#elif defined(__TIZEN__) +#define _EFFECTS_SYSTEM_TIZEN_ 1 +#elif defined(__ANDROID__) +#define _EFFECTS_SYSTEM_ANDROID_ 1 +#elif defined(__SLP__) +#define _EFFECTS_SYSTEM_SLP_ 1 +#elif defined(__LINUX__) +#define _EFFECTS_SYSTEM_LINUX_ 1 +#else +#define _EFFECTS_SYSTEM_TIZEN_ 1 +#endif + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + + const char* GetPlatformName(void); + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_PLATFORMDEFINE_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSelectType.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSelectType.h new file mode 100644 index 0000000..ec77e1d --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSelectType.h @@ -0,0 +1,49 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemSelectType.h + * @brief The SelectType template + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SELECTTYPE_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SELECTTYPE_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +/** +* @brief SelectType template +*/ +template +class SelectType +{ +public: + typedef TypeTrue Result; +}; + +template +class SelectType +{ +public: + typedef TypeFalse Result; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SELECTTYPE_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtr.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtr.h new file mode 100644 index 0000000..6a324fa --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtr.h @@ -0,0 +1,654 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemSmartPtr.h + * @brief The SmartPtr template + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +template +< + typename ValueType, + template class OwnershipPolicy = SmartPtrRefCountedMtPolicy, + template class CheckingPolicy = SmartPtrAssertCheckPolicy, + template class StoragePolicy = SmartPtrDefaultStoragePolicy, + template class ConstnessPolicy = ConstnessPolicyDontConst +> +class SmartPtr; + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +class SmartPtr : + public CheckingPolicy::StoredType>, + public StoragePolicy, + public OwnershipPolicy::InitPointerType> +{ +public: + typedef OwnershipPolicy::InitPointerType> OwnershipPolicyType; + typedef CheckingPolicy::StoredType> CheckingPolicyType; + typedef StoragePolicy StoragePolicyType; + typedef ConstnessPolicy ConstnessPolicyType; + + typedef typename StoragePolicyType::PointerType PointerType; + typedef typename StoragePolicyType::StoredType StoredType; + typedef typename StoragePolicyType::ReferenceType ReferenceType; + + typedef typename ConstnessPolicyType::Type* ConstPointerType; + typedef typename ConstnessPolicyType::Type& ConstReferenceType; + + SmartPtr(void); + + /// constructor by an objects pointer + /// \param value an objects pointer + explicit SmartPtr(ValueType* pValue); + + /// constructor by a SmartPtr + /// \param aSmartPtr an another SmartPtr + SmartPtr(const SmartPtr& smartPtr); + + /// constructor by an another type of SmartPtr + /// \param aSmartPtr an another SmartPtr + template + < + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 + > + SmartPtr(const SmartPtr& smartPtr); + + SmartPtr& operator = (const SmartPtr& smartPtr); + + template + < + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 + > + SmartPtr& operator = (const SmartPtr& smartPtr); + + virtual ~SmartPtr(void); + + void Swap(SmartPtr& smartPtr); + + PointerType operator -> (void); + + ConstPointerType operator -> (void) const; + + ReferenceType operator * (void); + + ConstReferenceType operator * (void) const; + + operator bool(void) const; + + bool operator ! (void) const; + + template + < + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 + > + bool operator == (const SmartPtr& smartPtr) const; + + template + < + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 + > + bool operator != (const SmartPtr& smartPtr) const; + + template + < + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 + > + bool operator < (const SmartPtr& smartPtr) const; + + template + < + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 + > + bool operator > (const SmartPtr& smartPtr) const; + + template + < + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 + > + bool operator <= (const SmartPtr& smartPtr) const; + + template + < + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 + > + bool operator >= (const SmartPtr& smartPtr) const; + + template + SmartPtr staticCast(void) const; + + template + < + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 + > + friend void Reset(SmartPtr& smartPtr); + + template + < + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 + > + friend class SmartPtr; + + template + < + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 + > + friend class WeakPtr; + +private: + SmartPtr(const CheckingPolicyType& checkingPolicyType, const StoragePolicyType& storagePolicyType, const OwnershipPolicyType& ownershipPolicyType); + +}; + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +void Reset(SmartPtr& smartPtr); + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +SmartPtr::SmartPtr(void) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + CheckingPolicyType::OnDefault(GetImpl(*this)); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +SmartPtr::SmartPtr(ValueType* pValue) : + StoragePolicyType(pValue) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + CheckingPolicyType::OnInit(GetImpl(*this)); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +SmartPtr::SmartPtr(const SmartPtr& smartPtr) : + CheckingPolicyType(smartPtr), + StoragePolicyType(smartPtr), + OwnershipPolicyType(smartPtr) +{ + GetImplRef(*this) = OwnershipPolicyType::Clone(GetImplRef(smartPtr)); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +template +< + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 +> +SmartPtr::SmartPtr( + const SmartPtr& smartPtr) : + CheckingPolicyType(smartPtr), + StoragePolicyType(smartPtr), + OwnershipPolicyType(smartPtr) +{ + GetImplRef(*this) = OwnershipPolicyType::Clone(GetImplRef(smartPtr)); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +SmartPtr& + SmartPtr::operator = (const SmartPtr& smartPtr) +{ + if (this != &smartPtr) + { + SmartPtr temp(smartPtr); + temp.Swap(*this); + } + return *this; +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +template +< + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 +> +SmartPtr& SmartPtr::operator = + (const SmartPtr& smartPtr) +{ + SmartPtr temp(smartPtr); + temp.Swap(*this); + return *this; +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +SmartPtr::~SmartPtr(void) +{ + if (OwnershipPolicyType::Release(GetImpl(*static_cast(this)))) + { + StoragePolicyType::Destroy(); + } +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +void SmartPtr::Swap(SmartPtr& smartPtr) +{ + CheckingPolicyType::Swap(smartPtr); + OwnershipPolicyType::Swap(smartPtr); + StoragePolicyType::Swap(smartPtr); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +typename SmartPtr::PointerType + SmartPtr::operator -> (void) +{ + CheckingPolicyType::OnDereference(GetImplRef(*this)); + return StoragePolicyType::operator->(); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +typename SmartPtr::ConstPointerType + SmartPtr::operator -> (void) const +{ + CheckingPolicyType::OnDereference(GetImplRef(*this)); + return StoragePolicyType::operator->(); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +typename SmartPtr::ReferenceType + SmartPtr::operator * (void) +{ + CheckingPolicyType::OnDereference(GetImplRef(*this)); + return StoragePolicyType::operator*(); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +typename SmartPtr::ConstReferenceType + SmartPtr::operator * (void) const +{ + CheckingPolicyType::OnDereference(GetImplRef(*this)); + return StoragePolicyType::operator*(); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +SmartPtr::operator bool(void) const +{ + if (GetImpl(*this) != null) + { + return true; + } + return false; +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +bool SmartPtr::operator ! (void) const +{ + return GetImpl(*this) == null; +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +template +< + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 +> +bool SmartPtr::operator == + (const SmartPtr& smartPtr) const +{ + return GetImpl(*this) == GetImpl(smartPtr); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +template +< + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 +> +bool SmartPtr::operator != + (const SmartPtr& smartPtr) const +{ + return GetImpl(*this) != GetImpl(smartPtr); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +template +< + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 +> +bool SmartPtr::operator < + (const SmartPtr& smartPtr) const +{ + return GetImpl(*this) < GetImpl(smartPtr); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +template +< + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 +> +bool SmartPtr::operator > + (const SmartPtr& smartPtr) const +{ + return GetImpl(*this) > GetImpl(smartPtr); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +template +< + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 +> +bool SmartPtr::operator <= + (const SmartPtr& smartPtr) const +{ + return GetImpl(*this) <= GetImpl(smartPtr); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +template +< + typename ValueType2, + template class OwnershipPolicy2, + template class CheckingPolicy2, + template class StoragePolicy2, + template class ConstnessPolicy2 +> +bool SmartPtr::operator >= + (const SmartPtr& smartPtr) const +{ + return GetImpl(*this) >= GetImpl(smartPtr); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +template +SmartPtr + SmartPtr::staticCast(void) const +{ + SmartPtr result(*this, *this, *this); + GetImplRef(result) = static_cast(GetImpl(*this)); + return result; +} + + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +SmartPtr:: + SmartPtr(const CheckingPolicyType& checkingPolicyType, const StoragePolicyType& storagePolicyType, const OwnershipPolicyType& ownershipPolicyType) : + CheckingPolicyType(checkingPolicyType), + StoragePolicyType(storagePolicyType), + OwnershipPolicyType(ownershipPolicyType) +{ + GetImplRef(*this) = OwnershipPolicyType::Clone(GetImplRef(storagePolicyType)); +} + +template +< + typename ValueType, + template class OwnershipPolicy, + template class CheckingPolicy, + template class StoragePolicy, + template class ConstnessPolicy +> +void Reset(SmartPtr& smartPtr) +{ + SmartPtr temp; + temp.Swap(smartPtr); +} + +// Common types definitions +typedef SmartPtr FloatPtr; + +}}}}} //Tizen::Ui::Effects::_Renderer::System + + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrAssertCheckPolicy.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrAssertCheckPolicy.h new file mode 100644 index 0000000..bf53f8e --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrAssertCheckPolicy.h @@ -0,0 +1,100 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemSmartPtrAssertCheckPolicy.h + * @brief The SmartPtrAssertCheckPolicy template + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_ASSERT_CHECK_POLICY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_ASSERT_CHECK_POLICY_H_ + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ +/** + * \brief SmartPtrAssertCheckPolicy + */ +template +class SmartPtrAssertCheckPolicy +{ +public: + SmartPtrAssertCheckPolicy(void); + + template + SmartPtrAssertCheckPolicy(const SmartPtrAssertCheckPolicy& smartPtrAssertCheckPolicy); + + template + SmartPtrAssertCheckPolicy(const SmartPtrNoCheckPolicy& smartPtrNoCheckPolicy); + + static inline void OnDefault(const ValueType& value); + static inline void OnInit(const ValueType& value); + static inline void OnDereference(const ValueType value); + static inline void Swap(SmartPtrAssertCheckPolicy& smartPtrAssertCheckPolicy); +}; + +template +SmartPtrAssertCheckPolicy::SmartPtrAssertCheckPolicy(void) +{ + +} + +template +template +SmartPtrAssertCheckPolicy::SmartPtrAssertCheckPolicy(const SmartPtrAssertCheckPolicy& smartPtrAssertCheckPolicy) +{ + +} + +template +template +SmartPtrAssertCheckPolicy::SmartPtrAssertCheckPolicy(const SmartPtrNoCheckPolicy& smartPtrNoCheckPolicy) +{ + +} + +template +void SmartPtrAssertCheckPolicy::OnDefault(const ValueType& value) +{ + +} + +template +void SmartPtrAssertCheckPolicy::OnInit(const ValueType& value) +{ + +} + +template +void SmartPtrAssertCheckPolicy::OnDereference(const ValueType value) +{ + assert(value); +} + +template +void SmartPtrAssertCheckPolicy::Swap(SmartPtrAssertCheckPolicy& smartPtrAssertCheckPolicy) +{ + +} + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_ASSERT_CHECK_POLICY_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrDefaultStoragePolicy.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrDefaultStoragePolicy.h new file mode 100644 index 0000000..8a5212d --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrDefaultStoragePolicy.h @@ -0,0 +1,172 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemSmartPtrDefaultStoragePolicy.h + * @brief The SmartPtrDefaultStoragePolicy template + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_DEFAULT_STORAGE_POLICY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_DEFAULT_STORAGE_POLICY_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +/** + * @brief SmartPtrDefaultStoragePolicy + */ +template +class SmartPtrDefaultStoragePolicy +{ +public: + typedef ValueType* StoredType; + typedef ValueType* InitPointerType; + typedef ValueType* PointerType; + typedef ValueType& ReferenceType; + + inline SmartPtrDefaultStoragePolicy(void); + inline SmartPtrDefaultStoragePolicy(const SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy); + inline SmartPtrDefaultStoragePolicy(const StoredType& pObject); + + template + inline SmartPtrDefaultStoragePolicy(const SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy); + + PointerType operator->(void) const; + ReferenceType operator*(void) const; + SmartPtrDefaultStoragePolicy& operator=(const SmartPtrDefaultStoragePolicy& rhs); + + void Swap(SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy); + + template + friend typename SmartPtrDefaultStoragePolicy::PointerType GetImpl(const SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy); + + template + friend typename SmartPtrDefaultStoragePolicy::StoredType& GetImplRef(SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy); + + template + friend const typename SmartPtrDefaultStoragePolicy::StoredType& GetImplRef(const SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy); + +protected: + void Destroy(void); + +private: + StoredType __pObject; +}; + +template +inline typename SmartPtrDefaultStoragePolicy::PointerType GetImpl(const SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy); + +template +inline typename SmartPtrDefaultStoragePolicy::StoredType& GetImplRef(SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy); + +template +inline const typename SmartPtrDefaultStoragePolicy::StoredType& GetImplRef(const SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy); + +template +SmartPtrDefaultStoragePolicy::SmartPtrDefaultStoragePolicy(void) : + __pObject(null) +{ + +} + +// OwnershipPolicy must init objectPtr +template +SmartPtrDefaultStoragePolicy::SmartPtrDefaultStoragePolicy(const SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy) : + __pObject(null) +{ + +} + +template +SmartPtrDefaultStoragePolicy::SmartPtrDefaultStoragePolicy(const StoredType& pObject) : + __pObject(pObject) +{ + +} + +// OwnershipPolicy must init objectPtr +template +template +SmartPtrDefaultStoragePolicy::SmartPtrDefaultStoragePolicy(const SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy) : + __pObject(null) +{ + +} + +template +typename SmartPtrDefaultStoragePolicy::PointerType SmartPtrDefaultStoragePolicy::operator->(void) const +{ + return __pObject; +} + +template +typename SmartPtrDefaultStoragePolicy::ReferenceType SmartPtrDefaultStoragePolicy::operator*(void) const +{ + return *__pObject; +} + +template +SmartPtrDefaultStoragePolicy& SmartPtrDefaultStoragePolicy::operator=(const SmartPtrDefaultStoragePolicy& rhs) +{ + if (this != &rhs) + { + SmartPtrDefaultStoragePolicy temp(rhs); + temp.Swap(*this); + } + return *this; +} + +template +void SmartPtrDefaultStoragePolicy::Swap(SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy) +{ + std::swap(__pObject, smartPtrDefaultStoragePolicy.__pObject); +} + +template +void SmartPtrDefaultStoragePolicy::Destroy(void) +{ + if (__pObject != null) + { + delete __pObject; + } + __pObject = null; +} + +template +typename SmartPtrDefaultStoragePolicy::PointerType GetImpl(const SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy) +{ + return smartPtrDefaultStoragePolicy.__pObject; +} + +template +typename SmartPtrDefaultStoragePolicy::StoredType& GetImplRef(SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy) +{ + return smartPtrDefaultStoragePolicy.__pObject; +} + +template +const typename SmartPtrDefaultStoragePolicy::StoredType& GetImplRef(const SmartPtrDefaultStoragePolicy& smartPtrDefaultStoragePolicy) +{ + return smartPtrDefaultStoragePolicy.__pObject; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_DEFAULT_STORAGE_POLICY_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrNoCheckPolicy.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrNoCheckPolicy.h new file mode 100644 index 0000000..10efcac --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrNoCheckPolicy.h @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemSmartPtrNoCheckPolicy.h + * @brief The SmartPtrNoCheckPolicy template + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_NO_CHECK_POLICY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_NO_CHECK_POLICY_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +/** + * @brief SmartPtrNoCheckPolicy + */ +template +class SmartPtrNoCheckPolicy +{ +public: + SmartPtrNoCheckPolicy(void); + + template + SmartPtrNoCheckPolicy(const SmartPtrNoCheckPolicy& smartPtrNoCheckPolicy); + + static inline void OnDefault(const ValueType& value); + static inline void OnInit(const ValueType& value); + static inline void OnDereference(const ValueType& value); + static inline void Swap(SmartPtrNoCheckPolicy& smartPtrNoCheckPolicy); +}; + +template +SmartPtrNoCheckPolicy::SmartPtrNoCheckPolicy(void) +{ + +} + +template +template +SmartPtrNoCheckPolicy::SmartPtrNoCheckPolicy(const SmartPtrNoCheckPolicy& smartPtrNoCheckPolicy) +{ + +} + +template +void SmartPtrNoCheckPolicy::OnDefault(const ValueType& value) +{ + +} + +template +void SmartPtrNoCheckPolicy::OnInit(const ValueType& value) +{ + +} + +template +void SmartPtrNoCheckPolicy::OnDereference(const ValueType& value) +{ + +} + +template +void SmartPtrNoCheckPolicy::Swap(SmartPtrNoCheckPolicy& smartPtrNoCheckPolicy) +{ + +} + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_NO_CHECK_POLICY_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrRefCountedMTPolicy.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrRefCountedMTPolicy.h new file mode 100644 index 0000000..0f6821d --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrRefCountedMTPolicy.h @@ -0,0 +1,178 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemSmartPtrRefCountedMTPolicy.h + * @brief The SmartPtrRefCountedMTPolicy template + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_REF_COUNTED_MTPOLICY_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_REF_COUNTED_MTPOLICY_H_ + +#include + +#include +#include +#include + +#ifdef _EFFECTS_SYSTEM_WINDOWS_ +#include +#else +#include +#endif + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +/** + * \brief SmartPtrRefCountedMTPolicy + */ +template +class SmartPtrRefCountedMtPolicy +{ +public: + +#ifdef _EFFECTS_SYSTEM_WINDOWS_ + typedef SmartPtrRefCounterHandlerInterlocked RefCounterHandlerType; +#else + typedef SmartPtrRefCounterHandlerAtomic RefCounterHandlerType; +#endif + + typedef RefCounterHandlerType::CounterData CounterData; + typedef RefCounterHandlerType::CounterType CounterType; + + inline SmartPtrRefCountedMtPolicy(void); + inline SmartPtrRefCountedMtPolicy(const SmartPtrRefCountedMtPolicy& smartPtrRefCountedMTPolicy); + + template + inline SmartPtrRefCountedMtPolicy(const SmartPtrRefCountedMtPolicy& smartPtrRefCountedMTPolicy); + + inline ValueType Clone(const ValueType& value); + inline ValueType CloneWeak(const ValueType& value); + + inline bool Release(const ValueType& value); + inline bool ReleaseWeak(const ValueType& value); + + inline void Swap(SmartPtrRefCountedMtPolicy& smartPtrRefCountedMTPolicy); + + enum { destructiveCopy = false }; + + template friend class SmartPtrRefCountedMtPolicy; + + template + friend typename SmartPtrRefCountedMtPolicy::CounterType GetUseCount(const SmartPtrRefCountedMtPolicy& smartPtr); + +protected: + inline void DecreaseUseCount(void); + +private: + CounterData* __pCounterData; +}; + +template +typename SmartPtrRefCountedMtPolicy::CounterType GetUseCount(const SmartPtrRefCountedMtPolicy& smartPtrRefCountedMTPolicy); + +template +SmartPtrRefCountedMtPolicy::SmartPtrRefCountedMtPolicy(void) +{ + __pCounterData = RefCounterHandlerType::NewCounter(); + + _TryJmp(__pCounterData != null, E_OUT_OF_MEMORY, "SmartPtrRefCountedMTPolicy::counterData = null"); + + __pCounterData->useCount = 1; + __pCounterData->ownerCount = 1; +} + +template +SmartPtrRefCountedMtPolicy::SmartPtrRefCountedMtPolicy(const SmartPtrRefCountedMtPolicy& smartPtrRefCountedMTPolicy) +{ + __pCounterData = smartPtrRefCountedMTPolicy.__pCounterData; +} + +template +template +SmartPtrRefCountedMtPolicy::SmartPtrRefCountedMtPolicy(const SmartPtrRefCountedMtPolicy& smartPtrRefCountedMTPolicy) +{ + __pCounterData = smartPtrRefCountedMTPolicy.__pCounterData; +} + +template +ValueType SmartPtrRefCountedMtPolicy::Clone(const ValueType& value) +{ + RefCounterHandlerType::IncrementUse(__pCounterData); + RefCounterHandlerType::IncrementOwner(__pCounterData); + return value; +} + +template +ValueType SmartPtrRefCountedMtPolicy::CloneWeak(const ValueType& value) +{ + RefCounterHandlerType::IncrementOwner(__pCounterData); + return value; +} + +template +bool SmartPtrRefCountedMtPolicy::Release(const ValueType& value) +{ + CounterType currenUse = RefCounterHandlerType::DecrementUse(__pCounterData); + if (RefCounterHandlerType::DecrementOwner(__pCounterData) == 0) + { + RefCounterHandlerType::DeleteCounter(__pCounterData); + } + if (currenUse == 0) + { + return true; + } + return false; +} + +template +bool SmartPtrRefCountedMtPolicy::ReleaseWeak(const ValueType& value) +{ + if (RefCounterHandlerType::DecrementOwner(__pCounterData) == 0) + { + RefCounterHandlerType::DeleteCounter(__pCounterData); + return true; + } + return false; +} + +template +void SmartPtrRefCountedMtPolicy::Swap(SmartPtrRefCountedMtPolicy& smartPtrRefCountedMTPolicy) +{ + std::swap(__pCounterData, smartPtrRefCountedMTPolicy.__pCounterData); +} + +template +void SmartPtrRefCountedMtPolicy::DecreaseUseCount(void) +{ + RefCounterHandlerType::DecrementUse(__pCounterData); +} + +template +typename SmartPtrRefCountedMtPolicy::CounterType GetUseCount(const SmartPtrRefCountedMtPolicy& smartPtrRefCountedMTPolicy) +{ + return smartPtrRefCountedMTPolicy.counterData->useCount; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::System + + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_REF_COUNTED_MTPOLICY_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrRefCounter.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrRefCounter.h new file mode 100644 index 0000000..dad4aa6 --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrRefCounter.h @@ -0,0 +1,48 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemSmartPtrRefCounter.h + * @brief The SmartPtrRefCounter template + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_REFCOUNTER_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_REFCOUNTER_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +template +class SmartPtrRefCounter +{ +public: + typedef Counter CounterType; + + Counter useCount; + Counter ownerCount; + + SmartPtrRefCounter(void) + { + useCount = 0; + ownerCount = 0; + } +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_REFCOUNTER_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrRefCounterHandlerAtomic.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrRefCounterHandlerAtomic.h new file mode 100644 index 0000000..8589a18 --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemSmartPtrRefCounterHandlerAtomic.h @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemSmartPtrRefCounterHandlerAtomic.h + * @brief The SmartPtrRefCounterHandlerAtomic template + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_REFCOUNTER_HANDLER_ATOMIC_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_REFCOUNTER_HANDLER_ATOMIC_H_ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +class SmartPtrRefCounterHandlerAtomic +{ +public: + typedef long CounterType; + typedef SmartPtrRefCounter CounterData; + + static inline CounterData* NewCounter(void); + static inline void DeleteCounter(CounterData* pCounterData); + + static inline CounterType IncrementUse(CounterData* pCounterData); + static inline CounterType DecrementUse(CounterData* pCounterData); + + static inline CounterType IncrementOwner(CounterData* pCounterData); + static inline CounterType DecrementOwner(CounterData* pCounterData); + +}; + +inline SmartPtrRefCounterHandlerAtomic::CounterData* SmartPtrRefCounterHandlerAtomic::NewCounter(void) +{ + return new (std::nothrow) CounterData; +} + +inline void SmartPtrRefCounterHandlerAtomic::DeleteCounter(CounterData* pCounterData) +{ + if (pCounterData != null) + { + delete pCounterData; + } +} + +inline SmartPtrRefCounterHandlerAtomic::CounterType SmartPtrRefCounterHandlerAtomic::IncrementUse(CounterData* pCounterData) +{ + return ++(pCounterData->useCount); +} + +inline SmartPtrRefCounterHandlerAtomic::CounterType SmartPtrRefCounterHandlerAtomic::DecrementUse(CounterData* pCounterData) +{ + return --(pCounterData->useCount); +} + +inline SmartPtrRefCounterHandlerAtomic::CounterType SmartPtrRefCounterHandlerAtomic::IncrementOwner(CounterData* pCounterData) +{ + return ++(pCounterData->ownerCount); +} + +inline SmartPtrRefCounterHandlerAtomic::CounterType SmartPtrRefCounterHandlerAtomic::DecrementOwner(CounterData* pCounterData) +{ + return --(pCounterData->ownerCount); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_SMARTPTR_REFCOUNTER_HANDLER_ATOMIC_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemStaticAssert.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemStaticAssert.h new file mode 100644 index 0000000..37fffb8 --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemStaticAssert.h @@ -0,0 +1,45 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemStaticAssert.h + * @brief The StaticAssert template + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_STATIC_ASSERT_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_STATIC_ASSERT_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +template +struct EffectsStaticAssertChecker; + +template<> +struct EffectsStaticAssertChecker +{ + +}; + +}} //Tizen::Ui::Effects::_Renderer::System + +#define EffectsStaticAssert(Condition) (Tizen::Ui::Effects::_Renderer::System::EffectsStaticAssertChecker<(Condition) != false>()) + +}}} //Tizen::Ui::Effects + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_STATIC_ASSERT_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemTypeNull.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemTypeNull.h new file mode 100644 index 0000000..615e618 --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemTypeNull.h @@ -0,0 +1,36 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemTypeNull.h + * @brief The TypeNull template + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_TYPE_NULL_H_ +#define _FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_TYPE_NULL_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +class TypeNull +{ +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::System + +#endif //_FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_TYPE_NULL_H_ diff --git a/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemTypeTraits.h b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemTypeTraits.h new file mode 100644 index 0000000..6d6b618 --- /dev/null +++ b/src/ui/effects/inc/renderer/system/FUiEffects_RendererSystemTypeTraits.h @@ -0,0 +1,184 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemTypeTraits.h + * @brief The TypeTraits template + * + */ + +#ifndef FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_TYPE_TRAITS_H_ +#define FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_TYPE_TRAITS_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace System +{ + +template +class IsStdSignedInts +{ + public: + enum { VALUE = 0 }; +}; + +template +class IsStdUnsignedInts +{ + public: + enum { VALUE = 0 }; +}; + +template +class IsStdOtherInts +{ + public: + enum { VALUE = 0 }; +}; + +template +class IsStdFloats +{ + public: + enum { VALUE = 0 }; +}; + +template +class TypeTraits +{ + public: + enum {isStdSignedInt = IsStdSignedInts::VALUE }; + enum {isStdUnsignedInt = IsStdUnsignedInts::VALUE }; + enum {isStdOtherInt = IsStdOtherInts::VALUE }; + enum {isStdFloat = IsStdFloats::VALUE }; + + enum {isStdIntegral = isStdSignedInt || isStdUnsignedInt || isStdOtherInt }; + + enum {isStdArith = isStdIntegral || isStdFloat }; + + enum {isStdFundamental = isStdIntegral || isStdFloat }; + + enum {isFundamental = isStdFundamental }; +}; + +template <> +class IsStdSignedInts +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdSignedInts +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdSignedInts +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdSignedInts +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdSignedInts +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdUnsignedInts +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdUnsignedInts +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdUnsignedInts +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdUnsignedInts +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdUnsignedInts +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdOtherInts +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdOtherInts +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdFloats +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdFloats +{ + public: + enum { VALUE = 1 }; +}; + +template <> +class IsStdFloats +{ + public: + enum { VALUE = 1 }; +}; + +}}}}} //Tizen::Ui::Effects::_Renderer::System + + +#endif // FUI_EFFECTS_INTERNAL_RENDERER_SYSTEM_TYPE_TRAITS_H_ diff --git a/src/ui/effects/inc/utils/FUiEffects_Utils.h b/src/ui/effects/inc/utils/FUiEffects_Utils.h new file mode 100644 index 0000000..ddd3ef6 --- /dev/null +++ b/src/ui/effects/inc/utils/FUiEffects_Utils.h @@ -0,0 +1,36 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_Utils.h + * @brief This is the header file for the Tizen::Ui::Effects::_utils namespace + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_UTILS_H_ +#define _FUI_EFFECTS_INTERNAL_UTILS_H_ + + +#include "FUiEffects_UtilsVector2.h" +#include "FUiEffects_UtilsVector3.h" +#include "FUiEffects_UtilsVector4.h" + +#include "FUiEffects_UtilsMatrix2.h" +#include "FUiEffects_UtilsMatrix3.h" +#include "FUiEffects_UtilsMatrix4.h" + +#endif // _FUI_EFFECTS_INTERNAL_UTILS_H_ diff --git a/src/ui/effects/inc/utils/FUiEffects_UtilsAdapterFunctions.h b/src/ui/effects/inc/utils/FUiEffects_UtilsAdapterFunctions.h new file mode 100644 index 0000000..dae48cf --- /dev/null +++ b/src/ui/effects/inc/utils/FUiEffects_UtilsAdapterFunctions.h @@ -0,0 +1,261 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_UtilsAdapterFunctions.h + * @brief The adapter math functions for user types + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_UTILS_ADAPTER_FUNCTIONS_H_ +#define _FUI_EFFECTS_INTERNAL_UTILS_ADAPTER_FUNCTIONS_H_ + +#include +#include "FUiEffects_UtilsCommon.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Utils +{ + inline float effects_sqrt(float aValue); + inline double effects_sqrt(double aValue); + + inline float effects_cos(float aAngle); + inline double effects_cos(double aAngle); + inline float effects_acos(float aAngle); + inline double effects_acos(double aAngle); + + inline float effects_sin(float aAngle); + inline double effects_sin(double aAngle); + inline float effects_asin(float aAngle); + inline double effects_asin(double aAngle); + + template inline T EffectsAbs(const T& aValue); + inline float EffectsAbs(const float& aValue); + inline double EffectsAbs(const double& aValue); + + inline float effects_atan2(float x, float y); + inline double effects_atan2(double x, double y); + + inline float effects_atan(float val); + inline double effects_atan(double val); + + template struct effects_epsilon + { + static inline const T& epsilon() {return get_epsilon(static_cast(0));} + }; + template<> struct effects_epsilon + { + static inline const float& epsilon() {return fEPS;} + }; + template<> struct effects_epsilon + { + static inline const double& epsilon() {return dEPS;} + }; + + inline bool EffectsEqual(const float& aLhv, const float& aRhv, const float& aEpsilon = fEPS); + inline bool EffectsEqual(const double& aLhv, const double& aRhv, const double& aEpsilon = dEPS); + + template inline void EffectsSwap(T& aLhv, T& aRhv); + inline void EffectsSwap(float& aLhv, float& aRhv); + inline void EffectsSwap(double& aLhv, double& aRhv); + + template inline T effects_clamp(const T& aValue, const T& aMin, const T& aMax); + inline float effects_clamp(const float& aValue, const float& aMin, const float& aMax); + inline double effects_clamp(const double& aValue, const double& aMin, const double& aMax); + + template inline T effects_lerp(const T& aFrom, const T& aTo, const T& aCoeff); + inline float effects_lerp(const float& aFrom, const float& aTo, const float& aCoeff); + inline double effects_lerp(const double& aFrom, const double& aTo, const double& aCoeff); + inline int effects_lerp(const int& aFrom, const int& aTo, const int& aCoeff); + inline unsigned int effects_lerp(const unsigned int& aFrom, const unsigned int& aTo, const unsigned int& aCoeff); + + template inline T EffectsMin(const T& a1, const T& a2); + template inline T EffectsMin3(const T& a1, const T& a2, const T& a3); + template inline T EffectsMax(const T& a1, const T& a2); + template inline T EffectsMax3(const T& a1, const T& a2, const T& a3); + + inline float effects_sqrt(float aValue) + { + return sqrtf(aValue); + } + inline double effects_sqrt(double aValue) + { + return sqrt(aValue); + } + + template inline bool EffectsEqual(const T& aLhv, const T& aRhv, const T& aEpsilon = effects_epsilon::epsilon()) + { + return aLhv == aRhv; + } + inline bool EffectsEqual(const float& aLhv, const float& aRhv, const float& aEpsilon) + { + return (aLhv + aEpsilon >= aRhv) && (aLhv - aEpsilon <= aRhv); + } + inline bool EffectsEqual(const double& aLhv, const double& aRhv, const double& aEpsilon) + { + return (aLhv + aEpsilon >= aRhv) && (aLhv - aEpsilon <= aRhv); + } + + inline float effects_cos(float aAngle) + { + return cosf(aAngle); + } + inline double effects_cos(double aAngle) + { + return cos(aAngle); + } + inline float effects_acos(float aAngle) + { + return acosf(aAngle); + } + inline double effects_acos(double aAngle) + { + return acos(aAngle); + } + + inline float effects_sin(float aAngle) + { + return sinf(aAngle); + } + inline double effects_sin(double aAngle) + { + return sin(aAngle); + } + + inline float effects_asin(float aAngle) + { + return asinf(aAngle); + } + inline double effects_asin(double aAngle) + { + return asin(aAngle); + } + + template inline T EffectsAbs(const T& aValue) + { + return abs(aValue); + } + inline float EffectsAbs(float aValue) + { + return fabsf(aValue); + } + inline double EffectsAbs(double aValue) + { + return fabs(aValue); + } + + inline float effects_atan2(float x, float y) + { + return atan2f(x, y); + } + inline double effects_atan2(double x, double y) + { + return atan2(x, y); + } + + inline float effects_atan(float val) + { + return atanf(val); + } + inline double effects_atan(double val) + { + return atan(val); + } + + template inline void EffectsSwap(T& aLhv, T& aRhv) + { + T temp(aLhv); + aLhv = aRhv; + aRhv = temp; + } + inline void EffectsSwap(float& aLhv, float& aRhv) + { + std::swap(aLhv, aRhv); + } + inline void EffectsSwap(double& aLhv, double& aRhv) + { + std::swap(aLhv, aRhv); + } + + template inline T effects_clamp(const T& aValue, const T& aMin, const T& aMax) + { + if(aValue < aMin) + return aMin; + if(aValue > aMax) + return aMax; + return aValue; + } + inline float effects_clamp(const float& aValue, const float& aMin, const float& aMax) + { + if(aValue < aMin) + return aMin; + if(aValue > aMax) + return aMax; + return aValue; + } + inline double effects_clamp(const double& aValue, const double& aMin, const double& aMax) + { + if(aValue < aMin) + return aMin; + if(aValue > aMax) + return aMax; + return aValue; + } + + template inline T effects_lerp(const T& aFrom, const T& aTo, const T& aCoeff) + { + return aFrom + (aTo - aFrom) * aCoeff; + } + inline float effects_lerp(const float& aFrom, const float& aTo, const float& aCoeff) + { + return aFrom + (aTo - aFrom) * aCoeff; + } + inline double effects_lerp(const double& aFrom, const double& aTo, const double& aCoeff) + { + return aFrom + (aTo - aFrom) * aCoeff; + } + inline int effects_lerp(const int& aFrom, const int& aTo, const int& aCoeff) + { + return aFrom + (((aTo - aFrom) * aCoeff) >> 8); + } + inline unsigned int effects_lerp(const unsigned int& aFrom, const unsigned int& aTo, const unsigned int& aCoeff) + { + return aFrom + (((aTo - aFrom) * aCoeff) >> 8); + } + + template inline T EffectsMin(const T& a1, const T& a2) + { + if(a1 < a2) + return a1; + return a2; + } + template inline T EffectsMin3(const T& a1, const T& a2, const T& a3) + { + return EffectsMin(EffectsMin(a1, a2), a3); + } + template inline T EffectsMax(const T& a1, const T& a2) + { + if(a1 < a2) + return a2; + return a1; + } + template inline T EffectsMax3(const T& a1, const T& a2, const T& a3) + { + return EffectsMax(EffectsMax(a1, a2), a3); + } +} } } } //Tizen::Ui::Effects::_Utils + +#endif //_FUI_EFFECTS_INTERNAL_UTILS_ADAPTER_FUNCTIONS_H_ diff --git a/src/ui/effects/inc/utils/FUiEffects_UtilsCommon.h b/src/ui/effects/inc/utils/FUiEffects_UtilsCommon.h new file mode 100644 index 0000000..6ff9d37 --- /dev/null +++ b/src/ui/effects/inc/utils/FUiEffects_UtilsCommon.h @@ -0,0 +1,58 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_UtilsCommon.h + * @brief The common math functions and constants + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_UTILS_COMMON_H_ +#define _FUI_EFFECTS_INTERNAL_UTILS_COMMON_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Utils +{ + const float fEPS = std::numeric_limits::epsilon(); + const double dEPS = std::numeric_limits::epsilon(); + + const double dPI_2 = 6.283185307179586232; + const double dPI = dPI_2 * 0.5; + const float fPI_2 = float(dPI_2); + const float fPI = float(dPI); + + const double dDEG2RADCoeff = dPI / 180.0; + const double dRAD2DEGCoeff = 180.0 / dPI; + const float fDEG2RADCoeff = float(dDEG2RADCoeff); + const float fRAD2DEGCoeff = float(dRAD2DEGCoeff); + + inline double dDEG2RAD(double aDEG) {return aDEG * dDEG2RADCoeff;} + inline float fDEG2RAD(float aDEG) {return aDEG * fDEG2RADCoeff;} + inline double dRAD2DEG(double aRAD) {return aRAD * dRAD2DEGCoeff;} + inline float fRAD2DEG(float aRAD) {return aRAD * fRAD2DEGCoeff;} + + enum RotationOrder3 {ROTATION_XYZ = 0, ROTATION_XZY, ROTATION_YXZ, ROTATION_YZX, ROTATION_ZXY, ROTATION_ZYX, ROTATION3_MAX}; + + template inline bool isPowerOf2(T aValue) //only for positive integes + { + return (aValue & (aValue - T(1))) == T(0); + } +} } } } //Tizen::Ui::Effects::_Utils + +#endif //_FUI_EFFECTS_INTERNAL_UTILS_COMMON_H_ diff --git a/src/ui/effects/inc/utils/FUiEffects_UtilsLuaMat4.h b/src/ui/effects/inc/utils/FUiEffects_UtilsLuaMat4.h new file mode 100644 index 0000000..ed7a617 --- /dev/null +++ b/src/ui/effects/inc/utils/FUiEffects_UtilsLuaMat4.h @@ -0,0 +1,603 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_UtilsLuaMat4.h + * @brief This file contains a definition of LuaMat4 class template + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_UTILS_LUA_MAT4_H_ +#define _FUI_EFFECTS_INTERNAL_UTILS_LUA_MAT4_H_ + +namespace Tizen { namespace Ui { namespace Effects { namespace _Utils +{ + +template class Matrix4; + +/** + * @template class LuaMat4 + * @brief This class is needed for model matrix manipulations + * from scripts such as rotation, scale, translate and set identity matrix + */ + +template +class LuaMat4 +{ +public: + /** + * @brief LuaMat4 class default constructor + */ + inline LuaMat4(void); + + /** + * @brief LuaMat4 class copy constructor + */ + inline LuaMat4(const LuaMat4& rhs); + + /** + * @brief LuaMat4 class constructor by elements + */ + inline LuaMat4(T m0, T m1, T m2, T m3, + T m4, T m5, T m6, T m7, + T m8, T m9, T m10, T m11, + T m12, T m13, T m14, T m15); + + /** + * @brief LuaMat4 class constructor by one element + */ + inline LuaMat4(T m); + + /** + * @brief LuaMat4 class adaptive constructor from class Matrix4 + */ + inline LuaMat4(const Matrix4 &mat4); + + /** + * @brief Sets identity matrix + */ + inline void SetIdentity(void); + + /** + * @brief Translates model matrix by values X0, Y0 and Z0 relative to the axes + */ + inline void Translate(T x0, T y0, T z0); + + /** + * @brief Scales model matrix by the factors ax, ay, az relative to the axes + * @remark The coordinates of point (0,0,0) do not change + */ + inline bool Scale(T ax, T ay, T az); + + /** + * @brief Scales model matrix by the factors ax, ay, az relative to the axes + * @remark The coordinates of point (x0, y0, z0) do not change + */ + inline bool Scale(T ax, T ay, T az, T x0, T y0, T z0); + + /** + * @brief Rotates model matrix by the Angle around axis Z + * drawn from the point (0,0,0) in global coordinates + */ + inline void RotateAroundAxisZ(T angle); + + /** + * @brief Rotates model matrix by the Angle around axis Z + * drawn from the point (x0, y0, z0) in global coordinates + */ + inline void RotateAroundAxisZ(T angle, T x0, T y0, T z0); + + /** + * @brief Rotates model matrix by the Angle around axis X + * drawn from the point (0, 0, 0) in global coordinates + */ + inline void RotateAroundAxisX(T angle); + + /** + * @brief Rotates model matrix by the Angle around axis X + * drawn from the point (x0, y0, z0) in global coordinates + */ + inline void RotateAroundAxisX(T angle, T x0, T y0, T z0); + + /** + * @brief Rotates model matrix by the Angle around axis Y + * drawn from the point (0, 0, 0) in global coordinates + */ + inline void RotateAroundAxisY(T angle); + + /** + * @brief Rotates model matrix by the Angle around axis Y + * drawn from the point (x0,y0,z0) in global coordinates + */ + inline void RotateAroundAxisY(T angle, T x0, T y0, T z0); + + /** + * @brief Rotates model matrix by the Angle around axis with coordinates Ax, Ay, Az + * drawn from the point (0,0,0) in global coordinates + */ + inline bool RotateAroundAxisArbitrary(T angle, T ax, T ay, T az); + + /** + * @brief Rotates model matrix by the Angle around axis with coordinates Ax, Ay, Az + * drawn from the point (x0, y0, z0) in global coordinates + */ + inline bool RotateAroundAxisArbitrary(T angle, T ax, T ay, T az, T x0, T y0, T z0); + + /** + * @brief Overloading multiplication operator of two matrix as class LuaMat4 instances + */ + inline LuaMat4 operator*(const LuaMat4 &mul) const; + + /** + * @brief Overloading multiplication operator of matrix and number + */ + inline LuaMat4 operator*(T mul) const; + + /** + * @brief Overloading addition operator of two matrix + */ + inline LuaMat4 operator+(const LuaMat4 &add) const; + + /** + * @brief Overloading subtraction operator of two matrix + */ + inline LuaMat4 operator-(const LuaMat4 &sub) const; + + /** + * @brief Overloading the unary minus operator + */ + inline LuaMat4 operator-(void)const; + + /** + * @brief Overloading the assignment operator + */ + inline LuaMat4 &operator=(const LuaMat4 &orig); + + /** + * @brief Casts LuaMat4 class instance to type Matrix4 + */ + inline operator Matrix4(void)const; + +protected: + +private: + + +public: + +protected: + +private: + + T __m[16]; /**< the matrix 4*4 as one dimensional array of type T */ + +}; // LuaMat4 + +typedef LuaMat4 LuaMatrix4; + +} } } } // Tizen::Ui::Effects::_Utils + + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Utils +{ + + +template inline +LuaMat4::LuaMat4(void) +{ + SetIdentity(); +} + +template inline +LuaMat4::LuaMat4(T m) +{ + for (int i = 0; i < 16; ++i) + { + __m[i] = m; + } +} + +template inline +LuaMat4::LuaMat4(const LuaMat4 &rhs) +{ + memcpy(this->__m, rhs.__m, 16 * sizeof(T)); +} + +template inline +LuaMat4::LuaMat4(const Matrix4 &mat4) +{ + memcpy( __m, &mat4.i, 4 * sizeof(T)); + memcpy(&__m[4], &mat4.j, 4 * sizeof(T)); + memcpy(&__m[8], &mat4.k, 4 * sizeof(T)); + memcpy(&__m[12], &mat4.c, 4 * sizeof(T)); +} + +template inline +LuaMat4::LuaMat4(T m0, T m1, T m2, T m3, + T m4, T m5, T m6, T m7, + T m8, T m9, T m10, T m11, + T m12, T m13, T m14, T m15) +{ + T* pm = __m; + *(pm++) = m0; + *(pm++) = m1; + *(pm++) = m2; + *(pm++) = m3; + *(pm++) = m4; + *(pm++) = m5; + *(pm++) = m6; + *(pm++) = m7; + *(pm++) = m8; + *(pm++) = m9; + *(pm++) = m10; + *(pm++) = m11; + *(pm++) = m12; + *(pm++) = m13; + *(pm++) = m14; + *(pm++) = m15; +} + +template inline void +LuaMat4::SetIdentity(void) +{ + memset(__m, 0, 16 * sizeof(T)); + + T one = static_cast(1); + __m[0] = one; + __m[5] = one; + __m[10] = one; + __m[15] = one; + + return; +} + +template inline void +LuaMat4::Translate(T x0, T y0, T z0) +{ + T* pnt0 = __m; + T* pnt3Init = &(__m[12]); + T* pnt3 = pnt3Init; + + const T* pArg[3] = {&x0, &y0, &z0}; + const T** p = pArg; + for (short i = 0, j = 0; i < 12; ++i, ++j) + { + if (j == 4) + { + j = 0; + p++; + pnt3 = pnt3Init; + } + *pnt0 += *(pnt3++) * (**p); + pnt0++; + } + + return; +} + +template inline bool +LuaMat4::Scale(T aX, T aY, T aZ) +{ + T epsilon = std::numeric_limits::epsilon(); + if (aX <= -epsilon || aY <= -epsilon || aZ <= -epsilon) + { + return false; + } + + T *pnt0 = __m; + const T* pArg[3] = {&aX, &aY, &aZ}; + const T** p = pArg; + for (short i = 0, j = 0; i < 12; ++i, ++j) + { + if (j == 4) + { + j = 0; + ++p; + } + *pnt0 *= (**p); + pnt0++; + } + + return true; +} + +template inline bool +LuaMat4::Scale(T aX, T aY, T aZ, T x0, T y0, T z0) +{ + Translate(-x0, -y0, -z0); + bool res = Scale(aX, aY, aZ); + Translate(x0, y0, z0); + + return res; +} + +template inline void +LuaMat4::RotateAroundAxisZ(T angle) +{ + // ---- for case T==float ---------- + float coi = cosf(angle); + float sii = sinf(angle); + //---------------------------------- + float co = coi; + float si = sii; + + T* pnt1Init = __m; + T* pnt2Init = &(__m[4]); + T* pnt1 = pnt1Init; + T* pnt2 = pnt2Init; + T mTemp[8]; + T* pMTemp = mTemp; + for (short i = 0, j = 0; i < 8; ++i, ++j) + { + if (j == 4) + { + j = 0; + co = -sii; + si = coi; + pnt1 = pnt1Init; + pnt2 = pnt2Init; + } + *pMTemp = (*(pnt1++) * co + *(pnt2++) * si); + pMTemp++; + } + memcpy(__m, mTemp, 8 * sizeof(T)); + + return; +} + +template inline void +LuaMat4::RotateAroundAxisZ(T angle, T x0, T y0, T z0) +{ + Translate(-x0, -y0, -z0); + RotateAroundAxisZ(angle); + Translate(x0, y0, z0); + + return; +} + +template inline void +LuaMat4::RotateAroundAxisX(T angle) +{ + // ---- for case T==float ---------- + float coi = cosf(angle); + float sii = sinf(angle); + //---------------------------------- + float co = coi; + float si = -sii; + + T* pnt1Init = &(__m[4]); + T* pnt2Init = &(__m[8]); + T* pnt1 = pnt1Init; + T* pnt2 = pnt2Init; + T mTemp[8]; + T* pMTemp = mTemp; + for (short i = 0, j = 0; i < 8; ++i, ++j) + { + if (j == 4) + { + j = 0; + co = sii; + si = coi; + pnt1 = pnt1Init; + pnt2 = pnt2Init; + } + *pMTemp = (*(pnt1++) * co + *(pnt2++) * si); + pMTemp++; + } + memcpy(&(__m[4]), mTemp, 8 * sizeof(T)); + + return; +} + +template inline void +LuaMat4::RotateAroundAxisX(T angle, T x0, T y0, T z0) +{ + Translate(-x0, -y0, -z0); + RotateAroundAxisX(angle); + Translate(x0, y0, z0); + + return; +} + +template inline void +LuaMat4::RotateAroundAxisY(T angle) +{ + // ---- for case T==float ---------- + float coi = cosf(angle); + float sii = sinf(angle); + //---------------------------------- + float co = coi; + float si = sii; + + T* pnt1Init = __m; + T* pnt2Init = &(__m[8]); + T* pnt1 = pnt1Init; + T* pnt2 = pnt2Init; + T mTemp[8]; + T* pMTemp = mTemp; + for (short i = 0, j = 0; i < 8; ++i, ++j) + { + if (j == 4) + { + j = 0; + co = -sii; + si = coi; + pnt1 = pnt1Init; + pnt2 = pnt2Init; + } + *pMTemp = (*(pnt1++) * co + *(pnt2++) * si); + pMTemp++; + } + memcpy(__m, mTemp, 4 * sizeof(T)); + memcpy(&(__m[8]), &(mTemp[4]), 4 * sizeof(T)); + + return; +} + +template inline void +LuaMat4::RotateAroundAxisY(T angle, T x0, T y0, T z0) +{ + Translate(-x0, -y0, -z0); + RotateAroundAxisY(angle); + Translate(x0, y0, z0); + + return; +} + +template inline bool +LuaMat4::RotateAroundAxisArbitrary(T angle, T ax, T ay, T az) +{ + // ---- for case T==float ------------------------------------- + float c = cosf(angle); + float s = sinf(angle); + + T len = sqrtf(ax * ax + ay * ay + az * az); + if (fabsf(len) <= std::numeric_limits::epsilon()) + { + return false; + } + //------------------------------------------------------------- + T axn = ax / len; + T ayn = ay / len; + T azn = az / len; + + LuaMat4 res(c + (1 - c) * axn * axn, (1 - c) * axn * ayn - s * azn, (1 - c) * axn * azn + s * ayn, 0, + (1 - c) * ayn * axn + s * azn, c + (1 - c) * ayn * ayn, (1 - c) * ayn * azn - s * axn, 0, + (1 - c) * azn * axn - s * ayn, (1 - c) * azn * ayn + s * axn, c + (1 - c) * azn * azn, 0, + 0, 0, 0, 1); + + *this = res * (*this); + return true; +} + +template inline bool +LuaMat4::RotateAroundAxisArbitrary(T angle, T ax, T ay, T az, T x0, T y0, T z0) +{ + Translate(-x0, -y0, -z0); + bool res = RotateAroundAxisArbitrary(angle, ax, ay, az); + Translate(x0, y0, z0); + + return res; +} + +template inline LuaMat4 +LuaMat4::operator*(const LuaMat4 &rhs) const +{ + LuaMat4 res; + memset(res.__m, 0, 16 * sizeof(T)); + const T* pThis = __m; + const T* pThisC; + const T* pMul = rhs.__m; + const T* pMulC; + T *pRes = res.__m; + short i, j, k; + for (k = 0; k < 4; ++k) + { + for (j = 0; j < 4; ++j) + { + pThisC = pThis; + pMulC = pMul; + for (i = 0; i < 4; ++i) + { + *pRes += *(pThisC++) * (*pMulC); + pMulC += 4; + } + pRes++; + pMul++; + } + pThis += 4; + pMul = rhs.__m; + } + + return res; +} + +template inline LuaMat4 +LuaMat4::operator*(T rhs)const +{ + LuaMat4 res(*this); + T *pRes = res.__m; + + for (short i = 0; i < 15; ++i, ++pRes) + { + *pRes *= rhs; + } + + return res; +} + +template inline LuaMat4 +LuaMat4::operator+(const LuaMat4 &rhs)const +{ + LuaMat4 res; + memset(res.__m, 0, 16*sizeof(T)); + T *pRes = res.__m; + const T* pAdd1 = __m; + const T* pAdd2 = rhs.__m; + + for (short i = 0; i < 15; ++i, ++pRes) + { + *pRes = *(pAdd1++) + *(pAdd2++); + } + + return res; +} + +template inline LuaMat4 +LuaMat4::operator-(void)const +{ + LuaMat4 res(*this); + T *pRes = res.__m; + + for (short i = 0; i < 15; ++i, ++pRes) + { + *pRes = -(*pRes); + } + + return res; +} + +template inline LuaMat4 +LuaMat4::operator-(const LuaMat4 &rhs)const +{ + return *this + (-rhs); +} + +template inline LuaMat4 & +LuaMat4::operator=(const LuaMat4 &rhs) +{ + memcpy(__m, rhs.__m, 16 * sizeof(T)); + return *this; +} + +template inline +LuaMat4::operator Matrix4(void)const +{ + Matrix4 res(__m[0], __m[1], __m[2], __m[3], + __m[4], __m[5], __m[6], __m[7], + __m[8], __m[9], __m[10], __m[11], + __m[12], __m[13], __m[14], __m[15]); + + return res; +} + + +} } } } // Tizen::Ui::Effects::_Utils + +#endif //_FUI_EFFECTS_INTERNAL_UTILS_LUA_MAT4_H_ diff --git a/src/ui/effects/inc/utils/FUiEffects_UtilsMatrix2.h b/src/ui/effects/inc/utils/FUiEffects_UtilsMatrix2.h new file mode 100644 index 0000000..1b6efcf --- /dev/null +++ b/src/ui/effects/inc/utils/FUiEffects_UtilsMatrix2.h @@ -0,0 +1,713 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_UtilsMatrix2.h + * @brief The Matrix2 class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_UTILS_MATRIX2_H_ +#define _FUI_EFFECTS_INTERNAL_UTILS_MATRIX2_H_ + +#include "FUiEffects_UtilsAdapterFunctions.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Utils +{ + template class _Vector2; + template class Quaternion; + + template class Matrix2 + { + private: + typedef Matrix2 SelfType; + + public: + _Vector2 i; + _Vector2 j; + + inline Matrix2(); + inline explicit Matrix2(const T& aValue); + inline explicit Matrix2(const T* aValue); + inline Matrix2(const SelfType& aOther); + inline Matrix2(const _Vector2& aI, const _Vector2& aJ); + inline Matrix2(const T& a11, const T& a12, + const T& a21, const T& a22); + + inline SelfType& operator=(const SelfType& aRhv); + + inline SelfType& set(const T& aValue); + inline SelfType& set(const T* aValue); + inline SelfType& set(const SelfType& aOther); + inline SelfType& set(const _Vector2& aI, const _Vector2& aJ); + inline SelfType& set(const T& a11, const T& a12, + const T& a21, const T& a22); + + inline SelfType& identity(); + inline static const SelfType& getIdentity(); + inline bool isIdentity() const; + + inline SelfType operator-() const; + inline SelfType& inverse(); + inline SelfType getInversed() const; + inline SelfType& transpose(); + inline SelfType getTransposed() const; + + inline SelfType& operator+=(const SelfType& aRhv); + inline SelfType& operator+=(const T& aRhv); + inline SelfType& operator-=(const SelfType& aRhv); + inline SelfType& operator-=(const T& aRhv); + inline SelfType& operator*=(const SelfType& aRhv); + inline SelfType& operator*=(const T& aRhv); + inline SelfType& operator/=(const T& aRhv); + inline SelfType GetMultipliedByMember(const SelfType& aRhv) const; + inline SelfType& multiplyByMember(const SelfType& aRhv); + static inline SelfType createMultipliedByMember(const SelfType& aLhv, const SelfType& aRhv); + inline SelfType getDividedByMember(const SelfType& aRhv) const; + inline SelfType& divideByMember(const SelfType& aRhv); + static inline SelfType createDividedByMember(const SelfType& aLhv, const SelfType& aRhv); + + inline T* getPointer(); + inline const T* getPointer() const; + inline T& get(unsigned int aRow, unsigned int aColumn); + inline const T& get(unsigned int aRow, unsigned int aColumn) const; + inline T& get(unsigned int aAbsIndex); + inline const T& get(unsigned int aAbsIndex) const; + inline SelfType& set(unsigned int aRow, unsigned int aColumn, const T& aValue); + inline SelfType& set(unsigned int aAbsIndex, const T& aValue); + inline _Vector2& getRow(unsigned int aRow); + inline const _Vector2& getRow(unsigned int aRow) const; + inline SelfType& setRow(unsigned int aRow, const _Vector2& aValue); + inline _Vector2 getColumn(unsigned int aColumn) const; + inline SelfType& setColumn(unsigned int aColumn, const _Vector2& aValue); + inline T& operator()(unsigned int aRow, unsigned int aColumn); + inline const T& operator()(unsigned int aRow, unsigned int aColumn) const; + inline T& operator()(unsigned int aAbsIndex); + inline const T& operator()(unsigned int aAbsIndex) const; + inline T& operator[](unsigned int aAbsIndex); + inline const T& operator[](unsigned int aAbsIndex) const; + + inline SelfType& lerp(const SelfType& aTo, const T& aCoeff); + inline SelfType getLerped(const SelfType& aTo, const T& aCoeff) const; + inline SelfType& makeLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + static inline SelfType createLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + inline SelfType& slerp(const SelfType& aTo, const T& aCoeff); + inline SelfType getSlerped(const SelfType& aTo, const T& aCoeff) const; + inline SelfType& makeSlerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + static inline SelfType createSlerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + + inline T determinant() const; + + inline _Vector2& applyTransform(_Vector2& aVector) const; + inline _Vector2 getAppliedTransform(const _Vector2& aVector) const; + + inline SelfType& makeRotation(const T& aAngleRAD); + inline SelfType& rotate(const T& aAngleRAD); + static inline SelfType createRotation(const T& aAngleRAD); + inline T getRotationAngle() const; + + inline SelfType& makeScale(const T& aX, const T& aY); + inline SelfType& makeScale(const _Vector2& aScale); + static inline SelfType createScale(const T& aX, const T& aY); + static inline SelfType createScale(const _Vector2& aScale); + inline SelfType& scale(const T& aX, const T& aY); + inline SelfType& scale(const _Vector2& aScale); + }; + + typedef Matrix2 Mat2f; + typedef Matrix2 Mat2d; + + template inline Matrix2 operator+(const Matrix2& aLhv, const Matrix2& aRhv); + template inline Matrix2 operator+(const Matrix2& aLhv, const T& aRhv); + template inline Matrix2 operator+(const T& aLhv, const Matrix2& aRhv); + template inline Matrix2 operator-(const Matrix2& aLhv, const Matrix2& aRhv); + template inline Matrix2 operator-(const Matrix2& aLhv, const T& aRhv); + template inline Matrix2 operator-(const T& aLhv, const Matrix2& aRhv); + template inline Matrix2 operator*(const Matrix2& aLhv, const Matrix2& aRhv); + template inline Matrix2 operator*(const Matrix2& aLhv, const T& aRhv); + template inline Matrix2 operator*(const T& aLhv, const Matrix2& aRhv); + template inline _Vector2 operator*(const Matrix2& aLhv, const _Vector2& aRhv); + template inline _Vector2 operator*(const _Vector2& aLhv, const Matrix2& aRhv); + template inline Matrix2 operator/(const Matrix2& aLhv, const T& aRhv); + template inline bool operator==(const Matrix2& aLhv, const Matrix2& aRhv); + template inline bool operator==(const T& aLhv, const Matrix2& aRhv); + template inline bool operator==(const Matrix2& aLhv, const T& aRhv); + template inline bool operator!=(const Matrix2& aLhv, const Matrix2& aRhv); + template inline bool operator!=(const T& aLhv, const Matrix2& aRhv); + template inline bool operator!=(const Matrix2& aLhv, const T& aRhv); + + template Matrix2::Matrix2() {} + + template Matrix2::Matrix2(const T& aValue): + i(aValue), j(aValue) {} + + template Matrix2::Matrix2(const T* aValue): + i(aValue[0], aValue[1]), j(aValue[2], aValue[3]) {} + + template Matrix2::Matrix2(const Matrix2& aOther): + i(aOther.i), j(aOther.j) {} + + template Matrix2::Matrix2(const _Vector2& aI, const _Vector2& aJ): + i(aI), j(aJ) {} + + template Matrix2::Matrix2( const T& a11, const T& a12, + const T& a21, const T& a22): + i(a11, a12), j(a21, a22) {} + + template Matrix2& Matrix2::operator=(const Matrix2& aRhv) + { + i = aRhv.i; + j = aRhv.j; + return *this; + } + + template Matrix2& Matrix2::set(const T& aValue) + { + i.set(aValue); + j.set(aValue); + return *this; + } + + template Matrix2& Matrix2::set(const T* aValue) + { + i.set(aValue[0], aValue[1]); + j.set(aValue[2], aValue[3]); + return *this; + } + + template Matrix2& Matrix2::set(const Matrix2& aOther) + { + i = aOther.i; + j = aOther.j; + return *this; + } + + template Matrix2& Matrix2::set(const _Vector2& aI, const _Vector2& aJ) + { + i = aI; + j = aJ; + return *this; + } + + template Matrix2& Matrix2::set(const T& a11, const T& a12, const T& a21, const T& a22) + { + i.set(a11, a12); + j.set(a21, a22); + return *this; + } + + + template inline Matrix2& Matrix2::identity() + { + return operator=(getIdentity()); + } + + template inline const Matrix2& Matrix2::getIdentity() + { + static Matrix2 identityMatrix( + T(1.0f), T(0.0f), + T(0.0f), T(1.0f)); + return identityMatrix; + } + + template inline bool Matrix2::isIdentity() const + { + return *this == getIdentity(); + } + + template inline Matrix2 Matrix2::operator-() const + { + return Matrix2(-i, -j); + } + + template inline Matrix2& Matrix2::inverse() + { + static const T t0(0.0f); + static const T t1(1.0f); + + T s = determinant(); + if(EffectsEqual(s, t0)) + return *this; + T inv_det(t1 / s); + return set(j.y * inv_det, -i.y * inv_det, -j.x * inv_det, i.x * inv_det); + } + template inline Matrix2 Matrix2::getInversed() const + { + static const T t0(0.0f); + static const T t1(1.0f); + + T s = determinant(); + if(EffectsEqual(s, t0)) return *this; + T inv_det(t1 / s); + return Matrix2(j.y * inv_det, -i.y * inv_det, -j.x * inv_det, i.x * inv_det); + } + + template inline T Matrix2::determinant() const + { + return i.x * j.y - j.x * i.y; + } + + template inline Matrix2& Matrix2::transpose() + { + EffectsSwap(i.y, j.x); + return *this; + } + + template inline Matrix2 Matrix2::getTransposed() const + { + return Matrix2(i.x, j.x, i.y, j.y); + } + + template inline Matrix2& Matrix2::operator+=(const Matrix2& aRhv) + { + i += aRhv.i; + j += aRhv.j; + return *this; + } + template inline Matrix2& Matrix2::operator+=(const T& aRhv) + { + i += aRhv; + j += aRhv; + return *this; + } + template inline Matrix2& Matrix2::operator-=(const Matrix2& aRhv) + { + i -= aRhv.i; + j -= aRhv.j; + return *this; + } + template inline Matrix2& Matrix2::operator-=(const T& aRhv) + { + i -= aRhv; + j -= aRhv; + return *this; + } + template inline Matrix2& Matrix2::operator*=(const T& aRhv) + { + i *= aRhv; + j *= aRhv; + return *this; + } + + template inline Matrix2 Matrix2::GetMultipliedByMember(const Matrix2& aRhv) const + { + return Matrix2(i * aRhv.i, j * aRhv.j); + } + + template inline Matrix2& Matrix2::multiplyByMember(const Matrix2& aRhv) + { + i *= aRhv.i; + j *= aRhv.j; + return *this; + } + + template inline Matrix2 Matrix2::createMultipliedByMember(const Matrix2& aLhv, const Matrix2& aRhv) + { + return Matrix2(aLhv.i * aRhv.i, aLhv.j * aRhv.j); + } + + template inline Matrix2& Matrix2::operator*=(const Matrix2& aRhv) + { + set( + i.x * aRhv.i.x + i.y * aRhv.j.x, + i.x * aRhv.i.y + i.y * aRhv.j.y, + + j.x * aRhv.i.x + j.y * aRhv.j.x, + j.x * aRhv.i.y + j.y * aRhv.j.y); + return *this; + } + + template inline Matrix2 Matrix2::getDividedByMember(const Matrix2& aRhv) const + { + return Matrix2(i / aRhv.i, j / aRhv.j); + } + + template inline Matrix2& Matrix2::divideByMember(const Matrix2& aRhv) + { + i /= aRhv.i; + j /= aRhv.j; + return *this; + } + template inline Matrix2 Matrix2::createDividedByMember(const Matrix2& aLhv, const Matrix2& aRhv) + { + return Matrix2(aLhv.i / aRhv.i, aLhv.j / aRhv.j); + } + + template inline Matrix2& Matrix2::operator/=(const T& aRhv) + { + i /= aRhv; + j /= aRhv; + return *this; + } + + template inline T* Matrix2::getPointer() + { + return i.getPointer(); + } + + template inline const T* Matrix2::getPointer() const + { + return i.getPointer(); + } + + template inline T& Matrix2::get(unsigned int aRow, unsigned int aColumn) + { + return operator()(aRow, aColumn); + } + + template inline const T& Matrix2::get(unsigned int aRow, unsigned int aColumn) const + { + return operator()(aRow, aColumn); + } + + template inline T& Matrix2::get(unsigned int aAbsIndex) + { + return operator()(aAbsIndex); + } + + template inline const T& Matrix2::get(unsigned int aAbsIndex) const + { + return operator()(aAbsIndex); + } + + template inline _Vector2& Matrix2::getRow(unsigned int aRow) + { + if(1 == aRow) + return j; + return i; + } + + template inline const _Vector2& Matrix2::getRow(unsigned int aRow) const + { + if(1 == aRow) + return j; + return i; + } + + template inline _Vector2 Matrix2::getColumn(unsigned int aColumn) const + { + if(1 == aColumn) + return _Vector2(i.y, j.y); + return _Vector2(i.x, j.x); + } + + template inline T& Matrix2::operator()(unsigned int aRow, unsigned int aColumn) + { + return operator[]((aRow << 1) + aColumn); + } + + template inline const T& Matrix2::operator()(unsigned int aRow, unsigned int aColumn) const + { + return operator[]((aRow << 1) + aColumn); + } + + template inline T& Matrix2::operator()(unsigned int aAbsIndex) + { + return operator[](aAbsIndex); + } + + template inline const T& Matrix2::operator()(unsigned int aAbsIndex) const + { + return operator[](aAbsIndex); + } + + template inline T& Matrix2::operator[](unsigned int aAbsIndex) + { + return getPointer()[aAbsIndex]; + } + + template inline const T& Matrix2::operator[](unsigned int aAbsIndex) const + { + return getPointer()[aAbsIndex]; + } + + template inline Matrix2& Matrix2::setColumn(unsigned int aColumn, const _Vector2& aValue) + { + switch(aColumn) + { + case 0: + i.x = aValue.x; + j.x = aValue.y; + break; + case 1: + i.y = aValue.x; + j.y = aValue.y; + break; + } + + return *this; + } + + template inline Matrix2& Matrix2::setRow(unsigned int aRow, const _Vector2& aValue) + { + switch(aRow) + { + case 0: + i = aValue; + break; + case 1: + j = aValue; + break; + } + + return *this; + } + + template inline Matrix2& Matrix2::set(unsigned int aRow, unsigned int aColumn, const T& aValue) + { + operator()(aRow, aColumn) = aValue; + return *this; + } + + template inline Matrix2& Matrix2::set(unsigned int aAbsIndex, const T& aValue) + { + operator()(aAbsIndex) = aValue; + return *this; + } + + template inline Matrix2& Matrix2::lerp(const Matrix2& aTo, const T& aCoeff) + { + i.lerp(aTo.i, aCoeff); + j.lerp(aTo.j, aCoeff); + return *this; + } + + template inline Matrix2 Matrix2::getLerped(const Matrix2& aTo, const T& aCoeff) const + { + Matrix2 result(i.getLerped(aTo.i, aCoeff), j.getLerped(aTo.j, aCoeff)); + return result; + } + + template inline Matrix2& Matrix2::makeLerped(const Matrix2& aFrom, const Matrix2& aTo, const T& aCoeff) + { + i.makeLerped(aFrom.i, aTo.i, aCoeff); + j.makeLerped(aFrom.j, aTo.j, aCoeff); + return *this; + } + template inline Matrix2 Matrix2::createLerped(const Matrix2& aFrom, const Matrix2& aTo, const T& aCoeff) + { + return Matrix2().makeLerped(aFrom, aTo, aCoeff); + } + + template inline Matrix2& Matrix2::slerp(const Matrix2& aTo, const T& aCoeff) + { + makeRotation(effects_lerp(getRotationAngle(), aTo.getRotationAngle(), aCoeff)); + return *this; + } + + template inline Matrix2 Matrix2::getSlerped(const Matrix2& aTo, const T& aCoeff) const + { + Matrix2 result; + result.makeRotation(effects_lerp(getRotationAngle(), aTo.getRotationAngle(), aCoeff)); + return result; + } + + template inline Matrix2& Matrix2::makeSlerped(const Matrix2& aFrom, const Matrix2& aTo, const T& aCoeff) + { + makeRotation(effects_lerp(aFrom.getRotationAngle(), aTo.getRotationAngle(), aCoeff)); + return *this; + } + + template inline Matrix2 Matrix2::createSlerped(const Matrix2& aFrom, const Matrix2& aTo, const T& aCoeff) + { + return Matrix2().makeSlerped(aFrom, aTo, aCoeff); + } + + template inline Matrix2& Matrix2::makeRotation(const T& aAngleRAD) + { + const T s = effects_sin(aAngleRAD); + const T c = effects_cos(aAngleRAD); + i.x = c; + i.y = s; + j.x = -s; + j.y = c; + return *this; + } + + template inline Matrix2& Matrix2::rotate(const T& aAngleRAD) + { + const T s = effects_sin(aAngleRAD); + const T c = effects_cos(aAngleRAD); + const T ix = i.x * c - i.y * s; + const T iy = i.x * s + i.y * c; + const T jx = j.x * c - j.y * s; + const T jy = j.x * s + j.y * c; + i.x = ix; + i.y = iy; + j.x = jx; + j.y = jy; + return *this; + } + template inline Matrix2 Matrix2::createRotation(const T& aAngleRAD) + { + return Matrix2().makeRotation(aAngleRAD); + } + + template inline T Matrix2::getRotationAngle() const + { + static const T t0(0.0f); + static const T t1(1.0f); + + static const _Vector2 orig_vector(t1, t0); + static const _Vector2 orig_vector_cross(t0, t1); + + _Vector2 rotated(getAppliedTransform(orig_vector).normalize()); + const T angleCos = effects_clamp(rotated.dot(orig_vector), -t1, t1); + const T angleCosCross = effects_clamp(rotated.dot(orig_vector_cross), -t1, t1); + + if(angleCosCross > t0) + return effects_acos(angleCos); + return -effects_acos(angleCos); + } + + template inline Matrix2& Matrix2::makeScale(const T& aX, const T& aY) + { + i.x = aX; + j.y = aY; + + i.y = j.x = T(0.0f); + return *this; + } + template inline Matrix2& Matrix2::makeScale(const _Vector2& aScale) + { + return makeScale(aScale.x, aScale.y); + } + template inline Matrix2 Matrix2::createScale(const T& aX, const T& aY) + { + return Matrix2().makeScale(aX, aY); + } + template inline Matrix2 Matrix2::createScale(const _Vector2& aScale) + { + return Matrix2().makeScale(aScale); + } + + template inline Matrix2& Matrix2::scale(const T& aX, const T& aY) + { + i.x *= aX; i.y *= aY; + j.x *= aX; j.y *= aY; + + return *this; + } + template inline Matrix2& Matrix2::scale(const _Vector2& aScale) + { + return scale(aScale.x, aScale.y); + } + + template inline _Vector2& Matrix2::applyTransform(_Vector2& aVector) const + { + return aVector.set( + aVector.x * i.x + aVector.y * j.x, + aVector.x * i.y + aVector.y * j.y); + } + + template inline _Vector2 Matrix2::getAppliedTransform(const _Vector2& aVector) const + { + return _Vector2( + aVector.x * i.x + aVector.y * j.x, + aVector.x * i.y + aVector.y * j.y); + } + + template inline bool isEqual(const Matrix2& aLhv, const Matrix2& aRhv, const T& aEpsilon = effects_epsilon::epsilon()) + { + return isEqual(aLhv.i, aRhv.i, aEpsilon) && isEqual(aLhv.j, aRhv.j, aEpsilon); + } + template inline Matrix2 operator+(const Matrix2& aLhv, const Matrix2& aRhv) + { + return Matrix2(aLhv.i + aRhv.i, aLhv.j + aRhv.j); + } + template inline Matrix2 operator+(const Matrix2& aLhv, const T& aRhv) + { + return Matrix2(aLhv.i + aRhv, aLhv.j + aRhv); + } + template inline Matrix2 operator+(const T& aLhv, const Matrix2& aRhv) + { + return Matrix2(aLhv + aRhv.i, aLhv + aRhv.j); + } + template inline Matrix2 operator-(const Matrix2& aLhv, const Matrix2& aRhv) + { + return Matrix2(aLhv.i - aRhv.i, aLhv.j - aRhv.j); + } + template inline Matrix2 operator-(const Matrix2& aLhv, const T& aRhv) + { + return Matrix2(aLhv.i - aRhv, aLhv.j - aRhv); + } + template inline Matrix2 operator-(const T& aLhv, const Matrix2& aRhv) + { + return Matrix2(aLhv - aRhv.i, aLhv - aRhv.j); + } + template inline Matrix2 operator*(const Matrix2& aLhv, const Matrix2& aRhv) + { + return Matrix2( + aLhv.i.x * aRhv.i.x + aLhv.i.y * aRhv.j.x, + aLhv.i.x * aRhv.i.y + aLhv.i.y * aRhv.j.y, + + aLhv.j.x * aRhv.i.x + aLhv.j.y * aRhv.j.x, + aLhv.j.x * aRhv.i.y + aLhv.j.y * aRhv.j.y); + } + template inline Matrix2 operator*(const Matrix2& aLhv, const T& aRhv) + { + return Matrix2(aLhv.i * aRhv, aLhv.j * aRhv); + } + template inline Matrix2 operator*(const T& aLhv, const Matrix2& aRhv) + { + return Matrix2(aLhv * aRhv.i, aLhv * aRhv.j); + } + template inline _Vector2 operator*(const _Vector2& aLhv, const Matrix2& aRhv) + { + return aRhv.getAppliedTransform(aLhv); + } + template inline _Vector2 operator*(const Matrix2& aLhv, const _Vector2& aRhv) + { + return _Vector2( + aLhv.i.x * aRhv.x + aLhv.i.y * aRhv.y, + aLhv.j.x * aRhv.x + aLhv.j.y * aRhv.y); + } + template inline Matrix2 operator/(const Matrix2& aLhv, const T& aRhv) + { + return Matrix2(aLhv.i / aRhv, aLhv.j / aRhv); + } + template inline Matrix2 operator/(const T& aLhv, const Matrix2& aRhv) + { + return Matrix2(aLhv / aRhv.i, aLhv / aRhv.j); + } + template inline bool operator==(const Matrix2& aLhv, const Matrix2& aRhv) + { + return aLhv.i == aRhv.i && aLhv.j == aRhv.j; + } + template inline bool operator==(const Matrix2& aLhv, const T& aRhv) + { + return aLhv.i == aRhv && aLhv.j == aRhv; + } + template inline bool operator==(const T& aLhv, const Matrix2& aRhv) + { + return aLhv == aRhv.i && aLhv == aRhv.j; + } + template inline bool operator!=(const Matrix2& aLhv, const Matrix2& aRhv) + { + return !(aLhv == aRhv); + } + template inline bool operator!=(const Matrix2& aLhv, const T& aRhv) + { + return !(aLhv == aRhv); + } + template inline bool operator!=(const T& aLhv, const Matrix2& aRhv) + { + return !(aLhv == aRhv); + } +} } } } //Tizen::Ui::Effects::_Utils + +#endif //_FUI_EFFECTS_INTERNAL_UTILS_MATRIX2_H_ diff --git a/src/ui/effects/inc/utils/FUiEffects_UtilsMatrix3.h b/src/ui/effects/inc/utils/FUiEffects_UtilsMatrix3.h new file mode 100644 index 0000000..dcdc2de --- /dev/null +++ b/src/ui/effects/inc/utils/FUiEffects_UtilsMatrix3.h @@ -0,0 +1,1136 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_UtilsMatrix3.h + * @brief The Matrix3 class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_UTILS_MATRIX3_H_ +#define _FUI_EFFECTS_INTERNAL_UTILS_MATRIX3_H_ + +#include "FUiEffects_UtilsAdapterFunctions.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Utils +{ + template class _Vector3; + template class _Vector2; + template class Matrix2; + template class Quaternion; + + template class Matrix3 + { + private: + typedef Matrix3 SelfType; + + public: + _Vector3 i; + _Vector3 j; + _Vector3 k; + + inline Matrix3(); + inline explicit Matrix3(const T& aValue); + inline explicit Matrix3(const T* aValue); + inline Matrix3(const SelfType& aOther); + inline Matrix3(const _Vector3& aI, const _Vector3& aJ, const _Vector3& aC); + inline Matrix3(const _Vector2& aI, const _Vector2& aJ, const _Vector2& aC); + inline Matrix3(const T& a11, const T& a12, const T& a13, + const T& a21, const T& a22, const T& a23, + const T& a31, const T& a32, const T& a33); + + inline SelfType& operator=(const SelfType& aRhv); + + inline SelfType& set(const T& aValue); + inline SelfType& set(const T* aValue); + inline SelfType& set(const SelfType& aOther); + inline SelfType& set(const _Vector3& aI, const _Vector3& aJ, const _Vector3& aC); + inline SelfType& set(const _Vector2& aI, const _Vector2& aJ, const _Vector2& aC); + inline SelfType& set(const T& a11, const T& a12, const T& a13, + const T& a21, const T& a22, const T& a23, + const T& a31, const T& a32, const T& a33); + + inline SelfType& identity(); + inline static const SelfType& getIdentity(); + inline bool isIdentity() const; + + inline SelfType operator-() const; + inline SelfType& inverse(); + inline SelfType getInversed() const; + inline SelfType& transpose(); + inline SelfType getTransposed() const; + + inline SelfType& operator+=(const SelfType& aRhv); + inline SelfType& operator+=(const T& aRhv); + inline SelfType& operator-=(const SelfType& aRhv); + inline SelfType& operator-=(const T& aRhv); + inline SelfType& operator*=(const SelfType& aRhv); + inline SelfType& operator*=(const T& aRhv); + inline SelfType& operator/=(const T& aRhv); + inline SelfType GetMultipliedByMember(const SelfType& aRhv) const; + static inline SelfType createMultipliedByMember(const SelfType& aLhv, const SelfType& aRhv); + inline SelfType& multiplyByMember(const SelfType& aRhv); + inline SelfType getDividedByMember(const SelfType& aRhv) const; + static inline SelfType createDividedByMember(const SelfType& aLhv, const SelfType& aRhv); + inline SelfType& divideByMember(const SelfType& aRhv); + + inline T* getPointer(); + inline const T* getPointer() const; + inline T& get(unsigned int aRow, unsigned int aColumn); + inline const T& get(unsigned int aRow, unsigned int aColumn) const; + inline T& get(unsigned int aAbsIndex); + inline const T& get(unsigned int aAbsIndex) const; + inline SelfType& set(unsigned int aRow, unsigned int aColumn, const T& aValue); + inline SelfType& set(unsigned int aAbsIndex, const T& aValue); + inline _Vector3& getRow(unsigned int aRow); + inline const _Vector3& getRow(unsigned int aRow) const; + inline SelfType& setRow(unsigned int aRow, const _Vector3& aValue); + inline _Vector3 getColumn(unsigned int aColumn) const; + inline SelfType& setColumn(unsigned int aColumn, const _Vector3& aValue); + inline T& operator()(unsigned int aRow, unsigned int aColumn); + inline const T& operator()(unsigned int aRow, unsigned int aColumn) const; + inline T& operator()(unsigned int aAbsIndex); + inline const T& operator()(unsigned int aAbsIndex) const; + inline T& operator[](unsigned int aAbsIndex); + inline const T& operator[](unsigned int aAbsIndex) const; + + inline SelfType& lerp(const SelfType& aTo, const T& aCoeff); + inline SelfType getLerped(const SelfType& aTo, const T& aCoeff) const; + inline SelfType& makeLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + static inline SelfType createLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + inline SelfType& slerp(const SelfType& aTo, const T& aCoeff); + inline SelfType getSlerped(const SelfType& aTo, const T& aCoeff) const; + inline SelfType& makeSlerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + static inline SelfType createSlerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + + inline T determinant() const; + + inline _Vector3& applyTransform(_Vector3& aVector) const; + inline _Vector3 getAppliedTransform(const _Vector3& aVector) const; + inline _Vector3& applyRotation(_Vector3& aVector) const; + inline _Vector3 getAppliedRotation(const _Vector3& aVector) const; + inline _Vector3& applyTranslate(_Vector3& aVector) const; + inline _Vector3 getAppliedTranslate(const _Vector3& aVector) const; + + inline _Vector2& applyTransform(_Vector2& aVector) const; + inline _Vector2 getAppliedTransform(const _Vector2& aVector) const; + inline _Vector2& applyRotation(_Vector2& aVector) const; + inline _Vector2 getAppliedRotation(const _Vector2& aVector) const; + inline _Vector2& applyTranslate(_Vector2& aVector) const; + inline _Vector2 getAppliedTranslate(const _Vector2& aVector) const; + + inline SelfType& setRotation(const T& aAngleRAD); + inline SelfType& setRotation(const Matrix2& aRotation); + inline SelfType& setRotation(const Matrix3& aRotation); + inline SelfType& makeRotation(const T& aAngleRAD); + inline SelfType& makeRotation(const Matrix2& aRotation); + inline SelfType& makeRotation(const Matrix3& aRotation); + inline SelfType& rotate(const T& aAngleRAD); + inline SelfType& rotate(const Matrix2& aRotation); + inline SelfType& rotate(const Matrix3& aRotation); + static inline SelfType createRotation(const T& aAngleRAD); + static inline SelfType createRotation(const Matrix2& aRotation); + static inline SelfType createRotation(const Matrix3& aRotation); + inline Matrix2 getRotation() const; + inline T getRotationAngle() const; + + inline SelfType& makeScale(const T& aX, const T& aY); + inline SelfType& makeScale(const _Vector2& aScale); + inline SelfType& setScale(const T& aX, const T& aY); + inline SelfType& setScale(const _Vector2& aScale); + static inline SelfType createScale(const T& aX, const T& aY); + static inline SelfType createScale(const _Vector2& aScale); + inline SelfType& scale(const T& aX, const T& aY); + inline SelfType& scale(const _Vector2& aScale); + + inline SelfType& setTranslation(const T& aX, const T& aY); + inline SelfType& setTranslation(const _Vector2& aTran); + inline SelfType& makeTranslation(const T& aX, const T& aY); + inline SelfType& makeTranslation(const _Vector2& aTran); + inline SelfType& translate(const T& aX, const T& aY); + inline SelfType& translate(const _Vector2& aTran); + static inline SelfType createTranslation(const T& aX, const T& aY); + static inline SelfType createTranslation(const _Vector2& aTran); + inline _Vector2 getTranslation() const; + inline _Vector3 getFullTranslation() const; + + inline T magnitude() const; + inline T magnitude_sqr() const; + inline T trace() const; + inline Matrix2 minorMatrix(int row, int column) const; + inline SelfType& makeCross(const _Vector3& aVector); + static inline SelfType createCross(const _Vector3& aVector); + + inline const SelfType& QR_Decomposition(SelfType& aQ, SelfType& aR) const; + }; + + typedef Matrix3 Mat3f; + typedef Matrix3 Mat3d; + + template inline Matrix3 operator+(const Matrix3& aLhv, const Matrix3& aRhv); + template inline Matrix3 operator+(const Matrix3& aLhv, const T& aRhv); + template inline Matrix3 operator+(const T& aLhv, const Matrix3& aRhv); + template inline Matrix3 operator-(const Matrix3& aLhv, const Matrix3& aRhv); + template inline Matrix3 operator-(const Matrix3& aLhv, const T& aRhv); + template inline Matrix3 operator-(const T& aLhv, const Matrix3& aRhv); + template inline Matrix3 operator*(const Matrix3& aLhv, const Matrix3& aRhv); + template inline Matrix3 operator*(const Matrix3& aLhv, const T& aRhv); + template inline Matrix3 operator*(const T& aLhv, const Matrix3& aRhv); + template inline _Vector3 operator*(const Matrix3& aLhv, const _Vector3& aRhv); + template inline _Vector3 operator*(const _Vector3& aLhv, const Matrix3& aRhv); + template inline _Vector2 operator*(const Matrix3& aLhv, const _Vector2& aRhv); + template inline _Vector2 operator*(const _Vector2& aLhv, const Matrix3& aRhv); + template inline Matrix3 operator/(const Matrix3& aLhv, const T& aRhv); + template inline Matrix3 operator/(const T& aLhv, const Matrix3& aRhv); + template inline bool operator==(const Matrix3& aLhv, const Matrix3& aRhv); + template inline bool operator==(const T& aLhv, const Matrix3& aRhv); + template inline bool operator==(const Matrix3& aLhv, const T& aRhv); + template inline bool operator!=(const Matrix3& aLhv, const Matrix3& aRhv); + template inline bool operator!=(const T& aLhv, const Matrix3& aRhv); + template inline bool operator!=(const Matrix3& aLhv, const T& aRhv); + + template Matrix3::Matrix3() {} + + template Matrix3::Matrix3(const T& aValue): + i(aValue), j(aValue), k(aValue) {} + + template Matrix3::Matrix3(const T* aValue): + i(aValue[0], aValue[1], aValue[2]), j(aValue[3], aValue[4], aValue[5]), k(aValue[6], aValue[7], aValue[8]) {} + + template Matrix3::Matrix3(const Matrix3& aOther): + i(aOther.i), j(aOther.j), k(aOther.k) {} + + template Matrix3::Matrix3(const _Vector3& aI, const _Vector3& aJ, const _Vector3& aK): + i(aI), j(aJ), k(aK) {} + + template Matrix3::Matrix3(const _Vector2& aI, const _Vector2& aJ, const _Vector2& aK): + i(aI, T(0.0f)), j(aJ, T(0.0f)), k(aK, T(1.0f)) {} + + template Matrix3::Matrix3(const T& a11, const T& a12, const T& a13, + const T& a21, const T& a22, const T& a23, + const T& a31, const T& a32, const T& a33): + i(a11, a12, a13), j(a21, a22, a23), k(a31, a32, a33) {} + + + template Matrix3& Matrix3::operator=(const Matrix3& aRhv) + { + i = aRhv.i; + j = aRhv.j; + k = aRhv.k; + return *this; + } + + template Matrix3& Matrix3::set(const T& aValue) + { + i.set(aValue); + j.set(aValue); + k.set(aValue); + return *this; + } + + template Matrix3& Matrix3::set(const T* aValue) + { + i.set(aValue[0], aValue[1], aValue[2]); + j.set(aValue[3], aValue[4], aValue[5]); + k.set(aValue[6], aValue[7], aValue[8]); + return *this; + } + + template Matrix3& Matrix3::set(const Matrix3& aOther) + { + i = aOther.i; + j = aOther.j; + k = aOther.k; + return *this; + } + + template Matrix3& Matrix3::set(const _Vector3& aI, const _Vector3& aJ, const _Vector3& aK) + { + i = aI; + j = aJ; + k = aK; + return *this; + } + + template Matrix3& Matrix3::set(const _Vector2& aI, const _Vector2& aJ, const _Vector2& aK) + { + i.set(aI, T(0.0f)); + j.set(aJ, T(0.0f)); + k.set(aK, T(1.0f)); + return *this; + } + + template Matrix3& Matrix3::set(const T& a11, const T& a12, const T& a13, + const T& a21, const T& a22, const T& a23, + const T& a31, const T& a32, const T& a33) + { + i.set(a11, a12, a13); + j.set(a21, a22, a23); + k.set(a31, a32, a33); + return *this; + } + + template inline Matrix3& Matrix3::identity() + { + return operator=(getIdentity()); + } + + template inline const Matrix3& Matrix3::getIdentity() + { + static Matrix3 identityMatrix( + T(1.0f), T(0.0f), T(0.0f), + T(0.0f), T(1.0f), T(0.0f), + T(0.0f), T(0.0f), T(1.0f)); + return identityMatrix; + } + + template inline bool Matrix3::isIdentity() const + { + return *this == getIdentity(); + } + + template inline Matrix3 Matrix3::operator-() const + { + return Matrix3(-i, -j, -k); + } + + template inline Matrix3& Matrix3::inverse() + { + static const T t0(0.0f); + static const T t1(1.0f); + + T s = determinant(); + if(EffectsEqual(s, t0)) return *this; + T inv_det(t1 / s); + return set( (j.y * k.z - k.y * j.z) * inv_det, -(i.y * k.z - k.y * i.z) * inv_det, (i.y * j.z - j.y * i.z) * inv_det, + -(j.x * k.z - k.x * j.z) * inv_det, (i.x * k.z - k.x * i.z) * inv_det, -(i.x * j.z - j.x * i.z) * inv_det, + (j.x * k.y - k.x * j.y) * inv_det, -(i.x * k.y - k.x * i.y) * inv_det, (i.x * j.y - j.x * i.y) * inv_det); + } + template inline Matrix3 Matrix3::getInversed() const + { + static const T t0(0.0f); + static const T t1(1.0f); + + T s = determinant(); + if(EffectsEqual(s, t0)) return *this; + T inv_det(t1 / s); + return Matrix3( (j.y * k.z - k.y * j.z) * inv_det, -(i.y * k.z - k.y * i.z) * inv_det, (i.y * j.z - j.y * i.z) * inv_det, + -(j.x * k.z - k.x * j.z) * inv_det, (i.x * k.z - k.x * i.z) * inv_det, -(i.x * j.z - j.x * i.z) * inv_det, + (j.x * k.y - k.x * j.y) * inv_det, -(i.x * k.y - k.x * i.y) * inv_det, (i.x * j.y - j.x * i.y) * inv_det); + } + + template inline T Matrix3::determinant() const + { + return + i.x * (j.y * k.z - j.z * k.y) + - i.y * (j.x * k.z - j.z * k.x) + + i.z * (j.x * k.y - j.y * k.x); + } + + template inline Matrix3& Matrix3::transpose() + { + EffectsSwap(i.y, j.x); + EffectsSwap(i.z, k.x); + EffectsSwap(j.z, k.y); + return *this; + } + + template inline Matrix3 Matrix3::getTransposed() const + { + return Matrix3( i.x, j.x, k.x, + i.y, j.y, k.y, + i.z, j.z, k.z); + } + + template inline T* Matrix3::getPointer() + { + return i.getPointer(); + } + + template inline const T* Matrix3::getPointer() const + { + return i.getPointer(); + } + + template inline T& Matrix3::get(unsigned int aRow, unsigned int aColumn) + { + return operator()(aRow, aColumn); + } + + template inline const T& Matrix3::get(unsigned int aRow, unsigned int aColumn) const + { + return operator()(aRow, aColumn); + } + + template inline T& Matrix3::get(unsigned int aAbsIndex) + { + return operator()(aAbsIndex); + } + + template inline const T& Matrix3::get(unsigned int aAbsIndex) const + { + return operator()(aAbsIndex); + } + + template inline _Vector3& Matrix3::getRow(unsigned int aRow) + { + switch(aRow) + { + case 1: + return j; + case 2: + return k; + } + return i; + } + + template inline const _Vector3& Matrix3::getRow(unsigned int aRow) const + { + switch(aRow) + { + case 1: + return j; + case 2: + return k; + } + return i; + } + + template inline _Vector3 Matrix3::getColumn(unsigned int aColumn) const + { + switch(aColumn) + { + case 1: + return _Vector3(i.y, j.y, k.y); + case 2: + return _Vector3(i.z, j.z, k.z); + } + + return _Vector3(i.x, j.x, k.x); + } + + template inline T& Matrix3::operator()(unsigned int aRow, unsigned int aColumn) + { + return operator[]((aRow * 3) + aColumn); + } + + template inline const T& Matrix3::operator()(unsigned int aRow, unsigned int aColumn) const + { + return operator[]((aRow * 3) + aColumn); + } + + template inline T& Matrix3::operator()(unsigned int aAbsIndex) + { + return operator[](aAbsIndex); + } + + template inline const T& Matrix3::operator()(unsigned int aAbsIndex) const + { + return operator[](aAbsIndex); + } + + template inline T& Matrix3::operator[](unsigned int aAbsIndex) + { + return getPointer()[aAbsIndex]; + } + + template inline const T& Matrix3::operator[](unsigned int aAbsIndex) const + { + return getPointer()[aAbsIndex]; + } + + template inline Matrix3& Matrix3::setColumn(unsigned int aColumn, const _Vector3& aValue) + { + switch(aColumn) + { + case 0: + i.x = aValue.x; + j.x = aValue.y; + k.x = aValue.z; + break; + case 1: + i.y = aValue.x; + j.y = aValue.y; + k.y = aValue.z; + break; + case 2: + i.z = aValue.x; + j.z = aValue.y; + k.z = aValue.z; + break; + } + + return *this; + } + + template inline Matrix3& Matrix3::setRow(unsigned int aRow, const _Vector3& aValue) + { + switch(aRow) + { + case 0: + i = aValue; + break; + case 1: + j = aValue; + break; + case 2: + k = aValue; + break; + } + + return *this; + } + + template inline Matrix3& Matrix3::set(unsigned int aRow, unsigned int aColumn, const T& aValue) + { + operator()(aRow, aColumn) = aValue; + return *this; + } + + template inline Matrix3& Matrix3::set(unsigned int aAbsIndex, const T& aValue) + { + operator()(aAbsIndex) = aValue; + return *this; + } + + + + template inline Matrix3& Matrix3::operator+=(const Matrix3& aRhv) + { + i += aRhv.i; + j += aRhv.j; + k += aRhv.k; + return *this; + } + template inline Matrix3& Matrix3::operator+=(const T& aRhv) + { + i += aRhv; + j += aRhv; + k += aRhv; + return *this; + } + template inline Matrix3& Matrix3::operator-=(const Matrix3& aRhv) + { + i -= aRhv.i; + j -= aRhv.j; + k -= aRhv.k; + return *this; + } + template inline Matrix3& Matrix3::operator-=(const T& aRhv) + { + i -= aRhv; + j -= aRhv; + k -= aRhv; + return *this; + } + template inline Matrix3& Matrix3::operator*=(const T& aRhv) + { + i *= aRhv; + j *= aRhv; + k *= aRhv; + return *this; + } + + template inline Matrix3 Matrix3::GetMultipliedByMember(const Matrix3& aRhv) const + { + return Matrix3(i * aRhv.i, j * aRhv.j, k * aRhv.k); + } + + template inline Matrix3& Matrix3::multiplyByMember(const Matrix3& aRhv) + { + i *= aRhv.i; + j *= aRhv.j; + k *= aRhv.k; + return *this; + } + + template inline Matrix3 Matrix3::createMultipliedByMember(const Matrix3& aLhv, const Matrix3& aRhv) + { + return Matrix3(aLhv.i * aRhv.i, aLhv.j * aRhv.j, aLhv.k * aRhv.k); + } + + template inline Matrix3& Matrix3::operator*=(const Matrix3& aRhv) + { + set( + i.x * aRhv.i.x + i.y * aRhv.j.x + i.z * aRhv.k.x, + i.x * aRhv.i.y + i.y * aRhv.j.y + i.z * aRhv.k.y, + i.x * aRhv.i.z + i.y * aRhv.j.z + i.z * aRhv.k.z, + + j.x * aRhv.i.x + j.y * aRhv.j.x + j.z * aRhv.k.x, + j.x * aRhv.i.y + j.y * aRhv.j.y + j.z * aRhv.k.y, + j.x * aRhv.i.z + j.y * aRhv.j.z + j.z * aRhv.k.z, + + k.x * aRhv.i.x + k.y * aRhv.j.x + k.z * aRhv.k.x, + k.x * aRhv.i.y + k.y * aRhv.j.y + k.z * aRhv.k.y, + k.x * aRhv.i.z + k.y * aRhv.j.z + k.z * aRhv.k.z); + return *this; + } + + template inline Matrix3 Matrix3::getDividedByMember(const Matrix3& aRhv) const + { + return Matrix3(i / aRhv.i, j / aRhv.j, k / aRhv.k); + } + + template inline Matrix3& Matrix3::divideByMember(const Matrix3& aRhv) + { + i /= aRhv.i; + j /= aRhv.j; + k /= aRhv.k; + return *this; + } + template inline Matrix3 Matrix3::createDividedByMember(const Matrix3& aLhv, const Matrix3& aRhv) + { + return Matrix3(aLhv.i / aRhv.i, aLhv.j / aRhv.j, aLhv.k / aRhv.k); + } + + template inline Matrix3& Matrix3::operator/=(const T& aRhv) + { + i /= aRhv; + j /= aRhv; + k /= aRhv; + return *this; + } + + + + template inline _Vector3& Matrix3::applyTransform(_Vector3& aVector) const + { + return aVector.set( + aVector.x * i.x + aVector.y * j.x + aVector.z * k.x, + aVector.x * i.y + aVector.y * j.y + aVector.z * k.y, + aVector.x * i.z + aVector.y * j.z + aVector.z * k.z); + } + + template inline _Vector3 Matrix3::getAppliedTransform(const _Vector3& aVector) const + { + return _Vector3( + aVector.x * i.x + aVector.y * j.x + aVector.z * k.x, + aVector.x * i.y + aVector.y * j.y + aVector.z * k.y, + aVector.x * i.z + aVector.y * j.z + aVector.z * k.z); + } + + template inline _Vector3& Matrix3::applyRotation(_Vector3& aVector) const + { + return aVector.set( + aVector.x * i.x + aVector.y * j.x, + aVector.x * i.y + aVector.y * j.y, + aVector.z); + } + + template inline _Vector3 Matrix3::getAppliedRotation(const _Vector3& aVector) const + { + return _Vector3( + aVector.x * i.x + aVector.y * j.x, + aVector.x * i.y + aVector.y * j.y, + aVector.z); + } + + template inline _Vector3& Matrix3::applyTranslate(_Vector3& aVector) const + { + return aVector.set( + aVector.x + aVector.z * k.x, + aVector.y + aVector.z * k.y, + aVector.z); + } + + template inline _Vector3 Matrix3::getAppliedTranslate(const _Vector3& aVector) const + { + return _Vector3( + aVector.x + aVector.z * k.x, + aVector.y + aVector.z * k.y, + aVector.z); + } + + template inline _Vector2& Matrix3::applyTransform(_Vector2& aVector) const + { + return aVector.set( + aVector.x * i.x + aVector.y * j.x + k.x, + aVector.x * i.y + aVector.y * j.y + k.y); + } + + template inline _Vector2 Matrix3::getAppliedTransform(const _Vector2& aVector) const + { + return _Vector2( + aVector.x * i.x + aVector.y * j.x + k.x, + aVector.x * i.y + aVector.y * j.y + k.y); + } + + template inline _Vector2& Matrix3::applyRotation(_Vector2& aVector) const + { + return aVector.set( + aVector.x * i.x + aVector.y * j.x, + aVector.x * i.y + aVector.y * j.y); + } + + template inline _Vector2 Matrix3::getAppliedRotation(const _Vector2& aVector) const + { + return _Vector2( + aVector.x * i.x + aVector.y * j.x, + aVector.x * i.y + aVector.y * j.y); + } + + template inline _Vector2& Matrix3::applyTranslate(_Vector2& aVector) const + { + return aVector.set( + aVector.x + k.x, + aVector.y + k.y); + } + + template inline _Vector2 Matrix3::getAppliedTranslate(const _Vector2& aVector) const + { + return _Vector2( + aVector.x + k.x, + aVector.y + k.y); + } + + template inline Matrix3& Matrix3::setRotation(const T& aAngleRAD) + { + const T s = effects_sin(aAngleRAD); + const T c = effects_cos(aAngleRAD); + i.x = c; + i.y = s; + j.x = -s; + j.y = c; + return *this; + } + template inline Matrix3& Matrix3::setRotation(const Matrix2& aRotation) + { + i.x = aRotation.i.x; + i.y = aRotation.i.y; + j.x = aRotation.j.x; + j.y = aRotation.j.y; + return *this; + } + template inline Matrix3& Matrix3::setRotation(const Matrix3& aRotation) + { + i.x = aRotation.i.x; + i.y = aRotation.i.y; + j.x = aRotation.j.x; + j.y = aRotation.j.y; + return *this; + } + template inline Matrix3& Matrix3::makeRotation(const T& aAngleRAD) + { + identity(); + return setRotation(aAngleRAD); + } + template inline Matrix3& Matrix3::makeRotation(const Matrix2& aRotation) + { + identity(); + return setRotation(aRotation); + } + template inline Matrix3& Matrix3::makeRotation(const Matrix3& aRotation) + { + identity(); + return setRotation(aRotation); + } + template inline Matrix3& Matrix3::rotate(const T& aAngleRAD) + { + const T s = effects_sin(aAngleRAD); + const T c = effects_cos(aAngleRAD); + const T ix = i.x * c - i.y * s; + const T iy = i.x * s + i.y * c; + const T jx = j.x * c - j.y * s; + const T jy = j.x * s + j.y * c; + i.x = ix; + i.y = iy; + j.x = jx; + j.y = jy; + return *this; + } + template inline Matrix3& Matrix3::rotate(const Matrix2& aRotation) + { + const T ix = i.x * aRotation.i.x + i.y * aRotation.j.x; + const T iy = i.x * aRotation.i.y + i.y * aRotation.j.y; + const T jx = j.x * aRotation.i.x + j.y * aRotation.j.x; + const T jy = j.x * aRotation.i.y + j.y * aRotation.j.y; + i.x = ix; + i.y = iy; + j.x = jx; + j.y = jy; + return *this; + } + template inline Matrix3& Matrix3::rotate(const Matrix3& aRotation) + { + const T ix = i.x * aRotation.i.x + i.y * aRotation.j.x; + const T iy = i.x * aRotation.i.y + i.y * aRotation.j.y; + const T jx = j.x * aRotation.i.x + j.y * aRotation.j.x; + const T jy = j.x * aRotation.i.y + j.y * aRotation.j.y; + i.x = ix; + i.y = iy; + j.x = jx; + j.y = jy; + return *this; + } + template inline Matrix3 Matrix3::createRotation(const T& aAngleRAD) + { + return Matrix3().makeRotation(aAngleRAD); + } + template inline Matrix3 Matrix3::createRotation(const Matrix2& aRotation) + { + return Matrix3().makeRotation(aRotation); + } + template inline Matrix3 Matrix3::createRotation(const Matrix3& aRotation) + { + return Matrix3().makeRotation(aRotation); + } + template inline Matrix2 Matrix3::getRotation() const + { + return Matrix2(i.x, i.y, j.x, j.y); + } + template inline T Matrix3::getRotationAngle() const + { + static const T t0(0.0f); + static const T t1(1.0f); + + static const _Vector2 orig_vector(t1, t0); + static const _Vector2 orig_vector_cross(t0, t1); + + _Vector2 rotated(getAppliedRotation(orig_vector).normalize()); + const T angleCos = effects_clamp(rotated.dot(orig_vector), -t1, t1); + const T angleCosCross = effects_clamp(rotated.dot(orig_vector_cross), -t1, t1); + + if(angleCosCross > t0) + return effects_acos(angleCos); + return -effects_acos(angleCos); + } + + template inline Matrix3& Matrix3::makeScale(const T& aX, const T& aY) + { + identity(); + return setScale(aX, aY); + } + template inline Matrix3& Matrix3::makeScale(const _Vector2& aScale) + { + return makeScale(aScale.x, aScale.y); + } + template inline Matrix3 Matrix3::createScale(const T& aX, const T& aY) + { + return Matrix3().makeScale(aX, aY); + } + template inline Matrix3 Matrix3::createScale(const _Vector2& aScale) + { + return Matrix3().makeScale(aScale); + } + template inline Matrix3& Matrix3::setScale(const T& aX, const T& aY) + { + i.x = aX; + j.y = aY; + + i.y = j.x = T(0.0f); + return *this; + } + template inline Matrix3& Matrix3::setScale(const _Vector2& aScale) + { + return setScale(aScale.x, aScale.y); + } + template inline Matrix3& Matrix3::scale(const T& aX, const T& aY) + { + i.x *= aX; i.y *= aY; + j.x *= aX; j.y *= aY; + + return *this; + } + template inline Matrix3& Matrix3::scale(const _Vector2& aScale) + { + return scale(aScale.x, aScale.y); + } + + template inline Matrix3& Matrix3::setTranslation(const T& aX, const T& aY) + { + k.x = aX; + k.y = aY; + return *this; + } + template inline Matrix3& Matrix3::setTranslation(const _Vector2& aTran) + { + return setTranslation(aTran.x, aTran.y); + } + template inline Matrix3& Matrix3::makeTranslation(const T& aX, const T& aY) + { + identity(); + return setTranslation(aX, aY); + } + template inline Matrix3& Matrix3::makeTranslation(const _Vector2& aTran) + { + return makeTranslation(aTran.x, aTran.y); + } + template inline Matrix3 Matrix3::createTranslation(const T& aX, const T& aY) + { + return Matrix3().makeTranslation(aX, aY); + } + template inline Matrix3 Matrix3::createTranslation(const _Vector2& aTran) + { + return Matrix3().makeTranslation(aTran); + } + template inline Matrix3& Matrix3::translate(const T& aX, const T& aY) + { + k.x += aX; + k.y += aY; + return *this; + } + template inline Matrix3& Matrix3::translate(const _Vector2& aTran) + { + return translate(aTran.x, aTran.y); + } + template inline _Vector2 Matrix3::getTranslation() const + { + return k.swizzle(0, 1); + } + template inline _Vector3 Matrix3::getFullTranslation() const + { + return k; + } + + template inline Matrix3& Matrix3::lerp(const Matrix3& aTo, const T& aCoeff) + { + i.lerp(aTo.i, aCoeff); + j.lerp(aTo.j, aCoeff); + k.lerp(aTo.k, aCoeff); + return *this; + } + + template inline Matrix3 Matrix3::getLerped(const Matrix3& aTo, const T& aCoeff) const + { + Matrix3 result(i.getLerped(aTo.i, aCoeff), + j.getLerped(aTo.j, aCoeff), + k.getLerped(aTo.k, aCoeff)); + return result; + } + + template inline Matrix3& Matrix3::makeLerped(const Matrix3& aFrom, const Matrix3& aTo, const T& aCoeff) + { + i.makeLerped(aFrom.i, aTo.i, aCoeff); + j.makeLerped(aFrom.j, aTo.j, aCoeff); + k.makeLerped(aFrom.k, aTo.k, aCoeff); + return *this; + } + template inline Matrix3 Matrix3::createLerped(const Matrix3& aFrom, const Matrix3& aTo, const T& aCoeff) + { + return Matrix3().makeLerped(aFrom, aTo, aCoeff); + } + + template inline Matrix3& Matrix3::slerp(const Matrix3& aTo, const T& aCoeff) + { + setRotation(effects_lerp(getRotationAngle(), aTo.getRotationAngle(), aCoeff)); + k.lerp(aTo.k, aCoeff); + return *this; + } + + template inline Matrix3 Matrix3::getSlerped(const Matrix3& aTo, const T& aCoeff) const + { + Matrix3 result; + result.makeRotation(effects_lerp(getRotationAngle(), aTo.getRotationAngle(), aCoeff)); + result.k = k.getLerped(aTo.k, aCoeff); + return result; + } + + template inline Matrix3& Matrix3::makeSlerped(const Matrix3& aFrom, const Matrix3& aTo, const T& aCoeff) + { + makeRotation(effects_lerp(aFrom.getRotationAngle(), aTo.getRotationAngle(), aCoeff)); + k.makeLerped(aFrom.k, aTo.k, aCoeff); + return *this; + } + + template inline Matrix3 Matrix3::createSlerped(const Matrix3& aFrom, const Matrix3& aTo, const T& aCoeff) + { + return Matrix3().makeSlerped(aFrom, aTo, aCoeff); + } + + template inline T Matrix3::magnitude_sqr() const + { + return i.dot(i) + j.dot(j) + k.dot(k); + } + template inline T Matrix3::magnitude() const + { + return effects_sqrt(magnitude_sqr()); + } + template inline T Matrix3::trace() const + { + return i.x + j.y + k.z; + } + template inline Matrix2 Matrix3::minorMatrix(int row, int column) const + { + Matrix2 result; + + int row_counter = 0; + int column_counter = 0; + for(int current_row = 0; 3 > current_row; ++current_row) + { + if(current_row == row) + continue; + + column_counter = 0; + for(int current_column = 0; 3 > current_column; ++current_column) + { + if(current_column == column) + continue; + + result(row_counter, column_counter) = this->operator()(current_row, current_column); + ++column_counter; + } + ++row_counter; + } + return result; + } + template inline Matrix3& Matrix3::makeCross(const _Vector3& aVector) + { + static const T t0(0.0f); + + return set( t0, -aVector.z, aVector.y, + aVector.z, t0, -aVector.x, + -aVector.y, aVector.x, t0); + } + template inline Matrix3 Matrix3::createCross(const _Vector3& aVector) + { + return Matrix3().makeCross(aVector); + } + + template inline const Matrix3& Matrix3::QR_Decomposition(Matrix3& aQ, Matrix3& aR) const + { + aR.set(0, 0, 0, 0, 0, 0, 0, 0, 0); + + aQ = *this; + + for (int k = 0; k < 3; ++k) + { + for (int i = 0; i < k; ++i) + { + _Vector3 v1 = aQ.getColumn(i); + _Vector3 v2 = aQ.getColumn(k); + aR(i, k) = v1.dot(v2); + + _Vector3 v3 = aR(i, k) * v1; + _Vector3 v4 = v2 - v3; + aQ.setColumn(k, v4); + } + + _Vector3 qv1 = aQ.getColumn(k); + aR(k, k) = qv1.length(); + + _Vector3 qv2 = qv1 / aR(k, k); + aQ.setColumn(k, qv2); + } + + return *this; + } + + template inline bool isEqual(const Matrix3& aLhv, const Matrix3& aRhv, const T& aEpsilon = effects_epsilon::epsilon()) + { + return isEqual(aLhv.i, aRhv.i, aEpsilon) && isEqual(aLhv.j, aRhv.j, aEpsilon) && isEqual(aLhv.k, aRhv.k, aEpsilon); + } + template inline Matrix3 operator+(const Matrix3& aLhv, const Matrix3& aRhv) + { + return Matrix3(aLhv.i + aRhv.i, aLhv.j + aRhv.j, aLhv.k + aRhv.k); + } + template inline Matrix3 operator+(const Matrix3& aLhv, const T& aRhv) + { + return Matrix3(aLhv.i + aRhv, aLhv.j + aRhv, aLhv.k + aRhv); + } + template inline Matrix3 operator+(const T& aLhv, const Matrix3& aRhv) + { + return Matrix3(aLhv + aRhv.i, aLhv + aRhv.j, aLhv + aRhv.k); + } + template inline Matrix3 operator-(const Matrix3& aLhv, const Matrix3& aRhv) + { + return Matrix3(aLhv.i - aRhv.i, aLhv.j - aRhv.j, aLhv.k - aRhv.k); + } + template inline Matrix3 operator-(const Matrix3& aLhv, const T& aRhv) + { + return Matrix3(aLhv.i - aRhv, aLhv.j - aRhv, aLhv.k - aRhv); + } + template inline Matrix3 operator-(const T& aLhv, const Matrix3& aRhv) + { + return Matrix3(aLhv - aRhv.i, aLhv - aRhv.j, aLhv - aRhv.k); + } + template inline Matrix3 operator*(const Matrix3& aLhv, const Matrix3& aRhv) + { + return Matrix3( + aLhv.i.x * aRhv.i.x + aLhv.i.y * aRhv.j.x + aLhv.i.z * aRhv.k.x, + aLhv.i.x * aRhv.i.y + aLhv.i.y * aRhv.j.y + aLhv.i.z * aRhv.k.y, + aLhv.i.x * aRhv.i.z + aLhv.i.y * aRhv.j.z + aLhv.i.z * aRhv.k.z, + + aLhv.j.x * aRhv.i.x + aLhv.j.y * aRhv.j.x + aLhv.j.z * aRhv.k.x, + aLhv.j.x * aRhv.i.y + aLhv.j.y * aRhv.j.y + aLhv.j.z * aRhv.k.y, + aLhv.j.x * aRhv.i.z + aLhv.j.y * aRhv.j.z + aLhv.j.z * aRhv.k.z, + + aLhv.k.x * aRhv.i.x + aLhv.k.y * aRhv.j.x + aLhv.k.z * aRhv.k.x, + aLhv.k.x * aRhv.i.y + aLhv.k.y * aRhv.j.y + aLhv.k.z * aRhv.k.y, + aLhv.k.x * aRhv.i.z + aLhv.k.y * aRhv.j.z + aLhv.k.z * aRhv.k.z); + } + template inline Matrix3 operator*(const Matrix3& aLhv, const T& aRhv) + { + return Matrix3(aLhv.i * aRhv, aLhv.j * aRhv, aLhv.k * aRhv); + } + template inline Matrix3 operator*(const T& aLhv, const Matrix3& aRhv) + { + return Matrix3(aLhv * aRhv.i, aLhv * aRhv.j, aLhv * aRhv.k); + } + template inline _Vector3 operator*(const _Vector3& aLhv, const Matrix3& aRhv) + { + return aRhv.getAppliedTransform(aLhv); + } + template inline _Vector3 operator*(const Matrix3& aLhv, const _Vector3& aRhv) + { + return _Vector3( aLhv.i.x * aRhv.x + aLhv.i.y * aRhv.y + aLhv.i.z * aRhv.z, + aLhv.j.x * aRhv.x + aLhv.j.y * aRhv.y + aLhv.j.z * aRhv.z, + aLhv.k.x * aRhv.x + aLhv.k.y * aRhv.y + aLhv.k.z * aRhv.z); + } + template inline _Vector2 operator*(const _Vector2& aLhv, const Matrix3& aRhv) + { + return aRhv.getAppliedTransform(aLhv); + } + template inline _Vector2 operator*(const Matrix3& aLhv, const _Vector2& aRhv) + { + return _Vector2( aLhv.i.x * aRhv.x + aLhv.i.y * aRhv.y + aLhv.i.z, + aLhv.j.x * aRhv.x + aLhv.j.y * aRhv.y + aLhv.j.z); + } + template inline Matrix3 operator/(const Matrix3& aLhv, const T& aRhv) + { + return Matrix3(aLhv.i / aRhv, aLhv.j / aRhv, aLhv.k / aRhv); + } + template inline Matrix3 operator/(const T& aLhv, const Matrix3& aRhv) + { + return Matrix3(aLhv / aRhv.i, aLhv / aRhv.j, aLhv / aRhv.k); + } + template inline bool operator==(const Matrix3& aLhv, const Matrix3& aRhv) + { + return aLhv.i == aRhv.i && aLhv.j == aRhv.j && aLhv.k == aRhv.k; + } + template inline bool operator==(const Matrix3& aLhv, const T& aRhv) + { + return aLhv.i == aRhv && aLhv.j == aRhv && aLhv.k == aRhv; + } + template inline bool operator==(const T& aLhv, const Matrix3& aRhv) + { + return aLhv == aRhv.i && aLhv == aRhv.j && aLhv == aRhv.k; + } + template inline bool operator!=(const Matrix3& aLhv, const Matrix3& aRhv) + { + return !(aLhv == aRhv); + } + template inline bool operator!=(const Matrix3& aLhv, const T& aRhv) + { + return !(aLhv == aRhv); + } + template inline bool operator!=(const T& aLhv, const Matrix3& aRhv) + { + return !(aLhv == aRhv); + } +} } } } //Tizen::Ui::Effects::_Utils + +#endif //_FUI_EFFECTS_INTERNAL_UTILS_MATRIX3_H_ diff --git a/src/ui/effects/inc/utils/FUiEffects_UtilsMatrix4.h b/src/ui/effects/inc/utils/FUiEffects_UtilsMatrix4.h new file mode 100644 index 0000000..05a0b4e --- /dev/null +++ b/src/ui/effects/inc/utils/FUiEffects_UtilsMatrix4.h @@ -0,0 +1,1833 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_UtilsMatrix4.h + * @brief The Matrix4 class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_UTILS_MATRIX4_H_ +#define _FUI_EFFECTS_INTERNAL_UTILS_MATRIX4_H_ + +#include "FUiEffects_UtilsAdapterFunctions.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Utils +{ + template class Vector4; + template class _Vector3; + template class Matrix3; + template class Quaternion; + + template class Matrix4 + { + private: + typedef Matrix4 SelfType; + + public: + Vector4 i; + Vector4 j; + Vector4 k; + Vector4 c; + + inline Matrix4(); + inline explicit Matrix4(const T& aValue); + inline explicit Matrix4(const T* aValues); + inline Matrix4(const SelfType& aOther); + inline Matrix4(const Vector4& aI, const Vector4& aJ, + const Vector4& aK, const Vector4& aC); + inline Matrix4(const _Vector3& aI, const _Vector3& aJ, + const _Vector3& aK, const _Vector3& aC); + inline Matrix4(const T& a11, const T& a12, const T& a13, const T& a14, + const T& a21, const T& a22, const T& a23, const T& a24, + const T& a31, const T& a32, const T& a33, const T& a34, + const T& a41, const T& a42, const T& a43, const T& a44); + + inline SelfType& operator=(const SelfType& aRhv); + + inline SelfType& set(const T& aValue); + inline SelfType& set(const T* aValues); + inline SelfType& set(const SelfType& aOther); + inline SelfType& set(const Vector4& aI, const Vector4& aJ, + const Vector4& aK, const Vector4& aC); + inline SelfType& set(const _Vector3& aI, const _Vector3& aJ, + const _Vector3& aK, const _Vector3& aC); + inline SelfType& set(const T& a11, const T& a12, const T& a13, const T& a14, + const T& a21, const T& a22, const T& a23, const T& a24, + const T& a31, const T& a32, const T& a33, const T& a34, + const T& a41, const T& a42, const T& a43, const T& a44); + + inline SelfType& identity(); + inline static const SelfType& getIdentity(); + inline bool isIdentity() const; + + inline SelfType operator-() const; + inline SelfType& inverse(); + inline SelfType getInversed() const; + inline SelfType& transpose(); + inline SelfType getTransposed() const; + + inline SelfType& operator+=(const SelfType& aRhv); + inline SelfType& operator+=(const T& aRhv); + inline SelfType& operator-=(const SelfType& aRhv); + inline SelfType& operator-=(const T& aRhv); + inline SelfType& operator*=(const SelfType& aRhv); + inline SelfType& operator*=(const T& aRhv); + inline SelfType& operator/=(const T& aRhv); + inline SelfType GetMultipliedByMember(const SelfType& aRhv) const; + inline SelfType& multiplyByMember(const SelfType& aRhv); + static inline SelfType createMultipliedByMember(const SelfType& aLhv, const SelfType& aRhv); + inline SelfType getDividedByMember(const SelfType& aRhv) const; + inline SelfType& divideByMember(const SelfType& aRhv); + static inline SelfType createDividedByMember(const SelfType& aLhv, const SelfType& aRhv); + + inline T* getPointer(); + inline const T* getPointer() const; + inline T& get(unsigned int aRow, unsigned int aColumn); + inline const T& get(unsigned int aRow, unsigned int aColumn) const; + inline T& get(unsigned int aAbsIndex); + inline const T& get(unsigned int aAbsIndex) const; + inline SelfType& set(unsigned int aRow, unsigned int aColumn, const T& aValue); + inline SelfType& set(unsigned int aAbsIndex, const T& aValue); + inline Vector4& getRow(unsigned int aRow); + inline const Vector4& getRow(unsigned int aRow) const; + inline SelfType& setRow(unsigned int aRow, const Vector4& aValue); + inline Vector4 getColumn(unsigned int aColumn) const; + inline SelfType& setColumn(unsigned int aColumn, const Vector4& aValue); + inline T& operator()(unsigned int aRow, unsigned int aColumn); + inline const T& operator()(unsigned int aRow, unsigned int aColumn) const; + inline T& operator()(unsigned int aAbsIndex); + inline const T& operator()(unsigned int aAbsIndex) const; + inline T& operator[](unsigned int aAbsIndex); + inline const T& operator[](unsigned int aAbsIndex) const; + + inline SelfType& lerp(const SelfType& aTo, const T& aCoeff); + inline SelfType getLerped(const SelfType& aTo, const T& aCoeff) const; + inline SelfType& makeLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + static inline SelfType createLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + inline SelfType& slerp(const SelfType& aTo, const T& aCoeff); + inline SelfType getSlerped(const SelfType& aTo, const T& aCoeff) const; + inline SelfType& makeSlerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + static inline SelfType createSlerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + + inline T determinant() const; + + inline Vector4& applyTransform(Vector4& aVector) const; + inline Vector4 getAppliedTransform(const Vector4& aVector) const; + inline Vector4& applyRotation(Vector4& aVector) const; + inline Vector4 getAppliedRotation(const Vector4& aVector) const; + inline Vector4& applyTranslate(Vector4& aVector) const; + inline Vector4 getAppliedTranslate(const Vector4& aVector) const; + + inline _Vector3& applyTransform(_Vector3& aVector) const; + inline _Vector3 getAppliedTransform(const _Vector3& aVector) const; + inline _Vector3& applyRotation(_Vector3& aVector) const; + inline _Vector3 getAppliedRotation(const _Vector3& aVector) const; + inline _Vector3& applyTranslate(_Vector3& aVector) const; + inline _Vector3 getAppliedTranslate(const _Vector3& aVector) const; + + inline Quaternion& applyRotation(Quaternion& aQuaternion) const; + inline Quaternion getAppliedRotation(const Quaternion& aQuaternion) const; + + inline SelfType& setRotation(const T& aXAngleRAD, const T& aYAngleRAD, const T& aZAngleRAD, RotationOrder3 aOrder = ROTATION_XYZ); + inline SelfType& setRotation(const _Vector3& aAnglesRAD, RotationOrder3 aOrder = ROTATION_XYZ); + inline SelfType& setRotationX(const T& aAngleRAD); + inline SelfType& setRotationY(const T& aAngleRAD); + inline SelfType& setRotationZ(const T& aAngleRAD); + inline SelfType& setRotationAxis(const _Vector3& aAxis, const T& aAngleRAD); + inline SelfType& setRotationAxis(const T& aXAxis, const T& aYAxis, const T& aZAxis, const T& aAngleRAD); + inline SelfType& setRotation(const Quaternion& aRotation); + inline SelfType& setRotation(const Matrix3& aRotation); + inline SelfType& makeRotation(const T& aXAngleRAD, const T& aYAngleRAD, const T& aZAngleRAD, RotationOrder3 aOrder = ROTATION_XYZ); + inline SelfType& makeRotation(const _Vector3& aAnglesRAD, RotationOrder3 aOrder = ROTATION_XYZ); + inline SelfType& makeRotationX(const T& aAngleRAD); + inline SelfType& makeRotationY(const T& aAngleRAD); + inline SelfType& makeRotationZ(const T& aAngleRAD); + inline SelfType& makeRotationAxis(const _Vector3& aAxis, const T& aAngleRAD); + inline SelfType& makeRotationAxis(const T& aXAxis, const T& aYAxis, const T& aZAxis, const T& aAngleRAD); + inline SelfType& makeRotation(const Quaternion& aRotation); + inline SelfType& makeRotation(const Matrix3& aRotation); + inline SelfType& rotate(const T& aXAngleRAD, const T& aYAngleRAD, const T& aZAngleRAD, RotationOrder3 aOrder = ROTATION_XYZ); + inline SelfType& rotate(const _Vector3& aAnglesRAD, RotationOrder3 aOrder3 = ROTATION_XYZ); + inline SelfType& rotateX(const T& aAngleRAD); + inline SelfType& rotateY(const T& aAngleRAD); + inline SelfType& rotateZ(const T& aAngleRAD); + inline SelfType& rotateAxis(const _Vector3& aAxis, const T& aAngleRAD); + inline SelfType& rotateAxis(const T& aXAxis, const T& aYAxis, const T& aZAxis, const T& aAngleRAD); + inline SelfType& rotate(const Quaternion& aRotation); + inline SelfType& rotate(const Matrix3& aRotation); + inline SelfType& rotate(const Matrix4& aRotation); + static inline SelfType createRotation(const T& aXAngleRAD, const T& aYAngleRAD, const T& aZAngleRAD, RotationOrder3 aOrder = ROTATION_XYZ); + static inline SelfType createRotation(const _Vector3& aAnglesRAD, RotationOrder3 aOrder = ROTATION_XYZ); + static inline SelfType createRotationX(const T& aAngleRAD); + static inline SelfType createRotationY(const T& aAngleRAD); + static inline SelfType createRotationZ(const T& aAngleRAD); + static inline SelfType createRotationAxis(const _Vector3& aAxis, const T& aAngleRAD); + static inline SelfType createRotationAxis(const T& aXAxis, const T& aYAxis, const T& aZAxis, const T& aAngleRAD); + static inline SelfType createRotation(const Quaternion& aRotation); + static inline SelfType createRotation(const Matrix3& aRotation); + inline const SelfType& getRotationAngles(T& aXAngleRAD, T& aYAngeRAD, T& aZAngleRAD, unsigned int aSolutionNumber = 1) const; + inline Quaternion getQuaternion() const; + inline Quaternion& getQuaternion(Quaternion& aRotation) const; + inline Matrix3 getRotation() const; + inline Matrix3& getRotation(Matrix3& aRotation) const; + + inline SelfType& makeScale(const T& aX, const T& aY, const T& aZ); + inline SelfType& makeScale(const _Vector3& aScale); + inline SelfType& setScale(const T& aX, const T& aY, const T& aZ); + inline SelfType& setScale(const _Vector3& aScale); + static inline SelfType createScale(const T& aX, const T& aY, const T& aZ); + static inline SelfType createScale(const _Vector3& aScale); + inline SelfType& scale(const T& aX, const T& aY, const T& aZ); + inline SelfType& scale(const _Vector3& aScale); + + inline SelfType& setTranslation(const T& aX, const T& aY, const T& aZ); + inline SelfType& setTranslation(const _Vector3& aTran); + inline SelfType& makeTranslation(const T& aX, const T& aY, const T& aZ); + inline SelfType& makeTranslation(const _Vector3& aTran); + inline SelfType& translate(const T& aX, const T& aY, const T& aZ); + inline SelfType& translate(const _Vector3& aTran); + static inline SelfType createTranslation(const T& aX, const T& aY, const T& aZ); + static inline SelfType createTranslation(const _Vector3& aTran); + inline _Vector3 getTranslation() const; + inline Vector4 getFullTranslation() const; + + inline SelfType& makeLookAtLH(const _Vector3& aEye, const _Vector3& aAt, const _Vector3& aUp); + inline SelfType& makeLookAtRH(const _Vector3& aEye, const _Vector3& aAt, const _Vector3& aUp); + inline SelfType& makeOrthoRH(const T& aWidth, const T& aHeight, const T& aZNear, const T& aZFar); + inline SelfType& makeOrthoLH(const T& aWidth, const T& aHeight, const T& aZNear, const T& aZFar); + inline SelfType& makeOrthoRH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar); + inline SelfType& makeOrthoLH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar); + inline SelfType& makePerspectiveLH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar); + inline SelfType& makePerspectiveRH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar); + inline SelfType& makePerspectiveLH(const T& aWidth, const T& aHeight, const T& aZnear, const T& aZFar); + inline SelfType& makePerspectiveRH(const T& aWidth, const T& aHeight, const T& aZnear, const T& aZFar); + inline SelfType& makePerspectiveFovLH(const T& aFovY, const T& aAspect, const T& aZnear, const T& aZFar); + inline SelfType& makePerspectiveFovRH(const T& aFovY, const T& aAspect, const T& aZnear, const T& aZFar); + static inline SelfType createLookAtLH(const _Vector3& aEye, const _Vector3& aAt, const _Vector3& aUp); + static inline SelfType createLookAtRH(const _Vector3& aEye, const _Vector3& aAt, const _Vector3& aUp); + static inline SelfType createOrthoRH(const T& aWidth, const T& aHeight, const T& aZNear, const T& aZFar); + static inline SelfType createOrthoLH(const T& aWidth, const T& aHeight, const T& aZNear, const T& aZFar); + static inline SelfType createOrthoRH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar); + static inline SelfType createOrthoLH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar); + static inline SelfType createPerspectiveLH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar); + static inline SelfType createPerspectiveRH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar); + static inline SelfType createPerspectiveLH(const T& aWidth, const T& aHeight, const T& aZnear, const T& aZFar); + static inline SelfType createPerspectiveRH(const T& aWidth, const T& aHeight, const T& aZnear, const T& aZFar); + static inline SelfType createPerspectiveFovLH(const T& aFovY, const T& aAspect, const T& aZnear, const T& aZFar); + static inline SelfType createPerspectiveFovRH(const T& aFovY, const T& aAspect, const T& aZnear, const T& aZFar); + + inline bool getOrthoParamsRH(T& aLeft, T& aRight, T& aTop, T& aBottom, T& aZNear, T& aZFar) const; + inline bool getPerspectiveParamsRH(T& aLeft, T& aRight, T& aTop, T& aBottom, T& aZNear, T& aZFar) const; + inline bool getPerspectiveParamsRH(T& aFovY, T& aAspect, T& aZNear, T& aZFar) const; + inline bool getViewParams(_Vector3& aPosition, _Vector3& aDirection, _Vector3& aUp, _Vector3& aRight) const; + }; + + typedef Matrix4 Mat4f; + typedef Matrix4 Mat4d; + + template inline Matrix4 operator+(const Matrix4& aLhv, const Matrix4& aRhv); + template inline Matrix4 operator+(const Matrix4& aLhv, const T& aRhv); + template inline Matrix4 operator+(const T& aLhv, const Matrix4& aRhv); + template inline Matrix4 operator-(const Matrix4& aLhv, const Matrix4& aRhv); + template inline Matrix4 operator-(const Matrix4& aLhv, const T& aRhv); + template inline Matrix4 operator-(const T& aLhv, const Matrix4& aRhv); + template inline Matrix4 operator*(const Matrix4& aLhv, const Matrix4& aRhv); + template inline Matrix4 operator*(const Matrix4& aLhv, const T& aRhv); + template inline Matrix4 operator*(const T& aLhv, const Matrix4& aRhv); + template inline Vector4 operator*(const Matrix4& aLhv, const Vector4& aRhv); + template inline Vector4 operator*(const Vector4& aLhv, const Matrix4& aRhv); + template inline _Vector3 operator*(const Matrix4& aLhv, const _Vector3& aRhv); + template inline _Vector3 operator*(const _Vector3& aLhv, const Matrix4& aRhv); + template inline Matrix4 operator/(const Matrix4& aLhv, const T& aRhv); + template inline Matrix4 operator/(const T& aLhv, const Matrix4& aRhv); + template inline bool operator==(const Matrix4& aLhv, const Matrix4& aRhv); + template inline bool operator==(const Matrix4& aLhv, const T& aRhv); + template inline bool operator==(const T& aLhv, const Matrix4& aRhv); + template inline bool operator!=(const Matrix4& aLhv, const Matrix4& aRhv); + template inline bool operator!=(const Matrix4& aLhv, const T& aRhv); + template inline bool operator!=(const T& aLhv, const Matrix4& aRhv); + + template inline Matrix4::Matrix4() {} + + template inline Matrix4::Matrix4(const T& aValue): + i(aValue), j(aValue), k(aValue), c(aValue) {} + + template inline Matrix4::Matrix4(const T* aValues): + i(aValues[0], aValues[1], aValues[2], aValues[3]), + j(aValues[4], aValues[5], aValues[6], aValues[7]), + k(aValues[8], aValues[9], aValues[10], aValues[11]), + c(aValues[12], aValues[13], aValues[14], aValues[15]) {} + + template inline Matrix4::Matrix4(const Matrix4& aOther): + i(aOther.i), j(aOther.j), k(aOther.k), c(aOther.c) {} + + template inline Matrix4::Matrix4(const Vector4& aI, const Vector4& aJ, const Vector4& aK, const Vector4& aC): + i(aI), j(aJ), k(aK), c(aC) {} + + template inline Matrix4::Matrix4(const _Vector3& aI, const _Vector3& aJ, const _Vector3& aK, const _Vector3& aC): + i(aI, T(0.0f)), j(aJ, T(0.0f)), k(aK, T(0.0f)), c(aC, T(1.0f)) {} + + template inline Matrix4::Matrix4(const T& a11, const T& a12, const T& a13, const T& a14, + const T& a21, const T& a22, const T& a23, const T& a24, + const T& a31, const T& a32, const T& a33, const T& a34, + const T& a41, const T& a42, const T& a43, const T& a44): + i(a11, a12, a13, a14), j(a21, a22, a23, a24), k(a31, a32, a33, a34), c(a41, a42, a43, a44) {} + + template inline Matrix4& Matrix4::operator=(const Matrix4& aRhv) + { + i = aRhv.i; + j = aRhv.j; + k = aRhv.k; + c = aRhv.c; + return *this; + } + + template inline Matrix4& Matrix4::set(const T& aValue) + { + i.set(aValue); + j.set(aValue); + k.set(aValue); + c.set(aValue); + return *this; + } + + template inline Matrix4& Matrix4::set(const T* aValues) + { + i.set(aValues[0], aValues[1], aValues[2], aValues[3]); + j.set(aValues[4], aValues[5], aValues[6], aValues[7]); + k.set(aValues[8], aValues[9], aValues[10], aValues[11]); + c.set(aValues[12], aValues[13], aValues[14], aValues[15]); + return *this; + } + + template inline Matrix4& Matrix4::set(const Matrix4& aOther) + { + i = aOther.i; + j = aOther.j; + k = aOther.k; + c = aOther.c; + return *this; + } + + template inline Matrix4& Matrix4::set(const Vector4& aI, const Vector4& aJ, + const Vector4& aK, const Vector4& aC) + { + i = aI; + j = aJ; + k = aK; + c = aC; + return *this; + } + + template inline Matrix4& Matrix4::set(const _Vector3& aI, const _Vector3& aJ, + const _Vector3& aK, const _Vector3& aC) + { + i.set(aI, T(0.0f)); + j.set(aJ, T(0.0f)); + k.set(aK, T(0.0f)); + c.set(aC, T(1.0f)); + return *this; + } + + template inline Matrix4& Matrix4::set(const T& a11, const T& a12, const T& a13, const T& a14, + const T& a21, const T& a22, const T& a23, const T& a24, + const T& a31, const T& a32, const T& a33, const T& a34, + const T& a41, const T& a42, const T& a43, const T& a44) + { + i.set(a11, a12, a13, a14); + j.set(a21, a22, a23, a24); + k.set(a31, a32, a33, a34); + c.set(a41, a42, a43, a44); + return *this; + } + + template inline Matrix4& Matrix4::identity() + { + return operator=(getIdentity()); + } + + template inline const Matrix4& Matrix4::getIdentity() + { + static Matrix4 identityMatrix( + T(1.0f), T(0.0f), T(0.0f), T(0.0f), + T(0.0f), T(1.0f), T(0.0f), T(0.0f), + T(0.0f), T(0.0f), T(1.0f), T(0.0f), + T(0.0f), T(0.0f), T(0.0f), T(1.0f)); + return identityMatrix; + } + + template inline Matrix4 Matrix4::operator-() const + { + return Matrix4(-i, -j, -k, -c); + } + + template inline Matrix4& Matrix4::inverse() + { + static const T t0(0.0f); + + T s = determinant(); + if(EffectsEqual(s, t0)) return *this; + set( + (j.y*(k.z*c.w - k.w*c.z) + j.z*(k.w*c.y - k.y*c.w) + j.w*(k.y*c.z - k.z*c.y)) / s, + (k.y*(i.z*c.w - i.w*c.z) + k.z*(i.w*c.y - i.y*c.w) + k.w*(i.y*c.z - i.z*c.y)) / s, + (c.y*(i.z*j.w - i.w*j.z) + c.z*(i.w*j.y - i.y*j.w) + c.w*(i.y*j.z - i.z*j.y)) / s, + (i.y*(j.w*k.z - j.z*k.w) + i.z*(j.y*k.w - j.w*k.y) + i.w*(j.z*k.y - j.y*k.z)) / s, + (j.z*(k.x*c.w - k.w*c.x) + j.w*(k.z*c.x - k.x*c.z) + j.x*(k.w*c.z - k.z*c.w)) / s, + (k.z*(i.x*c.w - i.w*c.x) + k.w*(i.z*c.x - i.x*c.z) + k.x*(i.w*c.z - i.z*c.w)) / s, + (c.z*(i.x*j.w - i.w*j.x) + c.w*(i.z*j.x - i.x*j.z) + c.x*(i.w*j.z - i.z*j.w)) / s, + (i.z*(j.w*k.x - j.x*k.w) + i.w*(j.x*k.z - j.z*k.x) + i.x*(j.z*k.w - j.w*k.z)) / s, + (j.w*(k.x*c.y - k.y*c.x) + j.x*(k.y*c.w - k.w*c.y) + j.y*(k.w*c.x - k.x*c.w)) / s, + (k.w*(i.x*c.y - i.y*c.x) + k.x*(i.y*c.w - i.w*c.y) + k.y*(i.w*c.x - i.x*c.w)) / s, + (c.w*(i.x*j.y - i.y*j.x) + c.x*(i.y*j.w - i.w*j.y) + c.y*(i.w*j.x - i.x*j.w)) / s, + (i.w*(j.y*k.x - j.x*k.y) + i.x*(j.w*k.y - j.y*k.w) + i.y*(j.x*k.w - j.w*k.x)) / s, + (j.x*(k.z*c.y - k.y*c.z) + j.y*(k.x*c.z - k.z*c.x) + j.z*(k.y*c.x - k.x*c.y)) / s, + (k.x*(i.z*c.y - i.y*c.z) + k.y*(i.x*c.z - i.z*c.x) + k.z*(i.y*c.x - i.x*c.y)) / s, + (c.x*(i.z*j.y - i.y*j.z) + c.y*(i.x*j.z - i.z*j.x) + c.z*(i.y*j.x - i.x*j.y)) / s, + (i.x*(j.y*k.z - j.z*k.y) + i.y*(j.z*k.x - j.x*k.z) + i.z*(j.x*k.y - j.y*k.x)) / s); + return *this; + } + + template inline Matrix4 Matrix4::getInversed() const + { + static const T t0(0.0f); + + T s = determinant(); + if(EffectsEqual(s, t0)) return *this; + Matrix4 inverted( + (j.y*(k.z*c.w - k.w*c.z) + j.z*(k.w*c.y - k.y*c.w) + j.w*(k.y*c.z - k.z*c.y)) / s, + (k.y*(i.z*c.w - i.w*c.z) + k.z*(i.w*c.y - i.y*c.w) + k.w*(i.y*c.z - i.z*c.y)) / s, + (c.y*(i.z*j.w - i.w*j.z) + c.z*(i.w*j.y - i.y*j.w) + c.w*(i.y*j.z - i.z*j.y)) / s, + (i.y*(j.w*k.z - j.z*k.w) + i.z*(j.y*k.w - j.w*k.y) + i.w*(j.z*k.y - j.y*k.z)) / s, + (j.z*(k.x*c.w - k.w*c.x) + j.w*(k.z*c.x - k.x*c.z) + j.x*(k.w*c.z - k.z*c.w)) / s, + (k.z*(i.x*c.w - i.w*c.x) + k.w*(i.z*c.x - i.x*c.z) + k.x*(i.w*c.z - i.z*c.w)) / s, + (c.z*(i.x*j.w - i.w*j.x) + c.w*(i.z*j.x - i.x*j.z) + c.x*(i.w*j.z - i.z*j.w)) / s, + (i.z*(j.w*k.x - j.x*k.w) + i.w*(j.x*k.z - j.z*k.x) + i.x*(j.z*k.w - j.w*k.z)) / s, + (j.w*(k.x*c.y - k.y*c.x) + j.x*(k.y*c.w - k.w*c.y) + j.y*(k.w*c.x - k.x*c.w)) / s, + (k.w*(i.x*c.y - i.y*c.x) + k.x*(i.y*c.w - i.w*c.y) + k.y*(i.w*c.x - i.x*c.w)) / s, + (c.w*(i.x*j.y - i.y*j.x) + c.x*(i.y*j.w - i.w*j.y) + c.y*(i.w*j.x - i.x*j.w)) / s, + (i.w*(j.y*k.x - j.x*k.y) + i.x*(j.w*k.y - j.y*k.w) + i.y*(j.x*k.w - j.w*k.x)) / s, + (j.x*(k.z*c.y - k.y*c.z) + j.y*(k.x*c.z - k.z*c.x) + j.z*(k.y*c.x - k.x*c.y)) / s, + (k.x*(i.z*c.y - i.y*c.z) + k.y*(i.x*c.z - i.z*c.x) + k.z*(i.y*c.x - i.x*c.y)) / s, + (c.x*(i.z*j.y - i.y*j.z) + c.y*(i.x*j.z - i.z*j.x) + c.z*(i.y*j.x - i.x*j.y)) / s, + (i.x*(j.y*k.z - j.z*k.y) + i.y*(j.z*k.x - j.x*k.z) + i.z*(j.x*k.y - j.y*k.x)) / s); + return inverted; + } + + template inline Matrix4& Matrix4::transpose() + { + EffectsSwap(i.y, j.x); + EffectsSwap(i.z, k.x); + EffectsSwap(i.w, c.x); + EffectsSwap(j.z, k.y); + EffectsSwap(j.w, c.y); + EffectsSwap(k.w, c.z); + return *this; + } + + template inline Matrix4 Matrix4::getTransposed() const + { + Matrix4 transposed(i.x, j.x, k.x, c.x, + i.y, j.y, k.y, c.y, + i.z, j.z, k.z, c.z, + i.w, j.w, k.w, c.w); + + return transposed; + } + + template inline Matrix4& Matrix4::operator+=(const Matrix4& aRhv) + { + i += aRhv.i; + j += aRhv.j; + k += aRhv.k; + c += aRhv.c; + return *this; + } + template inline Matrix4& Matrix4::operator+=(const T& aRhv) + { + i += aRhv; + j += aRhv; + k += aRhv; + c += aRhv; + return *this; + } + template inline Matrix4& Matrix4::operator-=(const Matrix4& aRhv) + { + i -= aRhv.i; + j -= aRhv.j; + k -= aRhv.k; + c -= aRhv.c; + return *this; + } + template inline Matrix4& Matrix4::operator-=(const T& aRhv) + { + i -= aRhv; + j -= aRhv; + k -= aRhv; + c -= aRhv; + return *this; + } + template inline Matrix4& Matrix4::operator*=(const T& aRhv) + { + i *= aRhv; + j *= aRhv; + k *= aRhv; + c *= aRhv; + return *this; + } + + template inline Matrix4 Matrix4::GetMultipliedByMember(const Matrix4& aRhv) const + { + return Matrix4(i * aRhv.i, j * aRhv.j, k * aRhv.k, c * aRhv.c); + } + + template inline Matrix4& Matrix4::multiplyByMember(const Matrix4& aRhv) + { + i *= aRhv.i; + j *= aRhv.j; + k *= aRhv.k; + c *= aRhv.c; + return *this; + } + + template inline Matrix4 Matrix4::createMultipliedByMember(const Matrix4& aLhv, const Matrix4& aRhv) + { + return Matrix4(aLhv.i * aRhv.i, aLhv.j * aRhv.j, aLhv.k * aRhv.k, aLhv.c * aRhv.c); + } + + template inline Matrix4& Matrix4::operator*=(const Matrix4& aRhv) + { + set( + i.x * aRhv.i.x + i.y * aRhv.j.x + i.z * aRhv.k.x + i.w * aRhv.c.x, + i.x * aRhv.i.y + i.y * aRhv.j.y + i.z * aRhv.k.y + i.w * aRhv.c.y, + i.x * aRhv.i.z + i.y * aRhv.j.z + i.z * aRhv.k.z + i.w * aRhv.c.z, + i.x * aRhv.i.w + i.y * aRhv.j.w + i.z * aRhv.k.w + i.w * aRhv.c.w, + + j.x * aRhv.i.x + j.y * aRhv.j.x + j.z * aRhv.k.x + j.w * aRhv.c.x, + j.x * aRhv.i.y + j.y * aRhv.j.y + j.z * aRhv.k.y + j.w * aRhv.c.y, + j.x * aRhv.i.z + j.y * aRhv.j.z + j.z * aRhv.k.z + j.w * aRhv.c.z, + j.x * aRhv.i.w + j.y * aRhv.j.w + j.z * aRhv.k.w + j.w * aRhv.c.w, + + k.x * aRhv.i.x + k.y * aRhv.j.x + k.z * aRhv.k.x + k.w * aRhv.c.x, + k.x * aRhv.i.y + k.y * aRhv.j.y + k.z * aRhv.k.y + k.w * aRhv.c.y, + k.x * aRhv.i.z + k.y * aRhv.j.z + k.z * aRhv.k.z + k.w * aRhv.c.z, + k.x * aRhv.i.w + k.y * aRhv.j.w + k.z * aRhv.k.w + k.w * aRhv.c.w, + + c.x * aRhv.i.x + c.y * aRhv.j.x + c.z * aRhv.k.x + c.w * aRhv.c.x, + c.x * aRhv.i.y + c.y * aRhv.j.y + c.z * aRhv.k.y + c.w * aRhv.c.y, + c.x * aRhv.i.z + c.y * aRhv.j.z + c.z * aRhv.k.z + c.w * aRhv.c.z, + c.x * aRhv.i.w + c.y * aRhv.j.w + c.z * aRhv.k.w + c.w * aRhv.c.w); + return *this; + } + + template inline Matrix4 Matrix4::getDividedByMember(const Matrix4& aRhv) const + { + return Matrix4(i / aRhv.i, j / aRhv.j, k / aRhv.k, c / aRhv.c); + } + + template inline Matrix4& Matrix4::divideByMember(const Matrix4& aRhv) + { + i /= aRhv.i; + j /= aRhv.j; + k /= aRhv.k; + c /= aRhv.c; + return *this; + } + template inline Matrix4 Matrix4::createDividedByMember(const Matrix4& aLhv, const Matrix4& aRhv) + { + return Matrix4(aLhv.i / aRhv.i, aLhv.j / aRhv.j, aLhv.k / aRhv.k, aLhv.c / aRhv.c); + } + + template inline Matrix4& Matrix4::operator/=(const T& aRhv) + { + i /= aRhv; + j /= aRhv; + k /= aRhv; + c /= aRhv; + return *this; + } + + template inline bool Matrix4::isIdentity() const + { + return *this == getIdentity(); + } + + template inline T* Matrix4::getPointer() + { + return i.getPointer(); + } + + template inline const T* Matrix4::getPointer() const + { + return i.getPointer(); + } + + template inline T& Matrix4::get(unsigned int aRow, unsigned int aColumn) + { + return operator()(aRow, aColumn); + } + + template inline const T& Matrix4::get(unsigned int aRow, unsigned int aColumn) const + { + return operator()(aRow, aColumn); + } + + template inline T& Matrix4::get(unsigned int aAbsIndex) + { + return operator()(aAbsIndex); + } + + template inline const T& Matrix4::get(unsigned int aAbsIndex) const + { + return operator()(aAbsIndex); + } + + template inline Vector4& Matrix4::getRow(unsigned int aRow) + { + switch(aRow) + { + case 1: + return j; + case 2: + return k; + case 3: + return c; + } + return i; + } + + template inline const Vector4& Matrix4::getRow(unsigned int aRow) const + { + switch(aRow) + { + case 1: + return j; + case 2: + return k; + case 3: + return c; + } + return i; + } + + template inline Vector4 Matrix4::getColumn(unsigned int aColumn) const + { + switch(aColumn) + { + case 1: + return Vector4(i.y, j.y, k.y, c.y); + case 2: + return Vector4(i.z, j.z, k.z, c.z); + case 3: + return Vector4(i.w, j.w, k.w, c.w); + } + + return Vector4(i.x, j.x, k.x, c.x); + } + + template inline T& Matrix4::operator()(unsigned int aRow, unsigned int aColumn) + { + return operator[]((aRow << 2) + aColumn); + } + + template inline const T& Matrix4::operator()(unsigned int aRow, unsigned int aColumn) const + { + return operator[]((aRow << 2) + aColumn); + } + + template inline T& Matrix4::operator()(unsigned int aAbsIndex) + { + return operator[](aAbsIndex); + } + + template inline const T& Matrix4::operator()(unsigned int aAbsIndex) const + { + return operator[](aAbsIndex); + } + + template inline T& Matrix4::operator[](unsigned int aAbsIndex) + { + return getPointer()[aAbsIndex]; + } + + template inline const T& Matrix4::operator[](unsigned int aAbsIndex) const + { + return getPointer()[aAbsIndex]; + } + + template inline Matrix4& Matrix4::setColumn(unsigned int aColumn, const Vector4& aValue) + { + switch(aColumn) + { + case 0: + i.x = aValue.x; + j.x = aValue.y; + k.x = aValue.z; + c.x = aValue.w; + break; + case 1: + i.y = aValue.x; + j.y = aValue.y; + k.y = aValue.z; + c.y = aValue.w; + break; + case 2: + i.z = aValue.x; + j.z = aValue.y; + k.z = aValue.z; + c.z = aValue.w; + break; + case 3: + i.w = aValue.x; + j.w = aValue.y; + k.w = aValue.z; + c.w = aValue.w; + break; + } + + return *this; + } + + template inline Matrix4& Matrix4::setRow(unsigned int aRow, const Vector4& aValue) + { + switch(aRow) + { + case 0: + i = aValue; + break; + case 1: + j = aValue; + break; + case 2: + k = aValue; + break; + case 3: + c = aValue; + break; + } + + return *this; + } + + template inline Matrix4& Matrix4::set(unsigned int aRow, unsigned int aColumn, const T& aValue) + { + operator()(aRow, aColumn) = aValue; + return *this; + } + + template inline Matrix4& Matrix4::set(unsigned int aAbsIndex, const T& aValue) + { + operator()(aAbsIndex) = aValue; + return *this; + } + + template inline Matrix4& Matrix4::lerp(const Matrix4& aTo, const T& aCoeff) + { + i.lerp(aTo.i, aCoeff); + j.lerp(aTo.j, aCoeff); + k.lerp(aTo.k, aCoeff); + c.lerp(aTo.c, aCoeff); + return *this; + } + + template inline Matrix4 Matrix4::getLerped(const Matrix4& aTo, const T& aCoeff) const + { + Matrix4 result(i.getLerped(aTo.i, aCoeff), + j.getLerped(aTo.j, aCoeff), + k.getLerped(aTo.k, aCoeff), + c.getLerped(aTo.c, aCoeff)); + return result; + } + + template inline Matrix4& Matrix4::makeLerped(const Matrix4& aFrom, const Matrix4& aTo, const T& aCoeff) + { + i.makeLerped(aFrom.i, aTo.i, aCoeff); + j.makeLerped(aFrom.j, aTo.j, aCoeff); + k.makeLerped(aFrom.k, aTo.k, aCoeff); + c.makeLerped(aFrom.c, aTo.c, aCoeff); + return *this; + } + template inline Matrix4 Matrix4::createLerped(const Matrix4& aFrom, const Matrix4& aTo, const T& aCoeff) + { + return Matrix4().makeLerped(aFrom, aTo, aCoeff); + } + + template inline Matrix4& Matrix4::slerp(const Matrix4& aTo, const T& aCoeff) + { + setRotation(getQuaternion().slerp(aTo.getQuaternion(), aCoeff)); + c.lerp(aTo.c, aCoeff); + return *this; + } + + template inline Matrix4 Matrix4::getSlerped(const Matrix4& aTo, const T& aCoeff) const + { + Matrix4 result; + result.makeRotation(getQuaternion().slerp(aTo.getQuaternion(), aCoeff)); + result.c = c.getLerped(aTo.c, aCoeff); + return result; + } + + template inline Matrix4& Matrix4::makeSlerped(const Matrix4& aFrom, const Matrix4& aTo, const T& aCoeff) + { + makeRotation(aFrom.getQuaternion().slerp(aTo.getQuaternion(), aCoeff)); + c.makeLerped(aFrom.c, aTo.c, aCoeff); + return *this; + } + + template inline Matrix4 Matrix4::createSlerped(const Matrix4& aFrom, const Matrix4& aTo, const T& aCoeff) + { + return Matrix4().makeSlerped(aFrom, aTo, aCoeff); + } + + template inline T Matrix4::determinant() const + { + return (i.x * j.y - i.y * j.x) * (k.z * c.w - k.w * c.z)- + (i.x * j.z - i.z * j.x) * (k.y * c.w - k.w * c.y)+ + (i.x * j.w - i.w * j.x) * (k.y * c.z - k.z * c.y)+ + (i.y * j.z - i.z * j.y) * (k.x * c.w - k.w * c.x)- + (i.y * j.w - i.w * j.y) * (k.x * c.z - k.z * c.x)+ + (i.z * j.w - i.w * j.z) * (k.x * c.y - k.y * c.x); + } + + template inline Vector4& Matrix4::applyTransform(Vector4& aVector) const + { + return aVector.set( + aVector.x * i.x + aVector.y * j.x + aVector.z * k.x + aVector.w * c.x, + aVector.x * i.y + aVector.y * j.y + aVector.z * k.y + aVector.w * c.y, + aVector.x * i.z + aVector.y * j.z + aVector.z * k.z + aVector.w * c.z, + aVector.x * i.w + aVector.y * j.w + aVector.z * k.w + aVector.w * c.w); + } + + template inline Vector4 Matrix4::getAppliedTransform(const Vector4& aVector) const + { + return Vector4( + aVector.x * i.x + aVector.y * j.x + aVector.z * k.x + aVector.w * c.x, + aVector.x * i.y + aVector.y * j.y + aVector.z * k.y + aVector.w * c.y, + aVector.x * i.z + aVector.y * j.z + aVector.z * k.z + aVector.w * c.z, + aVector.x * i.w + aVector.y * j.w + aVector.z * k.w + aVector.w * c.w); + } + + template inline Vector4& Matrix4::applyRotation(Vector4& aVector) const + { + return aVector.set( + aVector.x * i.x + aVector.y * j.x + aVector.z * k.x, + aVector.x * i.y + aVector.y * j.y + aVector.z * k.y, + aVector.x * i.z + aVector.y * j.z + aVector.z * k.z, + aVector.w); + } + + template inline Vector4 Matrix4::getAppliedRotation(const Vector4& aVector) const + { + return Vector4( + aVector.x * i.x + aVector.y * j.x + aVector.z * k.x, + aVector.x * i.y + aVector.y * j.y + aVector.z * k.y, + aVector.x * i.z + aVector.y * j.z + aVector.z * k.z, + aVector.w); + } + + template inline Vector4& Matrix4::applyTranslate(Vector4& aVector) const + { + return aVector.set( + aVector.x + aVector.w * c.x, + aVector.y + aVector.w * c.y, + aVector.z + aVector.w * c.z, + aVector.w); + } + + template inline Vector4 Matrix4::getAppliedTranslate(const Vector4& aVector) const + { + return Vector4( + aVector.x + aVector.w * c.x, + aVector.y + aVector.w * c.y, + aVector.z + aVector.w * c.z, + aVector.w); + } + + template inline _Vector3& Matrix4::applyTransform(_Vector3& aVector) const + { + return aVector.set( + aVector.x * i.x + aVector.y * j.x + aVector.z * k.x + c.x, + aVector.x * i.y + aVector.y * j.y + aVector.z * k.y + c.y, + aVector.x * i.z + aVector.y * j.z + aVector.z * k.z + c.z); + } + + template inline _Vector3 Matrix4::getAppliedTransform(const _Vector3& aVector) const + { + return _Vector3( + aVector.x * i.x + aVector.y * j.x + aVector.z * k.x + c.x, + aVector.x * i.y + aVector.y * j.y + aVector.z * k.y + c.y, + aVector.x * i.z + aVector.y * j.z + aVector.z * k.z + c.z); + } + + template inline _Vector3& Matrix4::applyRotation(_Vector3& aVector) const + { + return aVector.set( + aVector.x * i.x + aVector.y * j.x + aVector.z * k.x, + aVector.x * i.y + aVector.y * j.y + aVector.z * k.y, + aVector.x * i.z + aVector.y * j.z + aVector.z * k.z); + } + + template inline _Vector3 Matrix4::getAppliedRotation(const _Vector3& aVector) const + { + return _Vector3( + aVector.x * i.x + aVector.y * j.x + aVector.z * k.x, + aVector.x * i.y + aVector.y * j.y + aVector.z * k.y, + aVector.x * i.z + aVector.y * j.z + aVector.z * k.z); + } + + template inline _Vector3& Matrix4::applyTranslate(_Vector3& aVector) const + { + return aVector.set( + aVector.x + c.x, + aVector.y + c.y, + aVector.z + c.z); + } + + template inline _Vector3 Matrix4::getAppliedTranslate(const _Vector3& aVector) const + { + return _Vector3( + aVector.x + c.x, + aVector.y + c.y, + aVector.z + c.z); + } + + template inline Quaternion& Matrix4::applyRotation(Quaternion& aQuaternion) const + { + + return aQuaternion.set(getQuaternion() * aQuaternion); + } + + template inline Quaternion Matrix4::getAppliedRotation(const Quaternion& aQuaternion) const + { + return getQuaternion() * aQuaternion; + } + + template inline Matrix4& Matrix4::setRotation(const T& aXAngleRAD, const T& aYAngleRAD, const T& aZAngleRAD, RotationOrder3 aOrder) + { + Matrix4 result; + result.makeRotation(aXAngleRAD, aYAngleRAD, aZAngleRAD, aOrder); + + i.x = result.i.x; i.y = result.i.y; i.z = result.i.z; + j.x = result.j.x; j.y = result.j.y; j.z = result.j.z; + k.x = result.k.x; k.y = result.k.y; k.z = result.k.z; + return *this; + } + + template inline Matrix4& Matrix4::setRotation(const _Vector3& aAnglesRAD, RotationOrder3 aOrder) + { + return setRotation(aAnglesRAD.x, aAnglesRAD.y, aAnglesRAD.z, aOrder); + } + + template inline Matrix4& Matrix4::setRotationX(const T& aAngleRAD) + { + const T c = effects_cos(aAngleRAD); + const T s = effects_sin(aAngleRAD); + i.x = T(1.0f); + i.y = i.z = j.x = k.x = T(0.0f); + j.y = c; + j.z = s; + k.y = -s; + k.z = c; + return *this; + } + + template inline Matrix4& Matrix4::setRotationY(const T& aAngleRAD) + { + const T c = effects_cos(aAngleRAD); + const T s = effects_sin(aAngleRAD); + j.y = T(1.0f); + i.y = j.x = j.z = k.y = T(0.0f); + i.x = c; + i.z = -s; + k.x = s; + k.z = c; + return *this; + } + + template inline Matrix4& Matrix4::setRotationZ(const T& aAngleRAD) + { + const T c = effects_cos(aAngleRAD); + const T s = effects_sin(aAngleRAD); + k.z = T(1.0f); + i.z = j.z = k.x = k.y = T(0.0f); + i.x = c; + i.y = s; + j.x = -s; + j.y = c; + return *this; + } + + template inline Matrix4& Matrix4::setRotationAxis(const _Vector3& aAxis, const T& aAngleRAD) + { + return setRotationAxis(aAxis.x, aAxis.y, aAxis.z, aAngleRAD); + } + + template inline Matrix4& Matrix4::setRotationAxis(const T& aXAxis, const T& aYAxis, const T& aZAxis, const T& aAngleRAD) + { + Matrix4 result; + result.makeRotationAxis(aXAxis, aYAxis, aZAxis, aAngleRAD); + + i.x = result.i.x; i.y = result.i.y; i.z = result.i.z; + j.x = result.j.x; j.y = result.j.y; j.z = result.j.z; + k.x = result.k.x; k.y = result.k.y; k.z = result.k.z; + return *this; + } + + template inline Matrix4& Matrix4::setRotation(const Quaternion& aRotation) + { + T wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2; + T s = T(2.0f) / aRotation.lengthSqr(); // 4 mul 3 add 1 div + x2 = aRotation.x * s; y2 = aRotation.y * s; z2 = aRotation.z * s; + xx = aRotation.x * x2; xy = aRotation.x * y2; xz = aRotation.x * z2; + yy = aRotation.y * y2; yz = aRotation.y * z2; zz = aRotation.z * z2; + wx = aRotation.w * x2; wy = aRotation.w * y2; wz = aRotation.w * z2; + + const T t1(1.0f); + i.x = t1 - (yy + zz); + j.x = xy - wz; + k.x = xz + wy; + + i.y = xy + wz; + j.y = t1 - (xx + zz); + k.y = yz - wx; + + i.z = xz - wy; + j.z = yz + wx; + k.z = t1 - (xx + yy); + return *this; + } + + template inline Matrix4& Matrix4::setRotation(const Matrix3& aRotation) + { + i.x = aRotation.i.x; i.y = aRotation.i.y; i.z = aRotation.i.z; + j.x = aRotation.j.x; j.y = aRotation.j.y; j.z = aRotation.j.z; + k.x = aRotation.k.x; k.y = aRotation.k.y; k.z = aRotation.k.z; + return *this; + } + + template inline Matrix4& Matrix4::makeRotation(const T& aXAngleRAD, const T& aYAngleRAD, const T& aZAngleRAD, RotationOrder3 aOrder) + { + switch(aOrder) + { + case ROTATION_XYZ: + makeRotationX(aXAngleRAD); + rotateY(aYAngleRAD); + rotateZ(aZAngleRAD); + break; + case ROTATION_XZY: + makeRotationX(aXAngleRAD); + rotateZ(aZAngleRAD); + rotateY(aYAngleRAD); + break; + case ROTATION_YXZ: + makeRotationY(aYAngleRAD); + rotateX(aXAngleRAD); + rotateZ(aZAngleRAD); + break; + case ROTATION_YZX: + makeRotationY(aYAngleRAD); + rotateZ(aZAngleRAD); + rotateX(aXAngleRAD); + break; + case ROTATION_ZXY: + makeRotationZ(aZAngleRAD); + rotateX(aXAngleRAD); + rotateY(aYAngleRAD); + break; + case ROTATION_ZYX: + makeRotationZ(aZAngleRAD); + rotateY(aYAngleRAD); + rotateX(aXAngleRAD); + break; + default: + break; + } + return *this; + } + + template inline Matrix4& Matrix4::makeRotation(const _Vector3& aAnglesRAD, RotationOrder3 aOrder) + { + return makeRotation(aAnglesRAD.x, aAnglesRAD.y, aAnglesRAD.z, aOrder); + } + + template inline Matrix4& Matrix4::makeRotationX(const T& aAngleRAD) + { + identity(); + const T c = effects_cos(aAngleRAD); + const T s = effects_sin(aAngleRAD); + j.y = c; + j.z = s; + k.y = -s; + k.z = c; + return *this; + } + + template inline Matrix4& Matrix4::makeRotationY(const T& aAngleRAD) + { + identity(); + const T c = effects_cos(aAngleRAD); + const T s = effects_sin(aAngleRAD); + i.x = c; + i.z = -s; + k.x = s; + k.z = c; + return *this; + } + + template inline Matrix4& Matrix4::makeRotationZ(const T& aAngleRAD) + { + identity(); + const T c = effects_cos(aAngleRAD); + const T s = effects_sin(aAngleRAD); + i.x = c; + i.y = s; + j.x = -s; + j.y = c; + return *this; + } + + template inline Matrix4& Matrix4::makeRotationAxis(const _Vector3& aAxis, const T& aAngleRAD) + { + return makeRotationAxis(aAxis.x, aAxis.y, aAxis.z, aAngleRAD); + } + + template inline Matrix4& Matrix4::makeRotationAxis(const T& aXAxis, const T& aYAxis, const T& aZAxis, const T& aAngleRAD) + { + static const T t1(1.0f); + + _Vector3 v(aXAxis, aYAxis, aZAxis); + v.normalize(); + const T sa = effects_sin(aAngleRAD); + const T ca = effects_cos(aAngleRAD); + const T inv_ca = t1 - ca; + + + identity(); + + i.x = ca + inv_ca * v.x * v.x; + i.y = inv_ca * v.x * v.y - sa * v.z; + i.z = inv_ca * v.z * v.x + sa * v.y; + j.x = inv_ca * v.x * v.y + sa * v.z; + j.y = ca + inv_ca * v.y * v.y; + j.z = inv_ca * v.y * v.z - sa * v.x; + k.x = inv_ca * v.z * v.x - sa * v.y; + k.y = inv_ca * v.y * v.z + sa * v.x; + k.z = ca + inv_ca * v.z * v.z; + + return *this; + } + + template inline Matrix4& Matrix4::makeRotation(const Quaternion& aRotation) + { + identity(); + return setRotation(aRotation); + } + + template inline Matrix4& Matrix4::makeRotation(const Matrix3& aRotation) + { + identity(); + return setRotation(aRotation); + } + + template inline Matrix4 Matrix4::createRotation(const T& aXAngleRAD, const T& aYAngleRAD, const T& aZAngleRAD, RotationOrder3 aOrder) + { + return Matrix4().makeRotation(aXAngleRAD, aYAngleRAD, aZAngleRAD, aOrder); + } + + template inline Matrix4 Matrix4::createRotation(const _Vector3& aAnglesRAD, RotationOrder3 aOrder) + { + return Matrix4().makeRotation(aAnglesRAD, aOrder); + } + + template inline Matrix4 Matrix4::createRotationX(const T& aAngleRAD) + { + return Matrix4().makeRotationX(aAngleRAD); + } + + template inline Matrix4 Matrix4::createRotationY(const T& aAngleRAD) + { + return Matrix4().makeRotationY(aAngleRAD); + } + + template inline Matrix4 Matrix4::createRotationZ(const T& aAngleRAD) + { + return Matrix4().makeRotationZ(aAngleRAD); + } + + template inline Matrix4 Matrix4::createRotationAxis(const _Vector3& aAxis, const T& aAngleRAD) + { + return Matrix4().makeRotationAxis(aAxis, aAngleRAD); + } + + template inline Matrix4 Matrix4::createRotationAxis(const T& aXAxis, const T& aYAxis, const T& aZAxis, const T& aAngleRAD) + { + return Matrix4().makeRotationAxis(aXAxis, aYAxis, aZAxis, aAngleRAD); + } + + template inline Matrix4 Matrix4::createRotation(const Quaternion& aRotation) + { + return Matrix4().makeRotation(aRotation); + } + + template inline Matrix4 Matrix4::createRotation(const Matrix3& aRotation) + { + return Matrix4().makeRotation(aRotation); + } + + template inline Matrix4& Matrix4::rotate(const T& aXAngleRAD, const T& aYAngleRAD, const T& aZAngleRAD, RotationOrder3 aOrder) + { + return rotate(Matrix4().makeRotation(aXAngleRAD, aYAngleRAD, aZAngleRAD, aOrder)); + } + template inline Matrix4& Matrix4::rotate(const _Vector3& aAnglesRAD, RotationOrder3 aOrder3) + { + return rotate(Matrix4().makeRotation(aAnglesRAD, aOrder3)); + } + template inline Matrix4& Matrix4::rotateX(const T& aAngleRAD) + { + return rotate(Matrix4().makeRotationX(aAngleRAD)); + } + template inline Matrix4& Matrix4::rotateY(const T& aAngleRAD) + { + return rotate(Matrix4().makeRotationY(aAngleRAD)); + } + template inline Matrix4& Matrix4::rotateZ(const T& aAngleRAD) + { + return rotate(Matrix4().makeRotationZ(aAngleRAD)); + } + template inline Matrix4& Matrix4::rotateAxis(const _Vector3& aAxis, const T& aAngleRAD) + { + return rotate(Matrix4().makeRotationAxis(aAxis, aAngleRAD)); + } + template inline Matrix4& Matrix4::rotateAxis(const T& aXAxis, const T& aYAxis, const T& aZAxis, const T& aAngleRAD) + { + return rotate(Matrix4().makeRotationAxis(aXAxis, aYAxis, aZAxis, aAngleRAD)); + } + template inline Matrix4& Matrix4::rotate(const Quaternion& aRotation) + { + return rotate(Matrix4().makeRotation(aRotation)); + } + template inline Matrix4& Matrix4::rotate(const Matrix3& aRotation) + { + const T _11 = i.x * aRotation.i.x + i.y * aRotation.j.x + i.z * aRotation.k.x; + const T _12 = i.x * aRotation.i.y + i.y * aRotation.j.y + i.z * aRotation.k.y; + const T _13 = i.x * aRotation.i.z + i.y * aRotation.j.z + i.z * aRotation.k.z; + + const T _21 = j.x * aRotation.i.x + j.y * aRotation.j.x + j.z * aRotation.k.x; + const T _22 = j.x * aRotation.i.y + j.y * aRotation.j.y + j.z * aRotation.k.y; + const T _23 = j.x * aRotation.i.z + j.y * aRotation.j.z + j.z * aRotation.k.z; + + const T _31 = k.x * aRotation.i.x + k.y * aRotation.j.x + k.z * aRotation.k.x; + const T _32 = k.x * aRotation.i.y + k.y * aRotation.j.y + k.z * aRotation.k.y; + const T _33 = k.x * aRotation.i.z + k.y * aRotation.j.z + k.z * aRotation.k.z; + + i.x = _11; i.y = _12; i.z = _13; + j.x = _21; j.y = _22; j.z = _23; + k.x = _31; k.y = _32; k.z = _33; + + return *this; + } + template inline Matrix4& Matrix4::rotate(const Matrix4& aRotation) + { + const T _11 = i.x * aRotation.i.x + i.y * aRotation.j.x + i.z * aRotation.k.x; + const T _12 = i.x * aRotation.i.y + i.y * aRotation.j.y + i.z * aRotation.k.y; + const T _13 = i.x * aRotation.i.z + i.y * aRotation.j.z + i.z * aRotation.k.z; + + const T _21 = j.x * aRotation.i.x + j.y * aRotation.j.x + j.z * aRotation.k.x; + const T _22 = j.x * aRotation.i.y + j.y * aRotation.j.y + j.z * aRotation.k.y; + const T _23 = j.x * aRotation.i.z + j.y * aRotation.j.z + j.z * aRotation.k.z; + + const T _31 = k.x * aRotation.i.x + k.y * aRotation.j.x + k.z * aRotation.k.x; + const T _32 = k.x * aRotation.i.y + k.y * aRotation.j.y + k.z * aRotation.k.y; + const T _33 = k.x * aRotation.i.z + k.y * aRotation.j.z + k.z * aRotation.k.z; + + i.x = _11; i.y = _12; i.z = _13; + j.x = _21; j.y = _22; j.z = _23; + k.x = _31; k.y = _32; k.z = _33; + + return *this; + } + template inline const Matrix4& Matrix4::getRotationAngles(T& aXAngleRAD, T& aYAngeRAD, T& aZAngleRAD, unsigned int aSolutionNumber) const + { + static const T t0(0.0f); + static const T t2(2.0f); + static const T pi(fPI); + + T& yaw = aZAngleRAD; + T& pitch = aYAngeRAD; + T& roll = aXAngleRAD; + + struct Euler + { + T yaw; + T pitch; + T roll; + }; + + Euler euler_out; + Euler euler_out2; //second solution + + // Check that pitch is not at a singularity + if(EffectsAbs(k.x) >= T(1.0f)) + { + euler_out.yaw = t0; + euler_out2.yaw = t0; + + // From difference of angles formula + T delta = effects_atan2(i.x, i.z); + if (k.x > 0) //gimbal locked up + { + euler_out.pitch = pi / t2; + euler_out2.pitch = pi / t2; + euler_out.roll = euler_out.pitch + delta; + euler_out2.roll = euler_out.pitch + delta; + } + else // gimbal locked down + { + euler_out.pitch = -pi / t2; + euler_out2.pitch = -pi / t2; + euler_out.roll = -euler_out.pitch + delta; + euler_out2.roll = -euler_out.pitch + delta; + } + } + else + { + euler_out.pitch = - effects_asin(k.x); + euler_out2.pitch = pi - euler_out.pitch; + + euler_out.roll = effects_atan2(k.y / effects_cos(euler_out.pitch), k.z / effects_cos(euler_out.pitch)); + + euler_out2.roll = effects_atan2(k.y / effects_cos(euler_out2.pitch), k.z / effects_cos(euler_out2.pitch)); + + euler_out.yaw = effects_atan2(j.x / effects_cos(euler_out.pitch), i.x / effects_cos(euler_out.pitch)); + + euler_out2.yaw = effects_atan2(j.x / effects_cos(euler_out2.pitch), i.x / effects_cos(euler_out2.pitch)); + } + + if (aSolutionNumber == 1) + { + yaw = euler_out.yaw; + pitch = euler_out.pitch; + roll = euler_out.roll; + } + else + { + yaw = euler_out2.yaw; + pitch = euler_out2.pitch; + roll = euler_out2.roll; + } + return *this; + } + template inline Quaternion& Matrix4::getQuaternion(Quaternion& aRotation) const + { + static const T t0(0.0f); + static const T thalf(0.5f); + static const T t1(1.0f); + + Quaternion& result = aRotation; + + T tr = i.x + j.y + k.z; // trace of martix + if(tr > t0) + { // if trace positive than "w" is biggest component + result.set(j.z - k.y, k.x - i.z, i.y - j.x, tr + t1); + result *= (T(0.5f) / effects_sqrt(result.w)); // "w" contain the "norm * 4" + + } + else // Some of vector components is bigger + { + if((i.x > j.y) && (i.x > k.z)) + { + result.set(t1 + i.x - j.y - k.z, j.x + i.y, k.x + i.z, j.z - k.y); + result *= (thalf / effects_sqrt(result.x)); + + } + else + { + if(j.y > k.z) + { + result.set(j.x + i.y, t1 + j.y - i.x - k.z, k.y + j.z, k.x - i.z); + result *= (thalf / effects_sqrt(result.x)); + + } + else + { + result.set(k.x + i.z, k.y + j.z, t1 + k.z - i.x - j.y, i.y - j.x); + result *= (thalf / effects_sqrt(result.z)); + + } + } + } + return result.normalize(); + } + template inline Quaternion Matrix4::getQuaternion() const + { + Quaternion result; + return getQuaternion(result); + } + template inline Matrix3 Matrix4::getRotation() const + { + return Matrix3(i.x, i.y, i.z, + j.x, j.y, j.z, + k.x, k.y, k.z); + } + + template inline Matrix4& Matrix4::makeScale(const T& aX, const T& aY, const T& aZ) + { + identity(); + return setScale(aX, aY, aZ); + } + template inline Matrix4& Matrix4::makeScale(const _Vector3& aScale) + { + return makeScale(aScale.x, aScale.y, aScale.z); + } + template inline Matrix4 Matrix4::createScale(const T& aX, const T& aY, const T& aZ) + { + return Matrix4().makeScale(aX, aY, aZ); + } + template inline Matrix4 Matrix4::createScale(const _Vector3& aScale) + { + return Matrix4().makeScale(aScale); + } + template inline Matrix4& Matrix4::setScale(const T& aX, const T& aY, const T& aZ) + { + i.x = aX; + j.y = aY; + k.z = aZ; + + i.y = i.z = j.x = j.z = k.x = k.y = T(0.0f); + return *this; + } + template inline Matrix4& Matrix4::setScale(const _Vector3& aScale) + { + return setScale(aScale.x, aScale.y, aScale.z); + } + template inline Matrix4& Matrix4::scale(const T& aX, const T& aY, const T& aZ) + { + i.x *= aX; i.y *= aY; i.z *= aZ; + j.x *= aX; j.y *= aY; j.z *= aZ; + k.x *= aX; k.y *= aY; k.z *= aZ; + + return *this; + } + template inline Matrix4& Matrix4::scale(const _Vector3& aScale) + { + return scale(aScale.x, aScale.y, aScale.z); + } + + template inline Matrix4& Matrix4::setTranslation(const T& aX, const T& aY, const T& aZ) + { + c.x = aX; + c.y = aY; + c.z = aZ; + return *this; + } + template inline Matrix4& Matrix4::setTranslation(const _Vector3& aTran) + { + return setTranslation(aTran.x, aTran.y, aTran.z); + } + template inline Matrix4& Matrix4::makeTranslation(const T& aX, const T& aY, const T& aZ) + { + identity(); + return setTranslation(aX, aY, aZ); + } + template inline Matrix4& Matrix4::makeTranslation(const _Vector3& aTran) + { + return makeTranslation(aTran.x, aTran.y, aTran.z); + } + template inline Matrix4 Matrix4::createTranslation(const T& aX, const T& aY, const T& aZ) + { + return Matrix4().makeTranslation(aX, aY, aZ); + } + template inline Matrix4 Matrix4::createTranslation(const _Vector3& aTran) + { + return Matrix4().makeTranslation(aTran); + } + template inline Matrix4& Matrix4::translate(const T& aX, const T& aY, const T& aZ) + { + c.x += aX; + c.y += aY; + c.z += aZ; + return *this; + } + template inline Matrix4& Matrix4::translate(const _Vector3& aTran) + { + return translate(aTran.x, aTran.y, aTran.z); + } + template inline _Vector3 Matrix4::getTranslation() const + { + return c.swizzle(0, 1, 2); + } + template inline Vector4 Matrix4::getFullTranslation() const + { + return c; + } + + template inline Matrix4& Matrix4::makeLookAtLH(const _Vector3& aEye, const _Vector3& aAt, const _Vector3& aUp) + { + static const T t0(0.0f); + static const T t1(1.0f); + + _Vector3 z((aAt - aEye).normalize()); + _Vector3 x; x.makeCrossed(aUp, z).normalize(); + _Vector3 y; y.makeCrossed(z, x); + + i.x = x.x; i.y = y.x; i.z = z.x; i.w = t0; + j.x = x.y; j.y = y.y; j.z = z.y; j.w = t0; + k.x = x.z; k.y = y.z; k.z = z.z; k.w = t0; + c.x = -x.dot(aEye); + c.y = -y.dot(aEye); + c.z = -z.dot(aEye); + c.w = t1; + return *this; + } + template inline Matrix4& Matrix4::makeLookAtRH(const _Vector3& aEye, const _Vector3& aAt, const _Vector3& aUp) + { + static const T t0(0.0f); + static const T t1(1.0f); + + _Vector3 z((aEye - aAt).normalize()); + _Vector3 x; x.makeCrossed(aUp, z).normalize(); + _Vector3 y; y.makeCrossed(z, x); + + i.x = x.x; i.y = y.x; i.z = z.x; i.w = t0; + j.x = x.y; j.y = y.y; j.z = z.y; j.w = t0; + k.x = x.z; k.y = y.z; k.z = z.z; k.w = t0; + c.x = -x.dot(aEye); + c.y = -y.dot(aEye); + c.z = -z.dot(aEye); + c.w = t1; + return *this; + } + template inline Matrix4& Matrix4::makeOrthoRH(const T& aWidth, const T& aHeight, const T& aZNear, const T& aZFar) + { + static const T t2(2.0f); + + identity(); + i.x = t2 / aWidth; + j.y = t2 / aHeight; + k.z = t2 / (aZNear - aZFar); + c.z = (aZFar + aZNear) / (aZNear - aZFar); + return *this; + } + template inline Matrix4& Matrix4::makeOrthoLH(const T& aWidth, const T& aHeight, const T& aZNear, const T& aZFar) + { + makeOrthoRH(aWidth, aHeight, aZNear, aZFar); + k.z = -k.z; + return *this; + } + template inline Matrix4& Matrix4::makeOrthoRH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar) + { + static const T t2(2.0f); + + identity(); + + i.x = t2 / (aRight - aLeft); + j.y = t2 / (aTop - aBottom); + k.z = t2 / (aZNear - aZFar); + + c.x = (aLeft + aRight) / (aLeft - aRight); + c.y = (aTop + aBottom) / (aBottom - aTop); + c.z = (aZFar + aZNear) / (aZNear - aZFar); + + return *this; + } + template inline Matrix4& Matrix4::makeOrthoLH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar) + { + makeOrthoRH(aLeft, aRight, aTop, aBottom, aZNear, aZFar); + k.z = -k.z; + return *this; + } + template inline Matrix4& Matrix4::makePerspectiveLH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar) + { + makePerspectiveRH(aLeft, aRight, aTop, aBottom, aZNear, aZFar); + k.z = -k.z; + return *this; + } + template inline Matrix4& Matrix4::makePerspectiveRH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar) + { + static const T t0(0.0f); + static const T t1(1.0f); + static const T t2(2.0f); + + identity(); + i.x = t2 * aZNear / (aRight - aLeft); + j.y = t2 * aZNear / (aTop - aBottom); + k.z = (aZFar + aZNear) / (aZNear - aZFar); + c.w = t0; + + k.w = -t1; + k.x = (aLeft + aRight) / (aRight - aLeft); + k.y = (aTop + aBottom) / (aTop - aBottom); + c.z = t2 * aZNear * aZFar / (aZNear - aZFar); + + return *this; + } + template inline Matrix4& Matrix4::makePerspectiveLH(const T& aWidth, const T& aHeight, const T& aZNear, const T& aZFar) + { + makePerspectiveRH(aWidth, aHeight, aZNear, aZFar); + k.z = -k.z; + return *this; + } + template inline Matrix4& Matrix4::makePerspectiveRH(const T& aWidth, const T& aHeight, const T& aZNear, const T& aZFar) + { + static const T t0(0.0f); + static const T t1(1.0f); + static const T t2(2.0f); + + identity(); + i.x = t2 * aZNear / aWidth; + j.y = t2 * aZNear / aHeight; + k.z = (aZFar + aZNear) / (aZNear - aZFar); + c.z = t2 * aZNear * aZFar / (aZNear - aZFar); + k.w = -t1; + c.w = t0; + return *this; + } + template inline Matrix4& Matrix4::makePerspectiveFovLH(const T& aFovY, const T& aAspect, const T& aZNear, const T& aZFar) + { + makePerspectiveFovRH(aFovY, aAspect, aZNear, aZFar); + k.z = -k.z; + return *this; + } + template inline Matrix4& Matrix4::makePerspectiveFovRH(const T& aFovY, const T& aAspect, const T& aZNear, const T& aZFar) + { + static const T t0(0.0f); + static const T t1(1.0f); + static const T t2(2.0f); + + identity(); + j.y = t1 / tan(aFovY / t2); + i.x = j.y / aAspect; + k.z = (aZFar + aZNear) / (aZNear - aZFar); + k.w = -t1; + c.z = t2 * (aZNear * aZFar / (aZNear - aZFar)); + c.w = t0; + return *this; + } + + template inline Matrix4 Matrix4::createLookAtLH(const _Vector3& aEye, const _Vector3& aAt, const _Vector3& aUp) + { + return Matrix4().makeLookAtLH(aEye, aAt, aUp); + } + template inline Matrix4 Matrix4::createLookAtRH(const _Vector3& aEye, const _Vector3& aAt, const _Vector3& aUp) + { + return Matrix4().makeLookAtRH(aEye, aAt, aUp); + } + template inline Matrix4 Matrix4::createOrthoRH(const T& aWidth, const T& aHeight, const T& aZNear, const T& aZFar) + { + return Matrix4().makeOrthoRH(aWidth, aHeight, aZNear, aZFar); + } + template inline Matrix4 Matrix4::createOrthoLH(const T& aWidth, const T& aHeight, const T& aZNear, const T& aZFar) + { + return Matrix4().makeOrthoLH(aWidth, aHeight, aZNear, aZFar); + } + template inline Matrix4 Matrix4::createOrthoRH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar) + { + return Matrix4().makeOrthoRH(aLeft, aRight, aTop, aBottom, aZNear, aZFar); + } + template inline Matrix4 Matrix4::createOrthoLH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar) + { + return Matrix4().makeOrthoLH(aLeft, aRight, aTop, aBottom, aZNear, aZFar); + } + template inline Matrix4 Matrix4::createPerspectiveLH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar) + { + return Matrix4().makePerspectiveLH(aLeft, aRight, aTop, aBottom, aZNear, aZFar); + } + template inline Matrix4 Matrix4::createPerspectiveRH(const T& aLeft, const T& aRight, const T& aTop, const T& aBottom, const T& aZNear, const T& aZFar) + { + return Matrix4().makePerspectiveRH(aLeft, aRight, aTop, aBottom, aZNear, aZFar); + } + template inline Matrix4 Matrix4::createPerspectiveLH(const T& aWidth, const T& aHeight, const T& aZnear, const T& aZFar) + { + return Matrix4().makePerspectiveLH(aWidth, aHeight, aZnear, aZFar); + } + template inline Matrix4 Matrix4::createPerspectiveRH(const T& aWidth, const T& aHeight, const T& aZnear, const T& aZFar) + { + return Matrix4().makePerspectiveRH(aWidth, aHeight, aZnear, aZFar); + } + template inline Matrix4 Matrix4::createPerspectiveFovLH(const T& aFovY, const T& aAspect, const T& aZnear, const T& aZFar) + { + return Matrix4().makePerspectiveFovLH(aFovY, aAspect, aZnear, aZFar); + } + template inline Matrix4 Matrix4::createPerspectiveFovRH(const T& aFovY, const T& aAspect, const T& aZnear, const T& aZFar) + { + return Matrix4().makePerspectiveFovRH(aFovY, aAspect, aZnear, aZFar); + } + + template inline bool Matrix4::getOrthoParamsRH(T& aLeft, T& aRight, T& aTop, T& aBottom, T& aZNear, T& aZFar) const + { + static const T t1(1.0f); + + aZNear = (c.z + t1) / k.z; + aZFar = (c.z - t1) / k.z; + + aLeft = -(t1 + c.x) / i.x; + aRight = (t1 - c.x) / i.x; + + aBottom = -(t1 + c.y) / j.y; + aTop = (t1 - c.y) / j.y; + + return true; + } + template inline bool Matrix4::getPerspectiveParamsRH(T& aLeft, T& aRight, T& aTop, T& aBottom, T& aZNear, T& aZFar) const + { + static const T t1(1.0f); + + aZNear = c.z / (k.z - t1); + aZFar = c.z / (t1 + k.z); + + aLeft = aZNear * (k.x - t1) / i.x; + aRight = aZNear * (t1 + k.x) / i.x; + + aTop = aZNear * (t1 + k.y) / j.y; + aBottom = aZNear * (k.y - t1) / j.y; + + return true; + } + template inline bool Matrix4::getPerspectiveParamsRH(T& aFovY, T& aAspect, T& aZNear, T& aZFar) const + { + T left, right, bottom, top; + bool result = getPerspectiveParamsRH(left, right, top, bottom, aZNear, aZFar); + if(result) + { + T height = top - bottom; + T width = right - left; + aAspect = width / height; + aFovY = T(2.0f) * effects_atan(height / aZNear * T(0.5f)); + } + return result; + } + template inline bool Matrix4::getViewParams(_Vector3& aPosition, _Vector3& aDirection, _Vector3& aUp, _Vector3& aRight) const + { + aRight.set(i.x, j.x, k.x); + aUp.set(i.y, j.y, k.y); + aDirection.set(-i.z, -j.z, -k.z); + aPosition = aDirection * c.z - aRight * c.x - aUp * c.y; + return true; + } + + template inline bool isEqual(const Matrix4& aLhv, const Matrix4& aRhv, const T& aEpsilon = effects_epsilon::epsilon()) + { + return isEqual(aLhv.i, aRhv.i, aEpsilon) && isEqual(aLhv.j, aRhv.j, aEpsilon) && isEqual(aLhv.k, aRhv.k, aEpsilon) && isEqual(aLhv.c, aRhv.c, aEpsilon); + } + template inline Matrix4 operator+(const Matrix4& aLhv, const Matrix4& aRhv) + { + return Matrix4(aLhv.i + aRhv.i, aLhv.j + aRhv.j, aLhv.k + aRhv.k, aLhv.c + aRhv.c); + } + template inline Matrix4 operator+(const Matrix4& aLhv, const T& aRhv) + { + return Matrix4(aLhv.i + aRhv, aLhv.j + aRhv, aLhv.k + aRhv, aLhv.c + aRhv); + } + template inline Matrix4 operator+(const T& aLhv, const Matrix4& aRhv) + { + return Matrix4(aLhv + aRhv.i, aLhv + aRhv.j, aLhv + aRhv.k, aLhv + aRhv.c); + } + template inline Matrix4 operator-(const Matrix4& aLhv, const Matrix4& aRhv) + { + return Matrix4(aLhv.i - aRhv.i, aLhv.j - aRhv.j, aLhv.k - aRhv.k, aLhv.c - aRhv.c); + } + template inline Matrix4 operator-(const Matrix4& aLhv, const T& aRhv) + { + return Matrix4(aLhv.i - aRhv, aLhv.j - aRhv, aLhv.k - aRhv, aLhv.c - aRhv); + } + template inline Matrix4 operator-(const T& aLhv, const Matrix4& aRhv) + { + return Matrix4(aLhv - aRhv.i, aLhv - aRhv.j, aLhv - aRhv.k, aLhv - aRhv.c); + } + template inline Matrix4 operator*(const Matrix4& aLhv, const Matrix4& aRhv) + { + return Matrix4( + aLhv.i.x * aRhv.i.x + aLhv.i.y * aRhv.j.x + aLhv.i.z * aRhv.k.x + aLhv.i.w * aRhv.c.x, + aLhv.i.x * aRhv.i.y + aLhv.i.y * aRhv.j.y + aLhv.i.z * aRhv.k.y + aLhv.i.w * aRhv.c.y, + aLhv.i.x * aRhv.i.z + aLhv.i.y * aRhv.j.z + aLhv.i.z * aRhv.k.z + aLhv.i.w * aRhv.c.z, + aLhv.i.x * aRhv.i.w + aLhv.i.y * aRhv.j.w + aLhv.i.z * aRhv.k.w + aLhv.i.w * aRhv.c.w, + + aLhv.j.x * aRhv.i.x + aLhv.j.y * aRhv.j.x + aLhv.j.z * aRhv.k.x + aLhv.j.w * aRhv.c.x, + aLhv.j.x * aRhv.i.y + aLhv.j.y * aRhv.j.y + aLhv.j.z * aRhv.k.y + aLhv.j.w * aRhv.c.y, + aLhv.j.x * aRhv.i.z + aLhv.j.y * aRhv.j.z + aLhv.j.z * aRhv.k.z + aLhv.j.w * aRhv.c.z, + aLhv.j.x * aRhv.i.w + aLhv.j.y * aRhv.j.w + aLhv.j.z * aRhv.k.w + aLhv.j.w * aRhv.c.w, + + aLhv.k.x * aRhv.i.x + aLhv.k.y * aRhv.j.x + aLhv.k.z * aRhv.k.x + aLhv.k.w * aRhv.c.x, + aLhv.k.x * aRhv.i.y + aLhv.k.y * aRhv.j.y + aLhv.k.z * aRhv.k.y + aLhv.k.w * aRhv.c.y, + aLhv.k.x * aRhv.i.z + aLhv.k.y * aRhv.j.z + aLhv.k.z * aRhv.k.z + aLhv.k.w * aRhv.c.z, + aLhv.k.x * aRhv.i.w + aLhv.k.y * aRhv.j.w + aLhv.k.z * aRhv.k.w + aLhv.k.w * aRhv.c.w, + + aLhv.c.x * aRhv.i.x + aLhv.c.y * aRhv.j.x + aLhv.c.z * aRhv.k.x + aLhv.c.w * aRhv.c.x, + aLhv.c.x * aRhv.i.y + aLhv.c.y * aRhv.j.y + aLhv.c.z * aRhv.k.y + aLhv.c.w * aRhv.c.y, + aLhv.c.x * aRhv.i.z + aLhv.c.y * aRhv.j.z + aLhv.c.z * aRhv.k.z + aLhv.c.w * aRhv.c.z, + aLhv.c.x * aRhv.i.w + aLhv.c.y * aRhv.j.w + aLhv.c.z * aRhv.k.w + aLhv.c.w * aRhv.c.w); + } + template inline Matrix4 operator*(const Matrix4& aLhv, const T& aRhv) + { + return Matrix4(aLhv.i * aRhv, aLhv.j * aRhv, aLhv.k * aRhv, aLhv.c * aRhv); + } + template inline Matrix4 operator*(const T& aLhv, const Matrix4& aRhv) + { + return Matrix4(aLhv * aRhv.i, aLhv * aRhv.j, aLhv * aRhv.k, aLhv * aRhv.c); + } + template inline Vector4 operator*(const Matrix4& aLhv, const Vector4& aRhv) + { + return Vector4(aLhv.i.dot(aRhv), aLhv.j.dot(aRhv), aLhv.k.dot(aRhv), aLhv.c.dot(aRhv)); + } + template inline Vector4 operator*(const Vector4& aLhv, const Matrix4& aRhv) + { + return aRhv.getAppliedTransform(aLhv); + } + template inline _Vector3 operator*(const _Vector3& aLhv, const Matrix4& aRhv) + { + return aRhv.getAppliedTransform(aLhv); + } + template inline _Vector3 operator*(const Matrix4& aLhv, const _Vector3& aRhv) + { + return _Vector3( aLhv.i.x * aRhv.x + aLhv.i.y * aRhv.y + aLhv.i.z * aRhv.z + aLhv.i.w, + aLhv.j.x * aRhv.x + aLhv.j.y * aRhv.y + aLhv.j.z * aRhv.z + aLhv.j.w, + aLhv.k.x * aRhv.x + aLhv.k.y * aRhv.y + aLhv.k.z * aRhv.z + aLhv.k.w); + } + template inline Matrix4 operator/(const Matrix4& aLhv, const T& aRhv) + { + return Matrix4(aLhv.i / aRhv, aLhv.j / aRhv, aLhv.k / aRhv, aLhv.c / aRhv); + } + template inline Matrix4 operator/(const T& aLhv, const Matrix4& aRhv) + { + return Matrix4(aLhv / aRhv.i, aLhv / aRhv.j, aLhv / aRhv.k, aLhv / aRhv.c); + } + template inline bool operator==(const Matrix4& aLhv, const Matrix4& aRhv) + { + return aLhv.i == aRhv.i && aLhv.j == aRhv.j && aLhv.k == aRhv.k && aLhv.c == aRhv.c; + } + template inline bool operator==(const Matrix4& aLhv, const T& aRhv) + { + return aLhv.i == aRhv && aLhv.j == aRhv && aLhv.k == aRhv && aLhv.c == aRhv; + } + template inline bool operator==(const T& aLhv, const Matrix4& aRhv) + { + return aLhv == aRhv.i && aLhv == aRhv.j && aLhv == aRhv.k && aLhv == aRhv.c; + } + template inline bool operator!=(const Matrix4& aLhv, const Matrix4& aRhv) + { + return !(aLhv == aRhv); + } + template inline bool operator!=(const Matrix4& aLhv, const T& aRhv) + { + return !(aLhv == aRhv); + } + template inline bool operator!=(const T& aLhv, const Matrix4& aRhv) + { + return !(aLhv == aRhv); + } +} } } } //Tizen::Ui::Effects::_Utils + +#endif //_FUI_EFFECTS_INTERNAL_UTILS_MATRIX4_H_ diff --git a/src/ui/effects/inc/utils/FUiEffects_UtilsVector2.h b/src/ui/effects/inc/utils/FUiEffects_UtilsVector2.h new file mode 100644 index 0000000..7b5c753 --- /dev/null +++ b/src/ui/effects/inc/utils/FUiEffects_UtilsVector2.h @@ -0,0 +1,435 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_UtilsVector2.h + * @brief The _Vector2 class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_UTILS_VECTOR2_H_ +#define _FUI_EFFECTS_INTERNAL_UTILS_VECTOR2_H_ + +#include "FUiEffects_UtilsAdapterFunctions.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Utils +{ + template class _Vector3; + template class Vector4; + + template class _Vector2 + { + private: + typedef _Vector2 SelfType; + + public: + T x; + T y; + + inline _Vector2(); + inline explicit _Vector2(const T& aValue); + inline explicit _Vector2(const T* aValue); + inline _Vector2(const T& aX, const T& aY); + inline _Vector2(const SelfType& aOther); + + inline SelfType& operator=(const SelfType& aRhv); + + inline SelfType& set(const SelfType& aOther); + inline SelfType& set(const T& aX, const T& aY); + inline SelfType& set(const T& aValue); + inline SelfType& set(const T* aValue); + + inline SelfType operator-() const; + inline SelfType& inverse(); + inline SelfType getInversed() const; + + inline SelfType& operator+=(const SelfType& aRhv); + inline SelfType& operator+=(const T& aRhv); + inline SelfType& operator-=(const SelfType& aRhv); + inline SelfType& operator-=(const T& aRhv); + inline SelfType& operator*=(const SelfType& aRhv); + inline SelfType& operator*=(const T& aRhv); + inline SelfType& operator/=(const SelfType& aRhv); + inline SelfType& operator/=(const T& aRhv); + + inline SelfType operator+(const SelfType& aRhv) const; + inline SelfType operator+(const T& aRhv) const; + inline SelfType operator-(const SelfType& aRhv) const; + inline SelfType operator-(const T& aRhv) const; + inline SelfType operator*(const SelfType& aRhv) const; + inline SelfType operator*(const T& aRhv) const; + inline SelfType operator/(const SelfType& aRhv) const; + inline SelfType operator/(const T& aRhv) const; + inline bool operator==(const SelfType& aRhv) const; + + inline T* getPointer(); + inline const T* getPointer() const; + + inline SelfType& normalize(); + inline SelfType getNormalized() const; + + inline SelfType& lerp(const SelfType& aTo, const T& aCoeff); + inline SelfType getLerped(const SelfType& aTo, const T&) const; + inline SelfType& makeLerped(const SelfType& aFrom, const SelfType& aTo, const T&); + static inline SelfType createLerped(const SelfType& aFrom, const SelfType& aTo, const T&); + + inline T dot(const SelfType& aOther) const; + + inline SelfType& cross(const SelfType& aOther); + inline SelfType getCrossed(const SelfType& aOther) const; + inline SelfType& makeCrossed(const SelfType& aFirst, const SelfType& aSecond) const; + static inline SelfType createCrossed(const SelfType& aFirst, const SelfType& aSecond); + + inline T lengthSqr() const; + inline T length() const; + inline T distanceSqr(const SelfType& aOther) const; + inline T distance(const SelfType& aOther) const; + + inline _Vector2 swizzle(unsigned int aX, unsigned int aY) const; + inline _Vector3 swizzle(unsigned int aX, unsigned int aY, unsigned int aZ) const; + inline Vector4 swizzle(unsigned int aX, unsigned int aY, unsigned int aZ, unsigned int aW) const; + }; + + typedef _Vector2 Vec2f; + typedef _Vector2 Vector2; //for use in lua + typedef _Vector2 Vec2d; + + template inline _Vector2 operator+(const T& aLhv, const _Vector2& aRhv); + template inline _Vector2 operator-(const T& aLhv, const _Vector2& aRhv); + template inline _Vector2 operator*(const T& aLhv, const _Vector2& aRhv); + template inline _Vector2 operator/(const T& aLhv, const _Vector2& aRhv); + template inline bool operator==(const _Vector2& aLhv, const T& aRhv); + template inline bool operator==(const T& aLhv, const _Vector2& aRhv); + template inline bool operator!=(const _Vector2& aLhv, const _Vector2& aRhv); + template inline bool operator!=(const _Vector2& aLhv, const T& aRhv); + template inline bool operator!=(const T& aLhv, const _Vector2& aRhv); + + template _Vector2::_Vector2(void) : x(static_cast(0)), y(static_cast(0)) {} + template _Vector2::_Vector2(const T& aValue): x(aValue), y(aValue) {} + template _Vector2::_Vector2(const T* aValue): x(aValue[0]), y(aValue[1]) {} + template _Vector2::_Vector2(const T& aX, const T& aY): x(aX), y(aY) {} + template _Vector2::_Vector2(const _Vector2& aOther): x(aOther.x), y(aOther.y) {} + + template _Vector2& _Vector2::operator=(const _Vector2& aRhv) + { + if (this != &aRhv) + { + x = aRhv.x; + y = aRhv.y; + } + return *this; + } + + template _Vector2& _Vector2::set(const _Vector2& aOther) + { + return *this = aOther; + } + template _Vector2& _Vector2::set(const T& aX, const T& aY) + { + x = aX; + y = aY; + return *this; + } + template _Vector2& _Vector2::set(const T& aValue) + { + x = aValue; + y = aValue; + return *this; + } + template _Vector2& _Vector2::set(const T* aValue) + { + x = aValue[0]; + y = aValue[1]; + return *this; + } + + template _Vector2 _Vector2::operator-() const + { + return getInversed(); + } + template _Vector2& _Vector2::inverse() + { + x = -x; + y = -y; + return *this; + } + template _Vector2 _Vector2::getInversed() const + { + return _Vector2(-x, -y); + } + + template _Vector2& _Vector2::operator+=(const _Vector2& aRhv) + { + x += aRhv.x; + y += aRhv.y; + return *this; + } + template _Vector2& _Vector2::operator+=(const T& aRhv) + { + x += aRhv; + y += aRhv; + return *this; + } + template _Vector2& _Vector2::operator-=(const _Vector2& aRhv) + { + x -= aRhv.x; + y -= aRhv.y; + return *this; + } + template _Vector2& _Vector2::operator-=(const T& aRhv) + { + x -= aRhv; + y -= aRhv; + return *this; + } + template _Vector2& _Vector2::operator*=(const _Vector2& aRhv) + { + x *= aRhv.x; + y *= aRhv.y; + return *this; + } + template _Vector2& _Vector2::operator*=(const T& aRhv) + { + x *= aRhv; + y *= aRhv; + return *this; + } + template _Vector2& _Vector2::operator/=(const _Vector2& aRhv) + { + x /= aRhv.x; + y /= aRhv.y; + return *this; + } + template _Vector2& _Vector2::operator/=(const T& aRhv) + { + x /= aRhv; + y /= aRhv; + return *this; + } + + template T* _Vector2::getPointer() + { + return &x; + } + template const T* _Vector2::getPointer() const + { + return &x; + } + + template _Vector2& _Vector2::normalize() + { + const static T t0(0.0f); + + const T dist = length(); + if(EffectsEqual(t0, dist)) + return *this; + + return operator/=(dist); + } + template _Vector2 _Vector2::getNormalized() const + { + const static T t0(0.0f); + + const T dist = length(); + if(EffectsEqual(t0, dist)) + return *this; + + return *this / dist; + } + + template _Vector2& _Vector2::lerp(const _Vector2& aTo, const T& aCoeff) + { + x += (aTo.x - x) * aCoeff; + y += (aTo.y - y) * aCoeff; + return *this; + } + template _Vector2 _Vector2::getLerped(const _Vector2& aTo, const T& aCoeff) const + { + return _Vector2( + x + (aTo.x - x) * aCoeff, + y + (aTo.y - y) * aCoeff); + } + template _Vector2& _Vector2::makeLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff) + { + return set( + aFrom.x + (aTo.x - aFrom.x) * aCoeff, + aFrom.y + (aTo.y - aFrom.y) * aCoeff); + } + template _Vector2 _Vector2::createLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff) + { + return _Vector2().makeLerped(aFrom, aTo, aCoeff); + } + + template T _Vector2::dot(const _Vector2& aOther) const + { + return x * aOther.x + y * aOther.y; + } + + template _Vector2& _Vector2::cross(const _Vector2& aOther) + { + return set( + y - aOther.y, + aOther.x - x); + } + template _Vector2 _Vector2::getCrossed(const _Vector2& aOther) const + { + return _Vector2( + y - aOther.y, + aOther.x - x); + } + template _Vector2& _Vector2::makeCrossed(const SelfType& aFirst, const SelfType& aSecond) const + { + return set( + aFirst.y - aSecond.y, + aSecond.x - aFirst.x); + } + template _Vector2 _Vector2::createCrossed(const SelfType& aFirst, const SelfType& aSecond) + { + return _Vector2().makeCrossed(aFirst, aSecond); + } + + template T _Vector2::lengthSqr() const + { + return x * x + y * y; + } + template T _Vector2::length() const + { + return effects_sqrt(lengthSqr()); + } + template T _Vector2::distanceSqr(const SelfType& aOther) const + { + const T _x = aOther.x - x; + const T _y = aOther.y - y; + return _x * _x + _y * _y; + } + template T _Vector2::distance(const SelfType& aOther) const + { + return effects_sqrt(distanceSqr(aOther)); + } + + template _Vector2 _Vector2::swizzle(unsigned int aX, unsigned int aY) const + { + const T* pointer = getPointer(); + return _Vector2(pointer[aX], pointer[aY]); + } + + template _Vector3 _Vector2::swizzle(unsigned int aX, unsigned int aY, unsigned int aZ) const + { + const T* pointer = getPointer(); + return _Vector3(pointer[aX], pointer[aY], pointer[aZ]); + } + + template Vector4 _Vector2::swizzle(unsigned int aX, unsigned int aY, unsigned int aZ, unsigned int aW) const + { + const T* pointer = getPointer(); + return Vector4(pointer[aX], pointer[aY], pointer[aZ], pointer[aW]); + } + + + template inline bool isEqual(const _Vector2& aLhv, const _Vector2& aRhv, const T& aEpsilon = effects_epsilon::epsilon()) + { + return EffectsEqual(aLhv.x, aRhv.x, aEpsilon) && EffectsEqual(aLhv.y, aRhv.y, aEpsilon); + } + + template _Vector2 _Vector2::operator+(const _Vector2& aRhv) const + { + return _Vector2(x + aRhv.x, y + aRhv.y); + } + template _Vector2 _Vector2::operator+(const T& aRhv) const + { + return _Vector2(x + aRhv, y + aRhv); + } + + template inline _Vector2 operator+(const T& aLhv, const _Vector2& aRhv) + { + return _Vector2(aLhv + aRhv.x, aLhv + aRhv.y); + } + template _Vector2 _Vector2::operator-(const _Vector2& aRhv) const + { + return _Vector2(x - aRhv.x, y - aRhv.y); + } + template _Vector2 _Vector2::operator-(const T& aRhv) const + { + return _Vector2(x - aRhv, y - aRhv); + } + + template inline _Vector2 operator-(const T& aLhv, const _Vector2& aRhv) + { + return _Vector2(aLhv - aRhv.x, aLhv - aRhv.y); + } + template _Vector2 _Vector2::operator*(const _Vector2& aRhv) const + { + return _Vector2(x * aRhv.x, y * aRhv.y); + } + template _Vector2 _Vector2::operator*(const T& aRhv) const + { + return _Vector2(x * aRhv, y * aRhv); + } + + template inline _Vector2 operator*(const T& aLhv, const _Vector2& aRhv) + { + return _Vector2(aLhv * aRhv.x, aLhv * aRhv.y); + } + template _Vector2 _Vector2::operator/(const _Vector2& aRhv) const + { + if (EffectsEqual(aRhv.x, 0) || EffectsEqual(aRhv.y, 0)) + { + return _Vector2(0, 0); + } + return _Vector2(x / aRhv.x, y / aRhv.y); + } + template _Vector2 _Vector2::operator/(const T& aRhv) const + { + if (EffectsEqual(aRhv, 0)) + { + return _Vector2(0, 0); + } + return _Vector2(x / aRhv, y / aRhv); + } + + template inline _Vector2 operator/(const T& aLhv, const _Vector2& aRhv) + { + return _Vector2(aLhv / aRhv.x, aLhv / aRhv.y); + } + template bool _Vector2::operator==(const _Vector2& aRhv) const + { + return EffectsEqual(x, aRhv.x) && EffectsEqual(y, aRhv.y); + } + + template inline bool operator==(const _Vector2& aLhv, const T& aRhv) + { + return EffectsEqual(aLhv.x, aRhv) && EffectsEqual(aLhv.y, aRhv); + } + template inline bool operator==(const T& aLhv, const _Vector2& aRhv) + { + return EffectsEqual(aLhv, aRhv.x) && EffectsEqual(aLhv, aRhv.x); + } + template inline bool operator!=(const _Vector2& aLhv, const _Vector2& aRhv) + { + return !(aLhv == aRhv); + } + template inline bool operator!=(const _Vector2& aLhv, const T& aRhv) + { + return !(aLhv == aRhv); + } + template inline bool operator!=(const T& aLhv, const _Vector2& aRhv) + { + return !(aLhv == aRhv); + } + } } } } //Tizen::Ui::Effects::_Utils + +#endif //_FUI_EFFECTS_INTERNAL_UTILS_VECTOR2_H_ diff --git a/src/ui/effects/inc/utils/FUiEffects_UtilsVector3.h b/src/ui/effects/inc/utils/FUiEffects_UtilsVector3.h new file mode 100644 index 0000000..2c3c268 --- /dev/null +++ b/src/ui/effects/inc/utils/FUiEffects_UtilsVector3.h @@ -0,0 +1,486 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_UtilsVector3.h + * @brief The _Vector3 class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_UTILS_VECTOR3_H_ +#define _FUI_EFFECTS_INTERNAL_UTILS_VECTOR3_H_ + +#include "FUiEffects_UtilsAdapterFunctions.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Utils +{ + template class _Vector2; + template class Vector4; + + template class _Vector3 + { + private: + typedef _Vector3 SelfType; + + public: + T x; + T y; + T z; + + inline _Vector3(); + inline explicit _Vector3(const T& aValue); + inline explicit _Vector3(const T* aValue); + inline _Vector3(const T& aX, const T& aY, const T& aZ); + inline _Vector3(const _Vector2& aXY, const T& aZ); + inline _Vector3(const T& aX, const _Vector2& aYZ); + inline _Vector3(const SelfType& aOther); + + inline SelfType& operator=(const SelfType& aRhv); + + inline SelfType& set(const SelfType& aOther); + inline SelfType& set(const T& aX, const T& aY, const T& aZ); + inline SelfType& set(const _Vector2& aXY, const T& aZ); + inline SelfType& set(const T& aX, const _Vector2& aYZ); + inline SelfType& set(const T& aValue); + inline SelfType& set(const T* aValue); + + inline SelfType operator-() const; + inline SelfType& inverse(); + inline SelfType getInversed() const; + + inline SelfType& operator+=(const SelfType& aRhv); + inline SelfType& operator+=(const T& aRhv); + inline SelfType& operator-=(const SelfType& aRhv); + inline SelfType& operator-=(const T& aRhv); + inline SelfType& operator*=(const SelfType& aRhv); + inline SelfType& operator*=(const T& aRhv); + inline SelfType& operator/=(const SelfType& aRhv); + inline SelfType& operator/=(const T& aRhv); + + inline SelfType operator+(const SelfType& aRhv) const; + inline SelfType operator+(const T& aRhv) const; + inline SelfType operator-(const SelfType& aRhv) const; + inline SelfType operator-(const T& aRhv) const; + inline SelfType operator*(const SelfType& aRhv) const; + inline SelfType operator*(const T& aRhv) const; + inline SelfType operator/(const SelfType& aRhv) const; + inline SelfType operator/(const T& aRhv) const; + inline bool operator==(const SelfType& aRhv) const; + + inline T* getPointer(); + inline const T* getPointer() const; + + inline SelfType& normalize(); + inline SelfType& GetNormalizedVector3(); // for using in lua + inline SelfType getNormalized() const; + + inline SelfType& lerp(const SelfType& aTo, const T& aCoeff); + inline SelfType getLerped(const SelfType& aTo, const T& aCoeff) const; + inline SelfType& makeLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + static inline SelfType createLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + + inline T dot(const SelfType& aOther) const; + + inline SelfType& cross(const SelfType& aOther); + inline SelfType& GetCrossVector3(const SelfType& aOther); + inline SelfType getCrossed(const SelfType& aOther) const; + inline SelfType& makeCrossed(const SelfType& aFirst, const SelfType& aSecond); + static inline SelfType createCrossed(const SelfType& aFirst, const SelfType& aSecond); + + inline T lengthSqr() const; + inline T length() const; + inline T distanceSqr(const SelfType& aOther) const; + inline T distance(const SelfType& aOther) const; + + inline _Vector2 swizzle(unsigned int aX, unsigned int aY) const; + inline _Vector3 swizzle(unsigned int aX, unsigned int aY, unsigned int aZ) const; + inline Vector4 swizzle(unsigned int aX, unsigned int aY, unsigned int aZ, unsigned int aW) const; + }; + + typedef _Vector3 Vec3f; + typedef _Vector3 Vector3; //for use in lua + typedef _Vector3 Vec3d; + + template inline _Vector3 operator+(const T& aLhv, const _Vector3& aRhv); + template inline _Vector3 operator-(const T& aLhv, const _Vector3& aRhv); + template inline _Vector3 operator*(const T& aLhv, const _Vector3& aRhv); + template inline _Vector3 operator/(const T& aLhv, const _Vector3& aRhv); + template inline bool operator==(const _Vector3& aLhv, const T& aRhv); + template inline bool operator==(const T& aLhv, const _Vector3& aRhv); + template inline bool operator!=(const _Vector3& aLhv, const _Vector3& aRhv); + template inline bool operator!=(const _Vector3& aLhv, const T& aRhv); + template inline bool operator!=(const T& aLhv, const _Vector3& aRhv); + + template _Vector3::_Vector3(void) : x(static_cast(0)), y(static_cast(0)), z(static_cast(0)) {} + template _Vector3::_Vector3(const T& aValue): x(aValue), y(aValue), z(aValue) {} + template _Vector3::_Vector3(const T* aValue): x(aValue[0]), y(aValue[1]), z(aValue[2]) {} + template _Vector3::_Vector3(const T& aX, const T& aY, const T& aZ): x(aX), y(aY), z(aZ) {} + template _Vector3::_Vector3(const _Vector2& aXY, const T& aZ): x(aXY.x), y(aXY.y), z(aZ) {} + template _Vector3::_Vector3(const T& aX, const _Vector2& aYZ): x(aX), y(aYZ.x), z(aYZ.y) {} + template _Vector3::_Vector3(const _Vector3& aOther): x(aOther.x), y(aOther.y), z(aOther.z) {} + + template _Vector3& _Vector3::operator=(const _Vector3& aRhv) + { + if (this != &aRhv) + { + x = aRhv.x; + y = aRhv.y; + z = aRhv.z; + } + return *this; + } + + template _Vector3& _Vector3::set(const _Vector3& aOther) + { + return *this = aOther; + } + template _Vector3& _Vector3::set(const T& aX, const T& aY, const T& aZ) + { + x = aX; + y = aY; + z = aZ; + return *this; + } + template _Vector3& _Vector3::set(const _Vector2& aXY, const T& aZ) + { + x = aXY.x; + y = aXY.y; + z = aZ; + return *this; + } + template _Vector3& _Vector3::set(const T& aX, const _Vector2& aYZ) + { + x = aX; + y = aYZ.x; + z = aYZ.y; + return *this; + } + template _Vector3& _Vector3::set(const T& aValue) + { + x = aValue; + y = aValue; + z = aValue; + return *this; + } + template _Vector3& _Vector3::set(const T* aValue) + { + x = aValue[0]; + y = aValue[1]; + z = aValue[2]; + return *this; + } + + template _Vector3 _Vector3::operator-() const + { + return getInversed(); + } + template _Vector3& _Vector3::inverse() + { + x = -x; + y = -y; + z = -z; + return *this; + } + template _Vector3 _Vector3::getInversed() const + { + return _Vector3(-x, -y, -z); + } + + template _Vector3& _Vector3::operator+=(const _Vector3& aRhv) + { + x += aRhv.x; + y += aRhv.y; + z += aRhv.z; + return *this; + } + template _Vector3& _Vector3::operator+=(const T& aRhv) + { + x += aRhv; + y += aRhv; + z += aRhv; + return *this; + } + template _Vector3& _Vector3::operator-=(const _Vector3& aRhv) + { + x -= aRhv.x; + y -= aRhv.y; + z -= aRhv.z; + return *this; + } + template _Vector3& _Vector3::operator-=(const T& aRhv) + { + x -= aRhv; + y -= aRhv; + z -= aRhv; + return *this; + } + template _Vector3& _Vector3::operator*=(const _Vector3& aRhv) + { + x *= aRhv.x; + y *= aRhv.y; + z *= aRhv.z; + return *this; + } + template _Vector3& _Vector3::operator*=(const T& aRhv) + { + x *= aRhv; + y *= aRhv; + z *= aRhv; + return *this; + } + template _Vector3& _Vector3::operator/=(const _Vector3& aRhv) + { + x /= aRhv.x; + y /= aRhv.y; + z /= aRhv.z; + return *this; + } + template _Vector3& _Vector3::operator/=(const T& aRhv) + { + x /= aRhv; + y /= aRhv; + z /= aRhv; + return *this; + } + + template T* _Vector3::getPointer() + { + return &x; + } + template const T* _Vector3::getPointer() const + { + return &x; + } + + template _Vector3& _Vector3::normalize() + { + const static T t0(0.0f); + + const T dist = length(); + if(EffectsEqual(t0, dist)) + return *this; + + return operator/=(dist); + } + //--- for using in lua --------------------------------------------------------- + template _Vector3& _Vector3::GetNormalizedVector3() + { + return normalize(); + } + //------------------------------------------------------------------------------ + template _Vector3 _Vector3::getNormalized() const + { + const static T t0(0.0f); + + const T dist = length(); + if(EffectsEqual(t0, dist)) + return *this; + + return *this / dist; + } + + template _Vector3& _Vector3::lerp(const _Vector3& aTo, const T& aCoeff) + { + x += (aTo.x - x) * aCoeff; + y += (aTo.y - y) * aCoeff; + z += (aTo.z - z) * aCoeff; + return *this; + } + template _Vector3 _Vector3::getLerped(const _Vector3& aTo, const T& aCoeff) const + { + return _Vector3( + x + (aTo.x - x) * aCoeff, + y + (aTo.y - y) * aCoeff, + z + (aTo.z - z) * aCoeff); + } + template _Vector3& _Vector3::makeLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff) + { + return set( + aFrom.x + (aTo.x - aFrom.x) * aCoeff, + aFrom.y + (aTo.y - aFrom.y) * aCoeff, + aFrom.z + (aTo.z - aFrom.z) * aCoeff); + } + template _Vector3 _Vector3::createLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff) + { + return _Vector3().makeLerped(aFrom, aTo, aCoeff); + } + + template T _Vector3::dot(const _Vector3& aOther) const + { + return x * aOther.x + y * aOther.y + z * aOther.z; + } + + template _Vector3& _Vector3::cross(const _Vector3& aOther) + { + return set( + (y * aOther.z - z * aOther.y), + (z * aOther.x - x * aOther.z), + (x * aOther.y - y * aOther.x)); + } + //--- for using in lua code ----------------------------------------------------------- + template _Vector3& _Vector3::GetCrossVector3(const _Vector3& aOther) + { + return cross(aOther); + } + //-------------------------------------------------------------------------------------- + template _Vector3 _Vector3::getCrossed(const _Vector3& aOther) const + { + return _Vector3( + (y * aOther.z - z * aOther.y), + (z * aOther.x - x * aOther.z), + (x * aOther.y - y * aOther.x)); + } + template _Vector3& _Vector3::makeCrossed(const SelfType& aFirst, const SelfType& aSecond) + { + return set( + (aFirst.y * aSecond.z - aFirst.z * aSecond.y), + (aFirst.z * aSecond.x - aFirst.x * aSecond.z), + (aFirst.x * aSecond.y - aFirst.y * aSecond.x)); + } + template _Vector3 _Vector3::createCrossed(const SelfType& aFirst, const SelfType& aSecond) + { + return _Vector3().makeCrossed(aFirst, aSecond); + } + + template T _Vector3::lengthSqr() const + { + return x * x + y * y + z * z; + } + template T _Vector3::length() const + { + return effects_sqrt(lengthSqr()); + } + template T _Vector3::distanceSqr(const SelfType& aOther) const + { + T _x = aOther.x - x; + T _y = aOther.y - y; + T _z = aOther.z - z; + return _x * _x + _y * _y + _z * _z; + } + template T _Vector3::distance(const SelfType& aOther) const + { + return effects_sqrt(distanceSqr(aOther)); + } + + template _Vector2 _Vector3::swizzle(unsigned int aX, unsigned int aY) const + { + const T* pointer = getPointer(); + return _Vector2(pointer[aX], pointer[aY]); + } + template _Vector3 _Vector3::swizzle(unsigned int aX, unsigned int aY, unsigned int aZ) const + { + const T* pointer = getPointer(); + return _Vector3(pointer[aX], pointer[aY], pointer[aZ]); + } + template Vector4 _Vector3::swizzle(unsigned int aX, unsigned int aY, unsigned int aZ, unsigned int aW) const + { + const T* pointer = getPointer(); + return Vector4(pointer[aX], pointer[aY], pointer[aZ], pointer[aW]); + } + + template inline bool isEqual(const _Vector3& aLhv, const _Vector3& aRhv, const T& aEpsilon = effects_epsilon::epsilon()) + { + return EffectsEqual(aLhv.x, aRhv.x, aEpsilon) && EffectsEqual(aLhv.y, aRhv.y, aEpsilon) && EffectsEqual(aLhv.z, aRhv.z, aEpsilon); + } + template _Vector3 _Vector3::operator+(const _Vector3& aRhv) const + { + return _Vector3(x + aRhv.x, y + aRhv.y, z + aRhv.z); + } + template _Vector3 _Vector3::operator+(const T& aRhv) const + { + return _Vector3(x + aRhv, y + aRhv, z + aRhv); + } + + template inline _Vector3 operator+(const T& aLhv, const _Vector3& aRhv) + { + return _Vector3(aLhv + aRhv.x, aLhv + aRhv.y, aLhv + aRhv.z); + } + template _Vector3 _Vector3::operator-(const _Vector3& aRhv) const + { + return _Vector3(x - aRhv.x, y - aRhv.y, z - aRhv.z); + } + template _Vector3 _Vector3::operator-(const T& aRhv) const + { + return _Vector3(x - aRhv, y - aRhv, z - aRhv); + } + + template inline _Vector3 operator-(const T& aLhv, const _Vector3& aRhv) + { + return _Vector3(aLhv - aRhv.x, aLhv - aRhv.y, aLhv - aRhv.z); + } + template _Vector3 _Vector3::operator*(const _Vector3& aRhv) const + { + return _Vector3(x * aRhv.x, y * aRhv.y, z * aRhv.z); + } + template _Vector3 _Vector3::operator*(const T& aRhv) const + { + return _Vector3(x * aRhv, y * aRhv, z * aRhv); + } + + template inline _Vector3 operator*(const T& aLhv, const _Vector3& aRhv) + { + return _Vector3(aLhv * aRhv.x, aLhv * aRhv.y, aLhv * aRhv.z); + } + template _Vector3 _Vector3::operator/(const _Vector3& aRhv) const + { + if (EffectsEqual(aRhv.x, 0) || EffectsEqual(aRhv.y, 0) || EffectsEqual(aRhv.z, 0)) + { + return _Vector3(0, 0, 0); + } + return _Vector3(x / aRhv.x, y / aRhv.y, z / aRhv.z); + } + template _Vector3 _Vector3::operator/(const T& aRhv) const + { + if (EffectsEqual(aRhv, 0)) + { + return _Vector3(0, 0, 0); + } + return _Vector3(x / aRhv, y / aRhv, z / aRhv); + } + + template inline _Vector3 operator/(const T& aLhv, const _Vector3& aRhv) + { + return _Vector3(aLhv / aRhv.x, aLhv / aRhv.y, aLhv / aRhv.z); + } + template bool _Vector3::operator==(const _Vector3& aRhv) const + { + return EffectsEqual(x, aRhv.x) && EffectsEqual(y, aRhv.y) && EffectsEqual(z, aRhv.z); + } + + template inline bool operator==(const _Vector3& aLhv, const T& aRhv) + { + return EffectsEqual(aLhv.x, aRhv) && EffectsEqual(aLhv.y, aRhv) && EffectsEqual(aLhv.z, aRhv); + } + template inline bool operator==(const T& aLhv, const _Vector3& aRhv) + { + return EffectsEqual(aLhv, aRhv.x) && EffectsEqual(aLhv, aRhv.x) && EffectsEqual(aLhv, aRhv.z); + } + template inline bool operator!=(const _Vector3& aLhv, const _Vector3& aRhv) + { + return !(aLhv == aRhv); + } + template inline bool operator!=(const _Vector3& aLhv, const T& aRhv) + { + return !(aLhv == aRhv); + } + template inline bool operator!=(const T& aLhv, const _Vector3& aRhv) + { + return !(aLhv == aRhv); + } +} } } } //Tizen::Ui::Effects::_Utils + +#endif //_FUI_EFFECTS_INTERNAL_UTILS_VECTOR3_H_ diff --git a/src/ui/effects/inc/utils/FUiEffects_UtilsVector4.h b/src/ui/effects/inc/utils/FUiEffects_UtilsVector4.h new file mode 100644 index 0000000..a0f1b81 --- /dev/null +++ b/src/ui/effects/inc/utils/FUiEffects_UtilsVector4.h @@ -0,0 +1,487 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_UtilsVector4.h + * @brief The Vector4 class + * + */ + +#ifndef _FUI_EFFECTS_INTERNAL_UTILS_VECTOR4_H_ +#define _FUI_EFFECTS_INTERNAL_UTILS_VECTOR4_H_ + +#include "FUiEffects_UtilsAdapterFunctions.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Utils +{ + template class _Vector2; + template class _Vector3; + + template class Vector4 + { + private: + typedef Vector4 SelfType; + + public: + T x; + T y; + T z; + T w; + + inline Vector4(); + inline explicit Vector4(const T& aValue); + inline explicit Vector4(const T* aValue); + inline Vector4(const T& aX, const T& aY, const T& aZ, const T& aW); + inline Vector4(const _Vector2& aXY, const T& aZ, const T& aW); + inline Vector4(const T& aX, const _Vector2& aYZ, const T& aW); + inline Vector4(const T& aX, const T& aY, const _Vector2& aZW); + inline Vector4(const _Vector3& aXYZ, const T& aW); + inline Vector4(const T& aX, const _Vector3& aYZW); + inline Vector4(const _Vector2& aXY, const _Vector2& aZW); + inline Vector4(const SelfType& aOther); + + inline SelfType& operator=(const SelfType& aRhv); + + inline SelfType& set(const SelfType& aOther); + inline SelfType& set(const T& aX, const T& aY, const T& aZ, const T& aW); + inline SelfType& set(const T& aValue); + inline SelfType& set(const T* aValue); + inline SelfType& set(const _Vector2& aXY, const T& aZ, const T& aW); + inline SelfType& set(const T& aX, const _Vector2& aYZ, const T& aW); + inline SelfType& set(const T& aX, const T& aY, const _Vector2& aZW); + inline SelfType& set(const _Vector3& aXYZ, const T& aW); + inline SelfType& set(const T& aX, const _Vector3& aYZW); + inline SelfType& set(const _Vector2& aXY, const _Vector2& aZW); + + inline SelfType operator-() const; + inline SelfType& inverse(); + inline SelfType getInversed() const; + + inline SelfType& operator+=(const SelfType& aRhv); + inline SelfType& operator+=(const T& aRhv); + inline SelfType& operator-=(const SelfType& aRhv); + inline SelfType& operator-=(const T& aRhv); + inline SelfType& operator*=(const SelfType& aRhv); + inline SelfType& operator*=(const T& aRhv); + inline SelfType& operator/=(const SelfType& aRhv); + inline SelfType& operator/=(const T& aRhv); + + inline T* getPointer(); + inline const T* getPointer() const; + + inline SelfType& normalize(); + inline SelfType getNormalized() const; + + inline SelfType& lerp(const SelfType& aTo, const T& aCoeff); + inline SelfType getLerped(const SelfType& aTo, const T& aCoeff) const; + inline SelfType& makeLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + static inline SelfType createLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff); + + inline T dot(const SelfType& aOther) const; + + inline T lengthSqr() const; + inline T length() const; + inline T distanceSqr(const SelfType& aOther) const; + inline T distance(const SelfType& aOther) const; + + inline _Vector2 swizzle(unsigned int aX, unsigned int aY) const; + inline _Vector3 swizzle(unsigned int aX, unsigned int aY, unsigned int aZ) const; + inline Vector4 swizzle(unsigned int aX, unsigned int aY, unsigned int aZ, unsigned int aW) const; + }; + + typedef Vector4 Vec4f; + typedef Vector4 Vec4d; + + template inline Vector4 operator+(const Vector4& aLhv, const Vector4& aRhv); + template inline Vector4 operator+(const Vector4& aLhv, const T& aRhv); + template inline Vector4 operator+(const T& aLhv, const Vector4& aRhv); + template inline Vector4 operator-(const Vector4& aLhv, const Vector4& aRhv); + template inline Vector4 operator-(const Vector4& aLhv, const T& aRhv); + template inline Vector4 operator-(const T& aLhv, const Vector4& aRhv); + template inline Vector4 operator*(const Vector4& aLhv, const Vector4& aRhv); + template inline Vector4 operator*(const Vector4& aLhv, const T& aRhv); + template inline Vector4 operator*(const T& aLhv, const Vector4& aRhv); + template inline Vector4 operator/(const Vector4& aLhv, const Vector4& aRhv); + template inline Vector4 operator/(const Vector4& aLhv, const T& aRhv); + template inline Vector4 operator/(const T& aLhv, const Vector4& aRhv); + template inline bool operator==(const Vector4& aLhv, const Vector4& aRhv); + template inline bool operator==(const Vector4& aLhv, const T& aRhv); + template inline bool operator==(const T& aLhv, const Vector4& aRhv); + template inline bool operator!=(const Vector4& aLhv, const Vector4& aRhv); + template inline bool operator!=(const Vector4& aLhv, const T& aRhv); + template inline bool operator!=(const T& aLhv, const Vector4& aRhv); + + template Vector4::Vector4() {} + template Vector4::Vector4(const T& aValue): x(aValue), y(aValue), z(aValue), w(aValue) {} + template Vector4::Vector4(const T* aValue): x(aValue[0]), y(aValue[1]), z(aValue[2]), w(aValue[3]) {} + template Vector4::Vector4(const T& aX, const T& aY, const T& aZ, const T& aW): x(aX), y(aY), z(aZ), w(aW) {} + template Vector4::Vector4(const Vector4& aOther): x(aOther.x), y(aOther.y), z(aOther.z), w(aOther.w) {} + template Vector4::Vector4(const _Vector2& aXY, const T& aZ, const T& aW): x(aXY.x), y(aXY.y), z(aZ), w(aW) {} + template Vector4::Vector4(const T& aX, const _Vector2& aYZ, const T& aW): x(aX), y(aYZ.x), z(aYZ.y), w(aW) {} + template Vector4::Vector4(const T& aX, const T& aY, const _Vector2& aZW): x(aX), y(aY), z(aZW.x), w(aZW.y) {} + template Vector4::Vector4(const _Vector3& aXYZ, const T& aW): x(aXYZ.x), y(aXYZ.y), z(aXYZ.z), w(aW) {} + template Vector4::Vector4(const T& aX, const _Vector3& aYZW): x(aX), y(aYZW.x), z(aYZW.y), w(aYZW.z) {} + template Vector4::Vector4(const _Vector2& aXY, const _Vector2& aZW): x(aXY.x), y(aXY.y), z(aZW.x), w(aZW.y) {} + + template Vector4& Vector4::operator=(const Vector4& aRhv) + { + x = aRhv.x; + y = aRhv.y; + z = aRhv.z; + w = aRhv.w; + return *this; + } + + template Vector4& Vector4::set(const Vector4& aOther) + { + return *this = aOther; + } + template Vector4& Vector4::set(const T& aX, const T& aY, const T& aZ, const T& aW) + { + x = aX; + y = aY; + z = aZ; + w = aW; + return *this; + } + template Vector4& Vector4::set(const T& aValue) + { + x = aValue; + y = aValue; + z = aValue; + w = aValue; + return *this; + } + template Vector4& Vector4::set(const T* aValue) + { + x = aValue[0]; + y = aValue[1]; + z = aValue[2]; + w = aValue[3]; + return *this; + } + template Vector4& Vector4::set(const _Vector2& aXY, const T& aZ, const T& aW) + { + x = aXY.x; + y = aXY.y; + z = aZ; + w = aW; + return *this; + } + template Vector4& Vector4::set(const T& aX, const _Vector2& aYZ, const T& aW) + { + x = aX; + y = aYZ.x; + z = aYZ.y; + w = aW; + return *this; + } + template Vector4& Vector4::set(const T& aX, const T& aY, const _Vector2& aZW) + { + x = aX; + y = aY; + z = aZW.x; + w = aZW.y; + return *this; + } + template Vector4& Vector4::set(const _Vector3& aXYZ, const T& aW) + { + x = aXYZ.x; + y = aXYZ.y; + z = aXYZ.z; + w = aW; + return *this; + } + template Vector4& Vector4::set(const T& aX, const _Vector3& aYZW) + { + x = aX; + y = aYZW.x; + z = aYZW.y; + w = aYZW.z; + return *this; + } + template Vector4& Vector4::set(const _Vector2& aXY, const _Vector2& aZW) + { + x = aXY.x; + y = aXY.y; + z = aZW.x; + w = aZW.y; + return *this; + } + + template Vector4 Vector4::operator-() const + { + return getInversed(); + } + template Vector4& Vector4::inverse() + { + x = -x; + y = -y; + z = -z; + w = -w; + return *this; + } + template Vector4 Vector4::getInversed() const + { + return Vector4(-x, -y, -z, -w); + } + + template Vector4& Vector4::operator+=(const Vector4& aRhv) + { + x += aRhv.x; + y += aRhv.y; + z += aRhv.z; + w += aRhv.w; + return *this; + } + template Vector4& Vector4::operator+=(const T& aRhv) + { + x += aRhv; + y += aRhv; + z += aRhv; + w += aRhv; + return *this; + } + template Vector4& Vector4::operator-=(const Vector4& aRhv) + { + x -= aRhv.x; + y -= aRhv.y; + z -= aRhv.z; + w -= aRhv.w; + return *this; + } + template Vector4& Vector4::operator-=(const T& aRhv) + { + x -= aRhv; + y -= aRhv; + z -= aRhv; + w -= aRhv; + return *this; + } + template Vector4& Vector4::operator*=(const Vector4& aRhv) + { + x *= aRhv.x; + y *= aRhv.y; + z *= aRhv.z; + w *= aRhv.w; + return *this; + } + template Vector4& Vector4::operator*=(const T& aRhv) + { + x *= aRhv; + y *= aRhv; + z *= aRhv; + w *= aRhv; + return *this; + } + template Vector4& Vector4::operator/=(const Vector4& aRhv) + { + x /= aRhv.x; + y /= aRhv.y; + z /= aRhv.z; + w /= aRhv.w; + return *this; + } + template Vector4& Vector4::operator/=(const T& aRhv) + { + x /= aRhv; + y /= aRhv; + z /= aRhv; + w /= aRhv; + return *this; + } + + template T* Vector4::getPointer() + { + return &x; + } + template const T* Vector4::getPointer() const + { + return &x; + } + + template Vector4& Vector4::normalize() + { + const static T t0(0.0f); + + const T dist = length(); + if(EffectsEqual(t0, dist)) + return *this; + + return operator/=(dist); + } + template Vector4 Vector4::getNormalized() const + { + const static T t0(0.0f); + + const T dist = length(); + if(EffectsEqual(t0, dist)) + return *this; + + return *this / dist; + } + + template Vector4& Vector4::lerp(const Vector4& aTo, const T& aCoeff) + { + x += (aTo.x - x) * aCoeff; + y += (aTo.y - y) * aCoeff; + z += (aTo.z - z) * aCoeff; + w += (aTo.w - w) * aCoeff; + return *this; + } + template Vector4 Vector4::getLerped(const Vector4& aTo, const T& aCoeff) const + { + return Vector4( + x + (aTo.x - x) * aCoeff, + y + (aTo.y - y) * aCoeff, + z + (aTo.z - z) * aCoeff, + w + (aTo.w - w) * aCoeff); + } + template Vector4& Vector4::makeLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff) + { + return set( + aFrom.x + (aTo.x - aFrom.x) * aCoeff, + aFrom.y + (aTo.y - aFrom.y) * aCoeff, + aFrom.z + (aTo.z - aFrom.z) * aCoeff, + aFrom.w + (aTo.w - aFrom.w) * aCoeff); + } + template Vector4 Vector4::createLerped(const SelfType& aFrom, const SelfType& aTo, const T& aCoeff) + { + return Vector4().makeLerped(aFrom, aTo, aCoeff); + } + + template T Vector4::dot(const Vector4& aOther) const + { + return x * aOther.x + y * aOther.y + z * aOther.z + w * aOther.w; + } + + template T Vector4::lengthSqr() const + { + return x * x + y * y + z * z + w * w; + } + template T Vector4::length() const + { + return effects_sqrt(lengthSqr()); + } + template T Vector4::distanceSqr(const SelfType& aOther) const + { + T _x = aOther.x - x; + T _y = aOther.y - y; + T _z = aOther.z - z; + T _w = aOther.w - w; + return _x * _x + _y * _y + _z * _z + _w * _w; + } + template T Vector4::distance(const SelfType& aOther) const + { + return effects_sqrt(distanceSqr(aOther)); + } + + template _Vector2 Vector4::swizzle(unsigned int aX, unsigned int aY) const + { + const T* pointer = getPointer(); + return _Vector2(pointer[aX], pointer[aY]); + } + template _Vector3 Vector4::swizzle(unsigned int aX, unsigned int aY, unsigned int aZ) const + { + const T* pointer = getPointer(); + return _Vector3(pointer[aX], pointer[aY], pointer[aZ]); + } + template Vector4 Vector4::swizzle(unsigned int aX, unsigned int aY, unsigned int aZ, unsigned int aW) const + { + const T* pointer = getPointer(); + return Vector4(pointer[aX], pointer[aY], pointer[aZ], pointer[aW]); + } + + template inline bool isEqual(const Vector4& aLhv, const Vector4& aRhv, const T& aEpsilon = effects_epsilon::epsilon()) + { + return EffectsEqual(aLhv.x, aRhv.x, aEpsilon) && EffectsEqual(aLhv.y, aRhv.y, aEpsilon) && EffectsEqual(aLhv.z, aRhv.z, aEpsilon) && EffectsEqual(aLhv.w, aRhv.w, aEpsilon); + } + template inline Vector4 operator+(const Vector4& aLhv, const Vector4& aRhv) + { + return Vector4(aLhv.x + aRhv.x, aLhv.y + aRhv.y, aLhv.z + aRhv.z, aLhv.w + aRhv.w); + } + template inline Vector4 operator+(const Vector4& aLhv, const T& aRhv) + { + return Vector4(aLhv.x + aRhv, aLhv.y + aRhv, aLhv.z + aRhv, aLhv.w + aRhv); + } + template inline Vector4 operator+(const T& aLhv, const Vector4& aRhv) + { + return Vector4(aLhv + aRhv.x, aLhv + aRhv.y, aLhv + aRhv.z, aLhv + aRhv.w); + } + template inline Vector4 operator-(const Vector4& aLhv, const Vector4& aRhv) + { + return Vector4(aLhv.x - aRhv.x, aLhv.y - aRhv.y, aLhv.z - aRhv.z, aLhv.w - aRhv.w); + } + template inline Vector4 operator-(const Vector4& aLhv, const T& aRhv) + { + return Vector4(aLhv.x - aRhv, aLhv.y - aRhv, aLhv.z - aRhv, aLhv.w - aRhv); + } + template inline Vector4 operator-(const T& aLhv, const Vector4& aRhv) + { + return Vector4(aLhv - aRhv.x, aLhv - aRhv.y, aLhv - aRhv.z, aLhv - aRhv.w); + } + template inline Vector4 operator*(const Vector4& aLhv, const Vector4& aRhv) + { + return Vector4(aLhv.x * aRhv.x, aLhv.y * aRhv.y, aLhv.z * aRhv.z, aLhv.w * aRhv.w); + } + template inline Vector4 operator*(const Vector4& aLhv, const T& aRhv) + { + return Vector4(aLhv.x * aRhv, aLhv.y * aRhv, aLhv.z * aRhv, aLhv.w * aRhv); + } + template inline Vector4 operator*(const T& aLhv, const Vector4& aRhv) + { + return Vector4(aLhv * aRhv.x, aLhv * aRhv.y, aLhv * aRhv.z, aLhv * aRhv.w); + } + template inline Vector4 operator/(const Vector4& aLhv, const Vector4& aRhv) + { + return Vector4(aLhv.x / aRhv.x, aLhv.y / aRhv.y, aLhv.z / aRhv.z, aLhv.w / aRhv.w); + } + template inline Vector4 operator/(const Vector4& aLhv, const T& aRhv) + { + return Vector4(aLhv.x / aRhv, aLhv.y / aRhv, aLhv.z / aRhv, aLhv.w / aRhv); + } + template inline Vector4 operator/(const T& aLhv, const Vector4& aRhv) + { + return Vector4(aLhv / aRhv.x, aLhv / aRhv.y, aLhv / aRhv.z, aLhv / aRhv.w); + } + template inline bool operator==(const Vector4& aLhv, const Vector4& aRhv) + { + return EffectsEqual(aLhv.x, aRhv.x) && EffectsEqual(aLhv.y, aRhv.y) && EffectsEqual(aLhv.z, aRhv.z) && EffectsEqual(aLhv.w, aRhv.w); + } + template inline bool operator==(const Vector4& aLhv, const T& aRhv) + { + return EffectsEqual(aLhv.x, aRhv) && EffectsEqual(aLhv.y, aRhv) && EffectsEqual(aLhv.z, aRhv) && EffectsEqual(aLhv.w, aRhv); + } + template inline bool operator==(const T& aLhv, const Vector4& aRhv) + { + return EffectsEqual(aLhv, aRhv.x) && EffectsEqual(aLhv, aRhv.x) && EffectsEqual(aLhv, aRhv.z) && EffectsEqual(aLhv, aRhv.w); + } + template inline bool operator!=(const Vector4& aLhv, const Vector4& aRhv) + { + return !(aLhv == aRhv); + } + template inline bool operator!=(const Vector4& aLhv, const T& aRhv) + { + return !(aLhv == aRhv); + } + template inline bool operator!=(const T& aLhv, const Vector4& aRhv) + { + return !(aLhv == aRhv); + } +} } } } //Tizen::Ui::Effects::_Utils + +#endif //_FUI_EFFECTS_INTERNAL_UTILS_VECTOR4_H_ diff --git a/src/ui/effects/parser/FUiEffects_ParserEffectParser.cpp b/src/ui/effects/parser/FUiEffects_ParserEffectParser.cpp new file mode 100644 index 0000000..8c86633 --- /dev/null +++ b/src/ui/effects/parser/FUiEffects_ParserEffectParser.cpp @@ -0,0 +1,2286 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include + +#include +#include +#include "../FUiEffects_EffectErrorMessages.h" + +#include +#include +#include +#include + +using namespace Tizen::Ui::Effects::_Runtime; +using namespace Tizen::Ui::Effects::_PhysicsEngine; +using namespace Tizen::Ui::Effects::_Renderer; +using namespace Tizen::Ui::Effects::_Utils; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Parser +{ + +EffectParser* EffectParser::__pInstance = null; + +const std::string EffectParser::__MANIFEST_FILE_NAME = "manifest.xml"; +const std::string EffectParser::__SCENE_FILE_NAME = "scene.xml"; +const std::string EffectParser::__SCRIPT_FILE_NAME = "script.lua"; + +namespace +{ +bool +FileExists(const char* pPath) +{ + bool result = true; + std::fstream file; + + file.open(pPath, std::fstream::in); + + if (file.is_open()) + { + file.close(); + } + else + { + result = false; + } + + return result; +} +} // namespace + +Vec3f EffectParser::StringHexToRgb(const std::string& stringColor) +{ + Vec3f rgbColor; + unsigned long int bytes = strtoul(stringColor.c_str(), null, 16); + + unsigned char nextByte = bytes; + rgbColor.z = nextByte / float (UCHAR_MAX); + bytes = bytes >> CHAR_BIT; + nextByte = bytes; + rgbColor.y = nextByte / float (UCHAR_MAX); + bytes = bytes >> CHAR_BIT; + nextByte = bytes; + rgbColor.x = nextByte / float (UCHAR_MAX); + + return rgbColor; +} + +EffectParser::SceneData::SceneData() + : timerTimeout(0u) + , ambientColor(Vec3f(1.0f, 1.0f, 1.0f)) + , intensity(1.0f) + , attenuation(0.f) +{ +} + +EffectParser::ViewportData::ViewportData() + : x(0.f) + , y(0.f) + , z(0.f) + , width(0.f) + , height(0.f) + , near(0.f) + , far(0.f) + , angle(0.f) + , perspective(false) +{ +} + +EffectParser::EffectParser(void) + : __pXmlParser(null) + , __currentModelFilesDirectoryPath("") + , __elementBuffer(0) + , __pointSurfaceNurbsIndices() + , __elementSurfaceBuffer(0) + , __unitLightBuffer(0) + , __pCurrentGraphicalSurface(null) + , __currentGravityForce(0, 0, 0) + , __currentGravityForceValue(0.f) + , __modelSurfaceBuffer(0) + , __lastSceneXMLElementIndex(0) + , __lastModelSurfaceXMLElementIndex(0) + , __lastGraphicalSurfaceXMLElementIndex(0) + , __pCurrentEffectModel(null) + , __pCurrentEffectManager(null) + , __currentEffectId(0l) + , __currentModelBehaviourType(EFFECT_TYPE_TIME_BASED) + , __currentEffectDuration(0.f) + , __currentEffectInstanceName("") + , __currentModelSurfaceX(0.f) + , __currentModelSurfaceY(0.f) + , __currentGraphicalSurfaceDimCtrlX(0u) + , __currentGraphicalSurfaceDimCtrlY(0u) + , __insideGraphicalSurface(false) + , __rightAfterSceneStart(false) + , __rightAfterModelSurfaceStart(false) + , __rightAfterGraphicalSurfaceStart(false) + , __insideVectorX(false) + , __insideVectorY(false) + , __buildingModelFailed(false) + , __insideElementsPool(false) +{ + __pXmlParser = std::unique_ptr(new (std::nothrow) XmlParser(this)); + + SysTryReturnVoidResult(NID_UI_EFFECT, + __pXmlParser.get() != null, + E_OUT_OF_MEMORY, + _UiEffectError::OUT_OF_MEMORY + ); +} + +EffectParser::~EffectParser(void) +{ + __pInstance = null; +} + +bool +EffectParser::ExtractModelFiles(const char* pPath) +{ + bool result = true; + + if (!XmlParser::ExtractFromArchive(pPath, __currentModelFilesDirectoryPath.c_str())) + { + SysLogException(NID_UI_EFFECT, result = false, "Effects. Unzipping of \"%s\" failed!", pPath); + } + + if (result) + { + std::string sceneFilePath = __currentModelFilesDirectoryPath + __SCENE_FILE_NAME; + std::string manifestFilePath = __currentModelFilesDirectoryPath + __MANIFEST_FILE_NAME; + std::string scriptFilePath = __currentModelFilesDirectoryPath + __SCRIPT_FILE_NAME; + + if ( !FileExists(sceneFilePath.c_str()) || + !FileExists(manifestFilePath.c_str()) || + !FileExists(scriptFilePath.c_str())) + { + SysLogException(NID_UI_EFFECT, result = false, "Effects. Effect file is incomplete!", pPath); + } + } + + return result; +} + +bool +EffectParser::ParseEffectFile(const char* pEffectFilePath, const char* pModelFilesDirectoryPath) +{ + bool result = true; + std::string sceneFilePath; + std::string manifestFilePath; + + if (__pInstance == null) + { + __pInstance = new (std::nothrow) EffectParser(); + } + + SysTryCatchLabel(NID_UI_EFFECT, __pInstance != null, result = false, CATCH1, E_OUT_OF_MEMORY, Tizen::Ui::Effects::_UiEffectError::OUT_OF_MEMORY); + + SysTryCatchLabel(NID_UI_EFFECT, __pInstance->__pXmlParser != null, result = false, CATCH1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pInstance->__currentModelFilesDirectoryPath = pModelFilesDirectoryPath; + + sceneFilePath = __pInstance->__currentModelFilesDirectoryPath + __SCENE_FILE_NAME; + manifestFilePath = __pInstance->__currentModelFilesDirectoryPath + __MANIFEST_FILE_NAME; + + __pInstance->__buildingModelFailed = false; + + SysTryCatchLabel(NID_UI_EFFECT, __pInstance->ExtractModelFiles(pEffectFilePath), result = false; + __pInstance->ClearModelFiles(); , CATCH2, E_OPERATION_FAILED, Tizen::Ui::Effects::_UiEffectError::EP_EXTRACTING_MODEL_FILES_FAILED); + + result = __pInstance->__pXmlParser->Parse(manifestFilePath.c_str(), false) && __pInstance->__pXmlParser->Parse(sceneFilePath.c_str(), false); + + __pInstance->ClearModelFiles(); // should always go before calling _clearBuffers() + __pInstance->ClearBuffers(); // not necessary unless XMLParser was sending callbacks by mistake + + if (result) + { + SysLog(NID_UI_EFFECT, "Effects. XML-parsing of the XML-files was successful"); + } + else + { + SysLog(NID_UI_EFFECT, "Effects. XML-parsing of one of the XML-files failed"); + } + + delete __pInstance; + __pInstance = null; + + return result; + +CATCH2: + __pInstance->ClearModelFiles(); +CATCH1: + delete __pInstance; + __pInstance = null; + + return result; +} + +result +EffectParser::ParseEffectFileLoadModel(const char* pEffectFilePath, const char* pModelFilesDirectoryPath, + IEffectModelListener* effectsManager, long effectModelID, + IEffectModelManager*& pEffectModel, EffectRenderer*& pEffectRenderer, int& modelTimerTimeout) +{ + std::unique_ptr pEffectModelTemp; + EffectRendererUniquePtr pRenderer; + std::string sceneFilePath; + std::string manifestFilePath; + result res = E_SUCCESS; + + if (__pInstance == null) + { + __pInstance = new (std::nothrow) EffectParser(); + } + + SysTryReturn(NID_UI_EFFECT, __pInstance != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, Tizen::Ui::Effects::_UiEffectError::OUT_OF_MEMORY); + + SysTryCatchLabel(NID_UI_EFFECT, __pInstance->__pXmlParser != null, , CATCH1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __pInstance->__currentModelFilesDirectoryPath = pModelFilesDirectoryPath; + + sceneFilePath = __pInstance->__currentModelFilesDirectoryPath + __SCENE_FILE_NAME; + manifestFilePath = __pInstance->__currentModelFilesDirectoryPath + __MANIFEST_FILE_NAME; + + __pInstance->__buildingModelFailed = false; + + SysTryCatchLabel(NID_UI_EFFECT, __pInstance->ExtractModelFiles(pEffectFilePath), , CATCH2, E_OPERATION_FAILED, + Tizen::Ui::Effects::_UiEffectError::EP_EXTRACTING_MODEL_FILES_FAILED); + + __pInstance->__lastSceneXMLElementIndex = -1; + __pInstance->__lastModelSurfaceXMLElementIndex = -1; + __pInstance->__lastGraphicalSurfaceXMLElementIndex = -1; + __pInstance->__pCurrentEffectModel = null; + __pInstance->__pCurrentGraphicalSurface = null; + __pInstance->__pCurrentVectorXBuffer.reset(); + __pInstance->__pCurrentVectorYBuffer.reset(); + __pInstance->__insideGraphicalSurface = false; + __pInstance->__rightAfterSceneStart = false; + __pInstance->__rightAfterModelSurfaceStart = false; + __pInstance->__rightAfterGraphicalSurfaceStart = false; + __pInstance->__insideVectorX = false; + __pInstance->__insideVectorY = false; + __pInstance->__insideElementsPool = false; + __pInstance->__pCurrentEffectManager = effectsManager; + __pInstance->__currentEffectId = effectModelID; + __pInstance->__currentModelBehaviourType = EFFECT_TYPE_TIME_BASED; + __pInstance->__currentEffectDuration = 0.0f; + __pInstance->__currentEffectInstanceName = ""; + __pInstance->__currentSceneData.timerTimeout = 30; + __pInstance->__currentSceneData.ambientColor = Vec3f(0.0f, 0.0f, 0.0f); + __pInstance->__currentSceneData.intensity = 1.0f; + __pInstance->__currentSceneData.attenuation = 0.0f; + __pInstance->__currentViewportData.x = 0.0f; + __pInstance->__currentViewportData.y = 0.0f; + __pInstance->__currentViewportData.z = 0.0f; + __pInstance->__currentViewportData.width = 0.0f; + __pInstance->__currentViewportData.height = 0.0f; + __pInstance->__currentViewportData.near = 0.0f; + __pInstance->__currentViewportData.far = 0.0f; + __pInstance->__currentViewportData.angle = 0.0f; + __pInstance->__currentViewportData.perspective = false; + __pInstance->__currentModelSurfaceX = 0.0f; + __pInstance->__currentModelSurfaceY = 0.0f; + __pInstance->__currentGraphicalSurfaceDimCtrlX = 0; + __pInstance->__currentGraphicalSurfaceDimCtrlY = 0; + __pInstance->__currentGravityForceValue = 0.0f; + + SysTryCatchLabel(NID_UI_EFFECT, __pInstance->__pXmlParser->Parse(manifestFilePath.c_str(), true) && __pInstance->__pXmlParser->Parse(sceneFilePath.c_str(), true), + __pInstance->__buildingModelFailed = true, CATCH2, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + SysTryCatchLabel(NID_UI_EFFECT, !__pInstance->__buildingModelFailed, , CATCH2, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pEffectModelTemp = std::move(__pInstance->__pCurrentEffectModel); + + SetLastResult(E_SUCCESS); + + if(EffectRenderer::CheckOpenGlesInitialized()) + { + SysTryCatchLabel(NID_UI_EFFECT, SETJMP == 0, pEffectModelTemp.reset(); pRenderer.reset(); , + CATCH2, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pRenderer = EffectRendererUniquePtr(new (std::nothrow) EffectRenderer()); + + SysTryCatchLabel(NID_UI_EFFECT, pRenderer != null, pEffectModelTemp.reset();, + CATCH2, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + res = GetLastResult(); + + SysTryCatchLabel(NID_UI_EFFECT, res == E_SUCCESS || res == E_OPERATION_FAILED, pEffectModelTemp.reset(); pRenderer.reset(); , + CATCH2, res, "[%s] Propagating.", GetErrorMessage(res)); + + if (res == E_OPERATION_FAILED) + { + SysLog(NID_UI_EFFECT, "Renderer has invalid context"); + SetLastResult(E_SUCCESS); + + pRenderer.reset(); + } + else + { + pRenderer->SetWorld( + __pInstance->__currentViewportData.x, + __pInstance->__currentViewportData.x + __pInstance->__currentViewportData.width, + __pInstance->__currentViewportData.y, + __pInstance->__currentViewportData.y + __pInstance->__currentViewportData.height, + __pInstance->__currentViewportData.z, + __pInstance->__currentViewportData.near, + __pInstance->__currentViewportData.far, + __pInstance->__currentViewportData.angle, + __pInstance->__currentViewportData.perspective); + + pRenderer->Construct(*pEffectModelTemp->GetRenderingData()); + + res = GetLastResult(); + SysTryCatchLabel(NID_UI_EFFECT, res == E_SUCCESS, pEffectModelTemp.reset(); pRenderer.reset(); , + CATCH2, res, "[%s] Propagating.", GetErrorMessage(res)); + } + } + + pEffectRenderer = pRenderer.release(); + + modelTimerTimeout = __pInstance->__currentSceneData.timerTimeout; + + __pInstance->ClearModelFiles(); + __pInstance->ClearBuffers(); + delete __pInstance; + __pInstance = null; + + pEffectModel = pEffectModelTemp.release(); + + return GetLastResult(); + +CATCH2: + __pInstance->ClearModelFiles(); + __pInstance->ClearBuffers(); +CATCH1: + delete __pInstance; + __pInstance = null; + + return GetLastResult(); +} + +void +EffectParser::StartElement(const char* pElementName) +{ + if (__buildingModelFailed) + { + return; + } + + std::string elementNameLowerCase(pElementName); + + XmlElement newElement; + newElement.name = elementNameLowerCase; + __elementBuffer.push_back(newElement); + + if (__rightAfterSceneStart) + { + PriorReadSceneData(); + __rightAfterSceneStart = false; + } + + if (__rightAfterModelSurfaceStart) + { + PriorReadModelSurfaceData(); + __rightAfterModelSurfaceStart = false; + } + + if (__rightAfterGraphicalSurfaceStart) + { + PriorReadGraphicalSurfaceData(); + __rightAfterGraphicalSurfaceStart = false; + } + + if (elementNameLowerCase == "Scene") + { + __rightAfterSceneStart = true; + __lastSceneXMLElementIndex = (int) __elementBuffer.size() - 1; + + return; + } + + if (elementNameLowerCase == "Model") + { + __rightAfterModelSurfaceStart = true; + __lastModelSurfaceXMLElementIndex = (int) __elementBuffer.size() - 1; + + return; + } + + if (elementNameLowerCase == "GraphicalSurface") + { + __rightAfterGraphicalSurfaceStart = true; + __lastGraphicalSurfaceXMLElementIndex = (int) __elementBuffer.size() - 1; + __insideGraphicalSurface = true; + + return; + } + + if (elementNameLowerCase == "KnotVectorX") + { + __insideVectorX = true; + __pCurrentVectorXBuffer = std::unique_ptr(new (std::nothrow) TypeKnots()); + + SysTryCatch(NID_UI_EFFECT, __pCurrentVectorXBuffer != null, , E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + return; + } + + if (elementNameLowerCase == "KnotVectorY") + { + __insideVectorY = true; + __pCurrentVectorYBuffer = std::unique_ptr(new (std::nothrow) TypeKnots()); + + SysTryCatch(NID_UI_EFFECT, __pCurrentVectorYBuffer != null, , E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + return; + } + + if (elementNameLowerCase == "ElementsPool") + { + __insideElementsPool = true; + + return; + } + + return; + +CATCH: + __buildingModelFailed = true; + return; +} + +void +EffectParser::EndElement(const char* pElementName) +{ + if (__buildingModelFailed) + { + return; + } + + std::string elementName(pElementName); + + if (__elementBuffer.size() == 0) + { + __buildingModelFailed = true; + + SysLogException(NID_UI_EFFECT, E_INVALID_STATE, "Effects. [E_INVALID_STATE] Building a model failed: _elementBuffer.size() == 0"); + + return; + } + + int lastElementIndex = (int) __elementBuffer.size() - 1; + + if (elementName != __elementBuffer[lastElementIndex].name) + { + __buildingModelFailed = true; + + SysLogException(NID_UI_EFFECT, E_INVALID_ARG, "Effects. [E_INVALID_ARG] Building a model failed: elName != lastElement.name"); + + return; + } + + if (elementName == "ElementsPool") + { + __insideElementsPool = false; + __elementBuffer.pop_back(); + + return; + } // ElementsPool + + if (__insideElementsPool) + { + __elementBuffer.pop_back(); + + return; + } // _insideElementsPool but not + + if (elementName == "Point") + { + if (__insideGraphicalSurface) // PointSurfaceNURBS + { + CreatePointSurfaceNurbs(__elementBuffer[lastElementIndex]); + + __elementBuffer.pop_back(); + + return; + } // PointSurfaceNURBS + else // PointSurface + { + CreatePointSurface(__elementBuffer[lastElementIndex]); + + __elementBuffer.pop_back(); + + return; + } // PointSurface + } + + if (elementName == "Spring") + { + CreateSpringSurface(__elementBuffer[lastElementIndex]); + + __elementBuffer.pop_back(); + + return; + } // SpringSurface + + if (elementName == "Rod") + { + CreateRodSurface(__elementBuffer[lastElementIndex]); + + __elementBuffer.pop_back(); + + return; + } // RodSurface + + if (elementName == "PointLight") + { + CreatePointLight(__elementBuffer[lastElementIndex]); + + __elementBuffer.pop_back(); + + return; + } // PointLight + + if (elementName == "SpotLight") + { + CreateSpotLight(__elementBuffer[lastElementIndex]); + + __elementBuffer.pop_back(); + + return; + } // SpotLight + + if (elementName == "DirectionalLight") + { + CreateDirectionalLight(__elementBuffer[lastElementIndex]); + + __elementBuffer.pop_back(); + + return; + } // DirectionalLight + + if (elementName == "ModelsArray") + { + CreateEffectModel(__elementBuffer[lastElementIndex]); + __elementBuffer.pop_back(); + + return; + } // EffectModel + + if (elementName == "GraphicalSurface") + { + if (__insideGraphicalSurface) + { + __insideGraphicalSurface = false; + } + + CreateGraphicalSurface(__elementBuffer[lastElementIndex]); + + __elementBuffer.pop_back(); + + __rightAfterGraphicalSurfaceStart = false; + __lastGraphicalSurfaceXMLElementIndex = -1; + + return; + } // GraphicalSurface + + if (elementName == "KnotVectorX") + { + if (__insideVectorX) + { + __insideVectorX = false; + } + __elementBuffer.pop_back(); + + return; + } // VectorX + + if (elementName == "KnotVectorY") + { + if (__insideVectorY) + { + __insideVectorY = false; + } + __elementBuffer.pop_back(); + + return; + } // VectorY + + if (elementName == "knot") + { + CreateGraphicalSurfaceKnot(__elementBuffer[lastElementIndex]); + __elementBuffer.pop_back(); + + return; + } // knot + + if (elementName == "Viewport") + { + ReadViewportData(__elementBuffer[lastElementIndex]); + __elementBuffer.pop_back(); + + return; + } // Viewport + + if (elementName == "GravityForce") + { + CreateGravityForce(__elementBuffer[lastElementIndex]); + __elementBuffer.pop_back(); + + return; + } // GravityForce + + if (elementName == "Model") + { + CreateModelSurface(__elementBuffer[lastElementIndex]); + __elementBuffer.pop_back(); + + __rightAfterModelSurfaceStart = false; + __currentModelSurfaceX = 0; + __currentModelSurfaceY = 0; + __currentGraphicalSurfaceDimCtrlX = 0; + __currentGraphicalSurfaceDimCtrlY = 0; + __lastModelSurfaceXMLElementIndex = -1; + + return; + } // ModelSurface + + if (elementName == "Scene") + { + __elementBuffer.pop_back(); + + __rightAfterSceneStart = false; + __lastSceneXMLElementIndex = -1; + + return; + } // Scene + + if (elementName == "EffectManifest") + { + ReadManifestData(__elementBuffer[lastElementIndex]); + __elementBuffer.pop_back(); + + return; + } // EffectManifest + + // otherwise + __elementBuffer.pop_back(); + + return; +} + +void +EffectParser::Attribute(const char* pAttributeName, const char* pAttributeValue) +{ + if (__buildingModelFailed) + { + return; + } + + std::string attributeNameLowerCase(pAttributeName); + + if (__elementBuffer.size() == 0) + { + __buildingModelFailed = true; + + SysLogException(NID_UI_EFFECT, E_INVALID_STATE, "Effects. [E_INVALID_STATE] Building a model failed: _elementBuffer.size() == 0 ( %s = %s )", + pAttributeName, pAttributeValue); + + return; + } + + int lastElementIndex = (int) __elementBuffer.size() - 1; + __elementBuffer[lastElementIndex].attributes[attributeNameLowerCase] = pAttributeValue; + + return; +} + +void +EffectParser::ClearBuffers(void) +{ + for (TypePModelSurfaceCollection::iterator it = __modelSurfaceBuffer.begin(); + it != __modelSurfaceBuffer.end(); + ++it) + { + ModelSurface* pNextModelSurface = *it; + if (pNextModelSurface != null) + { + delete pNextModelSurface; + } + else + { + ; + } + } + + for (TypePElementSurfaceCollection::iterator it = __elementSurfaceBuffer.begin(); + it != __elementSurfaceBuffer.end(); + ++it) + { + ElementSurface* pNextElementSurface = *it; + if (pNextElementSurface != null) + { + delete pNextElementSurface; + } + else + { + ; + } + } + + UnitLight::ReleaseObjectsPool(); + + __lastSceneXMLElementIndex = -1; + __lastModelSurfaceXMLElementIndex = -1; + __lastGraphicalSurfaceXMLElementIndex = -1; + __currentModelFilesDirectoryPath = ""; + __modelSurfaceBuffer.clear(); + __elementSurfaceBuffer.clear(); + __unitLightBuffer.clear(); + __elementBuffer.clear(); + __pointSurfaceNurbsIndices.clear(); + __pCurrentEffectManager = null; + __currentEffectId = 0; + __currentModelBehaviourType = EFFECT_TYPE_TIME_BASED; + __currentEffectDuration = 0.0f; + __currentEffectInstanceName = ""; + __currentSceneData.timerTimeout = 0; + __pInstance->__currentSceneData.ambientColor = Vec3f(1.0f, 1.0f, 1.0f); + __pInstance->__currentSceneData.intensity = 1.0f; + __pInstance->__currentSceneData.attenuation = 0.0f; + __currentViewportData.x = 0.0f; + __currentViewportData.y = 0.0f; + __currentViewportData.z = 0.0f; + __currentViewportData.width = 0.0f; + __currentViewportData.height = 0.0f; + __currentViewportData.near = 0.0f; + __currentViewportData.far = 0.0f; + __currentViewportData.angle = 0.0f; + __currentViewportData.perspective = false; + __currentModelSurfaceX = 0.0f; + __currentModelSurfaceY = 0.0f; + __currentGraphicalSurfaceDimCtrlX = 0; + __currentGraphicalSurfaceDimCtrlY = 0; + __currentGravityForceValue = 0.0f; + + if (__buildingModelFailed) + { + __currentGravityForce = Vec3f(0, 0, 0); + } + + __pCurrentVectorXBuffer.reset(); + __pCurrentVectorYBuffer.reset(); + + return; +} + +void +EffectParser::ClearModelFiles(void) +{ + std::string sceneFilePath = __currentModelFilesDirectoryPath + __SCENE_FILE_NAME; + std::string manifestFilePath = __currentModelFilesDirectoryPath + __MANIFEST_FILE_NAME; + std::string scriptFilePath = __currentModelFilesDirectoryPath + __SCRIPT_FILE_NAME; + + remove(sceneFilePath.c_str()); + remove(manifestFilePath.c_str()); + remove(scriptFilePath.c_str()); + + return; +} + +PointSurface* +EffectParser::FindPointSurfaceById(long pointId) const +{ + PointSurface* pResult = null; + + for (TypePElementSurfaceCollection::const_iterator it = __elementSurfaceBuffer.begin(); + it != __elementSurfaceBuffer.end(); + ++it) + { + // It is assumed that all the points are going before any Spring or a rod + if (((*it)->GetType() != ESURFACE_POINT_SURFACE) + && ((*it)->GetType() != ESURFACE_POINT_SURFACE_NURBS)) + { + break; + } + if ((*it)->GetId() == pointId) + { + pResult = dynamic_cast((*it)); + break; + } + } + + return pResult; +} + +PointSurfaceNurbs* +EffectParser::FindPointSurfaceNurbsByIndices(unsigned int row, unsigned int col) const +{ + PointSurfaceNurbs* pResult = null; + for (TypeNurbsPointIndexDistributor::const_iterator it = __pointSurfaceNurbsIndices.begin(); + it != __pointSurfaceNurbsIndices.end(); + ++it) + { + if ((it->first.first == row) && (it->first.second == col)) + { + pResult = dynamic_cast(__elementSurfaceBuffer[it->second]); + break; + } + } + + return pResult; +} + +bool +EffectParser::CreatePointLight(XmlElement& xmlElement) +{ + bool result = true; + Tizen::Ui::Effects::_Runtime::PointLight* newPointLight = null; + + std::string name; + bool isEnabled = false; + float intensity = 0.0f; + Vec3f color(0, 0, 0); + Vec3f position(0, 0, 0); + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("name"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + name = foundAttribute->second.c_str(); + + foundAttribute = xmlElement.attributes.find("x"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + // x - coordinate is absolute + position.x = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("y"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND,Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + // y - coordinate is absolute + position.y = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("z"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND ); + + // z - coordinate is absolute + position.z = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("enable"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + if (foundAttribute->second == std::string("true")) + { + isEnabled = true; + } + else + { + SysTryCatch(NID_UI_EFFECT, foundAttribute->second == std::string("false"), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + } + + foundAttribute = xmlElement.attributes.find("intensity"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + intensity = (float) strtod(foundAttribute->second.c_str(), null); + + SysTryCatch(NID_UI_EFFECT, intensity >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + foundAttribute = xmlElement.attributes.find("color"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + std::string stringColor = foundAttribute->second; + SysTryCatchLabel(NID_UI_EFFECT, *(stringColor.begin()) == '#', result = false, CATCH, + E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatchLabel(NID_UI_EFFECT, stringColor.size() == 7, result = false, CATCH, + E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + stringColor.erase(stringColor.begin()); + stringColor = "0x" + stringColor; + color = StringHexToRgb(stringColor); + } + + SysTryCatch(NID_UI_EFFECT, (0.0f <= color.x) && (color.x <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatch(NID_UI_EFFECT, (0.0f <= color.y) && (color.y <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatch(NID_UI_EFFECT, (0.0f <= color.z) && (color.z <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + // Create a new point light if all the requests for an attribute succeeded + newPointLight = Tizen::Ui::Effects::_Runtime::PointLight::CreatePointLight(isEnabled, name, color, intensity, position); + SysTryReturn(NID_UI_EFFECT, newPointLight != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __unitLightBuffer.push_back(newPointLight); + + return result; + +CATCH: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::CreateSpotLight(XmlElement& xmlElement) +{ + bool result = true; + Tizen::Ui::Effects::_Runtime::SpotLight* newSpotLight = null; + + std::string name; + bool isEnabled = false; + float intensity = 0.0f; + Vec3f color(0, 0, 0); + Vec3f position(0, 0, 0); + Vec3f direction(0, 0, 0); + float angleOpening = 0.0f; + float angleFadeOut = 0.0f; + + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("name"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + name = foundAttribute->second.c_str(); + + foundAttribute = xmlElement.attributes.find("x"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + // x - coordinate is absolute + position.x = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("y"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND,Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + // y - coordinate is absolute + position.y = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("z"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND ); + + // z - coordinate is absolute + position.z = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("enable"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + if (foundAttribute->second == std::string("true")) + { + isEnabled = true; + } + else + { + SysTryCatch(NID_UI_EFFECT, foundAttribute->second == std::string("false"), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + } + + foundAttribute = xmlElement.attributes.find("intensity"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + intensity = (float) strtod(foundAttribute->second.c_str(), null); + + SysTryCatch(NID_UI_EFFECT, intensity >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + foundAttribute = xmlElement.attributes.find("color"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + std::string stringColor = foundAttribute->second; + SysTryCatchLabel(NID_UI_EFFECT, *(stringColor.begin()) == '#', result = false, CATCH, + E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatchLabel(NID_UI_EFFECT, stringColor.size() == 7, result = false, CATCH, + E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + stringColor.erase(stringColor.begin()); + stringColor = "0x" + stringColor; + color = StringHexToRgb(stringColor); + } + + SysTryCatch(NID_UI_EFFECT, (0.0f <= color.x) && (color.x <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatch(NID_UI_EFFECT, (0.0f <= color.y) && (color.y <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatch(NID_UI_EFFECT, (0.0f <= color.z) && (color.z <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + foundAttribute = xmlElement.attributes.find("targetX"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + // x - coordinate is absolute + direction.x = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("targetY"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND,Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + // y - coordinate is absolute + direction.y = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("targetZ"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND ); + + // z - coordinate is absolute + direction.z = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("angleOpening"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + angleOpening = (float) strtod(foundAttribute->second.c_str(), null); + + SysTryCatch(NID_UI_EFFECT, (0.0f <= angleOpening) && (angleOpening <= 360.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + foundAttribute = xmlElement.attributes.find("angleFadeOut"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + angleFadeOut = (float) strtod(foundAttribute->second.c_str(), null); + + SysTryCatch(NID_UI_EFFECT, (0.0f <= angleFadeOut) && (angleFadeOut <= 360.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + // Create a new spot light if all the requests for an attribute succeeded + newSpotLight = Tizen::Ui::Effects::_Runtime::SpotLight:: + CreateSpotLight(isEnabled, name, color, intensity, position, direction, angleOpening, angleFadeOut); + SysTryReturn(NID_UI_EFFECT, newSpotLight != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __unitLightBuffer.push_back(newSpotLight); + + return result; + +CATCH: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::CreateDirectionalLight(XmlElement& xmlElement) +{ + bool result = true; + Tizen::Ui::Effects::_Runtime::DirectionalLight* newDirectionalLight = null; + + std::string name; + bool isEnabled = false; + float intensity = 0.0f; + Vec3f color(0, 0, 0); + Vec3f direction(0, 0, 0); + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("name"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + name = foundAttribute->second.c_str(); + + foundAttribute = xmlElement.attributes.find("directionX"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + // x - coordinate is absolute + direction.x = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("directionY"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND,Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + // y - coordinate is absolute + direction.y = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("directionZ"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND ); + + // z - coordinate is absolute + direction.z = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("enable"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + if (foundAttribute->second == std::string("true")) + { + isEnabled = true; + } + else + { + SysTryCatch(NID_UI_EFFECT, foundAttribute->second == std::string("false"), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + } + + foundAttribute = xmlElement.attributes.find("intensity"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + intensity = (float) strtod(foundAttribute->second.c_str(), null); + + SysTryCatch(NID_UI_EFFECT, intensity >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + foundAttribute = xmlElement.attributes.find("color"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + std::string stringColor = foundAttribute->second; + SysTryCatchLabel(NID_UI_EFFECT, *(stringColor.begin()) == '#', result = false, CATCH, + E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatchLabel(NID_UI_EFFECT, stringColor.size() == 7, result = false, CATCH, + E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + stringColor.erase(stringColor.begin()); + stringColor = "0x" + stringColor; + color = StringHexToRgb(stringColor); + } + + SysTryCatch(NID_UI_EFFECT, (0.0f <= color.x) && (color.x <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatch(NID_UI_EFFECT, (0.0f <= color.y) && (color.y <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatch(NID_UI_EFFECT, (0.0f <= color.z) && (color.z <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + // Create a new directional light if all the requests for an attribute succeeded + newDirectionalLight = Tizen::Ui::Effects::_Runtime::DirectionalLight::CreateDirectionalLight(isEnabled, name, color, intensity, direction); + SysTryReturn(NID_UI_EFFECT, newDirectionalLight != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __unitLightBuffer.push_back(newDirectionalLight); + + return result; + +CATCH: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::CreatePointSurface(XmlElement& xmlElement) +{ + bool result = true; + PointSurface* newPointSurface = null; + + long id = 0; + Vec3f positionInit(0, 0, 0); + float massInit = 1.0f; + float pointResistance = 0.f; + bool fixed = false; + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("id"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + id = (long) strtol(foundAttribute->second.c_str(), null, 10); + + foundAttribute = xmlElement.attributes.find("x"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + // x - coordinate is related to the ModelSurface's x-coordinate + positionInit.x = __currentModelSurfaceX + (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("y"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND,Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + // y - coordinate is related to the ModelSurface's y-coordinate + positionInit.y = __currentModelSurfaceY + (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("z"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND ); + + // z - coordinate is absolute + positionInit.z = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("mass"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + massInit = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("pointResistance"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + pointResistance = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("fixed"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + if (foundAttribute->second == std::string("true")) + { + fixed = true; + } + else + { + SysTryCatch(NID_UI_EFFECT, foundAttribute->second == std::string("false"), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + } + + SysTryCatch(NID_UI_EFFECT, massInit > 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + // Create a new point if all the requests for an attribute succeeded + newPointSurface = new (std::nothrow) PointSurface(id, positionInit, massInit, pointResistance, fixed); + SysTryReturn(NID_UI_EFFECT, newPointSurface != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __elementSurfaceBuffer.push_back(newPointSurface); + + return result; + +CATCH: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::CreatePointSurfaceNurbs(XmlElement& xmlElement) +{ + bool result = true; + PointSurfaceNurbs* newPointSurfaceNurbs = null; + + long id = 0; + Vec3f positionInit(0, 0, 0); + float massInit = 1.0f; + float weight = 0.0f; + float pointResistance = 2.f; + bool fixed = false; + unsigned int row = 0; + unsigned int col = 0; + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("id"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + id = (long) strtol(foundAttribute->second.c_str(), null, 10); + + foundAttribute = xmlElement.attributes.find("x"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + // x - coordinate is related to the ModelSurface's x-coordinate + positionInit.x = __currentModelSurfaceX + (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("y"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND ); + + // y - coordinate is related to the ModelSurface's y-coordinate + positionInit.y = __currentModelSurfaceY + (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("z"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + // z - coordinate is absolute + positionInit.z = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("mass"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND ); + massInit = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("gWeight"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + weight = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("fixed"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + + if (foundAttribute->second == std::string("true")) + { + fixed = true; + } + else + { + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute->second == std::string("false"), result = false, CATCH1, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + } + + foundAttribute = xmlElement.attributes.find("pointResistance"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + pointResistance = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("row"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + int rowValue = (int) strtol(foundAttribute->second.c_str(), null, 10); + SysTryCatchLabel(NID_UI_EFFECT, rowValue >= 0, result = false, CATCH1, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + row = (unsigned int) rowValue; + } + + foundAttribute = xmlElement.attributes.find("col"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH1, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + int colValue = (int) strtol(foundAttribute->second.c_str(), null, 10); + SysTryCatchLabel(NID_UI_EFFECT, colValue >= 0, result = false, CATCH1, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + col = (unsigned int) colValue; + } + + SysTryCatchLabel(NID_UI_EFFECT, massInit > 0.0f, result = false, CATCH1, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatchLabel(NID_UI_EFFECT, weight >= 0.0f, result = false, CATCH1, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + SysTryCatchLabel(NID_UI_EFFECT,(col < __currentGraphicalSurfaceDimCtrlX) && (row < __currentGraphicalSurfaceDimCtrlY), result = false, CATCH2, + E_INVALID_FORMAT, Tizen::Ui::Effects::_UiEffectError::EP_ERROR_IN_LOGIC); + + SysTryCatchLabel(NID_UI_EFFECT, __pointSurfaceNurbsIndices.find(std::pair(row, col)) == __pointSurfaceNurbsIndices.end(), result = false, CATCH3, + E_INVALID_FORMAT, Tizen::Ui::Effects::_UiEffectError::EP_ERROR_IN_LOGIC); + + newPointSurfaceNurbs = new (std::nothrow) PointSurfaceNurbs(id, positionInit, massInit, pointResistance, weight, fixed, row, col); + SysTryReturn(NID_UI_EFFECT, newPointSurfaceNurbs != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __elementSurfaceBuffer.push_back(newPointSurfaceNurbs); + + __pointSurfaceNurbsIndices[std::pair(row, col)] = __elementSurfaceBuffer.size() - 1; + + return true; + +CATCH1: + __buildingModelFailed = true; + + return result; + +CATCH2: + __buildingModelFailed = true; + + return result; + +CATCH3: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::CreateSpringSurface(XmlElement& xmlElement) +{ + bool result = true; + SpringSurface* newSpringSurface = null; + + long id = 0; + float stiffness = 0.0f; + PointSurface* pPoint1 = null; + PointSurface* pPoint2 = null; + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("id"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + id = (long) strtol(foundAttribute->second.c_str(), null, 10); + + foundAttribute = xmlElement.attributes.find("pointId1"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND ); + { + long point1ID = (long) strtol(foundAttribute->second.c_str(), null, 10); + pPoint1 = FindPointSurfaceById(point1ID); + } + + foundAttribute = xmlElement.attributes.find("pointId2"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + long point2ID = (long) strtol(foundAttribute->second.c_str(), null, 10); + pPoint2 = FindPointSurfaceById(point2ID); + } + + foundAttribute = xmlElement.attributes.find("stiffness"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + stiffness = (float) strtod(foundAttribute->second.c_str(), null); + + SysTryCatch(NID_UI_EFFECT, stiffness >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + // Create a new Spring if all the requests for an attribute succeeded + if ((pPoint1 != null) && (pPoint2 != null) && result) + { + newSpringSurface = new (std::nothrow) SpringSurface(id, stiffness, pPoint1, pPoint2); + SysTryReturn(NID_UI_EFFECT, newSpringSurface != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __elementSurfaceBuffer.push_back(newSpringSurface); + } + else + { + result = false; + + __buildingModelFailed = true; + + SysLogException(NID_UI_EFFECT, E_KEY_NOT_FOUND, "Effects. [E_KEY_NOT_FOUND] Building a model failed: error in SpringSurface's attributes"); + } + + return result; + +CATCH: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::CreateRodSurface(XmlElement& xmlElement) +{ + bool result = true; + RodSurface* newRodSurface = null; + + long id = 0; + float stiffness = 0.0f; + PointSurface* pPoint1 = null; + PointSurface* pPoint2 = null; + PointSurface* pPoint3 = null; + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("id"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + id = (long) strtol(foundAttribute->second.c_str(), null, 10); + + foundAttribute = xmlElement.attributes.find("pointId1"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + long point1ID = (long) strtol(foundAttribute->second.c_str(), null, 10); + pPoint1 = FindPointSurfaceById(point1ID); + } + + foundAttribute = xmlElement.attributes.find("pointId2"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + long point2ID = (long) strtol(foundAttribute->second.c_str(), null, 10); + pPoint2 = FindPointSurfaceById(point2ID); + } + + foundAttribute = xmlElement.attributes.find("pointId3"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + long point3ID = (long) strtol(foundAttribute->second.c_str(), null, 10); + pPoint3 = FindPointSurfaceById(point3ID); + } + + foundAttribute = xmlElement.attributes.find("stiffness"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + stiffness = (float) strtod(foundAttribute->second.c_str(), null); + + SysTryCatch(NID_UI_EFFECT, stiffness >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + // Create a new rod if all the requests for an attribute succeeded + if ((pPoint1 != null) && (pPoint2 != null) && (pPoint3 != null) && result) + { + newRodSurface = new (std::nothrow) RodSurface(id, stiffness, pPoint1, pPoint2, pPoint3); + SysTryReturn(NID_UI_EFFECT, newRodSurface != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __elementSurfaceBuffer.push_back(newRodSurface); + } + else + { + result = false; + + __buildingModelFailed = true; + + SysLogException(NID_UI_EFFECT, E_KEY_NOT_FOUND, "Effects. [E_KEY_NOT_FOUND] Building a model failed: error in RodSurface's attributes"); + } + + return result; + +CATCH: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::CreateRodSurfaceNurbs(XmlElement& xmlElement) +{ + bool result = true; + RodSurfaceNurbs* newRodSurfaceNurbs = null; + long id = 0; + float stiffness = 0.0f; + PointSurfaceNurbs* pPoint1 = null; + PointSurfaceNurbs* pPoint2 = null; + PointSurfaceNurbs* pPoint3 = null; + PointSurfaceNurbs* pPoint4 = null; + unsigned int normalPointRowIndex = 0; + unsigned int normalPointColIndex = 0; + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("id"); + SysTryCatch( + NID_UI_EFFECT, + foundAttribute != xmlElement.attributes.end(), + result = false, + E_KEY_NOT_FOUND, + Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + id = (long) strtol(foundAttribute->second.c_str(), null, 10); + + foundAttribute = xmlElement.attributes.find("pointId1"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + long point1ID = (long) strtol(foundAttribute->second.c_str(), null, 10); + pPoint1 = dynamic_cast (FindPointSurfaceById(point1ID)); + } + + foundAttribute = xmlElement.attributes.find("pointId2"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + long point2ID = (long) strtol(foundAttribute->second.c_str(), null, 10); + pPoint2 = dynamic_cast (FindPointSurfaceById(point2ID)); + } + + foundAttribute = xmlElement.attributes.find("pointId3"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + long point3ID = (long) strtol(foundAttribute->second.c_str(), null, 10); + pPoint3 = dynamic_cast (FindPointSurfaceById(point3ID)); + } + + foundAttribute = xmlElement.attributes.find("stiffness"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + stiffness = (float) strtod(foundAttribute->second.c_str(), null); + + SysTryCatch(NID_UI_EFFECT, stiffness >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + if ((pPoint1 != null) && (pPoint2 != null) && (pPoint3 != null)) + { + int tempRow = (int) pPoint2->GetRow() + (int) pPoint2->GetCol() - (int) pPoint1->GetCol(); + int tempCol = (int) pPoint2->GetCol() + (int) pPoint1->GetRow() - (int) pPoint2->GetRow(); + + if (( tempRow < 0 ) || + ((int) __currentGraphicalSurfaceDimCtrlY - 1 < tempRow) || + (tempCol < 0 ) || + ((int) __currentGraphicalSurfaceDimCtrlX - 1 < tempCol)) + { + tempRow = static_cast(pPoint2->GetRow()) + static_cast(pPoint1->GetCol()) - static_cast(pPoint2->GetCol()); + tempCol = static_cast(pPoint2->GetCol()) + static_cast(pPoint2->GetRow()) - static_cast(pPoint1->GetRow()); + } + + normalPointRowIndex = tempRow; + normalPointColIndex = tempCol; + + pPoint4 = FindPointSurfaceNurbsByIndices(normalPointRowIndex, normalPointColIndex); + } + + // Create a new rod if all the requests for an attribute succeeded + if ((pPoint1 != null) && (pPoint2 != null) && (pPoint3 != null) && (pPoint4 != null) && result) + { + newRodSurfaceNurbs = new (std::nothrow) RodSurfaceNurbs(id, stiffness, pPoint1, pPoint2, pPoint3, pPoint4); + SysTryReturn(NID_UI_EFFECT, newRodSurfaceNurbs != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __elementSurfaceBuffer.push_back(newRodSurfaceNurbs); + } + else + { + result = false; + + __buildingModelFailed = true; + + SysLogException(NID_UI_EFFECT, E_KEY_NOT_FOUND, "Effects. [E_KEY_NOT_FOUND] Building a model failed: _error in RodSurfaceNURBS's attributes"); + } + + return result; + +CATCH: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::CreateGraphicalSurface(XmlElement& xmlElement) +{ + bool result = true; + long id = 0; + float x = 0.0f; + float y = 0.0f; + float width = 0.0f; + float height = 0.0f; + float transparency = 0.0f; + long bitmapId = 0; + unsigned int dimGraphX = 0; + unsigned int dimGraphY = 0; + unsigned int dimCtrlX = 0; + unsigned int dimCtrlY = 0; + unsigned int orderX = 0; + unsigned int orderY = 0; + + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("id"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + id = (long) strtol(foundAttribute->second.c_str(), null, 10); + + foundAttribute = xmlElement.attributes.find("x"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + x = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("y"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + y = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("width"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + width = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("height"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + height = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("transparency"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + transparency = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("bitmapID"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + bitmapId = (long) strtol(foundAttribute->second.c_str(), null, 10); + + foundAttribute = xmlElement.attributes.find("dimGraphX"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + int dimGraphXValue = (int) strtol(foundAttribute->second.c_str(), null, 10); + SysTryCatch(NID_UI_EFFECT, dimGraphXValue >= 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + dimGraphX = (unsigned int) dimGraphXValue; + } + + foundAttribute = xmlElement.attributes.find("dimGraphY"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND ); + { + int dimGraphYValue = (int) strtol(foundAttribute->second.c_str(), null, 10); + SysTryCatch(NID_UI_EFFECT, dimGraphYValue >= 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + dimGraphY = (unsigned int) dimGraphYValue; + } + + foundAttribute = xmlElement.attributes.find("dimCtrlX"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + int dimCtrlXValue = (int) strtol(foundAttribute->second.c_str(), null, 10); + SysTryCatch(NID_UI_EFFECT, dimCtrlXValue >= 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + dimCtrlX = (unsigned int) dimCtrlXValue; + } + + foundAttribute = xmlElement.attributes.find("dimCtrlY"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + int dimCtrlYValue = (int) strtol(foundAttribute->second.c_str(), null, 10); + SysTryCatch(NID_UI_EFFECT, dimCtrlYValue >= 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + dimCtrlY = (unsigned int) dimCtrlYValue; + } + + foundAttribute = xmlElement.attributes.find("orderX"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + int orderXValue = (int) strtol(foundAttribute->second.c_str(), null, 10); + SysTryCatch(NID_UI_EFFECT, orderXValue >= 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + orderX = (unsigned int) orderXValue; + } + + foundAttribute = xmlElement.attributes.find("orderY"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + { + int orderYValue = (int) strtol(foundAttribute->second.c_str(), null, 10); + SysTryCatch(NID_UI_EFFECT, orderYValue >= 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + orderY = (unsigned int) orderYValue; + } + + SysTryCatch(NID_UI_EFFECT, width >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatch(NID_UI_EFFECT, height >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatch(NID_UI_EFFECT, (0.0f <= transparency) && (transparency <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + __pCurrentGraphicalSurface = std::unique_ptr(new (std::nothrow) GraphicalSurfaceNurbs(id, bitmapId, dimCtrlX, dimCtrlY, orderX, orderY, dimGraphX, dimGraphY, + std::move(__pCurrentVectorXBuffer), std::move(__pCurrentVectorYBuffer), transparency)); + + if (__pCurrentGraphicalSurface != null) + { + ; + } + else + { + result = false; + __buildingModelFailed = true; + + SysLogException(NID_UI_EFFECT, E_OUT_OF_MEMORY, "Effects. Effect was not created! Exception E_OUT_OF_MEMORY was appeared while creating of GraphicalSurfaceNurbs instance"); //E_OUT_OF_MEMORY + } + + if (result) + { + __pCurrentVectorXBuffer.reset(); + __pCurrentVectorYBuffer.reset(); + } + + return result; + +CATCH: + __buildingModelFailed = true; + + __pCurrentVectorXBuffer.reset(); + __pCurrentVectorYBuffer.reset(); + + return result; +} + +bool +EffectParser::CreateModelSurface(XmlElement& xmlElement) +{ + bool result = true; + + long id = 0; + float width = 0.0f; + float height = 0.0f; + std::string name; + unsigned short iterationCount = 1; + unsigned short modelSpeed = 1; + float environmentResistance = 0.0f; + float groundLevel = 0.0f; + unsigned int expectedNurbsPointsCount = 0; + ModelSurface* newModelSurface = null; + + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("id"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + id = (long) strtol(foundAttribute->second.c_str(), null, 10); + + foundAttribute = xmlElement.attributes.find("width"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND ); + width = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("height"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + height = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("name"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + name = foundAttribute->second.c_str(); + + foundAttribute = xmlElement.attributes.find("timeoutDivisor"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + iterationCount = (unsigned short) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("speedFactor"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + modelSpeed = (unsigned short) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("environmentResistance"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + environmentResistance = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("groundLevel"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND ); + groundLevel = (float) strtod(foundAttribute->second.c_str(), null); + + SysTryCatch(NID_UI_EFFECT, width >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatch(NID_UI_EFFECT, height >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatch(NID_UI_EFFECT, environmentResistance >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + // Create a new ModelSurface object if all the requests for an attribute succeded + newModelSurface = new (std::nothrow) ModelSurface( + id, iterationCount, modelSpeed, environmentResistance, __currentGravityForce, __currentGravityForceValue, groundLevel); + + SysTryCatchLabel(NID_UI_EFFECT, newModelSurface != null, result = false, CATCH1, E_OUT_OF_MEMORY, + "Effects. [E_OUT_OF_MEMORY] NOT CREATED: ModelSurface\n" + "Effects. Building a model failed: an object of ModelSurface hasn't been created"); + + __currentGravityForce = Vec3f(0, 0, 0); + __currentGravityForceValue = 0; + + // Now add the ElementSurface objects to a newly created ModelSurface + + expectedNurbsPointsCount = __currentGraphicalSurfaceDimCtrlX * __currentGraphicalSurfaceDimCtrlY; + + if ((unsigned int) __elementSurfaceBuffer.size() < expectedNurbsPointsCount) + { + __buildingModelFailed = true; + + SysLogException(NID_UI_EFFECT, E_INVALID_FORMAT, "Effects. [E_INVALID_FORMAT] Building a model failed : " + "not enough ElementSurface objects in _elementSurfaceBuffer - less then the predefined number of PoiinSurfaceNURBS objects"); + } + else + { + // first add all the PointSurfaceNURBS objects in the right order + TypePElementSurfaceCollection::iterator beginIt = __elementSurfaceBuffer.begin(); + for (unsigned int rowIndex = 0; rowIndex < __currentGraphicalSurfaceDimCtrlY; ++rowIndex) + { + for (unsigned int colIndex = 0; colIndex < __currentGraphicalSurfaceDimCtrlX; ++colIndex) + { + TypeNurbsPointIndexDistributor::iterator indexIt; + + indexIt = __pointSurfaceNurbsIndices.find(std::pair(rowIndex, colIndex)); + if (indexIt != __pointSurfaceNurbsIndices.end()) + { + unsigned int pointNurbsIndex = indexIt->second; + + if (pointNurbsIndex < expectedNurbsPointsCount) + { + TypePElementSurfaceCollection::iterator pointNurbsIterator = + beginIt + pointNurbsIndex; + + if ((*pointNurbsIterator)->GetType() == ESURFACE_POINT_SURFACE_NURBS) + { + newModelSurface->AddElementSurface(*pointNurbsIterator); + } + else + { + __buildingModelFailed = true; + + SysLogException(NID_UI_EFFECT, E_INVALID_FORMAT,"Effects. [E_INVALID_FORMAT] _elementSurfaceBuffer.begin() + %i is not a PointSurfaceNURBS", + pointNurbsIndex); + } + } + else + { + __buildingModelFailed = true; + + SysLogException(NID_UI_EFFECT, E_INVALID_FORMAT, "Effects. [E_INVALID_FORMAT] pointNurbsIndex = %i is >= expectedNumberOfNurbsPoints = %i", + pointNurbsIndex, expectedNurbsPointsCount); + } + } + else + { + __buildingModelFailed = true; + + SysLogException(NID_UI_EFFECT, E_KEY_NOT_FOUND, "Effects. [E_KEY_NOT_FOUND] A pair <%i, %i> not present in _pointSurfaceNurbsIndices", + rowIndex, colIndex); + } + } + } + + // now add all the Elementsurface objects going after PointSurfaceNURBS objects + if (!__buildingModelFailed) + { + for (TypePElementSurfaceCollection::iterator it = __elementSurfaceBuffer.begin() + expectedNurbsPointsCount; + it != __elementSurfaceBuffer.end(); + ++it) + { + newModelSurface->AddElementSurface(*it); + } + } + } + + __pointSurfaceNurbsIndices.clear(); + __elementSurfaceBuffer.clear(); + + // set Graphical surface + newModelSurface->AddGraphicalSurface(std::move(__pCurrentGraphicalSurface)); + + __pCurrentGraphicalSurface = null; + + // Add created ModelSurface to the list + __modelSurfaceBuffer.push_back(newModelSurface); + + return result; + +CATCH: + ; +CATCH1: + __buildingModelFailed = true; + + __pointSurfaceNurbsIndices.clear(); + __elementSurfaceBuffer.clear(); + + return result; +} + +bool +EffectParser::CreateEffectModel(XmlElement& xmlElement) +{ + bool result = true; + + std::string pathToScript = __currentModelFilesDirectoryPath + __SCRIPT_FILE_NAME; + + SetLastResult(E_SUCCESS); + + __pCurrentEffectModel = std::unique_ptr<_Runtime::EffectModel>(new (std::nothrow) _Runtime::EffectModel( + __currentEffectId, __currentEffectInstanceName, pathToScript.c_str(), __pCurrentEffectManager, __currentModelBehaviourType, __currentEffectDuration)); + + if (__pCurrentEffectModel != null) + { + ; + } + else + { + result = false; + + __buildingModelFailed = true; + SysLogException(NID_UI_EFFECT, E_OUT_OF_MEMORY, "Effects. Effect was not created! Exception E_OUT_OF_MEMORY was appeared while creating of EffectModel instance"); //E_OUT_OF_MEMORY + } + + if (GetLastResult() != E_SUCCESS) + { + result = false; + + __buildingModelFailed = true; + SysLogException(NID_UI_EFFECT, GetLastResult(), + "Effects. Building a model failed: error generated by the constructor of EffectModel: %s", GetErrorMessage(GetLastResult())); + } + + if ((__pCurrentEffectModel != null) && (GetLastResult() == E_SUCCESS)) + { + for (TypePModelSurfaceCollection::iterator it = __modelSurfaceBuffer.begin(); + it != __modelSurfaceBuffer.end(); + ++it) + { + __pCurrentEffectModel->AddModelSurface(*it); + } + + __modelSurfaceBuffer.clear(); + + RenderDataScene* pRenderDataScene = __pCurrentEffectModel->GetRenderingData(); + + // in case there was no light sources described inthe scene a single directional light should be set + if (__unitLightBuffer.size() == 0) + { + Tizen::Ui::Effects::_Runtime::DirectionalLight* newDirectionalLight = + Tizen::Ui::Effects::_Runtime::DirectionalLight::CreateDirectionalLight( + true, std::string("DirectionalLight_0"), Vec3f(1.0f, 1.0f, 1.0f), 1.0f, Vec3f(0.0f, 0.0f, -1.0f)); + SysTryReturn(NID_UI_EFFECT, newDirectionalLight != null, result = false, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + bool addUnitLightResult = pRenderDataScene->AddUnitLight(*newDirectionalLight); + SysTryCatch(NID_UI_EFFECT, addUnitLightResult, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED); + } + else + { + for (TypePUnitLightCollection::iterator it = __unitLightBuffer.begin(); + it != __unitLightBuffer.end(); + ++it) + { + bool addUnitLightResult = pRenderDataScene->AddUnitLight(*(*it)); + SysTryCatch(NID_UI_EFFECT, addUnitLightResult, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED); + } + } + + __unitLightBuffer.clear(); + + pRenderDataScene->SetLightAmbientColour(__currentSceneData.ambientColor); + pRenderDataScene->SetLightIntensity(__currentSceneData.intensity); + pRenderDataScene->SetLightAttenuation(__currentSceneData.attenuation); + + __pCurrentEffectModel->Construct(); + } + + return result; + +CATCH: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::CreateGraphicalSurfaceKnot(XmlElement& xmlElement) +{ + bool result = true; + Tizen::Ui::Effects::_Runtime::TypeKnots* pVectorToRefill = null; + unsigned int index = 0; + float value = 0.0f; + TypeXmlElementAttributes::iterator foundAttribute; + + if (__insideVectorX) + { + pVectorToRefill = __pCurrentVectorXBuffer.get(); + } + else if (__insideVectorY) + { + pVectorToRefill = __pCurrentVectorYBuffer.get(); + } + else + { + ; + } + + SysTryCatchLabel(NID_UI_EFFECT, pVectorToRefill != null, result = false, CATCH1, E_INVALID_CONDITION, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED); + + foundAttribute = xmlElement.attributes.find("index"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH2, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + index = (unsigned int) strtol(foundAttribute->second.c_str(), null, 10); + + foundAttribute = xmlElement.attributes.find("value"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, CATCH2, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + value = (float) strtod(foundAttribute->second.c_str(), null); + + SysTryCatchLabel(NID_UI_EFFECT, index == pVectorToRefill->size(), result = false, CATCH3, E_INVALID_FORMAT, Tizen::Ui::Effects::_UiEffectError::EP_ERROR_IN_LOGIC); + pVectorToRefill->push_back(value); + + return true; + +CATCH1: + __buildingModelFailed = true; + + return result; + +CATCH2: + __buildingModelFailed = true; + + return result; + +CATCH3: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::CreateGravityForce(XmlElement& xmlElement) +{ + bool result = true; + Vec3f gravity = Vec3f(0, 0, 0); + float value = 0.0f; + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("x"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + gravity.x = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("y"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + gravity.y = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("z"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + gravity.z = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("abs"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + value = (float) strtod(foundAttribute->second.c_str(), null); + + SysTryCatch(NID_UI_EFFECT, value >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + __currentGravityForce = gravity; + __currentGravityForceValue = value; + + return true; + +CATCH: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::ReadViewportData(XmlElement& xmlElement) +{ + bool result = true; + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("x"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentViewportData.x = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("y"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentViewportData.y = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("z"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentViewportData.z = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("width"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentViewportData.width = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("height"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentViewportData.height = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("near"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentViewportData.near = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("far"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentViewportData.far = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("angle"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentViewportData.angle = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = xmlElement.attributes.find("perspective"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + if (foundAttribute->second == std::string("true")) + { + __currentViewportData.perspective = true; + } + else + { + SysTryCatch(NID_UI_EFFECT, foundAttribute->second == std::string("false"), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + } + + SysTryCatch(NID_UI_EFFECT, __currentViewportData.near < __currentViewportData.far, result = false, E_INVALID_FORMAT, Tizen::Ui::Effects::_UiEffectError::EP_ERROR_IN_LOGIC); + + return true; + +CATCH: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::PriorReadModelSurfaceData(void) +{ + bool result = true; + TypeXmlElementAttributes::iterator foundAttribute; + + SysTryCatchLabel(NID_UI_EFFECT, __lastModelSurfaceXMLElementIndex != -1, result = false, CATCH1, E_INVALID_CONDITION, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED); + + foundAttribute = __elementBuffer[__lastModelSurfaceXMLElementIndex].attributes.find("x"); + SysTryCatchLabel(NID_UI_EFFECT, (foundAttribute != __elementBuffer[__lastModelSurfaceXMLElementIndex].attributes.end()), result = false, CATCH2, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentModelSurfaceX = (float) strtod(foundAttribute->second.c_str(), null); + + foundAttribute = __elementBuffer[__lastModelSurfaceXMLElementIndex].attributes.find("y"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != __elementBuffer[__lastModelSurfaceXMLElementIndex].attributes.end(), result = false, CATCH2, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentModelSurfaceY = (float) strtod(foundAttribute->second.c_str(), null); + + return true; + +CATCH1: + __buildingModelFailed = true; + + return result; + +CATCH2: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::PriorReadGraphicalSurfaceData(void) +{ + bool result = true; + TypeXmlElementAttributes::iterator foundAttribute; + + SysTryCatchLabel(NID_UI_EFFECT, __lastGraphicalSurfaceXMLElementIndex != -1, result = false, CATCH1, + E_INVALID_CONDITION, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED); + + foundAttribute = __elementBuffer[__lastGraphicalSurfaceXMLElementIndex].attributes.find("dimCtrlX"); + SysTryCatchLabel(NID_UI_EFFECT, (foundAttribute != __elementBuffer[__lastGraphicalSurfaceXMLElementIndex].attributes.end()), result = false, CATCH2, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentGraphicalSurfaceDimCtrlX = (unsigned int) strtol(foundAttribute->second.c_str(), null, 10); + + foundAttribute = __elementBuffer[__lastGraphicalSurfaceXMLElementIndex].attributes.find("dimCtrlY"); + SysTryCatchLabel(NID_UI_EFFECT, foundAttribute != __elementBuffer[__lastGraphicalSurfaceXMLElementIndex].attributes.end(), result = false, CATCH2, + E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentGraphicalSurfaceDimCtrlY = (unsigned int) strtol(foundAttribute->second.c_str(), null, 10); + + return true; + +CATCH1: + __buildingModelFailed = true; + + return result; + +CATCH2: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::PriorReadSceneData(void) +{ + bool result = true; + int timerTimeout = 0; + Vec3f ambientColor = __currentSceneData.ambientColor; + float intensity = __currentSceneData.intensity; + float attenuation = __currentSceneData.attenuation; + TypeXmlElementAttributes::iterator foundAttribute; + + SysTryCatch(NID_UI_EFFECT, __lastSceneXMLElementIndex != -1, result = false, E_INVALID_CONDITION, Tizen::Ui::Effects::_UiEffectError::EP_MEMBER_NOT_INITIALIZED); + { + XmlElement& xmlElement = __elementBuffer[__lastSceneXMLElementIndex]; + + foundAttribute = xmlElement.attributes.find("timerTimeout"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + timerTimeout = (int) strtol(foundAttribute->second.c_str(), null, 10); + SysTryCatch(NID_UI_EFFECT, timerTimeout > 0, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + __currentSceneData.timerTimeout = (unsigned int) timerTimeout; + + foundAttribute = xmlElement.attributes.find("ambientColor"); + if (foundAttribute != xmlElement.attributes.end()) + { + std::string stringColor = foundAttribute->second; + SysTryCatchLabel(NID_UI_EFFECT, *(stringColor.begin()) == '#', result = false, CATCH, + E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatchLabel(NID_UI_EFFECT, stringColor.size() == 7, result = false, CATCH, + E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + stringColor.erase(stringColor.begin()); + stringColor = "0x" + stringColor; + ambientColor = StringHexToRgb(stringColor); + } + + SysTryCatch(NID_UI_EFFECT, (0.0f <= ambientColor.x) && (ambientColor.x <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatch(NID_UI_EFFECT, (0.0f <= ambientColor.y) && (ambientColor.y <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + SysTryCatch(NID_UI_EFFECT, (0.0f <= ambientColor.z) && (ambientColor.z <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + __currentSceneData.ambientColor = ambientColor; + + foundAttribute = xmlElement.attributes.find("intensity"); + if (foundAttribute != xmlElement.attributes.end()) + { + intensity = (float) strtod(foundAttribute->second.c_str(), null); + SysTryCatch(NID_UI_EFFECT, (0.0f <= intensity) && (intensity <= 1.0f), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + __currentSceneData.intensity = intensity; + } + + foundAttribute = xmlElement.attributes.find("attenuation"); + if (foundAttribute != xmlElement.attributes.end()) + { + attenuation = (float) strtod(foundAttribute->second.c_str(), null); + SysTryCatch(NID_UI_EFFECT, 0.0f <= attenuation, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + __currentSceneData.attenuation = attenuation; + } + } + return true; + +CATCH: + __buildingModelFailed = true; + + return result; +} + +bool +EffectParser::ReadManifestData(XmlElement& xmlElement) +{ + bool result = true; + TypeXmlElementAttributes::iterator foundAttribute; + + foundAttribute = xmlElement.attributes.find("name"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentEffectInstanceName = foundAttribute->second; + + foundAttribute = xmlElement.attributes.find("behaviorType"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + if (foundAttribute->second == std::string("User controlled")) + { + __currentModelBehaviourType = EFFECT_TYPE_INTERACTIVE; + } + else + { + SysTryCatch(NID_UI_EFFECT, foundAttribute->second == std::string("Time based"), result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + } + + foundAttribute = xmlElement.attributes.find("timeDuration"); + SysTryCatch(NID_UI_EFFECT, foundAttribute != xmlElement.attributes.end(), result = false, E_KEY_NOT_FOUND, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_NOT_FOUND); + __currentEffectDuration = (TypeTimeEffect) ((float) strtod(foundAttribute->second.c_str(), null) / 1000.0f); + + SysTryCatch(NID_UI_EFFECT, __currentEffectDuration >= 0.0f, result = false, E_INVALID_ARG, Tizen::Ui::Effects::_UiEffectError::EP_ATTRIBUTE_VALUE_OUT_OF_PREDEFINED_RANGE); + + return true; + +CATCH: + __buildingModelFailed = true; + + return result; +} + +} } } } // Tizen::Ui::Effects::_EffectParser diff --git a/src/ui/effects/parser/FUiEffects_ParserXMLParser.cpp b/src/ui/effects/parser/FUiEffects_ParserXMLParser.cpp new file mode 100644 index 0000000..f5618d8 --- /dev/null +++ b/src/ui/effects/parser/FUiEffects_ParserXMLParser.cpp @@ -0,0 +1,181 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include +#include "../FUiEffects_EffectErrorMessages.h" + +namespace Tizen { namespace Ui { namespace Effects { namespace _Parser +{ + +EffectParser* XmlParser::__pCurrentParent = null; +bool XmlParser::__justParse = false; + +XmlParser::XmlParser(EffectParser* pParent) +{ + __pCurrentParent = pParent; + + SysLog(NID_UI_EFFECT, "Effects. An object of XMLParser class created!"); +} + +XmlParser::~XmlParser() +{ + __pCurrentParent = null; + __justParse = false; + + SysLog(NID_UI_EFFECT, "Effects. An object of XMLParser class destroyed!"); +} + +void +XmlParser::StartElementNs(void * pCtx, const xmlChar* pLocalName, const xmlChar* pPrefix, const xmlChar* pUri, + int namespaceCount, const xmlChar** ppNamespaces, int attributeCount, int defaultedCount, const xmlChar** ppAttributes) +{ + if (!__justParse) + { + __pCurrentParent->StartElement((const char*)pLocalName); + } + + if (attributeCount > 0) + { + std::string value; + unsigned int index = 0; + + for (int indexAttribute = 0; indexAttribute < attributeCount; ++indexAttribute, index += 5) + { + const xmlChar *pLocalAttributeName = ppAttributes[index]; + std::string attributesName((const char* )pLocalAttributeName); + + const xmlChar *pValueBegin = ppAttributes[index+3]; + std::string attributesValue((const char* )pValueBegin); + + size_t pos = attributesValue.find('"'); + value = attributesValue.substr(0, pos); + + if (!__justParse) + { + __pCurrentParent->Attribute(attributesName.c_str(), value.c_str()); + } + } + } + + return; +} + +void +XmlParser::EndElementNs(void* pCtx, const xmlChar* pLocalName, const xmlChar* pPrefix, const xmlChar* pUri) +{ + if (!__justParse) + { + __pCurrentParent->EndElement((const char*) pLocalName); + } + + return; +} + +void +XmlParser::CharactersM(void* pCtx, const xmlChar* pCh, int len) +{ + std::string wholeDoc = (char*) pCh; + size_t pos1 = wholeDoc.find('<'); + // check whether the character has been found + if (pos1 == std::string::npos) + { + return; + } + + if (!__justParse) + { + __pCurrentParent->Attribute("", wholeDoc.substr(pos1).c_str()); + } + + return; +} + +void +XmlParser::Error(void* pCtx, const char* pMsg, ... ) +{ + char buffer[256]; + va_list args; + va_start(args, pMsg); + vsprintf(buffer, pMsg, args); + va_end(args); + + return; +} + +void +XmlParser::Warning(void* pCtx, const char* pMsg, ... ) +{ + char buffer[256]; + va_list args; + va_start(args, pMsg); + vsprintf(buffer, pMsg, args); + va_end(args); + + return; +} + +bool +XmlParser::ExtractFromArchive(const char* pArchivePath, const char* pDestinationPath) +{ + bool result = true; + Tizen::Base::Utility::FileUnzipper unzipper; + + Tizen::Base::String archivePath = pArchivePath; + Tizen::Base::String destinationPath = pDestinationPath; + + unzipper.Construct(archivePath); + if (unzipper.UnzipTo(destinationPath) != E_SUCCESS) + { + result = false; + } + + return result; +} + +bool +XmlParser::Parse(const char* pFilePath, bool sendCallbacks) +{ + __justParse = !sendCallbacks; + + xmlSAXHandler saxHandler; + memset(&saxHandler, 0, sizeof(saxHandler)); + + // set SAX callbacks + saxHandler.initialized = XML_SAX2_MAGIC; + saxHandler.startElementNs = StartElementNs; + saxHandler.endElementNs = EndElementNs; + saxHandler.warning = Warning; + saxHandler.error = Error; + saxHandler.characters = CharactersM; + + // perform parsing + int parseResult = xmlSAXUserParseFile(&saxHandler, null, pFilePath); + + SysTryReturn(NID_UI_EFFECT, + parseResult == 0, + false, + E_PARSING_FAILED, + Tizen::Ui::Effects::_UiEffectError::EP_XML_PARSING_FAILED + ); + + return true; +} + +} } } } // Tizen::Ui::Effects::_Parser diff --git a/src/ui/effects/physics-engine/FUiEffects_PeElementSurface.cpp b/src/ui/effects/physics-engine/FUiEffects_PeElementSurface.cpp new file mode 100644 index 0000000..9b3e9b2 --- /dev/null +++ b/src/ui/effects/physics-engine/FUiEffects_PeElementSurface.cpp @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_PeElementSurface.cpp + * @brief This file contains an implementation of ElementSurface class methods + * + */ + +#include + +#include + +using namespace Tizen::Ui::Effects::_Runtime; +using namespace Tizen::Ui::Effects::_Utils; + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ + + +ElementSurface::ElementSurface(long objId) + : __objId(objId) +{ + return; +} + +ElementSurface::~ElementSurface() +{ + return; +} + +long +ElementSurface::GetId(void) const +{ + return __objId; +} + +PropertyCast +ElementSurface::GetProperty(ElementProperty property) const +{ + PropertyCast result; + result.type = PropertyCast::NO_PROPERTY; // failed to find corresponding property + result.value.numberValue = 0.; // value with no sence to init struct + + SysLog(NID_UI_EFFECT, "Bad get property call in element %u.\n", GetId()); + return result; +} + +bool +ElementSurface::SetProperty(ElementProperty property, bool boolValue) +{ + SysLog(NID_UI_EFFECT, "Bad set bool property call in element %u.\n", GetId()); + return false; // set failed +} + +bool +ElementSurface::SetProperty(ElementProperty property, LUA_NUMBER numericValue) +{ + SysLog(NID_UI_EFFECT, "Bad set number property call in element %u.\n", GetId()); + return false; // set failed +} + +bool +ElementSurface::SetProperty(ElementProperty property, const Tizen::Ui::Effects::_Utils::Vec3f & vectorValue) +{ + SysLog(NID_UI_EFFECT, "Bad set vector property call in element %u.\n", GetId()); + return false; // set failed +} + +} } } } // Tizen::Ui::Effects::_PhysicsEngine diff --git a/src/ui/effects/physics-engine/FUiEffects_PePointSurface.cpp b/src/ui/effects/physics-engine/FUiEffects_PePointSurface.cpp new file mode 100644 index 0000000..cda41cb --- /dev/null +++ b/src/ui/effects/physics-engine/FUiEffects_PePointSurface.cpp @@ -0,0 +1,326 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_PePointSurface.cpp + * @brief This file contains an implementation of PointSurface class methods + * + */ + +#include +#include +#include +#include "../FUiEffects_EffectErrorMessages.h" + +using namespace Tizen::Ui::Effects::_Runtime; +using namespace Tizen::Ui::Effects::_Utils; + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ + +PointSurface::PointSurface(long objId, Vec3f& positionInit, float massInit, float pointEnvResist, bool fixed) + : ElementSurface(objId), __positionInit(positionInit), __massInit(massInit), __pointEnvResist(pointEnvResist) +{ + this->__fixed = fixed; + + // those must be initialised in PointSurface::Construct + this->__pEnvResist = null; + this->__pGravityAcc = null; + this->__pGroundLevel = null; + + // initialize after creation + InitPoint(); +} + +PointSurface::~PointSurface() +{ + return; +} + +ESurface +PointSurface::GetType(void) const +{ + return ESURFACE_POINT_SURFACE; +} + +void +PointSurface::Initialize(void) +{ + InitPoint(); + return; +} + +bool +PointSurface::Construct(const float* pEnvResist, const Vec3f* pGravAcc, const float* pGroundLevel) +{ + SysAssertf(!(pEnvResist == null || pGravAcc == null || pGroundLevel == null), _UiEffectError::INTERNAL_ERROR); + + this->__pEnvResist = pEnvResist; + this->__pGravityAcc = pGravAcc; + this->__pGroundLevel = pGroundLevel; + return true; +} + +void +PointSurface::Calculate(float timeStep) +{ + // don't move point if fixed setting is enabled + if (__fixed) + { + __force.set(0.0f); + return; + } + + // add user force to total force + __force += __forceUser; + + // apply gravity force (m * g) + __force += __mass * (*__pGravityAcc); + + // apply environment resistance + __force -= __velocity * (__pointEnvResist * (*__pEnvResist)); + + __positionPrev = __position; // save current position + + // a = F(total) / m + // using explicit Euler time integration + // V = V0 + a * dt + // x = x0 + V * dt + __velocity += __force * timeStep / __mass; + __position += __velocity * timeStep; + + // GroundLevel value needs to be specified + if ( __position.z < *__pGroundLevel ) + { + __position.z = *__pGroundLevel; + } + + // reset force for next time step + //_vForceUser.set(0.0f); + __force.set(0.0f); + return; +} + +bool +PointSurface::IsFixed(void) const +{ + return __fixed; +} + +PropertyCast +PointSurface::GetProperty(ElementProperty property) const +{ + PropertyCast result; + switch (property) + { + // position coordinates + case N_POS_X: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __position.x; + break; + case N_POS_Y: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __position.y; + break; + case N_POS_Z: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __position.z; + break; + // initial position coordinates + case N_POS_X_INIT: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __positionInit.x; + break; + case N_POS_Y_INIT: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __positionInit.y; + break; + case N_POS_Z_INIT: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __positionInit.z; + break; + // velocity vector + case V_POS: + result.type = PropertyCast::VEC3; + result.value.vec3Value = &__position; + break; + // initial velocity vector + case V_POS_INIT: + result.type = PropertyCast::VEC3; + result.value.vec3Value = &__positionInit; + break; + // user force coordinates + case N_FUSER_X: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __forceUser.x; + break; + case N_FUSER_Y: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __forceUser.y; + break; + case N_FUSER_Z: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __forceUser.z; + break; + // user force vector + case V_FUSER: + result.type = PropertyCast::VEC3; + result.value.vec3Value = &__forceUser; + break; + // node mass + case N_MASS: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __mass; + break; + // node resistance + case N_POINT_RESISTANCE: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __pointEnvResist; + break; + // fixation setting + case B_IS_FIXED: + result.type = PropertyCast::BOOL; + result.value.boolValue = __fixed; + break; + default: + result = ElementSurface::GetProperty(property); + break; + } + return result; +} + +bool +PointSurface::SetProperty(ElementProperty property, bool boolValue) +{ + bool result = true; // for successful set + switch (property) + { + // fixation setting + case B_IS_FIXED: + __fixed = boolValue; + break; + default: + result = ElementSurface::SetProperty(property, boolValue); + break; + } + return result; +} + +bool +PointSurface::SetProperty(ElementProperty property, LUA_NUMBER numericValue) +{ + bool result = true; // for successful set + switch (property) + { + // position coordinates + case N_POS_X: + __position.x = numericValue; + break; + case N_POS_Y: + __position.y = numericValue; + break; + case N_POS_Z: + __position.z = numericValue; + break; + // user force coordinates + case N_FUSER_X: + __forceUser.x = numericValue; + break; + case N_FUSER_Y: + __forceUser.y = numericValue; + break; + case N_FUSER_Z: + __forceUser.z = numericValue; + break; + // node mass + case N_MASS: + __mass = numericValue; + break; + // node resistance + case N_POINT_RESISTANCE: + __pointEnvResist = numericValue; + break; + default: + result = ElementSurface::SetProperty(property, numericValue); + break; + } + return result; +} + +bool +PointSurface::SetProperty(ElementProperty property, const Vec3f& vectorValue) +{ + bool result = true; // for successful set + switch (property) + { + // velocity vector + case V_POS: + __position = vectorValue; + break; + // user force vector + case V_FUSER: + __forceUser = vectorValue; + break; + default: + result = ElementSurface::SetProperty(property, vectorValue); + break; + } + return result; +} + +const Vec3f& +PointSurface::GetPosition(void) const +{ + return __position; +} + +const Vec3f& +PointSurface::GetVelocity(void) const +{ + return __velocity; +} + +void +PointSurface::AddForce(Vec3f appliedForce) +{ + __force += appliedForce; + return; +} + +void +PointSurface::AddVelocity(Vec3f newVelocity) +{ + __velocity += newVelocity; + return; +} + +void +PointSurface::InitPoint(void) +{ + // setting simulation initial position and mass + __position = __positionPrev = __positionInit; + __mass = __massInit; + + // the point is considered still in the beginning + __velocity.set(0.0f); + __force.set(0.0f); + __forceUser.set(0.0f); + + return; +} + +} } } }//Tizen::Ui::Ext::Effects3d::_PhysicsEngine diff --git a/src/ui/effects/physics-engine/FUiEffects_PePointSurfaceNURBS.cpp b/src/ui/effects/physics-engine/FUiEffects_PePointSurfaceNURBS.cpp new file mode 100644 index 0000000..6f9e834 --- /dev/null +++ b/src/ui/effects/physics-engine/FUiEffects_PePointSurfaceNURBS.cpp @@ -0,0 +1,152 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_PePointSurfaceNURBS.cpp + * @brief This file contains an implementation of PointSurfaceNURBS class methods + * + */ + +#include + +using namespace Tizen::Ui::Effects::_Runtime; +using namespace Tizen::Ui::Effects::_Utils; + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ + +PointSurfaceNurbs::PointSurfaceNurbs( + long objId, + Vec3f positionInit, + float massInit, + float pointEnvResist, + float weightInit, + bool fixed, + unsigned int row, + unsigned int col +) + : PointSurface(objId, positionInit, massInit, pointEnvResist, fixed), + __nurbsWeightInit(weightInit), + __row(row), __col(col) +{ + // init after creation + InitPointNurbs(); +} + +PointSurfaceNurbs::~PointSurfaceNurbs(void) +{ + return; +} + +ESurface +PointSurfaceNurbs::GetType(void) const +{ + return ESURFACE_POINT_SURFACE_NURBS; +} + +void +PointSurfaceNurbs::Initialize(void) +{ + PointSurface::Initialize(); + InitPointNurbs(); + return; +} + +bool +PointSurfaceNurbs::Construct(const float* pEnvResist, const Vec3f* pGravAcc, const float* pGroundLevel) +{ + return PointSurface::Construct(pEnvResist, pGravAcc, pGroundLevel); +} + +void +PointSurfaceNurbs::Calculate(float timeStep) +{ + PointSurface::Calculate(timeStep); + return; +} + +PropertyCast +PointSurfaceNurbs::GetProperty(ElementProperty property) const +{ + PropertyCast result; + switch (property) + { + case N_NURBS_WEIGHT: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __nurbsWeight; + break; + default: + result = PointSurface::GetProperty(property); + break; + } + return result; +} + +bool +PointSurfaceNurbs::SetProperty(ElementProperty property, bool boolValue) +{ + return PointSurface::SetProperty(property, boolValue); +} + +bool +PointSurfaceNurbs::SetProperty(ElementProperty property, LUA_NUMBER numericValue) +{ + bool result = true; // for successful set + switch (property) + { + case N_NURBS_WEIGHT: + __nurbsWeight = numericValue; + break; + default: + result = PointSurface::SetProperty(property, numericValue); + break; + } + return result; +} + +bool +PointSurfaceNurbs::SetProperty(ElementProperty property, const Vec3f& vectorValue) +{ + return PointSurface::SetProperty(property, vectorValue); +} + +float +PointSurfaceNurbs::GetWeight(void) const +{ + return __nurbsWeight; +} + +unsigned int +PointSurfaceNurbs::GetRow(void) const +{ + return __row; +} + +unsigned int +PointSurfaceNurbs::GetCol(void) const +{ + return __col; +} + + +void +PointSurfaceNurbs::InitPointNurbs(void) +{ + __nurbsWeight = __nurbsWeightInit; + return; +} + +} } } } // Tizen::Ui::Effects::_PhysicsEngine diff --git a/src/ui/effects/physics-engine/FUiEffects_PeRodSurface.cpp b/src/ui/effects/physics-engine/FUiEffects_PeRodSurface.cpp new file mode 100644 index 0000000..b58cc03 --- /dev/null +++ b/src/ui/effects/physics-engine/FUiEffects_PeRodSurface.cpp @@ -0,0 +1,180 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_PeRodSurface.cpp + * @brief This file contains an implementation of RodSurface class methods + * + */ + +#include + +using namespace Tizen::Ui::Effects::_Runtime; +using namespace Tizen::Ui::Effects::_Utils; + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ + +RodSurface::RodSurface( + long objId, + float stiffness, + PointSurface* pPoint1, + PointSurface* pPoint2, + PointSurface* pPoint3 +) + : ElementSurface(objId), + __stiffnessInit(stiffness) +{ + this->_pPoint1 = pPoint1; + this->_pPoint2 = pPoint2; + this->_pPoint3 = pPoint3; + + // init when created + InitRod(); +} + +RodSurface::~RodSurface(void) +{ + return; +} + +ESurface +RodSurface::GetType(void) const +{ + return ESURFACE_ROD_SURFACE; +} + +void +RodSurface::Initialize(void) +{ + InitRod(); + return; +} + +void +RodSurface::Calculate(float timeStep) +{ + UseUnbendModel(timeStep); + return; +} + +PropertyCast +RodSurface::GetProperty(ElementProperty property) const +{ + PropertyCast result; + switch (property) + { + case N_STIFFNESS: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __stiffness; + break; + default: + result = ElementSurface::GetProperty(property); + break; + } + return result; +} + +bool +RodSurface::SetProperty(ElementProperty property, bool boolValue) +{ + return ElementSurface::SetProperty(property, boolValue); +} + +bool +RodSurface::SetProperty(ElementProperty property, LUA_NUMBER numericValue) +{ + bool result = true; // for successful set + switch (property) + { + // coefficient of rigidity + case N_STIFFNESS: + __stiffness = numericValue; + break; + default: + result = ElementSurface::SetProperty(property, numericValue); + break; + } + return result; +} + +bool +RodSurface::SetProperty(ElementProperty property, const Vec3f& vectorValue) +{ + return ElementSurface::SetProperty(property, vectorValue); +} + +void +RodSurface::InitRod(void) +{ + this->_deformationAngle = 0.f; + this->__stiffness = __stiffnessInit; + return; +} + +// old rod model, currently not used +void +RodSurface::UseStretchModel(float timeStep) +{ + Vec3f + direction31 = _pPoint3->GetPosition() - _pPoint1->GetPosition(), + direction21 = _pPoint2->GetPosition() - _pPoint1->GetPosition(), + rodForce; + + direction31.normalize(); + direction21.normalize(); + + // |[AxB]| = |A||B|sin(alpha) (angle between A and B) + // |A| = |B| = 1, so fDeformArc is equal to angle sine + _deformationAngle = direction21.getCrossed(direction31).length(); + float rodForceValue = __stiffness * _deformationAngle; + + rodForce = direction31 * rodForceValue; + + _pPoint3->AddForce( rodForce); + _pPoint1->AddForce(-rodForce); + return; +} + +// new rod model, now in use +void +RodSurface::UseUnbendModel(float timeStep) +{ + Vec3f + direction21 = _pPoint1->GetPosition() - _pPoint2->GetPosition(), + direction23 = _pPoint3->GetPosition() - _pPoint2->GetPosition(); + + direction21.normalize(); + direction23.normalize(); + + Vec3f rodNormal = direction23.getCrossed(direction21); + float deformation = rodNormal.length(), + forceValue = __stiffness * deformation; + + Vec3f forceDirection; + // force for central point + forceDirection = direction21 + direction23; + _pPoint2->AddForce( forceDirection.normalize() * forceValue ); + + // forces for edge points + forceValue *= 0.5f; + _pPoint1->AddForce( rodNormal.getCrossed(direction21).normalize() * forceValue ); + _pPoint3->AddForce( direction23.getCrossed(rodNormal).normalize() * forceValue ); + return; +} + +} } } } // Tizen::Ui::Effects::_PhysicsEngine diff --git a/src/ui/effects/physics-engine/FUiEffects_PeRodSurfaceNURBS.cpp b/src/ui/effects/physics-engine/FUiEffects_PeRodSurfaceNURBS.cpp new file mode 100644 index 0000000..a7c09d1 --- /dev/null +++ b/src/ui/effects/physics-engine/FUiEffects_PeRodSurfaceNURBS.cpp @@ -0,0 +1,113 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_PeRodSurfaceNURBS.cpp + * @brief This file contains an implementation of RodSurface class methods + * + */ + +#include + +using namespace Tizen::Ui::Effects::_Runtime; +using namespace Tizen::Ui::Effects::_Utils; + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ + +RodSurfaceNurbs::RodSurfaceNurbs( + long objId, + float stiffness, + PointSurfaceNurbs* pPoint1, + PointSurfaceNurbs* pPoint2, + PointSurfaceNurbs* pPoint3, + PointSurfaceNurbs* pPointN +) + : RodSurface(objId, stiffness, pPoint1, pPoint2, pPoint3), + __pPointNeighb(pPointN) +{ + // init when created + InitRodNurbs(); +} + +RodSurfaceNurbs::~RodSurfaceNurbs(void) +{ + return; +} + +ESurface +RodSurfaceNurbs::GetType(void) const +{ + return ESURFACE_ROD_SURFACE; +} + +void +RodSurfaceNurbs::Initialize(void) +{ + RodSurface::Initialize(); + InitRodNurbs(); + return; +} + +void +RodSurfaceNurbs::Calculate(float timeStep) +{ + RodSurface::Calculate(timeStep); +} + +PropertyCast +RodSurfaceNurbs::GetProperty(ElementProperty property) const +{ + return RodSurface::GetProperty(property); +} + +bool +RodSurfaceNurbs::SetProperty(ElementProperty property, bool boolValue) +{ + return RodSurface::SetProperty(property, boolValue); +} + +bool +RodSurfaceNurbs::SetProperty(ElementProperty property, LUA_NUMBER numericValue) +{ + return RodSurface::SetProperty(property, numericValue); +} + +bool +RodSurfaceNurbs::SetProperty(ElementProperty property, const Vec3f& vectorValue) +{ + return RodSurface::SetProperty(property, vectorValue); +} + +void +RodSurfaceNurbs::InitRodNurbs(void) +{ + return; +} + +const Vec3f +RodSurfaceNurbs::GetSurfaceNormal(void) const +{ + Vec3f + direction13 = _pPoint1->GetPosition() - _pPoint3->GetPosition(), + direction24 = _pPoint2->GetPosition() - __pPointNeighb->GetPosition(), + normalVec = direction13.getCrossed(direction24); + + normalVec.normalize(); + return normalVec; +} + +} } } } // Tizen::Ui::Effects::_PhysicsEngine diff --git a/src/ui/effects/physics-engine/FUiEffects_PeSpringSurface.cpp b/src/ui/effects/physics-engine/FUiEffects_PeSpringSurface.cpp new file mode 100644 index 0000000..39e5971 --- /dev/null +++ b/src/ui/effects/physics-engine/FUiEffects_PeSpringSurface.cpp @@ -0,0 +1,151 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_PeSpringSurface.cpp + * @brief This file contains an implementation of SpringSurface class methods + * + */ + +#include + +using namespace Tizen::Ui::Effects::_Runtime; +using namespace Tizen::Ui::Effects::_Utils; + +namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine +{ + +SpringSurface::SpringSurface( + long objId, + float stiffness, + PointSurface* pPoint1, + PointSurface* pPoint2 +) + : ElementSurface(objId), + __stiffnessInit(stiffness) +{ + this->__pPoint1 = pPoint1; + this->__pPoint2 = pPoint2; + + // init when created + InitSpring(); +} + +SpringSurface::~SpringSurface(void) +{ + return; +} + +ESurface +SpringSurface::GetType(void) const +{ + return ESURFACE_SPRING_SURFACE; +} + +void +SpringSurface::Initialize(void) +{ + InitSpring(); + return; +} + +void +SpringSurface::Calculate(float timeStep) +{ + float springLength = 0.f; + float deltaLength = 0.f; + Vec3f direction; + Vec3f tempForce; + + // compute current distance between nodes + direction = __pPoint1->GetPosition() - __pPoint2->GetPosition(); + + springLength = direction.length(); + if (springLength > 1.0e-4f) // delta precision + { + direction /= springLength; // normalizing without computing length again + } + + // compute elastic force + // simple Hooke's law: F = k*dx; + deltaLength = springLength - __restLength; + tempForce = direction * (__stiffness * deltaLength); + + // if F is positive - spring is stretched + // if F is negative - compressed + // apply force to nodes + __pPoint1->AddForce(-tempForce); + __pPoint2->AddForce( tempForce); + return; +} + +PropertyCast +SpringSurface::GetProperty(ElementProperty property) const +{ + PropertyCast result; + switch (property) + { + // coefficient of rigidity + case N_STIFFNESS: + result.type = PropertyCast::NUMBER; + result.value.numberValue = __stiffness; + break; + default: + result = ElementSurface::GetProperty(property); + break; + } + return result; +} + +bool +SpringSurface::SetProperty(ElementProperty property, bool boolValue) +{ + return ElementSurface::SetProperty(property, boolValue); +} + +bool +SpringSurface::SetProperty(ElementProperty property, LUA_NUMBER numericValue) +{ + bool result = true; // for successful set + switch (property) + { + // coefficient of rigidity + case N_STIFFNESS: + __stiffness = numericValue; + break; + default: + result = ElementSurface::SetProperty(property, numericValue); + break; + } + return result; +} + +bool +SpringSurface::SetProperty(ElementProperty property, const Vec3f& vectorValue) +{ + return ElementSurface::SetProperty(property, vectorValue); +} + +void +SpringSurface::InitSpring(void) +{ + __stiffness = __stiffnessInit; + // spring is considered unstrained in the beginning + __restLength = (__pPoint1->GetPosition() - __pPoint2->GetPosition()).length(); + return; +} + +} } } } // Tizen::Ui::Effects::_PhysicsEngine diff --git a/src/ui/effects/renderer/FUiEffects_RendererEffectRenderer.cpp b/src/ui/effects/renderer/FUiEffects_RendererEffectRenderer.cpp new file mode 100644 index 0000000..1230dc7 --- /dev/null +++ b/src/ui/effects/renderer/FUiEffects_RendererEffectRenderer.cpp @@ -0,0 +1,1055 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEffectRenderer.cpp + * @brief This is the source file for the EffectRenderer class + */ + +#include + +#include +#include + +#include +#include +#include + +#include "FUiEffects_RendererEffectShader.h" +#include +#include +#include +#include "../FUiEffects_EffectErrorMessages.h" +#include + +using namespace Tizen::Ui::Effects::_Runtime; +using namespace Tizen::Ui::Effects::_Renderer::EngineModel; +using namespace Tizen::Ui::Effects::_Renderer::Math; +using namespace Tizen::Ui::Effects::_Renderer::GraphicsEngine; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using std::string; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +EGLDisplay EffectRenderer::__eglDisplay = EGL_NO_DISPLAY; +EGLConfig EffectRenderer::__eglConfig = 0; +EGLint EffectRenderer::__glMajorVer = 0; +EGLint EffectRenderer::__glMinorVer = 0; +bool EffectRenderer::__OpenGLInitialized = false; + +const EGLint RENDERER_EGL_DEFAULT_CONFIG_ATTRIBS[] = +{ + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_DEPTH_SIZE, 0, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_NONE +}; + +static const EGLint RENDERER_EGL_DEFAULT_CONTEXT_ATTRIBS[] = +{ + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE +}; + +bool +EffectRenderer::InitOpenGL(const EGLint* pConfig) +{ + //if already initialized + if (__OpenGLInitialized) + { + SysLog(NID_UI_EFFECT, "OpenGL already initialized."); + + return true; + } + + int nconfigs = 0; + eglBindAPI(EGL_OPENGL_ES_API); + + __eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); + SysTryReturn(NID_UI_EFFECT, __eglDisplay != EGL_NO_DISPLAY, false, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Effects. There was an error while performing function eglGetDisplay"); + + + SysTryCatchLabel(NID_UI_EFFECT, eglInitialize(__eglDisplay, &__glMajorVer, &__glMinorVer) == EGL_TRUE, , INIT_ERROR, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Effects. There was an error while performing function eglInitialize"); + //SysLog(NID_UI_EFFECT, "Effects. GL version %d.%d", __glMajorVer, __glMinorVer); + + SysTryCatchLabel(NID_UI_EFFECT, eglChooseConfig(__eglDisplay, pConfig, &__eglConfig, 1, &nconfigs) == EGL_TRUE, , INIT_ERROR, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Effects. There was an error while performing function eglChooseConfig"); + + + SysTryCatchLabel(NID_UI_EFFECT, nconfigs == 1, , INIT_ERROR, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Effects. There is eglChooseConfig matching configurations count error (OpenGL)"); + +//INIT_SUCCESS: + __OpenGLInitialized = CheckEglNoErrors(); + + SysTryReturn(NID_UI_EFFECT, __OpenGLInitialized, false, E_OPERATION_FAILED, "[E_OPERATION_FAILED] There are OpenGL errors during initialization"); + + SysLog(NID_UI_EFFECT, "OpenGL initialized successfully."); + return true; + + +INIT_ERROR: + __OpenGLInitialized = false; + eglTerminate(__eglDisplay); + __eglDisplay = EGL_NO_DISPLAY; + SysLogException(NID_UI_EFFECT, E_OPERATION_FAILED, "[E_OPERATION_FAILED] OpenGL errors were appeared during initialization"); + + return false; +} + +void +EffectRenderer::CloseOpenGL(void) +{ + SysLog(NID_UI_EFFECT, "Effects. OpenGL is closing..."); + + //if already initialized + if (!__OpenGLInitialized) + { + SysLog(NID_UI_EFFECT, "OpenGL not initialized."); + + return; + } + + if (__eglDisplay != EGL_NO_DISPLAY) + { + eglTerminate(__eglDisplay); + __eglDisplay = EGL_NO_DISPLAY; + } + + __OpenGLInitialized = false; + + SysLog(NID_UI_EFFECT, "OpenGL closed!"); + + return; +} + +bool +EffectRenderer::CheckOpenGlesInitialized(void) +{ + return __OpenGLInitialized; +} + +EGLSurface +EffectRenderer::CreateSurface(EGLNativeWindowType wnd) +{ + EGLSurface newsurface = eglCreateWindowSurface(__eglDisplay, __eglConfig, wnd, 0); + + EGL_ASSERT_NOERRORS + + SysTryReturn(NID_UI_EFFECT, newsurface != EGL_NO_SURFACE && CheckEglNoErrors(), EGL_NO_SURFACE, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Effects. There was an error while performing function eglCreateWindowSurface (EGL_NO_SURFACE)"); + + EGL_ASSERT_NOERRORS + return newsurface; +} + +void +EffectRenderer::DeleteSurface(EGLSurface surface) +{ + SysTryReturnVoidResult(NID_UI_EFFECT, surface != EGL_NO_SURFACE, E_OPERATION_FAILED, "DeleteSurface EGL_NO_SURFACE"); + + eglDestroySurface(__eglDisplay, surface); + + return; +} + +EGLContext +EffectRenderer::CreateContext(EGLContext shareContext) +{ + EGLContext newContext = eglCreateContext(__eglDisplay, __eglConfig, EGL_NO_CONTEXT, RENDERER_EGL_DEFAULT_CONTEXT_ATTRIBS); + + SysTryReturn(NID_UI_EFFECT, newContext != EGL_NO_CONTEXT && CheckEglNoErrors(), EGL_NO_CONTEXT, E_OPERATION_FAILED, "[E_OPERATION_FAILED] Effects. There was an error while performing function eglCreateContext (EGL_NO_CONTEXT)"); + EGL_ASSERT_NOERRORS + + return newContext; +} + +void +EffectRenderer::DeleteContext(EGLContext context) +{ + //SysTryLog(NID_UI_EFFECT, context != EGL_NO_CONTEXT, "DeleteContext EGL_NO_CONTEXT"); + + eglDestroyContext(__eglDisplay, context); + + return; +} + +EffectRenderer::EffectRenderer(void) + : __previousContext(EGL_NO_CONTEXT) + , __previousContextSaved(false) + , __FOV_Y_deg(0.f) + , __perspectiveProjection(false) + , __renderDataScene(null) + , __pRenderDataSurfaceCollection(null) + , __dimensionPreviousControl() +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + surface = EGL_NO_SURFACE; + __context = CreateContext(); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __renderer = RenderPtr(new (std::nothrow) Render); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__renderer) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __root = GroupPtr(new (std::nothrow) Group); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__root) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __camera = CameraPtr(new (std::nothrow) Camera); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__camera) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __camera->SetWorld(Math::Matrix4f().Identity()); + + StringShaderPropertyPtr vertex(new (std::nothrow) StringShaderProperty(ShaderProperty::ShaderType::VERTEX, EFFECT_VERTEX_SHADER_STR)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(vertex) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + StringShaderPropertyPtr fragment(new (std::nothrow) StringShaderProperty(ShaderProperty::ShaderType::FRAGMENT, EFFECT_DUMMY_FRAGMENT_SHADER_STR)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(fragment) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __program = ShaderHolderProgramPropertyPtr(new (std::nothrow) ShaderHolderProgramProperty(vertex, fragment)); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__program) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __renderer->SetDefaultDepthTestState(true); +} + +EffectRenderer::~EffectRenderer(void) +{ + ReleaseCache(); + DeleteContext(__context); +} + +void +EffectRenderer::MakeCurrent(void) +{ + SysAssertf(__eglDisplay != EGL_NO_DISPLAY, _UiEffectError::INTERNAL_ERROR); + SysAssertf(surface != EGL_NO_SURFACE, _UiEffectError::INTERNAL_ERROR); + + if (!__previousContextSaved) + { + __previousContext = eglGetCurrentContext(); + __previousContextSaved = true; + } + + eglMakeCurrent(__eglDisplay, surface, surface, __context); + + return; +} + +void +EffectRenderer::RestorePreviousContext(void) +{ + if (__previousContextSaved && __eglDisplay != EGL_NO_DISPLAY) + { + if (__previousContext != EGL_NO_CONTEXT && surface != EGL_NO_SURFACE) + { + eglMakeCurrent(__eglDisplay, surface, surface, __previousContext); + } + else + { + eglMakeCurrent(__eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + } + } + + __previousContextSaved = false; + + return; +} + +MemoryTexture2DPropertyPtr +EffectRenderer::FindTexture(long bitmapID) +{ + TexturesMap::const_iterator it = __textures.find(bitmapID); + + if (it != __textures.end()) + { + return it->second; + } + + //else (not found) + // create empty placeholder for further texture upload + MemoryTexture2DPropertyPtr tex = MemoryTexture2DPropertyPtr(new (std::nothrow) MemoryTexture2DProperty); + + result r = GetLastResult(); + SysTryReturn(NID_UI_EFFECT, r == E_SUCCESS, tex, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturn(NID_UI_EFFECT, System::GetImpl(tex) != null, tex, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __textures.insert(TexturesMap::value_type(bitmapID, tex)); + return tex; +} + +void +EffectRenderer::InitializeContext(void) const +{ + glClearColor(0,0,0,1); + glDisable(GL_CULL_FACE); + + return; +} + +void +EffectRenderer::Construct(RenderDataScene &renderDataCollection) +{ + __renderDataScene = &renderDataCollection; + __pRenderDataSurfaceCollection = &renderDataCollection.GetRenderDataSurfaceCollection(); + + Tizen::Ui::Effects::_Runtime::RenderDataSurfaceCollection::size_type objcount = __pRenderDataSurfaceCollection->size(); + + __root->Clear();// no deletion of children? check destructors + __root->AddChild(__camera); + __objects.clear(); + + ConstructLighting(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __objects.resize(objcount); + for (RenderDataSurfaceCollection::size_type i = 0; i < objcount; ++i) + { + __objects[i] = RendererObjectPtr(new (std::nothrow) RendererObject); + + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__objects[i]) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + } + + for (RenderDataSurfaceCollection::size_type i = 0; i < objcount; ++i) + { + InitRObjectFromData(i, *(*__pRenderDataSurfaceCollection)[i]); + } + + return; +} + +void +EffectRenderer::ConstructLighting() +{ + SysAssertf(__renderDataScene != null, _UiEffectError::INTERNAL_ERROR); + + __lightingParameters.SetAmbientColor(__renderDataScene->GetLightAmbientColour()); + __lightingParameters.SetAmbientIntensity(__renderDataScene->GetLightIntensity()); + __lightingParameters.SetAttenuation(__renderDataScene->GetLightAttenuation()); + + if (__renderDataScene->LockUnitsLightContainer()) + { + do + { + switch (__renderDataScene->GetTypeOfCurrentUnitLight()) + { + case TYPE_UNIT_LIGHT_POINT: + { + const _Runtime::PointLight* pModelPointLight = __renderDataScene->GetCurrentUnitLight<_Runtime::PointLight>(); + if (pModelPointLight != null) + { + PointLightPtr pointLight = PointLightPtr(new (std::nothrow) PointLight(__lightingParameters.GetAttenuation())); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(pointLight) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + __pointLights[pModelPointLight->GetName()] = pointLight; + + pointLight->SetPosition(pModelPointLight->GetPosition()); + pointLight->SetColor(pModelPointLight->GetColour()); + pointLight->SetIntensity(pModelPointLight->GetIntensity()); + pointLight->SetEnabled(pModelPointLight->GetEnabled()); + } + } + break; + case TYPE_UNIT_LIGHT_SPOT: + { + const _Runtime::SpotLight* pModelSpotLight = __renderDataScene->GetCurrentUnitLight<_Runtime::SpotLight>(); + if (pModelSpotLight != null) + { + SpotLightPtr spotLight = SpotLightPtr(new (std::nothrow) SpotLight(__lightingParameters.GetAttenuation())); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(spotLight) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + __spotLights[pModelSpotLight->GetName()] = spotLight; + + spotLight->SetPosition(pModelSpotLight->GetPosition()); + spotLight->SetTarget(pModelSpotLight->GetTarget()); + spotLight->SetOpeningAngle(pModelSpotLight->GetAngleOpening()); + spotLight->SetFadeOutAngle(pModelSpotLight->GetAngleFadeOut()); + spotLight->SetColor(pModelSpotLight->GetColour()); + spotLight->SetIntensity(pModelSpotLight->GetIntensity()); + spotLight->SetEnabled(pModelSpotLight->GetEnabled()); + } + } + break; + case TYPE_UNIT_LIGHT_DIRECTIONAL: + { + const _Runtime::DirectionalLight* pModelDirectionalLight = __renderDataScene->GetCurrentUnitLight<_Runtime::DirectionalLight>(); + if (pModelDirectionalLight != null) + { + DirectionalLightPtr directionalLight = DirectionalLightPtr(new (std::nothrow) DirectionalLight); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(directionalLight) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + __directionalLights[pModelDirectionalLight->GetName()] = directionalLight; + + directionalLight->SetDirection(pModelDirectionalLight->GetDirection()); + directionalLight->SetColor(pModelDirectionalLight->GetColour()); + directionalLight->SetIntensity(pModelDirectionalLight->GetIntensity()); + directionalLight->SetEnabled(pModelDirectionalLight->GetEnabled()); + } + } + break; + default: + break; + } + } + while (__renderDataScene->GoToNextUnitLight()); + } + + CreateShader(); + + return; +} + +void +EffectRenderer::UpdateLighting(void) +{ + SysAssertf(__renderDataScene != null, _UiEffectError::INTERNAL_ERROR); + + bool updated = false; + bool needShaderCompilation = false; + + if (__renderDataScene->isSomethingChanged) + { + updated = true; + + if (__renderDataScene->isAmbientColourChanged) + { + __lightingParameters.SetAmbientColor(__renderDataScene->GetLightAmbientColour()); + __renderDataScene->isAmbientColourChanged = false; + } + + if (__renderDataScene->isIntensityChanged) + { + __lightingParameters.SetAmbientIntensity(__renderDataScene->GetLightIntensity()); + __renderDataScene->isIntensityChanged = false; + } + + if (__renderDataScene->isAttenuationChanged) + { + __lightingParameters.SetAttenuation(__renderDataScene->GetLightAttenuation()); + + for (PointLightsList::iterator it = __pointLights.begin(); it != __pointLights.end(); ++it) + { + it->second->UpdateAttenuation(); + } + + for (SpotLightsList::iterator it = __spotLights.begin(); it != __spotLights.end(); ++it) + { + it->second->UpdateAttenuation(); + } + + __renderDataScene->isAttenuationChanged = false; + } + __renderDataScene->isSomethingChanged = false; + } + + if (__renderDataScene->LockUnitsLightContainer()) + { + do + { + const _Runtime::UnitLight *pLight = __renderDataScene->GetCurrentUnitLight<_Runtime::UnitLight>(); + updated = updated || pLight->isSomethingChanged; + + if (pLight->isSomethingChanged) + { + string nameUnitLight = pLight->GetName(); + + switch (pLight->GetType()) + { + case TYPE_UNIT_LIGHT_POINT: + { + const _Runtime::PointLight* pModelPointLight = static_cast(pLight); + PointLight *pPointLight = System::GetImpl(__pointLights[nameUnitLight]); + + if (pModelPointLight->isPositionChanged) + { + pPointLight->SetPosition(pModelPointLight->GetPosition()); + } + + if (pModelPointLight->isColourChanged) + { + pPointLight->SetColor(pModelPointLight->GetColour()); + } + + if (pModelPointLight->isIntensityChanged) + { + pPointLight->SetIntensity(pModelPointLight->GetIntensity()); + } + + if (pModelPointLight->isEnabledChanged) + { + needShaderCompilation = true; + pPointLight->SetEnabled(pModelPointLight->GetEnabled()); + } + + } + break; + case TYPE_UNIT_LIGHT_SPOT: + { + const _Runtime::SpotLight* pModelSpotLight = static_cast(pLight); + SpotLight *pSpotLight = System::GetImpl(__spotLights[nameUnitLight]); + + if (pModelSpotLight->isPositionChanged) + { + pSpotLight->SetPosition(pModelSpotLight->GetPosition()); + } + + if (pModelSpotLight->isTargetChanged) + { + pSpotLight->SetTarget(pModelSpotLight->GetTarget()); + } + + if (pModelSpotLight->isAngleOpeningChanged) + { + pSpotLight->SetOpeningAngle(pModelSpotLight->GetAngleOpening()); + } + + if (pModelSpotLight->isAngleFadeOutChanged) + { + pSpotLight->SetFadeOutAngle(pModelSpotLight->GetAngleFadeOut()); + } + + if (pModelSpotLight->isColourChanged) + { + pSpotLight->SetColor(pModelSpotLight->GetColour()); + } + + if (pModelSpotLight->isIntensityChanged) + { + pSpotLight->SetIntensity(pModelSpotLight->GetIntensity()); + } + + if (pModelSpotLight->isEnabledChanged) + { + needShaderCompilation = true; + pSpotLight->SetEnabled(pModelSpotLight->GetEnabled()); + } + } + break; + case TYPE_UNIT_LIGHT_DIRECTIONAL: + { + const _Runtime::DirectionalLight* pModelDirectionalLight = static_cast(pLight); + DirectionalLight *pDirectionalLight = System::GetImpl(__directionalLights[nameUnitLight]); + + if (pModelDirectionalLight->isDirectionChanged) + { + pDirectionalLight->SetDirection(pModelDirectionalLight->GetDirection()); + } + + if (pModelDirectionalLight->isColourChanged) + { + pDirectionalLight->SetColor(pModelDirectionalLight->GetColour()); + } + + if (pModelDirectionalLight->isIntensityChanged) + { + pDirectionalLight->SetIntensity(pModelDirectionalLight->GetIntensity()); + } + + if (pModelDirectionalLight->isEnabledChanged) + { + needShaderCompilation = true; + pDirectionalLight->SetEnabled(pModelDirectionalLight->GetEnabled()); + } + } + break; + default: + break; + } // switch + + __renderDataScene->ResetSignsCurrentUnitLight(); + + } // if (flags != 0) + } + while (__renderDataScene->GoToNextUnitLight()); + + if (updated) + { + if (needShaderCompilation) + { + CreateShader(); + } + + std::vector::size_type n = __objects.size(); + for (std::vector::size_type i = 0; i < n; ++i) + { + __objects[i]->GetMaterial()->TouchDrawables(); + __objects[i]->InvalidateCache(); + } + } + } + + return; +} + +void +EffectRenderer::CreateShader() +{ + string __fragmentSource = EFFECT_FRAGMENT_SHADER_STR; + + + if (__pointLights.size() > 0) + { + char buffer [30]; + string def_entry; + string src_entry; + + string::size_type defpos = __fragmentSource.find(POINTLIGHT_DEFPOS_STR); + string::size_type srcpos = __fragmentSource.find(POINTLIGHT_SRCPOS_STR); + + SysAssert(defpos != string::npos); + SysAssert(srcpos != string::npos); + + int i = 0; + + for (PointLightsList::const_iterator it = __pointLights.begin(); it != __pointLights.end(); ++it) + { + if (!it->second->GetEnabled()) + { + continue; + } + + def_entry = POINTLIGHT_DEF_STR; + sprintf(buffer, "%d", i); + replace(def_entry, "%n", buffer); + __fragmentSource.insert(defpos, def_entry); + defpos += def_entry.length(); + srcpos += def_entry.length(); + + src_entry = it->second->IsBlack()? POINTLIGHT_NOATTSRC_STR : POINTLIGHT_ATTSRC_STR; + sprintf(buffer, "%d", i); + replace(src_entry, "%n", buffer); + __fragmentSource.insert(srcpos, src_entry); + srcpos += src_entry.length(); + + i++; + } + } + + if (__spotLights.size() > 0) + { + char buffer [30]; + string def_entry; + string src_entry; + + string::size_type defpos = __fragmentSource.find(SPOTLIGHT_DEFPOS_STR); + string::size_type srcpos = __fragmentSource.find(SPOTLIGHT_SRCPOS_STR); + + SysAssert(defpos != string::npos); + SysAssert(srcpos != string::npos); + + int i = 0; + + for (SpotLightsList::const_iterator it = __spotLights.begin(); it != __spotLights.end(); ++it) + { + if (!it->second->GetEnabled()) + { + continue; + } + + def_entry = SPOTLIGHT_DEF_STR; + sprintf(buffer, "%d", i); + replace(def_entry, "%n", buffer); + __fragmentSource.insert(defpos, def_entry); + defpos += def_entry.length(); + srcpos += def_entry.length(); + + src_entry = it->second->IsBlack()? SPOTLIGHT_NOATTSRC_STR : SPOTLIGHT_ATTSRC_STR; + sprintf(buffer, "%d", i); + replace(src_entry, "%n", buffer); + __fragmentSource.insert(srcpos, src_entry); + srcpos += src_entry.length(); + + i++; + } + } + + if (__directionalLights.size() > 0) + { + char buffer [30]; + string def_entry; + string src_entry; + + string::size_type defpos = __fragmentSource.find(DIRECTIOALLIGHT_DEFPOS_STR); + string::size_type srcpos = __fragmentSource.find(DIRECTIOALLIGHT_SRCPOS_STR); + + SysAssert(defpos != string::npos); + SysAssert(srcpos != string::npos); + + int i = 0; + + for (DirectionalLightsList::const_iterator it = __directionalLights.begin(); it != __directionalLights.end(); ++it) + { + if (!it->second->GetEnabled()) + { + continue; + } + + def_entry = DIRECTIOALLIGHT_DEF_STR; + sprintf(buffer, "%d", i); + replace(def_entry, "%n", buffer); + __fragmentSource.insert(defpos, def_entry); + defpos += def_entry.length(); + srcpos += def_entry.length(); + + src_entry = DIRECTIOALLIGHT_SRC_STR; + sprintf(buffer, "%d", i); + replace(src_entry, "%n", buffer); + __fragmentSource.insert(srcpos, src_entry); + srcpos += src_entry.length(); + + i++; + } + } + + __program->GetShader(EngineModel::ShaderProperty::ShaderType::FRAGMENT).staticCast()->SetSource(__fragmentSource); + if (System::GetImpl(__program->GetCache()) != null) + { + __program->GetCache()->Invalidate(); + } + + PRINT_DEBUG("Shader ", __fragmentSource); + + return; +} + +void +EffectRenderer::InitRObjectFromData(RenderDataSurfaceCollection::size_type index, RenderDataSurface &rdata) +{ + SysAssertf(index < __objects.size(), "Effects. Renderer: index < __objects.size()"); + + __objects[index]->opacity->Set(1.0f - rdata.transparency); + __objects[index]->alphablend->Enable(rdata.transparency > 0.0f); + + __objects[index]->GetMat()->AddProperty("Lib Effects Rendering Program", __program); + __objects[index]->GetMat()->AddProperty(MAIN_TEX_STR, FindTexture(rdata.bitmapId)); + __objects[index]->GetMat()->AddProperty(LIGHTING_AMBIENTCOLORI_STR, __lightingParameters.GetAmbientColorIHolder()); + + char buffer [30]; + + int i = 0; + for(PointLightsList::const_iterator it = __pointLights.begin(); it != __pointLights.end(); ++it) + { + sprintf(buffer, "%d", i); + + __objects[index]->GetMat()->AddProperty((string(POINTLIGHT_STR) + buffer + POINTLIGHT_POSITION_STR).c_str(), (*it).second->GetPositionHolder()); + __objects[index]->GetMat()->AddProperty((string(POINTLIGHT_STR) + buffer + POINTLIGHT_COLORI_STR).c_str(), (*it).second->GetColorIHolder()); + __objects[index]->GetMat()->AddProperty((string(POINTLIGHT_STR) + buffer + POINTLIGHT_RK_STR).c_str(), (*it).second->GetRkHolder()); + + i++; + } + + i = 0; + for (DirectionalLightsList::const_iterator it = __directionalLights.begin(); it != __directionalLights.end(); ++it) + { + sprintf(buffer, "%d", i); + + __objects[index]->GetMat()->AddProperty((string(DIRECTIOALLIGHT_STR) + buffer + DIRECTIOALLIGHT_DIRECTION_STR).c_str(), (*it).second->GetDirectionHolder()); + __objects[index]->GetMat()->AddProperty((string(DIRECTIOALLIGHT_STR) + buffer + DIRECTIOALLIGHTLIGHT_COLORI_STR).c_str(), (*it).second->GetColorIHolder()); + + i++; + } + + i = 0; + for (SpotLightsList::const_iterator it = __spotLights.begin(); it != __spotLights.end(); ++it) + { + sprintf(buffer, "%d", i); + + __objects[index]->GetMat()->AddProperty((string(SPOTLIGHT_STR) + buffer + SPOTLIGHT_POSITION_STR).c_str(), (*it).second->GetPositionHolder()); + __objects[index]->GetMat()->AddProperty((string(SPOTLIGHT_STR) + buffer + SPOTLIGHT_DIRECTION_STR).c_str(), (*it).second->GetDirectionHolder()); + __objects[index]->GetMat()->AddProperty((string(SPOTLIGHT_STR) + buffer + SPOTLIGHT_K1_STR).c_str(), (*it).second->GetK1Holder()); + __objects[index]->GetMat()->AddProperty((string(SPOTLIGHT_STR) + buffer + SPOTLIGHT_K2_STR).c_str(), (*it).second->GetK2Holder()); + __objects[index]->GetMat()->AddProperty((string(SPOTLIGHT_STR) + buffer + SPOTLIGHT_COLORI_STR).c_str(), (*it).second->GetColorIHolder()); + __objects[index]->GetMat()->AddProperty((string(SPOTLIGHT_STR) + buffer + SPOTLIGHT_RK_STR).c_str(), (*it).second->GetRkHolder()); + + i++; + } + + RendererGeometryPtr geom(new (std::nothrow) RendererGeometry); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(geom) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __objects[index]->setGeometry(geom); + + __objects[index]->GetGeom()->SetVertData(rdata.vnt); + __objects[index]->GetGeom()->SetIndices(rdata.indices); + + __objects[index]->modelMtr->Set(Math::Matrix4f(rdata.modelMtr[0], rdata.modelMtr[4], rdata.modelMtr[8], rdata.modelMtr[12], + rdata.modelMtr[1], rdata.modelMtr[5], rdata.modelMtr[9], rdata.modelMtr[13], + rdata.modelMtr[2], rdata.modelMtr[6], rdata.modelMtr[10], rdata.modelMtr[14], + rdata.modelMtr[3], rdata.modelMtr[7], rdata.modelMtr[11], rdata.modelMtr[15])); + + Math::Matrix4f tmpNormalMtr(Math::Matrix4f::GetIdentity()); + __objects[index]->normalMtr->Set(tmpNormalMtr.SetRotation(__objects[index]->modelMtr->Get().GetRotation().Inverse())); // ".transpose()" is omitted due to "column order" matrix representation in GLSL + + __root->AddChild(__objects[index]); + + return; +} + +void +EffectRenderer::Update(void) +{ + + std::unique_ptr x; + + SysAssertf(__renderDataScene != null, _UiEffectError::INTERNAL_ERROR); + SysAssertf(__pRenderDataSurfaceCollection != null, _UiEffectError::INTERNAL_ERROR); + SysAssertf(__objects.size() == __pRenderDataSurfaceCollection->size(), _UiEffectError::INTERNAL_ERROR); + + Tizen::Ui::Effects::_Runtime::RenderDataSurfaceCollection::size_type objcount = __pRenderDataSurfaceCollection->size(); + + for (RenderDataSurfaceCollection::size_type i = 0; i < objcount; ++i) + { + UpdateRObject(i, *(*__pRenderDataSurfaceCollection)[i]); + } + + UpdateLighting(); + + return; +} + +void +EffectRenderer::UpdateRObject(RenderDataSurfaceCollection::size_type index, RenderDataSurface &rdata) +{ + if (rdata.vertexDataChanged || rdata.indicesChanged) + { + RendererGeometryPtr geometry = __objects[index]->GetGeom(); + + if (rdata.vertexDataChanged) + { + geometry->InvalidateVertexData(); + rdata.vertexDataChanged = false; + } + + if (rdata.indicesChanged) + { + geometry->InvalidateIndices(); + rdata.indicesChanged = false; + } + + geometry->TouchDrawables(); + } + + if (rdata.modelMtrChanged) + { + __objects[index]->modelMtr->Set(Math::Matrix4f(rdata.modelMtr[0], rdata.modelMtr[4], rdata.modelMtr[8], rdata.modelMtr[12], + rdata.modelMtr[1], rdata.modelMtr[5], rdata.modelMtr[9], rdata.modelMtr[13], + rdata.modelMtr[2], rdata.modelMtr[6], rdata.modelMtr[10], rdata.modelMtr[14], + rdata.modelMtr[3], rdata.modelMtr[7], rdata.modelMtr[11], rdata.modelMtr[15])); + + Math::Matrix4f tmpNormalMtr(Math::Matrix4f::GetIdentity()); + + __objects[index]->normalMtr->Set(tmpNormalMtr.SetRotation(__objects[index]->modelMtr->Get().GetRotation().Inverse())); // ".transpose()" is omitted due to "column order" matrix representation in GLSL + __objects[index]->InvalidateCache(); + rdata.modelMtrChanged = false; + } + + if (rdata.bitmapIdChanged || rdata.transparencyChanged) + { + PropertyHolderMaterialPtr material = __objects[index]->GetMat(); + + if (rdata.bitmapIdChanged) + { + material->AddProperty(MAIN_TEX_STR, FindTexture(rdata.bitmapId)); + rdata.bitmapIdChanged = false; + } + + if (rdata.transparencyChanged) + { + __objects[index]->opacity->Set(1.0f - rdata.transparency); + __objects[index]->alphablend->Enable(rdata.transparency > 0.0f); + rdata.transparencyChanged = false; + } + + material->TouchDrawables(); + } + + return; +} + +void +EffectRenderer::Draw(void) +{ + SysAssertf(__eglDisplay != EGL_NO_DISPLAY, _UiEffectError::INTERNAL_ERROR); + SysAssertf(surface != EGL_NO_SURFACE, _UiEffectError::INTERNAL_ERROR); + SysAssertf(__context != EGL_NO_CONTEXT, _UiEffectError::INTERNAL_ERROR); + + MakeCurrent(); + InitializeContext(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + __renderer->Draw(*__root); + eglSwapBuffers(__eglDisplay, surface); + + RestorePreviousContext(); + + return; +} + +void +EffectRenderer::SetScreen(float screenLeft, float screenRight, float screenBottom, float screenTop, int displayWidth, int displayHeight) +{ + SysAssertf(screenRight > screenLeft, _UiEffectError::INTERNAL_ERROR); + SysAssertf(screenTop < screenBottom, _UiEffectError::INTERNAL_ERROR); + SysAssertf(displayWidth > 0, _UiEffectError::INTERNAL_ERROR); + SysAssertf(displayHeight > 0, _UiEffectError::INTERNAL_ERROR); + + __viewport.screenLeft = screenLeft; + __viewport.screenRight = screenRight; + __viewport.screenTop = screenTop; + __viewport.screenBottom = screenBottom; + __viewport.displayWidth = displayWidth; + __viewport.displayHeight = displayHeight; + + __camera->SetViewport(Vector2f(0,0), Vector2f(displayWidth, displayHeight)); + + return; +} + +void +EffectRenderer::TrackScreenSizeChanges(const Control& control) +{ + if (__dimensionPreviousControl != control.GetSize()) + { + SetScreen(control); + } + return; +} + +void +EffectRenderer::SetScreen(const Control& control) +{ + Dimension logicalScreenSizeCurrent = control.GetSize(); // not real but logical size of control + Dimension realScreenSize = _CoordinateSystemUtils::Transform(logicalScreenSizeCurrent); // real size of control + SetScreen(0, logicalScreenSizeCurrent.width, logicalScreenSizeCurrent.height, 0, realScreenSize.width, realScreenSize.height); + __dimensionPreviousControl = logicalScreenSizeCurrent; + return; +} + +bool +EffectRenderer::SetWorld(float worldLeft, float worldRight, float worldBottom, float worldTop, float worldZ, float worldNearDist, float worldFarDist, float FOV_Y_deg, bool perspectiveProjection) +{ + SysAssertf(fabs(worldLeft - worldRight) > std::numeric_limits::epsilon(), _UiEffectError::INTERNAL_ERROR); + SysAssertf(fabs(worldTop - worldBottom) > std::numeric_limits::epsilon(), _UiEffectError::INTERNAL_ERROR); + SysAssertf(FOV_Y_deg < 180.0f && FOV_Y_deg > 0.0f, _UiEffectError::INTERNAL_ERROR); + SysAssertf(worldNearDist > 0.0f && worldFarDist > 0.0f && worldNearDist < worldFarDist, _UiEffectError::INTERNAL_ERROR); + + __viewport.worldLeft = worldLeft; + __viewport.worldRight = worldRight; + __viewport.worldTop = worldTop; + __viewport.worldBottom = worldBottom; + __viewport.worldZ = worldZ; + __viewport.worldNearDist = worldNearDist; + __viewport.worldFarDist = worldFarDist; + + __FOV_Y_deg = FOV_Y_deg; + __perspectiveProjection = perspectiveProjection; + + Math::Matrix4f tmpmat; + + if (__perspectiveProjection) + { + float cameraHeight = (__viewport.worldTop - __viewport.worldBottom) / 2 / tan(Math::F_Deg_2_Rad(__FOV_Y_deg)/2.0f) + __viewport.worldZ; + + tmpmat = Math::Matrix4f::CreatePerspectiveFovRH(Math::F_Deg_2_Rad(__FOV_Y_deg), (__viewport.worldRight - __viewport.worldLeft) / (__viewport.worldTop - __viewport.worldBottom), __viewport.worldNearDist, __viewport.worldFarDist); + tmpmat.data[1].data[1] = -tmpmat.data[1].data[1]; + __camera->SetProj(tmpmat); + + tmpmat = Math::Matrix4f::GetIdentity(); + tmpmat.SetTranslation((__viewport.worldRight + __viewport.worldLeft) / 2, (__viewport.worldTop + __viewport.worldBottom) / 2, cameraHeight); + __camera->SetWorld(tmpmat); + } + else + { + tmpmat = Math::Matrix4f::GetIdentity(); + __camera->SetWorld(tmpmat); + + tmpmat = Math::Matrix4f::CreateOrthoRH(__viewport.worldLeft, __viewport.worldRight, __viewport.worldBottom, __viewport.worldTop, -__viewport.worldFarDist, __viewport.worldFarDist); + __camera->SetProj(tmpmat); + } + + return true; +} + +Tizen::Ui::Effects::_Utils::Vec3f +EffectRenderer::TransformScreenToWorld(Tizen::Ui::Effects::_Utils::Vec2f p) const +{ + return __viewport.TransformScreenToWorld(p); +} + +bool +EffectRenderer::SetBitmap(long bitmapID, Tizen::Graphics::Bitmap &bitmap) +{ + MemoryTexture2DPropertyPtr tex = FindTexture(bitmapID); + Tizen::Graphics::_BitmapImpl* pBitmapImpl = Tizen::Graphics::_BitmapImpl::GetInstance(bitmap); + BufferInfo bufferInfo; + + SysTryReturn(NID_UI_EFFECT, pBitmapImpl != null, false, E_OPERATION_FAILED, "[E_OPERATION_FAILED] _BitmapImpl::GetInstance has returned null value"); + + PROFILER_EXPR(pBitmapImpl->LockFast(bufferInfo);, PROFLOG_Lock); + + if (bufferInfo.pPixels == null || bufferInfo.width <= 0 || bufferInfo.height <= 0) + { + bitmap.Unlock(); + return false; + } + + PROFILER_EXPR(tex->SetData((void*) bufferInfo.pPixels, bufferInfo.width, bufferInfo.height);, PROFLOG_Setdata); + PROFILER_EXPR(pBitmapImpl->UnlockFast();, PROFLOG_Unlock); + + return true; +} + +bool +EffectRenderer::SetBitmap(long bitmapID, const void* ptr, size_t width, size_t height) +{ + //ptr = null is OK for texture memory allocation + FindTexture(bitmapID)->SetData(ptr, width, height); + + return true; +} + +void EffectRenderer::BuildCache() +{ + MakeCurrent(); + __renderer->InternalCollectInfo(*__root); + RestorePreviousContext(); +} + +void EffectRenderer::ReleaseCache() +{ + if (surface != EGL_NO_SURFACE) + { + MakeCurrent(); + Reset(__renderer); + RestorePreviousContext(); + } +} + +}}}} //Tizen::Ui::Effects::_Renderer diff --git a/src/ui/effects/renderer/FUiEffects_RendererEffectShader.cpp b/src/ui/effects/renderer/FUiEffects_RendererEffectShader.cpp new file mode 100644 index 0000000..9526814 --- /dev/null +++ b/src/ui/effects/renderer/FUiEffects_RendererEffectShader.cpp @@ -0,0 +1,216 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEffectShader.cpp + * @brief This is the file with effects library shaders sources + * + */ + +#include + +#include + +using std::string; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +const char* const EFFECT_VERTEX_SHADER_STR = + "#define SHADER_NAME EffectVertexShader \n" + "attribute vec3 "SHADER_IN_POSITION_STR";\n" + "attribute vec3 "SHADER_IN_NORMAL_STR";\n" + "attribute vec2 "SHADER_IN_TEXCOORDS_STR";\n" + "\n" + "uniform highp mat4 WorldViewProjection;\n" + "uniform highp mat4 ModelMtr; \n" + "uniform mediump mat4 NormalMtr; \n" + "\n" + "varying highp vec3 Position; \n" + "varying mediump vec3 Normal; \n" + "varying mediump vec2 TexCoords;\n" + "\n" + "void main()\n" + "{\n" + " highp vec4 WorldPos = ModelMtr * vec4(in_Position, 1.0); \n" + " gl_Position = WorldViewProjection * WorldPos;\n" + " Position = WorldPos.xyz; \n" + " Normal = (NormalMtr * vec4(in_Normal, 0.0)).xyz; \n" + " TexCoords = in_TexCoords;\n" + "}\n"; + +const char* const EFFECT_FRAGMENT_SHADER_STR = + "#define SHADER_NAME EffectFragmentShader \n" + "//precision highp float;\n" + "//precision highp vec3;\n" + "//precision highp vec4;\n" + "varying highp vec3 Position; \n" + "varying mediump vec3 Normal;\n" + "varying mediump vec2 TexCoords;\n" + "\n" + "uniform mediump sampler2D "MAIN_TEX_STR";\n" + "\n" + "struct LightingParameters \n" + "{ \n" + " mediump vec3 ambientColorI; \n" + " mediump float attenuationR2; \n" + "}; \n" + "\n" + "struct PointLight \n" + "{ \n" + " highp vec3 position; \n" + " mediump vec3 colorI; \n" + " mediump float Rk; \n" + "}; \n" + "\n" + "struct SpotLight \n" + "{ \n" + " highp vec3 position; \n" + " mediump vec3 direction; \n" + " mediump float k1; \n" + " mediump float k2; \n" + " mediump vec3 colorI; \n" + " mediump float Rk; \n" + "}; \n" + "\n" + "struct DirectionalLight \n" + "{ \n" + " mediump vec3 direction; \n" + " mediump vec3 colorI; \n" + "}; \n" + "\n" + "uniform LightingParameters lightingParameters; \n" + POINTLIGHT_DEFPOS_STR + SPOTLIGHT_DEFPOS_STR + DIRECTIOALLIGHT_DEFPOS_STR + "uniform lowp float opacity; \n" + "\n" + "void main ()\n" + "{ \n" + " mediump vec3 normal = normalize(Normal); \n" + " mediump vec3 color = lightingParameters.ambientColorI; \n" + " highp vec3 lightdir; \n" + " mediump float att; \n" + " \n" + POINTLIGHT_SRCPOS_STR + "\n" + SPOTLIGHT_SRCPOS_STR + "\n" + DIRECTIOALLIGHT_SRCPOS_STR + " \n" + " gl_FragColor.rgb = texture2D(TEX_MAIN, TexCoords).bgr * color; \n" + " gl_FragColor.a = opacity; \n" + "}"; + +const char* const EFFECT_DUMMY_FRAGMENT_SHADER_STR = "void main() { gl_FragColor = vec4(0.5, 0.9, 0.2, 1.0); }"; + +const char* const BLUR_VS = + "#define SHADER_NAME BlurVS \n" + "attribute vec3 "SHADER_IN_POSITION_STR";\n" + "attribute vec2 "SHADER_IN_TEXCOORDS_STR";\n" + "\n" + "varying mediump vec2 TexCoords;\n" + "\n" + "void main()\n" + "{\n" + " gl_Position = vec4(in_Position, 1.0);\n" + " TexCoords = in_TexCoords;\n" + "}\n"; + +const char* const BLUR_HORIZ_FS = + "#define SHADER_NAME BlurHorizFS_2 \n" + "varying mediump vec2 TexCoords;\n" + "\n" + "uniform mediump sampler2D "MAIN_TEX_STR";\n" + "uniform mediump float weights[48]; \n" + "uniform mediump float stepx; \n" + "uniform mediump float stepy; \n" + "uniform mediump float size; \n" + "//mediump float weights2[5]; \n" + "\n" + "void main (void)\n" + "{\n" + " /////if(int(size) == 4) gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); else gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); \n" + " // weights2[0] = 0.3990503; weights2[1] = 0.24203622; weights2[2] = 0.054005586; weights2[3] = 0.0044330484; \n" + " mediump vec4 result = vec4(0.0); \n" + " mediump vec2 coords1 = TexCoords; \n" + " mediump vec2 coords2 = TexCoords; \n" + " mediump int sizei = int(size); \n" + " mediump vec4 ppp; \n" + " \n" + " for(mediump int i = 1; i < 201; i++){ if(i >= 2) break; ppp = vec4(vec3(weights[i]), 1.0); result = ppp; } \n" + "\n" + " gl_FragColor = result; \n" + "} \n"; + +const char* const BLUR_VERT_FS = + "#define SHADER_NAME BlurVertFS_TEST \n" + "varying lowp vec2 TexCoords;\n" + "void main() { mediump vec4 p = vec4(0.0); gl_FragColor = p; }"; + + +void replace(std::string &str, const std::string what, const std::string with) +{ + if (what.empty()) + { + return; + } + + string::size_type start_pos = str.find(what); + + while (start_pos != string::npos) + { + str.replace(start_pos, what.length(), with); + start_pos += with.length(); + start_pos = str.find(what, start_pos); + } + + return; +} + +void printstring(const std::string name, const std::string &str) +{ + std::string delim = "\n"; + + string::size_type pos = 0; + string::size_type pos2, dlen = delim.length(), slen = str.length(); + int i = 1; + char buffer [30]; + + while (pos < slen && i < 10000) + { + sprintf(buffer, "%d", i); + + pos2 = str.find(delim, pos); + + string sss = name + buffer + ". " + string(str, pos, pos2); + + SysLog(0, "%s", sss.length() == 0? "" : sss.c_str()); + + if (pos2 == string::npos) + { + break; + } + + pos = pos2 + dlen; + i++; + } + + return; +} + +}}}} //Tizen::Ui::Effects::_Renderer diff --git a/src/ui/effects/renderer/FUiEffects_RendererLog.cpp b/src/ui/effects/renderer/FUiEffects_RendererLog.cpp new file mode 100644 index 0000000..05830b8 --- /dev/null +++ b/src/ui/effects/renderer/FUiEffects_RendererLog.cpp @@ -0,0 +1,121 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererLog.cpp + * @brief This is the source file for the renderer logging functions + */ +#include + +#include +#include +#include +#include + +using namespace Tizen::Graphics::Opengl; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +bool +CheckEglNoErrors(void) +{ + EGLint egl_error_code = eglGetError(); + + switch (egl_error_code) + { + case EGL_SUCCESS: + return true; + case EGL_NOT_INITIALIZED: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_NOT_INITIALIZED"); + return false; + case EGL_BAD_ACCESS: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_BAD_ACCESS"); + return false; + case EGL_BAD_ALLOC: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_BAD_ALLOC"); + return false; + case EGL_BAD_ATTRIBUTE: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_BAD_ATTRIBUTE"); + return false; + case EGL_BAD_CONTEXT: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_BAD_CONTEXT"); + return false; + case EGL_BAD_CONFIG: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_BAD_CONFIG"); + return false; + case EGL_BAD_CURRENT_SURFACE: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_BAD_CURRENT_SURFACE"); + return false; + case EGL_BAD_DISPLAY: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_BAD_DISPLAY"); + return false; + case EGL_BAD_SURFACE: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_BAD_SURFACE"); + return false; + case EGL_BAD_MATCH: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_BAD_MATCH"); + return false; + case EGL_BAD_PARAMETER: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_BAD_PARAMETER"); + return false; + case EGL_BAD_NATIVE_PIXMAP: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_BAD_NATIVE_PIXMAP"); + return false; + case EGL_BAD_NATIVE_WINDOW: + SysLog(NID_UI_EFFECT, "[OpenGL] EGL_BAD_NATIVE_WINDOW"); + return false; + default: + SysLog(NID_UI_EFFECT, "[OpenGL] Unknown eglGetError error code %d", egl_error_code); + return false; + } + + return false; +} + +bool +CheckGlNoErrors(void) +{ + GLint gl_error_code = glGetError(); + + switch (gl_error_code) + { + case GL_NO_ERROR: + return true; + case GL_INVALID_ENUM: + SysLog(NID_UI_EFFECT, "[OpenGL] GL_INVALID_ENUM"); + return false; + case GL_INVALID_VALUE: + SysLog(NID_UI_EFFECT, "[OpenGL] GL_INVALID_VALUE"); + return false; + case GL_INVALID_OPERATION: + SysLog(NID_UI_EFFECT, "[OpenGL] GL_INVALID_OPERATION"); + return false; + case GL_INVALID_FRAMEBUFFER_OPERATION: + SysLog(NID_UI_EFFECT, "[OpenGL] GL_INVALID_FRAMEBUFFER_OPERATION"); + return false; + case GL_OUT_OF_MEMORY: + SysLog(NID_UI_EFFECT, "[OpenGL] GL_OUT_OF_MEMORY"); + return false; + default: + return false; + } + + return false; +} + +} } } } // Tizen::Ui::Effects::_EffectRenderer diff --git a/src/ui/effects/renderer/FUiEffects_RendererMemoryTexture2DProperty.cpp b/src/ui/effects/renderer/FUiEffects_RendererMemoryTexture2DProperty.cpp new file mode 100644 index 0000000..7c422bc --- /dev/null +++ b/src/ui/effects/renderer/FUiEffects_RendererMemoryTexture2DProperty.cpp @@ -0,0 +1,80 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RendererMemoryTexture2DProperty.cpp + * @brief This is the source file for the MemoryTexture2DProperty class + */ + +#include +#include + +using namespace Tizen::Ui::Effects::_Renderer::EngineModel; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +MemoryTexture2DProperty::MemoryTexture2DProperty(void) +{ + unsigned char pix[4] = {255, 0, 128, 255}; + SetData(pix, 1, 1); +} + +MemoryTexture2DProperty::~MemoryTexture2DProperty(void) +{ + +} + +int +MemoryTexture2DProperty::GetFormatSize(void) +{ + switch (GetDataFormat()) + { + case TextureProperty::DataFormat::RGB: + // fall through + + case TextureProperty::DataFormat::BGR: + return 3; + + case TextureProperty::DataFormat::RGBA: + // fall through + + case TextureProperty::DataFormat::BGRA: + return 4; + + default: ; //ASSERTLOG(0); + return 0; + } +} + +void +MemoryTexture2DProperty::SetData(const void* ptr, size_t width, size_t height) +{ + __width = width; + __height = height; + __data.Resize(__width * __height * GetFormatSize()); + + if (ptr != null) + { + __data.Copy(ptr, __data.Size(), 0); + } + + TouchCache(); + + return; +} + +}}}} //Tizen::Ui::Effects::_Renderer diff --git a/src/ui/effects/renderer/FUiEffects_RendererRendererGeometry.cpp b/src/ui/effects/renderer/FUiEffects_RendererRendererGeometry.cpp new file mode 100644 index 0000000..649ef4f --- /dev/null +++ b/src/ui/effects/renderer/FUiEffects_RendererRendererGeometry.cpp @@ -0,0 +1,80 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererRendererGeometry.cpp + * @brief This is the source file for the RendererGeometry class + */ + +#include +#include +#include +#include + +using namespace Tizen::Ui::Effects::_Renderer::Math; +using namespace Tizen::Ui::Effects::_Renderer::EngineModel; +using namespace Tizen::Ui::Effects::_Runtime; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ + +RendererGeometry::RendererGeometry(void) +{ + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __composite = Buffer_CompositeFloatVertexPtr(new (std::nothrow) _Buffer_CompositeFloatVertex()); + __indexTriangles = Buffer_UIntIndexPtr(new (std::nothrow) _Buffer_UShortIndex()); + + __partVertex = Buffer_VertexAttributePtr(new (std::nothrow) _Buffer_VertexAttribute(__composite, 3, VertexData::OffsetPos(), VertexData::Stride())); + __partNormal = Buffer_VertexAttributePtr(new (std::nothrow) _Buffer_VertexAttribute(__composite, 3, VertexData::OffsetNorm(), VertexData::Stride())); + __partTexCoords = Buffer_VertexAttributePtr(new (std::nothrow) _Buffer_VertexAttribute(__composite, 2, VertexData::OffsetTexCoords(), VertexData::Stride())); + + r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__composite) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__indexTriangles) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__partVertex) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__partNormal) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + SysTryReturnVoidResult(NID_UI_EFFECT, System::GetImpl(__partTexCoords) != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); +} + +RendererGeometry::~RendererGeometry(void) +{ + return; +} + +BufferPtr +RendererGeometry::GetBuffer(const std::string& aName) const +{ + if (aName == SHADER_IN_POSITION_STR) + { + return __partVertex; + } + else if (aName == SHADER_IN_TEXCOORDS_STR ) + { + return __partTexCoords; + } + else if (aName == SHADER_IN_NORMAL_STR) + { + return __partNormal; + } + + return BufferPtr(); +} + +}}}} //Tizen::Ui::Effects::_Renderer diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelAlphaBlendProperty.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelAlphaBlendProperty.cpp new file mode 100644 index 0000000..f371e7f --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelAlphaBlendProperty.cpp @@ -0,0 +1,115 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelAlphaBlendProperty.cpp + * @brief This file contains implementation of AlphaBlendProperty class + * + */ + +#include +#include + + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +AlphaBlendProperty::AlphaBlendProperty(void): + __source(BlendFactor::SRC_ALPHA), + __destination(BlendFactor::ONE_MINUS_SRC_ALPHA), + __isEnabled(true) +{ + +} + +AlphaBlendProperty::~AlphaBlendProperty(void) +{ + if (__cache) + { + __cache->Die(); + } +} + +void +AlphaBlendProperty::Visit(PropertyVisitor& v) +{ + v.OnAlphaBlendProperty(*this); + return; +} + +bool +AlphaBlendProperty::IsEnable(void) +{ + return __isEnabled; +} + +AlphaBlendProperty::BlendFactor::Value +AlphaBlendProperty::GetSourceFactor(void) +{ + return __source; +} + +AlphaBlendProperty::BlendFactor::Value +AlphaBlendProperty::GetDestinationFactor(void) +{ + return __destination; +} + +void +AlphaBlendProperty::SetFactors(BlendFactor::Value source, BlendFactor::Value destination) +{ + __source = source; + __destination = destination; + TouchCache(); + return; +} +void +AlphaBlendProperty::Enable(bool isEnabled) +{ + __isEnabled = isEnabled; + TouchCache(); + return; +} + +CachePtr +AlphaBlendProperty::GetCache(void) +{ + return __cache; +} + +void +AlphaBlendProperty::SetCache(CachePtr cache) +{ + if (__cache) + { + __cache->Die(); + } + __cache = cache; + return; +} + +void +AlphaBlendProperty::TouchCache(void) +{ + if (__cache) + { + __cache->Invalidate(); + } + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelBuffer.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelBuffer.cpp new file mode 100644 index 0000000..2d88e57 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelBuffer.cpp @@ -0,0 +1,41 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelBuffer.cpp + * @brief This file contains implementation of Buffer class + * + */ + + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +Buffer::Buffer(void) +{ + +} + +Buffer::~Buffer(void) +{ + +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelCache.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelCache.cpp new file mode 100644 index 0000000..a8392c6 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelCache.cpp @@ -0,0 +1,30 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelCache.cpp + * @brief This file contains implementation of Cache class + * + */ + + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelCamera.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelCamera.cpp new file mode 100644 index 0000000..0f845b8 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelCamera.cpp @@ -0,0 +1,169 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelCamera.cpp + * @brief This file contains implementation of Camera class + * + */ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +Camera::Camera(void) +{ + _proj.value.MakePerspectiveFovRH(Math::F_Deg_2_Rad(45.0f), 1.0f, 0.1f, 32000.0f); + _proj.invalid = false; + + _frustum.invalid = true; + + _minPos.Set(0.0f, 0.0f); + _maxPos.Set(0.0f, 0.0f); + + _clearColor.Set(1.0f, 1.0f, 1.0f, 1.0f); +} + +Camera::~Camera(void) +{ +} + +void +Camera::SetViewport(const Math::Vector2f& minPos, const Math::Vector2f& maxPos) +{ + _minPos = minPos; + _maxPos = maxPos; + return; +} + +const Math::Vector2f& +Camera::GetViewportMin(void) +{ + return _minPos; +} + +const Math::Vector2f& +Camera::GetViewportMax(void) +{ + return _maxPos; +} + +void +Camera::Visit(Visitor& v) +{ + v.OnCamera(*this); + return; +} + +const Math::Matrix4f& +Camera::GetProj(void) +{ + return _proj.value; +} + +void +Camera::SetProj(const Math::Matrix4f& arg) +{ + _proj.value = arg; + _proj.invalid = false; + + _frustum.invalid = true; + return; +} + +void +Camera::SetLocal(const Math::Matrix4f& arg) +{ + Node::SetLocal(arg); + _frustum.invalid = true; + return; +} + +void +Camera::SetWorld(const Math::Matrix4f& arg) +{ + Node::SetWorld(arg); + _frustum.invalid = true; + return; +} + +const Frustum& +Camera::GetFrustum(void) +{ + if (_frustum.invalid) + { + ValidateFrustum(); + } + return _frustum.value; +} + +bool +Camera::AttachedToParent(Group* pParent) +{ + if (!Node::AttachedToParent(pParent)) + { + return false; + } + + _frustum.invalid = true; + return true; +} + +bool +Camera::RemoveFromParent(Group* pParent) +{ + if (!Node::RemoveFromParent(pParent)) + { + return false; + } + + _frustum.invalid = true; + return true; +} + +void +Camera::ParentMoved(Group* pParent) +{ + Node::ParentMoved(pParent); + _frustum.invalid = true; + return; +} + +void +Camera::ValidateFrustum(void) +{ + _frustum.value.Build(GetProj(), GetWorld()); + _frustum.invalid = false; + return; +} + +void +Camera::SetClearColor(const Math::Vector4f& color) +{ + _clearColor = color; + return; +} + +const Math::Vector4f& +Camera::GetClearColor(void) +{ + return _clearColor; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelDrawable.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelDrawable.cpp new file mode 100644 index 0000000..c0aeb51 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelDrawable.cpp @@ -0,0 +1,149 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelDrawable.cpp + * @brief This file contains implementation of Drawable class + * + */ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +Drawable::Drawable(void) +{ +} + +Drawable::~Drawable(void) +{ + if (_pCache) + { + _pCache->Die(); + } +} + +void +Drawable::SetGeometry(GeometryPtr pGeom) +{ + if (_pGeometry) + { + _pGeometry->RemovedFromDrawable(this); + } + _pGeometry = pGeom; + + if (_pGeometry) + { + _pGeometry->AttachedToDrawable(this); + } + TouchParentBoundBox(); + InvalidateCache(); + return; +} + +GeometryPtr +Drawable::GetGeometry(void) +{ + return _pGeometry; +} + +void +Drawable::SetMaterial(MaterialPtr pMat) +{ + if (_pMaterial) + { + _pMaterial->RemovedFromDrawable(this); + } + _pMaterial = pMat; + + if (_pMaterial) + { + _pMaterial->AttachedToDrawable(this); + } + InvalidateCache(); + return; +} + +MaterialPtr +Drawable::GetMaterial(void) +{ + return _pMaterial; +} + +void +Drawable::InvalidateCache(void) +{ + if (_pCache) + { + _pCache->Invalidate(); + } + return; +} + +void +Drawable::ValidateBoundBox(void) +{ + if (_pGeometry) + { + _boundBox.value = _pGeometry->GetBoundBox(); + } + else + { + _boundBox.value.Identity(); + } + + _boundBox.invalid = false; + return; +} + +const Aabb& +Drawable::GetBoundBox(void) +{ + if (_boundBox.invalid) + { + ValidateBoundBox(); + } + return _boundBox.value; +} + +CachePtr +Drawable::GetCache(void) +{ + return _pCache; +} + +void +Drawable::SetCache(CachePtr pCache) +{ + if (_pCache) + { + _pCache->Die(); + } + _pCache = pCache; + return; +} + +void +Drawable::InvalidateBoundBox(void) +{ + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelFloatArrayProperty.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelFloatArrayProperty.cpp new file mode 100644 index 0000000..4fe2d23 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelFloatArrayProperty.cpp @@ -0,0 +1,36 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelFloatArrayProperty.cpp + * @brief This file contains implementation of FloatArrayProperty class + * + */ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +void +FloatArrayProperty::Visit(PropertyVisitor& v) +{ + v.OnFloatArrayProperty(*this); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelFloatPropertyHolder.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelFloatPropertyHolder.cpp new file mode 100644 index 0000000..79db3a1 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelFloatPropertyHolder.cpp @@ -0,0 +1,52 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelFloatPropertyHolder.cpp + * @brief This file contains implementation of FloatPropertyHolder class + * + */ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +FloatPropertyHolder::FloatPropertyHolder(void) +{ + __value = 0.0f; +} + +FloatPropertyHolder::~FloatPropertyHolder(void) +{ + +} + +float +FloatPropertyHolder::Get(void) const +{ + return __value; +} + +void +FloatPropertyHolder::Set(float value) +{ + __value = value; + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelGeometry.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelGeometry.cpp new file mode 100644 index 0000000..037532f --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelGeometry.cpp @@ -0,0 +1,80 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelGeometry.cpp + * @brief This file contains implementation of Geometry class + * + */ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +void +Geometry::AttachedToDrawable(Drawable* drawable) +{ + DrawablesListIteratorType it = std::find(_drawables.begin(), _drawables.end(), drawable); + if (_drawables.end() != it) + { + return; + } + _drawables.push_back(drawable); + return; +} + +void +Geometry::RemovedFromDrawable(Drawable* drawable) +{ + DrawablesListIteratorType it = std::find(_drawables.begin(), _drawables.end(), drawable); + if (_drawables.end() == it) + { + return; + } + + const DrawablesListSizeType len = _drawables.size(); + std::swap(_drawables[len - 1], _drawables[it - _drawables.begin()]); + _drawables.resize(len - 1); + return; +} + +void +Geometry::TouchDrawables(void) +{ + const DrawablesListSizeType len = _drawables.size(); + for (DrawablesListSizeType i = 0; len > i; ++i) + { + _drawables[i]->InvalidateCache(); + } + return; +} + +void +Geometry::TouchDrawablesBoundBox(void) +{ + const DrawablesListSizeType len = _drawables.size(); + for (DrawablesListSizeType i = 0; len > i; ++i) + { + _drawables[i]->InvalidateBoundBox(); + } + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelGroup.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelGroup.cpp new file mode 100644 index 0000000..c959306 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelGroup.cpp @@ -0,0 +1,236 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelGroup.cpp + * @brief This file contains implementation of Group class + * + */ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +Group::Group(void) + : Node() + , _invalidBoundBox(true) + , _children() +{ + +} + +Group::~Group(void) +{ + const ChildrenListSizeType len = _children.size(); + for (ChildrenListSizeType i = 0; len > i; ++i) + { + _children[i]->RemoveFromParent(this); + } +} + +void +Group::Visit(Visitor& v) +{ + v.OnGroup(*this); + return; +} + +bool +Group::AddChild(NodePtr pChild) +{ + if (!pChild->AttachedToParent(this)) + { + return false; + } + + _children.push_back(pChild); + InvalidateBoundBox(); + return true; +} + +bool +Group::RemoveChild(NodePtr pChild) +{ + const ChildrenListSizeType len = _children.size(); + for (ChildrenListSizeType i = 0; len > i; ++i) + { + if (pChild == _children[i]) + { + InternalRemoveChild(i); + return true; + } + } + + return false; +} + +bool +Group::RemoveChild(ChildrenListSizeType index) +{ + if (index >= _children.size()) + { + return false; + } + InternalRemoveChild(index); + return true; +} + +void +Group::Clear(void) +{ + for (ChildrenListType::iterator it = _children.begin(); it != _children.end(); ++it) + { + (*it)->RemoveFromParent(this); + } + _children.clear(); + InvalidateBoundBox(); + return; +} + +void +Group::InternalRemoveChild(ChildrenListSizeType index) +{ + const ChildrenListSizeType len = _children.size(); + NodePtr current = _children[index]; + std::swap(_children[index], _children[len - 1]); + current->RemoveFromParent(this); + InvalidateBoundBox(); + return; +} + +void +Group::InvalidateBoundBox(void) +{ + if (_boundBox.invalid) + { + return; + } + _boundBox.invalid = true; + TouchParentBoundBox(); + return; +} + +const Aabb& +Group::GetBoundBox(void) +{ + if (_boundBox.invalid) + { + ValidateBoundBox(); + } + return _boundBox.value; +} + +void +Group::SetWorld(const Math::Matrix4f& arg) +{ + Node::SetWorld(arg); + const ChildrenListSizeType len = _children.size(); + for (ChildrenListSizeType i = 0; len > i; ++i) + { + _children[i]->ParentMoved(this); + } + return; +} + +void +Group::SetLocal(const Math::Matrix4f& arg) +{ + Node::SetLocal(arg); + const ChildrenListSizeType len = _children.size(); + for (ChildrenListSizeType i = 0; len > i; ++i) + { + _children[i]->ParentMoved(this); + } + return; +} + +void +Group::ValidateBoundBox(void) +{ + _boundBox.value.Identity(); + + const ChildrenListSizeType len = _children.size(); + for (ChildrenListSizeType i = 0; len > i; ++i) + { + _boundBox.value.Extend(_children[i]->GetBoundBoxInParentSpace()); + } + _boundBox.invalid = false; + return; +} + +bool +Group::AttachedToParent(Group* pParent) +{ + if (!Node::AttachedToParent(pParent)) + { + return false; + } + + const ChildrenListSizeType len = _children.size(); + for (ChildrenListSizeType i = 0; len > i; ++i) + { + _children[i]->ParentMoved(this); + } + return true; +} + +bool +Group::RemoveFromParent(Group* pParent) +{ + if (!Node::RemoveFromParent(pParent)) + { + return false; + } + + const ChildrenListSizeType len = _children.size(); + for (ChildrenListSizeType i = 0; len > i; ++i) + { + _children[i]->ParentMoved(this); + } + return true; +} + +void +Group::ParentMoved(Group* pParent) +{ + if (_worldTransform.invalid) + { + return; + } + Node::ParentMoved(pParent); + const ChildrenListSizeType len = _children.size(); + for (ChildrenListSizeType i = 0; len > i; ++i) + { + _children[i]->ParentMoved(this); + } +} + +Group::ChildrenListSizeType +Group::ChildrenCount(void) +{ + return _children.size(); +} + +NodePtr +Group::GetChild(ChildrenListSizeType index) +{ + return _children[index]; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelMaterial.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelMaterial.cpp new file mode 100644 index 0000000..c6e0d1f --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelMaterial.cpp @@ -0,0 +1,68 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelMaterial.cpp + * @brief This file contains implementation of Material class + * + */ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +void +Material::AttachedToDrawable(Drawable* pDrawable) +{ + DrawablesListIteratorType it = std::find(_drawables.begin(), _drawables.end(), pDrawable); + if (_drawables.end() != it) + { + return; + } + _drawables.push_back(pDrawable); + return; +} + +void +Material::RemovedFromDrawable(Drawable* pDrawable) +{ + DrawablesListIteratorType it = std::find(_drawables.begin(), _drawables.end(), pDrawable); + if (_drawables.end() == it) + { + return; + } + + const DrawablesListSizeType len = _drawables.size(); + std::swap(_drawables[len - 1], _drawables[it - _drawables.begin()]); + _drawables.resize(len - 1); + return; +} + +void +Material::TouchDrawables(void) +{ + const DrawablesListSizeType len = _drawables.size(); + for (DrawablesListSizeType i = 0; len > i; ++i) + { + _drawables[i]->InvalidateCache(); + } + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelMatrix4fPropertyHolder.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelMatrix4fPropertyHolder.cpp new file mode 100644 index 0000000..061fc2e --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelMatrix4fPropertyHolder.cpp @@ -0,0 +1,62 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelMatrix4fPropertyHolder.cpp + * @brief This file contains implementation of Matrix4fPropertyHolder class + * + */ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +Matrix4fPropertyHolder::Matrix4fPropertyHolder(void) +{ + __matrix = MatrixType::GetIdentity(); +} + +Matrix4fPropertyHolder::~Matrix4fPropertyHolder(void) +{ + +} + +const Matrix4fPropertyHolder::MatrixType& +Matrix4fPropertyHolder::Get() const +{ + return __matrix; +} + +void +Matrix4fPropertyHolder::Set(const float a11, const float a12, const float a13, const float a14, + const float a21, const float a22, const float a23, const float a24, + const float a31, const float a32, const float a33, const float a34, + const float a41, const float a42, const float a43, const float a44) +{ + __matrix.Set(a11, a12, a13, a14, a21, a22, a23, a24, a31, a32, a33, a34, a41, a42, a43, a44); + return; +} + +void +Matrix4fPropertyHolder::Set(const MatrixType& matrix) +{ + __matrix = matrix; + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelNode.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelNode.cpp new file mode 100644 index 0000000..c236c40 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelNode.cpp @@ -0,0 +1,221 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelNode.cpp + * @brief This file contains implementation of Node class + * + */ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +Node::Node(): + _pParent(null) +{ + _relatedTransform.value.Identity(); + _relatedTransform.invalid = false; + + _worldTransform.value.Identity(); + _worldTransform.invalid = false; + + _boundBox.value.Identity(); + _boundBox.invalid = false; + _boundBox.value.maximum.Set(1.0f, 1.0f, 1.0f); + _boundBox.value.minimum.Set(-1.0f, -1.0f, -1.0f); + + _transformType = TransformationType::RELATED; + _transformMatrix.Identity(); +} + +Node::~Node(void) +{ + +} + +void +Node::Visit(Visitor& visitor) +{ + visitor.OnNode(*this); + return; +} + +void +Node::ValidateLocal(void) +{ + if ((_transformType == TransformationType::RELATED) || !_pParent) + { + _relatedTransform.value = _transformMatrix; + } + else + { + _relatedTransform.value = _pParent->GetWorld().GetInversed() * _transformMatrix; + } + + _relatedTransform.invalid = false; + return; +} + +void +Node::ValidateWorld(void) +{ + if ((_transformType == TransformationType::WORLD) || !_pParent) + { + _worldTransform.value = _transformMatrix; + } + else + { + _worldTransform.value = _pParent->GetWorld() * _transformMatrix; + } + + _worldTransform.invalid = false; + return; +} + +void +Node::SetLocal(const Math::Matrix4f& arg) +{ + _transformType = TransformationType::RELATED; + _transformMatrix = arg; + _relatedTransform.invalid = true; + _worldTransform.invalid = true; + TouchParentBoundBox(); + return; +} + +void +Node::SetWorld(const Math::Matrix4f& arg) +{ + _transformType = TransformationType::WORLD; + _transformMatrix = arg; + _relatedTransform.invalid = true; + _worldTransform.invalid = true; + TouchParentBoundBox(); + return; +} + +void +Node::TouchParentBoundBox(void) +{ + if (_pParent) + { + _pParent->InvalidateBoundBox(); + } + return; +} + +const Math::Matrix4f& +Node::GetLocal(void) +{ + if (_transformType == TransformationType::RELATED) + { + return _transformMatrix; + } + + if (_relatedTransform.invalid) + { + ValidateLocal(); + } + return _relatedTransform.value; +} + +const Math::Matrix4f& +Node::GetWorld(void) +{ + if (_transformType == TransformationType::WORLD) + { + return _transformMatrix; + } + + if (_worldTransform.invalid) + { + ValidateWorld(); + } + return _worldTransform.value; +} + +const Aabb& +Node::GetBoundBox(void) +{ + return _boundBox.value; +} + +Aabb +Node::GetBoundBoxInParentSpace(void) +{ + return GetBoundBox().GetTransformed(GetLocal()); +} + +bool +Node::AttachedToParent(Group* pParent) +{ + if (null != _pParent) + { + return false; + } + _pParent = pParent; + + if (_transformType != TransformationType::WORLD) + { + _worldTransform.invalid = true; + } + + return true; +} + +bool +Node::RemoveFromParent(Group* pParent) +{ + if (pParent != _pParent) + { + return false; + } + + if (_transformType == TransformationType::WORLD) + { + _relatedTransform.invalid = true; + } + else + { + _worldTransform.invalid = true; + } + + _pParent = null; + return true; +} + +void +Node::ParentMoved(Group* pParent) +{ + if (pParent != _pParent) + { + return; + } + + if (_transformType == TransformationType::WORLD) + { + return; + } + + _worldTransform.invalid = true; + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelProperty.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelProperty.cpp new file mode 100644 index 0000000..fbc270d --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelProperty.cpp @@ -0,0 +1,45 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelProperty.cpp + * @brief This file contains implementation of Property class + * + */ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ +namespace EngineModel +{ + +Property::Property(void) +{ +} + +Property::~Property(void) +{ +} + +void +Property::Visit(PropertyVisitor& v) +{ + v.OnProperty(*this); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelPropertyHolderMaterial.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelPropertyHolderMaterial.cpp new file mode 100644 index 0000000..c2a752b --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelPropertyHolderMaterial.cpp @@ -0,0 +1,113 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelPropertyHolderMaterial.cpp + * @brief This file contains implementation of PropertyHolderMaterial class + * + */ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +PropertyHolderMaterial::PropertyHolderMaterial(void) +{ +} + +PropertyHolderMaterial::~PropertyHolderMaterial(void) +{ +} + +PropertyPtr +PropertyHolderMaterial::GetProperty(const std::string& name) +{ + const PropertyListSizeType len = _properties.size(); + for (PropertyListSizeType i = 0; len > i; ++i) + { + if (name == _properties[i].first) + { + return _properties[i].second; + } + } + return PropertyPtr(); +} + +PropertyPtr +PropertyHolderMaterial::GetProperty(PropertyListSizeType index) +{ + if (_properties.size() > index) + { + return _properties[index].second; + } + return PropertyPtr(); +} + +size_t +PropertyHolderMaterial::GetNumProperties(void) +{ + return _properties.size(); +} + +void +PropertyHolderMaterial::AddProperty(const std::string& name, PropertyPtr pProperty) +{ + const PropertyListSizeType len = _properties.size(); + for (PropertyListSizeType i = 0; len > i; ++i) + { + if (name == _properties[i].first) + { + _properties[i].second = pProperty; + return; + } + } + _properties.push_back(std::make_pair(name, pProperty)); + return; +} + +void +PropertyHolderMaterial::RemoveProperty(const std::string& name) +{ + const PropertyListSizeType len = _properties.size(); + for (PropertyListSizeType i = 0; len > i; ++i) + { + if (name == _properties[i].first) + { + _properties[i] = _properties[len - 1]; + _properties.resize(len - 1); + return; + } + } + return; +} + +void +PropertyHolderMaterial::RemoveProperty(PropertyListSizeType index) +{ + const PropertyListSizeType len = _properties.size(); + if (len <= index) + { + return; + } + _properties[index] = _properties[len - 1]; + _properties.resize(len - 1); + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelRenderTarget.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelRenderTarget.cpp new file mode 100644 index 0000000..814c8f3 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelRenderTarget.cpp @@ -0,0 +1,156 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelRenderTarget.cpp + * @brief This file contains implementation of RenderTarget class + * + */ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ +namespace EngineModel +{ + +RenderTarget::RenderTarget(): + _width(1), + _height(1) +{ +} + +RenderTarget::~RenderTarget(void) +{ + const unsigned int len = RenderTarget::Attachment::ATTACHMENT_MAX; + for (unsigned int i = 0; len > i; ++i) + { + if (_pTextures[i]) + { + _pTextures[i]->RemovedFromRenderTarget(this); + } + } + + if (__pCache) + { + __pCache->Die(); + } + return; +} + +void +RenderTarget::Visit(RenderTargetVisitor& v) +{ + v.OnRenderTarget(*this); + return; +} + +void +RenderTarget::AttachTexture2D(Attachment::Value attachment, Texture2DAttachmentPropertyPtr pTexture, size_t mipLevel) +{ + _pTextures[attachment] = pTexture; + _attachments[attachment].Set(System::GetImpl(pTexture), mipLevel); + pTexture->AttachedToRenderTarget(this); + if (__pCache) + { + __pCache->Invalidate(); + } + return; +} + +void +RenderTarget::AttachStub(Attachment::Value attachment, StubAttachmentPtr pStub) +{ + _pTextures[attachment] = pStub; + _attachments[attachment].Set(System::GetImpl(pStub)); + pStub->AttachedToRenderTarget(this); + if (__pCache) + { + __pCache->Invalidate(); + } + return; +} + +void +RenderTarget::Detach(Attachment::Value attachment) +{ + if (_pTextures[attachment]) + { + _pTextures[attachment]->RemovedFromRenderTarget(this); + } + System::Reset(_pTextures[attachment]); + + if (__pCache) + { + __pCache->Invalidate(); + } + return; +} + +RenderTarget::AttachInfo* +RenderTarget::GetAttachment(Attachment::Value attachment) +{ + if (!_pTextures[attachment]) + { + return null; + } + return &_attachments[attachment]; +} + +CachePtr +RenderTarget::GetCache(void) +{ + return __pCache; +} + +void +RenderTarget::SetCache(CachePtr pCache) +{ + if (__pCache) + { + __pCache->Die(); + } + __pCache = pCache; + return; +} + +unsigned int +RenderTarget::GetWidth(void) +{ + return _width; +} + +unsigned int +RenderTarget::GetHeight(void) +{ + return _height; +} + +void +RenderTarget::SetSize(unsigned int width, unsigned int height) +{ + _width = width; + _height = height; + if (__pCache) + { + __pCache->Invalidate(); + } + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelRenderTargetExternalRender.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelRenderTargetExternalRender.cpp new file mode 100644 index 0000000..624a453 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelRenderTargetExternalRender.cpp @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelRenderTargetExternalRender.cpp + * @brief This file contains implementation of RenderTargetExternalRender class + * + */ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +RenderTargetExternalRender::RenderTargetExternalRender(): + _pExternalRender(null) +{ +} + +RenderTargetExternalRender::~RenderTargetExternalRender(void) +{ +} + +void +RenderTargetExternalRender::Visit(RenderTargetVisitor& v) +{ + v.OnRenderTargetExternalRender(*this); + return; +} + +void +RenderTargetExternalRender::SetExternalRender(ExternalRenderInterface* pExternalRender) +{ + _pExternalRender = pExternalRender; + return; +} + +ExternalRenderInterface* +RenderTargetExternalRender::GetExternalRender(void) +{ + return _pExternalRender; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelShaderHolderProgramProperty.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelShaderHolderProgramProperty.cpp new file mode 100644 index 0000000..199b631 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelShaderHolderProgramProperty.cpp @@ -0,0 +1,52 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelShaderHolderProgramProperty.cpp + * @brief This file contains implementation of ShaderHolderProgramProperty class + * + */ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +ShaderHolderProgramProperty::ShaderHolderProgramProperty(ShaderPropertyPtr pVertexShader, ShaderPropertyPtr pFragmentShader): + _pVertexShader(pVertexShader), + _pFragmentShader(pFragmentShader) +{ +} + +ShaderHolderProgramProperty::~ShaderHolderProgramProperty(void) +{ +} + +ShaderPropertyPtr +ShaderHolderProgramProperty::GetShader(ShaderProperty::ShaderType::Value type) +{ + switch (type) + { + case ShaderProperty::ShaderType::VERTEX: + return _pVertexShader; + case ShaderProperty::ShaderType::FRAGMENT: + return _pFragmentShader; + } + return ShaderPropertyPtr(); +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelStringShaderProperty.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelStringShaderProperty.cpp new file mode 100644 index 0000000..d4f1dad --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelStringShaderProperty.cpp @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelStringShaderProperty.cpp + * @brief This file contains implementation of StringShaderProperty class + * + */ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +StringShaderProperty::StringShaderProperty(ShaderProperty::ShaderType::Value shaderType, const std::string& source): + _shaderType(shaderType), + _source(source) +{ +} + +StringShaderProperty::~StringShaderProperty(void) +{ +} + +const void* +StringShaderProperty::GetData(void) +{ + return _source.c_str(); +} + +std::string +StringShaderProperty::GetSource(void) const +{ + return _source; +} + +void +StringShaderProperty::SetSource(std::string source) +{ + _source = source; + if (System::GetImpl(GetCache()) != null) + { + GetCache()->Invalidate(); + } +} + +ShaderProperty::DataType::Value +StringShaderProperty::GetDataType(void) +{ + return ShaderProperty::DataType::SOURCE_CODE; +} + +ShaderProperty::ShaderType::Value +StringShaderProperty::GetShaderType(void) +{ + return _shaderType; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelStubAttachment.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelStubAttachment.cpp new file mode 100644 index 0000000..714c7ff --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelStubAttachment.cpp @@ -0,0 +1,75 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelStubAttachment.cpp + * @brief This file contains implementation of StubAttachment class + * + */ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +StubAttachment::StubAttachment(TextureProperty::InternalFormat::Value aInternalFormat): + _internalFormat(aInternalFormat) +{ +} + +StubAttachment::~StubAttachment(void) +{ + if (__pCache) + { + __pCache->Die(); + } +} + +CachePtr +StubAttachment::GetCache(void) +{ + return __pCache; +} + +void +StubAttachment::SetCache(CachePtr aCache) +{ + if (__pCache) + { + __pCache->Die(); + } + __pCache = aCache; + return; +} + +void +StubAttachment::TouchCache(void) +{ + if (__pCache) + { + __pCache->Invalidate(); + } + return; +} + +TextureProperty::InternalFormat::Value +StubAttachment::GetInternalFormat(void) +{ + return _internalFormat; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DAttachmentProperty.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DAttachmentProperty.cpp new file mode 100644 index 0000000..b65b614 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DAttachmentProperty.cpp @@ -0,0 +1,153 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelTexture2DAttachmentProperty.cpp + * @brief This file contains implementation of Texture2DAttachmentProperty class + * + */ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +void +Texture2dAttachmentProperty::Visit(PropertyVisitor& v) +{ + v.OnTexture2DAttachmentProperty(*this); + return; +} + +Texture2dAttachmentProperty::Texture2dAttachmentProperty( + bool generateMipmaps, + InternalFormat::Value internalFormat, + DataFormat::Value dataFormat, + DataType::Value dataType, + FilterType::Value minFilter, + FilterType::Value magFilter, + WrapType::Value wrapS, + WrapType::Value wrapT): + _generateMipmaps(generateMipmaps), + _internalFormat(internalFormat), + _dataFormat(dataFormat), + _dataType(dataType), + _minFilter(minFilter), + _magFilter(magFilter), + _wrapS(wrapS), + _wrapT(wrapT) +{ + +} + +Texture2dAttachmentProperty::~Texture2dAttachmentProperty(void) +{ + if (__pCache) + { + __pCache->Die(); + } +} + +void +Texture2dAttachmentProperty::SetMipmapGeneration(bool generateMipmaps) +{ + _generateMipmaps = generateMipmaps; + return; +} + +bool +Texture2dAttachmentProperty::GetGenerateMipmaps(void) const +{ + return _generateMipmaps; +} + +TextureProperty::InternalFormat::Value +Texture2dAttachmentProperty::GetInternalFormat(void) const +{ + return _internalFormat; +} + +TextureProperty::DataFormat::Value +Texture2dAttachmentProperty::GetDataFormat(void) const +{ + return _dataFormat; +} + +TextureProperty::DataType::Value +Texture2dAttachmentProperty::GetDataType(void) const +{ + return _dataType; +} + +TextureProperty::FilterType::Value +Texture2dAttachmentProperty::GetMinFilter(void) const +{ + return _minFilter; +} + +TextureProperty::FilterType::Value +Texture2dAttachmentProperty::GetMagFilter(void) const +{ + return _magFilter; +} + +TextureProperty::WrapType::Value +Texture2dAttachmentProperty::GetWrapS(void) const +{ + return _wrapS; +} + +TextureProperty::WrapType::Value +Texture2dAttachmentProperty::GetWrapT(void) const +{ + return _wrapT; +} + +TextureProperty::WrapType::Value +Texture2dAttachmentProperty::GetWrapR(void) const +{ + return WrapType::CLAMP_TO_EDGE; +} + +CachePtr +Texture2dAttachmentProperty::GetCache(void) +{ + return __pCache; +} + +void +Texture2dAttachmentProperty::SetCache(CachePtr pCache) +{ + if (__pCache) + { + __pCache->Die(); + } + __pCache = pCache; + return; +} + +void +Texture2dAttachmentProperty::TouchCache(void) +{ + if (__pCache) + { + __pCache->Invalidate(); + } + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DProperty.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DProperty.cpp new file mode 100644 index 0000000..5b4c2c1 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelTexture2DProperty.cpp @@ -0,0 +1,75 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelTexture2DProperty.cpp + * @brief This file contains implementation of Texture2DProperty class + * + */ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +void +Texture2dProperty::Visit(PropertyVisitor& v) +{ + v.OnTexture2DProperty(*this); + return; +} + +Texture2dProperty::Texture2dProperty(void) +{ +} + +Texture2dProperty::~Texture2dProperty(void) +{ + if (__pCache) + { + __pCache->Die(); + } +} + +CachePtr +Texture2dProperty::GetCache(void) +{ + return __pCache; +} + +void +Texture2dProperty::SetCache(CachePtr pCache) +{ + if (__pCache) + { + __pCache->Die(); + } + __pCache = pCache; + return; +} + +void +Texture2dProperty::TouchCache(void) +{ + if (__pCache) + { + __pCache->Invalidate(); + } + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelTextureAttachment.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelTextureAttachment.cpp new file mode 100644 index 0000000..b2076ea --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelTextureAttachment.cpp @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelTextureAttachment.cpp + * @brief This file contains implementation of TextureAttachment class + * + */ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +bool +TextureAttachment::AttachedToRenderTarget(RenderTarget* pRenderTarget) +{ + RenderTargetListType::iterator it = std::find(_targets.begin(), _targets.end(), pRenderTarget); + if (_targets.end() != it) + { + return false; + } + + _targets.push_back(pRenderTarget); + return true; +} + +bool +TextureAttachment::RemovedFromRenderTarget(RenderTarget* pRenderTarget) +{ + RenderTargetListType::iterator it = std::find(_targets.begin(), _targets.end(), pRenderTarget); + if (_targets.end() == it) + { + return false; + } + + const RenderTargetListSizeType index = it - _targets.begin(); + const RenderTargetListSizeType len = _targets.size(); + + std::swap(_targets[index], _targets[len - 1]); + _targets.resize(len - 1); + + return true; +} + +TextureAttachment::RenderTargetListSizeType +TextureAttachment::GetNumRenderTargets(void) +{ + return _targets.size(); +} + +RenderTarget* +TextureAttachment::GetRenderTarget(RenderTargetListSizeType index) +{ + if (index >= _targets.size()) + { + return null; + } + return _targets[index]; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelTextureProperty.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelTextureProperty.cpp new file mode 100644 index 0000000..ca16a4a --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelTextureProperty.cpp @@ -0,0 +1,44 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelTextureProperty.cpp + * @brief This file contains implementation of TextureProperty class + * + */ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +void +TextureProperty::Visit(PropertyVisitor& v) +{ + v.OnTextureProperty(*this); + return; +} + +TextureProperty::TextureProperty(void) +{ +} + +TextureProperty::~TextureProperty(void) +{ +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelVector2fPropertyHolder.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelVector2fPropertyHolder.cpp new file mode 100644 index 0000000..e6decd0 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelVector2fPropertyHolder.cpp @@ -0,0 +1,58 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelVector2fPropertyHolder.cpp + * @brief This file contains implementation of Vector2fPropertyHolder class + * + */ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +Vector2fPropertyHolder::Vector2fPropertyHolder(void) +{ + __vector = VectorType(0.0f, 0.0f); +} + +Vector2fPropertyHolder::~Vector2fPropertyHolder(void) +{ +} + +const Vector2fPropertyHolder::VectorType& +Vector2fPropertyHolder::Get() const +{ + return __vector; +} + +void +Vector2fPropertyHolder::Set(float x, float y) +{ + __vector.Set(x, y); + return; +} + +void +Vector2fPropertyHolder::Set(const VectorType& vector) +{ + __vector = vector; + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelVector3fPropertyHolder.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelVector3fPropertyHolder.cpp new file mode 100644 index 0000000..f91a5c6 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelVector3fPropertyHolder.cpp @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelVector3fPropertyHolder.cpp + * @brief This file contains implementation of Vector3fPropertyHolder class + * + */ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +Vector3fPropertyHolder::Vector3fPropertyHolder(void) +{ + __vector = VectorType(0.0f, 0.0f, 0.0f); +} + +Vector3fPropertyHolder::~Vector3fPropertyHolder(void) +{ + +} + +const Vector3fPropertyHolder::VectorType& +Vector3fPropertyHolder::Get() const +{ + return __vector; +} + +void +Vector3fPropertyHolder::Set(float x, float y, float z) +{ + __vector.Set(x, y, z); + return; +} + +void +Vector3fPropertyHolder::Set(const VectorType& vector) +{ + __vector = vector; + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelVector4fPropertyHolder.cpp b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelVector4fPropertyHolder.cpp new file mode 100644 index 0000000..38f7751 --- /dev/null +++ b/src/ui/effects/renderer/engine-model/FUiEffects_RendererEngineModelVector4fPropertyHolder.cpp @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererEngineModelVector4fPropertyHolder.cpp + * @brief This file contains implementation of Vector4fPropertyHolder class + * + */ + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel +{ + +Vector4fPropertyHolder::Vector4fPropertyHolder(void) +{ + __vector = VectorType(0.0f, 0.0f, 0.0f, 0.0f); +} + +Vector4fPropertyHolder::~Vector4fPropertyHolder(void) +{ + +} + +const Vector4fPropertyHolder::VectorType& +Vector4fPropertyHolder::Get() const +{ + return __vector; +} + +void +Vector4fPropertyHolder::Set(float x, float y, float z, float w) +{ + __vector.Set(x, y, z, w); + return; +} + +void +Vector4fPropertyHolder::Set(const VectorType& vector) +{ + __vector = vector; + return; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::EngineModel diff --git a/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRender.cpp b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRender.cpp new file mode 100644 index 0000000..037d269 --- /dev/null +++ b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRender.cpp @@ -0,0 +1,493 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRender.cpp + * @brief Implementation of class for rendering scene tree + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +Render::Render(void) + : __worldViewProjection() + , __externalRenderTargets() + , __drawables() + , __blendDrawables() + , __pCamera(null) + , __findCameraPass(false) + , __caches() + , __deadCaches() + , __alphaBlendSource(GL_SRC_ALPHA) + , __alphaBlendDestination(GL_ONE_MINUS_SRC_ALPHA) + , __depthTestState(false) + , __currentFrameBuffer(0) +{ +} + +Render::~Render(void) +{ + const CacheListSizeType len = __caches.size(); + for (CacheListSizeType i = 0; len > i; ++i) + { + __caches[i]->InternalDestroyCache(); + } +} + +void +Render::SetDefaultDepthTestState(bool aIsEnable) +{ + __depthTestState = aIsEnable; + return; +} + +void +Render::Draw(Tizen::Ui::Effects::_Renderer::EngineModel::Node& root, EngineModel::Camera& camera) +{ + InternalKillDeadCaches(); + + __pCamera = &camera; + if (null == __pCamera) + { + ThrowJmp("Render::draw: Can`t render, no active camera"); + } + + InternalPreDraw(); + + InternalCollectInfo(root); + + InternalDraw(); + + InternalPostDraw(); + return; +} + +void +Render::Draw(Tizen::Ui::Effects::_Renderer::EngineModel::Node& root) +{ + InternalFindCameras(root); + + Draw(root, *__pCamera); + return; +} + +void +Render::OnGroup(Tizen::Ui::Effects::_Renderer::EngineModel::Group& prop) +{ + const size_t len = prop.ChildrenCount(); + for (size_t i = 0; len > i; ++i) + { + prop.GetChild(i)->Visit(*this); + } + return; +} + +void +Render::OnDrawable(Tizen::Ui::Effects::_Renderer::EngineModel::Drawable& prop) +{ + EngineModel::Cache* pCache = System::GetImpl(prop.GetCache()); + if (!pCache) + { + BuildCache(prop); + + pCache = System::GetImpl(prop.GetCache()); + if (!pCache) { return; } + } + + RenderDrawableCache* renderCache = dynamic_cast(pCache); + if (renderCache == null) + { + return; + } + + __drawables.push_back(renderCache); + + + const RenderDrawableCache::ExternalTexturesListSizeType numExternalTextures = renderCache->NumExternalTextures(); + + for (RenderDrawableCache::ExternalTexturesListSizeType i = 0; numExternalTextures > i; ++i) + { + + EngineModel::TextureAttachment* attachment = renderCache->GetExternalTexture(i); + if (attachment == null) + { + return; + } + + const EngineModel::TextureAttachment::RenderTargetListSizeType numRenderTargets = attachment->GetNumRenderTargets(); + + for (Tizen::Ui::Effects::_Renderer::EngineModel::TextureAttachment::RenderTargetListSizeType rt = 0; numRenderTargets > rt; ++rt) + { + EngineModel::RenderTargetExternalRender* pRenderTarget = static_cast(attachment->GetRenderTarget(rt)); + if (pRenderTarget == null) + { + return; + } + + RenderTargetExternalRenderCache* cache = static_cast(System::GetImpl(pRenderTarget->GetCache())); + if (!cache) + { + BuildCache(*pRenderTarget); + + cache = static_cast(System::GetImpl(pRenderTarget->GetCache())); + } + __externalRenderTargets[cache] = cache; + } + } + + return; +} + +void +Render::ManageCache(RenderCacheImplPtr pCache) +{ + __caches.push_back(pCache); + pCache->__cacheIndex = __caches.size() - 1; + return; +} + +void +Render::KillCache(RenderCacheImpl* pCache) +{ + __deadCaches.push_back(pCache); + return; +} + +void +Render::InternalKillDeadCaches(void) +{ + const DeadCacheListSizeType len = __deadCaches.size(); + for (DeadCacheListSizeType i = 0; len > i; ++i) + { + __deadCaches[i]->InternalDestroyCache(); + const size_t cacheIndex = __deadCaches[i]->__cacheIndex; + const CacheListSizeType cachesSize = __caches.size(); + __caches[cacheIndex] = __caches[cachesSize - 1]; + __caches[cacheIndex]->__cacheIndex = cacheIndex; + __caches.resize(cachesSize - 1); + } + __deadCaches.clear(); + return; +} + +void +Render::ContextLost(void) +{ + const CacheListSizeType len = __caches.size(); + for (CacheListSizeType i = 0; len > i; ++i) + { + __caches[i]->InternalDropCache(); + } + return; +} + +namespace +{ + struct CameraFinder: public EngineModel::Visitor + { + EngineModel::Camera* pCamera; + CameraFinder(): pCamera(null) {} + + virtual void + OnGroup(Tizen::Ui::Effects::_Renderer::EngineModel::Group& prop) + { + const size_t len = prop.ChildrenCount(); + for (size_t i = 0; len > i; ++i) + { + prop.GetChild(i)->Visit(*this); + } + return; + } + + virtual void + OnCamera(Tizen::Ui::Effects::_Renderer::EngineModel::Camera& prop) + { + pCamera = ∝ + return; + } + }; +} + +void +Render::InternalFindCameras(Tizen::Ui::Effects::_Renderer::EngineModel::Node& prop) +{ + __pCamera = null; + CameraFinder cameraFinder; + prop.Visit(cameraFinder); + __pCamera = cameraFinder.pCamera; + return; +} + +void +Render::InternalPreDraw(void) +{ + __drawables.clear(); + __blendDrawables.clear(); + __externalRenderTargets.clear(); + return; +} + +void +Render::InternalCollectInfo(Tizen::Ui::Effects::_Renderer::EngineModel::Node& prop) +{ + prop.Visit(*this); + return; +} + +void +Render::InternalDraw(void) +{ + Math::Vector2f minPos = __pCamera->GetViewportMin(); + Math::Vector2f maxPos = __pCamera->GetViewportMax(); + glViewport(static_cast(minPos.X()), static_cast(minPos.Y()), static_cast(maxPos.X()), static_cast(maxPos.Y())); + + Math::Matrix4f cameraWorld(__pCamera->GetWorld()); + Math::Matrix4f cameraView(cameraWorld.GetInversed()); //__pCamera world matrix is inverted view matrix + Math::Matrix4f projection(__pCamera->GetProj()); + Math::Matrix4f viewProjection = projection * cameraView; + if (__depthTestState) + { + glEnable(GL_DEPTH_TEST); + } + else + { + glDisable(GL_DEPTH_TEST); + } + + //solid Draw + const size_t len = __drawables.size(); + for (size_t i = 0; len > i; ++i) + { + __worldViewProjection = viewProjection * __drawables[i]->GetWorld(); + __worldViewProjection.Transpose(); + if (static_cast(__drawables[i])->HasAlphaBlend(this)) + { + glEnable(GL_BLEND); + } + else + { + glDisable(GL_BLEND); + } + + static_cast(__drawables[i])->Draw(this); + } + + return; +} + +void +Render::InternalPostDraw(void) +{ + return; +} + +void +Render::BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::Drawable& prop) +{ + RenderCachePtr cachePtr(new (std::nothrow) RenderDrawableCache(this, &prop)); + _TryJmp(GetImpl(cachePtr) != null, E_OUT_OF_MEMORY, "cache = null"); + + prop.SetCache(cachePtr); + + cachePtr->Validate(this); + + ManageCache(cachePtr); + return; +} + +void +Render::BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::VertexBuffer& prop) +{ + RenderCachePtr cachePtr(new (std::nothrow) SolidVertexBufferCache(this, &prop)); + _TryJmp(GetImpl(cachePtr) != null, E_OUT_OF_MEMORY, "cache = null"); + + prop.SetCache(cachePtr); + cachePtr->Validate(this); + ManageCache(cachePtr); + return; +} + +void +Render::BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::IndexBuffer& prop) +{ + RenderCachePtr cachePtr(new (std::nothrow) IndexBufferCache(this, &prop)); + _TryJmp(GetImpl(cachePtr) != null, E_OUT_OF_MEMORY, "cache = null"); + + prop.SetCache(cachePtr); + cachePtr->Validate(this); + ManageCache(cachePtr); + return; +} + +void +Render::BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::CompositeVertexBuffer& prop) +{ + RenderCachePtr cachePtr(new (std::nothrow) CompositeVertexBufferCache(this, &prop)); + _TryJmp(GetImpl(cachePtr) != null, E_OUT_OF_MEMORY, "pCache = null"); + + prop.SetCache(cachePtr); + cachePtr->Validate(this); + ManageCache(cachePtr); + return; +} + +void +Render::BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::PartVertexBuffer& prop) +{ + RenderCachePtr cachePtr(new (std::nothrow) PartVertexBufferCache(this, &prop)); + _TryJmp(GetImpl(cachePtr) != null, E_OUT_OF_MEMORY, "pCache = null"); + + prop.SetCache(cachePtr); + cachePtr->Validate(this); + ManageCache(cachePtr); + return; +} + +void +Render::BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::Texture2dProperty& prop, GLuint stage) +{ + RenderCachePtr cachePtr(new (std::nothrow) RenderTexture2dCache(this, &prop)); + _TryJmp(GetImpl(cachePtr) != null, E_OUT_OF_MEMORY, "pCache = null"); + + prop.SetCache(cachePtr); + cachePtr.staticCast()->Validate(this, stage); + ManageCache(cachePtr); + return; +} + +void +Render::BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::ShaderProperty& prop) +{ + RenderCachePtr cachePtr(new (std::nothrow) RenderShaderCache(this, &prop)); + _TryJmp(GetImpl(cachePtr) != null, E_OUT_OF_MEMORY, "pCache = null"); + + prop.SetCache(cachePtr); + cachePtr->Validate(this); + ManageCache(cachePtr); + return; +} + +void +Render::BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::ProgramProperty& prop) +{ + RenderCachePtr cachePtr(new (std::nothrow) RenderProgramCache(this, &prop)); + _TryJmp(GetImpl(cachePtr) != null, E_OUT_OF_MEMORY, "pCache = null"); + + prop.SetCache(cachePtr); + cachePtr->Validate(this); + ManageCache(cachePtr); + return; +} + +void +Render::BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::RenderTargetExternalRender& prop) +{ + RenderCachePtr cachePtr(new (std::nothrow) RenderTargetExternalRenderCache(this, &prop)); + _TryJmp(GetImpl(cachePtr) != null, E_OUT_OF_MEMORY, "pCache = null"); + + prop.SetCache(cachePtr); + cachePtr->Validate(this); + ManageCache(cachePtr); + return; +} + +void +Render::BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::Texture2dAttachmentProperty& prop, GLuint stage) +{ + RenderCachePtr cachePtr(new (std::nothrow) Texture2dAttachmentCache(this, &prop)); + _TryJmp(GetImpl(cachePtr) != null, E_OUT_OF_MEMORY, "pCache = null"); + + prop.SetCache(cachePtr); + cachePtr.staticCast()->Validate(this, stage); + ManageCache(cachePtr); + return; +} + +void +Render::BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::StubAttachment& o) +{ + RenderCachePtr cachePtr(new (std::nothrow) StubAttachmentCache(this, &o)); + _TryJmp(GetImpl(cachePtr) != null, E_OUT_OF_MEMORY, "pCache = null"); + + o.SetCache(cachePtr); + cachePtr->Validate(this); + ManageCache(cachePtr); + return; +} + +void +Render::BuildCache(Tizen::Ui::Effects::_Renderer::EngineModel::AlphaBlendProperty& prop) +{ + RenderCachePtr cachePtr(new (std::nothrow) RenderAlphaBlendCache(this, &prop)); + _TryJmp(GetImpl(cachePtr) != null, E_OUT_OF_MEMORY, "pCache = null"); + + prop.SetCache(cachePtr); + cachePtr->Validate(this); + ManageCache(cachePtr); + return; +} + +RenderCommandPtr +Render::GetDefaultRenderCommand(const RenderProgramCache::UniformListValueType* pInfo) +{ + if (pInfo->second == "WorldViewProjection") + { + RenderCommandPtr result = RenderCommandPtr(new (std::nothrow) SetWorldViewProjection(pInfo->first.location)); + _TryJmp(System::GetImpl(result) != null, E_OUT_OF_MEMORY, "GetDefaultRenderCommand = null"); + + return result; + } + + return RenderCommandPtr(); +} + +SetWorldViewProjection::SetWorldViewProjection(GLuint location): + __location(location) +{ +} + +void +SetWorldViewProjection::Apply(Render* pRender) +{ + glUniformMatrix4fv(__location, 1, GL_FALSE, pRender->GetWorldViewProjection().data[0].data); + return; +} + +const Math::Matrix4f& +Render::GetWorldViewProjection(void) +{ + return __worldViewProjection; +} + +}}}}} //Tizen::Ui::Effects::_Renderer::GraphicsEngine diff --git a/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderBufferCache.cpp b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderBufferCache.cpp new file mode 100644 index 0000000..48ba004 --- /dev/null +++ b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderBufferCache.cpp @@ -0,0 +1,473 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderBufferCache.cpp + * @brief Implementation of class for buffer caching + * + */ + + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +IBufferCache::IBufferCache(Render* pRender) + : RenderCache(pRender) + , _bufferId(static_cast(0)) + , _dataType(static_cast(0)) +{ +} + +IBufferCache::~IBufferCache() {} + +void +IBufferCache::DropCache(void) +{ + _bufferId = 0; + return; +} + +void +IBufferCache::DestroyCache(void) +{ + if (_bufferId) + { + glDeleteBuffers(1, &_bufferId); + } + + return; +} + +GLenum +IBufferCache::GetGlUsage(Tizen::Ui::Effects::_Renderer::EngineModel::SolidBufferStrategy::BufferUsage::Value usage) +{ + switch (usage) + { + case EngineModel::SolidBufferStrategy::BufferUsage::STREAM_DRAW: + return GL_STREAM_DRAW; + case EngineModel::SolidBufferStrategy::BufferUsage::STREAM_READ: + return GL_STREAM_DRAW; + case EngineModel::SolidBufferStrategy::BufferUsage::STREAM_COPY: + return GL_STREAM_DRAW; + case EngineModel::SolidBufferStrategy::BufferUsage::STATIC_DRAW: + return GL_STATIC_DRAW; + case EngineModel::SolidBufferStrategy::BufferUsage::STATIC_READ: + return GL_STATIC_DRAW; + case EngineModel::SolidBufferStrategy::BufferUsage::STATIC_COPY: + return GL_STATIC_DRAW; + case EngineModel::SolidBufferStrategy::BufferUsage::DYNAMIC_DRAW: + return GL_DYNAMIC_DRAW; + case EngineModel::SolidBufferStrategy::BufferUsage::DYNAMIC_READ: + return GL_DYNAMIC_DRAW; + case EngineModel::SolidBufferStrategy::BufferUsage::DYNAMIC_COPY: + return GL_DYNAMIC_DRAW; + } + return GL_STATIC_DRAW; +} + +GLenum +IBufferCache::GetGlDataType(Tizen::Ui::Effects::_Renderer::EngineModel::TypedBufferStrategy::DataType::Value dataType) +{ + switch (dataType) + { + case EngineModel::TypedBufferStrategy::DataType::BYTE: + return GL_BYTE; + case EngineModel::TypedBufferStrategy::DataType::UNSIGNED_BYTE: + return GL_UNSIGNED_BYTE; + case EngineModel::TypedBufferStrategy::DataType::SHORT: + return GL_SHORT; + case EngineModel::TypedBufferStrategy::DataType::UNSIGNED_SHORT: + return GL_UNSIGNED_SHORT; + case EngineModel::TypedBufferStrategy::DataType::INT: + return GL_INT; + case EngineModel::TypedBufferStrategy::DataType::UNSIGNED_INT: + return GL_UNSIGNED_INT; + case EngineModel::TypedBufferStrategy::DataType::FLOAT: + return GL_FLOAT; + case EngineModel::TypedBufferStrategy::DataType::DOUBLE: + ThrowJmp("GL_DOUBLE is not allowed as buffer data format undel GLES2"); + break; + } + return GL_FLOAT; +} + +GLsizei +IBufferCache::GetGlDataTypeSize(Tizen::Ui::Effects::_Renderer::EngineModel::TypedBufferStrategy::DataType::Value dataType) +{ + switch (dataType) + { + case EngineModel::TypedBufferStrategy::DataType::BYTE: + case EngineModel::TypedBufferStrategy::DataType::UNSIGNED_BYTE: + return 1; + case EngineModel::TypedBufferStrategy::DataType::SHORT: + case EngineModel::TypedBufferStrategy::DataType::UNSIGNED_SHORT: + return 2; + case EngineModel::TypedBufferStrategy::DataType::DOUBLE: + return 8; + case EngineModel::TypedBufferStrategy::DataType::INT: + case EngineModel::TypedBufferStrategy::DataType::UNSIGNED_INT: + case EngineModel::TypedBufferStrategy::DataType::FLOAT: + default: + return 4; + } +} + +GLenum +IndexBufferCache::GetGlPrimitiveType(Tizen::Ui::Effects::_Renderer::EngineModel::IndexBuffer::PrimitiveType::Value primitiveType) +{ + switch (primitiveType) + { + case EngineModel::IndexBuffer::PrimitiveType::POINTS: + return GL_POINTS; + case EngineModel::IndexBuffer::PrimitiveType::LINE_STRIP: + return GL_LINE_STRIP; + case EngineModel::IndexBuffer::PrimitiveType::LINE_LOOP: + return GL_LINE_LOOP; + case EngineModel::IndexBuffer::PrimitiveType::LINES: + return GL_LINES; + case EngineModel::IndexBuffer::PrimitiveType::TRIANGLE_STRIP: + return GL_TRIANGLE_STRIP; + case EngineModel::IndexBuffer::PrimitiveType::TRIANGLE_FAN: + return GL_TRIANGLE_FAN; + case EngineModel::IndexBuffer::PrimitiveType::TRIANGLES: + return GL_TRIANGLES; + case EngineModel::IndexBuffer::PrimitiveType::QUAD_STRIP: + ThrowJmp("GL_QUAD_STRIP - is anasseptable as geometry type under GLES2"); + // fall through + case EngineModel::IndexBuffer::PrimitiveType::QUADS: + ThrowJmp("GL_QUADS - is anasseptable as geometry type under GLES2"); + // fall through + case EngineModel::IndexBuffer::PrimitiveType::POLYGON: + ThrowJmp("GL_POLYGON - is anasseptable as geometry type under GLES2"); + // fall through + } + return GL_POINTS; +} + +IndexBufferCache::IndexBufferCache(Render* pRender, EngineModel::IndexBuffer* pBuffer) + : IBufferCache(pRender) + , __elementsCount(static_cast(0)) + , __primitiveType(static_cast(0)) + , __pBuffer(pBuffer) +{ +} + +IndexBufferCache::~IndexBufferCache() +{} + +void +IndexBufferCache::DestroyCache(void) +{ + if (__pBuffer) + { + __pBuffer->SetCache(IndexBufferCachePtr()); + } + + __pBuffer = null; + IBufferCache::DestroyCache(); + + return; +} + +void +IndexBufferCache::Die(void) +{ + __pBuffer = null; + IBufferCache::Die(); + return; +} + +void +IndexBufferCache::Validate(Render*) +{ + if (!_invalid) + { + return; + } + _dataType = GetGlDataType(__pBuffer->GetDataType()); + __elementsCount = static_cast(__pBuffer->GetSize() / GetGlDataTypeSize(__pBuffer->GetDataType())); + __primitiveType = GetGlPrimitiveType(__pBuffer->GetPrimitiveType()); + void* pData = __pBuffer->GetData(); + if (!pData) + { + ThrowJmp("IndexBufferCache::validate: data buffer is null"); + } + if (!_bufferId) + { + glGenBuffers(1, &_bufferId); + } + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _bufferId); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, __pBuffer->GetSize(), pData, GetGlUsage(__pBuffer->GetUsage())); + _invalid = false; + return; +} + +void +IndexBufferCache::DrawElements(Render* pRender) +{ + if (_invalid) + { + Validate(pRender); + } + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _bufferId); + glDrawElements(__primitiveType, __elementsCount, _dataType, 0); + return; +} + +SolidVertexBufferCache::SolidVertexBufferCache(Render *pRender, EngineModel::VertexBuffer* pBuffer) + : VertexBufferCache(pRender) + , __componentsPerElement(static_cast(0)) + , __pBuffer(pBuffer) +{ +} + +SolidVertexBufferCache::~SolidVertexBufferCache() +{ } + +void +SolidVertexBufferCache::DestroyCache(void) +{ + if (__pBuffer) + { + __pBuffer->SetCache(SolidVertexBufferCachePtr()); + } + + __pBuffer = null; + IBufferCache::DestroyCache(); + + return; +} + +void +SolidVertexBufferCache::Die(void) +{ + __pBuffer = null; + IBufferCache::Die(); + return; +} + +void +SolidVertexBufferCache::Validate(Render*) +{ + if (Valid()) + { + return; + } + __componentsPerElement = static_cast(__pBuffer->GetComponentsPerElement()); + _dataType = GetGlDataType(__pBuffer->GetDataType()); + void* pData = __pBuffer->GetData(); + if (!pData) + { + ThrowJmp("SolidVertexBufferCache::validate: data buffer is null"); + } + if (!_bufferId) + { + glGenBuffers(1, &_bufferId); + } + glBindBuffer(GL_ARRAY_BUFFER, _bufferId); + glBufferData(GL_ARRAY_BUFFER, __pBuffer->GetSize(), pData, GetGlUsage(__pBuffer->GetUsage())); + _invalid = false; + return; +} + +void +SolidVertexBufferCache::BindToAttrib(Render* pRender, GLuint index) +{ + if (_invalid) + { + Validate(pRender); + } + glBindBuffer(GL_ARRAY_BUFFER, _bufferId); + glVertexAttribPointer(index, __componentsPerElement, _dataType, GL_FALSE, 0, 0); + return; +} + +void +SolidVertexBufferCache::BindAsVertices(Render* pRender) +{ + ThrowJmp("SolidVertexBufferCache::bindAsVertices is anasseptable under GLES2"); + return; +} + +void +SolidVertexBufferCache::BindAsColor(Render* pRender) +{ + ThrowJmp("SolidVertexBufferCache::bindAsColor is anasseptable under GLES2"); + return; +} + +void +SolidVertexBufferCache::BindAsTexCoord(Render* pRender, GLuint stage) +{ + ThrowJmp("SolidVertexBufferCache::bindAsTexCoord is anasseptable under GLES2"); + return; +} + +PartVertexBufferCache::PartVertexBufferCache(Render *pRender, EngineModel::PartVertexBuffer* pBuffer) + : VertexBufferCache(pRender) + , __componentsPerElement(static_cast(0)) + , __stride(static_cast(0)) + , __pOffset(null) + , __pBuffer(pBuffer) +{ +} + +PartVertexBufferCache::~PartVertexBufferCache() {} + +void +PartVertexBufferCache::DestroyCache(void) +{ + if (__pBuffer) + { + __pBuffer->SetCache(PartVertexBufferCachePtr()); + } + + __pBuffer = null; + IBufferCache::DestroyCache(); + + return; +} + +void +PartVertexBufferCache::Die(void) +{ + __pBuffer = null; + IBufferCache::Die(); + return; +} + +void +PartVertexBufferCache::Validate(Render*) +{ + if (Valid()) + { + return; + } + EngineModel::CompositeVertexBufferPtr composite = __pBuffer->GetCompositeBuffer(); + if (!composite) + { + ThrowJmp("PartVertexBufferCache::validate: no composite buffer in part buffer"); + } + __pOffset = reinterpret_cast(__pBuffer->GetOffset()); + __stride = static_cast(__pBuffer->GetStride()); + __componentsPerElement = static_cast(__pBuffer->GetComponentsPerElement()); + _dataType = GetGlDataType(composite->GetDataType()); + _invalid = false; + return; +} + +void +PartVertexBufferCache::BindToAttrib(Render* pRender, GLuint index) +{ + if (_invalid) + { + Validate(pRender); + } + glVertexAttribPointer(index, __componentsPerElement, _dataType, GL_FALSE, __stride, __pOffset); + return; +} + +void +PartVertexBufferCache::BindAsVertices(Render* pRender) +{ + ThrowJmp("PartVertexBufferCache::bindAsVertices is anasseptable under GLES2"); + return; +} + +void +PartVertexBufferCache::BindAsColor(Render* pRender) +{ + ThrowJmp("PartVertexBufferCache::bindAsColor is anasseptable under GLES2"); + return; +} + +void +PartVertexBufferCache::BindAsTexCoord(Render* pRender, GLuint stage) +{ + ThrowJmp("PartVertexBufferCache::bindAsColor is anasseptable under GLES2"); + return; +} + +CompositeVertexBufferCache::CompositeVertexBufferCache(Render* pRender, EngineModel::CompositeVertexBuffer* pBuffer): + IBufferCache(pRender), __pBuffer(pBuffer) +{ +} + +CompositeVertexBufferCache::~CompositeVertexBufferCache(void) +{ +} + +void +CompositeVertexBufferCache::DestroyCache(void) +{ + if (__pBuffer) + { + __pBuffer->SetCache(CompositeVertexBufferCachePtr()); + } + + __pBuffer = null; + IBufferCache::DestroyCache(); + + return; +} + +void +CompositeVertexBufferCache::Die(void) +{ + __pBuffer = null; + IBufferCache::Die(); + return; +} + +void +CompositeVertexBufferCache::Validate(Render*) +{ + if (Valid()) + { + return; + } + _dataType = GetGlDataType(__pBuffer->GetDataType()); + void* pData = __pBuffer->GetData(); + if (!pData) + { + ThrowJmp("CompositeVertexBufferCache::validate: data buffer is null"); + } + if (!_bufferId) + { + glGenBuffers(1, &_bufferId); + } + glBindBuffer(GL_ARRAY_BUFFER, _bufferId); + glBufferData(GL_ARRAY_BUFFER, __pBuffer->GetSize(), pData, GetGlUsage(__pBuffer->GetUsage())); + _invalid = false; + return; +} + +void +CompositeVertexBufferCache::Bind(Render* pRender) +{ + if (_invalid) + { + Validate(pRender); + } + glBindBuffer(GL_ARRAY_BUFFER, _bufferId); + return; +} + +}}}}} // Tizen::Ui::Effects::_Renderer::GraphicsEngine diff --git a/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderCache.cpp b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderCache.cpp new file mode 100644 index 0000000..11d6a8a --- /dev/null +++ b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderCache.cpp @@ -0,0 +1,58 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderCache.cpp + * @brief Implementation of class for rendering cache + * + */ + + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +void +RenderCacheImpl::InternalForceToDie(void) +{ + if (__pCreator) + { + __pCreator->KillCache(this); + } + __pCreator = null; + return; +} + +void +RenderCacheImpl::InternalDestroyCache(void) +{ + __pCreator = null; + DestroyCache(); + return; +} + +void +RenderCacheImpl::InternalDropCache(void) +{ + DropCache(); + InvalidateImpl(); + return; +} + +}}}}} // Tizen::Ui::Effects::_Renderer::GraphicsEngine diff --git a/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderDrawableCache.cpp b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderDrawableCache.cpp new file mode 100644 index 0000000..d6eee9f --- /dev/null +++ b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderDrawableCache.cpp @@ -0,0 +1,732 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderDrawableCache.cpp + * @brief Implementation of class for drawable objects cache + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +UseProgram::UseProgram(RenderProgramCache* pProgram): + __pProgram(pProgram) +{ +} + +void +UseProgram::Apply(Render* pRender) +{ + __pProgram->UseProgram(pRender); __pProgram->EnableAttributes(pRender); + + return; +} + +DisableProgramAttributers::DisableProgramAttributers(RenderProgramCache* pProgram): + __pProgram(pProgram) +{ +} + +void +DisableProgramAttributers::Apply(Render* pRender) +{ + __pProgram->DisableAttributes(pRender); + return; +} + +Sampler2dUniform::Sampler2dUniform(RenderTexture2dCache* pTexture, GLuint stage): + __pTexture(pTexture), + __stage(stage) +{ +} + +void +Sampler2dUniform::Apply(Render* pRender) +{ + __pTexture->Bind(pRender, __stage); + return; +} + +void +Sampler2dAttachmentUniform::Apply(Render* pRender) +{ + __pTexture->Bind(pRender, __stage); + return; +} + +Sampler2dAttachmentUniform::Sampler2dAttachmentUniform(Texture2dAttachmentCache* pTexture, GLuint stage): + __pTexture(pTexture), + __stage(stage) +{ +} + +Matrix4fUniform::Matrix4fUniform(Tizen::Ui::Effects::_Renderer::EngineModel::Matrix4fProperty* pUniform, GLuint location): + __pUniform(pUniform), + __location(location) +{ +} + +void +Matrix4fUniform::Apply(Render*) +{ + glUniformMatrix4fv(__location, 1, GL_FALSE, __pUniform->Get().data[0].data); + return; +} + +IntUniform::IntUniform(Tizen::Ui::Effects::_Renderer::EngineModel::IntProperty* pUniform, GLuint location): + __pUniform(pUniform), + __location(location) +{ +} + +void +IntUniform::Apply(Render*) +{ + glUniform1i(__location, __pUniform->Get()); + return; +} + +FloatUniform::FloatUniform(Tizen::Ui::Effects::_Renderer::EngineModel::FloatProperty* pUniform, GLuint location): + __pUniform(pUniform), + __location(location) +{ +} + +void +FloatUniform::Apply(Render*) +{ + glUniform1f(__location, __pUniform->Get()); + return; +} + +FloatArrayUniform::FloatArrayUniform(Tizen::Ui::Effects::_Renderer::EngineModel::FloatArrayProperty* pUniform, GLuint location): + __pUniform(pUniform), + __location(location) +{ +} + +void +FloatArrayUniform::Apply(Render* pRender) +{ + glUniform1fv(__location, __pUniform->GetNumElements(), __pUniform->GetData()); + return; +} + +Vector2fUniform::Vector2fUniform(Tizen::Ui::Effects::_Renderer::EngineModel::Vector2fProperty* pUniform, GLuint location): + __pUniform(pUniform), + __location(location) +{ +} + +void +Vector2fUniform::Apply(Render*) +{ + glUniform2fv(__location, 1, __pUniform->Get().data); + return; +} + +Vector3fUniform::Vector3fUniform(Tizen::Ui::Effects::_Renderer::EngineModel::Vector3fProperty* pUniform, GLuint location): + __pUniform(pUniform), + __location(location) +{ +} + +void +Vector3fUniform::Apply(Render*) +{ + glUniform3fv(__location, 1, __pUniform->Get().data); + return; +} + +Vector4fUniform::Vector4fUniform(Tizen::Ui::Effects::_Renderer::EngineModel::Vector4fProperty* pUniform, GLuint location): + _pUniform(pUniform), + __location(location) +{ +} + +void +Vector4fUniform::Apply(Render*) +{ + glUniform4fv(__location, 1, _pUniform->Get().data); + return; +} + +ProgramAttribute::ProgramAttribute(VertexBufferCache* pAttribute, GLuint location): + __pAttribute(pAttribute), + __location(location) +{ +} + +void +ProgramAttribute::Apply(Render* pRender) +{ + __pAttribute->BindToAttrib(pRender, __location); + return; +} + +BindBuffer::BindBuffer(CompositeVertexBufferCache* pBuffer): + __pBuffer(pBuffer) +{ +} + +void +BindBuffer::Apply(Render* pRender) +{ + __pBuffer->Bind(pRender); + return; +} + +DrawIndexed::DrawIndexed(IndexBufferCache* pBuffer): + __pBuffer(pBuffer) +{ +} + +void +DrawIndexed::Apply(Render* pRender) +{ + __pBuffer->DrawElements(pRender); + return; +} + +SetState::SetState(RenderStateCache* pState): + __pState(pState) +{ +} + +void +SetState::Apply(Render* pRender) +{ + __pState->Set(pRender); + return; +} + +RenderDrawableCache::RenderDrawableCache(Render* pRender, EngineModel::Drawable* pDrawable) : + RenderCache(pRender), + __pDrawable(pDrawable), + __pAlphaBlend(null) +{ +} + +RenderDrawableCache::~RenderDrawableCache(void) +{ + +} + +RenderDrawableCache::ExternalTexturesListSizeType +RenderDrawableCache::NumExternalTextures(void) +{ + return __externalTextures.size(); +} + +EngineModel::TextureAttachment* +RenderDrawableCache::GetExternalTexture(ExternalTexturesListSizeType index) +{ + if (index < __externalTextures.size()) + { + return __externalTextures[index]; + } + return null; +} + +const Math::Matrix4f& +RenderDrawableCache::GetWorld(void) +{ + return __pDrawable->GetWorld(); +} + +void +RenderDrawableCache::DropCache(void) +{ + __ownCommands.clear(); + __commands.clear(); + __externalTextures.clear(); + return; +} + +void +RenderDrawableCache::Die(void) +{ + __pDrawable = null; + RenderCache::Die(); + return; +} + +void +RenderDrawableCache::DestroyCache(void) +{ + if (__pDrawable) + { + __pDrawable->SetCache(RenderDrawableCachePtr()); + } + __pDrawable = null; + DropCache(); + return; +} + +namespace +{ + struct ProgramFinder: EngineModel::PropertyVisitor + { + RenderProgramCache* programCache; + RenderAlphaBlendCache* alphaBlend; + Render* render; + + ProgramFinder(Tizen::Ui::Effects::_Renderer::EngineModel::MaterialPtr& material, Render* pRender): + programCache(null), + alphaBlend(null), + render(pRender) + { + const size_t len = material->GetNumProperties(); + for (size_t i = 0; len > i; ++i) + { + material->GetProperty(i)->Visit(*this); + } + } + + virtual void + OnProgramProperty(Tizen::Ui::Effects::_Renderer::EngineModel::ProgramProperty& prop) + { + programCache = static_cast(System::GetImpl(prop.GetCache())); + if (!programCache) + { + render->BuildCache(prop); + programCache = static_cast(System::GetImpl(prop.GetCache())); + } + + return; + } + + virtual void + OnAlphaBlendProperty(Tizen::Ui::Effects::_Renderer::EngineModel::AlphaBlendProperty& prop) + { + alphaBlend = static_cast(System::GetImpl(prop.GetCache())); + if (!alphaBlend) + { + render->BuildCache(prop); + alphaBlend = static_cast(System::GetImpl(prop.GetCache())); + } + + return; + } + }; + + struct UniformFinder: EngineModel::PropertyVisitor + { + RenderProgramCache* program; + EngineModel::MaterialPtr& material; + RenderDrawableCache::RenderCommandsListType& commands; + RenderDrawableCache::RenderCommandsListType& ownCommands; + std::vector& externalTextures; + Render* pRender; + + const RenderProgramCache::UniformListValueType* currentUniformInfo; + GLuint currentTextureStage; + + UniformFinder(RenderProgramCache* pProgram, EngineModel::MaterialPtr& materialArg, Render* pRenderArg, + RenderDrawableCache::RenderCommandsListType& commandsArg, RenderDrawableCache::RenderCommandsListType& ownCommandsArg, + std::vector& externalTexturesArg): + program(pProgram), + material(materialArg), + commands(commandsArg), + ownCommands(ownCommandsArg), + externalTextures(externalTexturesArg), + pRender(pRenderArg), + currentUniformInfo(null), + currentTextureStage(0) + { + const RenderProgramCache::UniformListSizeType numUniforms = program->GetNumUniforms(); + for (RenderProgramCache::UniformListSizeType i = 0; numUniforms > i; ++i) + { + const RenderProgramCache::UniformListValueType& uniformInfo = program->GetUniform(i); + currentUniformInfo = &uniformInfo; + EngineModel::PropertyPtr property = material->GetProperty(uniformInfo.second); + if (!property) + { + RenderCommandPtr renderCommandPtr = pRenderArg->GetDefaultRenderCommand(currentUniformInfo); + if (System::GetImpl(renderCommandPtr) != null) + { + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + } + continue; + } + property->Visit(*this); + } + } + + void + OnTexture2DProperty(Tizen::Ui::Effects::_Renderer::EngineModel::Texture2dProperty& prop) + { + glUniform1i(currentUniformInfo->first.location, currentTextureStage); + + RenderTexture2dCache* cache = static_cast(System::GetImpl(prop.GetCache())); + if (!cache) + { + pRender->BuildCache(prop, currentTextureStage); + cache = static_cast(System::GetImpl(prop.GetCache())); + } + + RenderCommandPtr renderCommandPtr(new (std::nothrow) Sampler2dUniform(cache, currentTextureStage)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "Sampler2dUniform = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + ++currentTextureStage; + return; + } + + void + OnTexture2DAttachmentProperty(Tizen::Ui::Effects::_Renderer::EngineModel::Texture2dAttachmentProperty& prop) + { + glUniform1i(currentUniformInfo->first.location, currentTextureStage); + + Texture2dAttachmentCache* cache = static_cast(System::GetImpl(prop.GetCache())); + if (!cache) + { + pRender->BuildCache(prop, currentTextureStage); + cache = static_cast(System::GetImpl(prop.GetCache())); + } + externalTextures.push_back(&prop); + RenderCommandPtr renderCommandPtr(new (std::nothrow) Sampler2dAttachmentUniform(cache, currentTextureStage)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "Sampler2dAttachmentUniform = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + ++currentTextureStage; + return; + } + + void + OnMatrix4fProperty(Tizen::Ui::Effects::_Renderer::EngineModel::Matrix4fProperty& prop) + { + RenderCommandPtr renderCommandPtr(new (std::nothrow) Matrix4fUniform(&prop, currentUniformInfo->first.location)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "Matrix4fUniform = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + return; + } + + void + OnVector2fProperty(Tizen::Ui::Effects::_Renderer::EngineModel::Vector2fProperty& prop) + { + RenderCommandPtr renderCommandPtr(new (std::nothrow) Vector2fUniform(&prop, currentUniformInfo->first.location)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "Vector2fUniform = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + return; + } + + void + OnVector3fProperty(Tizen::Ui::Effects::_Renderer::EngineModel::Vector3fProperty& prop) + { + RenderCommandPtr renderCommandPtr(new (std::nothrow) Vector3fUniform(&prop, currentUniformInfo->first.location)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "Vector3fUniform = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + return; + } + + void + OnVector4fProperty(Tizen::Ui::Effects::_Renderer::EngineModel::Vector4fProperty& prop) + { + RenderCommandPtr renderCommandPtr(new (std::nothrow) Vector4fUniform(&prop, currentUniformInfo->first.location)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "Vector4fUniform = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + return; + } + + void + OnIntProperty(Tizen::Ui::Effects::_Renderer::EngineModel::IntProperty& prop) + { + RenderCommandPtr renderCommandPtr(new (std::nothrow) IntUniform(&prop, currentUniformInfo->first.location)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "IntUniform = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + return; + } + + void + OnFloatProperty(Tizen::Ui::Effects::_Renderer::EngineModel::FloatProperty& prop) + { + RenderCommandPtr renderCommandPtr(new (std::nothrow) FloatUniform(&prop, currentUniformInfo->first.location)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "FloatUniform = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + return; + } + + void + OnFloatArrayProperty(Tizen::Ui::Effects::_Renderer::EngineModel::FloatArrayProperty& prop) + { + RenderCommandPtr renderCommandPtr(new (std::nothrow) FloatArrayUniform(&prop, currentUniformInfo->first.location)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "FloatArrayUniform = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + return; + } + }; + + + struct GeometryFinder: EngineModel::BufferVisitor + { + RenderProgramCache* pProgram; + EngineModel::GeometryPtr& geometry; + RenderDrawableCache::RenderCommandsListType& commands; + RenderDrawableCache::RenderCommandsListType& ownCommands; + Render* pRender; + + const RenderProgramCache::AttribuleListValueType* pCurrentAttributeInfo; + + GeometryFinder(RenderProgramCache* pProgramArg, EngineModel::GeometryPtr& geometryArg, Render* pRenderArg, + RenderDrawableCache::RenderCommandsListType& commandsArg, RenderDrawableCache::RenderCommandsListType& ownCommandsArg): + pProgram(pProgramArg), + geometry(geometryArg), + commands(commandsArg), + ownCommands(ownCommandsArg), + pRender(pRenderArg), + pCurrentAttributeInfo(null) + { + const RenderProgramCache::AttribuleListSizeType numAttributes = pProgram->GetNumAttributes(); + for (RenderProgramCache::AttribuleListSizeType i = 0; numAttributes > i; ++i) + { + const RenderProgramCache::AttribuleListValueType& attributeInfo = pProgram->GetAttribute(i); + pCurrentAttributeInfo = &attributeInfo; + EngineModel::BufferPtr buffer = geometry->GetBuffer(attributeInfo.second); + if (!buffer) + { + continue; + } + buffer->Visit(*this); + } + + EngineModel::BufferPtr buffer = geometry->GetIndexBuffer(); + if (!buffer) + { + return; + } + buffer->Visit(*this); + return; + } + + void + OnVertexBuffer(Tizen::Ui::Effects::_Renderer::EngineModel::VertexBuffer& prop) + { + VertexBufferCache* cache = static_cast(System::GetImpl(prop.GetCache())); + if (!cache) + { + pRender->BuildCache(prop); + } + + RenderCommandPtr renderCommandPtr(new (std::nothrow) ProgramAttribute(static_cast(System::GetImpl(prop.GetCache())), pCurrentAttributeInfo->first.location)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "ProgramAttribute = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + return; + } + + void + OnCompositeVertexBuffer(Tizen::Ui::Effects::_Renderer::EngineModel::CompositeVertexBuffer& prop) + { + CompositeVertexBufferCache* cache = static_cast(System::GetImpl(prop.GetCache())); + if (!cache) + { + pRender->BuildCache(prop); + } + + RenderCommandPtr renderCommandPtr(new (std::nothrow) BindBuffer(static_cast(System::GetImpl(prop.GetCache())))); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "BindBuffer = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + return; + } + + void + OnPartVertexBuffer(Tizen::Ui::Effects::_Renderer::EngineModel::PartVertexBuffer& prop) + { + prop.GetCompositeBuffer()->Visit(*this); + + VertexBufferCache* cache = static_cast(System::GetImpl(prop.GetCache())); + if (!cache) + { + pRender->BuildCache(prop); + } + + RenderCommandPtr renderCommandPtr(new (std::nothrow) ProgramAttribute(static_cast(System::GetImpl(prop.GetCache())), pCurrentAttributeInfo->first.location)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "ProgramAttribute = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + return; + } + + void + OnIndexBuffer(Tizen::Ui::Effects::_Renderer::EngineModel::IndexBuffer& prop) + { + IndexBufferCache* cache = static_cast(System::GetImpl(prop.GetCache())); + if (!cache) + { + pRender->BuildCache(prop); + } + + RenderCommandPtr renderCommandPtr(new (std::nothrow) DrawIndexed(static_cast(System::GetImpl(prop.GetCache())))); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "DrawIndexed = null"); + + commands.push_back(renderCommandPtr); + ownCommands.push_back(renderCommandPtr); + return; + } + }; +} + +void +RenderDrawableCache::Validate(Render* pRender) +{ + RenderCommandPtr renderCommandPtr; + + if (!_invalid) + { + return; + } + if (!__pDrawable) + { + return; + } + + __ownCommands.clear(); + __commands.clear(); + __externalTextures.clear(); + + EngineModel::MaterialPtr material = __pDrawable->GetMaterial(); + if (!material) + { + return; + } + + EngineModel::GeometryPtr geometry = __pDrawable->GetGeometry(); + if (!geometry) + { + return; + } + + //find __pProgram + ProgramFinder programFinder(material, pRender); + RenderProgramCache* pProgram = programFinder.programCache; + if (null == pProgram) + { + return; + } + + renderCommandPtr = RenderCommandPtr(new (std::nothrow) UseProgram(pProgram)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "UseProgram = null"); + + __commands.push_back(renderCommandPtr); + __ownCommands.push_back(renderCommandPtr); + + //Set states + if (programFinder.alphaBlend) + { + __pAlphaBlend = programFinder.alphaBlend; + renderCommandPtr = RenderCommandPtr(new (std::nothrow) SetState(__pAlphaBlend)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "SetState = null"); + + __commands.push_back(renderCommandPtr); + __ownCommands.push_back(renderCommandPtr); + } + + //parse uniforms + pProgram->UseProgram(pRender); + UniformFinder uniformFinder(pProgram, material, pRender, __commands, __ownCommands, __externalTextures); + glUseProgram(0); + + //parse geometry + GeometryFinder geometryFinder(pProgram, geometry, pRender, __commands, __ownCommands); + + //DisableAttributes + renderCommandPtr = RenderCommandPtr(new (std::nothrow) DisableProgramAttributers(pProgram)); + _TryJmp(System::GetImpl(renderCommandPtr) != null, E_OUT_OF_MEMORY, "DisableProgramAttributers = null"); + + __commands.push_back(renderCommandPtr); + __ownCommands.push_back(renderCommandPtr); + + _invalid = false; + return; +} + +void +RenderDrawableCache::Draw(Render* pRender) +{ + if (_invalid) + { + Validate(pRender); + } + + const size_t len = __commands.size(); + for (size_t i = 0; len > i; ++i) + { + __commands[i]->Apply(pRender); + } + + return; +} + +bool +RenderDrawableCache::HasAlphaBlend(Render* pRender) +{ + if (!__pAlphaBlend) + { + return false; + } + return __pAlphaBlend->IsEnable(pRender); +} + +}}}}} // Tizen::Ui::Effects::_Renderer::GraphicsEngine diff --git a/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderRenderTargetCache.cpp b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderRenderTargetCache.cpp new file mode 100644 index 0000000..fc4f978 --- /dev/null +++ b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderRenderTargetCache.cpp @@ -0,0 +1,404 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderRenderTargetCache.cpp + * @brief Implementation of class for render targets cache + * + */ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +StubAttachmentCache::StubAttachmentCache(Render *pRender, EngineModel::StubAttachment* pStubAttachment): + RenderCache(pRender), + _width(1), + _height(1), + _pStubAttachment(pStubAttachment), + _id(0) +{ +} + +StubAttachmentCache::~StubAttachmentCache(void) +{ + +} + +void +StubAttachmentCache::DropCache(void) +{ + _id = 0; + return; +} + +void +StubAttachmentCache::DestroyCache(void) +{ + if (_pStubAttachment) + { + _pStubAttachment->SetCache(StubAttachmentCachePtr()); + } + + _pStubAttachment = null; + + if (_id) + { + glDeleteRenderbuffers(1, &_id); + } + + return; +} + +void +StubAttachmentCache::Die(void) +{ + _pStubAttachment = null; + RenderCache::Die(); + return; +} + +void +StubAttachmentCache::Validate(Render* pRender) +{ + if (!_invalid) + { + return; + } + if (!_pStubAttachment) + { + return; + } + + if (!_id) + { + glGenRenderbuffers(1, &_id); + } + + glBindRenderbuffer(GL_RENDERBUFFER, _id); + glRenderbufferStorage(GL_RENDERBUFFER, RenderTextureCache::GetGlInternalFormat(_pStubAttachment->GetInternalFormat()), _width, _height); + + _invalid = false; + return; +} + +void +StubAttachmentCache::AttachToFrameBuffer(Render* pRender, GLenum attachment, GLuint width, GLuint height) +{ + if (width != _width || height != _height) + { + _width = width; + _height = height; + Invalidate(); + } + if (_invalid) + { + Validate(pRender); + } + glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, _id); + return; +} + + +Texture2dAttachmentCache::Texture2dAttachmentCache(Render *pRender, EngineModel::Texture2dAttachmentProperty* pTexture2DAttachmentProperty): + RenderCache(pRender), + _width(1), + _height(1), + _pTexture2DAttachmentProperty(pTexture2DAttachmentProperty), + _id(0) +{ +} + +Texture2dAttachmentCache::~Texture2dAttachmentCache(void) +{ + +} + +void +Texture2dAttachmentCache::DropCache(void) +{ + _id = 0; + return; +} + +void +Texture2dAttachmentCache::Die(void) +{ + _pTexture2DAttachmentProperty = null; + RenderCache::Die(); + return; +} + +void +Texture2dAttachmentCache::DestroyCache(void) +{ + if (_pTexture2DAttachmentProperty) + { + _pTexture2DAttachmentProperty->SetCache(Texture2DAttachmentCachePtr()); + } + + _pTexture2DAttachmentProperty = null; + + if (_id) + { + glDeleteTextures(1, &_id); + } + + return; +} + +void +Texture2dAttachmentCache::Validate(Render* pRender) +{ + Validate(pRender, 0); + return; +} + +void +Texture2dAttachmentCache::Validate(Render* pRender, GLuint stage) +{ + if (!_invalid) + { + return; + } + if (!_pTexture2DAttachmentProperty) + { + return; + } + if (!_id) + { + glGenTextures(1, &_id); + } + + glActiveTexture(GL_TEXTURE0 + stage); + glBindTexture(GL_TEXTURE_2D, _id); + + GLenum internalFormat = RenderTextureCache::GetGlInternalFormat(_pTexture2DAttachmentProperty->GetInternalFormat()); + GLenum dataFormat = RenderTextureCache::GetGlDataFormat(_pTexture2DAttachmentProperty->GetDataFormat()); + GLenum dataType = RenderTextureCache::GetGlDataType(_pTexture2DAttachmentProperty->GetDataType()); + + glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, + static_cast(_width), + static_cast(_height), + 0, dataFormat, dataType, null); + + if (_pTexture2DAttachmentProperty->GetGenerateMipmaps()) + { + glGenerateMipmap(GL_TEXTURE_2D); + } + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, RenderTextureCache::GetGlFilterType(_pTexture2DAttachmentProperty->GetMinFilter())); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, RenderTextureCache::GetGlFilterType(_pTexture2DAttachmentProperty->GetMagFilter())); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, RenderTextureCache::GetGlWrapType(_pTexture2DAttachmentProperty->GetWrapS())); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, RenderTextureCache::GetGlWrapType(_pTexture2DAttachmentProperty->GetWrapT())); + + glBindTexture(GL_TEXTURE_2D, 0); + + _invalid = false; + return; +} + +void +Texture2dAttachmentCache::AttachToFrameBuffer(Render* pRender, GLenum attachment, GLuint width, GLuint height, GLuint mipmap) +{ + if (width != _width || height != _height) + { + _width = width; + _height = height; + Invalidate(); + } + if (_invalid) + { + Validate(pRender, 0); + } + glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, _id, mipmap); + return; +} + +void +Texture2dAttachmentCache::Bind(Render* pRender, GLuint stage) +{ + if (_invalid) + { + Validate(pRender, stage); + } + + glActiveTexture(GL_TEXTURE0 + stage); + glBindTexture(GL_TEXTURE_2D, _id); + return; +} + + +RenderTargetExternalRenderCache::RenderTargetExternalRenderCache(Render *pRender, EngineModel::RenderTargetExternalRender* pRenderTargetExternalRender) + : RenderCache(pRender) + , _pRenderTargetExternalRender(pRenderTargetExternalRender) + , _id(0) + , _ppp(0) + , _numColorBuffers(static_cast(0)) +{ + memset(_colorBuffers, 0, EngineModel::RenderTarget::Attachment::ATTACHMENT_MAX * sizeof(GLenum)); +} + +RenderTargetExternalRenderCache::~RenderTargetExternalRenderCache(void) +{ + +} + +void +RenderTargetExternalRenderCache::DropCache(void) +{ + _id = 0; + return; +} + +void +RenderTargetExternalRenderCache::Die(void) +{ + _pRenderTargetExternalRender = null; + RenderCache::Die(); + return; +} + +void +RenderTargetExternalRenderCache::DestroyCache(void) +{ + if (_pRenderTargetExternalRender) + { + _pRenderTargetExternalRender->SetCache(RenderTargetExternalRenderCachePtr()); + } + + _pRenderTargetExternalRender = null; + + if (_id) + { + glDeleteFramebuffers(1, &_id); + } + + return; +} + +namespace +{ +#ifdef _EFFECTS_GRAPHICSENGINE_OPENGL_DESKTOP_ + GLenum _attachments[] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3, + GL_COLOR_ATTACHMENT4, GL_COLOR_ATTACHMENT5, GL_COLOR_ATTACHMENT6, GL_COLOR_ATTACHMENT7, + GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT}; +#endif + +#ifdef _EFFECTS_GRAPHICSENGINE_OPENGL_ES_ + GLenum _attachments[] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0, + GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT}; +#endif +} + +void +RenderTargetExternalRenderCache::Validate(Render* pRender) +{ + if (!_invalid) + { + return; + } + if (!_pRenderTargetExternalRender) + { + return; + } + if (!_id) + { + glGenFramebuffers(1, &_id); + } + _numColorBuffers = 0; + glBindFramebuffer(GL_FRAMEBUFFER, _id); + + GLuint width = _pRenderTargetExternalRender->GetWidth(); + GLuint height = _pRenderTargetExternalRender->GetHeight(); + + for (unsigned short i = EngineModel::RenderTarget::Attachment::COLOR_0; + EngineModel::RenderTarget::Attachment::STENCIL > i; ++i) + { + const EngineModel::RenderTarget::AttachInfo* pAttachment = _pRenderTargetExternalRender->GetAttachment(static_cast(i)); + if (null == pAttachment) + { + continue; + } + switch (pAttachment->textureType) + { + case EngineModel::RenderTarget::AttachInfo::TEXTURE_2D: + { + EngineModel::Texture2dAttachmentProperty* texture = pAttachment->textureInfo.texture2D.pTexture; + Texture2dAttachmentCache* textureTarget = static_cast(System::GetImpl(texture->GetCache())); + if (!textureTarget) + { + pRender->BuildCache(*texture, 0); + textureTarget = static_cast(System::GetImpl(texture->GetCache())); + } + textureTarget->AttachToFrameBuffer(pRender, _attachments[i], width, height, static_cast(pAttachment->textureInfo.texture2D.mipLevel)); + break; + } + case EngineModel::RenderTarget::AttachInfo::STUB: + { + EngineModel::StubAttachment* stub = pAttachment->textureInfo.stub.pStub; + StubAttachmentCache* stubTarget = static_cast(System::GetImpl(stub->GetCache())); + if (!stubTarget) + { + pRender->BuildCache(*stub); + stubTarget = static_cast(System::GetImpl(stub->GetCache())); + } + stubTarget->AttachToFrameBuffer(pRender, _attachments[i], width, height); + break; + } + default: + continue; + } + if (i < EngineModel::RenderTarget::Attachment::DEPTH) + { + _colorBuffers[_numColorBuffers] = _attachments[i]; + ++_numColorBuffers; + } + } + + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + _invalid = false; + return; +} + +void +RenderTargetExternalRenderCache::Draw(Render* pRender) +{ + if (!_pRenderTargetExternalRender->GetExternalRender()->NeedRedraw()) + { + return; + } + if (_invalid) + { + Validate(pRender); + } + glBindFramebuffer(GL_FRAMEBUFFER , _id); +#ifdef _EFFECTS_GRAPHICSENGINE_OPENGL_DESKTOP_ + +#endif + _pRenderTargetExternalRender->GetExternalRender()->Draw(); + return; +} + +}}}}} // Tizen::Ui::Effects::_Renderer::GraphicsEngine diff --git a/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderShaderCache.cpp b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderShaderCache.cpp new file mode 100644 index 0000000..2b01eb5 --- /dev/null +++ b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderShaderCache.cpp @@ -0,0 +1,385 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderShaderCache.cpp + * @brief Implementation of class for render shaders cache + * + */ + +#include + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +GLenum +RenderShaderCache::GetShaderType(Tizen::Ui::Effects::_Renderer::EngineModel::ShaderProperty::ShaderType::Value shaderType) +{ + switch (shaderType) + { + case EngineModel::ShaderProperty::ShaderType::VERTEX: + return GL_VERTEX_SHADER; + case EngineModel::ShaderProperty::ShaderType::FRAGMENT: + return GL_FRAGMENT_SHADER; + } + return GL_VERTEX_SHADER; +} + +bool +RenderShaderCache::IsBinary(Tizen::Ui::Effects::_Renderer::EngineModel::ShaderProperty::DataType::Value dataType) +{ + if (dataType == EngineModel::ShaderProperty::DataType::BINARY_DATA) + { + return true; + } + + return false; +} + +RenderShaderCache::RenderShaderCache(Render *pRender, EngineModel::ShaderProperty* pShader): + RenderCache(pRender), + _shaderId(0), + _pShader(pShader) +{ +} + +RenderShaderCache::~RenderShaderCache(void) +{ + +} + +void +RenderShaderCache::DropCache(void) +{ + _shaderId = 0; + return; +} + +void +RenderShaderCache::Die(void) +{ + _pShader = null; + RenderCache::Die(); + return; +} + +void +RenderShaderCache::DestroyCache(void) +{ + if (_pShader) + { + _pShader->SetCache(RenderShaderCachePtr()); + } + + _pShader = null; + + if (_shaderId) + { + glDeleteShader(_shaderId); + } + + return; +} + +void +RenderShaderCache::Validate(Render* pRender) +{ + if (!_invalid) + { + return; + } + if (null == _pShader) + { + return; + } + if (!_shaderId) + { + _shaderId = glCreateShader(GetShaderType(_pShader->GetShaderType())); + } + + if (!IsBinary(_pShader->GetDataType())) + { + const char* pData = (reinterpret_cast(_pShader->GetData())); + + glShaderSource(_shaderId, 1, &pData, null); + glCompileShader(_shaderId); + + GLint compiled = GL_FALSE; + glGetShaderiv(_shaderId, GL_COMPILE_STATUS, &compiled); + + if (!compiled) + { + int infologLength = 0; + int charsWritten = 0; + + glGetShaderiv(_shaderId, GL_INFO_LOG_LENGTH, &infologLength); + + if (infologLength > 0) + { + std::string infoLog(infologLength, '\0'); + + glGetShaderInfoLog(_shaderId, infologLength, &charsWritten, &infoLog[0]); + SysLogException(NID_UI_EFFECT, E_SYSTEM, "Shader compilation error: %s in \"%s\"", infoLog.c_str(), pData); + } + } + else + { + SysLog(NID_UI_EFFECT, "Shader was compiled successfully"); + } + } + _invalid = false; + return; +} + +void +RenderShaderCache::AttachToProgram(Render* pRender, GLuint programId) +{ + if (_invalid) + { + Validate(pRender); + } + + glAttachShader(programId, _shaderId); + + return; +} + +RenderProgramCache::RenderProgramCache(Render* pRender, EngineModel::ProgramProperty* pProgram) + : RenderCache(pRender) + , _attributes() + , _uniforms() + , _programId(0) + , _pVertexShader(null) + , _pFragmentShader(null) + , _pProgram(pProgram) +{ +} + +RenderProgramCache::~RenderProgramCache(void) +{ + +} + +void +RenderProgramCache::DropCache(void) +{ + _programId = 0; + return; +} + +void +RenderProgramCache::Die(void) +{ + _pProgram = null; + RenderCache::Die(); + return; +} + +void +RenderProgramCache::DestroyCache(void) +{ + if (_pProgram) + { + _pProgram->SetCache(RenderProgramCachePtr()); + } + + _pProgram = null; + + if (_programId) + { + glDeleteProgram(_programId); + } + + return; +} + +void +RenderProgramCache::Validate(Render* pRender) +{ + if (!_invalid) + { + return; + } + if (!_pProgram) + { + return; + } + + EngineModel::ShaderPropertyPtr vertexShaderProperty = _pProgram->GetShader(Tizen::Ui::Effects::_Renderer::EngineModel::ShaderProperty::ShaderType::VERTEX); + if (!vertexShaderProperty) + { + return; + } + + _pVertexShader = static_cast(System::GetImpl(vertexShaderProperty->GetCache())); + if (!_pVertexShader) + { + pRender->BuildCache(*System::GetImpl(vertexShaderProperty)); + _pVertexShader = static_cast(System::GetImpl(vertexShaderProperty->GetCache())); + } + + EngineModel::ShaderPropertyPtr fragmentShaderProperty = _pProgram->GetShader(Tizen::Ui::Effects::_Renderer::EngineModel::ShaderProperty::ShaderType::FRAGMENT); + if (!fragmentShaderProperty) + { + return; + } + _pFragmentShader = static_cast(System::GetImpl(fragmentShaderProperty->GetCache())); + if (!_pFragmentShader) + { + pRender->BuildCache(*System::GetImpl(fragmentShaderProperty)); + _pFragmentShader = static_cast(System::GetImpl(fragmentShaderProperty->GetCache())); + } + + if (_programId != 0) + { + glDeleteProgram(_programId); + } + + _programId = glCreateProgram(); + + _pVertexShader->AttachToProgram(pRender, _programId); + _pFragmentShader->AttachToProgram(pRender, _programId); + glLinkProgram(_programId); + + int isLinked = GL_FALSE; + glGetProgramiv(_programId, GL_LINK_STATUS, (int *)&isLinked); + + if (isLinked == GL_FALSE) + { + int infologLength = 0; + int charsWritten = 0; + + glGetProgramiv(_programId, GL_INFO_LOG_LENGTH, &infologLength); + + if (infologLength > 0) + { + std::string infoLog(infologLength, '\0'); + + glGetProgramInfoLog(_programId, infologLength, &charsWritten, &infoLog[0]); + SysLogException(NID_UI_EFFECT, E_SYSTEM, "Shader program linkage error: %s", infoLog.c_str()); + } + } + else + { + SysLog(NID_UI_EFFECT, "Compiled shader was linked successfully"); + } + + _attributes.clear(); + _uniforms.clear(); + + char nameBuffer[256]; + GLint nameLength = 0; + GLenum type = 0; + GLint size = 0; + + GLint numAttributes = 0; + glGetProgramiv(_programId, GL_ACTIVE_ATTRIBUTES, &numAttributes); + _attributes.resize(numAttributes); + for (GLint i = 0; numAttributes > i; ++i) + { + glGetActiveAttrib(_programId, i, 250, &nameLength, &size, &type, nameBuffer); + nameBuffer[nameLength] = 0; + _attributes[i].first.type = type; + _attributes[i].first.size = size; + _attributes[i].first.location = glGetAttribLocation(_programId, nameBuffer); + _attributes[i].second = nameBuffer; + } + + GLint numUniforms = 0; + glGetProgramiv(_programId, GL_ACTIVE_UNIFORMS, &numUniforms); + _uniforms.resize(numUniforms); + + for (GLint i = 0; numUniforms > i; ++i) + { + glGetActiveUniform(_programId, i, 250, &nameLength, &size, &type, nameBuffer); + nameBuffer[nameLength] = 0; + _uniforms[i].first.type = type; + _uniforms[i].first.size = size; + _uniforms[i].first.location = glGetUniformLocation(_programId, nameBuffer); + _uniforms[i].second = nameBuffer; + } + + _invalid = false; + return; +} + +void +RenderProgramCache::UseProgram(Render* pRender) +{ + if (_invalid) + { + Validate(pRender); + } + + glUseProgram(_programId); + + return; +} + +void +RenderProgramCache::EnableAttributes(Render*) +{ + const AttribuleListSizeType len = _attributes.size(); + for (AttribuleListSizeType i = 0; len > i; ++i) + { + glEnableVertexAttribArray(_attributes[i].first.location); + } + return; +} + +void +RenderProgramCache::DisableAttributes(Render*) +{ + const AttribuleListSizeType len = _attributes.size(); + for (AttribuleListSizeType i = 0; len > i; ++i) + { + glDisableVertexAttribArray(_attributes[i].first.location); + } + return; +} + +const RenderProgramCache::AttribuleListValueType& +RenderProgramCache::GetAttribute(AttribuleListSizeType aIndex) +{ + return _attributes[aIndex]; +} + +RenderProgramCache::AttribuleListSizeType +RenderProgramCache::GetNumAttributes(void) +{ + return _attributes.size(); +} + +const RenderProgramCache::UniformListValueType& +RenderProgramCache::GetUniform(UniformListSizeType aIndex) +{ + return _uniforms[aIndex]; +} + +RenderProgramCache::UniformListSizeType +RenderProgramCache::GetNumUniforms(void) +{ + return _uniforms.size(); +} + + +}}}}} // Tizen::Ui::Effects::_Renderer::GraphicsEngine diff --git a/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderStateCache.cpp b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderStateCache.cpp new file mode 100644 index 0000000..5f99422 --- /dev/null +++ b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderStateCache.cpp @@ -0,0 +1,136 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderStateCache.cpp + * @brief Implementation of class for render states cache + * + */ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +GLenum +RenderAlphaBlendCache::GetGlBlendFactor(Tizen::Ui::Effects::_Renderer::EngineModel::AlphaBlendProperty::BlendFactor::Value value) +{ + switch (value) + { + case EngineModel::AlphaBlendProperty::BlendFactor::ZERO: + return GL_ZERO; + case EngineModel::AlphaBlendProperty::BlendFactor::ONE: + return GL_ONE; + case EngineModel::AlphaBlendProperty::BlendFactor::SRC_COLOR: + return GL_SRC_COLOR; + case EngineModel::AlphaBlendProperty::BlendFactor::ONE_MINUS_SRC_COLOR: + return GL_ONE_MINUS_SRC_COLOR; + case EngineModel::AlphaBlendProperty::BlendFactor::DST_COLOR: + return GL_DST_COLOR; + case EngineModel::AlphaBlendProperty::BlendFactor::ONE_MINUS_DST_COLOR: + return GL_ONE_MINUS_DST_COLOR; + case EngineModel::AlphaBlendProperty::BlendFactor::SRC_ALPHA: + return GL_SRC_ALPHA; + case EngineModel::AlphaBlendProperty::BlendFactor::ONE_MINUS_SRC_ALPHA: + return GL_ONE_MINUS_SRC_ALPHA; + case EngineModel::AlphaBlendProperty::BlendFactor::DST_ALPHA: + return GL_DST_ALPHA; + case EngineModel::AlphaBlendProperty::BlendFactor::ONE_MINUS_DST_ALPHA: + return GL_ONE_MINUS_DST_ALPHA; + case EngineModel::AlphaBlendProperty::BlendFactor::CONSTANT_COLOR: + return GL_CONSTANT_COLOR; + case EngineModel::AlphaBlendProperty::BlendFactor::ONE_MINUS_CONSTANT_COLOR: + return GL_ONE_MINUS_CONSTANT_COLOR; + case EngineModel::AlphaBlendProperty::BlendFactor::CONSTANT_ALPHA: + return GL_CONSTANT_ALPHA; + case EngineModel::AlphaBlendProperty::BlendFactor::ONE_MINUS_CONSTANT_ALPHA: + return GL_ONE_MINUS_CONSTANT_ALPHA; + case EngineModel::AlphaBlendProperty::BlendFactor::SRC_ALPHA_SATURATE: + return GL_SRC_ALPHA_SATURATE; + } + ThrowJmp("RenderAlphaBlendCache::getGLBlendFactor: unknown blend factor"); +} + +RenderAlphaBlendCache::RenderAlphaBlendCache(Render* pRender, EngineModel::AlphaBlendProperty* pState) + : RenderStateCache(pRender) + , __pState(pState) + , __source(static_cast(0)) + , __destination(static_cast(0)) + , __isEnabled(false) +{ +} + +RenderAlphaBlendCache::~RenderAlphaBlendCache(void) +{ +} + +void +RenderAlphaBlendCache::Validate(Render* pRender) +{ + if (!_invalid) + { + return; + } + if (!__pState) + { + return; + } + if (!(__isEnabled = __pState->IsEnable())) + { + return; + } + __source = GetGlBlendFactor(__pState->GetSourceFactor()); + __destination = GetGlBlendFactor(__pState->GetDestinationFactor()); + _invalid = false; + return; +} + +void +RenderAlphaBlendCache::Set(Render* pRender) +{ + if (_invalid) + { + Validate(pRender); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + + if (!__pState->IsEnable()) + { + return; + } + + if (pRender->GetAlphaBlendSource() != __source || pRender->GetAlphaBlendDestination() != __destination) + { + glBlendFunc(__source, __destination); + } + + return; +} + +bool +RenderAlphaBlendCache::IsEnable(Render* pRender) +{ + if (_invalid) + { + Validate(pRender); + } + return __isEnabled; +} + +}}}}} // Tizen::Ui::Effects::_Renderer::GraphicsEngine diff --git a/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderTextureCache.cpp b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderTextureCache.cpp new file mode 100644 index 0000000..4b43b82 --- /dev/null +++ b/src/ui/effects/renderer/graphics-engine/FUiEffects_RendererGraphicsEngineRenderTextureCache.cpp @@ -0,0 +1,278 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererGraphicsEngineRenderTextureCache.cpp + * @brief Implementation of class for render textures cache + * + */ + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace GraphicsEngine +{ + +RenderTextureCache::RenderTextureCache(Render *aRender): + RenderCache(aRender), + _textureId(0) +{ +} + +RenderTextureCache::~RenderTextureCache() +{ +} + +void +RenderTextureCache::DropCache(void) +{ + _textureId = 0; + return; +} + +void +RenderTextureCache::DestroyCache(void) +{ + if (_textureId) + { + glDeleteTextures(1, &_textureId); + } + + return; +} + +GLenum +RenderTextureCache::GetGlInternalFormat(Tizen::Ui::Effects::_Renderer::EngineModel::TextureProperty::InternalFormat::Value internalFormat) +{ + switch (internalFormat) + { + case EngineModel::TextureProperty::InternalFormat::ONE_COMPONENT: + return 1; + case EngineModel::TextureProperty::InternalFormat::TWO_COMPONENTS: + return 2; + case EngineModel::TextureProperty::InternalFormat::THREE_COMPONENTS: + return 3; + case EngineModel::TextureProperty::InternalFormat::FOUR_COMPONENTS: + return 4; + case EngineModel::TextureProperty::InternalFormat::DEPTH_COMPONENT: + return GL_DEPTH_COMPONENT; + case EngineModel::TextureProperty::InternalFormat::DEPTH_COMPONENT_16: + return GL_DEPTH_COMPONENT16; + case EngineModel::TextureProperty::InternalFormat::DEPTH_COMPONENT_24: + ThrowJmp("GL_DEPTH_COMPONENT24 not allowed under GLES2"); + // fall through + case EngineModel::TextureProperty::InternalFormat::DEPTH_COMPONENT_32: + ThrowJmp("GL_DEPTH_COMPONENT32 not allowed under GLES2"); + // fall through + case EngineModel::TextureProperty::InternalFormat::RGB: + return GL_RGB; + case EngineModel::TextureProperty::InternalFormat::RGBA: + return GL_RGBA; + case EngineModel::TextureProperty::InternalFormat::BGRA: + return GL_BGRA; + } + return 1; +} + +GLenum +RenderTextureCache::GetGlDataFormat(Tizen::Ui::Effects::_Renderer::EngineModel::TextureProperty::DataFormat::Value dataFormat) +{ + switch (dataFormat) + { + case EngineModel::TextureProperty::DataFormat::RGB: + return GL_RGB; + case EngineModel::TextureProperty::DataFormat::BGR: + ThrowJmp("GL_BGR not allowed under GLES2"); + // fall through + case EngineModel::TextureProperty::DataFormat::RGBA: + return GL_RGBA; + case EngineModel::TextureProperty::DataFormat::BGRA: + return GL_BGRA_EXT; + case EngineModel::TextureProperty::DataFormat::LUMINANCE: + return GL_LUMINANCE; + case EngineModel::TextureProperty::DataFormat::LUMINANCE_ALPHA: + return GL_LUMINANCE_ALPHA; + } + ThrowJmp("RenderTextureCache::getGLDataFormat: unknown data format"); +} + +GLenum +RenderTextureCache::GetGlDataType(Tizen::Ui::Effects::_Renderer::EngineModel::TextureProperty::DataType::Value dataType) +{ + switch (dataType) + { + case EngineModel::TextureProperty::DataType::UNSIGNED_BYTE: + return GL_UNSIGNED_BYTE; + case EngineModel::TextureProperty::DataType::BYTE: + return GL_BYTE; + case EngineModel::TextureProperty::DataType::UNSIGNED_SHORT: + return GL_UNSIGNED_SHORT; + case EngineModel::TextureProperty::DataType::SHORT: + return GL_SHORT; + case EngineModel::TextureProperty::DataType::UNSIGNED_INT: + return GL_UNSIGNED_INT; + case EngineModel::TextureProperty::DataType::INT: + return GL_INT; + case EngineModel::TextureProperty::DataType::FLOAT: + return GL_FLOAT; + case EngineModel::TextureProperty::DataType::UNSIGNED_SHORT_565: + return GL_UNSIGNED_SHORT_5_6_5; + } + ThrowJmp("RenderTextureCache::getGLDataType: unknown data type"); +} + +GLenum +RenderTextureCache::GetGlFilterType(Tizen::Ui::Effects::_Renderer::EngineModel::TextureProperty::FilterType::Value filterType) +{ + switch (filterType) + { + case EngineModel::TextureProperty::FilterType::NEAREST: + return GL_NEAREST; + case EngineModel::TextureProperty::FilterType::LINEAR: + return GL_LINEAR; + case EngineModel::TextureProperty::FilterType::NEAREST_MIPMAP_NEAREST: + return GL_NEAREST_MIPMAP_NEAREST; + case EngineModel::TextureProperty::FilterType::LINEAR_MIPMAP_NEAREST: + return GL_LINEAR_MIPMAP_NEAREST; + case EngineModel::TextureProperty::FilterType::NEAREST_MIPMAP_LINEAR: + return GL_NEAREST_MIPMAP_LINEAR; + case EngineModel::TextureProperty::FilterType::LINEAR_MIPMAP_LINEAR: + return GL_LINEAR_MIPMAP_LINEAR; + } + ThrowJmp("RenderTextureCache::getGLFilterType: unknown filter type"); +} + +GLenum +RenderTextureCache::GetGlWrapType(Tizen::Ui::Effects::_Renderer::EngineModel::TextureProperty::WrapType::Value wrapType) +{ + switch (wrapType) + { + case EngineModel::TextureProperty::WrapType::CLAMP: + ThrowJmp("GL_CLAMP not allowed under GLES2"); + // fall through + case EngineModel::TextureProperty::WrapType::CLAMP_TO_BORDER: + ThrowJmp("GL_CLAMP_TO_BORDER not allowed under GLES2"); + // fall through + case EngineModel::TextureProperty::WrapType::CLAMP_TO_EDGE: + return GL_CLAMP_TO_EDGE; + case EngineModel::TextureProperty::WrapType::MIRRORED_REPEAT: + return GL_MIRRORED_REPEAT; + case EngineModel::TextureProperty::WrapType::REPEAT: + return GL_REPEAT; + } + ThrowJmp("RenderTextureCache::getGLWrapType: unknown wrap type"); +} + + +RenderTexture2dCache::RenderTexture2dCache(Render* pRender, EngineModel::Texture2dProperty* pTexture): + RenderTextureCache(pRender), + __pTexture(pTexture) +{ +} + +RenderTexture2dCache::~RenderTexture2dCache(void) +{ +} + +void +RenderTexture2dCache::Die(void) +{ + __pTexture = null; + RenderCache::Die(); + return; +} + +void +RenderTexture2dCache::DestroyCache(void) +{ + if (__pTexture) + { + __pTexture->SetCache(RenderTexture2DCachePtr()); + } + + __pTexture = null; + RenderTextureCache::DestroyCache(); + + return; +} + +void +RenderTexture2dCache::Validate(Render* pRender) +{ + Validate(pRender, 0); + return; +} + +void +RenderTexture2dCache::Validate(Render*, GLuint stage) +{ + if (!_invalid) + { + return; + } + if (!_textureId) + { + glGenTextures(1, &_textureId); + } + glActiveTexture(GL_TEXTURE0 + stage); + glBindTexture(GL_TEXTURE_2D, _textureId); + const size_t numMipMaps = __pTexture->GetNumMipmaps(); + + GLenum internalFormat = GetGlInternalFormat(__pTexture->GetInternalFormat()); + GLenum dataFormat = GetGlDataFormat(__pTexture->GetDataFormat()); + GLenum dataType = GetGlDataType(__pTexture->GetDataType()); + + for (size_t i = 0; numMipMaps > i; ++i) + { + glTexImage2D(GL_TEXTURE_2D, static_cast(i), internalFormat, + static_cast(__pTexture->GetWidth(i)), + static_cast(__pTexture->GetHeight(i)), + 0, dataFormat, dataType, + __pTexture->GetData(i)); + } + + if (__pTexture->GenerateMipmaps()) + { + glGenerateMipmap(GL_TEXTURE_2D); + } + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GetGlFilterType(__pTexture->GetMinFilter())); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GetGlFilterType(__pTexture->GetMagFilter())); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GetGlWrapType(__pTexture->GetWrapS())); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GetGlWrapType(__pTexture->GetWrapT())); + + _invalid = false; + return; +} + +void +RenderTexture2dCache::Bind(Render* pRender, GLuint stage) +{ + if (_invalid) + { + Validate(pRender, stage); + } + else + { + glActiveTexture(GL_TEXTURE0 + stage); + glBindTexture(GL_TEXTURE_2D, _textureId); + } + return; +} + +}}}}} // Tizen::Ui::Effects::_Renderer::GraphicsEngine diff --git a/src/ui/effects/renderer/system/FUiEffects_RendererSystemData.cpp b/src/ui/effects/renderer/system/FUiEffects_RendererSystemData.cpp new file mode 100644 index 0000000..66082da --- /dev/null +++ b/src/ui/effects/renderer/system/FUiEffects_RendererSystemData.cpp @@ -0,0 +1,36 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemData.cpp + * @brief This file contains implementation of Data class + * + */ + + +#include + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ +namespace System +{ + + + +}}}}} // Tizen::Ui::Effects::_Renderer::System diff --git a/src/ui/effects/renderer/system/FUiEffects_RendererSystemException.cpp b/src/ui/effects/renderer/system/FUiEffects_RendererSystemException.cpp new file mode 100644 index 0000000..d6fed0d --- /dev/null +++ b/src/ui/effects/renderer/system/FUiEffects_RendererSystemException.cpp @@ -0,0 +1,33 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemException.cpp + * @brief Exceptions + * + */ + + +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ +namespace System +{ + jmp_buf jumpBuffer; + +}}}}} // Tizen::Ui::Effects::_Renderer::System diff --git a/src/ui/effects/renderer/system/FUiEffects_RendererSystemPlatformDefine.cpp b/src/ui/effects/renderer/system/FUiEffects_RendererSystemPlatformDefine.cpp new file mode 100644 index 0000000..ec1d1de --- /dev/null +++ b/src/ui/effects/renderer/system/FUiEffects_RendererSystemPlatformDefine.cpp @@ -0,0 +1,51 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiEffects_RendererSystemPlatformDefine.cpp + * @brief The platform's defines + * + */ + + +#include +#include + +namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer +{ +namespace System +{ + +const char* +GetPlatformName(void) +{ +#if defined(_EFFECTS_SYSTEM_WINDOWS_) + static const char* pResult = "Windows"; +#elif defined(_EFFECTS_SYSTEM_ANDROID_) + static const char* pResult = "Android"; +#elif defined(_EFFECTS_SYSTEM_SLP_) + static const char* pResult = "Samsung Linux Platform"; +#elif defined(_EFFECTS_SYSTEM_LINUX_) + static const char* pResult = "Generic Linux"; +#else + static const char* pResult = "Unknown"; +#endif + + return pResult; +} + +}}}}} // Tizen::Ui::Effects::_Renderer::System diff --git a/src/ui/effects/runtime/FUiEffects_RuntimeDirectionalLight.cpp b/src/ui/effects/runtime/FUiEffects_RuntimeDirectionalLight.cpp new file mode 100644 index 0000000..c8f8e21 --- /dev/null +++ b/src/ui/effects/runtime/FUiEffects_RuntimeDirectionalLight.cpp @@ -0,0 +1,124 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeDirectionalLight.cpp + * @brief This file contains an implementation of DirectionalLight class methods + * + */ + +#include +#include + +using namespace Tizen::Ui::Effects::_Utils; +using namespace std; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +DirectionalLight::DirectionalLight(const string& name) + : UnitLight(name) + , isDirectionChanged(false) + , __direction(0.f, 0.f, -1.f) +{ + +} + +DirectionalLight::DirectionalLight(bool enabled, + const string& name, + const Vec3f& colour, + float intensity, + const Vec3f& direction) + : UnitLight(enabled, name, colour, intensity) + , isDirectionChanged(false) + , __direction(direction) +{ + +} + + +DirectionalLight::~DirectionalLight(void) +{ + +} + +DirectionalLight* +DirectionalLight::CreateDirectionalLight(const string& name) +{ + DirectionalLight* pDirectionalLight = new (std::nothrow) DirectionalLight(name); + AddUnitLightToPool(pDirectionalLight); + return pDirectionalLight; +} + +DirectionalLight* +DirectionalLight::CreateDirectionalLight(bool isEnabled, + const string& name, + const Vec3f& colour, + float intensity, + const Vec3f& direction) +{ + DirectionalLight* pDirectionalLight = new (std::nothrow) DirectionalLight(isEnabled, + name, + colour, + intensity, + direction); + AddUnitLightToPool(pDirectionalLight); + return pDirectionalLight; +} + +const Vec3f& +DirectionalLight::GetDirection(void) const +{ + return __direction; +} + +void +DirectionalLight::SetDirection(const Tizen::Ui::Effects::_Utils::Vec3f& direction) +{ + SetDirection(direction.x, direction.y, direction.z); + return; +} + +void +DirectionalLight::SetDirection(float x, float y, float z) +{ + if (fabs(__direction.x - x) > EFFECT_EPSILONF + || fabs(__direction.y - y) > EFFECT_EPSILONF + || fabs(__direction.z - z) > EFFECT_EPSILONF) + { + __direction.x = x; + __direction.y = y; + __direction.z = z; + isDirectionChanged = true; + isSomethingChanged = true; + } + return; +} + +TypeUnitLight +DirectionalLight::GetType(void) const +{ + return TYPE_UNIT_LIGHT_DIRECTIONAL; +} + +void +DirectionalLight::ResetSigns(void) +{ + UnitLight::ResetSigns(); + isDirectionChanged = false; +} + +} } } } // Tizen::Ui::Effects::_Runtime diff --git a/src/ui/effects/runtime/FUiEffects_RuntimeEffectModel.cpp b/src/ui/effects/runtime/FUiEffects_RuntimeEffectModel.cpp new file mode 100644 index 0000000..9dd97ed --- /dev/null +++ b/src/ui/effects/runtime/FUiEffects_RuntimeEffectModel.cpp @@ -0,0 +1,708 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeEffectModel.cpp + * @brief This file contains an implementation of EffectModel class methods + * + */ + +#include +#include +#include +#include "../FUiEffects_EffectErrorMessages.h" +#include +#include +#include "FUiEffects_RuntimeEffectModel.h" +#include "FUiEffects_RuntimeModelSurface.h" +#include "FUiEffects_RuntimeGraphicalSurface.h" +#include "FUiEffects_RuntimeRenderDataScene.h" + +using namespace Tizen::Ui::Effects; +using namespace Tizen::Ui::Effects::_PhysicsEngine; +using namespace Tizen::Ui::Effects::_Utils; +using namespace std; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +void +ModelSurfacesCollectionDeleter::operator()(TypeMSurfacesCollection* pMSurfacesCollection) +{ + TypeMSurfacesCollection::iterator it; + for (it = pMSurfacesCollection->begin(); it != pMSurfacesCollection->end(); ++it) + { + delete *it; + } + delete pMSurfacesCollection; +} + +EffectModel::EffectModel(long effectID_, + const std::string& name, + const char* pPathToScript, + IEffectModelListener* pEMListener, + EffectType effectType_, + TypeTimeEffect effectDuration_) + : __pScript(null) + , __pEMListener(pEMListener) + , __state(_EFFECT_STATE_INITIALIZING) + , __effectType(effectType_) + , __effectResult() + , __pMapElements(null) + , __pMapGSurface(null) + , __pMSurfacesCollection(null) + , __effectID(effectID_) + , __name(name) + , __effectTimePassed(0) + , __effectDuration(effectDuration_) + , __pRenderDataScene(null) +{ + __state = _EFFECT_STATE_RUNTIME_ERROR; + + unique_ptr pScript(new (std::nothrow) ScriptProcessing(pPathToScript, this)); + SysTryReturnVoidResult(NID_UI_EFFECT, pScript.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + result res = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, res == E_SUCCESS, res, GetErrorMessage(res)); + + unique_ptr pMSurfacesCollection(new (std::nothrow) TypeMSurfacesCollection, ModelSurfacesCollectionDeleter()); + SysTryReturnVoidResult(NID_UI_EFFECT, pMSurfacesCollection.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + unique_ptr pMapElements(new (std::nothrow) TypeMapElements); + SysTryReturnVoidResult(NID_UI_EFFECT, pMapElements.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + unique_ptr pMapGSurface(new (std::nothrow) TypeMapGSurface); + SysTryReturnVoidResult(NID_UI_EFFECT, pMapGSurface.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + unique_ptr pRenderDataScene(new (std::nothrow) RenderDataScene()); + SysTryReturnVoidResult(NID_UI_EFFECT, pRenderDataScene.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __state = _EFFECT_STATE_INITIALIZING; + + __pScript = std::move(pScript); + __pMSurfacesCollection = std::move(pMSurfacesCollection); + __pMapElements = std::move(pMapElements); + __pMapGSurface = std::move(pMapGSurface); + __pRenderDataScene = std::move(pRenderDataScene); + + if (pEMListener == null) + { + SysLogException(NID_UI_EFFECT, E_SYSTEM, "The pointer to EffectModelListener is null!"); + __state = _EFFECT_STATE_RUNTIME_ERROR; + } +} + +EffectModel::~EffectModel(void) +{ + +} + +void +EffectModel::AddModelSurface(ModelSurface* pMSurface) +{ + if (__state == _EFFECT_STATE_INITIALIZING) + { + __pMSurfacesCollection->push_back(pMSurface); + } + return; +} + +inline void +EffectModel::EffectInitialize(void) +{ + SysAssertf(__state == _EFFECT_STATE_FINISHING || __state == _EFFECT_STATE_INITIALIZING, _UiEffectError::INTERNAL_ERROR); + + __state = _EFFECT_STATE_INITIALIZING; + + TypeMSurfacesCollection::iterator it; + for (it = __pMSurfacesCollection->begin(); it != __pMSurfacesCollection->end(); ++it) + { + (*it)->Initialize(); + } + + InitEffectModel(); + return; +} + +int +EffectModel::Start(const EffectsVector& effectStartInfo) +{ + if (__state != _EFFECT_STATE_RUNNABLE) + { + return 1; + } + + __state = _EFFECT_STATE_STARTING; + + START_PROFILER(EFFLOG_SCRIPT) + if (!__pScript->OnEffectStart(effectStartInfo)) + { + Stop(true, false); + return 2; + } + END_PROFILER(EFFLOG_SCRIPT) + + //requesting a bitmap for each graphical surface to effect impl + RenderDataSurfaceCollection::const_iterator it; + for (it = __pRenderDataScene->GetRenderDataSurfaceCollection().begin(); it != __pRenderDataScene->GetRenderDataSurfaceCollection().end(); ++it) + { + START_PROFILER(EFFLOG_BITMAP) + if (!__pEMListener->OnBitmapRequested((*it)->bitmapId)) + { + Stop(true, false); + return 3; + } + END_PROFILER(EFFLOG_BITMAP) + } + + //sending event to effect impl about effect started + PROFILER_EXPR(__pEMListener->OnEffectStarted();, EFFLOG_OnEffectStarted); + + __state = _EFFECT_STATE_RUNNING; + return 0; +} + +void +EffectModel::Stop(bool isBreakdown, bool isInterruptedFromApplication) +{ + if (!isBreakdown) + { + if (__state != _EFFECT_STATE_RUNNING) + { + return; + } + + __state = _EFFECT_STATE_FINISHING; + if (isInterruptedFromApplication) + { + __effectResult.effectResult = EFFECT_RESULT_INTERRUPTED; + __effectResult.lastShownBitmapsId = LastShownBitmapIdCollection(1, -1); + } + __pEMListener->OnEffectFinished(__effectResult.effectResult, __effectResult.lastShownBitmapsId); + EffectInitialize(); + } + else + { + __state = _EFFECT_STATE_RUNTIME_ERROR; + __effectResult.effectResult = EFFECT_RESULT_ERROR; + __effectResult.lastShownBitmapsId = LastShownBitmapIdCollection(1, -1); + __pEMListener->OnEffectFinished(__effectResult.effectResult, __effectResult.lastShownBitmapsId); + } + return; +} + +void +EffectModel::Calculate(float dt) +{ + if (__state != _EFFECT_STATE_RUNNING) + { + return; + } + + __effectTimePassed += dt; + if (__effectTimePassed > __effectDuration && __effectDuration > std::numeric_limits::epsilon()) + { + __effectTimePassed = __effectDuration; + } + + START_PROFILER_AV(Calculate_calc_script, 50); + if (!__pScript->OnEffectCalculate(dt)) + { + Stop(true, false); + return; + } + END_PROFILER_AV(Calculate_calc_script); + + TypeMSurfacesCollection::iterator it; + START_PROFILER_AV(Calculate_calc_model, 50); + for (it = __pMSurfacesCollection->begin(); it != __pMSurfacesCollection->end(); ++it) + { + //physics calculations + (*it)->Calculate(dt); + } + END_PROFILER_AV(Calculate_calc_model); + + if (__effectType == EFFECT_TYPE_INTERACTIVE) + { + __effectResult = __pScript->IsEffectFinished(); + } + else if (__effectTimePassed >= __effectDuration && __effectDuration > std::numeric_limits::epsilon()) + { + __effectResult.effectResult = EFFECT_RESULT_FINISHED; + __effectResult.lastShownBitmapsId = LastShownBitmapIdCollection(1, 1); + } + + switch (__effectResult.effectResult) + { + case EFFECT_RESULT_FINISHED: + Stop(false, false); + break; + case EFFECT_RESULT_ERROR: + Stop(true, false); + break; + default: + break; + } + return; +} + +void +EffectModel::FeedTouchPressEvent(const TouchEventScript &pos3) +{ + SysTryReturnVoidResult(NID_UI_EFFECT, __state == _EFFECT_STATE_RUNNING, E_INVALID_STATE, _UiEffectError::FEED_TOUCH_IS_BLOCKED, __effectID, __name.c_str()); + SysTryReturnVoidResult(NID_UI_EFFECT, __effectType == EFFECT_TYPE_INTERACTIVE, E_OPERATION_FAILED, _UiEffectError::FEED_TOUCH_IS_BLOCKED, __effectID, __name.c_str()); + + if (!__pScript->OnTouchPressed(pos3)) + { + Stop(true, false); + SysLogException(NID_UI_EFFECT, E_OPERATION_FAILED, "Runtime error in OnEffectsTouchPressed Script for Effect with Id = %i and name \"%s\" is appeared. Effect is blocked!", __effectID, __name.c_str()); + } + return; +} + +void +EffectModel::FeedTouchMoveEvent(const TouchEventScript &pos3) +{ + SysTryReturnVoidResult(NID_UI_EFFECT, __state == _EFFECT_STATE_RUNNING, E_INVALID_STATE, _UiEffectError::FEED_TOUCH_IS_BLOCKED, __effectID, __name.c_str()); + SysTryReturnVoidResult(NID_UI_EFFECT, __effectType == EFFECT_TYPE_INTERACTIVE, E_OPERATION_FAILED, _UiEffectError::FEED_TOUCH_IS_BLOCKED, __effectID, __name.c_str()); + + if (!__pScript->OnTouchMoved(pos3)) + { + Stop(true, false); + SysLogException(NID_UI_EFFECT, E_OPERATION_FAILED, "Runtime error in OnEffectsTouchMoved Script for Effect with Id = %i and name \"%s\" is appeared. Effect is blocked!", __effectID, __name.c_str()); + } + return; +} + +void +EffectModel::FeedTouchReleaseEvent(const TouchEventScript &pos3) +{ + SysTryReturnVoidResult(NID_UI_EFFECT, __state == _EFFECT_STATE_RUNNING, E_INVALID_STATE, _UiEffectError::FEED_TOUCH_IS_BLOCKED, __effectID, __name.c_str()); + SysTryReturnVoidResult(NID_UI_EFFECT, __effectType == EFFECT_TYPE_INTERACTIVE, E_OPERATION_FAILED, _UiEffectError::FEED_TOUCH_IS_BLOCKED, __effectID, __name.c_str()); + + if (!__pScript->OnTouchReleased(pos3)) + { + Stop(true, false); + SysLogException(NID_UI, E_OPERATION_FAILED, "Runtime error in OnEffectsTouchReleased Script for Effect with Id = %i and name \"%s\" is appeared. Effect is blocked!", __effectID, __name.c_str()); + } + return; +} + +void +EffectModel::FeedTouchDoublePressEvent(const TouchEventScript &pos3) +{ + SysTryReturnVoidResult(NID_UI_EFFECT, __state == _EFFECT_STATE_RUNNING, E_INVALID_STATE, _UiEffectError::FEED_TOUCH_IS_BLOCKED, __effectID, __name.c_str()); + SysTryReturnVoidResult(NID_UI_EFFECT, __effectType == EFFECT_TYPE_INTERACTIVE, E_OPERATION_FAILED, _UiEffectError::FEED_TOUCH_IS_BLOCKED, __effectID, __name.c_str()); + + if (!__pScript->OnTouchDoublePressed(pos3)) + { + Stop(true, false); + SysLogException(NID_UI_EFFECT, E_OPERATION_FAILED, "Runtime error in OnEffectsTouchDoublePressed Script for Effect with Id = %i and name \"%s\" is appeared. Effect is blocked!", __effectID, __name.c_str()); + } + return; +} + +float +EffectModel::GetCalculationPeriodForTimer(void)const +{ + return __effectTimePassed; +} + +_EffectState +EffectModel::GetState(void)const +{ + return __state; +} + +EffectType +EffectModel::GetType(void)const +{ + return __effectType; +} + +bool +EffectModel::ScriptSetProperty(long objID, ElementProperty property, bool value) +{ + TypeMapElements::iterator it; + if (!FindElement(objID, it)) + { + return false; + } + return it->second->SetProperty(property, value); +} + +bool +EffectModel::ScriptSetProperty(long objID, ElementProperty property, LUA_NUMBER value) +{ + if (objID == 0) + { + bool res = true; + switch (property) + { + case N_EFFECT_DURATION: + __effectDuration = value; + break; + default: + res = false; + break; + } + return res; + } + + TypeMapElements::iterator it; + if (!FindElement(objID, it)) + { + return false; + } + return it->second->SetProperty(property, value); +} + +bool +EffectModel::ScriptSetProperty(long objID, ElementProperty property, const Vec3f &value) +{ + TypeMapElements::iterator it; + if (!FindElement(objID, it)) + { + return false; + } + return it->second->SetProperty(property, value); +} + +bool +EffectModel::ScriptSetPropertyGroup(long modelSurfaceID, GroupElements group, ElementProperty property, LUA_NUMBER value) +{ + TypeMSurfacesCollection::iterator it; + for (it = __pMSurfacesCollection->begin(); it != __pMSurfacesCollection->end(); ++it) + { + if ((*it)->GetId() == modelSurfaceID) + { + return (*it)->SetPropertyGroup(group, property, value); + } + } + return false; +} + +PropertyCast +EffectModel::ScriptGetDistanceFromGround(long modelSurfaceID) const +{ + PropertyCast propCast = {PropertyCast::NO_PROPERTY, {0} }; + TypeMSurfacesCollection::iterator it; + for (it = __pMSurfacesCollection->begin(); it != __pMSurfacesCollection->end(); ++it) + { + if ((*it)->GetId() == modelSurfaceID) + { + propCast.type = PropertyCast::NUMBER; + propCast.value.numberValue = (*it)->GetDistanceFromGround(); + return propCast; + } + } + propCast.type = PropertyCast::NO_PROPERTY; + return propCast; +} + +PropertyCast +EffectModel::ScriptGetProperty(long objID, ElementProperty property) const +{ + if (objID == 0) + { + PropertyCast propCast = {PropertyCast::NO_PROPERTY, {0}}; + switch (property) + { + case N_EFFECT_TIME_PASSED: + propCast.type = PropertyCast::NUMBER; + propCast.value.numberValue = __effectTimePassed; + break; + case N_EFFECT_DURATION: + propCast.type = PropertyCast::NUMBER; + propCast.value.numberValue = __effectDuration; + break; + default: + propCast.type = PropertyCast::NO_PROPERTY; + break; + } + return propCast; + } + + TypeMapElements::iterator it; + if (!FindElement(objID, it)) + { + PropertyCast propCast = {PropertyCast::NO_PROPERTY, {0} }; + propCast.type = PropertyCast::NO_PROPERTY; + return propCast; + } + else + { + return it->second->GetProperty(property); + } +} + +bool +EffectModel::ScriptUpdateBitmap(long graphicalSurfaceId, long bitmapId) +{ + TypeMapGSurface::iterator it; + if (!FindGraphicalSurface(graphicalSurfaceId, it)) + { + return false; + } + else + { + it->second->SetBitmapId(bitmapId); + } + return __pEMListener->OnBitmapRequested(bitmapId); +} + +RenderDataScene* +EffectModel::GetRenderingData(void) const +{ + return __pRenderDataScene.get(); +} + +PropertyCast +EffectModel::ScriptGetNearestPointsIds(long graphicalSurfaceId, Vec3f &position) const +{ + TypeMapGSurface::iterator it; + if (!FindGraphicalSurface(graphicalSurfaceId, it)) + { + PropertyCast propCast = {PropertyCast::BOOL, {false}}; + return propCast; + } + return it->second->GetNearestPointsIds(position); +} + +void +EffectModel::Construct(void) +{ + if (__state != _EFFECT_STATE_INITIALIZING) + { + return; + } + + TypeMSurfacesCollection::iterator it; + for (it = __pMSurfacesCollection->begin(); it != __pMSurfacesCollection->end(); ++it) + { + (*it)->Construct(__pMapElements.get(), __pMapGSurface.get(), &(__pRenderDataScene->__renderDataSurfaceCollection)); + } + + InitEffectModel(); + return; +} + +void +EffectModel::UpdateGraphicalSurfaces(void) +{ + if (__state == _EFFECT_STATE_RUNNING || __state == _EFFECT_STATE_STARTING || __state == _EFFECT_STATE_FINISHING) + { + TypeMSurfacesCollection::iterator it; + for ( it = __pMSurfacesCollection->begin(); it != __pMSurfacesCollection->end(); ++it ) + { + (*it)->UpdateGraphicalSurface(); + } + } + return; +} + +bool +EffectModel::ScriptRotateSurface(long graphicalSurfaceId, float angle, _Axis axis, _Point point, + float ax, float ay, float az, float x0, float y0, float z0) +{ + TypeMapGSurface::iterator it; + if (!FindGraphicalSurface(graphicalSurfaceId, it)) + { + return false; + } + else + { + return it->second->RotateSurface(angle, axis, point, + ax, ay, az, x0, y0, z0); + } +} + +bool +EffectModel::ScriptScaleSurface(long graphicalSurfaceId, float ax, float ay, float az, _Point point, + float x0, float y0, float z0) +{ + TypeMapGSurface::iterator it; + if (!FindGraphicalSurface(graphicalSurfaceId, it)) + { + return false; + } + else + { + return it->second->ScaleSurface(ax, ay, az, point, + x0, y0, z0); + } +} + +bool +EffectModel::ScriptMoveSurface(long graphicalSurfaceId, float x0, float y0, float z0) +{ + TypeMapGSurface::iterator it; + if (!FindGraphicalSurface(graphicalSurfaceId, it)) + { + return false; + } + else + { + it->second->MoveSurface(x0, y0, z0); + return true; + } +} + +bool +EffectModel::ScriptResetSurfaceTransformation(long graphicalSurfaceID) +{ + TypeMapGSurface::iterator it; + if (!FindGraphicalSurface(graphicalSurfaceID, it)) + { + return false; + } + else + { + it->second->ResetSurfaceTransformation(); + return true; + } +} + +bool +EffectModel::ScriptSetTransformationMatrix(long graphicalSurfaceID, const LuaMatrix4& luaMatrix4) +{ + TypeMapGSurface::iterator it; + if (!FindGraphicalSurface(graphicalSurfaceID, it)) + { + return false; + } + else + { + it->second->SetTransformationMatrix(luaMatrix4); + return true; + } +} + +inline bool +EffectModel::FindElement(long objID, TypeMapElements::iterator &it) const +{ + it = __pMapElements->find(objID); + return (it != __pMapElements->end()); +} + +inline bool +EffectModel::FindGraphicalSurface(long objID, TypeMapGSurface::iterator &it) const +{ + it = __pMapGSurface->find(objID); + return (it != __pMapGSurface->end()); +} + +inline void +EffectModel::InitEffectModel(void) +{ + __effectTimePassed = 0; + __effectResult.effectResult = static_cast(0); + __effectResult.lastShownBitmapsId = LastShownBitmapIdCollection(1, 1); + + if (!__pScript->Initialize()) + { + __state = _EFFECT_STATE_RUNTIME_ERROR; + } + else + { + __state = _EFFECT_STATE_RUNNABLE; + } + return; +} + +//lighting +bool +EffectModel::ScriptAddUnitLight(UnitLight& unitLight) +{ + return __pRenderDataScene->AddUnitLight(unitLight); +} + +bool +EffectModel::ScriptRemoveUnitLight(const string& name) +{ + return __pRenderDataScene->RemoveUnitLight(name); +} + +bool +EffectModel::ScriptRemoveAllUnitsLightType(TypeUnitLight typeUnitLight) +{ + return __pRenderDataScene->RemoveAllUnitsLightType(typeUnitLight); +} + +PropertyCast +EffectModel::ScriptGetUnitLight(const string& name) const +{ + return __pRenderDataScene->GetUnitLight(name); +} + +void +EffectModel::ScriptSetLightAmbientColour(const Vec3f& ambientColour) +{ + __pRenderDataScene->SetLightAmbientColour(ambientColour); + return; +} + +void +EffectModel::ScriptSetLightAmbientColour(float red, float green, float blue) +{ + __pRenderDataScene->SetLightAmbientColour(red, green, blue); + return; +} + +void +EffectModel::ScriptSetLightIntensity(float intensity) +{ + __pRenderDataScene->SetLightIntensity(intensity); + return; +} + +void +EffectModel::ScriptSetLightAttenuation(float attenuation) +{ + __pRenderDataScene->SetLightAttenuation(attenuation); + return; +} + +const Vec3f& +EffectModel::ScriptGetLightAmbientColour(void) const +{ + return __pRenderDataScene->GetLightAmbientColour(); +} + +float +EffectModel::ScriptGetLightIntensity(void) const +{ + return __pRenderDataScene->GetLightIntensity(); +} + +float +EffectModel::ScriptGetLightAttenuation(void) const +{ + return __pRenderDataScene->GetLightAttenuation(); +} +/////////////////////////////////////////////////// +long +EffectModel::GetId(void) const +{ + return __effectID; +} + +std::string +EffectModel::GetName(void) const +{ + return __name; +} + +} } } } // Tizen::Ui::Effects::_Runtime diff --git a/src/ui/effects/runtime/FUiEffects_RuntimeEffectModelScript.cpp b/src/ui/effects/runtime/FUiEffects_RuntimeEffectModelScript.cpp new file mode 100644 index 0000000..aae4dba --- /dev/null +++ b/src/ui/effects/runtime/FUiEffects_RuntimeEffectModelScript.cpp @@ -0,0 +1,235 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeEffectModelScript.cpp + * @brief This file contains an implementation of EffectModelScript class methods + * + */ + +#include +#include +#include "FUiEffects_RuntimeEffectModelScript.h" +#include + +using namespace std; +using namespace Tizen::Ui::Effects; +using namespace Tizen::Ui::Effects::_Utils; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +EffectModelScript::EffectModelScript(IEffectModelScript* pEModel) +{ + __pEModel = pEModel; + return; +} + +EffectModelScript::~EffectModelScript(void) +{ + return; +} + +PropertyCast +EffectModelScript::GetProperty(long objID, ElementProperty property) const +{ + return __pEModel->ScriptGetProperty(objID, property); +} + +bool +EffectModelScript::SetProperty(long objID, ElementProperty property, bool value) +{ + return __pEModel->ScriptSetProperty(objID, property, value); +} + +bool +EffectModelScript::SetProperty(long objID, ElementProperty property, LUA_NUMBER value) +{ + return __pEModel->ScriptSetProperty(objID, property, value); +} + +bool +EffectModelScript::SetProperty(long objID, ElementProperty property, const Vec3f &value) +{ + return __pEModel->ScriptSetProperty(objID, property, value); +} + +bool +EffectModelScript::SetPropertyGroup(long objID, GroupElements group, ElementProperty property, LUA_NUMBER value) +{ + return __pEModel->ScriptSetPropertyGroup(objID, group, property, value); +} + +PropertyCast +EffectModelScript::GetDistanceFromGround(long modelSurfaceID) const +{ + return __pEModel->ScriptGetDistanceFromGround(modelSurfaceID); +} + +bool +EffectModelScript::UpdateBitmap(long graphicalSurfaceID, long bitmapID) +{ + return __pEModel->ScriptUpdateBitmap(graphicalSurfaceID, bitmapID); +} + +PropertyCast +EffectModelScript::GetNearestPointsIds(long graphicalSurfaceID, Vec3f &position) const +{ + return __pEModel->ScriptGetNearestPointsIds(graphicalSurfaceID, position); +} + +PropertyCast +EffectModelScript::GetNearestPointsIds(long graphicalSurfaceID, float posX, float posY, float posZ) const +{ + Vec3f tempVec3(posX, posY, posZ); + return __pEModel->ScriptGetNearestPointsIds(graphicalSurfaceID, tempVec3); +} + +bool +EffectModelScript::RotateSurfaceN(long graphicalSurfaceID, float angle, _Axis axis, _Point point, + float ax, float ay, float az, float x0, float y0, float z0) +{ + return __pEModel->ScriptRotateSurface(graphicalSurfaceID, angle, axis, point, + ax, ay, az, x0, y0, z0); +} + +bool +EffectModelScript::RotateSurfaceV(long graphicalSurfaceID, float angle, _Axis axis, _Point point, + const Vec3f &axisArbit, const Vec3f &basePointArbit) +{ + return __pEModel->ScriptRotateSurface(graphicalSurfaceID, angle, axis, point, + axisArbit.x, axisArbit.y, axisArbit.z, basePointArbit.x, basePointArbit.y, basePointArbit.z); +} + +bool +EffectModelScript::ScaleSurface(long graphicalSurfaceID, float ax, float ay, float az, _Point point, + float x0, float y0, float z0) +{ + return __pEModel->ScriptScaleSurface(graphicalSurfaceID, ax, ay, az, point, + x0, y0, z0); +} + +bool +EffectModelScript::ScaleSurface(long graphicalSurfaceID, const Vec3f &multipliers, _Point point, + const Vec3f &basePopintArbit) +{ + return __pEModel->ScriptScaleSurface(graphicalSurfaceID, multipliers.x, multipliers.y, multipliers.z, point, + basePopintArbit.x, basePopintArbit.y, basePopintArbit.z); +} + +bool +EffectModelScript::MoveSurface(long graphicalSurfaceId, float x0, float y0, float z0) +{ + return __pEModel->ScriptMoveSurface(graphicalSurfaceId, x0, y0, z0); +} + +bool +EffectModelScript::MoveSurface(long graphicalSurfaceId, const Vec3f &pointTarget) +{ + return __pEModel->ScriptMoveSurface(graphicalSurfaceId, pointTarget.x, pointTarget.y, pointTarget.z); +} + +bool +EffectModelScript::ResetSurfaceTransformation(long graphicalSurfaceID) +{ + return __pEModel->ScriptResetSurfaceTransformation(graphicalSurfaceID); +} + +void +EffectModelScript::PrintLuaInfo(const char* pStr) +{ + SysLog(NID_UI_EFFECT, "%s", pStr); + return; +} + +bool +EffectModelScript::SetTransformationMatrix(long graphicalSurfaceID, const LuaMatrix4& luaMatrix4) +{ + return __pEModel->ScriptSetTransformationMatrix(graphicalSurfaceID, luaMatrix4); +} + +//lighting +bool +EffectModelScript::AddUnitLight(UnitLight& unitLight) +{ + return __pEModel->ScriptAddUnitLight(unitLight); +} + +bool +EffectModelScript::RemoveUnitLight(const std::string& name) +{ + return __pEModel->ScriptRemoveUnitLight(name); +} + +bool +EffectModelScript::RemoveAllUnitsLightType(TypeUnitLight typeUnitLight) +{ + return __pEModel->ScriptRemoveAllUnitsLightType(typeUnitLight); +} + +PropertyCast +EffectModelScript::GetUnitLight(const string& name) const +{ + return __pEModel->ScriptGetUnitLight(name); +} + +void +EffectModelScript::SetLightAmbientColour(const Vec3f& ambientColour) +{ + __pEModel->ScriptSetLightAmbientColour(ambientColour); + return; +} + +void +EffectModelScript::SetLightAmbientColour(float red, float green, float blue) +{ + __pEModel->ScriptSetLightAmbientColour(red, green, blue); + return; +} + +void +EffectModelScript::SetLightIntensity(float intensity) +{ + __pEModel->ScriptSetLightIntensity(intensity); + return; +} + +void +EffectModelScript::SetLightAttenuation(float attenuation) +{ + __pEModel->ScriptSetLightAttenuation(attenuation); + return; +} + +const Vec3f& +EffectModelScript::GetLightAmbientColour(void) const +{ + return __pEModel->ScriptGetLightAmbientColour(); +} + +float +EffectModelScript::GetLightIntensity(void) const +{ + return __pEModel->ScriptGetLightIntensity(); +} + +float +EffectModelScript::GetLightAttenuation(void) const +{ + return __pEModel->ScriptGetLightAttenuation(); +} + +} } } } // Tizen::Ui::Effects::_Runtime diff --git a/src/ui/effects/runtime/FUiEffects_RuntimeGraphicalSurface.cpp b/src/ui/effects/runtime/FUiEffects_RuntimeGraphicalSurface.cpp new file mode 100644 index 0000000..6216e06 --- /dev/null +++ b/src/ui/effects/runtime/FUiEffects_RuntimeGraphicalSurface.cpp @@ -0,0 +1,373 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeGraphicalSurface.cpp + * @brief This file contains an implementation of GraphicalSurface class methods + * + */ + +#include +#include +#include +#include "../FUiEffects_EffectErrorMessages.h" +#include "FUiEffects_RuntimeGraphicalSurface.h" + +using namespace Tizen::Ui::Effects; +using namespace Tizen::Ui::Effects::_Utils; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +#define SIGN(x) (((x) >= 0) ? (1) : (-1)) + + +GraphicalSurface::GraphicalSurface(long objId, + long bitmapID, + float transpar) + : ElementSurface(objId) + , _pRenderData(null) + , __initTransparency(transpar) + , __initBitmapID(bitmapID) + , __initModelMtr(Mat4f::getIdentity()) +{ +} + +GraphicalSurface::~GraphicalSurface(void) +{ +} + +long +GraphicalSurface::GetBitmapId(void) const +{ + return _pRenderData->bitmapId; +} + +void +GraphicalSurface::SetBitmapId(long bitmapId) +{ + _pRenderData->bitmapId = bitmapId; + _pRenderData->bitmapIdChanged = true; + return; +} + +void +GraphicalSurface::Construct(TypeElemSurfaceCollection* pElemSurfaceCollection, RenderDataSurfaceCollection* pRenderDataSurfaceCollection) +{ + pRenderDataSurfaceCollection->push_back(_pRenderData.get()); + return; +} + +PropertyCast +GraphicalSurface::GetProperty(ElementProperty propName)const +{ + PropertyCast propCast = {PropertyCast::NO_PROPERTY, {0} }; + switch (propName) + { + case N_TRANSPARENCY: + propCast.value.numberValue = _pRenderData->transparency; + propCast.type = PropertyCast::NUMBER; + break; + default: + propCast.type = PropertyCast::NO_PROPERTY; + break; + } + return propCast; +} + +bool +GraphicalSurface::SetProperty(ElementProperty propName, bool propValue) +{ + return false; +} + +bool +GraphicalSurface::SetProperty(ElementProperty propName, LUA_NUMBER propValue) +{ + switch (propName) + { + case N_TRANSPARENCY: + _pRenderData->transparency = propValue; + _pRenderData->transparencyChanged = true; + return true; + break; + default: + return false; + break; + } +} + +bool +GraphicalSurface::SetProperty(ElementProperty propName, const Vec3f &propValue) +{ + return false; +} + +void +GraphicalSurface::Initialize(void) +{ + _pRenderData->transparency = __initTransparency; + _pRenderData->transparencyChanged = true; + _pRenderData->bitmapId = __initBitmapID; + _pRenderData->bitmapIdChanged = true; + _pRenderData->modelMtr = __initModelMtr; + _pRenderData->modelMtrChanged = true; + return; +} + +PropertyCast +GraphicalSurface::GetNearestPointsIds(Vec3f &position) const +{ + IndicesCollection::iterator itIndex; + IndicesCollection::iterator itIndex1; + IndicesCollection::iterator itIndex2; + IndicesCollection::iterator itIndex3; + std::list listIndeces; + //if there are no crossing with a triangle it returns nil (in scripts) + PropertyCast res = {PropertyCast::NO_PROPERTY, {0}}; + //Finds triangles from RenderData structure which are crossed by + //a ray with position (position.x, position.y) + for (itIndex = _pRenderData->indices.begin(); itIndex != _pRenderData->indices.end(); ) + { + SysAssertf(itIndex != _pRenderData->indices.end(), _UiEffectError::INTERNAL_ERROR); + itIndex1 = itIndex++; + + SysAssertf(itIndex != _pRenderData->indices.end(), _UiEffectError::INTERNAL_ERROR); + itIndex2 = itIndex++; + + SysAssertf(itIndex != _pRenderData->indices.end(), _UiEffectError::INTERNAL_ERROR); + itIndex3 = itIndex++; + + if (InTriangle(position, *itIndex1, *itIndex2, *itIndex3)) + { + listIndeces.push_back(itIndex1); + } + } + + if (listIndeces.empty()) + { + res.type = PropertyCast::NO_PROPERTY; + } + else + { + res.type = PropertyCast::VEC3; + + std::list::iterator itList; + IndicesCollection::iterator itList1; + IndicesCollection::iterator itList2; + IndicesCollection::iterator itList3; + float maxZ = 0.f; + IndicesCollection::iterator itVertexTriangle; + //Finds z-coordinates of crossing planes of triangles from RenderData structure with + //a ray (position.x, position.y) + for (itList = listIndeces.begin(); itList != listIndeces.end(); ++itList) + { + itList1 = *itList; + itList2 = *itList+1; + itList3 = *itList+2; + float curZ = ZInPlane(position, *itList1, *itList2, *itList3); + //finding maximal z-coordinate and storing corresponding triangle + if (maxZ < curZ || itList == listIndeces.begin()) + { + maxZ = curZ; + itVertexTriangle = *itList; + } + } + + position.z = maxZ; + } + + return res; +} + +bool +GraphicalSurface::InTriangle(const Vec3f &pos, short i1, short i2, short i3) const +{ + //If point pos and any triangle vertex lie on opposite sides relatively an other side, + //then point pos lies outside of triangle + + unsigned short i = 0; + unsigned short k = 0; + unsigned short p = 0; + float c = 0.f; + float c1 = 0.f; + for (short ic = 0; ic < 3; ic++) + { + if (ic == 0) + { + i = i1; + k = i2; + p = i3; + } + else if (ic == 1) + { + i = i2; + k = i1; + p = i3; + } + else + { + i = i3; + k = i1; + p = i2; + } + + const Vec3f &point1 = _pRenderData->vnt[k].pos; + const Vec3f &point2 = _pRenderData->vnt[p].pos; + const Vec3f &pointp = _pRenderData->vnt[i].pos; + + if (fabsf(point1.x - point2.x) > std::numeric_limits::epsilon()) + { + c = (pos.x - point2.x) * (point1.y - point2.y) / (point1.x - point2.x) + point2.y; + c1 = (pointp.x - point2.x) * (point1.y-point2.y) / (point1.x - point2.x) + point2.y; + if (SIGN(pos.y - c) != SIGN(pointp.y - c1)) + { + return false; + } + } + else if (fabsf(point1.y - point2.y) > std::numeric_limits::epsilon()) + { + c = (pos.y - point2.y) * (point1.x - point2.x) / (point1.y - point2.y) + point2.x; + c1 = (pointp.y - point2.y) * (point1.x-point2.x) / (point1.y - point2.y) + point2.x; + if (SIGN(pos.x - c) != SIGN(pointp.x - c1)) + { + return false; + } + } + else + { + return false; + } + } + return true; +} + +float +GraphicalSurface::ZInPlane(const Vec3f &pos, short i1, short i2, short i3) const +{ + //restoring the plane passing through 3 triangle vertexes + //z=Ax+By+C + //Kramer's method for solving the linear equations system with 3 equations and 3 variables is used + const Vec3f &p1 = _pRenderData->vnt[i1].pos; + const Vec3f &p2 = _pRenderData->vnt[i2].pos; + const Vec3f &p3 = _pRenderData->vnt[i3].pos; + + float delta = p1.x * p2.y + p3.x * p1.y + p2.x * p3.y - p3.x * p2.y - p1.x * p3.y - p2.x * p1.y; + float deltaA = p2.y * p1.z + p1.y * p3.z + p3.y * p2.z - p2.y * p3.z - p1.y * p2.z - p3.y * p1.z; + float deltaB = p1.x * p2.z + p3.x * p1.z + p2.x * p3.z - p3.x * p2.z - p2.x * p1.z - p1.x * p3.z; + float deltaC = p1.x * p2.y * p3.z + p3.x * p1.y * p2.z + p2.x * p3.y * p1.z - p3.x * p2.y * p1.z - p1.x * p3.y * p2.z - p2.x * p1.y * p3.z; + + float res = 0.f; + //if 3 triangle vertexes lie on vertical plane, returns maximal z-coordinate of one of these points + if (fabsf(delta) <= std::numeric_limits::epsilon()) + { + float t1 = p1.z; + float t2 = p2.z; + float t3 = p3.z; + res = (t1 >= t2 ? (t1 >= t3 ? t1 : t3) : (t2 >= t3 ? t2 : t3)); + } + else + { + float koefA = deltaA / delta; + float koefB = deltaB / delta; + float koefC = deltaC / delta; + + res = koefA * pos.x + koefB * pos.y + koefC; + } + return res; +} + +void +GraphicalSurface::ResetSurfaceTransformation(void) +{ + LuaMat4 matrix4; + _pRenderData->modelMtr = matrix4; + _pRenderData->modelMtrChanged = true; + return; +} + +void +GraphicalSurface::SetTransformationMatrix(const LuaMatrix4& luaMatrix4) +{ + _pRenderData->modelMtr = luaMatrix4; + _pRenderData->modelMtrChanged = true; + return; +} + +void +GraphicalSurface::MoveSurface(float x0, float y0, float z0) +{ + LuaMat4 matrix4(_pRenderData->modelMtr); + matrix4.Translate(x0, y0, z0); + + _pRenderData->modelMtr = matrix4; + _pRenderData->modelMtrChanged = true; + + return; +} + +bool +GraphicalSurface::ScaleSurface(float ax, float ay, float az, float x0, float y0, float z0) +{ + LuaMat4 matrix4(_pRenderData->modelMtr); + bool result = matrix4.Scale(ax, ay, az, x0, y0, z0); + + if (result) + { + _pRenderData->modelMtr = matrix4; + _pRenderData->modelMtrChanged = true; + } + return result; +} + +bool +GraphicalSurface::RotateSurface(float angle, _Axis axis, + float ax, float ay, float az, float x0, float y0, float z0) +{ + bool res = false; + + LuaMat4 matrix4(_pRenderData->modelMtr); + switch (axis) + { + case AXIS_X: + matrix4.RotateAroundAxisX(angle, x0, y0, z0); + res = true; + break; + case AXIS_Y: + matrix4.RotateAroundAxisY(angle, x0, y0, z0); + res = true; + break; + case AXIS_Z: + matrix4.RotateAroundAxisZ(angle, x0, y0, z0); + res = true; + break; + case AXIS_ARBITRARY: + res = matrix4.RotateAroundAxisArbitrary(angle, ax, ay, az, x0, y0, z0); + break; + default: + res = false; + break; + } + + if (res) + { + _pRenderData->modelMtr = matrix4; + _pRenderData->modelMtrChanged = true; + } + return res; +} + +} } } } // Tizen::Ui::Effects::_Runtime diff --git a/src/ui/effects/runtime/FUiEffects_RuntimeGraphicalSurfaceNurbs.cpp b/src/ui/effects/runtime/FUiEffects_RuntimeGraphicalSurfaceNurbs.cpp new file mode 100644 index 0000000..c73cd23 --- /dev/null +++ b/src/ui/effects/runtime/FUiEffects_RuntimeGraphicalSurfaceNurbs.cpp @@ -0,0 +1,596 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeGraphicalSurfaceNurbs.cpp + * @brief This file contains an implementation of GraphicalSurfaceNurbs class methods + * + */ + +#include +#include +#include +#include +#include +#include "../FUiEffects_EffectErrorMessages.h" +#include +#include "FUiEffects_RuntimeGraphicalSurfaceNurbs.h" + +using namespace Tizen::Ui::Effects; +using namespace Tizen::Ui::Effects::_PhysicsEngine; +using namespace Tizen::Ui::Effects::_Utils; +using namespace std; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +GraphicalSurfaceNurbs::GraphicalSurfaceNurbs(long objID, + long bitmapID_, + int dimCtrlX_, + int dimCtrlY_, + int orderX_, + int orderY_, + int dimGraphX_, + int dimGraphY_, + std::unique_ptr pKnotsX_, + std::unique_ptr pKnotsY_, + float transparency_) + : GraphicalSurface(objID, bitmapID_, transparency_) + , __dimGraphX(dimGraphX_), __dimGraphY (dimGraphY_) + , __dimCtrlX(dimCtrlX_), __dimCtrlY(dimCtrlY_) + , __orderX(orderX_), __orderY(orderY_) +{ + __pKnotsX = std::move(pKnotsX_); + __pKnotsY = std::move(pKnotsY_); + + if (__dimGraphX < 2) + { + __dimGraphX = 2; + } + if (__dimGraphY < 2) + { + __dimGraphY = 2; + } + + unique_ptr pPSurfaceNURBSCollection(new (std::nothrow) TypePSurfaceNURBSCollection); + SysTryReturnVoidResult(NID_UI_EFFECT, pPSurfaceNURBSCollection.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + unique_ptr pNURBSCoeffsCollection(new (std::nothrow) TypeNURBSCoeffsCollection); + SysTryReturnVoidResult(NID_UI_EFFECT, pNURBSCoeffsCollection.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + unique_ptr pRenderData(new (std::nothrow) RenderDataSurface(__dimGraphX * __dimGraphY, (__dimGraphX - 1) * (__dimGraphY - 1) * 6)); + SysTryReturnVoidResult(NID_UI_EFFECT, pRenderData.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + unique_ptr pCornerPointsGraphSurface(new (std::nothrow) TypeCornerGrapSurPointsCollection); + SysTryReturnVoidResult(NID_UI_EFFECT, pCornerPointsGraphSurface.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + unique_ptr pCornerPointsPhysicalSurface(new (std::nothrow) TypeCornerPhysSurPointsCollection); + SysTryReturnVoidResult(NID_UI_EFFECT, pCornerPointsPhysicalSurface.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + unique_ptr pNearestPointsCollection(new (std::nothrow) TypeNearestPointsCollection); + SysTryReturnVoidResult(NID_UI_EFFECT, pNearestPointsCollection.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __pPSurfaceNURBSCollection = std::move(pPSurfaceNURBSCollection); + __pPSurfaceNURBSCollection->resize(__dimCtrlX * __dimCtrlY); + __pNURBSCoeffsCollection = std::move(pNURBSCoeffsCollection); + _pRenderData = std::move(pRenderData); + __pCornerPointsGraphSurface = std::move(pCornerPointsGraphSurface); + __pCornerPointsPhysicalSurface = std::move(pCornerPointsPhysicalSurface); + __pNearestPointsCollection = std::move(pNearestPointsCollection); + + _pRenderData->bitmapId = bitmapID_; + _pRenderData->transparency = transparency_; + + TypeNURBSCoeffsCollection::size_type size = __dimCtrlX * __dimCtrlY * __dimGraphX * __dimGraphY; + __pNURBSCoeffsCollection->resize(size); + + __pNearestPointsCollection->resize(__dimCtrlX + __dimCtrlY - 1); + (*__pNearestPointsCollection)[0].reserve(1); + TypeNearestPointsCollection::size_type sizeNearest = __pNearestPointsCollection->size(); + for (TypeNearestPointsCollection::size_type i = 1, n = 0; i < sizeNearest; ++i) + { + if (i <= sizeNearest / 2) + { + n += 4; + } + else + { + n > 4 ? n -= 4 : n = 1; + } + (*__pNearestPointsCollection)[i].reserve(n); + } +} + +GraphicalSurfaceNurbs::~GraphicalSurfaceNurbs() +{ + +} + +void +GraphicalSurfaceNurbs::Construct(TypeElemSurfaceCollection* pElemSurfaceCollection, RenderDataSurfaceCollection* pRenderDataSurfaceCollection) +{ + //constructing the collection of pointers to physical (PointSurfaceNURBS) points + TypeElemSurfaceCollection::iterator it; + TypeElemSurfaceCollection::size_type counter = 0; + for (it = pElemSurfaceCollection->begin(); it != pElemSurfaceCollection->end(); ++it) + { + if ((*it)->GetType() == ESURFACE_POINT_SURFACE_NURBS) + { + PointSurfaceNurbs* p = dynamic_cast(*it); + SysAssertf(p != null, _UiEffectError::INTERNAL_ERROR); + SysAssertf(counter < static_cast(__dimCtrlX * __dimCtrlY), _UiEffectError::INTERNAL_ERROR); + (*__pPSurfaceNURBSCollection)[counter] = p; + ++counter; + } + } + SysAssertf(!__pPSurfaceNURBSCollection->empty(), _UiEffectError::INTERNAL_ERROR); + + //constructing the corners of graphical surface as rectangular area + __pCornerPointsGraphSurface->push_back(&_pRenderData->vnt[0].pos); + __pCornerPointsGraphSurface->push_back(&_pRenderData->vnt[__dimGraphX - 1].pos); + __pCornerPointsGraphSurface->push_back(&_pRenderData->vnt[_pRenderData->vnt.size() - __dimGraphX].pos); + __pCornerPointsGraphSurface->push_back(&_pRenderData->vnt[_pRenderData->vnt.size() - 1].pos); + + //constructing the corners of physical surface as rectangular area + __pCornerPointsPhysicalSurface->push_back(&(*__pPSurfaceNURBSCollection)[0]->GetPosition()); + __pCornerPointsPhysicalSurface->push_back(&(*__pPSurfaceNURBSCollection)[__dimCtrlX - 1]->GetPosition()); + __pCornerPointsPhysicalSurface->push_back(&(*__pPSurfaceNURBSCollection)[__pPSurfaceNURBSCollection->size() - __dimCtrlX]->GetPosition()); + __pCornerPointsPhysicalSurface->push_back(&(*__pPSurfaceNURBSCollection)[__pPSurfaceNURBSCollection->size() - 1]->GetPosition()); + + //--------the order of these two functions is not important------------- + //indices calculation for triangles + CalcIndices(); + //B-spline coefficients calculation + neglecting the coefficients which less then some threshold + CalculationNurbsCoefficients(); + //--------------------------------------------------------------------- + //Synchronizes the collections of graphical and physical points + recalculates of normals + //must be called after CalcIndices(); and CalculationNurbsCoefficients(); + Initialize(); //GraphicalSurface::Initialize() + Update() + //--------------------------------------------------------------------- + //calculates the texture coordinates + //must be called after Update(); + CalcTexCoords(); + //--------------------------------------------------------------------- + + //pRenderDataSurfaceCollection construction + GraphicalSurface::Construct(null, pRenderDataSurfaceCollection); + + return; +} + +void +GraphicalSurfaceNurbs::Initialize(void) +{ + GraphicalSurface::Initialize(); + Update(); + return; +} + +PropertyCast +GraphicalSurfaceNurbs::GetNearestPointsIds(Vec3f &position) const +{ + PropertyCast result = GraphicalSurface::GetNearestPointsIds(position); + if (result.type == PropertyCast::NO_PROPERTY) + { + return result; + } + else + { + float minR2 = 0.f; + TypePSurfaceNURBSCollection::iterator it; + TypePSurfaceNURBSCollection::iterator minIt; + for (it = __pPSurfaceNURBSCollection->begin(); it != __pPSurfaceNURBSCollection->end(); ++it) + { + const Vec3f &point = (*it)->GetPosition(); + float r2 = point.distanceSqr(position); + if (it == __pPSurfaceNURBSCollection->begin() || r2 < minR2) + { + minR2 = r2; + minIt = it; + } + } + + for (TypeNearestPointsCollection::size_type i = 0; i < __pNearestPointsCollection->size(); ++i) + { + (*__pNearestPointsCollection)[i].clear(); + } + + int minRow = (*minIt)->GetRow(); + int minCol = (*minIt)->GetCol(); + for (it = __pPSurfaceNURBSCollection->begin(); it != __pPSurfaceNURBSCollection->end(); ++it) + { + int row = (*it)->GetRow(); + int col = (*it)->GetCol(); + int radious = abs(row - minRow) + abs(col - minCol); + (*__pNearestPointsCollection)[radious].push_back((*it)->GetId()); + } + + result.type = PropertyCast::VECTOR_VECTOR; + result.value.vecVecValue = __pNearestPointsCollection.get(); + } + return result; +} + +void +GraphicalSurfaceNurbs::Calculate(float timeStep) +{ + return; +} + +ESurface +GraphicalSurfaceNurbs::GetType(void) const +{ + return ESURFACE_GRAPHICAL_SURFACE_NURBS; +} + +PropertyCast +GraphicalSurfaceNurbs::GetProperty(ElementProperty propName)const +{ + return GraphicalSurface::GetProperty(propName); +} + +bool +GraphicalSurfaceNurbs::SetProperty(ElementProperty propName, bool propValue) +{ + return GraphicalSurface::SetProperty(propName, propValue); +} + +bool +GraphicalSurfaceNurbs::SetProperty(ElementProperty propName, LUA_NUMBER propValue) +{ + return GraphicalSurface::SetProperty(propName, propValue); +} + +bool +GraphicalSurfaceNurbs::SetProperty(ElementProperty propName, const Tizen::Ui::Effects::_Utils::Vec3f &propValue) +{ + return GraphicalSurface::SetProperty(propName, propValue); +} + +void +GraphicalSurfaceNurbs::Update(void) +{ + VertexDataCollection::iterator itGraph; + unsigned long pointIndex = 0; + unsigned long dataPointsCount = __dimCtrlX * __dimCtrlY; + + for (itGraph = _pRenderData->vnt.begin(); itGraph != _pRenderData->vnt.end(); ++pointIndex, ++itGraph) + { + Vec3f &pos = itGraph->pos; + + //case of corner graphical points + //(the coordinates of corner points of graphical surface and physical surface should be same (see NURBS theory)) + //(there is some inaccuracy in NURBS weights calculation by reason of floating point values precision (whatever float or double)) + bool isCorner = false; + TypeCornerGrapSurPointsCollection::iterator itG = __pCornerPointsGraphSurface->begin(); + TypeCornerPhysSurPointsCollection::iterator itP = __pCornerPointsPhysicalSurface->begin(); + for (; itG != __pCornerPointsGraphSurface->end(); ++itG, ++itP) + { + if (&pos == *itG) + { + pos = **itP; + isCorner = true; + break; + } + } + if (isCorner) + { + continue; + } + + _DataPointWeight* pointWeight = &(*__pNURBSCoeffsCollection)[pointIndex * dataPointsCount]; + + pos.x = 0.0f; + pos.y = 0.0f; + pos.z = 0.0f; + + for (unsigned long ii = 0; ii < dataPointsCount && pointWeight->pPoint != null; ++ii, ++pointWeight) + { + float &weight = pointWeight->weight; + const Vec3f &dataPoint = *pointWeight->pPoint; + + pos.x += dataPoint.x * weight; + pos.y += dataPoint.y * weight; + pos.z += dataPoint.z * weight; + } + } + + //normals recalculation + CalcNormals(); + + _pRenderData->vertexDataChanged = true; + + return; +} + +float +GraphicalSurfaceNurbs::NurbsSingleBasisFunction(long i, long order, float u, const TypeKnots &knots) const +{ + if (order == 1) + { + if (u >= knots[i] && u < knots[i + 1]) + { + return 1.0f; + } + else + { + return 0.0f; + } + } + else + { + float result = 0.0f; + static float epsilon = std::numeric_limits::epsilon(); + + if (fabs(knots[i + order - 1] - knots[i]) > epsilon) + { + result = (u - knots[i])/(knots[i + order - 1] - knots[i]) * NurbsSingleBasisFunction(i, order - 1, u, knots); + } + + if (fabs((knots[i + order] - knots[i + 1])) > epsilon) + { + result += (knots[i + order] - u)/(knots[i + order] - knots[i + 1]) * NurbsSingleBasisFunction(i + 1, order - 1, u, knots); + } + + return result; + } +} + +float +GraphicalSurfaceNurbs::SummaryForNurbs(float u, float w) const +{ + float sum = 0.f; + TypePSurfaceNURBSCollection::iterator it = __pPSurfaceNURBSCollection->begin(); + for (int i1 = 0; i1 < __dimCtrlX; ++i1) + { + for (int j1 = 0; j1 < __dimCtrlY; ++j1) + { + SysAssertf(it != __pPSurfaceNURBSCollection->end(), _UiEffectError::INTERNAL_ERROR); + sum += (*it++)->GetWeight() * NurbsSingleBasisFunction(i1, __orderX, u, *__pKnotsX) * + NurbsSingleBasisFunction(j1, __orderY, w, *__pKnotsY); + } + } + return sum; +} + +void +GraphicalSurfaceNurbs::CalculationNurbsCoefficients(void) +{ + float du = 1.0f / (__dimGraphX - 1); + float dv = 1.0f / (__dimGraphY - 1); + + TypeNURBSCoeffsCollection::iterator itCoeff = __pNURBSCoeffsCollection->begin(); + + float v = 0.0f; + for (int kv = 0; kv < __dimGraphY; ++kv) + { + float u = 0.0f; + for (int ku = 0; ku < __dimGraphX; ++ku) + { + float sum = SummaryForNurbs(u, v); + + TypePSurfaceNURBSCollection::iterator itData = __pPSurfaceNURBSCollection->begin(); + + for (int j = 0; j < __dimCtrlY; ++j) + { + for (int i = 0; i < __dimCtrlX; ++i) + { + SysAssertf(itData != __pPSurfaceNURBSCollection->end(), _UiEffectError::INTERNAL_ERROR); + SysAssertf(itCoeff != __pNURBSCoeffsCollection->end(), _UiEffectError::INTERNAL_ERROR); + + (*itCoeff).weight = (*itData)->GetWeight() * NurbsSingleBasisFunction(i, __orderX, u, *__pKnotsX); + (*itCoeff).weight *= NurbsSingleBasisFunction(j, __orderY, v, *__pKnotsY) / sum; + (*itCoeff).pPoint = &(*itData)->GetPosition(); + ++itCoeff; + ++itData; + } + } + u += du; + } + v += dv; + } + + WeightsApplyThreshold(0.0001f); + + return; +} + +void +GraphicalSurfaceNurbs::WeightsApplyThreshold(float threshold) +{ + TypeNURBSCoeffsCollection::size_type graphicalPointsCount = __dimGraphX * __dimGraphY; + TypeNURBSCoeffsCollection::size_type dataPointsCount = __dimCtrlX * __dimCtrlY; + for (unsigned long pointIndex = 0; pointIndex < graphicalPointsCount; ++pointIndex) + { + long startW = pointIndex * dataPointsCount; + long endW = startW + dataPointsCount - 1; + + for (; startW <= endW; ++startW) + { + if (fabs((*__pNURBSCoeffsCollection)[startW].weight) <= threshold) + { + (*__pNURBSCoeffsCollection)[startW] = (*__pNURBSCoeffsCollection)[endW]; + (*__pNURBSCoeffsCollection)[endW].pPoint = null; + endW--; + startW--; + } + } + } + return; +} + +void +GraphicalSurfaceNurbs::CalcIndices(void) +{ + unsigned long dimGraphXm1 = __dimGraphX - 1; + unsigned long dimGraphYm1 = __dimGraphY - 1; + + IndicesCollection::iterator it = _pRenderData->indices.begin(); + + for (unsigned short i = 0; i < dimGraphYm1; ++i) + { + for (unsigned short j = 0, poffset = __dimGraphX * i; j < dimGraphXm1; ++j, ++poffset) + { + SysAssertf(it != _pRenderData->indices.end(), _UiEffectError::INTERNAL_ERROR); + (*it++) = poffset + __dimGraphX; + + SysAssertf(it != _pRenderData->indices.end(), _UiEffectError::INTERNAL_ERROR); + (*it++) = poffset + 1; + + SysAssertf(it != _pRenderData->indices.end(), _UiEffectError::INTERNAL_ERROR); + (*it++) = poffset; + + SysAssertf(it != _pRenderData->indices.end(), _UiEffectError::INTERNAL_ERROR); + (*it++) = poffset + __dimGraphX; + + SysAssertf(it != _pRenderData->indices.end(), _UiEffectError::INTERNAL_ERROR); + (*it++) = poffset + __dimGraphX + 1; + + SysAssertf(it != _pRenderData->indices.end(), _UiEffectError::INTERNAL_ERROR); + (*it++) = poffset + 1; + } + } + return; +} + +void +GraphicalSurfaceNurbs::CalcNormals(void) +{ + IndicesCollection::iterator itIndex = _pRenderData->indices.begin(); + + unsigned long triCount = (__dimGraphX - 1) * (__dimGraphY - 1) * 2; + std::vector triNormals; + triNormals.resize(triCount); + + //calc normals for each triangle + for (unsigned long i = 0; i < triCount; ++i) + { + SysAssertf(itIndex != _pRenderData->indices.end(), _UiEffectError::INTERNAL_ERROR); + const Vec3f &tempVec0 = _pRenderData->vnt[*itIndex++].pos; + + SysAssertf(itIndex != _pRenderData->indices.end(), _UiEffectError::INTERNAL_ERROR); + const Vec3f &tempVec1 = _pRenderData->vnt[*itIndex++].pos; + + SysAssertf(itIndex != _pRenderData->indices.end(), _UiEffectError::INTERNAL_ERROR); + const Vec3f &tempVec2 = _pRenderData->vnt[*itIndex++].pos; + + triNormals[i] = Vec3f::createCrossed(tempVec2 - tempVec0, tempVec1 - tempVec0); + triNormals[i].normalize(); + } + + itIndex = _pRenderData->indices.begin(); + + //not smoothed normals + for (unsigned long i = 0; i < triCount; ++i) + { + const Vec3f &norm = triNormals[i]; + _pRenderData->vnt[*itIndex++].norm = norm; + _pRenderData->vnt[*itIndex++].norm = norm; + _pRenderData->vnt[*itIndex++].norm = norm; + } + + return; +} + +void +GraphicalSurfaceNurbs::CalcTexCoords(void) +{ + //------------------------the size of model------------------------ + const Vec3f &posBegin = _pRenderData->vnt[0].pos; + unsigned int modelSizeX = _pRenderData->vnt[__dimGraphX - 1].pos.x - posBegin.x; + unsigned int modelSizeY = _pRenderData->vnt[_pRenderData->vnt.size() - 1].pos.y - posBegin.y; + //----------------------------------------------------------------- + + VertexDataCollection::iterator itVnt = _pRenderData->vnt.begin(); + for (; itVnt!=_pRenderData->vnt.end(); ++itVnt) + { + const Vec3f &posCur = itVnt->pos - posBegin; + itVnt->texcoords.x = posCur.x / modelSizeX; + itVnt->texcoords.y = posCur.y / modelSizeY; + } + return; +} + +inline bool +GraphicalSurfaceNurbs::DefinePointOnModel(_Point point, Vec3f &pointOnModel, + float x0, float y0, float z0) const +{ + switch (point) + { + case POINT_LEFT_TOP: + pointOnModel = *(*__pCornerPointsGraphSurface)[2]; + break; + case POINT_CENTER_TOP: + pointOnModel = (*(*__pCornerPointsGraphSurface)[2] + *(*__pCornerPointsGraphSurface)[3]) / 2.f; + break; + case POINT_RIGHT_TOP: + pointOnModel = *(*__pCornerPointsGraphSurface)[3]; + break; + case POINT_LEFT_CENTER: + pointOnModel = (*(*__pCornerPointsGraphSurface)[0] + *(*__pCornerPointsGraphSurface)[2]) / 2.f; + break; + case POINT_CENTER_CENTER: + pointOnModel = (*(*__pCornerPointsGraphSurface)[1] + *(*__pCornerPointsGraphSurface)[2]) / 2.f; + break; + case POINT_RIGHT_CENTER: + pointOnModel = (*(*__pCornerPointsGraphSurface)[1] + *(*__pCornerPointsGraphSurface)[3]) / 2.f; + break; + case POINT_LEFT_BOTTOM: + pointOnModel = *(*__pCornerPointsGraphSurface)[0]; + break; + case POINT_CENTER_BOTTOM: + pointOnModel = (*(*__pCornerPointsGraphSurface)[0] + *(*__pCornerPointsGraphSurface)[1]) / 2.f; + break; + case POINT_RIGHT_BOTTOM: + pointOnModel = *(*__pCornerPointsGraphSurface)[1]; + break; + case POINT_ARBITRARY: + pointOnModel.x = x0; + pointOnModel.y = y0; + pointOnModel.z = z0; + break; + default: + return false; + break; + } + + return true; +} + +bool +GraphicalSurfaceNurbs::RotateSurface(float angle, _Axis axis, _Point point, + float ax, float ay, float az, float x0, float y0, float z0) +{ + Vec3f tempPoint; + if (!DefinePointOnModel(point, tempPoint, x0, y0, z0)) + { + return false; + } + return GraphicalSurface::RotateSurface(angle, axis, ax, ay, az, tempPoint.x, tempPoint.y, tempPoint.z); +} + +bool +GraphicalSurfaceNurbs::ScaleSurface(float ax, float ay, float az, _Point point, + float x0, float y0, float z0) +{ + Vec3f tempPoint; + if (!DefinePointOnModel(point, tempPoint, x0, y0, z0)) + { + return false; + } + return GraphicalSurface::ScaleSurface(ax, ay, az, tempPoint.x, tempPoint.y, tempPoint.z); +} + +} } } } // Tizen::Ui::Effects::_Runtime diff --git a/src/ui/effects/runtime/FUiEffects_RuntimeLuaProcessing.cpp b/src/ui/effects/runtime/FUiEffects_RuntimeLuaProcessing.cpp new file mode 100644 index 0000000..b845c10 --- /dev/null +++ b/src/ui/effects/runtime/FUiEffects_RuntimeLuaProcessing.cpp @@ -0,0 +1,246 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeLuaProcessing.cpp + * @brief This file contains an implementation of LuaProcessing class methods + * + */ +#include +#include +#include +#include +#include +#include +#include +#include <../runtime/lua-cpp-binding/tolua.h> +#include "FUiEffects_RuntimeLuaProcessing.h" +#include "../FUiEffects_EffectErrorMessages.h" + +using namespace std; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +const char* LuaProcessing::__pStringLua = " function _MyFunction510693810(scene_) \n" + " scene = scene_ \n" + " end"; + +LuaProcessing::LuaProcessing(void) + : __pLua(null) + , __pEMScript(null) +{ +} + +LuaProcessing::LuaProcessing(const char* pPathToScript, IEffectModelScript* pEModel) + : __pLua(null) + , __pEMScript(null) +{ + std::unique_ptr pLua(luaL_newstate(), LuaClose()); + SysTryReturnVoidResult(NID_UI_EFFECT, pLua.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + luaL_openlibs(pLua.get()); + tolua__open(pLua.get()); + + static const char* errorString; + switch (luaL_loadfile(pLua.get(), pPathToScript)) + { + case 0: + SysLog(NID_UI_EFFECT, "LuaProcessing: File %s was opened successfully", pPathToScript); + break; + case LUA_ERRFILE: + SysLogException(NID_UI_EFFECT, E_FILE_NOT_FOUND, "LuaProcessing: Can not open/read the file %s", pPathToScript); + break; + case LUA_ERRSYNTAX: + errorString = lua_tostring(pLua.get(), -1); + errorString = (errorString == null ? "error null" : errorString); + SysLogException(NID_UI_EFFECT, E_PARSING_FAILED, "LuaProcessing: There is syntax error during pre-compilation of file %s: %s", pPathToScript, errorString); + break; + case LUA_ERRMEM: + SysLogException(NID_UI_EFFECT, E_OUT_OF_MEMORY, "LuaProcessing: There is memory allocation error while opening the file %s", pPathToScript); + break; + default: + SysLogException(NID_UI_EFFECT, E_FILE_NOT_FOUND, "LuaProcessing: There is unknown error while opening the file %s", pPathToScript); + break; + } + + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_EFFECT, r == E_SUCCESS, r, GetErrorMessage(r)); + + int res = CallFunction("LuaProcessing", 0, LUA_MULTRET, pLua.get()); + SysTryReturnVoidResult(NID_UI_EFFECT, res == 0, GetLastResult(), GetErrorMessage(GetLastResult())); + + std::unique_ptr pEMScript(new (std::nothrow) EffectModelScript(pEModel)); + SysTryReturnVoidResult(NID_UI_EFFECT, pEMScript.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + //loading and performing the string __pStringLua + int resLoadString = luaL_dostring(pLua.get(), __pStringLua); + SysAssertf(resLoadString == 0, _UiEffectError::INTERNAL_ERROR); + lua_getfield(pLua.get(), LUA_GLOBALSINDEX, "_MyFunction510693810"); + tolua_pushusertype(pLua.get(), (void*)pEMScript.get(), "EffectModelScript"); + int resCallMyFun = lua_pcall(pLua.get(), 1, 0, 0); + SysAssertf(resCallMyFun == 0, _UiEffectError::INTERNAL_ERROR); + + __pLua = std::move(pLua); + __pEMScript = std::move(pEMScript); +} + +LuaProcessing::~LuaProcessing(void) +{ + +} + +inline bool +LuaProcessing::OnTouchEvent(const char* pFunName, const TouchEventScript& position) +{ + lua_getfield(__pLua.get(), LUA_GLOBALSINDEX, pFunName); + tolua_pushusertype(__pLua.get(), (void*)&position, "TouchEventScript"); + return (CallFunction(pFunName, 1, 0, __pLua.get()) == 0); +} + +bool +LuaProcessing::OnEffectStart(const EffectsVector& effectStartInfo) +{ + lua_getfield(__pLua.get(), LUA_GLOBALSINDEX, "OnEffectStart"); + + bool isVectorEmpty = false; + EffectsVector effectStartInfoTemp(effectStartInfo); + if (effectStartInfo.empty()) + { + isVectorEmpty = true; + effectStartInfoTemp.push_back(0.f); + } + + tolua_pushusertype(__pLua.get(), (void*)&effectStartInfoTemp, "EffectsVector"); + + if (isVectorEmpty) + { + effectStartInfoTemp.clear(); + } + + return (CallFunction("OnEffectStart", 1, 0, __pLua.get()) == 0); +} + +bool +LuaProcessing::OnEffectCalculate(float dt) +{ + lua_getfield(__pLua.get(), LUA_GLOBALSINDEX, "OnEffectCalculate"); + lua_pushnumber(__pLua.get(), dt); + return (CallFunction("OnEffectCalculate", 1, 0, __pLua.get()) == 0); +} + +bool +LuaProcessing::OnTouchPressed(const TouchEventScript &position) +{ + return OnTouchEvent("OnTouchPressed", position); +} + +bool +LuaProcessing::OnTouchDoublePressed(const TouchEventScript &position) +{ + return OnTouchEvent("OnTouchDoublePressed", position); +} + +bool +LuaProcessing::OnTouchMoved(const TouchEventScript& position) +{ + return OnTouchEvent("OnTouchMoved", position); +} + +bool +LuaProcessing::OnTouchReleased(const TouchEventScript& position) +{ + return OnTouchEvent("OnTouchReleased", position); +} + +EffectResultS +LuaProcessing::IsEffectFinished(void) +{ + EffectResultS effectRes; + + lua_getfield(__pLua.get(), LUA_GLOBALSINDEX, "IsEffectFinished"); + if (CallFunction("IsEffectFinished", 0, LUA_MULTRET, __pLua.get()) != 0) + { + effectRes.effectResult = EFFECT_RESULT_ERROR; + return effectRes; + } + + int returnsCount = lua_gettop(__pLua.get()); + effectRes.lastShownBitmapsId.clear(); + if (returnsCount == 0) + { + effectRes.effectResult = EFFECT_RESULT_ERROR; + return effectRes; + } + LUA_NUMBER res = lua_tonumber(__pLua.get(), 1); + for (int i = 2; i <= returnsCount; ++i) + { + effectRes.lastShownBitmapsId.push_back(lua_tonumber(__pLua.get(), i)); + } + lua_pop(__pLua.get(), returnsCount); + + _EffectResult tempRes = static_cast<_EffectResult>(res); + switch (tempRes) + { + case EFFECT_FINISHED: + effectRes.effectResult = EFFECT_RESULT_FINISHED; + break; + case EFFECT_CONTINUED: + effectRes.effectResult = static_cast(0); + break; + default: + effectRes.effectResult = EFFECT_RESULT_ERROR; + break; + } + return effectRes; +} + +bool +LuaProcessing::Initialize(void) +{ + lua_getfield(__pLua.get(), LUA_GLOBALSINDEX, "Initialize"); + return (CallFunction("Initialize", 0, 0, __pLua.get()) == 0); +} + +int +LuaProcessing::CallFunction(const char* pFunctionName, int argsCount, int resultsCount, lua_State* pLua) +{ + static const char* pStringError; + int res = lua_pcall(pLua, argsCount, resultsCount, 0); + switch (res) + { + case 0: + //SysLog(NID_UI_EFFECT, "LuaProcessing, %s: Script function was performed successfully", pFunctionName); + break; + case LUA_ERRRUN: + pStringError = lua_tostring(pLua, -1); + pStringError = (pStringError == null ? "error null" : pStringError); + SysLogException(NID_UI_EFFECT, E_SERVER, "LuaProcessing; %s: There is a runtime error in script: %s", pFunctionName, pStringError); + break; + case LUA_ERRMEM: + SysLogException(NID_UI_EFFECT, E_OUT_OF_MEMORY, "LuaProcessing; %s: There is memory allocation error while performing script", pFunctionName); + break; + case LUA_ERRERR: + SysLogException(NID_UI_EFFECT, E_SERVER, "LuaProcessing; %s: There is an error while running the error handler function for script", pFunctionName); + break; + default: + SysLogException(NID_UI_EFFECT, E_SERVER, "LuaProcessing; %s > There is an unknown error while performing script", pFunctionName); + break; + } + return res; +} + +} } } } // Tizen::Ui::Effects::_Runtime diff --git a/src/ui/effects/runtime/FUiEffects_RuntimeModelSurface.cpp b/src/ui/effects/runtime/FUiEffects_RuntimeModelSurface.cpp new file mode 100644 index 0000000..6295ec0 --- /dev/null +++ b/src/ui/effects/runtime/FUiEffects_RuntimeModelSurface.cpp @@ -0,0 +1,335 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeModelSurface.cpp + * @brief This file contains an implementation of ModelSurface class methods + * + */ + +#include +#include "../FUiEffects_EffectErrorMessages.h" +#include +#include +#include +#include +#include +#include "FUiEffects_RuntimeModelSurface.h" +#include "FUiEffects_RuntimeGraphicalSurface.h" +#include "FUiEffects_RuntimeModel.h" +#include "FUiEffects_RuntimePropertyCast.h" + +using namespace Tizen::Ui::Effects::_PhysicsEngine; +using namespace Tizen::Ui::Effects::_Utils; +using namespace std; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +void +ElementsSurfaceContainerDeleter::operator()(TypeElemSurfaceCollection* pElemSurfaceCollection) +{ + TypeElemSurfaceCollection::iterator it; + for (it = pElemSurfaceCollection->begin(); it != pElemSurfaceCollection->end(); ++it) + { + delete *it; + } + delete pElemSurfaceCollection; +} + +ModelSurface::ModelSurface(long objId, + unsigned short iterationCount_, + unsigned short modelSpeed_, + float envResistance_, + const Vec3f &gravityAccelerationIdentity_, + float gravityAccelerationValue_, + float groundLevel_) + : ElementSurface(objId) + , __pElemSurfaceCollection(null) + , __pGraphicalSurface(null) + , __iterationCount(iterationCount_) + , __modelSpeed(modelSpeed_) + , __envResistance(envResistance_) + , __gravityAccelerationIdentity(gravityAccelerationIdentity_) + , __gravityAccelerationValue(gravityAccelerationValue_) + , __gravityAccelerationVector(gravityAccelerationValue_ * gravityAccelerationIdentity_) + , __groundLevel(groundLevel_) + , __pPointsCollection(null) + , __pSpringsCollection(null) + , __pRodsCollection(null) +{ + unique_ptr pElemSurfaceCollection(new (std::nothrow) TypeElemSurfaceCollection, ElementsSurfaceContainerDeleter()); + SysTryReturnVoidResult(NID_UI_EFFECT, pElemSurfaceCollection.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + unique_ptr pPointsCollection(new (std::nothrow) TypePointSurfaceCollection); + SysTryReturnVoidResult(NID_UI_EFFECT, pPointsCollection.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + unique_ptr pSpringsCollection(new (std::nothrow) TypeSpringSurfaceCollection); + SysTryReturnVoidResult(NID_UI_EFFECT, pSpringsCollection.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + unique_ptr pRodsCollection(new (std::nothrow) TypeRodSurfaceCollection); + SysTryReturnVoidResult(NID_UI_EFFECT, pRodsCollection.get() != null, E_OUT_OF_MEMORY, _UiEffectError::OUT_OF_MEMORY); + + __pElemSurfaceCollection = std::move(pElemSurfaceCollection); + __pPointsCollection = std::move(pPointsCollection); + __pSpringsCollection = std::move(pSpringsCollection); + __pRodsCollection = std::move(pRodsCollection); +} + +ModelSurface::~ModelSurface(void) +{ + +} + +void +ModelSurface::Calculate(float timeStep) +{ + TypeElemSurfaceCollection::iterator it; + for (int j = 0; j < __modelSpeed; ++j) + { + for (int i = 0; i < __iterationCount; ++i) + { + for (it = __pElemSurfaceCollection->begin(); it != __pElemSurfaceCollection->end(); ++it ) + { + (*it)->Calculate(timeStep / __iterationCount); + } + } + } + return; +} + +PropertyCast +ModelSurface::GetProperty(ElementProperty propName)const +{ + PropertyCast propCast = {PropertyCast::NO_PROPERTY, {0}}; + switch (propName) + { + case N_NUMBER_ITERATIONS: + propCast.type = PropertyCast::NUMBER; + propCast.value.numberValue = __iterationCount; + break; + case N_MODEL_SPEED: + propCast.type = PropertyCast::NUMBER; + propCast.value.numberValue = __modelSpeed; + break; + case N_ENV_RESISTANCE: + propCast.type = PropertyCast::NUMBER; + propCast.value.numberValue = __envResistance; + break; + case N_GRAVITY_ACCEL_VALUE: + propCast.type = PropertyCast::NUMBER; + propCast.value.numberValue = __gravityAccelerationValue; + break; + case V_GRAVITY_ACCELERATION: + propCast.type = PropertyCast::VEC3; + propCast.value.vec3Value = &__gravityAccelerationVector; + break; + default: + propCast.type = PropertyCast::NO_PROPERTY; + break; + } + return propCast; +} + +bool +ModelSurface::SetProperty(ElementProperty propName, bool propValue) +{ + return false; +} + +bool +ModelSurface::SetProperty(ElementProperty propName, LUA_NUMBER propValue) +{ + switch (propName) + { + case N_NUMBER_ITERATIONS: + __iterationCount = propValue; + break; + case N_MODEL_SPEED: + __modelSpeed = propValue; + break; + case N_ENV_RESISTANCE: + __envResistance = propValue; + break; + case N_GRAVITY_ACCEL_VALUE: + __gravityAccelerationValue = propValue; + __gravityAccelerationVector = __gravityAccelerationValue * __gravityAccelerationIdentity; + break; + default: + return false; + break; + } + return true; +} + +bool +ModelSurface::SetProperty(ElementProperty propName, const Vec3f &propValue) +{ + switch (propName) + { + case V_GRAVITY_ACCELERATION: + __gravityAccelerationIdentity = propValue.getNormalized(); + __gravityAccelerationVector = __gravityAccelerationValue * __gravityAccelerationIdentity; + break; + default: + return false; + break; + } + + return true; +} + +bool +ModelSurface::SetPropertyGroup(GroupElements group, ElementProperty property, LUA_NUMBER value) +{ + switch (group) + { + case ALL_POINTS: + return SetPropertyGroup(__pPointsCollection.get(), property, value); + break; + case ALL_SPRINGS: + return SetPropertyGroup(__pSpringsCollection.get(), property, value); + break; + case ALL_RODS: + return SetPropertyGroup(__pRodsCollection.get(), property, value); + break; + default: + return false; + break; + } +} + +template bool +ModelSurface::SetPropertyGroup(T* pDataPointer, ElementProperty property, LUA_NUMBER value) +{ + TIter it; + TIter itBegin = pDataPointer->begin(); + TIter itEnd = pDataPointer->end(); + + if (pDataPointer->empty()) + { + return false; + } + + for (it = itBegin; it != itEnd; ++it) + { + if (!((*it)->SetProperty(property, value))) + { + return false; + } + } + return true; +} + +void +ModelSurface::Initialize(void) +{ + TypeElemSurfaceCollection::iterator it; + for (it = __pElemSurfaceCollection->begin(); it != __pElemSurfaceCollection->end(); ++it) + { + (*it)->Initialize(); + } + + __pGraphicalSurface->Initialize(); + + return; +} + +void +ModelSurface::AddGraphicalSurface(unique_ptr pGraphicalSurface) +{ + __pGraphicalSurface = std::move(pGraphicalSurface); + return; +} + +void +ModelSurface::AddElementSurface(ElementSurface* pElementSurface) +{ + __pElemSurfaceCollection->push_back(pElementSurface); + return; +} + +bool +ModelSurface::Construct(TypeMapElements* pMapElements, TypeMapGSurface* pMapGSurface, RenderDataSurfaceCollection* pRenderDataSurfaceCollection) +{ + pMapElements->insert(std::make_pair(this->GetId(), this)); + pMapElements->insert(std::make_pair(__pGraphicalSurface->GetId(), __pGraphicalSurface.get())); + pMapGSurface->insert(std::make_pair(__pGraphicalSurface->GetId(), __pGraphicalSurface.get())); + TypeElemSurfaceCollection::iterator it; + for (it = __pElemSurfaceCollection->begin(); it != __pElemSurfaceCollection->end(); ++it) + { + pMapElements->insert(std::make_pair((*it)->GetId(), *it)); + + if ((*it)->GetType() >= ESURFACE_POINT_SURFACE) + { + PointSurface* p = dynamic_cast(*it); + SysAssertf(p != null, _UiEffectError::INTERNAL_ERROR); + bool res = p->Construct(&__envResistance, &__gravityAccelerationVector, &__groundLevel); + SysTryReturn(NID_UI_EFFECT, res, false, E_SYSTEM, _UiEffectError::INTERNAL_ERROR); + + __pPointsCollection->push_back(p); + } + else if ((*it)->GetType() == ESURFACE_SPRING_SURFACE) + { + SpringSurface* p = dynamic_cast(*it); + SysAssertf(p != null, _UiEffectError::INTERNAL_ERROR); + __pSpringsCollection->push_back(p); + } + else if ((*it)->GetType() == ESURFACE_ROD_SURFACE) + { + RodSurface* p = dynamic_cast(*it); + SysAssertf(p != null, _UiEffectError::INTERNAL_ERROR); + __pRodsCollection->push_back(p); + } + } + + //constructing the collection of pointers to physical points (PointSurfaceNURBS) and + //constructing data collection for rendering + __pGraphicalSurface->Construct(__pElemSurfaceCollection.get(), pRenderDataSurfaceCollection); + + return true; +} + +void +ModelSurface::UpdateGraphicalSurface(void) +{ + __pGraphicalSurface->Update(); + return; +} + +ESurface +ModelSurface::GetType(void)const +{ + return ESURFACE_MODEL_SURFACE; +} + +float +ModelSurface::GetDistanceFromGround(void) const +{ + TypePointSurfaceCollection::iterator it; + float sum = 0.f; + for (it = __pPointsCollection->begin(); it != __pPointsCollection->end(); ++it) + { + sum += (*it)->GetPosition().z - __groundLevel; + } + + TypePointSurfaceCollection::size_type size = __pPointsCollection->size(); + + return (size == 0 ? sum : sum / size); +} + +} } } } // Tizen::Ui::Effects::_Runtime diff --git a/src/ui/effects/runtime/FUiEffects_RuntimePointLight.cpp b/src/ui/effects/runtime/FUiEffects_RuntimePointLight.cpp new file mode 100644 index 0000000..bc97308 --- /dev/null +++ b/src/ui/effects/runtime/FUiEffects_RuntimePointLight.cpp @@ -0,0 +1,124 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimePointLight.cpp + * @brief This file contains an implementation of PointLight class methods + * + */ + +#include +#include +#include + +using namespace Tizen::Ui::Effects::_Utils; +using namespace std; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +PointLight::PointLight(const string& name) + : UnitLight(name) + , isPositionChanged(false) + , __position(0.f, 0.f, 0.f) +{ + +} + +PointLight::PointLight(bool enabled, + const string& name, + const Vec3f& colour, + float intensity, + const Vec3f& position) + : UnitLight(enabled, name, colour, intensity) + , isPositionChanged(false) + , __position(position) +{ + +} + +PointLight::~PointLight(void) +{ + +} + +PointLight* +PointLight::CreatePointLight(const string& name) +{ + PointLight* pPointLight = new (std::nothrow) PointLight(name); + AddUnitLightToPool(pPointLight); + return pPointLight; +} + +PointLight* +PointLight::CreatePointLight(bool isEnabled, + const std::string& name, + const Vec3f& colour, + float intensity, + const Vec3f& position) +{ + PointLight* pPointLight = new (std::nothrow) PointLight(isEnabled, + name, + colour, + intensity, + position); + AddUnitLightToPool(pPointLight); + return pPointLight; +} + +const Vec3f& +PointLight::GetPosition(void) const +{ + return __position; +} + +void +PointLight::SetPosition(const Tizen::Ui::Effects::_Utils::Vec3f& position) +{ + SetPosition(position.x, position.y, position.z); + return; +} + +void +PointLight::SetPosition(float x, float y, float z) +{ + if (fabs(__position.x - x) > EFFECT_EPSILONF + || fabs(__position.y - y) > EFFECT_EPSILONF + || fabs(__position.z - z) > EFFECT_EPSILONF) + { + __position.x = x; + __position.y = y; + __position.z = z; + isPositionChanged = true; + isSomethingChanged = true; + } + return; +} + +TypeUnitLight +PointLight::GetType(void) const +{ + return TYPE_UNIT_LIGHT_POINT; +} + +void +PointLight::ResetSigns(void) +{ + UnitLight::ResetSigns(); + isPositionChanged = false; +} + +} } } } // Tizen::Ui::Effects::_Runtime diff --git a/src/ui/effects/runtime/FUiEffects_RuntimeRenderDataScene.cpp b/src/ui/effects/runtime/FUiEffects_RuntimeRenderDataScene.cpp new file mode 100644 index 0000000..2bc57ce --- /dev/null +++ b/src/ui/effects/runtime/FUiEffects_RuntimeRenderDataScene.cpp @@ -0,0 +1,377 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeRenderDataScene.cpp + * @brief This file contains an implementation of light structures for scene + */ + +#include +#include +#include +#include "FUiEffects_RuntimeUnitLight.h" +#include "FUiEffects_RuntimePointLight.h" +#include "FUiEffects_RuntimeSpotLight.h" +#include "FUiEffects_RuntimeDirectionalLight.h" +#include "FUiEffects_RuntimeRenderDataScene.h" + +using namespace Tizen::Ui::Effects::_Utils; +using namespace std; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +RenderDataScene::RenderDataScene(void) : + isAmbientColourChanged(false) + , isIntensityChanged(false) + , isAttenuationChanged(false) + , isSomethingChanged(false) + , __renderDataSurfaceCollection() + , __unitsLight() + , __iteratorCurrentUnitLight() + , __isLockedUnitsLightContainer(false) + , __unitLightNameTree() + , __ambientColour(0.f, 0.f, 0.f) + , __intensity(1.f) + , __attenuation(0.f) +{ + +} + +RenderDataScene::~RenderDataScene(void) +{ + while (!__unitsLight.empty()) + { + RemoveUnitLight(**(__unitsLight.begin())); + } +} + +bool +RenderDataScene::AddUnitLight(UnitLight& unitLight) +{ + UnitLight::DoesExistsInPool resExist = UnitLight::IsUnitLightInPool(unitLight); + if (__unitLightNameTree.find(unitLight.GetName()) == __unitLightNameTree.end() + && resExist.first == true) + { + __unitsLight.push_back(&unitLight); + + std::pair resNameInsertion = __unitLightNameTree.insert(std::make_pair(unitLight.GetName(), &unitLight)); + SysAssertf(resNameInsertion.second == true, _UiEffectError::INTERNAL_ERROR); + + UnlockUnitsLightContainer(); + + UnitLight::RemoveUnitLightFromPool(resExist.second); + + return true; + } + return false; +} + +void +RenderDataScene::RemoveUnitLight(UnitLight& unitLight) +{ + UnitLightCollection::iterator itUnitsLight = __unitsLight.begin(); + UnitLightCollection::iterator itUnitsLightEnd = __unitsLight.end(); + for (; itUnitsLight != itUnitsLightEnd; ++itUnitsLight) + { + if (*itUnitsLight == &unitLight) + { + break; + } + } + UnitLightNameTree::iterator itNameTree = __unitLightNameTree.find(unitLight.GetName()); + + __unitsLight.erase(itUnitsLight); + __unitLightNameTree.erase(itNameTree); + + delete &unitLight; + + UnlockUnitsLightContainer(); + + return; +} + +bool +RenderDataScene::RemoveUnitLight(const std::string& name) +{ + UnitLightNameTree::iterator itNameTree = __unitLightNameTree.find(name); + if (itNameTree != __unitLightNameTree.end()) + { + RemoveUnitLight(*(itNameTree->second)); + return true; + } + return false; +} + +bool +RenderDataScene::RemoveAllUnitsLightType(TypeUnitLight typeUnitLight) +{ + if (typeUnitLight != TYPE_UNIT_LIGHT_POINT && + typeUnitLight != TYPE_UNIT_LIGHT_SPOT && + typeUnitLight != TYPE_UNIT_LIGHT_DIRECTIONAL) + { + return false; + } + + UnitLightCollection::iterator itUnitLight = __unitsLight.begin(); + UnitLightCollection::iterator itUnitLightEnd = __unitsLight.end(); + for (; itUnitLight != itUnitLightEnd; ++itUnitLight) + { + if ((*itUnitLight)->GetType() == typeUnitLight) + { + UnitLight* pTemp = *itUnitLight; + --itUnitLight; + RemoveUnitLight(*pTemp); + } + } + + return true; +} + +PropertyCast +RenderDataScene::GetUnitLight(const string& name) const +{ + PropertyCast prop = {PropertyCast::NO_PROPERTY, {0}}; + UnitLightNameTree::const_iterator itNameTree = __unitLightNameTree.find(name); + if (itNameTree != __unitLightNameTree.end()) + { + return GetConcreteUnitLight(*(itNameTree->second)); + } + return prop; +} + +long +RenderDataScene::GetSizeUnitLightContainer(void) const +{ + return __unitsLight.size(); +} + +PropertyCast +RenderDataScene::GetConcreteUnitLight(const UnitLight& unitLight) const +{ + PropertyCast prop = {PropertyCast::NO_PROPERTY, {0}}; + switch (unitLight.GetType()) + { + case TYPE_UNIT_LIGHT_POINT: + { + const PointLight* pPointLight = dynamic_cast(&unitLight); + SysAssertf(pPointLight != null, _UiEffectError::INTERNAL_ERROR); + prop.value.pPointLight = pPointLight; + prop.type = PropertyCast::POINT_LIGHT; + } + break; + case TYPE_UNIT_LIGHT_SPOT: + { + const SpotLight* pSpotLight = dynamic_cast(&unitLight); + SysAssertf(pSpotLight != null, _UiEffectError::INTERNAL_ERROR); + prop.value.pSpotLight = pSpotLight; + prop.type = PropertyCast::SPOT_LIGHT; + } + break; + case TYPE_UNIT_LIGHT_DIRECTIONAL: + { + const DirectionalLight* pDirectionalLight = dynamic_cast(&unitLight); + SysAssertf(pDirectionalLight != null, _UiEffectError::INTERNAL_ERROR); + prop.value.pDirectionalLight = pDirectionalLight; + prop.type = PropertyCast::DIRECTIONAL_LIGHT; + } + break; + default: + break; + } + return prop; +} + +template<> const PointLight* +RenderDataScene::GetCurrentUnitLight(void) const +{ + return GetCurrentUnitLightInternal(); +} + +template<> const SpotLight* +RenderDataScene::GetCurrentUnitLight(void) const +{ + return GetCurrentUnitLightInternal(); +} + +template<> const DirectionalLight* +RenderDataScene::GetCurrentUnitLight(void) const +{ + return GetCurrentUnitLightInternal(); +} + +template<> const UnitLight* +RenderDataScene::GetCurrentUnitLight(void) const +{ + if (__isLockedUnitsLightContainer) + { + return *__iteratorCurrentUnitLight; + } + else + { + return null; + } +} + +template const T* +RenderDataScene::GetCurrentUnitLightInternal(void) const +{ + if (__isLockedUnitsLightContainer) + { + return static_cast(*__iteratorCurrentUnitLight); + } + else + { + return null; + } +} + +TypeUnitLight +RenderDataScene::GetTypeOfCurrentUnitLight(void) const +{ + if (__isLockedUnitsLightContainer) + { + return (*__iteratorCurrentUnitLight)->GetType(); + } + else + { + return static_cast(-1); + } +} + +bool +RenderDataScene::GoToNextUnitLight(void) +{ + if (__isLockedUnitsLightContainer) + { + if (++__iteratorCurrentUnitLight == __unitsLight.end()) + { + --__iteratorCurrentUnitLight; + return false; + } + return true; + } + return false; +} + +bool +RenderDataScene::LockUnitsLightContainer(void) +{ + if (!__unitsLight.empty()) + { + __isLockedUnitsLightContainer = true; + __iteratorCurrentUnitLight = __unitsLight.begin(); + return true; + } + return false; +} + +void +RenderDataScene::UnlockUnitsLightContainer(void) +{ + __isLockedUnitsLightContainer = false; + return; +} + +bool +RenderDataScene::GetIsLockedUnitsLightContainer(void) const +{ + return __isLockedUnitsLightContainer; +} + +RenderDataSurfaceCollection& +RenderDataScene::GetRenderDataSurfaceCollection(void) +{ + return __renderDataSurfaceCollection; +} + +void +RenderDataScene::SetLightAmbientColour(const Vec3f& ambientColour) +{ + SetLightAmbientColour(ambientColour.x, ambientColour.y, ambientColour.z); + return; +} + +void +RenderDataScene::SetLightAmbientColour(float red, float green, float blue) +{ + if (fabs(__ambientColour.x - red) > EFFECT_EPSILONF + || fabs(__ambientColour.y - green) > EFFECT_EPSILONF + || fabs(__ambientColour.z - blue) > EFFECT_EPSILONF) + { + __ambientColour.x = red; + __ambientColour.y = green; + __ambientColour.z = blue; + isAmbientColourChanged = true; + isSomethingChanged = true; + } + return; +} + +void +RenderDataScene::SetLightIntensity(float intensity) +{ + if (fabs(__intensity - intensity) > EFFECT_EPSILONF) + { + __intensity = intensity; + isIntensityChanged = true; + isSomethingChanged = true; + } + return; +} + +void +RenderDataScene::SetLightAttenuation(float attenuation) +{ + if (fabs(__attenuation - attenuation) > EFFECT_EPSILONF) + { + __attenuation = attenuation; + isAttenuationChanged = true; + isSomethingChanged = true; + } + return; +} + +const Vec3f& +RenderDataScene::GetLightAmbientColour(void) const +{ + return __ambientColour; +} + +float +RenderDataScene::GetLightIntensity(void) const +{ + return __intensity; +} + +float +RenderDataScene::GetLightAttenuation(void) const +{ + return __attenuation; +} + +bool +RenderDataScene::ResetSignsCurrentUnitLight(void) +{ + if (__isLockedUnitsLightContainer) + { + (*__iteratorCurrentUnitLight)->ResetSigns(); + return true; + } + return false; +} + +} } } } // Tizen::Ui::Effects::_Runtime diff --git a/src/ui/effects/runtime/FUiEffects_RuntimeSpotLight.cpp b/src/ui/effects/runtime/FUiEffects_RuntimeSpotLight.cpp new file mode 100644 index 0000000..a516359 --- /dev/null +++ b/src/ui/effects/runtime/FUiEffects_RuntimeSpotLight.cpp @@ -0,0 +1,187 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeSpotLight.cpp + * @brief This file contains an implementation of SpotLight class methods + * + */ + +#include +#include +#include + +using namespace Tizen::Ui::Effects::_Utils; +using namespace std; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +SpotLight::SpotLight(const std::string& name) + : PointLight(name) + , isTargetChanged(false) + , isAngleOpeningChanged(false) + , isAngleFadeOutChanged(false) + , __target(0.f, 0.f, -1.f) + , __angleOpening(30.f / 180.f * M_PI) + , __angleFadeOut(5.f / 180.f * M_PI) +{ + +} + +SpotLight::SpotLight(bool isEnabled, + const string& name, + const Vec3f& colour, + float intensity, + const Vec3f& position, + const Vec3f& target, + float angleOpening, + float angleFadeOut) + : PointLight(isEnabled, name, colour, intensity, position) + , isTargetChanged(false) + , isAngleOpeningChanged(false) + , isAngleFadeOutChanged(false) + , __target(target) + , __angleOpening(angleOpening) + , __angleFadeOut(angleFadeOut) +{ + +} + +SpotLight::~SpotLight(void) +{ + +} + +SpotLight* +SpotLight::CreateSpotLight(const std::string& name) +{ + SpotLight* pSpotLight = new (std::nothrow) SpotLight(name); + AddUnitLightToPool(pSpotLight); + return pSpotLight; +} + +SpotLight* +SpotLight::CreateSpotLight(bool isEnabled, + const std::string& name, + const Vec3f& colour, + float intensity, + const Vec3f& position, + const Vec3f& target, + float angleOpening, + float angleFadeOut) +{ + SpotLight* pSpotLight = new (std::nothrow) SpotLight(isEnabled, + name, + colour, + intensity, + position, + target, + angleOpening, + angleFadeOut); + AddUnitLightToPool(pSpotLight); + return pSpotLight; +} + +const Vec3f& +SpotLight::GetTarget(void) const +{ + return __target; +} + +float +SpotLight::GetAngleOpening(void) const +{ + return __angleOpening; +} + +float +SpotLight::GetAngleFadeOut(void) const +{ + return __angleFadeOut; +} + +void +SpotLight::SetTarget(const Vec3f& target) +{ + SetTarget(target.x, target.y, target.z); + return; +} + +void +SpotLight::SetTarget(float x, float y, float z) +{ + if (fabs(__target.x - x) > EFFECT_EPSILONF + || fabs(__target.y - y) > EFFECT_EPSILONF + || fabs(__target.z - z) > EFFECT_EPSILONF) + { + __target.x = x; + __target.y = y; + __target.z = z; + isTargetChanged = true; + isSomethingChanged = true; + } + return; +} + +bool +SpotLight::SetAngleOpening(float angleOpening) +{ + if (fabs(__angleOpening - angleOpening) > EFFECT_EPSILONF) + { + if (angleOpening < 0 || angleOpening > 2 * M_PI) + { + return false; + } + __angleOpening = angleOpening; + isAngleOpeningChanged = true; + isSomethingChanged = true; + } + return true; +} + +bool +SpotLight::SetAngleFadeOut(float angleFadeOut) +{ + if (fabs(__angleFadeOut - angleFadeOut) > EFFECT_EPSILONF) + { + if (angleFadeOut < 0 || angleFadeOut > M_PI - __angleOpening / 2.f) + { + return false; + } + __angleFadeOut = angleFadeOut; + isAngleFadeOutChanged = true; + isSomethingChanged = true; + } + return true; +} + +TypeUnitLight +SpotLight::GetType(void) const +{ + return TYPE_UNIT_LIGHT_SPOT; +} + +void +SpotLight::ResetSigns(void) +{ + PointLight::ResetSigns(); + isTargetChanged = false; + isAngleOpeningChanged = false; + isAngleFadeOutChanged = false; +} + +} } } } // Tizen::Ui::Effects::_Runtime diff --git a/src/ui/effects/runtime/FUiEffects_RuntimeUnitLight.cpp b/src/ui/effects/runtime/FUiEffects_RuntimeUnitLight.cpp new file mode 100644 index 0000000..63e6e73 --- /dev/null +++ b/src/ui/effects/runtime/FUiEffects_RuntimeUnitLight.cpp @@ -0,0 +1,201 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiEffects_RuntimeUnitLight.cpp + * @brief This file contains an implementation of UnitLight class methods + * + */ + +#include +#include +#include + +using namespace Tizen::Ui::Effects::_Utils; +using namespace std; + +namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime +{ + +UnitLight::ObjectsPool UnitLight::__objectsPool = UnitLight::ObjectsPool(); + +UnitLight::UnitLight(const string& name) : + isEnabledChanged(false) + , isColourChanged(false) + , isIntensityChanged(false) + , isSomethingChanged(false) + , __enabled(true) + , __name(name) + , __colour(1.f, 0.f, 0.f) + , __intensity(1.f) +{ + +} + +UnitLight::UnitLight(bool enabled, + const string& name, + const Vec3f& colour, + float intensity) : + isEnabledChanged(false) + , isColourChanged(false) + , isIntensityChanged(false) + , isSomethingChanged(false) + , __enabled(enabled) + , __name(name) + , __colour(colour) + , __intensity(intensity) +{ + +} + +UnitLight::~UnitLight(void) +{ + +} + +bool +UnitLight::GetEnabled(void) const +{ + return __enabled; +} + +const Vec3f& +UnitLight::GetColour(void) const +{ + return __colour; +} + +float +UnitLight::GetIntensity(void) const +{ + return __intensity; +} + +const string& +UnitLight::GetName(void) const +{ + return __name; +} + +void +UnitLight::SetEnabled(bool enabled) +{ + if (__enabled != enabled) + { + __enabled = enabled; + if (!isEnabledChanged) + { + isEnabledChanged = true; + isSomethingChanged = true; + } + else + { + isEnabledChanged = false; + } + } + return; +} + +void +UnitLight::SetColour(const Vec3f& colour) +{ + SetColour(colour.x, colour.y, colour.z); + return; +} + +void +UnitLight::SetColour(float red, float green, float blue) +{ + if (fabs(__colour.x - red) > EFFECT_EPSILONF + || fabs(__colour.y - green) > EFFECT_EPSILONF + || fabs(__colour.z - blue) > EFFECT_EPSILONF) + { + __colour.x = red; + __colour.y = green; + __colour.z = blue; + isColourChanged = true; + isSomethingChanged = true; + } + return; +} + +void +UnitLight::SetIntensity(float intensity) +{ + if (fabs(__intensity - intensity) > EFFECT_EPSILONF) + { + __intensity = intensity; + isIntensityChanged = true; + isSomethingChanged = true; + } +} + +void +UnitLight::ResetSigns(void) +{ + isEnabledChanged = false; + isColourChanged = false; + isIntensityChanged = false; + isSomethingChanged = false; +} + +void +UnitLight::AddUnitLightToPool(UnitLight* unitLigth) +{ + if (unitLigth == null) + { + return; + } + + SysAssertf(IsUnitLightInPool(*unitLigth).first == false, _UiEffectError::INTERNAL_ERROR); + __objectsPool.push_back(unitLigth); + + return; +} + +void +UnitLight::ReleaseObjectsPool(void) +{ + ObjectsPool::iterator it = __objectsPool.begin(); + for (; it != __objectsPool.end(); ++it) + { + SysAssertf(*it != null, _UiEffectError::INTERNAL_ERROR); + delete *it; + } + __objectsPool.clear(); +} + +UnitLight::DoesExistsInPool +UnitLight::IsUnitLightInPool(UnitLight& unitLight) +{ + ObjectsPool::iterator it = __objectsPool.begin(); + for (; it != __objectsPool.end(); ++it) + { + if (&unitLight == *it) + { + return make_pair(true, it); + } + } + return make_pair(false, __objectsPool.end()); +} + +void +UnitLight::RemoveUnitLightFromPool(ObjectsPool::iterator it) +{ + __objectsPool.erase(it); +} + +} } } } // Tizen::Ui::Effects::_Runtime diff --git a/src/ui/effects/runtime/lua-cpp-binding/tolua.cpp b/src/ui/effects/runtime/lua-cpp-binding/tolua.cpp new file mode 100644 index 0000000..66eb75d --- /dev/null +++ b/src/ui/effects/runtime/lua-cpp-binding/tolua.cpp @@ -0,0 +1,6872 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 __cplusplus +#include "stdlib.h" +#endif +#include "string.h" + +#include "tolua++.h" + +/* Exported function */ +TOLUA_API int tolua__open (lua_State* tolua_S); + +#include +#include +#include +#include "../../inc/FUiEffects_RuntimeEffectModelScript.h" +#include "../../inc/FUiEffects_RuntimeModel.h" +#include "../../inc/FUiEffects_RuntimePropertyCast.h" +#include "../../inc/FUiEffects_RuntimeUnitLight.h" +#include "../../inc/FUiEffects_RuntimePointLight.h" +#include "../../inc/FUiEffects_RuntimeSpotLight.h" +#include "../../inc/FUiEffects_RuntimeDirectionalLight.h" +#ifndef _DEBUG +#define TOLUA_RELEASE +#endif +using namespace Tizen::Ui::Effects::_Utils; +using namespace Tizen::Ui::Effects::_Runtime; +using namespace Tizen::Ui::Effects; +using namespace std; + + static int SetMetatable(lua_State* tolua_S, const char* type, const char* operation, lua_CFunction func) +{ + char ctype[128] = "const "; + strcat(ctype,type); + const char* types[2] = {type, ctype}; + + for (short i = 0; i < 2; ++i) + { + luaL_getmetatable(tolua_S, types[i]); + lua_pushstring(tolua_S, operation); + lua_pushcfunction(tolua_S, func); + lua_rawset(tolua_S, -3); + lua_pop(tolua_S, 1); + } + + return 1; +} + +/* function to release collected object via destructor */ +#ifdef __cplusplus + +static int tolua_collect_PropertyCast (lua_State* tolua_S) +{ + PropertyCast* self = (PropertyCast*) tolua_tousertype(tolua_S,1,0); + Mtolua_delete(self); + return 0; +} + +static int tolua_collect_Vector2 (lua_State* tolua_S) +{ + Vector2* self = (Vector2*) tolua_tousertype(tolua_S,1,0); + Mtolua_delete(self); + return 0; +} + +static int tolua_collect_LuaMatrix4 (lua_State* tolua_S) +{ + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + Mtolua_delete(self); + return 0; +} + +static int tolua_collect_EffectsVector_long_ (lua_State* tolua_S) +{ + EffectsVector* self = (EffectsVector*) tolua_tousertype(tolua_S,1,0); + Mtolua_delete(self); + return 0; +} + +static int tolua_collect_Vector3 (lua_State* tolua_S) +{ + Vector3* self = (Vector3*) tolua_tousertype(tolua_S,1,0); + Mtolua_delete(self); + return 0; +} +#endif + + +/* function to register type */ +static void tolua_reg_types (lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"LuaMatrix4"); + tolua_usertype(tolua_S,"EffectsVector"); + tolua_usertype(tolua_S,"PropertyCast"); + tolua_usertype(tolua_S,"EffectsVector >"); + tolua_usertype(tolua_S,"SpotLight"); + tolua_usertype(tolua_S,"Vector2"); + tolua_usertype(tolua_S,"EffectModelScript"); + tolua_usertype(tolua_S,"PointLight"); + tolua_usertype(tolua_S,"Vector3"); + tolua_usertype(tolua_S,"TouchEventScript"); + tolua_usertype(tolua_S,"EffectsVector"); + tolua_usertype(tolua_S,"DirectionalLight"); + tolua_usertype(tolua_S,"PropertyCast::TypeValue"); + tolua_usertype(tolua_S,"UnitLight"); +} + +/* method: GetProperty of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_GetProperty00 +static int tolua__EffectModelScript_GetProperty00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectModelScript* self = (const EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long objID = ((long) tolua_tonumber(tolua_S,2,0)); + ElementProperty property = ((ElementProperty) (int) tolua_tonumber(tolua_S,3,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetProperty'", NULL); +#endif + { + PropertyCast tolua_ret = (PropertyCast) self->GetProperty(objID,property); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((PropertyCast)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"PropertyCast"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(PropertyCast)); + tolua_pushusertype(tolua_S,tolua_obj,"PropertyCast"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetProperty'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetProperty of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_SetProperty00 +static int tolua__EffectModelScript_SetProperty00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isboolean(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long objID = ((long) tolua_tonumber(tolua_S,2,0)); + ElementProperty property = ((ElementProperty) (int) tolua_tonumber(tolua_S,3,0)); + bool value = ((bool) tolua_toboolean(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetProperty'", NULL); +#endif + { + bool tolua_ret = (bool) self->SetProperty(objID,property,value); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetProperty'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetProperty of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_SetProperty01 +static int tolua__EffectModelScript_SetProperty01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long objID = ((long) tolua_tonumber(tolua_S,2,0)); + ElementProperty property = ((ElementProperty) (int) tolua_tonumber(tolua_S,3,0)); + LUA_NUMBER value = ((LUA_NUMBER) tolua_tonumber(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetProperty'", NULL); +#endif + { + bool tolua_ret = (bool) self->SetProperty(objID,property,value); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +tolua_lerror: + return tolua__EffectModelScript_SetProperty00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetProperty of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_SetProperty02 +static int tolua__EffectModelScript_SetProperty02(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + (tolua_isvaluenil(tolua_S,4,&tolua_err) || !tolua_isusertype(tolua_S,4,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long objID = ((long) tolua_tonumber(tolua_S,2,0)); + ElementProperty property = ((ElementProperty) (int) tolua_tonumber(tolua_S,3,0)); + const Vector3* value = ((const Vector3*) tolua_tousertype(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetProperty'", NULL); +#endif + { + bool tolua_ret = (bool) self->SetProperty(objID,property,*value); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +tolua_lerror: + return tolua__EffectModelScript_SetProperty01(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetPropertyGroup of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_SetPropertyGroup00 +static int tolua__EffectModelScript_SetPropertyGroup00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long modelSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + GroupElements group = ((GroupElements) (int) tolua_tonumber(tolua_S,3,0)); + ElementProperty property = ((ElementProperty) (int) tolua_tonumber(tolua_S,4,0)); + LUA_NUMBER value = ((LUA_NUMBER) tolua_tonumber(tolua_S,5,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPropertyGroup'", NULL); +#endif + { + bool tolua_ret = (bool) self->SetPropertyGroup(modelSurfaceID,group,property,value); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetPropertyGroup'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetDistanceFromGround of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_GetDistanceFromGround00 +static int tolua__EffectModelScript_GetDistanceFromGround00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectModelScript* self = (const EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long modelSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetDistanceFromGround'", NULL); +#endif + { + PropertyCast tolua_ret = (PropertyCast) self->GetDistanceFromGround(modelSurfaceID); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((PropertyCast)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"PropertyCast"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(PropertyCast)); + tolua_pushusertype(tolua_S,tolua_obj,"PropertyCast"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetDistanceFromGround'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: UpdateBitmap of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_UpdateBitmap00 +static int tolua__EffectModelScript_UpdateBitmap00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + long bitmapID = ((long) tolua_tonumber(tolua_S,3,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'UpdateBitmap'", NULL); +#endif + { + bool tolua_ret = (bool) self->UpdateBitmap(graphicalSurfaceID,bitmapID); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'UpdateBitmap'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetNearestPointsIds of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_GetNearestPointsIds00 +static int tolua__EffectModelScript_GetNearestPointsIds00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectModelScript* self = (const EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + Vector3* position = ((Vector3*) tolua_tousertype(tolua_S,3,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetNearestPointsIds'", NULL); +#endif + { + PropertyCast tolua_ret = (PropertyCast) self->GetNearestPointsIds(graphicalSurfaceID,*position); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((PropertyCast)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"PropertyCast"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(PropertyCast)); + tolua_pushusertype(tolua_S,tolua_obj,"PropertyCast"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetNearestPointsIds'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetNearestPointsIds of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_GetNearestPointsIds01 +static int tolua__EffectModelScript_GetNearestPointsIds01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) + ) + goto tolua_lerror; + else + { + const EffectModelScript* self = (const EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + float posX = ((float) tolua_tonumber(tolua_S,3,0)); + float posY = ((float) tolua_tonumber(tolua_S,4,0)); + float posZ = ((float) tolua_tonumber(tolua_S,5,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetNearestPointsIds'", NULL); +#endif + { + PropertyCast tolua_ret = (PropertyCast) self->GetNearestPointsIds(graphicalSurfaceID,posX,posY,posZ); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((PropertyCast)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"PropertyCast"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(PropertyCast)); + tolua_pushusertype(tolua_S,tolua_obj,"PropertyCast"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + return tolua__EffectModelScript_GetNearestPointsIds00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RotateSurfaceN of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_RotateSurfaceN00 +static int tolua__EffectModelScript_RotateSurfaceN00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,1,&tolua_err) || + !tolua_isnumber(tolua_S,7,1,&tolua_err) || + !tolua_isnumber(tolua_S,8,1,&tolua_err) || + !tolua_isnumber(tolua_S,9,1,&tolua_err) || + !tolua_isnumber(tolua_S,10,1,&tolua_err) || + !tolua_isnumber(tolua_S,11,1,&tolua_err) || + !tolua_isnoobj(tolua_S,12,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + float angle = ((float) tolua_tonumber(tolua_S,3,0)); + _Axis axis = ((_Axis) (int) tolua_tonumber(tolua_S,4,0)); + _Point point = ((_Point) (int) tolua_tonumber(tolua_S,5,0)); + float ax = ((float) tolua_tonumber(tolua_S,6,0.f)); + float ay = ((float) tolua_tonumber(tolua_S,7,0.f)); + float az = ((float) tolua_tonumber(tolua_S,8,1.f)); + float x0 = ((float) tolua_tonumber(tolua_S,9,0.f)); + float y0 = ((float) tolua_tonumber(tolua_S,10,0.f)); + float z0 = ((float) tolua_tonumber(tolua_S,11,0.f)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RotateSurfaceN'", NULL); +#endif + { + bool tolua_ret = (bool) self->RotateSurfaceN(graphicalSurfaceID,angle,axis,point,ax,ay,az,x0,y0,z0); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'RotateSurfaceN'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RotateSurfaceV of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_RotateSurfaceV00 +static int tolua__EffectModelScript_RotateSurfaceV00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + float angle = ((float) tolua_tonumber(tolua_S,3,0)); + _Axis axis = ((_Axis) (int) tolua_tonumber(tolua_S,4,0)); + _Point point = ((_Point) (int) tolua_tonumber(tolua_S,5,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RotateSurfaceV'", NULL); +#endif + { + bool tolua_ret = (bool) self->RotateSurfaceV(graphicalSurfaceID,angle,axis,point); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'RotateSurfaceV'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RotateSurfaceV of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_RotateSurfaceV01 +static int tolua__EffectModelScript_RotateSurfaceV01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + (tolua_isvaluenil(tolua_S,6,&tolua_err) || !tolua_isusertype(tolua_S,6,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,7,&tolua_err) + ) + goto tolua_lerror; + else + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + float angle = ((float) tolua_tonumber(tolua_S,3,0)); + _Axis axis = ((_Axis) (int) tolua_tonumber(tolua_S,4,0)); + _Point point = ((_Point) (int) tolua_tonumber(tolua_S,5,0)); + const Vector3* axisArbit = ((const Vector3*) tolua_tousertype(tolua_S,6,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RotateSurfaceV'", NULL); +#endif + { + bool tolua_ret = (bool) self->RotateSurfaceV(graphicalSurfaceID,angle,axis,point,*axisArbit); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +tolua_lerror: + return tolua__EffectModelScript_RotateSurfaceV00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RotateSurfaceV of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_RotateSurfaceV02 +static int tolua__EffectModelScript_RotateSurfaceV02(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + (tolua_isvaluenil(tolua_S,6,&tolua_err) || !tolua_isusertype(tolua_S,6,"const Vector3",0,&tolua_err)) || + (tolua_isvaluenil(tolua_S,7,&tolua_err) || !tolua_isusertype(tolua_S,7,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,8,&tolua_err) + ) + goto tolua_lerror; + else + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + float angle = ((float) tolua_tonumber(tolua_S,3,0)); + _Axis axis = ((_Axis) (int) tolua_tonumber(tolua_S,4,0)); + _Point point = ((_Point) (int) tolua_tonumber(tolua_S,5,0)); + const Vector3* axisArbit = ((const Vector3*) tolua_tousertype(tolua_S,6,0)); + const Vector3* basePointArbit = ((const Vector3*) tolua_tousertype(tolua_S,7,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RotateSurfaceV'", NULL); +#endif + { + bool tolua_ret = (bool) self->RotateSurfaceV(graphicalSurfaceID,angle,axis,point,*axisArbit,*basePointArbit); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +tolua_lerror: + return tolua__EffectModelScript_RotateSurfaceV01(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: ScaleSurface of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_ScaleSurface00 +static int tolua__EffectModelScript_ScaleSurface00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,0,&tolua_err) || + !tolua_isnumber(tolua_S,7,1,&tolua_err) || + !tolua_isnumber(tolua_S,8,1,&tolua_err) || + !tolua_isnumber(tolua_S,9,1,&tolua_err) || + !tolua_isnoobj(tolua_S,10,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + float ax = ((float) tolua_tonumber(tolua_S,3,0)); + float ay = ((float) tolua_tonumber(tolua_S,4,0)); + float az = ((float) tolua_tonumber(tolua_S,5,0)); + _Point point = ((_Point) (int) tolua_tonumber(tolua_S,6,0)); + float x0 = ((float) tolua_tonumber(tolua_S,7,0.f)); + float y0 = ((float) tolua_tonumber(tolua_S,8,0.f)); + float z0 = ((float) tolua_tonumber(tolua_S,9,0.f)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ScaleSurface'", NULL); +#endif + { + bool tolua_ret = (bool) self->ScaleSurface(graphicalSurfaceID,ax,ay,az,point,x0,y0,z0); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'ScaleSurface'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: ScaleSurface of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_ScaleSurface01 +static int tolua__EffectModelScript_ScaleSurface01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"const Vector3",0,&tolua_err)) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + const Vector3* multipliers = ((const Vector3*) tolua_tousertype(tolua_S,3,0)); + _Point point = ((_Point) (int) tolua_tonumber(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ScaleSurface'", NULL); +#endif + { + bool tolua_ret = (bool) self->ScaleSurface(graphicalSurfaceID,*multipliers,point); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +tolua_lerror: + return tolua__EffectModelScript_ScaleSurface00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: ScaleSurface of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_ScaleSurface02 +static int tolua__EffectModelScript_ScaleSurface02(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"const Vector3",0,&tolua_err)) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + (tolua_isvaluenil(tolua_S,5,&tolua_err) || !tolua_isusertype(tolua_S,5,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,6,&tolua_err) + ) + goto tolua_lerror; + else + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + const Vector3* multipliers = ((const Vector3*) tolua_tousertype(tolua_S,3,0)); + _Point point = ((_Point) (int) tolua_tonumber(tolua_S,4,0)); + const Vector3* basePoint = ((const Vector3*) tolua_tousertype(tolua_S,5,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ScaleSurface'", NULL); +#endif + { + bool tolua_ret = (bool) self->ScaleSurface(graphicalSurfaceID,*multipliers,point,*basePoint); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +tolua_lerror: + return tolua__EffectModelScript_ScaleSurface01(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: MoveSurface of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_MoveSurface00 +static int tolua__EffectModelScript_MoveSurface00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + float x0 = ((float) tolua_tonumber(tolua_S,3,0)); + float y0 = ((float) tolua_tonumber(tolua_S,4,0)); + float z0 = ((float) tolua_tonumber(tolua_S,5,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'MoveSurface'", NULL); +#endif + { + bool tolua_ret = (bool) self->MoveSurface(graphicalSurfaceID,x0,y0,z0); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'MoveSurface'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: MoveSurface of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_MoveSurface01 +static int tolua__EffectModelScript_MoveSurface01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + const Vector3* pointTarget = ((const Vector3*) tolua_tousertype(tolua_S,3,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'MoveSurface'", NULL); +#endif + { + bool tolua_ret = (bool) self->MoveSurface(graphicalSurfaceID,*pointTarget); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +tolua_lerror: + return tolua__EffectModelScript_MoveSurface00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: ResetSurfaceTransformation of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_ResetSurfaceTransformation00 +static int tolua__EffectModelScript_ResetSurfaceTransformation00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ResetSurfaceTransformation'", NULL); +#endif + { + bool tolua_ret = (bool) self->ResetSurfaceTransformation(graphicalSurfaceID); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'ResetSurfaceTransformation'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: PrintLuaInfo of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_PrintLuaInfo00 +static int tolua__EffectModelScript_PrintLuaInfo00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isstring(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const char* pStr = ((const char*) tolua_tostring(tolua_S,2,0)); + { + EffectModelScript::PrintLuaInfo(pStr); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'PrintLuaInfo'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetTransformationMatrix of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_SetTransformationMatrix00 +static int tolua__EffectModelScript_SetTransformationMatrix00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"const LuaMatrix4",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + long graphicalSurfaceID = ((long) tolua_tonumber(tolua_S,2,0)); + const LuaMatrix4* luaMatrix4 = ((const LuaMatrix4*) tolua_tousertype(tolua_S,3,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetTransformationMatrix'", NULL); +#endif + { + bool tolua_ret = (bool) self->SetTransformationMatrix(graphicalSurfaceID,*luaMatrix4); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetTransformationMatrix'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: AddUnitLight of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_AddUnitLight00 +static int tolua__EffectModelScript_AddUnitLight00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"UnitLight",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + UnitLight* unitLight = ((UnitLight*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'AddUnitLight'", NULL); +#endif + { + bool tolua_ret = (bool) self->AddUnitLight(*unitLight); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'AddUnitLight'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RemoveUnitLight of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_RemoveUnitLight00 +static int tolua__EffectModelScript_RemoveUnitLight00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_iscppstring(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + const string name = ((const string) tolua_tocppstring(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RemoveUnitLight'", NULL); +#endif + { + bool tolua_ret = (bool) self->RemoveUnitLight(name); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + tolua_pushcppstring(tolua_S,(const char*)name); + } + } + return 2; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'RemoveUnitLight'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RemoveAllUnitsLightType of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_RemoveAllUnitsLightType00 +static int tolua__EffectModelScript_RemoveAllUnitsLightType00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + TypeUnitLight typeUnitLight = ((TypeUnitLight) (int) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RemoveAllUnitsLightType'", NULL); +#endif + { + bool tolua_ret = (bool) self->RemoveAllUnitsLightType(typeUnitLight); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'RemoveAllUnitsLightType'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetUnitLight of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_GetUnitLight00 +static int tolua__EffectModelScript_GetUnitLight00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectModelScript",0,&tolua_err) || + !tolua_iscppstring(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectModelScript* self = (const EffectModelScript*) tolua_tousertype(tolua_S,1,0); + const string name = ((const string) tolua_tocppstring(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetUnitLight'", NULL); +#endif + { + PropertyCast tolua_ret = (PropertyCast) self->GetUnitLight(name); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((PropertyCast)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"PropertyCast"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(PropertyCast)); + tolua_pushusertype(tolua_S,tolua_obj,"PropertyCast"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + tolua_pushcppstring(tolua_S,(const char*)name); + } + } + return 2; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetUnitLight'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetLightAmbientColour of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_SetLightAmbientColour00 +static int tolua__EffectModelScript_SetLightAmbientColour00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + const Vector3* ambientColour = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetLightAmbientColour'", NULL); +#endif + { + self->SetLightAmbientColour(*ambientColour); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetLightAmbientColour'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetLightAmbientColour of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_SetLightAmbientColour01 +static int tolua__EffectModelScript_SetLightAmbientColour01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + float red = ((float) tolua_tonumber(tolua_S,2,0)); + float green = ((float) tolua_tonumber(tolua_S,3,0)); + float blue = ((float) tolua_tonumber(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetLightAmbientColour'", NULL); +#endif + { + self->SetLightAmbientColour(red,green,blue); + } + } + return 0; +tolua_lerror: + return tolua__EffectModelScript_SetLightAmbientColour00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetLightIntensity of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_SetLightIntensity00 +static int tolua__EffectModelScript_SetLightIntensity00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + float intensity = ((float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetLightIntensity'", NULL); +#endif + { + self->SetLightIntensity(intensity); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetLightIntensity'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetLightAttenuation of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_SetLightAttenuation00 +static int tolua__EffectModelScript_SetLightAttenuation00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"EffectModelScript",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + EffectModelScript* self = (EffectModelScript*) tolua_tousertype(tolua_S,1,0); + float attenuation = ((float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetLightAttenuation'", NULL); +#endif + { + self->SetLightAttenuation(attenuation); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetLightAttenuation'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetLightAmbientColour of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_GetLightAmbientColour00 +static int tolua__EffectModelScript_GetLightAmbientColour00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectModelScript",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectModelScript* self = (const EffectModelScript*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLightAmbientColour'", NULL); +#endif + { + const Vector3& tolua_ret = (const Vector3&) self->GetLightAmbientColour(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"const Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(const Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"const Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetLightAmbientColour'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetLightIntensity of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_GetLightIntensity00 +static int tolua__EffectModelScript_GetLightIntensity00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectModelScript",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectModelScript* self = (const EffectModelScript*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLightIntensity'", NULL); +#endif + { + float tolua_ret = (float) self->GetLightIntensity(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetLightIntensity'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetLightAttenuation of class EffectModelScript */ +#ifndef TOLUA_DISABLE_tolua__EffectModelScript_GetLightAttenuation00 +static int tolua__EffectModelScript_GetLightAttenuation00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectModelScript",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectModelScript* self = (const EffectModelScript*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLightAttenuation'", NULL); +#endif + { + float tolua_ret = (float) self->GetLightAttenuation(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetLightAttenuation'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: currentPosition of class TouchEventScript */ +#ifndef TOLUA_DISABLE_tolua_get_TouchEventScript_currentPosition +static int tolua_get_TouchEventScript_currentPosition(lua_State* tolua_S) +{ + TouchEventScript* self = (TouchEventScript*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'currentPosition'",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)&self->currentPosition,"Vector3"); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: currentPosition of class TouchEventScript */ +#ifndef TOLUA_DISABLE_tolua_set_TouchEventScript_currentPosition +static int tolua_set_TouchEventScript_currentPosition(lua_State* tolua_S) +{ + TouchEventScript* self = (TouchEventScript*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'currentPosition'",NULL); + if ((tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"Vector3",0,&tolua_err))) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->currentPosition = *((Vector3*) tolua_tousertype(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: startPosition of class TouchEventScript */ +#ifndef TOLUA_DISABLE_tolua_get_TouchEventScript_startPosition +static int tolua_get_TouchEventScript_startPosition(lua_State* tolua_S) +{ + TouchEventScript* self = (TouchEventScript*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'startPosition'",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)&self->startPosition,"Vector3"); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: startPosition of class TouchEventScript */ +#ifndef TOLUA_DISABLE_tolua_set_TouchEventScript_startPosition +static int tolua_set_TouchEventScript_startPosition(lua_State* tolua_S) +{ + TouchEventScript* self = (TouchEventScript*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'startPosition'",NULL); + if ((tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"Vector3",0,&tolua_err))) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->startPosition = *((Vector3*) tolua_tousertype(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: touchId of class TouchEventScript */ +#ifndef TOLUA_DISABLE_tolua_get_TouchEventScript_unsigned_touchId +static int tolua_get_TouchEventScript_unsigned_touchId(lua_State* tolua_S) +{ + TouchEventScript* self = (TouchEventScript*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'touchId'",NULL); +#endif + tolua_pushnumber(tolua_S,(lua_Number)self->touchId); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: touchId of class TouchEventScript */ +#ifndef TOLUA_DISABLE_tolua_set_TouchEventScript_unsigned_touchId +static int tolua_set_TouchEventScript_unsigned_touchId(lua_State* tolua_S) +{ + TouchEventScript* self = (TouchEventScript*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'touchId'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->touchId = ((unsigned long) tolua_tonumber(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: type of class PropertyCast */ +#ifndef TOLUA_DISABLE_tolua_get_PropertyCast_type +static int tolua_get_PropertyCast_type(lua_State* tolua_S) +{ + PropertyCast* self = (PropertyCast*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'type'",NULL); +#endif + tolua_pushnumber(tolua_S,(lua_Number)self->type); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: numberValue of class TypeValue */ +#ifndef TOLUA_DISABLE_tolua_get_PropertyCast__TypeValue_numberValue +static int tolua_get_PropertyCast__TypeValue_numberValue(lua_State* tolua_S) +{ + PropertyCast::TypeValue* self = (PropertyCast::TypeValue*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'numberValue'",NULL); +#endif + tolua_pushnumber(tolua_S,(lua_Number)self->numberValue); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: numberValue of class TypeValue */ +#ifndef TOLUA_DISABLE_tolua_set_PropertyCast__TypeValue_numberValue +static int tolua_set_PropertyCast__TypeValue_numberValue(lua_State* tolua_S) +{ + PropertyCast::TypeValue* self = (PropertyCast::TypeValue*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'numberValue'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->numberValue = ((LUA_NUMBER) tolua_tonumber(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: boolValue of class TypeValue */ +#ifndef TOLUA_DISABLE_tolua_get_PropertyCast__TypeValue_boolValue +static int tolua_get_PropertyCast__TypeValue_boolValue(lua_State* tolua_S) +{ + PropertyCast::TypeValue* self = (PropertyCast::TypeValue*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'boolValue'",NULL); +#endif + tolua_pushboolean(tolua_S,(bool)self->boolValue); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: boolValue of class TypeValue */ +#ifndef TOLUA_DISABLE_tolua_set_PropertyCast__TypeValue_boolValue +static int tolua_set_PropertyCast__TypeValue_boolValue(lua_State* tolua_S) +{ + PropertyCast::TypeValue* self = (PropertyCast::TypeValue*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'boolValue'",NULL); + if (!tolua_isboolean(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->boolValue = ((bool) tolua_toboolean(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: vec3Value of class TypeValue */ +#ifndef TOLUA_DISABLE_tolua_get_PropertyCast__TypeValue_vec3Value_ptr +static int tolua_get_PropertyCast__TypeValue_vec3Value_ptr(lua_State* tolua_S) +{ + PropertyCast::TypeValue* self = (PropertyCast::TypeValue*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'vec3Value'",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)self->vec3Value,"Vector3"); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: vecVecValue of class TypeValue */ +#ifndef TOLUA_DISABLE_tolua_get_PropertyCast__TypeValue_vecVecValue_ptr +static int tolua_get_PropertyCast__TypeValue_vecVecValue_ptr(lua_State* tolua_S) +{ + PropertyCast::TypeValue* self = (PropertyCast::TypeValue*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'vecVecValue'",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)self->vecVecValue,"EffectsVector >"); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: pPointLight of class TypeValue */ +#ifndef TOLUA_DISABLE_tolua_get_PropertyCast__TypeValue_pPointLight_ptr +static int tolua_get_PropertyCast__TypeValue_pPointLight_ptr(lua_State* tolua_S) +{ + PropertyCast::TypeValue* self = (PropertyCast::TypeValue*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'pPointLight'",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)self->pPointLight,"PointLight"); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: pPointLight of class TypeValue */ +#ifndef TOLUA_DISABLE_tolua_set_PropertyCast__TypeValue_pPointLight_ptr +static int tolua_set_PropertyCast__TypeValue_pPointLight_ptr(lua_State* tolua_S) +{ + PropertyCast::TypeValue* self = (PropertyCast::TypeValue*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'pPointLight'",NULL); + if (!tolua_isusertype(tolua_S,2,"PointLight",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->pPointLight = ((PointLight*) tolua_tousertype(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: pSpotLight of class TypeValue */ +#ifndef TOLUA_DISABLE_tolua_get_PropertyCast__TypeValue_pSpotLight_ptr +static int tolua_get_PropertyCast__TypeValue_pSpotLight_ptr(lua_State* tolua_S) +{ + PropertyCast::TypeValue* self = (PropertyCast::TypeValue*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'pSpotLight'",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)self->pSpotLight,"SpotLight"); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: pSpotLight of class TypeValue */ +#ifndef TOLUA_DISABLE_tolua_set_PropertyCast__TypeValue_pSpotLight_ptr +static int tolua_set_PropertyCast__TypeValue_pSpotLight_ptr(lua_State* tolua_S) +{ + PropertyCast::TypeValue* self = (PropertyCast::TypeValue*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'pSpotLight'",NULL); + if (!tolua_isusertype(tolua_S,2,"SpotLight",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->pSpotLight = ((SpotLight*) tolua_tousertype(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: pDirectionalLight of class TypeValue */ +#ifndef TOLUA_DISABLE_tolua_get_PropertyCast__TypeValue_pDirectionalLight_ptr +static int tolua_get_PropertyCast__TypeValue_pDirectionalLight_ptr(lua_State* tolua_S) +{ + PropertyCast::TypeValue* self = (PropertyCast::TypeValue*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'pDirectionalLight'",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)self->pDirectionalLight,"DirectionalLight"); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: pDirectionalLight of class TypeValue */ +#ifndef TOLUA_DISABLE_tolua_set_PropertyCast__TypeValue_pDirectionalLight_ptr +static int tolua_set_PropertyCast__TypeValue_pDirectionalLight_ptr(lua_State* tolua_S) +{ + PropertyCast::TypeValue* self = (PropertyCast::TypeValue*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'pDirectionalLight'",NULL); + if (!tolua_isusertype(tolua_S,2,"DirectionalLight",0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->pDirectionalLight = ((DirectionalLight*) tolua_tousertype(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: value of class PropertyCast */ +#ifndef TOLUA_DISABLE_tolua_get_PropertyCast_value +static int tolua_get_PropertyCast_value(lua_State* tolua_S) +{ + PropertyCast* self = (PropertyCast*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'value'",NULL); +#endif + tolua_pushusertype(tolua_S,(void*)&self->value,"PropertyCast::TypeValue"); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: value of class PropertyCast */ +#ifndef TOLUA_DISABLE_tolua_set_PropertyCast_value +static int tolua_set_PropertyCast_value(lua_State* tolua_S) +{ + PropertyCast* self = (PropertyCast*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'value'",NULL); + if ((tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"PropertyCast::TypeValue",0,&tolua_err))) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->value = *((PropertyCast::TypeValue*) tolua_tousertype(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetEnabled of class UnitLight */ +#ifndef TOLUA_DISABLE_tolua__UnitLight_GetEnabled00 +static int tolua__UnitLight_GetEnabled00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const UnitLight",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const UnitLight* self = (const UnitLight*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetEnabled'", NULL); +#endif + { + bool tolua_ret = (bool) self->GetEnabled(); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetEnabled'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetColour of class UnitLight */ +#ifndef TOLUA_DISABLE_tolua__UnitLight_GetColour00 +static int tolua__UnitLight_GetColour00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const UnitLight",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const UnitLight* self = (const UnitLight*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetColour'", NULL); +#endif + { + const Vector3& tolua_ret = (const Vector3&) self->GetColour(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"const Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(const Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"const Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetColour'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetIntensity of class UnitLight */ +#ifndef TOLUA_DISABLE_tolua__UnitLight_GetIntensity00 +static int tolua__UnitLight_GetIntensity00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const UnitLight",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const UnitLight* self = (const UnitLight*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetIntensity'", NULL); +#endif + { + float tolua_ret = (float) self->GetIntensity(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetIntensity'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetName of class UnitLight */ +#ifndef TOLUA_DISABLE_tolua__UnitLight_GetName00 +static int tolua__UnitLight_GetName00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const UnitLight",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const UnitLight* self = (const UnitLight*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetName'", NULL); +#endif + { + const std::string tolua_ret = (const std::string) self->GetName(); + tolua_pushcppstring(tolua_S,(const char*)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetName'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetEnabled of class UnitLight */ +#ifndef TOLUA_DISABLE_tolua__UnitLight_SetEnabled00 +static int tolua__UnitLight_SetEnabled00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"UnitLight",0,&tolua_err) || + !tolua_isboolean(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + UnitLight* self = (UnitLight*) tolua_tousertype(tolua_S,1,0); + bool isEnabled = ((bool) tolua_toboolean(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetEnabled'", NULL); +#endif + { + self->SetEnabled(isEnabled); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetEnabled'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetColour of class UnitLight */ +#ifndef TOLUA_DISABLE_tolua__UnitLight_SetColour00 +static int tolua__UnitLight_SetColour00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"UnitLight",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + UnitLight* self = (UnitLight*) tolua_tousertype(tolua_S,1,0); + const Vector3* colour = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetColour'", NULL); +#endif + { + self->SetColour(*colour); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetColour'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetColour of class UnitLight */ +#ifndef TOLUA_DISABLE_tolua__UnitLight_SetColour01 +static int tolua__UnitLight_SetColour01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"UnitLight",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else + { + UnitLight* self = (UnitLight*) tolua_tousertype(tolua_S,1,0); + float red = ((float) tolua_tonumber(tolua_S,2,0)); + float green = ((float) tolua_tonumber(tolua_S,3,0)); + float blue = ((float) tolua_tonumber(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetColour'", NULL); +#endif + { + self->SetColour(red,green,blue); + } + } + return 0; +tolua_lerror: + return tolua__UnitLight_SetColour00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetIntensity of class UnitLight */ +#ifndef TOLUA_DISABLE_tolua__UnitLight_SetIntensity00 +static int tolua__UnitLight_SetIntensity00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"UnitLight",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + UnitLight* self = (UnitLight*) tolua_tousertype(tolua_S,1,0); + float intensity = ((float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetIntensity'", NULL); +#endif + { + self->SetIntensity(intensity); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetIntensity'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: CreatePointLight of class PointLight */ +#ifndef TOLUA_DISABLE_tolua__PointLight_CreatePointLight00 +static int tolua__PointLight_CreatePointLight00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"PointLight",0,&tolua_err) || + !tolua_iscppstring(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const string name = ((const string) tolua_tocppstring(tolua_S,2,0)); + { + PointLight* tolua_ret = (PointLight*) PointLight::CreatePointLight(name); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"PointLight"); + tolua_pushcppstring(tolua_S,(const char*)name); + } + } + return 2; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'CreatePointLight'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetPosition of class PointLight */ +#ifndef TOLUA_DISABLE_tolua__PointLight_GetPosition00 +static int tolua__PointLight_GetPosition00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const PointLight",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const PointLight* self = (const PointLight*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetPosition'", NULL); +#endif + { + const Vector3& tolua_ret = (const Vector3&) self->GetPosition(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"const Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(const Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"const Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetPosition'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetPosition of class PointLight */ +#ifndef TOLUA_DISABLE_tolua__PointLight_SetPosition00 +static int tolua__PointLight_SetPosition00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"PointLight",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + PointLight* self = (PointLight*) tolua_tousertype(tolua_S,1,0); + const Vector3* position = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPosition'", NULL); +#endif + { + self->SetPosition(*position); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetPosition'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetPosition of class PointLight */ +#ifndef TOLUA_DISABLE_tolua__PointLight_SetPosition01 +static int tolua__PointLight_SetPosition01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"PointLight",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else + { + PointLight* self = (PointLight*) tolua_tousertype(tolua_S,1,0); + float x = ((float) tolua_tonumber(tolua_S,2,0)); + float y = ((float) tolua_tonumber(tolua_S,3,0)); + float z = ((float) tolua_tonumber(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetPosition'", NULL); +#endif + { + self->SetPosition(x,y,z); + } + } + return 0; +tolua_lerror: + return tolua__PointLight_SetPosition00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: CreateSpotLight of class SpotLight */ +#ifndef TOLUA_DISABLE_tolua__SpotLight_CreateSpotLight00 +static int tolua__SpotLight_CreateSpotLight00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"SpotLight",0,&tolua_err) || + !tolua_iscppstring(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const string name = ((const string) tolua_tocppstring(tolua_S,2,0)); + { + SpotLight* tolua_ret = (SpotLight*) SpotLight::CreateSpotLight(name); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"SpotLight"); + tolua_pushcppstring(tolua_S,(const char*)name); + } + } + return 2; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'CreateSpotLight'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetTarget of class SpotLight */ +#ifndef TOLUA_DISABLE_tolua__SpotLight_GetTarget00 +static int tolua__SpotLight_GetTarget00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const SpotLight",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const SpotLight* self = (const SpotLight*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetTarget'", NULL); +#endif + { + const Vector3& tolua_ret = (const Vector3&) self->GetTarget(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"const Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(const Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"const Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetTarget'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetAngleOpening of class SpotLight */ +#ifndef TOLUA_DISABLE_tolua__SpotLight_GetAngleOpening00 +static int tolua__SpotLight_GetAngleOpening00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const SpotLight",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const SpotLight* self = (const SpotLight*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetAngleOpening'", NULL); +#endif + { + float tolua_ret = (float) self->GetAngleOpening(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetAngleOpening'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetAngleFadeOut of class SpotLight */ +#ifndef TOLUA_DISABLE_tolua__SpotLight_GetAngleFadeOut00 +static int tolua__SpotLight_GetAngleFadeOut00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const SpotLight",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const SpotLight* self = (const SpotLight*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetAngleFadeOut'", NULL); +#endif + { + float tolua_ret = (float) self->GetAngleFadeOut(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetAngleFadeOut'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetTarget of class SpotLight */ +#ifndef TOLUA_DISABLE_tolua__SpotLight_SetTarget00 +static int tolua__SpotLight_SetTarget00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"SpotLight",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + SpotLight* self = (SpotLight*) tolua_tousertype(tolua_S,1,0); + const Vector3* target = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetTarget'", NULL); +#endif + { + self->SetTarget(*target); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetTarget'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetTarget of class SpotLight */ +#ifndef TOLUA_DISABLE_tolua__SpotLight_SetTarget01 +static int tolua__SpotLight_SetTarget01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"SpotLight",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else + { + SpotLight* self = (SpotLight*) tolua_tousertype(tolua_S,1,0); + float x = ((float) tolua_tonumber(tolua_S,2,0)); + float y = ((float) tolua_tonumber(tolua_S,3,0)); + float z = ((float) tolua_tonumber(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetTarget'", NULL); +#endif + { + self->SetTarget(x,y,z); + } + } + return 0; +tolua_lerror: + return tolua__SpotLight_SetTarget00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetAngleOpening of class SpotLight */ +#ifndef TOLUA_DISABLE_tolua__SpotLight_SetAngleOpening00 +static int tolua__SpotLight_SetAngleOpening00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"SpotLight",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + SpotLight* self = (SpotLight*) tolua_tousertype(tolua_S,1,0); + float angleOpening = ((float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetAngleOpening'", NULL); +#endif + { + bool tolua_ret = (bool) self->SetAngleOpening(angleOpening); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetAngleOpening'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetAngleFadeOut of class SpotLight */ +#ifndef TOLUA_DISABLE_tolua__SpotLight_SetAngleFadeOut00 +static int tolua__SpotLight_SetAngleFadeOut00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"SpotLight",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + SpotLight* self = (SpotLight*) tolua_tousertype(tolua_S,1,0); + float angleFadeOut = ((float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetAngleFadeOut'", NULL); +#endif + { + bool tolua_ret = (bool) self->SetAngleFadeOut(angleFadeOut); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetAngleFadeOut'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: CreateDirectionalLight of class DirectionalLight */ +#ifndef TOLUA_DISABLE_tolua__DirectionalLight_CreateDirectionalLight00 +static int tolua__DirectionalLight_CreateDirectionalLight00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"DirectionalLight",0,&tolua_err) || + !tolua_iscppstring(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const string name = ((const string) tolua_tocppstring(tolua_S,2,0)); + { + DirectionalLight* tolua_ret = (DirectionalLight*) DirectionalLight::CreateDirectionalLight(name); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"DirectionalLight"); + tolua_pushcppstring(tolua_S,(const char*)name); + } + } + return 2; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'CreateDirectionalLight'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetDirection of class DirectionalLight */ +#ifndef TOLUA_DISABLE_tolua__DirectionalLight_GetDirection00 +static int tolua__DirectionalLight_GetDirection00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const DirectionalLight",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const DirectionalLight* self = (const DirectionalLight*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetDirection'", NULL); +#endif + { + const Vector3& tolua_ret = (const Vector3&) self->GetDirection(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"const Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(const Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"const Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetDirection'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetDirection of class DirectionalLight */ +#ifndef TOLUA_DISABLE_tolua__DirectionalLight_SetDirection00 +static int tolua__DirectionalLight_SetDirection00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"DirectionalLight",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + DirectionalLight* self = (DirectionalLight*) tolua_tousertype(tolua_S,1,0); + const Vector3* direction = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetDirection'", NULL); +#endif + { + self->SetDirection(*direction); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetDirection'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetDirection of class DirectionalLight */ +#ifndef TOLUA_DISABLE_tolua__DirectionalLight_SetDirection01 +static int tolua__DirectionalLight_SetDirection01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"DirectionalLight",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else + { + DirectionalLight* self = (DirectionalLight*) tolua_tousertype(tolua_S,1,0); + float x = ((float) tolua_tonumber(tolua_S,2,0)); + float y = ((float) tolua_tonumber(tolua_S,3,0)); + float z = ((float) tolua_tonumber(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetDirection'", NULL); +#endif + { + self->SetDirection(x,y,z); + } + } + return 0; +tolua_lerror: + return tolua__DirectionalLight_SetDirection00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: x of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua_get_Vector3_x +static int tolua_get_Vector3_x(lua_State* tolua_S) +{ + Vector3* self = (Vector3*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL); +#endif + tolua_pushnumber(tolua_S,(lua_Number)self->x); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: x of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua_set_Vector3_x +static int tolua_set_Vector3_x(lua_State* tolua_S) +{ + Vector3* self = (Vector3*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->x = ((float) tolua_tonumber(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: y of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua_get_Vector3_y +static int tolua_get_Vector3_y(lua_State* tolua_S) +{ + Vector3* self = (Vector3*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL); +#endif + tolua_pushnumber(tolua_S,(lua_Number)self->y); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: y of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua_set_Vector3_y +static int tolua_set_Vector3_y(lua_State* tolua_S) +{ + Vector3* self = (Vector3*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->y = ((float) tolua_tonumber(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: z of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua_get_Vector3_z +static int tolua_get_Vector3_z(lua_State* tolua_S) +{ + Vector3* self = (Vector3*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'z'",NULL); +#endif + tolua_pushnumber(tolua_S,(lua_Number)self->z); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: z of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua_set_Vector3_z +static int tolua_set_Vector3_z(lua_State* tolua_S) +{ + Vector3* self = (Vector3*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'z'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->z = ((float) tolua_tonumber(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3_new00 +static int tolua__Vector3_new00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Vector3",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + { + Vector3* tolua_ret = (Vector3*) Mtolua_new((Vector3)()); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3"); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new_local of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3_new00_local +static int tolua__Vector3_new00_local(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Vector3",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + { + Vector3* tolua_ret = (Vector3*) Mtolua_new((Vector3)()); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3_new01 +static int tolua__Vector3_new01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Vector3",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else + { + float _x = ((float) tolua_tonumber(tolua_S,2,0)); + float _y = ((float) tolua_tonumber(tolua_S,3,0)); + float _z = ((float) tolua_tonumber(tolua_S,4,0)); + { + Vector3* tolua_ret = (Vector3*) Mtolua_new((Vector3)(_x,_y,_z)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3"); + } + } + return 1; +tolua_lerror: + return tolua__Vector3_new00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new_local of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3_new01_local +static int tolua__Vector3_new01_local(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Vector3",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else + { + float _x = ((float) tolua_tonumber(tolua_S,2,0)); + float _y = ((float) tolua_tonumber(tolua_S,3,0)); + float _z = ((float) tolua_tonumber(tolua_S,4,0)); + { + Vector3* tolua_ret = (Vector3*) Mtolua_new((Vector3)(_x,_y,_z)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + } + } + return 1; +tolua_lerror: + return tolua__Vector3_new00_local(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3_new02 +static int tolua__Vector3_new02(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Vector3",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const Vector3* rhs = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); + { + Vector3* tolua_ret = (Vector3*) Mtolua_new((Vector3)(*rhs)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3"); + } + } + return 1; +tolua_lerror: + return tolua__Vector3_new01(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new_local of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3_new02_local +static int tolua__Vector3_new02_local(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Vector3",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const Vector3* rhs = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); + { + Vector3* tolua_ret = (Vector3*) Mtolua_new((Vector3)(*rhs)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + } + } + return 1; +tolua_lerror: + return tolua__Vector3_new01_local(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: delete of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3_delete00 +static int tolua__Vector3_delete00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Vector3",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Vector3* self = (Vector3*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL); +#endif + Mtolua_delete(self); + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator- of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3__sub00 +static int tolua__Vector3__sub00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector3",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector3* self = (const Vector3*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'", NULL); +#endif + { + Vector3 tolua_ret = (Vector3) self->operator-(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator+ of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3__add00 +static int tolua__Vector3__add00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector3",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector3* self = (const Vector3*) tolua_tousertype(tolua_S,1,0); + const Vector3* aRhv = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'", NULL); +#endif + { + Vector3 tolua_ret = (Vector3) self->operator+(*aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator+ of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3__add01 +static int tolua__Vector3__add01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector3",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const Vector3* self = (const Vector3*) tolua_tousertype(tolua_S,1,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'", NULL); +#endif + { + Vector3 tolua_ret = (Vector3) self->operator+(aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + if ( + !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err) || + !tolua_isnumber(tolua_S,1,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror1; + else + { + const Vector3* self = (const Vector3*) tolua_tousertype(tolua_S,2,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,1,0)); + #ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'", NULL); + #endif + { + Vector3 tolua_ret = (Vector3) self->operator+(aRhv); + { + #ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + #else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + #endif + } + } + } + return 1; + tolua_lerror1: + return tolua__Vector3__add00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator- of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3__sub01 +static int tolua__Vector3__sub01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector3",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const Vector3* self = (const Vector3*) tolua_tousertype(tolua_S,1,0); + const Vector3* aRhv = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'", NULL); +#endif + { + Vector3 tolua_ret = (Vector3) self->operator-(*aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + return tolua__Vector3__sub00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator- of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3__sub02 +static int tolua__Vector3__sub02(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector3",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const Vector3* self = (const Vector3*) tolua_tousertype(tolua_S,1,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'", NULL); +#endif + { + Vector3 tolua_ret = (Vector3) self->operator-(aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + return tolua__Vector3__sub01(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator* of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3__mul00 +static int tolua__Vector3__mul00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector3",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector3* self = (const Vector3*) tolua_tousertype(tolua_S,1,0); + const Vector3* aRhv = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL); +#endif + { + Vector3 tolua_ret = (Vector3) self->operator*(*aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator* of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3__mul01 +static int tolua__Vector3__mul01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector3",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const Vector3* self = (const Vector3*) tolua_tousertype(tolua_S,1,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL); +#endif + { + Vector3 tolua_ret = (Vector3) self->operator*(aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + if ( + !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err) || + !tolua_isnumber(tolua_S,1,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror1; + else + { + const Vector3* self = (const Vector3*) tolua_tousertype(tolua_S,2,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,1,0)); + #ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL); + #endif + { + Vector3 tolua_ret = (Vector3) self->operator*(aRhv); + { + #ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + #else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + #endif + } + } + } + return 1; + tolua_lerror1: + return tolua__Vector3__mul00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator/ of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3__div00 +static int tolua__Vector3__div00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector3",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector3* self = (const Vector3*) tolua_tousertype(tolua_S,1,0); + const Vector3* aRhv = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator/'", NULL); +#endif + { + Vector3 tolua_ret = (Vector3) self->operator/(*aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.div'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator/ of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3__div01 +static int tolua__Vector3__div01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector3",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const Vector3* self = (const Vector3*) tolua_tousertype(tolua_S,1,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator/'", NULL); +#endif + { + Vector3 tolua_ret = (Vector3) self->operator/(aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + return tolua__Vector3__div00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator== of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3__eq00 +static int tolua__Vector3__eq00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector3",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector3* self = (const Vector3*) tolua_tousertype(tolua_S,1,0); + const Vector3* aRhv = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='", NULL); +#endif + { + bool tolua_ret = (bool) self->operator==(*aRhv); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetCrossVector3 of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3_GetCrossVector300 +static int tolua__Vector3_GetCrossVector300(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Vector3",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector3",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Vector3* self = (Vector3*) tolua_tousertype(tolua_S,1,0); + const Vector3* aOther = ((const Vector3*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetCrossVector3'", NULL); +#endif + { + Vector3& tolua_ret = (Vector3&) self->GetCrossVector3(*aOther); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetCrossVector3'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetNormalizedVector3 of class Vector3 */ +#ifndef TOLUA_DISABLE_tolua__Vector3_GetNormalizedVector300 +static int tolua__Vector3_GetNormalizedVector300(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Vector3",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Vector3* self = (Vector3*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetNormalizedVector3'", NULL); +#endif + { + Vector3& tolua_ret = (Vector3&) self->GetNormalizedVector3(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector3)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector3)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector3"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetNormalizedVector3'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: x of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua_get_Vector2_x +static int tolua_get_Vector2_x(lua_State* tolua_S) +{ + Vector2* self = (Vector2*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL); +#endif + tolua_pushnumber(tolua_S,(lua_Number)self->x); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: x of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua_set_Vector2_x +static int tolua_set_Vector2_x(lua_State* tolua_S) +{ + Vector2* self = (Vector2*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'x'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->x = ((float) tolua_tonumber(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* get function: y of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua_get_Vector2_y +static int tolua_get_Vector2_y(lua_State* tolua_S) +{ + Vector2* self = (Vector2*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL); +#endif + tolua_pushnumber(tolua_S,(lua_Number)self->y); + return 1; +} +#endif //#ifndef TOLUA_DISABLE + +/* set function: y of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua_set_Vector2_y +static int tolua_set_Vector2_y(lua_State* tolua_S) +{ + Vector2* self = (Vector2*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'y'",NULL); + if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) + tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err); +#endif + self->y = ((float) tolua_tonumber(tolua_S,2,0)) +; + return 0; +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2_new00 +static int tolua__Vector2_new00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Vector2",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector2",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector2* rhs = ((const Vector2*) tolua_tousertype(tolua_S,2,0)); + { + Vector2* tolua_ret = (Vector2*) Mtolua_new((Vector2)(*rhs)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector2"); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new_local of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2_new00_local +static int tolua__Vector2_new00_local(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Vector2",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector2",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector2* rhs = ((const Vector2*) tolua_tousertype(tolua_S,2,0)); + { + Vector2* tolua_ret = (Vector2*) Mtolua_new((Vector2)(*rhs)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2_new01 +static int tolua__Vector2_new01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Vector2",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else + { + float _x = ((float) tolua_tonumber(tolua_S,2,0)); + float _y = ((float) tolua_tonumber(tolua_S,3,0)); + { + Vector2* tolua_ret = (Vector2*) Mtolua_new((Vector2)(_x,_y)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector2"); + } + } + return 1; +tolua_lerror: + return tolua__Vector2_new00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new_local of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2_new01_local +static int tolua__Vector2_new01_local(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Vector2",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnoobj(tolua_S,4,&tolua_err) + ) + goto tolua_lerror; + else + { + float _x = ((float) tolua_tonumber(tolua_S,2,0)); + float _y = ((float) tolua_tonumber(tolua_S,3,0)); + { + Vector2* tolua_ret = (Vector2*) Mtolua_new((Vector2)(_x,_y)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + } + } + return 1; +tolua_lerror: + return tolua__Vector2_new00_local(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2_new02 +static int tolua__Vector2_new02(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Vector2",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else + { + { + Vector2* tolua_ret = (Vector2*) Mtolua_new((Vector2)()); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector2"); + } + } + return 1; +tolua_lerror: + return tolua__Vector2_new01(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new_local of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2_new02_local +static int tolua__Vector2_new02_local(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"Vector2",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else + { + { + Vector2* tolua_ret = (Vector2*) Mtolua_new((Vector2)()); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + } + } + return 1; +tolua_lerror: + return tolua__Vector2_new01_local(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: delete of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2_delete00 +static int tolua__Vector2_delete00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"Vector2",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + Vector2* self = (Vector2*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL); +#endif + Mtolua_delete(self); + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator- of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2__sub00 +static int tolua__Vector2__sub00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector2",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector2* self = (const Vector2*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'", NULL); +#endif + { + Vector2 tolua_ret = (Vector2) self->operator-(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector2)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector2)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator+ of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2__add00 +static int tolua__Vector2__add00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector2",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector2",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector2* self = (const Vector2*) tolua_tousertype(tolua_S,1,0); + const Vector2* aRhv = ((const Vector2*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'", NULL); +#endif + { + Vector2 tolua_ret = (Vector2) self->operator+(*aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector2)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector2)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator+ of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2__add01 +static int tolua__Vector2__add01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector2",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const Vector2* self = (const Vector2*) tolua_tousertype(tolua_S,1,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'", NULL); +#endif + { + Vector2 tolua_ret = (Vector2) self->operator+(aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector2)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector2)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + if ( + !tolua_isusertype(tolua_S,2,"const Vector2",0,&tolua_err) || + !tolua_isnumber(tolua_S,1,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror1; + else + { + const Vector2* self = (const Vector2*) tolua_tousertype(tolua_S,2,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,1,0)); + #ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'", NULL); + #endif + { + Vector2 tolua_ret = (Vector2) self->operator+(aRhv); + { + #ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector2)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + #else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector2)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + #endif + } + } + } + return 1; + tolua_lerror1: + return tolua__Vector2__add00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator- of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2__sub01 +static int tolua__Vector2__sub01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector2",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector2",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const Vector2* self = (const Vector2*) tolua_tousertype(tolua_S,1,0); + const Vector2* aRhv = ((const Vector2*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'", NULL); +#endif + { + Vector2 tolua_ret = (Vector2) self->operator-(*aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector2)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector2)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + return tolua__Vector2__sub00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator- of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2__sub02 +static int tolua__Vector2__sub02(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector2",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const Vector2* self = (const Vector2*) tolua_tousertype(tolua_S,1,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'", NULL); +#endif + { + Vector2 tolua_ret = (Vector2) self->operator-(aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector2)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector2)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + return tolua__Vector2__sub01(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator* of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2__mul00 +static int tolua__Vector2__mul00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector2",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector2",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector2* self = (const Vector2*) tolua_tousertype(tolua_S,1,0); + const Vector2* aRhv = ((const Vector2*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL); +#endif + { + Vector2 tolua_ret = (Vector2) self->operator*(*aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector2)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector2)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator* of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2__mul01 +static int tolua__Vector2__mul01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector2",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const Vector2* self = (const Vector2*) tolua_tousertype(tolua_S,1,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL); +#endif + { + Vector2 tolua_ret = (Vector2) self->operator*(aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector2)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector2)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + if ( + !tolua_isusertype(tolua_S,2,"const Vector2",0,&tolua_err) || + !tolua_isnumber(tolua_S,1,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror1; + else + { + const Vector2* self = (const Vector2*) tolua_tousertype(tolua_S,2,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,1,0)); + #ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL); + #endif + { + Vector2 tolua_ret = (Vector2) self->operator*(aRhv); + { + #ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector2)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + #else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector2)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + #endif + } + } + } + return 1; + tolua_lerror1: + return tolua__Vector2__mul00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator/ of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2__div00 +static int tolua__Vector2__div00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector2",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector2",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector2* self = (const Vector2*) tolua_tousertype(tolua_S,1,0); + const Vector2* aRhv = ((const Vector2*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator/'", NULL); +#endif + { + Vector2 tolua_ret = (Vector2) self->operator/(*aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector2)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector2)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.div'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator/ of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2__div01 +static int tolua__Vector2__div01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector2",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const Vector2* self = (const Vector2*) tolua_tousertype(tolua_S,1,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator/'", NULL); +#endif + { + Vector2 tolua_ret = (Vector2) self->operator/(aRhv); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((Vector2)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(Vector2)); + tolua_pushusertype(tolua_S,tolua_obj,"Vector2"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + return tolua__Vector2__div00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator== of class Vector2 */ +#ifndef TOLUA_DISABLE_tolua__Vector2__eq00 +static int tolua__Vector2__eq00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const Vector2",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const Vector2",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const Vector2* self = (const Vector2*) tolua_tousertype(tolua_S,1,0); + const Vector2* aRhv = ((const Vector2*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator=='", NULL); +#endif + { + bool tolua_ret = (bool) self->operator==(*aRhv); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.eq'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetSize of class EffectsVector > */ +#ifndef TOLUA_DISABLE_tolua__EffectsVector_EffectsVector_long____GetSize00 +static int tolua__EffectsVector_EffectsVector_long____GetSize00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectsVector >",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectsVector >* self = (const EffectsVector >*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSize'", NULL); +#endif + { + long tolua_ret = (long) self->GetSize(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetSize'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator[] of class EffectsVector > */ +#ifndef TOLUA_DISABLE_tolua__EffectsVector_EffectsVector_long_____geti00 +static int tolua__EffectsVector_EffectsVector_long_____geti00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectsVector >",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectsVector >* self = (const EffectsVector >*) tolua_tousertype(tolua_S,1,0); + long index = ((long) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator[]'", NULL); +#endif + if (index >= self->GetSize() || index < 0) + { + return luaL_error(tolua_S, "Attempt to get out of the array range (see operator[] calling)"); + } + { + const EffectsVector tolua_ret = (const EffectsVector) self->operator[](index); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((EffectsVector)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"const EffectsVector"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(const EffectsVector)); + tolua_pushusertype(tolua_S,tolua_obj,"const EffectsVector"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.geti'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetSize of class EffectsVector */ +#ifndef TOLUA_DISABLE_tolua__EffectsVector_long__GetSize00 +static int tolua__EffectsVector_long__GetSize00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectsVector",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectsVector* self = (const EffectsVector*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSize'", NULL); +#endif + { + long tolua_ret = (long) self->GetSize(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetSize'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator[] of class EffectsVector */ +#ifndef TOLUA_DISABLE_tolua__EffectsVector_long___geti00 +static int tolua__EffectsVector_long___geti00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectsVector",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectsVector* self = (const EffectsVector*) tolua_tousertype(tolua_S,1,0); + long index = ((long) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator[]'", NULL); +#endif + if (index >= self->GetSize() || index < 0) + { + return luaL_error(tolua_S, "Attempt to get out of the array range (see operator[] calling)"); + } + { + const long tolua_ret = (const long) self->operator[](index); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.geti'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: GetSize of class EffectsVector */ +#ifndef TOLUA_DISABLE_tolua__EffectsVector_float__GetSize00 +static int tolua__EffectsVector_float__GetSize00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectsVector",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectsVector* self = (const EffectsVector*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetSize'", NULL); +#endif + { + long tolua_ret = (long) self->GetSize(); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'GetSize'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator[] of class EffectsVector */ +#ifndef TOLUA_DISABLE_tolua__EffectsVector_float___geti00 +static int tolua__EffectsVector_float___geti00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const EffectsVector",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const EffectsVector* self = (const EffectsVector*) tolua_tousertype(tolua_S,1,0); + long index = ((long) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator[]'", NULL); +#endif + if (index >= self->GetSize() || index < 0) + { + return luaL_error(tolua_S, "Attempt to get out of the array range (see operator[] calling)"); + } + { + const float tolua_ret = (const float) self->operator[](index); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.geti'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_new00 +static int tolua__LuaMatrix4_new00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + { + LuaMatrix4* tolua_ret = (LuaMatrix4*) Mtolua_new((LuaMatrix4)()); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"LuaMatrix4"); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new_local of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_new00_local +static int tolua__LuaMatrix4_new00_local(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + { + LuaMatrix4* tolua_ret = (LuaMatrix4*) Mtolua_new((LuaMatrix4)()); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_new01 +static int tolua__LuaMatrix4_new01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + float m = ((float) tolua_tonumber(tolua_S,2,0)); + { + LuaMatrix4* tolua_ret = (LuaMatrix4*) Mtolua_new((LuaMatrix4)(m)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"LuaMatrix4"); + } + } + return 1; +tolua_lerror: + return tolua__LuaMatrix4_new00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new_local of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_new01_local +static int tolua__LuaMatrix4_new01_local(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + float m = ((float) tolua_tonumber(tolua_S,2,0)); + { + LuaMatrix4* tolua_ret = (LuaMatrix4*) Mtolua_new((LuaMatrix4)(m)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + } + } + return 1; +tolua_lerror: + return tolua__LuaMatrix4_new00_local(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_new02 +static int tolua__LuaMatrix4_new02(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const LuaMatrix4",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const LuaMatrix4* rhs = ((const LuaMatrix4*) tolua_tousertype(tolua_S,2,0)); + { + LuaMatrix4* tolua_ret = (LuaMatrix4*) Mtolua_new((LuaMatrix4)(*rhs)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"LuaMatrix4"); + } + } + return 1; +tolua_lerror: + return tolua__LuaMatrix4_new01(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new_local of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_new02_local +static int tolua__LuaMatrix4_new02_local(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const LuaMatrix4",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const LuaMatrix4* rhs = ((const LuaMatrix4*) tolua_tousertype(tolua_S,2,0)); + { + LuaMatrix4* tolua_ret = (LuaMatrix4*) Mtolua_new((LuaMatrix4)(*rhs)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + } + } + return 1; +tolua_lerror: + return tolua__LuaMatrix4_new01_local(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_new03 +static int tolua__LuaMatrix4_new03(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,0,&tolua_err) || + !tolua_isnumber(tolua_S,7,0,&tolua_err) || + !tolua_isnumber(tolua_S,8,0,&tolua_err) || + !tolua_isnumber(tolua_S,9,0,&tolua_err) || + !tolua_isnumber(tolua_S,10,0,&tolua_err) || + !tolua_isnumber(tolua_S,11,0,&tolua_err) || + !tolua_isnumber(tolua_S,12,0,&tolua_err) || + !tolua_isnumber(tolua_S,13,0,&tolua_err) || + !tolua_isnumber(tolua_S,14,0,&tolua_err) || + !tolua_isnumber(tolua_S,15,0,&tolua_err) || + !tolua_isnumber(tolua_S,16,0,&tolua_err) || + !tolua_isnumber(tolua_S,17,0,&tolua_err) || + !tolua_isnoobj(tolua_S,18,&tolua_err) + ) + goto tolua_lerror; + else + { + float m0 = ((float) tolua_tonumber(tolua_S,2,0)); + float m1 = ((float) tolua_tonumber(tolua_S,3,0)); + float m2 = ((float) tolua_tonumber(tolua_S,4,0)); + float m3 = ((float) tolua_tonumber(tolua_S,5,0)); + float m4 = ((float) tolua_tonumber(tolua_S,6,0)); + float m5 = ((float) tolua_tonumber(tolua_S,7,0)); + float m6 = ((float) tolua_tonumber(tolua_S,8,0)); + float m7 = ((float) tolua_tonumber(tolua_S,9,0)); + float m8 = ((float) tolua_tonumber(tolua_S,10,0)); + float m9 = ((float) tolua_tonumber(tolua_S,11,0)); + float m10 = ((float) tolua_tonumber(tolua_S,12,0)); + float m11 = ((float) tolua_tonumber(tolua_S,13,0)); + float m12 = ((float) tolua_tonumber(tolua_S,14,0)); + float m13 = ((float) tolua_tonumber(tolua_S,15,0)); + float m14 = ((float) tolua_tonumber(tolua_S,16,0)); + float m15 = ((float) tolua_tonumber(tolua_S,17,0)); + { + LuaMatrix4* tolua_ret = (LuaMatrix4*) Mtolua_new((LuaMatrix4)(m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"LuaMatrix4"); + } + } + return 1; +tolua_lerror: + return tolua__LuaMatrix4_new02(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: new_local of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_new03_local +static int tolua__LuaMatrix4_new03_local(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertable(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,0,&tolua_err) || + !tolua_isnumber(tolua_S,7,0,&tolua_err) || + !tolua_isnumber(tolua_S,8,0,&tolua_err) || + !tolua_isnumber(tolua_S,9,0,&tolua_err) || + !tolua_isnumber(tolua_S,10,0,&tolua_err) || + !tolua_isnumber(tolua_S,11,0,&tolua_err) || + !tolua_isnumber(tolua_S,12,0,&tolua_err) || + !tolua_isnumber(tolua_S,13,0,&tolua_err) || + !tolua_isnumber(tolua_S,14,0,&tolua_err) || + !tolua_isnumber(tolua_S,15,0,&tolua_err) || + !tolua_isnumber(tolua_S,16,0,&tolua_err) || + !tolua_isnumber(tolua_S,17,0,&tolua_err) || + !tolua_isnoobj(tolua_S,18,&tolua_err) + ) + goto tolua_lerror; + else + { + float m0 = ((float) tolua_tonumber(tolua_S,2,0)); + float m1 = ((float) tolua_tonumber(tolua_S,3,0)); + float m2 = ((float) tolua_tonumber(tolua_S,4,0)); + float m3 = ((float) tolua_tonumber(tolua_S,5,0)); + float m4 = ((float) tolua_tonumber(tolua_S,6,0)); + float m5 = ((float) tolua_tonumber(tolua_S,7,0)); + float m6 = ((float) tolua_tonumber(tolua_S,8,0)); + float m7 = ((float) tolua_tonumber(tolua_S,9,0)); + float m8 = ((float) tolua_tonumber(tolua_S,10,0)); + float m9 = ((float) tolua_tonumber(tolua_S,11,0)); + float m10 = ((float) tolua_tonumber(tolua_S,12,0)); + float m11 = ((float) tolua_tonumber(tolua_S,13,0)); + float m12 = ((float) tolua_tonumber(tolua_S,14,0)); + float m13 = ((float) tolua_tonumber(tolua_S,15,0)); + float m14 = ((float) tolua_tonumber(tolua_S,16,0)); + float m15 = ((float) tolua_tonumber(tolua_S,17,0)); + { + LuaMatrix4* tolua_ret = (LuaMatrix4*) Mtolua_new((LuaMatrix4)(m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)); + tolua_pushusertype(tolua_S,(void*)tolua_ret,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + } + } + return 1; +tolua_lerror: + return tolua__LuaMatrix4_new02_local(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: SetIdentity of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_SetIdentity00 +static int tolua__LuaMatrix4_SetIdentity00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetIdentity'", NULL); +#endif + { + self->SetIdentity(); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'SetIdentity'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: Translate of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_Translate00 +static int tolua__LuaMatrix4_Translate00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + float x0 = ((float) tolua_tonumber(tolua_S,2,0)); + float y0 = ((float) tolua_tonumber(tolua_S,3,0)); + float z0 = ((float) tolua_tonumber(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Translate'", NULL); +#endif + { + self->Translate(x0,y0,z0); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'Translate'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: Scale of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_Scale00 +static int tolua__LuaMatrix4_Scale00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnoobj(tolua_S,5,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + float multiplierX = ((float) tolua_tonumber(tolua_S,2,0)); + float multiplierY = ((float) tolua_tonumber(tolua_S,3,0)); + float multiplierZ = ((float) tolua_tonumber(tolua_S,4,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Scale'", NULL); +#endif + { + bool tolua_ret = (bool) self->Scale(multiplierX,multiplierY,multiplierZ); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'Scale'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: Scale of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_Scale01 +static int tolua__LuaMatrix4_Scale01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,0,&tolua_err) || + !tolua_isnumber(tolua_S,7,0,&tolua_err) || + !tolua_isnoobj(tolua_S,8,&tolua_err) + ) + goto tolua_lerror; + else + { + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + float multiplierX = ((float) tolua_tonumber(tolua_S,2,0)); + float multiplierY = ((float) tolua_tonumber(tolua_S,3,0)); + float multiplierZ = ((float) tolua_tonumber(tolua_S,4,0)); + float x0 = ((float) tolua_tonumber(tolua_S,5,0)); + float y0 = ((float) tolua_tonumber(tolua_S,6,0)); + float z0 = ((float) tolua_tonumber(tolua_S,7,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Scale'", NULL); +#endif + { + bool tolua_ret = (bool) self->Scale(multiplierX,multiplierY,multiplierZ,x0,y0,z0); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +tolua_lerror: + return tolua__LuaMatrix4_Scale00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RotateAroundAxisZ of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_RotateAroundAxisZ00 +static int tolua__LuaMatrix4_RotateAroundAxisZ00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + float angle = ((float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RotateAroundAxisZ'", NULL); +#endif + { + self->RotateAroundAxisZ(angle); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'RotateAroundAxisZ'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RotateAroundAxisZ of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_RotateAroundAxisZ01 +static int tolua__LuaMatrix4_RotateAroundAxisZ01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) + ) + goto tolua_lerror; + else + { + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + float angle = ((float) tolua_tonumber(tolua_S,2,0)); + float x0 = ((float) tolua_tonumber(tolua_S,3,0)); + float y0 = ((float) tolua_tonumber(tolua_S,4,0)); + float z0 = ((float) tolua_tonumber(tolua_S,5,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RotateAroundAxisZ'", NULL); +#endif + { + self->RotateAroundAxisZ(angle,x0,y0,z0); + } + } + return 0; +tolua_lerror: + return tolua__LuaMatrix4_RotateAroundAxisZ00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RotateAroundAxisX of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_RotateAroundAxisX00 +static int tolua__LuaMatrix4_RotateAroundAxisX00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + float angle = ((float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RotateAroundAxisX'", NULL); +#endif + { + self->RotateAroundAxisX(angle); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'RotateAroundAxisX'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RotateAroundAxisX of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_RotateAroundAxisX01 +static int tolua__LuaMatrix4_RotateAroundAxisX01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) + ) + goto tolua_lerror; + else + { + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + float angle = ((float) tolua_tonumber(tolua_S,2,0)); + float x0 = ((float) tolua_tonumber(tolua_S,3,0)); + float y0 = ((float) tolua_tonumber(tolua_S,4,0)); + float z0 = ((float) tolua_tonumber(tolua_S,5,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RotateAroundAxisX'", NULL); +#endif + { + self->RotateAroundAxisX(angle,x0,y0,z0); + } + } + return 0; +tolua_lerror: + return tolua__LuaMatrix4_RotateAroundAxisX00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RotateAroundAxisY of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_RotateAroundAxisY00 +static int tolua__LuaMatrix4_RotateAroundAxisY00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + float angle = ((float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RotateAroundAxisY'", NULL); +#endif + { + self->RotateAroundAxisY(angle); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'RotateAroundAxisY'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RotateAroundAxisY of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_RotateAroundAxisY01 +static int tolua__LuaMatrix4_RotateAroundAxisY01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) + ) + goto tolua_lerror; + else + { + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + float angle = ((float) tolua_tonumber(tolua_S,2,0)); + float x0 = ((float) tolua_tonumber(tolua_S,3,0)); + float y0 = ((float) tolua_tonumber(tolua_S,4,0)); + float z0 = ((float) tolua_tonumber(tolua_S,5,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RotateAroundAxisY'", NULL); +#endif + { + self->RotateAroundAxisY(angle,x0,y0,z0); + } + } + return 0; +tolua_lerror: + return tolua__LuaMatrix4_RotateAroundAxisY00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RotateAroundAxisArbitrary of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_RotateAroundAxisArbitrary00 +static int tolua__LuaMatrix4_RotateAroundAxisArbitrary00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnoobj(tolua_S,6,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + float angle = ((float) tolua_tonumber(tolua_S,2,0)); + float projectionX = ((float) tolua_tonumber(tolua_S,3,0)); + float projectionY = ((float) tolua_tonumber(tolua_S,4,0)); + float projectionZ = ((float) tolua_tonumber(tolua_S,5,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RotateAroundAxisArbitrary'", NULL); +#endif + { + bool tolua_ret = (bool) self->RotateAroundAxisArbitrary(angle,projectionX,projectionY,projectionZ); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'RotateAroundAxisArbitrary'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: RotateAroundAxisArbitrary of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4_RotateAroundAxisArbitrary01 +static int tolua__LuaMatrix4_RotateAroundAxisArbitrary01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnumber(tolua_S,3,0,&tolua_err) || + !tolua_isnumber(tolua_S,4,0,&tolua_err) || + !tolua_isnumber(tolua_S,5,0,&tolua_err) || + !tolua_isnumber(tolua_S,6,0,&tolua_err) || + !tolua_isnumber(tolua_S,7,0,&tolua_err) || + !tolua_isnumber(tolua_S,8,0,&tolua_err) || + !tolua_isnoobj(tolua_S,9,&tolua_err) + ) + goto tolua_lerror; + else + { + LuaMatrix4* self = (LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + float angle = ((float) tolua_tonumber(tolua_S,2,0)); + float projectionX = ((float) tolua_tonumber(tolua_S,3,0)); + float projectionY = ((float) tolua_tonumber(tolua_S,4,0)); + float projectionZ = ((float) tolua_tonumber(tolua_S,5,0)); + float x0 = ((float) tolua_tonumber(tolua_S,6,0)); + float y0 = ((float) tolua_tonumber(tolua_S,7,0)); + float z0 = ((float) tolua_tonumber(tolua_S,8,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'RotateAroundAxisArbitrary'", NULL); +#endif + { + bool tolua_ret = (bool) self->RotateAroundAxisArbitrary(angle,projectionX,projectionY,projectionZ,x0,y0,z0); + tolua_pushboolean(tolua_S,(bool)tolua_ret); + } + } + return 1; +tolua_lerror: + return tolua__LuaMatrix4_RotateAroundAxisArbitrary00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator* of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4__mul00 +static int tolua__LuaMatrix4__mul00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const LuaMatrix4",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const LuaMatrix4",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const LuaMatrix4* self = (const LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + const LuaMatrix4* mul = ((const LuaMatrix4*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL); +#endif + { + LuaMatrix4 tolua_ret = (LuaMatrix4) self->operator*(*mul); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((LuaMatrix4)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(LuaMatrix4)); + tolua_pushusertype(tolua_S,tolua_obj,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.mul'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator* of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4__mul01 +static int tolua__LuaMatrix4__mul01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,2,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else + { + const LuaMatrix4* self = (const LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + const float mul = ((const float) tolua_tonumber(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL); +#endif + { + LuaMatrix4 tolua_ret = (LuaMatrix4) self->operator*(mul); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((LuaMatrix4)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(LuaMatrix4)); + tolua_pushusertype(tolua_S,tolua_obj,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + if ( + !tolua_isusertype(tolua_S,2,"const LuaMatrix4",0,&tolua_err) || + !tolua_isnumber(tolua_S,1,0,&tolua_err) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror1; + else + { + const LuaMatrix4* self = (const LuaMatrix4*) tolua_tousertype(tolua_S,2,0); + const float aRhv = ((const float) tolua_tonumber(tolua_S,1,0)); + #ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator*'", NULL); + #endif + { + LuaMatrix4 tolua_ret = (LuaMatrix4) self->operator*(aRhv); + { + #ifdef __cplusplus + void* tolua_obj = Mtolua_new((LuaMatrix4)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + #else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(LuaMatrix4)); + tolua_pushusertype(tolua_S,tolua_obj,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + #endif + } + } + } + return 1; + tolua_lerror1: + return tolua__LuaMatrix4__mul00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator+ of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4__add00 +static int tolua__LuaMatrix4__add00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const LuaMatrix4",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const LuaMatrix4",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const LuaMatrix4* self = (const LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + const LuaMatrix4* add = ((const LuaMatrix4*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator+'", NULL); +#endif + { + LuaMatrix4 tolua_ret = (LuaMatrix4) self->operator+(*add); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((LuaMatrix4)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(LuaMatrix4)); + tolua_pushusertype(tolua_S,tolua_obj,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.add'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator- of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4__sub00 +static int tolua__LuaMatrix4__sub00(lua_State* tolua_S) +{ +#ifndef TOLUA_RELEASE + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const LuaMatrix4",0,&tolua_err) || + (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const LuaMatrix4",0,&tolua_err)) || + !tolua_isnoobj(tolua_S,3,&tolua_err) + ) + goto tolua_lerror; + else +#endif + { + const LuaMatrix4* self = (const LuaMatrix4*) tolua_tousertype(tolua_S,1,0); + const LuaMatrix4* sub = ((const LuaMatrix4*) tolua_tousertype(tolua_S,2,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'", NULL); +#endif + { + LuaMatrix4 tolua_ret = (LuaMatrix4) self->operator-(*sub); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((LuaMatrix4)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(LuaMatrix4)); + tolua_pushusertype(tolua_S,tolua_obj,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function '.sub'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: operator- of class LuaMatrix4 */ +#ifndef TOLUA_DISABLE_tolua__LuaMatrix4__sub01 +static int tolua__LuaMatrix4__sub01(lua_State* tolua_S) +{ + tolua_Error tolua_err; + if ( + !tolua_isusertype(tolua_S,1,"const LuaMatrix4",0,&tolua_err) || + !tolua_isnoobj(tolua_S,2,&tolua_err) + ) + goto tolua_lerror; + else + { + const LuaMatrix4* self = (const LuaMatrix4*) tolua_tousertype(tolua_S,1,0); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'operator-'", NULL); +#endif + { + LuaMatrix4 tolua_ret = (LuaMatrix4) self->operator-(); + { +#ifdef __cplusplus + void* tolua_obj = Mtolua_new((LuaMatrix4)(tolua_ret)); + tolua_pushusertype(tolua_S,tolua_obj,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#else + void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(LuaMatrix4)); + tolua_pushusertype(tolua_S,tolua_obj,"LuaMatrix4"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); +#endif + } + } + } + return 1; +tolua_lerror: + return tolua__LuaMatrix4__sub00(tolua_S); +} +#endif //#ifndef TOLUA_DISABLE + +/* Open function */ +TOLUA_API int tolua__open (lua_State* tolua_S) +{ + tolua_open(tolua_S); + tolua_reg_types(tolua_S); + tolua_module(tolua_S,NULL,0); + tolua_beginmodule(tolua_S,NULL); + tolua_cclass(tolua_S,"EffectModelScript","EffectModelScript","",NULL); + tolua_beginmodule(tolua_S,"EffectModelScript"); + tolua_function(tolua_S,"GetProperty",tolua__EffectModelScript_GetProperty00); + tolua_function(tolua_S,"SetProperty",tolua__EffectModelScript_SetProperty00); + tolua_function(tolua_S,"SetProperty",tolua__EffectModelScript_SetProperty01); + tolua_function(tolua_S,"SetProperty",tolua__EffectModelScript_SetProperty02); + tolua_function(tolua_S,"SetPropertyGroup",tolua__EffectModelScript_SetPropertyGroup00); + tolua_function(tolua_S,"GetDistanceFromGround",tolua__EffectModelScript_GetDistanceFromGround00); + tolua_function(tolua_S,"UpdateBitmap",tolua__EffectModelScript_UpdateBitmap00); + tolua_function(tolua_S,"GetNearestPointsIds",tolua__EffectModelScript_GetNearestPointsIds00); + tolua_function(tolua_S,"GetNearestPointsIds",tolua__EffectModelScript_GetNearestPointsIds01); + tolua_function(tolua_S,"RotateSurfaceN",tolua__EffectModelScript_RotateSurfaceN00); + tolua_function(tolua_S,"RotateSurfaceV",tolua__EffectModelScript_RotateSurfaceV00); + tolua_function(tolua_S,"RotateSurfaceV",tolua__EffectModelScript_RotateSurfaceV01); + tolua_function(tolua_S,"RotateSurfaceV",tolua__EffectModelScript_RotateSurfaceV02); + tolua_function(tolua_S,"ScaleSurface",tolua__EffectModelScript_ScaleSurface00); + tolua_function(tolua_S,"ScaleSurface",tolua__EffectModelScript_ScaleSurface01); + tolua_function(tolua_S,"ScaleSurface",tolua__EffectModelScript_ScaleSurface02); + tolua_function(tolua_S,"MoveSurface",tolua__EffectModelScript_MoveSurface00); + tolua_function(tolua_S,"MoveSurface",tolua__EffectModelScript_MoveSurface01); + tolua_function(tolua_S,"ResetSurfaceTransformation",tolua__EffectModelScript_ResetSurfaceTransformation00); + tolua_function(tolua_S,"PrintLuaInfo",tolua__EffectModelScript_PrintLuaInfo00); + tolua_function(tolua_S,"SetTransformationMatrix",tolua__EffectModelScript_SetTransformationMatrix00); + tolua_function(tolua_S,"AddUnitLight",tolua__EffectModelScript_AddUnitLight00); + tolua_function(tolua_S,"RemoveUnitLight",tolua__EffectModelScript_RemoveUnitLight00); + tolua_function(tolua_S,"RemoveAllUnitsLightType",tolua__EffectModelScript_RemoveAllUnitsLightType00); + tolua_function(tolua_S,"GetUnitLight",tolua__EffectModelScript_GetUnitLight00); + tolua_function(tolua_S,"SetLightAmbientColour",tolua__EffectModelScript_SetLightAmbientColour00); + tolua_function(tolua_S,"SetLightAmbientColour",tolua__EffectModelScript_SetLightAmbientColour01); + tolua_function(tolua_S,"SetLightIntensity",tolua__EffectModelScript_SetLightIntensity00); + tolua_function(tolua_S,"SetLightAttenuation",tolua__EffectModelScript_SetLightAttenuation00); + tolua_function(tolua_S,"GetLightAmbientColour",tolua__EffectModelScript_GetLightAmbientColour00); + tolua_function(tolua_S,"GetLightIntensity",tolua__EffectModelScript_GetLightIntensity00); + tolua_function(tolua_S,"GetLightAttenuation",tolua__EffectModelScript_GetLightAttenuation00); + tolua_endmodule(tolua_S); + tolua_constant(tolua_S,"TYPE_UNIT_LIGHT_POINT",TYPE_UNIT_LIGHT_POINT); + tolua_constant(tolua_S,"TYPE_UNIT_LIGHT_SPOT",TYPE_UNIT_LIGHT_SPOT); + tolua_constant(tolua_S,"TYPE_UNIT_LIGHT_DIRECTIONAL",TYPE_UNIT_LIGHT_DIRECTIONAL); + tolua_constant(tolua_S,"EFFECT_CONTINUED",EFFECT_CONTINUED); + tolua_constant(tolua_S,"EFFECT_FINISHED",EFFECT_FINISHED); + tolua_constant(tolua_S,"B_IS_FIXED",B_IS_FIXED); + tolua_constant(tolua_S,"N_POS_X",N_POS_X); + tolua_constant(tolua_S,"N_POS_Y",N_POS_Y); + tolua_constant(tolua_S,"N_POS_Z",N_POS_Z); + tolua_constant(tolua_S,"N_POS_X_INIT",N_POS_X_INIT); + tolua_constant(tolua_S,"N_POS_Y_INIT",N_POS_Y_INIT); + tolua_constant(tolua_S,"N_POS_Z_INIT",N_POS_Z_INIT); + tolua_constant(tolua_S,"N_MASS",N_MASS); + tolua_constant(tolua_S,"N_FUSER_X",N_FUSER_X); + tolua_constant(tolua_S,"N_FUSER_Y",N_FUSER_Y); + tolua_constant(tolua_S,"N_FUSER_Z",N_FUSER_Z); + tolua_constant(tolua_S,"N_POINT_RESISTANCE",N_POINT_RESISTANCE); + tolua_constant(tolua_S,"V_POS",V_POS); + tolua_constant(tolua_S,"V_POS_INIT",V_POS_INIT); + tolua_constant(tolua_S,"V_FUSER",V_FUSER); + tolua_constant(tolua_S,"N_NURBS_WEIGHT",N_NURBS_WEIGHT); + tolua_constant(tolua_S,"N_STIFFNESS",N_STIFFNESS); + tolua_constant(tolua_S,"N_ENV_RESISTANCE",N_ENV_RESISTANCE); + tolua_constant(tolua_S,"N_NUMBER_ITERATIONS",N_NUMBER_ITERATIONS); + tolua_constant(tolua_S,"N_MODEL_SPEED",N_MODEL_SPEED); + tolua_constant(tolua_S,"N_GRAVITY_ACCEL_VALUE",N_GRAVITY_ACCEL_VALUE); + tolua_constant(tolua_S,"V_GRAVITY_ACCELERATION",V_GRAVITY_ACCELERATION); + tolua_constant(tolua_S,"N_TRANSPARENCY",N_TRANSPARENCY); + tolua_constant(tolua_S,"N_EFFECT_TIME_PASSED",N_EFFECT_TIME_PASSED); + tolua_constant(tolua_S,"N_EFFECT_DURATION",N_EFFECT_DURATION); + tolua_constant(tolua_S,"ALL_POINTS",ALL_POINTS); + tolua_constant(tolua_S,"ALL_SPRINGS",ALL_SPRINGS); + tolua_constant(tolua_S,"ALL_RODS",ALL_RODS); + tolua_constant(tolua_S,"AXIS_X",AXIS_X); + tolua_constant(tolua_S,"AXIS_Y",AXIS_Y); + tolua_constant(tolua_S,"AXIS_Z",AXIS_Z); + tolua_constant(tolua_S,"AXIS_ARBITRARY",AXIS_ARBITRARY); + tolua_constant(tolua_S,"POINT_LEFT_TOP",POINT_LEFT_TOP); + tolua_constant(tolua_S,"POINT_CENTER_TOP",POINT_CENTER_TOP); + tolua_constant(tolua_S,"POINT_RIGHT_TOP",POINT_RIGHT_TOP); + tolua_constant(tolua_S,"POINT_LEFT_CENTER",POINT_LEFT_CENTER); + tolua_constant(tolua_S,"POINT_CENTER_CENTER",POINT_CENTER_CENTER); + tolua_constant(tolua_S,"POINT_RIGHT_CENTER",POINT_RIGHT_CENTER); + tolua_constant(tolua_S,"POINT_LEFT_BOTTOM",POINT_LEFT_BOTTOM); + tolua_constant(tolua_S,"POINT_CENTER_BOTTOM",POINT_CENTER_BOTTOM); + tolua_constant(tolua_S,"POINT_RIGHT_BOTTOM",POINT_RIGHT_BOTTOM); + tolua_constant(tolua_S,"POINT_ARBITRARY",POINT_ARBITRARY); + tolua_cclass(tolua_S,"TouchEventScript","TouchEventScript","",NULL); + tolua_beginmodule(tolua_S,"TouchEventScript"); + tolua_variable(tolua_S,"currentPosition",tolua_get_TouchEventScript_currentPosition,tolua_set_TouchEventScript_currentPosition); + tolua_variable(tolua_S,"startPosition",tolua_get_TouchEventScript_startPosition,tolua_set_TouchEventScript_startPosition); + tolua_variable(tolua_S,"touchId",tolua_get_TouchEventScript_unsigned_touchId,tolua_set_TouchEventScript_unsigned_touchId); + tolua_endmodule(tolua_S); + #ifdef __cplusplus + tolua_cclass(tolua_S,"PropertyCast","PropertyCast","",tolua_collect_PropertyCast); + #else + tolua_cclass(tolua_S,"PropertyCast","PropertyCast","",NULL); + #endif + tolua_beginmodule(tolua_S,"PropertyCast"); + tolua_constant(tolua_S,"NO_PROPERTY",PropertyCast::NO_PROPERTY); + tolua_constant(tolua_S,"NUMBER",PropertyCast::NUMBER); + tolua_constant(tolua_S,"BOOL",PropertyCast::BOOL); + tolua_constant(tolua_S,"VEC3",PropertyCast::VEC3); + tolua_constant(tolua_S,"VECTOR_VECTOR",PropertyCast::VECTOR_VECTOR); + tolua_constant(tolua_S,"POINT_LIGHT",PropertyCast::POINT_LIGHT); + tolua_constant(tolua_S,"SPOT_LIGHT",PropertyCast::SPOT_LIGHT); + tolua_constant(tolua_S,"DIRECTIONAL_LIGHT",PropertyCast::DIRECTIONAL_LIGHT); + tolua_variable(tolua_S,"type",tolua_get_PropertyCast_type,NULL); + tolua_cclass(tolua_S,"TypeValue","PropertyCast::TypeValue","",NULL); + tolua_beginmodule(tolua_S,"TypeValue"); + tolua_variable(tolua_S,"numberValue",tolua_get_PropertyCast__TypeValue_numberValue,tolua_set_PropertyCast__TypeValue_numberValue); + tolua_variable(tolua_S,"boolValue",tolua_get_PropertyCast__TypeValue_boolValue,tolua_set_PropertyCast__TypeValue_boolValue); + tolua_variable(tolua_S,"vec3Value",tolua_get_PropertyCast__TypeValue_vec3Value_ptr,NULL); + tolua_variable(tolua_S,"vecVecValue",tolua_get_PropertyCast__TypeValue_vecVecValue_ptr,NULL); + tolua_variable(tolua_S,"pPointLight",tolua_get_PropertyCast__TypeValue_pPointLight_ptr,tolua_set_PropertyCast__TypeValue_pPointLight_ptr); + tolua_variable(tolua_S,"pSpotLight",tolua_get_PropertyCast__TypeValue_pSpotLight_ptr,tolua_set_PropertyCast__TypeValue_pSpotLight_ptr); + tolua_variable(tolua_S,"pDirectionalLight",tolua_get_PropertyCast__TypeValue_pDirectionalLight_ptr,tolua_set_PropertyCast__TypeValue_pDirectionalLight_ptr); + tolua_endmodule(tolua_S); + tolua_variable(tolua_S,"value",tolua_get_PropertyCast_value,tolua_set_PropertyCast_value); + tolua_endmodule(tolua_S); + tolua_cclass(tolua_S,"UnitLight","UnitLight","",NULL); + tolua_beginmodule(tolua_S,"UnitLight"); + tolua_function(tolua_S,"GetEnabled",tolua__UnitLight_GetEnabled00); + tolua_function(tolua_S,"GetColour",tolua__UnitLight_GetColour00); + tolua_function(tolua_S,"GetIntensity",tolua__UnitLight_GetIntensity00); + tolua_function(tolua_S,"GetName",tolua__UnitLight_GetName00); + tolua_function(tolua_S,"SetEnabled",tolua__UnitLight_SetEnabled00); + tolua_function(tolua_S,"SetColour",tolua__UnitLight_SetColour00); + tolua_function(tolua_S,"SetColour",tolua__UnitLight_SetColour01); + tolua_function(tolua_S,"SetIntensity",tolua__UnitLight_SetIntensity00); + tolua_endmodule(tolua_S); + tolua_cclass(tolua_S,"PointLight","PointLight","UnitLight",NULL); + tolua_beginmodule(tolua_S,"PointLight"); + tolua_function(tolua_S,"CreatePointLight",tolua__PointLight_CreatePointLight00); + tolua_function(tolua_S,"GetPosition",tolua__PointLight_GetPosition00); + tolua_function(tolua_S,"SetPosition",tolua__PointLight_SetPosition00); + tolua_function(tolua_S,"SetPosition",tolua__PointLight_SetPosition01); + tolua_endmodule(tolua_S); + tolua_cclass(tolua_S,"SpotLight","SpotLight","PointLight",NULL); + tolua_beginmodule(tolua_S,"SpotLight"); + tolua_function(tolua_S,"CreateSpotLight",tolua__SpotLight_CreateSpotLight00); + tolua_function(tolua_S,"GetTarget",tolua__SpotLight_GetTarget00); + tolua_function(tolua_S,"GetAngleOpening",tolua__SpotLight_GetAngleOpening00); + tolua_function(tolua_S,"GetAngleFadeOut",tolua__SpotLight_GetAngleFadeOut00); + tolua_function(tolua_S,"SetTarget",tolua__SpotLight_SetTarget00); + tolua_function(tolua_S,"SetTarget",tolua__SpotLight_SetTarget01); + tolua_function(tolua_S,"SetAngleOpening",tolua__SpotLight_SetAngleOpening00); + tolua_function(tolua_S,"SetAngleFadeOut",tolua__SpotLight_SetAngleFadeOut00); + tolua_endmodule(tolua_S); + tolua_cclass(tolua_S,"DirectionalLight","DirectionalLight","UnitLight",NULL); + tolua_beginmodule(tolua_S,"DirectionalLight"); + tolua_function(tolua_S,"CreateDirectionalLight",tolua__DirectionalLight_CreateDirectionalLight00); + tolua_function(tolua_S,"GetDirection",tolua__DirectionalLight_GetDirection00); + tolua_function(tolua_S,"SetDirection",tolua__DirectionalLight_SetDirection00); + tolua_function(tolua_S,"SetDirection",tolua__DirectionalLight_SetDirection01); + tolua_endmodule(tolua_S); + #ifdef __cplusplus + tolua_cclass(tolua_S,"Vector3","Vector3","",tolua_collect_Vector3); + #else + tolua_cclass(tolua_S,"Vector3","Vector3","",NULL); + #endif + tolua_beginmodule(tolua_S,"Vector3"); + tolua_variable(tolua_S,"x",tolua_get_Vector3_x,tolua_set_Vector3_x); + tolua_variable(tolua_S,"y",tolua_get_Vector3_y,tolua_set_Vector3_y); + tolua_variable(tolua_S,"z",tolua_get_Vector3_z,tolua_set_Vector3_z); + tolua_function(tolua_S,"new",tolua__Vector3_new00); + tolua_function(tolua_S,"new_local",tolua__Vector3_new00_local); + tolua_function(tolua_S,".call",tolua__Vector3_new00_local); + tolua_function(tolua_S,"new",tolua__Vector3_new01); + tolua_function(tolua_S,"new_local",tolua__Vector3_new01_local); + tolua_function(tolua_S,".call",tolua__Vector3_new01_local); + tolua_function(tolua_S,"new",tolua__Vector3_new02); + tolua_function(tolua_S,"new_local",tolua__Vector3_new02_local); + tolua_function(tolua_S,".call",tolua__Vector3_new02_local); + tolua_function(tolua_S,"delete",tolua__Vector3_delete00); + tolua_function(tolua_S,".sub",tolua__Vector3__sub00); + SetMetatable(tolua_S, "Vector3", "__add",tolua__Vector3__add00); + SetMetatable(tolua_S, "Vector3", "__add",tolua__Vector3__add01); + tolua_function(tolua_S,".sub",tolua__Vector3__sub01); + tolua_function(tolua_S,".sub",tolua__Vector3__sub02); + SetMetatable(tolua_S, "Vector3", "__mul",tolua__Vector3__mul00); + SetMetatable(tolua_S, "Vector3", "__mul",tolua__Vector3__mul01); + tolua_function(tolua_S,".div",tolua__Vector3__div00); + tolua_function(tolua_S,".div",tolua__Vector3__div01); + tolua_function(tolua_S,".eq",tolua__Vector3__eq00); + tolua_function(tolua_S,"GetCrossVector3",tolua__Vector3_GetCrossVector300); + tolua_function(tolua_S,"GetNormalizedVector3",tolua__Vector3_GetNormalizedVector300); + tolua_endmodule(tolua_S); + #ifdef __cplusplus + tolua_cclass(tolua_S,"Vector2","Vector2","",tolua_collect_Vector2); + #else + tolua_cclass(tolua_S,"Vector2","Vector2","",NULL); + #endif + tolua_beginmodule(tolua_S,"Vector2"); + tolua_variable(tolua_S,"x",tolua_get_Vector2_x,tolua_set_Vector2_x); + tolua_variable(tolua_S,"y",tolua_get_Vector2_y,tolua_set_Vector2_y); + tolua_function(tolua_S,"new",tolua__Vector2_new00); + tolua_function(tolua_S,"new_local",tolua__Vector2_new00_local); + tolua_function(tolua_S,".call",tolua__Vector2_new00_local); + tolua_function(tolua_S,"new",tolua__Vector2_new01); + tolua_function(tolua_S,"new_local",tolua__Vector2_new01_local); + tolua_function(tolua_S,".call",tolua__Vector2_new01_local); + tolua_function(tolua_S,"new",tolua__Vector2_new02); + tolua_function(tolua_S,"new_local",tolua__Vector2_new02_local); + tolua_function(tolua_S,".call",tolua__Vector2_new02_local); + tolua_function(tolua_S,"delete",tolua__Vector2_delete00); + tolua_function(tolua_S,".sub",tolua__Vector2__sub00); + SetMetatable(tolua_S, "Vector2", "__add",tolua__Vector2__add00); + SetMetatable(tolua_S, "Vector2", "__add",tolua__Vector2__add01); + tolua_function(tolua_S,".sub",tolua__Vector2__sub01); + tolua_function(tolua_S,".sub",tolua__Vector2__sub02); + SetMetatable(tolua_S, "Vector2", "__mul",tolua__Vector2__mul00); + SetMetatable(tolua_S, "Vector2", "__mul",tolua__Vector2__mul01); + tolua_function(tolua_S,".div",tolua__Vector2__div00); + tolua_function(tolua_S,".div",tolua__Vector2__div01); + tolua_function(tolua_S,".eq",tolua__Vector2__eq00); + tolua_endmodule(tolua_S); + tolua_cclass(tolua_S,"EffectsVector_EffectsVector_long___","EffectsVector >","",NULL); + tolua_beginmodule(tolua_S,"EffectsVector_EffectsVector_long___"); + tolua_function(tolua_S,"GetSize",tolua__EffectsVector_EffectsVector_long____GetSize00); + tolua_function(tolua_S,".geti",tolua__EffectsVector_EffectsVector_long_____geti00); + tolua_endmodule(tolua_S); + #ifdef __cplusplus + tolua_cclass(tolua_S,"EffectsVector_long_","EffectsVector","",tolua_collect_EffectsVector_long_); + #else + tolua_cclass(tolua_S,"EffectsVector_long_","EffectsVector","",NULL); + #endif + tolua_beginmodule(tolua_S,"EffectsVector_long_"); + tolua_function(tolua_S,"GetSize",tolua__EffectsVector_long__GetSize00); + tolua_function(tolua_S,".geti",tolua__EffectsVector_long___geti00); + tolua_endmodule(tolua_S); + tolua_cclass(tolua_S,"EffectsVector_float_","EffectsVector","",NULL); + tolua_beginmodule(tolua_S,"EffectsVector_float_"); + tolua_function(tolua_S,"GetSize",tolua__EffectsVector_float__GetSize00); + tolua_function(tolua_S,".geti",tolua__EffectsVector_float___geti00); + tolua_endmodule(tolua_S); + #ifdef __cplusplus + tolua_cclass(tolua_S,"LuaMatrix4","LuaMatrix4","",tolua_collect_LuaMatrix4); + #else + tolua_cclass(tolua_S,"LuaMatrix4","LuaMatrix4","",NULL); + #endif + tolua_beginmodule(tolua_S,"LuaMatrix4"); + tolua_function(tolua_S,"new",tolua__LuaMatrix4_new00); + tolua_function(tolua_S,"new_local",tolua__LuaMatrix4_new00_local); + tolua_function(tolua_S,".call",tolua__LuaMatrix4_new00_local); + tolua_function(tolua_S,"new",tolua__LuaMatrix4_new01); + tolua_function(tolua_S,"new_local",tolua__LuaMatrix4_new01_local); + tolua_function(tolua_S,".call",tolua__LuaMatrix4_new01_local); + tolua_function(tolua_S,"new",tolua__LuaMatrix4_new02); + tolua_function(tolua_S,"new_local",tolua__LuaMatrix4_new02_local); + tolua_function(tolua_S,".call",tolua__LuaMatrix4_new02_local); + tolua_function(tolua_S,"new",tolua__LuaMatrix4_new03); + tolua_function(tolua_S,"new_local",tolua__LuaMatrix4_new03_local); + tolua_function(tolua_S,".call",tolua__LuaMatrix4_new03_local); + tolua_function(tolua_S,"SetIdentity",tolua__LuaMatrix4_SetIdentity00); + tolua_function(tolua_S,"Translate",tolua__LuaMatrix4_Translate00); + tolua_function(tolua_S,"Scale",tolua__LuaMatrix4_Scale00); + tolua_function(tolua_S,"Scale",tolua__LuaMatrix4_Scale01); + tolua_function(tolua_S,"RotateAroundAxisZ",tolua__LuaMatrix4_RotateAroundAxisZ00); + tolua_function(tolua_S,"RotateAroundAxisZ",tolua__LuaMatrix4_RotateAroundAxisZ01); + tolua_function(tolua_S,"RotateAroundAxisX",tolua__LuaMatrix4_RotateAroundAxisX00); + tolua_function(tolua_S,"RotateAroundAxisX",tolua__LuaMatrix4_RotateAroundAxisX01); + tolua_function(tolua_S,"RotateAroundAxisY",tolua__LuaMatrix4_RotateAroundAxisY00); + tolua_function(tolua_S,"RotateAroundAxisY",tolua__LuaMatrix4_RotateAroundAxisY01); + tolua_function(tolua_S,"RotateAroundAxisArbitrary",tolua__LuaMatrix4_RotateAroundAxisArbitrary00); + tolua_function(tolua_S,"RotateAroundAxisArbitrary",tolua__LuaMatrix4_RotateAroundAxisArbitrary01); + SetMetatable(tolua_S, "LuaMatrix4", "__mul",tolua__LuaMatrix4__mul00); + SetMetatable(tolua_S, "LuaMatrix4", "__mul",tolua__LuaMatrix4__mul01); + SetMetatable(tolua_S, "LuaMatrix4", "__add",tolua__LuaMatrix4__add00); + tolua_function(tolua_S,".sub",tolua__LuaMatrix4__sub00); + tolua_function(tolua_S,".sub",tolua__LuaMatrix4__sub01); + tolua_endmodule(tolua_S); + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static const unsigned char B[] = { + 10,102,117,110, 99,116,105,111,110, 32, 71,101,116, 80,114, + 111,112,101,114,116,121, 40,101,108,101,109,101,110,116, 73, + 68, 44, 32,112,114,111,112,101,114,116,121, 41, 13, 10,105, + 102, 32,116,121,112,101, 40,101,108,101,109,101,110,116, 73, + 68, 41, 32,126, 61, 32, 39,110,117,109, 98,101,114, 39, 32, + 116,104,101,110, 13, 10,101,114,114,111,114, 40, 39, 70,105, + 114,115,116, 32, 97,114,103,117,109,101,110,116, 32,102,111, + 114, 32, 71,101,116, 80,114,111,112,101,114,116,121, 32,109, + 117,115,116, 32,104, 97,118,101, 32,116,121,112,101, 32,110, + 117,109, 98,101,114, 32, 40,101,108,101,109,101,110,116, 32, + 73, 68, 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10, + 105,102, 32,116,121,112,101, 40,112,114,111,112,101,114,116, + 121, 41, 32,126, 61, 32, 39,110,117,109, 98,101,114, 39, 32, + 116,104,101,110, 13, 10,101,114,114,111,114, 40, 39, 83,101, + 99,111,110,100, 32, 97,114,103,117,109,101,110,116, 32,102, + 111,114, 32, 71,101,116, 80,114,111,112,101,114,116,121, 32, + 109,117,115,116, 32,104, 97,118,101, 32,116,121,112,101, 32, + 110,117,109, 98,101,114, 32, 40, 78, 95, 46, 46, 46, 32,111, + 114, 32, 86, 95, 46, 46, 46, 32,111,114, 32, 66, 95, 46, 46, + 46, 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,108, + 111, 99, 97,108, 32,114,101,115, 32, 61, 32,115, 99,101,110, + 101, 58, 71,101,116, 80,114,111,112,101,114,116,121, 40,101, + 108,101,109,101,110,116, 73, 68, 44, 32,112,114,111,112,101, + 114,116,121, 41, 32, 13, 10,105,102, 32,114,101,115, 46,116, + 121,112,101, 32, 61, 61, 32, 80,114,111,112,101,114,116,121, + 67, 97,115,116, 46, 78, 85, 77, 66, 69, 82, 32,116,104,101, + 110, 13, 10,114,101,116,117,114,110, 32,114,101,115, 46,118, + 97,108,117,101, 46,110,117,109, 98,101,114, 86, 97,108,117, + 101, 13, 10,101,108,115,101,105,102, 32,114,101,115, 46,116, + 121,112,101, 32, 61, 61, 32, 80,114,111,112,101,114,116,121, + 67, 97,115,116, 46, 66, 79, 79, 76, 32,116,104,101,110, 13, + 10,114,101,116,117,114,110, 32,114,101,115, 46,118, 97,108, + 117,101, 46, 98,111,111,108, 86, 97,108,117,101, 13, 10,101, + 108,115,101,105,102, 32,114,101,115, 46,116,121,112,101, 32, + 61, 61, 32, 80,114,111,112,101,114,116,121, 67, 97,115,116, + 46, 86, 69, 67, 51, 32,116,104,101,110, 13, 10,114,101,116, + 117,114,110, 32,114,101,115, 46,118, 97,108,117,101, 46,118, + 101, 99, 51, 86, 97,108,117,101, 13, 10,101,108,115,101, 32, + 13, 10,101,114,114,111,114, 40, 39, 69,114,114,111,114, 32, + 105,110, 32,102,117,110, 99,116,105,111,110, 32, 71,101,116, + 80,114,111,112,101,114,116,121, 58, 32,116,104,101,114,101, + 32,105,115, 32,110,111, 32,115,112,101, 99,105,102,105,101, + 100, 32,112,114,111,112,101,114,116,121, 39, 44, 32, 50, 41, + 13, 10,101,110,100, 13, 10,101,110,100, 13, 10,102,117,110, + 99,116,105,111,110, 32, 83,101,116, 80,114,111,112,101,114, + 116,121, 40,101,108,101,109,101,110,116, 73, 68, 44, 32,112, + 114,111,112,101,114,116,121, 44, 32,118, 97,108,117,101, 41, + 13, 10,105,102, 32,116,121,112,101, 40,101,108,101,109,101, + 110,116, 73, 68, 41, 32,126, 61, 32, 39,110,117,109, 98,101, + 114, 39, 32,116,104,101,110, 13, 10,101,114,114,111,114, 40, + 39, 70,105,114,115,116, 32, 97,114,103,117,109,101,110,116, + 32,102,111,114, 32, 83,101,116, 80,114,111,112,101,114,116, + 121, 32,109,117,115,116, 32,104, 97,118,101, 32,116,121,112, + 101, 32,110,117,109, 98,101,114, 32, 40,101,108,101,109,101, + 110,116, 32, 73, 68, 41, 39, 44, 32, 50, 41, 13, 10,101,110, + 100, 13, 10,105,102, 32,116,121,112,101, 40,112,114,111,112, + 101,114,116,121, 41, 32,126, 61, 32, 39,110,117,109, 98,101, + 114, 39, 32,116,104,101,110, 13, 10,101,114,114,111,114, 40, + 39, 83,101, 99,111,110,100, 32, 97,114,103,117,109,101,110, + 116, 32,102,111,114, 32, 83,101,116, 80,114,111,112,101,114, + 116,121, 32,109,117,115,116, 32,104, 97,118,101, 32,116,121, + 112,101, 32,110,117,109, 98,101,114, 32, 40, 78, 95, 46, 46, + 46, 32,111,114, 32, 86, 95, 46, 46, 46, 32,111,114, 32, 66, + 95, 46, 46, 46, 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, + 13, 10,108,111, 99, 97,108, 32,118, 97,108,117,101, 84,121, + 112,101, 32, 61, 32,116,111,108,117, 97, 46,116,121,112,101, + 40,118, 97,108,117,101, 41, 13, 10,105,102, 32,118, 97,108, + 117,101, 84,121,112,101, 32,126, 61, 32, 39,110,117,109, 98, + 101,114, 39, 32, 97,110,100, 32,118, 97,108,117,101, 84,121, + 112,101, 32,126, 61, 32, 39, 98,111,111,108,101, 97,110, 39, + 32, 97,110,100, 32,118, 97,108,117,101, 84,121,112,101, 32, + 126, 61, 32, 39, 86,101, 99,116,111,114, 51, 39, 32, 97,110, + 100, 32,118, 97,108,117,101, 84,121,112,101, 32,126, 61, 32, + 39, 99,111,110,115,116, 32, 86,101, 99,116,111,114, 51, 39, + 32,116,104,101,110, 13, 10,101,114,114,111,114, 40, 39, 84, + 104,105,114,100, 32, 97,114,103,117,109,101,110,116, 32,102, + 111,114, 32, 83,101,116, 80,114,111,112,101,114,116,121, 32, + 109,117,115,116, 32,104, 97,118,101, 32,111,110,101, 32,111, + 102, 32,116,104,101, 32,116,121,112,101,115, 58, 32,110,117, + 109, 98,101,114, 44, 32, 98,111,111,108,101, 97,110, 44, 32, + 86,101, 99,116,111,114, 51, 44, 32, 99,111,110,115,116, 32, + 86,101, 99,116,111,114, 51, 32, 40, 97, 32,118, 97,108,117, + 101, 32,102,111,114, 32,115,112,101, 99,105,102,105,101,100, + 32,112,114,111,112,101,114,116,121, 41, 39, 44, 32, 50, 41, + 13, 10,101,110,100, 13, 10,108,111, 99, 97,108, 32,114,101, + 115, 32, 61, 32,115, 99,101,110,101, 58, 83,101,116, 80,114, + 111,112,101,114,116,121, 40,101,108,101,109,101,110,116, 73, + 68, 44, 32,112,114,111,112,101,114,116,121, 44, 32,118, 97, + 108,117,101, 41, 13, 10,105,102, 32,114,101,115, 32, 61, 61, + 32,102, 97,108,115,101, 32,116,104,101,110, 13, 10,101,114, + 114,111,114, 40, 39, 69,114,114,111,114, 32,105,110, 32,102, + 117,110, 99,116,105,111,110, 32, 83,101,116, 80,114,111,112, + 101,114,116,121, 58, 32,115,112,101, 99,105,102,105,101,100, + 32,112,114,111,112,101,114,116,121, 32,119, 97,115, 32,110, + 111,116, 32,115,101,116, 39, 44, 32, 50, 41, 13, 10,101,110, + 100, 13, 10,101,110,100, 13, 10,102,117,110, 99,116,105,111, + 110, 32, 83,101,116, 80,114,111,112,101,114,116,121, 71,114, + 111,117,112, 40, 77,111,100,101,108, 83,117,114,102, 97, 99, + 101, 73, 68, 44, 32,103,114,111,117,112, 44, 32,112,114,111, + 112,101,114,116,121, 44, 32,118, 97,108,117,101, 41, 13, 10, + 105,102, 32,116,121,112,101, 40, 77,111,100,101,108, 83,117, + 114,102, 97, 99,101, 73, 68, 41, 32,126, 61, 32, 39,110,117, + 109, 98,101,114, 39, 32,116,104,101,110, 13, 10,101,114,114, + 111,114, 40, 39, 70,105,114,115,116, 32, 97,114,103,117,109, + 101,110,116, 32,102,111,114, 32, 83,101,116, 80,114,111,112, + 101,114,116,121, 71,114,111,117,112, 32,109,117,115,116, 32, + 104, 97,118,101, 32,116,121,112,101, 32,110,117,109, 98,101, + 114, 32, 40, 73, 68, 32,102,111,114, 32,109,111,100,101,108, + 32,115,117,114,102, 97, 99,101, 41, 39, 44, 32, 50, 41, 13, + 10,101,110,100, 13, 10,105,102, 32,116,121,112,101, 40,103, + 114,111,117,112, 41, 32,126, 61, 32, 39,110,117,109, 98,101, + 114, 39, 32,116,104,101,110, 13, 10,101,114,114,111,114, 40, + 39, 83,101, 99,111,110,100, 32, 97,114,103,117,109,101,110, + 116, 32,102,111,114, 32, 83,101,116, 80,114,111,112,101,114, + 116,121, 71,114,111,117,112, 32,109,117,115,116, 32,104, 97, + 118,101, 32,116,121,112,101, 32,110,117,109, 98,101,114, 32, + 40,102,111,114, 32,101,120, 97,109,112,108,101, 32, 65, 76, + 76, 95, 80, 79, 73, 78, 84, 83, 41, 39, 44, 32, 50, 41, 13, + 10,101,110,100, 13, 10,105,102, 32,116,121,112,101, 40,112, + 114,111,112,101,114,116,121, 41, 32,126, 61, 32, 39,110,117, + 109, 98,101,114, 39, 32,116,104,101,110, 13, 10,101,114,114, + 111,114, 40, 39, 84,104,105,114,100, 32, 97,114,103,117,109, + 101,110,116, 32,102,111,114, 32, 83,101,116, 80,114,111,112, + 101,114,116,121, 71,114,111,117,112, 32,109,117,115,116, 32, + 104, 97,118,101, 32,116,121,112,101, 32,110,117,109, 98,101, + 114, 32, 40, 78, 95, 46, 46, 46, 41, 39, 44, 32, 50, 41, 13, + 10,101,110,100, 13, 10,105,102, 32,116,121,112,101, 40,118, + 97,108,117,101, 41, 32,126, 61, 32, 39,110,117,109, 98,101, + 114, 39, 32,116,104,101,110, 13, 10,101,114,114,111,114, 40, + 39, 70,111,117,114,116,104, 32, 97,114,103,117,109,101,110, + 116, 32,102,111,114, 32, 83,101,116, 80,114,111,112,101,114, + 116,121, 71,114,111,117,112, 32,109,117,115,116, 32,104, 97, + 118,101, 32,116,121,112,101, 32,110,117,109, 98,101,114, 32, + 40, 97, 32,118, 97,108,117,101, 32,102,111,114, 32,115,112, + 101, 99,105,102,105,101,100, 32,112,114,111,112,101,114,116, + 121, 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,108, + 111, 99, 97,108, 32,114,101,115, 32, 61, 32,115, 99,101,110, + 101, 58, 83,101,116, 80,114,111,112,101,114,116,121, 71,114, + 111,117,112, 40, 77,111,100,101,108, 83,117,114,102, 97, 99, + 101, 73, 68, 44, 32,103,114,111,117,112, 44, 32,112,114,111, + 112,101,114,116,121, 44, 32,118, 97,108,117,101, 41, 32, 13, + 10,105,102, 32,114,101,115, 32, 61, 61, 32,102, 97,108,115, + 101, 32,116,104,101,110, 13, 10,101,114,114,111,114, 40, 39, + 69,114,114,111,114, 32,105,110, 32,102,117,110, 99,116,105, + 111,110, 32, 83,101,116, 80,114,111,112,101,114,116,121, 71, + 114,111,117,112, 58, 32,115,112,101, 99,105,102,105,101,100, + 32,112,114,111,112,101,114,116,121, 32,119, 97,115, 32,110, + 111,116, 32,115,101,116, 39, 44, 32, 50, 41, 13, 10,101,110, + 100, 13, 10,101,110,100, 13, 10, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ./SetGetProperty.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static const unsigned char B[] = { + 10,102,117,110, 99,116,105,111,110, 32, 77,111,118,101, 83, + 117,114,102, 97, 99,101, 40, 71,114, 97,112,104,105, 99, 97, + 108, 83,117,114,102, 97, 99,101, 73, 68, 44, 32, 88, 48, 44, + 32, 89, 48, 44, 32, 90, 48, 41, 13, 10,105,102, 32,116,121, + 112,101, 40, 71,114, 97,112,104,105, 99, 97,108, 83,117,114, + 102, 97, 99,101, 73, 68, 41, 32,126, 61, 32, 39,110,117,109, + 98,101,114, 39, 32,116,104,101,110, 13, 10,101,114,114,111, + 114, 40, 39, 70,105,114,115,116, 32, 97,114,103,117,109,101, + 110,116, 32,102,111,114, 32, 77,111,118,101, 83,117,114,102, + 97, 99,101, 32,109,117,115,116, 32,104, 97,118,101, 32,116, + 121,112,101, 32,110,117,109, 98,101,114, 32, 40, 73, 68, 32, + 102,111,114, 32,103,114, 97,112,104,105, 99, 97,108, 32,115, + 117,114,102, 97, 99,101, 41, 39, 44, 32, 50, 41, 13, 10,101, + 110,100, 13, 10,108,111, 99, 97,108, 32,114,101,115, 32, 61, + 32,102, 97,108,115,101, 13, 10,108,111, 99, 97,108, 32,116, + 121,112,101, 88, 48, 32, 61, 32,116,111,108,117, 97, 46,116, + 121,112,101, 40, 88, 48, 41, 13, 10,105,102, 32, 40,116,121, + 112,101, 88, 48, 32, 61, 61, 32, 39, 86,101, 99,116,111,114, + 51, 39, 32,111,114, 32,116,121,112,101, 88, 48, 32, 61, 61, + 32, 39, 99,111,110,115,116, 32, 86,101, 99,116,111,114, 51, + 39, 41, 32, 97,110,100, 32, 89, 48, 32, 61, 61, 32,110,105, + 108, 32, 97,110,100, 32, 90, 48, 32, 61, 61, 32,110,105,108, + 32,116,104,101,110, 32, 13, 10,114,101,115, 32, 61, 32,115, + 99,101,110,101, 58, 77,111,118,101, 83,117,114,102, 97, 99, + 101, 40, 71,114, 97,112,104,105, 99, 97,108, 83,117,114,102, + 97, 99,101, 73, 68, 44, 32, 88, 48, 41, 13, 10,101,108,115, + 101,105,102, 32,116,121,112,101, 88, 48, 32, 61, 61, 32, 39, + 110,117,109, 98,101,114, 39, 32, 97,110,100, 32,116,121,112, + 101, 40, 89, 48, 41, 32, 61, 61, 32, 39,110,117,109, 98,101, + 114, 39, 32, 97,110,100, 32,116,121,112,101, 40, 90, 48, 41, + 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, 32,116,104, + 101,110, 13, 10,114,101,115, 32, 61, 32,115, 99,101,110,101, + 58, 77,111,118,101, 83,117,114,102, 97, 99,101, 40, 71,114, + 97,112,104,105, 99, 97,108, 83,117,114,102, 97, 99,101, 73, + 68, 44, 32, 88, 48, 44, 32, 89, 48, 44, 32, 90, 48, 41, 13, + 10,101,108,115,101, 13, 10,101,114,114,111,114, 40, 39, 83, + 101, 99,111,110,100, 32, 97,114,103,117,109,101,110,116, 32, + 102,111,114, 32, 77,111,118,101, 83,117,114,102, 97, 99,101, + 32,109,117,115,116, 32,104, 97,118,101, 32,116,121,112,101, + 32, 86,101, 99,116,111,114, 51, 32,111,114, 32,115,101, 99, + 111,110,100, 44, 32,116,104,105,114,100, 32, 97,110,100, 32, + 102,111,117,114,116,104, 32, 97,114,103,117,109,101,110,116, + 115, 32,109,117,115,116, 32,104, 97,118,101, 32,116,121,112, + 101, 32,110,117,109, 98,101,114, 39, 44, 32, 50, 41, 13, 10, + 101,110,100, 13, 10,105,102, 32,114,101,115, 32, 61, 61, 32, + 102, 97,108,115,101, 32,116,104,101,110, 13, 10,101,114,114, + 111,114, 40, 39, 69,114,114,111,114, 32,105,110, 32,102,117, + 110, 99,116,105,111,110, 32, 77,111,118,101, 83,117,114,102, + 97, 99,101, 32, 40,109, 97,121, 98,101, 32,121,111,117, 32, + 104, 97,118,101, 32,115,112,101, 99,105,102,105,101,100, 32, + 119,114,111,110,103, 32,105,100, 41, 39, 44, 32, 50, 41, 13, + 10,101,110,100, 13, 10,101,110,100, 13, 10,102,117,110, 99, + 116,105,111,110, 32, 82,111,116, 97,116,101, 83,117,114,102, + 97, 99,101, 40, 71,114, 97,112,104,105, 99, 97,108, 83,117, + 114,102, 97, 99,101, 73, 68, 44, 32, 65,110,103,108,101, 44, + 32, 65,120,105,115, 44, 32, 66, 97,115,101, 80,111,105,110, + 116, 44, 32, 65,120, 44, 32, 65,121, 44, 32, 65,122, 44, 32, + 88, 48, 44, 32, 89, 48, 44, 32, 90, 48, 41, 13, 10,105,102, + 32,116,121,112,101, 40, 71,114, 97,112,104,105, 99, 97,108, + 83,117,114,102, 97, 99,101, 73, 68, 41, 32,126, 61, 32, 39, + 110,117,109, 98,101,114, 39, 32,116,104,101,110, 13, 10,101, + 114,114,111,114, 40, 39, 70,105,114,115,116, 32, 97,114,103, + 117,109,101,110,116, 32,102,111,114, 32, 82,111,116, 97,116, + 101, 83,117,114,102, 97, 99,101, 32,109,117,115,116, 32,104, + 97,118,101, 32,116,121,112,101, 32,110,117,109, 98,101,114, + 32, 40, 73, 68, 32,102,111,114, 32,103,114, 97,112,104,105, + 99, 97,108, 32,115,117,114,102, 97, 99,101, 41, 39, 44, 32, + 50, 41, 13, 10,101,110,100, 13, 10,105,102, 32,116,121,112, + 101, 40, 65,110,103,108,101, 41, 32,126, 61, 32, 39,110,117, + 109, 98,101,114, 39, 32,116,104,101,110, 13, 10,101,114,114, + 111,114, 40, 39, 83,101, 99,111,110,100, 32, 97,114,103,117, + 109,101,110,116, 32,102,111,114, 32, 82,111,116, 97,116,101, + 83,117,114,102, 97, 99,101, 32,109,117,115,116, 32,104, 97, + 118,101, 32,116,121,112,101, 32,110,117,109, 98,101,114, 32, + 40,114,111,116, 97,116,105,111,110, 32, 97,110,103,108,101, + 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,105,102, + 32,116,121,112,101, 40, 65,120,105,115, 41, 32,126, 61, 32, + 39,110,117,109, 98,101,114, 39, 32,116,104,101,110, 13, 10, + 101,114,114,111,114, 40, 39, 84,104,105,114,100, 32, 97,114, + 103,117,109,101,110,116, 32,102,111,114, 32, 82,111,116, 97, + 116,101, 83,117,114,102, 97, 99,101, 32,109,117,115,116, 32, + 104, 97,118,101, 32,116,121,112,101, 32,110,117,109, 98,101, + 114, 32, 40,102,111,114, 32,101,120, 97,109,112,108,101, 32, + 65, 88, 73, 83, 95, 89, 41, 39, 44, 32, 50, 41, 13, 10,101, + 110,100, 13, 10,105,102, 32,116,121,112,101, 40, 66, 97,115, + 101, 80,111,105,110,116, 41, 32,126, 61, 32, 39,110,117,109, + 98,101,114, 39, 32,116,104,101,110, 13, 10,101,114,114,111, + 114, 40, 39, 70,111,117,114,116,104, 32, 97,114,103,117,109, + 101,110,116, 32,102,111,114, 32, 82,111,116, 97,116,101, 83, + 117,114,102, 97, 99,101, 32,109,117,115,116, 32,104, 97,118, + 101, 32,116,121,112,101, 32,110,117,109, 98,101,114, 32, 40, + 102,111,114, 32,101,120, 97,109,112,108,101, 32, 80, 79, 73, + 78, 84, 95, 76, 69, 70, 84, 95, 84, 79, 80, 41, 39, 44, 32, + 50, 41, 13, 10,101,110,100, 13, 10, 13, 10,108,111, 99, 97, + 108, 32,114,101,115, 32, 61, 32,102, 97,108,115,101, 13, 10, + 108,111, 99, 97,108, 32,116,121,112,101, 65,120, 32, 61, 32, + 116,111,108,117, 97, 46,116,121,112,101, 40, 65,120, 41, 13, + 10,105,102, 32,116,121,112,101, 65,120, 32, 61, 61, 32, 39, + 86,101, 99,116,111,114, 51, 39, 32,111,114, 32,116,121,112, + 101, 65,120, 32, 61, 61, 32, 39, 99,111,110,115,116, 32, 86, + 101, 99,116,111,114, 51, 39, 32,116,104,101,110, 13, 10,105, + 102, 32, 65,122, 32, 61, 61, 32,110,105,108, 32, 97,110,100, + 32, 88, 48, 32, 61, 61, 32,110,105,108, 32, 97,110,100, 32, + 89, 48, 32, 61, 61, 32,110,105,108, 32, 97,110,100, 32, 90, + 48, 32, 61, 61, 32,110,105,108, 32,116,104,101,110, 13, 10, + 108,111, 99, 97,108, 32,116,121,112,101, 65,121, 32, 61, 32, + 116,111,108,117, 97, 46,116,121,112,101, 40, 65,121, 41, 13, + 10,105,102, 32,116,121,112,101, 65,121, 32, 61, 61, 32, 39, + 86,101, 99,116,111,114, 51, 39, 32,111,114, 32,116,121,112, + 101, 65,121, 32, 61, 61, 32, 39, 99,111,110,115,116, 32, 86, + 101, 99,116,111,114, 51, 39, 32,116,104,101,110, 13, 10,114, + 101,115, 32, 61, 32,115, 99,101,110,101, 58, 82,111,116, 97, + 116,101, 83,117,114,102, 97, 99,101, 86, 40, 71,114, 97,112, + 104,105, 99, 97,108, 83,117,114,102, 97, 99,101, 73, 68, 44, + 32, 65,110,103,108,101, 44, 32, 65,120,105,115, 44, 32, 66, + 97,115,101, 80,111,105,110,116, 44, 32, 65,120, 44, 32, 65, + 121, 41, 13, 10,101,108,115,101,105,102, 32, 65,121, 32, 61, + 61, 32,110,105,108, 32,116,104,101,110, 13, 10,114,101,115, + 32, 61, 32,115, 99,101,110,101, 58, 82,111,116, 97,116,101, + 83,117,114,102, 97, 99,101, 86, 40, 71,114, 97,112,104,105, + 99, 97,108, 83,117,114,102, 97, 99,101, 73, 68, 44, 32, 65, + 110,103,108,101, 44, 32, 65,120,105,115, 44, 32, 66, 97,115, + 101, 80,111,105,110,116, 44, 32, 65,120, 41, 13, 10,101,108, + 115,101, 13, 10,101,114,114,111,114, 40, 39, 83,105,120,116, + 104, 32, 97,114,103,117,109,101,110,116, 32,102,111,114, 32, + 82,111,116, 97,116,101, 83,117,114,102, 97, 99,101, 32,105, + 115, 32,105,110, 99,111,114,114,101, 99,116, 39, 44, 32, 50, + 41, 32, 13, 10,101,110,100, 13, 10,101,108,115,101, 13, 10, + 101,114,114,111,114, 40, 39, 87,114,111,110,103, 32,110,117, + 109, 98,101,114, 32,111,114, 32,116,121,112,101, 32,111,102, + 32,112, 97,114, 97,109,101,116,101,114,115, 32,102,111,114, + 32, 82,111,116, 97,116,101, 83,117,114,102, 97, 99,101, 32, + 40,115,101,101, 32,102,114,111,109, 32,115,105,120,116,104, + 32,112, 97,114, 97,109,101,116,101,114, 41, 39, 44, 32, 50, + 41, 13, 10,101,110,100, 13, 10, 13, 10,105,102, 32,114,101, + 115, 32, 61, 61, 32,102, 97,108,115,101, 32,116,104,101,110, + 13, 10,101,114,114,111,114, 40, 39, 69,114,114,111,114, 32, + 105,110, 32,102,117,110, 99,116,105,111,110, 32, 82,111,116, + 97,116,101, 83,117,114,102, 97, 99,101, 32, 40,109, 97,121, + 98,101, 32,121,111,117, 32,104, 97,118,101, 32,115,112,101, + 99,105,102,105,101,100, 32,119,114,111,110,103, 32,105,100, + 32,111,114, 32,119,114,111,110,103, 32, 97,120,105,115, 32, + 99,111,110,102,105,103,117,114, 97,116,105,111,110, 41, 39, + 44, 32, 50, 41, 13, 10,101,108,115,101, 13, 10,114,101,116, + 117,114,110, 13, 10,101,110,100, 13, 10,101,110,100, 13, 10, + 105,102, 32,116,121,112,101, 65,120, 32, 61, 61, 32, 39,110, + 117,109, 98,101,114, 39, 32, 97,110,100, 32,116,121,112,101, + 40, 65,121, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, + 39, 32, 97,110,100, 32,116,121,112,101, 40, 65,122, 41, 32, + 61, 61, 32, 39,110,117,109, 98,101,114, 39, 32,116,104,101, + 110, 13, 10,105,102, 32,116,121,112,101, 40, 88, 48, 41, 32, + 61, 61, 32, 39,110,117,109, 98,101,114, 39, 32, 97,110,100, + 32,116,121,112,101, 40, 89, 48, 41, 32, 61, 61, 32, 39,110, + 117,109, 98,101,114, 39, 32, 97,110,100, 32,116,121,112,101, + 40, 90, 48, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, + 39, 32,116,104,101,110, 13, 10,114,101,115, 32, 61, 32,115, + 99,101,110,101, 58, 82,111,116, 97,116,101, 83,117,114,102, + 97, 99,101, 78, 40, 71,114, 97,112,104,105, 99, 97,108, 83, + 117,114,102, 97, 99,101, 73, 68, 44, 32, 65,110,103,108,101, + 44, 32, 65,120,105,115, 44, 32, 66, 97,115,101, 80,111,105, + 110,116, 44, 32, 65,120, 44, 32, 65,121, 44, 32, 65,122, 44, + 32, 88, 48, 44, 32, 89, 48, 44, 32, 90, 48, 41, 13, 10,101, + 108,115,101,105,102, 32, 88, 48, 32, 61, 61, 32,110,105,108, + 32, 97,110,100, 32, 89, 48, 32, 61, 61, 32,110,105,108, 32, + 97,110,100, 32, 90, 48, 32, 61, 61, 32,110,105,108, 32,116, + 104,101,110, 13, 10,114,101,115, 32, 61, 32,115, 99,101,110, + 101, 58, 82,111,116, 97,116,101, 83,117,114,102, 97, 99,101, + 78, 40, 71,114, 97,112,104,105, 99, 97,108, 83,117,114,102, + 97, 99,101, 73, 68, 44, 32, 65,110,103,108,101, 44, 32, 65, + 120,105,115, 44, 32, 66, 97,115,101, 80,111,105,110,116, 44, + 32, 65,120, 44, 32, 65,121, 44, 32, 65,122, 41, 13, 10,101, + 108,115,101, 13, 10,101,114,114,111,114, 40, 39, 87,114,111, + 110,103, 32,110,117,109, 98,101,114, 32,111,114, 32,116,121, + 112,101, 32,111,102, 32,112, 97,114, 97,109,101,116,101,114, + 115, 32,102,111,114, 32, 82,111,116, 97,116,101, 83,117,114, + 102, 97, 99,101, 32, 40,115,101,101, 32,102,114,111,109, 32, + 101,105,103,104,116,104, 32,112, 97,114, 97,109,101,116,101, + 114, 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,101, + 108,115,101,105,102, 32, 65,120, 32, 61, 61, 32,110,105,108, + 32, 97,110,100, 32, 65,121, 32, 61, 61, 32,110,105,108, 32, + 97,110,100, 32, 65,122, 32, 61, 61, 32,110,105,108, 32, 97, + 110,100, 32, 88, 48, 32, 61, 61, 32,110,105,108, 32, 97,110, + 100, 32, 89, 48, 32, 61, 61, 32,110,105,108, 32, 97,110,100, + 32, 90, 48, 32, 61, 61, 32,110,105,108, 32,116,104,101,110, + 13, 10,114,101,115, 32, 61, 32,115, 99,101,110,101, 58, 82, + 111,116, 97,116,101, 83,117,114,102, 97, 99,101, 78, 40, 71, + 114, 97,112,104,105, 99, 97,108, 83,117,114,102, 97, 99,101, + 73, 68, 44, 32, 65,110,103,108,101, 44, 32, 65,120,105,115, + 44, 32, 66, 97,115,101, 80,111,105,110,116, 41, 13, 10,101, + 108,115,101, 13, 10,101,114,114,111,114, 40, 39, 87,114,111, + 110,103, 32,110,117,109, 98,101,114, 32,111,114, 32,116,121, + 112,101, 32,111,102, 32,112, 97,114, 97,109,101,116,101,114, + 115, 32,102,111,114, 32, 82,111,116, 97,116,101, 83,117,114, + 102, 97, 99,101, 32, 40,115,101,101, 32,102,114,111,109, 32, + 102,105,102,116,104, 32,112, 97,114, 97,109,101,116,101,114, + 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,105,102, + 32,114,101,115, 32, 61, 61, 32,102, 97,108,115,101, 32,116, + 104,101,110, 13, 10,101,114,114,111,114, 40, 39, 69,114,114, + 111,114, 32,105,110, 32,102,117,110, 99,116,105,111,110, 32, + 82,111,116, 97,116,101, 83,117,114,102, 97, 99,101, 32, 40, + 109, 97,121, 98,101, 32,121,111,117, 32,104, 97,118,101, 32, + 115,112,101, 99,105,102,105,101,100, 32,119,114,111,110,103, + 32,105,100, 32,111,114, 32,119,114,111,110,103, 32, 97,120, + 105,115, 32, 99,111,110,102,105,103,117,114, 97,116,105,111, + 110, 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,101, + 110,100, 13, 10,102,117,110, 99,116,105,111,110, 32, 83, 99, + 97,108,101, 83,117,114,102, 97, 99,101, 40, 71,114, 97,112, + 104,105, 99, 97,108, 83,117,114,102, 97, 99,101, 73, 68, 44, + 32, 77,117,108, 88, 44, 32, 77,117,108, 89, 44, 32, 77,117, + 108, 90, 44, 32, 66, 97,115,101, 80,111,105,110,116, 44, 32, + 88, 48, 44, 32, 89, 48, 44, 32, 90, 48, 41, 13, 10,105,102, + 32,116,121,112,101, 40, 71,114, 97,112,104,105, 99, 97,108, + 83,117,114,102, 97, 99,101, 73, 68, 41, 32,126, 61, 32, 39, + 110,117,109, 98,101,114, 39, 32,116,104,101,110, 13, 10,101, + 114,114,111,114, 40, 39, 70,105,114,115,116, 32, 97,114,103, + 117,109,101,110,116, 32,102,111,114, 32, 83, 99, 97,108,101, + 83,117,114,102, 97, 99,101, 32,109,117,115,116, 32,104, 97, + 118,101, 32,116,121,112,101, 32,110,117,109, 98,101,114, 32, + 40, 73, 68, 32,102,111,114, 32,103,114, 97,112,104,105, 99, + 97,108, 32,115,117,114,102, 97, 99,101, 41, 39, 44, 32, 50, + 41, 13, 10,101,110,100, 13, 10, 13, 10,108,111, 99, 97,108, + 32,114,101,115, 32, 61, 32,102, 97,108,115,101, 13, 10,108, + 111, 99, 97,108, 32,116,121,112,101, 77,117,108, 88, 32, 61, + 32,116,111,108,117, 97, 46,116,121,112,101, 40, 77,117,108, + 88, 41, 13, 10,105,102, 32,116,121,112,101, 77,117,108, 88, + 32, 61, 61, 32, 39, 86,101, 99,116,111,114, 51, 39, 32,111, + 114, 32,116,121,112,101, 77,117,108, 88, 32, 61, 61, 32, 39, + 99,111,110,115,116, 32, 86,101, 99,116,111,114, 51, 39, 32, + 116,104,101,110, 13, 10,105,102, 32,116,121,112,101, 40, 77, + 117,108, 89, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, + 39, 32,116,104,101,110, 13, 10,108,111, 99, 97,108, 32,116, + 121,112,101, 77,117,108, 90, 32, 61, 32,116,111,108,117, 97, + 46,116,121,112,101, 40, 77,117,108, 90, 41, 13, 10,105,102, + 32,116,121,112,101, 77,117,108, 90, 32, 61, 61, 32, 39, 86, + 101, 99,116,111,114, 51, 39, 32,111,114, 32,116,121,112,101, + 77,117,108, 90, 32, 61, 61, 32, 39, 99,111,110,115,116, 32, + 86,101, 99,116,111,114, 51, 39, 32,116,104,101,110, 13, 10, + 114,101,115, 32, 61, 32,115, 99,101,110,101, 58, 83, 99, 97, + 108,101, 83,117,114,102, 97, 99,101, 40, 71,114, 97,112,104, + 105, 99, 97,108, 83,117,114,102, 97, 99,101, 73, 68, 44, 32, + 77,117,108, 88, 44, 32, 77,117,108, 89, 44, 32, 77,117,108, + 90, 41, 13, 10,101,108,115,101,105,102, 32, 77,117,108, 90, + 32, 61, 61, 32,110,105,108, 32,116,104,101,110, 13, 10,114, + 101,115, 32, 61, 32,115, 99,101,110,101, 58, 83, 99, 97,108, + 101, 83,117,114,102, 97, 99,101, 40, 71,114, 97,112,104,105, + 99, 97,108, 83,117,114,102, 97, 99,101, 73, 68, 44, 32, 77, + 117,108, 88, 44, 32, 77,117,108, 89, 41, 13, 10,101,108,115, + 101, 13, 10,101,114,114,111,114, 40, 39, 70,111,117,114,116, + 104, 32, 97,114,103,117,109,101,110,116, 32,102,111,114, 32, + 83, 99, 97,108,101, 83,117,114,102, 97, 99,101, 32,104, 97, + 115, 32,119,114,111,110,103, 32,116,121,112,101, 39, 44, 32, + 50, 41, 13, 10,101,110,100, 13, 10,101,108,115,101, 13, 10, + 101,114,114,111,114, 40, 39, 84,104,105,114,100, 32, 97,114, + 103,117,109,101,110,116, 32,102,111,114, 32, 83, 99, 97,108, + 101, 83,117,114,102, 97, 99,101, 32,104, 97,115, 32,119,114, + 111,110,103, 32,116,121,112,101, 39, 44, 32, 50, 41, 13, 10, + 101,110,100, 13, 10,105,102, 32,114,101,115, 32, 61, 61, 32, + 102, 97,108,115,101, 32,116,104,101,110, 13, 10,101,114,114, + 111,114, 40, 39, 69,114,114,111,114, 32,105,110, 32,102,117, + 110, 99,116,105,111,110, 32, 83, 99, 97,108,101, 83,117,114, + 102, 97, 99,101, 32, 40,121,111,117, 32,104, 97,118,101, 32, + 115,112,101, 99,105,102,105,101,100, 32,119,114,111,110,103, + 32,105,100, 32,111,114, 32,115,101,110,116, 32,110,101,103, + 97,116,105,118,101, 32,109,117,108,116,105,112,108,105,101, + 114,115, 41, 39, 44, 32, 50, 41, 13, 10,101,108,115,101, 13, + 10,114,101,116,117,114,110, 13, 10,101,110,100, 13, 10,101, + 110,100, 13, 10,105,102, 32,116,121,112,101, 40, 77,117,108, + 88, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, 32, + 97,110,100, 32,116,121,112,101, 40, 77,117,108, 89, 41, 32, + 61, 61, 32, 39,110,117,109, 98,101,114, 39, 32, 97,110,100, + 32,116,121,112,101, 40, 77,117,108, 90, 41, 32, 61, 61, 32, + 39,110,117,109, 98,101,114, 39, 32,116,104,101,110, 13, 10, + 105,102, 32,116,121,112,101, 40, 66, 97,115,101, 80,111,105, + 110,116, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, + 32,116,104,101,110, 13, 10,105,102, 32,116,121,112,101, 40, + 88, 48, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, + 32, 97,110,100, 32,116,121,112,101, 40, 89, 48, 41, 32, 61, + 61, 32, 39,110,117,109, 98,101,114, 39, 32, 97,110,100, 32, + 116,121,112,101, 40, 90, 48, 41, 32, 61, 61, 32, 39,110,117, + 109, 98,101,114, 39, 32,116,104,101,110, 13, 10,114,101,115, + 32, 61, 32,115, 99,101,110,101, 58, 83, 99, 97,108,101, 83, + 117,114,102, 97, 99,101, 40, 71,114, 97,112,104,105, 99, 97, + 108, 83,117,114,102, 97, 99,101, 73, 68, 44, 32, 77,117,108, + 88, 44, 32, 77,117,108, 89, 44, 32, 77,117,108, 90, 44, 32, + 66, 97,115,101, 80,111,105,110,116, 44, 32, 88, 48, 44, 32, + 89, 48, 44, 32, 90, 48, 41, 13, 10,101,108,115,101,105,102, + 32, 88, 48, 32, 61, 61, 32,110,105,108, 32, 97,110,100, 32, + 89, 48, 32, 61, 61, 32,110,105,108, 32, 97,110,100, 32, 90, + 48, 32, 61, 61, 32,110,105,108, 32,116,104,101,110, 13, 10, + 114,101,115, 32, 61, 32,115, 99,101,110,101, 58, 83, 99, 97, + 108,101, 83,117,114,102, 97, 99,101, 40, 71,114, 97,112,104, + 105, 99, 97,108, 83,117,114,102, 97, 99,101, 73, 68, 44, 32, + 77,117,108, 88, 44, 32, 77,117,108, 89, 44, 32, 77,117,108, + 90, 44, 32, 66, 97,115,101, 80,111,105,110,116, 41, 13, 10, + 101,108,115,101, 13, 10,101,114,114,111,114, 40, 39, 87,114, + 111,110,103, 32,110,117,109, 98,101,114, 32,111,114, 32,116, + 121,112,101, 32,111,102, 32,112, 97,114, 97,109,101,116,101, + 114,115, 32,102,111,114, 32, 83, 99, 97,108,101, 83,117,114, + 102, 97, 99,101, 32, 40,115,101,101, 32,102,114,111,109, 32, + 115,105,120,116,104, 32,112, 97,114, 97,109,101,116,101,114, + 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,101,108, + 115,101, 13, 10,101,114,114,111,114, 40, 39, 70,105,102,116, + 104, 32, 97,114,103,117,109,101,110,116, 32,102,111,114, 32, + 83, 99, 97,108,101, 83,117,114,102, 97, 99,101, 32,104, 97, + 115, 32,119,114,111,110,103, 32,116,121,112,101, 39, 44, 32, + 50, 41, 13, 10,101,110,100, 13, 10,101,108,115,101, 13, 10, + 101,114,114,111,114, 40, 39, 87,114,111,110,103, 32,110,117, + 109, 98,101,114, 32,111,114, 32,116,121,112,101, 32,111,102, + 32,112, 97,114, 97,109,101,116,101,114,115, 32,102,111,114, + 32, 83, 99, 97,108,101, 83,117,114,102, 97, 99,101, 32, 40, + 115,101,101, 32,102,114,111,109, 32,115,101, 99,111,110,100, + 32,112, 97,114, 97,109,101,116,101,114, 41, 39, 44, 32, 50, + 41, 13, 10,101,110,100, 13, 10,105,102, 32,114,101,115, 32, + 61, 61, 32,102, 97,108,115,101, 32,116,104,101,110, 13, 10, + 101,114,114,111,114, 40, 39, 69,114,114,111,114, 32,105,110, + 32,102,117,110, 99,116,105,111,110, 32, 83, 99, 97,108,101, + 83,117,114,102, 97, 99,101, 32, 40,109, 97,121, 98,101, 32, + 121,111,117, 32,104, 97,118,101, 32,115,112,101, 99,105,102, + 105,101,100, 32,119,114,111,110,103, 32,105,100, 41, 39, 44, + 32, 50, 41, 13, 10,101,110,100, 13, 10,101,110,100, 13, 10, + 102,117,110, 99,116,105,111,110, 32, 82,101,115,101,116, 83, + 117,114,102, 97, 99,101, 84,114, 97,110,115,102,111,114,109, + 97,116,105,111,110, 40, 71,114, 97,112,104,105, 99, 97,108, + 83,117,114,102, 97, 99,101, 73, 68, 41, 13, 10,105,102, 32, + 116,121,112,101, 40, 71,114, 97,112,104,105, 99, 97,108, 83, + 117,114,102, 97, 99,101, 73, 68, 41, 32,126, 61, 32, 39,110, + 117,109, 98,101,114, 39, 32,116,104,101,110, 13, 10,101,114, + 114,111,114, 40, 39, 65,114,103,117,109,101,110,116, 32,102, + 111,114, 32, 82,101,115,101,116, 83,117,114,102, 97, 99,101, + 84,114, 97,110,115,102,111,114,109, 97,116,105,111,110, 32, + 109,117,115,116, 32,104, 97,118,101, 32,116,121,112,101, 32, + 110,117,109, 98,101,114, 32, 40, 73, 68, 32,102,111,114, 32, + 103,114, 97,112,104,105, 99, 97,108, 32,115,117,114,102, 97, + 99,101, 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10, + 108,111, 99, 97,108, 32,114,101,115, 32, 61, 32,115, 99,101, + 110,101, 58, 82,101,115,101,116, 83,117,114,102, 97, 99,101, + 84,114, 97,110,115,102,111,114,109, 97,116,105,111,110, 40, + 71,114, 97,112,104,105, 99, 97,108, 83,117,114,102, 97, 99, + 101, 73, 68, 41, 13, 10,105,102, 32,114,101,115, 32, 61, 61, + 32,102, 97,108,115,101, 32,116,104,101,110, 13, 10,101,114, + 114,111,114, 40, 39, 69,114,114,111,114, 32,105,110, 32,102, + 117,110, 99,116,105,111,110, 32, 82,101,115,101,116, 83,117, + 114,102, 97, 99,101, 84,114, 97,110,115,102,111,114,109, 97, + 116,105,111,110, 32, 40,109, 97,121, 98,101, 32,121,111,117, + 32,104, 97,118,101, 32,115,112,101, 99,105,102,105,101,100, + 32,119,114,111,110,103, 32,105,100, 41, 39, 44, 32, 50, 41, + 13, 10,101,110,100, 13, 10,101,110,100, 13, 10,102,117,110, + 99,116,105,111,110, 32, 83,101,116, 84,114, 97,110,115,102, + 111,114,109, 97,116,105,111,110, 77, 97,116,114,105,120, 40, + 103,114, 97,112,104,105, 99, 97,108, 83,117,114,102, 97, 99, + 101, 73, 68, 44, 32,109, 97,116,114,105,120, 52, 41, 13, 10, + 105,102, 32,116,121,112,101, 40,103,114, 97,112,104,105, 99, + 97,108, 83,117,114,102, 97, 99,101, 73, 68, 41, 32,126, 61, + 32, 39,110,117,109, 98,101,114, 39, 32,116,104,101,110, 13, + 10,101,114,114,111,114, 40, 39, 70,105,114,115,116, 32, 97, + 114,103,117,109,101,110,116, 32,102,111,114, 32, 83,101,116, + 84,114, 97,110,115,102,111,114,109, 97,116,105,111,110, 77, + 97,116,114,105,120, 32,109,117,115,116, 32,104, 97,118,101, + 32,116,121,112,101, 32,110,117,109, 98,101,114, 32, 40, 73, + 68, 32,102,111,114, 32,103,114, 97,112,104,105, 99, 97,108, + 32,115,117,114,102, 97, 99,101, 41, 39, 44, 32, 50, 41, 13, + 10,101,110,100, 13, 10,108,111, 99, 97,108, 32,116,121,112, + 101, 77, 97,116, 52, 32, 61, 32,116,111,108,117, 97, 46,116, + 121,112,101, 40,109, 97,116,114,105,120, 52, 41, 13, 10,105, + 102, 32,116,121,112,101, 77, 97,116, 52, 32,126, 61, 32, 39, + 76,117, 97, 77, 97,116,114,105,120, 52, 39, 32, 97,110,100, + 32,116,121,112,101, 77, 97,116, 52, 32,126, 61, 32, 39, 99, + 111,110,115,116, 32, 76,117, 97, 77, 97,116,114,105,120, 52, + 39, 32,116,104,101,110, 32, 13, 10,101,114,114,111,114, 40, + 39, 83,101, 99,111,110,100, 32, 97,114,103,117,109,101,110, + 116, 32,102,111,114, 32, 83,101,116, 84,114, 97,110,115,102, + 111,114,109, 97,116,105,111,110, 77, 97,116,114,105,120, 32, + 109,117,115,116, 32,104, 97,118,101, 32,116,121,112,101, 32, + 77, 97,116,114,105,120, 52, 32, 40,116,114, 97,110,115,102, + 111,114,109, 97,116,105,111,110, 32,109, 97,116,114,105,120, + 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,108,111, + 99, 97,108, 32,114,101,115, 32, 61, 32,115, 99,101,110,101, + 58, 83,101,116, 84,114, 97,110,115,102,111,114,109, 97,116, + 105,111,110, 77, 97,116,114,105,120, 40,103,114, 97,112,104, + 105, 99, 97,108, 83,117,114,102, 97, 99,101, 73, 68, 44, 32, + 109, 97,116,114,105,120, 52, 41, 13, 10,105,102, 32,114,101, + 115, 32, 61, 61, 32,102, 97,108,115,101, 32,116,104,101,110, + 13, 10,101,114,114,111,114, 40, 39, 69,114,114,111,114, 32, + 105,110, 32,102,117,110, 99,116,105,111,110, 32, 83,101,116, + 84,114, 97,110,115,102,111,114,109, 97,116,105,111,110, 77, + 97,116,114,105,120, 32, 40,109, 97,121, 98,101, 32,121,111, + 117, 32,104, 97,118,101, 32,115,112,101, 99,105,102,105,101, + 100, 32,119,114,111,110,103, 32,105,100, 41, 39, 44, 32, 50, + 41, 13, 10,101,110,100, 13, 10,101,110,100, 13, 10, 45, 45, + 45, 45, 45, 45, 45,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ./ModelMatrixManipulations.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static const unsigned char B[] = { + 10,102,117,110, 99,116,105,111,110, 32, 71,101,116, 68,105, + 115,116, 97,110, 99,101, 70,114,111,109, 71,114,111,117,110, + 100, 40, 77,111,100,101,108, 83,117,114,102, 97, 99,101, 73, + 68, 41, 13, 10,105,102, 32,116,121,112,101, 40, 77,111,100, + 101,108, 83,117,114,102, 97, 99,101, 73, 68, 41, 32,126, 61, + 32, 39,110,117,109, 98,101,114, 39, 32,116,104,101,110, 13, + 10,101,114,114,111,114, 40, 39, 65,114,103,117,109,101,110, + 116, 32,102,111,114, 32, 71,101,116, 68,105,115,116, 97,110, + 99,101, 70,114,111,109, 71,114,111,117,110,100, 32,109,117, + 115,116, 32,104, 97,118,101, 32,116,121,112,101, 32,110,117, + 109, 98,101,114, 32, 40, 73, 68, 32,102,111,114, 32,109,111, + 100,101,108, 32, 99,111,110,116, 97,105,110,101,114, 41, 39, + 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,108,111, 99, 97, + 108, 32,114,101,115, 32, 61, 32,115, 99,101,110,101, 58, 71, + 101,116, 68,105,115,116, 97,110, 99,101, 70,114,111,109, 71, + 114,111,117,110,100, 40, 77,111,100,101,108, 83,117,114,102, + 97, 99,101, 73, 68, 41, 13, 10,105,102, 32,114,101,115, 46, + 116,121,112,101, 32, 61, 61, 32, 80,114,111,112,101,114,116, + 121, 67, 97,115,116, 46, 78, 85, 77, 66, 69, 82, 32,116,104, + 101,110, 13, 10,114,101,116,117,114,110, 32,114,101,115, 46, + 118, 97,108,117,101, 46,110,117,109, 98,101,114, 86, 97,108, + 117,101, 13, 10,101,108,115,101, 13, 10,101,114,114,111,114, + 40, 39, 69,114,114,111,114, 32,105,110, 32,102,117,110, 99, + 116,105,111,110, 32, 71,101,116, 68,105,115,116, 97,110, 99, + 101, 70,114,111,109, 71,114,111,117,110,100, 58, 32,121,111, + 117, 32,115,112,101, 99,105,102,105,101,100, 32,119,114,111, + 110,103, 32,105,100, 39, 44, 32, 50, 41, 13, 10,101,110,100, + 13, 10,101,110,100, 13, 10,102,117,110, 99,116,105,111,110, + 32, 71,101,116, 78,101, 97,114,101,115,116, 80,111,105,110, + 116,115, 73,100,115, 40, 71,114, 97,112,104,105, 99, 97,108, + 83,117,114,102, 97, 99,101, 73, 68, 44, 32, 80,111,115, 88, + 44, 32, 80,111,115, 89, 44, 32, 80,111,115, 90, 41, 13, 10, + 105,102, 32,116,121,112,101, 40, 71,114, 97,112,104,105, 99, + 97,108, 83,117,114,102, 97, 99,101, 73, 68, 41, 32,126, 61, + 32, 39,110,117,109, 98,101,114, 39, 32,116,104,101,110, 13, + 10,101,114,114,111,114, 40, 39, 70,105,114,115,116, 32, 97, + 114,103,117,109,101,110,116, 32,102,111,114, 32, 71,101,116, + 78,101, 97,114,101,115,116, 80,111,105,110,116,115, 73,100, + 115, 32,109,117,115,116, 32,104, 97,118,101, 32,116,121,112, + 101, 32,110,117,109, 98,101,114, 32, 40, 73, 68, 32,102,111, + 114, 32,103,114, 97,112,104,105, 99, 97,108, 32,115,117,114, + 102, 97, 99,101, 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, + 13, 10,108,111, 99, 97,108, 32,114,101,115, 13, 10,105,102, + 32,116,111,108,117, 97, 46,116,121,112,101, 40, 80,111,115, + 88, 41, 32, 61, 61, 32, 39, 86,101, 99,116,111,114, 51, 39, + 32, 97,110,100, 32, 80,111,115, 89, 32, 61, 61, 32,110,105, + 108, 32, 97,110,100, 32, 80,111,115, 90, 32, 61, 61, 32,110, + 105,108, 32,116,104,101,110, 13, 10,114,101,115, 32, 61, 32, + 115, 99,101,110,101, 58, 71,101,116, 78,101, 97,114,101,115, + 116, 80,111,105,110,116,115, 73,100,115, 40, 71,114, 97,112, + 104,105, 99, 97,108, 83,117,114,102, 97, 99,101, 73, 68, 44, + 32, 80,111,115, 88, 41, 13, 10,101,108,115,101,105,102, 32, + 116,121,112,101, 40, 80,111,115, 88, 41, 32, 61, 61, 32, 39, + 110,117,109, 98,101,114, 39, 32, 97,110,100, 32,116,121,112, + 101, 40, 80,111,115, 89, 41, 32, 61, 61, 32, 39,110,117,109, + 98,101,114, 39, 32, 97,110,100, 32,116,121,112,101, 40, 80, + 111,115, 90, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, + 39, 32,116,104,101,110, 13, 10,114,101,115, 32, 61, 32,115, + 99,101,110,101, 58, 71,101,116, 78,101, 97,114,101,115,116, + 80,111,105,110,116,115, 73,100,115, 40, 71,114, 97,112,104, + 105, 99, 97,108, 83,117,114,102, 97, 99,101, 73, 68, 44, 32, + 80,111,115, 88, 44, 32, 80,111,115, 89, 44, 32, 80,111,115, + 90, 41, 13, 10,101,108,115,101, 13, 10,101,114,114,111,114, + 40, 39, 87,114,111,110,103, 32,110,117,109, 98,101,114, 32, + 111,114, 32,116,121,112,101, 32,111,102, 32,112, 97,114, 97, + 109,101,116,101,114,115, 32,102,111,114, 32, 71,101,116, 78, + 101, 97,114,101,115,116, 80,111,105,110,116,115, 73,100,115, + 32, 40,115,101,101, 32,102,114,111,109, 32,115,101, 99,111, + 110,100, 32,112, 97,114, 97,109,101,116,101,114, 41, 39, 44, + 32, 50, 41, 32, 13, 10,101,110,100, 32, 13, 10,105,102, 32, + 114,101,115, 46,116,121,112,101, 32, 61, 61, 32, 80,114,111, + 112,101,114,116,121, 67, 97,115,116, 46, 86, 69, 67, 84, 79, + 82, 95, 86, 69, 67, 84, 79, 82, 32,116,104,101,110, 13, 10, + 114,101,116,117,114,110, 32,114,101,115, 46,118, 97,108,117, + 101, 46,118,101, 99, 86,101, 99, 86, 97,108,117,101, 13, 10, + 101,108,115,101,105,102, 32,114,101,115, 46,116,121,112,101, + 32, 61, 61, 32, 80,114,111,112,101,114,116,121, 67, 97,115, + 116, 46, 78, 79, 95, 80, 82, 79, 80, 69, 82, 84, 89, 32,116, + 104,101,110, 13, 10,114,101,116,117,114,110, 32,110,105,108, + 13, 10,101,108,115,101,105,102, 32,114,101,115, 46,116,121, + 112,101, 32, 61, 61, 32, 80,114,111,112,101,114,116,121, 67, + 97,115,116, 46, 66, 79, 79, 76, 32,116,104,101,110, 13, 10, + 101,114,114,111,114, 40, 39, 69,114,114,111,114, 32,105,110, + 32,102,117,110, 99,116,105,111,110, 32, 71,101,116, 78,101, + 97,114,101,115,116, 80,111,105,110,116,115, 73,100,115, 58, + 32,121,111,117, 32,104, 97,118,101, 32,115,112,101, 99,105, + 102,105,101,100, 32,119,114,111,110,103, 32, 73, 68, 32,102, + 111,114, 32,103,114, 97,112,104,105, 99, 97,108, 32,115,117, + 114,102, 97, 99,101, 39, 44, 32, 50, 41, 13, 10,101,110,100, + 13, 10,101,110,100, 13, 10,102,117,110, 99,116,105,111,110, + 32, 85,112,100, 97,116,101, 66,105,116,109, 97,112, 40,103, + 114, 97,112,104,105, 99, 97,108, 83,117,114,102, 97, 99,101, + 73, 68, 44, 32, 98,105,116,109, 97,112, 73, 68, 41, 13, 10, + 105,102, 32,116,121,112,101, 40,103,114, 97,112,104,105, 99, + 97,108, 83,117,114,102, 97, 99,101, 73, 68, 41, 32,126, 61, + 32, 39,110,117,109, 98,101,114, 39, 32,116,104,101,110, 13, + 10,101,114,114,111,114, 40, 39, 70,105,114,115,116, 32, 97, + 114,103,117,109,101,110,116, 32,102,111,114, 32, 85,112,100, + 97,116,101, 66,105,116,109, 97,112, 32,109,117,115,116, 32, + 104, 97,118,101, 32,116,121,112,101, 32,110,117,109, 98,101, + 114, 32, 40, 73, 68, 32,102,111,114, 32,103,114, 97,112,104, + 105, 99, 97,108, 32,115,117,114,102, 97, 99,101, 41, 39, 44, + 32, 50, 41, 13, 10,101,110,100, 13, 10,105,102, 32,116,121, + 112,101, 40, 98,105,116,109, 97,112, 73, 68, 41, 32,126, 61, + 32, 39,110,117,109, 98,101,114, 39, 32,116,104,101,110, 13, + 10,101,114,114,111,114, 40, 39, 83,101, 99,111,110,100, 32, + 97,114,103,117,109,101,110,116, 32,102,111,114, 32, 85,112, + 100, 97,116,101, 66,105,116,109, 97,112, 32,109,117,115,116, + 32,104, 97,118,101, 32,116,121,112,101, 32,110,117,109, 98, + 101,114, 32, 40,110,101,119, 32, 73, 68, 32,102,111,114, 32, + 98,105,116,109, 97,112, 41, 39, 44, 32, 50, 41, 13, 10,101, + 110,100, 13, 10,108,111, 99, 97,108, 32,114,101,115, 32, 61, + 32,115, 99,101,110,101, 58, 85,112,100, 97,116,101, 66,105, + 116,109, 97,112, 40,103,114, 97,112,104,105, 99, 97,108, 83, + 117,114,102, 97, 99,101, 73, 68, 44, 32, 98,105,116,109, 97, + 112, 73, 68, 41, 13, 10,105,102, 32,114,101,115, 32, 61, 61, + 32,102, 97,108,115,101, 32,116,104,101,110, 13, 10,101,114, + 114,111,114, 40, 39, 69,114,114,111,114, 32,105,110, 32,102, + 117,110, 99,116,105,111,110, 32, 85,112,100, 97,116,101, 66, + 105,116,109, 97,112, 58, 32,121,111,117, 32,115,112,101, 99, + 105,102,105,101,100, 32,119,114,111,110,103, 32,103,114, 97, + 112,104,105, 99, 97,108, 32,115,117,114,102, 97, 99,101, 32, + 105,100, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,101, + 110,100, 13, 10,102,117,110, 99,116,105,111,110, 32, 95,117, + 115,101,114, 95,112,114,105,110,116, 40, 46, 46, 46, 41, 13, + 10,115,116,114, 32, 61, 32, 39, 39, 13, 10,102,111,114, 32, + 105, 32, 61, 32, 49, 44, 32, 97,114,103, 46,110, 45, 49, 32, + 100,111, 13, 10,115,116,114, 32, 61, 32,115,116,114, 32, 46, + 46, 32,116,111,115,116,114,105,110,103, 40, 97,114,103, 91, + 105, 93, 41, 32, 46, 46, 32, 39, 92,116, 39, 13, 10,101,110, + 100, 13, 10,115,116,114, 32, 61, 32,115,116,114, 32, 46, 46, + 32,116,111,115,116,114,105,110,103, 40, 97,114,103, 91, 97, + 114,103, 46,110, 93, 41, 32, 46, 46, 32, 39, 92,110, 39, 13, + 10, 69,102,102,101, 99,116, 77,111,100,101,108, 83, 99,114, + 105,112,116, 58, 80,114,105,110,116, 76,117, 97, 73,110,102, + 111, 40,115,116,114, 41, 13, 10,101,110,100, 13, 10,112,114, + 105,110,116, 32, 61, 32, 95,117,115,101,114, 95,112,114,105, + 110,116, 13, 10,102,117,110, 99,116,105,111,110, 32, 67,114, + 101, 97,116,101, 86,101, 99,116,111,114, 51, 40,120, 44, 32, + 121, 44, 32,122, 41, 13, 10,105,102, 32,116,121,112,101, 40, + 120, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, 32, + 97,110,100, 32,116,121,112,101, 40,121, 41, 32, 61, 61, 32, + 39,110,117,109, 98,101,114, 39, 32, 97,110,100, 32,116,121, + 112,101, 40,122, 41, 32, 61, 61, 32, 39,110,117,109, 98,101, + 114, 39, 32,116,104,101,110, 13, 10,114,101,116,117,114,110, + 32, 86,101, 99,116,111,114, 51, 40,120, 44, 32,121, 44, 32, + 122, 41, 13, 10,101,108,115,101, 13, 10,101,114,114,111,114, + 40, 39, 65,108,108, 32, 97,114,103,117,109,101,110,116,115, + 32,102,111,114, 32, 67,114,101, 97,116,101, 86,101, 99,116, + 111,114, 51, 32,109,117,115,116, 32,104, 97,118,101, 32,116, + 121,112,101, 32,110,117,109, 98,101,114, 39, 44, 32, 50, 41, + 13, 10,101,110,100, 13, 10,101,110,100, 13, 10,102,117,110, + 99,116,105,111,110, 32, 67,114,101, 97,116,101, 80,111,105, + 110,116, 40,120, 44, 32,121, 41, 13, 10,105,102, 32,116,121, + 112,101, 40,120, 41, 32, 61, 61, 32, 39,110,117,109, 98,101, + 114, 39, 32, 97,110,100, 32,116,121,112,101, 40,121, 41, 32, + 61, 61, 32, 39,110,117,109, 98,101,114, 39, 32,116,104,101, + 110, 13, 10,114,101,116,117,114,110, 32, 86,101, 99,116,111, + 114, 50, 40,120, 44, 32,121, 41, 13, 10,101,108,115,101, 13, + 10,101,114,114,111,114, 40, 39, 65,108,108, 32, 97,114,103, + 117,109,101,110,116,115, 32,102,111,114, 32, 67,114,101, 97, + 116,101, 80,111,105,110,116, 32,109,117,115,116, 32,104, 97, + 118,101, 32,116,121,112,101, 32,110,117,109, 98,101,114, 39, + 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,101,110,100, 13, + 10,102,117,110, 99,116,105,111,110, 32, 67,114,101, 97,116, + 101, 77, 97,116,114,105,120, 52, 40,109, 48, 44, 32,109, 49, + 44, 32,109, 50, 44, 32,109, 51, 44, 32,109, 52, 44, 32,109, + 53, 44, 32,109, 54, 44, 32,109, 55, 44, 32,109, 56, 44, 32, + 109, 57, 44, 32,109, 49, 48, 44, 32,109, 49, 49, 44, 32,109, + 49, 50, 44, 32,109, 49, 51, 44, 32,109, 49, 52, 44, 32,109, + 49, 53, 41, 13, 10,105,102, 32,109, 48, 32, 61, 61, 32,110, + 105,108, 32,116,104,101,110, 13, 10,114,101,116,117,114,110, + 32, 76,117, 97, 77, 97,116,114,105,120, 52, 58,110,101,119, + 95,108,111, 99, 97,108, 40, 41, 32, 13, 10,101,108,115,101, + 105,102, 32, 40,116,121,112,101, 40,109, 48, 41, 32, 61, 61, + 32, 39,110,117,109, 98,101,114, 39, 32,111,114, 32,116,111, + 108,117, 97, 46,116,121,112,101, 40,109, 48, 41, 32, 61, 61, + 32, 39, 76,117, 97, 77, 97,116,114,105,120, 52, 39, 41, 32, + 97,110,100, 32,109, 49, 32, 61, 61, 32,110,105,108, 32,116, + 104,101,110, 13, 10,114,101,116,117,114,110, 32, 76,117, 97, + 77, 97,116,114,105,120, 52, 58,110,101,119, 95,108,111, 99, + 97,108, 40,109, 48, 41, 13, 10,101,108,115,101,105,102, 32, + 116,121,112,101, 40,109, 48, 41, 32, 61, 61, 32, 39,110,117, + 109, 98,101,114, 39, 32, 97,110,100, 32,116,121,112,101, 40, + 109, 49, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, + 32, 97,110,100, 32,116,121,112,101, 40,109, 50, 41, 32, 61, + 61, 32, 39,110,117,109, 98,101,114, 39, 32, 97,110,100, 32, + 116,121,112,101, 40,109, 51, 41, 32, 61, 61, 32, 39,110,117, + 109, 98,101,114, 39, 32, 97,110,100, 32,116,121,112,101, 40, + 109, 52, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, + 32, 97,110,100, 32,116,121,112,101, 40,109, 53, 41, 32, 61, + 61, 32, 39,110,117,109, 98,101,114, 39, 32, 97,110,100, 32, + 116,121,112,101, 40,109, 54, 41, 32, 61, 61, 32, 39,110,117, + 109, 98,101,114, 39, 32, 97,110,100, 32,116,121,112,101, 40, + 109, 55, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, + 32, 97,110,100, 32,116,121,112,101, 40,109, 56, 41, 32, 61, + 61, 32, 39,110,117,109, 98,101,114, 39, 32, 97,110,100, 32, + 116,121,112,101, 40,109, 57, 41, 32, 61, 61, 32, 39,110,117, + 109, 98,101,114, 39, 32, 97,110,100, 32,116,121,112,101, 40, + 109, 49, 48, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, + 39, 32, 97,110,100, 32,116,121,112,101, 40,109, 49, 49, 41, + 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, 32, 97,110, + 100, 32,116,121,112,101, 40,109, 49, 50, 41, 32, 61, 61, 32, + 39,110,117,109, 98,101,114, 39, 32, 97,110,100, 32,116,121, + 112,101, 40,109, 49, 51, 41, 32, 61, 61, 32, 39,110,117,109, + 98,101,114, 39, 32, 97,110,100, 32,116,121,112,101, 40,109, + 49, 52, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, + 32, 97,110,100, 32,116,121,112,101, 40,109, 49, 53, 41, 32, + 61, 61, 32, 39,110,117,109, 98,101,114, 39, 32,116,104,101, + 110, 13, 10,114,101,116,117,114,110, 32, 76,117, 97, 77, 97, + 116,114,105,120, 52, 58,110,101,119, 95,108,111, 99, 97,108, + 40,109, 48, 44, 32,109, 49, 44, 32,109, 50, 44, 32,109, 51, + 44, 32,109, 52, 44, 32,109, 53, 44, 32,109, 54, 44, 32,109, + 55, 44, 32,109, 56, 44, 32,109, 57, 44, 32,109, 49, 48, 44, + 32,109, 49, 49, 44, 32,109, 49, 50, 44, 32,109, 49, 51, 44, + 32,109, 49, 52, 44, 32,109, 49, 53, 41, 13, 10,101,108,115, + 101, 13, 10,101,114,114,111,114, 40, 39, 87,114,111,110,103, + 32,110,117,109, 98,101,114, 32,111,114, 32,116,121,112,101, + 32,111,102, 32,112, 97,114, 97,109,101,116,101,114,115, 32, + 102,111,114, 32, 67,114,101, 97,116,101, 77, 97,116,114,105, + 120, 52, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,101, + 110,100, 13, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ./OtherFunctions.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static const unsigned char B[] = { + 10,102,117,110, 99,116,105,111,110, 32, 71,101,116, 73,110, + 116,101,114,112,111,108, 97,116,101,100, 86, 97,108,117,101, + 40, 95,115,111,117,114, 99,101, 44, 32, 95,116, 97,114,103, + 101,116, 44, 32, 69,102,102,101, 99,116, 84,105,109,101, 80, + 97,115,115,101,100, 44, 32, 69,102,102,101, 99,116, 68,117, + 114, 97,116,105,111,110, 44, 32, 73,110,116,101,114,112,111, + 108, 97,116,111,114, 41, 13, 10,108,111, 99, 97,108, 32,115, + 111,117,114, 99,101, 84,121,112,101, 32, 61, 32,116,111,108, + 117, 97, 46,116,121,112,101, 40, 95,115,111,117,114, 99,101, + 41, 13, 10,105,102, 32,115,111,117,114, 99,101, 84,121,112, + 101, 32,126, 61, 32, 39,110,117,109, 98,101,114, 39, 32, 97, + 110,100, 32,115,111,117,114, 99,101, 84,121,112,101, 32,126, + 61, 32, 39, 86,101, 99,116,111,114, 51, 39, 32, 97,110,100, + 32,115,111,117,114, 99,101, 84,121,112,101, 32,126, 61, 32, + 39, 99,111,110,115,116, 32, 86,101, 99,116,111,114, 51, 39, + 32, 97,110,100, 32,115,111,117,114, 99,101, 84,121,112,101, + 32,126, 61, 32, 39, 86,101, 99,116,111,114, 50, 39, 32, 97, + 110,100, 32,115,111,117,114, 99,101, 84,121,112,101, 32,126, + 61, 32, 39, 99,111,110,115,116, 32, 86,101, 99,116,111,114, + 50, 39, 32,116,104,101,110, 13, 10,101,114,114,111,114, 40, + 39, 70,105,114,115,116, 32, 97,114,103,117,109,101,110,116, + 32,102,111,114, 32, 71,101,116, 73,110,116,101,114,112,111, + 108, 97,116,101,100, 86, 97,108,117,101, 32,109,117,115,116, + 32,104, 97,118,101, 32,111,110,101, 32,111,102, 32,116,104, + 101, 32,116,121,112,101,115, 58, 32,110,117,109, 98,101,114, + 44, 32, 86,101, 99,116,111,114, 51, 32,111,114, 32, 86,101, + 99,116,111,114, 50, 39, 44, 32, 50, 41, 13, 10,101,110,100, + 13, 10,108,111, 99, 97,108, 32,115,111,117,114, 99,101, 84, + 121,112,101, 67,111,110,115,116, 13, 10,108,111, 99, 97,108, + 32,114,101,115,117,108,116, 83,101, 97, 99,104, 32, 61, 32, + 115,116,114,105,110,103, 46,102,105,110,100, 40,115,111,117, + 114, 99,101, 84,121,112,101, 44, 32, 39, 99,111,110,115,116, + 32, 39, 41, 13, 10,105,102, 32,114,101,115,117,108,116, 83, + 101, 97, 99,104, 32, 61, 61, 32,110,105,108, 32,116,104,101, + 110, 13, 10,115,111,117,114, 99,101, 84,121,112,101, 67,111, + 110,115,116, 32, 61, 32, 39, 99,111,110,115,116, 32, 39, 32, + 46, 46, 32,115,111,117,114, 99,101, 84,121,112,101, 13, 10, + 101,108,115,101, 32, 13, 10,115,111,117,114, 99,101, 84,121, + 112,101, 67,111,110,115,116, 32, 61, 32,115,116,114,105,110, + 103, 46,115,117, 98, 40,115,111,117,114, 99,101, 84,121,112, + 101, 44, 32, 55, 41, 13, 10,101,110,100, 13, 10, 13, 10,108, + 111, 99, 97,108, 32,116, 97,114,103,101,116, 84,121,112,101, + 32, 61, 32,116,111,108,117, 97, 46,116,121,112,101, 40, 95, + 116, 97,114,103,101,116, 41, 13, 10,105,102, 32,116, 97,114, + 103,101,116, 84,121,112,101, 32,126, 61, 32,115,111,117,114, + 99,101, 84,121,112,101, 32, 97,110,100, 32,116, 97,114,103, + 101,116, 84,121,112,101, 32,126, 61, 32,115,111,117,114, 99, + 101, 84,121,112,101, 67,111,110,115,116, 32,116,104,101,110, + 13, 10,101,114,114,111,114, 40, 39, 70,105,114,115,116, 32, + 97,110,100, 32,115,101, 99,111,110,100, 32, 97,114,103,117, + 109,101,110,116,115, 32,102,111,114, 32, 71,101,116, 73,110, + 116,101,114,112,111,108, 97,116,101,100, 86, 97,108,117,101, + 32,109,117,115,116, 32,104, 97,118,101, 32,115, 97,109,101, + 32,116,121,112,101,115, 39, 44, 32, 50, 41, 13, 10,101,110, + 100, 13, 10,105,102, 32,116,121,112,101, 40, 69,102,102,101, + 99,116, 84,105,109,101, 80, 97,115,115,101,100, 41, 32,126, + 61, 32, 39,110,117,109, 98,101,114, 39, 32,116,104,101,110, + 13, 10,101,114,114,111,114, 40, 39, 84,104,105,114,100, 32, + 97,114,103,117,109,101,110,116, 32,102,111,114, 32, 71,101, + 116, 73,110,116,101,114,112,111,108, 97,116,101,100, 86, 97, + 108,117,101, 32,109,117,115,116, 32,104, 97,118,101, 32,110, + 117,109, 98,101,114, 32,116,121,112,101, 39, 44, 32, 50, 41, + 13, 10,101,110,100, 13, 10,105,102, 32,116,121,112,101, 40, + 69,102,102,101, 99,116, 68,117,114, 97,116,105,111,110, 41, + 32,126, 61, 32, 39,110,117,109, 98,101,114, 39, 32,116,104, + 101,110, 13, 10,101,114,114,111,114, 40, 39, 70,111,117,114, + 116,104, 32, 97,114,103,117,109,101,110,116, 32,102,111,114, + 32, 71,101,116, 73,110,116,101,114,112,111,108, 97,116,101, + 100, 86, 97,108,117,101, 32,109,117,115,116, 32,104, 97,118, + 101, 32,110,117,109, 98,101,114, 32,116,121,112,101, 39, 44, + 32, 50, 41, 13, 10,101,110,100, 13, 10, 13, 10,105,102, 32, + 73,110,116,101,114,112,111,108, 97,116,111,114, 32, 61, 61, + 32,110,105,108, 32,116,104,101,110, 13, 10, 73,110,116,101, + 114,112,111,108, 97,116,111,114, 32, 61, 32, 76,105,110,101, + 97,114, 13, 10,101,110,100, 13, 10,105,102, 32,116,121,112, + 101, 40, 73,110,116,101,114,112,111,108, 97,116,111,114, 41, + 32,126, 61, 32, 39,102,117,110, 99,116,105,111,110, 39, 32, + 116,104,101,110, 13, 10,101,114,114,111,114, 40, 39, 70,105, + 102,116,104, 32, 97,114,103,117,109,101,110,116, 32,102,111, + 114, 32, 71,101,116, 73,110,116,101,114,112,111,108, 97,116, + 101,100, 86, 97,108,117,101, 32,115,104,111,117,108,100, 32, + 98,101, 32, 97, 32,102,117,110, 99,116,105,111,110, 32, 40, + 102,111,114, 32,101,120, 97,109,112,108,101, 32, 69, 97,115, + 101, 73,110, 79,117,116, 41, 32,111,114, 32,110,105,108, 39, + 44, 32, 50, 41, 13, 10,101,110,100, 13, 10, 13, 10,105,102, + 32, 69,102,102,101, 99,116, 68,117,114, 97,116,105,111,110, + 32, 62, 32, 49,101, 45, 52, 32,116,104,101,110, 13, 10,114, + 101,116,117,114,110, 32, 95,115,111,117,114, 99,101, 32, 43, + 32, 40, 95,116, 97,114,103,101,116, 32, 45, 32, 95,115,111, + 117,114, 99,101, 41, 32, 42, 32, 40, 73,110,116,101,114,112, + 111,108, 97,116,111,114, 40, 69,102,102,101, 99,116, 84,105, + 109,101, 80, 97,115,115,101,100, 44, 32, 69,102,102,101, 99, + 116, 68,117,114, 97,116,105,111,110, 41, 32, 47, 32, 69,102, + 102,101, 99,116, 68,117,114, 97,116,105,111,110, 41, 13, 10, + 101,108,115,101, 13, 10,101,114,114,111,114, 40, 39, 70,111, + 117,114,116,104, 32, 97,114,103,117,109,101,110,116, 32,102, + 111,114, 32, 71,101,116, 73,110,116,101,114,112,111,108, 97, + 116,101,100, 86, 97,108,117,101, 32, 40,101,102,102,101, 99, + 116, 32,100,117,114, 97,116,105,111,110, 41, 32,115,104,111, + 117,108,100, 32, 98,101, 32, 97, 32,112,111,115,105,116,105, + 118,101, 32, 40,100,117,114, 97,116,105,111,110, 32, 62, 32, + 48, 41, 39, 44, 32, 50, 41, 13, 10,101,110,100, 32, 13, 10, + 101,110,100, 13, 10,102,117,110, 99,116,105,111,110, 32, 76, + 105,110,101, 97,114, 40, 69,102,102,101, 99,116, 84,105,109, + 101, 80, 97,115,115,101,100, 44, 32, 69,102,102,101, 99,116, + 68,117,114, 97,116,105,111,110, 41, 13, 10,105,102, 32,116, + 121,112,101, 40, 69,102,102,101, 99,116, 84,105,109,101, 80, + 97,115,115,101,100, 41, 32,126, 61, 32, 39,110,117,109, 98, + 101,114, 39, 32,116,104,101,110, 13, 10,101,114,114,111,114, + 40, 39, 70,105,114,115,116, 32, 97,114,103,117,109,101,110, + 116, 32,102,111,114, 32, 76,105,110,101, 97,114, 32,109,117, + 115,116, 32,104, 97,118,101, 32,110,117,109, 98,101,114, 32, + 116,121,112,101, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, + 10,114,101,116,117,114,110, 32, 69,102,102,101, 99,116, 84, + 105,109,101, 80, 97,115,115,101,100, 13, 10,101,110,100, 13, + 10, 13, 10,102,117,110, 99,116,105,111,110, 32, 68,105,115, + 99,114,101,116,101, 40, 69,102,102,101, 99,116, 84,105,109, + 101, 80, 97,115,115,101,100, 44, 32, 69,102,102,101, 99,116, + 68,117,114, 97,116,105,111,110, 41, 13, 10,105,102, 32,116, + 121,112,101, 40, 69,102,102,101, 99,116, 84,105,109,101, 80, + 97,115,115,101,100, 41, 32,126, 61, 32, 39,110,117,109, 98, + 101,114, 39, 32,116,104,101,110, 13, 10,101,114,114,111,114, + 40, 39, 70,105,114,115,116, 32, 97,114,103,117,109,101,110, + 116, 32,102,111,114, 32, 68,105,115, 99,114,101,116,101, 32, + 109,117,115,116, 32,104, 97,118,101, 32,110,117,109, 98,101, + 114, 32,116,121,112,101, 39, 44, 32, 50, 41, 13, 10,101,110, + 100, 13, 10,105,102, 32,116,121,112,101, 40, 69,102,102,101, + 99,116, 68,117,114, 97,116,105,111,110, 41, 32,126, 61, 32, + 39,110,117,109, 98,101,114, 39, 32,116,104,101,110, 13, 10, + 101,114,114,111,114, 40, 39, 83,101, 99,111,110,100, 32, 97, + 114,103,117,109,101,110,116, 32,102,111,114, 32, 68,105,115, + 99,114,101,116,101, 32,109,117,115,116, 32,104, 97,118,101, + 32,110,117,109, 98,101,114, 32,116,121,112,101, 39, 44, 32, + 50, 41, 13, 10,101,110,100, 13, 10, 13, 10,105,102, 32, 69, + 102,102,101, 99,116, 84,105,109,101, 80, 97,115,115,101,100, + 32, 60, 32, 69,102,102,101, 99,116, 68,117,114, 97,116,105, + 111,110, 32,116,104,101,110, 13, 10,114,101,116,117,114,110, + 32, 48, 13, 10,101,108,115,101, 32, 13, 10,114,101,116,117, + 114,110, 32, 69,102,102,101, 99,116, 68,117,114, 97,116,105, + 111,110, 13, 10,101,110,100, 13, 10,101,110,100, 13, 10,102, + 117,110, 99,116,105,111,110, 32, 69, 97,115,101, 73,110, 40, + 69,102,102,101, 99,116, 84,105,109,101, 80, 97,115,115,101, + 100, 44, 32, 69,102,102,101, 99,116, 68,117,114, 97,116,105, + 111,110, 41, 13, 10,105,102, 32,116,121,112,101, 40, 69,102, + 102,101, 99,116, 84,105,109,101, 80, 97,115,115,101,100, 41, + 32,126, 61, 32, 39,110,117,109, 98,101,114, 39, 32,116,104, + 101,110, 13, 10,101,114,114,111,114, 40, 39, 70,105,114,115, + 116, 32, 97,114,103,117,109,101,110,116, 32,102,111,114, 32, + 69, 97,115,101, 73,110, 32,109,117,115,116, 32,104, 97,118, + 101, 32,110,117,109, 98,101,114, 32,116,121,112,101, 39, 44, + 32, 50, 41, 13, 10,101,110,100, 13, 10,105,102, 32,116,121, + 112,101, 40, 69,102,102,101, 99,116, 68,117,114, 97,116,105, + 111,110, 41, 32,126, 61, 32, 39,110,117,109, 98,101,114, 39, + 32,116,104,101,110, 13, 10,101,114,114,111,114, 40, 39, 83, + 101, 99,111,110,100, 32, 97,114,103,117,109,101,110,116, 32, + 102,111,114, 32, 69, 97,115,101, 73,110, 32,109,117,115,116, + 32,104, 97,118,101, 32,110,117,109, 98,101,114, 32,116,121, + 112,101, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10, 13, + 10,105,102, 32, 69,102,102,101, 99,116, 84,105,109,101, 80, + 97,115,115,101,100, 32, 62, 32, 69,102,102,101, 99,116, 68, + 117,114, 97,116,105,111,110, 32,116,104,101,110, 13, 10, 69, + 102,102,101, 99,116, 84,105,109,101, 80, 97,115,115,101,100, + 32, 61, 32, 69,102,102,101, 99,116, 68,117,114, 97,116,105, + 111,110, 13, 10,101,110,100, 13, 10, 13, 10,114,101,116,117, + 114,110, 32, 45,109, 97,116,104, 46,115,113,114,116, 40, 69, + 102,102,101, 99,116, 68,117,114, 97,116,105,111,110, 32, 42, + 32, 69,102,102,101, 99,116, 68,117,114, 97,116,105,111,110, + 32, 45, 32, 69,102,102,101, 99,116, 84,105,109,101, 80, 97, + 115,115,101,100, 32, 42, 32, 69,102,102,101, 99,116, 84,105, + 109,101, 80, 97,115,115,101,100, 41, 32, 43, 32, 69,102,102, + 101, 99,116, 68,117,114, 97,116,105,111,110, 13, 10,101,110, + 100, 13, 10,102,117,110, 99,116,105,111,110, 32, 69, 97,115, + 101, 79,117,116, 40, 69,102,102,101, 99,116, 84,105,109,101, + 80, 97,115,115,101,100, 44, 32, 69,102,102,101, 99,116, 68, + 117,114, 97,116,105,111,110, 41, 13, 10,105,102, 32,116,121, + 112,101, 40, 69,102,102,101, 99,116, 84,105,109,101, 80, 97, + 115,115,101,100, 41, 32,126, 61, 32, 39,110,117,109, 98,101, + 114, 39, 32,116,104,101,110, 13, 10,101,114,114,111,114, 40, + 39, 70,105,114,115,116, 32, 97,114,103,117,109,101,110,116, + 32,102,111,114, 32, 69, 97,115,101, 79,117,116, 32,109,117, + 115,116, 32,104, 97,118,101, 32,110,117,109, 98,101,114, 32, + 116,121,112,101, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, + 10,105,102, 32,116,121,112,101, 40, 69,102,102,101, 99,116, + 68,117,114, 97,116,105,111,110, 41, 32,126, 61, 32, 39,110, + 117,109, 98,101,114, 39, 32,116,104,101,110, 13, 10,101,114, + 114,111,114, 40, 39, 83,101, 99,111,110,100, 32, 97,114,103, + 117,109,101,110,116, 32,102,111,114, 32, 69, 97,115,101, 79, + 117,116, 32,109,117,115,116, 32,104, 97,118,101, 32,110,117, + 109, 98,101,114, 32,116,121,112,101, 39, 44, 32, 50, 41, 13, + 10,101,110,100, 13, 10, 13, 10,105,102, 32, 69,102,102,101, + 99,116, 84,105,109,101, 80, 97,115,115,101,100, 32, 62, 32, + 69,102,102,101, 99,116, 68,117,114, 97,116,105,111,110, 32, + 116,104,101,110, 13, 10, 69,102,102,101, 99,116, 84,105,109, + 101, 80, 97,115,115,101,100, 32, 61, 32, 69,102,102,101, 99, + 116, 68,117,114, 97,116,105,111,110, 13, 10,101,110,100, 13, + 10, 13, 10,114,101,116,117,114,110, 32,109, 97,116,104, 46, + 115,113,114,116, 40, 69,102,102,101, 99,116, 68,117,114, 97, + 116,105,111,110, 32, 42, 32, 69,102,102,101, 99,116, 68,117, + 114, 97,116,105,111,110, 32, 45, 32, 40, 69,102,102,101, 99, + 116, 84,105,109,101, 80, 97,115,115,101,100, 32, 45, 32, 69, + 102,102,101, 99,116, 68,117,114, 97,116,105,111,110, 41, 32, + 42, 32, 40, 69,102,102,101, 99,116, 84,105,109,101, 80, 97, + 115,115,101,100, 32, 45, 32, 69,102,102,101, 99,116, 68,117, + 114, 97,116,105,111,110, 41, 41, 13, 10,101,110,100, 13, 10, + 102,117,110, 99,116,105,111,110, 32, 69, 97,115,101, 73,110, + 79,117,116, 40, 69,102,102,101, 99,116, 84,105,109,101, 80, + 97,115,115,101,100, 44, 32, 69,102,102,101, 99,116, 68,117, + 114, 97,116,105,111,110, 41, 13, 10,105,102, 32,116,121,112, + 101, 40, 69,102,102,101, 99,116, 84,105,109,101, 80, 97,115, + 115,101,100, 41, 32,126, 61, 32, 39,110,117,109, 98,101,114, + 39, 32,116,104,101,110, 13, 10,101,114,114,111,114, 40, 39, + 70,105,114,115,116, 32, 97,114,103,117,109,101,110,116, 32, + 102,111,114, 32, 69, 97,115,101, 73,110, 79,117,116, 32,109, + 117,115,116, 32,104, 97,118,101, 32,110,117,109, 98,101,114, + 32,116,121,112,101, 39, 44, 32, 50, 41, 13, 10,101,110,100, + 13, 10,105,102, 32,116,121,112,101, 40, 69,102,102,101, 99, + 116, 68,117,114, 97,116,105,111,110, 41, 32,126, 61, 32, 39, + 110,117,109, 98,101,114, 39, 32,116,104,101,110, 13, 10,101, + 114,114,111,114, 40, 39, 83,101, 99,111,110,100, 32, 97,114, + 103,117,109,101,110,116, 32,102,111,114, 32, 69, 97,115,101, + 73,110, 79,117,116, 32,109,117,115,116, 32,104, 97,118,101, + 32,110,117,109, 98,101,114, 32,116,121,112,101, 39, 44, 32, + 50, 41, 13, 10,101,110,100, 13, 10, 13, 10,105,102, 32, 69, + 102,102,101, 99,116, 84,105,109,101, 80, 97,115,115,101,100, + 32, 62, 32, 69,102,102,101, 99,116, 68,117,114, 97,116,105, + 111,110, 32,116,104,101,110, 13, 10, 69,102,102,101, 99,116, + 84,105,109,101, 80, 97,115,115,101,100, 32, 61, 32, 69,102, + 102,101, 99,116, 68,117,114, 97,116,105,111,110, 13, 10,101, + 110,100, 13, 10, 13, 10,108,111, 99, 97,108, 32,100,117,114, + 50, 32, 61, 32, 69,102,102,101, 99,116, 68,117,114, 97,116, + 105,111,110, 32, 47, 32, 50, 13, 10,105,102, 32, 69,102,102, + 101, 99,116, 84,105,109,101, 80, 97,115,115,101,100, 32, 60, + 32,100,117,114, 50, 32,116,104,101,110, 32, 13, 10,114,101, + 116,117,114,110, 32, 45,109, 97,116,104, 46,115,113,114,116, + 40,100,117,114, 50, 32, 42, 32,100,117,114, 50, 32, 45, 32, + 69,102,102,101, 99,116, 84,105,109,101, 80, 97,115,115,101, + 100, 32, 42, 32, 69,102,102,101, 99,116, 84,105,109,101, 80, + 97,115,115,101,100, 41, 32, 43, 32,100,117,114, 50, 13, 10, + 101,108,115,101, 32, 13, 10,114,101,116,117,114,110, 32,109, + 97,116,104, 46,115,113,114,116, 40,100,117,114, 50, 32, 42, + 32,100,117,114, 50, 32, 45, 32, 40, 69,102,102,101, 99,116, + 84,105,109,101, 80, 97,115,115,101,100, 32, 45, 32, 69,102, + 102,101, 99,116, 68,117,114, 97,116,105,111,110, 41, 32, 42, + 32, 40, 69,102,102,101, 99,116, 84,105,109,101, 80, 97,115, + 115,101,100, 32, 45, 32, 69,102,102,101, 99,116, 68,117,114, + 97,116,105,111,110, 41, 41, 32, 43, 32,100,117,114, 50, 13, + 10,101,110,100, 13, 10,101,110,100, 13, 10, 95, 80,111,105, + 110,116, 48, 95, 66,101,122,105,101,114, 32, 61, 32, 86,101, + 99,116,111,114, 50, 40, 48, 44, 32, 48, 41, 13, 10, 95, 80, + 111,105,110,116, 49, 95, 66,101,122,105,101,114, 32, 61, 32, + 86,101, 99,116,111,114, 50, 40, 48, 46, 50, 44, 32, 50, 41, + 13, 10, 95, 80,111,105,110,116, 50, 95, 66,101,122,105,101, + 114, 32, 61, 32, 86,101, 99,116,111,114, 50, 40, 48, 46, 56, + 44, 32, 45, 49, 41, 32, 13, 10, 95, 80,111,105,110,116, 51, + 95, 66,101,122,105,101,114, 32, 61, 32, 86,101, 99,116,111, + 114, 50, 40, 49, 44, 32, 49, 41, 13, 10, 13, 10,102,117,110, + 99,116,105,111,110, 32, 83,101,116, 66,101,115,105,101,114, + 73,110,116,101,114,112,111,108, 97,116,111,114, 40, 80,111, + 105,110,116, 49, 44, 32, 80,111,105,110,116, 50, 41, 13, 10, + 108,111, 99, 97,108, 32,112,111,105,110,116, 49, 84,121,112, + 101, 32, 61, 32,116,111,108,117, 97, 46,116,121,112,101, 40, + 80,111,105,110,116, 49, 41, 13, 10,105,102, 32,112,111,105, + 110,116, 49, 84,121,112,101, 32, 61, 61, 32, 39, 86,101, 99, + 116,111,114, 50, 39, 32,111,114, 32,112,111,105,110,116, 49, + 84,121,112,101, 32, 61, 61, 32, 39, 99,111,110,115,116, 32, + 86,101, 99,116,111,114, 50, 39, 32,116,104,101,110, 13, 10, + 95, 80,111,105,110,116, 49, 95, 66,101,122,105,101,114, 46, + 120, 32, 61, 32, 80,111,105,110,116, 49, 46,120, 13, 10, 95, + 80,111,105,110,116, 49, 95, 66,101,122,105,101,114, 46,121, + 32, 61, 32, 80,111,105,110,116, 49, 46,121, 13, 10,101,108, + 115,101, 13, 10,101,114,114,111,114, 40, 39, 70,105,114,115, + 116, 32, 97,114,103,117,109,101,110,116, 32,102,111,114, 32, + 83,101,116, 66,101,115,105,101,114, 73,110,116,101,114,112, + 111,108, 97,116,111,114, 32,109,117,115,116, 32,104, 97,118, + 101, 32, 86,101, 99,116,111,114, 50, 32,116,121,112,101, 39, + 44, 32, 50, 41, 13, 10,101,110,100, 13, 10, 13, 10,108,111, + 99, 97,108, 32,112,111,105,110,116, 50, 84,121,112,101, 32, + 61, 32,116,111,108,117, 97, 46,116,121,112,101, 40, 80,111, + 105,110,116, 50, 41, 13, 10,105,102, 32,112,111,105,110,116, + 50, 84,121,112,101, 32, 61, 61, 32, 39, 86,101, 99,116,111, + 114, 50, 39, 32,111,114, 32,112,111,105,110,116, 50, 84,121, + 112,101, 32, 61, 61, 32, 39, 99,111,110,115,116, 32, 86,101, + 99,116,111,114, 50, 39, 32,116,104,101,110, 32, 13, 10, 95, + 80,111,105,110,116, 50, 95, 66,101,122,105,101,114, 46,120, + 32, 61, 32, 80,111,105,110,116, 50, 46,120, 13, 10, 95, 80, + 111,105,110,116, 50, 95, 66,101,122,105,101,114, 46,121, 32, + 61, 32, 80,111,105,110,116, 50, 46,121, 13, 10,101,108,115, + 101, 13, 10,101,114,114,111,114, 40, 39, 83,101, 99,111,110, + 100, 32, 97,114,103,117,109,101,110,116, 32,102,111,114, 32, + 83,101,116, 66,101,115,105,101,114, 73,110,116,101,114,112, + 111,108, 97,116,111,114, 32,109,117,115,116, 32,104, 97,118, + 101, 32, 86,101, 99,116,111,114, 50, 32,116,121,112,101, 39, + 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,101,110,100, 13, + 10, 13, 10,102,117,110, 99,116,105,111,110, 32, 66,101,122, + 105,101,114, 40, 69,102,102,101, 99,116, 84,105,109,101, 80, + 97,115,115,101,100, 44, 32, 69,102,102,101, 99,116, 68,117, + 114, 97,116,105,111,110, 41, 13, 10,105,102, 32,116,121,112, + 101, 40, 69,102,102,101, 99,116, 84,105,109,101, 80, 97,115, + 115,101,100, 41, 32,126, 61, 32, 39,110,117,109, 98,101,114, + 39, 32,116,104,101,110, 13, 10,101,114,114,111,114, 40, 39, + 70,105,114,115,116, 32, 97,114,103,117,109,101,110,116, 32, + 102,111,114, 32, 66,101,122,105,101,114, 32,109,117,115,116, + 32,104, 97,118,101, 32,110,117,109, 98,101,114, 32,116,121, + 112,101, 39, 44, 32, 50, 41, 13, 10,101,110,100, 13, 10,105, + 102, 32,116,121,112,101, 40, 69,102,102,101, 99,116, 68,117, + 114, 97,116,105,111,110, 41, 32,126, 61, 32, 39,110,117,109, + 98,101,114, 39, 32,116,104,101,110, 13, 10,101,114,114,111, + 114, 40, 39, 83,101, 99,111,110,100, 32, 97,114,103,117,109, + 101,110,116, 32,102,111,114, 32, 66,101,122,105,101,114, 32, + 109,117,115,116, 32,104, 97,118,101, 32,110,117,109, 98,101, + 114, 32,116,121,112,101, 39, 44, 32, 50, 41, 13, 10,101,110, + 100, 13, 10, 13, 10,105,102, 32, 69,102,102,101, 99,116, 68, + 117,114, 97,116,105,111,110, 32, 60, 32, 49,101, 45, 52, 32, + 116,104,101,110, 13, 10,101,114,114,111,114, 40, 39, 83,101, + 99,111,110,100, 32, 97,114,103,117,109,101,110,116, 32,102, + 111,114, 32, 66,101,122,105,101,114, 32, 40,100,117,114, 97, + 116,105,111,110, 41, 32,115,104,111,117,108,100, 32, 98,101, + 32, 97, 32,112,111,115,105,116,105,118,101, 32, 40,100,117, + 114, 97,116,105,111,110, 32, 62, 32, 48, 41, 39, 44, 32, 50, + 41, 13, 10,101,110,100, 13, 10, 13, 10,105,102, 32, 69,102, + 102,101, 99,116, 84,105,109,101, 80, 97,115,115,101,100, 32, + 62, 32, 69,102,102,101, 99,116, 68,117,114, 97,116,105,111, + 110, 32,116,104,101,110, 13, 10, 69,102,102,101, 99,116, 84, + 105,109,101, 80, 97,115,115,101,100, 32, 61, 32, 69,102,102, + 101, 99,116, 68,117,114, 97,116,105,111,110, 13, 10,101,110, + 100, 13, 10, 13, 10,105,102, 32,116,111,108,117, 97, 46,116, + 121,112,101, 40, 95, 80,111,105,110,116, 48, 95, 66,101,122, + 105,101,114, 41, 32,126, 61, 32, 39, 86,101, 99,116,111,114, + 50, 39, 32,111,114, 32,116,111,108,117, 97, 46,116,121,112, + 101, 40, 95, 80,111,105,110,116, 49, 95, 66,101,122,105,101, + 114, 41, 32,126, 61, 32, 39, 86,101, 99,116,111,114, 50, 39, + 32,111,114, 32,116,111,108,117, 97, 46,116,121,112,101, 40, + 95, 80,111,105,110,116, 50, 95, 66,101,122,105,101,114, 41, + 32,126, 61, 32, 39, 86,101, 99,116,111,114, 50, 39, 32,111, + 114, 32,116,111,108,117, 97, 46,116,121,112,101, 40, 95, 80, + 111,105,110,116, 51, 95, 66,101,122,105,101,114, 41, 32,126, + 61, 32, 39, 86,101, 99,116,111,114, 50, 39, 32,116,104,101, + 110, 13, 10,101,114,114,111,114, 40, 39, 83,121,115,116,101, + 109, 32,101,114,114,111,114, 39, 44, 32, 50, 41, 13, 10,101, + 110,100, 13, 10, 13, 10,108,111, 99, 97,108, 32,116, 32, 61, + 32, 69,102,102,101, 99,116, 84,105,109,101, 80, 97,115,115, + 101,100, 32, 47, 32, 69,102,102,101, 99,116, 68,117,114, 97, + 116,105,111,110, 13, 10,108,111, 99, 97,108, 32,114,101,115, + 32, 61, 32, 40, 49, 32, 45, 32,116, 41, 32, 42, 32, 40, 49, + 32, 45, 32,116, 41, 32, 42, 32, 40, 49, 32, 45, 32,116, 41, + 32, 42, 32, 95, 80,111,105,110,116, 48, 95, 66,101,122,105, + 101,114, 13, 10,114,101,115, 32, 61, 32,114,101,115, 32, 43, + 32, 51, 32, 42, 32,116, 32, 42, 32, 40, 49, 32, 45, 32,116, + 41, 32, 42, 32, 40, 49, 32, 45, 32,116, 41, 32, 42, 32, 69, + 102,102,101, 99,116, 68,117,114, 97,116,105,111,110, 32, 42, + 32, 95, 80,111,105,110,116, 49, 95, 66,101,122,105,101,114, + 13, 10,114,101,115, 32, 61, 32,114,101,115, 32, 43, 32, 51, + 32, 42, 32,116, 32, 42, 32,116, 32, 42, 32, 40, 49, 32, 45, + 32,116, 41, 32, 42, 32, 69,102,102,101, 99,116, 68,117,114, + 97,116,105,111,110, 32, 42, 32, 95, 80,111,105,110,116, 50, + 95, 66,101,122,105,101,114, 13, 10,114,101,115, 32, 61, 32, + 114,101,115, 32, 43, 32,116, 32, 42, 32,116, 32, 42, 32,116, + 32, 42, 32, 69,102,102,101, 99,116, 68,117,114, 97,116,105, + 111,110, 32, 42, 32, 95, 80,111,105,110,116, 51, 95, 66,101, + 122,105,101,114, 13, 10,114,101,116,117,114,110, 32,114,101, + 115, 46,121, 13, 10,101,110,100, 13, 10, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ./animation.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + + { /* begin embedded lua code */ + int top = lua_gettop(tolua_S); + static const unsigned char B[] = { + 10,102,117,110, 99,116,105,111,110, 32, 65,100,100, 85,110, + 105,116, 76,105,103,104,116, 40,117,110,105,116, 76,105,103, + 104,116, 41, 10,108,111, 99, 97,108, 32,116,121,112,101, 65, + 114,103, 32, 61, 32,116,111,108,117, 97, 46,116,121,112,101, + 40,117,110,105,116, 76,105,103,104,116, 41, 10,105,102, 32, + 116,121,112,101, 65,114,103, 32, 61, 61, 32, 39, 80,111,105, + 110,116, 76,105,103,104,116, 39, 32,111,114, 32,116,121,112, + 101, 65,114,103, 32, 61, 61, 32, 39, 83,112,111,116, 76,105, + 103,104,116, 39, 32,111,114, 32,116,121,112,101, 65,114,103, + 32, 61, 61, 32, 39, 68,105,114,101, 99,116,105,111,110, 97, + 108, 76,105,103,104,116, 39, 32,116,104,101,110, 10,108,111, + 99, 97,108, 32,114,101,115, 32, 61, 32,115, 99,101,110,101, + 58, 65,100,100, 85,110,105,116, 76,105,103,104,116, 40,117, + 110,105,116, 76,105,103,104,116, 41, 10,105,102, 32,114,101, + 115, 32, 61, 61, 32,102, 97,108,115,101, 32,116,104,101,110, + 10,101,114,114,111,114, 40, 39, 69,114,114,111,114, 32,105, + 110, 32,102,117,110, 99,116,105,111,110, 32, 65,100,100, 85, + 110,105,116, 76,105,103,104,116, 58, 32,117,110,105,116, 32, + 108,105,103,104,116, 32,119,105,116,104, 32,115, 97,109,101, + 32,110, 97,109,101, 32,119, 97,115, 32, 97,100,100,101,100, + 32,101, 97,114,108,105,101,114, 39, 44, 32, 50, 41, 10,101, + 110,100, 10,101,108,115,101, 10,101,114,114,111,114, 40, 39, + 65,114,103,117,109,101,110,116, 32,102,111,114, 32, 65,100, + 100, 85,110,105,116, 76,105,103,104,116, 32,109,117,115,116, + 32,104, 97,118,101, 32,111,110,101, 32,111,102, 32,116,104, + 101, 32,116,121,112,101, 58, 32, 80,111,105,110,116, 76,105, + 103,104,116, 44, 32, 83,112,111,116, 76,105,103,104,116, 32, + 111,114, 32, 68,105,114,101, 99,116,105,111,110, 97,108, 76, + 105,103,104,116, 39, 44, 32, 50, 41, 10,101,110,100, 10,101, + 110,100, 10,102,117,110, 99,116,105,111,110, 32, 82,101,109, + 111,118,101, 85,110,105,116, 76,105,103,104,116, 40, 97,114, + 103, 41, 10,105,102, 32,116,121,112,101, 40, 97,114,103, 41, + 32, 61, 61, 32, 39,115,116,114,105,110,103, 39, 32,116,104, + 101,110, 10,108,111, 99, 97,108, 32,114,101,115, 32, 61, 32, + 115, 99,101,110,101, 58, 82,101,109,111,118,101, 85,110,105, + 116, 76,105,103,104,116, 40, 97,114,103, 41, 10,105,102, 32, + 114,101,115, 32, 61, 61, 32,102, 97,108,115,101, 32,116,104, + 101,110, 10,101,114,114,111,114, 40, 39, 69,114,114,111,114, + 32,105,110, 32,102,117,110, 99,116,105,111,110, 32, 82,101, + 109,111,118,101, 85,110,105,116, 76,105,103,104,116, 58, 32, + 117,110,105,116, 32,108,105,103,104,116, 32,119,105,116,104, + 32,115,112,101, 99,105,102,105,101,100, 32,110, 97,109,101, + 32,119, 97,115, 32,110,111,116, 32, 97,100,100,101,100, 32, + 105,110,116,111, 32,115, 99,101,110,101, 39, 44, 32, 50, 41, + 10,101,110,100, 10,101,108,115,101, 10,101,114,114,111,114, + 40, 39, 65,114,103,117,109,101,110,116, 32,102,111,114, 32, + 82,101,109,111,118,101, 85,110,105,116, 76,105,103,104,116, + 32,109,117,115,116, 32,104, 97,118,101, 32,115,116,114,105, + 110,103, 32,116,121,112,101, 39, 44, 32, 50, 41, 10,101,110, + 100, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, + 82,101,109,111,118,101, 65,108,108, 85,110,105,116,115, 76, + 105,103,104,116, 84,121,112,101, 40,115,116,114, 41, 10,108, + 111, 99, 97,108, 32,114,101,115, 32, 61, 32,102, 97,108,115, + 101, 10,105,102, 32,116,121,112,101, 40,115,116,114, 41, 32, + 126, 61, 32, 39,115,116,114,105,110,103, 39, 32,116,104,101, + 110, 10,101,114,114,111,114, 40, 39, 65,114,103,117,109,101, + 110,116, 32,102,111,114, 32, 82,101,109,111,118,101, 65,108, + 108, 85,110,105,116,115, 76,105,103,104,116, 84,121,112,101, + 32,109,117,115,116, 32,104, 97,118,101, 32,115,116,114,105, + 110,103, 32,116,121,112,101, 39, 44, 32, 50, 41, 10,101,108, + 115,101,105,102, 32,115,116,114, 32, 61, 61, 32, 39,112,111, + 105,110,116, 39, 32,116,104,101,110, 10,114,101,115, 32, 61, + 32,115, 99,101,110,101, 58, 82,101,109,111,118,101, 65,108, + 108, 85,110,105,116,115, 76,105,103,104,116, 84,121,112,101, + 40, 84, 89, 80, 69, 95, 85, 78, 73, 84, 95, 76, 73, 71, 72, + 84, 95, 80, 79, 73, 78, 84, 41, 10,101,108,115,101,105,102, + 32,115,116,114, 32, 61, 61, 32, 39,115,112,111,116, 39, 32, + 116,104,101,110, 10,114,101,115, 32, 61, 32,115, 99,101,110, + 101, 58, 82,101,109,111,118,101, 65,108,108, 85,110,105,116, + 115, 76,105,103,104,116, 84,121,112,101, 40, 84, 89, 80, 69, + 95, 85, 78, 73, 84, 95, 76, 73, 71, 72, 84, 95, 83, 80, 79, + 84, 41, 10,101,108,115,101,105,102, 32,115,116,114, 32, 61, + 61, 32, 39,100,105,114,101, 99,116,105,111,110, 97,108, 39, + 32,116,104,101,110, 10,114,101,115, 32, 61, 32,115, 99,101, + 110,101, 58, 82,101,109,111,118,101, 65,108,108, 85,110,105, + 116,115, 76,105,103,104,116, 84,121,112,101, 40, 84, 89, 80, + 69, 95, 85, 78, 73, 84, 95, 76, 73, 71, 72, 84, 95, 68, 73, + 82, 69, 67, 84, 73, 79, 78, 65, 76, 41, 10,101,108,115,101, + 10,101,114,114,111,114, 40, 39, 65,114,103,117,109,101,110, + 116, 32,102,111,114, 32, 82,101,109,111,118,101, 65,108,108, + 85,110,105,116,115, 76,105,103,104,116, 84,121,112,101, 32, + 109,117,115,116, 32,104, 97,118,101, 32,111,110,101, 32,111, + 102, 32,116,104,101, 32,115,116,114,105,110,103, 32,118, 97, + 108,117,101, 58, 32,112,111,105,110,116, 44, 32,115,112,111, + 116, 32,111,114, 32,100,105,114,101, 99,116,105,111,110, 97, + 108, 39, 44, 32, 50, 41, 10,101,110,100, 10,105,102, 32,114, + 101,115, 32, 61, 61, 32,102, 97,108,115,101, 32,116,104,101, + 110, 10,101,114,114,111,114, 40, 39, 73,110,116,101,114,110, + 97,108, 32,101,114,114,111,114, 39, 44, 32, 49, 41, 10,101, + 110,100, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, + 32, 71,101,116, 85,110,105,116, 76,105,103,104,116, 40, 97, + 114,103, 41, 10,105,102, 32,116,121,112,101, 40, 97,114,103, + 41, 32, 61, 61, 32, 39,115,116,114,105,110,103, 39, 32,116, + 104,101,110, 10,108,111, 99, 97,108, 32,114,101,115, 32, 61, + 32,115, 99,101,110,101, 58, 71,101,116, 85,110,105,116, 76, + 105,103,104,116, 40, 97,114,103, 41, 10,105,102, 32,114,101, + 115, 46,116,121,112,101, 32, 61, 61, 32, 80,114,111,112,101, + 114,116,121, 67, 97,115,116, 46, 80, 79, 73, 78, 84, 95, 76, + 73, 71, 72, 84, 32,116,104,101,110, 10,114,101,116,117,114, + 110, 32,114,101,115, 46,118, 97,108,117,101, 46,112, 80,111, + 105,110,116, 76,105,103,104,116, 10,101,108,115,101,105,102, + 32,114,101,115, 46,116,121,112,101, 32, 61, 61, 32, 80,114, + 111,112,101,114,116,121, 67, 97,115,116, 46, 83, 80, 79, 84, + 95, 76, 73, 71, 72, 84, 32,116,104,101,110, 10,114,101,116, + 117,114,110, 32,114,101,115, 46,118, 97,108,117,101, 46,112, + 83,112,111,116, 76,105,103,104,116, 10,101,108,115,101,105, + 102, 32,114,101,115, 46,116,121,112,101, 32, 61, 61, 32, 80, + 114,111,112,101,114,116,121, 67, 97,115,116, 46, 68, 73, 82, + 69, 67, 84, 73, 79, 78, 65, 76, 95, 76, 73, 71, 72, 84, 32, + 116,104,101,110, 10,114,101,116,117,114,110, 32,114,101,115, + 46,118, 97,108,117,101, 46,112, 68,105,114,101, 99,116,105, + 111,110, 97,108, 76,105,103,104,116, 10,101,108,115,101, 10, + 101,114,114,111,114, 40, 39, 69,114,114,111,114, 32,105,110, + 32,102,117,110, 99,116,105,111,110, 32, 71,101,116, 85,110, + 105,116, 76,105,103,104,116, 58, 32,117,110,105,116, 32,108, + 105,103,104,116, 32,119,105,116,104, 32,115,112,101, 99,105, + 102,105,101,100, 32,110, 97,109,101, 32,119, 97,115, 32,110, + 111,116, 32, 97,100,100,101,100, 32,105,110,116,111, 32,115, + 99,101,110,101, 39, 44, 32, 50, 41, 10,101,110,100, 10,101, + 108,115,101, 10,101,114,114,111,114, 40, 39, 65,114,103,117, + 109,101,110,116, 32,102,111,114, 32, 71,101,116, 85,110,105, + 116, 76,105,103,104,116, 32,109,117,115,116, 32,104, 97,118, + 101, 32,115,116,114,105,110,103, 32,116,121,112,101, 39, 44, + 32, 50, 41, 10,101,110,100, 10,101,110,100, 10,102,117,110, + 99,116,105,111,110, 32, 83,101,116, 76,105,103,104,116, 65, + 109, 98,105,101,110,116, 67,111,108,111,117,114, 40,114,101, + 100, 44, 32,103,114,101,101,110, 44, 32, 98,108,117,101, 41, + 10,108,111, 99, 97,108, 32,116,121,112,101, 70,105,114,115, + 116, 65,114,103, 32, 61, 32,116,111,108,117, 97, 46,116,121, + 112,101, 40,114,101,100, 41, 10,105,102, 32,116,121,112,101, + 70,105,114,115,116, 65,114,103, 32, 61, 61, 32, 39, 86,101, + 99,116,111,114, 51, 39, 32,111,114, 32,116,121,112,101, 70, + 105,114,115,116, 65,114,103, 32, 61, 61, 32, 39, 99,111,110, + 115,116, 32, 86,101, 99,116,111,114, 51, 39, 32,116,104,101, + 110, 10,105,102, 32,103,114,101,101,110, 32, 61, 61, 32,110, + 105,108, 32, 97,110,100, 32, 98,108,117,101, 32, 61, 61, 32, + 110,105,108, 32,116,104,101,110, 10,115, 99,101,110,101, 58, + 83,101,116, 76,105,103,104,116, 65,109, 98,105,101,110,116, + 67,111,108,111,117,114, 40,114,101,100, 41, 10,101,108,115, + 101, 10,101,114,114,111,114, 40, 39, 87,114,111,110,103, 32, + 110,117,109, 98,101,114, 32,111,114, 32,116,121,112,101, 32, + 111,102, 32,112, 97,114, 97,109,101,116,101,114,115, 32,102, + 111,114, 32, 83,101,116, 76,105,103,104,116, 65,109, 98,105, + 101,110,116, 67,111,108,111,117,114, 32, 40,115,101,101, 32, + 102,114,111,109, 32,115,101, 99,111,110,100, 32,112, 97,114, + 97,109,101,116,101,114, 41, 39, 44, 32, 50, 41, 10,101,110, + 100, 10,101,108,115,101,105,102, 32,116,121,112,101, 70,105, + 114,115,116, 65,114,103, 32, 61, 61, 32, 39,110,117,109, 98, + 101,114, 39, 32, 97,110,100, 32,116,121,112,101, 40,103,114, + 101,101,110, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, + 39, 32, 97,110,100, 32,116,121,112,101, 40, 98,108,117,101, + 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, 39, 32,116, + 104,101,110, 10,115, 99,101,110,101, 58, 83,101,116, 76,105, + 103,104,116, 65,109, 98,105,101,110,116, 67,111,108,111,117, + 114, 40,114,101,100, 44, 32,103,114,101,101,110, 44, 32, 98, + 108,117,101, 41, 10,101,108,115,101, 10,101,114,114,111,114, + 40, 39, 87,114,111,110,103, 32,110,117,109, 98,101,114, 32, + 111,114, 32,116,121,112,101, 32,111,102, 32,112, 97,114, 97, + 109,101,116,101,114,115, 32,102,111,114, 32, 83,101,116, 76, + 105,103,104,116, 65,109, 98,105,101,110,116, 67,111,108,111, + 117,114, 32, 40,115,101,101, 32,102,114,111,109, 32,102,105, + 114,115,116, 32,112, 97,114, 97,109,101,116,101,114, 41, 39, + 44, 32, 50, 41, 10,101,110,100, 10,101,110,100, 10,102,117, + 110, 99,116,105,111,110, 32, 83,101,116, 76,105,103,104,116, + 73,110,116,101,110,115,105,116,121, 40,105,110,116,101,110, + 115,105,116,121, 41, 10,105,102, 32,116,121,112,101, 40,105, + 110,116,101,110,115,105,116,121, 41, 32, 61, 61, 32, 39,110, + 117,109, 98,101,114, 39, 32,116,104,101,110, 10,115, 99,101, + 110,101, 58, 83,101,116, 76,105,103,104,116, 73,110,116,101, + 110,115,105,116,121, 40,105,110,116,101,110,115,105,116,121, + 41, 10,101,108,115,101, 10,101,114,114,111,114, 40, 39, 65, + 114,103,117,109,101,110,116, 32,102,111,114, 32, 83,101,116, + 76,105,103,104,116, 73,110,116,101,110,115,105,116,121, 32, + 109,117,115,116, 32,104, 97,118,101, 32,110,117,109, 98,101, + 114, 32,116,121,112,101, 32, 40,105,110,116,101,110,115,105, + 116,121, 41, 39, 44, 32, 50, 41, 10,101,110,100, 10,101,110, + 100, 10,102,117,110, 99,116,105,111,110, 32, 83,101,116, 76, + 105,103,104,116, 65,116,116,101,110,117, 97,116,105,111,110, + 40, 97,116,116,101,110,117, 97,116,105,111,110, 41, 10,105, + 102, 32,116,121,112,101, 40, 97,116,116,101,110,117, 97,116, + 105,111,110, 41, 32, 61, 61, 32, 39,110,117,109, 98,101,114, + 39, 32,116,104,101,110, 10,115, 99,101,110,101, 58, 83,101, + 116, 76,105,103,104,116, 65,116,116,101,110,117, 97,116,105, + 111,110, 40, 97,116,116,101,110,117, 97,116,105,111,110, 41, + 10,101,108,115,101, 10,101,114,114,111,114, 40, 39, 65,114, + 103,117,109,101,110,116, 32,102,111,114, 32, 83,101,116, 76, + 105,103,104,116, 65,116,116,101,110,117, 97,116,105,111,110, + 32,109,117,115,116, 32,104, 97,118,101, 32,110,117,109, 98, + 101,114, 32,116,121,112,101, 32, 40, 97,116,116,101,110,117, + 97,116,105,111,110, 41, 39, 44, 32, 50, 41, 10,101,110,100, + 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 71, + 101,116, 76,105,103,104,116, 65,109, 98,105,101,110,116, 67, + 111,108,111,117,114, 40, 41, 10,114,101,116,117,114,110, 32, + 115, 99,101,110,101, 58, 71,101,116, 76,105,103,104,116, 65, + 109, 98,105,101,110,116, 67,111,108,111,117,114, 40, 41, 10, + 101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 71,101, + 116, 76,105,103,104,116, 73,110,116,101,110,115,105,116,121, + 40, 41, 10,114,101,116,117,114,110, 32,115, 99,101,110,101, + 58, 71,101,116, 76,105,103,104,116, 73,110,116,101,110,115, + 105,116,121, 40, 41, 10,101,110,100, 10,102,117,110, 99,116, + 105,111,110, 32, 71,101,116, 76,105,103,104,116, 65,116,116, + 101,110,117, 97,116,105,111,110, 40, 41, 10,114,101,116,117, + 114,110, 32,115, 99,101,110,101, 58, 71,101,116, 76,105,103, + 104,116, 65,116,116,101,110,117, 97,116,105,111,110, 40, 41, + 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67, + 114,101, 97,116,101, 80,111,105,110,116, 76,105,103,104,116, + 40,110, 97,109,101, 41, 10,105,102, 32,116,121,112,101, 40, + 110, 97,109,101, 41, 32,126, 61, 32, 39,115,116,114,105,110, + 103, 39, 32,116,104,101,110, 10,101,114,114,111,114, 40, 39, + 65,114,103,117,109,101,110,116, 32,102,111,114, 32, 67,114, + 101, 97,116,101, 80,111,105,110,116, 76,105,103,104,116, 32, + 109,117,115,116, 32,104, 97,118,101, 32,115,116,114,105,110, + 103, 32,116,121,112,101, 32, 40,110, 97,109,101, 32,111,102, + 32,112,111,105,110,116, 32,108,105,103,104,116, 41, 39, 44, + 32, 50, 41, 10,101,110,100, 10,108,111, 99, 97,108, 32,114, + 101,115, 32, 61, 32, 80,111,105,110,116, 76,105,103,104,116, + 58, 67,114,101, 97,116,101, 80,111,105,110,116, 76,105,103, + 104,116, 40,110, 97,109,101, 41, 10,105,102, 32,114,101,115, + 32,126, 61, 32,110,105,108, 32,116,104,101,110, 10,114,101, + 116,117,114,110, 32,114,101,115, 10,101,108,115,101, 10,101, + 114,114,111,114, 40, 39, 79,117,116, 32,111,102, 32,109,101, + 109,111,114,121, 32,119,104,105,108,101, 32, 99,114,101, 97, + 116,105,110,103, 32, 80,111,105,110,116, 76,105,103,104,116, + 32,111, 98,106,101, 99,116, 39, 44, 32, 50, 41, 10,101,110, + 100, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, + 67,114,101, 97,116,101, 83,112,111,116, 76,105,103,104,116, + 40,110, 97,109,101, 41, 10,105,102, 32,116,121,112,101, 40, + 110, 97,109,101, 41, 32,126, 61, 32, 39,115,116,114,105,110, + 103, 39, 32,116,104,101,110, 10,101,114,114,111,114, 40, 39, + 65,114,103,117,109,101,110,116, 32,102,111,114, 32, 67,114, + 101, 97,116,101, 83,112,111,116, 76,105,103,104,116, 32,109, + 117,115,116, 32,104, 97,118,101, 32,115,116,114,105,110,103, + 32,116,121,112,101, 32, 40,110, 97,109,101, 32,111,102, 32, + 115,112,111,116, 32,108,105,103,104,116, 41, 39, 44, 32, 50, + 41, 10,101,110,100, 10,108,111, 99, 97,108, 32,114,101,115, + 32, 61, 32, 83,112,111,116, 76,105,103,104,116, 58, 67,114, + 101, 97,116,101, 83,112,111,116, 76,105,103,104,116, 40,110, + 97,109,101, 41, 10,105,102, 32,114,101,115, 32,126, 61, 32, + 110,105,108, 32,116,104,101,110, 10,114,101,116,117,114,110, + 32,114,101,115, 10,101,108,115,101, 10,101,114,114,111,114, + 40, 39, 79,117,116, 32,111,102, 32,109,101,109,111,114,121, + 32,119,104,105,108,101, 32, 99,114,101, 97,116,105,110,103, + 32, 83,112,111,116, 76,105,103,104,116, 32,111, 98,106,101, + 99,116, 39, 44, 32, 50, 41, 10,101,110,100, 10,101,110,100, + 10,102,117,110, 99,116,105,111,110, 32, 67,114,101, 97,116, + 101, 68,105,114,101, 99,116,105,111,110, 97,108, 76,105,103, + 104,116, 40,110, 97,109,101, 41, 10,105,102, 32,116,121,112, + 101, 40,110, 97,109,101, 41, 32,126, 61, 32, 39,115,116,114, + 105,110,103, 39, 32,116,104,101,110, 10,101,114,114,111,114, + 40, 39, 65,114,103,117,109,101,110,116, 32,102,111,114, 32, + 67,114,101, 97,116,101, 68,105,114,101, 99,116,105,111,110, + 97,108, 76,105,103,104,116, 32,109,117,115,116, 32,104, 97, + 118,101, 32,115,116,114,105,110,103, 32,116,121,112,101, 32, + 40,110, 97,109,101, 32,111,102, 32,100,105,114,101, 99,116, + 105,111,110, 97,108, 32,108,105,103,104,116, 41, 39, 44, 32, + 50, 41, 10,101,110,100, 10,108,111, 99, 97,108, 32,114,101, + 115, 32, 61, 32, 68,105,114,101, 99,116,105,111,110, 97,108, + 76,105,103,104,116, 58, 67,114,101, 97,116,101, 68,105,114, + 101, 99,116,105,111,110, 97,108, 76,105,103,104,116, 40, 41, + 10,105,102, 32,114,101,115, 32,126, 61, 32,110,105,108, 32, + 116,104,101,110, 10,114,101,116,117,114,110, 32,114,101,115, + 10,101,108,115,101, 10,101,114,114,111,114, 40, 39, 79,117, + 116, 32,111,102, 32,109,101,109,111,114,121, 32,119,104,105, + 108,101, 32, 99,114,101, 97,116,105,110,103, 32, 68,105,114, + 101, 99,116,105,111,110, 97,108, 76,105,103,104,116, 32,111, + 98,106,101, 99,116, 39, 44, 32, 50, 41, 10,101,110,100, 10, + 101,110,100, 45, 45, 45, 45, 45, 45, 45,32 + }; + tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ./light.lua"); + lua_settop(tolua_S, top); + } /* end of embedded lua code */ + + tolua_endmodule(tolua_S); + return 1; +} + + +#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 + TOLUA_API int luaopen_ (lua_State* tolua_S) { + return tolua__open(tolua_S); +}; +#endif + diff --git a/src/ui/effects/runtime/lua-cpp-binding/tolua.h b/src/ui/effects/runtime/lua-cpp-binding/tolua.h new file mode 100644 index 0000000..72c34ac --- /dev/null +++ b/src/ui/effects/runtime/lua-cpp-binding/tolua.h @@ -0,0 +1,20 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/* Exported function */ +TOLUA_API int tolua__open (lua_State* tolua_S); + diff --git a/src/ui/inc/FUiAnim_DisplayContextImpl.h b/src/ui/inc/FUiAnim_DisplayContextImpl.h new file mode 100644 index 0000000..6ca0318 --- /dev/null +++ b/src/ui/inc/FUiAnim_DisplayContextImpl.h @@ -0,0 +1,61 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_DisplayContextImpl.h + * @brief This is the header file for the %_DisplayContextImpl class. + * + * This header file contains declarations of the %_DisplayContextImpl class. + */ + +#ifndef FUI_ANIM_DISPLAY_CONTEXT_IMPL_H +#define FUI_ANIM_DISPLAY_CONTEXT_IMPL_H + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _NativeLayer; +class VisualElement; +class DisplayContext; + +class _OSP_EXPORT_ _DisplayContextImpl +{ +public: + explicit _DisplayContextImpl(const _NativeLayer& layer); + virtual ~_DisplayContextImpl(void); + result SetPublicInstance(DisplayContext* pInstance); + DisplayContext* GetPublicInstance(void); + result SetNativeLayer(const Tizen::Ui::Animations::_NativeLayer& layer); + _NativeLayer* GetNativeLayer(void) const { return __pLayer;}; + static DisplayContext* CreatePublicInstance(const _NativeLayer& layer); + static result DestroyPublicInstance(const DisplayContext& displayContext); + static _DisplayContextImpl* GetInstance(DisplayContext& displayContext); + static const _DisplayContextImpl* GetInstance(const DisplayContext& displayContext); + + +private: + friend class DisplayContext; + DisplayContext* _pPublicInstance; + Tizen::Ui::Animations::_NativeLayer* __pLayer; +}; + + +}}} //namespace Tizen { namespace Ui { namespace Animations + +#endif //FUI_ANIM_DISPLAY_CONTEXT_IMPL_H diff --git a/src/ui/inc/FUiAnim_DisplayManager.h b/src/ui/inc/FUiAnim_DisplayManager.h new file mode 100644 index 0000000..705b118 --- /dev/null +++ b/src/ui/inc/FUiAnim_DisplayManager.h @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_DisplayManager.h + * @brief This is the header file for the _DisplayManager class. + * + * This header file contains the declarations of the _DisplayManager class. + */ + +#ifndef _FUI_ANIM_INTERNAL_DISPLAY_MANAGER_H_ +#define _FUI_ANIM_INTERNAL_DISPLAY_MANAGER_H_ + +#include + +// Backend feature +#define VE_EFL +//#define VE_OPENGL +#define VE_VSYNC_UPDATE + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _RootVisualElement; + +class _OSP_EXPORT_ _DisplayManager +{ +public: + static _DisplayManager* GetInstance(void) + { + return _DisplayManager::__pInstance; + } + + static result CreateInstance(void); + static result ReleaseInstance(void); + static bool __wakeUpEventAdded; + +public: + _RootVisualElement* CreateRoot(void); + + result DestroyRoot(_RootVisualElement& root); + + result RegisterRoot(_RootVisualElement& root); + + result UnregisterRoot(_RootVisualElement& root); + + int GetRootCount(void) const; + + _RootVisualElement* GetRoot(int index) const; + + void AddWakeUpEvent(void); + void RemoveWakeUpEvent(void); + + bool Render(_RootVisualElement& root); + result PostRender(_RootVisualElement& root); + bool RenderAll(void); + result Flush(void); + +private: + _DisplayManager(void); + virtual ~_DisplayManager(void); + +private: + Tizen::Base::Collection::ArrayList __roots; + + static int __eventType; + static void* __pWakeUpEventHandler; + static _DisplayManager* __pInstance; +}; // _DisplayManager + +}}} //namespace Tizen { namespace Ui { namespace Animations + +#endif //_FUI_ANIM_INTERNAL_DISPLAY_MANAGER_H_ diff --git a/src/ui/inc/FUiAnim_EflLayer.h b/src/ui/inc/FUiAnim_EflLayer.h new file mode 100755 index 0000000..08a4615 --- /dev/null +++ b/src/ui/inc/FUiAnim_EflLayer.h @@ -0,0 +1,123 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_EflLayer.h + * @brief This is the header file for the _EflLayer class. + * + * This header file contains the declarations of the _EflLayer class. + */ + +#ifndef _FUI_ANIM_INTERNAL_EFL_LAYER_H_ +#define _FUI_ANIM_INTERNAL_EFL_LAYER_H_ + +#define ECORE_EVAS_ASYNC_VISIBILITY_BUG_HACK + + +#include +#include +#include + +#include +#include "FUiAnim_NativeLayer.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _OSP_EXPORT_ _EflLayer + : public _NativeLayer +{ +public: + _EflLayer(void); + virtual ~_EflLayer(void); + + virtual result OnConstructed(void); + virtual result SetBounds(const Tizen::Graphics::FloatRectangle& bounds); + virtual Tizen::Graphics::FloatRectangle GetBounds(void) const; + virtual result SetShowState(bool show); + virtual bool GetShowState(void) const; + virtual void Flush(void); + + + void SetOpacity(float opacity); + float GetOpacity(void); + + _RootVisualElement* GetRootVisualElement(void) const + { + return _pRootVisualElement; + } + + Evas* GetEvas(void) const + { + return _pEvas; + } + + Ecore_Evas* GetEcoreEvas(void) const + { + return _pEcoreEvas; + } + + Evas_Object* GetElmWin(void) const + { + return _pWindow; + } + + void SetEvasRenderNeeded(void) + { + _needEvasRender = 1; + } + + void SetVisibilityChangeCompleted(void) + { + _isVisibilityChangeInProgress = false; + } + + bool IsAsyncVisibilityChangeNeeded(void) const + { + return _needAsyncVisibilityChangeRequest; + } + + void SetAsyncVisibilityChangeNeeded(bool asyncVisibilityChange) + { + _needAsyncVisibilityChangeRequest = asyncVisibilityChange; + } + +protected: + result Initialize(Evas_Object* pWindow); + virtual result Configure(_RootVisualElement& rootElement); + +protected: + _RootVisualElement* _pRootVisualElement; + Evas* _pEvas; + Ecore_Evas* _pEcoreEvas; + Evas_Object* _pWindow; + Ecore_Event_Handler* _pOnWindowDamagedHandler; + Ecore_Event_Handler* _pOnWindowConfiguredHandler; + Ecore_Event_Handler* _pOnWindowHideHandler; + Ecore_Event_Handler* _pOnWindowShowHandler; + int _needEvasRender; + bool _needShowStateChangeRequest; + bool _isShow; + bool _isVisibilityChangeInProgress; + bool _needAsyncVisibilityChangeRequest; + + static int _countOfLayer; +}; + +}}} //namespace Tizen { namespace Ui { namespace Animations + +#endif //_FUI_ANIM_INTERNAL_EFL_LAYER_H_ diff --git a/src/ui/inc/FUiAnim_EflNode.h b/src/ui/inc/FUiAnim_EflNode.h new file mode 100644 index 0000000..5ce0d05 --- /dev/null +++ b/src/ui/inc/FUiAnim_EflNode.h @@ -0,0 +1,118 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_EflNode.h + * @brief Header file of _EflNode class + * + * This file contains declarations _EflNode class. + */ + +#ifndef FUI_ANIM_INTERNAL_EFLNODE_H_ +#define FUI_ANIM_INTERNAL_EFLNODE_H_ + +#include +#include +#include +#include + +#include "FUi_Colorf.h" +#include "FUiAnim_INativeNode.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class VisualElement; +class _VisualElementImpl; +class VisualElementSurface; +class _NativeLayer; + +class _OSP_EXPORT_ _EflNode + : public _INativeNode +{ +public: + _EflNode(void); + virtual ~_EflNode(void); + + virtual result Construct(void); + virtual result RebuildIfNeeded(const _INativeNode& parent); + +public: + virtual Handle GetGroupContainer(void) const; + virtual result InsertChild(_INativeNode& child, const _INativeNode* pReference, bool above); + virtual result RemoveChild(_INativeNode& child); + virtual result SetFlushNeeded(void); + virtual result Flush(void); + virtual result Reconfigure(VisualElementSurface* pSurface, _VisualElementImpl& element, bool surfaceOnly); + virtual VisualElementSurface* GetSurface(void) const; + + Evas* GetEvas(void) const; + + _Colorf GetBackgroundColor(void) const; + result SetBackgroundColor(const _Colorf& backgroundColor); + + void AddNativeSmartObject(VisualElement& element, Evas_Object* pSmartObject); + void SetNativeObject(VisualElement& element, Evas_Object* pNativeObject); + void RemoveNativeObject(void); + Evas_Object* GetNativeObject(void) const; + +private: + void AdjustEvasObjectOrder(void); + bool AdjustImageHolder(bool useHolder); + + result ReConstruct(const Evas* pEvas); + result ReConstruct(const _NativeLayer& layer); + + result Destruct(void); + +private: + _EflNode(const _EflNode& rhs); // no impl. + _EflNode& operator =(const _EflNode& rhs); // no impl. + +private: + VisualElementSurface* __pSurface; + VisualElementSurface* __pSharedSurface; + Evas* __pEvas; + Evas_Object* __pSmartObject; + Evas_Object* __pClipObject; + Evas_Object* __pRectangleObject; + Evas_Object* __pImageHolder; + Evas_Object* __pNativeSmartObject; + Evas_Map* __pMap; + bool __mapUsed; + VisualElement::RenderOperation __renderOperation; + bool __needEvasObjectSync; + Tizen::Graphics::FloatRectangle __realBounds; + + _Colorf __backgroundColor; + + _NativeLayer* __pLayer; + + static Evas_Smart* __pStaticSmartClass; + static Evas_Smart* __pStaticSmartClassForImageHolder; + + friend class _INativeNode; + friend class _VeDebug; + friend class _VisualElementImpl; + friend class _EflLayer; +}; // _EflNode + + +}}} // Tizen::Ui::Animations + +#endif //FUI_ANIM_INTERNAL_EFLNODE_H_ diff --git a/src/ui/inc/FUiAnim_INativeNode.h b/src/ui/inc/FUiAnim_INativeNode.h new file mode 100644 index 0000000..097affe --- /dev/null +++ b/src/ui/inc/FUiAnim_INativeNode.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_INativeNode.h + * @brief Header file of _INativeNode class + * + * This file contains declarations _INativeNode class. + */ + +#ifndef _FUI_ANIM_INTERNAL_INATIVENODE_H_ +#define _FUI_ANIM_INTERNAL_INATIVENODE_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _VisualElementImpl; +class VisualElementSurface; + +class _OSP_EXPORT_ _INativeNode +{ +protected: + _INativeNode(void); +public: + virtual ~_INativeNode(void); + static _INativeNode* CreateInstanceN(void); + + virtual result Construct(void) = 0; + virtual result RebuildIfNeeded(const _INativeNode& parent) = 0; + +public: + virtual result InsertChild(_INativeNode& child, const _INativeNode* pReference, bool above) = 0; + virtual result RemoveChild(_INativeNode& child) = 0; + virtual result SetFlushNeeded(void) = 0; + virtual result Flush(void) = 0; + virtual result Reconfigure(VisualElementSurface* pSurface, _VisualElementImpl& element, bool surfaceOnly) = 0; + virtual VisualElementSurface* GetSurface(void) const = 0; + +private: + _INativeNode(const _INativeNode& rhs); // no impl. + _INativeNode& operator =(const _INativeNode& rhs); // no impl. +}; // _INativeNode + + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_INATIVENODE_H_ diff --git a/src/ui/inc/FUiAnim_NativeLayer.h b/src/ui/inc/FUiAnim_NativeLayer.h new file mode 100755 index 0000000..de9c337 --- /dev/null +++ b/src/ui/inc/FUiAnim_NativeLayer.h @@ -0,0 +1,184 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_NativeLayer.h + * @brief This is the header file for the _NativeLayer class. + * + * This header file contains the declarations of the _NativeLayer class. + */ + +#ifndef _FUI_ANIM_INTERNAL_INATIVE_LAYER_H_ +#define _FUI_ANIM_INTERNAL_INATIVE_LAYER_H_ + +#include +#include + + +namespace Tizen { namespace Ui { namespace Animations +{ +class _RootVisualElement; +class _INativeNode; + +class _OSP_EXPORT_ _NativeLayer +{ +public: + /** + * destructor + * + * @since 2.0 + */ + virtual ~_NativeLayer(void); + + /** + * Factory method of the native layer. + * + * @since 2.0 + * @return instance of the native layer. + * @remarks This method make a instance of native layer by configuration.And call the Construct() method. + */ + static _NativeLayer* CreateInstanceN(void); + +public: + /** + * Initializes the native layer. It is designed with 2 phase-construction. + * This method invoke the OnConstructed method for constructing. + * @since 2.0 + * @return instance of the native layer. + * + * @see OnConstructed() + */ + result Construct(void); + + _RootVisualElement* GetRootVisualElement(void) const; + + + void SetFlushNeeded(void) + { + __needFlush = true; + } + + void ResetFlushNeeded(void) + { + __needFlush = false; + } + + bool IsFlushNeeded(void) const + { + return __needFlush; + } + + /** + * Sets the position and the size of this instance. + * + * @since 2.0 + * + * @return An error code + */ + virtual result SetBounds(const Tizen::Graphics::FloatRectangle& bounds) = 0; + + /** + * Gets the position and the size of this instance. + * + * @since 2.0 + * + * @return An instance of the FloatRectangle that represents the position of top-left corner,@n + * the width, and the height of this instance. It has relative coordinate space to the parent. + */ + virtual Tizen::Graphics::FloatRectangle GetBounds(void) const = 0; + + /** + * Sets the show state of this instance. + * + * @since 2.0 + * + * @return An error code + * @param[in] show Set to @c true if this instance needs to be shown,@n + * else @c false + * @see GetShowState() + */ + virtual result SetShowState(bool show) = 0; + + + /** + * Gets the show state of this instance. + * + * @since 2.0 + * @return The show state of the %VisualElement instance. + * If an exception occurs , return @c false. + * @see SetShowState() + */ + virtual bool GetShowState(void) const = 0; + + + /** + * Flushes native layer on screen. + * + * @since 2.0 + * + */ + virtual void Flush(void) = 0; + +protected: + + virtual result OnConstructed(void) = 0; + /** + * Binds a _RootVisualElement to the native layer. This method should configure the _RootVisualElement. + * + * @since 2.0 + * @return error code. + */ + virtual result Configure(_RootVisualElement& rootElement) = 0; + +protected: + /** + * constructor + * + * @since 2.0 + */ + _NativeLayer(void); + +private: + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.0 + * + */ + _NativeLayer(const _NativeLayer& rhs); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.0 + * + */ + _NativeLayer& operator =(const _NativeLayer& rhs); + +protected: + _RootVisualElement* _pRootVisualElement; + +private: + bool __needFlush; + + friend class _RootVisualElement; + +}; + +}}} //namespace Tizen { namespace Ui { namespace Animations + +#endif //_FUI_ANIM_INTERNAL_INATIVE_LAYER_H_ diff --git a/src/ui/inc/FUiAnim_RootVisualElement.h b/src/ui/inc/FUiAnim_RootVisualElement.h new file mode 100644 index 0000000..7406776 --- /dev/null +++ b/src/ui/inc/FUiAnim_RootVisualElement.h @@ -0,0 +1,81 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiAnim_RootVisualElement.h + * @brief This is the header file for the _RootVisualElement class. + * + * This header file contains the declarations of the _RotateAnimationImpl class. + */ + + +#ifndef _FUI_ANIM_INTERNAL_ROOT_VISUAL_EMENET_H_ +#define _FUI_ANIM_INTERNAL_ROOT_VISUAL_EMENET_H_ + +#include "FUiAnim_VisualElement.h" + +namespace Tizen { namespace Ui { namespace Animations +{ +class _NativeLayer; + +class _OSP_EXPORT_ _RootVisualElement + : public _VisualElement +{ +public: + + _RootVisualElement(void); + + + virtual ~_RootVisualElement(void); + +public: + + bool GetNeedsContentUpdate(void) const + { + return __needsUpdateFromRoot; + } + + + void SetNeedsContentUpdate(bool needsUpdate) + { + __needsUpdateFromRoot = needsUpdate; + } + + _NativeLayer* GetNativeLayer(void) const + { + return __pLayer; + } + + result SetNativeLayer(_NativeLayer* pLayer); + +protected: + _RootVisualElement(const _RootVisualElement& rhs); + + virtual VisualElement* CloneN(void) const; + + + +private: + bool __needsUpdateFromRoot; + bool __isModel; + _NativeLayer* __pLayer; + +}; // _RootVisualElement + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_ROOT_VISUAL_EMENET_H_ + diff --git a/src/ui/inc/FUiAnim_TransformMatrix3Df.h b/src/ui/inc/FUiAnim_TransformMatrix3Df.h new file mode 100644 index 0000000..4ed9f79 --- /dev/null +++ b/src/ui/inc/FUiAnim_TransformMatrix3Df.h @@ -0,0 +1,202 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_TransformMatrix3Df.h + * @brief Header file of _TransformMatrix3Df class + * + * This file contains declarations _TransformMatrix3Df class. + */ + +#ifndef _FUI_ANIM_INTERNAL_TRANSFORM_MATRIX3DF_H_ +#define _FUI_ANIM_INTERNAL_TRANSFORM_MATRIX3DF_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Animations { + +enum Matrix4Type +{ + MATRIX4_Identity, + MATRIX4_Translation, + MATRIX4_Scale, + MATRIX4_Generic +}; + +class _OSP_EXPORT_ _TransformMatrix3Df +{ +public: + _TransformMatrix3Df(void); + ~_TransformMatrix3Df(void); + +public: + void Clear(void); + bool SetTransformMatrix(const Tizen::Graphics::FloatMatrix4& transformMatrix); + Tizen::Graphics::FloatMatrix4 GetTransformMatrix(void) const; + Tizen::Graphics::FloatMatrix4 Interpolate(const _TransformMatrix3Df& transformMatrixFrom, float progress) const; + + void UpdateRotationFromEulerAngles(float x, float y, float z); + + void GetEulerAngles(float& x, float& y, float& z) const; + void GetQuaternion(float& x, float& y, float& z, float& w) const; + void GetRotationAnchor(float& x, float& y, float& z) const; + void SetRotationAnchor(float x, float y, float z); + void GetScaleFactors(float& x, float& y, float& z) const; + void SetScaleFactors(float x, float y, float z); + void GetScaleAnchor(float& x, float& y, float& z) const; + void SetScaleAnchor(float x, float y, float z); + void GetShearFactors(float& xy, float& xz, float& yz) const; + void SetShearFactors(float xy, float xz, float yz); + void GetTranslationFactors(float& x, float& y, float& z) const; + void SetTranslationFactors(float x, float y, float z); + void GetPerspectiveFactors(float& x, float& y, float& z, float& w) const; + void SetPerspectiveFactors(float x, float y, float z, float w); + + Matrix4Type GetMatrixType(void) const + { + return __transformType; + } + +private: + class Vector3Df + { + public: + Vector3Df(void) + : x(0.0f), y(0.0f), z(0.0f) + { + } + + float GetSquaredLength(void) const + { + return ((x * x) + (y * y) + (z * z)); + } + + float GetLength(void) const + { + return (sqrtf(GetSquaredLength())); + } + + void Scale(float newLength) + { + float length = GetLength(); + + if (length != 0.0f) + { + x *= newLength / length; + y *= newLength / length; + z *= newLength / length; + } + } + + float Dot(const Vector3Df& vector3D) const + { + return ((x * vector3D.x) + (y * vector3D.y) + (z * vector3D.z)); + } + + Vector3Df Cross(const Vector3Df& vector3D) const + { + Vector3Df cross; + cross.x = (y * vector3D.z) - (z * vector3D.y); + cross.y = (z * vector3D.x) - (x * vector3D.z); + cross.z = (x * vector3D.y) - (y * vector3D.x); + return cross; + } + + static void Combine(Vector3Df& result, const Vector3Df& a, const Vector3Df& b, float ascl, float bscl) + { + result.x = (ascl * a.x) + (bscl * b.x); + result.y = (ascl * a.y) + (bscl * b.y); + result.z = (ascl * a.z) + (bscl * b.z); + } + + + public: + float x, y, z; + }; + + class Vector4Df + { + public: + Vector4Df(void) + : x(0.0f), y(0.0f), z(0.0f), w(0.0f) + { + } + + Vector4Df Transform(const Tizen::Graphics::FloatMatrix4& m) const + { + Vector4Df outputVector; + + /* + outputVector.x = (pin.x * m.Get(0, 0)) + (pin.y * m.Get(1, 0)) + (pin.z * m.Get(2, 0)) + (pin.w * m.Get(3, 0)); + outputVector.y = (pin.x * m.Get(0, 1)) + (pin.y * m.Get(1, 1)) + (pin.z * m.Get(2, 1)) + (pin.w * m.Get(3, 1)); + outputVector.z = (pin.x * m.Get(0, 2)) + (pin.y * m.Get(1, 2)) + (pin.z * m.Get(2, 2)) + (pin.w * m.Get(3, 2)); + outputVector.w = (pin.x * m.Get(0, 3)) + (pin.y * m.Get(1, 3)) + (pin.z * m.Get(2, 3)) + (pin.w * m.Get(3, 3)); + */ + + outputVector.x = (x * m.matrix[0][0]) + (y * m.matrix[0][1]) + (z * m.matrix[0][2]) + (w * m.matrix[0][3]); + outputVector.y = (x * m.matrix[1][0]) + (y * m.matrix[1][1]) + (z * m.matrix[1][2]) + (w * m.matrix[1][3]); + outputVector.z = (x * m.matrix[2][0]) + (y * m.matrix[2][1]) + (z * m.matrix[2][2]) + (w * m.matrix[2][3]); + outputVector.w = (x * m.matrix[3][0]) + (y * m.matrix[3][1]) + (z * m.matrix[3][2]) + (w * m.matrix[3][3]); + + return outputVector; + } + + public: + float x, y, z, w; + }; + + void DoSlerp(float* result, const float* src1, const float* src2, float t) const; +#if 0 + void CalcEulerAngles(void); +#endif +#if 0 + void V4MulPointByMatrix(const _Vector4Df& pin, const Tizen::Graphics::FloatMatrix4& m, _Vector4Df& pout) const; + float V3SquaredLength(const _Vector3Df& v) const; + float V3Length(const _Vector3Df& v) const; + void V3Scale(_Vector3Df& v, float newlen) const; + float V3Dot(const _Vector3Df& a, const _Vector3Df& b) const; + void V3Combine(const _Vector3Df& a, const _Vector3Df& b, _Vector3Df& result, float ascl, float bscl) const; + void V3Cross(const _Vector3Df& a, const _Vector3Df& b, _Vector3Df& c) const; +#endif + + void UpdateMatrixType(bool fullCheck); + +private: + Matrix4Type __transformType; + bool __usePerspective; + bool __useScale; + bool __useShear; + bool __useRotation; + bool __useTranslation; + + float __scaleX, __scaleY, __scaleZ; + float __shearXY, __shearXZ, __shearYZ; + float __quatX, __quatY, __quatZ, __quatW; + float __translationX, __translationY, __translationZ; + float __perspectiveX, __perspectiveY, __perspectiveZ, __perspectiveW; + + float __rotAnchorX, __rotAnchorY, __rotAnchorZ; + float __scaleAnchorX, __scaleAnchorY, __scaleAnchorZ; + + float __rotX, __rotY, __rotZ; // in degree-unit +}; // _TransformMatrix3Df + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_TRANSFORM_MATRIX3DF_H_ + diff --git a/src/ui/inc/FUiAnim_VisualElement.h b/src/ui/inc/FUiAnim_VisualElement.h new file mode 100644 index 0000000..71d4e39 --- /dev/null +++ b/src/ui/inc/FUiAnim_VisualElement.h @@ -0,0 +1,152 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiAnim_VisualElement.h + * @brief This is the header file for the _VisualElement class. + * + * This header file contains declarations of the @e _VisualElement class. + */ +#ifndef _FUIANIM_INTERNAL_VISUAL_ELEMENT_H_ +#define _FUIANIM_INTERNAL_VISUAL_ELEMENT_H_ + +#include +#include "FUi_Colorf.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _OSP_EXPORT_ _VisualElement + : public VisualElement +{ + +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _VisualElement(void); + + +protected: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_VisualElement(void); + +public: + IVisualElementAnimationProvider* GetAnimationProvider(void) const; + + IVisualElementContentProvider* GetContentProvider(void) const; + + IVisualElementEventListener* GetVisualElementEventListener(void) const; + +public: + + /** + * Clones the instance of VisualElement. + * + * @since 2.0 + * @return The pointer to the cloned VisualElement instance. + */ + virtual VisualElement* CloneN(void) const; + + /** + * Gets the current background color of the VisualElement. + * + * @since 2.0 + * @return The background color of the VisualElement. + * @see SetBackgroundColor() + */ + _Colorf GetBackgroundColor(void) const; + + /** + * Changes the background color of the VisualElement. + * + * @since 2.0 + * @return An error code + * @param[in] color The new background color. + * @exception E_SUCCESS The method was successful. + * @see GetBackgroundColor() + * + */ + result SetBackgroundColor(const _Colorf& color); + + + /** + * Sets the custom data of the VisualElement. + * + * @since 2.0 + * @param[in] pUserData data to save. + */ + void SetControlUserData(void* pUserData); + + /** + * Gets the custom data of the VisualElement. + * + * @since 2.0 + */ + void* GetControlUserData(void) const; + + /** + * Gets the top-most child ControlVisualElement indicated by @c point. + * + * @since 2.0 + * @return the child ControlVisualElement indicated by point. + * @param[in] point The position to find the child ControlVisualElement. + */ +// _VisualElement* GetControlChildAtPoint(Tizen::Graphics::FloatPoint& point); + + /** + * Overrides this method to check the element can draw. + * + * @since 2.0 + */ + virtual bool OnPrepareDraw(void); + + result SetClipToParent(bool clipToParent); + result SetBackBufferEnabled(bool enable); + result SetSurfaceOpaque(bool isSurfaceOpaque); + + Tizen::Graphics::FloatRectangle GetBoundingBox(void); + result SetZOrder(const VisualElement* pReference, bool above); + + result SetImageSource(const Tizen::Base::String& fileName); + result SetContentOpacity(float contentOpacity); + + result ScrollByPoint(const Tizen::Graphics::FloatPoint& pointOffset, bool scrollSelf); + + result Capture(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& boundsToDraw, bool withChilren); + class _INativeNode* GetNativeNode(void) const; + + _VisualElement* GetPresentation(void); + _VisualElement* GetModel(void); + +protected: + _VisualElement(const _VisualElement& rhs); + + +private: + void* __pUserData; +}; // _VisualElement + +}}} // Tizen::Ui::Animations + +#endif //_FUIANIM_INTERNAL_VISUAL_ELEMENT_H_ + diff --git a/src/ui/inc/FUiAnim_VisualElementCanvas.h b/src/ui/inc/FUiAnim_VisualElementCanvas.h new file mode 100644 index 0000000..4bc9344 --- /dev/null +++ b/src/ui/inc/FUiAnim_VisualElementCanvas.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiAnim_VisualElementCanvas.h + * @brief This is the header file for the _VisualElementCanvas class. + * + * This header file contains the declarations of the _VisualElementCanvas class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_CANVAS_H_ +#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_CANVAS_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +/* TBD: from WinCanvas...... new class really needed??? */ +//class _VisualElementCanvas : +// public Tizen::Ui::__WinCanvas +//{ +//}; +class VisualElementSurface; + +class _VisualElementCanvas + : public Tizen::Graphics::Canvas +{ +public: + _VisualElementCanvas(void); + virtual ~_VisualElementCanvas(void); + + result Construct(const VisualElementSurface& surface, const Tizen::Graphics::Rectangle& rectangle); + +private: + _VisualElementCanvas(const _VisualElementCanvas& rhs); + _VisualElementCanvas& operator =(const _VisualElementCanvas& rhs); + +}; // _VisualElementCanvas + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_CANVAS_H_ + diff --git a/src/ui/inc/FUiAnim_VisualElementCoordinateSystem.h b/src/ui/inc/FUiAnim_VisualElementCoordinateSystem.h new file mode 100644 index 0000000..4c2b0fc --- /dev/null +++ b/src/ui/inc/FUiAnim_VisualElementCoordinateSystem.h @@ -0,0 +1,167 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementCoordinateSystem.h + * @brief This is the header file for the _VisualElementCoordinateSystem class. + * + * This header file contains the declarations of the _VisualElementCoordinateSystem class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_COORDINATE_SYSTEM_H_ +#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_COORDINATE_SYSTEM_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _OSP_EXPORT_ _VisualElementCoordinateSystem +{ +public: + static void Initialize(void); + + static void MakeIntegralPoint(float& x, float& y) + { + x = floorf(x + floatIntegralEpsilon); + y = floorf(y + floatIntegralEpsilon); + } + + static void MakeIntegralPoint(float x, float y, int& intX, int& intY) + { + intX = int(floorf(x + floatIntegralEpsilon)); + intY = int(floorf(y + floatIntegralEpsilon)); + } + + static void MakeIntegralDimension(float& width, float& height) + { + width = floorf(width + floatIntegralEpsilon); + height = floorf(height + floatIntegralEpsilon); + } + + static void MakeIntegralDimension(float width, float height, int& intWidth, int& intHeight) + { + intWidth = int(floorf(width + floatIntegralEpsilon)); + intHeight = int(floorf(height + floatIntegralEpsilon)); + } + + static void ConvertDimensionToPhysical(float& width, float& height) + { + if (unlikely(needScale)) + { + width *= scaleFactorX; + height *= scaleFactorY; + } + } + + static void ConvertRectangleToPhysical(float& x, float& y, float& width, float& height) + { + if (unlikely(needScale)) + { + ConvertPointToPhysical(x, y); + ConvertDimensionToPhysical(width, height);; + } + } + + static void ConvertDimensionToPhysicalIntegral(float& width, float& height) + { + if (unlikely(needScale)) + { + width *= scaleFactorX; + height *= scaleFactorY; + + // WARNING: + // Because auto-scaling coordinate system of graphics ceils only for down-scaling, we do the same ! + // CHECKME: + // Separate Horz/Vert handling ? + MakeIntegralDimension(width, height); + } + } + + static void ConvertDimensionToPhysicalIntegral(float width, float height, int& intWidth, int& intHeight) + { + ConvertDimensionToPhysicalIntegral(width, height); + intWidth = static_cast< int >(width); + intHeight = static_cast< int >(height); + } + + static void ConvertDimensionToLogicalIntegral(float& width, float& height) + { + if (unlikely(needScale)) + { + width /= scaleFactorX; + height /= scaleFactorY; + + // WARNING: + // Because auto-scaling coordinate system of graphics ceils only for down-scaling, we do the same ! + // CHECKME: + // Separate Horz/Vert handling ? + MakeIntegralDimension(width, height); + } + } + + static void ConvertDimensionToLogicalIntegral(float width, float height, int& intWidth, int& intHeight) + { + ConvertDimensionToLogicalIntegral(width, height); + intWidth = static_cast< int >(width); + intHeight = static_cast< int >(height); + } + + static void ConvertDimensionToLogical(float& width, float& height) + { + if (unlikely(needScale)) + { + width /= scaleFactorX; + height /= scaleFactorY; + } + } + + static void ConvertPointToPhysical(float& x, float& y) + { + if (unlikely(needScale)) + { + x *= scaleFactorX; + y *= scaleFactorY; + } + } + + static void ConvertPointToLogical(float& x, float& y) + { + if (unlikely(needScale)) + { + x /= scaleFactorX; + y /= scaleFactorY; + } + } + +public: + // WARNING: + // Some float functions like sin and cos emit too-much float-error. + // So, the rounding const must be a bigger value than expected. + static const float floatIntegralEpsilon = 0.01f; + + static bool needScale; + static float scaleFactorX; + static float scaleFactorY; + static int logScreenWidth; + static int logScreenHeight; +}; // _VisualElementCoordinateSystem + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_COORDINATE_SYSTEM_H_ + diff --git a/src/ui/inc/FUiAnim_VisualElementImpl.h b/src/ui/inc/FUiAnim_VisualElementImpl.h new file mode 100644 index 0000000..4d0444d --- /dev/null +++ b/src/ui/inc/FUiAnim_VisualElementImpl.h @@ -0,0 +1,1391 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementImpl.h + * @brief This is the header file for the _VisualElementImpl class. + * + * This header file contains the declarations of the _VisualElementImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_IMPL_H_ +#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_IMPL_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "FUi_PropertyBase.h" + +#include "FUiAnim_RootVisualElement.h" +#include "FUiAnim_VisualElementSharedData.h" +#include "FUiAnim_TransformMatrix3Df.h" +#include "FUiAnim_VisualElementCoordinateSystem.h" + +#define SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION + +namespace Tizen { namespace Ui +{ +class _ControlImpl; +class _ControlManagerImpl; +class _EflUiEventManager; +}} + +namespace Tizen { namespace Ui { namespace Controls +{ +class _FrameImpl; +}}} + +namespace Tizen { namespace Web { namespace Controls +{ +class _WebImpl; +}}} + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _IVisualElementObserver; +class IVisualElementAnimationProvider; +class IVisualElementContentProvider; +class IVisualElementEventListener; +class _AnimationManager; + + +extern const wchar_t* VePropBounds; +extern const wchar_t* VePropContentBounds; +extern const wchar_t* VePropContentOpacity; +extern const wchar_t* VePropRenderOperation; +extern const wchar_t* VePropOpacity; +extern const wchar_t* VePropShowState; +extern const wchar_t* VePropAnchor; +extern const wchar_t* VePropAnchorZ; +extern const wchar_t* VePropTransform; +extern const wchar_t* VePropChildrenTransform; +extern const wchar_t* VePropZPosition; +extern const wchar_t* VePropZOrderGroup; +extern const wchar_t* VePropClipToParent; +extern const wchar_t* VePropClipChildren; +extern const wchar_t* VePropName; +extern const wchar_t* VePropSurfaceOpaque; +extern const wchar_t* VePropPropertyPropagationEnabled; +extern const wchar_t* VePropImplicitAnimationEnabled; + +#if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION) +extern const wchar_t* VePropActionDetach; +extern const wchar_t* VePropActionInsert; +#endif + +extern const wchar_t* VeSubPropBounds; +extern const wchar_t* VeSubPropBoundsPosition; +extern const wchar_t* VeSubPropBoundsSize; + +extern const wchar_t* VeSubPropTransform; +extern const wchar_t* VeSubPropTransformRotationX; +extern const wchar_t* VeSubPropTransformRotationY; +extern const wchar_t* VeSubPropTransformRotationZ; +extern const wchar_t* VeSubPropTransformScaleX; +extern const wchar_t* VeSubPropTransformScaleY; +extern const wchar_t* VeSubPropTransformScaleZ; +extern const wchar_t* VeSubPropTransformTranslationX; +extern const wchar_t* VeSubPropTransformTranslationY; +extern const wchar_t* VeSubPropTransformTranslationZ; +extern const wchar_t* VeSubPropTransformRotationAnchorX; +extern const wchar_t* VeSubPropTransformRotationAnchorY; +extern const wchar_t* VeSubPropTransformRotationAnchorZ; +extern const wchar_t* VeSubPropTransformScaleAnchorX; +extern const wchar_t* VeSubPropTransformScaleAnchorY; +extern const wchar_t* VeSubPropTransformScaleAnchorZ; + +extern const wchar_t* VeSubPropTransformRotationXY; +extern const wchar_t* VeSubPropTransformScaleXY; +extern const wchar_t* VeSubPropTransformTranslationXY; +extern const wchar_t* VeSubPropTransformRotationAnchorXY; +extern const wchar_t* VeSubPropTransformScaleAnchorXY; + +extern const wchar_t* VeSubPropChildrenTransform; +extern const wchar_t* VeSubPropChildrenTransformRotationX; +extern const wchar_t* VeSubPropChildrenTransformRotationY; +extern const wchar_t* VeSubPropChildrenTransformRotationZ; +extern const wchar_t* VeSubPropChildrenTransformScaleX; +extern const wchar_t* VeSubPropChildrenTransformScaleY; +extern const wchar_t* VeSubPropChildrenTransformScaleZ; +extern const wchar_t* VeSubPropChildrenTransformTranslationX; +extern const wchar_t* VeSubPropChildrenTransformTranslationY; +extern const wchar_t* VeSubPropChildrenTransformTranslationZ; +extern const wchar_t* VeSubPropChildrenTransformRotationAnchorX; +extern const wchar_t* VeSubPropChildrenTransformRotationAnchorY; +extern const wchar_t* VeSubPropChildrenTransformRotationAnchorZ; +extern const wchar_t* VeSubPropChildrenTransformScaleAnchorX; +extern const wchar_t* VeSubPropChildrenTransformScaleAnchorY; +extern const wchar_t* VeSubPropChildrenTransformScaleAnchorZ; + +extern const wchar_t* VeSubPropChildrenTransformRotationXY; +extern const wchar_t* VeSubPropChildrenTransformScaleXY; +extern const wchar_t* VeSubPropChildrenTransformTranslationXY; +extern const wchar_t* VeSubPropChildrenTransformRotationAnchorXY; +extern const wchar_t* VeSubPropChildrenTransformScaleAnchorXY; + +extern const wchar_t* VePrivPropShowOpacity; + + +extern Tizen::Base::String* pVePropBounds; +extern Tizen::Base::String* pVePropContentBounds; +extern Tizen::Base::String* pVePropContentOpacity; +extern Tizen::Base::String* pVePropRenderOperation; +extern Tizen::Base::String* pVePropOpacity; +extern Tizen::Base::String* pVePropShowState; +extern Tizen::Base::String* pVePropAnchor; +extern Tizen::Base::String* pVePropAnchorZ; +extern Tizen::Base::String* pVePropTransform; +extern Tizen::Base::String* pVePropChildrenTransform; +extern Tizen::Base::String* pVePropZPosition; +extern Tizen::Base::String* pVePropZOrderGroup; +extern Tizen::Base::String* pVePropClipToParent; +extern Tizen::Base::String* pVePropClipChildren; +extern Tizen::Base::String* pVePropName; +extern Tizen::Base::String* pVePropSurfaceOpaque; +extern Tizen::Base::String* pVePropPropertyPropagationEnabled; +extern Tizen::Base::String* pVePropImplicitAnimationEnabled; + +#if defined(SUPPORT_CUSTOMIZING_ATTACH_DETACH_ANIMATION) +extern Tizen::Base::String* pVePropActionDetach; +extern Tizen::Base::String* pVePropActionAttach; +#endif + +extern Tizen::Base::String* pVeSubPropBounds; +extern Tizen::Base::String* pVeSubPropBoundsPosition; +extern Tizen::Base::String* pVeSubPropBoundsSize; + +extern Tizen::Base::String* pVeSubPropTransform; +extern Tizen::Base::String* pVeSubPropTransformRotationX; +extern Tizen::Base::String* pVeSubPropTransformRotationY; +extern Tizen::Base::String* pVeSubPropTransformRotationZ; +extern Tizen::Base::String* pVeSubPropTransformScaleX; +extern Tizen::Base::String* pVeSubPropTransformScaleY; +extern Tizen::Base::String* pVeSubPropTransformScaleZ; +extern Tizen::Base::String* pVeSubPropTransformTranslationX; +extern Tizen::Base::String* pVeSubPropTransformTranslationY; +extern Tizen::Base::String* pVeSubPropTransformTranslationZ; +extern Tizen::Base::String* pVeSubPropTransformRotationAnchorX; +extern Tizen::Base::String* pVeSubPropTransformRotationAnchorY; +extern Tizen::Base::String* pVeSubPropTransformRotationAnchorZ; +extern Tizen::Base::String* pVeSubPropTransformScaleAnchorX; +extern Tizen::Base::String* pVeSubPropTransformScaleAnchorY; +extern Tizen::Base::String* pVeSubPropTransformScaleAnchorZ; + +extern Tizen::Base::String* pVeSubPropTransformRotationXY; +extern Tizen::Base::String* pVeSubPropTransformScaleXY; +extern Tizen::Base::String* pVeSubPropTransformTranslationXY; +extern Tizen::Base::String* pVeSubPropTransformRotationAnchorXY; +extern Tizen::Base::String* pVeSubPropTransformScaleAnchorXY; + +extern Tizen::Base::String* pVeSubPropChildrenTransform; +extern Tizen::Base::String* pVeSubPropChildrenTransformRotationX; +extern Tizen::Base::String* pVeSubPropChildrenTransformRotationY; +extern Tizen::Base::String* pVeSubPropChildrenTransformRotationZ; +extern Tizen::Base::String* pVeSubPropChildrenTransformScaleX; +extern Tizen::Base::String* pVeSubPropChildrenTransformScaleY; +extern Tizen::Base::String* pVeSubPropChildrenTransformScaleZ; +extern Tizen::Base::String* pVeSubPropChildrenTransformTranslationX; +extern Tizen::Base::String* pVeSubPropChildrenTransformTranslationY; +extern Tizen::Base::String* pVeSubPropChildrenTransformTranslationZ; +extern Tizen::Base::String* pVeSubPropChildrenTransformRotationAnchorX; +extern Tizen::Base::String* pVeSubPropChildrenTransformRotationAnchorY; +extern Tizen::Base::String* pVeSubPropChildrenTransformRotationAnchorZ; +extern Tizen::Base::String* pVeSubPropChildrenTransformScaleAnchorX; +extern Tizen::Base::String* pVeSubPropChildrenTransformScaleAnchorY; +extern Tizen::Base::String* pVeSubPropChildrenTransformScaleAnchorZ; + +extern Tizen::Base::String* pVeSubPropChildrenTransformRotationXY; +extern Tizen::Base::String* pVeSubPropChildrenTransformScaleXY; +extern Tizen::Base::String* pVeSubPropChildrenTransformTranslationXY; +extern Tizen::Base::String* pVeSubPropChildrenTransformRotationAnchorXY; +extern Tizen::Base::String* pVeSubPropChildrenTransformScaleAnchorXY; + +extern Tizen::Base::String* pVePrivPropShowOpacity; + + +/** +* @class _VisualElementImpl +* @brief This class provides methods to control VisualElement. +* @since 2.0 +*/ + + +class _OSP_EXPORT_ _VisualElementImpl + : public Tizen::Ui::_PropertyBase +{ + DECLARE_CLASS_BEGIN(_VisualElementImpl, Tizen::Ui::_PropertyBase); + DECLARE_PROPERTY(VePropBounds, GetBoundsProperty, SetBoundsProperty); + DECLARE_PROPERTY(VeSubPropBoundsPosition, GetBoundsPositionSubProperty, SetBoundsPositionSubProperty); + DECLARE_PROPERTY(VeSubPropBoundsSize, GetBoundsSizeSubProperty, SetBoundsSizeSubProperty); + DECLARE_PROPERTY(VePropRenderOperation, GetRenderOperationProperty, SetRenderOperationProperty); + DECLARE_PROPERTY(VePropContentBounds, GetContentBoundsProperty, SetContentBoundsProperty); + DECLARE_PROPERTY(VePropContentOpacity, GetContentOpacityProperty, SetContentOpacityProperty); + DECLARE_PROPERTY(VePropOpacity, GetOpacityProperty, SetOpacityProperty); + DECLARE_PROPERTY(VePropShowState, GetShowStateProperty, SetShowStateProperty); + DECLARE_PROPERTY(VePropAnchor, GetAnchorProperty, SetAnchorProperty); + DECLARE_PROPERTY(VePropAnchorZ, GetAnchorZProperty, SetAnchorZProperty); + DECLARE_PROPERTY(VePropTransform, GetTransformMatrixProperty, SetTransformMatrixProperty); + DECLARE_PROPERTY(VeSubPropTransformRotationX, GetTransformRotationXSubProperty, SetTransformRotationXSubProperty); + DECLARE_PROPERTY(VeSubPropTransformRotationY, GetTransformRotationYSubProperty, SetTransformRotationYSubProperty); + DECLARE_PROPERTY(VeSubPropTransformRotationZ, GetTransformRotationZSubProperty, SetTransformRotationZSubProperty); + DECLARE_PROPERTY(VeSubPropTransformRotationAnchorXY, GetTransformRotationAnchorXYSubProperty, SetTransformRotationAnchorXYSubProperty); + DECLARE_PROPERTY(VeSubPropTransformRotationXY, GetTransformRotationXYSubProperty, SetTransformRotationXYSubProperty); + DECLARE_PROPERTY(VeSubPropTransformScaleX, GetTransformScaleXSubProperty, SetTransformScaleXSubProperty); + DECLARE_PROPERTY(VeSubPropTransformScaleY, GetTransformScaleYSubProperty, SetTransformScaleYSubProperty); + DECLARE_PROPERTY(VeSubPropTransformScaleZ, GetTransformScaleZSubProperty, SetTransformScaleZSubProperty); + DECLARE_PROPERTY(VeSubPropTransformScaleAnchorXY, GetTransformScaleAnchorXYSubProperty, SetTransformScaleAnchorXYSubProperty); + DECLARE_PROPERTY(VeSubPropTransformScaleXY, GetTransformScaleXYSubProperty, SetTransformScaleXYSubProperty); + DECLARE_PROPERTY(VeSubPropTransformTranslationX, GetTransformTranslationXSubProperty, SetTransformTranslationXSubProperty); + DECLARE_PROPERTY(VeSubPropTransformTranslationY, GetTransformTranslationYSubProperty, SetTransformTranslationYSubProperty); + DECLARE_PROPERTY(VeSubPropTransformTranslationZ, GetTransformTranslationZSubProperty, SetTransformTranslationZSubProperty); + DECLARE_PROPERTY(VeSubPropTransformTranslationXY, GetTransformTranslationXYSubProperty, SetTransformTranslationXYSubProperty); + DECLARE_PROPERTY(VePropChildrenTransform, GetChildrenTransformMatrixProperty, SetChildrenTransformMatrixProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformRotationX, GetChildrenTransformRotationXSubProperty, SetChildrenTransformRotationXSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformRotationY, GetChildrenTransformRotationYSubProperty, SetChildrenTransformRotationYSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformRotationZ, GetChildrenTransformRotationZSubProperty, SetChildrenTransformRotationZSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformRotationAnchorXY, GetChildrenTransformRotationAnchorXYSubProperty, SetChildrenTransformRotationAnchorXYSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformRotationXY, GetChildrenTransformRotationXYSubProperty, SetChildrenTransformRotationXYSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformScaleX, GetChildrenTransformScaleXSubProperty, SetChildrenTransformScaleXSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformScaleY, GetChildrenTransformScaleYSubProperty, SetChildrenTransformScaleYSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformScaleZ, GetChildrenTransformScaleZSubProperty, SetChildrenTransformScaleZSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformScaleAnchorXY, GetChildrenTransformScaleAnchorXYSubProperty, SetChildrenTransformScaleAnchorXYSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformScaleXY, GetChildrenTransformScaleXYSubProperty, SetChildrenTransformScaleXYSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformTranslationX, GetChildrenTransformTranslationXSubProperty, SetChildrenTransformTranslationXSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformTranslationY, GetChildrenTransformTranslationYSubProperty, SetChildrenTransformTranslationYSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformTranslationZ, GetChildrenTransformTranslationZSubProperty, SetChildrenTransformTranslationZSubProperty); + DECLARE_PROPERTY(VeSubPropChildrenTransformTranslationXY, GetChildrenTransformTranslationXYSubProperty, SetChildrenTransformTranslationXYSubProperty); + DECLARE_PROPERTY(VePropZPosition, GetZPositionProperty, SetZPositionProperty); + DECLARE_PROPERTY(VePropZOrderGroup, GetZOrderGroupProperty, SetZOrderGroupProperty); + DECLARE_PROPERTY(VePropClipToParent, GetClipToParentProperty, SetClipToParentProperty); + DECLARE_PROPERTY(VePropClipChildren, GetClipChildrenProperty, SetClipChildrenProperty); + DECLARE_PROPERTY(VePropName, GetNameProperty, SetNameProperty); + DECLARE_PROPERTY(VePropSurfaceOpaque, GetSurfaceOpaqueProperty, SetSurfaceOpaqueProperty); + DECLARE_PROPERTY(VePropImplicitAnimationEnabled, GetImplicitAnimationProperty, SetImplicitAnimationProperty); + DECLARE_PROPERTY(VePropPropertyPropagationEnabled, GetPropertyPropagationProperty, SetPropertyPropagationProperty); + + // private and internal property + DECLARE_PROPERTY(VePrivPropShowOpacity, GetShowOpacityPrivateProperty, SetShowOpacityPrivateProperty); + DECLARE_CLASS_END(); + + +public: + IVisualElementAnimationProvider* GetAnimationProvider(void) const; + + result SetAnimationProvider(IVisualElementAnimationProvider* pProvider); + + IVisualElementContentProvider* GetContentProvider(void) const; + + result SetContentProvider(IVisualElementContentProvider* pProvider); + + IVisualElementEventListener* GetVisualElementEventListener(void) const; + + result SetVisualElementEventListener(IVisualElementEventListener* pListener); + + static _VisualElementImpl* GetInstance(VisualElement& element) + { + return element._pVisualElementImpl; + } + + static const _VisualElementImpl* GetInstance(const VisualElement& element) + { + return element._pVisualElementImpl; + } + + static result FlushI(void); + + static const int Z_ORDER_GROUP_ALWAYS_BELOW_BOTTOM = -1000; // lowest drawing gadget.(Background) + static const int Z_ORDER_GROUP_NORMAL = 0; // level of the default group. + static const int Z_ORDER_GROUP_ALWAYS_ON_TOP = 1000; // highest drawing gadget. + + result SetZOrderGroup(int zorderGroup); + int GetZOrderGroup(void) const; + + VisualElementSurface* GetSurfaceN(void) const; + result SetSurface(const VisualElementSurface* pSurface); + + result SetContentBounds(const Tizen::Graphics::FloatRectangle& contentBounds); + Tizen::Graphics::FloatRectangle GetContentBounds(void) const; + + /** + * Checks whether the back buffer is enabled or not. + * + * @since 2.0 + * @return @c true if the back buffer is enabled @n + * @c false, otherwise + */ + bool GetBackBufferEnabled(void) const; + + /** + * Sets whether the back buffer is enabled or not. + * + * @since 2.0 + * @return An error code. + * @param[in] enabled Set to @c true if need to enable the back buffer @n + * @c false, otherwise + */ + result SetBackBufferEnabled(bool enabled); + + /** + * Checks whether the VisualElement will be redrawn or not when resized. + * + * @since 2.0 + * @return @c true if the VisualElement is redrawn @n + * @c false, otherwise + */ + bool GetRedrawOnResizeEnabled(void) const; + + /** + * Sets whether the VisualElement is redrawn or not when resized. + * + * @since 2.0 + * @return An error code. + * @param[in] enabled Set to @c true if need to redraw the VisualElement when resized @n + * @c false, otherwise + */ + result SetRedrawOnResizeEnabled(bool enabled); + + /** + * Gets the bounding box information of the VisualElement. + * + * @since 2.0 + * @return Rectangular coordinates. + */ + Tizen::Graphics::FloatRectangle GetBoundingBox(void) const; + + Tizen::Graphics::FloatRectangle GetBounds(void) const; + result SetBounds(const Tizen::Graphics::FloatRectangle& bounds); + + float GetZPosition(void) const; + result SetZPosition(float zPosition); + + bool IsVisible(void) const; + bool GetShowState(void) const; + result SetShowState(bool show); + + /** + * Gets the current opacity of the VisualElement. + * + * @since 2.0 + * @return The opacity of the VisualElement. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @see SetOpacity() + */ + float GetContentOpacity(void) const; + + /** + * Changes the opacity of the VisualElement. + * + * @since 2.0 + * @return An error code + * @param[in] contentOpacity The new opacity. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @see GetOpacity() + * + */ + result SetContentOpacity(float contentOpacity); + + /** + * Gets absolute opacity of the VisualElement . + * + * @since 2.0 + * @return 0.0 ~ 1.0 multiplied by parent's absolute opacity. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + float GetOpacityFromRoot(void) const; + + float GetOpacity(void) const; + result SetOpacity(float opacity); + + Tizen::Graphics::FloatPoint GetAnchor(void) const; + result SetAnchor(const Tizen::Graphics::FloatPoint& anchor); + + float GetAnchorZ(void) const; + result SetAnchorZ(float anchorZ); + + Tizen::Graphics::FloatMatrix4 GetTransformMatrix(void) const; + result SetTransformMatrix(const Tizen::Graphics::FloatMatrix4& xform); + + Tizen::Graphics::FloatMatrix4 GetChildrenTransformMatrix(void) const; + result SetChildrenTransformMatrix(const Tizen::Graphics::FloatMatrix4& xform); + + /** + * Checks whether the VisualElement has been clipped to parent or not. + * + * @since 2.0 + * @return @c true, if the VisualElement has been clipped @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @see SetClipToParent() + */ + bool IsClipToParent(void) const; + + /** + * Changes the clipping state of the VisualElement. + * + * @since 2.0 + * @return An error code + * @param[in] clipToParent Set to @c true if need to be clipped to the parent VisualElement @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @see IsClipToParent() + * + */ + result SetClipToParent(bool clipToParent); + + bool IsClipChildrenEnabled(void) const; + result SetClipChildrenEnabled(bool clipChildren); + + /** + * Gets the Root of the VisualElementImpl. + * + * @since 2.0 + * @return The root of the VisualElement + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + _VisualElementImpl* GetRoot(void) const; + + + /** + * Gets the Root of the VisualElement. + * + * @since 2.0 + * @return The root of the VisualElement. The return type is _RootVisualElement. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + + _RootVisualElement* GetRootPublic(void) const + { + if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))) + { + const_cast< _VisualElementImpl* >(this)->RebuildCoordinates(); + } + + if (unlikely(!__pRoot)) + return null; + + return dynamic_cast< _RootVisualElement* >(__pRoot->__pPublicInstance); + } + + _VisualElementImpl* GetParent(void) const; + + int GetChildrenCount(void) const; + Tizen::Base::Collection::IList* GetPublicChildrenN(void) const; + + bool IsChildOf(const _VisualElementImpl& element) const; + result SetZOrder(const _VisualElementImpl* pReference, bool above); + + result AddChild(_VisualElementImpl& child); + result InsertChild(_VisualElementImpl& child, const _VisualElementImpl* pReference, bool above); + result RemoveChild(_VisualElementImpl& child, bool deallocate = false); + + Tizen::Base::String GetName(void) const; + result SetName(const Tizen::Base::String& name); + + result SetUserData(void* pUserData); + void* GetUserData(void) const; + + _VisualElementImpl* GetChild(const Tizen::Base::String& name, bool searchAllDescendants) const; + + result SetFlushNeeded(void); + result Flush(void); + result InvalidateRectangle(const Tizen::Graphics::FloatRectangle* pRectangle); + + /** + * Gets the rectangular region information was invalidated. + * + * @since 2.0 + * @return The rectangular region information was invalidated. + */ + Tizen::Graphics::FloatRectangle GetInvalidatedRectangle(void) const; + Tizen::Graphics::FloatRectangle GetUpdateRectangle(void) const; + + /** + * Checks whether the VisualElement is opaque or not. + * + * @since 2.0 + * @return @c true, if the VisualElement is opaque @n + * @c false, otherwise + */ + virtual bool IsOpaque(void) const; + + /** + * Checks whether the surface is opaque or not. + * + * @since 2.0 + * @return @c true, if the surface is opaque @n + * @c false, otherwise + */ + bool IsSurfaceOpaque(void) const; + + /** + * Changes the opaque of the surface. + * + * @since 2.0 + * @return An error code + * @param[in] isSurfaceOpaque The new show state. + * @exception E_SUCCESS The method was successful. + * @see IsSurfaceOpaque() + * + */ + result SetSurfaceOpaque(bool isSurfaceOpaque); + + result Draw(void); + Tizen::Graphics::Canvas* GetCanvasN(void); + Tizen::Graphics::Canvas* GetCanvasN(const Tizen::Graphics::Rectangle& bounds); + + /** + * Gets the top-most child VisualElement indicated by @c point. + * + * @since 2.0 + * @return the child VisualElement indicated by point. + * @param[in] point The position to find the child VisualElement. + */ + _VisualElementImpl* GetChildAt(const Tizen::Graphics::FloatPoint& point); + + result ConvertCoordinates(Tizen::Graphics::FloatPoint& point, const _VisualElementImpl* pFromElement) const; + result ConvertCoordinates(Tizen::Graphics::FloatRectangle& rectangle, const _VisualElementImpl* pFromElement) const; + + /** + * Converts the specified four 3-dimensional coordinates @c (x, y, z) in @c pFromVisualElement coordinate space to this instance's coordinate space. + * + * @since 2.0 + * + * @return An error code + * @param[in,out] x The values of X-axis to be converted. + * @param[in,out] y The values of Y-axis to be converted. + * @param[in,out] z The values of Z-axis to be converted. + * @param[in] count The number of coordinates in the @c (x, y, z) array. + * @param[in] pFromVisualElement The %VisualElement instance with @c (x, y, z) in its coordinate space. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The input parameter is incorrect. + * @exception E_SYSTEM A system error has occurred. + * @remarks This instance and @c pFromVisualElement must share a common parent.@n + * If @c null, it is regarded that the @c point is in the root %c VisualElement(%c Frame) coordinate space. + * @see ConvertCoordinates(Tizen::Graphics::FloatRectangle& rectangle, const VisualElement* pFromVisualElement) + * @see ConvertCoordinates(Tizen::Graphics::FloatPoint& point, const VisualElement* pFromVisualElement) + */ + result ConvertCoordinates(float* x, float* y, float* z, int count, const _VisualElementImpl* pFromElement) const; + + result AddAnimation(const Tizen::Base::String* keyName, VisualElementAnimation& animation); + result RemoveAnimation(const Tizen::Base::String& keyName); + + VisualElementAnimation* GetAnimationN(const Tizen::Base::String& keyName) const; + + /** + * Gets the animation playing for the specified property. + * + * @since 2.0 + * @return The pointer to the animation + * @param[in] property The name of the property. + * @exception E_SUCCESS The method was successful. + * @see AddAnimation() + * @see RemoveAnimation() + */ + VisualElementAnimation* GetAnimationForPropertyN(const Tizen::Base::String& property) const; + + result RemoveAllAnimations(void); + + /** + * Scrolls the VisualElement. + * + * @since 2.0 + * @param[in] pointOffset The new position to scroll + * @param[in] scrollSelf TBD + * @return An error code + * @exception E_SUCCESS The method was successful. + */ + result ScrollByPoint(const Tizen::Graphics::FloatPoint& pointOffset, bool scrollSelf); + + /** + * Gets the VisualElement for presentation. + * + * @since 2.0 + * @return the VisualElement for presentation. + */ + _VisualElementImpl* GetPresentation(void) const + { + ClearLastResult(); + return __pPresentation; + } + + /** + * Gets the VisualElement for presentation. + * + * @since 2.0 + * @return the VisualElement for presentation. + */ + _VisualElementImpl* GetModel(void) const + { + ClearLastResult(); + return __pModel; + } + + // only using in the control + void SetHidingParentNeeded(bool need) + { + __isHidingParent = need; + if(this == __pModel && __pPresentation) + { + __pPresentation->__isHidingParent = need; + } + } + + + // only using in internal instance( RootVisualElement or Dummy) + void SetInternal(bool internal) + { + __isInternal = internal; + if(this == __pModel && __pPresentation) + { + __pPresentation->__isInternal = internal; + } + } + + /** + * Gets the VisualElement's native node. + * + * @since 2.0 + * @return INativeNode , this value Platform dependency . + */ + class _INativeNode* GetNativeNode(void) const + { + return GetSharedData().pNativeNode; + } + + /** + * This method returned the status that the VisualElement could enable the implicit animation to do. + * + * @since 2.0 + * @return true/false implicit animation enable status. + */ + bool GetImplicitAnimationEnabled(void) const; + + /** + * Set enable or disable the implicit animation of the VisualElement . + * + * @since 2.0 + */ + result SetImplicitAnimationEnabled(bool enable); + + /** + * Checks whether the property propagation is enabled or not. + * + * @since 2.0 + * @return @c true if the property propagation is enabled @n + * @c false, otherwise + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + bool GetPropertyPropagationEnabled(void) const; + + /** + * Sets whether the property propagation is enabled or not. + * + * @since 2.0 + * @return An error code. + * @param[in] enable Set to @c true if need to enable the property propagation @n + * @c false, otherwise + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetPropertyPropagationEnabled(bool enable); + + /** + * This method fill the canvas with the drawn surface. + * + * @since 2.0 + * @param[in] canvas capture target. + * @param[in] boundsToDraw capture region of the VisualElement. + * @param[in] withChildren capture with the children. + * @return An error code + */ + result Capture(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& boundsToDraw, bool withChilren); + //Tizen::Graphics::Bitmap* CaptureBitmapN(bool withChildren = false); + + /** + * This method return stored public VisualElement instance pointer. + * + * @since 2.0 + * @return pointer of the public VisualElement instance. + */ + VisualElement* GetPublic(void) const + { + return __pPublicInstance; + } + + + result SetImageSource(const Tizen::Base::String& filePath); + result SetRenderOperation(VisualElement::RenderOperation renderOperation); + + + /** + * Gets the rendering operation of the VisualElement. + * + * @since 2.0 + * @return The rendering operation of the VisualElement. + * @see SetRenderOperation() + */ + VisualElement::RenderOperation GetRenderOperation(void) const; + + result SetPropertyI(const Tizen::Base::String& property, const Variant& value); + result InvokeOnSetPropertyRequested(const Tizen::Base::String& property, const Variant& value); + + Variant InvokeOnGetPropertyRequested(const Tizen::Base::String& property) const + { + if (__pPublicInstance) + { + return __pPublicInstance->OnGetPropertyRequested(property); + } + + return Variant(); + } + /** + * The hit testing default logic. + * + * @since 2.0 + * @return hit test result. + * @param[in] point hit test position. + * @see InvokeHitTest() + */ + int HitTestI(const Tizen::Graphics::FloatPoint& point); + + + /** + * The creating animation for the property. + * + * @since 2.0 + * @return animation instance for the property. + * @param[in] property property name. + * @see InvokeCreateAnimationForProperty() + */ + VisualElementAnimation* CreateAnimationForPropertyI(const Tizen::Base::String& property); + + typedef void (*BoundsChangedCallback)(void*); + void SetBoundsChangedCallback(BoundsChangedCallback pCallback, void* pData); + +protected: +// virtual _VisualElementImpl* CloneN(void); + + void InvalidateHierarchyProps(int invalidProps, bool broadcastToChildren, bool propagateToParentsOnly); + +private: + _VisualElementImpl(void); + _VisualElementImpl(VisualElement& element); + _VisualElementImpl(VisualElement& presentation, _VisualElementImpl& modelImpl); + virtual ~_VisualElementImpl(void); + _VisualElementImpl& operator =(const _VisualElementImpl& rhs); + + result Construct(void); + void Destroy(void); + + + Variant GetBoundsProperty(void) const; + result SetBoundsProperty(const Variant& v); + + Variant GetBoundsPositionSubProperty(void) const; + result SetBoundsPositionSubProperty(const Variant& v); + + Variant GetBoundsSizeSubProperty(void) const; + result SetBoundsSizeSubProperty(const Variant& v); + + Variant GetZPositionProperty(void) const; + result SetZPositionProperty(const Variant& v); + + Variant GetZOrderGroupProperty(void) const; + result SetZOrderGroupProperty(const Variant& v); + + Variant GetShowStateProperty(void) const; + result SetShowStateProperty(const Variant& v); + + Variant GetShowOpacityPrivateProperty(void) const; + result SetShowOpacityPrivateProperty(const Variant& v); + + Variant GetRenderOperationProperty(void) const; + result SetRenderOperationProperty(const Variant& v); + + Variant GetContentOpacityProperty(void) const; + result SetContentOpacityProperty(const Variant& v); + + Variant GetContentBoundsProperty(void) const; + result SetContentBoundsProperty(const Variant& v); + + Variant GetOpacityProperty(void) const; + result SetOpacityProperty(const Variant& v); + + Variant GetAnchorProperty(void) const; + result SetAnchorProperty(const Variant& v); + + Variant GetAnchorZProperty(void) const; + result SetAnchorZProperty(const Variant& v); + + Variant GetTransformMatrixProperty(void) const; + result SetTransformMatrixProperty(const Variant& v); + + Variant GetTransformRotationXSubProperty(void) const; + result SetTransformRotationXSubProperty(const Variant& v); + + Variant GetTransformRotationYSubProperty(void) const; + result SetTransformRotationYSubProperty(const Variant& v); + + Variant GetTransformRotationZSubProperty(void) const; + result SetTransformRotationZSubProperty(const Variant& v); + + Variant GetTransformRotationXYSubProperty(void) const; + result SetTransformRotationXYSubProperty(const Variant& v); + + Variant GetTransformRotationAnchorXSubProperty(void) const; + result SetTransformRotationAnchorXSubProperty(const Variant& v); + + Variant GetTransformRotationAnchorYSubProperty(void) const; + result SetTransformRotationAnchorYSubProperty(const Variant& v); + + Variant GetTransformRotationAnchorZSubProperty(void) const; + result SetTransformRotationAnchorZSubProperty(const Variant& v); + + Variant GetTransformRotationAnchorXYSubProperty(void) const; + result SetTransformRotationAnchorXYSubProperty(const Variant& v); + + Variant GetTransformScaleXSubProperty(void) const; + result SetTransformScaleXSubProperty(const Variant& v); + + Variant GetTransformScaleYSubProperty(void) const; + result SetTransformScaleYSubProperty(const Variant& v); + + Variant GetTransformScaleZSubProperty(void) const; + result SetTransformScaleZSubProperty(const Variant& v); + + Variant GetTransformScaleXYSubProperty(void) const; + result SetTransformScaleXYSubProperty(const Variant& v); + + Variant GetTransformScaleAnchorXSubProperty(void) const; + result SetTransformScaleAnchorXSubProperty(const Variant& v); + + Variant GetTransformScaleAnchorYSubProperty(void) const; + result SetTransformScaleAnchorYSubProperty(const Variant& v); + + Variant GetTransformScaleAnchorZSubProperty(void) const; + result SetTransformScaleAnchorZSubProperty(const Variant& v); + + Variant GetTransformScaleAnchorXYSubProperty(void) const; + result SetTransformScaleAnchorXYSubProperty(const Variant& v); + + Variant GetTransformTranslationXSubProperty(void) const; + result SetTransformTranslationXSubProperty(const Variant& v); + + Variant GetTransformTranslationYSubProperty(void) const; + result SetTransformTranslationYSubProperty(const Variant& v); + + Variant GetTransformTranslationZSubProperty(void) const; + result SetTransformTranslationZSubProperty(const Variant& v); + + Variant GetTransformTranslationXYSubProperty(void) const; + result SetTransformTranslationXYSubProperty(const Variant& v); + + Variant GetChildrenTransformMatrixProperty(void) const; + result SetChildrenTransformMatrixProperty(const Variant& v); + + Variant GetChildrenTransformRotationXSubProperty(void) const; + result SetChildrenTransformRotationXSubProperty(const Variant& v); + + Variant GetChildrenTransformRotationYSubProperty(void) const; + result SetChildrenTransformRotationYSubProperty(const Variant& v); + + Variant GetChildrenTransformRotationZSubProperty(void) const; + result SetChildrenTransformRotationZSubProperty(const Variant& v); + + Variant GetChildrenTransformRotationXYSubProperty(void) const; + result SetChildrenTransformRotationXYSubProperty(const Variant& v); + + Variant GetChildrenTransformRotationAnchorXSubProperty(void) const; + result SetChildrenTransformRotationAnchorXSubProperty(const Variant& v); + + Variant GetChildrenTransformRotationAnchorYSubProperty(void) const; + result SetChildrenTransformRotationAnchorYSubProperty(const Variant& v); + + Variant GetChildrenTransformRotationAnchorZSubProperty(void) const; + result SetChildrenTransformRotationAnchorZSubProperty(const Variant& v); + + Variant GetChildrenTransformRotationAnchorXYSubProperty(void) const; + result SetChildrenTransformRotationAnchorXYSubProperty(const Variant& v); + + Variant GetChildrenTransformScaleXSubProperty(void) const; + result SetChildrenTransformScaleXSubProperty(const Variant& v); + + Variant GetChildrenTransformScaleYSubProperty(void) const; + result SetChildrenTransformScaleYSubProperty(const Variant& v); + + Variant GetChildrenTransformScaleZSubProperty(void) const; + result SetChildrenTransformScaleZSubProperty(const Variant& v); + + Variant GetChildrenTransformScaleXYSubProperty(void) const; + result SetChildrenTransformScaleXYSubProperty(const Variant& v); + + Variant GetChildrenTransformScaleAnchorXSubProperty(void) const; + result SetChildrenTransformScaleAnchorXSubProperty(const Variant& v); + + Variant GetChildrenTransformScaleAnchorYSubProperty(void) const; + result SetChildrenTransformScaleAnchorYSubProperty(const Variant& v); + + Variant GetChildrenTransformScaleAnchorZSubProperty(void) const; + result SetChildrenTransformScaleAnchorZSubProperty(const Variant& v); + + Variant GetChildrenTransformScaleAnchorXYSubProperty(void) const; + result SetChildrenTransformScaleAnchorXYSubProperty(const Variant& v); + + Variant GetChildrenTransformTranslationXSubProperty(void) const; + result SetChildrenTransformTranslationXSubProperty(const Variant& v); + + Variant GetChildrenTransformTranslationYSubProperty(void) const; + result SetChildrenTransformTranslationYSubProperty(const Variant& v); + + Variant GetChildrenTransformTranslationZSubProperty(void) const; + result SetChildrenTransformTranslationZSubProperty(const Variant& v); + + Variant GetChildrenTransformTranslationXYSubProperty(void) const; + result SetChildrenTransformTranslationXYSubProperty(const Variant& v); + + Variant GetClipToParentProperty(void) const; + result SetClipToParentProperty(const Variant& v); + + Variant GetClipChildrenProperty(void) const; + result SetClipChildrenProperty(const Variant& v); + + Variant GetNameProperty(void) const; + result SetNameProperty(const Variant& v); + + Variant GetSurfaceOpaqueProperty(void) const; + result SetSurfaceOpaqueProperty(const Variant& v); + + Variant GetImplicitAnimationProperty(void) const; + result SetImplicitAnimationProperty(const Variant& v); + + Variant GetPropertyPropagationProperty(void) const; + result SetPropertyPropagationProperty(const Variant& v); + + static void AdjustSizeForSurface(float& width, float& height) + { + float originalWidth = width; + float originalHeight = height; + _VisualElementCoordinateSystem::MakeIntegralDimension(width, height); + + if (originalWidth > 0.0f && width == 0.0f) + { + width = 1.0f; + } + + if (originalHeight > 0.0f && height == 0.0f) + { + height = 1.0f; + } + } + + result SetBoundsI(const Tizen::Graphics::FloatRectangle& bounds); + result SetZPositionI(float zPosition); + result SetShowOpacityI(float showOpacity); + result SetShowStateI(bool show); + result SetContentBoundsI(const Tizen::Graphics::FloatRectangle& contentBounds); + result SetContentOpacityI(float contentOpacity); + result SetOpacityI(float opacity); + result SetAnchorI(const Tizen::Graphics::FloatPoint& anchor); + result SetAnchorZI(float anchorZ); + result SetPropertyPropagationEnabledI(bool enable); + result SetTransformMatrixI(const Tizen::Graphics::FloatMatrix4& xform, bool updateDecomposed = true); + result SetChildrenTransformMatrixI(const Tizen::Graphics::FloatMatrix4& xform, bool updateDecomposed = true); + result SetZOrderGroupI(int zOrderGroup); + + bool CheckIfAnimatable(const Tizen::Base::String& property) const; + bool IsSurfaceNeeded(void) const; + void RebuildSurfaces(void); + void ResetSurfaceIfNeeded(void); + _VisualElementImpl* GetRenderTarget(void) const; + _VisualElementImpl* GetClipSource(void) const + { + if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES))) + { + const_cast< _VisualElementImpl* >(this)->RebuildCoordinates(); + } + + return __pClipSource; + } + + int GetChildIndex(const _VisualElementImpl& child) const; + result RemoveChildWithoutReconfiguring(int indexChild, bool invalidate); + result RemoveAllChild(void); + void RemoveFromParent(void); + + void RebuildNativeNodeTree(_VisualElementImpl& parent); + void ExposeRectangle(const Tizen::Graphics::FloatRectangle* pDirtyRectangle, bool invalidate); + + bool IsVisibleI(void) const + { + if (unlikely(IsPropsInvalidated(HIERARCHY_PROPERTY_COORDINATES | HIERARCHY_PROPERTY_SHOWSTATE | HIERARCHY_PROPERTY_OPACITY | HIERARCHY_PROPERTY_CONTENTOPACITY))) + { + const_cast< _VisualElementImpl* >(this)->RebuildVisibility(); + } + + return __isVisible; + } + + void SetRootNeedsContentUpdate(void) + { + if (unlikely(__childrenNeedsUpdateProps & HIERARCHY_PROPERTY_CONTENT)) + { + _RootVisualElement* pRoot = GetRootPublic(); + if (likely(pRoot)) + { + pRoot->SetNeedsContentUpdate(true); + } + } + } + + bool IsAncestorDestroying(void) const + { + const _VisualElementImpl* pElement = __pParent; + + while (pElement != null) + { + if (pElement->__isDestroying) + { + return true; + } + + pElement = pElement->GetParent(); + } + + return false; + } + // Presentation update method(observer) + void UpdatePresentationWhenChildRemoved(_VisualElementImpl& child, bool deallocate); + void UpdatePresentationWhenZOrderChanged(const _VisualElementImpl* pReferenceModel, bool above); + result UpdatePresentationWhenCustomPropertyChanged(const Tizen::Base::String& property, const Variant& value); + + // invoke the delegation method. + void InvokeOnConstructed(void); + + void InvokeOnDestructing(void); + + result InvokeOnChildAttaching( _VisualElementImpl& child); + + void InvokeOnChildAttached( _VisualElementImpl& child); + + result InvokeOnChildDetaching( _VisualElementImpl& child); + + void InvokeOnChildDetached( _VisualElementImpl& child); + + result InvokeOnAttaching( _VisualElementImpl& parent); + + void InvokeOnAttached(void); + + result InvokeOnDetaching(void); + + void InvokeOnDetached( _VisualElementImpl& parent); + + result InvokeOnAnimationAdded( const VisualElementAnimation* pAnimation); + + result InvokeOnAnimationRemoved( const VisualElementAnimation* pAnimation); + + void InvokeOnShowStateChanged(bool showState); + + /** + * Called when transform matrix is about to be changed. + * + * @since 2.0 + * @param[in] source VisualElement instance to be changed. + * @param[in,out] newTransform Transform matrix to be applied. + */ + result InvokeOnTransformMatrixChanging(Tizen::Graphics::FloatMatrix4& newTransform); + + /** + * Called when transform matrix is changed. + * + * @since 2.0 + * @param[in] source VisualElement instance changed. + * @param[in] oldTransform The old transform matrix + */ + void InvokeOnTransformMatrixChanged(const Tizen::Graphics::FloatMatrix4& oldTransform); + + /** + * Called when transform matrix for children is about to be changed. + * + * @since 2.0 + * @param[in] source VisualElement instance to be changed. + * @param[in,out] newTransform Transform matrix for children to be applied. + */ + result InvokeOnChildrenTransformMatrixChanging(Tizen::Graphics::FloatMatrix4& newTransform); + + /** + * Called when transform matrix for children is changed. + * + * @since 2.0 + * @param[in] source VisualElement instance changed. + * @param[in] oldTransform The old transform matrix + */ + void InvokeOnChildrenTransformMatrixChanged(const Tizen::Graphics::FloatMatrix4& oldTransform); + + /** + * Called when bounds is about to be changed. + * + * @since 2.0 + * @param[in] source VisualElement instance to be changed. + * @param[in,out] newBounds The new bounds + */ + result InvokeOnBoundsChanging(Tizen::Graphics::FloatRectangle& newBounds); + + /** + * Called when bounds is changed. + * + * @since 2.0 + * @param[in] source VisualElement instance changed. + * @param[in] oldBounds The old bounds + */ + void InvokeOnBoundsChanged(const Tizen::Graphics::FloatRectangle& oldBounds); + + /** + * For checking that point is in the VisualElement region. + * + * @since 2.0 + * @param[in] point the point to check in self coordinate system. + * + */ + int InvokeHitTest(const Tizen::Graphics::FloatPoint& point); + + + /** + * Overrides this method to check the element can draw. + * + * @since 2.0 + */ + bool InvokePrepareDraw(void); + + /** + * Overrides this method to provide user-specific draw code. + * + * @since 2.0 + */ + void InvokeOnDraw( Tizen::Graphics::Canvas& canvas); + + /** + * Overrides this method to provide user-specific implicit animation. + * + * return return _Animation instance for the specified property, or null to disable implcit animation for the property. + * @since 2.0 + */ + VisualElementAnimation* InvokeCreateAnimationForProperty(const Tizen::Base::String& property); + + VisualElement* CreateElementForImplicitAnimationN(void) const; + result CreateElementTreeForDetachImplicitAnimation(_VisualElementImpl& child); + + Tizen::Graphics::FloatRectangle GetVisibleRect(void) const; + Tizen::Graphics::FloatRectangle GetDrawableRect(void) const; + + const Tizen::Graphics::FloatRectangle& GetBoundingBoxI(void) const; + const Tizen::Graphics::FloatMatrix4& GetMatrixToSuper(void) const; + const Tizen::Graphics::FloatMatrix4& GetMatrixToTop(void) const; + const Tizen::Graphics::FloatMatrix4& GetMatrixFromTop(void) const; + Tizen::Graphics::FloatMatrix4 CalcMatrixToBase(const _VisualElementImpl& base) const; + const Tizen::Graphics::FloatMatrix4& GetMatrixToClipSource(void) const; + + void DrawRectangleIfNeeded(const Tizen::Graphics::FloatRectangle& drawRect); + void DrawRectangle(const Tizen::Graphics::FloatRectangle& drawRect); + + void LockInvalidate(bool lock); + void InvalidateHierarchyPropsDownward(int invalidProps, bool broadcastToChildren, bool propagateToParentsOnly); + void InvalidateVisibleRectToRenderTarget(const Tizen::Graphics::FloatRectangle* pDirtyRectangle); + void RebuildCoordinates(void); + void RebuildVisibility(void); + void RebuildHierarchyProps(int props, bool checkSurface, bool reconfSurfaceOnly); + void UpdateHierarchyProps(void); + void FlushNativeChanges(void); + + void SetSurfaceChanged(void); + + bool IsPropsInvalidated(int props) const + { + return (__invalidatedProps & props) != 0; + } + + void SetPropsValidaty(int validProps, int invalidProps) + { + __invalidatedProps &= ~validProps; + __invalidatedProps |= invalidProps; + + if (this == __pPresentation) + GetSharedData().invalidatedNativeProps |= invalidProps; + } + + bool IsDrawingObject(void) const + { + return (this == __pModel); + } + + result InvalidateRectangleI(const Tizen::Graphics::FloatRectangle* pRectangle); + + int GetZOrderGroupIndex(int orderGroup, int& begin, int& end) const; + result ChangeZOrder(_VisualElementImpl& child, const _VisualElementImpl* pReference, bool above, int zorderGroup); + + _VisualElementImpl* GetChildAtPointI(const Tizen::Graphics::FloatPoint& point, int parentHitTest); + + result AddAnimationI(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation); + result AddAnimationGroupI(const Tizen::Base::String* pKeyName, VisualElementAnimation& animation); + + result CaptureI(Tizen::Graphics::Canvas& outputCanvas, const Tizen::Graphics::FloatRectangle& rectDest, _VisualElementImpl& reference, const Tizen::Graphics::FloatRectangle& clipRect, bool withChilren, int depth); + + _VisualElementSharedData& GetSharedData(void) const + { + return *__pSharedData; + } + + bool CreateImplicitAnimationIfNeeded(const Tizen::Base::String& property, const Variant& newValue, const Variant& currentPresntationValue, const Tizen::Base::String** pSubList); + +public: + enum + { + HITTEST_NOWHERE = 0, + HITTEST_NOMORECHILDREN = 1, + HITTEST_MATCH = 2 + }; + +protected: + enum { + HIERARCHY_PROPERTY_COORDINATES = 0x01, + HIERARCHY_PROPERTY_OPACITY = 0x02, + HIERARCHY_PROPERTY_SHOWSTATE = 0x04, + HIERARCHY_PROPERTY_CONTENTOPACITY = 0x08, + HIERARCHY_PROPERTY_NATIVENODE = HIERARCHY_PROPERTY_CONTENTOPACITY, + HIERARCHY_PROPERTY_SURFACE = 0x10, // only for presentation element + HIERARCHY_PROPERTY_CONTENT = 0x20, + HIERARCHY_PROPERTY_CONTENTBOUNDS = 0x40, + HIERARCHY_PROPERTY_MASK = 0x7F + }; + + int _zOrderGroup; + +private: + _VisualElementSharedData* __pSharedData; + _VisualElementImpl* __pParent; + _VisualElementImpl* __pModel; + _VisualElementImpl* __pPresentation; + +// _RootVisualElement* __pRoot; + _VisualElementImpl* __pRoot; + bool __isRoot; + bool __isVisible; + float __showOpacity; + + bool __needRecreateSurface; + + Tizen::Graphics::FloatRectangle __bounds; + Tizen::Graphics::FloatDimension __alignedSize; + Tizen::Graphics::FloatRectangle __contentBounds; + bool __useContentBounds; + float __zPosition; + float __contentOpacity; + float __opacity; + Tizen::Graphics::FloatPoint __anchor; + float __anchorZ; + Tizen::Graphics::FloatMatrix4 __transform; + _TransformMatrix3Df __decomposedTransform; + Tizen::Graphics::FloatMatrix4 __childrenTransform; + _TransformMatrix3Df __decomposedChildrenTransform; + + unsigned int __childrenNeedsUpdateProps; + unsigned int __invalidatedProps; + + bool __matrixFromTopValid; + bool __matrixFromTopInvertible; + bool __matrixToSuperValid; + bool __matrixToTopValid; + bool __matrixToClipSourceValid; + bool __boundingBoxValid; + bool __visibleRectValid; + bool __needTransform; + bool __needClipForUntransformed; + bool __isImplicitAnimationEnabled; + + bool __isClipChildren; + + Tizen::Graphics::FloatRectangle __boundingBox; + Tizen::Graphics::FloatRectangle __boundingBoxToClipSource; + Tizen::Graphics::FloatMatrix4 __matrixToSuper; + Tizen::Graphics::FloatMatrix4 __matrixToTop; + Tizen::Graphics::FloatMatrix4 __matrixFromTop; + Tizen::Graphics::FloatMatrix4 __matrixToClipSource; + _VisualElementImpl* __pClipSource; + + Tizen::Graphics::FloatRectangle __visibleRect; + + bool __isPropertyPropagationEnabled; + bool __isDestroying; + bool __isHidingParent; + bool __isInternal; + bool __isAllowedTreeModification; + + class ChildrenListT : public Tizen::Base::Collection::ArrayListT<_VisualElementImpl*> + { + public: + _VisualElementImpl* GetChildAt(int index) const + { + _VisualElementImpl* pChild = null; + if (likely(GetAt(index, pChild) == E_SUCCESS)) + return pChild; + + return null; + } + }; + + ChildrenListT __children; + + VisualElement* __pPublicInstance; // for public class instance pointer + + Tizen::Base::String __imageFilePath; + VisualElement::RenderOperation __renderOperation; + + BoundsChangedCallback __pBoundsChangedCallback; + void* __pBoundsChangedCallbackData; + + friend class _VeDebug; + friend class _EflNode; + friend class _VisualElementModelObserver; + friend class VisualElement; + friend class _VisualElement; + friend class _ControlVisualElement; + friend class _RootVisualElement; + friend class _AnimationManager; + friend class _DisplayManager; +}; // _VisualElementImpl + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_VISUAL_ELEMENT_IMPL_H_ + diff --git a/src/ui/inc/FUiAnim_VisualElementSharedData.h b/src/ui/inc/FUiAnim_VisualElementSharedData.h new file mode 100644 index 0000000..ee41c11 --- /dev/null +++ b/src/ui/inc/FUiAnim_VisualElementSharedData.h @@ -0,0 +1,105 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementSharedData.h + * @brief This is the header file for the _VisualElementSharedData class. + * + * This header file contains the declarations of the _VisualElementSharedData class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_SHAREDDATA_H_ +#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_SHAREDDATA_H_ + +#include + +#include "FUiAnim_INativeNode.h" + + +namespace Tizen { namespace Ui { namespace Animations +{ + +class IVisualElementAnimationProvider; +class IVisualElementContentProvider; +class IVisualElementEventListener; +class _NativeLayer; +class _OSP_EXPORT_ _VisualElementSharedData +{ +public: + _VisualElementSharedData(void); + virtual ~_VisualElementSharedData(void); + + result Construct(void); + + virtual void AddRef(void); + virtual void Release(void); + int GetReferenceCount(void) const; + + void LockInvalidate(bool lock); + result NodeReconfigure(_VisualElementImpl& presentation, bool surfaceOnly) + { + ClearLastResult(); + SysTryReturn(NID_UI, pNativeNode, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The Native Node is not valid."); + + return pNativeNode->Reconfigure(pSurface, presentation, surfaceOnly); + } + + result CreateSurface(const Tizen::Graphics::Dimension& size, _NativeLayer& layer); + void RemoveSurface(_VisualElementImpl& presentation); + result SetImage(const Tizen::Base::String& fileName); + + bool NeedNativeReconfigure(void) const + { + return (invalidatedNativeProps != 0) || surfaceChanged; + } + + +public: + int invalidatedNativeProps; + bool surfaceChanged; + _INativeNode* pNativeNode; + VisualElementSurface* pSurface; + Tizen::Graphics::FloatRectangle invalidatedRegion; + bool drawOnPresentation; + bool needSurface; + bool redrawOnResize; + bool isSurfaceOpaque; + bool fixedSurfaceSize; + int invalidationLockCount; + Tizen::Graphics::FloatRectangle updateRegion; + + IVisualElementAnimationProvider* pAnimationProvider; + IVisualElementContentProvider* pContentProvider; + IVisualElementEventListener* pEventListener; + + Tizen::Base::String name; + + void* pUserData; + +private: + _VisualElementSharedData(const _VisualElementSharedData& rhs); + _VisualElementSharedData& operator =(const _VisualElementSharedData& rhs); + +private: + int __refCount; +}; // _VisualElementSharedData + + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_VISUAL_ELEMENT_SHAREDDATA_H_ + diff --git a/src/ui/inc/FUiAnim_VisualElementSurfaceImpl.h b/src/ui/inc/FUiAnim_VisualElementSurfaceImpl.h new file mode 100644 index 0000000..405c082 --- /dev/null +++ b/src/ui/inc/FUiAnim_VisualElementSurfaceImpl.h @@ -0,0 +1,100 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiAnim_VisualElementSurfaceImpl.h + * @brief This is the header file for the _VisualElementSurfaceImpl class. + * + * This header file contains the declarations of the _VisualElementSurfaceImpl class. + */ + +#ifndef _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_SURFACE_IMPL_H_ +#define _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_SURFACE_IMPL_H_ + +#include +#include +#include +#include +#include + +// CHECKME: Why 'Handle' is 'int' ? no 64-bit support??? :( + +namespace Tizen { namespace Base +{ + class String; +}} // Tizen::Base + +namespace Tizen { namespace Ui { namespace Animations +{ +class DisplayContext; + +class _VisualElementSurfaceImpl + : public Tizen::Base::Object +{ +protected: + _VisualElementSurfaceImpl(const Tizen::Graphics::Dimension& size); + +public: + virtual ~_VisualElementSurfaceImpl(void); + +public: + static VisualElementSurface* CreateSurfaceN(const Handle handle, const Tizen::Graphics::Dimension& size); // create public instance + static VisualElementSurface* CreateSurfaceUsingExistingObjectN(const DisplayContext& displayContext, const Handle handle, const Tizen::Graphics::Dimension& size); + static _VisualElementSurfaceImpl* CreateInstanceN(const DisplayContext& displayContext, const Tizen::Graphics::Dimension& size); // create internal instance + + virtual Handle GetNativeHandle(void) const = 0; + virtual result SetImage(const Tizen::Base::String& fileName); + virtual result GetBufferInfo(Tizen::Graphics::BufferInfo& bufferInfo) const; + + virtual Tizen::Graphics::Dimension GetPhysicalSize(void) const; + + Tizen::Graphics::Dimension GetSize(void) const + { + return __logicalSize; + } + + virtual bool Equals(const Tizen::Base::Object& obj) const; + virtual int GetHashCode(void) const; + + void AddRef(void); + bool Release(void); + int GetReferenceCount(void) const; + + static _VisualElementSurfaceImpl* GetInstance(VisualElementSurface& surface) + { + return surface.__pVisualElementSurfaceImpl; + } + + static const _VisualElementSurfaceImpl* GetInstance(const VisualElementSurface& surface) + { + return surface.__pVisualElementSurfaceImpl; + } + +private: + _VisualElementSurfaceImpl(void); + _VisualElementSurfaceImpl(const _VisualElementSurfaceImpl& rhs); + _VisualElementSurfaceImpl& operator =(const _VisualElementSurfaceImpl& rhs); + +private: + int __refCount; + Tizen::Graphics::Dimension __logicalSize; +}; // _VisualElementSurfaceImpl + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_VISUAL_ELEMENT_SURFACE_IMPL_H_ + diff --git a/src/ui/inc/FUiCtrl_ActionEvent.h b/src/ui/inc/FUiCtrl_ActionEvent.h new file mode 100644 index 0000000..6d83b3b --- /dev/null +++ b/src/ui/inc/FUiCtrl_ActionEvent.h @@ -0,0 +1,99 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ActionEvent.h + * @brief This is the header file for _ActionEvent class. + * + * This header file contains declaration of _ActionEvent class. + * The ActionEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_INTERNAL_ACTION_EVENT_H_ +#define _FUI_CTRL_INTERNAL_ACTION_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +} } // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** +* @class _ActionEvent +* @brief This class handles a action event. It is inherited from Event class. +* +* The Window(root of all widgets) class has an instance of the _ActionEvent class as a member variable. +* Applications can register action event listeners through it. When a action event occurred, +* the _ActionEvent class finds listener and calls the appropriate listener's method. +* +*/ +class _ActionEvent + : public Tizen::Base::Runtime::_Event +{ +public: + /** + * This is the default class destructor. + * + */ + virtual ~_ActionEvent(void); + + static _ActionEvent* CreateInstanceN(const Tizen::Ui::_Control& source); + +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::_Control* GetSource(void) const; + +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _ActionEvent(const Tizen::Ui::_Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * listener's method. + * + * @param[in] listener It is a event listener related to this action event. + * @param[in] arg It is an argument-like instance of action event retransmitted to the listener's method + * as an argument. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +public: + static Tizen::Base::Runtime::IEventArg* CreateActionEventArgN(int actionId); + +private: + const Tizen::Ui::_Control* __pSource; +}; // _ActionEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ACTION_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_AdjustmentEvent.h b/src/ui/inc/FUiCtrl_AdjustmentEvent.h new file mode 100644 index 0000000..316f58a --- /dev/null +++ b/src/ui/inc/FUiCtrl_AdjustmentEvent.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_AdjustmentEvent.h + * @brief This is the header file for _AdjustmentEvent class. + * + * This header file contains declaration of _AdjustmentEvent class. + */ +#ifndef _FUICTRL_ADJUSTMENT_EVENT_H_ +#define _FUICTRL_ADJUSTMENT_EVENT_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** +* @class _AdjustmentEvent +* @brief When cursor change occurred. +* +*/ +class _AdjustmentEvent + : public Tizen::Base::Runtime::_Event +{ +public: + virtual ~_AdjustmentEvent(void); + + const Tizen::Ui::_Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateAdjustmentEventArgN(int adjustment); + static _AdjustmentEvent* CreateInstanceN(const Tizen::Ui::_Control& source); + +protected: + _AdjustmentEvent(const Tizen::Ui::_Control& source); + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + const Tizen::Ui::_Control* __pSource; + +}; // _AdjustmentEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_ADJUSTMENT_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_Animation.h b/src/ui/inc/FUiCtrl_Animation.h new file mode 100644 index 0000000..f0b4e84 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Animation.h @@ -0,0 +1,100 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Animation.h + * @brief This is the header file for the _Animation class. + * + * This header file contains the declarations of the %_Animation class. + */ +#ifndef _FUI_CTRL_INTERNAL_ANIMATION_H_ +#define _FUI_CTRL_INTERNAL_ANIMATION_H_ + +#include +#include +#include +#include +#include +#include "FUi_Control.h" +#include "FUiCtrl_AnimationEvent.h" +#include "FUiCtrl_IAnimationEventListener.h" + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _AnimationPresenter; + + +class _Animation + : public Tizen::Ui::_Control + , public Tizen::Base::Runtime::ITimerEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer +{ + DECLARE_CLASS_BEGIN(_Animation, Tizen::Ui::_Control); + DECLARE_PROPERTY("repeatCount", GetPropertyRepeatCount, SetPropertyRepeatCount); + DECLARE_CLASS_END(); + +public: + _Animation(void); + virtual ~_Animation(void); + + result SetPropertyRepeatCount(const Tizen::Ui::Variant& repeatCount); + Tizen::Ui::Variant GetPropertyRepeatCount(void) const; + + result AddAnimationEventListener(const _IAnimationEventListener& listener); + result RemoveAnimationEventListener(const _IAnimationEventListener& listener); + result SetAnimationFrames(const Tizen::Base::Collection::IList& animationFrames); + void SetImageCount(int imageCount); + result SetRepeatCount(int count); + Tizen::Base::Collection::IList* GetAnimationFrames(void) const; + int GetRepeatCount(void) const; + int GetImageCount(void) const; + int GetCurrentRepeatedCount(void) const; + result Play(void); + result Stop(void); + result Pause(void); + AnimationStatus GetStatus(void) const; + + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + virtual void OnDraw(void); + virtual result OnAttachedToMainTree(void); + virtual void OnBoundsChanged(void); + + static _Animation* CreateAnimationN(void); + +private: + _Animation(const _Animation& rhs); + _Animation& operator =(const _Animation& rhs); + +private: + _AnimationPresenter* __pAnimationPresenter; + Tizen::Ui::Control* __pControlAnimation; + _AnimationEvent* __pAnimationEvent; + Tizen::Base::Collection::IList* __pAnimationFrames; + Tizen::Ui::_AccessibilityElement* __pAccessibilityElement; + +}; // _Animation + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ANIMATION_H_ diff --git a/src/ui/inc/FUiCtrl_AnimationEvent.h b/src/ui/inc/FUiCtrl_AnimationEvent.h new file mode 100644 index 0000000..dab429a --- /dev/null +++ b/src/ui/inc/FUiCtrl_AnimationEvent.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_AnimationEvent.h + * @brief This is the header file for _AnimationEvent class. + * + * This header file contains declaration of _AnimationEvent class. + * The AnimationEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_INTERNAL_ANIMATION_EVENT_H_ +#define _FUI_CTRL_INTERNAL_ANIMATION_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _AnimationEvent + : public Tizen::Base::Runtime::_Event +{ +public: + virtual ~_AnimationEvent(void); + + const Tizen::Ui::_Control* GetSource(void) const; + + static _AnimationEvent* CreateInstanceN(const Tizen::Ui::_Control& source); + static Tizen::Base::Runtime::IEventArg* CreateAnimationEventArgN(void); + +protected: + _AnimationEvent(const Tizen::Ui::_Control& source); + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + const Tizen::Ui::_Control* __pSource; + +}; // _AnimationEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ANIMATION_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_AnimationFrameImpl.h b/src/ui/inc/FUiCtrl_AnimationFrameImpl.h new file mode 100644 index 0000000..fc47f4c --- /dev/null +++ b/src/ui/inc/FUiCtrl_AnimationFrameImpl.h @@ -0,0 +1,58 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_AnimationFrameImpl.h + * @brief This is the header file for the _AnimationFrameImpl class. + * + * This header file contains the declarations of the %_AnimationFrameImpl class. + */ +#ifndef _FUI_CTRL_INTERNAL_ANIMATION_FRAME_IMPL_H_ +#define _FUI_CTRL_INTERNAL_ANIMATION_FRAME_IMPL_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _AnimationFrameImpl + : public Tizen::Base::Object +{ +public: + _AnimationFrameImpl(void); + _AnimationFrameImpl(const Tizen::Graphics::Bitmap& frame, long duration); + virtual ~_AnimationFrameImpl(void); + +public: + result SetFrame(const Tizen::Graphics::Bitmap& frame); + const Tizen::Graphics::Bitmap* GetFrame(void) const; + result SetDuration(long duration); + long GetDuration(void) const; + +private: + _AnimationFrameImpl(const _AnimationFrameImpl& rhs); + _AnimationFrameImpl& operator =(const _AnimationFrameImpl& rhs); + +private: + Tizen::Graphics::Bitmap* __pFrame; + long __duration; + +}; // _AnimationFrameImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_ANIMATION_FRAME_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_AnimationImpl.h b/src/ui/inc/FUiCtrl_AnimationImpl.h new file mode 100644 index 0000000..902b82a --- /dev/null +++ b/src/ui/inc/FUiCtrl_AnimationImpl.h @@ -0,0 +1,80 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_AnimationImpl.h + * @brief This is the header file for the _AnimationImpl class. + * + * This header file contains the declarations of the %_AnimationImpl class. + */ +#ifndef _FUI_CTRL_INTERNAL_ANIMATION_IMPL_H_ +#define _FUI_CTRL_INTERNAL_ANIMATION_IMPL_H_ + +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_IAnimationEventListener.h" +#include "FUiCtrl_PublicAnimationEvent.h" +#include "FUiCtrl_Animation.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _AnimationImpl + : public _ControlImpl + , public _IAnimationEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ + +public: + virtual ~_AnimationImpl(void); + + result SetAnimationFrames(const Tizen::Base::Collection::IList& animationFrames); + void SetImageCount(int imageCount); + result AddAnimationEventListener(Tizen::Ui::IAnimationEventListener& listener); + result RemoveAnimationEventListener(Tizen::Ui::IAnimationEventListener& listener); + result SetRepeatCount(int count); + int GetRepeatCount(void) const; + int GetCurrentRepeatedCount(void) const; + int GetImageCount(void) const; + result Play(void); + result Stop(void); + result Pause(void); + AnimationStatus GetStatus(void) const; + + virtual const char* GetPublicClassName(void) const; + virtual const Animation& GetPublic(void) const; + virtual Animation& GetPublic(void); + virtual const _Animation& GetCore(void) const; + virtual _Animation& GetCore(void); + virtual void OnAnimationStopped(const Tizen::Ui::_Control& source); + + static _AnimationImpl* CreateAnimationImplN(Animation* pControl); + static _AnimationImpl* GetInstance(Animation& animation); + static const _AnimationImpl* GetInstance(const Animation& animation); + +private: + _AnimationImpl(Animation* pPublic, _Animation* pCore); + _AnimationImpl(const _AnimationImpl& rhs); + _AnimationImpl& operator =(const _AnimationImpl& rhs); + +private: + _PublicAnimationEvent* __pPublicAnimationEvent; + +}; // _AnimationImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_ANIMATION_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_AnimationModel.h b/src/ui/inc/FUiCtrl_AnimationModel.h new file mode 100644 index 0000000..459e138 --- /dev/null +++ b/src/ui/inc/FUiCtrl_AnimationModel.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_AnimationModel.h + * @brief This is the header file for the _AnimationModel class. + * + * This header file contains the declarations of the %_AnimationModel class. + */ +#ifndef _FUI_CTRL_INTERNAL_ANIMATION_MODEL_H_ +#define _FUI_CTRL_INTERNAL_ANIMATION_MODEL_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _AnimationModel + : public Tizen::Base::Object +{ +public: + _AnimationModel(void); + virtual ~_AnimationModel(void); + +public: + void SetAnimationStatus(AnimationStatus status); + AnimationStatus GetAnimationStatus(void) const; + void SetImageCount(int imageCount); + int GetImageCount(void) const; + void SetRepeatCount(int repeatCount); + int GetRepeatCount(void) const; + void SetCurrentRepeatedCount(int currentRepeatCount); + int GetCurrentRepeatedCount(void) const; + +private: + _AnimationModel(const _AnimationModel& rhs); + _AnimationModel& operator =(const _AnimationModel& rhs); + +private: + AnimationStatus __animationStatus; + int __imageCount; + int __repeatCount; + int __currentRepeatedCount; + +}; //_AnimationModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ANIMATION_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_AnimationPresenter.h b/src/ui/inc/FUiCtrl_AnimationPresenter.h new file mode 100644 index 0000000..f26735e --- /dev/null +++ b/src/ui/inc/FUiCtrl_AnimationPresenter.h @@ -0,0 +1,82 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_AnimationPresenter.h + * @brief This is the header file for the _AnimationPresenter class. + * + * This header file contains the declarations of the %_AnimationPresenter class. + */ +#ifndef _FUI_CTRL_INTERNAL_ANIMATION_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_ANIMATION_PRESENTER_H_ + +#include +#include +#include +#include "FUi_ControlImpl.h" +#include "FUiAnim_VisualElement.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Animation; +class _AnimationModel; + + +class _AnimationPresenter + : public Tizen::Base::Object +{ +public: + virtual ~_AnimationPresenter(void); + + result Draw(void); + bool IsTimerExpired(Tizen::Base::Runtime::Timer& timer); + void SetImageCount(int imageCount); + result SetAnimationFrames(const Tizen::Base::Collection::IList* pAnimationFrames); + void SetRepeatCount(int count); + int GetRepeatCount(void) const; + int GetCurrentRepeatedCount(void) const; + int GetImageCount(void) const; + result Play(void); + result Stop(void); + result Pause(void); + AnimationStatus GetStatus(void) const; + + static _AnimationPresenter* CreateInstanceN(const _Animation& animation); + +private: + _AnimationPresenter(void); + result Initialize(const _Animation& animation); + + AnimationFrame* GetCurrentFrame(void) const; + AnimationFrame* GetNextFrame(void) const; + result Dispose(void); + + _AnimationPresenter(const _AnimationPresenter& rhs); + _AnimationPresenter& operator =(const _AnimationPresenter& rhs); + +private: + _Animation* __pAnimation; + _AnimationModel* __pAnimationModel; + Tizen::Base::Runtime::Timer* __pTimer; + Tizen::Base::Collection::IEnumerator* __pCurrentFrame; + bool __isTimerRunning; + Tizen::Ui::Animations::_VisualElement* __pVisualElement; + +}; // _AnimationPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ANIMATION_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_Button.h b/src/ui/inc/FUiCtrl_Button.h new file mode 100644 index 0000000..bc3fce8 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Button.h @@ -0,0 +1,274 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Button.h + * @brief This is the header file for the _Button class. + * + * This header file contains the declarations of the %_Button class. + */ +#ifndef _FUI_CTRL_INTERNAL_BUTTON_H_ +#define _FUI_CTRL_INTERNAL_BUTTON_H_ + +#include +#include "FUi_Control.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_ActionEvent.h" + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class _ButtonPresenter; + +/** + * @class _Button + * @brief + * @since 1.0 + * + * + * + * + */ +enum _ButtonStatus +{ + _BUTTON_STATUS_NORMAL = 0, /**< The normal status */ + _BUTTON_STATUS_DISABLED, /**< The disabled status */ + _BUTTON_STATUS_PRESSED, /**< The pressed status */ + _BUTTON_STATUS_HIGHLIGHTED, /**< The highlighted status */ + _BUTTON_STATUS_SELECTED /**< The slecteded status */ +}; + +enum _ButtonStyle +{ + _BUTTON_STYLE_NORMAL, + _BUTTON_STYLE_SEGMENT +}; + +class _OSP_EXPORT_ _Button + : public Tizen::Ui::_Control + , public _IPropertyChangeEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer +{ + DECLARE_CLASS_BEGIN(_Button, _Control); + DECLARE_PROPERTY("normalColor", GetPropertyNormalColor, SetPropertyNormalColor); + DECLARE_PROPERTY("disabledColor", GetPropertyDisabledColor, SetPropertyDisabledColor); + DECLARE_PROPERTY("pressedColor", GetPropertyPressedColor, SetPropertyPressedColor); + DECLARE_PROPERTY("highlightedColor", GetPropertyHighlightedColor, SetPropertyHighlightedColor); + DECLARE_PROPERTY("selectedColor", GetPropertySelectedColor, SetPropertySelectedColor); + DECLARE_PROPERTY("normalTextColor", GetPropertyNormalTextColor, SetPropertyNormalTextColor); + DECLARE_PROPERTY("disabledTextColor", GetPropertyDisabledTextColor, SetPropertyDisabledTextColor); + DECLARE_PROPERTY("pressedTextColor", GetPropertyPressedTextColor, SetPropertyPressedTextColor); + DECLARE_PROPERTY("highlightedTextColor", GetPropertyHighlightedTextColor, SetPropertyHighlightedTextColor); + DECLARE_PROPERTY("selectedTextColor", GetPropertySelectedTextColor, SetPropertySelectedTextColor); + DECLARE_PROPERTY("text", GetPropertyText, SetPropertyText); + DECLARE_PROPERTY("textSize", GetPropertyTextSize, SetPropertyTextSize); + DECLARE_PROPERTY("actionId", GetPropertyActionId, SetPropertyActionId); + DECLARE_CLASS_END(); + + result SetPropertyNormalColor(const Variant& color); + Variant GetPropertyNormalColor(void) const; + result SetPropertyDisabledColor(const Variant& color); + Variant GetPropertyDisabledColor(void) const; + result SetPropertyPressedColor(const Variant& color); + Variant GetPropertyPressedColor(void) const; + result SetPropertyHighlightedColor(const Variant& color); + Variant GetPropertyHighlightedColor(void) const; + result SetPropertySelectedColor(const Variant& color); + Variant GetPropertySelectedColor(void) const; + + result SetPropertyNormalTextColor(const Variant& color); + Variant GetPropertyNormalTextColor(void) const; + result SetPropertyDisabledTextColor(const Variant& color); + Variant GetPropertyDisabledTextColor(void) const; + result SetPropertyPressedTextColor(const Variant& color); + Variant GetPropertyPressedTextColor(void) const; + result SetPropertyHighlightedTextColor(const Variant& color); + Variant GetPropertyHighlightedTextColor(void) const; + result SetPropertySelectedTextColor(const Variant& color); + Variant GetPropertySelectedTextColor(void) const; + + result SetPropertyText(const Variant& text); + Variant GetPropertyText(void) const; + + result SetPropertyTextSize(const Variant& textSize); + Variant GetPropertyTextSize(void) const; + result SetPropertyActionId(const Variant& actionId); + Variant GetPropertyActionId(void) const; + + virtual void OnPropertyChanging(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty); + virtual void OnPropertyChanged(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty); + +public: + virtual ~_Button(void); + +public: + static _Button* CreateButtonN(void); + + virtual void OnDraw(void); + virtual result OnAttachedToMainTree(void); + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const _Control& control); + virtual void OnBoundsChanged(void); + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + virtual Tizen::Graphics::Dimension GetContentSize(void) const; + +public: + result SetText(const Tizen::Base::String& text); + Tizen::Base::String GetText(void) const; + + result SetColor(_ButtonStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetColor(_ButtonStatus status) const; + + result AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); + result RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); + + result SetActionId(int actionId); + int GetActionId(void) const; + + result SetTextHorizontalAlignment(HorizontalAlignment alignment); + HorizontalAlignment GetTextHorizontalAlignment(void) const; + result SetTextVerticalAlignment(VerticalAlignment alignment); + VerticalAlignment GetTextVerticalAlignment(void) const; + + result SetTextColor(_ButtonStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTextColor(_ButtonStatus status) const; + + result SetBitmap(_ButtonStatus status, const Tizen::Graphics::Point& position, const Tizen::Graphics::Bitmap& bitmap); + Tizen::Graphics::Bitmap* GetBitmap(_ButtonStatus status) const; + Tizen::Graphics::Point GetBitmapPosition(_ButtonStatus status) const; + + result SetToolbarItemBackgroundBitmap(_ButtonStatus status, const Tizen::Graphics::Bitmap& bitmap); + Tizen::Graphics::Bitmap* GetToolbarItemBackgroundBitmap(_ButtonStatus status) const; + + result SetToolbarSelectedBitmap(const Tizen::Graphics::Bitmap& bitmap, bool drawInner); + Tizen::Graphics::Bitmap* GetToolbarSelectedBitmap(void) const; + + result SetBackgroundBitmap(_ButtonStatus status, const Tizen::Graphics::Bitmap& bitmap); + Tizen::Graphics::Bitmap* GetBackgroundBitmap(_ButtonStatus status) const; + + result SetBackgroundEffectBitmap(_ButtonStatus status, const Tizen::Graphics::Bitmap& bitmap); + Tizen::Graphics::Bitmap* GetBackgroundEffectBitmap(_ButtonStatus status) const; + + result SetTextSize(int size, unsigned long fontStyle = Tizen::Graphics::FONT_STYLE_PLAIN); + int GetTextSize(void) const; + + result SetButtonStyle(_ButtonStyle buttonStyle); + _ButtonStyle GetButtonStyle(void) const; + + result SetButtonStatus(_ButtonStatus buttonStatus, bool fire = true); + _ButtonStatus GetButtonStatus(void) const; + + result SetTextMaxLine(int textMaxLine); + int GetTextMaxLine(void) const; + + result UnloadBackgroundBitmap(_ButtonStatus status); + result UnloadBackgroundEffectBitmap(_ButtonStatus status); + bool IsUserBackgroundBitmap(_ButtonStatus status) const; + bool IsUserBackgroundEffectBitmap(_ButtonStatus status) const; + + + result FireActionEvent(void); + + result SetUserDefinedTextArea(const Tizen::Graphics::Rectangle& bounds); + Tizen::Graphics::Rectangle GetUserDefinedTextArea(void) const; + + bool UserDefinedText(void) const; + bool IsDrawInner(void) const; + + result SetMargin(int topMargin, int leftMargin); + int GetTopMargin(void) const; + int GetLeftMargin(void) const; + + Tizen::Graphics::Dimension GetContentSizeInternal(void) const; + int GetTextExtentSize(void) const; + +protected: + result SetPresenter(const _ButtonPresenter& buttonPresenter); + +private: + bool IsTouchAreaChanged(bool currentButtonArea); + void InitializeAccessibilityElement(void); + + _Button(void); + _Button(const _Button& rhs); + _Button& operator =(const _Button& rhs); + +private: + enum + { + NUMBER_OF_BUTTON_STATUS = 5 + }; + +private: + _ButtonPresenter* __pButtonPresenter; + _ActionEvent* __pActionEvent; + + int __actionId; + + Tizen::Base::String __text; + + Tizen::Graphics::Color __textColor[NUMBER_OF_BUTTON_STATUS]; + Tizen::Graphics::Color __color[NUMBER_OF_BUTTON_STATUS]; + + Tizen::Graphics::Bitmap* __pBitmap[NUMBER_OF_BUTTON_STATUS]; + Tizen::Graphics::Point __bitmapPosition[NUMBER_OF_BUTTON_STATUS]; + + Tizen::Graphics::Bitmap* __pToolbarItemBackgroundBitmap[NUMBER_OF_BUTTON_STATUS]; + Tizen::Graphics::Bitmap* __pBackgroundBitmap[NUMBER_OF_BUTTON_STATUS]; + Tizen::Graphics::Bitmap* __pBackgroundEffectBitmap[NUMBER_OF_BUTTON_STATUS]; + Tizen::Graphics::Bitmap* __pToolbarSelectedBitmap; + + HorizontalAlignment __horizontalAlignment; + VerticalAlignment __verticalAlignment; + + _ButtonStatus __buttonStatus; + _ButtonStyle __buttonStyle; + + int __textSize; + int __textMaxLine; + + int __parentMoveDistance; + + bool __isUserBackgroundBitmap[NUMBER_OF_BUTTON_STATUS]; + bool __isUserBackgroundEffectBitmap[NUMBER_OF_BUTTON_STATUS]; + + bool __previousTouchArea; + + bool __userDefinedText; + + int __topMargin; + int __leftMargin; + + bool __drawInner; + + Tizen::Graphics::Rectangle __userDefinedTextArea; + + Tizen::Ui::_AccessibilityElement* __pTextElement; +}; // _Button + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_BUTTON_H_ diff --git a/src/ui/inc/FUiCtrl_ButtonImpl.h b/src/ui/inc/FUiCtrl_ButtonImpl.h new file mode 100644 index 0000000..4679ab8 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ButtonImpl.h @@ -0,0 +1,131 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ButtonImpl.h + * @brief This is the header file for the _ButtonImpl class. + * + * This header file contains the declarations of the %_ButtonImpl class. + */ +#ifndef _FUI_CTRL_INTERNAL_BUTTON_IMPL_H_ +#define _FUI_CTRL_INTERNAL_BUTTON_IMPL_H_ + +#include +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_PublicActionEvent.h" + +namespace Tizen { namespace Graphics +{ + class Dimension; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ButtonImpl + : public _ControlImpl + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + class ButtonSizeInfo : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + }; // ButtonSizeInfo + +public: + virtual ~_ButtonImpl(void); + static _ButtonImpl* CreateButtonImplN(Button* pControl, const Tizen::Graphics::Rectangle& bounds); + + virtual const char* GetPublicClassName(void) const; + virtual const Button& GetPublic(void) const; + virtual Button& GetPublic(void); + virtual const _Button& GetCore(void) const; + virtual _Button& GetCore(void); + +public: + result SetText(const Tizen::Base::String& text); + Tizen::Base::String GetText(void) const; + + result SetColor(ButtonStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetColor(ButtonStatus status) const; + + result AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + result RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + result SetActionId(int actionId); + int GetActionId(void) const; + + result SetTextHorizontalAlignment(HorizontalAlignment alignment); + HorizontalAlignment GetTextHorizontalAlignment(void) const; + result SetTextVerticalAlignment(VerticalAlignment alignment); + VerticalAlignment GetTextVerticalAlignment(void) const; + + result SetTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTextColor(void) const; + result SetDisabledTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetDisabledTextColor(void) const; + result SetPressedTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetPressedTextColor(void) const; + result SetHighlightedTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetHighlightedTextColor(void) const; + + result SetNormalBitmap(const Tizen::Graphics::Point& position, const Tizen::Graphics::Bitmap& bitmap); + result SetDisabledBitmap(const Tizen::Graphics::Point& position, const Tizen::Graphics::Bitmap& bitmap); + result SetPressedBitmap(const Tizen::Graphics::Point& position, const Tizen::Graphics::Bitmap& bitmap); + + result SetNormalBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + result SetPressedBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + result SetHighlightedBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + result SetTextSize(int size); + int GetTextSize(void) const; + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + virtual result OnAttachedToMainTree(void); + + virtual bool OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo); + + virtual Tizen::Graphics::Dimension GetContentSize(void) const; + +public: + static const Tizen::Graphics::Color GetColorOnError(void); + + static _ButtonImpl* GetInstance(Button& button); + static const _ButtonImpl* GetInstance(const Button& button); + +protected: + _ButtonStatus ConvertStatus(ButtonStatus status) const; + +private: + _ButtonImpl(Button* pPublic, _Button* pCore); + + _ButtonImpl(const _ButtonImpl& rhs); + _ButtonImpl& operator =(const _ButtonImpl& rhs); + + _PublicActionEvent* __pPublicActionEvent; + +}; // _ButtonImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_BUTTON_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_ButtonItemImpl.h b/src/ui/inc/FUiCtrl_ButtonItemImpl.h new file mode 100644 index 0000000..9d32817 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ButtonItemImpl.h @@ -0,0 +1,89 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ButtonItemImpl.h + * @brief This is the header file for the %_ButtonItemImpl class. + * + * This header file contains the declarations of the %_ButtonItemImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_BUTTON_ITEM_IMPL_H_ +#define _FUI_CTRL_INTERNAL_BUTTON_ITEM_IMPL_H_ + +#include +#include + + +namespace Tizen { namespace Ui { namespace Controls +{ + +static const int BUTTON_ITEM_ACTION_ID_MIN = 0; +static const int BUTTON_ITEM_ACTION_ID_MAX = INT_MAX; +static const int BUTTON_ITEM_MAX_STATE_COUNT = 4; + +class _ButtonItemImpl + : public Tizen::Base::Object +{ +public: + _ButtonItemImpl(ButtonItem* pPublic); + + virtual ~_ButtonItemImpl(void); + + static const _ButtonItemImpl* GetInstance(const ButtonItem& buttonItem); + + static _ButtonItemImpl* GetInstance(ButtonItem& buttonItem); + + result Construct(ButtonItemStyle style, int actionId); + + int GetActionId(void) const; + + const Tizen::Graphics::Bitmap* GetBackgroundBitmap(ButtonItemStatus status) const; + + const Tizen::Graphics::Bitmap* GetIcon(ButtonItemStatus status) const; + + Tizen::Base::String GetText(void) const; + + result SetActionId(int actionId); + + result SetBackgroundBitmap(ButtonItemStatus status, const Tizen::Graphics::Bitmap* pBitmap); + + result SetIcon(ButtonItemStatus status, const Tizen::Graphics::Bitmap* pIcon); + + result SetText(const Tizen::Base::String& text); + + +private: + _ButtonItemImpl(const _ButtonItemImpl& buttonItem); + + _ButtonItemImpl& operator =(const _ButtonItemImpl& buttonItem); + + +private: + int __actionId; + ButtonItemStyle __itemStyle; + Tizen::Base::String __itemText; + const Tizen::Graphics::Bitmap* __pIconBitmap[BUTTON_ITEM_MAX_STATE_COUNT]; + const Tizen::Graphics::Bitmap* __pButtonItemBackgroundBitmap[BUTTON_ITEM_MAX_STATE_COUNT]; + + friend class _FooterImpl; + friend class _HeaderImpl; + +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_BUTTON_ITEM_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_ButtonModel.h b/src/ui/inc/FUiCtrl_ButtonModel.h new file mode 100644 index 0000000..ee57e8c --- /dev/null +++ b/src/ui/inc/FUiCtrl_ButtonModel.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ButtonModel.h + * @brief This is the header file for the _ButtonModel class. + * + * This header file contains the declarations of the %_ButtonModel class. + */ +#ifndef _FUI_CTRL_INTERNAL_BUTTON_MODEL_H_ +#define _FUI_CTRL_INTERNAL_BUTTON_MODEL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _ButtonModel + * @brief + * @since 1.0 + * + * + * + * + */ +class _ButtonModel + : public Tizen::Base::Object +{ +public: + _ButtonModel(void); + + virtual ~_ButtonModel(void); + +public: + virtual result Construct(void); + +private: + _ButtonModel(const _ButtonModel& rhs); + _ButtonModel& operator =(const _ButtonModel& rhs); +}; // _ButtonModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_BUTTON_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_ButtonPresenter.h b/src/ui/inc/FUiCtrl_ButtonPresenter.h new file mode 100644 index 0000000..a60e2ac --- /dev/null +++ b/src/ui/inc/FUiCtrl_ButtonPresenter.h @@ -0,0 +1,108 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ButtonPresenter.h + * @brief This is the header file for the _ButtonPresenter class. + * + * This header file contains the declarations of the %_ButtonPresenter class. + */ +#ifndef _FUI_CTRL_INTERNAL_BUTTON_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_BUTTON_PRESENTER_H_ + +#include +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Button; +class _ButtonModel; + +/** + * @class _ButtonPresenter + * @brief + * @since 1.0 + * + * + * + * + */ +class _ButtonPresenter + : public Tizen::Base::Object +{ +public: + _ButtonPresenter(void); + virtual ~_ButtonPresenter(void); + +public: + virtual result Construct(const _Button& button); + virtual result Install(void); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const _Control& control); + + void Draw(void); + + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + void SetTextSize(int size, unsigned long fontStyle = Tizen::Graphics::FONT_STYLE_PLAIN); + void SetFontInfo(unsigned long style, int size); + + Tizen::Graphics::_Text::TextObject* GetTextObject(void) const; + result InitTextObject(void); + +protected: + result SetModel(const _ButtonModel& buttonModel); + +private: + _ButtonPresenter(const _ButtonPresenter& rhs); + _ButtonPresenter& operator =(const _ButtonPresenter& rhs); + + void DrawBackground(void); + void DrawToolbarItemBackground(void); + void DrawBitmap(void); + void DrawText(void); + void DrawToolbarSelectedBitmap(void); + + bool IsEnabledStateChanged(void); + +private: + _Button* __pButton; + _ButtonModel* __pButtonModel; + bool __needDraw; + bool __previousEnabledState; + bool __touchMoveHandled; + + Tizen::Graphics::Font* __pFont; + Tizen::Graphics::_Text::TextObject* __pTextObject; + + Tizen::Ui::Animations::_VisualElement* __pBase; + unsigned long __fontStyle; + int __fontSize; +}; // _ButtonPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_BUTTON_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_CheckButton.h b/src/ui/inc/FUiCtrl_CheckButton.h new file mode 100644 index 0000000..678d3a2 --- /dev/null +++ b/src/ui/inc/FUiCtrl_CheckButton.h @@ -0,0 +1,326 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_CheckButton.h + * @brief This is the header file for the _CheckButton class. + * + * This header file contains the declarations of the %_CheckButton class. + */ +#ifndef _FUI_CTRL_INTERNAL_CHECK_BUTTON_H_ +#define _FUI_CTRL_INTERNAL_CHECK_BUTTON_H_ + +#include +#include "FUi_Control.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_ActionEvent.h" + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +class _IAccessibilityListener; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class _CheckButtonPresenter; + +/** + * @class _CheckButton + * @brief + * @since 1.0 + * + * + * + * + */ + +class _OSP_EXPORT_ _CheckButton + : public Tizen::Ui::_Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer +{ + DECLARE_CLASS_BEGIN(_CheckButton, _Control); + DECLARE_PROPERTY("normalColor", GetPropertyNormalColor, SetPropertyNormalColor); + DECLARE_PROPERTY("disabledColor", GetPropertyDisabledColor, SetPropertyDisabledColor); + DECLARE_PROPERTY("pressedColor", GetPropertyPressedColor, SetPropertyPressedColor); + DECLARE_PROPERTY("highlightedColor", GetPropertyHighlightedColor, SetPropertyHighlightedColor); + DECLARE_PROPERTY("normalTextColor", GetPropertyNormalTextColor, SetPropertyNormalTextColor); + DECLARE_PROPERTY("disabledTextColor", GetPropertyDisabledTextColor, SetPropertyDisabledTextColor); + DECLARE_PROPERTY("pressedTextColor", GetPropertyPressedTextColor, SetPropertyPressedTextColor); + DECLARE_PROPERTY("highlightedTextColor", GetPropertyHighlightedTextColor, SetPropertyHighlightedTextColor); + DECLARE_PROPERTY("normalTitleTextColor", GetPropertyNormalTitleTextColor, SetPropertyNormalTitleTextColor); + DECLARE_PROPERTY("disabledTitleTextColor", GetPropertyDisabledTitleTextColor, SetPropertyDisabledTitleTextColor); + DECLARE_PROPERTY("pressedTitleTextColor", GetPropertyPressedTitleTextColor, SetPropertyPressedTitleTextColor); + DECLARE_PROPERTY("highlightedTitleTextColor", GetPropertyHighlightedTitleTextColor, SetPropertyHighlightedTitleTextColor); + DECLARE_PROPERTY("checkedActionId", GetPropertyCheckedActionId, SetPropertyCheckedActionId); + DECLARE_PROPERTY("uncheckedActionId", GetPropertyUncheckedActionId, SetPropertyUncheckedActionId); + DECLARE_PROPERTY("selectedActionId", GetPropertySelectedActionId, SetPropertySelectedActionId); + DECLARE_PROPERTY("text", GetPropertyText, SetPropertyText); + DECLARE_PROPERTY("titleText", GetPropertyTitleText, SetPropertyTitleText); + DECLARE_PROPERTY("selected", GetPropertySelected, SetPropertySelected); + DECLARE_CLASS_END(); + + result SetPropertyNormalColor(const Variant& color); + Variant GetPropertyNormalColor(void) const; + result SetPropertyDisabledColor(const Variant& color); + Variant GetPropertyDisabledColor(void) const; + result SetPropertyPressedColor(const Variant& color); + Variant GetPropertyPressedColor(void) const; + result SetPropertyHighlightedColor(const Variant& color); + Variant GetPropertyHighlightedColor(void) const; + + result SetPropertyNormalTextColor(const Variant& color); + Variant GetPropertyNormalTextColor(void) const; + result SetPropertyDisabledTextColor(const Variant& color); + Variant GetPropertyDisabledTextColor(void) const; + result SetPropertyPressedTextColor(const Variant& color); + Variant GetPropertyPressedTextColor(void) const; + result SetPropertyHighlightedTextColor(const Variant& color); + Variant GetPropertyHighlightedTextColor(void) const; + + result SetPropertyNormalTitleTextColor(const Variant& color); + Variant GetPropertyNormalTitleTextColor(void) const; + result SetPropertyDisabledTitleTextColor(const Variant& color); + Variant GetPropertyDisabledTitleTextColor(void) const; + result SetPropertyPressedTitleTextColor(const Variant& color); + Variant GetPropertyPressedTitleTextColor(void) const; + result SetPropertyHighlightedTitleTextColor(const Variant& color); + Variant GetPropertyHighlightedTitleTextColor(void) const; + + result SetPropertyCheckedActionId(const Variant& actionId); + Variant GetPropertyCheckedActionId(void) const; + result SetPropertyUncheckedActionId(const Variant& actionId); + Variant GetPropertyUncheckedActionId(void) const; + result SetPropertySelectedActionId(const Variant& actionId); + Variant GetPropertySelectedActionId(void) const; + + result SetPropertyText(const Variant& text); + Variant GetPropertyText(void) const; + + result SetPropertyTitleText(const Variant& titleText); + Variant GetPropertyTitleText(void) const; + + result SetPropertySelected(const Variant& selected); + Variant GetPropertySelected(void) const; + +public: + virtual ~_CheckButton(void); + +public: + static _CheckButton* CreateCheckButtonN(void); + + virtual void OnDraw(void); + virtual result OnAttachedToMainTree(void); + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const _Control& control); + virtual void OnBoundsChanged(void); + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + +public: + result LoadDefaultBackgroundBitmap(void); + + result SetSelected(bool select); + bool IsSelected(void) const; + + result AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); + result RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); + + result SetActionId(int checkedActionId, int uncheckedActionId, int selectedActionId = -1); + int GetCheckedActionId(void) const; + int GetUncheckedActionId(void) const; + int GetSelectedActionId(void) const; + + result SetText(const Tizen::Base::String& text); + Tizen::Base::String GetText(void) const; + result SetTitleText(const Tizen::Base::String& title); + Tizen::Base::String GetTitleText(void) const; + + result SetTextHorizontalAlignment(HorizontalAlignment alignment); + HorizontalAlignment GetTextHorizontalAlignment(void) const; + result SetTextVerticalAlignment(VerticalAlignment alignment); + VerticalAlignment GetTextVerticalAlignment(void) const; + + result SetTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTextColor(void) const; + result SetDisabledTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetDisabledTextColor(void) const; + result SetPressedTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetPressedTextColor(void) const; + result SetHighlightedTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetHighlightedTextColor(void) const; + + result SetTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTitleTextColor(void) const; + result SetDisabledTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetDisabledTitleTextColor(void) const; + result SetPressedTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetPressedTitleTextColor(void) const; + result SetHighlightedTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetHighlightedTitleTextColor(void) const; + + result SetColor(CheckButtonStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetColor(CheckButtonStatus status) const; + + int GetTextSize(void) const; + int GetTitleTextSize(void) const; + + result SetCheckButtonStyle(const CheckButtonStyle& checkButtonStyle); + result SetBackgroundStyle(const BackgroundStyle& backgroundStyle); + result SetShowTitle(bool showTitle); + result SetGroupStyle(const GroupStyle& groupStyle); + result SetCheckButtonStatus(CheckButtonStatus checkButtonStatus); + + CheckButtonStyle GetCheckButtonStyle(void) const; + BackgroundStyle GetBackgroundStyle(void) const; + bool GetShowTitle(void) const; + GroupStyle GetGroupStyle(void) const; + CheckButtonStatus GetCheckButtonStatus(void) const; + + Tizen::Graphics::Bitmap* GetMarkBgNormalBitmap(void) const; + Tizen::Graphics::Bitmap* GetMarkBgPressedBitmap(void) const; + Tizen::Graphics::Bitmap* GetMarkBitmap(void) const; + + Tizen::Graphics::Bitmap* GetOnOffBgNormalBitmap(void) const; + Tizen::Graphics::Bitmap* GetOnOffBgPressedBitmap(void) const; + Tizen::Graphics::Bitmap* GetOnOffBitmap(void) const; + + Tizen::Graphics::Bitmap* GetOnOffSlidingOnBitmap(void) const; + Tizen::Graphics::Bitmap* GetOnOffSlidingOffBitmap(void) const; + Tizen::Graphics::Bitmap* GetDimOnOffSlidingOnBitmap(void) const; + Tizen::Graphics::Bitmap* GetDimOnOffSlidingOffBitmap(void) const; + + Tizen::Graphics::Bitmap* GetCircleBitmap(void) const; + Tizen::Graphics::Bitmap* GetCircleNormalEffectBitmap(void) const; + Tizen::Graphics::Bitmap* GetCirclePressedEffectBitmap(void) const; + Tizen::Graphics::Bitmap* GetDetailedBitmap(void) const; + + Tizen::Graphics::Bitmap* GetBackgroundBitmap(GroupStyle groupStyle) const; + Tizen::Graphics::Bitmap* GetBackgroundNormalEffectBitmap(GroupStyle groupStyle) const; + Tizen::Graphics::Bitmap* GetBackgroundPressedEffectBitmap(GroupStyle groupStyle) const; + + result AddRadioGroup(const _Control& radioGroup); + result RemoveRadioGroup(void); + + result FireActionEvent(void); + _Control* GetRadioGroup(void); + void SendTouchReleasedEvent(const _Control& control); + +protected: + result SetPresenter(const _CheckButtonPresenter& checkButtonPresenter); + +private: + bool IsTouchAreaChanged(bool currentButtonArea); + void UpdateAccessibilityElement(void); + void UpdateAccessibilityCheckStatus(void); + + _CheckButton(void); + _CheckButton(const _CheckButton& rhs); + _CheckButton& operator =(const _CheckButton& rhs); + +public: + CheckButtonStyle __checkButtonStyle; + BackgroundStyle __backgroundStyle; + bool __showTitle; + GroupStyle __groupStyle; + CheckButtonStatus __checkButtonStatus; + +private: + _CheckButtonPresenter* __pCheckButtonPresenter; + _ActionEvent* __pActionEvent; + + bool __selected; + + int __checkedActionId; + int __uncheckedActionId; + int __selectedActionId; + + Tizen::Base::String __text; + Tizen::Base::String __titleText; + + Tizen::Graphics::Color __normalTextColor; + Tizen::Graphics::Color __disabledTextColor; + Tizen::Graphics::Color __pressedTextColor; + Tizen::Graphics::Color __highlightedTextColor; + + Tizen::Graphics::Color __normalTitleTextColor; + Tizen::Graphics::Color __disabledTitleTextColor; + Tizen::Graphics::Color __pressedTitleTextColor; + Tizen::Graphics::Color __highlightedTitleTextColor; + + Tizen::Graphics::Color __normalColor; + Tizen::Graphics::Color __disabledColor; + Tizen::Graphics::Color __pressedColor; + Tizen::Graphics::Color __highlightedColor; + + Tizen::Graphics::Bitmap* __pMarkBgNormalBitmap; + Tizen::Graphics::Bitmap* __pMarkBgPressedBitmap; + Tizen::Graphics::Bitmap* __pMarkBitmap; + + Tizen::Graphics::Bitmap* __pOnOffBgNormalBitmap; + Tizen::Graphics::Bitmap* __pOnOffBgPressedBitmap; + Tizen::Graphics::Bitmap* __pOnOffBitmap; + + Tizen::Graphics::Bitmap* __pOnOffSlidingOnBitmap; + Tizen::Graphics::Bitmap* __pOnOffSlidingOffBitmap; + Tizen::Graphics::Bitmap* __pDimOnOffSlidingOnBitmap; + Tizen::Graphics::Bitmap* __pDimOnOffSlidingOffBitmap; + + Tizen::Graphics::Bitmap* __pCircleBitmap; + Tizen::Graphics::Bitmap* __pCircleNormalEffectBitmap; + Tizen::Graphics::Bitmap* __pCirclePressedEffectBitmap; + Tizen::Graphics::Bitmap* __pDetailedBitmap; + + Tizen::Graphics::Bitmap* __pBackgroundBitmap; + Tizen::Graphics::Bitmap* __pBackgroundNormalEffectBitmap; + Tizen::Graphics::Bitmap* __pBackgroundPressedEffectBitmap; + + Tizen::Graphics::Bitmap* __pBackgroundTopBitmap; + Tizen::Graphics::Bitmap* __pBackgroundTopNormalEffectBitmap; + Tizen::Graphics::Bitmap* __pBackgroundTopPressedEffectBitmap; + + Tizen::Graphics::Bitmap* __pBackgroundMiddleBitmap; + Tizen::Graphics::Bitmap* __pBackgroundMiddleNormalEffectBitmap; + Tizen::Graphics::Bitmap* __pBackgroundMiddlePressedEffectBitmap; + + Tizen::Graphics::Bitmap* __pBackgroundBottomBitmap; + Tizen::Graphics::Bitmap* __pBackgroundBottomNormalEffectBitmap; + Tizen::Graphics::Bitmap* __pBackgroundBottomPressedEffectBitmap; + + HorizontalAlignment __horizontalAlignment; + VerticalAlignment __verticalAlignment; + + int __textSize; + int __titleTextSize; + + int __parentMoveDistance; + bool __previousTouchArea; + + _Control* __pRadioGroup; + + Tizen::Ui::_AccessibilityElement* __pButtonElement; + Tizen::Ui::_AccessibilityElement* __pDetailButtonElement; + Tizen::Ui::_IAccessibilityListener* __pAccessibilityListener; +}; // _CheckButton + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_CHECK_BUTTON_H_ diff --git a/src/ui/inc/FUiCtrl_CheckButtonImpl.h b/src/ui/inc/FUiCtrl_CheckButtonImpl.h new file mode 100644 index 0000000..f550055 --- /dev/null +++ b/src/ui/inc/FUiCtrl_CheckButtonImpl.h @@ -0,0 +1,129 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_CheckButtonImpl.h + * @brief This is the header file for the _CheckButtonImpl class. + * + * This header file contains the declarations of the %_CheckButtonImpl class. + */ +#ifndef _FUI_CTRL_INTERNAL_CHECK_BUTTON_IMPL_H_ +#define _FUI_CTRL_INTERNAL_CHECK_BUTTON_IMPL_H_ + +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_CheckButton.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_PublicActionEvent.h" + +namespace Tizen { namespace Graphics +{ + class Dimension; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _CheckButtonImpl + : public _ControlImpl + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + class CheckButtonSizeInfo : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + }; // CheckButtonSizeInfo + +public: + virtual ~_CheckButtonImpl(void); + static _CheckButtonImpl* CreateCheckButtonImplN(CheckButton* pControl, const Tizen::Graphics::Rectangle& bounds); + + virtual const char* GetPublicClassName(void) const; + virtual const CheckButton& GetPublic(void) const; + virtual CheckButton& GetPublic(void); + virtual const _CheckButton& GetCore(void) const; + virtual _CheckButton& GetCore(void); + +public: + result SetSelected(bool select); + bool IsSelected(void) const; + + result AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + result RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + result SetActionId(int checkedActionId, int uncheckedActionId, int selectedActionId = -1); + int GetCheckedActionId(void) const; + int GetUncheckedActionId(void) const; + int GetSelectedActionId(void) const; + + result SetText(const Tizen::Base::String& text); + Tizen::Base::String GetText(void) const; + result SetTitleText(const Tizen::Base::String& title); + Tizen::Base::String GetTitleText(void) const; + + result SetTextHorizontalAlignment(HorizontalAlignment alignment); + HorizontalAlignment GetTextHorizontalAlignment(void) const; + result SetTextVerticalAlignment(VerticalAlignment alignment); + VerticalAlignment GetTextVerticalAlignment(void) const; + + result SetTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTextColor(void) const; + result SetDisabledTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetDisabledTextColor(void) const; + result SetPressedTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetPressedTextColor(void) const; + result SetHighlightedTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetHighlightedTextColor(void) const; + + result SetTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTitleTextColor(void) const; + result SetDisabledTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetDisabledTitleTextColor(void) const; + result SetPressedTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetPressedTitleTextColor(void) const; + result SetHighlightedTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetHighlightedTitleTextColor(void) const; + + result SetColor(CheckButtonStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetColor(CheckButtonStatus status) const; + + result SetCheckButtonStyle(const CheckButtonStyle& checkButtonStyle); + result SetBackgroundStyle(const BackgroundStyle& backgroundStyle); + result SetShowTitle(bool showTitle); + result SetGroupStyle(const GroupStyle& groupStyle); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + virtual bool IsLayoutable(void) const; + +public: + static Tizen::Graphics::Color GetColorOnError(void); + + static _CheckButtonImpl* GetInstance(CheckButton& checkButton); + static const _CheckButtonImpl* GetInstance(const CheckButton& checkButton); + +private: + _CheckButtonImpl(CheckButton* pPublic, _CheckButton* pCore); + + _CheckButtonImpl(const _CheckButtonImpl& rhs); + _CheckButtonImpl& operator =(const _CheckButtonImpl& rhs); + + _PublicActionEvent* __pPublicActionEvent; +}; // _CheckButtonImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_CHECK_BUTTON_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_CheckButtonModel.h b/src/ui/inc/FUiCtrl_CheckButtonModel.h new file mode 100644 index 0000000..99c3f71 --- /dev/null +++ b/src/ui/inc/FUiCtrl_CheckButtonModel.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_CheckButtonModel.h + * @brief This is the header file for the _CheckButtonModel class. + * + * This header file contains the declarations of the %_CheckButtonModel class. + */ +#ifndef _FUI_CTRL_INTERNAL_CHECK_BUTTON_MODEL_H_ +#define _FUI_CTRL_INTERNAL_CHECK_BUTTON_MODEL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _CheckButtonModel + * @brief + * @since 1.0 + * + * + * + * + */ +class _CheckButtonModel + : public Tizen::Base::Object +{ +public: + _CheckButtonModel(void); + + virtual ~_CheckButtonModel(void); + +public: + virtual result Construct(void); + +private: + _CheckButtonModel(const _CheckButtonModel& rhs); + _CheckButtonModel& operator =(const _CheckButtonModel& rhs); +}; // _CheckButtonModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_CHECK_BUTTON_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_CheckButtonPresenter.h b/src/ui/inc/FUiCtrl_CheckButtonPresenter.h new file mode 100644 index 0000000..d2249c8 --- /dev/null +++ b/src/ui/inc/FUiCtrl_CheckButtonPresenter.h @@ -0,0 +1,131 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_CheckButtonPresenter.h + * @brief This is the header file for the _CheckButtonPresenter class. + * + * This header file contains the declarations of the %_CheckButtonPresenter class. + */ +#ifndef _FUI_CTRL_INTERNAL_CHECK_BUTTON_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_CHECK_BUTTON_PRESENTER_H_ + +#include +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Ui { namespace Controls +{ +class _CheckButton; +class _CheckButtonModel; + +/** + * @class _CHeckButtonPresenter + * @brief + * @since 1.0 + * + * + * + * + */ +class _CheckButtonPresenter + : public Tizen::Base::Object + , public Tizen::Base::Runtime::ITimerEventListener +{ +public: + _CheckButtonPresenter(void); + virtual ~_CheckButtonPresenter(void); + +public: + virtual result Construct(const _CheckButton& checkButton); + virtual result Install(void); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const _Control& control); + + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + void Draw(void); + + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + void SetFontInfo(unsigned long style, int size); + + Tizen::Graphics::Rectangle GetTitleTextBounds(void) const; + Tizen::Graphics::Rectangle GetTextBounds(void) const; + Tizen::Graphics::Rectangle GetDefaultButtonBounds(void) const; + Tizen::Graphics::Rectangle GetOnOffSlidingButtonBounds(void) const; + Tizen::Graphics::Rectangle GetDetailedButtonBounds(void) const; + + result StartCheckAnimationTimer(void); + result ResetCheckAnimationTimer(void); + +protected: + result SetModel(const _CheckButtonModel& checkButtonModel); + +private: + _CheckButtonPresenter(const _CheckButtonPresenter& rhs); + _CheckButtonPresenter& operator =(const _CheckButtonPresenter& rhs); + + void DrawBackground(void); + void DrawCheckBitmap(void); + void DrawText(void); + + bool IsEnabledStateChanged(void); + result CalculateTitleTextBounds(void); + result CalculateTextBounds(void); + result CalculateButtonBounds(void); + + void DrawMarkAnimation(void); + +private: + _CheckButton* __pCheckButton; + _CheckButtonModel* __pCheckButtonModel; + bool __previousEnabledState; + bool __touchMoveHandled; + + Tizen::Graphics::Font* __pTextFont; + Tizen::Graphics::Font* __pTitleTextFont; + Tizen::Graphics::_Text::TextObject* __pTextObject; + Tizen::Graphics::_Text::TextObject* __pTitleTextObject; + + Tizen::Graphics::Rectangle __titleTextBounds; + Tizen::Graphics::Rectangle __textBounds; + Tizen::Graphics::Rectangle __defaultButtonBounds; + Tizen::Graphics::Rectangle __onOffSlidingButtonBounds; + Tizen::Graphics::Rectangle __detailedButtonBounds; + + unsigned long __fontStyle; + int __fontSize; + + static const int CHECK_ACTION_TIMER_PERIOD = 10; + static const int RATIO_MAX = 10; + Tizen::Base::Runtime::Timer* __pCheckAnimationTimer; + int __ratio; + +}; // _CheckButtonPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_CHECK_BUTTON_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_ColorChangeEvent.h b/src/ui/inc/FUiCtrl_ColorChangeEvent.h new file mode 100644 index 0000000..3280a58 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ColorChangeEvent.h @@ -0,0 +1,102 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ColorChangeEvent.h + * @brief This is the header file for _ColorChangeEvent class. + * + * This header file contains declaration of _ColorChangeEvent class. + * The ColorChangeEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_INTERNAL_COLOR_CHANGE_EVENT_H_ +#define _FUI_CTRL_INTERNAL_COLOR_CHANGE_EVENT_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** +* @class _ColorChangeEvent +* @brief This class handles a action event. It is inherited from Event class. +* +* The Window(root of all widgets) class has an instance of the ColorChangeEvent class as a member variable. +* Applications can register action event listeners through it. When a action event occurred, +* the ColorChangeEvent class finds listener and calls the appropriate listener's method. +* +*/ +class _ColorChangeEvent + : public Tizen::Base::Runtime::_Event +{ +public: + // + // This is the default class destructor. + // + virtual ~_ColorChangeEvent(void); + + // + // This method initializes this instance. This method should be called + // after this instance is constructed. + // + // @return The method returns error code. + // @param[in] source A pointer to the Object instance which contains this instance. + // @exception E_SUCCESS - This method is successful. + // @exception E_OUT_OF_MEMORY - The memory is insufficient. + // + static _ColorChangeEvent* CreateInstanceN(const Tizen::Ui::_Control& source); + + // + // This method returns the owner of this event. + // + // @return See the comment above. + // + const Tizen::Ui::_Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateColorChangeEventArgN(const Tizen::Graphics::Color& color); + +protected: + + // + // This method checks the arg and finds out the type of event. After that this method calls appropriate + // listener's method. + // + // @param[in] pListener It is a event listener related to this ColorChange event. + // @param[in] arg It is an argument-like instance of ColorChange event retransmitted to the listener's method + // as an argument. + // + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + _ColorChangeEvent(const Tizen::Ui::_Control& source); + + _ColorChangeEvent(const _ColorChangeEvent&); + + _ColorChangeEvent& operator=(const _ColorChangeEvent&); + +private: + const Tizen::Ui::_Control* __pSource; +}; // _ColorChangeEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_COLOR_CHANGE_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_ColorPicker.h b/src/ui/inc/FUiCtrl_ColorPicker.h new file mode 100644 index 0000000..db52e7c --- /dev/null +++ b/src/ui/inc/FUiCtrl_ColorPicker.h @@ -0,0 +1,181 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_ColorPicker.h +* @brief This is the header file for the _ColorPicker class. +* +* This header file contains the declarations of the _ColorPicker class. +*/ +#ifndef _FUI_CTRL_INTERNAL_COLORPICKER_H_ +#define _FUI_CTRL_INTERNAL_COLORPICKER_H_ + +#include "FUi_Control.h" +#include "FUiCtrl_ColorChangeEvent.h" +#include "FUi_IAccessibilityListener.h" + +namespace Tizen { namespace Ui { +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IColorChangeEventListener; +class _ColorPickerPresenter; + +class _OSP_EXPORT_ _ColorPicker + : public Tizen::Ui::_Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer + , public _IAccessibilityListener +{ + DECLARE_CLASS_BEGIN(_ColorPicker, Tizen::Ui::_Control); + DECLARE_PROPERTY("color", GetPropertyColor, SetPropertyColor); + DECLARE_PROPERTY("hue", GetPropertyHue, SetPropertyHue); + DECLARE_PROPERTY("saturation", GetPropertySaturation, SetPropertySaturation); + DECLARE_PROPERTY("luminance", GetPropertyLuminance, SetPropertyLuminance); + DECLARE_CLASS_END(); + +// Properties + result SetPropertyColor(const Tizen::Ui::Variant& color); + + result SetPropertyHue(const Tizen::Ui::Variant& hue); + + result SetPropertySaturation(const Tizen::Ui::Variant& saturation); + + result SetPropertyLuminance(const Tizen::Ui::Variant& luminance); + + Variant GetPropertyColor(void) const; + + Variant GetPropertyHue(void) const; + + Variant GetPropertySaturation(void) const; + + Variant GetPropertyLuminance(void) const; + +public: + Tizen::Graphics::Color GetColor(void) const; + + int GetHue(void) const; + + int GetSaturation(void) const; + + int GetLuminance(void) const; + + result SetColor(const Tizen::Graphics::Color& color); + + result SetHue(int hue); + + result SetSaturation(int saturation); + + result SetLuminance(int luminance); + + result AddColorChangeEventListener(const _IColorChangeEventListener& listener); + + result RemoveColorChangeEventListener(const _IColorChangeEventListener& listener); + + result FireColorChangeEvent(const Tizen::Graphics::Color& color); + + Tizen::Ui::Animations::_VisualElement* GetHueHandler(void); + + Tizen::Ui::Animations::_VisualElement* GetSaturationHandler(void); + + Tizen::Ui::Animations::_VisualElement* GetLuminanceHandler(void); + + Tizen::Ui::_AccessibilityElement* GetAccessibilityElement(int elementId); + + result UpdateView(void); + + virtual ~_ColorPicker(void); + + virtual result OnAttachedToMainTree(void); + + void InitializeAccessibilityElement(void); + + virtual void OnBoundsChanged(void); + + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + + virtual void OnDraw(void); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + static _ColorPicker* CreateColorPickerN(void); + + // accessibility listener + virtual bool OnAccessibilityFocusMovedNext(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusMovedPrevious(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityReadElement(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusIn(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusOut(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityActionPerformed(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&); + virtual bool OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&); + +private: + _ColorPicker(void); + + _ColorPicker(const _ColorPicker&); + + _ColorPicker& operator =(const _ColorPicker&); + +private: + + _ColorPickerPresenter* __pColorPickerPresenter; + + _ColorChangeEvent* __pColorChangeEvent; + + Tizen::Ui::Animations::_VisualElement* __pHueHandler; + + Tizen::Ui::Animations::_VisualElement* __pSaturationHandler; + + Tizen::Ui::Animations::_VisualElement* __pLuminanceHandler; + + Tizen::Ui::_AccessibilityElement* __pDecreaseHueButtonElement; + + Tizen::Ui::_AccessibilityElement* __pIncreaseHueButtonElement; + + Tizen::Ui::_AccessibilityElement* __pDecreaseSaturationButtonElement; + + Tizen::Ui::_AccessibilityElement* __pIncreaseSaturationButtonElement; + + Tizen::Ui::_AccessibilityElement* __pDecreaseLuminanceButtonElement; + + Tizen::Ui::_AccessibilityElement* __pIncreaseLuminanceButtonElement; + + Tizen::Ui::_AccessibilityElement* __pHueBarElement; + + Tizen::Ui::_AccessibilityElement* __pSaturationBarElement; + + Tizen::Ui::_AccessibilityElement* __pLuminanceBarElement; +}; // _ColorPicker + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_COLORPICKER_H_ diff --git a/src/ui/inc/FUiCtrl_ColorPickerImpl.h b/src/ui/inc/FUiCtrl_ColorPickerImpl.h new file mode 100644 index 0000000..75d5daf --- /dev/null +++ b/src/ui/inc/FUiCtrl_ColorPickerImpl.h @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_ColorPickerImpl.h +* @brief This is the header file for the _ColorPickerImpl class. +* +* This header file contains the declarations of the _ColorPickerImpl class. +*/ +#ifndef _FUI_CTRL_INTERNAL_COLOR_PICKER_IMPL_H_ +#define _FUI_CTRL_INTERNAL_COLOR_PICKER_IMPL_H_ + +#include +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_ColorPicker.h" +#include "FUiCtrl_IColorChangeEventListener.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +class _PublicColorChangeEvent; + +class _ColorPickerImpl + : public Tizen::Ui::_ControlImpl + , public _IColorChangeEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + class ColorPickerSizeInfo : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMaximumSize(_ControlOrientation orientation) const; + + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + }; + +public: + const Tizen::Graphics::Color GetColor(void) const; + + const int GetHue(void) const; + + const int GetSaturation(void) const; + + const int GetLuminance(void) const; + + result SetColor(const Tizen::Graphics::Color& color); + + result SetHue(int hue); + + result SetSaturation(int saturation); + + result SetLuminance(int luminance); + + result AddColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener); + + result RemoveColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener); + + virtual void OnColorChanged(const Tizen::Ui::_Control& source, const Tizen::Graphics::Color& color); + + virtual const char* GetPublicClassName(void) const; + + virtual ColorPicker& GetPublic(void); + + virtual const ColorPicker& GetPublic(void) const; + + virtual const _ColorPicker& GetCore(void) const; + + virtual _ColorPicker& GetCore(void); + + virtual ~_ColorPickerImpl(void); + + static _ColorPickerImpl* CreateColorPickerImplN(ColorPicker& control); + + static _ColorPickerImpl* GetInstance(ColorPicker& colorPicker); + + static const _ColorPickerImpl* GetInstance(const ColorPicker& colorPicker); + +private: + _ColorPickerImpl(ColorPicker& pPublic, _ColorPicker& pCore); + + _ColorPickerImpl(const _ColorPickerImpl&); + + _ColorPickerImpl& operator =(const _ColorPickerImpl&); + +private: + _PublicColorChangeEvent* __pPublicColorChangeEvent; +}; // _ColorPickerImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_COLOR_PICKER_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_ColorPickerModel.h b/src/ui/inc/FUiCtrl_ColorPickerModel.h new file mode 100644 index 0000000..deae6b9 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ColorPickerModel.h @@ -0,0 +1,86 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_ColorPickerModel.h +* @brief This is the header file for the _ColorPickerModel class. +* +* This header file contains the declarations of the _ColorPickerModel class. +*/ + +#ifndef _FUI_CTRL_INTERNAL_COLORPICKER_MODEL_H_ +#define _FUI_CTRL_INTERNAL_COLORPICKER_MODEL_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ColorPickerModel + : public Tizen::Base::Object +{ +public: + double GetHue(void) const; + + double GetSaturation(void) const; + + double GetLuminance(void) const; + + void SetHue(double hueValue); + + void SetSaturation(double saturationValue); + + void SetLuminance(double luminanceValue); + + Tizen::Graphics::Color GetHueColor(void) const; + + Tizen::Graphics::Color GetSaturationColor(void) const; + + Tizen::Graphics::Color GetColor(void) const; + + void SetColor(const Tizen::Graphics::Color& color); + + virtual ~_ColorPickerModel(void); + + static _ColorPickerModel* CreateInstanceN(void); + +private: + _ColorPickerModel(void); + + _ColorPickerModel(const _ColorPickerModel&); + + _ColorPickerModel& operator =(const _ColorPickerModel&); + + void CalulateColor(void); + + static void ConvertHSLToRGB(double h, double s, double l, Tizen::Graphics::Color& color); + + static void ConvertRGBToHSL(const Tizen::Graphics::Color& color, double& h, double& s, double& l); + +private: + double __hue; + + double __sat; + + double __lum; + + Tizen::Graphics::Color __color; +}; // _ColorPickerModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_COLORPICKER_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_ColorPickerPresenter.h b/src/ui/inc/FUiCtrl_ColorPickerPresenter.h new file mode 100644 index 0000000..a7a4b4f --- /dev/null +++ b/src/ui/inc/FUiCtrl_ColorPickerPresenter.h @@ -0,0 +1,210 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ColorPickerPresenter.h + * @brief This is the header file for the _ColorPicker class. + * + * This header file contains the declarations of the %_ColorPicker class. + */ + +#ifndef _FUI_CTRL_INTERNAL_COLORPICKER_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_COLORPICKER_PRESENTER_H_ + +#include +#include "FUiCtrl_ColorPicker.h" + +namespace Tizen { namespace Graphics +{ +class Point; +class Rectangle; +class Canvas; +class Color; +}} //Tizen::Graphics + +namespace Tizen {namespace Ui +{ +class _TouchInfo; +}} //Tizen::Ui + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen {namespace Ui { namespace Controls +{ + +enum _ColorPickerComponentType +{ + HSL_NOT = -1, + HUE_HANDLER = 0, + SAT_HANDLER, + LUM_HANDLER, + HUE_BAR, + SAT_BAR, + LUM_BAR, + HUE_ARROWLEFT, + HUE_ARROWRIGHT, + SAT_ARROWLEFT, + SAT_ARROWRIGHT, + LUM_ARROWLEFT, + LUM_ARROWRIGHT, + COMPONENT_TYPE_MAX +}; + +class _ColorPickerModel; + +class _ColorPickerPresenter + : public Tizen::Base::Object + , public Tizen::Base::Runtime::ITimerEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + result Draw(void); + + Tizen::Graphics::Color GetColor(void) const; + + int GetHue(void) const; + + int GetSaturation(void) const; + + int GetLuminance(void) const; + + void SetColor(const Tizen::Graphics::Color& color); + + result SetHue(int hue); + + result SetSaturation(int saturation); + + result SetLuminance(int luminance); + + void LoadDrawingProperties(const Tizen::Graphics::Rectangle& controlBounds); + + void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + + bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + virtual ~_ColorPickerPresenter(void); + + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + static _ColorPickerPresenter* CreateInstanceN(_ColorPicker& colorPicker); + + Tizen::Ui::Animations::_VisualElement* CreateHandlerN(Tizen::Ui::Animations::_VisualElement& rootElement, _ColorPickerComponentType handlerType); + +private: + + result LoadResource(void); + + result DrawHueSlider(Tizen::Graphics::Canvas& canvas); + + result DrawLuminanceSlider(Tizen::Graphics::Canvas& canvas); + + result DrawSaturationSlider(Tizen::Graphics::Canvas& canvas); + + result DrawLine(Tizen::Graphics::Canvas& canvas); + + result DrawArrowButton(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& rcButton, bool isSelected, bool drawLeftButton); + + result DrawArrowButtons(Tizen::Graphics::Canvas& canvas); + + result MoveHandler(_ColorPickerComponentType handlerType); + + result TouchButton(void); + + result TouchHandler(int x); + + result SetHandlerPosition(_ColorPickerComponentType handlerType, int position); + + result SetHandlerPositionByRatio(_ColorPickerComponentType handlerType, double ratio); + + result ChangeColorFromCurrentHandlerPosition(_ColorPickerComponentType handlerType); + + bool IsLeftButton(_ColorPickerComponentType buttonType); + + Tizen::Graphics::Rectangle& GetBarBoundsFromHandler(_ColorPickerComponentType handlerType); + + _ColorPickerComponentType GetTouchActionType(const Tizen::Graphics::Point& position) const; + + result DrawResourceBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, Tizen::Graphics::Bitmap* pBitmap); + + _ColorPickerPresenter(_ColorPicker& colorPicker); + + _ColorPickerPresenter(const _ColorPickerPresenter&); + + _ColorPickerPresenter& operator =(const _ColorPickerPresenter&); + +private: + + static const double _MAX_COLOR_VALUE = 255.0; + static const double _MIN_COLOR_VALUE = 0.0; + static const double _HUE_SPACE_RANGE = 6.0; + static const byte _ZERO_SATURATION_RGB_VALUE = 127; + + _ColorPicker* __pColorPicker; + + _ColorPickerModel* __pColorPickerModel; + + _ColorPickerComponentType __eventType; + + int __topMargin; + + int __blockMargin; + + int __blockHeight; + int __dividerMargin; + int __dividerWidth; + + Tizen::Graphics::Rectangle __componentBounds[COMPONENT_TYPE_MAX]; + + Tizen::Graphics::Color __hueColor; + + Tizen::Graphics::Color __saturationColor; + + Tizen::Base::Runtime::Timer* __pSlideTimer; + Tizen::Graphics::Bitmap* __pHueSliderBgBitmap; + Tizen::Graphics::Bitmap* __pCustomBitmap; + Tizen::Graphics::Bitmap* __pLuminanceSliderBgBitmap; + Tizen::Graphics::Bitmap* __pSaturationSliderBgBitmap; + Tizen::Graphics::Bitmap* __pColorNormalReplacementBgBitmap; + Tizen::Graphics::Bitmap* __pColorPressedReplacementBgBitmap; + Tizen::Graphics::Bitmap* __pColorDisabledReplacementBgBitmap; + Tizen::Graphics::Bitmap* __pColorNormalEffectReplacementBgBitmap; + Tizen::Graphics::Bitmap* __pColorPressedEffectReplacementBgBitmap; + Tizen::Graphics::Bitmap* __pColorDisabledEffectReplacementBgBitmap; + Tizen::Graphics::Bitmap* __pLeftArrowNormalBitmap; + Tizen::Graphics::Bitmap* __pLeftArrowPressedBitmap; + Tizen::Graphics::Bitmap* __pLeftArrowDisabledBitmap; + Tizen::Graphics::Bitmap* __pRightArrowNormalBitmap; + Tizen::Graphics::Bitmap* __pRightArrowPressedBitmap; + Tizen::Graphics::Bitmap* __pRightArrowDisabledBitmap; + Tizen::Graphics::Bitmap* __pHandlerBitmap; + Tizen::Graphics::Bitmap* __pLandscapeHueSliderBgBitmap; + Tizen::Graphics::Bitmap* __pLandscapeCustomBitmap; + Tizen::Graphics::Bitmap* __pLandscapeLuminanceSliderBgBitmap; + Tizen::Graphics::Bitmap* __pLandscapeSaturationSliderBgBitmap; +}; // _ColorPickerPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_COLORPICKER_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_ContextMenu.h b/src/ui/inc/FUiCtrl_ContextMenu.h new file mode 100644 index 0000000..a4ce7eb --- /dev/null +++ b/src/ui/inc/FUiCtrl_ContextMenu.h @@ -0,0 +1,267 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ContextMenu.h + * @brief This is the header file for the _ContextMenu class. + * + * This header file contains the declarations of the %_ContextMenu class. + */ +#ifndef _FUI_CTRL_INTERNAL_CONTEXT_MENU_H_ +#define _FUI_CTRL_INTERNAL_CONTEXT_MENU_H_ + +#include +#include +#include "FUi_Window.h" +#include "FUiCtrl_IContextMenuPresenter.h" +#include "FUiCtrl_ContextMenuGridPresenter.h" +#include "FUiCtrl_ContextMenuListPresenter.h" +#include "FUiCtrl_ActionEvent.h" +#include "FUiCtrl_IActionEventListener.h" + +#include "FUiCtrl_ScrollPanel.h" + +namespace Tizen { namespace Ui { +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +const int CONTEXT_MENU_ITEM_STATUS_COUNT = 3; +const int MAX_CONTEXTMENU_LIST_SHOW_ITEM = 4; +const int MAX_CONTEXTMENU_ICON_SHOW_ITEM = 5; + +enum ContextMenuCoreStyle +{ + CONTEXT_MENU_CORE_STYLE_LIST, /**< The style of the vertical list of image + text */ + CONTEXT_MENU_CORE_STYLE_GRID /**< The style of the horizontal list of image + text */ +}; + +enum ContextMenuCoreAlign +{ + CONTEXT_MENU_CORE_ALIGN_LEFT, + CONTEXT_MENU_CORE_ALIGN_RIGHT, + CONTEXT_MENU_CORE_ALIGN_UP, + CONTEXT_MENU_CORE_ALIGN_DOWN, + CONTEXT_MENU_CORE_ALIGN_AUTO +}; + +enum ContextMenuCoreItemStatus +{ + CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL = 0, /**< The normal state */ + CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED, /**< The pressed state */ + CONTEXT_MENU_CORE_ITEM_STATUS_HIGHLIGHTED /**< The highlighted state */ +}; + +// Align Bound Base +enum ContextMenuCoreDropPosition +{ + CONTEXT_MENU_CORE_DROP_POSITION_INVALID = -1, + CONTEXT_MENU_CORE_DROP_POSITION_UP, + CONTEXT_MENU_CORE_DROP_POSITION_DOWN, + CONTEXT_MENU_CORE_DROP_POSITION_LEFT, + CONTEXT_MENU_CORE_DROP_POSITION_RIGHT, + + CONTEXT_MENU_CORE_DROP_POSITION_MAX +}; + +struct _ContextMenuItemInfo; + +/** + * @class _ContextMenu + * @brief + * @since 2.0 + * + * + * + * + */ +class _OSP_EXPORT_ _ContextMenu + : public _Window + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ + DECLARE_CLASS_BEGIN(_ContextMenu, _Control); + DECLARE_PROPERTY("color", GetPropertyColor, SetPropertyColor); + DECLARE_PROPERTY("normalItemColor", GetPropertyNormalItemColor, SetPropertyNormalItemColor); + DECLARE_PROPERTY("pressedItemColor", GetPropertyPressedItemColor, SetPropertyPressedItemColor); + DECLARE_PROPERTY("highlightedItemColor", GetPropertyHighlightedItemColor, SetPropertyHighlightedItemColor); + DECLARE_PROPERTY("normalItemTextColor", GetPropertyNormalItemTextColor, SetPropertyNormalItemTextColor); + DECLARE_PROPERTY("pressedItemTextColor", GetPropertyPressedItemTextColor, SetPropertyPressedItemTextColor); + DECLARE_PROPERTY("highlightedItemTextColor", GetPropertyHighlightedItemTextColor, SetPropertyHighlightedItemTextColor); + DECLARE_PROPERTY("maxVisibleItemsCount", GetPropertyMaxVisibleItemsCount, SetPropertyMaxVisibleItemsCount); + DECLARE_CLASS_END(); + +// Properties + result SetPropertyMaxVisibleItemsCount(const Variant& count); + Variant GetPropertyMaxVisibleItemsCount(void) const; + + result SetPropertyColor(const Variant& color); + Variant GetPropertyColor(void) const; + + result SetPropertyNormalItemColor(const Variant& color); + Variant GetPropertyNormalItemColor(void) const; + + result SetPropertyPressedItemColor(const Variant& color); + Variant GetPropertyPressedItemColor(void) const; + + result SetPropertyHighlightedItemColor(const Variant & color); + Variant GetPropertyHighlightedItemColor(void) const; + + result SetPropertyNormalItemTextColor(const Variant& color); + Variant GetPropertyNormalItemTextColor(void) const; + + result SetPropertyPressedItemTextColor(const Variant& color); + Variant GetPropertyPressedItemTextColor(void) const; + + result SetPropertyHighlightedItemTextColor(const Variant & color); + Variant GetPropertyHighlightedItemTextColor(void) const; + +// Lifecycle +public: + _ContextMenu(const Tizen::Graphics::Point& point, enum ContextMenuCoreStyle style + , enum ContextMenuCoreAlign contextMenuAlign = CONTEXT_MENU_CORE_ALIGN_AUTO); + virtual ~_ContextMenu(void); + static _ContextMenu* CreateContextMenuN(const Tizen::Graphics::Point& point + , enum ContextMenuCoreStyle style, enum ContextMenuCoreAlign contextMenuAlign); + +// Operation +public: + result Install(void); + result Initialize(void); + result AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + result InsertItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap + , const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + result SetItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap + , const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + result RemoveItemAt(int index); + result RemoveAllItems(void); + int GetItemCount(void) const; + result SetShowItemCount(int count); + int GetShowItemCount(void) const; + int GetShowItemMaxCount(void) const; + int GetItemIndexAt(int actionId) const; + int GetItemActionIdAt(int index) const; + result SetAnchorPosition(int x, int y); + Tizen::Graphics::Point GetAnchorPosition(void) const; + result SetBodyRect(const Tizen::Graphics::Rectangle& rect); + Tizen::Graphics::Rectangle GetBodyRect(void) const; + result SetArrowRect(const Tizen::Graphics::Rectangle& rect); + Tizen::Graphics::Rectangle GetArrowRect(void) const; + result SetWindowRect(const Tizen::Graphics::Rectangle& rect); + Tizen::Graphics::Rectangle GetWindowRect(void) const; + result SetTextColor(enum ContextMenuCoreItemStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTextColor(enum ContextMenuCoreItemStatus status) const; + result SetColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetColor(void) const; + result SetItemColor(enum ContextMenuCoreItemStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetItemColor(enum ContextMenuCoreItemStatus status) const; + result AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); + result RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); + Tizen::Ui::Controls::_ActionEvent* GetActionEvent(void) const; + const Tizen::Graphics::Bitmap* GetArrowNormalBitmap(ContextMenuCoreDropPosition dropPosition) const; + const Tizen::Graphics::Bitmap* GetArrowEffectBitmap(ContextMenuCoreDropPosition dropPosition) const; + const Tizen::Graphics::Bitmap* GetBackgroundNormalBitmap(void) const; + const Tizen::Graphics::Bitmap* GetBackgroundEffectBitmap(void) const; + ContextMenuCoreDropPosition GetDropPosition(void) const; + _ControlOrientation GetLayout(void) const; + + virtual result OnAttachedToMainTree(void); + virtual result OnDetachingFromMainTree(void); + virtual void OnDraw(void); + + virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + virtual void OnVisibleStateChanged(void); + virtual void OnChangeLayout(_ControlOrientation orientation); + + virtual bool IsActivatedOnOpen(void) const; + Tizen::Ui::_AccessibilityElement* GetAccessibilityElement(const int mainIndex) const; + void AddAccessibilityElement(const _AccessibilityElement& element); + + _ContextMenuItemInfo GetItemFromPosition(const Tizen::Graphics::Point& position) const; + _ContextMenuItemInfo FindItem(int index) const; + result SetTopDrawnItemIndex(int index); + + _ScrollPanel* GetScrollPanel(void); + +protected: + result SetPresenter(const _IContextMenuPresenter& ContextMenuPresenter); + +private: + result LoadBitmap(void); + result LoadColorReplacedBitmap(const Tizen::Graphics::Color& color); + void AdjustDropPosition(void); + void SetAllAccessibilityElement(void); + void RemoveAllAccessibilityElement(void); + +private: + _ContextMenu(const _ContextMenu& rhs); + _ContextMenu& operator =(const _ContextMenu& rhs); + +// Attribute +private: + _IContextMenuPresenter* __pContextMenuPresenter; + enum ContextMenuCoreStyle __style; + enum ContextMenuCoreAlign __align; + int __showItemCount; + int __showItemMaxCount; + bool __isAttachedToMainTree; + bool __ownerInputEnableState; + +// attribute for position fo the window + Tizen::Graphics::Point __anchorPoint; // the anchor point on whole screen area. + Tizen::Graphics::Rectangle __bodyRect; // the body area of the ContextMenu area. + Tizen::Graphics::Rectangle __arrowRect; // the arrow area of the ContextMenu area. + Tizen::Graphics::Rectangle __windowRect; // the ContextMenu area on whole screen area. + +// attribute for event + _ActionEvent* __pActionEvent; + +// attribute for drawing + Tizen::Graphics::Bitmap* __pArrowNormalBitmap[CONTEXT_MENU_CORE_DROP_POSITION_MAX]; + Tizen::Graphics::Bitmap* __pArrowEffectBitmap[CONTEXT_MENU_CORE_DROP_POSITION_MAX]; + Tizen::Graphics::Bitmap* __pBackgroundNormalBitmap; + Tizen::Graphics::Bitmap* __pBackgroundEffectBitmap; + enum ContextMenuCoreDropPosition __dropPosition; + enum _ControlOrientation __layout; + + Tizen::Graphics::Color __backgroundColor; + Tizen::Graphics::Color __textColor[CONTEXT_MENU_ITEM_STATUS_COUNT]; + Tizen::Graphics::Color __itemColor[CONTEXT_MENU_ITEM_STATUS_COUNT]; + + Tizen::Base::Collection::ArrayListT __actionId; + Tizen::Base::Collection::LinkedListT<_AccessibilityElement*> __accessibilityElements; + + _ScrollPanel* __pScrollPanel; + +}; // _ContextMenu + +}}} // Tizen::Ui: Control + +#endif //_FUI_CTRL_INTERNAL_CONTEXT_MENU_H_ diff --git a/src/ui/inc/FUiCtrl_ContextMenuGridPresenter.h b/src/ui/inc/FUiCtrl_ContextMenuGridPresenter.h new file mode 100644 index 0000000..44544a8 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ContextMenuGridPresenter.h @@ -0,0 +1,147 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ContextMenuGridPresenter.h + * @brief This is the header file for the _ContextMenuGridPresenter class. + * + * This header file contains the declarations of the %_ContextMenuGridPresenter class. + */ +#ifndef _FUI_CTRL_INTERNAL_CONTEXTMENU_GRID_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_CONTEXTMENU_GRID_PRESENTER_H_ + +#include +#include "FUi_Control.h" +#include "FUiCtrl_ContextMenu.h" +#include "FUiCtrl_ContextMenuModel.h" +#include "FUiCtrl_IContextMenuPresenter.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ContextMenu; +class _ContextMenuModel; +class _ContextMenuItem; + +/** + * @class _ContextMenuGridPresenter + * @brief + * @since 2.0 + * + * + * + * + */ +class _ContextMenuGridPresenter + : public _IContextMenuPresenter +{ +// Lifecycle +public: + _ContextMenuGridPresenter(_ContextMenu* pContextMenu); + virtual ~_ContextMenuGridPresenter(void); + +// Operation +public: + virtual result Install(void); + virtual result Draw(void); + virtual result DrawBackground(Tizen::Graphics::Canvas* pCanvas); + virtual result DrawArrow(Tizen::Graphics::Canvas* pCanvas); + virtual result AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + virtual result InsertItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + virtual result SetItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + virtual result DeleteItem(int index); + virtual result DeleteItemAll(void); + virtual int CalculateShowItemCount(void); + virtual result CalculateWindowRect(void); + virtual result ApplyColorProperty(void); + + virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + virtual void SetAllAccessibilityElement(void); + + virtual _ContextMenuItemInfo GetItemFromPosition(const Tizen::Graphics::Point& position); + virtual _ContextMenuItemInfo FindItem(int index); + virtual result SetTopDrawnItemIndex(int index); + virtual result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap); + +private: + void LoadShape(void); + result CalculateRect(void); + void AdjustItemLayout(void); + void AdjustItemPosition(void); + Tizen::Graphics::Dimension AdjustItemLayoutIconStyle(void); + Tizen::Graphics::Dimension AdjustItemLayoutTabStyle(void); + bool IsLayoutBitmapOnly(void); + + _ContextMenuItem* CreateItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + result DrawItem(Tizen::Graphics::Canvas* pCanvas); + result DrawLine(Tizen::Graphics::Canvas* pCanvas, Tizen::Graphics::Point point1, Tizen::Graphics::Point point2, bool drawVLine); + void SetItemSize(_ContextMenuItem* pItem); + int GetItemIndexFromPosition(const Tizen::Graphics::Point& point) const; + int GetCountPerLine(int count, int min, int max) const; +private: + _ContextMenuGridPresenter(const _ContextMenuGridPresenter& rhs); + _ContextMenuGridPresenter& operator =(const _ContextMenuGridPresenter& rhs); + +// Attribute +private: + _ContextMenu* __pContextMenu; + _ContextMenuModel* __pModel; + + Tizen::Graphics::_Text::TextObject* __pTextObject; + Tizen::Graphics::Font* __pFont; + Tizen::Graphics::Dimension __layoutSize; + + bool __touchOutRect; + int __selectedIndex; + int __pressedIndex; + int __maxWidth; + int __minWidth; + int __topMargin; + int __bottomMargin; + int __leftMargin; + int __rightMargin; + int __screenTopMargin; + int __screenBottomMargin; + int __screenLeftMargin; + int __screenRightMargin; + int __arrowMargin; + int __arrowWidth; + int __arrowHeight; + int __itemWidth; + int __itemHeight; + int __itemMaxWidth; + int __itemTextMargin; + int __itemGap; + int __itemBitmapWidth; + int __itemBitmapHeight; + int __itemFontSize; + int __dividerHeight; +}; // _ContextMenuGridPresenter + +}}} // Tizen::Ui: Control + +#endif //_FUI_CTRL_INTERNAL_CONTEXTMENU_GRID_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_ContextMenuImpl.h b/src/ui/inc/FUiCtrl_ContextMenuImpl.h new file mode 100644 index 0000000..c5e7755 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ContextMenuImpl.h @@ -0,0 +1,119 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ContextMenuImpl.h + * @brief This is the header file for the _ContextMenuImpl class. + * + * This header file contains the declarations of the %_ContextMenuImpl class. + */ +#ifndef _FUI_CTRL_INTERNAL_CONTEXT_MENU_IMPL_H_ +#define _FUI_CTRL_INTERNAL_CONTEXT_MENU_IMPL_H_ + +#include +#include +#include +#include "FUi_WindowImpl.h" +#include "FUiCtrl_ContextMenu.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_PublicActionEvent.h" + +namespace Tizen { namespace Ui +{ +class _IWindow; +}} + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class ContextMenuImpl + * @brief + * @since 1.0 + * + * + * + * + */ +class _ContextMenuImpl + : public _WindowImpl + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + virtual ~_ContextMenuImpl(void); + static _ContextMenuImpl* CreateContextMenuImplN(ContextMenu* pPublic, const Tizen::Graphics::Point& point, ContextMenuStyle style, ContextMenuAnchorDirection direction); +// Operation +public: + result AddItem(const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + result InsertItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + result SetItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + result RemoveItemAt(int index); + result RemoveAllItems(void); + int GetItemCount(void) const; + result SetMaxVisibleItemsCount(int maxItemsCount); + int GetMaxVisibleItemsCount(void) const; + int GetItemIndexFromActionId(int actionId) const; + int GetItemActionIdAt(int index) const; + result SetAnchorPosition(int x, int y); + Tizen::Graphics::Point GetAnchorPosition(void) const; + result SetColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetColor(void) const; + result SetItemTextColor(ContextMenuItemStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetItemTextColor(ContextMenuItemStatus status) const; + result SetItemColor(ContextMenuItemStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetItemColor(ContextMenuItemStatus status) const; + ContextMenuStyle GetPublicStyle(void) const; + result AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + result RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + virtual result OnAttachedToMainTree(void); + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + +// Accessor +public: + + static _ContextMenuImpl* GetInstance(ContextMenu& contextMenu); + static const _ContextMenuImpl* GetInstance(const ContextMenu& contextMenu); + + virtual const char* GetPublicClassName(void) const; + virtual const ContextMenu& GetPublic(void) const; + virtual ContextMenu& GetPublic(void); + virtual const _ContextMenu& GetCore(void) const; + virtual _ContextMenu& GetCore(void); + +protected: + result _Dispose(void); + +private: + _ContextMenuImpl(ContextMenu* pPublic, _ContextMenu* pCore, ContextMenuStyle style); + + _ContextMenuImpl(const _ContextMenuImpl& rhs); + _ContextMenuImpl& operator =(const _ContextMenuImpl& rhs); + + +//attribute +private: + ContextMenuStyle __style; + _ContextMenu* __pContextMenu; + _PublicActionEvent* __pPublicActionEvent; + +}; // _ContextMenuImpl + +}}} // Tizen::Ui: Control + +#endif //_FUI_CTRL_INTERNAL_CONTEXT_MENU_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_ContextMenuItem.h b/src/ui/inc/FUiCtrl_ContextMenuItem.h new file mode 100644 index 0000000..3b291a5 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ContextMenuItem.h @@ -0,0 +1,154 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ContextMenuItem.h + * @brief This is the header file for the _ContextMenuItem class. + * + * This header file contains the declarations of the %_ContextMenuItem class. + */ +#ifndef _FUI_CTRL_INTERNAL_CONTEXTMENU_ITEM_H_ +#define _FUI_CTRL_INTERNAL_CONTEXTMENU_ITEM_H_ + +#include +#include +#include +#include +#include + +#include "FUi_Control.h" +#include "FUiCtrl_Label.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum ContextMenuItemDrawingStatus +{ + CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL = 0, + CONTEXT_MENU_ITEM_DRAWING_STATUS_PRESSED, + CONTEXT_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED, + CONTEXT_MENU_ITEM_DRAWING_STATUS_MAX +}; + +enum ContextMenuItemDrawingType +{ + CONTEXT_MENU_ITEM_DRAWING_TYPE_NONE = -1, + CONTEXT_MENU_ITEM_DRAWING_TYPE_TEXT, + CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP +}; + +/** + * @class _ContextMenuItem + * @brief + * @since 2.0 + * + * + * + * + */ +class _ContextMenuItem + : public Tizen::Ui::_Control +{ +// Lifecycle + +public: + _ContextMenuItem(void); + virtual ~_ContextMenuItem(void); + + static _ContextMenuItem* CreateContextMenuItemN(void); + + void SetType(ContextMenuItemDrawingType type); + ContextMenuItemDrawingType GetType(void) const; + + void SetActionId(int actionId); + int GetActionId(void) const; + + void SetDivider(bool drawDivider); + bool GetDivider(void) const; + + void SetTextSize(int size); + + result SetText(const Tizen::Base::String& text); + const Tizen::Base::String& GetText(void) const; + + result SetBitmap(ContextMenuItemDrawingStatus status, const Tizen::Graphics::Bitmap* pBitmap); + const Tizen::Graphics::Bitmap* GetBitmap(ContextMenuItemDrawingStatus status) const; + + void SetSize(Tizen::Graphics::Dimension size); + Tizen::Graphics::Dimension GetSize(void) const; + + void SetDrawRect(Tizen::Graphics::Rectangle rect); + Tizen::Graphics::Rectangle GetDrawRect(void) const; + + void SetParentScrollEnable(bool enable); + bool GetParentScrollEnable() const; + + bool IsSelected() const; + + int Release(void); + + void Reset(void); + + // draw + virtual void OnDraw(void); + void DrawItem(void); + void SetBitmapLabel(_Label* pLabel); + void SetTextLabel(_Label* pLabel); + void DrawItemDivider(void); + + // event handler for ITouchEventListener + virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + +private: + _ContextMenuItem(const _ContextMenuItem& rhs); + _ContextMenuItem& operator =(const _ContextMenuItem& rhs); + +// Attribute +private: + ContextMenuItemDrawingType __type; + int __actionId; + bool __divider; + + bool __pressed; + bool __selected; + bool __parentScrollEnable; + + int __textSize; + Tizen::Base::String __text; + Tizen::Graphics::Bitmap* __pBitmap[CONTEXT_MENU_ITEM_DRAWING_STATUS_MAX]; + Tizen::Graphics::Dimension __size; + Tizen::Graphics::Rectangle __drawRect; + + _Label* __pBitmapLabel; + _Label* __pTextLabel; + _Label* __pDividerLineLabel1; + _Label* __pDividerLineLabel2; + +}; // _ContextMenuItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_CONTEXTMENU_ITEM_H_ diff --git a/src/ui/inc/FUiCtrl_ContextMenuListPresenter.h b/src/ui/inc/FUiCtrl_ContextMenuListPresenter.h new file mode 100644 index 0000000..89c5d4a --- /dev/null +++ b/src/ui/inc/FUiCtrl_ContextMenuListPresenter.h @@ -0,0 +1,143 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ContextMenuListPresenter.h + * @brief This is the header file for the _ContextMenuListPresenter class. + * + * This header file contains the declarations of the %_ContextMenuListPresenter class. + */ +#ifndef _FUI_CTRL_INTERNAL_CONTEXTMENU_LIST_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_CONTEXTMENU_LIST_PRESENTER_H_ + +#include +#include "FUi_Control.h" +#include "FUiCtrl_ContextMenu.h" +#include "FUiCtrl_ContextMenuModel.h" +#include "FUiCtrl_IContextMenuPresenter.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ContextMenu; +class _ContextMenuModel; +class _ContextMenuItem; + +/** + * @class _ContextMenuListPresenter + * @brief + * @since 2.0 + * + * + * + * + */ +class _ContextMenuListPresenter + : public _IContextMenuPresenter +{ +// Lifecycle +public: + _ContextMenuListPresenter(_ContextMenu* pContextMenu); + virtual ~_ContextMenuListPresenter(void); + +// Operation +public: + virtual result Install(void); + virtual result Draw(void); + virtual result DrawBackground(Tizen::Graphics::Canvas* pCanvas); + virtual result DrawArrow(Tizen::Graphics::Canvas* pCanvas); + virtual result AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + virtual result InsertItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + virtual result SetItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + virtual result DeleteItem(int index); + virtual result DeleteItemAll(void); + virtual int CalculateShowItemCount(void); + virtual result CalculateWindowRect(void); + virtual result ApplyColorProperty(void); + + virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + virtual void SetAllAccessibilityElement(void); + + virtual _ContextMenuItemInfo GetItemFromPosition(const Tizen::Graphics::Point& position); + virtual _ContextMenuItemInfo FindItem(int index); + virtual result SetTopDrawnItemIndex(int index); + virtual result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap); + +private: + void LoadShape(void); + result CalculateRect(void); + void AdjustItemLayout(void); + void AdjustItemPosition(void); + Tizen::Graphics::Dimension AdjustItemLayoutStyle(void); + + _ContextMenuItem* CreateItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + int GetItemIndexFromPosition(const Tizen::Graphics::Point& point) const; + +private: + _ContextMenuListPresenter(const _ContextMenuListPresenter& rhs); + _ContextMenuListPresenter& operator =(const _ContextMenuListPresenter& rhs); + +// Attribute +private: + _ContextMenu* __pContextMenu; + _ContextMenuModel* __pModel; + + Tizen::Graphics::Font* __pFont; + Tizen::Graphics::Dimension __layoutSize; + + bool __touchOutRect; + int __selectedIndex; + bool __scrollEnable; + + int __maxWidth; + int __minWidth; + int __topMargin; + int __bottomMargin; + int __leftMargin; + int __rightMargin; + int __screenTopMargin; + int __screenBottomMargin; + int __screenLeftMargin; + int __screenRightMargin; + int __arrowMargin; + int __arrowWidth; + int __arrowHeight; + int __itemWidth; + int __itemMinWidth; + int __itemHeight; + int __itemMaxWidth; + int __itemGap; + int __itemBitmapWidth; + int __itemBitmapHeight; + int __itemFontSize; + int __dividerHeight; + +}; // _ContextMenuListPresenter + +}}} // Tizen::Ui: Control + +#endif //_FUI_CTRL_INTERNAL_CONTEXTMENU_LIST_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_ContextMenuModel.h b/src/ui/inc/FUiCtrl_ContextMenuModel.h new file mode 100644 index 0000000..e4a49d6 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ContextMenuModel.h @@ -0,0 +1,76 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ContextMenuModel.h + * @brief This is the header file for the _ContextMenuModel class. + * + * This header file contains the declarations of the %_ContextMenuModel class. + */ +#ifndef _FUI_CTRL_INTERNAL_CONTEXTMENU_MODEL_H_ +#define _FUI_CTRL_INTERNAL_CONTEXTMENU_MODEL_H_ + +#include +#include +#include "FUiCtrl_ContextMenuItem.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _ContextMenuModel + * @brief + * @since 2.0 + * + * + * + * + */ + +class _ContextMenuModel + : public Tizen::Base::Object +{ +// Lifecycle +public: + _ContextMenuModel(void); + virtual ~_ContextMenuModel(void); + +// Operations +public: + result Construct(void); + int GetItemCount(void) const; + _ContextMenuItem* GetItem(int index) const; + result AddItem(_ContextMenuItem* pItem); + result InsertItem(_ContextMenuItem* pItem, int index); + result SetItem(_ContextMenuItem* pItem, int index); + result RemoveItem(int index); + result RemoveAllItem(void); + void ResetAllItem(void); + +private: + bool IsValidItem(_ContextMenuItem *pItem); + +private: + _ContextMenuModel(const _ContextMenuModel& rhs); + _ContextMenuModel& operator =(const _ContextMenuModel& rhs); + +// Attribute +private: + Tizen::Base::Collection::ArrayList __items; +}; // _ContextMenuModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_CONTEXTMENU_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_CustomElement.h b/src/ui/inc/FUiCtrl_CustomElement.h new file mode 100644 index 0000000..ec125e9 --- /dev/null +++ b/src/ui/inc/FUiCtrl_CustomElement.h @@ -0,0 +1,56 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_CustomElement.h + * @brief This is the header file for the _CustomElement class. + * + * This header file contains the declarations of the _CustomElement class. + */ + +#ifndef _FUI_CTRL_INTERNAL_CUSTOM_ELEMENT_H_ +#define _FUI_CTRL_INTERNAL_CUSTOM_ELEMENT_H_ + +#include "FUiCtrl_ICustomElement.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _CustomElement + : public _ICustomElement + , public Tizen::Base::Object +{ +public: + _CustomElement(int elementId); + + ~_CustomElement(void); + +public: + virtual bool DrawElement(Tizen::Graphics::Canvas* pCanvas, Tizen::Graphics::Rectangle& rect, ListViewItemDrawingStatus status); + + void SetElement(const Tizen::Ui::Controls::ICustomElement& element); + + int GetElementId(void) const; + +private: + Tizen::Ui::Controls::ICustomElement* __pElement; + int __elementId; +}; // _CustomElement + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_CUSTOM_ELEMENT_H_ diff --git a/src/ui/inc/FUiCtrl_CustomItemImpl.h b/src/ui/inc/FUiCtrl_CustomItemImpl.h new file mode 100644 index 0000000..5b055e2 --- /dev/null +++ b/src/ui/inc/FUiCtrl_CustomItemImpl.h @@ -0,0 +1,85 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_CustomItemImpl.h + * @brief This is the header file for the _CustomItemImpl class. + * + * This header file contains the declarations of the _CustomItemImpl class. + */ + +#ifndef _FUI_CTRL_CUSTOM_ITEM_IMPL_H_ +#define _FUI_CTRL_CUSTOM_ITEM_IMPL_H_ + +#include "FUiCtrl_ListItemBaseImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class ICustomElement; +class CustomItem; + +class _CustomItemImpl + : public _ListItemBaseImpl +{ +public: + static _CustomItemImpl* CreateCustomItemImplN(CustomItem* pPublic, const Tizen::Graphics::Dimension& itemSize, ListAnnexStyle style); + + virtual ~_CustomItemImpl(void); + + virtual CustomItem& GetPublic(void); + + virtual const char* GetPublicClassName(void) const; + + virtual result Construct(const Tizen::Graphics::Dimension& itemSize, ListAnnexStyle style); + + result AddElement(const Tizen::Graphics::Rectangle& rect, int elementId, const Tizen::Graphics::EnrichedText& text); + + result AddElement(const Tizen::Graphics::Rectangle& rect, int elementId, const Tizen::Base::String& text, bool textSliding = true); + + result AddElement(const Tizen::Graphics::Rectangle& rect, int elementId, const Tizen::Base::String& text, int textSize, + const Tizen::Graphics::Color& normalTextColor, const Tizen::Graphics::Color& pressedTextColor, + const Tizen::Graphics::Color& highlightedTextColor, bool textSliding = true); + + result AddElement(const Tizen::Graphics::Rectangle& rect, int elementId, const Tizen::Graphics::Bitmap& normalBitmap, + const Tizen::Graphics::Bitmap* pPressedBitmap = null, const Tizen::Graphics::Bitmap* pHighlightedBitmap = null); + + result AddElement(const Tizen::Graphics::Rectangle& rect, int elementId, const Tizen::Ui::Controls::ICustomElement& element); + + result RemoveAllElements(void); + + result RemoveElement(int elementId); + + result SetElementSelectionEnabled(int elementId, bool enable); + + result SetElementTextHorizontalAlignment(int elementId, HorizontalAlignment alignment); + + result SetElementTextVerticalAlignment(int elementId, VerticalAlignment alignment); + + result SetElementAutoLinkMask(int elementId, unsigned long mask); + +private: + _CustomItemImpl(CustomItem* pPublic); + + _CustomItemImpl(const _CustomItemImpl& rhs); + + _CustomItemImpl& operator =(const _CustomItemImpl& rhs); +}; // _CustomItemImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_CUSTOM_ITEM_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_CustomListElements.h b/src/ui/inc/FUiCtrl_CustomListElements.h new file mode 100644 index 0000000..b55044c --- /dev/null +++ b/src/ui/inc/FUiCtrl_CustomListElements.h @@ -0,0 +1,292 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_CustomListElements.h + * @brief This is the header file for the classes related to implementing elements in CustomListItem. + * + * This header file contains the declarations of the helper classes of _CustomListItemImpl. + */ + +#ifndef _FUI_CTRL_INTERNAL_CUSTOM_LIST_ELEMENTS_H_ +#define _FUI_CTRL_INTERNAL_CUSTOM_LIST_ELEMENTS_H_ + +#include +#include +#include +#include +#include +#include +#include "FUiCtrl_IListItemCommon.h" +#include "FUiCtrl_ListBaseImpl.h" +#include "FGrp_TextTextObject.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class ICustomListElement; + +enum ListElementType +{ + LIST_ITEM_ELEMENT_TYPE_TEXT, + LIST_ITEM_ELEMENT_TYPE_BITMAP, + LIST_ITEM_ELEMENT_TYPE_CUSTOM, + LIST_ITEM_ELEMENT_TYPE_CHECKBOX +}; + +struct _ElementViewParams +{ + TableViewItemBase* pTableViewItemBase; + class _ElementBaseModel* pElementModel; + class _ElementFormatData* pElementFormatData; + _CustomListItemImpl* pCustomListItemImpl; + + bool isDividerEnabled; + TableViewAnnexStyle annexStyle; + Tizen::Graphics::Bitmap** pCheckBitmaps; + Tizen::Base::Collection::LinkedList* pElementFormat; +}; //_ElementViewParams + +class _ElementBaseModel + : public Tizen::Base::Object +{ +public: + _ElementBaseModel(void); + ~_ElementBaseModel(void); + + virtual void HandleElementEvent(CustomListItemStatus itemStatus); + int GetElementId(void); + CustomListItemStatus GetItemStatus(void); + + virtual result CreateElementView(_ElementViewParams& elementParams) = 0; + +private: + _ElementBaseModel(const _ElementBaseModel& rhs); + _ElementBaseModel& operator =(const _ElementBaseModel& rhs); + +protected: + int _elementId; + ListElementType _elementType; + CustomListItemStatus _itemStatus; + + friend class _CustomListItemImpl; + friend class _TableViewItemData; + friend class _CustomListImpl; + friend class _ExpandableListImpl; + friend class _ListImpl; + friend class _SlidableListImpl; + friend class _GroupedListImpl; + friend class _SlidableGroupedListImpl; + friend class _ListBaseImpl; + +}; //_ElementBaseModel + +class _TextElementModel + : public _ElementBaseModel +{ +public: + _TextElementModel(const Tizen::Base::String& text); + ~_TextElementModel(void); + + void GetData(Tizen::Base::String& text, Tizen::Graphics::Color& textColor, int& textSize) const; + int GetTextSize(void) const; + result CreateElementView(_ElementViewParams& elementParams); + void SetTextSliding(bool enable); + bool GetTextSliding(void); + +private: + _TextElementModel(const _TextElementModel& rhs); + _TextElementModel& operator =(const _TextElementModel& rhs); + +private: + Tizen::Base::String __text; + int __textSize; + bool __slidingEnabled; + Tizen::Graphics::Color __textColor[CUSTOM_LIST_ITEM_STATUS_FOCUSED + 1]; + + friend class _CustomListItemImpl; + friend class _GroupedListImpl; + +}; //_TextElementModel + +class _BitmapElementModel + : public _ElementBaseModel +{ +public: + _BitmapElementModel(void); + ~_BitmapElementModel(void); + + Tizen::Graphics::Bitmap* GetData(void) const; + +private: + _BitmapElementModel(const _BitmapElementModel& rhs); + _BitmapElementModel& operator =(const _BitmapElementModel& rhs); + + result CreateElementView(_ElementViewParams& elementParams); + +private: + Tizen::Graphics::Bitmap* __pBitmap[CUSTOM_LIST_ITEM_STATUS_FOCUSED + 1]; + + friend class _CustomListItemImpl; + friend class _GroupedListImpl; +}; //_BitmapElementModel + + +class _CustomElementModel + : public _ElementBaseModel +{ +public: + _CustomElementModel(void); + ~_CustomElementModel(void); + ICustomListElement* GetData(void) const; + + result CreateElementView(_ElementViewParams& elementParams); + +private: + _CustomElementModel(const _CustomElementModel& rhs); + _CustomElementModel& operator =(const _CustomElementModel& rhs); + +private: + ICustomListElement* __pListElement; + + friend class _CustomListItemImpl; +}; //_CustomElementModel + +class _CheckElementModel + : public _ElementBaseModel +{ +public: + _CheckElementModel(void); + ~_CheckElementModel(void); + void GetData(Tizen::Graphics::Rectangle& bitmapBounds, bool& isDividerEnabled, bool& leftDivider, bool& rightDivider) const; + Tizen::Graphics::Bitmap* GetCheckBitmap(void) const; + + void SetCheckBoxStatus(_CheckBoxBitmapType checkBoxStatus); + _CheckBoxBitmapType GetCheckBoxStatus(void); + const _CheckBoxBitmapType GetCheckBoxStatus(void) const; + + result CreateElementView(_ElementViewParams& elementParams); + +private: + _CheckElementModel(const _CheckElementModel& rhs); + _CheckElementModel& operator =(const _CheckElementModel& rhs); + +private: + _CheckBoxBitmapType __checkBoxStatus; + Tizen::Graphics::Bitmap** __pCheckBitmaps; + bool __isDividerEnabled; + bool __rightDivider; + bool __leftDivider; + Tizen::Graphics::Rectangle __bitmapBounds; + + friend class _CustomListItemImpl; +}; + +class _ElementBaseView + : public Panel +{ +public: + _ElementBaseView(void); + virtual ~_ElementBaseView(void); + + virtual int GetElementId(void) const; + +private: + _ElementBaseView(const _ElementBaseView& rhs); + _ElementBaseView& operator =(const _ElementBaseView& rhs); + +protected: + _ElementBaseModel* __pElementBaseModel; +}; + +class _TextElementView + : public _ElementBaseView +{ +public: + _TextElementView(Tizen::Graphics::_Text::TextObject* pText); + ~_TextElementView(void); + + result OnDraw(void); + void SetModel(_TextElementModel* pTextElementModel); + + void StartTextSlide(void); + void StopTextSlide(void); + +private: + _TextElementView(const _TextElementView& rhs); + _TextElementView& operator =(const _TextElementView& rhs); + +private: + Tizen::Graphics::_Text::TextObject* __pText; +}; + +class _BitmapElementView + : public _ElementBaseView +{ +public: + _BitmapElementView(void); + ~_BitmapElementView(void); + + result OnDraw(void); + void SetModel(_BitmapElementModel* pBitmapElementModel); + +private: + _BitmapElementView(const _BitmapElementView& rhs); + _BitmapElementView& operator =(const _BitmapElementView& rhs); + +}; + +class _CustomElementView + : public _ElementBaseView +{ +public: + _CustomElementView(void); + ~_CustomElementView(void); + + result OnDraw(void); + void SetModel(_CustomElementModel* pCustomElementModel); + +private: + _CustomElementView(const _CustomElementView& rhs); + _CustomElementView& operator =(const _CustomElementView& rhs); + +}; + +class _CheckElementView + : public _ElementBaseView +{ +public: + _CheckElementView(void); + ~_CheckElementView(void); + + result OnDraw(void); + void SetModel(_CheckElementModel* pCheckElementModel); + void SetPressed(bool pressedState); + +private: + _CheckElementView(const _CheckElementView& rhs); + _CheckElementView& operator =(const _CheckElementView& rhs); + +private: + bool __pressedState; + Tizen::Graphics::Color __leftHalfDividerColor; + Tizen::Graphics::Color __rightHalfDividerColor; +}; + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_CUSTOM_LIST_ELEMENTS_H_ diff --git a/src/ui/inc/FUiCtrl_CustomListImpl.h b/src/ui/inc/FUiCtrl_CustomListImpl.h new file mode 100644 index 0000000..ad47a92 --- /dev/null +++ b/src/ui/inc/FUiCtrl_CustomListImpl.h @@ -0,0 +1,152 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_CustomListImpl.h + * @brief This is the header file for the _CustomListImpl class. + * + * This header file contains the declarations of the _CustomListImpl class and its helper classes. + */ + +#ifndef _FUI_CTRL_INTERNAL_CUSTOM_LIST_IMPL_H_ +#define _FUI_CTRL_INTERNAL_CUSTOM_LIST_IMPL_H_ + +#include +#include +#include +#include +#include "FUiCtrl_TableViewItemProvider.h" +#include +#include "FUiCtrl_TableView.h" +#include "FUi_ControlImpl.h" +#include "FUiCtrl_ITableViewItemEventListener.h" +#include "FUiCtrl_ListBaseImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +extern const int INVALID_INDEX; + +class CustomListItem; +class _CustomListImpl; + +class _CustomListItemDataProvider + : public ITableViewItemProvider +{ +public: + _CustomListItemDataProvider(_CustomListImpl* pList); + virtual ~_CustomListItemDataProvider(void); + + virtual int GetItemCount(void); + virtual TableViewItem* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(const int itemIndex, TableViewItem* pItem); + virtual void UpdateItem(int itemIndex, TableViewItem* pItem); + virtual int GetDefaultItemHeight(void); + +private: + _CustomListItemDataProvider(void); + _CustomListItemDataProvider(const _CustomListItemDataProvider& rhs); + _CustomListItemDataProvider& operator =(const _CustomListItemDataProvider& rhs); + +private: + _CustomListImpl* __pList; +}; //_CustomListItemDataProvider + + +class _CustomListImpl + : public _ListBaseImpl + , public _ITableViewItemEventListener +{ +public: + virtual ~_CustomListImpl(void); + virtual const char* GetPublicClassName(void) const; + virtual const CustomList& GetPublic(void) const; + virtual CustomList& GetPublic(void); + virtual const _TableView& GetCore(void) const; + virtual _TableView& GetCore(void); + + result Initialize(void); + result AddCustomItemEventListener(const ICustomItemEventListener& listener); + result RemoveCustomItemEventListener(const ICustomItemEventListener& listener); + result AddItem(const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + result SetItemAt(int index, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + result InsertItemAt(int index, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + result RemoveItemAt(int index); + result RemoveAllItems(void); + result SetItemEnabled(int index, bool enable); + bool IsItemEnabled(int index) const; + result SetItemChecked(int index, bool check); + bool IsItemChecked(int index) const; + result SetAllItemsChecked(bool check); + result RemoveAllCheckedItems(void); + int GetFirstCheckedItemIndex(void) const; + int GetLastCheckedItemIndex(void) const; + int GetNextCheckedItemIndexAfter(int index) const; + int GetItemIndexFromItemId(int itemId) const; + void ScrollToBottom(void); + void ScrollToTop(void); + result ScrollToTop(int index); + result RefreshItem(int index); + int GetItemIdAt(int index) const; + result InitializeBounds(const Tizen::Graphics::Rectangle& rect); + + void OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + void OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo); + void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + void OnGroupedTableViewItemReordered(_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo); + void OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + void OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction); + + static _CustomListImpl* CreateCustomListImplN(CustomList* pControl, const Tizen::Graphics::Rectangle& bounds, bool itemDivider); + static _CustomListImpl* GetInstance(CustomList& customList); + static const _CustomListImpl* GetInstance(const CustomList& customList); + + Tizen::Graphics::Bitmap** GetCheckBitmaps(); + result SetItemChecked(int groupIndex, int itemIndex, bool check); + bool IsItemChecked(int groupIndex, int subIndex) const; + +private: + _CustomListImpl(Control* pPublic, _TableView* pCore); + _CustomListImpl(const _CustomListImpl& rhs); + _CustomListImpl& operator =(const _CustomListImpl& rhs); + + void ProcessItemStateChange(int groupIndex, int itemIndex, int elementId, ItemStatus itemStatus); + void ProcessItemStateChange(int groupIndex, int itemIndex, ItemStatus itemStatus); + +private: + _CustomListItemDataProvider* __pItemProvider; + Tizen::Base::Collection::LinkedList __itemListenersList; + + friend class _CustomListItemDataProvider; + friend class _ExpandableListImpl; + friend class _SlidableListImpl; + friend class _GroupedListImpl; + friend class _SlidableGroupedListImpl; + friend class _SlidableListItemProvider; + friend class _SlidableGroupedListItemProvider; + friend class _ListImpl; + friend class _TableViewItemData; + friend class _CustomListItemImpl; + +}; //_CustomListImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_CUSTOM_LIST_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_CustomListItemFormatImpl.h b/src/ui/inc/FUiCtrl_CustomListItemFormatImpl.h new file mode 100644 index 0000000..d03a30c --- /dev/null +++ b/src/ui/inc/FUiCtrl_CustomListItemFormatImpl.h @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_CustomListItemFormatImpl.h + * @brief This is the header file for the _CustomListItemFormatImpl class. + * + * This header file contains the declarations of the _CustomListItemFormatImpl class and its helper classes. + */ + +#ifndef _FUI_CTRL_INTERNAL_CUSTOM_LIST_ITEM_FORMAT_IMPL_H_ +#define _FUI_CTRL_INTERNAL_CUSTOM_LIST_ITEM_FORMAT_IMPL_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ElementFormatData + : public Tizen::Base::Object +{ +public: + _ElementFormatData(void); + ~_ElementFormatData(void); + +private: + _ElementFormatData(const _ElementFormatData& rhs); + _ElementFormatData& operator =(const _ElementFormatData& rhs); + +public: + int elementId; + Tizen::Graphics::Rectangle rect; + int textSize; + Tizen::Graphics::Color normalTextColor; + Tizen::Graphics::Color focusedTextColor; + Tizen::Graphics::Color highlightedTextColor; + bool enable; +}; //_ElementFormatData + + +class _CustomListItemFormatImpl + : public Tizen::Base::Object +{ +public: + virtual ~_CustomListItemFormatImpl(void); + static _CustomListItemFormatImpl* CreateInstanceN(void); + + result AddElement(int elementId, const Tizen::Graphics::Rectangle& rect); + result AddElement(int elementId, const Tizen::Graphics::Rectangle& rect, int textSize); + result AddElement(int elementId, const Tizen::Graphics::Rectangle& rect, int textSize, const Tizen::Graphics::Color& normalTextColor, const Tizen::Graphics::Color& focusedTextColor); + result AddElement(int elementId, const Tizen::Graphics::Rectangle& rect, int textSize, const Tizen::Graphics::Color& normalTextColor, const Tizen::Graphics::Color& focusedTextColor, const Tizen::Graphics::Color& highlightedTextColor); + + Tizen::Graphics::Rectangle GetElement(int elementId) const; + int GetFirstElementId(void); + int GetFirstEnabledElementId(void); + int GetNextElementId(int elementId); + int GetNextEnabledElementId(int elementId); + int GetPreviousEnabledElementId(int elementId); + bool IsElementEventEnabled(int elementId); + void SetElementEventEnabled(int elementId, bool enable); + + _ElementFormatData* GetElementFormatById(int elementId); + +private: + _CustomListItemFormatImpl(void); + _CustomListItemFormatImpl(const _CustomListItemFormatImpl& rhs); + _CustomListItemFormatImpl& operator =(const _CustomListItemFormatImpl& rhs); + + _ElementFormatData* CreateElementN(int elementId); + +public: + Tizen::Base::Collection::LinkedList elementFormatDataList; +}; //_CustomListItemFormatImpl + +}}} //Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_CUSTOM_LIST_ITEM_FORMAT_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_CustomListItemImpl.h b/src/ui/inc/FUiCtrl_CustomListItemImpl.h new file mode 100644 index 0000000..238c0da --- /dev/null +++ b/src/ui/inc/FUiCtrl_CustomListItemImpl.h @@ -0,0 +1,218 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_CustomListItemImpl.h + * @brief This is the header file for the _CustomListItemImpl class. + * + * This header file contains the declarations of the _CustomListItemImpl class and its helper classes. + */ + +#ifndef _FUI_CTRL_INTERNAL_CUSTOM_LIST_ITEM_IMPL_H_ +#define _FUI_CTRL_INTERNAL_CUSTOM_LIST_ITEM_IMPL_H_ + +#include +#include +#include +#include +#include +#include +#include "FUiCtrl_CustomListElements.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +extern const int INVALID_INDEX; + +struct _TableViewItemParams +{ + CustomListItem* pItem; + int width; + int groupIndex; + int itemIndex; + int itemId; + bool isDividerEnabled; + Tizen::Graphics::Bitmap** pCheckBitmaps; + TableViewAnnexStyle annexStyle; +}; // _TableViewItemParams + +struct _TableViewItemUpdateParams +{ + CustomListItem* pItem; + bool isDividerEnabled; + Tizen::Graphics::Bitmap** pCheckBitmaps; + TableViewAnnexStyle annexStyle; +}; // _TableViewItemUpdateParams + +class _ITableViewBaseItemData +{ +public: + virtual ~_ITableViewBaseItemData(void) {} + + virtual void GetIndex(int& mainIndex, int& subIndex) const = 0; +}; //_ITableViewBaseItemData + +class _TableViewItemData + : public TableViewItem + , public _ITableViewBaseItemData +{ +public: + _TableViewItemData(void); + ~_TableViewItemData(void); + + result SetEnabled(bool enable); + + void GetIndex(int& mainIndex, int& subIndex) const; + +private: + _TableViewItemData(const _TableViewItemData& rhs); + _TableViewItemData& operator =(const _TableViewItemData& rhs); + +public: + int itemIndex; + int groupIndex; +}; //_TableViewItemData + +class _TableViewGroupItemData + : public TableViewGroupItem + , public _ITableViewBaseItemData +{ + +public: + _TableViewGroupItemData(); + ~_TableViewGroupItemData(); + + result SetEnabled(bool enable); + + void GetIndex(int& mainIndex, int& subIndex) const; + +private: + _TableViewGroupItemData(const _TableViewGroupItemData& rhs); + _TableViewGroupItemData& operator =(const _TableViewGroupItemData& rhs); + +public: + int groupIndex; +}; // _TableViewGroupItemData + +class _CustomListItemImpl + : public Tizen::Base::Object + , public Tizen::Ui::ITouchEventListener + , public Tizen::Base::Runtime::ITimerEventListener +{ + +public: + virtual ~_CustomListItemImpl(void); + static _CustomListItemImpl* CreateInstanceN(int itemHeight); + void Initialize(int itemHeight); + int GetValue(void) const; + result SetCheckBox(int elementId); + result SetElement(int elementId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pFocusedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + result SetElement(int elementId, const Tizen::Base::String& text); + result SetElement(int elementId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pFocusedBitmap); + result SetElement(int elementId, const ICustomListElement& element); + void SetFocusedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + void SetNormalItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + void SetHighlightedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + void UpdateBitmaps(void); + result SetValue(int value); + _CheckElementModel* GetCheckElement(void); + + result SetTextSliding(int elementId, bool enable); + void StartSliding(void); + void StopSliding(void); + + // Timer Callback API + void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + static result SetDividerRequired(Tizen::Base::Collection::LinkedList& elementFormatList, Tizen::Graphics::Rectangle& checkElementBounds, bool& leftDivider, bool& rightDivider); + static result CreateTableViewItem(_TableViewItemParams& tableViewItemParams); + static TableViewItemBase* CreateTableViewItemN(_TableViewItemParams& tableViewItemParams); + static TableViewItemBase* CreateTableViewGroupItemN(_TableViewItemParams& tableViewItemParams); + static result UpdateTableViewItem(_TableViewItemUpdateParams& updateItemParams); + + result SetElementData(_ElementBaseModel* pElement); + void SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap, TableViewItemDrawingStatus status); + _ElementBaseView* GetViewById(int elementId) const; + + virtual void OnTouchDoublePressed (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchFocusIn (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchFocusOut (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchLongPressed (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchMoved (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchPressed (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchReleased (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + + static _CustomListItemFormatImpl* GetFormatImpl(CustomListItem* pItem); + static _CustomListItemImpl* GetItemImpl(CustomListItem* pItem); + + static void DeleteCustomListItem(Tizen::Base::Object* pObj); + static _ListBaseImpl* GetListBaseImplFromElement(const Control& element); + +private: + _CustomListItemImpl(int itemHeight); + _CustomListItemImpl(const _CustomListItemImpl& rhs); + _CustomListItemImpl& operator =(const _CustomListItemImpl& rhs); + + _ElementBaseModel* GetElementModelById(int elementId) const; + _ElementBaseView* GetElementViewById(int elementId) const; + void RemoveElement(int elementId); + + void UpdateItemBackground(const Control& element, bool isDividerEnabled); + void UpdateElements(const Control &source, int elementId, bool isPressed, bool isDividerEnabled); + bool IsElementEventEnabled(const Control& source); + CustomListItem* GetItemFromElement(const Control& source) const; + void GetIndexFromElement(const Control& source, int& groupIndex, int& itemIndex) const; + + bool IsElementIdValid(Tizen::Base::Collection::LinkedList* pElementFormat, int elementId) const; + + void StartTextSlideTimer(void); + void StopTextSlideTimer(void); +public: + int height; + int itemId; + Tizen::Base::Collection::LinkedList elements; + +private: + static const int TEXT_SLIDING_TIMER_DURATION = 60; + + int __percentValue; + _TableViewItemData* __pTableViewItemData; + _TableViewGroupItemData* __pTableViewGroupItemData; + Tizen::Base::Collection::ArrayList* __pSubItemsList; + Tizen::Base::Runtime::Timer* __pTextSlideTimer; + Tizen::Graphics::Bitmap* __pBitmaps[CUSTOM_LIST_ITEM_STATUS_FOCUSED + 1]; + bool __isMoved; + + friend class _CustomListImpl; + friend class _ExpandableListImpl; + friend class _ListImpl; + friend class _SlidableListImpl; + friend class _GroupedListImpl; + friend class _SlidableGroupedListImpl; + friend class _ListBaseImpl; + + friend class _GroupedListItemDataProvider; + friend class _CustomListItemDataProvider; + friend class _ExpandableListItemDataProvider; + friend class _SlidableListItemProvider; + friend class _SlidableGroupedListItemProvider; + friend class _ListItemDataProvider; +}; //_CustomListItemImpl + +}}} //Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_CUSTOM_LIST_ITEM_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_DatePickerImpl.h b/src/ui/inc/FUiCtrl_DatePickerImpl.h new file mode 100644 index 0000000..ca061bf --- /dev/null +++ b/src/ui/inc/FUiCtrl_DatePickerImpl.h @@ -0,0 +1,98 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DatePickerImpl.h + * @brief This is the header file for the _DatePickerImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_DATEPICKER_IMPL_H_ +#define _FUI_CTRL_INTERNAL_DATEPICKER_IMPL_H_ + +#include +#include "FUi_WindowImpl.h" +#include "FUiCtrl_DateTimePicker.h" +#include "FUiCtrl_IDateTimeChangeEventListener.h" +#include "FUiCtrl_PublicDateTimeChangeEvent.h" + +namespace Tizen { namespace Ui +{ +class IDateChangeEventListener; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _DatePickerImpl + : public _WindowImpl + , public _IDateTimeChangeEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + class DatePickerSizeInfo : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + virtual Tizen::Graphics::Dimension GetDefaultMaximumSize(_ControlOrientation orientation) const; + }; + +public: + static _DatePickerImpl* CreateDatePickerImplN(DatePicker* pControl, const Tizen::Base::String& title = L""); + virtual ~_DatePickerImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const DatePicker& GetPublic(void) const; + virtual DatePicker& GetPublic(void); + virtual const _DateTimePicker& GetCore(void) const; + virtual _DateTimePicker& GetCore(void); + + result AddDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener); + result RemoveDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener); + + void SetDate(const Tizen::Base::DateTime& date); + Tizen::Base::DateTime GetDate(void) const; + + void SetCurrentDate(void); + result SetDay(int day); + int GetDay(void) const; + result SetMonth(int month); + int GetMonth(void) const; + result SetYear(int year); + int GetYear(void) const; + + result SetYearRange(int minYear, int maxYear); + result GetYearRange(int& minYear, int& maxYear) const; + + virtual result OnAttachedToMainTree(void); + virtual void OnDateTimeChanged(const Tizen::Ui::_Control& source, int year, int month, int day, int hour, int minute); + virtual void OnDateTimeChangeCanceled(const Tizen::Ui::_Control& source); + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + +public: + static _DatePickerImpl* GetInstance(DatePicker& datePicker); + static const _DatePickerImpl* GetInstance(const DatePicker& datePicker); + +private: + _DatePickerImpl(DatePicker* pPublic, _DateTimePicker* pCore); + _DatePickerImpl(const _DatePickerImpl&); + _DatePickerImpl& operator =(const _DatePickerImpl&); + +private: + _PublicDateTimeChangeEvent* __pPublicDateTimeChangeEvent; +}; // _DatePickerImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_DATEPICKER_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_DateTimeBar.h b/src/ui/inc/FUiCtrl_DateTimeBar.h new file mode 100644 index 0000000..7ae9ef7 --- /dev/null +++ b/src/ui/inc/FUiCtrl_DateTimeBar.h @@ -0,0 +1,139 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DateTimeBar.h + * @brief This is the header file for the _DateTimeBar class. + * + * This header file contains the declarations of the %_DateTimeBar class. + */ +#ifndef _FUI_CTRL_INTERNAL_DATETIME_BAR_H_ +#define _FUI_CTRL_INTERNAL_DATETIME_BAR_H_ + +#include +#include +#include "FUi_Window.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_IAccessibilityListener.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_ActionEvent.h" +#include "FUiCtrl_DateTimeDefine.h" +#include "FUiCtrl_DateTimeChangeEvent.h" +#include "FUiCtrl_IDateTimeChangeEventListener.h" +#include "FUi_ITouchFlickGestureEventListener.h" + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class _DateTimeBarPresenter; + +class _DateTimeBar + : public _Window + , public _IAccessibilityListener + , virtual public Tizen::Ui::_ITouchFlickGestureEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ +public: + virtual ~_DateTimeBar(void); + static _DateTimeBar* CreateDateTimeBarN(void); + +public: + result SetPositionAndAlignment(const Tizen::Graphics::Point& point, _DateTimeBarAlignment alignment); + + result SetInitialValue(int minValue, int maxValue, int displayValue, _DateTimeId boxId); + result RemoveAllItems(void); + + _DateTimeId GetSelectedBoxId(void) const; + + int GetItemCount(void) const; + + _DateTimeBarAlignment GetAlignment(void) const; + + result AddActionEventListener(const _IActionEventListener& listener); + result RemoveActionEventListener(const _IActionEventListener& listener); + + result AddDateTimeChangeEventListener(const _IDateTimeChangeEventListener& listener); + result RemoveDateTimeChangeEventListener(const _IDateTimeChangeEventListener& listener); + + result CalculateArrowBounds(const Tizen::Graphics::Rectangle& bounds); + + result FireActionEvent(int actionId); + result FireDateTimeChangeEvent(_DateTimeChangeStatus status); + + virtual void OnDraw(void); + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const Tizen::Ui::_Control& control); + virtual result OnAttachingToMainTree(const Tizen::Ui::_Control* pParent); + virtual result OnAttachedToMainTree(void); + virtual result OnDetachingFromMainTree(void); + virtual void OnActivated(void); + virtual void OnDeactivated(void); + virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture); + virtual bool OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture); + void AddAccessibilityElement(const Tizen::Graphics::Rectangle& itemBounds, const Tizen::Base::String& itemText); + void RemoveAllAccessibilityElement(void); + Tizen::Ui::AccessibilityTraits GetAccessibilityTraitValue(); + Tizen::Base::String GetMonthValue(int month) const; + void SetFont(Tizen::Graphics::Font& pFont); + void SetParentWindowBounds(Tizen::Graphics::Rectangle& parentWindowBounds); + Tizen::Graphics::Rectangle GetParentWindowBounds() const; + + // accessibility listener + virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&); + virtual bool OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&); + +private: + _DateTimeBar(void); + + _DateTimeBar(const _DateTimeBar&); + _DateTimeBar& operator =(const _DateTimeBar&); + + void SetAlignment(_DateTimeBarAlignment alignment); + void SetSelectedBoxId(_DateTimeId boxId); + void InitializeAccessibilityElement(void); +private: + _DateTimeBarPresenter* __pDateTimeBarPresenter; + _ActionEvent* __pActionEvent; + + _DateTimeId __selectedBoxId; + _DateTimeBarAlignment __alignment; + _DateTimeChangeEvent* __pDateTimeChangeEvent; + _TouchFlickGestureDetector* __pGestureFlick; + Tizen::Base::Collection::LinkedListT<_AccessibilityElement*> __accessibilityElements; + Tizen::Graphics::Rectangle __parentWindowBounds; +}; // _DateTimeBar + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_DATETIME_BAR_H_ diff --git a/src/ui/inc/FUiCtrl_DateTimeBarItem.h b/src/ui/inc/FUiCtrl_DateTimeBarItem.h new file mode 100644 index 0000000..a5f9d22 --- /dev/null +++ b/src/ui/inc/FUiCtrl_DateTimeBarItem.h @@ -0,0 +1,68 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DateTimeBarItem.h + * @brief This is the header file for the _DateTimeBarItem class. + * + * This header file contains the declarations of the %_DateTimeBarItem class. + */ +#ifndef _FUI_CTRL_INTERNAL_DATETIMEBAR_ITEM_H_ +#define _FUI_CTRL_INTERNAL_DATETIMEBAR_ITEM_H_ + +#include "FUi_Control.h" +#include "FUiCtrl_DateTimeDefine.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _DateTimeBarItem + : public Tizen::Base::Object +{ +public: + ~_DateTimeBarItem(void); + +public: + static _DateTimeBarItem* CreateInstanceN(_DateTimeBarAlignment alignment, int itemWidth); + void SetActionId(int actionId); + int GetActionId(void) const; + + void SetText(const Tizen::Base::String& text); + Tizen::Base::String GetText(void) const; + + void SetStatus(_DateTimeBarItemStatus status); + _DateTimeBarItemStatus GetStatus(void) const; + + void SetBounds(const Tizen::Graphics::Rectangle& bounds); + Tizen::Graphics::Rectangle GetBounds(void) const; + +private: + _DateTimeBarItem(void); + + _DateTimeBarItem(const _DateTimeBarItem&); + _DateTimeBarItem& operator =(const _DateTimeBarItem&); + +private: + int __actionId; + Tizen::Base::String __text; + _DateTimeBarItemStatus __status; + Tizen::Graphics::Rectangle __bounds; +}; // _DateTimeBarItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_DATETIMEBAR_ITEM_H_ diff --git a/src/ui/inc/FUiCtrl_DateTimeBarModel.h b/src/ui/inc/FUiCtrl_DateTimeBarModel.h new file mode 100644 index 0000000..fd07c48 --- /dev/null +++ b/src/ui/inc/FUiCtrl_DateTimeBarModel.h @@ -0,0 +1,85 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DateTimeBarModel.h + * @brief This is the implementation file for the _DateTimeBarModel class. + */ + +#ifndef _FUI_CTRL_INTERNAL_DATETIMEBAR_MODEL_H_ +#define _FUI_CTRL_INTERNAL_DATETIMEBAR_MODEL_H_ + +#include "FUiCtrl_DateTimeBarItem.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _DateTimeBarModel + : public Tizen::Base::Object +{ +public: + _DateTimeBarModel(void); + virtual ~_DateTimeBarModel(void); + +public: + static _DateTimeBarModel* CreateInstanceN(void); + + void SetSelectedItemIndex(int index); + int GetSelectedItemIndex(void) const; + + void SetFirstDrawnItemIndex(int index); + int GetFirstDrawnItemIndex(void) const; + + int GetItemCount(void) const; + + result AddItem(const Tizen::Base::String& text, int actionId, _DateTimeBarAlignment alignment, int itemWidth, int margin); + result InsertItemAt(int index, const Tizen::Base::String& text, int actionId, _DateTimeBarAlignment alignment, int itemWidth, int margin); + + result RemoveItemAt(int index); + void RemoveAllItems(void); + + const _DateTimeBarItem* GetItemAt(int index) const; + _DateTimeBarItem* GetItemAt(int index); + + int GetMinimumValue(void) const; + void SetMinimumValue(int minValue); + + int GetMaximumValue(void) const; + void SetMaximumValue(int maxValue); + + int GetMaxCachingSize(void) const; + result SetItemStartPosition(int positionX); + +private: + _DateTimeBarModel(const _DateTimeBarModel&); + + _DateTimeBarModel& operator =(const _DateTimeBarModel&); + +private: + Tizen::Base::Collection::ArrayList __dateTimeBarItems; + + int __selectedItemIndex; + int __firstDrawnItemIndex; + int __minValue; + int __maxValue; + int __maxCachingSize; + int __itemStartPositionX; +}; // _DateTimeBarModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_DATETIMEBAR_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_DateTimeBarPresenter.h b/src/ui/inc/FUiCtrl_DateTimeBarPresenter.h new file mode 100644 index 0000000..a9e74d3 --- /dev/null +++ b/src/ui/inc/FUiCtrl_DateTimeBarPresenter.h @@ -0,0 +1,158 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DateTimeBarPresenter.h + * @brief This is the header file for the _DateTimeBarPresenter class. + * + * This header file contains the declarations of the %_DateTimeBarPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_DATETIMEBAR_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_DATETIMEBAR_PRESENTER_H_ + +#include +#include "FUiCtrl_DateTimeBarModel.h" +#include "FUi_ITouchFlickGestureEventListener.h" +#include "FUiCtrl_FlickAnimation.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +class _DateTimeBar; + +class _DateTimeBarPresenter + : public Tizen::Base::Object + , public Tizen::Base::Runtime::ITimerEventListener +{ +public: + _DateTimeBarPresenter(_DateTimeBar* pDateTimeBar); + virtual ~_DateTimeBarPresenter(void); + +public: + static _DateTimeBarPresenter* CreateInstanceN(_DateTimeBar& dateTimeBar); + void AddFlickAnimationInfo(); + + result CalculateWindowBounds(void); + result LoadArrowBitmap(void); + result Draw(void); + + result AddItems(int actionId); + result RemoveAllItems(void); + + Tizen::Graphics::Rectangle GetBodyBounds(void) const; + void SetArrowBounds(const Tizen::Graphics::Rectangle& bounds); + Tizen::Graphics::Rectangle GetWindowBounds(void) const; + Tizen::Graphics::Rectangle GetArrowBounds(void) const; + + int GetItemCount(void) const; + _DateTimeBarItem* GetItemAt(int index) const; + + int GetFirstDrawnItemIndex(void) const; + + int GetMinimumValue(void) const; + void SetMinimumValue(int minValue); + + int GetMaximumValue(void) const; + void SetMaximumValue(int maxValue); + + int GetItemWidth(void) const; + int GetItemMargin(void) const; + int GetFontSize(void) const; + int GetLeftRightMargin(void) const; + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const Tizen::Ui::_Control& control); + void RefreshAccessibilityElement(void); + virtual bool OnFlickGestureDetected(int distanceX,int distanceY,int duration); + void StartFlickAnimation(void); + void StartAnimationEffect(void); + void SetInitialAnimationValue(int animationValue); + void SetFont(Tizen::Graphics::Font& pFont); + + virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element); + +private: + result AddItem(int actionId); + result InsertItems(int actionId); + result InsertItem(int index, int actionId); + result DeleteItem(int index); + + result DrawItem(Tizen::Graphics::Canvas& canvas); + result DrawBackground(Tizen::Graphics::Canvas& canvas); + result DrawArrow(Tizen::Graphics::Canvas& canvas); + + result SetItemStatus(int index, _DateTimeBarItemStatus status); + _DateTimeBarItemStatus GetItemStatus(int index) const; + + result LoadItems(); + + result StartFlickAnimationTimer(void); + result ResetFlickAnimationTimer(void); + + void SetItemSelected(int index); + int GetSelectedItemIndex(void) const; + + void SetFirstDrawnItemIndex(int index); + int GetItemIndexFromPosition(const Tizen::Graphics::Point& point) const; + + void SetWindowBounds(const Tizen::Graphics::Rectangle& bounds); + void SetBodyBounds(const Tizen::Graphics::Rectangle& bounds); + result AdjustItemPosition(int distance); + + Tizen::Base::String GetDisplayedText(int value) const; + result LoadResource(void); + + _DateTimeBarPresenter(const _DateTimeBarPresenter&); + _DateTimeBarPresenter& operator =(const _DateTimeBarPresenter&); + + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + void ValidateAndAdjustStartPosition(void); + +private: + _DateTimeBar* __pDateTimeBar; + _DateTimeBarModel* __pDateTimeBarModel; + + Tizen::Graphics::Point __currentPoint; + bool __isTouchMoved; + bool __touchMoveHandled; + bool __isFlickEnabled; + int __distance; + Tizen::Base::Runtime::Timer* __pFlickAnimationTimer; + _FlickAnimation __flickAnimation; + Tizen::Base::String __selectedText; + + static const int FLICK_ANIMATION_TIMER_PERIOD = 10; + static const int FLICK_ANIMATION_FPS_DATE_TIME_BAR = 30; + static const int FLICK_ANIMATION_SENSITIVITY_DATE_TIME_BAR = 30; + + Tizen::Graphics::Rectangle __bodyAreaBounds; + Tizen::Graphics::Rectangle __arrowAreaBounds; + Tizen::Graphics::Rectangle __windowAreaBounds; + Tizen::Graphics::Bitmap* __pBgColorReplacementBitmap; + Tizen::Graphics::Bitmap* __pArrowColorReplacementBitmap; + bool __isInitialAnimation; + int __initialAnimationValue; + Tizen::Graphics::Font* __pFont; +}; // _DateTimeBarPresenter + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_DATETIMEBAR_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_DateTimeChangeEvent.h b/src/ui/inc/FUiCtrl_DateTimeChangeEvent.h new file mode 100644 index 0000000..44caa5e --- /dev/null +++ b/src/ui/inc/FUiCtrl_DateTimeChangeEvent.h @@ -0,0 +1,129 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DateTimeChangeEvent.h + * @brief This is the header file for the _DateTimeChangeEvent and _DateTimeChangeEventArg classes. + */ + +#ifndef _FUI_CTRL_INTERNAL_DATETIME_CHANGE_EVENT_H_ +#define _FUI_CTRL_INTERNAL_DATETIME_CHANGE_EVENT_H_ + +#include +#include +#include +#include "FUiCtrl_DateTimeDefine.h" + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _DateTimeChangeEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +public: + _DateTimeChangeEventArg(_DateTimeChangeStatus status); + + ~_DateTimeChangeEventArg(void); + + int GetYear(void) const; + + int GetMonth(void) const; + + int GetDay(void) const; + + int GetHour(void) const; + + int GetMinute(void) const; + + Tizen::Base::DateTime GetDateTime(void) const; + + void SetDateTime(const Tizen::Base::DateTime& dateTime); + + void SetTime(int hour, int minute); + + void SetDate(int year, int month, int day); + + _DateTimeChangeStatus GetStatus(void) const; + +private: + // Attributes + _DateTimeChangeStatus __status; + + int __year; + int __month; + int __day; + int __hour; + int __minute; + + Tizen::Base::DateTime __dateTime; + +}; // _DateTimeChangeEventArg + +/** +* @class _DateTimeChangeEvent +* @brief This class handle a Date change event. +*/ + +class _DateTimeChangeEvent + : public Tizen::Base::Runtime::_Event +{ +public: + /** + * This is the default class constructor. After creating an instance of this + * class, you must explicitly call one of construction methods to initialize + * the instance. + */ + _DateTimeChangeEvent(const Tizen::Ui::_Control& source); + + /** + * This is the class destructor. + */ + virtual ~_DateTimeChangeEvent(void); + + // Operations +protected: + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @return This method returns a result code. + * @param[in] pListener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of __FlashEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + + // Attributes +private: + Tizen::Ui::_Control* __pSource; +}; // _DateTimeChangeEvent + + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_DATETIME_CHANGE_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_DateTimeDefine.h b/src/ui/inc/FUiCtrl_DateTimeDefine.h new file mode 100644 index 0000000..9585253 --- /dev/null +++ b/src/ui/inc/FUiCtrl_DateTimeDefine.h @@ -0,0 +1,166 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DateTimeDefine.h + * @brief This is the header file for DateTimePicker defines. + * + * This header file contains the declarations of the %_DateTime picker define type + */ + +#ifndef _FUI_CTRL_INTERNAL_DATETIME_DEFINE_H_ +#define _FUI_CTRL_INTERNAL_DATETIME_DEFINE_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ +const int DATETIME_YEAR_MAX = 9999; +const int DATETIME_YEAR_MIN = 1; + +const int DATETIME_MONTH_MAX = 12; +const int DATETIME_MONTH_MIN = 1; + +const int DATETIME_DAY_MAX = 31; +const int DATETIME_DAY_MIN = 1; + +const int DATETIME_HOUR_MAX = 23; +const int DATETIME_HOUR_MIN = 0; + +const int DATETIME_MINUTE_MAX = 59; +const int DATETIME_MINUTE_MIN = 0; + +const int DATETIME_SECOND_MAX = 59; +const int DATETIME_SECOND_MIN = 0; + +const int DATETIME_HOUR_MAX_FOR_24NOTATION = 12; + +const int DATETIME_FOUR_DIGIT_MAX = 9999; +const int DATETIME_THREE_DIGIT_MAX = 999; +const int DATETIME_TWO_DIGIT_MAX = 99; +const int DATETIME_ONE_DIGIT_MAX = 9; + +const int DATE_TIME_CHANGE_FOCUS_COUNTER_MIN = 0; +const int DATE_TIME_CHANGE_FOCUS_COUNTER_MAX = 4; + +enum _DateTimeInput +{ + DATETIME_INPUT_BEGIN = 1, + DATETIME_INPUT_END = 2 +}; + +enum _DateTimeOutputStyle +{ + DATETIME_OUTPUT_STYLE_INVALID = 0x0, /**< Invalid Style, for error check */ + DATETIME_OUTPUT_STYLE_DATE = 0x1, /**< DatePicker Style */ + DATETIME_OUTPUT_STYLE_TIME = 0x2, /**< TimePicker Style */ + DATETIME_OUTPUT_STYLE_DATETIME = 0x3 /**< DateTimePicker Style */ +}; + +enum _DateTimeArea +{ + DATETIME_AREA_NONE = 10, + DATETIME_AREA_OUTPUT = 20, + DATETIME_AREA_OUTPUT_AMPM = 30, + DATETIME_AREA_FOOTER = 40, + DATETIME_AREA_INPUT = 50 +}; + +enum _DateTimeEventId +{ + DATETIME_EVENT_ID_SAVE = 0, + DATETIME_EVENT_ID_CANCEL +}; + +enum _DateTimeHeaderId +{ + DATETIME_HEADER_NONE = -1, + DATETIME_HEADER_ID = 0, + DATETIME_HEADER_ID_MAX +}; + +/** +* @enum DateChangeStatus +* Defines constants used to identify date&time change status. +*/ +enum _DateTimeChangeStatus +{ + DATE_INTERNAL_CHANGE_SAVED, + DATE_INTERNAL_CHANGE_CANCELED, + DATETIME_INTERNAL_CHANGE_SAVED, + DATETIME_INTERNAL_CHANGE_CANCELED, + TIME_INTERNAL_CHANGE_SAVED, + TIME_INTERNAL_CHANGE_CANCELED +}; + +enum _DateTimeId +{ + DATETIME_ID_NONE = -1, + DATETIME_ID_YEAR = 0, + DATETIME_ID_MONTH, + DATETIME_ID_DAY, + DATETIME_ID_HOUR, + DATETIME_ID_MINUTE, + DATETIME_ID_MAX, + DATETIME_ID_AMPM = 99 +}; + +enum DateTimePickerStatus +{ + DATETIME_STATUS_NORMAL = 0, + DATETIME_STATUS_SELECTED, + DATETIME_STATUS_FOCUSED, + DATETIME_STATUS_DISABLED, + DATETIME_STATUS_MAX +}; + +enum _DateTimeBarItemStatus +{ + DATETIMEBAR_ITEM_STATUS_NORMAL = 0, + DATETIMEBAR_ITEM_STATUS_SELECTED, + DATETIMEBAR_ITEM_STATUS_MAX +}; + +enum _DateTimeBarAlignment +{ + DATETIME_BAR_ALIGN_DOWN = 0, + DATETIME_BAR_ALIGN_UP +}; + +enum _DateDisplayBoxId +{ + DATE_DISPLAY_BOX_LEFT = 0, + DATE_DISPLAY_BOX_CENTER, + DATE_DISPLAY_BOX_RIGHT, + DATE_DISPLAY_BOX_MAX +}; + +enum _InputPadStyle +{ + INPUTPAD_STYLE_NORMAL = 0, + INPUTPAD_STYLE_ALPHA, + INPUTPAD_STYLE_MAX +}; + +enum _DateFormat +{ + DATE_FORMAT_DDMMYYYY = 0, + DATE_FORMAT_MMDDYYYY, + DATE_FORMAT_YYYYMMDD, + DATE_FORMAT_YYYYDDMM +}; +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_DATETIME_DEFINE_H_ diff --git a/src/ui/inc/FUiCtrl_DateTimeDisplayBox.h b/src/ui/inc/FUiCtrl_DateTimeDisplayBox.h new file mode 100644 index 0000000..70b33c2 --- /dev/null +++ b/src/ui/inc/FUiCtrl_DateTimeDisplayBox.h @@ -0,0 +1,91 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DateTimeDisplayBox.h + * @brief This is the header file for the _DateTimeDisplayBox class. + */ + +#ifndef _FUI_CTRL_INTERNAL_DATETIME_DISPLAY_BOX_H_ +#define _FUI_CTRL_INTERNAL_DATETIME_DISPLAY_BOX_H_ + +#include +#include "FUiCtrl_DateTimeDefine.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _DateTimeDisplayBox + : public Tizen::Base::Object +{ +public: + _DateTimeDisplayBox(const Tizen::Graphics::Rectangle& bounds, int boxId); + + virtual ~_DateTimeDisplayBox(void); + + void DrawDisplayBox(Tizen::Graphics::Canvas& canvas, DateTimePickerStatus status); + + Tizen::Graphics::Rectangle GetDisplayBoxBounds(void) const; + + bool SetText(const Tizen::Base::String& text); + + const Tizen::Base::String& GetText(void) const; + + int GetDisplayBoxId(void) const; + + void SetFocusable(bool focusable); + + void SetBackgroundBitmap(Tizen::Graphics::Bitmap* pNormalBitmap, Tizen::Graphics::Bitmap* pEffectBitmap, + Tizen::Graphics::Bitmap* pPressedEffectBitmap, Tizen::Graphics::Bitmap* pDisabledEffectBitmap); + + void UpdateDisplayBoxBounds(Tizen::Graphics::Rectangle& bounds); + + void SetFont(Tizen::Graphics::Font* pFont); + +protected: + void DrawBackground(Tizen::Graphics::Canvas& canvas, DateTimePickerStatus status); + + void DrawText(Tizen::Graphics::Canvas& canvas, DateTimePickerStatus status); + +private: + _DateTimeDisplayBox(const _DateTimeDisplayBox&); + + _DateTimeDisplayBox& operator =(const _DateTimeDisplayBox&); + +private: + Tizen::Graphics::Rectangle __windowBounds; + + int __boxId; + + Tizen::Graphics::_Text::TextObject* __pTextObject; + + Tizen::Base::String __text; + + bool __focusable; + + Tizen::Graphics::Color __backgroundColor[DATETIME_STATUS_MAX]; + Tizen::Graphics::Color __textColor[DATETIME_STATUS_MAX]; + + Tizen::Graphics::Font* __pFont; + Tizen::Graphics::Bitmap* __pBackgroundNormalBitmap[DATETIME_STATUS_MAX]; + Tizen::Graphics::Bitmap* __pBackgroundEffectBitmap; + Tizen::Graphics::Bitmap* __pBackgroundPressedEffectBitmap; + Tizen::Graphics::Bitmap* __pBackgroundDisabledEffectBitmap; +}; // _DateTimeDisplayBox + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_DATETIME_DISPLAY_BOX_H_ diff --git a/src/ui/inc/FUiCtrl_DateTimeModel.h b/src/ui/inc/FUiCtrl_DateTimeModel.h new file mode 100644 index 0000000..edbec95 --- /dev/null +++ b/src/ui/inc/FUiCtrl_DateTimeModel.h @@ -0,0 +1,89 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DateTimeModel.h + * @brief This is the header file for the _DateTimeModel class. + */ + +#ifndef _FUI_CTRL_INTERNAL_DATETIME_MODEL_H_ +#define _FUI_CTRL_INTERNAL_DATETIME_MODEL_H_ + +#include +#include +#include +#include "FUiCtrl_DateTimeDefine.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _DateTimeModel + : public Tizen::Base::Object +{ +public: + _DateTimeModel(void); + virtual ~_DateTimeModel(void); + +public: + result SetYear(int year); + int GetYear(void) const; + + result SetMonth(int month); + int GetMonth(void) const; + + result SetDay(int day); + int GetDay(void) const; + + result SetHour(int hour); + int GetHour(void) const; + + result SetMinute(int minute); + int GetMinute(void) const; + + result SetMaxYear(int maxYear); + result SetMinYear(int minYear); + result GetYearRange(int& minYear, int& maxYear) const; + + void SetCurrentDateTime(void); + + void SetDateTime(const Tizen::Base::DateTime& time); + Tizen::Base::DateTime GetDateTime(void) const; + +private: + _DateTimeModel(const _DateTimeModel&); + + _DateTimeModel& operator =(const _DateTimeModel&); + + void SetSecond(int second); + int GetSecond(void) const; + +private: + int __year; + int __month; + int __day; + + int __maxYear; + int __minYear; + + int __hour; + int __minute; + int __second; + +}; // _DateTimeModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_DATETIME_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_DateTimePicker.h b/src/ui/inc/FUiCtrl_DateTimePicker.h new file mode 100644 index 0000000..2e859f6 --- /dev/null +++ b/src/ui/inc/FUiCtrl_DateTimePicker.h @@ -0,0 +1,196 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DateTimePicker.h + * @brief This is the header file for the _DateTimePicker class. + */ + +#ifndef _FUI_CTRL_INTERNAL_DATETIMEPICKER_H_ +#define _FUI_CTRL_INTERNAL_DATETIMEPICKER_H_ + +#include +#include +#include + +#include "FUi_Window.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_DateTimeDefine.h" +#include "FUiAnim_VisualElement.h" +#include "FUi_IAccessibilityListener.h" + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +//class _IAccessibilityListener; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _DateTimePresenter; +class _DateTimeChangeEvent; +class _IDateTimeChangeEventListener; +class _Toolbar; + +class _DateTimePicker + : public Tizen::Ui::_Window + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer + , virtual public Tizen::Ui::_IAccessibilityListener +{ + DECLARE_CLASS_BEGIN(_DateTimePicker, _Control); + DECLARE_PROPERTY("year", GetPropertyYear, SetPropertyYear); + DECLARE_PROPERTY("month", GetPropertyMonth, SetPropertyMonth); + DECLARE_PROPERTY("day", GetPropertyDay, SetPropertyDay); + DECLARE_PROPERTY("hour", GetPropertyHour, SetPropertyHour); + DECLARE_PROPERTY("minute", GetPropertyMinute, SetPropertyMinute); + DECLARE_PROPERTY("24hourNotation", GetProperty24HourNotation, SetProperty24HourNotation); + DECLARE_PROPERTY("minYearRange", GetPropertyMinYearRange, SetPropertyMinYearRange); + DECLARE_PROPERTY("maxYearRange", GetPropertyMaxYearRange, SetPropertyMaxYearRange); + DECLARE_PROPERTY("dateTime", GetPropertyDateTime, SetPropertyDateTime); + DECLARE_CLASS_END(); + + result SetPropertyYear(const Tizen::Ui::Variant& year); + Tizen::Ui::Variant GetPropertyYear(void) const; + + result SetPropertyMonth(const Tizen::Ui::Variant& month); + Tizen::Ui::Variant GetPropertyMonth(void) const; + + result SetPropertyDay(const Tizen::Ui::Variant& day); + Tizen::Ui::Variant GetPropertyDay(void) const; + + result SetPropertyHour(const Tizen::Ui::Variant& hour); + Tizen::Ui::Variant GetPropertyHour(void) const; + + result SetPropertyMinute(const Tizen::Ui::Variant& minute); + Tizen::Ui::Variant GetPropertyMinute(void) const; + + result SetProperty24HourNotation(const Tizen::Ui::Variant& enable); + Tizen::Ui::Variant GetProperty24HourNotation(void) const; + + result SetPropertyMinYearRange(const Tizen::Ui::Variant& minYear); + Tizen::Ui::Variant GetPropertyMinYearRange(void) const; + + result SetPropertyMaxYearRange(const Tizen::Ui::Variant& maxYear); + Tizen::Ui::Variant GetPropertyMaxYearRange(void) const; + + result SetPropertyDateTime(const Tizen::Ui::Variant& dateTime); + Tizen::Ui::Variant GetPropertyDateTime(void) const; + +public: + virtual ~_DateTimePicker(void); + + static _DateTimePicker* CreateDateTimePickerN(int style, const Tizen::Base::String& title = L""); + +public: + result AddDateTimeChangeEventListener(const _IDateTimeChangeEventListener& listener); + result RemoveDateTimeChangeEventListener(const _IDateTimeChangeEventListener& listener); + result FireDateTimeChangeEvent(_DateTimeChangeStatus status, Tizen::Base::DateTime& dateTime); + + result SetYear(int year); + int GetYear(void) const; + + result SetMonth(int month); + int GetMonth(void) const; + + result SetDay(int day); + int GetDay(void) const; + + result SetHour(int hour); + int GetHour(void) const; + + result SetMinute(int minute); + int GetMinute(void) const; + + void Set24HourNotationEnabled(bool enable); + bool Is24HourNotationEnabled(void) const; + + result SetYearRange(int minYear, int maxYear); + result GetYearRange(int& minYear, int& maxYear) const; + + void SetDateTime(const Tizen::Base::DateTime& dateTime); + Tizen::Base::DateTime GetDateTime(void) const; + + void SetCurrentDateTime(void); + + void SetFocusBoxId(int boxId); + + void SetAccessibilityElementText(int index, const Tizen::Base::String& text, bool isAmPm); + + virtual result OnAttachedToMainTree(void); + virtual void OnDraw(void); + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + + virtual bool OnAccessibilityFocusMovedNext(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusMovedPrevious(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityReadElement(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusIn(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusOut(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityActionPerformed(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + Tizen::Graphics::Font* GetDateTimeFont(void); + result InitializeFont(void); + + result CreateHeader(void); + result DestroyHeader(void); + result CreateFooter(void); + result DestroyFooter(void); + + Tizen::Graphics::Rectangle GetHeaderBounds(void); + + result CreateDisplayVisualElement(void); + void SetDisplayVisualElementBounds(Tizen::Graphics::Rectangle bounds); + Tizen::Ui::Animations::_VisualElement* GetDisplayVisualElement(void); + +private: + _DateTimePicker(_DateTimePresenter* pPresenter, const Tizen::Base::String& title = L""); + + _DateTimePicker(const _DateTimePicker&); + _DateTimePicker& operator =(const _DateTimePicker&); + +private: + _DateTimePresenter* __pPresenter; + + _Toolbar* __pHeader; + _Toolbar* __pFooter; + Tizen::Base::String __title; + + _DateTimeChangeEvent* __pDateTimeChangeEvent; + + Tizen::Graphics::Font* __pFont; + + Tizen::Ui::Animations::_VisualElement* __pDisplayVisualElement; + + Tizen::Base::Collection::LinkedListT __accessibilityElements; +}; // _DateTimePicker + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_DATETIMEPICKER_H_ diff --git a/src/ui/inc/FUiCtrl_DateTimePickerImpl.h b/src/ui/inc/FUiCtrl_DateTimePickerImpl.h new file mode 100644 index 0000000..63d88f3 --- /dev/null +++ b/src/ui/inc/FUiCtrl_DateTimePickerImpl.h @@ -0,0 +1,105 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DateTimePickerImpl.h + * @brief This is the header file for the _DateTimePickerImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_DATETIMEPICKER_IMPL_H_ +#define _FUI_CTRL_INTERNAL_DATETIMEPICKER_IMPL_H_ + +#include +#include "FUi_WindowImpl.h" +#include "FUiCtrl_DateTimePicker.h" +#include "FUiCtrl_IDateTimeChangeEventListener.h" +#include "FUiCtrl_PublicDateTimeChangeEvent.h" + +namespace Tizen { namespace Ui +{ +class IDateTimeChangeEventListener; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _DateTimePickerImpl + : public _WindowImpl + , public _IDateTimeChangeEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + class DateTimePickerSizeInfo : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + virtual Tizen::Graphics::Dimension GetDefaultMaximumSize(_ControlOrientation orientation) const; + }; +public: + static _DateTimePickerImpl* CreateDateTimePickerImplN(DateTimePicker* pControl, const Tizen::Base::String& title = L""); + virtual ~_DateTimePickerImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const DateTimePicker& GetPublic(void) const; + virtual DateTimePicker& GetPublic(void); + virtual const _DateTimePicker& GetCore(void) const; + virtual _DateTimePicker& GetCore(void); + + result AddDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener); + result RemoveDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener); + + void SetDateTime(const Tizen::Base::DateTime& dateTime); + Tizen::Base::DateTime GetDateTime(void) const; + + void SetCurrentDateTime(void); + result SetYear(int year); + int GetYear(void) const; + result SetMonth(int month); + int GetMonth(void) const; + result SetDay(int day); + int GetDay(void) const; + result SetHour(int hour); + int GetHour(void) const; + result SetMinute(int minute); + int GetMinute(void) const; + + void Set24HourNotationEnabled(bool enable); + bool Is24HourNotationEnabled(void) const; + + result SetYearRange(int minYear, int maxYear); + result GetYearRange(int& minYear, int& maxYear) const; + + virtual result OnAttachedToMainTree(void); + virtual void OnDateTimeChanged(const Tizen::Ui::_Control& source, int year, int month, int day, int hour, int minute); + virtual void OnDateTimeChangeCanceled(const Tizen::Ui::_Control& source); + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + +public: + static _DateTimePickerImpl* GetInstance(DateTimePicker& dateTimePicker); + static const _DateTimePickerImpl* GetInstance(const DateTimePicker& dateTimePicker); + +private: + _DateTimePickerImpl(DateTimePicker* pPublic, _DateTimePicker* pCore); + + _DateTimePickerImpl(const _DateTimePickerImpl&); + _DateTimePickerImpl& operator =(const _DateTimePickerImpl&); + +private: + _PublicDateTimeChangeEvent* __pPublicDateTimeChangeEvent; +}; // _DateTimePickerImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_DATETIMEPICKER_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_DateTimePresenter.h b/src/ui/inc/FUiCtrl_DateTimePresenter.h new file mode 100644 index 0000000..0072f54 --- /dev/null +++ b/src/ui/inc/FUiCtrl_DateTimePresenter.h @@ -0,0 +1,221 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_DateTimePresenter.h + * @brief This is the header file for the _DateTimePresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_DATETIME_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_DATETIME_PRESENTER_H_ + +#include +#include "FUi_Control.h" +#include "FUiCtrl_DateTimeDefine.h" +#include "FUiCtrl_IInputPadEventListener.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +class _DateTimePicker; +class _DateTimeDisplayBox; +class _DateTimeModel; +class _InputPad; +}}} // Tizen::Ui::Controls + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _DateTimePresenter + : public _IInputPadEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + _DateTimePresenter(int pickerStyle, const Tizen::Base::String& title = L""); + + virtual ~_DateTimePresenter(void); + + result Construct(_DateTimePicker& view); + + result SetYear(int year); + + result SetMonth(int month); + + result SetDay(int day); + + result SetHour(int hour); + + result SetMinute(int minute); + + result SetYearRange(int minYear, int maxYear); + + int GetYear(void) const; + + int GetMonth(void) const; + + int GetDay(void) const; + + int GetHour(void) const; + + int GetMinute(void) const; + + result GetYearRange(int& minYear, int& maxYear) const; + + void Set24HourNotationEnabled(bool enable); + + bool Is24HourNotationEnabled(void) const; + + void SetCurrentDateTime(void); + + void SetDateTime(const Tizen::Base::DateTime& dateTime); + + Tizen::Base::DateTime GetDateTime(void) const; + + void SetFocusBoxId(int boxId); + + const _DateTimeDisplayBox* GetDisplayBox(int index) const; + + const _DateTimeDisplayBox* GetAmPmBox(void) const; + + bool Draw(void); + + result SetFont(Tizen::Graphics::Font* pFont); + + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + virtual void OnInputPadValueChanged(const Tizen::Ui::_Control& source, int inputPadReturnValue); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + +private: + void UpdateDateTimeOutputConfig(void); + + void LoadResource(void); + + void DrawColon(Tizen::Graphics::Canvas& canvas); + + void DrawDateTimeDisplayBox(Tizen::Graphics::Canvas& canvas, int index); + + void DrawPm(Tizen::Graphics::Canvas& canvas); + + void DrawDividers(Tizen::Graphics::Canvas& canvas); + + void ChangeInputPadStyle(int boxId); + + Tizen::Graphics::Rectangle GetOutputArea(void); + + int CalculateTouchArea(int posX, int posY); + + int CalculateTouchOutputArea(int posX, int posY); + + int CalculateTwoDigit(int originalNumber, int number); + + int CalculateFourDigit(int originalNumber, int number); + + int SetTwoDigit(int originalNumber, int number); + + int SetFourDigit(int originalNumber, int number); + + void SetNumberInBox(int boxId, int number); + + int GetNumberInBox(int boxId) const; + + void SetFocusBox(int index); + + void LoadPickerData(void); + + void SavePickerData(void); + + void UpdateDisplayData(int boxId); + + void AdjustDisplayValue(int index); + + void AdjustValue(int& value, int minValue, int maxValue); + + void ChangeFocusBox(void); + + int GetLocaleDateFormat(void) const; + + void SetAccessibilityElementText(void); + +private: + _DateTimePresenter(const _DateTimePresenter&); + + _DateTimePresenter& operator =(const _DateTimePresenter&); + + void Dispose(void); + +private: + _DateTimePicker* __pView; + + _DateTimeModel* __pModel; + + int __selectedBoxIndex; + + int __focusedBoxIndex; + + _InputPad* __pInputPad; + + _InputPadStyle __inputPadType; + + int __pickerStyle; + + bool __inputPadEnabled; + + int __outputBoxMaxCount; + + int __year; + + int __month; + + int __day; + + int __hour; + + int __minute; + + bool __is24HourNotation; + + bool __isPm; + + bool __isPmButtonPressed; + + bool __isFocusBoxChanged; + + int __inputComposing; + + int __changeFocusCounter; + + Tizen::Graphics::Bitmap* __pPmBoxNormalBitmap; + Tizen::Graphics::Bitmap* __pPmBoxEffectBitmap; + Tizen::Graphics::Bitmap* __pPmBoxPressedEffectBitmap; + Tizen::Graphics::Bitmap* __pPmBoxDisabledEffectBitmap; + Tizen::Graphics::Bitmap* __pColonBitmap; + + Tizen::Graphics::Font* __pFont; + + _DateTimeDisplayBox* __pDisplayBox[DATETIME_ID_MAX]; + + _DateTimeDisplayBox* __pPmBox; +}; // _DateTimePresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_DATETIME_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_DateTimeUtils.h b/src/ui/inc/FUiCtrl_DateTimeUtils.h new file mode 100644 index 0000000..a554214 --- /dev/null +++ b/src/ui/inc/FUiCtrl_DateTimeUtils.h @@ -0,0 +1,54 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DateTimeUtils.h + * @brief This is the header file for the _DateTimeUtils class. + */ + +#ifndef _FUI_CTRL_INTERNAL_DATETIME_UTILS_H_ +#define _FUI_CTRL_INTERNAL_DATETIME_UTILS_H_ + +#include "FUi_Control.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +class _DateTimeUtils + : public Tizen::Base::Object +{ +// Lifecycle +public: + _DateTimeUtils(void); + + virtual ~_DateTimeUtils(void); + +// Operations +public: + const Tizen::Base::String GetMonthString(int month) const; + int CalculateMaxDay(int displayYear, int month) const ; + bool IsLeapYear(int year) const; + +private: + _DateTimeUtils(const _DateTimeUtils&); + + _DateTimeUtils& operator =(const _DateTimeUtils&); + +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_DATETIME_UTILS_H_ diff --git a/src/ui/inc/FUiCtrl_DimmingLayer.h b/src/ui/inc/FUiCtrl_DimmingLayer.h new file mode 100644 index 0000000..a0a11e1 --- /dev/null +++ b/src/ui/inc/FUiCtrl_DimmingLayer.h @@ -0,0 +1,64 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_DimmingLayer.h + * @brief This is the header file for the _DimmingLayer class. + * + * This header file contains the declarations of the _DimmingLayer class. + */ + + +#ifndef _FUICTRL_INTERNAL_DIMMINGLAYER_H_ +#define _FUICTRL_INTERNAL_DIMMINGLAYER_H_ + + +#include + +#include "FUi_Control.h" +#include "FUiAnim_VisualElement.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _DimmingLayer + : public Tizen::Base::Object +{ +public: + _DimmingLayer(void); + virtual ~_DimmingLayer(void); + + result Construct(_Control& control); + result SetOpacity(float opacity); + float GetOpacity(void) const; + result SetDimmingEnabled(bool enabled); + bool GetDimmingEnabled(void) const; + result Rearrange(void); + +private: + _DimmingLayer(const _DimmingLayer& rhs); /* no impl. */ + _DimmingLayer& operator =(const _DimmingLayer& rhs); /* no impl. */ + + bool __enabled; + Tizen::Ui::_Control* __pControl; + Tizen::Ui::Animations::_ControlVisualElement* __pDimmingElement; + Tizen::Ui::Animations::VisualElement::RenderOperation __oldControlRenderOperation; +}; + +}}} // Tizen::Ui::Controls + +#endif /* _FUICTRL_INTERNAL_DIMMINGLAYER_H_ */ diff --git a/src/ui/inc/FUiCtrl_Edit.h b/src/ui/inc/FUiCtrl_Edit.h new file mode 100644 index 0000000..5ac4644 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Edit.h @@ -0,0 +1,533 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Edit.h + * @brief This is the header file for the _Edit class. + * + * This header file contains the declarations of the %_Edit class. + */ + +#ifndef _FUI_CTRL_INTERNAL_EDIT_H_ +#define _FUI_CTRL_INTERNAL_EDIT_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_Control.h" +#include "FUi_ITouchFlickGestureEventListener.h" +#include "FUi_ITouchLongPressGestureEventListener.h" +#include "FUi_ITouchTapGestureEventListener.h" +#include "FUi_ResourceManager.h" +#include "FUi_TouchFlickGestureDetector.h" +#include "FUi_TouchLongPressGestureDetector.h" +#include "FUi_TouchTapGestureDetector.h" +#include "FUiCtrl_ExpandableEditAreaEvent.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_IExpandableEditAreaEventListener.h" +#include "FUiCtrl_IKeypadEventListener.h" +#include "FUiCtrl_ITextBlockEventListener.h" +#include "FUiCtrl_ITextEventListener.h" +#include "FUiCtrl_ILanguageEventListener.h" +#include "FUiCtrl_IScrollPanelEventListener.h" +#include "FUiCtrl_IUiLinkEventListener.h" +#include "FUiCtrl_KeypadEvent.h" +#include "FUiCtrl_LanguageEvent.h" +#include "FUiCtrl_LinkEvent.h" +#include "FUiCtrl_ScrollPanelEvent.h" +#include "FUiCtrl_TextBlockEvent.h" +#include "FUiCtrl_TextEvent.h" + + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +}}} + +namespace Tizen { namespace Ui { namespace Controls +{ + +struct EditColor +{ + Tizen::Graphics::Color textColor; + Tizen::Graphics::Color titleTextColor; + Tizen::Graphics::Color backgroundColor; +}; + +struct EditBlockTextColor +{ + bool used; + Tizen::Graphics::Color blockTextColor; +}; + +struct EditCutlinkColor +{ + Tizen::Graphics::Color cutlinkFgColor; + Tizen::Graphics::Color cutlinkBgColor; +}; + +enum EditCutLinkType +{ + EDIT_LINK_TYPE_INVALID = -1, + EDIT_LINK_TYPE_URL, + EDIT_LINK_TYPE_EMAIL, + EDIT_LINK_TYPE_PHONE_NUM, + EDIT_LINK_TYPE_STREAMING_URL, + EDIT_LINK_TYPE_MAX +}; + +enum EditTextHorizontalMargin +{ + EDIT_TEXT_LEFT_MARGIN, + EDIT_TEXT_RIGHT_MARGIN, + EDIT_TEXT_HORIZONTAL_MARGIN +}; + +enum EditTextVerticalMargin +{ + EDIT_TEXT_TOP_MARGIN, + EDIT_TEXT_BOTTOM_MARGIN, + EDIT_TEXT_VERTICAL_MARGIN +}; + +enum EditAccessibilityElementType +{ + EDIT_ACCESSIBILITY_ELEMENT_TYPE_TITLE_TEXT, + EDIT_ACCESSIBILITY_ELEMENT_TYPE_TEXT, + EDIT_ACCESSIBILITY_ELEMENT_TYPE_CLEAR_ICON +}; + +const int EDIT_STYLE_SINGLE_LINE = 0x00000001; +const int EDIT_STYLE_NORMAL = 0x00000002; +const int EDIT_STYLE_BORDER = 0x00000004; +const int EDIT_STYLE_TITLE_LEFT = 0x00000010; +const int EDIT_STYLE_TITLE_TOP = 0x00000020; +const int EDIT_STYLE_PASSWORD = 0x00000100; +const int EDIT_STYLE_VIEWER = 0x00000200; +const int EDIT_STYLE_NOSCROLL = 0x00000400; +const int EDIT_STYLE_CLEAR = 0x00001000; +const int EDIT_STYLE_ICON_EMBEDDED = 0x00010000; +const int EDIT_STYLE_DASHBOARD_EMBEDDED = 0x00100000; +const int EDIT_STYLE_FLEXIBLE = 0x01000000; +const int EDIT_STYLE_TOKEN = 0x02000000; +const int EDIT_COLOR_OPACITY = 100; +const int EDIT_AREA_DEFAULT_LIMIT_LENGTH = 1000; +const int EDIT_FIELD_DEFAULT_LIMIT_LENGTH = 100; + +const int EDIT_COLOR_MAX = 4; +const int EDIT_TEXT_COLOR_MAX = 4; +const int EDIT_MARGIN_COUNT_MAX = 2; +const int DEFAULT_LINE_SPACE = 1; + +/** + * @class _Edit + * @brief + * @since 2.0 + */ + +class _EditPresenter; +class _Form; +class _ScrollPanelItemEvent; +class _EditInternalTouchEventListener; +class _Toolbar; + +class _OSP_EXPORT_ _Edit + : public _Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer + , virtual public Tizen::Ui::_ITouchGestureEventListener + , public _ITouchFlickGestureEventListener + , public _ITouchLongPressGestureEventListener + , public _ITouchTapGestureEventListener + , public IClipboardPopupEventListener +{ +public: + DECLARE_CLASS_BEGIN(_Edit, _Control); + DECLARE_PROPERTY("autoResizingEnabled", GetPropertyAutoResizingEnabled, SetPropertyAutoResizingEnabled); + DECLARE_PROPERTY("guideTextColor", GetPropertyGuideTextColor, SetPropertyGuideTextColor); + DECLARE_PROPERTY("normalColor", GetPropertyNormalColor, SetPropertyNormalColor); + DECLARE_PROPERTY("disabledColor", GetPropertyDisabledColor, SetPropertyDisabledColor); + DECLARE_PROPERTY("highlightedColor", GetPropertyHighlightedColor, SetPropertyHighlightedColor); + DECLARE_PROPERTY("pressedColor", GetPropertyPressedColor, SetPropertyPressedColor); + DECLARE_PROPERTY("normalTextColor", GetPropertyNormalTextColor, SetPropertyNormalTextColor); + DECLARE_PROPERTY("disabledTextColor", GetPropertyDisabledTextColor, SetPropertyDisabledTextColor); + DECLARE_PROPERTY("highlightedTextColor", GetPropertyHighlightedTextColor, SetPropertyHighlightedTextColor); + DECLARE_PROPERTY("pressedTextColor", GetPropertyPressedTextColor, SetPropertyPressedTextColor); + DECLARE_PROPERTY("lineSpacing", GetPropertyLineSpacing, SetPropertyLineSpacing); + DECLARE_PROPERTY("textSize", GetPropertyTextSize, SetPropertyTextSize); + DECLARE_PROPERTY("cursorPosition", GetPropertyCursorPosition, SetPropertyCursorPosition); + DECLARE_PROPERTY("guideText", GetPropertyGuideText, SetPropertyGuideText); + DECLARE_PROPERTY("keypadActionEnabled", GetPropertyKeypadActionEnabled, SetPropertyKeypadActionEnabled); + DECLARE_PROPERTY("keypadAction", GetPropertyKeypadAction, SetPropertyKeypadAction); + DECLARE_PROPERTY("keypadEnabled", GetPropertyKeypadEnabled, SetPropertyKeypadEnabled); + DECLARE_PROPERTY("keypadStyle", GetPropertyKeypadStyle, SetPropertyKeypadStyle); + DECLARE_PROPERTY("lowerCaseModeEnabled", GetPropertyLowerCaseModeEnabled, SetPropertyLowerCaseModeEnabled); + DECLARE_PROPERTY("overlayKeypadCommandButtonVisible", GetPropertyOverlayKeypadCommandButtonVisible, SetPropertyOverlayKeypadCommandButtonVisible); + DECLARE_PROPERTY("text", GetPropertyText, SetPropertyText); + DECLARE_PROPERTY("viewModeEnabled", GetPropertyViewModeEnabled, SetPropertyViewModeEnabled); + DECLARE_PROPERTY("autoLinkMask", GetPropertyAutoLinkMask, SetPropertyAutoLinkMask); + DECLARE_PROPERTY("titleText", GetPropertyTitleText, SetPropertyTitleText); + DECLARE_PROPERTY("normalTitleTextColor", GetPropertyNormalTitleTextColor, SetPropertyNormalTitleTextColor); + DECLARE_PROPERTY("disabledTitleTextColor", GetPropertyDisabledTitleTextColor, SetPropertyDisabledTitleTextColor); + DECLARE_PROPERTY("highlightedTitleTextColor", GetPropertyHighlightedTitleTextColor, SetPropertyHighlightedTitleTextColor); + DECLARE_PROPERTY("pressedTitleTextColor", GetPropertyPressedTitleTextColor, SetPropertyPressedTitleTextColor); + DECLARE_PROPERTY("blockedTextColor", GetPropertyBlockedTextColor, SetPropertyBlockedTextColor); + DECLARE_PROPERTY("topMargin", GetPropertyTopMargin, SetPropertyTopMargin); + DECLARE_PROPERTY("bottomMargin", GetPropertyBottomMargin, SetPropertyBottomMargin); + DECLARE_PROPERTY("leftMargin", GetPropertyLeftMargin, SetPropertyLeftMargin); + DECLARE_PROPERTY("rightMargin", GetPropertyRightMargin, SetPropertyRightMargin); + DECLARE_CLASS_END(); + + result SetPropertyAutoResizingEnabled(const Variant& enable); + result SetPropertyGuideTextColor(const Variant& color); + result SetPropertyNormalColor(const Variant& color); + result SetPropertyDisabledColor(const Variant& color); + result SetPropertyHighlightedColor(const Variant& color); + result SetPropertyPressedColor(const Variant& color); + result SetPropertyNormalTextColor(const Variant& color); + result SetPropertyDisabledTextColor(const Variant& color); + result SetPropertyHighlightedTextColor(const Variant& color); + result SetPropertyPressedTextColor(const Variant& color); + result SetPropertyLineSpacing(const Variant& lineSpacing); + result SetPropertyTextSize(const Variant& textSize); + result SetPropertyCursorPosition(const Variant& position); + result SetPropertyGuideText(const Variant& guideText); + result SetPropertyKeypadActionEnabled(const Variant& enabled); + result SetPropertyKeypadAction(const Variant& action); + result SetPropertyKeypadEnabled(const Variant& enabled); + result SetPropertyKeypadStyle(const Variant& style); + result SetPropertyLowerCaseModeEnabled(const Variant& enabled); + result SetPropertyOverlayKeypadCommandButtonVisible(const Variant& visible); + result SetPropertyText(const Variant& text); + result SetPropertyViewModeEnabled(const Variant& enabled); + result SetPropertyAutoLinkMask(const Variant& autoLinks); + result SetPropertyTitleText(const Variant& titleText); + result SetPropertyNormalTitleTextColor(const Variant& color); + result SetPropertyDisabledTitleTextColor(const Variant& color); + result SetPropertyHighlightedTitleTextColor(const Variant& color); + result SetPropertyPressedTitleTextColor(const Variant& color); + result SetPropertyBlockedTextColor(const Variant& color); + result SetPropertyTopMargin(const Variant& margin); + result SetPropertyBottomMargin(const Variant& margin); + result SetPropertyLeftMargin(const Variant& margin); + result SetPropertyRightMargin(const Variant& margin); + + Variant GetPropertyAutoResizingEnabled(void) const; + Variant GetPropertyGuideTextColor(void) const; + Variant GetPropertyNormalColor(void) const; + Variant GetPropertyDisabledColor(void) const; + Variant GetPropertyHighlightedColor(void) const; + Variant GetPropertyPressedColor(void) const; + Variant GetPropertyNormalTextColor(void) const; + Variant GetPropertyDisabledTextColor(void) const; + Variant GetPropertyHighlightedTextColor(void) const; + Variant GetPropertyPressedTextColor(void) const; + Variant GetPropertyLineSpacing(void) const; + Variant GetPropertyTextSize(void) const; + Variant GetPropertyCursorPosition(void) const; + Variant GetPropertyGuideText(void) const; + Variant GetPropertyKeypadActionEnabled(void) const; + Variant GetPropertyKeypadAction(void) const; + Variant GetPropertyKeypadEnabled(void) const; + Variant GetPropertyKeypadStyle(void) const; + Variant GetPropertyLowerCaseModeEnabled(void) const; + Variant GetPropertyOverlayKeypadCommandButtonVisible(void) const; + Variant GetPropertyText(void) const; + Variant GetPropertyViewModeEnabled(void) const; + Variant GetPropertyAutoLinkMask(void) const; + Variant GetPropertyTitleText(void) const; + Variant GetPropertyNormalTitleTextColor(void) const; + Variant GetPropertyDisabledTitleTextColor(void) const; + Variant GetPropertyHighlightedTitleTextColor(void) const; + Variant GetPropertyPressedTitleTextColor(void) const; + Variant GetPropertyBlockedTextColor(void) const; + Variant GetPropertyTopMargin(void) const; + Variant GetPropertyBottomMargin(void) const; + Variant GetPropertyLeftMargin(void) const; + Variant GetPropertyRightMargin(void) const; + +public: + _Edit(void); + virtual ~_Edit(void); + + static _Edit* CreateEditN(void); + virtual result Initialize(int editStyle, InputStyle inputStyle, int limitLength, GroupStyle groupStyle = GROUP_STYLE_NONE); + + result SetAutoLinkMask(unsigned long autoLinks); + result SetAutoResizingEnabled(bool enable); + result SetBackgroundBitmap(EditStatus status, const Tizen::Graphics::Bitmap& bitmap); + result SetBlockRange(int start, int end); + result SetBlockTextColor(const Tizen::Graphics::Color& color); + result SetColor(EditStatus status, const Tizen::Graphics::Color& color); + result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode); + result SetCursorPosition(int position); + void SetCutlinkColorInfo(EditCutLinkType type, EditCutlinkColor colorInfo); + void SetEllipsisPosition(EllipsisPosition position); + result SetFont(const Tizen::Graphics::Font& font); + result SetFontType(const Tizen::Base::String& typefaceName, unsigned long styleMask); + result SetTextStyle(unsigned long style); + void SetGuideText(const Tizen::Base::String& guideText); + result SetGuideTextColor(const Tizen::Graphics::Color& color); + result SetHorizontalMargin(int margin, EditTextHorizontalMargin marginType = EDIT_TEXT_HORIZONTAL_MARGIN); + result SetKeypadAction(CoreKeypadAction keypadAction); + result SetKeypadActionEnabled(bool enabled); + void SetKeypadEnabled(bool enable); + result SetKeypadStyle(KeypadStyle keypadStyle); + result SetKeypadNormalNumberStyle(bool enable); + result SetTextPredictionEnabled(bool enable); + result SetLimitLength(int limitLength); + result SetLineSpacing(int linePixelGap); + void SetLowerCaseModeEnabled(bool enable); + void SetMaxLineCount(int maxLineCount); + result SetKeypadCommandButton(CommandButtonPosition position, const Tizen::Base::String& text, int actionId); + result SetKeypadCommandButtonVisible(bool visible); + _Toolbar* GetKeypadCommandButton(void) const; + result SetText(const Tizen::Base::String& text); + result SetTextAlignment(HorizontalAlignment alignment); + result SetTextColor(EditTextColor type, const Tizen::Graphics::Color& color); + result SetTextSize(int size); + virtual result SetTitleText(const Tizen::Base::String& title); + result SetTitleTextColor(EditStatus status, const Tizen::Graphics::Color& color); + result SetViewModeEnabled(bool enable); + result SetVerticalMargin(int margin, EditTextVerticalMargin marginType = EDIT_TEXT_VERTICAL_MARGIN); + void SetEditStyle(unsigned long style); + void SetBorderRoundStyleEnabled(bool enable); + + unsigned long GetAutoLinkMask(void) const; + Tizen::Graphics::Bitmap* GetBackgroundBitmap(EditStatus status) const; + result LoadDefaultBackgroundBitmap(GroupStyle groupStyle); + result ReplaceDefaultBackgroundBitmapForSearchBar(void); + Tizen::Graphics::Bitmap* GetDefaultBackgroundBitmap(EditStatus status) const; + bool IsCustomDefaultBackgroundBitmap(EditStatus status) const; + Tizen::Graphics::Bitmap* GetDefaultBackgroundEffectBitmap(void) const; + void GetBlockRange(int& start, int& end) const; + Tizen::Graphics::Color GetBlockTextColor(void) const; + Tizen::Graphics::Color GetColor(EditStatus status) const; + result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const; + void GetCurrentTextRange(int& start, int& end) const; + int GetCursorPosition(void) const; + int GetCursorPositionAt(const Tizen::Graphics::Point& point) const; + result GetCursorBounds(bool isAbsRect, Tizen::Graphics::Rectangle& cursorBounds) const; + void GetCutlinkColorInfo(EditCutLinkType type, EditCutlinkColor* colorInfo) const; + EllipsisPosition GetEllipsisPosition(void) const; + void GetFontType(Tizen::Base::String& typefaceName, unsigned long& styleMask) const; + unsigned long GetTextStyle(void) const; + Tizen::Base::String GetGuideText(void) const; + Tizen::Graphics::Color GetGuideTextColor(void) const; + int GetHorizontalMargin(EditTextHorizontalMargin marginType) const; + InputStyle GetInputStyle(void) const; + CoreKeypadAction GetKeypadAction(void) const; + bool GetKeypadActionEnabled(void) const; + result GetKeypadBounds(Tizen::Graphics::Rectangle& rect) const; + KeypadStyle GetKeypadStyle(void) const; + int GetTextLimitLength(void) const; + int GetLineSpacing(void) const; + int GetMaxLineCount(void) const; + int GetKeypadCommandButtonActionId(CommandButtonPosition position) const; + Tizen::Base::String GetKeypadCommandButtonText(CommandButtonPosition position) const; + int GetRemainingLength(void) const; + Tizen::Base::String GetText(void) const; + Tizen::Base::String GetText(int start, int end) const; + HorizontalAlignment GetTextAlignment(void) const; + Tizen::Graphics::Color GetTextColor(EditStatus status) const; + Tizen::Graphics::Color GetTextColor(EditTextColor type) const; + int GetTextLength(void) const; + int GetTextLineCount(void) const; + int GetTextSize(void) const; + int GetTextTotalHeight(void) const; + virtual Tizen::Base::String GetTitleText(void) const; + Tizen::Graphics::Color GetTitleTextColor(EditStatus status) const; + int GetVerticalMargin(EditTextVerticalMargin marginType) const; + unsigned long GetEditStyle(void) const; + void GetWordPosition(int cursorPos, int& startPos, int& endPos) const; + result GetTextImageRangeAt(int postion, int& startPosition, int& endPosition) const; + + result AppendCharacter(const Tizen::Base::Character& character); + result AppendText(const Tizen::Base::String& text); + result BeginTextBlock(void); + bool CalculateAbsoluteCursorBounds(int index ,Tizen::Graphics::Rectangle& absCursorRect); + result ClearText(void); + result CopyText(void); + result CutText(void); + result DeleteCharacterAt(int index); + result DeleteCharacterAtCursorPosition(void); + void SetCursorDisabled(bool disabled); + result HideKeypad(void); + void InitializeColorInformation(void); + void SetViewModeColorInformation(bool enabled); + result InsertTextAtCursorPosition(const Tizen::Base::String& text); + result InsertCharacterAt(int index, const Tizen::Base::Character& character); + result InsertTextAt(int index, const Tizen::Base::String& text); + result InsertTextAt(int position, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& textImage); + result AppendText(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& textImage); + bool IsAutoResizingEnabled(void) const; + bool IsBlocked(void) const; + bool IsClipped(void) const; + bool IsLowerCaseModeEnabled(void) const; + bool IsKeypadCommandButtonVisible(void) const; + bool IsSettingGuideTextColor(void) const; + bool IsViewModeEnabled(void) const; + bool IsKeypadEnabled(void) const; + bool IsTextPredictionEnabled(void) const; + void UpdateAccessibilityElement(EditAccessibilityElementType type); + void SetFullScreenKeypadEdit(bool enabled); + bool IsFullScreenKeypadEdit(void); + bool IsBorderRoundStyleEnabled(void) const; + bool IsUsbKeyboardConnected(void) const; + bool IsKeypadExist(void) const; + virtual void SetAutoShrinkModeEnabled(bool enable); + virtual bool IsAutoShrinkModeEnabled(void) const; + + result PasteText(void); + result ReleaseTextBlock(void); + result RemoveTextBlock(void); + result ShowKeypad(void); + + result AddActionEventListener(const _IActionEventListener& listener); + result AddExpandableEditAreaEventListener(const _IExpandableEditAreaEventListener& listener); + result AddKeypadEventListener(const _IKeypadEventListener& listener); + result AddLanguageEventListener(const _ILanguageEventListener& listener); + result AddScrollPanelEventListener(const _IScrollPanelEventListener& listener); + result AddTextBlockEventListener(const _ITextBlockEventListener& listener); + result AddTextEventListener(const _ITextEventListener& listener); + result AddUiLinkEventListener(const _IUiLinkEventListener& listener); + + result RemoveActionEventListener(const _IActionEventListener& listener); + result RemoveExpandableEditAreaEventListener(const _IExpandableEditAreaEventListener& listener); + result RemoveKeypadEventListener(const _IKeypadEventListener& listener); + result RemoveLanguageEventListener(const _ILanguageEventListener& listener); + result RemoveScrollPanelEventListener(const _IScrollPanelEventListener& listener); + result RemoveTextBlockEventListener(const _ITextBlockEventListener& listener); + result RemoveTextEventListener(const _ITextEventListener& listener); + result RemoveUiLinkEventListener(const _IUiLinkEventListener& listener); + + result AttachScrollPanelEvent(void); + result DetachScrollPanelEvent(void); + + result SendExpandableEditAreaEvent(_ExpandableEditAreaEventStatus status, int selectedTokenIndex = -1); + result SendKeypadEvent(CoreKeypadAction keypadAction, CoreKeypadEventStatus eventstatus); + result SendLanguageEvent(Tizen::Locales::LanguageCode prevLanguageCode, Tizen::Locales::LanguageCode currentLanguageCode); + result SendLinkEvent(const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link); + result SendScrollPanelEvent(CoreScrollPanelStatus eventstatus); + result SendTextBlockEvent(int start, int end); + result SendTextEvent(CoreTextEventStatus textEventStatus); + + void OnScrollPanelBoundsChanged(void); + virtual result OnAttachedToMainTree(void); + virtual void OnBoundsChanged(void); + virtual void OnChangeLayout(_ControlOrientation orientation); + virtual void OnClipboardPopupClosed(const ClipboardItem* pClipboardItem); + virtual void OnDraw(void); + virtual bool OnFocusGained(const _Control& source); + virtual bool OnFocusLost(const _Control& source); + virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture); + virtual bool OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture); + virtual bool OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture); + virtual bool OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture); + virtual bool OnTapGestureDetected(_TouchTapGestureDetector& gesture); + virtual bool OnTapGestureCanceled(_TouchTapGestureDetector& gesture); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo); + virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo); + virtual bool OnNotifiedN(const _Control& source, Tizen::Base::Collection::IList* pArgs); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + virtual void OnAncestorEnableStateChanged(const _Control& control); + + _EditPresenter* GetPresenter(void) const; + Tizen::Graphics::Dimension GetContentSizeInternal(void) const; + +protected: + result SetPresenter(const _EditPresenter& pPresenter); + +private: + _Edit(const _Edit&); + _Edit& operator =(const _Edit&); + _EditPresenter* _pEditPresenter; + +private: + int __bottomMargin; + int __leftMargin; + int __lineSpacing; + int __rightMargin; + int __textSize; + int __topMargin; + int __editStyle; + bool __borderRoundStyle; + + EllipsisPosition __ellipsisPosition; + InputStyle __inputStyle; + bool __isConstructed; + + EditColor __color[EDIT_COLOR_MAX]; + EditBlockTextColor __blockTextColor; + EditCutlinkColor __cutlinkColor[EDIT_LINK_TYPE_MAX]; + Tizen::Graphics::Color __guideTextColor; + bool __isSettingGuideTextColor; + + Tizen::Graphics::Bitmap* __pBackgroundBitmap[EDIT_COLOR_MAX]; + +//Default Bitmap + Tizen::Graphics::Bitmap* __pDefaultBackgroundBitmap[EDIT_COLOR_MAX]; + Tizen::Graphics::Bitmap* __pDefaultBackgroundEffectBitmap; + + Tizen::Ui::_TouchFlickGestureDetector* __pGestureFlick; + Tizen::Ui::_TouchLongPressGestureDetector* __pGestureLongPress; + Tizen::Ui::_TouchTapGestureDetector* __pGestureTap; + Tizen::Ui::Controls::_EditInternalTouchEventListener* __pEditInternalTouchEventListener; + + _ExpandableEditAreaEvent* __pExpandableEditAreaEvent; + _KeypadEvent* __pKeypadEvent; + _LanguageEvent* __pLanguageEvent; + _LinkEvent* __pLinkEvent; + _ScrollPanelEvent* __pScrollPanelEvent; + _TextBlockEvent* __pTextBlockEvent; + _TextEvent* __pTextEvent; + Tizen::Ui::_AccessibilityElement* __pTitleTextAccessibilityElement; + Tizen::Ui::_AccessibilityElement* __pTextAccessibilityElement; + Tizen::Ui::_AccessibilityElement* __pClearButtonTextAccessibilityElement; + Tizen::Ui::_AccessibilityElement* __pToolbarAccessibilityElement; + bool __isAccessibilityCreated; + bool __isFullScreenKeypadEdit; +}; // _Edit + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_EDIT_H_ diff --git a/src/ui/inc/FUiCtrl_EditAreaImpl.h b/src/ui/inc/FUiCtrl_EditAreaImpl.h new file mode 100644 index 0000000..62288e4 --- /dev/null +++ b/src/ui/inc/FUiCtrl_EditAreaImpl.h @@ -0,0 +1,211 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_EditAreaImpl.h + * @brief This is the header file for the _EditAreaImpl class. + * + * This header file contains the declarations of the %_EditAreaPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_EDIT_AREA_IMPL_H_ +#define _FUI_CTRL_INTERNAL_EDIT_AREA_IMPL_H_ + +#include +#include "FUi_ControlImpl.h" +#include "FUi_IFocusEventListener.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_IKeypadEventListener.h" +#include "FUiCtrl_ILanguageEventListener.h" +#include "FUiCtrl_IScrollPanelEventListener.h" +#include "FUiCtrl_ITextBlockEventListener.h" +#include "FUiCtrl_ITextEventListener.h" +#include "FUiCtrl_IUiLinkEventListener.h" +#include "FUiCtrl_PublicActionEvent.h" +#include "FUiCtrl_PublicKeypadEvent.h" +#include "FUiCtrl_PublicLanguageEvent.h" +#include "FUiCtrl_PublicLinkEvent.h" +#include "FUiCtrl_PublicScrollPanelEvent.h" +#include "FUiCtrl_PublicTextBlockEvent.h" +#include "FUiCtrl_PublicTextEvent.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _EditAreaImpl + : public _ControlImpl + , virtual public Tizen::Base::Runtime::IEventListener + , public _ITextEventListener + , public _IActionEventListener + , public _IKeypadEventListener + , public _IUiLinkEventListener + , public _ITextBlockEventListener + , public _ILanguageEventListener + , public _IScrollPanelEventListener +{ +public: + class EditAreaSizeInfo : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(Tizen::Ui::_ControlOrientation orientation) const; + }; + +public: + _EditAreaImpl(EditArea* pPublic, _Edit* pCore); + virtual ~_EditAreaImpl(void); + + static _EditAreaImpl* CreateEditAreaImplN(EditArea* pControl, const Tizen::Graphics::Rectangle& rect); + result Initialize(InputStyle inputStyle = INPUT_STYLE_FULLSCREEN, int limitLength = 1000); + + virtual const _Edit& GetCore(void) const; + virtual _Edit& GetCore(void); + virtual const EditArea& GetPublic(void) const; + virtual EditArea& GetPublic(void); + virtual const char* GetPublicClassName(void) const; + + result SetAutoLinkMask(unsigned long autoLinks); + result SetBackgroundBitmap(EditStatus status, const Tizen::Graphics::Bitmap& bitmap); + result SetColor(EditStatus status, const Tizen::Graphics::Color& color); + result SetCurrentInputModeCategory(EditInputModeCategory inputModeCategory); + result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode); + result SetCursorPosition(int position); + void SetGuideText(const Tizen::Base::String& guideText); + result SetGuideTextColor(const Tizen::Graphics::Color& color); + result SetInputModeCategory(unsigned long categories, bool enable); + result SetKeypadActionEnabled(bool enable); + result SetKeypadAction(Tizen::Ui::KeypadAction keypadAction); + void SetKeypadEnabled(bool enable); + result SetKeypadStyle(KeypadStyle keypadStyle); + result SetLineSpacing(int multiplier, int extra); + void SetLowerCaseModeEnabled(bool enable); + result SetMargin(EditMarginType marginType, int margin); + result SetOverlayKeypadCommandButton(CommandButtonPosition position, const Tizen::Base::String& text, int actionId); + result SetOverlayKeypadCommandButtonVisible(bool visible); + result SetText(const Tizen::Base::String& text); + result SetTextAlignment(HorizontalAlignment alignment); + result SetTextColor(EditTextColor type, const Tizen::Graphics::Color& color); + result SetTextSize(int size); + result SetViewModeEnabled(bool enable); + result SetTextPredictionEnabled(bool enable); + + unsigned long GetAutoLinkMask(void) const; + void GetBlockRange(int& start, int& end) const; + Tizen::Graphics::Color GetColor(EditStatus status) const; + EditInputModeCategory GetCurrentInputModeCategory(void) const; + result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const; + void GetCurrentTextRange(int& start, int& end) const; + int GetCursorPosition(void) const; + Tizen::Base::String GetGuideText(void) const; + Tizen::Graphics::Color GetGuideTextColor(void) const; + unsigned long GetInputModeCategory(void) const; + Tizen::Base::String GetText(void) const; + Tizen::Base::String GetText(int start, int end) const; + HorizontalAlignment GetTextAlignment(void) const; + Tizen::Graphics::Color GetTextColor(EditTextColor type) const; + int GetTextLength(void) const; + int GetTextLineCount(void) const; + int GetTextSize(void) const; + Tizen::Ui::KeypadAction GetKeypadAction(void) const; + KeypadStyle GetKeypadStyle(void) const; + int GetLineSpacing(void) const; + int GetMargin(EditMarginType marginType) const; + int GetOverlayKeypadCommandButtonActionId(CommandButtonPosition position) const; + Tizen::Base::String GetOverlayKeypadCommandButtonText(CommandButtonPosition position) const; + int GetRemainingLength(void) const; + + result AppendCharacter(const Tizen::Base::Character& character); + result AppendText(const Tizen::Base::String& text); + result BeginBlock(void); + result Clear(void); + result Copy(void); + result Cut(void); + result DeleteCharacterAtCursorPosition(void); + result HideKeypad(void); + result InsertTextAtCursorPosition(const Tizen::Base::String& text); + result InsertTextAt(int position, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& textImage); + result AppendText(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& textImage); + bool IsBlocked(void) const; + bool IsClipped(void) const; + bool IsKeypadEnabled(void) const; + bool IsKeypadActionEnabled(void) const; + bool IsLowerCaseModeEnabled(void) const; + bool IsOverlayCommandButtonVisible(void) const; + bool IsViewModeEnabled(void) const; + bool IsTextPredictionEnabled(void) const; + + result Paste(void); + result ReleaseBlock(void); + result Remove(void); + result ShowKeypad(void); + + result AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + result AddKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + result AddLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + result AddScrollPanelEventListener(Tizen::Ui::IScrollPanelEventListener& listener); + result AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + result AddTextEventListener(Tizen::Ui::ITextEventListener& listener); + result AddUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + result RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + result RemoveKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + result RemoveLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + result RemoveScrollPanelEventListener(Tizen::Ui::IScrollPanelEventListener& listener); + result RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + result RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener); + result RemoveUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + virtual result OnBoundsChanged(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect); + virtual void OnKeypadActionPerformed(CoreKeypadAction keypadAction); + virtual void OnKeypadClosed(void); + virtual void OnKeypadOpened(void); + virtual void OnKeypadWillOpen(void); + virtual void OnKeypadBoundsChanged(void); + virtual void OnLanguageChanged(Tizen::Locales::LanguageCode oldLanguage, Tizen::Locales::LanguageCode newLanguage); + virtual void OnLinkClicked(Tizen::Ui::_Control& source, const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link); + virtual void OnOtherControlSelected(const Tizen::Ui::_Control& source); + virtual void OnOverlayControlClosed(const Tizen::Ui::_Control& source); + virtual void OnOverlayControlCreated(const Tizen::Ui::_Control& source); + virtual void OnOverlayControlOpened(const Tizen::Ui::_Control& source); + virtual void OnTextBlockSelected(Tizen::Ui::_Control& source, int start, int end); + virtual void OnTextValueChanged(const Tizen::Ui::_Control& source); + virtual void OnTextValueChangeCanceled(const Tizen::Ui::_Control& source); + +public: + static _EditAreaImpl* GetInstance(EditArea& editArea); + static const _EditAreaImpl* GetInstance(const EditArea& pEditArea); + +private: + _EditAreaImpl(const _EditAreaImpl&); + _EditAreaImpl& operator =(const _EditAreaImpl&); + +private: + _Edit* __pEdit; + unsigned long __inputModeCategory; + EditInputModeCategory __currentInputMode; + + _PublicActionEvent* __pPublicActionEvent; + _PublicKeypadEvent* __pPublicKeypadEvent; + _PublicLanguageEvent* __pPublicLanguageEvent; + _PublicLinkEvent* __pPublicLinkEvent; + _PublicScrollPanelEvent* __pPublicScrollPanelEvent; + _PublicTextBlockEvent* __pPublicTextBlockEvent; + _PublicTextEvent* __pPublicTextEvent; + unsigned long __autoLinkMask; +}; //_EditAreaImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_EDIT_AREA_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_EditCopyPasteEvent.h b/src/ui/inc/FUiCtrl_EditCopyPasteEvent.h new file mode 100644 index 0000000..1feac5a --- /dev/null +++ b/src/ui/inc/FUiCtrl_EditCopyPasteEvent.h @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_EditCopyPasteEvent.h +* @brief This is the header file for _EditCopyPasteEvent class. +* +* This header file contains declaration of _EditCopyPasteEvent class. +*/ + +#ifndef _FUI_CTRL_INTERNAL_EDIT_COPY_PASTE_EVENT_H_ +#define _FUI_CTRL_INTERNAL_EDIT_COPY_PASTE_EVENT_H_ + +#include +#include +#include +#include "FUiCtrl_IEditCopyPasteEventListener.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +//forward declaration +class _EditCopyPasteManager; + +/** +* @class _EditCopyPasteEvent +* @brief This class handles an EditCopyPaste event. It is inherited from Event class. +* +*/ +class _EditCopyPasteEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_EditCopyPasteEvent(void); + + static _EditCopyPasteEvent* CreateInstanceN(const Tizen::Ui::Controls::_EditCopyPasteManager& source); + +// Accessors +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::Controls::_EditCopyPasteManager* GetSource(void) const; + +// Operations +protected: + + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _EditCopyPasteEvent(const Tizen::Ui::Controls::_EditCopyPasteManager& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of _CustomItemEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +public: + static Tizen::Base::Runtime::IEventArg* CreateCopyPasteEventArgN(Tizen::Ui::Controls::CoreCopyPasteStatus status, Tizen::Ui::Controls::CoreCopyPasteAction action ); + + //Attributess +private: + const Tizen::Ui::Controls::_EditCopyPasteManager* __pSource; +}; // _EditCopyPasteEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_EDIT_COPY_PASTE_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_EditCopyPasteManager.h b/src/ui/inc/FUiCtrl_EditCopyPasteManager.h new file mode 100644 index 0000000..d1df7ab --- /dev/null +++ b/src/ui/inc/FUiCtrl_EditCopyPasteManager.h @@ -0,0 +1,137 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_EditCopyPasteManager.h +* @brief This is the header file for _EditCopyPasteManager class. +* +* This header file contains declaration of _EditCopyPasteManager class. +*/ + +#ifndef _FUI_CTRL_INTERNAL_EDIT_COPY_PASTE_MANAGER_H_ +#define _FUI_CTRL_INTERNAL_EDIT_COPY_PASTE_MANAGER_H_ + +#include +#include +#include "FUi_Control.h" +#include "FUiCtrl_ContextMenu.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_IEditCopyPasteEventListener.h" + +namespace Tizen {namespace Ui {namespace Controls +{ + +//forward declaration +class _EditCopyPasteHandler; +class _EditCopyPasteEvent; + +/** +* @class _EditCopyPasteManager +* @brief This class handles CopyPastePopup and Handler Windows. +* +*/ +class _EditCopyPasteManager + : virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer + , public _IActionEventListener +{ +public: + enum HandlerType + { + HANDLER_TYPE_LEFT = 0, + HANDLER_TYPE_RIGHT, + HANDLER_TYPE_MAX + }; + + enum HandlerMoveType + { + HANDLER_MOVE_TYPE_LEFT = 0, + HANDLER_MOVE_TYPE_UP, + HANDLER_MOVE_TYPE_DOWN, + HANDLER_MOVE_TYPE_RIGHT + }; + +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _EditCopyPasteManager(_Edit& parenEdit); + + /** + * This is the default class destructor. + * + */ + virtual ~_EditCopyPasteManager(void); + +// Operations +public: + void CreateCopyPastePopup(void); + void CreateHandle(void); + void Show(void); + bool CheckHandleBounds(const Tizen::Graphics::Point& point); + bool CheckHandlePosition(bool leftHandle, int cursorPosition); + void CheckVisibleState(bool leftHandle); + void HideHandle(void); + void RefreshBlock(bool changeVisibleState, bool isLeftHandle = false); + Tizen::Graphics::Rectangle GetCursorBounds(bool isAbsRect) const; + int GetCursorPositionAt(const Tizen::Graphics::Point& touchPoint) const; + result SetCursorPosition(int position); + int GetCursorPosition(void) const; + int GetHandlerCursorPosition(bool rightHandler) const; + void SendTextBlockEvent(void); + void Release(void); + void ReleaseCopyPastePopup(void); + void SwitchHandle(void); + bool IsCopyPastePopup(const _Control& control) const; + void AdjustBounds(void); + + result AddCopyPasteEventListener(const _IEditCopyPasteEventListener& listener); + result SendCopyPasteEvent(Tizen::Ui::Controls::CoreCopyPasteStatus status, Tizen::Ui::Controls::CoreCopyPasteAction action); + void PrintLog(const Tizen::Graphics::Point& point); + bool GetTextBlockReleaseFlag(void) const; + void SetTextBlockReleaseFlag(bool enabled); + +// virtual function + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + void ScrollText(int distance); + _Edit* GetEdit(void) const; + void MoveHandler(HandlerMoveType moveType); + bool IsHandlerMovingEnabled(void) const; + void SetHandlerMovingEnabled(bool enabled); + Tizen::Graphics::Rectangle GetEditVisibleArea(void) const; +private: + _EditCopyPasteManager(const _EditCopyPasteManager& value); + _EditCopyPasteManager& operator =(const _EditCopyPasteManager& value); + +private: + _ContextMenu* __pCopyPastePopup; + ContextMenuCoreAlign __contextMenuAlign; + _EditCopyPasteHandler* __pHandle[HANDLER_TYPE_MAX]; + _EditCopyPasteEvent* __pCoreCopyPasteEvent; + _Edit* __pEdit; + int __contextMenuHeight; + bool __needToReleaseBlock; + bool __isHandlerMoving; + Tizen::Graphics::Rectangle __editVisibleArea; +}; // _EditCopyPasteManager + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_EDIT_COPY_PASTE_MANAGER_H_ diff --git a/src/ui/inc/FUiCtrl_EditDate.h b/src/ui/inc/FUiCtrl_EditDate.h new file mode 100644 index 0000000..8a2e4ec --- /dev/null +++ b/src/ui/inc/FUiCtrl_EditDate.h @@ -0,0 +1,161 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditDate.h + * @brief This is the header file for the _EditDate class. + * + * This header file contains the declarations of the %_EditDate class. + */ + +#ifndef _FUI_CTRL_INTERNAL_EDITDATE_H_ +#define _FUI_CTRL_INTERNAL_EDITDATE_H_ + +#include "FUi_Control.h" +#include "FUi_UiTouchEvent.h" +#include "FUiCtrl_IDateTimeChangeEventListener.h" +#include "FUiCtrl_DateTimeChangeEvent.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_DateTimeBar.h" + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class _EditDatePresenter; + +class _OSP_EXPORT_ _EditDate + : public _Control + , public _IDateTimeChangeEventListener + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ + DECLARE_CLASS_BEGIN(_EditDate, _Control); + DECLARE_PROPERTY("date", GetPropertyDate, SetPropertyDate); + DECLARE_PROPERTY("minYearRange", GetPropertyMinYearRange, SetPropertyMinYearRange); + DECLARE_PROPERTY("maxYearRange", GetPropertyMaxYearRange, SetPropertyMaxYearRange); + DECLARE_PROPERTY("day", GetPropertyDay, SetPropertyDay); + DECLARE_PROPERTY("month", GetPropertyMonth, SetPropertyMonth); + DECLARE_PROPERTY("year", GetPropertyYear, SetPropertyYear); + DECLARE_PROPERTY("datePickerEnabled", GetPropertyDatePickerEnabled, SetPropertyDatePickerEnabled); + DECLARE_CLASS_END(); + + result SetPropertyDate(const Tizen::Ui::Variant& date); + Tizen::Ui::Variant GetPropertyDate(void) const; + + result SetPropertyMinYearRange(const Tizen::Ui::Variant& minYear); + result SetPropertyMaxYearRange(const Tizen::Ui::Variant& maxYear); + Tizen::Ui::Variant GetPropertyMinYearRange(void) const; + Tizen::Ui::Variant GetPropertyMaxYearRange(void) const; + + result SetPropertyDay(const Tizen::Ui::Variant& day); + Tizen::Ui::Variant GetPropertyDay(void) const; + + result SetPropertyMonth(const Tizen::Ui::Variant& month); + Tizen::Ui::Variant GetPropertyMonth(void) const; + + result SetPropertyYear(const Tizen::Ui::Variant& year); + Tizen::Ui::Variant GetPropertyYear(void) const; + + result SetPropertyDatePickerEnabled(const Tizen::Ui::Variant& enable); + Tizen::Ui::Variant GetPropertyDatePickerEnabled(void) const; + +public: + virtual ~_EditDate(void); + static _EditDate* CreateEditDateN(const Tizen::Base::String& title); + + result AddDateChangeEventListener(const _IDateTimeChangeEventListener& listener); + result RemoveDateChangeEventListener(const _IDateTimeChangeEventListener& listener); + + void SetDate(const Tizen::Base::DateTime& date); + Tizen::Base::DateTime GetDate(void) const; + + result SetDay(int day); + int GetDay(void) const; + + result SetMonth(int month); + int GetMonth(void) const; + + result SetYear(int year); + int GetYear(void) const; + + void SetCurrentDate(void); + + void SetDatePickerEnabled(bool enable); + bool IsDatePickerEnabled(void) const; + + result SetYearRange(int minYear, int maxYear); + result GetYearRange(int& minYear, int& maxYear) const; + + result SetMinYearRange(int minYear); + result SetMaxYearRange(int maxYear); + + int GetMinYearRange(void) const; + int GetMaxYearRange(void) const; + + _DateTimeBar* GetDateTimeBar(void) const; + + virtual void OnDraw(void); + virtual result OnAttachedToMainTree(void); + virtual void OnBoundsChanged(void); + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const Tizen::Ui::_Control& control); + + virtual void OnDateTimeChanged(const Tizen::Ui::_Control& source, int year, int month, int day, int hour, int minute); + virtual void OnDateTimeChangeCanceled(const Tizen::Ui::_Control& source); + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + Tizen::Graphics::Rectangle GetParentWindowBounds(void) const; + +private: + _EditDate(void); + + _EditDate(const _EditDate&); + _EditDate& operator =(const _EditDate&); + + result CreateDateTimeBar(void); + result CalculateDateTimeBarPosition(void); + result FireDateChangeEvent(_DateTimeChangeStatus status); + void AdjustDay(int year, int month); + void UpdateAccessibilityElement(void); + +private: + _EditDatePresenter* __pEditDatePresenter; + _DateTimeChangeEvent* __pDateChangeEvent; + _DateTimeBar* __pDateTimeBar; + Tizen::Graphics::Rectangle __absoluteBounds; + Tizen::Base::String __title; + Tizen::Ui::_AccessibilityElement* __pAccessibilityTitleElement; + Tizen::Ui::_AccessibilityElement* __pAccessibilityYearElement; + Tizen::Ui::_AccessibilityElement* __pAccessibilityMonthElement; + Tizen::Ui::_AccessibilityElement* __pAccessibilityDayElement; + +}; // _EditDate + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_EDITDATE_H_ diff --git a/src/ui/inc/FUiCtrl_EditDateImpl.h b/src/ui/inc/FUiCtrl_EditDateImpl.h new file mode 100644 index 0000000..9e79f32 --- /dev/null +++ b/src/ui/inc/FUiCtrl_EditDateImpl.h @@ -0,0 +1,101 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditDateImpl.h + * @brief This is the header file for the _EditDateImpl class. + * + * This header file contains the declarations of the %_EditDateImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_EDITDATE_IMPL_H_ +#define _FUI_CTRL_INTERNAL_EDITDATE_IMPL_H_ + +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_EditDate.h" +#include "FUiCtrl_IDateTimeChangeEventListener.h" +#include "FUiCtrl_PublicDateTimeChangeEvent.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _EditDateImpl + : public _ControlImpl + , public _IDateTimeChangeEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + class EditDateSizeInfo : public Tizen::Ui::_ControlImpl::SizeInfo + { + public: + EditDateSizeInfo(void); + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(Tizen::Ui::_ControlOrientation orientation) const; + virtual Tizen::Graphics::Dimension GetDefaultMaximumSize(Tizen::Ui::_ControlOrientation orientation) const; + void SetTitleStyle(bool titleStyle = false); + + private: + bool __isTitle; + }; + +public: + virtual ~_EditDateImpl(void); + static _EditDateImpl* CreateEditDateImplN(EditDate* pControl, const Tizen::Graphics::Point& point, const Tizen::Base::String& title); + + virtual const char* GetPublicClassName(void) const; + virtual const EditDate& GetPublic(void) const; + virtual EditDate& GetPublic(void); + virtual const _EditDate& GetCore(void) const; + virtual _EditDate& GetCore(void); + +public: + result AddDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener); + result RemoveDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener); + Tizen::Base::DateTime GetDate(void) const; + int GetDay(void) const; + int GetMonth(void) const; + int GetYear(void) const; + void SetDate(const Tizen::Base::DateTime& date); + void SetCurrentDate(void); + result SetYear(int year); + result SetMonth(int month); + result SetDay(int day); + void SetDatePickerEnabled(bool enable); + bool IsDatePickerEnabled(void) const; + result SetYearRange(int minYear, int maxYear); + result GetYearRange(int& minYear, int& maxYear) const; + + virtual void OnDateTimeChanged(const Tizen::Ui::_Control& source, int year, int month, int day, int hour, int minute); + virtual void OnDateTimeChangeCanceled(const Tizen::Ui::_Control& source); + +public: + static _EditDateImpl* GetInstance(EditDate& editDate); + static const _EditDateImpl* GetInstance(const EditDate& editDate); + +private: + _EditDateImpl(EditDate* pPublic, _EditDate* pCore); + + _EditDateImpl(const _EditDateImpl&); + _EditDateImpl& operator =(const _EditDateImpl&); + +private: + _PublicDateTimeChangeEvent* __pPublicDateChangeEvent; +}; // _EditDateImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_EDITDATE_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_EditDatePresenter.h b/src/ui/inc/FUiCtrl_EditDatePresenter.h new file mode 100644 index 0000000..1d4cec4 --- /dev/null +++ b/src/ui/inc/FUiCtrl_EditDatePresenter.h @@ -0,0 +1,133 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditDatePresenter.h + * @brief This is the header file for the _EditDatePresenter class. + * + * This header file contains the declarations of the %_EditDatePresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_EDITDATE_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_EDITDATE_PRESENTER_H_ + +#include +#include "FUi_Control.h" +#include "FUiCtrl_DateTimeDefine.h" +#include "FUiAnimIVisualElementAnimationStatusEventListener.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _EditDate; +class _DateTimeModel; + +class _EditDatePresenter + : public Tizen::Base::Object + , Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener +{ +public: + _EditDatePresenter(void); + virtual ~_EditDatePresenter(void); + + static _EditDatePresenter* CreateInstanceN(const _EditDate& editDate, const Tizen::Base::String& title); + + Tizen::Base::DateTime GetDate(void) const; + int GetDay(void) const; + int GetMonth(void) const; + int GetYear(void) const; + void SetDate(const Tizen::Base::DateTime& date); + void SetCurrentDate(void); + result SetYear(int year); + result SetMonth(int month); + result SetDay(int day); + void SetDatePickerEnabled(bool enable); + bool IsDatePickerEnabled(void) const; + result SetMinYear(int minYear); + result SetMaxYear(int maxYear); + int GetMinYear(void) const; + int GetMaxYear(void) const; + result Initialize(void); + + result Draw(void); + + _DateTimeId GetLastSelectedId(void) const; + Tizen::Graphics::Rectangle GetDateAreaBounds(_DateTimeId id) const; + Tizen::Graphics::Rectangle GetTitleBounds(void) const; + int GetLocaleDateFormat(void) const; + void Animate(void); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const Tizen::Ui::_Control& control); + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + + virtual void OnVisualElementAnimationFinished (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, bool completedNormally); + virtual void OnVisualElementAnimationRepeated (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, long currentRepeatCount){} + virtual void OnVisualElementAnimationStarted (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target){} + +private: + _EditDatePresenter(const _EditDatePresenter&); + _EditDatePresenter& operator =(const _EditDatePresenter&); + + void SetTitle(const Tizen::Base::String& title); + result InitializeTextObject(void); + result InitializeTitleObject(void); + + result CalculateAreaBounds(void); + result DrawTitle(Tizen::Graphics::Canvas& canvas); + result DrawText(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Base::String& text); + result DrawDividers(Tizen::Graphics::Canvas& canvas); + _DateTimeId GetBoxIdFromPosition(const Tizen::Graphics::Point& point) const; + void SetLastSelectedId(_DateTimeId boxId); + +private: + _DateTimeModel* __pEditDateTimeModel; + _EditDate* __pEditDate; + + Tizen::Graphics::Rectangle __dayBounds; + Tizen::Graphics::Rectangle __monthBounds; + Tizen::Graphics::Rectangle __yearBounds; + Tizen::Graphics::Rectangle __titleBounds; + Tizen::Base::String __title; + Tizen::Base::String __lastSelectedValue; + + bool __datePickerEnabled; + + _DateTimeId __selectedId; + _DateTimeId __lastSelectedId; + bool __touchMoveHandled; + Tizen::Graphics::_Text::TextObject __titleObject; + Tizen::Graphics::_Text::TextObject __textObject; + Tizen::Graphics::Font* __pFont; + int __dividerLineWidth; + int __dividerLineHeight; + int __titleFontSize; + int __dateFontSize; + Tizen::Ui::Animations::VisualElement* __pContentProvider; + bool __isAnimating; + bool __isEditDateInitialized; + static const int __dividerCount = 2; +}; // _EditDatePresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_EDITDATE_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_EditFieldImpl.h b/src/ui/inc/FUiCtrl_EditFieldImpl.h new file mode 100644 index 0000000..31e823e --- /dev/null +++ b/src/ui/inc/FUiCtrl_EditFieldImpl.h @@ -0,0 +1,231 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditFieldImpl.h + * @brief This file contains implementation of _EditFieldImpl class + */ + +#ifndef _FUI_CTRL_EDIT_FIELD_IMPL_H_ +#define _FUI_CTRL_EDIT_FIELD_IMPL_H_ + +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_IKeypadEventListener.h" +#include "FUiCtrl_ILanguageEventListener.h" +#include "FUiCtrl_IScrollPanelEventListener.h" +#include "FUiCtrl_ITextBlockEventListener.h" +#include "FUiCtrl_ITextEventListener.h" +#include "FUiCtrl_IUiLinkEventListener.h" + +namespace Tizen { namespace Ui +{ +class ITouchEventListener; +class _IFocusEventListener; +}} + +namespace Tizen { namespace Ui { namespace Controls +{ +class _PublicActionEvent; +class _PublicKeypadEvent; +class _PublicLanguageEvent; +class _PublicLinkEvent; +class _PublicScrollPanelEvent; +class _PublicTextBlockEvent; +class _PublicTextEvent; + +class _EditFieldImpl + : public _ControlImpl + , virtual public Tizen::Base::Runtime::IEventListener + , public _IActionEventListener + , public _IKeypadEventListener + , public _ILanguageEventListener + , public _IScrollPanelEventListener + , public _ITextBlockEventListener + , public _ITextEventListener + , public _IUiLinkEventListener +{ +public: + class EditFieldSizeInfo : public _ControlImpl::SizeInfo + { + public: + EditFieldSizeInfo(void); + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(Tizen::Ui::_ControlOrientation orientation) const; + void SetTitleStyle(EditFieldTitleStyle titleStyle); + void SetSmallStyle(bool isSmallStyle); + + private: + EditFieldTitleStyle __titleStyle; + bool __smallStyle; + }; + +public: + _EditFieldImpl(EditField* pPublic, _Edit* pCore); + virtual ~_EditFieldImpl(void); + + static _EditFieldImpl* CreateEditFieldImplN(EditField* pControl, const Tizen::Graphics::Rectangle& rect, EditFieldStyle style, EditFieldTitleStyle titleStyle = EDIT_FIELD_TITLE_STYLE_NONE); + result Initialize(EditFieldStyle style = EDIT_FIELD_STYLE_NORMAL, InputStyle inputStyle = INPUT_STYLE_OVERLAY, EditFieldTitleStyle titleStlye = EDIT_FIELD_TITLE_STYLE_NONE, bool enableClear = false, int limitLength = 100, GroupStyle groupStyle = GROUP_STYLE_NONE); + + virtual const _Edit& GetCore(void) const; + virtual _Edit& GetCore(void); + virtual const EditField& GetPublic(void) const; + virtual EditField& GetPublic(void); + virtual const char* GetPublicClassName(void) const; + + result SetAutoLinkMask(unsigned long autoLinks); + result SetBackgroundBitmap(EditStatus status, const Tizen::Graphics::Bitmap& bitmap); + result SetColor(EditStatus status, const Tizen::Graphics::Color& color); + result SetCurrentInputModeCategory(EditInputModeCategory inputModeCategory); + result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode); + result SetCursorPosition(int position); + result SetEllipsisPosition(EllipsisPosition position); + void SetGuideText(const Tizen::Base::String& guideText); + result SetGuideTextColor(const Tizen::Graphics::Color& color); + result SetInputModeCategory(unsigned long categories, bool enable); + result SetKeypadActionEnabled(bool enable); + result SetKeypadAction(Tizen::Ui::KeypadAction keypadAction); + void SetKeypadEnabled(bool enable); + void SetLowerCaseModeEnabled(bool enable); + result SetMargin(EditMarginType marginType, int margin); + result SetOverlayKeypadCommandButton(CommandButtonPosition position, const Tizen::Base::String& text, int actionId); + result SetOverlayKeypadCommandButtonVisible(bool visible); + result SetText(const Tizen::Base::String& text); + result SetTextAlignment(HorizontalAlignment alignment); + result SetTextColor(EditTextColor type, const Tizen::Graphics::Color& color); + result SetTextSize(int size); + result SetTitleText(const Tizen::Base::String& title); + result SetTitleTextColor(EditStatus status, const Tizen::Graphics::Color& color); + result SetViewModeEnabled(bool enable); + result SetTextPredictionEnabled(bool enable); + + unsigned long GetAutoLinkMask(void) const; + void GetBlockRange(int& start, int& end) const; + Tizen::Graphics::Color GetColor(EditStatus status) const; + EditInputModeCategory GetCurrentInputModeCategory(void) const; + result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const; + int GetCursorPosition(void) const; + void GetCurrentTextRange(int& start, int& end) const; + EllipsisPosition GetEllipsisPosition(void) const; + Tizen::Base::String GetGuideText(void) const; + Tizen::Graphics::Color GetGuideTextColor(void) const; + unsigned long GetInputModeCategory(void) const; + Tizen::Ui::KeypadAction GetKeypadAction(void) const; + KeypadStyle GetKeypadStyle(void) const; + int GetMargin(EditMarginType marginType) const; + int GetOverlayKeypadCommandButtonActionId(CommandButtonPosition position) const; + Tizen::Base::String GetOverlayKeypadCommandButtonText(CommandButtonPosition position) const; + int GetRemainingLength(void) const; + Tizen::Base::String GetText(void) const; + Tizen::Base::String GetText(int start, int end) const; + HorizontalAlignment GetTextAlignment(void) const; + Tizen::Graphics::Color GetTextColor(EditTextColor type) const; + int GetTextLength(void) const; + int GetTextSize(void) const; + Tizen::Base::String GetTitleText(void) const; + Tizen::Graphics::Color GetTitleTextColor(EditStatus status) const; + + result AppendCharacter(const Tizen::Base::Character& character); + result AppendText(const Tizen::Base::String& text); + result BeginBlock(void); + result Clear(void); + result Copy(void); + result Cut(void); + result DeleteCharacterAtCursorPosition(void); + result HideKeypad(void); + result InsertTextAtCursorPosition(const Tizen::Base::String& text); + bool IsBlocked(void) const; + bool IsClipped(void) const; + bool IsKeypadEnabled(void) const; + bool IsKeypadActionEnabled(void) const; + bool IsLowerCaseModeEnabled(void) const; + bool IsOverlayCommandButtonVisible(void) const; + bool IsViewModeEnabled(void) const; + bool IsTextPredictionEnabled(void) const; + + result Paste(void); + result ReleaseBlock(void); + result Remove(void); + result ShowKeypad(void); + + result AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + result AddKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + result AddLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + result AddScrollPanelEventListener(Tizen::Ui::IScrollPanelEventListener& listener); + result AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + result AddTextEventListener(Tizen::Ui::ITextEventListener& listener); + result AddUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + result RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + result RemoveKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + result RemoveLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + result RemoveScrollPanelEventListener(Tizen::Ui::IScrollPanelEventListener& listener); + result RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + result RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener); + result RemoveUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + virtual result OnBoundsChanged(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect); + virtual void OnKeypadActionPerformed(CoreKeypadAction keypadAction); + virtual void OnKeypadClosed(void); + virtual void OnKeypadOpened(void); + virtual void OnKeypadWillOpen(void); + virtual void OnKeypadBoundsChanged(void); + virtual void OnLanguageChanged(Tizen::Locales::LanguageCode oldLanguage, Tizen::Locales::LanguageCode newLanguage); + virtual void OnLinkClicked(Tizen::Ui::_Control& source, const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link); + virtual void OnOtherControlSelected(const Tizen::Ui::_Control& source); + virtual void OnOverlayControlClosed(const Tizen::Ui::_Control& source); + virtual void OnOverlayControlCreated(const Tizen::Ui::_Control& source); + virtual void OnOverlayControlOpened(const Tizen::Ui::_Control& source); + virtual void OnTextBlockSelected(Tizen::Ui::_Control& source, int start, int end); + virtual void OnTextValueChanged(const Tizen::Ui::_Control& source); + virtual void OnTextValueChangeCanceled(const Tizen::Ui::_Control& source); + +public: + static _EditFieldImpl* GetInstance(EditField& editField); + static const _EditFieldImpl* GetInstance(const EditField& editField); + +protected: + virtual result Dispose(void); + +private: + _EditFieldImpl(const _EditFieldImpl&); + _EditFieldImpl& operator =(const _EditFieldImpl&); + +private: + friend class _Edit; + _Edit* __pEdit; + + EditFieldStyle __editFieldStyle; + InputStyle __inputStyle; + unsigned long __inputModeCategory; + EditInputModeCategory __currentInputMode; + + _PublicActionEvent* __pPublicActionEvent; + _PublicKeypadEvent* __pPublicKeypadEvent; + _PublicLanguageEvent* __pPublicLanguageEvent; + _PublicLinkEvent* __pPublicLinkEvent; + _PublicScrollPanelEvent* __pPublicScrollPanelEvent; + _PublicTextBlockEvent* __pPublicTextBlockEvent; + _PublicTextEvent* __pPublicTextEvent; + unsigned long __autoLinkMask; +}; // _EditFieldImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_EDIT_FIELD_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_EditModel.h b/src/ui/inc/FUiCtrl_EditModel.h new file mode 100644 index 0000000..6053ea4 --- /dev/null +++ b/src/ui/inc/FUiCtrl_EditModel.h @@ -0,0 +1,361 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_EditModel.h + * @brief This is the header file for the _EditModel class. + * + * This header file contains the declarations of the %_EditModel class. + */ + +#ifndef _FUI_CTRL_INTERNAL_EDIT_MODEL_H_ +#define _FUI_CTRL_INTERNAL_EDIT_MODEL_H_ + +#include +#include +#include +#include "FUiCtrl_FooterImpl.h" +#include "FUiCtrl_IKeypadEventListener.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _EditModel + * @brief + * @since 1.0 + * + * + * + * + */ +class _EditModel + : public Tizen::Base::Object +{ +// Lifecycle +public: + _EditModel(void); + virtual ~_EditModel(void); + +// Operations +public: + /** + * Sets the auto-link mask. + * + * @since 2.0 + * @return An error code + * @param[in] autoLinks The auto-link mask.@n + * Multiple link types can be combined using bitwise OR (see Tizen::Base::Utility::LinkType). + * For more information, refer to @ref linkAutoLinkDetection "here". + * @exception E_SUCCESS The method was successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * -- The operation is not supported if the input style is not INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error occurred. + * @remarks When @c autoLinks is set to zero, the auto-link detection is disabled. + * @see Tizen::Base::Utility::LinkType + * @see GetAutoLinkMask() + * @see IsViewModeEnabled() + * @see SetViewModeEnabled() + */ + result SetAutoLinkMask(unsigned long autoLinks); + + /** + * Gets the auto-link mask. + * + * @since 2.0 + * @return The auto-link mask + * @exception E_SUCCESS The method was successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * -- The operation is not supported if the input style is not INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult()() method. + * @see SetAutoLinkMask() + */ + unsigned long GetAutoLinkMask(void) const; + + /** + * Determines whether the view mode is enabled. + * + * @since 2.0 + * @return A Boolean value indicating whether the view mode is enabled. + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetViewModeEnabled() + */ + bool IsViewModeEnabled(void) const; + + /** + * Enables or disables the view mode. + * + * @since 2.0 + * @return An error code. + * @param[in] enable The view mode enabled flag + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks When the view mode is enabled, the auto-detected links will be displayed as linked text. + * @see IsViewModeEnabled() + */ + result SetViewModeEnabled(bool enable); + + /** + * Enables or disables the keypad action. + * + * @since 2.0 + * @return An error code. + * @param[in] enable A Boolean value indicating whether the keypad action is enabled. + * @exception E_SUCCESS The method was successful. + */ + result SetKeypadActionEnabled(bool enable); + + /** + * Checks whether the keypad action is enabled. + * + * @since 2.0 + * @return @c true if the keypad action is enabled @n + * @c false, otherwise + */ + bool IsKeypadActionEnabled(void) const; + +// Keypad Action + /** + * Gets the keypad action type. + * + * @since 2.0 + * @return The keypad action + * @exception E_SUCCESS The method was successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * -- The operation is not supported if the input style is not INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult()() method. + */ + Tizen::Ui::Controls::CoreKeypadAction GetKeypadAction(void) const; + + /** + * Sets the keypad action type. + * + * @since 2.0 + * @return An error code + * @param[in] keypadAction The keypad action + * @exception E_SUCCESS The method was successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation.@n + * -- The operation is not supported if the input style is not INPUT_STYLE_OVERLAY. + * @exception E_SYSTEM A system error occurred. + * @remarks Depending on the value of @c keypadAction specified, the keypad's enter key label will change accordingly. + */ + result SetKeypadAction(Tizen::Ui::Controls::CoreKeypadAction keypadAction); + + /** + * Sets the input language. + * + * @since 1.0 + * @return An error code + * @param[in] language The language to set + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. @n + * -- The specified language is not supported or unavailable. + * @exception E_SYSTEM A system error occurred. + */ + result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode); + + /** + * Gets the current input language. + * + * @since 1.0 + * @return An error code + * @param[out] language The current input language + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + */ + result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const; + + /** + * Sets the input language. + * + * @since 2.0 + * @return An error code + * @param[in] language The inital keypad language to set + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + */ + result SetInitialKeypadLanguage(Tizen::Locales::LanguageCode languageCode); + + /** + * Gets the current input language. + * + * @since 2.0 + * @return An error code + * @param[out] language The current inital keypad language + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + */ + result GetInitialKeypadLanguage(Tizen::Locales::LanguageCode& language) const; + + /** + * Enables or disables the keypad. + * + * @since 1.0 + * @param[in] enable A Boolean value indicating whether the keypad is enabled. + */ + void SetKeypadEnabled(bool enable); + + /** + * Checks whether the keypad is enabled. + * + * @since 1.0 + * @return @c true if the keypad is enabled @n + * @c false, otherwise + */ + bool IsKeypadEnabled(void) const; + + /** + * Enables or disables the lowercase mode. + * + * @since 1.0 + * @param[in] enable Set to @c true to enable lowercase mode @n + * @c false, otherwise + */ + void SetLowerCaseModeEnabled(bool enable); + + /** + * Checks whether the lowercase mode is enabled. + * + * @since 1.0 + * @return @c true if the lowercase mode is set @n + * @c false, otherwise + */ + bool IsLowerCaseModeEnabled(void) const; + + /** + * Gets the keypad style. + * + * @since 2.0 + * @return The keypad style + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult()() method. + * @see SetKeypadStyle() + */ + KeypadStyle GetKeypadStyle(void) const; + + /** + * Sets the keypad style. + * + * @since 2.0 + * @return An error code + * @param[in] keypadStyle The keypad style + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * -- @c keypadStyle cannot be @c KEYPAD_STYLE_PASSWORD. + * @exception E_SYSTEM A system error occurred. + * @remarks Depending on the value of the specified @c keypadStyle, the keypad's layout will change accordingly. + * @see GetKeypadStyle() + */ + result SetKeypadStyle(KeypadStyle keypadStyle); + + result SetTextPredictionEnabled(bool enable); + + bool IsTextPredictionEnabled(void) const; + + /** + * Enables or disables the auto resizing if the candidate word list appears. + * + * @since 2.0 + * @return An error code + * @param[in] enable Set to @c true to enable the auto resizing, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The current style of the %ExpandableEditArea does not support the operation. + * @remarks Note that when this option is enabled, the normal style %ExpandableEditArea is auto resized and the line added and removed events are + * generated if the candidate word list pop-up appears during the predictive texting. @n + * The operation is not supported by the token style %ExpandableEditArea. + * @see IsAutoResizingEnabled() + * @see Tizen::Ui::Controls::IExpandableEditAreaEventListener + */ + result SetAutoResizingEnabled(bool enable); + + /** + * Checks whether the auto-resizing is enabled. + * + * @since 2.0 + * @return @c true if the auto-resizing is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_UNSUPPORTED_OPERATION The current state of the instance prohibits the execution of the specified operation. @n + * The current style of the %ExpandableEditArea control does not support the operation. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetAutoResizingEnabled() + */ + bool IsAutoResizingEnabled(void) const; + + void SetMaxLineCount(int maxLineCount); + + /** + * Gets the maximum line count supported by the flexible text edit. + * + * @since 2.0 + * @return The maximum line count, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetMaxLineCount(void) const; + + // command button + result SetCommandButtonItem(CommandButtonPosition buttonPosition, int actionId, const Tizen::Base::String& text); + Tizen::Base::String GetKeypadCommandButtonText(CommandButtonPosition position) const; + int GetKeypadCommandButtonActionId(CommandButtonPosition position) const; + +private: + _EditModel(const _EditModel& value); + _EditModel& operator =(const _EditModel& value); + +private: +// Attributes + unsigned long __autoLinkMask; + + bool __keypadActionEnabled; + + bool __viewModeEnabled; + + KeypadStyle __keypadStyle; + + bool __keypadEnabled; + + bool __isLowerCase; + + bool __isTextPredictionEnabled; + + CoreKeypadAction __keypadAction; + + bool __enablePredictiveAutoResizing; + + int __maxLineCount; + + Tizen::Locales::LanguageCode __languageCode; + Tizen::Locales::LanguageCode __initialKeypadLanguageCode; + + int __leftCommandButtonActionId; + int __rightCommandButtonActionId; + Tizen::Base::String __leftCommandButtonText; + Tizen::Base::String __rightCommandButtonText; +}; // _EditModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_EDIT_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_EditPresenter.h b/src/ui/inc/FUiCtrl_EditPresenter.h new file mode 100644 index 0000000..e6b1290 --- /dev/null +++ b/src/ui/inc/FUiCtrl_EditPresenter.h @@ -0,0 +1,508 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_EditPresenter.h + * @brief This is the header file for the _EditPresenter class. + * + * This header file contains the declarations of the %_EditPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_EDIT_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_EDIT_PRESENTER_H_ + +#include +#include +#include +#include +#include +#include +#include "FUi_InputConnectionImpl.h" +#include "FUi_UiTouchEvent.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_EditModel.h" +#include "FUiCtrl_IFrameEventListener.h" +#include "FUiCtrl_IEditCopyPasteEventListener.h" +#include "FUiCtrl_Keypad.h" +#include "FUiCtrl_Toolbar.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +const int EDIT_SCROLLFRAME_MAX = 5; +const int EDIT_PASSWORD_BUFFER_MAX = 1024; +const int SCROLL_STYLE_VERTICAL = 2; +const int ANIMATION_DURATION = 333; + +enum _EditFooterVisibleStatus +{ + EDIT_FOOTER_VISIBLE_STATUS_NONE = 0, + EDIT_FOOTER_VISIBLE_STATUS_SHOW, + EDIT_FOOTER_VISIBLE_STATUS_HIDE +}; + +enum _EditTextStatus +{ + EDIT_TEXT_STATUS_COMPOSE_NON = 0, + EDIT_TEXT_STATUS_COMPOSE +}; + +enum _EditFontChange +{ + EDIT_FONT_CHANGE_CONTENT = 0, + EDIT_FONT_CHANGE_TITLE, + EDIT_FONT_CHANGE_ALL +}; + +struct _EditScrollEffectInfo +{ + int previousY; + int currentY; + int effectGap; + int effectFrame; + int touchScrollFrameLevel[EDIT_SCROLLFRAME_MAX]; +}; + +class _Form; +class _EditCopyPasteManager; +class _FlickAnimation; +class _Frame; +class _Scroll; +class _ScrollPanel; + +class _EditAnimationProvider + : public Tizen::Ui::Animations::VisualElementAnimationProvider +{ +public: + _EditAnimationProvider(void); + + virtual ~_EditAnimationProvider(void); + + virtual Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationForProperty(Tizen::Ui::Animations::VisualElement& source, const Tizen::Base::String& property); +}; // _EditAnimationProvider + + +class _EditPresenter + : public Tizen::Base::Object + , virtual public Tizen::Base::Runtime::IEventListener + , public IInputConnectionEventListener + , public IInputConnectionProvider + , public Tizen::Base::Runtime::ITimerEventListener + , public _IEditCopyPasteEventListener + , virtual public _IFrameEventListener +{ +public: + _EditPresenter(void); + virtual ~_EditPresenter(void); + + static _EditPresenter* CreateInstanceN(void); + virtual result Initialize(const _Control& control); + result AddActionEventListener(const _IActionEventListener& listener); + result RemoveActionEventListener(const _IActionEventListener& listener); + virtual bool OnLongPressGestureDetected(void); + virtual bool OnTapGestureDetected(void); + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo); + virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo); + + virtual void OnClipboardPopupClosed(const ClipboardItem* pClipboardItem); + virtual result SetInitialBounds(void); + virtual result Draw(Tizen::Graphics::Canvas& canvas); + virtual result DrawCursor(Tizen::Graphics::Canvas& canvas, Tizen::Graphics::Rectangle& cursorRect, bool isCursorOpaque); + virtual result DrawScrollBar(void); + virtual bool OnFocusGained(void); + virtual bool OnFocusLost(void); + + virtual bool OnNotifiedN(Tizen::Base::Collection::IList* pArgs); + virtual void OnFrameActivated(const Tizen::Ui::Controls::_Frame& source); + virtual void OnFrameDeactivated(const Tizen::Ui::Controls::_Frame& source); + + virtual result SetLineSpacing(int linePixelGap); + virtual int GetLineSpacing(void) const; + + void OnScrollPanelBoundsChanged(void); + + void OnFontInfoRequested(unsigned long& style, int& size); + void OnFontChanged(Tizen::Graphics::Font* pFont); + + result SetAutoLinkMask(unsigned long autoLinks); + result SetAutoResizingEnabled(bool enable); + result SetBlockRange(int start, int end); + result SetCurrentInputModeCategory(EditInputModeCategory inputModeCategory); + result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode); + result SetCursorPosition(int position); + void SetClientBounds(void); + result SetEllipsisPosition(EllipsisPosition position); + virtual result SetFlexBounds(const Tizen::Graphics::Rectangle& bounds); + result SetTextSize(const int size); + result SetFont(const Tizen::Graphics::Font& font); + result AdjustFont(Tizen::Graphics::Font& font, _EditFontChange fontChange = EDIT_FONT_CHANGE_CONTENT); + result SetFontType(const Tizen::Base::String& typefaceName, unsigned long styleMask); + result SetTextStyle(unsigned long style); + result SetGuideText(const Tizen::Base::String& guideText); + result SetInputModeCategory(unsigned long categories, bool enable); + result SetInputModePanelCategory(unsigned long panelCategory); + result SetKeypadActionEnabled(bool enable); + result SetKeypadAction(CoreKeypadAction keypadAction); + void SetKeypadEnabled(bool enable); + result SetKeypadStyle(KeypadStyle keypadStyle); + result SetKeypadNormalNumberStyle(bool enable); + result SetTextPredictionEnabled(bool enable); + result SetTextLimitLength(int limitLength); + void SetLowerCaseModeEnabled(bool enable); + void SetMaxLineCount(int maxLineCount); + result SetKeypadCommandButton(CommandButtonPosition position, const Tizen::Base::String& text, int actionId); + _Toolbar* GetKeypadCommandButton(void) const; + result SetKeypadCommandButtonVisible(bool visible); + bool SetKeypadBounds(const Tizen::Graphics::Rectangle& bounds); + result SetText(const Tizen::Base::String& text); + result SetTextAlignment(HorizontalAlignment alignment); + result SetTextBounds(Tizen::Graphics::Rectangle& bounds); + result SetTitleText(const Tizen::Base::String& title); + result SetViewModeEnabled(bool enable); + unsigned long GetAutoLinkMask(void) const; + void GetBlockRange(int& start, int& end) const; + EditInputModeCategory GetCurrentInputModeCategory(void) const; + result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const; + void GetCurrentTextRange(int& start, int& end) const; + int GetCursorPositionAt(const Tizen::Graphics::Point& touchPoint) const; + int GetCursorPosition(void) const; + result GetCursorBounds(bool isAbsRect, Tizen::Graphics::Rectangle& cursorBounds); + EllipsisPosition GetEllipsisPosition(void) const; + Tizen::Graphics::Font* GetFont(void) const; + Tizen::Graphics::Font* CopyFontN(const Tizen::Graphics::Font* pFont); + Tizen::Graphics::Font* CreateFontN(const Tizen::Graphics::Font* pFont, unsigned long styleMask); + Tizen::Graphics::Font* CreateFontN(const Tizen::Graphics::Font* pFont, unsigned long newStyle, int newSize); + Tizen::Graphics::Font* CreateFontN(const Tizen::Graphics::Font* pSrcFaceFont, const Tizen::Graphics::Font* pSrcStyleFont); + unsigned int GetFontStyle(const Tizen::Graphics::Font* pBaseFont) const; + result GetFontType(Tizen::Base::String& typefaceName, unsigned long& styleMask) const; + Tizen::Base::String GetTitleFontFaceName(void); + unsigned long GetTextStyle(void) const; + Tizen::Base::String GetGuideText(void) const; + int GetTextSize(void) const; + unsigned long GetInputModeCategory(void) const; + CoreKeypadAction GetKeypadAction(void) const; + result GetKeypadBounds(Tizen::Graphics::Rectangle& bounds) const; + KeypadStyle GetKeypadStyle(void) const; + int GetTextLimitLength(void) const; + int GetMaxLineCount(void) const; + int GetKeypadCommandButtonActionId(CommandButtonPosition position) const; + Tizen::Base::String GetKeypadCommandButtonText(CommandButtonPosition position) const; + _Form* GetParentForm(void); + int GetRemainingLength(void) const; + Tizen::Base::String GetText(void) const; + Tizen::Base::String GetText(int start, int end) const; + HorizontalAlignment GetTextAlignment(void) const; + int GetTextLength(void) const; + int GetTextLineCount(void) const; + int GetTextTotalHeight(void) const; + Tizen::Base::String GetTitleText(void) const; + void GetWordPosition(int cursorPos, int& startPos, int& endPos) const; + result GetTextImageRangeAt(int postion, int& startPosition, int& endPosition) const; + bool IsAutoResizingEnabled(void) const; + bool IsBlocked(void) const; + bool IsClipped(void) const; + bool IsFocused(void) const; + bool IsKeypadActionEnabled(void) ; + bool IsKeypadEnabled(void) ; + bool IsLowerCaseModeEnabled(void) const; + bool IsKeypadCommandButtonVisible(void) const; + bool IsViewModeEnabled(void) const; + bool IsTextPredictionEnabled(void) const; + bool IsKeypadExist(void) const; + void CheckUSBKeyboardStatus(void); + void CheckKeypadStatus(void); + bool IsUsbKeyboardConnected(void) const; + + result AppendCharacter(const Tizen::Base::Character& character); + result AppendText(const Tizen::Base::String& text); + result BeginTextBlock(void); + result CalculateAbsoluteCursorBounds(int index, Tizen::Graphics::Rectangle& absCursorBounds); + result ChangeLayout(_ControlOrientation orientation); + result ClearText(void); + result CopyText(void); + virtual result CutText(void); + result DeleteCharacterAt(int index); + result DeleteCharacterAtCursorPosition(void); + result DeleteText(int start, int end); + void SetCursorDisabled(bool disabled); + result HideKeypad(bool focus = false); + void ChangeKeypadStatus(void); + result InsertCharacterAt(int index, const Tizen::Base::Character& character); + result InsertTextAt(int index, const Tizen::Base::String& text); + result InsertTextAt(int position, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& textImage); + result InsertTextAtCursorPosition(const Tizen::Base::String& text); + result PasteText(void); + result ReleaseTextBlock(void); + result RemoveTextBlock(void); + result Resize(void); + result ShowKeypad(bool focus = true); + result StartFlickAnimation(const Tizen::Graphics::Point& flickPosition, int flickTime); + Tizen::Graphics::Rectangle GetTextAreaBounds(void) const; + Tizen::Graphics::Rectangle GetTitleBounds(void) const; + Tizen::Graphics::Rectangle GetClearIconBounds(void) const; + void FinishTextComposition(void); + void InitializeCopyPasteManager(void); + bool IsCopyPastePopupVisible(void) const; + bool GetTextCompositionState(void) const; + bool IsCopyPastePopup(const _Control& control) const; + Tizen::Graphics::_Text::TextObject* GetTextObject(void) const; + EditStatus GetCurrentStatus(void) const; + result ScrollContents(int moveY); + void DrawText(void); + result UpdateComponentInformation(void); + void SetCursorChangedFlag(bool enabled); + bool GetCursorChangedFlag(void) const; + void SetAutoShrinkModeEnabled(bool enable); + bool IsAutoShrinkModeEnabled(void) const; + result SetDefaultFont(void); + void SetEditGroupStyle(GroupStyle groupStyle); + void ScrollPanelToCursorPosition(bool show = true); + void SetSearchBarFlag(bool enabled); + bool GetSearchBarFlag(void) const; + void SetKeypadClosedEventSkipped(bool skipped); + void PostInternalEvent(const Tizen::Base::String& type); + +protected: + virtual void OnInputConnectionTextCommitted(InputConnection& source, const Tizen::Base::String& committedText); + virtual void DeleteSurroundingText(InputConnection& source, int offset, int chars); + virtual void OnTextCommitted(const Tizen::Base::String& commitText); + virtual void OnSurroundingTextDeleted(int offset, int charCount); + result InitializeAtFirstDrawing(void); + result CalculateCursorBounds(const Tizen::Graphics::Rectangle& textBounds, Tizen::Graphics::Rectangle& cursorBounds, int curPos = -1); + Tizen::Ui::Animations::_VisualElement* GetCursorVisualElement(void) const; + virtual Tizen::Graphics::Rectangle GetTextBounds(void) const; + result DrawBackground(Tizen::Graphics::Canvas& canvas, bool drawTitleText = true); + result InitializeCursor(void); + result DrawText(Tizen::Graphics::Canvas& canvas); + bool IsInitialized(void) const; + void StopCursorTimer(void); + result StartCursorTimer(void); + virtual void OnCursorTimerExpired(void); + virtual result SetModel(const _EditModel& editModel); + virtual int CalculateFlexibleHeight(void); + void SetCursorEnabled(bool enable); + bool IsCursorEnabled(void) const; + void SetScrollBarVisible(bool enable); + void SetScrollBarBounds(const Tizen::Graphics::Rectangle& bounds); + Tizen::Graphics::Rectangle GetDisplayScrollBounds(void) const; + Tizen::Graphics::Rectangle GetInitialBounds(void) const; + void SetPreviousScrollBarPosition(int position); + int GetPreviousScrollPosition(void) const; + void SetMaximumPreviousScrollBarPosition(int position); + _Scroll* GetScrollBar(void) const; + _Edit* GetEditView(void) const; + +private: + virtual void OnEditCopyPasteStatusChanged(CoreCopyPasteStatus status, CoreCopyPasteAction action); + virtual void OnInputConnectionPanelShowStateChanged(InputConnection& source, InputPanelShowState showState); + virtual void OnInputConnectionPanelLanguageChanged(InputConnection& source, Tizen::Locales::LanguageCode language); + virtual void OnInputConnectionPanelBoundsChanged(InputConnection& source, const Tizen::Graphics::Rectangle& bounds); + virtual void OnInputConnectionTextPredictionShowStateChanged(InputConnection& source, bool isShown); + virtual void OnInputConnectionTextPredictionBoundsChanged(InputConnection& source, const Tizen::Graphics::Rectangle& bounds); + virtual void OnInputConnectionComposingTextChanged(InputConnection& source, const Tizen::Base::String& composingText, int cursorPosition); + virtual void GetPreviousText(InputConnection& source, Tizen::Base::String& text, int& cursorPosition); + void OnComposingTextChanged(const Tizen::Base::String& preeditText, int cursorPosition); + void OnKeypadStateChanged(void *data, InputPanelShowState showState); + void OnLanguageStateChanged(void* data, Tizen::Locales::LanguageCode newLanguageCode); + result InitializeFlickAnimation(void); + void InitializeParentPanel(void); + result InitializeEditFieldClientRect(void); + result SetInitialEditFieldBounds(void); + virtual result AdjustFlexibleHeight(void); + result SetKeypadCommandButton(const Tizen::Graphics::Rectangle& bounds); + result SetTitleTextSlidingAction(Tizen::Graphics::_Text::TextObjectActionType action); + result SetWrap(Tizen::Graphics::_Text::TextObjectWrapType wrapMode); + bool IsGuideTextActivated(void) const; + bool IsContained(Tizen::Graphics::Rectangle& paramRect) const; + int CalculateMaximumFlexibleHeight(void); + result ChangePasswordToEchoCharacter(int cursorPos, int textLength); + result ConvertLinkType(void); + int GetLinkElementOffsetInTextBuffer(int elementIndex) const; + // todo : move to DrawBackground + result DrawBackgroundBitmap(Tizen::Graphics::Canvas& canvas, bool focused); + result DrawChangeableBackground(Tizen::Graphics::Canvas& canvas, bool focused, int bitmapId, int effectBitmapId, bool outLine = false, int outlineBitmapId = 0); + result DrawClearIcon(Tizen::Graphics::Canvas& canvas); + // todo : move to DrawBackground + result DrawSingleLineBackground(Tizen::Graphics::Canvas& canvas, bool drawTitleText); + // todo : move to DrawBackgroundBitmap + result DrawSingleLineBackgroundBitmap(Tizen::Graphics::Canvas& canvas, bool focused); + // todo : move to DrawText + result DrawTextForEntireFontSetting(Tizen::Graphics::Canvas& canvas); + result DrawTitleText(Tizen::Graphics::Canvas& canvas); + result MoveCursor(const Tizen::Graphics::Rectangle& fromRect, const Tizen::Graphics::Rectangle& toRect); + bool IsHorizontalDirection(const _TouchInfo& touchInfo); + result ScrollContentsOnFlick(void); + result ChangePasswordToEchoCharacter(wchar_t* dspStrBuffer, wchar_t echoChar); + // todo : move to PastePasswordEchoCharacter + result ReplaceTextIntoPasswordHyphenString(void); + // todo : delete, do not use + result SetFocused(void); + void ScrollText(int distance); + void FadeOutScrollBar(void); + // todo : move to OperateFlickScrollEffect + bool ScrollOnFlick(int moveDistanceY); + result StartFlickTimer(int flickVelocityX, int flickVelocityY); + void StopFlickTimer(void); + void StopPasswordTimer(void); + result StartPasswordTimer(void); + result OnPasswordTimerExpired(void); + void StopTitleSlidingTimer(void); + result StartTitleSlidingTimer(void); + result OnTitleSlidingTimerExpired(void); + result OnFlickTimerExpired(void); + bool IsDelimiter(wchar_t character) const; + void AdjustParentPanelHeight(bool restore, bool panelResizeByPrediction=false); + result ChangeLayoutInternal(_ControlOrientation orientation); + _Button* CreateCommandButtonItemN(int actionId, const Tizen::Base::String& text); + void CheckFooterVisible(void); + void SetFooterVisible(bool isVisible); + result ShowFullscreenKeypad(void); + InputPanelAction ConvertKeypadAction(CoreKeypadAction keypadAction); + void ScrollPanelToTop(bool show); + void ScrollPanelToExposedRegion(bool show); + result Dispose(void); + + _EditPresenter(const _EditPresenter&); + _EditPresenter& operator =(const _EditPresenter&); + +private: + _Edit* __pEdit; + wchar_t* __pTextBuffer; + Tizen::Base::String* __pTextString; + _EditModel* __pEditModel; + _Scroll* __pScrollBar; + // todo : check to be needed + _EditScrollEffectInfo* __pScrollEffect; + int __limitLength; + HorizontalAlignment __horizontalAlignment; + bool __isScrollBarVisible; + Tizen::Graphics::Rectangle __scrollBarBounds; + Tizen::Graphics::Rectangle __initialBounds; + int __previousScrollBarPos; // First save prev scroll and if scroll pos is changed then draw scroll + int __previousScrollBarMaxPos; // When scroll max value is changed then draw scroll + + _IActionEventListener* __pActionEventListener; + + Tizen::Base::Runtime::Timer* __pCursorTimer; + Tizen::Base::Runtime::Timer* __pFlickAnimationTimer; + Tizen::Base::Runtime::Timer* __pPasswordTimer; + Tizen::Base::Runtime::Timer* __pTitleSlidingTimer; + + Tizen::Graphics::Font* __pFont; + + Tizen::Ui::Animations::_VisualElement* __pCursorVisualElement; + Tizen::Ui::Animations::_VisualElement* __pTextVisualElement; + + _EditCopyPasteManager* __pCopyPasteManager; + _FlickAnimation* __pFlickAnimation; + _Form* __pParentForm; + _Keypad* __pFullscreenKeypad; + _ScrollPanel* __pParentPanel; + _Toolbar* __pCommandButton; + + _InputConnectionImpl* __pInputConnection; + bool __isInputConnectionBound; + + Tizen::Base::String __guideText; + Tizen::Base::String __titleText; + + Tizen::Graphics::Point __pressedPoint; + bool __isCopyPastePopupMoving; + Tizen::Graphics::Point __pressedAbsolutePoint; + + Tizen::Graphics::Rectangle __clearIconBounds; + Tizen::Graphics::Rectangle __textBoxBounds; + Tizen::Graphics::Rectangle __textObjectBounds; + Tizen::Graphics::Rectangle __titleBounds; + Tizen::Graphics::Rectangle __clientBounds; + Tizen::Graphics::Rectangle __previousCursorBounds; + Tizen::Graphics::Rectangle __keypadBounds; + + Tizen::Graphics::_Text::TextObject* __pTextObject; + Tizen::Graphics::_Text::TextObject* __pGuideTextObject; + Tizen::Graphics::_Text::TextObject* __pTitleTextObject; + Tizen::Graphics::_Text::TextObjectActionType __titleSlidingAction; + Tizen::Graphics::_Text::TextObjectWrapType __textObjectWrap; + + bool __isTextBlocked; + bool __isGuideTextColorChanged; + bool __isKeypadCommandButtonVisible; + bool __isKeypadHiding; + bool __isTextComposing; + bool __isCopyPastePopupVisible; + bool __isCursorChanged; + bool __isCursorInitialized; + bool __isCursorDisabled; + // todo : check InitAtFirstDrawing + bool __isInitialized; + // todo : check + bool __isMovingCursorByTouchMove; + bool __isTouchMoving; + bool __isTouchPressed; + bool __isClearIconPressed; + bool __isCursorOpaque; + bool __isTouchReleaseSkipped; + bool __isViewerModeEnabled; + bool __isKeypadNormalNumberStyleEnabled; + bool __isTextCompositionFinished; + bool __isFlexibleHeightFrozen; + bool __isKeypadShowing; + + int __blockStartPos; + int __cursorPos; + int __maximumFlexibleHeight; + int __prevTotalTextHeight; + int __textLength; + int __composingTextLength; + int __titleWidth; + int __verticalMargin; + bool __isUSBKeyboardConnected; + bool __rotated; + bool __isCutLinkParserEnabled; + + static bool __isKeypadExist; + static int __initialParentHeight; + static bool __isPanelBoundsChanging; + + wchar_t __echoChar; + + _EditFooterVisibleStatus __footerVisibleStatus; + _EditTextStatus __ContentTextStatus; + + _EditAnimationProvider* __pEditVEDelegator; + + bool __isAutoShrinkEnabled; + + GroupStyle __groupStyle; + + bool __isFontInitialized; + int __contentFontSize; + int __titleFontSize; + unsigned long __contentFontStyle; + unsigned long __contentTextStyle; + Tizen::Base::String __titleFontFaceName; + bool __isSearchBar; + bool __isKeypadClosedEventSkipped; + _Frame* __pCurrentFrame; +}; // _EditPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_EDIT_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_EditTime.h b/src/ui/inc/FUiCtrl_EditTime.h new file mode 100644 index 0000000..39c0495 --- /dev/null +++ b/src/ui/inc/FUiCtrl_EditTime.h @@ -0,0 +1,151 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditTime.h + * @brief This is the header file for the _EditTime class. + * + * This header file contains the declarations of the %_EditTime class. + */ + +#ifndef _FUI_CTRL_INTERNAL_EDITTIME_H_ +#define _FUI_CTRL_INTERNAL_EDITTIME_H_ + +#include "FUi_Control.h" +#include "FUi_UiTouchEvent.h" +#include "FUiCtrl_IDateTimeChangeEventListener.h" +#include "FUiCtrl_DateTimeChangeEvent.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUi_IAccessibilityListener.h" +#include "FUiCtrl_DateTimeBar.h" + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class _EditTimePresenter; + +class _OSP_EXPORT_ _EditTime + : public _Control + , public _IDateTimeChangeEventListener + , public _IActionEventListener + , public _IAccessibilityListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ + DECLARE_CLASS_BEGIN(_EditTime, _Control); + DECLARE_PROPERTY("time", GetPropertyTime, SetPropertyTime); + DECLARE_PROPERTY("hour", GetPropertyHour, SetPropertyHour); + DECLARE_PROPERTY("minute", GetPropertyMinute, SetPropertyMinute); + DECLARE_PROPERTY("timePickerEnabled", GetPropertyTimePickerEnabled, SetPropertyTimePickerEnabled); + DECLARE_CLASS_END(); + + result SetPropertyTime(const Tizen::Ui::Variant& time); + Tizen::Ui::Variant GetPropertyTime(void) const; + + result SetPropertyHour(const Tizen::Ui::Variant& hour); + Tizen::Ui::Variant GetPropertyHour(void) const; + + result SetPropertyMinute(const Tizen::Ui::Variant& minute); + Tizen::Ui::Variant GetPropertyMinute(void) const; + + result SetPropertyTimePickerEnabled(const Tizen::Ui::Variant& enable); + Tizen::Ui::Variant GetPropertyTimePickerEnabled(void) const; + +public: + virtual ~_EditTime(void); + static _EditTime* CreateEditTimeN(const Tizen::Base::String& title); + + result AddTimeChangeEventListener(const _IDateTimeChangeEventListener& listener); + result RemoveTimeChangeEventListener(const _IDateTimeChangeEventListener& listener); + + void SetTime(const Tizen::Base::DateTime& time); + Tizen::Base::DateTime GetTime(void) const; + + result SetHour(int hour); + int GetHour(void) const; + + result SetMinute(int minute); + int GetMinute(void) const; + + void SetCurrentTime(void); + + void SetTimePickerEnabled(bool enable); + bool IsTimePickerEnabled(void) const; + + void Set24HourNotationEnabled(bool enable); + bool Is24HourNotationEnabled(void) const; + + result FireTimeChangeEvent(_DateTimeChangeStatus status); + + _DateTimeBar* GetDateTimeBar(void) const; + + virtual void OnDraw(void); + virtual result OnAttachedToMainTree(void); + virtual void OnBoundsChanged(void); + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const Tizen::Ui::_Control& control); + + virtual void OnDateTimeChanged(const Tizen::Ui::_Control& source, int year, int month, int day, int hour, int minute); + virtual void OnDateTimeChangeCanceled(const Tizen::Ui::_Control& source); + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + Tizen::Graphics::Rectangle GetParentWindowBounds(void) const; + void UpdateAccessibilityElement(void); + + // accessibility listener + virtual bool OnAccessibilityFocusMovedNext(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityFocusMovedPrevious(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityReadElement(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityFocusIn(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityFocusOut(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityActionPerformed(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&); + virtual bool OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&); +private: + _EditTime(void); + + _EditTime(const _EditTime&); + _EditTime& operator =(const _EditTime&); + + result CreateDateTimeBar(void); + result CalculateDateTimeBarPosition(void); + +private: + _EditTimePresenter* __pEditTimePresenter; + _DateTimeChangeEvent* __pTimeChangeEvent; + _DateTimeBar* __pDateTimeBar; + Tizen::Graphics::Rectangle __absoluteBounds; + Tizen::Base::String __title; + Tizen::Ui::_AccessibilityElement* __pAccessibilityTitleElement; + Tizen::Ui::_AccessibilityElement* __pAccessibilityHourElement; + Tizen::Ui::_AccessibilityElement* __pAccessibilityMinuteElement; + Tizen::Ui::_AccessibilityElement* __pAccessibilityAmPmElement; +}; // _EditTime + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_EDITTIME_H_ diff --git a/src/ui/inc/FUiCtrl_EditTimeImpl.h b/src/ui/inc/FUiCtrl_EditTimeImpl.h new file mode 100644 index 0000000..145c564 --- /dev/null +++ b/src/ui/inc/FUiCtrl_EditTimeImpl.h @@ -0,0 +1,98 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditTimeImpl.h + * @brief This is the header file for the _EditTimeImpl class. + * + * This header file contains the declarations of the %_EditTimeImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_EDITTIME_IMPL_H_ +#define _FUI_CTRL_INTERNAL_EDITTIME_IMPL_H_ + +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_EditTime.h" +#include "FUiCtrl_IDateTimeChangeEventListener.h" +#include "FUiCtrl_PublicDateTimeChangeEvent.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _EditTimeImpl + : public _ControlImpl + , public _IDateTimeChangeEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + class EditTimeSizeInfo : public Tizen::Ui::_ControlImpl::SizeInfo + { + public: + EditTimeSizeInfo(void); + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(Tizen::Ui::_ControlOrientation orientation) const; + virtual Tizen::Graphics::Dimension GetDefaultMaximumSize(Tizen::Ui::_ControlOrientation orientation) const; + void SetTitleStyle(bool titleStyle = false); + + private: + bool __isTitle; + }; + +public: + virtual ~_EditTimeImpl(void); + static _EditTimeImpl* CreateEditTimeImplN(EditTime* pControl, const Tizen::Graphics::Point& point, const Tizen::Base::String& title); + + virtual const char* GetPublicClassName(void) const; + virtual const EditTime& GetPublic(void) const; + virtual EditTime& GetPublic(void); + virtual const _EditTime& GetCore(void) const; + virtual _EditTime& GetCore(void); + +public: + result AddTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener); + result RemoveTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener); + Tizen::Base::DateTime GetTime(void) const; + int GetHour(void) const; + int GetMinute(void) const; + void SetTime(const Tizen::Base::DateTime& time); + void SetCurrentTime(void); + result SetHour(int hour); + result SetMinute(int minute); + void SetTimePickerEnabled(bool enable); + bool IsTimePickerEnabled(void) const; + void Set24HourNotationEnabled(bool enable); + + virtual void OnDateTimeChanged(const Tizen::Ui::_Control& source, int year, int month, int day, int hour, int minute); + virtual void OnDateTimeChangeCanceled(const Tizen::Ui::_Control& source); + +public: + static _EditTimeImpl* GetInstance(EditTime& editTime); + static const _EditTimeImpl* GetInstance(const EditTime& editTime); + +private: + _EditTimeImpl(EditTime* pPublic, _EditTime* pCore); + + _EditTimeImpl(const _EditTimeImpl&); + _EditTimeImpl& operator =(const _EditTimeImpl&); + +private: + _PublicDateTimeChangeEvent* __pPublicTimeChangeEvent; +}; // _EditTimeImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_EDITTIME_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_EditTimePresenter.h b/src/ui/inc/FUiCtrl_EditTimePresenter.h new file mode 100644 index 0000000..778582c --- /dev/null +++ b/src/ui/inc/FUiCtrl_EditTimePresenter.h @@ -0,0 +1,147 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_EditTimePresenter.h + * @brief This is the header file for the _EditTimePresenter class. + * + * This header file contains the declarations of the %_EditTimePresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_EDITTIME_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_EDITTIME_PRESENTER_H_ + +#include +#include "FUi_Control.h" +#include "FUiCtrl_DateTimeDefine.h" +#include "FUiAnimIVisualElementAnimationStatusEventListener.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _EditTime; +class _DateTimeModel; + +class _EditTimePresenter + : public Tizen::Base::Object + , Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener +{ +public: + _EditTimePresenter(const Tizen::Base::String& title); + virtual ~_EditTimePresenter(void); + + static _EditTimePresenter* CreateInstanceN(const _EditTime& editTime, const Tizen::Base::String& title); + + Tizen::Base::DateTime GetTime(void) const; + int GetHour(void) const; + int GetMinute(void) const; + void SetTime(const Tizen::Base::DateTime& time); + void SetCurrentTime(void); + result SetHour(int hour); + result SetMinute(int minute); + void SetTimePickerEnabled(bool enable); + bool IsTimePickerEnabled(void) const; + void Set24HourNotationEnabled(bool enable); + bool Is24HourNotationEnabled(void) const; + + _DateTimeId GetLastSelectedId(void) const; + Tizen::Graphics::Rectangle GetDisplayAreaBoundsFromHoursStyle(_DateTimeId displayBoxId) const; + void SetTitleBounds(void); + Tizen::Graphics::Rectangle GetTitleBounds(void) const; + + void SetAmEnabled(bool amEnable); + bool GetAmEnabled(void) const; + + result Draw(void); + void Animate(void); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const Tizen::Ui::_Control& control); + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + result Initialize(void); + + virtual void OnVisualElementAnimationFinished (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, bool completedNormally); + virtual void OnVisualElementAnimationRepeated (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, long currentRepeatCount){} + virtual void OnVisualElementAnimationStarted (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target){} + +private: + _EditTimePresenter(const _EditTimePresenter&); + _EditTimePresenter& operator =(const _EditTimePresenter&); + + result InitializeTextObject(void); + result InitializeTitleObject(void); + void SetTimeConversion(void); + + result DrawTitle(Tizen::Graphics::Canvas& canvas); + result DrawText(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Base::String& text, int textSize = 0); + result DrawColon(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds); + _DateTimeId GetBoxIdFromPosition(const Tizen::Graphics::Point& point) const; + void SetLastSelectedId(_DateTimeId boxId); + result LoadResource(void); + result DrawResourceBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, Tizen::Graphics::Bitmap* pBitmap); + +private: + _DateTimeModel* __pEditDateTimeModel; + _EditTime* __pEditTime; + + Tizen::Graphics::Rectangle __bounds; + Tizen::Graphics::Rectangle __titleBounds; + + Tizen::Base::String __ampmString; + Tizen::Base::String __hourString; + Tizen::Base::String __minuteString; + Tizen::Base::String __title; + Tizen::Base::String __lastSelectedValue; + + bool __24hours; + bool __amEnable; + bool __timePickerEnabled; + + _DateTimeId __selectedId; + _DateTimeId __lastSelectedId; + + bool __touchMoveHandled; + + Tizen::Graphics::Bitmap* __pAmPmBgNormalColorReplacementBitmap; + Tizen::Graphics::Bitmap* __pAmPmBgDisabledColorReplacementBitmap; + Tizen::Graphics::Bitmap* __pAmPmBgPressedColorReplacementBitmap; + Tizen::Graphics::Bitmap* __pAmPmBgEffectNomralBitmap; + Tizen::Graphics::Bitmap* __pAmPmBgEffectPressedBitmap; + Tizen::Graphics::Bitmap* __pAmPmBgEffectDisabledBitmap; + Tizen::Graphics::Bitmap* __pColonColorReplacementBitmap; + Tizen::Graphics::Bitmap* __pColonDisabledColorReplacementBitmap; + Tizen::Ui::Animations::VisualElement* __pContentProvider; + + Tizen::Graphics::_Text::TextObject __textObject; + Tizen::Graphics::Font* __pFont; + + Tizen::Graphics::_Text::TextObject __titleObject; + int __amPmTextSize; + int __titleFontSize; + int __timeFontSize; + bool __isAnimating; + bool __isEditTimeInitialized; +}; // _EditTimePresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_EDITTIME_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_ExpandableEditAreaEvent.h b/src/ui/inc/FUiCtrl_ExpandableEditAreaEvent.h new file mode 100644 index 0000000..a515939 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ExpandableEditAreaEvent.h @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ExpandableEditAreaEvent.h + * @brief This is the header file for _ExpandableEditAreaEvent class. + * + * This header file contains declaration of _ExpandableEditAreaEvent class. + */ +#ifndef _FUICTRL_EXPANDABLE_EDITAREA_EVENT_H_ +#define _FUICTRL_EXPANDABLE_EDITAREA_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +} } // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum _ExpandableEditAreaEventStatus +{ + _EXPANDABLE_EDITAREA_EVENT_ADDED = 0, + _EXPANDABLE_EDITAREA_EVENT_REMOVED +// _EXPANDABLE_EDITAREA_EVENT_TOKEN_SELECTED +}; + +/** +* @class _ExpandableEditAreaEvent +* @brief This class handles a action event. It is inherited from Event class. +* +* The Window(root of all widgets) class has an instance of the _ExpandableEditAreaEvent class as a member variable. +* +*/ +class _ExpandableEditAreaEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_ExpandableEditAreaEvent(void); + + static _ExpandableEditAreaEvent* CreateInstanceN(const Tizen::Ui::_Control& source); + +// Accessors + + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::_Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateExpandableEditAreaEventArgN(_ExpandableEditAreaEventStatus status, int selectedTokenIndex); + +// Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _ExpandableEditAreaEvent(const Tizen::Ui::_Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this action event. + * @param[in] arg It is an argument-like instance of action event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IActionEventListener class or + * the p__ActionEventArg is not the instance of _ActionEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attributess +private: + const Tizen::Ui::_Control* __pSource; +}; // _ExpandableEditAreaEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_EXPANDABLE_EDITAREA_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_ExpandableEditAreaImpl.h b/src/ui/inc/FUiCtrl_ExpandableEditAreaImpl.h new file mode 100644 index 0000000..89ea508 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ExpandableEditAreaImpl.h @@ -0,0 +1,214 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_EXPANDABLEEDITAREA_IMPL_H_ +#define _FUI_CTRL_INTERNAL_EXPANDABLEEDITAREA_IMPL_H_ + +#include +#include +#include "FUi_ControlImpl.h" +#include "FUi_IFocusEventListener.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_IExpandableEditAreaEventListener.h" +#include "FUiCtrl_IKeypadEventListener.h" +#include "FUiCtrl_ILanguageEventListener.h" +#include "FUiCtrl_ITextEventListener.h" +#include "FUiCtrl_ITextBlockEventListener.h" +#include "FUiCtrl_ITokenFilter.h" +#include "FUiCtrl_PublicExpandableEditAreaEvent.h" +#include "FUiCtrl_PublicKeypadEvent.h" +#include "FUiCtrl_PublicLanguageEvent.h" +#include "FUiCtrl_PublicTextBlockEvent.h" +#include "FUiCtrl_PublicTextEvent.h" + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +}}} // Tizen::Ui::Animation + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _TokenEdit; +class _Edit; + +class _ExpandableEditAreaImpl + : public _ControlImpl + , virtual public Tizen::Base::Runtime::IEventListener + , public _ITextEventListener + , public _IExpandableEditAreaEventListener + , public _ITextBlockEventListener + , public _IKeypadEventListener + , public _ILanguageEventListener + , public _ITokenFilter +{ +public: + static _ExpandableEditAreaImpl* CreateExpandableEditAreaImplN(ExpandableEditArea* pControl, const Tizen::Graphics::Rectangle& rect, ExpandableEditAreaStyle style, ExpandableEditAreaTitleStyle titleStyle); + _ExpandableEditAreaImpl(ExpandableEditArea* pPublic, _Edit* pCore); + virtual ~_ExpandableEditAreaImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const ExpandableEditArea& GetPublic(void) const; + virtual ExpandableEditArea& GetPublic(void); + virtual const _Edit& GetCore(void) const; + virtual _Edit& GetCore(void); + + result Construct(const Tizen::Graphics::Rectangle& rect, ExpandableEditAreaStyle style, ExpandableEditAreaTitleStyle titleStyle, int maxLines = 10); + result CreateExpandableEditArea(const Tizen::Graphics::Rectangle& rect, ExpandableEditAreaStyle style, ExpandableEditAreaTitleStyle titleStyle, int maxLines); + int GetMargin(EditMarginType marginType) const; + result SetMargin(EditMarginType marginType, int margin); + Tizen::Ui::KeypadAction GetKeypadAction(void) const; + result SetKeypadAction(Tizen::Ui::KeypadAction keypadAction); + KeypadStyle GetKeypadStyle(void) const; + result SetKeypadStyle(KeypadStyle keypadStyle); + result HideKeypad(void); + int GetTextSize(void) const; + result SetTextSize(int size); + Tizen::Graphics::Color GetColor(EditStatus status) const; + Tizen::Graphics::Color GetTextColor(EditTextColor type) const; + result SetBackgroundBitmap(EditStatus status, const Tizen::Graphics::Bitmap& bitmap); + result SetColor(EditStatus status, const Tizen::Graphics::Color& color); + result SetTextColor(EditTextColor type, const Tizen::Graphics::Color& color); + Tizen::Base::String GetText(int start, int end) const; + result AddExpandableEditAreaEventListener(IExpandableEditAreaEventListener& listener); + result RemoveExpandableEditAreaEventListener(IExpandableEditAreaEventListener& listener); + result AddKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + result RemoveKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + result AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + result RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + result AddTextEventListener(Tizen::Ui::ITextEventListener& listener); + result AddLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + result RemoveLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + result RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener); + result SetLowerCaseModeEnabled(bool enable); + bool IsLowerCaseModeEnabled(void) const; + result SetCursorPosition(int position); + int GetCursorPosition(void) const; + Tizen::Base::String GetText(void) const; + int GetTextLength(void) const; + void SetMaxLineCount(int maxLineCount); + int GetMaxLineCount(void) const; + result SetText(const Tizen::Base::String& text); + result InsertTextAt(int index, const Tizen::Base::String& text); + result AppendText(const Tizen::Base::String& text); + result AppendCharacter(const Tizen::Base::Character& character); + result InsertTextAt(int position, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& textImage); + result AppendText(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& textImage); + result Clear(void); + result DeleteCharacterAt(int index); + result InsertCharacterAt(int index, const Tizen::Base::Character& character); + result SetTitleText(const Tizen::Base::String& title); + Tizen::Base::String GetTitleText(void) const; + result SetGuideText(const Tizen::Base::String& guideText); + Tizen::Base::String GetGuideText(void) const; + Tizen::Graphics::Color GetGuideTextColor(void) const; + result SetGuideTextColor(const Tizen::Graphics::Color& color); + int GetLineSpacing (void) const; + result SetLineSpacing (int multiplier, int extra); + Tizen::Graphics::Color GetTitleTextColor(EditStatus status) const; + result SetTitleTextColor(EditStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTokenColor(ExpandableEditAreaTokenStatus status) const; + result SetTokenColor(ExpandableEditAreaTokenStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTokenTextColor(void) const; + Tizen::Graphics::Color GetSelectedTokenTextColor(void) const; + result SetTokenTextColor(const Tizen::Graphics::Color& color); + result SetSelectedTokenTextColor(const Tizen::Graphics::Color& color); + int GetLimitLength(void) const; + result SetLimitLength(int limitLength); + result SetAutoResizingEnabled(bool enable); + bool IsAutoResizingEnabled(void) const; + void SetAutoShrinkModeEnabled(bool enable); + bool IsAutoShrinkModeEnabled(void) const; + + void SetKeypadEnabled(bool enable); + bool IsKeypadEnabled(void) const; + result SetTextPredictionEnabled(bool enable); + bool IsTextPredictionEnabled(void) const; + + result ShowKeypad(void); + int GetTextLineCount(void) const; + result GetBlockRange(int& start, int& end) const; + result ReleaseBlock(void); + result RemoveTextBlock(void); + result SetBlockRange(int start, int end); + + // for token + ITokenFilter* GetTokenFilter(void) const; + result SetTokenFilter(const ITokenFilter* pFilter); + result AppendToken(const Tizen::Base::String& token); + result InsertTokenAt(int index, const Tizen::Base::String& token); + Tizen::Base::String GetTokenAt(int index) const; + int GetTokenCount(void) const; + int GetSelectedTokenIndex(void) const; + bool IsTokenEditModeEnabled(void) const; + result RemoveTokenAt(int index); + result SetTokenSelected(int index, bool selected); + result SetTokenEditModeEnabled(bool enable); + + result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const; + result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode); + +public: + virtual result OnBoundsChanged(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect); + + virtual void OnTextValueChanged(const Tizen::Ui::_Control& source); + virtual void OnTextValueChangeCanceled(const Tizen::Ui::_Control& source); + + virtual void OnExpandableEditAreaLineAdded(const Tizen::Ui::_Control& source, int newLineCount); + virtual void OnExpandableEditAreaLineRemoved(const Tizen::Ui::_Control& source, int newLineCount); + + virtual void OnTextBlockSelected(Tizen::Ui::_Control& source, int start, int end); + + virtual void OnKeypadWillOpen(void); + virtual void OnKeypadOpened(void); + virtual void OnKeypadClosed(void); + virtual void OnKeypadBoundsChanged(void); + virtual void OnKeypadActionPerformed(CoreKeypadAction keypadAction); + + virtual void OnLanguageChanged(Tizen::Locales::LanguageCode oldLanguage, Tizen::Locales::LanguageCode newLanguage); + + virtual bool ReplaceToken(const Tizen::Base::String& token, Tizen::Base::String& replacement); + +public: + static _ExpandableEditAreaImpl* GetInstance(ExpandableEditArea& expandableEditArea); + static const _ExpandableEditAreaImpl* GetInstance(const ExpandableEditArea& expandableEditArea); + +protected: + virtual result Dispose(void); + +private: + _ExpandableEditAreaImpl(const _ExpandableEditAreaImpl&); + _ExpandableEditAreaImpl& operator =(const _ExpandableEditAreaImpl&); + +private: + friend class _Edit; + _Edit* __pExpandableEditArea; + ExpandableEditAreaStyle __expandableEditAreaStyle; + ExpandableEditAreaTitleStyle __expandableEditAreaTitleStyle; + int __maxLineCount; + + _PublicTextEvent* __pPublicTextEvent; + _PublicExpandableEditAreaEvent* __pPublicExpandableEditAreaEvent; + _PublicTextBlockEvent* __pPublicTextBlockEvent; + _PublicKeypadEvent* __pPublicKeypadEvent; + _PublicLanguageEvent* __pPublicLanguageEvent; + + ITokenFilter* __pTokenFilter; +}; // _ExpandableEditAreaImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL__EXPANDABLE_EDIT_AREA_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_ExpandableListData.h b/src/ui/inc/FUiCtrl_ExpandableListData.h new file mode 100644 index 0000000..65765e4 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ExpandableListData.h @@ -0,0 +1,99 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ExpandableListData.h + * @brief This is the header file for the _ExpandableListData class. + * + * This header file contains the declarations of the _MainItem, _SubItem & _ExpandableListItemDataProvider class. + */ + +#ifndef _FUI_CTRL_INTERNAL_EXPANDABLELIST_DATA_H_ +#define _FUI_CTRL_INTERNAL_EXPANDABLELIST_DATA_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _CustomItemData; +class _ExpandableListImpl; + +class _MainItem + : public Tizen::Base::Object +{ +public: + _MainItem(void); + ~_MainItem(void); + +private: + _MainItem(const _MainItem& rhs); + _MainItem& operator =(const _MainItem& rhs); + +public: + bool isExpanded; + bool isEnabled; + int checkCount; + Tizen::Base::Collection::ArrayList subItemList; + Tizen::Base::Collection::ArrayList actualSubItemList; + _CustomItemData* pCustomItemData; +}; //_MainItem + + +class _SubItem + : public Tizen::Base::Object +{ +public: + _SubItem(bool removeItemData = false); + ~_SubItem(void); + +private: + _SubItem(const _SubItem& rhs); + _SubItem& operator =(const _SubItem& rhs); + +public: + bool isEnabled; + _CustomItemData* pCustomItemData; + bool isDeleteNeeded; +}; //_SubItem + + +class _ExpandableListItemDataProvider + : public Tizen::Ui::Controls::IListViewItemProvider +{ +public: + _ExpandableListItemDataProvider(_ExpandableListImpl* pList); + virtual ~_ExpandableListItemDataProvider(void); + int GetItemCount(void); + Tizen::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth); + bool DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth); + +private: + _ExpandableListItemDataProvider(const _ExpandableListItemDataProvider& rhs); + _ExpandableListItemDataProvider& operator =(const _ExpandableListItemDataProvider& rhs); + +private: + _ExpandableListImpl* __pList; +}; //_ExpandableListItemDataProvider + +}}} // Tizen::Ui::Controls + + +#endif //_FUI_CTRL_INTERNAL_EXPANDABLELIST_DATA_H_ diff --git a/src/ui/inc/FUiCtrl_ExpandableListImpl.h b/src/ui/inc/FUiCtrl_ExpandableListImpl.h new file mode 100644 index 0000000..2c791e3 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ExpandableListImpl.h @@ -0,0 +1,235 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ExpandableListImpl.h + * @brief This is the header file for the _ExpandableListImpl class. + * + * This header file contains the declarations of the _ExpandableListImpl class and its helper classes. + */ + +#ifndef _FUI_CTRL_INTERNAL_EXPANDABLELIST_IMPL_H_ +#define _FUI_CTRL_INTERNAL_EXPANDABLELIST_IMPL_H_ + +#include +#include "FUiCtrl_CustomListItemImpl.h" +#include +#include +#include "FUiCtrl_TableViewItemProvider.h" +#include +#include "FUiCtrl_TableView.h" +#include "FUiCtrl_ITableViewItemEventListener.h" +#include "FUiCtrl_ListBaseImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ListView; +class _TableViewGroupItemData; +class _TableViewItemData; +class _CheckBoxElement; +class _ExpandableListImpl; + +class _ExpandableListItemDataProvider + : public Tizen::Ui::Controls::IGroupedTableViewItemProvider +{ +public: + _ExpandableListItemDataProvider(_ExpandableListImpl* pList); + virtual ~_ExpandableListItemDataProvider(void); + + virtual int GetGroupCount(void); + virtual int GetItemCount(int groupIndex); + virtual Tizen::Ui::Controls::TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + virtual Tizen::Ui::Controls::TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth); + virtual bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + virtual bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + virtual bool IsReorderable(int groupIndexFrom, int groupIndexTo); + + void UpdateGroupItem(int groupIndex, TableViewGroupItem *pItem); + void UpdateItem(int groupIndex, int itemIndex, TableViewItem *pItem); + int GetDefaultGroupItemHeight(void); + int GetDefaultItemHeight(void); + +private: + _ExpandableListItemDataProvider(const _ExpandableListItemDataProvider& rhs); + _ExpandableListItemDataProvider& operator =(const _ExpandableListItemDataProvider& rhs); + +private: + _ExpandableListImpl* __pListImpl; +}; //_ExpandableListItemDataProvider + + +class _ExpandableListImpl + : public _ListBaseImpl + , public _ITableViewItemEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + virtual ~_ExpandableListImpl(void); + static _ExpandableListImpl* CreateExpandableListImplN(ExpandableList* pControl, const Tizen::Graphics::Rectangle& bounds, bool itemDivider); + virtual const char* GetPublicClassName(void) const; + virtual const ExpandableList& GetPublic(void) const; + virtual ExpandableList& GetPublic(void); + virtual const _TableView& GetCore(void) const; + virtual _TableView& GetCore(void); + + //@See doxygen + result AddExpandableItemEventListener(const Tizen::Ui::IExpandableItemEventListener& listener); + //@See doxygen + result RemoveExpandableItemEventListener(const Tizen::Ui::IExpandableItemEventListener& listener); + //@See doxygen + result AddItem(const CustomListItem& item, int itemId); + //@See doxygen + result AddSubItem(int mainIndex, const CustomListItem& item, int itemId); + //@See doxygen + result InsertItemAt(int mainIndex, const CustomListItem& item, int itemId); + //@See doxygen + result SetItemAt(int mainIndex, const CustomListItem& item, int itemId); + //@See doxygen + result RemoveItemAt(int mainIndex); + //@See doxygen + result InsertSubItemAt(int mainIndex, int subIndex, const CustomListItem& item, int itemId); + //@See doxygen + result SetSubItemAt(int mainIndex, int subIndex, const CustomListItem& item, int itemId); + //@See doxygen + result RemoveSubItemAt(int mainIndex, int subIndex); + //@See doxygen + result RemoveAllSubItemsAt(int mainIndex); + //@See doxygen + const CustomListItem* GetSubItemAt(int mainIndex, int subIndex) const; + //@See doxygen + result RemoveAllItems(void); + //@See doxygen + int GetItemCount(void) const; + //@See doxygen + int GetSubItemCount(int mainIndex) const; + //@See doxygen + int GetFirstCheckedItemIndex(void) const; + //@See doxygen + int GetItemIdAt(int mainIndex) const; + //@See doxygen + int GetItemIndexFromItemId(int itemId) const; + //@See doxygen + int GetSubItemIdAt(int mainIndex, int subIndex) const; + //@See doxygen + result SetItemExpanded(int mainIndex, bool expand); + //@See doxygen + result SetItemEnabled(int mainIndex, bool enable); + //@See doxygen + bool IsItemEnabled(int mainIndex) const; + //@See doxygen + bool IsItemExpanded(int mainIndex) const; + //@See doxygen + result SetSubItemEnabled(int mainIndex, int subIndex, bool enable); + //@See doxygen + bool IsSubItemEnabled(int mainIndex, int subIndex) const; + //@See doxygen + result SetItemChecked(int mainIndex, bool check); + //@See doxygen + bool IsItemChecked(int mainIndex) const; + //@See doxygen + result SetSubItemChecked(int mainIndex, int subIndex, bool check); + //@See doxygen + bool IsSubItemChecked(int mainIndex, int subIndex) const; + //@See doxygen + result SetAllSubItemsChecked(int mainIndex, bool check); + //@See doxygen + result RemoveAllCheckedSubItemsAt(int mainIndex); + //@See doxygen + int GetFirstCheckedSubItemIndex(int mainIndex) const; + //@See doxygen + int GetLastCheckedItemIndex(void) const; + //@See doxygen + int GetLastCheckedSubItemIndex(int mainIndex) const; + //@See doxygen + int GetNextCheckedItemIndexAfter(int index) const; + //@See doxygen + int GetNextCheckedSubItemIndexAfter(int mainIndex, int subIndex) const; + //@See doxygen + result GetSubItemIndexFromItemId(int itemId, int& mainIndex, int& subIndex) const; + //@See doxygen + result ScrollToBottom(void); + //@See doxygen + result ScrollToTop(void); + //@See doxygen + result ScrollToTop(int mainIndex, int subIndex); + //@See doxygen + result ScrollToTop(int mainIndex); + //@See doxygen + void SetBgColor(const Tizen::Graphics::Color& color); + result RefreshItem(int index); + //@See doxygen + result RefreshSubItem(int mainIndex, int subIndex); + + result Initialize(void); + result LoadArrowBitmap(void); + result UpdateBounds(const Tizen::Graphics::Rectangle& rect); + result SetItemChecked(int groupIndex, int itemIndex, bool check); + bool IsItemChecked(int groupIndex, int subIndex) const; + + void OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + void OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo); + void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + void OnGroupedTableViewItemReordered(_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo); + void OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + void OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction); + + virtual void OnTouchPressed (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + int GetCheckedItemCount(int mainIndex); + + static _ExpandableListImpl* GetInstance(ExpandableList& expandableList); + static const _ExpandableListImpl* GetInstance(const ExpandableList& expandableList); + + void OnDraw(void); + + static void DeleteExpandStateFlag(Tizen::Base::Object* pObj); + +private: + _ExpandableListImpl(Control* pPublic, _TableView* pCore); + _ExpandableListImpl(const _ExpandableListImpl& rhs); + _ExpandableListImpl& operator =(const _ExpandableListImpl& rhs); + result AddSubItem(int mainIndex, _TableViewItemData* pCustomItemData); + virtual void ProcessItemStateChange(int groupIndex, int itemIndex, int elementId, ItemStatus itemStatus); + virtual void ProcessItemStateChange(int groupIndex,int itemIndex, ItemStatus itemStatus); + + int GetCheckedItemCountAt(int mainIndex) const; + result SetSubItemCheckedMarkOnOff(int mainIndex, int subIndex, bool check); + result SetSubItemCheckedRadio(int mainIndex, int subIndex, bool check); + + result CreateArrowIcon(int groupIndex); + +private: + Tizen::Graphics::Bitmap* __pOpenedImage; + Tizen::Graphics::Bitmap* __pClosedImage; + friend class _ExpandableListItemDataProvider; + _ExpandableListItemDataProvider* __pItemProvider; + Tizen::Base::Collection::LinkedList __itemListenersList; + Tizen::Graphics::Color __subItemBgColor; + bool __directDelete; + Tizen::Base::Collection::ArrayList __groupExpandStateList; + + static const int _EXPANDABLE_ICON_ID = Tizen::Base::Integer::VALUE_MAX; +}; //_ExpandableListImpl + +}}} //Tizen::Ui::Controls + + +#endif //_FUI_CTRL_INTERNAL_EXPANDABLELIST_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_FastScroll.h b/src/ui/inc/FUiCtrl_FastScroll.h new file mode 100644 index 0000000..e6780c3 --- /dev/null +++ b/src/ui/inc/FUiCtrl_FastScroll.h @@ -0,0 +1,96 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FastScroll.h + * @brief This is the header file for the _FastScroll class. + * + * This header file contains the declarations of the %_FastScroll class. + */ + +#ifndef _FUICTRL_INTERNAL_FASTSCROLL_H_ +#define _FUICTRL_INTERNAL_FASTSCROLL_H_ + +#include "FUi_Control.h" +#include "FUiCtrl_IFastScrollListener.h" +#include "FUiCtrl_FastScrollPresenter.h" +#include "FUiCtrl_FastScrollIndex.h" +#include "FUi_IAccessibilityListener.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUi_AccessibilityManager.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _OSP_EXPORT_ _FastScroll + : public Tizen::Ui::_Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ +public: + virtual ~_FastScroll(void); + + static _FastScroll* CreateFastScrollN(Tizen::Ui::_Control& parentCtrl); + + result SetIndex(_FastScrollIndex* pIndex); + _FastScrollIndex* GetIndex(void) const; + result UpdateIndex(void); + + void EnableFadeEffect(bool enable); + bool IsEnabledFadeEffect(void) const; + bool IsOnFadeEffect(void) const; + result SetScrollVisibility(bool visibility); + bool GetScrollVisibility(void) const; + void CancelFadeEffect(void); + result InitializeAccessibility(void); + result AddAccessibilityElement(const Tizen::Ui::_AccessibilityContainer& control, bool onAccessibility); + + void AddFastScrollEventListener(const Tizen::Ui::Controls::_IUiFastScrollListener& listener); + void RemoveFastScrollEventListener(const Tizen::Ui::Controls::_IUiFastScrollListener& listener); + + void OnParentBoundsChanged(void); + + virtual result OnAttachedToMainTree(void); + virtual void OnDraw(void); + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + virtual Tizen::Ui::Animations::HitTestResult HitTest(const Tizen::Graphics::FloatPoint& point); + +private: + _FastScroll(const _FastScroll& rhs); + _FastScroll& operator =(const _FastScroll& rhs); + + _FastScroll(void); + result Construct(Tizen::Ui::_Control& parentCtrl); + + void SetPresenter(_FastScrollPresenter& fastScrollPresenter); + _FastScrollPresenter& GetPresenter(void) const; + +private: + _FastScrollPresenter* __pPresenter; + Tizen::Ui::_IAccessibilityListener* __pAccessibilityListener; +}; + +}}} // Tizen::Ui::Controls + +#endif //_FUICTRL_INTERNAL_FASTSCROLL_H_ diff --git a/src/ui/inc/FUiCtrl_FastScrollEvent.h b/src/ui/inc/FUiCtrl_FastScrollEvent.h new file mode 100644 index 0000000..0b1c7ca --- /dev/null +++ b/src/ui/inc/FUiCtrl_FastScrollEvent.h @@ -0,0 +1,111 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FastScrollEvent.h + * @brief This is the header file for _FastScrollEvent class. + * + * This header file contains declaration of _FastScrollEvent class. + * The ItemEvent class can call listener's method. So, when event is occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUICTRL_INTERNAL_FASTSCROLL_EVENT_H_ +#define _FUICTRL_INTERNAL_FASTSCROLL_EVENT_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui { namespace Controls +{ +/** +* @class _FastScrollEvent +* @brief This class handles a slidable event. It is inherited from Event class. +* +*/ +class _FastScrollEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _FastScrollEvent(void); + + /** + * This is the default class destructor. + * + */ + virtual ~_FastScrollEvent(void); + + /** + * This method initializes this instance. This method should be called + * after this instance is constructed. + * + * @return The method returns error code. + * @param[in] source A pointer to the Object instance which contains this instance. + * @exception E_SUCCESS - This method is successful. + * @exception E_ARG_NULL - The input source is null. + */ + result Construct(const Tizen::Ui::Control& source); + +// Accessors +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::Control* GetSource(void) const; + +// Operations +protected: + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @return This method returns a result code. + * @param[in] pListener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of _CustomItemEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attributess +private: + Tizen::Ui::Control* __pSource; +}; +}}}; + +#endif diff --git a/src/ui/inc/FUiCtrl_FastScrollEventArg.h b/src/ui/inc/FUiCtrl_FastScrollEventArg.h new file mode 100644 index 0000000..3ccf66f --- /dev/null +++ b/src/ui/inc/FUiCtrl_FastScrollEventArg.h @@ -0,0 +1,65 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FastScrollEventArg.h + * @brief This is the header file for _FastScrollEventArg class. + * + * This header file contains declaration of _FastScrollEventArg class. + * + */ +#ifndef _FUICTRL_INTERNAL_FASTSCROLL_EVENT_ARG_H_ +#define _FUICTRL_INTERNAL_FASTSCROLL_EVENT_ARG_H_ + +// Includes +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui { namespace Controls +{ + +/** + * @class _FastScrollEventArg + * @brief This class is used as the argument to item event listener. + * + * From this class, one can find out, the (event) source object, index and FastScroll event type. + */ +class _FastScrollEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +public: + _FastScrollEventArg(const Tizen::Ui::Control& source, Tizen::Base::String& index); + virtual ~_FastScrollEventArg(void); + Tizen::Ui::Control* GetSource(void); + Tizen::Base::String GetIndex(void); + +private: + Tizen::Ui::Control* __pSource; + Tizen::Base::String& __index; +}; + + +}}} // Tizen::Ui::Controls + +#endif diff --git a/src/ui/inc/FUiCtrl_FastScrollIndex.h b/src/ui/inc/FUiCtrl_FastScrollIndex.h new file mode 100644 index 0000000..e1523d1 --- /dev/null +++ b/src/ui/inc/FUiCtrl_FastScrollIndex.h @@ -0,0 +1,124 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FastScrollIndex.h + * @brief This is the header file for the _FastScrollIndex class. + * + * This header file contains the declarations of the %_FastScrollIndex class. + */ + +#ifndef _FUICTRL_INTERNAL_FASTSCROLL_INDEX_H_ +#define _FUICTRL_INTERNAL_FASTSCROLL_INDEX_H_ + +#include "FBaseObject.h" +#include "FBaseString.h" +#include "FBaseColArrayList.h" +#include "FGrpBitmap.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +class _FastScrollIndex; + +enum _FastScrollIndexType +{ + FAST_SCROLL_INDEX_TYPE_NORMAL = 0, + FAST_SCROLL_INDEX_TYPE_OMISSION, +}; + +class _IFastScrollIndexObserver + : public Tizen::Base::Object +{ +public: + virtual ~_IFastScrollIndexObserver(void){} + + virtual void OnIndexDataUpdated(_FastScrollIndex& updatedIndex) = 0; + virtual void OnIndexDeleted(_FastScrollIndex& deletedIndex) = 0; + virtual void OnChildIndexAttached(_FastScrollIndex& parentIndex, int attachedOrder, _FastScrollIndex& attachedIndex) = 0; + virtual void OnChildIndexDetached(_FastScrollIndex& parentIndex, int detachedOrder, _FastScrollIndex& detachedIndex) = 0; +}; + +class _FastScrollIndex + : public Tizen::Base::Object +{ +public: + virtual ~_FastScrollIndex(void); + + static _FastScrollIndex* CreateFastScrollIndexN(void); + + result SetIndexText(Tizen::Base::String* pText); + Tizen::Base::String* GetIndexText(void) const; + + result SetIndexImage(Tizen::Graphics::Bitmap* pImage); + Tizen::Graphics::Bitmap* GetIndexImage(void) const; + + void SetIndexObserver(_IFastScrollIndexObserver* pIndexListener); + _IFastScrollIndexObserver* GetIndexObserver(void) const; + + result SetOmissionIndex(int indexCountMax); + + result AddChildIndex(Tizen::Base::String* pText, Tizen::Graphics::Bitmap* pImage, bool omitted = false); + result AddChildIndex(_FastScrollIndex* pChildIndex, bool omitted = false); + result AddChildIndex(int childOrder, Tizen::Base::String* pText, Tizen::Graphics::Bitmap* pImage, bool omitted = false); + result AddChildIndex(int childOrder, _FastScrollIndex* pChildIndex, bool omitted = false); + void AddOmissionChildIndex(_FastScrollIndex* pChildIndex); + result AddChildTextIndexArray(int childOrder, const wchar_t* pTextIndexArray, int textLenth, int indexCount); + + result RemoveChildIndex(int childOrder, bool destroy); + result RemoveChildIndex(_FastScrollIndex* pChildIndex, bool destroy); + void RemoveChildren(bool destroy); + result RemoveOmissionChildren(bool destroy); + + void SetParentIndex(_FastScrollIndex* pParent); + _FastScrollIndex* GetParentIndex(void) const; + + _FastScrollIndex* GetChildIndex(int childOrder, bool omitted = false) const; + int GetChildOrder(const _FastScrollIndex* pChildIndex, bool omitted = false) const; + int GetChildCount(bool omitted = false) const; + int GetIndexOrder(bool omitted = false) const; + + void SetIndexType(_FastScrollIndexType type); + _FastScrollIndexType GetIndexType(void) const; + + void SetOmitted(bool omitted); + bool GetOmitted(void) const; + +private: + _FastScrollIndex(const _FastScrollIndex& rhs); + _FastScrollIndex& operator =(const _FastScrollIndex& rhs); + + _FastScrollIndex(void); + result Construct(void); + +private: + Tizen::Graphics::Bitmap* __pImage; + Tizen::Base::String* __pText; + + _FastScrollIndex* __pParentIndex; + Tizen::Base::Collection::ArrayList __childIndexList; + Tizen::Base::Collection::ArrayList __childOmittedIndexList; + + _IFastScrollIndexObserver* __pIndexObserver; + + bool __omitted; + _FastScrollIndexType __indexType; + +}; + +} } } // Tizen::Ui::Controls + +#endif //_FUICTRL_INTERNAL_FASTSCROLL_INDEX_H_ diff --git a/src/ui/inc/FUiCtrl_FastScrollIndexNode.h b/src/ui/inc/FUiCtrl_FastScrollIndexNode.h new file mode 100644 index 0000000..2446120 --- /dev/null +++ b/src/ui/inc/FUiCtrl_FastScrollIndexNode.h @@ -0,0 +1,80 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FastScrollIndexNode.h + * @brief This is the header file for the _FastScrollIndexNode class. + * + * This header file contains the declarations of the %_FastScrollIndexNode class. + */ + +#ifndef _FUICTRL_INTERNAL_FASTSCROLL_INDEXNODE_H_ +#define _FUICTRL_INTERNAL_FASTSCROLL_INDEXNODE_H_ + +#if 0 + +#include "FBaseString.h" +#include "FGrpBitmap.h" +#include "FUiCtrl_FastScrollIndex.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _FastScrollIndexNode +{ +public: + virtual ~_FastScrollIndexNode(void); + + static _FastScrollIndexNode* CreateFastScrollIndexNodeN(Tizen::Graphics::Bitmap* pImage, Tizen::Base::String* pText); + + Tizen::Graphics::Bitmap* GetIndexNodeImage(void); + Tizen::Base::String* GetIndexNodeText(void); + + result SetIndexNodeOrder(int indexNodeOrder); + int GetIndexNodeOrder(void); + + result SetChildIndex(_FastScrollIndex* pChildIndex); + _FastScrollIndex* GetChildIndex(void); + + result SetOmissionIndex(_FastScrollIndex* pChildIndex); + _FastScrollIndex* GetOmissionIndex(void); + + result RemoveChildIndex(void); + result RemoveOmissionIndex(void); + +private: + _FastScrollIndexNode(const _FastScrollIndexNode& rhs); + _FastScrollModel& operator =(const _FastScrollIndexNode& rhs); + + _FastScrollIndexNode(void); + result Contruct(Tizen::Graphics::Bitmap* pImage, Tizen::Base::String* pText); + +private: + Tizen::Graphics::Bitmap* __pImage; + Tizen::Base::String* __pText; + + int __indexNodeOrder; + + _FastScrollIndex* __pChildIndex; + _FastScrollIndex* __pOmissionIndex; +}; + +} }} // Tizen::Ui::Controls + +#endif + +#endif //_FUICTRL_INTERNAL_FASTSCROLL_INDEXNODE_H_ diff --git a/src/ui/inc/FUiCtrl_FastScrollModel.h b/src/ui/inc/FUiCtrl_FastScrollModel.h new file mode 100644 index 0000000..88dd2b0 --- /dev/null +++ b/src/ui/inc/FUiCtrl_FastScrollModel.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FastScrollModel.h + * @brief This is the header file for the _FastScrollModel class. + * + * This header file contains the declarations of the %_FastScrollModel class. + */ + +#ifndef _FUICTRL_INTERNAL_FASTSCROLL_MODEL_H_ +#define _FUICTRL_INTERNAL_FASTSCROLL_MODEL_H_ + +#include "FUiCtrl_FastScrollIndex.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _FastScrollModel +{ +public: + virtual ~_FastScrollModel(void); + + static _FastScrollModel* CreateFastScrollModelN(void); + + result SetRootIndex(_FastScrollIndex* pIndex); + _FastScrollIndex* GetRootIndex(void) const; + +private: + _FastScrollModel(const _FastScrollModel& rhs); + _FastScrollModel& operator =(const _FastScrollModel& rhs); + + _FastScrollModel(void); + result Construct(void); + +private: + int __visibleIndexNodeCount; + _FastScrollIndex* __pRootIndex; +}; + +} } } // Tizen::Ui::Controls + +#endif //_FUICTRL_INTERNAL_FASTSCROLL_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_FastScrollPresenter.h b/src/ui/inc/FUiCtrl_FastScrollPresenter.h new file mode 100644 index 0000000..b07f17d --- /dev/null +++ b/src/ui/inc/FUiCtrl_FastScrollPresenter.h @@ -0,0 +1,384 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FastScrollPresenter.h + * @brief This is the header file for the _FastScrollPresenter class. + * + * This header file contains the declarations of the %_FastScrollPresenter class. + */ + +#ifndef _FUICTRL_INTERNAL_FASTSCROLL_PRESENTER_H_ +#define _FUICTRL_INTERNAL_FASTSCROLL_PRESENTER_H_ + +#include "FBaseString.h" +#include "FGrpFloatMatrix4.h" + +#include "FGrpBitmap.h" +#include "FGrpRectangle.h" +#include "FGrpColor.h" +#include "FGrpDimension.h" +#include "FGrp_TextTextObject.h" + +#include "FUi_Control.h" +#include "FUiCtrl_IFastScrollListener.h" +#include "FUiCtrl_UiFastScrollEvent.h" + +#include "FUiAnim_VisualElement.h" +#include "FUiAnimVisualElementAnimation.h" +#include "FUiAnimVisualElementAnimationProvider.h" +#include "FUiAnimIVisualElementAnimationStatusEventListener.h" +#include "FUiAnimVisualElementContentProvider.h" +#include "FUiAnimIVisualElementContentProvider.h" + +#include "FUiCtrl_FastScroll.h" +#include "FUiCtrl_FastScrollIndex.h" +#include "FUiCtrl_FastScrollModel.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _FastScrollViewConfig +{ +public: + virtual ~_FastScrollViewConfig(void); + static _FastScrollViewConfig* CreateFastScrollViewConfigN(Tizen::Ui::_ControlOrientation orientation); + + result ReloadConfig(Tizen::Ui::_ControlOrientation orientation); + void ReleaseResources(void); + +private: + _FastScrollViewConfig(const _FastScrollViewConfig& rhs); + _FastScrollViewConfig& operator =(const _FastScrollViewConfig& rhs); + + _FastScrollViewConfig(void); + result Construct(Tizen::Ui::_ControlOrientation orientation); + +private: + friend class _FastScrollIndexView; + friend class _FastScrollPopupView; + friend class _FastScrollPresenter; + + Tizen::Graphics::Color __indexBgColor; + Tizen::Graphics::Color __indexHighlightColor; + Tizen::Graphics::Color __indexLeftLineColor; + Tizen::Graphics::Color __indexTextColor; + Tizen::Graphics::Color __indexSeparatorColor; + Tizen::Graphics::Color __selectedIndexBgColor; + Tizen::Graphics::Color __selectedIndexTextColor; + Tizen::Graphics::Color __selectedIndexOutlineColor; + Tizen::Graphics::Color __popupBgColor; + Tizen::Graphics::Color __popupTextColor; + + Tizen::Graphics::Dimension __indexSizeMin; + Tizen::Graphics::Dimension __popupSize; + + int __indexMarginRight; + int __indexMarginTop; + int __indexGap; + + int __indexLeftLineThickness; + int __indexTextSize; + int __indexSeparatorThickness; + int __selectedIndexMarginRight; + int __selectedIndexHeight; + int __popupWidthIncrement; + int __popupTextSize; + int __popupShadowRight; + int __popupShadowBottom; + + Tizen::Graphics::Bitmap* __pIndexBgBitmap; + Tizen::Graphics::Bitmap* __pSelectedIndexBgBitmap; + Tizen::Graphics::Bitmap* __pSelectedIndexOutlineBitmap; + Tizen::Graphics::Bitmap* __pPopupBgBitmap; + Tizen::Graphics::Bitmap* __pPopupBgEffectBitmap; + + Tizen::Graphics::Font* __pFont; +}; + + +class _FastScrollIndexView + : public Tizen::Base::Object + , public Tizen::Ui::Animations::VisualElementAnimationProvider + , public Tizen::Ui::Animations::VisualElementContentProvider + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener + , virtual public Tizen::Ui::Animations::IVisualElementAnimationProvider + , virtual public _IUiEventListener +{ +public: + virtual ~_FastScrollIndexView(void); + + static _FastScrollIndexView* CreateFastScrollIndexViewN(Tizen::Ui::Animations::_VisualElement& parentVe, _FastScrollViewConfig& viewConfig); + + result FadeOutAndDestroy(void); + + result SetBaseIndex(_FastScrollIndex* pIndex); + _FastScrollIndex* GetBaseIndex(void) const; + + result SetIndexBounds(const Tizen::Graphics::Rectangle& indexBounds); + Tizen::Graphics::Rectangle GetIndexBounds(void) const; + result SetSelectedBgBounds(const Tizen::Graphics::Rectangle& indexBounds); + Tizen::Graphics::Rectangle GetSelectedBgBounds(void) const; + result SetSelectedIndexBounds(const Tizen::Graphics::Rectangle& indexBounds); + Tizen::Graphics::Rectangle GetSelectedIndexBounds(void) const; + + _FastScrollIndex* GetIndexAtPoint(const Tizen::Graphics::Point& point) const; + _FastScrollIndex* GetOmissionIndexAtPoint(_FastScrollIndex* pIndex, const Tizen::Graphics::Point& point) const; + int GetIndexHeight(void) const; + result SelectIndex(int indexOrder); + result SelectIndex(_FastScrollIndex* pIndex, bool animation); + int GetSelectedIndexOrder(void) const; + _FastScrollIndex* GetSelectedIndex(void) const; + void SetSelectedIndexInOmittedIndex(_FastScrollIndex* pIndex); + _FastScrollIndex* GetSelectedIndexInOmittedIndex(void) const; + _FastScrollIndex* GetFormerIndex(void) const; + + bool IsOnAnimation(void) const; + void RemoveAllAnimations(void); + + result SetIndexVisibility(bool visibility); + bool GetIndexVisibility(void) const; + result SetSelectedIndexVisibility(bool visibility, bool bAnimation); + bool GetSelectedIndexVisibility(void) const; + result AddAccessibilityElement(const Tizen::Ui::_AccessibilityContainer& control); + + result UpdateIndex(bool bNeedUpdateBaseIndex); + Tizen::Graphics::Rectangle CalculateSelectedBg(void); + + void OnDraw(void); + void DrawBaseIndex(void); + void DrawSelectedBg(void); + void DrawSelectedIndex(void); + result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap); + result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& srcRect, const Tizen::Graphics::Bitmap& bitmap, const Tizen::Graphics::Rectangle& dstRect); + + virtual Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationForProperty(Tizen::Ui::Animations::VisualElement& target, const Tizen::Base::String& property); + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount); + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + +private: + _FastScrollIndexView(const _FastScrollIndexView& rhs); + _FastScrollIndexView& operator =(const _FastScrollIndexView& rhs); + + _FastScrollIndexView(Tizen::Ui::Animations::_VisualElement& parentVe, _FastScrollViewConfig& viewConfig); + result Construct(void); + +private: + Tizen::Ui::Animations::_VisualElement& __parentVe; + _FastScrollViewConfig& __viewConfig; + + _FastScrollIndex* __pBaseIndex; + _FastScrollIndex* __pSelectedIndex; + _FastScrollIndex* __pSelectedIndexInOmittedIndex; + _FastScrollIndex* __pFormerIndex; + Tizen::Ui::Animations::_VisualElement* __pBaseIndexVe; + Tizen::Ui::Animations::_VisualElement* __pSelectedBgVe; + Tizen::Ui::Animations::_VisualElement* __pSelectedIndexVe; + + bool __needUpdateBaseIndex; + bool __needUpdateSelectedIndex; + bool __needDestroySelf; +}; + +class _FastScrollPopupView + : public Tizen::Ui::Animations::VisualElementAnimationProvider + , public Tizen::Ui::Animations::VisualElementContentProvider + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener + , virtual public Tizen::Ui::Animations::IVisualElementAnimationProvider + , virtual public _IUiEventListener +{ +public: + virtual ~_FastScrollPopupView(void); + + static _FastScrollPopupView* CreateFastScrollPopupViewN(Tizen::Ui::Animations::_VisualElement& parentVe, _FastScrollViewConfig& viewConfig); + + result FadeOutAndDestroy(void); + + result SelectIndex(int indexLevel, _FastScrollIndex* pIndex, _FastScrollIndex* pFormerIndex); + result AddPopupIndexVe(int indexLevel); + result RemovePopupIndexVe(int indexLevel); + + result SetPopupBounds(const Tizen::Graphics::Rectangle& indexBounds); + Tizen::Graphics::Rectangle GetPopupBounds(void) const; + result SetPopupIndexBounds(int indexLevel, const _FastScrollIndex* pBaseIndex); + Tizen::Graphics::Rectangle GetPopupIndexBounds(int indexLevel) const; + Tizen::Ui::Animations::_VisualElement* GetIndexVe(int indexLevel) const; + int GetIndexVeCount(void) const; + + bool IsOnAnimation(void) const; + void RemoveAllAnimations(void); + + result SetPopupVisibility(bool visibility); + bool GetPopupVisibility(void) const; + void SetPopupVeUpdateNeeded(bool needUpdate); + + result UpdateIndex(void); + + void DrawPopupVe(void); + void DrawPopupIndexVe(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex); + + void OnDraw(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex); + result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap); + result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& srcRect, const Tizen::Graphics::Bitmap& bitmap, const Tizen::Graphics::Rectangle& dstRect); + + virtual Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationForProperty(Tizen::Ui::Animations::VisualElement& target, const Tizen::Base::String& property); + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount); + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + +private: + _FastScrollPopupView(const _FastScrollPopupView& rhs); + _FastScrollPopupView& operator =(const _FastScrollPopupView& rhs); + + _FastScrollPopupView(Tizen::Ui::Animations::_VisualElement& parentVe, _FastScrollViewConfig& viewConfig); + result Construct(void); + +private: + Tizen::Ui::Animations::_VisualElement& __parentVe; + _FastScrollViewConfig& __viewConfig; + + Tizen::Ui::Animations::_VisualElement* __pPopupVe; + Tizen::Base::Collection::ArrayList __indexViews; + + Tizen::Graphics::FloatMatrix4 __matrixOrigin; + Tizen::Graphics::FloatMatrix4 __matrixFadeInStart; + Tizen::Graphics::FloatMatrix4 __matrixFadeOutEnd; + + bool __needUpdatePopupVe; + bool __needUpdatePopupIndexVe; + bool __needDestroySelf; +}; + + +class _FastScroll; + +class _FastScrollPresenter + : public Tizen::Ui::Animations::VisualElementAnimationProvider + , public Tizen::Ui::Animations::VisualElementContentProvider + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener + , public _IFastScrollIndexObserver + , virtual public Tizen::Ui::Animations::IVisualElementAnimationProvider + , virtual public _IUiEventListener +{ +public: + virtual ~_FastScrollPresenter(void); + + static _FastScrollPresenter* CreateFastScrollPresenterN(Tizen::Ui::_Control& parentCtrl, + _FastScroll& fastScroll, + bool visibility = false); + + result SetRootIndex(_FastScrollIndex* pIndex); + _FastScrollIndex* GetRootIndex(void) const; + result UpdateIndex(void); + + void EnableFadeEffect(bool enable); + bool IsEnabledFadeEffect(void) const; + bool IsOnFadeEffect(void) const; + bool IsScrollVisible(void) const; + result SetScrollVisibility(bool visibility); + bool GetScrollVisibility(void) const; + void CancelFadeEffect(void); + + void AddFastScrollEventListener(const Tizen::Ui::Controls::_IUiFastScrollListener& listener); + void RemoveFastScrollEventListener(const Tizen::Ui::Controls::_IUiFastScrollListener& listener); + result AddAccessibilityElement(const Tizen::Ui::_AccessibilityContainer& control, bool onAccessibility); + + void OnParentBoundsChanged(void); + + void OnDraw(void); + bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + result SetFontInfo(unsigned long style, int size); + Tizen::Ui::Animations::HitTestResult HitTest(const Tizen::Graphics::FloatPoint& point); + + virtual Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationForProperty(Tizen::Ui::Animations::VisualElement& target, const Tizen::Base::String& property); + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount); + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + + virtual void OnIndexDataUpdated(_FastScrollIndex& updatedIndex); + virtual void OnIndexDeleted(_FastScrollIndex& deletedIndex); + virtual void OnChildIndexAttached(_FastScrollIndex& parentIndex, int attachedOrder, _FastScrollIndex& attachedIndex); + virtual void OnChildIndexDetached(_FastScrollIndex& parentIndex, int detachedOrder, _FastScrollIndex& detachedIndex); + +private: + _FastScrollPresenter(const _FastScrollPresenter& rhs); + _FastScrollPresenter& operator =(const _FastScrollPresenter& rhs); + + _FastScrollPresenter(Tizen::Ui::_Control& parentCtrl, _FastScroll& fastScroll, bool visibility); + result Construct(void); + + Tizen::Graphics::Rectangle CalculateFastScrollBounds(int indexCount); + Tizen::Graphics::Rectangle CalculateIndexBounds(int indexLevel, _FastScrollIndex& pIndex); + Tizen::Graphics::Rectangle CalculatePopupBounds(void); + void RelayoutFastScrollChildren(void); + + _FastScrollIndex* SelectOnIndexViews(const Tizen::Graphics::Point& point, bool animation); + result DeselectIndexViews(void); + + result SetPopupIndex(_FastScrollIndex& popupIndex, const Tizen::Graphics::Point& point); + result ClearPopupIndex(void); + + result FireFastScrollEvent(_FastScrollIndex& selectedIndex); + + bool OnTouchPressedAndMoved(const Tizen::Graphics::Point& point, bool animation); + bool OnTouchReleasedAndCanceled(void); + + result AddIndexView(_FastScrollIndex& baseIndex); + result AddIndexView(int indexLevel, _FastScrollIndex& baseIndex); + result RemoveIndexView(int indexLevel, bool fadeout); + result RemoveAllIndexViews(bool fadeout); + + _FastScrollIndexView* GetIndexView(int indexLevel) const; + int GetIndexViewCount(void) const; + +private: + Tizen::Ui::_Control& __parentCtrl; + _FastScroll& __fastScroll; + Tizen::Ui::Animations::_VisualElement* __pCtrlVe; + + _FastScrollViewConfig* __pViewConfig; + + _UiFastScrollEvent* __pFastScrollEvent; + _FastScrollModel* __pFastScrollModel; + unsigned long __fontStyle; + int __fontSize; + + _FastScrollPopupView* __pPopupView; + Tizen::Base::Collection::ArrayList __indexViews; + + int __focusedIndexLevel; + _FastScrollIndex* __pSelectedIndex; + + bool __enableFadeEffect; + int __indexCountMax; + bool __fadeIn; + bool __fadeOut; + bool __scrollVisibility; + int __fadeEffectDuration_ms; + +}; + +} } } // Tizen::Ui::Controls + +#endif //_FUICTRL_INTERNAL_FASTSCROLL_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_FlickAnimation.h b/src/ui/inc/FUiCtrl_FlickAnimation.h new file mode 100644 index 0000000..2771d4a --- /dev/null +++ b/src/ui/inc/FUiCtrl_FlickAnimation.h @@ -0,0 +1,151 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_FlickAnimation.h + * @brief This is the header file for the _FlickAnimation class. + * + * This header file contains the declarations of the _FlickAnimation class. + */ + +#ifndef _FUI_CTRL_INTERNAL_FLICKANIMATION_H_ +#define _FUI_CTRL_INTERNAL_FLICKANIMATION_H_ + +const int DEVICE_SIZE_HORIZONTAL = 56; // LCD Width (mm) +const int DEVICE_SIZE_VERTICAL = 93; // LCD Hight (mm) +const int FLICK_ANIMATION_FPS_LIST = 300; // List FPS +const int FLICK_ANIMATION_SENSITIVITY_LIST = 150; // List Animation Sensitivity +const int FLICK_ANIMATION_FPS_ICONLIST = 60; // IconList FPS +const int FLICK_ANIMATION_SENSITIVITY_ICONLIST = 30;// IconList Animation Sensitivity +const int FLICK_ANIMATION_FPS_PANEL = 30; // Panel FPS +const int FLICK_ANIMATION_SENSITIVITY_PANEL = 30; // Panel Animation Sensitivity + + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum FlickDir +{ + FD_VERTICAL = 0x1, + FD_HORIZONTAL = 0x2, + FD_BOTH = FD_VERTICAL | FD_HORIZONTAL, +}; + +class _FlickAnimation +{ +public: + _FlickAnimation(void); + + virtual ~_FlickAnimation(void); + + // Functions for Setting Parameter + void SetSizeInformation(int resW, int resH, int mmW, int mmH); + + void SetAlignInformation(int alignW, int alignH); + + void SetSensitivity(int fps, int sensitivity); + + void SetDirection(int dir); + + void SetTensionEnable(bool enableX, bool enableY); + + // Check Item Executable or not + bool IsItemExecutable(int flickX, int flickY); + + // Functions For Initializeialization of Flick Animation + void CalculateInitializeVelocity(int flickX, int flickY, int flickTime, int* pFlkVelX, int* pFlkVelY); + + int EstimateInitializeVelocity(int totalDist, int idx = 1); + + // Functions For Flick Animation + void InitializeFlickAmount(int flkVelX, int flkVelY); + + int CalculateNextMove(int* pMoveX, int* pMoveY); + + // For Legacy : Functions For Flick Animation + void InitializeFlickAmount(int flkVel); + + int CalculateNextMove(void); + + bool StartTensionEffect(int pos, int end, int idx = 1); + + // Functions for Getting State Value + int GetCurVelocity(int idx = 1) const; + + int GetCurFriction(int idx = 1) const; + +private: + void InitializeFlick(int flkVelX, int flkVelY); + + void InitializeFlickXY(int flkVel, int idx); + + int CalculateNextMoveXY(int idx); + + void InitializeTension(void); + +private: + // Tuning Parameter + static const int FLK_ANI_TIME_MIN_MSEC = 1500; // Minimum Animation Duration + static const int FLK_ANI_TIME_MAX_MSEC = 3000; // Maximum Animation Duration + static const int FLK_ANI_DEFAULT_ALIGN_RATIO = 6; // Default Item Counts for Virtual Align Height + static const int FLK_ANI_OVERSPEED_START_CNT = 1; // Overspeed starting draw count + static const int FLK_ANI_OVERSPEED_END_CNT = 14; // Overspeed ending draw count + static const int FLK_WEIGHT_VEL = 1; // Flick Velocity weight + static const int FLK_WEIGHT_DIST = 5;//20 // Flick Distance weight + static const int FLK_ALPHA_PER_MM = 240; // mm - Flick Coefficient + static const int FLK_ALPHA_PER_PIXEL = 3; // pixel - Flick Coefficient + static const int FLK_ANI_SPEED_MIN_RATIO = 5; // Flick Animation Minimum Speed Ratio (Vmin=Vmax/Ratio) + static const int FLK_SPEED_MIN = 400; // Minimum Flick Speed for Stage 1 + static const int FLK_SPEED_THRES1 = 2400; // Flick Speed Threshold for Stage 2 + static const int FLK_SPEED_THRES2 = 3000; // Flick Speed Threshold for Stage 3 (Overspeed applied) + static const int FLK_OVERSPEED_STEP = 800; // Acceleration Step for Overspeed + + int __flickDirection; // Flick Direction + int __dimension[2]; // Width/Height Dimension (mm) + int __resolution[2]; // Width/Height Resolution (pixel) + int __align[2]; // Align Width/Height Resolution (pixel) + int __margin[2]; // Margin Width/Height Resolution (pixel) + + int __flickAnimationFPS; + int __flickAnimationFPSRef; + int __flickAnimaionTimeMin; + int __flickAnimationTimeMax; + + int __friction[2]; // Friction Coefficient + int __velocity[2]; // Animation Velocity + + int __frictionMin[2]; // Minimum Friction Coefficient near Stop + int __velocityMin[2]; // Minimum Animation Velocity near Stop + + int __acceleration[2]; // Animation Acceleration Coefficient + int __drawCount; // Drawing Count + + enum + { + TENSION_NA = 0, + TENSION_DONE, + TENSION_COMPRESS, + TENSION_RELEASE + } + + __tensionStatus[2]; // Tension Effect Status + int __tensionDistMax[2]; // Maximum Distance for Tension Effect +}; // _FlickAnimation + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_FLICKANIMATION_H_ diff --git a/src/ui/inc/FUiCtrl_FooterImpl.h b/src/ui/inc/FUiCtrl_FooterImpl.h new file mode 100644 index 0000000..83e0a2c --- /dev/null +++ b/src/ui/inc/FUiCtrl_FooterImpl.h @@ -0,0 +1,197 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FooterImpl.h + * @brief This is the header file for the _FooterImp class. + * + * This header file contains the declarations of the %_FooterImp class. + */ + +#ifndef _FUI_CTRL_INTERNAL_FOOTER_IMPL_H_ +#define _FUI_CTRL_INTERNAL_FOOTER_IMPL_H_ + +#include +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_Toolbar.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _PublicActionEvent; + +const int FOOTER_MAX_STATE_COUNT = 7; +const int FOOTER_BUTTON_MAX_STATE_COUNT = 4; +const int FOOTER_MAX_ITEM_COUNT_WITH_BUTTON = 3; +const int FOOTER_BUTTON_MAX_COUNT = 3; +const int FOOTER_ITEM_MAX_COUNT = 15; +const int FOOTER_ACTION_ID_MIN = 0; +const int FOOTER_ACTION_ID_MAX = INT_MAX; +const int FOOTER_NUMBERD_BADGE_ICON_NUMBER_MAX = 99999; + +class _FooterImpl + : public _ControlImpl + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + static _FooterImpl* CreateFooterImplN(Footer* pControl); + + _FooterImpl(Footer* pPublic, _Toolbar* pCore); + + virtual ~_FooterImpl(void); + + Footer* GetFooter(void) const; + + virtual const char* GetPublicClassName(void) const; + + virtual const Footer& GetPublic(void) const; + + virtual Footer& GetPublic(void); + + virtual const _Toolbar& GetCore(void) const; + + virtual _Toolbar& GetCore(void); + + static const _FooterImpl* GetInstance(const Footer& footer); + + static _FooterImpl* GetInstance(Footer& footer); + + result AddItem(const FooterItem& item); + + Tizen::Graphics::Color GetButtonColor(ButtonItemStatus status) const; + + Tizen::Graphics::Color GetButtonTextColor(ButtonItemStatus status) const; + + ButtonItemStatus GetButtonStatus(ButtonPosition position) const; + + ButtonItemStatus GetBackButtonStatus(void) const; + + Tizen::Graphics::Color GetItemColor(FooterItemStatus status) const; + + int GetItemCount(void) const; + + result GetItemStatus(int itemIndex, FooterItemStatus& status) const; + + Tizen::Graphics::Color GetItemTextColor(FooterItemStatus status) const; + + FooterStyle GetStyle(void) const; + + int GetSelectedItemIndex(void) const; + + Tizen::Graphics::Color GetColor(void) const; + + result InsertItemAt(int itemIndex, const FooterItem& item); + + bool IsButtonSet(ButtonPosition position) const; + + bool IsBackButtonSet(void) const; + + bool IsTabEditModeEnabled(void) const; + + result RemoveAllButtons(void); + + result RemoveButtonAt(ButtonPosition position); + + result RemoveBackButton(void); + + result RemoveAllItems(void); + + result RemoveItemAt(int itemIndex); + + result SetBackButton(void); + + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + result SetButton(ButtonPosition position, const ButtonItem& button); + + result SetButtonColor(ButtonItemStatus status, const Tizen::Graphics::Color& color); + + result SetButtonTextColor(ButtonItemStatus status, const Tizen::Graphics::Color& color); + + result SetButtonEnabled(ButtonPosition position, bool enable); + + result SetBackButtonEnabled(bool enable); + + result SetItemAt(int itemIndex, const FooterItem& item); + + result SetItemColor(FooterItemStatus status, const Tizen::Graphics::Color& color); + + result SetItemEnabled(int itemIndex, bool enable); + + result SetItemBadgeIcon(int itemIndex, const Tizen::Graphics::Bitmap* pBadgeIcon); + + result SetItemTextColor(FooterItemStatus status, const Tizen::Graphics::Color& color); + + result SetItemSelected(int itemIndex); + + result SetItemNumberedBadgeIcon(int itemIndex, int number); + + result SetColor(const Tizen::Graphics::Color& color); + + result SetStyle(FooterStyle style); + + result SetTabEditModeEnabled(bool enable); + + result SetTransparent(bool transparent); + + Tizen::Graphics::Rectangle GetButtonBounds(ButtonPosition position) const; + + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + + +private: + result CheckItemValidate(const FooterItem& item); + + _Button* ConvertButtonItem(const ButtonItem& buttonItem); + + _Button* ConvertFooterItem(const FooterItem& footerItem); + + ButtonItemStatus ConvertButtonItemStatus(_ButtonStatus status) const; + + FooterItemStatus ConvertFooterItemStatus(_ButtonStatus status) const; + + _ButtonStatus ConvertButtonStatus(ButtonItemStatus status) const; + + _ButtonStatus ConvertButtonStatus(FooterItemStatus status) const; + + ToolbarStyle ConvertFooterStyle(FooterStyle style); + + virtual void OnChangeLayout(_ControlOrientation orientation); + + _FooterImpl(const _FooterImpl&); + + _FooterImpl& operator =(const _FooterImpl&); + + +private: + //bool __calledBySetItemSelected; + + FooterStyle __style; + + _PublicActionEvent* __pPublicActionEvent; + +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_FOOTER_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_FooterItemImpl.h b/src/ui/inc/FUiCtrl_FooterItemImpl.h new file mode 100644 index 0000000..7b5e828 --- /dev/null +++ b/src/ui/inc/FUiCtrl_FooterItemImpl.h @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FooterItemImpl.h + * @brief This is the header file for the %_FooterItemImpl class. + * + * This header file contains the declarations of the %_FooterItemImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_FOOTER_ITEM_IMPL_H_ +#define _FUI_CTRL_INTERNAL_FOOTER_ITEM_IMPL_H_ + +#include +#include + + +namespace Tizen { namespace Ui { namespace Controls +{ + +static const int FOOTER_ITEM_ACTION_ID_MIN = 0; +static const int FOOTER_ITEM_ACTION_ID_MAX = INT_MAX; +static const int FOOTER_ITEM_MAX_STATE_COUNT = 5; + +class _FooterItemImpl + : public Tizen::Base::Object +{ + +public: + _FooterItemImpl(FooterItem* pPublic); + + virtual ~_FooterItemImpl(void); + + static const _FooterItemImpl* GetInstance(const FooterItem& footerItem); + + static _FooterItemImpl* GetInstance(FooterItem& footerItem); + + result Construct(int actionId); + + int GetActionId(void) const; + + const Tizen::Graphics::Bitmap* GetBackgroundBitmap(FooterItemStatus status) const; + + const Tizen::Graphics::Bitmap* GetIcon(FooterItemStatus status) const; + + Tizen::Base::String GetText(void) const; + + result SetActionId(int actionId); + + result SetBackgroundBitmap(FooterItemStatus status, const Tizen::Graphics::Bitmap* pBitmap); + + result SetIcon(FooterItemStatus status, const Tizen::Graphics::Bitmap* pIcon); + + result SetText(const Tizen::Base::String& text); + + +private: + _FooterItemImpl(const _FooterItemImpl& footerItem); + + _FooterItemImpl& operator =(const _FooterItemImpl& footerItem); + + +private: + int __actionId; + Tizen::Base::String __itemText; + const Tizen::Graphics::Bitmap* __pIconBitmap[FOOTER_ITEM_MAX_STATE_COUNT]; + const Tizen::Graphics::Bitmap* __pFooterItemBackgroundBitmap[FOOTER_ITEM_MAX_STATE_COUNT]; + + friend class _FooterImpl; + +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_FOOTER_ITEM_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_Form.h b/src/ui/inc/FUiCtrl_Form.h new file mode 100644 index 0000000..edcfe30 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Form.h @@ -0,0 +1,249 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Form.h + * @brief This is the header file for the %_Form class. + * + * This header file contains the declarations of the %_Form class. + */ +#ifndef _FUI_CTRL_INTERNAL_FORM_H_ +#define _FUI_CTRL_INTERNAL_FORM_H_ + +#include +#include +#include "FUi_Control.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUi_EcoreEvas.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _FormPresenter; +class _Toolbar; +class _Tab; +class _Indicator; +class _ActionEvent; +class _OverlayRegionImpl; +class _IFormBackEventListener; + +enum _FormStyle +{ + _FORM_STYLE_NORMAL = 0x00000000, /**< The basic form style */ + _FORM_STYLE_TITLE = 0x00000001, /**< @deprecated This enumeration field is deprecated because the use of the Title control is no longer recommended.*/ + _FORM_STYLE_INDICATOR = 0x00000002, /**< The form with the indicator area */ + _FORM_STYLE_SOFTKEY_0 = 0x00000010, /**< @deprecated This enumeration field is deprecated because the use of the Softkey control is no longer recommended.*/ + _FORM_STYLE_SOFTKEY_1 = 0x00000020, /**< @deprecated This enumeration field is deprecated because the use of the Softkey control is no longer recommended.*/ + _FORM_STYLE_OPTIONKEY = 0x00000040, /**< @deprecated This enumeration field is deprecated because the use of the Optionkey control is no longer recommended.*/ + _FORM_STYLE_TEXT_TAB = 0x00000100, /**< @deprecated This enumeration field is deprecated because the use of the Tab control is no longer recommended.*/ + _FORM_STYLE_ICON_TAB = 0x00000200, /**< @deprecated This enumeration field is deprecated because the use of the Tab control is no longer recommended.*/ + _FORM_STYLE_HEADER = 0x00001000, /**< The form with a header @b Since: @b 2.0 */ + _FORM_STYLE_FOOTER = 0x00002000 /**< The form with a footer @b Since: @b 2.0 */ +}; + +enum _Softkey +{ + _SOFTKEY_0, /**< The left softkey */ + _SOFTKEY_1, /**< The right softkey */ + _SOFTKEY_COUNT /**< This is internal. If used in an application, the application can get rejected during the certification process. Define the softkey count */ +}; + +/** + * @class _Form + * @brief + * @since 1.0 + */ + +class _OSP_EXPORT_ _Form + : public _Control + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer +{ +// Lifecycle +public: + _Form(void); + virtual ~_Form(void); + +// Operations +public: + static _Form* CreateFormN(void); + + void SetFormBackEventListener(_IFormBackEventListener* pFormBackEventListener); + + unsigned long GetFormStyle(void) const; + _Toolbar* GetFooter(void) const; + _Toolbar* GetHeader(void) const; + _Tab* GetTab(void) const; + _Indicator* GetIndicator(void) const; + Tizen::Base::String GetTitleText(void) const; + HorizontalAlignment GetTitleTextHorizontalAlignment(void) const; + OverlayRegion* GetOverlayRegionN(const Tizen::Graphics::Rectangle& rect, OverlayRegionType regionType); + int GetOverlayRegionCount(void) const; + Tizen::Graphics::Canvas* GetClientAreaCanvasN(void) const; + int GetSoftkeyActionId(_Softkey softkey) const; + int GetOptionkeyActionId(void) const; + Tizen::Base::String GetSoftkeyText(_Softkey softkey) const; + + void SetFormStyle(unsigned long formStyle); + result SetActionBarsTranslucent(unsigned long actionBars, bool translucent); + result SetActionBarsVisible(unsigned long actionBars, bool visible); + result SetTitleIcon(const Tizen::Graphics::Bitmap* pTitleBitmap); + result SetTitleText(const Tizen::Base::String& title, HorizontalAlignment alignment); + result SetSoftkeyEnabled(_Softkey softkey, bool enable); + result SetOptionkeyActionId(int actionId); + result SetSoftkeyActionId(_Softkey softkey, int actionId); + result SetSoftkeyText(_Softkey softkey, const Tizen::Base::String& text); + result SetSoftkeyIcon(_Softkey softkey, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap); + + bool HasFooter(void) const; + bool HasHeader(void) const; + bool HasIndicator(void) const; + bool HasTitle(void) const; + bool HasTab(void) const; + bool IsIndicatorVisible(void) const; + bool IsHeaderVisible(void) const; + bool IsFooterVisible(void) const; + bool IsIndicatorTranslucent(void) const; + bool IsHeaderTranslucent(void) const; + bool IsFooterTranslucent(void) const; + bool IsTabTranslucent(void) const; + bool HasOptionkey(void) const; + bool HasSoftkey(_Softkey softkey) const; + bool IsSoftkeyEnabled(_Softkey softkey) const; + bool CheckSoftkey(_Softkey softkey) const; + virtual bool IsOrientationRoot(void) const; + + Tizen::Graphics::Point TranslateToClientAreaPosition(const Tizen::Graphics::Point& position) const; + Tizen::Graphics::Point TranslateFromClientAreaPosition(const Tizen::Graphics::Point& clientPosition) const; + + bool DeflateClientRectHeight(int height); + + static _Toolbar* CreateHeaderN(void); + static _Toolbar* CreateFooterN(void); + static _Tab* CreateTabN(void); + static _Indicator* CreateIndicatorN(void); + + int GetToolbarHeight(bool header) const; + int GetTabHeight(void) const; + bool RemoveHeader(void); + bool RemoveFooter(void); + bool RemoveTab(void); + bool RemoveIndicator(void); + result SetHeaderBounds(Tizen::Graphics::Rectangle& bounds); + result SetHeaderFloatBounds(Tizen::Graphics::FloatRectangle& bounds); + result SetFooterBounds(Tizen::Graphics::Rectangle& bounds); + result SetTabBounds(Tizen::Graphics::Rectangle& bounds); + Tizen::Graphics::Rectangle GetIndicatorBounds(void) const; + Tizen::Graphics::FloatRectangle GetIndicatorFloatBounds(void) const; + + void SetHeader(_Toolbar* pToolbar); + void SetFooter(_Toolbar* pToolbar); + void SetTab(_Tab* pTab); + void CreateSoftkey(unsigned long formStyle); + void SetTabStyle(int style); + + result SetIndicatorShowState(bool state); + result SetIndicatorOpacity(_IndicatorOpacity opacity); + + result AdjustClientBounds(void); + + result AddActionEventListener(Tizen::Ui::Controls::_IActionEventListener& listener); + void AddOptionkeyActionListener(Tizen::Ui::Controls::_IActionEventListener& listener); + void AddSoftkeyActionListener(_Softkey softkey, Tizen::Ui::Controls::_IActionEventListener& listener); + result RemoveActionEventListener(Tizen::Ui::Controls::_IActionEventListener& listener); + void RemoveOptionkeyActionListener(Tizen::Ui::Controls::_IActionEventListener& listener); + void RemoveSoftkeyActionListener(_Softkey softkey, Tizen::Ui::Controls::_IActionEventListener& listener); + + result AttachedToMainTree(void); + result DetachingFromMainTree(void); + + result AddIndicatorObject(void); + result DeleteIndicatorObject(void); + +//callback + virtual void OnDraw(void); + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + virtual void OnChildVisibleStateChanged(const _Control& child); + virtual void OnBoundsChanged(void); + +// Accessor +protected: + result SetPresenter(const _FormPresenter& formPresenter); + +private: + _Form(const _Form& value); + _Form& operator =(const _Form& value); + + void MoveOverlayRegion(bool top); + void UpdateSoftkey(unsigned long formStyle); + + virtual Tizen::Base::String GetDescription(void) const; + + // Attribute +private: + _FormPresenter* __pFormPresenter; + _IFormBackEventListener* __pFormBackEventListener; + + unsigned long __formStyle; + _ActionEvent* __pActionEvent; + + _Toolbar* __pHeader; + _Toolbar* __pFooter; + _Tab* __pTab; + _Indicator* __pIndicator; + + bool __transparentIndicator; + bool __transparentHeader; + bool __transparentFooter; + bool __transparentTab; + + bool __indicatorShowState; + + bool __deflated; + int __deflatedHeight; + + int __overlayRegionCount; + _OverlayRegionImpl** __ppOverlayerRegionImplArray; + + int __softkeyCount; + int __updatedSoftkeyCount; + int __actionId[_SOFTKEY_COUNT + 1]; + bool __enableSoftkey[_SOFTKEY_COUNT + 1]; + bool __showSoftkey[_SOFTKEY_COUNT + 1]; + + Tizen::Base::String __softkeyText[_SOFTKEY_COUNT + 1]; + + Tizen::Graphics::Bitmap* __pSoftkeyNormalBitmap[_SOFTKEY_COUNT+1]; + Tizen::Graphics::Bitmap* __pSoftkeyNormalEffectBitmap[_SOFTKEY_COUNT+1]; + Tizen::Graphics::Bitmap* __pSoftkeyPressedBitmap[_SOFTKEY_COUNT+1]; + Tizen::Graphics::Bitmap* __pSoftkeyPressedEffectBitmap[_SOFTKEY_COUNT+1]; + + Tizen::Graphics::Bitmap* __pSoftkeyNormalIcon[_SOFTKEY_COUNT]; + Tizen::Graphics::Bitmap* __pSoftkeyPressedIcon[_SOFTKEY_COUNT]; + + //Back button action ID + static const int ID_BACK_BUTTON = -10; + + friend class _Frame; + friend class _OverlayRegionImpl; +}; // _Form + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_FORM_H_ diff --git a/src/ui/inc/FUiCtrl_FormImpl.h b/src/ui/inc/FUiCtrl_FormImpl.h new file mode 100644 index 0000000..8e1cde2 --- /dev/null +++ b/src/ui/inc/FUiCtrl_FormImpl.h @@ -0,0 +1,176 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUICTRL_INTERNAL_FORM_IMPL_H_ +#define _FUICTRL_INTERNAL_FORM_IMPL_H_ + +#include +#include "FUi_ContainerImpl.h" +#include "FUiCtrl_Form.h" +#include "FUiCtrl_IFormBackEventListener.h" + +namespace Tizen { namespace Ui { +class DataBindingContext; +class _OrientationAgent; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls { + +class _HeaderImpl; +class _FooterImpl; +class _TabImpl; // Ki-Dong,Hong.Temp +class _PublicActionEvent; + +class _OSP_EXPORT_ _FormImpl + : public _ContainerImpl + , public Tizen::Ui::Controls::_IActionEventListener + , public Tizen::Ui::Controls::_IFormBackEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + class FormSizeInfo : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + }; // FormSizeInfo + +// Lifecycle +public: + virtual ~_FormImpl(void); + +// Operations + static _FormImpl* CreateFormImplN(Form* pControl, Layout* pPublicPortraitLayout = null, Layout* pPublicLandscapeLayout = null); + + virtual const char* GetPublicClassName(void) const; + virtual const Form& GetPublic(void) const; + virtual Form& GetPublic(void); + virtual const _Form& GetCore(void) const; + virtual _Form& GetCore(void); + + _ControlImpl* GetFocusControl(void); + + void SetFormBackEventListener(const IFormBackEventListener* pFormBackEventListener); + + unsigned long GetFormStyle(void) const; + _FooterImpl* GetFooter(void) const; + _HeaderImpl* GetHeader(void) const; + _TabImpl* GetTabImpl(void) const; // Ki-Dong,Hong.Temp + Tizen::Base::String GetTitleText(void) const; + HorizontalAlignment GetTitleTextHorizontalAlignment(void) const; + OverlayRegion* GetOverlayRegionN(const Tizen::Graphics::Rectangle& rect, OverlayRegionType regionType); + Tizen::Graphics::Canvas* GetClientAreaCanvasN(void) const; + int GetSoftkeyActionId(Softkey softkey) const; + int GetOptionkeyActionId(void) const; + Tizen::Base::String GetSoftkeyText(Softkey softkey) const; + + void SetFormStyle(unsigned long formStyle); + result SetActionBarsTranslucent(unsigned long actionBars, bool translucent); + result SetActionBarsVisible(unsigned long actionBars, bool visible); + result SetTitleIcon(const Tizen::Graphics::Bitmap* pTitleBitmap); + result SetTitleText(const Tizen::Base::String& title, HorizontalAlignment alignment); + result SetSoftkeyEnabled(Softkey softkey, bool enable); + result SetOptionkeyActionId(int actionId); + result SetSoftkeyActionId(Softkey softkey, int actionId); + result SetSoftkeyText(Softkey softkey, const Tizen::Base::String& text); + result SetSoftkeyIcon(Softkey softkey, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap); + + bool HasFooter(void) const; + bool HasHeader(void) const; + bool HasIndicator(void) const; + bool HasTitle(void) const; + bool HasTab(void) const; + bool IsIndicatorVisible(void) const; + bool IsHeaderVisible(void) const; + bool IsFooterVisible(void) const; + bool IsIndicatorTranslucent(void) const; + bool IsHeaderTranslucent(void) const; + bool IsFooterTranslucent(void) const; + bool IsTabTranslucent(void) const; // Ki-Dong,Hong.Temp + bool HasOptionkey(void) const; + bool HasSoftkey(Softkey softkey) const; + bool IsSoftkeyEnabled(Softkey softkey) const; + + Tizen::Graphics::Point TranslateToClientAreaPosition(const Tizen::Graphics::Point& position) const; + Tizen::Graphics::Point TranslateFromClientAreaPosition(const Tizen::Graphics::Point& clientPosition) const; + + void AddOrientationEventListener(Tizen::Ui::IOrientationEventListener& listener); + void AddOptionkeyActionListener(const Tizen::Ui::IActionEventListener& listener); + void AddSoftkeyActionListener(Softkey softkey, const Tizen::Ui::IActionEventListener& listener); + void RemoveOrientationEventListener(Tizen::Ui::IOrientationEventListener& listener); + void RemoveOptionkeyActionListener(const Tizen::Ui::IActionEventListener& listener); + void RemoveSoftkeyActionListener(Softkey softkey, const Tizen::Ui::IActionEventListener& listener); + + void SetOrientation(Tizen::Ui::Orientation orientation); + Tizen::Ui::Orientation GetOrientation(void) const; + Tizen::Ui::OrientationStatus GetOrientationStatus(void) const; + void UpdateOrientationStatus(bool draw = false); + + // Invoked by operations + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + + bool DeflateClientRectHeight(int height); + + virtual void OnDraw(void); + DataBindingContext* GetDataBindingContextN(void) const; + + virtual result OnAttachedToMainTree(void); + virtual result OnDetachingFromMainTree(void); + virtual result OnAttaching(const _Control* pParent); + + virtual bool IsOpaque(void) const; + + virtual void OnFormBackRequested(Tizen::Ui::Controls::_Form& source); + + static const _FormImpl* GetInstance(const Form& form); + + static _FormImpl* GetInstance(Form& form); + +protected: + _FormImpl(Form* pPublic, _Form* pCore, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout); + +private: + static _HeaderImpl* CreateHeaderN(void); + static _FooterImpl* CreateFooterN(void); + static _TabImpl* CreateTabImplN(void); // Ki-Dong,Hong.Temp + + bool RemoveHeader(void); + bool RemoveFooter(void); + bool RemoveTabImpl(void); // Ki-Dong,Hong.Temp + + _Softkey ConvertSoftkey(Softkey softkey) const; + +// key event callback + virtual bool OnKeyReleased(const _ControlImpl& source, _KeyCode keyCode); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + +// Attribute +private: + _Form* __pForm; + IFormBackEventListener* __pFormBackEventListener; + + Tizen::Ui::_OrientationAgent* __pOriAgent; + Tizen::Ui::Controls::_PublicActionEvent* __pLeftSoftkeyActionEvent; + Tizen::Ui::Controls::_PublicActionEvent* __pRightSoftkeyActionEvent; + Tizen::Ui::Controls::_PublicActionEvent* __pOptionMenuActionEvent; + Tizen::Base::Collection::LinkedList __leftSoftkeyActionList; + Tizen::Base::Collection::LinkedList __rightSoftkeyActionList; + + friend class _FrameImpl; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_FORM_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_FormModel.h b/src/ui/inc/FUiCtrl_FormModel.h new file mode 100644 index 0000000..be5bd89 --- /dev/null +++ b/src/ui/inc/FUiCtrl_FormModel.h @@ -0,0 +1,54 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FormModel.h + * @brief This is the header file for the _FormModel class. + * + * This header file contains the declarations of the %_FormModel class. + */ +#ifndef _FUICTRL_INTERNAL_FORM_MODEL_H_ +#define _FUICTRL_INTERNAL_FORM_MODEL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _FormModel + * @brief + * @since 1.0 + */ + +class _FormModel +{ +// Lifecycle +public: + _FormModel(void); + + virtual ~_FormModel(void); + +private: + _FormModel(const _FormModel& value); + + _FormModel& operator =(const _FormModel& value); + +}; // _FormModel + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_FORM_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_FormPresenter.h b/src/ui/inc/FUiCtrl_FormPresenter.h new file mode 100644 index 0000000..529ca3e --- /dev/null +++ b/src/ui/inc/FUiCtrl_FormPresenter.h @@ -0,0 +1,69 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FormPresenter.h + * @brief This is the header file for the _FormPresenter class. + * + * This header file contains the declarations of the %_FormPresenter class. + */ + +#ifndef _FUICTRL_INTERNAL_FORM_PRESENTER_H_ +#define _FUICTRL_INTERNAL_FORM_PRESENTER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Form; +class _FormModel; + +/** + * @class _FormPresenter + * @brief + * @since 1.0 + */ + +class _FormPresenter +{ +// Lifecycle +public: + _FormPresenter(const _Form& form); + + virtual ~_FormPresenter(void); + +// Operations +public: + void Draw(void); + +// Accessor +protected: + result SetModel(const _FormModel& FormModel); + +private: + _FormPresenter(const _FormPresenter& value); + _FormPresenter& operator =(const _FormPresenter& value); + + void _Draw(void); + +private: + _Form* __pForm; + _FormModel* __pFormModel; +}; // _FormPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_FORM_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_Frame.h b/src/ui/inc/FUiCtrl_Frame.h new file mode 100644 index 0000000..63ad93c --- /dev/null +++ b/src/ui/inc/FUiCtrl_Frame.h @@ -0,0 +1,115 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Frame.h + * @brief This is the header file for the _Frame class. + * + * This header file contains the declarations of the %_Frame class. + */ +#ifndef _FUICTRL_INTERNAL_FRAME_H_ +#define _FUICTRL_INTERNAL_FRAME_H_ + +#include +#include "FUi_Window.h" + +namespace Tizen { namespace Ui { namespace Controls { + +class _FramePresenter; +class _FrameEvent; +class _IFrameEventListener; +class _IFormActivationChangeEventListener; +class _Form; + +/** + * @class _Frame + * @brief + * @since 2.0 + */ + +class _OSP_EXPORT_ _Frame + : public Tizen::Ui::_Window + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer +{ +// Lifecycle +public: + static _Frame* CreateFrameN(void); + virtual ~_Frame(void); + +// Callbacks + virtual void OnDraw(void); + virtual void OnActivated(void); + virtual void OnChildAttached(const Tizen::Ui::_Control& child); + virtual void OnChildDetached(const Tizen::Ui::_Control& child); + virtual bool OnNotifiedN(const Tizen::Ui::_Control& source, Tizen::Base::Collection::IList* pArgs); + virtual void OnFrameActivated(void); + virtual void OnFrameDeactivated(void); + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); + virtual result OnAttached(void); +#if !defined(MULTI_WINDOW) + virtual result OnAttachedToMainTree(void); + virtual void OnVisibleStateChanged(void); +#endif + +// Current form + void SetCurrentForm(const Tizen::Ui::Controls::_Form* pForm); + Tizen::Ui::Controls::_Form* GetCurrentForm(void) const; + +// Focus + virtual bool IsFocusableDescendant(const Tizen::Ui::_Control* pFocus) const; + virtual void SetFocusOff(Tizen::Ui::_Control* pFocus); + +#if !defined(MULTI_WINDOW) +// Orientation + virtual bool IsLayoutChangable(void) const; +#endif + virtual bool IsOrientationRoot(void) const; + +// Event listeners + void AddFrameEventListener(const Tizen::Ui::Controls::_IFrameEventListener& listener); + void RemoveFrameEventListener(const Tizen::Ui::Controls::_IFrameEventListener& listener); + void SetFormActivationChangeEventListener(const Tizen::Ui::Controls::_IFormActivationChangeEventListener* plistener); + +// Floating + void SetFloatingBounds(const Tizen::Graphics::Rectangle& rect); + result SetShowMode(FrameShowMode showMode); + FrameShowMode GetShowMode(void) const; + bool IsActivated(void) const; + +protected: + result SetPresenter(const _FramePresenter& framePresenter); + +private: + _Frame(void); + _Frame(const _Frame&); + _Frame& operator =(const _Frame&); + +// Attribute +private: + _FramePresenter* __pFramePresenter; + _FrameEvent* __pFrameEvent; + Tizen::Graphics::Rectangle __floatingBounds; + FrameShowMode __showMode; + bool __restore; + bool __activated; + _IFormActivationChangeEventListener* __pFormActivationChangeEventListener; +}; // _Frame + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_FRAME_H_ diff --git a/src/ui/inc/FUiCtrl_FrameEvent.h b/src/ui/inc/FUiCtrl_FrameEvent.h new file mode 100644 index 0000000..1b78203 --- /dev/null +++ b/src/ui/inc/FUiCtrl_FrameEvent.h @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FrameEvent.h + * @brief This is the header file for _FrameEvent class. + * @version 1.0 + * + * This header file contains declaration of _FrameEvent class. + * The _FrameEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_INTERNAL_FRAME_EVENT_H_ +#define _FUI_CTRL_INTERNAL_FRAME_EVENT_H_ + +#include +#include +#include "FBaseRt_Event.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum _FrameStatus +{ + _FRAME_STATUS_ACTIVATED = 0, + _FRAME_STATUS_DEACTIVATED +}; + +class _Frame; + +/** + * @class _FrameEvent + * @brief This class handles a frame event. It is inherited from Event class. + * + * The _Frame class has an instance of the _FrameEvent class as a member variable. + * Applications can register frame event listeners through it. When a frame lifecycle event occurs, + * the _FrameEvent class finds listener and calls the appropriate listener's method. + */ +class _FrameEvent + : public Tizen::Base::Runtime::_Event +{ +public: +// Lifecycle + static _FrameEvent* CreateInstanceN(const _Frame& source); + static Tizen::Base::Runtime::IEventArg* CreateFrameEventArgN(const _Frame& source, int frameState); + + /** + * This is the class destructor. + * + */ + virtual ~_FrameEvent(void); + +// Accessor + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const _Frame* GetSource(void) const; + +protected: +// Operation + /** + * This method is Implemented to call the corresponding event listener's method. + * + * @return The method returns the error code + * @param[in] pListener The eventListener instance which is currently processing + * @param[in] arg The event argument that is fired + * @return The method returns error code. + * @exception E_SUCCESS - This method is successful. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value. + * @exception E_ARG_NULL - The pointer passed to a method contains a @c null reference. + * @exception E_UNKNOWN - An undetermined error has occurred during operation. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: +// Lifecycle + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _FrameEvent(const _Frame& source); + +private: +// Attribute + const _Frame* __pSource; +}; // _FrameEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_FRAME_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_FrameImpl.h b/src/ui/inc/FUiCtrl_FrameImpl.h new file mode 100644 index 0000000..dea93ac --- /dev/null +++ b/src/ui/inc/FUiCtrl_FrameImpl.h @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUICTRL_INTERNAL_FRAME_IMPL_H_ +#define _FUICTRL_INTERNAL_FRAME_IMPL_H_ + +#include +#include "FUi_WindowImpl.h" +#include "FUiCtrl_Frame.h" +#include "FUiCtrl_IFrameEventListener.h" + +namespace Tizen { namespace Ui { +class _OrientationAgent; +} } // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Animations { +class FrameAnimator; +} } } // Tizen::Ui::Animations + +namespace Tizen { namespace Ui { namespace Controls { + +class _FormImpl; +class _PublicFrameEvent; +class IFrameEventListener; + +class _FrameImpl + : public _WindowImpl + , public _IFrameEventListener +{ +// Lifecycle +public: + static _FrameImpl* CreateFrameImplN(Frame* pControl); + virtual ~_FrameImpl(); + +// Common + virtual const char* GetPublicClassName(void) const; + virtual const Frame& GetPublic(void) const; + virtual Frame& GetPublic(void); + virtual const _Frame& GetCore(void) const; + virtual _Frame& GetCore(void); + +// Form managing + result SetCurrentForm(const _FormImpl& formImpl); + _FormImpl* GetCurrentForm(void) const; + +// Event listeners + void AddOrientationEventListener(Tizen::Ui::IOrientationEventListener& listener); + void AddFrameEventListener(Tizen::Ui::Controls::IFrameEventListener& listener); + void RemoveOrientationEventListener(Tizen::Ui::IOrientationEventListener& listener); + void RemoveFrameEventListener(Tizen::Ui::Controls::IFrameEventListener& listener); + +// Orientation + Tizen::Ui::Orientation GetOrientation(void) const; + Tizen::Ui::OrientationStatus GetOrientationStatus(void) const; + void SetOrientation(Tizen::Ui::Orientation orientation); + void UpdateOrientationStatus(void); + +// Callback + virtual void OnDraw(void); + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + virtual void OnChildDetaching(const _Control& child); + virtual void OnChildDetached(const _Control& child); + virtual void OnFrameActivated(const _Frame& source); + virtual void OnFrameDeactivated(const _Frame& source); + virtual void OnBoundsChanged(void); + +// Animator + Tizen::Ui::Animations::FrameAnimator* GetFrameAnimator(void) const; + +// Drawing + virtual bool IsOpaque(void) const; + +// Floating + void SetFloatingBounds(const Tizen::Graphics::Rectangle& rect); + result SetShowMode(FrameShowMode showMode); + FrameShowMode GetShowMode(void) const; + + static const _FrameImpl* GetInstance(const Frame& frame); + static _FrameImpl* GetInstance(Frame& frame); + +protected: + _FrameImpl(Frame* pPublic, _Frame* pCore); + void Dispose(void); + +private: + virtual bool IsChildAttachable(Tizen::Ui::_ControlImpl& child) const; + +// Attribute +private: + _PublicFrameEvent* __pFrameEvent; + Tizen::Ui::Animations::FrameAnimator* __pFrameAnimator; + Tizen::Ui::_OrientationAgent* __pOrientationAgent; +}; // _FrameImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_FRAME_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_FrameModel.h b/src/ui/inc/FUiCtrl_FrameModel.h new file mode 100644 index 0000000..370c3cd --- /dev/null +++ b/src/ui/inc/FUiCtrl_FrameModel.h @@ -0,0 +1,54 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FrameModel.h + * @brief This is the header file for the _FrameModel class. + * + * This header file contains the declarations of the %_FrameModel class. + */ +#ifndef _FUICTRL_INTERNAL_FRAME_MODEL_H_ +#define _FUICTRL_INTERNAL_FRAME_MODEL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _FrameModel + * @brief + * @since 1.0 + */ + +class _FrameModel +{ +// Lifecycle +public: + _FrameModel(void); + + virtual ~_FrameModel(void); + +private: + _FrameModel(const _FrameModel& value); + + _FrameModel& operator =(const _FrameModel& value); + +}; // _FrameModel + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_FRAME_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_FramePresenter.h b/src/ui/inc/FUiCtrl_FramePresenter.h new file mode 100644 index 0000000..f4761bf --- /dev/null +++ b/src/ui/inc/FUiCtrl_FramePresenter.h @@ -0,0 +1,72 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_FramePresenter.h + * @brief This is the header file for the _FramePresenter class. + * + * This header file contains the declarations of the %_FramePresenter class. + */ +#ifndef _FUICTRL_INTERNAL_FRAME_PRESENTER_H_ +#define _FUICTRL_INTERNAL_FRAME_PRESENTER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _Frame; +class _FrameModel; + +/** + * @class _FramePresenter + * @brief + * @since 1.0 + */ + +class _FramePresenter +{ +// Lifecycle +public: + _FramePresenter(const _Frame& frame); + + virtual ~_FramePresenter(void); + +// Operations +public: + void Draw(void); + +// Accessor +protected: + result _SetModel(const _FrameModel& frameModel); + +private: + _FramePresenter(const _FramePresenter& value); + + _FramePresenter& operator =(const _FramePresenter& value); + + void _Draw(void); + +private: + _Frame* __pFrame; + + _FrameModel* __pFrameModel; + +}; // _FramePresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_FRAME_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_Gallery.h b/src/ui/inc/FUiCtrl_Gallery.h new file mode 100644 index 0000000..0c4b640 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Gallery.h @@ -0,0 +1,169 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_H_ + + +#include "FUi_Control.h" +#include "FUi_ITouchFlickGestureEventListener.h" +#include "FUi_ITouchTapGestureEventListener.h" +#include "FUi_ITouchPinchGestureEventListener.h" +#include "FUiCtrl_GalleryTypes.h" + + +namespace Tizen { namespace Base { + +class String; + +}} // Tizen::Base + +namespace Tizen { namespace Graphics { + +class Color; + +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { +class _TouchFlickGestureDetector; +class _TouchTapGestureDetector; +class _TouchPinchGestureDetector; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Effects { +class Effect; +}}} + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryBitmap; +class _GalleryRenderer; +class _GalleryPresenter; +class _GalleryViewEvent; +class _IGalleryCoreEventListener; +class _IGalleryRendererNotiListener; +class _GalleryItemProviderAdaptorImpl; + +class _Gallery + : public Tizen::Ui::_Control + , virtual public Tizen::Ui::_ITouchFlickGestureEventListener + , virtual public Tizen::Ui::_ITouchTapGestureEventListener + , virtual public Tizen::Ui::_ITouchPinchGestureEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_ITouchGestureEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + virtual ~_Gallery(void); + static _Gallery* CreateGalleryN(_GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor); + + // presenter access + result SetTextOfEmptyGallery(const Tizen::Base::String& text); + Tizen::Base::String GetTextOfEmptyGallery(void) const; + result SetBitmapOfEmptyGallery(const _GalleryBitmap* pBitmap); + result SetCoreEventListener(const _IGalleryCoreEventListener& coreEventListener); + result RemoveCoreEventListener(const _IGalleryCoreEventListener& coreEventListener); + result SetZoomingEnabled(bool enable); + bool IsZoomingEnabled(void) const; + result SetSlideShowType(_GallerySlideShowType slideShowType); + _GallerySlideShowType GetSlideShowType(void) const; + result SetSlideShowAnimationDuration(int duration); + int GetSlideShowAnimationDuration(void) const; + result SetSlideShowViewDuration(int duration); + int GetSlideShowViewDuration(void) const; + result StartSlideShow(bool repeat); + result StopSlideShow(void); + bool IsSlideShowStarted(void) const; + + // model access + result SetCurrentItemIndex(int itemIndex); + int GetCurrentItemIndex(void) const; + int GetItemCount(void) const; + result RequestToLoadItem(int itemIndex); + result RequestToUnloadItem(int itemIndex); + result RequestToUnloadAllItems(void); + result RequestToUpdateItem(int itemIndex); + result RequestToUpdateAllItems(void); + + // gesture + virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture); + virtual bool OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture); + virtual bool OnTapGestureDetected(_TouchTapGestureDetector& gesture); + virtual bool OnTapGestureCanceled(_TouchTapGestureDetector& gesture); + virtual bool OnPinchGestureStarted(_TouchPinchGestureDetector& gesture); + virtual bool OnPinchGestureChanged(_TouchPinchGestureDetector& gesture); + virtual bool OnPinchGestureFinished(_TouchPinchGestureDetector& gesture); + virtual bool OnPinchGestureCanceled(_TouchPinchGestureDetector& gesture); + + // Touch Event Callbacks + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + // Windowing Event Callbacks + virtual void OnDraw(void); + virtual void OnBoundsChanged(void); + + // Font Callback + virtual void OnFontInfoRequested(unsigned long& style, int& size); + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + + void SetEffect(Tizen::Ui::Effects::Effect* pEffect); + Tizen::Ui::Effects::Effect* GetEffect(void); + +private: + _Gallery(void); + result Construct(_GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor); + + // Copy constructor + _Gallery(const _Gallery& rhs); + _Gallery& operator=(const _Gallery& rhs); + + void SetRenderer(_GalleryRenderer& galleryRenderer) + { + __pRenderer = &galleryRenderer; + } + + _GalleryRenderer& GetRenderer(void) + { + return *__pRenderer; + } + + void SetPresenter(_GalleryPresenter& galleryPresenter) + { + __pPresenter = &galleryPresenter; + } + + _GalleryPresenter& GetPresenter(void) const + { + return *__pPresenter; + } + +private: + _GalleryRenderer* __pRenderer; + _GalleryPresenter* __pPresenter; + + _TouchFlickGestureDetector __flickGesture; + _TouchTapGestureDetector __tapGesture; + _TouchPinchGestureDetector __pinchGesture; + + bool __modelInitialized; +}; // _Gallery + +}}} +#endif //_FUI_CTRL_INTERNAL_GALLERY_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryBitmap.h b/src/ui/inc/FUiCtrl_GalleryBitmap.h new file mode 100644 index 0000000..6d30c01 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryBitmap.h @@ -0,0 +1,69 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_BITMAP_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_BITMAP_H_ + +#include +#include "FUiCtrl_GalleryTypes.h" + +namespace Tizen { namespace Graphics { + +class Bitmap; + +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryBitmap + : public Tizen::Base::Object +{ +public: + virtual ~_GalleryBitmap(void); + + static _GalleryBitmap* CloneN(_GalleryBitmap* pBitmap); + static _GalleryBitmap* CreateGalleryBitmapN(Tizen::Graphics::Bitmap* pBitmap); + + result SetSize(const Tizen::Graphics::Dimension& size); + Tizen::Graphics::Dimension GetSize(void) const; + + result Initialize(const Tizen::Graphics::Dimension& size, _GalleryFittingType fittingType = GALLERY_FITTING_TYPE_FIT); + result AdjustBitmapSize(const Tizen::Graphics::Dimension& size, _GalleryFittingType fittingType); + result AdjustBitmapRotate(void); + + bool IsInitialize(void) const; + + void SetBitmapRotation(_GalleryImageRotation rotation); + _GalleryImageRotation GetBitmapRotation(void) const; + Tizen::Graphics::Bitmap* GetInternalBitmap(void) const; + +private: + _GalleryBitmap(const _GalleryBitmap& rhs); + _GalleryBitmap& operator=(const _GalleryBitmap& rhs); + + _GalleryBitmap(void); + void SetAdjustBitmapFlag(bool initialize); + void SetInternalBitmap(Tizen::Graphics::Bitmap* pBitmap); + +private: + Tizen::Graphics::Bitmap* __pBitmap; + _GalleryImageRotation __rotation; + bool __bitmapSizeAndRotateAdjusted; +}; // _GalleryBitmap + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_GALLERY_BITMAP_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryCanvas.h b/src/ui/inc/FUiCtrl_GalleryCanvas.h new file mode 100644 index 0000000..b6984ee --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryCanvas.h @@ -0,0 +1,176 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_CANVAS_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_CANVAS_H_ + +#include +#include +#include "FUi_Control.h" +#include "FUiCtrl_GalleryTypes.h" + +namespace Tizen { namespace Graphics { + +class Rectangle; + +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Animations { + +class VisualElementPropertyAnimation; +class IVisualElementAnimationStatusEventListener; +class IVisualElementAnimationTimingFunction; +class _VisualElement; + +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryBitmap; +class _GalleryRootCanvas; + +class _GalleryAnimationProvider + : virtual public Tizen::Ui::Animations::VisualElementAnimationProvider +{ +public: + _GalleryAnimationProvider(void); + virtual ~_GalleryAnimationProvider(void); + virtual Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationForProperty(Tizen::Ui::Animations::VisualElement& source, const Tizen::Base::String& property); + + void SetAnimationDelegator(Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener* animationDelegator); + void SetGalleryAnimationTiming(_GalleryAnimationTiming animationTiming); + + const Tizen::Ui::Animations::IVisualElementAnimationTimingFunction* GetTimingFunc(_GalleryAnimationTimingFunction timingFunction) const; + +private: + Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener* __pAnimationDelegator; + _GalleryAnimationTiming __animationTiming; +}; // _GalleryAnimationProvider + +class _GalleryCanvas + : public Tizen::Base::Object +{ +public: + virtual ~_GalleryCanvas(void); + static _GalleryCanvas* CreateGalleryCanvasN(Tizen::Graphics::Rectangle& canvasBounds); + + result SetImage(const _GalleryBitmap* pImage, const Tizen::Graphics::Rectangle& viewBounds, _GalleryFittingType fittingType = GALLERY_FITTING_TYPE_FIT); + _GalleryBitmap* GetImage(void) const; + result SetBounds(const Tizen::Graphics::Rectangle& bounds); + const Tizen::Graphics::Rectangle& GetBounds(void) const; + Tizen::Ui::Animations::_VisualElement& GetImageVisualElement(void) const; + Tizen::Ui::Animations::_VisualElement& GetFrameVisualElement(void) const; + Tizen::Ui::Animations::VisualElementPropertyAnimation& GetAnimation(void) const; + result SetVisibility(bool visibility); + bool IsVisibility(void) const; + result RefreshCanvas(void); + result LoadImage(void); + + result SetVisualElementBounds(const Tizen::Graphics::Rectangle& bounds); + Tizen::Graphics::Rectangle GetImageVisualElementBounds(void) const; + + void SetImageBounds(const Tizen::Graphics::Rectangle& bounds); + Tizen::Graphics::Rectangle GetImageBounds(void) const; + Tizen::Graphics::Rectangle GetOriginalImageBounds(void) const; + + result SetAnimationDelegator(_GalleryAnimationProvider* pVEDelegator); + void SetRootCanvas(_GalleryRootCanvas& rootCanvas); + + void SetNeedUpdateImage(bool needUpdate); + bool IsNeedUpdateImage(void) const; + + void SetCanvasFactor(float factor); + float GetCanvasFactor(void) const; + + void SetImageAnchor(Tizen::Graphics::FloatPoint); + Tizen::Graphics::FloatPoint GetImageAnchor(void) const; + + Tizen::Graphics::Rectangle GetAlignBoundary(void) const; + + void SetClippingOfFrameVisualElement(bool clipping); + + void SetImageAlignment(_GalleryVerticalAlignment imageVerticalAlignment + , _GalleryHorizontalAlignment imageHorizontalAlignment); + void GetImageAlignment(_GalleryVerticalAlignment& imageVerticalAlignment + , _GalleryHorizontalAlignment& imageHorizontalAlignment) const; + +private: + _GalleryCanvas(_GalleryCanvas& rhs); + _GalleryCanvas& operator=(const _GalleryCanvas& rhs); + + _GalleryCanvas(void); + result Construct(Tizen::Graphics::Rectangle& canvasBounds); + + void SetImageVisualElement(Tizen::Ui::Animations::_VisualElement& visualElement); + void SetFrameVisualElement(Tizen::Ui::Animations::_VisualElement& visualElement); + void SetAnimation(Tizen::Ui::Animations::VisualElementPropertyAnimation& animation); + +private: + Tizen::Ui::Animations::_VisualElement* __pImageVisualElement; + Tizen::Ui::Animations::_VisualElement* __pFrameVisualElement; + Tizen::Ui::Animations::VisualElementPropertyAnimation* __pAnimation; + Tizen::Graphics::Rectangle __bounds; + _GalleryBitmap* __pImage; + Tizen::Graphics::Rectangle __visableRegionOfImage; + bool __needUpdateImage; + bool __visualElementBoundsChanged; + Tizen::Graphics::Rectangle __imageBounds; + Tizen::Graphics::Rectangle __originalImageBounds; + _GalleryRootCanvas* __pRootCanvas; + float __factor; + Tizen::Graphics::FloatPoint __imageAnchor; + _GalleryVerticalAlignment __imageVerticalAlignment; + _GalleryHorizontalAlignment __imageHorizontalAlignment; +}; // _GalleryCanvas + + +class _GalleryRootCanvas + : public Tizen::Base::Object +{ + +public: + virtual ~_GalleryRootCanvas(void); + static _GalleryRootCanvas* CreateGalleryRootCanvasN(Tizen::Ui::_Control& control); + + result SetBackgroundImage(const _GalleryBitmap* pImage); + _GalleryBitmap* GetBackgroundImage(void) const; + Tizen::Graphics::Color GetBackgroundColor(void) const; + result SetBounds(const Tizen::Graphics::Rectangle& bounds); + Tizen::Graphics::Rectangle GetBounds(void) const; + Tizen::Graphics::Dimension GetControlSize(void) const; + Tizen::Ui::Animations::_VisualElement* GetImageVisualElement(void) const; + result SetVisibility(bool visibility); + bool IsVisibility(void) const; + result AddChildCanvas(_GalleryCanvas& canvas); + result RemoveChildCanvas(_GalleryCanvas& canvas); + result RefreshCanvas(void); + +private: + _GalleryRootCanvas(_Control& control); + + void SetControl(Tizen::Ui::_Control& control); + Tizen::Ui::_Control& GetControl(void) const; + +private: + Tizen::Ui::_Control* __pControl; + Tizen::Graphics::Rectangle __bounds; + _GalleryBitmap* __pBackgroundImage; + bool __needUpdateBackgroundImage; +}; // _GalleryRootCanvas + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_CANVAS_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryCanvasManager.h b/src/ui/inc/FUiCtrl_GalleryCanvasManager.h new file mode 100644 index 0000000..0b7c071 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryCanvasManager.h @@ -0,0 +1,76 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_CANVAS_MANAGER_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_CANVAS_MANAGER_H_ + +namespace Tizen { namespace Base { namespace Collection { + +class ArrayList; + +}}} // Tizen::Base::Collection + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryRootCanvas; +class _GalleryCanvas; +class _GalleryAnimationProvider; + +class _GalleryCanvasManager +{ +public: + virtual ~_GalleryCanvasManager(void); + + static _GalleryCanvasManager* CreateCanvasManagerN(Tizen::Ui::_Control& control, int initialCanvasCount, + Tizen::Graphics::Rectangle& initialCanvasBounds, + _GalleryAnimationProvider* pVEDelegator); + + result ResetCanvasManager(int canvasCount, Tizen::Graphics::Rectangle& canvasBounds); + int GetCanvasCount(void) const; + _GalleryRootCanvas& GetRootCanvas(void) const; + _GalleryCanvas* GetCanvas(int canvasIndex) const; + result ReleaseAllCanvasResource(void); + result ResetAllCanvas(Tizen::Graphics::Rectangle& canvasBounds); + result LoadAllCanvasImage(void); + +private: + _GalleryCanvasManager(_GalleryCanvasManager& rhs); + _GalleryCanvasManager& operator=(const _GalleryCanvasManager& rhs); + + _GalleryCanvasManager(void); + result Construct(Tizen::Ui::_Control& control, int initialCanvasCount, Tizen::Graphics::Rectangle& initialCanvasBounds); + + result RemoveAllCanvas(void); + + void SetControl(Tizen::Ui::_Control& control); + Tizen::Ui::_Control& GetControl(void) const; + + void SetRootCanvas(_GalleryRootCanvas& rootCanvas); + + void SetCanvasCount(int canvasCount); + void SetAnimationDelegator(_GalleryAnimationProvider& pVEDelegator); + _GalleryAnimationProvider& GetAnimationDelegator(void) const; + +private: + Tizen::Ui::_Control* __pControl; + _GalleryRootCanvas* __pRootCanvas; + Tizen::Base::Collection::ArrayList __canvasArray; + _GalleryAnimationProvider* __pVEDelegator; +}; // _GalleryCanvasManager + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_CANVAS_MANAGER_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryCoreEvent.h b/src/ui/inc/FUiCtrl_GalleryCoreEvent.h new file mode 100644 index 0000000..caf8986 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryCoreEvent.h @@ -0,0 +1,41 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_CORE_EVENT_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_CORE_EVENT_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryCoreEvent + : public Tizen::Base::Runtime::_Event +{ +public: + _GalleryCoreEvent(void); + virtual ~_GalleryCoreEvent(void); + +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + _GalleryCoreEvent(const _GalleryCoreEvent& rhs); + _GalleryCoreEvent& operator=(const _GalleryCoreEvent& rhs); +}; // _GalleryCoreEvent + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_CORE_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryCoreEventArg.h b/src/ui/inc/FUiCtrl_GalleryCoreEventArg.h new file mode 100644 index 0000000..7d0712f --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryCoreEventArg.h @@ -0,0 +1,64 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_CORE_EVENT_ARG_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_CORE_EVENT_ARG_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls { + +enum _GalleryCoreEventType +{ + GALLERY_CORE_EVENT_CURRENT_ITEM_CHANGED = 0, + GALLERY_CORE_EVENT_ITEM_CLICKED, + GALLERY_CORE_EVENT_SLIDE_SHOW_STARTED, + GALLERY_CORE_EVENT_SLIDE_SHOW_STOPPED, + GALLERY_CORE_EVENT_CREATE_ITEM, + GALLERY_CORE_EVENT_DELETE_ITEM, + GALLERY_CORE_EVENT_GET_ITEM_COUNT +}; + +class _GalleryItem; + +class _GalleryCoreEventArg + : public Tizen::Base::Runtime::IEventArg +{ +public: + _GalleryCoreEventArg(_GalleryCoreEventType eventType, int arg1 = 0, _GalleryItem** arg2 = null, bool arg3 = true); + virtual ~_GalleryCoreEventArg(void); + + int& GetArg1(void) const; + _GalleryItem** GetArg2(void) const; + bool& GetArg3(void) const; + + _GalleryCoreEventType GetEventType(void) const; + +private: + _GalleryCoreEventArg(const _GalleryCoreEventArg& rhs); + _GalleryCoreEventArg& operator=(const _GalleryCoreEventArg& rhs); + +private: + int __arg1; + _GalleryItem** __ppArg2; + bool __arg3; + _GalleryCoreEventType __eventType; +}; // _GalleryCoreEventArg + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_GALLERY_CORE_EVENT_ARG_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryCoreEventListener.h b/src/ui/inc/FUiCtrl_GalleryCoreEventListener.h new file mode 100644 index 0000000..03c8d42 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryCoreEventListener.h @@ -0,0 +1,55 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_CORE_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_CORE_EVENT_LISTENER_H_ + +#include "FUiCtrl_IGalleryCoreEventListener.h" + +namespace Tizen { namespace Ui { namespace Controls { + +class IGalleryItemProvider; +class _GalleryImplEvent; +class _GalleryItem; + +class _GalleryCoreEventListener + : public _IGalleryCoreEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + _GalleryCoreEventListener(_GalleryImplEvent& implEvent); + virtual ~_GalleryCoreEventListener(void); + + void SetItemProvider(const IGalleryItemProvider* pItemProvider); + IGalleryItemProvider* GetItemProvider(void) const; + + virtual void OnCurrentItemChanged(int currentIndex); + virtual void OnItemClicked(int itemIndex); + virtual void OnSlideShowStarted(void); + virtual void OnSlideShowStopped(void); + +private: + _GalleryCoreEventListener(const _GalleryCoreEventListener& rhs); + _GalleryCoreEventListener& operator=(const _GalleryCoreEventListener& rhs); + +private: + IGalleryItemProvider* __pItemProvider; + _GalleryImplEvent& __implEvent; +}; // _GalleryCoreEventListener + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_CORE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryImageReader.h b/src/ui/inc/FUiCtrl_GalleryImageReader.h new file mode 100644 index 0000000..1b43edf --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryImageReader.h @@ -0,0 +1,62 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_IMAGE_READER_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_IMAGE_READER_H_ + +#include +#include + +namespace Tizen { namespace Graphics { + +class Rectangle; +class Bitmap; + +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryModel; +class _GalleryBitmap; + +class _GalleryImageReader + : public Tizen::Base::Object +{ +public: + _GalleryImageReader(_GalleryModel& galleryModel); + virtual ~_GalleryImageReader(void); + + //void SetPartialDecoder(); + _GalleryBitmap* GetPartialImageFromFileN(int index, const Tizen::Graphics::Rectangle& partialBounds, + const Tizen::Graphics::Dimension& imageSize) const; + _GalleryBitmap* GetItemImage(int index) const; + +private: + _GalleryImageReader(const _GalleryImageReader& rhs); + _GalleryImageReader& operator=(const _GalleryImageReader& rhs); + + void LoadPartialImageFromFile(int index, const Tizen::Graphics::Dimension& imageSize); + +private: + _GalleryModel& __galleryModel; + Tizen::Graphics::Bitmap* __pTmpFileBitmap; + int __currentLoadBitmapIndex; + Tizen::Graphics::Dimension __currentLoadBitmapSize; +}; // _GalleryImageReader + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_IMAGE_READER_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryImpl.h b/src/ui/inc/FUiCtrl_GalleryImpl.h new file mode 100644 index 0000000..0b33c4c --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryImpl.h @@ -0,0 +1,105 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_IMPL_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_IMPL_H_ + +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_Gallery.h" + +namespace Tizen { namespace Ui { namespace Effects +{ +class Effect; +}}} + +namespace Tizen { namespace Ui { namespace Controls { + +class Gallery; +class IGalleryItemProvider; +class IGalleryEventListener; +class _GalleryImplEvent; +class _GalleryCoreEventListener; +class _GalleryItemProviderAdaptorImpl; + +class _GalleryImpl + : public Tizen::Ui::_ControlImpl +{ +public: + virtual ~_GalleryImpl(void); + + static _GalleryImpl* CreateGalleryImplN(Gallery* pGallery); + + virtual const char* GetPublicClassName(void) const; + virtual const Gallery& GetPublic(void) const; + virtual Gallery& GetPublic(void); + virtual const _Gallery& GetCore(void) const; + virtual _Gallery& GetCore(void); + + void AddGalleryEventListener(IGalleryEventListener& listener); + void RemoveGalleryEventListener(IGalleryEventListener& listener); + result SetItemProvider(IGalleryItemProvider& provider); + + result SetCurrentItemIndex(int index); + int GetCurrentItemIndex(void) const; + result SetZoomingEnabled(bool enable); + bool IsZoomingEnabled(void) const; + + result SetTextOfEmptyGallery(const Tizen::Base::String& text); + Tizen::Base::String GetTextOfEmptyGallery(void) const; + result SetBitmapOfEmptyGallery(const Tizen::Graphics::Bitmap* pBitmap); + + result SetSlideShowAnimation(GalleryAnimation animation); + GalleryAnimation GetSlideShowAnimation(void) const; + result SetSlideShowAnimationDuration(int duration); + int GetSlideShowAnimationDuration(void) const; + result SetSlideShowViewDuration(int duration); + int GetSlideShowViewDuration(void) const; + + result StartSlideShow(bool repeat = false); + result StopSlideShow(void) const; + bool IsSlideShowStarted(void) const; + + int GetItemCount(void) const; + + result RefreshGallery(int itemIndex, GalleryRefreshType type); + result UpdateGallery(void); + + static _GalleryImpl* GetInstance(Gallery& gallery); + static const _GalleryImpl* GetInstance(const Gallery& gallery); + + void SetEffect(Tizen::Ui::Effects::Effect* pEffect); + Tizen::Ui::Effects::Effect* GetEffect(void); + +protected: + _GalleryImpl(Gallery* pGallery, _Gallery* pCore, _GalleryImplEvent* pImplEvent, + _GalleryCoreEventListener* pCoreEventListener, _GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor); + +private: + _GalleryImpl(const _GalleryImpl& rhs); + _GalleryImpl& operator=(const _GalleryImpl& rhs); + + void RequestToUnloadAllItems(void); + +private: + _GalleryImplEvent* __pImplEvent; + _GalleryCoreEventListener* __pCoreEventListener; + _GalleryItemProviderAdaptorImpl* __pGalleryItemProviderAdaptor; +}; //_GalleryImpl + +}}} //Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryImplEvent.h b/src/ui/inc/FUiCtrl_GalleryImplEvent.h new file mode 100644 index 0000000..3c787ca --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryImplEvent.h @@ -0,0 +1,49 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_IMPL_EVENT_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_IMPL_EVENT_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls { + +class Gallery; + +class _GalleryImplEvent + : public Tizen::Base::Runtime::_Event +{ +public: + _GalleryImplEvent(void); + virtual ~_GalleryImplEvent(void); + + result Construct(Gallery* pSource); + +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + _GalleryImplEvent(const _GalleryImplEvent& rhs); + _GalleryImplEvent& operator=(const _GalleryImplEvent& rhs); + +private: + Gallery* __pSource; +}; // _GalleryImplEvent + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_IMPL_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryImplEventArg.h b/src/ui/inc/FUiCtrl_GalleryImplEventArg.h new file mode 100644 index 0000000..d9cf77d --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryImplEventArg.h @@ -0,0 +1,56 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_IMPL_EVENT_ARG_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_IMPL_EVENT_ARG_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls { + +enum _GalleryEventType +{ + GALLERY_EVENT_CURRENT_ITEM_CHANGED = 0, + GALLERY_EVENT_ITEM_CLICKED, + GALLERY_EVENT_SLIDE_SHOW_STARTED, + GALLERY_EVENT_SLIDE_SHOW_STOPPED +}; + +class _GalleryImplEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +public: + _GalleryImplEventArg(_GalleryEventType eventType, int arg1 = -1); + virtual ~_GalleryImplEventArg(void); + + int GetArg1(void) const; + + _GalleryEventType GetEventType(void) const; + +private: + _GalleryImplEventArg(const _GalleryImplEventArg& rhs); + _GalleryImplEventArg& operator=(const _GalleryImplEventArg& rhs); + +private: + int __arg1; + _GalleryEventType __eventType; +}; // _GalleryImplEventArg + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_GALLERY_IMPL_EVENT_ARG_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryItem.h b/src/ui/inc/FUiCtrl_GalleryItem.h new file mode 100644 index 0000000..99e0656 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryItem.h @@ -0,0 +1,70 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_ITEM_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_ITEM_H_ + +#include +#include +#include +#include "FUiCtrl_ListItemCommon.h" +#include "FUiCtrl_GalleryTypes.h" + + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryBitmap; + +class _GalleryItem + : public _ListItemCommon +{ +public: + _GalleryItem(_GalleryBitmap* pImage = null, Tizen::Base::String imageFilePath = L"", + _GalleryImageRotation rotation = GALLERY_INTERNAL_IMAGE_ROTATION_0); + virtual ~_GalleryItem(void); + + void SetGalleryItemImage(_GalleryBitmap* pImage); + _GalleryBitmap* GetGalleryItemImage(void) const; + void SetOriginGalleryItemImage(_GalleryBitmap* pImage); + _GalleryBitmap* GetOriginItemImage(void) const; + void SetGalleryItemFilePath(Tizen::Base::String& filePath); + Tizen::Base::String GetGalleryItemFilePath(void) const; + void SetGalleryRotation(_GalleryImageRotation rotation); + _GalleryImageRotation GetGalleryRotation(void) const; + + virtual bool DrawItem(Tizen::Graphics::Rectangle &rcItem, ListItemState isFocused, bool itemDivider = false) + { + return true; + } + + virtual void SetItemIndex(int groupIndex, int itemIndex); + virtual void GetItemIndex(int& groupIndex, int& itemIndex) const; + +private: + _GalleryItem(const _GalleryItem& rhs); + _GalleryItem& operator=(const _GalleryItem& rhs); + +private: + _GalleryBitmap* __pOriginImage; + _GalleryBitmap* __pImage; + Tizen::Base::String __imageFilePath; + _GalleryImageRotation __rotation; + int __itemIndex; +}; // _GalleryItem + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_ITEM_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryItemImpl.h b/src/ui/inc/FUiCtrl_GalleryItemImpl.h new file mode 100644 index 0000000..7bd0997 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryItemImpl.h @@ -0,0 +1,71 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_ITEM_IMPL_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_ITEM_IMPL_H_ + +#include +#include + +namespace Tizen { namespace Graphics { + +class Bitmap; + +}} // Tizen::Graphics + +namespace Tizen { namespace Base { + +class String; + +}} // Tizen::Base + +namespace Tizen { namespace Ui { namespace Controls { + +class Gallery; +class GalleryItem; +class _GalleryItem; + +class _GalleryItemImpl + : public Tizen::Base::Object +{ +public: + _GalleryItemImpl(GalleryItem* pPublicGalleryItem, _GalleryItem* pCoreGalleryItem); + virtual ~_GalleryItemImpl(void); + + static _GalleryItemImpl* CreateGalleryItemImplN(GalleryItem* pGallery, const Tizen::Graphics::Bitmap& image, + GalleryImageRotation rotation, Tizen::Base::String filePath); + + virtual const char* GetPublicClassName(void) const; + virtual const GalleryItem& GetPublic(void) const; + virtual GalleryItem& GetPublic(void); + virtual const _GalleryItem& GetCore(void) const; + virtual _GalleryItem& GetCore(void); + + static _GalleryItemImpl* GetInstance(GalleryItem& galleryItem); + static const _GalleryItemImpl* GetInstance(const GalleryItem& galleryItem); + +private: + _GalleryItemImpl(const _GalleryItemImpl& rhs); + _GalleryItemImpl& operator=(const _GalleryItemImpl& rhs); + +private: + GalleryItem* __pPublicGalleryItem; + _GalleryItem* __pCoreGalleryItem; +}; // _GalleryItemImpl + +}}} //Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_ITEM_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryItemProvider.h b/src/ui/inc/FUiCtrl_GalleryItemProvider.h new file mode 100644 index 0000000..24903c0 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryItemProvider.h @@ -0,0 +1,50 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_ITEM_PROVIDER_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_ITEM_PROVIDER_H_ + +#include "FUiCtrl_IGalleryItemProvider.h" + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryCoreEvent; +class _GalleryItemProviderAdaptorImpl; + +class _GalleryItemProvider + : public _IGalleryItemProvider +{ +public: + _GalleryItemProvider(_GalleryCoreEvent& coreEvent, _GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor); + virtual ~_GalleryItemProvider(void); + + virtual _GalleryItem* CreateItem(int index); + virtual bool DeleteItem(int index, _GalleryItem* pItem); + virtual bool UnloadItem(int index, _GalleryItem* pItem); + virtual int GetItemCount(void) const; + +private: + _GalleryItemProvider(const _GalleryItemProvider& rhs); + _GalleryItemProvider& operator=(const _GalleryItemProvider& rhs); + +private: + _GalleryCoreEvent& __coreEvent; + _GalleryItemProviderAdaptorImpl* __pItemProviderAdaptor; +}; // _GalleryItemProvider + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_ITEM_PROVIDER_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryItemProviderAdaptor.h b/src/ui/inc/FUiCtrl_GalleryItemProviderAdaptor.h new file mode 100644 index 0000000..d1889e4 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryItemProviderAdaptor.h @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_ITEM_PROVIDER_ADAPTOR_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_ITEM_PROVIDER_ADAPTOR_H_ + +#include +#include "FUiCtrl_IListItemProviderAdaptor.h" + +namespace Tizen { namespace Ui { namespace Controls { + +class _IGalleryItemProvider; + +class _GalleryItemProviderAdaptor + : public _IListItemProviderAdaptor +{ +public: + // Lifecycle + _GalleryItemProviderAdaptor(_IGalleryItemProvider& itemProvider); + virtual ~_GalleryItemProviderAdaptor(void); + + // Accessor + + result SetGalleryItemProvider(_IGalleryItemProvider& itemProvider); + + virtual _IListItemCommon* LoadItem(int groupIndex, int itemIndex); + virtual result UnloadItem(_IListItemCommon* pItem, int groupIndex, int itemIndex); + virtual int GetItemCount(int groupIndex = 0) const; + virtual int GetGroupCount(void) const + { + return 1; + } + + virtual result DeleteItem(_IListItemCommon* pItem, int groupIndex, int itemIndex); + +private: + _GalleryItemProviderAdaptor(const _GalleryItemProviderAdaptor& rhs); + _GalleryItemProviderAdaptor& operator=(const _GalleryItemProviderAdaptor& rhs); + +private: + _IGalleryItemProvider& __itemProvider; +}; // _GalleryItemProviderAdaptor + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_GALLERY_ITEM_PROVIDER_ADAPTOR_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryItemProviderAdaptorImpl.h b/src/ui/inc/FUiCtrl_GalleryItemProviderAdaptorImpl.h new file mode 100644 index 0000000..22fd2be --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryItemProviderAdaptorImpl.h @@ -0,0 +1,48 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_ITEM_PROVIDER_ADAPTOR_IMPL_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_ITEM_PROVIDER_ADAPTOR_IMPL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls { + +class IGalleryItemProvider; +class _GalleryItem; + +class _GalleryItemProviderAdaptorImpl + : public Tizen::Base::Object +{ +public: + _GalleryItemProviderAdaptorImpl(void); + virtual ~_GalleryItemProviderAdaptorImpl(void); + + void SetGalleryItemProvider(const IGalleryItemProvider& itemProvider); + bool HasGalleryItemProvider(void) const; + + virtual _GalleryItem* CreateItem(int index); + virtual bool DeleteItem(int index, _GalleryItem* pItem); + virtual bool UnloadItem(int index, _GalleryItem* pItem); + virtual int GetItemCount(void) const; + +private: + IGalleryItemProvider* __pItemProvider; +}; // _GalleryItemProviderAdaptorImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_GALLERY_ITEM_PROVIDER_ADAPTOR_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryModel.h b/src/ui/inc/FUiCtrl_GalleryModel.h new file mode 100644 index 0000000..1cfce41 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryModel.h @@ -0,0 +1,70 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_MODEL_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_MODEL_H_ + +#include +#include "FUiCtrl_ListViewModel.h" + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryItem; +class _IGalleryItemProvider; +class _GalleryItemProviderAdaptor; + +class _GalleryModel + : public Tizen::Base::Object +{ +public: + virtual ~_GalleryModel(void); + + static _GalleryModel* CreateGalleryModelN(_IGalleryItemProvider& galleryItemProvider); + + result RegisterItemProviderAdaptor(_GalleryItemProviderAdaptor* pGalleryItemProviderAdaptor); + + _GalleryItem* GetItem(int index) const; + result SetItemProvider(_IGalleryItemProvider& provider); + int GetItemCount(void) const; + int GetItemCountFromProvider(void) const; + void UpdateItemCount(void); + + result RequestToLoadItem(int index); + result RequestToUnloadItem(int index); + result RequestToUnloadAllItems(void); + result RequestToUpdateItem(int itemIndex); + result RequestToUpdateAllItems(void); + result SetCacheSize(int size); + int GetCacheSize(void) const; + + result AddGroup(void); + +protected: + _GalleryModel(void); + +private: + _GalleryModel(const _GalleryModel& rhs); + _GalleryModel& operator=(const _GalleryModel& rhs); + +private: + _ListViewModel __listViewModel; + _GalleryItemProviderAdaptor* __pGalleryItemProviderAdaptor; + int __itemCount; +}; // _GalleryModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_GALLERY_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryPresenter.h b/src/ui/inc/FUiCtrl_GalleryPresenter.h new file mode 100644 index 0000000..b86a039 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryPresenter.h @@ -0,0 +1,208 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H +#define _FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H + +#include +#include +#include +#include +#include "FUi_PropertyBase.h" +#include "FUiCtrl_GalleryTypes.h" +#include "FUiCtrl_IGalleryRendererNotiListener.h" + +namespace Tizen { namespace Base { namespace Runtime { + +class Timer; + +}}} // Tizen::Base::RunTime + +namespace Tizen { namespace Ui { namespace Controls { + +const int MAX_CANVAS_COUNT = 4; +const int NOT_EXIST_CANVAS = -1; +const int NOT_USED_CANVAS = -1; +const int NO_CURRENT_IMAGE = -1; + +class _GalleryViewEvent; +class _GalleryBitmap; +class _IGalleryRenderer; +class _IGalleryCoreEventListener; +class _GalleryViewEventHandler; +class _GalleryModel; +class _GalleryImageReader; +class _GalleryCoreEvent; +class _GalleryItemProvider; +class _GalleryBitmap; +class _GalleryItemProviderAdaptorImpl; + +class _GalleryPresenter + : public Tizen::Ui::_PropertyBase + , public _IGalleryRendererNotiListener + , public Tizen::Ui::_IPropertyChangeEventListener + , public Tizen::Base::Runtime::ITimerEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Declare Properties + DECLARE_CLASS_BEGIN(_GalleryPresenter, _PropertyBase); + DECLARE_PROPERTY("slideShowViewDuration", GetPropertySlideShowViewDuration, SetPropertySlideShowViewDuration); + DECLARE_PROPERTY("slideShowAnimationDuration", GetPropertySlideShowAnimationDuration, SetPropertySlideShowAnimationDuration); + DECLARE_PROPERTY("textOfEmptyGallery", GetPropertyTextOfEmptyGallery, SetPropertyTextOfEmptyGallery); + DECLARE_PROPERTY("zoomingEnabled", GetPropertyZoomingEnabled, SetPropertyZoomingEnabled); + DECLARE_CLASS_END(); + +public: + virtual ~_GalleryPresenter(void); + + static _GalleryPresenter* CreateGalleryPresenterN(_IGalleryRenderer& galleryRenderer, _GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor); + + int GetCurrentItemIndex(void) const; + result SetCurrentItemIndex(int index, bool eventFire = true); + result SetCurrentItem(int index); + + int GetItemCount(void) const; + + void SetItemSpacing(int spacing); + int GetItemSpacing(void) const; + + _GallerySlideShowType GetSlideShowType(void) const; + result SetSlideShowType(_GallerySlideShowType slideShowType); + + int GetSlideShowAnimationDuration(void) const; + result SetSlideShowAnimationDuration(int duration); + + int GetSlideShowViewDuration(void) const; + result SetSlideShowViewDuration(int duration); + + result StartSlideShow(bool repeat = false); + result StopSlideShow(void); + bool IsSlideShowStarted(void) const; + + Tizen::Base::String GetTextOfEmptyGallery(void) const; + result SetTextOfEmptyGallery(const Tizen::Base::String& text); + result SetBitmapOfEmptyGallery(const _GalleryBitmap* pBitmap); + + result SetZoomingEnabled(bool enable); + bool IsZoomingEnabled(void) const; + + bool PostEvent(_GalleryViewEvent& event); + bool OnBoundsChanged(void); + void OnDraw(void); + + result SetCoreEventListener(const _IGalleryCoreEventListener& coreEventListener); + result RemoveCoreEventListener(const _IGalleryCoreEventListener& coreEventListener); + + bool ClickedItem(void); + bool ChangedItem(void); + + // model access + result RequestToLoadItem(int index); + result RequestToUnloadItem(int index); + result RequestToUnloadAllItems(void); + result RequestToUpdateItem(int index); + result RequestToUpdateAllItems(void); + result RequestToUpdateItemCount(void); + + // timer + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + // renderer noti listener + virtual void OnTransitionCancel(void); + virtual void OnTransitionCompleted(void); + virtual void OnCanvasAnimationCancel(void); + virtual void OnCanvasAnimationCompleted(void); + virtual void OnCanvasAnimationStarted(void); + + // data binding event listener + virtual void OnPropertyChanging(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty); + virtual void OnPropertyChanged(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty); + + // font function + void SetFontSize(int size); + int GetFontSize(void) const; + void SetFontStyle(Tizen::Graphics::FontStyle style); + Tizen::Graphics::FontStyle GetFontStyle(void) const; + void OnFontChanged(void); + + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + +protected: + _GalleryPresenter(_IGalleryRenderer& galleryRenderer); + result Construct(_GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor); + + // property getter/setter + Variant GetPropertySlideShowViewDuration(void) const; + result SetPropertySlideShowViewDuration(const Variant& variant); + Variant GetPropertySlideShowAnimationDuration(void) const; + result SetPropertySlideShowAnimationDuration(const Variant& variant); + Variant GetPropertyTextOfEmptyGallery(void) const; + result SetPropertyTextOfEmptyGallery(const Variant& variant); + Variant GetPropertyZoomingEnabled(void) const; + result SetPropertyZoomingEnabled(const Variant& variant); + +private: + _GalleryPresenter(const _GalleryPresenter& rhs); + _GalleryPresenter& operator=(const _GalleryPresenter& rhs); + + result SetCanvasImage(int itemIndex); + result SetPartialCanvasImage(void); + int SearchCanvasIndex(int itemIndex); + int GetEmptyCanvasIndex(void) const; + result SetCanvasIndex(int canvasIndex, int itemIndex); + int ClearCanvasIndex(int currentItemIndex); + void SortItemToCanvasIndex(int itemIndex, bool add); + + result StartSlideShowTimer(int duration); + void StopSlideShowTimer(void); + result PlaySlideShow(void); + +private: + _IGalleryRenderer& __galleryRenderer; + _GalleryViewEventHandler* __pGalleryViewEventHandler; + _GalleryCoreEvent* __pGalleryCoreEvent; + _GalleryItemProvider* __pGalleryItemProvider; + _GalleryModel* __pGalleryModel; + _GalleryImageReader* __pGalleryImageReader; + + //_GalleryBitmap* __pPartialImage; + _GalleryBitmap* __pEmptyGalleryImage; + Tizen::Base::String __emptyText; + int __slideShowAnimationDuration; + int __slideShowViewDuration; + _GallerySlideShowType __gallerySlideShowType; + int __currentItemIndex; + bool __slideShowRepeat; + bool __slideShowStarted; + bool __zoomingEnabled; + Tizen::Base::Runtime::Timer* __pSlideShowTimer; + int __slideShowPlayCount; + int __itemSpacing; + int* __pItemToCanvas; + _GalleryFittingType __fittingType; + _GalleryVerticalAlignment __verticalAlignment; + _GalleryHorizontalAlignment __horizontalAlignment; + + int __emptyFontSize; + Tizen::Graphics::FontStyle __emptyFontStyle; + +friend class _GalleryViewEventHandler; +}; // _GalleryPresenter + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H diff --git a/src/ui/inc/FUiCtrl_GalleryRenderer.h b/src/ui/inc/FUiCtrl_GalleryRenderer.h new file mode 100644 index 0000000..645a038 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryRenderer.h @@ -0,0 +1,175 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_RENDERER_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_RENDERER_H_ + +#include +#include +#include +#include "FUiCtrl_IGalleryRenderer.h" + +namespace Tizen { namespace Graphics { +class Color; +class Rectangle; +}} + +namespace Tizen { namespace Ui { +class _Control; +}} + +namespace Tizen { namespace Ui { namespace Animation { +class VisualElement; +}}} + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryBitmap; +class _GalleryCanvasManager; +class _GalleryRendererNotifier; +class _IGalleryRendererNotiListener; +class _GalleryAnimationProvider; + +class _GalleryRenderer + : public _IGalleryRenderer + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , public Tizen::Ui::Effects::IEffectEventListener + , public Tizen::Ui::Effects::IEffectResourceProvider +{ +public: + virtual ~_GalleryRenderer(void); + static _GalleryRenderer* CreateGalleryRendererN(Tizen::Ui::_Control& control); + + virtual result AddNotiListener(const _IGalleryRendererNotiListener& notiListener); + virtual result RemoveNotiListener(const _IGalleryRendererNotiListener& notiListener); + virtual result SetCanvasMaxCount(int maxCount); + virtual int GetCanvasMaxCount(void) const; + virtual result SetCanvasVisibility(int canvasIndex, bool visibility); + virtual bool IsCanvasVisibility(int canvasIndex) const; + virtual result SetCanvasShowState(int canvasIndex, bool showState); + virtual Tizen::Graphics::Rectangle GetViewRect(void) const; + virtual result SetEmptyImage(const _GalleryBitmap* pImage); + virtual result SetEmptyText(const Tizen::Base::String& pText); + virtual result EnableEmptyView(void); + virtual result DisableEmptyView(void); + virtual result SetCanvasImage(int canvasIndex, const _GalleryBitmap* pImage + , _GalleryVerticalAlignment imageVerticalAlignment, _GalleryHorizontalAlignment imageHorizontalAlignment + , _GalleryFittingType fittingType); + virtual result SetCanvasBounds(int canvasIndex, const Tizen::Graphics::Rectangle& bounds, + const _GalleryAnimationTiming* pAnimation = null); + virtual Tizen::Graphics::Rectangle GetCanvasBounds(int canvasIndex) const; + virtual Tizen::Graphics::Rectangle GetCanvasAlignBoundary(int canvasIndex) const; + virtual result SetCanvasImageBounds(int canvasIndex, const Tizen::Graphics::Rectangle& bounds); + virtual Tizen::Graphics::Rectangle GetCanvasImageBounds(int canvasIndex) const; + virtual result RunCanvasTransition(int startCanvasIndex, int endCanvasIndex, _GalleryTransitionType transition, + const _GalleryAnimationTiming* pAnimation = null); + virtual void StopAllCanvasAnimation(void); + virtual bool IsRunningCanvasTransition(void) const; + virtual bool IsRunningCanvasAnimation(void) const; + virtual bool IsExposed(void) const; + virtual result RefreshView(void); + virtual result ReleaseAllCanvasResource(void); + virtual result ResetAllCanvas(void); + virtual result InitializeCanvasBounds(void); + + result Draw(void); + virtual void GalleryBoundsChanged(int currentCanvasIndex); + + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, + const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, + const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount); + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, + const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + + void SetEffect(Tizen::Ui::Effects::Effect* effect); + Tizen::Ui::Effects::Effect* GetEffect(void); + + // 3d effect listener + virtual void OnEffectStarted(Tizen::Ui::Effects::Effect& effect); + virtual void OnEffectFinished(Tizen::Ui::Effects::Effect& effect, Tizen::Ui::Effects::EffectResult effectResult, const Tizen::Base::Collection::IList& lastShownBitmapIds); + + // 3d effect provider + virtual result SetBitmap(Tizen::Ui::Effects::Effect& effect, long bitmapId); + +private: + _GalleryRenderer(const _GalleryRenderer& value); + _GalleryRenderer& operator=(const _GalleryRenderer& value); + + _GalleryRenderer(void); + result Construct(Tizen::Ui::_Control& control); + + result ShowEmptyImageAndText(void); + + result RunDissolveTransition(int startCanvasIndex, int endCanvasIndex, const _GalleryAnimationTiming* pAnimation); + result RunZoomTransition(int startCanvasIndex, int endCanvasIndex, const _GalleryAnimationTiming* pAnimation); + result RunPageTransition(int startCanvasIndex, int endCanvasIndex, const _GalleryAnimationTiming* pAnimation); + + void OnAnimationCancel(void); + + void SetControl(Tizen::Ui::_Control& control); + Tizen::Ui::_Control& GetControl(void) const; + + void SetCanvasManager(_GalleryCanvasManager& canvasManager); + _GalleryCanvasManager& GetCanvasManager(void) const; + + void SetRendererNotifier(_GalleryRendererNotifier& rendererNotifier); + _GalleryRendererNotifier& GetRendererNotifier(void) const; + + void SetAnimationDelegator(_GalleryAnimationProvider& galleryVEDelegator); + _GalleryAnimationProvider& GetAnimationDelegator(void) const; + + void SetEmptyCanvasIndex(int emptyCanvasIndex); + int GetEmptyCanvasIndex(void) const; + + void SetSlideShowPlayType(_GallerySlideShowType slideShowType); + _GallerySlideShowType GetSlideShowPlayType(void) const; + + void AddAnimationCount(void); + void ReleaseAnimationCount(void); + void ResetAnimationCount(void); + int GetAnimationCount(void) const; + void StopAllAnimation(void); + + void SetStartCanvasOfPageCurling(int startCanvasIndex); + int GetStartCanvasOfPageCurling(void); + void SetEndCanvasOfPageCurling(int endCanvasIndex); + int GetEndCanvasOfPageCurling(void); + +private: + Tizen::Ui::_Control* __pControl; + _GalleryCanvasManager* __pCanvasManager; + _GalleryRendererNotifier* __pRendererNotifyer; + _GalleryAnimationProvider* __pGalleryAnimationDelegator; + Tizen::Base::String __emptyString; + int __emptyCanvasIndex; + int __slideShowAnimationCount; + _GallerySlideShowType __slideShowPlayType; + bool __showEmptyImage; + bool __animationRunning; + bool __needDrawEmptyCanvas; + int __startCanvasOfPageCurling; + int __endCanvasOfPageCurling; + Tizen::Ui::Effects::Effect* __pEffect; + Tizen::Graphics::Bitmap* __pTransparentBitmap; + Tizen::Graphics::Bitmap* __pPageCurlingBitmap; + Tizen::Graphics::Color __emptyTextColor; +}; // _GalleryRenderer + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_RENDERER_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryRendererNotification.h b/src/ui/inc/FUiCtrl_GalleryRendererNotification.h new file mode 100644 index 0000000..97ec092 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryRendererNotification.h @@ -0,0 +1,62 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_RENDERER_NOTIFICATION_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_RENDERER_NOTIFICATION_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls { + +enum _GalleryRendererNotiType +{ + GALLERY_RENDERER_NOTI_MIN_COUNT = -1, + GALLERY_RENDERER_NOTI_TRANSITION_CANCEL, + GALLERY_RENDERER_NOTI_TRANSITION_COMPLETED, + GALLERY_RENDERER_NOTI_CANVAS_ANIMATION_CANCEL, + GALLERY_RENDERER_NOTI_CANVAS_ANIMATION_COMPLETED, + GALLERY_RENDERER_NOTI_CANVAS_ANIMATION_STARTED, + GALLERY_RENDERER_NOTI_MAX_COUNT +}; + +class _GalleryRendererNotification + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +public: + _GalleryRendererNotification(_GalleryRendererNotiType notificationType) + { + __notificationType = notificationType; + } + + virtual ~_GalleryRendererNotification(void) + { + } + + _GalleryRendererNotiType GetNotificationType(void) const + { + return __notificationType; + } + +private: + _GalleryRendererNotiType __notificationType; +}; // _GalleryRendererNotification + +}}} // Tizen::Ui::Controls + + +#endif // _FUI_CTRL_INTERNAL_GALLERY_IMPL_EVENT_ARG_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryRendererNotifier.h b/src/ui/inc/FUiCtrl_GalleryRendererNotifier.h new file mode 100644 index 0000000..1832c73 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryRendererNotifier.h @@ -0,0 +1,51 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_RENDERER_NOTIFIER_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_RENDERER_NOTIFIER_H_ + +#include + + +namespace Tizen { namespace Base { namespace Runtime { + +class IEventListener; +class IEventArg; + +}}} // Tizen::Base::Runtime + + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryRendererNotifier + : public Tizen::Base::Runtime::_Event +{ +public: + _GalleryRendererNotifier(void); + virtual ~_GalleryRendererNotifier(void); + +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + _GalleryRendererNotifier(const _GalleryRendererNotifier& rhs); + _GalleryRendererNotifier& operator=(const _GalleryRendererNotifier& rhs); + +}; // _GalleryRendererNotifier + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_RENDERER_NOTIFIER_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryTypes.h b/src/ui/inc/FUiCtrl_GalleryTypes.h new file mode 100644 index 0000000..a18185e --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryTypes.h @@ -0,0 +1,83 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_ENUM_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_ENUM_H_ + +namespace Tizen { namespace Ui { namespace Controls { + +enum _GalleryImageRotation +{ + GALLERY_INTERNAL_IMAGE_ROTATION_0 = 0, /**< No rotate */ + GALLERY_INTERNAL_IMAGE_ROTATION_90, /**< The 90 degree clockwise rotation */ + GALLERY_INTERNAL_IMAGE_ROTATION_180, /**< The clockwise rotation */ + GALLERY_INTERNAL_IMAGE_ROTATION_270 /**< The anticlockwise rotation */ +}; + +enum _GallerySlideShowType { + GALLERY_SLIDESHOW_NONE = -1, + GALLERY_SLIDESHOW_DISSOLVE = 0, + GALLERY_SLIDESHOW_ZOOM, + GALLERY_SLIDESHOW_PAGE, +}; + +enum _GalleryAnimationTimingFunction +{ + GALLERY_ANIMATION_TIMING_FUNC_LINEAR = 0, + GALLERY_ANIMATION_TIMING_FUNC_EASEIN, + GALLERY_ANIMATION_TIMING_FUNC_EASEOUT, + GALLERY_ANIMATION_TIMING_FUNC_EASEINOUT +}; + +enum _GalleryVerticalAlignment +{ + GALLERY_VERTICAL_ALIGN_TOP = 0, + GALLERY_VERTICAL_ALIGN_MIDDLE, // default + GALLERY_VERTICAL_ALIGN_BOTTOM, +}; + +enum _GalleryHorizontalAlignment +{ + GALLERY_HORIZONTAL_ALIGN_LEFT = 0, + GALLERY_HORIZONTAL_ALIGN_CENTER, // default + GALLERY_HORIZONTAL_ALIGN_RIGHT, +}; + +enum _GalleryFittingType +{ + GALLERY_FITTING_TYPE_NONE = 0, + GALLERY_FITTING_TYPE_FIT, + GALLERY_FITTING_TYPE_FIT_XY, + GALLERY_FITTING_TYPE_STRECTABLE, + GALLERY_FITTING_TYPE_SHRINKABLE, +}; + + +struct _GalleryAnimationTiming +{ + int duration_ms; + _GalleryAnimationTimingFunction timingFunction; +}; + +struct _GalleryImageAlignment +{ + _GalleryVerticalAlignment verticalAlignment; + _GalleryHorizontalAlignment horizontalAlignment; +}; + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_GALLERY_ENUM_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryViewEvent.h b/src/ui/inc/FUiCtrl_GalleryViewEvent.h new file mode 100644 index 0000000..9175dc4 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryViewEvent.h @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_VIEW_EVENT_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_VIEW_EVENT_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls { + +enum GalleryViewEventType +{ + GALLERY_VIEW_EVENT_ERROR = -1, + GALLERY_VIEW_EVENT_BOUNDS_CHANGED, + GALLERY_VIEW_EVENT_TOUCH_PRESSED, + GALLERY_VIEW_EVENT_TOUCH_RELEASED, + GALLERY_VIEW_EVENT_TOUCH_DOUBLE_PRESSED, + GALLERY_VIEW_EVENT_TOUCH_MOVED, + GALLERY_VIEW_EVENT_TOUCH_PINCH_ZOOM, + GALLERY_VIEW_EVENT_TOUCH_FLICK +}; + +class _GalleryViewEventInfo; + +class _GalleryViewEvent + : public Tizen::Base::Object +{ +public: + _GalleryViewEvent(GalleryViewEventType eventType, _GalleryViewEventInfo* eventInfo); + virtual ~_GalleryViewEvent(void); + + GalleryViewEventType GetEventType(void) const; + _GalleryViewEventInfo* GetEventInfo(void) const; + +private: + _GalleryViewEvent(const _GalleryViewEvent& rhs); + _GalleryViewEvent& operator=(const _GalleryViewEvent& rhs); + +private: + GalleryViewEventType __eventType; + _GalleryViewEventInfo* __pEventInfo; +}; // _GalleryViewEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_GALLERY_VIEW_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryViewEventHandler.h b/src/ui/inc/FUiCtrl_GalleryViewEventHandler.h new file mode 100644 index 0000000..c6fe7e9 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryViewEventHandler.h @@ -0,0 +1,116 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_VIEW_EVENT_HANDLER_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_VIEW_EVENT_HANDLER_H_ + +#include +#include +#include "FUiCtrl_GalleryTypes.h" +#include "FUiCtrl_IGalleryRendererNotiListener.h" + +namespace Tizen { namespace Graphics { + +class Dimension; + +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls { + +enum FlickDirection +{ + FLICK_DIRECTION_NONE = 0, + FLICK_DIRECTION_LEFT, + FLICK_DIRECTION_RIGHT +}; + +class _GalleryImageReader; +class _GalleryModel; +class _GalleryPresenter; +class _GalleryViewEventInfo; +class _IGalleryRenderer; + +class _GalleryViewEventHandler + : public Tizen::Base::Object + , public _IGalleryRendererNotiListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + _GalleryViewEventHandler(_GalleryPresenter& galleryPresenter, _IGalleryRenderer& galleryRenderer, _GalleryImageReader& galleryModel); + virtual ~_GalleryViewEventHandler(void); + + result Construct(void); + + bool OnTouchPressed(_GalleryViewEventInfo& eventInfo); + bool OnTouchDoublePressed(_GalleryViewEventInfo& eventInfo); + bool OnTouchReleased(_GalleryViewEventInfo& eventInfo); + bool OnTouchPinchZoom(_GalleryViewEventInfo& eventInfo); + bool OnTouchMoved(_GalleryViewEventInfo& eventInfo); + bool OnTouchFlicked(_GalleryViewEventInfo& eventInfo); + + //notiListener + virtual void OnTransitionCancel(void); + virtual void OnTransitionCompleted(void); + virtual void OnCanvasAnimationCancel(void); + virtual void OnCanvasAnimationCompleted(void); + virtual void OnCanvasAnimationStarted(void); + + void SetZoomFlag(bool zoomMode); + bool IsZoomFlag(void) const; + result SetVisibleCanvas(void); + result AlignCanvas(bool animation = true); + bool CorrectCanvasPosition(Tizen::Graphics::Rectangle& canvasBounds, const Tizen::Graphics::Rectangle& imageBounds); + +private: + _GalleryViewEventHandler(const _GalleryViewEventHandler& rhs); + _GalleryViewEventHandler& operator=(const _GalleryViewEventHandler& rhs); + + result RefreshView(void); + + result SetInvisibleCanvas(void); + + result FlickToTheRight(void); + result FlickToTheLeft(void); + + result ZoomCanvas(int distance, const Tizen::Graphics::Point& center, bool zoomIn, _GalleryAnimationTiming* pAnimation = null); + result PinchZoomCanvas(int area, const Tizen::Graphics::Point& center, bool zoomIn); + result MoveCanvas(const Tizen::Graphics::Dimension& distance, _GalleryAnimationTiming* pAnimation = null); + + void SetRollbackCanvas(void); + int CalculateRound(float value); + result SetCurrentItemIndex(int index); + result CallChangeItemIndex(void); + +private: + _GalleryPresenter& __galleryPresenter; + _IGalleryRenderer& __galleryRenderer; + _GalleryImageReader& __galleryImageReader; + Tizen::Graphics::Point __previousPosition; + Tizen::Graphics::Point __startPinchCenterPosition; + FlickDirection __flickingDirection; + int __pinchInitialArea; + bool __pressed; + bool __moving; + bool __zoomMode; + bool __zoomAnimationComplete; + bool __pinchMode; + unsigned long __touchPointId; + int __currentItemIndex; +}; // _GalleryViewEventHandler + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_GALLERY_VIEW_EVENT_HANDLER_H_ diff --git a/src/ui/inc/FUiCtrl_GalleryViewEventInfo.h b/src/ui/inc/FUiCtrl_GalleryViewEventInfo.h new file mode 100644 index 0000000..d4f9d5f --- /dev/null +++ b/src/ui/inc/FUiCtrl_GalleryViewEventInfo.h @@ -0,0 +1,70 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_GALLERY_VIEW_EVENT_INFO_H_ +#define _FUI_CTRL_INTERNAL_GALLERY_VIEW_EVENT_INFO_H_ + +#include +#include "FUi_UiTouchEvent.h" + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryViewEventInfo + : public Tizen::Base::Object +{ +public: + _GalleryViewEventInfo(void); + _GalleryViewEventInfo(_TouchInfo& touchInfo); + virtual ~_GalleryViewEventInfo(void); + + // touch Info access + _TouchStatus GetTouchStatus(void) const; + Tizen::Graphics::Point GetCurrentPosition(void) const; + + // flick info access + void SetFlicked(bool flicked); + bool IsFlicked(void) const; + void SetFlickPosition(Tizen::Graphics::Point flickPos); + Tizen::Graphics::Point GetFlickPosition(void) const; + void SetFlickTime(int flickTime); + int GetFlickTime(void) const; + + // pinch info access + void SetPinchCenterPosition(Tizen::Graphics::Point centerPos); + Tizen::Graphics::Point GetPinchCenterPosition(void) const; + void SetPinchArea(int area); + int GetPinchArea(void) const; + + unsigned long GetPointId(void) const; + +private: + _GalleryViewEventInfo(const _GalleryViewEventInfo& rhs); + _GalleryViewEventInfo& operator=(const _GalleryViewEventInfo& rhs); + +private: + _TouchInfo* __pTouchInfo; + + bool __flicked; + Tizen::Graphics::Point __flickPosition; + int __flickTime; + + Tizen::Graphics::Point __pinchCenterPosition; + int __PinchArea; +}; // _GalleryViewEventInfo + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_GALLERY_VIEW_EVENT_INFO_H_ diff --git a/src/ui/inc/FUiCtrl_GroupItemImpl.h b/src/ui/inc/FUiCtrl_GroupItemImpl.h new file mode 100644 index 0000000..47f8166 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GroupItemImpl.h @@ -0,0 +1,89 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_GroupItemImpl.h + * @brief This is the header file for the GroupItemImpl class. + * + * This header file contains the declarations of the GroupItemImpl class. + */ + +#ifndef _FUI_CTRL_GROUP_ITEM_IMPL_H_ +#define _FUI_CTRL_GROUP_ITEM_IMPL_H_ + +#include "FUiCtrl_ListItemBaseImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class ICustomElement; +class GroupItem; + +class _GroupItemImpl + : public _ListItemBaseImpl +{ +// Lifecycle +public: + static _GroupItemImpl* CreateGroupItemImpN(GroupItem* pPublic, const Tizen::Graphics::Dimension& itemSize); + + virtual ~_GroupItemImpl(void); + +// Operation +public: + virtual const char* GetPublicClassName(void) const; + + result Construct(const Tizen::Graphics::Dimension& itemSize); + + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + result SetBackgroundColor(const Tizen::Graphics::Color& color); + + Tizen::Graphics::Color GetBackgroundColor(void) const; + + result SetTextColor(const Tizen::Graphics::Color& color); + + Tizen::Graphics::Color GetTextColor(void) const; + + result SetTextSize(int size); + + int GetTextSize(void) const; + + result SetElement(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap = null); + +public: + static _GroupItemImpl* GetInstance(GroupItem& groupItem); + + static const _GroupItemImpl* GetInstance(const GroupItem& groupItem); + +// Constructor +private: + _GroupItemImpl(GroupItem* pPublic); + + _GroupItemImpl(const _GroupItemImpl& rhs); + + _GroupItemImpl& operator =(const _GroupItemImpl& rhs); + +// Attribute +private: + static const float GROUP_ITEM_ELEMENT_BITMAP_SIZE_RATIO = 0.6f; + int __textSize; + Tizen::Graphics::Color __textColor; +}; // _GroupItemImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_GROUP_ITEM_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_GroupedListImpl.h b/src/ui/inc/FUiCtrl_GroupedListImpl.h new file mode 100644 index 0000000..c8dddaa --- /dev/null +++ b/src/ui/inc/FUiCtrl_GroupedListImpl.h @@ -0,0 +1,206 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_GroupedListImpl.h + * @brief This is the header file for the _GroupedListImpl class. + * + * This header file contains the declarations of the _GroupedListImpl class and its helper classes. + */ + +#ifndef _FUI_CTRL_INTERNAL_GROUPED_LIST_IMPL_H_ +#define _FUI_CTRL_INTERNAL_GROUPED_LIST_IMPL_H_ + +#include +#include +#include +#include +#include +#include "FUiCtrl_CustomListImpl.h" +#include "FUiCtrl_TableView.h" +#include "FUi_ControlImpl.h" +#include "FUiCtrl_ListBaseImpl.h" +#include "FUiCtrl_IFastScrollListener.h" +#include "FUiCtrl_CustomListItemImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _GroupedListItemDataProvider + : public Tizen::Ui::Controls::IGroupedTableViewItemProvider +{ +public: + _GroupedListItemDataProvider(class _GroupedListImpl* pGroupedListImpl); + virtual ~_GroupedListItemDataProvider(void); + + int GetGroupCount(void); + int GetItemCount(int groupIndex); + Tizen::Ui::Controls::TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + Tizen::Ui::Controls::TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth); + bool DeleteItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem); + bool DeleteGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem); + bool IsReorderable(int groupIndexFrom, int groupIndexTo); + + void UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem); + void UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem); + int GetDefaultGroupItemHeight(void); + int GetDefaultItemHeight(void); + +private: + _GroupedListItemDataProvider(const _GroupedListItemDataProvider& rhs); + _GroupedListItemDataProvider& operator =(const _GroupedListItemDataProvider& rhs); + +private: + _GroupedListImpl* __pList; +}; //_GroupedListItemDataProvider + +class _GroupedListImpl + : public _ListBaseImpl + , public _ITableViewItemEventListener + , public _IUiFastScrollListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + virtual ~_GroupedListImpl(void); + static _GroupedListImpl* CreateGroupedListImplN(GroupedList* pControl, const Tizen::Graphics::Rectangle& bounds, bool itemDivider = true, bool fastScroll = false); + virtual const char* GetPublicClassName(void) const; + virtual const GroupedList& GetPublic(void) const; + virtual GroupedList& GetPublic(void); + virtual const _TableView& GetCore(void) const; + virtual _TableView& GetCore(void); + result Initialize(void); + //@See doxygen + result AddFastScrollEventListener(const Tizen::Ui::IFastScrollEventListener& listener); + //@See doxygen + result RemoveFastScrollEventListener(const Tizen::Ui::IFastScrollEventListener& listener); + //@See doxygen + result AddGroupedItemEventListener(const Tizen::Ui::IGroupedItemEventListener& listener); + //@See doxygen + result RemoveGroupedItemEventListener(const Tizen::Ui::IGroupedItemEventListener& listener); + result SetItemProvider(void); + //@See doxygen + result AddGroup(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int groupId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result AddItem(int groupIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result SetItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result InsertGroupAt(int groupIndex, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int groupId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result SetGroupAt(int groupIndex, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int groupId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result InsertItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result RemoveItemAt(int groupIndex, int itemIndex); + //@See doxygen + result RemoveAllItemsAt(int groupIndex); + //@See doxygen + result RemoveGroupAt(int groupIndex); + //@See doxygen + result RemoveAllGroups(void); + //@See doxygen + result RemoveAllItems(void); + //@See doxygen + result SetItemEnabled(int groupIndex, int itemIndex, bool enable); + //@See doxygen + bool IsItemEnabled(int groupIndex, int itemIndex) const; + //@See doxygen + result SetItemChecked(int groupIndex, int itemIndex, bool check); + //@See doxygen + bool IsItemChecked(int groupIndex, int itemIndex) const; + //@See doxygen + result SetAllItemsChecked(int groupIndex, bool check); + //@See doxygen + result RemoveAllCheckedItems(void); + //@See doxygen + result RemoveAllCheckedItemsAt(int groupIndex); + //@See doxygen + result GetFirstCheckedItemIndex(int& groupIndex, int& itemIndex) const; + //@See doxygen + result GetLastCheckedItemIndex(int& groupIndex, int& itemIndex) const; + //@See doxygen + result GetNextCheckedItemIndexAfter(int& groupIndex, int& itemIndex) const; + //@See doxygen + int GetGroupIndexFromGroupId(int groupId) const; + //@See doxygen + result GetItemIndexFromItemId(int itemId, int& groupIndex, int& itemIndex) const; + //@See doxygen + result SetFastScrollMainIndex(const Tizen::Base::String& text); + //@See doxygen + result SetFastScrollSubIndex(const Tizen::Base::String& text, FastScrollIndexDigit indexDigit); + //@See doxygen + void ScrollToBottom(void); + //@See doxygen + void ScrollToTop(void); + //@See doxygen + result ScrollToTop(int groupIndex, int itemIndex); + //@See doxygen + result ScrollToTop(int groupIndex); + //@See doxygen + result RefreshGroup(int groupIndex); + //@See doxygen + result RefreshItem(int groupIndex, int itemIndex); + //@See doxygen + int GetGroupIdAt(int groupIndex) const; + //@See doxygen + int GetItemIdAt(int groupIndex, int itemIndex) const; + + void SetListBackgroundColor(const Tizen::Graphics::Color& bgColor); + + void OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + void OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo); + void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + void OnGroupedTableViewItemReordered(_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo); + void OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + void OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction); + + virtual void OnUiFastScrollIndexSelected(Tizen::Ui::_Control& source, Tizen::Ui::Controls::_FastScrollIndex& index); + virtual void OnBoundsChanged(void); + +public: + static _GroupedListImpl* GetInstance(GroupedList& groupedList); + static const _GroupedListImpl* GetInstance(const GroupedList& groupedList); + +private: + _GroupedListImpl(Control* pPublic, _TableView* pCore); + _GroupedListImpl(const _GroupedListImpl& rhs); + _GroupedListImpl& operator =(const _GroupedListImpl& rhs); + virtual void ProcessItemStateChange(int groupIndex, int itemIndex, ItemStatus itemStatus); + virtual void ProcessItemStateChange(int groupIndex, int itemIndex, int elementId, ItemStatus itemStatus); + + _GroupedListItemDataProvider* __pItemProvider; + Tizen::Ui::IGroupedItemEventListener* __pItemListener; + Tizen::Base::String __mainIndexText; + int __groupItemHeight; + int __groupItemTextFont; + Tizen::Base::Collection::LinkedList __itemListenersList; + Tizen::Base::Collection::LinkedList __fastScrollListenersList; + Tizen::Graphics::Color __bgColor; + bool __directDelete; + CustomListItemFormat* __pItemFormat; + + friend class _GroupedListItemDataProvider; +}; //_GroupedListImpl + +}}} // Tizen::Ui::Controls + + +#endif //_FUI_CTRL_INTERNAL_GROUPED_LIST_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_GroupedListViewImpl.h b/src/ui/inc/FUiCtrl_GroupedListViewImpl.h new file mode 100644 index 0000000..c3d04e0 --- /dev/null +++ b/src/ui/inc/FUiCtrl_GroupedListViewImpl.h @@ -0,0 +1,267 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_GroupedListViewImpl.h + * @brief This file defines the GroupedListViewImpl class. + * @version 3.0 + * + * This file contains the declarations of GroupedListViewImpl class. + */ + +#ifndef _FUI_CTRL_GROUPED_LIST_VIEW_IMPL_H_ +#define _FUI_CTRL_GROUPED_LIST_VIEW_IMPL_H_ + +#include "FUi_ControlImpl.h" +#include "FUi_TouchEventArg.h" +#include "FUiCtrl_IFastScrollListener.h" +#include "FUiCtrl_IScrollEventListener.h" +#include "FUiCtrl_IUiListViewItemEventListener.h" +#include "FUiCtrl_TableView.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class GroupedListView; +class _FastScrollEvent; +class _Label; +class _ListItemEvent; +class _ListViewItem; +class _PublicLinkEvent; +class _ScrollEvent; + +class _GroupedListViewImpl + : public _ControlImpl + , public _ITableViewItemEventListener + , public _IScrollEventListener + , public _IUiFastScrollListener + , public _IUiListViewItemEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + virtual ~_GroupedListViewImpl(void); + + static _GroupedListViewImpl* CreateGroupedListViewImplN(GroupedListView* pControl, GroupedListViewStyle style, + bool itemDivider, ListScrollStyle scrollStyle); + + virtual const char* GetPublicClassName(void) const; + + virtual const GroupedListView& GetPublic(void) const; + + virtual GroupedListView& GetPublic(void); + + virtual const _TableView& GetCore(void) const; + + virtual _TableView& GetCore(void); + +public: + result SetItemProvider(IGroupedListViewItemProvider& provider); + + void AddGroupedListViewItemEventListener(IGroupedListViewItemEventListener& listener); + + void RemoveGroupedListViewItemEventListener(IGroupedListViewItemEventListener& listener); + + void AddFastScrollListener(IFastScrollListener& listener); + + void RemoveFastScrollListener(IFastScrollListener& listener); + + void AddScrollEventListener(IScrollEventListener& listener); + + void RemoveScrollEventListener(IScrollEventListener& listener); + + void AddUiLinkEventListener(const Tizen::Ui::IUiLinkEventListener& listener); + + void RemoveUiLinkEventListener(const Tizen::Ui::IUiLinkEventListener& listener); + + result SetSweepEnabled(bool enable); + + result SetFastScrollIndex(const Tizen::Base::String& text, bool useSearchIcon); + + result GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const; + + result GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const; + + result ScrollToItem(int groupIndex, int itemIndex, ListScrollItemAlignment itemAlignment); + + result SetItemChecked(int groupIndex, int itemIndex, bool check); + + bool IsItemChecked(int groupIndex, int itemIndex) const; + + result SetItemEnabled(int groupIndex, int itemIndex, bool enable); + + bool IsItemEnabled(int groupIndex, int itemIndex) const; + + int GetGroupCount(void) const; + + int GetItemCountAt(int groupIndex) const; + + result ShowItemDescriptionText(int groupIndex, int itemIndex); + + result HideItemDescriptionText(int groupIndex, int itemIndex); + + result RefreshList(int groupIndex, int itemIndex, ListRefreshType type); + + result RefreshList(int groupIndex, int itemIndex, int elementId); + + result UpdateList(void); + + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex) const; + + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex, int& elementId) const; + + result SetSectionColor(const Tizen::Graphics::Color& color); + + Tizen::Graphics::Color GetSectionColor(void) const; + + result SetItemDividerColor(const Tizen::Graphics::Color& color); + + Tizen::Graphics::Color GetItemDividerColor(void) const; + + void SetListBackgroundColor(const Tizen::Graphics::Color& color); + + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + result SetBitmapOfEmptyList(const Tizen::Graphics::Bitmap* pBitmap); + + result SetTextOfEmptyList(const Tizen::Base::String& text); + + Tizen::Base::String GetTextOfEmptyList(void) const; + + result SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + result ExpandGroup(int groupIndex); + + result CollapseGroup(int groupIndex); + + bool IsGroupExpanded(int groupIndex) const; + + result BeginReorderingMode(void); + + result EndReorderingMode(void); + + bool IsInReorderingMode(void) const; + + // _IUiListViewItemEventListener + virtual void OnListViewContextItemStateChanged(Tizen::Ui::_Control& source, int groupIndex, int itemIndex, int elementId, + Tizen::Ui::Controls::ListContextItemStatus status); + + virtual void OnListViewItemLongPressed(Tizen::Ui::_Control& source, int groupIndex, int itemIndex, int elementId); + + // _ITableViewItemEventListener + virtual void OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, + Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) {}; + + virtual void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, + Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) {}; + + virtual void OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo) {}; + + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, + Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, + Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, + int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + + virtual void OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, + int groupIndexTo, int itemIndexTo); + + virtual void OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, + Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + + virtual void OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, + int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + + virtual void OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, + Tizen::Ui::Controls::TableViewSweepDirection direction); + + // _IScrollEventListener + virtual void OnScrollEndReached(Tizen::Ui::_Control& source, ScrollEndEvent type); + + virtual void OnScrollPositionChanged(Tizen::Ui::_Control& source, int scrollPos); + + virtual void OnScrollStopped(Tizen::Ui::_Control& source); + + // event handler for _IUiFastScrollListener + virtual void OnUiFastScrollIndexSelected(Tizen::Ui::_Control& source, Tizen::Ui::Controls::_FastScrollIndex& index); + + virtual void OnDraw(void); + + virtual void OnBoundsChanged(void); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + virtual bool OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo); + +public: + static _GroupedListViewImpl* GetInstance(GroupedListView& groupedListView); + static const _GroupedListViewImpl* GetInstance(const GroupedListView& groupedListView); + +private: + _GroupedListViewImpl(GroupedListView* pGroupedList, _TableView* pCore); + + _GroupedListViewImpl(_GroupedListViewImpl& rhs); + + _GroupedListViewImpl& operator =(_GroupedListViewImpl& rhs); + + result SetItemDescriptionTextShowState(int groupIndex, int itemIndex, bool show); + + void AdjustLayoutOfEmptyList(void); + + void CheckEmptyListShowState(void); + + void FireListViewItemEvent(int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, + Tizen::Ui::Controls::TableViewItemStatus status); + + void FirePublicTouchEvent(const _TouchInfo& touchInfo); + + void FirePublicListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo); + + void FireFocusListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo); + + _TouchEventArg* GetTouchEventArgN(const _TouchInfo& touchInfo); + +private: + _ListItemEvent* __pListItemEvent; + _PublicLinkEvent* __pLinkEvent; + _ScrollEvent* __pScrollEvent; + _FastScrollEvent* __pFastScrollEvent; + + _Label* __pEmptyBitmap; + _Label* __pEmptyText; + Tizen::Graphics::Color __emptyTextColor; + + bool __redrawListView; + _ListViewItem* __pItemNeedsLazyDeletion; + _ListViewItem* __pItemSwept; +}; // _GroupedListViewImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_GROUPED_LIST_VIEW_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_GroupedListViewItemProviderAdaptor.h b/src/ui/inc/FUiCtrl_GroupedListViewItemProviderAdaptor.h new file mode 100644 index 0000000..ecec65f --- /dev/null +++ b/src/ui/inc/FUiCtrl_GroupedListViewItemProviderAdaptor.h @@ -0,0 +1,109 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_GroupedListViewItemProviderAdaptor.h + * @brief This is the header file for _GroupedListViewItemProviderAdaptor class. + * + * This header file contains declaration of _GroupedListViewItemProviderAdaptor class. + */ + +#ifndef _FUI_CTRL_INTERNAL_GROUPED_LIST_VIEW_ITEM_PROVIDER_H_ +#define _FUI_CTRL_INTERNAL_GROUPED_LIST_VIEW_ITEM_PROVIDER_H_ + +#include +#include +#include "FUiCtrl_IUiListViewItemEventListener.h" +#include "FUiCtrl_LinkedList.h" +#include "FUiCtrl_ListViewTypes.h" +#include "FUiCtrl_TableViewItemProviderAdaptor.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IListItemCommon; +class _ListViewItem; + +class _GroupedListViewItemProviderAdaptor + : public _TableViewItemProviderAdaptor +{ + +public: +// Lifecycle + _GroupedListViewItemProviderAdaptor(const IGroupedListViewItemProvider& provider); + + virtual ~_GroupedListViewItemProviderAdaptor(void); + +// Operation + void SetItemProvider(const IGroupedListViewItemProvider& provider); + + virtual _IListItemCommon* LoadItem(int groupIndex, int itemIndex); + + virtual result UnloadItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex); + + virtual result DeleteItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex); + + virtual bool UpdateItem(_IListItemCommon* pItem, int groupIndex, int itemIndex); + + virtual int GetItemCount(int groupIndex = 0) const; + + virtual int GetGroupCount(void) const; + + virtual int GetDefaultItemHeight(void); + + virtual int GetDefaultGroupItemHeight(void); + + virtual bool IsReorderable(int groupIndexFrom, int groupIndexTo); + + virtual bool HasSectionHeader(int groupIndex) const; + + virtual bool HasSectionFooter(int groupIndex) const; + + bool SetDescriptionTextShowState(int groupIndex, int itemIndex, bool show); + + bool IsDescriptionTextShown(int groupIndex, int itemIndex) const; + + void SetListViewItemEventListener(Tizen::Ui::Controls::_IUiListViewItemEventListener& listener); + + void SetItemFont(const Tizen::Base::String& fontName); + + void SetItemNeedsLazyDeletion(_ListViewItem* pItem); + +private: + _GroupedListViewItemProviderAdaptor(const _GroupedListViewItemProviderAdaptor& rhs); + + _GroupedListViewItemProviderAdaptor& operator =(const _GroupedListViewItemProviderAdaptor& rhs); + +// Variable +private: + IGroupedListViewItemProvider* __pGroupedListViewProvider; + _LinkedList <_ListItemPos> __descriptionTextShowItem; + _IUiListViewItemEventListener* __pEventListener; + Tizen::Base::String __fontName; + int __groupItemAverageHeight; + int __itemAverageHeight; + int __groupItemLoadedCount; + int __itemLoadedCount; + int __countOfAllGroups; + int __countOfAllItems; + _ListViewItem* __pItemNeedsLazyDeletion; +}; // _GroupedListViewItemProviderAdaptor + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_GROUPED_LIST_VIEW_ITEM_PROVIDER_H_ + diff --git a/src/ui/inc/FUiCtrl_HeaderImpl.h b/src/ui/inc/FUiCtrl_HeaderImpl.h new file mode 100644 index 0000000..e2bf849 --- /dev/null +++ b/src/ui/inc/FUiCtrl_HeaderImpl.h @@ -0,0 +1,226 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_HeaderImpl.h + * @brief This is the header file for the _HeaderImpl class. + * + * This header file contains the declarations of the %_HeaderImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_HEADER_IMPL_H_ +#define _FUI_CTRL_INTERNAL_HEADER_IMPL_H_ + +#include +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_Toolbar.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _PublicActionEvent; + +const int HEADER_MAX_ITEM_COUNT_WITH_BUTTON = 3; +const int HEADER_BUTTON_MAX_COUNT = 2; +const int HEADER_ITEM_MAX_COUNT = 4; +const int HEADER_MAX_WAITING_ANIMATION_POSITION = 3; +const int HEADER_TITLE_BUTTON_STYLE_MAX_ITEM_COUNT = 1; +const int HEADER_TAB_STYLE_MAX_ITEM_COUNT = 15; +const int HEADER_ACTION_ID_MIN = 0; +const int HEADER_ACTION_ID_MAX = INT_MAX; +const int HEADER_NUMBERD_BADGE_ICON_NUMBER_MAX = 99999; +const int HEADER_MORE_BUTTON_ACTION_ID = 500; + +class _HeaderImpl + : public _ControlImpl + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + static _HeaderImpl* CreateHeaderImplN(Header* pControl); + + _HeaderImpl(Header* pPublic, _Toolbar* pCore); + + virtual ~_HeaderImpl(void); + + Header* GetHeader(void) const; + + virtual const char* GetPublicClassName(void) const; + + virtual const Header& GetPublic(void) const; + + virtual Header& GetPublic(void); + + virtual const _Toolbar& GetCore(void) const; + + virtual _Toolbar& GetCore(void); + + static const _HeaderImpl* GetInstance(const Header& header); + + static _HeaderImpl* GetInstance(Header& header); + + result AddItem(const HeaderItem& item); + + ButtonItemStatus GetButtonStatus(ButtonPosition position) const; + + Tizen::Graphics::Color GetButtonColor(ButtonItemStatus status) const; + + Tizen::Graphics::Color GetButtonTextColor(ButtonItemStatus status) const; + + Tizen::Base::String GetDescriptionText(void) const; + + Tizen::Graphics::Color GetDescriptionTextColor(void) const; + + Tizen::Graphics::Color GetItemColor(HeaderItemStatus status) const; + + int GetItemCount(void) const; + + result GetItemStatus(int itemIndex, HeaderItemStatus& status) const; + + Tizen::Graphics::Color GetItemTextColor(HeaderItemStatus status) const; + + HeaderStyle GetStyle(void) const; + + int GetSelectedItemIndex(void) const; + + Tizen::Base::String GetTitleText(void) const; + + Tizen::Graphics::Color GetTitleTextColor(void) const; + + Tizen::Graphics::Color GetColor(void) const; + + AnimationStatus GetWaitingAnimationStatus(HeaderAnimationPosition animationPos) const; + + result InsertItemAt(int itemIndex, const HeaderItem& item); + + bool IsButtonSet(ButtonPosition position) const; + + result PauseWaitingAnimation(HeaderAnimationPosition animationPos); + + result PlayWaitingAnimation(HeaderAnimationPosition animationPos); + + result RemoveAllButtons(void); + + result RemoveAllItems(void); + + result RemoveItemAt(int itemIndex); + + result RemoveButtonAt(ButtonPosition position); + + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + result SetButton(ButtonPosition position, const ButtonItem& button); + + result SetButtonColor(ButtonItemStatus status, const Tizen::Graphics::Color& color); + + result SetButtonEnabled(ButtonPosition position, bool enable); + + result SetButtonTextColor(ButtonItemStatus status, const Tizen::Graphics::Color& color); + + result SetButtonBadgeIcon(ButtonPosition position, const Tizen::Graphics::Bitmap* pBadgeIcon); + + result SetButtonNumberedBadgeIcon(ButtonPosition position, int number); + + result SetItemAt(int itemIndex, const HeaderItem& item); + + result SetItemBadgeIcon(int itemIndex, const Tizen::Graphics::Bitmap* pBadgeIcon); + + result SetItemNumberedBadgeIcon(int itemIndex, int number); + + result SetItemColor(HeaderItemStatus status, const Tizen::Graphics::Color& color); + + result SetItemEnabled(int itemIndex, bool enable); + + result SetItemTextColor(HeaderItemStatus status, const Tizen::Graphics::Color& color); + + result SetItemSelected(int itemIndex); + + result SetColor(const Tizen::Graphics::Color& color); + + result SetStyle(HeaderStyle style); + + result SetTitleIcon(const Tizen::Graphics::Bitmap* pIcon); + + result SetTitleText(const Tizen::Base::String& text); + + result SetTitleTextColor(const Tizen::Graphics::Color& color); + + result SetTransparent(bool transparent); + + result SetDescriptionText(const Tizen::Base::String& text); + + result SetDescriptionTextColor(const Tizen::Graphics::Color& color); + + result StopWaitingAnimation(HeaderAnimationPosition animationPos); + + bool IsTabEditModeEnabled(void) const; + + result SetTabEditModeEnabled(bool enable); + + result SetBackButton(void); + + bool IsBackButtonSet(void) const; + + void RemoveBackButton(void); + + result SetBackButtonEnabled(bool enable); + + ButtonItemStatus GetBackButtonStatus(void) const; + + Tizen::Graphics::Rectangle GetButtonBounds(ButtonPosition position) const; + + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + + +private: + result CheckItemValidate(const HeaderItem& item); + + ToolbarStyle ConvertHeaderStyle(HeaderStyle style); + + _Button* ConvertButtonItem(const ButtonItem& buttonItem); + + _Button* ConvertHeaderItem(const HeaderItem& headerItem); + + ButtonItemStatus ConvertButtonItemStatus(_ButtonStatus status) const; + + HeaderItemStatus ConvertHeaderItemStatus(_ButtonStatus status) const; + + _ButtonStatus ConvertButtonStatus(ButtonItemStatus status) const; + + _ButtonStatus ConvertButtonStatus(HeaderItemStatus status) const; + + _HeaderImpl(const _HeaderImpl&); + + _HeaderImpl& operator =(const _HeaderImpl&); + + +private: + HeaderStyle __style; + + _PublicActionEvent* __pPublicActionEvent; + + //bool __calledBySetItemSelected; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_HEADER_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_HeaderItemImpl.h b/src/ui/inc/FUiCtrl_HeaderItemImpl.h new file mode 100644 index 0000000..4491bd2 --- /dev/null +++ b/src/ui/inc/FUiCtrl_HeaderItemImpl.h @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_HeaderItemImpl.h + * @brief This is the header file for the %_HeaderItemImpl class. + * + * This header file contains the declarations of the %_HeaderItemImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_HEADER_ITEM_IMPL_H_ +#define _FUI_CTRL_INTERNAL_HEADER_ITEM_IMPL_H_ + +#include +#include + + +namespace Tizen { namespace Ui { namespace Controls +{ + +static const int HEADER_ITEM_ACTION_ID_MIN = 0; +static const int HEADER_ITEM_ACTION_ID_MAX = INT_MAX; +static const int HEADER_ITEM_MAX_STATE_COUNT = 5; + +class _HeaderItemImpl + : public Tizen::Base::Object +{ +public: + _HeaderItemImpl(HeaderItem* pPublic); + + virtual ~_HeaderItemImpl(void); + + static const _HeaderItemImpl* GetInstance(const HeaderItem& headerItem); + + static _HeaderItemImpl* GetInstance(HeaderItem& headerItem); + + result Construct(int actionId); + + int GetActionId(void) const; + + const Tizen::Graphics::Bitmap* GetBackgroundBitmap(HeaderItemStatus status) const; + + const Tizen::Graphics::Bitmap* GetIcon(HeaderItemStatus status) const; + + Tizen::Base::String GetText(void) const; + + result SetActionId(int actionId); + + result SetBackgroundBitmap(HeaderItemStatus status, const Tizen::Graphics::Bitmap* pBitmap); + + result SetIcon(HeaderItemStatus status, const Tizen::Graphics::Bitmap* pIcon); + + result SetText(const Tizen::Base::String& text); + + +private: + _HeaderItemImpl(const _HeaderItemImpl& headerItem); + + _HeaderItemImpl& operator =(const _HeaderItemImpl& headerItem); + + +private: + int __actionId; + Tizen::Base::String __itemText; + const Tizen::Graphics::Bitmap* __pIconBitmap[HEADER_ITEM_MAX_STATE_COUNT]; + const Tizen::Graphics::Bitmap* __pHeaderItemBackgroundBitmap[HEADER_ITEM_MAX_STATE_COUNT]; + + friend class _HeaderImpl; + +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_HEADER_ITEM_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_IActionEventListener.h b/src/ui/inc/FUiCtrl_IActionEventListener.h new file mode 100644 index 0000000..5c4515b --- /dev/null +++ b/src/ui/inc/FUiCtrl_IActionEventListener.h @@ -0,0 +1,72 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IActionEventListener.h + * @brief This is the header file for the _IActionEventListener class. + * + * This header file contains the declarations of the _IActionEventListener class. @n + * If an action event is generated, a method of this class is called. + * So, if the application does some jobs related to the action event, use the methods of this class. + * + */ +#ifndef _FUI_CTRL_INTERNAL_IACTION_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IACTION_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +} } // Tizen::Ui + +namespace Tizen {namespace Ui { namespace Controls +{ +/** + * @interface _IActionEventListener + * @brief This interface implements the listener for _action event. + * @since 1.0 + * + * The listener interface for receiving the action events. The class that processes an action event + * implements this interface, and the object created with that class is registered with a _control, using the _control's + * AddActionEventListener() method. When the action event occurs, the OnActionPerformed() method of that object is invoked. + */ +class _IActionEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is the destructor for this class. + * + * @since 1.0 + */ + virtual ~_IActionEventListener(void) {} + + /** + * Notifies when an action event occurs. + * + * @since 1.0 + * @param[in] source The source of the event + * @param[in] actionId The information about the action event + */ + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId) = 0; + +}; // _IActionEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IACTION_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IAdjustmentEventListener.h b/src/ui/inc/FUiCtrl_IAdjustmentEventListener.h new file mode 100644 index 0000000..5a0658a --- /dev/null +++ b/src/ui/inc/FUiCtrl_IAdjustmentEventListener.h @@ -0,0 +1,74 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IAdjustmentEventListener.h + * @brief This is the header file for the _IAdjustmentEventListener class. + * + * This header file contains the declarations of the _IAdjustmentEventListener class. + * If a change event is generated, a method of this class is called. + * So, if applications do jobs related to change events, use the methods of this class. + * + */ +#ifndef _FUI_CTRL_INTERNAL_IADJUSTMENT_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IADJUSTMENT_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @interface _IAdjustmentEventListener + * @brief This interface implements the listener for adjustment events. + * @since 1.0 + * + * The _IAdjustmentEventListener interface receives adjustment events which are fired when the knob of a Slider moves. The class that is + * interested in processing an adjustment event implements this interface, and the object created with that class + * is registered with a UI control, using the control's AddAdjustmentEventListener() method. When adjustment event occurs, + * the object's OnAdjustmentValueChanged() method is invoked. + */ +class _IAdjustmentEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 1.0 + */ + virtual ~_IAdjustmentEventListener(void) {} + + /** + * Notifies when a change event occurs. + * + * @since 1.0 + * @param[in] source The source of the event + * @param[in] adjustment The adjustment value + */ + virtual void OnAdjustmentValueChanged(const Tizen::Ui::_Control& source, int adjustment) = 0; + +}; // _IAdjustmentEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IADJUSTMENT_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IAnimationEventListener.h b/src/ui/inc/FUiCtrl_IAnimationEventListener.h new file mode 100644 index 0000000..a2ddadc --- /dev/null +++ b/src/ui/inc/FUiCtrl_IAnimationEventListener.h @@ -0,0 +1,71 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IAnimationEventListener.h + * @brief This is the header file for the _IAnimationEventListener class. + * + * This header file contains the declarations of the _IAnimationEventListener class. @n + * If an animation event is generated, a method of this class is called. + * So, if the application does some jobs related to the animation event, use the methods of this class. + * + */ +#ifndef _FUI_CTRL_INTERNAL_IANIMATION_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IANIMATION_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen {namespace Ui { namespace Controls +{ +/** + * @interface _IAnimationEventListener + * @brief This interface implements the listener for animation event. + * @since 2.0 + * + * The listener interface for receiving the animation events. The class that processes an animation event + * implements this interface, and the object created with that class is registered with a _control, using the _control's + * AddAnimationEventListener() method. When the animation event occurs, the OnAnimationStopped() method of that object is invoked. + */ +class _IAnimationEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is the destructor for this class. + * + * @since 1.0 + */ + virtual ~_IAnimationEventListener(void) {} + + /** + * Notifies when an animation event occurs. + * + * @since 1.0 + * @param[in] source The source of the event + */ + virtual void OnAnimationStopped(const Tizen::Ui::_Control& source) = 0; + +}; // _IAnimationEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IANIMATION_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IColorChangeEventListener.h b/src/ui/inc/FUiCtrl_IColorChangeEventListener.h new file mode 100644 index 0000000..e4e09db --- /dev/null +++ b/src/ui/inc/FUiCtrl_IColorChangeEventListener.h @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IColorChangeEventListener.h + * @brief This is the header file for the _IColorChangeEventListener class. + * + * This header file contains the declarations of the _IColorChangeEventListener class. + * If a change event is generated, a method of this class is called. + * So, if applications do jobs related to change events, use the methods of this class. + * + */ +#ifndef _FUI_CTRL_INTERNAL_ICOLOR_CHANGE_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_ICOLOR_CHANGE_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Graphics +{ +class Color; +}} // Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @interface _IColorChangeEventListener + * @brief This interface implements the listener for color change events. + * @since 2.0 + * + * This is the listener interface for receiving color change events. The class that processes a color change event + * implements this interface, and the object created with that class is registered with a UI control, using the control's + * AddColorChangeEventListener() method. When the color change event occurs, the object's OnColorChanged() method is invoked. + */ +class _IColorChangeEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 1.0 + */ + virtual ~_IColorChangeEventListener(void) {} + + /** + * Notifies when there is a change in Color. The color instance is passed as an input parameter. + * + * @since 1.0 + * @param[in] source The source of the event + * @param[in] color The color + */ + virtual void OnColorChanged(const Tizen::Ui::_Control& source, const Tizen::Graphics::Color& color) = 0; +}; // _IColorChangeEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ICOLOR_CHANGE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IContextMenuPresenter.h b/src/ui/inc/FUiCtrl_IContextMenuPresenter.h new file mode 100644 index 0000000..5ccc9dd --- /dev/null +++ b/src/ui/inc/FUiCtrl_IContextMenuPresenter.h @@ -0,0 +1,104 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IContextMenuPresenter.h + * @brief This is the header file for the _ContextMenuListPresenter class. + * + * This header file contains the declarations of the %_ContextMenuListPresenter class. + */ +#ifndef _FUI_CTRL_INTERNAL_ICONTEXTMENU_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_ICONTEXTMENU_PRESENTER_H_ + +#include +#include +#include +#include +#include +#include "FUi_Control.h" +#include "FUiCtrl_ContextMenu.h" +#include "FUiAnim_VisualElement.h" + +namespace Tizen { namespace Ui +{ +namespace Controls +{ + +class _ContextMenu; +class _ListItem; +class _ContextMenuItem; + +struct _ContextMenuItemInfo +{ + bool bListItem; + _ListItem* pListItem; + _ContextMenuItem* pContextMenuItem; +}; + +/** + * @class _IContextMenuPresenter + * @brief + * @since 2.0 + * + * + * + * + */ +class _IContextMenuPresenter +{ +// Lifecycle +public: + virtual ~_IContextMenuPresenter(void) {} + +// Operation +public: + virtual result Install(void) = 0; + virtual result Draw(void) = 0; + virtual result DrawBackground(Tizen::Graphics::Canvas* pCanvas) = 0; + virtual result DrawArrow(Tizen::Graphics::Canvas* pCanvas) = 0; + virtual result AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap) = 0; + virtual result InsertItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap) = 0; + virtual result SetItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap) = 0; + virtual result DeleteItem(int index) = 0; + virtual result DeleteItemAll(void) = 0; + virtual int CalculateShowItemCount(void) = 0; + virtual result CalculateWindowRect(void) = 0; + virtual result ApplyColorProperty(void) = 0; + + virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo) = 0; + virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo) = 0; + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) = 0; + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) = 0; + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) = 0; + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) = 0; + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) = 0; + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont) = 0; + virtual void OnFontInfoRequested(unsigned long& style, int& size) =0; + + virtual void SetAllAccessibilityElement(void) = 0; + + virtual _ContextMenuItemInfo GetItemFromPosition(const Tizen::Graphics::Point& position) = 0; + virtual _ContextMenuItemInfo FindItem(int index) = 0; + virtual result SetTopDrawnItemIndex(int index) = 0; + virtual result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap) = 0; +}; //_IContextMenuPresenter + +} // Control +}} // Tizen::Ui + +#endif //_FUI_CTRL_INTERNAL_ICONTEXTMENU_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_ICustomElement.h b/src/ui/inc/FUiCtrl_ICustomElement.h new file mode 100644 index 0000000..3ea922d --- /dev/null +++ b/src/ui/inc/FUiCtrl_ICustomElement.h @@ -0,0 +1,44 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ICustomElement.h + * @brief This is the header file for the _ICustomElement Interface. + * + * This header file contains the declarations of the _ICustomElement Interface. + */ + +#ifndef _FUI_CTRL_INTERNAL_ICUSTOM_ELEMENT_H +#define _FUI_CTRL_INTERNAL_ICUSTOM_ELEMENT_H + +#include +#include "FUiCtrl_ListViewTypes.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ICustomElement +{ +public: + virtual ~_ICustomElement(void) {} + + virtual bool DrawElement(Tizen::Graphics::Canvas* pCanvas, Tizen::Graphics::Rectangle& rect, ListViewItemDrawingStatus status) = 0; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ICUSTOM_ELEMENT_H diff --git a/src/ui/inc/FUiCtrl_IDateTimeChangeEventListener.h b/src/ui/inc/FUiCtrl_IDateTimeChangeEventListener.h new file mode 100644 index 0000000..96e6643 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IDateTimeChangeEventListener.h @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IDateTimeChangeEventListener.h + * @brief This is the header file for the _IDateTimeChangeEventListener interface. + */ + +#ifndef _FUI_CTRL_INTERNAL_IDATETIME_CHANGE_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IDATETIME_CHANGE_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen {namespace Ui { namespace Controls +{ + +/** + * @interface _IDateTimeChangeEventListener + * @brief This interface implements the listener for Date and Time change events. + * @since 1.0 + * + * The listener interface for receiving date and time change events. The class that processes date and time change event + * implements this interface, and the object created with that class is registered with a UI control, using the control's + * AddDateTimeChangeEventListener() method. When the action event occurs, that instance's OnDateTimeChanged() method is invoked. + */ +class _IDateTimeChangeEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 1.0 + */ + virtual ~_IDateTimeChangeEventListener(void) {} + + /** + * Notifies when there is a change in DateTime . The changed values of day, month, year, hour and minute are passed as input parameters. + * + * @since 1.0 + * @param[in] source The source of the event + * @param[in] year The year value + * @param[in] month The month value + * @param[in] day The day value + * @param[in] hour The hour value + * @param[in] minute The minute value + * + */ + virtual void OnDateTimeChanged(const Tizen::Ui::_Control& source, int year, int month, int day, int hour, int minute) = 0; + + + /** + * Notifies when date and time change is canceled. + * + * @since 1.0 + * @param[in] source The source of the event + */ + virtual void OnDateTimeChangeCanceled(const Tizen::Ui::_Control& source) = 0; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IDATETIME_CHANGE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IEditCopyPasteEventListener.h b/src/ui/inc/FUiCtrl_IEditCopyPasteEventListener.h new file mode 100644 index 0000000..5878897 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IEditCopyPasteEventListener.h @@ -0,0 +1,76 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IEditCopyPasteEventListener.h + * @brief This is the header file for the _IEditCopyPasteEventListener class. + * + * This header file contains the declarations of the %_IEditCopyPasteEventListener class. + */ + +#ifndef _FUI_CTRL_INTERNAL_IEDIT_COPY_PASTE_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IEDIT_COPY_PASTE_EVENT_LISTENER_H_ + +// includes +#include + +// namespace declaration +namespace Tizen { namespace Ui { namespace Controls +{ + +enum CoreCopyPasteStatus +{ + CORE_COPY_PASTE_STATUS_HIDE = 0, + CORE_COPY_PASTE_STATUS_SHOW, + CORE_COPY_PASTE_STATUS_MAX +}; + +enum CoreCopyPasteAction +{ + CORE_COPY_PASTE_ACTION_SELECT = 0, + CORE_COPY_PASTE_ACTION_SELECT_ALL, + CORE_COPY_PASTE_ACTION_COPY, + CORE_COPY_PASTE_ACTION_CUT, + CORE_COPY_PASTE_ACTION_PASTE +}; + +/** + * @interface _IEditCopyPasteEventListener + * @brief This interface implements the listener for CopyPaste events. + * @since 2.0 + * + * The _IEditCopyPasteEventListener interface enables the implementer to receive the + * CopyPaste related events. + */ +class _IEditCopyPasteEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This is the destructor for this class. + * @since 2.0 + */ + virtual ~_IEditCopyPasteEventListener(void) {} + +public: + + virtual void OnEditCopyPasteStatusChanged(Tizen::Ui::Controls::CoreCopyPasteStatus status, Tizen::Ui::Controls::CoreCopyPasteAction action) = 0; +}; // _IEditCopyPasteEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IEDIT_COPY_PASTE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IExpandableEditAreaEventListener.h b/src/ui/inc/FUiCtrl_IExpandableEditAreaEventListener.h new file mode 100644 index 0000000..484355b --- /dev/null +++ b/src/ui/inc/FUiCtrl_IExpandableEditAreaEventListener.h @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IExpandableEditAreaEventListener.h + * @brief This is the header file for the _IExpandableEditAreaEventListener class. + * + * This header file contains the declarations of the _IExpandableEditAreaEventListener class. @n + * If an action event is generated, a method of this class is called. + * So, if the application does some jobs related to the action event, use the methods of this class. + * + */ +#ifndef _FUICTRL_INTERNAL_IEXPANDABLE_EDITAREA_EVENT_LISTENER_H_ +#define _FUICTRL_INTERNAL_IEXPANDABLE_EDITAREA_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @interface _IExpandableEditAreaEventListener + * @brief This interface implements the listener for _kmjaction event. + * @since 2.0 + * + * The interface provides a listener to receive events related to ExpandableEditArea. + * + */ +class _IExpandableEditAreaEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ + +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 1.0 + */ + virtual ~_IExpandableEditAreaEventListener(void) {} + +public: + /** + * Notifies the application that a new line is added to ExpandableEditArea. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] newLineCount The new line count + */ + virtual void OnExpandableEditAreaLineAdded(const Tizen::Ui::_Control& source, int newLineCount) = 0; + + /** + * Notifies the application that a line is removed from ExpandableEditArea. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] newLineCount The new line count + */ + virtual void OnExpandableEditAreaLineRemoved(const Tizen::Ui::_Control& source, int newLineCount) = 0; +}; // _IExpandableEditAreaEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_IEXPANDABLE_EDITAREA_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IFastScrollListener.h b/src/ui/inc/FUiCtrl_IFastScrollListener.h new file mode 100644 index 0000000..497e0d8 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IFastScrollListener.h @@ -0,0 +1,89 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IFastScrollListener.h + * @brief This is the header file for _IUiFastScrollListener class. + * + * This header file contains declarations of IFastScrollListener class. + * If item event is generated, a method of this class will be called. + * Applications that do some jobs related to item event, they call methods of this class. + * + */ +#ifndef _FUICTRL_INTERNAL_IFASTSCROLL_LISTENER_H_ +#define _FUICTRL_INTERNAL_IFASTSCROLL_LISTENER_H_ + +// Includes +#include +#include +#include "FUiCtrl_FastScrollIndex.h" + +namespace Tizen { namespace Ui +{ +class _Control; +} } + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @interface IFastScrollListener + * @brief This interface implements the listener for fast scroll event. + * @since 2.0 + * + * IFastScrollListerer is an interface which implements a listener for receiving fast scroll events. + * The class that is interested in processing a fast scroll implements this interface, + * and the object created with that class is registered with a UI control, using the control's + * AddFastScrollListener method. When the item event occurs, that object's OnFastScrollIndexChanged method is invoked. + */ +class _IUiFastScrollListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * @since 2.0 + */ + virtual ~_IUiFastScrollListener(void) {} + + /** + * Notifies when an index is selected. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] index The index + * @remark When the search icon index is enabled, you can check whether the search icon index is touched by comparing @c index @n + * with the string constant FAST_SCROLL_SEARCH_ICON_INDEX_STRING. + * + */ + virtual void OnUiFastScrollIndexSelected(Tizen::Ui::_Control& source, Tizen::Ui::Controls::_FastScrollIndex& index) = 0; + +protected: + // reserved virtual methods for later extension + /* + Following methods are reserved and may change its name at any time without prior notice. + */ + virtual void _IUiFastScrollListener_Reserved1(void) {} + virtual void _IUiFastScrollListener_Reserved2(void) {} + virtual void _IUiFastScrollListener_Reserved3(void) {} +}; + +}; +}; +}; + +#endif diff --git a/src/ui/inc/FUiCtrl_IFormActivationChangeEventListener.h b/src/ui/inc/FUiCtrl_IFormActivationChangeEventListener.h new file mode 100644 index 0000000..a5dfac2 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IFormActivationChangeEventListener.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IFormActivationChangeEventListener.h + * @brief This is the header file for the _IFormActivationChangeEventListener class. + * + * This header file contains the declarations of the _IFormActivationChangeEventListener class. @n + * If a Form activation is changed, a method of this class is called. @n + * So, if an application needs to perform some jobs related to the form event, + * provide the implementation of the methods declared in this interface. + */ +#ifndef _FUI_CTRL_INTERNAL_IFORM_ACTIVATION_CHANGE_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IFORM_ACTIVATION_CHANGE_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class _FormImpl; + +/** + * @interface _IFormActivationChangeEventListener + * @brief This interface implements the listener for the form activation chage event. + * @since 1.0 + * + * The listener interface for receiving form activation chage event. + * + */ +class _IFormActivationChangeEventListener + : public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is internal. If used in an application, the application can get rejected during the certification process. + * This is the virtual destructor for this class. + * + * @since 1.0 + */ + virtual ~_IFormActivationChangeEventListener(void) {} + + virtual void OnFormActivated(const Tizen::Ui::Controls::_Form& source) = 0; + virtual void OnFormDeactivated(const Tizen::Ui::Controls::_Form& source) = 0; + +}; // _IFormActivationChangeEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IFORM_ACTIVATION_CHANGE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IFormBackEventListener.h b/src/ui/inc/FUiCtrl_IFormBackEventListener.h new file mode 100644 index 0000000..2beec3a --- /dev/null +++ b/src/ui/inc/FUiCtrl_IFormBackEventListener.h @@ -0,0 +1,105 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IFormBackEventListener.h + * @brief This is the header file for the _IFormBackEventListener interface. + * + * This header file contains the declarations of the _IFormBackEventListener interface. + */ +#ifndef _FUI_CTRL_INTERNAL_IFORM_BACK_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IFORM_BACK_EVENT_LISTENER_H_ + +// includes +#include + +// namespace declaration +namespace Tizen { namespace Ui { namespace Controls +{ + +class _Form; + +/** + * @interface _IFormBackEventListener + * @brief This interface implements the listener for Form related events. + * @since 2.0 + * + * The %_IFormBackEventListener interface is the listener interface for receiving Form-related back button events. + * + * For more information on the class features, see Form. + */ +class _IFormBackEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This is the destructor for this class. + * @since 2.0 + */ + virtual ~_IFormBackEventListener(void) {} + +// Operation +public: + /** + * Called when the current %Form control needs to be closed to revert back to the previous %Form control. + * + * @since 2.0 + * @param[in] source The source of the event + * @remarks This event is fired when the user clicks on the software 'back' button on the Footer control, or the hardware back button on the + * device. + */ + virtual void OnFormBackRequested(Tizen::Ui::Controls::_Form& source) = 0; + +// Reserves +protected: + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void _IFormBackEventListener_Reserved1(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void _IFormBackEventListener_Reserved2(void) { } + + // + //This method is for internal use only. Using this method can cause behavioral, security-related, + //and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.0 + // + virtual void _IFormBackEventListener_Reserved3(void) { } +}; // _IFormBackEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IFORM_BACK_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IFrameEventListener.h b/src/ui/inc/FUiCtrl_IFrameEventListener.h new file mode 100644 index 0000000..9d3f91f --- /dev/null +++ b/src/ui/inc/FUiCtrl_IFrameEventListener.h @@ -0,0 +1,62 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IFrameEventListener.h + * @brief This is the header file for the _IFrameEventListener class. + * + * This header file contains the declarations of the _IFrameEventListener class. @n + * If a frame lifecycle event is generated, a method of this class is called. @n + * So, if an application needs to perform some jobs related to the frame event, + * provide the implementation of the methods declared in this interface. + */ +#ifndef _FUI_CTRL_INTERNAL_IFRAME_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IFRAME_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Frame; + +/** + * @interface _IFrameEventListener + * @brief This interface implements the listener for the frame lifecycle event. + * @since 1.0 + * + * The listener interface for receiving frame lifecycle events. + * + */ +class _IFrameEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 1.0 + */ + virtual ~_IFrameEventListener(void) {} + + virtual void OnFrameActivated(const Tizen::Ui::Controls::_Frame& source) = 0; + virtual void OnFrameDeactivated(const Tizen::Ui::Controls::_Frame& source) = 0; + +}; // _IFrameEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IFRAME_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IGalleryCoreEventListener.h b/src/ui/inc/FUiCtrl_IGalleryCoreEventListener.h new file mode 100644 index 0000000..277b444 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IGalleryCoreEventListener.h @@ -0,0 +1,40 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_IGALLERY_CORE_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IGALLERY_CORE_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryItem; + +class _IGalleryCoreEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + virtual ~_IGalleryCoreEventListener(void) {} + + virtual void OnCurrentItemChanged(int currentIndex) = 0; + virtual void OnItemClicked(int itemIndex) = 0; + virtual void OnSlideShowStarted(void) = 0; + virtual void OnSlideShowStopped(void) = 0; +}; // _IGalleryCoreEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IGALLERY_CORE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IGalleryItemProvider.h b/src/ui/inc/FUiCtrl_IGalleryItemProvider.h new file mode 100644 index 0000000..c3211d1 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IGalleryItemProvider.h @@ -0,0 +1,36 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_IGALLERY_ITEM_PROVIDER_H_ +#define _FUI_CTRL_INTERNAL_IGALLERY_ITEM_PROVIDER_H_ + +namespace Tizen { namespace Ui { namespace Controls { + +class _GalleryItem; + +class _IGalleryItemProvider +{ +public: + virtual ~_IGalleryItemProvider(void) {} + virtual _GalleryItem* CreateItem(int index) = 0; + virtual bool DeleteItem(int index, _GalleryItem* pItem) = 0; + virtual bool UnloadItem(int index, _GalleryItem* pItem) = 0; + virtual int GetItemCount(void) const = 0; +}; // _IGalleryItemProvider + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_IGALLERY_ITEM_PROVIDER_H_ diff --git a/src/ui/inc/FUiCtrl_IGalleryRenderer.h b/src/ui/inc/FUiCtrl_IGalleryRenderer.h new file mode 100644 index 0000000..f78c488 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IGalleryRenderer.h @@ -0,0 +1,78 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_IGALLERY_RENDERER_H_ +#define _FUI_CTRL_INTERNAL_IGALLERY_RENDERER_H_ + +#include +#include +#include "FUiCtrl_GalleryTypes.h" + +namespace Tizen { namespace Ui { namespace Controls { + +enum _GalleryTransitionType +{ + GALLERY_TRANSITION_DISSOLVE = 0, + GALLERY_TRANSITION_ZOOM, + GALLERY_TRANSITION_PAGE +}; + +class _GalleryBitmap; +class _IGalleryRendererNotiListener; + +class _IGalleryRenderer +{ +public: + virtual ~_IGalleryRenderer(void) {} + + virtual result AddNotiListener(const _IGalleryRendererNotiListener& notiListener) = 0; + virtual result RemoveNotiListener(const _IGalleryRendererNotiListener& notiListener) = 0; + virtual result SetCanvasMaxCount(int maxCount) = 0; + virtual int GetCanvasMaxCount(void) const = 0; + virtual result SetCanvasVisibility(int canvasIndex, bool visibility) = 0; + virtual result SetCanvasShowState(int canvasIndex, bool showState) = 0; + virtual bool IsCanvasVisibility(int canvasIndex) const = 0; + virtual Tizen::Graphics::Rectangle GetViewRect(void) const = 0; + virtual result SetEmptyImage(const _GalleryBitmap* pImage) = 0; + virtual result SetEmptyText(const Tizen::Base::String& pText) = 0; + virtual result EnableEmptyView(void) = 0; + virtual result DisableEmptyView(void) = 0; + virtual result SetCanvasImage(int canvasIndex, const _GalleryBitmap* pImage + , _GalleryVerticalAlignment imageVerticalAlignment, _GalleryHorizontalAlignment imageHorizontalAlignment + , _GalleryFittingType fittingType) = 0; + virtual result SetCanvasBounds(int canvasIndex, const Tizen::Graphics::Rectangle& bounds, + const _GalleryAnimationTiming* pAnimation = null) = 0; + virtual Tizen::Graphics::Rectangle GetCanvasBounds(int canvasIndex) const = 0; + virtual Tizen::Graphics::Rectangle GetCanvasAlignBoundary(int canvasIndex) const = 0; + virtual result SetCanvasImageBounds(int canvasIndex, const Tizen::Graphics::Rectangle& bounds) = 0; + virtual Tizen::Graphics::Rectangle GetCanvasImageBounds(int canvasIndex) const = 0; + virtual result RunCanvasTransition(int startCanvasIndex, int endCanvasIndex, _GalleryTransitionType transition, + const _GalleryAnimationTiming* pAnimation = null) = 0; + virtual void StopAllCanvasAnimation(void) = 0; + virtual bool IsRunningCanvasTransition(void) const = 0; + virtual bool IsRunningCanvasAnimation(void) const = 0; + virtual bool IsExposed(void) const = 0; + virtual result RefreshView(void) = 0; + virtual result ReleaseAllCanvasResource(void) = 0; + virtual result ResetAllCanvas(void) = 0; + virtual result InitializeCanvasBounds(void) = 0; + virtual result Draw(void) = 0; + virtual void GalleryBoundsChanged(int currentCanvasIndex) = 0; +}; // _IGalleryRenderer + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_IGALLERY_RENDERER_H_ diff --git a/src/ui/inc/FUiCtrl_IGalleryRendererNotiListener.h b/src/ui/inc/FUiCtrl_IGalleryRendererNotiListener.h new file mode 100644 index 0000000..1eea55a --- /dev/null +++ b/src/ui/inc/FUiCtrl_IGalleryRendererNotiListener.h @@ -0,0 +1,39 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_IGALLERY_RENDERER_NOTI_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IGALLERY_RENDERER_NOTI_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls { + +class _IGalleryRendererNotiListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + virtual ~_IGalleryRendererNotiListener(void) {} + + virtual void OnTransitionCancel(void) = 0; + virtual void OnTransitionCompleted(void) = 0; + virtual void OnCanvasAnimationCancel(void) = 0; + virtual void OnCanvasAnimationCompleted(void) = 0; + virtual void OnCanvasAnimationStarted(void) = 0; +}; // _IGalleryRendererNotiListener + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_IGALLERY_RENDERER_NOTI_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IIconListItemEventListener.h b/src/ui/inc/FUiCtrl_IIconListItemEventListener.h new file mode 100644 index 0000000..05f69eb --- /dev/null +++ b/src/ui/inc/FUiCtrl_IIconListItemEventListener.h @@ -0,0 +1,66 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IIconListItemEventListener.h + * @brief This is the header file for the _IIconListItemEventListener class. + * + * This header file contains the declarations of the _IIconListItemEventListener class. @n + * If an item event is generated, a method of this class is called. @n + * So, if an application does some jobs related to the item event, use the methods of this class. + */ + +#ifndef _FUI_CTRL_INTERNAL_IICONLISTITEM_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IICONLISTITEM_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IconListViewItemEventArg; + +/** + * @interface _IIconListItemEventListener + * @brief This interface implements the listener for the item event. + * @since 2.0 + * + * The listener interface for receiving item events. The class that processes an item event + * implements this interface, and the instance created with that class is registered with a UI control, using the control's + * AddIIconListViewItemEventListener() method. When the item event occurs, the OnItemStateChanged() method of that instance is invoked. + */ +class _IIconListItemEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_IIconListItemEventListener(void) {} + + virtual void OnIconListItemStateChanged(_IconListViewItemEventArg* pArg) = 0; + + virtual void OnIconListViewOverlayBitmapSelected(_IconListViewItemEventArg* pArg) {} + + virtual void OnIconListViewItemReordered(_IconListViewItemEventArg* pArg) {} +}; //_IIconListItemEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IICONLISTITEM_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IInputPadEventListener.h b/src/ui/inc/FUiCtrl_IInputPadEventListener.h new file mode 100644 index 0000000..3bd4c0f --- /dev/null +++ b/src/ui/inc/FUiCtrl_IInputPadEventListener.h @@ -0,0 +1,76 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IInputPadEventListener.h + * @brief This is the header file for the _IInputPadEventListener class. + * + * This header file contains the declarations of the _IInputPadEventListener class. + * If a change event is generated, a method of this class is called. + * Applications that do jobs related to change events call the methods of this class. + * + */ + +#ifndef _FUI_CTRL_INTERNAL_IINPUTPAD_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IINPUTPAD_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +} } + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @interface IInputPadEventListener + * @brief This interface implements a listener for InputPadPanel events. + * @since 2.0 + * + * The interface implements a listener for receiving changes to the Control's the behavior of the InputPad. + * The class that displays and controls InputPad implements this interface, and the instance created with + * that class is registered with a UI control, using the control's AddInputPadEventListener() method. + */ +class _IInputPadEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + * + */ + virtual ~_IInputPadEventListener(void) {} + + /** + * Notifies when the InputPad reached on one of top, bottom, left or right end + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] inputPadReturnValue The return value + */ + virtual void OnInputPadValueChanged(const Tizen::Ui::_Control& source, int inputPadReturnValue) = 0; +}; // _IInputPadEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IINPUTPAD_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IKeypadEventListener.h b/src/ui/inc/FUiCtrl_IKeypadEventListener.h new file mode 100644 index 0000000..6c6f85b --- /dev/null +++ b/src/ui/inc/FUiCtrl_IKeypadEventListener.h @@ -0,0 +1,135 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IKeypadEventListener.h + * @brief This is the header file for the _IKeypadEventListener interface. + * + * This header file contains the declarations of the _IKeypadEventListener interface. + */ +#ifndef _FUI_CTRL_INTERNAL_IKEYPAD_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IKEYPAD_EVENT_LISTENER_H_ + +// includes +#include +#include + +namespace Tizen { namespace Graphics +{ +class Dimension; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +// namespace declaration +namespace Tizen { namespace Ui { namespace Controls +{ + +enum CoreKeypadAction +{ + CORE_KEYPAD_ACTION_ENTER, /**< The enter key */ + CORE_KEYPAD_ACTION_GO, /**< The Go key */ + CORE_KEYPAD_ACTION_NEXT, /**< The Next key */ + CORE_KEYPAD_ACTION_SEND, /**< The Send key */ + CORE_KEYPAD_ACTION_SEARCH, /**< The Search key */ + CORE_KEYPAD_ACTION_LOGIN, /**< The Login key */ + CORE_KEYPAD_ACTION_SIGN_IN, /**< The Sign-In key */ + CORE_KEYPAD_ACTION_JOIN, /**< The Join key */ + CORE_KEYPAD_ACTION_DONE /**< The Done key */ +}; +/** + * @interface _IKeypadEventListener + * @brief This interface implements the listener for keypad events. + * @since 2.0 + * + * The _IKeypadEventListener interface enables the implementer to receive the + * software keypad related events. + */ +class _IKeypadEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This is the destructor for this class. + * @since 2.0 + */ + virtual ~_IKeypadEventListener(void) {} + + +// Operation +public: + /** + * Notifies that the keypad is about to be shown on the screen. + * + * @since 2.0 + * @param[in] source The source of the event + * @remarks When the software keypad appears on screen, the current Form's + * client area is adjusted to account for the space that is taken + * up by the software keypad. + * @see Tizen::Ui::Controls::Form::GetClientAreaBounds() + */ + virtual void OnKeypadWillOpen(void) = 0; + + /** + * Notifies that the keypad is shown on the screen. + * + * @since 2.0 + * @param[in] source The source of the event + * @remarks When the software keypad appears on screen, the current Form's + * client area is adjusted to account for the space that is taken + * up by the software keypad. + * @see Tizen::Ui::Controls::Form::GetClientAreaBounds() + */ + virtual void OnKeypadOpened(void) = 0; + + /** + * Notifies that the keypad is hidden from the screen. + * + * @since 2.0 + * @param[in] source The source of the event + * @see Tizen::Ui::Controls::Form::GetClientAreaBounds() + */ + virtual void OnKeypadClosed(void) = 0; + + /** + * Notifies that the keypad bounds is changed, for instance when the predictive text@n + * which is located in the upper side of the keypad is shown. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @see Tizen::Ui::Controls::Form::GetClientAreaBounds() + */ + virtual void OnKeypadBoundsChanged(void) = 0; + + /** + * Notifies that the keypad action button is pressed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] keypadAction The keypad action + * @see KeypadAction + */ + virtual void OnKeypadActionPerformed(CoreKeypadAction keypadAction) = 0; +}; // _IKeypadEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IKEYPAD_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_ILanguageEventListener.h b/src/ui/inc/FUiCtrl_ILanguageEventListener.h new file mode 100644 index 0000000..fb5dc36 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ILanguageEventListener.h @@ -0,0 +1,89 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ILanguageEventListener.h + * @brief This is the header file for the _ILanguageEventListener class. + * + * This header file contains the declarations of the _ILanguageEventListener class. + */ + +#ifndef _FUI_CTRL_INTERNAL_ILANGUAGE_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_ILANGUAGE_EVENT_LISTENER_H_ + +// Includes +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @if PRIVCORE + * This is internal. If used in an application, the application can get rejected during the certification process. + * @interface ILanguageEventListener + * @brief This interface implements the listener for the language event. + * @since 1.0 + * + * The ILanguageEventListener interface receives language events. The class that processes a language event + * implements this interface, and the instance created with that class is registered with a UI control, using the control's + * AddLanguageEventListener() method. @n + * + * When the current input language is changed (for example, when the user toggles the input language from the virtual +* keypad, the listener's OnLanguageChanged() method is +* invoked. + */ + +class _ILanguageEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ + +// Operation + +public: + /** + * @if PRIVCORE + * This is the default constructor for this class. + * + * @since 1.0 + */ + _ILanguageEventListener(void) {}; + + /** + * @if PRIVCORE + * This is internal. If used in an application, the application can get rejected during the certification process. + * This is the destructor for this class. + * + * @since 1.0 + */ + virtual ~_ILanguageEventListener(void) {} + + /** + * @if PRIVCORE + * Notifies when the input language is changed. + * + * @since 1.0 + * @param[in] source The source of the event + * @param[in] previousLanguage The previous input language + * @param[in] currentLanguage The current input language + */ + virtual void OnLanguageChanged(Tizen::Locales::LanguageCode oldLanguage, Tizen::Locales::LanguageCode newLanguage) = 0; +}; // _ILanguageEventListener + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_ILANGUAGE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IListItemCommon.h b/src/ui/inc/FUiCtrl_IListItemCommon.h new file mode 100644 index 0000000..48f4535 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IListItemCommon.h @@ -0,0 +1,89 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IListItemCommon.h + * @brief This is the header file for the _IListItemCommon Interface. + * + * This header file contains the declarations of the _IListItemCommon interface. + */ + +#ifndef _FUI_CTRL_INTERNAL_ILIST_ITEM_COMMON_H_ +#define _FUI_CTRL_INTERNAL_ILIST_ITEM_COMMON_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum ListItemState +{ + LIST_ITEM_STATE_NORMAL = 0, + LIST_ITEM_STATE_PRESSED, + LIST_ITEM_STATE_HIGHLIGHTED, + LIST_ITEM_STATE_REORDERED, + LIST_ITEM_STATE_MAX +}; + +enum ListItemType +{ + LIST_ITEM_TYPE_SIMPLE = 0, + LIST_ITEM_TYPE_CUSTOM, + LIST_ITEM_TYPE_GROUP_TITLE +}; + +class _IListItemCommon +{ +public: + virtual ~_IListItemCommon(void) {}; + + virtual bool DrawItem(Tizen::Graphics::Rectangle& rcItem, ListItemState isFocused, bool itemDivider = false) = 0; + + virtual int GetItemHeight(void) const = 0; + + virtual void SetItemHeight(int itemHeight) = 0; + + virtual void SetChecked(bool checked) = 0; + + virtual bool IsChecked(void) const = 0; + + virtual void SetItemEnabled(bool enabled) = 0; + + virtual bool IsItemEnabled(void) const = 0; + + virtual bool IsReorderMode(void) const = 0; + + virtual void SetReorderMode(bool enabled) = 0; + + virtual void SetItemChanged(bool changed) = 0; + + virtual bool IsItemChanged(void) const = 0; + + virtual void SetAppInfo(const void* pAppInfo) = 0; + + virtual void* GetAppInfo(void) const = 0; + + virtual void SetItemIndex(int groupIndex, int itemIndex) {} + + virtual void GetItemIndex(int& groupIndex, int& itemIndex) const {} + +}; // _IListItemCommon + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ILIST_ITEM_COMMON_H_ + diff --git a/src/ui/inc/FUiCtrl_IListItemProviderAdaptor.h b/src/ui/inc/FUiCtrl_IListItemProviderAdaptor.h new file mode 100644 index 0000000..b907dc0 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IListItemProviderAdaptor.h @@ -0,0 +1,55 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IListItemProviderAdaptor.h + * @brief This is the header file for the _IListItemProviderAdaptor Interface. + * + * This header file contains the declarations of the + * _IListItemProviderAdaptor Interface. + */ + + +#ifndef _FUI_CTRL_INTERNAL_ILIST_ITEM_PROVIDER_ADAPTOR_H_ +#define _FUI_CTRL_INTERNAL_ILIST_ITEM_PROVIDER_ADAPTOR_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IListItemCommon; + +class _IListItemProviderAdaptor +{ +public: + virtual ~_IListItemProviderAdaptor(void) {} + + virtual _IListItemCommon* LoadItem(int groupIndex, int itemIndex) = 0; + + virtual result UnloadItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex) = 0; + + virtual result DeleteItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex) = 0; + + virtual int GetItemCount(int groupIndex = 0) const = 0; + + virtual int GetGroupCount(void) const = 0; +}; // _IListItemProviderAdaptor + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_ILIST_ITEM_PROVIDER_ADAPTOR_H_ diff --git a/src/ui/inc/FUiCtrl_IProgressPopupEventListener.h b/src/ui/inc/FUiCtrl_IProgressPopupEventListener.h new file mode 100644 index 0000000..5acbc5a --- /dev/null +++ b/src/ui/inc/FUiCtrl_IProgressPopupEventListener.h @@ -0,0 +1,74 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IProgressPopupEventListener.h + * @brief This is the header file for the _IProgressPopupEventListener class. + * + * This header file contains the declarations of the _IProgressPopupEventListener class. @n + * If a closing ProgressPopup event is generated, a method of this class is called. + * So, if the application does some jobs related to the closing ProgressPopup event, use the methods of this class. + * + */ +#ifndef _FUI_CTRL_INTERNAL_IPROGRESSPOPUP_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IPROGRESSPOPUP_EVENT_LISTENER_H_ + + +#include +#include + + +namespace Tizen { namespace Ui +{ +class _Control; +} } // Tizen::Ui + + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @interface _IProgressPopupEventListener + * @brief This interface implements the listener for ProgressPopup event. + * @since 2.0 + * + * The listener interface for receiving event to close the ProgressPopup. The class that processes a ProgressPopup event + * implements this interface, and the instance created with that class is registered with a UI control, using the control's + * AddProgressPopupEventListener() method. When the event to close ProgressPopup occurs, the OnCanceled() method of that object is invoked. + */ +class _IProgressPopupEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_IProgressPopupEventListener(void) {} + + /** + * Notifies when a ProgressPopup event occurs. + * + * @since 2.0 + * @param[in] source The source of the event + */ + virtual void OnProgressPopupCanceled(void) = 0; + +}; // _IProgressPopupEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IPROGRESSPOPUP_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IScrollEventListener.h b/src/ui/inc/FUiCtrl_IScrollEventListener.h new file mode 100644 index 0000000..1c58830 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IScrollEventListener.h @@ -0,0 +1,98 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IScrollEventListener.h + * @brief This is the header file for the _IScrollEventListener class. + * @brief This is the header file for the _ScrollExtraValue class. + * + * This header file contains the declarations of the _IScrollEventListener class. + * If a change event is generated, a method of this class is called. + * Applications that do jobs related to change events call the methods of this class. + */ + +#ifndef _FUICTRL_INTERNAL_ISCROLL_EVENT_LISTENER_H_ +#define _FUICTRL_INTERNAL_ISCROLL_EVENT_LISTENER_H_ + +// Includes +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen {namespace Ui { namespace Controls +{ + +/** + * @interface _IScrollEventListener + * @brief This interface implements a listener for scroll events. + * @since 2.0 + * + * The interface implements a listener for receiving changes to the Control's the behavior of the scroll. + * The class that displays and controls scroll implements this interface, and the instance created with + * that class is registered with a UI control, using the control's AddScrollEventListener() method. + */ +class _IScrollEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + * + */ + virtual ~_IScrollEventListener(void) {} + + /** + * Notifies when the scroll reached on one of top, bottom, left or right end + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] type The type of scroll end event + */ + virtual void OnScrollEndReached(Tizen::Ui::_Control& source, ScrollEndEvent type) = 0; + + /** + * Notifies when the scroll is scrolled by scroll bar. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] scrollPos The scrolled position + */ + virtual void OnScrollPositionChanged(Tizen::Ui::_Control& source, int scrollPos) {}; + + /** + * Called when the control's scroll movement has come to a stop. + * + * @since 2.0 + * + * @param[in] source The control being scrolled + */ + virtual void OnScrollStopped(Tizen::Ui::_Control& source) {}; + +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_ISCROLL_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IScrollPanelEventListener.h b/src/ui/inc/FUiCtrl_IScrollPanelEventListener.h new file mode 100644 index 0000000..02f03bc --- /dev/null +++ b/src/ui/inc/FUiCtrl_IScrollPanelEventListener.h @@ -0,0 +1,98 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IScrollPanelEventListener.h + * @brief This is the header file for the _IScrollPanelEventListener class. + * + * This header file contains the declarations of the _IScrollPanelEventListener class. + * If a change event is generated, a method of this class is called. + * Applications that do jobs related to change events call the methods of this class. + * + */ +#ifndef _FUI_CTRL_INTERNAL_ISCROLLPANEL_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_ISCROLLPANEL_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @interface _IScrollPanelEventListener + * @brief This interface implements a listener for ScrollPanel events. + * @since 1.0 + * + * The interface implements a listener for receiving changes to the overlay keypad. The class that + * displays and controls an overlay keypad implements this interface, and the instance created with + * that class is registered with a UI control, using the control's AddScrollPanelEventListener() method. + */ +class _IScrollPanelEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 1.0 + */ + virtual ~_IScrollPanelEventListener(void) {} + + /** + * Notifies when an overlay keypad is created on the ScrollPanel. + * + * @since 1.0 + * @param[in] source The source of the event + */ + virtual void OnOverlayControlCreated(const Tizen::Ui::_Control& source) = 0; + + /** + * Notifies when an overlay keypad is opened on the ScrollPanel. + * + * @since 1.0 + * @param[in] source The source of the event + */ + virtual void OnOverlayControlOpened(const Tizen::Ui::_Control& source) = 0; + + /** + * Notifies when an overlay keypad is closed on the ScrollPanel. + * + * @since 1.0 + * @param[in] source The source of the event + */ + virtual void OnOverlayControlClosed(const Tizen::Ui::_Control& source) = 0; + + /** + * Notifies when a control on the ScrollPanel is selected. + * + * @since 1.0 + * @param[in] source The source of the event + */ + virtual void OnOtherControlSelected(const Tizen::Ui::_Control& source) = 0; +}; // _IScrollPanelEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ISCROLLPANEL_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IScrollableContainer.h b/src/ui/inc/FUiCtrl_IScrollableContainer.h new file mode 100644 index 0000000..7d6fe1b --- /dev/null +++ b/src/ui/inc/FUiCtrl_IScrollableContainer.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_IScrollableContainer.h +* @brief This is the implementation for the _IScrollableContainer class. +* +* This header file contains the declarations of the _IScrollableContainer class. +*/ + +#ifndef _FUI_CTRL_INTERNAL_ISCROLLABLE_CONTAINER_H_ +#define _FUI_CTRL_INTERNAL_ISCROLLABLE_CONTAINER_H_ + +// includes +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** +* @class _IScrollableContainer +* @brief This class handles a scrollable container. It is inherited from scrollable container interface class. +* +*/ +class _IScrollableContainer +{ +// Lifecycle +public: + virtual ~_IScrollableContainer(void){} + +// Operations +public: + virtual bool ScrollToControl(const _Control& source) = 0; + +protected: +// reserved virtual methods for later extension +// Following methods are reserved and may change its name at any time without prior notice. + virtual void _IScrollableContainer_Reserved1(void) {} + virtual void _IScrollableContainer_Reserved2(void) {} + virtual void _IScrollableContainer_Reserved3(void) {} + +// Property +private: +}; // _IScrollableContainer + +}}}// Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ISCROLLABLE_CONTAINER_H_ + diff --git a/src/ui/inc/FUiCtrl_ISearchBarEventListener.h b/src/ui/inc/FUiCtrl_ISearchBarEventListener.h new file mode 100644 index 0000000..b5ae1d1 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ISearchBarEventListener.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ISearchBarEventListener.h + * @brief This is the header file for the _ISearchBarEventListener interface. + * + * This header file contains the declarations of the _ISearchBarEventListener + * interface. + */ +#ifndef _FUI_CTRL_INTERNAL_ISEARCH_BAR_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_ISEARCH_BAR_EVENT_LISTENER_H_ + +// incluses +#include +#include + +namespace Tizen {namespace Ui { namespace Controls +{ + +class _SearchBar; + +/** + * @interface _ISearchBarEventListener + * @brief This interface implements the listener for SearchBar events. + * @since 2.0 + * + * The _ISearchBarEventListener interface enables the implementer to receive the + * SearchBar events. + */ +class _ISearchBarEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ISearchBarEventListener(void) {} + + +// Operation +public: + /** + * Notifies that the mode of the SearchBar is changed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] mode The current search bar mode. + */ + virtual void OnSearchBarModeChanged(Tizen::Ui::Controls::_SearchBar& source, SearchBarMode mode) = 0; + +}; // _ISearchBarEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ISEARCH_BAR_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_ISliderEventListener.h b/src/ui/inc/FUiCtrl_ISliderEventListener.h new file mode 100644 index 0000000..b54f361 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ISliderEventListener.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ISliderEventListener.h + * @brief This is the header file for the _ISliderEventListener class. + * + * This header file contains the declarations of the _ISliderEventListener class. + * If a change event is generated, a method of this class is called. + * So, if applications do jobs related to change events, use the methods of this class. + * + */ +#ifndef _FUICTRL_INTERNAL_ISLIDER_EVENT_LISTENER_H_ +#define _FUICTRL_INTERNAL_ISLIDER_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Slider; + +/** + * @interface _ISliderEventListener + * @brief This interface implements the listener for all slider events. + * @since 2.0 + * + * The _ISliderEventListener interface receives slider events which are fired when the knob of a Slider moves. + * The class that is interested in processing an slider event implements this interface, and the object created + * with that class is registered with a UI control, using the control's AddSliderEventListener() method. + * When slider event occurs, the object's OnSliderBarMoved() method is invoked. + */ +class _ISliderEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ISliderEventListener(void) {} + + /** + * Notifies that the Slider bar moved. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] value The current value indicated by the knob + * @remarks This event is fired when the knob is moved until the user releases + * the knob. + */ + virtual void OnSliderBarMoved(Tizen::Ui::Controls::_Slider& source, int value) = 0; + +}; // _ISliderEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_ISLIDER_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_ISplitPanelEventListener.h b/src/ui/inc/FUiCtrl_ISplitPanelEventListener.h new file mode 100644 index 0000000..bed02cd --- /dev/null +++ b/src/ui/inc/FUiCtrl_ISplitPanelEventListener.h @@ -0,0 +1,83 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ISplitPanelEventListener.h + * @brief This is the header file for the _ISplitPanelEventListener interface. + * + * This header file contains the declarations of the _ISplitPanelEventListener + * interface. + */ +#ifndef _FUI_CTRL_INTERNAL_ISPLIT_PANEL_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_ISPLIT_PANEL_EVENT_LISTENER_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class _SplitPanel; + +/** + * @interface _ISplitPanelEventListener + * @brief This interface implements the listener for all splitpanel events. + * @since 2.0 + * + * The %_ISplitPanelEventListener interface is the listener interface for receiving SplitPanel events, which are fired when the divider moves or is double pressed. + * The class that processes a SplitPanel event implements this interface, and the instance created with that class is registered with + * a UI control, using the control's AddSplitPanelEventListener() method. When the splitpanle divider is moved, the OnDividerPositionChanged() + * method of that instance is invoked. + * + * For more information on the class features, see SplitPanel. + */ +class _ISplitPanelEventListener + : public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ISplitPanelEventListener(void) {} + +public: + /** + * + * Called when the divider moves. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] position The position of the divider + */ + virtual void OnDividerPositionChanged(Tizen::Ui::Controls::_SplitPanel& source, int position) = 0; + + /** + * Called when the divider is double pressed. + * + * @since 2.0 + * + * @param[in] source The source of the event + * @remark This method is invoked when an divider is double pressed. + */ + virtual void OnDividerDoublePressed(Tizen::Ui::Controls::_SplitPanel& source) = 0; + +}; // _ISplitPanelEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ISPLIT_PANEL_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_ITableViewItemEventListener.h b/src/ui/inc/FUiCtrl_ITableViewItemEventListener.h new file mode 100644 index 0000000..7f054c3 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ITableViewItemEventListener.h @@ -0,0 +1,218 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ITableViewItemEventListener.h + * @brief This is the header file for the _ITableViewItemEventListener class. + * + * This header file contains the declarations of the _ITableViewItemEventListener + * class. @n + * If an item event is generated, a method of this class is called. @n + * So, if an application does some jobs related to the item event, + * use the methods of this class. + * + */ + +#ifndef _FUI_CTRL_INTERNAL_ITABLEVIEWITEM_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_ITABLEVIEWITEM_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class TableViewItem; +class TableViewContextItem; +class TableViewGroupItem; +class _TableView; +class _TableViewItem; + +/** + * @interface _ITableViewItemEventListener + * @brief This interface implements the listener for + * internal item event. + * @since 2.0 + * + * _ITableViewItemEventListener is an interface which implements a listener for receiving + * item change events. The class that is interested in + * processing an item event implements this interface, and the + * instance created with that class is registered with a UI + * control, using the control's AddTableViewItemEventListener() + * method. When the item event occurs, the OnItemStateChanged() + * method of that object is invoked. + */ +class _ITableViewItemEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ITableViewItemEventListener(void) {} + + /** + * Called when the state of a TableViewItem in the TableView is changed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] itemIndex The item index + * @param[in] pItem The target item + * @param[in] status The status of the item + * @remarks This method is called when a TableViewItem in the TableView is checked, unchecked, or selected. + * The application can change @c pItem in this method, but should not keep @c pItem for later use. + */ + virtual void OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) = 0; + + /** + * Called when the TableViewContextItem is opened or closed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] itemIndex The item index + * @param[in] pContextItem The context item which is opened or closed + * @param[in] activated @c true if a context item is opened,@n + * @c false, otherwise + */ + virtual void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) = 0; + + /** + * Called when the item is reordered. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] itemIndexFrom The start item index of the item + * @param[in] itemIndexTo The final item index of the item + */ + virtual void OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo) = 0; + + + /** + * Called when the state of a TableViewGroupItem is changed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] groupIndex The group index + * @param[in] pItem The target item + * @param[in] status The status of the item + * @remarks This method is called when the TableViewGroupItem in the GroupedTableView is checked, unchecked, or selected. + */ + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) = 0; + + /** + * Called when the state of a TableViewItem in the GroupedTableView is changed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] pItem The target item + * @param[in] status The status of the item + * @remarks This method is called when the TableViewItem in the GroupedTableView is checked, unchecked, or selected. + */ + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) = 0; + + /** + * Called when the TableViewContextItem is opened or closed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] groupIndex The group index + * @param[in] itemIndex The item index + * @param[in] pContextItem The context item which is opened or closed + * @param[in] activated @c true if a context item is opened,@n + * @c false, otherwise + */ + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) = 0; + + /** + * Called when the item is reordered. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] groupIndexFrom The source group index of the item + * @param[in] itemIndexFrom The source item index of the item + * @param[in] groupIndexTo The target group index of the item + * @param[in] itemIndexTo The target item index of the item + */ + virtual void OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo) = 0; + + + /** + * Called when the state of a TableViewItem in the SectionTableView is changed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @param[in] pItem The target item + * @param[in] status The status of the item + * @remarks This method is called when the TableViewItem in the SectionTableView is checked, unchecked, or selected. + */ + virtual void OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) = 0; + + /** + * Called when the TableViewContextItem is opened or closed. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] sectionIndex The section index + * @param[in] itemIndex The item index + * @param[in] pContextItem The context item which is opened or closed + * @param[in] activated @c true if a context item is opened,@n + * @c false, otherwise + */ + virtual void OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) = 0; + + + /* + * Called when the TableViewItem is swept. + * + * @since 2.0 + * + * @param[in] tableView The source of the event + * @param[in] groupIndex The item index + * @param[in] itemIndex The item index + * @param[in] direction The sweep direction + */ + virtual void OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction) = 0; + +protected: + // reserved virtual methods for later extension + // + // Following methods are reserved and may change its name at any time without prior notice. + // + virtual void _ITableViewItemEventListener_Reserved1(void) {} + virtual void _ITableViewItemEventListener_Reserved2(void) {} + virtual void _ITableViewItemEventListener_Reserved3(void) {} +}; // _ITableViewItemEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ITABLEVIEWITEM_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_ITextBlockEventListener.h b/src/ui/inc/FUiCtrl_ITextBlockEventListener.h new file mode 100644 index 0000000..c6603d1 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ITextBlockEventListener.h @@ -0,0 +1,74 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ITextBlockEventListener.h + * @brief This is the header file for the _ITextBlockEventListener interface. + * + * This header file contains the declarations of the _ITextBlockEventListener interface. + */ +#ifndef _FUI_CTRL_INTERNAL_ITEXT_BLOCK_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_ITEXT_BLOCK_EVENT_LISTENER_H_ + +// Includes +#include + +// forward declaration +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +// namespace declaration +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @interface ITextBlockEventListener + * @brief This interface implements the listener for text block events. + * @since 2.0 + * + * The ITextBlockEventListener interface enables the implementer to receive the + * text block selection event. + */ +class _ITextBlockEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This is the destructor for this class. + * @since 2.0 + */ + virtual ~_ITextBlockEventListener(void) {} + + +// Operation +public: + /** + * Notifies that a text block is selected. + * @since 2.0 + * + * @param[in] source The source of the event + * @param[in] start The starting index of the selected text block. + * @param[in] end The end index of the selected text block. + */ + virtual void OnTextBlockSelected(Tizen::Ui::_Control& source, int start, int end) = 0; + +}; // _ITextBlockEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ITEXT_BLOCK_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_ITextEventListener.h b/src/ui/inc/FUiCtrl_ITextEventListener.h new file mode 100644 index 0000000..62a4f4b --- /dev/null +++ b/src/ui/inc/FUiCtrl_ITextEventListener.h @@ -0,0 +1,107 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ITextEventListener.h + * @brief This is the header file for the _ITextEventListener class. + * + * This header file contains the declarations of the _ITextEventListener class. @n + * If a change event is generated, a method of this class is called. @n + * So, if the applications perform tasks related to change events, use the methods of this class. + * + */ +#ifndef _FUI_CTRL_INTERNAL_ITEXT_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_ITEXT_EVENT_LISTENER_H_ + +// Includes +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} //Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @interface _ITextEventListener + * @brief This interface implements the listener for _kmjaction event. + * @since 1.0 + * + * The listener interface for receiving the action events. The class that processes an action event + * implements this interface, and the object created with that class is registered with a _control, using the _control's + * AddTextEventListener() method. When the action event occurs, the OnTextValueChanged() method of that object is invoked. + */ +class _ITextEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 1.0 + */ + virtual ~_ITextEventListener(void) {} + + /** + * Notifies when a text is changed. + * + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 1.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompIEventListenerOnTextValueChanged "here". + * @endif + * @param[in] source The source of the event + * @remarks For EditField or EditArea with INPUT_STYLE_FULLSCREEN input style, this listener method is invoked when + * the user presses "Done" soft-key. Whereas, EditField or EditArea with INPUT_STYLE_OVERLAY input style, + * this method is called whenever the presses a key. + * @remarks Note that when a non-character key is pressed, OnTextValueChanged callback is invoked. + */ + virtual void OnTextValueChanged(const Tizen::Ui::_Control& source) = 0; + + /** + * @if OSPCOMPAT + * @page CompIEventListenerOnTextValueChanged Compatibility for OnTextValueChanged() + * @section CompIEventListenerOnTextValueChangedIssues Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * + * -# When texts are inserted by prediction feature in the predictive input mode of EditArea or EditField, OnTextValueChanged callback is not invoked. + * + * @section CompIEventListenerOnTextValueChanged Resolutions Resolutions + * This issue has been resolved in Tizen. @n + * @endif + */ + + /** + * Notifies when a change made to the text is cancelled. + * + * @since 1.0 + * @param[in] source The source of the event + * @remarks This listener method is called when the user presses "Cancel" soft-key for EditField or + * EditArea with INPUT_STYLE_FULLSCREEN input style. + */ + virtual void OnTextValueChangeCanceled(const Tizen::Ui::_Control& source) = 0; + +}; // _ITextEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ITEXT_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_ITokenFilter.h b/src/ui/inc/FUiCtrl_ITokenFilter.h new file mode 100644 index 0000000..61a1904 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ITokenFilter.h @@ -0,0 +1,52 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ITokenFilter.h + * @brief This is the header file for the _ITokenFilter interface. + * + * This header file contains the declarations of the _ITokenFilter interface. + */ +#ifndef _FUICTRL_INTERNAL_ITOKEN_FILTER_H_ +#define _FUICTRL_INTERNAL_ITOKEN_FILTER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ITokenFilter +{ +public: + virtual ~_ITokenFilter(void) {}; + + // Operation +public: + /** + * Asks the filter if the text tokenized by the ExpandableEditArea should + * be replaced. + * + * @since 2.0 + * @return @c true if the text of the current token needs to be replaced. + * @c false otherwise + * @param[in] token The current token's text + * @param[out] replacement The user-defined replacement text + */ + virtual bool ReplaceToken(const Tizen::Base::String& token, Tizen::Base::String& replacement) = 0; +}; // _ITokenFilter + +}}} // Tizen::Ui::Controls +#endif diff --git a/src/ui/inc/FUiCtrl_IUiLinkEventListener.h b/src/ui/inc/FUiCtrl_IUiLinkEventListener.h new file mode 100644 index 0000000..a30c1e8 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IUiLinkEventListener.h @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IUiLinkEventListener.h + * @brief This file defines the _IUiLinkEventListener interface. + * @version 3.0 + * + * This file contains the declarations of _IUiLinkEventListener interface. + */ + +#ifndef _FUI_CTRL_INTERNAL_IUI_LINK_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_IUI_LINK_EVENT_LISTENER_H_ + +// includes +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +// namespace declaration +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @interface _IUiLinkEventListener + * @brief This interface implements the listener for link events. + * @since 2.0 + * + * The _IUiLinkEventListener interface enables the implementer to receive the + * link click event. + */ +class _IUiLinkEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_IUiLinkEventListener(void) {} + + // Operation +public: + /** + * Notifies that a link is clicked. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] text The text. + * @param[in] linkType The link type. + * @param[in] link The optional link text. + * @remarks If clicked link does not contain optional link text then, the value of @c text and @c link will be the same. + */ + virtual void OnLinkClicked(Tizen::Ui::_Control& source, const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link) = 0; +}; // _IUiLinkEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_IUI_LINK_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IUiListViewItemEventListener.h b/src/ui/inc/FUiCtrl_IUiListViewItemEventListener.h new file mode 100644 index 0000000..bf3b493 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IUiListViewItemEventListener.h @@ -0,0 +1,90 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IUiListViewItemEventListener.h + * @brief This is the header file for the _IUiListViewItemEventListener class. + * + * This header file contains the declarations of the _IUiListViewItemEventListener + * class. @n + * If an item event is generated, a method of this class is called. @n + * So, if an application does some jobs related to the item event, + * use the methods of this class. + * + */ + +#ifndef _FUI_CTRL_INTERNAL_ILIST_VIEW_ITEM_EVENT_LISTENER_H_ +#define _FUI_CTRL_INTERNAL_ILIST_VIEW_ITEM_EVENT_LISTENER_H_ + +#include +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IUiListViewItemEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ + +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called + * when the destructor of this interface is called. + * + * @since 2.0 + */ + virtual ~_IUiListViewItemEventListener(void) {} + + /** + * Notifies when the state of an element in the ListContextItem is changed. + * + * @since 2.0 + * + * @param[in] groupIndex The group index of the list + * @param[in] itemIndex The item index of the list + * @param[in] elementId The element ID + * @param[in] status The status of the element + */ + virtual void OnListViewContextItemStateChanged(Tizen::Ui::_Control& source, int groupIndex, int itemIndex, int elementId, Tizen::Ui::Controls::ListContextItemStatus status) = 0; + + /** + * Called when the item or the element is long pressed. + * + * @since 2.0 + * + * @param[in] groupIndex The group index of the list + * @param[in] itemIndex The item index of the list + * @param[in] elementId The element ID + */ + virtual void OnListViewItemLongPressed(Tizen::Ui::_Control& source, int groupIndex, int itemIndex, int elementId) = 0; + + +protected: + // reserved virtual methods for later extension + // + // Following methods are reserved and may change its name at any time without prior notice. + // + virtual void _IUiListViewItemEventListener_Reserved1(void) {} + virtual void _IUiListViewItemEventListener_Reserved2(void) {} + virtual void _IUiListViewItemEventListener_Reserved3(void) {} +}; // _IUiListViewItemEventListener + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ILIST_VIEW_ITEM_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_IconListData.h b/src/ui/inc/FUiCtrl_IconListData.h new file mode 100644 index 0000000..4cd7c64 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListData.h @@ -0,0 +1,74 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListData.h + * @brief This is the header file for the _IconListData class. + * + * This header file contains the declarations of the _IconListData class. + */ + +#ifndef _FUI_CTRL_ICON_LIST_DATA_H_ +#define _FUI_CTRL_ICON_LIST_DATA_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IconListData + : public Tizen::Base::Object +{ +public: + _IconListData(void); + + ~_IconListData(void); + +public: + const Tizen::Graphics::Bitmap* GetNormalBitmap(void); + + const Tizen::Graphics::Bitmap* GetFocusedBitmap(void); + + const Tizen::Base::String GetLabelText(void); + + int GetItemId(void); + + void SetNormalBitmap(const Tizen::Graphics::Bitmap* pNormalBitmap); + + void SetFocusedBitmap(const Tizen::Graphics::Bitmap* pFocusedBitmap); + + void SetLabelText(const Tizen::Base::String& labelText); + + void SetItemId(int itemId); + +private: + _IconListData(const _IconListData& rhs); + _IconListData& operator =(const _IconListData& rhs); + +private: + Tizen::Graphics::Bitmap* __pNormalBitmap; + Tizen::Graphics::Bitmap* __pFocusedBitmap; + Tizen::Base::String __labelText; + int __itemId; + +}; //_IconListData + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_ICON_LIST_DATA_H_ diff --git a/src/ui/inc/FUiCtrl_IconListImpl.h b/src/ui/inc/FUiCtrl_IconListImpl.h new file mode 100644 index 0000000..8cc5c0b --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListImpl.h @@ -0,0 +1,130 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IconListImpl.h + * @brief This is the header file for the _IconListImpl class. + * + * This header file contains the declarations of the _IconListImpl class. + */ + +#ifndef _FUI_CTRL_ICON_LIST_IMPL_H_ +#define _FUI_CTRL_ICON_LIST_IMPL_H_ + +// Includes +#include +#include +#include +#include +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_IconListView.h" +#include "FUiCtrl_IconListViewItemEventArg.h" +#include "FUiCtrl_IIconListItemEventListener.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IconListData; +class _IconListItemProvider; + +class _IconListImpl + : public _ControlImpl + , public _IIconListItemEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ + +public: + virtual ~_IconListImpl(void); + static _IconListImpl* CreateIconListImplN(IconList* pControl); + virtual const char* GetPublicClassName(void) const; + virtual const IconList& GetPublic(void) const; + virtual IconList& GetPublic(void); + virtual const _IconListView& GetCore(void) const; + virtual _IconListView& GetCore(void); + result SetListener(void); + void AddItemEventListener(Tizen::Ui::IItemEventListener& listener); + void RemoveItemEventListener(Tizen::Ui::IItemEventListener& listener); + void SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + result SetMargin(int topMargin, int leftMargin); + int GetTopMargin(void) const; + int GetLeftMargin(void) const; + result AddItem(const Tizen::Base::String* pText, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pFocusedBitmap, int itemId = LIST_ITEM_UNSPECIFIED_ID); + result InsertItemAt(int index, const Tizen::Base::String* pText, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pFocusedBitmap, int itemId = LIST_ITEM_UNSPECIFIED_ID); + result SetItemAt(int index, const Tizen::Base::String* pText, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pFocusedBitmap, int itemId = LIST_ITEM_UNSPECIFIED_ID); + result RemoveItemAt(int index); + result RemoveAllItems(void); + int GetColumnCount(void) const; + int GetItemCount(void) const; + result SetItemChecked(int index, bool check); + bool IsItemChecked(int index) const; + result SetAllItemsChecked(bool check); + result RemoveAllCheckedItems(void); + int GetFirstCheckedItemIndex(void) const; + int GetLastCheckedItemIndex(void) const; + int GetNextCheckedItemIndexAfter(int index) const; + int GetItemIndexFromPosition(int x, int y) const; + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + void SetTextHorizontalAlignment(HorizontalAlignment alignment); + void SetTextVerticalAlignment(VerticalAlignment alignment); + HorizontalAlignment GetTextHorizontalAlignment(void) const; + VerticalAlignment GetTextVerticalAlignment(void) const; + void SetTextOfEmptyList(const Tizen::Base::String& text); + void SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + void SetItemTextColor(const Tizen::Graphics::Color& textColor); + Tizen::Graphics::Color GetItemTextColor(void) const; + void SetTextSize(int size); + int GetTextSize(void) const; + int GetItemIndexFromItemId(int itemId) const; + int GetItemIdAt(int index) const; + void SetCheckBoxPosition(IconListCheckBoxPosition position); + IconListCheckBoxPosition GetCheckBoxPosition(void) const; + void SetFocusAnimationEnabled(bool enable); + void ScrollToBottom(void); + void ScrollToTop(void); + result ScrollToTop(int itemIndex); + result RefreshItem(int index); + virtual void OnIconListItemStateChanged(_IconListViewItemEventArg* pArg); + result SetIconListStyle(IconListStyle style); + result InitializeIconList(int itemWidth, int itemHeight); + result SetItemProvider(void); + result SetNonSlidable(void); + +public: + static _IconListImpl* GetInstance(IconList& iconList); + static const _IconListImpl* GetInstance(const IconList& iconList); + +private: + _IconListImpl(Control* pPublic, _IconListView* pCore); + _IconListImpl(const _IconListImpl& rhs); + _IconListImpl& operator =(const _IconListImpl& rhs); + _IconListData* CreateIconListItemN(const Tizen::Base::String* pText, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pFocusedBitmap, int itemId = LIST_ITEM_UNSPECIFIED_ID); + _IconListImpl* GetIconListImpl(void); + +private: + static const int INVALID_INDEX = -1; + friend class _IconListItemProvider; + _IconListItemProvider* __pIconListItemProvider; + Tizen::Base::Collection::LinkedList __iconList; + Tizen::Base::Collection::LinkedList __iconListenersList; + IconListViewStyle __annexStyle; + +}; //_IconListImpl + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_ICON_LIST_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_IconListItem.h b/src/ui/inc/FUiCtrl_IconListItem.h new file mode 100644 index 0000000..f1f1e12 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListItem.h @@ -0,0 +1,137 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListItem.h + * @brief This is the header file for the _IconListItem class. + */ + +#ifndef _FUI_CTRL_INTERNAL_ICON_LIST_ITEM_H_ +#define _FUI_CTRL_INTERNAL_ICON_LIST_ITEM_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUiCtrl_LinkedList.h" +#include "FUiCtrl_ListItemCommon.h" + +namespace Tizen { namespace Ui +{ + +namespace Animations +{ +class _VisualElement; +} // Tizen::Ui::Animations + +namespace Controls +{ + +class IconListViewItem; +class _IconListItemDrawingProperty; + +struct _OverlayBitmap +{ + int id; + Tizen::Graphics::Bitmap* pBitmap; + HorizontalAlignment horizontalAlignment; + VerticalAlignment verticalAlignment; + Tizen::Ui::Animations::_VisualElement* pVE; +}; + +class _IconListItem + : public _ListItemCommon +{ +// Lifecycle + +public: + virtual ~_IconListItem(void); + + static _IconListItem* CreateIconListItemN(IconListViewItem* pIconListViewItem); + + // _ListItemCommon + virtual bool DrawItem(Tizen::Graphics::Rectangle& rcItem, ListItemState isFocused, bool itemDivider = false); + virtual void SetChecked(bool checked); + virtual void SetItemIndex(int groupIndex, int itemIndex); + virtual void GetItemIndex(int& groupIndex, int& itemIndex) const; + + result DrawItemTouchAnimation(Tizen::Graphics::Rectangle& rcItem, float ratio); + result DrawItemCheckAnimation(Tizen::Graphics::Rectangle& rcItem, float ratio); + + result SetText(const Tizen::Base::String* pText); + + const Tizen::Base::String& GetText(void) const; + + result SetBitmap(IconListViewItemDrawingStatus status, const Tizen::Graphics::Bitmap* pBitmap); + + const Tizen::Graphics::Bitmap* GetBitmap(IconListViewItemDrawingStatus status) const; + + Tizen::Ui::Animations::_VisualElement* GetVisualElement(void) const; + + void ClearVisualElement(void); + + result SetDrawingProperty(_IconListItemDrawingProperty& property); + + result SetOverlayBitmap(int overlayBitmapId, const Tizen::Graphics::Bitmap* pOverlayBitmap, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment); + + int GetOverlayBitmapIdFromPosition(Tizen::Graphics::Point& position) const; + + Tizen::Ui::Animations::_VisualElement* GetItemVisualElement(void) const; + +protected: + result DrawBitmap(Tizen::Graphics::Canvas& canvas, Tizen::Graphics::Bitmap& bitmap, bool isFocused = false, float ratio = 1.0f); + result DrawText(const Tizen::Graphics::Color& color); + result DrawCheck(Tizen::Graphics::Canvas& canvas, float ratio = 1.0f); + result DrawOverlayBitmaps(void); + +private: + _IconListItem(Tizen::Ui::Animations::_VisualElement* pBase); + _IconListItem(const _IconListItem& rhs); + _IconListItem& operator =(const _IconListItem& rhs); + + Tizen::Graphics::Rectangle GetOverlayBitmapBounds(_OverlayBitmap* pOverlayBitmap, const Tizen::Graphics::Rectangle& parentRect, int overlayMargin) const; + +// Inquiry +public: +// Attribute +private: + static const int DEFAULT_GROUP_INDEX = 0; + static const int MAX_ITEM_TEXT_LINE_COUNT = 2; + static const float REFERENCE_FACTOR = 1.0f; + static const int OPAQUE_ALPHA = 255; + + int __itemIndex; + Tizen::Base::String __text; + Tizen::Graphics::Bitmap* __pBitmap[LIST_ITEM_STATE_MAX]; + Tizen::Ui::Animations::_VisualElement* __pBase; + Tizen::Ui::Animations::_VisualElement* __pTextVE; + Tizen::Ui::Animations::_VisualElement* __pCheckVE; + _IconListItemDrawingProperty* __pProperty; + ListItemState __foreDrawnState; + bool __isDrawn; + + Tizen::Graphics::_Text::TextObject* __pTextObject; + _LinkedList <_OverlayBitmap*> __overlayBitmaps; +}; // _IconListItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ICON_LIST_ITEM_H_ diff --git a/src/ui/inc/FUiCtrl_IconListItemDrawingProperty.h b/src/ui/inc/FUiCtrl_IconListItemDrawingProperty.h new file mode 100644 index 0000000..623502d --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListItemDrawingProperty.h @@ -0,0 +1,215 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListItemDrawingProperty.h + * @brief This is the header file for the _IconListItemDrawingProperty class. + */ + +#ifndef _FUI_CTRL_INTERNAL_ICON_LIST_ITEM_DRAWING_PROPERTY_H_ +#define _FUI_CTRL_INTERNAL_ICON_LIST_ITEM_DRAWING_PROPERTY_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUiCtrl_ListItemCommon.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IconListItemDrawingProperty +{ +// Lifecycle +public: + virtual ~_IconListItemDrawingProperty(void); + + static _IconListItemDrawingProperty* CreateInstanceN(void); + +// Operations +public: + result Initialize(void); + +// Accessor +public: + const Tizen::Graphics::Color GetBackgroundColor(IconListViewItemDrawingStatus status) const; + + result SetTextSize(int size); + + int GetTextSize(void) const; + + result SetFont(Tizen::Graphics::Font* pFont); + + Tizen::Graphics::Font* GetFont(void) const; + + result SetTextColor(IconListViewItemDrawingStatus status, const Tizen::Graphics::Color color); + + const Tizen::Graphics::Color GetTextColor(IconListViewItemDrawingStatus status) const; + + const Tizen::Graphics::Color GetTextBackgroundColor(void) const; + + const Tizen::Graphics::Color GetBorderColor(bool isFocused) const; + + result SetItemLayout(void); + + result SetItemBitmapBounds(const Tizen::Graphics::Rectangle bounds); + + const Tizen::Graphics::Rectangle GetItemBitmapBounds(void) const; + + const Tizen::Graphics::Dimension GetItemBitmapSize(void) const; + + result SetItemSize(const Tizen::Graphics::Dimension size); + + const Tizen::Graphics::Dimension GetItemSize(void) const; + + const int GetTextXPosition(void) const; + + const int GetTextYPosition(void) const; + + const int GetTwoLineTextYPosition(void) const; + + const int GetTextAreaWidth(void) const; + + const int GetTextVerticalMargin(void) const; + + result SetCheckBoxPosition(IconListViewCheckBoxPosition position); + + IconListViewCheckBoxPosition GetCheckBoxPosition(void) const; + + result SetBorderStyle(IconListViewItemBorderStyle style); + + IconListViewItemBorderStyle GetBorderStyle(void) const; + + result SetTextHorizontalAlignment(HorizontalAlignment alignment); + + HorizontalAlignment GetTextHorizontalAlignment(void) const; + + result SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment); + + IconListViewItemTextVerticalAlignment GetTextVerticalAlignment(void) const; + + const Tizen::Graphics::Bitmap* GetDropShadowBitmap(void) const; + + const Tizen::Graphics::Bitmap* GetFocusDropShadowBitmap(void) const; + + int GetDropShadowBorderWidth(void) const; + + int GetDropShadowMargin(void) const; + + const Tizen::Graphics::Rectangle GetDropShadowBitmapBounds(void) const; + + const Tizen::Graphics::Bitmap* GetCheckBitmap(void) const; + + const Tizen::Graphics::Bitmap* GetCheckedBackgroundBitmap(void) const; + + const Tizen::Graphics::Bitmap* GetUnCheckedBackgroundBitmap(void) const; + + const Tizen::Graphics::Bitmap* GetDisabledCheckBitmap(void) const; + + void SetItemCheckedStyle(bool checkStyle); + + bool IsItemCheckedStyle(void) const; + + int GetCheckMargin(void) const; + + int GetOverlayMargin(void) const; + + int GetSelectBackgroundMargin(void) const; + + void SetDrawingFlag(void); + + bool IsChanged(void) const; + + int AddRef(void); + + int Release(void); + + void SetItemBitmapAsAspectRatio(bool isAspect); + + bool IsItemBitmapAsAspectRatio(void) const; + +// Inquiry +public: + +private: + _IconListItemDrawingProperty(void); + _IconListItemDrawingProperty(const _IconListItemDrawingProperty& rhs); + _IconListItemDrawingProperty& operator =(const _IconListItemDrawingProperty& rhs); + +// Attribute +private: + int __textSize; + Tizen::Graphics::Font* __pFont; + + Tizen::Graphics::Color __normalTextColor; + Tizen::Graphics::Color __pressedTextColor; + Tizen::Graphics::Color __highlightedTextColor; + + Tizen::Graphics::Dimension __size; + Tizen::Graphics::Rectangle __bitmapBounds; + + Tizen::Graphics::Bitmap* __pDropShadowBitmap; + Tizen::Graphics::Bitmap* __pFocusDropShadowBitmap; + Tizen::Graphics::Bitmap* __pDropShadowBitmapWithReplacementColor; + + int __dropShadowBorderWidth; + int __dropShadowMargin; + + Tizen::Graphics::Bitmap* __pCheckBitmap; + Tizen::Graphics::Bitmap* __pCheckedBackgroundBitmap; + Tizen::Graphics::Bitmap* __pUnCheckedBackgroundBitmap; + Tizen::Graphics::Bitmap* __pDisabledCheckBitmap; + + int __checkMargin; + int __overlayMargin; + + Tizen::Graphics::Color __pressedBackgroundColor; + Tizen::Graphics::Color __normalBorderColor; + Tizen::Graphics::Color __focusBorderColor; + Tizen::Graphics::Color __inTextBackgroundColor; + + int __textYPos; + int __2LineTextYPos; + + IconListViewCheckBoxPosition __checkBoxPosition; + IconListViewItemBorderStyle __borderStyle; + HorizontalAlignment __textHorizontalAlignment; + IconListViewItemTextVerticalAlignment __textVerticalAlignment; + + int __refCount; + + bool __changed; + + bool __asAspectRatio; + bool __checkedStyle; + + int __verticalExtent; + int __insideOneLineTextHeight; + int __insideTwoLineTextHeight; + + int __selectBackgroundMargin; + int __itemTextHorizontalMargin; + int __itemTextVerticalMargin; +}; // _IconListItemDrawingProperty + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ICON_LIST_ITEM_DRAWING_PROPERTY_H_ diff --git a/src/ui/inc/FUiCtrl_IconListItemProvider.h b/src/ui/inc/FUiCtrl_IconListItemProvider.h new file mode 100644 index 0000000..703c5ad --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListItemProvider.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IconListItemProvider.h + * @brief This is the header file for the _IconListItemProvider class. + * + * This header file contains the declarations of the _IconListItemProvider class. + */ + +#ifndef _FUI_CTRL_ICON_LIST_PROVIDER_H_ +#define _FUI_CTRL_ICON_LIST_PROVIDER_H_ + +// Includes +#include +#include +// forward declarations +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IconListImpl; + +class _IconListItemProvider + : public IIconListViewItemProvider +{ +public: + _IconListItemProvider(_IconListImpl* pIconList); + virtual ~_IconListItemProvider(void); + + int GetItemCount(void); + IconListViewItem* CreateItem(int index); + bool DeleteItem(int index, IconListViewItem* pItem); + +private: + _IconListItemProvider(const _IconListItemProvider& rhs); + _IconListItemProvider& operator =(const _IconListItemProvider& rhs); + +private: + _IconListImpl* __pIconListImpl; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_ICON_LIST_PROVIDER_H_ diff --git a/src/ui/inc/FUiCtrl_IconListItemProviderAdaptor.h b/src/ui/inc/FUiCtrl_IconListItemProviderAdaptor.h new file mode 100644 index 0000000..3396908 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListItemProviderAdaptor.h @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListItemProviderAdaptor.h + * @brief This is the header file for the _IconListItemProviderAdaptor class. + */ + +#ifndef _FUI_CTRL_INTERNAL_ICON_LIST_ITEM_PROVIDER_ADAPTOR_H_ +#define _FUI_CTRL_INTERNAL_ICON_LIST_ITEM_PROVIDER_ADAPTOR_H_ + +#include + +#include "FUiCtrl_IListItemProviderAdaptor.h" + +namespace Tizen { namespace Ui +{ + +namespace Animations +{ +class _VisualElement; +} // Tizen::Ui::Animations + +namespace Controls +{ + +class _IconListItemProviderAdaptor + : public _IListItemProviderAdaptor +{ +// Lifecycle +public: + _IconListItemProviderAdaptor(void); + + virtual ~_IconListItemProviderAdaptor(void); + +// Operation + _IListItemCommon* GetBlankItem(void) const; + +// Accessor + virtual void SetItemProvider(void* pProvider); + + virtual _IListItemCommon* LoadItem(int groupIndex, int itemIndex); + + virtual result UnloadItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex); + + virtual int GetItemCount(int groupIndex = 0) const; + + virtual int GetGroupCount(void) const; + + virtual result DeleteItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex); + + void SetVisualElement(Tizen::Ui::Animations::_VisualElement* pRoot); + +private: + _IconListItemProviderAdaptor(const _IconListItemProviderAdaptor& rhs); + _IconListItemProviderAdaptor& operator =(const _IconListItemProviderAdaptor& rhs); + +// Attribute +private: + static const int DEFAULT_GROUP_INDEX = 0; + static const int DEFAULT_GROUP_COUNT = 1; + static const int GROUP_TITLE_INDEX = -1; + + IIconListViewItemProvider* __pItemProvider; + + _IListItemCommon* __pBlankItem; + + Tizen::Ui::Animations::_VisualElement* __pRoot; + +}; // _IconListItemProviderAdaptor + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_ICON_LIST_ITEM_PROVIDER_ADAPTOR_H_ diff --git a/src/ui/inc/FUiCtrl_IconListPresenter.h b/src/ui/inc/FUiCtrl_IconListPresenter.h new file mode 100644 index 0000000..8294a4b --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListPresenter.h @@ -0,0 +1,442 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListPresenter.h + * @brief This is the header file for the _IconListPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_ICON_LIST_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_ICON_LIST_PRESENTER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FUi_ControlImpl.h" +#include "FUi_UiTouchEvent.h" +#include "FUiCtrl_FlickAnimation.h" +#include "FUiCtrl_IconListUtils.h" +#include "FUiCtrl_IconListViewItemEventArg.h" +#include "FUiCtrl_IScrollEventListener.h" + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IconListItem; +class _IconListItemDrawingProperty; +class _IconListItemProviderAdaptor; +class _IconListView; +class _IListItemProviderAdaptor; +class _ListViewModel; + +class _IconListPresenter + : public Tizen::Base::Object + , public Tizen::Base::Runtime::ITimerEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IScrollEventListener +{ +// Lifecycle +public: + virtual ~_IconListPresenter(void); + + static _IconListPresenter* CreateInstanceN(_IconListView& pIconListView); + +// Operations +public: + result Draw(void); + +// Accessor +public: + result SetItemProvider(const IIconListViewItemProvider& provider); + + result RegisterItemProviderAdaptor(_IListItemProviderAdaptor* pItemProviderAdaptor); + + result SetScrollDirection(IconListViewScrollDirection scrollDirection); + + result SetTopMargin(int value); + + int GetTopMargin(void) const; + + result SetBottomMargin(int value); + + int GetBottomMargin(void) const; + + result SetLeftMargin(int value); + + int GetLeftMargin(void) const; + + result SetRightMargin(int value); + + int GetRightMargin(void) const; + + result SetItemSpacing(int horizontalSpacing, int verticalSpacing); + + int GetItemHorizontalSpacing(void) const; + + int GetItemVerticalSpacing(void) const; + + void SetUseCheckedStyle(bool checkedStyle); + + result SetItemChecked(int index, bool check); + + bool IsItemChecked(int index) const; + + int GetItemIndexFromPosition(int x, int y) const; + + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + + result SetTextHorizontalAlignment(HorizontalAlignment alignment); + + result SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment); + + HorizontalAlignment GetTextHorizontalAlignment(void) const; + + IconListViewItemTextVerticalAlignment GetTextVerticalAlignment(void) const; + + result SetItemTextColor(IconListViewItemDrawingStatus status, const Tizen::Graphics::Color& color); + + const Tizen::Graphics::Color GetItemTextColor(IconListViewItemDrawingStatus status) const; + + result SetItemTextSize(int size); + + int GetItemTextSize(void) const; + + result SetCheckBoxPosition(IconListViewCheckBoxPosition position); + + IconListViewCheckBoxPosition GetCheckBoxPosition(void) const; + + result SetTouchAnimationEnabled(bool enable); + + bool IsTouchAnimationEnabled(void) const; + + result ScrollToItem(int index); + + result ScrollByPixel(int pixel); + + result RefreshList(int index, ListRefreshType type); + + result UpdateList(void); + + result SetItemBitmapBounds(const Tizen::Graphics::Rectangle& bounds); + + const Tizen::Graphics::Rectangle GetItemBitmapBounds(void) const; + + result GetItemBitmapSize(int& width, int& height) const; + + const Tizen::Graphics::Dimension GetItemBitmapSize(void) const; + + result SetItemSize(const Tizen::Graphics::Dimension& size); + + result GetItemSize(int& width, int& height) const; + + const Tizen::Graphics::Dimension GetItemSize(void) const; + + result SetMagneticScrollSize(int scrollSize); + + int GetMagneticScrollSize(void) const; + + void SetItemCountPerAxis(int itemCountPerAxis); + + int GetItemCountPerAxis(void) const; + + result SetItemLayoutHorizontalAlignment(HorizontalAlignment alignment); + + result SetItemLayoutVerticalAlignment(VerticalAlignment alignment); + + HorizontalAlignment GetItemLayoutHorizontalAlignment(void) const; + + VerticalAlignment GetItemLayoutVerticalAlignment(void) const; + + result SetItemBorderStyle(IconListViewItemBorderStyle borderStyle); + + IconListViewItemBorderStyle GetItemBorderStyle(void) const; + + _IconListItemDrawingProperty* GetItemDrawingProperty(void) const; + + void ClearVisualElement(void); + + result SetNonSlidableList(void); + + result AddItem(_IconListItem* pItem); + + result InsertItemAt(int index, _IconListItem* pItem); + + result SetItemAt(int index, _IconListItem* pItem); + + result RemoveItemAt(int index); + + result RemoveAllItems(void); + + void SetItemBitmapAsAspectRatio(bool isAspect); + + bool IsItemBitmapAsAspectRatio(void) const; + + result SetReorderModeEnabled(bool enable); + + void ScrollFadeOut(bool showEffect = false); + +// Inquiry +public: + // Tizen::Ui::_Control + virtual void OnBoundsChanged(void); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + + // Tizen::Ui::_IKeyEventPreviewer + virtual bool OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo); + virtual bool OnPreviewKeyReleased(const _Control& source, const _KeyInfo& keyInfo); + + // Tizen::Ui::_IKeyEventListener + virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo); + virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo); + + // Tizen::Ui::_INotificationEventPreviewer + virtual bool OnPreviewNotifiedN(const _Control& source, Tizen::Base::Collection::IList* pArgs); + + // Tizen::Ui::_INotificationEventListener + virtual bool OnNotifiedN(const _Control& source, Tizen::Base::Collection::IList* pArgs); + + // Tizen::Ui::_ITouchEventPreviewer + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + // Tizen::Ui::_ITouchEventListener + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + // GestureListener Callback API + bool OnFlickGestureDetected(bool isFlicked, const Tizen::Graphics::Point& flickPosition, int flickTime); + bool OnLongPressGestureDetected(void); + + // Tizen::Base::Runtime::ITimerEventListener + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + void OnVisibleStateChanged(void); + + // Tizen::Ui::_IScrollEventListener + virtual void OnScrollEndReached(Tizen::Ui::_Control& source, ScrollEndEvent type); + virtual void OnScrollPositionChanged(Tizen::Ui::_Control& source, int scrollPos); + virtual void OnScrollStopped(Tizen::Ui::_Control& source); + + // Osp::Ui::Animations::IAnimationTransactionEventListener + virtual void OnAnimationTransactionStarted(int transactionId); + virtual void OnAnimationTransactionStopped(int transactionId); + virtual void OnAnimationTransactionFinished(int transactionId); + +protected: + result Dispose(void); + result Initialize(void); + result InitializeFont(void); + +protected: + result DrawEmptyList(void); + result DrawHorizontalScrollList(void); + result DrawVerticalScrollList(void); + + void AdjustLayout(void); + void UpdateDrawnIndex(void); + + void HideItems(int startIndex, int endIndex); + + result RedrawItem(int index, float ratio = 1.0f, bool doShow = true, float checkRatio = 1.0f); + + result FireIconListViewItemEvent(_IconListViewItemEventType eventType, int index, int arg); + result FireScrollEndReachedEvent(ScrollEndEvent type); + result FireScrollPositionChangedEvent(int scrollPosition); + result FireScrollStoppedEvent(); + result FireScrollEvent(); + + bool SetScrollPosition(int position, bool enableFadeEffect = true); + + int GetMagneticScrollPosition(void) const; + + void TranslateIconListItemPosition(int& x, int& y); + + Tizen::Graphics::Rectangle GetItemBounds(int index) const; + + // visual interaction animation + void AddAnimation(_IconListItem& item, int index, int delay = 0); + void RemoveAnimation(_IconListItem& item, int index); + void MoveAnimation(_IconListItem& item, Tizen::Graphics::FloatRectangle& bounds, int delay = 0); + void MoveAnimation(_IconListItem& item, Tizen::Graphics::FloatRectangle& bounds, int delay, bool fadeIn); + void MoveAnimation(_IconListItem& item, Tizen::Graphics::FloatRectangle& startBounds, Tizen::Graphics::FloatRectangle& endBounds, int delay = 0); + void RemoveAllAnimation(_IconListItem& item); + + void MoveForward(int index); + void MoveBackward(int index); + bool IsAnimationRunning(int transactionId); + + void InitializeAccessibilityElement(void); + void AddAccessibilityElement(_IconListItem& item, const Tizen::Graphics::Rectangle& rect); + void RemoveAllAccessibilityElements(void); + +private: + _IconListPresenter(_IconListView* pIconListView, _ListViewModel* pListModel); + _IconListPresenter(const _IconListPresenter& rhs); + _IconListPresenter& operator =(const _IconListPresenter& rhs); + + virtual bool OnTouchActionActivated(const _Control& source, const _TouchInfo& touchinfo); + +private: + void ProcessAfterTouchRelease(int index); + void FireEventAfterTouchRelease(int index); + + void PrepareReordering(void); + void DoReordering(const Tizen::Graphics::Point& movedPosition); + void CheckAndReorderItem(int movedX, int movedY); + void SwapReorderedItems(int toIndex, bool singleItemChanged); + void FinishReordering(void); + void ClearReorderingInformation(void); + + result StartSelectionAnimationTimer(void); + result ResetSelectionAnimationTimer(void); + + result StartCheckAnimationTimer(void); + result ResetCheckAnimationTimer(void); + + result StartTouchActionTimer(void); + result ResetTouchActionTimer(void); + + result StartFlickAnimationTimer(void); + result ResetFlickAnimationTimer(void); + void StartFlickAnimation(void); + + result StartMagneticScrollTimer(void); + result ResetMagneticScrollTimer(void); + + result StartReorderScrollTimer(void); + result ResetReorderScrollTimer(void); + void StartReorderScrollAnimation(void); + + result StartAnimationTimer(int delay); + result ResetAnimationTimer(void); + +// Attribute +private: + static const int DEFAULT_GROUP_INDEX = 0; + static const int INVALID_INDEX = -1; + static const int ITEM_CACHE_SIZE_MULTIPLIER = 5; + static const int MINIMUM_FLICK_EFFECT_TIME = 80; + static const int FLICK_ANIMATION_TIMER_PERIOD = 10; + static const int MAGNETIC_SCROLL_TIMER_PERIOD = 10; + static const int SELECTION_ANIMATION_TIMER_PERIOD = 30; + static const int TOUCH_ACTION_TIMER_PERIOD = 100; + static const int REORDER_SCROLL_TIMER_PERIOD = 20; + static const int REORDER_SCROLL_ANIMATION_DISTANCE = 10; + static const int ITEM_ANIMATION_DURATION = 333; + static const int ITEM_ANIMATION_DELAY = 334; + static const int MOVE_ITEM_ANIMATION_DURATION = 500; + static const int MOVE_ITEM_ANIMATION_DELAY = 167; + static const int SCREEN_WIDTH = 480; + static const int SCREEN_HEIGHT = 800; + static const int NEEDED_FLICK_COUNT_FOR_FINGER_FASTSCROLL = 3; + static const int OVERSCROLLING_MAX_DISTANCE = 400; + + _ListViewModel* __pListModel; + _IconListView* __pIconListView; + _IListItemProviderAdaptor* __pItemProviderAdaptor; + Tizen::Graphics::Color __backgroundColor; + Tizen::Ui::_TouchInfo __currentTouchInfo; + int __selectedOverlayBitmapId; + int __selectedIndex; + int __checkedIndex; + int __highlightedIndex; + int __firstDrawnIndex; + int __lastDrawnIndex; + IconListViewScrollDirection __scrollDirection; + int __topMargin; + int __bottomMargin; + int __leftMargin; + int __rightMargin; + int __horizontalSpacing; + int __verticalSpacing; + int __magneticScrollSize; + int __itemCountPerAxis; + HorizontalAlignment __itemHorizontalAlignment; + VerticalAlignment __itemVerticalAlignment; + int __scrollPosition; + int __unitScrollLength; + int __scrollLength; + int __unitLengthOfAxis; + int __startPosOfAxis; + int __endPosOfAxis; + _IconListItemDrawingProperty* __pItemDrawingProperty; + Tizen::Base::Runtime::Timer* __pSelectionAnimationTimer; + Tizen::Base::Runtime::Timer* __pCheckAnimationTimer; + Tizen::Base::Runtime::Timer* __pTouchActionTimer; + Tizen::Base::Runtime::Timer* __pFlickAnimationTimer; + Tizen::Base::Runtime::Timer* __pMagneticScrollTimer; + Tizen::Base::Runtime::Timer* __pAnimationTimer; + _FlickAnimation __flickAnimation; + _IconListUtils::TouchAnimation __touchAnimation; + _IconListUtils::MagneticScrollAnimation __magneticScrollAnimation; + _IconListUtils::CheckAnimation __checkAnimation; + bool __isTouchAnimationEnabled; + bool __previousTouchAnimatinEnabled; + bool __isLayoutChanged; + bool __isTouchPressed; + bool __onDrawing; + bool __requireNextDrawing; + bool __alreadyDrawn; + bool __enableCustomItemProviderAdaptor; + bool __listStatusChanged; + bool __needBaseCanvas; + bool __isSelectionDelayed; + + Tizen::Ui::Animations::_VisualElement* __pRemoveItemVE; + Tizen::Ui::Animations::_VisualElement* __pEmptyListVE; + Tizen::Ui::Animations::_VisualElement* __pVE; + + // reorder + bool __onReordering; + int __reorderFromIndex; + int __reorderToIndex; + Tizen::Graphics::Point __lastReorderedPosition; + Tizen::Graphics::Point __lastReorderedDifferences; + Tizen::Graphics::FloatRectangle __reorderItemBounds; + Tizen::Base::Runtime::Timer* __pReorderScrollTimer; + int __reorderScrollAnimationDistance; + int __scrollPositionBeforeScrollAnimation; + + int __flickCount; + bool __isFlickDown; + + int __animationItemIndex; + int __addTransactionId; + int __removeTransactionId; + int __moveTransactionId; + +}; // _IconListPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ICON_LIST_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_IconListUtils.h b/src/ui/inc/FUiCtrl_IconListUtils.h new file mode 100644 index 0000000..6a636af --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListUtils.h @@ -0,0 +1,114 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListUtils.h + * @brief This is the header file for the _IconListUtils. + */ + +#ifndef _FUI_CTRL_INTERNAL_ICON_LIST_UTILS_H_ +#define _FUI_CTRL_INTERNAL_ICON_LIST_UTILS_H_ + +#include + +#include "FUiCtrl_ListItemCommon.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +namespace _IconListUtils +{ + +static const int MAGNETIC_SCROLL_EFFECT_DIVIDER = 5; + +class TouchAnimation +{ +public: + TouchAnimation(void); + + virtual ~TouchAnimation(void); + + bool GetTouchAnimationFrame(float& ratio); + + float GetCurrentAnimationFrame(void) const; + + void StartAnimation(void); + +private: + TouchAnimation(const TouchAnimation& rhs); + TouchAnimation& operator =(const TouchAnimation& rhs); + +private: + static const int FRAME_COUNT = 16; + static const float FRAME_RATIO[FRAME_COUNT]; + int __frame; +}; // _TouchAnimation + +class MagneticScrollAnimation +{ +public: + MagneticScrollAnimation(void); + + virtual ~MagneticScrollAnimation(void); + + bool GetMagneticScrollAnimationFrame(int& dif); + + void StartAnimation(int scroll); + +private: + MagneticScrollAnimation(const MagneticScrollAnimation& rhs); + MagneticScrollAnimation& operator =(const MagneticScrollAnimation& rhs); + +private: + int __scroll; +}; // _MagneticScrollAnimation + +class CheckAnimation +{ +public: + CheckAnimation(void); + + virtual ~CheckAnimation(void); + + bool GetCheckAnimationFrame(float& ratio); + + float GetCurrentAnimationFrame(void) const; + + void StartAnimation(void); + +private: + CheckAnimation(const CheckAnimation& rhs); + CheckAnimation& operator =(const CheckAnimation& rhs); + +private: + static const int FRAME_COUNT = 5; + int __frame; +}; // _CheckAnimation + +class EnumConverter +{ +public: + static ListItemState ConvertIconListViewItemDrawingStatusToListItemState(IconListViewItemDrawingStatus status); + + static IconListViewItemDrawingStatus ConvertListItemStateToIconListViewItemDrawingStatus(ListItemState state); +}; // _EnumConverter + +} // Tizen::Ui::Controls::_IconListUtils + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ICON_LIST_UTILS_H_ diff --git a/src/ui/inc/FUiCtrl_IconListView.h b/src/ui/inc/FUiCtrl_IconListView.h new file mode 100644 index 0000000..fb1d96f --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListView.h @@ -0,0 +1,380 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListView.h + * @brief This is the header file for the _IconListView class. + */ + +#ifndef _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_H_ +#define _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_H_ + +#include +#include +#include +#include +#include +#include + +#include "FUi_Control.h" +#include "FUi_ITouchFlickGestureEventListener.h" +#include "FUi_ITouchLongPressGestureEventListener.h" +#include "FUiCtrl_Scroll.h" + +namespace Tizen { namespace Ui +{ +class _TouchFlickGestureDetector; +class _TouchLongPressGestureDetector; + +namespace Animations +{ +class _VisualElement; +} // Tizen::Ui::Animations + +namespace Controls +{ +class IIconListViewItemProvider; +class _IconListPresenter; +class _IconListItem; +class _IIconListItemEventListener; +class _IListItemProviderAdaptor; +class _UiIconListItemEvent; +class _UiScrollEvent; + +class _OSP_EXPORT_ _IconListView + : public _Control + , public _ITouchFlickGestureEventListener + , public _ITouchLongPressGestureEventListener + , public _IPropertyChangeEventListener + , public Tizen::Ui::Animations::IAnimationTransactionEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _ITouchGestureEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ + DECLARE_CLASS_BEGIN(_IconListView, _Control); + DECLARE_PROPERTY("textColorOfEmptyList", GetPropertyTextColorOfEmptyList, SetPropertyTextColorOfEmptyList); + DECLARE_PROPERTY("textOfEmptyList", GetPropertyTextOfEmptyList, SetPropertyTextOfEmptyList); + DECLARE_PROPERTY("itemTextSize", GetPropertyItemTextSize, SetPropertyItemTextSize); + DECLARE_PROPERTY("textHorizontalAlignment", GetPropertyTextHorizontalAlignment, SetPropertyTextHorizontalAlignment); + DECLARE_PROPERTY("textVerticalAlignment", GetPropertyTextVerticalAlignment, SetPropertyTextVerticalAlignment); + DECLARE_PROPERTY("checkBoxPosition", GetPropertyCheckBoxPosition, SetPropertyCheckBoxPosition); + DECLARE_PROPERTY("touchAnimationEnabled", GetPropertyTouchAnimationEnabled, SetPropertyTouchAnimationEnabled); + DECLARE_PROPERTY("itemLayoutHorizontalAlignment", GetPropertyItemLayoutHorizontalAlignment, SetPropertyItemLayoutHorizontalAlignment); + DECLARE_PROPERTY("itemLayoutVerticalAlignment", GetPropertyItemLayoutVerticalAlignment, SetPropertyItemLayoutVerticalAlignment); + DECLARE_PROPERTY("itemBorderStyle", GetPropertyItemBorderStyle, SetPropertyItemBorderStyle); + DECLARE_PROPERTY("magneticScrollSize", GetPropertyMagneticScrollSize, SetPropertyMagneticScrollSize); + DECLARE_CLASS_END(); + + // Properties + result SetPropertyTextColorOfEmptyList(const Variant& color); + Variant GetPropertyTextColorOfEmptyList(void) const; + + result SetPropertyTextOfEmptyList(const Variant& text); + Variant GetPropertyTextOfEmptyList(void) const; + + result SetPropertyItemTextSize(const Variant& size); + Variant GetPropertyItemTextSize(void) const; + + result SetPropertyTextHorizontalAlignment(const Variant& alignment); + Variant GetPropertyTextHorizontalAlignment(void) const; + + result SetPropertyTextVerticalAlignment(const Variant& alignment); + Variant GetPropertyTextVerticalAlignment(void) const; + + result SetPropertyCheckBoxPosition(const Variant& position); + Variant GetPropertyCheckBoxPosition(void) const; + + result SetPropertyTouchAnimationEnabled(const Variant& enabled); + Variant GetPropertyTouchAnimationEnabled(void) const; + + result SetPropertyItemLayoutHorizontalAlignment(const Variant& alignment); + Variant GetPropertyItemLayoutHorizontalAlignment(void) const; + + result SetPropertyItemLayoutVerticalAlignment(const Variant& alignment); + Variant GetPropertyItemLayoutVerticalAlignment(void) const; + + result SetPropertyItemBorderStyle(const Variant& style); + Variant GetPropertyItemBorderStyle(void) const; + + result SetPropertyMagneticScrollSize(const Variant& alignment); + Variant GetPropertyMagneticScrollSize(void) const; + +// Lifecycle +public: + virtual ~_IconListView(void); + + static _IconListView* CreateIconListViewN(IconListViewStyle style = ICON_LIST_VIEW_STYLE_NORMAL); + + result Dispose(void); + +// Operations +public: + result Initialize(_IconListPresenter& presenter); + +// Accessor +public: + result SetItemProvider(const IIconListViewItemProvider& provider); + + result RegisterItemProviderAdaptor(_IListItemProviderAdaptor* pItemProviderAdaptor); + + result AddIconListItemEventListener(const _IIconListItemEventListener& listener); + + result RemoveIconListItemEventListener(const _IIconListItemEventListener& listener); + + result AddScrollEventListener(const _IScrollEventListener& listener); + + result RemoveScrollEventListener(const _IScrollEventListener& listener); + + result SetStyle(IconListViewStyle style); + + IconListViewStyle GetStyle(void) const; + + result SetScrollDirection(IconListViewScrollDirection scrollDirection); + + result SetScrollStyle(IconListViewScrollStyle scrollStyle); + + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + const Tizen::Graphics::Bitmap* GetBackgroundBitmap(void) const; + + result SetMargin(MarginType type, int value); + + int GetMargin(MarginType type) const; + + result SetItemSpacing(int horizontalSpacing, int verticalSpacing); + + int GetItemHorizontalSpacing(void) const; + + int GetItemVerticalSpacing(void) const; + + result SetItemChecked(int index, bool check); + + bool IsItemChecked(int index) const; + + int GetItemIndexFromPosition(int x, int y) const; + + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + + result SetTextHorizontalAlignment(HorizontalAlignment alignment); + + result SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment); + + HorizontalAlignment GetTextHorizontalAlignment(void) const; + + IconListViewItemTextVerticalAlignment GetTextVerticalAlignment(void) const; + + result SetTextOfEmptyList(const Tizen::Base::String& text); + + const Tizen::Base::String GetTextOfEmptyList(void) const; + + result SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + const Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + result SetTextSizeOfEmptyList(int size); + + int GetTextSizeOfEmptyList(void) const; + + result SetItemTextColor(IconListViewItemDrawingStatus status, const Tizen::Graphics::Color& color); + + const Tizen::Graphics::Color GetItemTextColor(IconListViewItemDrawingStatus status) const; + + result SetItemTextSize(int size); + + int GetItemTextSize(void) const; + + result SetCheckBoxPosition(IconListViewCheckBoxPosition position); + + IconListViewCheckBoxPosition GetCheckBoxPosition(void) const; + + result SetTouchAnimationEnabled(bool enable); + + bool IsTouchAnimationEnabled(void) const; + + result ScrollToItem(int index); + + result ScrollByPixel(int pixel); + + result RefreshList(int index, ListRefreshType type); + + result UpdateList(void); + + result SetItemBitmapBounds(const Tizen::Graphics::Rectangle& bounds); + + const Tizen::Graphics::Rectangle GetItemBitmapBounds(void) const; + + result GetItemBitmapSize(int& width, int& height) const; + + const Tizen::Graphics::Dimension GetItemBitmapSize(void) const; + + result SetItemSize(const Tizen::Graphics::Dimension& size); + + result GetItemSize(int& width, int& height) const; + + const Tizen::Graphics::Dimension GetItemSize(void) const; + + result SetMagneticScrollSize(int scrollSize); + + int GetMagneticScrollSize(void) const; + + int GetItemCountPerAxis(void) const; + + result SetItemLayoutHorizontalAlignment(HorizontalAlignment alignment); + + result SetItemLayoutVerticalAlignment(VerticalAlignment alignment); + + HorizontalAlignment GetItemLayoutHorizontalAlignment(void) const; + + VerticalAlignment GetItemLayoutVerticalAlignment(void) const; + + result SetItemBorderStyle(IconListViewItemBorderStyle borderStyle); + + IconListViewItemBorderStyle GetItemBorderStyle(void) const; + + result SetBitmapOfEmptyList(const Tizen::Graphics::Bitmap* pBitmap); + + const Tizen::Graphics::Bitmap* GetBitmapOfEmptyList(void) const; + + result SetNonSlidableList(void); + + result AddItem(_IconListItem* pItem); + + result InsertItemAt(int index, _IconListItem* pItem); + + result SetItemAt(int index, _IconListItem* pItem); + + result RemoveItemAt(int index); + + result RemoveAllItems(void); + + result SetScroll(const Tizen::Graphics::Rectangle& bounds, _ScrollDirection scrollDirection); + + _Scroll* GetScroll(void) const; + + void SetItemBitmapAsAspectRatio(bool isAspect); + + bool IsItemBitmapAsAspectRatio(void) const; + + _UiIconListItemEvent* GetIconListItemEvent(void) const; + + _UiScrollEvent* GetScrollEvent(void) const; + + // Event handling APIs + _TouchLongPressGestureDetector* GetLongPressGesture(void) const; + result SetLongPressGesture(_TouchLongPressGestureDetector* pLongPress); + _TouchFlickGestureDetector* GetFlickGesture(void) const; + result SetFlickGesture(_TouchFlickGestureDetector* pFlick); + + result SetReorderModeEnabled(bool enable); + bool IsInReorderingMode(void) const; + +// Inquiry +public: + // Tizen::Ui::_Control + virtual void OnBoundsChanged(void); + virtual void OnDraw(void); + virtual void OnAncestorVisibleStateChanged(const _Control& control); + virtual void OnAncestorEnableStateChanged(const _Control& control); + virtual void OnChangeLayout(_ControlOrientation orientation); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + + // Tizen::Ui::_IKeyEventListenerPreviewer + virtual bool OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo); + virtual bool OnPreviewKeyReleased(const _Control& source, const _KeyInfo& keyInfo); + + // Tizen::Ui::_IKeyEventListener + virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo); + virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo); + + // Tizen::Ui::_INotificationEventPreviewer + virtual bool OnPreviewNotifiedN(const _Control& source, Tizen::Base::Collection::IList* pArgs); + + // Tizen::Ui::_INotificationEventListener + virtual bool OnNotifiedN(const _Control& source, Tizen::Base::Collection::IList* pArgs); + + // Tizen::Ui::_ITouchEventPreviewer + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + // Tizen::Ui::_ITouchEventListener + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + // GestureListener Callback API + virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture); + virtual bool OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture); + virtual bool OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture); + virtual bool OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture); + + // data binding event listener + virtual void OnPropertyChanging(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty); + virtual void OnPropertyChanged(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty); + + virtual void OnVisibleStateChanged(void); + + // Tizen::Ui::_IScrollEventListener + virtual void OnScrollEndReached(Tizen::Ui::_Control& source, ScrollEndEvent type); + virtual void OnScrollPositionChanged(Tizen::Ui::_Control& source, int scrollPos); + virtual void OnScrollStopped(Tizen::Ui::_Control& source); + + // Tizen::Ui::Animations::IAnimationTransactionEventListener + virtual void OnAnimationTransactionStarted(int transactionId); + virtual void OnAnimationTransactionStopped(int transactionId); + virtual void OnAnimationTransactionFinished(int transactionId); + +private: + _IconListView(void); + _IconListView(const _IconListView& rhs); + _IconListView& operator =(const _IconListView& rhs); + +// Attribute +private: + _IconListPresenter* __pIconListPresenter; + + _Scroll* __pScroll; + + _UiIconListItemEvent* __pIconListItemEvent; + + _UiScrollEvent* __pScrollEvent; + + // Gesture Event + _TouchFlickGestureDetector* __pGestureFlick; + _TouchLongPressGestureDetector* __pGestureLongPress; + + IconListViewStyle __style; + + IconListViewScrollStyle __scrollStyle; + + Tizen::Graphics::Bitmap* __pBackgroundBitmap; + + Tizen::Base::String __textOfEmptyList; + + Tizen::Graphics::Color __textColorOfEmptyList; + + int __textSizeOfEmptyList; + + Tizen::Graphics::Bitmap* __pBitmapOfEmptyList; + + bool __reorderEnabled; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_H_ diff --git a/src/ui/inc/FUiCtrl_IconListViewImpl.h b/src/ui/inc/FUiCtrl_IconListViewImpl.h new file mode 100644 index 0000000..8defe13 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListViewImpl.h @@ -0,0 +1,203 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListViewImpl.h + * @brief This is the header file for the _IconListViewImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_IMPL_H_ +#define _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_IMPL_H_ + +#include + +#include "FUi_ControlImpl.h" +#include "FUiCtrl_IIconListItemEventListener.h" +#include "FUiCtrl_IScrollEventListener.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IconListView; +class _IconListViewItemEvent; +class _IconListViewItemEventArg; +class _ScrollEvent; + +class _IconListViewImpl + : public _ControlImpl + , public _IIconListItemEventListener + , public _IScrollEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + virtual ~_IconListViewImpl(void); + + static _IconListViewImpl* CreateIconListViewImplN(IconListView* pIconListView); + + virtual const char* GetPublicClassName(void) const; + + virtual IconListView& GetPublic(void); + +// Operations +public: + result Initialize(IconListView* pIconListView, const Tizen::Graphics::Dimension& itemBitmapSize, IconListViewStyle style, IconListViewScrollDirection scrollDirection, IconListViewScrollStyle scrollStyle); + +// Accessor +public: + result SetItemProvider(IIconListViewItemProvider& provider); + + void AddIconListViewItemEventListener(IIconListViewItemEventListener& listener); + + void RemoveIconListViewItemEventListener(IIconListViewItemEventListener& listener); + + void AddScrollEventListener(IScrollEventListener& listener); + + void RemoveScrollEventListener(IScrollEventListener& listener); + + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + result SetMargin(MarginType type, int value); + + int GetMargin(MarginType type) const; + + result SetItemSpacing(int horizontalSpacing, int verticalSpacing); + + int GetItemHorizontalSpacing(void) const; + + int GetItemVerticalSpacing(void) const; + + result SetItemChecked(int index, bool check); + + bool IsItemChecked(int index) const; + + int GetItemIndexFromPosition(int x, int y) const; + + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + + result SetTextHorizontalAlignment(HorizontalAlignment alignment); + + result SetTextVerticalAlignment(IconListViewItemTextVerticalAlignment alignment); + + HorizontalAlignment GetTextHorizontalAlignment(void) const; + + IconListViewItemTextVerticalAlignment GetTextVerticalAlignment(void) const; + + result SetTextOfEmptyList(const Tizen::Base::String& text); + + Tizen::Base::String GetTextOfEmptyList(void) const; + + result SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + result SetItemTextColor(IconListViewItemDrawingStatus status, const Tizen::Graphics::Color& color); + + Tizen::Graphics::Color GetItemTextColor(IconListViewItemDrawingStatus status) const; + + result SetItemTextSize(int size); + + int GetItemTextSize(void) const; + + result SetCheckBoxPosition(IconListViewCheckBoxPosition position); + + IconListViewCheckBoxPosition GetCheckBoxPosition(void) const; + + result SetTouchAnimationEnabled(bool enable); + + bool IsTouchAnimationEnabled(void) const; + + result ScrollToItem(int index); + + result ScrollByPixel(int pixel); + + result RefreshList(int index, ListRefreshType type); + + result UpdateList(void); + + result GetItemBitmapSize(int& width, int& height) const; + + Tizen::Graphics::Dimension GetItemBitmapSize(void) const; + + result GetItemSize(int& width, int& height) const; + + Tizen::Graphics::Dimension GetItemSize(void) const; + + result SetMagneticScrollSize(int scrollSize); + + int GetMagneticScrollSize(void) const; + + int GetItemCountPerAxis(void) const; + + result SetItemLayoutHorizontalAlignment(HorizontalAlignment alignment); + + result SetItemLayoutVerticalAlignment(VerticalAlignment alignment); + + HorizontalAlignment GetItemLayoutHorizontalAlignment(void) const; + + VerticalAlignment GetItemLayoutVerticalAlignment(void) const; + + result SetItemBorderStyle(IconListViewItemBorderStyle borderStyle); + + IconListViewItemBorderStyle GetItemBorderStyle(void) const; + + result SetBitmapOfEmptyList(const Tizen::Graphics::Bitmap* pBitmap); + + result BeginReorderingMode(void); + + result EndReorderingMode(void); + + bool IsInReorderingMode(void) const; + +// Inquiry +public: + // _IIconListItemEventListener + virtual void OnIconListItemStateChanged(_IconListViewItemEventArg* pArg); + virtual void OnIconListViewOverlayBitmapSelected(_IconListViewItemEventArg* pArg); + virtual void OnIconListViewItemReordered(_IconListViewItemEventArg* pArg); + + // _IScrollEventListener + virtual void OnScrollEndReached(Tizen::Ui::_Control& source, ScrollEndEvent type); + virtual void OnScrollPositionChanged(Tizen::Ui::_Control& source, int scrollPos); + virtual void OnScrollStopped(Tizen::Ui::_Control& source); + +// Constants +public: + static _IconListViewImpl* GetInstance(IconListView& iconListView); + static const _IconListViewImpl* GetInstance(const IconListView& iconListView); + +// Lifecycle +protected: + result Dispose(void); + +private: + _IconListViewImpl(IconListView* pIconListView, _IconListView* pCore); + _IconListViewImpl(const _IconListViewImpl& rhs); + _IconListViewImpl& operator =(const _IconListViewImpl& rhs); + +// Attribute +private: + static const int ICONLISTVIEW_MAX_VIEW_COUNT = 256; + + _IconListView* __pIconListView; + _IconListViewItemEvent* __pIconListViewItemEvent; + _ScrollEvent* __pScrollEvent; +}; // _IconListViewImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_IconListViewItemEvent.h b/src/ui/inc/FUiCtrl_IconListViewItemEvent.h new file mode 100644 index 0000000..c6baac5 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListViewItemEvent.h @@ -0,0 +1,74 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListViewItemEvent.h + * @brief This is the header file for _IconListViewItemEvent class. + * + * This header file contains declaration of _IconListViewItemEvent class. + * The _IconListViewItemEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ + +#ifndef _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_ITEM_EVENT_H_ +#define _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_ITEM_EVENT_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class IconListView; + +// +// @class _IconListViewItemEvent +// @brief This class handles a item event. It is inherited from _Event class. +// +// The Window(root of all widgets) class has an instance of the ItemEvent class as a member variable. +// Applications can register item event listeners through it. When a item event occurred, +// the ItemEvent class finds listener and calls the appropriate listener's method. +// +class _IconListViewItemEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + _IconListViewItemEvent(void); + + // This is the default class destructor. + virtual ~_IconListViewItemEvent(void); + + result Construct(const IconListView& source); + +// Accessors +public: + const IconListView* GetSource(void) const; + +// Operations +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attributess +private: + IconListView* __pSource; +}; // _IconListViewItemEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_ITEM_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_IconListViewItemEventArg.h b/src/ui/inc/FUiCtrl_IconListViewItemEventArg.h new file mode 100644 index 0000000..a33e496 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListViewItemEventArg.h @@ -0,0 +1,102 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListViewItemEventArg.h + * @brief This is the header file for _IconListViewItemEventArg class. + * + * This header file contains declaration of _IconListViewItemEventArg class. + * + */ + +#ifndef _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_ITEM_EVENT_ARG_H_ +#define _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_ITEM_EVENT_ARG_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum _IconListViewItemEventType +{ + EVENT_TYPE_ITEM_SELECTED = 0, + EVENT_TYPE_OVERLAY_BITMAP_SELECTED, + EVENT_TYPE_ITEM_REORDERED +}; + +// +// @class _IconListViewItemEventArg +// @brief This class is used as the argument to item event listener. +// +// This class is used as the argument to item event listener. When an item event is generated +// (such as when a button is pressed) the ItemEvent calls ItemEventListener's OnItemStateChanged +// with an instance of this class as an argument. +// +// From this class, one can find out, the (event) source object and item event type. +// +class _IconListViewItemEventArg + : public Tizen::Base::Object + , public Tizen::Base::Runtime::IEventArg +{ +// Lifecycle +public: + _IconListViewItemEventArg(int index, _IconListViewItemEventType eventType); + + virtual ~_IconListViewItemEventArg(void); + +// Access +public: + int GetIndex(void) const; + + IconListViewItemStatus GetStatus(void) const; + + void SetStatus(const IconListViewItemStatus status); + + int GetOverlayBitmapId(void) const; + + void SetOverlayBitmapId(const int overlayBitmapId); + + int GetFromIndex(void) const; + + int GetToIndex(void) const; + + void SetToIndex(int toIndex); + + _IconListViewItemEventType GetEventType(void) const; + +// Attribute +private: + // The index of an item + int __itemIndex; + + int __toIndex; + + int __overlayBitmapId; + + // The status of an item + IconListViewItemStatus __itemStatus; + + _IconListViewItemEventType __eventType; +}; // _IconListViewItemEventArg + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_ITEM_EVENT_ARG_H_ diff --git a/src/ui/inc/FUiCtrl_IconListViewItemImpl.h b/src/ui/inc/FUiCtrl_IconListViewItemImpl.h new file mode 100644 index 0000000..7eb5c2e --- /dev/null +++ b/src/ui/inc/FUiCtrl_IconListViewItemImpl.h @@ -0,0 +1,62 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_IconListViewItemImpl.h + * @brief This is the header file for the _IconListViewItemImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_ITEM_IMPL_H_ +#define _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_ITEM_IMPL_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IconListItem; + +class _IconListViewItemImpl +{ +// Lifecycle +public: + virtual ~_IconListViewItemImpl(void); + + static _IconListViewItemImpl* CreateIconListViewItemImplN(IconListViewItem& pIconListViewItem, const Tizen::Graphics::Bitmap& bitmap, const Tizen::Base::String* pText, const Tizen::Graphics::Bitmap* pSelectedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap); + + result SetOverlayBitmap(int overlayBitmapId, const Tizen::Graphics::Bitmap* pOverlayBitmap, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment); + +private: + _IconListViewItemImpl(IconListViewItem* pIconListViewItem, _IconListItem* pItem); + _IconListViewItemImpl(const _IconListViewItemImpl& rhs); + _IconListViewItemImpl& operator =(const _IconListViewItemImpl& rhs); + +// Attribute +private: + friend class _IconListItemProviderAdaptor; + + IconListViewItem* __pIconListViewItem; + _IconListItem* __pIconListItem; +}; // _IconListViewItemImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_ICON_LIST_VIEW_ITEM_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_Indicator.h b/src/ui/inc/FUiCtrl_Indicator.h new file mode 100644 index 0000000..2189141 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Indicator.h @@ -0,0 +1,83 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Indicator.h + * @brief This is the header file for the %_Indicator class. + * + * This header file contains the declarations of the %_Indicator class. + */ +#ifndef _FUI_CTRL_INTERNAL_INDICATOR_H_ +#define _FUI_CTRL_INTERNAL_INDICATOR_H_ + +#include +#include "FUi_Control.h" +#include "FUi_EcoreEvas.h" + +namespace Tizen { namespace Ui { namespace Animations +{ +class VisualElementSurface; +}}} + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Form; + +class _Indicator + : public _Control + , public Tizen::Base::Runtime::ITimerEventListener +{ +public: + _Indicator(void); + virtual ~_Indicator(void); + + static _Indicator* CreateIndicator(void); + + result SetIndicatorShowState(bool state); + result SetIndicatorOpacity(_IndicatorOpacity opacity); + bool GetIndicatorShowState(void) const; + _IndicatorOpacity GetIndicatorOpacity(void) const; + result AddEvasObject(_Form* pForm); + result DeleteEvasObject(void); + result SetSurface(Tizen::Ui::Animations::VisualElementSurface* pSurface); + + virtual void OnChangeLayout(_ControlOrientation orientation); + virtual result OnAttachedToMainTree(void); + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + static void OnDisconnected(Ecore_Evas *pEe); + +private: + _Indicator(const _Indicator& value); + _Indicator& operator =(const _Indicator& value); + + Tizen::Graphics::Rectangle GetIndicatorBounds(void) const; + +private: + Evas_Object* __pPortraitIndicatorEvasObject; + Evas_Object* __pLandscapeIndicatorEvasObject; + Tizen::Base::Runtime::Timer* __pConnectionTimer; + Tizen::Ui::Animations::VisualElementSurface* __pPortraitSurface; + Tizen::Ui::Animations::VisualElementSurface* __pLandScapeSurface; + Tizen::Ui::Animations::VisualElementSurface* __pCurrentSurface; + Tizen::Ui::Animations::_VisualElement* __pVisualElement; + bool __showstate; + _IndicatorOpacity __opacity; + +}; // _Indicator + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_INDICATOR_H_ diff --git a/src/ui/inc/FUiCtrl_IndicatorManager.h b/src/ui/inc/FUiCtrl_IndicatorManager.h new file mode 100644 index 0000000..6f4ce46 --- /dev/null +++ b/src/ui/inc/FUiCtrl_IndicatorManager.h @@ -0,0 +1,95 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_IndicatorManager.h + * @brief This is the header file for the _IndicatorManager class. + * + * This header file contains the declarations of the %_IndicatorManager class. + */ + +#ifndef _FUI_CTRL_INTERNAL_INDICATOR_MANAGER_H_ +#define _FUI_CTRL_INTERNAL_INDICATOR_MANAGER_H_ + +namespace Tizen { namespace Ui { +class _Window; +}}; + +namespace Tizen { namespace Base { namespace Collection +{ +template class HashMapT; +}}} + +namespace Tizen { namespace Ui { namespace Animations { +class VisualElementSurface; +}}}; + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Form; + +typedef struct +{ + Evas_Object* pPortraitEvasObject; + Evas_Object* pLandscapeEvasObject; + Tizen::Ui::Animations::VisualElementSurface* pPortraitSurface; + Tizen::Ui::Animations::VisualElementSurface* pLandscapeSurface; + bool portraitSurfaceUsed; + bool landscapeSurfaceUsed; + _Form* pForm; +} IndicatorSurface ; + +enum _IndicatorOrientation +{ + _INDICATOR_ORIENTATION_PORTRAIT, + _INDICATOR_ORIENTATION_LANDSCAPE +}; + +class _IndicatorManager +{ +public: + static _IndicatorManager* GetInstance(void); + static void Initialize(void); + static void InitializeInstance(void); + static void ReleaseInstance(void); + + Tizen::Ui::Animations::VisualElementSurface* GetSurface(_Window* pWindow, _IndicatorOrientation orientation, _Form* pForm) const; + result ReleaseSurface(_Window* pWindow, _IndicatorOrientation orientation, Tizen::Ui::Animations::VisualElementSurface* pSurface); + + result AddWindow(_Window* pWindow); + result DeleteWindow(_Window* pWindow); + IndicatorSurface* MakeEvasSurfaceArrayN(_Window* pWindow); + bool IsFull(IndicatorSurface* pIndicatorSurfaceArray) const; + + Evas_Object* GetEvasObject(_Window* pWindow, _Form* pForm, _IndicatorOrientation orientation)const; + Tizen::Graphics::Dimension GetIndicatorSize(_IndicatorOrientation orientation) const; + +private: + ~_IndicatorManager(void); + _IndicatorManager(void); + + _IndicatorManager(const _IndicatorManager& value); + _IndicatorManager& operator =(const _IndicatorManager& value); + +private: + static _IndicatorManager* __pInstance; + + Tizen::Base::Collection::HashMapT __indicatorMap; +}; // _IndicatorManager + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_INDICATOR_MANAGER_H_ diff --git a/src/ui/inc/FUiCtrl_InputPad.h b/src/ui/inc/FUiCtrl_InputPad.h new file mode 100644 index 0000000..e5b8c0d --- /dev/null +++ b/src/ui/inc/FUiCtrl_InputPad.h @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_InputPad.h + * @brief This is the header file for the _InputPad class. + * + * This header file contains the declarations of the %_InputPad class. + */ + +#ifndef _FUI_CTRL_INTERNAL_INPUTPAD_H_ +#define _FUI_CTRL_INTERNAL_INPUTPAD_H_ + +#include + +#include "FUi_Control.h" +#include "FUi_UiTouchEvent.h" +#include "FUiCtrl_IInputPadEventListener.h" +#include "FUiCtrl_DateTimeDefine.h" + +namespace Tizen { namespace Ui { +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class _InputPadPresenter; + +class _InputPad + : public Tizen::Ui::_Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ +public: + _InputPad(void); + virtual ~_InputPad(void); + + result Construct(const Tizen::Graphics::Rectangle& bounds); + result SetInputPadEventListener(const _IInputPadEventListener& listener); + void SetInputPadStyle(const _InputPadStyle style); + Tizen::Base::String& GetAccessebilityElementMonthName(int number); + void SetFont(Tizen::Graphics::Font* pFont); + + virtual void OnBoundsChanged(void); + virtual void OnDraw(void); + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + +private: + _InputPad(const _InputPad&); + _InputPad& operator =(const _InputPad&); + + bool HasAccessibilityElement(void); + void SetAllAccessibilityElement(void); + void SetBoundsAllAccessibilityElement(void); + void RemoveAllAccessibilityElement(void); + void InitializeAccessebilityElementMonthNames(void); + +private: + _InputPadPresenter* __pInputPadPresenter; + Tizen::Base::String __pMonthNames[DATETIME_MONTH_MAX]; + Tizen::Base::Collection::LinkedListT __accessibilityElements; +}; // _InputPad + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_INPUTPAD_H_ diff --git a/src/ui/inc/FUiCtrl_InputPadPresenter.h b/src/ui/inc/FUiCtrl_InputPadPresenter.h new file mode 100644 index 0000000..ac7e0c7 --- /dev/null +++ b/src/ui/inc/FUiCtrl_InputPadPresenter.h @@ -0,0 +1,122 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_InputPadPresenter.h + * @brief This is the header file for the _InputPadPresenter class. + * + * This header file contains the declarations of the %_InputPadPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_INPUTPAD_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_INPUTPAD_PRESENTER_H_ + +#include + +#include "FUi_Control.h" +#include "FUiCtrl_IInputPadEventListener.h" +#include "FUiCtrl_DateTimeDefine.h" + +namespace Tizen { namespace Graphics { +class Font; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _InputPad; + +class _InputPadPresenter + : public Tizen::Base::Object +{ +public: + _InputPadPresenter(_InputPad* pInputPad); + virtual ~_InputPadPresenter(void); + + result Construct(const Tizen::Graphics::Rectangle& bounds); + + result LoadProperties(Tizen::Ui::_ControlOrientation orientation); + result LoadResource(void); + result InitializeTextObjects(void); + + void SetInputPadEventListener(const _IInputPadEventListener& listener); + result SetInputPadStyle(const _InputPadStyle style); + + _InputPadStyle GetInputPadStyle(void) const; + Tizen::Graphics::Rectangle GetButtonBounds(int index) const; + int GetReturnValue(int index) const; + + result Draw(void); + + void EnableLayoutChangedFlag(void); + + void SetFont(Tizen::Graphics::Font* pFont); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + +private: + result DrawAllButtons(Tizen::Graphics::Canvas& canvas); + result DrawButton(Tizen::Graphics::Canvas& canvas, int index); + result RefreshButton(int index); + int GetIndexFromTouchedPosition(const Tizen::Graphics::Point& point) const; + + _InputPadPresenter(const _InputPadPresenter&); + _InputPadPresenter& operator =(const _InputPadPresenter&); + +private: + _InputPad* __pInputPad; + _IInputPadEventListener* __pInputPadEventListener; + + Tizen::Graphics::Font* __pFont; + + Tizen::Graphics::Bitmap* __pKeypadBackgroundBitmap; + + Tizen::Graphics::Bitmap* __pKeypadButtonNormalPlainBitmap; + Tizen::Graphics::Bitmap* __pKeypadButtonPressedPlainBitmap; + + Tizen::Graphics::Bitmap* __pKeypadButtonNormalEffectBitmap; + Tizen::Graphics::Bitmap* __pKeypadButtonPressedEffectBitmap; + + Tizen::Graphics::_Text::TextObject __textObject; + Tizen::Graphics::_Text::TextObject __guideTextObject; + + _InputPadStyle __inputPadStyle; + + int __buttonWidth; + int __buttonHeight; + int __startX; + int __startY; + int __marginX; + int __marginY; + int __pressedIndex; + + bool __isLayoutChanged; + + static const int INPUTPAD_BUTTON_MAX = 12; + static const int INPUTPAD_BUTTON_COLUMN_MAX = 3; + static const int INPUTPAD_BUTTON_ROW_MAX = 4; + + static const int INPUTPAD_NUMBER_1 = 0; + static const int INPUTPAD_NUMBER_9 = 8; + static const int INPUTPAD_NUMBER_0 = 10; +}; // _InputPadPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_INPUTPAD_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_Keypad.h b/src/ui/inc/FUiCtrl_Keypad.h new file mode 100644 index 0000000..189c3f8 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Keypad.h @@ -0,0 +1,123 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_Keypad.h +* @brief This is the header file for the _Keypad class. +* +* This header file contains the declarations of the _Keypad class. +*/ +#ifndef _FUI_CTRL_INTERNAL_KEYPAD_H_ +#define _FUI_CTRL_INTERNAL_KEYPAD_H_ + +#include +#include "FUi_Window.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_IKeypadEventListener.h" +#include "FUiCtrl_ITextEventListener.h" +#include "FUiCtrl_TextEvent.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +struct _KeypadStyleInfo +{ + KeypadStyle keypadStyle; + bool textPredictionEnabled; + bool isNormalNumberStyle; + bool enterActionEnabled; + bool isLowerCaseModeEnabled; +}; + +class _OSP_EXPORT_ _Keypad + : virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer + , public Tizen::Ui::_Window + , public _IActionEventListener + , public _IKeypadEventListener +{ + DECLARE_CLASS_BEGIN(_Keypad, _Control); + DECLARE_PROPERTY("singleLineEnabled", GetPropertySingleLineEnabled, SetPropertySingleLineEnabled); + DECLARE_PROPERTY("text", GetPropertyText, SetPropertyText); + DECLARE_CLASS_END(); + + result SetPropertySingleLineEnabled(const Tizen::Ui::Variant& enabled); + Tizen::Ui::Variant GetPropertySingleLineEnabled(void) const; + + result SetPropertyText(const Tizen::Ui::Variant& text); + Tizen::Ui::Variant GetPropertyText(void) const; + +public: + static _Keypad* CreateKeypadN(void); + virtual ~_Keypad(void); + + result Initialize(int editStyle, _KeypadStyleInfo styleInfo, int limitLength, _Edit* pCallerEdit = null); + virtual void OnDraw(void); + + result SetSingleLineEnabled(bool enabled); + bool IsSingleLineEnabled(void) const; + + Tizen::Base::String GetText(void) const; + void SetText(const Tizen::Base::String& text); + + result AddTextEventListener(const _ITextEventListener& listener); + result RemoveTextEventListener(const _ITextEventListener& listener); + + virtual result OnAttachedToMainTree(void); + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + virtual void OnKeypadWillOpen(void); + virtual void OnKeypadOpened(void); + virtual void OnKeypadClosed(void); + virtual void OnKeypadBoundsChanged(void); + virtual void OnKeypadActionPerformed(CoreKeypadAction keypadAction); + virtual void OnChangeLayout(_ControlOrientation orientation); + virtual void OnNativeWindowActivated(void); + +#if defined(MULTI_WINDOW) + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); + virtual bool IsLayoutChangable(void) const; +#endif + + +private: + _Keypad(void); + _Keypad(const _Keypad&); + _Keypad& operator =(const _Keypad&); + + result Dispose(void); + result ChangeLayoutInternal(void); + Tizen::Graphics::Rectangle GetIndicatorBounds(void) const; + _Button* CreateButtonItemN(int actionId, const Tizen::Base::String& text); + _Toolbar* CreateHeaderForSIP(void); + +private: + bool __isInitialized; + bool __isSingleLineEnabled; + _Control* __pOwner; + _Edit* __pCallerEdit; + _Edit* __pChildEdit; + _Toolbar* __pHeaderForSIP; + Tizen::Base::String __text; + _TextEvent* __pTextEvent; + bool __isCommandButtonPressed; + bool __isPredictionWindowOpendInUSBMode; +}; // _Keypad + +} } } // Tizen::Ui::Controls +#endif // _FUI_CTRL_INTERNAL_KEYPAD_H_ diff --git a/src/ui/inc/FUiCtrl_KeypadEvent.h b/src/ui/inc/FUiCtrl_KeypadEvent.h new file mode 100644 index 0000000..a9642a3 --- /dev/null +++ b/src/ui/inc/FUiCtrl_KeypadEvent.h @@ -0,0 +1,114 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_KeypadEvent.h +* @brief This is the header file for _KeypadEvent class. +* +* This header file contains declaration of _KeypadEvent class. +* +*/ + +#ifndef _FUI_CTRL_KEYPAD_EVENT_H_ +#define _FUI_CTRL_KEYPAD_EVENT_H_ + +#include +#include +#include +#include "FUiCtrl_IKeypadEventListener.h" + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum CoreKeypadEventStatus +{ + CORE_KEYPAD_EVENT_STATUS_CREATED, + CORE_KEYPAD_EVENT_STATUS_OPEN, + CORE_KEYPAD_EVENT_STATUS_CLOSE, + CORE_KEYPAD_EVENT_STATUS_BOUNDS_CHANGED, + CORE_KEYPAD_EVENT_STATUS_ENTERACTION +}; + + +/** +* @class _KeypadEvent +* @brief This class handles a keypad event event. It is inherited from Event class. +* +*/ +class _KeypadEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_KeypadEvent(void); + + static _KeypadEvent* CreateInstanceN(const Tizen::Ui::_Control& source); + +// Accessors + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::_Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateKeypadEventArgN(CoreKeypadAction actionId, Tizen::Ui::Controls::CoreKeypadEventStatus status); + + // Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _KeypadEvent(const Tizen::Ui::_Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of _CustomItemEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + + //Attributess +private: + const Tizen::Ui::_Control* __pSource; +}; // _KeypadEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_KEYPAD_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_KeypadImpl.h b/src/ui/inc/FUiCtrl_KeypadImpl.h new file mode 100644 index 0000000..f93fec3 --- /dev/null +++ b/src/ui/inc/FUiCtrl_KeypadImpl.h @@ -0,0 +1,99 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_KeypadImpl.h +* @brief This is the header file for the _KeypadImpl class. +* +* This header file contains the declarations of the _KeypadImpl class. +*/ + +#ifndef _FUI_CTRL_INTERNAL_KEYPAD_IMPL_H_ +#define _FUI_CTRL_INTERNAL_KEYPAD_IMPL_H_ + +#include +#include "FUi_WindowImpl.h" +#include "FUiCtrl_ITextEventListener.h" +#include "FUiCtrl_Keypad.h" + +namespace Tizen { namespace Base { namespace Runtime +{ +class IEvent; +}}} // Tizen::Base::Runtime + +namespace Tizen { namespace Ui { namespace Controls +{ +class _PublicTextEvent; + +class _KeypadImpl + : virtual public Tizen::Base::Runtime::IEventListener + , public _WindowImpl + , public _ITextEventListener +{ + +public: + virtual ~_KeypadImpl(void); + + static _KeypadImpl* CreateKeypadImplN(Keypad* pControl); + static _KeypadImpl* GetInstance(Keypad& pKeypad); + static const _KeypadImpl* GetInstance(const Keypad& pKeypad); + + virtual const char* GetPublicClassName(void) const; + virtual const Keypad& GetPublic(void) const; + virtual Keypad& GetPublic(void); + virtual const _Keypad& GetCore(void) const; + virtual _Keypad& GetCore(void); + + result Initialize(KeypadStyle keypadStyle, KeypadInputModeCategory category, int limitLength, bool enabledTextPrediction = true); + + void SetTextPredictionEnabled(bool enable); + + bool IsTextPredictionEnabled(void) const; + + result SetSingleLineEnabled(bool enabled); + + bool IsSingleLineEnabled(void) const; + + result AddTextEventListener(Tizen::Ui::ITextEventListener& listener); + + result RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener); + + Tizen::Base::String GetText(void) const; + + void SetText(const Tizen::Base::String& text); + + virtual result OnAttachedToMainTree(void); + + virtual void OnTextValueChanged(const Tizen::Ui::_Control& source); + + virtual void OnTextValueChangeCanceled(const Tizen::Ui::_Control& source); + +private: + _KeypadImpl(Keypad* pPublic, _Keypad* pCore); + _KeypadImpl(const _KeypadImpl&); + _KeypadImpl& operator =(const _KeypadImpl&); + +private: + _Keypad* __pKeypad; + _KeypadStyleInfo __keypadStyleInfo; + int __limitLength; + Tizen::Base::Runtime::IEvent* __pTextEvent; + _PublicTextEvent* __pPublicTextEvent; +}; // _KeypadImpl + +} } } // OSp::Ui::Controls; + +#endif // _FUI_CTRL_INTERNAL_KEYPAD_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_Label.h b/src/ui/inc/FUiCtrl_Label.h new file mode 100644 index 0000000..6fc0473 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Label.h @@ -0,0 +1,147 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Label.h + * @brief This is the header file for the _Label class. + * + * This header file contains the declarations of the %_Label class. + */ +#ifndef _FUI_CTRL_INTERNAL_LABEL_H_ +#define _FUI_CTRL_INTERNAL_LABEL_H_ + +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class _LabelPresenter; + +/** + * @class _Label + * @brief + * @since 1.0 + * + * + * + * + */ + +class _OSP_EXPORT_ _Label + : public Tizen::Ui::_Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer +{ + DECLARE_CLASS_BEGIN(_Label, _Control); + DECLARE_PROPERTY("text", GetPropertyText, SetPropertyText); + DECLARE_PROPERTY("textColor", GetPropertyTextColor, SetPropertyTextColor); + DECLARE_PROPERTY("textSize", GetPropertyTextSize, SetPropertyTextSize); + DECLARE_CLASS_END(); + + result SetPropertyText(const Variant& text); + Variant GetPropertyText(void) const; + result SetPropertyTextColor(const Variant& color); + Variant GetPropertyTextColor(void) const; + result SetPropertyTextSize(const Variant& textSize); + Variant GetPropertyTextSize(void) const; + +public: + virtual ~_Label(void); + +public: + static _Label* CreateLabelN(void); + + virtual void OnDraw(void); + virtual result OnAttachedToMainTree(void); + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const _Control& control); + virtual void OnBoundsChanged(void); + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + virtual Tizen::Graphics::Dimension GetContentSize(void) const; + +public: + result SetText(const Tizen::Base::String& text); + Tizen::Base::String GetText(void) const; + + result SetTextConfig(int size, LabelTextStyle style); + int GetTextSize(void) const; + LabelTextStyle GetTextStyle(void) const; + + result SetTextHorizontalAlignment(HorizontalAlignment alignment); + HorizontalAlignment GetTextHorizontalAlignment(void) const; + result SetTextVerticalAlignment(VerticalAlignment alignment); + VerticalAlignment GetTextVerticalAlignment(void) const; + + result SetTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTextColor(void) const; + + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + Tizen::Graphics::Bitmap* GetBackgroundBitmap(void) const; + + result SetBackgroundEffectBitmap(const Tizen::Graphics::Bitmap& bitmap); + Tizen::Graphics::Bitmap* GetBackgroundEffectBitmap(void) const; + + unsigned long GetFontStyle(void) const; + + result SetMargin(int topMargin, int leftMargin); + int GetTopMargin(void) const; + int GetLeftMargin(void) const; + + Tizen::Graphics::Dimension GetContentSizeInternal(void) const; + +protected: + result SetPresenter(const _LabelPresenter& labelPresenter); + +private: + void InitializeAccessibilityElement(void); + + _Label(void); + _Label(const _Label& rhs); + _Label& operator =(const _Label& rhs); + +private: + _LabelPresenter* __pLabelPresenter; + + Tizen::Base::String __text; + int __textSize; + + HorizontalAlignment __horizontalAlignment; + VerticalAlignment __verticalAlignment; + + Tizen::Graphics::Color __textColor; + + Tizen::Graphics::Bitmap* __pBackgroundBitmap; + Tizen::Graphics::Bitmap* __pBackgroundEffectBitmap; + + int __topMargin; + int __leftMargin; + + Tizen::Ui::_AccessibilityElement* __pTextElement; +}; // _Label + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LABEL_H_ diff --git a/src/ui/inc/FUiCtrl_LabelImpl.h b/src/ui/inc/FUiCtrl_LabelImpl.h new file mode 100644 index 0000000..e2e00d7 --- /dev/null +++ b/src/ui/inc/FUiCtrl_LabelImpl.h @@ -0,0 +1,100 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_LabelImpl.h + * @brief This is the header file for the _LabelImpl class. + * + * This header file contains the declarations of the %_LabelImpl class. + */ +#ifndef _FUI_CTRL_INTERNAL_LABEL_IMPL_H_ +#define _FUI_CTRL_INTERNAL_LABEL_IMPL_H_ + +#include +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_Label.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + class _VisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Graphics +{ + class Dimension; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _LabelImpl + : public _ControlImpl +{ +public: + class LabelSizeInfo : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + }; // LabelSizeInfo + +public: + virtual ~_LabelImpl(void); + static _LabelImpl* CreateLabelImplN(Label* pControl, const Tizen::Graphics::Rectangle& bounds); + + virtual const char* GetPublicClassName(void) const; + virtual const Label& GetPublic(void) const; + virtual Label& GetPublic(void); + virtual const _Label& GetCore(void) const; + virtual _Label& GetCore(void); + +public: + result SetText(const Tizen::Base::String& text); + result SetTextColor(const Tizen::Graphics::Color& color); + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + result SetTextHorizontalAlignment(HorizontalAlignment alignment); + result SetTextVerticalAlignment(VerticalAlignment alignment); + result SetTextConfig(int size, LabelTextStyle style); + result SetMargin(int topMargin, int leftMargin); + + Tizen::Base::String GetText(void) const; + HorizontalAlignment GetTextHorizontalAlignment(void) const; + VerticalAlignment GetTextVerticalAlignment(void) const; + Tizen::Graphics::Color GetTextColor(void) const; + int GetTextSize(void) const; + LabelTextStyle GetTextStyle(void) const; + int GetTopMargin(void) const; + int GetLeftMargin(void) const; + + virtual result OnBoundsChanged(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect); + virtual Tizen::Graphics::Dimension GetContentSize(void) const; + +public: + static Tizen::Graphics::Color GetColorOnError(void); + + static _LabelImpl* GetInstance(Label& label); + static const _LabelImpl* GetInstance(const Label& label); + +private: + _LabelImpl(Label* pPublic, _Label* pCore); + + _LabelImpl(const _LabelImpl& rhs); + _LabelImpl& operator =(const _LabelImpl& rhs); + +}; // _LabelImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LABEL_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_LabelModel.h b/src/ui/inc/FUiCtrl_LabelModel.h new file mode 100644 index 0000000..2dc876a --- /dev/null +++ b/src/ui/inc/FUiCtrl_LabelModel.h @@ -0,0 +1,60 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_LabelModel.h + * @brief This is the header file for the _LabelModel class. + * + * This header file contains the declarations of the %_LabelModel class. + */ +#ifndef _FUI_CTRL_INTERNAL_LABEL_MODEL_H_ +#define _FUI_CTRL_INTERNAL_LABEL_MODEL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _LabelModel + * @brief + * @since 1.0 + * + * + * + * + */ +class _LabelModel + : public Tizen::Base::Object +{ + +public: + _LabelModel(void); + + virtual ~_LabelModel(void); + +public: + virtual result Construct(void); + +private: + _LabelModel(const _LabelModel& rhs); + + _LabelModel& operator =(const _LabelModel& rhs); + +}; // _LabelModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LABEL_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_LabelPresenter.h b/src/ui/inc/FUiCtrl_LabelPresenter.h new file mode 100644 index 0000000..b9df783 --- /dev/null +++ b/src/ui/inc/FUiCtrl_LabelPresenter.h @@ -0,0 +1,106 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_LabelPresenter.h + * @brief This is the header file for the _LabelPresenter class. + * + * This header file contains the declarations of the %_LabelPresenter class. + */ +#ifndef _FUI_CTRL_INTERNAL_LABEL_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_LABEL_PRESENTER_H_ + +#include +#include +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Label; +class _LabelModel; + +/** + * @class _LabelPresenter + * @brief + * @since 1.0 + * + * + * + * + */ +class _LabelPresenter + : public Tizen::Base::Object +{ +public: + _LabelPresenter(void); + virtual ~_LabelPresenter(void); + +public: + virtual result Construct(const _Label& label); + virtual result Install(void); + + void Draw(void); + + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + void SetFontInfo(unsigned long style, int size); + result SetTextConfig(int size, LabelTextStyle style); + LabelTextStyle GetTextStyle(void) const; + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const _Control& control); + + Tizen::Graphics::_Text::TextObject* GetTextObject(void) const; + result InitTextObject(void); + +protected: + result SetModel(const _LabelModel& labelModel); + +private: + _LabelPresenter(const _LabelPresenter& rhs); + _LabelPresenter& operator =(const _LabelPresenter& rhs); + + void DrawBackground(void); + void DrawText(void); + bool IsEnabledStateChanged(void); + +private: + _Label* __pLabel; + _LabelModel* __pLabelModel; + + bool __previousEnabledState; + + Tizen::Graphics::Font* __pFont; + Tizen::Graphics::_Text::TextObject* __pTextObject; + + Tizen::Ui::Animations::_VisualElement* __pBase; + LabelTextStyle __textStyle; + unsigned long __fontStyle; + int __fontSize; +}; // _LabelPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LABEL_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_LanguageEvent.h b/src/ui/inc/FUiCtrl_LanguageEvent.h new file mode 100644 index 0000000..14269c6 --- /dev/null +++ b/src/ui/inc/FUiCtrl_LanguageEvent.h @@ -0,0 +1,96 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_LanguageEvent.h + * @brief This is the header file for _LanguageEvent class. + * @version 1.0 + * + * This header file contains declaration of _LanguageEvent class. + */ + +#ifndef _FUI_CTRL_INTERNAL_LANGUAGE_EVENT_H_ +#define _FUI_CTRL_INTERNAL_LANGUAGE_EVENT_H_ + +#include +#include +#include +#include "FUiCtrl_ILanguageEventListener.h" + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _FocusEvent + * @brief This class handles a focus event. It is inherited from LowLevelEvent class. + * + * The Control class has an instance of the _LanguageEvent class as a member variable. + * _LanguageEvent notifies the listeners when a Keypad language is changed. + * + * @since 1.0 + */ +class _LanguageEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the class destructor. + */ + virtual ~_LanguageEvent(); + + static _LanguageEvent* CreateInstanceN(const Tizen::Ui::_Control& source); + +// Accessors + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::_Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateLanguageEventArgN(Tizen::Locales::LanguageCode prevLanguageCode, Tizen::Locales::LanguageCode currentLanguageCode); + +protected: + /** + * This is the default class constructor. After creating an instance of this + * class, you must explicitly call one of construction methods to initialize + * the instance. + */ + _LanguageEvent(const Tizen::Ui::_Control& source); + + /** + * This method calls appropriate IKeyEventListener method. + * + * @param[in] listener The IKeyEventListener instance. + * @param[in] arg The _FocusEventArg. + * @exception E_SUCCESS - The method is successful. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value. + * @exception E_INVALID_ARG - @c pListener is @c null. + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + const Tizen::Ui::_Control* __pSource; + +}; // _LanguageEvent +}}} // Tizen::Ui//Controls + +#endif //_FUI_CTRL_INTERNAL_LANGUAGE_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_LinkEvent.h b/src/ui/inc/FUiCtrl_LinkEvent.h new file mode 100644 index 0000000..fb39060 --- /dev/null +++ b/src/ui/inc/FUiCtrl_LinkEvent.h @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_LinkEvent.h +* @brief This is the header file for _LinkEvent class. +* +* This header file contains declaration of _LinkEvent class. +* +*/ + +#ifndef _FUI_CTRL_LINK_EVENT_H_ +#define _FUI_CTRL_LINK_EVENT_H_ + +#include +#include +#include +#include "FUiCtrl_IUiLinkEventListener.h" + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** +* @class _LinkEvent +* @brief This class handles a keypad event event. It is inherited from Event class. +* +*/ +class _LinkEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_LinkEvent(void); + + static _LinkEvent* CreateInstanceN(const Tizen::Ui::_Control& source); + +// Accessors + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::_Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateLinkEventArgN(Tizen::Base::String text, Tizen::Base::Utility::LinkType linkType, Tizen::Base::String link); + + // Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _LinkEvent(const Tizen::Ui::_Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of _CustomItemEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + + //Attributess +private: + const Tizen::Ui::_Control* __pSource; +}; // _LinkEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_LINK_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_LinkedList.h b/src/ui/inc/FUiCtrl_LinkedList.h new file mode 100644 index 0000000..e2184a9 --- /dev/null +++ b/src/ui/inc/FUiCtrl_LinkedList.h @@ -0,0 +1,621 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_LinkedList.h + * @brief This is the header file for the _LinkedList template. + * + * This file contains the declarations and implementation of + * _LinkedList template. + */ + +#ifndef _FUI_CTRL_INTERNAL_LINKEDLIST_H +#define _FUI_CTRL_INTERNAL_LINKEDLIST_H + +#include + +template +class _LinkedList +{ +private: + class _ListNode + { + public: + _ListNode(void) + : pPrev(null) + , pNext(null) + , val(T()) + { + } + + _ListNode* pPrev; + _ListNode* pNext; + T val; + }; // _ListNode + + _ListNode* __pHead; + _ListNode* __pTail; + int __length; + +public: + class _Iterator + { + private: + friend class _LinkedList; + _ListNode* __pPos; + + public: + _Iterator(_ListNode& _lnr) + : __pPos(&_lnr) {} + _Iterator(_ListNode* _p = null) + : __pPos(_p) {} + + _Iterator& operator ++(void) + { + __pPos = __pPos->pNext; + return *this; + } //pre + + _Iterator operator ++(int) + { + _Iterator _retval = *this; + ++*this; + return _retval; + } //post + + _Iterator& operator +(int cnt) + { + while (cnt--) + { + __pPos = __pPos->pNext; + } + return *this; + } + + _Iterator& operator --(void) + { + __pPos = __pPos->pPrev; + return *this; + } //pre + + _Iterator operator --(int) + { + _Iterator _retval = *this; + --*this; + return _retval; + } //post + + _Iterator& operator -(int cnt) + { + while (cnt--) + { + __pPos = __pPos->pPrev; + } + return *this; + } + + T* operator ->() const { return &__pPos->val;} + T& operator *() const { return __pPos->val;} + bool operator ==(const _Iterator& _rhs) const { return __pPos == _rhs.__pPos;} + bool operator !=(const _Iterator& _rhs) const { return __pPos != _rhs.__pPos;} + }; // _Iterator + + class _ReverseIterator + { + private: + friend class _LinkedList; + _ListNode* __pPos; + + public: + _ReverseIterator(_ListNode& _lnr) + : __pPos(&_lnr) {} + _ReverseIterator(_ListNode* _p = null) + : __pPos(_p) {} + + _ReverseIterator& operator ++(void) + { + __pPos = __pPos->pPrev; + return *this; + } //pre + + _ReverseIterator operator ++(int) + { + _ReverseIterator _retval = *this; + ++*this; + return _retval; + } //post + + _ReverseIterator& operator --(void) + { + __pPos = __pPos->pNext; + return *this; + } //pre + + _ReverseIterator operator --(int) + { + _Iterator _retval = *this; + --*this; + return _retval; + } //post + + T* operator ->() const { return &__pPos->val;} + T& operator *() const { return __pPos->val;} + bool operator ==(const _ReverseIterator& _rhs) const { return __pPos == _rhs.__pPos;} + bool operator !=(const _ReverseIterator& _rhs) const { return __pPos != _rhs.__pPos;} + }; // _ReverseIterator + + _LinkedList(void); + ~_LinkedList(void); + + _LinkedList& operator =(_LinkedList& rhs) + { + //destruct + clear(); + + delete __pHead; + __pHead = null; + delete __pTail; + __pTail = null; + + // copy + __pHead = rhs.__pHead; + __pTail = rhs.__pTail; + __length = rhs.__length; + + // initializing + rhs.__pHead = new (std::nothrow) _ListNode(); + rhs.__pTail = new (std::nothrow) _ListNode(); + + rhs.__pHead->pNext = rhs.__pTail; + rhs.__pTail->pPrev = rhs.__pHead; + rhs.__length = 0; + + return *this; + } + + void insert(_Iterator&, const T &); + void erase(_Iterator&); + void remove(const T&); + void push_front(const T&); + void push_back(const T&); + void pop_front(void); + void pop_back(void); + void clear(void); + bool empty(void) const; + int size(void) const { return __length;} + void sort(bool (*)(T, T)); + void advance(_Iterator& _where, int _index); + T& front(void) const { return __pHead->pNext->val;} + T& back(void) const { return __pTail->pPrev->val;} + T& at(int) const; + + _Iterator begin(void) const { return _Iterator(__pHead->pNext);} + _Iterator end(void) const { return _Iterator(__pTail);} + _ReverseIterator rbegin(void) const { return _ReverseIterator(__pTail->pPrev);} + _ReverseIterator rend(void) const { return _ReverseIterator(__pHead);} + +private: + void insert_node(_Iterator, _ListNode *, _ListNode *, const T &); + void delete_node(_Iterator, _ListNode *, _ListNode*); + void swap_node(_ListNode*, _ListNode*); + void sort_node(bool (*)(T, T), _ListNode *, _ListNode*); + int count_node(_ListNode*, _ListNode*); + +private: + _LinkedList(const _LinkedList& rhs); +}; // _LinkedList + +template +_LinkedList ::_LinkedList(void) + : __pHead(null) + , __pTail(null) + , __length(0) +{ + __pHead = new (std::nothrow) _ListNode(); + __pTail = new (std::nothrow) _ListNode(); + + __pHead->pNext = __pTail; + __pTail->pPrev = __pHead; +} + +template +_LinkedList ::~_LinkedList(void) +{ + clear(); + + delete __pHead; + __pHead = null; + delete __pTail; + __pTail = null; +} + +template +void +_LinkedList ::insert(_Iterator& _where, const T& _val) +{ + insert_node(_where, null, null, _val); +} + +template +void +_LinkedList ::erase(_Iterator& _where) +{ + delete_node(_where, null, null); +} + +template +void +_LinkedList ::remove(const T& _val) +{ + if (__length <= 0) + { + return; + } + + _ListNode* _pTempNode = __pHead->pNext; + + //while(_val != _pTempNode->val) + while (memcmp(&(_val), &(_pTempNode->val), sizeof(T))) + { + if (_pTempNode == __pTail) + { + _pTempNode = null; + break; + } + + _pTempNode = _pTempNode->pNext; + } + + if ((_pTempNode == __pHead->pNext) && (_pTempNode == __pTail->pPrev)) + { + delete __pHead->pNext; + __pHead->pNext = __pTail; + __pTail->pPrev = __pHead; + } + else if (_pTempNode != null) + { + _pTempNode->pPrev->pNext = _pTempNode->pNext; + _pTempNode->pNext->pPrev = _pTempNode->pPrev; + delete _pTempNode; + _pTempNode = null; + } + else + { + return; + } + + __length--; +} + +template +void +_LinkedList ::push_front(const T& _val) +{ + insert_node(null, __pHead->pNext, null, _val); +} + +template +void +_LinkedList ::push_back(const T& _val) +{ + insert_node(null, null, __pTail->pPrev, _val); +} + +template +void +_LinkedList ::pop_front(void) +{ + delete_node(null, __pHead->pNext, null); +} + +template +void +_LinkedList ::pop_back(void) +{ + delete_node(null, null, __pTail->pPrev); +} + +template +void +_LinkedList ::clear(void) +{ + _ListNode* _pTempNode; + + while (__pHead->pNext != __pTail) + { + _pTempNode = __pHead->pNext; + __pHead->pNext = __pHead->pNext->pNext; + delete _pTempNode; + _pTempNode = null; + } + + __pTail->pPrev = __pHead; + __length = 0; +} + +template +bool +_LinkedList ::empty(void) const +{ + if (__length <= 0) + { + return true; + } + + return false; +} + +template +void +_LinkedList ::sort(bool (* _compare)(T _a, T _b)) +{ + if (__length <= 0) + { + return; + } + + sort_node(_compare, __pHead->pNext, __pTail->pPrev); +} + +template +void +_LinkedList ::advance(_Iterator& _where, int _index) +{ + while (_index--) + { + ++_where; + } +} + +template +void +_LinkedList ::insert_node(_Iterator _where, _ListNode* _first, _ListNode* _last, const T& _val) +{ + _ListNode* _pNewNode = new (std::nothrow) _ListNode; + _pNewNode->val = _val; + + if (_where == null) + { + if (!_first && !_last) + { + __pHead->pNext = _pNewNode; + __pTail->pPrev = _pNewNode; + } + else if (_first) + { + _pNewNode->pPrev = __pHead; + _pNewNode->pNext = __pHead->pNext; + __pHead->pNext->pPrev = _pNewNode; + __pHead->pNext = _pNewNode; + } + else + { + _pNewNode->pPrev = __pTail->pPrev; + _pNewNode->pNext = __pTail; + __pTail->pPrev->pNext = _pNewNode; + __pTail->pPrev = _pNewNode; + } + } + else + { + if (_where.__pPos == __pHead->pNext) + { + _pNewNode->pPrev = __pHead; + _pNewNode->pNext = __pHead->pNext; + __pHead->pNext->pPrev = _pNewNode; + __pHead->pNext = _pNewNode; + } + else if (_where.__pPos == __pTail) + { + _pNewNode->pPrev = __pTail->pPrev; + _pNewNode->pNext = __pTail; + __pTail->pPrev->pNext = _pNewNode; + __pTail->pPrev = _pNewNode; + } + else + { + _pNewNode->pPrev = _where.__pPos->pPrev; + _where.__pPos->pPrev->pNext = _pNewNode; + _pNewNode->pNext = _where.__pPos; + _where.__pPos->pPrev = _pNewNode; + } + + _where++; + } + + __length++; +} + +template +void +_LinkedList ::delete_node(_Iterator _where, _ListNode* _first, _ListNode* _last) +{ + if (__length <= 0) + { + return; + } + + if (_where == null) + { + if ((_first == __pHead->pNext) && (_first == __pTail->pPrev)) // only one node + { + delete __pHead->pNext; + __pHead->pNext = __pTail; + __pTail->pPrev = __pHead; + } + else if (_first) // pop_front + { + __pHead->pNext = __pHead->pNext->pNext; + delete __pHead->pNext->pPrev; + __pHead->pNext->pPrev = __pHead; + } + else if (_last) // pop_back + { + __pTail->pPrev = __pTail->pPrev->pPrev; + delete __pTail->pPrev->pNext; + __pTail->pPrev->pNext = __pTail; + } + else + { + return; + } + } + else + { + if ((_where.__pPos == __pHead->pNext) && (_where.__pPos == __pTail->pPrev)) + { + delete __pHead->pNext; + __pHead->pNext = __pTail; + __pTail->pPrev = __pHead; + } + else + { + if (_where.__pPos == __pHead->pNext) + { + __pHead->pNext = __pHead->pNext->pNext; + delete __pHead->pNext->pPrev; + __pHead->pNext->pPrev = __pHead; + } + else if (_where.__pPos == __pTail->pPrev) + { + __pTail->pPrev = __pTail->pPrev->pPrev; + delete __pTail->pPrev->pNext; + __pTail->pPrev->pNext = __pTail; + } + else + { + _where.__pPos->pPrev->pNext = _where.__pPos->pNext; + _where.__pPos->pNext->pPrev = _where.__pPos->pPrev; + delete _where.__pPos; + _where.__pPos = null; + } + } + } + + __length--; +} + +template +void +_LinkedList ::swap_node(_ListNode* _a, _ListNode* _b) +{ + T _temp; + + _temp = _a->val; + _a->val = _b->val; + _b->val = _temp; +} + +template +void +_LinkedList ::sort_node(bool (* _compare)(T _a, T _b), _ListNode* _low, _ListNode* _hight) +{ + // FIXME : This function implement using quick sort algorithm. + // You should remember that _Iterator is invalid after sorting. + _ListNode* _left, * _right, * _pivot; + + int _total = count_node(_low, _hight); + int _leftCount = 1; + int _rightCount = _total - 1; + + if (_rightCount > 0) + { + _left = _low; + _right = _hight->pPrev; + _pivot = _hight; + + while (1) + { + while (_compare(_left->val, _pivot->val)) + { + _left = _left->pNext; + _leftCount++; + } + + while (!_compare(_right->val, _pivot->val)) + { + if ((_rightCount <= 1) || (_right->pPrev == null)) + { + break; + } + + _right = _right->pPrev; + _rightCount--; + } + + if ((_leftCount >= _rightCount) || (_right->pPrev == null)) + { + break; + } + + swap_node(_left, _right); + + _left = _left->pNext; + _leftCount++; + + _right = _right->pPrev; + _rightCount--; + } + + swap_node(_pivot, _left); + + if ((_left->pPrev != null) && (_leftCount - 1 > 0)) + if ((_left->pNext != _low) && (_low->pPrev != _left)) + sort_node(_compare, _low, _left->pPrev); + + if ((_left->pNext != null) && (_leftCount < _total)) + if ((_left->pPrev != _hight) && (_hight->pNext != _left)) + sort_node(_compare, _left->pNext, _hight); + } +} + +template +int +_LinkedList ::count_node(_ListNode* _left, _ListNode* _right) +{ + int _count = 0; + _ListNode* _pTempNode = _left; + + while (_pTempNode != _right) + { + _pTempNode = _pTempNode->pNext; + _count++; + } + + return ++_count; +} + +template +T& +_LinkedList ::at(int _index) const +{ + if ((__length <= 0) || (_index >= __length)) + { + return __pHead->val; + } + + _ListNode* _pTempNode = __pHead->pNext; + + for (int i = 0; i < _index; i++) + { + _pTempNode = _pTempNode->pNext; + } + + return _pTempNode->val; +} + +#endif // _FUI_CTRL_INTERNAL_LINKEDLIST_H diff --git a/src/ui/inc/FUiCtrl_ListBaseImpl.h b/src/ui/inc/FUiCtrl_ListBaseImpl.h new file mode 100644 index 0000000..bc6134d --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListBaseImpl.h @@ -0,0 +1,141 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListBaseImpl.h + * @brief This is the header file for the _ListBaseImpl class. + * + * This header file contains the declarations of the _ListBaseImpl class and its helper classes. + */ + +#ifndef _FUI_CTRL_INTERNAL_LIST_COMMON_H_ +#define _FUI_CTRL_INTERNAL_LIST_COMMON_H_ + +#include +#include +#include +#include "FUiCtrl_TableView.h" +#include "FUi_ResourceManager.h" +#include "FUi_ContainerImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _Label; + +typedef enum _CheckBoxBitmapType +{ + CHECK_BOX_UNCHECKED = 0, + CHECK_BOX_CHECKED, + CHECK_BOX_DISABLED, + CHECK_BOX_MAX +}_CheckBoxStatus; + +class _ListBaseImpl + : public _ControlImpl + , public Tizen::Ui::ITouchEventListener +{ +public: + _ListBaseImpl(Control* pList, _TableView* pCore); + ~_ListBaseImpl(void); + + result LoadDefaultBitmap(void); + Tizen::Graphics::Bitmap** GetCheckBitmaps(void); + _TableView& GetCore(void); + const _TableView& GetCore(void) const; + + virtual void OnDraw(void); + virtual result SetListStyle(CustomListStyle style); + + virtual void ProcessItemStateChange(int groupIndex, int itemIndex, int elementId, ItemStatus itemStatus) = 0; + virtual void ProcessItemStateChange(int groupIndex, int itemIndex, ItemStatus itemStatus) = 0; + + virtual result SetItemChecked(int groupIndex, int itemIndex, bool check); + virtual bool IsItemChecked(int groupIndex, int itemIndex) const; + + virtual void SetTextOfEmptyList(const Tizen::Base::String& text); + virtual void SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + virtual Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + virtual result GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const; + virtual result GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const; + + result GetItemIndexFromPosition(const Tizen::Graphics::Point& point, int& groupIndex, int& itemIndex) const; + + virtual void OnTouchDoublePressed (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchFocusIn (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchFocusOut (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchLongPressed (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchMoved (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchPressed (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + virtual void OnTouchReleased (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo); + + void UpdateElements(const Control &source, CustomListItemStatus itemStatus); + + result InsertIntoItemsList(const CustomListItem& item, int groupIndex, int itemIndex, bool updateIndexes = true); + result RemoveFromItemsList(int groupIndex, int itemIndex, bool updateIndexes = true); + result SetInItemsList(const CustomListItem& item, int groupIndex, int itemIndex); + + void RemoveAllFromItemsList(void); + + CustomListItem* GetCustomListItemAt(int groupIndex, int itemIndex); + class _TableViewItemData* GetTableViewItemAt(int groupIndex, int itemIndex); + class _TableViewGroupItemData* GetTableViewGroupItemAt(int groupIndex); + + const CustomListItem* GetCustomListItemAt(int groupIndex, int itemIndex) const; + const class _TableViewItemData* GetTableViewItemAt(int groupIndex, int itemIndex) const; + const class _TableViewGroupItemData* GetTableViewGroupItemAt(int groupIndex) const; + + class _CheckElementModel* GetCheckElementAt(int groupIndex, int itemIndex); + const class _CheckElementModel* GetCheckElementAt(int groupIndex, int itemIndex) const; + void DrawItem(int groupIndex, int itemIndex); + virtual int GetTopItemIndex(int groupIndex) const; + + int GetItemCount(void) const; + int GetGroupCount(void) const; + int GetSubItemCountAt(int groupIndex) const; + + result RemoveFromSubItemsList(int groupIndex); + + bool IsItemNew(const CustomListItem& item) const; + +private: + _ListBaseImpl(const _ListBaseImpl& rhs); + _ListBaseImpl& operator =(const _ListBaseImpl& rhs); + + result UpdateIndices(int groupIndex, int itemIndex, int updateBy); + CustomListItem* GetItemFromControl(const Control &source); + +protected: + TableViewAnnexStyle _annexStyle; + Tizen::Graphics::Bitmap* _pCheckBitmaps[CHECK_BOX_MAX]; + int _currentRadioIndex; + int _currentRadioGroupIndex; + bool _isDividerEnabled; + int _defaultItemHeight; + Tizen::Base::Collection::ArrayList _itemsList; + +private: + _Label* __pEmptyText; + Tizen::Graphics::Color __emptyTextColor; + + friend class _CustomListItemImpl; +}; + +}}} //Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_LIST_COMMON_H_ diff --git a/src/ui/inc/FUiCtrl_ListContextItemImpl.h b/src/ui/inc/FUiCtrl_ListContextItemImpl.h new file mode 100644 index 0000000..9aca680 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListContextItemImpl.h @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListContextItemImpl.h + * @brief This is the header file for the _ListContextItemImpl class. + * + * This header file contains the declarations of the _ListContextItemImpl + * class. + */ + +#ifndef _FUI_CTRL_LIST_CONTEXT_ITEM_IMPL_H_ +#define _FUI_CTRL_LIST_CONTEXT_ITEM_IMPL_H_ + +#include "FUiCtrl_ListViewImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class ListContextItem; +class _ListViewContextItem; + +class _ListContextItemImpl + : public Tizen::Base::Object +{ +public: + static _ListContextItemImpl* CreateListContextItemImplN(ListContextItem* pPublic); + + virtual ~_ListContextItemImpl(void); + + virtual const char* GetPublicClassName(void) const; + + virtual const ListContextItem& GetPublic(void) const; + + virtual ListContextItem& GetPublic(void); + + result AddElement(int elementId, const Tizen::Base::String& text, bool enable = true); + + result AddElement(int elementId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap& pressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap = null, bool enable = true); + + result AddElement(int elementId, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap& normalBitmap, + const Tizen::Graphics::Bitmap& pressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap = null, bool enable = true); + + Tizen::Graphics::Color GetBackgroundColor(void) const; + + result SetBackgroundColor(const Tizen::Graphics::Color& color); + + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + _ListViewContextItem* GetContextItem(void) const; + +public: + static _ListContextItemImpl* GetInstance(ListContextItem& listContextItem); + + static const _ListContextItemImpl* GetInstance(const ListContextItem& listContextItem); + +private: + _ListContextItemImpl(ListContextItem* pPublic); + + _ListContextItemImpl(const _ListContextItemImpl& rhs); + + _ListContextItemImpl& operator =(const _ListContextItemImpl& rhs); + + result Construct(void); + +private: + ListContextItem* __pPublic; + _ListViewContextItem* __pContextItem; +}; // _ListContextItemImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_LIST_CONTEXT_ITEM_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_ListImpl.h b/src/ui/inc/FUiCtrl_ListImpl.h new file mode 100644 index 0000000..d95f7d3 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListImpl.h @@ -0,0 +1,246 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ListImpl.h + * @brief This is the header file for the _ListImpl class. + */ + +#ifndef _FUI_CTRL_LIST_IMPL_H_ +#define _FUI_CTRL_LIST_IMPL_H_ + +#include +#include "FUiCtrl_TableViewItemProvider.h" +#include "FUiCtrl_CustomListItemImpl.h" +#include "FUiCtrl_ITableViewItemEventListener.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +extern const int INVALID_INDEX; + +class _ListImpl; + +class _NumberElement + : public ICustomListElement +{ +public: + _NumberElement(void); + ~_NumberElement(void); + + result DrawElement(const Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& rect, Tizen::Ui::Controls::CustomListItemStatus itemStatus); + +private: + _NumberElement(const _NumberElement& rhs); + _NumberElement& operator =(const _NumberElement& rhs); + +public: + int index; + +}; //_NumberElement + +class _ListItemDataProvider + : public ITableViewItemProvider +{ +public: + _ListItemDataProvider(_ListImpl* pListImpl); + virtual ~_ListItemDataProvider(void); + + virtual int GetItemCount(void); + virtual TableViewItem* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(const int itemIndex, TableViewItem* pItem); + virtual int GetDefaultItemHeight(void); + virtual void UpdateItem(int itemIndex, TableViewItem* pItem); + +private: + _ListItemDataProvider(void); + _ListItemDataProvider(const _ListItemDataProvider& rhs); + _ListItemDataProvider& operator =(const _ListItemDataProvider& rhs); + +private: + _ListImpl* __pListImpl; +}; //_ListItemDataProvider + +class _ListImpl + : public _ListBaseImpl + , public _ITableViewItemEventListener +{ +public: + _ListImpl(Control* pList, _TableView* pCore); + ~_ListImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const List& GetPublic(void) const; + virtual List& GetPublic(void); + virtual const _TableView& GetCore(void) const; + virtual _TableView& GetCore(void); + static _ListImpl* CreateListImplN(List* pControl, const Tizen::Graphics::Rectangle& bounds); + result Initialize(ListItemFormat itemFormat, int row1Height, int row2Height, int column1Width, int column2Width); + result UpdateBounds(const Tizen::Graphics::Rectangle& rect); + result SetStyle(ListStyle style); + void SetListItemFormat(ListItemFormat itemFormat); + result InitCustomListItemFormat(void); + bool GetTextSlide(ListItemText textIndex); + + //@See doxygen + result AddItemEventListener(const Tizen::Ui::IItemEventListener& listener); + //@See doxygen + result RemoveItemEventListener(const Tizen::Ui::IItemEventListener& listener); + //@See doxygen + result AddItem(const Tizen::Base::String* pText1, const Tizen::Base::String* pText2, const Tizen::Graphics::Bitmap* pBitmap1, const Tizen::Graphics::Bitmap* pBitmap2, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result InsertItemAt(int index, const Tizen::Base::String* pText1, const Tizen::Base::String* pText2, const Tizen::Graphics::Bitmap* pBitmap1, const Tizen::Graphics::Bitmap* pBitmap2, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result SetItemAt(int index, const Tizen::Base::String* pText1, const Tizen::Base::String* pText2, const Tizen::Graphics::Bitmap* pBitmap1, const Tizen::Graphics::Bitmap* pBitmap2, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result RemoveItemAt(int index); + //@See doxygen + result RemoveAllItems(void); + //@See doxygen + result SetItemEnabled(int index, bool enable); + //@See doxygen + bool IsItemEnabled(int index) const; + //@See doxygen + void SetFocusedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + //@See doxygen + void SetHighlightedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + //@See doxygen + void SetNormalItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + //@See doxygen + void SetItemTextColor(ListItemText textIndex, const Tizen::Graphics::Color& textColor); + //@See doxygen + Tizen::Graphics::Color GetItemTextColor(ListItemText textIndex) const; + //@See doxygen + void EnableTextSlide(ListItemText textIndex); + //@See doxygen + void DisableTextSlide(void); + //@See doxygen + int GetItemHeight(void) const; + //@See doxygen + int GetRow1Height(void) const; + //@See doxygen + int GetRow2Height(void) const; + //@See doxygen + int GetColumn1Width(void) const; + //@See doxygen + int GetColumn2Width(void) const; + //@See doxygen + result SetRow1Height(int row1Height); + //@See doxygen + result SetRow2Height(int row2Height); + //@See doxygen + result SetColumn1Width(int column1Width); + //@See doxygen + result SetColumn2Width(int column2Width); + //@See doxygen + result SetItemChecked(int index, bool check); + //@See doxygen + bool IsItemChecked(int index) const; + //@See doxygen + result SetAllItemsChecked(bool check); + //@See doxygen + result RemoveAllCheckedItems(void); + //@See doxygen + int GetFirstCheckedItemIndex(void) const; + //@See doxygen + int GetLastCheckedItemIndex(void) const; + //@See doxygen + int GetNextCheckedItemIndexAfter(int index) const; + //@See doxygen + int GetItemIndexFromItemId(int itemId) const; + //@See doxygen + int GetItemIdAt(int index) const; + //@See doxygen + void ScrollToBottom(void); + //@See doxygen + void ScrollToTop(void); + //@See doxygen + result ScrollToTop(int index); + //@See doxygen + result RefreshItem(int index); + + static _ListImpl* GetInstance(List& list); + static const _ListImpl* GetInstance(const List& list); + +private: + _ListImpl(const _ListImpl& rhs); + _ListImpl& operator =(const _ListImpl& rhs); + + virtual void OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + virtual void OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo); + virtual void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + virtual void OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo); + virtual void OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + virtual void OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + virtual void OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction); + + void ProcessItemStateChange(int groupIndex, int itemIndex, ItemStatus itemStatus); + void ProcessItemStateChange(int groupIndex, int itemIndex, int elementId, ItemStatus itemStatus); + + CustomListItem* GetNewItemN(const Tizen::Base::String* pText1, const Tizen::Base::String* pText2, + const Tizen::Graphics::Bitmap* pBitmap1, const Tizen::Graphics::Bitmap* pBitmap2, int itemId, int index); + + void GetElementRects(Tizen::Graphics::Rectangle& text1Rect, Tizen::Graphics::Rectangle& text2Rect, Tizen::Graphics::Rectangle& img1Rect, Tizen::Graphics::Rectangle& img2Rect); + result ReDrawList(void); + void SetBitmap(TableViewItemDrawingStatus itemStatus, const Tizen::Graphics::Bitmap& bitmap); + result UpdateNumbers(int index); + result Refresh(int); + result SetItemChecked(int groupIndex, int itemIndex, bool check); + bool IsItemChecked(int groupIndex, int subIndex) const; + + result InitializeItemSizes(int row1Height, int row2height, int column1Width, int column2Width); + void GetItemMargins(int& leftMargin, int& numberStyleMargin, int& dividerMargin, int& lowerMargin, int& upperMargin); + +private: + static const int ID_FORMAT_TEXT1 = 101; + static const int ID_FORMAT_TEXT2 = 102; + static const int ID_FORMAT_IMAGE1 = 103; + static const int ID_FORMAT_IMAGE2 = 104; + static const int ID_FORMAT_NUMBER = 105; + static const int ID_FORMAT_CHECK = 106; + + Tizen::Base::Collection::LinkedList __itemListeners; + int __row1Height; + int __row2Height; + int __column1Width; + int __column2Width; + Tizen::Graphics::Color __text1Color; + Tizen::Graphics::Color __text2Color; + bool __text1SlideEnabled; + bool __text2SlideEnabled; + ListStyle __listStyle; + ListItemFormat __listItemFormat; + Tizen::Graphics::Bitmap* __pNormalBgBitmap; + Tizen::Graphics::Bitmap* __pHighlightedBgBitmap; + Tizen::Graphics::Bitmap* __pFocusedBgBitmap; + Tizen::Base::Collection::LinkedList* __pNumberElements; + CustomListItemFormat* __pItemFormat; + _ListItemDataProvider* __pItemProvider; + int maxCount; + bool divider; + + friend class _ListItemDataProvider; + friend class _CustomListItemImpl; + +}; //_ListImpl + +} } } //Tizen::Ui::Controls + +#endif //_FUI_CTRL_LIST_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_ListItemBaseImpl.h b/src/ui/inc/FUiCtrl_ListItemBaseImpl.h new file mode 100644 index 0000000..9f592c4 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListItemBaseImpl.h @@ -0,0 +1,127 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListItemBaseImpl.h + * @brief This is the header file for the _ListItemBaseImpl class. + * + * This header file contains the declarations of the _ListItemBaseImpl class. + */ + +#ifndef _FUI_CTRL_LIST_ITEM_BASE_IMPL_H_ +#define _FUI_CTRL_LIST_ITEM_BASE_IMPL_H_ + +#include +#include "FUi_ITouchLongPressGestureEventListener.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_IUiListViewItemEventListener.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class ListItemBase; +class _ListContextItemImpl; +class _ListViewItem; +class _UiListViewItemEvent; + +class _ListItemBaseImpl + : public Tizen::Base::Object + , public Tizen::Ui::_ITouchLongPressGestureEventListener + , public Tizen::Ui::Controls::_IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ + +public: + static _ListItemBaseImpl* CreateListItemBaseImplN(ListItemBase* pPublic, const Tizen::Graphics::Dimension& itemSize, ListAnnexStyle style); + + _ListItemBaseImpl(ListItemBase* pPublic); + + virtual ~_ListItemBaseImpl(void); + + virtual const char* GetPublicClassName(void) const; + + virtual const ListItemBase& GetPublic(void) const; + + virtual ListItemBase& GetPublic(void); + + result Construct(const Tizen::Graphics::Dimension& itemSize, ListAnnexStyle style); + + _ListViewItem* GetListViewItem(void) const; + + Tizen::Graphics::Dimension GetItemSize(void) const; + + result SetBackgroundBitmap(ListItemDrawingStatus status, const Tizen::Graphics::Bitmap* pBitmap); + + result SetBackgroundColor(ListItemDrawingStatus status, const Tizen::Graphics::Color& color); + + Tizen::Graphics::Color GetBackgroundColor(ListItemDrawingStatus status) const; + + result SetContextItem(const _ListContextItemImpl* pItem); + + result SetDescriptionText(const Tizen::Base::String& text); + + result SetDescriptionTextColor(const Tizen::Graphics::Color& color); + + result SetProgressValue(int value); + + result SetProgressMargins(int leftMargin, int rightMargin); + + static int GetAnnexWidth(ListAnnexStyle style); + + ListAnnexStyle GetListItemAnnexStyle(void); + + bool SetTextColor(int elementId, Tizen::Graphics::Color textColor); + + bool GetTextColor(int elementId, Tizen::Graphics::Color& textColor) const; + + void AddListViewItemEventListener(_IUiListViewItemEventListener& listener); + + void RemoveListViewItemEventListener(_IUiListViewItemEventListener& listener); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + + virtual bool OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture); + + virtual bool OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture); + +public: + static _ListItemBaseImpl* GetInstance(ListItemBase& listItemBase); + + static const _ListItemBaseImpl* GetInstance(const ListItemBase& listItemBase); + +private: + _ListItemBaseImpl(const _ListItemBaseImpl& rhs); + + _ListItemBaseImpl& operator =(const _ListItemBaseImpl& rhs); + +protected: + friend class _ListViewItemProviderAdaptor; + friend class _GroupedListViewItemProviderAdaptor; + +private: + ListItemBase* __pPublic; + _ListViewItem* __pListViewItem; + + Tizen::Graphics::Dimension __itemSize; + ListAnnexStyle __style; + + _UiListViewItemEvent* __pEvent; +}; // _ListItemBaseImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_LIST_ITEM_BASE_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_ListItemCommon.h b/src/ui/inc/FUiCtrl_ListItemCommon.h new file mode 100644 index 0000000..da9d5f9 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListItemCommon.h @@ -0,0 +1,91 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListItemCommon.h + * @brief This is the header file for the _ListItemCommon class. + * + * This header file contains the declarations of the _ListItemCommon class. + */ + + +#ifndef _FUI_CTRL_INTERNAL_LIST_ITEM_COMMON_H_ +#define _FUI_CTRL_INTERNAL_LIST_ITEM_COMMON_H_ + +#include "FUiCtrl_IListItemCommon.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _OSP_EXPORT_ _ListItemCommon + : public _IListItemCommon +{ +public: + virtual ~_ListItemCommon(void); + + virtual bool DrawItem(Tizen::Graphics::Rectangle& rcItem, ListItemState isFocused, bool itemDivider = false) = 0; + + virtual int GetItemHeight(void) const; + + virtual void SetItemHeight(int itemHeight); + + virtual void SetChecked(bool checked); + + virtual bool IsChecked(void) const; + + virtual void SetItemEnabled(bool enabled); + + virtual bool IsItemEnabled(void) const; + + virtual bool IsReorderMode(void) const; + + virtual void SetReorderMode(bool enabled); + + virtual void SetItemChanged(bool changed); + + virtual bool IsItemChanged(void) const; + + virtual void SetAppInfo(const void* pAppInfo); + + virtual void* GetAppInfo(void) const; + + ListItemType GetItemType(void) const; + + void SetItemType(ListItemType); + + int AddRef(void); + + int Release(void); + +protected: + _ListItemCommon(void); + +private: + void* __pAppInfo; + int __refCount; + int __itemHeight; + bool __checkedState; + bool __enabledState; + bool __itemChanged; + ListItemType __itemType; + bool __reorderMode; +}; // _ListItemCommon + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LIST_ITEM_COMMON_H_ diff --git a/src/ui/inc/FUiCtrl_ListItemEvent.h b/src/ui/inc/FUiCtrl_ListItemEvent.h new file mode 100644 index 0000000..ed77172 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListItemEvent.h @@ -0,0 +1,74 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListItemEvent.h + * @brief This is the header file for the _ListItemEvent class. + * + * This header file contains the declarations of the _ListItemEvent class. + */ + +#ifndef _FUI_CTRL_INTERNAL_LIST_ITEM_EVENT_H_ +#define _FUI_CTRL_INTERNAL_LIST_ITEM_EVENT_H_ + +#include +#include +#include +#include "FUiCtrl_ListViewTypes.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum ListClassName +{ + CLASSNAME_LISTVIEW = 0, + CLASSNAME_GROUPEDLISTVIEW, + CLASSNAME_NONE = 99 +}; + +class _ListItemEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + _ListItemEvent(void); + + virtual ~_ListItemEvent(void); + + result Construct(Tizen::Ui::Control& source, ListClassName name); + +// Accessors +public: + Tizen::Ui::Control* GetSource(void) const; + + ListClassName GetListClassName(void) const; + +// Operations +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attribute +private: + Tizen::Ui::Control* __pSource; + bool __invokeListViewItemCallback; + bool __invokeGroupedListViewItemCallback; + ListClassName __className; +}; // _ListItemEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LIST_ITEM_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_ListItemEventArg.h b/src/ui/inc/FUiCtrl_ListItemEventArg.h new file mode 100644 index 0000000..ce48a03 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListItemEventArg.h @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListItemEventArg.h + * @brief This is the header file for the _ListItemEventArg class. + * + * This header file contains the declarations of the _ListItemEventArg class. + */ + +#ifndef _FUI_CTRL_INTERNAL_LIST_ITEM_EVENT_ARG_H_ +#define _FUI_CTRL_INTERNAL_LIST_ITEM_EVENT_ARG_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum NotifyType +{ + NOTIFY_TYPE_SELECTED_ITEM = 0, + NOTIFY_TYPE_HIGHLIGHED_ITEM, + NOTIFY_TYPE_ANNEX_CHECK, + NOTIFY_TYPE_ANNEX_UNCHECK, + NOTIFY_TYPE_ANNEX_MORE, + NOTIFY_TYPE_LONG_PRESSED_ITEM, + NOTIFY_TYPE_SWEPT_ITEM, + NOTIFY_TYPE_REORDERED_ITEM, + NOTIFY_TYPE_SELCTED_CONTEXT_ITEM +}; + +class _ListItemEventArg + : public Tizen::Base::Runtime::IEventArg +{ +// Lifecycle +public: + _ListItemEventArg(int arg1, int arg2, int arg3, int arg4, NotifyType type); + + virtual ~_ListItemEventArg(void); + +// Accessor + int GetEventArg1(void) const; + + int GetEventArg2(void) const; + + int GetEventArg3(void) const; + + int GetEventArg4(void) const; + + void GetEventArgs(int& arg1, int& arg2, int& arg3, int& arg4); + + NotifyType GetNotifyType(void) const; + +private: + _ListItemEventArg(const _ListItemEventArg& rhs); + _ListItemEventArg& operator=(const _ListItemEventArg& rhs); + +// Attribute +private: + // Case 1. ListView event + // normal event : __arg1 - itemIndex / __arg2 - elementId + // reorder event : __arg1 - itemIndexFrom / __arg2 - itemIndexTo + // Case 2. GroupedListView event + // normal event : __arg1 - groupIndex / __arg2 - itemIndex / __arg3 - elementId + // reorder event : __arg1 - groupIndexFrom / __arg2 - itemIndexFrom / __arg3 - groupIndexTo / __arg4 - itemIndexTo + int __arg1; + int __arg2; + int __arg3; + int __arg4; + NotifyType __type; +}; // _ListItemEventArg + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LIST_ITEM_EVENT_ARG_H_ diff --git a/src/ui/inc/FUiCtrl_ListListener.h b/src/ui/inc/FUiCtrl_ListListener.h new file mode 100644 index 0000000..dd744d0 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListListener.h @@ -0,0 +1,53 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListListener.h + * @brief This is the header file for the _ListListener class. + * + * This header file contains the declarations of the _ListListener class and its helper classes. + */ + +#ifndef _FUICTRL_LIST_LISTENER_H_ +#define _FUICTRL_LIST_LISTENER_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ListListener + : public Tizen::Base::Object +{ + +public: + _ListListener(void) + : pListener(null) + { + } + + virtual ~_ListListener(void) {} + +private: + _ListListener(const _ListListener& rhs); + _ListListener& operator =(const _ListListener& rhs); + +public: + Tizen::Base::Runtime::IEventListener* pListener; +}; //_ListListener + +}}} + +#endif //_FUICTRL_LIST_LISTENER_H_ diff --git a/src/ui/inc/FUiCtrl_ListViewContextItem.h b/src/ui/inc/FUiCtrl_ListViewContextItem.h new file mode 100644 index 0000000..c99af06 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListViewContextItem.h @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListViewContextItem.h + * @brief This is the header file for the FUiCtrl_ListViewContextItem class. + * + * This header file contains the declarations of the FUiCtrl_ListViewContextItem class. + */ + +#ifndef _FUI_CTRL_INTERNAL_LIST_VIEW_CONTEXT_ITEM_H_ +#define _FUI_CTRL_INTERNAL_LIST_VIEW_CONTEXT_ITEM_H_ + +#include "FUi_Control.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_LinkedList.h" +#include "FUiCtrl_TableViewItem.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +struct _ListViewContextItemElement +{ + int elementId; + Tizen::Ui::Controls::_Button* pButton; +}; + +class _ListViewContextItem + : public Tizen::Ui::Controls::_TableViewItem +{ +public: + _ListViewContextItem(int itemHeight); + + virtual ~_ListViewContextItem(void); + + static _ListViewContextItem* CreateListViewContextItemN(int itemHeight); + + bool AddElement(int elementId, const Tizen::Base::String& text, bool enable = true); + + bool AddElement(int elementId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, + const Tizen::Graphics::Bitmap* pHighlightedBitmap, bool enable = true); + + bool AddElement(int elementId, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pNormalBitmap, + const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, bool enable = true); + + int GetElementIdFromPosition(const Tizen::Graphics::Point& position) const; + + void AddContextItemEventListener(Tizen::Ui::Controls::_IActionEventListener& listener); + + void RemoveContextItemEventListener(Tizen::Ui::Controls::_IActionEventListener& listener); + + void AdjustItemBounds(Tizen::Graphics::Rectangle& bounds); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + +private: + _ListViewContextItem(const _ListViewContextItem& rhs); + + _ListViewContextItem& operator =(const _ListViewContextItem& rhs); + + _ListViewContextItemElement* GetElement(int elementId) const; + + bool HasElement(int elementId); + + void AdjustElementLayout(void); + +private: + _LinkedList <_ListViewContextItemElement> __elements; + + int __margin; + int __elementSpacing; + int __elementHeight; + int __textSize; +}; // _ListContextItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LIST_VIEW_CONTEXT_ITEM_H_ diff --git a/src/ui/inc/FUiCtrl_ListViewImpl.h b/src/ui/inc/FUiCtrl_ListViewImpl.h new file mode 100644 index 0000000..3d2d116 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListViewImpl.h @@ -0,0 +1,252 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListViewImpl.h + * @brief This file defines the _ListViewImpl class. + * @version 3.0 + * + * This file contains the declarations of _ListViewImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_LIST_VIEW_IMPL_H_ +#define _FUI_CTRL_INTERNAL_LIST_VIEW_IMPL_H_ + +#include +#include "FUi_ControlImpl.h" +#include "FUi_TouchEventArg.h" +#include "FUiCtrl_IFastScrollListener.h" +#include "FUiCtrl_IScrollEventListener.h" +#include "FUiCtrl_IUiListViewItemEventListener.h" +#include "FUiCtrl_TableView.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _FastScrollEvent; +class _Label; +class _ListItemEvent; +class _ListViewItem; +class _PublicLinkEvent; +class _ScrollEvent; + +class _ListViewImpl + : public _ControlImpl + , public _IScrollEventListener + , public _ITableViewItemEventListener + , public _IUiFastScrollListener + , public _IUiListViewItemEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + virtual ~_ListViewImpl(void); + + static _ListViewImpl* CreateListViewImplN(ListView* pControl, bool itemDivider, bool fastScroll); + + static _ListViewImpl* CreateListViewImplN(ListView* pControl, bool itemDivider, ListScrollStyle scrollStyle); + + virtual const char* GetPublicClassName(void) const; + + virtual const ListView& GetPublic(void) const; + + virtual ListView& GetPublic(void); + + virtual const _TableView& GetCore(void) const; + + virtual _TableView& GetCore(void); + + result SetItemProvider(IListViewItemProvider& provider); + + void AddListViewItemEventListener(IListViewItemEventListener& listener); + + void RemoveListViewItemEventListener(IListViewItemEventListener& listener); + + void AddFastScrollListener(IFastScrollListener& listener); + + void RemoveFastScrollListener(IFastScrollListener& listener); + + void AddScrollEventListener(IScrollEventListener& listener); + + void RemoveScrollEventListener(IScrollEventListener& listener); + + void AddUiLinkEventListener(const Tizen::Ui::IUiLinkEventListener& listener); + + void RemoveUiLinkEventListener(const Tizen::Ui::IUiLinkEventListener& listener); + + result SetSweepEnabled(bool enable); + + result SetFastScrollIndex(const Tizen::Base::String& text, bool useSearchIcon); + + int GetTopDrawnItemIndex(void) const; + + int GetBottomDrawnItemIndex(void) const; + + result ScrollToItem(int index, ListScrollItemAlignment itemAlignment); + + result SetItemChecked(int index, bool check); + + bool IsItemChecked(int index) const; + + result SetItemEnabled(int index, bool enable); + + bool IsItemEnabled(int index) const; + + int GetItemCount(void) const; + + result ShowItemDescriptionText(int index); + + result HideItemDescriptionText(int index); + + result RefreshList(int index, ListRefreshType type); + + result RefreshList(int index, int elementId); + + result UpdateList(void); + + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& itemIndex, int& elementId) const; + + result SetItemDividerColor(const Tizen::Graphics::Color& color); + + Tizen::Graphics::Color GetItemDividerColor(void) const; + + result SetBitmapOfEmptyList(const Tizen::Graphics::Bitmap* pBitmap); + + result SetTextOfEmptyList(const Tizen::Base::String& text); + + Tizen::Base::String GetTextOfEmptyList(void) const; + + result SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + + result SetListBackgroundColor(const Tizen::Graphics::Color& color); + + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap* pBitmap); + + result BeginReorderingMode(void); + + result EndReorderingMode(void); + + bool IsInReorderingMode(void) const; + + virtual void OnListViewContextItemStateChanged(Tizen::Ui::_Control& source, int groupIndex, int itemIndex, int elementId, + Tizen::Ui::Controls::ListContextItemStatus status); + + virtual void OnListViewItemLongPressed(Tizen::Ui::_Control& source, int groupIndex, int itemIndex, int elementId); + + // _ITableViewItemEventListener + virtual void OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, + Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + + virtual void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, + Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + + virtual void OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo); + + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, + Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) {}; + + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, + Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) {}; + + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, + int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) {}; + + virtual void OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, + int groupIndexTo, int itemIndexTo) {}; + + virtual void OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, + Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status) {}; + + virtual void OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, + int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated) {}; + + virtual void OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, + Tizen::Ui::Controls::TableViewSweepDirection direction); + + // Event handler for _IScrollEventListener + virtual void OnScrollEndReached(Tizen::Ui::_Control& source, ScrollEndEvent type); + + virtual void OnScrollPositionChanged(Tizen::Ui::_Control& source, int scrollPos); + + virtual void OnScrollStopped(Tizen::Ui::_Control& source); + + // Event handler for _IUiFastScrollListener + virtual void OnUiFastScrollIndexSelected(Tizen::Ui::_Control& source, Tizen::Ui::Controls::_FastScrollIndex& index); + + virtual void OnDraw(void); + + virtual void OnBoundsChanged(void); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + virtual bool OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo); + +public: + static _ListViewImpl* GetInstance(ListView& listView); + + static const _ListViewImpl* GetInstance(const ListView& listView); + +private: + _ListViewImpl(ListView* pList, _TableView* pCore); + + _ListViewImpl(_ListViewImpl& rhs); + + _ListViewImpl& operator =(_ListViewImpl& rhs); + + result SetItemDescriptionTextShowState(int index, bool show); + + void AdjustLayoutOfEmptyList(void); + + void CheckEmptyListShowState(void); + + void FirePublicTouchEvent(const _TouchInfo& touchInfo); + + void FirePublicListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo); + + void FireFocusListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo); + + _TouchEventArg* GetTouchEventArgN(const _TouchInfo& touchInfo); + +private: + _ListItemEvent* __pListItemEvent; + _PublicLinkEvent* __pLinkEvent; + _ScrollEvent* __pScrollEvent; + _FastScrollEvent* __pFastScrollEvent; + + _Label* __pEmptyBitmap; + _Label* __pEmptyText; + Tizen::Graphics::Color __emptyTextColor; + + bool __redrawListView; + _ListViewItem* __pItemNeedsLazyDeletion; + _ListViewItem* __pItemSwept; +}; // _ListViewImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LIST_VIEW_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_ListViewItem.h b/src/ui/inc/FUiCtrl_ListViewItem.h new file mode 100644 index 0000000..d82361e --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListViewItem.h @@ -0,0 +1,335 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListViewItem.h + * @brief This is the header file for the _ListViewItem class. + * + * This header file contains the declarations of the _ListViewItem class. + */ + +#ifndef _FUI_CTRL_INTERNAL_LIST_VIEW_ITEM_H_ +#define _FUI_CTRL_INTERNAL_LIST_VIEW_ITEM_H_ + +#include +#include +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_ICustomElement.h" +#include "FUiCtrl_LinkedList.h" +#include "FUiCtrl_TableViewItem.h" + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +class _ITouchLongPressGestureEventListener; +class _TouchLongPressGestureDetector; +}} + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _Label; +class _ListViewContextItem; +class _Progress; + +enum ListViewItemElementType +{ + LISTVIEW_ITEM_ELEMENT_TEXT = 0, + LISTVIEW_ITEM_ELEMENT_BITMAP, + LISTVIEW_ITEM_ELEMENT_OBJ, + LISTVIEW_ITEM_ELEMENT_INVALID +}; + +enum ListViewItemSelectionType +{ + LISTVIEW_ITEM_SELECTED = 0, + LISTVIEW_ITEM_ELEMENT_SELECTED, + LISTVIEW_ITEM_UILINK_SELECTED +}; + +struct _ListViewItemUiLinkInfo +{ + Tizen::Base::String textInfo; + Tizen::Base::Utility::LinkType linkType; + Tizen::Base::String linkInfo; +}; + +struct _ListViewItemStateChangedInfo +{ + ListViewItemSelectionType selectionType; + int elementId; + _ListViewItemUiLinkInfo* pUiLinkInfo; +}; + +struct _ListViewItemElementText +{ + Tizen::Ui::_AccessibilityElement* pAccessibilityElement; + Tizen::Ui::Animations::_VisualElement* pVE; + Tizen::Graphics::_Text::TextObject* pTextObject; + Tizen::Graphics::_EnrichedTextImpl* pEnrichedText; + Tizen::Graphics::Color textColor[LISTVIEW_ITEM_STATUS_MAX]; + int textSize; + bool cutlinkViewModeEnabled; + bool cutlinkParseEnabled; + unsigned long cutlinkMaskType; + bool textSlidingEnabled; +}; + +struct _ListViewItemElementBitmap +{ + Tizen::Ui::Animations::_VisualElement* pVE; + Tizen::Graphics::Bitmap* pBitmap[LISTVIEW_ITEM_STATUS_MAX]; +}; + +struct _ListViewItemElementCustom +{ + Tizen::Ui::Animations::_VisualElement* pVE; + _ICustomElement* pCustom; +}; + +struct _ListViewItemElement +{ + int elementId; + bool actionElement; + bool selectionEnabled; + ListViewItemElementType elementType; + _ListViewItemElementText* pTextElement; + _ListViewItemElementBitmap* pBitmapElement; + _ListViewItemElementCustom* pCustomElement; + Tizen::Graphics::Rectangle bounds; +}; + +class _ListViewItemHitTestVEDelegator + : public Tizen::Ui::Animations::VisualElementContentProvider +{ +public: + _ListViewItemHitTestVEDelegator(void); + + virtual ~_ListViewItemHitTestVEDelegator(void); + + virtual Tizen::Ui::Animations::HitTestResult HitTest(Tizen::Ui::Animations::VisualElement& target, const Tizen::Graphics::FloatPoint& point); +}; // _ListViewItemHitTestVEDelegator + +class _ListViewItem + : public Tizen::Ui::Controls::_TableViewItem +{ +public: + _ListViewItem(int itemHeight); + + virtual ~_ListViewItem(void); + + static _ListViewItem* CreateListViewItemN(int itemHeight); + + void SetListViewItemType(ListViewItemType type); + + void AddTouchLongPressGestureEventListener(Tizen::Ui::_ITouchLongPressGestureEventListener& listener); + + void RemoveTouchLongPressGestureEventListener(Tizen::Ui::_ITouchLongPressGestureEventListener& listener); + + result AddElement(Tizen::Graphics::Rectangle& rect, int elementId, const Tizen::Base::String& text, bool textSliding = false); + + result AddElement(Tizen::Graphics::Rectangle& rect, int elementId, const Tizen::Graphics::EnrichedText* pEnrichedText, bool textSliding = false); + + result AddElement(Tizen::Graphics::Rectangle& rect, int elementId, const Tizen::Graphics::Bitmap* pNormalBitmap, + const Tizen::Graphics::Bitmap* pPressedBitmap = null, const Tizen::Graphics::Bitmap* pHighlightedBitmap = null); + + result AddElement(Tizen::Graphics::Rectangle& rect, int elementId, const _ICustomElement* pCustom); + + bool DeleteElement(int elementId); + + void DeleteAllElement(void); + + bool HasElement(int elementId); + + bool RefreshElement(int elementId); + + void SetLastStateChangedInfo(void); + + bool GetLastStateChangedInfo(_ListViewItemStateChangedInfo& changedInfo) const; + + void ClearLastStateChangedInfo(void); + + int GetElementIdFromPosition(const Tizen::Graphics::Point& position) const; + + int GetElementIdFromCurrentTouchPosition(void) const; + + ListViewItemElementType GetElementType(int elementId) const; + + bool SetElementSelectionEnabled(int elementId, bool enable); + + bool GetElementSelectionEnabled(int elementId, bool& enable); + + bool SetTextCutlinkMask(int elementId, unsigned long mask); + + bool SetTextCutlinkViewMode(int elementId, bool cutlinkViewMode, bool cutlinkParseEnable = true); + + bool SetTextAlignment(int elementId, Tizen::Graphics::_Text::TextObjectAlignment textAlignment); + + bool GetTextAlignment(int elementId, Tizen::Graphics::_Text::TextObjectAlignment& textAlignment) const; + + bool SetTextWrapType(int elementId, Tizen::Graphics::_Text::TextObjectWrapType wrapType); + + bool SetTextSize(int elementId, int textSize); + + bool SetTextColor(int elementId, Tizen::Graphics::Color textColor, ListViewItemDrawingStatus status = LISTVIEW_ITEM_STATUS_NORMAL); + + bool GetTextColor(int elementId, Tizen::Graphics::Color& textColor, ListViewItemDrawingStatus status = LISTVIEW_ITEM_STATUS_NORMAL) const; + + bool SetProgressValue(int value); + + bool SetProgressMargins(int leftMargin, int rightMargin); + + bool SetDescriptionText(const Tizen::Base::String& text); + + void SetDescriptionTextColor(const Tizen::Graphics::Color& color); + + void SetDescriptionTextShowState(bool show); + + void SetContextItemEventListener(Tizen::Ui::Controls::_IActionEventListener& listener); + + void SetContextItemActivationState(bool activate); + + // Window event handler + virtual void OnDraw(void); + + virtual void OnBoundsChanged(void); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + virtual void OnAncestorEnableStateChanged(const _Control& control); + + // Touch event handler + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + // Timer Callback API + void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + +private: + _ListViewItem(const _ListViewItem& rhs); + + _ListViewItem& operator =(const _ListViewItem& rhs); + + void DeleteElement(_ListViewItemElement* pElement); + + _ListViewItemElement* GetElement(int elementId) const; + + Tizen::Graphics::_Text::TextObject* GetTextObjectInElement(int elementId) const; + + _ListViewItemElementText* GetElementText(int elementId) const; + + _ListViewItemElementBitmap* GetElementBitmap(int elementId) const; + + ListViewItemDrawingStatus GetItemDrawingStatus(void); + + void DrawElement(_ListViewItemElement* pElement); + + void DrawElements(void); + + bool DrawText(Tizen::Graphics::Rectangle& rect, ListViewItemDrawingStatus status, _ListViewItemElementText* pText); + + bool DrawBitmap(Tizen::Graphics::Rectangle& rect, ListViewItemDrawingStatus status, _ListViewItemElementBitmap* pBitmap); + + void DrawDivider(void); + + int GetDescriptionTextHeight(void); + + void AdjustProgressBounds(void); + + Tizen::Graphics::Font* GetFont(unsigned long fontStyle, int fontSize); + + // TextSlide + void StartTextSlideTimer(void); + + void StopTextSlideTimer(void); + + bool IsTextSlideTimerRunning(void); + + void OnTextSlideTimerExpired(void); + + void ResetTextSlide(void); + + // UiLink + bool ParseCutlinkText(_ListViewItemElementText* pText); + + bool IsCutlinkTextSelected(const Tizen::Graphics::Point& position, int* index, _ListViewItemUiLinkInfo** ppInfo) const; + + bool SetCutlinkTextFocus(const Tizen::Graphics::Point& position); + + bool ResetCutlinkFocus(void); + + void SetAccessibilityElement(void); + +private: + static const int TOUCH_LONGPRESSED_EVENT_DURATION = 300; + static const int TEXT_SLIDING_TIMER_DURATION = 60; + + _LinkedList <_ListViewItemElement> __elements; + + ListViewItemType __itemType; + + bool __touchPressed; + + int __selectedElementId; + + int __progressLeftMargin; + + int __progressRightMargin; + + _Progress* __pProgress; + + bool __descriptionTextShowState; + + Tizen::Graphics::Color __descriptionTextColor; + + _Label* __pDescriptionText; + + _Label* __pDivider; + + bool __selectionEabled; + + Tizen::Graphics::Color __selectionEabledBgColor; + + unsigned long __fontStyle; + + int __fontSize; + + Tizen::Base::String __fontName; + + Tizen::Graphics::Point __prevTouchPos; // for UiLink + + Tizen::Base::Runtime::Timer* __pTextSlideTimer; + + _ListViewItemStateChangedInfo ___stateChangedInfo; // for event fire in _ListViewImpl + + _ListViewItemHitTestVEDelegator __hitTestVEDelegator; + + _TouchLongPressGestureDetector* __pLongPressedGesture; + + _IActionEventListener* __pContextItemEventListener; +}; // _ListViewItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LIST_VIEW_ITEM_H_ diff --git a/src/ui/inc/FUiCtrl_ListViewItemProviderAdaptor.h b/src/ui/inc/FUiCtrl_ListViewItemProviderAdaptor.h new file mode 100644 index 0000000..e85b90d --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListViewItemProviderAdaptor.h @@ -0,0 +1,98 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListViewItemProviderAdaptor.h + * @brief This is the header file for the __ListViewItemProviderAdaptor class. + * + * This header file contains the declarations of the __ListViewItemProviderAdaptor class. + */ + +#ifndef _FUI_CTRL_INTERNAL_LIST_VIEW_ITEM_PROVIDER_ADAPTOR_H_ +#define _FUI_CTRL_INTERNAL_LIST_VIEW_ITEM_PROVIDER_ADAPTOR_H_ + +#include +#include +#include "FUiCtrl_IUiListViewItemEventListener.h" +#include "FUiCtrl_LinkedList.h" +#include "FUiCtrl_TableViewItemProviderAdaptor.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IListItemCommon; +class _ListViewItem; + +class _ListViewItemProviderAdaptor + : public _TableViewItemProviderAdaptor +{ +public: +// Lifecycle + _ListViewItemProviderAdaptor(const IListViewItemProvider& provider); + + virtual ~_ListViewItemProviderAdaptor(void); + +// Operation + void SetItemProvider(const IListViewItemProvider& provider); + + virtual _IListItemCommon* LoadItem(int groupIndex, int itemIndex); + + virtual result UnloadItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex); + + virtual result DeleteItem(_IListItemCommon* pListItem, int groupIndex, int itemIndex); + + virtual bool UpdateItem(_IListItemCommon* pItem, int groupIndex, int itemIndex); + + virtual int GetItemCount(int groupIndex = 0) const; + + virtual int GetGroupCount(void) const; + + virtual int GetDefaultItemHeight(void); + + virtual int GetDefaultGroupItemHeight(void); + + bool SetDescriptionTextShowState(int itemIndex, bool show); + + bool IsDescriptionTextShown(int itemIndex) const; + + void SetListViewItemEventListener(Tizen::Ui::Controls::_IUiListViewItemEventListener& listener); + + void SetItemFont(const Tizen::Base::String& fontName); + + void SetItemNeedsLazyDeletion(_ListViewItem* pItem); + +private: + _ListViewItemProviderAdaptor(const _ListViewItemProviderAdaptor& rhs); + + _ListViewItemProviderAdaptor& operator =(const _ListViewItemProviderAdaptor& rhs); + +// Variable +private: + IListViewItemProvider* __pListViewProvider; + _LinkedList __descriptionTextShowItem; + _IUiListViewItemEventListener* __pEventListener; + Tizen::Base::String __fontName; + int __itemAverageHeight; + int __itemLoadedCount; + int __countOfAllItems; + _ListViewItem* __pItemNeedsLazyDeletion; +}; // _ListViewItemProviderAdaptor + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LIST_VIEW_ITEM_PROVIDER_ADAPTOR_H_ + diff --git a/src/ui/inc/FUiCtrl_ListViewModel.h b/src/ui/inc/FUiCtrl_ListViewModel.h new file mode 100644 index 0000000..8293d73 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListViewModel.h @@ -0,0 +1,191 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListViewModel.h + * @brief This is the header file for the _ListViewModel class. + * + * This header file contains the declarations of the _ListViewModel class. + */ + +#ifndef _FUI_CTRL_INTERNAL_LIST_VIEW_MODEL_H_ +#define _FUI_CTRL_INTERNAL_LIST_VIEW_MODEL_H_ + +#include "FUiCtrl_LinkedList.h" +#include "FUiCtrl_ListViewTypes.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IListItemProviderAdaptor; +class _IListItemCommon; + +struct _ListViewGroupNode +{ + +public: + _ListViewGroupNode(void) + { + __itemCountInGroup = 0; + __radioCheckedItemIndex = -1; + __usingRadioStyle = false; + __itemExpanded = true; + } + +private: + friend class _ListViewModel; + + _LinkedList <_IListItemCommon*> __items; + _LinkedList __checkedItems; + _LinkedList __disabledItems; + int __itemCountInGroup; // except groupItem + int __radioCheckedItemIndex; + bool __usingRadioStyle; + bool __itemExpanded; +}; // _ListViewGroupNode + +class _ListViewModel +{ +public: + _ListViewModel(void); + + virtual ~_ListViewModel(void); + + // Set/Get ItemProviderAdaptor + _IListItemProviderAdaptor* GetItemProviderAdaptor(void) const; + + result RegisterItemProviderAdaptor(const _IListItemProviderAdaptor* pProviderAdaptor); + + //item handling ( Add / Insert / Delete / Get ) + _IListItemCommon* GetGroup(int groupIndex) const; + + _IListItemCommon* LoadItem(int groupIndex, int itemIndex); + + _IListItemCommon* GetItemFromContainer(int groupIndex, int itemIndex) const; + + _IListItemCommon* GetItemFromTemporaryBuffer(int groupIndex, int itemIndex); + + bool IsValidItem(int groupIndex, int itemIndex) const; + + bool IsLoadedItem(int groupIndex, int itemIndex) const; + + result AddGroup(int itemCount = 0, bool usingRadioStyle = false); + + result InsertGroup(int groupIndex, int itemCount = 0, bool usingRadioStyle = false); + + result RemoveGroup(int groupIndex); + + result AddItemToGroup(_IListItemCommon* pItem, int groupIndex); + + result InsertItemToGroup(_IListItemCommon* pItem, int groupIndex, int itemIndex); + + result SetItem(_IListItemCommon& item, int groupIndex, int itemIndex); + + result MoveItem(_ListItemPos originPosition, _ListItemPos destinationPosition); + + result RemoveItemAt(int groupIndex, int itemIndex, bool internalDestroy = false); + + result RemoveAllItem(bool internalDestroy = false, bool backupItemStatus = false); + + void RestoreItemStatus(void); + + result DeleteAllGroupAndItem(void); + + result SetMaxCachingSize(int cachingSize); + + int GetMaxCachingSize(void) const; + + result UnloadItem(int groupIndex, int itemIndex); + + // Focused item & element + bool IsFocusedItem(int groupIndex, int itemIndex) const; + + void GetFocusedItem(int& groupIndex, int& itemIndex) const; + + void SetFocusedItem(int groupIndex, int itemIndex); + + bool IsItemEnabled(int groupIndex, int itemIndex) const; + + result SetItemEnabled(int groupIndex, int itemIndex, bool enable); + + result SetItemChecked(int groupIndex, int itemIndex, bool check); + + bool IsItemChecked(int groupIndex, int itemIndex) const; + + int GetIndexOfRadioCheckedItem(int groupIndex) const; + + //item handling - Group and item + int GetAllItemCount(void) const; + + int GetAllGroupCount(void) const; + + int GetItemCountInGroup(int groupIndex) const; + + // for group Expand/Collapse + result SetGroupExpandState(int groupIndex, bool state); + + bool IsGroupExpanded(int groupIndex) const; + + void SetAllLoadedItemStateChanged(bool state); + + void GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const; + + void GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const; + +private: + void MoveCheckedAndDisabledItemIndex(_ListViewGroupNode* pListGroupNode, int originItemIndex, int destinationItemIndex, bool checked = false, bool enabled = true); + + result LoadItemToContainer(int groupIndex, int itemIndex, _IListItemCommon& item); + + result UnloadAllItem(void); + + // item handling - item states + int GetOverflowCount(void) const; + + result RemoveOverflowItems(bool deleteFromEnd, int removeCount); + + _ListViewGroupNode* GetGroupNode(int groupIndex) const; + +private: + _ListViewModel(const _ListViewModel& rhs); + + _ListViewModel& operator =(const _ListViewModel& rhs); + +private: + static const int CACHE_SIZE = 30; + + // member variables for view + _LinkedList <_ListViewGroupNode*> __groupNodes; + _LinkedList <_ListViewGroupNode*> __backupGroupNodes; + _IListItemProviderAdaptor* __pListProviderAdaptor; + _IListItemCommon* __pTemporaryItemBuffer; + int __countOfAllGroups; + int __countOfAllItems; + + // member variables for items + int __indexOfFocusedGroup; + int __indexOfFocusedItem; + + // member variables for model + int __sizeOfCachingItems; + bool __overflowItemsRemovingEnabled; +}; // _ListViewModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LIST_VIEW_MODEL_H_ + diff --git a/src/ui/inc/FUiCtrl_ListViewTypes.h b/src/ui/inc/FUiCtrl_ListViewTypes.h new file mode 100644 index 0000000..826e073 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ListViewTypes.h @@ -0,0 +1,53 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ListViewTypes.h + * @brief This is the header file for the _ListView enumerations. + * + * This header file contains the declarations of the _ListView enumerations. + */ + +#ifndef _FUI_CTRL_INTERNAL_LIST_VIEW_TYPES_H_ +#define _FUI_CTRL_INTERNAL_LIST_VIEW_TYPES_H_ + +#define LIST_ITEM_RESERVED_ID_1 -1 +#define LIST_ITEM_RESERVED_ID_2 10002 +#define LIST_ITEM_RESERVED_ID_3 10003 + +enum ListViewItemDrawingStatus +{ + LISTVIEW_ITEM_STATUS_NORMAL = 0, + LISTVIEW_ITEM_STATUS_PRESSED, + LISTVIEW_ITEM_STATUS_HIGHLIGHTED, + LISTVIEW_ITEM_STATUS_MAX +}; + +enum ListViewItemType +{ + LISTVIEW_ITEM_TYPE_SIMPLE = 0, + LISTVIEW_ITEM_TYPE_CUSTOM, + LISTVIEW_ITEM_TYPE_GROUP +}; + +struct _ListItemPos +{ + int groupIndex; + int itemIndex; +}; + +#endif //_FUI_CTRL_INTERNAL_LIST_VIEW_TYPES_H_ diff --git a/src/ui/inc/FUiCtrl_MessageBox.h b/src/ui/inc/FUiCtrl_MessageBox.h new file mode 100644 index 0000000..30cb407 --- /dev/null +++ b/src/ui/inc/FUiCtrl_MessageBox.h @@ -0,0 +1,123 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_MessageBox.h + * @brief This is the header file for the _MessageBox class. + * + * This header file contains the declarations of the %_MessageBox class. + */ + +#ifndef _FUI_CTRL_INTERNAL_MESSAGEBOX_H_ +#define _FUI_CTRL_INTERNAL_MESSAGEBOX_H_ + + +#include +#include "FUiCtrl_Popup.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _MessageBoxPresenter; + +/** + * @class _MessageBox + * @brief + * @since 1.0 + * + * + * + * + */ +class _OSP_EXPORT_ _MessageBox + : public _Popup + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ +// Lifecycle +public: + virtual ~_MessageBox(void); + +// Operations +public: + static _MessageBox* CreateMessageBoxN(void); + result Initialize(const Tizen::Base::String& title, const Tizen::Base::String& text, MessageBoxStyle style, unsigned long timeout); + + virtual result ShowAndWait(int& modalResult); + + int GetTotalHeight(void) const; + + virtual void OnDraw(void); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + virtual void OnActivated(void); + virtual void OnDeactivated(void); + + virtual result OnAttachedToMainTree(void); + + virtual void OnChangeLayout(_ControlOrientation orientation); + + virtual void OnBoundsChanged(void); + + +// Accessors +public: + MessageBoxStyle GetMsgBoxStyle(void) const; + + unsigned long GetTimeout(void) const; + + Tizen::Base::String GetText(void) const; + + void SetTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTextColor(void) const; + +protected: + result SetPresenter(const _MessageBoxPresenter& msgboxPresenter); + + // Touch Event Listener + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + +private: + _MessageBox(void); + + _MessageBox(const _MessageBox& rhs); + _MessageBox& operator =(const _MessageBox& rhs); + +// Attributes +private: + _MessageBoxPresenter* __pMsgboxPresenter; + + MessageBoxStyle __msgboxStyle; + + Tizen::Graphics::Color __textColor; + Tizen::Base::String __text; + + unsigned long __timeout; + +}; // _MessageBox + + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_MESSAGEBOX_H_ + diff --git a/src/ui/inc/FUiCtrl_MessageBoxImpl.h b/src/ui/inc/FUiCtrl_MessageBoxImpl.h new file mode 100644 index 0000000..16e23c0 --- /dev/null +++ b/src/ui/inc/FUiCtrl_MessageBoxImpl.h @@ -0,0 +1,91 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_MessageBoxImpl.h + * @brief This is the header file for the _MessageBoxImpl class. + * + * This header file contains the declarations of the %_MessageBoxImpl class. + */ + +#ifndef _FUI_CTRL_MESSAGEBOX_IMPL_H_ +#define _FUI_CTRL_MESSAGEBOX_IMPL_H_ + + +// Includes +#include +#include "FUi_WindowImpl.h" +#include "FUiCtrl_MessageBox.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +class _MessageBoxImpl + : public _WindowImpl +{ +public: + _MessageBoxImpl(MessageBox* pPublic, _MessageBox* pCore); + virtual ~_MessageBoxImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const MessageBox& GetPublic(void) const; + virtual MessageBox& GetPublic(void); + virtual const _MessageBox& GetCore(void) const; + virtual _MessageBox& GetCore(void); + +public: + static _MessageBoxImpl* CreateMessageBoxImplN(MessageBox* pControl); + result Initialize(const Tizen::Base::String& title, const Tizen::Base::String& text, MessageBoxStyle style, unsigned long timeout); + + virtual result ShowAndWait(int& modalResult); + + Tizen::Graphics::Rectangle GetCenterAlignRect(int width, int height) const; + + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + +public: + void SetColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetColor(void) const; + + void SetTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTitleTextColor(void) const; + + void SetTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTextColor(void) const; + + MessageBoxStyle GetMessageBoxStyle(void) const; + Tizen::Base::String GetTitleText(void) const; + Tizen::Base::String GetText(void) const; + unsigned long GetTimeout(void) const; + int GetMaxTextLength(void) const; + +public: + static _MessageBoxImpl* GetInstance(MessageBox& pMessageBox); + static const _MessageBoxImpl* GetInstance(const MessageBox& pMessageBox); + +private: + _MessageBoxImpl(const _MessageBoxImpl& rhs); + _MessageBoxImpl& operator =(const _MessageBoxImpl& rhs); + +}; // _MessageBoxImpl + + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_MESSAGEBOX_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_MessageBoxPresenter.h b/src/ui/inc/FUiCtrl_MessageBoxPresenter.h new file mode 100644 index 0000000..a6ef420 --- /dev/null +++ b/src/ui/inc/FUiCtrl_MessageBoxPresenter.h @@ -0,0 +1,185 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_MessageBoxPresenter.h + * @brief This is the header file for the _MessageBoxPresenter class. + * + * This header file contains the declarations of the %_MessageBoxPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_MESSAGEBOX_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_MESSAGEBOX_PRESENTER_H_ + + +#include +#include "FUi_UiTouchEvent.h" +#include "FUiCtrl_PopupPresenter.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +class Button; +class _MessageBox; +class _Scroll; + +/** + * @class _MessageBoxPresenter + * @brief + * @since 1.0 + * + * + * + * + */ +class _MessageBoxPresenter + : public _PopupPresenter + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + _MessageBoxPresenter(void); + virtual ~_MessageBoxPresenter(void); + +// Operations +public: + result Initialize(_MessageBox& msgbox); + + virtual void Draw(void); + + virtual result ShowAndWait(int& modalResult); + + result OnAttachedToMainTree(void); + + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + + result SetFontInfo(unsigned long style, int size); + + // get touch event from _MessageBox, for drawing scroll in TextObject + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + +//Accessor +public: + int GetBodyTextHeight(void) const; + + Tizen::Graphics::Rectangle GetTitleBounds(void) const; + Tizen::Graphics::Rectangle GetTextBounds(void) const; + +protected: + virtual void ProcessEvent(void); + +private: + _MessageBoxPresenter(const _MessageBoxPresenter& rhs); + _MessageBoxPresenter& operator =(const _MessageBoxPresenter& rhs); + + result CreateButtons(void); + void FindButtonAndResult(const _ControlHandle handle); + + int CalculateButtonAreaHeight(void); + Tizen::Graphics::Rectangle CalculateButtonPositionAndSize(int buttonIndex); + + void SetReturnValue(MessageBoxModalResult rtn); + int GetReturnValue(void) const; + +// Inner class +private: + class _MessageBoxButtonListener + : public ITouchEventListener + , virtual public Tizen::Base::Runtime::IEventListener + { +public: + _MessageBoxButtonListener(void); + virtual ~_MessageBoxButtonListener(void); + + _ControlHandle GetClickedButtonHandle(void) const; + bool IsButtonClicked(void); + +protected: + virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, + const Tizen::Ui::TouchEventInfo& touchInfo); + virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, + const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, + const Tizen::Ui::TouchEventInfo& touchInfo); + virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, + const Tizen::Ui::TouchEventInfo& touchInfo); + virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, + const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, + const Tizen::Ui::TouchEventInfo& touchInfo) {} + virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, + const Tizen::Ui::TouchEventInfo& touchInfo) {} + +private: + _ControlHandle __buttonHandle; + + bool __buttonPressFlag; + bool __buttonReleaseState; + + Tizen::Graphics::Point __point; + + }; // class _MessageBoxButtonListener + + +private: + enum + { + MSGBOX_BUTTON_CLICKED = 0xFF + }; + +// Attributes +private: + _MessageBox* __pMessageBox; + _MessageBoxButtonListener* __pButtonListener; + MessageBoxModalResult __msgboxResult; + + Tizen::Ui::Controls::Button* __pButtons[3]; + + Tizen::Ui::_AccessibilityElement* __pTextAccessibilityElement; + + Tizen::Graphics::_Text::TextObject* __pTitleTextObject; + Tizen::Graphics::_Text::TextObject* __pBodyTextObject; + + Tizen::Graphics::Rectangle __titleBounds; + Tizen::Graphics::Rectangle __textBounds; + + Tizen::Ui::Controls::_Scroll* __pScroll; + + unsigned long __fontStyle; + int __fontSize; + + int __scrollPos; + int __buttonNum; + int __prevPositionY; + int __textObjHeight; + + bool __touchPressFlag; + bool __scrollStart; + bool __btnClickFlag; + bool __bodyClickFlag; + bool __touchOutBounds; + +}; // _MessageBoxPresenter + + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_MESSAGEBOX_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_OptionMenu.h b/src/ui/inc/FUiCtrl_OptionMenu.h new file mode 100644 index 0000000..79d6bb9 --- /dev/null +++ b/src/ui/inc/FUiCtrl_OptionMenu.h @@ -0,0 +1,157 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OptionMenu.h + * @brief This is the header file for the _OptionMenu class. + */ + +#ifndef _FUI_CTRL_INTERNAL_OPTION_MENU_H_ +#define _FUI_CTRL_INTERNAL_OPTION_MENU_H_ + +#include + +#include "FUi_Window.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_OptionMenuItem.h" + +namespace Tizen { namespace Ui { +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ActionEvent; +class _ContextMenu; +class _OptionMenuPresenter; + +class _OSP_EXPORT_ _OptionMenu + : public Tizen::Ui::_Window + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ +public: + result AddActionEventListener(const _IActionEventListener& listener); + + result RemoveActionEventListener(const _IActionEventListener& listener); + + result FireActionEvent(int actionId); + + result AddItem(const Tizen::Base::String& text, int actionId); + + result InsertItemAt(int mainIndex, const Tizen::Base::String& text, int actionId); + + result SetItemAt(int mainIndex, const Tizen::Base::String& text, int actionId); + + result RemoveItemAt(int mainIndex); + + int GetItemCount(void) const; + + int GetItemIndexFromActionId(int actionId) const; + + int GetItemActionIdAt(int mainIndex) const; + + result AddSubItem(int mainIndex, const Tizen::Base::String& text, int actionId); + + result InsertSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId); + + result SetSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId); + + result RemoveSubItemAt(int mainIndex, int subIndex); + + int GetSubItemCount(int mainIndex) const; + + int GetSubItemIndexFromActionId(int actionId) const; + + int GetSubItemActionIdAt(int mainIndex, int subIndex) const; + + bool IsSubMenuShown(void) const; + + result ShowSubMenu(int mainIndex, _OptionMenuItem& item); + + result DestroySubMenu(void); + + Tizen::Ui::_AccessibilityElement* GetAccessibilityElement(int mainIndex); + +public: +// _IControlDelegator + virtual void OnDraw(void); + + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + + virtual void OnBoundsChanged(void); + + virtual result OnAttachingToMainTree(const Tizen::Ui::_Control* pParent); + + virtual result OnAttachedToMainTree(void); + + virtual result OnDetachingFromMainTree(void); + + virtual void OnVisibleStateChanged(void); + +// _IWindowDelegator + virtual void OnActivated(void); + + virtual void OnDeactivated(void); + +// _ITouchEventListener + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + +// _IActionEventListener + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + + virtual ~_OptionMenu(void); + + static _OptionMenu* CreateOptionMenuN(void); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + +private: + _OptionMenu(void); + + _OptionMenu(const _OptionMenu&); + + _OptionMenu& operator =(const _OptionMenu&); + + void SetBoundsAllAccessibilityElement(void); + + void RemoveAllAccessibilityElement(void); + +private: + _OptionMenuPresenter* __pOptionMenuPresenter; + + _ActionEvent* __pActionEvent; + + _ContextMenu* __pSubMenu; + + int __subMenuIndex; + + Tizen::Base::Collection::LinkedListT<_AccessibilityElement*> __accessibilityElements; +}; // _OptionMenu + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_OPTION_MENU_H_ diff --git a/src/ui/inc/FUiCtrl_OptionMenuImpl.h b/src/ui/inc/FUiCtrl_OptionMenuImpl.h new file mode 100644 index 0000000..aed49d5 --- /dev/null +++ b/src/ui/inc/FUiCtrl_OptionMenuImpl.h @@ -0,0 +1,109 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OptionMenuImpl.h + * @brief This is the header file for the _OptionMenuImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_OPTION_MENU_IMPL_H_ +#define _FUI_CTRL_INTERNAL_OPTION_MENU_IMPL_H_ + +#include + +#include "FUiCtrl_OptionMenu.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUi_WindowImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _PublicActionEvent; + +class _OptionMenuImpl + : public Tizen::Ui::_WindowImpl + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + result AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + result RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + result AddItem(const Tizen::Base::String& text, int actionId); + + result InsertItemAt(int mainIndex, const Tizen::Base::String& text, int actionId); + + result SetItemAt(int mainIndex, const Tizen::Base::String& text, int actionId); + + result RemoveItemAt(int mainIndex); + + int GetItemCount(void) const; + + int GetItemIndexFromActionId(int actionId) const; + + int GetItemActionIdAt(int mainIndex) const; + + result AddSubItem(int mainIndex, const Tizen::Base::String& text, int actionId); + + result InsertSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId); + + result SetSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId); + + result RemoveSubItemAt(int mainIndex, int subIndex); + + int GetSubItemCount(int mainIndex) const; + + int GetSubItemIndexFromActionId(int actionId) const; + + int GetSubItemActionIdAt(int mainIndex, int subIndex) const; + + virtual const char* GetPublicClassName(void) const; + + virtual const OptionMenu& GetPublic(void) const; + + virtual OptionMenu& GetPublic(void); + + virtual const _OptionMenu& GetCore(void) const; + + virtual _OptionMenu& GetCore(void); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + + virtual ~_OptionMenuImpl(void); + + static _OptionMenuImpl* GetInstance(OptionMenu& optionMenu); + + static const _OptionMenuImpl* GetInstance(const OptionMenu& optionMenu); + + static _OptionMenuImpl* CreateOptionMenuImplN(OptionMenu& control); + + virtual result OnAttachedToMainTree(void); + +private: + _OptionMenuImpl(OptionMenu* pPublic, _OptionMenu* pCore); + + _OptionMenuImpl(const _OptionMenuImpl&); + + _OptionMenuImpl& operator =(const _OptionMenuImpl&); + +private: + _PublicActionEvent* __pPublicActionEvent; +}; // _OptionMenuImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_OPTION_MENU_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_OptionMenuItem.h b/src/ui/inc/FUiCtrl_OptionMenuItem.h new file mode 100644 index 0000000..638cfbc --- /dev/null +++ b/src/ui/inc/FUiCtrl_OptionMenuItem.h @@ -0,0 +1,82 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OptionMenuItem.h + * @brief This is the header file for the _OptionMenuItem class. + */ + +#ifndef _FUI_CTRL_INTERNAL_OPTION_MENU_ITEM_H_ +#define _FUI_CTRL_INTERNAL_OPTION_MENU_ITEM_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _OptionMenuItem + : public Tizen::Base::Object +{ +public: + void SetText(const Tizen::Base::String& text); + + const Tizen::Base::String& GetText(void) const; + + void SetActionId(int actionId); + + int GetActionId(void) const; + + result InsertSubItemAt(_OptionMenuItem& subItem, int index); + + result RemoveSubItemAt(int index); + + result RemoveAllSubItem(void); + + _OptionMenuItem* GetSubItem(int index); + + const _OptionMenuItem* GetSubItem(int index) const; + + int GetSubItemCount(void) const; + + int GetSubItemIndexFromActionId(int actionId) const; + + bool HasSubItem(void) const; + + virtual ~_OptionMenuItem(void); + + static _OptionMenuItem* CreateInstanceN(void); + +private: + _OptionMenuItem(void); + + _OptionMenuItem(const _OptionMenuItem&); + + _OptionMenuItem& operator=(const _OptionMenuItem&); + +private: + Tizen::Base::String __text; + + int __actionId; + + Tizen::Base::Collection::ArrayList* __pSubItems; +}; // _OptionMenuItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_OPTION_MENU_ITEM_H_ diff --git a/src/ui/inc/FUiCtrl_OptionMenuModel.h b/src/ui/inc/FUiCtrl_OptionMenuModel.h new file mode 100644 index 0000000..c7bd9b5 --- /dev/null +++ b/src/ui/inc/FUiCtrl_OptionMenuModel.h @@ -0,0 +1,78 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OptionMenuModel.h + * @brief This is the header file for the _OptionMenuModel class. + */ + +#ifndef _FUI_CTRL_INTERNAL_OPTION_MENU_MODEL_H_ +#define _FUI_CTRL_INTERNAL_OPTION_MENU_MODEL_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _OptionMenuItem; + +class _OptionMenuModel + : public Tizen::Base::Object +{ +public: + result AddItem(const Tizen::Base::String& text, int actionId, int mainIndex = -1); + + result InsertItemAt(const Tizen::Base::String& text, int actionId, int mainIndex, int subIndex = -1); + + result SetItemAt(const Tizen::Base::String& text, int actionId, int mainIndex, int subIndex = -1); + + result RemoveItemAt(int mainIndex, int subIndex = -1); + + result RemoveAllItem(void); + + _OptionMenuItem* GetItem(int mainIndex, int subIndex = -1); + + const _OptionMenuItem* GetItem(int mainIndex, int subIndex = -1) const; + + int GetItemCount(void) const; + + int GetItemIndexFromActionId(int actionId) const; + + int GetSubItemCount(int mainIndex) const; + + int GetSubItemIndexFromActionId(int actionId, int& mainIndex) const; + + virtual ~_OptionMenuModel(void); + + static _OptionMenuModel* CreateInstanceN(void); + +private: + _OptionMenuModel(void); + + _OptionMenuModel(const _OptionMenuModel&); + + _OptionMenuModel& operator =(const _OptionMenuModel&); + +private: + Tizen::Base::Collection::ArrayList __items; +}; // _OptionMenuModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_OPTION_MENU_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_OptionMenuPresenter.h b/src/ui/inc/FUiCtrl_OptionMenuPresenter.h new file mode 100644 index 0000000..3a58250 --- /dev/null +++ b/src/ui/inc/FUiCtrl_OptionMenuPresenter.h @@ -0,0 +1,256 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OptionMenuPresenter.h + * @brief This is the header file for the _OptionMenuPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_OPTION_MENU_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_OPTION_MENU_PRESENTER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "FUi_Control.h" + +namespace Tizen { namespace Graphics { +class Font; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _OptionMenu; +class _OptionMenuModel; + +class SineThirtyThreeTimingFunction + : public Tizen::Ui::Animations::IVisualElementAnimationTimingFunction +{ +public: + float CalculateProgress(float timeProgress) const; +}; // SineTimingFunction + +class SineSixtyTimingFunction + : public Tizen::Ui::Animations::IVisualElementAnimationTimingFunction +{ +public: + float CalculateProgress(float timeProgress) const; +}; // SineTimingFunction + +class _OptionMenuPresenter + : public Tizen::Base::Object + , virtual public Tizen::Ui::Animations::VisualElementAnimationProvider + , virtual public Tizen::Ui::Animations::IVisualElementAnimationProvider + , virtual public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + result AddItem(const Tizen::Base::String& text, int actionId); + + result InsertItemAt(int mainIndex, const Tizen::Base::String& text, int actionId); + + result SetItemAt(int mainIndex, const Tizen::Base::String& text, int actionId); + + result RemoveItemAt(int mainIndex); + + Tizen::Graphics::Rectangle GetItemBounds(int index) const; + + int GetItemCount(void) const; + + int GetItemIndexFromActionId(int actionId) const; + + int GetItemActionIdAt(int mainIndex) const; + + result AddSubItem(int mainIndex, const Tizen::Base::String& text, int actionId); + + result InsertSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId); + + result SetSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId); + + result RemoveSubItemAt(int mainIndex, int subIndex); + + int GetSubItemCount(int mainIndex) const; + + int GetSubItemIndexFromActionId(int actionId) const; + + int GetSubItemActionIdAt(int mainIndex, int subIndex) const; + + result Draw(void); + +public: + result InitializeVisualElement(void); + + result InitializeTextObject(void); + +// _IControlDelegator + void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + + result OnAttachingToMainTree(const Tizen::Ui::_Control* pParent); + + result OnAttachedToMainTree(void); + + result OnDetachingFromMainTree(void); + + void OnVisibleStateChanged(void); + +// _ITouchEventListener + bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + +// _IActionEventListener + void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + + virtual ~_OptionMenuPresenter(void); + + static _OptionMenuPresenter* CreateInstanceN(_OptionMenu& optionMenu); + + result CalculateBounds(void); + + result PrepareAnimation(void); + result SetOptionMenuVisibility(bool visibility); + virtual Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationForProperty(Tizen::Ui::Animations::VisualElement& target, const Tizen::Base::String& property); + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount); + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + result DrawResourceBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, Tizen::Graphics::Bitmap* pBitmap); + + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + Tizen::Graphics::Font* GetFont(void) const; + +private: + _OptionMenuPresenter(_OptionMenu* optionMenu); + + _OptionMenuPresenter(const _OptionMenuPresenter&); + + _OptionMenuPresenter& operator =(const _OptionMenuPresenter&); + + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + + result LoadBitmap(void); + + result DrawHandler(Tizen::Graphics::Canvas& canvas); + + result DrawItem(Tizen::Graphics::Canvas& canvas, int index); + + result DrawItemLine(Tizen::Graphics::Canvas& canvas); + + result RefreshItem(int index); + + result LoadShapeResource(Tizen::Ui::_ControlOrientation orientation); + + void Hide(void); + + result SetPosition(const Tizen::Graphics::Point& position); + + result StopAnimation(void); + +private: + _OptionMenu* __pOptionMenu; + + _OptionMenuModel* __pOptionMenuModel; + + Tizen::Graphics::Bitmap* __pItemBitmap; + + Tizen::Graphics::Bitmap* __pItemPressedBitmap; + + Tizen::Graphics::Bitmap* __pItemPressedEffectBitmap; + + Tizen::Graphics::Bitmap* __pArrowBitmap; + + Tizen::Graphics::Bitmap* __pArrowPressedBitmap; + + Tizen::Graphics::Bitmap* __pHandleBitmap; + + Tizen::Graphics::Bitmap* __pHandleEffectBitmap; + + Tizen::Graphics::Bitmap* __pHandlePressedBitmap; + + Tizen::Graphics::Bitmap* __pHandlePressedEffectBitmap; + + Tizen::Graphics::Bitmap* __pHandleArrowNormalBitmap; + + Tizen::Graphics::Bitmap* __pHandleArrowPressedBitmap; + + Tizen::Graphics::_Text::TextObject __textObject; + + Tizen::Graphics::Font* __pFont; + + int __maxColumnCount; + + int __rowCount; + + int __columnCount; + + int __width; + + int __handleHeight; + + int __itemHeight; + + int __lineWidth; + + int __leftMargin; + + int __rightMargin; + + int __textSize; + + int __textLeftMargin; + + int __textRightMargin; + + int __textTopMargin; + + int __textBottomMargin; + + int __arrowMargin; + + int __selectedIndex; + + bool __isHandlerPressed; + + bool __isClosing; + + bool __isAnimationStarted; + + Tizen::Graphics::FloatMatrix4 _matrixOrigin; + Tizen::Graphics::FloatMatrix4 _matrixScale; + Tizen::Ui::Animations::_VisualElement* __pOptionMenuVE; + const Tizen::Ui::Animations::IVisualElementAnimationTimingFunction* __pThirtyThreeTimingFunction; + const Tizen::Ui::Animations::IVisualElementAnimationTimingFunction* __pSixtyTimingFunction; + + +}; // _OptionMenuPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_OPTION_MENU_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_OverlayAgent.h b/src/ui/inc/FUiCtrl_OverlayAgent.h new file mode 100644 index 0000000..76ca7f5 --- /dev/null +++ b/src/ui/inc/FUiCtrl_OverlayAgent.h @@ -0,0 +1,197 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OverlayAgent.h + * @brief This is the header file for the _OverlayAgent class. + * + * This header file contains the declarations of the _OverlayAgent class. + * + */ +#ifndef _FUI_INTERNAL_OVERLAY_AGENT_H_ +#define _FUI_INTERNAL_OVERLAY_AGENT_H_ + +#include +#include + +#include +#include +#include + +#include + +namespace Tizen { namespace Base +{ +class ByteBuffer; +}} // Tizen::Base + +namespace Tizen { namespace Ui +{ +class _Controls; +}} // Tizen::Base + +namespace Tizen { namespace Graphics +{ +class BufferInfo; +class Dimension; +class Rectangle; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +} } } + +namespace Tizen { namespace Ui { namespace Controls +{ +enum _OverlayAgentRotation +{ + _OVERLAY_AGENT_ROTATION_NONE, + _OVERLAY_AGENT_ROTATION_90, + _OVERLAY_AGENT_ROTATION_180, + _OVERLAY_AGENT_ROTATION_270, + _OVERLAY_AGENT_ROTATION_NONE_LR, + _OVERLAY_AGENT_ROTATION_NONE_UD, + _OVERLAY_AGENT_ROTATION_90_LR, + _OVERLAY_AGENT_ROTATION_90_UD, + _OVERLAY_AGENT_ROTATION_180_LR, + _OVERLAY_AGENT_ROTATION_180_UD, + _OVERLAY_AGENT_ROTATION_270_LR, + _OVERLAY_AGENT_ROTATION_270_UD, + _OVERLAY_AGENT_ROTATION_MAX +}; + +enum _OverlayAgentBufferPixelFormat +{ + _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_ARGB8888, + _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_RGB565, + _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_YCbCr420_PLANAR, + _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_NV12, + _OVERLAY_AGENT_BUFFER_PIXEL_FORMAT_UYVY +}; + +enum _OverlayAgentStyle +{ + _OVERLAY_AGENT_STYLE_NONE, + _OVERLAY_AGENT_STYLE_REGION_SW, + _OVERLAY_AGENT_STYLE_REGION_GL, + _OVERLAY_AGENT_STYLE_PANEL_SW, + _OVERLAY_AGENT_STYLE_PANEL_GL +}; + +class _OverlayAgent +{ +public: + static _OverlayAgent* CreateInstanceN(_OverlayAgentStyle style, const _Control& control, const Tizen::Graphics::Rectangle& phyBounds); + ~_OverlayAgent(void); + + result Draw(void); + result GetBufferInfo(Tizen::Graphics::BufferInfo& bufferInfo) const; + + result SetInputBuffer(const Tizen::Graphics::Dimension& destDim, const Tizen::Base::ByteBuffer& srcBuffer, + const Tizen::Graphics::Dimension& srcDim, _OverlayAgentBufferPixelFormat srcFormat); + result SetRotation(_OverlayAgentRotation rotation); + result SetDestination(const Tizen::Graphics::Dimension& dimension); + result SetAspectRatio(bool enable); + + result CreatePixmap(void); + Pixmap GetPixmap(void) const; + Evas_Object* GetPixmapImageObject(void) const; + + result GrabXvPort(void); + void UngrabXvPort(void); + + result Show(void) const; + result AdjustImageObject(void); + + static int GetOverlayAgentCount(void); + + static int GetDstRectMinWidth(void); + static int GetDstRectMinHeight(void); + static int GetSrcRectMinWidth(void); + static int GetSrcRectMinHeight(void); + +private: + result CreateImageObjectForOverlayRegion(const _Control& control, const Tizen::Graphics::Rectangle& bounds); + result CreateImageObject(const _Control& control, const Tizen::Graphics::Rectangle& bounds); + + result PutXvImage(void); + result PutEvasImage(void); + + bool IsValidSourceDimension(const Tizen::Graphics::Dimension& dimension) const; + bool IsValidDestinationDimension(const Tizen::Graphics::Dimension& dimension) const; + + _OverlayAgent(_OverlayAgentStyle style, const _Control& control, const Tizen::Graphics::Rectangle& bounds); + + _OverlayAgent(const _OverlayAgent& rhs); + _OverlayAgent& operator=(const _OverlayAgent& rhs); + +private: + const static int _OVERLAYAGENT_XV_PORT = 100; + + static int overlayAgentcount; + static int overlayAgentXvPortCount; + static int baseXvPort; + static bool isPortGrapped[_OVERLAYAGENT_XV_PORT]; + + static int dstRectMinWidth; + static int dstRectMinHegith; + static int srcRectMinWidth; + static int srcRectMinHegith; + + Evas_Object* __pImageObject; + Evas_Object* __pRenderImageObject; + Evas_Object* __pSmartObject; + + Ecore_X_Damage __pixmapDamageHandle; + Ecore_Event_Handler *__pPixmapEventHandler; + Pixmap __pixmap; + + Tizen::Ui::Animations::_VisualElement* __pVisualElement; + Tizen::Graphics::Color __bgColor; + + int __xvPort; + bool __grabXvPort; + + unsigned int __colorFormat; + int __userRotation; + bool __flushRotate; + int __udMirroring; + int __lrMirroring; + bool __aspectRatio; + + Tizen::Graphics::Dimension __srcDimension; + Tizen::Graphics::Dimension __destDimension; + Tizen::Graphics::Rectangle __pixmapPhyRect; + Tizen::Graphics::Rectangle __resizeRect; + + _OverlayAgentStyle __style; + + XvImage* __pXvImage; + unsigned int __newColorFormat; + XShmSegmentInfo* __pShmInfo; + + _OverlayAgentBufferPixelFormat __overlayAgentColorFormat; + const Tizen::Base::ByteBuffer* __pRefUserByteBuffer; + Tizen::Base::ByteBuffer* __pOrgUserByteBuffer; + Tizen::Graphics::Dimension __orgImgDimension; + +}; // _OverlayAgent + +}}} // Tizen::Ui + +#endif // _FUI_INTERNAL_OVERLAY_AGENT_H_ + diff --git a/src/ui/inc/FUiCtrl_OverlayPanel.h b/src/ui/inc/FUiCtrl_OverlayPanel.h new file mode 100644 index 0000000..08eb16a --- /dev/null +++ b/src/ui/inc/FUiCtrl_OverlayPanel.h @@ -0,0 +1,83 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OverlayPanel.h + * @brief This is the header file for the _OverlayPanel class. + * + * This header file contains the declarations of the _OverlayPanel class. + * + */ +#ifndef _FUI_CTRL_INTERNAL_OVERLAY_PANEL_H_ +#define _FUI_CTRL_INTERNAL_OVERLAY_PANEL_H_ + +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Graphics +{ +class Rectangle; +class Dimension; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ +class _OverlayAgent; + +class _OverlayPanel + : public _Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer +{ +public: + static _OverlayPanel* CreateOverlayPanelN(const Tizen::Graphics::Rectangle& bounds); + + virtual ~_OverlayPanel(void); + + result SetInputBuffer(const Tizen::Graphics::Dimension& destDim, const Tizen::Base::ByteBuffer& srcBuffer, + const Tizen::Graphics::Dimension& srcDim, OverlayPanel::BufferPixelFormat srcFormat); + result SetRendererRotation(OverlayPanel::Rotation rotation); + result SetRendererAspectRatio(bool aspectRatio); + result SetRendererSize(const Tizen::Graphics::Dimension& dimension); + + result GetBackgroundBufferInfo(Tizen::Graphics::BufferInfo& info) const; + Tizen::Graphics::Color GetMaskingColor(void) const; + +// virtual result OnAttaching(const Tizen::Ui::_Control* pParent); + virtual void OnDraw(void); + virtual void OnVisibleStateChanged(void); + //virtual result OnAttached(void); + virtual result OnAttachedToMainTree(void); + virtual void OnBoundsChanged(void); + + virtual void OnChildDetached(const _Control& child); + + +private: + _OverlayPanel(const Tizen::Graphics::Rectangle& bounds); + + _OverlayPanel(const _OverlayPanel& rhs); + _OverlayPanel& operator=(const _OverlayPanel& rhs); + +private: + _OverlayAgent* __pOverlayAgent; +}; // _OverlayPanel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_OVERLAY_PANEL_H_ + diff --git a/src/ui/inc/FUiCtrl_OverlayPanelImpl.h b/src/ui/inc/FUiCtrl_OverlayPanelImpl.h new file mode 100644 index 0000000..6855287 --- /dev/null +++ b/src/ui/inc/FUiCtrl_OverlayPanelImpl.h @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_OverlayPanelImpl.h + * @brief This is the header file for the _OverlayPanelImpl class. + * + * This header file contains the declarations of the _OverlayPanelImpl class. + * + */ +#ifndef _FUI_CTRL_INTERNAL_OVERLAY_PANEL_IMPL_H_ +#define _FUI_CTRL_INTERNAL_OVERLAY_PANEL_IMPL_H_ + +#include +#include +#include "FUi_ContainerImpl.h" +#include "FUiCtrl_OverlayPanel.h" + +namespace Tizen { namespace Graphics +{ +class Canvas; +class Rectangle; +class Dimension; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Ui { namespace Controls +{ +class _OverlayPanelImpl + : public _ContainerImpl +{ +public: + class OverlayPanelSizeInfo : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + }; + + static _OverlayPanelImpl* CreateOverlayPanelImplN(OverlayPanel* pPublic, const Tizen::Graphics::Rectangle& bounds); + + virtual ~_OverlayPanelImpl(void); + + result SetInputBuffer(const Tizen::Graphics::Dimension& destDim, const Tizen::Base::ByteBuffer& srcBuffer, const Tizen::Graphics::Dimension& srcDim, OverlayPanel::BufferPixelFormat srcFormat); + + void SetRendererRotation(OverlayPanel::Rotation rotation); + void SetRendererAspectRatio(bool fix); + void SetRendererSize(const Tizen::Graphics::Dimension& dimension); + + result GetBackgroundBufferInfo(Tizen::Graphics::BufferInfo& bufferInfo) const; + Tizen::Graphics::Color GetMaskingColor(void) const; + + virtual const char* GetPublicClassName(void) const; + + virtual const _OverlayPanel& GetCore(void) const; + virtual _OverlayPanel& GetCore(void); + virtual const OverlayPanel& GetPublic(void) const; + virtual OverlayPanel& GetPublic(void); + + static _OverlayPanelImpl* GetInstance(OverlayPanel& overlayPanel); + static const _OverlayPanelImpl* GetInstance(const OverlayPanel& overlayPanel); + + static result SetPixelFormatList(void); + +private: + static bool overlayPanelPixelFomatList[OVERLAY_REGION_BUFFER_PIXEL_FORMAT_MAX]; + +private: + _OverlayPanelImpl(OverlayPanel* pPublic, _OverlayPanel* pCore); + + _OverlayPanelImpl(const _OverlayPanelImpl& rhs); + _OverlayPanelImpl& operator=(const _OverlayPanelImpl& rhs); +}; // _OverlayPanelImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_OVERLAY_PANEL_IMPL_H_ + diff --git a/src/ui/inc/FUiCtrl_OverlayRegionImpl.h b/src/ui/inc/FUiCtrl_OverlayRegionImpl.h new file mode 100644 index 0000000..a304074 --- /dev/null +++ b/src/ui/inc/FUiCtrl_OverlayRegionImpl.h @@ -0,0 +1,126 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_OverlayRegionImpl.h + * @brief This is the header file for the _OverlayRegionImpl class. + * + * This header file contains the declarations of the _OverlayRegionImpl class. + * + */ + +#ifndef _FUI_CTRL_INTERNAL_OVERLAY_REGION_IMPL_H_ +#define _FUI_CTRL_INTERNAL_OVERLAY_REGION_IMPL_H_ + +#include + +#include + +namespace Tizen { namespace Graphics +{ +class Canvas; +class Rectangle; +class Dimension; +} } + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Form; +class OverlayRegion; +class _OverlayAgent; +} } } + +namespace Tizen { namespace Ui +{ +class _Control; +} } + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum OverlayRegionRotate +{ + OVERLAYREGION_ROTATE_0 = 0, + OVERLAYREGION_ROTATE_90, + OVERLAYREGION_ROTATE_180, + OVERLAYREGION_ROTATE_270, + OVERLAYREGION_ROTATE_NONE +}; + +class _OverlayRegionImpl + : public Tizen::Base::Object +{ +public: + virtual ~_OverlayRegionImpl(void); + + Tizen::Graphics::Rectangle GetBounds(void) const; + void GetBounds(int& x, int& y, int& width, int& height) const; + result SetInputBuffer(const Tizen::Base::ByteBuffer& srcBuffer, const Tizen::Graphics::Dimension& srcDim, OverlayRegionBufferPixelFormat srcFormat, bool isUserInput); + result GetBackgroundBufferInfo(Tizen::Graphics::BufferInfo& info) const; + result Show(void) const; + + result Construct(_Form* pParentForm, OverlayRegionType overlayRegionType, const Tizen::Graphics::Point& leftTopPos, const Tizen::Graphics::Rectangle& userDestRect, const Tizen::Graphics::Rectangle& finalPhyRect); + + OverlayRegion* CreateOverlayRegionN(void); + void SetFormArrayIndex(int index); + Tizen::Ui::Controls::OverlayRegion* GetOverlayRegion(void) const; + + void GoForeground(void); + void GoBackground(void); + + static result IsValidOverlayRect(Tizen::Graphics::Rectangle& userRect, Tizen::Graphics::Rectangle& overlayPhysicalRect, const Tizen::Graphics::Rectangle& basePhysicalRect, bool& modified); + static result SetPixelFormatList(void); + static int GetWidthUnit(void); + static int GetHeightUnit(void); + static int GetMaxCount(void); + + static _OverlayRegionImpl* GetInstance(OverlayRegion& overlayRegion); + static const _OverlayRegionImpl* GetInstance(const OverlayRegion& overlayRegion); + +public: + static int overlayRegionWidthUnit; + static int overlayRegionHeightUnit; + static int overlayRegionMaxCount; + static bool overlayRegionPixelFomatList[OVERLAY_REGION_BUFFER_PIXEL_FORMAT_MAX]; + +private: + _OverlayRegionImpl(void); + _OverlayRegionImpl(const _OverlayRegionImpl& rhs); + + _OverlayRegionImpl& operator =(const _OverlayRegionImpl& rhs); + +private: + Tizen::Ui::Controls::_Form* __pParentForm; + Tizen::Ui::Controls::OverlayRegion* __pOverlayRegion; + Tizen::Graphics::Rectangle __destRect; + Tizen::Ui::Controls::OverlayRegionType __overlayRegionType; + bool __showState; + int __myIdx; + + int __cameraDirection; + int __cameraRotation; + + // Evas version + _OverlayAgent* __pOverlayAgent; + + friend class _Form; + +}; // OverlayRegionImpl + +} } } //Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_OVERLAY_REGION_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_Panel.h b/src/ui/inc/FUiCtrl_Panel.h new file mode 100644 index 0000000..900c869 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Panel.h @@ -0,0 +1,140 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_Panel.h + * @brief This is the header file for the _Panel class. + * + * This header file contains the declarations of the _Panel class. + */ + +#ifndef _FUI_CTRL_INTERNAL_PANEL_H_ +#define _FUI_CTRL_INTERNAL_PANEL_H_ + +#include +#include "FUi_Control.h" +#include "FUiCtrl_PanelPresenter.h" + +namespace Tizen { namespace Graphics +{ + +class Bitmap; + +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum _PanelBackgroundBitmapHorizontalAlign +{ + PANEL_BACKGROUND_BITMAP_HORIZONTAL_ALIGN_LEFT, + PANEL_BACKGROUND_BITMAP_HORIZONTAL_ALIGN_CENTER, + PANEL_BACKGROUND_BITMAP_HORIZONTAL_ALIGN_RIGHT +}; + +enum _PanelBackgroundBitmapVerticalAlign +{ + PANEL_BACKGROUND_BITMAP_VERTICAL_ALIGN_TOP, + PANEL_BACKGROUND_BITMAP_VERTICAL_ALIGN_MIDDLE, + PANEL_BACKGROUND_BITMAP_VERTICAL_ALIGN_BOTTOM +}; + +class _OSP_EXPORT_ _Panel + : public _Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ +// Lifecycle +public: + virtual ~_Panel(void); + +// Operations +public: + static _Panel* CreatePanelN(const Tizen::Graphics::Rectangle& rect, GroupStyle groupStyle = GROUP_STYLE_NONE); + + virtual void OnDraw(void); + + // Accessor + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + GroupStyle GetGroupStyle(void) const; + void SetGroupStyle(GroupStyle groupStyle); + + Tizen::Graphics::Bitmap* GetGroupStyleBitmap(void) const; + Tizen::Graphics::Bitmap* GetGroupStyleBackgroundBitmap(void) const; + + bool IsBackgroundBitmapStretch(void) const; + void SetBackgroundBitmapStretch(bool stretch); + + _PanelBackgroundBitmapHorizontalAlign GetBackgroundBitmapHorizontalAlign(void) const; + void SetBackgroundBitmapHorizontalAlign(_PanelBackgroundBitmapHorizontalAlign align); + + _PanelBackgroundBitmapVerticalAlign GetBackgroundBitmapVerticalAlign(void) const; + void SetBackgroundBitmapVerticalAlign(_PanelBackgroundBitmapVerticalAlign align); + + void SetBackgroundBitmapAlign(_PanelBackgroundBitmapHorizontalAlign horizontalAlign, _PanelBackgroundBitmapVerticalAlign verticalAlign); + + Tizen::Graphics::Bitmap* GetBackgroundBitmap(void) const; + void SetBackgroundBitmap(Tizen::Graphics::Bitmap* bitmap); + +protected: + // Lifecycle + _Panel(void); + + virtual result Initialize(const _PanelPresenter& presenter); + + // Accessor + virtual result SetPanelPresenter(const _PanelPresenter* presenter); + +// Copy constructor +private: + /** + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.0 + * + */ + _Panel(const _Panel& rhs); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.0 + * + */ + _Panel& operator =(const _Panel& rhs); + +// Attribute +private: + _PanelPresenter* __pPanelPresenter; + + GroupStyle __groupStyle; + Tizen::Graphics::Bitmap* __pGroupStyleBitmap; + Tizen::Graphics::Bitmap* __pGroupStyleBackgroundBitmap; + + bool __backgroundBitmapStretch; + _PanelBackgroundBitmapHorizontalAlign __backgroundBitmapHorizontalAlign; + _PanelBackgroundBitmapVerticalAlign __backgroundBitmapVerticalAlign; + Tizen::Graphics::Bitmap* __pBackgroundBitmap; +}; // _Panel + + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_PANEL_H_ + diff --git a/src/ui/inc/FUiCtrl_PanelImpl.h b/src/ui/inc/FUiCtrl_PanelImpl.h new file mode 100644 index 0000000..144fedb --- /dev/null +++ b/src/ui/inc/FUiCtrl_PanelImpl.h @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_PanelImpl.h + * @brief This is the header file for the _PanelImpl class. + * + * This header file contains the declarations of the _PanelImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_PANEL_IMPL_H_ +#define _FUI_CTRL_INTERNAL_PANEL_IMPL_H_ + +#include +#include "FUi_ContainerImpl.h" +#include "FUiCtrl_Panel.h" + +namespace Tizen { namespace Ui +{ +class DataBindingContext; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _PanelImpl + : public _ContainerImpl +{ + +// Life Cycle +public: + virtual ~_PanelImpl(void); + + static _PanelImpl* CreatePanelImplN(Panel* pControl, const Tizen::Graphics::Rectangle& rect, GroupStyle groupStyle, Layout* pPublicPortraitLayout = null, Layout* pPublicLandscapeLayout = null); + +//Accessor +public: + static const _PanelImpl* GetInstance(const Panel& panel); + static _PanelImpl* GetInstance(Panel& panel); + + virtual const char* GetPublicClassName(void) const; + virtual const Panel& GetPublic(void) const; + virtual Panel& GetPublic(void); + virtual const _Panel& GetCore(void) const; + virtual _Panel& GetCore(void); + + virtual result OnAttachedToMainTree(void); + +// Setter/Getter +public: + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + void SetChildBuilderBouds(_ContainerImpl* pContainerImpl, _ControlOrientation controlOrientation); + result SetCompositeEnabled(bool enabled); + bool IsCompositeEnabled(void) const; + + DataBindingContext* GetDataBindingContextN(void) const; + +protected: + _PanelImpl(Control* pPublic, _Control* pCore, Layout* pPublicPortraitLayout = null, Layout* pPublicLandscapeLayout = null); + +private: + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + _PanelImpl(const _PanelImpl& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + _PanelImpl& operator =(const _PanelImpl& rhs); + +}; // _PanelImpl + +}}} //Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_PANEL_IMPL_H_ + diff --git a/src/ui/inc/FUiCtrl_PanelPresenter.h b/src/ui/inc/FUiCtrl_PanelPresenter.h new file mode 100644 index 0000000..e3a7be7 --- /dev/null +++ b/src/ui/inc/FUiCtrl_PanelPresenter.h @@ -0,0 +1,66 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_PanelPresenter.h + * @brief This is the header file for the _PanelPresenter class. + * + * This header file contains the declarations of the %_PanelPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_PANEL_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_PANEL_PRESENTER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Panel; + +class _PanelPresenter + : public Tizen::Base::Object +{ +// Lifecycle +public: + _PanelPresenter(void); + virtual ~_PanelPresenter(void); + +// Operations +public: + virtual result Initialize(_Panel& panel); + virtual result Draw(void); + +protected: + void DrawBackgrounBitmap(Tizen::Graphics::Canvas* pCanvas); + void DrawGroupStyleBitmap(Tizen::Graphics::Canvas* pCanvas); + void DrawGroupStyleBackgroundBitmap(Tizen::Graphics::Canvas* pCanvas); + +private: + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + _PanelPresenter(const _PanelPresenter& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + _PanelPresenter& operator =(const _PanelPresenter& rhs); + +private: + _Panel* __pPanel; +}; // _PanelPresenter; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_PANEL_PRESENTER_H_ + diff --git a/src/ui/inc/FUiCtrl_Popup.h b/src/ui/inc/FUiCtrl_Popup.h new file mode 100644 index 0000000..aaec26e --- /dev/null +++ b/src/ui/inc/FUiCtrl_Popup.h @@ -0,0 +1,176 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_Popup.h + * @brief This is the header file for the _Popup class. + * + * This header file contains the declarations of the %_Popup class. + */ + +#ifndef _FUI_CTRL_INTERNAL_POPUP_H_ +#define _FUI_CTRL_INTERNAL_POPUP_H_ + + +#include +#include "FUi_Window.h" +#include "FUiCtrl_DimmingLayer.h" + + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} // Tizen::Ui + + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _PopupPresenter; + +enum PopupModalResult +{ + POPUP_RESULT_NONE, + POPUP_RESULT_END_MODAL, /**< The Popup is closed by EndModal() */ + POPUP_RESULT_CANCEL = -1 /**< The Cancel button is selected (ProgressPopup)*/ +}; + +/** + * @class _Popup + * @brief + * @since 1.0 + * + * + * + * + */ +class _OSP_EXPORT_ _Popup + : public _Window + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ + +//Lifecycle +public: + virtual ~_Popup(void); + +// Operations +public: + static _Popup* CreatePopupN(void); + result Initialize(bool hasTitle, const Tizen::Graphics::Rectangle& bounds); + + virtual result DoModal(int& modalResult); + result EndModal(int modalResult); + + bool HasTitle(void) const; + Tizen::Graphics::Canvas* GetClientAreaCanvasN(void) const; + + Tizen::Graphics::Point TranslateFromClientAreaPosition(const Tizen::Graphics::Point& clientPosition) const; + Tizen::Graphics::Point TranslateToClientAreaPosition(const Tizen::Graphics::Point& position) const; + + virtual void OnDraw(void); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + virtual result OnAttachingToMainTree(const Tizen::Ui::_Control* pParent); + virtual result OnAttachedToMainTree(void); + virtual result OnDetachingFromMainTree(void); + + virtual void OnVisibleStateChanged(void); + + // Callbacks for processing dim + virtual void OnActivated(void); + virtual void OnDeactivated(void); + + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + + // Touch Event Listener + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + virtual void OnBoundsChanged(void); +#if defined(MULTI_WINDOW) + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); + virtual bool IsLayoutChangable(void) const; +#endif + +// Accessor +public: + void SetColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetColor(void) const; + + void SetTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTitleTextColor(void) const; + + virtual result SetTitleText(const Tizen::Base::String& title); + Tizen::Base::String GetTitleText(void) const; + + const Tizen::Graphics::Bitmap* GetBackgroundBitmap(void) const; + const Tizen::Graphics::Bitmap* GetOutlineBitmap(void) const; + + Tizen::Graphics::Rectangle GetPopupClientArea(void) const; + + void SetReturnValue(PopupModalResult rtn); + int GetPopupReturnValue(void) const; + + Tizen::Ui::_AccessibilityElement* GetTitleTextAccessibilityElement(void); + +protected: + _Popup(void); + + result SetPresenter(const _PopupPresenter& popupPresenter); + + virtual void InitializeAccessibilityElement(void); + +private: + _Popup(const _Popup& rhs); + _Popup& operator =(const _Popup& rhs); + +// Attribute +protected: + bool _titleState; + bool _ownerEnableState; + + Tizen::Base::String _titleText; + + Tizen::Graphics::Color _bgColor; + + Tizen::Graphics::Color _titleTextColor; + + Tizen::Graphics::Bitmap* _pBgBitmap; + Tizen::Graphics::Bitmap* _pComposedBgBitmap; + Tizen::Graphics::Bitmap* _pOutlineBitmap; + + Tizen::Ui::Controls::_DimmingLayer* _pDimmingLayer; + + Tizen::Ui::_AccessibilityElement* _pTitleTextAccessibilityElement; + +private: + _PopupPresenter* __pPopupPresenter; + + Tizen::Graphics::Rectangle __bounds; + + PopupModalResult __popupResult; + +}; // _Popup + + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_POPUP_H_ diff --git a/src/ui/inc/FUiCtrl_PopupImpl.h b/src/ui/inc/FUiCtrl_PopupImpl.h new file mode 100644 index 0000000..7d9f59f --- /dev/null +++ b/src/ui/inc/FUiCtrl_PopupImpl.h @@ -0,0 +1,122 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_PopupImpl.h + * @brief This is the implementation file for the _PopupImpl class. + * + * This header file contains the declarations of the %_PopupImpl class. + */ + +#ifndef _FUI_CTRL_POPUP_IMPL_H_ +#define _FUI_CTRL_POPUP_IMPL_H_ + + +// Includes +#include +#include "FUi_WindowImpl.h" +#include "FUiCtrl_Popup.h" + + +namespace Tizen { namespace Ui +{ +class DataBindingContext; +}} // Tizen::Ui + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +class _PopupImpl + : public _WindowImpl +{ +public: + class PopupSizeInfo + : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + virtual Tizen::Graphics::Dimension GetDefaultMaximumSize(_ControlOrientation orientation) const; + }; // PopupSizeInfo + +public: + _PopupImpl(Popup* pPublic, _Popup* pCore, Layout* pPublicPortraitLayout = null, Layout* pPublicLandscapeLayout = null); + virtual ~_PopupImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const Popup& GetPublic(void) const; + virtual Popup& GetPublic(void); + virtual const _Popup& GetCore(void) const; + virtual _Popup& GetCore(void); + +public: + static _PopupImpl* CreatePopupImplN(Popup* pControl, const Tizen::Graphics::Dimension& dim, Layout* pPublicPortraitLayout = null, Layout* pPublicLandscapeLayout = null); + result Initialize(bool hasTitle, const Tizen::Graphics::Dimension& dim); + + virtual result DoModal(int& modalResult); + result EndModal(int modalResult); + + Tizen::Graphics::Canvas* GetClientAreaCanvasN(void) const; + Tizen::Graphics::Rectangle GetClientAreaBounds(void) const; + + Tizen::Graphics::Point TranslateFromClientAreaPosition(const Tizen::Graphics::Point& clientPosition) const; + Tizen::Graphics::Point TranslateToClientAreaPosition(const Tizen::Graphics::Point& position) const; + + DataBindingContext* GetDataBindingContextN(void) const; + + Tizen::Graphics::Rectangle GetCenterAlignedRect(int width, int height) const; + + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + virtual void OnBoundsChanged(void); + +public: + result SetColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetColor(void) const; + + virtual result SetTitleText(const Tizen::Base::String& title); + Tizen::Base::String GetTitleText(void) const; + + result SetTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTitleTextColor(void) const; + + int GetMinWidth(void) const; + int GetMinHeight(void) const; + + int GetMaxWidth(void) const; + int GetMaxHeight(void) const; + +public: + static _PopupImpl* GetInstance(Popup& pPopup); + static const _PopupImpl* GetInstance(const Popup& pPopup); + +private: + _PopupImpl(const _PopupImpl& rhs); + _PopupImpl& operator =(const _PopupImpl& rhs); + +protected: + bool _isModal; + +private: + bool __init; + bool __centerAlign; + bool __callBoundsChange; +}; // _PopupImpl + + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_POPUP_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_PopupPresenter.h b/src/ui/inc/FUiCtrl_PopupPresenter.h new file mode 100644 index 0000000..56a26c6 --- /dev/null +++ b/src/ui/inc/FUiCtrl_PopupPresenter.h @@ -0,0 +1,111 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_PopupPresenter.h + * @brief This is the header file for the _PopupPresenter class. + * + * This header file contains the declarations of the _PopupPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_POPUP_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_POPUP_PRESENTER_H_ + + +#include +#include +#include "FUiCtrl_Label.h" +#include "FUiCtrl_Popup.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _Popup; + +/** + * @class _PopupPresenter + * @brief + * @since 1.0 + * + * + * + * + */ +class _PopupPresenter + : virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ +// Lifecycle +public: + _PopupPresenter(void); + virtual ~_PopupPresenter(void); + +// Operations +public: + void Initialize(_Popup& popup); + + void OnDraw(void); + virtual void Draw(void); + + virtual result DoModal(int& modalResult); + + result SetTitleTextObject(const Tizen::Base::String& title); + + Tizen::Ui::Controls::_Label* GetSystemLabel(void) const; + + Tizen::Graphics::Rectangle GetTitleTextBounds(void) const; + + void OnActivated(void); + + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + void UpdateEffectBounds(void); + + // Touch Event Listener + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + +protected: + virtual void ProcessEvent(void); + +private: + _PopupPresenter(const _PopupPresenter& rhs); + _PopupPresenter& operator =(const _PopupPresenter& rhs); + + void DrawSystemLabel(void); + +//Attribute +protected: + Tizen::Graphics::Font* _pFont; + +private: + _Popup* __pPopup; + Tizen::Ui::Animations::_VisualElement* __pPopupVE; + Tizen::Ui::Animations::_VisualElement* __pBackgroundVE; + + Tizen::Graphics::_Text::TextObject* __pTextObject; + Tizen::Ui::Controls::_Label* __pLabelCore; + Tizen::Graphics::Rectangle __titleBounds; + + static const int POPUP_LABEL_GAP = 8; +}; // _PopupPresenter + + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_POPUP_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_Progress.h b/src/ui/inc/FUiCtrl_Progress.h new file mode 100644 index 0000000..ea0639f --- /dev/null +++ b/src/ui/inc/FUiCtrl_Progress.h @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Progress.h + * @brief This is the header file for the _Progress class. + * + * This header file contains the declarations of the %_Progress class. + */ +#ifndef _FUI_CTRL_INTERNAL_PROGRESS_H_ +#define _FUI_CTRL_INTERNAL_PROGRESS_H_ + +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class _ProgressPresenter; + + +class _OSP_EXPORT_ _Progress + : public Tizen::Ui::_Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer +{ + DECLARE_CLASS_BEGIN(_Progress, Tizen::Ui::_Control); + DECLARE_PROPERTY("value", GetPropertyValue, SetPropertyValue); + DECLARE_PROPERTY("minValue", GetPropertyMinValue, SetPropertyMinValue); + DECLARE_PROPERTY("maxValue", GetPropertyMaxValue, SetPropertyMaxValue); + DECLARE_PROPERTY("barColor", GetPropertyBarColor, SetPropertyBarColor); + DECLARE_CLASS_END(); + +public: + virtual ~_Progress(void); + +public: + result SetValue(int value); + result SetRange(int minValue, int maxValue); + result SetBarColor(const Tizen::Graphics::Color& color); + int GetValue(void) const; + result GetRange(int& minValue, int& maxValue) const; + Tizen::Graphics::Color GetBarColor(void) const; + int GetPercentComplete(void) const; + + result SetPropertyValue(const Tizen::Ui::Variant& value); + result SetPropertyMinValue(const Tizen::Ui::Variant& minValue); + result SetPropertyMaxValue(const Tizen::Ui::Variant& maxValue); + result SetPropertyBarColor(const Tizen::Ui::Variant& barColor); + Tizen::Ui::Variant GetPropertyValue(void) const; + Tizen::Ui::Variant GetPropertyMinValue(void) const; + Tizen::Ui::Variant GetPropertyMaxValue(void) const; + Tizen::Ui::Variant GetPropertyBarColor(void) const; + + virtual void OnDraw(void); + virtual result OnAttachedToMainTree(void); + virtual void OnBoundsChanged(void); + static _Progress* CreateProgressN(void); + +private: + _Progress(void); + _Progress(const _Progress&); + _Progress& operator =(const _Progress&); + result InitializeAccessibilityElement(void); + +private: + _ProgressPresenter* __pProgressPresenter; + Tizen::Graphics::Color __barColor; + Tizen::Ui::_AccessibilityElement* __pAccessibilityElement; + +}; // _Progress + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_PROGRESS_H_ diff --git a/src/ui/inc/FUiCtrl_ProgressImpl.h b/src/ui/inc/FUiCtrl_ProgressImpl.h new file mode 100644 index 0000000..cf924c4 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ProgressImpl.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ProgressImpl.h + * @brief This is the header file for the _ProgressImpl class. + * + * This header file contains the declarations of the %_ProgressImp class. + */ +#ifndef _FUI_CTRL_INTERNAL_PROGRESS_IMPL_H_ +#define _FUI_CTRL_INTERNAL_PROGRESS_IMPL_H_ + +#include "FUi_ControlImpl.h" +#include "FUiCtrl_Progress.h" + +namespace Tizen { namespace Graphics +{ +class Dimension; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ +class Progress; + + +class _ProgressImpl + : public Tizen::Ui::_ControlImpl +{ +public: + virtual ~_ProgressImpl(void); + +public: + result SetValue(int value); + result SetRange(int minValue, int maxValue); + int GetValue(void) const; + result GetRange(int& minValue, int& maxValue) const; + int GetPercentComplete(void) const; + result SetBarColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetBarColor(void) const; + + virtual const char* GetPublicClassName(void) const; + virtual const Progress& GetPublic(void) const; + virtual Progress& GetPublic(void); + virtual const _Progress& GetCore(void) const; + virtual _Progress& GetCore(void); + + static _ProgressImpl* CreateProgressImplN(Progress* pControl, const Tizen::Graphics::Rectangle& bounds); + static _ProgressImpl* GetInstance(Progress& progress); + static const _ProgressImpl* GetInstance(const Progress& progress); + +private: + _ProgressImpl(Progress* pPublic, _Progress* pCore); + _ProgressImpl(const _ProgressImpl&); + _ProgressImpl& operator =(const _ProgressImpl&); + +}; // _ProgressImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_PROGRESS_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_ProgressModel.h b/src/ui/inc/FUiCtrl_ProgressModel.h new file mode 100644 index 0000000..0039ef4 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ProgressModel.h @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ProgressModel.h + * @brief This is the header file for the _ProgressModel class. + * + * This header file contains the declarations of the %_ProgressModel class. + */ +#ifndef _FUI_CTRL_INTERNAL_PROGRESS_MODEL_H_ +#define _FUI_CTRL_INTERNAL_PROGRESS_MODEL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ProgressModel + : public Tizen::Base::Object +{ +public: + _ProgressModel(void); + virtual ~_ProgressModel(void); + +public: + void SetValue(int value); + void SetMinValue(int minValue); + void SetMaxValue(int maxValue); + int GetValue(void) const; + int GetMinValue(void) const; + int GetMaxValue(void) const; + +private: + _ProgressModel(const _ProgressModel&); + _ProgressModel& operator =(const _ProgressModel&); + +private: + int __minValue; + int __maxValue; + int __currentValue; + +}; // _ProgressModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_PROGRESS_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_ProgressPopup.h b/src/ui/inc/FUiCtrl_ProgressPopup.h new file mode 100644 index 0000000..870ac51 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ProgressPopup.h @@ -0,0 +1,150 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ProgressPopup.h + * @brief This is the header file for the _ProgressPopup class. + * + * This header file contains the declarations of the %_ProgressPopup class. + */ + +#ifndef _FUI_CTRL_INTERNAL_PROGRESS_POPUP_H_ +#define _FUI_CTRL_INTERNAL_PROGRESS_POPUP_H_ + + +#include +#include "FUiCtrl_Popup.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_IProgressPopupEventListener.h" +#include "FUiCtrl_ProgressPopupEvent.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +class Button; +class _ProgressPopupPresenter; + +/** + * @class _ProgressPopup + * @brief + * @since 2.0 + * + * + * + * + */ +class _ProgressPopup + : public _Popup + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ + +//Lifecycle +public: + virtual ~_ProgressPopup(void); + +// Operations +public: + static _ProgressPopup* CreateProgressPopupN(void); + result Initialize(bool cancelButton, bool translucent, const Tizen::Graphics::Rectangle& animationRect); + + virtual result DoModal(int& modalResult); + + virtual void OnDraw(void); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + virtual result OnAttachedToMainTree(void); + + virtual void OnActivated(void); + virtual void OnDeactivated(void); + + virtual void OnVisibleStateChanged(void); + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + + virtual void OnBoundsChanged(void); + + // Touch Event Listener + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + +public: + result AddProgressPopupEventListener(const Tizen::Ui::Controls::_IProgressPopupEventListener& listener); + + void FireProgressPopupEvent(void); + + bool HasText(void) const; + bool HasButton(void) const; + bool IsTranslucent(void) const; + + virtual result SetTitleText(const Tizen::Base::String& title); + + result SetText(const Tizen::Base::String& text); + Tizen::Base::String GetText(void) const; + + result SetTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTextColor(void) const; + + result UpdateBounds(void); + + int GetTotalHeight(void) const; + Tizen::Graphics::Rectangle GetAnimationRect(void) const; + +protected: + result SetPresenter(const _ProgressPopupPresenter& ProgressPopupPresenter); + + virtual void InitializeAccessibilityElement(void); + +private: + _ProgressPopup(void); + + _ProgressPopup(const _ProgressPopup& rhs); + _ProgressPopup& operator =(const _ProgressPopup& rhs); + +// Attribute +private: + _ProgressPopupPresenter* __pProgressPopupPresenter; + _ProgressPopupEvent* __pProgressPopupEvent; + + Tizen::Ui::Controls::Button* __pButton; + + Tizen::Base::String __text; + Tizen::Graphics::Color __textColor; + + Tizen::Graphics::Rectangle __animationRect; + + Tizen::Ui::_AccessibilityElement* __pTextAccessibilityElement; + + bool __textState; + bool __buttonState; + bool __isTranslucent; + + // Cancel button action ID + static const int ID_PROGRESS_POPUP_CANCEL_BUTTON = 701; + +}; // _ProgressPopup + + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_PROGRESS_POPUP_H_ diff --git a/src/ui/inc/FUiCtrl_ProgressPopupEvent.h b/src/ui/inc/FUiCtrl_ProgressPopupEvent.h new file mode 100644 index 0000000..6360d74 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ProgressPopupEvent.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ProgressPopupEvent.h + * @brief This is the header file for _ProgressPopupEvent class. + * + * This header file contains declaration of _ProgressPopupEvent class. + * The ProgressPopupEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_INTERNAL_PROGRESSPOPUP_EVENT_H_ +#define _FUI_CTRL_INTERNAL_PROGRESSPOPUP_EVENT_H_ + + +#include +#include +#include + + +namespace Tizen { namespace Ui +{ +class _Control; +} } // Tizen::Ui + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +class _ProgressPopupEvent + : public Tizen::Base::Runtime::_Event +{ +public: + _ProgressPopupEvent(const _Control& source); + virtual ~_ProgressPopupEvent(void); + + static _ProgressPopupEvent* CreateInstanceN(const Tizen::Ui::_Control& source); + +public: + const Tizen::Ui::_Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateProgressPopupEventArgN(void); + +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& pListener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + _ProgressPopupEvent(const _ProgressPopupEvent& rhs); + _ProgressPopupEvent& operator=(const _ProgressPopupEvent& rhs); + +private: + const Tizen::Ui::_Control* __pSource; +}; // _ProgressPopupEvent + +}}} // Tizen::Ui::Controls + + +#endif // _FUI_CTRL_INTERNAL_PROGRESSPOPUP_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_ProgressPopupImpl.h b/src/ui/inc/FUiCtrl_ProgressPopupImpl.h new file mode 100644 index 0000000..dba5e2d --- /dev/null +++ b/src/ui/inc/FUiCtrl_ProgressPopupImpl.h @@ -0,0 +1,94 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ProgressPopupImpl.h + * @brief This is the implementation file for the _ProgressPopupImpl class. + * + * This header file contains the declarations of the %_ProgressPopupImpl class. + */ + +#ifndef _FUI_CTRL_PROGRESS_POPUP_IMPL_H_ +#define _FUI_CTRL_PROGRESS_POPUP_IMPL_H_ + +#include +#include "FUiCtrl_PopupImpl.h" +#include "FUiCtrl_ProgressPopup.h" +#include "FUiCtrl_IProgressPopupEventListener.h" +#include "FUiCtrl_PublicProgressPopupEvent.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + + +class _ProgressPopupImpl + : public _PopupImpl + , public _IProgressPopupEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + _ProgressPopupImpl(ProgressPopup* pPublic, _ProgressPopup* pCore); + virtual ~_ProgressPopupImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const ProgressPopup& GetPublic(void) const; + virtual ProgressPopup& GetPublic(void); + virtual const _ProgressPopup& GetCore(void) const; + virtual _ProgressPopup& GetCore(void); + +public: + static _ProgressPopupImpl* CreateProgressPopupImplN(ProgressPopup* pControl); + result Initialize(bool cancelButton, bool translucent); + + result AddProgressPopupEventListener(Tizen::Ui::IProgressPopupEventListener& listener); + result RemoveProgressPopupEventListener(Tizen::Ui::IProgressPopupEventListener& listener); + + virtual result OnAttachedToMainTree(void); + virtual void OnProgressPopupCanceled(void); + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + +public: + virtual result SetTitleText(const Tizen::Base::String& title); + + result SetText(const Tizen::Base::String& text); + Tizen::Base::String GetText(void) const; + + result SetTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTextColor(void) const; + + int GetMaxTextLength(void) const; + + Tizen::Graphics::Rectangle GetCenterAlignedRect(int width, int height) const; + +public: + static _ProgressPopupImpl* GetInstance(ProgressPopup& pProgressPopup); + static const _ProgressPopupImpl* GetInstance(const ProgressPopup& pProgressPopup); + +private: + _ProgressPopupImpl(const _ProgressPopupImpl& rhs); + _ProgressPopupImpl& operator =(const _ProgressPopupImpl& rhs); + +private: + _PublicProgressPopupEvent* __pPublicProgressPopupEvent; + +}; // _ProgressPopupImpl + + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_PROGRESS_POPUP_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_ProgressPopupPresenter.h b/src/ui/inc/FUiCtrl_ProgressPopupPresenter.h new file mode 100644 index 0000000..46f596e --- /dev/null +++ b/src/ui/inc/FUiCtrl_ProgressPopupPresenter.h @@ -0,0 +1,136 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ProgressPopupPresenter.h + * @brief This is the header file for the _ProgressPopupPresenter class. + * + * This header file contains the declarations of the _ProgressPopupPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_PROGRESS_POPUP_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_PROGRESS_POPUP_PRESENTER_H_ + + +#include "FUiCtrl_Animation.h" +#include "FUiCtrl_PopupPresenter.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ProgressPopup; + + +/** + * @class _ProgressPopupPresenter + * @brief + * @since 1.0 + * + * + * + * + */ +class _ProgressPopupPresenter + : public _PopupPresenter + , public Tizen::Ui::Controls::_IAnimationEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + _ProgressPopupPresenter(void); + virtual ~_ProgressPopupPresenter(void); + +// Operations +public: + result Initialize(_ProgressPopup& ProgressPopup, bool cancelButton, bool translucent, const Tizen::Graphics::Rectangle& animationRect); + + void SetTitleTextObject(void); + void SetTextObject(void); + + virtual void Draw(void); + + virtual result DoModal(int& modalResult); + + int GetBodyTextHeight(void) const; + + Tizen::Graphics::Rectangle GetButtonBounds(void) const; + Tizen::Graphics::Rectangle GetTitleBounds(void) const; + Tizen::Graphics::Rectangle GetTextBounds(void) const; + + result PlayProcessAnimation(void); + result StopProcessAnimation(void); + result SetProcessAnimation(void); + + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + + result SetFontInfo(unsigned long style, int size); + + // Touch Event Listener + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + virtual void OnAnimationStopped(const Tizen::Ui::_Control& source); + +private: + _ProgressPopupPresenter(const _ProgressPopupPresenter& rhs); + _ProgressPopupPresenter& operator =(const _ProgressPopupPresenter& rhs); + + result LoadImages(void); + +private: + enum + { + MAX_PROCESS_IMAGE_COUNT = 30 + }; + +//Attribute +private: + _ProgressPopup* __pProgressPopup; + + Tizen::Graphics::_Text::TextObject* __pTitleTextObject; + Tizen::Graphics::_Text::TextObject* __pBodyTextObject; + + Tizen::Graphics::Rectangle __titleBounds; + Tizen::Graphics::Rectangle __textBounds; + Tizen::Graphics::Rectangle __animationBounds; + + Tizen::Graphics::Bitmap* __pProcessImage[MAX_PROCESS_IMAGE_COUNT]; + + _Animation* __pAnimation; + Tizen::Base::Collection::ArrayList* __pAnimationFrameList; + + unsigned long __fontStyle; + int __fontSize; + + int __textObjectHeight; + int __currentIndex; + + bool __buttonPressState; + bool __cancelButton; + bool __translucent; + + static const int ANIMATION_REPEAT_COUNT = 100; + +}; // _ProgressPopupPresenter + + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_PROGRESS_POPUP_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_ProgressPresenter.h b/src/ui/inc/FUiCtrl_ProgressPresenter.h new file mode 100644 index 0000000..0a5417a --- /dev/null +++ b/src/ui/inc/FUiCtrl_ProgressPresenter.h @@ -0,0 +1,74 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ProgressPresenter.h + * @brief This is the header file for the _ProgressPresenter class. + * + * This header file contains the declarations of the %_ProgressPresenter class. + */ +#ifndef _FUI_CTRL_INTERNAL_PROGRESS_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_PROGRESS_PRESENTER_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Progress; +class _ProgressModel; + + +class _ProgressPresenter + : public Tizen::Base::Object +{ +public: + virtual ~_ProgressPresenter(void); + + result Draw(void); + void SetValue(int value); + void SetMinValue(int minValue); + void SetMaxValue(int maxValue); + int GetValue(void) const; + int GetMinValue(void) const; + int GetMaxValue(void) const; + int GetPercentComplete(void) const; + + static _ProgressPresenter* CreateInstanceN(const _Progress& progress); + + result LoadResource(void); + result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, Tizen::Graphics::Bitmap* pBitmap); + +private: + _ProgressPresenter(void); + _ProgressPresenter(const _ProgressPresenter&); + _ProgressPresenter& operator =(const _ProgressPresenter&); + +private: + _Progress* __pProgress; + _ProgressModel* __pProgressModel; + + Tizen::Graphics::Bitmap* __pResourceBitmap; + Tizen::Graphics::Bitmap* __pBarResourceEffectBitmap; + Tizen::Graphics::Bitmap* __pBarBgResourceEffectBitmap; + Tizen::Graphics::Bitmap* __pBarColorReplacementBitmap; + Tizen::Graphics::Bitmap* __pBarBgColorReplacementBitmap; + + Tizen::Graphics::Color __currentBarColor; +}; // _ProgressPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_PROGRESS_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_PublicActionEvent.h b/src/ui/inc/FUiCtrl_PublicActionEvent.h new file mode 100644 index 0000000..ebd585b --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicActionEvent.h @@ -0,0 +1,99 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicActionEvent.h + * @brief This is the header file for _PublicActionEvent class. + * + * This header file contains declaration of _PublicActionEvent class. + * The PublicActionEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_PUBLIC_ACTION_EVENT_H_ +#define _FUI_CTRL_PUBLIC_ACTION_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** +* @class _PublicActionEvent +* @brief This class handles a action event. It is inherited from Event class. +* +* The Window(root of all widgets) class has an instance of the _PublicActionEvent class as a member variable. +* Applications can register action event listeners through it. When a action event occurred, +* the _PublicActionEvent class finds listener and calls the appropriate listener's method. +* +*/ +class _PublicActionEvent + : public Tizen::Base::Runtime::_Event +{ +public: + /** + * This is the default class destructor. + * + */ + virtual ~_PublicActionEvent(void); + + static _PublicActionEvent* CreateInstanceN(const Tizen::Ui::Control& source); + +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::Control* GetSource(void) const; + +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _PublicActionEvent(const Tizen::Ui::Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * listener's method. + * + * @param[in] listener It is a event listener related to this action event. + * @param[in] arg It is an argument-like instance of action event retransmitted to the listener's method + * as an argument. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +public: + static Tizen::Base::Runtime::IEventArg* CreateActionEventArgN(int actionId); + +private: + const Tizen::Ui::Control* __pSource; +}; // _PublicActionEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_PUBLIC_ACTION_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicAdjustmentEvent.h b/src/ui/inc/FUiCtrl_PublicAdjustmentEvent.h new file mode 100644 index 0000000..8194094 --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicAdjustmentEvent.h @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicAdjustmentEvent.h + * @brief This is the header file for _PublicAdjustmentEvent class. + * + * This header file contains declaration of _PublicAdjustmentEvent class. + */ +#ifndef _FUI_CTRL_PUBLIC_ADJUSTMENT_EVENT_H_ +#define _FUI_CTRL_PUBLIC_ADJUSTMENT_EVENT_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _PublicAdjustmentEvent + : public Tizen::Base::Runtime::_Event +{ +public: + virtual ~_PublicAdjustmentEvent(void); + + const Tizen::Ui::Control* GetSource(void) const; + + static _PublicAdjustmentEvent* CreateInstanceN(const Tizen::Ui::Control& source); + static Tizen::Base::Runtime::IEventArg* CreateAdjustmentEventArgN(int adjustment); + +protected: + _PublicAdjustmentEvent(const Tizen::Ui::Control& source); + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + const Tizen::Ui::Control* __pSource; + +}; // _PublicAdjustmentEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_PUBLIC_ADJUSTMENT_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicAnimationEvent.h b/src/ui/inc/FUiCtrl_PublicAnimationEvent.h new file mode 100644 index 0000000..d2d41b7 --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicAnimationEvent.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicAnimationEvent.h + * @brief This is the header file for _PublicAnimationEvent class. + * + * This header file contains declaration of _PublicAnimationEvent class. + * The PublicAnimationEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_PUBLIC_ANIMATION_EVENT_H_ +#define _FUI_CTRL_PUBLIC_ANIMATION_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _PublicAnimationEvent + : public Tizen::Base::Runtime::_Event +{ +public: + virtual ~_PublicAnimationEvent(void); + + const Tizen::Ui::Control* GetSource(void) const; + + static _PublicAnimationEvent* CreateInstanceN(const Tizen::Ui::Control& source); + static Tizen::Base::Runtime::IEventArg* CreateAnimationEventArgN(void); + +protected: + _PublicAnimationEvent(const Tizen::Ui::Control& source); + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + const Tizen::Ui::Control* __pSource; + +}; // _PublicAnimationEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_PUBLIC_ANIMATION_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicClipboardPopupEvent.h b/src/ui/inc/FUiCtrl_PublicClipboardPopupEvent.h new file mode 100644 index 0000000..cea984b --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicClipboardPopupEvent.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicClipboardPopupEvent.h + * @brief This is the header file containing the declaration of the _PublicClipboardPopupEvent class. + * + * This header file contains the declarations of the _PublicClipboardPopupEvent class. + */ +#ifndef _FUI_CTRL_INTERNAL_PUBLIC_CLIPBOARD_POPUP_EVENT_H_ +#define _FUI_CTRL_INTERNAL_PUBLIC_CLIPBOARD_POPUP_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { +class ClipboardItem; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class _PublicClipboardPopupEvent + : public Tizen::Base::Runtime::_Event +{ +public: + static _PublicClipboardPopupEvent* CreateInstanceN(void); + static Tizen::Base::Runtime::IEventArg* CreateClipboardPopupEventArgN(const Tizen::Ui::ClipboardItem* pClipboardItem); + + virtual ~_PublicClipboardPopupEvent(void); + +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + _PublicClipboardPopupEvent(void); + + _PublicClipboardPopupEvent(const _PublicClipboardPopupEvent& rhs); + _PublicClipboardPopupEvent& operator =(const _PublicClipboardPopupEvent& rhs); +}; // _PublicClipboardPopupEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_PUBLIC_CLIPBOARD_POPUP_EVENT_H_ \ No newline at end of file diff --git a/src/ui/inc/FUiCtrl_PublicColorChangeEvent.h b/src/ui/inc/FUiCtrl_PublicColorChangeEvent.h new file mode 100644 index 0000000..1470554 --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicColorChangeEvent.h @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicColorChangeEvent.h + * @brief This is the header file for _PublicColorChangeEvent class. + * + * This header file contains declaration of _PublicColorChangeEvent class. + */ +#ifndef _FUI_CTRL_INTERNAL_PUBLIC_COLOR_CHANGE_EVENT_H_ +#define _FUI_CTRL_INTERNAL_PUBLIC_COLOR_CHANGE_EVENT_H_ + +#include +#include + +namespace Tizen { namespace Graphics +{ +class Color; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** +* @class _ColorChangeEvent +* @brief This class handles a action event. It is inherited from Event class. +* +* The Window(root of all widgets) class has an instance of the ColorChangeEvent class as a member variable. +* Applications can register action event listeners through it. When a action event occurred, +* the ColorChangeEvent class finds listener and calls the appropriate listener's method. +* +*/ +class _PublicColorChangeEvent + : public Tizen::Base::Runtime::_Event +{ +public: + // + // This is the default class constructor. + // + _PublicColorChangeEvent(void); + + // + // This is the default class destructor. + // + virtual ~_PublicColorChangeEvent(void); + + // + // This method initializes this instance. This method should be called + // after this instance is constructed. + // + // @return The method returns error code. + // @param[in] source A pointer to the Object instance which contains this instance. + // @exception E_SUCCESS - This method is successful. + // @exception E_ARG_NULL - The input source is null. + // + static _PublicColorChangeEvent* CreateInstanceN(const Tizen::Ui::Control& source); + + // + // This method returns the owner of this event. + // + // @return See the comment above. + // + const Tizen::Ui::Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateColorChangeEventArgN(const Tizen::Graphics::Color& color); + +protected: + _PublicColorChangeEvent(const Tizen::Ui::Control& source); + + // + // This method checks the arg and finds out the type of event. After that this method calls appropriate + // listener's method. + // + // @param[in] pListener It is a event listener related to this ColorChange event. + // @param[in] arg It is an argument-like instance of ColorChange event retransmitted to the listener's method + // as an argument. + // + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + const Tizen::Ui::Control* __pSource; +}; // _PublicColorChangeEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_PUBLIC_COLOR_CHANGE_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicDateTimeChangeEvent.h b/src/ui/inc/FUiCtrl_PublicDateTimeChangeEvent.h new file mode 100644 index 0000000..0a3c78d --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicDateTimeChangeEvent.h @@ -0,0 +1,156 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicDateTimeChangeEvent.h + * @brief This is the header file for the _PublicDateTimeChangeEvent and _PublicDateTimeChangeEventArg classes. + */ + +#ifndef _FUI_CTRL_INTERNAL_PUBLIC_DATETIME_CHANGE_EVENT_H_ +#define _FUI_CTRL_INTERNAL_PUBLIC_DATETIME_CHANGE_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +enum DateTimePublicChangeStatus +{ + DATE_PUBLIC_CHANGE_SAVED, + DATE_PUBLIC_CHANGE_CANCELED, + DATETIME_PUBLIC_CHANGE_SAVED, + DATETIME_PUBLIC_CHANGE_CANCELED, + TIME_PUBLIC_CHANGE_SAVED, + TIME_PUBLIC_CHANGE_CANCELED +}; + +class _PublicDateTimeChangeEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +public: + /** + * This is the default class constructor. + * + * @param[in] source - A pointer to the Object instance which contains this instance. + */ + _PublicDateTimeChangeEventArg(DateTimePublicChangeStatus status); + + /** + * This is the class destructor. + */ + ~_PublicDateTimeChangeEventArg(void); + + int GetYear(void) const; + + int GetMonth(void) const; + + int GetDay(void) const; + + int GetHour(void) const; + + int GetMinute(void) const; + + Tizen::Base::DateTime GetDateTime(void) const; + + void SetDateTime(const Tizen::Base::DateTime& dateTime); + + void SetTime(int hour, int minute); + + void SetDate(int year, int month, int day); + + DateTimePublicChangeStatus GetStatus(void) const; + +private: + // Attributes + DateTimePublicChangeStatus __status; + + int __year; + int __month; + int __day; + int __hour; + int __minute; + + Tizen::Base::DateTime __dateTime1; + +}; // _PublicDateTimeChangeEventArg + +/**l +* @class _PublicDateTimeChangeEvent +* @brief This class handle a Date change event. +*/ + +class _PublicDateTimeChangeEvent + : public Tizen::Base::Runtime::_Event +{ +public: + static Tizen::Base::Runtime::IEventArg* CreateDateTimeChangeEventArgN(DateTimePublicChangeStatus status); + + /** + * This is the default class constructor. After creating an instance of this + * class, you must explicitly call one of construction methods to initialize + * the instance. + */ + _PublicDateTimeChangeEvent(const Tizen::Ui::Control& source); + + /** + * This is the class destructor. + */ + virtual ~_PublicDateTimeChangeEvent(void); + + // Accessors + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::Control* GetSource(void) const; + + + // Operations +protected: + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @return This method returns a result code. + * @param[in] pListener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of __FlashEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + + // Attributes +private: + Tizen::Ui::Control* __pSource; +}; // _PublicDateTimeChangeEvent + + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_PUBLIC_DATETIME_CHANGE_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicExpandableEditAreaEvent.h b/src/ui/inc/FUiCtrl_PublicExpandableEditAreaEvent.h new file mode 100644 index 0000000..6865f9a --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicExpandableEditAreaEvent.h @@ -0,0 +1,117 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicExpandableEditAreaEvent.h + * @brief This is the header file for _PublicExpandableEditAreaEvent class. + * @version 1.0 + * + * This header file contains declaration of _PublicExpandableEditAreaEvent class. + * The PublicExpandableEditAreaEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUICTRL_PUBLIC_EXPANDABLE_EDITAREA_EVENT_H_ +#define _FUICTRL_PUBLIC_EXPANDABLE_EDITAREA_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum ExpandableEditAreaEventStatus +{ + EXPANDABLE_EDITAREA_EVENT_ADDED = 0, + EXPANDABLE_EDITAREA_EVENT_REMOVED +// EXPANDABLE_EDITAREA_EVENT_TOKEN_SELECTED +}; + +/** +* @class _PublicExpandableEditAreaEvent +* @brief This class handles a action event. It is inherited from Event class. +* +* The Window(root of all widgets) class has an instance of the _PublicExpandableEditAreaEvent class as a member variable. +* Applications can register action event listeners through it. When a action event occurred, +* the _PublicExpandableEditAreaEvent class finds listener and calls the appropriate listener's method. +* +*/ +class _PublicExpandableEditAreaEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_PublicExpandableEditAreaEvent(void); + + static _PublicExpandableEditAreaEvent* CreateInstanceN(const Tizen::Ui::Control& source); + +// Accessors +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::Control* GetSource(void) const; + +// Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _PublicExpandableEditAreaEvent(const Tizen::Ui::Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this action event. + * @param[in] arg It is an argument-like instance of action event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IExpandableEditAreaEventListener class or + * the p__ExpandableEditAreaEventArg is not the instance of _ExpandableEditAreaEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +public: + static Tizen::Base::Runtime::IEventArg* CreateExpandableEditAreaEventArgN(ExpandableEditAreaEventStatus status, int index = -1); + +//Attributess +private: + const Tizen::Ui::Control* __pSource; +}; // _PublicExpandableEditAreaEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_PUBLIC_EXPANDABLE_EDITAREA_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicFrameEvent.h b/src/ui/inc/FUiCtrl_PublicFrameEvent.h new file mode 100644 index 0000000..ad8ba86 --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicFrameEvent.h @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicFrameEvent.h + * @brief This is the header file for _PublicFrameEvent class. + * @version 1.0 + * + * This header file contains declaration of _PublicFrameEvent class. + * The _PublicFrameEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_INTERNAL_PUBLIC_FRAME_EVENT_H_ +#define _FUI_CTRL_INTERNAL_PUBLIC_FRAME_EVENT_H_ + +#include +#include +#include "FBaseRt_Event.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * A constant that indicates that Frame is about to be destroyed. + */ +static const int FRAME_STATE_TERMINATING = 0x08; +static const int FRAME_STATE_ACTIVATED = 0x10; +static const int FRAME_STATE_DEACTIVATED = 0x20; + +class Frame; + +/** + * @class _PublicFrameEvent + * @brief This class handles a frame event. It is inherited from Event class. + * + * The Frame class has an instance of the _PublicFrameEvent class as a member variable. + * Applications can register frame event listeners through it. When a frame lifecycle event occurs, + * the _PublicFrameEvent class finds listener and calls the appropriate listener's method. + */ +class _PublicFrameEvent + : public Tizen::Base::Runtime::_Event +{ +public: +// Lifecycle + static _PublicFrameEvent* CreateInstanceN(const Frame& source); + static Tizen::Base::Runtime::IEventArg* CreateFrameEventArgN(const Frame& source, int frameState); + + /** + * This is the class destructor. + * + */ + virtual ~_PublicFrameEvent(void); + +// Accessor + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Frame* GetSource(void) const; + +protected: +// Operation + /** + * This method is Implemented to call the corresponding event listener's method. + * + * @return The method returns the error code + * @param[in] pListener The eventListener instance which is currently processing + * @param[in] arg The event argument that is fired + * @return The method returns error code. + * @exception E_SUCCESS - This method is successful. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value. + * @exception E_ARG_NULL - The pointer passed to a method contains a @c null reference. + * @exception E_UNKNOWN - An undetermined error has occurred during operation. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: +// Lifecycle + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _PublicFrameEvent(const Frame& source); + +private: +// Attribute + const Frame* __pSource; +}; // _PublicFrameEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_PUBLIC_FRAME_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicKeypadEvent.h b/src/ui/inc/FUiCtrl_PublicKeypadEvent.h new file mode 100644 index 0000000..5eee7dd --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicKeypadEvent.h @@ -0,0 +1,111 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicKeypadEvent.h +* @brief This is the header file for _PublicKeypadEvent class. +* +* This header file contains declaration of _PublicKeypadEvent class. +*/ + +#ifndef _FUI_CTRL_INTERNAL_PUBLIC_KEYPAD_EVENT_H_ +#define _FUI_CTRL_INTERNAL_PUBLIC_KEYPAD_EVENT_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum KeypadEventStatus +{ + KEYPAD_EVENT_STATUS_CREATED, + KEYPAD_EVENT_STATUS_OPEN, + KEYPAD_EVENT_STATUS_CLOSE, + KEYPAD_EVENT_STATUS_BOUNDS_CHANGED, + KEYPAD_EVENT_STATUS_ENTERACTION +}; + +/** +* @class _PublicKeypadEvent +* @brief This class handles a keypad event event. It is inherited from Event class. +* +*/ +class _PublicKeypadEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_PublicKeypadEvent(void); + + static _PublicKeypadEvent* CreateInstanceN(const Tizen::Ui::Control& source); + +// Accessors + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateKeypadEventArgN(const Tizen::Ui::Control& source, Tizen::Ui::KeypadAction actionId, Tizen::Ui::Controls::KeypadEventStatus status); + + // Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _PublicKeypadEvent(const Tizen::Ui::Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of _CustomItemEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + + //Attributess +private: + const Tizen::Ui::Control* __pSource; +}; // _PublicKeypadEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_PUBLIC_KEYPAD_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicLanguageEvent.h b/src/ui/inc/FUiCtrl_PublicLanguageEvent.h new file mode 100644 index 0000000..3dcc930 --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicLanguageEvent.h @@ -0,0 +1,96 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicLanguageEvent.h + * @brief This is the header file for _LanguageEvent class. + * @version 1.0 + * + * This header file contains declaration of _LanguageEvent class. + */ + +#ifndef _FUI_CTRL_INTERNAL_PUBLIC_LANGUAGE_EVENT_H_ +#define _FUI_CTRL_INTERNAL_PUBLIC_LANGUAGE_EVENT_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _PublicLanguageEvent + * @brief This class handles a _PublicLanguageEvent event. It is inherited from LowLevelEvent class. + * + * _LanguageEvent notifies the listeners when a Keypad language is changed. + * + * @since 1.0 + */ +class _PublicLanguageEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the class destructor. + */ + virtual ~_PublicLanguageEvent(); + + static _PublicLanguageEvent* CreateInstanceN(const Tizen::Ui::Control& source); + +// Accessors + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateLanguageEventArgN(const Tizen::Ui::Control& source, Tizen::Locales::LanguageCode prevLanguageCode, Tizen::Locales::LanguageCode currentLanguageCode); + +protected: + /** + * This is the default class constructor. After creating an instance of this + * class, you must explicitly call one of construction methods to initialize + * the instance. + */ + _PublicLanguageEvent(const Tizen::Ui::Control& source); + + /** + * This method calls appropriate IKeyEventListener method. + * + * @param[in] listener The IKeyEventListener instance. + * @param[in] arg The _FocusEventArg. + * @exception E_SUCCESS - The method is successful. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value. + * @exception E_INVALID_ARG - @c pListener is @c null. + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + const Tizen::Ui::Control* __pSource; + +}; // _PublicLanguageEvent + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_PUBLIC_LANGUAGE_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicLinkEvent.h b/src/ui/inc/FUiCtrl_PublicLinkEvent.h new file mode 100644 index 0000000..7844e70 --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicLinkEvent.h @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicLinkEvent.h +* @brief This is the header file for _PublicLinkEvent class. +* +* This header file contains declaration of _PublicLinkEvent class. +* +*/ + +#ifndef _FUI_CTRL_PUBLIC_LINK_EVENT_H_ +#define _FUI_CTRL_PUBLIC_LINK_EVENT_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** +* @class _PublicLinkEvent +* @brief This class handles a keypad event event. It is inherited from Event class. +* +*/ +class _PublicLinkEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_PublicLinkEvent(void); + + static _PublicLinkEvent* CreateInstanceN(const Tizen::Ui::Control& source); + +// Accessors + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateLinkEventArgN(Tizen::Base::String text, Tizen::Base::Utility::LinkType linkType, Tizen::Base::String link); + + // Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _PublicLinkEvent(const Tizen::Ui::Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of _CustomItemEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + + //Attributess +private: + const Tizen::Ui::Control* __pSource; +}; // _PublicLinkEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_PUBLIC_LINK_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicProgressPopupEvent.h b/src/ui/inc/FUiCtrl_PublicProgressPopupEvent.h new file mode 100644 index 0000000..0731eb2 --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicProgressPopupEvent.h @@ -0,0 +1,81 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicProgressPopupEvent.h + * @brief This is the header file for _PublicProgressPopupEvent class. + * + * This header file contains declaration of _PublicProgressPopupEvent class. + * The PublicActionEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_PUBLIC_PROGRESSPOPUP_EVENT_H_ +#define _FUI_CTRL_PUBLIC_PROGRESSPOPUP_EVENT_H_ + + +#include +#include +#include + + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** +* @class _PublicProgressPopupEvent +* @brief This class handles a ProgressPopup event. It is inherited from Event class. +* +* The Window(root of all widgets) class has an instance of the _PublicProgressPopupEvent class as a member variable. +* Applications can register ProgressPopup event listeners through it. When a ProgressPopup event occurred, +* the _PublicProgressPopupEvent class finds listener and calls the appropriate listener's method. +* +*/ +class _PublicProgressPopupEvent + : public Tizen::Base::Runtime::_Event +{ +public: + _PublicProgressPopupEvent(const Tizen::Ui::Control& source); + virtual ~_PublicProgressPopupEvent(void); + + static _PublicProgressPopupEvent* CreateInstanceN(const Tizen::Ui::Control& source); + +public: + const Tizen::Ui::Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateProgressPopupEventArgN(void); + +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& pListener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + _PublicProgressPopupEvent(const _PublicProgressPopupEvent& rhs); + _PublicProgressPopupEvent& operator=(const _PublicProgressPopupEvent& rhs); + +private: + const Tizen::Ui::Control* __pSource; +}; // _PublicProgressPopupEvent + +}}} // Tizen::Ui::Controls + + +#endif // _FUI_CTRL_PUBLIC_PROGRESSPOPUP_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicScrollPanelEvent.h b/src/ui/inc/FUiCtrl_PublicScrollPanelEvent.h new file mode 100644 index 0000000..22ac77d --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicScrollPanelEvent.h @@ -0,0 +1,115 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicScrollPanelEvent.h +* @brief This is the header file for _PublicScrollPanelEvent class. +* +* This header file contains declaration of _PublicScrollPanelEvent class. +* +*/ + +#ifndef _FUI_CTRL_INTERNAL_PUBLIC_SCROLLPANEL_EVENT_H_ +#define _FUI_CTRL_INTERNAL_PUBLIC_SCROLLPANEL_EVENT_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** +* @enum ScrollPanelStatus +* Defines constants used to identify ScrollPanel's Overlay status. @n +* This is used for overlay keypad support. +* +* @since 1.0 +*/ +enum ScrollPanelStatus +{ + OVERLAY_CONTROL_CREATED, /**< An overlay keypad created on top of ScrollPanel */ + OVERLAY_CONTROL_OPENED, /**< An overlay keypad opened on top of ScrollPanel */ + OVERLAY_CONTROL_CLOSED, /**< An overlay keypad closed */ + OTHER_CONTROL_SELECTED /**< Another control in the ScrollPanel is selected */ +}; + +/** +* @class _PublicScrollPanelEvent +* @brief This class handles a text Block event event. It is inherited from Event class. +* +*/ +class _PublicScrollPanelEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_PublicScrollPanelEvent(void); + + static _PublicScrollPanelEvent* CreateInstanceN(const Tizen::Ui::Control& source); + +// Accessors +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::Control* GetSource(void) const; + + // Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _PublicScrollPanelEvent(const Tizen::Ui::Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of _CustomItemEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +public: + static Tizen::Base::Runtime::IEventArg* CreateScrollPanelEventArgN(ScrollPanelStatus status); + + //Attributess +private: + const Tizen::Ui::Control* __pSource; +}; // _PublicScrollPanelEvent + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_PUBLIC_SCROLLPANEL_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicSearchBarEvent.h b/src/ui/inc/FUiCtrl_PublicSearchBarEvent.h new file mode 100644 index 0000000..2cd0d91 --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicSearchBarEvent.h @@ -0,0 +1,114 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_PublicSearchBarEvent.h + * @brief This is the header file for _PublicSearchBarEvent class. + * @version 1.0 + * + * This header file contains declaration of _PublicSearchBarEvent class. + * The PublicActionEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_INTERNAL_PUBLIC_SEARCH_BAR_EVENT_H_ +#define _FUI_CTRL_INTERNAL_PUBLIC_SEARCH_BAR_EVENT_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class SearchBar; + +enum SearchBarEventStatus +{ + SEARCH_BAR_EVENT_MODE_CHANGE = 0, + SEARCH_BAR_EVENT_CONTENT_AREA_RESIZE +}; + +/** +* @class _PublicSearchBarEvent +* @brief This class handles a action event. It is inherited from Event class. +* +* The Window(root of all widgets) class has an instance of the _PublicSearchBarEvent class as a member variable. +* Applications can register action event listeners through it. When a action event occurred, +* the _PublicSearchBarEvent class finds listener and calls the appropriate listener's method. +* +*/ +class _PublicSearchBarEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_PublicSearchBarEvent(void); + + static _PublicSearchBarEvent* CreateInstanceN(const SearchBar& source); + +// Accessors + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const SearchBar* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateSearchBarEventArgN(SearchBarEventStatus status); + +// Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _PublicSearchBarEvent(const SearchBar& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this action event. + * @param[in] arg It is an argument-like instance of action event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IActionEventListener class or + * the p__ActionEventArg is not the instance of _ActionEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attributess +private: + const SearchBar* __pSource; + +}; // _PublicSearchBarEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_PUBLIC_SEARCH_BAR_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicSliderEvent.h b/src/ui/inc/FUiCtrl_PublicSliderEvent.h new file mode 100644 index 0000000..39c4ad0 --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicSliderEvent.h @@ -0,0 +1,56 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicSliderEvent.h + * @brief This is the header file for _PublicSliderEvent class. + * + * This header file contains declaration of _PublicSliderEvent class. + */ +#ifndef _FUI_CTRL_PUBLIC_SLIDER_EVENT_H_ +#define _FUI_CTRL_PUBLIC_SLIDER_EVENT_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class Slider; + + +class _PublicSliderEvent + : public Tizen::Base::Runtime::_Event +{ +public: + virtual ~_PublicSliderEvent(void); + + const Slider* GetSource(void) const; + + static _PublicSliderEvent* CreateInstanceN(const Slider& source); + static Tizen::Base::Runtime::IEventArg* CreateSliderEventArgN(int value); + +protected: + _PublicSliderEvent(const Slider& source); + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + Slider* __pSource; + +}; // _PublicSliderEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_PUBLIC_SLIDER_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicSplitPanelEvent.h b/src/ui/inc/FUiCtrl_PublicSplitPanelEvent.h new file mode 100644 index 0000000..245ee5e --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicSplitPanelEvent.h @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicSplitPanelEvent.h +* @brief This is the header file for _PublicSplitPanelEvent class. +* +* This header file contains declaration of _PublicSplitPanelEvent class. +* +*/ + +#ifndef _FUI_CTRL_INTERNAL_PUBLIC_SPLIT_PANEL_EVENT_H_ +#define _FUI_CTRL_INTERNAL_PUBLIC_SPLIT_PANEL_EVENT_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class SplitPanel; + +enum SplitPanelEventStatus +{ + SPLIT_PANEL_EVENT_DIVIDER_POSITION_CHANGE = 0, + SPLIT_PANEL_EVENT_DIVIDER_DOUBLE_PRESSED +}; + +/** +* @class _PublicSplitPanelEvent +* @brief This class handles a text Block event event. It is inherited from Event class. +* +*/ +class _PublicSplitPanelEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_PublicSplitPanelEvent(void); + + static _PublicSplitPanelEvent* CreateInstanceN(const SplitPanel& source); + +// Accessors +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const SplitPanel* GetSource(void) const; + + // Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _PublicSplitPanelEvent(const SplitPanel& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @return This method returns a result code. + * @param[in] pListener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of _CustomItemEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +public: + static Tizen::Base::Runtime::IEventArg* CreateSplitPanelEventArgN(SplitPanelEventStatus status); + + //Attributess +private: + const SplitPanel* __pSource; +}; // _PublicSplitPanelEvent + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_PUBLIC_SPLIT_PANEL_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicTextBlockEvent.h b/src/ui/inc/FUiCtrl_PublicTextBlockEvent.h new file mode 100644 index 0000000..2ee3feb --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicTextBlockEvent.h @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUiCtrl_PublicTextBlockEvent.h +* @brief This is the header file for _PublicTextBlockEvent class. +* +* This header file contains declaration of _TextBlockEvent class. +*/ + +#ifndef _FUI_CTRL_INTERNAL_PUBLIC_TEXT_BLOCK_EVENT_H_ +#define _FUI_CTRL_INTERNAL_PUBLIC_TEXT_BLOCK_EVENT_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** +* @class _PublicTextBlockEvent +* @brief This class handles a text Block event event. It is inherited from Event class. +* +*/ +class _PublicTextBlockEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_PublicTextBlockEvent(void); + + static _PublicTextBlockEvent* CreateInstanceN(const Tizen::Ui::Control& source); + +// Accessors +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::Control* GetSource(void) const; + + // Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _PublicTextBlockEvent(const Tizen::Ui::Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of _CustomItemEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +public: + static Tizen::Base::Runtime::IEventArg* CreateTextBlockEventArgN(int start, int end); + + //Attributess +private: + const Tizen::Ui::Control* __pSource; +}; // _PublicTextBlockEvent + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_PUBLIC_TEXT_BLOCK_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_PublicTextEvent.h b/src/ui/inc/FUiCtrl_PublicTextEvent.h new file mode 100644 index 0000000..eceac3e --- /dev/null +++ b/src/ui/inc/FUiCtrl_PublicTextEvent.h @@ -0,0 +1,113 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_PublicTextEvent.h + * @brief This is the header file for _PublicTextEvent class. + * + * This header file contains declaration of _PublicTextEvent class. + * The PublicTextEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_INTERNAL_PUBLIC_TEXT_EVENT_H_ +#define _FUI_CTRL_INTERNAL_PUBLIC_TEXT_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum TextEventStatus +{ + TEXT_EVENT_CHANGED, + TEXT_EVENT_CANCELED +}; + +/** +* @class _PublicTextEvent +* @brief This class handles a action event. It is inherited from Event class. +* +* The Window(root of all widgets) class has an instance of the _PublicTextEvent class as a member variable. +* Applications can register action event listeners through it. When a action event occurred, +* the _PublicTextEvent class finds listener and calls the appropriate listener's method. +* +*/ +class _PublicTextEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_PublicTextEvent(void); + + static _PublicTextEvent* CreateInstanceN(const Tizen::Ui::Control& source); + +// Accessors + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateTextEventArgN(TextEventStatus status); + +// Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _PublicTextEvent(const Tizen::Ui::Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this action event. + * @param[in] arg It is an argument-like instance of action event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of ITextEventListener class or + * the p__TextEventArg is not the instance of _TextEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attributess +private: + const Tizen::Ui::Control* __pSource; +}; // _PublicTextEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_PUBLIC_TEXT_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_RadioGroup.h b/src/ui/inc/FUiCtrl_RadioGroup.h new file mode 100644 index 0000000..71dccde --- /dev/null +++ b/src/ui/inc/FUiCtrl_RadioGroup.h @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_RadioGroup.h + * @brief This is the header file for the _RadioGroup class. + * + * This header file contains the declarations of the %_RadioGroup class. + */ +#ifndef _FUI_CTRL_INTERNAL_RADIO_GROUP_H_ +#define _FUI_CTRL_INTERNAL_RADIO_GROUP_H_ + +#include +#include "FUi_Control.h" +#include "FUiCtrl_CheckButton.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +class _RadioGroupPresenter; + +/** + * @class _RadioGroup + * @brief + * @since 1.0 + * + * + * + * + */ + +class _OSP_EXPORT_ _RadioGroup + : public Tizen::Ui::_Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer +{ +public: + virtual ~_RadioGroup(void); + +public: + static _RadioGroup* CreateRadioGroupN(void); + +public: + result CreateCheckList(void); + result Add(_CheckButton& checkButton); + result Remove(_CheckButton& checkButton); + virtual bool OnNotifiedN(const _Control& source, Tizen::Base::Collection::IList* pArgs); + + int GetItemCount(void) const; + + result SetSelectedItem(const _CheckButton& checkButton); + const _CheckButton* GetSelectedItem(void) const; + +protected: + result SetPresenter(const _RadioGroupPresenter& radioGroupPresenter); + +private: + _RadioGroup(void); + + _RadioGroup(const _RadioGroup& rhs); + _RadioGroup& operator =(const _RadioGroup& rhs); + +private: + _RadioGroupPresenter* __pRadioGroupPresenter; + Tizen::Base::Collection::ArrayList* __checkList; + +}; // _RadioGroup + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_RADIO_GROUP_H_ diff --git a/src/ui/inc/FUiCtrl_RadioGroupImpl.h b/src/ui/inc/FUiCtrl_RadioGroupImpl.h new file mode 100644 index 0000000..5bf3fce --- /dev/null +++ b/src/ui/inc/FUiCtrl_RadioGroupImpl.h @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_RadioGroupImpl.h + * @brief This is the header file for the _RadioGroupImpl class. + * + * This header file contains the declarations of the %_RadioGroupImpl class. + */ +#ifndef _FUI_CTRL_INTERNAL_RADIO_GROUP_IMPL_H_ +#define _FUI_CTRL_INTERNAL_RADIO_GROUP_IMPL_H_ + +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_RadioGroup.h" + +namespace Tizen { namespace Graphics +{ + class Dimension; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _RadioGroupImpl + : public _ControlImpl +{ +public: + class RadioGroupSizeInfo : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + }; // RadioGroupSizeInfo + +public: + virtual ~_RadioGroupImpl(void); + static _RadioGroupImpl* CreateRadioGroupImplN(RadioGroup* pControl); + + virtual const char* GetPublicClassName(void) const; + virtual const RadioGroup& GetPublic(void) const; + virtual RadioGroup& GetPublic(void); + virtual const _RadioGroup& GetCore(void) const; + virtual _RadioGroup& GetCore(void); + + virtual result OnAttachedToMainTree(void); + +public: + result Add(const CheckButton& checkButton); + result Remove(const CheckButton& checkButton); + + int GetItemCount(void) const; + + result SetSelectedItem(const CheckButton& checkButton); + const CheckButton* GetSelectedItem(void) const; + +public: + static Tizen::Graphics::Color GetColorOnError(void); + + static _RadioGroupImpl* GetInstance(RadioGroup& radioGroup); + static const _RadioGroupImpl* GetInstance(const RadioGroup& radioGroup); + +private: + _RadioGroupImpl(RadioGroup* pPublic, _RadioGroup* pCore); + + _RadioGroupImpl(const _RadioGroupImpl& rhs); + _RadioGroupImpl& operator =(const _RadioGroupImpl& rhs); + +}; // _RadioGroupImpl + +}}} // Tizen::Ui::Controls + +#endif //_ FUI_CTRL_INTERNAL_RADIO_GROUP_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_RadioGroupModel.h b/src/ui/inc/FUiCtrl_RadioGroupModel.h new file mode 100644 index 0000000..2886d57 --- /dev/null +++ b/src/ui/inc/FUiCtrl_RadioGroupModel.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_RadioGroupModel.h + * @brief This is the header file for the _RadioGroupModel class. + * + * This header file contains the declarations of the %_RadioGroupModel class. + */ +#ifndef _FUI_CTRL_INTERNAL_RADIO_GROUP_MODEL_H_ +#define _FUI_CTRL_INTERNAL_RADIO_GROUP_MODEL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _RadioGroupModel + * @brief + * @since 1.0 + * + * + * + * + */ +class _RadioGroupModel + : public Tizen::Base::Object +{ +public: + _RadioGroupModel(void); + + virtual ~_RadioGroupModel(void); + +public: + virtual result Construct(void); + +private: + _RadioGroupModel(const _RadioGroupModel& value); + _RadioGroupModel& operator =(const _RadioGroupModel& value); +}; // _RadioGroupModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_RADIO_GROUP_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_RadioGroupPresenter.h b/src/ui/inc/FUiCtrl_RadioGroupPresenter.h new file mode 100644 index 0000000..7c90753 --- /dev/null +++ b/src/ui/inc/FUiCtrl_RadioGroupPresenter.h @@ -0,0 +1,75 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_RadioGroupPresenter.h + * @brief This is the header file for the _RadioGroupPresenter class. + * + * This header file contains the declarations of the %_RadioGroupPresenter class. + */ +#ifndef _FUI_CTRL_INTERNAL_RADIO_GROUP_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_RADIO_GROUP_PRESENTER_H_ + +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Ui { namespace Controls +{ +class _RadioGroup; +class _RadioGroupModel; + +/** + * @class _RadioGroupPresenter + * @brief + * @since 1.0 + * + * + * + * + */ +class _RadioGroupPresenter + : public Tizen::Base::Object +{ +public: + _RadioGroupPresenter(void); + virtual ~_RadioGroupPresenter(void); + +public: + virtual result Construct(const _RadioGroup& radioGroup); + virtual result Install(void); + +protected: + result SetModel(const _RadioGroupModel& radioGroupModel); + +private: + _RadioGroupPresenter(const _RadioGroupPresenter& rhs); + _RadioGroupPresenter& operator =(const _RadioGroupPresenter& rhs); + +private: + _RadioGroup* __pRadioGroup; + _RadioGroupModel* __pRadioGroupModel; + + Tizen::Ui::Animations::_VisualElement* __pRoot; +}; // _RadioGroupPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_RADIO_GROUP_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_Scroll.h b/src/ui/inc/FUiCtrl_Scroll.h new file mode 100644 index 0000000..1a0c314 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Scroll.h @@ -0,0 +1,125 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_Scroll.h + * @brief This is the header file for the _Scroll class. + * + * This header file contains the declarations of the %_Scroll class. + */ + +#ifndef _FUICTRL_INTERNAL_SCROLL_H_ +#define _FUICTRL_INTERNAL_SCROLL_H_ + +#include "FUi_Control.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ScrollPresenter; +class _IScrollEventListener; + +enum _ScrollDirection +{ + SCROLL_DIRECTION_VERTICAL = 0, + SCROLL_DIRECTION_HORIZONTAL +}; + +class _Scroll + : public Tizen::Ui::_Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ +public: + virtual ~_Scroll(void); + static _Scroll* CreateScrollN(Tizen::Ui::_Control& parentCtrl, + _ScrollDirection scrollDir, + bool enableFadeEffect, + bool enableJumpToTop, + bool enableHandler, + bool visibility, + int viewRange, + int scrollRange, + int scrollPosition); + + result SetScrollDirection(_ScrollDirection scrollDir); + _ScrollDirection GetScrollDirection(void) const; + result SetScrollRange(int viewRange, int scrollRange); + void GetScrollRange(int* pViewRange, int* pScrollRange) const; + result SetScrollPosition(int scrollPosition); + int GetScrollPosition(void) const; + + void EnableFadeEffect(bool enable); + bool IsEnabledFadeEffect(void) const; + bool IsOnFadeEffect(void) const; + void EnableScrollingEffect(bool enable); + bool IsEnabledScrollingEffect(void) const; + void EnableOverScrollingEffect(bool enable); + bool IsEnabledOverScrollingEffect(void) const; + void SetParentUsingViewport(bool useViewport); + bool IsParentUsingViewport(void) const; + result SetScrollVisibility(bool visibility); + bool GetScrollVisibility(void) const; + void CancelFadeEffect(void); + result SetScrollingEffectVisibility(bool visibility); + + + result EnableJumpToTop(bool enable); + bool IsEnabledJumpToTop(void) const; + + result EnableHandler(bool enable); + bool IsEnabledHandler(void) const; + + void AddScrollEventListener(const Tizen::Ui::Controls::_IScrollEventListener& listener); + void RemoveScrollEventListener(const Tizen::Ui::Controls::_IScrollEventListener& listener); + + void OnParentBoundsChanged(void); + + virtual void OnDraw(void); + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual Tizen::Ui::Animations::HitTestResult HitTest(const Tizen::Graphics::FloatPoint& point); + +private: + _Scroll(const _Scroll& rhs); + _Scroll& operator =(const _Scroll& rhs); + + _Scroll(void); + result Construct(Tizen::Ui::_Control& parentCtrl, + _ScrollDirection scrollDir, + bool enableFadeEffect, + bool enableJumpToTop, + bool enableHandler, + bool visibility, + int viewRange, + int scrollRange, + int scrollPosition); + + void SetPresenter(_ScrollPresenter& scrollPresenter); + _ScrollPresenter& GetPresenter(void) const; + + +private: + _ScrollPresenter* __pPresenter; + +}; + +}}} // Tizen::Ui::Controls + +#endif //_FUICTRL_INTERNAL_SCROLL_H_ diff --git a/src/ui/inc/FUiCtrl_ScrollEvent.h b/src/ui/inc/FUiCtrl_ScrollEvent.h new file mode 100644 index 0000000..a668f96 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ScrollEvent.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollEvent.h +* @brief This is the header file for _ScrollEvent class. + * + * This header file contains declaration of _ScrollEvent class. + * The ItemEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ + +#ifndef _FUI_INTERNAL_SCROLL_EVENT_H_ +#define _FUI_INTERNAL_SCROLL_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** +* @class _ScrollEvent +* @brief This class handles a scroll event. It is inherited from Event class. +* +*/ +class _ScrollEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + _ScrollEvent(void); + + virtual ~_ScrollEvent(void); + + result Construct(const Tizen::Ui::Control& source); + +// Accessors +public: + Tizen::Ui::Control* GetSource(void) const; + +// Operations +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attributess +private: + Tizen::Ui::Control* __pSource; +}; // _ScrollEvent + +}}} //Tizen::Ui::Controls + +#endif // _FUI_SCROLL_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_ScrollEventArg.h b/src/ui/inc/FUiCtrl_ScrollEventArg.h new file mode 100644 index 0000000..b61c96e --- /dev/null +++ b/src/ui/inc/FUiCtrl_ScrollEventArg.h @@ -0,0 +1,139 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollEventArg.h + * @brief This is the header file for _ScrollEventArg class. + * + * This header file contains declaration of _ScrollEventArg class. + * + */ + +#ifndef _FUI_INTERNAL_SCROLL_EVENT_ARG_H_ +#define _FUI_INTERNAL_SCROLL_EVENT_ARG_H_ + +#include +#include +#include +#include +#include +#include "FUiCtrl_ScrollEventTypes.h" + +namespace Tizen { namespace Ui +{ +class Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _ScrollEventArg + * @brief This class is used as the argument to item event listener. + * + * From this class, one can find out, the (event) source object, index and Scroll event type. + */ +class _ScrollEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +// Lifecycle +public: + /** + * This is the class destructor. + * + */ + virtual ~_ScrollEventArg(void); + + /** + * General getter for %_ScrollEventArg class object when fire OnScrollStopped event + * + * @param[in] source A pointer to the Object instance which contains this instance + */ + static _ScrollEventArg* GetScrollEventArgN(const Control& source); + + /** + * General getter for %_ScrollEventArg class object when fire OnScrollPositionChanged event + * + * @param[in] source A pointer to the Object instance which contains this instance + * @param[in] scrollPosition A scroll position of the scroll + */ + static _ScrollEventArg* GetScrollEventArgN(const Control& source, int scrollPosition); + + /** + * General getter for %_ScrollEventArg class object when fire OnScrollEndReached event + * + * @param[in] source A pointer to the Object instance which contains this instance + * @param[in] scrollType A direction of the scroll + */ + static _ScrollEventArg* GetScrollEventArgN(const Control& source, ScrollEndEvent scrollType); + +// Accessor +public: + /** + * This method returns the type of firing event + * + * @return See the comment above. + */ + _ScrollEventType GetEventType(void) const; + + /** + * This method returns the object which the event initially occurred. + * + * @return The object which the event initially occurred. + */ + Tizen::Ui::Control* GetSource(void) const; + + /** + * This method returns the scroll position + * + * @return See the comment above. + */ + int GetScrollPosition(void) const; + + /** + * This method returns the ItemStatus + * + * @return See the comment above. + */ + ScrollEndEvent GetScrollType(void) const; + +// Attribute +private: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Object instance which contains this instance + * @param[in] eventType A type of firing event + * @param[in] scrollPosition A scroll position of the scroll + * @param[in] scrollType A direction of the scroll + */ + _ScrollEventArg(_ScrollEventType eventType, const Control& source, int scrollPosition = -1, ScrollEndEvent scrollType = SCROLL_END_EVENT_END_TOP); + + /** + * Event source. + */ + _ScrollEventType __eventType; + Control* __pSource; + int __scrollPosition; + ScrollEndEvent __scrollType; +}; // _ScrollEventArg + + +}}} //Tizen::Ui::Controls + +#endif // _FUI_SCROLL_EVENT_ARG_H_ diff --git a/src/ui/inc/FUiCtrl_ScrollEventTypes.h b/src/ui/inc/FUiCtrl_ScrollEventTypes.h new file mode 100644 index 0000000..33408c6 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ScrollEventTypes.h @@ -0,0 +1,42 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollEventTypes.h + * @brief This is the header file for enumeration using in _ScrollEvent and _UiScrollEvent. + * + * This header file contains declaration of enumeration for _ScrollEvent and _UiScrollEvent. + * + */ + +#ifndef _FUI_CTRL_INTERNAL_SCROLL_EVENT_TYPES_H_ +#define _FUI_CTRL_INTERNAL_SCROLL_EVENT_TYPES_H_ + + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum _ScrollEventType +{ + SCROLL_EVENT_ON_SCROLL_POSITION_CHANGED, + SCROLL_EVENT_ON_SCROLL_END_REACHED, + SCROLL_EVENT_ON_SCROLL_STOPPED +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SCROLL_EVENT_TYPES_H_ diff --git a/src/ui/inc/FUiCtrl_ScrollPanel.h b/src/ui/inc/FUiCtrl_ScrollPanel.h new file mode 100644 index 0000000..606cd1b --- /dev/null +++ b/src/ui/inc/FUiCtrl_ScrollPanel.h @@ -0,0 +1,276 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollPanel.h + * @brief This is the header file for the _ScrollPanel class. + * + * This header file contains the declarations of the _ScrollPanel class. + */ + +#ifndef _FUI_CTRL_INTERNAL_SCROLL_PANEL_H_ +#define _FUI_CTRL_INTERNAL_SCROLL_PANEL_H_ + +#include +#include +#include +#include +#include "FUi_ITouchFlickGestureEventListener.h" +#include "FUi_IAccessibilityListener.h" +#include "FUi_AccessibilityContainer.h" +#include "FUi_AccessibilityElement.h" +#include "FUiCtrl_IScrollableContainer.h" +#include "FUiCtrl_IScrollEventListener.h" +#include "FUiCtrl_ScrollPanelEvent.h" +#include "FUiCtrl_Panel.h" + +namespace Tizen { namespace Ui +{ + +class _Control; +class _ControlImpl; +class _TouchInfo; +class _TouchFlickGestureDetector; + +namespace Animations +{ + +class VisualElementValueAnimation; + +} // Tizen::Ui::Animations + +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _UiScrollEvent; +class _Scroll; +class _ScrollPanelPresenter; + + +class _OSP_EXPORT_ _ScrollPanel + : public _Panel + , public _IScrollEventListener + , public _IScrollableContainer + , public _ITouchFlickGestureEventListener + , public _IAccessibilityListener + , public Tizen::Ui::Animations::IVisualElementAnimationTickEventListener + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _ITouchGestureEventListener +{ +// Lifecycle +public: + virtual ~_ScrollPanel(void); + + static _ScrollPanel* CreateScrollPanelN(const Tizen::Graphics::Rectangle& rect + , ScrollPanelScrollDirection scrollDirection = SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL + , bool autoResizingEnable = true + , bool pageScrollEnabled = false); +// Operations +public: + // delegateas + virtual void OnDraw(void); + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); + virtual void OnBoundsChanged(void); + + // listener + virtual void OnChildAttached(const _Control& child); + virtual void OnChildDetached(const _Control& child); + virtual void OnChildBoundsChanged(const _Control& child); + + // scroll event listener + virtual void OnScrollEndReached(_Control& source, ScrollEndEvent type); + virtual void OnScrollPositionChanged(_Control& source, int scrollPos); + + // touch Event Previewer + virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + // touch Event Listener + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const _Control& control); + + // gestureListener Callback API + virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture); + virtual bool OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture); + + // accessibility listener + virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element); + // scroll animation event listener + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount); + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + virtual void OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue); + + // manage scroll event listener + void AddScrollEventListener(const _IScrollEventListener& listener); + void RemoveScrollEventListener(const _IScrollEventListener& listener); + + // scroll operations + void ScrollToBottom(void) const; + void ScrollToTop(void) const; + void ScrollToLeft(void) const; + void ScrollToRight(void) const; + + // scrollable container interface + virtual bool ScrollToControl(const _Control& source); + + // Accessor + int GetScrollPosition(void) const; + void SetScrollPosition(int position, bool withAnimation = false); + + // scroll position + int GetVerticalScrollPosition(void) const; + void SetVerticalScrollPosition(int position); + + int GetHorizontalScrollPosition(void) const; + void SetHorizontalScrollPosition(int position); + + // scroll area type + bool IsScrollAreaAutoResizingEnabled(void) const; + void SetScrollAreaAutoResizingEnabled(bool autoResizingEnable); + + // scroll area bounds + Tizen::Graphics::Rectangle GetScrollAreaBounds(void) const; + result SetClientAreaHeight(int height); + result SetClientAreaWidth(int width); + result SetScrollAreaBounds(Tizen::Graphics::Rectangle& bounds); + + // scroll direction + ScrollPanelScrollDirection GetScrollDirection(void) const; + void SetScrollDirection(ScrollPanelScrollDirection direction); + + ScrollInputMode GetScrollInputMode(void) const; + void SetScrollInputMode(ScrollInputMode mode); + + // page scroll + bool IsPageScrollEnabled(void) const; + void SetPageScrollEnabled(bool enable); + + Tizen::Graphics::Dimension GetPageScrollAlignSize(void) const; + void SetPageScrollAlignSize(Tizen::Graphics::Dimension size); + + bool IsPageScrollFlickMoveLimitedOnePage(void) const; + + // store SIP keypad binding control + const _Control* GetControlKeypadBinding(void) const; + void SetControlKeypadBinding(const _Control* pControl); + + // scrollpanel event + _ScrollPanelEvent* GetScrollPanelEvent(void) const; + void SetScrollPanelEvent(const _ScrollPanelEvent* pScrollPanelEvent); + + // _Scroll + bool IsScrollBarVisible(void) const; + void SetScrollBarVisible(bool scrollBarVisible); + + _Scroll* GetScrollBar(void) const; + void SetScrollBar(const _Scroll* pVerticalScrollBar); + + _Scroll* GetVerticalScrollBar(void) const; + void SetVerticalScrollBar(const _Scroll* pVerticalScrollBar); + + _Scroll* GetHorizontalScrollBar(void) const; + void SetHorizontalScrollBar(const _Scroll* pHorizontalScrollBar); + + bool IsFixingClientBoundsEnable(void) const; + void SetFixingClientBoundsEnable(bool enable); + + // VE Value Animation + Tizen::Ui::Animations::VisualElementValueAnimation* GetScrollingAnimation(void) const; + + // event fire + result FireOnScrollEndEvent(ScrollEndEvent scrollEndEventType); + result FireOnScrollPositionChangedEvent(void); + result FireOnScrollPositionChangedEvent(int scrollPosition); + result FireOnScrollStoppedEvent(void); + result FireScrollPanelEvent(const _Control& source, CoreScrollPanelStatus scrollPanelStatus); + +// Lifecycle +protected: + _ScrollPanel(void); + + virtual result Initialize(const _ScrollPanelPresenter& presenter); + + // Accessor + virtual result SetScrollPanelPresenter(const _ScrollPanelPresenter* presenter); + +private: + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + _ScrollPanel(const _ScrollPanel& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + _ScrollPanel& operator =(const _ScrollPanel& rhs); + +// Attribute +private: + _ScrollPanelPresenter* __pScrollPanelPresenter; + + // Scroll event + _UiScrollEvent* __pScrollEvent; + + // ScrollPanel event + _ScrollPanelEvent* __pCoreScrollPanelEvent; + + // gesture event + _TouchFlickGestureDetector* __pGestureFlick; + + const _Control* __pKeyPadBindingControl; + + // scroll feature + ScrollPanelScrollDirection __scrollDirection; + ScrollInputMode __scrollInputMode; + + // scroll area feature + bool __autoResizingEnable; + + // page scroll + bool __pageScrollEnabled; + Tizen::Graphics::Dimension __pageScrollAlignSize; + bool __pageScrollMoveOnlyOnePageOnFlick; + + // scroll bar + bool __scrollBarVisible; + _Scroll* __pHorizontalScrollBar; + _Scroll* __pVerticalScrollBar; + + // scrolling animation + Tizen::Ui::Animations::VisualElementValueAnimation* __pScrollingAnimation; + + bool __fixingClientBoundsEnable; +}; // _ScrollPanel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SCROLL_PANEL_H_ + diff --git a/src/ui/inc/FUiCtrl_ScrollPanelEvent.h b/src/ui/inc/FUiCtrl_ScrollPanelEvent.h new file mode 100644 index 0000000..1707af4 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ScrollPanelEvent.h @@ -0,0 +1,121 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_ScrollPanelEvent.h +* @brief This is the header file for _ScrollPanelEvent class. +* +* This header file contains declaration of _ScrollPanelEvent class. +* +*/ + +#ifndef _FUI_CTRL_SCROLL_PANEL_EVENT_H_ +#define _FUI_CTRL_SCROLL_PANEL_EVENT_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** +* @enum ScrollPanelStatus +* Defines constants used to identify ScrollPanel's Overlay status. @n +* This is used for overlay keypad support. +* +* @since 1.0 +*/ +enum CoreScrollPanelStatus +{ + CORE_OVERLAY_CONTROL_CREATED, /**< An overlay keypad created on top of ScrollPanel */ + CORE_OVERLAY_CONTROL_OPENED, /**< An overlay keypad opened on top of ScrollPanel */ + CORE_OVERLAY_CONTROL_CLOSED, /**< An overlay keypad closed */ + CORE_OTHER_CONTROL_SELECTED /**< Another control in the ScrollPanel is selected */ +}; + +/** +* @class _ScrollPanelEvent +* @brief This class handles a text Block event event. It is inherited from Event class. +* +*/ +class _ScrollPanelEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_ScrollPanelEvent(void); + + static _ScrollPanelEvent* CreateScrollPanelEventN(const Tizen::Ui::_Control& source); + +// Accessors +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::_Control* GetSource(void) const; + +public: + static Tizen::Base::Runtime::IEventArg* CreateScrollPanelEventArgN(CoreScrollPanelStatus status); + + // Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _ScrollPanelEvent(const Tizen::Ui::_Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of _CustomItemEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + + //Attributess +private: + const Tizen::Ui::_Control* __pSource; +}; // _ScrollPanelEvent + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_SCROLL_PANEL_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_ScrollPanelImpl.h b/src/ui/inc/FUiCtrl_ScrollPanelImpl.h new file mode 100644 index 0000000..4535db6 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ScrollPanelImpl.h @@ -0,0 +1,118 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollPanelImpl.h + * @brief This is the header file for the _ScrollPanelImpl class. + * + * This header file contains the declarations of the _ScrollPanelImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_SCROLL_PANEL_IMPL_H_ +#define _FUI_CTRL_INTERNAL_SCROLL_PANEL_IMPL_H_ + +#include +#include "FUiCtrl_IScrollEventListener.h" +#include "FUiCtrl_PanelImpl.h" +#include "FUiCtrl_ScrollPanel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ScrollEvent; + +class _ScrollPanelImpl + : public _PanelImpl + , public _IScrollEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + virtual ~_ScrollPanelImpl(void); + +// Operations +public: + static _ScrollPanelImpl* CreateScrollPanelImplN(ScrollPanel* pPublic, const Tizen::Graphics::Rectangle& rect, ScrollPanelScrollDirection scrollDirection, bool autoResizingEnable, Layout* pPublicPortraitLayout = null, Layout* pPublicLandscapeLayout = null); + + // scroll operations + int GetScrollPosition(void) const; + void SetScrollPosition(int position, bool withAnimation); + + void ScrollToBottom(void) const; + void ScrollToTop(void) const; + + // scroll event listener + void AddScrollEventListener(IScrollEventListener& listener); + void RemoveScrollEventListener(IScrollEventListener& listener); + + // scroll event listener + virtual void OnScrollEndReached(_Control& source, ScrollEndEvent type); + virtual void OnScrollPositionChanged(_Control& source, int scrollPosition); + virtual void OnScrollStopped(_Control& source); + + Tizen::Graphics::Rectangle GetClientAreaBounds(void) const; + result SetClientAreaHeight(int height); + result SetClientAreaWidth(int width); + + ScrollPanelScrollDirection GetScrollDirection(void) const; + + bool IsScrollAreaAutoResizingEnabled(void) const; + + void SetPageScrollEnabled(bool enable); + bool IsPageScrollEnabled(void) const; + + void SetScrollBarVisible(bool visible); + bool IsScrollBarVisible(void) const; + + void SetScrollInputMode(ScrollInputMode mode); + ScrollInputMode GetScrollInputMode(void) const; + + // dirty function for OSP 2.0 + result CloseOverlayWindow(void); // deprecate on Tizen 2.0 + +// Accessor +public: + static const _ScrollPanelImpl* GetInstance(const ScrollPanel& scrollPanel); + static _ScrollPanelImpl* GetInstance(ScrollPanel& scrollPanel); + + virtual const char* GetPublicClassName(void) const; + virtual const ScrollPanel& GetPublic(void) const; + virtual ScrollPanel& GetPublic(void); + virtual const _ScrollPanel& GetCore(void) const; + virtual _ScrollPanel& GetCore(void); + +// Lifecycle +protected: + _ScrollPanelImpl(Control* pPublic, _Control* pCore, Layout* pPublicPortraitLayout = null, Layout* pPublicLandscapeLayout = null); + +private: + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + _ScrollPanelImpl(const _ScrollPanelImpl& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + _ScrollPanelImpl& operator =(const _ScrollPanelImpl& rhs); + +// scroll event +private: + _ScrollEvent* __pScrollEvent; + +}; // _ScrollPanelImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_SCROLL_PANEL_IMPL_H_ + diff --git a/src/ui/inc/FUiCtrl_ScrollPanelModel.h b/src/ui/inc/FUiCtrl_ScrollPanelModel.h new file mode 100644 index 0000000..4fbb406 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ScrollPanelModel.h @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollPanelModel.h + * @brief This is the header file for the _ScrollPanelModel class. + * + * This header file contains the declarations of the _ScrollPanelModel class. + */ + +#ifndef _FUI_CTRL_INTERNAL_SCROLL_PANEL_MODEL_H_ +#define _FUI_CTRL_INTERNAL_SCROLL_PANEL_MODEL_H_ + +#include + +namespace Tizen { namespace Graphics { + +class Point; +class Rectangle; +class Dimension; + +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { + +class _Control; + +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ScrollPanelModel + : public Tizen::Base::Object +{ +// Lifecycle +public: + _ScrollPanelModel(void); + virtual ~_ScrollPanelModel(void); + +// Accessor +public: + Tizen::Graphics::Point GetCurrentScrollPosition(void) const; + void SetCurrentScrollPosition(int currentScrollHorizontalPosition, int currentScrollVerticalPosition); + void SetCurrentScrollPosition(Tizen::Graphics::Point& currentScrollPosition); + + int GetCurrentVerticalScrollPosition(void) const; + void SetCurrentVerticalScrollPosition(int currentScrollVerticalPosition); + + int GetCurrentHorizontalScrollPosition(void) const; + void SetCurrentHorizontalScrollPosition(int currentScrollHorizontalPosition); + + void SetScrollAreaBounds(Tizen::Graphics::Rectangle& areaBounds); + Tizen::Graphics::Rectangle GetScrollAreaBounds(void) const; + +private: + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + _ScrollPanelModel(const _ScrollPanelModel& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + _ScrollPanelModel& operator =(const _ScrollPanelModel& rhs); + +// Attribute +private: + Tizen::Graphics::Point __currentScrollPosition; // x : horizontal position, y : vertical position + + Tizen::Graphics::Rectangle __scrollAreaBounds; +}; // _ScrollPanelModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SCROLL_PANEL_MODEL_H_ + diff --git a/src/ui/inc/FUiCtrl_ScrollPanelPresenter.h b/src/ui/inc/FUiCtrl_ScrollPanelPresenter.h new file mode 100644 index 0000000..5a044e3 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ScrollPanelPresenter.h @@ -0,0 +1,246 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollPanelPresenter.h + * @brief This is the header file for the _ScrollPanelPresenter class. + * + * This header file contains the declarations of the _ScrollPanelPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_SCROLL_PANEL_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_SCROLL_PANEL_PRESENTER_H_ + +#include +#include "FUiCtrl_ScrollPanel.h" +#include "FUiCtrl_PanelPresenter.h" + +namespace Tizen { namespace Ui +{ + +class _Control; +class _TouchInfo; +class _TouchFlickGestureDetector; + +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ScrollPanelModel; + + +class _ScrollPanelPresenter + : public _PanelPresenter + , public Tizen::Base::Runtime::ITimerEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + _ScrollPanelPresenter(void); + virtual ~_ScrollPanelPresenter(void); + +// Operations +public: + virtual result Initialize(_ScrollPanel& scrollPanel); + + virtual result Draw(void); + + // Control Delegator + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); + virtual void OnBoundsChanged(void); + + // Listener + virtual void OnChildAttached(const _Control& child); + virtual void OnChildDetached(const _Control& child); + virtual void OnChildBoundsChanged(const _Control& child); + + // Touch Event Previewer + virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchInfo); + virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchInfo); + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchInfo); + virtual _UiTouchEventDelivery OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + // Touch Event Listener + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual void OnTouchMoveHandled(const _Control& control); + + // gestureListener callback API + virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture); + virtual bool OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture); + + // accessibility listener + virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element); + + // scroll event listener + virtual void OnScrollEndReached(_Control& source, ScrollEndEvent type); + virtual void OnScrollPositionChanged(_Control& source, int scrollPos); + + // Timer - Tension, FlickGesture + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + // scroll animation event listener + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount); + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + + virtual void OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue); + + // Scroll Operations + void ScrollToBottom(void); + void ScrollToTop(void); + void ScrollToLeft(void); + void ScrollToRight(void); + + // scrollable container interface + bool ScrollToControl(const _Control& source); + + // Accessor + bool IsScrollable(void) const; + + // scroll area + Tizen::Graphics::Rectangle GetScrollAreaBounds(void) const; + result SetClientAreaHeight(int height); + result SetClientAreaWidth(int width); + result SetScrollAreaBounds(Tizen::Graphics::Rectangle& bounds); + void SetScrollAreaBoundsInternal(Tizen::Graphics::Rectangle& bounds); + + // scroll position + void SetScrollPosition(int position, bool withAnimation); // sets and move + int GetScrollPosition(void) const; + + int GetVerticalScrollPosition(void) const; + void SetVerticalScrollPosition(int position); + + int GetHorizontalScrollPosition(void) const; + void SetHorizontalScrollPosition(int position); + +protected: + // Update Layout + virtual void UpdateLayout(void); + + // Accessor + const _Control* GetPressedControl(void) const; + Tizen::Graphics::Point GetPreviousTouchPosition(void) const; + Tizen::Graphics::Point GetCurrentTouchPosition(void) const; + + bool IsScrollAnimationRunning(void) const; + + // Scroll operation + virtual int ScrollToInternal(int targetPosition); + int ScrollTo(int distance); + int ScrollTo(int distance, bool withAnimation); + + // Scrollbar operations + virtual void FadeOutScrollBar(void); + virtual void StopFadeOutScrollBar(void); + virtual void FadeInScrollBar(void); + + // bouncing back + void RollbackBouncing(bool withAnimation); + +private: + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + _ScrollPanelPresenter(const _ScrollPanelPresenter& rhs); + + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + _ScrollPanelPresenter& operator =(const _ScrollPanelPresenter& rhs); + + // Previous Touch Event + result RunPreviewTouchPressed(const _Control& source, const _TouchInfo& touchInfo); + result RunPreviewTouchMoved(const _Control& source, const _TouchInfo& touchInfo); + result RunPreviewTouchReleased(const _Control& source, const _TouchInfo& touchInfo); + result RunPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + // Adjust Model + void AdjustModel(void); + + // scroll + int GetScrollPositionInternal(void) const; + void SetScrollPositionInternal(int position); + + int GetVerticalScrollPositionInternal(void) const; + void SetVerticalScrollPositionInternal(int position); + + int GetHorizontalScrollPositionInternal(void) const; + void SetHorizontalScrollPositionInternal(int position); + + void StopScrollingAnimation(void); + int FixScrollPositionIntoScrollAreaBounds(int position) const; + int FixScrollPositionIntoScrollAreaBounds(int position, Tizen::Graphics::Rectangle bounds, Tizen::Graphics::Rectangle scrollArea) const; + + // Scrollbar operations + void ChangeScrollBarRange(void); + void ChangeScrollBarPosition(int position); + + // scroll to ... + bool IsControlOutOfView(const _Control& control) const; + void ScrollToControlWhenOutOfView(const _Control& control); + + // scroll bar load effect + void StartScrollBarLoadEffectTimer(void); + void StopScrollBarLoadEffectTimer(void); + + // Flick + int CalculateFlickAmount(int flickDistance, int flickDuration); + bool DoFlickGestureRecognized(_TouchFlickGestureDetector& gesture); + + void StartFlickScrollEffectTimer(void); + void StopFlickScrollEffectTimer(void); + +// Attribute +private: + _ScrollPanel* __pScrollPanel; + _ScrollPanelModel* __pScrollPanelModel; + + _Control* __pPressedControl; + bool __subControlMoved; + bool __touchPressed; + bool __scrollOccured; + + Tizen::Graphics::Point __previousTouchedPosition; + Tizen::Graphics::Point __currentMovedPosition; + + bool __scrollAnimationRunning; + bool __flickRunning; + + Tizen::Base::Runtime::Timer* __pFlickScrollEffectTimer; + _FlickDirection __flickDirection; + int __flickCount; + + Tizen::Base::Runtime::Timer* __pScrollBarLoadEffectTimer; + bool __scrollBarFirstLoaded; + + bool __bouncing; + + bool __firstTouchMove; + ScrollPanelScrollDirection __firstScrollMoveDirection; + +}; // _ScrollPanelPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SCROLL_PANEL_PRESENTER_H_ + diff --git a/src/ui/inc/FUiCtrl_ScrollPresenter.h b/src/ui/inc/FUiCtrl_ScrollPresenter.h new file mode 100644 index 0000000..9a6769a --- /dev/null +++ b/src/ui/inc/FUiCtrl_ScrollPresenter.h @@ -0,0 +1,265 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_ScrollPresenter.h + * @brief This is the header file for the _ScrollPresenter class. + * + * This header file contains the declarations of the %_ScrollPresenter class. + */ + +#ifndef _FUICTRL_INTERNAL_FASTSCROLL_PRESENTER_H_ +#define _FUICTRL_INTERNAL_FASTSCROLL_PRESENTER_H_ + +#include "FBaseString.h" + +#include "FGrpBitmap.h" +#include "FGrpRectangle.h" +#include "FGrpColor.h" +#include "FGrpDimension.h" + +#include "FUi_Control.h" +#include "FUi_UiTouchEvent.h" + +#include "FUiAnim_VisualElement.h" +#include "FUiAnimVisualElementAnimation.h" +#include "FUiAnimVisualElementAnimationProvider.h" +#include "FUiAnimIVisualElementAnimationStatusEventListener.h" + +#include "FUiCtrl_Scroll.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _UiScrollEvent; +class _IScrollEventListener; + + +class _ScrollPresenter + : public Tizen::Ui::Animations::VisualElementAnimationProvider + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener + , virtual public Tizen::Ui::Animations::IVisualElementAnimationProvider + , virtual public _IUiEventListener +{ +public: + virtual ~_ScrollPresenter(void); + static _ScrollPresenter* CreateScrollPresenterN(Tizen::Ui::_Control& parentCtrl, + _Scroll& scrollCtrl, + _ScrollDirection scrollDirection, + bool enableFadeEffect, + bool enableJumpToTop, + bool enableHandler, + bool visibility, + int viewRange, + int scrollRange, + int scrollPosition); + + result SetScrollDirection(_ScrollDirection scrollDirection); + _ScrollDirection GetScrollDirection(void) const; + result SetScrollRange(int viewRange, int scrollRange); + void GetScrollRange(int* pViewRange, int* pScrollRange) const; + result SetScrollPosition(int scrollPosition); + int GetScrollPosition(void) const; + + void EnableFadeEffect(bool enable); + bool IsEnabledFadeEffect(void) const; + bool IsOnFadeEffect(void) const; + void EnableScrollingEffect(bool enable); + bool IsEnabledScrollingEffect(void) const; + void EnableOverScrollingEffect(bool enable); + bool IsEnabledOverScrollingEffect(void) const; + void SetParentUsingViewport(bool useViewPort); + bool IsParentUsingViewport(void) const; + + result SetScrollVisibility(bool visibility); + bool GetScrollVisibility(void) const; + void CancelFadeEffect(void); + + result EnableJumpToTop(bool enable); + bool IsEnabledJumpToTop(void) const; + + result EnableHandler(bool enable); + bool IsEnabledHandler(void) const; + + result SetScrollingEffectVisibility(bool visibility); + + void AddScrollEventListener(const Tizen::Ui::Controls::_IScrollEventListener& listener); + void RemoveScrollEventListener(const Tizen::Ui::Controls::_IScrollEventListener& listener); + + void OnParentBoundsChanged(void); + + void OnDraw(void); + bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + Tizen::Ui::Animations::HitTestResult HitTest(const Tizen::Graphics::FloatPoint& point); + + + virtual Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationForProperty(Tizen::Ui::Animations::VisualElement& target, const Tizen::Base::String& property); + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount); + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + +private: + _ScrollPresenter(const _ScrollPresenter& rhs); + _ScrollPresenter& operator =(const _ScrollPresenter& rhs); + + _ScrollPresenter(void); + result Construct(Tizen::Ui::_Control& parentCtrl, + _Scroll& scrollCtrl, + _ScrollDirection scrollDirection, + bool enableFadeEffect, + bool enableJumpToTop, + bool enableHandler, + bool visibility, + int viewRange, + int scrollRange, + int scrollPosition); + + result LoadResources(_ScrollDirection scrollDirection, _ControlOrientation orientation); + result LoadColorConfig(void); + result LoadBitmapResources(_ScrollDirection scrollDirection); + result LoadShapeConfig(_ScrollDirection scrollDirection, _ControlOrientation orientation); + void ReleaseBitmapResources(void); + + Tizen::Graphics::Rectangle CalculateScrollCtrlBounds(_ScrollDirection scrollDirection); + Tizen::Graphics::Rectangle CalculateThumbBounds(_ScrollDirection scrollDirection); + Tizen::Graphics::Point CalculateThumbPosition(_ScrollDirection scrollDirection); + Tizen::Graphics::Dimension CalculateThumbSize(_ScrollDirection scrollDirection); + Tizen::Graphics::Rectangle CalculateHandlerBounds(_ScrollDirection scrollDirection); + Tizen::Graphics::Point CalculateHandlerPosition(_ScrollDirection scrollDirection); + Tizen::Graphics::Dimension CalculateHandlerSize(_ScrollDirection scrollDirection); + Tizen::Graphics::Rectangle CalculateJumpToTopBounds(_ScrollDirection scrollDirection); + Tizen::Graphics::Rectangle CalculateScrollingEffectFrontBounds(_ScrollDirection scrollDirection); + Tizen::Graphics::Rectangle CalculateScrollingEffectReerBounds(_ScrollDirection scrollDirection); + + result AttachScrollChild(Tizen::Ui::Animations::_VisualElement** ppScrollVe, const Tizen::Graphics::Rectangle& bounds, bool visibility); + void DetachScrollChild(Tizen::Ui::Animations::_VisualElement** ppScrollVe, bool destroy); + Tizen::Graphics::Rectangle GetScrollChildBounds(Tizen::Ui::Animations::_VisualElement& scrollVe) const; + result SetScrollChildBounds(Tizen::Ui::Animations::_VisualElement& scrollVe, const Tizen::Graphics::Rectangle& bounds); + result RelayoutScrollChildren(_ScrollDirection scrollDirection); + result SetParentBouncing(float rate); + + void SetScrollingEffectOpacity(float opacity); + void SetScrollingEffectOpacity(Tizen::Ui::Animations::_VisualElement& Ve, bool isActive, float ratio); + bool IsScrollVisible(void) const; + + void DrawThumb(void); + void DrawJumpToTop(void); + void DrawHandler(void); + void DrawScrollingEffect(void); + result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap); + + bool OnTouchPressedJumpToTop(const _Control& source, const _TouchInfo& touchinfo); + bool OnTouchReleasedJumpToTop(const _Control& source, const _TouchInfo& touchinfo); + bool OnTouchMovedJumpToTop(const _Control& source, const _TouchInfo& touchinfo); + bool OnTouchPressedHandler(const _Control& source, const _TouchInfo& touchinfo); + bool OnTouchReleasedHandler(const _Control& source, const _TouchInfo& touchinfo); + bool OnTouchMovedHandler(const _Control& source, const _TouchInfo& touchinfo); + + void SetParentCtrl(Tizen::Ui::_Control& parentCtrl); + Tizen::Ui::_Control& GetParentCtrl(void) const; + + void SetControl(_Scroll& scrollCtrl); + _Scroll& GetControl(void) const; + +private: + Tizen::Ui::_Control* __pParentCtrl; + _Scroll* __pScrollCtrl; + + // attributes + _ScrollDirection __scrollDirection; + bool __enableFadeEffect; + bool __enableJumpToTop; + bool __enableHandler; + bool __enableScrollingEffect; + bool __enableOverScrollingEffect; + bool __parentUsingViewport; + int __positionMin; + int __positionMax; + int __viewRange; + int __scrollRange; + int __scrollPositionCurr; + + // additional information + int __scrollPositionPrev; + bool __fadeIn; + bool __fadeOut; + bool __scrollVisibility; + bool __scrollingEffectVisibility; + float __parentBouncingRate; + int __fadeEffectDuration_ms; + bool __needUpdateThumb; + bool __needUpdateJumpTopTop; + bool __needUpdateHandler; + bool __needUpdateScrollingEffect; + bool __handlerTouched; + int __handlerTouchedPosition; + bool __jumpToTopPressed; + + _UiScrollEvent* __pScrollEvent; + + Tizen::Ui::Animations::_VisualElement* __pCtrlVe; + Tizen::Ui::Animations::_VisualElement* __pThumbVe; + Tizen::Ui::Animations::_VisualElement* __pJumpToTopVe; + Tizen::Ui::Animations::_VisualElement* __pHandlerVe; + Tizen::Ui::Animations::_VisualElement* __pFrontScrollingEffectVe; + Tizen::Ui::Animations::_VisualElement* __pReerScrollingEffectVe; + + Tizen::Graphics::Color __thumbColor; + Tizen::Graphics::Color __jumpToTopBgColor; + Tizen::Graphics::Color __jumpToTopColor; + Tizen::Graphics::Color __jumpToTopColorPressed; + Tizen::Graphics::Color __buttonColor; + Tizen::Graphics::Color __buttonColorPressed; + + Tizen::Graphics::Bitmap* __pThumbBitmap; + Tizen::Graphics::Bitmap* __pThumbEffectBitmap; + Tizen::Graphics::Bitmap* __pJumpToTopBitmap; + Tizen::Graphics::Bitmap* __pJumpToTopEfBitmap; + Tizen::Graphics::Bitmap* __pJumpToTopLeftBitmap; + Tizen::Graphics::Bitmap* __pJumpToTopLeftEfBitmap; + Tizen::Graphics::Bitmap* __pButtonBitmap; + Tizen::Graphics::Bitmap* __pButtonEfBitmap; + Tizen::Graphics::Bitmap* __pButtonPressBitmap; + Tizen::Graphics::Bitmap* __pHandlerBgBitmap; + Tizen::Graphics::Bitmap* __pHandlerBgEffectBitmap; + Tizen::Graphics::Bitmap* __pHandlerBitmap; + Tizen::Graphics::Bitmap* __pFrontScrollingEffectBitmap; + Tizen::Graphics::Bitmap* __pReerScrollingEffectBitmap; + + Tizen::Graphics::Dimension __thumbSizeMin; + int __thumbMargin; + Tizen::Graphics::Dimension __jumpToTopSize; + int __jumpToTopMarginRight; + int __jumpToTopMarginTop; + Tizen::Graphics::Dimension __handlerSizeMin; + int __handlerMarginLeft; + int __handlerMarginRight; + int __handlerMarginTop; + int __handlerMarginBottom; + int __scrollingEffectWidthLeft; + int __scrollingEffectWidthRight; + int __scrollingEffectHeightTop; + int __scrollingEffectHeightBottom; + Tizen::Base::Collection::HashMap __beforeBouncingMatrixHash; + +}; + +}}} // Tizen::Ui::Controls + +#endif //_FUICTRL_INTERNAL_FASTSCROLL_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_SearchBar.h b/src/ui/inc/FUiCtrl_SearchBar.h new file mode 100644 index 0000000..aeaba4a --- /dev/null +++ b/src/ui/inc/FUiCtrl_SearchBar.h @@ -0,0 +1,1068 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SearchBar.h + * @brief This is the header file for the _SearchBar class. + * + * This header file contains the declarations of the %_SearchBar class. + */ + +#ifndef _FUI_CTRL_INTERNAL_SEARCH_BAR_H_ +#define _FUI_CTRL_INTERNAL_SEARCH_BAR_H_ + +#include +#include "FUi_Control.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_IKeypadEventListener.h" +#include "FUiCtrl_ILanguageEventListener.h" +#include "FUiCtrl_ITextBlockEventListener.h" +#include "FUiCtrl_ITextEventListener.h" +#include "FUiCtrl_ISearchBarEventListener.h" +#include "FUiCtrl_KeypadEvent.h" +#include "FUiCtrl_LanguageEvent.h" +#include "FUiCtrl_SearchBarEvent.h" + +const int SEARCHBAR_COLOR_MAX = 3; +const int SEARCHBAR_BUTTON_COLOR_MAX = 4; +const int SEARCHBAR_TEXT_LENGTH_MAX = 500; +const int SEARCHBAR_DEFAULT_OPACITY = 100; + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _Panel; +class _SearchBarPresenter; +class _ActionEvent; +class _TextBlockEvent; +class _TextEvent; + +/** + * @class _SearchBar + * @brief + * @since 2.0 + */ +class _SearchBar + : public _Control + , public _IActionEventListener + , public _IKeypadEventListener + , public _ITextBlockEventListener + , public _ITextEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer +{ + DECLARE_CLASS_BEGIN(_SearchBar, _Control); + DECLARE_PROPERTY("buttonActionId", GetPropertyButtonActionId, SetPropertyButtonActionId); + DECLARE_PROPERTY("buttonDisabledColor", GetPropertyButtonDisabledColor, SetPropertyButtonDisabledColor); + DECLARE_PROPERTY("buttonHighlightedColor", GetPropertyButtonHighlightedColor, SetPropertyButtonHighlightedColor); + DECLARE_PROPERTY("buttonNormalColor", GetPropertyButtonNormalColor, SetPropertyButtonNormalColor); + DECLARE_PROPERTY("buttonPressedColor", GetPropertyButtonPressedColor, SetPropertyButtonPressedColor); + DECLARE_PROPERTY("buttonDisabledTextColor", GetPropertyButtonDisabledTextColor, SetPropertyButtonDisabledTextColor); + DECLARE_PROPERTY("buttonHighlightedTextColor", GetPropertyButtonHighlightedTextColor, SetPropertyButtonHighlightedTextColor); + DECLARE_PROPERTY("buttonNormalTextColor", GetPropertyButtonNormalTextColor, SetPropertyButtonNormalTextColor); + DECLARE_PROPERTY("buttonPressedTextColor", GetPropertyButtonPressedTextColor, SetPropertyButtonPressedTextColor); + DECLARE_PROPERTY("searchFieldDisabledColor", GetPropertySearchFieldDisabledColor, SetPropertySearchFieldDisabledColor); + DECLARE_PROPERTY("searchFieldHighlightedColor", GetPropertySearchFieldHighlightedColor, SetPropertySearchFieldHighlightedColor); + DECLARE_PROPERTY("searchFieldNormalColor", GetPropertySearchFieldNormalColor, SetPropertySearchFieldNormalColor); + DECLARE_PROPERTY("searchFieldDisabledTextColor", GetPropertySearchFieldDisabledTextColor, SetPropertySearchFieldDisabledTextColor); + DECLARE_PROPERTY("searchFieldHighlightedTextColor", GetPropertySearchFieldHighlightedTextColor, SetPropertySearchFieldHighlightedTextColor); + DECLARE_PROPERTY("searchFieldNormalTextColor", GetPropertySearchFieldNormalTextColor, SetPropertySearchFieldNormalTextColor); + DECLARE_PROPERTY("color", GetPropertyColor, SetPropertyColor); + DECLARE_PROPERTY("contentAreaSize", GetPropertyContentAreaSize, SetPropertyContentAreaSize); + DECLARE_CLASS_END(); + + result SetPropertyButtonActionId(const Tizen::Ui::Variant& actionId); + Tizen::Ui::Variant GetPropertyButtonActionId(void) const; + result SetPropertyButtonDisabledColor(const Tizen::Ui::Variant& color); + Tizen::Ui::Variant GetPropertyButtonDisabledColor(void) const; + result SetPropertyButtonHighlightedColor(const Tizen::Ui::Variant& color); + Tizen::Ui::Variant GetPropertyButtonHighlightedColor(void) const; + result SetPropertyButtonNormalColor(const Tizen::Ui::Variant& color); + Tizen::Ui::Variant GetPropertyButtonNormalColor(void) const; + result SetPropertyButtonPressedColor(const Tizen::Ui::Variant& color); + Tizen::Ui::Variant GetPropertyButtonPressedColor(void) const; + result SetPropertyButtonDisabledTextColor(const Tizen::Ui::Variant& textColor); + Tizen::Ui::Variant GetPropertyButtonDisabledTextColor(void) const; + result SetPropertyButtonHighlightedTextColor(const Tizen::Ui::Variant& textColor); + Tizen::Ui::Variant GetPropertyButtonHighlightedTextColor(void) const; + result SetPropertyButtonNormalTextColor(const Tizen::Ui::Variant& textColor); + Tizen::Ui::Variant GetPropertyButtonNormalTextColor(void) const; + result SetPropertyButtonPressedTextColor(const Tizen::Ui::Variant& textColor); + Tizen::Ui::Variant GetPropertyButtonPressedTextColor(void) const; + result SetPropertySearchFieldDisabledColor(const Tizen::Ui::Variant& color); + Tizen::Ui::Variant GetPropertySearchFieldDisabledColor(void) const; + result SetPropertySearchFieldHighlightedColor(const Tizen::Ui::Variant& color); + Tizen::Ui::Variant GetPropertySearchFieldHighlightedColor(void) const; + result SetPropertySearchFieldNormalColor(const Tizen::Ui::Variant& color); + Tizen::Ui::Variant GetPropertySearchFieldNormalColor(void) const; + result SetPropertySearchFieldDisabledTextColor(const Tizen::Ui::Variant& textColor); + Tizen::Ui::Variant GetPropertySearchFieldDisabledTextColor(void) const; + result SetPropertySearchFieldHighlightedTextColor(const Tizen::Ui::Variant& textColor); + Tizen::Ui::Variant GetPropertySearchFieldHighlightedTextColor(void) const; + result SetPropertySearchFieldNormalTextColor(const Tizen::Ui::Variant& textColor); + Tizen::Ui::Variant GetPropertySearchFieldNormalTextColor(void) const; + result SetPropertyColor(const Tizen::Ui::Variant& color); + Tizen::Ui::Variant GetPropertyColor(void) const; + result SetPropertyContentAreaSize(const Tizen::Ui::Variant& size); + Tizen::Ui::Variant GetPropertyContentAreaSize(void) const; + +public: + /** + * This is default constructor for this class. + * + * @since 2.0 + */ + _SearchBar(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_SearchBar(void); + + static _SearchBar* CreateSearchBarN(void); + + /** + * Initializes this instance of the SearchBar control with the specified parameters. + * + * @since 2.0 + * @return An error code + * @param[in] enableSearchBarButton Set to @c true to display the search bar button, @n + * else @c false + * @param[in] keypadAction The keypad action + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or the action ID of the specified item must be a positive integer. + * @exception E_SYSTEM A system error occurred. + * @remarks By default, a "Cancel" button is displayed if @c enableSearchBarButton is set to @c true. When the user presses the cancel button, + * the SearchBar control returns to SEARCH_BAR_MODE_NORMAL automatically. + */ + result Initialize(bool enableSearchBarButton = true, CoreKeypadAction keypadAction = CORE_KEYPAD_ACTION_SEARCH); + + /** + * Gets the content of %Control. + * + * @since 2.0 + * @return The control that is displayed in the SearchBar's content area in SEARCH_BAR_MODE_INPUT mode, @n + * else @c null if an error occurs + * @exception E_SUCCESS The method was successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Ui::_Control* GetContent(void) const; + + /** + * Sets the content control. + * + * @since 2.0 + * @return An error code + * @param[in] pContent The control that is to be displayed in the + * SearchBar's content area. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The following controls cannot be set as the + * content: @n + * @li All classes derived from Window class + * @li All picker classes (ex: DateTimePicker) + * @li Form + * @li Keypad + * @li OverlayPanel + * @exception E_SYSTEM A system error occurred. + * @remarks The specified content control is displayed when the SearchBar controls mode is changed to SEARCH_BAR_MODE_INPUT. + * @see GetContentAreaSize() + * @see AddSearchBarEventListener() + * @see ISearchBarEventListener + */ + result SetContent(const Tizen::Ui::_Control* pContent); + + /** + * Updates the content area of the SearchBar control. + * + * @since 2.0 + * @return An error code + * @param[in] show A Boolean flag indicating whether to perform show on the content area. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation @n + * -- the current mode of SearchBar prohibits the execution of the method. @n + * @exception E_SYSTEM A system error occurred. + * @remarks The method performs Invalidate() on the content area. + */ + result UpdateContentArea(bool invalidate = true); + + /** + * Sets the visibility state of the content area. + * + * @since 2.0 + * @return An error code + * @param[in] visible The visibility state of the content area. + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see IsContentAreaVisible() + */ + result SetContentAreaVisible(bool visible); + + /** + * Checks whether the content area is visible. + * + * @since 2.0 + * @return The visibility state of the content area. + * @exception E_SUCCESS The method was successful. + * @see SetContentAreaVisible() + */ + bool IsContentAreaVisible(void) const; + + /** + * Sets the size of the content area of the SearchBar control. + * + * @since 2.0 + * @return An error code + * @param[in] size The content area size. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * -- width and height of @c size must be greater than or equal to @c 0. + * @remarks You must resize the content area when the Form's orientation is changed once you change the + + * the size of the content area. + + * @see GetContentAreaSize() + */ + result SetContentAreaSize(const Tizen::Graphics::Dimension& size); + + /** + * Gets the size of the content area of the SearchBar control. + * + * @since 2.0 + * @return The size of the content area + * @remarks The content area is the area where the 'content' of the SearchBar control is displayed. The size of the content areas can + * be changed at runtime. + * @see AddSearchBarEventListener() + * @see ISearchBarEventListener + */ + Tizen::Graphics::Dimension GetContentAreaSize(void) const; + + /** + * Gets the search bar mode. + * + * @since 2.0 + * @return The search bar mode + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetMode() + */ + SearchBarMode GetMode(void) const; + + /** + * Determines whether the search bar mode is locked. + * + * @since 2.0 + * @return @c true if the mode is locked, @n + * else @c false + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetModeLock() + */ + bool IsModeLocked(void) const; + + /** + * Sets the search bar mode. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation, or the mode is locked. + * @exception E_SYSTEM A system error occurred. + * @see GetMode() + * @see SetModeLock() + */ + result SetMode(SearchBarMode mode); + + /** + * Locks or unlocks the search bar mode. + * + * @since 2.0 + * @return An error code + * @param[in] modeLocked The mode lock + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetMode() + */ + result SetModeLocked(bool modeLocked); + + /** + * Gets the search bar button's action Id + * + * @since 2.0 + * @return The action ID, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * By default, the method returns @c -1 if no user defined search bar button is set. + */ + int GetButtonActionId(void) const; + + /** + * Gets the color of the search bar button for the specified state. + * + * @since 2.0 + * @return The color of the search bar button, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The search bar button's status + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetButtonColor() + */ + Tizen::Graphics::Color GetButtonColor(SearchBarButtonStatus status) const; + + /** + * Gets the text color of the search bar button for the specified state. + * + * @since 2.0 + * @return The text color of the search bar button, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The search bar button's status + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetButtonTextColor(SearchBarButtonStatus status) const; + + /** + * Gets the state of the search bar button. + * + * @since 2.0 + * @return The state of the search bar button + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + SearchBarButtonStatus GetButtonStatus(void) const; + + /** + * Sets the user defined search bar button text. + * + * @since 2.0 + * @return An error code + * @param[in] actionId The button action ID + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or the action ID of the specified item must greater than or equal to zero. + * @exception E_SYSTEM A system error occurred. + */ + result SetButtonText(const Tizen::Base::String& text); + + /** + * Sets the user defined search bar button action ID. + * + * @since 2.0 + * @return An error code + * @param[in] actionId The button action ID + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or the action ID of the specified item must greater than or equal to zero. + * @exception E_SYSTEM A system error occurred. + */ + result SetButtonActionId(int actionId); + + /** + * Enables or disables the search bar button. + * + * @since 2.0 + * @return An error code + * @param[in] enabled Set to @c true to enable the search bar button, @n + * else @c false + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + */ + result SetButtonEnabled(bool enabled); + + /** + * Sets the search bar button's color for the specified state. + * + * @since 2.0 + * @return An error code + * @param[in] status The button status + * @param[in] color The button color to set + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetButtonColor() + */ + result SetButtonColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the SearchBar control's button for the specified state. + * + * @since 2.0 + * @return An error code + * @param[in] status The button status + * @param[in] color The button text color to set + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + */ + result SetButtonTextColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color); + + /** + * Appends the specified character at the end of the text. + * + * @since 2.0 + * @return An error code + * @param[in] character The character to add + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The method modifies the text buffer that is managed by the SearchBar control. @n + * To display the changes, the control must be drawn again. + */ + result AppendCharacter(const Tizen::Base::Character& character); + + /** + * Appends the specified text at the end of the existing text. + * + * @since 1.0 + * @return An error code + * @param[in] text The text to append + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks To denote the end of a line use '\\n'. @n + * The method modifies the text buffer that is managed by the SearchBar control. @n + * To display the changes, the control must be drawn again. + */ + result AppendText(const Tizen::Base::String& text); + + /** + * Sets the text to display. + * + * @since 2.0 + * @return An error code + * @param[in] text The text to display + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks To denote the end of a line use '\\n'. @n + * The method modifies the text buffer that is managed by the SearchBar control. @n + * To display the changes, the control must be drawn again. + */ + result SetText(const Tizen::Base::String& text); + + /** + * Inserts the character at the specified index. + * + * @since 2.0 + * @return An error code + * @param[in] index The position to insert the character + * @param[in] character The character to insert + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n + * -- @c index is greater than the number of elements or less than zero. + * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the system limitation. + * @exception E_SYSTEM A system error occurred. + * @remarks The method modifies the text buffer that is managed by the SearchBar control. + * To display the changes, the control must be drawn again. + */ + result InsertCharacterAt(int index, const Tizen::Base::Character& character); + + /** + * Inserts the specified text at the specified index. + * + * @since 2.0 + * @return An error code + * @param[in] index The position at which to insert. + * @param[in] text The text to be inserted + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds + * of the data structure. @n + * -- @c index is greater than the number of elements or less than zero. + * @exception E_MAX_EXCEEDED The length of the specified @c text + * exceeds the system limitation. + * @exception E_SYSTEM A system error occurred. + * @remarks The method modifies the text buffer that is managed by the SearchBar control. + * To display the changes, the control must be drawn again. + */ + result InsertTextAt(int index, const Tizen::Base::String& text); + + /** + * Deletes the character at the specified position. + * + * @since 2.0 + * @return An error code + * @param[in] index The index + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified @c index is negative. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds + * of the data structure. @n + * -- @c index is greater than the number of elements or less than zero. + * @exception E_SYSTEM A system error occurred. + * @remarks The method modifies the text buffer that is managed by the SearchBar control. + * To display the changes, the control must be drawn again. + */ + result DeleteCharacterAt(int index); + + /** + * Clears text that is displayed by the SearchBar control. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The method modifies the text buffer that is managed by the SearchBar control. + * To display the changes, the control must be drawn again. + */ + result Clear(void); + + /** + * Gets the length of the text that is displayed by the SearchBar control. + * + * @since 2.0 + * @return The length of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetTextLength(void) const; + + /** + * Gets the text that is displayed by the SearchBar control. + * + * @since 2.0 + * @return The text of the SearchBar control, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetText() + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets a portion of text that is displayed by the SearchBar control. + * + * @since 2.0 + * @return The specified portion of the text, @n + * else an empty string if an error occurs + * @param[in] start The starting index of range + * @param[in] end The last index of range + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or either the @c start or @c end parameter is greater than the number of elements or less than zero. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetText() + */ + Tizen::Base::String GetText(int start, int end) const; + + /** + * Gets the limit of the length of the text. + * + * @since 2.0 + * @return The limit length, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * The default limit length is @c 500. + * @see SetLimitLength() + */ + int GetLimitLength(void) const; + + /** + * Sets the limit of the length of the text. + * + * @since 2.0 + * @return An error code + * @param[in] limitLength The limit text length to set + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or the specified limit length cannot be negative value or zero. + * @exception E_SYSTEM A system error occurred. + * @see GetLimitLength() + */ + result SetLimitLength(int limitLength); + + /** + * Opens the keypad associated with the SearchBar control. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see HideKeypad() + */ + result ShowKeypad(void) const; + + /** + * Closes the keypad associated with the SearchBar control. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see ShowKeypad() + */ + result HideKeypad(void); + + /** + * Gets the text size of the search field. + * + * @since 2.0 + * @return The size of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetSearchFieldTextSize() + */ + int GetSearchFieldTextSize(void) const; + + /** + * Sets the text size of the SearchBar control's text field. + * + * @since 2.0 + * @return An error code + * @param[in] size The text size + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or the specified @c size cannot be negative value. + * @exception E_SYSTEM A system error occurred. + * @see GetSearchFieldTextSize() + */ + result SetSearchFieldTextSize(int size); + + /** + * Gets the start and the end index of the currently selected text block. + * + * @since 2.0 + * @return An error code + * @param[out] start The start index of the text block + * @param[out] end The end index of the text block + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The method returns @c start = 0 and @c end = 0 if no text block is selected. + * @see ReleaseBlock() + * @see SetBlockRange() + */ + result GetBlockRange(int& start, int& end) const; + + /** + * Releases the selection of the current text block. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetBlockRange() + * @see SetBlockRange() + */ + result ReleaseBlock(void); + + /** + * Selects the specified block of the text. + * + * @since 2.0 + * @return An error code + * @param[in] start The start index of the text block + * @param[in] end The end index of the text block + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or either the @c start or @c end parameter is greater than the number of elements or less than zero. + * @exception E_SYSTEM A system error occurred. + * @see ReleaseBlock() + * @see GetBlockRange() + */ + result SetBlockRange(int start, int end); + + /** + * Removes the text of the selected text block. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + */ + result RemoveTextBlock(void); + + /** + * Gets the color of the SearchBar control for the specified status. + * + * @since 2.0 + * @return The color of the SearchBar control, @n + * else RGBA(0,0,0,0) if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetColor() + */ + Tizen::Graphics::Color GetColor(void) const; + + /** + * Gets the color of the search field for the specified status. + * + * @since 2.0 + * @return The color, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The search field status + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetSearchFieldColor() + */ + Tizen::Graphics::Color GetSearchFieldColor(SearchFieldStatus status) const; + + /** + * Gets the text color of the search field for the specified status. + * + * @since 2.0 + * @return The text color, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The search field status + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetSearchFieldTextColor() + */ + Tizen::Graphics::Color GetSearchFieldTextColor(SearchFieldStatus status) const; + + /** + * Sets the background bitmap of the SearchBar control. + * + * @since 2.0 + * @return An error code + * @param[in] bitmap The background bitmap + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + */ + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the color of the search bar. + * + * @since 2.0 + * @return An error code + * @param[in] status The state of SearchBar + * @param[in] color The color + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetColor() + */ + result SetColor(const Tizen::Graphics::Color& color); + + /** + * Sets the color of the search field for the specified status. + * + * @since 2.0 + * @return An error code + * @param[in] status The state of search field + * @param[in] color The text color + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetSearchFieldColor() + */ + result SetSearchFieldColor(SearchFieldStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the search field for the specified status. + * + * @since 2.0 + * @return An error code + * @param[in] status The state of search field + * @param[in] color The text color + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetSearchFieldTextColor() + */ + result SetSearchFieldTextColor(SearchFieldStatus status, const Tizen::Graphics::Color& color); + + /** + * Gets the guide text. + * + * @since 2.0 + * @return The guide text, @n + * else an empty string if an error occurs + * @param[in] guideText + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see GetGuideText() + */ + Tizen::Base::String GetGuideText(void) const; + + /** + * Displays the specified text when there is no text in the SearchBar control. + * + * @since 2.0 + * @return An error code + * @param[in] guideText The guide text + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetGuideText() + */ + result SetGuideText(const Tizen::Base::String& guideText); + + /** + * Gets the text color of the guide text. + * + * @since 2.0 + * @return The text color of the guide text, @n + * else RGBA(0,0,0,0) if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetGuideTextColor() + */ + Tizen::Graphics::Color GetGuideTextColor(void) const; + + /** + * Sets the text color of the guide text. + * + * @since 2.0 + * @return An error code + * @param[in] color The guide text color + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetGuideTextColor() + */ + result SetGuideTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the current cursor position index. + * + * @since 2.0 + * @return The cursor position, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetCursorPosition() + */ + int GetCursorPosition(void) const; + + /** + * Sets the cursor at the specified index. + * + * @since 2.0 + * @return An error code + * @param[in] index The cursor index + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure, or @c index is greater than the number of elements or less than zero. + * @exception E_SYSTEM A system error occurred. + * @see GetCursorPosition() + */ + result SetCursorPosition(int index); + + /** + * Checks whether the lowercase mode is enabled. + * + * @since 2.0 + * @return @c true if the lowercase mode is enabled, @n + * else @c false + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetLowerCaseModeEnabled() + */ + bool IsLowerCaseModeEnabled(void) const; + + /** + * Enables or disables the lowercase mode. + * + * @since 2.0 + * @param[in] enable Set to @c true to enable lowercase mode, @n + * else @c false + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see IsLowerCaseModeEnabled() + */ + void SetLowerCaseModeEnabled(bool enable); + + /** + * Gets the ellipsis position. + * + * @since 2.0 + * @return The ellipsis position + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetEllipsisPosition() + */ + EllipsisPosition GetEllipsisPosition(void) const; + + /** + * Sets the ellipsis position. + * + * @since 2.0 + * @return An error code + * @param[in] position The ellipsis position + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetEllipsisPosition() + */ + result SetEllipsisPosition(EllipsisPosition position); + + /** + * Gets the keypad action type. + * + * @since 2.0 + * @return The keypad action + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + CoreKeypadAction GetKeypadAction(void) const; + + /** + * Checks whether the text prediction is enabled. + * + * @since 2.0 + * @return @c true if the text prediction is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextPredictionEnabled() + */ + bool IsTextPredictionEnabled(void) const; + + /** + * Enables or disables the text prediction. + * + * @since 2.0 + * @param[in] enable Set to @c true to enable the text prediction, @n + * else @c false + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see IsTextPredictionEnabled() + */ + result SetTextPredictionEnabled(bool enable); + + result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const; + result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode); + + result AddActionEventListener(const _IActionEventListener& listener); + result RemoveActionEventListener(const _IActionEventListener& listener); + result AddKeypadEventListener(const _IKeypadEventListener& listener); + result RemoveKeypadEventListener(const _IKeypadEventListener& listener); + result AddTextBlockEventListener(const _ITextBlockEventListener& listener); + result RemoveTextBlockEventListener(const _ITextBlockEventListener& listener); + result AddTextEventListener(const _ITextEventListener& listener); + result RemoveTextEventListener(const _ITextEventListener& listener); + result AddSearchBarEventListener(const _ISearchBarEventListener& listener); + result RemoveSearchBarEventListener(const _ISearchBarEventListener& listener); + result AddLanguageEventListener(const _ILanguageEventListener& listener); + result RemoveLanguageEventListener(const _ILanguageEventListener& listener); + + void SetContentsArea(void); + + Tizen::Graphics::Bitmap* GetBackgroundBitmap(void) const; + bool IsUsableCancelButton(void) const; + + _Button* GetSearchBarButton(void) const; + _Edit* GetSearchField(void); + _Control* GetSearchBarContainer(void) const; + _Control* GetClippedGroupControl(void) const; + + result SendSearchBarEvent(_SearchBarEventStatus status); + void SetHeaderVisibleState(bool visible); + void SetContentDimming(void); + bool IsContentAttachable(const _Control* pContent); + result ResizeCancelButton(void); + + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + + virtual void OnKeypadWillOpen(void); + virtual void OnKeypadOpened(void); + virtual void OnKeypadClosed(void); + virtual void OnKeypadBoundsChanged(void); + virtual void OnKeypadActionPerformed(CoreKeypadAction keypadAction); + + virtual void OnTextBlockSelected(Tizen::Ui::_Control& source, int start, int end); + + virtual void OnTextValueChanged(const Tizen::Ui::_Control& source); + virtual void OnTextValueChangeCanceled(const Tizen::Ui::_Control& source); + + virtual void OnBoundsChanged(void); + virtual result OnAttachedToMainTree(void); + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + virtual bool OnFocusGained(const _Control& source); + virtual bool OnFocusLost(const _Control& source); + +protected: + virtual void OnDraw(void); + +private: + _SearchBar(const _SearchBar&); + _SearchBar& operator =(const _SearchBar&); + + _ButtonStatus ConvertSearchBarButtonStatus(SearchBarButtonStatus status); + EditStatus ConvertSearchBarStatus(SearchFieldStatus status); + + result CreateSearchField(void); + result CreateCancelButton(void); + result CreateFrontButton(void); + result CreateContentsArea(void); + result CreateClippedGroupControl(void); + //Tizen::Graphics::Font* CreateEditFontN(const Tizen::Graphics::Font* pFont); + + Tizen::Ui::_Control* GetParentForm(void) const; + + _SearchBarPresenter* __pSearchBarPresenter; + + _Control* __pClippedGroupControl; + _Edit* __pEdit; + _Button* __pCancelButton; + _Control* __pContainer; + _Control* __pContentControl; + + int __actionId; + int __searchBarStyle; + + bool __isButtonEnabled; + bool __isUsableCancelButton; + bool __isUserContainerBounds; + bool __isCancelActionInProgress; + + CoreKeypadAction __keypadAction; + + Tizen::Graphics::Bitmap* __pBackgroundBitmap; + Tizen::Graphics::Color __backgroundColor; + Tizen::Graphics::Color __contentColor; + + Tizen::Graphics::Color __color[SEARCHBAR_COLOR_MAX]; + Tizen::Graphics::Color __textColor[SEARCHBAR_COLOR_MAX]; + Tizen::Graphics::Color __buttonColor[SEARCHBAR_BUTTON_COLOR_MAX]; + Tizen::Graphics::Color __buttonTextColor[SEARCHBAR_BUTTON_COLOR_MAX]; + + Tizen::Graphics::Rectangle __contentAreaBounds; + + _ActionEvent* __pActionEvent; + _KeypadEvent* __pKeypadEvent; + _TextBlockEvent* __pTextBlockEvent; + _TextEvent* __pTextEvent; + _SearchBarEvent* __pSearchBarEvent; + _LanguageEvent* __pLanguageEvent; + static const byte _SEARCH_CONTENT_DIM_OPACITY = 128; //50% opacity + +}; // _SearchBar + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SEARCH_BAR_H_ diff --git a/src/ui/inc/FUiCtrl_SearchBarEvent.h b/src/ui/inc/FUiCtrl_SearchBarEvent.h new file mode 100644 index 0000000..46785aa --- /dev/null +++ b/src/ui/inc/FUiCtrl_SearchBarEvent.h @@ -0,0 +1,113 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SearchBarEvent.h + * @brief This is the header file for _SearchBarEvent class. + * @version 1.0 + * + * This header file contains declaration of _SearchBarEvent class. + * The SearchBarEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_INTERNAL_SEARCH_BAR_EVENT_H_ +#define _FUI_CTRL_INTERNAL_SEARCH_BAR_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _SearchBar; + +enum _SearchBarEventStatus +{ + _SEARCH_BAR_EVENT_MODE_CHANGE = 0, + _SEARCH_BAR_EVENT_CONTENT_AREA_RESIZE +}; + +/** +* @class _SearchBarEvent +* @brief This class handles a action event. It is inherited from Event class. +* +* The Window(root of all widgets) class has an instance of the _SearchBarEvent class as a member variable. +* Applications can register searchbar event listeners through it. When a searchbar event occurred, +* the _SearchBarEvent class finds listener and calls the appropriate listener's method. +* +*/ +class _SearchBarEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_SearchBarEvent(void); + + static _SearchBarEvent* CreateInstanceN(const _SearchBar& source); + +// Accessors + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const _SearchBar* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateSearchBarEventArgN(_SearchBarEventStatus status); + +// Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _SearchBarEvent(const _SearchBar& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this action event. + * @param[in] arg It is an argument-like instance of action event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IActionEventListener class or + * the p__SearchBarEventArg is not the instance of _SearchBarEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attributess +private: + const _SearchBar* __pSource; + +}; // _SearchBarEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SEARCH_BAR_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_SearchBarImpl.h b/src/ui/inc/FUiCtrl_SearchBarImpl.h new file mode 100644 index 0000000..bf5e0e0 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SearchBarImpl.h @@ -0,0 +1,1019 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SearchBarImpl.h + * @brief This is the header file for the _SearchBarImpl class. + * + * This header file contains the declarations of the %_SearchBarImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_SEARCH_BAR_IMPL_H_ +#define _FUI_CTRL_INTERNAL_SEARCH_BAR_IMPL_H_ + +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_IKeypadEventListener.h" +#include "FUiCtrl_ILanguageEventListener.h" +#include "FUiCtrl_ITextBlockEventListener.h" +#include "FUiCtrl_ITextEventListener.h" +#include "FUiCtrl_ISearchBarEventListener.h" +#include "FUiCtrl_PublicKeypadEvent.h" +#include "FUiCtrl_PublicLanguageEvent.h" +#include "FUiCtrl_PublicSearchBarEvent.h" +#include "FUiCtrl_SearchBar.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ +class _PublicActionEvent; +class _PublicTextEvent; +class _PublicTextBlockEvent; + +class _SearchBarImpl + : public _ControlImpl + , public _IActionEventListener + , public _IKeypadEventListener + , public _ILanguageEventListener + , public _ITextBlockEventListener + , public _ITextEventListener + , public _ISearchBarEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + static _SearchBarImpl* CreateSearchBarImplN(SearchBar* pCore, const Tizen::Graphics::Rectangle& bounds, bool enableSearchBarButton = true, KeypadAction keypadAction = KEYPAD_ACTION_SEARCH); + + /** + * This is default constructor for this class. + * + * @since 2.0 + */ + _SearchBarImpl(SearchBar* pPublic, _SearchBar* pCore); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_SearchBarImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const SearchBar& GetPublic(void) const; + virtual SearchBar& GetPublic(void); + virtual const _SearchBar& GetCore(void) const; + virtual _SearchBar& GetCore(void); + + /** + * Gets the content of %Control. + * + * @since 2.0 + * @return The control that is displayed in the SearchBar's content area in SEARCH_BAR_MODE_INPUT mode, @n + * else @c null if an error occurs + * @exception E_SUCCESS The method was successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Ui::Control* GetContent(void) const; + + /** + * Sets the content control. + * + * @since 2.0 + * @return An error code + * @param[in] pContent The control that is to be displayed in the + * SearchBar's content area. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * The following controls cannot be set as the + * content: @n + * @li All classes derived from Window class + * @li All picker classes (ex: DateTimePicker) + * @li Form + * @li Keypad + * @li OverlayPanel + * @exception E_SYSTEM A system error occurred. + * @remarks The specified content control is displayed when the SearchBar controls mode is changed to SEARCH_BAR_MODE_INPUT. + * @see GetContentAreaSize() + * @see AddSearchBarEventListener() + * @see ISearchBarEventListener + */ + result SetContent(const Tizen::Ui::Control* pContent); + + /** + * Updates the content area of the SearchBar control. + * + * @since 2.0 + * @return An error code + * @param[in] show A Boolean flag indicating whether to perform show on the content area. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation @n + * -- the current mode of SearchBar prohibits the execution of the method. @n + * @exception E_SYSTEM A system error occurred. + * @remarks The method performs Invalidate() on the content area. + */ + result UpdateContentArea(bool invalidate = true); + + /** + * Sets the visibility state of the content area. + * + * @since 2.0 + * @return An error code + * @param[in] visible The visibility state of the content area. + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see IsContentAreaVisible() + */ + result SetContentAreaVisible(bool visible); + + /** + * Checks whether the content area is visible. + * + * @since 2.0 + * @return The visibility state of the content area. + * @exception E_SUCCESS The method was successful. + * @see SetContentAreaVisible() + */ + bool IsContentAreaVisible(void) const; + + /** + * Sets the size of the content area of the SearchBar control. + * + * @since 2.0 + * @return An error code + * @param[in] size The content area size. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. @n + * -- width and height of @c size must be greater than or equal to @c 0. + * @remarks You must resize the content area when the Form's orientation is changed once you change the + + * the size of the content area. + + * @see GetContentAreaSize() + */ + result SetContentAreaSize(const Tizen::Graphics::Dimension& size); + + /** + * Gets the size of the content area of the SearchBar control. + * + * @since 2.0 + * @return The size of the content area + * @remarks The content area is the area where the 'content' of the SearchBar control is displayed. The size of the content areas can + * be changed at runtime. + * @see AddSearchBarEventListener() + * @see ISearchBarEventListener + */ + Tizen::Graphics::Dimension GetContentAreaSize(void) const; + + /** + * Gets the search bar mode. + * + * @since 2.0 + * @return The search bar mode + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetMode() + */ + SearchBarMode GetMode(void) const; + + /** + * Determines whether the search bar mode is locked. + * + * @since 2.0 + * @return @c true if the mode is locked, @n + * else @c false + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetModeLock() + */ + bool IsModeLocked(void) const; + + /** + * Sets the search bar mode. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation, or the mode is locked. + * @exception E_SYSTEM A system error occurred. + * @see GetMode() + * @see SetModeLock() + */ + result SetMode(SearchBarMode mode); + + /** + * Locks or unlocks the search bar mode. + * + * @since 2.0 + * @return An error code + * @param[in] modeLocked The mode lock + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetMode() + */ + result SetModeLocked(bool modeLocked); + + /** + * Gets the search bar button's action Id + * + * @since 2.0 + * @return The action ID, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * By default, the method returns @c -1 if no user defined search bar button is set. + */ + int GetButtonActionId(void) const; + + /** + * Gets the color of the search bar button for the specified state. + * + * @since 2.0 + * @return The color of the search bar button, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The search bar button's status + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetButtonColor() + */ + Tizen::Graphics::Color GetButtonColor(SearchBarButtonStatus status) const; + + /** + * Gets the text color of the search bar button for the specified state. + * + * @since 2.0 + * @return The text color of the search bar button, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The search bar button's status + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Graphics::Color GetButtonTextColor(SearchBarButtonStatus status) const; + + /** + * Gets the state of the search bar button. + * + * @since 2.0 + * @return The state of the search bar button + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + SearchBarButtonStatus GetButtonStatus(void) const; + + /** + * Sets the user defined search bar button. + * + * @since 2.0 + * @return An error code + * @param[in] text The button text + * @param[in] actionId The button action ID + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or the action ID of the specified item must greater than or equal to zero. + * @exception E_SYSTEM A system error occurred. + */ + result SetButton(const Tizen::Base::String& text, int actionId); + + /** + * Enables or disables the search bar button. + * + * @since 2.0 + * @return An error code + * @param[in] enabled Set to @c true to enable the search bar button, @n + * else @c false + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + */ + result SetButtonEnabled(bool enabled); + + /** + * Sets the search bar button's color for the specified state. + * + * @since 2.0 + * @return An error code + * @param[in] status The button status + * @param[in] color The button color to set + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetButtonColor() + */ + result SetButtonColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the SearchBar control's button for the specified state. + * + * @since 2.0 + * @return An error code + * @param[in] status The button status + * @param[in] color The button text color to set + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + */ + result SetButtonTextColor(SearchBarButtonStatus status, const Tizen::Graphics::Color& color); + + /** + * Appends the specified character at the end of the text. + * + * @since 2.0 + * @return An error code + * @param[in] character The character to add + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The method modifies the text buffer that is managed by the SearchBar control. @n + * To display the changes, the control must be drawn again. + */ + result AppendCharacter(const Tizen::Base::Character& character); + + /** + * Appends the specified text at the end of the existing text. + * + * @since 1.0 + * @return An error code + * @param[in] text The text to append + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks To denote the end of a line use '\\n'. @n + * The method modifies the text buffer that is managed by the SearchBar control. @n + * To display the changes, the control must be drawn again. + */ + result AppendText(const Tizen::Base::String& text); + + /** + * Sets the text to display. + * + * @since 2.0 + * @return An error code + * @param[in] text The text to display + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks To denote the end of a line use '\\n'. @n + * The method modifies the text buffer that is managed by the SearchBar control. @n + * To display the changes, the control must be drawn again. + */ + result SetText(const Tizen::Base::String& text); + + /** + * Inserts the character at the specified index. + * + * @since 2.0 + * @return An error code + * @param[in] index The position to insert the character + * @param[in] character The character to insert + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure. @n + * -- @c index is greater than the number of elements or less than zero. + * @exception E_MAX_EXCEEDED The length of the specified @c text exceeds the system limitation. + * @exception E_SYSTEM A system error occurred. + * @remarks The method modifies the text buffer that is managed by the SearchBar control. + * To display the changes, the control must be drawn again. + */ + result InsertCharacterAt(int index, const Tizen::Base::Character& character); + + /** + * Inserts the specified text at the specified index. + * + * @since 2.0 + * @return An error code + * @param[in] index The position at which to insert. + * @param[in] text The text to be inserted + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds + * of the data structure. @n + * -- @c index is greater than the number of elements or less than zero. + * @exception E_MAX_EXCEEDED The length of the specified @c text + * exceeds the system limitation. + * @exception E_SYSTEM A system error occurred. + * @remarks The method modifies the text buffer that is managed by the SearchBar control. + * To display the changes, the control must be drawn again. + */ + result InsertTextAt(int index, const Tizen::Base::String& text); + + /** + * Deletes the character at the specified position. + * + * @since 2.0 + * @return An error code + * @param[in] index The index + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified @c index is negative. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds + * of the data structure. @n + * -- @c index is greater than the number of elements or less than zero. + * @exception E_SYSTEM A system error occurred. + * @remarks The method modifies the text buffer that is managed by the SearchBar control. + * To display the changes, the control must be drawn again. + */ + result DeleteCharacterAt(int index); + + /** + * Clears text that is displayed by the SearchBar control. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The method modifies the text buffer that is managed by the SearchBar control. + * To display the changes, the control must be drawn again. + */ + result Clear(void); + + /** + * Gets the length of the text that is displayed by the SearchBar control. + * + * @since 2.0 + * @return The length of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetTextLength(void) const; + + /** + * Gets the text that is displayed by the SearchBar control. + * + * @since 2.0 + * @return The text of the SearchBar control, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetText() + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets a portion of text that is displayed by the SearchBar control. + * + * @since 2.0 + * @return The specified portion of the text, @n + * else an empty string if an error occurs + * @param[in] start The starting index of range + * @param[in] end The last index of range + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or either the @c start or @c end parameter is greater than the number of elements or less than zero. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetText() + */ + Tizen::Base::String GetText(int start, int end) const; + + /** + * Gets the limit of the length of the text. + * + * @since 2.0 + * @return The limit length, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. @n + * The default limit length is @c 500. + * @see SetLimitLength() + */ + int GetLimitLength(void) const; + + /** + * Sets the limit of the length of the text. + * + * @since 2.0 + * @return An error code + * @param[in] limitLength The limit text length to set + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or the specified limit length cannot be negative value or zero. + * @exception E_SYSTEM A system error occurred. + * @see GetLimitLength() + */ + result SetLimitLength(int limitLength); + + /** + * Opens the keypad associated with the SearchBar control. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see HideKeypad() + */ + result ShowKeypad(void) const; + + /** + * Closes the keypad associated with the SearchBar control. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see ShowKeypad() + */ + result HideKeypad(void) const; + + /** + * Gets the text size of the search field. + * + * @since 2.0 + * @return The size of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetSearchFieldTextSize() + */ + int GetSearchFieldTextSize(void) const; + + /** + * Sets the text size of the SearchBar control's text field. + * + * @since 2.0 + * @return An error code + * @param[in] size The text size + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or the specified @c size cannot be negative value. + * @exception E_SYSTEM A system error occurred. + * @see GetSearchFieldTextSize() + */ + result SetSearchFieldTextSize(int size); + + /** + * Gets the start and the end index of the currently selected text block. + * + * @since 2.0 + * @return An error code + * @param[out] start The start index of the text block + * @param[out] end The end index of the text block + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The method returns @c start = 0 and @c end = 0 if no text block is selected. + * @see ReleaseBlock() + * @see SetBlockRange() + */ + result GetBlockRange(int& start, int& end) const; + + /** + * Releases the selection of the current text block. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetBlockRange() + * @see SetBlockRange() + */ + result ReleaseBlock(void); + + /** + * Selects the specified block of the text. + * + * @since 2.0 + * @return An error code + * @param[in] start The start index of the text block + * @param[in] end The end index of the text block + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or either the @c start or @c end parameter is greater than the number of elements or less than zero. + * @exception E_SYSTEM A system error occurred. + * @see ReleaseBlock() + * @see GetBlockRange() + */ + result SetBlockRange(int start, int end); + + /** + * Removes the text of the selected text block. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + */ + result RemoveTextBlock(void); + + /** + * Gets the color of the SearchBar control for the specified status. + * + * @since 2.0 + * @return The color of the SearchBar control, @n + * else RGBA(0,0,0,0) if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetColor() + */ + Tizen::Graphics::Color GetColor(void) const; + + /** + * Gets the color of the search field for the specified status. + * + * @since 2.0 + * @return The color, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The search field status + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetSearchFieldColor() + */ + Tizen::Graphics::Color GetSearchFieldColor(SearchFieldStatus status) const; + + /** + * Gets the text color of the search field for the specified status. + * + * @since 2.0 + * @return The text color, @n + * else RGBA(0,0,0,0) if an error occurs + * @param[in] status The search field status + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetSearchFieldTextColor() + */ + Tizen::Graphics::Color GetSearchFieldTextColor(SearchFieldStatus status) const; + + /** + * Sets the background bitmap of the SearchBar control. + * + * @since 2.0 + * @return An error code + * @param[in] bitmap The background bitmap + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + */ + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the color of the search bar. + * + * @since 2.0 + * @return An error code + * @param[in] status The state of SearchBar + * @param[in] color The color + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetColor() + */ + result SetColor(const Tizen::Graphics::Color& color); + + /** + * Sets the color of the search field for the specified status. + * + * @since 2.0 + * @return An error code + * @param[in] status The state of search field + * @param[in] color The text color + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetSearchFieldColor() + */ + result SetSearchFieldColor(SearchFieldStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the search field for the specified status. + * + * @since 2.0 + * @return An error code + * @param[in] status The state of search field + * @param[in] color The text color + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetSearchFieldTextColor() + */ + result SetSearchFieldTextColor(SearchFieldStatus status, const Tizen::Graphics::Color& color); + + /** + * Gets the guide text. + * + * @since 2.0 + * @return The guide text, @n + * else an empty string if an error occurs + * @param[in] guideText + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see GetGuideText() + */ + Tizen::Base::String GetGuideText(void) const; + + /** + * Displays the specified text when there is no text in the SearchBar control. + * + * @since 2.0 + * @return An error code + * @param[in] guideText The guide text + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetGuideText() + */ + result SetGuideText(const Tizen::Base::String& guideText); + + /** + * Gets the text color of the guide text. + * + * @since 2.0 + * @return The text color of the guide text, @n + * else RGBA(0,0,0,0) if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetGuideTextColor() + */ + Tizen::Graphics::Color GetGuideTextColor(void) const; + + /** + * Sets the text color of the guide text. + * + * @since 2.0 + * @return An error code + * @param[in] color The guide text color + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetGuideTextColor() + */ + result SetGuideTextColor(const Tizen::Graphics::Color& color); + + /** + * Gets the current cursor position index. + * + * @since 2.0 + * @return The cursor position, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetCursorPosition() + */ + int GetCursorPosition(void) const; + + /** + * Sets the cursor at the specified index. + * + * @since 2.0 + * @return An error code + * @param[in] index The cursor index + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure, or @c index is greater than the number of elements or less than zero. + * @exception E_SYSTEM A system error occurred. + * @see GetCursorPosition() + */ + result SetCursorPosition(int index); + + /** + * Checks whether the lowercase mode is enabled. + * + * @since 2.0 + * @return @c true if the lowercase mode is enabled, @n + * else @c false + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetLowerCaseModeEnabled() + */ + bool IsLowerCaseModeEnabled(void) const; + + /** + * Enables or disables the lowercase mode. + * + * @since 2.0 + * @param[in] enable Set to @c true to enable lowercase mode, @n + * else @c false + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see IsLowerCaseModeEnabled() + */ + void SetLowerCaseModeEnabled(bool enable); + + /** + * Gets the ellipsis position. + * + * @since 2.0 + * @return The ellipsis position + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetEllipsisPosition() + */ + EllipsisPosition GetEllipsisPosition(void) const; + + /** + * Sets the ellipsis position. + * + * @since 2.0 + * @return An error code + * @param[in] position The ellipsis position + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetEllipsisPosition() + */ + result SetEllipsisPosition(EllipsisPosition position); + + /** + * Gets the keypad action type. + * + * @since 2.0 + * @return The keypad action + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + KeypadAction GetKeypadAction(void) const; + + /** + * Checks whether the text prediction is enabled. + * + * @since 2.0 + * @return @c true if the text prediction is enabled, @n + * else @c false + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextPredictionEnabled() + */ + bool IsTextPredictionEnabled(void) const; + + /** + * Enables or disables the text prediction. + * + * @since 2.0 + * @param[in] enable Set to @c true to enable the text prediction, @n + * else @c false + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @see IsTextPredictionEnabled() + */ + result SetTextPredictionEnabled(bool enable); + + result GetCurrentLanguage(Tizen::Locales::LanguageCode& language) const; + result SetCurrentLanguage(Tizen::Locales::LanguageCode languageCode); + + /** + * Adds an action event listener. @n + * The added listener is notified when the user clicks the search bar button. + * + * @since 2.0 + * @param[in] listener The event listener to add + * @see RemoveActionEventListener() + */ + result AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * Removes the specified action event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * @param[in] listener The event listener to remove + * @see AddActionEventListener() + */ + result RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + /** + * Adds a text event listener. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * @param[in] listener The event listener to add + * @remarks The added listener is notified when: @n + * @li the user presses a key on the software keypad. + * @li the user selects a word in the candidate list. + * @li the user pastes a text. + * @see RemoveTextEventListener() + */ + result AddTextEventListener(Tizen::Ui::ITextEventListener& listener); + + /** + * Removes the specified text event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * @param[in] listener The event listener to remove + * @see AddTextEventListener() + */ + result RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener); + + /** + * Adds a search bar event listener. @n + * The added listener can listen to events on the specified event dispatcher's context when they are fired. + * + * @since 2.0 + * @param[in] listener The event listener to add + * @remarks The added listener is notified when: @n + * @li the user presses a key on the software keypad. + * @li the user selects a word in the candidate list. + * @li the user pastes a text. + * @see AddSearchBarEventListener() + */ + result AddSearchBarEventListener(const ISearchBarEventListener& listener); + + /** + * Removes the specified search bar event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * @param[in] listener The event listener to remove + * @see RemoveTextEventListener() + */ + result RemoveSearchBarEventListener(const ISearchBarEventListener& listener); + + /** + * Adds a text block event listener. + * + * @since 2.0 + * @param[in] listener The event listener to add + * @remarks Programmatically, modification of the text selection does not cause + * the text block selection event to fire. + * @see RemoveTextBlockEventListener() + */ + result AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + /** + * Removes the specified text block event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * @param[in] listener The event listener to remove + * @see AddTextBlockEventListener() + */ + result RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + /** + * Adds a keypad event listener. @n + * The added listener is notified when the keypad associated with this text + * editor is opened or closed. + * + * @since 2.0 + * @param[in] listener The event listener to add + * @see RemoveKeypadEventListener() + */ + result AddKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + + /** + * Removes the specified keypad event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * @param[in] listener The event listener to remove + * @see AddKeypadEventListener() + */ + result RemoveKeypadEventListener(Tizen::Ui::IKeypadEventListener& listener); + + result AddLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + result RemoveLanguageEventListener(Tizen::Ui::ILanguageEventListener& listener); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + + virtual void OnKeypadWillOpen(void); + virtual void OnKeypadOpened(void); + virtual void OnKeypadClosed(void); + virtual void OnKeypadBoundsChanged(void); + virtual void OnKeypadActionPerformed(CoreKeypadAction keypadAction); + + virtual void OnTextBlockSelected(Tizen::Ui::_Control& source, int start, int end); + + virtual void OnTextValueChanged(const Tizen::Ui::_Control& source); + virtual void OnTextValueChangeCanceled(const Tizen::Ui::_Control& source); + + virtual void OnSearchBarModeChanged(_SearchBar& source, SearchBarMode mode); + + virtual void OnLanguageChanged(Tizen::Locales::LanguageCode oldLanguage, Tizen::Locales::LanguageCode newLanguage); + + static _SearchBarImpl* GetInstance(SearchBar& searchBar); + static const _SearchBarImpl* GetInstance(const SearchBar& searchBar); + +private: + _SearchBarImpl(const _SearchBarImpl&); + _SearchBarImpl& operator =(const _SearchBarImpl&); + + result Initialize(bool enableSearchBarButton, KeypadAction keypadAction); + KeypadAction ConvertKeypadAction(CoreKeypadAction keypadAction) const; + CoreKeypadAction ConvertKeypadAction(KeypadAction keypadAction) const; + + _SearchBar* __pSearchBar; + + Control* __pContentControl; + + _PublicActionEvent* __pPublicActionEvent; + _PublicKeypadEvent* __pPublicKeypadEvent; + _PublicTextBlockEvent* __pPublicTextBlockEvent; + _PublicTextEvent* __pPublicTextEvent; + _PublicSearchBarEvent* __pPublicSearchBarEvent; + _PublicLanguageEvent* __pPublicLanguageEvent; + +}; // _SearchBarImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SEARCH_BAR_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_SearchBarModel.h b/src/ui/inc/FUiCtrl_SearchBarModel.h new file mode 100644 index 0000000..dddbbc7 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SearchBarModel.h @@ -0,0 +1,147 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SearchBarModel.h + * @brief This is the header file for the _SearchBarModel class. + * + * This header file contains the declarations of the %_SearchBarModel class. + */ + +#ifndef _FUI_CTRL_INTERNAL_SEARCH_BAR_MODEL_H_ +#define _FUI_CTRL_INTERNAL_SEARCH_BAR_MODEL_H_ + +#include +#include "FUiCtrl_SearchBarPresenter.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _SearchBarModel + * @brief + * @since 2.0 + */ +class _SearchBarModel + : public Tizen::Base::Object +{ +// Lifecycle +public: + /** + * This is default constructor for this class. + * + * @since 2.0 + */ + _SearchBarModel(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_SearchBarModel(void); + +// Operations + virtual result Construct(void); + + /** + * Sets the visibility state of the content area. + * + * @since 2.0 + * @return An error code + * @param[in] visible The visibility state of the content area. + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see IsContentAreaVisible() + */ + result SetContentAreaVisible(bool visible); + + /** + * Checks whether the content area is visible. + * + * @since 2.0 + * @return The visibility state of the content area. + * @exception E_SUCCESS The method was successful. + * @see SetContentAreaVisible() + */ + bool IsContentAreaVisible(void) const; + + /** + * Gets the search bar mode. + * + * @since 2.0 + * @return The search bar mode + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetMode() + */ + SearchBarMode GetMode(void) const; + + /** + * Determines whether the search bar mode is locked. + * + * @since 2.0 + * @return @c true if the mode is locked, @n + * else @c false + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetModeLock() + */ + bool IsModeLocked(void) const; + + /** + * Sets the search bar mode. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation, or the mode is locked. + * @exception E_SYSTEM A system error occurred. + * @see GetMode() + * @see SetModeLock() + */ + result SetMode(SearchBarMode mode); + + /** + * Locks or unlocks the search bar mode. + * + * @since 2.0 + * @return An error code + * @param[in] modeLocked The mode lock + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetMode() + */ + result SetModeLocked(bool modeLocked); + + +private: + _SearchBarModel(const _SearchBarModel& value); + + _SearchBarModel& operator =(const _SearchBarModel& value); + +// Attributes + bool __isContentAreaVisible; + bool __isModeLocked; + SearchBarMode __searchBarMode; + +}; // _SearchBarModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SEARCH_BAR_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_SearchBarPresenter.h b/src/ui/inc/FUiCtrl_SearchBarPresenter.h new file mode 100644 index 0000000..950479b --- /dev/null +++ b/src/ui/inc/FUiCtrl_SearchBarPresenter.h @@ -0,0 +1,202 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SearchBarPresenter.h + * @brief This is the header file for the _SearchBarPresenter class. + * + * This header file contains the declarations of the %_SearchBarPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_SEARCH_BAR_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_SEARCH_BAR_PRESENTER_H_ + +#include +#include "FUiCtrl_SearchBar.h" + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _SearchBar; +class _SearchBarModel; + +/** + * @class _SearchBarPresenter + * @brief + * @since 2.0 + */ +class _SearchBarPresenter + : public Tizen::Base::Object +{ +public: + /** + * This is default constructor for this class. + * + * @since 2.0 + */ + _SearchBarPresenter(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_SearchBarPresenter(void); + +// Operations + result Construct(const _SearchBar& searchBar); + result Install(void); + + /** + * Updates the content area of the SearchBar control. + * + * @since 2.0 + * @return An error code + * @param[in] show A Boolean flag indicating whether to perform show on the content area. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation @n + * -- the current mode of SearchBar prohibits the execution of the method. @n + * @exception E_SYSTEM A system error occurred. + * @remarks The method performs Invalidate() on the content area. + */ + result UpdateContentArea(bool invalidate = true); + + /** + * Sets the visibility state of the content area. + * + * @since 2.0 + * @return An error code + * @param[in] visible The visibility state of the content area. + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see IsContentAreaVisible() + */ + result SetContentAreaVisible(bool visible); + + /** + * Checks whether the content area is visible. + * + * @since 2.0 + * @return The visibility state of the content area. + * @exception E_SUCCESS The method was successful. + * @see SetContentAreaVisible() + */ + bool IsContentAreaVisible(void) const; + + /** + * Gets the search bar mode. + * + * @since 2.0 + * @return The search bar mode + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetMode() + */ + SearchBarMode GetMode(void) const; + + /** + * Determines whether the search bar mode is locked. + * + * @since 2.0 + * @return @c true if the mode is locked, @n + * else @c false + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetModeLock() + */ + bool IsModeLocked(void) const; + + /** + * Sets the search bar mode. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation, or the mode is locked. + * @exception E_SYSTEM A system error occurred. + * @see GetMode() + * @see SetModeLock() + */ + result SetMode(SearchBarMode mode); + + /** + * Locks or unlocks the search bar mode. + * + * @since 2.0 + * @return An error code + * @param[in] modeLocked The mode lock + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetMode() + */ + result SetModeLocked(bool modeLocked); + + /** + * Sets the visibility state of the header. + * + * @since 2.0 + * @param[in] visible The visibility state of the the header. + */ + void SetHeaderVisibleState(bool visible); + + result Draw(void); + + // callback + void OnBoundsChanged(void); + +private: + _SearchBarPresenter(const _SearchBarPresenter&); + + _SearchBarPresenter& operator =(const _SearchBarPresenter&); + + void SetCancelButtonVisible(bool visible); + void SetContainerVisible(bool visible); + result DrawIcon(void); + + result ChangeMode(SearchBarMode mode); + void InitializeInputModeLayout(void); + void InitializeViewModeLayout(void); + result LoadSearchFieldIcon(void); + + _SearchBar* __pSearchBar; + _SearchBarModel* __pSearchBarModel; + + _Button* __pCancelButton; + _Edit* __pEdit; + _Control* __pContainer; + + Tizen::Graphics::Rectangle __searchFieldBounds; + + Tizen::Ui::Animations::_VisualElement* __pIconElement; + + Tizen::Graphics::Bitmap* __pReplacedSearchFieldNormalBitmap; + Tizen::Graphics::Bitmap* __pReplacedSearchFieldDisabledBitmap; + Tizen::Graphics::Bitmap* __pSearchFieldEffectBitmap; + + +}; // _SearchBarPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SEARCH_BAR_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_SimpleItemImpl.h b/src/ui/inc/FUiCtrl_SimpleItemImpl.h new file mode 100644 index 0000000..923d0f2 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SimpleItemImpl.h @@ -0,0 +1,66 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SimpleItemImpl.h + * @brief This is the header file for the _SimpleItemImpl class. + * + * This header file contains the declarations of the _SimpleItemImpl class. + */ + +#ifndef _FUI_CTRL_SIMPLE_ITEM_IMPL_H_ +#define _FUI_CTRL_SIMPLE_ITEM_IMPL_H_ + +#include "FUiCtrl_ListItemBaseImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class SimpleItem; + +class _SimpleItemImpl + : public _ListItemBaseImpl +{ +public: + static _SimpleItemImpl* CreateSimpleItemImplN(SimpleItem* pPublic, const Tizen::Graphics::Dimension& itemSize, ListAnnexStyle style); + + virtual ~_SimpleItemImpl(void); + + virtual const char* GetPublicClassName(void) const; + + virtual const SimpleItem& GetPublic(void) const; + + virtual SimpleItem& GetPublic(void); + + virtual result Construct(const Tizen::Graphics::Dimension& itemSize, ListAnnexStyle style); + + result SetElement(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap = null); + +private: + _SimpleItemImpl(SimpleItem* pPublic); + + _SimpleItemImpl(const _SimpleItemImpl& rhs); + + _SimpleItemImpl& operator =(const _SimpleItemImpl& rhs); + +private: + static const float SIMPLE_ITEM_ELEMENT_BITMAP_SIZE_RATIO = 0.6f; +}; // _SimpleItemImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_SIMPLE_ITEM_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_SlidableGroupedListImpl.h b/src/ui/inc/FUiCtrl_SlidableGroupedListImpl.h new file mode 100644 index 0000000..f2283be --- /dev/null +++ b/src/ui/inc/FUiCtrl_SlidableGroupedListImpl.h @@ -0,0 +1,302 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SlidableGroupedListImpl.h + * @brief This is the header file for _SlidableGroupedListImpl class. + */ + +#ifndef _FUI_CTRL_SLIDABLE_GROUPED_LIST_IMPL_H_ +#define _FUI_CTRL_SLIDABLE_GROUPED_LIST_IMPL_H_ + +#include +#include +#include +#include + +#include "FUi_ControlImpl.h" +#include "FUiCtrl_TableViewItemProvider.h" +#include "FUiCtrl_ITableViewItemEventListener.h" +#include "FUiCtrl_TableView.h" +#include "FUiCtrl_ListBaseImpl.h" +#include "FUiCtrl_IFastScrollListener.h" +#include "FUiCtrl_CustomListItemImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _SlidableGroupedListItemProvider + : public IGroupedTableViewItemProvider +{ + +public: + _SlidableGroupedListItemProvider(class _SlidableGroupedListImpl* pList); + virtual ~_SlidableGroupedListItemProvider(void){} + +public: + int GetGroupCount(void); + int GetItemCount(int groupIndex); + TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + TableViewItem* CreateItem(int groupIndex, int itemIndex, int itemWidth); + bool DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem); + bool DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem); + bool IsReorderable(int groupIndexFrom, int groupIndexTo); + + void UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem); + void UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem); + int GetDefaultGroupItemHeight(void); + int GetDefaultItemHeight(void); + + result UpdateCheckStatus(_TableViewItemData* pTableViewItemData, int groupIndex, int itemIndex); + result CallLoadToTopCb(int groupIndex, int itemIndex); + result ModifyIndicesAfterTopLoad(); + _TableViewItemData* LoadAtTop(int groupIndex, int itemIndex); + result CallLoadToBottomCb(int groupIndex, int itemIndex); + result ModifyIndicesAfterBottomLoad(int groupIndex, int itemIndex); + _TableViewItemData* LoadAtBottom(int groupIndex, int itemIndex); + + bool firstTime; +private: + _SlidableGroupedListItemProvider(const _SlidableGroupedListItemProvider& rhs); + _SlidableGroupedListItemProvider& operator =(const _SlidableGroupedListItemProvider& rhs); + + + _SlidableGroupedListImpl* __pListImpl; + int __bottomListenerIndex; + int __topListenerIndex; +}; //_SlidableGroupedListItemProvider + +class _SlidableGroupObject + : public Tizen::Base::Object +{ + +public: + _SlidableGroupObject(void); + ~_SlidableGroupObject(void); + +private: + _SlidableGroupObject(const _SlidableGroupObject& rhs); + _SlidableGroupObject& operator =(const _SlidableGroupObject& rhs); + + int __itemCount; + int __groupHeight; + int __topIndex; + + Tizen::Base::Collection::ArrayList* __pCheckedList; + + friend class _SlidableGroupedListImpl; + friend class _SlidableGroupedListItemProvider; + +}; //_SlidableGroupObject + +class _SlidableGroupedListImpl + : public _ITableViewItemEventListener + , public _IUiFastScrollListener + , public _ListBaseImpl +{ +public: + _SlidableGroupedListImpl(Control* pList, _TableView* pCore); + ~_SlidableGroupedListImpl(void); + static _SlidableGroupedListImpl* CreateSlidableGroupedListImplN(SlidableGroupedList* pControl, bool itemDivider, bool fastScroll); + + //@See doxygen + void AddSlidableGroupedListEventListener(Tizen::Ui::ISlidableGroupedListEventListener& listener); + //@See doxygen + void RemoveSlidableGroupedListEventListener(Tizen::Ui::ISlidableGroupedListEventListener& listener); + //@See doxygen + void AddFastScrollEventListener(Tizen::Ui::IFastScrollEventListener& listener); + //@See doxygen + result AddGroup(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int itemCount, int groupHeight, int groupId); + //@See doxygen + void AddGroupedItemEventListener(Tizen::Ui::IGroupedItemEventListener& listener); + //@See doxygen + result AddItem(int groupIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const; + //@See doxygen + result GetFirstCheckedItemIndex(int& groupIndex, int& itemIndex) const; + //@See doxygen + int GetGroupIdAt(int groupIndex) const; + //@See doxygen + int GetGroupIndexFromGroupId(int groupId) const; + //@See doxygen + result GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const; + //@See doxygen + result GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const; + //@See doxygen + result SetFastScrollMainIndex(const Tizen::Base::String& text); + //@See doxygen + result SetFastScrollSubIndex(const Tizen::Base::String& text, FastScrollIndexDigit indexDigit); + //@See doxygen + result GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex) const; + //@See doxygen + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex) const; + //@See doxygen + result InsertGroupAt(int groupIndex, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int itemCount, int groupHeight, int groupId); + //@See doxygen + result GetLastCheckedItemIndex(int& groupIndex, int& itemIndex) const; + //@See doxygen + const CustomListItem* GetLoadedItemAt(int groupIndex, int index) const; + //@See doxygen + int GetLoadedItemIdAt(int groupIndex, int index) const; + //@See doxygen + result GetNextCheckedItemIndexAfter(int& groupIndex, int& index) const; + //@See doxygen + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + //@See doxygen + result GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const; + //@See doxygen + bool IsItemChecked(int groupIndex, int index) const; + //@See doxygen + bool IsItemEnabled(int index) const; + //@See doxygen + bool IsItemLoaded(int groupIndex, int itemIndex) const; + //@See doxygen + result RemoveAllGroups(void); + //@See doxygen + result InsertItemAt(int groupIndex, int index, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + int GetItemCountAt(int groupIndex) const; + //@See doxygen + result RefreshItem(int groupIndex, int index); + //@See doxygen + result RefreshGroup(int groupIndex); + //@See doxygen + bool IsLoadedItemEnabled(int groupIndex, int index) const; + //@See doxygen + result LoadItemToTop(const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result LoadItemToBottom(const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result GetLoadedItemIndexFromItemId(int itemId, int& groupIndex, int& itemIndex) const; + //@See doxygen + result UnloadAllItems(void); + //@See doxygen + result RemoveAllCheckedItemsAt(int groupIndex, int itemHeight); + //@See doxygen + result RemoveAllCheckedItems(int itemHeight); + //@See doxygen + result RemoveAllItemsAt(int groupIndex); + //@See doxygen + result RemoveAllItems(void); + //@See doxygen + void RemoveFastScrollEventListener(IFastScrollEventListener& listener); + //@See doxygen + void RemoveGroupedItemEventListener(IGroupedItemEventListener& listener); + //@See doxygen + result RemoveItemAt(int groupIndex, int index, int itemHeight); + //@See doxygen + result RemoveGroupAt(int groupIndex); + //@See doxygen + void ScrollToBottom(void); + //@See doxygen + result ScrollToTop(int index); + //@See doxygen + result ScrollToTop(int groupIndex, int itemIndex); + //@See doxygen + void ScrollToTop(void); + //@See doxygen + result SetAllItemsChecked(int groupIndex, bool check); + //@See doxygen + result SetItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result SetItemChecked(int groupIndex, int index, bool check); + //@See doxygen + result SetItemEnabled(int index, bool enable); + //@See doxygen + result SetLoadedItemEnabled(int groupIndex, int index, bool enable); + //@See doxygen + void SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + //@See doxygen + void SetTextOfEmptyList(const Tizen::Base::String& text); + //@See doxygen + result SetGroupAt(int groupIndex, const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int groupId); + + void OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + void OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo); + void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + void OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo); + void OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + void OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + void OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction); + + void OnUiFastScrollIndexSelected(Tizen::Ui::_Control& source, Tizen::Ui::Controls::_FastScrollIndex& index); + + void OnDraw(void); + + void Initialize(void); + int GetTopItemIndex(int groupIndex) const; + +public: + static _SlidableGroupedListImpl* GetInstance(SlidableGroupedList& slidableGroupedList); + static const _SlidableGroupedListImpl* GetInstance(const SlidableGroupedList& slidableGroupedList); + +private: + _SlidableGroupedListImpl(const _SlidableGroupedListImpl& rhs); + _SlidableGroupedListImpl& operator =(const _SlidableGroupedListImpl& rhs); + + const char* GetPublicClassName(void) const; + const SlidableGroupedList& GetPublic(void) const; + SlidableGroupedList& GetPublic(void); + const _TableView& GetCore(void) const; + _TableView& GetCore(void); + + void ProcessItemStateChange(int groupIndex, int index, int elementId, ItemStatus itemStatus); + void ProcessItemStateChange(int groupIndex, int index, ItemStatus itemStatus); + + void CallUnloadItemCb(int groupIndex, int itemIndex); + + int GetCurrentLoadedCount(void); + result CreateItemProvider(void); + CustomListItem* CreateGroupItemN(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBackgroundBitmap, int groupId); + + bool IsCheckedStyle(void); + const bool IsCheckedStyle(void) const; + + result CreateGroupObject(int groupIndex, int itemCount, int groupHeight); + result UpdateCheckedList(int groupIndex, int index, bool check); + + result SetItemCheckedMarkOnOff(int groupIndex, int index, bool check); + result SetItemCheckedRadio(int groupIndex, int index, bool check); + + Tizen::Base::Collection::LinkedList __groupsList; + Tizen::Ui::IFastScrollEventListener* __pFastScrollListener; + Tizen::Base::String __mainScrollIndex; + + int __bottomGroup; + int __topGroup; + int __loadedCount; + _SlidableGroupedListItemProvider* __pItemProvider; + Tizen::Base::Collection::LinkedList __slidableListenersList; + Tizen::Base::Collection::LinkedList __itemListenersList; + bool __directDelete; + bool __forceScroll; + bool __isCreating; + int __groupItemTextFont; + int __groupItemHeight; + int __itemCacheSize; + CustomListItemFormat* __pItemFormat; + + friend class _SlidableGroupedListItemProvider; +}; //_SlidableGroupedListImpl + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_SLIDABLE_GROUPED_LIST_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_SlidableListImpl.h b/src/ui/inc/FUiCtrl_SlidableListImpl.h new file mode 100644 index 0000000..46f4de0 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SlidableListImpl.h @@ -0,0 +1,238 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SlidableListImpl.h + * @brief This is the header file for the _SlidableListImpl class. + */ + +#ifndef _FUI_CTRL_SLIDABLE_LIST_IMPL_H_ +#define _FUI_CTRL_SLIDABLE_LIST_IMPL_H_ + +#include + +#include "FUiCtrl_CustomListItemImpl.h" +#include "FUiCtrl_IFastScrollListener.h" +#include "FUiCtrl_TableView.h" +#include "FUiCtrl_ListBaseImpl.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class CustomListItem; +class _SlidableListImpl; +class _TableViewItemData; + +class _SlidableListItemProvider + : public ITableViewItemProvider +{ +public: + _SlidableListItemProvider(_SlidableListImpl* pList); + virtual ~_SlidableListItemProvider(void){} + +public: + virtual int GetItemCount(void); + virtual TableViewItem* CreateItem(int index, int itemWidth); + virtual bool DeleteItem(const int itemIndex, TableViewItem* pItem); + virtual void UpdateItem(int itemIndex, TableViewItem* pItem); + virtual int GetDefaultItemHeight(void); + + result UpdateCheckStatus(_TableViewItemData* pTableViewItemData, int index); + result CallLoadToTopCb(int index); + _TableViewItemData* LoadAtTop(int index); + result CallLoadToBottomCb(int index); + _TableViewItemData* LoadAtBottom(int index); + + bool firstTime; + int bottomListenerIndex; + int topListenerIndex; + +private: + _SlidableListItemProvider(const _SlidableListItemProvider& rhs); + _SlidableListItemProvider& operator =(const _SlidableListItemProvider& rhs); + _SlidableListImpl* __pListImpl; + + friend class _CustomListItemImpl; + +}; //_SlidableListItemProvider + +class _SlidableListImpl + : public _ListBaseImpl + , public _ITableViewItemEventListener +{ +private: + _SlidableListImpl(Control* pList, _TableView* pCore); + ~_SlidableListImpl(void); + + void ProcessItemStateChange(int groupIndex, int index, int elementId, ItemStatus itemStatus); + void ProcessItemStateChange(int groupIndex, int index, ItemStatus itemStatus); + +public: + static _SlidableListImpl* CreateSlidableListImplN(SlidableList* pControl, const Tizen::Graphics::Rectangle& bounds, bool itemDivider); + + void AddSlidableListEventListener(const Tizen::Ui::ISlidableListEventListener& listener); + void RemoveSlidableListEventListener(const Tizen::Ui::ISlidableListEventListener& listener); + + void AddCustomItemEventListener(const Tizen::Ui::ICustomItemEventListener& listener); + + result AddItem(const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + int GetBottomDrawnItemIndex(void) const; + //@See doxygen + int GetFirstCheckedItemIndex(void) const; + //@See doxygen + int GetFirstLoadedItemIndex(void) const; + //@See doxygen + int GetLastLoadedItemIndex(void) const; + //@See doxygen + int GetItemCount(void) const; + int GetItemIndexFromItemId(int itemId) const; + //@See doxygen + int GetItemIndexFromPosition(int x, int y) const; + //@See doxygen + int GetItemIndexFromPosition(const Tizen::Graphics::Point& position) const; + //@See doxygen + int GetLastCheckedItemIndex(void) const; + //@See doxygen + const CustomListItem* GetLoadedItemAt(int index) const; + //@See doxygen + int GetLoadedItemIdAt(int index) const; + //@See doxygen + int GetNextCheckedItemIndexAfter(int index) const; + //@See doxygen + Tizen::Graphics::Color GetTextColorOfEmptyList(void) const; + //@See doxygen + int GetTopDrawnItemIndex(void) const; + //@See doxygen + result InsertItemAt(int index, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + bool IsItemChecked(int index) const; + //@See doxygen + bool IsItemLoaded(int index) const; + //@See doxygen + bool IsLoadedItemEnabled(int index) const; + //@See doxygen + result LoadItemToTop(const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result LoadItemToBottom(const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + void SetItemCountAndHeight(int count, int listHeight); + + //@See doxygen + int GetLoadedItemIndexFromItemId(int itemId) const; + + //@See doxygen + result UnloadAllItems(void); + //@See doxygen + result RefreshItem(int index); + //@See doxygen + result RemoveAllCheckedItems(int itemHeight); + //@See doxygen + result RemoveAllItems(void); + //@See doxygen + void RemoveCustomItemEventListener(const Tizen::Ui::ICustomItemEventListener& listener); + //@See doxygen + result RemoveItemAt(int index, int itemHeight); + //@See doxygen + void ScrollToBottom(void); + //@See doxygen + result ScrollToTop(int index); + //@See doxygen + void ScrollToTop(void); + //@See doxygen + result SetAllItemsChecked(bool check); + + //@See doxygen + result SetItemAt(int index, const CustomListItem& item, int itemId = LIST_ITEM_UNSPECIFIED_ID); + //@See doxygen + result SetItemChecked(int index, bool check); + result SetItemChecked(int groupindex, int index, bool check); + //@See doxygen + result SetLoadedItemEnabled(int index, bool enable); + //@See doxygen + void SetTextColorOfEmptyList(const Tizen::Graphics::Color& color); + //@See doxygen + void SetTextOfEmptyList(const Tizen::Base::String& text); + + virtual void OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + + virtual void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + + virtual void OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo); + + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + + virtual void OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo); + + virtual void OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + + virtual void OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + + virtual void OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction); + + result Initalize(void); + result UpdateBounds(const Tizen::Graphics::Rectangle& rect); + + void OnDraw(void); + int GetTopItemIndex(void); + bool IsItemChecked(int groupIndex, int subIndex) const; + +public: + static _SlidableListImpl* GetInstance(SlidableList& slidableList); + static const _SlidableListImpl* GetInstance(const SlidableList& slidableList); + +private: + _SlidableListImpl(const _SlidableListImpl& rhs); + _SlidableListImpl& operator =(const _SlidableListImpl& rhs); + + void CallUnloadItemCb(int index); + void HandleItemStateChanged(int index, int elementId, ItemStatus itemStatus); + void HandleItemStateChanged(int index, ItemStatus itemStatus); + bool IsCheckedStyle(void); + const bool IsCheckedStyle(void) const; + + result CreateItemProvider(void); + + const char* GetPublicClassName(void) const; + const SlidableList& GetPublic(void) const; + SlidableList& GetPublic(void); + const _TableView& GetCore(void) const; + _TableView& GetCore(void); + + Tizen::Base::Collection::ArrayList* __pCheckedList; + Tizen::Base::Collection::LinkedList __slidableListenersList; + Tizen::Base::Collection::LinkedList __itemListenersList; + + int __totalItemCount; + int __topIndex; + _SlidableListItemProvider* __pItemProvider; + bool __isDirectDelete; + bool __isCreating; + int __itemCacheSize; + static const int LISTVIEW_MAX_ITEM_COUNT = 30; + static const int LISTVIEW_ITEM_HEIGHT = 100; + friend class _SlidableListItemProvider; + friend class _CustomListItemImpl; +}; //_SlidableListImpl +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_SLIDABLE_LIST_IMPL_H_ + diff --git a/src/ui/inc/FUiCtrl_Slider.h b/src/ui/inc/FUiCtrl_Slider.h new file mode 100644 index 0000000..9da4ff3 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Slider.h @@ -0,0 +1,174 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Slider.h + * @brief This is the header file for the _Slider class. + * + * This header file contains the declarations of the %_Slider class. + */ +#ifndef _FUI_CTRL_INTERNAL_SLIDER_H_ +#define _FUI_CTRL_INTERNAL_SLIDER_H_ + +#include +#include "FUi_Control.h" +#include "FUiCtrl_AdjustmentEvent.h" +#include "FUiCtrl_SliderEvent.h" +#include "FUi_IAccessibilityListener.h" +const int _SLIDER_MAXIMUM_VALUE = 999; +const int _SLIDER_MINIMUM_VALUE = -99; + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class _SliderPresenter; +class _ISliderEventListener; +class _IAdjustmentEventListener; + +enum _SliderStyle +{ + _SLIDER_STYLE_NONE = 0x00000000, + _SLIDER_STYLE_OVERLAY = 0x00000001, + _SLIDER_STYLE_TITLE_TEXT = 0x00000002, + _SLIDER_STYLE_NO_BG = 0x00000004 +}; + +class _OSP_EXPORT_ _Slider + : public Tizen::Ui::_Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer + , public Tizen::Ui::_IAccessibilityListener +{ + DECLARE_CLASS_BEGIN(_Slider, Tizen::Ui::_Control); + DECLARE_PROPERTY("value", GetPropertyValue, SetPropertyValue); + DECLARE_PROPERTY("minValue", GetPropertyMinValue, SetPropertyMinValue); + DECLARE_PROPERTY("maxValue", GetPropertyMaxValue, SetPropertyMaxValue); + DECLARE_PROPERTY("barColor", GetPropertyBarColor, SetPropertyBarColor); + DECLARE_PROPERTY("color", GetPropertyColor, SetPropertyColor); + DECLARE_PROPERTY("titleText", GetPropertyTitleText, SetPropertyTitleText); + DECLARE_PROPERTY("titleTextColor", GetPropertyTitleTextColor, SetPropertyTitleTextColor); + DECLARE_CLASS_END(); + +public: + result SetPropertyValue(const Tizen::Ui::Variant& value); + result SetPropertyMinValue(const Tizen::Ui::Variant& minValue); + result SetPropertyMaxValue(const Tizen::Ui::Variant& maxValue); + result SetPropertyBarColor(const Tizen::Ui::Variant& barColor); + result SetPropertyTitleText(const Tizen::Ui::Variant& titleText); + result SetPropertyTitleTextColor(const Tizen::Ui::Variant& titleTextColor); + result SetPropertyColor(const Tizen::Ui::Variant& color); + void SetAccessibilityElementValue(void); + + Tizen::Ui::Variant GetPropertyValue(void) const; + Tizen::Ui::Variant GetPropertyMinValue(void) const; + Tizen::Ui::Variant GetPropertyMaxValue(void) const; + Tizen::Ui::Variant GetPropertyBarColor(void) const; + Tizen::Ui::Variant GetPropertyTitleText(void) const; + Tizen::Ui::Variant GetPropertyTitleTextColor(void) const; + Tizen::Ui::Variant GetPropertyColor(void) const; + +public: + virtual ~_Slider(void); + + void SetStyle(int style); + int GetStyle(void) const; + Tizen::Graphics::Canvas* GetHandleCanvasN(void) const; + Animations::_VisualElement* GetHandle(void) const; + void SetGroupStyle(GroupStyle groupStyle); + result UpdateHandle(const Tizen::Graphics::Rectangle& handleRect); + + result SetRange(int minValue, int maxValue); + result GetRange(int& minValue, int& maxValue) const; + result SetValue(int value); + int GetValue(void) const; + result SetIcon(IconPosition position, const Tizen::Graphics::Bitmap& icon); + Tizen::Graphics::Bitmap* GetIcon(IconPosition position) const; + result SetTitleText(const Tizen::Base::String& title); + Tizen::Base::String GetTitleText(void) const; + result SetTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTitleTextColor(void) const; + result AddAdjustmentEventListener(const _IAdjustmentEventListener& listener); + result RemoveAdjustmentEventListener(const _IAdjustmentEventListener& listener); + result AddSliderEventListener(const _ISliderEventListener& listener); + result RemoveSliderEventListener(const _ISliderEventListener& listener); + result SetBarColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetBarColor(void) const; + result SetColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetColor(void) const; + Tizen::Base::Runtime::_Event* GetAdjustmentEvent(void) const; + _SliderEvent* GetSliderEvent(void) const; + result SetThumbBitmap(SliderThumbStatus status, const Tizen::Graphics::Bitmap& bitmap); + void SetThumbTextColor(SliderThumbStatus status, const Tizen::Graphics::Color& color); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual void OnBoundsChanged(void); + virtual void OnDraw(void); + virtual result OnAttachedToMainTree(void); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + // accessibility listener + virtual bool OnAccessibilityFocusMovedNext(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusMovedPrevious(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityReadElement(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusIn(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusOut(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityActionPerformed(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + static _Slider* CreateSliderN(void); + +private: + _Slider(void); + _Slider(const _Slider&); + _Slider& operator =(const _Slider&); + + result Initialize(void); + result InitializeAccessibilityElement(void); + +private: + _SliderPresenter* __pSliderPresenter; + _AdjustmentEvent* __pAdjustmentEvent; + _SliderEvent* __pSliderEvent; + + Tizen::Base::String __titleText; + Tizen::Graphics::Bitmap* __pLeftBitmap; + Tizen::Graphics::Bitmap* __pRightBitmap; + + Tizen::Graphics::Color __bgColor; + Tizen::Graphics::Color __barColor; + Tizen::Graphics::Color __titleTextColor; + + int __sliderStyle; + + Tizen::Ui::Animations::_VisualElement* __pBase; + Tizen::Ui::Animations::_VisualElement* __pHandle; + + Tizen::Ui::_AccessibilityElement* __pAccessibilityElement; +}; // _Slider + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SLIDER_H_ diff --git a/src/ui/inc/FUiCtrl_SliderEvent.h b/src/ui/inc/FUiCtrl_SliderEvent.h new file mode 100644 index 0000000..be919c0 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SliderEvent.h @@ -0,0 +1,55 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SliderEvent.h + * @brief This is the header file for __SliderEvent class. + * + * This header file contains declaration of _SliderEvent class. + */ +#ifndef _FUI_CTRL_INTERNAL_SLIDER_EVENT_H_ +#define _FUI_CTRL_INTERNAL_SLIDER_EVENT_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Slider; + + +class _SliderEvent + : public Tizen::Base::Runtime::_Event +{ +public: + virtual ~_SliderEvent(void); + + const _Slider* GetSource(void) const; + static _SliderEvent* CreateInstanceN(const _Slider& source); + static Tizen::Base::Runtime::IEventArg* CreateSliderEventArgN(int value); + +protected: + _SliderEvent(const _Slider& source); + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + _Slider* __pSource; + +}; // _SliderEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SLIDER_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_SliderImpl.h b/src/ui/inc/FUiCtrl_SliderImpl.h new file mode 100644 index 0000000..0f364c5 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SliderImpl.h @@ -0,0 +1,96 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SliderImpl.h + * @brief This is the header file for the _SliderImpl class. + * + * This header file contains the declarations of the %_SliderImpl class. + */ +#ifndef _FUI_CTRL_INTERNAL_SLIDER_IMPL_H_ +#define _FUI_CTRL_INTERNAL_SLIDER_IMPL_H_ + +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_Slider.h" +#include "FUiCtrl_IAdjustmentEventListener.h" +#include "FUiCtrl_ISliderEventListener.h" + +namespace Tizen { namespace Graphics +{ +class Dimension; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ +class _PublicAdjustmentEvent; +class _PublicSliderEvent; + +class _SliderImpl + : public _ControlImpl + , public _IAdjustmentEventListener + , public _ISliderEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + virtual ~_SliderImpl(void); + + result Initialize(int minValue, int maxValue, BackgroundStyle bgStyle, int sliderStyle, GroupStyle groupStyle); + result SetRange(int minValue, int maxValue); + result GetRange(int& minValue, int& maxValue) const; + result SetValue(int value); + int GetValue(void) const; + result SetIcon(IconPosition position, const Tizen::Graphics::Bitmap& icon); + result SetTitleText(const Tizen::Base::String& title); + Tizen::Base::String GetTitleText(void) const; + result SetTitleTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTitleTextColor(void) const; + result AddAdjustmentEventListener(Tizen::Ui::IAdjustmentEventListener& listener); + result RemoveAdjustmentEventListener(Tizen::Ui::IAdjustmentEventListener& listener); + result AddSliderEventListener(const ISliderEventListener& listener); + result RemoveSliderEventListener(const ISliderEventListener& listener); + result SetBarColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetBarColor(void) const; + result SetColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetColor(void) const; + result SetThumbBitmap(SliderThumbStatus status, const Tizen::Graphics::Bitmap& bitmap); + void SetThumbTextColor(SliderThumbStatus status, const Tizen::Graphics::Color& color); + + virtual const char* GetPublicClassName(void) const; + virtual const Slider& GetPublic(void) const; + virtual Slider& GetPublic(void); + virtual const _Slider& GetCore(void) const; + virtual _Slider& GetCore(void); + virtual void OnAdjustmentValueChanged(const Tizen::Ui::_Control& source, int adjustment); + virtual void OnSliderBarMoved(_Slider& source, int value); + + static _SliderImpl* CreateSliderImplN(Slider* pControl, const Tizen::Graphics::Rectangle& rect, int sliderStyle); + static _SliderImpl* GetInstance(Slider& slider); + static const _SliderImpl* GetInstance(const Slider& slider); + +private: + _SliderImpl(Slider* pPublic, _Slider* pCore); + _SliderImpl(const _SliderImpl&); + _SliderImpl& operator =(const _SliderImpl&); + + _PublicAdjustmentEvent* __pPublicAdjustmentEvent; + _PublicSliderEvent* __pPublicSliderEvent; + +}; // _SliderImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_SLIDER_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_SliderModel.h b/src/ui/inc/FUiCtrl_SliderModel.h new file mode 100644 index 0000000..792e9f2 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SliderModel.h @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SliderModel.h + * @brief This is the header file for the _SliderModel class. + * + * This header file contains the declarations of the %_SliderModel class. + */ +#ifndef _FUI_CTRL_INTERNAL_SLIDER_MODEL_H_ +#define _FUI_CTRL_INTERNAL_SLIDER_MODEL_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _SliderModel + : public Tizen::Base::Object +{ +public: + _SliderModel(void); + virtual ~_SliderModel(void); + + void SetMinValue(int minValue); + void SetMaxValue(int maxValue); + int GetMinValue(void) const; + int GetMaxValue(void) const; + void SetValue(int value); + int GetValue(void) const; + +private: + _SliderModel(const _SliderModel&); + _SliderModel& operator =(const _SliderModel&); + +private: + int __minValue; + int __maxValue; + int __currentValue; + +}; // _SliderModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SLIDER_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_SliderOverlay.h b/src/ui/inc/FUiCtrl_SliderOverlay.h new file mode 100644 index 0000000..9fef4e5 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SliderOverlay.h @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SliderOverlay.h + * @brief This is the header file for the _SliderOverlay class. + * + * This header file contains the declarations of the %_SliderOverlay class. + */ +#ifndef _FUI_CTRL_INTERNAL_SLIDEROVERLAY_H_ +#define _FUI_CTRL_INTERNAL_SLIDEROVERLAY_H_ + +#include "FUi_Window.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +class _SliderPresenter; + + +class _SliderOverlay + : public Tizen::Ui::_Window + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer +{ +public: + _SliderOverlay(void); + virtual ~_SliderOverlay(void); + + result Construct(void); + result SetSliderRect(Tizen::Graphics::Rectangle& sliderRect, Tizen::Graphics::Rectangle& sliderTouchRect); + void SetFont(Tizen::Graphics::Font* pFont); + result DrawSliderOverlay(int positionX,int handleWidth, int value); + + virtual bool IsActivatedOnOpen(void) const; + +private: + result LoadBitmaps(Tizen::Graphics::Dimension& dim); + + _SliderOverlay(const _SliderOverlay&); + _SliderOverlay& operator =(const _SliderOverlay&); + +private: + + static const int SLIDER_OVERLAY_THREE_DIGIT = 3; + static const int SLIDER_OVERLAY_TWO_DIGIT = 2; + + Tizen::Graphics::Rectangle __sliderRect; + Tizen::Graphics::Rectangle __sliderTouchRect; + Tizen::Graphics::Rectangle __sliderOverlayRect; + Tizen::Graphics::Bitmap* __pOverlayBgBitmap; + Tizen::Graphics::Bitmap* __pOverlayBgEffectBitmap; + Tizen::Graphics::Bitmap* __pOverlayBottomBgBitmap; + Tizen::Graphics::Bitmap* __pOverlayBottomBgEffectBitmap; + Tizen::Graphics::Color __overlayBgColor; + Tizen::Graphics::Color __overlayTextColor; + + Tizen::Graphics::Font* __pFont; + +}; // _SliderOverlay + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SLIDEROVERLAY_H_ diff --git a/src/ui/inc/FUiCtrl_SliderPresenter.h b/src/ui/inc/FUiCtrl_SliderPresenter.h new file mode 100644 index 0000000..c741d01 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SliderPresenter.h @@ -0,0 +1,163 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SliderPresenter.h + * @brief This is the header file for the _SliderPresenter class. + * + * This header file contains the declarations of the %_SliderPresenter class. + */ +#ifndef _FUI_CTRL_INTERNAL_SLIDER_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_SLIDER_PRESENTER_H_ + +#include +#include +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +class _Slider; +class _SliderModel; +class _SliderOverlay; + + +class _SliderPresenter + : public Tizen::Base::Object +{ +public: + virtual ~_SliderPresenter(void); + + result Draw(void); + void SetMinValue(int minValue); + void SetMaxValue(int maxValue); + int GetMinValue(void) const; + int GetMaxValue(void) const; + void SetValue(int value); + int GetValue(void) const; + void SetNeedUpdate(void); + void SetGroupStyle(GroupStyle groupStyle); + + Tizen::Graphics::Rectangle GetTitleTextBounds(void) const; + Tizen::Graphics::Rectangle GetIconBounds(IconPosition iconPosition) const; + Tizen::Graphics::Rectangle GetTouchBounds(void) const; + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual void OnBoundsChanged(void); + + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + + static _SliderPresenter* CreateInstanceN(const _Slider& slider); + result SetThumbBitmap(SliderThumbStatus status, const Tizen::Graphics::Bitmap& bitmap); + void SetThumbTextColor(SliderThumbStatus status, const Tizen::Graphics::Color& color); + +private: + int CalculateSliderValue(int positionX, int offsetX); + result Resize(void); + result LoadBitmap(void); + result DrawSlider(void); + result DrawBackground(Tizen::Graphics::Canvas& canvas); + result DrawSliderBar(Tizen::Graphics::Canvas& canvas); + result DrawTitleText(Tizen::Graphics::Canvas& canvas); + result DrawIcon(Tizen::Graphics::Canvas& canvas); + result DrawSliderOverlay(int value); + result DrawSliderBarNumber(int value); + result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, Tizen::Graphics::Bitmap* pBitmap); + + _SliderPresenter(void); + _SliderPresenter(const _SliderPresenter&); + _SliderPresenter& operator =(const _SliderPresenter&); + +private: + + static const int SLIDER_HANDLE_THREE_DIGIT = 3; + static const int SLIDER_HANDLE_TWO_DIGIT = 2; + + _Slider* __pSlider; + _SliderModel* __pSliderModel; + _SliderOverlay* __pSliderOverlay; + Tizen::Graphics::Rectangle __rect; + Tizen::Graphics::Rectangle __touchRect; + Tizen::Graphics::Rectangle __barBgRect; + Tizen::Graphics::Rectangle __barRect; + Tizen::Graphics::Rectangle __handleRect; + + Tizen::Graphics::Bitmap* __pResourceBgTopBitmap; + Tizen::Graphics::Bitmap* __pResourceBgMiddleBitmap; + Tizen::Graphics::Bitmap* __pResourceBgBottomBitmap; + Tizen::Graphics::Bitmap* __pResourceBgSingleBitmap; + + + Tizen::Graphics::Bitmap* __pBgTopBitmap; + Tizen::Graphics::Bitmap* __pBgMiddleBitmap; + Tizen::Graphics::Bitmap* __pBgBottomBitmap; + Tizen::Graphics::Bitmap* __pBgSingleBitmap; + Tizen::Graphics::Bitmap* __pBgGrpStyleNoneBitmap; + + Tizen::Graphics::Bitmap* __pBgTopEffectBitmap; + Tizen::Graphics::Bitmap* __pBgMiddleEffectBitmap; + Tizen::Graphics::Bitmap* __pBgBottomEffectBitmap; + Tizen::Graphics::Bitmap* __pBgSingleEffectBitmap; + + + Tizen::Graphics::Bitmap* __pResourceBarBitmap; + Tizen::Graphics::Bitmap* __pBarResourceEffectBitmap; + Tizen::Graphics::Bitmap* __pBarBgResourceEffectBitmap; + Tizen::Graphics::Bitmap* __pBarColorReplacementBitmap; + Tizen::Graphics::Bitmap* __pBarBgColorReplacementBitmap; + + Tizen::Graphics::Bitmap* __pHandleNormalBitmap; + Tizen::Graphics::Bitmap* __pHandlePressedBitmap; + Tizen::Graphics::Bitmap* __pHandleDisabledBitmap; + Tizen::Graphics::Bitmap* __pHandleHighlightedBitmap; + + Tizen::Graphics::Bitmap* __pHandleNormalEffectBitmap; + Tizen::Graphics::Bitmap* __pHandlePressedEffectBitmap; + Tizen::Graphics::Bitmap* __pHandleDisabledEffectBitmap; + Tizen::Graphics::Bitmap* __pHandleHighlightedEffectBitmap; + + Tizen::Graphics::Color __currentBarColor; + Tizen::Graphics::Color __currentBgColor; + Tizen::Graphics::Color __currentGrpStyleNoneColor; + + Tizen::Graphics::Color __handleTextColor; + Tizen::Graphics::Color __handleTextPressedColor; + Tizen::Graphics::Color __handleTextDisabledColor; + Tizen::Graphics::Color __handleTextHighlightedColor; + + Tizen::Graphics::Font* __pFont; + Tizen::Graphics::_Text::TextObject* __pTitleTextObject; + + int __sliderX; + int __handleX; + bool __isSliderPressed; + + bool __isNeedToBeUpdated; + bool __isBubblingBlocked; + bool __isResourceLoaded; + bool __isCustomHandle; + bool __isCustomPressedTextColor; + GroupStyle __groupStyle; + int __fontSize; +}; // _SliderPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SLIDER_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_SplitPanel.h b/src/ui/inc/FUiCtrl_SplitPanel.h new file mode 100644 index 0000000..923c990 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SplitPanel.h @@ -0,0 +1,185 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SplitPanel.h + * @brief This is the header file for the _SplitPanel class. + * + * This header file contains the declarations of the %_SplitPanel class. + */ +#ifndef _FUICTRL_INTERNAL_SPLIT_PANEL_H_ +#define _FUICTRL_INTERNAL_SPLIT_PANEL_H_ + +#include +#include +#include "FUi_Control.h" +#include "FUiCtrl_ISplitPanelEventListener.h" +#include "FUiCtrl_SplitPanelEvent.h" +#include "FUiCtrl_SplitPanelPresenter.h" +#include "FUi_ITouchTapGestureEventListener.h" +#include "FUiAnim_VisualElement.h" +#include "FUi_IAccessibilityListener.h" + +namespace Tizen { namespace Ui +{ + class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class _SplitPanelPresenter; + +enum _SplitPanelDividerState +{ + _SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_LANDSCAPE = 0, + _SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_LANDSCAPE, + _SPLIT_PANEL_VERTICAL_DIVIDER_ORIENTATION_PORTRAIT, + _SPLIT_PANEL_HORIZONTAL_DIVIDER_ORIENTATION_PORTRAIT, + + _SPLIT_PANEL_DIVIDER_STATE_MAX +}; + +const int _SPLIT_PANEL_DIVIDER_STATE = 4; + +/** + * @class _SplitPanel + * @brief + * @since 1.0 + * + * + * + * + */ + +class _OSP_EXPORT_ _SplitPanel + : public Tizen::Ui::_Control + , public Tizen::Ui::_ITouchTapGestureEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer + , virtual public Tizen::Ui::_ITouchGestureEventListener + , public Tizen::Ui::_IAccessibilityListener +{ +public: + virtual ~_SplitPanel(void); + +public: + static _SplitPanel* CreateSplitPanelN(const Tizen::Graphics::Rectangle& rect, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection); + result Construct(SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection); + + virtual void OnDraw(void); + + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + virtual void OnBoundsChanged(void); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnTapGestureDetected(_TouchTapGestureDetector& gesture); + virtual bool OnTapGestureCanceled(_TouchTapGestureDetector& gesture); + + // accessibility listener + virtual bool OnAccessibilityFocusMovedNext(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusMovedPrevious(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityReadElement(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusIn(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityFocusOut(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityActionPerformed(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element){return true;} + virtual bool OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + + +public: + result AddSplitPanelEventListener(const _ISplitPanelEventListener& listener); + result RemoveSplitPanelEventListener(const _ISplitPanelEventListener& listener); + + result SetPane(_Control* pControl, SplitPanelPaneOrder paneOrder); + _Control* GetPane(SplitPanelPaneOrder paneOrder) const; + + result SetDividerStyle(SplitPanelDividerStyle splitPanelDividerStyle); + SplitPanelDividerStyle GetDividerStyle(void) const; + + result SetDividerPosition(int position); + int GetDividerPosition(void) const; + + result SetMaximumDividerPosition(int position); + int GetMaximumDividerPosition(void) const; + + result SetMinimumDividerPosition(int position); + int GetMinimumDividerPosition(void) const; + + void SetDividerDirection(SplitPanelDividerDirection dividerDirection); + SplitPanelDividerDirection GetDividerDirection(void) const; + + result MaximizePane(SplitPanelPaneOrder paneOrder); + bool IsPaneMaximized(SplitPanelPaneOrder paneOrder) const; + result RestorePane(void); + + result SendSplitPanelEvent(_SplitPanelEventStatus status); + + void SetTapCount(int count); + int GetTapCount(void) const; + + result OnAttachedToMainTree(void); + + Tizen::Ui::Animations::VisualElement* GetDividerVisualElement(void); + + void SetDividerVisualElementBounds(Tizen::Graphics::Rectangle& bounds); + +protected: + result SetPresenter(const _SplitPanelPresenter& splitPanelPresenter); + +private: + _SplitPanel(void); + + _SplitPanel(const _SplitPanel& rhs); + _SplitPanel& operator =(const _SplitPanel& rhs); + +private: + _SplitPanelPresenter* __pSplitPanelPresenter; + + _TouchTapGestureDetector* __pTapGesture; + + Tizen::Ui::_Control* __pFirstPane; + Tizen::Ui::_Control* __pSecondPane; + + int __dividerPosition[_SPLIT_PANEL_DIVIDER_STATE]; + int __minimumDividerPosition[_SPLIT_PANEL_DIVIDER_STATE]; + int __maximumDividerPosition[_SPLIT_PANEL_DIVIDER_STATE]; + + SplitPanelDividerDirection __splitPanelDividerDirection; + + _SplitPanelEvent* __pSplitPanelEvent; + + int __dividerTapCount; + + Tizen::Ui::_AccessibilityElement* __pAccessibilityElement; + + Tizen::Ui::Animations::VisualElement* __pDividerVisualElement; + + bool __isDividerPositionInitialized; + bool __isDividerMaximumPositionInitialized; + bool __isDividerMinimumPositionInitialized; + bool __isFirstTimeOrientationChanged; + +}; // _SplitPanel + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_SPLIT_PANEL_H_ + diff --git a/src/ui/inc/FUiCtrl_SplitPanelEvent.h b/src/ui/inc/FUiCtrl_SplitPanelEvent.h new file mode 100644 index 0000000..1844fa7 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SplitPanelEvent.h @@ -0,0 +1,115 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_SplitPanelEvent.h + * @brief This is the header file for _SplitPanelEvent class. + * @version 1.0 + * + * This header file contains declaration of _SplitPanelEvent class. + * The SplitPanelEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_CTRL_INTERNAL_SPLIT_PANEL_EVENT_H_ +#define _FUI_CTRL_INTERNAL_SPLIT_PANEL_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _SplitPanel; + +enum _SplitPanelEventStatus +{ + _SPLIT_PANEL_EVENT_DIVIDER_POSITION_CHANGE = 0, + _SPLIT_PANEL_EVENT_DIVIDER_DOUBLE_PRESSED +}; + + +/** +* @class _SplitPanelEvent +* @brief This class handles a action event. It is inherited from Event class. +* +* The Window(root of all widgets) class has an instance of the _SplitPanelEvent class as a member variable. +* Applications can register splitpanel event listeners through it. When a splitpanel event occurred, +* the _SplitPanelEvent class finds listener and calls the appropriate listener's method. +* +*/ +class _SplitPanelEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_SplitPanelEvent(void); + + static _SplitPanelEvent* CreateInstanceN(const _SplitPanel& source); + +// Accessors + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const _SplitPanel* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateSplitPanelEventArgN(_SplitPanelEventStatus status); + +// Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _SplitPanelEvent(const _SplitPanel& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @return This method returns a result code. + * @param[in] pListener It is a event listener related to this action event. + * @param[in] arg It is an argument-like instance of action event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IActionEventListener class or + * the p__SplitPanelEventArg is not the instance of _SplitPanelEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attributess +private: + const _SplitPanel* __pSource; + +}; // _SplitPanelEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SPLIT_PANEL_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_SplitPanelImpl.h b/src/ui/inc/FUiCtrl_SplitPanelImpl.h new file mode 100644 index 0000000..c90c794 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SplitPanelImpl.h @@ -0,0 +1,104 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SplitPanelImpl.h + * @brief This is the header file for the _SplitPanelImpl class. + * + * This header file contains the declarations of the %_SplitPanelImpl class. + */ +#ifndef _FUI_CTRL_INTERNAL_SPLIT_PANEL_IMPL_H_ +#define _FUI_CTRL_INTERNAL_SPLIT_PANEL_IMPL_H_ + +#include +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_SplitPanel.h" +#include "FUiCtrl_ISplitPanelEventListener.h" +#include "FUiCtrl_PublicSplitPanelEvent.h" + +namespace Tizen { namespace Graphics +{ + class Dimension; +}} //Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _SplitPanelImpl + : public _ControlImpl + , public _ISplitPanelEventListener +{ + +// Lifecycle +public: + virtual ~_SplitPanelImpl(void); + static _SplitPanelImpl* CreateSplitPanelImplN(SplitPanel* pControl, const Tizen::Graphics::Rectangle& rect, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection); + + result Initialize(const Tizen::Graphics::Rectangle& rect); + + virtual const char* GetPublicClassName(void) const; + virtual const SplitPanel& GetPublic(void) const; + virtual SplitPanel& GetPublic(void); + virtual const _SplitPanel& GetCore(void) const; + virtual _SplitPanel& GetCore(void); + +public: + + virtual void OnDividerPositionChanged(_SplitPanel& source, int position); + virtual void OnDividerDoublePressed(_SplitPanel& source); + + result AddSplitPanelEventListener(ISplitPanelEventListener& listener); + result RemoveSplitPanelEventListener(ISplitPanelEventListener& listener); + + result SetPane(_ControlImpl* pControl, SplitPanelPaneOrder paneOrder); + _ControlImpl* GetPane(SplitPanelPaneOrder paneOrder) const; + + result SetDividerPosition(int position); + int GetDividerPosition(void) const; + + result SetMaximumDividerPosition(int position); + int GetMaximumDividerPosition(void) const; + + result SetMinimumDividerPosition(int position); + int GetMinimumDividerPosition(void) const; + + result MaximizePane(SplitPanelPaneOrder paneOrder); + bool IsPaneMaximized(SplitPanelPaneOrder paneOrder) const; + result RestorePane(void); + +//Constants +public: + static _SplitPanelImpl* GetInstance(SplitPanel& pSplitPanel); + static const _SplitPanelImpl* GetInstance(const SplitPanel& pSplitPanel); + +private: + _SplitPanelImpl(SplitPanel* pPublic, _SplitPanel* pCore); + + _SplitPanelImpl(const _SplitPanelImpl& rhs); + _SplitPanelImpl& operator =(const _SplitPanelImpl& rhs); + +private: + _SplitPanel* __pSplitPanel; + _PublicSplitPanelEvent* __pPublicSplitPanelEvent; + +}; // _SplitPanelImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_SPLIT_PANEL_IMPL_H_ + + diff --git a/src/ui/inc/FUiCtrl_SplitPanelModel.h b/src/ui/inc/FUiCtrl_SplitPanelModel.h new file mode 100644 index 0000000..d22b6a4 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SplitPanelModel.h @@ -0,0 +1,68 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SplitPanelModel.h + * @brief This is the header file for the _SplitPanelModel class. + * + * This header file contains the declarations of the %_SplitPanelModel class. + */ +#ifndef _FUICTRL_INTERNAL_SPLIT_PANEL_MODEL_H_ +#define _FUICTRL_INTERNAL_SPLIT_PANEL_MODEL_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _SplitPanelModel + : public Tizen::Base::Object +{ +// Lifecycle +public: + _SplitPanelModel(void); + virtual ~_SplitPanelModel(void); + + result Construct(void); + +// Operations +public: + void SetDividerStyle(SplitPanelDividerStyle splitPanelDividerStyle); + SplitPanelDividerStyle GetDividerStyle(void) const; + + void SetPaneMaximumState(bool bMaximum); + bool GetPaneMaximumState(void) const; + + void SetMaximizedPaneOrder(SplitPanelPaneOrder paneOrder); + SplitPanelPaneOrder GetMaximizedPaneOrder(void) const; + +private: + _SplitPanelModel(const _SplitPanelModel&); + _SplitPanelModel& operator =(const _SplitPanelModel&); + +// Attribute +private: + SplitPanelDividerStyle __dividerStyle; + bool __isPaneMaximized; + SplitPanelPaneOrder __maximizedPaneOrder; + +}; // _SplitPanelModel + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_SPLIT_PANEL_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_SplitPanelPresenter.h b/src/ui/inc/FUiCtrl_SplitPanelPresenter.h new file mode 100644 index 0000000..5619bd8 --- /dev/null +++ b/src/ui/inc/FUiCtrl_SplitPanelPresenter.h @@ -0,0 +1,143 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_SplitPanelPresenter.h + * @brief This is the header file for the _SplitPanelPresenter class. + * + * This header file contains the declarations of the %_SplitPanelPresenter class. + */ + +#ifndef _FUICTRL_INTERNAL_SPLIT_PANEL_PRESENTER_H_ +#define _FUICTRL_INTERNAL_SPLIT_PANEL_PRESENTER_H_ + +#include +#include "FUi_Control.h" +#include "FUiCtrl_SplitPanelModel.h" +#include "FUi_ITouchTapGestureEventListener.h" +#include "FUiAnimations.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +class _SplitPanel; + +enum _SplitPanelAnimationDirection +{ + _SPLIT_PANEL_ANIMATION_RIGHT = 0, + _SPLIT_PANEL_ANIMATION_LEFT, + _SPLIT_PANEL_ANIMATION_TOP, + _SPLIT_PANEL_ANIMATION_BOTTOM, + _SPLIT_PANEL_ANIMATION_RESTORE_HORIZONTAL, + _SPLIT_PANEL_ANIMATION_RESTORE_VERTICAL, + _SPLIT_PANEL_ANIMATION_MAX +}; + +const long ANIMATION_DURATION = 1000; +const float ANIMATION_ALPHA_HIDE = 0.0; +const float ANIMATION_ALPHA_SHOW = 1.0; + +class _SplitPanelPresenter + : public Tizen::Base::Object + , public Tizen::Ui::_ITouchTapGestureEventListener +{ +// Lifecycle +public: + _SplitPanelPresenter(void); + virtual ~_SplitPanelPresenter(void); + +// Operations + virtual result Construct(const _SplitPanel& splitPanel, SplitPanelDividerStyle splitPanelDividerStyle, SplitPanelDividerDirection splitPanelDividerDirection); + bool CheckDividerTouchRegion(int positionX, int positionY); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnTapGestureDetected(_TouchTapGestureDetector& gesture); + virtual bool OnTapGestureCanceled(_TouchTapGestureDetector& gesture); + + result SetDividerStyle(SplitPanelDividerStyle splitPanelDividerStyle); + SplitPanelDividerStyle GetDividerStyle(void) const; + + Tizen::Graphics::Rectangle GetDividerRectangle(void) const; + + result MaximizePane(SplitPanelPaneOrder paneOrder); + bool IsPaneMaximized(SplitPanelPaneOrder paneOrder) const; + result RestorePane(void); + + result Draw(void); + + result LoadBitmap(SplitPanelDividerDirection splitPanelDividerDirection); + + void RecalcSplitPanel(void); + + void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + + void OnBoundsChanged(void); + +protected: + result SetModel(const _SplitPanelModel& splitPanelModel); + +private: + result SetPaneBounds(void); + void AdjustDividerRectangle(void); + + // Animation + void ChangePaneOrder(SplitPanelPaneOrder paneOrder); + result AnimateDivider(int destination); + result AnimatePane(int destination); + Tizen::Ui::Control* GetPaneControl(SplitPanelPaneOrder paneOrder); + Tizen::Ui::Animations::AnimatorStatus GetAnimationStatus(void); + Tizen::Graphics::Rectangle GetRestorePaneBounds(SplitPanelPaneOrder paneOrder); + +private: + _SplitPanelPresenter(const _SplitPanelPresenter& value); + _SplitPanelPresenter& operator =(const _SplitPanelPresenter& value); + +private: + _SplitPanel* __pSplitPanel; + _SplitPanelModel* __pSplitPanelModel; + + int __dividerMaximumPosition; + int __dividerMinimumPosition; + bool __splitPanelDividerPressed; + bool __setFirstDividerPositionChangeEvent; + + Tizen::Graphics::Rectangle __dividerRectangle; + Tizen::Graphics::Rectangle __dividerThumbRectangle; + Tizen::Graphics::Bitmap* __pDividerPressedBackgroundBitmap; + Tizen::Graphics::Bitmap* __pDividerBackgroundBitmap; + Tizen::Graphics::Bitmap* __pDividerBackgroundEffectBitmap; + Tizen::Graphics::Bitmap* __pDividerThumbBitmap; + Tizen::Graphics::Color __dividerBackgroundColor; + Tizen::Graphics::Color __dividerPressedBackgroundColor; + + // Animation + int __transactionIdMaximize; + int __transactionIdRestore; + + Tizen::Ui::Animations::AnimationInterpolatorType __controlAnimatorAnimationInterpolator; + Tizen::Base::String __visualElementAnimationInterpolator; + +}; // _SplitPanelPresenter; + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_SPLIT_PANEL_PRESENTER_H_ + + + diff --git a/src/ui/inc/FUiCtrl_Tab.h b/src/ui/inc/FUiCtrl_Tab.h new file mode 100644 index 0000000..f64cbd7 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Tab.h @@ -0,0 +1,242 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Tab.h + * @brief This is the header file for the _Tab class. + * + * This header file contains the declarations of the %_Tab class. + */ +#ifndef _FUICTRL_INTERNAL_TAB_H_ +#define _FUICTRL_INTERNAL_TAB_H_ + + +#include +#include "FUi_Control.h" +#include "FUi_ITouchLongPressGestureEventListener.h" +#include "FUi_ITouchFlickGestureEventListener.h" +#include "FUi_IAccessibilityListener.h" +#include "FUiCtrl_ActionEvent.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_TabItem.h" +#include "FUiCtrl_TabPresenter.h" + +const int _TAB_STATE = 6; +const int _TAB_ACTION_ID_MIN = 0; +const int _TAB_ACTION_ID_MAX = 999; +const int _TAB_ITEM_MAXCOUNT = 14; // 3 Line + +namespace Tizen { namespace Ui { namespace Controls { + + class _PublicActionEvent; + class _TabPresenter; + class _TabItem; + +// enum +enum _TabStatus +{ + _TAB_STATUS_NORMAL = 0, /** The normal status */ + _TAB_STATUS_PRESSED, /** The pressed status */ + _TAB_STATUS_SELECTED, /** The selected status */ + _TAB_STATUS_HIGHLIGHTED, /** The focused status */ + _TAB_STATUS_DISABLED, /** The disabled status */ + + _TAB_STATUS_MAX +}; + +enum _TabStyle +{ + _TAB_STYLE_TEXT, + _TAB_STYLE_ICON, + _TAB_STYLE_ICON_TEXT +}; + + +/** + * @class _Tab + * @brief + * @since 2.0 + * + * + * + * + */ +class _OSP_EXPORT_ _Tab + : public Tizen::Ui::_Control + , public Tizen::Ui::_ITouchLongPressGestureEventListener + , public Tizen::Ui::_IAccessibilityListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer + , virtual public Tizen::Ui::_ITouchGestureEventListener + , virtual public Tizen::Ui::_ITouchFlickGestureEventListener +{ +private: + _Tab(const _Tab& value); + _Tab& operator=(const _Tab& value); + +public: + _Tab(void); + virtual ~_Tab(void); + +public: + static _Tab* CreateTabN(void); + +protected: + result SetPresenter(const _TabPresenter& tabPresenter); + + +public: + result AddItem(const Tizen::Graphics::Bitmap& icon, const Tizen::Base::String& text, int actionId); + result AddItem(const Tizen::Graphics::Bitmap& icon, int actionId); + result AddItem(const Tizen::Base::String& text, int actionId); + + result InsertItemAt(int index, const Tizen::Graphics::Bitmap& icon, const Tizen::Base::String& text, int actionId); + result InsertItemAt(int index, const Tizen::Graphics::Bitmap& icon, int actionId); + result InsertItemAt(int index, const Tizen::Base::String& text, int actionId); + + result SetItemAt(int index, const Tizen::Graphics::Bitmap& icon, const Tizen::Base::String& text, int actionId); + result SetItemAt(int index, const Tizen::Graphics::Bitmap& icon, int actionId); + result SetItemAt(int index, const Tizen::Base::String& text, int actionId); + + result RemoveItemAt(int index); + result RemoveAllItems(void); + + bool ChangeItemAt(const int srcIndex, const int destIndex); + + result SetBadgeIcon(int actionId, const Tizen::Graphics::Bitmap* pBadgeIcon); + + int GetItemCount(void) const; + + int GetItemIndexFromActionId(int actionId) const; + int GetItemActionIdAt(int index) const; + + _TabItem* GetItemAt(int index); + + + void SetSelectedItemIndex(int index); + int GetSelectedItemIndex(void) const; + + void SetFirstDrawnItemIndex(int index); + int GetFirstDrawnItemIndex(void) const; + + void SetEditModeEnabled(bool enable); + bool IsEditModeEnabled(void) const; + + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + Tizen::Graphics::Bitmap* GetBackgroundBitmap(void) const; + + result SetPressedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + Tizen::Graphics::Bitmap* GetPressedItemBackgroundBitmap(void) const; + + result SetSelectedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + Tizen::Graphics::Bitmap* GetSelectedItemBackgroundBitmap(void) const; + + result SetHighlightedItemBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + Tizen::Graphics::Bitmap* GetHighlightedItemBackgroundBitmap(void) const; + + void SetItemBackgroundColor(Tizen::Graphics::Color color); + Tizen::Graphics::Color GetItemBackgroundColor(void) const; + + void SetPressedItemBackgroundColor(Tizen::Graphics::Color color); + Tizen::Graphics::Color GetPressedItemBackgroundColor(void) const; + + void SetSelectedItemBackgroundColor(Tizen::Graphics::Color color); + Tizen::Graphics::Color GetSelectedItemBackgroundColor(void) const; + + void SetHighlightedItemBackgroundColor(Tizen::Graphics::Color color); + Tizen::Graphics::Color GetHighlightedItemBackgroundColor(void) const; + + void SetTextColor(const Tizen::Graphics::Color& textColor); + Tizen::Graphics::Color GetTextColor(void) const; + + void SetPressedTextColor(const Tizen::Graphics::Color& textColor); + Tizen::Graphics::Color GetPressedTextColor(void) const; + + void SetSelectedTextColor(const Tizen::Graphics::Color& textColor); + Tizen::Graphics::Color GetSelectedTextColor(void) const; + + void SetHighlightedTextColor(const Tizen::Graphics::Color& textColor); + Tizen::Graphics::Color GetHighlightedTextColor(void) const; + + void SetStyle(int style); + _TabStyle GetStyle(void) const; + + void AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); + void RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture); + virtual bool OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture); + + virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture); + virtual bool OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture); + + virtual void OnDraw(void); + result OnAttachedToMainTree(void); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + virtual void OnBoundsChanged(void); + + void AddAccessibilityElement(const Tizen::Graphics::Rectangle& itemBounds, const Tizen::Base::String& itemText, _TabItemStatus status); + void RemoveAllAccessibilityElement(void); + + // accessibility listener + virtual bool OnAccessibilityFocusMovedNext(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityFocusMovedPrevious(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityReadElement(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityFocusIn(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityFocusOut(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityActionPerformed(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&); + virtual bool OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&); + +private: + int GetItemIndex(int actionId); + bool CheckDuplicatedActionId(int actionId); + result LoadBitmap(void); + +private: + _TabPresenter* __pTabPresenter; + + int __style; + _TabStatus __tabStatus; + Tizen::Base::Collection::ArrayList __tabItems; + + Tizen::Ui::Controls::_ActionEvent* __pActionEvent; + + _TouchLongPressGestureDetector* __pGestureLongPress; + _TouchFlickGestureDetector* __pFlickGesture; + + Tizen::Graphics::Bitmap* __pBackgroundBitmap; + Tizen::Graphics::Bitmap* __pPressedItemBackgroundBitmap; + Tizen::Graphics::Bitmap* __pSelectedItemBackgroundBitmap; + Tizen::Graphics::Bitmap* __pHighlightedItemBackgroundBitmap; + + Tizen::Graphics::Color __itemBgColor[_TAB_STATE]; + Tizen::Graphics::Color __itemTextColor[_TAB_STATE]; + + Tizen::Base::Collection::LinkedListT<_AccessibilityElement*> __accessibilityElements; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_TAB_H_ + diff --git a/src/ui/inc/FUiCtrl_TabBar.h b/src/ui/inc/FUiCtrl_TabBar.h new file mode 100644 index 0000000..1cdc7d6 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TabBar.h @@ -0,0 +1,165 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabBar.h + * @brief This is the header file for the _TabBar class. + * + * This header file contains the declarations of the %_TabBar class. + */ +#ifndef _FUI_CTRL_INTERNAL_TABBAR_H_ +#define _FUI_CTRL_INTERNAL_TABBAR_H_ + + +#include "FUi_Control.h" +#include "FUiCtrl_TabBarItem.h" +#include "FUiCtrl_TabBarPresenter.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_ActionEvent.h" + +namespace Tizen { namespace Ui { +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _TabBarPresenter; + +/** + * @class _TabBar + * @brief + * @since 2.0 + * + * + * + * + */ +class _OSP_EXPORT_ _TabBar + : public Tizen::Ui::_Control + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ + DECLARE_CLASS_BEGIN(_TabBar, _Control); + DECLARE_PROPERTY("color", GetPropertyColor, SetPropertyColor); + DECLARE_PROPERTY("normalItemColor", GetPropertyNormalItemColor, SetPropertyNormalItemColor); + DECLARE_PROPERTY("selectedItemColor", GetPropertySelectedItemColor, SetPropertySelectedItemColor); + DECLARE_PROPERTY("highlightedItemColor", GetPropertyHighlightedItemColor, SetPropertyHighlightedItemColor); + DECLARE_PROPERTY("normalItemTextColor", GetPropertyNormalItemTextColor, SetPropertyNormalItemTextColor); + DECLARE_PROPERTY("selectedItemTextColor", GetPropertySelectedItemTextColor, SetPropertySelectedItemTextColor); + DECLARE_PROPERTY("highlightedItemTextColor", GetPropertyHighlightedItemTextColor, SetPropertyHighlightedItemTextColor); + DECLARE_CLASS_END(); + +// Properties + result SetPropertyColor(const Variant& color); + Variant GetPropertyColor(void) const; + + result SetPropertyNormalItemColor(const Variant& color); + Variant GetPropertyNormalItemColor(void) const; + + result SetPropertySelectedItemColor(const Variant& color); + Variant GetPropertySelectedItemColor(void) const; + + result SetPropertyHighlightedItemColor(const Variant& color); + Variant GetPropertyHighlightedItemColor(void) const; + + result SetPropertyNormalItemTextColor(const Variant& color); + Variant GetPropertyNormalItemTextColor(void) const; + + result SetPropertySelectedItemTextColor(const Variant& color); + Variant GetPropertySelectedItemTextColor(void) const; + + result SetPropertyHighlightedItemTextColor(const Variant& color); + Variant GetPropertyHighlightedItemTextColor(void) const; + +// Lifecycle +public: + virtual ~_TabBar(void); + +// Operations +public: + static _TabBar* CreateTabBarN(void); + result Initialize(void); + result AddItem(const Tizen::Base::String& text, int actionId); + result InsertItemAt(int index, const Tizen::Base::String& text, int actionId); + result SetItemAt(int index, const Tizen::Base::String& text, int actionId); + result RemoveItemAt(int index); + result RemoveAllItems(void); + + result SetColor(Tizen::Graphics::Color color); + Tizen::Graphics::Color GetColor(void) const; + + result SetItemColor(_TabBarItemStatus itemStatus, Tizen::Graphics::Color color); + Tizen::Graphics::Color GetItemColor(_TabBarItemStatus itemStatus) const; + + void SetItemTextColor(_TabBarItemStatus status, Tizen::Graphics::Color color); + Tizen::Graphics::Color GetItemTextColor(_TabBarItemStatus status) const; + + result SetItemSelected(int index); + int GetSelectedItemIndex(void) const; + + _TabBarItem* GetItemFromPosition(const Tizen::Graphics::Point& position) const; + result SetTopDrawnItemIndex(int index); + + int GetItemCount(void) const; + + result SetWidth(int width); + + void AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); + void RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); + + Tizen::Ui::_AccessibilityElement* GetAccessibilityElement(const int mainIndex) const; + void AddAccessibilityElement(const _AccessibilityElement& element); + + virtual void OnDraw(void); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual void OnBoundsChanged(void); + +protected: + result SetPresenter(const _TabBarPresenter& tabBarPresenter); + +private: + void SetAllAccessibilityElement(void); + void RemoveAllAccessibilityElement(void); + +private: + _TabBar(void); + + _TabBar(const _TabBar& rhs); + _TabBar& operator =(const _TabBar& rhs); + +// Attribute +private: + _TabBarPresenter* __pTabBarPresenter; + + _ActionEvent* __pActionEvent; + + Tizen::Graphics::Color __color; + Tizen::Graphics::Color __itemColor[ITEM_STATUS_MAX]; + Tizen::Graphics::Color __itemTextColor[ITEM_STATUS_MAX]; + Tizen::Base::Collection::LinkedListT<_AccessibilityElement*> __accessibilityElements; +}; // _TabBar + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TABBAR_H_ diff --git a/src/ui/inc/FUiCtrl_TabBarImpl.h b/src/ui/inc/FUiCtrl_TabBarImpl.h new file mode 100644 index 0000000..67d27dc --- /dev/null +++ b/src/ui/inc/FUiCtrl_TabBarImpl.h @@ -0,0 +1,97 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_CTRL_INTERNAL_TABBAR_IMPL_H_ +#define _FUI_CTRL_INTERNAL_TABBAR_IMPL_H_ + +#include +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_TabBar.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_PublicActionEvent.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _TabBarImpl + : public _ControlImpl + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ + +//Constants +public: + class TabBarSizeInfo : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + }; + +public: + virtual ~_TabBarImpl(void); + + static _TabBarImpl* CreateTabBarImplN(TabBar* pTabBar, const Tizen::Graphics::Rectangle& bounds); + + result AddItem(const Tizen::Base::String& text, int actionId); + result InsertItemAt(int index, const Tizen::Base::String& text, int actionId); + result SetItemAt(int index, const Tizen::Base::String& text, int actionId); + result RemoveItemAt(int index); + result RemoveAllItems(void); + + + result SetColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetColor(void) const; + + result SetSelectedItemColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetSelectedItemColor(void) const; + + result SetItemTextColor(TabBarItemStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetItemTextColor(TabBarItemStatus status) const; + + result SetItemSelected(int index); + int GetSelectedItemIndex(void) const; + + int GetItemCount(void) const; + + result SetWidth(int width); + + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + static _TabBarImpl* GetInstance(TabBar& tabBar); + static const _TabBarImpl* GetInstance(const TabBar& tabBar); + + virtual TabBar& GetPublic(void); + virtual const TabBar& GetPublic(void) const; + virtual const char* GetPublicClassName(void) const; + virtual const _TabBar& GetCore(void) const; + virtual _TabBar& GetCore(void); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + +private: + _TabBarImpl(TabBar* pTabBar, _TabBar* pCore); + + _TabBarImpl(const _TabBarImpl& rhs); + _TabBarImpl& operator =(const _TabBarImpl& rhs); + + _PublicActionEvent* __pPublicActionEvent; +}; // _TabBarImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_TABBAR_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_TabBarItem.h b/src/ui/inc/FUiCtrl_TabBarItem.h new file mode 100644 index 0000000..815506c --- /dev/null +++ b/src/ui/inc/FUiCtrl_TabBarItem.h @@ -0,0 +1,97 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabBarItem.h + * @brief This is the header file for the _TabBarItem class. + * + * This header file contains the declarations of the %_TabBarItem class. + */ +#ifndef _FUI_CTRL_INTERNAL_TABBAR_ITEM_H_ +#define _FUI_CTRL_INTERNAL_TABBAR_ITEM_H_ + + +#include +#include +#include +#include "FUi_Control.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum _TabBarItemStatus +{ + ITEM_STATUS_NORMAL = 0, + ITEM_STATUS_SELECTED, + ITEM_STATUS_HIGHLIGHTED, + ITEM_STATUS_MAX +}; +/** + * @class _TabBarItem + * @brief + * @since 1.0 + * + * + * + * + */ +class _TabBarItem + : public Tizen::Base::Object +{ +// Lifecycle +public: + _TabBarItem(_ControlOrientation orientation); + + ~_TabBarItem(void); + +// Operations +public: + void SetActionId(int actionId); + + int GetActionId(void) const; + + void SetText(const Tizen::Base::String& text, _ControlOrientation orientation); + + Tizen::Base::String GetText(void) const; + + void SetStatus(_TabBarItemStatus status); + + _TabBarItemStatus GetStatus(void) const; + + void SetBounds(const Tizen::Graphics::Rectangle& bounds); + + Tizen::Graphics::Rectangle GetBounds(void) const; + +private: + _TabBarItem(const _TabBarItem& rhs); + _TabBarItem& operator =(const _TabBarItem& rhs); + +// Attribute +private: + int __actionId; + + Tizen::Base::String __text; + + _TabBarItemStatus __status; + + Tizen::Graphics::Rectangle __bounds; + +}; // _TabBarItem + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TABBAR_ITEM_H_ diff --git a/src/ui/inc/FUiCtrl_TabBarItemImpl.h b/src/ui/inc/FUiCtrl_TabBarItemImpl.h new file mode 100644 index 0000000..4669205 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TabBarItemImpl.h @@ -0,0 +1,52 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabBarItemImpl.h + * @brief This is the header file for the _TabBarItemImpl class. + * + * This header file contains the declarations of the _TabBarItemImpl class. + */ +#ifndef _FUI_CTRL_INTERNAL_TAB_BAR_ITEM_IMPL_H_ +#define _FUI_CTRL_INTERNAL_TAB_BAR_ITEM_IMPL_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _TabBarItemImpl + : public Tizen::Base::Object +{ +public: + _TabBarItemImpl(void); + virtual ~_TabBarItemImpl(void); + + void SetText(const Tizen::Base::String& text); + Tizen::Base::String GetText(void) const; + + void SetActionId(int actionId); + int GetActionId(void) const; + +private: + Tizen::Base::String __text; + int __actionId; + +}; // _TabBarItemImpl + +}}} // Tizen::Ui::Controls +#endif // _FUI_CTRL_INTERNAL_TAB_BAR_ITEM_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_TabBarModel.h b/src/ui/inc/FUiCtrl_TabBarModel.h new file mode 100644 index 0000000..e74f66d --- /dev/null +++ b/src/ui/inc/FUiCtrl_TabBarModel.h @@ -0,0 +1,85 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabBarModel.h + * @brief This is the header file for the _TabBarModel class. + * + * This header file contains the declarations of the %_TabBarModel class. + */ +#ifndef _FUI_CTRL_INTERNAL_TABBAR_MODEL_H_ +#define _FUI_CTRL_INTERNAL_TABBAR_MODEL_H_ + + +#include +#include +#include "FUiCtrl_TabBarItem.h" +#include "FUi_ResourceManager.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +/** + * @class _TabBarModel + * @brief + * @since 2.0 + * + * + * + * + */ +class _TabBarModel + : public Tizen::Base::Object +{ +// Lifecycle +public: + _TabBarModel(void); + virtual ~_TabBarModel(void); + +// Operations +public: + void SetSelectedItemIndex(int index); + int GetSelectedItemIndex(void) const; + void SetFirstDrawnItemIndex(int index); + int GetFirstDrawnItemIndex(void) const; + int GetItemCount(void) const; + int GetWidthOfAllItems(void) const; + + result AddItem(const Tizen::Base::String& text, int actionId, _ControlOrientation orientation); + result InsertItemAt(int index, const Tizen::Base::String& text, int actionId, _ControlOrientation orientation); + result SetItemAt(int index, const Tizen::Base::String& text, int actionId, _ControlOrientation orientation); + result RemoveItemAt(int index, _ControlOrientation orientation); + void RemoveAllItems(void); + + _TabBarItem* GetItemAt(int index) const; + +private: + _TabBarModel(const _TabBarModel& rhs); + _TabBarModel& operator =(const _TabBarModel& rhs); + result ReCalculateItemPosition(int itemIndex, _ControlOrientation orientation); + +// Attribute +private: + Tizen::Base::Collection::ArrayList __tabBarItems; + + int __selectedItemIndex; + int __firstDrawnItemIndex; + int __widthOfAllItems; + +}; // _TabBarModel + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TABBAR_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_TabBarPresenter.h b/src/ui/inc/FUiCtrl_TabBarPresenter.h new file mode 100644 index 0000000..4570b8c --- /dev/null +++ b/src/ui/inc/FUiCtrl_TabBarPresenter.h @@ -0,0 +1,128 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabBarPresenter.h + * @brief This is the header file for the _TabBarPresenter class. + * + * This header file contains the declarations of the %_TabBarPresenter class. + */ +#ifndef _FUI_CTRL_INTERNAL_TABBAR_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_TABBAR_PRESENTER_H_ + + +#include +#include +#include "FUi_Control.h" +#include "FUiCtrl_TabBar.h" +#include "FUiCtrl_TabBarItem.h" +#include "FUiCtrl_TabBarModel.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ +class _TabBar; + +/** + * @class _TabBarPresenter + * @brief + * @since 2.0 + * + * + * + * + */ +class _TabBarPresenter + : public Tizen::Base::Object +{ +// Lifecycle +public: + _TabBarPresenter(_TabBar& pTabBar); + virtual ~_TabBarPresenter(void); + +// Operations +public: + result Construct(void); + result InitializeFont(void); + + result AddItem(const Tizen::Base::String& text, int actionId); + result InsertItemAt(int index, const Tizen::Base::String& text, int actionId); + result SetItemAt(int index, const Tizen::Base::String& text, int actionId); + _TabBarItem* GetItemAt(int index) const; + result RemoveItemAt(int index); + result RemoveAllItems(void); + + result SetItemSelected(int index); + int GetSelectedItemIndex(void) const; + + int GetItemCount(void) const; + int GetItemIndexFromPosition(const Tizen::Graphics::Point& point) const; + _TabBarItem* GetItemFromPosition(const Tizen::Graphics::Point& position) const; + result SetTopDrawnItemIndex(int index); + + result SetReplacementColor(const Tizen::Graphics::Color& color); + result SetItemReplacementColor(_TabBarItemStatus itemStatus, const Tizen::Graphics::Color& color); + + void Draw(void); + void InitItemPositionX(void); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + void OnBoundsChanged(void); + + void SetAllAccessibilityElement(void); + +private: + result LoadBitmap(void); + result AdjustItemPositionX(int distance); + _TabBarItemStatus GetItemStatus(int index) const; + result SetItemStatus(int index, _TabBarItemStatus status); + void DrawBackground(Tizen::Graphics::Canvas* pCanvas); + void DrawItem(Tizen::Graphics::Canvas* pCanvas); + void DrawArrow(Tizen::Graphics::Canvas* pCanvas); + result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap); + +private: + _TabBarPresenter(const _TabBarPresenter& rhs); + _TabBarPresenter& operator =(const _TabBarPresenter& rhs); + +private: + _TabBar& __tabBar; + _TabBarModel* __pTabBarModel; + + Tizen::Graphics::Font* __pFont; + Tizen::Graphics::_Text::TextObject* __pTextObject; + Tizen::Graphics::Point __startPosition; + int __highlightedItemIndex; + bool __touchMoved; + bool __touchBubblingBlocked; + Tizen::Graphics::Bitmap* __pBgBitmapCached; + + Tizen::Graphics::Bitmap* __pItemBgBitmapCached[ITEM_STATUS_MAX]; + + Tizen::Graphics::Bitmap* __pLeftArrowBgBitmapCached; + Tizen::Graphics::Bitmap* __pRightArrowBgBitmapCached; + Tizen::Graphics::Bitmap* __pLeftArrowBitmapCached; + Tizen::Graphics::Bitmap* __pRightArrowBitmapCached; +}; // _TabBarPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TABBAR_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_TabImpl.h b/src/ui/inc/FUiCtrl_TabImpl.h new file mode 100644 index 0000000..4a67c30 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TabImpl.h @@ -0,0 +1,137 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabImpl.h + * @brief This is the header file for the _TabImpl class. + * + * This header file contains the declarations of the %_TabImpl class. + */ + +#ifndef _FUICTRL_TAB_IMPL_H_ +#define _FUICTRL_TAB_IMPL_H_ + +#include +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_Tab.h" +#include "FUiCtrl_IActionEventListener.h" +#include "FUiCtrl_PublicActionEvent.h" + +namespace Tizen { namespace Ui { namespace Controls { + + class _PublicActionEvent; + +/** + * @class _TabImpl + * @brief + * @since 2.0 + * + * + * + * + */ +class _TabImpl + : public _ControlImpl + , public _IActionEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + static _TabImpl* CreateTabImplN(Tab* pPublic); + virtual ~_TabImpl(void); + + virtual const char* GetPublicClassName(void) const; + + Tab* GetTab(void); + + virtual Tab& GetPublic(void); + virtual const Tab& GetPublic(void) const; + + virtual const _Tab& GetCore(void) const; + virtual _Tab& GetCore(void); + +private: + _TabImpl(Tab* pPublic, _Tab* pCore); + + _TabImpl(const _TabImpl& value); + _TabImpl& operator =(const _TabImpl& value); + +public: + static _TabImpl* GetInstance(Tab& pControl); + static const _TabImpl* GetInstance(const Tab& pControl); + + static Tab* CreateTabN(void); + static void DeleteTab(Tab* pTab); + + virtual bool IsMovable(void) const; + virtual bool IsResizable(void) const; + + + result AddItem(const Tizen::Graphics::Bitmap& icon, const Tizen::Base::String& text, int actionId); + result AddItem(const Tizen::Graphics::Bitmap& icon, int actionId); + result AddItem(const Tizen::Base::String& text, int actionId); + + result InsertItemAt(int index, const Tizen::Graphics::Bitmap& icon, const Tizen::Base::String& text, int actionId); + result InsertItemAt(int index, const Tizen::Graphics::Bitmap& icon, int actionId); + result InsertItemAt(int index, const Tizen::Base::String& text, int actionId); + + result SetItemAt(int index, const Tizen::Graphics::Bitmap& icon, const Tizen::Base::String& text, int actionId); + result SetItemAt(int index, const Tizen::Graphics::Bitmap& icon, int actionId); + result SetItemAt(int index, const Tizen::Base::String& text, int actionId); + + result RemoveItemAt(int index); + result RemoveAllItems(void); + + result SetBadgeIcon(int actionId, const Tizen::Graphics::Bitmap* pBadgeIcon); + + int GetItemCount(void) const; + + int GetItemIndexFromActionId(int actionId) const; + int GetItemActionIdAt(int index) const; + + void SetSelectedItem(int index); + int GetSelectedItemIndex(void) const; + + void SetEditModeEnabled(bool enable); + bool IsEditModeEnabled(void) const; + + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + result SetFocusedItemBackgroundBitmap (const Tizen::Graphics::Bitmap& bitmap); + + void SetTextColor(const Tizen::Graphics::Color& textColor); + Tizen::Graphics::Color GetTextColor(void) const; + + void SetSelectedTextColor(const Tizen::Graphics::Color& textColor); + Tizen::Graphics::Color GetSelectedTextColor(void) const; + + result SetHighlightedItemBackgroundBitmap (const Tizen::Graphics::Bitmap& bitmap); + + void SetHighlightedTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetHighlightedTextColor(void) const; + + void AddActionEventListener(Tizen::Ui::IActionEventListener& listener); + void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener); + + virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId); + +private: + _PublicActionEvent* __pActionEvent; + +}; + +}}} // Tizen::Ui::Controls + +#endif //_FUICTRL_TAB_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_TabItem.h b/src/ui/inc/FUiCtrl_TabItem.h new file mode 100644 index 0000000..fc96dc1 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TabItem.h @@ -0,0 +1,120 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabItem.h + * @brief This is the header file for the _TabItem class. + * + * This header file contains the declarations of the %_Tab class. + */ + +#ifndef _FUICTRL_INTERNAL_TABITEM_H_ +#define _FUICTRL_INTERNAL_TABITEM_H_ + +#include +#include +#include + +namespace Tizen { namespace Graphics { + class Bitmap; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Controls { + +// enum +enum _TabItemStatus +{ + _TABITEM_STATUS_NORMAL = 0, /** The normal status */ + _TABITEM_STATUS_PRESSED, /** The pressed status */ + _TABITEM_STATUS_SELECTED, /** The selected status */ + _TABITEM_STATUS_HIGHLIGHTED, /** The focused status */ + _TABITEM_STATUS_DISABLED, /** The disabled status */ + + _TABITEM_STATUS_MAX +}; + +enum _TabItemStyle +{ + _TABITEM_STYLE_TEXT, + _TABITEM_STYLE_ICON, + _TABITEM_STYLE_ICON_TEXT +}; + +/** + * @class _TabItem + * @brief + * @since 2.0 + * + * + * + * + */ +class _TabItem + : public Tizen::Base::Object +{ +private: + _TabItem(const _TabItem& value); + _TabItem& operator =(const _TabItem& value); + +public: + _TabItem(void); + virtual ~_TabItem(void); + +public: + void SetActionId(int actionId); + int GetActionId(void) const; + + void SetUpdateState(bool bUpdate); + int GetUpdateState(void) const; + + void SetText(const Tizen::Base::String& text); + Tizen::Base::String GetText(void) const; + + void SetIcon(const Tizen::Graphics::Bitmap& icon); + Tizen::Graphics::Bitmap* GetIcon(void) const; + + void SetBadgeIcon(const Tizen::Graphics::Bitmap& icon); + Tizen::Graphics::Bitmap* GetBadgeIcon(void) const; + + void SetItemBounds(Tizen::Graphics::Rectangle bounds); + Tizen::Graphics::Rectangle GetItemBounds(void) const; + + void SetStatus(_TabItemStatus status); + _TabItemStatus GetStatus(void) const; + + void SetStyle(int style); + _TabItemStyle GetStyle(void) const; + + +private: + int __actionId; + bool __bUpdate; + + int __style; + + Tizen::Base::String __text; + + Tizen::Graphics::Bitmap* __pbmIcon; + Tizen::Graphics::Bitmap* __pbmBadge; + + Tizen::Graphics::Rectangle __bounds; + + _TabItemStatus __status; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_TABITEM_H_ diff --git a/src/ui/inc/FUiCtrl_TabModel.h b/src/ui/inc/FUiCtrl_TabModel.h new file mode 100644 index 0000000..69e7046 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TabModel.h @@ -0,0 +1,75 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabModel.h + * @brief This is the header file for the _TabModel class. + * + * This header file contains the declarations of the %_TabModel class. + */ +#ifndef _FUICTRL_INTERNAL_TAB_MODEL_H_ +#define _FUICTRL_INTERNAL_TAB_MODEL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls { + +/** + * @class _TabModel + * @brief + * @since 2.0 + * + * + * + * + */ +class _TabModel + : public Tizen::Base::Object +{ +private: + _TabModel(const _TabModel& value); + _TabModel& operator=(const _TabModel& value); + +// Lifecycle +public: + _TabModel(void); + virtual ~_TabModel(void); + +public: + result Construct(void); + + void SetSelectedItemIndex(int index); + int GetSelectedItemIndex(void) const; + + void SetPressedItemIndex(int index); + int GetPressedItemIndex(void) const; + + void SetFirstDrawnItemIndex(int index); + int GetFirstDrawnItemIndex(void) const; + + void SetEditModeEnabled(bool enable); + bool IsEditModeEnabled(void) const; + +private: + int __selectedItemIndex; + int __pressedItemIndex; + int __firstDrawnItemIndex; + bool __isEditModeEnabled; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_TAB_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_TabPresenter.h b/src/ui/inc/FUiCtrl_TabPresenter.h new file mode 100644 index 0000000..1a35102 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TabPresenter.h @@ -0,0 +1,267 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TabPresenter.h + * @brief This is the header file for the _TabPresenter class. + * + * This header file contains the declarations of the %_TabPresenter class. + */ +#ifndef _FUICTRL_INTERNAL_TAB_PRESENTER_H_ +#define _FUICTRL_INTERNAL_TAB_PRESENTER_H_ + +#include +#include +#include "FUiCtrl_Tab.h" +#include "FUiCtrl_TabModel.h" +#include "FUiCtrl_TabItem.h" +#include "FUiCtrl_FlickAnimation.h" + +namespace Tizen { namespace Ui { namespace Animations { + class _VisualElement; + class VisualElementAnimation; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Graphics { + class Bitmap; + class Font; +}} // Tizen::Graphics + +namespace Tizen { namespace Graphics { namespace _Text { + class TextObject; +}}} // Tizen::Graphics::_Text + +namespace Tizen { namespace Base { namespace RunTime { + class Timer; +}}} +namespace Tizen { namespace Ui { namespace Controls { + class _Tab; + class _TabModel; + class _TabItem; + class _FlickAnimation; + +const int _TIMER_COUNT = 3; +const int _TAB_ITEM_MAXCOUNT = 14; +/** + * @class _TabPresenter + * @brief + * @since 2.0 + * + * + * + * + */ +class _TabPresenter + : public Tizen::Base::Object + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener + , public Tizen::Base::Runtime::ITimerEventListener +{ + +public: + _TabPresenter(void); + virtual ~_TabPresenter(void); + +public: + result Construct(const _Tab& tab); + +public: + + void SetSelectedItemIndex(int index); + int GetSelectedItemIndex(void) const; + + void SetPressedItemIndex(int index); + int GetPressedItemIndex(void) const; + + void SetFirstDrawnItemIndex(int index); + int GetFirstDrawnItemIndex(void) const; + + void SetEditModeEnabled(bool enable); + bool IsEditModeEnabled(void) const; + + int GetItemCount(void) const; + _TabItem* GetItemAt(int index); + + result SetItemStatus(int index, _TabItemStatus status); + _TabItemStatus GetItemStatus(int index) const; + + int GetItemIndexFromPosition(const Tizen::Graphics::Point& point) const; + int GetNextItemIndexFromPosition(const Tizen::Graphics::Point& point, int currentIndex) const; + + void Draw(void); + void SetReCalculateItemBounds(bool reCalculationRequired); + + float CalculateProgress(float timeProgress) const; + + result StartReorderTimer(int); + result ResetReorderTimer(int index = 0); + result CancelReorderTimer(void); + result StopReorderTimer(void); + void StartReorderAnimation(int, int); + void FreeHorizontalLineBitmap(); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount); + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + + virtual bool OnLongPressGestureDetected(void); + virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture); + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + void OnBoundsChanged(void); + + virtual bool OnAccessibilityFocusMovedNext(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); + virtual bool OnAccessibilityFocusMovedPrevious(const Tizen::Ui::_AccessibilityContainer& control, const Tizen::Ui::_AccessibilityElement& element); +protected: + result SetModel(const _TabModel& tabModel); + +private: + + result LoadBitmap(void); + void DrawResourceBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, Tizen::Graphics::Bitmap* pBitmap); + + void DrawTextItem(Tizen::Graphics::Canvas* pCanvas); + + void DrawItemBackground(Tizen::Graphics::Canvas* pCanvas, Tizen::Graphics::Rectangle& itemRect); + + void DrawFocusItemBackground(Tizen::Graphics::Canvas* pCanvas, Tizen::Graphics::Rectangle& itemRect); + void DrawSelectedItemBackground(Tizen::Graphics::Canvas* pCanvas, Tizen::Graphics::Rectangle& itemRect); + + void DrawIconItem(Tizen::Graphics::Canvas* pCanvas); + void DrawItem(Tizen::Graphics::Canvas* pCanvas); + + void DrawEditItem(const Tizen::Graphics::Point& point); + void DrawItemDivisionVerticalLine(Tizen::Graphics::Canvas* pCanvas, Tizen::Graphics::Rectangle& lineRect); + void DrawHorizontal(void); + void DrawBadgeIcon(_TabItem* pDrawItem, Tizen::Graphics::Canvas* pCanvas); + + + void CalcItemBounds(void); + void CalcTabBounds(bool bReset); + + void StartFlickAnimation(void); + result StartFlickAnimationTimer(void); + result ResetFlickAnimationTimer(void); + + result StartScrollAnimationTimer(void); + result ResetScrollAnimationTimer(void); + + void SetItemFit(int); + void SetItemFitToLeft(void); + void SetItemFitToRight(void); + void SwapItems(int indexDest, int distance); + void ShiftItems(void); + + void SetFirstLoadedItemIndex(void); + void SetLastLoadedItemIndex(void); + + void StartScrollingEffect(void); + void SetOpacityVisualElement(int xPosition); + + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + void RefreshAccessibilityElement(void); + +private: + _TabPresenter(const _TabPresenter& value); + _TabPresenter& operator=(const _TabPresenter& value); + +private: + _Tab* __pTab; + + _TabModel* __pTabModel; + + Tizen::Graphics::Font* __pFont; + + Tizen::Graphics::_Text::TextObject* __pTextObject; + + Tizen::Graphics::Point __currentTouchPosition; + Tizen::Graphics::Rectangle __dividerLine; + Tizen::Graphics::Rectangle __selectedLine; + + struct ReorderAnimationInfo *__pAnimInfo[_TAB_ITEM_MAXCOUNT]; + struct TimerInfo *__pTimerInfo[_TIMER_COUNT]; + bool __recalc; + bool __editMode; + + int __editItemIndex; + + Tizen::Graphics::Bitmap* __pVerticalLineBitmap; + Tizen::Graphics::Bitmap* __pHorizontalLineBitmap; + + Tizen::Graphics::Bitmap* __pFrontScrollingEffectBitmap; + Tizen::Graphics::Bitmap* __pRearScrollingEffectBitmap; + Tizen::Graphics::Bitmap* __pScrollingEffectBitmap; + Tizen::Ui::Animations::_VisualElement* __pScrollingEffectVe; + + Tizen::Base::Runtime::Timer* __pFlickAnimationTimer; + Tizen::Base::Runtime::Timer* __pScrollAnimationTimer; + + _FlickAnimation __flickAnimation; + + Tizen::Graphics::Color backgroundColor; + int __startShowIndex; + int __showItemCount; + int __width; + int __height; + static const int FLICK_ANIMATION_TIMER_PERIOD = 3; + static const int FLICK_ANIMATION_FPS_TAB = 30; + static const int FLICK_ANIMATION_SENSITIVITY_TAB = 30; + static const int SCROLL_ANIMATION_TIMER_PERIOD = 500; + + static const int REORDER_TIMER_PERIOD = 1; + + int __moveDistance; + bool __isFlickEnabled; + int __itemMaxCount; + int __itemWidth; + int __itemHeight; + int __rearIndex; + bool __isRightScrolable; + bool __isLeftScrolable; + + bool __isDirectionRight; + bool __isTimerCanceled; + float __flickMove;; + int __flickDistance; + int __flickFlag; + int __reorderDist; + + int __firstItemIndex; + int __lastItemIndex; + + int __firstLoadedItemIndex; + int __lastLoadedItemIndex; + + int __selectedLineLeftMargin; + int __selectedLineRightMargin; + bool __isScrollEffectEnded; + bool __isScrollEffectStarted; + int __timerCount; + bool __isTouchMove; + int __scrollFlag; + int __tabMinimumSize; + +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_TAB_PRESENTER_H_ + + diff --git a/src/ui/inc/FUiCtrl_TableView.h b/src/ui/inc/FUiCtrl_TableView.h new file mode 100644 index 0000000..4bfb6e9 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TableView.h @@ -0,0 +1,270 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableView.h + * @brief This file defines the _TableView class. + * @version 3.0 + * + * This file contains the declarations of TableView Control class and its helper classes. + */ + +#ifndef _FUI_CTRL_INTERNAL_TABLE_VIEW_H_ +#define _FUI_CTRL_INTERNAL_TABLE_VIEW_H_ + +#include +#include "FUiCtrl_ScrollPanel.h" +#include "FUiCtrl_TableViewItemEventArg.h" +#include "FUiCtrl_ITableViewItemEventListener.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +class _FastScroll; +class _TableViewItem; +class _TableViewItemProvider; +class _TableViewItemProviderAdaptor; +class _TableViewPresenter; +class _IUiFastScrollListener; +class _UiTableViewItemEvent; + +enum TableViewStyle +{ + TABLE_VIEW_STYLE_SIMPLE = 0, + TABLE_VIEW_STYLE_GROUPED, + TABLE_VIEW_STYLE_SECTION +}; + +struct TableViewItemTag +{ + int groupIndex; + int itemIndex; +}; + +class _OSP_EXPORT_ _TableView + : public _ScrollPanel + , virtual public _ITouchGestureEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer + , virtual public Tizen::Base::Runtime::IEventListener +{ + DECLARE_CLASS_BEGIN(_TableView, _ScrollPanel); + DECLARE_PROPERTY("itemDividerColor", GetPropertyItemDividerColor, SetPropertyItemDividerColor); + DECLARE_PROPERTY("textColorOfEmptyTableView", GetPropertyTextColorOfEmptyTableView, SetPropertyTextColorOfEmptyTableView); + DECLARE_PROPERTY("textOfEmptyTableView", GetPropertyTextOfEmptyTableView, SetPropertyTextOfEmptyTableView); + DECLARE_PROPERTY("sectionColor", GetPropertySectionColor, SetPropertySectionColor); + DECLARE_CLASS_END(); + +public: + virtual ~_TableView(void); + + static _TableView* CreateTableViewN(TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle); + + result Initialize(TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle); + + result SetItemProvider(const _TableViewItemProvider* pProvider); + + void SetItemProviderAdaptor(_TableViewItemProviderAdaptor* pProviderAdaptor); + _TableViewItemProviderAdaptor* GetItemProviderAdaptor(void) const; + + result AddTableViewItemEventListener(const _ITableViewItemEventListener& listener); + result RemoveTableViewItemEventListener(const _ITableViewItemEventListener& listener); + result AddGroupedTableViewItemEventListener(const _ITableViewItemEventListener& listener); + result RemoveGroupedTableViewItemEventListener(const _ITableViewItemEventListener& listener); + result AddSectionTableViewItemEventListener(const _ITableViewItemEventListener& listener); + result RemoveSectionTableViewItemEventListener(const _ITableViewItemEventListener& listener); + + result AddFastScrollListener(const _IUiFastScrollListener& listener); + + result RemoveFastScrollListener(const _IUiFastScrollListener& listener); + + // touch Event Previewer + virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + // event handler for ITouchEventListener + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + // gestureListener Callback API + virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture); + virtual bool OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture); + + void SetSweepEnabled(bool enable); + bool IsSweepEnabled(void) const; + + bool IsReorderModeEnabled(void) const; + result SetReorderModeEnabled(bool enable); + + _FastScroll* GetFastScrollBar(void) const; + result SetFastScrollIndex(const Tizen::Base::String& text, bool useSearchIcon); + + TableViewScrollBarStyle GetScrollStyle(void) const; + result SetScrollStyle(TableViewScrollBarStyle scrollStyle); + + TableViewStyle GetTableViewStyle(void) const; + void SetTableViewStyle(TableViewStyle style); + + result GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const; + result SetTopDrawnItemIndex(int groupIndex, int itemIndex); // ScrollToItem(); + + result GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const; + result SetBottomDrawnItemIndex(int groupIndex, int itemIndex); // ScrollToItem(); + + result ScrollByPixel(int scrollDistance); + void SetScrollEnabled(bool enable); + bool IsScrollEnabled(void) const; + + result SetItemChecked(int groupIndex, int itemIndex, bool check); + bool IsItemChecked(int groupIndex, int itemIndex) const; + + result SetItemEnabled(int groupIndex, int itemIndex, bool enable); + bool IsItemEnabled(int groupIndex, int itemIndex) const; + + int GetGroupCount(void) const; + int GetItemCountAt(int groupIndex) const; + + result RefreshTableView(int groupIndex, int itemIndex, TableViewRefreshType type, bool animation = true); + result UpdateTableView(void); + + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex) const; + + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex, int& elementId) const; + + Tizen::Graphics::Color GetItemDividerColor(void) const; + result SetItemDividerColor(const Tizen::Graphics::Color& color); + + bool IsItemDividerEnabled(void) const; + void SetItemDividerEnabled(bool enable); + + Tizen::Graphics::Bitmap* GetBitmapOfEmptyTableView(void) const; + result SetBitmapOfEmptyTableView(const Tizen::Graphics::Bitmap* pBitmap); + + Tizen::Graphics::Color GetTextColorOfEmptyTableView(void) const; + result SetTextColorOfEmptyTableView(const Tizen::Graphics::Color& color); + + Tizen::Base::String GetTextOfEmptyTableView(void) const; + result SetTextOfEmptyTableView(const Tizen::Base::String& text); + + Tizen::Graphics::Color GetSectionColor(void) const; + result SetSectionColor(const Tizen::Graphics::Color& color); + + int GetTopMargin(void) const; + result SetTopMargin(int topMargin); + + int GetBottomMargin(void) const; + result SetBottomMargin(int bottomMargin); + + bool IsItemChecked(int index) const; + result SetItemChecked(int index, bool check); + + bool IsItemEnabled(int index) const; + result SetItemEnabled(int index, bool enable); + + void CheckItemHeightAndRefreshLayout(int groupIndex, int itemIndex); + + _TableViewItem* FindItem(int groupIndex, int itemIndex) const; + void UnloadItem(int groupIndex, int itemIndex); + _TableViewItem* LoadItem(int groupIndex, int itemIndex); + void RefreshItemLayout(int groupIndex, int itemIndex); + void GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const; + void GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const; + void ResetSweepItem(void); + int GetPressedItemCount(void); + + void FireTableViewItemEvent(int groupIndex, int itemIndex, TableViewNotifyType type, _TableViewItem* pItem); + void FireTableViewItemSweepEvent(int groupIndex, int itemIndex, TableViewSweepDirection directioin); + void FireTableViewItemReorderEvent(int fromItemIndex, int toItemIndex); + void FireTableViewItemReorderEvent(int fromGroupIndex, int fromItemIndex, int toGroupIndex, int toItemIndex); + void FireTableViewContextItemActivationEvent(int groupIndex, int itemIndex, _TableViewItem* pItem, bool activated); + + // Item Expand / Collapse + result ExpandGroup(int groupIndex); + result CollapseGroup(int groupIndex); + bool IsGroupExpanded(int groupIndex) const; + + result ExpandAllGroup(bool animation); + result CollapseAllGroup(bool animation); + + void SetGroupedLookEnabled(bool enable); + bool IsGroupedLookEnabled(void) const; + + bool GetFirstDrawnFlag(void) const; + int GetMaxItemCachingSize(void) const; + + virtual void OnDraw(void); + virtual void OnBoundsChanged(void); + + virtual void OnChildAttached(const _Control& child); + virtual void OnChildDetached(const _Control& child); + + result SetTableViewStatusChanged(bool changed); + +protected: + // Properties + result SetPropertyItemDividerColor(const Variant& itemDividerColor); + Variant GetPropertyItemDividerColor(void) const; + + result SetPropertyTextColorOfEmptyTableView(const Variant& textColorOfEmptyTableView); + Variant GetPropertyTextColorOfEmptyTableView(void) const; + + result SetPropertyTextOfEmptyTableView(const Variant& textOfEmptyTableView); + Variant GetPropertyTextOfEmptyTableView(void) const; + + result SetPropertySectionColor(const Variant& sectionColor); + Variant GetPropertySectionColor(void) const; + +protected: + _TableView(void); + _TableViewPresenter* GetTableViewPresenter(void) const; + void SetTableViewPresenter(const _TableViewPresenter* pPresenter); + +private: + _TableView(_TableView& rhs); + _TableView& operator =(_TableView& rhs); + + bool IsOnProcessing(void); + +// Attribute +private: + _TableViewPresenter* __pTableViewPresenter; + _FastScroll* __pFastScroll; + _UiTableViewItemEvent* __pTableViewItemEvent; + + // property + bool __itemDividerEnabled; + bool __sweepEnabled; + bool __reorderEnabled; + bool __sectionStyle; + bool __groupedLookEnable; + TableViewStyle __tableViewStyle; + TableViewScrollBarStyle __scrollStyle; + + Tizen::Graphics::Color __itemDividerColor; + Tizen::Graphics::Bitmap* __pBitmapOfEmptyTableView; + Tizen::Graphics::Bitmap* __pBackgroundBitmap; + Tizen::Base::String __textOfEmptyTableView; + Tizen::Graphics::Color __textColorOfEmptyTableView; + Tizen::Graphics::Color __sectionStyleColor; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TABLE_VIEW_H_ diff --git a/src/ui/inc/FUiCtrl_TableViewImpl.h b/src/ui/inc/FUiCtrl_TableViewImpl.h new file mode 100644 index 0000000..038f390 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TableViewImpl.h @@ -0,0 +1,227 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewImpl.h + * @brief This file defines the TableViewImpl class. + * @version 3.0 + * + * This file contains the declarations of TableViewImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_TABLE_VIEW_IMPL_H_ +#define _FUI_CTRL_INTERNAL_TABLE_VIEW_IMPL_H_ + +#include +#include +#include +#include "FUi_ContainerImpl.h" +#include "FUiCtrl_TableView.h" +#include "FUiCtrl_TableViewItemEvent.h" +#include "FUiCtrl_ITableViewItemEventListener.h" +#include "FUiCtrl_IScrollEventListener.h" +#include "FUiCtrl_FastScrollEvent.h" +#include "FUiCtrl_FastScrollEventArg.h" +#include "FUiCtrl_IFastScrollListener.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class ITableViewitemEventListener; +class IGroupedTableViewItemEventListener; +class ISectionTableViewItemEventListener; +class ITableViewItemProvider; +class IGroupedTableViewItemProvider; +class ISectionTableViewItemProvider; +class _ScrollEvent; +class _FastScrollEvent; + +struct _TableViewPublic +{ + TableViewStyle style; + TableView *pTableView; + GroupedTableView *pGroupedTableView; + SectionTableView *pSectionTableView; + + _TableViewPublic(void) + { + style = TABLE_VIEW_STYLE_SIMPLE; + pTableView = null; + pGroupedTableView = null; + pSectionTableView = null; + } +}; + +class _TableViewImpl + : public _ContainerImpl + , public _ITableViewItemEventListener + , public _IScrollEventListener + , public _IUiFastScrollListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + class TableViewSizeInfo + : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + }; + +private: + _TableViewImpl(Container* pPublic, _TableView* pCore); +public: + virtual ~_TableViewImpl(void); + + static _TableViewImpl* CreateTableViewImplN(Container* pPublic, Tizen::Graphics::Rectangle bounds, TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle); + static _TableViewImpl* CreateTableViewImplN(TableView* pPublic, Tizen::Graphics::Rectangle bounds, TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle); + static _TableViewImpl* CreateGroupedTableViewImplN(GroupedTableView* pPublic, Tizen::Graphics::Rectangle bounds, TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle); + static _TableViewImpl* CreateSectionTableViewImplN(SectionTableView* pPublic, Tizen::Graphics::Rectangle bounds, TableViewStyle style, bool itemDivider, TableViewScrollBarStyle scrollStyle); + + virtual const char* GetPublicClassName(void) const; +// virtual const _TableViewPublic& GetPublic(void) const; +// virtual _TableViewPublic& GetPublic(void); + virtual const _TableView& GetCore(void) const; + virtual _TableView& GetCore(void); + +public: + result SetSimpleStyleItemProvider(ITableViewItemProvider* pProvider); + result SetGroupedStyleItemProvider(IGroupedTableViewItemProvider* pProvider); + result SetSectionStyleItemProvider(ISectionTableViewItemProvider* pProvider); + + result AddTableViewItemEventListener(ITableViewItemEventListener& listener); + result RemoveTableViewItemEventListener(ITableViewItemEventListener& listener); + result AddGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener); + result RemoveGroupedTableViewItemEventListener(IGroupedTableViewItemEventListener& listener); + result AddSectionTableViewItemEventListener(ISectionTableViewItemEventListener& listener); + result RemoveSectionTableViewItemEventListener(ISectionTableViewItemEventListener& listener); + + result AddFastScrollListener(IFastScrollListener& listener); + result RemoveFastScrollListener(IFastScrollListener& listener); + result AddScrollEventListener(IScrollEventListener& listener); + result RemoveScrollEventListener(IScrollEventListener& listener); + + result SetSweepEnabled(bool enable); + result SetFastScrollIndex(const Tizen::Base::String& text, bool useSearchIcon); + + result GetTopDrawnItemIndex(int &groupIndex, int& itemIndex) const; + result GetBottomDrawnItemIndex(int &groupIndex, int& itemIndex) const; + + result ScrollToItem(int groupIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment); + + result ScrollByPixel(int scrollDistance); + int GetCurrentScrollPosition(void) const; + + void SetScrollEnabled(bool enable); + bool IsScrollEnabled(void) const; + + result SetItemChecked(int groupIndex, int itemIndex, bool check); + bool IsItemChecked(int groupIndex, int itemIndex) const; + + result SetItemEnabled(int groupIndex, int itemIndex, bool enable); + bool IsItemEnabled(int groupIndex, int itemIndex) const; + + int GetGroupCount(void) const; + int GetItemCountAt(int groupIndex) const; + + result RefreshTableView(int groupIndex, int itemIndex, TableViewRefreshType type); + result UpdateTableView(void); + + result GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex) const; + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex) const; + + result SetSectionColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetSectionColor(void) const; + result SetItemDividerColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetItemDividerColor(void) const; + + result SetBitmapOfEmptyTableView(const Tizen::Graphics::Bitmap* pBitmap); + + result SetTextOfEmptyTableView(const Tizen::Base::String& text); + Tizen::Base::String GetTextOfEmptyTableView(void) const; + + result SetTextColorOfEmptyTableView(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetTextColorOfEmptyTableView(void) const; + + // Item Expand / Collapse + result ExpandGroup(int groupIndex); + result CollapseGroup(int groupIndex); + bool IsGroupExpanded(int groupIndex) const; + + result ExpandAllGroup(void); + result CollapseAllGroup(void); + + result SetGroupedLookEnabled(bool enable); + bool IsGroupedLookEnabled(void) const; + + result BeginReorderingMode(void); + result EndReorderingMode(void); + bool IsInReorderingMode(void) const; + + void SetScrollInputMode(ScrollInputMode mode); + ScrollInputMode GetScrollInputMode(void) const; + + void SetPublic(TableViewStyle style, Container *pPublic); + + // _ITableViewItemEventListener + virtual void OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + virtual void OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + virtual void OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo); + virtual void OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + virtual void OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + virtual void OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + virtual void OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo); + virtual void OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); + virtual void OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated); + virtual void OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& TableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction); +// virtual void OnTableViewItemLongPressed(Tizen::Ui::Controls::_TableView& tableView, const Tizen::Ui::Controls::TableViewItemTag& itemTag, bool& invokeTableViewItemCallback); + + // _IScrollEventListener + virtual void OnScrollEndReached(_Control& source, ScrollEndEvent type); + virtual void OnScrollPositionChanged(_Control& source, int scrollPosition); + virtual void OnScrollStopped(_Control& source); + + // event handler for _IUiFastScrollListener + virtual void OnUiFastScrollIndexSelected(Tizen::Ui::_Control& source, Tizen::Ui::Controls::_FastScrollIndex& index); + + +public: + static _TableViewImpl* GetInstance(TableView& tableView); + static const _TableViewImpl* GetInstance(const TableView& tableView); + + static _TableViewImpl* GetInstance(GroupedTableView& tableView); + static const _TableViewImpl* GetInstance(const GroupedTableView& tableView); + + static _TableViewImpl* GetInstance(SectionTableView& tableView); + static const _TableViewImpl* GetInstance(const SectionTableView& tableView); + +private: + _TableViewImpl(_TableViewImpl& rhs); + _TableViewImpl& operator =(_TableViewImpl& rhs); + + _TableViewItemEvent* __pTableViewEvent; + _ScrollEvent* __pScrollEvent; + _FastScrollEvent* __pFastScrollEvent; + + bool __useSearchIcon; + + _TableViewPublic __tableViewPublic; + + //friend class _TableView; +}; + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_TABLE_VIEW_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_TableViewItem.h b/src/ui/inc/FUiCtrl_TableViewItem.h new file mode 100644 index 0000000..249123b --- /dev/null +++ b/src/ui/inc/FUiCtrl_TableViewItem.h @@ -0,0 +1,350 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewItem.h + * @brief This is the header file for the _TableViewItem class. + * + * This header file contains the declarations of the _TableViewItem class. + */ + + +#ifndef _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_H_ +#define _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_H_ + +#include +#include +#include +#include +#include +#include "FUi_Control.h" +#include "FUi_IAccessibilityListener.h" +#include "FUiCtrl_IListItemCommon.h" +#include "FUiCtrl_Label.h" + +namespace Tizen { namespace Ui +{ +class _TouchLongPressGestureDetector; +}} + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum TableViewItemSelectionStyle +{ + TABLE_VIEW_ITEM_SELECTION_STYLE_NONE = 0, + TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE +}; + +enum TableViewItemType +{ + TABLE_VIEW_ITEM_TYPE_TOP, + TABLE_VIEW_ITEM_TYPE_MIDDLE, + TABLE_VIEW_ITEM_TYPE_BOTTOM, + TABLE_VIEW_ITEM_TYPE_ONE, + TABLE_VIEW_ITEM_TYPE_TITLE, + TABLE_VIEW_ITEM_TYPE_HEADER, + TABLE_VIEW_ITEM_TYPE_FOOTER, + TABLE_VIEW_ITEM_TYPE_NONE +}; + +enum TableViewGroupItemDrawingStatus +{ + TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL = 3, + TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED +}; + +enum TableViewSimpleItemDrawingStatus +{ + TABLE_VIEW_SIMPLEITEM_DRAWING_STATUS_DISABLED = 5, +}; + + +struct _ItemDrawingProperty +{ + bool itemDividerEnabled; + Tizen::Graphics::Color dividerColor; + bool sectionStyleEnabled; + Tizen::Graphics::Color sectionStyleBgColor; + bool groupedLookEnabled; + bool reorderMode; + int leftMargin; + int scrollMargin; + int width; + bool propertyChanged; +}; + +class _OSP_EXPORT_ _TableViewItem + : public Tizen::Ui::_Control + , public _IListItemCommon + , public _IAccessibilityListener + , public Tizen::Base::Runtime::ITimerEventListener + , public Tizen::Ui::Animations::IVisualElementAnimationTickEventListener + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer +{ +public: + virtual ~_TableViewItem(); + + static _TableViewItem* CreateTableViewItemN(int itemHeight); + + virtual bool DrawItem(Tizen::Graphics::Rectangle& rcItem, ListItemState isFocused, bool itemDivider = false); + + virtual int GetItemHeight(void) const; + virtual void SetItemHeight(int itemHeight); + + virtual void SetChecked(bool checked); + virtual bool IsChecked(void) const; + virtual void SetCheckedAnimationEnabled(bool enabled); + + virtual void SetItemEnabled(bool enabled); + virtual bool IsItemEnabled(void) const; + + void SetItemType(const TableViewItemType itemType); + TableViewItemType GetItemType(void) const; + + virtual bool IsReorderMode(void) const; + virtual void SetReorderMode(bool enabled); + + virtual void SetItemChanged(bool changed); + virtual bool IsItemChanged(void) const; + + virtual void SetItemIndex(int groupIndex, int itemIndex); + virtual void GetItemIndex(int& groupIndex, int& itemIndex) const; + + _TableViewItem* GetContextItem(void) const; + void SetContextItem(_TableViewItem* pContextItem); + + bool IsContextItem(void) const; + void SetContextItemActivation(bool activated); + bool IsContextItemActivated(void) const; + + result CreateItemDimLayer(void); + void ExposeContextItem(Tizen::Graphics::Rectangle itemBounds, int targetWidth); + void DrawItemDimLayer(bool visible); + + void SetItemStyle(TableViewAnnexStyle style); + TableViewAnnexStyle GetItemStyle(void) const; + + void SetItemWidth(int width); + + bool SetItemBackgroundBitmap(ListItemState itemState, const Tizen::Graphics::Bitmap* pBitmap); + Tizen::Graphics::Bitmap* GetItemBackgroundBitmap(ListItemState itemState) const; + + void SetItemBackgroundColor(ListItemState itemState, const Tizen::Graphics::Color bgColor); + Tizen::Graphics::Color GetItemBackgroundColor(ListItemState itemState) const; + + result SetSelectionStyle(TableViewItemSelectionStyle style); + TableViewItemSelectionStyle GetSelectionStyle(void) const; + + virtual void SetAppInfo(const void* pAppInfo); + virtual void* GetAppInfo(void) const; + + int AddRef(void); + int Release(void); + + void FireItemEvent(bool selectedBody = true); + void FireItemSweepEvent(TableViewSweepDirection direction); + + void SetDrawingProperty(_ItemDrawingProperty* pDrawingProperty); + _ItemDrawingProperty* GetDrawingProperty(void); + + void SetDrawingStatus(TableViewItemDrawingStatus status); + TableViewItemDrawingStatus GetDrawingStatus(void); + + void AdjustChildControlMargin(void); + + void AdjustContextItemBounds(void); + void AdjustChildControlCenterAlign(void); + void SetChildControlCenterAlign(bool centerAlign); + void SetItemCustomHeight(int height); + void AdjustAnnexBounds(void); + + //Simple Item + result SetSimpleItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap, bool groupType); + result SetSimpleTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status); + Tizen::Graphics::Color GetSimpleItemTextColor(TableViewItemDrawingStatus status) const; + result SetSimpleItemTextSize(int size); + int GetSimpleItemTextSize(void) const; + + bool MoveItem(Tizen::Graphics::Point position, int duration, int delay, Tizen::Base::String* pName = null); + bool FadeInOutItem(bool fadeOut, int duration, int delay, Tizen::Base::String* pName = null); + bool ZoomInOutItem(bool zoomOut, int duration, int delay, Tizen::Base::String* pName = null); + + Tizen::Graphics::Point GetLastTouchPressedPosition(void); + void SetLastTouchPressedPosition(Tizen::Graphics::Point position); + + bool GetSelectionState(void); + void SetSelectionState(bool selected); + + result SetIndividualSelectionEnabled(const _Control& control, bool enable); + bool IsIndividualSelectionEnabled(const _Control& control); + + bool IsAnimationPlaying(void); + void StopAllAnimation(void); + + void SetItemDividerEnabled(bool enable); + + result PlayCheckBoxAnimation(void); + result StartCheckBoxAnimation(void); + void StopCheckBoxAnimation(void); + + // event handler for ITouchEventListener + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + virtual void OnDraw(void); + virtual void OnChildAttached(const _Control& child); + virtual void OnChildDetached(const _Control& child); + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + virtual void OnBoundsChanged(void); + + // VisualElement Animation + virtual void OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue); + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount); + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + + // accessibility listener + virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element); + +protected: + _TableViewItem(int nItemHeight); + result Initialize(void); + + // Accessibility + virtual void SetAccessibilityElement(void); + +private: + _TableViewItem(const _TableViewItem&); + _TableViewItem& operator =(const _TableViewItem&); + +private: + void DrawItemBackground(void); + void DrawSectionStyleBackground(void); + void DrawAnnexStyle(void); + void DrawCheckBox(void); + void DrawRadioBox(void); + void DrawOnOffButton(void); + void DrawDetailButton(void); + void DrawItemDivider(void); + void DrawGroupedLook(void); + + result DrawBitmap (Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, const Tizen::Graphics::Bitmap& bitmap); + + result SetItemHighlightBounds(Tizen::Ui::Animations::_VisualElement& highlightVisualElement, const Tizen::Graphics::Rectangle& bounds); + Tizen::Graphics::Rectangle CalculateItemHighlightBounds(void); + Tizen::Graphics::Rectangle CalculateAnnexBitmapBounds(int annexWidth, int annexHeight, const Tizen::Graphics::Bitmap& bitmap); + + bool IsTitleStyleItem(void) const; + bool IsValidSelectionState(void); + + //Simple Item + void DrawSimpleItem(void); + result CreateSimpleItemContents(bool textOnly); + int GetAnnexWidth(TableViewAnnexStyle style); + +private: + void* __pAppInfo; + int __refCount; + int __itemHeight; + int __itemGroupIndex; + int __itemIndex; + + bool __checkedState; + bool __enabledState; + bool __itemChanged; + bool __reorderMode; + bool __itemSelected; + bool __childMarginState; + + TableViewAnnexStyle __annexStyle; + TableViewItemDrawingStatus __drawingStatus; + TableViewItemSelectionStyle __selectionStyle; + TableViewItemType __itemType; + + _TableViewItem* __pContextItem; + bool __isContextItem; + bool __isContextItemActivated; + bool __checkItemHeightNeeded; + + _Label* __pItemDivider; + _Label* __pItemTopDivider; + _Label* __pItemAnnex; + + int __itemWidth; + + Tizen::Graphics::Bitmap* __pItemBgBitmap[3]; + Tizen::Graphics::Color __colorItemBg[3]; + + _ItemDrawingProperty* __pDrawingProperty; + + bool __itemDividerEnabled; + + // Simple Item + _Label* __pSimpleItemText; + _Label* __pSimpleItemBitmap; + Tizen::Graphics::Color __simpleItemTextColor[6]; + int __simpleItemTextSize; + + _Label* __pDimLayer; + + Tizen::Graphics::Point __touchStartPosition; + bool __isTouchMoved; + bool __childControlCenterAlign; + int __customHeight; + int __animationCount; + + Tizen::Base::Collection::ArrayList __individualSelectionControls; + + Tizen::Ui::_AccessibilityElement* __pAccessibilityElement; + + Tizen::Base::Runtime::Timer* __pCheckedTimer; + bool __isCheckedTimerEnabled; + bool __isCheckedAnimationEnabled; + int __checkedCount; + Tizen::Graphics::Rectangle __checkedBounds; + + Tizen::Ui::Animations::_VisualElement* __pHighlightVisualElement; + + static const float SIMPLE_ITEM_ELEMENT_BITMAP_SIZE_RATIO = 0.6f; + static const float BACKGROUND_DIMMED_OPACITY = 0.7f; + static const float BACKGROUND_DISABLED_OPACITY = 0.3f; + static const int DEFAULT_CAPTURED_CONTROL_COUNT = 10; + static const int CHECKED_ANIMATION_DURATION = 30; + static const int MAX_CHECKED_COUNT = 10; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_H_ diff --git a/src/ui/inc/FUiCtrl_TableViewItemEvent.h b/src/ui/inc/FUiCtrl_TableViewItemEvent.h new file mode 100644 index 0000000..57dffa4 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TableViewItemEvent.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewItemEvent.h + * @brief This is the header file for the _TableViewItemEvent class. + * + * This header file contains the declarations of the _TableViewItemEvent class. + */ + +#ifndef _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_EVENT_H_ +#define _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_EVENT_H_ + +#include +#include +#include +#include "FUiCtrl_TableView.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _TableViewItemEvent + : public Tizen::Base::Runtime::_Event +{ + +public: + _TableViewItemEvent(void); + virtual ~_TableViewItemEvent(void); + + result Construct(Tizen::Ui::Control* pSource, TableViewStyle style); + +// Accessors + Tizen::Ui::Control* GetSource(void) const; + +// Operations +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attribute +private: + Tizen::Ui::Control* __pSource; + bool __invokeTableViewItemCallback; + TableViewStyle __style; +}; // _TableViewItemEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_TableViewItemEventArg.h b/src/ui/inc/FUiCtrl_TableViewItemEventArg.h new file mode 100644 index 0000000..94e0f4a --- /dev/null +++ b/src/ui/inc/FUiCtrl_TableViewItemEventArg.h @@ -0,0 +1,96 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewItemEventArg.h + * @brief This is the header file for the _TableViewItemEventArg class. + * + * This header file contains the declarations of the _TableViewItemEventArg class. + */ + +#ifndef _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_EVENT_ARG_H_ +#define _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_EVENT_ARG_H_ + +#include +#include +#include +#include +#include + +namespace Tizen { +namespace Ui { +namespace Controls { +class _TableViewItem; + +enum TableViewNotifyType { + TABLEVIEW_NOTIFY_TYPE_SELECTED_ITEM = 0, + TABLEVIEW_NOTIFY_TYPE_HIGHLIGHED_ITEM, + TABLEVIEW_NOTIFY_TYPE_ANNEX_CHECK, + TABLEVIEW_NOTIFY_TYPE_ANNEX_UNCHECK, + TABLEVIEW_NOTIFY_TYPE_ANNEX_MORE, + TABLEVIEW_NOTIFY_TYPE_SELCTED_CONTEXT_ITEM, + TABLEVIEW_NOTIFY_TYPE_ITEM_SWEPT, + TABLEVIEW_NOTIFY_TYPE_TOUCH_LONG_PRESSED, + TABLEVIEW_NOTIFY_TYPE_REORDERED_ITEM, + TABLEVIEW_NOTIFY_TYPE_CONTEXT_ITEM_ACTIVATION, + TABLEVIEW_NOTIFY_TYPE_NONE = 0xff +}; + +class _TableViewItemEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +// Lifecycle +public: + _TableViewItemEventArg(int arg1, int arg2, int arg3,int arg4, _TableViewItem* pItem, TableViewNotifyType type, bool activated = false); + + virtual ~_TableViewItemEventArg(void); + +// Accessor + int GetArg1(void) const; + + int GetArg2(void) const; + + int GetArg3(void) const; + + int GetArg4(void) const; + + _TableViewItem* GetItem(void) const; + + TableViewNotifyType GetNotifyType(void) const; + + bool GetActivated(void) const; + +private: + _TableViewItemEventArg(_TableViewItemEventArg& rhs); + _TableViewItemEventArg& operator=(const _TableViewItemEventArg& rhs); + +// Attribute +private: + int __arg1; // use by groupIndex + int __arg2; // use by itemIndex + int __arg3; + int __arg4; + _TableViewItem* __pItem; + TableViewNotifyType __type; + bool __activated; +}; +// _TableViewItemEventArg + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_EVENT_ARG_H_ diff --git a/src/ui/inc/FUiCtrl_TableViewItemImpl.h b/src/ui/inc/FUiCtrl_TableViewItemImpl.h new file mode 100644 index 0000000..30ef636 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TableViewItemImpl.h @@ -0,0 +1,95 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewItemImpl.h + * @brief This is the header file for the _TableViewItemImpl class. + * + * This header file contains the declarations of the _TableViewItemImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_IMPL_H_ +#define _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_IMPL_H_ + +#include +#include +#include "FUi_ContainerImpl.h" +#include "FUiCtrl_TableViewItem.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class TableViewContextItem; + +class _TableViewItemImpl + : public _ContainerImpl +{ +public: + class TableViewItemSizeInfo + : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + }; + +public: + static _TableViewItemImpl* CreateTableViewItemImplN(TableViewItemBase* pPublic, const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style=TABLE_VIEW_ANNEX_STYLE_NORMAL, Layout* pPublicPortraitLayout=null, Layout* pPublicLandscapeLayout=null); + virtual ~_TableViewItemImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const TableViewItem& GetPublic(void) const; + virtual TableViewItem& GetPublic(void); + virtual const _TableViewItem& GetCore(void) const; + virtual _TableViewItem& GetCore(void); + + virtual result Construct(const Tizen::Graphics::Dimension& itemSize, TableViewAnnexStyle style); + + result SetContextItem(_TableViewItemImpl* pItem); + + static int GetAnnexWidth(TableViewAnnexStyle style); + + result SetSelectionStyle(TableViewItemSelectionStyle style); + TableViewItemSelectionStyle GetSelectionStyle(void) const; + + // ItemBase + result SetBackgroundBitmap(TableViewItemDrawingStatus status, const Tizen::Graphics::Bitmap* pBitmap); + result SetBackgroundColor(TableViewItemDrawingStatus status, const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetBackgroundColor(TableViewItemDrawingStatus status) const; + + // Simple Item + result SetSimpleItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap, bool groupType = false); + result SetSimpleItemTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); + Tizen::Graphics::Color GetSimpleItemTextColor(TableViewItemDrawingStatus status = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL) const; + result SetSimpleItemTextSize(int size); + int GetSimpleItemTextSize(void) const; + + result SetIndividualSelectionEnabled(const Tizen::Ui::_ControlImpl& controlImpl, bool enable); + bool IsIndividualSelectionEnabled(const Tizen::Ui::_ControlImpl& controlImpl); + +public: + static _TableViewItemImpl* GetInstance(TableViewItemBase& tableViewItem); + static const _TableViewItemImpl* GetInstance(const TableViewItemBase& tableViewItem); + +private: + _TableViewItemImpl(TableViewItemBase* pPublic, _TableViewItem* pCore, Layout* pPublicPortraitLayout = null, Layout* pPublicLandscapeLayout = null); + _TableViewItemImpl(const _TableViewItemImpl&); + _TableViewItemImpl& operator=(const _TableViewItemImpl&); +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_IMPL_H_ + diff --git a/src/ui/inc/FUiCtrl_TableViewItemProvider.h b/src/ui/inc/FUiCtrl_TableViewItemProvider.h new file mode 100644 index 0000000..05ff5be --- /dev/null +++ b/src/ui/inc/FUiCtrl_TableViewItemProvider.h @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewItemProvider.h + * @brief This file defines the _TableViewItemProvider class. + * @version 3.0 + * + * This header file contains the declarations of the _TableViewItemProvider class. + */ + +#ifndef _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_PROVIDER_H_ +#define _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_PROVIDER_H_ + +#include +#include "FUiCtrl_TableView.h" +#include "FUi_Control.h" + +namespace Tizen { namespace Ui { namespace Controls +{ +class TableViewItem; +class TableViewGroupItem; +class ITableViewItemProvider; +class IGroupedTableViewItemProvider; +class ISectionTableViewItemProvider; +struct TableViewItemTag; + +class _TableViewItemProvider +{ +public: + virtual ~_TableViewItemProvider(void); + + static _TableViewItemProvider* CreateTableViewItemProviderN(TableViewStyle style); + + result SetSimpleStyleItemProvider(ITableViewItemProvider* pProvider); + result SetGroupedStyleItemProvider(IGroupedTableViewItemProvider* pProvider); + result SetSectionStyleItemProvider(ISectionTableViewItemProvider* pProvider); + + int GetGroupCount(void); + int GetItemCount(int groupIndex); + int GetGroupItemHeight(int groupIndex); + int GetItemHeight(const TableViewItemTag& itemTag); + TableViewGroupItem* CreateGroupItem(int groupIndex, int itemWidth); + bool DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem); + TableViewItem* CreateItem(const TableViewItemTag& itemTag, int itemWidth); + bool DeleteItem(const TableViewItemTag& itemTag, TableViewItem* pItem); + bool UpdateItem(const TableViewItemTag& itemTag, TableViewItem *pItem); + bool UpdateGroupItem(int groupIndex, TableViewGroupItem *pItem); + Tizen::Base::String GetSectionHeader(int groupIndex); + bool HasSectionHeader(int groupIndex); + Tizen::Base::String GetSectionFooter(int groupIndex); + bool HasSectionFooter(int groupIndex); + int GetDefaultItemHeight(void); + int GetDefaultGroupItemHeight(void); + bool IsReorderable(int groupIndexFrom, int groupIndexTo); + bool IsOnProcessing(); + +protected: + _TableViewItemProvider(TableViewStyle style); + +private: + _TableViewItemProvider(_TableViewItemProvider& rhs); + _TableViewItemProvider& operator =(_TableViewItemProvider& rhs); + +// Attribute +private: + ITableViewItemProvider* __pSimpleProvider; + IGroupedTableViewItemProvider* __pGroupedProvider; + ISectionTableViewItemProvider* __pSectionProvider; + TableViewStyle __style; + bool __onProcessing; + +}; // _TableViewItemProvider + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_PROVIDER_H_ + + diff --git a/src/ui/inc/FUiCtrl_TableViewItemProviderAdaptor.h b/src/ui/inc/FUiCtrl_TableViewItemProviderAdaptor.h new file mode 100644 index 0000000..ea7518c --- /dev/null +++ b/src/ui/inc/FUiCtrl_TableViewItemProviderAdaptor.h @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewItemProviderAdaptor.h + * @brief This is the header file for the __TableViewItemProviderAdaptor class. + * + * This header file contains the declarations of the __TableViewItemProviderAdaptor class. + */ + + +#ifndef _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_PROVIDER_ADAPTOR_H_ +#define _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_PROVIDER_ADAPTOR_H_ + +#include +#include +#include +#include "FUiCtrl_TableViewItemProvider.h" +#include "FUiCtrl_IListItemProviderAdaptor.h" +#include "FUiCtrl_LinkedList.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ +class _TableViewItem; + +class _TableViewItemProviderAdaptor + : public _IListItemProviderAdaptor +{ +public: +// Lifecycle + _TableViewItemProviderAdaptor(); + + virtual ~_TableViewItemProviderAdaptor(void); + +// Operation + void SetItemProvider(_TableViewItemProvider* pProvider); + virtual bool IsItemProvider() const; + virtual int GetGroupCount() const; + virtual int GetItemCount(int groupIndex = 0) const; + virtual _IListItemCommon* LoadItem(int groupIndex, int itemIndex); + virtual result UnloadItem(_IListItemCommon* pItem, int groupIndex, int itemIndex); + virtual result DeleteItem(_IListItemCommon* pItem, int groupIndex, int itemIndex); + + virtual bool UpdateItem(_IListItemCommon* pItem, int groupIndex, int itemIndex); + virtual int GetItemHeight(int groupIndex, int itemIndex); + virtual int GetDefaultItemHeight(void); + virtual int GetDefaultGroupItemHeight(void); + virtual bool HasSectionHeader(int groupIndex) const; + virtual bool HasSectionFooter(int groupIndex) const; + virtual bool IsReorderable(int groupIndexFrom, int groupIndexTo); + + bool IsOnProcessing(); + result SetListWidth(int width); + int GetListWidth(void); + result SetTableViewStyle(int style); + + _TableViewItem* GetDefaultItem(void); + +// Operation +private: + void SetAnnexToItem(TableViewItem* pItem); + +private: + _TableViewItemProviderAdaptor(const _TableViewItemProviderAdaptor&); + _TableViewItemProviderAdaptor& operator =(const _TableViewItemProviderAdaptor&); + +// Variable +private: + _TableViewItemProvider* __pTableViewProvider; + _TableViewItem* __pDefaultItem; + + int __listWidth; + int __style; +}; // _TableViewItemProviderAdaptor + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_PROVIDER_ADAPTOR_H_ diff --git a/src/ui/inc/FUiCtrl_TableViewPresenter.h b/src/ui/inc/FUiCtrl_TableViewPresenter.h new file mode 100644 index 0000000..30b3396 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TableViewPresenter.h @@ -0,0 +1,352 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TableViewPresenter.h + * @brief This is the implementation file for _TableViewPresenter class. + * + * This file contains the implementation of _TableViewPresenter class. + */ + + +#ifndef _FUI_CTRL_INTERNAL_TABLE_VIEW_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_TABLE_VIEW_PRESENTER_H_ + +#include +#include +#include "FUiCtrl_TableViewItem.h" +#include "FUiCtrl_ScrollPanelPresenter.h" + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +}}} + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum ItemAlignment +{ + TABLE_VIEW_ITEM_ALIGNMENT_TOP = 0, + TABLE_VIEW_ITEM_ALIGNMENT_BOTTOM +}; + +struct _TableViewReorderInfo +{ + int groupIndex; + int itemIndex; + int originGroupIndex; + int originItemIndex; + int touchPressedPositionY; + int itemBasisPositionY; + int isScrollDirectionUp; + int nonScrollableLimitArea; + bool blockedTouchReleaseState; + long long touchPressedTick; + Tizen::Graphics::Rectangle itemBounds; + + _TableViewReorderInfo(void) + : groupIndex(-1) + , itemIndex(-1) + , originGroupIndex(-1) + , originItemIndex(-1) + , touchPressedPositionY(0) + , itemBasisPositionY(0) + , isScrollDirectionUp(false) + , nonScrollableLimitArea(0) + , blockedTouchReleaseState(false) + , touchPressedTick(0) + , itemBounds() + { + + } +}; + +class _TableView; +class _ListViewModel; +class _TableViewItemProviderAdaptor; + +class _TableViewPresenter + : public _ScrollPanelPresenter + , public Tizen::Ui::Animations::IVisualElementAnimationTickEventListener + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + _TableViewPresenter(); + virtual ~_TableViewPresenter(void); + + virtual result Construct(_TableView* pTableView); + + bool Initialize(_TableView* pTableView); + + _TableView* GetView(void) const; + + _ListViewModel* GetModel(void) const; + + // set ItemProvider + result SetItemProvider(const _TableViewItemProvider* pProvider); + + virtual void PreloadItem(void); + + void SetTableViewItemProviderAdaptor(_TableViewItemProviderAdaptor* pProviderAdaptor); + + _TableViewItemProviderAdaptor* GetTableViewItemProviderAdaptor(void) const; + + // event handler for window event + virtual void OnBoundsChanged(void); + virtual result Draw(void); + + // Touch Event Previewer + virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchInfo); + virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchInfo); + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchInfo); + virtual _UiTouchEventDelivery OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchInfo); + + // Touch Event Listener + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo); + + // gestureListener Callback API + virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture); + virtual bool OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture); + virtual bool OnPreviewFlickGestureDetected(_TouchFlickGestureDetector& gesture); + + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount); + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + virtual void OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue); + + // Timer Event + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + void Dispose(void); + + result RefreshTableView(int groupIndex, int itemIndex, TableViewRefreshType type, bool animation); + result UpdateTableView(void); + + result GetItemIndexFromPosition(const Tizen::Graphics::Point& position, int& groupIndex, int& itemIndex) const; + result GetItemFromPosition(const Tizen::Graphics::Point& position, TableViewItemTag& itemPos) const; + + result GetTopDrawnItem(TableViewItemTag& itemPos) const; + result SetTopDrawnItem(TableViewItemTag& itemPos); + + result GetBottomDrawnItem(TableViewItemTag& itemPos) const; + + result GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const; + result SetTopDrawnItemIndex(int groupIndex, int itemIndex); + + result GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const; + result SetBottomDrawnItemIndex(int groupIndex, int itemIndex); + + int GetGroupCount(void) const; + int GetItemCountAt(int groupIndex) const; + bool HasSectionFooter(int groupIndex) const; + + int GetTopMargin(void) const; + result SetTopMargin(int topMargin); + + int GetBottomMargin(void) const; + result SetBottomMargin(int bottomMargin); + + int GetLeftMargin(void) const; + result SetLeftMargin(int leftMargin); + + bool IsItemChecked(int groupIndex, int itemIndex) const; + result SetItemChecked(int groupIndex, int itemIndex, bool checked); + + bool IsItemEnabled(int groupIndex, int itemIndex) const; + result SetItemEnabled(int groupIndex, int itemIndex, bool enabled); + + _TableViewItem* FindItem(TableViewItemTag& itemTag); + void UnloadItem(int groupIndex, int itemIndex); + _TableViewItem* LoadItem(int groupIndex, int itemIndex); + void RefreshItemLayout(int groupIndex, int itemIndex); + void GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const; + void GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const; + + result SetStatusChanged(bool changed); + bool IsStatusChanged(void) const; + + result ExpandGroup(int groupIndex, bool withAnimation); + result CollapseGroup(int groupIndex, bool withAnimation); + bool IsGroupExpanded(int groupIndex) const; + + result SetReorderMode(bool enabled); + + bool CheckItemHeightAndRefreshLayout(TableViewItemTag itemTag, bool downScroll); + + result ScrollByPixel(int scrollDistance); + void SetScrollEnabled(bool enable); + bool IsScrollEnabled(void) const; + + bool GetFirstDrawnFlag(void) const; + int GetMaxItemCachingSize(void) const; + void ResetSweepItem(void); + int GetPressedItemCount(void); + +protected: + virtual int ScrollToInternal(int targetPosition); + + virtual void FadeInScrollBar(void); + virtual void FadeOutScrollBar(void); + + // Update Layout + virtual void UpdateLayout(void); + +private: + _TableViewPresenter(const _TableViewPresenter& rhs); + _TableViewPresenter& operator =(const _TableViewPresenter& rhs); + + _TableView* __pTableView; + _ListViewModel* __pListModel; + _TableViewItemProviderAdaptor* __pProviderAdaptor; + + bool GetFirstItem(TableViewItemTag& firstItem) const; + bool GetPreviousItemPosition(const TableViewItemTag& currentItem, TableViewItemTag& prevItem) const; + bool GetNextItemPosition(const TableViewItemTag& currentItem, TableViewItemTag& nextItem) const; + int GetItemCount(void) const; + int GetHeightOfAllItems(void) const; + + void SetItemLayout(_TableViewItem* pItem, TableViewItemTag& itemPos); + int CalculateItemPositionY(int groupIndex, int itemIndex); + void AdjustLayoutItems(int scrollPosition); + void ResetItemLayout(TableViewItemTag& topDrawnItemTag); + void RefreshItemLayout(TableViewItemTag& topDrawnItemTag, TableViewItemTag& refreshItemTag, TableViewRefreshType type, bool animation); + void RefreshItemBounds(_TableViewItem* pItem, TableViewItemTag& itemPos); + void ScrollToItem(int groupIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment, int shiftingDistance = 0); + + _TableViewItem* GetTableViewItemFromControl(const _Control& source); + + void UnloadItem(TableViewItemTag& itemTag); + void DetachItem(TableViewItemTag& itemTag); + void DetachContextItem(TableViewItemTag& itemTag); + void DetachAllItem(bool removeItem); + void SetItemDrawingProperty(void); + void SetItemType(_TableViewItem* pItem, TableViewItemTag itemPosition); + + result StartFastScrollTimer(void); + void StopFastScrollTimer(void); + + bool IsEmpty(void) const; + result DrawEmptyTableView(void); + + void LoadItemWithScrollPosition(int previousScrollPosition, int currentScrollPos); + + bool GetTableViewItemPosition(_TableViewItem& item, TableViewItemTag& itemTag); // item must exist between from tag and end tag + + int LoadAllItemsInGroup(int groupIndex, bool downward); + void SetLoadedItemsVisibleInGroup(int groupIndex, bool visible); + TableViewItemTag LoadItemsToBeVisible(const TableViewItemTag& from); + void AttachNextItemsToBottom(const TableViewItemTag& anchor); + bool IsAnyItemInGroupLoaded(int groupIndex) const; + bool IsAnyItemInLoadedIndex(int groupIndex, int itemIndex); + void ScrollToHideNonClientArea(TableViewItemTag& bottomTag); + void AdjustClientAreaBounds(bool reset, int dist = 0); + void SetClientAreaHeight(int height); + void UnloadInvisibleItems(void); + + // reordering + bool SelectReorderItem(int groupIndex, int itemIndex); + bool ResetReorderItem(int groupIndex, int itemIndex); + bool DragSelectedItem(int distance, bool relativeCoordinate); + bool CheckReorderItemScrollAnimation(_TableViewItem *pItem); + bool CheckReorderItemPosition(_TableViewItem* pItem, TableViewItemTag& reorderItemTag); + void AdjustReorderItemLimitPositionY(int& positionY); + bool ReorderItem(int destinationGroupIndex, int destinationItemIndex); + void StartReorderScrollTimer(void); + void StopReorderScrollTimer(void); + + // item height + int GetItemHeight(TableViewItemTag itemTag) const; + int SetItemHeight(TableViewItemTag itemTag, int height); + bool CreateItemHeightList(void); + void DeleteItemHeightList(void); + bool RefreshItemHeightList(int groupIndex, int itemIndex, TableViewRefreshType refreshType); + + void CaptureAndStartRemoveItemAnimation(int groupIndex, int itemIndex); + + void SetLoadedItemsVisibleFromPosition(int position, bool visible); + void MoveLoadedItemsFromPosition(int position); + + void SweepItem(int x); + void ResetSweptItem(void); + void AdjustSweptItemPosition(bool withAnimation = false); + void AdjustLoadedItemWidth(void); + + bool IsValidDrawnItem(int groupIndex, int itemIndex); + +private: + int __topMargin; + int __bottomMargin; + int __leftMargin; + + bool __modelInitialized; + bool __firstDrawnFlag; + bool __statusChangedFlag; + bool __scrolling; + + // Scroll Bar + int __movedPos; + + _ItemDrawingProperty* __pItemDrawingProperty; + + Tizen::Ui::Animations::_VisualElement* __pBaseVisualElement; + + bool __sweepOccured; + Tizen::Graphics::Point __sweptItemPosition; + TableViewItemTag __sweptItemTag; + + TableViewItemTag __reservedScrollItemIndex; + TableViewScrollItemAlignment __reservedScrollItemAlignment; + + bool __firstTouchMoved; + + Tizen::Base::Runtime::Timer* __pReorderScrollTimer; + + _TableViewReorderInfo __reorderInfo; + + Tizen::Base::Collection::ArrayListT __itemHeightList; + int __itemTotalHeight; + + TableViewItemTag __expandableItemTag; + + Tizen::Base::Runtime::Timer* __pFastScrollTimer; + bool __isFastScrollTimerEnabled; + + static const int TABLEVIEW_MAX_ITEM_COUNT = 30; + static const int REORDER_SCROLL_ANIMATION_TIMER_DURATION = 10; + static const int REORDER_SCROLL_ANIMATION_DISTANCE = 10; + static const int REORDER_TOUCH_UIACTIVATE_DURATION = 100; + static const int FAST_SCROLL_FADE_OUT_DURATION = 500; + + //animation + static const int REORDER_ITEM_MOVE_ANIMATION_DURATION = 113; + static const int ADD_ITEM_ANIMATION_DURATION = 333; + static const int REMOVE_ITEM_MOVE_ANIMATION_DURATION = 267; + static const int REFRESH_ITEM_ANIMATION_DELAY = 100; + static const int EXPAND_GROUP_ANIMATION_DURATION = 335; + static const int COLLAPSE_GROUP_ANIMATION_DURATION = 329; + static const int SWEEP_ITEM_ANIMATION_DURATION = 300; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TABLE_VIEW_PRESENTER_H_ + diff --git a/src/ui/inc/FUiCtrl_TextBlockEvent.h b/src/ui/inc/FUiCtrl_TextBlockEvent.h new file mode 100644 index 0000000..92ac7be --- /dev/null +++ b/src/ui/inc/FUiCtrl_TextBlockEvent.h @@ -0,0 +1,105 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUiCtrl_TextBlockEvent.h +* @brief This is the header file for _TextBlockEvent class. +* +* This header file contains declaration of _TextBlockEvent class. +* +*/ + +#ifndef _FUI_CTRL_TEXT_BLOCK_EVENT_H_ +#define _FUI_CTRL_TEXT_BLOCK_EVENT_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** +* @class _TextBlockEvent +* @brief This class handles a text Block event event. It is inherited from Event class. +* +*/ +class _TextBlockEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_TextBlockEvent(void); + + static _TextBlockEvent* CreateInstanceN(const Tizen::Ui::_Control& source); + +// Accessors +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::_Control* GetSource(void) const; + + // Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _TextBlockEvent(const Tizen::Ui::_Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of _CustomItemEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +public: + static Tizen::Base::Runtime::IEventArg* CreateTextBlockEventArgN(int start, int end); + + //Attributess +private: + const Tizen::Ui::_Control* __pSource; +}; // _TextBlockEvent + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_TEXT_BLOCK_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_TextBoxImpl.h b/src/ui/inc/FUiCtrl_TextBoxImpl.h new file mode 100644 index 0000000..c60f719 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TextBoxImpl.h @@ -0,0 +1,596 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_TextBoxImpl.h + * @brief This is the header file for the _TextBoxImpl class. + * + * This header file contains the declarations of the %_EditPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_TEXT_BOX_IMPL_H_ +#define _FUI_CTRL_INTERNAL_TEXT_BOX_IMPL_H_ + +#include +#include +#include +#include +#include "FUi_ControlImpl.h" +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_ITextBlockEventListener.h" +#include "FUiCtrl_IUiLinkEventListener.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +// forward declarations +class _PublicTextBlockEvent; +class _PublicLinkEvent; + +class _TextBoxImpl + : public _ControlImpl + , public _IUiLinkEventListener + , public _ITextBlockEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + * + */ + _TextBoxImpl(TextBox* pPublic, _Edit* pCore); + + /** + * This is destructor for this class. + * + * @since 2.0 + */ + virtual ~_TextBoxImpl(void); + + /** + * Creates this instance of the _TextBoxImpl with the specified parameters. + * + * @since 2.0 + * @return An error code + * @param[in] pPublic The pointer of the TextBox control. + */ + static _TextBoxImpl* CreateTextBoxImplN(TextBox* pPublic); + + virtual const char* GetPublicClassName(void) const; + virtual const TextBox& GetPublic(void) const; + virtual TextBox& GetPublic(void); + virtual const _Edit& GetCore(void) const; + virtual _Edit& GetCore(void); + + /** + * Initializes this instance of the TextBox control with the specified parameters. + * + * @since 2.0 + * @return An error code + * @param[in] border The border style + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + * @exception E_SYSTEM A system error occurred. + */ + result Initialize(TextBoxBorder border = TEXT_BOX_BORDER_ROUNDED); + + /** + * Sets the auto-link mask. + * + * @since 2.0 + * @return An error code + * @param[in] autoLinks The auto-link mask @n + * Multiple link types can be combined using the bitwise OR operator (see Tizen::Base::Utility::LinkType). + * For more information, refer to @ref linkAutoLinkDetection "here". + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks When @c autoLinks is set to zero, the auto-link detection is disabled. + * @see Tizen::Base::Utility::LinkType + * @see GetAutoLinkMask() + */ + result SetAutoLinkMask(unsigned long autoLinks); + + /** + * Gets the auto-link mask. + * + * @since 2.0 + * @return The auto-link mask + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetAutoLinkMask() + */ + unsigned long GetAutoLinkMask(void) const; + + /** + * Adds a link event listener. + * + * @since 2.0 + * @param[in] listener The event listener to add + * @see RemoveUiLinkEventListener() + */ + result AddUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + + /** + * Removes the specified link event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * @param[in] listener The event listener to remove + * @see AddUiLinkEventListener() + */ + result RemoveUiLinkEventListener(Tizen::Ui::IUiLinkEventListener& listener); + +// Text + /** + * Appends the specified character at the end of the text. + * + * @since 2.0 + * @return An error code + * @param[in] character The character to add + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The method modifies the text buffer that is managed by the TextBox control. + * To display the changes, the control must be drawn again. + */ + result AppendCharacter(const Tizen::Base::Character& character); + + /** + * Appends the specified text at the end of the text. + * + * @since 1.0 + * @return An error code + * @param[in] text The text to append + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks To denote the end of a line use '\\n'. @n + * The method modifies the text buffer that is managed by the TextBox control. + * To display the changes, the control must be drawn again. + */ + result AppendText(const Tizen::Base::String& text); + + /** + * Clears text that is displayed by the TextBox control. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The method modifies the text buffer that is managed by the TextBox control. + * To display the changes, the control must be drawn again. + */ + result Clear(void); + + /** + * Gets the number of the lines contained in the TextBox control. + * + * @since 2.0 + * @return The line count of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetLineCount(void) const; + + /** + * Gets the text that is displayed by the TextBox control. + * + * @since 2.0 + * @return The text of the TextBox control, @n + * else an empty string if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetText() + */ + Tizen::Base::String GetText(void) const; + + /** + * Gets a portion of the text that is displayed by the TextBox control. + * + * @since 2.0 + * @return The specified portion of the text, @n + * else an empty string if an error occurs + * @param[in] start The starting index of range + * @param[in] end The last index of range + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or the index is greater + * than the number of elements or less than zero. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetText() + */ + Tizen::Base::String GetText(int start, int end) const; + + /** + * Gets the length of the text that is displayed by the TextBox control. + * + * @since 2.0 + * @return The length of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetTextLength(void) const; + + /** + * Inserts the character at the specified index. + * + * @since 2.0 + * @return An error code + * @param[in] index The position at which to insert the character + * @param[in] character The character to insert + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure, or @c index is greater than the number of elements or less than zero. + * @exception E_SYSTEM A system error occurred. + */ + result InsertCharacterAt(int index, const Tizen::Base::Character& character); + + /** + * Inserts the text at the specified index. + * + * @since 2.0 + * @return An error code + * @param[in] index The position at which to insert the text + * @param[in] text The text to insert + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the data structure, or @c index is greater than the number of elements or less than zero. + * @exception E_SYSTEM A system error occurred. + */ + result InsertTextAt(int index, const Tizen::Base::String& text); + + /** + * Sets the text to display. + * + * @since 2.0 + * @return An error code + * @param[in] text The text to display + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks To denote the end of a line use '\\n'. @n + * The method modifies the text buffer that is managed by the TextBox control. + * To display the changes, the control must be drawn again. + */ + result SetText(const Tizen::Base::String& text); + +// Line Spacing + /** + * Gets the line spacing. + * + * @since 2.0 + * @return The line spacing, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetLineSpacing() + */ + int GetLineSpacing(void) const; + + /** + * Sets the line spacing. @n + * The line spacing is determined by multiplying @c multiplier to the default line spacing and adding @c extra. + * @code + * The line spacing = (default line spacing) * multiplier + extra + * @endcode + * @since 2.0 + * @return An error code + * @param[in] multiplier The line spacing multiplier + * @param[in] extra The extra line spacing + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified parameter is invalid. @n + * -- The specified line spacing value cannot be supported. + * @exception E_SYSTEM A system error occurred. + * @see GetLineSpacing() + */ + result SetLineSpacing(int multiplier, int extra); + + // Text Alignment + /** + * Gets the horizontal text alignment. + * + * @since 2.0 + * @return The horizontal text alignment + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextAlignment() + */ + HorizontalAlignment GetTextAlignment(void) const; + + /** + * Sets the horizontal text alignment. + * + * @since 2.0 + * @return An error code + * @param[in] alignment The horizontal text alignment + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetTextAlignment() + */ + result SetTextAlignment(HorizontalAlignment alignment); + +// Text Size + /** + * Gets the text size of the TextBox control. + * + * @since 2.0 + * @return The size of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextSize() + */ + int GetTextSize(void) const; + + /** + * Gets the text total height of the TextBox control. + * + * @since 2.0 + * @return The total height of the text, @n + * else @c -1 if an error occurs + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + int GetTextTotalHeight(void) const; + + /** + * Sets the text size. + * + * @since 2.0 + * @return An error code + * @param[in] size The text size + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid.@n + * -- The specified @c size cannot be negative integer. + * @exception E_SYSTEM A system error occurred. + * @see GetTextSize() + */ + result SetTextSize(int size); + +// Text Font + /** + * Gets the font typeface name and the style mask of the TextBox control. + * + * @since 2.0 + * @return An error code + * @param[out] typefaceName The name of the font typeface + * @param[out] style The text style (see TextBoxTextStyle) + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks Multiple styles can be combined using the bitwise OR operator. + * @see SetFontType() + * @see Tizen::Graphics::Font::GetSystemFontListN() + * @see TextBoxTextStyle + */ + result GetFontType(Tizen::Base::String& typefaceName, unsigned long& style) const; + + unsigned long GetTextStyle(void) const; + + /** + * Sets the font and the style mask of the TextBox control. + * + * @since 2.0 + * @return An error code + * @param[in] typefaceName The name of the font typeface + * @param[in] style The text style @n + * Multiple styles can be combined using the bitwise OR operator(see TextBoxTextStyle). + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG A specified input parameter is invalid, or the specified font typeface is not supported. + * @exception E_SYSTEM A system error occurred. + * @remarks The specified font typeface must be one of the system fonts. @n + * @c italic and @c bold cannot be applied at the same time. If the specified style mask contains both @c italic and @c bold, @c italic will be applied. + * @see GetFontType() + * @see Tizen::Graphics::Font::GetSystemFontListN() + * @see TextBoxTextStyle + */ + result SetFontType(const Tizen::Base::String& typefaceName, unsigned long style); + + result SetTextStyle(unsigned long style); + + /** + * Sets the font to render the text. + * + * @since 2.0 + * @return An error code + * @param[in] font The text font + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks All previously set text attributes (style, weight, decoration, and size) will be discarded. + */ + result SetFont(const Tizen::Graphics::Font& font); + +// Text Block + /** + * Releases the selection of the current text block. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetBlockRange() + * @see SetBlockRange() + */ + result ReleaseBlock(void); + + /** + * Gets the start and the end index of the currently selected text block. + * + * @since 2.0 + * @return An error code + * @param[out] start The start index of the text block + * @param[out] end The end index of the text block + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The method returns @c start = 0 and @c end = 0 if there is no selected text block. + * @see ReleaseBlock() + * @see SetBlockRange() + */ + result GetBlockRange(int& start, int& end) const; + + /** + * Sets the specified block of the text. + * + * @since 2.0 + * @return An error code + * @param[in] start The start index of the text block + * @param[in] end The end index of the text block + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE The specified index is outside the bounds of the data structure, or either the @c start or @c end parameters are greater than the number of elements or less than zero. + * @exception E_SYSTEM A system error occurred. + * @see ReleaseBlock() + * @see GetBlockRange() + */ + result SetBlockRange(int start, int end); + +// Appearances + /** + * Gets the color of the TextBox control for the specified status. + * + * @since 2.0 + * @return The color of the TextBox control, @n + * else RGBA (0,0,0,0) if an error occurs + * @exception E_SUCCESS The method was successful. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetColor() + */ + Tizen::Graphics::Color GetColor(TextBoxStatus status) const; + + /** + * Gets the text color of the specified text color type. + * + * @since 2.0 + * @return The color, @n + * else RGBA (0,0,0,0) if an error occurs + * @param[in] type The text color type + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see SetTextColor() + */ + Tizen::Graphics::Color GetTextColor(TextBoxTextColor type) const; + + /** + * Sets the background bitmap of the TextBox control. + * + * @since 2.0 + * @return An error code + * @param[in] status The state of the TextBox control + * @param[in] bitmap The background bitmap + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see SetBackgroundColor() + */ + result SetBackgroundBitmap(TextBoxStatus status, const Tizen::Graphics::Bitmap& bitmap); + + /** + * Sets the color of the TextBox control for the specified status. + * + * @since 2.0 + * @return An error code + * @param[in] status The state of the TextBox control + * @param[in] color The color to set + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetColor() + */ + result SetColor(TextBoxStatus status, const Tizen::Graphics::Color& color); + + /** + * Sets the text color of the TextBox control for the specified text type. + * + * @since 2.0 + * @return An error code + * @param[in] type The text color type + * @param[in] color The text color to set + * @exception E_SUCCESS The method was successful. + * @exception E_SYSTEM A system error occurred. + * @see GetTextColor() + */ + result SetTextColor(TextBoxTextColor type, const Tizen::Graphics::Color& color); + + /** + * Adds a text block event listener. + * + * @since 2.0 + * @param[in] listener The event listener to add + * @remarks Programmatically modifying the text selection does not cause the text block selection event to fire. + * @see RemoveTextBlockEventListener() + */ + result AddTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + /** + * Removes the specified text block event listener. @n + * The removed listener cannot listen to events when they are fired. + * + * @since 2.0 + * @param[in] listener The event listener to remove + * @see AddTextBlockEventListener() + */ + result RemoveTextBlockEventListener(Tizen::Ui::ITextBlockEventListener& listener); + + virtual Tizen::Graphics::Dimension GetContentSize(void) const; + +// Operation +public: + // callback + virtual result OnBoundsChanged(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect); + virtual void OnLinkClicked(Tizen::Ui::_Control& source, const Tizen::Base::String& text, Tizen::Base::Utility::LinkType linkType, const Tizen::Base::String& link); + virtual void OnTextBlockSelected(Tizen::Ui::_Control& source, int start, int end); + +public: + static _TextBoxImpl* GetInstance(TextBox& textBox); + static const _TextBoxImpl* GetInstance(const TextBox& textBox); + +protected: + + // + // This is internal. If used in an application, the application can get rejected during the certification process. + // Frees the resources allocated by this control and destroys its native window if it is present). + // + virtual result Dispose(void); + + // + // This is internal. Converts text color type between the Edit control and the TextBox control. + // + EditTextColor ConvertTextColorType(TextBoxTextColor color) const; + + // + // This is internal. Converts text color type between the Edit control and the TextBox control. + // + EditStatus ConvertStatus(TextBoxStatus status) const; + +private: + _TextBoxImpl(const _TextBoxImpl&); + _TextBoxImpl& operator =(const _TextBoxImpl&); + +private: + _Edit* __pEdit; + _PublicTextBlockEvent* __pPublicTextBlockEvent; + _PublicLinkEvent* __pPublicLinkEvent; + unsigned long __autoLinkMask; + +}; // _TextBoxImpl + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TEXT_BOX_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_TextEvent.h b/src/ui/inc/FUiCtrl_TextEvent.h new file mode 100644 index 0000000..0efebce --- /dev/null +++ b/src/ui/inc/FUiCtrl_TextEvent.h @@ -0,0 +1,114 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TextEvent.h + * @brief This is the header file for _TextEvent class. + * @version 3.0 + * + * This header file contains declaration of _TextEvent class. + * + */ +#ifndef _FUI_CTRL_TEXT_EVENT_H_ +#define _FUI_CTRL_TEXT_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum CoreTextEventStatus +{ + CORE_TEXT_EVENT_CHANGED, + CORE_TEXT_EVENT_CANCELED +}; + +/** +* @class _TextEvent +* @brief This class handles a action event. It is inherited from Event class. +* +* The Window(root of all widgets) class has an instance of the _TextEvent class as a member variable. +* Applications can register action event listeners through it. When a action event occurred, +* the _ActionEvent class finds listener and calls the appropriate listener's method. +* +*/ +class _TextEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class destructor. + * + */ + virtual ~_TextEvent(void); + + static _TextEvent* CreateInstanceN(const Tizen::Ui::_Control& source); + +// Accessors +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::_Control* GetSource(void) const; + +// Operations +protected: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _TextEvent(const Tizen::Ui::_Control& source); + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @param[in] listener It is a event listener related to this action event. + * @param[in] arg It is an argument-like instance of action event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IActionEventListener class or + * the p__ActionEventArg is not the instance of _ActionEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +public: + static Tizen::Base::Runtime::IEventArg* CreateTextEventArgN(CoreTextEventStatus status); + +//Attributess +private: + const Tizen::Ui::_Control* __pSource; +}; // _TextEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_TEXT_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_TimePickerImpl.h b/src/ui/inc/FUiCtrl_TimePickerImpl.h new file mode 100644 index 0000000..6fe1945 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TimePickerImpl.h @@ -0,0 +1,97 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TimePickerImpl.h + * @brief This is the header file for the _TimePickerImpl class. + */ + +#ifndef _FUI_CTRL_INTERNAL_TIMEPICKER_IMPL_H_ +#define _FUI_CTRL_INTERNAL_TIMEPICKER_IMPL_H_ + +#include +#include "FUi_WindowImpl.h" +#include "FUiCtrl_DateTimePicker.h" +#include "FUiCtrl_IDateTimeChangeEventListener.h" +#include "FUiCtrl_PublicDateTimeChangeEvent.h" + +namespace Tizen { namespace Ui +{ +class ITimeChangeEventListener; +}} + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _TimePickerImpl + : public _WindowImpl + , public _IDateTimeChangeEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + class TimePickerSizeInfo : public _ControlImpl::SizeInfo + { + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; + virtual Tizen::Graphics::Dimension GetDefaultMaximumSize(_ControlOrientation orientation) const; + }; + +public: + static _TimePickerImpl* CreateTimePickerImplN(TimePicker* pControl, const Tizen::Base::String& title = L""); + virtual ~_TimePickerImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const TimePicker& GetPublic(void) const; + virtual TimePicker& GetPublic(void); + virtual const _DateTimePicker& GetCore(void) const; + virtual _DateTimePicker& GetCore(void); + + result AddTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener); + result RemoveTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener); + + void SetCurrentTime(void); + result SetHour(int hour); + int GetHour(void) const; + result SetMinute(int minute); + int GetMinute(void) const; + void SetTime(const Tizen::Base::DateTime& time); + Tizen::Base::DateTime GetTime(void) const; + void Set24HourNotationEnabled(bool enable); + + virtual result OnAttachedToMainTree(void); + virtual void OnDateTimeChanged(const Tizen::Ui::_Control& source, int year, int month, int day, int hour, int minute); + virtual void OnDateTimeChangeCanceled(const Tizen::Ui::_Control& source); + virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation); + +public: + static _TimePickerImpl* GetInstance(TimePicker& timePicker); + static const _TimePickerImpl* GetInstance(const TimePicker& timePicker); + +private: + result SetYear(int year); + result SetMonth(int month); + result SetDay(int day); + + _TimePickerImpl(TimePicker* pPublic, _DateTimePicker* pCore); + _TimePickerImpl(const _TimePickerImpl&); + _TimePickerImpl& operator =(const _TimePickerImpl&); + +private: + _PublicDateTimeChangeEvent* __pPublicDateTimeChangeEvent; +}; // _TimePickerImpl + +}}} // Tizen::Ui::Controls + +#endif //_FUI_CTRL_INTERNAL_TIMEPICKER_IMPL_H_ diff --git a/src/ui/inc/FUiCtrl_TokenEdit.h b/src/ui/inc/FUiCtrl_TokenEdit.h new file mode 100644 index 0000000..aef2c29 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TokenEdit.h @@ -0,0 +1,131 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TokenEdit.h + * @brief This is the header file for the _TokenEdit class. + * + * This header file contains the declarations of the %_TokenEdit class. + */ +#ifndef _FUICTRL_INTERNAL_TOKEN_EDIT_H_ +#define _FUICTRL_INTERNAL_TOKEN_EDIT_H_ + +#include +#include "FUiCtrl_Edit.h" +#include "FUiCtrl_ITokenFilter.h" + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +class _TokenEditPresenter; + +const int TOKEN_COLOR_MAX = 2; + +class _TokenEdit + : virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer + , virtual public Tizen::Ui::_ITouchGestureEventListener + , public Tizen::Ui::Controls::_Edit +{ + +public: + _TokenEdit(void); + + virtual ~_TokenEdit(void); + + static _TokenEdit* CreateTokenEditN(void); + + DECLARE_CLASS_BEGIN(_TokenEdit, _Edit); + DECLARE_PROPERTY("normalTokenColor", GetPropertyNormalTokenColor, SetPropertyNormalTokenColor); + DECLARE_PROPERTY("selectedTokenColor", GetPropertySelectedTokenColor, SetPropertySelectedTokenColor); + DECLARE_PROPERTY("tokenTextColor", GetPropertyTokenTextColor, SetPropertyTokenTextColor); + DECLARE_PROPERTY("selectedTokenTextColor", GetPropertySelectedTokenTextColor, SetPropertySelectedTokenTextColor); + DECLARE_PROPERTY("tokenEditModeEnabled", GetPropertyTokenEditModeEnabled, SetPropertyTokenEditModeEnabled); + DECLARE_CLASS_END(); + +// Properties + result SetPropertyNormalTokenColor(const Variant& color); + Variant GetPropertyNormalTokenColor(void) const; + result SetPropertySelectedTokenColor(const Variant& color); + Variant GetPropertySelectedTokenColor(void) const; + result SetPropertyTokenTextColor(const Variant& color); + Variant GetPropertyTokenTextColor(void) const; + result SetPropertySelectedTokenTextColor(const Variant& color); + Variant GetPropertySelectedTokenTextColor(void) const; + result SetPropertyTokenEditModeEnabled(const Variant& enable); + Variant GetPropertyTokenEditModeEnabled(void) const; + + virtual void OnDraw(void); + result SetTokenFilter(const _ITokenFilter* pFilter); + _ITokenFilter* GetTokenFilter(void) const; + result AppendToken(const Tizen::Base::String& token); + result InsertTokenAt(int index, const Tizen::Base::String& token); + Tizen::Base::String GetTokenAt(int index) const; + int GetTokenCount(void) const; + int GetSelectedTokenIndex(void) const; + bool IsTokenEditModeEnabled(void) const; + result RemoveTokenAt(int index); + result SetTokenSelected(int index, bool selected); + result SetTokenEditModeEnabled(bool enable); + Tizen::Graphics::Color GetTokenColor(ExpandableEditAreaTokenStatus status) const; + Tizen::Graphics::Color GetTokenTextColor(void) const; + result SetTokenColor(ExpandableEditAreaTokenStatus status, const Tizen::Graphics::Color& color); + result SetTokenTextColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Color GetSelectedTokenTextColor(void) const; + result SetSelectedTokenTextColor(const Tizen::Graphics::Color& color); + virtual result SetTitleText(const Tizen::Base::String& title); + virtual Tizen::Base::String GetTitleText(void) const; + void SetAutoShrinkModeEnabled(bool enable); + bool IsAutoShrinkModeEnabled(void) const; + result ProcessTokenFiltering(const Tizen::Base::String& inputString, Tizen::Base::String& replaceString, bool& enable); + + // Touch callbacks + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + + virtual result OnAttachedToMainTree(void); + +private: + _TokenEdit(const _TokenEdit& rhs); + _TokenEdit& operator =(const _TokenEdit& rhs); + + virtual void OnBoundsChanged(void); + +// Attributes +private: + _TokenEditPresenter* __pTokenEditPresenter; + Tizen::Graphics::Color __tokenColor[TOKEN_COLOR_MAX]; + + Tizen::Graphics::Color __tokenTextColor[TOKEN_COLOR_MAX]; + + bool __isSelectedTokenTextColorSet; + + _ITokenFilter* __pTokenFilter; + + Tizen::Ui::_AccessibilityElement* __pDescriptionTextAccessibilityElement; + Tizen::Ui::_AccessibilityElement* __pHiddenTokenCountAccessibilityElement; + Tizen::Ui::_AccessibilityElement* __pExpandableButtonAccessibilityElement; +}; // _TokenEdit + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_TOKEN_EDIT_H_ diff --git a/src/ui/inc/FUiCtrl_TokenEditModel.h b/src/ui/inc/FUiCtrl_TokenEditModel.h new file mode 100644 index 0000000..07ca470 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TokenEditModel.h @@ -0,0 +1,42 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TokenEditModel.h + * @brief This is the header file for the _TokenEditModel class. + * + * This header file contains the declarations of the %_TokenEditModel class. + */ +#ifndef _FUICTRL_INTERNAL_TOKEN_EDIT_MODEL_H_ +#define _FUICTRL_INTERNAL_TOKEN_EDIT_MODEL_H_ + +#include "FUiCtrl_EditModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _TokenEditModel + : public Tizen::Ui::Controls::_EditModel +{ +public: + _TokenEditModel(void); + + virtual ~_TokenEditModel(void); +}; // _TokenEditModel + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_TOKEN_EDIT_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_TokenEditPresenter.h b/src/ui/inc/FUiCtrl_TokenEditPresenter.h new file mode 100644 index 0000000..e4d5151 --- /dev/null +++ b/src/ui/inc/FUiCtrl_TokenEditPresenter.h @@ -0,0 +1,257 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_TokenEditPresenter.h + * @brief This is the header file for the _TokenEditPresenter class. + * + * This header file contains the declarations of the %_TokenEditPresenter class. + */ +#ifndef _FUI_CTRL_INTERNAL_TOKEN_EDIT_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_TOKEN_EDIT_PRESENTER_H_ + +#include +#include +#include +#include +#include "FUiCtrl_EditPresenter.h" +#include "FUiCtrl_TokenEditModel.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +#define MAX_TOKEN_COUNT 100; +const int ANIMATION_DURATION_BOUNDS = 167; +const int ANIMATION_DURATION_OPACITY = 83; + +class _TokenEdit; + +class SineTimingFunction + : public Tizen::Ui::Animations::IVisualElementAnimationTimingFunction +{ +public: + float CalculateProgress(float timeProgress) const; +}; + +class _TokenEditPresenter + : public Tizen::Ui::Controls::_EditPresenter + , virtual public Tizen::Base::Runtime::IEventListener + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener +{ +public: + _TokenEditPresenter(void); + + virtual ~_TokenEditPresenter(void); + + result DisposeTokenEditPresenter(void); + + static _TokenEditPresenter* CreateTokenEditPresenterN(void); + + result Initialize(const _Control& control); + + virtual result Draw(Tizen::Graphics::Canvas& canvas); + + result MakeToken(const Tizen::Base::String& tokenString); + + result MakeToken(void); + + result InsertTokenAt(int index, const Tizen::Base::String& token, bool isUser = false); + + Tizen::Base::String GetTokenAt(int index) const; + + int GetTokenCount(void) const; + + int GetSelectedTokenIndex(void) const; + + bool IsTokenEditModeEnabled(void) const; + + result RemoveTokenAt(int index, bool isClearText = false); + + result SetTokenSelected(int index, bool selected); + + result SetTokenEditModeEnabled(bool enable); + + result CalculateTokenPositionFromIndex(int startIndex, bool leftWard = true); + + virtual result SetInitialBounds(void); + + result CalculateDescriptionTextRect(const Tizen::Base::String& descriptionText); + + virtual void OnCursorTimerExpired(void); + + virtual result AdjustFlexibleHeight(void); + + virtual int CalculateFlexibleHeight(void); + + virtual result DrawScrollBar(void); + + void SetAutoShrinkModeEnabled(bool enable); + + bool IsAutoShrinkModeEnabled(void) const; + + void SetDescriptionText(Tizen::Base::String descriptionText); + + Tizen::Base::String GetDescriptionText(void) const; + + Tizen::Graphics::Rectangle GetTextBounds(void) const; + + virtual result CutText(void); + + result SetLineSpacing(int linePixelGap); + + int GetLineSpacing() const; + + Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationN(Tizen::Ui::Animations::VisualElement& source, bool create); + + virtual bool OnFocusGained(void); + virtual bool OnFocusLost(void); + + virtual result SetFlexBounds(const Tizen::Graphics::Rectangle& bounds); + + // Touch callbacks + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + + virtual void OnInputConnectionTextCommitted(InputConnection& source, const Tizen::Base::String& committedText); + virtual void DeleteSurroundingText(InputConnection& source, int offset, int charCount); + virtual void OnTextCommitted(const Tizen::Base::String& commitText); + virtual void OnSurroundingTextDeleted(int offset, int charCount); + + virtual bool OnTapGestureDetected(void); + virtual bool OnLongPressGestureDetected(void); + + virtual void OnVisualElementAnimationFinished (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, bool completedNormally); + virtual void OnVisualElementAnimationRepeated (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target, long currentRepeatCount){} + virtual void OnVisualElementAnimationStarted (const Tizen::Ui::Animations::VisualElementAnimation &animation, const Tizen::Base::String &keyName, Tizen::Ui::Animations::VisualElement &target){} + void OnBoundsChanged(void); + +private: + bool DrawToken(int count = -1); + Tizen::Graphics::Color GetTokenEditColor(const ExpandableEditAreaTokenStatus status) const; + Tizen::Graphics::Color GetTokenEditTextColor(const ExpandableEditAreaTokenStatus status) const; + result InitializeTokenVisibilityAt(int index); + bool DrawDescriptionText(void); + result SetDescriptionTextRect(const Tizen::Graphics::Rectangle& rect); + Tizen::Graphics::Rectangle GetDescriptionTextRect(void) const; + result TrimTokenAndAdjustEllipsisAt(int index); + int GetTokenIndexFromCoordinate(const Tizen::Graphics::Point point) const; + result SetEditingTokenTextBounds(int index, bool isSetText = true); + result ProcessTokeningByTouchEvent(const _Control& source, const _TouchInfo& touchinfo); + result SetTokenBoundsByTouchInfo(const _TouchInfo& touchinfo); + result RecalculateTokenBounds(int position); + result CheckTokenScrolling(bool scrollToCursorPosition = false); + result SetTokenVisualElementBounds(int index, const Tizen::Graphics::Rectangle& bounds); + int CalculateVisibleTokenCount(void); + Tizen::Graphics::Rectangle CalculateHiddenTokenCountDisplayBounds(int visibleTokenCount); + int CalculateAutoShrinkAlignmentValue(int hiddenTokenCount) const; + result DrawHiddenTokenCount(void); + result InitializeDescriptionText(void); + + int ResizeTokenAndAdjustEllipsis(int index, int value, bool isTokenShrink); + int PickToken(int index, Tizen::Graphics::Rectangle tokenDispRect, bool isTokenShrink); + void RepositionToken(int currentTokenIndex, int moveDistance, bool isTokenShrink); + int GetPickedTokenEndPoint(int index, Tizen::Graphics::Rectangle tokenDispRect); + void ShrinkTokens(); + void ExpandTokens(); + +private: + Tizen::Ui::Controls::_TokenEdit* __pTokenEdit; + + Tizen::Base::Collection::LinkedList* __pTokenList; + + Tizen::Base::String __delimiter; + + Tizen::Graphics::Bitmap* __pTokenBgBitmap; + + int __pressedTokenIndex; + + bool __isEditingToken; + + int __edittingTokenIndex; + + Tizen::Graphics::Rectangle __clientRect; + Tizen::Graphics::Rectangle __initTextRect; + + bool __isEditModeEnabled; + + Tizen::Ui::Animations::_VisualElement* __pDescriptionTextVisualElement; + + Tizen::Graphics::_Text::TextObject* __pDescriptionTextTextObject; + + Tizen::Graphics::Rectangle __descriptionTextRect; + + Tizen::Graphics::Font* __pDescriptionTextFont; + + bool __isTokenEditingFinished; + + int __prevScrollValue; + + int __scrollValue; + + bool __isTokenScrolling; + + bool __isNeedToScroll; + + int __maxScrollValue; + + bool __autoShrink; + + Tizen::Graphics::Rectangle __hiddenTokenDisplayCountBounds; + + Tizen::Ui::Animations::_VisualElement* __pHiddenTokenCountVisualElement; + + int __autoShrinkAlignmentValue; + + Tizen::Graphics::_Text::TextObject* __pHiddenTokenCountTextObject; + + Tizen::Base::String __descriptionText; + + bool __isPopupVisible; + + bool __isLongPressed; + + int __lineSpacing; + + int __animatingIndex; + + int __lastTokenIndex; + + const Tizen::Ui::Animations::IVisualElementAnimationTimingFunction* __pTimingFunction; + + Tizen::Graphics::Rectangle __descriptionTextRectForScroll; + + int __previousTitleWidth; + + Tizen::Graphics::Rectangle __previousEditBounds; + + bool __isTokenEditPresenterInitialized; + + bool __isFocus; + + int __previousCursorPosition; + + bool __isScrollValueChanged; + + int __lineAdded; + + bool __isScrollValueModified; + +}; // _TokenEditPresenter + +}}} // Tizen::Ui::Controls + +#endif // _FUICTRL_INTERNAL_TOKEN_EDIT_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_Toolbar.h b/src/ui/inc/FUiCtrl_Toolbar.h new file mode 100644 index 0000000..900bb51 --- /dev/null +++ b/src/ui/inc/FUiCtrl_Toolbar.h @@ -0,0 +1,481 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_Toolbar.h + * @brief This is the header file for the _Toolbar class. + * + * This header file contains the declarations of the %_Toolbar class. + */ + +#ifndef _FUI_CTRL_INTERNAL_TOOLBAR_H_ +#define _FUI_CTRL_INTERNAL_TOOLBAR_H_ + +#include +#include +#include +#include "FUi_Control.h" +#include "FUi_ITouchLongPressGestureEventListener.h" +#include "FUi_ITouchEventListener.h" +#include "FUiCtrl_Animation.h" +#include "FUiCtrl_Button.h" +#include "FUiCtrl_Label.h" + +namespace Tizen { namespace Ui +{ +class _TouchLongPressGestureDetector; +}} + +namespace Tizen { namespace Ui +{ +class _AccessibilityElement; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _ToolbarPresenter; +class _ActionEvent; + +const int TOOLBAR_BUTTON_MAX_STATE_COUNT = 4; +const int TOOLBAR_ITEM_MAX_STATE_COUNT = 5; +const int TOOLBAR_ACTION_ID_MIN = 0; +const int TOOLBAR_ACTION_ID_MAX = (int) 0x7FFFFFFF; +const int TOOLBAR_MORE_BUTTON_ID = -2; +const int TAB_ITEM_MAX = 15; +const int SEGMENTED_ITEM_MAX = 4; +const int PROCESSING_ANIMATION_COUNT = 30; + +enum ToolbarStyle +{ + TOOLBAR_TITLE = 0, + TOOLBAR_HEADER_SEGMENTED, + TOOLBAR_HEADER_SEGMENTED_WITH_TITLE, + TOOLBAR_TAB, + TOOLBAR_TAB_WITH_TITLE, + TOOLBAR_SEGMENTED, + TOOLBAR_TEXT, + TOOLBAR_ICON, + TOOLBAR_ICON_TEXT, + TOOLBAR_SOFTKEY +}; + +enum ToolbarButton +{ + LEFT_BUTTON = 0, + RIGHT_BUTTON, + BACK_BUTTON, + MIDDLE_BUTTON, + BUTTON_MAX +}; + +enum ButtonType +{ + TOOLBAR_BUTTON = 0, + TOOLBAR_ITEM +}; + +enum ToolbarAnimationPosition +{ + TOOLBAR_ANIMATION_POSITION_TITLE = 0, + TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT, + TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT, + TOOLBAR_ANIMATION_POSITION_MAX +}; + +/** + * @class _Toolbar + * @brief _Toolbar class is the core class of Header, Footer classes + * @since 2.0 + */ +class _OSP_EXPORT_ _Toolbar + : public Tizen::Ui::_Control + , public Tizen::Ui::_ITouchLongPressGestureEventListener + , public Tizen::Ui::Controls::_IAnimationEventListener + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public Tizen::Ui::_IUiEventListener + , virtual public Tizen::Ui::_IUiEventPreviewer + , virtual public Tizen::Ui::_ITouchGestureEventListener +{ + DECLARE_CLASS_BEGIN(_Toolbar, _Control); + DECLARE_PROPERTY("color", GetPropertyColor, SetPropertyColor); + DECLARE_PROPERTY("descriptionText", GetPropertyDescriptionText, SetPropertyDescriptionText); + DECLARE_PROPERTY("descriptionTextColor", GetPropertyDescriptionTextColor, SetPropertyDescriptionTextColor); + DECLARE_PROPERTY("titleText", GetPropertyTitleText, SetPropertyTitleText); + DECLARE_PROPERTY("titleTextColor", GetPropertyTitleTextColor, SetPropertyTitleTextColor); + DECLARE_PROPERTY("disabledButtonColor", GetPropertyDisabledButtonColor, SetPropertyDisabledButtonColor); + DECLARE_PROPERTY("disabledButtonTextColor", GetPropertyDisabledButtonTextColor, SetPropertyDisabledButtonTextColor); + DECLARE_PROPERTY("highlightedButtonColor", GetPropertyHighlightedButtonColor, SetPropertyHighlightedButtonColor); + DECLARE_PROPERTY("highlightedButtonTextColor", GetPropertyHighlightedButtonTextColor, SetPropertyHighlightedButtonTextColor); + DECLARE_PROPERTY("normalButtonColor", GetPropertyNormalButtonColor, SetPropertyNormalButtonColor); + DECLARE_PROPERTY("normalButtonTextColor", GetPropertyNormalButtonTextColor, SetPropertyNormalButtonTextColor); + DECLARE_PROPERTY("pressedButtonColor", GetPropertyPressedButtonColor, SetPropertyPressedButtonColor); + DECLARE_PROPERTY("pressedButtonTextColor", GetPropertyPressedButtonTextColor, SetPropertyPressedButtonTextColor); + DECLARE_PROPERTY("disabledItemColor", GetPropertyDisabledItemColor, SetPropertyDisabledItemColor); + DECLARE_PROPERTY("disabledItemTextColor", GetPropertyDisabledItemTextColor, SetPropertyDisabledItemTextColor); + DECLARE_PROPERTY("highlightedItemColor", GetPropertyHighlightedItemColor, SetPropertyHighlightedItemColor); + DECLARE_PROPERTY("highlightedItemTextColor", GetPropertyHighlightedItemTextColor, SetPropertyHighlightedItemTextColor); + DECLARE_PROPERTY("normalItemColor", GetPropertyNormalItemColor, SetPropertyNormalItemColor); + DECLARE_PROPERTY("normalItemTextColor", GetPropertyNormalItemTextColor, SetPropertyNormalItemTextColor); + DECLARE_PROPERTY("pressedItemColor", GetPropertyPressedItemColor, SetPropertyPressedItemColor); + DECLARE_PROPERTY("pressedItemTextColor", GetPropertyPressedItemTextColor, SetPropertyPressedItemTextColor); + DECLARE_PROPERTY("selectedItemColor", GetPropertySelectedItemColor, SetPropertySelectedItemColor); + DECLARE_PROPERTY("selectedItemTextColor", GetPropertySelectedItemTextColor, SetPropertySelectedItemTextColor); + DECLARE_CLASS_END(); + + + result SetPropertyColor(const Variant& color); + Variant GetPropertyColor(void) const; + result SetPropertyDescriptionText(const Variant& text); + Variant GetPropertyDescriptionText(void) const; + result SetPropertyDescriptionTextColor(const Variant& color); + Variant GetPropertyDescriptionTextColor(void) const; + result SetPropertyTitleText(const Variant& text); + Variant GetPropertyTitleText(void) const; + result SetPropertyTitleTextColor(const Variant& color); + Variant GetPropertyTitleTextColor(void) const; + result SetPropertyDisabledButtonColor(const Variant& color); + Variant GetPropertyDisabledButtonColor(void) const; + result SetPropertyDisabledButtonTextColor(const Variant& color); + Variant GetPropertyDisabledButtonTextColor(void) const; + result SetPropertyHighlightedButtonColor(const Variant& color); + Variant GetPropertyHighlightedButtonColor(void) const; + result SetPropertyHighlightedButtonTextColor(const Variant& color); + Variant GetPropertyHighlightedButtonTextColor(void) const; + result SetPropertyNormalButtonColor(const Variant& color); + Variant GetPropertyNormalButtonColor(void) const; + result SetPropertyNormalButtonTextColor(const Variant& color); + Variant GetPropertyNormalButtonTextColor(void) const; + result SetPropertyPressedButtonColor(const Variant& color); + Variant GetPropertyPressedButtonColor(void) const; + result SetPropertyPressedButtonTextColor(const Variant& color); + Variant GetPropertyPressedButtonTextColor(void) const; + result SetPropertyDisabledItemColor(const Variant& color); + Variant GetPropertyDisabledItemColor(void) const; + result SetPropertyDisabledItemTextColor(const Variant& color); + Variant GetPropertyDisabledItemTextColor(void) const; + result SetPropertyHighlightedItemColor(const Variant& color); + Variant GetPropertyHighlightedItemColor(void) const; + result SetPropertyHighlightedItemTextColor(const Variant& color); + Variant GetPropertyHighlightedItemTextColor(void) const; + result SetPropertyNormalItemColor(const Variant& color); + Variant GetPropertyNormalItemColor(void) const; + result SetPropertyNormalItemTextColor(const Variant& color); + Variant GetPropertyNormalItemTextColor(void) const; + result SetPropertyPressedItemColor(const Variant& color); + Variant GetPropertyPressedItemColor(void) const; + result SetPropertyPressedItemTextColor(const Variant& color); + Variant GetPropertyPressedItemTextColor(void) const; + result SetPropertySelectedItemColor(const Variant& color); + Variant GetPropertySelectedItemColor(void) const; + result SetPropertySelectedItemTextColor(const Variant& color); + Variant GetPropertySelectedItemTextColor(void) const; + + +public: + _Toolbar(void); + + virtual ~_Toolbar(void); + + static _Toolbar* CreateToolbarN(bool header); + + virtual result Construct(void); + + result AddItem(_Button* pButton); + + Tizen::Graphics::Bitmap* GetBackgroundBitmap(void) const; + + _Button* GetButton(ToolbarButton position) const; + + Tizen::Graphics::Color GetButtonColor(_ButtonStatus status) const; + + _ButtonStatus GetButtonStatus(ToolbarButton position) const; + + Tizen::Graphics::Color GetButtonTextColor(_ButtonStatus status) const; + + Tizen::Graphics::Color GetColor(void) const; + + Tizen::Base::String GetDescriptionText(void) const; + + Tizen::Graphics::Color GetDescriptionTextColor(void) const; + + int GetFirstEnabledItemIndex(void) const; + + _Button* GetItem(int itemIndex) const; + + Tizen::Graphics::Color GetItemColor(_ButtonStatus status) const; + + int GetItemCount(void) const; + + int GetItemIndexFromPosition(const Tizen::Graphics::Point& point) const; + + result GetItemStatus(int itemIndex, _ButtonStatus& status) const; // Temporarily uses GetItem() instead of this method + + Tizen::Graphics::Color GetItemTextColor(_ButtonStatus status) const; + + int GetSelectedItemIndex(void) const; + + ToolbarStyle GetStyle(void) const; + + Tizen::Graphics::Bitmap* GetTitleIcon(void) const; + + Tizen::Base::String GetTitleText(void) const; + + Tizen::Graphics::Color GetTitleTextColor(void) const; + + HorizontalAlignment GetTitleTextHorizontalAlignment(void) const; + + bool IsInitialDraw(void) const; + + bool IsTabEditModeEnabled(void) const; + + bool IsTransparent(void) const; + + AnimationStatus GetWaitingAnimationStatus(ToolbarAnimationPosition animationPos) const; + + result InsertItemAt(int itemIndex, _Button* pButton); + + bool IsButtonSet(ToolbarButton position) const; + + bool IsUserBackgroundBitmap() const; + + result MoveItem(const int srcIndex, const int destIndex); + + result PauseWaitingAnimation(ToolbarAnimationPosition animationPos); + + result PlayWaitingAnimation(ToolbarAnimationPosition animationPos); + + result RemoveAllButtons(void); + + result RemoveAllItems(void); + + result RemoveButtonAt(ToolbarButton position); + + result RemoveItemAt(int itemIndex); + + result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap); + + result SetButton(ToolbarButton position, _Button* pButton); + + result SetButtonColor(_ButtonStatus status, const Tizen::Graphics::Color& color); + + result SetButtonEnabled(ToolbarButton position, bool enabled); + + result SetButtonTextColor(_ButtonStatus status, const Tizen::Graphics::Color& color); + + result SetButtonBadgeIcon(ToolbarButton position, const Tizen::Graphics::Bitmap* pBadgeIcon); + + result SetButtonNumberedBadgeIcon(ToolbarButton position, int number); + + result SetColor(const Tizen::Graphics::Color& color); + + result SetTranslucentColor(const Tizen::Graphics::Color& color); + + result SetDescriptionText(const Tizen::Base::String& text); + + result SetDescriptionTextColor(const Tizen::Graphics::Color& color); + + result SetItemAt(int itemIndex, const _Button* pButton); + + result SetItemBadgeIcon(int itemIndex, const Tizen::Graphics::Bitmap* pBadgeIcon); + + result SetItemColor(_ButtonStatus status, const Tizen::Graphics::Color& color); + + result SetItemEnabled(int itemIndex, bool enabled); + + result SetItemNumberedBadgeIcon(int itemIndex, int number); + + result SetItemSelected(int itemIndex, bool fire = false); + + result SetItemTextColor(_ButtonStatus status, const Tizen::Graphics::Color& color); + + result SetStyle(ToolbarStyle style); + + result SetTabEditModeEnabled(bool enable); + + result SetTitleIcon(const Tizen::Graphics::Bitmap& bitmap); + + result SetTitleText(const Tizen::Base::String& text, HorizontalAlignment alignment = ALIGNMENT_LEFT); + + result SetTitleTextColor(const Tizen::Graphics::Color& color); + + result SetTransparent(bool transparent); + + result SetWaitingAnimationPosition(ToolbarAnimationPosition animationPos, int x, int y); + + result StopWaitingAnimation(ToolbarAnimationPosition animationPos); + + result InitializeLongPressGesture(void); + + virtual void OnAnimationStopped(const Tizen::Ui::_Control& source); + + virtual void OnBoundsChanged(void); + + virtual void OnChangeLayout(_ControlOrientation orientationStatus); + + virtual void OnDraw(void); + + virtual bool OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture); + + virtual bool OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + void AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); + + void RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener); + + void SetBackEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener, int actionId); + + virtual result OnAttachedToMainTree(void); + + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + + virtual void OnFontInfoRequested(unsigned long& style, int& size); + + Tizen::Graphics::Rectangle GetButtonBounds(ToolbarButton position) const; + + result RealignIcon(_Button* pButton); + + result RealignButtonIcon(_Button* pButton); + + result RearrangeItems(void); + +protected: + result SetPresenter(const _ToolbarPresenter& toolbarPresenter); + + +private: + _Toolbar(const _Toolbar& value); + + _Toolbar& operator =(const _Toolbar& value); + + result ApplyUserGUI(ButtonType buttonType, _Button* pButton); + + int CalculateMinimumToolbarWidth(void); + + result RearrangeHeaderSegmentedItems(void); + + result RearrangeFooterSegmentedItems(void); + + result RearrangeTabItmes(void); + + result RearrangeButtonItems(void); + + result SetAnimation(ToolbarAnimationPosition animationPos); + + result SetColorReplacedBitmap(_Button* pButton, const _ButtonStatus status, const Tizen::Graphics::Color& color, const Tizen::Graphics::Bitmap* pBitmap); + + void InitializeAccessibilityElement(void); + + result AdjustToolbarBounds(void); + + void AddAccessibilityItem(_Button* pButton); + + result Initialize(bool header); + + result InitToolbarColor(void); + +private: + bool __header; + + _ToolbarPresenter* __pToolbarPresenter; + + Tizen::Ui::Controls::_IActionEventListener* __pActionEventListener; + + Tizen::Ui::Controls::_IActionEventListener* __pBackEventListener; + + _TouchLongPressGestureDetector* __pLongPressGesture; + + Tizen::Graphics::Bitmap* __pToolbarBackgroundBitmap; + + Tizen::Graphics::Bitmap* __pTitleIcon; + + Tizen::Graphics::Color __backgroundColor; + + Tizen::Base::String __titleText; + + Tizen::Base::String __descriptionText; + + Tizen::Graphics::Color __descriptionTextColor; + + Tizen::Graphics::Color __transDescriptionTextColor; + + Tizen::Graphics::Color __titleTextColor; + + Tizen::Graphics::Color __transTitleTextColor; + + Tizen::Graphics::Color __itemBackgroundColor[TOOLBAR_ITEM_MAX_STATE_COUNT]; + + Tizen::Graphics::Color __itemTextColor[TOOLBAR_ITEM_MAX_STATE_COUNT]; + + Tizen::Graphics::Color __itemTransBackgroundColor[TOOLBAR_ITEM_MAX_STATE_COUNT]; + + Tizen::Graphics::Color __itemTransTextColor[TOOLBAR_ITEM_MAX_STATE_COUNT]; + + bool __isItemBgColorSetByUser[TOOLBAR_ITEM_MAX_STATE_COUNT]; + + bool __isItemTextColorSetByUser[TOOLBAR_ITEM_MAX_STATE_COUNT]; + + Tizen::Graphics::Color __buttonBackgroundColor[TOOLBAR_BUTTON_MAX_STATE_COUNT]; + + Tizen::Graphics::Color __buttonTextColor[TOOLBAR_BUTTON_MAX_STATE_COUNT]; + + Tizen::Graphics::Color __buttonTransBackgroundColor[TOOLBAR_BUTTON_MAX_STATE_COUNT]; + + Tizen::Graphics::Color __buttonTransTextColor[TOOLBAR_BUTTON_MAX_STATE_COUNT]; + + bool __isButtonBgColorSetByUser[TOOLBAR_BUTTON_MAX_STATE_COUNT]; + + bool __isButtonTextColorSetByUser[TOOLBAR_BUTTON_MAX_STATE_COUNT]; + + + HorizontalAlignment __titleTextAlignment; + + std::vector<_Button*> __pItems; + + _Button* __pButtonItems[BUTTON_MAX]; + + _Animation* __pAnimation[TOOLBAR_ANIMATION_POSITION_MAX]; + + Tizen::Base::Collection::ArrayList* __pAnimationFrameList; + + int __backActionId; + + int __itemCount; + + ToolbarStyle __style; + + bool __transparent; + + bool __isUserBackgroundBitmap; + + Tizen::Graphics::Rectangle __titleTextArea; + + Tizen::Graphics::Rectangle __itemArea; + + Tizen::Ui::_AccessibilityElement* __pTitleTextElement; +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TOOLBAR_H_ diff --git a/src/ui/inc/FUiCtrl_ToolbarModel.h b/src/ui/inc/FUiCtrl_ToolbarModel.h new file mode 100644 index 0000000..2be97f7 --- /dev/null +++ b/src/ui/inc/FUiCtrl_ToolbarModel.h @@ -0,0 +1,66 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ToolbarModel.h + * @brief This is the header file for the _ToolbarModel class. + * + * This header file contains the declarations of the %_ToolbarModel class. + */ + +#ifndef _FUI_CTRL_INTERNAL_TOOLBAR_MODEL_H_ +#define _FUI_CTRL_INTERNAL_TOOLBAR_MODEL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _ToolbarModel + * @brief The model class of _Toolbar class + * @since 2.0 + */ +class _ToolbarModel + : public Tizen::Base::Object +{ + +public: + _ToolbarModel(void); + + virtual ~_ToolbarModel(void); + + result Construct(void); + + int GetSelectedItemIndex(void) const; + + result SetSelectedItemIndex(int itemIndex); + + +private: + _ToolbarModel(const _ToolbarModel& value); + + _ToolbarModel& operator =(const _ToolbarModel& value); + + +private: + int __selectedIndex; + +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TOOLBAR_MODEL_H_ diff --git a/src/ui/inc/FUiCtrl_ToolbarPresenter.h b/src/ui/inc/FUiCtrl_ToolbarPresenter.h new file mode 100644 index 0000000..767821e --- /dev/null +++ b/src/ui/inc/FUiCtrl_ToolbarPresenter.h @@ -0,0 +1,191 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiCtrl_ToolbarPresenter.h + * @brief This is the header file for the _ToolbarPresenter class. + * + * This header file contains the declarations of the %_ToolbarPresenter class. + */ + +#ifndef _FUI_CTRL_INTERNAL_TOOLBAR_PRESENTER_H_ +#define _FUI_CTRL_INTERNAL_TOOLBAR_PRESENTER_H_ + +#include +#include +#include "FUiCtrl_Toolbar.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _Toolbar; +class _ToolbarModel; +class _Label; + +enum ToolbarSeparatorType +{ + TOOLBAR_SEPARATOR_HEADER_BUTTON = 0, + TOOLBAR_SEPARATOR_HEADER_SEGMENT, + TOOLBAR_SEPARATOR_HEADER_SEGMENT_TITLE, + TOOLBAR_SEPARATOR_FOOTER_BUTTON, + TOOLBAR_SEPARATOR_FOOTER_SEGMENT, + TOOLBAR_SEPARATOR_FOOTER_TOOLBAR, + TOOLBAR_SEPARATOR_FOOTER_TAB +}; + +/** + * @class _ToolbarPresenter + * @brief The presenter class of _Toolbar class + * @since 2.0 + */ +class _ToolbarPresenter + : public Tizen::Base::Object + , public Tizen::Base::Runtime::ITimerEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +public: + _ToolbarPresenter(void); + + virtual ~_ToolbarPresenter(void); + + result Construct(const _Toolbar& toolbar); + + result Install(void); + + result Draw(void); + + void DrawBackground(void); + + void DrawDescriptionText(void); + + void DrawEditItem(const Tizen::Graphics::Point& point); + + void DrawSeparator(ToolbarSeparatorType type, const Tizen::Graphics::Point& point, Tizen::Graphics::Canvas* pCanvas); + + void DrawItems(void); + + result DrawTitleText(Tizen::Graphics::Canvas* pCanvas); + + int GetSelectedItemIndex(void) const; + + bool IsInitialDraw(void) const; + + bool IsTabEditModeEnabled(void) const; + + result SetDescriptionText(const Tizen::Base::String& description); + + result SetItemSelected(int itemIndex); + + result SetInitialDrawState(bool state); + + result SetTabEditModeEnabled(bool enable); + + result SetTitleText(const Tizen::Base::String& title, HorizontalAlignment alignment); + + result SetUsableAreaBounds(const Tizen::Graphics::Rectangle& rect); + + bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + + bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + + bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + + bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + + bool OnLongPressGestureDetected(void); + + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + + result TimerForTitleSlideInit(void); + + result TimerForTitleSlideStart(void); + + result TimerForTitleSlideTimeout(void); + + Tizen::Graphics::Rectangle GetTitleTextBounds(void) const; + + Tizen::Graphics::Rectangle GetDescriptionBounds(void) const; + + void OnFontChanged(Tizen::Graphics::Font* pFont); + void OnFontInfoRequested(unsigned long& style, int& size); + void SetFontInfo(unsigned long style, int size); + +protected: + result _SetModel(const _ToolbarModel& toolbarModel); + +private: + result AdjustItemPositionX(int distance); + +private: + _Toolbar* __pToolbar; + + _ToolbarModel* __pToolbarModel; + + bool __initialDraw; + + bool __tabEditEnabled; + + bool __beingEdited; + + bool __touchInitiatedInToolbar; + + int __editItemIndex; + + int __initialPressedItemIndex; + + _ButtonStatus __initialPressesItemStatus; + + _Label* __pEditItem; + + Tizen::Graphics::Bitmap* __pTitleBackgroundBitmap; + + Tizen::Base::Runtime::Timer* __pTitleSlideTimer; + + Tizen::Graphics::Rectangle __titleRect; + + Tizen::Graphics::Rectangle __descriptionRect; + + Tizen::Graphics::Rectangle __toolbarUsableArea; + + Tizen::Graphics::Point __currentTouchPosition; + + Tizen::Base::String __titleText; + + Tizen::Graphics::Font* __pTitleTextFont; + + Tizen::Graphics::Font* __pTextFont; + + Tizen::Graphics::_Text::TextObject* __pDescriptionTextObject; + + Tizen::Graphics::_Text::TextObject* __pTitleTextObject; + + Tizen::Graphics::_Text::TextObjectActionType __titleSlidingAction; + + unsigned long __fontStyle; + int __fontSize; + + bool __touchMoveHandled; + +private: + _ToolbarPresenter(const _ToolbarPresenter& value); + + _ToolbarPresenter& operator =(const _ToolbarPresenter& value); + +}; + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_TOOLBAR_PRESENTER_H_ diff --git a/src/ui/inc/FUiCtrl_UiFastScrollEvent.h b/src/ui/inc/FUiCtrl_UiFastScrollEvent.h new file mode 100644 index 0000000..ffda4b9 --- /dev/null +++ b/src/ui/inc/FUiCtrl_UiFastScrollEvent.h @@ -0,0 +1,111 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_UiFastScrollEvent.h + * @brief This is the header file for _UiFastScrollEvent class. + * + * This header file contains declaration of _UiFastScrollEvent class. + * The ItemEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUICTRL_INTERNAL_UI_FASTSCROLL_EVENT_H_ +#define _FUICTRL_INTERNAL_UI_FASTSCROLL_EVENT_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +} } + +namespace Tizen {namespace Ui { namespace Controls +{ +/** +* @class _UiFastScrollEvent +* @brief This class handles a slidable event. It is inherited from Event class. +* +*/ +class _UiFastScrollEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @remarks After creating an instance of this class, you must explicitly call one of + * construction methods to initialize the instance. + * + */ + _UiFastScrollEvent(void); + + /** + * This is the default class destructor. + * + */ + virtual ~_UiFastScrollEvent(void); + + /** + * This method initializes this instance. This method should be called + * after this instance is constructed. + * + * @return The method returns error code. + * @param[in] source A pointer to the Object instance which contains this instance. + * @exception E_SUCCESS - This method is successful. + * @exception E_ARG_NULL - The input source is null. + */ + result Construct(const Tizen::Ui::_Control& source); + +// Accessors +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::_Control* GetSource(void) const; + +// Operations +protected: + + /** + * This method checks the arg and finds out the type of event. After that this method calls appopriate + * pListener's method. + * + * @return This method returns a result code. + * @param[in] pListener It is a event listener related to this item event. + * @param[in] arg It is an argument-like instance of item event retransmitted to the listener's method + * as an argument. + * @exception E_SUCCESS - The method is successful. + * @exception E_ARG_NULL - The listener is null. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.@n + *   The pListener is not the instance of IItemEventListener class or + * the pItemEventArg is not the instance of _CustomItemEventArg class. + * + */ + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attributess +private: + Tizen::Ui::_Control* __pSource; +}; +}}}; + +#endif diff --git a/src/ui/inc/FUiCtrl_UiFastScrollEventArg.h b/src/ui/inc/FUiCtrl_UiFastScrollEventArg.h new file mode 100644 index 0000000..c7c2627 --- /dev/null +++ b/src/ui/inc/FUiCtrl_UiFastScrollEventArg.h @@ -0,0 +1,67 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_UiFastScrollEventArg.h + * @brief This is the header file for _UiFastScrollEventArg class. + * + * This header file contains declaration of _UiFastScrollEventArg class. + * + */ +#ifndef _FUICTRL_INTERNAL_UI_FASTSCROLL_EVENT_ARG_H_ +#define _FUICTRL_INTERNAL_UI_FASTSCROLL_EVENT_ARG_H_ + +// Includes +#include +#include +//#include "FUiCtrl_IUiFastScrollListener.h" +#include "FUiCtrl_IFastScrollListener.h" +#include "FUiCtrl_FastScrollIndex.h" + +namespace Tizen { namespace Ui +{ +class _Control; +} } + +namespace Tizen {namespace Ui { namespace Controls +{ + +/** + * @class _UiFastScrollEventArg + * @brief This class is used as the argument to item event listener. + * + * From this class, one can find out, the (event) source object, index and FastScroll event type. + */ +class _UiFastScrollEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +public: + _UiFastScrollEventArg(const Tizen::Ui::_Control& source, const Tizen::Ui::Controls::_FastScrollIndex& index); + virtual ~_UiFastScrollEventArg(void); + Tizen::Ui::_Control* GetSource(void); + const Tizen::Ui::Controls::_FastScrollIndex& GetIndex(void); + +private: + Tizen::Ui::_Control* __pSource; + const Tizen::Ui::Controls::_FastScrollIndex& __index; +}; + + +} } } // Tizen::Ui::Controls + +#endif //_FUICTRL_INTERNAL_FASTSCROLL_BAR_EVENT_ARG_H_ diff --git a/src/ui/inc/FUiCtrl_UiIconListItemEvent.h b/src/ui/inc/FUiCtrl_UiIconListItemEvent.h new file mode 100644 index 0000000..f6acac6 --- /dev/null +++ b/src/ui/inc/FUiCtrl_UiIconListItemEvent.h @@ -0,0 +1,65 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_UiIconListItemEvent.h + * @brief This is the header file for _UiIconListItemEvent class. + * + * This header file contains declaration of _UiIconListItemEvent class. + * The _UiIconListItemEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ + +#ifndef _FUI_CTRL_INTERNAL_UI_ICON_LIST_ITEM_EVENT_H_ +#define _FUI_CTRL_INTERNAL_UI_ICON_LIST_ITEM_EVENT_H_ + +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _IconListView; + +class _UiIconListItemEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + _UiIconListItemEvent(void); + + virtual ~_UiIconListItemEvent(void); + + result Construct(const _IconListView& source); + +// Accessors +public: + const _IconListView* GetSource(void) const; + +// Operations +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attributess +private: + _IconListView* __pSource; +}; // _UiIconListItemEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_UI_ICON_LIST_ITEM_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_UiListViewItemEvent.h b/src/ui/inc/FUiCtrl_UiListViewItemEvent.h new file mode 100644 index 0000000..c6824c1 --- /dev/null +++ b/src/ui/inc/FUiCtrl_UiListViewItemEvent.h @@ -0,0 +1,55 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_UiListViewItemEvent.h + * @brief This is the header file for the _UiListViewItemEvent class. + * + * This header file contains the declarations of the _UiListViewItemEvent class. + */ + +#ifndef _FUI_CTRL_INTERNAL_UI_LIST_VIEW_ITEM_EVENT_H_ +#define _FUI_CTRL_INTERNAL_UI_LIST_VIEW_ITEM_EVENT_H_ + +#include +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _UiListViewItemEvent + : public Tizen::Base::Runtime::_Event +{ + +public: + _UiListViewItemEvent(void); + + virtual ~_UiListViewItemEvent(void); + + void SetSource(Tizen::Ui::_Control* pSource); // temporary code + +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + Tizen::Ui::_Control* __pSource; +}; // _UiListViewItemEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_UI_LIST_VIEW_ITEM_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_UiListViewItemEventArg.h b/src/ui/inc/FUiCtrl_UiListViewItemEventArg.h new file mode 100644 index 0000000..2dd431e --- /dev/null +++ b/src/ui/inc/FUiCtrl_UiListViewItemEventArg.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_UiListViewItemEventArg.h + * @brief This is the header file for the _UiListViewItemEventArg class. + * + * This header file contains the declarations of the _UiListViewItemEventArg class. + */ + +#ifndef _FUI_CTRL_INTERNAL_LIST_VIEW_ITEM_EVENT_ARG_H_ +#define _FUI_CTRL_INTERNAL_LIST_VIEW_ITEM_EVENT_ARG_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { namespace Controls +{ + +enum ListViewItemEventNotifyType +{ + NOTIFY_TYPE_ITEM_LONGPRESSED = 0, + NOTIFY_TYPE_CONTEXTITEM_SELCTED, + NOTIFY_TYPE_CONTEXTITEM_HIGHLIGHTED, +}; + +class _UiListViewItemEventArg + : public Tizen::Base::Runtime::IEventArg +{ + +public: + _UiListViewItemEventArg(int arg1, int arg2, int arg3, ListViewItemEventNotifyType type); + + virtual ~_UiListViewItemEventArg(void); + + int GetArg1(void) const; + + int GetArg2(void) const; + + int GetArg3(void) const; + + ListViewItemEventNotifyType GetNotifyType(void) const; + +private: + _UiListViewItemEventArg(const _UiListViewItemEventArg& rhs); + + _UiListViewItemEventArg& operator=(const _UiListViewItemEventArg& rhs); + +private: + int __arg1; // use by groupIndex + int __arg2; // use by itemIndex + int __arg3; // use by elementId + ListViewItemEventNotifyType __type; +}; // _UiListViewItemEventArg + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_LIST_VIEW_ITEM_EVENT_ARG_H_ diff --git a/src/ui/inc/FUiCtrl_UiScrollEvent.h b/src/ui/inc/FUiCtrl_UiScrollEvent.h new file mode 100644 index 0000000..afb9387 --- /dev/null +++ b/src/ui/inc/FUiCtrl_UiScrollEvent.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_UiScrollEvent.h + * @brief This is the header file for _UiScrollEvent class. + * + * This header file contains declaration of _UiScrollEvent class. + * The ItemEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ + +#ifndef _FUI_CTRL_INTERNAL_SCROLL_EVENT_H_ +#define _FUI_CTRL_INTERNAL_SCROLL_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Controls +{ +/** +* @class _UiScrollEvent +* @brief This class handles a scroll event. It is inherited from Event class. +* +*/ +class _UiScrollEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + _UiScrollEvent(void); + + virtual ~_UiScrollEvent(void); + + result Construct(const Tizen::Ui::_Control& source); + +// Accessors +public: + Tizen::Ui::_Control* GetSource(void) const; + +// Operations +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attributess +private: + Tizen::Ui::_Control* __pSource; +}; // _UiScrollEvent + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SCROLL_EVENT_H_ diff --git a/src/ui/inc/FUiCtrl_UiScrollEventArg.h b/src/ui/inc/FUiCtrl_UiScrollEventArg.h new file mode 100644 index 0000000..0931516 --- /dev/null +++ b/src/ui/inc/FUiCtrl_UiScrollEventArg.h @@ -0,0 +1,133 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_UiScrollEventArg.h + * @brief This is the header file for _UiScrollEventArg class. + * + * This header file contains declaration of _UiScrollEventArg class. + * + */ + +#ifndef _FUI_CTRL_INTERNAL_SCROLL_EVENT_ARG_H_ +#define _FUI_CTRL_INTERNAL_SCROLL_EVENT_ARG_H_ + +#include +#include +#include +#include +#include "FUiCtrl_IScrollEventListener.h" +#include "FUiCtrl_ScrollEventTypes.h" + +namespace Tizen { namespace Ui { namespace Controls +{ + +/** + * @class _UiScrollEventArg + * @brief This class is used as the argument to item event listener. + * + * From this class, one can find out, the (event) source object, index and Scroll event type. + */ +class _UiScrollEventArg + : public Tizen::Base::Runtime::IEventArg + , public Tizen::Base::Object +{ +// Lifecycle +public: + /** + * This is the class destructor. + * + */ + virtual ~_UiScrollEventArg(void); + + /** + * General getter for %_ScrollEventArg class object when fire OnScrollStopped event + * + * @param[in] source A pointer to the Object instance which contains this instance + */ + static _UiScrollEventArg* GetScrollEventArgN(const _Control& source); + + /** + * General getter for %_ScrollEventArg class object when fire OnScrollPositionChanged event + * + * @param[in] source A pointer to the Object instance which contains this instance + * @param[in] scrollPosition A scroll position of the scroll + */ + static _UiScrollEventArg* GetScrollEventArgN(const _Control& source, int scrollPosition); + + /** + * General getter for %_ScrollEventArg class object when fire OnScrollEndReached event + * + * @param[in] source A pointer to the Object instance which contains this instance + * @param[in] scrollType A direction of the scroll + */ + static _UiScrollEventArg* GetScrollEventArgN(const _Control& source, ScrollEndEvent scrollType); + +// Access +public: + /** + * This method returns the type of firing event + * + * @return See the comment above. + */ + _ScrollEventType GetEventType(void) const; + + /** + * This method returns the object which the event initially occurred. + * + * @return The object which the event initially occurred. + */ + _Control* GetSource(void) const; + + /** + * This method returns the ItemStatus + * + * @return See the comment above. + */ + ScrollEndEvent GetScrollType(void) const; + + /** + * This method returns the scroll position + * + * @return See the comment above. + */ + int GetScrollPosition(void) const; + +// Attribute +private: + /** + * This is the default class constructor. + * + * @param[in] source A pointer to the Object instance which contains this instance + * @param[in] eventType A type of firing event + * @param[in] scrollPosition A scroll position of the scroll + * @param[in] scrollType A direction of the scroll + */ + _UiScrollEventArg(_ScrollEventType eventType, const _Control& source, int scrollPosition = -1, ScrollEndEvent scrollType = SCROLL_END_EVENT_END_TOP); + + /** + * Event source. + */ + _ScrollEventType __eventType; + _Control* __pSource; + int __scrollPosition; + ScrollEndEvent __scrollType; +}; // _UiScrollEvent + +}}} //Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_SCROLL_EVENT_ARG_H_ diff --git a/src/ui/inc/FUiCtrl_UiTableViewItemEvent.h b/src/ui/inc/FUiCtrl_UiTableViewItemEvent.h new file mode 100644 index 0000000..522efd6 --- /dev/null +++ b/src/ui/inc/FUiCtrl_UiTableViewItemEvent.h @@ -0,0 +1,66 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiCtrl_UiTableViewItemEvent.h + * @brief This is the header file for the _UiTableViewItemEvent class. + * + * This header file contains the declarations of the _UiTableViewItemEvent class. + */ + +#ifndef _FUI_CTRL_INTERNAL_UI_TABLE_VIEW_ITEM_EVENT_H_ +#define _FUI_CTRL_INTERNAL_UI_TABLE_VIEW_ITEM_EVENT_H_ + +#include +#include +#include "FUi_Control.h" +#include "FUiCtrl_TableView.h" +//#include "FUiCtrl_TableViewItem.h" + + +namespace Tizen { namespace Ui { namespace Controls +{ + +class _UiTableViewItemEvent + : public Tizen::Base::Runtime::_Event +{ +// Lifecycle +public: + _UiTableViewItemEvent(void); + virtual ~_UiTableViewItemEvent(void); + + result Construct(Tizen::Ui::_Control* pSource, TableViewStyle style); + +// Accessors +public: + Tizen::Ui::_Control* GetSource(void) const; + +// Operations +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +//Attribute +private: + Tizen::Ui::_Control* __pSource; + bool __invokeTableViewItemCallback; + TableViewStyle __style; + +}; // _UiTableViewItemEvent + +}}} // Tizen::Ui::Controls + +#endif // _FUI_CTRL_INTERNAL_UI_TABLE_VIEW_ITEM_EVENT_H_ diff --git a/src/ui/inc/FUi_AccessibilityContainer.h b/src/ui/inc/FUi_AccessibilityContainer.h new file mode 100644 index 0000000..5dea6a2 --- /dev/null +++ b/src/ui/inc/FUi_AccessibilityContainer.h @@ -0,0 +1,189 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_AccessibilityContainer.h + * @brief This is the header file for the _AccessibilityContainer class. + * + * This header file contains the declarations of the _AccessibilityContainer class. + * + */ +#ifndef _FUI_INTERNAL_ACCESSIBILITY_CONTAINER_H_ +#define _FUI_INTERNAL_ACCESSIBILITY_CONTAINER_H_ + +#include +#include +#include +#include +#include "FUi_AccessibilityManager.h" + +namespace Tizen { namespace Base +{ +class String; +}} //Tizen::Base +namespace Tizen { namespace Graphics +{ +class Point; +class Rectangle; +}} //Tizen::Graphics + +namespace Tizen { namespace Ui { + +class IAccessibilityListener; +class _AccessibilityElement; +class _IAccessibilityListener; +class _Control; + +enum AccessibilityScreenReaderSpeechRate +{ + ACCESSIBILITY_SCREEN_READER_SPEECH_RATE_SYSTEM_SETTING, /**< The speech rate from system setting */ + ACCESSIBILITY_SCREEN_READER_SPEECH_RATE_VERY_SLOW, /**< The very slow speech rate */ + ACCESSIBILITY_SCREEN_READER_SPEECH_RATE_SLOW, /**< The slow speech rate*/ + ACCESSIBILITY_SCREEN_READER_SPEECH_RATE_NORMAL, /**< The normal speech rate */ + ACCESSIBILITY_SCREEN_READER_SPEECH_RATE_FAST, /**< The fast speech rate */ + ACCESSIBILITY_SCREEN_READER_SPEECH_RATE_VERY_FAST /**< The very fast speech rate */ +}; + +/** + * @enum AccessibilityTraits + * + * Defines the trait of the accessibility element. + * + * @since 2.0 + */ +enum AccessibilityTraits +{ + ACCESSIBILITY_TRAITS_NONE, + ACCESSIBILITY_TRAITS_TITLE, + ACCESSIBILITY_TRAITS_OPTION_HEADER, + ACCESSIBILITY_TRAITS_PICTURE, + ACCESSIBILITY_TRAITS_STATUS_BAR, + ACCESSIBILITY_TRAITS_TEXT_FIELD, + ACCESSIBILITY_TRAITS_RATING, + ACCESSIBILITY_TRAITS_ACTION_BAR, + ACCESSIBILITY_TRAITS_ACTION_BAR_MENU, + ACCESSIBILITY_TRAITS_BACK_BUTTON, + ACCESSIBILITY_TRAITS_BUTTON, + ACCESSIBILITY_TRAITS_LABEL, + ACCESSIBILITY_TRAITS_LIST, + ACCESSIBILITY_TRAITS_DATA_SELECTOR, + ACCESSIBILITY_TRAITS_DRAG_SCROLL, + ACCESSIBILITY_TRAITS_EXPAND_BUTTON, + ACCESSIBILITY_TRAITS_FUNCTION_PANEL, + ACCESSIBILITY_TRAITS_IN_DEPTH_BUTTON, + ACCESSIBILITY_TRAITS_INDEX_SCROLL, + ACCESSIBILITY_TRAITS_IMAGE, + ACCESSIBILITY_TRAITS_INDICATOR, + ACCESSIBILITY_TRAITS_NOTIFICATION, + ACCESSIBILITY_TRAITS_RADIO_BUTTON, + ACCESSIBILITY_TRAITS_SCROLL_BAR, + ACCESSIBILITY_TRAITS_SEARCH_FIELD, + ACCESSIBILITY_TRAITS_SEGMENT, + ACCESSIBILITY_TRAITS_SLIDER, + ACCESSIBILITY_TRAITS_SOFT_KEY, + ACCESSIBILITY_TRAITS_SUB_MENU_TITLE, + ACCESSIBILITY_TRAITS_TAB, + ACCESSIBILITY_TRAITS_TICKBOX, + ACCESSIBILITY_TRAITS_TIME_SELECTOR, + ACCESSIBILITY_TRAITS_VOLUME_SLIDER, + ACCESSIBILITY_TRAITS_HOUR, + ACCESSIBILITY_TRAITS_MINUTE, + ACCESSIBILITY_TRAITS_SECOND, + ACCESSIBILITY_TRAITS_YEAR, + ACCESSIBILITY_TRAITS_MONTH, + ACCESSIBILITY_TRAITS_DAY, + ACCESSIBILITY_TRAITS_END +}; + +const int ACCESSIBILITY_PRIORTY_TOP = 55555; +const int ACCESSIBILITY_PRIORTY_NORMAL = 10000; +const int ACCESSIBILITY_PRIORTY_BOTTOM = 0; + +class _AccessibilityContainer +{ +public: + _AccessibilityContainer(const _Control& owner); + ~_AccessibilityContainer(void); + _Control& GetOwner(void); + const _Control& GetOwner(void) const; + + void AddListener(const _IAccessibilityListener& listener); + Tizen::Base::Collection::IListT<_IAccessibilityListener*>* GetListenerListN(void) const; + void RemoveListener(const _IAccessibilityListener& listener); + + result AddChildContainer(const _AccessibilityContainer& child); + result RemoveChildContainer(const _AccessibilityContainer& child); + const Tizen::Base::Collection::LinkedListT<_AccessibilityContainer*>* GetChildContainerList(void) const; + + result AddElement(const _AccessibilityElement& element); + result AddElements(const Tizen::Base::Collection::IListT<_AccessibilityElement*>& elementList); + result InsertElement(const _AccessibilityElement& element, int index); + result RemoveElement(const _AccessibilityElement& element); + result RemoveAllElement(void); + + _AccessibilityElement* GetChildElement(const Tizen::Base::String& name) const; + void GetElements(Tizen::Base::Collection::IListT<_AccessibilityElement*>& list) const; + Tizen::Base::Collection::IListT<_AccessibilityElement*>* GetElementsN(void) const; + + result MoveElement(const _AccessibilityElement* pPreviousElement, const _AccessibilityElement& element); + + void ManageFocus(bool set); + bool IsFocusManaged(void); + void SetCurrentFocusedElement(_AccessibilityElement* pElement); + _AccessibilityElement* GetCurrentFocusedElement(void) const; + _AccessibilityElement* Hit(const Tizen::Graphics::Point& point) const; + bool MoveFocus(_AccessibilityFocusDirection direction); + bool MoveFocus(const Tizen::Graphics::Point& point); + void ResetFocus(void); + void SortElements(void); + + bool SetParent(const _AccessibilityContainer& parent); + _AccessibilityContainer* GetParent(void) const; + void SetPriority(int level); + int GetPriority(void); + void SetEnableState(bool enabledState); + bool GetEnableState(void); + void Activate(bool enable); + bool IsActivated(void) const; + Tizen::Graphics::Rectangle GetAbsoluteBounds(void) const; + + void ReadingAll(void); + Tizen::Base::String GetCurrentGrammar(void) const; + AccessibilityScreenReaderStatus GetStatus(void) const; + Tizen::Base::_HandleT <_AccessibilityContainer> GetHandle(void) const; + +private: + _AccessibilityContainer(const _AccessibilityContainer& rhs); + _AccessibilityContainer& operator =(const _AccessibilityContainer& rhs); + +private: + Tizen::Base::_HandleT <_AccessibilityContainer> __handle; + _Control* __pOwner; + _AccessibilityContainer* __pParent; + Tizen::Base::Collection::LinkedListT<_AccessibilityElement*> __elementList; + Tizen::Base::Collection::LinkedListT<_AccessibilityContainer*> __childContainerList; + Tizen::Base::Collection::LinkedListT<_IAccessibilityListener*> __listenerList; + int __currentElementIndex; + int __level; + bool __activated; + IAccessibilityListener* __pListener; + bool __enableState; + bool __focusManaged; +}; //class _AccessibilityContainer +}} //Tizen::Ui + +#endif //_FUI_INTERNAL_ACCESSIBILITY_CONTAINER_H_ diff --git a/src/ui/inc/FUi_AccessibilityContainerImpl.h b/src/ui/inc/FUi_AccessibilityContainerImpl.h new file mode 100644 index 0000000..ba2cea6 --- /dev/null +++ b/src/ui/inc/FUi_AccessibilityContainerImpl.h @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_AccessibilityContainerImpl.h + * @brief This is the header file for the _AccessibilityContainerImpl class. + * + * This header file contains the declarations of the _AccessibilityContainerImpl class. + * + */ +#ifndef _FUI_INTERNAL_ACCESSIBILITY_CONTAINER_IMPL_H_ +#define _FUI_INTERNAL_ACCESSIBILITY_CONTAINER_IMPL_H_ + +#include +#include +#include +#include "FUi_ControlManager.h" +#include "FUi_IAccessibilityListener.h" + +namespace Tizen { namespace Base +{ +class String; +}} //Tizen::Base + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +}}} //Tizen::Base::Collection + +namespace Tizen { namespace Ui +{ + +class Control; +class AccessibilityContainer; +class _ControlImpl; +class _AccessibilityElementImpl; +class _AccessibilityContainer; + +class _AccessibilityContainerImpl + : public Tizen::Base::Object + , virtual public _IAccessibilityListener +{ +public: + _AccessibilityContainerImpl(const _ControlImpl& controlImpl, const AccessibilityContainer& publicInstance, const _AccessibilityContainer& coreInstance); + virtual ~_AccessibilityContainerImpl(void); + _ControlImpl& GetOwner(void); + AccessibilityContainer& GetPublic(void); + result AddAccessibilityListener(const IAccessibilityListener& listener); + result RemoveAccessibilityListener(const IAccessibilityListener& listener); + + result AddElement(const _AccessibilityElementImpl& element); + result AddElements(const Tizen::Base::Collection::IList& elementList); + + Tizen::Base::Collection::IList* GetElementsN(void); + AccessibilityElement* GetChildElement(const Tizen::Base::String& name); + + result RemoveElement(const _AccessibilityElementImpl& element); + result RemoveAllElement(void); + + result MoveElement(const _AccessibilityElementImpl* pPreviousElement, const _AccessibilityElementImpl& element); + + Tizen::Base::String GetCurrentGrammar(void) const; + AccessibilityScreenReaderStatus GetStatus(void) const; + void ReadingAll(void); + + static AccessibilityContainer* CreateAccessibilityContainerN(const _ControlImpl& controlImpl); + static _AccessibilityContainerImpl* GetInstance(AccessibilityContainer& container); + static const _AccessibilityContainerImpl* GetInstance(const AccessibilityContainer& container); + + virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element); + virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) ; + virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element); + +private: + _AccessibilityContainerImpl(const _AccessibilityContainerImpl& rhs); + _AccessibilityContainerImpl& operator =(const _AccessibilityContainerImpl& rhs); + + void AddSystemElement(const AccessibilityElement& element); + bool ControlCoreExists(_ControlHandle handle) const; + +private: + _ControlImpl* __pControlImpl; + AccessibilityContainer* __pPublic; + _AccessibilityContainer* __pCore; + Tizen::Base::Collection::LinkedListT __elementList; + Tizen::Base::Collection::LinkedListT __listenerList; + _ControlHandle __coreHandle; +}; //class _AccessibilityContainerImpl +}} //Tizen::Ui + +#endif //_FUI_INTERNAL_ACCESSIBILITY_CONTAINER_IMPL_H_ \ No newline at end of file diff --git a/src/ui/inc/FUi_AccessibilityElement.h b/src/ui/inc/FUi_AccessibilityElement.h new file mode 100644 index 0000000..2d6df96 --- /dev/null +++ b/src/ui/inc/FUi_AccessibilityElement.h @@ -0,0 +1,95 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_AccessibilityElement.h + * @brief This is the header file for the _AccessibilityElement class. + * + * This header file contains the declarations of the _AccessibilityElement class. + * + */ +#ifndef _FUI_INTERNAL_ACCESSIBILITY_ELEMENT_H_ +#define _FUI_INTERNAL_ACCESSIBILITY_ELEMENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui { + +class _AccessibilityContainer; +class _AccessibilityElementImpl; + +class _AccessibilityElement +{ + +public: + _AccessibilityElement(bool systemElement = false); + virtual ~_AccessibilityElement(void); + result Construct(const Tizen::Base::String& name, const Tizen::Graphics::Rectangle& bounds); + void SetBounds(const Tizen::Graphics::Rectangle& bounds); + Tizen::Graphics::Rectangle GetBounds(void) const; + Tizen::Graphics::Rectangle GetAbsoluteBounds(void) const; + void SetName(const Tizen::Base::String& name); + Tizen::Base::String GetName(void) const; + void SetLabel(const Tizen::Base::String& label); + Tizen::Base::String GetLabel(void) const; + void SetHint(const Tizen::Base::String& hint); + Tizen::Base::String GetHint(void) const; + void SetStatus(const Tizen::Base::String& guide); + Tizen::Base::String GetStatus(void) const; + void SetTrait(AccessibilityTraits trait); + AccessibilityTraits GetTrait(void) const; + void SetTrait(const Tizen::Base::String& trait); + Tizen::Base::String GetTraitString(void) const; + void SetValue(const Tizen::Base::String& value); + Tizen::Base::String GetValue(void) const; + void Activate(bool enable); + bool IsActivated(void) const; + void SetParent(const _AccessibilityContainer& parent); + _AccessibilityContainer* GetParent(void) const; + void SetUserData(void* pUserData); + void* GetUserData(void) const; + + void SetSupportOperatingGesture(bool set); + bool GetSupportOperatingGesture(void); + + Tizen::Base::String GetReadingContents(void) const; + bool IsSystemElement(void); + +private: + _AccessibilityElement(const _AccessibilityElement& rhs); + _AccessibilityElement& operator =(const _AccessibilityElement& rhs); + +private: + Tizen::Base::String __name; + Tizen::Graphics::Rectangle __bounds; + Tizen::Graphics::Rectangle __absBounds; + Tizen::Base::String __label; + Tizen::Base::String __hint; + Tizen::Base::String __status; + Tizen::Base::String __traitString; + AccessibilityTraits __trait; + Tizen::Base::String __value; + _AccessibilityContainer* __pParent; + void* __pUserData; + bool __systemElement; + bool __activated; + bool __supportOperatingGesture; +}; +}} +#endif //_FUI_INTERNAL_ACCESSIBILITY_ELEMENT_H_ \ No newline at end of file diff --git a/src/ui/inc/FUi_AccessibilityElementImpl.h b/src/ui/inc/FUi_AccessibilityElementImpl.h new file mode 100644 index 0000000..90352db --- /dev/null +++ b/src/ui/inc/FUi_AccessibilityElementImpl.h @@ -0,0 +1,89 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_AccessibilityElementImpl.h + * @brief This is the header file for the _AccessibilityElementImpl class. + * + * This header file contains the declarations of the _AccessibilityElementImpl class. + * + */ +#ifndef _FUI_INTERNAL_ACCESSIBILITY_ELEMENT_IMPL_H_ +#define _FUI_INTERNAL_ACCESSIBILITY_ELEMENT_IMPL_H_ + +#include +#include + +namespace Tizen { namespace Base +{ +class String; +}} //Tizen::Base +namespace Tizen { namespace Graphics +{ +class Rectangle; +}} //Tizen::Graphics +namespace Tizen { namespace Ui +{ + +class AccessibilityElement; +class _AccessibilityElement; +class IAccessibilityListener; + +class _AccessibilityElementImpl +{ +public: + _AccessibilityElementImpl(const AccessibilityElement& element); + _AccessibilityElementImpl(const _AccessibilityElement& element); + virtual ~_AccessibilityElementImpl(void); + result Construct(const Tizen::Base::String& name, const Tizen::Graphics::Rectangle& bounds); + void SetBounds(const Tizen::Graphics::Rectangle& bounds); + void SetName(const Tizen::Base::String& name); + void SetLabel(const Tizen::Base::String& label); + void SetHint(const Tizen::Base::String& hint); + void SetStatus(const Tizen::Base::String& status); + void SetTrait(AccessibilityTraits trait); + void SetTrait(const Tizen::Base::String& trait); + void SetValue(const Tizen::Base::String& value); //variant gogogo + + AccessibilityElement& GetPublic(); + const AccessibilityElement& GetPublic() const; + void SetCore(_AccessibilityElement* pCore); + _AccessibilityElement& GetCore(); + const _AccessibilityElement& GetCore() const; + Tizen::Base::String GetName(void) const; + Tizen::Graphics::Rectangle GetBounds(void) const; + Tizen::Base::String GetLabel(void) const; + Tizen::Base::String GetHint(void) const; + Tizen::Base::String GetStatus(void) const; + AccessibilityTraits GetTrait(void) const; + Tizen::Base::String GetTraitString(void) const; + Tizen::Base::String GetValue(void) const; //variant gogogo + + static _AccessibilityElementImpl* GetInstance(AccessibilityElement& element); + static const _AccessibilityElementImpl* GetInstance(const AccessibilityElement& element); + +private: + _AccessibilityElementImpl(const _AccessibilityElementImpl& rhs); + _AccessibilityElementImpl& operator =(const _AccessibilityElementImpl& rhs); + +private: + AccessibilityElement* __pPublic; + _AccessibilityElement* __pCore; +}; //class _AccessibilityElementImpl +}} //Tizen::Ui + +#endif //_FUI_INTERNAL_ACCESSIBILITY_ELEMENT_IMPL_H_ \ No newline at end of file diff --git a/src/ui/inc/FUi_AccessibilityGesture.h b/src/ui/inc/FUi_AccessibilityGesture.h new file mode 100644 index 0000000..90e3c60 --- /dev/null +++ b/src/ui/inc/FUi_AccessibilityGesture.h @@ -0,0 +1,80 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_AccessibilityGesture.h + * @brief This is the header file for the _AccessibilityGesture class. + * + * This header file contains the declarations of the _AccessibilityGesture class. + * + */ +#ifndef _FUI_INTERNAL_ACCESSIBILITY_GESTURE_H_ +#define _FUI_INTERNAL_ACCESSIBILITY_GESTURE_H_ + +namespace Tizen { namespace Ui { + +enum _AccessibilityGestureType +{ + _ACCESSIBILITY_GESTURE_TYPE_NONE = 0, + _ACCESSIBILITY_GESTURE_TYPE_FLICK_UP, + _ACCESSIBILITY_GESTURE_TYPE_FLICK_DOWN, + _ACCESSIBILITY_GESTURE_TYPE_FLICK_LEFT, + _ACCESSIBILITY_GESTURE_TYPE_FLICK_RIGHT, + _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_ONE_TAP, + _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_DOUBLE_TAP, + _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_LONGPRESS, + _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_PANNING_STARTED, + _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_PANNING_CHANGED, + _ACCESSIBILITY_GESTURE_TYPE_ONE_FINGER_PANNING_FINISHED, + _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_TWO_TAP, + _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_DOUBLE_TAP, + _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_LONGPRESS, + _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_STARTED, + _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_CHANGED, + _ACCESSIBILITY_GESTURE_TYPE_TWO_FINGER_PANNING_FINISHED, + _ACCESSIBILITY_GESTURE_TYPE_THREE_FINGER_THREE_TAP, + _ACCESSIBILITY_GESTURE_TYPE_THREE_FINGER_DOUBLE_TAP, + _ACCESSIBILITY_GESTURE_TYPE_THREE_FINGER_LONGPRESS, + _ACCESSIBILITY_GESTURE_TYPE_THREE_FINGER_PANNING_STARTED, + _ACCESSIBILITY_GESTURE_TYPE_THREE_FINGER_PANNING_CHANGED, + _ACCESSIBILITY_GESTURE_TYPE_THREE_FINGER_PANNING_FINISHED, + _ACCESSIBILITY_GESTURE_TYPE_VALUE_INCREASED, + _ACCESSIBILITY_GESTURE_TYPE_VALUE_DECREASED, + _ACCESSIBILITY_GESTURE_TYPE_END +}; + +class _AccessibilityManager; + +class _AccessibilityGesture +{ +public: + _AccessibilityGesture(_AccessibilityManager& manager); + virtual ~_AccessibilityGesture(void); + static bool ProcessGesture(_AccessibilityGestureType type, int x = 0, int y = 0); +private: + _AccessibilityGesture(const _AccessibilityGesture& rhs); + _AccessibilityGesture& operator =(const _AccessibilityGesture& rhs); + +private: + friend class _AccessibilityManager; + _AccessibilityManager* __pManager; + +}; +}} + +#endif //_FUI_INTERNAL_ACCESSIBILITY_GESTURE_H_ + diff --git a/src/ui/inc/FUi_AccessibilityManager.h b/src/ui/inc/FUi_AccessibilityManager.h new file mode 100644 index 0000000..4631242 --- /dev/null +++ b/src/ui/inc/FUi_AccessibilityManager.h @@ -0,0 +1,147 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** +* @file FUi_AccessibilityManager.h +* @brief This is the header file for the _AccessibilityManager class. +* +* This header file contains the declarations of the _AccessibilityManager class. +* +*/ +#ifndef _FUI_INTERNAL_ACCESSIBILITY_MANAGER_H_ +#define _FUI_INTERNAL_ACCESSIBILITY_MANAGER_H_ + +#include +#include +#include +#include +#include +#include +#include "FUi_ControlManager.h" +#include "FUi_AccessibilityGesture.h" + +namespace Tizen { namespace Base +{ +class String; +}} //Tizen::Base + +namespace Tizen { namespace Ui { namespace Animations +{ +class VisualElement; +}}} //Tizen::Ui::Animations + +namespace Tizen { namespace Ui +{ + +class _Control; +class _TouchGestureDetector; +class _AccessibilityTtsPlayer; +class _AccessibilitySystemSettingLoader; +class _AccessibilityContainer; +class _AccessibilityElement; + +enum _AccessibilityFocusDirection +{ + _ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS = -1, + _ACCESSIBILITY_FOCUS_DIRECTION_NONE = 0, + _ACCESSIBILITY_FOCUS_DIRECTION_NEXT = 1 +}; + +class _AccessibilityManager +{ +public: + static _AccessibilityManager* GetInstance(void); + static void CreateInstance(void); + static void ReleaseInstance(void); + ~_AccessibilityManager(void); + + AccessibilityScreenReaderStatus GetReadingtatus(void); + void ReadElement(int index); + result ReadElement(const _AccessibilityElement& element); + result ReadContent(const Tizen::Base::String& content); + result ReadingStop(void); + result ReadingPause(void); + result ReadingResume(void); + void OnStartReading(const Tizen::Base::String& grammar); + void OnFinishReading(const Tizen::Base::String& grammar); + + void AddContainer(const _AccessibilityContainer& container); + void RemoveContainer(const _AccessibilityContainer& container); + + bool ProcessGesture(_AccessibilityGestureType type, const Tizen::Graphics::Point& point,const _TouchGestureDetector* pDetector = null); + Tizen::Base::String GetCurrentGrammar(void); + + void OnAccessibilityScreenReaderIsActivated(bool set); + bool IsAccessibilityActivated(void); + bool IsScreenReaderActivated(void); + int GetLargeFontSize(void); + + void RequestToDrawFocusUi(void); + void RequestAutoReading(void); + + Tizen::Base::_HandleT <_AccessibilityContainer> Register(_AccessibilityContainer* pObject); + void Unregister(Tizen::Base::_HandleT <_AccessibilityContainer> handle); + + static bool IsActivated(); +private: + enum GestureMode + { + MODE_NONE, + MODE_TAP, + MODE_FOCUS_MOVE, + MODE_PANNING + }; + _AccessibilityManager(void); + _AccessibilityManager(const _AccessibilityManager& rhs); + _AccessibilityManager& operator =(const _AccessibilityManager& rhs); + static void InitializeInstance(void); + bool MoveFocus(_AccessibilityFocusDirection direction); + void DrawFocusUi(const _AccessibilityContainer& container); + void MakeList(void); + void MakeList(_AccessibilityContainer* container); + void Initialize(void); + void ShowPopup(const Tizen::Base::String& content); + void ShowPopup(void); + void HidePopup(void); + bool IsContainerValid(_AccessibilityContainer* pContainer); + bool IsTargetContainerValid(void); + bool IsVisible(_AccessibilityElement* pElement); + bool IsVisible(_AccessibilityContainer* pContainer); + void SetGestureMode(GestureMode mode); + GestureMode GetGestureMode(void); +private: + + Tizen::Base::_ObjectManagerT <_AccessibilityContainer> __objectManager; + _AccessibilityGesture* __pAccGesture; + _AccessibilityTtsPlayer* __pPlayer; + _AccessibilitySystemSettingLoader* __pSettingLoader; + _AccessibilityContainer* __pTargetContainer; + _AccessibilityElement* __pTargetElement; + _AccessibilityElement* __pTitleElement; + Tizen::Base::Collection::LinkedListT<_AccessibilityContainer*> __containerList; + Tizen::Base::Collection::LinkedListT<_AccessibilityElement*> __candidateList; + GestureMode __mode; + _ControlHandle __targetControlHandle; + Tizen::Ui::Animations::VisualElement* __pReadingVe; + Tizen::Ui::Animations::VisualElement* __pFocusVe; + _Control* __pPanningControl; + static bool __screenReaderIsEnabled; +};//class _AccessibilityManager +}} //Tizen::Ui + +#endif //_FUI_INTERNAL_ACCESSIBILITY_MANAGER_H_ + diff --git a/src/ui/inc/FUi_AccessibilitySystemSettingLoader.h b/src/ui/inc/FUi_AccessibilitySystemSettingLoader.h new file mode 100644 index 0000000..8e3bdc3 --- /dev/null +++ b/src/ui/inc/FUi_AccessibilitySystemSettingLoader.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_AccessibilitySystemSettingLoader.h + * @brief This is the header file for the _AccessibilitySystemSettingLoader class. + * + * This header file contains the declarations of the _AccessibilitySystemSettingLoader class. + * + */ +#ifndef _FUI_INTERNAL_ACCESSIBILITY_SYSTEM_SETTING_LOADER_H_ +#define _FUI_INTERNAL_ACCESSIBILITY_SYSTEM_SETTING_LOADER_H_ + +#include + +namespace Tizen { namespace Ui { + +class _AccessibilityManager; + +class _AccessibilitySystemSettingLoader + : public Tizen::System::ISettingEventListener +{ +public: + _AccessibilitySystemSettingLoader(_AccessibilityManager& manager); + virtual ~_AccessibilitySystemSettingLoader(void); + + bool IsAccessibilityActivated(void); + bool IsScreenReaderActivated(void); + int GetLargeFontSize(void); + static void SetSystemSetting(const Tizen::Base::String key, bool value); + +private: + _AccessibilitySystemSettingLoader(const _AccessibilitySystemSettingLoader& rhs); + _AccessibilitySystemSettingLoader& operator =(const _AccessibilitySystemSettingLoader& rhs); + virtual void OnSettingChanged(Tizen::Base::String& key); + +private: + _AccessibilityManager* __pManager; + friend class _AccessibilityManager; +}; +}} + +#endif //_FUI_INTERNAL_ACCESSIBILITY_SYSTEM_SETTING_LOADER_H_ + diff --git a/src/ui/inc/FUi_AccessibilityTtsPlayer.h b/src/ui/inc/FUi_AccessibilityTtsPlayer.h new file mode 100644 index 0000000..2fb1b2f --- /dev/null +++ b/src/ui/inc/FUi_AccessibilityTtsPlayer.h @@ -0,0 +1,86 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @fileFUi_AccessibilityTtsPlayer.h + * @brief This is the header file for the _AccessibilityTtsPlayer class. + * + * This header file contains the declarations of the _AccessibilityTtsPlayer class. + * + */ +#ifndef _FUI_INTERNAL_ACCESSIBILITY_TTS_PLAYER_H_ +#define _FUI_INTERNAL_ACCESSIBILITY_TTS_PLAYER_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Base +{ +class String; +}} + +namespace Tizen { namespace Uix { namespace Speech +{ +class TextToSpeech; +}}} + +namespace Tizen { namespace Ui +{ +class _AccessibilityManager; + +class _AccessibilityTtsPlayer + :public Tizen::Uix::Speech::ITextToSpeechEventListener +{ +public: + virtual ~_AccessibilityTtsPlayer(void); + result ReadGrammar(const Tizen::Base::String& grammar, bool bInit = true); + result StopReading(void); + + AccessibilityScreenReaderStatus GetStatus(void); + Tizen::Base::String GetCurrentGrammar(void); + +private: + _AccessibilityTtsPlayer(_AccessibilityManager& manager); + result Activate(void); + result Deactivate(void); + + virtual void OnTextToSpeechInitialized(void); + virtual void OnTextToSpeechErrorOccurred (Tizen::Uix::Speech::TextToSpeechError error); + virtual void OnTextToSpeechStatusChanged (Tizen::Uix::Speech::TextToSpeechStatus status); + virtual void OnTextToSpeechCompleted(void); + void SetStatus(AccessibilityScreenReaderStatus status); + +private: + _AccessibilityTtsPlayer(const _AccessibilityTtsPlayer& rhs); + _AccessibilityTtsPlayer& operator =(const _AccessibilityTtsPlayer& rhs); + +private: + void* __handle; + Tizen::Uix::Speech::TextToSpeech* __pTts; + Tizen::Base::String __grammar; + int __localeIdx; + AccessibilityScreenReaderStatus __status; + + _AccessibilityManager* __pManager; + friend class _AccessibilityManager; +}; //class _AccessibilityTtsPlayer +}} //Tizen::Ui + +#endif //_FUI_INTERNAL_ACCESSIBILITY_TTS_PLAYER_H_ + diff --git a/src/ui/inc/FUi_Colorf.h b/src/ui/inc/FUi_Colorf.h new file mode 100644 index 0000000..359cb7c --- /dev/null +++ b/src/ui/inc/FUi_Colorf.h @@ -0,0 +1,107 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_Colorf.h + * @brief Header file of _Colorf class + * + * This file contains declarations _Colorf class. + */ + +#ifndef _FUI_INTERNAL_COLORF_H_ +#define _FUI_INTERNAL_COLORF_H_ + +#include + +namespace Tizen { namespace Ui +{ + +class _Colorf +{ +public: + _Colorf(void) { __r = __g = __b = 0.0f;__a = 1.0f;} + _Colorf(float red, float green, float blue, float alpha) + : __r(red) + , __g(green) + , __b(blue) + , __a(alpha) + { + } + _Colorf(const _Colorf& color) + { + __r = color.__r; + __g = color.__g; + __b = color.__b; + __a = color.__a; + } + + virtual ~_Colorf(void) {} + + _Colorf& operator =(const _Colorf& color) + { + if (&color != this) + { + __r = color.__r; + __g = color.__g; + __b = color.__b; + __a = color.__a; + } + + return *this; + } + + bool operator !=(const _Colorf& color) const + { + return (__r != color.__r) || (__g != color.__g) || (__b != color.__b) || (__a != color.__a); + } + + bool operator ==(const _Colorf& color) const + { + // CHECKME: need float compare ??? + return (__r == color.__r) && (__g == color.__g) && (__b == color.__b) && (__a == color.__a); + } + + result SetRGBAColor(float r, float g, float b, float a) + { + __r = r; + __g = g; + __b = b; + __a = a; + return E_SUCCESS; + } + + float& Red(void) { return __r;} + float& Green(void) { return __g;} + float& Blue(void) { return __b;} + float& Alpha(void) { return __a;} + + float Red(void) const { return __r;} + float Green(void) const { return __g;} + float Blue(void) const { return __b;} + float Alpha(void) const { return __a;} + +private: + float __r; + float __g; + float __b; + float __a; +}; + +}} + +#endif // Tizen::Ui + diff --git a/src/ui/inc/FUi_ContainerImpl.h b/src/ui/inc/FUi_ContainerImpl.h new file mode 100644 index 0000000..b565515 --- /dev/null +++ b/src/ui/inc/FUi_ContainerImpl.h @@ -0,0 +1,114 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_ContainerImpl.h +* @brief This is the header file for the _ContainerImp interface. +* +* This header file contains the declarations of the %_ContainerImp interface. +*/ + +#ifndef _FUI_INTERNAL_CONTAINER_IMPL_H_ +#define _FUI_INTERNAL_CONTAINER_IMPL_H_ + +#include +#include "FUi_ControlImpl.h" +#include "FUi_SharedPtr.h" + +namespace Tizen { namespace Ui +{ + +class _LayoutImpl; + +class _OSP_EXPORT_ _ContainerImpl + : public _ControlImpl +{ +public: +// Life Cycle + void Initialize(Control* pPublic, _Control* pCore, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout); + static _ContainerImpl* CreateContainerImplN(Container* pPublic); + static _ContainerImpl* CreateContainerImplN(Container* pPublic, const Tizen::Graphics::Rectangle& bounds, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, bool resizable, bool movable); + virtual ~_ContainerImpl(void); + + static _ContainerImpl* GetInstance(Container& container); + static const _ContainerImpl* GetInstance(const Container& container); +//Operation + // [ToDo] Must consider transforOwnership flags. + result AddChild(_ControlImpl* pChild, bool transferOwnership = true); + result RemoveChild(_ControlImpl* pChild, bool deallocate = true); + result RemoveChild(int index); + void RemoveAllChildren(bool detachSystemChild = true); + result MoveChildToTop(const _ControlImpl& child); + result MoveChildBefore(const _ControlImpl& targetChild, const _ControlImpl& child); + +// Z-Order + result SetControlAlwaysOnTop(Control& control, bool alwaysOnTop); + result SetControlAlwaysAtBottom(Control& control, bool alwaysAtBottom); + bool IsControlAlwaysAtBottom(const Control& control) const; + bool IsControlAlwaysOnTop(const Control& control) const; + +// Getters/Setters + virtual const char* GetPublicClassName(void) const; + virtual const Container& GetPublic(void) const; + virtual Container& GetPublic(void); + + Tizen::Base::Collection::IList* GetChildrenPublic(void) const; + _ControlImpl* GetChild(int index) const; + + _ControlImpl* SearchControlByName(const Tizen::Base::String& name, bool recursive, bool searchMyself = false) const; + + int GetChildIndex(const _ControlImpl* pChild) const; + int GetChildCount(void) const; + + // [ToDo] It's returning public class instance. OK? + Layout* GetPublicPortraitLayoutN(void) const; + Layout* GetPublicLandscapeLayoutN(void) const; + Layout* GetPublicLayoutN(void) const; + + result SetChildAt(const _ControlImpl* pChild, int index); + bool IsAncestorOf(const _ControlImpl* pChild) const; + +// Internal Callbacks + virtual void OnDraw(void); + virtual void OnChangeLayout(_ControlOrientation orientation); + virtual void OnVisibleStateChanging(void); + virtual void OnVisibleStateChanged(void); + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); + virtual void OnBoundsChanged(void); + virtual void OnEvaluateSize(Tizen::Graphics::Dimension& evaluatedSize); + + void CallOnDraw(void); + +protected: + _ContainerImpl(Control* pPublic, _Control* pCore, const Layout* pPublicPortraitLayout = null, const Layout* pPublicLandscapeLayout = null); + _ContainerImpl(Control* pPublic, _Control* pCore, const Tizen::Graphics::Rectangle& bounds, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, bool resizable, bool movable); + +private: + _ContainerImpl(const _ContainerImpl& rhs); + _ContainerImpl& operator =(const _ContainerImpl& rhs); + + virtual bool IsChildAttachable(_ControlImpl& child) const; + result SetLayout(_Control& core, _ControlOrientation orientation, const Layout* pPublicLayout); + +private: + Tizen::Base::Collection::LinkedList __controlPublics; + _SharedPtr __portraitLayout; + _SharedPtr __landscapeLayout; +}; // _ContainerImpl + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_CONTAINER_IMPL_H_ diff --git a/src/ui/inc/FUi_Control.h b/src/ui/inc/FUi_Control.h new file mode 100644 index 0000000..f3fb844 --- /dev/null +++ b/src/ui/inc/FUi_Control.h @@ -0,0 +1,628 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_Control.h + * @brief This is the header file for the _Control class. + * + * This header file contains the declarations of the %_Control class. + */ + +#ifndef _FUI_INTERNAL_CONTROL_H_ +#define _FUI_INTERNAL_CONTROL_H_ + +#include +#include +#include "FUi_Types.h" +#include "FUi_UiEventTypes.h" +#include "FUi_IUiEventListener.h" +#include "FUi_IKeyEventPreviewer.h" +#include "FUi_IKeyEventListener.h" +#include "FUi_ITouchEventPreviewer.h" +#include "FUi_ITouchEventListener.h" +#include "FUi_IFocusEventListener.h" +#include "FUi_INotificationEventPreviewer.h" +#include "FUi_INotificationEventListener.h" +#include "FUi_PropertyBase.h" +#include "FUi_TouchGestureDetector.h" +#include "FGrp_FontImpl.h" + +namespace Tizen { namespace Base { namespace Collection { +template class ArrayListT; +template class HashMapT; +}}} + +namespace Tizen { namespace Ui { namespace Animations +{ +class _VisualElement; +class _ControlVisualElement; +class _IVisualElementDelegate; +}}} + +namespace Tizen { namespace Ui { namespace _Layout +{ +class LayoutContainer; +class Layout; +}}} + +namespace Tizen { namespace Ui { + +class _Window; +class _DataBindingContext; +class _AccessibilityContainer; + +class _IControlDelegate +{ +public: + virtual ~_IControlDelegate(void){} + + // Queries + virtual Tizen::Graphics::Dimension GetContentSize(void) const = 0; + virtual Tizen::Ui::Animations::HitTestResult HitTest(const Tizen::Graphics::FloatPoint& point) = 0; + virtual Tizen::Base::String GetDescription(void) const = 0; + + // Invoked by operations + virtual void OnDraw(void) = 0; + virtual Tizen::Graphics::Canvas* OnCanvasRequestedN(const Tizen::Graphics::Dimension& size) = 0; + virtual Tizen::Graphics::Bitmap* OnCapturedBitmapRequestedN(void) = 0; + virtual result OnAttaching(const _Control* pParent) = 0; + virtual result OnAttached(void) = 0; + virtual void OnAttachingFailed(const _Control& parent) = 0; // [ToDo] Is this callback still necessary? + virtual result OnAttachingToMainTree(const _Control* pParent) = 0; + virtual result OnAttachedToMainTree(void) = 0; + virtual result OnDetachingFromMainTree(void) = 0; + virtual result OnDetaching(void) = 0; + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds) = 0; + virtual void OnBoundsChanged(void) = 0; + virtual void OnEvaluateSize(Tizen::Graphics::Dimension& evaluatedSize) = 0; + virtual void OnParentBoundsChanged(const _Control& parent) = 0; + virtual void OnChildAttached(const _Control& child) = 0; + virtual void OnChildDetaching(const _Control& child) = 0; + virtual void OnChildDetached(const _Control& child) = 0; + virtual void OnChildBoundsChanged(const _Control& child) = 0; + virtual void OnChildVisibleStateChanged(const _Control& child) = 0; + virtual void OnChangeLayout(_ControlOrientation orientation) = 0; // [ToDo] Generalize orientation to screen. + virtual void OnZOrderChanging(_ControlZOrderUpdate zOrderUpdate) = 0; + virtual void OnVisibleStateChanging(void) = 0; + virtual void OnVisibleStateChanged(void) = 0; + virtual void OnAncestorVisibleStateChanged(const _Control& control) = 0; + virtual void OnAncestorEnableStateChanged(const _Control& control) = 0; + virtual void OnFontChanged(Tizen::Graphics::Font* pFont) = 0; + virtual void OnFontInfoRequested(unsigned long& style, int& size) =0; +}; + +class _IPropagatedTouchEventListener + : public _ITouchEventListener +{ +public: + virtual ~_IPropagatedTouchEventListener(void){} + + virtual void OnTouchPressHandled(const _Control& control) = 0; + virtual void OnTouchReleaseHandled(const _Control& control) = 0; + virtual void OnTouchMoveHandled(const _Control& control) = 0; + virtual void OnTouchCancelHandled(const _Control& control) = 0; +}; + +class _IPropagatedKeyEventListener + : public _IKeyEventListener +{ +public: + virtual ~_IPropagatedKeyEventListener(void){} +}; + +class _OSP_EXPORT_ _Control // Temp: export only for test + : public _IControlDelegate + , public _ITouchEventPreviewer + , public _IKeyEventPreviewer + , public _IFocusEventListener + , public _INotificationEventPreviewer + , public _INotificationEventListener + , public _PropertyBase + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer + , public _IPropagatedTouchEventListener + , public _IPropagatedKeyEventListener +{ +// Declare Properties + DECLARE_CLASS_BEGIN(_Control, _PropertyBase); + DECLARE_PROPERTY("Name", GetPropertyName, SetPropertyName); + DECLARE_CLASS_END(); + +// Property Getters/Setters + result SetPropertyName(const Variant& name); + Variant GetPropertyName(void) const; + +public: +// Constants + enum + { + MAX_LENGTH = 0xFFFF + }; + + enum VisitType + { + VISIT_UPWARD, + VISIT_DOWNWARD, + VISIT_STOP + }; + +// Type definitions + class Visitor + { + public: + virtual ~Visitor(void){} + virtual VisitType Visit(_Control& control) = 0; + }; + + typedef Tizen::Base::Collection::ArrayListT<_Control*> ControlList; + typedef Tizen::Base::Collection::ArrayListT<_Window*> WindowList; + typedef Tizen::Base::Collection::HashMapT<_TouchGestureDetector*, _TouchGestureDetectorState> GestureMap; + +public: +// Life Cycle + static _Control* CreateControlN(void); + virtual ~_Control(void); + +// Event Callbacks + virtual bool OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo); + virtual bool OnPreviewKeyReleased(const _Control& source, const _KeyInfo& keyInfo); + virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo); + virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo); + virtual bool TranslateKeyEventInfo(const _Control& source, _KeyInfo& keyInfo); + virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual _UiTouchEventDelivery OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnFocusGained(const _Control& source); + virtual bool OnFocusLost(const _Control& source); + virtual bool OnPreviewNotifiedN(const _Control& source, Tizen::Base::Collection::IList* pArgs); // [ToDo] Make the notification id as enumeration. + virtual bool OnNotifiedN(const _Control& source, Tizen::Base::Collection::IList* pArgs); + +// Virtual Queries: Do not use directly. Use through delegate (GetControlDelegate()) + virtual Tizen::Graphics::Dimension GetContentSize(void) const; + virtual Tizen::Ui::Animations::HitTestResult HitTest(const Tizen::Graphics::FloatPoint& point); + virtual Tizen::Base::String GetDescription(void) const; + virtual int GetVerticalScrollPosition(void) const; + virtual int GetHorizontalScrollPosition(void) const; + +// Callbacks // [ToDo] Make these callbacks protected. + virtual void OnDraw(void); + virtual Tizen::Graphics::Canvas* OnCanvasRequestedN(const Tizen::Graphics::Dimension& size); + virtual Tizen::Graphics::Bitmap* OnCapturedBitmapRequestedN(void); + virtual result OnAttaching(const _Control* pParent); + virtual result OnAttached(void); + virtual result OnAttachingToMainTree(const _Control* pParent); + virtual result OnAttachedToMainTree(void); + virtual result OnDetachingFromMainTree(void); + virtual void OnAttachingFailed(const _Control& parent); + virtual result OnDetaching(void); + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); + virtual void OnBoundsChanged(void); + virtual void OnEvaluateSize(Tizen::Graphics::Dimension& evaluatedSize); + virtual void OnParentBoundsChanged(const _Control& parent); + virtual void OnChildAttached(const _Control& child); + virtual void OnChildDetaching(const _Control& child); + virtual void OnChildDetached(const _Control& child); + virtual void OnChildBoundsChanged(const _Control& child); + virtual void OnChildVisibleStateChanged(const _Control& child); + virtual void OnChangeLayout(_ControlOrientation orientation); + virtual void OnZOrderChanging(_ControlZOrderUpdate zOrderUpdate); + virtual void OnVisibleStateChanging(void); + virtual void OnVisibleStateChanged(void); + virtual void OnAncestorVisibleStateChanged(const _Control& control); + virtual void OnAncestorEnableStateChanged(const _Control& control); + virtual void OnTouchPressHandled(const _Control& control); + virtual void OnTouchReleaseHandled(const _Control& control); + virtual void OnTouchMoveHandled(const _Control& control); + virtual void OnTouchCancelHandled(const _Control& control); + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + +// Control Hierarchy - Common + bool HasParent(void) const; + _Control* GetParent(void) const; + _ControlArea GetArea(void) const; + _ControlLayer GetLayer(void) const; + + bool IsAncestorOf(const _Control& control) const; + bool IsAttachedToMainTree(void) const; + _Window* GetRootWindow(void) const; + + void Accept(Visitor& visitor); + void Accept(Visitor& visitor) const; + +// Control Hierarchy + int GetChildIndex(const _Control& child) const; + _Control* GetChild(int index) const; + int GetChildCount(void) const; + + result AttachChild(_Control& child); + result InsertChildToBottom(_Control& child); + result InsertChildAfter(const _Control& targetChild, _Control& child); + result InsertChildBefore(const _Control& targetChild, _Control& child); + result DetachChild(_Control& child); + void DetachAllChildren(bool detachSystemChild = true); + result MoveChildToTop(const _Control& child); + result MoveChildToBottom(const _Control& child); + result MoveChildAfter(const _Control& targetChild, const _Control& child); + result MoveChildBefore(const _Control& targetChild, const _Control& child); + + result SetChildAlwaysOnTop(_Control& child); + result SetChildAlwaysAtBottom(_Control& child); + result ResetChildLayer(_Control& child); + +// Control Hierarchy - System area: For system children, layout is not applyed. + result AttachSystemChild(_Control& child); + result DetachSystemChild(_Control& child); + +// Ownership + int GetOwneeCount(void) const; + _Window* GetOwnee(int index) const; + +// Handle + _ControlHandle GetHandle(void) const; + +// Name + Tizen::Base::String GetName(void) const; + void SetName(const Tizen::Base::String& name); + +// Event previewer/listener + template + T GetEventPreviewer(void) const + { + return GetEventPreviewer(_IntToType()); + } + + template + T GetEventListener(void) const + { + return GetEventListener(_IntToType()); + } + + template + void SetEventPreviewer(const T& t) + { + SetEventPreviewer(_IntToType(), t); + } + + template + void SetEventListener(const T& t) + { + SetEventListener(_IntToType(), t); + } + + void ResetEventListeners(void); + +// Drawing + void Draw(bool recursive = true); + void Show(void); + void Invalidate(void); + void Invalidate(bool recursive); + void Invalidate(const Tizen::Graphics::Rectangle& rect); + Tizen::Graphics::Canvas* GetCanvasN(void) const; + Tizen::Graphics::Canvas* GetCanvasN(const Tizen::Graphics::Rectangle& bounds) const; + bool IsCalledGetCanvasN(void) const; + Tizen::Graphics::Canvas* GetClientCanvasN(void) const; + Tizen::Graphics::Color GetBackgroundColor(void) const; + void SetBackgroundColor(const Tizen::Graphics::Color& color); + Tizen::Graphics::Bitmap* GetCapturedBitmapN(bool includeChildren) const; + Tizen::Graphics::Rectangle GetInvalidatedBounds(void) const; + void SetDrawWhenVisible(bool draw); + bool IsDrawWhenVisible(void); + void SetTerminatingOrder(bool postOrderTraversal); + +// Font + result SetFont(const Tizen::Base::String& fontName); + Tizen::Graphics::Font* GetFallbackFont(void); + Tizen::Base::String GetFont(void) const; + +// Enable + bool IsEnabled(void) const; + bool GetEnableState(void) const; + void SetEnableState(bool enableState); + + bool IsInputEnabled(void) const; + bool GetInputEnableState(void) const; + void SetInputEnableState(bool inputEnableState); + +// Visible + bool IsVisible(void) const; + bool GetVisibleState(void) const; + void SetVisibleState(bool visibleState); + +// Focus + bool IsFocusable(void) const; + void SetFocusable(bool focusable); + bool IsFocused(void) const; + _Control* GetFocused(void) const; + result SetFocused(void); + bool IsNativeObjectFocusable(void) const; + void SetNativeObjectFocusable(bool focusable); + +// Clipping + bool IsClipToParent(void) const; + result SetClipToParent(bool clipToParent); + result SetClipChildrenEnabled(bool clipChildren); + +// Geometry + bool IsMovable(void) const; + bool IsResizable(void) const; + void SetMovable(bool movable); + void SetResizable(bool resizable); + + Tizen::Graphics::Rectangle GetBounds(void) const; + Tizen::Graphics::Point GetPosition(void) const; + Tizen::Graphics::Dimension GetSize(void) const; + result SetBounds(const Tizen::Graphics::Rectangle& bounds, bool callBoundsChangeCallbacks = true); + result SetBounds(const Tizen::Graphics::FloatRectangle& bounds, bool callBoundsChangeCallbacks = true); + result SetPosition(const Tizen::Graphics::Point& position); + result SetSize(const Tizen::Graphics::Dimension& size); + + Tizen::Graphics::Dimension GetMinimumSize(void) const; + Tizen::Graphics::Dimension GetMaximumSize(void) const; + result SetMinimumSize(const Tizen::Graphics::Dimension& newMinSize); + result SetMaximumSize(const Tizen::Graphics::Dimension& newMaxSize); + Tizen::Graphics::Point ConvertToControlPosition(const Tizen::Graphics::Point& screenPosition) const; + Tizen::Graphics::Point ConvertToScreenPosition(const Tizen::Graphics::Point& controlPosition) const; + + Tizen::Graphics::Rectangle GetClientBounds(void) const; + Tizen::Graphics::Rectangle GetClientBounds(const Tizen::Graphics::Dimension& size) const; + Tizen::Graphics::Rectangle GetAbsoluteBounds(void) const; + result SetClientBounds(const Tizen::Graphics::Rectangle& bounds); + bool IsCalledSetClientBounds(void); + + bool Contains(const Tizen::Graphics::Point& point) const; + _Control* GetTopmostChildAt(const Tizen::Graphics::Point& point) const; + +// Layout + void PartialUpdateLayout(void); + void UpdateLayout(void); + bool IsLayoutable(void) const; + _Layout::LayoutContainer& GetLayoutContainer(void) const; + _Layout::Layout* GetLayout(void) const; + result AddLayout(_Layout::Layout& layout); + result SetCurrentLayout(_Layout::Layout& layout); + void SetUpdateLayoutState(bool state); + +// Orientation + void ChangeLayout(_ControlOrientation orientation); + _ControlOrientation GetOrientation(void) const; + virtual bool IsLayoutChangable(void) const; + virtual bool IsOrientationRoot(void) const; + +// Touch, Gesture + result AddGestureDetector(const _TouchGestureDetector& gestureDetector); + result RemoveGestureDetector(const _TouchGestureDetector& gestureDetector); + Tizen::Base::Collection::IListT<_TouchGestureDetector*>* GetGestureDetectorList(void) const; + bool IsDelayedTouchEventEnabled(void) const; + bool IsCancelOnGestureSuccess(void) const; + bool IsPossibleToSendDelayedTouchEvent(void) const; + bool IsSentDelayedEvent(void) const; + void SetSentDelayedEvent(bool sent); + void SetSendingDelayedEvent(bool sending); + bool IsSendingDelayedEvent(void) const; + void AddTouchInfo(const _TouchInfo& touchInfo); + Tizen::Base::Collection::IListT<_TouchInfo*>* GetTouchInfoList(void); + result AddStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state); + result ClearStartedGestureDetectorList(void); + result SetStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state); + Tizen::Base::Collection::IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* GetStartedGestureDetectorEnumeratorN(void) const; + + void SetMultiTouchEnabled(bool enabled); + bool IsMultiTouchEnabled(void) const; + void SetTouchCapture(bool allowOutOfBounds = false); + void ReleaseTouchCapture(void); + + bool IsDragEnabled(void) const; + bool IsDropEnabled(void) const; + void SetDragEnabled(bool enabled); + void SetDropEnabled(bool enabled); + + void SetTouchMoveAllowance(_TouchMoveAllowance touchMoveAllowanceType); + _TouchMoveAllowance GetTouchMoveAllowance(void) const; + + void SetChangingEventTarget(bool isChangingEventTarget); + bool GetChangingEventTarget(void) const; + +// Data binding + _DataBindingContext* GetDataBindingContext(void); + _AccessibilityContainer* GetAccessibilityContainer(void); + +// User data: Already used by impl. + void* GetUserData(void) const; + void SetUserData(void* pUserData); + +// Delegate Already used by impl. + void SetControlDelegate(_IControlDelegate& delegate); + void ResetControlDelegate(void); + _IControlDelegate& GetControlDelegate(void) const; + + void SetPropagatedTouchEventListener(_IPropagatedTouchEventListener* pListener); + _IPropagatedTouchEventListener* GetPropagatedTouchEventListener(void) const; + + void SetPropagatedKeyEventListener(_IPropagatedKeyEventListener* pListener); + _IPropagatedKeyEventListener* GetPropagatedKeyEventListener(void) const; + +// Visual element: Do not use visual element directly. + Animations::_VisualElement* GetVisualElement(void) const; + + void PrintDescription(bool printChildren = true); + + void SetEventReceivable(bool receivable); + bool IsEventReceivable(void) const; + +protected: + _Control(void); + void DisposeControl(void); + void AcquireHandle(void); + void SetDataBindingContext(_DataBindingContext* pDataBindingContext); + +private: + _Control(const _Control& rhs); + _Control& operator =(const _Control& rhs); + + void ReleaseHandle(void); + + bool IsInSizeRange(const Tizen::Graphics::Dimension& size); + result AdjustSizeToRange(void); + result SetBoundsInternal(const Tizen::Graphics::FloatRectangle& bounds, bool callBoundsChangeCallbacks); + result SetBoundsFinal(const Tizen::Graphics::FloatRectangle& newBounds, bool changeLayoutBaseRect, bool callBoundsChangeCallbacks); + result UpdateBoundsOfVisualElement(const Tizen::Graphics::FloatRectangle& controlBounds); + + const ControlList& GetChildList(void) const; + ControlList& GetChildList(void); + result StartAttaching(_Control& child, _ControlArea area); + result EndAttaching(_Control& child); + void SetParent(_Control* pParent); + + bool IsCalledCallAttachingToMainTree(void); + void SetCalledCallAttachingToMainTree(bool isAttaching); + bool IsCalledCallAttachedToMainTree(void); + void SetCalledCallAttachedToMainTree(bool isAttached); + + result CallOnAttachingToMainTree(_Control& control); + result CallOnAttachedToMainTree(_Control& control); + result CallOnDetachingFromMainTree(_Control& control); + void CallOnAncestorVisibleStateChanged(void); + void CallOnAncestorEnableStateChanged(void); + + result AttachOwnee(_Window& window); + void DetachOwnee(_Window& window); + void DetachAllOwnees(void); + + void SetLayer(_ControlLayer layer); + + int PrintDescription(bool printChildren, int depth); + + _ITouchEventPreviewer* GetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>) const; + _IKeyEventPreviewer* GetEventPreviewer(_IntToType<_UI_EVENT_KEY>) const; + _INotificationEventPreviewer* GetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>) const; + + _IKeyEventListener* GetEventListener(_IntToType<_UI_EVENT_KEY>) const; + _IFocusEventListener* GetEventListener(_IntToType<_UI_EVENT_FOCUS>) const; + _INotificationEventListener* GetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>) const; + + void SetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>, _ITouchEventPreviewer* pPreviewer); + void SetEventPreviewer(_IntToType<_UI_EVENT_KEY>, _IKeyEventPreviewer* pPreviewer); + void SetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventPreviewer* pPreviewer); + + void SetEventListener(_IntToType<_UI_EVENT_FOCUS>, _IFocusEventListener* pListener); + void SetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventListener* pListener); + + +//--[ToDo] To be removed---------------------------------------------------------------------------------------------// +private: + void SetFocusOn(void); +public: + virtual void SetFocusOff(_Control* pFocus); +//-------------------------------------------------------------------------------------------------------------------// + +private: + _ControlHandle __controlHandle; + Tizen::Base::String __name; + + _Control* __pParent; + ControlList* __pChildren; + WindowList* __pOwnees; + + Tizen::Graphics::Rectangle __bounds; + Tizen::Graphics::Rectangle __clientBounds; + Tizen::Graphics::Rectangle __absoluteBounds; + Tizen::Graphics::Rectangle __invalidatedBounds; + Tizen::Graphics::Dimension __minSize; + Tizen::Graphics::Dimension __maxSize; + Tizen::Graphics::Color __backgroundColor; + + bool __movable; + bool __resizable; + bool __focusable; + bool __nativeObjectFocusable; + bool __enabledState; + bool __inputEnabledState; + bool __visibleState; + bool __initVisibleState; + bool __clipToParent; + bool __focusSet; + bool __multiTouchEnabled; + bool __dragEnabled; + bool __dropEnabled; + bool __drawWhenVisible; + bool __isPostOrderTraversal; + bool __isCalledCallOnAttachingToMainTree; + bool __isCalledCallOnAttachedToMainTree; + bool __isSetClientBounds; + bool __isCalledGetCanvasN; + + class ControlVisualElementContentProvider; + ControlVisualElementContentProvider* __pVisualElementContentProvider; + Animations::_ControlVisualElement* __pVisualElement; + + class ControlVisualElementEventListener; + ControlVisualElementEventListener* __pVisualElementEventListener; + + class LayoutItemHandler; + LayoutItemHandler* __pLayoutItemHandler; + _Layout::Layout* __pPortraitLayout; + _Layout::Layout* __pLandscapeLayout; + _Layout::LayoutContainer* __pLayoutContainer; + + _ControlArea __area; + _ControlLayer __layer; + _ControlOrientation __orientation; + + _ITouchEventPreviewer* __pTouchEventPreviewer; + _IKeyEventPreviewer* __pKeyEventPreviewer; + _INotificationEventPreviewer* __pNotificationEventPreviewer; + + _IKeyEventListener* __pKeyEventListener; + _IFocusEventListener* __pFocusEventListener; + _INotificationEventListener* __pNotificationEventListener; + + Tizen::Base::Collection::IListT<_TouchGestureDetector*>* __pCoreGestureDetectors; + GestureMap* __pDetectStartedGestureMap; + Tizen::Base::Collection::IListT<_TouchInfo*>* __pDelayedTouchInfoList; + _TouchMoveAllowance __touchMoveAllowance; + bool __isSentDelayedEvent; + bool __isSendingDelayedEvent; + bool __isChangingEventTarget; + + _DataBindingContext* __pDataBindingContext; + _IControlDelegate* __pControlDelegate; + _IPropagatedTouchEventListener* __pPropagatedTouchEventListener; + _IPropagatedKeyEventListener* __pPropagatedKeyEventListener; + void* __pUserData; + _AccessibilityContainer* __pAccessibilityContainer; + + bool __destroying; + bool __isEventReceivable; + + bool __isControlFontChanged; + Tizen::Graphics::Font* __pFont; + Tizen::Base::String __fontName; + + friend class _Window; + friend class _ControlManager; + friend class LayoutItemHandler; +}; // _Control + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_CONTROL_H_ diff --git a/src/ui/inc/FUi_ControlImpl.h b/src/ui/inc/FUi_ControlImpl.h new file mode 100644 index 0000000..864103f --- /dev/null +++ b/src/ui/inc/FUi_ControlImpl.h @@ -0,0 +1,384 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ControlImpl.h + * @brief This is the header file for the _ControlImpl class. + * + * This header file contains the declarations of the %_ControlImpl class. + */ + +#ifndef _FUI_INTERNAL_CONTROL_IMPL_H_ +#define _FUI_INTERNAL_CONTROL_IMPL_H_ + +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Base { namespace Collection +{ +template class LinkedListT; +}}} + +namespace Tizen { namespace Ui { namespace Animations +{ +class VisualElement; +}}} + +namespace Tizen { namespace Ui +{ + +class _ContainerImpl; +class _Control; +class _TouchInfo; +class _TouchLongPressGestureDetector; +class _TouchFlickGestureDetector; +class TouchGestureDetector; +class _AccessibilityContainer; +class _AccessibilityContainerImpl; +class AccessibilityContainer; + +class _OSP_EXPORT_ _ControlImpl + : public Tizen::Base::Object + , public _IControlDelegate +{ +// Size Info +public: + class SizeInfo + { + public: + virtual ~SizeInfo(void); + virtual Tizen::Graphics::Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const; // default: (0, 0) + virtual Tizen::Graphics::Dimension GetDefaultMaximumSize(_ControlOrientation orientation) const; // default: (short_max, short_max) + virtual Tizen::Graphics::Dimension GetMinimumSizeLimit(_ControlOrientation orientation) const; // default: (0, 0) + virtual Tizen::Graphics::Dimension GetMaximumSizeLimit(_ControlOrientation orientation) const; // default: (short_max, short_max) + result CheckInitialSizeValid(const Tizen::Graphics::Dimension& size,_ControlOrientation orientation) const; + }; + +// Constants +public: + static Tizen::Graphics::Rectangle GetErrorBounds(void); + static CompositeMode GetErrorCompositeMode(void); + static Tizen::Graphics::Color GetErrorChromaKeyColor(void); + static Tizen::Graphics::Dimension GetErrorMinimumSize(void); + static Tizen::Graphics::Dimension GetErrorMaximumSize(void); + + static const SizeInfo& GetFullScreenSizeInfo(void); + +// Life Cycle +public: + static _ControlImpl* CreateControlImplN(Control& control); + virtual ~_ControlImpl(void); + + static _ControlImpl* GetInstance(Control& control); + static const _ControlImpl* GetInstance(const Control& control); + +// Common +public: + virtual const char* GetPublicClassName(void) const; + virtual const Control& GetPublic(void) const; + virtual Control& GetPublic(void); + virtual const _Control& GetCore(void) const; + virtual _Control& GetCore(void); + +// Public Event Listeners + result AddFocusEventListener(IFocusEventListener& listener); + result AddKeyEventListener(IKeyEventListener& listener); + result AddTouchEventListener(ITouchEventListener& listener); + result AddDragDropEventListener(IDragDropEventListener& listener); + result AddTouchModeChangedEventListener(ITouchModeChangedEventListener& listener); + result RemoveFocusEventListener(IFocusEventListener& listener); + result RemoveKeyEventListener(IKeyEventListener& listener); + result RemoveTouchEventListener(ITouchEventListener& listener); + result RemoveDragDropEventListener(IDragDropEventListener& listener); + result RemoveTouchModeChangedEventListener(ITouchModeChangedEventListener& listener); + result AddGestureDetector(const TouchGestureDetector& gestureDetector); + result RemoveGestureDetector(const TouchGestureDetector& gestureDetector); + Tizen::Base::Collection::IListT* GetGestureDetectorList(void) const; + + // [ToDo] Rename API: These APIs return collection. + Tizen::Base::Collection::LinkedListT * GetTouchEventListener(void) const; + Tizen::Base::Collection::LinkedListT * GetDragDropEventListener(void) const; + +// Queries + virtual Tizen::Graphics::Dimension GetContentSize(void) const; + virtual Tizen::Ui::Animations::HitTestResult HitTest(const Tizen::Graphics::FloatPoint& point); + virtual Tizen::Base::String GetDescription(void) const; + +// Callbacks + virtual void OnDraw(void); + virtual Tizen::Graphics::Canvas* OnCanvasRequestedN(const Tizen::Graphics::Dimension& size); + virtual Tizen::Graphics::Bitmap* OnCapturedBitmapRequestedN(void); + virtual result OnAttaching(const _Control* pParent); + virtual void OnAttachingFailed(const _Control& parent); + virtual result OnAttached(void); + virtual result OnAttachingToMainTree(const _Control* pParent); + virtual result OnAttachedToMainTree(void); + virtual result OnDetachingFromMainTree(void); + virtual result OnDetaching(void); + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); + virtual void OnBoundsChanged(void); + virtual void OnEvaluateSize(Tizen::Graphics::Dimension& evaluatedSize); + virtual void OnParentBoundsChanged(const _Control& parent); + virtual void OnChildAttached(const _Control& child); + virtual void OnChildDetaching(const _Control& child); + virtual void OnChildDetached(const _Control& child); + virtual void OnChildBoundsChanged(const _Control& child); + virtual void OnChildVisibleStateChanged(const _Control& child); + virtual void OnChangeLayout(_ControlOrientation orientation); + virtual void OnZOrderChanging(_ControlZOrderUpdate zOrderUpdate); + virtual void OnVisibleStateChanging(void); + virtual void OnVisibleStateChanged(void); + virtual void OnAncestorVisibleStateChanged(const _Control& control); + virtual void OnAncestorEnableStateChanged(const _Control& control); + virtual void OnTouchPressHandled(const _Control& control); + virtual void OnTouchReleaseHandled(const _Control& control); + virtual void OnTouchMoveHandled(const _Control& control); + virtual void OnTouchCancelHandled(const _Control& control); + virtual void OnFontChanged(Tizen::Graphics::Font* pFont); + virtual void OnFontInfoRequested(unsigned long& style, int& size); + +// Event Callbacks + virtual bool OnKeyPressed(const _ControlImpl& source, const _KeyInfo& keyInfo); + virtual bool OnKeyReleased(const _ControlImpl& source, const _KeyInfo& keyInfo); + virtual bool OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo); + virtual bool OnFocusGained(const _ControlImpl& source); + virtual bool OnFocusLost(const _ControlImpl& source); + virtual bool OnNotifiedN(const _ControlImpl& source, Tizen::Base::Collection::IList* pArgs); + virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs); + +// Control Hierarchy + bool IsAttachedToMainTree(void) const; + _ContainerImpl* GetParent(void) const; + +// Drawing + result Draw(bool recursive = true); + result Show(void); + void Invalidate(bool recursive); + void Invalidate(const Tizen::Graphics::Rectangle& rect); + Tizen::Graphics::Canvas* GetCanvasN(void) const; + Tizen::Graphics::Canvas* GetCanvasN(const Tizen::Graphics::Rectangle& bounds) const; + Tizen::Graphics::Canvas* GetClientCanvasN(void) const; + void RequestRedraw(bool show) const; + + virtual bool IsOpaque(void) const; + Tizen::Graphics::Color GetForegroundColor(void) const; + Tizen::Graphics::Color GetBackgroundColor(void) const; + void SetForegroundColor(const Tizen::Graphics::Color& color); + void SetBackgroundColor(const Tizen::Graphics::Color& color); + + int GetFontSize(void) const; + void SetFontSize(int fontSize); + +// Font + result SetFont(const Tizen::Base::String& fontName); + Tizen::Base::String GetFont(void) const; + +// Enable + bool IsEnabled(void) const; + bool GetEnableState(void) const; + void SetEnableState(bool enableState); + + bool IsInputEnabled(void) const; + bool GetInputEnableState(void) const; + void SetInputEnableState(bool inputEnableState); + +// Visible + bool IsVisible(void) const; + bool GetVisibleState(void) const; + result SetVisibleState(bool visibleState); + +// Focus + bool IsFocusable(void) const; + bool IsFocused(void) const; + void SetFocusableChangable(bool focusableChangable); + result SetFocusable(bool focusable); + result SetFocused(void); + +// Clipping + bool IsClipToParent(void) const; + result SetClipToParent(bool clipToParent); + +// Geometry + bool IsMovable(void) const; + bool IsResizable(void) const; + + Tizen::Graphics::Rectangle GetBounds(void) const; + Tizen::Graphics::Point GetPosition(void) const; + Tizen::Graphics::Dimension GetSize(void) const; + result SetBounds(const Tizen::Graphics::Rectangle& bounds, bool checkMove = true); + result SetBoundsAndUpdateLayout(const Tizen::Graphics::Rectangle& bounds); + result SetPosition(const Tizen::Graphics::Point& position); + result SetSize(const Tizen::Graphics::Dimension& size); + + Tizen::Graphics::Dimension GetMinimumSize(void) const; + Tizen::Graphics::Dimension GetMaximumSize(void) const; + result SetMinimumSize(const Tizen::Graphics::Dimension& newMinSize); + result SetMaximumSize(const Tizen::Graphics::Dimension& newMaxSize); + Tizen::Graphics::Point ConvertToControlPosition(const Tizen::Graphics::Point& screenPosition) const; + Tizen::Graphics::Point ConvertToScreenPosition(const Tizen::Graphics::Point& controlPosition) const; + + Tizen::Graphics::Rectangle GetClientBounds(void) const; + Tizen::Graphics::Rectangle GetAbsoluteBounds(void) const; + result SetClientBounds(const Tizen::Graphics::Rectangle& bounds); + + virtual Tizen::Graphics::Dimension GetMinimumSizeLimit(void) const; + virtual Tizen::Graphics::Dimension GetMaximumSizeLimit(void) const; + + Tizen::Graphics::Bitmap* GetCapturedBitmapN(void) const; + Tizen::Graphics::Rectangle GetInvalidatedBounds(void) const; + + bool Contains(const Tizen::Graphics::Point& point) const; + + bool GetBuilderBounds(_ControlOrientation orientation, Tizen::Graphics::Rectangle& bounds) const; + result SetBuilderBounds(_ControlOrientation orientation, const Tizen::Graphics::Rectangle& bounds); + +// Layout + bool IsLayoutable(void) const; + _Layout::LayoutContainer& GetLayoutContainer(void) const; + +// Key, Touch, Gesture + bool IsInTouchMode(void) const; + bool IsDragEnabled(void) const; + bool IsDropEnabled(void) const; + void SetDragEnabled(bool enabled); + void SetDropEnabled(bool enabled); + bool IsMultiTouchEnabled(void) const; + void SetMultiTouchEnabled(bool enabled); + result GenerateKeyEvent(KeyState keyState, _KeyCode keyCode); + result GenerateTouchEvent(const _TouchInfo& touchInfo); + +// Name + Tizen::Base::String GetName(void) const; + void SetName(const Tizen::Base::String& name); + +// Use Event + void SendUserEvent(RequestId requestId, const Tizen::Base::Collection::IList* pArgs) const; + +// Event Consumming + void ConsumeInputEvent(void); + ITouchEventListener* GetDefaultTouchEventListener(void) const; + IKeyEventListener* GetDefaultKeyEventListener(void) const; + void SetDefaultKeyEventListener(IKeyEventListener* pDefaultListener); + void SetDefaultTouchEventListener(ITouchEventListener* pDefaultListener); + +// Control Animator + Animations::ControlAnimator* GetControlAnimator(void) const; + +// Control VisualElement + Tizen::Ui::Animations::VisualElement* GetVisualElement(void) const; + + AccessibilityContainer* GetAccessibilityContainer(void); +// Deprecated APIs + Tizen::Ui::CompositeMode GetCompositeMode(void) const; + result SetCompositeMode(Tizen::Ui::CompositeMode compositeMode); + Tizen::Graphics::Color GetChromaKeyColor(void) const; + result SetChromaKeyColor(Tizen::Graphics::Color chromaKeyColor); + + +protected: + _ControlImpl(Control* pPublic, _Control* pCore); + static result CheckConstruction(_Control* pCore, _ControlImpl* pImpl); // Use this in the Factory methods. + + typedef Tizen::Base::Collection::LinkedListT PublicEventListenerList; + PublicEventListenerList* CreatePublicEventListenerListN(void) const; + + void SetMovable(bool movable); + void SetResizable(bool resizable); + +// Initializing Impl's bounds + result InitializeBoundsProperties(const SizeInfo& sizeInfo, _ControlOrientation orientation); + result InitializeBoundsProperties(const SizeInfo& sizeInfo, const Tizen::Graphics::Rectangle& bounds, _ControlOrientation orientation); + result InitializeBoundsProperties(const SizeInfo& sizeInfo, const Tizen::Graphics::Dimension& size, _ControlOrientation orientation); + +private: + _ControlImpl(const _ControlImpl& rhs); + _ControlImpl& operator =(const _ControlImpl& rhs); + + bool IsInputEventConsumed(void) const; + void ResetInputEventConsumed(void); + bool SendNotification(const _ControlImpl& source, Tizen::Base::Collection::IList* pArgs); + + // [ToDo] If not necessary remove. + bool HasCore(void) const; + result SetCore(_Control& core); + void ResetCore(bool deallocate = false); + + void Dispose(bool deallocateCore); + + bool CallOnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + bool CallOnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + bool CallOnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + bool CallOnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + +private: + Tizen::Graphics::Rectangle __oldBounds; + Control* __pControlPublic; + _Control* __pControlCore; + Tizen::Ui::Animations::ControlAnimator* __pControlAnimator; + Tizen::Ui::Animations::VisualElement* __pCustomVisualElement; + + PublicEventListenerList* __pPublicFocusEventListeners; + PublicEventListenerList* __pPublicKeyEventListeners; + PublicEventListenerList* __pPublicTouchEventListeners; + PublicEventListenerList* __pPublicDragDropEventListeners; + PublicEventListenerList* __pPublicTouchModeChangedEventListeners; + + IKeyEventListener* __pDefaultKeyEventListener; + ITouchEventListener* __pDefaultTouchEventListener; + + Tizen::Graphics::Color __foregroundColor; + int __fontSize; + + bool __inputEventConsumed; + bool __focusableChangable; + + class CoreEventListener; + CoreEventListener* __pCoreEventListener; + + class CoreKeyEvent; + CoreKeyEvent* __pCoreKeyEvent; + + class CoreTouchEvent; + CoreTouchEvent* __pCoreTouchEvent; + + class CoreFocusEvent; + CoreFocusEvent* __pCoreFocusEvent; + + class CoreGestureEvent; + CoreGestureEvent* __pCoreGestureEvent; + + class _PropagatedTouchEventListener; + _PropagatedTouchEventListener* __pPropagatedTouchEventListener; + + class _PropagatedKeyEventListener; + _PropagatedKeyEventListener* __pPropagatedKeyEventListener; + + Tizen::Graphics::Rectangle* __pBuilderPortraitBounds; + Tizen::Graphics::Rectangle* __pBuilderLandscapeBounds; + + _TouchFlickGestureDetector* __pFlickGestureDetector; + _TouchLongPressGestureDetector* __pLongPressGestureDetector; + Tizen::Base::Collection::IListT* __pPublicGestureDetectors; + _AccessibilityContainerImpl* __pAccessibilityContainerImpl; + friend class _ContainerImpl; +}; // _ControlImpl + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_CONTROL_IMPL_H_ diff --git a/src/ui/inc/FUi_ControlImplManager.h b/src/ui/inc/FUi_ControlImplManager.h new file mode 100644 index 0000000..dd0d641 --- /dev/null +++ b/src/ui/inc/FUi_ControlImplManager.h @@ -0,0 +1,80 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ControlImplManager.h + * @brief This is the header file for the _ControlImplManager class. + * + * This header file contains the declarations of the %_ControlImplManager class. + */ + +#ifndef _FUI_INTERNAL_CONTROL_IMPL_MANAGER_H_ +#define _FUI_INTERNAL_CONTROL_IMPL_MANAGER_H_ + +#include +#include "FUi_Types.h" + +extern "C" { +_OSP_EXPORT_ result InitializeUiFramework(void); +_OSP_EXPORT_ void FinalizeUiFramework(void); +} + +namespace Tizen { namespace Ui { + +class _WindowImpl; +class _ControlImpl; + +#if defined(MULTI_WINDOW) +class _ControlImpl; +#endif + +class _ControlImplManager +{ +public: + static void Initialize(void); + static void Release(void); + static _ControlImplManager* GetInstance(void); + static void InitInstance(void); + + _WindowImpl* GetCurrentFrame(void) const; + + void OnScreenRotated(int rotation); + OrientationStatus GetFormOrientationStatus(_ControlImpl *pControlImpl); + +private: + void SetOrientationStatus(OrientationStatus orientationStatus); +#if !defined(MULTI_WINDOW) + static void RotateScreen(OrientationStatus orientationStatus); +#else + static void RotateScreen(_ControlImpl* pControlImpl, OrientationStatus orientationStatus); +#endif + OrientationStatus GetOrientationStatus(Orientation mode) const; + +private: + _ControlImplManager(void); + _ControlImplManager(const _ControlImplManager& rhs); + _ControlImplManager& operator =(const _ControlImplManager& rhs); + ~_ControlImplManager(void); + +private: + _WindowImpl* __pFrameImpl; + static _ControlImplManager* __pInstance; + friend class _OrientationAgent; +}; // _ControlImplManager + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_CONTROL_IMPL_MANAGER_H_ diff --git a/src/ui/inc/FUi_ControlManager.h b/src/ui/inc/FUi_ControlManager.h new file mode 100644 index 0000000..4624a7c --- /dev/null +++ b/src/ui/inc/FUi_ControlManager.h @@ -0,0 +1,193 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ControlManager.h + * @brief This is the header file for the _ControlManager class. + * + * This header file contains the declarations of the %_ControlManager class. + */ + +#ifndef _FUI_INTERNAL_CONTROL_MANAGER_H_ +#define _FUI_INTERNAL_CONTROL_MANAGER_H_ + +#include +#include +#include +#include +#include "FUi_Types.h" + +#if defined(MULTI_WINDOW) +namespace Tizen { namespace Base { namespace Collection +{ +template class LinkedListT; +}}} // Tizen::Base::Collection +#endif + +namespace Tizen { namespace Ui +{ + +class _Window; +class _IWindow; +class _IUiEventListener; +class _TouchGestureDetector; + +class _OSP_EXPORT_ _ControlManager + : public Tizen::System::ISettingEventListener +{ +public: +// Initialize, Access, Release + static void Initialize(void); + static void Release(void); + static _ControlManager* GetInstance(void); + static void InitInstance(void); + +// Control Handle Management + _ControlHandle Register(_Control* pObject); + _Control* Release(const _ControlHandle& handle); + _Control* GetObject(const _ControlHandle& handle); + const _Control* GetObject(const _ControlHandle& handle) const; + int GetUsedHandleCount(void) const; + +// Operations + _Window* GetWindow(int index) const; + int GetWindowCount(void) const; + _Window* GetTopWindow(void) const; +#if defined(MULTI_WINDOW) + _Window* GetTopVisibleWindow(void) const; + _Window* GetTopVisibleWindowAt(const Tizen::Graphics::Point& point) const; +#endif + bool IsWindowOnTop(const _Window& window) const; + bool IsWindowAttached(const _Window& window) const; + result OpenWindow(_Window& window, bool invalidate); + result CloseWindow(_Window& window); + +// Orientation + _ControlOrientation GetOrientation(void) const; + void SetOrientation(_ControlOrientation orientation); + +// Screen Rotation + _ControlRotation GetScreenRotation(void) const; + +// Informations + Tizen::Graphics::Dimension GetScreenSize(void) const; + +// Font + result SetDefaultFont(const Tizen::Base::String& appFontName); + Tizen::Base::String GetDefaultFont(void); + bool IsDefaultFontChanged(void); + void SetDefaultFontChangeState(bool isDefaultFontChanged); + +// Coordinate system info + bool IsCoordinateSystemLogical(void) const; + int GetCoordinateSystem(void) const; + Tizen::Graphics::_BaseScreenSize GetLogicalBaseScreenSize(void) const; + +// Focus + _Control* GetFocusedControl(void) const; + void SetFocusedControl(const _Control& control); + bool TakeFocusFromControl(const _Control& control); + +// Queries + _Control* GetTopmostTouchedControl(const Tizen::Graphics::Point& point); + _Window* GetCurrentFrame(void) const; + bool IsFrameActivated(void) const; + +#if !defined(MULTI_WINDOW) +// Root Control + const _Control& GetRoot(void) const; + _Control& GetRoot(void); +#endif + +// Global Gesture + result AddGestureDetector(const _TouchGestureDetector& gesture); + result RemoveGestureDetector(const _TouchGestureDetector& gesture); + Tizen::Base::Collection::IListT<_TouchGestureDetector*>* GetGestureDetectorList(void) const; + int GetGestureMaxTimeDuration(void) const; + +// Do not use. System only. + void SetOrientationStatus(_ControlRotation orientationStatus); + void RotateScreen(_ControlRotation screenRotation); + void RotateScreen(const _Control& control, _ControlRotation screenRotation); + void OnScreenRotated(int rotation); + void OnWindowRotated(int rotation); +#if defined(MULTI_WINDOW) + void SetTouchedWindow(unsigned int window); + _Window* GetTouchedWindow(void) const; +#endif + result MoveWindowToTop(const _Window& window); + result MoveWindowToBottom(const _Window& window); + +private: + ~_ControlManager(void); + _ControlManager(void); + _ControlManager(const _ControlManager&); + _ControlManager& operator =(const _ControlManager&); + +// Coordinate system info + result GetAppCoordinateSystem(bool& isCoordinateSystemLogical, int& logicalCoordinateSystemInt, Tizen::Graphics::_BaseScreenSize& logicalBaseScreenSize); + + result AttachWindow(_Window& window); + result InsertWindowToBottom(_Window& window); + result InsertWindowAfter(const _Window& targetWindow, _Window& window); + result InsertWindowBefore(const _Window& targetWindow, _Window& window); + result DetachWindow(_Window& window); + void DetachAllWindows(void); + + result MoveWindowAfter(const _Window& targetWindow, const _Window& window); + result MoveWindowBefore(const _Window& targetWindow, const _Window& window); + + result ActivateWindow(_Window& window); + + result CallOnAttachingToMainTree(_Control& control); + result CallOnAttachedToMainTree(_Control& control); + result CallOnDetachingFromMainTree(_Control& control); + + virtual void OnSettingChanged(Tizen::Base::String& key); + +private: + Tizen::Base::_ObjectManagerT <_Control> __objectManager; + +#if !defined(MULTI_WINDOW) + _Control* __pRoot; +#else + Tizen::Base::Collection::LinkedListT<_Window*>* __pWindowList; +#endif + bool __isCoordinateSystemLogical; + int __logicalCoordinateSystem; + Tizen::Graphics::_BaseScreenSize __logicalBaseScreenSize; + Tizen::Base::Collection::LinkedListT<_Window*>* __pSystemWindowList; + _Control* __pFocusedControl; + _ControlRotation __screenRotation; + _ControlRotation __orientationStatus; + _ControlOrientation __orientation; +#if !defined(MULTI_WINDOW) + _IWindow* __pWindowPi; +#endif + _Window* __pCurrentFrame; + Tizen::Base::Collection::IListT<_TouchGestureDetector*>* __pGestureList; + int __gestureMaxDuration; +#if defined(MULTI_WINDOW) + unsigned int __touchedWindow; // [SLP] +#endif + bool __isDefaultFontChanged; + Tizen::Base::String __defaultFontName; + static _ControlManager* __pInstance; +}; // _ControlManager + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_CONTROL_MANAGER_H_ diff --git a/src/ui/inc/FUi_CoordinateSystemUtils.h b/src/ui/inc/FUi_CoordinateSystemUtils.h new file mode 100644 index 0000000..1892db0 --- /dev/null +++ b/src/ui/inc/FUi_CoordinateSystemUtils.h @@ -0,0 +1,71 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_CoordinateSystemUtils.h + * @brief This is the header file for the _CoordinateSystemUtils class. + * + * This header file contains the declarations of the _CoordinateSystemUtils class. + */ + +#ifndef _FUI_INTERNAL_COORDINATE_SYSTEM_UTILS_H_ +#define _FUI_INTERNAL_COORDINATE_SYSTEM_UTILS_H_ + +#include +#include + +namespace Tizen { namespace Ui { + +class _OSP_EXPORT_ _CoordinateSystemUtils +{ +public: + // Transform Utilities + static Tizen::Graphics::Rectangle Transform(const Tizen::Graphics::Rectangle& rect); + static Tizen::Graphics::Rectangle Transform(const Tizen::Graphics::Point& point, const Tizen::Graphics::Dimension& dim); + static Tizen::Graphics::Dimension Transform(const Tizen::Graphics::Dimension& dim); + static Tizen::Graphics::Point Transform(const Tizen::Graphics::Point& point); + static int HorizontalTransform(int scalar); + static int VerticalTransform(int scalar); + + + // Inverse Transform Utilities + static Tizen::Graphics::Rectangle InverseTransform(const Tizen::Graphics::Rectangle& rect); + static Tizen::Graphics::Rectangle InverseTransform(const Tizen::Graphics::Point& point, const Tizen::Graphics::Dimension& dim); + static Tizen::Graphics::Dimension InverseTransform(const Tizen::Graphics::Dimension& dim); + static Tizen::Graphics::Point InverseTransform(const Tizen::Graphics::Point& point); + static int InverseHorizontalTransform(int scalar); + static int InverseVerticalTransform(int scalar); + + +private: + _CoordinateSystemUtils(void); + ~_CoordinateSystemUtils(void); + + _CoordinateSystemUtils(const _CoordinateSystemUtils&); + _CoordinateSystemUtils& operator =(const _CoordinateSystemUtils&); + + static Tizen::Graphics::_ICoordinateSystemTransformer* GetTransformer(void); + static Tizen::Graphics::_ICoordinateSystemTransformer* GetInverseTransformer(void); + +private: + static Tizen::Graphics::_CoordinateSystem* __pCoordinateSystemInstance; + +}; //class _CoordinateSystemUtils + +}} // Tizen::Ui + +#endif //_FUI_INTERNAL_COORDINATE_SYSTEM_UTILS_H_ \ No newline at end of file diff --git a/src/ui/inc/FUi_CustomControlBaseImpl.h b/src/ui/inc/FUi_CustomControlBaseImpl.h new file mode 100644 index 0000000..9a8e71c --- /dev/null +++ b/src/ui/inc/FUi_CustomControlBaseImpl.h @@ -0,0 +1,62 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_CustomControlBaseImpl.h + * @brief This is the header file for the _CustomControlBaseImpl class. + * + * This header file contains the declarations of the _CustomControlBaseImpl class. + */ + +#ifndef _FUI_INTERNAL_CUSTOM_CONTROL_BASE_IMPL_H_ +#define _FUI_INTERNAL_CUSTOM_CONTROL_BASE_IMPL_H_ + +#include +#include "FUi_ContainerImpl.h" + +namespace Tizen { namespace Ui +{ + +class _CustomControlBaseImpl + : public _ContainerImpl +{ +public: + //Life Cycle + virtual ~_CustomControlBaseImpl(void); + + static _CustomControlBaseImpl* CreateCustomControlBaseImplN(CustomControlBase* pPublic, const Tizen::Graphics::Rectangle& bounds, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, bool resizable, bool movable); + + // Getters/Setters + virtual const char* GetPublicClassName(void) const; + virtual const CustomControlBase& GetPublic(void) const; + virtual CustomControlBase& GetPublic(void); + static _CustomControlBaseImpl* GetInstance(CustomControlBase& pCustomControlBase); + static const _CustomControlBaseImpl* GetInstance(const CustomControlBase& pCustomControlBase); + + //Internal callbacks + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); + virtual void OnBoundsChanged(void); + virtual void OnEvaluateSize(Tizen::Graphics::Dimension& evaluatedSize); + +protected: + _CustomControlBaseImpl(CustomControlBase* pCustomControlBase, _Control* pCore, const Tizen::Graphics::Rectangle& bounds, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, bool resizable, bool movable); + + Tizen::Graphics::Rectangle __oldBounds; +}; // CustomControlBaseImpl + +}} // Tizen::Ui + +#endif //_FUI_INTERNAL_CUSTOM_CONTROL_BASE_IMPL_H_ diff --git a/src/ui/inc/FUi_Dimensionf.h b/src/ui/inc/FUi_Dimensionf.h new file mode 100644 index 0000000..13393f3 --- /dev/null +++ b/src/ui/inc/FUi_Dimensionf.h @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_Dimensionf.h + * @brief Header file of _Dimensionf class + * + * This file contains declarations _Dimensionf class. + */ + +#ifndef _FUI_ANIM_INTERNAL_DIMENSIONF_H_ +#define _FUI_ANIM_INTERNAL_DIMENSIONF_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _Dimensionf +{ +public: + _Dimensionf(void) + : __width(0.0f) + , __height(0.0f) {} + _Dimensionf(float width, float height) + : __width(width) + , __height(height) {} + _Dimensionf(const _Dimensionf& dim) + : __width(dim.__width) + , __height(dim.__height) {} + virtual ~_Dimensionf(void) {} + + _Dimensionf& SetSize(float width, float height) { __width = width;__height = height; return *this; } + + float Width(void) const { return __width;} + float Height(void) const { return __height;} + float& Width(void) { return __width;} + float& Height(void) { return __height;} + + bool operator !=(const _Dimensionf& dim) const + { + // CHECKME: need float compare ??? + return (__width != dim.__width) || (__height != dim.__height); + } + + bool operator ==(const _Dimensionf& dim) const + { + // CHECKME: need float compare ??? + return (__width == dim.__width) && (__height == dim.__height); + } + + _Dimensionf& operator =(const _Dimensionf& dim) + { + if (&dim != this) + { + __width = dim.__width; + __height = dim.__height; + } + + return *this; + } + +public: + float __width; + float __height; +}; // _Dimensionf + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_DIMENSIONF_H_ diff --git a/src/ui/inc/FUi_DragDropEvent.h b/src/ui/inc/FUi_DragDropEvent.h new file mode 100644 index 0000000..9ba9e87 --- /dev/null +++ b/src/ui/inc/FUi_DragDropEvent.h @@ -0,0 +1,157 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_DragDropEvent.h + * @brief This is the header file for _DragDropEvent class. + * @version 2.0 + * + * This header file contains declaration of _DragDropEvent class. + */ +#ifndef _FUI_INTERNAL_DRAG_DROP_EVENT_H_ +#define _FUI_INTERNAL_DRAG_DROP_EVENT_H_ + +// includes +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen { namespace Ui +{ +/** + * @enum DragDropStatus + * + * Defines constants used to identify drag drop status. + */ +enum DragDropStatus +{ + DRAG_DROP_INDICATED = 0, /**< The touch indicated event type */ + DRAG_DROP_PRESSED, /**< The touch pressed event type */ + DRAG_DROP_LONG_PRESSED, /**< The touch long pressed event type */ + DRAG_DROP_RELEASED, /**< The touch released event type */ + DRAG_DROP_MOVED, /**< The touch moved event type */ + DRAG_DROP_DOUBLE_PRESSED, /**< The touch double pressed event type */ + DRAG_DROP_FOCUS_IN, /**< The touch focus-in event type */ + DRAG_DROP_FOCUS_OUT, /**< The touch focus-out event type */ + DRAG_DROP_FLICKED, /**< The touch flicked event type */ + DRAG_DROP_FLICK_HELD, /**< The touch flick held event type */ + DRAG_DROP_DRAGGED, /**< The touch dragged event type */ + DRAG_DROP_DROPPED /**< The touch dropped event type */ +}; + +/** + * @class _DragDropEvent + * @brief This class handles a touch event. It is inherited from LowLevelEvent class. + * + * The Control class has an instance of the _DragDropEvent class as a member variable. + * _DragDropEvent notifies the listeners when a control receives a touch event. + * + * @since 2.0 + */ +class _OSP_EXPORT_ _DragDropEvent + : public Tizen::Base::Runtime::_Event + , public Tizen::Base::Runtime::IEventFilter +{ +// Lifecycle +public: + /** + * This is the default class constructor. After creating an instance of this + * class, you must explicitly call one of construction methods to initialize + * the instance. + */ + _DragDropEvent(void); + + /** + * This method constructs this _DragDropEvent instance. + * + * @return This method returns the error code. + * @param[in] source The owner of this key event. + * @exception E_SUCCESS - The method is successful. + * @exception E_SYSTEM - The method has failed. + * @exception E_ARG_NULL - @c pSource is @c NULL. + */ + result Construct(const Tizen::Ui::Control& source); + + + /** + * This is the class destructor. + */ + virtual ~_DragDropEvent(void); + + +// Operations +public: + /** + * This method enables/disables this event. A disabled event can not fire notification. + * + * @return This method returns the error code. + * @param[in] enable Determines the state of this event. + * @exception E_SUCCESS - This method is successful. + * @exception E_SYSTEM - This method has failed. + */ + result SetEnabled(bool enable); + + +// Accessors +public: + /** + * This method returns the owner of this event. + * + * @return See the comment above. + */ + const Tizen::Ui::Control* GetSource(void) const; + + + bool Filter(const Tizen::Base::Runtime::IEventArg& eventArg); + + // due to build error + virtual result AddListener(const Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::_EventDispatcher* pEventDispatcher); + virtual result Wait(void); + + +// Operations +protected: + /** + * This method calls appropriate IKeyEventListener method. + * + * @return This method returns the error code. + * @param[in] pListener The IKeyEventListener instance. + * @param[in] arg The _DragDropEventArg. + * @exception E_SUCCESS - The method is successful. + * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value. + * @exception E_INVALID_ARG - @c pListener is @c NULL. + */ + virtual result FireImpl(Tizen::Base::Runtime::IEventListener* pListener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + /** + * The event source. + */ + Tizen::Ui::Control* __pSource; + +}; // _DragDropEvent + +} } // Tizen::Ui + +#endif //_FUI_INTERNAL_DRAG_DROP_EVENT_H_ diff --git a/src/ui/inc/FUi_DragDropEventArg.h b/src/ui/inc/FUi_DragDropEventArg.h new file mode 100644 index 0000000..e76476f --- /dev/null +++ b/src/ui/inc/FUi_DragDropEventArg.h @@ -0,0 +1,140 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_DragDropEventArg.h +* @brief This is the header file for _DragDropEventArg class. +* @since 2.0 +* +* This header file contains declarations of _DragDropEventArg class. +*/ + +#ifndef _FUI_DRAG_DROP_EVENT_ARG_H_ +#define _FUI_DRAG_DROP_EVENT_ARG_H_ + +// includes +#include +#include +#include +#include +#include +#include "FUi_DragDropEvent.h" + + +namespace Tizen { namespace Ui +{ +/** + * @class _DragDropEventArg + * + * @brief This class is used as the argument to drag drop event listener. + * + * This class is used as the argument of drag drop event listener. When drag drop event event is generated, + * the @c DragDropEvent instance calls the registered IDragDropEventListener with an instance of this + * class as the argument. + * + */ +class _OSP_EXPORT_ _DragDropEventArg + : public Tizen::Base::Object + , public Tizen::Base::Runtime::IEventArg +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] source - A pointer to the Object instance which contains this instance. + * @param[in] status - DragDropStatus + */ + _DragDropEventArg(const Tizen::Ui::Control& source, DragDropStatus status); + + + /** + * This is the class destructor. + */ + virtual ~_DragDropEventArg(void); + +// Access +public: + /** + * This method returns the object which the event initially occurred. + * + * @return The object which the event initially occurred. + */ + const Tizen::Ui::Control* GetSource(void) const; + + /** + * This method returns the touch status + * + * @return see the above + */ + DragDropStatus GetDragDropStatus(void) const; + + /** + * This method returns the start position of touch pressed event on the window rectangle coordination. + * + * @return see the above + */ + const Tizen::Graphics::Point GetStartPosition(void) const; + + /** + * This method returns the current position of touch event on the window rectangle coordination. + * + * @return see the above + */ + const Tizen::Graphics::Point GetCurrentPosition(void) const; + + /** + * This method sets the dragged controls pointer. + * + * @return see the above + */ + + result SetDraggedControl(const Tizen::Ui::Control* pDraggedControl); + + /** + * This method returns the dragged controls pointer. + * + * @return see the above + */ + const Tizen::Ui::Control* GetDraggedControl(void) const; + + /** + * This method sets the positions of touch event on the window rectangle coordination. + * + * @param[in] startX - x coordinate of the original touch pressed event + * @param[in] startY - y coordinate of the original touch pressed event + * @param[in] currentX - x coordinate of the current touch event + * @param[in] currentY - y coordinate of the currenttouch event + * @return The method returns error code. + * @exception E_SUCCESS - This method is successful. + */ + result SetTouchPosition(int startX, int startY, int currentX, int currentY); + + +// Attributes +private: + Tizen::Ui::Control* __pSource; // destination + Tizen::Ui::Control* __pDraggedControl; + + + DragDropStatus __dragDropStatus; + Tizen::Graphics::Point __startPosition; + Tizen::Graphics::Point __currentPosition; +}; // _DragDropEventArg + +} } // Tizen::Ui + +#endif // _FUI_DRAG_DROP_EVENT_ARG_H_ diff --git a/src/ui/inc/FUi_EcoreEvas.h b/src/ui/inc/FUi_EcoreEvas.h new file mode 100644 index 0000000..881a000 --- /dev/null +++ b/src/ui/inc/FUi_EcoreEvas.h @@ -0,0 +1,253 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_EcoreEvas.h + * @brief This is the header file for the _EcoreEvas class. + * + * This header file contains the declarations of the %_EcoreEvas class. + */ +#ifndef _FUI_INTERNAL_ECORE_EVAS_H_ +#define _FUI_INTERNAL_ECORE_EVAS_H_ + +#include +#include +#include +#include +#include +#include "FUi_Types.h" + +namespace Tizen { namespace App +{ +class _IActiveWindowEventListener; +}} // Tizen::App + +namespace Tizen { namespace Graphics +{ +class Rectangle; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Animations +{ +class _RootVisualElement; +class _NativeLayer; +class _EflLayer; +}}} // Tizen::Ui::Animations + + +namespace Tizen { namespace Ui +{ +enum _ClipFormat +{ + _CLIP_FORMAT_TARGETS = -1, + _CLIP_FORMAT_NONE = 0x00, + _CLIP_FORMAT_TEXT = 0x01, + _CLIP_FORMAT_MARKUP = 0x02, + _CLIP_FORMAT_IMAGE = 0x04, + _CLIP_FORMAT_VCARD = 0x08, + _CLIP_FORMAT_HTML = 0x10, +}; + +enum _IndicatorOpacity +{ + _INDICATOR_OPACITY_UNKNOWN, + _INDICATOR_OPACITY_OPAQUE, + _INDICATOR_OPACITY_TRANSLUCENT, + _INDICATOR_OPACITY_TRANSPARENT, +}; + +enum _WindowLevel +{ + _WINDOW_LEVEL_UNKNOWN, + _WINDOW_LEVEL_NORMAL, + _WINDOW_LEVEL_NOTIFICATION_MIDDLE, + _WINDOW_LEVEL_NOTIFICATION_HIGH, +}; + +enum _RenderBackend +{ + _RENDER_BACKEND_DEFAULT, + _RENDER_BACKEND_SW, + _RENDER_BACKEND_GL, +}; + +class _Control; +class _Window; +class _ActiveWindowEvent; + +class _OSP_EXPORT_ _EcoreEvas + : public Tizen::Base::Object +{ +public: + static _EcoreEvas* CreateInstanceN(void); + + virtual ~_EcoreEvas(void); + + void RotateWindow(int orientation); + void RotateWindow(const _Window& window, int orientation); + + bool GetFloatingMode(void) const; + bool GetFloatingMode(const _Window& window) const; + + void AddActiveWindowEventListener(const Tizen::App::_IActiveWindowEventListener& listener); + void RemoveActiveWindowEventListener(const Tizen::App::_IActiveWindowEventListener& listener); + void FireActiveWindowEvent(unsigned int xid, int pid, char* pAppName); + unsigned int GetActiveWindow(void); + + int GetProcessId(unsigned int window); + void SetOwner(NativeWindowHandle ownee, NativeWindowHandle owner); + void ActivateWindow(const _Window& window); + + void SetRenderBackend(_RenderBackend backend); + _RenderBackend GetRenderBackend(void); + +#if !defined(MULTI_WINDOW) + result CopyClip(_ClipFormat format, const char* pChar); + bool RetrieveClipN(int index, int* format, char** pData); + int GetClipCount(void) const; + void OpenClipboard(unsigned long clipFormats); + void CloseClipboard(void); + bool IsClipboardOpened(void); + + result SetEventPropagation(const _Control& control, bool enable); + result SetFocus(const _Control& control, bool focus); + + result SetIndicatorShowState(bool showState); + bool GetIndicatorShowState(void) const; + Tizen::Graphics::Rectangle GetIndicatorBounds(void) const; + result SetIndicatorOpacity(_IndicatorOpacity opacity); + _IndicatorOpacity GetIndicatorOpacity(void) const; + + result SetFloatingMode(bool enable); + + void SetFrame(const _Control& control); + const _Control* GetFrame(void) const; + + void SetWindowLevel(_WindowLevel level); + _WindowLevel GetWindowLevel(void) const; + + void SetWindowAlwaysOnTop(bool alwaysOnTop); + void SetWindowAlwaysAtBottom(bool alwaysAtBottom); + + void BringWindowToTop(void); + void BringWindowToBottom(void); + + + void SetWindowBounds(const Tizen::Graphics::Rectangle& bounds); + void SetWindowVisibleState(bool visibleState); + + Evas* GetEvas(void) const; + Ecore_Evas* GetEcoreEvas(void) const; + Evas_Object* GetWindowObject(void) const; + Ecore_X_Window GetXWindow(void) const; + + Tizen::Ui::Animations::_RootVisualElement* GetRootVisualElement(void)const; + + void AllowSetWindowBounds(bool allow); +#else + result CopyClip(_ClipFormat format, const char* pChar); + bool RetrieveClipN(int index, int* format, char** pData); + int GetClipCount(void) const; + void OpenClipboard(unsigned long clipFormats); + void CloseClipboard(void); + bool IsClipboardOpened(void); + + result SetEventPropagation(const _Control& control, bool enable); + result SetFocus(const _Control& control, bool focus); + + result SetIndicatorShowState(const _Window& window, bool showState); + bool GetIndicatorShowState(const _Window& window) const; + Tizen::Graphics::Rectangle GetIndicatorBounds(const _Window& window) const; + result SetIndicatorOpacity(const _Window& window, _IndicatorOpacity opacity); + _IndicatorOpacity GetIndicatorOpacity(const _Window& window) const; + + void SetWindowActivationEnabled(const _Window& window, bool enable); + bool IsWindowActivationEnabled(const _Window& window); + + result SetFloatingMode(const _Window& window, bool enable); + + void SetFrame(const _Control& control); + const _Control* GetFrame(void) const; + + void SetWindowLevel(const _Window& window, _WindowLevel level); + _WindowLevel GetWindowLevel(const _Window& window) const; + + void SetWindowBounds(const _Window& window, const Tizen::Graphics::Rectangle& bounds); + void SetWindowVisibleState(const _Window& window, bool visibleState); + + void SetOwner(const _Window& ownee, const _Control& owner); + + int GetWindowRotation(const _Window& window); + + Evas* GetEvas(void) const; + Ecore_Evas* GetEcoreEvas(void) const; + Evas_Object* GetWindowObject(void) const; + Ecore_X_Window GetXWindow(void) const; + + Tizen::Ui::Animations::_RootVisualElement* GetRootVisualElement(void)const; + + void AllowSetWindowBounds(bool allow); +#endif + + bool GetSelectedCbhmItem(Ecore_X_Atom* pDataType, char** pBuffer) const; + + //[Accessibility] + bool IsAccessibilityScreenReaderActivated(void); + +private: + result CreateWindow(void); + + result InitializeAtomList(void); + bool IsValidClipFormat(_ClipFormat clipFormat); + Ecore_X_Window GetCbhmWindow(void) const; + bool SendCbhmMessage(Ecore_X_Window xwin, const char* pMsg); + bool SetCbhmItem(Ecore_X_Window xwin, Ecore_X_Atom dataType, char* pItemData); + void* GetCbhmReply(Ecore_X_Window xwin, Ecore_X_Atom property, Ecore_X_Atom* pDataType, int* pNum) const; + int GetCbhmItemCount(void) const; + bool GetCbhmItem(int index, Ecore_X_Atom* pDataType, char** pBuffer) const; + + Tizen::Ui::Animations::_EflLayer* GetEflLayer(const _Window& window) const; + + _EcoreEvas(void); + _EcoreEvas(const _EcoreEvas& rhs); + _EcoreEvas& operator =(const _EcoreEvas& rhs); + +private: + Evas* __pEvas; + Evas_Object* __pForegroundWindow; + const _Control* __pFrame; + + Ecore_Event_Handler* __pXWindowVisibility; + Ecore_Event_Handler* __pClientMessageHandler; + + Ecore_Event_Handler* __pClearClip; + Ecore_Event_Handler* __pNotifyClip; + Ecore_Event_Handler* __pClipboardClosed; + + Ecore_Event_Handler* __pWindowPropertyChanged; + _ActiveWindowEvent* __pActiveWindowEvent; + int __count; + + Tizen::Ui::Animations::_RootVisualElement* __pRootVE; + Tizen::Ui::Animations::_NativeLayer* __pLayer; + + bool __changeBounds; + bool __openClipboard; +}; // _EcoreEvas + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_ECORE_EVAS_H_ diff --git a/src/ui/inc/FUi_EcoreEvasMgr.h b/src/ui/inc/FUi_EcoreEvasMgr.h new file mode 100644 index 0000000..e5145d7 --- /dev/null +++ b/src/ui/inc/FUi_EcoreEvasMgr.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_EcoreEvasMgr.h + * @brief This is the header file for the _EcoreEvasMgr class. + * + * This header file contains the declarations of the %_EcoreEvasMgr class. + */ +#ifndef _FUI_INTERNAL_ECORE_EVAS_MGR_H_ +#define _FUI_INTERNAL_ECORE_EVAS_MGR_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class _EcoreEvas; + +class _OSP_EXPORT_ _EcoreEvasMgr + : public Tizen::Base::Object +{ +public: + _EcoreEvasMgr(void); + + virtual ~_EcoreEvasMgr(void); + + void SetEcoreEvas(const _EcoreEvas& ecoreEvas); + _EcoreEvas* GetEcoreEvas(void) const; + + void BeginMainLoop(void); + void EndMainLoop(void); + + void SetRenderBackend(int backend); + int GetRenderBackend(void); + +private: + _EcoreEvasMgr(const _EcoreEvasMgr& rhs); + _EcoreEvasMgr& operator =(const _EcoreEvasMgr& rhs); + +private: + const _EcoreEvas* __pEcoreEvas; +}; // _EcoreEvasMgr + +_OSP_EXPORT_ void DestroyEcoreEvasMgr(void); +_OSP_EXPORT_ _EcoreEvasMgr* GetEcoreEvasMgr(void); + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_ECORE_EVAS_MGR_H_ diff --git a/src/ui/inc/FUi_ErrorMessages.h b/src/ui/inc/FUi_ErrorMessages.h new file mode 100644 index 0000000..bafdd55 --- /dev/null +++ b/src/ui/inc/FUi_ErrorMessages.h @@ -0,0 +1,32 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_INTERNAL_ERROR_MESSAGES_H_ +#define _FUI_INTERNAL_ERROR_MESSAGES_H_ + +namespace Tizen { namespace Ui { + +class _UiError +{ +public: + static const char* OUT_OF_MEMORY; + static const char* SYSTEM; +}; + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_ERROR_MESSAGES_H_ diff --git a/src/ui/inc/FUi_FingerInfo.h b/src/ui/inc/FUi_FingerInfo.h new file mode 100644 index 0000000..99072da --- /dev/null +++ b/src/ui/inc/FUi_FingerInfo.h @@ -0,0 +1,161 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_FingerInfo.h + * @brief This is the header file for the _FingerInfo class. + * + * This header file contains the declarations of the _FingerInfo class. @n + */ + +#ifndef _FUI_INTERNAL_FINGER_INFO_H +#define _FUI_INTERNAL_FINGER_INFO_H + +#include +#include "FUi_UiTouchEvent.h" + +namespace Tizen { namespace Ui +{ +const unsigned int INVALID_POINT_ID = 999; +const unsigned int SINGLE_POINT_ID = 0; + +class _OSP_EXPORT_ _FingerInfo +{ +public: + /** + * This is the default class constructor. + * + */ + _FingerInfo(void); + + /** + * This is the default class destructor. + * + */ + ~_FingerInfo(void); + +public: + /** + * This method sets device Id + * + * @since 2.0 + */ + void SetDeviceId(unsigned long deviceId); + + /** + * This method sets point Id + * + * @since 2.0 + */ + void SetPointId(unsigned long pointId); + + /** + * This method sets current point + * + * @since 2.0 + */ + void SetPoint(const Tizen::Graphics::Point& screenPoint, const Tizen::Graphics::Point& point); + + /** + * This method sets current status + * + * @since 2.0 + */ + void SetStatus(const _TouchStatus status); + + /** + * This method sets start point + * + * @since 2.0 + */ + void SetStartPoint(const Tizen::Graphics::Point& point); + + /** + * This method sets touch move allowance flag + * this flag is used to check move allowance + * + * @since 2.0 + */ + void SetMoveReady(bool moveReady); + + /** + * This method returns deviceId + * + * @since 2.0 + * @return The deviceId + */ + unsigned long GetDeviceId(void) const; + + /** + * This method returns converted pointId + * + * @since 2.0 + * @return The touch pointId + */ + unsigned long GetPointId(void) const; + + /** + * This method returns touch point + * + * @since 2.0 + * @return The touch point + */ + Tizen::Graphics::Point GetPoint(void) const; + + /** + * This method returns touch point + * + * @since 2.0 + * @return The touch point + */ + Tizen::Graphics::Point GetScreenPoint(void) const; + + /** + * This method returns current touch status + * + * @since 2.0 + * @return The touch status + */ + _TouchStatus GetStatus(void) const; + + /** + * This method returns touch start point + * + * @since 2.0 + * @return The touch start point + */ + Tizen::Graphics::Point GetStartPoint(void) const; + + /** + * This method returns touch move allowance + * + * @since 2.0 + * @return The touch move allowance + */ + bool GetMoveReady(void) const; + +private: + unsigned long __deviceId; + unsigned long __pointId; + _TouchStatus __status; + Tizen::Graphics::Point __point; + Tizen::Graphics::Point __startPoint; + Tizen::Graphics::Point __screenPoint; + bool __touchMoveReady; +}; // _FingerInfo +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_FINGER_INFO_H diff --git a/src/ui/inc/FUi_FocusManagerImpl.h b/src/ui/inc/FUi_FocusManagerImpl.h new file mode 100644 index 0000000..330faee --- /dev/null +++ b/src/ui/inc/FUi_FocusManagerImpl.h @@ -0,0 +1,108 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_FocusManagerImpl.h + * @brief This is the header file for the _FocusManagerImpl class. + * + * This header file contains the declarations of the _FocusManagerImpl class. @n. + */ +#ifndef _FUI_INTERNAL_FOCUS_MANAGER_IMPL_H_ +#define _FUI_INTERNAL_FOCUS_MANAGER_IMPL_H_ + +// Includes +#include + +namespace Tizen { namespace Ui +{ + +class _ControlImpl; +class _WindowImpl; + + +/** + * @class FocusManager + * @brief This class manages the application's current focus owned by the UI control + * and its ancestor Window. + * @since 2.0 + * + * Use this class to query the application's current focus owner. + */ +class _FocusManagerImpl + : public Tizen::Base::Object +{ +public: + /** + * Returns the pointer to the current focus manager. + * + * @since 2.0 + * @return The current focus manager instance + */ + static _FocusManagerImpl* GetInstance(void); + + + /** + * Gets the current focus owner. + * + * @since 2.0 + * @return The current focus owner + * @remarks The method returns the current focus owner of this application. + */ + _ControlImpl* GetCurrentFocusOwner(void) const; + + + /** + * Gets the current focused Window. + * + * @since 2.0 + * @return The current focused Window + * @remarks The method returns the application's current focus owner's ancestor + * Window or Window that is currently focused. + */ + _WindowImpl* GetCurrentFocusedWindow(void) const; + + static void Initialize(void); + + static void ReleaseInstance(void); + +private: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _FocusManagerImpl(void); + + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_FocusManagerImpl(void); + + _FocusManagerImpl(_FocusManagerImpl& rhs); + _FocusManagerImpl& operator=(_FocusManagerImpl& rhs); + + static void InitializeInstance(void); + +private: + static _FocusManagerImpl* __pInstance; +}; // _FocusManagerImpl + +}}//Tizen::Ui + +#endif // _FUI_INTERNAL_FOCUS_MANAGER_IMPL_H_ diff --git a/src/ui/inc/FUi_IAccessibilityListener.h b/src/ui/inc/FUi_IAccessibilityListener.h new file mode 100644 index 0000000..045a62e --- /dev/null +++ b/src/ui/inc/FUi_IAccessibilityListener.h @@ -0,0 +1,48 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_IAccessibilityListener.h + * @brief This is the header file for the _AccessibilityContainer class. + * + * This header file contains the declarations of the _AccessibilityContainer class. + * + */ +#ifndef _FUI_INTERNAL_IACCESSIBILITY_DELEGATE_H_ +#define _FUI_INTERNAL_IACCESSIBILITY_DELEGATE_H_ + +namespace Tizen { namespace Ui { + +class _AccessibilityContainer; +class _AccessibilityElement; + +class _IAccessibilityListener +{ +public: + virtual ~_IAccessibilityListener(void){}; + + virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element) = 0; + virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element) = 0; + virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element) = 0; + virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element) = 0; + virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element) = 0; + virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element) = 0; + virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) = 0; + virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element) = 0; +}; +}} + +#endif //_FUI_INTERNAL_IACCESSIBILITY_DELEGATE_H_ diff --git a/src/ui/inc/FUi_IFocusEventListener.h b/src/ui/inc/FUi_IFocusEventListener.h new file mode 100644 index 0000000..599d7a1 --- /dev/null +++ b/src/ui/inc/FUi_IFocusEventListener.h @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_IFocusEventListener.h + * @brief This is the header file for the _IFocusEventListener class. + * + * This header file contains the declarations of the %_IFocusEventListener class. + */ + +#ifndef _FUI_INTERNAL_IFOCUS_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_IFOCUS_EVENT_LISTENER_H_ + +#include "FUi_IUiEventListener.h" + +namespace Tizen { namespace Ui +{ + +class _Control; + +/** + * @interface _IFocusEventListener + * @brief This interface is used as the argument to focus the event listener. + * @since 2.0 + * + * The listener interface for receiving focus events. The class that processes a focus event + * implements this interface, and the instance created with that class is registered with a UI control, using the control's + * AddFocusEventListener() method. When the focus event occurs, the OnFocusGained() or OnFocusLost() method of that instance is invoked. + */ +class _IFocusEventListener + : virtual public _IUiEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This is internal. If used in an application, the application can get rejected during the certification process. + * This is the virtual destructor for this class. + * + * @since 2.0 + */ + virtual ~_IFocusEventListener(void) {} + +// Operation +public: + /** + * Notifies when Control gains the input focus. + * + * @since 2.0 + * @param[in] source The source of the event + */ + virtual bool OnFocusGained(const _Control& source) = 0; + + + /** + * Notifies when Control loses the input focus. + * + * @since 2.0 + * @param[in] source The source of the event + */ + virtual bool OnFocusLost(const _Control& source) = 0; +}; + +}}//Tizen::Ui + +#endif // _FUI_INTERNAL_IFOCUS_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUi_IKeyEventListener.h b/src/ui/inc/FUi_IKeyEventListener.h new file mode 100644 index 0000000..7a03bae --- /dev/null +++ b/src/ui/inc/FUi_IKeyEventListener.h @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_IKeyEventListener.h + * @brief This is the header file for the _IKeyEventListener class. + * + * This header file contains the declarations of the %_IKeyEventListener class. + */ + +#ifndef _FUI_INTERNAL_IKEY_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_IKEY_EVENT_LISTENER_H_ + +#include "FUi_IUiEventListener.h" +#include "FUi_UiKeyEvent.h" + +namespace Tizen {namespace Ui +{ + +class _Control; + +/** + * @interface _IKeyEventListener + * @brief This interface implements the listener for the key event. + * @since 2.0 + * + * @remarks A key event callback is called when key codes corresponding to the physical keys are + * pressed or released. ITextEventListener can be used to get the text value of the key in EditField and EditArea. + * + * The listener interface for receiving key events. The class that + * processes a key event implements this interface, and the instance created with + * that class is registered with a UI control, using the control's AddKeyEventListener() + * method. When the key event occurs, the OnKeyPressed(), OnKeyReleased(), or + * OnKeyLongPressed() method of that instance is invoked. @n + * + * Only the current focus owner can listen to key events. Use the control's SetFocus() + * method to give the input focus to a UI control. + * + */ +class _IKeyEventListener + : virtual public _IUiEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is internal. If used in an application, the application can get rejected during the certification process. + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_IKeyEventListener(void) {} + + /** + * Notifies when a key is pressed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] keyCode The key code + */ + virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) = 0; + + /** + * Notifies when a key is released. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] keyCode The key code + */ + virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo) = 0; +}; // _IKeyEventListener + +}} // Tizen::Ui + +#endif //_FUI_INTERNAL_IKEY_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUi_IKeyEventPreviewer.h b/src/ui/inc/FUi_IKeyEventPreviewer.h new file mode 100644 index 0000000..4f17158 --- /dev/null +++ b/src/ui/inc/FUi_IKeyEventPreviewer.h @@ -0,0 +1,90 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_IKeyEventPreviewer.h + * @brief This is the header file for the _IKeyEventPreviewer class. + * + * This header file contains the declarations of the %_IKeyEventListener class. + */ + +#ifndef _FUI_INTERNAL_IKEY_EVENT_PREVIEWER_H_ +#define _FUI_INTERNAL_IKEY_EVENT_PREVIEWER_H_ + +#include "FUi_IUiEventListener.h" +#include "FUi_UiKeyEvent.h" + +namespace Tizen {namespace Ui +{ + +class _Control; + +/** + * @interface _IKeyEventPreviewer + * @brief This interface implements the listener for the key event. + * @since 2.0 + * + * @remarks A key event callback is called when key codes corresponding to the physical keys are + * pressed or released. ITextEventListener can be used to get the text value of the key in EditField and EditArea. + * + * The listener interface for receiving key events. The class that + * processes a key event implements this interface, and the instance created with + * that class is registered with a UI control, using the control's AddKeyEventListener() + * method. When the key event occurs, the OnKeyPressed(), OnKeyReleased(), or + * OnKeyLongPressed() method of that instance is invoked. @n + * + * Only the current focus owner can listen to key events. Use the control's SetFocus() + * method to give the input focus to a UI control. + * + */ +class _IKeyEventPreviewer + : virtual public _IUiEventPreviewer + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is internal. If used in an application, the application can get rejected during the certification process. + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_IKeyEventPreviewer(void) {} + + + /** + * Notifies when a key is pressed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] keyCode The key code + */ + virtual bool OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo) = 0; + + + /** + * Notifies when a key is released. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] keyCode The key code + */ + virtual bool OnPreviewKeyReleased(const _Control& source, const _KeyInfo& keyInfo) = 0; +}; // _IKeyEventPreviewer + +}} // Tizen::Ui + +#endif //_FUI_INTERNAL_IKEY_EVENT_PREVIEWER_H_ diff --git a/src/ui/inc/FUi_INotificationEventListener.h b/src/ui/inc/FUi_INotificationEventListener.h new file mode 100644 index 0000000..97ec01c --- /dev/null +++ b/src/ui/inc/FUi_INotificationEventListener.h @@ -0,0 +1,58 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_INotificationEventListener.h + * @brief This is the header file for the _INotificationEventListener class. + * + * This header file contains the declarations of the %_INotificationEventListener class. + */ + +#ifndef _FUI_INTERNAL_INOTIFICATION_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_INOTIFICATION_EVENT_LISTENER_H_ + +#include +#include "FUi_IUiEventListener.h" + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +} } } + +namespace Tizen { namespace Ui +{ + +class _Control; + +class _INotificationEventListener + : virtual public _IUiEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_INotificationEventListener(void) {} + + virtual bool OnNotifiedN(const _Control& source, Tizen::Base::Collection::IList* pArgs) = 0; +}; + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_INOTIFICATION_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUi_INotificationEventPreviewer.h b/src/ui/inc/FUi_INotificationEventPreviewer.h new file mode 100644 index 0000000..acbf3ef --- /dev/null +++ b/src/ui/inc/FUi_INotificationEventPreviewer.h @@ -0,0 +1,58 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_INotificationEventPreviewer.h + * @brief This is the header file for the _INotificationEventPreviewer class. + * + * This header file contains the declarations of the %_INotificationEventPreviewer class. + */ + +#ifndef _FUI_INTERNAL_INOTIFICATION_EVENT_PREVIEWER_H_ +#define _FUI_INTERNAL_INOTIFICATION_EVENT_PREVIEWER_H_ + +#include +#include "FUi_IUiEventPreviewer.h" + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +} } } + +namespace Tizen { namespace Ui +{ + +class _Control; + +class _INotificationEventPreviewer + : virtual public _IUiEventPreviewer + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_INotificationEventPreviewer(void) {} + + virtual bool OnPreviewNotifiedN(const _Control& source, Tizen::Base::Collection::IList* pArgs) = 0; +}; + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_INOTIFICATION_EVENT_PREVIEWER_H_ diff --git a/src/ui/inc/FUi_IPropertyChangeEventListener.h b/src/ui/inc/FUi_IPropertyChangeEventListener.h new file mode 100644 index 0000000..4ae5a5b --- /dev/null +++ b/src/ui/inc/FUi_IPropertyChangeEventListener.h @@ -0,0 +1,76 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_IPropertyChangeEventListener.h + * @brief This is the header file for the _IPropertyChangeEventListener interface. + * + * This header file contains the declarations of the _IPropertyChangeEventListener interface. + */ +#ifndef _FUI_INTERNAL_IPROPERTY_CHANGED_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_IPROPERTY_CHANGED_EVENT_LISTENER_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class _PropertyBase; + +/** + * @interface _IPropertyChangeEventListener + * @brief The listener interface for property change event. + * @since 2.0 + */ +class _IPropertyChangeEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_IPropertyChangeEventListener(void) {} + + /** + * Notifies when an entity is touch pressed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] oldValue The old property + * @param[in] newValue The new property + */ + virtual void OnPropertyChanging(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldValue, const Variant& newValue) = 0; + + /** + * Notifies when an entity is touch pressed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] oldValue The old property + * @param[in] newValue The new property + */ + virtual void OnPropertyChanged(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldValue, const Variant& newValue) = 0; +}; // _IPropertyChangeEventListener + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_IPROPERTY_CHANGED_EVENT_LISTENER_H_ + diff --git a/src/ui/inc/FUi_ITouchCustomGestureEventListener.h b/src/ui/inc/FUi_ITouchCustomGestureEventListener.h new file mode 100644 index 0000000..73a98c7 --- /dev/null +++ b/src/ui/inc/FUi_ITouchCustomGestureEventListener.h @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_ITouchCustomGestureEventListener.h +* @brief This is the header file for the %_ITouchCustomGestureEventListener interface. +* +* This header file contains the declarations of the %_ITouchCustomGestureEventListener interface. +*/ +#ifndef _FUI_INTERNAL_ITOUCH_CUSTOM_GESTURE_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_ITOUCH_CUSTOM_GESTURE_EVENT_LISTENER_H_ + +#include "FUi_ITouchGestureEventListener.h" + +namespace Tizen { namespace Ui +{ + +/** + * @interface _ITouchCustomGestureEventListener + * @brief This interface is used as the argument to the gesture custom event listener. + * @since 2.0 + * + * The listener interface for receiving gesture events. The class that processes a custom gesture event + * implements this interface, and the instance created with that class is registered with a UI controls, using the gesture's + * AddGestureEventListener() method. When the gesture is recognized, OnGestureTapRecognized method of that instance is invoked. + */ +class _ITouchCustomGestureEventListener + : virtual public _ITouchGestureEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ITouchCustomGestureEventListener(void) {} + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnCustomGestureStarted(_TouchGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnCustomGestureChanged(_TouchGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnCustomGestureFinished(_TouchGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnCustomGestureCanceled(_TouchGestureDetector& gesture) = 0; +}; // _ITouchCustomGestureEventListener + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_ITOUCH_CUSTOM_GESTURE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUi_ITouchEventListener.h b/src/ui/inc/FUi_ITouchEventListener.h new file mode 100644 index 0000000..1e29c14 --- /dev/null +++ b/src/ui/inc/FUi_ITouchEventListener.h @@ -0,0 +1,102 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ITouchEventListener.h + * @brief This is the header file for the _ITouchEventListener class. + * + * This header file contains the declarations of the %_ITouchEventListener class. + */ + +#ifndef _FUI_INTERNAL_ITOUCH_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_ITOUCH_EVENT_LISTENER_H_ + +#include +#include +#include "FUi_IUiEventListener.h" + +namespace Tizen { namespace Ui +{ + +class _Control; +class _TouchInfo; + +/** + * @interface _ITouchEventListener + * @brief This interface is used as the argument to the touch event listener. + * @since 2.0 + * + * The listener interface for receiving touch events. The class that processes a touch event + * implements this interface, and the instance created with that class is registered with a UI control, using the control's + * AddTouchEventListener() method. When the touch event occurs, the OnTouchDoublePressed(), OnTouchFocusIn(), OnTouchFocusOut(), OnTouchLongPressed(), OnTouchLongPressed(), OnTouchMoved(), OnTouchPressed(), or OnTouchReleased() method of that instance is invoked. + */ +class _ITouchEventListener + : virtual public _IUiEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ITouchEventListener(void) {} + + /** + * Notifies when an entity is touch pressed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) = 0; + + /** + * Notifies when an entity is touch released. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo) = 0; + + /** + * Notifies when an entity is touch moved. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo) = 0; + + /** + * Notifies when an entity is touch cancelled. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) = 0; +}; // _ITouchEventListener + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_ITOUCH_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUi_ITouchEventPreviewer.h b/src/ui/inc/FUi_ITouchEventPreviewer.h new file mode 100644 index 0000000..c796dc8 --- /dev/null +++ b/src/ui/inc/FUi_ITouchEventPreviewer.h @@ -0,0 +1,103 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ITouchEventPreviewer.h + * @brief This is the header file for the _ITouchEventPreviewer class. + * + * This header file contains the declarations of the %_ITouchEventPreviewer class. + */ + +#ifndef _FUI_INTERNAL_ITOUCH_EVENT_PREVIEWER_H_ +#define _FUI_INTERNAL_ITOUCH_EVENT_PREVIEWER_H_ + +#include +#include +#include "FUi_IUiEventPreviewer.h" +#include "FUi_UiEventTypes.h" + +namespace Tizen { namespace Ui +{ + +class _Control; +class _TouchInfo; + +/** + * @interface _ITouchEventPreviewer + * @brief This interface is used as the argument to the touch event listener. + * @since 2.0 + * + * The listener interface for receiving touch events. The class that processes a touch event + * implements this interface, and the instance created with that class is registered with a UI control, using the control's + * AddTouchEventListener() method. When the touch event occurs, the OnTouchDoublePressed(), OnTouchFocusIn(), OnTouchFocusOut(), OnTouchLongPressed(), OnTouchLongPressed(), OnTouchMoved(), OnTouchPressed(), or OnTouchReleased() method of that instance is invoked. + */ +class _ITouchEventPreviewer + : virtual public _IUiEventPreviewer + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ITouchEventPreviewer(void) {} + + /** + * Notifies when an entity is touch pressed. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo) = 0; + + /** + * Notifies when an entity is touch released. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo) = 0; + + /** + * Notifies when an entity is touch moved. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo) = 0; + + /** + * Notifies when an entity is touch cancelled. + * + * @since 2.0 + * @param[in] source The source of the event + * @param[in] currentPosition The current position + * @param[in] touchInfo The touch event information + */ + virtual _UiTouchEventDelivery OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo) = 0; +}; // _ITouchEventPreviewer + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_ITOUCH_EVENT_PREVIEWER_H_ diff --git a/src/ui/inc/FUi_ITouchFlickGestureEventListener.h b/src/ui/inc/FUi_ITouchFlickGestureEventListener.h new file mode 100644 index 0000000..cd90ea6 --- /dev/null +++ b/src/ui/inc/FUi_ITouchFlickGestureEventListener.h @@ -0,0 +1,70 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_ITouchFlickGestureEventListener.h +* @brief This is the header file for the %_ITouchFlickGestureEventListener interface. +* +* This header file contains the declarations of the %_ITouchFlickGestureEventListener interface. +*/ +#ifndef _FUI_INTERNAL_ITOUCH_FLICK_GESTURE_EVENT_LISTENER_H +#define _FUI_INTERNAL_ITOUCH_FLICK_GESTURE_EVENT_LISTENER_H + +#include "FUi_ITouchGestureEventListener.h" +#include "FUi_TouchFlickGestureDetector.h" + +namespace Tizen { namespace Ui +{ +/** + * @interface _ITouchFlickGestureEventListener + * @brief This interface is used as the argument to the flick gesture event listener. + * @since 2.0 + * + * The listener interface for receiving gesture events. The class that processes a flick gesture event + * implements this interface, and the instance created with that class is registered with a UI controls, using the gesture's + * AddGestureEventListener() method. When the gesture is recognized, OnGestureTapRecognized method of that instance is invoked. + */ +class _ITouchFlickGestureEventListener + : virtual public _ITouchGestureEventListener +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ITouchFlickGestureEventListener(void) {} + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture recognition is canceled. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture) = 0; +}; // _ITouchFlickGestureEventListener + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_ITOUCH_FLICK_GESTURE_EVENT_LISTENER_H diff --git a/src/ui/inc/FUi_ITouchGestureDelegate.h b/src/ui/inc/FUi_ITouchGestureDelegate.h new file mode 100644 index 0000000..4abe6b4 --- /dev/null +++ b/src/ui/inc/FUi_ITouchGestureDelegate.h @@ -0,0 +1,50 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_ITouchGestureDelegate.h +* @brief This is the header file for the %_ITouchGestureDelegate interface. +* +* This header file contains the declarations of the %_ITouchGestureDelegate interface. +*/ +#ifndef _FUI_INTERNAL_ITOUCH_GESTURE_DELEGATE_H_ +#define _FUI_INTERNAL_ITOUCH_GESTURE_DELEGATE_H_ + +#include "FUi_ITouchEventListener.h" + +namespace Tizen { namespace Ui +{ +/** + * @interface _IGestureDelegator + * @since 2.0 + * + */ +class _ITouchGestureDelegate + : virtual public _ITouchEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ITouchGestureDelegate(void) {} +}; // _ITouchGestureDelegate + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_ITOUCH_GESTURE_DELEGATE_H_ diff --git a/src/ui/inc/FUi_ITouchGestureEventListener.h b/src/ui/inc/FUi_ITouchGestureEventListener.h new file mode 100644 index 0000000..00b8e71 --- /dev/null +++ b/src/ui/inc/FUi_ITouchGestureEventListener.h @@ -0,0 +1,51 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_ITouchGestureEventListener.h +* @brief This is the header file for the %_ITouchGestureEventListener interface. +* +* This header file contains the declarations of the %_ITouchGestureEventListener interface. +*/ +#ifndef _FUI_INTERNAL_ITOUCH_GESTURE_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_ITOUCH_GESTURE_EVENT_LISTENER_H_ + +#include "FUi_IUiEventListener.h" + +namespace Tizen { namespace Ui +{ +/** + * @interface _ITouchGestureEventListener + * @brief This interface is used as the argument to the base gesture event listener. + * @since 2.0 + * + */ +class _ITouchGestureEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ITouchGestureEventListener(void) {} +}; // _ITouchGestureEventListener + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_ITOUCH_GESTURE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUi_ITouchGestureStateChangedListener.h b/src/ui/inc/FUi_ITouchGestureStateChangedListener.h new file mode 100644 index 0000000..adb4fe7 --- /dev/null +++ b/src/ui/inc/FUi_ITouchGestureStateChangedListener.h @@ -0,0 +1,55 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_ITouchGestureStateChangedListener.h +* @brief This is the header file for the %_ITouchGestureStateChangedListener interface. +* +* This header file contains the declarations of the %_ITouchGestureStateChangedListener interface. +*/ +#ifndef _FUI_INTERNAL_ITOUCH_GESTURE_STATE_CHANGED_LISTENER_H_ +#define _FUI_INTERNAL_ITOUCH_GESTURE_STATE_CHANGED_LISTENER_H_ + +#include "FUi_IUiEventListener.h" + +namespace Tizen { namespace Ui +{ +class _TouchGestureDetector; + +/** + * @interface _ITouchGestureStateChangedListener + * @since 2.0 + * + */ +class _ITouchGestureStateChangedListener + : virtual public _IUiEventListener + , virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ITouchGestureStateChangedListener(void) {} + + virtual void OnGestureDetectorStateChanged(const _TouchGestureDetector& gestureDetector) = 0; +}; // _ITouchGestureStateChangedListener + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_ITOUCH_GESTURE_STATE_CHANGED_LISTENER_H_ diff --git a/src/ui/inc/FUi_ITouchLongPressGestureEventListener.h b/src/ui/inc/FUi_ITouchLongPressGestureEventListener.h new file mode 100644 index 0000000..b721f75 --- /dev/null +++ b/src/ui/inc/FUi_ITouchLongPressGestureEventListener.h @@ -0,0 +1,72 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_ITouchLongPressGestureEventListener.h +* @brief This is the header file for the %_ITouchLongPressGestureEventListener interface. +* +* This header file contains the declarations of the %_ITouchLongPressGestureEventListener interface. +*/ +#ifndef _FUI_INTERNAL_ITOUCH_LONG_PRESS_GESTURE_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_ITOUCH_LONG_PRESS_GESTURE_EVENT_LISTENER_H_ + +#include "FUi_ITouchGestureEventListener.h" +#include "FUi_TouchLongPressGestureDetector.h" + +namespace Tizen { namespace Ui +{ + +/** + * @interface _ITouchLongPressGestureEventListener + * @brief This interface is used as the argument to the long press gesture event listener. + * @since 2.0 + * + * The listener interface for receiving gesture events. The class that processes a long press gesture event + * implements this interface, and the instance created with that class is registered with a UI controls, using the gesture's + * AddGestureEventListener() method. When the gesture is recognized, OnGestureTapRecognized method of that instance is invoked. + */ +class _ITouchLongPressGestureEventListener + : virtual public _ITouchGestureEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ITouchLongPressGestureEventListener(void) {} + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture recognition is canceled. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture) = 0; +}; // _ITouchLongPressGestureEventListener + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_ITOUCH_LONG_PRESS_GESTURE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUi_ITouchPanningGestureEventListener.h b/src/ui/inc/FUi_ITouchPanningGestureEventListener.h new file mode 100644 index 0000000..9bef0e1 --- /dev/null +++ b/src/ui/inc/FUi_ITouchPanningGestureEventListener.h @@ -0,0 +1,83 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_ITouchPanningGestureEventListener.h +* @brief This is the header file for the %_ITouchPanningGestureEventListener interface. +* +* This header file contains the declarations of the %_ITouchPanningGestureEventListener interface. +*/ +#ifndef _FUI_INTERNAL_ITOUCH_PANNING_GESTURE_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_ITOUCH_PANNING_GESTURE_EVENT_LISTENER_H_ + +#include "FUi_ITouchGestureEventListener.h" +#include "FUi_TouchPanningGestureDetector.h" + +namespace Tizen { namespace Ui +{ + +/** + * @interface _ITouchPanningGestureEventListener + * @brief This interface is used as the argument to the panning gesture event listener. + * @since 2.0 + * + * The listener interface for receiving gesture events. The class that processes a panning gesture event + * implements this interface, and the instance created with that class is registered with a UI controls, using the gesture's + * AddGestureEventListener() method. When the gesture is recognized, OnGestureTapRecognized method of that instance is invoked. + */ +class _ITouchPanningGestureEventListener + : virtual public _ITouchGestureEventListener +{ +// Operation +public: + virtual ~_ITouchPanningGestureEventListener(void) {} + + /** + * Notifies when the gesture is started to recognition. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnPanningGestureStarted(_TouchPanningGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnPanningGestureChanged(_TouchPanningGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture recognition is finished. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnPanningGestureFinished(_TouchPanningGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture recognition is canceled. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnPanningGestureCanceled(_TouchPanningGestureDetector& gesture) = 0; +}; // _ITouchPanningGestureEventListener + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_ITOUCH_PANNING_GESTURE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUi_ITouchPinchGestureEventListener.h b/src/ui/inc/FUi_ITouchPinchGestureEventListener.h new file mode 100644 index 0000000..f790293 --- /dev/null +++ b/src/ui/inc/FUi_ITouchPinchGestureEventListener.h @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_ITouchPinchGestureEventListener.h +* @brief This is the header file for the %_ITouchPinchGestureEventListener interface. +* +* This header file contains the declarations of the %_ITouchPinchGestureEventListener interface. +*/ +#ifndef _FUI_INTERNAL_ITOUCH_PINCH_GESTURE_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_ITOUCH_PINCH_GESTURE_EVENT_LISTENER_H_ + +#include "FUi_ITouchGestureEventListener.h" +#include "FUi_TouchPinchGestureDetector.h" + +namespace Tizen { namespace Ui +{ + +/** + * @interface _ITouchPinchGestureEventListener + * @brief This interface is used as the argument to the pinch gesture event listener. + * @since 2.0 + * + * The listener interface for receiving gesture events. The class that processes a pinch gesture event + * implements this interface, and the instance created with that class is registered with a UI controls, using the gesture's + * AddGestureEventListener() method. When the gesture is recognized, OnPinchGestureRecognized method of that instance is invoked. + */ +class _ITouchPinchGestureEventListener + : virtual public _ITouchGestureEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ITouchPinchGestureEventListener(void) {} + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnPinchGestureStarted(_TouchPinchGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnPinchGestureChanged(_TouchPinchGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnPinchGestureFinished(_TouchPinchGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnPinchGestureCanceled(_TouchPinchGestureDetector& gesture) = 0; +}; // _ITouchPinchGestureEventListener + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_ITOUCH_PINCH_GESTURE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUi_ITouchRotationGestureEventListener.h b/src/ui/inc/FUi_ITouchRotationGestureEventListener.h new file mode 100644 index 0000000..b608905 --- /dev/null +++ b/src/ui/inc/FUi_ITouchRotationGestureEventListener.h @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_ITouchRotationGestureEventListener.h +* @brief This is the header file for the %_ITouchRotationGestureEventListener interface. +* +* This header file contains the declarations of the %_ITouchRotationGestureEventListener interface. +*/ +#ifndef _FUI_INTERNAL_ITOUCH_ROTATION_GESTURE_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_ITOUCH_ROTATION_GESTURE_EVENT_LISTENER_H_ + +#include "FUi_ITouchGestureEventListener.h" +#include "FUi_TouchRotationGestureDetector.h" + +namespace Tizen { namespace Ui +{ + +/** + * @interface _ITouchRotationGestureEventListener + * @brief This interface is used as the argument to the rotation gesture event listener. + * @since 2.0 + * + * The listener interface for receiving gesture events. The class that processes a rotation gesture event + * implements this interface, and the instance created with that class is registered with a UI controls, using the gesture's + * AddGestureEventListener() method. When the gesture is recognized, OnGestureTapRecognized method of that instance is invoked. + */ +class _ITouchRotationGestureEventListener + : virtual public _ITouchGestureEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ITouchRotationGestureEventListener(void) {} + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnRotationGestureStarted(_TouchRotationGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnRotationGestureChanged(_TouchRotationGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnRotationGestureFinished(_TouchRotationGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnRotationGestureCanceled(_TouchRotationGestureDetector& gesture) = 0; +}; // _ITouchRotationGestureEventListener + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_ITOUCH_ROTATION_GESTURE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUi_ITouchTapGestureEventListener.h b/src/ui/inc/FUi_ITouchTapGestureEventListener.h new file mode 100644 index 0000000..501d790 --- /dev/null +++ b/src/ui/inc/FUi_ITouchTapGestureEventListener.h @@ -0,0 +1,72 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_ITouchTapGestureEventListener.h +* @brief This is the header file for the %_ITouchTapGestureEventListener interface. +* +* This header file contains the declarations of the %_ITouchTapGestureEventListener interface. +*/ +#ifndef _FUI_INTERNAL_ITOUCH_TAP_GESTURE_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_ITOUCH_TAP_GESTURE_EVENT_LISTENER_H_ + +#include "FUi_ITouchGestureEventListener.h" +#include "FUi_TouchTapGestureDetector.h" + +namespace Tizen { namespace Ui +{ + +/** + * @interface _ITouchTapGestureEventListener + * @brief This interface is used as the argument to the tap gesture event listener. + * @since 2.0 + * + * The listener interface for receiving gesture events. The class that processes a tap gesture event + * implements this interface, and the instance created with that class is registered with a UI controls, using the gesture's + * AddGestureEventListener() method. When the gesture is recognized, OnTapGestureDetected method of that instance is invoked. + */ +class _ITouchTapGestureEventListener + : virtual public _ITouchGestureEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_ITouchTapGestureEventListener(void) {} + + /** + * Notifies when the gesture is recognized. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnTapGestureDetected(_TouchTapGestureDetector& gesture) = 0; + + /** + * Notifies when the gesture recognition is canceled. + * + * @since 2.0 + * @param[in] gesture the gesture instance + */ + virtual bool OnTapGestureCanceled(_TouchTapGestureDetector& gesture) = 0; +}; // _ITouchTapGestureEventListener + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_ITOUCH_TAP_GESTURE_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUi_IUiEventListener.h b/src/ui/inc/FUi_IUiEventListener.h new file mode 100644 index 0000000..c004804 --- /dev/null +++ b/src/ui/inc/FUi_IUiEventListener.h @@ -0,0 +1,48 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_IUiEventListener.h + * @brief This is the header file for the _IUiEventListener class. + * + * This header file contains the declarations of the %_IUiEventListener class. + */ + +#ifndef _FUI_INTERNAL_IUI_EVENT_LISTENER_H_ +#define _FUI_INTERNAL_IUI_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +class _IUiEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_IUiEventListener(void) {} +}; + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_IUI_EVENT_LISTENER_H_ diff --git a/src/ui/inc/FUi_IUiEventManager.h b/src/ui/inc/FUi_IUiEventManager.h new file mode 100644 index 0000000..aac21cc --- /dev/null +++ b/src/ui/inc/FUi_IUiEventManager.h @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_IUiEventManager.h + * @brief This is the header file for the _IUiEventManager class. + * + * This header file contains the declarations of the %_IUiEventManager class. + */ + +#ifndef _FUI_INTERNAL_IUI_EVENT_MANAGER_H_ +#define _FUI_INTERNAL_IUI_EVENT_MANAGER_H_ + +#include + +namespace Tizen { namespace Ui +{ + +class _UiEvent; +class _Control; + +/** +* This is internal. If used in an application, the application can get rejected during the certification process. +* @class _IUiEventManager +* @brief This class impliments _IUiEventManager and +* fire the Window Event object of a Ui Control. +*/ +class _IUiEventManager +{ +public: + virtual ~_IUiEventManager(void) {} + +public: + virtual result RegisterKeyEventHandler(const _Control& control) = 0; + virtual result RegisterTouchEventHandler(const _Control& control) = 0; + virtual result UnregisterKeyEventHandler(const _Control& control) = 0; + virtual result UnregisterTouchEventHandler(const _Control& control) = 0; + virtual result PostEvent(const _UiEvent& event) = 0; + + virtual void SetKeyCapture(const _Control& control, _KeyCode keyCode) = 0; + virtual void ReleaseKeyCapture(const _Control& control, _KeyCode keyCode) = 0; +}; // _IUiEventManager + +}} // Tizen::Ui + +#endif //_FUI_INTERNAL_IUI_EVENT_MANAGER_H_ diff --git a/src/ui/inc/FUi_IUiEventPreviewer.h b/src/ui/inc/FUi_IUiEventPreviewer.h new file mode 100644 index 0000000..38c6f91 --- /dev/null +++ b/src/ui/inc/FUi_IUiEventPreviewer.h @@ -0,0 +1,48 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_IUiEventPreviewer.h + * @brief This is the header file for the _IUiEventPreviewer class. + * + * This header file contains the declarations of the %_IUiEventPreviewer class. + */ + +#ifndef _FUI_INTERNAL_IUI_EVENT_PREVIEWER_H_ +#define _FUI_INTERNAL_IUI_EVENT_PREVIEWER_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +class _IUiEventPreviewer + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Operation +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_IUiEventPreviewer(void) {} +}; + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_IUI_EVENT_PREVIEWER_H_ diff --git a/src/ui/inc/FUi_IWindow.h b/src/ui/inc/FUi_IWindow.h new file mode 100644 index 0000000..9604c20 --- /dev/null +++ b/src/ui/inc/FUi_IWindow.h @@ -0,0 +1,41 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_IWindow.h + * @brief This is the header file for the _IWindow class. + * + * This header file contains the declarations of the %_IWindow class. + */ +#ifndef _FUI_INTERNAL_IWINDOW_H_ +#define _FUI_INTERNAL_IWINDOW_H_ + +#include + +namespace Tizen { namespace Ui +{ +class _Control; + +class _IWindow +{ +public: + virtual ~_IWindow(void) {} + virtual void SetFrame(const _Control& control) = 0; +}; // _IWindow + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_IWINDOW_H_ diff --git a/src/ui/inc/FUi_KeyEventManager.h b/src/ui/inc/FUi_KeyEventManager.h new file mode 100644 index 0000000..4afbab3 --- /dev/null +++ b/src/ui/inc/FUi_KeyEventManager.h @@ -0,0 +1,142 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_KeyEventManager.h + * @brief This is the header file for the _KeyEventManager class. + * + * This header file contains the declarations of the _KeyEventManager class. @n. + */ +#ifndef _FUI_KEY_EVENT_MANAGER_H_ +#define _FUI_KEY_EVENT_MANAGER_H_ + +// Includes +#include +#include +#include +#include +#include +#include "FUi_Types.h" +#include "FUi_IKeyEventListener.h" + +// Forward declarations +namespace Tizen { namespace Ui +{ +class Control; +} } + +namespace Tizen {namespace Ui +{ +/** + * @class _KeyEventManager + * @brief This class manages the key events that are fired within this application's context. + * @since 2.0 + * + * The _KeyEventManager listens to all key events that are generated within this application's context. + */ +class _KeyEventManager + : public Tizen::Base::Object +{ +public: + static void Initialize(void); + + /** + * Returns the pointer to the current key event manager. + * + * @since 2.0 + * @return The current _KeyEventManager instance + */ + static _KeyEventManager* GetInstance(void); + + /** + * Adds an application-wide _IKeyEventListener instance. @n + * The added listeners gets notified when a key is pressed, released, or long + * pressed within this application's context. + * + * @since 2.0 + * @param[in] listener The event listener to add + * @remarks The listener is called after the key event is delivered + * to the focused Control's key event listeners, but before the + * key event is passed onto the focused Control itself. @n + * Moreover, if the key needs to be consumed by Control itself, + * the added listeners will not be notified. + * @see Tizen::Ui::_IKeyEventListener::OnKeyPressed() + * @see Tizen::Ui::_IKeyEventListener::OnKeyReleased() + * @see RemoveKeyEventListener () + */ + void AddKeyEventListener(const _IKeyEventListener& listener); + + + /** + * Removes the _IKeyEventListener instance. @n + * The removed listener is not notified even when the key events are fired. + * + * @since 2.0 + * @return listener The current application-wide key event listener to remove + * @see AddKeyEventListener() + */ + void RemoveKeyEventListener(const _IKeyEventListener& listener); + + /** + * Returns the list of key event listeners. @n + * + * @since 2.0 + * @return _IKeyEventListener + */ + Tizen::Base::Collection::LinkedListT* GetKeyEventListener(void) const; + + _Control* GetCapturingControl(_KeyCode keyCode) const; + + void SetCapturingControl(const _Control& control, _KeyCode keyCode, bool captureAllowed); + + static void InitializeInstance(void); + static void ReleaseInstance(void); + +private: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _KeyEventManager(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_KeyEventManager(void); + + /* + * This is the copy constructor for this class. + */ + _KeyEventManager(const _KeyEventManager&); + + /** + * This is the assignment operator for this class. + */ + _KeyEventManager& operator =(const _KeyEventManager&); + +private: + static _KeyEventManager* __pInstance; + Tizen::Base::Collection::LinkedListT* __pKeyEventListeners; + _IKeyEventListener* __pKeyEventListener; + Tizen::Base::Collection::HashMapT<_KeyCode, _ControlHandle>* __pKeyCapturingMap; +}; // _KeyEventManager + +} } // Tizen::Ui + +#endif // _FUI_KEY_EVENT_MANAGER_H_ diff --git a/src/ui/inc/FUi_KeyEventManagerImpl.h b/src/ui/inc/FUi_KeyEventManagerImpl.h new file mode 100644 index 0000000..3ad255b --- /dev/null +++ b/src/ui/inc/FUi_KeyEventManagerImpl.h @@ -0,0 +1,131 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_KeyEventManagerImpl.h + * @brief This is the header file for the _KeyEventManagerImpl class. + * + * This header file contains the declarations of the _KeyEventManagerImpl class. @n. + */ +#ifndef _FUI_INTERNAL_KEY_EVENT_MANAGER_IMPL_H_ +#define _FUI_INTERNAL_KEY_EVENT_MANAGER_IMPL_H_ + +// Includes +#include +#include +#include +#include +#include + +namespace Tizen {namespace Ui +{ +class _ControlImpl; + +/** + * @class _KeyEventManagerImpl + * @brief This class manages the key events that are fired within this application's context. + * @since 2.0 + * + * The _KeyEventManagerImpl listens to all key events that are generated within this application's context. + */ +class _KeyEventManagerImpl + : public Tizen::Base::Object +{ +public: + /** + * Returns the pointer to the current key event manager. + * + * @since 2.0 + * @return The current _KeyEventManagerImpl instance + */ + static _KeyEventManagerImpl* GetInstance(void); + + + /** + * Adds an application-wide IKeyEventListener instance. @n + * The added listeners gets notified when a key is pressed, released, or long + * pressed within this application's context. + * + * @since 2.0 + * @param[in] listener The event listener to add + * @remarks The listener is called after the key event is delivered + * to the focused Control's key event listeners, but before the + * key event is passed onto the focused Control itself. @n + * Moreover, if the key needs to be consumed by Control itself, + * the added listeners will not be notified. + * @see Tizen::Ui::IKeyEventListener::OnKeyPressed() + * @see Tizen::Ui::IKeyEventListener::OnKeyReleased() + * @see Tizen::Ui::IKeyEventListener::OnKeyLongPressed() + * @see RemoveKeyEventListener () + */ + void AddKeyEventListener(IKeyEventListener& listener); + + + /** + * Removes the IKeyEventListener instance. @n + * The removed listener is not notified even when the key events are fired. + * + * @since 2.0 + * @return listener The current application-wide key event listener to remove + * @see AddKeyEventListener() + */ + void RemoveKeyEventListener(IKeyEventListener& listener); + + _ControlImpl* GetKeyCapturingControl(KeyCode keyCode) const; + + static void Initialize(void); + + static void ReleaseInstance(void); + +private: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _KeyEventManagerImpl(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_KeyEventManagerImpl(void); + + /* + * This is the copy constructor for this class. + */ + _KeyEventManagerImpl(const _KeyEventManagerImpl&); + + /** + * This is the assignment operator for this class. + */ + _KeyEventManagerImpl& operator =(const _KeyEventManagerImpl&); + + static void InitializeInstance(void); + +private: + static _KeyEventManagerImpl* __pInstance; + + Tizen::Base::Collection::LinkedListT * __pPublicKeyEventListeners; + + class PublicEventListener; + PublicEventListener* __pKeyEventListeners; +}; // _KeyEventManagerImpl + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_KEY_EVENT_MANAGER_IMPL_H_ diff --git a/src/ui/inc/FUi_LayoutAbsoluteLayout.h b/src/ui/inc/FUi_LayoutAbsoluteLayout.h new file mode 100644 index 0000000..1601ae7 --- /dev/null +++ b/src/ui/inc/FUi_LayoutAbsoluteLayout.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutAbsoluteLayout.h + * @brief This is the header file for AbsoluteLayout class. + * + * This header file contains the declaration of AbsoluteLayout class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_ABSOLUTE_LAYOUT_H_ +#define _FUI_INTERNAL_LAYOUT_ABSOLUTE_LAYOUT_H_ + +#include "FUi_LayoutLayout.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +/** + * @class AbsoluteLayout + * @brief . + * @since 2.0 + * + * . + */ +class _OSP_EXPORT_ AbsoluteLayout + : public Layout +{ +public: + AbsoluteLayout(void); + virtual ~AbsoluteLayout(void); + static AbsoluteLayout* CreateAbsoluteLayoutN(bool defaultMatchParent = false); + virtual result AddItem(LayoutItem& addItem); + +protected: + virtual result OnLayout(int width, int height, bool layoutUpdating); + +private: + AbsoluteLayout(const AbsoluteLayout&); + AbsoluteLayout& operator =(const AbsoluteLayout&); + +private: + bool __defaultMatchParent; +}; // AbsoluteLayout + +}}} // Tizen::Ui::_Layout + +#endif //_FUI_INTERNAL_LAYOUT_ABSOLUTE_LAYOUT_H_ diff --git a/src/ui/inc/FUi_LayoutILayoutItemHandler.h b/src/ui/inc/FUi_LayoutILayoutItemHandler.h new file mode 100644 index 0000000..11c615c --- /dev/null +++ b/src/ui/inc/FUi_LayoutILayoutItemHandler.h @@ -0,0 +1,54 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutILayoutItemHandler.h + * @brief This is the header file for ILayoutItemHandler interface. + * + * This header file contains the declaration of ILayoutItemHandler interface. + */ + +#ifndef _FUI_INTERNAL_LAYOUT_ILAYOUT_ITEM_HANDLER_H +#define _FUI_INTERNAL_LAYOUT_ILAYOUT_ITEM_HANDLER_H + +#include +#include + +namespace Tizen +{ +namespace Ui +{ +namespace _Layout +{ + +class _OSP_EXPORT_ ILayoutItemHandler +{ +public: + virtual ~ILayoutItemHandler(void) {} + + virtual void SetItemVisibleState(bool visible) = 0; + virtual result SetItemBounds(const Tizen::Graphics::Rectangle& rect) = 0; + virtual Tizen::Graphics::Rectangle GetItemBounds(void) const = 0; + virtual Tizen::Graphics::Rectangle GetItemClientBoundsFromSize(const Tizen::Graphics::Dimension& size) const = 0; + virtual Tizen::Graphics::Dimension GetItemContentSize(void) const = 0; + virtual Tizen::Graphics::Dimension GetItemMinimumSize(void) const = 0; + virtual Tizen::Graphics::Dimension GetItemMaximumSize(void) const = 0; + virtual result OnItemMeasure(int& width, int& height) = 0; +}; // ILayoutItemHandler + +}}} + +#endif //_FUI_INTERNAL_LAYOUT_ILAYOUT_ITEM_HANDLER_H diff --git a/src/ui/inc/FUi_LayoutLayout.h b/src/ui/inc/FUi_LayoutLayout.h new file mode 100644 index 0000000..8367544 --- /dev/null +++ b/src/ui/inc/FUi_LayoutLayout.h @@ -0,0 +1,446 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayout.h + * @brief This is the header file for Layout class. + * + * This header file contains the declaration of Layout class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_LAYOUT_H_ +#define _FUI_INTERNAL_LAYOUT_LAYOUT_H_ + +#include +#include "FUi_LayoutLayoutContainer.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +class ProxyList; +class ProxyListNode; +class LayoutItemProxy; + +enum LayoutUpdateFlag +{ + UPDATEFLAG_ERROR = 0x10000000, + UPDATEFLAG_NO_FLAG = 0x00000000, + UPDATEFLAG_NONE_MODE = 0x00000001, + UPDATEFLAG_MATCH_PARENT = 0x00000002, + UPDATEFLAG_WRAPCONTENT = 0x00000004, + UPDATEFLAG_ALIGNMENT = 0x00000008 +}; + +/** + * @class Layout + * @brief This class is the base class of all the Layout classes. + * @since 2.0 + * + * The Layout is the base class of all the Layout classes. + * The Layout class support common functions. + */ +class _OSP_EXPORT_ Layout + : public Tizen::Base::Object +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Layout(void); + + /** + * Gets the proxy of the current container. + * + * @return The current container proxy + * @since 2.0 + */ + LayoutItemProxy* GetContainerProxy(void); + + /** + * Sets the specified location and dimension of the layout + * + * @param[in] layoutRect The rectangle value with the specified location and dimension + * @since 2.0 + */ + void SetLayoutRect(const LayoutRect layoutRect); + + /** + * Gets the location and dimension of the layout. + * + * @return The rectangle value with the location and dimension of the layout + * @since 2.0 + */ + LayoutRect GetLayoutRect(void) const; + + /** + * Sets the alignment of the specified item. + * + * @return An error code + * @param[in] item The item for which the alignment is set + * @param[in] align The alignment + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The alignment parameter is invalid. + * @since 2.0 + */ + result SetItemAlignment(const LayoutItem& item, const ItemAlign align); + + /** + * Gets the alignment of the specified item. + * + * @return An error code + * @param[in] item The item to get the alignment + * @param[out] align The alignment + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result GetItemAlignment(const LayoutItem& Item, ItemAlign& align) const; + + /** + * Sets the margin of the specified item. + * + * @return An error code + * @param[in] item The item for which the margin is set + * @param[in] margin The margin + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result SetItemMargin(const LayoutItem& item, const ItemMargin margin); + + /** + * Gets the margin of the specified item. + * + * @return An error code + * @param[in] item The item to get the margin + * @param[out] margin The margin + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result GetItemMargin(const LayoutItem& item, ItemMargin& margin) const; + + /** + * Sets the width of the specified item with the match policy. + * + * @return An error code + * @param[in] item The item for which the width is set + * @patam[in] matchMode The match policy + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result SetItemWidthMatchMode(const LayoutItem& item, const LayoutMatchMode matchMode); + + /** + * Gets the width of the specified item with the match policy. + * + * @return An error code + * @param[in] item The item to get the match policy of the width + * @patam[out] matchMode The match policy + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result GetItemWidthMatchMode(const LayoutItem& item, LayoutMatchMode& matchMode) const; + + /** + * Sets the height of the specified item with the match policy. + * + * @return An error code + * @param[in] item The item for which the height is set + * @patam[in] matchMode The match policy + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result SetItemHeightMatchMode(const LayoutItem& item, const LayoutMatchMode matchMode); + + /** + * Gets the height of the specified item with the match policy. + * + * @return An error code + * @param[in] item The item to get the match policy of the height + * @patam[out] matchMode The match policy + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result GetItemHeightMatchMode(const LayoutItem& item, LayoutMatchMode& matchMode) const; + + /** + * Updates the all layout. + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result UpdateLayout(void); + + void SetUpdateState(bool state); + + /** + * Updates the current layout & all affected layout. + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result PartialUpdateLayout(void); + + /** + * Adds the item at the end of the list maintained by the layout. + * + * @return An error code + * @param[in] addItem The item to add to the list. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + virtual result AddItem(LayoutItem& addItem); + + /** + * Removes the item from the list maintained by the layout. + * + * @return An error code + * @param[in] removeItem The item to remove from list. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result RemoveItem(const LayoutItem& removeItem); + + /** + * + * + * @return An error code + * @param[in] viewPosX The x coordinate + * @param[in] viewPosY The y coordinate + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE The layout have a item instance that is in an invalid state. + * @since 2.0 + */ + result OnChangeViewPosition(int viewPosX, int viewPosY); + + /** + * Sets the base location and dimension of the specified item. + * + * @return An error code + * @param[in] item The item for which the base location and dimension are set + * @patam[in] baseRect The rectangle value with the location and dimension + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result SetItemBaseRect(const LayoutItem& item, const LayoutRect baseRect); + + /** + * Gets the base location and dimension of the specified item. + * + * @return An error code + * @param[in] item The item to get the base location and dimension + * @patam[out] baseRect The rectangle value with the location and dimension + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result GetItemBaseRect(const LayoutItem& item, LayoutRect& baseRect) const; + + /** + * Checks whether the specified item exists in list. + * + * @return @c true, if the item exists @n + * @c false, otherwise + * @param[in] The item to check. + * @since 2.0 + */ + bool ItemExists(LayoutItem& item); + +protected: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + Layout(void); + + /** + * Calculates the bounds of all children for the specified alignment mode. + * + * @return An error code + * @param[in] alignMode + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result CalculateAlignment(const LayoutAlignMode alignMode = BOTH); + + /** + * Overrides this method to provide user-specific layouting code. + * + * @return An error code + * @param[in] width + * @param[in] height + * @param[in] layoutUpdating + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + virtual result OnLayout(int width, int height, bool layoutUpdating) = 0; + + void SetPartialUpdateFlag(bool flag); + void SetItemList(ProxyList* pItemList); + ProxyList* GetProxyList(void) const; + +private: + /** + * This is the copy constructor for this class. + * + * @since 2.0 + */ + Layout(const Layout&); + + /** + * This is the substitution operator for this class. + * + * @since 2.0 + */ + Layout& operator =(const Layout&); + + /** + * Set the layout container. + * + * @return An error code + * @param[in] pContainer + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result SetContainer(LayoutContainer* pContainer); + + /** + * Creates the layout proxy for the specified item. + * + * @return The created proxy. + * @param[in] item + * @since 2.0 + */ + LayoutItemProxy* CreateProxy(LayoutItem& item); + + /** + * Set the root layout flag. + * + * @param[in] rootCheck + * @since 2.0 + */ + void SetRootLayout(bool rootCheck); + + /** + * Checks the specified item whether it is already in the item list or not. + * + * @return An error code + * @param[in] checkItem The item to check whether it is already in the list or not + * @exception E_SUCCESS The specified item is not in the item list. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified item parameter is null. + * @since 2.0 + */ + result CheckItem(const LayoutItem& checkItem); + + /** + * Internal method of UpdateLayout() and PartialUpdateLayout(). + * + * @return An error code + * @exception + * @since 2.0 + */ + result UpdateLayoutInternal(LayoutUpdateFlag updateFlag); + + /** + * Runs the OnLayout() for pLayout. + * + * @return An error code + * @exception + * @since 2.0 + */ + result OnLayoutTrigger(Layout& layout, bool layoutUpdating); + + /** + * Gets the update flag for parent layout. + * + * @return LayoutUpdateFlag + * @exception + * @since 2.0 + */ + LayoutUpdateFlag CheckParentFlag(void); + + /** + * Gets the update flag for current layout. + * + * @return LayoutUpdateFlag + * @exception + * @since 2.0 + */ + LayoutUpdateFlag CheckCurrentFlag(void); + + /** + * Internal method of CheckParentFlag() and CheckCurrentFlag(). + * + * @return LayoutUpdateFlag + * @exception + * @since 2.0 + */ + LayoutUpdateFlag CheckFlagInternal(LayoutItemProxy& containerProxy); + + /** + * Checks whether the layout has the container. + * + * @return bool + * @exception + * @since 2.0 + */ + bool HasLayoutContainer(void); + + result DetermineWindowRectToAllItem(void); + result OnDetermine(void); + +private: + ProxyList* __pProxyList; + int __x; + int __y; + int __width; + int __height; + + LayoutItemProxy* __pContainerProxy; + bool __rootLayout; + + bool __updateState; + bool __partialUpdateState; + bool __determineState; + + friend class LayoutContainer; +}; // Layout + +}}} // Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_LAYOUT_H_ diff --git a/src/ui/inc/FUi_LayoutLayoutContainer.h b/src/ui/inc/FUi_LayoutLayoutContainer.h new file mode 100644 index 0000000..97947f5 --- /dev/null +++ b/src/ui/inc/FUi_LayoutLayoutContainer.h @@ -0,0 +1,246 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutContainer.h + * @brief This is the header file for LayoutContainer class. + * + * This header file contains the declaration of LayoutContainer class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_LAYOUT_CONTAINER_H_ +#define _FUI_INTERNAL_LAYOUT_LAYOUT_CONTAINER_H_ + +#include "FUi_LayoutLayoutItem.h" + +//outer +namespace Tizen +{ +namespace Ui +{ +namespace _Layout +{ + +class LayoutList; + +class _OSP_EXPORT_ LayoutContainer + : public LayoutItem +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + LayoutContainer(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~LayoutContainer(void); + + /** + * Sets the current layout to specified layout that is in layout list. + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The input layout is not exist in layout list. + * @since 2.0 + */ + result SetCurrentLayout(Layout& layout); + + /** + * Adds the specified layout to the layout list. + * + * @return An error code + * @param[in] layout The layout to add to list. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_OUT_OF_MEMORY Insufficient memory. + * @since 2.0 + */ + result AddLayout(Layout& layout); + + /** + * Gets the current layout of container. + * + * @return The current layout. + * @since 2.0 + */ + Layout* GetLayout(void) const; + + /** + * Sets the default layout to specified layout. + * + * @return An error code + * @param[in] layout The default layout. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The input layout is not exist in layout list. + * @since 2.0 + */ + result SetDefaultLayout(Layout& layout); + + /** + * Gets the default layout. + * + * @return The default layout. + * @since 2.0 + */ + Layout* GetDefaultLayout(void) const; + + /** + * Checks whether the specified layout exists in list. + * + * @return @c true, if the layout exists @n + * @c false, otherwise + * @param[in] The layout to check. + * @since 2.0 + */ + bool LayoutExists(Layout& layout); + + /** + * Adds the item to all layout of container. + * + * @return An error code + * @param[in] addItem The item to add the layout. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result AddItem(LayoutItem& addItem); + + /** + * Removes the item from all layout of container. + * + * @return An error code + * @param[in] removeItem The item to remove from the layout. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result RemoveItem(LayoutItem& removeItem); + +private: + /** + * This is the copy constructor for this class. + * + * @since 2.0 + */ + LayoutContainer(const LayoutContainer&); + + /** + * This is the substitution operator for this class. + * + * @since 2.0 + */ + LayoutContainer& operator =(const LayoutContainer&); + + /** + * Sets the intended window size. + * + * @return void + * @param[in] intendedWindowSize + * @since 2.0 + */ + void SetIntendedWindowSize(const LayoutSize intendedWindowSize); + + /** + * Gets the intended window size. + * + * @return Intended window size. + * @since 2.0 + */ + LayoutSize GetIntendedWindowSize(void) const; + + /** + * Determines the basic size for calculating size for all children. + * + * @return An error code + * @param[in] width + * @param[in] height + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + virtual result Measure(int width, int height); + + /** + * This method is not used currently. + * + * @return An error code + * @param[in] deletedLayout + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result OnSetDefaultLayout(Layout& deletedLayout); + + /** + * Removes the item from layout when the item has been destroyed. + * + * @return An error code + * @param[in] deletedLayout The deleted item. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + void OnDestroyItem(LayoutItem& item); + + /** + * Removes the layout from list when the layout has been destroyed. + * + * @return An error code + * @param[in] pItem The deleted layout. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + void OnDestroyLayout(Layout& layout); + + /** + * Sets the container when the contaier proxy has been destroyed. + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + void OnDestroyContainerProxy(void); + + LayoutList* GetLayoutList(void); + +// property +private: + //_Control* __pOuterContainer; + Layout* __pCurrentLayout; + LayoutSize __intendedWindowSize; + + LayoutList* __pLayoutList; + + bool __defaultLayoutFlag; + + friend class Layout; + friend class LayoutItem; + friend class LayoutItemProxy; +}; // LayoutContainer + +}}} //Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_LAYOUT_CONTAINER_H_ diff --git a/src/ui/inc/FUi_LayoutLayoutItem.h b/src/ui/inc/FUi_LayoutLayoutItem.h new file mode 100644 index 0000000..215f296 --- /dev/null +++ b/src/ui/inc/FUi_LayoutLayoutItem.h @@ -0,0 +1,244 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutItem.h + * @brief This is the header file for LayoutItem class. + * + * This header file contains the declaration of LayoutItem class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_LAYOUT_ITEM_H_ +#define _FUI_INTERNAL_LAYOUT_LAYOUT_ITEM_H_ + +#include +#include +#include +#include +#include "FUi_LayoutLayoutTypes.h" +#include "FUi_LayoutILayoutItemHandler.h" + +namespace Tizen { namespace Ui +{ +class _Control; +} } + +namespace Tizen +{ +namespace Ui +{ +namespace _Layout +{ + +class Layout; +class LayoutContainer; + +class _OSP_EXPORT_ LayoutItem + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + LayoutItem(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~LayoutItem(void); + + /** + * Gets the layout of parent container. + * + * @return The layout of parent container. + * @since 2.0 + */ + Layout* GetIncludedLayout(void) const; + + /** + * Sets the base rect when the bounds of container has been changed. + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result OnChangeBaseRect(void); + + /** + * Sets the item handler. + * + * @return void + * @since 2.0 + */ + void SetItemHandler(ILayoutItemHandler* pOuterControl); + + /** + * Gets the layoutable flag. + * + * @return void + * @since 2.0 + */ + bool GetLayoutable(void); + + /** + * Converts the window bounds to client bounds. + * + * @param[in] windowRect + * @param[out] clientRect + * @since 2.0 + */ + void ConvertWindowToClientBounds(const LayoutRect windowRect, LayoutRect& clientRect); + +protected: + /** + * Determines the basic size for calculating size. + * + * @return An error code + * @param[in] width + * @param[in] height + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + virtual result Measure(int width, int height); + + /** + * Sets the parent container. + * + * @return void + * @param[in] pParentContainer + * @since 2.0 + */ + void SetParentContainer(LayoutContainer* pParentContainer); + + /** + * Gets the parent container. + * + * @return The parent container. + * @since 2.0 + */ + LayoutContainer* GetParentContainer(void) const; + + /** + * Sets the measured size. + * + * @return void + * @param[in] width + * @param[in] height + * @since 2.0 + */ + void SetMeasuredSize(int width, int height); + + /** + * Gets the measured size. + * + * @return void + * @param[out] width + * @param[out] height + * @since 2.0 + */ + void GetMeasuredSize(int& width, int& height) const; + + /** + * Runs ILayoutItemHandler::OnItemMeasure. + * + * @return void + * @param[inout] width + * @param[inout] height + * @since 2.0 + */ + void RunItemMeasure(int& width, int& height); + + /** + * Gets the minimum size of _Control. + * + * @param[out] minSize + * @since 2.0 + */ + void GetMinSize(LayoutSize& minSize) const; + + /** + * Gets the maximum size of _Control. + * + * @param[out] maxSize + * @since 2.0 + */ + void GetMaxSize(LayoutSize& maxSize) const; + + /** + * Sets the bounds of _Control. + * + * @return An error code + * @param[in] rect + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result SetItemWindowRect(const LayoutRect rect); + + /** + * Gets the bounds of _Control. + * + * @param[out] rect + * @since 2.0 + */ + void GetItemWindowRect(LayoutRect& rect) const; + +private: + /** + * This is the copy constructor for this class. + * + * @since 2.0 + */ + LayoutItem(const LayoutItem&); + + /** + * This is the substitution operator for this class. + * + * @since 2.0 + */ + LayoutItem& operator =(const LayoutItem&); + + /** + * Sets the visible state. + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + void Visible(bool visible); + +// property +private: + ILayoutItemHandler* __pOuterControl; + LayoutContainer* __pParentContainer; + + LayoutSize __measuredSize; + + friend class LayoutItemProxy; +}; // LayoutItem + +}}} //Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_LAYOUT_ITEM_H_ diff --git a/src/ui/inc/FUi_LayoutLayoutTypes.h b/src/ui/inc/FUi_LayoutLayoutTypes.h new file mode 100644 index 0000000..88c6ad4 --- /dev/null +++ b/src/ui/inc/FUi_LayoutLayoutTypes.h @@ -0,0 +1,132 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutTypes.h + * @brief This is the header file for internal layout enumeration. + * + * This is the header file for internal layout enumeration. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_LAYOUT_ENUM_H_ +#define _FUI_INTERNAL_LAYOUT_LAYOUT_ENUM_H_ + +#include + +namespace Tizen { namespace Ui { namespace _Layout +{ + +#define NOT_SUPPORT_NEGATIVE_SIZE + +struct LayoutRect +{ + int x; + int y; + int w; + int h; +}; + +struct LayoutPoint +{ + int x; + int y; +}; + +struct LayoutSize +{ + int w; + int h; +}; + +struct ItemMargin +{ + int left; + int top; + int right; + int bottom; +}; + +enum HorizontalAlign +{ + ITEM_HORIZONTAL_ALIGN_LEFT = 0, + ITEM_HORIZONTAL_ALIGN_CENTER, + ITEM_HORIZONTAL_ALIGN_RIGHT, + ITEM_HORIZONTAL_ALIGN_LEFT_RIGHT +}; + +enum VerticalAlign +{ + ITEM_VERTICAL_ALIGN_TOP = 0, + ITEM_VERTICAL_ALIGN_MIDDLE, + ITEM_VERTICAL_ALIGN_BOTTOM, + ITEM_VERTICAL_ALIGN_TOP_BOTTOM +}; + +struct ItemAlign +{ + HorizontalAlign HAlign; + VerticalAlign VAlign; +}; + +enum LayoutAlignMode +{ + BOTH = 0, + HORIZONTALONLY, + VERTICALONLY +}; + +enum LayoutMatchMode +{ + NONE_MODE = 0, + MATCH_PARENT, + WRAP_CONTENT +}; + +// Linear Layout +enum LinearLayoutOrientation +{ + LINEAR_NONE_ORIENTATION = -1, + LINEAR_VERTICAL, + LINEAR_HORIZONTAL +}; + +enum LinearLayoutDirection +{ + LINEAR_NONE_DIRECTION = -1, + LINEAR_LEFT_TO_RIGHT, + LINEAR_RIGHT_TO_LEFT, + LINEAR_TOP_TO_BOTTOM, + LINEAR_BOTTOM_TO_TOP +}; + +// Relative Layout +enum RelativeLayoutEdge +{ + EDGE_NONE = -1, + EDGE_LEFT = 0, + EDGE_TOP, + EDGE_RIGHT, + EDGE_BOTTOM, + EDGE_HCENTER, + EDGE_VCENTER, + EDGE_ALL +}; + +}}} // Tizen::Ui::_Layout + +#endif //_FUI_INTERNAL_LAYOUT_LAYOUT_TYPEDEF_H_ diff --git a/src/ui/inc/FUi_LayoutLinearLayout.h b/src/ui/inc/FUi_LayoutLinearLayout.h new file mode 100644 index 0000000..11b7cea --- /dev/null +++ b/src/ui/inc/FUi_LayoutLinearLayout.h @@ -0,0 +1,381 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLinearLayout.h + * @brief This is the header file for LinearLayout class. + * + * This header file contains the declaration of LinearLayout class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_LINEAR_LAYOUT_H_ +#define _FUI_INTERNAL_LAYOUT_LINEAR_LAYOUT_H_ + +#include "FUi_LayoutLayout.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +/** + * @class LinearLayout + * @brief . + * @since 2.0 + * + * . + */ +class _OSP_EXPORT_ LinearLayout + : public Layout +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + LinearLayout(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~LinearLayout(void); + + /** + * Creates the instance of LinearLayout. + * + * @since 2.0 + * @return The instance of LinearLayout. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + static LinearLayout* CreateLinearLayoutN(void); + + /** + * Checks whether the arguments are valid, and sets the arguments. + * + * @since 2.0 + * @return An error code + * @param[in] orientation The orientation of the linear layout. + * @param[in] direction The direction in which the children are attached. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result Initialize(const LinearLayoutOrientation orientation, const LinearLayoutDirection direction); + + /** + * Adds the item to the list according to the index. + * + * @since 2.0 + * @return An error code + * @param[in] addItem The added item. + * @param[in] index The index of list. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result AddItemToIndex(LayoutItem& addItem, int index); + + /** + * Moves the item according to the index. + * + * @since 2.0 + * @return An error code + * @param[in] item The item of list. + * @param[in] index The index of list. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result MoveItem(LayoutItem& item, int index); + + /** + * Swaps the targetItem and the destItem. + * + * @since 2.0 + * @return An error code + * @param[in] targetItem The target item. + * @param[in] destItem The destination item. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result SwapItem(LayoutItem& targetItem, LayoutItem& destItem); + + /** + * Gets the item count of layout. + * + * @since 2.0 + * @return The item count of layout. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + int GetItemCount(void) const; + + /** + * Gets the index of the specified item. + * + * @since 2.0 + * @return An error code + * @param[in] item The layout item. + * @param[out] index The index of item. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result GetItemIndex(LayoutItem& item, int& index) const; + + /** + * Sets the orientation. + * + * @since 2.0 + * @return An error code + * @param[in] orientation The orientation of linear layout. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result SetOrientation(const LinearLayoutOrientation orientation); + + /** + * Gets the orientation. + * + * @since 2.0 + * @return An error code + * @param[out] orientation The orientation of linear layout. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result GetOrientation(LinearLayoutOrientation& orientation) const; + + /** + * Sets the direction. + * + * @since 2.0 + * @return An error code + * @param[in] direction The direction in which the children are attached. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result SetDirection(const LinearLayoutDirection direction); + + /** + * Gets the direction. + * + * @since 2.0 + * @return An error code + * @param[out] direction The direction in which the children are attached. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result GetDirection(LinearLayoutDirection& direction) const; + + /** + * Sets the weight for specified item. + * + * @since 2.0 + * @return An error code + * @param[in] item The target item. + * @param[in] weight The weight that indicates how much extra space the control occupies in proportion to it. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetItemWeight(LayoutItem& item, const float weight); + + /** + * Gets the weight for specified item. + * + * @since 2.0 + * @return An error code + * @param[out] item The target item. + * @param[out] weight The weight of target item. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result GetItemWeight(const LayoutItem& item, float& weight) const; + + /** + * Sets the spacing for specified item. + * + * @since 2.0 + * @return An error code + * @param[in] item The target item. + * @param[in] spacing The space. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result SetItemSpacing(LayoutItem& item, int spacing); + + /** + * Gets the spacing for specified item. + * + * @since 2.0 + * @return An error code + * @param[in] item The target item. + * @param[out] spacing The space of target item. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result GetItemSpacing(const LayoutItem& item, int& spacing) const; + +protected: + /** + * Calculates the position and bounds of all chindren, and applies to the control. + * + * @return An error code + * @param[in] width + * @param[in] height + * @param[in] layoutUpdating + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + virtual result OnLayout(int width, int height, bool layoutUpdating); + +private: + /** + * This is the copy constructor for this class. + * + * @since 2.0 + */ + LinearLayout(const LinearLayout&); + + /** + * This is the substitution operator for this class. + * + * @since 2.0 + */ + LinearLayout& operator =(const LinearLayout&); + + /** + * Calculates the size & position of all children. @n + * Wrapper method of CalcHorizontalPosSize and CalcVerticalPosSize. @n + * Used by OnLayout. + * + * @since 2.0 + * @return An error code + * @param[out] rightBound + * @param[out] bottomBounds + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result CalculatePositionSize(int& rightBound, int& bottomBound); + + /** + * If orientation is horizontal, Calculates the size & position of all children. @n + * Used by CalcPosSize. + * + * @since 2.0 + * @return An error code + * @param[out] rightBound + * @param[out] bottomBound + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result CalculateHorizontalPositionSize(int& rightBound, int& bottomBound); + + /** + * If orientation is vertical, Calculates the size & position of all children. @n + * Used by CalcPosSize. + * + * @since 2.0 + * @return An error code + * @param[out] rightBound + * @param[out] bottomBound + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result CalculateVerticalPositonSize(int& rightBound, int& bottomBound); + + /** + * Calculates the bound in empty space according to weight. @n + * Used by OnLayout. + * + * @since 2.0 + * @return An error code + * @param[out] rightBound + * @param[out] bottomBound + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result CalculateWeight(int& rightBound, int& bottomBound); + + /** + * If orientation is horizontal, Calculates the bound in empty space according to weight. @n + * Used by CalcWeight. + * @since 2.0 + * @return An error code + * @param[out] emptySpace + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result CalculateHorizontalWeight(int& emptySpace); + + /** + * If orientation is vertical, Calculates the bound in empty space according to weight. @n + * Used by CalcWeight. + * @since 2.0 + * @return An error code + * @param[in] emptySpace + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result CalculateVerticalWeight(int& emptySpace); + + /** + * Checks whether container is wrap content mode, and calculate size. @n + * Used by OnLayout. + * @since 2.0 + * @return An error code + * @param[in] rightBound + * @param[in] bottomBound + * @param[in] layoutUpdating + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result CalculateWrapContent(LayoutItemProxy& containerProxy, int rightBound, int bottomBound, bool layoutUpdating); + + /** + * Checks whether container is match parent mode, and calculate size. @n + * Used by OnLayout. + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result CalculateMatchParent(void); + + /** + * Corrects the bounds according to orientation. @n + * Used by OnLayout. + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result CalculateCorrectedAlignment(void); + +private: + LinearLayoutOrientation __orientation; + LinearLayoutDirection __direction; + float __weightSum; +}; // LinearLayout + +}}} // Tizen::Ui::_Layout + +#endif //_FUI_INTERNAL_LAYOUT_LINEAR_LAYOUT_H_ diff --git a/src/ui/inc/FUi_LayoutRelativeLayout.h b/src/ui/inc/FUi_LayoutRelativeLayout.h new file mode 100644 index 0000000..de8e20b --- /dev/null +++ b/src/ui/inc/FUi_LayoutRelativeLayout.h @@ -0,0 +1,319 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutRelativeLayout.h + * @brief This is the header file for RelativeLayout class. + * + * This header file contains the declaration of RelativeLayout class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_RELATIVE_LAYOUT_H_ +#define _FUI_INTERNAL_LAYOUT_RELATIVE_LAYOUT_H_ + +#include "FUi_LayoutLayout.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ +class RelativeProxyList; + +class _OSP_EXPORT_ RelativeLayout + : public Layout +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + RelativeLayout(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~RelativeLayout(void); + + /** + * Creates the instance of RelativeLayout. + * + * @since 2.0 + * @return The instance of RelativeLayout. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + static RelativeLayout* CreateRelativeLayoutN(void); + + /** + * Sets the relation of the specified layout item for the edge with other layout item. + * + * @since 2.0 + * @return An error code + * @param[in] pItem The layout item for which the relation is set + * @param[in] itemEdge The edge of pItem. + * @param[in] pTarget The target layout item. + * @param[in] targetEdge The edge of targetEdge. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result SetRelation(LayoutItem& item, const RelativeLayoutEdge itemEdge, LayoutItem* pTarget = null, const RelativeLayoutEdge targetEdge = EDGE_NONE); + + /** + * Unsets the relation of the specified layout item for the edge. + * + * @since 2.0 + * @return An error code + * @param[in] pItem The layout item for which the relation is unset + * @param[in] itemEdge The edge of pItem. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result UnsetRelation(LayoutItem& item, const RelativeLayoutEdge itemEdge); + + /** + * Gets the layout itme of the specified layout item for the edge. + * + * @since 2.0 + * @return The layout item of specified edge. + * @param[in] pItem The layout item for which the relation is set + * @param[in] itemEdge The edge of pItem. + * @param[out] targetEdge The edge of target layout item. + */ + LayoutItem* GetRelation(LayoutItem& item, const RelativeLayoutEdge itemEdge, RelativeLayoutEdge* pTargetEdge = null); + +protected: + /** + * Calculates the position and bounds of all chindren, and applies to the control. + * + * @return An error code + * @param[in] width + * @param[in] height + * @param[in] layoutUpdating + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + virtual result OnLayout(int width, int height, bool updateLayouting); + +private: + /** + * This is the copy constructor for this class. + * + * @since 2.0 + */ + RelativeLayout(const RelativeLayout&); + + /** + * This is the substitution operator for this class. + * + * @since 2.0 + */ + RelativeLayout& operator =(const RelativeLayout&); + + /** + * Increases the reference count. + * + * @return An error code + * @param[in] pNode + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result IncreaseReferenceCount(ProxyListNode& node); + + /** + * Decreases the reference count. + * + * @return void + * @param[in] pNode + * @param[in] pTargetNode + * @since 2.0 + */ + void DecreaseReferenceCount(ProxyListNode& node, ProxyListNode& targetNode); + + /** + * Reorders the node list + * + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result AlignItemNodeMaxRefMove(void); + + /** + * Unsets the all relation of the specified node. + * + * @return An error code + * @param[in] pTargetNode + * @param[in] pDeleteNode + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result DeleteTargetInfo(ProxyListNode& targetNode, ProxyListNode& deleteNode); + + /** + * Calculates the position of the specified node. + * + * @return An error code + * @param[in] pCurNode + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + * @since 2.0 + */ + result CalculatePosition(ProxyListNode& curNode); + + /** + * Calculates the center position of the specified node. + * + * @return An error code + * @param[in] pCurNode + * @param[out] calcPosition + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + * @since 2.0 + */ + result CalculateCenter(ProxyListNode& curNode, bool calcPosition); + + /** + * Checks whether the sourceEdge and targetEdge is right. + * + * @return @c true, if the sourceEdge and targetEdge is right @n + @c false, otherwise + * @param[in] sourceEdge + * @param[in] targetEdge + * @since 2.0 + */ + bool CheckTargetEdge(const RelativeLayoutEdge sourceEdge, const RelativeLayoutEdge targetEdge) const; + + /** + * Gets the position of specified item. + * + * @return An error code + * @param[in] pTargetProxy + * @param[in] targetEdge + * @param[out] targetPoint + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + * @since 2.0 + */ + result GetTargetPosition(LayoutItemProxy* pTargetProxy, const RelativeLayoutEdge targetEdge, LayoutPoint& targetPoint) const; + + /** + * Sets the relation of the specified node for the edge with pTargetNode. + * + * @return An error code + * @param[in] pSourceNode + * @param[in] sourceEdge + * @param[in] pTargetNode + * @param[in] targetEdge + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @since 2.0 + */ + result SetAlignment(ProxyListNode& sourceNode, const RelativeLayoutEdge sourceEdge, ProxyListNode* pTargetNode, const RelativeLayoutEdge targetEdge); + + /** + * Unsets the relation of the specified node for the edge. + * + * @return An error code + * @param[in] pSourceNode + * @param[in] sourceEdge + * @param[out] ppTargetProxy + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error occurred. + * @since 2.0 + */ + result UnsetAlignment(ProxyListNode& sourceNode, const RelativeLayoutEdge sourceEdge, LayoutItemProxy** ppTargetProxy); + + /** + * Gets the layout itme proxy of the specified node for the edge. + * + * @return LayoutItemProxy of pSourceNode for sourceEdge + * @param[in] pSourceNode + * @param[in] sourceEdge + * @param[out] targetEdge + * @exception E_OUT_OF_RANGE An edge value is invalid. + * @since 2.0 + */ + LayoutItemProxy* GetAlignment(ProxyListNode& sourceNode, const RelativeLayoutEdge sourceEdge, RelativeLayoutEdge* targetEdge = null); + + /** + * The internal methode of IncreaseRefCount. + * + * @return An error code + * @param[in] pTargetNode + * @param[in] pBaseNode + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error occurred. + * @since 2.0 + */ + result IncreaseReference(ProxyListNode& targetNode, ProxyListNode& pBaseNode); + + /** + * Gets the node of specified node for edge. + * + * @return ProxyListNode of pNode for the edge + * @param[in] pNode + * @param[in] edge + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_SYSTEM A system error occurred. + * @since 2.0 + */ + ProxyListNode* GetTargetNode(ProxyListNode& node, const RelativeLayoutEdge edge); + + /** + * Sets the reference count to zero. + * + * @return An error code + * @param[in] pNode + * @param[in] pBaseNode + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + result SetZeroReference(ProxyListNode& node, ProxyListNode& pBaseNode); + + RelativeProxyList* GetRelativeProxyList(void); + +// property +private: + const LayoutItemProxy* __pTargetParent; + + friend class RelativeProxyList; +}; // RelativeLayout + +}}} //Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_RELATIVE_LAYOUT_H_ diff --git a/src/ui/inc/FUi_LayoutTableLayout.h b/src/ui/inc/FUi_LayoutTableLayout.h new file mode 100755 index 0000000..e75f87b --- /dev/null +++ b/src/ui/inc/FUi_LayoutTableLayout.h @@ -0,0 +1,671 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutTableLayout.h + * @brief This is the header file for TableLayout class. + * + * This header file contains the declaration of TableLayout class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_TABLE_LAYOUT_H_ +#define _FUI_INTERNAL_LAYOUT_TABLE_LAYOUT_H_ + +#include +#include "FUi_LayoutLayout.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +struct RowInfo +{ + int y; + int height; + bool rowCollapsed; + bool heightShrinkable; + bool heightStretchable; + int heightSpacing; + int maxHeight; + int mergedHeight; +}; + +struct ColumnInfo +{ + int x; + int width; + bool columnCollapsed; + bool widthShrinkable; + bool widthStretchable; + int widthSpacing; + int maxWidth; + int mergedWidth; +}; + +class _OSP_EXPORT_ TableLayout + : public Layout +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + TableLayout(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~TableLayout(void); + + /** + * Creates the instance of TableLayout. + * + * @since 2.0 + * @return The instance of TableLayout. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + static TableLayout* CreateTableLayoutN(void); + + /** + * Creates the table. + * + * @since 2.0 + * @return An error code + * @param[in] row The number of rows. + * @param[in] column The number of columns. + * @param[in] spacing The space. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + result CreateTable(int row, int column, int spacing = 0); + + /** + * Merges from the start cell to the end cell. + * + * @since 2.0 + * @return An error code + * @param[in] startRow The start row. + * @param[in] startCol The start column. + * @param[in] endRow The end row. + * @param[in] endCol The end column. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result Merge(int startRow, int startCol, int endRow, int endCol); + + /** + * Unmerges the specified cell. + * + * @since 2.0 + * @return An error code + * @param[in] row The target row. + * @param[in] column The target column. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE The target is impossible to unmerge. + */ + result Unmerge(int row, int column); + + /** + * Gets the size of merged cell for specified row and column. + * + * @since 2.0 + * @return An error code + * @param[in] row The target row. + * @param[in] column The target column. + * @param[out] rowSize The merged row size. + * @param[out] columnSize The merged column size. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + * @exception E_INVALID_STATE The target is merged by other cell. + */ + result GetMergeSize(int row, int column, int& rowSize, int& columnSize) const; + + /** + * Adds the item into the empty cell. + * + * @since 2.0 + * @return An error code + * @param[in] pAddItem The added item. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE The target cell has been already occupied. + */ + result AddItem(LayoutItem& addItem); + + /** + * Adds the item into the specified cell. + * + * @since 2.0 + * @return An error code + * @param[in] pAddItem The added item. + * @param[in] row The target row. + * @param[in] column The target column. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE The target cell has been already occupied. + */ + result AddItem(LayoutItem& addItem, int row, int column, bool mergedState = false); + + /** + * Gets the item of the specified cell. + * + * @since 2.0 + * @return LayoutItem + * @param[in] row The target row. + * @param[in] column The target column. + */ + LayoutItem* GetItem(int row, int column) const; + + /** + * Sets the row and column of specified item. + * + * @since 2.0 + * @return An error code + * @param[in] pItem The item to change the position. + * @param[in] row The target row. + * @param[in] column The target column. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_INVALID_STATE The target cell has been already occupied. + */ + result SetItemPosition(const LayoutItem& item, int row, int column); + + /** + * Gets the row and column of specified item. + * + * @since 2.0 + * @return An error code + * @param[in] pItem The item to change the position. + * @param[in] row The row of item. + * @param[in] column The column of item. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result GetItemPosition(const LayoutItem& item, int& row, int& column) const; + + /** + * Swaps the position between item1 and item2. + * + * @since 2.0 + * @return An error code + * @param[in] pItem1 The target item 1. + * @param[in] pItem2 The target item 2. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result SwapItemPosition(LayoutItem& item1, LayoutItem& item2); + + /** + * Adds the row to the table. + * + * @since 2.0 + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + * @return void + */ + result AddRow(void); + + /** + * Adds the column to the table. + * + * @since 2.0 + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + * @return void + */ + result AddColumn(void); + + /** + * Deletes the specified row from the table. + * + * @since 2.0 + * @return An error code + * @param[in] row The target row. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result DeleteRow(int row); + + /** + * Deletes the specified column from the table. + * + * @since 2.0 + * @return An error code + * @param[in] column The target column. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_SYSTEM A system error occurred. + */ + result DeleteColumn(int column); + + /** + * Sets the collapse property for the specified row. + * + * @since 2.0 + * @return An error code + * @param[in] row The target row. + * @param[in] collapsed The collase state. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetRowCollapsed(int rowIndex, bool collapsed); + + /** + * Checks whether the row is collapsed. + * + * @since 2.0 + * @return @c true, The row is collapsed @n + @c false, otherwise + * @param[in] row The target row. + */ + bool GetRowCollapsed(int rowIndex) const; + + /** + * Sets the collapse property for the specified column. + * + * @since 2.0 + * @return An error code + * @param[in] column The target column. + * @param[in] collapsed The collase state. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetColumnCollapsed(int column, bool collapsed); + + /** + * Checks whether the column is collapsed. + * + * @since 2.0 + * @return @c true, The column is collapsed @n + @c false, otherwise + * @param[in] column The target column. + */ + bool GetColumnCollapsed(int column) const; + + /** + * Sets the shrinkable property for the specified row. + * + * @since 2.0 + * @return An error code + * @param[in] row The target row. + * @param[in] shrinkable The shrinkable state. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetRowShrinkable(int row, bool shrinkable); + + /** + * Checks whether the row is shrinkable. + * + * @since 2.0 + * @return @c true, The row is shrinkable @n + @c false, otherwise + * @param[in] row The target row. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + bool GetRowShrinkable(int row) const; + + /** + * Sets the shrinkable property for the specified column. + * + * @since 2.0 + * @return An error code + * @param[in] column The target column. + * @param[in] shrinkable The shrinkable state. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetColumnShrinkable(int column, bool shrinkable); + + /** + * Checks whether the column is shrinkable. + * + * @since 2.0 + * @return @c true, The column is shrinkable @n + @c false, otherwise + * @param[in] column The target column. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + bool GetColumnShrinkable(int column) const; + + /** + * Sets the stretchable property for the specified row. + * + * @since 2.0 + * @return An error code + * @param[in] row The target row. + * @param[in] stretchable The stretchable state. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetRowStretchable(int row, bool stretchable); + + /** + * Checks whether the row is stretchable. + * + * @since 2.0 + * @return @c true, The row is stretchable @n + @c false, otherwise + * @param[in] row The target row. + */ + bool GetRowStretchable(int row) const; + + /** + * Sets the stretchable property for the specified column. + * + * @since 2.0 + * @return An error code + * @param[in] column The target column. + * @param[in] stretchable The stretchable state. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetColumnStretchable(int column, bool stretchable); + + /** + * Checks whether the column is stretchable. + * + * @since 2.0 + * @return @c true, The column is stretchable @n + @c false, otherwise + * @param[in] column The target column. + */ + bool GetColumnStretchable(int column) const; + + /** + * Sets the spacing for the specified row. + * + * @since 2.0 + * @return An error code + * @param[in] row The target row. + * @param[in] heightSpacing The space size. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetRowSpacing(int row, int heightSpacing); + + /** + * Gets the spacing of the specified row. + * + * @since 2.0 + * @return An error code + * @param[in] row The target row. + * @param[out] spacing The height space of target row. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result GetRowSpacing(int row, int& spacing) const; + + /** + * Sets the spacing for specified column. + * + * @since 2.0 + * @return An error code + * @param[in] column The target column. + * @param[in] widthSpacing The space size. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result SetColumnSpacing(int column, int widthSpacing); + + /** + * Gets the spacing of the specified column. + * + * @since 2.0 + * @return An error code + * @param[in] column The target column. + * @param[out] spacing The width space of target column. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + */ + result GetColumnSpacing(int column, int& spacing) const; + + /** + * Sets the fill property for specified cell. + * + * @since 2.0 + * @return An error code + * @param[in] row The target row. + * @param[in] column The target column. + * @param[in] fillWidth The fill width state. + * @param[in] fillHeight The fill height state. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + * @exception E_SYSTEM A system error occurred. + */ + result SetFillCell(int row, int column, bool fillWidth, bool fillHeight); + + /** + * Checks whether the cell has fill property. + * + * @since 2.0 + * @return An error code + * @param[in] row The target row. + * @param[in] column The target column. + * @param[out] fillWidth The fill width state of the target cell. + * @param[out] fillHeight The fill height state of the target cell. + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_RANGE Input Argument value over the max value. + * @exception E_SYSTEM A system error occurred. + */ + result GetFillCell(int row, int column, bool& fillWidth, bool& fillHeight) const; + +protected: + /** + * Calculates the position and bounds of all chindren, and applies to the control. + * + * @return An error code + * @param[in] width + * @param[in] height + * @param[in] layoutUpdating + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @since 2.0 + */ + virtual result OnLayout(int widht, int height, bool updateLayouting); + +private: + /** + * This is the copy constructor for this class. + * + * @since 2.0 + */ + TableLayout(const TableLayout&); + + /** + * This is the substitution operator for this class. + * + * @since 2.0 + */ + TableLayout& operator =(const TableLayout&); + + /** + * Calculates the size of the all cell. @n + * Used by OnLayout. + * + * @since 2.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + */ + result CalculateSize(void); + + /** + * Calculates the size of the all shrinkable cell. @n + * Used by OnLayout. + * + * @since 2.0 + * @return An error code + * @param[in] windowRect + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + result CalculateShrinkCell(LayoutRect windowRect); + + /** + * Calculates the size of the all stretchable cell. @n + * Used by OnLayout. + * + * @since 2.0 + * @return An error code + * @param[in] windowRect + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_OUT_OF_MEMORY Insufficient memory. + */ + result CalculateStretchCell(LayoutRect windowRect); + + /** + * Calculates the size of the merged cell. @n + * Used by AdjustTableLayout. + * + * @since 2.0 + * @return An error code + * @param[in] row + * @param[in] column + * @param[out] size + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result CalculateMergeCell(int row, int column, LayoutSize& size); + + /** + * Calculates the size of item for alignment. @n + * Used by AdjustTableLayout. + * + * @since 2.0 + * @return The calculated rect + * @param[in] pItemProxy + * @param[in] cellRect + * @param[in] itemRect + * @param[in] horizonEdge + * @param[in] verticalEdge + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + LayoutRect CalculateAlign(LayoutItemProxy& itemProxy, const LayoutRect cellRect, const LayoutRect itemRect, const HorizontalAlign horizonEdge, const VerticalAlign verticalEdge); + + /** + * Finally, adjusts the size. @n + * Used by OnLayout. + * + * @since 2.0 + * @return An error code + * @param[in] windowRect + * @param[in] updateLayouting + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result AdjustTableLayout(const LayoutRect windowRect, bool updateLayouting); + + /** + * Gets the node of specified cell. + * + * @since 2.0 + * @return The node for row and column + * @param[in] row + * @param[in] column + */ + ProxyListNode* GetNode(int row, int column) const; + + /** + * Gets the size of the specified cell. + * + * @since 2.0 + * @return An error code + * @param[in] cellIndex The target cell index. + * @param[out] rect The rect of target cell. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + */ + result GetCellSize(int cellIndex, LayoutRect& rect); + + /** + * Gets the row number from specified cell ID. + * + * @since 2.0 + * @return The row number + * @param[in] id The ID of target cell. + */ + int GetRow(int id) const; + + /** + * Gets the column number from specified cell ID. + * + * @since 2.0 + * @return The column number + * @param[in] id The ID of target cell. + */ + int GetColumn(int id) const; + + /** + * Makes & Gets the cell ID from specified row number and column number. + * + * @since 2.0 + * @return The cell ID + * @param[in] row The row number + * @param[in] column The column number + */ + int MakeCellID(int row, int column) const; + +// property +private: + // Table metrics information + int __row; + int __column; + int __maxRow; + int __maxColumn; + + // Shrink, Stretch Count + int __shrinkRowCount; + int __shrinkColumnCount; + int __stretchRowCount; + int __stretchColumnCount; + + bool __rowShrinkable; + bool __columnShrinkable; + bool __rowStretchable; + bool __columnStretchable; + + // Rows information + RowInfo* __pRowInfo; + // Columns information + ColumnInfo* __pColInfo; + + static const int INVALID_CELL_ID = 0xFFFFFFFF; + static const int NOT_MERGED = 0xFFFFFFFE; + + Tizen::Base::Collection::LinkedList __mergedCellList; + + friend class TableItemInfo; +}; // TableLayout + +}}} //Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_TABLE_LAYOUT_H_ diff --git a/src/ui/inc/FUi_Math.h b/src/ui/inc/FUi_Math.h new file mode 100644 index 0000000..648a4881 --- /dev/null +++ b/src/ui/inc/FUi_Math.h @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_Math.h + * @brief Header file for internal float math functions + * + * This file contains declarations internal float math functions. + */ + + +#ifndef _FUI_INTERNAL_MATH_H_ +#define _FUI_INTERNAL_MATH_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +template +inline T +_Abs(const T& t) { return t >= 0 ? t : -t;} + +template +inline const T& +_Min(const T& a, const T& b) +{ + if (a < b) + return a; + return b; +} + +template +inline const T& +_Max(const T& a, const T& b) +{ + if (a < b) + return b; + return a; +} + +#define ALMOST_ZERO_FLOAT 0.00001f +#define ALMOST_ZERO_DOUBLE 0.000000000001 + +// We do not use epsilon but hard-coded value to check if the two values are close "*ENOUGH*". +static inline bool +_FloatCompare(double p1, double p2) +{ + return (_Abs(p1 - p2) <= ALMOST_ZERO_FLOAT * _Min(_Abs(p1), _Abs(p2))); +} + +static inline bool +_FloatCompare(float p1, float p2) +{ + return (_Abs(p1 - p2) <= ALMOST_ZERO_DOUBLE * _Min(_Abs(p1), _Abs(p2))); +} + +static inline bool +_FloatHardCompare(double p1, double p2) +{ + return (_Abs(p1 - p2) <= DBL_EPSILON); +} + +static inline bool +_FloatHardCompare(float p1, float p2) +{ + return (_Abs(p1 - p2) <= FLT_EPSILON); +} + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_MATH_H_ diff --git a/src/ui/inc/FUi_Matrix3Df.h b/src/ui/inc/FUi_Matrix3Df.h new file mode 100644 index 0000000..9e316bf --- /dev/null +++ b/src/ui/inc/FUi_Matrix3Df.h @@ -0,0 +1,244 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_Matrix3Df.h + * @brief Header file of _Matrix3Df class + * + * This file contains declarations _Matrix3Df class. + */ + +#ifndef _FUI_ANIM_INTERNAL_MATRIX3DF_H_ +#define _FUI_ANIM_INTERNAL_MATRIX3DF_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _Matrix3Df +{ +public: + enum + { + IdentityMatrix = 0x0001, + TranslationMatrix = 0x0002, + ScaleMatrix = 0x0004, + GenericMatrix = 0x0008 + }; + + _Matrix3Df(void); + _Matrix3Df(const _Matrix3Df& rhs) + { + memcpy(__m, rhs.__m, sizeof(__m)); + __complexity = rhs.__complexity; + } + + explicit _Matrix3Df(const float* pValues); + + _Matrix3Df& Assign(const _Matrix3Df& rhs); + + bool operator ==(const _Matrix3Df& rhs) const; + bool operator !=(const _Matrix3Df& rhs) const; + _Matrix3Df& operator =(const _Matrix3Df& rhs); + _Matrix3Df& operator *=(const _Matrix3Df& rhs); + + friend _Matrix3Df operator *(const _Matrix3Df& matrix1, const _Matrix3Df& matrix2); + + void Optimize(void); + bool IsIdentity(void) const { return __complexity == IdentityMatrix;} + bool IsTranslation(void) const { return __complexity == TranslationMatrix;} + bool IsScale(void) const { return __complexity == ScaleMatrix;} + bool IsGeneric(void) const { return __complexity == GenericMatrix;} + + void LoadIdentity(void); + void Transpose(void); + + _Matrix3Df& MultiplyMatrix(const _Matrix3Df& matrix); + _Matrix3Df& Concatenate(const _Matrix3Df* matrix); + _Matrix3Df& Concatenate(const _Matrix3Df& matrix); + + float GetDeterminant(void) const; + bool IsInvertible(void) const; + bool Invert(void); + + void Translate(float x, float y, float z); + void Shear(float xy, float yz, float zx, float yx, float zy, float xz); + void Scale(float sx, float sy, float sz); + void Rotate(float angle, float x, float y, float z); + void MakeOrthogonal(float left, float right, float bottom, float top, float n, float f); + void MakeFrustum(float left, float right, float bottom, float top, float n, float f); + void MakePerspective(float fovy, float aspect, float nearZ, float farZ); + void MakeLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ); + _Matrix3Df& MakeTransformAtAnchor(float x, float y, float z); + float Normalize(void); + void Transform(float* pX, float* pY, float* pZ) const; + + float operator ()(int row, int col) const { return __m[col][row];} + float GetItem(int row, int col) const { return __m[col][row];} + void SetItem(int row, int col, float value) { __m[col][row] = value; __complexity = GenericMatrix; } + + const float* GetItems(void) const { return __m[0];} + +protected: + float __m[4][4]; // column-major order (for OpenGL awareness...) + int __complexity; // for performance optimization. Most operations will be done with identity matrix. +}; // _Matrix3Df + + +inline _Matrix3Df +operator *(const _Matrix3Df& matrix1, const _Matrix3Df& matrix2) +{ + if (matrix1.__complexity == _Matrix3Df::IdentityMatrix) + return matrix2; + + if (matrix2.__complexity == _Matrix3Df::IdentityMatrix) + return matrix1; + + + if (matrix1.__complexity == _Matrix3Df::TranslationMatrix) + { + if (matrix2.__complexity == _Matrix3Df::TranslationMatrix) + { + _Matrix3Df ret; + + ret.__m[3][0] = matrix2.__m[3][0] + matrix1.__m[3][0] * matrix2.__m[3][3]; + ret.__m[3][1] = matrix2.__m[3][1] + matrix1.__m[3][1] * matrix2.__m[3][3]; + ret.__m[3][2] = matrix2.__m[3][2] + matrix1.__m[3][2] * matrix2.__m[3][3]; + ret.__m[3][3] = matrix1.__m[3][3] * matrix2.__m[3][3]; + + ret.__complexity = _Matrix3Df::TranslationMatrix; + + return ret; + } + } + + /* TODO: Can be optimized more cases....?? (scale??) */ + + + /* Optimization with loop-unrolling.. really effective for this case ??? */ + float m[4][4]; + + m[0][0] = (matrix1.__m[0][0] * matrix2.__m[0][0]) + + (matrix1.__m[1][0] * matrix2.__m[0][1]) + + (matrix1.__m[2][0] * matrix2.__m[0][2]) + + (matrix1.__m[3][0] * matrix2.__m[0][3]); + m[1][0] = (matrix1.__m[0][0] * matrix2.__m[1][0]) + + (matrix1.__m[1][0] * matrix2.__m[1][1]) + + (matrix1.__m[2][0] * matrix2.__m[1][2]) + + (matrix1.__m[3][0] * matrix2.__m[1][3]); + m[2][0] = (matrix1.__m[0][0] * matrix2.__m[2][0]) + + (matrix1.__m[1][0] * matrix2.__m[2][1]) + + (matrix1.__m[2][0] * matrix2.__m[2][2]) + + (matrix1.__m[3][0] * matrix2.__m[2][3]); + m[3][0] = (matrix1.__m[0][0] * matrix2.__m[3][0]) + + (matrix1.__m[1][0] * matrix2.__m[3][1]) + + (matrix1.__m[2][0] * matrix2.__m[3][2]) + + (matrix1.__m[3][0] * matrix2.__m[3][3]); + + m[0][1] = (matrix1.__m[0][1] * matrix2.__m[0][0]) + + (matrix1.__m[1][1] * matrix2.__m[0][1]) + + (matrix1.__m[2][1] * matrix2.__m[0][2]) + + (matrix1.__m[3][1] * matrix2.__m[0][3]); + m[1][1] = (matrix1.__m[0][1] * matrix2.__m[1][0]) + + (matrix1.__m[1][1] * matrix2.__m[1][1]) + + (matrix1.__m[2][1] * matrix2.__m[1][2]) + + (matrix1.__m[3][1] * matrix2.__m[1][3]); + m[2][1] = (matrix1.__m[0][1] * matrix2.__m[2][0]) + + (matrix1.__m[1][1] * matrix2.__m[2][1]) + + (matrix1.__m[2][1] * matrix2.__m[2][2]) + + (matrix1.__m[3][1] * matrix2.__m[2][3]); + m[3][1] = (matrix1.__m[0][1] * matrix2.__m[3][0]) + + (matrix1.__m[1][1] * matrix2.__m[3][1]) + + (matrix1.__m[2][1] * matrix2.__m[3][2]) + + (matrix1.__m[3][1] * matrix2.__m[3][3]); + + m[0][2] = (matrix1.__m[0][2] * matrix2.__m[0][0]) + + (matrix1.__m[1][2] * matrix2.__m[0][1]) + + (matrix1.__m[2][2] * matrix2.__m[0][2]) + + (matrix1.__m[3][2] * matrix2.__m[0][3]); + m[1][2] = (matrix1.__m[0][2] * matrix2.__m[1][0]) + + (matrix1.__m[1][2] * matrix2.__m[1][1]) + + (matrix1.__m[2][2] * matrix2.__m[1][2]) + + (matrix1.__m[3][2] * matrix2.__m[1][3]); + m[2][2] = (matrix1.__m[0][2] * matrix2.__m[2][0]) + + (matrix1.__m[1][2] * matrix2.__m[2][1]) + + (matrix1.__m[2][2] * matrix2.__m[2][2]) + + (matrix1.__m[3][2] * matrix2.__m[2][3]); + m[3][2] = (matrix1.__m[0][2] * matrix2.__m[3][0]) + + (matrix1.__m[1][2] * matrix2.__m[3][1]) + + (matrix1.__m[2][2] * matrix2.__m[3][2]) + + (matrix1.__m[3][2] * matrix2.__m[3][3]); + + m[0][3] = (matrix1.__m[0][3] * matrix2.__m[0][0]) + + (matrix1.__m[1][3] * matrix2.__m[0][1]) + + (matrix1.__m[2][3] * matrix2.__m[0][2]) + + (matrix1.__m[3][3] * matrix2.__m[0][3]); + m[1][3] = (matrix1.__m[0][3] * matrix2.__m[1][0]) + + (matrix1.__m[1][3] * matrix2.__m[1][1]) + + (matrix1.__m[2][3] * matrix2.__m[1][2]) + + (matrix1.__m[3][3] * matrix2.__m[1][3]); + m[2][3] = (matrix1.__m[0][3] * matrix2.__m[2][0]) + + (matrix1.__m[1][3] * matrix2.__m[2][1]) + + (matrix1.__m[2][3] * matrix2.__m[2][2]) + + (matrix1.__m[3][3] * matrix2.__m[2][3]); + m[3][3] = (matrix1.__m[0][3] * matrix2.__m[3][0]) + + (matrix1.__m[1][3] * matrix2.__m[3][1]) + + (matrix1.__m[2][3] * matrix2.__m[3][2]) + + (matrix1.__m[3][3] * matrix2.__m[3][3]); + + return _Matrix3Df((const float*)m); +} + +class _Matrix3DfTr + : public _Matrix3Df +{ +public: + _Matrix3DfTr(float tx, float ty, float tz) + { + SetItem(0, 3, tx); + SetItem(1, 3, ty); + SetItem(2, 3, tz); + __complexity = TranslationMatrix; + } + + _Matrix3DfTr(const _Matrix3DfTr& rhs) + { + Assign(rhs); + } +}; // _Matrix3DfTr + +class _Matrix3DfRot + : public _Matrix3Df +{ +public: + _Matrix3DfRot(float angle, float x, float y, float z) + { + Rotate(angle, x, y, z); + __complexity = GenericMatrix; + } + + _Matrix3DfRot(const _Matrix3DfRot& rhs) + { + Assign(rhs); + } +}; // _Matrix3DfRot + +}}} // Tizen::Ui::Animations + +#endif //_FUI_ANIM_INTERNAL_MATRIX3DF_H_ + diff --git a/src/ui/inc/FUi_ModalLoopManager.h b/src/ui/inc/FUi_ModalLoopManager.h new file mode 100644 index 0000000..0f36d4a --- /dev/null +++ b/src/ui/inc/FUi_ModalLoopManager.h @@ -0,0 +1,90 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ModalLoopManager.h + * @brief This is the header file for the _ModalLoopManager class. + * + * This header file contains the declarations of the %_ModalLoopManager class. + */ + +#ifndef _FUI_INTERNAL_MODAL_LOOP_MANAGER_H_ +#define _FUI_INTERNAL_MODAL_LOOP_MANAGER_H_ + +#include +#include + +namespace Tizen { namespace Base { namespace Runtime +{ +class Timer; +}}} + +namespace Tizen { namespace Ui +{ + +class _ModalLoopManager + : public Tizen::Base::Runtime::ITimerEventListener +{ + class _TimerInfo { + public: + _TimerInfo(void); + ~_TimerInfo(void); + + bool operator== (const _TimerInfo& rhs) const; + bool operator!= (const _TimerInfo& rhs) const; + _TimerInfo& operator= (const _TimerInfo& rhs); + + public: + int loopId; + Tizen::Base::Runtime::Timer* pTimer; + int exitCode; + bool expired; + }; + typedef Tizen::Base::Collection::ArrayListT<_TimerInfo> TimerInfoList; + +public: + static void Initialize(void); + static _ModalLoopManager* GetInstance(void); + + int BeginMainLoop(void); + int BeginMainLoop(unsigned long timeOut, int exitCode); + int EndMainLoop(int exitCode, bool endAllLoops); + int GetLastExitCode(void); + + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + +private: + ~_ModalLoopManager(void); + _ModalLoopManager(void); + _ModalLoopManager(const _ModalLoopManager& rhs); + _ModalLoopManager& operator =(const _ModalLoopManager& rhs); + +public: + enum { + MODAL_LOOP_EXIT_CODE_APP_TERMINATION = -1, + MODAL_LOOP_EXIT_CODE_CONTINUOUS_TERMINATION = -2 + }; + +private: + static _ModalLoopManager* __pInstance; + TimerInfoList* __pTimerInfoList; + int __nestedMainLoop; + int __lastExitCode; +}; // _ModalLoopManager + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_MODAL_LOOP_MANAGER_H_ diff --git a/src/ui/inc/FUi_Pointf.h b/src/ui/inc/FUi_Pointf.h new file mode 100644 index 0000000..69a745f --- /dev/null +++ b/src/ui/inc/FUi_Pointf.h @@ -0,0 +1,106 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_Pointf.h + * @brief Header file of _Pointf class + * + * This file contains declarations _Pointf class. + */ + +#ifndef _FUI_ANIM_INTERNAL_POINTF_H_ +#define _FUI_ANIM_INTERNAL_POINTF_H_ + +#include + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _Pointf +{ +public: + _Pointf(void) + { + x = y = 0.0f; + } + + _Pointf(float _x, float _y) + : x(_x) + , y(_y) + { + } + + _Pointf(const _Pointf& point) { *this = point;} + _Pointf(const Tizen::Graphics::Point& point) { x = point.x; y = point.y;} + + bool operator ==(const _Pointf& point) const + { + return (x == point.x && y == point.y); + } + + bool operator !=(const _Pointf& point) const + { + return !(x == point.x && y == point.y); + } + + _Pointf& operator =(const _Pointf& point) + { + if (likely(&point != this)) + { + x = point.x; + y = point.y; + } + + return *this; + } + + _Pointf operator -(const _Pointf& point) const + { + return _Pointf(x - point.x, y - point.y); + } + + _Pointf operator +(const _Pointf& point) const + { + return _Pointf(x + point.x, y + point.y); + } + + void OffsetPoint(float xDelta, float yDelta) + { + x += xDelta; + y += yDelta; + } + + void SetPoint(float xPoint, float yPoint) + { + x = xPoint; + y = yPoint; + } + + float X(void) const { return x;} + float Y(void) const { return y;} + float& X(void) { return x;} + float& Y(void) { return y;} + +public: + float x; + float y; +}; // _Pointf + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_POINTF_H_ + diff --git a/src/ui/inc/FUi_PropertyBase.h b/src/ui/inc/FUi_PropertyBase.h new file mode 100644 index 0000000..8f1c5c9 --- /dev/null +++ b/src/ui/inc/FUi_PropertyBase.h @@ -0,0 +1,338 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_PropertyBase.h + * @brief This is the header file for the _PropertyBase class. + * + * This header file contains declarations of the _PropertyBase class. @n + */ +#ifndef _FUI_INTERNAL_PROPERTYBASE_H_ +#define _FUI_INTERNAL_PROPERTYBASE_H_ + +#include +#include +#include +#include +#include +#include +#include "FUi_IPropertyChangeEventListener.h" +#include "FUi_PropertyUtils.h" + +enum _PropertyType +{ + READ_ONLY = 0, + WRITE_ONLY, + READ_WRITE +}; + +namespace Tizen { namespace Ui +{ + +#define DECLARE_CLASS_BEGIN(classType, superClassType) \ +public: \ + typedef classType _THISCLASS; \ + typedef superClassType _SUPERCLASS; \ + class __register_property_class__ \ + : public Tizen::Ui::_RegisterPropertyBase \ + { \ +public: \ + __register_property_class__() \ + { + +#define DECLARE_PROPERTY(Name, GetName, SetName) \ + { \ + _RegisterPropertyBase::RegisterProperty<_THISCLASS>(Name, &_THISCLASS::GetName, &_THISCLASS::SetName); \ + } + +#define DECLARE_READONLY_PROPERTY(Name, GetName) \ + { \ + _RegisterPropertyBase::RegisterProperty<_THISCLASS>(Name, &_THISCLASS::GetName, null); \ + } + +#define DECLARE_WRITEONLY_PROPERTY(Name, SetName) \ + { \ + _RegisterPropertyBase::RegisterProperty<_THISCLASS>(Name, null, &_THISCLASS::SetName); \ + } + +#define DECLARE_CLASS_END() \ + } \ + virtual ~__register_property_class__(void) { } \ + }; \ +public: \ + static __register_property_class__ _registerPropertyClass; \ + virtual result SetProperty(const Tizen::Base::String & name, const Tizen::Ui::Variant &value) \ + { \ + ClearLastResult(); \ + result r = E_SUCCESS; \ + if (IsPropertyChangeEventListenerAdded()) \ + { \ + bool returnValue = _registerPropertyClass.IsPropertyAvailable<_THISCLASS>(this, name); \ + if (returnValue) \ + { \ + Tizen::Ui::Variant oldValue(GetProperty(name)); \ + _PropertyBase::FirePropertyEvent(*this, name, oldValue, value, false); \ + r = _registerPropertyClass.SetProperty<_THISCLASS>(this, name, value); \ + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); \ + _PropertyBase::FirePropertyEvent(*this, name, oldValue, value, true); \ + } \ + else \ + { \ + r = _SUPERCLASS::SetProperty(name, value); \ + return r; \ + } \ + } \ + else \ + { \ + r = _registerPropertyClass.SetProperty<_THISCLASS>(this, name, value); \ + if (r == E_KEY_NOT_FOUND) \ + { \ + r = _SUPERCLASS::SetProperty(name, value); \ + return r; \ + } \ + } \ + if (r != E_KEY_NOT_FOUND) \ + { \ + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); \ + } \ + return r; \ + } \ + virtual Tizen::Ui::Variant GetProperty(const Tizen::Base::String & name) const { \ + ClearLastResult(); \ + Tizen::Ui::Variant returnValue = _registerPropertyClass.GetProperty<_THISCLASS>(this, name); \ + if (GetLastResult() == E_KEY_NOT_FOUND) \ + { \ + returnValue = _SUPERCLASS::GetProperty(name); \ + return returnValue; \ + } \ + else \ + { \ + result r = GetLastResult();\ + SysTryReturn(NID_UI, r == E_SUCCESS, returnValue, r, "[%s] Propagating.", GetErrorMessage(r)); \ + } \ + return returnValue; \ + } + +#define IMPLEMENT_PROPERTY(classType) \ + classType::__register_property_class__ classType::_registerPropertyClass; + +template +class _Property + : public Tizen::Base::Object +{ +public: + typedef result (OwnType::*SetterType)(const Variant& value); + typedef Variant (OwnType::*GetterType)(void) const; + + _Property(void) + : __setter(null) + , __getter(null) + { + } + virtual ~_Property(void) + { + } + + void Register(GetterType getter, SetterType setter) { __setter = setter; __getter = getter; } + Variant GetProperty(const Object* pObject) const + { + return Variant((((OwnType*) pObject)->*__getter)()); + } + result SetProperty(const Object* pObject, const Variant& value) + { + OwnType* pOwnType = (OwnType*) pObject; + return (pOwnType->*__setter)(value); + } + bool IsReadOnly(void) const { return __setter == null; } + bool IsWriteOnly(void) const { return __getter == null; } + +private: + SetterType __setter; + GetterType __getter; +}; // _Property + +class _RegisterPropertyBase + : public Tizen::Base::Object +{ +public: + _RegisterPropertyBase() + { + __pHashMap = null; + } + virtual ~_RegisterPropertyBase(void) + { + if (__pHashMap) + { + __pHashMap->RemoveAll(true); + delete __pHashMap; + } + } + + template + result SetProperty(const Object* pObject, const Tizen::Base::String& name, const Variant& value) + { + ClearLastResult(); + + Tizen::Base::Collection::HashMap* pMap = GetHashMap(); + _Property* pProperty = null; + if (pMap != null) + { + pProperty = static_cast<_Property*>(pMap->GetValue(name)); + if (pProperty != null) + { + SysTryReturn(NID_UI, !pProperty->IsReadOnly(), E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + return pProperty->SetProperty(pObject, value); + } + } + return E_KEY_NOT_FOUND; + } + + template + Variant GetProperty(const Object* pObject, const Tizen::Base::String& name) const + { + ClearLastResult(); + + Tizen::Base::Collection::HashMap* pMap = GetHashMap(); + _Property* pProperty = null; + if (pMap != null) + { + pProperty = static_cast<_Property*>(pMap->GetValue(name)); + if (pProperty != null) + { + SysTryReturn(NID_UI, !pProperty->IsWriteOnly(), Variant(), E_INVALID_OPERATION, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + return pProperty->GetProperty(pObject); + } + else + { + SetLastResult(E_KEY_NOT_FOUND); + } + } + + return Variant::NULL_VARIANT; + } + + template + bool IsPropertyAvailable(const Object* pObject, const Tizen::Base::String& name) const + { + Tizen::Base::Collection::HashMap* pMap = GetHashMap(); + _Property* pProperty = null; + if (pMap != null) + { + pProperty = static_cast<_Property*>(pMap->GetValue(name)); + if (pProperty != null) + { + return true; + } + } + + return false; + } + + template + void RegisterProperty(const Tizen::Base::String& propertyName, typename _Property::GetterType getter, typename _Property::SetterType setter) + { + ClearLastResult(); + result r = E_SUCCESS; + + Tizen::Base::Collection::HashMap* pMap = GetHashMap(); + if (pMap != null) + { + // create the property name key in the HashMap + bool hasKey = true; + r = pMap->ContainsKey(propertyName, hasKey); + if (!IsFailed(r) && hasKey == false) + { + _Property* pProperty = new (std::nothrow) _Property; + if (pProperty == null) + { + SysLog(NID_UI, "[E_OUT_OF_MEMORY] Unable to create _Property."); + SetLastResult(E_OUT_OF_MEMORY); + return; + } + pProperty->Register(getter, setter); + pMap->Add(*(new (std::nothrow) Tizen::Base::String(propertyName)), *pProperty); + } + } + } + + result InitHashMap(void) + { + result r = E_SUCCESS; + + if (__pHashMap == null) + { + __pHashMap = new (std::nothrow) Tizen::Base::Collection::HashMap; + if (__pHashMap == null) + { + return E_OUT_OF_MEMORY; + } + + r = __pHashMap->Construct(16, 0.75f, *_PropertyUtils::GetInstance()->GetStringHashProvider(), *_PropertyUtils::GetInstance()->GetStringComparer()); + } + + return r; + } + + Tizen::Base::Collection::HashMap* GetHashMap(void) const + { + result r = E_SUCCESS; + + _RegisterPropertyBase& thisObject = const_cast<_RegisterPropertyBase&>(*this); + if (__pHashMap == null) + { + r = thisObject.InitHashMap(); + if (r != E_SUCCESS) + { + SysLog(NID_UI, "[E_OUT_OF_MEMORY] Unable to create HashMap."); + SetLastResult(E_OUT_OF_MEMORY); + return null; + } + } + return __pHashMap; + } + +private: + _RegisterPropertyBase(const _RegisterPropertyBase&); + _RegisterPropertyBase& operator =(const _RegisterPropertyBase&); + Tizen::Base::Collection::HashMap* __pHashMap; +}; // _RegisterPropertyBase + +class _OSP_EXPORT_ _PropertyBase + : public Tizen::Base::Object +{ +public: + _PropertyBase(void); + virtual ~_PropertyBase(void); + + virtual result SetProperty(const Tizen::Base::String& name, const Variant& value); + virtual Variant GetProperty(const Tizen::Base::String& name) const; + + result AddPropertyChangeEventListener(const Tizen::Ui::_IPropertyChangeEventListener& listener); + result RemovePropertyChangeEventListener(const Tizen::Ui::_IPropertyChangeEventListener& listener); + result SetPropertyChangeEventListener(const Tizen::Ui::_IPropertyChangeEventListener* pListener); + bool FirePropertyEvent(const Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldValue, const Variant& newValue, bool isChangedEvent = false); + bool IsPropertyChangeEventListenerAdded(void) const; + +private: + _PropertyBase(const _PropertyBase&); + _PropertyBase& operator =(const _PropertyBase&); + Tizen::Ui::_IPropertyChangeEventListener* __pPropertyChangeEventListener; +}; // _PropertyBase + +} } // Tizen::Ui + +#endif //_FUI_INTERNAL_PROPERTYBASE_H_ + diff --git a/src/ui/inc/FUi_PropertyUtils.h b/src/ui/inc/FUi_PropertyUtils.h new file mode 100644 index 0000000..8e821a1 --- /dev/null +++ b/src/ui/inc/FUi_PropertyUtils.h @@ -0,0 +1,76 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_PropertyUtils.h + * @brief This is the header file for the _PropertyUtils class. + * + * This header file contains declarations of the _PropertyUtils class. @n + */ +#ifndef _FUI_INTERNAL_PROPERTY_UTILS_H_ +#define _FUI_INTERNAL_PROPERTY_UTILS_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ + +class _StringComparer + : public Tizen::Base::Collection::IComparer +{ +public: + _StringComparer(void); + virtual ~_StringComparer(void); + virtual result Compare(const Tizen::Base::Object& obj1, const Tizen::Base::Object& obj2, int& cmp) const; +}; // StringComparer + +class _StringHashProvider + : public Tizen::Base::Collection::IHashCodeProvider +{ +public: + _StringHashProvider(void); + virtual ~_StringHashProvider(void); + + virtual int GetHashCode(const Tizen::Base::Object& obj) const; +}; // StringComparer + +class _OSP_EXPORT_ _PropertyUtils + : public Tizen::Base::Object +{ +public: + _PropertyUtils(void); + virtual ~_PropertyUtils(void); + static _PropertyUtils* GetInstance(void); + result Construct(void); + const _StringComparer* GetStringComparer(void) const; + const _StringHashProvider* GetStringHashProvider(void) const; + +private: + _PropertyUtils(const _PropertyUtils&); + _PropertyUtils& operator =(const _PropertyUtils&); + +private: + _StringComparer* __pStringComparer; + _StringHashProvider* __pStringHashProvider; +}; // PropertyUtils + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_PROPERTY_UTILS_H_ + diff --git a/src/ui/inc/FUi_PublicOrientationEvent.h b/src/ui/inc/FUi_PublicOrientationEvent.h new file mode 100644 index 0000000..0c0548b --- /dev/null +++ b/src/ui/inc/FUi_PublicOrientationEvent.h @@ -0,0 +1,71 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_PublicOrientationEvent.h + * @brief This is the header file for _PublicOrientationEvent class. + * @version 1.0 + * + * This header file contains declaration of _PublicOrientationEvent class. + * The OrientationEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_INTERNAL_PUBLIC_ORIENTATION_EVENT_H_ +#define _FUI_INTERNAL_PUBLIC_ORIENTATION_EVENT_H_ + +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class Control; + +/** + * @class _PublicOrientationEvent + * @brief This class handles a orientation event. It is inherited from Event class. + * + * The Window(root of all widgets) class has an instance of the OrientationEvent class as a member variable. + * Applications can register orientation event listeners through it. When a orientation event occurred, + * the OrientationEvent class finds listener and calls the appropriate listener's method. + */ +class _OSP_EXPORT_ _PublicOrientationEvent + : public Tizen::Base::Runtime::_Event +{ +public: + static _PublicOrientationEvent* CreateInstanceN(const Control& source); + static Tizen::Base::Runtime::IEventArg* CreateOrientationEventArgN(const Control& source, OrientationStatus orientationStatus); + + virtual ~_PublicOrientationEvent(void); + + const Control* GetSource(void) const; + +private: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + + _PublicOrientationEvent(const Control& source); + + _PublicOrientationEvent(const _PublicOrientationEvent& rhs); + _PublicOrientationEvent& operator =(const _PublicOrientationEvent& rhs); + +private: + const Control* __pSource; +}; // _PublicOrientationEvent + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_PUBLIC_ORIENTATION_EVENT_H_ diff --git a/src/ui/inc/FUi_Rectanglef.h b/src/ui/inc/FUi_Rectanglef.h new file mode 100644 index 0000000..8dc57eb --- /dev/null +++ b/src/ui/inc/FUi_Rectanglef.h @@ -0,0 +1,273 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_Rectanglef.h + * @brief Header file of _Rectanglef class + * + * This file contains declarations _Rectanglef class. + */ + +#ifndef _FUI_ANIM_INTERNAL_RECTANGLEF_H_ +#define _FUI_ANIM_INTERNAL_RECTANGLEF_H_ + +#include + +#include "FUi_Math.h" +#include "FUi_Pointf.h" +#include "FUi_Dimensionf.h" + +namespace Tizen { namespace Ui { namespace Animations +{ + +class _Rectanglef +{ +public: + _Rectanglef(void) + { + __left = __top = __width = __height = 0.0f; + } + + _Rectanglef(float left, float top, float width, float height) + { + __left = left; + __top = top; + __width = width; + __height = height; + } + + _Rectanglef(const Tizen::Graphics::Rectangle& rt) + { + __left = static_cast(rt.x); + __top = static_cast(rt.y); + __width = static_cast(rt.width); + __height = static_cast(rt.height); + } + + _Rectanglef(const Tizen::Graphics::FloatRectangle& rt) + { + __left = rt.x; + __top = rt.y; + __width = rt.width; + __height = rt.height; + } + + _Rectanglef(const _Rectanglef& rt) { *this = rt;} + + bool operator ==(const _Rectanglef& rt) const + { + return (__left == rt.__left && __top == rt.__top && __width == rt.__width && __height == rt.__height); + } + + bool operator ==(const Tizen::Graphics::FloatRectangle& rt) const + { + return (__left == rt.x && __top == rt.y && __width == rt.width && __height == rt.height); + } + + bool operator !=(const _Rectanglef& rt) const + { + return !(__left == rt.__left && __top == rt.__top && __width == rt.__width && __height == rt.__height); + } + + bool operator !=(const Tizen::Graphics::FloatRectangle& rt) const + { + return !(__left == rt.x && __top == rt.y && __width == rt.width && __height == rt.height); + } + + _Rectanglef& operator =(const _Rectanglef& rt) + { + if (&rt != this) + { + __left = rt.__left; + __top = rt.__top; + __width = rt.__width; + __height = rt.__height; + } + + return *this; + } + + _Rectanglef& operator =(const Tizen::Graphics::FloatRectangle& rt) + { + __left = rt.x; + __top = rt.y; + __width = rt.width; + __height = rt.height; + + return *this; + } + operator Tizen::Graphics::Rectangle(void) const + { + return Tizen::Graphics::Rectangle( + static_cast(__left), + static_cast(__top), + static_cast(__left + __width) - static_cast(__left), + static_cast(__top + __height) - static_cast(__top) + ); + } + + bool IsEmpty(void) const + { + if (__width <= 0.0f || __height <= 0.0f) + return true; + + return false; + } + + void SetEmpty(void) + { + __left = __top = __width = __height = 0.0f; + } + + bool IsIntersected(const _Rectanglef& rt) const + { + if (IsEmpty() || rt.IsEmpty()) + return false; + + if (__left >= rt.Right()) + return false; + + if (__top >= rt.Bottom()) + return false; + + if (Right() <= rt.__left) + return false; + + if (Bottom() <= rt.__top) + return false; + + return true; + } + + /* TODO: rename method names such as MakeIntersect */ + _Rectanglef Intersect(const _Rectanglef& rt) const + { + _Rectanglef retRect; + + if (IsIntersected(rt)) + { + retRect.__left = _Max(__left, rt.__left); + retRect.__top = _Max(__top, rt.__top); + retRect.__width = _Min(Right(), rt.Right()) - retRect.__left; + retRect.__height = _Min(Bottom(), rt.Bottom()) - retRect.__top; + } + + return retRect; + } + + _Rectanglef Union(const _Rectanglef& rt) const + { + _Rectanglef retRect; + + if (IsEmpty()) + { + if (rt.IsEmpty()) + return _Rectanglef(); + + return rt; + } + else + { + if (rt.IsEmpty()) + return *this; + } + + retRect.__left = _Min(__left, rt.__left); + retRect.__top = _Min(__top, rt.__top); + retRect.__width = _Max(Right(), rt.Right()) - retRect.__left; + retRect.__height = _Max(Bottom(), rt.Bottom()) - retRect.__top; + + return retRect; + } + + void OffsetRect(const _Pointf& point) + { + __left += point.X(); + __top += point.Y(); + } + + void OffsetRect(float dx, float dy) + { + __left += dx; + __top += dy; + } + + void InflateRect(float dx, float dy) + { + __left -= dx; + __top -= dy; + __width += dx + dx; + __height += dy + dy; + } + + void SetRect(float l, float t, float w, float h) + { + __left = l; + __top = t; + __width = w; + __height = h; + } + + bool Contains(float x, float y) const + { + return (x >= __left && x < Right() && y >= __top && y < Bottom()); + } + + bool Contains(const _Pointf& pt) const + { + return Contains(pt.x, pt.y); + } + + bool Contains(const _Rectanglef& rt) const + { + return (!rt.IsEmpty() && __left <= rt.__left && __top <= rt.__top && Right() >= rt.Right() && Bottom() >= rt.Bottom()); + } + + _Rectanglef& SetLeftTop(float left, float top) { __left = left;__top = top;return *this;} + _Rectanglef& SetLeftTop(const _Pointf& leftTop) { __left = leftTop.X();__top = leftTop.Y();return *this;} + _Rectanglef& SetSize(const _Dimensionf& size) { __width = size.Width();__height = size.Height();return *this;} + + _Pointf LeftTop(void) const { return _Pointf(__left, __top);} + _Pointf RightBottom(void) const { return _Pointf(__left + __width, __top + __height);} + + float& Left(void) { return __left;} + float& Top(void) { return __top;} + float& Width(void) { return __width;} + float& Height(void) { return __height;} + + float Left(void) const { return __left;} + float Top(void) const { return __top;} + float Right(void) const { return __left + __width;} + float Bottom(void) const { return __top + __height;} + float Width(void) const { return __width;} + float Height(void) const { return __height;} + + int IntegralLeft(void) const { return (int) __left;} + int IntegralTop(void) const { return (int) __top;} + int IntegralWidth(void) const { return (int) Right() - IntegralLeft();} + int IntegralHeight(void) const { return (int) Bottom() - IntegralTop();} + +private: + float __left; + float __top; + float __width; + float __height; +}; // _Rectanglef + +}}} // Tizen::Ui::Animations + +#endif // _FUI_ANIM_INTERNAL_RECTANGLEF_H_ diff --git a/src/ui/inc/FUi_ResourceManager.h b/src/ui/inc/FUi_ResourceManager.h new file mode 100644 index 0000000..bb9a387 --- /dev/null +++ b/src/ui/inc/FUi_ResourceManager.h @@ -0,0 +1,166 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceManager.h + * @brief This is the header file for _ResourceManager class. + * @version 3.0 + * + * This header file contains declaration of _ResourceManager class. + * The ActionEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_INTERNAL_RESOURCE_MANAGER_H_ +#define _FUI_INTERNAL_RESOURCE_MANAGER_H_ + +#include +#include +#include +#include "FUi_ControlManager.h" + +namespace Tizen { namespace Base +{ +class Integer; +}}//Tizen::Base:: + +namespace Tizen { namespace Base { namespace Collection +{ +template class ArrayListT; +}}} + +namespace Tizen { namespace Graphics +{ +class Bitmap; +class Dimension; +class Color; +class _ICoordinateSystemTransformer; +}}//Tizen::Graphics + +namespace Tizen { namespace Ui { namespace _Resource +{ +class StringLoader; +class ConfigLoader; +class MapContainer; +}}} + +namespace Tizen { namespace Ui +{ + namespace Controls { namespace __Internal + { + const int OVERLAY_REGION_MIN_LENGTH = 16; + }}//Tizen::Ui::Controls::__Internal + +#define GET_SHAPE_CONFIG(shapeId, orientation, x)\ + Tizen::Ui::_ResourceManager::GetInstance()->GetShape(#shapeId, orientation, x); + +#define GET_DIMENSION_CONFIG(dimensionId, orientation, x)\ + Tizen::Ui::_ResourceManager::GetInstance()->GetDimension(#dimensionId, orientation, x); + +#define GET_COLOR_CONFIG(colorId, x) \ + Tizen::Ui::_ResourceManager::GetInstance()->GetColor(#colorId, x); + +#define GET_BITMAP_CONFIG_N(bitmapId, pixelFormat, pOutBitmap)\ + Tizen::Ui::_ResourceManager::GetInstance()->GetBitmapN(#bitmapId, pixelFormat, _CONTROL_ORIENTATION_PORTRAIT, pOutBitmap); + +#define GET_STRING_CONFIG(stringId, string)\ + Tizen::Ui::_ResourceManager::GetInstance()->GetString(#stringId, string); + +#define GET_FIXED_VALUE_CONFIG(fixedValueId, orientation, x)\ + Tizen::Ui::_ResourceManager::GetInstance()->GetFixedValue(#fixedValueId, orientation, x); + +#define IS_CUSTOM_BITMAP(bitmapId) \ + Tizen::Ui::_ResourceManager::GetInstance()->IsCustomBitmap(#bitmapId); + +#define IS_CUSTOM_COLOR(colorId) \ + Tizen::Ui::_ResourceManager::GetInstance()->IsCustomColor(#colorId); + + +class _OSP_EXPORT_ _ResourceManager +{ +public: + static _ResourceManager* GetInstance(void); + result GetBitmapN(const Tizen::Base::String& bitmapId, Tizen::Graphics::BitmapPixelFormat pixelFormat, _ControlOrientation orientation, Tizen::Graphics::Bitmap*& pBitmap); + result GetString(const Tizen::Base::String& stringId, Tizen::Base::String& string); + result GetColor(const Tizen::Base::String& colorId, Tizen::Graphics::Color& color); + result GetShape(const Tizen::Base::String& shapeId, _ControlOrientation orientation, int& value); + result GetFixedValue(const Tizen::Base::String& shapeId, _ControlOrientation orientation, int& value); + result GetDimension(const Tizen::Base::String& dimensionId, _ControlOrientation orientation, Tizen::Graphics::Dimension& dimension); + void GetThemeName(Tizen::Base::String& systemTheme, Tizen::Base::String& userTheme) const; + void ReloadTheme(Tizen::Base::String& themeName, bool userdefine); + bool IsCustomColor(const Tizen::Base::String& colorId); + bool IsCustomBitmap(const Tizen::Base::String& bitmapId); + + +private: + _ResourceManager(void); + ~_ResourceManager(void); + static void CreateInstance(void); + + _ResourceManager(const _ResourceManager& rhs); + _ResourceManager& operator =(const _ResourceManager& rhs); + + enum MapContainerType + { + MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT = 0, + MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE = 1, + MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT = 2, + MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE = 3, + MAP_CONTAINER_TYPE_MAX = 4, + }; + result GetBitmapInternalN(const Tizen::Base::String& fileName, Tizen::Graphics::BitmapPixelFormat pixelFormat, _ControlOrientation orientation, Tizen::Graphics::Bitmap*& pBitmap); + result GetDefaultShapeWithScaling(const Tizen::Base::String& shapeId, _ControlOrientation orientation, Tizen::Base::Integer& integer); + result GetDefaultShapeWithScaling(const Tizen::Base::String& shapeId, _ControlOrientation orientation, Tizen::Graphics::Dimension& dimension); + result LoadThemeInformation(Tizen::Base::String& systemTheme, Tizen::Base::String& userTheme); + bool InitializeTheme(_Resource::MapContainer& mapContainer); + void LoadConfig(const Tizen::Base::String& resolution, _Resource::MapContainer& mapContainer); + _Resource::MapContainer* GetMapContainer(MapContainerType type); + void SetSystemColor(void); + Tizen::Base::String FindImagePath(const Tizen::Base::String& fileName, int& findFolder); + bool GetDensityDirectory(const Tizen::Base::String directoryName, float scaleFactor); + bool GetResolutionDirectory(const Tizen::Base::String directoryName, float scaleFactor); + +private: + + struct ResourceFallbackItem + { + float scaleFactor; + Tizen::Base::String directoryName; + }; + + _Resource::StringLoader* __pStringLoader; + _Resource::MapContainer* __pMapContainer[MAP_CONTAINER_TYPE_MAX]; + Tizen::Graphics::_ICoordinateSystemTransformer* __pTransformer; + Tizen::Base::String __appBasePortraitMode; + Tizen::Base::String __appBaseLandscapeMode; + Tizen::Base::String __targetPortraitMode; + Tizen::Base::String __targetLandscapeMode; + Tizen::Base::String __defaultPortraitMode; + Tizen::Base::String __defaultLandscapeMode; + Tizen::Base::String __systemTheme; + Tizen::Base::String __userTheme; + bool __appliedUserTheme; + int __appBaseWidth; + int __appBaseHeight; + int __targetWidth; + int __targetHeight; + int __deviceDPI; + Tizen::Base::Collection::ArrayListT* __pFallbackList; +}; + +}}//Tizen::Ui + +#endif // _FUI_INTERNAL_RESOURCE_MANAGER_H_ diff --git a/src/ui/inc/FUi_ResourceSizeInfo.h b/src/ui/inc/FUi_ResourceSizeInfo.h new file mode 100644 index 0000000..6043ae4 --- /dev/null +++ b/src/ui/inc/FUi_ResourceSizeInfo.h @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceSizeInfo.h + * @brief This is the header file for _ResourceSizeInfo class. + * @version 3.0 + * + * This header file contains declaration of _ResourceSizeInfo class. + * The ActionEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_INTERNAL_RESOURCE_SIZE_INFO_H_ +#define _FUI_INTERNAL_RESOURCE_SIZE_INFO_H_ + +#include +#include +#include "FUi_ControlImpl.h" + + +#define GET_SIZE_INFO(x) Tizen::Ui::_Resource::SizeInfo::Get##x##SizeInfo() +#define FUNC_SIZE_INFO(x) Tizen::Ui::_Resource::SizeInfo::Get##x##SizeInfo + +namespace Tizen { namespace Ui { namespace _Resource +{ + +class _OSP_EXPORT_ SizeInfo +{ +public: + static Tizen::Ui::_ControlImpl::SizeInfo& GetButtonSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetCheckButtonSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetLabelSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetRadioGroupSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetColorPickerSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetDatePickerSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetDateTimePickerSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetFormSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetTimePickerSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetPopupSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetProgressSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetSliderSizeInfo(int sliderStyle); + static Tizen::Ui::_ControlImpl::SizeInfo& GetEditAreaSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetEditFieldSizeInfo(bool isSmallStyle, Tizen::Ui::Controls::EditFieldTitleStyle titleStlye = Tizen::Ui::Controls::EDIT_FIELD_TITLE_STYLE_NONE); + static Tizen::Ui::_ControlImpl::SizeInfo& GetExpandableEditAreaSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetSearchBarSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetTabBarSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetCustomListSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetExpandableListSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetGroupedListSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetListSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetOverlayPanelSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetSlidableListSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetWebSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetMapSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetEditDateSizeInfo(bool titleStyle); + static Tizen::Ui::_ControlImpl::SizeInfo& GetEditTimeSizeInfo(bool titleStyle); + static Tizen::Ui::_ControlImpl::SizeInfo& GetTableViewSizeInfo(void); + static Tizen::Ui::_ControlImpl::SizeInfo& GetTableViewItemSizeInfo(void); +}; + +}}}//Tizen::Ui + +#endif //_FUI_INTERNAL_RESOURCE_SIZE_INFO_H_ diff --git a/src/ui/inc/FUi_SharedPtr.h b/src/ui/inc/FUi_SharedPtr.h new file mode 100644 index 0000000..0a8d940 --- /dev/null +++ b/src/ui/inc/FUi_SharedPtr.h @@ -0,0 +1,171 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_INTERNAL_SHARED_PTR_H_ +#define _FUI_INTERNAL_SHARED_PTR_H_ + +#include + +namespace Tizen { namespace Ui +{ + +template +class _SharedPtr +{ +protected: + BaseType* _pInstance; + unsigned int* _useCount; + +public: + _SharedPtr(void) + : _pInstance(0) + , _useCount(0) + { + } + + explicit _SharedPtr(BaseType* pInstance) + : _pInstance(pInstance) + , _useCount(new (std::nothrow) unsigned int (1)) + { + } + + _SharedPtr(const _SharedPtr& refInstance) + : _pInstance(0) + , _useCount(0) + { + _pInstance = refInstance._pInstance; + _useCount = refInstance._useCount; + + if (_useCount) + ++(*_useCount); + } + + virtual ~_SharedPtr(void) + { + _Release(); + } + + _SharedPtr& operator =(const _SharedPtr& refInstance) + { + if (_pInstance == refInstance._pInstance) + { + return *this; + } + + _Release(); + { + _pInstance = refInstance._pInstance; + _useCount = refInstance._useCount; + if (_useCount) + { + ++(*_useCount); + } + } + + return *this; + } + + inline BaseType& operator *(void) const + { + // assert(_pInstance); + return *_pInstance; + } + + inline BaseType* operator ->(void) const + { + return _pInstance; + } + + inline BaseType* Get(void) const + { + return _pInstance; + } + + void Bind(BaseType* rep) + { + if (!_pInstance && !_useCount) + { + _useCount = new (std::nothrow) unsigned int(1); + _pInstance = rep; + } + } + + inline bool Unique(void) const + { + return (_useCount) ? (*_useCount == 1) : true; + } + + inline unsigned int UseCount() const + { + return (_useCount) ? *_useCount : 0; + } + + inline unsigned int* UseCountPointer(void) const + { + return _useCount; + } + + inline bool IsNull(void) const + { + return (_pInstance == 0); + } + + inline void SetNull(void) + { + if (_pInstance) + { + _Release(); + _pInstance = 0; + _useCount = 0; + } + } + +protected: + inline void _Release(void) + { + if (_useCount) + { + if (--(*_useCount) == 0) + { + _Destroy(); + } + } + } + + virtual void _Destroy(void) + { + delete _pInstance; + delete _useCount; + } +}; + +template inline bool +operator ==(_SharedPtr const& a, _SharedPtr const& b) +{ + return a.Get() == b.Get(); +} + +template inline bool +operator !=(_SharedPtr const& a, _SharedPtr const& b) +{ + return a.Get() != b.Get(); +} + +}} // Tizen::Ui + + +#endif // _FUI_INTERNAL_SHARED_PTR_H_ diff --git a/src/ui/inc/FUi_TouchEventArg.h b/src/ui/inc/FUi_TouchEventArg.h new file mode 100644 index 0000000..d9b8565 --- /dev/null +++ b/src/ui/inc/FUi_TouchEventArg.h @@ -0,0 +1,144 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_TouchEventArg.h +* @brief This is the header file for _TouchEventArg class. +* @version 2.0 +* +* This header file contains declarations of _TouchEventArg class. +*/ + +#ifndef _FUI_TOUCH_EVENT_ARG_H_ +#define _FUI_TOUCH_EVENT_ARG_H_ + +// includes +#include +#include +#include +#include +#include +#include "FUi_UiTouchEvent.h" + + +namespace Tizen { namespace Ui +{ + +/** + * @class _TouchEventArg + * + * @brief This class is used as tje argument to touch event listener. + * + * This class is used as the argument of touch event listener. When touch event event is generated, + * the @c TouchEvent instance calls the registered ITouchEventListener with an instance of this + * class as the argument. + * + */ +class _TouchEventArg + : public Tizen::Base::Object + , public Tizen::Base::Runtime::IEventArg +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + * @param[in] source - A pointer to the Object instance which contains this instance. + * @param[in] status - TouchStatus + */ + _TouchEventArg(const Tizen::Ui::Control& source, _TouchStatus status); + + + /** + * This is the class destructor. + */ + virtual ~_TouchEventArg(void); + + +// Access +public: + /** + * This method returns the object which the event initially occurred. + * + * @return The object which the event initially occurred. + */ + const Tizen::Ui::Control* GetSource(void) const; + + /** + * This method sets the positions of touch event on the window rectangle coordination. + * @param[in] PointId - PointId of the touch event + * @param[in] startX - x coordinate of the original touch pressed event + * @param[in] startY - y coordinate of the original touch pressed event + * @param[in] currentX - x coordinate of the current touch event + * @param[in] currentY - y coordinate of the currenttouch event + */ + void SetTouchPosition(unsigned long PointId, int startX, int startY, int currentX, int currentY); + + /** + * This method returns the touch id + * + * @return see the above + */ + unsigned long GetPointId(void) const; + + /** + * This method returns the touch status + * + * @return see the above + */ + _TouchStatus GetTouchStatus(void) const; + + /** + * This method returns the start position of touch pressed event on the window rectangle coordination. + * + * @return see the above + */ + const Tizen::Graphics::Point GetStartPosition(void) const; + + /** + * This method returns the current position of touch event on the window rectangle coordination. + * + * @return see the above + */ + const Tizen::Graphics::Point GetCurrentPosition(void) const; + + /** + * This method sets the positions of touch event on the window rectangle coordination. + * + * @param[in] isFlicked - Flag whether it is flicked. + */ + void SetFlickedStatus(bool isFlicked); + + /** + * This method returns the flicked status + * + * @return see the above + */ + bool IsFlicked(void) const; + +// Attributes +private: + unsigned long __PointId; + Tizen::Ui::Control* __pSource; + _TouchStatus __touchStatus; + Tizen::Graphics::Point __startPosition; + Tizen::Graphics::Point __currentPosition; + bool __isFlicked; +}; // _TouchEventArg + +} } // Tizen::Ui + +#endif // _FUI_TOUCH_EVENT_ARG_H_ diff --git a/src/ui/inc/FUi_TouchEventInfoImpl.h b/src/ui/inc/FUi_TouchEventInfoImpl.h new file mode 100644 index 0000000..2ac92fa --- /dev/null +++ b/src/ui/inc/FUi_TouchEventInfoImpl.h @@ -0,0 +1,97 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_TouchEventInfoImpl.h +* @brief This is the header file for _TouchEventInfoImpl class. +* @version 2.0 +* +* This header file contains declarations of _TouchEventInfoImpl class. +*/ + +#ifndef _FUI_INTERNAL_TOUCH_EVENT_INFO_IMPL_H_ +#define _FUI_INTERNAL_TOUCH_EVENT_INFO_IMPL_H_ + +#include +#include +#include "FUi_UiTouchEvent.h" + +namespace Tizen { namespace Ui +{ + +class TouchEventInfo; +/** + * @class _TouchEventInfoImpl + * + * @brief This class is used as the argument to touch event listener. + * + * This class is used as the argument of touch event listener. When touch event event is generated, + * the @c TouchEvent instance calls the registered ITouchEventListener with an instance of this + * class as the argument. + * + */ +class _TouchEventInfoImpl + : public Tizen::Base::Object +{ +public: + static _TouchEventInfoImpl* CreateInstanceN(TouchEventInfo* pPublic); + + ~_TouchEventInfoImpl(void); + + void SetTouchEventInfo(const _TouchInfo& touchInfo, const Tizen::Graphics::Point startPosition); + + unsigned long GetPointId(void) const; + + Tizen::Graphics::Point GetStartPosition(void) const; + + Tizen::Graphics::Point GetCurrentPosition(void) const; + + _TouchStatus GetTouchStatus(void) const; + + bool IsFlicked(void) const; + +private: + /** + * This is the default class constructor. + * + * @param[in] source - A pointer to the Object instance which contains this instance. + * @param[in] status - TouchStatus + */ + _TouchEventInfoImpl(TouchEventInfo* pPublic); + + /* + * This is the copy constructor for this class. + */ + _TouchEventInfoImpl(const _TouchEventInfoImpl&); + + /** + * This is the assignment operator for this class. + */ + _TouchEventInfoImpl& operator =(const _TouchEventInfoImpl&); + +// Attributes +private: + TouchEventInfo* __pPublic; + unsigned long __pointId; + _TouchStatus __touchStatus; + Tizen::Graphics::Point __startPosition; + Tizen::Graphics::Point __currentPosition; + bool __isFlicked; +}; // TouchEventInfo + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_TOUCH_EVENT_INFO_IMPL_H_ diff --git a/src/ui/inc/FUi_TouchEventManagerImpl.h b/src/ui/inc/FUi_TouchEventManagerImpl.h new file mode 100644 index 0000000..e0eb3a4 --- /dev/null +++ b/src/ui/inc/FUi_TouchEventManagerImpl.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_TouchEventManagerImpl.h + * @brief This is the header file for the %_TouchEventManagerImpl class. + * + * This header file contains the declarations of the %_TouchEventManagerImpl class. + * + */ + +#ifndef _FUI_INTERNAL_TOUCH_EVENT_MANAGER_IMPL_H_ +#define _FUI_INTERNAL_TOUCH_EVENT_MANAGER_IMPL_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ + +/** + * @class _TouchEventManagerImpl + * @brief This class stores the information of each touch events. + * + * @since 2.0 + * + * @final This class is not intended for extension. + * + * The %_TouchEventManagerImpl class provides the touch event information: touch position, status, ID, and so on. + * @see TouchEventInfo + * + */ +class _OSP_EXPORT_ _TouchEventManagerImpl + : public Tizen::Base::Object +{ +public: + _TouchEventManagerImpl(void); + virtual ~_TouchEventManagerImpl(void); + + Tizen::Base::Collection::IListT* GetTouchInfoListN(void) const; + +private: + _TouchEventManagerImpl(const _TouchEventManagerImpl& value); + _TouchEventManagerImpl& operator =(const _TouchEventManagerImpl& value); +}; // _TouchEventManagerImpl + +} } //Tizen::Ui + +#endif // _FUI_INTERNAL_TOUCH_EVENT_MANAGER_IMPL_H_ \ No newline at end of file diff --git a/src/ui/inc/FUi_TouchFlickGestureDetector.h b/src/ui/inc/FUi_TouchFlickGestureDetector.h new file mode 100644 index 0000000..94ef41a --- /dev/null +++ b/src/ui/inc/FUi_TouchFlickGestureDetector.h @@ -0,0 +1,99 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchFlickGestureDetector.h + * @brief This is the header file for the %_TouchFlickGestureDetector class. + * + * This header file contains the declarations of the %_TouchFlickGestureDetector class. + * + */ + +#ifndef _FUI_INTERNAL_TOUCH_FLICK_GESTURE_DETECTOR_H_ +#define _FUI_INTERNAL_TOUCH_FLICK_GESTURE_DETECTOR_H_ + +#include "FUi_TouchGestureDetector.h" +#include "FUi_UiTouchEvent.h" + +namespace Tizen { namespace Ui +{ + +enum _FlickDirection +{ + _FLICK_DIRECTION_NONE = -1, + _FLICK_DIRECTION_RIGHT, + _FLICK_DIRECTION_UP, + _FLICK_DIRECTION_LEFT, + _FLICK_DIRECTION_DOWN +}; + +struct _FlickInfo +{ + int x; + int y; + int time; + _TouchStatus touchStatus; +}; + +/** + * @class _TouchFlickGestureDetector + * @brief + * @since 2.0 + * + */ +class _OSP_EXPORT_ _TouchFlickGestureDetector + : public _TouchGestureDetector +{ +public: + _TouchFlickGestureDetector(void); + virtual ~_TouchFlickGestureDetector(void); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + void GetDistance(int& x, int &y) const; + int GetDuration(void) const; + _FlickDirection GetDirection(void) const; + +private: + void CheckMoveMinMax(const int x, const int y); + void ClearVariables(void); + bool FindFlickWindow(const Tizen::Base::Collection::ArrayListT<_FlickInfo*>* pList, const _FlickInfo* pFlickInfo, int* pStartIndex, int* pEndIndex); + bool CalculateFlick(const Tizen::Base::Collection::ArrayListT<_FlickInfo*>* pList, const _FlickInfo* pFlickInfo, _FlickInfo* pReturnFlick); + result OnTouchDown(Tizen::Base::Collection::ArrayListT<_FlickInfo*>* pList, const _FlickInfo* pFlickInfo); + result OnTouchMove(Tizen::Base::Collection::ArrayListT<_FlickInfo*>* pList, const _FlickInfo* pFlickInfo); + result OnTouchUp(Tizen::Base::Collection::ArrayListT<_FlickInfo*>* pList, const _FlickInfo* pFlickInfo, _FlickInfo* pReturnFlick, bool& isFlicked); + + _TouchFlickGestureDetector(const _TouchFlickGestureDetector&); + _TouchFlickGestureDetector& operator =(const _TouchFlickGestureDetector&); + +private: + int __xDistance; + int __yDistance; + int __duration; + _FlickDirection __direction; + int __maxMoveX; + int __minMoveX; + int __maxMoveY; + int __minMoveY; + Tizen::Base::Collection::ArrayListT<_FlickInfo*>* __pFlickInfoList; +}; // _TouchFlickGestureDetector + +} } //Tizen::Ui + +#endif // _FUI_INTERNAL_TOUCH_FLICK_GESTURE_DETECTOR_H_ diff --git a/src/ui/inc/FUi_TouchFlickGestureDetectorImpl.h b/src/ui/inc/FUi_TouchFlickGestureDetectorImpl.h new file mode 100644 index 0000000..290037c --- /dev/null +++ b/src/ui/inc/FUi_TouchFlickGestureDetectorImpl.h @@ -0,0 +1,68 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchFlickGestureDetectorImpl.h + * @brief This is the header file for the %_TouchFlickGestureDetectorImpl class. + * + * This header file contains the declarations of the %_TouchFlickGestureDetectorImpl class. + * + */ + +#ifndef _FUI_INTERNAL_TOUCH_GESTURE_FLICK_DETECTOR_IMPL_H_ +#define _FUI_INTERNAL_TOUCH_GESTURE_FLICK_DETECTOR_IMPL_H_ + +#include +#include "FUi_TouchGestureDetectorImpl.h" +#include "FUi_TouchFlickGestureDetector.h" + +namespace Tizen { namespace Ui +{ + +/** + * @class _TouchFlickGestureDetectorImpl + * @brief + * @since 2.0 + * + */ +class _TouchFlickGestureDetectorImpl + : public Tizen::Ui::_TouchGestureDetectorImpl +{ +public: + virtual ~_TouchFlickGestureDetectorImpl(void); + + static _TouchFlickGestureDetectorImpl* CreateInstanceN(TouchFlickGestureDetector* pPublic); + + virtual const _TouchFlickGestureDetector& GetCore(void) const; + virtual _TouchFlickGestureDetector& GetCore(void); + + static _TouchFlickGestureDetectorImpl* GetInstance(TouchFlickGestureDetector& gestureDetector); + static const _TouchFlickGestureDetectorImpl* GetInstance(const TouchFlickGestureDetector& gestureDetector); + + result GetDistance(int &x, int &y) const; + int GetDuration(void) const; + FlickDirection GetDirection(void) const; + +private: + _TouchFlickGestureDetectorImpl(TouchFlickGestureDetector* pPublic, _TouchFlickGestureDetector* pCore); + + _TouchFlickGestureDetectorImpl(const _TouchFlickGestureDetectorImpl&); + _TouchFlickGestureDetectorImpl& operator =(const _TouchFlickGestureDetectorImpl&); +}; // _TouchFlickGestureDetectorImpl + +} } //Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_GESTURE_FLICK_DETECTOR_IMPL_H_ diff --git a/src/ui/inc/FUi_TouchGestureDetector.h b/src/ui/inc/FUi_TouchGestureDetector.h new file mode 100644 index 0000000..46d9c31 --- /dev/null +++ b/src/ui/inc/FUi_TouchGestureDetector.h @@ -0,0 +1,165 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchGestureDetector.h + * @brief This is the header file for the %_TouchGestureDetector class. + * + * This header file contains the declarations of the %_TouchGestureDetector class. + */ +#ifndef _FUI_INTERNAL_TOUCH_GESTURE_DETECTOR_H_ +#define _FUI_INTERNAL_TOUCH_GESTURE_DETECTOR_H_ + +#include +#include +#include +#include +#include "FUi_Types.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_ITouchEventListener.h" +#include "FUi_ITouchGestureEventListener.h" +#include "FUi_ITouchGestureDelegate.h" +#include "FUi_ITouchGestureStateChangedListener.h" + +namespace Tizen { namespace Ui +{ +class _Control; + +template +T Distance(T x1, T y1, T x2, T y2) +{ + return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); +} + +enum _TouchGestureDetectorState +{ + _TOUCH_GESTURE_DETECTOR_STATE_READY, + _TOUCH_GESTURE_DETECTOR_STATE_STARTED, + _TOUCH_GESTURE_DETECTOR_STATE_CHANGED, + _TOUCH_GESTURE_DETECTOR_STATE_FINISHED, + _TOUCH_GESTURE_DETECTOR_STATE_FAILED, + _TOUCH_GESTURE_DETECTOR_STATE_CANCELED, + _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS_AND_WAIT, + _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS = _TOUCH_GESTURE_DETECTOR_STATE_FINISHED +}; + +enum _TouchGestureDetectorType +{ + _TOUCH_GESTURE_DETECTOR_TYPE_CUSTOM, + _TOUCH_GESTURE_DETECTOR_TYPE_TAP, + _TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS, + _TOUCH_GESTURE_DETECTOR_TYPE_PINCH, + _TOUCH_GESTURE_DETECTOR_TYPE_FLICK, + _TOUCH_GESTURE_DETECTOR_TYPE_ROTATION, + _TOUCH_GESTURE_DETECTOR_TYPE_PANNING +}; + +enum _TouchGestureDetectorEventType +{ + _TOUCH_GESTURE_DETECTOR_EVENT_TYPE_DISCRETE, + _TOUCH_GESTURE_DETECTOR_EVENT_TYPE_CONTINUOUS +}; + +class _OSP_EXPORT_ _TouchGestureDetector + : public Tizen::Base::Object + , virtual public _ITouchGestureStateChangedListener + , virtual public _ITouchGestureDelegate +{ +public: + _TouchGestureDetector(void); + virtual ~_TouchGestureDetector(void); + + void SetDetectorState(_TouchGestureDetectorState state); + _TouchGestureDetectorState GetDetectorState(void) const; + + void SetDelayTouchEventEnabled(bool enable); + bool IsDelayTouchEventEnabled(void) const; + + void SetCancelTouchEventOnSuccessEnabled(bool enable); + bool IsCancelTouchEventOnSuccessEnabled(void) const; + + result AddGestureListener(const Tizen::Ui::_ITouchGestureEventListener& listener); + result RemoveGestureListener(const Tizen::Ui::_ITouchGestureEventListener& listener); + Tizen::Base::Collection::IListT * GetGestureListenerList(void) const; + + result StartOnFailureOf(const _TouchGestureDetector& gesture); + + void SetDetectorType(_TouchGestureDetectorType type); + _TouchGestureDetectorType GetDetectorType(void) const; + + result SetControl(const Tizen::Ui::_Control& control); + _Control* GetControl(void) const; + + void SetUserData(void* pUserData); + void* GetUserData(void) const; + + void SetDelegate(const _ITouchGestureDelegate& delegator); + _ITouchGestureDelegate* GetDelegate(void) const; + + bool IsSentDelayedEvent(void) const; + void SetSentDelayedEvent(bool sent); + bool IsSendingDelayedEvent(void) const; + + void AddTouchInfo(const _TouchInfo& touchInfo); + void ClearTouchInfo(void); + + void SetGestureStart(bool start); + bool IsGestureStarted(void) const; + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui:: _Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + virtual void OnGestureDetectorStateChanged(const _TouchGestureDetector& gestureDetector); + + void ProcessPublicListener(_TouchGestureDetector& gesture); + void ProcessCoreListener(_TouchGestureDetector& gesture); + + Tizen::Base::String GetDescription(void); + +private: + Tizen::Base::Collection::IListT <_TouchGestureDetector*>* GetWantToFailList(void) const; + Tizen::Base::Collection::IListT <_TouchGestureDetector*>* GetCurrentWantToFailList(void) const; + bool ExistWaitingList(void) const; + void NotifyStateChanged(void); + Tizen::Base::Collection::IListT<_TouchInfo*>* GetTouchInfoList(void); + bool IsPossibleToAddFailList(const _TouchGestureDetector& gesture); + void SetToDefaultState(void); + _TouchGestureDetectorEventType GetGestureDetectorEventType(void); + void SendDelayedTouchEvent(_Control* pControl); + void ProcessGestureCondition(void); + + _TouchGestureDetector(const _TouchGestureDetector&); + _TouchGestureDetector& operator =(const _TouchGestureDetector&); + +private: + bool __isTouchEventDelayed; + bool __isTouchCanceledOnSuccess; + bool __isDetectionStarted; + _TouchGestureDetectorState __currentState; + _TouchGestureDetectorType __type; + _ControlHandle __gestureContol; + void* __pUserData; + _ITouchGestureDelegate* __pDelegator; + Tizen::Base::Collection::IListT <_TouchGestureDetector*>* __pWantToFailList; + Tizen::Base::Collection::IListT <_TouchGestureDetector*>* __pCurrentWantToFailList; + Tizen::Base::Collection::IListT * __pEventListenerList; +}; // _TouchGestureDetector + +} } //Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_GESTURE_DETECTOR_H_ \ No newline at end of file diff --git a/src/ui/inc/FUi_TouchGestureDetectorImpl.h b/src/ui/inc/FUi_TouchGestureDetectorImpl.h new file mode 100644 index 0000000..35dff49 --- /dev/null +++ b/src/ui/inc/FUi_TouchGestureDetectorImpl.h @@ -0,0 +1,95 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchGestureDetectorImpl.h + * @brief This is the header file for the %_TouchGestureDetectorImpl class. + * + * This header file contains the declarations of the %_TouchGestureDetectorImpl class. + */ +#ifndef _FUI_INTERNAL_TOUCH_GESTURE_DETECTOR_IMPL_H_ +#define _FUI_INTERNAL_TOUCH_GESTURE_DETECTOR_IMPL_H_ + +#include +#include +#include +#include +#include "FUi_TouchGestureDetector.h" +#include "FUi_ITouchGestureDelegate.h" + +namespace Tizen { namespace Ui +{ +class _TouchEventArg; + +class _TouchGestureDetectorImpl + : public Tizen::Base::Object + , virtual public _ITouchGestureDelegate +{ +public: + virtual ~_TouchGestureDetectorImpl(void); + + static _TouchGestureDetectorImpl* CreateInstanceN(TouchGestureDetector* pPublic); + + result SetDetectorState(TouchGestureDetectorState state); + TouchGestureDetectorState GetDetectorState(void) const; + + result SetDelayTouchEventEnabled(bool enable); + bool IsDelayTouchEventEnabled(void) const; + + result SetCancelTouchEventOnSuccessEnabled(bool enable); + bool IsCancelTouchEventOnSuccessEnabled(void) const; + + result AddGestureEventListener(Tizen::Ui::ITouchGestureEventListener& listener); + result RemoveGestureEventListener(Tizen::Ui::ITouchGestureEventListener& listener); + Tizen::Base::Collection::IListT * GetGestureEventListenerList(void) const; + + result StartOnFailureOf(const TouchGestureDetector& gesture); + + Control* GetControl(void) const; + + virtual const TouchGestureDetector& GetPublic(void) const; + virtual TouchGestureDetector& GetPublic(void); + + virtual const _TouchGestureDetector& GetCore(void) const; + virtual _TouchGestureDetector& GetCore(void); + + static _TouchGestureDetectorImpl* GetInstance(TouchGestureDetector& gestureDetector); + static const _TouchGestureDetectorImpl* GetInstance(const TouchGestureDetector& gestureDetector); + + virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo); + +protected: + _TouchGestureDetectorImpl(TouchGestureDetector* pPublic, _TouchGestureDetector* pCore); + +private: + _TouchEventArg* GetTouchEventArgN(const Control& source, const _TouchInfo& touchInfo); + + _TouchGestureDetectorImpl(const _TouchGestureDetectorImpl&); + _TouchGestureDetectorImpl& operator =(const _TouchGestureDetectorImpl&); + +private: + TouchGestureDetector* __pPublicGestureDetector; + _TouchGestureDetector* __pCoreGestureDetector; + + Tizen::Base::Collection::IListT* __pPublicGestureEventListenerList; +}; // _TouchGestureDetectorImpl + +} } //Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_GESTURE_DETECTOR_IMPL_H_ diff --git a/src/ui/inc/FUi_TouchLongPressGestureDetector.h b/src/ui/inc/FUi_TouchLongPressGestureDetector.h new file mode 100644 index 0000000..13c6ab9 --- /dev/null +++ b/src/ui/inc/FUi_TouchLongPressGestureDetector.h @@ -0,0 +1,87 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchLongPressGestureDetector.h + * @brief This is the header file for the %_TouchLongPressGestureDetector class. + * + * This header file contains the declarations of the %_TouchLongPressGestureDetector class. + * + */ + +#ifndef _FUI_INTERNAL_TOUCH_LONG_PRESS_GESTURE_DETECTOR_H +#define _FUI_INTERNAL_TOUCH_LONG_PRESS_GESTURE_DETECTOR_H + +#include "FUi_TouchGestureDetector.h" +#include "FUi_UiTouchEvent.h" + +namespace Tizen { namespace Ui +{ +class _TouchGestureTimerManager; + +/** + * @class _TouchLongPressGestureDetector + * @brief + * @since 2.0 + * + */ +class _OSP_EXPORT_ _TouchLongPressGestureDetector + : public _TouchGestureDetector +{ +public: + _TouchLongPressGestureDetector(void); + virtual ~_TouchLongPressGestureDetector(void); + + result SetDuration(int duration); + int GetDuration(void) const; + + result SetMoveAllowance(int allowance); + int GetMoveAllowance(void) const; + + result SetTouchCount(int count); + int GetTouchCount(void) const; + + bool IsPressed(void); + void ClearLongPressInfoList(void); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + +private: + void RemoveLongPressInfoList(void); + +private: + _TouchLongPressGestureDetector(const _TouchLongPressGestureDetector&); + _TouchLongPressGestureDetector& operator =(const _TouchLongPressGestureDetector&); + +private: + int __duration; + int __moveAllowance; + int __touchCount; + unsigned int __maxPointId; + _TouchGestureTimerManager* __pGestureTimerManager; + + class _LongPressInfo; + Tizen::Base::Collection::ArrayListT<_LongPressInfo*>* __pLongPressInfoList; +}; // _TouchLongPressGestureDetector + +} } // Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_LONG_PRESS_GESTURE_DETECTOR_H + + diff --git a/src/ui/inc/FUi_TouchLongPressGestureDetectorImpl.h b/src/ui/inc/FUi_TouchLongPressGestureDetectorImpl.h new file mode 100644 index 0000000..a890ce3 --- /dev/null +++ b/src/ui/inc/FUi_TouchLongPressGestureDetectorImpl.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchLongPressGestureDetectorImpl.h + * @brief This is the header file for the %_TouchLongPressGestureDetectorImpl class. + * + * This header file contains the declarations of the %_TouchLongPressGestureDetectorImpl class. + * + */ + +#ifndef _FUI_INTERNAL_TOUCH_LONG_PRESS_GESTURE_DETECTOR_IMPL_H +#define _FUI_INTERNAL_TOUCH_LONG_PRESS_GESTURE_DETECTOR_IMPL_H + +#include +#include "FUi_TouchGestureDetectorImpl.h" +#include "FUi_TouchLongPressGestureDetector.h" + +namespace Tizen { namespace Ui +{ + +/** + * @class _TouchLongPressGestureDetectorImpl + * @brief + * @since 2.0 + * + */ +class _TouchLongPressGestureDetectorImpl + : public Tizen::Ui::_TouchGestureDetectorImpl +{ +public: + virtual ~_TouchLongPressGestureDetectorImpl(void); + + static _TouchLongPressGestureDetectorImpl* CreateInstanceN(TouchLongPressGestureDetector* pPublic); + + const _TouchLongPressGestureDetector& GetCore(void) const; + _TouchLongPressGestureDetector& GetCore(void); + + static _TouchLongPressGestureDetectorImpl* GetInstance(TouchLongPressGestureDetector& gestureDetector); + static const _TouchLongPressGestureDetectorImpl* GetInstance(const TouchLongPressGestureDetector& gestureDetector); + + result SetDuration(int duration); + int GetDuration(void) const; + + result SetMoveAllowance(int allowance); + int GetMoveAllowance(void) const; + + result SetTouchCount(int count); + int GetTouchCount(void) const; + +private: + _TouchLongPressGestureDetectorImpl(TouchLongPressGestureDetector* pPublic, _TouchLongPressGestureDetector* pCore); + + _TouchLongPressGestureDetectorImpl(const _TouchLongPressGestureDetectorImpl&); + _TouchLongPressGestureDetectorImpl& operator =(const _TouchLongPressGestureDetectorImpl&); +}; // _TouchLongPressGestureDetectorImpl + +} } // Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_LONG_PRESS_GESTURE_DETECTOR_IMPL_H diff --git a/src/ui/inc/FUi_TouchManager.h b/src/ui/inc/FUi_TouchManager.h new file mode 100644 index 0000000..cd27ea2 --- /dev/null +++ b/src/ui/inc/FUi_TouchManager.h @@ -0,0 +1,413 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchManager.h + * @brief This is the header file for the _TouchManager class. + * + * This header file contains the declarations of the _TouchManager class. @n + */ + +#ifndef _FUI_INTERNAL_TOUCH_MANAGER_H_ +#define _FUI_INTERNAL_TOUCH_MANAGER_H_ + +#include "FUi_ControlImpl.h" +#include "FUi_FingerInfo.h" + +namespace Tizen { namespace Base { namespace Collection { +template class IListT; +template class HashMapT; +}}} + +namespace Tizen { namespace Ui +{ + +class _MultiFingerInfo +{ +public: + /** + * This is the default class constructor. + * + */ + _MultiFingerInfo(void); + + /** + * This is the default class destructor. + * + */ + ~_MultiFingerInfo(void); + +public: + /** + * This method returns point id. + * + * @since 2.0 + * @return The point Id + */ + unsigned long GetPointId(unsigned long deviceId) const; + + /** + * This method returns current cursor id. + * + * @since 2.0 + * @return The cursor Id + */ + unsigned long GetCurrentPointId(void) const; + + /** + * This method convert efl point id to cursor id. + * + * @since 2.0 + * @return The cursor Id + */ + unsigned long GeneratePointId(unsigned long deviceId); + + /** + * This method returns the touch position of specific pointId. + * + * @since 2.0 + * @return The touch position + */ + Tizen::Graphics::Point GetPosition(unsigned long id) const; + + /** + * This method returns the touch position of specific pointId. + * + * @since 2.0 + * @return The touch position + */ + Tizen::Graphics::Point GetScreenPoint(unsigned long id) const; + + /** + * This method returns the touch status of specific pointId. + * + * @since 2.0 + * @return The touch status + */ + _TouchStatus GetStatus(unsigned long id) const; + + /** + * This method returns the touch start position. + * + * @since 2.0 + * @return The touch start position + */ + Tizen::Graphics::Point GetStartPoint(unsigned long id) const; + + /** + * This method returns the touch count + * + * @since 2.0 + * @return The touch count + */ + int GetPointCount(void) const; + + /** + * This method returns the touch info list. + * + * @since 2.0 + * @return The touch info list + */ + Tizen::Base::Collection::IListT<_FingerInfo*>* GetMultiFingerListN(void) const; + + /** + * This method sets current finger info + * + * @since 2.0 + */ + result SetFingerInfo(unsigned long pointId, const Tizen::Graphics::Point& point, const Tizen::Graphics::Point& screenPoint, _TouchStatus status); + + /** + * This method resets finger info + * + * @since 2.0 + */ + void ResetFingerInfo(void); + +private: + /** + * This method initializes finger information + * + * @since 2.0 + * @return + */ + void InitializeFingerInfo(void); + + /** + * This method remove finger informations + * + * @since 2.0 + * @return + */ + void RemoveFingerInfoList(void); + + /* + * This is the copy constructor for this class. + */ + _MultiFingerInfo(const _MultiFingerInfo&); + + /** + * This is the assignment operator for this class. + */ + _MultiFingerInfo& operator =(const _MultiFingerInfo&); + +private: + unsigned long __currentPointId; + unsigned long __generatedPointId; + int __pointCount; + Tizen::Base::Collection::HashMapT* __pFingerInfoMap; +}; //_MultiFingerInfo + +class _Control; +class _TouchEventArg; +class _ITouchEventListener; + +class _OSP_EXPORT_ _TouchManager +{ +public: + static void Initialize(void); + static _TouchManager* GetInstance(void); + +public: + /** + * This method adds current position to multi touch list + * + * @since 2.0 + * @return + */ + result AddPoint(unsigned long pointId, const Tizen::Graphics::Point& point, _TouchStatus status); + + /** + * This method returns the touch point count. + * + * @since 2.0 + * @return The touch point count + */ + int GetPointCount(void) const; + + /** + * This method returns the touch position. + * + * @since 2.0 + * @return The touch position + */ + Tizen::Graphics::Point GetScreenPoint(unsigned long id) const; + + /** + * This method returns the touch position. + * + * @since 2.0 + * @return The touch position + */ + Tizen::Graphics::Point GetPosition(unsigned long id) const; + + /** + * This method returns the touch status of specific pointId. + * + * @since 2.0 + * @return The touch status + */ + TouchStatus GetTouchStatus(unsigned long id) const; + + /** + * This method converts device id to point id. + * + * @since 2.0 + * @return The point Id + */ + unsigned long GetPointId(unsigned long deviceId) const; + + /** + * This method generates pointId. + * + * @since 2.0 + * @return The point Id + */ + unsigned long GeneratePointId(unsigned long deviceId) const; + + /** + * This method returns the current pointId for multi touch + * + * @since 2.0 + * @return The point Id + */ + unsigned long GetCurrentPointId(void) const; + + /** + * This method returns touch start point + * + * @since 2.0 + * @return The touch start point(means touch pressed point) + */ + Tizen::Graphics::Point GetStartPoint(unsigned long pointId) const; + + /** + * This method makes touch event and send touch event through event manager + * + * @since 2.0 + */ + result SendEvent(_Control* pControl, const _TouchInfo& touchInfo); + + /** + * This method sets touch cancelled status + * + * @since 2.0 + */ + void SetTouchCanceled(bool canceled, bool onlyTouchEvent = false);; + + /** + * This method sets touch allowed status + * + * @since 2.0 + */ + void SetTouchAllowed(bool allowed); + + /** + * This method returns touch allowed status + * + * @since 2.0 + * @return touch allowed status + */ + bool IsTouchAllowed(void); + + /** + * This method returns touch move allowed status + * Whenever starting touch move, checking this value if it allows to move. + * + * @since 2.0 + * @return touch move allowed status + */ + bool IsInTouchMoveAllowanceBounds(const _Control& source, const _TouchInfo& touchInfo); + + /** + * This method sets the touch control source. - common control of focus, drag. + * It's the control touch press occurred. + * + * @since 2.0 + */ + void SetTouchControlSource(const _Control& source); + + /** + * This method returns the touch control source, + * + * @since 2.0 + * @return The first touched control source + */ + _Control* GetTouchControlSource(void) const; + + /** + * This method sets the touch focused control source. - common control of focus, drag. + * It's the control touch press occurred. + * + * @since 2.0 + */ + void SetFocusedControlSource(const _Control& source); + + /** + * This method returns the touch focused control source, + * + * @since 2.0 + * @return The first touched control source + */ + _Control* GetFocusedControlSource(void) const; + + /** + * This method sets touch captured control + * If you set the captured control, all touch events are sent to captured control. + * + * @since 2.0 + */ + void SetCapturedControl(const _Control* pControl, bool allowOutOfBounds); + + /** + * This method returns touch captured control + * + * @since 2.0 + * @return The captured control + */ + _Control* GetCapturedControl(void) const; + + bool IsCaptureAllowedOutOfBounds(void) const; + + /** + * This method resets touch information, point count and cursorID etc. + * + * @since 2.0 + */ + void ResetTouchInfo(void); + + /** + * This method sets touch is canceled by gesture success. + * + * @since 2.0 + */ + void SetTouchCanceledOnGestureSuccess(bool cancel); + + /** + * This method returns whether touch is canceled on gesture success. + * + * @since 2.0 + */ + bool IsTouchCanceledOnGestureSuccess(void) const; + + Tizen::Base::Collection::IListT<_FingerInfo*>* GetMultiFingerInfoListN(void) const; + + bool IsSendingDelayedEvent(void) const; + + static void ReleaseInstance(void); + +private: + /** + * This is the default class constructor. + * + */ + _TouchManager(void); + + /** + * This is the default class destructor. + * + */ + ~_TouchManager(void); + + /* + * This is the copy constructor for this class. + */ + _TouchManager(const _TouchManager&); + + /** + * This is the assignment operator for this class. + */ + _TouchManager& operator =(const _TouchManager&); + + static void InitializeInstance(void); + +private: + static _TouchManager* __pInstance; + _MultiFingerInfo* __pMultiFingerInfo; + _ControlHandle __touchControlHandle; + _ControlHandle __capturedControlHandle; + _ControlHandle __focusedControlHandle; + bool __touchCanceled; + bool __touchAllowed; + _ITouchEventListener* __pTouchEventListener; + bool __captureAllowOutOfBounds; //will be deleted + bool __isSendingDelayedEvent; + bool __touchCanceledOnGestureSuccess; +}; // _TouchManager + +} } // Tizen::Ui + +#endif // _FUI_INTERNAL_TOUCH_MANAGER_H_ diff --git a/src/ui/inc/FUi_TouchPanningGestureDetector.h b/src/ui/inc/FUi_TouchPanningGestureDetector.h new file mode 100644 index 0000000..45a10dc --- /dev/null +++ b/src/ui/inc/FUi_TouchPanningGestureDetector.h @@ -0,0 +1,70 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchPanningGestureDetector.h + * @brief This is the header file for the %_TouchPanningGestureDetector class. + * + * This header file contains the declarations of the %_TouchPanningGestureDetector class. + */ +#ifndef _FUI_INTERNAL_TOUCH_PANNING_GESTURE_DETECTOR_H_ +#define _FUI_INTERNAL_TOUCH_PANNING_GESTURE_DETECTOR_H_ + +#include "FUi_TouchGestureDetector.h" + +namespace Tizen { namespace Ui +{ +/** + * @class _TouchPanningGestureDetector + * @brief + * @since 2.0 + * + */ +class _OSP_EXPORT_ _TouchPanningGestureDetector + : public _TouchGestureDetector + , public Tizen::Base::Runtime::ITimerEventListener +{ +public: + _TouchPanningGestureDetector(void); + virtual ~_TouchPanningGestureDetector(void); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui:: _Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + result SetTouchCount(int count); + int GetTouchCount(void) const; + + Tizen::Base::Collection::IListT<_TouchInfo*>* GetTouchInfoListN(const _Control* pControl) const; + +private: + _TouchPanningGestureDetector(const _TouchPanningGestureDetector&); + _TouchPanningGestureDetector& operator =(const _TouchPanningGestureDetector&); + + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + void SetDetectorStateChanged(void); + +private: + int __touchCount; //touch count for gesture recognition + int __fingerCount; //current pressed finger count + unsigned int __maxPointId; + Tizen::Base::Runtime::Timer* __pTimer; +}; // _TouchPanningGestureDetector + +}} //Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_PANNING_GESTURE_DETECTOR_H_ diff --git a/src/ui/inc/FUi_TouchPanningGestureDetectorImpl.h b/src/ui/inc/FUi_TouchPanningGestureDetectorImpl.h new file mode 100644 index 0000000..f0e1808 --- /dev/null +++ b/src/ui/inc/FUi_TouchPanningGestureDetectorImpl.h @@ -0,0 +1,67 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchPanningGestureDetectorImpl.h + * @brief This is the header file for the %_TouchPanningGestureDetectorImpl class. + * + * This header file contains the declarations of the %_TouchPanningGestureDetectorImpl class. + */ +#ifndef _FUI_INTERNAL_TOUCH_PANNING_GESTURE_DETECTOR_IMPL_H_ +#define _FUI_INTERNAL_TOUCH_PANNING_GESTURE_DETECTOR_IMPL_H_ + +#include +#include "FUi_TouchGestureDetectorImpl.h" +#include "FUi_TouchPanningGestureDetector.h" + +namespace Tizen { namespace Ui +{ + +/** + * @class _TouchPanningGestureDetectorImpl + * @brief + * @since 2.0 + * + */ +class _TouchPanningGestureDetectorImpl + : public Tizen::Ui::_TouchGestureDetectorImpl +{ +public: + virtual ~_TouchPanningGestureDetectorImpl(void); + + static _TouchPanningGestureDetectorImpl* CreateInstanceN(TouchPanningGestureDetector* pPublic); + + virtual const _TouchPanningGestureDetector& GetCore(void) const; + virtual _TouchPanningGestureDetector& GetCore(void); + + static _TouchPanningGestureDetectorImpl* GetInstance(TouchPanningGestureDetector& gestureDetector); + static const _TouchPanningGestureDetectorImpl* GetInstance(const TouchPanningGestureDetector& gestureDetector); + + result SetTouchCount(int count); + int GetTouchCount(void) const; + + Tizen::Base::Collection::IList* GetTouchInfoListN(void) const; + +private: + _TouchPanningGestureDetectorImpl(TouchPanningGestureDetector* pPublic, _TouchPanningGestureDetector* pCore); + + _TouchPanningGestureDetectorImpl(const _TouchPanningGestureDetectorImpl&); + _TouchPanningGestureDetectorImpl& operator =(const _TouchPanningGestureDetectorImpl&); +}; // _TouchPanningGestureDetectorImpl + +} } //Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_PANNING_GESTURE_DETECTOR_IMPL_H_ diff --git a/src/ui/inc/FUi_TouchPinchGestureDetector.h b/src/ui/inc/FUi_TouchPinchGestureDetector.h new file mode 100644 index 0000000..8aa2972 --- /dev/null +++ b/src/ui/inc/FUi_TouchPinchGestureDetector.h @@ -0,0 +1,68 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchPinchGestureDetector.h + * @brief This is the header file for the %_TouchPinchGestureDetector class. + * + * This header file contains the declarations of the %_TouchPinchGestureDetector class. + */ +#ifndef _FUI_INTERNAL_TOUCH_PINCH_GESTURE_DETECTOR_H_ +#define _FUI_INTERNAL_TOUCH_PINCH_GESTURE_DETECTOR_H_ + +#include "FUi_TouchGestureDetector.h" +#include "FUi_UiTouchEvent.h" + +namespace Tizen { namespace Ui +{ +class _PinchInfo; + +class _OSP_EXPORT_ _TouchPinchGestureDetector + : public _TouchGestureDetector + , public Tizen::Base::Runtime::ITimerEventListener +{ +public: + _TouchPinchGestureDetector(void); + virtual ~_TouchPinchGestureDetector(void); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + Tizen::Graphics::Point GetCenterPoint(void) const; + int GetScale(void) const; + +private: + _TouchPinchGestureDetector(const _TouchPinchGestureDetector&); + _TouchPinchGestureDetector& operator =(const _TouchPinchGestureDetector&); + + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + void SetDetectorStateChanged(void); + int MeasureArea(void); + +private: + Tizen::Graphics::Point __MinimumPoint; + Tizen::Graphics::Point __MaximumPoint; + Tizen::Graphics::Point __centerPosition; + Tizen::Base::Runtime::Timer* __pTimer; + int __threshold; + int __scale; +}; // _TouchPinchGestureDetector + +}} //Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_PINCH_GESTURE_DETECTOR_H_ diff --git a/src/ui/inc/FUi_TouchPinchGestureDetectorImpl.h b/src/ui/inc/FUi_TouchPinchGestureDetectorImpl.h new file mode 100644 index 0000000..04559ec --- /dev/null +++ b/src/ui/inc/FUi_TouchPinchGestureDetectorImpl.h @@ -0,0 +1,59 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchPinchGestureDetectorImpl.h + * @brief This is the header file for the %_TouchPinchGestureDetectorImpl class. + * + * This header file contains the declarations of the %_TouchPinchGestureDetectorImpl class. + */ +#ifndef _FUI_INTERNAL_TOUCH_PINCH_GESTURE_DETECTOR_IMPL_H_ +#define _FUI_INTERNAL_TOUCH_PINCH_GESTURE_DETECTOR_IMPL_H_ + +#include +#include "FUi_TouchGestureDetectorImpl.h" +#include "FUi_TouchPinchGestureDetector.h" + +namespace Tizen { namespace Ui +{ + +class _TouchPinchGestureDetectorImpl + : public Tizen::Ui::_TouchGestureDetectorImpl +{ +public: + virtual ~_TouchPinchGestureDetectorImpl(void); + + static _TouchPinchGestureDetectorImpl* CreateInstanceN(TouchPinchGestureDetector* pPublic); + + virtual const _TouchPinchGestureDetector& GetCore(void) const; + virtual _TouchPinchGestureDetector& GetCore(void); + + static _TouchPinchGestureDetectorImpl* GetInstance(TouchPinchGestureDetector& gestureDetector); + static const _TouchPinchGestureDetectorImpl* GetInstance(const TouchPinchGestureDetector& gestureDetector); + + Tizen::Graphics::Point GetCenterPoint(void) const; + int GetScale(void) const; + +private: + _TouchPinchGestureDetectorImpl(TouchPinchGestureDetector* pPublic, _TouchPinchGestureDetector* pCore); + + _TouchPinchGestureDetectorImpl(const _TouchPinchGestureDetectorImpl&); + _TouchPinchGestureDetectorImpl& operator =(const _TouchPinchGestureDetectorImpl&); +}; // _TouchPinchGestureDetectorImpl + +} } //Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_PINCH_GESTURE_DETECTOR_IMPL_H_ diff --git a/src/ui/inc/FUi_TouchRotationGestureDetector.h b/src/ui/inc/FUi_TouchRotationGestureDetector.h new file mode 100644 index 0000000..a01b0b0 --- /dev/null +++ b/src/ui/inc/FUi_TouchRotationGestureDetector.h @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchRotationGestureDetector.h + * @brief This is the header file for the %_TouchRotationGestureDetector class. + * + * This header file contains the declarations of the %_TouchRotationGestureDetector class. + */ +#ifndef _FUI_INTERNAL_TOUCH_ROTATION_GESTURE_DETECTOR_H_ +#define _FUI_INTERNAL_TOUCH_ROTATION_GESTURE_DETECTOR_H_ + +#include "FUi_TouchGestureDetector.h" + +namespace Tizen { namespace Ui +{ +/** + * @class _TouchRotationGestureDetector + * @brief + * @since 2.0 + * + */ +class _OSP_EXPORT_ _TouchRotationGestureDetector + : public _TouchGestureDetector + , public Tizen::Base::Runtime::ITimerEventListener +{ +public: + _TouchRotationGestureDetector(void); + ~_TouchRotationGestureDetector(void); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui:: _Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + + float GetAngle(void) const; + int GetDistance(void) const; + +private: + _TouchRotationGestureDetector(const _TouchRotationGestureDetector&); + _TouchRotationGestureDetector& operator =(const _TouchRotationGestureDetector&); + + double GetAngle(int x1, int y1, int x2, int y2) const; + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + void SetDetectorStateChanged(void); + +private: + int __distance; + float __angle; + int __fingerCount; + Tizen::Graphics::Point __firstPoint; + Tizen::Graphics::Point __secondPoint; + Tizen::Graphics::Point __firstPrevPoint; + Tizen::Graphics::Point __secondPrevPoint; + int __firstMovedDirection; + int __secondMovedDirection; + Tizen::Base::Runtime::Timer* __pTimer; + unsigned long __firstPointId; + unsigned long __secondPointId; +}; // _TouchRotationGestureDetector + +}} //Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_ROTATION_GESTURE_DETECTOR_H_ diff --git a/src/ui/inc/FUi_TouchRotationGestureDetectorImpl.h b/src/ui/inc/FUi_TouchRotationGestureDetectorImpl.h new file mode 100644 index 0000000..1a632d4 --- /dev/null +++ b/src/ui/inc/FUi_TouchRotationGestureDetectorImpl.h @@ -0,0 +1,64 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchRotationGestureDetectorImpl.h + * @brief This is the header file for the %_TouchRotationGestureDetectorImpl class. + * + * This header file contains the declarations of the %_TouchRotationGestureDetectorImpl class. + */ +#ifndef _FUI_INTERNAL_TOUCH_ROTATION_GESTURE_DETECTOR_IMPL_H_ +#define _FUI_INTERNAL_TOUCH_ROTATION_GESTURE_DETECTOR_IMPL_H_ + +#include +#include "FUi_TouchGestureDetectorImpl.h" +#include "FUi_TouchRotationGestureDetector.h" + +namespace Tizen { namespace Ui +{ +/** + * @class _TouchRotationGestureDetectorImpl + * @brief + * @since 2.0 + * + */ +class _TouchRotationGestureDetectorImpl + : public Tizen::Ui::_TouchGestureDetectorImpl +{ +public: + ~_TouchRotationGestureDetectorImpl(void); + + static _TouchRotationGestureDetectorImpl* CreateInstanceN(TouchRotationGestureDetector* pPublic); + + virtual const _TouchRotationGestureDetector& GetCore(void) const; + virtual _TouchRotationGestureDetector& GetCore(void); + + static _TouchRotationGestureDetectorImpl* GetInstance(TouchRotationGestureDetector& gestureDetector); + static const _TouchRotationGestureDetectorImpl* GetInstance(const TouchRotationGestureDetector& gestureDetector); + + float GetAngle(void) const; + int GetDistance(void) const; + +private: + _TouchRotationGestureDetectorImpl(TouchRotationGestureDetector* pPublic, _TouchRotationGestureDetector* pCore); + + _TouchRotationGestureDetectorImpl(const _TouchRotationGestureDetectorImpl&); + _TouchRotationGestureDetectorImpl& operator =(const _TouchRotationGestureDetectorImpl&); +}; // _TouchRotationGestureDetectorImpl + +} } //Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_ROTATION_GESTURE_DETECTOR_IMPL_H_ diff --git a/src/ui/inc/FUi_TouchTapGestureDetector.h b/src/ui/inc/FUi_TouchTapGestureDetector.h new file mode 100644 index 0000000..4d56b35 --- /dev/null +++ b/src/ui/inc/FUi_TouchTapGestureDetector.h @@ -0,0 +1,89 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchTapGestureDetector.h + * @brief This is the header file for the %_TouchTapGestureDetector class. + * + * This header file contains the declarations of the %_TouchTapGestureDetector class. + */ +#ifndef _FUI_INTERNAL_TOUCH_TAP_GESTURE_DETECTOR_H_ +#define _FUI_INTERNAL_TOUCH_TAP_GESTURE_DETECTOR_H_ + +#include "FUi_TouchGestureDetector.h" +#include "FUi_UiTouchEvent.h" + +namespace Tizen { namespace Ui +{ +class _TouchGestureTimerManager; + +/** + * @class _TouchTapGestureDetector + * @brief + * @since 2.0 + * + */ +class _OSP_EXPORT_ _TouchTapGestureDetector + : public _TouchGestureDetector +{ +public: + _TouchTapGestureDetector(void); + virtual ~_TouchTapGestureDetector(void); + + result SetTapCount(int count); + int GetTapCount(void) const; + + result SetTapInterval(long interval); + long GetTapInterval(void) const; + + result SetTouchCount(int count); + int GetTouchCount(void) const; + + //apply only one touch count + result SetMoveAllowance(int allowance); + int GetMoveAllowance(void) const; + bool IsInBounds(void); + void ClearTapInfoList(void); + bool IsAllTapped(void); + + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo); + +private: + _TouchTapGestureDetector(const _TouchTapGestureDetector& value); + _TouchTapGestureDetector& operator =(const _TouchTapGestureDetector& value); + + void RemoveTapInfoList(void); + +private: + int __tapCount; + int __interval; + int __touchCount; + int __oneTapMoveAllowance; + bool __oneTapIsInBounds; + unsigned int __maxPointId; + Tizen::Graphics::Point __oneTapStartPoint; + _TouchGestureTimerManager* __pGestureTimerManager; + + class _TapInfo; + Tizen::Base::Collection::ArrayListT<_TapInfo*>* __pTapInfoList; +}; // _TapGestureDetector + +}} //Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_TAP_GESTURE_DETECTOR_H_ diff --git a/src/ui/inc/FUi_TouchTapGestureDetectorImpl.h b/src/ui/inc/FUi_TouchTapGestureDetectorImpl.h new file mode 100644 index 0000000..7dff398 --- /dev/null +++ b/src/ui/inc/FUi_TouchTapGestureDetectorImpl.h @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_TouchTapGestureDetectorImpl.h + * @brief This is the header file for the %_TouchTapGestureDetectorImpl class. + * + * This header file contains the declarations of the %_TouchTapGestureDetectorImpl class. + */ +#ifndef _FUI_INTERNAL_TOUCH_TAP_GESTURE_DETECTOR_IMPL_H_ +#define _FUI_INTERNAL_TOUCH_TAP_GESTURE_DETECTOR_IMPL_H_ + +#include +#include "FUi_TouchGestureDetectorImpl.h" +#include "FUi_TouchTapGestureDetector.h" + +namespace Tizen { namespace Ui +{ +/** + * @class _TouchTapGestureDetectorImpl + * @brief + * @since 2.0 + * + */ +class _TouchTapGestureDetectorImpl + : public Tizen::Ui::_TouchGestureDetectorImpl +{ +public: + virtual ~_TouchTapGestureDetectorImpl(void); + + static _TouchTapGestureDetectorImpl* CreateInstanceN(TouchTapGestureDetector* pPublic); + + virtual const _TouchTapGestureDetector& GetCore(void) const; + virtual _TouchTapGestureDetector& GetCore(void); + + static _TouchTapGestureDetectorImpl* GetInstance(TouchTapGestureDetector& gestureDetector); + static const _TouchTapGestureDetectorImpl* GetInstance(const TouchTapGestureDetector& gestureDetector); + + result SetTapCount(int count); + int GetTapCount(void) const; + + result SetTapInterval(long interval); + long GetTapInterval(void) const; + + result SetTouchCount(int count); + int GetTouchCount(void) const; + + result SetMoveAllowance(int allowance); + int GetMoveAllowance(void) const; + +private: + _TouchTapGestureDetectorImpl(TouchTapGestureDetector* pPublic, _TouchTapGestureDetector* pCore); + + _TouchTapGestureDetectorImpl(const _TouchTapGestureDetectorImpl& value); + _TouchTapGestureDetectorImpl& operator =(const _TouchTapGestureDetectorImpl& value); +}; // _TouchTapGestureDetectorImpl + +} } //Tizen::Ui + +#endif //_FUI_INTERNAL_TOUCH_TAP_GESTURE_DETECTOR_IMPL_H_ diff --git a/src/ui/inc/FUi_Types.h b/src/ui/inc/FUi_Types.h new file mode 100644 index 0000000..16550f9 --- /dev/null +++ b/src/ui/inc/FUi_Types.h @@ -0,0 +1,100 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_INTERNAL_DEFINITIONS_H_ +#define _FUI_INTERNAL_DEFINITIONS_H_ + +#include +#include +#include +#include + +#define MULTI_WINDOW + +namespace Tizen { namespace Ui +{ + +class _Control; + +typedef Tizen::Base::_HandleT <_Control> _ControlHandle; + +enum _ControlRotation +{ + _CONTROL_ROTATION_0, + _CONTROL_ROTATION_90, + _CONTROL_ROTATION_180, + _CONTROL_ROTATION_270, +}; + +enum _ControlOrientation +{ + _CONTROL_ORIENTATION_PORTRAIT, + _CONTROL_ORIENTATION_LANDSCAPE +}; + +enum _ControlArea +{ + _CONTROL_AREA_NONE = -1, + _CONTROL_AREA_CLIENT, + _CONTROL_AREA_SYSTEM, +}; + +enum _ControlLayer +{ + _CONTROL_LAYER_NONE = -1, + _CONTROL_LAYER_OVERLAY, + _CONTROL_LAYER_CLIENT_BOTTOM, + _CONTROL_LAYER_CLIENT_MIDDLE, + _CONTROL_LAYER_CLIENT_TOP, + _CONTROL_LAYER_SYSTEM, +}; + +enum _ControlZOrderUpdate +{ + _CONTROL_ZORDER_UPDATE_TOP, + _CONTROL_ZORDER_UPDATE_BOTTOM, + _CONTROL_ZORDER_UPDATE_UPWARD, + _CONTROL_ZORDER_UPDATE_DOWNWARD, +}; + +enum _TouchMoveAllowance +{ + TOUCH_MOVE_ALLOWANCE_SENSITIVE = 0, + TOUCH_MOVE_ALLOWANCE_NORMAL, + TOUCH_MOVE_ALLOWANCE_INSENSITIVE +}; + +template +struct _IntToType +{ + enum + { + VALUE = V + }; +}; + +template +struct _TypeToType +{ + typedef T type; +}; + +typedef unsigned int NativeWindowHandle; + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_DEFINITIONS_H_ diff --git a/src/ui/inc/FUi_UiBuilder.h b/src/ui/inc/FUi_UiBuilder.h new file mode 100644 index 0000000..6f1540b --- /dev/null +++ b/src/ui/inc/FUi_UiBuilder.h @@ -0,0 +1,86 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiBuilder.h + * @brief This is the header file for the _UiBuilder class. + * + * This header file contains the declarations of the _UiBuilder class. @n + */ +#ifndef _FUI_INTERNAL_UI_BUILDER_H_ +#define _FUI_INTERNAL_UI_BUILDER_H_ + +#include +#include +#include +#include +#include +#include "FUi_UiBuilderConfig.h" +#include "FUi_UiBuilderRegister.h" +#include "FUi_UiBuilderControl.h" +#include "FUi_UiBuilderControlTable.h" + +namespace Tizen { namespace Ui +{ + +/** +* @class _UiBuilder +* @brief This class is an implementation of a %_UiBuilder. +* @since 2.0 +* +* The %_UiBuiler Class contains information that control register and XML parser. +* +* +*/ +class _OSP_EXPORT_ _UiBuilder + : public Tizen::Base::Object +{ +public: + virtual ~_UiBuilder(void); + _UiBuilder(void); + result Construct(const Tizen::Base::String& xmlFile, Tizen::Ui::Container* pContainer); + result MakeUI(_UiBuilderControl* pControl); + _UiBuilderControl* CreateControl(void); + Tizen::Ui::Container* GetContainer(void) const; + result Parse(void); + bool IsSameResolution(void) const; + void SetVersion(int xmlVersion); + void SetUiBuilderRotateState(_UiBuilderScreenRotate rotate); + void SetLayoutOrientation(_UiBuilderControl* pUiBuilderControl, Tizen::Ui::Control* pControl); + int GetVersion(void) const; + _UiBuilderScreenRotate GetUiBuilderRotateState(void) const; + _UiBuilderControl* GetControl(int index) const; + _UiBuilderControl* GetControl(const Tizen::Base::String& id) const; + result SetFormXmlResolution(Tizen::Graphics::_LogicalResolution formXmlResoluton); + Tizen::Graphics::_ICoordinateSystemTransformer* GetTransformer(void) const; +private: + _UiBuilder(const _UiBuilder& rhs); + _UiBuilder& operator =(const _UiBuilder& rhs); + +private: + int __version; + int __lastIndex; + int __logicalResolution; + Tizen::Base::Collection::ArrayListT<_UiBuilderControl*>* __pUiBuilderControlList; + Tizen::Ui::Container* __pContainer; + _UiBuilderScreenRotate __rotate; + Tizen::Graphics::_ICoordinateSystemTransformer* __pTransform; + Tizen::Base::String __xmlFile; +}; // _UiBuilder + +} } // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_BUILDER_H_ diff --git a/src/ui/inc/FUi_UiBuilderConfig.h b/src/ui/inc/FUi_UiBuilderConfig.h new file mode 100644 index 0000000..b089185 --- /dev/null +++ b/src/ui/inc/FUi_UiBuilderConfig.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_UiBuilderConfig.h +* @brief This is the header file for the %OptionHeader class. +* +* This header file contains the declarations of the UiBuilder configuration values. +*/ + +#ifndef _FUI_INTERNAL_UI_BUILDER_CONFIG_H_ +#define _FUI_INTERNAL_UI_BUILDER_CONFIG_H_ + +const int UIBUILDER_CONTROL_TEXT_MAX_LENGTH = 1000; +const int UIBUILDER_CONTROL_ELEMENT_NUMBER = 100; +const int UIBUILDER_CONTROL_MAX_COUNT = 100; + +const int UIBUILDER_ATTRIBUTE_PORTRAIT = 0; +const int UIBUILDER_ATTRIBUTE_LANDSCAPE = 1; +const int UIBUILDER_ATTRIBUTE_NUM = 2; + +/** +* @enum _UiBuilderLayoutType +* Defines the layout mode of a UiBuilder control +* +* @since 2.0 +*/ +enum _UiBuilderLayoutType +{ + UIBUILDER_LAYOUT_NONE, + UIBUILDER_LAYOUT_GRID, + UIBUILDER_LAYOUT_HORIZONTAL_BOX, + UIBUILDER_LAYOUT_VERTICAL_BOX, + UIBUILDER_LAYOUT_RELATIVE +}; + +/** +* @enum _UiBuilderScreenRotate +* Defines the screen rotate of a UiBuilder control +* +* @since 2.0 +*/ +enum _UiBuilderScreenRotate +{ + UIBUIDER_SCREEN_NONE, + UIBUIDER_SCREEN_VERTICAL, + UIBUIDER_SCREEN_HORIZONTAL +}; + +#endif // _FUI_INTERNAL_UI_BUILDER_CONFIG_H_ diff --git a/src/ui/inc/FUi_UiBuilderControl.h b/src/ui/inc/FUi_UiBuilderControl.h new file mode 100644 index 0000000..2ea723b --- /dev/null +++ b/src/ui/inc/FUi_UiBuilderControl.h @@ -0,0 +1,85 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_UiBuilderControl.h +* @brief This is the header file for the %_UiBuilderControl class. +* +* This header file contains the declarations of the %_UiBuilderControl class. +*/ + +#ifndef _FUI_INTERNAL_UI_BUILDER_CONTROL_H_ +#define _FUI_INTERNAL_UI_BUILDER_CONTROL_H_ + +#include "FUi_UiBuilderConfig.h" +#include "FUi_UiBuilderControlLayout.h" +#include "FUi_UiBuilderControlItem.h" + +namespace Tizen { namespace Ui +{ + +/** +* @class _UiBuilderControl +* @brief This class is an implementation of a %_UiBuilderControl. +* @since 2.0 +* +* The %_UiBuilderControl Class contains that informaition for generating the control. +* +* +*/ +class _OSP_EXPORT_ _UiBuilderControl + : public Tizen::Base::Object +{ +public: + _UiBuilderControl(void); + ~_UiBuilderControl(void); + void Construct(const Tizen::Base::String& type); + void SetId(const Tizen::Base::String& id); + void SetType(const Tizen::Base::String& type); + void SetParentWin(const Tizen::Base::String& parent); + void SetElement(int index, const Tizen::Base::String& elementName, const Tizen::Base::String& elementOutValue); + void SetItemElement(int index, const Tizen::Base::String& name, const Tizen::Base::String& value); + void SetItemName(const Tizen::Base::String& name); + Tizen::Base::String GetItemName(int index) const; + bool GetItemElement(int index, const Tizen::Base::String& elementName, Tizen::Base::String& elementOutValue); + int GetItemCount(void) const; + bool GetElement(const Tizen::Base::String& elementName, Tizen::Base::String& elementValue); + Tizen::Base::String GetId(void) const; + Tizen::Base::String GetType(void) const; + Tizen::Base::String GetParentWin(void) const; + _UiBuilderControlLayout* GetAttribute(int mode) const; + +private: + _UiBuilderControl(const _UiBuilderControl& rhs); + _UiBuilderControl& operator =(const _UiBuilderControl& rhs); + bool IsSpecialChar(const Tizen::Base::String& string) const; + void ConvertSpecialChar(Tizen::Base::String& string) const; + +private: + int __itemCount; + void* __pHandle; + Tizen::Base::String __type; + Tizen::Base::String __id; + Tizen::Base::String __parentId; + Tizen::Base::Collection::ArrayListT<_UiBuilderControlElement*>* __pUiBuilderControlElementList; + Tizen::Base::Collection::ArrayListT<_UiBuilderControlItem*>* __pUiBuilderControlItemList; + _UiBuilderControlLayout __layout[UIBUILDER_ATTRIBUTE_NUM]; + +}; // _UiBuilderControl + +} } // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_BUILDER_CONTROL_H_ diff --git a/src/ui/inc/FUi_UiBuilderControlElement.h b/src/ui/inc/FUi_UiBuilderControlElement.h new file mode 100644 index 0000000..ea5600d --- /dev/null +++ b/src/ui/inc/FUi_UiBuilderControlElement.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_UiBuilderControlElement.h +* @brief This is the header file for the %UiBuilderControlElement class. +* +* This header file contains the declarations of the %UiBuilderControlElement class. +*/ + +#ifndef _FUI_INTERNAL_UI_BUILDER_CONTROL_ELEMENT_H_ +#define _FUI_INTERNAL_UI_BUILDER_CONTROL_ELEMENT_H_ + +#include +#include "FUi_UiBuilderConfig.h" + +namespace Tizen { namespace Ui +{ +/** +* @class _UiBuilderControlElement +* @brief This class is an implementation of a %_UiBuilderControlElement. +* @since 2.0 +* +* The %_UiBuilderControlElement Class contains that XML attribute for UiBuilder Control. +* +* +*/ +class _UiBuilderControlElement + : public Tizen::Base::Object +{ +public: + _UiBuilderControlElement(void); + virtual ~_UiBuilderControlElement(void); + void SetName(const Tizen::Base::String& elementName); + void SetValue(const Tizen::Base::String& elementValue); + Tizen::Base::String GetName(void) const; + Tizen::Base::String GetValue(void) const; + +private: + _UiBuilderControlElement(const _UiBuilderControlElement& rhs); + _UiBuilderControlElement& operator =(const _UiBuilderControlElement& rhs); + +protected: + Tizen::Base::String __elementName; + Tizen::Base::String __elementValue; +}; // _UiBuilderControlElement + +} } // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_BUILDER_CONTROL_ELEMENT_H_ diff --git a/src/ui/inc/FUi_UiBuilderControlItem.h b/src/ui/inc/FUi_UiBuilderControlItem.h new file mode 100644 index 0000000..a84423d --- /dev/null +++ b/src/ui/inc/FUi_UiBuilderControlItem.h @@ -0,0 +1,62 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_UiBuilderControlItem.h +* @brief This is the header file for the %UiBuilderControlItem class. +* +* This header file contains the declarations of the %UiBuilderControlItem class. +*/ + +#ifndef _FUI_INTERNAL_UI_BUILDER_CONTROL_ITEM_H_ +#define _FUI_INTERNAL_UI_BUILDER_CONTROL_ITEM_H_ + +#include "FUi_UiBuilderConfig.h" +#include "FUi_UiBuilderControlElement.h" + +namespace Tizen { namespace Ui +{ +/** +* @class _UiBuilderControlItem +* @brief This class is an implementation of a %_UiBuilderControlItem. +* @since 2.0 +* +* The %_UiBuilderControlItem Class contains that information for information for Ui control item. +* +* +*/ +class _UiBuilderControlItem + : public Tizen::Base::Object +{ +public: + _UiBuilderControlItem(void); + virtual ~_UiBuilderControlItem(void); + void SetItemName(const Tizen::Base::String& name); + void SetItemElement(int index, const Tizen::Base::String& name, const Tizen::Base::String& value); + Tizen::Base::String GetItemName(void) const; + Tizen::Base::Collection::ArrayListT<_UiBuilderControlElement*>* GetItemProperty(void); +private: + _UiBuilderControlItem(const _UiBuilderControlItem& rhs); + _UiBuilderControlItem& operator =(const _UiBuilderControlItem& rhs); + +protected: + Tizen::Base::String _itemName; + Tizen::Base::Collection::ArrayListT<_UiBuilderControlElement*>* __pUiBuilderControlElementList; +}; // _UiBuilderControlItem + +} } // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_BUILDER_CONTROL_ELEMENT_H_ diff --git a/src/ui/inc/FUi_UiBuilderControlLayout.h b/src/ui/inc/FUi_UiBuilderControlLayout.h new file mode 100644 index 0000000..f1b8d65 --- /dev/null +++ b/src/ui/inc/FUi_UiBuilderControlLayout.h @@ -0,0 +1,80 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_UiBuilderControlLayout.h +* @brief This is the header file for the %_UiBuilderControlLayout class. +* +* This header file contains the declarations of the %_UiBuilderControlLayout class. +*/ + +#ifndef _FUI_INTERNAL_UI_BUILDER_CONTROL_LAYOUT_H_ +#define _FUI_INTERNAL_UI_BUILDER_CONTROL_LAYOUT_H_ + +#include +#include "FUi_UiBuilderControlItem.h" + +namespace Tizen { namespace Ui +{ +/** +* @class _UiBuilderControlLayout +* @brief This class is an implementation of a %_UiBuilderControlLayout. +* @since 2.0 +* +* The %_UiBuilderControlLayout Class contains that coordinates of the control. +* +* +*/ +class _OSP_EXPORT_ _UiBuilderControlLayout + : public Tizen::Base::Object +{ +public: + _UiBuilderControlLayout(void); + virtual ~_UiBuilderControlLayout(void); + void SetStyle(const Tizen::Base::String& style); + void SetRect(const Tizen::Base::String& x, const Tizen::Base::String& y, Tizen::Base::String& width, Tizen::Base::String& height); + void SetRect(const int x, const int y, const int width, const int height); + void SetLayoutElement(int index, const Tizen::Base::String& name, const Tizen::Base::String& value); + Tizen::Base::String GetStyle(void) const; + Tizen::Graphics::Rectangle& GetRect(void) const; + bool GetLayoutElement(const Tizen::Base::String& layoutElementName, Tizen::Base::String& outValue) const; + +private: + _UiBuilderControlLayout(const _UiBuilderControlLayout& rhs); + _UiBuilderControlLayout& operator =(const _UiBuilderControlLayout& rhs); + enum _UiBuilderDockTypeDef + { + _UIBUILDER_DOCK_LEFT = 0x00001, + _UIBUILDER_DOCK_RIGHT = 0x00002, + _UIBUILDER_DOCK_TOP = 0x00004, + _UIBUILDER_DOCK_BOTTOM = 0x00008 + }; + + enum _UiBuilderFitTypeDef + { + _UIBUILDER_FIT_WIDTH = 0x00001, + _UIBUILDER_FIT_HEIGHT = 0x00002 + }; + +protected: + Tizen::Base::String _styleInformation; /** stored the style information. It is different each control.*/ + Tizen::Graphics::Rectangle _rect; /** stored rectangle value. This values are ignored sometimes by the Docking and Fit value. */ + _UiBuilderControlElement _layoutElement[UIBUILDER_CONTROL_ELEMENT_NUMBER]; +}; // _UiBuilderControlLayout + +} } // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_BUILDER_CONTROL_LAYOUT_H_ diff --git a/src/ui/inc/FUi_UiBuilderControlMaker.h b/src/ui/inc/FUi_UiBuilderControlMaker.h new file mode 100644 index 0000000..51c5f71 --- /dev/null +++ b/src/ui/inc/FUi_UiBuilderControlMaker.h @@ -0,0 +1,199 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_UiBuilderControlMaker.h +* @brief This is the header file for the %_UiBuilderControlMaker class. +* +* This header file contains the declarations of the %_UiBuilderControlMaker class. +*/ + +#ifndef _FUI_INTERNAL_UI_BUILDER_CONTROL_MAKER_H_ +#define _FUI_INTERNAL_UI_BUILDER_CONTROL_MAKER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_UiBuilderConfig.h" +#include "FUi_UiBuilderControl.h" + + + +namespace Tizen { namespace Ui +{ + +struct UiBuilderRelativeLayout +{ + Tizen::Ui::Control* pBottomRelation; + RectangleEdgeRelation bottomRelationType; + + Tizen::Ui::Control* pLeftRelation; + RectangleEdgeRelation leftRelationType; + + Tizen::Ui::Control* pRightRelation; + RectangleEdgeRelation rightRelationType; + + Tizen::Ui::Control* pTopRelation; + RectangleEdgeRelation topRelationType; + + bool centerHorizontal; + bool centerVertical; + + int height; + FitPolicy verticalFitPolicy; + + int marginBottom; + int marginLeft; + int marginRight; + int marginTop; + + int width; + FitPolicy horizontalFitPolicy; +}; + +struct UiBuilderGridLayoutContainer +{ + int maxColumn; + int maxRow; + int columnSpacing; + int rowSpacing; + bool columnCollapsed; + bool columnShrinkable; + bool columnStretchable; + bool rowCollapsed; + bool rowShrinkable; + bool rowStretchable; +}; + +struct UiBuilderGridLayoutControl +{ + int marginBottom; + int marginLeft; + int marginRight; + int marginTop; + int positionRow; + int positionColumn; + int positionRowSpan; + int positionColumnSpan; + LayoutHorizontalAlignment horizontalAlignment; + LayoutVerticalAlignment verticalAlignment; +}; + +struct UiBuilderHorizontalBoxLayoutContainer +{ + HorizontalDirection direction; +}; + +struct UiBuilderHorizontalBoxLayoutControl +{ + int height; + FitPolicy verticalFitPolicy; + LayoutVerticalAlignment verticalAlignment; + int verticalBottomMargin; + int verticalTopMargin; + int spacing; + float weight; + int width; + FitPolicy horizontalFitPolicy; +}; + +struct UiBuilderVerticalBoxLayoutContainer +{ + VerticalDirection direction; +}; + +struct UiBuilderVerticalBoxLayoutControl +{ + int height; + FitPolicy verticalFitPolicy; + LayoutHorizontalAlignment horizontalAlignment; + int horizontalLeftMargin; + int horizontalRightMargin; + int spacing; + float weight; + int width; + FitPolicy horizontalFitPolicy; +}; + +class _UiBuilder; +/** +* @class _UiBuilderControlMaker +* @brief This class is an implementation of a %_UiBuilderControlMaker. +* @since 2.0 +* +* The %_UiBuilderControlMaker Class contains that information for generating a Control and setting a layout information. +* +* +*/ +class _OSP_EXPORT_ _UiBuilderControlMaker + : public Tizen::Base::Object +{ +public: + _UiBuilderControlMaker(void); + _UiBuilderControlMaker(_UiBuilder* pUibuilder); + virtual ~_UiBuilderControlMaker(void); + result MakeControl(_UiBuilderControl* pControl); + +protected: + virtual Tizen::Ui::Control* Make(_UiBuilderControl* pControl) = 0; + Tizen::Ui::Container* GetContainer(void) const; + Tizen::Graphics::Bitmap* LoadBitmapN(const Tizen::Base::String& imagePath); + bool ConvertHAlignToHorizontalAlignment(const Tizen::Base::String& align, Tizen::Ui::Controls::HorizontalAlignment& alignment); + bool ConvertVAlignToVerticalAlignment(const Tizen::Base::String& align, Tizen::Ui::Controls::VerticalAlignment& alignment); + bool ConvertSlideShowAnimation(const Tizen::Base::String& animationType, Tizen::Ui::Controls::GalleryAnimation& animation); + int ConvertOpacity100to255(int opacity); + void ConvertStringToColor(const Tizen::Base::String& colorString, Tizen::Graphics::Color& color); + void ConvertStringToColor32(const Tizen::Base::String& colorString, int transparency, Tizen::Graphics::Color& color); + void AddControl(_UiBuilderControl* pUiBuilderControl, Tizen::Ui::Control* pControl); + void SetUiBuilderRotateState(_UiBuilderScreenRotate rotate); + result SetGridLayoutContainerProperty(GridLayout* pLayout, _UiBuilderControlLayout* pControlProperty) const; + void SetGridLayoutControlProperty(GridLayout* pLayout, _UiBuilderControlLayout* pControlProperty, Control* pControl); + void SetHorizontalBoxLayoutProperty(HorizontalBoxLayout* pLayout, _UiBuilderControlLayout* pControlProperty, Control* pControl); + void SetVerticalBoxLayoutProperty(VerticalBoxLayout* pLayout, _UiBuilderControlLayout* pControlProperty, Control* pControl); + void SetRelativeLayoutProperty(RelativeLayout* pLayout, _UiBuilderControlLayout* pControlProperty, Control* pControl); + void SetLayoutProperty(_UiBuilderControl* pUiBuilderControl, Control* pControl); + void SetLayoutOrientation(_UiBuilderControl* pUiBuilderCOntrol, Tizen::Ui::Control* pControl); + void GetProperty(_UiBuilderControl* pControl, _UiBuilderControlLayout** pControlProperty) const; + bool GetLayoutType(_UiBuilderControlLayout* pControlProperty, _UiBuilderLayoutType& layoutType) const; + bool GetParentLayoutType(_UiBuilderControlLayout* pControlProperty, _UiBuilderLayoutType& returnType) const; + result GetGridLayoutN(_UiBuilderControlLayout* pControlProperty, Layout*& pLayout) const; + result GetHorizontalBoxLayoutN(_UiBuilderControlLayout* pControlProperty, Layout*& pLayout) const; + result GetVerticalBoxLayoutN(_UiBuilderControlLayout* pControlProperty, Layout*& pLayout) const; + result GetRelativeLayoutN(_UiBuilderControlLayout* pControlProperty, Layout*& pLayout) const; + _UiBuilderScreenRotate GetUiBuilderRotateState(void); + result GetLayoutN(_UiBuilderControl* pUiBuilderControl, Layout*& pPortraitLayout, Layout*& pLandscapeLayout) const ; + Tizen::Graphics::_ICoordinateSystemTransformer* GetTransformer(void) const; + +private: + _UiBuilderControlMaker(const _UiBuilderControlMaker& rhs); + _UiBuilderControlMaker& operator =(const _UiBuilderControlMaker& rhs); + +private: + _UiBuilder* __pUiBuilder; +}; // _UiBuilderControlMaker + +} } // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_BUILDER_CONTROL_MAKER_H_ + + diff --git a/src/ui/inc/FUi_UiBuilderControlTable.h b/src/ui/inc/FUi_UiBuilderControlTable.h new file mode 100644 index 0000000..2ad0261 --- /dev/null +++ b/src/ui/inc/FUi_UiBuilderControlTable.h @@ -0,0 +1,90 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_UiBuilderControlTable.h +* @brief This is the header file for the %_UiBuilderControlMakerTable class. +* +* This header file contains the declarations of the %_UiBuilderControlMakerTable class. +*/ + +#ifndef _FUI_INTERNAL_UI_BUILDER_CONTROL_TABLE_H_ +#define _FUI_INTERNAL_UI_BUILDER_CONTROL_TABLE_H_ + +#include "FUi_UiBuilderConfig.h" +#include "FUi_UiBuilderControlMaker.h" + +namespace Tizen { namespace Ui +{ + +typedef _UiBuilderControlMaker* (*_UiBuilderControlMakerFunctionPointer)(_UiBuilder* uibuilder); +/** +* @class _UiBuilderControlMakerTable +* @brief This class is an implementation of a %_UiBuilderControlMakerTable. +* @since 2.0 +* +* The %_UiBuilderControlTable Class contains that information for controls' maker. +* +* +*/ + +class _UiBuilderControlTableInFomation +{ +public: + Tizen::Base::String __controlMakerName; + _UiBuilderControlMakerFunctionPointer __pContolMakerFunctionPointer; +}; + + +class _UiBuilderControlTable + : public Tizen::Base::Object +{ +public: + _UiBuilderControlTable(void); + virtual ~_UiBuilderControlTable(void); + +private: + _UiBuilderControlTable(const _UiBuilderControlTable&); + _UiBuilderControlTable& operator =(const _UiBuilderControlTable&); + +public: + Tizen::Base::Collection::ArrayListT<_UiBuilderControlTableInFomation*>* __pUiBuilderControlTableInFomationList; +}; + +class _OSP_EXPORT_ _UiBuilderControlTableManager + : public Tizen::Base::Object +{ +public: + _UiBuilderControlTableManager(void); + virtual ~_UiBuilderControlTableManager(void); + result Construct(void); + void RegisterControl(const Tizen::Base::String& controlMakerName, _UiBuilderControlMakerFunctionPointer pControlMakerFunctionPointer); + void UnregisterControl(const Tizen::Base::String& controlMakerName); + Tizen::Base::String GetName(int index) const; + _UiBuilderControlMakerFunctionPointer GetControlMaker(int index) const; + static _UiBuilderControlTableManager* GetInstance(void); + _UiBuilderControlTable* GetControlTable() const; + +private: + _UiBuilderControlTableManager(const _UiBuilderControlTableManager& rhs); + _UiBuilderControlTableManager& operator =(const _UiBuilderControlTableManager& rhs); +private: + _UiBuilderControlTable* __pControlTable; +}; // _UiBuilderControlTable + +} } // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_BUILDER_CONTROL_TABLE_H_ diff --git a/src/ui/inc/FUi_UiBuilderRegister.h b/src/ui/inc/FUi_UiBuilderRegister.h new file mode 100644 index 0000000..acf571c --- /dev/null +++ b/src/ui/inc/FUi_UiBuilderRegister.h @@ -0,0 +1,746 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_UiBuilderRegister.h +* @brief This is the header file for the %FormRegister class. +* +* This header file contains the declarations of the %FormRegister class. +*/ + +#include "FBaseObject.h" + +#ifndef _FUI_INTERNAL_UI_BUILDER_REGISTER_H_ +#define _FUI_INTERNAL_UI_BUILDER_REGISTER_H_ + +namespace Tizen { namespace Ui { namespace Controls +{ +/** +* @class _FormRegister +* @brief This class is an implementation of a %_FormRegister. +* @since 2.0 +* +* The %_FormRegister Class contains that declaration of Form's maker +* +* +*/ +class _FormRegister + : public Tizen::Base::Object +{ +public: + _FormRegister(void); + virtual ~_FormRegister(void); +}; // _FormRegister + +/** +* @class _CheckButtonRegister +* @brief This class is an implementation of a %_CheckButtonRegister. +* @since 2.0 +* +* The %_CheckButtonRegister Class contains that declaration of CheckButton's maker +* +* +*/ +class _CheckButtonRegister + : public Tizen::Base::Object +{ +public: + _CheckButtonRegister(void); + virtual ~_CheckButtonRegister(void); +}; // _CheckButtonRegister + +/** +* @class _ButtonRegister +* @brief This class is an implementation of a %_ButtonRegister. +* @since 2.0 +* +* The %_ButtonRegister Class contains that declaration of Button's maker +* +* +*/ +class _ButtonRegister + : public Tizen::Base::Object +{ +public: + _ButtonRegister(void); + virtual ~_ButtonRegister(void); +}; // _ButtonRegister + +/** +* @class _SliderRegister +* @brief This class is an implementation of a %_SliderRegister. +* @since 2.0 +* +* The %_SliderRegister Class contains that declaration of Slider's maker +* +* +*/ +class _SliderRegister + : public Tizen::Base::Object +{ +public: + _SliderRegister(void); + virtual ~_SliderRegister(void); +}; // _SliderRegister + +/** +* @class _SlidableListRegister +* @brief This class is an implementation of a %_SlidableListRegister. +* @since 2.0 +* +* The %_SlidableListRegister Class contains that declaration of SlidableList's maker +* +* +*/ +class _SlidableListRegister + : public Tizen::Base::Object +{ +public: + _SlidableListRegister(void); + virtual ~_SlidableListRegister(void); +}; // _SlidableListRegister + +/** +* @class _SlidableGroupedListRegister +* @brief This class is an implementation of a %_SlidableGroupedListRegister. +* @since 2.0 +* +* The %_SlidableGroupedListRegister Class contains that declaration of SlidableGroupedList's maker +* +* +*/ +class _SlidableGroupedListRegister + : public Tizen::Base::Object +{ +public: + _SlidableGroupedListRegister(void); + virtual ~_SlidableGroupedListRegister(void); +}; // _SlidableGroupedListRegister + +/** +* @class _ScrollPanelRegister +* @brief This class is an implementation of a %_ScrollPanelRegister. +* @since 2.0 +* +* The %_ScrollPanelRegister Class contains that declaration of ScrollPanel's maker +* +* +*/ +class _ScrollPanelRegister + : public Tizen::Base::Object +{ +public: + _ScrollPanelRegister(void); + virtual ~_ScrollPanelRegister(void); +}; // _ScrollPanelRegister + +/** +* @class _TableViewRegister +* @brief This class is an implementation of a %_TableViewRegister. +* @since 2.0 +* +* The %_TableViewRegister Class contains that declaration of TableView's maker +* +* +*/ +class _TableViewRegister + : public Tizen::Base::Object +{ +public: + _TableViewRegister(); + virtual ~_TableViewRegister(); +}; // _TableViewRegister + +/** +* @class _GroupedTableViewRegister +* @brief This class is an implementation of a %_GroupedTableViewRegister. +* @since 2.0 +* +* The %_GroupedTableViewRegister Class contains that declaration of GroupedTableView's maker +* +* +*/ +class _GroupedTableViewRegister + : public Tizen::Base::Object +{ +public: + _GroupedTableViewRegister(); + virtual ~_GroupedTableViewRegister(); +}; // _GroupedTableViewRegister + +/** +* @class _SectionTableViewRegister +* @brief This class is an implementation of a %_SectionTableViewRegister. +* @since 2.0 +* +* The %_SectionTableViewRegister Class contains that declaration of SectionTableView's maker +* +* +*/ +class _SectionTableViewRegister + : public Tizen::Base::Object +{ +public: + _SectionTableViewRegister(); + virtual ~_SectionTableViewRegister(); +}; // _SectionTableViewRegister + +/** +* @class _ProgressRegister +* @brief This class is an implementation of a %_ProgressRegister. +* @since 2.0 +* +* The %_ProgressRegister Class contains that declaration of Progress's maker +* +* +*/ +class _ProgressRegister + : public Tizen::Base::Object +{ +public: + _ProgressRegister(void); + virtual ~_ProgressRegister(void); +}; // _ProgressRegister + +/** +* @class _PopupRegister +* @brief This class is an implementation of a %_PopupRegister. +* @since 2.0 +* +* The %_PopupRegister Class contains that declaration of Popup's maker +* +* +*/ +class _PopupRegister + : public Tizen::Base::Object +{ +public: + _PopupRegister(void); + virtual ~_PopupRegister(void); +}; // _PopupRegister + +/** +* @class _PanelRegister +* @brief This class is an implementation of a %_PanelRegister. +* @since 2.0 +* +* The %_PanelRegister Class contains that declaration of Panel's maker +* +* +*/ +class _PanelRegister + : public Tizen::Base::Object +{ +public: + _PanelRegister(void); + virtual ~_PanelRegister(void); +}; // _PanelRegister + +/** +* @class _OverlayPanelRegister +* @brief This class is an implementation of a %_OverlayPanelRegister. +* @since 2.0 +* +* The %_OverlayPanelRegister Class contains that declaration of OverlayPanel's maker +* +* +*/ +class _OverlayPanelRegister + : public Tizen::Base::Object +{ +public: + _OverlayPanelRegister(void); + virtual ~_OverlayPanelRegister(void); +}; // _OverlayPanelRegister + +/** +* @class _ListRegister +* @brief This class is an implementation of a %_ListRegister. +* @since 2.0 +* +* The %_ListRegister Class contains that declaration of List's maker +* +* +*/ +class _ListRegister + : public Tizen::Base::Object +{ +public: + _ListRegister(void); + virtual ~_ListRegister(void); +}; // _ListRegister + +/** +* @class _LabelRegister +* @brief This class is an implementation of a %_LabelRegister. +* @since 2.0 +* +* The %_LabelRegister Class contains that declaration of Label's maker +* +* +*/ +class _LabelRegister + : public Tizen::Base::Object +{ +public: + _LabelRegister(void); + virtual ~_LabelRegister(void); +}; // _LabelRegister + +/** +* @class _IconListRegister +* @brief This class is an implementation of a %_IconListRegister. +* @since 2.0 +* +* The %_IconListRegister Class contains that declaration of IconList's maker +* +* +*/ +class _IconListRegister + : public Tizen::Base::Object +{ +public: + _IconListRegister(void); + virtual ~_IconListRegister(void); +}; // _IconListRegister + +/** +* @class _GroupedListRegister +* @brief This class is an implementation of a %_GroupedListRegister. +* @since 2.0 +* +* The %_GroupedListRegister Class contains that declaration of GroupedList's maker +* +* +*/ +class _GroupedListRegister + : public Tizen::Base::Object +{ +public: + _GroupedListRegister(void); + virtual ~_GroupedListRegister(void); +}; // _GroupedListRegister + +/** +* @class _FlashRegister +* @brief This class is an implementation of a %_FlashRegister. +* @since 2.0 +* +* The %_FlashRegister Class contains that declaration of Flash's maker +* +* +*/ +class _FlashRegister + : public Tizen::Base::Object +{ +public: + _FlashRegister(void); + virtual ~_FlashRegister(void); +}; // _FlashRegister + +/** +* @class _ExpandableListRegister +* @brief This class is an implementation of a %_ExpandableListRegister. +* @since 2.0 +* +* The %_ExpandableListRegister Class contains that declaration of ExpandableList's maker +* +* +*/ +class _ExpandableListRegister + : public Tizen::Base::Object +{ +public: + _ExpandableListRegister(void); + virtual ~_ExpandableListRegister(void); +}; // _ExpandableListRegister + +/** +* @class _EditTimeRegister +* @brief This class is an implementation of a %_EditTimeRegister. +* @since 2.0 +* +* The %_EditTimeRegister Class contains that declaration of EditTime's maker +* +* +*/ +class _EditTimeRegister + : public Tizen::Base::Object +{ +public: + _EditTimeRegister(void); + virtual ~_EditTimeRegister(void); +}; // _EditTimeRegister + +/** +* @class _EditFieldRegister +* @brief This class is an implementation of a %_EditFieldRegister. +* @since 2.0 +* +* The %_EditFieldRegister Class contains that declaration of EditField's maker +* +* +*/ +class _EditFieldRegister + : public Tizen::Base::Object +{ +public: + _EditFieldRegister(void); + virtual ~_EditFieldRegister(void); +}; // _EditFieldRegister + +/** +* @class _EditDateRegister +* @brief This class is an implementation of a %_EditDateRegister. +* @since 2.0 +* +* The %_EditDateRegister Class contains that declaration of EditDate's maker +* +* +*/ +class _EditDateRegister + : public Tizen::Base::Object +{ +public: + _EditDateRegister(void); + virtual ~_EditDateRegister(void); +}; // _EditDateRegister + +/** +* @class _EditAreaRegister +* @brief This class is an implementation of a %_EditAreaRegister. +* @since 2.0 +* +* The %_EditAreaRegister Class contains that declaration of EditArea's maker +* +* +*/ +class _EditAreaRegister + : public Tizen::Base::Object +{ +public: + _EditAreaRegister(void); + virtual ~_EditAreaRegister(void); +}; // _EditAreaRegister + +/** +* @class _CustomListRegister +* @brief This class is an implementation of a %_CustomListRegister. +* @since 2.0 +* +* The %_CustomListRegister Class contains that declaration of CustomList's maker +* +* +*/ +class _CustomListRegister + : public Tizen::Base::Object +{ +public: + _CustomListRegister(void); + virtual ~_CustomListRegister(void); +}; // _CustomListRegister + +/** +* @class _ColorPickerRegister +* @brief This class is an implementation of a %_ColorPickerRegister. +* @since 2.0 +* +* The %_ColorPickerRegister Class contains that declaration of ColorPicker's maker +* +* +*/ +class _ColorPickerRegister + : public Tizen::Base::Object +{ +public: + _ColorPickerRegister(void); + virtual ~_ColorPickerRegister(void); +}; // _ColorPickerRegister + +/** +* @class _TabBarRegister +* @brief This class is an implementation of a %_TabBarRegister. +* @since 2.0 +* +* The %_TabBarRegister Class contains that declaration of TabBar's maker +* +* +*/ +class _TabBarRegister + : public Tizen::Base::Object +{ +public: + _TabBarRegister(void); + virtual ~_TabBarRegister(void); +}; // _TabBarRegister + +/** +* @class _HeaderRegister +* @brief This class is an implementation of a %_HeaderRegister. +* @since 2.0 +* +* The %_HeaderRegister Class contains that declaration of Header's maker +* +* +*/ +class _HeaderRegister + : public Tizen::Base::Object +{ +public: + _HeaderRegister(void); + virtual ~_HeaderRegister(void); +}; // HeaderRegister + +/** +* @class _FooterRegister +* @brief This class is an implementation of a %_FooterRegister. +* @since 2.0 +* +* The %_FooterRegister Class contains that declaration of Footer's maker +* +* +*/ +class _FooterRegister + : public Tizen::Base::Object +{ +public: + _FooterRegister(void); + virtual ~_FooterRegister(void); +}; // _FooterRegister + +/** +* @class _GalleryRegister +* @brief This class is an implementation of a %_GalleryRegister. +* @since 2.0 +* +* The %_GalleryRegister Class contains that declaration of Gallery's maker +* +* +*/ +class _GalleryRegister + : public Tizen::Base::Object +{ +public: + _GalleryRegister(void); + virtual ~_GalleryRegister(void); +}; // _GalleryRegister + +/** +* @class _IconListViewRegister +* @brief This class is an implementation of a %_IconListViewRegister. +* @since 2.0 +* +* The %_IconListViewRegister Class contains that declaration of IconListView's maker +* +* +*/ +class _IconListViewRegister + : public Tizen::Base::Object +{ +public: + _IconListViewRegister(void); + virtual ~_IconListViewRegister(void); +}; // _IconListViewRegister + +/** +* @class _ListViewRegister +* @brief This class is an implementation of a %_ListViewRegister. +* @since 2.0 +* +* The %_ListViewRegister Class contains that declaration of ListView's maker +* +* +*/ +class _ListViewRegister + : public Tizen::Base::Object +{ +public: + _ListViewRegister(void); + virtual ~_ListViewRegister(void); +}; // _ListViewRegister + +/** +* @class _GroupedListViewRegister +* @brief This class is an implementation of a %_GroupedListViewRegister. +* @since 2.0 +* +* The %_GroupedListViewRegister Class contains that declaration of GroupedListView's maker +* +* +*/ +class _GroupedListViewRegister + : public Tizen::Base::Object +{ +public: + _GroupedListViewRegister(void); + virtual ~_GroupedListViewRegister(void); +}; // _GroupedListViewRegister + +/** +* @class _ExpandableEditAreaRegister +* @brief This class is an implementation of a %_ExpandableEditAreaRegister. +* @since 2.0 +* +* The %_ExpandableEditAreaRegister Class contains that declaration of ExpandableEditArea's maker +* +* +*/ +class _ExpandableEditAreaRegister + : public Tizen::Base::Object +{ +public: + _ExpandableEditAreaRegister(void); + virtual ~_ExpandableEditAreaRegister(void); +}; // _ExpandableEditAreaRegister + +/** +* @class _SearchBarRegister +* @brief This class is an implementation of a %_SearchBarRegister. +* @since 2.0 +* +* The %_SearchBarRegister Class contains that declaration of SearchBar's maker +* +* +*/ +class _SearchBarRegister + : public Tizen::Base::Object +{ +public: + _SearchBarRegister(void); + virtual ~_SearchBarRegister(void); +}; // _SearchBarRegister + +/** +* @class _TextBoxRegister +* @brief This class is an implementation of a %_TextBoxRegister. +* @since 2.0 +* +* The %_TextBoxRegister Class contains that declaration of TextBox's maker +* +* +*/ +class _TextBoxRegister + : public Tizen::Base::Object +{ +public: + _TextBoxRegister(void); + virtual ~_TextBoxRegister(void); +}; // _TextBoxRegister + +/** +* @class _MapRegister +* @brief This class is an implementation of a %_MapRegister. +* @since 2.0 +* +* The %_MapRegister Class contains that declaration of Map's maker +* +* +*/ +class _MapRegister + : public Tizen::Base::Object +{ +public: + _MapRegister(void); + virtual ~_MapRegister(void); +}; // _MapRegister + +/** +* @class _WebRegister +* @brief This class is an implementation of a %_WebRegister. +* @since 2.0 +* +* The %_WebRegister Class contains that declaration of Web's maker +* +* +*/ +class _WebRegister + : public Tizen::Base::Object +{ +public: + _WebRegister(void); + virtual ~_WebRegister(void); +}; // _WebRegister + +/** +* @class _AdRegister +* @brief This class is an implementation of a %_AdRegister. +* @since 2.0 +* +* The %_AdRegister Class contains that declaration of Ad's maker +* +* +*/ +class _AdRegister + : public Tizen::Base::Object +{ +public: + _AdRegister(void); + virtual ~_AdRegister(void); +}; // _AdRegister + +/** +* @class _SplitPanel +* @brief This class is an implementation of a %_SplitPanel. +* @since 2.0 +* +* The %_SplitPanel Class contains that declaration of SplitPanel's maker +* +* +*/ +class _SplitPanelRegister + : public Tizen::Base::Object +{ +public: + _SplitPanelRegister(void); + virtual ~_SplitPanelRegister(void); +}; // _SplitPanelRegister + +/** +* @class _NotificationFrame +* @brief This class is an implementation of a %_NotificationFrame. +* @since 2.0 +* +* The %_NotificationFrame Class contains that declaration of NotificationFrame maker +* +* +*/ +class _NotificationFrameRegister + : public Tizen::Base::Object +{ +public: + _NotificationFrameRegister(void); + virtual ~_NotificationFrameRegister(void); +}; // _NotificationFrameRegister + +/** +* @class _QuickPanelFrame +* @brief This class is an implementation of a %_QuickPanelFrame. +* @since 2.0 +* +* The %_QuickPanelFrame Class contains that declaration of QuickPanelFrame maker +* +* +*/ +class _QuickPanelFrameRegister + : public Tizen::Base::Object +{ +public: + _QuickPanelFrameRegister(void); + virtual ~_QuickPanelFrameRegister(void); +}; // _QuickPanelFrameRegister + +} } } // Tizen::Ui::Controls +#endif // _FUI_INTERNAL_UI_BUILDER_REGISTER_H_ diff --git a/src/ui/inc/FUi_UiBuilderXmlHandler.h b/src/ui/inc/FUi_UiBuilderXmlHandler.h new file mode 100644 index 0000000..8ef1b67 --- /dev/null +++ b/src/ui/inc/FUi_UiBuilderXmlHandler.h @@ -0,0 +1,84 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** +* @file FUi_UiBuilderXmlHandler.h +* @brief This is the header file for the %_UiBuilderXmlHandler class. +* +* This header file contains the declarations of the %_UiBuilderXmlHandler class. +*/ + +#ifndef _FUI_INTERNAL_UI_BUILDER_XML_HANDLER_H_ +#define _FUI_INTERNAL_UI_BUILDER_XML_HANDLER_H_ + + + +#include +#include +#include +#include "FUi_UiBuilder.h" + +namespace Tizen { namespace Ui +{ +/** +* @class _UiBuilderXmlHandler +* @brief This class is an implementation of a %_UiBuilderXmlHandler. +* @since 2.0 +* +* The %_UiBuilerXmlHandler Class contains that control's information by parsing the XML. +* +* +*/ +class _UiBuilderXmlHandler + : public Tizen::Base::Object +{ +public: + _UiBuilderXmlHandler(void); + virtual ~_UiBuilderXmlHandler(void); + bool Construct(_UiBuilder* pGenerator); + + result ParseXml(char* pXmlBuffer, int size); + void SetAttribute(const xmlChar** pAtts); + void SetProperty(const xmlChar** pAtts); + void SetItem(const xmlChar* pName, const xmlChar** pAtts); + void SetXmlVersion(const xmlChar** pAttributes); + void ParseAttribute(const xmlChar** pAttributes, int index, const Tizen::Base::String& name); + +private: + _UiBuilderXmlHandler(const _UiBuilderXmlHandler& rhs); + _UiBuilderXmlHandler& operator =(const _UiBuilderXmlHandler& rhs); + +public: + static const int LAYOUT_SETTING = -1; + _UiBuilder* __pGenerator; + _UiBuilderControl* __pControl; + bool __formXmlResolutionExists; + Tizen::Base::String __errorLog; + result __errorResult; + +private: + int __layoutMode; + Tizen::Base::String __xPosition; + Tizen::Base::String __yPosition; + Tizen::Base::String __width; + Tizen::Base::String __height; + + _UiBuilderControlLayout* __pProperty; +}; // _UiBuilderXmlHandler + +} } // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_BUILDER_XML_HANDLER_H_ diff --git a/src/ui/inc/FUi_UiEvent.h b/src/ui/inc/FUi_UiEvent.h new file mode 100644 index 0000000..179d995 --- /dev/null +++ b/src/ui/inc/FUi_UiEvent.h @@ -0,0 +1,108 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiEvent.h + * @brief This is the header file for the _UiEvent class. + * + * This header file contains the declarations of the %_UiEvent class. + */ + +#ifndef _FUI_INTERNAL_UI_EVENT_H_ +#define _FUI_INTERNAL_UI_EVENT_H_ + +#include +#include +#include +#include "FUi_UiEventTypes.h" +#include "FUi_IUiEventListener.h" +#include "FUi_IUiEventPreviewer.h" + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +} } } + +namespace Tizen {namespace Ui +{ + +class _Control; +typedef Tizen::Base::_HandleT _UiObjectHandle; + +/** +* This is internal. If used in an application, the application can get rejected during the certification process. +* @class _UiEvent +* @brief This class impliments _UiEvent and +* fire the Window Event object of a Ui Control. +*/ +class _OSP_EXPORT_ _UiEvent + : public Tizen::Base::Object +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _UiEvent(const _UiObjectHandle& destination, const _UiObjectHandle& source, _UiEventRouteType routeType); + _UiEvent(const _UiEvent& rhs); + + /** + * This is the default class destructor. + * + */ + virtual ~_UiEvent(void); + +public: + _UiEvent& operator =(const _UiEvent& rhs); + +public: + _UiObjectHandle GetDestination(void) const; + _UiObjectHandle GetSource(void) const; + void SetRouteType(_UiEventRouteType routeType); + _UiEventRouteType GetRouteType(void) const; + void SetOriginalDestination(const _Control& control); + _UiObjectHandle GetOriginalDestination(void) const; + result ProcessPreviewEvent(const _Control& control, bool& isFiltered); + result ProcessEvent(const _Control& control, bool& isFiltered); + result ProcessListener(const _IUiEventListener& listener, bool& isFiltered); + +public: + virtual _UiEvent* CloneN(void) const = 0; + virtual _UiEventType GetEventType(void) const = 0; + const _Control* GetControl(const _UiObjectHandle& handle) const; + void SetAccessibilityEvent(bool set); + bool GetAccessibilityEvent(void) const; + +private: + virtual bool IsEventReceivable(const _Control& control) const; + virtual result OnPreviewEventProcessing(const _Control& control, bool& isFiltered) = 0; + virtual result OnEventProcessing(const _Control& control, bool& isFiltered) = 0; + virtual result OnListenerProcessing(const _IUiEventListener& listener, bool& isFiltered) = 0; + virtual result OnEventHandled(const _Control& control); + +private: + _UiObjectHandle __destination; + _UiObjectHandle __source; + _UiObjectHandle __originalDestination; + + _UiEventRouteType __routeType; + bool __accessibilityEvent; +}; + +}} // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_EVENT_H_ diff --git a/src/ui/inc/FUi_UiEventManager.h b/src/ui/inc/FUi_UiEventManager.h new file mode 100644 index 0000000..9aab001 --- /dev/null +++ b/src/ui/inc/FUi_UiEventManager.h @@ -0,0 +1,124 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiEventManager.h + * @brief This is the header file for the _UiEventManager class. + * + * This header file contains the declarations of the %_UiEventManager class. + */ + +#ifndef _FUI_INTERNAL_UI_EVENT_MANAGER_H_ +#define _FUI_INTERNAL_UI_EVENT_MANAGER_H_ + +#include +#include +#include +#include +#include "FUi_UiEventTypes.h" +#include "FUi_UiTouchEvent.h" +#include "FUi_UiKeyEvent.h" + +namespace Tizen { namespace Base { namespace Collection +{ +template class LinkedListT; +template class HashMapT; +} } } + +namespace Tizen { namespace Ui +{ + +class _IUiEventManager; +class _UiEvent; +class _IUiEventListener; +class _ITouchEventListener; +class _IKeyEventListener; +class _IFocusEventListener; +class _INotificationEventListener; +class _UiEventListenerMapDeleter; + +/** +* This is internal. If used in an application, the application can get rejected during the certification process. +* @class _UiEventManager +* @brief This class impliments _UiEventManager and +* fire the Window Event object of a Ui Control. +*/ +class _OSP_EXPORT_ _UiEventManager +{ +public: + static void Initialize(void); + static void Release(void); + static _UiEventManager* GetInstance(void); + +public: + result AddTouchEventListener(const _ITouchEventListener& listener); + result AddKeyEventListener(const _IKeyEventListener& listener); + result AddFocusEventListener(const _IFocusEventListener& listener); + result AddNotificationEventListener(const _INotificationEventListener& listener); + + result RemoveTouchEventListener(const _ITouchEventListener& listener); + result RemoveKeyEventListener(const _IKeyEventListener& listener); + result RemoveFocusEventListener(const _IFocusEventListener& listener); + result RemoveNotificationEventListener(const _INotificationEventListener& listener); + + result AddPostKeyEventListener(const _IKeyEventListener& listener); + result RemovePostKeyEventListener(const _IKeyEventListener& listener); + + result SendEvent(const _UiEvent& event); + result PostEvent(const _UiEvent& event); + + result GenerateKeyEvent(KeyState keyState, _KeyCode keyCode, _KeyModifier keyModifier, bool async = true); + result GenerateTouchEvent(_TouchStatus touchStatus, int x, int y, bool async = true); + + _IUiEventManager* GetEventManager(void) const; + + void SetKeyCapture(const _Control& control, _KeyCode keyCode); + void ReleaseKeyCapture(const _Control& control, _KeyCode keyCode); + +private: + static void InitInstance(void); + result AddEventListener(_UiEventType eventType, bool postListener, const _IUiEventListener& listener); + result RemoveEventListener(_UiEventType eventType, bool postListener, const _IUiEventListener& listener); + bool IsListenerRegistered(_UiEventType eventType, bool postListener, const _IUiEventListener& listener); + + result Fire(const _UiEvent& notification); + Tizen::Base::Collection::LinkedListT <_IUiEventListener*>* GetEventListeners(_UiEventType eventType, bool postListener) const; + result ProcessListener(const _UiEvent& event, bool& isFiltered); + result ProcessPostListener(const _UiEvent& event, bool& isFiltered); + result ProcessListener(const _UiEvent& event, bool postListener, bool& isFiltered); + result ProcessEvent(const _UiEvent& event, bool& isFiltered); + result ProcessGlobalGesture(const _UiEvent& event, bool& isFiltered); + result MakeRoutingPath(Tizen::Base::Collection::LinkedListT <_UiObjectHandle>& tunnelingPath, Tizen::Base::Collection::LinkedListT <_UiObjectHandle>& bubblingPath, const _UiEvent& event); + result ProcessTunnelingEvent(const Tizen::Base::Collection::LinkedListT <_UiObjectHandle>& routingPath, const _UiEvent& event, bool& isFiltered); + result ProcessBubblingEvent(const Tizen::Base::Collection::LinkedListT <_UiObjectHandle>& routingPath, const _UiEvent& event, bool& isFiltered); + _UiObjectHandle GetTarget(void) const; + _UiObjectHandle GetTarget(int x, int y) const; + void RemoveAllEventListenerList(Tizen::Base::Collection::HashMapT<_UiEventType, Tizen::Base::Collection::LinkedListT<_IUiEventListener*>*>* pMap); + _UiEventManager(void); + ~_UiEventManager(void); + _UiEventManager(const _UiEventManager& rhs); + _UiEventManager& operator =(const _UiEventManager& rhs); + +private: + static _UiEventManager* __pInstance; + std::unique_ptr<_IUiEventManager> __pEventManager; + std::unique_ptr*> > __pEventListenerMap; + std::unique_ptr*> > __pPostEventListenerMap; +}; + +}} // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_EVENT_MANAGER_H_ diff --git a/src/ui/inc/FUi_UiEventTypes.h b/src/ui/inc/FUi_UiEventTypes.h new file mode 100644 index 0000000..67f53e7 --- /dev/null +++ b/src/ui/inc/FUi_UiEventTypes.h @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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 _FUI_INTERNAL_UI_EVENT_TYPES_H_ +#define _FUI_INTERNAL_UI_EVENT_TYPES_H_ + +#include +#include + +namespace Tizen {namespace Ui +{ + +/** + * @enum _EventType + * + * Defines constants used to identify touch status. + * + * @since 2.0 + */ +enum _UiEventType +{ + _UI_EVENT_TOUCH, /**< The touch event type */ + _UI_EVENT_KEY, /**< The key event type */ + _UI_EVENT_FOCUS, /**< The focus event type */ + _UI_EVENT_NOTIFICAITON /**< The notification event type */ +}; + +enum _UiEventRouteType +{ + _UI_EVENT_ROUTE_TUNNEL_BUBBLE, + _UI_EVENT_ROUTE_DIRECT +}; + +enum _UiTouchEventDelivery +{ + _UI_TOUCH_EVENT_DELIVERY_NO, + _UI_TOUCH_EVENT_DELIVERY_YES, + _UI_TOUCH_EVENT_DELIVERY_FORCED_YES, +}; + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_UI_EVENT_TYPES_H_ \ No newline at end of file diff --git a/src/ui/inc/FUi_UiFocusEvent.h b/src/ui/inc/FUi_UiFocusEvent.h new file mode 100644 index 0000000..6ac95d6 --- /dev/null +++ b/src/ui/inc/FUi_UiFocusEvent.h @@ -0,0 +1,82 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiFocusEvent.h + * @brief This is the header file for the _UiFocusEvent class. + * + * This header file contains the declarations of the %_UiFocusEvent class. @n + */ + +#ifndef _FUI_INTERNAL_UI_FOCUS_EVENT_H_ +#define _FUI_INTERNAL_UI_FOCUS_EVENT_H_ + +#include +#include "FUi_UiEvent.h" + +namespace Tizen {namespace Ui +{ + +class _IFocusEventListener; + +// +//This is internal. If used in an application, the application can get rejected during the certification process. +//@class _UiFocusEvent +//@brief This class impliments _UiFocusEvent and +//fire the Window Event object of a Ui Control. +// + +class _UiFocusEvent + : public _UiEvent +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _UiFocusEvent(const _UiObjectHandle& destination, FocusStatus focusState, _UiEventRouteType routeType = _UI_EVENT_ROUTE_DIRECT, const _UiObjectHandle& source = _UiObjectHandle()); + _UiFocusEvent(const _UiFocusEvent& rhs); + + /** + * This is the default class destructor. + * + */ + virtual ~_UiFocusEvent(void); + +public: + _UiFocusEvent& operator =(const _UiFocusEvent& rhs); + +public: + FocusStatus GetFocusState(void) const; + +private: + virtual _UiFocusEvent* CloneN(void) const; + virtual _UiEventType GetEventType(void) const; + virtual result OnPreviewEventProcessing(const _Control& control, bool& isFiltered); + virtual result OnEventProcessing(const _Control& control, bool& isFiltered); + virtual result OnListenerProcessing(const _IUiEventListener& listener, bool& isFiltered); + +private: + result FireListener(const _IFocusEventListener* pListener, bool& isFiltered); + +private: + FocusStatus __focusState; +}; + +}} // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_FOCUS_EVENT_H_ diff --git a/src/ui/inc/FUi_UiKeyEvent.h b/src/ui/inc/FUi_UiKeyEvent.h new file mode 100644 index 0000000..f080302 --- /dev/null +++ b/src/ui/inc/FUi_UiKeyEvent.h @@ -0,0 +1,587 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiKeyEvent.h + * @brief This is the header file for the _UiKeyEvent class. + * + * This header file contains the declarations of the %_UiKeyEvent class. + */ + +#ifndef _FUI_INTERNAL_UI_KEY_EVENT_H_ +#define _FUI_INTERNAL_UI_KEY_EVENT_H_ + +#include +#include "FUi_UiEvent.h" + +namespace Tizen {namespace Ui +{ + +enum _KeyCode +{ + /** + * Invalid key + */ + _KEY_INVALID = KEY_INVALID, + + /** + * Up side key + */ + _KEY_SIDE_UP = KEY_SIDE_UP, + + /** + * Down side key + */ + _KEY_SIDE_DOWN = KEY_SIDE_DOWN, + + /** + * Ok key + */ + _KEY_OK = KEY_OK, + + /** + * Clear key + */ + _KEY_CLEAR = KEY_CLEAR, + + /** + * Camera key + */ + _KEY_CAMERA = KEY_CAMERA, + + /** + * Task switcher key + */ + _KEY_SWITCH = KEY_SWITCH, + + /** + * 0 key + */ + _KEY_0 = KEY_0, + + /** + * 1 key + */ + _KEY_1 = KEY_1, + + /** + * 2 key + */ + _KEY_2 = KEY_2, + + /** + * 3 key + */ + _KEY_3 = KEY_3, + + /** + * 4 key + */ + _KEY_4 = KEY_4, + + /** + * 5 key + */ + _KEY_5 = KEY_5, + + /** + * 6 key + */ + _KEY_6 = KEY_6, + + /** + * 7 key + */ + _KEY_7 = KEY_7, + + /** + * 8 key + */ + _KEY_8 = KEY_8, + + /** + * 9 key + */ + _KEY_9 = KEY_9, + + /** + * Asterisk key + */ + _KEY_ASTERISK = KEY_ASTERISK, + + /** + * Sharp key + */ + _KEY_SHARP = KEY_SHARP, + + /** + * Left directional key + */ + _KEY_LEFT = KEY_LEFT, + + /** + * Up directional key + */ + _KEY_UP = KEY_UP, + + /** + * Down directional key + */ + _KEY_DOWN = KEY_DOWN, + + /** + * Right directional key + */ + _KEY_RIGHT = KEY_RIGHT, + + /* + * Placeholder + */ + _KEY_MAX = KEY_MAX, + + /** + * A key + */ + _KEY_A = KEY_A, + + /** + * B key + */ + _KEY_B = KEY_B, + + /** + * C key + */ + _KEY_C = KEY_C, + + /** + * D key + */ + _KEY_D = KEY_D, + + /** + * E key + */ + _KEY_E = KEY_E, + + /** + * F key + */ + _KEY_F = KEY_F, + + /** + * G key + */ + _KEY_G = KEY_G, + + /** + * H key + */ + _KEY_H = KEY_H, + + /** + * I key + */ + _KEY_I = KEY_I, + + /** + * J key + */ + _KEY_J = KEY_J, + + /** + * K key + */ + _KEY_K = KEY_K, + + /** + * L key + */ + _KEY_L = KEY_L, + + /** + * M key + */ + _KEY_M = KEY_M, + + /** + * N key + */ + _KEY_N = KEY_N, + + /** + * O key + */ + _KEY_O = KEY_O, + + /** + * P key + */ + _KEY_P = KEY_P, + + /** + * Q key + */ + _KEY_Q = KEY_Q, + + /** + * R key + */ + _KEY_R = KEY_R, + + /** + * S key + */ + _KEY_S = KEY_S, + + /** + * T key + */ + _KEY_T = KEY_T, + + /** + * U key + */ + _KEY_U = KEY_U, + + /** + * V key + */ + _KEY_V = KEY_V, + + /** + * W key + */ + _KEY_W = KEY_W, + + /** + * Y key + */ + _KEY_Y = KEY_Y, + + /** + * X key + */ + _KEY_X = KEY_X, + + /** + * Z key + */ + _KEY_Z = KEY_Z, + + /** + * Backspace key + */ + _KEY_BACKSPACE = KEY_BACKSPACE, + + /** + * Comma key + */ + _KEY_COMMA = KEY_COMMA, + + /** + * Enter key + */ + _KEY_ENTER = KEY_ENTER, + + /** + * Caps Lock key + */ + _KEY_CAPSLOCK = KEY_CAPSLOCK, + + /** + * Question key + */ + _KEY_QUESTION = KEY_QUESTION, + + /** + * Alt key + */ + _KEY_ALT = KEY_ALT, + + /** + * Language Symbol key + */ + _KEY_SYM = KEY_SYM, + + /** + * Language Setting key + */ + _KEY_SETTING = KEY_SETTING, + + /** + * Space key + */ + _KEY_SPACE = KEY_SPACE, + + /** + * Dot key + */ + _KEY_DOT = KEY_DOT, + + /** + * Function key + */ + _KEY_FN = KEY_FN, + + /** + * Camera half shutter key + */ + _KEY_CAMERA_HALF_SHUTTER = KEY_CAMERA_HALF_SHUTTER, + + /** + * Character symbol 1 key + */ + _KEY_CHAR_SYM_1 = KEY_CHAR_SYM_1, + + /** + * Character symbol 2 key + */ + _KEY_CHAR_SYM_2 = KEY_CHAR_SYM_2, + + /** + * Character symbol 3 key + */ + _KEY_CHAR_SYM_3 = KEY_CHAR_SYM_3, + + /** + * Character symbol 4 key + */ + _KEY_CHAR_SYM_4 = KEY_CHAR_SYM_4, + + /** + * Character symbol 5 key + */ + _KEY_CHAR_SYM_5 = KEY_CHAR_SYM_5, + + /** + * Character symbol 6 key + */ + _KEY_CHAR_SYM_6 = KEY_CHAR_SYM_6, + + /** + * Character symbol 7 key + */ + _KEY_CHAR_SYM_7 = KEY_CHAR_SYM_7, + + /** + * Character symbol 8 key + */ + _KEY_CHAR_SYM_8 = KEY_CHAR_SYM_8, + + /** + * Character symbol 9 key + */ + _KEY_CHAR_SYM_9 = KEY_CHAR_SYM_9, + + /** + * Character symbol A key + */ + _KEY_CHAR_SYM_A = KEY_CHAR_SYM_A, + + /** + * Character symbol B key + */ + _KEY_CHAR_SYM_B = KEY_CHAR_SYM_B, + + /** + * Character symbol C key + */ + _KEY_CHAR_SYM_C = KEY_CHAR_SYM_C, + + /** + * Character symbol D key + */ + _KEY_CHAR_SYM_D = KEY_CHAR_SYM_D, + + /** + * Character symbol E key. + */ + _KEY_CHAR_SYM_E = KEY_CHAR_SYM_E, + + /** + * Character symbol F key. + */ + _KEY_CHAR_SYM_F = KEY_CHAR_SYM_F, + + /** + * Special function 1 key + */ + _KEY_FN_1 = KEY_FN_1, + + /** + * Special function 2 key + */ + _KEY_FN_2 = KEY_FN_2, + + /** + * Special function 3 key + */ + _KEY_FN_3 = KEY_FN_3, + + /** + * Special function 4 key + */ + _KEY_FN_4 = KEY_FN_4, + + /** + * Special function 5 key + */ + _KEY_FN_5 = KEY_FN_5, + + /** + * The power key + */ + _KEY_POWER_HOLD = KEY_POWER_HOLD, + + /** + * The delete key + */ + _KEY_DELETE = KEY_DELETE, + + _KEY_CTRL_L = KEY_HARDWARE_MAX, + + _KEY_CTRL_R, + + _KEY_SHIFT_L, + + _KEY_SHIFT_R, + + _KEY_NUM_LEFT, + + _KEY_NUM_RIGHT, + + _KEY_NUM_UP, + + _KEY_NUM_DOWN, + + _KEY_HARDWARE_MAX, + /** + * internal Key - end + */ + _KEY_END, + + /** + * internal Key - send + */ + _KEY_SEND +}; + +enum _KeyModifier +{ + _KEY_MODIFIER_NONE = 0, /**< No active modifiers */ + _KEY_MODIFIER_SHIFT = 1 << 0, /**< "Control" is pressed */ + _KEY_MODIFIER_CTRL = 1 << 1, /**< "Alt" is pressed */ + _KEY_MODIFIER_ALT = 1 << 2, /**< "Shift" is pressed */ + _KEY_MODIFIER_WIN = 1 << 3, /**< "Win" (between "Ctrl" and "Alt") is pressed */ + _KEY_MODIFIER_SCROLL = 1 << 4, /**< "AltGr" is pressed */ + _KEY_MODIFIER_NUM = 1 << 5, + _KEY_MODIFIER_CAPS = 1 << 6, + _KEY_LOCK_SCROLL = 1 << 7, + _KEY_LOCK_NUM = 1 << 8, + _KEY_LOCK_CAPS = 1 << 9, + _KEY_LOCK_SHIFT = 1 << 10, + _KEY_MODIFIER_ALTGR = 1 << 11, + _KEY_MODIFIER_LAST +}; + +class _OSP_EXPORT_ _KeyInfo +{ +public: + _KeyInfo(KeyState keyState, _KeyCode keyCode, int keyModifier, void* pUserData); + ~_KeyInfo(void); + _KeyInfo(const _KeyInfo& rhs); + _KeyInfo& operator =(const _KeyInfo& rhs); + +public: + void SetKeyState(KeyState keyState); + KeyState GetKeyState(void) const; + + void SetKeyCode(_KeyCode keyCode); + _KeyCode GetKeyCode(void) const; + + void SetKeyModifier(int keyModifier); + int GetKeyModifier(void) const; + + void SetUserData(void* pUserData); + void* GetUserData(void) const; + +private: + KeyState __keyState; + _KeyCode __keyCode; + int __keyModifier; + void* __pUserData; +}; + +class _IKeyEventListener; + +/** +* This is internal. If used in an application, the application can get rejected during the certification process. +* @class _UiKeyEvent +* @brief This class impliments _UiKeyEvent and +* fire the Window Event object of a Ui Control. +*/ +class _UiKeyEvent + : public _UiEvent +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _UiKeyEvent(const _UiObjectHandle& destination, const _KeyInfo& keyInfo, _UiEventRouteType routeType = _UI_EVENT_ROUTE_TUNNEL_BUBBLE, const _UiObjectHandle& source = _UiObjectHandle()); + _UiKeyEvent(const _UiKeyEvent& rhs); + + /** + * This is the default class destructor. + * + */ + virtual ~_UiKeyEvent(void); + +public: + _UiKeyEvent& operator =(const _UiKeyEvent& rhs); + +public: + const _KeyInfo* GetKeyInfo(void) const; + +private: + void SetKeyState(KeyState keyState); + KeyState GetKeyState(void) const; + + void SetKeyCode(_KeyCode keyCode); + _KeyCode GetKeyCode(void) const; + + void SetKeyModifier(int keyModifier); + int GetKeyModifier(void) const; + +private: + virtual _UiKeyEvent* CloneN(void) const; + virtual _UiEventType GetEventType(void) const; + virtual result OnPreviewEventProcessing(const _Control& control, bool& isFiltered); + virtual result OnEventProcessing(const _Control& control, bool& isFiltered); + virtual result OnListenerProcessing(const _IUiEventListener& listener, bool& isFiltered); + +private: + result FireListener(const _IKeyEventListener* pListener, bool& isFiltered); + +private: + _KeyInfo __keyInfo; +}; + +}} // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_KEY_EVENT_H_ diff --git a/src/ui/inc/FUi_UiNotificationEvent.h b/src/ui/inc/FUi_UiNotificationEvent.h new file mode 100644 index 0000000..742e7b6 --- /dev/null +++ b/src/ui/inc/FUi_UiNotificationEvent.h @@ -0,0 +1,86 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiNotificationEvent.h + * @brief This is the header file for the _UiNotificationEvent class. + * + * This header file contains the declarations of the %_UiNotificationEvent class. + */ + +#ifndef _FUI_INTERNAL_UI_NOTIFICATION_EVENT_H_ +#define _FUI_INTERNAL_UI_NOTIFICATION_EVENT_H_ + +#include "FUi_UiEvent.h" + +namespace Tizen { namespace Base { namespace Collection +{ +class IList; +}}} // Tizen::Base::Collection + +namespace Tizen {namespace Ui +{ + +class _INotificationEventListener; + +/** +* This is internal. If used in an application, the application can get rejected during the certification process. +* @class _UiNotificationEvent +* @brief This class impliments _UiNotificationEvent and +* fire the Window Event object of a Ui Control. +*/ +class _OSP_EXPORT_ _UiNotificationEvent + : public _UiEvent +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _UiNotificationEvent(const _UiObjectHandle& destination, Tizen::Base::Collection::IList* pArgs, _UiEventRouteType routeType = _UI_EVENT_ROUTE_TUNNEL_BUBBLE, const _UiObjectHandle& source = _UiObjectHandle()); + _UiNotificationEvent(const _UiNotificationEvent& rhs); + + /** + * This is the default class destructor. + * + */ + virtual ~_UiNotificationEvent(void); + +public: + _UiNotificationEvent& operator =(const _UiNotificationEvent& rhs); + +public: + Tizen::Base::Collection::IList* GetArgs(void) const; + +private: + virtual _UiNotificationEvent* CloneN(void) const; + virtual _UiEventType GetEventType(void) const; + virtual bool IsEventReceivable(const _Control& control) const; + virtual result OnPreviewEventProcessing(const _Control& control, bool& isFiltered); + virtual result OnEventProcessing(const _Control& control, bool& isFiltered); + virtual result OnListenerProcessing(const _IUiEventListener& listener, bool& isFiltered); + +private: + result FireListener(const _INotificationEventListener* pListener, bool& isFiltered); + +private: + Tizen::Base::Collection::IList* __pArgs; +}; + +}} // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_NOTIFICATION_EVENT_H_ diff --git a/src/ui/inc/FUi_UiTouchEvent.h b/src/ui/inc/FUi_UiTouchEvent.h new file mode 100644 index 0000000..bc4656e --- /dev/null +++ b/src/ui/inc/FUi_UiTouchEvent.h @@ -0,0 +1,150 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_UiTouchEvent.h + * @brief This is the header file for the _UiTouchEvent class. + * + * This header file contains the declarations of the %_UiTouchEvent class. + */ + +#ifndef _FUI_INTERNAL_UI_TOUCH_EVENT_H_ +#define _FUI_INTERNAL_UI_TOUCH_EVENT_H_ + +#include +#include +#include "FUi_UiEvent.h" +#include "FUi_ITouchGestureEventListener.h" +#include "FUi_ITouchEventPreviewer.h" + +namespace Tizen {namespace Ui +{ + +enum _TouchStatus +{ + _TOUCH_PRESSED = TOUCH_PRESSED, /**< Touch pressed event type */ + _TOUCH_LONG_PRESSED = TOUCH_LONG_PRESSED, /**< Touch long pressed event type */ + _TOUCH_RELEASED = TOUCH_RELEASED, /**< Touch released event type */ + _TOUCH_MOVED = TOUCH_MOVED, /**< Touch moved event type */ + _TOUCH_DOUBLE_PRESSED = TOUCH_DOUBLE_PRESSED, /**< Touch double pressed event type */ + _TOUCH_FOCUS_IN = TOUCH_FOCUS_IN, /**< Touch focus-in event type */ + _TOUCH_FOCUS_OUT = TOUCH_FOCUS_OUT, /**< Touch focus-out event type */ + _TOUCH_CANCELED = TOUCH_CANCELED, /**< Touch canceled event type */ +}; + +class _OSP_EXPORT_ _TouchInfo +{ +public: + _TouchInfo(void); + _TouchInfo(unsigned long pointId, _TouchStatus status, const Tizen::Graphics::Point& current, const bool isFlick, long long timeStamp); + _TouchInfo(const _TouchInfo& rhs); + _TouchInfo& operator =(const _TouchInfo& rhs); + ~_TouchInfo(void); + +public: + /** + * This method returns the touch status. + * + * @since 2.0 + * @return The touch status + */ + _TouchStatus GetTouchStatus(void) const; + + /** + * This method returns the current position of the touch event. + * + * @since 2.0 + * @return The current position of the touch event + */ + Tizen::Graphics::Point GetCurrentPosition(void) const; + + /** + * This method returns the touch pointId. + * + * @since 2.0 + * @return The touch pointId + */ + unsigned long GetPointId(void) const; + + bool IsFlicked(void) const; + long long GetTimeStamp(void) const; + void SetTouchInfo(unsigned long pointId, _TouchStatus status, Tizen::Graphics::Point& current, bool isFlick, long long timeStamp); + +private: + unsigned long __pointId; + _TouchStatus __touchStatus; + Tizen::Graphics::Point __currentPosition; + bool __isFlicked; + long long __timeStamp; +}; // _TouchInfo + +class _ITouchEventListener; +class _Control; + +/** +* This is internal. If used in an application, the application can get rejected during the certification process. +* @class _UiTouchEvent +* @brief This class impliments _UiTouchEvent and +* fire the Window Event object of a Ui Control. +*/ +class _OSP_EXPORT_ _UiTouchEvent + : public _UiEvent +{ +// Lifecycle +public: + /** + * This is the default class constructor. + * + */ + _UiTouchEvent(const _UiObjectHandle& destination, const _TouchInfo& touchInfo, _UiEventRouteType routeType = _UI_EVENT_ROUTE_TUNNEL_BUBBLE, const _UiObjectHandle& source = _UiObjectHandle()); + _UiTouchEvent(const _UiTouchEvent& rhs); + + /** + * This is the default class destructor. + * + */ + virtual ~_UiTouchEvent(void); + +public: + _UiTouchEvent& operator =(const _UiTouchEvent& rhs); + +public: + const _TouchInfo* GetTouchInfo(void) const; + +private: + virtual _UiTouchEvent* CloneN(void) const; + virtual _UiEventType GetEventType(void) const; + virtual result OnPreviewEventProcessing(const _Control& control, bool& isFiltered); + virtual result OnEventProcessing(const _Control& control, bool& isFiltered); + virtual result OnListenerProcessing(const _IUiEventListener& listener, bool& isFiltered); + virtual result OnEventHandled(const _Control& control); + +private: + result ProcessGesture(const _Control& control, bool& isFiltered); + result FireListener(const _ITouchEventListener* pListener, const _Control* pControl, bool isTouchEvent, bool& isFiltered); + result FirePreviewListener(const _ITouchEventPreviewer* pListener, const _Control* pControl, bool& isFiltered); + Tizen::Graphics::Point GetRelativePoint(const _Control& control, const Tizen::Graphics::Point& point) const; + result ResetTouchInfo(const _Control* pControl, const _TouchInfo& touchInfo); + bool ExistGlobalGesture(void); + +private: + _TouchInfo __touchInfo; + std::tr1::shared_ptr > __pForcedGestureList; +}; // _UiTouchEvent + +}} // Tizen::Ui + +#endif //_FUI_INTERNAL_UI_TOUCH_EVENT_H_ diff --git a/src/ui/inc/FUi_VariantImpl.h b/src/ui/inc/FUi_VariantImpl.h new file mode 100644 index 0000000..ca6e98b --- /dev/null +++ b/src/ui/inc/FUi_VariantImpl.h @@ -0,0 +1,119 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_VariantImpl.h + * @brief This is the header file for the _VariantImpl class. + * + * This header file contains declarations of the _VariantImpl class. @n + */ +#ifndef _FUI_VARIANT_IMPL_H_ +#define _FUI_VARIANT_IMPL_H_ + +#include + +namespace Tizen { namespace Ui +{ + +typedef union +{ + int valueInt; + unsigned int valueUInt; + bool valueBool; + float valueFloat; + double valueDouble; + long valueLong; + unsigned long valueULong; + long long valueLongLong; + unsigned long long valueULongLong; + Tizen::Base::String* pString; + Tizen::Base::DateTime* pDateTime; + Tizen::Graphics::Color* pColor; + Tizen::Graphics::Point* pPoint; + Tizen::Graphics::FloatPoint* pFloatPoint; + Tizen::Graphics::Rectangle* pRect; + Tizen::Graphics::FloatRectangle* pRectf; + Tizen::Graphics::Dimension* pDimension; + Tizen::Graphics::FloatDimension* pFloatDimension; + Tizen::Graphics::FloatMatrix4* pFloatMatrix4; +} VariantData; + +class _VariantImpl + : public Tizen::Base::Object +{ +public: + _VariantImpl(void); + +private: + virtual ~_VariantImpl(void); + + void AddRef(void); + void Release(void); + + /* + * Deallocates an internal buffer. + * + * @since 2.0 + */ + void Clear(void); + + /* + * Copy an internal buffer. + * + * @since 2.0 + * @param[in] value Variant value + */ + void Copy(const Variant& rhs); + + /* + * Deallocates an internal buffer. + * + * @since 2.0 + * @param[in] type VariantType + */ + void SetVariantType(VariantType type); + + /* + * Check if the type is same + * + * @since 2.0 + * @param[in] type VariantType + */ + bool IsSameType(VariantType type) const; + + /* + * This is the copy constructor for this class. + * @since 2.0 + */ + _VariantImpl(const _VariantImpl&); + + /** + * This is the assignment operator for this class. + * + * @since 2.0 + */ + _VariantImpl& operator =(const _VariantImpl&); + +public: + int __refCount; + VariantData __data; + VariantType __type; + friend class Variant; +}; // _VariantImpl + +} } // Tizen::Ui + +#endif //_FUI_VARIANT_IMPL_H_ diff --git a/src/ui/inc/FUi_Window.h b/src/ui/inc/FUi_Window.h new file mode 100644 index 0000000..aca6e24 --- /dev/null +++ b/src/ui/inc/FUi_Window.h @@ -0,0 +1,149 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_Window.h + * @brief This is the header file for the _Window class. + * + * This header file contains the declarations of the %_Window class. + */ + +#ifndef _FUI_INTERNAL_WINDOW_H_ +#define _FUI_INTERNAL_WINDOW_H_ + +#include +#include "FUi_Control.h" + +namespace Tizen { namespace Ui { namespace Animations { +class DisplayContext; +// #if defined(MULTI_WINDOW) +class _RootVisualElement; +class _NativeLayer; +// #endif +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Ui +{ + +class _IWindowDelegate +{ +public: + virtual ~_IWindowDelegate(void){} + + virtual void OnActivated(void) = 0; + virtual void OnNativeWindowActivated(void) = 0; + virtual void OnDeactivated(void) = 0; +}; // _IWindowDelegate + +class _OSP_EXPORT_ _Window // Temp: export only for test + : public _Control + , public _IWindowDelegate + , virtual public Tizen::Base::Runtime::IEventListener + , virtual public _IUiEventListener + , virtual public _IUiEventPreviewer +{ +public: + static _Window* CreateWindowN(void); + virtual ~_Window(void); + void SetWindowDelegate(_IWindowDelegate& delegate); + void ResetWindowDelegate(void); + virtual bool IsActivatedOnOpen(void) const; + bool IsAttached(void) const; + bool IsActivated(void) const; + WindowState GetWindowState(void) const; + void SetWindowState(WindowState windowState); + result Open(bool drawAndShow = true); + void Close(void); + _Control* GetOwner(void) const; + void SetOwner(_Control* pOwner); +#if defined(MULTI_WINDOW) + result CreateRootVisualElement(void); + virtual result CreateLayer(void); +#endif + + virtual bool IsFocusableDescendant(const _Control* pFocus) const; + +// Callbacks + virtual void OnActivated(void); + virtual void OnNativeWindowActivated(void); + virtual void OnDeactivated(void); + virtual void OnVisibleStateChanged(void); + virtual bool OnNotifiedN(const Tizen::Ui::_Control& source, Tizen::Base::Collection::IList* pArgs); +#if defined(MULTI_WINDOW) + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); + virtual result OnAttachingToMainTree(const _Control* pParent); + virtual result OnDetachingFromMainTree(void); + + virtual bool IsLayoutChangable(void) const; +#endif + +#if defined(MULTI_WINDOW) + void SetActivationEnabled(bool enable); + bool IsActivationEnabled(void); + + Tizen::Ui::Animations::_RootVisualElement* GetRootVisualElement(void) const; +#else + virtual Tizen::Ui::Animations::_RootVisualElement* GetRootVisualElement(void) const; +#endif + NativeWindowHandle GetNativeHandle(void) const; + + // Internal: Only necessary for implementing _Window. Never override this callback except for _Window. + virtual void OnChangeLayout(_ControlOrientation orientation); + + Tizen::Ui::Animations::DisplayContext* GetDisplayContext(void) const; + + result SetZOrderGroup(int windowZOrderGroup); + bool IsSystemWindow(void) const; + +protected: + _Window(void); + _IWindowDelegate& GetWindowDelegate(void) const; + virtual Tizen::Base::String GetDescription(void) const; + +#if defined(MULTI_WINDOW) + void SetRootVisualElement(const Tizen::Ui::Animations::_RootVisualElement& rootVisualElement); +#endif + + void SetSystemWindow(bool systemWindow); + +private: + _Window(const _Window& rhs); + _Window& operator =(const _Window& rhs); + + void Activate(void); + void Deactivate(void); + +private: + WindowState __windowState; + _Control* __pOwner; + _IWindowDelegate* __pWindowDelegate; + bool __activated; + bool __destroying; + + Tizen::Ui::Animations::_RootVisualElement* __pRootVisualElement; + Tizen::Ui::Animations::_NativeLayer* __pLayer; + + mutable Tizen::Ui::Animations::DisplayContext* __pDisplayContext; + bool __systemWindow; + bool __isOpened; + bool __isInitialized; + + friend class _ControlManager; +}; // _Window + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_WINDOW_H_ diff --git a/src/ui/inc/FUi_WindowImpl.h b/src/ui/inc/FUi_WindowImpl.h new file mode 100644 index 0000000..2d9890e --- /dev/null +++ b/src/ui/inc/FUi_WindowImpl.h @@ -0,0 +1,104 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_WindowImpl.h + * @brief This is the header file for the _WindowImpl class. + * + * This header file contains the declarations of the %_WindowImpl class. + */ + +#ifndef _FUI_INTERNAL_WINDOW_IMPL_H_ +#define _FUI_INTERNAL_WINDOW_IMPL_H_ + +#include +#include "FUi_ContainerImpl.h" +#include "FUi_Window.h" + +namespace Tizen { namespace Ui { namespace Animations { +class DisplayContext; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Ui +{ + +class _OSP_EXPORT_ _WindowImpl + : public _ContainerImpl +{ +public: +// Constants + static WindowState GetErrorWindowState(void); + +public: +// Life Cycle + void Initialize(Window* pPublic, _Window* pCore, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout); + static _WindowImpl* CreateWindowImplN(Window* pPublic, const Tizen::Graphics::Rectangle& bounds, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, bool resizable, bool movable); + virtual ~_WindowImpl(void); + + static _WindowImpl* GetInstance(Window& window); + static const _WindowImpl* GetInstance(const Window& window); + virtual const char* GetPublicClassName(void) const; + virtual const Window& GetPublic(void) const; + virtual Window& GetPublic(void); + virtual const _Window& GetCore(void) const; + virtual _Window& GetCore(void); + +// Public Event Listeners + void AddWindowEventListener(Tizen::Ui::IWindowEventListener& listener); + void RemoveWindowEventListener(Tizen::Ui::IWindowEventListener& listener); + + virtual void OnActivated(void); + virtual void OnNativeWindowActivated(void); + virtual void OnDeactivated(void); + + +#if !defined(MULTI_WINDOW) + virtual void Rotate(_ControlRotation rotation); +#else + virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds); + virtual void OnRotated(_ControlRotation rotation); +#endif + +// Operations + result Open(bool drawAndShow = true); + void Close(void); + WindowState GetWindowState(void) const; + void SetWindowState(WindowState windowState); // [ToDo] Failed if the window is opened. + Tizen::Ui::Animations::DisplayContext* GetDisplayContext(void) const; + + result SetZOrderGroup(WindowZOrderGroup windowZOrderGroup); + _Control* GetOwner(void) const; + void SetOwner(Tizen::Ui::Control *pControl); + + NativeWindowHandle GetNativeHandle(void) const; + +protected: + _WindowImpl(Window* pPublic, _Window* pCore, const Layout* pPublicPortraitLayout = null, const Layout* pPublicLandscapeLayout = null); + _WindowImpl(Window* pPublic, _Window* pCore, const Tizen::Graphics::Rectangle& bounds, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, bool resizable, bool movable); +private: + _WindowImpl(const _WindowImpl& rhs); + _WindowImpl& operator =(const _WindowImpl& rhs); + +private: + PublicEventListenerList* __pPublicWindowEventListeners; + class WindowImplDelegate; + WindowImplDelegate* __pImplDelegate; + +}; // _WindowImpl + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_WINDOW_IMPL_H_ diff --git a/src/ui/layout/FUi_LayoutAbsoluteLayout.cpp b/src/ui/layout/FUi_LayoutAbsoluteLayout.cpp new file mode 100644 index 0000000..8a0db1c --- /dev/null +++ b/src/ui/layout/FUi_LayoutAbsoluteLayout.cpp @@ -0,0 +1,143 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutAbsoluteLayout.cpp + * @brief This is the implementation file for AbsoluteLayout class. + * + * This file contains the implementation of AbsoluteLayout class. + */ + +#include +#include "FUi_LayoutAbsoluteLayout.h" +#include "FUi_LayoutLayoutItemProxy.h" +#include "FUi_LayoutProxyList.h" +#include "FUi_LayoutLayoutItemInfo.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +AbsoluteLayout::AbsoluteLayout(void) + : __defaultMatchParent(false) +{ + AbsoluteProxyList* pAbsoluteProxyList = new (std::nothrow) AbsoluteProxyList(); + SysTryReturnVoidResult(NID_UI, pAbsoluteProxyList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage"); + SetItemList(pAbsoluteProxyList); +} + +AbsoluteLayout::~AbsoluteLayout(void) +{ +} + +AbsoluteLayout* +AbsoluteLayout::CreateAbsoluteLayoutN(bool defaultMatchParent) +{ + AbsoluteLayout* pLayout = new (std::nothrow) AbsoluteLayout(); + SysTryReturn(NID_UI, pLayout != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Absolute layout core allocation failure."); + if (GetLastResult() != E_SUCCESS) + { + delete pLayout; + return null; + } + + pLayout->__defaultMatchParent = defaultMatchParent; + + return pLayout; +} + +result +AbsoluteLayout::AddItem(LayoutItem& addItem) +{ + result r = E_SUCCESS; + + r = Layout::AddItem(addItem); + if (r != E_SUCCESS) + { + return r; + } + + if (__defaultMatchParent) + { + r = Layout::SetItemWidthMatchMode(addItem, MATCH_PARENT); + if (r != E_SUCCESS) + { + return r; + } + + r = Layout::SetItemHeightMatchMode(addItem, MATCH_PARENT); + if (r != E_SUCCESS) + { + return r; + } + } + + return r; +} + +result +AbsoluteLayout::OnLayout(int width, int height, bool layoutUpdating) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid"); + + if (pProxyList == null) + { + return E_INVALID_STATE; + } + + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + if (pContainerProxy == null) + { + return E_INVALID_STATE; + } + + LayoutRect intendedRect = {0, 0, width, height}; + pContainerProxy->ConvertWindowToClientBounds(intendedRect, intendedRect); + + LayoutRect layoutRect = GetLayoutRect(); + layoutRect.w = intendedRect.w; + layoutRect.h = intendedRect.h; + SetLayoutRect(layoutRect); + + ProxyListNode* pNode = pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + if (pItemProxy == null) + { + return E_INVALID_STATE; + } + LayoutRect itemRect = pItemProxy->GetItemBaseRect(); + if (pItemProxy->Measure(itemRect.w, itemRect.h) != E_SUCCESS) + { + return E_INVALID_STATE; + } + pItemProxy->GetMeasuredSize(itemRect.w, itemRect.h); + LayoutRect layoutRect = GetLayoutRect(); + itemRect.x += layoutRect.x; + itemRect.y += layoutRect.y; + if (pItemProxy->SetItemWindowRect(itemRect) != E_SUCCESS) + { + return E_INVALID_STATE; + } + + pNode = pProxyList->GetNextNode(*pNode); + } + + return E_SUCCESS; +} + +}}} // Tizen::Ui::_Layout \ No newline at end of file diff --git a/src/ui/layout/FUi_LayoutLayout.cpp b/src/ui/layout/FUi_LayoutLayout.cpp new file mode 100644 index 0000000..6ed59b8 --- /dev/null +++ b/src/ui/layout/FUi_LayoutLayout.cpp @@ -0,0 +1,896 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayout.cpp + * @brief This is the implementation file for Layout class. + * + * This file contains the implementation of Layout class. + */ + +#include +#include "FUi_LayoutLayout.h" +#include "FUi_LayoutLayoutItemProxy.h" +#include "FUi_LayoutProxyList.h" +#include "FUi_LayoutLayoutItemInfo.h" +#include "FUi_LayoutLayoutList.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +Layout::Layout(void) + : __pProxyList(null) + , __x(0) + , __y(0) + , __width(0) + , __height(0) + , __pContainerProxy(null) + , __rootLayout(false) + , __updateState(true) + , __partialUpdateState(false) + , __determineState(false) +{ +} + +Layout::~Layout(void) +{ + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + if (pContainerProxy != null) + { + LayoutContainer* pContainer = dynamic_cast (pContainerProxy->GetItem()); + if (pContainer) + { + pContainer->OnDestroyLayout(*this); + } + } + + if (__rootLayout) + { + delete __pContainerProxy; + } + + delete __pProxyList; +} + +LayoutItemProxy* +Layout::GetContainerProxy(void) +{ + if (__pContainerProxy == null) + { + return null; + } + + if (__rootLayout == false) + { + LayoutContainer* pContainer = dynamic_cast (__pContainerProxy->GetItem()); + if (pContainer == null) + { + SysLog(NID_UI, "Container is null."); + return null; + } + + LayoutContainer* pParentContainer = pContainer->GetParentContainer(); + if (pParentContainer == null) + { + SysLog(NID_UI, "Parent of container is null."); + return null; + } + + Layout* pParentLayout = __pContainerProxy->GetParentLayout(); + if (pParentLayout == null) + { + SysLog(NID_UI, "Parent layout of container is null."); + return null; + } + + if (pParentLayout != pParentContainer->__pCurrentLayout) + { + ProxyListNode* pNode = pParentContainer->__pCurrentLayout->__pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + LayoutContainer* pResultContainer = dynamic_cast (pItemProxy->GetItem()); + if (pContainer == pResultContainer) + { + __pContainerProxy = pItemProxy; + break; + } + pNode = __pProxyList->GetNextNode(*pNode); + } + } + } + + return __pContainerProxy; +} + +void +Layout::SetLayoutRect(const LayoutRect layoutRect) +{ + __x = layoutRect.x; + __y = layoutRect.y; + __width = layoutRect.w; + __height = layoutRect.h; +} + +LayoutRect +Layout::GetLayoutRect(void) const +{ + LayoutRect layoutRect = {__x, __y, __width, __height}; + + return layoutRect; +} + +result +Layout::SetItemAlignment(const LayoutItem& item, const ItemAlign align) +{ + ClearLastResult(); + + if (align.HAlign < ITEM_HORIZONTAL_ALIGN_LEFT || align.HAlign > ITEM_HORIZONTAL_ALIGN_LEFT_RIGHT || + align.VAlign < ITEM_VERTICAL_ALIGN_TOP || align.VAlign > ITEM_VERTICAL_ALIGN_TOP_BOTTOM) + { + SysTryReturn(NID_UI, false, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The alignment parameter is invalid parameter."); + } + + LayoutItemProxy* pItemProxy = __pProxyList->GetItemProxy(item); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + pItemProxy->SetItemAlignment(align); + + SetUpdateState(true); + return E_SUCCESS; +} + +result +Layout::GetItemAlignment(const LayoutItem& item, ItemAlign& align) const +{ + ClearLastResult(); + + LayoutItemProxy* pItemProxy = __pProxyList->GetItemProxy(item); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + align = pItemProxy->GetItemAlignment(); + + return E_SUCCESS; +} + +result +Layout::SetItemMargin(const LayoutItem& item, const ItemMargin margin) +{ + ClearLastResult(); + + LayoutItemProxy* pItemProxy = __pProxyList->GetItemProxy(item); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + pItemProxy->SetItemMargin(margin); + + SetUpdateState(true); + return E_SUCCESS; +} + +result +Layout::GetItemMargin(const LayoutItem& item, ItemMargin& margin) const +{ + ClearLastResult(); + + LayoutItemProxy* pItemProxy = __pProxyList->GetItemProxy(item); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + margin = pItemProxy->GetItemMargin(); + + return E_SUCCESS; +} + +result +Layout::SetItemWidthMatchMode(const LayoutItem& item, const LayoutMatchMode matchMode) +{ + ClearLastResult(); + + LayoutItemProxy* pItemProxy = __pProxyList->GetItemProxy(item); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + pItemProxy->SetItemWidthMatchMode(matchMode); + + SetUpdateState(true); + return E_SUCCESS; +} + +result +Layout::GetItemWidthMatchMode(const LayoutItem& item, LayoutMatchMode& matchMode) const +{ + ClearLastResult(); + + LayoutItemProxy* pItemProxy = __pProxyList->GetItemProxy(item); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + matchMode = pItemProxy->GetItemWidthMatchMode(); + + return E_SUCCESS; +} + +result +Layout::SetItemHeightMatchMode(const LayoutItem& item, const LayoutMatchMode matchMode) +{ + ClearLastResult(); + + LayoutItemProxy* pItemProxy = __pProxyList->GetItemProxy(item); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + pItemProxy->SetItemHeightMatchMode(matchMode); + + return E_SUCCESS; +} + +result +Layout::GetItemHeightMatchMode(const LayoutItem& item, LayoutMatchMode& matchMode) const +{ + ClearLastResult(); + + LayoutItemProxy* pItemProxy = __pProxyList->GetItemProxy(item); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + matchMode = pItemProxy->GetItemHeightMatchMode(); + + return E_SUCCESS; +} + +result +Layout::SetItemBaseRect(const LayoutItem& item, const LayoutRect baseRect) +{ + ClearLastResult(); + + LayoutItemProxy* pItemProxy = __pProxyList->GetItemProxy(item); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + pItemProxy->SetItemBaseRect(baseRect); + + SetUpdateState(true); + return E_SUCCESS; +} + +result +Layout::GetItemBaseRect(const LayoutItem& item, LayoutRect& baseRect) const +{ + ClearLastResult(); + + LayoutItemProxy* pItemProxy = __pProxyList->GetItemProxy(item); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + baseRect = pItemProxy->GetItemBaseRect(); + + return E_SUCCESS; +} + +bool +Layout::ItemExists(LayoutItem& item) +{ + if (__pProxyList->GetItemProxy(item) != null) + { + return true; + } + return false; +} + +LayoutUpdateFlag +Layout::CheckParentFlag(void) +{ + ClearLastResult(); + + if (__rootLayout) + { + return UPDATEFLAG_NO_FLAG; + } + + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + SysTryReturn(NID_UI, pContainerProxy != null, UPDATEFLAG_ERROR, E_INVALID_STATE, "[E_INVALID_STATE] Did not set the container."); + + Layout* pParentLayout = pContainerProxy->GetParentLayout(); + SysTryReturn(NID_UI, pParentLayout != null, UPDATEFLAG_ERROR, E_INVALID_STATE, "[E_INVALID_STATE] Layout does not exist."); + + LayoutItemProxy* pParentContainerProxy = pParentLayout->GetContainerProxy(); + SysTryReturn(NID_UI, pContainerProxy != null, UPDATEFLAG_ERROR, E_INVALID_STATE, "[E_INVALID_STATE] Did not set the parent container."); + + return CheckFlagInternal(*pParentContainerProxy); +} + +LayoutUpdateFlag +Layout::CheckCurrentFlag(void) +{ + ClearLastResult(); + + if (__rootLayout) + { + return UPDATEFLAG_NO_FLAG; + } + + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + SysTryReturn(NID_UI, pContainerProxy != null, UPDATEFLAG_ERROR, E_INVALID_STATE, "[E_INVALID_STATE] Did not set the container."); + + return CheckFlagInternal(*pContainerProxy); +} + +LayoutUpdateFlag +Layout::CheckFlagInternal(LayoutItemProxy& containerProxy) +{ + int updateFlag = 0; + + LayoutMatchMode widthMode = containerProxy.GetItemWidthMatchMode(); + LayoutMatchMode heightMode = containerProxy.GetItemHeightMatchMode(); + ItemAlign align = containerProxy.GetItemAlignment(); + + if (widthMode == NONE_MODE && heightMode == NONE_MODE) + { + updateFlag |= UPDATEFLAG_NONE_MODE; + } + + if (widthMode == MATCH_PARENT || heightMode == MATCH_PARENT) + { + updateFlag |= UPDATEFLAG_MATCH_PARENT; + } + + if (widthMode == WRAP_CONTENT || heightMode == WRAP_CONTENT) + { + updateFlag |= UPDATEFLAG_WRAPCONTENT; + } + + if (align.HAlign != ITEM_HORIZONTAL_ALIGN_LEFT || align.VAlign != ITEM_VERTICAL_ALIGN_TOP) + { + updateFlag |= UPDATEFLAG_ALIGNMENT; + } + + return static_cast (updateFlag); + +} + +result +Layout::UpdateLayout(void) +{ + result r = UpdateLayoutInternal(UPDATEFLAG_NO_FLAG); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Failed to UpdateLayout.", GetErrorMessage(r)); + r = DetermineWindowRectToAllItem(); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Failed to DetermineWindowRectToAllItem.", GetErrorMessage(r)); + + return r; +} + +result +Layout::DetermineWindowRectToAllItem(void) +{ + ClearLastResult(); + + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + SysTryReturn(NID_UI, pContainerProxy != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Did not set the container."); + + if (__rootLayout) + { + if (__determineState) + { + OnDetermine(); + __determineState = false; + } + } + else + { + Layout* pParentLayout = pContainerProxy->GetParentLayout(); + SysTryReturn(NID_UI, pParentLayout != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Layout does not exist."); + return pParentLayout->DetermineWindowRectToAllItem(); + } + + return E_SUCCESS; +} + +result +Layout::OnDetermine(void) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid"); + + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + SysTryReturn(NID_UI, pContainerProxy != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Did not set the container."); + + LayoutRect itemRect; + pContainerProxy->GetItemWindowRect(itemRect); + pContainerProxy->SetItemWindowRect(itemRect, false); + + ProxyListNode* pCurNode = pProxyList->GetFirstNode(); + while (pCurNode != null) + { + LayoutItemProxy* pItemProxy = pCurNode->GetItemProxy(); + LayoutContainer* pCurContainer = dynamic_cast(pItemProxy->GetItem()); + SysTryReturn(NID_UI, pCurContainer != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] This item is not container."); + + pCurContainer->GetLayout()->OnDetermine(); + + pCurNode = pProxyList->GetNextNode(*pCurNode); + } + + return E_SUCCESS; +} + + +void +Layout::SetUpdateState(bool state) +{ + ClearLastResult(); + + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + + SysTryReturnVoidResult(NID_UI, pContainerProxy != null, E_INVALID_STATE, "[E_INVALID_STATE] Did not set the container."); + + if (__rootLayout) + { + __updateState = state; + } + else + { + Layout* pParentLayout = pContainerProxy->GetParentLayout(); + SysTryReturnVoidResult(NID_UI, pParentLayout != null, E_INVALID_STATE, "[E_INVALID_STATE] Layout does not exist."); + return pParentLayout->SetUpdateState(state); + } +} + +result +Layout::PartialUpdateLayout(void) +{ + ClearLastResult(); + + LayoutUpdateFlag flag = CheckCurrentFlag(); + SysTryReturn(NID_UI, flag != UPDATEFLAG_ERROR, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] CheckCurrentFlag is failed."); + + return UpdateLayoutInternal(flag); + +} + +result +Layout::OnLayoutTrigger(Layout& layout, bool layoutUpdating) +{ + ClearLastResult(); + + LayoutItemProxy* pContainerProxy = layout.GetContainerProxy(); + + SysTryReturn(NID_UI, pContainerProxy != null, E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] Did not set the container."); + + LayoutRect containerRect; + pContainerProxy->GetItemWindowRect(containerRect); + LayoutContainer* pContainer = dynamic_cast (pContainerProxy->GetItem()); + SysTryReturn(NID_UI, pContainer != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Did not set the container."); + pContainer->ConvertWindowToClientBounds(containerRect, containerRect); + + LayoutSize containerSize; + containerSize.w = containerRect.w; + containerSize.h = containerRect.h; + pContainer->SetIntendedWindowSize(containerSize); + + return layout.OnLayout(containerRect.w, containerRect.h, layoutUpdating); +} + +result +Layout::UpdateLayoutInternal(LayoutUpdateFlag updateFlag) +{ + ClearLastResult(); + + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + + SysTryReturn(NID_UI, pContainerProxy != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Did not set the container."); + + if (__rootLayout) + { + if (__updateState) + { + if (updateFlag == UPDATEFLAG_NO_FLAG) + { + __updateState = false; + } + __determineState = true; + return OnLayoutTrigger(*this, true); + } + else + { + return E_SUCCESS; + } + } + else + { + Layout* pParentLayout = pContainerProxy->GetParentLayout(); + SysTryReturn(NID_UI, pParentLayout != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Layout does not exist."); + + if (updateFlag != UPDATEFLAG_NO_FLAG) + { + if (updateFlag & UPDATEFLAG_MATCH_PARENT || updateFlag & UPDATEFLAG_ALIGNMENT || pParentLayout->__partialUpdateState) + { + LayoutUpdateFlag parentflag = CheckParentFlag(); + SysTryReturn(NID_UI, parentflag != UPDATEFLAG_ERROR, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] CheckParentFlag is failed."); + + if (parentflag & UPDATEFLAG_MATCH_PARENT || parentflag & UPDATEFLAG_ALIGNMENT || pParentLayout->__partialUpdateState) + { + return pParentLayout->UpdateLayoutInternal(parentflag); + } + else + { + return OnLayoutTrigger(*pParentLayout, true); + } + } + else + { + return OnLayoutTrigger(*this, true); + } + } + + return pParentLayout->UpdateLayoutInternal(UPDATEFLAG_NO_FLAG); + } +} + +result +Layout::AddItem(LayoutItem& addItem) +{ + //ClearLastResult(); + result r = CheckItem(addItem); + SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + LayoutItemProxy* pItemProxy = CreateProxy(addItem); + SysTryReturn(NID_UI, pItemProxy != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create proxy of layout item."); + + LayoutContainer* pContainer = dynamic_cast (&addItem); + if (pContainer != null) + { + LayoutListNode* pCurNode = pContainer->GetLayoutList()->GetFirstNode(); + + while (pCurNode) + { + Layout* pLayout = pCurNode->GetLayout(); + if (pLayout != null) + { + if (pLayout->__rootLayout == true) + { + delete pLayout->__pContainerProxy; + pLayout->__pContainerProxy = pItemProxy; + pLayout->__rootLayout = false; + } + } + pCurNode = pContainer->GetLayoutList()->GetNextNode(*pCurNode); + } + } + + if (__pProxyList->AddNode(*pItemProxy) == null) + { + pItemProxy->Destroy(); + r = GetLastResult(); + SysTryReturn(NID_UI, false, r, r, "[%s] Failed to add layout item.", GetErrorMessage(r)); + } + + pItemProxy->SetParentLayout(this); + pItemProxy->SetParentContainer(static_cast (__pContainerProxy->GetItem())); + + LayoutRect itemRect; + pItemProxy->GetItemWindowRect(itemRect); + + pItemProxy->SetItemBaseRect(itemRect); + + SetUpdateState(true); + return E_SUCCESS; +} + +result +Layout::RemoveItem(const LayoutItem& removeItem) +{ + ClearLastResult(); + + LayoutItemProxy* pItemProxy = __pProxyList->GetItemProxy(removeItem); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] Control dose not belong to layout."); + + result r = __pProxyList->RemoveNode(*pItemProxy); + if (r != E_SUCCESS) + { + SysLog(NID_UI, "Failed to RemoveNode()"); + SysTryReturn(NID_UI, r, r, r, "[E_INVALID_STATE] Failed to remove layout item."); + } + + pItemProxy->SetParentLayout(null); + pItemProxy->SetParentContainer(null); + pItemProxy->Destroy(); + + return E_SUCCESS; +} + +result +Layout::OnChangeViewPosition(int viewPosX, int viewPosY) +{ + ClearLastResult(); + + if (viewPosX != 0 || viewPosY != 0) + { + ProxyListNode* pNode = __pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] Layout proxy list error."); + + LayoutRect itemRect; + pItemProxy->GetItemWindowRect(itemRect); + itemRect.x += viewPosX; + itemRect.y += viewPosY; + result r = pItemProxy->SetItemWindowRect(itemRect); + if (r != E_SUCCESS) + { + return r; + } + + pNode = __pProxyList->GetNextNode(*pNode); + } + + __x += viewPosX; + __y += viewPosY; + } + + return E_SUCCESS; +} + +result +Layout::CalculateAlignment(const LayoutAlignMode alignMode) +{ + ClearLastResult(); + + result r = E_SUCCESS; + bool needMeasure = false; + + SysAssertf(__pProxyList != null, "ProxyList is invalid."); + + ProxyListNode* pNode = __pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Layout proxy list error."); + + ItemAlign align = pItemProxy->GetItemAlignment(); + ItemMargin margin = pItemProxy->GetItemMargin(); + LayoutRect itemRect; + pItemProxy->GetItemWindowRect(itemRect); + + if (alignMode == BOTH || alignMode == HORIZONTALONLY) + { + switch (align.HAlign) + { + case ITEM_HORIZONTAL_ALIGN_LEFT: + { + itemRect.x = __x + margin.left; + break; + } + + case ITEM_HORIZONTAL_ALIGN_CENTER: + { + itemRect.x = (__x + (__width / 2)) - (itemRect.w / 2); + break; + } + + case ITEM_HORIZONTAL_ALIGN_RIGHT: + { + itemRect.x = (__x + __width) - (itemRect.w + margin.right); + break; + } + + case ITEM_HORIZONTAL_ALIGN_LEFT_RIGHT: + { + itemRect.x = __x + margin.left; + itemRect.w = __width - (margin.left + margin.right); + needMeasure = true; + break; + } + } +#ifdef NOT_SUPPORT_NEGATIVE_SIZE + if (itemRect.w < 0) + { + itemRect.w = 0; + } +#endif + } + + if (alignMode == BOTH || alignMode == VERTICALONLY) + { + switch (align.VAlign) + { + case ITEM_VERTICAL_ALIGN_TOP: + { + itemRect.y = __y + margin.top; + break; + } + + case ITEM_VERTICAL_ALIGN_MIDDLE: + { + itemRect.y = (__y + (__height / 2)) - (itemRect.h / 2); + break; + } + + case ITEM_VERTICAL_ALIGN_BOTTOM: + { + itemRect.y = (__y + __height) - (itemRect.h + margin.bottom); + break; + } + + case ITEM_VERTICAL_ALIGN_TOP_BOTTOM: + { + itemRect.y = __y + margin.top; + itemRect.h = __height - (margin.top + margin.bottom); + needMeasure = true; + break; + } + } +#ifdef NOT_SUPPORT_NEGATIVE_SIZE + if (itemRect.h < 0) + { + itemRect.h = 0; + } +#endif + } + + if (needMeasure) + { + r = pItemProxy->Measure(itemRect.w, itemRect.h); + if (r != E_SUCCESS) + { + return r; + } + pItemProxy->GetMeasuredSize(itemRect.w, itemRect.h); + } + r = pItemProxy->SetItemWindowRect(itemRect); + if (r != E_SUCCESS) + { + return r; + } + + pNode = __pProxyList->GetNextNode(*pNode); + } + + return E_SUCCESS; +} + +result +Layout::SetContainer(LayoutContainer* pContainer) +{ + ClearLastResult(); + + if (pContainer == null) + { + ProxyListNode* pNode = __pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_STATE, E_INVALID_STATE, + "[E_INVALID_STATE] Layout proxy list error."); + + pItemProxy->SetParentContainer(null); + + pNode = __pProxyList->GetNextNode(*pNode); + } + + if (__pContainerProxy) + { + if (__rootLayout) + { + //__pContainerProxy->Destroy(); + delete __pContainerProxy; + __rootLayout = false; + } + __pContainerProxy = null; + } + + return E_SUCCESS; + } + + LayoutContainer* pParentContainer = pContainer->GetParentContainer(); + if (pParentContainer == null) + { + if (__rootLayout && __pContainerProxy != null) + { + delete __pContainerProxy; + } + + __pContainerProxy = CreateProxy(*pContainer); + SysTryReturn(NID_UI, __pContainerProxy != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to create proxy of layout item."); + + __rootLayout = true; + } + else + { + Layout* pParentLayout = pParentContainer->GetLayout(); + SysTryReturn(NID_UI, pParentLayout, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Did not set a layout."); + + ProxyListNode* pNode = pParentLayout->__pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + if (pItemProxy == null) + { + return E_INVALID_STATE; + } + LayoutContainer* pResultContainer = dynamic_cast (pItemProxy->GetItem()); + if (pContainer == pResultContainer) + { + if (__rootLayout && __pContainerProxy != null) + { + delete __pContainerProxy; + __rootLayout = false; + } + __pContainerProxy = pItemProxy; + break; + } + pNode = __pProxyList->GetNextNode(*pNode); + } + } + + return E_SUCCESS; +} + +LayoutItemProxy* +Layout::CreateProxy(LayoutItem& item) +{ + return LayoutItemProxy::Create(*this, item); +} + +void +Layout::SetRootLayout(bool rootCheck) +{ + __rootLayout = rootCheck; +} + +result +Layout::CheckItem(const LayoutItem& checkItem) +{ + ClearLastResult(); + + ProxyListNode* pNode = __pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + SysTryReturn(NID_UI, pItemProxy != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Invalid proxy list node."); + + LayoutItem* pItem = pItemProxy->GetItem(); + SysTryReturn(NID_UI, pItem != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Invalid layout item."); + + SysTryReturn(NID_UI, &checkItem != pItem, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Control belong to layout."); + + pNode = __pProxyList->GetNextNode(*pNode); + } + + return E_SUCCESS; +} + +bool +Layout::HasLayoutContainer(void) +{ + return __pContainerProxy != null; +} + +void +Layout::SetPartialUpdateFlag(bool flag) +{ + __partialUpdateState = flag; +} + +void +Layout::SetItemList(ProxyList* pItemList) +{ + __pProxyList = pItemList; +} + +ProxyList* +Layout::GetProxyList(void) const +{ + return __pProxyList; +} + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutLayoutContainer.cpp b/src/ui/layout/FUi_LayoutLayoutContainer.cpp new file mode 100755 index 0000000..e81c405 --- /dev/null +++ b/src/ui/layout/FUi_LayoutLayoutContainer.cpp @@ -0,0 +1,416 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutContainer.cpp + * @brief This is the implementation file for LayoutContainer class. + * + * This file contains the implementation of LayoutContainer class. + */ + +#include +#include "FUi_Control.h" +#include "FUi_LayoutLayoutContainer.h" +#include "FUi_LayoutLayoutList.h" +#include "FUi_LayoutLayout.h" +#include "FUi_LayoutAbsoluteLayout.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +LayoutContainer::LayoutContainer(void) + : __pCurrentLayout(null) + , __defaultLayoutFlag(false) +{ + LayoutSize zeroSize = {0, 0}; + __intendedWindowSize = zeroSize; + + __pLayoutList = new (std::nothrow) LayoutList(); + SysTryReturnVoidResult(NID_UI, __pLayoutList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); +} + +LayoutContainer::~LayoutContainer(void) +{ + Layout* pDefaultLayout = GetDefaultLayout(); + delete pDefaultLayout; + + LayoutListNode* pLayoutNode = __pLayoutList->GetFirstNode(); + while (pLayoutNode != null) + { + Layout* pLayout = pLayoutNode->GetLayout(); + if (pLayout != null) + { + if (pLayout->SetContainer(null) != E_SUCCESS) + { + SysAssert(false); + } + } + pLayoutNode = __pLayoutList->GetNextNode(*pLayoutNode); + } + delete __pLayoutList; +} + +result +LayoutContainer::SetCurrentLayout(Layout& layout) +{ + if (!__pLayoutList->CheckNodeExists(layout)) + { + SysTryReturn(NID_UI, false, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This layout does not exist."); + } + + __pCurrentLayout = &layout; + __pCurrentLayout->SetUpdateState(true); + + return E_SUCCESS; +} + +result +LayoutContainer::AddLayout(Layout& layout) +{ + result r = E_SUCCESS; + + if (!__pLayoutList->CheckNodeExists(layout)) + { + SysTryReturn(NID_UI, !layout.HasLayoutContainer(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] This layout already belong to other container."); + SysTryReturn(NID_UI, __pLayoutList->AddNode(layout), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + r = layout.SetContainer(this); + } + + return r; +} + +Layout* +LayoutContainer::GetLayout() const +{ + return __pCurrentLayout; +} + +result +LayoutContainer::AddItem(LayoutItem& addItem) +{ + LayoutListNode* pCurNode = __pLayoutList->GetFirstNode(); + Layout* pLayout = null; + result r = E_SUCCESS; + + while (pCurNode) + { + pLayout = pCurNode->GetLayout(); + if (pLayout) + { + r = pLayout->AddItem(addItem); + } + + SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pCurNode = __pLayoutList->GetNextNode(*pCurNode); + } + return E_SUCCESS; + +CATCH: + LayoutListNode* pRollBackNode = __pLayoutList->GetFirstNode(); + while (pRollBackNode != null && pRollBackNode != pCurNode) + { + pLayout = pRollBackNode->GetLayout(); + if (pLayout) + { + pLayout->RemoveItem(addItem); + } + + pRollBackNode = __pLayoutList->GetNextNode(*pCurNode); + } + return r; +} + +result +LayoutContainer::RemoveItem(LayoutItem& removeItem) +{ + LayoutListNode* pCurNode = __pLayoutList->GetFirstNode(); + Layout* pLayout = null; + result r = E_SUCCESS; + + while (pCurNode) + { + pLayout = pCurNode->GetLayout(); + if (pLayout) + { + r |= pLayout->RemoveItem(removeItem); + } + pCurNode = __pLayoutList->GetNextNode(*pCurNode); + } + + return (r == E_SUCCESS) ? E_SUCCESS : GetLastResult(); +} + +void +LayoutContainer::OnDestroyItem(LayoutItem& item) +{ + LayoutListNode* pCurNode = __pLayoutList->GetFirstNode(); + Layout* pLayout = null; + + while (pCurNode) + { + pLayout = pCurNode->GetLayout(); + if (pLayout) + { + pLayout->RemoveItem(item); + } + pCurNode = __pLayoutList->GetNextNode(*pCurNode); + } +} + +result +LayoutContainer::OnSetDefaultLayout(Layout& deletedLayout) +{ + LayoutListNode* pDefaultNode = __pLayoutList->GetFirstNode(); + if (pDefaultNode == null) + { + return E_INVALID_STATE; + } + + Layout* pLayout = pDefaultNode->GetLayout(); + if (pLayout == null) + { + return E_INVALID_STATE; + } + + if (__pCurrentLayout == &deletedLayout) + { + SetCurrentLayout(*pLayout); + return E_SUCCESS; + } + + return E_SYSTEM; +} + +void +LayoutContainer::SetIntendedWindowSize(const LayoutSize intendedWindowSize) +{ + __intendedWindowSize = intendedWindowSize; +} + +LayoutSize +LayoutContainer::GetIntendedWindowSize() const +{ + return __intendedWindowSize; +} + +result +LayoutContainer::Measure(int width, int height) +{ + LayoutContainer* pContainer = GetParentContainer(); + if (pContainer == null) + { + return E_INVALID_STATE; + } + + Layout* pLayout = pContainer->GetLayout(); + if (pLayout == null) + { + return E_INVALID_STATE; + } + + LayoutMatchMode widthMode; + LayoutMatchMode heightMode; + result re = E_SYSTEM; + re = pLayout->GetItemWidthMatchMode(*this, widthMode); + if (re != E_SUCCESS) + { + return re; + } + re = pLayout->GetItemHeightMatchMode(*this, heightMode); + if (re != E_SUCCESS) + { + return re; + } + + re = LayoutItem::Measure(width, height); + if (re != E_SUCCESS) + { + return re; + } + + int measuredWidth = 0; + int measuredHeight = 0; + GetMeasuredSize(measuredWidth, measuredHeight); + + bool wrapContainer = true; + LayoutRect itemBounds; + pLayout->GetItemBaseRect(*this, itemBounds); + + if (widthMode == WRAP_CONTENT || heightMode == WRAP_CONTENT) + { + if (measuredWidth != itemBounds.w || measuredHeight != itemBounds.h) + { + wrapContainer = false; + } + } + + if (widthMode == WRAP_CONTENT && wrapContainer) + { + measuredWidth = width; + } + if (heightMode == WRAP_CONTENT && wrapContainer) + { + measuredHeight = height; + } + + LayoutRect rect = {0, 0, measuredWidth, measuredHeight}; + + if (__pCurrentLayout != null) + { + LayoutRect calculatedRect; + GetItemWindowRect(calculatedRect); + calculatedRect.w = measuredWidth; + calculatedRect.h = measuredHeight; + SetItemWindowRect(calculatedRect); + + ConvertWindowToClientBounds(calculatedRect, calculatedRect); + + LayoutSize containerSize = {calculatedRect.w, calculatedRect.h}; + + SetIntendedWindowSize(containerSize); + __pCurrentLayout->OnLayout(measuredWidth, measuredHeight, true); + rect = __pCurrentLayout->GetLayoutRect(); + } + + if (widthMode == WRAP_CONTENT && wrapContainer) + { + measuredWidth = rect.w; + } + if (heightMode == WRAP_CONTENT && wrapContainer) + { + measuredHeight = rect.h; + } + + RunItemMeasure(measuredWidth, measuredHeight); + + LayoutSize minSize; + LayoutSize maxSize; + + GetMinSize(minSize); + GetMaxSize(maxSize); + + if (measuredWidth < minSize.w) + { + measuredWidth = minSize.w; + } + else if (measuredWidth > maxSize.w) + { + measuredWidth = maxSize.w; + } + + if (measuredHeight < minSize.h) + { + measuredHeight = minSize.h; + } + else if (measuredHeight > maxSize.h) + { + measuredHeight = maxSize.h; + } + + SetMeasuredSize(measuredWidth, measuredHeight); + + return E_SUCCESS; +} + +void +LayoutContainer::OnDestroyLayout(Layout& layout) +{ + LayoutListNode* pLayoutNode = __pLayoutList->GetFirstNode(); + while (pLayoutNode != null) + { + if (pLayoutNode->GetLayout() == &layout) + { + __pLayoutList->RemoveNode(*pLayoutNode); + break; + } + pLayoutNode = __pLayoutList->GetNextNode(*pLayoutNode); + } + + if (&layout == __pCurrentLayout) + { + pLayoutNode = __pLayoutList->GetFirstNode(); + + if (pLayoutNode != null) + { + SetCurrentLayout(*pLayoutNode->GetLayout()); + } + } +} + +result +LayoutContainer::SetDefaultLayout(Layout& layout) +{ + if (__defaultLayoutFlag) + { + return E_INVALID_STATE; + } + + if (__pLayoutList->GetFirstNode() != null) + { + return E_INVALID_STATE; + } + AddLayout(layout); + __defaultLayoutFlag = true; + + return SetCurrentLayout(layout); +} + +Layout* +LayoutContainer::GetDefaultLayout() const +{ + LayoutListNode* pLayoutNode = __pLayoutList->GetFirstNode(); + if (pLayoutNode == null) + { + return null; + } + else + { + return pLayoutNode->GetLayout(); + } +} + +bool +LayoutContainer::LayoutExists(Layout& layout) +{ + return __pLayoutList->CheckNodeExists(layout); +} + +void +LayoutContainer::OnDestroyContainerProxy() +{ + LayoutListNode* pCurNode = __pLayoutList->GetFirstNode(); + Layout* pLayout = null; + + while (pCurNode) + { + pLayout = pCurNode->GetLayout(); + if (pLayout) + { + pLayout->SetContainer(this); + } + pCurNode = __pLayoutList->GetNextNode(*pCurNode); + } +} + +LayoutList* +LayoutContainer::GetLayoutList(void) +{ + return __pLayoutList; +} + + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutLayoutItem.cpp b/src/ui/layout/FUi_LayoutLayoutItem.cpp new file mode 100644 index 0000000..4cda442 --- /dev/null +++ b/src/ui/layout/FUi_LayoutLayoutItem.cpp @@ -0,0 +1,313 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutItem.cpp + * @brief This is the implementation file for LayoutItem class. + * + * This file contains the implementation of LayoutItem class. + */ + +#include "FUi_Control.h" +#include "FUi_LayoutLayoutItem.h" +#include "FUi_LayoutLayout.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +LayoutItem::LayoutItem(void) + : __pOuterControl(null) + , __pParentContainer(null) +{ + __measuredSize.w = 0; + __measuredSize.h = 0; +} + +LayoutItem::~LayoutItem(void) +{ + if (__pParentContainer != null) + { + __pParentContainer->OnDestroyItem(*this); + } +} + +void +LayoutItem::SetItemHandler(ILayoutItemHandler* pOuterControl) +{ + __pOuterControl = pOuterControl; +} + +result +LayoutItem::SetItemWindowRect(const LayoutRect layoutRect) +{ + SysAssertf(__pOuterControl != null, "Did not set a ILayoutItemHandler."); + + Tizen::Graphics::Rectangle rect(layoutRect.x, layoutRect.y, layoutRect.w, layoutRect.h); + return __pOuterControl->SetItemBounds(rect); +} + +void +LayoutItem::GetItemWindowRect(LayoutRect& LayoutRect) const +{ + SysAssertf(__pOuterControl != null, "Did not set a ILayoutItemHandler."); + + Tizen::Graphics::Rectangle rect = __pOuterControl->GetItemBounds(); + + LayoutRect.x = rect.x; + LayoutRect.y = rect.y; + LayoutRect.w = rect.width; + LayoutRect.h = rect.height; +} + +void +LayoutItem::ConvertWindowToClientBounds(const LayoutRect windowRect, LayoutRect& clientRect) +{ + SysAssertf(__pOuterControl != null, "Did not set a ILayoutItemHandler."); + + Tizen::Graphics::Dimension size(windowRect.w, windowRect.h); + Tizen::Graphics::Rectangle rect = __pOuterControl->GetItemClientBoundsFromSize(size); + + clientRect.x = rect.x; + clientRect.y = rect.y; + clientRect.w = rect.width; + clientRect.h = rect.height; +} + +result +LayoutItem::Measure(int width, int height) +{ + LayoutContainer* pContainer = __pParentContainer; + if (pContainer == null) + { + return E_INVALID_STATE; + } + + Layout* pLayout = pContainer->GetLayout(); + if (pLayout == null) + { + return E_INVALID_STATE; + } + + LayoutMatchMode widthMode; + LayoutMatchMode heightMode; + result re = E_SYSTEM; + re = pLayout->GetItemWidthMatchMode(*this, widthMode); + if (re != E_SUCCESS) + { + return re; + } + re = pLayout->GetItemHeightMatchMode(*this, heightMode); + if (re != E_SUCCESS) + { + return re; + } + + LayoutRect layoutRect = pLayout->GetLayoutRect(); + + LayoutMatchMode containerWidthMode = NONE_MODE; + LayoutMatchMode containerHeightMode = NONE_MODE; + + LayoutContainer* pContainerParent = pContainer->GetParentContainer(); + if (pContainerParent != null) + { + re = pContainerParent->GetLayout()->GetItemWidthMatchMode(*pContainer, containerWidthMode); + if (re != E_SUCCESS) + { + return re; + } + re = pContainerParent->GetLayout()->GetItemHeightMatchMode(*pContainer, containerHeightMode); + if (re != E_SUCCESS) + { + return re; + } + } + + LayoutSize containerSize = pContainer->GetIntendedWindowSize(); + + int measuredWidth = 0; + int measuredHeight = 0; + + int wrapContentWidth = 0; + int wrapContentHeight = 0; + + Tizen::Graphics::Dimension size = __pOuterControl->GetItemContentSize(); + + wrapContentWidth = size.width; + wrapContentHeight = size.height; + + if (widthMode == NONE_MODE) + { + measuredWidth = width; + } + else if (widthMode == WRAP_CONTENT) + { + measuredWidth = wrapContentWidth; + } + else if (widthMode == MATCH_PARENT) + { + if (containerWidthMode != WRAP_CONTENT) + { + measuredWidth = containerSize.w; + } + else + { + measuredWidth = layoutRect.w; + } + } + + if (heightMode == NONE_MODE) + { + measuredHeight = height; + } + else if (heightMode == WRAP_CONTENT) + { + measuredHeight = wrapContentHeight; + } + else if (heightMode == MATCH_PARENT) + { + if (containerHeightMode != WRAP_CONTENT) + { + measuredHeight = containerSize.h; + } + else + { + measuredHeight = layoutRect.h; + } + } + + RunItemMeasure(measuredWidth, measuredHeight); + + LayoutSize minSize; + LayoutSize maxSize; + + Tizen::Graphics::Dimension controlMinSize = __pOuterControl->GetItemMinimumSize(); + Tizen::Graphics::Dimension controlMaxSize = __pOuterControl->GetItemMaximumSize(); + + minSize.w = controlMinSize.width; + minSize.h = controlMinSize.height; + + maxSize.w = controlMaxSize.width; + maxSize.h = controlMaxSize.height; + + if (measuredWidth < minSize.w) + { + measuredWidth = minSize.w; + } + else if (measuredWidth > maxSize.w) + { + measuredWidth = maxSize.w; + } + + if (measuredHeight < minSize.h) + { + measuredHeight = minSize.h; + } + else if (measuredHeight > maxSize.h) + { + measuredHeight = maxSize.h; + } + + SetMeasuredSize(measuredWidth, measuredHeight); + + return E_SUCCESS; +} + +void +LayoutItem::RunItemMeasure(int& width, int& height) +{ + __pOuterControl->OnItemMeasure(width, height); +} + +void +LayoutItem::Visible(bool visible) +{ + SysAssertf(__pOuterControl != null, "Did not set a ILayoutItemHandler."); + + __pOuterControl->SetItemVisibleState(visible); +} + +void +LayoutItem::SetParentContainer(LayoutContainer* pParentContainer) +{ + SysAssertf(__pOuterControl != null, "Did not set a ILayoutItemHandler."); + __pParentContainer = pParentContainer; +} + +LayoutContainer* +LayoutItem::GetParentContainer(void) const +{ + return __pParentContainer; +} + +void +LayoutItem::SetMeasuredSize(int width, int height) +{ + __measuredSize.w = width; + __measuredSize.h = height; +} + +void +LayoutItem::GetMeasuredSize(int& width, int& height) const +{ + width = __measuredSize.w; + height = __measuredSize.h; +} + +void +LayoutItem::GetMinSize(LayoutSize& minSize) const +{ + SysAssertf(__pOuterControl != null, "Did not set a ILayoutItemHandler."); + Tizen::Graphics::Dimension controlMinSize = __pOuterControl->GetItemMinimumSize(); + + minSize.w = controlMinSize.width; + minSize.h = controlMinSize.height; +} + +void +LayoutItem::GetMaxSize(LayoutSize& maxSize) const +{ + SysAssertf(__pOuterControl != null, "Did not set a ILayoutItemHandler."); + Tizen::Graphics::Dimension controlMaxSize = __pOuterControl->GetItemMaximumSize(); + + maxSize.w = controlMaxSize.width; + maxSize.h = controlMaxSize.height; +} + +Layout* +LayoutItem::GetIncludedLayout(void) const +{ + if (__pParentContainer != null) + { + return __pParentContainer->GetLayout(); + } + return null; +} + +result +LayoutItem::OnChangeBaseRect(void) +{ + Layout* pLayout = GetIncludedLayout(); + if (pLayout == null) + { + return E_INVALID_STATE; + } + LayoutRect rect; + GetItemWindowRect(rect); + + return pLayout->SetItemBaseRect(*this, rect); +} + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutLayoutItemInfo.cpp b/src/ui/layout/FUi_LayoutLayoutItemInfo.cpp new file mode 100644 index 0000000..41e4576 --- /dev/null +++ b/src/ui/layout/FUi_LayoutLayoutItemInfo.cpp @@ -0,0 +1,90 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutItemInfo.cpp + * @brief This is the implementation file for LayoutItemInfo class. + * + * This file contains the implementation of LinkedListNode class. + */ + +#include +#include +#include +#include "FUi_LayoutTableLayout.h" +#include "FUi_LayoutLayoutItemInfo.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +// Super class +LayoutItemInfo::LayoutItemInfo(void) +{ +} + +LayoutItemInfo::~LayoutItemInfo(void) +{ +} + +// Relative layout +RelativeItemInfo::RelativeItemInfo(void) + : __refCount(0) +{ + memset(__pTarget, 0, sizeof(LayoutItemProxy*) * 6); + memset(__targetEdge, EDGE_NONE, sizeof(RelativeLayoutEdge) * 6); +} + +RelativeItemInfo::~RelativeItemInfo(void) +{ +} + +// Table layout +TableItemInfo::TableItemInfo(void) + : __id(TableLayout::INVALID_CELL_ID) + , __enable(true) + , __merged(false) + , __fillWidth(false) + , __fillHeight(false) +{ + __mergeEndPoint.x = TableLayout::NOT_MERGED; + __mergeEndPoint.y = TableLayout::NOT_MERGED; + __minSize.w = 0; + __minSize.h = 0; + __maxSize.w = 0; + __maxSize.h = 0; +} + +TableItemInfo::~TableItemInfo(void) +{ +} + +// Linear layout +LinearItemInfo::LinearItemInfo(void) + : __weight(0.0) + , __spacing(0) + , __fixedSize(false) +{ + __itemRect.x = 0; + __itemRect.y = 0; + __itemRect.w = 0; + __itemRect.h = 0; +} + +LinearItemInfo::~LinearItemInfo(void) +{ +} + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutLayoutItemInfo.h b/src/ui/layout/FUi_LayoutLayoutItemInfo.h new file mode 100644 index 0000000..2896f09 --- /dev/null +++ b/src/ui/layout/FUi_LayoutLayoutItemInfo.h @@ -0,0 +1,146 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutItemInfo.h + * @brief This is the header file for LayoutItemInfo class. + * + * This header file contains the declaration of LayoutItemInfo class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_LAYOUT_ITEM_INFO_H_ +#define _FUI_INTERNAL_LAYOUT_LAYOUT_ITEM_INFO_H_ + +#include "FUi_LayoutLayoutTypes.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +class LayoutItemProxy; +class RelativeLayout; +class RelativeProxyList; +class TableLayout; +class LinearLayout; + +class LayoutItemInfo +{ + +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + LayoutItemInfo(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~LayoutItemInfo(void); +}; // LayoutItemInfo + +class RelativeItemInfo + : public LayoutItemInfo +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + RelativeItemInfo(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~RelativeItemInfo(void); + +private: + int __refCount; + LayoutItemProxy* __pTarget[6]; + RelativeLayoutEdge __targetEdge[6]; + + friend class RelativeLayout; + friend class RelativeProxyList; +}; // RelativeItemInfo + +class TableItemInfo + : public LayoutItemInfo +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + TableItemInfo(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~TableItemInfo(void); + +private: + int __id; + bool __enable; + bool __merged; + LayoutPoint __mergeEndPoint; + bool __fillWidth; + bool __fillHeight; + LayoutSize __minSize; + LayoutSize __maxSize; + + friend class TableLayout; +}; // TableItemInfo + +class LinearItemInfo + : public LayoutItemInfo +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + LinearItemInfo(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~LinearItemInfo(void); + +private: + float __weight; + int __spacing; + bool __fixedSize; + LayoutRect __itemRect; + + friend class LinearLayout; +}; // LinearItemInfo + +}}} //Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_LAYOUT_ITEM_PROXY_H_ diff --git a/src/ui/layout/FUi_LayoutLayoutItemProxy.cpp b/src/ui/layout/FUi_LayoutLayoutItemProxy.cpp new file mode 100644 index 0000000..e01bece --- /dev/null +++ b/src/ui/layout/FUi_LayoutLayoutItemProxy.cpp @@ -0,0 +1,254 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutItemProxy.cpp + * @brief This is the implementation file for LayoutItemProxy class. + * + * This file contains the implementation of LayoutItemProxy class. + */ + +#include +#include +#include "FUi_LayoutLayoutItemProxy.h" +#include "FUi_LayoutLayoutContainer.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +LayoutItemProxy::LayoutItemProxy(LayoutItem& pRealItem) + : __index(-1) + , __pItem(&pRealItem) + , __widthMatchmode(NONE_MODE) + , __heightMatchmode(NONE_MODE) + , __pParentLayout(null) +{ + __itemAlign.HAlign = ITEM_HORIZONTAL_ALIGN_LEFT; + __itemAlign.VAlign = ITEM_VERTICAL_ALIGN_TOP; + LayoutRect rect = {0, 0, 0, 0}; + ItemMargin margin = {0, 0, 0, 0}; + __itemMargin = margin; + __baseRect = rect; + __calculatedRect = rect; +} + +LayoutItemProxy::~LayoutItemProxy() +{ +} + +LayoutItemProxy* +LayoutItemProxy::Create(Layout& pLayout, LayoutItem& pRealItem) +{ + LayoutItemProxy* pItemProxy = new (std::nothrow) LayoutItemProxy(pRealItem); + + return pItemProxy; +} + +void +LayoutItemProxy::Destroy() +{ + LayoutContainer* pContainer = dynamic_cast (GetItem()); + if (pContainer) + { + pContainer->OnDestroyContainerProxy(); + } + delete this; +} + +int +LayoutItemProxy::GetIndex(void) const +{ + return __index; +} + +LayoutItem* +LayoutItemProxy::GetItem() const +{ + return __pItem; +} + +void +LayoutItemProxy::SetItemAlignment(ItemAlign align) +{ + __itemAlign = align; +} + +ItemAlign +LayoutItemProxy::GetItemAlignment(void) const +{ + return __itemAlign; +} + +void +LayoutItemProxy::SetItemMargin(ItemMargin margin) +{ + __itemMargin = margin; +} + +ItemMargin +LayoutItemProxy::GetItemMargin(void) const +{ + return __itemMargin; +} + +void +LayoutItemProxy::SetItemWidthMatchMode(LayoutMatchMode matchMode) +{ + __widthMatchmode = matchMode; +} + +LayoutMatchMode +LayoutItemProxy::GetItemWidthMatchMode(void) const +{ + return __widthMatchmode; +} + +void +LayoutItemProxy::SetItemHeightMatchMode(LayoutMatchMode matchMode) +{ + __heightMatchmode = matchMode; +} + +LayoutMatchMode +LayoutItemProxy::GetItemHeightMatchMode(void) const +{ + return __heightMatchmode; +} + +void +LayoutItemProxy::SetItemBaseRect(LayoutRect rect) +{ + __baseRect = rect; +} + +LayoutRect +LayoutItemProxy::GetItemBaseRect() const +{ + return __baseRect; +} + +void +LayoutItemProxy::SetMeasuredSize(int width, int height) +{ + SysAssertf(__pItem != null, "LayoutItem is invalid"); + __pItem->SetMeasuredSize(width, height); +} + +void +LayoutItemProxy::GetMeasuredSize(int& width, int& height) const +{ + SysAssertf(__pItem != null, "LayoutItem is invalid"); + __pItem->GetMeasuredSize(width, height); +} + +result +LayoutItemProxy::SetItemWindowRect(const LayoutRect itemRect, bool calculating) +{ + SysAssertf(__pItem != null, "LayoutItem is invalid"); + if (calculating) + { + __calculatedRect = itemRect; + + return E_SUCCESS; + } + else + { + return __pItem->SetItemWindowRect(itemRect); + } +} + +void +LayoutItemProxy::GetItemWindowRect(LayoutRect& itemRect) const +{ + SysAssertf(__pItem != null, "LayoutItem is invalid"); + if (__calculatedRect.x == 0 && __calculatedRect.y == 0 && __calculatedRect.w == 0 && __calculatedRect.h == 0) + { + __pItem->GetItemWindowRect(itemRect); + } + else + { + itemRect = __calculatedRect; + } +} + +void +LayoutItemProxy::ConvertWindowToClientBounds(const LayoutRect windowRect, LayoutRect& clientRect) +{ + SysAssertf(__pItem != null, "LayoutItem is invalid"); + __pItem->ConvertWindowToClientBounds(windowRect, clientRect); +} + +result +LayoutItemProxy::Measure(int width, int height) +{ + SysAssertf(__pItem != null, "LayoutItem is invalid"); + return __pItem->Measure(width, height); +} + +void +LayoutItemProxy::Visible(const bool visible) +{ + SysAssertf(__pItem != null, "LayoutItem is invalid"); + __pItem->Visible(visible); +} + +void +LayoutItemProxy::SetParentLayout(Layout* pLayout) +{ + __pParentLayout = pLayout; +} + +Layout* +LayoutItemProxy::GetParentLayout() const +{ + return __pParentLayout; +} + +void +LayoutItemProxy::SetIndex(int index) +{ + __index = index; +} + +void +LayoutItemProxy::GetMinSize(LayoutSize& minSize) const +{ + SysAssertf(__pItem != null, "LayoutItem is invalid"); + __pItem->GetMinSize(minSize); +} + +void +LayoutItemProxy::GetMaxSize(LayoutSize& maxSize) const +{ + SysAssertf(__pItem != null, "LayoutItem is invalid"); + __pItem->GetMaxSize(maxSize); +} + +void +LayoutItemProxy::SetParentContainer(LayoutContainer* pParentContainer) +{ + SysAssertf(__pItem != null, "LayoutItem is invalid"); + __pItem->SetParentContainer(pParentContainer); +} + +LayoutContainer* +LayoutItemProxy::GetParentContainer() const +{ + SysAssertf(__pItem != null, "LayoutItem is invalid"); + return __pItem->GetParentContainer(); +} + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutLayoutItemProxy.h b/src/ui/layout/FUi_LayoutLayoutItemProxy.h new file mode 100644 index 0000000..4e53733 --- /dev/null +++ b/src/ui/layout/FUi_LayoutLayoutItemProxy.h @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutItemProxy.h + * @brief This is the header file for LayoutItemProxy class. + * + * This header file contains the declaration of LayoutItemProxy class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_LAYOUT_ITEM_PROXY_H_ +#define _FUI_INTERNAL_LAYOUT_LAYOUT_ITEM_PROXY_H_ + +#include "FUi_LayoutLayoutItem.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +class Layout; + +class LayoutItemProxy +{ +public: + int GetIndex(void) const; + + LayoutItem* GetItem(void) const; + + void SetItemAlignment(const ItemAlign align); + ItemAlign GetItemAlignment(void) const; + + void SetItemMargin(const ItemMargin margin); + ItemMargin GetItemMargin(void) const; + + void SetItemWidthMatchMode(const LayoutMatchMode matchmode); + LayoutMatchMode GetItemWidthMatchMode(void) const; + void SetItemHeightMatchMode(const LayoutMatchMode matchmode); + LayoutMatchMode GetItemHeightMatchMode(void) const; + + void SetItemBaseRect(const LayoutRect rect); + LayoutRect GetItemBaseRect(void) const; + + void SetMeasuredSize(int width, int height); + void GetMeasuredSize(int& width, int& height) const; + + result SetItemWindowRect(const LayoutRect itemRect, bool calculating = true); + void GetItemWindowRect(LayoutRect& itemRect) const; + + void ConvertWindowToClientBounds(const LayoutRect windowRect, LayoutRect& clientRect); + + result Measure(int width, int height); + void Visible(const bool visible); + + void SetParentLayout(Layout* pLayout); + Layout* GetParentLayout(void) const; + + void GetMinSize(LayoutSize& minSize) const; + void GetMaxSize(LayoutSize& maxSize) const; + + void SetParentContainer(LayoutContainer* pParentContainer); + LayoutContainer* GetParentContainer(void) const; + +private: + LayoutItemProxy(LayoutItem& pRealItem); + LayoutItemProxy(const LayoutItemProxy&); + LayoutItemProxy& operator =(const LayoutItemProxy&); + + virtual ~LayoutItemProxy(void); + + void SetIndex(int index); + static LayoutItemProxy* Create(Layout& pLayout, LayoutItem& pRealItem); + void Destroy(void); + +// property +private: + int __index; + LayoutItem* __pItem; + + ItemAlign __itemAlign; + ItemMargin __itemMargin; + + LayoutMatchMode __widthMatchmode; + LayoutMatchMode __heightMatchmode; + + LayoutRect __baseRect; + LayoutRect __calculatedRect; + + Layout* __pParentLayout; + + friend class Layout; + friend class ProxyList; +}; // LayoutItemProxy + +}}} //Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_LAYOUT_ITEM_PROXY_H_ diff --git a/src/ui/layout/FUi_LayoutLayoutList.cpp b/src/ui/layout/FUi_LayoutLayoutList.cpp new file mode 100644 index 0000000..d5405fd --- /dev/null +++ b/src/ui/layout/FUi_LayoutLayoutList.cpp @@ -0,0 +1,126 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutList.cpp + * @brief This is the implementation file for LayoutList class. + * + * This file contains the implementation of LayoutList class. + */ + +#include +#include "FUi_LayoutLayoutList.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +LayoutList::LayoutList(void) +{ +} + +LayoutList::~LayoutList(void) +{ + RemoveAllNode(); +} + +LayoutListNode* +LayoutList::GetFirstNode(void) const +{ + return dynamic_cast (LinkedList::GetFirstNode()); +} + +LayoutListNode* +LayoutList::GetLastNode(void) const +{ + return dynamic_cast (LinkedList::GetLastNode()); +} + +LayoutListNode* +LayoutList::GetNextNode(const LayoutListNode& node) const +{ + return dynamic_cast (LinkedList::GetNextNode(node)); +} + +LayoutListNode* +LayoutList::GetPrevNode(const LayoutListNode& node) const +{ + return dynamic_cast (LinkedList::GetPrevNode(node)); +} + +LayoutListNode* +LayoutList::AddNode(Layout& addLayout) +{ + LayoutListNode* pAddNode = new (std::nothrow) LayoutListNode(); + + if (pAddNode == null) + { + return null; + } + + pAddNode->Create(addLayout); + + if (InsertIntoLeft(*_pEndNode, *pAddNode) != E_SUCCESS) + { + delete pAddNode; + return null; + } + + return pAddNode; +} + +bool +LayoutList::CheckNodeExists(const Layout& layout) const +{ + LayoutListNode* pCurNode = GetFirstNode(); + Layout* pCurLayout = null; + + while (pCurNode) + { + pCurLayout = pCurNode->GetLayout(); + if (pCurLayout == &layout) + { + return true; + } + pCurNode = GetNextNode(*pCurNode); + } + return false; +} + +result +LayoutList::RemoveNode(LinkedListNode& node) +{ + return LinkedList::RemoveNode(node); +} + + +void +LayoutList::RemoveAllNode(void) +{ + LinkedListNode* pCurNode = GetFirstNode(); + LinkedListNode* pNextNode = pCurNode; + + while (pCurNode != null) + { + pNextNode = LinkedList::GetNextNode(*pCurNode); + if (RemoveNode(*pCurNode) != E_SUCCESS) + { + SysAssert(false); + } + pCurNode = pNextNode; + } +} + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutLayoutList.h b/src/ui/layout/FUi_LayoutLayoutList.h new file mode 100644 index 0000000..e16ec7d --- /dev/null +++ b/src/ui/layout/FUi_LayoutLayoutList.h @@ -0,0 +1,65 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutList.h + * @brief This is the header file for LayoutList class. + * + * This header file contains the declaration of LayoutList class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_LAYOUT_LIST_H_ +#define _FUI_INTERNAL_LAYOUT_LAYOUT_LIST_H_ + +#include "FUi_LayoutLinkedList.h" +#include "FUi_LayoutLayoutListNode.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +class LayoutList + : public LinkedList +{ +private: + LayoutList(void); + virtual ~LayoutList(void); + + LayoutListNode* GetFirstNode(void) const; + LayoutListNode* GetLastNode(void) const; + + LayoutListNode* GetNextNode(const LayoutListNode& node) const; + LayoutListNode* GetPrevNode(const LayoutListNode& node) const; + + LayoutListNode* AddNode(Layout& addLayout); + virtual result RemoveNode(LinkedListNode& node); + + bool CheckNodeExists(const Layout& layout) const; + + void RemoveAllNode(void); + +private: + LayoutList(const LayoutList&); + LayoutList& operator =(const LayoutList&); + + friend class Layout; + friend class LayoutContainer; +}; // LayoutList + +}}} //Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_LAYOUT_LIST_H_ diff --git a/src/ui/layout/FUi_LayoutLayoutListNode.cpp b/src/ui/layout/FUi_LayoutLayoutListNode.cpp new file mode 100644 index 0000000..a5d6ebf --- /dev/null +++ b/src/ui/layout/FUi_LayoutLayoutListNode.cpp @@ -0,0 +1,50 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutListNode.cpp + * @brief This is the implementation file for LayoutListNode class. + * + * This file contains the implementation of LayoutListNode class. + */ + +#include "FUi_LayoutLayoutListNode.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +LayoutListNode::LayoutListNode() + : __pLayout(null) +{ +} + +LayoutListNode::~LayoutListNode() +{ +} + +void +LayoutListNode::Create(Layout& pLayout) +{ + __pLayout = &pLayout; +} + +Layout* +LayoutListNode::GetLayout() const +{ + return __pLayout; +} + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutLayoutListNode.h b/src/ui/layout/FUi_LayoutLayoutListNode.h new file mode 100644 index 0000000..a099442 --- /dev/null +++ b/src/ui/layout/FUi_LayoutLayoutListNode.h @@ -0,0 +1,61 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLayoutListNode.h + * @brief This is the header file for LayoutListNode class. + * + * This header file contains the declaration of LayoutListNode class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_LAYOUT_LIST_NODE_H_ +#define _FUI_INTERNAL_LAYOUT_LAYOUT_LIST_NODE_H_ + +#include "FUi_LayoutLinkedListNode.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +class Layout; + +class LayoutListNode + : public LinkedListNode +{ +public: + Layout* GetLayout(void) const; + +protected: + LayoutListNode(void); + virtual ~LayoutListNode(void); + + void Create(Layout& pData); + +private: + LayoutListNode(const LayoutListNode&); + LayoutListNode& operator =(const LayoutListNode&); + +// property +private: + Layout* __pLayout; + + friend class LayoutList; +}; // LayoutListNode + +}}} //Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_LAYOUT_LIST_NODE_H_ diff --git a/src/ui/layout/FUi_LayoutLinearLayout.cpp b/src/ui/layout/FUi_LayoutLinearLayout.cpp new file mode 100644 index 0000000..505a501 --- /dev/null +++ b/src/ui/layout/FUi_LayoutLinearLayout.cpp @@ -0,0 +1,1419 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLinearLayout.cpp + * @brief This is the implementation file for LinearLayout class. + * + * This file contains the implementation of LinearLayout class. + */ + +#include +#include +#include "FUi_Math.h" +#include "FUi_LayoutLinearLayout.h" +#include "FUi_LayoutLayoutItemProxy.h" +#include "FUi_LayoutProxyList.h" +#include "FUi_LayoutLayoutItemInfo.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +LinearLayout::LinearLayout(void) + : __orientation(LINEAR_NONE_ORIENTATION) + , __direction(LINEAR_NONE_DIRECTION) + , __weightSum(0.0) +{ + LinearProxyList* pLinearProxyList = new (std::nothrow) LinearProxyList(); + SysTryReturnVoidResult(NID_UI, pLinearProxyList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + SetItemList(pLinearProxyList); +} + +LinearLayout::~LinearLayout(void) +{ +} + +LinearLayout* +LinearLayout::CreateLinearLayoutN(void) +{ + LinearLayout* pLayout = new (std::nothrow) LinearLayout(); + SysTryReturn(NID_UI, pLayout != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Linear layout core allocation failure."); + if (GetLastResult() != E_SUCCESS) + { + delete pLayout; + return null; + } + + return pLayout; +} + +result +LinearLayout::Initialize(const LinearLayoutOrientation orientation, const LinearLayoutDirection direction) +{ + if (orientation == LINEAR_NONE_ORIENTATION || direction == LINEAR_NONE_DIRECTION) + { + return E_INVALID_ARG; + } + + __orientation = orientation; + + if (orientation == LINEAR_HORIZONTAL) + { + if (direction != LINEAR_LEFT_TO_RIGHT && direction != LINEAR_RIGHT_TO_LEFT) + { + return E_INVALID_ARG; + } + } + else + { + if (direction != LINEAR_TOP_TO_BOTTOM && direction != LINEAR_BOTTOM_TO_TOP) + { + return E_INVALID_ARG; + } + } + + __direction = direction; + + SetPartialUpdateFlag(true); + + return E_SUCCESS; +} + +result +LinearLayout::AddItemToIndex(LayoutItem& addItem, int index) +{ + result r = Layout::AddItem(addItem); + if (r != E_SUCCESS) + { + return r; + } + + return MoveItem(addItem, index); +} + +result +LinearLayout::MoveItem(LayoutItem& item, int index) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + if (index < 0 || pProxyList->GetNodeCount() <= index) + { + return E_INVALID_ARG; + } + + ProxyListNode* pItemNode = pProxyList->GetNode(item); + SysTryReturn(NID_UI, pItemNode != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + int indexCount = -1; + int targetIndex = -1; + int itemIndex = -1; + ProxyListNode* pTargetNode = null; + ProxyListNode* pNode = pProxyList->GetFirstNode(); + while (pNode != null) + { + indexCount++; + if (indexCount == index) + { + targetIndex = indexCount; + pTargetNode = pNode; + } + if (pItemNode == pNode) + { + itemIndex = indexCount; + } + + pNode = pProxyList->GetNextNode(*pNode); + } + + if (targetIndex == -1 || itemIndex == -1) + { + return E_INVALID_STATE; + } + + if (targetIndex == itemIndex) + { + return E_SUCCESS; + } + + result r = pProxyList->DetachNode(*pItemNode); + if (r != E_SUCCESS) + { + return r; + } + + if (targetIndex < itemIndex) + { + r = pProxyList->InsertIntoLeft(*pTargetNode, *pItemNode); + pProxyList->RefreshIndex(); + + return r; + } + else + { + r = pProxyList->InsertIntoRight(*pTargetNode, *pItemNode); + pProxyList->RefreshIndex(); + + return r; + } +} + +result +LinearLayout::SwapItem(LayoutItem& targetItem, LayoutItem& destItem) +{ + result r = E_SUCCESS; + + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + ProxyListNode* pTargetNode = pProxyList->GetNode(targetItem); + SysTryReturn(NID_UI, pTargetNode != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + ProxyListNode* pDestNode = pProxyList->GetNode(destItem); + SysTryReturn(NID_UI, pDestNode != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + r = pProxyList->SwapNode(*pTargetNode, *pDestNode); + pProxyList->RefreshIndex(); + + SetUpdateState(true); + return r; +} + +int +LinearLayout::GetItemCount(void) const +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + return pProxyList->GetNodeCount(); +} + +result +LinearLayout::GetItemIndex(LayoutItem& item, int& index) const +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + ProxyListNode* pTargetNode = pProxyList->GetNode(item); + SysTryReturn(NID_UI, pTargetNode != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + index = pProxyList->GetIndex(*pTargetNode); + + return E_SUCCESS; +} + +result +LinearLayout::SetOrientation(const LinearLayoutOrientation orientation) +{ + if (orientation == LINEAR_NONE_ORIENTATION) + { + return E_INVALID_ARG; + } + + if (__orientation != orientation) + { + if (orientation == LINEAR_HORIZONTAL) + { + __direction = LINEAR_LEFT_TO_RIGHT; + } + else + { + __direction = LINEAR_TOP_TO_BOTTOM; + } + } + + __orientation = orientation; + + SetUpdateState(true); + return E_SUCCESS; +} + +result +LinearLayout::GetOrientation(LinearLayoutOrientation& orientation) const +{ + if (__orientation == LINEAR_NONE_ORIENTATION) + { + return E_INVALID_STATE; + } + + orientation = __orientation; + + return E_SUCCESS; +} + +result +LinearLayout::SetDirection(const LinearLayoutDirection direction) +{ + if (direction == LINEAR_NONE_DIRECTION) + { + return E_INVALID_ARG; + } + + if (__orientation == LINEAR_HORIZONTAL && + (direction == LINEAR_TOP_TO_BOTTOM || direction == LINEAR_BOTTOM_TO_TOP)) + { + return E_INVALID_ARG; + } + + if (__orientation == LINEAR_VERTICAL && + (direction == LINEAR_LEFT_TO_RIGHT || direction == LINEAR_RIGHT_TO_LEFT)) + { + return E_INVALID_ARG; + } + + __direction = direction; + + SetUpdateState(true); + return E_SUCCESS; +} + +result +LinearLayout::GetDirection(LinearLayoutDirection& direction) const +{ + if (__direction == LINEAR_NONE_DIRECTION) + { + return E_INVALID_STATE; + } + + direction = __direction; + + return E_SUCCESS; +} + +result +LinearLayout::SetItemWeight(LayoutItem& item, const float weight) +{ + SysTryReturn(NID_UI, weight >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The weight value is negative."); + + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + ProxyListNode* pNode = pProxyList->GetNode(item); + SysTryReturn(NID_UI, pNode != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + + __weightSum -= pItemInfo->__weight; + pItemInfo->__weight = weight; + __weightSum += pItemInfo->__weight; + + SetUpdateState(true); + return E_SUCCESS; +} + +result +LinearLayout::GetItemWeight(const LayoutItem& item, float& weight) const +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + ProxyListNode* pNode = pProxyList->GetNode(item); + SysTryReturn(NID_UI, pNode != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + + weight = pItemInfo->__weight; + + return E_SUCCESS; +} + +result +LinearLayout::SetItemSpacing(LayoutItem& item, int spacing) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + ProxyListNode* pNode = pProxyList->GetNode(item); + SysTryReturn(NID_UI, pNode != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + + pItemInfo->__spacing = spacing; + + SetUpdateState(true); + return E_SUCCESS; +} + +result +LinearLayout::GetItemSpacing(const LayoutItem& item, int& spacing) const +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + ProxyListNode* pNode = pProxyList->GetNode(item); + SysTryReturn(NID_UI, pNode != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout."); + + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + + spacing = pItemInfo->__spacing; + + return E_SUCCESS; +} + +result +LinearLayout::OnLayout(int width, int height, bool layoutUpdating) +{ + result r = E_SUCCESS; + + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + if (__orientation == LINEAR_NONE_ORIENTATION || __direction == LINEAR_NONE_DIRECTION) + { + return E_INVALID_STATE; + } + + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + if (pContainerProxy == null) + { + return E_INVALID_STATE; + } + + LayoutRect intendedRect = {0, 0, width, height}; + pContainerProxy->ConvertWindowToClientBounds(intendedRect, intendedRect); + + LayoutRect layoutRect = GetLayoutRect(); + layoutRect.w = intendedRect.w; + layoutRect.h = intendedRect.h; + SetLayoutRect(layoutRect); + + int rightBound = 0; + int bottomBound = 0; + r = CalculatePositionSize(rightBound, bottomBound); + if (r != E_SUCCESS) + { + return r; + } + + if (_FloatHardCompare(__weightSum, 0.0f) == false) + { + r = CalculateWeight(rightBound, bottomBound); + if (r != E_SUCCESS) + { + return r; + } + } + + r = CalculateWrapContent(*pContainerProxy, rightBound, bottomBound, layoutUpdating); + if (r != E_SUCCESS) + { + return r; + } + + if (__orientation == LINEAR_HORIZONTAL) + { + r = CalculateAlignment(VERTICALONLY); + } + else + { + r = CalculateAlignment(HORIZONTALONLY); + } + if (r != E_SUCCESS) + { + return r; + } + + r = CalculateCorrectedAlignment(); + if (r != E_SUCCESS) + { + return r; + } + + r = CalculateMatchParent(); + if (r != E_SUCCESS) + { + return r; + } + + ProxyListNode* pNode = pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemProxy == null || pItemInfo == null) + { + return E_INVALID_STATE; + } + + r = pItemProxy->SetItemWindowRect(pItemInfo->__itemRect); + if (r != E_SUCCESS) + { + return r; + } + + pNode = pProxyList->GetNextNode(*pNode); + } + + return E_SUCCESS; +} + +result +LinearLayout::CalculatePositionSize(int& rightBound, int& bottomBound) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + if (pProxyList->GetNodeCount() == 0) + { + return E_SUCCESS; + } + + if (__orientation == LINEAR_HORIZONTAL) + { + return CalculateHorizontalPositionSize(rightBound, bottomBound); + } + else + { + return CalculateVerticalPositonSize(rightBound, bottomBound); + } +} + +result +LinearLayout::CalculateHorizontalPositionSize(int& rightBound, int& bottomBound) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + LayoutRect layoutRect = GetLayoutRect(); + int x = layoutRect.x; + if (__direction == LINEAR_RIGHT_TO_LEFT) + { + x += layoutRect.w; + } + + ProxyListNode* pNode = pProxyList->GetFirstNode(); + ProxyListNode* pFirstNode = pNode; + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemProxy == null || pItemInfo == null) + { + return E_INVALID_STATE; + } + + bool changedProperty = false; + if (pItemProxy->GetItemWidthMatchMode() == MATCH_PARENT) + { + pItemProxy->SetItemWidthMatchMode(NONE_MODE); + changedProperty = true; + } + + LayoutRect itemRect = pItemProxy->GetItemBaseRect(); + result r = pItemProxy->Measure(itemRect.w, itemRect.h); + if (r != E_SUCCESS) + { + return r; + } + pItemProxy->GetMeasuredSize(itemRect.w, itemRect.h); + if (__direction == LINEAR_LEFT_TO_RIGHT) + { + itemRect.x = x; + if (pNode != pFirstNode) + { + itemRect.x += pItemInfo->__spacing; + } + x = itemRect.x + itemRect.w; + } + else + { + x -= itemRect.w; + if (pNode != pFirstNode) + { + x -= pItemInfo->__spacing; + } + itemRect.x = x; + } + itemRect.y = layoutRect.y; + pItemInfo->__itemRect = itemRect; + + if (__direction == LINEAR_LEFT_TO_RIGHT) + { + rightBound = x; + } + else + { + rightBound = layoutRect.x + layoutRect.w; + } + + ItemAlign align = pItemProxy->GetItemAlignment(); + ItemMargin margin = pItemProxy->GetItemMargin(); + if (pItemProxy->GetItemHeightMatchMode() != MATCH_PARENT) + { + int itemBottomPosition = 0; + if (align.VAlign == ITEM_VERTICAL_ALIGN_TOP) + { + itemBottomPosition = margin.top + itemRect.h; + } + else if (align.VAlign == ITEM_VERTICAL_ALIGN_BOTTOM) + { + itemBottomPosition = margin.bottom + itemRect.h; + } + else if (align.VAlign == ITEM_VERTICAL_ALIGN_TOP_BOTTOM) + { + itemBottomPosition = margin.top + itemRect.h + margin.bottom; + } + else + { + itemBottomPosition = itemRect.h; + } + + if (itemBottomPosition > bottomBound) + { + bottomBound = itemBottomPosition; + } + } + + if (changedProperty) + { + pItemProxy->SetItemWidthMatchMode(MATCH_PARENT); + } + + pNode = pProxyList->GetNextNode(*pNode); + } + + return E_SUCCESS; +} + +result +LinearLayout::CalculateVerticalPositonSize(int& rightBound, int& bottomBound) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + LayoutRect layoutRect = GetLayoutRect(); + int y = layoutRect.y; + if (__direction == LINEAR_BOTTOM_TO_TOP) + { + y += layoutRect.h; + } + + ProxyListNode* pNode = pProxyList->GetFirstNode(); + ProxyListNode* pFirstNode = pNode; + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemProxy == null || pItemInfo == null) + { + return E_INVALID_STATE; + } + + bool changedProperty = false; + if (pItemProxy->GetItemHeightMatchMode() == MATCH_PARENT) + { + pItemProxy->SetItemHeightMatchMode(NONE_MODE); + changedProperty = true; + } + + LayoutRect itemRect = pItemProxy->GetItemBaseRect(); + result r = pItemProxy->Measure(itemRect.w, itemRect.h); + if (r != E_SUCCESS) + { + return r; + } + pItemProxy->GetMeasuredSize(itemRect.w, itemRect.h); + if (__direction == LINEAR_TOP_TO_BOTTOM) + { + itemRect.y = y; + if (pNode != pFirstNode) + { + itemRect.y += pItemInfo->__spacing; + } + y = itemRect.y + itemRect.h; + } + else + { + y -= itemRect.h; + if (pNode != pFirstNode) + { + y -= pItemInfo->__spacing; + } + itemRect.y = y; + } + itemRect.x = layoutRect.x; + pItemInfo->__itemRect = itemRect; + + if (__direction == LINEAR_TOP_TO_BOTTOM) + { + bottomBound = y; + } + else + { + bottomBound = layoutRect.y + layoutRect.h; + } + + ItemAlign align = pItemProxy->GetItemAlignment(); + ItemMargin margin = pItemProxy->GetItemMargin(); + if (pItemProxy->GetItemWidthMatchMode() != MATCH_PARENT) + { + int itemRightPosition = 0; + if (align.HAlign == ITEM_HORIZONTAL_ALIGN_LEFT) + { + itemRightPosition = margin.left + itemRect.w; + } + else if (align.HAlign == ITEM_HORIZONTAL_ALIGN_RIGHT) + { + itemRightPosition = margin.right + itemRect.w; + } + else if (align.HAlign == ITEM_HORIZONTAL_ALIGN_LEFT_RIGHT) + { + itemRightPosition = margin.left + itemRect.w + margin.right; + } + else + { + itemRightPosition = itemRect.w; + } + + if (itemRightPosition > rightBound) + { + rightBound = itemRightPosition; + } + } + + if (changedProperty) + { + pItemProxy->SetItemHeightMatchMode(MATCH_PARENT); + } + + pNode = pProxyList->GetNextNode(*pNode); + } + + return E_SUCCESS; +} + +result +LinearLayout::CalculateWeight(int& rightBound, int& bottomBound) +{ + float originalWeightSum = __weightSum; + LayoutRect layoutRect = GetLayoutRect(); + int emptySpace = 0; + result r = E_SUCCESS; + + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + if (__orientation == LINEAR_HORIZONTAL) + { + if (__direction == LINEAR_LEFT_TO_RIGHT) + { + emptySpace = (layoutRect.x + layoutRect.w) - rightBound; + } + else + { + ProxyListNode* pNode = pProxyList->GetLastNode(); + if (pNode == null) + { + return E_INVALID_STATE; + } + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + + emptySpace = pItemInfo->__itemRect.x - layoutRect.x; + } + + while (emptySpace != 0) + { + r = CalculateHorizontalWeight(emptySpace); + if (r != E_SUCCESS) + { + return r; + } + } + + ProxyListNode* pBoundNode = null; + if (__direction == LINEAR_TOP_TO_BOTTOM) + { + pBoundNode = pProxyList->GetLastNode(); + } + else + { + pBoundNode = pProxyList->GetFirstNode(); + } + if (pBoundNode == null) + { + return E_INVALID_STATE; + } + LinearItemInfo* pBoundInfo = dynamic_cast (pBoundNode->GetItemInfo()); + if (pBoundInfo == null) + { + return E_INVALID_STATE; + } + rightBound = pBoundInfo->__itemRect.x + pBoundInfo->__itemRect.w; + } + else + { + if (__direction == LINEAR_TOP_TO_BOTTOM) + { + emptySpace = (layoutRect.y + layoutRect.h) - bottomBound; + } + else + { + ProxyListNode* pNode = pProxyList->GetLastNode(); + if (pNode == null) + { + return E_INVALID_STATE; + } + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + + emptySpace = pItemInfo->__itemRect.y - layoutRect.y; + } + + while (emptySpace != 0) + { + r = CalculateVerticalWeight(emptySpace); + if (r != E_SUCCESS) + { + return r; + } + } + + ProxyListNode* pBoundNode = null; + if (__direction == LINEAR_TOP_TO_BOTTOM) + { + pBoundNode = pProxyList->GetLastNode(); + } + else + { + pBoundNode = pProxyList->GetFirstNode(); + } + if (pBoundNode == null) + { + return E_INVALID_STATE; + } + LinearItemInfo* pBoundInfo = dynamic_cast (pBoundNode->GetItemInfo()); + if (pBoundInfo == null) + { + return E_INVALID_STATE; + } + bottomBound = pBoundInfo->__itemRect.y + pBoundInfo->__itemRect.h; + } + + ProxyListNode* pNode = pProxyList->GetFirstNode(); + while (pNode != null) + { + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + pItemInfo->__fixedSize = false; + + pNode = pProxyList->GetNextNode(*pNode); + } + + __weightSum = originalWeightSum; + + return E_SUCCESS; +} + +result +LinearLayout::CalculateHorizontalWeight(int& emptySpace) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + if (_FloatHardCompare(__weightSum, 0.0f) == true) + { + emptySpace = 0; + return E_SUCCESS; + } + + result r = E_SUCCESS; + int x = 0; + int measuredWidth = 0; + int usedEmptySpace = emptySpace; + int itemCount = pProxyList->GetNodeCount(); + + if (usedEmptySpace <= itemCount && usedEmptySpace >= -itemCount) + { + ProxyListNode* pNode = pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemProxy == null || pItemInfo == null) + { + return E_INVALID_STATE; + } + LayoutRect itemRect = pItemInfo->__itemRect; + itemRect.x += x; + if (pItemInfo->__fixedSize == false && usedEmptySpace != 0) + { + if (usedEmptySpace > 0) + { + itemRect.w++; + + r = pItemProxy->Measure(itemRect.w, itemRect.h); + if (r != E_SUCCESS) + { + return r; + } + + pItemProxy->GetMeasuredSize(measuredWidth, itemRect.h); + if (measuredWidth == itemRect.w) + { + usedEmptySpace--; + if (__direction == LINEAR_LEFT_TO_RIGHT) + { + x++; + } + else + { + itemRect.x--; + x--; + } + } + else + { + itemRect.w = measuredWidth; + __weightSum -= pItemInfo->__weight; + pItemInfo->__fixedSize = true; + } + } + else + { + itemRect.w--; +#ifdef NOT_SUPPORT_NEGATIVE_SIZE + if (itemRect.w < 0) + { + itemRect.w = 0; + } +#endif + r = pItemProxy->Measure(itemRect.w, itemRect.h); + if (r != E_SUCCESS) + { + return r; + } + + pItemProxy->GetMeasuredSize(measuredWidth, itemRect.h); + if (measuredWidth == itemRect.w) + { + usedEmptySpace++; + if (__direction == LINEAR_LEFT_TO_RIGHT) + { + x--; + } + else + { + itemRect.x++; + x++; + } + } + else + { + itemRect.w = measuredWidth; + __weightSum -= pItemInfo->__weight; + pItemInfo->__fixedSize = true; + } + } + } + pItemInfo->__itemRect = itemRect; + + pNode = pProxyList->GetNextNode(*pNode); + } + emptySpace = usedEmptySpace; + + return E_SUCCESS; + } + + float unitSize = emptySpace / __weightSum; + int correctionValue = emptySpace - (int) (unitSize * 100.0) * (int) (__weightSum) / 100; + if (correctionValue < 0) + { + correctionValue = -correctionValue; + } + + ProxyListNode* pNode = pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemProxy == null || pItemInfo == null) + { + return E_INVALID_STATE; + } + LayoutRect itemRect = pItemInfo->__itemRect; + int correctionSize = (int) (unitSize * pItemInfo->__weight); + if (correctionValue) + { + if (correctionSize < 0) + { + correctionSize--; + } + else + { + correctionSize++; + } + correctionValue--; + } + + if (__direction == LINEAR_LEFT_TO_RIGHT) + { + itemRect.x += x; + } + + if (pItemInfo->__fixedSize == false) + { + itemRect.w += correctionSize; + x += correctionSize; + usedEmptySpace -= correctionSize; + } + + if (__direction == LINEAR_RIGHT_TO_LEFT) + { + itemRect.x -= x; + } + + r = pItemProxy->Measure(itemRect.w, itemRect.h); + if (r != E_SUCCESS) + { + return r; + } + pItemProxy->GetMeasuredSize(measuredWidth, itemRect.h); + if (measuredWidth != itemRect.w) + { + usedEmptySpace = usedEmptySpace - (measuredWidth - itemRect.w); + x = x + (measuredWidth - itemRect.w); + itemRect.w = measuredWidth; + __weightSum -= pItemInfo->__weight; + pItemInfo->__fixedSize = true; + } +#ifdef NOT_SUPPORT_NEGATIVE_SIZE + if (itemRect.w < 0) + { + itemRect.w = 0; + } +#endif + pItemInfo->__itemRect = itemRect; + + pNode = pProxyList->GetNextNode(*pNode); + } + emptySpace = usedEmptySpace; + + return E_SUCCESS; +} + +result +LinearLayout::CalculateVerticalWeight(int& emptySpace) +{ + if (_FloatHardCompare(__weightSum, 0.0f)) + { + emptySpace = 0; + return E_SUCCESS; + } + + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + result r = E_SUCCESS; + int y = 0; + int measuredHeight = 0; + int usedEmptySpace = emptySpace; + int itemCount = pProxyList->GetNodeCount(); + + if (usedEmptySpace <= itemCount && usedEmptySpace >= -itemCount) + { + ProxyListNode* pNode = pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemProxy == null || pItemInfo == null) + { + return E_INVALID_STATE; + } + LayoutRect itemRect = pItemInfo->__itemRect; + itemRect.y += y; + if (pItemInfo->__fixedSize == false && usedEmptySpace != 0) + { + if (usedEmptySpace > 0) + { + itemRect.h++; + + r = pItemProxy->Measure(itemRect.w, itemRect.h); + if (r != E_SUCCESS) + { + return r; + } + + pItemProxy->GetMeasuredSize(itemRect.w, measuredHeight); + if (measuredHeight == itemRect.h) + { + usedEmptySpace--; + if (__direction == LINEAR_TOP_TO_BOTTOM) + { + y++; + } + else + { + itemRect.y--; + y--; + } + } + else + { + itemRect.h = measuredHeight; + __weightSum -= pItemInfo->__weight; + pItemInfo->__fixedSize = true; + } + } + else + { + itemRect.h--; +#ifdef NOT_SUPPORT_NEGATIVE_SIZE + if (itemRect.h < 0) + { + itemRect.h = 0; + } +#endif + r = pItemProxy->Measure(itemRect.w, itemRect.h); + if (r != E_SUCCESS) + { + return r; + } + + pItemProxy->GetMeasuredSize(itemRect.w, measuredHeight); + if (measuredHeight == itemRect.h) + { + usedEmptySpace++; + if (__direction == LINEAR_TOP_TO_BOTTOM) + { + y--; + } + else + { + itemRect.y++; + y++; + } + } + else + { + itemRect.h = measuredHeight; + __weightSum -= pItemInfo->__weight; + pItemInfo->__fixedSize = true; + } + } + } + pItemInfo->__itemRect = itemRect; + + pNode = pProxyList->GetNextNode(*pNode); + } + emptySpace = usedEmptySpace; + + return E_SUCCESS; + } + + float unitSize = emptySpace / __weightSum; + int correctionValue = emptySpace - (int) (unitSize * 100.0) * (int) (__weightSum) / 100; + if (correctionValue < 0) + { + correctionValue = -correctionValue; + } + + ProxyListNode* pNode = pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemProxy == null || pItemInfo == null) + { + return E_INVALID_STATE; + } + LayoutRect itemRect = pItemInfo->__itemRect; + int correctionSize = (int) (unitSize * pItemInfo->__weight); + if (correctionValue) + { + if (correctionSize < 0) + { + correctionSize--; + } + else + { + correctionSize++; + } + correctionValue--; + } + + if (__direction == LINEAR_TOP_TO_BOTTOM) + { + itemRect.y += y; + } + + if (pItemInfo->__fixedSize == false) + { + itemRect.h += correctionSize; + y += correctionSize; + usedEmptySpace -= correctionSize; + } + + if (__direction == LINEAR_BOTTOM_TO_TOP) + { + itemRect.y -= y; + } + + r = pItemProxy->Measure(itemRect.w, itemRect.h); + if (r != E_SUCCESS) + { + return r; + } + pItemProxy->GetMeasuredSize(itemRect.w, measuredHeight); + if (measuredHeight != itemRect.h) + { + usedEmptySpace = usedEmptySpace - (measuredHeight - itemRect.h); + y = y + (measuredHeight - itemRect.h); + itemRect.h = measuredHeight; + __weightSum -= pItemInfo->__weight; + pItemInfo->__fixedSize = true; + } +#ifdef NOT_SUPPORT_NEGATIVE_SIZE + if (itemRect.h < 0) + { + itemRect.h = 0; + } +#endif + pItemInfo->__itemRect = itemRect; + + pNode = pProxyList->GetNextNode(*pNode); + } + emptySpace = usedEmptySpace; + + return E_SUCCESS; +} + +result +LinearLayout::CalculateWrapContent(LayoutItemProxy& containerProxy, int rightBound, int bottomBound, bool layoutUpdating) +{ + LayoutMatchMode widthMatchMode = containerProxy.GetItemWidthMatchMode(); + LayoutMatchMode heightMatchMode = containerProxy.GetItemHeightMatchMode(); + + if (widthMatchMode != WRAP_CONTENT && heightMatchMode != WRAP_CONTENT) + { + return E_SUCCESS; + } + + LayoutRect containerRect; + LayoutRect clientRect; + containerProxy.GetItemWindowRect(containerRect); + containerProxy.ConvertWindowToClientBounds(containerRect, clientRect); + + int correctionWidth = containerRect.w - clientRect.w; + int correctionHeight = containerRect.h - clientRect.h; + LayoutSize minSize; + LayoutSize maxSize; + containerProxy.GetMinSize(minSize); + containerProxy.GetMaxSize(maxSize); + LayoutRect layoutRect = GetLayoutRect(); + + if (widthMatchMode == WRAP_CONTENT) + { + layoutRect.w = rightBound - layoutRect.x; + if (layoutRect.w < 0) + { + layoutRect.w = 0; + } + containerRect.w = layoutRect.w + (containerRect.w - clientRect.w); + containerRect.w = layoutRect.w + correctionWidth; +#ifdef NOT_SUPPORT_NEGATIVE_SIZE + if (containerRect.w < 0) + { + containerRect.w = 0; + } +#endif + if (containerRect.w < minSize.w) + { + containerRect.w = minSize.w; + } + if (containerRect.w > maxSize.w) + { + containerRect.w = maxSize.w; + } + layoutRect.w = containerRect.w - correctionWidth; + } + if (heightMatchMode == WRAP_CONTENT) + { + layoutRect.h = bottomBound - layoutRect.y; + if (layoutRect.h < 0) + { + layoutRect.h = 0; + } + containerRect.h = layoutRect.h + (containerRect.h - clientRect.h); + containerRect.h = layoutRect.h + correctionHeight; +#ifdef NOT_SUPPORT_NEGATIVE_SIZE + if (containerRect.h < 0) + { + containerRect.h = 0; + } +#endif + if (containerRect.h < minSize.h) + { + containerRect.h = minSize.h; + } + if (containerRect.h > maxSize.h) + { + containerRect.h = maxSize.h; + } + layoutRect.h = containerRect.h - correctionHeight; + } + SetLayoutRect(layoutRect); + if (layoutUpdating) + { + result r = containerProxy.SetItemWindowRect(containerRect); + if (r != E_SUCCESS) + { + return r; + } + } + + return E_SUCCESS; +} + +result +LinearLayout::CalculateMatchParent(void) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + LayoutRect layoutRect = GetLayoutRect(); + + ProxyListNode* pNode = pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemProxy == null || pItemInfo == null) + { + return E_INVALID_STATE; + } + + bool changedProperty = false; + if (pItemProxy->GetItemHeightMatchMode() == MATCH_PARENT && __orientation == LINEAR_HORIZONTAL) + { + if (pItemProxy->GetItemWidthMatchMode() == MATCH_PARENT) + { + pItemProxy->SetItemWidthMatchMode(NONE_MODE); + changedProperty = true; + } + LayoutRect itemRect = pItemInfo->__itemRect; + result r = pItemProxy->Measure(itemRect.w, itemRect.h); + if (r != E_SUCCESS) + { + return r; + } + pItemProxy->GetMeasuredSize(itemRect.w, itemRect.h); + itemRect.y = layoutRect.y; + pItemInfo->__itemRect = itemRect; + + if (changedProperty == true) + { + pItemProxy->SetItemWidthMatchMode(MATCH_PARENT); + } + } + if (pItemProxy->GetItemWidthMatchMode() == MATCH_PARENT && __orientation == LINEAR_VERTICAL) + { + if (pItemProxy->GetItemHeightMatchMode() == MATCH_PARENT) + { + pItemProxy->SetItemHeightMatchMode(NONE_MODE); + changedProperty = true; + } + LayoutRect itemRect = pItemInfo->__itemRect; + result r = pItemProxy->Measure(itemRect.w, itemRect.h); + if (r != E_SUCCESS) + { + return r; + } + pItemProxy->GetMeasuredSize(itemRect.w, itemRect.h); + itemRect.x = layoutRect.x; + pItemInfo->__itemRect = itemRect; + + if (changedProperty == true) + { + pItemProxy->SetItemHeightMatchMode(MATCH_PARENT); + } + } + + pNode = pProxyList->GetNextNode(*pNode); + } + + return E_SUCCESS; +} + +result +LinearLayout::CalculateCorrectedAlignment(void) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + ProxyListNode* pNode = pProxyList->GetFirstNode(); + while (pNode != null) + { + LayoutItemProxy* pItemProxy = pNode->GetItemProxy(); + LinearItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemProxy == null || pItemInfo == null) + { + return E_INVALID_STATE; + } + ItemAlign align = pItemProxy->GetItemAlignment(); + LayoutRect itemWindowRect; + pItemProxy->GetItemWindowRect(itemWindowRect); + + if (__orientation == LINEAR_HORIZONTAL) + { + pItemInfo->__itemRect.y = itemWindowRect.y; + if (align.VAlign == ITEM_VERTICAL_ALIGN_TOP_BOTTOM) + { + pItemInfo->__itemRect.h = itemWindowRect.h; + } + } + else + { + pItemInfo->__itemRect.x = itemWindowRect.x; + if (align.HAlign == ITEM_HORIZONTAL_ALIGN_LEFT_RIGHT) + { + pItemInfo->__itemRect.w = itemWindowRect.w; + } + } + + pNode = pProxyList->GetNextNode(*pNode); + } + + return E_SUCCESS; +} + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutLinkedList.cpp b/src/ui/layout/FUi_LayoutLinkedList.cpp new file mode 100644 index 0000000..f9d0c2c --- /dev/null +++ b/src/ui/layout/FUi_LayoutLinkedList.cpp @@ -0,0 +1,241 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLinkedList.cpp + * @brief This is the implementation file for LinkedList class. + * + * This file contains the implementation of LinkedList class. + */ + +#include +#include "FUi_LayoutLinkedList.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +LinkedList::LinkedList(void) + : _pRootNode(null) + , _pEndNode(null) +{ + _pRootNode = new (std::nothrow) LinkedListNode(); + _pEndNode = new (std::nothrow) LinkedListNode(); + + if (_pRootNode != null && _pEndNode != null) + { + _pRootNode->__pNextNode = _pEndNode; + _pEndNode->__pPrevNode = _pRootNode; + } +} + +LinkedList::~LinkedList(void) +{ + delete _pRootNode; + delete _pEndNode; +} + +LinkedListNode* +LinkedList::GetFirstNode(void) const +{ + if (_pRootNode->__pNextNode != _pEndNode) + { + return _pRootNode->__pNextNode; + } + else + { + return null; + } +} + +LinkedListNode* +LinkedList::GetLastNode(void) const +{ + if (_pEndNode->__pPrevNode != _pRootNode) + { + return _pEndNode->__pPrevNode; + } + else + { + return null; + } +} + +LinkedListNode* +LinkedList::GetNextNode(const LinkedListNode& node) const +{ + if (&node == _pEndNode) + { + return null; + } + + if (node.__pNextNode == _pEndNode) + { + return null; + } + return node.__pNextNode; +} + +LinkedListNode* +LinkedList::GetPrevNode(const LinkedListNode& node) const +{ + if (&node == _pRootNode) + { + return null; + } + + if (node.__pPrevNode == _pRootNode) + { + return null; + } + + return node.__pPrevNode; +} + +result +LinkedList::RemoveNode(LinkedListNode& node) +{ + if (&node == _pRootNode || &node == _pEndNode) + { + return E_SYSTEM; + } + + LinkedListNode* pPrevNode = node.__pPrevNode; + LinkedListNode* pNextNode = node.__pNextNode; + + if (pPrevNode == null || pNextNode == null) + { + return E_SYSTEM; + } + + pPrevNode->__pNextNode = pNextNode; + pNextNode->__pPrevNode = pPrevNode; + + if (node.Destroy() != E_SUCCESS) + { + return E_SYSTEM; + } + + return E_SUCCESS; +} + +result +LinkedList::DetachNode(LinkedListNode& node) +{ + SysTryReturn(NID_UI, &node != _pRootNode, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is root node."); + SysTryReturn(NID_UI, &node != _pEndNode, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is end node."); + + LinkedListNode* pPrevNode = node.__pPrevNode; + LinkedListNode* pNextNode = node.__pNextNode; + + pPrevNode->__pNextNode = pNextNode; + pNextNode->__pPrevNode = pPrevNode; + + node.__pPrevNode = null; + node.__pNextNode = null; + + return E_SUCCESS; +} + +result +LinkedList::InsertIntoLeft(LinkedListNode& node, LinkedListNode& leftNode) +{ + LinkedListNode* pPrevNode = node.__pPrevNode; + + if (pPrevNode == null) + { + SysAssert(false); + return E_INVALID_ARG; + } + + pPrevNode->__pNextNode = &leftNode; + leftNode.__pPrevNode = pPrevNode; + leftNode.__pNextNode = &node; + node.__pPrevNode = &leftNode; + + return E_SUCCESS; +} + +result +LinkedList::InsertIntoRight(LinkedListNode& node, LinkedListNode& rightNode) +{ + LinkedListNode* pNextNode = node.__pNextNode; + + if (pNextNode == null) + { + SysAssert(false); + return E_INVALID_ARG; + } + + node.__pNextNode = &rightNode; + rightNode.__pPrevNode = &node; + rightNode.__pNextNode = pNextNode; + pNextNode->__pPrevNode = &rightNode; + + return E_SUCCESS; +} + +result +LinkedList::SwapNode(LinkedListNode& node1, LinkedListNode& node2) +{ + if (&node1 == _pRootNode || &node1 == _pEndNode || + &node2 == _pRootNode || &node2 == _pEndNode) + { + return E_INVALID_ARG; + } + + LinkedListNode* pPrevNode1 = node1.__pPrevNode; + LinkedListNode* pNextNode1 = node1.__pNextNode; + + LinkedListNode* pPrevNode2 = node2.__pPrevNode; + LinkedListNode* pNextNode2 = node2.__pNextNode; + + if (pPrevNode1 != &node2) + { + pPrevNode1->__pNextNode = &node2; + node2.__pPrevNode = pPrevNode1; + } + else + { + node1.__pNextNode = &node2; + node2.__pPrevNode = &node1; + } + + if (pNextNode1 != &node2) + { + pNextNode1->__pPrevNode = &node2; + node2.__pNextNode = pNextNode1; + } + else + { + node2.__pNextNode = &node1; + node1.__pPrevNode = &node2; + } + + if (pPrevNode2 != &node1) + { + pPrevNode2->__pNextNode = &node1; + node1.__pPrevNode = pPrevNode2; + } + if (pNextNode2 != &node1) + { + pNextNode2->__pPrevNode = &node1; + node1.__pNextNode = pNextNode2; + } + + return E_SUCCESS; +} + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutLinkedList.h b/src/ui/layout/FUi_LayoutLinkedList.h new file mode 100644 index 0000000..4562a60 --- /dev/null +++ b/src/ui/layout/FUi_LayoutLinkedList.h @@ -0,0 +1,69 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLinkedList.h + * @brief This is the header file for LinkedList class. + * + * This header file contains the declaration of LinkedList class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_LINKED_LIST_H_ +#define _FUI_INTERNAL_LAYOUT_LINKED_LIST_H_ + +#include "FUi_LayoutLinkedListNode.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +class LinkedList +{ +public: + virtual LinkedListNode* GetFirstNode(void) const; + virtual LinkedListNode* GetLastNode(void) const; + + virtual LinkedListNode* GetNextNode(const LinkedListNode& node) const; + virtual LinkedListNode* GetPrevNode(const LinkedListNode& node) const; + + result DetachNode(LinkedListNode& node); + + result InsertIntoLeft(LinkedListNode& node, LinkedListNode& leftNode); + result InsertIntoRight(LinkedListNode& node, LinkedListNode& rightNode); + result SwapNode(LinkedListNode& node1, LinkedListNode& node2); + + virtual result RemoveNode(LinkedListNode& node); + +protected: + LinkedList(void); + virtual ~LinkedList(void); + +private: + LinkedList(const LinkedList&); + LinkedList& operator =(const LinkedList&); + +// property +protected: + LinkedListNode* _pRootNode; + LinkedListNode* _pEndNode; + + friend class _Layout; +}; // LinkedList + +}}} //Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_LINKED_LIST_H_ diff --git a/src/ui/layout/FUi_LayoutLinkedListNode.cpp b/src/ui/layout/FUi_LayoutLinkedListNode.cpp new file mode 100644 index 0000000..df3e09c --- /dev/null +++ b/src/ui/layout/FUi_LayoutLinkedListNode.cpp @@ -0,0 +1,46 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLinkedListNode.cpp + * @brief This is the implementation file for LinkedListNode class. + * + * This file contains the implementation of LinkedListNode class. + */ + +#include "FUi_LayoutLinkedListNode.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +LinkedListNode::LinkedListNode(void) + : __pPrevNode(null) + , __pNextNode(null) +{ +} + +LinkedListNode::~LinkedListNode(void) +{ +} + +result +LinkedListNode::Destroy(void) +{ + delete this; + return E_SUCCESS; +} + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutLinkedListNode.h b/src/ui/layout/FUi_LayoutLinkedListNode.h new file mode 100644 index 0000000..ff73c2a --- /dev/null +++ b/src/ui/layout/FUi_LayoutLinkedListNode.h @@ -0,0 +1,61 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutLinkedListNode.h + * @brief This is the header file for LinkedListNode class. + * + * This header file contains the declaration of LinkedListNode class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_LINKED_LIST_NODE_H_ +#define _FUI_INTERNAL_LAYOUT_LINKED_LIST_NODE_H_ + +#include +#include +#include + +namespace Tizen +{ +namespace Ui +{ +namespace _Layout +{ + +class LinkedListNode +{ +protected: + LinkedListNode(void); + virtual ~LinkedListNode(void); + virtual result Destroy(void); + +private: + LinkedListNode(const LinkedListNode&); + LinkedListNode& operator =(const LinkedListNode&); + +// property +private: + LinkedListNode* __pPrevNode; + LinkedListNode* __pNextNode; + + friend class LinkedList; +}; // LinkedListNode + +}}} //Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_LINKED_LIST_NODE_H_ diff --git a/src/ui/layout/FUi_LayoutProxyList.cpp b/src/ui/layout/FUi_LayoutProxyList.cpp new file mode 100644 index 0000000..bff4870 --- /dev/null +++ b/src/ui/layout/FUi_LayoutProxyList.cpp @@ -0,0 +1,504 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutProxyList.cpp + * @brief This is the implementation file for ProxyList class. + * + * This file contains the implementation of ProxyList class. + */ + +#include +#include +#include "FUi_LayoutRelativeLayout.h" +#include "FUi_LayoutProxyList.h" +#include "FUi_LayoutLayoutItemProxy.h" +#include "FUi_LayoutLayoutItemInfo.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +ProxyList::ProxyList(void) + : __lastIndex(-1) +{ +} + +ProxyList::~ProxyList(void) +{ +} + +ProxyListNode* +ProxyList::GetFirstNode(void) const +{ + return dynamic_cast (LinkedList::GetFirstNode()); +} + +ProxyListNode* +ProxyList::GetLastNode(void) const +{ + return dynamic_cast (LinkedList::GetLastNode()); +} + +ProxyListNode* +ProxyList::GetNextNode(const LinkedListNode& node) const +{ + return dynamic_cast (LinkedList::GetNextNode(node)); +} + +ProxyListNode* +ProxyList::GetPrevNode(const LinkedListNode& node) const +{ + return dynamic_cast (LinkedList::GetPrevNode(node)); +} + +ProxyListNode* +ProxyList::GetNode(int index) const +{ + ProxyListNode* pNode = SearchNode(index); + + return pNode; +} + +ProxyListNode* +ProxyList::GetNode(const LayoutItem& item) const +{ + LinkedListNode* pCurNode = GetFirstNode(); + LinkedListNode* pNextNode = pCurNode; + + while (pCurNode) + { + pNextNode = GetNextNode(*pCurNode); + ProxyListNode* pProxyNode = dynamic_cast (pCurNode); + if (pProxyNode == null) + { + return null; + } + LayoutItemProxy* pItemProxy = pProxyNode->GetItemProxy(); + if (pItemProxy == null) + { + return null; + } + + if (pItemProxy->GetItem() == &item) + { + return pProxyNode; + } + + pCurNode = pNextNode; + } + return null; +} + +int +ProxyList::GetIndex(ProxyListNode& node) const +{ + LayoutItemProxy* pItemProxy = node.GetItemProxy(); + if (pItemProxy == null) + { + SysAssert(false); + return -1; + } + return pItemProxy->GetIndex(); +} + +LayoutItemProxy* +ProxyList::GetItemProxy(const LayoutItem& item) const +{ + LinkedListNode* pCurNode = GetFirstNode(); + LinkedListNode* pNextNode = pCurNode; + + while (pCurNode) + { + pNextNode = GetNextNode(*pCurNode); + ProxyListNode* pProxyNode = dynamic_cast (pCurNode); + if (pProxyNode == null) + { + return null; + } + LayoutItemProxy* pItemProxy = pProxyNode->GetItemProxy(); + if (pItemProxy == null) + { + return null; + } + + if (pItemProxy->GetItem() == &item) + { + return pItemProxy; + } + + pCurNode = pNextNode; + } + return null; +} + +ProxyListNode* +ProxyList::SearchNode(int index) const +{ + ProxyListNode* pCurNode = GetFirstNode(); + ProxyListNode* pNextNode = pCurNode; + + while (pCurNode) + { + pNextNode = GetNextNode(*pCurNode); + LayoutItemProxy* pItemProxy = pCurNode->GetItemProxy(); + if (pItemProxy == null) + { + return null; + } + + if (pItemProxy->GetIndex() == index) + { + return pCurNode; + } + + pCurNode = pNextNode; + } + return null; +} + +ProxyListNode* +ProxyList::SearchNode(const LayoutItemProxy& itemProxy) const +{ + ProxyListNode* pCurNode = GetFirstNode(); + ProxyListNode* pNextNode = pCurNode; + + while (pCurNode) + { + pNextNode = GetNextNode(*pCurNode); + LayoutItemProxy* pCurItemProxy = pCurNode->GetItemProxy(); + if (pCurItemProxy == null) + { + return null; + } + + if (pCurItemProxy == &itemProxy) + { + return pCurNode; + } + + pCurNode = pNextNode; + } + return null; +} + +void +ProxyList::RefreshIndex(void) +{ + ProxyListNode* pCurNode = GetFirstNode(); + ProxyListNode* pNextNode = pCurNode; + + int bakLastIndex = __lastIndex; + __lastIndex = -1; + + while (pCurNode) + { + pNextNode = GetNextNode(*pCurNode); + LayoutItemProxy* pCurItemProxy = pCurNode->GetItemProxy(); + + pCurItemProxy->SetIndex(++__lastIndex); + + pCurNode = pNextNode; + } + + SysAssert(bakLastIndex == __lastIndex); +} + +ProxyListNode* +ProxyList::AddNode(LayoutItemProxy& addProxy) +{ + if (SearchNode(addProxy) != null) + { + SysLog(NID_UI, "SearchNode() is failed."); + return null; + } + ProxyListNode* pAddNode = new (std::nothrow) ProxyListNode(); + SysTryReturn(NID_UI, pAddNode != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to add to ProxyList."); + + pAddNode->Create(addProxy); + + if (OnAddNode(*pAddNode) != E_SUCCESS) + { + SysLog(NID_UI, "OnAddNode() is failed."); + delete pAddNode; + return null; + } + if (InsertIntoLeft(*_pEndNode, *pAddNode) != E_SUCCESS) + { + SysLog(NID_UI, "InsertIntoLeft() is failed."); + delete pAddNode; + return null; + } + + pAddNode->GetItemProxy()->SetIndex(++__lastIndex); + + return pAddNode; +} + +result +ProxyList::RemoveNode(LinkedListNode& removeNode) +{ + ProxyListNode* pProxyNode = dynamic_cast (&removeNode); + result re = E_SYSTEM; + re = OnRemoveNode(*pProxyNode); + if (re != E_SUCCESS) + { + SysLog(NID_UI, "OnRemoveNode() is failed."); + SysAssert(false); + return re; + } + + re = LinkedList::RemoveNode(removeNode); + if (re != E_SUCCESS) + { + SysLog(NID_UI, "RemoveNode() is failed."); + } + + __lastIndex--; + + return re; +} + +result +ProxyList::RemoveNode(int index) +{ + ProxyListNode* pRemoveNode = SearchNode(index); + + result re = E_SYSTEM; + re = RemoveNode(*pRemoveNode); + + return re; +} + +result +ProxyList::RemoveNode(LayoutItemProxy& removeItem) +{ + ProxyListNode* pRemoveNode = SearchNode(removeItem); + + return RemoveNode(*pRemoveNode); + //int index = GetIndex(*removeNode); + + //return RemoveNode(index); +} + +result +ProxyList::OnAddNode(ProxyListNode& addNode) +{ + return E_SUCCESS; +} + +result +ProxyList::OnRemoveNode(ProxyListNode& removeNode) +{ + return E_SUCCESS; +} + +int +ProxyList::GetNodeCount(void) const +{ + return __lastIndex + 1; +} + +void +ProxyList::RemoveAllNode(void) +{ + ProxyListNode* pCurNode = GetFirstNode(); + ProxyListNode* pNextNode = pCurNode; + LayoutItemProxy* pItemProxy = null; + + while (pCurNode != null) + { + pNextNode = GetNextNode(*pCurNode); + pItemProxy = pCurNode->GetItemProxy(); + SysAssert(pItemProxy != null); + pItemProxy->SetParentContainer(null); + delete pItemProxy; + + if (RemoveNode(*pCurNode) != E_SUCCESS) + { + SysAssert(false); + } + pCurNode = pNextNode; + } +} + +// +// Absolute layout +// +AbsoluteProxyList::AbsoluteProxyList(void) +{ +} + +AbsoluteProxyList::~AbsoluteProxyList(void) +{ + RemoveAllNode(); +} + +result +AbsoluteProxyList::OnAddNode(ProxyListNode& addNode) +{ + return E_SUCCESS; +} + +result +AbsoluteProxyList::OnRemoveNode(ProxyListNode& removeNode) +{ + return E_SUCCESS; +} + +// +// Relative layout +// +RelativeProxyList::RelativeProxyList() + : __pRelativeLayout(null) +{ +} + +RelativeProxyList::~RelativeProxyList() +{ + RemoveAllNode(); +} + +result +RelativeProxyList::OnAddNode(ProxyListNode& addNode) +{ + RelativeItemInfo* pItemInfo = new (std::nothrow) RelativeItemInfo(); + if (pItemInfo == null) + { + return E_OUT_OF_MEMORY; + } + + addNode.SetItemInfo(pItemInfo); + + return E_SUCCESS; +} + +result +RelativeProxyList::OnRemoveNode(ProxyListNode& removeNode) +{ + RelativeItemInfo* pItemInfo = dynamic_cast (removeNode.GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_ARG; + } + ProxyListNode* pCurNode = GetFirstNode(); + while (pCurNode != null) + { + __pRelativeLayout->DeleteTargetInfo(*pCurNode, removeNode); + pCurNode = GetNextNode(*pCurNode); + } + delete pItemInfo; + removeNode.SetItemInfo(null); + + return E_SUCCESS; +} + +int +RelativeProxyList::GetReferenceCount(ProxyListNode& node) const +{ + RelativeItemInfo* pItemInfo = dynamic_cast (node.GetItemInfo()); + if (pItemInfo == null) + { + return 0; + } + + return pItemInfo->__refCount; +} + +void +RelativeProxyList::SetRelativeLayout(RelativeLayout* pLayout) +{ + __pRelativeLayout = pLayout; +} + +// +// Table layout +// +TableProxyList::TableProxyList() +{ +} + +TableProxyList::~TableProxyList() +{ + RemoveAllNode(); +} + +result +TableProxyList::OnAddNode(ProxyListNode& addNode) +{ + TableItemInfo* pItemInfo = new (std::nothrow) TableItemInfo(); + if (pItemInfo == null) + { + return E_OUT_OF_MEMORY; + } + addNode.SetItemInfo(pItemInfo); + + return E_SUCCESS; +} + +result +TableProxyList::OnRemoveNode(ProxyListNode& removeNode) +{ + TableItemInfo* pItemInfo = dynamic_cast (removeNode.GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + + delete pItemInfo; + removeNode.SetItemInfo(null); + + return E_SUCCESS; +} + +// +// Linear layout +// +LinearProxyList::LinearProxyList(void) +{ +} + +LinearProxyList::~LinearProxyList(void) +{ + RemoveAllNode(); +} + +result +LinearProxyList::OnAddNode(ProxyListNode& addNode) +{ + LinearItemInfo* pItemInfo = new (std::nothrow) LinearItemInfo(); + if (pItemInfo == null) + { + return E_OUT_OF_MEMORY; + } + addNode.SetItemInfo(pItemInfo); + + return E_SUCCESS; +} + +result +LinearProxyList::OnRemoveNode(ProxyListNode& removeNode) +{ + LinearItemInfo* pItemInfo = dynamic_cast (removeNode.GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + delete pItemInfo; + + return E_SUCCESS; +} + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutProxyList.h b/src/ui/layout/FUi_LayoutProxyList.h new file mode 100644 index 0000000..47ed656 --- /dev/null +++ b/src/ui/layout/FUi_LayoutProxyList.h @@ -0,0 +1,165 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutProxyList.h + * @brief This is the header file for ProxyList class. + * + * This header file contains the declaration of ProxyList class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_PROXY_LIST_H_ +#define _FUI_INTERNAL_LAYOUT_PROXY_LIST_H_ + +#include "FUi_LayoutLinkedList.h" +#include "FUi_LayoutProxyListNode.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +class LayoutItem; +class AbsoluteLayout; +class RelativeLayout; +class TableLayout; +class LinearLayout; + +// Super class +class ProxyList + : public LinkedList +{ +public: + virtual ~ProxyList(void); + + ProxyListNode* GetFirstNode(void) const; + ProxyListNode* GetLastNode(void) const; + + ProxyListNode* GetNextNode(const LinkedListNode& node) const; + ProxyListNode* GetPrevNode(const LinkedListNode& node) const; + + int GetIndex(ProxyListNode& pnode) const; + ProxyListNode* GetNode(int index) const; + ProxyListNode* GetNode(const LayoutItem& item) const; + + int GetNodeCount(void) const; + + LayoutItemProxy* GetItemProxy(const LayoutItem& item) const; + + void RefreshIndex(void); + + ProxyListNode* AddNode(LayoutItemProxy& addProxy); + virtual result RemoveNode(LinkedListNode& removeNode); + result RemoveNode(LayoutItemProxy& removeItem); + result RemoveNode(int index); + + virtual result OnAddNode(ProxyListNode& addNode); + virtual result OnRemoveNode(ProxyListNode& removeNode); + + ProxyListNode* SearchNode(int index) const; + ProxyListNode* SearchNode(const LayoutItemProxy& item) const; + +protected: + ProxyList(void); + + void RemoveAllNode(void); + +private: + ProxyList(const ProxyList&); + ProxyList& operator =(const ProxyList&); + +private: + int __lastIndex; + + friend class Layout; +}; // ProxyList + +// Absolute layout +class AbsoluteProxyList + : public ProxyList +{ +public: + virtual result OnAddNode(ProxyListNode& addNode); + virtual result OnRemoveNode(ProxyListNode& removeNode); + +protected: + AbsoluteProxyList(void); + virtual ~AbsoluteProxyList(void); + +private: + AbsoluteProxyList(const AbsoluteProxyList&); + AbsoluteProxyList& operator =(const AbsoluteProxyList&); + + friend class AbsoluteLayout; +}; // AbsoluteProxyList + +// Relative layout +class RelativeProxyList + : public ProxyList +{ +public: + virtual result OnAddNode(ProxyListNode& pAddNode); + virtual result OnRemoveNode(ProxyListNode& pRemoveNode); + void SetRelativeLayout(RelativeLayout* pLayout); + int GetReferenceCount(ProxyListNode& pNode) const; + +private: + RelativeProxyList(void); + virtual ~RelativeProxyList(void); + +private: + RelativeLayout* __pRelativeLayout; + + friend class RelativeLayout; +}; // RelativeProxyList + +// Table layout +class TableProxyList + : public ProxyList +{ +public: + virtual result OnAddNode(ProxyListNode& addNode); + virtual result OnRemoveNode(ProxyListNode& removeNode); + +private: + TableProxyList(void); + virtual ~TableProxyList(void); + + friend class TableLayout; +}; // TableProxyList + +// Linear layout +class LinearProxyList + : public ProxyList +{ +public: + virtual result OnAddNode(ProxyListNode& addNode); + virtual result OnRemoveNode(ProxyListNode& removeNode); + +protected: + LinearProxyList(void); + virtual ~LinearProxyList(void); + +private: + LinearProxyList(const LinearProxyList&); + LinearProxyList& operator =(const LinearProxyList&); + + friend class LinearLayout; +}; // LinearProxyList + +}}} //Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_PROXY_LIST_H_ diff --git a/src/ui/layout/FUi_LayoutProxyListNode.cpp b/src/ui/layout/FUi_LayoutProxyListNode.cpp new file mode 100644 index 0000000..52a64f5 --- /dev/null +++ b/src/ui/layout/FUi_LayoutProxyListNode.cpp @@ -0,0 +1,64 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutProxyListNode.cpp + * @brief This is the implementation file for ProxyListNode class. + * + * This file contains the implementation of ProxyListNode class. + */ + +#include "FUi_LayoutProxyListNode.h" +#include "FUi_LayoutLayoutItemProxy.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +ProxyListNode::ProxyListNode(void) + : __pItemProxy(null) + , __pItemInfo(null) +{ +} + +ProxyListNode::~ProxyListNode(void) +{ +} + +void +ProxyListNode::Create(LayoutItemProxy& pItemProxy) +{ + __pItemProxy = &pItemProxy; +} + +void +ProxyListNode::SetItemInfo(LayoutItemInfo* pItemInfo) +{ + __pItemInfo = pItemInfo; +} + +LayoutItemInfo* +ProxyListNode::GetItemInfo(void) const +{ + return __pItemInfo; +} + +LayoutItemProxy* +ProxyListNode::GetItemProxy(void) const +{ + return __pItemProxy; +} + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutProxyListNode.h b/src/ui/layout/FUi_LayoutProxyListNode.h new file mode 100644 index 0000000..2cfdd03 --- /dev/null +++ b/src/ui/layout/FUi_LayoutProxyListNode.h @@ -0,0 +1,70 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutProxyListNode.h + * @brief This is the header file for ProxyListNode class. + * + * This header file contains the declaration of ProxyListNode class. + */ + +#pragma once + +#ifndef _FUI_INTERNAL_LAYOUT_PROXY_LIST_NODE_H_ +#define _FUI_INTERNAL_LAYOUT_PROXY_LIST_NODE_H_ + +#include +#include "FUi_LayoutLinkedListNode.h" + +namespace Tizen +{ +namespace Ui +{ +namespace _Layout +{ + +class LayoutItemProxy; +class LayoutItemInfo; + +class ProxyListNode + : public LinkedListNode +{ +public: + void SetItemInfo(LayoutItemInfo* pItemInfo); + LayoutItemProxy* GetItemProxy(void) const; + LayoutItemInfo* GetItemInfo(void) const; + +protected: + ProxyListNode(void); + virtual ~ProxyListNode(void); + + void Create(LayoutItemProxy& pProxy); + +private: + ProxyListNode(const ProxyListNode&); + ProxyListNode& operator =(const ProxyListNode&); + +// property +private: + LayoutItemProxy* __pItemProxy; + LayoutItemInfo* __pItemInfo; + + friend class ProxyList; +}; // ProxyListNode + +}}} //Tizen::Ui::_Layout + +#endif // _FUI_INTERNAL_LAYOUT_PROXY_LIST_NODE_H_ diff --git a/src/ui/layout/FUi_LayoutRelativeLayout.cpp b/src/ui/layout/FUi_LayoutRelativeLayout.cpp new file mode 100644 index 0000000..3a2bc20 --- /dev/null +++ b/src/ui/layout/FUi_LayoutRelativeLayout.cpp @@ -0,0 +1,926 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutRelativeLayout.cpp + * @brief This is the implementation file for RelativeLayout class. + * + * This file contains the implementation of RelativeLayout class. + */ + +#include +#include +#include +#include "FUi_LayoutRelativeLayout.h" +#include "FUi_LayoutLayoutItemProxy.h" +#include "FUi_LayoutProxyList.h" +#include "FUi_LayoutLayoutItemInfo.h" + +namespace Tizen { namespace Ui { namespace _Layout +{ + +// relative layout +RelativeLayout::RelativeLayout() + : __pTargetParent(reinterpret_cast (0xffff)) +{ + RelativeProxyList* pRelativeProxyList = new (std::nothrow) RelativeProxyList(); + SysTryReturnVoidResult(NID_UI, pRelativeProxyList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + SetItemList(pRelativeProxyList); + + pRelativeProxyList->SetRelativeLayout(this); +} + +RelativeLayout::~RelativeLayout() +{ +} + +RelativeLayout* +RelativeLayout::CreateRelativeLayoutN() +{ + RelativeLayout* pLayout = new (std::nothrow) RelativeLayout(); + SysTryReturn(NID_UI, pLayout != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Relative layout core allocation failure."); + if (GetLastResult() != E_SUCCESS) + { + delete pLayout; + return null; + } + + return pLayout; +} + +result +RelativeLayout::SetRelation(LayoutItem& item, const RelativeLayoutEdge itemEdge, LayoutItem* pTarget, + const RelativeLayoutEdge targetEdge) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + ProxyListNode* pSourceNode = pProxyList->GetNode(item); + ProxyListNode* pTargetNode = pProxyList->GetNode(*pTarget); + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + + if (pContainerProxy == null) + { + return E_INVALID_STATE; + } + + if (pSourceNode == null || + (pTarget != null && pTarget != pContainerProxy->GetItem() && pTargetNode == null)) + { + return E_INVALID_ARG; + } + + if (itemEdge == EDGE_ALL) + { + return E_INVALID_ARG; + } + + if (itemEdge == EDGE_NONE) + { + for (int i = EDGE_LEFT; i < EDGE_ALL; i++) + { + UnsetRelation(item, static_cast (i)); + } + + SetUpdateState(true); + SetPartialUpdateFlag(true); + return E_SUCCESS; + } + + if (itemEdge == EDGE_HCENTER || itemEdge == EDGE_VCENTER) + { + if (pTarget != null || targetEdge != EDGE_NONE) + { + return E_INVALID_ARG; + } + } + + // release to relation if exist relation + result re = E_SYSTEM; + if (GetRelation(item, itemEdge, null) != null) + { + re = UnsetRelation(item, itemEdge); + if (re != E_SUCCESS) + { + return re; + } + } + + int rollBackRefCount = 0; + RelativeItemInfo* pTargetItemInfo = null; + if (pTargetNode != null) + { + pTargetItemInfo = dynamic_cast (pTargetNode->GetItemInfo()); + if (pTargetItemInfo == null) + { + return E_INVALID_STATE; + } + rollBackRefCount = pTargetItemInfo->__refCount; + } + re = SetAlignment(*pSourceNode, itemEdge, pTargetNode, targetEdge); + if (re != E_SUCCESS) + { + return re; + } + + if (pTargetItemInfo != null && IncreaseReferenceCount(*pSourceNode) != E_SUCCESS) + { + re = UnsetAlignment(*pSourceNode, itemEdge, null); + if (re != E_SUCCESS) + { + SysAssert(false); + } + DecreaseReferenceCount(*pSourceNode, *pTargetNode); + pTargetItemInfo->__refCount = rollBackRefCount; + re = IncreaseReferenceCount(*pTargetNode); + if (re != E_SUCCESS) + { + SysAssert(false); + } + + ProxyListNode* pCurNode = pProxyList->GetFirstNode(); + while (pCurNode) + { + re = IncreaseReferenceCount(*pCurNode); + if (re != E_SUCCESS) + { + SysAssert(false); + } + pCurNode = pProxyList->GetNextNode(*pCurNode); + } + + return E_SYSTEM; + } + + SetUpdateState(true); + SetPartialUpdateFlag(true); + return E_SUCCESS; +} + +result +RelativeLayout::UnsetRelation(LayoutItem& item, const RelativeLayoutEdge itemEdge) +{ + RelativeProxyList* pRelativeProxyList = GetRelativeProxyList(); + SysTryReturn(NID_UI, pRelativeProxyList, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] RelativeProxyList is invalid."); + + ProxyListNode* pItemNode = pRelativeProxyList->GetNode(item); + if (pItemNode == null) + { + return E_INVALID_ARG; + } + + if (itemEdge == EDGE_NONE || itemEdge == EDGE_ALL) + { + return E_INVALID_ARG; + } + + result re = E_SYSTEM; + ProxyListNode* pTargetNode = null; + LayoutItemProxy* pTargetProxy = null; + re = UnsetAlignment(*pItemNode, itemEdge, &pTargetProxy); + if (re != E_SUCCESS) + { + return re; + } + if (pTargetProxy != null) + { + pTargetNode = pRelativeProxyList->GetNode(*(pTargetProxy->GetItem())); + if (pTargetNode == null) + { + return E_INVALID_STATE; + } + } + + if (pTargetNode == null) + { + return E_SUCCESS; + } + + // Refcount of all nodes is set to 0. + DecreaseReferenceCount(*pItemNode, *pTargetNode); + + // find another node to refer to pTargetNode. + ProxyListNode* pCurNode = pRelativeProxyList->GetFirstNode(); + int maxRefCount = 0; + int nodeIndex = 0; + while (pCurNode != null) + { + for (int i = EDGE_LEFT; i <= EDGE_BOTTOM; i++) + { + LayoutItemProxy* pTargetProxy = GetAlignment(*pCurNode, static_cast (i)); + if (pTargetProxy != null && pTargetProxy != GetContainerProxy()) + { + ProxyListNode* pCurTargetNode = pRelativeProxyList->GetNode(*(pTargetProxy->GetItem())); + if (pTargetNode == pCurTargetNode) + { + if (maxRefCount < pRelativeProxyList->GetReferenceCount(*pCurNode)) + { + maxRefCount = pRelativeProxyList->GetReferenceCount(*pCurNode); + nodeIndex = pRelativeProxyList->GetIndex(*pCurNode); + } + } + } + } + pCurNode = pRelativeProxyList->GetNextNode(*pCurNode); + } + + if (nodeIndex != 0) + { + pCurNode = pRelativeProxyList->GetNode(nodeIndex); + IncreaseReference(*pTargetNode, *pCurNode); + } + + // Nodes Recalculation + re = IncreaseReferenceCount(*pTargetNode); + if (re != E_SUCCESS) + { + return re; + } + + return E_SUCCESS; +} + +LayoutItem* +RelativeLayout::GetRelation(LayoutItem& item, const RelativeLayoutEdge itemEdge, RelativeLayoutEdge* pTargetEdge) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + ProxyListNode* pNode = pProxyList->GetNode(item); + + if (pNode != null) + { + LayoutItemProxy* pItemProxy = GetAlignment(*pNode, itemEdge, pTargetEdge); + if (pItemProxy) + { + return pItemProxy->GetItem(); + } + } + + return null; +} + +result +RelativeLayout::OnLayout(int width, int height, bool updateLayouting) +{ + result re = E_SUCCESS; + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + if (pContainerProxy == null) + { + return E_INVALID_STATE; + } + + LayoutRect windowRect = {0, 0, width, height}; + LayoutRect clientRect; + pContainerProxy->ConvertWindowToClientBounds(windowRect, clientRect); + + LayoutRect layoutRect = GetLayoutRect(); + clientRect.x = layoutRect.x; + clientRect.y = layoutRect.y; + + int correctionWidth = windowRect.w - clientRect.w; + int correctionHeight = windowRect.h - clientRect.h; + + + LayoutMatchMode widthMatchMode = pContainerProxy->GetItemWidthMatchMode(); + LayoutMatchMode heightMatchMode = pContainerProxy->GetItemHeightMatchMode(); + + SetLayoutRect(clientRect); + + int childrenMaxPosX = 0; + int childrenMaxPosY = 0; + LayoutRect childRect = {0, 0, 0, 0}; + + ProxyListNode* pCurNode = pProxyList->GetFirstNode(); + + while (pCurNode != null) + { + re = CalculatePosition(*pCurNode); + re = CalculateCenter(*pCurNode, re == E_SUCCESS); + if (re != E_SUCCESS) + { + return re; + } + + LayoutItemProxy* pItemProxy = pCurNode->GetItemProxy(); + if (pItemProxy == null) + { + return E_INVALID_STATE; + } + + pItemProxy->GetItemWindowRect(childRect); + + if (childrenMaxPosX < childRect.x + childRect.w) + { + childrenMaxPosX = childRect.x + childRect.w; + if (GetAlignment(*pCurNode, EDGE_RIGHT) != null) + { + ItemMargin margin = pItemProxy->GetItemMargin(); + childrenMaxPosX += margin.right; + } + } + + if (childrenMaxPosY < childRect.y + childRect.h) + { + childrenMaxPosY = childRect.y + childRect.h; + if (GetAlignment(*pCurNode, EDGE_BOTTOM) != null) + { + ItemMargin margin = pItemProxy->GetItemMargin(); + childrenMaxPosY += margin.bottom; + } + } + + pCurNode = pProxyList->GetNextNode(*pCurNode); + } + + if (widthMatchMode == WRAP_CONTENT) + { + clientRect.w = childrenMaxPosX + correctionWidth; + } + else + { + clientRect.w += correctionWidth; + } + + if (heightMatchMode == WRAP_CONTENT) + { + clientRect.h = childrenMaxPosY + correctionHeight; + } + else + { + clientRect.h += correctionHeight; + } + + SetLayoutRect(clientRect); + LayoutRect containerRect; + pContainerProxy->GetItemWindowRect(containerRect); + clientRect.x = containerRect.x; + clientRect.y = containerRect.y; + if (windowRect.w != clientRect.w || windowRect.h != clientRect.h) + { + if (updateLayouting) + { + pContainerProxy->SetItemWindowRect(clientRect); + } + // Recalculate + pCurNode = pProxyList->GetFirstNode(); + while (pCurNode) + { + re = CalculatePosition(*pCurNode); + re = CalculateCenter(*pCurNode, re == E_SUCCESS); + pCurNode = pProxyList->GetNextNode(*pCurNode); + } + } + + return re; +} + +result +RelativeLayout::IncreaseReferenceCount(ProxyListNode& node) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + ProxyListNode* pTargetNode = null; + result re = E_SUCCESS; + for (int i = EDGE_LEFT; i < EDGE_ALL; i++) + { + LayoutItemProxy* pProxy = GetAlignment(node, static_cast (i)); + if (pProxy == null || pProxy == GetContainerProxy()) + { + continue; + } + pTargetNode = pProxyList->GetNode(*(pProxy->GetItem())); + if (pTargetNode != null) + { + re = IncreaseReference(*pTargetNode, node); + if (re == E_SUCCESS) + { + re = IncreaseReferenceCount(*pTargetNode); + if (re != E_SUCCESS) + { + return re; + } + } + else + { + return re; + } + } + } + // Order of nodes is recalculate + return AlignItemNodeMaxRefMove(); +} + +void +RelativeLayout::DecreaseReferenceCount(ProxyListNode& node, ProxyListNode& pTargetNode) +{ + ProxyListNode* pTargetTargetNode = null; + for (int i = EDGE_LEFT; i <= EDGE_BOTTOM; i++) + { + pTargetTargetNode = GetTargetNode(pTargetNode, static_cast (i)); + if (pTargetTargetNode != null) + { + DecreaseReferenceCount(pTargetNode, *pTargetTargetNode); + } + } + //if (pTargetNode != null) + //{ + SetZeroReference(pTargetNode, node); + //} +} + +result +RelativeLayout::AlignItemNodeMaxRefMove() +{ + result r = E_SUCCESS; + + RelativeProxyList* pRelativeProxyList = GetRelativeProxyList(); + SysTryReturn(NID_UI, pRelativeProxyList, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] RelativeProxyList is invalid."); + + ProxyListNode* pCurNode = pRelativeProxyList->GetFirstNode(); + ProxyListNode* pNextNode = pCurNode; + int maxRefCount = 0; + + while (pCurNode != null) + { + pNextNode = pRelativeProxyList->GetNextNode(*pCurNode); + maxRefCount = pRelativeProxyList->GetReferenceCount(*pCurNode); + + if (pNextNode != null && maxRefCount < pRelativeProxyList->GetReferenceCount(*pNextNode)) + { + ProxyListNode* pMoveNode = pNextNode; + if (pRelativeProxyList->DetachNode(*pMoveNode) != E_SUCCESS) + { + break; + } + + maxRefCount = pRelativeProxyList->GetReferenceCount(*pMoveNode); + + pCurNode = pRelativeProxyList->GetFirstNode(); + while (pRelativeProxyList->GetReferenceCount(*pCurNode) >= maxRefCount) + { + pCurNode = pRelativeProxyList->GetNextNode(*pCurNode); + } + pRelativeProxyList->InsertIntoLeft(*pCurNode, *pMoveNode); + return E_SUCCESS; + } + else + { + pCurNode = pRelativeProxyList->GetNextNode(*pCurNode); + } + } + + return r; +} + +result +RelativeLayout::DeleteTargetInfo(ProxyListNode& targetNode, ProxyListNode& deleteNode) +{ + RelativeItemInfo* pItemInfo = dynamic_cast (targetNode.GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + for (int i = EDGE_LEFT; i < EDGE_ALL; i++) + { + if (pItemInfo->__pTarget[i] == deleteNode.GetItemProxy()) + { + UnsetRelation(*(targetNode.GetItemProxy()->GetItem()), static_cast (i)); + } + } + return E_SUCCESS; +} + +result +RelativeLayout::CalculatePosition(ProxyListNode& curNode) +{ + RelativeItemInfo* pCurItemInfo = null; + LayoutItemProxy* pCurProxy = null; + ItemMargin curItemMargin = {0, 0, 0, 0}; + LayoutRect curItemRect = {0, 0, 0, 0}; + LayoutPoint targetPosition = {0, 0}; + result re = E_SYSTEM; + int relatedRight = 0; + int relatedBottom = 0; + + pCurItemInfo = dynamic_cast (curNode.GetItemInfo()); + pCurProxy = curNode.GetItemProxy(); + + if (pCurItemInfo == null || pCurProxy == null) + { + return E_INVALID_STATE; + } + + curItemRect = pCurProxy->GetItemBaseRect(); + GetItemMargin(*(pCurProxy->GetItem()), curItemMargin); + + if (pCurItemInfo->__pTarget[EDGE_LEFT] != null) + { + re = GetTargetPosition(pCurItemInfo->__pTarget[EDGE_LEFT], pCurItemInfo->__targetEdge[EDGE_LEFT], targetPosition); + if (re != E_SUCCESS) + { + return re; + } + curItemRect.x = targetPosition.x + curItemMargin.left; + } + + if (pCurItemInfo->__pTarget[EDGE_TOP] != null) + { + re = GetTargetPosition(pCurItemInfo->__pTarget[EDGE_TOP], pCurItemInfo->__targetEdge[EDGE_TOP], targetPosition); + if (re != E_SUCCESS) + { + return re; + } + curItemRect.y = targetPosition.y + curItemMargin.top; + } + + if (pCurItemInfo->__pTarget[EDGE_RIGHT] != null) + { + re = GetTargetPosition(pCurItemInfo->__pTarget[EDGE_RIGHT], pCurItemInfo->__targetEdge[EDGE_RIGHT], targetPosition); + if (re != E_SUCCESS) + { + return re; + } + + if (pCurItemInfo->__pTarget[EDGE_LEFT] != null) + { + curItemRect.w = targetPosition.x - curItemRect.x - curItemMargin.right; + } + curItemRect.x = targetPosition.x - curItemMargin.right - curItemRect.w; + relatedRight = curItemRect.x + curItemRect.w; + } + + if (pCurItemInfo->__pTarget[EDGE_BOTTOM] != null) + { + re = GetTargetPosition(pCurItemInfo->__pTarget[EDGE_BOTTOM], pCurItemInfo->__targetEdge[EDGE_BOTTOM], targetPosition); + if (re != E_SUCCESS) + { + return re; + } + + if (pCurItemInfo->__pTarget[EDGE_TOP] != null) + { + curItemRect.h = targetPosition.y - curItemRect.y - curItemMargin.bottom; + } + curItemRect.y = targetPosition.y - curItemMargin.bottom - curItemRect.h; + relatedBottom = curItemRect.y + curItemRect.h; + } + + re = pCurProxy->Measure(curItemRect.w, curItemRect.h); + if (re != E_SUCCESS) + { + return re; + } + pCurProxy->GetMeasuredSize(curItemRect.w, curItemRect.h); + + if (pCurItemInfo->__pTarget[EDGE_LEFT] == null && pCurItemInfo->__pTarget[EDGE_RIGHT] != null) + { + curItemRect.x = relatedRight - curItemRect.w; + } + + if (pCurItemInfo->__pTarget[EDGE_TOP] == null && pCurItemInfo->__pTarget[EDGE_BOTTOM] != null) + { + curItemRect.y = relatedBottom - curItemRect.h; + } + + re = pCurProxy->SetItemWindowRect(curItemRect); + if (re != E_SUCCESS) + { + return re; + } + + return re; +} + +result +RelativeLayout::CalculateCenter(ProxyListNode& curNode, bool calcPosition) +{ + LayoutRect targetRect; + RelativeItemInfo* pCurItemInfo = null; + LayoutItemProxy* pCurProxy = null; + LayoutRect curItemRect = {0, 0, 0, 0}; + result re = E_SYSTEM; + + pCurItemInfo = dynamic_cast (curNode.GetItemInfo()); + pCurProxy = curNode.GetItemProxy(); + + if (pCurItemInfo == null || pCurProxy == null) + { + return E_INVALID_STATE; + } + + if (pCurItemInfo->__pTarget[EDGE_HCENTER] == null && pCurItemInfo->__pTarget[EDGE_VCENTER] == null) + { + return E_SUCCESS; + } + + if (calcPosition) + { + pCurProxy->GetItemWindowRect(curItemRect); + } + else + { + curItemRect = pCurProxy->GetItemBaseRect(); + } + + re = pCurProxy->Measure(curItemRect.w, curItemRect.h); + if (re != E_SUCCESS) + { + return re; + } + pCurProxy->GetMeasuredSize(curItemRect.w, curItemRect.h); + + if (pCurItemInfo->__pTarget[EDGE_HCENTER] == __pTargetParent) + { + //targetRect = __pTarget[EDGE_HCENTER]->GetItemWindowRect(); + targetRect = GetLayoutRect(); + int targetWidth = targetRect.w; + int margin = ((targetWidth - curItemRect.w) >> 1); + curItemRect.x = margin + targetRect.x; + } + + if (pCurItemInfo->__pTarget[EDGE_VCENTER] == __pTargetParent) + { + //targetRect = __pTarget[EDGE_VCENTER]->GetItemWindowRect(); + targetRect = GetLayoutRect(); + int targetHeight = targetRect.h; + int margin = ((targetHeight - curItemRect.h) >> 1); + curItemRect.y = margin + targetRect.y; + } + + re = pCurProxy->Measure(curItemRect.w, curItemRect.h); + if (re != E_SUCCESS) + { + return re; + } + pCurProxy->GetMeasuredSize(curItemRect.w, curItemRect.h); + + re = pCurProxy->SetItemWindowRect(curItemRect); + if (re != E_SUCCESS) + { + return re; + } + + return re; +} + +bool +RelativeLayout::CheckTargetEdge(const RelativeLayoutEdge sourceEdge, const RelativeLayoutEdge targetEdge) const +{ + if (sourceEdge & 0x1) + { + if (targetEdge & 0x1) + { + return true; + } + else + { + return false; + } + } + else if (!(sourceEdge & 0x1)) + { + if (targetEdge & 0x1) + { + return false; + } + else + { + return true; + } + } + + return false; +} + +result +RelativeLayout::SetAlignment(ProxyListNode& sourceNode, const RelativeLayoutEdge sourceEdge, ProxyListNode* pTargetNode, const RelativeLayoutEdge targetEdge) +{ + //RelativeLayoutEdge realTargetEdge = const_cast(targetEdge); + RelativeLayoutEdge realTargetEdge = targetEdge; + if (realTargetEdge == EDGE_NONE) + { + realTargetEdge = sourceEdge; + } + + if (!CheckTargetEdge(sourceEdge, realTargetEdge)) + { + return E_INVALID_ARG; + } + + RelativeItemInfo* pSourceItemInfo = dynamic_cast (sourceNode.GetItemInfo()); + + if (pSourceItemInfo == null || pSourceItemInfo->__targetEdge[sourceEdge] != EDGE_NONE || pSourceItemInfo->__pTarget[sourceEdge] != null) + { + return E_INVALID_STATE; + } + + LayoutItemProxy* pTargetProxy = null; + if (pTargetNode == null) + { + pTargetProxy = const_cast (__pTargetParent); + } + else + { + pTargetProxy = pTargetNode->GetItemProxy(); + } + if (pTargetProxy == null) + { + return E_INVALID_ARG; + } + + pSourceItemInfo->__targetEdge[sourceEdge] = realTargetEdge; + pSourceItemInfo->__pTarget[sourceEdge] = pTargetProxy; + + return E_SUCCESS; +} + +result +RelativeLayout::UnsetAlignment(ProxyListNode& sourceNode, const RelativeLayoutEdge sourceEdge, LayoutItemProxy** ppTargetProxy) +{ + RelativeItemInfo* pSourceItemInfo = dynamic_cast (sourceNode.GetItemInfo()); + + if (pSourceItemInfo == null) + { + return E_INVALID_STATE; + } + + if (sourceEdge != EDGE_NONE) + { + pSourceItemInfo->__targetEdge[sourceEdge] = EDGE_NONE; + if (pSourceItemInfo->__pTarget[sourceEdge] != null) + { + if (ppTargetProxy != null) + { + if (pSourceItemInfo->__pTarget[sourceEdge] != __pTargetParent) + { + *ppTargetProxy = pSourceItemInfo->__pTarget[sourceEdge]; + } + else + { + *ppTargetProxy = null; + } + } + pSourceItemInfo->__pTarget[sourceEdge] = null; + } + else + { + return E_INVALID_STATE; + } + return E_SUCCESS; + } + + return E_SYSTEM; +} + +LayoutItemProxy* +RelativeLayout::GetAlignment(ProxyListNode& sourceNode, const RelativeLayoutEdge sourceEdge, RelativeLayoutEdge* pTargetEdge) +{ + SysTryReturn(NID_UI, sourceEdge >= EDGE_NONE, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Argument is out of range."); + SysTryReturn(NID_UI, sourceEdge <= EDGE_VCENTER, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Argument is out of range."); + RelativeItemInfo* pSourceItemInfo = dynamic_cast (sourceNode.GetItemInfo()); + + SysTryReturn(NID_UI, pSourceItemInfo, null, E_INVALID_STATE, "[E_INVALID_STATE] RelativeItemInfo is invalid."); + + if (pTargetEdge != null) + { + *pTargetEdge = pSourceItemInfo->__targetEdge[sourceEdge]; + } + + if (pSourceItemInfo->__pTarget[sourceEdge] != __pTargetParent) + { + return pSourceItemInfo->__pTarget[sourceEdge]; + } + else + { + return GetContainerProxy(); + } +} + +result +RelativeLayout::IncreaseReference(ProxyListNode& targetNode, ProxyListNode& sourceNode) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + RelativeItemInfo* pTargetItemInfo = dynamic_cast (targetNode.GetItemInfo()); + RelativeItemInfo* pSourceItemInfo = dynamic_cast (sourceNode.GetItemInfo()); + + if (pTargetItemInfo == null || pSourceItemInfo == null) + { + return E_INVALID_STATE; + } + + int refCount = pSourceItemInfo->__refCount + 1; + + if (refCount > pProxyList->GetNodeCount() - 1) + { + return E_INVALID_STATE; + } + + if (refCount > pTargetItemInfo->__refCount) + { + pTargetItemInfo->__refCount = refCount; + } + return E_SUCCESS; +} + +ProxyListNode* +RelativeLayout::GetTargetNode(ProxyListNode& node, RelativeLayoutEdge sourceEdge) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid."); + + LayoutItemProxy* pProxy = GetAlignment(node, sourceEdge); + if (pProxy == null || pProxy == GetContainerProxy()) + { + return null; + } + return pProxyList->GetNode(*(pProxy->GetItem())); +} + +result +RelativeLayout::SetZeroReference(ProxyListNode& node, ProxyListNode& baseNode) +{ + RelativeItemInfo* pTargetItemInfo = dynamic_cast (node.GetItemInfo()); + if (pTargetItemInfo == null) + { + return E_INVALID_STATE; + } + + //int refCount = ((RelativeProxyList*)_pProxyList)->GetReferenceCount(pBaseNode) + 1; + + //if (refCount == pTargetItemInfo->__refCount) + //{ + pTargetItemInfo->__refCount = 0; + //} + return E_SUCCESS; +} + +result +RelativeLayout::GetTargetPosition(LayoutItemProxy* pTargetProxy, const RelativeLayoutEdge targetEdge, LayoutPoint& targetPoint) const +{ + if (pTargetProxy == null) + { + return E_INVALID_ARG; + } + + LayoutRect targetRect; + if (pTargetProxy == __pTargetParent) + { + targetRect = GetLayoutRect(); + } + else + { + pTargetProxy->GetItemWindowRect(targetRect); + } + + switch (targetEdge) + { + case EDGE_LEFT: + targetPoint.x = targetRect.x; + break; + + case EDGE_TOP: + targetPoint.y = targetRect.y; + break; + + case EDGE_RIGHT: + targetPoint.x = targetRect.x + targetRect.w; + break; + + case EDGE_BOTTOM: + targetPoint.y = targetRect.y + targetRect.h; + break; + + default: + return E_SYSTEM; + } + + return E_SUCCESS; +} + +RelativeProxyList* +RelativeLayout::GetRelativeProxyList(void) +{ + return dynamic_cast (GetProxyList()); +} + +}}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutTableLayout.cpp b/src/ui/layout/FUi_LayoutTableLayout.cpp new file mode 100755 index 0000000..5c2539d --- /dev/null +++ b/src/ui/layout/FUi_LayoutTableLayout.cpp @@ -0,0 +1,2385 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_LayoutTableLayout.cpp + * @brief This is the implementation file for TableLayout class. + * + * This file contains the implementation of TableLayout class. + */ + +#include +#include +#include +#include +#include +#include "FUi_LayoutTableLayout.h" +#include "FUi_LayoutLayoutItemProxy.h" +#include "FUi_LayoutProxyList.h" +#include "FUi_LayoutLayoutItemInfo.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace _Layout +{ + +TableLayout::TableLayout(void) + : Layout() + , __row(0) + , __column(0) + , __maxRow(0) + , __maxColumn(0) + , __shrinkRowCount(0) + , __shrinkColumnCount(0) + , __stretchRowCount(0) + , __stretchColumnCount(0) + , __rowShrinkable(false) + , __columnShrinkable(false) + , __rowStretchable(false) + , __columnStretchable(false) + , __pRowInfo(null) + , __pColInfo(null) +{ + TableProxyList* pTableProxyList = new (std::nothrow) TableProxyList(); + SysTryReturnVoidResult(NID_UI, pTableProxyList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + SetItemList(pTableProxyList); +} + +TableLayout::~TableLayout(void) +{ + __mergedCellList.RemoveAll(true); + + delete[] __pRowInfo; + delete[] __pColInfo; +} + +TableLayout* +TableLayout::CreateTableLayoutN(void) +{ + TableLayout* pLayout = new (std::nothrow) TableLayout(); + SysTryReturn(NID_UI, pLayout != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Table layout core allocation failure."); + if (GetLastResult() != E_SUCCESS) + { + delete pLayout; + return null; + } + + return pLayout; +} + +result +TableLayout::CreateTable(int row, int column, int spacing) +{ + if (row < 1 || column < 1) + { + SysTryReturn(NID_UI, false, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Negative argument : row(%d), column(%d)", row, + column); + } + + __row = row; + __column = column; + __maxRow = row; + __maxColumn = column; + + __pColInfo = new (std::nothrow) ColumnInfo[__column]; + SysTryReturn(NID_UI, __pColInfo != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + memset(__pColInfo, 0, sizeof(ColumnInfo) * __column); + + for (int i = 0; i < __column; i++) + { + __pColInfo[i].widthSpacing = spacing; + } + + __pRowInfo = new (std::nothrow) RowInfo[__row]; + SysTryReturn(NID_UI, __pRowInfo != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + memset(__pRowInfo, 0, sizeof(RowInfo) * __row); + + for (int i = 0; i < __row; i++) + { + __pRowInfo[i].heightSpacing = spacing; + } + + return E_SUCCESS; +} + +result +TableLayout::CalculateSize() +{ + if (__row < 1 || __column < 1) + { + return E_SUCCESS; + } + + int nextPosX = 0; //-__pColInfo[0].widthSpacing + m_nPosX; + int nextPosY = 0; //-__pRowInfo[0].heightSpacing + m_nPosY; + + __shrinkRowCount = 0; + __shrinkColumnCount = 0; + __stretchRowCount = 0; + __stretchColumnCount = 0; + + for (int j = 0; j < __column; j++) + { + __pColInfo[j].x = 0; + __pColInfo[j].width = 0; + __pColInfo[j].maxWidth = 0; + __pColInfo[j].mergedWidth = 0; + } + + ProxyListNode* pCurNode = null; + TableItemInfo* pItemInfo = null; + LayoutItemProxy* pItemProxy = null; + + for (int i = 0; i < __row; i++) + { + __pRowInfo[i].y = 0; + __pRowInfo[i].height = 0; + __pRowInfo[i].maxHeight = 0; + __pRowInfo[i].mergedHeight = 0; + + for (int j = 0; j < __column; j++) + { + pCurNode = GetNode(i, j); + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + + pItemProxy = pCurNode->GetItemProxy(); + if (pItemInfo == null || pItemProxy == null) + { + return E_INVALID_STATE; + } + + if (pItemInfo->__enable) + { + pItemProxy->GetMinSize(pItemInfo->__minSize); + pItemProxy->GetMaxSize(pItemInfo->__maxSize); + } + + LayoutRect rect = pItemProxy->GetItemBaseRect(); + + result r = pItemProxy->Measure(rect.w, rect.h); + if (r != E_SUCCESS) + { + return r; + } + pItemProxy->GetMeasuredSize(rect.w, rect.h); + + ItemMargin margin = pItemProxy->GetItemMargin(); + ItemAlign itemAlign = pItemProxy->GetItemAlignment(); + if (itemAlign.HAlign == ITEM_HORIZONTAL_ALIGN_LEFT || itemAlign.HAlign == ITEM_HORIZONTAL_ALIGN_LEFT_RIGHT) + { + rect.w += margin.left; + } + if (itemAlign.HAlign == ITEM_HORIZONTAL_ALIGN_RIGHT || itemAlign.HAlign == ITEM_HORIZONTAL_ALIGN_LEFT_RIGHT) + { + rect.w += margin.right; + } + if (itemAlign.VAlign == ITEM_VERTICAL_ALIGN_TOP || itemAlign.VAlign == ITEM_VERTICAL_ALIGN_TOP_BOTTOM) + { + rect.h += margin.top; + } + if (itemAlign.VAlign == ITEM_VERTICAL_ALIGN_BOTTOM || itemAlign.VAlign == ITEM_VERTICAL_ALIGN_TOP_BOTTOM) + { + rect.h += margin.bottom; + } + + if (!pItemInfo->__merged) + { + if (__pColInfo[j].maxWidth < rect.w && !__pRowInfo[i].rowCollapsed) + { + __pColInfo[j].maxWidth = rect.w; + } + + if (__pRowInfo[i].maxHeight < rect.h && !__pColInfo[j].columnCollapsed) + { + __pRowInfo[i].maxHeight = rect.h; + } + } + else + { + if (__pColInfo[j].mergedWidth < rect.w) + { + __pColInfo[j].mergedWidth = rect.w; + } + if (__pRowInfo[i].mergedHeight < rect.h) + { + __pRowInfo[i].mergedHeight = rect.h; + } + } + } + } + + if (!__pRowInfo[i].rowCollapsed) + { + if (__pRowInfo[i].heightStretchable) + { + __stretchRowCount++; + } + if (__pRowInfo[i].heightShrinkable) + { + __shrinkRowCount++; + } + + if (__pRowInfo[i].maxHeight != 0) + { + __pRowInfo[i].height = __pRowInfo[i].maxHeight; + } + } + } + + for (int j = 0; j < __column; j++) + { + if (!__pColInfo[j].columnCollapsed) + { + if (__pColInfo[j].widthStretchable) + { + __stretchColumnCount++; + } + if (__pColInfo[j].widthShrinkable) + { + __shrinkColumnCount++; + } + + if (__pColInfo[j].maxWidth != 0) + { + __pColInfo[j].width = __pColInfo[j].maxWidth; + } + } + } + + pCurNode = null; + pItemInfo = null; + pItemProxy = null; + + int mergedHeight = 0; + int mergedWidth = 0; + for (int i = __row - 1; i >= 0; i--) + { + if (!__pRowInfo[i].rowCollapsed) + { + for (int j = __column - 1; j >= 0; j--) + { + if (!__pColInfo[j].columnCollapsed) + { + pCurNode = GetNode(i, j); + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + pItemProxy = pCurNode->GetItemProxy(); + if (pItemInfo->__mergeEndPoint.x != NOT_MERGED) + { + int startRow = i; + int startColumn = j; + int endRow = pItemInfo->__mergeEndPoint.x; + int endColumn = pItemInfo->__mergeEndPoint.y; + + pItemProxy->GetMeasuredSize(mergedWidth, mergedHeight); + + int rowHeightSum = 0; + if (startRow == 0) + { + rowHeightSum -= __pRowInfo[startRow].heightSpacing; + } + for (int k = startRow; k <= endRow; k++) + { + rowHeightSum += __pRowInfo[k].height + __pRowInfo[k].heightSpacing; + } + if (mergedHeight > rowHeightSum) + { + __pRowInfo[startRow].height += mergedHeight - rowHeightSum; + } + + int colWidthSum = 0; + if (startColumn == 0) + { + colWidthSum -= __pColInfo[startColumn].widthSpacing; + } + for (int k = startColumn; k <= endColumn; k++) + { + colWidthSum += __pColInfo[k].width + __pColInfo[k].widthSpacing; + } + if (mergedWidth > colWidthSum) + { + __pColInfo[startColumn].width += mergedWidth - colWidthSum; + } + } + } + } + } + } + } + + LayoutRect layoutRect = GetLayoutRect(); + nextPosY = -__pRowInfo[0].heightSpacing + layoutRect.y; + for (int i = 0; i < __row; i++) + { + nextPosX = -__pColInfo[0].widthSpacing + layoutRect.x; + if (!__pRowInfo[i].rowCollapsed) + { + for (int j = 0; j < __column; j++) + { + if (!__pColInfo[j].columnCollapsed) + { + __pColInfo[j].x = nextPosX + __pColInfo[j].widthSpacing; + nextPosX = __pColInfo[j].x + __pColInfo[j].width; + } + } + __pRowInfo[i].y = nextPosY + __pRowInfo[i].heightSpacing; + nextPosY = __pRowInfo[i].y + __pRowInfo[i].height; + } + } + + layoutRect.w = nextPosX; + layoutRect.h = nextPosY; + SetLayoutRect(layoutRect); + + return E_SUCCESS; +} + +result +TableLayout::CalculateShrinkCell(const LayoutRect windowRect) +{ + __rowShrinkable = false; + __columnShrinkable = false; + + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + if (pContainerProxy == null) + { + return E_INVALID_STATE; + } + + LayoutRect containerRect; + pContainerProxy->ConvertWindowToClientBounds(windowRect, containerRect); + + LayoutRect layoutRect = GetLayoutRect(); + + int shrinkTotalWidth = layoutRect.w - containerRect.w; + int shrinkTotalHeight = layoutRect.h - containerRect.h; + + int shrinkColumnCount = __shrinkColumnCount; + int shrinkRowCount = __shrinkRowCount; + + int* pShrinkedColumns = null; + int* pShrinkedRows = null; + + int lastShrinkRow = 0; + int lastShrinkColumn = 0; + + ProxyListNode* pCurNode = null; + TableItemInfo* pItemInfo = null; + + if (shrinkTotalWidth > 0 && __shrinkColumnCount > 0) + { + if (pContainerProxy->GetItemWidthMatchMode() == WRAP_CONTENT) + { + return E_SUCCESS; + } + + __columnShrinkable = true; + + pShrinkedColumns = new (std::nothrow) int[__shrinkColumnCount]; + SysTryReturn(NID_UI, pShrinkedColumns != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + memset(pShrinkedColumns, 0x00, sizeof(int) * __shrinkColumnCount); + + int shrinkedColumnCount = 0; + bool shrinkedItem = true; + + while (shrinkedItem && shrinkColumnCount != 0) + { + shrinkedItem = false; + + for (int j = 0; j < __column; j++) + { + int shrinkWidth = shrinkTotalWidth / shrinkColumnCount; + int shrinkedColWidth = __pColInfo[j].width; + + if (__pColInfo[j].widthShrinkable && !__pColInfo[j].columnCollapsed) + { + shrinkedColWidth -= shrinkWidth; + + if (shrinkedColWidth < 0) + { + shrinkWidth += shrinkedColWidth; + + __pColInfo[j].width = 0; + shrinkedColWidth = 0; + __pColInfo[j].widthShrinkable = false; + + } + + for (int i = 0; i < __row; i++) + { + pCurNode = GetNode(i, j); + pItemInfo = null; + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + } + if (pItemInfo != null && shrinkedColWidth < pItemInfo->__minSize.w) + { + shrinkWidth -= pItemInfo->__minSize.w - shrinkedColWidth; + __pColInfo[j].width = pItemInfo->__minSize.w; + __pColInfo[j].widthShrinkable = false; + } + } + + if (__pColInfo[j].widthShrinkable == false) + { + shrinkTotalWidth -= shrinkWidth; + layoutRect.w -= shrinkWidth; + shrinkColumnCount--; + + pShrinkedColumns[shrinkedColumnCount++] = j; + shrinkedItem = true; + + break; + } + } + } + } + + int nextPosX = -__pColInfo[0].widthSpacing + layoutRect.x; + + for (int j = 0; j < __column; j++) + { + __pColInfo[j].x = nextPosX + __pColInfo[j].widthSpacing; + + if (!__pColInfo[j].columnCollapsed) + { + if (shrinkColumnCount != 0) + { + int shrinkWidth = shrinkTotalWidth / shrinkColumnCount; + + if (__pColInfo[j].widthShrinkable) + { + __pColInfo[j].width -= shrinkWidth; + lastShrinkColumn = j; + layoutRect.w -= shrinkWidth; + } + } + nextPosX = __pColInfo[j].width + __pColInfo[j].x; + } + } + + nextPosX = -__pColInfo[0].widthSpacing + layoutRect.x; + int shrinkWidth = 0; + if (shrinkTotalWidth != 0 && shrinkColumnCount != 0) + { + shrinkWidth = shrinkTotalWidth % shrinkColumnCount; + } + bool shrinkableColumn = true; + + while (shrinkWidth > 0 && shrinkableColumn) + { + shrinkableColumn = false; + for (int j = 0; j < __column; j++) + { + __pColInfo[j].x = nextPosX + __pColInfo[j].widthSpacing; + + if (!__pColInfo[j].columnCollapsed) + { + if (shrinkColumnCount != 0) + { + if (__pColInfo[j].widthShrinkable) + { + for (int i = 0; i < __row; i++) + { + pCurNode = GetNode(i, j); + pItemInfo = null; + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + } + if ((pItemInfo != null && ((__pColInfo[j].width - 1) < pItemInfo->__minSize.w)) || (__pColInfo[j].width - 1) < 0) + { + pShrinkedColumns[shrinkedColumnCount++] = j; + __pColInfo[j].widthShrinkable = false; + shrinkColumnCount--; + break; + } + } + + if (__pColInfo[j].widthShrinkable && shrinkWidth > 0) + { + __pColInfo[j].width--; + layoutRect.w--; + shrinkWidth--; + shrinkableColumn = true; + } + } + } + nextPosX = __pColInfo[j].width + __pColInfo[j].x; + } + } + } + + for (int j = 0; j < shrinkedColumnCount; j++) + { + __pColInfo[pShrinkedColumns[j]].widthShrinkable = true; + } + + delete[] pShrinkedColumns; + } + + if (shrinkTotalHeight > 0 && __shrinkRowCount > 0) + { + if (pContainerProxy->GetItemHeightMatchMode() == WRAP_CONTENT) + { + return E_SUCCESS; + } + + __rowShrinkable = true; + + pShrinkedRows = new (std::nothrow) int[__shrinkRowCount]; + SysTryReturn(NID_UI, pShrinkedRows != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + memset(pShrinkedRows, 0x00, sizeof(int) * __shrinkRowCount); + int shrinkedRowCount = 0; + bool shrinkedItem = true; + + while (shrinkedItem && shrinkRowCount != 0) + { + shrinkedItem = false; + + for (int i = 0; i < __row; i++) + { + int shrinkHeight = shrinkTotalHeight / shrinkRowCount; + int shrinkedRowHeight = __pRowInfo[i].height; + + if (__pRowInfo[i].heightShrinkable && !__pRowInfo[i].rowCollapsed) + { + shrinkedRowHeight -= shrinkHeight; + + if (shrinkedRowHeight < 0) + { + shrinkHeight += shrinkedRowHeight; + + __pRowInfo[i].height = 0; + shrinkedRowHeight = 0; + __pRowInfo[i].heightShrinkable = false; + + } + + for (int j = 0; j < __column; j++) + { + pCurNode = GetNode(i, j); + pItemInfo = null; + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + } + if (pItemInfo != null && shrinkedRowHeight < pItemInfo->__minSize.h) + { + shrinkHeight -= pItemInfo->__minSize.h - shrinkedRowHeight; + __pRowInfo[i].height = pItemInfo->__minSize.h; + __pRowInfo[i].heightShrinkable = false; + } + } + + if (__pRowInfo[i].heightShrinkable == false) + { + shrinkTotalHeight -= shrinkHeight; + layoutRect.h -= shrinkHeight; + shrinkRowCount--; + + pShrinkedRows[shrinkedRowCount++] = i; + shrinkedItem = true; + + break; + } + } + } + } + + int nextPosY = -__pRowInfo[0].heightSpacing + layoutRect.y; + + for (int i = 0; i < __row; i++) + { + if (!__pRowInfo[i].rowCollapsed) + { + if (shrinkRowCount != 0) + { + int shrinkHeight = shrinkTotalHeight / shrinkRowCount; + + if (__pRowInfo[i].heightShrinkable) + { + __pRowInfo[i].height -= shrinkHeight; + lastShrinkRow = i; + layoutRect.h -= shrinkHeight; + } + } + __pRowInfo[i].y = nextPosY + __pRowInfo[i].heightSpacing; + nextPosY = __pRowInfo[i].height + __pRowInfo[i].y; + } + } + + nextPosY = -__pRowInfo[0].heightSpacing + layoutRect.y; + int shrinkHeight = 0; + if (shrinkTotalHeight != 0 && shrinkRowCount != 0) + { + shrinkHeight = shrinkTotalHeight % shrinkRowCount; + } + bool shrinkableRow = true; + + while (shrinkHeight > 0 && shrinkableRow) + { + shrinkableRow = false; + for (int i = 0; i < __row; i++) + { + if (!__pRowInfo[i].rowCollapsed) + { + if (shrinkRowCount != 0) + { + if (__pRowInfo[i].heightShrinkable) + { + for (int j = 0; j < __column; j++) + { + pCurNode = GetNode(i, j); + pItemInfo = null; + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + } + if ((pItemInfo != null && ((__pRowInfo[i].height - 1) < pItemInfo->__minSize.h)) || (__pRowInfo[i].height - 1) < 0) + { + pShrinkedRows[shrinkedRowCount++] = i; + __pRowInfo[i].heightShrinkable = false; + shrinkRowCount--; + break; + } + } + + if (__pRowInfo[i].heightShrinkable && shrinkHeight > 0) + { + __pRowInfo[i].height--; + layoutRect.h--; + shrinkHeight--; + shrinkableRow = true; + } + } + } + __pRowInfo[i].y = nextPosY + __pRowInfo[i].heightSpacing; + nextPosY = __pRowInfo[i].height + __pRowInfo[i].y; + } + } + } + + for (int i = 0; i < shrinkedRowCount; i++) + { + __pRowInfo[pShrinkedRows[i]].heightShrinkable = true; + } + + delete[] pShrinkedRows; + } + SetLayoutRect(layoutRect); + return E_SUCCESS; +} + +result +TableLayout::CalculateStretchCell(const LayoutRect windowRect) +{ + __rowStretchable = false; + __columnStretchable = false; + + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + if (pContainerProxy == null) + { + return E_INVALID_STATE; + } + + LayoutRect containerRect; + pContainerProxy->ConvertWindowToClientBounds(windowRect, containerRect); + + LayoutRect layoutRect = GetLayoutRect(); + + int stretchTotalWidth = containerRect.w - layoutRect.w; + int stretchTotalHeight = containerRect.h - layoutRect.h; + + int stretchColumnCount = __stretchColumnCount; + int stretchRowCount = __stretchRowCount; + + int lastStretchRow = 0; + int lastStretchColumn = 0; + + int* pStretchedColumns = null; + int* pStretchedRows = null; + + ProxyListNode* pCurNode = null; + TableItemInfo* pItemInfo = null; + + if (stretchTotalWidth > 0 && __stretchColumnCount > 0) + { + if (pContainerProxy->GetItemWidthMatchMode() == WRAP_CONTENT) + { + return E_SUCCESS; + } + + __columnStretchable = true; + + pStretchedColumns = new (std::nothrow) int[__stretchColumnCount]; + SysTryReturn(NID_UI, pStretchedColumns != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + memset(pStretchedColumns, 0x00, sizeof(int) * __stretchColumnCount); + int stretchedColumnCount = 0; + bool stretchedItem = true; + + while (stretchedItem && stretchColumnCount != 0) + { + stretchedItem = false; + int stretchWidth = stretchTotalWidth / stretchColumnCount; + + for (int j = 0; j < __column; j++) + { + if (__pColInfo[j].widthStretchable && !__pColInfo[j].columnCollapsed) + { + int maxWidth = 0; + int stretchedColWidth = __pColInfo[j].width; + stretchedColWidth += stretchWidth; + for (int i = 0; i < __row; i++) + { + pCurNode = GetNode(i, j); + pItemInfo = null; + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + } + if (pItemInfo != null && maxWidth < pItemInfo->__maxSize.w) + { + maxWidth = pItemInfo->__maxSize.w; + } + } + + if (maxWidth < stretchedColWidth) + { + stretchWidth -= stretchedColWidth - maxWidth; + __pColInfo[j].width += stretchWidth; + stretchTotalWidth -= stretchWidth; + layoutRect.w += stretchWidth; + stretchColumnCount--; + __pColInfo[j].widthStretchable = false; + + pStretchedColumns[stretchedColumnCount++] = j; + stretchedItem = true; + break; + } + } + } + } + + int nextPosX = -__pColInfo[0].widthSpacing + layoutRect.x; + + for (int j = 0; j < __column; j++) + { + if (!__pColInfo[j].columnCollapsed) + { + if (__pColInfo[j].widthStretchable && stretchColumnCount != 0) + { + int stretchWidth = stretchTotalWidth / stretchColumnCount; + __pColInfo[j].width += stretchWidth; + layoutRect.w += stretchWidth; + lastStretchColumn = j; + } + __pColInfo[j].x = nextPosX + __pColInfo[j].widthSpacing; + nextPosX = __pColInfo[j].x + __pColInfo[j].width; + } + } + nextPosX = -__pColInfo[0].widthSpacing + layoutRect.x; + int stretchWidth = 0; + if (stretchTotalWidth != 0 && stretchColumnCount != 0) + { + stretchWidth = stretchTotalWidth % stretchColumnCount; + } + bool stretchableColumn = true; + + while (stretchWidth > 0 && stretchableColumn) + { + stretchableColumn = false; + for (int j = 0; j < __column; j++) + { + if (!__pColInfo[j].columnCollapsed) + { + if (stretchColumnCount != 0) + { + if (__pColInfo[j].widthStretchable) + { + for (int i = 0; i < __row; i++) + { + pCurNode = GetNode(i, j); + pItemInfo = null; + if (pCurNode != null) + { + pItemInfo = (TableItemInfo*) pCurNode->GetItemInfo(); + } + if (pItemInfo != null && ((__pColInfo[j].width + 1) > pItemInfo->__maxSize.w) && !pItemInfo->__merged) + { + pStretchedColumns[stretchedColumnCount++] = j; + __pColInfo[j].widthStretchable = false; + stretchColumnCount--; + break; + } + } + + if (__pColInfo[j].widthStretchable && stretchWidth > 0) + { + __pColInfo[j].width++; + layoutRect.w++; + stretchWidth--; + stretchableColumn = true; + } + } + } + __pColInfo[j].x = nextPosX + __pColInfo[j].widthSpacing; + nextPosX = __pColInfo[j].x + __pColInfo[j].width; + } + } + } + + for (int j = 0; j < stretchedColumnCount; j++) + { + __pColInfo[pStretchedColumns[j]].widthStretchable = true; + } + + delete[] pStretchedColumns; + } + + if (stretchTotalHeight > 0 && __stretchRowCount > 0) + { + if (pContainerProxy->GetItemHeightMatchMode() == WRAP_CONTENT) + { + return E_SUCCESS; + } + + __rowStretchable = true; + + pStretchedRows = new (std::nothrow) int[__stretchRowCount]; + SysTryReturn(NID_UI, pStretchedRows != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + memset(pStretchedRows, 0x00, sizeof(int) * __stretchRowCount); + int stretchedRowCount = 0; + bool stretchedItem = true; + + while (stretchedItem && stretchRowCount != 0) + { + stretchedItem = false; + int stretchHeight = stretchTotalHeight / stretchRowCount; + + for (int i = 0; i < __row; i++) + { + if (__pRowInfo[i].heightStretchable && !__pRowInfo[i].rowCollapsed) + { + int maxHeight = 0; + int stretchedRowHeight = __pRowInfo[i].height; + stretchedRowHeight += stretchHeight; + + for (int j = 0; j < __column; j++) + { + pCurNode = GetNode(i, j); + pItemInfo = null; + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + } + if (pItemInfo != null && maxHeight < pItemInfo->__maxSize.h) + { + maxHeight = pItemInfo->__maxSize.h; + } + } + + if (maxHeight < stretchedRowHeight) + { + stretchHeight -= stretchedRowHeight - maxHeight; + __pRowInfo[i].height += stretchHeight; + stretchTotalHeight -= stretchHeight; + layoutRect.h += stretchHeight; + stretchRowCount--; + __pRowInfo[i].heightStretchable = false; + + pStretchedRows[stretchedRowCount++] = i; + stretchedItem = true; + break; + } + } + } + } + + int nextPosY = -__pRowInfo[0].heightSpacing + layoutRect.y; + for (int i = 0; i < __row; i++) + { + if (!__pRowInfo[i].rowCollapsed) + { + if (__pRowInfo[i].heightStretchable && stretchRowCount != 0) + { + int stretchHeight = stretchTotalHeight / stretchRowCount; + __pRowInfo[i].height += stretchHeight; + layoutRect.h += stretchHeight; + lastStretchRow = i; + } + __pRowInfo[i].y = nextPosY + __pRowInfo[i].heightSpacing; + nextPosY = __pRowInfo[i].y + __pRowInfo[i].height; + } + } + + nextPosY = -__pRowInfo[0].heightSpacing + layoutRect.y; + int stretchHeight = 0; + if (stretchTotalHeight != 0 && stretchRowCount != 0) + { + stretchHeight = stretchTotalHeight % stretchRowCount; + } + bool stretchableRow = true; + + while (stretchHeight > 0 && stretchableRow) + { + stretchableRow = false; + for (int i = 0; i < __row; i++) + { + if (!__pRowInfo[i].rowCollapsed) + { + if (stretchRowCount != 0) + { + if (__pRowInfo[i].heightStretchable) + { + for (int j = 0; j < __column; j++) + { + pCurNode = GetNode(i, j); + pItemInfo = null; + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + } + if (pItemInfo != null && ((__pRowInfo[i].height + 1) > pItemInfo->__maxSize.h) && !pItemInfo->__merged) + { + pStretchedRows[stretchedRowCount++] = i; + __pRowInfo[i].heightStretchable = false; + stretchRowCount--; + break; + } + } + + if (__pRowInfo[i].heightStretchable && stretchHeight > 0) + { + __pRowInfo[i].height++; + layoutRect.h++; + stretchHeight--; + stretchableRow = true; + } + } + } + __pRowInfo[i].y = nextPosY + __pRowInfo[i].heightSpacing; + nextPosY = __pRowInfo[i].y + __pRowInfo[i].height; + } + } + } + + for (int i = 0; i < stretchedRowCount; i++) + { + __pRowInfo[pStretchedRows[i]].heightStretchable = true; + } + + delete[] pStretchedRows; + } + SetLayoutRect(layoutRect); + return E_SUCCESS; +} + +result +TableLayout::Merge(int startRow, int startCol, int endRow, int endCol) +{ + if (startRow < 0 || startRow >= __row || startCol < 0 || startCol >= __column + || endRow < 0 || endRow >= __row || endCol < 0 || endCol >= __column + || startRow > endRow || startCol > endCol) + { + return E_INVALID_ARG; + } + + int realEndRow = endRow; + int realEndColumn = endCol; + + ProxyListNode* pCurNode = null; + TableItemInfo* pItemInfo = null; + for (int i = startRow; i <= realEndRow; i++) + { + if (__pRowInfo[i].rowCollapsed) + { + realEndRow++; + } + + for (int j = startCol; j <= realEndColumn; j++) + { + int k = 0; + int mergedCellIndex = MakeCellID(i, j); + + for (k = 0; k < __mergedCellList.GetCount(); k++) + { + Integer* cellID = static_cast (__mergedCellList.GetAt(k)); + if (cellID->ToInt() == mergedCellIndex) + { + return E_SYSTEM; + } + } + + if (i != startRow || j != startCol) + { + __mergedCellList.Add(*(new Integer(mergedCellIndex))); + } + + pCurNode = GetNode(i, j); + pItemInfo = null; + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + } + if (pItemInfo == null) + { + continue; + } + if (pItemInfo->__merged) + { + return E_SYSTEM; + } + if (__pColInfo[j].columnCollapsed) + { + realEndColumn++; + } + + if (i == startRow && j == startCol) + { + pItemInfo->__merged = true; + continue; + } + + pItemInfo->__enable = false; + pItemInfo->__merged = true; + if (pCurNode->GetItemProxy() != null) + { + pCurNode->GetItemProxy()->Visible(false); + } + } + } + + pCurNode = GetNode(startRow, startCol); + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + pItemInfo->__mergeEndPoint.x = realEndRow; + pItemInfo->__mergeEndPoint.y = realEndColumn; + } + + SetUpdateState(true); + return E_SUCCESS; +} + +result +TableLayout::OnLayout(int width, int height, bool updateLayouting) +{ + LayoutRect layoutRect = GetLayoutRect(); + LayoutRect windowRect = {layoutRect.x, layoutRect.y, width, height}; + + result r = CalculateSize(); + if (r != E_SUCCESS) + { + return r; + } + + r = CalculateShrinkCell(windowRect); + if (r != E_SUCCESS) + { + return r; + } + + r = CalculateStretchCell(windowRect); + if (r != E_SUCCESS) + { + return r; + } + + r = AdjustTableLayout(windowRect, updateLayouting); + if (r != E_SUCCESS) + { + return r; + } + + return E_SUCCESS; +} + +result +TableLayout::AdjustTableLayout(const LayoutRect windowRect, bool updateLayouting) +{ + LayoutItemProxy* pContainerProxy = GetContainerProxy(); + if (pContainerProxy == null) + { + return E_INVALID_STATE; + } + + result r = E_SUCCESS; + LayoutSize size = {0, 0}; + ProxyListNode* pCurNode = null; + TableItemInfo* pItemInfo = null; + LayoutItemProxy* pItemProxy = null; + for (int i = 0; i < __row; i++) + { + for (int j = 0; j < __column; j++) + { + pCurNode = GetNode(i, j); + pItemInfo = null; + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + pItemProxy = pCurNode->GetItemProxy(); + } + if (pItemInfo != null && pItemInfo->__enable) + { + size.w = __pColInfo[j].width; + size.h = __pRowInfo[i].height; + if (pItemInfo->__mergeEndPoint.x != NOT_MERGED || pItemInfo->__mergeEndPoint.y != NOT_MERGED) + { + result r = CalculateMergeCell(i, j, size); + if (r != E_SUCCESS) + { + SysLog(NID_UI, "CalculateMergeCell() is Failed."); + } + } + if (pItemProxy != null) + { + LayoutRect rect = pItemProxy->GetItemBaseRect(); + rect.x = __pColInfo[j].x; + rect.y = __pRowInfo[i].y; + + LayoutRect cellRect; + cellRect.x = __pColInfo[j].x; + cellRect.y = __pRowInfo[i].y; + cellRect.w = size.w; + cellRect.h = size.h; + + r = pItemProxy->Measure(rect.w, rect.h); + if (r != E_SUCCESS) + { + return r; + } + pItemProxy->GetMeasuredSize(rect.w, rect.h); + + if ((__pRowInfo[i].heightShrinkable && __rowShrinkable) || + (__pRowInfo[i].heightStretchable && __rowStretchable) || + pItemInfo->__fillHeight) + { + int height = 0; + r = pItemProxy->Measure(rect.w, cellRect.h); + if (r != E_SUCCESS) + { + return r; + } + pItemProxy->GetMeasuredSize(rect.w, height); + + if ((__pRowInfo[i].heightShrinkable && __rowShrinkable) && rect.h > height) + { + rect.h = height; + } + else if ((__pRowInfo[i].heightStretchable && __rowStretchable) && rect.h < height) + { + rect.h = height; + } + else if (pItemInfo->__fillHeight) + { + rect.h = height; + } + } + + if ((__pColInfo[j].widthShrinkable && __columnShrinkable) || + (__pColInfo[j].widthStretchable && __columnStretchable) || + pItemInfo->__fillWidth) + { + int width = 0; + r = pItemProxy->Measure(cellRect.w, rect.h); + if (r != E_SUCCESS) + { + return r; + } + pItemProxy->GetMeasuredSize(width, rect.h); + + if ((__pColInfo[j].widthShrinkable && __columnShrinkable) && rect.w > width) + { + rect.w = width; + } + else if ((__pColInfo[j].widthStretchable && __columnStretchable) && rect.w < width) + { + rect.w = width; + } + else if (pItemInfo->__fillWidth) + { + rect.w = width; + } + } + + ItemAlign align = pItemProxy->GetItemAlignment(); + rect = CalculateAlign(*pItemProxy, cellRect, rect, align.HAlign, align.VAlign); + + r = pItemProxy->Measure(rect.w, rect.h); + if (r != E_SUCCESS) + { + return r; + } + pItemProxy->GetMeasuredSize(rect.w, rect.h); + pItemProxy->SetItemWindowRect(rect); + } + } + } + } + + LayoutMatchMode widthMode = pContainerProxy->GetItemWidthMatchMode(); + LayoutMatchMode heightMode = pContainerProxy->GetItemHeightMatchMode(); + LayoutRect containerRect; + pContainerProxy->ConvertWindowToClientBounds(windowRect, containerRect); + + containerRect.x = windowRect.x; + containerRect.y = windowRect.y; + + int correctionWidth = windowRect.w - containerRect.w; + int correctionHeight = windowRect.h - containerRect.h; + + LayoutRect layoutRect = GetLayoutRect(); + if (widthMode == WRAP_CONTENT) + { + containerRect.w = layoutRect.w + correctionWidth; + } + else + { + containerRect.w += correctionWidth; + } + + if (heightMode == WRAP_CONTENT) + { + containerRect.h = layoutRect.h + correctionHeight; + } + else + { + containerRect.h += correctionHeight; + } + + SetLayoutRect(containerRect); + + LayoutRect clientRect; + pContainerProxy->GetItemWindowRect(clientRect); + containerRect.x = clientRect.x; + containerRect.y = clientRect.y; + if (updateLayouting) + { + pContainerProxy->SetItemWindowRect(containerRect); + } + return E_SUCCESS; +} + +result +TableLayout::AddItem(LayoutItem& item) +{ + ProxyListNode* pCurNode = null; + + int cellIndex = INVALID_CELL_ID; + for (int i = 0; i < __row; i++) + { + for (int j = 0; j < __column; j++) + { + pCurNode = GetNode(i, j); + if (pCurNode == null) + { + if (!__pRowInfo[i].rowCollapsed && !__pColInfo[j].columnCollapsed) + { + cellIndex = MakeCellID(i, j); + for (int k = 0; k < __mergedCellList.GetCount(); k++) + { + Integer* cellID = static_cast (__mergedCellList.GetAt(k)); + if (cellID->ToInt() == cellIndex) + { + return AddItem(item, i, j, true); + } + } + + return AddItem(item, i, j); + } + } + } + } + + return E_SYSTEM; +} + +result +TableLayout::AddItem(LayoutItem& item, int row, int column, bool mergedState) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid"); + + if (row < 0 || row >= __row || column < 0 || column >= __column) + { + return E_INVALID_ARG; + } + ProxyListNode* pGetNode = GetNode(row, column); + if (pGetNode != null) + { + return E_INVALID_STATE; + } + + int cellIndex = MakeCellID(row, column); + + if (!mergedState) + { + for (int k = 0; k < __mergedCellList.GetCount(); k++) + { + Integer* cellID = static_cast (__mergedCellList.GetAt(k)); + if (cellID->ToInt() == cellIndex) + { + return E_SYSTEM; + } + } + } + + result r = Layout::AddItem(item); + if (r != E_SUCCESS) + { + return r; + } + + ProxyListNode* pAddNode = pProxyList->GetNode(item); + if (pAddNode == null) + { + return E_INVALID_STATE; + } + TableItemInfo* pAddItemInfo = dynamic_cast (pAddNode->GetItemInfo()); + if (pAddItemInfo == null) + { + return E_INVALID_STATE; + } + + cellIndex = MakeCellID(row, column); + pAddItemInfo->__id = cellIndex; + + if (mergedState) + { + pAddItemInfo->__enable = false; + pAddItemInfo->__merged = true; + + if (pAddNode->GetItemProxy() != null) + { + pAddNode->GetItemProxy()->Visible(false); + } + } + + return E_SUCCESS; +} + +LayoutItem* +TableLayout::GetItem(int row, int column) const +{ + if (row < 0 || row >= __row) + { + return null; + } + + if (column < 0 || column >= __column) + { + return null; + } + + ProxyListNode* pCurNode = GetNode(row, column); + if (pCurNode != null && pCurNode->GetItemProxy() != null) + { + return pCurNode->GetItemProxy()->GetItem(); + } + else + { + return null; + } +} + +result +TableLayout::SetItemPosition(const LayoutItem& item, int row, int column) +{ + SysTryReturn(NID_UI, row >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Negative input argument : row(%d)", row); + SysTryReturn(NID_UI, row < __row, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Input Argument row over the max row : row(%d), maxRow(%d)", row, __row); + SysTryReturn(NID_UI, column >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Negative input argument : column(%d)", column); + SysTryReturn(NID_UI, column < __column, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Input Argument column over the max column : column(%d), maxColumn(%d)", column, __column); + + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid"); + + ProxyListNode* pTargetNode = GetNode(row, column); + ProxyListNode* pCurNode = pProxyList->GetNode(item); + SysTryReturn(NID_UI, (pCurNode != null), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Controls have not been added to the container."); + + if (pTargetNode == pCurNode) + { + return E_SUCCESS; + } + + SysTryReturn(NID_UI, (pTargetNode == null), E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The (%d, %d) cell is not available.", row, column); + + int cellIndex = MakeCellID(row, column); + TableItemInfo* pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + + if (pItemInfo->__merged || !pItemInfo->__enable) + { + pItemInfo->__enable = true; + pItemInfo->__merged = false; + if (pCurNode->GetItemProxy() != null) + { + pCurNode->GetItemProxy()->Visible(true); + } + } + + pItemInfo->__id = cellIndex; + + SetUpdateState(true); + return E_SUCCESS; +} + +result +TableLayout::GetItemPosition(const LayoutItem& item, int& row, int& column) const +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid"); + + ProxyListNode* pCurNode = pProxyList->GetNode(item); + SysTryReturn(NID_UI, (pCurNode != null), E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Controls have not been added to the container."); + + TableItemInfo* pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + row = (GetRow(pItemInfo->__id)); + column = (GetColumn(pItemInfo->__id)); + + return E_SUCCESS; +} + +result +TableLayout::AddRow(void) +{ + if (__row == __maxRow) + { + RowInfo* pRowInfo = new (std::nothrow) RowInfo[__maxRow + 1]; + SysTryReturn(NID_UI, pRowInfo != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + memset(pRowInfo, 0x0, sizeof(RowInfo) * (__maxRow + 1)); + memcpy(pRowInfo, __pRowInfo, sizeof(RowInfo) * __maxRow); + delete[] __pRowInfo; + __pRowInfo = pRowInfo; + __maxRow++; + } + __row++; + return E_SUCCESS; +} + +result +TableLayout::AddColumn(void) +{ + if (__column == __maxColumn) + { + ColumnInfo* pColInfo = new (std::nothrow) ColumnInfo[__maxColumn + 1]; + SysTryReturn(NID_UI, pColInfo != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory."); + + memset(pColInfo, 0x0, sizeof(ColumnInfo) * (__maxColumn + 1)); + memcpy(pColInfo, __pColInfo, sizeof(ColumnInfo) * __maxColumn); + delete[] __pColInfo; + __pColInfo = pColInfo; + __maxColumn++; + } + __column++; + return E_SUCCESS; +} + +result +TableLayout::DeleteRow(int row) +{ + if (row < 0 || row >= __row) + { + return E_INVALID_ARG; + } + + ProxyListNode* pCurNode = null; + result r = E_SUCCESS; + for (int j = 0; j < __column; j++) + { + pCurNode = GetNode(row, j); + if (pCurNode != null) + { + r = RemoveItem(*(pCurNode->GetItemProxy()->GetItem())); + if (r != E_SUCCESS) + { + return r; + } + } + } + + TableItemInfo* pItemInfo = null; + for (int i = 0; i < __row; i++) + { + for (int j = 0; j < __column; j++) + { + pCurNode = GetNode(i, j); + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + if (i > row) + { + pItemInfo->__id = MakeCellID((i - 1), j); + } + if (pItemInfo->__mergeEndPoint.x != NOT_MERGED) + { + if (pItemInfo->__mergeEndPoint.x >= row) + { + pItemInfo->__mergeEndPoint.x--; + } + if (pItemInfo->__mergeEndPoint.x == GetRow(pItemInfo->__id)) + { + r = Unmerge(GetRow(pItemInfo->__id), GetColumn(pItemInfo->__id)); + if (r != E_SUCCESS) + { + return r; + } + } + } + } + } + } + + memcpy(&__pRowInfo[row], &__pRowInfo[row + 1], sizeof(RowInfo) * (__row - row - 1)); + + __row--; + + return r; +} + +result +TableLayout::DeleteColumn(int column) +{ + if (column < 0 || column >= __column) + { + return E_INVALID_ARG; + } + + ProxyListNode* pCurNode = null; + TableItemInfo* pItemInfo = null; + result r = E_SUCCESS; + for (int i = 0; i < __row; i++) + { + pCurNode = GetNode(i, column); + if (pCurNode != null) + { + r = RemoveItem(*(pCurNode->GetItemProxy()->GetItem())); + if (r != E_SUCCESS) + { + return r; + } + } + + for (int j = 0; j < __column; j++) + { + pCurNode = GetNode(i, j); + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + if (j > column) + { + pItemInfo->__id = MakeCellID(i, (j - 1)); + } + + if (pItemInfo->__mergeEndPoint.y != NOT_MERGED) + { + if (pItemInfo->__mergeEndPoint.y >= column) + { + pItemInfo->__mergeEndPoint.y--; + } + int mergeEndColumn = GetColumn(pItemInfo->__id); + if (pItemInfo->__mergeEndPoint.y == mergeEndColumn) + { + r = Unmerge(GetRow(pItemInfo->__id), GetColumn(pItemInfo->__id)); + if (r != E_SUCCESS) + { + return r; + } + } + } + } + } + } + + memcpy(&__pColInfo[column], &__pColInfo[column + 1], sizeof(ColumnInfo) * (__column - column - 1)); + + __column--; + + return E_SUCCESS; +} + +result +TableLayout::CalculateMergeCell(int row, int column, LayoutSize& size) +{ + if (row < 0 || row >= __row || column < 0 || column >= __column) + { + return E_INVALID_ARG; + } + + ProxyListNode* pCurNode = GetNode(row, column); + if (pCurNode == null) + { + return E_INVALID_ARG; + } + + TableItemInfo* pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + if (pItemInfo->__mergeEndPoint.x > NOT_MERGED && !__pRowInfo[pItemInfo->__mergeEndPoint.x].rowCollapsed) + { + int endRowPos = __pRowInfo[pItemInfo->__mergeEndPoint.x].y; + size.h = __pRowInfo[pItemInfo->__mergeEndPoint.x].height + endRowPos - __pRowInfo[row].y; + } + else + { + size.h = __pRowInfo[row].height; + } + + if (pItemInfo->__mergeEndPoint.y > NOT_MERGED && !__pColInfo[pItemInfo->__mergeEndPoint.y].columnCollapsed) + { + int endColPos = __pColInfo[pItemInfo->__mergeEndPoint.y].x; + size.w = __pColInfo[pItemInfo->__mergeEndPoint.y].width + endColPos - __pColInfo[column].x; + } + else + { + size.w = __pColInfo[column].width; + } + + return E_SUCCESS; +} + +LayoutRect +TableLayout::CalculateAlign(LayoutItemProxy& itemProxy, LayoutRect cellRect, LayoutRect itemRect, const HorizontalAlign horizonAlign, const VerticalAlign verticalAlign) +{ + ItemMargin margin = itemProxy.GetItemMargin(); + itemRect.y = cellRect.y; + itemRect.x = cellRect.x; + + if (verticalAlign == ITEM_VERTICAL_ALIGN_TOP) + { + if (itemRect.h > cellRect.h - margin.top) + { + itemRect.h = cellRect.h - margin.top; + } + itemRect.y = cellRect.y + margin.top; + } + else if (verticalAlign == ITEM_VERTICAL_ALIGN_BOTTOM) + { + if (itemRect.h > cellRect.h - margin.bottom) + { + itemRect.h = cellRect.h - margin.bottom; + } + itemRect.y = cellRect.h + cellRect.y - itemRect.h - margin.bottom; + } + else if (verticalAlign == ITEM_VERTICAL_ALIGN_TOP_BOTTOM) + { + itemRect.h = cellRect.h - margin.top - margin.bottom; + itemRect.y = cellRect.y + margin.top; + } + else if (verticalAlign == ITEM_VERTICAL_ALIGN_MIDDLE) + { + if (cellRect.h > itemRect.h) + { + itemRect.y = cellRect.y + ((cellRect.h - itemRect.h) >> 1); + } + else + { + itemRect.h = cellRect.h; + } + } + if (horizonAlign == ITEM_HORIZONTAL_ALIGN_RIGHT) + { + if (itemRect.w > cellRect.w - margin.right) + { + itemRect.w = cellRect.w - margin.right; + } + itemRect.x = cellRect.w + cellRect.x - itemRect.w - margin.right; + } + else if (horizonAlign == ITEM_HORIZONTAL_ALIGN_LEFT) + { + if (itemRect.w > cellRect.w - margin.left) + { + itemRect.w = cellRect.w - margin.left; + } + itemRect.x = cellRect.x + margin.left; + } + else if (horizonAlign == ITEM_HORIZONTAL_ALIGN_CENTER) + { + if (cellRect.w > itemRect.w) + { + itemRect.x = cellRect.x + ((cellRect.w - itemRect.w) >> 1); + } + else + { + itemRect.w = cellRect.w; + } + } + else if (horizonAlign == ITEM_HORIZONTAL_ALIGN_LEFT_RIGHT) + { + itemRect.w = cellRect.w - margin.left - margin.right; + itemRect.x = cellRect.x + margin.left; + } + + return itemRect; +} + +result +TableLayout::GetCellSize(int cellIndex, LayoutRect& rect) +{ + if (cellIndex == INVALID_CELL_ID) + { + return E_INVALID_ARG; + } + + int row = GetRow(cellIndex); + if (row < 0 || row >= __row) + { + return E_INVALID_ARG; + } + + int column = GetColumn(cellIndex); + if (column < 0 || column >= __column) + { + return E_INVALID_ARG; + } + + ProxyListNode* pCurNode = GetNode(row, column); + if (pCurNode != null) + { + TableItemInfo* pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + if (pItemInfo->__mergeEndPoint.x != NOT_MERGED || pItemInfo->__mergeEndPoint.y != NOT_MERGED) + { + LayoutSize size = {0, 0}; + result r = CalculateMergeCell(row, column, size); + if (r != E_SUCCESS) + { + rect.w = size.w; + rect.h = size.h; + } + } + else + { + rect.h = __pRowInfo[row].height; + rect.w = __pColInfo[column].width; + } + } + + if (__pRowInfo[row].rowCollapsed) + { + rect.h = 0; + } + + if (__pColInfo[column].columnCollapsed) + { + rect.w = 0; + } + + return E_SUCCESS; +} + +result +TableLayout::SetColumnCollapsed(int columnIndex, bool collapsed) +{ + SysTryReturn(NID_UI, columnIndex >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : column(%d)", columnIndex); + SysTryReturn(NID_UI, columnIndex < __column, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument column over the max column : column(%d), maxColumn(%d)", columnIndex, __column); + + __pColInfo[columnIndex].columnCollapsed = collapsed; + + ProxyListNode* pCurNode = null; + TableItemInfo* pItemInfo = null; + result r = E_SUCCESS; + for (int i = 0; i < __row; i++) + { + pCurNode = GetNode(i, columnIndex); + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + if (pItemInfo->__merged == true) + { + continue; + } + if (__pColInfo[columnIndex].columnCollapsed) + { + pItemInfo->__enable = false; + if (pCurNode->GetItemProxy() != null) + { + pCurNode->GetItemProxy()->Visible(false); + } + } + else if (!__pRowInfo[i].rowCollapsed) + { + pItemInfo->__enable = true; + if (pCurNode->GetItemProxy() != null) + { + pCurNode->GetItemProxy()->Visible(true); + } + } + } + } + + SetUpdateState(true); + return r; +} + +bool +TableLayout::GetColumnCollapsed(int columnIndex) const +{ + if (columnIndex < 0 || columnIndex >= __column) + { + return false; + } + + return __pColInfo[columnIndex].columnCollapsed; +} + +result +TableLayout::SetRowCollapsed(int rowIndex, bool collapsed) +{ + SysTryReturn(NID_UI, rowIndex >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : row(%d)", rowIndex); + SysTryReturn(NID_UI, rowIndex < __row, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument row over the max row : row(%d), maxRow(%d)", rowIndex, __row); + + __pRowInfo[rowIndex].rowCollapsed = collapsed; + + ProxyListNode* pCurNode = null; + TableItemInfo* pItemInfo = null; + + for (int i = 0; i < __column; i++) + { + pCurNode = GetNode(rowIndex, i); + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + if (pItemInfo->__merged == true) + { + continue; + } + if (__pRowInfo[rowIndex].rowCollapsed) + { + pItemInfo->__enable = false; + if (pCurNode->GetItemProxy() != null) + { + pCurNode->GetItemProxy()->Visible(false); + } + } + else if (!__pColInfo[i].columnCollapsed) + { + pItemInfo->__enable = true; + if (pCurNode->GetItemProxy() != null) + { + pCurNode->GetItemProxy()->Visible(true); + } + } + } + } + + SetUpdateState(true); + return E_SUCCESS; +} + +bool +TableLayout::GetRowCollapsed(int rowIndex) const +{ + if (rowIndex < 0 || rowIndex >= __row) + { + return false; + } + + return __pRowInfo[rowIndex].rowCollapsed; +} + +result +TableLayout::SetRowShrinkable(int row, bool shrinkable) +{ + SysTryReturn(NID_UI, row >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : row(%d)", row); + SysTryReturn(NID_UI, row < __row, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument row over the max row : row(%d), maxRow(%d)", row, __row); + + __pRowInfo[row].heightShrinkable = shrinkable; + + SetUpdateState(true); + SetPartialUpdateFlag(true); + return E_SUCCESS; +} + +bool +TableLayout::GetRowShrinkable(int row) const +{ + SysTryReturn(NID_UI, row >= 0, false, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Negative input argument : row(%d)", row); + SysTryReturn(NID_UI, row < __row, false, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument row over the max row : row(%d), maxRow(%d)", row, __row); + + return __pRowInfo[row].heightShrinkable; +} + +result +TableLayout::SetColumnShrinkable(int column, bool shrinkable) +{ + SysTryReturn(NID_UI, column >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : column(%d)", column); + SysTryReturn(NID_UI, column < __column, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument column over the max column : column(%d), maxColumn(%d)", column, __column); + + __pColInfo[column].widthShrinkable = shrinkable; + + SetUpdateState(true); + SetPartialUpdateFlag(true); + return E_SUCCESS; +} + +bool +TableLayout::GetColumnShrinkable(int column) const +{ + SysTryReturn(NID_UI, column >= 0, false, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : column(%d)", column); + SysTryReturn(NID_UI, column < __column, false, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument column over the max column : column(%d), maxColumn(%d)", column, __column); + + return __pColInfo[column].widthShrinkable; +} + +result +TableLayout::SetRowStretchable(int row, bool stretchable) +{ + SysTryReturn(NID_UI, row >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : row(%d)", row); + SysTryReturn(NID_UI, row < __row, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument row over the max row : row(%d), maxRow(%d)", row, __row); + + __pRowInfo[row].heightStretchable = stretchable; + + SetUpdateState(true); + SetPartialUpdateFlag(true); + return E_SUCCESS; +} + +bool +TableLayout::GetRowStretchable(int row) const +{ + if (row < 0 || row >= __row) + { + return false; + } + + return __pRowInfo[row].heightStretchable; +} + +result +TableLayout::SetColumnStretchable(int column, bool stretchable) +{ + SysTryReturn(NID_UI, column >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Negative input argument : column(%d)", + column); + SysTryReturn(NID_UI, column < __column, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument column over the max column : column(%d), maxColumn(%d)", column, __column); + + __pColInfo[column].widthStretchable = stretchable; + + SetUpdateState(true); + SetPartialUpdateFlag(true); + return E_SUCCESS; +} + +bool +TableLayout::GetColumnStretchable(int column) const +{ + SysTryReturn(NID_UI, column >= 0, false, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Negative input argument : column(%d)", column); + SysTryReturn(NID_UI, column < __column, false, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument column over the max column : column(%d), maxColumn(%d)", column, __column); + + return __pColInfo[column].widthStretchable; +} + +result +TableLayout::SetRowSpacing(int row, int heightSpacing) +{ + SysTryReturn(NID_UI, row >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : row(%d)", row); + SysTryReturn(NID_UI, row < __row, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument row over the max row : row(%d), maxRow(%d)", row, __row); + SysTryReturn(NID_UI, heightSpacing >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : spacing(%d)", heightSpacing); + + __pRowInfo[row].heightSpacing = heightSpacing; + + SetUpdateState(true); + return E_SUCCESS; +} + +result +TableLayout::GetRowSpacing(int row, int& spacing) const +{ + SysTryReturn(NID_UI, row >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : row(%d)", row); + SysTryReturn(NID_UI, row < __row, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument row over the max row : row(%d), maxRow(%d)", row, __row); + + spacing = __pRowInfo[row].heightSpacing; + return E_SUCCESS; +} + +result +TableLayout::SetColumnSpacing(int column, int widthSpacing) +{ + SysTryReturn(NID_UI, column >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : column(%d)", column); + SysTryReturn(NID_UI, column < __column, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument column over the max column : column(%d), maxColumn(%d)", column, __column); + SysTryReturn(NID_UI, widthSpacing >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : spacing(%d)", widthSpacing); + + __pColInfo[column].widthSpacing = widthSpacing; + + SetUpdateState(true); + return E_SUCCESS; +} + +result +TableLayout::GetColumnSpacing(int column, int& spacing) const +{ + SysTryReturn(NID_UI, column >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : column(%d)", column); + SysTryReturn(NID_UI, column < __column, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument column over the max column : column(%d), maxColumn(%d)", column, __column); + + spacing = __pColInfo[column].widthSpacing; + + return E_SUCCESS; +} + +result +TableLayout::SetFillCell(int row, int column, bool fillWidth, bool fillHeight) +{ + SysTryReturn(NID_UI, row >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : row(%d)", row); + SysTryReturn(NID_UI, row < __row, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument row over the max row : row(%d), maxRow(%d)", row, __row); + SysTryReturn(NID_UI, column >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : column(%d)", column); + SysTryReturn(NID_UI, column < __column, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument column over the max column : column(%d), maxColumn(%d)", column, __column); + + ProxyListNode* pNode = GetNode(row, column); + if (pNode != null) + { + TableItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + pItemInfo->__fillWidth = fillWidth; + pItemInfo->__fillHeight = fillHeight; + return E_SUCCESS; + } + return E_SYSTEM; +} + +result +TableLayout::GetFillCell(int row, int column, bool& fillWidth, bool& fillHeight) const +{ + SysTryReturn(NID_UI, row >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : row(%d)", row); + SysTryReturn(NID_UI, row < __row, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument row over the max row : row(%d), maxRow(%d)", row, __row); + SysTryReturn(NID_UI, column >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : column(%d)", column); + SysTryReturn(NID_UI, column < __column, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument column over the max column : column(%d), maxColumn(%d)", column, __column); + + ProxyListNode* pNode = GetNode(row, column); + if (pNode != null) + { + TableItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + fillWidth = pItemInfo->__fillWidth; + fillHeight = pItemInfo->__fillHeight; + return E_SUCCESS; + } + return E_SYSTEM; +} + +result +TableLayout::SwapItemPosition(LayoutItem& item1, LayoutItem& item2) +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid"); + + ProxyListNode* pNode1 = pProxyList->GetNode(item1); + ProxyListNode* pNode2 = pProxyList->GetNode(item2); + + SysTryReturn(NID_UI, (pNode1 != null && pNode2 != null), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Control dose not belong to layout.") + + TableItemInfo* pItemInfo1 = dynamic_cast (pNode1->GetItemInfo()); + TableItemInfo* pItemInfo2 = dynamic_cast (pNode2->GetItemInfo()); + if (pItemInfo1 == null || pItemInfo2 == null) + { + return E_INVALID_STATE; + } + + int cellIndex1 = pItemInfo1->__id; + int cellIndex2 = pItemInfo2->__id; + bool merged1 = pItemInfo1->__merged; + bool merged2 = pItemInfo2->__merged; + bool enable1 = pItemInfo1->__enable; + bool enable2 = pItemInfo2->__enable; + + pItemInfo1->__id = cellIndex2; + pItemInfo2->__id = cellIndex1; + pItemInfo1->__merged = merged2; + pItemInfo2->__merged = merged1; + pItemInfo1->__enable = enable2; + pItemInfo2->__enable = enable1; + + if (pNode1->GetItemProxy() != null) + { + if (pItemInfo1->__merged || !pItemInfo1->__enable) + { + pNode1->GetItemProxy()->Visible(false); + } + else + { + pNode1->GetItemProxy()->Visible(true); + } + } + + if (pNode2->GetItemProxy() != null) + { + if (pItemInfo2->__merged || !pItemInfo2->__enable) + { + pNode2->GetItemProxy()->Visible(false); + } + else + { + pNode2->GetItemProxy()->Visible(true); + } + } + + SetUpdateState(true); + return E_SUCCESS; +} + +result +TableLayout::Unmerge(int row, int column) +{ + SysTryReturn(NID_UI, row >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Negative input argument : row(%d)", row); + SysTryReturn(NID_UI, row < __row, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Input Argument row over the max row : row(%d), maxRow(%d)", row, __row); + SysTryReturn(NID_UI, column >= 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Negative input argument : column(%d)", column); + SysTryReturn(NID_UI, column < __column, E_INVALID_ARG, E_INVALID_ARG, + "[E_INVALID_ARG] Input Argument column over the max column : column(%d), maxColumn(%d)", column, __column); + + int endRow = 0; + int endColumn = 0; + + ProxyListNode* pCurNode = null; + TableItemInfo* pItemInfo = null; + + pCurNode = GetNode(row, column); + SysTryReturn(NID_UI, pCurNode, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALIDE_ARG] (%d, %d) cell is not merged.", row, column); + + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + endRow = pItemInfo->__mergeEndPoint.x; + endColumn = pItemInfo->__mergeEndPoint.y; + + if (pItemInfo->__enable == false || pItemInfo->__merged == false + || endRow == NOT_MERGED || endColumn == NOT_MERGED) + { + return E_INVALID_STATE; + } + + pItemInfo->__mergeEndPoint.x = NOT_MERGED; + pItemInfo->__mergeEndPoint.y = NOT_MERGED; + + for (int i = row; i <= endRow; i++) + { + for (int j = column; j <= endColumn; j++) + { + pCurNode = GetNode(i, j); + if (pCurNode != null) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo == null) + { + return E_INVALID_STATE; + } + pItemInfo->__enable = true; + pItemInfo->__merged = false; + + for (int k = 0; k < __mergedCellList.GetCount(); k++) + { + Integer* cellID = static_cast (__mergedCellList.GetAt(k)); + if (cellID->ToInt() == MakeCellID(i, j)) + { + __mergedCellList.RemoveAt(k, true); + break; + } + } + + if (pCurNode->GetItemProxy() != null) + { + pCurNode->GetItemProxy()->Visible(true); + } + } + } + } + + SetUpdateState(true); + return E_SUCCESS; +} + +result +TableLayout::GetMergeSize(int row, int column, int& rowSize, int& colSize) const +{ + rowSize = 0; + colSize = 0; + + SysTryReturn(NID_UI, row >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : row(%d)", row); + SysTryReturn(NID_UI, row < __row, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument row over the max row : row(%d), maxRow(%d)", row, __row); + SysTryReturn(NID_UI, column >= 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Negative input argument : column(%d)", column); + SysTryReturn(NID_UI, column < __column, E_OUT_OF_RANGE, E_OUT_OF_RANGE, + "[E_OUT_OF_RANGE] Input Argument column over the max column : column(%d), maxColumn(%d)", column, __column); + + ProxyListNode* pNode = GetNode(row, column); + if (pNode == null) + { + rowSize = 1; + colSize = 1; + return E_SUCCESS; + } + TableItemInfo* pItemInfo = dynamic_cast (pNode->GetItemInfo()); + if (pItemInfo == null || pItemInfo->__enable == false) + { + return E_INVALID_STATE; + } + + if (pItemInfo->__merged == false) + { + rowSize = 1; + colSize = 1; + } + else + { + rowSize = pItemInfo->__mergeEndPoint.x - row + 1; + colSize = pItemInfo->__mergeEndPoint.y - column + 1; + } + + return E_SUCCESS; +} + +ProxyListNode* +TableLayout::GetNode(int row, int column) const +{ + ProxyList* pProxyList = GetProxyList(); + SysAssertf(pProxyList != null, "ProxyList is invalid"); + + ProxyListNode* pCurNode = pProxyList->GetFirstNode(); + TableItemInfo* pItemInfo = null; + int rowIndex = 0; + int columnIndex = 0; + while (pCurNode) + { + pItemInfo = dynamic_cast (pCurNode->GetItemInfo()); + if (pItemInfo != null) + { + rowIndex = GetRow(pItemInfo->__id); + columnIndex = GetColumn(pItemInfo->__id); + if (row == rowIndex && column == columnIndex) + { + return pCurNode; + } + } + pCurNode = pProxyList->GetNextNode(*pCurNode); + } + return null; +} + +int +TableLayout::GetRow(int id) const +{ + return id >> 16; +} + +int +TableLayout::GetColumn(int id) const +{ + return id & 0x0000FFFF; +} + +int +TableLayout::MakeCellID(int row, int column) const +{ + return (row << 16) | (column & 0x0000FFFF); +} + +} // Tizen::Ui::_Layout +} // Tizen::Ui +} // Osp diff --git a/src/ui/resource/FUi_ResourceAccessibilityConfig.cpp b/src/ui/resource/FUi_ResourceAccessibilityConfig.cpp new file mode 100644 index 0000000..1d2a52a --- /dev/null +++ b/src/ui/resource/FUi_ResourceAccessibilityConfig.cpp @@ -0,0 +1,42 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(ACCESSIBILITY); +{ + ADD_COLOR_CONFIG(TITLE_TEXT, #0xFF4C4C4C); + ADD_COLOR_CONFIG(POINT_TEXT, #0xFF3B73B6); + ADD_COLOR_CONFIG(TEXT, #0xFF000000); + + ADD_IMAGE_CONFIG(POPUP_BG,#TTS_popup_bg.9.png); + ADD_IMAGE_CONFIG(FOCUS,#TTS_focus.9.png); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(TITLE_FONT_SIZE, 40); + ADD_SHAPE_CONFIG(TEXT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(POPUP_WIDTH, 624); + ADD_SHAPE_CONFIG(TOP_MARGIN, 6); + ADD_SHAPE_CONFIG(BOTTON_MARGIN, 4); + ADD_SHAPE_CONFIG(SIDE_MARGIN, 24); + ADD_SHAPE_CONFIG(TITLE_HEIGHT, 63); + ADD_SHAPE_CONFIG(TEXT_TOP_MARGIN, 16); + ADD_SHAPE_CONFIG(TEXT_HEGIHT,42); + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(ACCESSIBILITY); + diff --git a/src/ui/resource/FUi_ResourceButtonConfig.cpp b/src/ui/resource/FUi_ResourceButtonConfig.cpp new file mode 100644 index 0000000..0f8c766 --- /dev/null +++ b/src/ui/resource/FUi_ResourceButtonConfig.cpp @@ -0,0 +1,68 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceButtonConfig.cpp + * @brief This is the implementation file for the properties of Button. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(BUTTON); +{ + ADD_COLOR_CONFIG(BG_NORMAL, $W011); + ADD_COLOR_CONFIG(BG_DISABLED, $W011); + ADD_COLOR_CONFIG(BG_PRESSED, $B042); + ADD_COLOR_CONFIG(BG_HIGHLIGHTED, $B042); + + ADD_COLOR_CONFIG(TEXT_NORMAL, $F031L1); + ADD_COLOR_CONFIG(TEXT_DISABLED, $F031L1D); + ADD_COLOR_CONFIG(TEXT_PRESSED, $F031L1P); + ADD_COLOR_CONFIG(TEXT_HIGHLIGHTED, $F031L1P); + + ADD_IMAGE_CONFIG(BG_NORMAL, #00_button_02.9.png); + ADD_IMAGE_CONFIG(BG_DISABLED, #00_button_02.9.png); + ADD_IMAGE_CONFIG(BG_PRESSED, #00_button_02.9.png); + ADD_IMAGE_CONFIG(BG_HIGHLIGHTED, #00_button_02.9.png); + + ADD_IMAGE_CONFIG(BG_EFFECT_NORMAL, #00_button_02_ef.9.png); + ADD_IMAGE_CONFIG(BG_EFFECT_DISABLED, #00_button_03_dim_ef.9.png); + ADD_IMAGE_CONFIG(BG_EFFECT_PRESSED, #00_button_02_ef_press.9.png); + ADD_IMAGE_CONFIG(BG_EFFECT_HIGHLIGHTED, #00_button_02_ef_press.9.png); + + START_UI_CONFIG_MODE(480x800); + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(DEFAULT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(MULTILINE_FONT_SIZE, 28); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 12); + ADD_SHAPE_CONFIG(TOP_MARGIN, 4); + ADD_FIXED_VALUE_CONFIG(TEXT_MAX_LENGTH, 60); + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + ADD_SHAPE_CONFIG(DEFAULT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(MULTILINE_FONT_SIZE, 28); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 12); + ADD_SHAPE_CONFIG(TOP_MARGIN, 4); + ADD_FIXED_VALUE_CONFIG(TEXT_MAX_LENGTH, 60); + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(BUTTON); diff --git a/src/ui/resource/FUi_ResourceCheckButtonConfig.cpp b/src/ui/resource/FUi_ResourceCheckButtonConfig.cpp new file mode 100644 index 0000000..c9bb3ca --- /dev/null +++ b/src/ui/resource/FUi_ResourceCheckButtonConfig.cpp @@ -0,0 +1,189 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceCheckButtonConfig.cpp + * @brief This is the implementation file for the properties of CheckButton. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(CHECKBUTTON); +{ + ADD_COLOR_CONFIG(BG_NORMAL, $B0217); + ADD_COLOR_CONFIG(BG_DISABLED, $B0217); + ADD_COLOR_CONFIG(BG_PRESSED, $B041); + ADD_COLOR_CONFIG(BG_HIGHLIGHTED, $B041); + ADD_COLOR_CONFIG(BG_SELECTED, $B041); + + ADD_COLOR_CONFIG(TEXT_NORMAL, $F011L1); + ADD_COLOR_CONFIG(TEXT_DISABLED, $F011L3); + ADD_COLOR_CONFIG(TEXT_PRESSED, $F031L1P); + ADD_COLOR_CONFIG(TEXT_HIGHLIGHTED, $F011L1P); + ADD_COLOR_CONFIG(TEXT_SELECTED, $F011L1P); + + ADD_COLOR_CONFIG(TITLE_TEXT_NORMAL, $F011L1); + ADD_COLOR_CONFIG(TITLE_TEXT_DISABLED, $F011L3); + ADD_COLOR_CONFIG(TITLE_TEXT_PRESSED, $F031L1P); + ADD_COLOR_CONFIG(TITLE_TEXT_HIGHLIGHTED, $F011L1P); + ADD_COLOR_CONFIG(TITLE_TEXT_SELECTED, $F011L1P); + + ADD_COLOR_CONFIG(DETAILED_ICON_BG_NORMAL, $W011); + ADD_COLOR_CONFIG(DETAILED_ICON_BG_DISABLED, $W011); + ADD_COLOR_CONFIG(DETAILED_ICON_BG_PRESSED, $B042); + ADD_COLOR_CONFIG(DETAILED_ICON_BG_HIGHLIGHTED, $B042); + ADD_COLOR_CONFIG(DETAILED_ICON_BG_SELECTED, $B042); + + ADD_COLOR_CONFIG(DETAILED_ICON_TEXT_NORMAL, $F032L1); + ADD_COLOR_CONFIG(DETAILED_ICON_TEXT_DISABLED, $F032L1); + ADD_COLOR_CONFIG(DETAILED_ICON_TEXT_PRESSED, $F032L1P); + ADD_COLOR_CONFIG(DETAILED_ICON_TEXT_HIGHLIGHTED, $F032L1P); + ADD_COLOR_CONFIG(DETAILED_ICON_TEXT_SELECTED, $F032L1P); + + ADD_IMAGE_CONFIG(BG_NORMAL, #00_list_group_bg.9.png); + ADD_IMAGE_CONFIG(BG_DISABLED, #00_list_group_bg.9.png); + ADD_IMAGE_CONFIG(BG_PRESSED, #00_list_group_bg.9.png); + ADD_IMAGE_CONFIG(BG_HIGHLIGHTED, #00_list_group_bg.9.png); + ADD_IMAGE_CONFIG(BG_SELECTED, #00_list_group_bg.9.png); + + ADD_IMAGE_CONFIG(BG_EFFECT_NORMAL, #00_list_group_bg_ef.9.png); //not supported by theme + ADD_IMAGE_CONFIG(BG_EFFECT_PRESSED, #00_list_group_bg_ef.9.png); //not supported by theme + + ADD_IMAGE_CONFIG(TOP_BG_NORMAL, #00_list_group_bg_top.9.png); + ADD_IMAGE_CONFIG(TOP_BG_DISABLED, #00_list_group_bg_top.9.png); + ADD_IMAGE_CONFIG(TOP_BG_PRESSED, #00_list_group_bg_top.9.png); + ADD_IMAGE_CONFIG(TOP_BG_HIGHLIGHTED, #00_list_group_bg_top.9.png); + ADD_IMAGE_CONFIG(TOP_BG_SELECTED, #00_list_group_bg_top.9.png); + + ADD_IMAGE_CONFIG(TOP_BG_EFFECT_NORMAL, #00_list_group_bg_top_ef.9.png); //not supported by theme + ADD_IMAGE_CONFIG(TOP_BG_EFFECT_PRESSED, #00_list_group_bg_top_ef.9.png); //not supported by theme + + ADD_IMAGE_CONFIG(CENTER_BG_NORMAL, #00_list_group_bg_center.9.png); + ADD_IMAGE_CONFIG(CENTER_BG_DISABLED, #00_list_group_bg_center.9.png); + ADD_IMAGE_CONFIG(CENTER_BG_PRESSED, #00_list_group_bg_center.9.png); + ADD_IMAGE_CONFIG(CENTER_BG_HIGHLIGHTED, #00_list_group_bg_center.9.png); + ADD_IMAGE_CONFIG(CENTER_BG_SELECTED, #00_list_group_bg_center.9.png); + + ADD_IMAGE_CONFIG(CENTER_BG_EFFECT_NORMAL, #00_list_group_bg_center_ef.9.png); //not supported by theme + ADD_IMAGE_CONFIG(CENTER_BG_EFFECT_PRESSED, #00_list_group_bg_center_ef.9.png); //not supported by theme + + ADD_IMAGE_CONFIG(BOTTOM_BG_NORMAL, #00_list_group_bg_bottom.9.png); + ADD_IMAGE_CONFIG(BOTTOM_BG_DISABLED, #00_list_group_bg_bottom.9.png); + ADD_IMAGE_CONFIG(BOTTOM_BG_PRESSED, #00_list_group_bg_bottom.9.png); + ADD_IMAGE_CONFIG(BOTTOM_BG_HIGHLIGHTED, #00_list_group_bg_bottom.9.png); + ADD_IMAGE_CONFIG(BOTTOM_BG_SELECTED, #00_list_group_bg_bottom.9.png); + + ADD_IMAGE_CONFIG(BOTTOM_BG_EFFECT_NORMAL, #00_list_group_bg_bottom_ef.9.png); //not supported by theme + ADD_IMAGE_CONFIG(BOTTOM_BG_EFFECT_PRESSED, #00_list_group_bg_bottom_ef.9.png); //not supported by theme + + ADD_IMAGE_CONFIG(MARK_ICON_BG_NORMAL, #00_check_bg.png); + ADD_IMAGE_CONFIG(MARK_ICON_BG_DISABLED, #00_check_bg_dim.png); + ADD_IMAGE_CONFIG(MARK_ICON_BG_PRESSED, #00_check_bg_press.png); + ADD_IMAGE_CONFIG(MARK_ICON_BG_HIGHLIGHTED, #00_check_bg_press.png); + ADD_IMAGE_CONFIG(MARK_ICON_BG_SELECTED, #00_check_bg_press.png); + + ADD_IMAGE_CONFIG(MARK_ICON_NORMAL, #00_check_checking.png); + ADD_IMAGE_CONFIG(MARK_ICON_DISABLED, #00_check_checking_dim.png); + ADD_IMAGE_CONFIG(MARK_ICON_PRESSED, #00_check_checking.png); + ADD_IMAGE_CONFIG(MARK_ICON_HIGHLIGHTED, #00_check_checking.png); + ADD_IMAGE_CONFIG(MARK_ICON_SELECTED, #00_check_checking.png); + + ADD_IMAGE_CONFIG(ONOFF_ICON_BG_NORMAL, #00_button_radio.png); + ADD_IMAGE_CONFIG(ONOFF_ICON_BG_DISABLED, #00_button_radio_dim.png); + ADD_IMAGE_CONFIG(ONOFF_ICON_BG_PRESSED, #00_button_radio_press.png); + ADD_IMAGE_CONFIG(ONOFF_ICON_BG_HIGHLIGHTED, #00_button_radio_press.png); + ADD_IMAGE_CONFIG(ONOFF_ICON_BG_SELECTED, #00_button_radio_press.png); + + ADD_IMAGE_CONFIG(ONOFF_ICON_NORMAL, #00_button_radio_select.png); + ADD_IMAGE_CONFIG(ONOFF_ICON_DISABLED, #00_button_radio_radio_select_dim.png); + ADD_IMAGE_CONFIG(ONOFF_ICON_PRESSED, #00_button_radio_select.png); + ADD_IMAGE_CONFIG(ONOFF_ICON_HIGHLIGHTED, #00_button_radio_select.png); + ADD_IMAGE_CONFIG(ONOFF_ICON_SELECTED, #00_button_radio_select.png); + + ADD_IMAGE_CONFIG(ONOFF_SLIDING_ICON_ON_NORMAL, #00_button_on_temp.png); + ADD_IMAGE_CONFIG(ONOFF_SLIDING_ICON_ON_DISABLED, #00_button_on_dim_temp.png); + ADD_IMAGE_CONFIG(ONOFF_SLIDING_ICON_ON_PRESSED, #00_button_on_temp.png); + ADD_IMAGE_CONFIG(ONOFF_SLIDING_ICON_ON_HIGHLIGHTED, #00_button_on_temp.png); + ADD_IMAGE_CONFIG(ONOFF_SLIDING_ICON_ON_SELECTED, #00_button_on_temp.png); + + ADD_IMAGE_CONFIG(ONOFF_SLIDING_ICON_OFF_NORMAL, #00_button_off_temp.png); + ADD_IMAGE_CONFIG(ONOFF_SLIDING_ICON_OFF_DISABLED, #00_button_off_dim_temp.png); + ADD_IMAGE_CONFIG(ONOFF_SLIDING_ICON_OFF_PRESSED, #00_button_off_temp.png); + ADD_IMAGE_CONFIG(ONOFF_SLIDING_ICON_OFF_HIGHLIGHTED, #00_button_off_temp.png); + ADD_IMAGE_CONFIG(ONOFF_SLIDING_ICON_OFF_SELECTED, #00_button_off_temp.png); + + ADD_IMAGE_CONFIG(DETAILED_BG_NORMAL, #00_circle_bg.png); + ADD_IMAGE_CONFIG(DETAILED_BG_DISABLED, #00_circle_bg.png); + ADD_IMAGE_CONFIG(DETAILED_BG_PRESSED, #00_circle_bg.png); + ADD_IMAGE_CONFIG(DETAILED_BG_HIGHLIGHTED, #00_circle_bg.png); + ADD_IMAGE_CONFIG(DETAILED_BG_SELECTED, #00_circle_bg.png); + + ADD_IMAGE_CONFIG(DETAILED_BG_EFFECT_NORMAL, #00_circle_bg_ef.png); //not supported by theme + ADD_IMAGE_CONFIG(DETAILED_BG_EFFECT_DISABLED, #00_circle_bg_ef_dim.png); //not supported by theme + ADD_IMAGE_CONFIG(DETAILED_BG_EFFECT_PRESSED, #00_circle_bg_ef_press); //not supported by theme + ADD_IMAGE_CONFIG(DETAILED_BG_EFFECT_HIGHLIGHTED, #00_circle_bg_ef_press); //not supported by theme + ADD_IMAGE_CONFIG(DETAILED_BG_EFFECT_SELECTED, #00_circle_bg_ef_press); //not supported by theme + + ADD_IMAGE_CONFIG(DETAILED_ICON_NORMAL, #00_button_right.png); + ADD_IMAGE_CONFIG(DETAILED_ICON_DISABLED, #00_button_right.png); + ADD_IMAGE_CONFIG(DETAILED_ICON_PRESSED, #00_button_right.png); + ADD_IMAGE_CONFIG(DETAILED_ICON_HIGHLIGHTED, #00_button_right.png); + ADD_IMAGE_CONFIG(DETAILED_ICON_SELECTED, #00_button_right.png); + + ADD_IMAGE_CONFIG(DETAILED_ICON_EFFECT_NORMAL, # #00_button_right_ef.png); //not supported by theme + ADD_IMAGE_CONFIG(DETAILED_ICON_EFFECT_PRESSED, # #00_button_right_ef.png); //not supported by theme + + START_UI_CONFIG_MODE(480x800); + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(TITLE_TEXT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(TEXT_FONT_SIZE, 44); + ADD_SHAPE_CONFIG(TITLE_TEXT_HEIGHT, 48); + ADD_SHAPE_CONFIG(TEXT_HEIGHT, 60); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 26); + ADD_SHAPE_CONFIG(TOP_MARGIN, 10); + ADD_SHAPE_CONFIG(MARK_BITMAP_WIDTH, 64); + ADD_SHAPE_CONFIG(MARK_BITMAP_HEIGHT, 64); + ADD_SHAPE_CONFIG(ONOFF_SLIDING_BITMAP_WIDTH, 128); + ADD_SHAPE_CONFIG(ONOFF_SLIDING_BITMAP_HEIGHT, 66); + ADD_SHAPE_CONFIG(DETAILED_BITMAP_WIDTH, 74); + ADD_SHAPE_CONFIG(DETAILED_BITMAP_HEIGHT, 74); + ADD_FIXED_VALUE_CONFIG(TITLE_TEXT_MAX_LENGTH, 60); + ADD_FIXED_VALUE_CONFIG(TEXT_MAX_LENGTH, 60); + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + ADD_SHAPE_CONFIG(TITLE_TEXT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(TEXT_FONT_SIZE, 44); + ADD_SHAPE_CONFIG(TITLE_TEXT_HEIGHT, 48); + ADD_SHAPE_CONFIG(TEXT_HEIGHT, 60); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 26); + ADD_SHAPE_CONFIG(TOP_MARGIN, 10); + ADD_SHAPE_CONFIG(MARK_BITMAP_WIDTH, 64); + ADD_SHAPE_CONFIG(MARK_BITMAP_HEIGHT, 64); + ADD_SHAPE_CONFIG(ONOFF_SLIDING_BITMAP_WIDTH, 128); + ADD_SHAPE_CONFIG(ONOFF_SLIDING_BITMAP_HEIGHT, 66); + ADD_SHAPE_CONFIG(DETAILED_BITMAP_WIDTH, 74); + ADD_SHAPE_CONFIG(DETAILED_BITMAP_HEIGHT, 74); + ADD_FIXED_VALUE_CONFIG(TITLE_TEXT_MAX_LENGTH, 60); + ADD_FIXED_VALUE_CONFIG(TEXT_MAX_LENGTH, 60); + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(CHECKBUTTON); diff --git a/src/ui/resource/FUi_ResourceColorPickerConfig.cpp b/src/ui/resource/FUi_ResourceColorPickerConfig.cpp new file mode 100644 index 0000000..48c9d92 --- /dev/null +++ b/src/ui/resource/FUi_ResourceColorPickerConfig.cpp @@ -0,0 +1,91 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceColorPickerConfig.cpp + * @brief This is the implementation file for the color, image and shape properties of ColorPicker. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(COLORPICKER); +{ + ADD_COLOR_CONFIG(DIVIDER_NORMAL, $B0231); + ADD_COLOR_CONFIG(ARROW_BUTTON_BG_NORMAL, $W011); + ADD_COLOR_CONFIG(ARROW_BUTTON_BG_PRESSED, $B042); + ADD_COLOR_CONFIG(ARROW_BUTTON_BG_DISABLED, $W011); + ADD_COLOR_CONFIG(ARROW_BUTTON_NORMAL, $F032L1); + ADD_COLOR_CONFIG(ARROW_BUTTON_PRESSED, $F032L1P); + ADD_COLOR_CONFIG(ARROW_BUTTON_DISABLED, $F031L1D); + + ADD_IMAGE_CONFIG(HUE_BAR_PORTRAIT_NORMAL, #00_color_picker_color.png); + ADD_IMAGE_CONFIG(LUMINANCE_BAR_PORTRAIT_NORMAL, #00_color_picker_brightness.png); + ADD_IMAGE_CONFIG(SATURATION_BAR_PORTRAIT_NORMAL, #00_color_picker_saturation.png); + ADD_IMAGE_CONFIG(ARROW_BUTTON_BG_NORMAL, #00_button_01.9.png); + ADD_IMAGE_CONFIG(ARROW_BUTTON_BG_PRESSED, #00_button_01.9.png); + ADD_IMAGE_CONFIG(ARROW_BUTTON_BG_DISABLED, #00_button_01.9.png); + ADD_IMAGE_CONFIG(ARROW_BUTTON_BG_EFFECT_NORMAL, #00_button_01_ef.9.png); + ADD_IMAGE_CONFIG(ARROW_BUTTON_BG_EFFECT_PRESSED, #00_button_01_ef_press.9.png); + ADD_IMAGE_CONFIG(ARROW_BUTTON_BG_EFFECT_DISABLED, #00_button_01_ef_dim.9.png); + ADD_IMAGE_CONFIG(LEFT_ARROW_BUTTON_NORMAL, #00_button_left.png); + ADD_IMAGE_CONFIG(LEFT_ARROW_BUTTON_PRESSED, #00_button_left.png); + ADD_IMAGE_CONFIG(LEFT_ARROW_BUTTON_DISABLED, #00_button_left.png); + ADD_IMAGE_CONFIG(RIGHT_ARROW_BUTTON_NORMAL, #00_button_right.png); + ADD_IMAGE_CONFIG(RIGHT_ARROW_BUTTON_PRESSED, #00_button_right.png); + ADD_IMAGE_CONFIG(RIGHT_ARROW_BUTTON_DISABLED, #00_button_right.png); + ADD_IMAGE_CONFIG(HANDLER_NORMAL, #00_color_picker_focus.png); + ADD_IMAGE_CONFIG(BAR_BG_PORTRAIT_NORMAL, #00_color_picker_custom_color.png); + ADD_IMAGE_CONFIG(HUE_BAR_LANDSCAPE_NORMAL, #00_color_picker_color_h.png); + ADD_IMAGE_CONFIG(LUMINANCE_BAR_LANDSCAPE_NORMAL, #00_color_picker_brightness_h.png); + ADD_IMAGE_CONFIG(SATURATION_BAR__LANDSCAPE_NORMAL, #00_color_picker_saturation_h.png); + ADD_IMAGE_CONFIG(BAR_BG_LANDSCAPE_NORMAL, #00_color_picker_custom_color_h.png); + + START_UI_CONFIG_MODE(800x480); + { + ADD_DIMENSION_CONFIG(DEFAULT_SIZE, 800, 225); + } + END_UI_CONFIG_MODE(800x480); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_SHAPE_CONFIG(ARROW_BUTTON_LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(ARROW_BUTON_TOP_MARGIN, 19); + ADD_SHAPE_CONFIG(BAR_TOP_MARGIN, 26); + ADD_SHAPE_CONFIG(BAR_LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(SLIDER_HEIGHT, 60); + ADD_SHAPE_CONFIG(ARROW_BUTTON_WIDTH, 74); + ADD_SHAPE_CONFIG(ARROW_BUTTON_HEIGHT, 74); + ADD_SHAPE_CONFIG(HANDLER_WIDTH, 22); + ADD_SHAPE_CONFIG(HANDLER_HEIGHT, 70); + ADD_SHAPE_CONFIG(BLOCK_HEIGHT, 112); + ADD_FIXED_VALUE_CONFIG(BLOCK_MARGIN, 1); + ADD_SHAPE_CONFIG(BAR_WIDTH, 476); + ADD_SHAPE_CONFIG(DIVIDER_MARGIN, 16); + ADD_SHAPE_CONFIG(DIVIDER_WIDTH, 656); + ADD_DIMENSION_CONFIG(DEFAULT_SIZE, 688, 338); + } + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + { + ADD_SHAPE_CONFIG(ARROW_BUTTON_LEFT_MARGIN, 184); + ADD_SHAPE_CONFIG(BAR_WIDTH, 700); + ADD_SHAPE_CONFIG(DIVIDER_WIDTH, 1216); + ADD_DIMENSION_CONFIG(DEFAULT_SIZE, 1248, 338); + } + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(COLORPICKER); diff --git a/src/ui/resource/FUi_ResourceConfigLoader.cpp b/src/ui/resource/FUi_ResourceConfigLoader.cpp new file mode 100644 index 0000000..d2c5fa9 --- /dev/null +++ b/src/ui/resource/FUi_ResourceConfigLoader.cpp @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include "FUi_ResourceConfigLoader.h" + +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Ui { namespace _Resource { + +ConfigLoader* pColorLoader = null; + +ConfigLoader* +ConfigLoader::GetInstance(void) +{ + static pthread_once_t onceBlock = PTHREAD_ONCE_INIT; + + if (pColorLoader == null) + { + pthread_once(&onceBlock, CreateInstance); + } + return pColorLoader; +} + +void +ConfigLoader::CreateInstance(void) +{ + static ConfigLoader loader; + pColorLoader = &loader; +} + +ConfigLoader::~ConfigLoader(void) +{ + __itemList.RemoveAll(); +} +void +ConfigLoader::AddInitFunc(_Init_Func func) +{ + __itemList.Add(func); +} +int +ConfigLoader::GetInitFuncCount(void) const +{ + return __itemList.GetCount(); +} +bool +ConfigLoader::GetInitFunc(int index, _Init_Func& func) const +{ + int count = __itemList.GetCount(); + if (index >= count) + { + return null; + } + return __itemList.GetAt(index, func); +} +ConfigLoader::ConfigLoader(void) + : __itemList() +{ +} +}}}//Tizen::Ui::_Resource diff --git a/src/ui/resource/FUi_ResourceConfigLoader.h b/src/ui/resource/FUi_ResourceConfigLoader.h new file mode 100644 index 0000000..c881672 --- /dev/null +++ b/src/ui/resource/FUi_ResourceConfigLoader.h @@ -0,0 +1,58 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceConfigLoader.h + * @brief This is the header file for ConfigLoader class. + * @version 3.0 + * + * This header file contains declaration of ConfigLoader class. + * The ActionEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_INTERNAL_RESOURCE_CONFIG_LOADER_H_ +#define _FUI_INTERNAL_RESOURCE_CONFIG_LOADER_H_ + +#include +#include "FUi_ResourceMapContainer.h" + +namespace Tizen { namespace Base { + class String; +}}// Tizen::Base + +namespace Tizen { namespace Ui { namespace _Resource +{ +typedef bool (*_Init_Func)(MapContainer& table, const Tizen::Base::String& mode); + +class ConfigLoader +{ +public: + void AddInitFunc(_Init_Func func); + int GetInitFuncCount(void) const; + bool GetInitFunc(int index, _Init_Func& func) const; + static ConfigLoader* GetInstance(void); +private: + ConfigLoader(void); + ~ConfigLoader(void); + static void CreateInstance(void); + ConfigLoader(const ConfigLoader&); + ConfigLoader& operator =(const ConfigLoader&); + Tizen::Base::Collection::LinkedListT <_Init_Func> __itemList; +}; +}}}// Tizen::Ui::_Resource + +#endif // _FUI_INTERNAL_RESOURCE_CONFIG_LOADER_H_ \ No newline at end of file diff --git a/src/ui/resource/FUi_ResourceConfigMacro.h b/src/ui/resource/FUi_ResourceConfigMacro.h new file mode 100644 index 0000000..98cc8b0 --- /dev/null +++ b/src/ui/resource/FUi_ResourceConfigMacro.h @@ -0,0 +1,313 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceConfigMacro.h + * @brief This is the header file for resource config macros. + * @version 3.0 + * + * This header file contains declaration of resource config macros.. + * + */ +#ifndef _FUI_RESOURCE_CONFIG_MACRO_H_ +#define _FUI_RESOURCE_CONFIG_MACRO_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_ResourceConfigLoader.h" +#include "FUi_ResourceConfigParser.h" +#include "FUi_ResourceMapContainer.h" + +#define START_UI_CONFIG(control)\ +using namespace Tizen::Base;\ +using namespace Tizen::Base::Collection;\ +using namespace Tizen::Graphics;\ +namespace Tizen { namespace Ui { namespace _Resource\ +{\ +class control ## Config\ +{\ +public:\ + control ## Config(void)\ + {\ + ConfigLoader::GetInstance()->AddInitFunc(control ## Config::Initialize);\ + };\ + ~control ## Config(void){};\ + static bool Initialize(MapContainer & table, const String & mode);\ +private:\ + static const char* GetControlName(void)\ + {\ + return #control;\ + }\ + static String GetCurrentThemeName(void)\ + {\ + return L"";\ + };\ + static String GetAPIVersion(void)\ + {\ + if(Tizen::App::_AppInfo::IsOspCompat())\ + {\ + return L"2.0";\ + }\ + else \ + {\ + return L"";\ + }\ + };\ + static void ConvertStringToColor32(const char* pString, Color& color)\ + {\ + int index = 0;\ + int len = 0;\ + int gap = 0;\ + char ch;\ + unsigned int temp = 0;\ + len = strlen(pString);\ + if (len < 1)\ + {\ + SysLog(NID_UI, "String is empty");\ + return;\ + }\ + for (index = 1; index < len + 1; index++)\ + {\ + ch = pString[index];\ + if ((ch >= '0') && (ch <= '9'))\ + {\ + temp = temp << 4;\ + gap = ch - '0';\ + temp |= gap;\ + }\ + else if ((ch >= 'A') && (ch <= 'F'))\ + {\ + temp = temp << 4;\ + gap = ch - 'A' + 10;\ + temp |= gap;\ + }\ + else if ((ch >= 'a') && (ch <= 'f'))\ + {\ + temp = temp << 4;\ + gap = ch - 'a' + 10;\ + temp |= gap;\ + }\ + }\ + color.SetRGB32(temp, true);\ + };\ + static void AddDimensionConfig(MapContainer & table, const char* key, int width, int height)\ + {\ + Dimension* pDimension = null;\ + ResourceDimensionMap* pDimensionMap = table.GetDimensionMap();\ + if(pDimensionMap != null)\ + {\ + String _key = GetControlName();\ + _key.Append(L"::");\ + _key.Append(key);\ + result r = pDimensionMap->GetValue(_key, pDimension);\ + if(r == E_OBJ_NOT_FOUND)\ + {\ + pDimension = new (std::nothrow) Dimension(width, height);\ + SysAssert(pDimension);\ + pDimensionMap->Add(_key, pDimension);\ + }\ + else if(r == E_SUCCESS)\ + {\ + pDimension->SetSize(width, height);\ + }\ + }\ + };\ + static void AddShapeConfig(MapContainer & table, const char* key, int value)\ + {\ + Integer* pInteger = null;\ + ResourceShapeMap* pShapeMap = table.GetShapeMap();\ + if(pShapeMap != null)\ + {\ + String _key = GetControlName();\ + _key.Append(L"::");\ + _key.Append(key);\ + result r = pShapeMap->GetValue(_key, pInteger);\ + if(r == E_OBJ_NOT_FOUND)\ + {\ + pInteger = new (std::nothrow) Integer(value);\ + SysAssert(pInteger);\ + pShapeMap->Add(_key, pInteger);\ + }\ + else if(r == E_SUCCESS)\ + {\ + *pInteger = value;\ + }\ + }\ + };\ + static void AddFixedValueConfig(MapContainer & table, const char* key, int value)\ + {\ + Integer* pInteger = null;\ + ResourceShapeMap* pFixedValueMap = table.GetFixedValueMap();\ + if(pFixedValueMap != null)\ + {\ + String _key = GetControlName();\ + _key.Append(L"::");\ + _key.Append(key);\ + result r = pFixedValueMap->GetValue(_key, pInteger);\ + if(r == E_OBJ_NOT_FOUND)\ + {\ + pInteger = new (std::nothrow) Integer(value);\ + SysAssert(pInteger);\ + pFixedValueMap->Add(_key, pInteger);\ + }\ + else if(r == E_SUCCESS)\ + {\ + *pInteger = value;\ + }\ + }\ + };\ + static void AddImageConfig(MapContainer & table, const char* key, const char* value)\ + {\ + String* pString = null;\ + ResourceImageMap* pImageMap = table.GetImageMap();\ + if(pImageMap != null)\ + {\ + String _key = GetControlName();\ + _key.Append(L"::");\ + _key.Append(key);\ + result r = pImageMap->GetValue(_key, pString);\ + if(r == E_OBJ_NOT_FOUND)\ + {\ + pString = new (std::nothrow) String(value);\ + SysAssert(pString);\ + pString->SubString(1,*pString);\ + pImageMap->Add(_key, pString);\ + }\ + else if(r == E_SUCCESS)\ + {\ + *pString = value;\ + pString->SubString(1,*pString);\ + }\ + }\ + };\ + static void AddColorConfig(MapContainer & table, const char* key, const char* value)\ + {\ + Color* pColor = null;\ + String _key = L"";\ + result r = E_FAILURE;\ + ResourceColorMap* pColorMap = table.GetColorMap();\ + if(pColorMap != null)\ + {\ + _key = GetControlName();\ + _key.Append(L"::");\ + _key.Append(key);\ + String valueString(value);\ + if((valueString.StartsWith(L"$", 0)))\ + {\ + Color* pColor2 = null;\ + String key2(L"");\ + valueString.SubString(1, key2);\ + if(!(key2.Contains(L"::")))\ + {\ + key2.Insert("DEFAULTCOLORTABLE::",0);\ + }\ + r = pColorMap->GetValue(key2, pColor);\ + if(r != E_SUCCESS)\ + {\ + SysLog(NID_UI,"[OBJ_NOT_FOUND] Resource color code is not valid : %s", value);\ + r = pColorMap->GetValue(L"foreground", pColor);\ + if(r == E_SUCCESS)\ + {\ + pColor2 = new (std::nothrow) Color(*pColor);\ + SysAssert(pColor2);\ + pColorMap->Add(_key, pColor2);\ + }\ + else\ + {\ + pColor2 = new (std::nothrow) Color(0xff000000);\ + SysAssert(pColor2);\ + pColorMap->Add(_key, pColor2);\ + }\ + }\ + else\ + {\ + bool found = false;\ + r = pColorMap->ContainsKey(_key, found);\ + if(found)\ + {\ + pColorMap->SetValue(_key, pColor2);\ + }\ + else\ + {\ + pColor2 = new (std::nothrow) Color(*pColor);\ + SysAssert(pColor2);\ + pColorMap->Add(_key, pColor2);\ + SysLog(NID_UI, "Resource Color is added , key : %ls, value : %x", _key.GetPointer(), pColor2->GetRGB32());\ + }\ + }\ + }\ + else\ + {\ + r = pColorMap->GetValue(_key, pColor);\ + if(r == E_OBJ_NOT_FOUND)\ + {\ + pColor = new (std::nothrow) Color();\ + SysAssert(pColor);\ + ConvertStringToColor32(value,*pColor);\ + pColorMap->Add(_key, pColor);\ + }\ + else if(r == E_SUCCESS)\ + {\ + Color _color;\ + ConvertStringToColor32(value,_color);\ + pColorMap->SetValue(_key, &_color);\ + }\ + }\ + }\ + };\ + control ## Config(const control ## Config &);\ + control ## Config& operator =(const control ## Config&);\ +};\ +bool control ## Config::Initialize(MapContainer & table, const String & mode)\ +{\ + String themeName = GetCurrentThemeName();\ + String apiVer = GetAPIVersion();\ + String __mode = mode;\ + if (themeName.GetLength() > 0)\ + {\ + __mode = __mode + L"_" + themeName;\ + } +#define START_UI_CONFIG_API_VERSION(ver)\ + if(apiVer == ver)\ + { +#define END_UI_CONFIG_API_VERSION(ver)\ + } + +#define START_UI_CONFIG_MODE(_mode)\ + if (__mode == #_mode)\ + { +#define END_UI_CONFIG_MODE(_mode)\ + } + +#define ADD_DIMENSION_CONFIG(key, width, height) AddDimensionConfig(table, #key, width, height); +#define ADD_COLOR_CONFIG(key, value) AddColorConfig(table, #key, #value); +#define ADD_SHAPE_CONFIG(key, value) AddShapeConfig(table, #key, value); +#define ADD_FIXED_VALUE_CONFIG(key, value) AddFixedValueConfig(table, #key, value); +#define ADD_IMAGE_CONFIG(key, value) AddImageConfig(table, #key, #value); + +#define END_UI_CONFIG(control)\ + return true;\ +};\ +control ## Config __config ## control;\ +}}}//Tizen::Ui::_Resource + +#endif // _FUI_RESOURCE_CONFIG_MACRO_H_ diff --git a/src/ui/resource/FUi_ResourceConfigParser.cpp b/src/ui/resource/FUi_ResourceConfigParser.cpp new file mode 100644 index 0000000..0d19ef1 --- /dev/null +++ b/src/ui/resource/FUi_ResourceConfigParser.cpp @@ -0,0 +1,666 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceConfigParser.cpp + * @brief This is the header file for the ConfigParser. + * + * This header file contains the declarations of the ConfigParser. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_ResourceMapContainer.h" +#include "FUi_ResourceConfigParser.h" + +using namespace Tizen::Base; +using namespace Collection; +using namespace Tizen::Io; +using namespace Tizen::Graphics; + +namespace +{ +class _ColorMatchingMapProvider + : public IHashCodeProviderT +{ +public: + _ColorMatchingMapProvider(void) {} + virtual ~_ColorMatchingMapProvider(void) {} + + virtual int GetHashCode(const String& obj) const + { + return obj.GetHashCode(); + } +}; + +class _ColorMatchingMapComparer + : public IComparerT +{ +public: + _ColorMatchingMapComparer(void) {} + virtual ~_ColorMatchingMapComparer(void) {} + virtual result Compare(const String& obj1, const String& obj2, int& cmp) const + { + if (obj1 == obj2) + { + cmp = 0; + return E_SUCCESS; + } + else + { + cmp = -1; + return E_SUCCESS; + } + } +}; +} + +namespace +{ +xmlSAXHandler mySaxHandler = {null, null, null, null, null, null, null, null, null, null, null, null, null, null, + Tizen::Ui::_Resource::ConfigParser::StartSaxFunc, + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null}; +} + +namespace Tizen { namespace Ui { namespace _Resource +{ +ConfigParser* pConfigXmlHandler = null; +HashMapT* pColorMatchingMap = null; + +ConfigParser::ColorMatchingMap::ColorMatchingMap(void) + :HashMapT() + , __pProvider(null) + , __pComparer(null) +{ + __pProvider = new (std::nothrow) _ColorMatchingMapProvider; + SysTryReturnVoidResult(NID_UI, __pProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + __pComparer = new (std::nothrow) _ColorMatchingMapComparer; + SysTryReturnVoidResult(NID_UI, __pComparer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); +} +ConfigParser::ColorMatchingMap::~ColorMatchingMap(void) +{ + result r = E_SUCCESS; + Collection::IMapEnumeratorT< String, String* >* pMapEnum = null; + if (Collection::HashMapT::GetCount() > 0) + { + pMapEnum = Collection::HashMapT::GetMapEnumeratorN(); + SysTryReturn(NID_UI_ANIM, (pMapEnum != null), , E_SYSTEM, "[E_SYSTEM] System Error."); + + Collection::MapEntryT< String, String* > value; + while ((pMapEnum->MoveNext() == E_SUCCESS)) + { + r = pMapEnum->GetCurrent(value); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + String* pObj = value.GetValue(); + delete pObj; + } + Collection::HashMapT::RemoveAll(); + } + //fall through + CATCH: + delete pMapEnum; + delete __pProvider; + __pProvider = null; + delete __pComparer; + __pComparer = null; +} +bool +ConfigParser::ColorMatchingMap::Initialize(const String& version, const String& dVersion) +{ + if (HashMapT::Construct(0,0,*__pProvider, *__pComparer) != E_SUCCESS) + { + return false; + } + /* + if(version == L"beta1") + { + Add(L"W0612", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_text_disabled")); + Add(L"B0622", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_list_item_divider_01")); + Add(L"B0231", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_divider_line_01")); + Add(L"B022", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_divider_line_01")); + + Add(L"B011", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_bg")); + Add(L"B012", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_group_list_bg")); + Add(L"B013", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_black")); + Add(L"B014", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_white")); + Add(L"B015", new (std::nothrow) String(L"DEFAULTCOLORTABLE::form_list_reorder_bg")); + Add(L"B0211", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_bg")); + Add(L"B0211D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_bg_disabled")); + Add(L"B0212", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_context_item_bg")); + Add(L"B0213", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_grid_item_bg")); + Add(L"B0214", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_2nd_depth_item_bg")); + Add(L"B0215", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_bg")); + Add(L"B0216", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_select_all_item_bg")); + Add(L"B0217", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_bg")); + Add(L"B0217D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_bg_disabled")); + Add(L"B0221", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_divider_line_01")); + Add(L"B0222", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_divider_line_02")); + Add(L"B0231L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_divider_line_01")); + Add(L"B0231L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_divider_line_02")); + Add(L"B0232", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_bar")); + Add(L"B0233", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_item_top_line")); + Add(L"B031", new (std::nothrow) String(L"DEFAULTCOLORTABLE::indicator_bg")); + Add(L"B041", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_bg_pressed")); + Add(L"B042", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_item_bg_pressed")); + Add(L"B043", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_item_bg_pressed")); + Add(L"B044", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_item_bg_pressed")); + Add(L"B0511", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_bg")); + Add(L"B0512", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_optiontray_bg")); + Add(L"B0513", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_bg")); + Add(L"B0514", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_item_bg")); + Add(L"B0514P1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_item_bg_selected")); + Add(L"B0514P2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_item_bg_edit")); + Add(L"B0515", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_toolbar_bg")); + Add(L"B0516", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_toolbar_item_bg_pressed")); + Add(L"B0517", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_tab_item_bg")); + Add(L"B0517P1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_tab_item_selected")); + Add(L"B0517P2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_tab_item_bg_edit")); + Add(L"B0518", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_item_bg")); + Add(L"B0518P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_bg")); + Add(L"B0520", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_bg_normal")); + Add(L"B0520P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_bg_pressed")); + Add(L"B052L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_item_normal")); + Add(L"B052L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_item_selected")); + Add(L"B052L1D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_item_disabled")); + Add(L"B052L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_item_normal")); + Add(L"B052L2P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_more_icon_pressed")); + Add(L"B052L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_segment_font_normal")); + Add(L"B052L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_text_normal")); + Add(L"B052L4P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_text_pressed")); + Add(L"B052L4D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_text_disabled")); + Add(L"B052L5", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_title_text_normal")); + Add(L"B052L6", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_text_normal")); + Add(L"B052L6P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_tab_text_pressed")); + Add(L"B052L8", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_footer_text_normal")); + Add(L"B052L8P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_footer_text_pressed")); + Add(L"B052L8D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_footer_text_disabled")); + Add(L"B052L9", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_icon_normal")); + Add(L"B052L9P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_icon_pressed")); + Add(L"B052L9D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_softkey_item_icon_disabled")); + Add(L"B0531", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_segment_item_bg_normal")); + Add(L"B0532", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_segment_item_bg_selected")); + Add(L"B0533", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_segment_item_bg_normal")); + Add(L"B0534", new (std::nothrow) String(L"DEFAULTCOLORTABLE::footer_segment_item_bg_selected")); + Add(L"B0535", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_segment_item_bg_normal")); + Add(L"B0536", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_segment_item_bg_selected")); + Add(L"B0537", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_expandable_line")); + Add(L"B0545", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_button_item_bg_pressed")); + Add(L"B0556", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_item_bg")); + Add(L"B0557", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_item_bg_normal")); + Add(L"B0558", new (std::nothrow) String(L"DEFAULTCOLORTABLE::header_translucent_item_bg_pressed")); + Add(L"B061L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_bg")); + Add(L"B061L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_title_bg")); + Add(L"B061L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_bottom_bg")); + Add(L"B061L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_bg")); + Add(L"B0621", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_list_item_divider")); + Add(L"B0622L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_list_item_divider_01")); + Add(L"B0622L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_list_item_divider_02")); + Add(L"B0623L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_grid_item_divider_01")); + Add(L"B0623L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_grid_item_divider_02")); + Add(L"B063L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_text")); + Add(L"B063L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_item_text_pressed")); + Add(L"B063L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::ticker_detail_text")); + Add(L"B063L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_progress_text")); + Add(L"B063L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_title_text")); + Add(L"B063L5", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_item_text_normal")); + Add(L"B063L5D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::contextmenu_item_text_disabled")); + Add(L"B071", new (std::nothrow) String(L"DEFAULTCOLORTABLE::scroll_bar_bg")); + Add(L"B0721", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_text_normal")); + Add(L"B0722", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_text_selected")); + Add(L"B0723", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_bg")); + Add(L"B0724", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_line_01")); + Add(L"B0725", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_index_bar_line_02")); + Add(L"B0731", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_popup_bg")); + Add(L"B0732", new (std::nothrow) String(L"DEFAULTCOLORTABLE::fastscroll_popup_text")); + Add(L"B0741", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_text_normal")); + Add(L"B0742", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_text_selected")); + Add(L"B0743", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_bg")); + Add(L"B0744", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_line_01")); + Add(L"B0745", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_index_bar_line_02")); + Add(L"B0751", new (std::nothrow) String(L"DEFAULTCOLORTABLE::old_fastscroll_popup_bg")); + Add(L"F011L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_normal")); + Add(L"F011L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_pressed")); + Add(L"F011L1D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_disabled")); + Add(L"F011L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sub_text_setting_normal")); + Add(L"F011L2D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sub_text_setting_disabled")); + Add(L"F011L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sub_text_title_normal")); + Add(L"F011L3D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sub_text_title_disabled")); + Add(L"F011L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_read_normal")); + Add(L"F011L4D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_read_disabled")); + Add(L"F011L5", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_title_text")); + Add(L"F011L6", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_no_content_text")); + Add(L"F011L7", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_3line_2nd_text_normal")); + Add(L"F011L7D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_3line_2nd_text_disabled")); + Add(L"F011L8", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_invalid")); + Add(L"F011L9", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_text_white")); + Add(L"F011L10", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_bubble_text")); + Add(L"F011L11", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_contact_text")); + Add(L"F011L12", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_name_text")); + Add(L"F011L13", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_edit_mode_text_01")); + Add(L"F011L14", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_edit_mode_text_02")); + Add(L"F011L15", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_time_failed_text")); + Add(L"F011L16", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_time_sent_text")); + Add(L"F011L17", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_time_receive_text")); + Add(L"F011L18", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_date_text")); + Add(L"F011L19", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_group_chat_name_text")); + Add(L"F011L20", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_sweep_text")); + Add(L"F011L21", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_help_text")); + Add(L"F011L22", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_message_help_text")); + Add(L"F021L1i", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_icon_normal")); + Add(L"F021L1iP", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_icon_pressed")); + Add(L"F021L1iD", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_icon_disabled")); + Add(L"F022L1i", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_star_icon_normal")); + Add(L"F022L2i", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_star_icon_selected")); + Add(L"F031L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_text_item_normal")); + Add(L"F031L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_text_item_pressed")); + Add(L"F031L1D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_text_item_disabled")); + Add(L"F031L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_text_normal")); + Add(L"F031L3P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_text_pressed")); + Add(L"F031L3D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_text_disabled")); + Add(L"F032L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_icon_item_normal")); + Add(L"F032L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_icon_item_pressed")); + Add(L"F032L1D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_icon_item_disabled")); + Add(L"F032L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::warning_font_icon_normal")); + Add(L"F032L2P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::warning_font_icon_pressed")); + Add(L"F032L2D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::warning_font_icon_disabled")); + Add(L"F041i", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_icon_normal")); + Add(L"F041iD", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_icon_disabled")); + Add(L"F051", new (std::nothrow) String(L"DEFAULTCOLORTABLE::editfield_guide_text")); + Add(L"F052", new (std::nothrow) String(L"DEFAULTCOLORTABLE::editfield_cursor")); + Add(L"W011", new (std::nothrow) String(L"DEFAULTCOLORTABLE::button_bg")); + Add(L"W012", new (std::nothrow) String(L"DEFAULTCOLORTABLE::popup_button_bg")); + Add(L"W013", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_context_item_button_bg")); + Add(L"W0141", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_context_delete_button_bg_normal")); + Add(L"W0141P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_context_delete_button_bg_pressed")); + Add(L"W021L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_bg_normal")); + Add(L"W021L1P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_bg_pressed")); + Add(L"W021L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_line_normal")); + Add(L"W021L2P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_line_pressed")); + Add(L"W021L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_text_normal")); + Add(L"W021L3P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_index_section_title_text_pressed")); + Add(L"W031", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_field_bg_normal")); + Add(L"W031D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_field_bg_disabled")); + Add(L"W032", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_text_normal")); + Add(L"W032D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::searchbar_text_disabled")); + Add(L"W041", new (std::nothrow) String(L"DEFAULTCOLORTABLE::editfield_bg")); + Add(L"W0611", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_text")); + Add(L"W0611D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_text_disabled")); + Add(L"W062L1", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_bar_bg")); + Add(L"W062L2", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_bar")); + Add(L"W062L3", new (std::nothrow) String(L"DEFAULTCOLORTABLE::progress_circle_bar_bg")); + Add(L"W062L4", new (std::nothrow) String(L"DEFAULTCOLORTABLE::progress_circle_bar")); + Add(L"W063", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_bubble_bg")); + Add(L"W0641", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_bg")); + Add(L"W0641P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_bg_pressed")); + Add(L"W0641D", new (std::nothrow) String(L"DEFAULTCOLORTABLE::slider_handle_bg_disabled")); + Add(L"W0711", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_item_bg_normal")); + Add(L"W0712", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_item_outline_normal")); + Add(L"W0713", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_item_bg_pressed")); + Add(L"W0714", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_item_outline_pressed")); + Add(L"W0721", new (std::nothrow) String(L"DEFAULTCOLORTABLE::token_edit_expansion_button_bg")); + Add(L"W0811", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_detail_bar_bg")); + Add(L"W0812", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_button_bg")); + Add(L"W082", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_detail_bar_bg")); + Add(L"W083", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_keypad_button_bg")); + Add(L"W084", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_detail_bar_text_normal")); + Add(L"W084P", new (std::nothrow) String(L"DEFAULTCOLORTABLE::picker_detail_bar_text_pressed")); + Add(L"W101", new (std::nothrow) String(L"DEFAULTCOLORTABLE::tabbar_item_bg_pressed")); + Add(L"W111", new (std::nothrow) String(L"DEFAULTCOLORTABLE::optionmenu_bg")); + Add(L"W1121", new (std::nothrow) String(L"DEFAULTCOLORTABLE::optionmenu_item_normal")); + Add(L"W1122", new (std::nothrow) String(L"DEFAULTCOLORTABLE::optionmenu_item_pressed")); + Add(L"W1123", new (std::nothrow) String(L"DEFAULTCOLORTABLE::optionmenu_item_disabled")); + Add(L"W1211", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_bg")); + Add(L"W1212", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_inputmode_bg")); + Add(L"W1221", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_text")); + Add(L"W1222", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_text_inputmode")); + Add(L"W1223", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_group_table_item_text_pressed")); + Add(L"W131", new (std::nothrow) String(L"DEFAULTCOLORTABLE::splitpanel_divider_bg")); + Add(L"W132", new (std::nothrow) String(L"DEFAULTCOLORTABLE::splitpanel_divider_bg_pressed")); + Add(L"W141", new (std::nothrow) String(L"DEFAULTCOLORTABLE::list_item_no_content_icon")); + Add(L"W151", new (std::nothrow) String(L"DEFAULTCOLORTABLE::iconlist_item_border_normal")); + Add(L"W152", new (std::nothrow) String(L"DEFAULTCOLORTABLE::iconlist_item_border_loading")); + Add(L"W153", new (std::nothrow) String(L"DEFAULTCOLORTABLE::iconlist_item_border_selected")); + } + */ + return true; +} +HashMapT* +ConfigParser::GetMatchingTable(void) +{ + return pColorMatchingMap; +} + +ConfigParser::ConfigParser(void) + : __pMapContainer(null) + , __currentAttribute(L"") +{ +} +ConfigParser::~ConfigParser(void) +{ + delete pColorMatchingMap; + pColorMatchingMap = null; +} +bool +ConfigParser::Parse(const String& filename, MapContainer & table) +{ + File file; + ByteBuffer buffer; + FileAttributes attrib; + int readCount = 0; + byte* pXmlContents = null; + result r = E_SUCCESS; + int size = 0; + + if (!File::IsFileExist(filename)) + { + return false; + } + r = file.Construct(filename, L"r"); + if (IsFailed(r)) + { + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed -- XML file Construct."); + return false; + } + + r = Tizen::Io::File::GetAttributes(filename, attrib); + if (IsFailed(r)) + { + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed -- XML file GetAttributes."); + return false; + } + size = (int) attrib.GetFileSize(); + + r = buffer.Construct(size); + if (IsFailed(r)) + { + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed - Buffer Construct Failed."); + return false; + } + + r = file.Read(buffer); + if (IsFailed(r)) + { + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed -- can't read the file."); + return false; + } + + readCount = buffer.GetPosition(); + pXmlContents = new (std::nothrow) byte[readCount]; + SysTryReturn(NID_UI, pXmlContents != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create XmlContents."); + buffer.Flip(); + + r = buffer.GetArray(pXmlContents, 0, readCount); + if (IsFailed(r)) + { + SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Parse Failed -- buffer.GetArray is Failed."); + delete[] pXmlContents; + return false; + } + char* pXmlBuffer = (char*) pXmlContents; + + __pMapContainer = &table; + pConfigXmlHandler = this; + xmlSAXHandlerPtr pMySaxhandler = &mySaxHandler; + xmlSubstituteEntitiesDefault(1); + xmlSAXUserParseMemory(pMySaxhandler, null, pXmlBuffer, readCount); + pConfigXmlHandler = null; + delete [] pXmlContents; + return true; +} +void +ConfigParser::StartSaxFunc(void* pXmlParserCtxt, const xmlChar* pName, const xmlChar** pAttributes) +{ + if (xmlStrcasecmp(pName, (xmlChar*) "Image") == 0) + { + pConfigXmlHandler->AddImage(pAttributes); + } + else if (xmlStrcasecmp(pName, (xmlChar*) "Color") == 0) + { + pConfigXmlHandler->AddColor(pAttributes); + } + else if (xmlStrcasecmp(pName, (xmlChar*) "Resource") == 0) + { + pConfigXmlHandler->SetInformation(pAttributes); + } + else if (xmlStrcasecmp(pName, (xmlChar*) "Palette") == 0) + { + pConfigXmlHandler->StartAttribute(pAttributes); + } + else if (xmlStrcasecmp(pName, (xmlChar*) "Control") == 0) + { + pConfigXmlHandler->StartAttribute(pAttributes); + } + else + { + ;//nothing to do + } +} + +void +ConfigParser::SetInformation(const xmlChar** pAttributes) +{ + if (pAttributes != null) + { + for (int i = 0; (pAttributes[i] != null); i++) + { + if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "Version") == 0) + { + String version = (char*) pAttributes[++i]; + __pMapContainer->SetVersion(version); +// ColorMatchingMap* matchingMap = new ColorMatchingMap; +// if (!matchingMap->Initialize(version)) +// { +// delete matchingMap; +// } +// else +// { +// pColorMatchingMap = matchingMap; +// } + } + } + } +} + +void +ConfigParser::StartAttribute(const xmlChar** pAttributes) +{ + if (pAttributes != null) + { + for (int i = 0; (pAttributes[i] != null); i++) + { + if (xmlStrcasecmp(pAttributes[i], (xmlChar*) "Name") == 0) + { + __currentAttribute = (char*) pAttributes[++i]; + } + } + } +} + +void +ConfigParser::AddColor(const xmlChar** pAttributes) +{ + if (pAttributes != null) + { + for (int i = 0; (pAttributes[i] != null); i++) + { + if (pAttributes[++i] != null) + { + bool exist = false; + String key = __currentAttribute + L"::" + (char*) pAttributes[i - 1]; + if(__pMapContainer->GetColorMap()->ContainsKey(key, exist) == E_SUCCESS) + { + if(exist) + { + Color color; + GetValue((char*) pAttributes[i], color); + SysLog(NID_UI,"The resource config parser changes resource color value, key %s, color %s", pAttributes[i - 1], pAttributes[i]); + __pMapContainer->GetColorMap()->SetValue(key,&color); + } + else + { + Color* pColor = new (std::nothrow) Color(); + SysTryReturnVoidResult(NID_UI, pColor, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + SysLog(NID_UI,"The resource config parser adds resource color, key %s, color %s", pAttributes[i - 1], pAttributes[i]); + GetValue((char*) pAttributes[i], *pColor); + result r = __pMapContainer->GetColorMap()->Add(key, pColor); + if(r != E_SUCCESS) + { + SysAssert(0); + } + } + } + } + } + } +} + +void +ConfigParser::AddImage(const xmlChar** pAttributes) +{ + if (pAttributes != null) + { + for (int i = 0; (pAttributes[i] != null); i++) + { + if (pAttributes[++i] != null) + { + bool exist = false; + String key = __currentAttribute + L"::" + (char*) pAttributes[i - 1]; + if(__pMapContainer->GetImageMap()->ContainsKey(key, exist) == E_SUCCESS) + { + if(exist) + { + String value((char*) pAttributes[i]); + value.SubString(1, value); + __pMapContainer->GetImageMap()->SetValue(key,&value); + } + else + { + String* pString = new (std::nothrow) String((char*) pAttributes[i]); + SysTryReturnVoidResult(NID_UI, pString, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + pString->SubString(1,*pString); + result r = __pMapContainer->GetImageMap()->Add(key, pString); + if(r != E_SUCCESS) + { + SysAssert(0); + } + } + } + } + } + } +} + +void +ConfigParser::ConvertStringToColor32(const char* pString, Color& color) +{ + int index = 0; + int len = 0; + int gap = 0; + char ch; + unsigned int temp = 0; + + len = strlen(pString); + + if (len < 1) + { + SysLog(NID_UI, "String is empty"); + return; + } + + for (index = 1; index < len + 1; index++) + { + ch = pString[index]; + if ((ch >= '0') && (ch <= '9')) + { + temp = temp << 4; + gap = ch - '0'; + temp |= gap; + + } + else if ((ch >= 'A') && (ch <= 'F')) + { + temp = temp << 4; + gap = ch - 'A' + 10; + temp |= gap; + + } + else if ((ch >= 'a') && (ch <= 'f')) + { + temp = temp << 4; + gap = ch - 'a' + 10; + temp |= gap; + } + } + color.SetRGB32(temp, true); +} + +void +ConfigParser::GetValue(const String& value, String& out) +{ + if (value.StartsWith(L"#", 0)) + { + value.SubString(1, out); + } + else if (value.StartsWith(L"$", 0)) + { + String* pString = null; + if(__pMapContainer->GetImageMap()->GetValue(value, pString) != E_SUCCESS) + { + SysAssert(0); + } + out = *pString; + } + else + { + //nothing to do + } +} +void +ConfigParser::GetValue(const String& value, Color& out) +{ + if (value.StartsWith(L"#", 0)) + { + char* pString = _StringConverter::CopyToCharArrayN(value); + ConvertStringToColor32(pString, out); + delete [] pString; + } + else if (value.StartsWith(L"$", 0)) + { + Color* pColor = null; + String key(L""); + value.SubString(1, key); + if(__pMapContainer->GetColorMap()->GetValue(key, pColor) != E_SUCCESS) + { + SysAssert(0); + } + out = *pColor; + } + else + { + //nothing to do + } +} + +}}}//Tizen::Ui diff --git a/src/ui/resource/FUi_ResourceConfigParser.h b/src/ui/resource/FUi_ResourceConfigParser.h new file mode 100644 index 0000000..90a1a02 --- /dev/null +++ b/src/ui/resource/FUi_ResourceConfigParser.h @@ -0,0 +1,86 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceConfigParser.h + * @brief This is the header file for ConfigParser class. + * @version 3.0 + * + * This header file contains declaration of ConfigParser class. + * + */ +#ifndef _FUI_INTERNAL_RESOURCE_CONFIG_PARSER_H_ +#define _FUI_INTERNAL_RESOURCE_CONFIG_PARSER_H_ + +#include + +namespace Tizen { namespace Base +{ + class String; +}} + +namespace Tizen { namespace Base { namespace Collection +{ + template class HashMapT; +}}} + +namespace Tizen { namespace Graphics +{ + class Color; +}} + +namespace Tizen { namespace Ui { namespace _Resource +{ +class MapContainer; + +class ConfigParser +{ +public: + ConfigParser(void); + ~ConfigParser(void); + bool Parse(const Tizen::Base::String& filename, MapContainer & table); + static void StartSaxFunc(void* pXmlParserCtxt, const xmlChar* pName, const xmlChar** pAttributes); + static Tizen::Base::Collection::HashMapT* GetMatchingTable(void); + + class ColorMatchingMap + : public Tizen::Base::Collection::HashMapT + { + public: + ColorMatchingMap(void); + virtual ~ColorMatchingMap(void); + bool Initialize(const Tizen::Base::String& version, const Tizen::Base::String& dVersion = L""); + private: + Tizen::Base::Collection::IHashCodeProviderT* __pProvider; + Tizen::Base::Collection::IComparerT* __pComparer; + }; + +private: + void SetInformation(const xmlChar** pAttributes); + void StartAttribute(const xmlChar** pAttributes); + void AddColor(const xmlChar** pAttributes); + void AddImage(const xmlChar** pAttributes); + void SetColorMatchingMap(const Tizen::Base::String& version); + void ConvertStringToColor32(const char* pString, Tizen::Graphics::Color& color); + void GetValue(const Tizen::Base::String& value, Tizen::Base::String& out); + void GetValue(const Tizen::Base::String& value, Tizen::Graphics::Color& out); + + MapContainer* __pMapContainer; + Tizen::Base::String __currentAttribute; +}; //class ConfigParser + +}}}//Tizen::Ui + +#endif //_FUI_INTERNAL_RESOURCE_CONFIG_PARSER_H_ \ No newline at end of file diff --git a/src/ui/resource/FUi_ResourceContextMenuConfig.cpp b/src/ui/resource/FUi_ResourceContextMenuConfig.cpp new file mode 100644 index 0000000..29cd1d3 --- /dev/null +++ b/src/ui/resource/FUi_ResourceContextMenuConfig.cpp @@ -0,0 +1,106 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceContextMenuConfig.cpp + * @brief This is the implementation file for the color and shape properties of ContextMenu. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(CONTEXTMENU); +{ + ADD_COLOR_CONFIG(BG_NORMAL, $B061L4); + ADD_COLOR_CONFIG(LIST_ITEM_DIVIDER1, $B0622L1); + ADD_COLOR_CONFIG(LIST_ITEM_DIVIDER2, $B0622L2); + ADD_COLOR_CONFIG(ITEM_BG_PRESSED, $B044); + ADD_COLOR_CONFIG(GRID_ITEM_DIVIDER_01, $B0623L1); + ADD_COLOR_CONFIG(GRID_ITEM_DIVIDER_02, $B0623L2); + ADD_COLOR_CONFIG(ITEM_TEXT_NORMAL, $B063L5); + ADD_COLOR_CONFIG(ITEM_TEXT_PRESSED, $B063L5); + ADD_COLOR_CONFIG(ITEM_TEXT_DISABLED, $B0622L5D); + + ADD_IMAGE_CONFIG(BG_NORMAL, #00_popup_bubble_bg.9.png); + ADD_IMAGE_CONFIG(BG_OUTLINE_EFFECT_NORMAL, #00_popup_bubble_bg_ef.9.png); + + ADD_IMAGE_CONFIG(ANCHOR_NORMAL_UP, #00_popup_bubble_tail_bottom_bg.png); + ADD_IMAGE_CONFIG(ANCHOR_NORMAL_DOWN, #00_popup_bubble_tail_top_bg.png); + ADD_IMAGE_CONFIG(ANCHOR_NORMAL_LEFT, #00_popup_bubble_tail_right_bg.png); + ADD_IMAGE_CONFIG(ANCHOR_NORMAL_RIGHT, #00_popup_bubble_tail_left_bg.png); + ADD_IMAGE_CONFIG(ANCHOR_EFFECT_UP, #00_popup_bubble_tail_bottom_ef.png); + ADD_IMAGE_CONFIG(ANCHOR_EFFECT_DOWN, #00_popup_bubble_tail_top_ef.png); + ADD_IMAGE_CONFIG(ANCHOR_EFFECT_LEFT, #00_popup_bubble_tail_right_ef.png); + ADD_IMAGE_CONFIG(ANCHOR_EFFECT_RIGHT, #00_popup_bubble_tail_left_ef.png); + + + START_UI_CONFIG_MODE(480x800); + ADD_SHAPE_CONFIG(ITEM_MAX_COUNT, 7); + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(800x480); + ADD_SHAPE_CONFIG(ITEM_MAX_COUNT, 5); + END_UI_CONFIG_MODE(800x480); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(LIST_ITEM_HEIGHT, 112); + ADD_SHAPE_CONFIG(LIST_MIN_WIDTH, 368); + ADD_SHAPE_CONFIG(LIST_MAX_WIDTH, 620); + ADD_SHAPE_CONFIG(LIST_TOP_MARGIN, 12); + ADD_SHAPE_CONFIG(LIST_BOTTOM_MARGIN, 12); + ADD_SHAPE_CONFIG(LIST_LEFT_MARGIN, 12); + ADD_SHAPE_CONFIG(LIST_RIGHT_MARGIN, 12); + + ADD_SHAPE_CONFIG(LIST_ICON_WIDTH, 64); + ADD_SHAPE_CONFIG(LIST_ICON_HEIGHT, 64); + ADD_SHAPE_CONFIG(LIST_TEXT_WIDTH, 266); + ADD_SHAPE_CONFIG(LIST_TEXT_HEIGHT, 64); + ADD_SHAPE_CONFIG(LIST_ITEM_GAP, 16); + ADD_SHAPE_CONFIG(LIST_DIVIDER_HEIGHT, 1); + + ADD_SHAPE_CONFIG(GRID_MIN_WIDTH, 128); + ADD_SHAPE_CONFIG(GRID_MAX_WIDTH, 648); + ADD_SHAPE_CONFIG(GRID_ITEM_WIDTH, 128); + ADD_SHAPE_CONFIG(GRID_ITEM_HEIGHT, 92); + ADD_SHAPE_CONFIG(GRID_ITEM_MAX_WIDTH, 324); + ADD_FIXED_VALUE_CONFIG(GRID_ITEM_GAP, 2); + ADD_SHAPE_CONFIG(GRID_TEXT_MARGIN, 20); + ADD_SHAPE_CONFIG(GRID_DIVIDER_HEIGHT, 74); + ADD_SHAPE_CONFIG(GRID_TOP_MARGIN, 12); + ADD_SHAPE_CONFIG(GRID_BOTTOM_MARGIN, 12); + ADD_SHAPE_CONFIG(GRID_LEFT_MARGIN, 12); + ADD_SHAPE_CONFIG(GRID_RIGHT_MARGIN, 12); + ADD_SHAPE_CONFIG(GRID_ICON_WIDTH, 48); + ADD_SHAPE_CONFIG(GRID_ICON_HEIGHT, 48); + + ADD_FIXED_VALUE_CONFIG(SCREEN_TOP_MARGIN, 24); + ADD_FIXED_VALUE_CONFIG(SCREEN_BOTTOM_MARGIN, 24); + ADD_FIXED_VALUE_CONFIG(SCREEN_LEFT_MARGIN, 24); + ADD_FIXED_VALUE_CONFIG(SCREEN_RIGHT_MARGIN, 24); + + ADD_SHAPE_CONFIG(ITEM_MAX_COUNT, 7); + ADD_SHAPE_CONFIG(LIST_ITEM_FONT_SIZE, 40); + ADD_SHAPE_CONFIG(GRID_ITEM_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(ANCHOR_WIDTH, 42); + ADD_SHAPE_CONFIG(ANCHOR_HEIGHT, 28); + ADD_SHAPE_CONFIG(ANCHOR_MARGIN, 12); + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + ADD_SHAPE_CONFIG(GRID_MAX_WIDTH, 1152); + ADD_SHAPE_CONFIG(ITEM_MAX_COUNT, 5); + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(CONTEXTMENU); diff --git a/src/ui/resource/FUi_ResourceDateTimeBarConfig.cpp b/src/ui/resource/FUi_ResourceDateTimeBarConfig.cpp new file mode 100644 index 0000000..827a410 --- /dev/null +++ b/src/ui/resource/FUi_ResourceDateTimeBarConfig.cpp @@ -0,0 +1,74 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceDateTimeBarConfig.cpp + * @brief This is the implementation file for the color and shape config of DateTimeBar class. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(DATETIMEBAR); +{ + ADD_COLOR_CONFIG(BG_NORMAL, $W0811); + ADD_COLOR_CONFIG(TEXT_NORMAL, $W084); + ADD_COLOR_CONFIG(TEXT_PRESSED, $W084P); + + ADD_IMAGE_CONFIG(TIMEPICKERBAR_BG_NORMAL, #00_timepicker_number_bg.9.png); + ADD_IMAGE_CONFIG(TAIL_DOWN, #00_timepicker_tail.png); + ADD_IMAGE_CONFIG(TAIL_UP, #00_timepicker_tail_01.png); + + START_UI_CONFIG_MODE(800x480); + { + ADD_DIMENSION_CONFIG(DEFAULT_SIZE, 800, 102); + } + END_UI_CONFIG_MODE(800x480); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_SHAPE_CONFIG(DAY_ITEM_WIDTH, 98); + ADD_SHAPE_CONFIG(MONTH_ITEM_WIDTH, 115); + ADD_SHAPE_CONFIG(YEAR_ITEM_WIDTH, 120); + ADD_SHAPE_CONFIG(ITEM_HEIGHT, 102); + + ADD_SHAPE_CONFIG(TOP_MARGIN, 22); + ADD_SHAPE_CONFIG(DAY_ITEM_MARGIN, 0); + ADD_SHAPE_CONFIG(MONTH_ITEM_MARGIN, 0); + ADD_SHAPE_CONFIG(YEAR_ITEM_MARGIN, 22); + + ADD_SHAPE_CONFIG(DAY_LEFT_RIGHT_MARGIN, 17); + ADD_SHAPE_CONFIG(MONTH_LEFT_RIGHT_MARGIN, 15); + ADD_SHAPE_CONFIG(YEAR_LEFT_RIGHT_MARGIN, 16); + + ADD_SHAPE_CONFIG(ARROW_WIDTH, 30); + ADD_SHAPE_CONFIG(ARROW_HEIGHT, 18); + + ADD_SHAPE_CONFIG(DAY_FONT_SIZE, 48); + ADD_SHAPE_CONFIG(MONTH_FONT_SIZE, 38); + ADD_SHAPE_CONFIG(YEAR_FONT_SIZE, 42); + + ADD_DIMENSION_CONFIG(DEFAULT_SIZE, 720, 102); + } + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + { + ADD_DIMENSION_CONFIG(DEFAULT_SIZE, 1280, 102); + } + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(DATETIMEBAR); diff --git a/src/ui/resource/FUi_ResourceDateTimePickerConfig.cpp b/src/ui/resource/FUi_ResourceDateTimePickerConfig.cpp new file mode 100644 index 0000000..af4b3d2 --- /dev/null +++ b/src/ui/resource/FUi_ResourceDateTimePickerConfig.cpp @@ -0,0 +1,95 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceDateTimePickerConfig.cpp + * @brief This is a configuration file for color, image and shape values of DateTimePicker. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(DATETIMEPICKER); +{ + ADD_COLOR_CONFIG(BG_NORMAL, $B011); + + ADD_COLOR_CONFIG(AMPM_BG_NORMAL, $W011); + ADD_COLOR_CONFIG(AMPM_BG_PRESSED, $B041); + ADD_COLOR_CONFIG(AMPM_BG_HIGHLIGHTED, $B041); + ADD_COLOR_CONFIG(AMPM_BG_DISABLED, $W011); + + ADD_COLOR_CONFIG(TEXT_NORMAL, $F011L1); + ADD_COLOR_CONFIG(TEXT_PRESSED, $F011L2); + ADD_COLOR_CONFIG(TEXT_HIGHLIGHTED, $F011L2); + ADD_COLOR_CONFIG(TEXT_DISABLED, $F011L1); + + ADD_COLOR_CONFIG(AMPM_TEXT_NORMAL, $F031L1); + ADD_COLOR_CONFIG(AMPM_TEXT_PRESSED, $F031L1P); + ADD_COLOR_CONFIG(AMPM_TEXT_HIGHLIGHTED, $F031L1P); + ADD_COLOR_CONFIG(AMPM_TEXT_DISABLED, $F031L1D); + + ADD_COLOR_CONFIG(DIVIDER_LEFT_HALF, $B0231L1); + ADD_COLOR_CONFIG(DIVIDER_RIGHT_HALF, $B0231L2); + + ADD_IMAGE_CONFIG(AMPM_BG_NORMAL, #00_button_01.9.png); + ADD_IMAGE_CONFIG(AMPM_BG_EFFECT, #00_button_01_ef.9.png); + ADD_IMAGE_CONFIG(AMPM_BG_PRESSED_EFFECT, #00_button_01_ef_press.9.png); + ADD_IMAGE_CONFIG(AMPM_BG_DISABLED_EFFECT, #00_button_01_ef_dim.9.png); + + ADD_IMAGE_CONFIG(COLON_BG_NORMAL, #00_date_picker_dot.png); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_SHAPE_CONFIG(FOOTER_HEIGHT, 94); + ADD_SHAPE_CONFIG(INPUTPAD_HEIGHT, 484); + ADD_SHAPE_CONFIG(OUTPUT_AREA_HEIGHT, 112); + ADD_SHAPE_CONFIG(DISPLAY_BOX_HEIGHT, 56); + + ADD_SHAPE_CONFIG(TOP_MARGIN, 32); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 16); + + ADD_SHAPE_CONFIG(DATE_ELEMENT_WIDTH, 130); + ADD_SHAPE_CONFIG(TIME_ELEMENT_WIDTH, 48); + + ADD_SHAPE_CONFIG(AMPM_WIDTH, 106); + ADD_SHAPE_CONFIG(COLON_WIDTH, 12); + + ADD_SHAPE_CONFIG(DATE_TIME_MARGIN, 10); + ADD_SHAPE_CONFIG(TIME_AMPM_MARGIN, 28); + ADD_SHAPE_CONFIG(COLON_MARGIN, 3); + + ADD_FIXED_VALUE_CONFIG(DIVIDER_WIDTH, 2); + ADD_SHAPE_CONFIG(DIVIDER_HEIGHT, 42); + + ADD_SHAPE_CONFIG(TIME_OUTPUT_MARGIN, 20); + + ADD_SHAPE_CONFIG(FONT_SIZE, 36); + } + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + { + ADD_SHAPE_CONFIG(FOOTER_HEIGHT, 84); + ADD_SHAPE_CONFIG(INPUTPAD_HEIGHT, 316); + + ADD_SHAPE_CONFIG(DATE_ELEMENT_WIDTH, 242); + + ADD_SHAPE_CONFIG(DATE_TIME_MARGIN, 66); + ADD_SHAPE_CONFIG(TIME_AMPM_MARGIN, 84); + } + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(DATETIMEPICKER); diff --git a/src/ui/resource/FUi_ResourceEditConfig.cpp b/src/ui/resource/FUi_ResourceEditConfig.cpp new file mode 100644 index 0000000..76ef28e --- /dev/null +++ b/src/ui/resource/FUi_ResourceEditConfig.cpp @@ -0,0 +1,141 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceEditConfig.cpp + * @brief This is the implementation file for the properties of Edit. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(EDIT); +{ + ADD_COLOR_CONFIG(BG_NORMAL, $B0217); + ADD_COLOR_CONFIG(BG_PRESSED, $B0217); + ADD_COLOR_CONFIG(BG_HIGHLIGHTED, $B0217); + ADD_COLOR_CONFIG(BG_DISABLED, $B0217); + ADD_COLOR_CONFIG(TITLE_TEXT_NORMAL, $F011L3); + ADD_COLOR_CONFIG(TITLE_TEXT_PRESSED, $F011L3); + ADD_COLOR_CONFIG(TITLE_TEXT_HIGHLIGHTED, $F011L3); + ADD_COLOR_CONFIG(TITLE_TEXT_DISABLED, $F011L3D); + ADD_COLOR_CONFIG(TEXT_NORMAL, $F011L1); + ADD_COLOR_CONFIG(TEXT_PRESSED, $F011L1); + ADD_COLOR_CONFIG(TEXT_HIGHLIGHTED, $F011L1); + ADD_COLOR_CONFIG(TEXT_DISABLED, $F011L1D); + ADD_COLOR_CONFIG(GUIDE_TEXT_NORMAL, $F051); + ADD_COLOR_CONFIG(CLEAR_ICON_NORMAL, $F041i); + ADD_COLOR_CONFIG(CLEAR_ICON_PRESSED, $B042); + ADD_COLOR_CONFIG(CUT_LINK_TEXT_NORMAL, $F011L1); + ADD_COLOR_CONFIG(CUT_LINK_BG_NORMAL, $B0217); + ADD_COLOR_CONFIG(CURSOR_NORMAL, $F052); + + ADD_IMAGE_CONFIG(BG_NORMAL, #00_edit_field_no_line_square_bg.9.png); + ADD_IMAGE_CONFIG(BG_PRESSED, #00_edit_field_no_line_square_bg.9.png); + ADD_IMAGE_CONFIG(BG_HIGHLIGHTED, #00_edit_field_no_line_square_bg.9.png); + ADD_IMAGE_CONFIG(BG_DISABLED, #00_edit_field_no_line_square_bg.9.png); + ADD_IMAGE_CONFIG(BG_EFFECT, #00_edit_field_no_line_square_bg.9.png); + ADD_IMAGE_CONFIG(BG_SINGLE_NORMAL, #00_list_group_bg.9.png); + ADD_IMAGE_CONFIG(BG_SINGLE_EFFECT, #00_list_group_bg_ef.9.png); + ADD_IMAGE_CONFIG(BG_SINGLE_PRESSED , #00_groupedlist_bg_press.9.png); + ADD_IMAGE_CONFIG(BG_TOP, #00_list_group_bg_top.9.png); + ADD_IMAGE_CONFIG(BG_TOP_EFFECT, #00_list_group_bg_top_ef.9.png); + ADD_IMAGE_CONFIG(BG_TOP_PRESSED, #00_groupedlist_top_bg_press.9.png); + ADD_IMAGE_CONFIG(BG_CENTER, #00_list_group_bg_center.9.png); + ADD_IMAGE_CONFIG(BG_CENTER_EFFECT, #00_list_group_bg_center_ef.9.png); + ADD_IMAGE_CONFIG(BG_CENTER_PRESSED, #00_groupedlist_center_bg_press.9.png); + ADD_IMAGE_CONFIG(BG_BOTTOM, #00_list_group_bg_bottom.9.png); + ADD_IMAGE_CONFIG(BG_BOTTOM_EFFECT, #00_list_group_bg_bottom_ef.9.png); + ADD_IMAGE_CONFIG(BG_BOTTOM_PRESSED, #00_groupedlist_bottom_bg_press.9.png); + ADD_IMAGE_CONFIG(COPY_PASTE_ICON_LEFT_NORMAL, #copy&paste_Icon_left.png); + ADD_IMAGE_CONFIG(COPY_PASTE_ICON_LEFT_PRESSED, #copy&paste_Icon_left_press.png); + ADD_IMAGE_CONFIG(COPY_PASTE_ICON_RIGHT_NORMAL, #copy&paste_Icon_right.png); + ADD_IMAGE_CONFIG(COPY_PASTE_ICON_RIGHT_PRESSED, #copy&paste_Icon_right_press.png); + ADD_IMAGE_CONFIG(COPY_PASTE_SEARCH_ICON, #copy&paste_icon_search.png); + ADD_IMAGE_CONFIG(BG_ROUND_NORMAL, #00_edit_field_round_bg.9.png); + ADD_IMAGE_CONFIG(BG_ROUND_EFFECT, #00_edit_field_line_round_bg_01.9.png); + ADD_IMAGE_CONFIG(CLEAR_ICON_NORMAL, #00_edit_field_clear.png); + ADD_IMAGE_CONFIG(CLEAR_ICON_PRESSED, #00_edit_field_clear.png); + + START_UI_CONFIG_MODE(480x800); + + ADD_DIMENSION_CONFIG(MIN_SIZE, 48, 60); + ADD_DIMENSION_CONFIG(TITLE_STYLE_MIN_SIZE, 48, 102); + ADD_DIMENSION_CONFIG(SMALL_STYLE_MIN_SIZE, 48, 48); + + START_UI_CONFIG_API_VERSION(2); + ADD_DIMENSION_CONFIG(MIN_SIZE, 48, 60); + ADD_DIMENSION_CONFIG(TITLE_STYLE_MIN_SIZE, 48, 102); + ADD_DIMENSION_CONFIG(SMALL_STYLE_MIN_SIZE, 48, 48); + END_UI_CONFIG_API_VERSION(); + + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(720x1280); + + ADD_FIXED_VALUE_CONFIG(FONT_MIN_SIZE, 4); + ADD_SHAPE_CONFIG(DEFAULT_FONT_SIZE, 44); + ADD_SHAPE_CONFIG(DEFAULT_TITLE_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(CLEAR_ICON_HEIGHT, 42); + ADD_SHAPE_CONFIG(CLEAR_ICON_WIDTH, 42); + ADD_SHAPE_CONFIG(COPYPASTE_HANDLER_WIDTH, 48); + ADD_SHAPE_CONFIG(COPYPASTE_HANDLER_HEIGHT, 68); + ADD_SHAPE_CONFIG(FIELD_BORDER_WIDTH, 1); + ADD_SHAPE_CONFIG(FIELD_LEFT_MARGIN, 0); + ADD_SHAPE_CONFIG(FIELD_RIGHT_MARGIN, 0); + ADD_SHAPE_CONFIG(FIELD_TOP_MARGIN, 0); + ADD_SHAPE_CONFIG(FIELD_BOTTOM_MARGIN, 0); + ADD_SHAPE_CONFIG(FIELD_TEXT_LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(FIELD_TEXT_RIGHT_MARGIN, 16); + ADD_SHAPE_CONFIG(FIELD_TEXT_TOP_MARGIN, 10); + ADD_SHAPE_CONFIG(FIELD_TEXT_BOTTOM_MARGIN, 10); + ADD_SHAPE_CONFIG(FIELD_TITLE_TEXT_LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(FIELD_TITLE_TEXT_RIGHT_MARGIN, 16); + ADD_SHAPE_CONFIG(FIELD_TITLE_TEXT_TOP_MARGIN, 10); + ADD_SHAPE_CONFIG(FIELD_TITLE_TEXT_BOTTOM_MARGIN, 10); + ADD_SHAPE_CONFIG(FIELD_TITLE_RECT_WIDTH, 120); + ADD_SHAPE_CONFIG(FIELD_TITLE_RECT_HEIGHT, 36); + + ADD_SHAPE_CONFIG(AREA_LEFT_MARGIN, 0); + ADD_SHAPE_CONFIG(AREA_RIGHT_MARGIN, 0); + ADD_SHAPE_CONFIG(AREA_TOP_MARGIN, 0); + ADD_SHAPE_CONFIG(AREA_BOTTOM_MARGIN, 0); + ADD_SHAPE_CONFIG(AREA_TEXT_LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(AREA_TEXT_RIGHT_MARGIN, 16); + ADD_SHAPE_CONFIG(AREA_TEXT_TOP_MARGIN, 10); + ADD_SHAPE_CONFIG(AREA_TEXT_BOTTOM_MARGIN, 10); + ADD_SHAPE_CONFIG(AREA_TITLE_TEXT_LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(AREA_TITLE_TEXT_RIGHT_MARGIN, 16); + ADD_SHAPE_CONFIG(AREA_TITLE_TEXT_TOP_MARGIN, 12); + ADD_SHAPE_CONFIG(AREA_TITLE_TEXT_BOTTOM_MARGIN, 12); + ADD_SHAPE_CONFIG(AREA_TITLE_RECT_WIDTH, 120); + ADD_SHAPE_CONFIG(AREA_TITLE_RECT_HEIGHT, 48); + ADD_SHAPE_CONFIG(AREA_SCROLL_WIDTH, 5); + ADD_SHAPE_CONFIG(CURSOR_WIDTH, 2); + ADD_SHAPE_CONFIG(TEXT_OBJECT_MININMUM_WIDTH, 63); + + ADD_DIMENSION_CONFIG(MIN_SIZE, 48, 60); + ADD_DIMENSION_CONFIG(TITLE_STYLE_MIN_SIZE, 48, 102); + ADD_DIMENSION_CONFIG(SMALL_STYLE_MIN_SIZE, 48, 48); + + START_UI_CONFIG_API_VERSION(2); + ADD_DIMENSION_CONFIG(MIN_SIZE, 48, 60); + ADD_DIMENSION_CONFIG(TITLE_STYLE_MIN_SIZE, 48, 102); + ADD_DIMENSION_CONFIG(SMALL_STYLE_MIN_SIZE, 48, 48); + END_UI_CONFIG_API_VERSION(); + + END_UI_CONFIG_MODE(720x1280); +} +END_UI_CONFIG(EDIT); diff --git a/src/ui/resource/FUi_ResourceEditDateConfig.cpp b/src/ui/resource/FUi_ResourceEditDateConfig.cpp new file mode 100644 index 0000000..9b0eb0d --- /dev/null +++ b/src/ui/resource/FUi_ResourceEditDateConfig.cpp @@ -0,0 +1,62 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceEditDateConfig.cpp + * @brief This is the implementation file for the color and shape config of EditDate class. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(EDITDATE); +{ + ADD_COLOR_CONFIG(TEXT_NORMAL, $F011L1); + ADD_COLOR_CONFIG(TEXT_PRESSED, $F011L2); + ADD_COLOR_CONFIG(TEXT_DISABLED, $F011L1); + ADD_COLOR_CONFIG(TITLE_TEXT_NORMAL, $F011L5); + ADD_COLOR_CONFIG(TITLE_TEXT_DISABLED, $F011L5); + ADD_COLOR_CONFIG(DIVIDER_HALF_LEFT, $B0231L1); + ADD_COLOR_CONFIG(DIVIDER_HALF_RIGHT, $B0231L2); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_SHAPE_CONFIG(WIDTH, 720); + ADD_SHAPE_CONFIG(HEIGHT, 112); + ADD_SHAPE_CONFIG(DATE_HEIGHT, 46); + ADD_SHAPE_CONFIG(TEXT_HEIGHT, 36); + ADD_SHAPE_CONFIG(DATE_FONT_SIZE, 36); + ADD_SHAPE_CONFIG(TEXT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(DATE_TEXT_LEFT_MARGIN, 20); + ADD_SHAPE_CONFIG(TEXT_ELEMENT_WIDTH, 130); + ADD_FIXED_VALUE_CONFIG(ITEM_DIVIDER_WIDTH, 2); + ADD_SHAPE_CONFIG(ITEM_DIVIDER_HEIGHT, 42); + ADD_SHAPE_CONFIG(TITLE_DATE_MARGIN, 5); + + ADD_DIMENSION_CONFIG(DEFAULT_SIZE, 720, 112); + } + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + { + ADD_DIMENSION_CONFIG(DEFAULT_SIZE, 1280, 112); + ADD_SHAPE_CONFIG(WIDTH, 1280); + ADD_SHAPE_CONFIG(TEXT_ELEMENT_WIDTH, 242); + } + END_UI_CONFIG_MODE(1280x720); + +} +END_UI_CONFIG(EDITDATE); diff --git a/src/ui/resource/FUi_ResourceEditTimeConfig.cpp b/src/ui/resource/FUi_ResourceEditTimeConfig.cpp new file mode 100644 index 0000000..5936e47 --- /dev/null +++ b/src/ui/resource/FUi_ResourceEditTimeConfig.cpp @@ -0,0 +1,77 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceEditTimeConfig.cpp + * @brief This is the implementation file for the color and shape config of EditTime class. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(EDITTIME); +{ + ADD_COLOR_CONFIG(BUTTON_BG_NORMAL, $W011); + ADD_COLOR_CONFIG(BUTTON_BG_PRESSED, $B042); + ADD_COLOR_CONFIG(BUTTON_BG_DISABLED, $W011); + ADD_COLOR_CONFIG(BUTTON_TEXT_NORMAL, $F031L1); + ADD_COLOR_CONFIG(BUTTON_TEXT_PRESSED, $F031L1P); + ADD_COLOR_CONFIG(BUTTON_TEXT_DISABLED, $F031L1); + ADD_COLOR_CONFIG(TEXT_NORMAL, $F011L1); + ADD_COLOR_CONFIG(TEXT_PRESSED, $F011L2); + ADD_COLOR_CONFIG(TEXT_DISABLED, $F011L1); + ADD_COLOR_CONFIG(TITLE_TEXT_NORMAL, $F011L5); + ADD_COLOR_CONFIG(TITLE_TEXT_DISABLED, $F011L5); + + ADD_IMAGE_CONFIG(COLON_BG_NORMAL, #00_date_picker_dot.png); + ADD_IMAGE_CONFIG(BUTTON_BG_NORMAL, #00_button_01.9.png); + ADD_IMAGE_CONFIG(BUTTON_BG_EFFECT_NORMAL, #00_button_01_ef.9.png); + ADD_IMAGE_CONFIG(BUTTON_BG_EFFECT_DISABLED, #00_button_01_ef_dim.9.png); + ADD_IMAGE_CONFIG(BUTTON_BG_EFFECT_PRESSED, #00_button_01_ef_press.9.png); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_SHAPE_CONFIG(WIDTH, 720); + ADD_SHAPE_CONFIG(HEIGHT, 112); + ADD_SHAPE_CONFIG(TIME_WIDTH, 114); + ADD_SHAPE_CONFIG(HOUR_MINUTE_WIDTH, 48); + ADD_SHAPE_CONFIG(TITLE_TIME_MARGIN, 5); + ADD_SHAPE_CONFIG(TIME_HEIGHT, 46); + ADD_SHAPE_CONFIG(TIME_AMPM_MARGIN, 24); + ADD_SHAPE_CONFIG(AMPM_WIDTH, 106); + ADD_SHAPE_CONFIG(AMPM_HEIGHT, 56); + ADD_SHAPE_CONFIG(TEXT_HEIGHT, 36); + ADD_SHAPE_CONFIG(TIME_FONT_SIZE, 36); + ADD_SHAPE_CONFIG(TEXT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(AMPM_FONT_SIZE, 36); + ADD_SHAPE_CONFIG(COLON_WIDTH, 12); + ADD_SHAPE_CONFIG(COLON_MARGIN, 3); + ADD_SHAPE_CONFIG(TIME_TEXT_LEFT_MARGIN, 20); + + ADD_DIMENSION_CONFIG(DEFAULT_SIZE, 720, 112); + } + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + { + ADD_DIMENSION_CONFIG(DEFAULT_SIZE, 1280, 112); + ADD_SHAPE_CONFIG(WIDTH, 1280); + ADD_SHAPE_CONFIG(TIME_WIDTH, 242); + ADD_SHAPE_CONFIG(TIME_AMPM_MARGIN, 84); + } + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(EDITTIME); diff --git a/src/ui/resource/FUi_ResourceFastScrollConfig.cpp b/src/ui/resource/FUi_ResourceFastScrollConfig.cpp new file mode 100644 index 0000000..46a6770 --- /dev/null +++ b/src/ui/resource/FUi_ResourceFastScrollConfig.cpp @@ -0,0 +1,60 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(FASTSCROLL); +{ + ADD_COLOR_CONFIG(INDEX_BAR, $B0723); + ADD_COLOR_CONFIG(INDEX_LEFT_LINE, $B0725); + ADD_COLOR_CONFIG(INDEX_BAR_TEXT, $B0721); + ADD_COLOR_CONFIG(INDEX_SEPARATOR, $B0724); + + ADD_COLOR_CONFIG(SELECTED_INDEX_BG, $B011); + ADD_COLOR_CONFIG(SELECTED_INDEX_TEXT, $B0722); + ADD_COLOR_CONFIG(SELECTED_INDEX_OUTLINE, $B0725); + + ADD_COLOR_CONFIG(POPUP_BG, $B0731); + ADD_COLOR_CONFIG(POPUP_TEXT, $B0732); + + ADD_IMAGE_CONFIG(INDEX_BG, #00_fast_scroll_rollover_bg.9.png); + ADD_IMAGE_CONFIG(SELECTED_INDEX_BG, #00_fast_scroll_rollover_bg_focus.9.png); + ADD_IMAGE_CONFIG(SELECTED_INDEX_OUTLINE, #00_fast_scroll_rollover_bg_line_focus.9.png); + ADD_IMAGE_CONFIG(POPUP_BG, #00_fast_scroll_popup_bg_ef.9.png); + ADD_IMAGE_CONFIG(POPUP_BG_EFFECT, #00_fast_scroll_popup_bg.9.png); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(INDEX_WIDTH, 51); + ADD_SHAPE_CONFIG(INDEX_HEIGHT, 33); + ADD_SHAPE_CONFIG(INDEX_TOP_MARGIN, 17); + ADD_SHAPE_CONFIG(INDEX_LEFT_LINE_THICKNESS, 3); + ADD_SHAPE_CONFIG(INDEX_TEXT_SIZE, 26); + ADD_FIXED_VALUE_CONFIG(INDEX_SEPARATOR_THICKNESS, 1); + ADD_SHAPE_CONFIG(SELECTED_INDEX_RIGHT_MARGIN, 4); + ADD_SHAPE_CONFIG(SELECTED_INDEX_HEIGHT, 92); + + ADD_SHAPE_CONFIG(POPUP_WIDTH, 208); + ADD_SHAPE_CONFIG(POPUP_HEIGHT, 200); + ADD_SHAPE_CONFIG(POPUP_WIDTH_INCREMENT, 76); + ADD_SHAPE_CONFIG(POPUP_RIGHT_SHADOW, 10); + ADD_SHAPE_CONFIG(POPUP_BOTTOM_SHADOW, 10); + ADD_SHAPE_CONFIG(POPUP_TEXT_SIZE, 136); + END_UI_CONFIG_MODE(720x1280); +} +END_UI_CONFIG(FASTSCROLL); + + diff --git a/src/ui/resource/FUi_ResourceFooterConfig.cpp b/src/ui/resource/FUi_ResourceFooterConfig.cpp new file mode 100644 index 0000000..8ee13bf --- /dev/null +++ b/src/ui/resource/FUi_ResourceFooterConfig.cpp @@ -0,0 +1,303 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceFooterConfig.cpp + * @brief This is the implementation file for the properties of Footer. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(FOOTER); +{ + // COLOR + ADD_COLOR_CONFIG(BG_NORMAL, $B0515); + ADD_COLOR_CONFIG(TRANSLUCENT_BG_NORMAL, $B013); + + ADD_COLOR_CONFIG(BUTTON_BG_NORMAL, $B0511); + ADD_COLOR_CONFIG(BUTTON_BG_DISABLED, $B0511); + ADD_COLOR_CONFIG(BUTTON_BG_PRESSED, $B0511); + ADD_COLOR_CONFIG(BUTTON_BG_HIGHLIGHTED, $B0511); + + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_BG_NORMAL, $B013); + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_BG_DISABLED, $B013); + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_BG_PRESSED, $B013); + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_BG_HIGHLIGHTED, $B013); + + ADD_COLOR_CONFIG(BUTTON_TEXT_NORMAL, $B052L4); + ADD_COLOR_CONFIG(BUTTON_TEXT_DISABLED, $B052L4D); + ADD_COLOR_CONFIG(BUTTON_TEXT_PRESSED, $B052L6P); + ADD_COLOR_CONFIG(BUTTON_TEXT_HIGHLIGHTED, $B052L4P); + + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_TEXT_NORMAL, $B052L8); + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_TEXT_DISABLED, $B052L8); + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_TEXT_PRESSED, $B052L8P); + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_TEXT_HIGHLIGHTED, $B052L8P); + + + ADD_COLOR_CONFIG(SEGMENTED_ITEM_BG_NORMAL, $B0515); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_BG_DISABLED, $B0515); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_BG_PRESSED, $B0514P1); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_BG_HIGHLIGHTED, $B0514P1); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_BG_SELECTED, $B0515); + + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_BG_NORMAL, $B013); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_BG_DISABLED, $B013); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_BG_PRESSED, $B013); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_BG_HIGHLIGHTED, $B013); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_BG_SELECTED, $B013); + + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TEXT_NORMAL, $B052L6); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TEXT_DISABLED, $B052L4D); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TEXT_PRESSED, $B052L6P); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TEXT_HIGHLIGHTED, $B052L6P); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TEXT_SELECTED, $B052L6P); + + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_TEXT_NORMAL, $B052L8); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_TEXT_DISABLED, $B052L8); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_TEXT_PRESSED, $B052L8P); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_TEXT_HIGHLIGHTED, $B052L8P); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_TEXT_SELECTED, $B052L8P); + + + ADD_COLOR_CONFIG(BUTTON_ITEM_BG_NORMAL, $W011); + ADD_COLOR_CONFIG(BUTTON_ITEM_BG_DISABLED, $W011); + ADD_COLOR_CONFIG(BUTTON_ITEM_BG_PRESSED, $B042); + ADD_COLOR_CONFIG(BUTTON_ITEM_BG_HIGHLIGHTED, $B042); + + ADD_COLOR_CONFIG(BUTTON_ITEM_TRANSLUCENT_BG_NORMAL, $B013); + ADD_COLOR_CONFIG(BUTTON_ITEM_TRANSLUCENT_BG_DISABLED, $B013); + ADD_COLOR_CONFIG(BUTTON_ITEM_TRANSLUCENT_BG_PRESSED, $B042); + ADD_COLOR_CONFIG(BUTTON_ITEM_TRANSLUCENT_BG_HIGHLIGHTED, $B042); + + ADD_COLOR_CONFIG(BUTTON_ITEM_TEXT_NORMAL, $B052L4); + ADD_COLOR_CONFIG(BUTTON_ITEM_TEXT_DISABLED, $B052L4D); + ADD_COLOR_CONFIG(BUTTON_ITEM_TEXT_PRESSED, $B052L4P); + ADD_COLOR_CONFIG(BUTTON_ITEM_TEXT_HIGHLIGHTED, $B052L4P); + + ADD_COLOR_CONFIG(BUTTON_ITEM_TRANSLUCENT_TEXT_NORMAL, $B052L9); + ADD_COLOR_CONFIG(BUTTON_ITEM_TRANSLUCENT_TEXT_DISABLED, $B052L9D); + ADD_COLOR_CONFIG(BUTTON_ITEM_TRANSLUCENT_TEXT_PRESSED, $B052L9P); + ADD_COLOR_CONFIG(BUTTON_ITEM_TRANSLUCENT_TEXT_HIGHLIGHTED, $B052L9P); + + + ADD_COLOR_CONFIG(BACK_ICON_NORMAL, $B052L1); + ADD_COLOR_CONFIG(BACK_ICON_DISABLED, $B052L1D); + ADD_COLOR_CONFIG(BACK_ICON_PRESSED, $B052L1P); + ADD_COLOR_CONFIG(BACK_ICON_HIGHLIGHTED, $B052L1P); + + + ADD_COLOR_CONFIG(SOFTKEY_BG_NORMAL, $B0520); + ADD_COLOR_CONFIG(SOFTKEY_BG_DISABLED, $B0520); + ADD_COLOR_CONFIG(SOFTKEY_BG_PRESSED, $B0520P); + ADD_COLOR_CONFIG(SOFTKEY_BG_HIGHLIGHTED, $B0520P); + + ADD_COLOR_CONFIG(SOFTKEY_TEXT_NORMAL, $F031L3); + ADD_COLOR_CONFIG(SOFTKEY_TEXT_DISABLED, $F031L3D); + ADD_COLOR_CONFIG(SOFTKEY_TEXT_PRESSED, $F031L3P); + ADD_COLOR_CONFIG(SOFTKEY_TEXT_HIGHLIGHTED, $F031L3P); + + ADD_COLOR_CONFIG(SOFTKEY_ICON_NORMAL, $B052L9); + ADD_COLOR_CONFIG(SOFTKEY_ICON_DISABLED, $B052L9); + ADD_COLOR_CONFIG(SOFTKEY_ICON_PRESSED, $B052L9); + ADD_COLOR_CONFIG(SOFTKEY_ICON_HIGHLIGHTED, $B052L9); + + + + // BITMAP + ADD_IMAGE_CONFIG(BG_NORMAL, #00_toolbar_bg.9.png); + ADD_IMAGE_CONFIG(BG_DISABLED, #00_toolbar_bg.9.png); + ADD_IMAGE_CONFIG(BG_PRESSED, #00_toolbar_press.9.png); + ADD_IMAGE_CONFIG(BG_HIGHLIGHTED, #00_toolbar_press.9.png); + + ADD_IMAGE_CONFIG(BG_EFFECT_NORMAL, #00_toolbar_bg_ef.9.png); //not supported by theme + ADD_IMAGE_CONFIG(BG_EFFECT_PRESSED, #00_toolbar_ef_press.9.png); //not supported by theme + + ADD_IMAGE_CONFIG(BACK_ICON_NORMAL, #00_icon_Back.png); + ADD_IMAGE_CONFIG(BACK_ICON_DISABLED, #00_icon_Back.png); + ADD_IMAGE_CONFIG(BACK_ICON_PRESSED, #00_icon_Back.png); + ADD_IMAGE_CONFIG(BACK_ICON_HIGHLIGHTED, #00_icon_Back.png); + + ADD_IMAGE_CONFIG(BACK_ICON_EFFECT_NORMAL, #00_icon_Back_ef.png); //not supported by theme + ADD_IMAGE_CONFIG(BACK_ICON_EFFECT_PRESSED, #00_icon_Back_ef.png); //not supported by theme + + ADD_IMAGE_CONFIG(BACK_ICON_EFFECT_NORMAL2, #00_icon_Back_ef_02.png); //not supported by theme + ADD_IMAGE_CONFIG(BACK_ICON_EFFECT_PRESSED2, #00_icon_Back_ef_02.png); //not supported by theme + + ADD_IMAGE_CONFIG(BACK_ICON_TRANSLUCENT_EFFECT_NORMAL, #00_icon_Back_trans_ef.png); //not supported by theme + ADD_IMAGE_CONFIG(BACK_ICON_TRANSLUCENT_EFFECT_PRESSED, #00_icon_Back_trans_ef.png); //not supported by theme + + ADD_IMAGE_CONFIG(MORE_ICON_NORMAL, #00_icon_more.png); + ADD_IMAGE_CONFIG(MORE_ICON_DISABLED, #00_icon_more.png); + ADD_IMAGE_CONFIG(MORE_ICON_PRESSED, #00_icon_more.png); + ADD_IMAGE_CONFIG(MORE_ICON_HIGHLIGHTED, #00_icon_more.png); + + ADD_IMAGE_CONFIG(MORE_ICON_EFFECT_NORMAL, #00_icon_more_ef.png); //not supported by theme + ADD_IMAGE_CONFIG(MORE_ICON_EFFECT_PRESSED, #00_icon_more_ef.png); //not supported by theme + + ADD_IMAGE_CONFIG(BUTTON_ITEM_BG_NORMAL, #00_toolbar_button_bg.9.png); + ADD_IMAGE_CONFIG(BUTTON_ITEM_BG_DISABLED, #00_toolbar_button_bg.9.png); + ADD_IMAGE_CONFIG(BUTTON_ITEM_BG_PRESSED, #00_toolbar_button_bg.9.png); + ADD_IMAGE_CONFIG(BUTTON_ITEM_BG_HIGHLIGHTED, #00_toolbar_button_bg.9.png); + + ADD_IMAGE_CONFIG(BUTTON_ITEM_BG_EFFECT_NORMAL, #00_toolbar_button_ef.9.png); //not supported by theme + ADD_IMAGE_CONFIG(BUTTON_ITEM_BG_EFFECT_PRESSED, #00_toolbar_button_ef_press.9.png); //not supported by theme + + ADD_IMAGE_CONFIG(BUTTON_ITEM_TRANSLUCENT_BG_NORMAL, #00_toolbar_button.9.png); + ADD_IMAGE_CONFIG(BUTTON_ITEM_TRANSLUCENT_BG_DISABLED, #00_toolbar_button.9.png); + ADD_IMAGE_CONFIG(BUTTON_ITEM_TRANSLUCENT_BG_PRESSED, #00_toolbar_button_press.9.png); + ADD_IMAGE_CONFIG(BUTTON_ITEM_TRANSLUCENT_BG_HIGHLIGHTED, #00_toolbar_button_press.9.png); + + ADD_IMAGE_CONFIG(SOFTKEY_LEFT_BG_NORMAL, #00_softkey_left_bg.png); + ADD_IMAGE_CONFIG(SOFTKEY_LEFT_BG_DISABLED, #00_softkey_left_bg.png); + ADD_IMAGE_CONFIG(SOFTKEY_LEFT_BG_PRESSED, #00_softkey_left_bg.png); + ADD_IMAGE_CONFIG(SOFTKEY_LEFT_BG_HIGHLIGHTED, #00_softkey_left_bg.png); + + ADD_IMAGE_CONFIG(SOFTKEY_LEFT_BG_EFFECT_NORMAL, #00_softkey_left_bg_ef.png); //not supported by theme + ADD_IMAGE_CONFIG(SOFTKEY_LEFT_BG_EFFECT_PRESSED, #00_softkey_left_bg_ef_press.png); //not supported by theme + + ADD_IMAGE_CONFIG(SOFTKEY_RIGHT_BG_NORMAL, #00_softkey_right_bg.png); + ADD_IMAGE_CONFIG(SOFTKEY_RIGHT_BG_DISABLED, #00_softkey_right_bg.png); + ADD_IMAGE_CONFIG(SOFTKEY_RIGHT_BG_PRESSED, #00_softkey_right_bg.png); + ADD_IMAGE_CONFIG(SOFTKEY_RIGHT_BG_HIGHLIGHTED, #00_softkey_right_bg.png); + + ADD_IMAGE_CONFIG(SOFTKEY_RIGHT_BG_EFFECT_NORMAL, #00_softkey_right_bg_ef.png); //not supported by theme + ADD_IMAGE_CONFIG(SOFTKEY_RIGHT_BG_EFFECT_PRESSED, #00_softkey_right_bg_ef_press.png); //not supported by theme + + ADD_IMAGE_CONFIG(SOFTKEY_LEFT_TEXT_BG_NORMAL, #00_softkey_left_text_bg.png); + ADD_IMAGE_CONFIG(SOFTKEY_LEFT_TEXT_BG_DISABLED, #00_softkey_left_text_bg.png); + ADD_IMAGE_CONFIG(SOFTKEY_LEFT_TEXT_BG_PRESSED, #00_softkey_left_text_bg.png); + ADD_IMAGE_CONFIG(SOFTKEY_LEFT_TEXT_BG_HIGHLIGHTED, #00_softkey_left_text_bg.png); + + ADD_IMAGE_CONFIG(SOFTKEY_LEFT_TEXT_BG_EFFECT_NORMAL, #00_softkey_left_text_bg_ef.png); //not supported by theme + ADD_IMAGE_CONFIG(SOFTKEY_LEFT_TEXT_BG_EFFECT_PRESSED, #00_softkey_left_text_bg_ef_press.png); //not supported by theme + + ADD_IMAGE_CONFIG(SOFTKEY_RIGHT_TEXT_BG_NORMAL, #00_softkey_right_text_bg.png); + ADD_IMAGE_CONFIG(SOFTKEY_RIGHT_TEXT_BG_DISABLED, #00_softkey_right_text_bg.png); + ADD_IMAGE_CONFIG(SOFTKEY_RIGHT_TEXT_BG_PRESSED, #00_softkey_right_text_bg.png); + ADD_IMAGE_CONFIG(SOFTKEY_RIGHT_TEXT_BG_HIGHLIGHTED, #00_softkey_right_text_bg.png); + + ADD_IMAGE_CONFIG(SOFTKEY_RIGHT_TEXT_BG_EFFECT_NORMAL, #00_softkey_right_text_bg_ef.png); //not supported by theme + ADD_IMAGE_CONFIG(SOFTKEY_RIGHT_TEXT_BG_EFFECT_PRESSED, #00_softkey_right_text_bg_ef_press.png); //not supported by theme + + ADD_IMAGE_CONFIG(SOFTKEY_ICON_ADD_NORMAL, #00_softkey_icon_add.png); + ADD_IMAGE_CONFIG(SOFTKEY_ICON_ADD_DISABLED, #00_softkey_icon_add.png); + ADD_IMAGE_CONFIG(SOFTKEY_ICON_ADD_PRESSED, #00_softkey_icon_add.png); + ADD_IMAGE_CONFIG(SOFTKEY_ICON_ADD_HIGHLIGHTED, #00_softkey_icon_add.png); + + ADD_IMAGE_CONFIG(SOFTKEY_ICON_ZOOM_NORMAL, #00_softkey_icon_zoom.png); + ADD_IMAGE_CONFIG(SOFTKEY_ICON_ZOOM_DISABLED, #00_softkey_icon_zoom.png); + ADD_IMAGE_CONFIG(SOFTKEY_ICON_ZOOM_PRESSED, #00_softkey_icon_zoom.png); + ADD_IMAGE_CONFIG(SOFTKEY_ICON_ZOOM_HIGHLIGHTED, #00_softkey_icon_zoom.png); + + ADD_IMAGE_CONFIG(OPTIONKEY_BG_NORMAL, #00_option_panel_handle_bg.png); + ADD_IMAGE_CONFIG(OPTIONKEY_BG_DISABLED, #00_option_panel_handle_bg.png); + ADD_IMAGE_CONFIG(OPTIONKEY_BG_PRESSED, #00_option_panel_handle_bg_press.png); + ADD_IMAGE_CONFIG(OPTIONKEY_BG_HIGHLIGHTED, #00_option_panel_handle_bg_press.png); + + ADD_IMAGE_CONFIG(OPTIONKEY_BG_EFFECT_NORMAL, #00_option_panel_handle_bg_ef.png); //not supported by theme + ADD_IMAGE_CONFIG(OPTIONKEY_BG_EFFECT_PRESSED, #00_option_panel_handle_bg_ef_press.png); //not supported by theme + + + //SHAPE + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(HEIGHT, 98); + ADD_SHAPE_CONFIG(WIDTH, 720); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 28); + ADD_SHAPE_CONFIG(VERTICAL_MARGIN, 0); + ADD_SHAPE_CONFIG(BUTTON_ITEM_FONT_SIZE, 20); + ADD_SHAPE_CONFIG(FOOTER_ITEM_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(FOOTER_ITEM_ICON_SIZE, 56); + ADD_SHAPE_CONFIG(FOOTER_ITEM_BUTTON_STYLE_ICON_SIZE, 48); + ADD_SHAPE_CONFIG(FOOTER_ITEM_BUTTON_STYLE_ICON_SIZE_WITH_TEXT, 40); + ADD_SHAPE_CONFIG(FOOTER_ITEM_BUTTON_STYLE_SIDE_MARGIN, 28); + ADD_SHAPE_CONFIG(FOOTER_ITEM_TEXT_TOP_MARGIN, 0); + ADD_SHAPE_CONFIG(FOOTER_ITEM_TEXT_LEFT_MARGIN, 10); + ADD_SHAPE_CONFIG(ITEM_MINIMUM_WIDTH, 60); + ADD_SHAPE_CONFIG(COMMON_MINIMUM_MARGIN, 8); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_HEIGHT, 72); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_LEFT_MARGIN, 6); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_TOP_MARGIN, 6); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3, 25); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_4, 25); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_5, 22); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3_WITH_ICON, 22); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_4_WITH_ICON, 22); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_5_WITH_ICON, 18); + ADD_SHAPE_CONFIG(SEGMENTED_ITEM_FONT_SIZE, 30); + ADD_SHAPE_CONFIG(SEGMENTED_ICON_TEXT_GAP, 20); + ADD_SHAPE_CONFIG(FOOTER_ITEM_WIDTH_1_MAX, 490); + ADD_SHAPE_CONFIG(FOOTER_ITEM_WIDTH_1_MIN, 182); + ADD_SHAPE_CONFIG(BUTTON_ITEM_WIDTH, 56); + ADD_SHAPE_CONFIG(BUTTON_ITEM_HEIGHT, 56); + ADD_SHAPE_CONFIG(BUTTON_ITEM_ICON_SIZE, 56); + ADD_SHAPE_CONFIG(SOFTKEY_HEIGHT, 118);//720x1280 + ADD_SHAPE_CONFIG(SOFTKEY_TEXT_SIZE, 42); + ADD_SHAPE_CONFIG(SOFTKEY_0_LEFT_MARGIN, 3); + ADD_SHAPE_CONFIG(SOFTKEY_TOP_MARGIN, 20); + ADD_SHAPE_CONFIG(SOFTKEY_1_LEFT_MARGIN, 8); + ADD_SHAPE_CONFIG(SOFTKEY_ICON_SIZE, 92); + ADD_DIMENSION_CONFIG(SOFTKEY_RECT, 139, 118); + ADD_DIMENSION_CONFIG(SOFTKEY_RECT_WITH_TEXT, 207, 118); + ADD_DIMENSION_CONFIG(SOFTKEY_DISPLAY_RECT_WITH_TEXT, 196, 92); + ADD_DIMENSION_CONFIG(OPTIONKEY_RECT, 240, 118); + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + ADD_SHAPE_CONFIG(HEIGHT, 85); + ADD_SHAPE_CONFIG(WIDTH, 1280); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 28); + ADD_SHAPE_CONFIG(VERTICAL_MARGIN, 0); + ADD_SHAPE_CONFIG(BUTTON_ITEM_FONT_SIZE, 20); + ADD_SHAPE_CONFIG(FOOTER_ITEM_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(FOOTER_ITEM_ICON_SIZE, 56); + ADD_SHAPE_CONFIG(FOOTER_ITEM_BUTTON_STYLE_ICON_SIZE, 48); + ADD_SHAPE_CONFIG(FOOTER_ITEM_BUTTON_STYLE_ICON_SIZE_WITH_TEXT, 40); + ADD_SHAPE_CONFIG(FOOTER_ITEM_BUTTON_STYLE_SIDE_MARGIN, 28); + ADD_SHAPE_CONFIG(FOOTER_ITEM_TEXT_TOP_MARGIN, 0); + ADD_SHAPE_CONFIG(FOOTER_ITEM_TEXT_LEFT_MARGIN, 10);//1280x720 + ADD_SHAPE_CONFIG(ITEM_MINIMUM_WIDTH, 60); + ADD_SHAPE_CONFIG(COMMON_MINIMUM_MARGIN, 8); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_HEIGHT, 72); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_LEFT_MARGIN, 6); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_TOP_MARGIN, 6); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3, 25); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_4, 25); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_5, 22); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_3_WITH_ICON, 22); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_4_WITH_ICON, 22); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TEXT_FONT_SIZE_ITEM_5_WITH_ICON, 18); + ADD_SHAPE_CONFIG(SEGMENTED_ITEM_FONT_SIZE, 30); + ADD_SHAPE_CONFIG(SEGMENTED_ICON_TEXT_GAP, 54); + ADD_SHAPE_CONFIG(FOOTER_ITEM_WIDTH_1_MAX, 1000); + ADD_SHAPE_CONFIG(FOOTER_ITEM_WIDTH_1_MIN, 330);//1280x720 + ADD_SHAPE_CONFIG(BUTTON_ITEM_WIDTH, 56); + ADD_SHAPE_CONFIG(BUTTON_ITEM_HEIGHT, 56); + ADD_SHAPE_CONFIG(BUTTON_ITEM_ICON_SIZE, 56); + ADD_SHAPE_CONFIG(SOFTKEY_HEIGHT, 118); + ADD_SHAPE_CONFIG(SOFTKEY_TEXT_SIZE, 42); + ADD_SHAPE_CONFIG(SOFTKEY_0_LEFT_MARGIN, 3); + ADD_SHAPE_CONFIG(SOFTKEY_TOP_MARGIN, 20); + ADD_SHAPE_CONFIG(SOFTKEY_1_LEFT_MARGIN, 8); + ADD_SHAPE_CONFIG(SOFTKEY_ICON_SIZE, 92); + ADD_DIMENSION_CONFIG(SOFTKEY_RECT, 139, 118); + ADD_DIMENSION_CONFIG(SOFTKEY_RECT_WITH_TEXT, 207, 118); + ADD_DIMENSION_CONFIG(SOFTKEY_DISPLAY_RECT_WITH_TEXT, 196, 92); + ADD_DIMENSION_CONFIG(OPTIONKEY_RECT, 240, 118); + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(FOOTER); + diff --git a/src/ui/resource/FUi_ResourceFormConfig.cpp b/src/ui/resource/FUi_ResourceFormConfig.cpp new file mode 100644 index 0000000..d217fa4 --- /dev/null +++ b/src/ui/resource/FUi_ResourceFormConfig.cpp @@ -0,0 +1,49 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceFormConfig.cpp + * @brief This is the implementation file for the color properties of Form. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(FORM); +{ + ADD_COLOR_CONFIG(BG_NORMAL, $B011); + + START_UI_CONFIG_MODE(480x800); + ADD_SHAPE_CONFIG(INDICATOR_WIDTH, 480); + ADD_SHAPE_CONFIG(INDICATOR_HEIGHT, 38); + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(800x480); + ADD_SHAPE_CONFIG(INDICATOR_WIDTH, 800); + ADD_SHAPE_CONFIG(INDICATOR_HEIGHT, 38); + END_UI_CONFIG_MODE(800x480); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(INDICATOR_WIDTH, 720); + ADD_SHAPE_CONFIG(INDICATOR_HEIGHT, 60); + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + ADD_SHAPE_CONFIG(INDICATOR_WIDTH, 1280); + ADD_SHAPE_CONFIG(INDICATOR_HEIGHT, 60); + END_UI_CONFIG_MODE(1280x720); + +} +END_UI_CONFIG(FORM); diff --git a/src/ui/resource/FUi_ResourceGalleryConfig.cpp b/src/ui/resource/FUi_ResourceGalleryConfig.cpp new file mode 100644 index 0000000..1885c9b --- /dev/null +++ b/src/ui/resource/FUi_ResourceGalleryConfig.cpp @@ -0,0 +1,35 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceGalleryConfig.cpp + * @brief This is the implementation file for the properties of Gallery. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(GALLERY); +{ + ADD_COLOR_CONFIG(EMPTY_GALLERY_TEXT_NORMAL, $F011L21); + + START_UI_CONFIG_MODE(480x800); + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(720x1280); + END_UI_CONFIG_MODE(720x1280); +} +END_UI_CONFIG(GALLERY); + diff --git a/src/ui/resource/FUi_ResourceHeaderConfig.cpp b/src/ui/resource/FUi_ResourceHeaderConfig.cpp new file mode 100644 index 0000000..f2b316a --- /dev/null +++ b/src/ui/resource/FUi_ResourceHeaderConfig.cpp @@ -0,0 +1,291 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceHeaderConfig.cpp + * @brief This is the implementation file for the properties of Header. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(HEADER); +{ + // COLOR + ADD_COLOR_CONFIG(BG_NORMAL, $B0511); + ADD_COLOR_CONFIG(TRANSLUCENT_BG_NORMAL, $B013); + + ADD_COLOR_CONFIG(TITLE_TEXT_NORMAL, $B052L5); + ADD_COLOR_CONFIG(TRANSLUCENT_TITLE_TEXT_NORMAL, $B052L8); + + ADD_COLOR_CONFIG(DESCRIPTION_TEXT_NORMAL, $B052L5); + ADD_COLOR_CONFIG(TRANSLUCENT_DESCRIPTION_TEXT_NORMAL, $B052L8); + + ADD_COLOR_CONFIG(BUTTON_BG_NORMAL, $B0511); + ADD_COLOR_CONFIG(BUTTON_BG_DISABLED, $B0511); + ADD_COLOR_CONFIG(BUTTON_BG_PRESSED, $B0511); + ADD_COLOR_CONFIG(BUTTON_BG_HIGHLIGHTED, $B0511); + + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_BG_NORMAL, $B013); + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_BG_DISABLED, $B013); + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_BG_PRESSED, $B013); + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_BG_HIGHLIGHTED, $B013); + + ADD_COLOR_CONFIG(BUTTON_TEXT_NORMAL, $B052L4); + ADD_COLOR_CONFIG(BUTTON_TEXT_DISABLED, $B052L4D); + ADD_COLOR_CONFIG(BUTTON_TEXT_PRESSED, $B052L6P); + ADD_COLOR_CONFIG(BUTTON_TEXT_HIGHLIGHTED, $B052L4P); + + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_TEXT_NORMAL, $B052L8); + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_TEXT_DISABLED, $B052L8); + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_TEXT_PRESSED, $B052L8P); + ADD_COLOR_CONFIG(BUTTON_TRANSLUCENT_TEXT_HIGHLIGHTED, $B052L8P); + + + + ADD_COLOR_CONFIG(SEGMENTED_ITEM_BG_NORMAL, $B0513); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_BG_DISABLED, $B0513); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_BG_PRESSED, $B0514P1); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_BG_HIGHLIGHTED, $B0514P1); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_BG_SELECTED, $B0513); + + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_BG_NORMAL, $B013); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_BG_DISABLED, $B013); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_BG_PRESSED, $B013); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_BG_HIGHLIGHTED, $B013); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_BG_SELECTED, $B013); + + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TEXT_NORMAL, $B052L6); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TEXT_DISABLED, $B052L4D); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TEXT_PRESSED, $B052L6P); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TEXT_HIGHLIGHTED, $B052L6P); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TEXT_SELECTED, $B052L6P); + + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_TEXT_NORMAL, $B052L8); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_TEXT_DISABLED, $B052L8); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_TEXT_PRESSED, $B052L8P); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_TEXT_HIGHLIGHTED, $B052L8P); + ADD_COLOR_CONFIG(SEGMENTED_ITEM_TRANSLUCENT_TEXT_SELECTED, $B052L8P); + + ADD_COLOR_CONFIG(BADGE_ICON_BG_NORMAL, $B0519); + ADD_COLOR_CONFIG(BADGE_ICON_BG_DISABLED, $B0519); + ADD_COLOR_CONFIG(BADGE_ICON_BG_PRESSED, $B0519); + ADD_COLOR_CONFIG(BADGE_ICON_BG_HIGHLIGHTED, $B0519); + + ADD_COLOR_CONFIG(BADGE_ICON_TEXT_NORMAL, $B052L7); + ADD_COLOR_CONFIG(BADGE_ICON_TEXT_DISABLED, $B052L7); + ADD_COLOR_CONFIG(BADGE_ICON_TEXT_PRESSED, $B052L7); + ADD_COLOR_CONFIG(BADGE_ICON_TEXT_HIGHLIGHTED, $B052L7); + + + // BITMAP + ADD_IMAGE_CONFIG(BG_NORMAL, #00_title_bg.9.png); + ADD_IMAGE_CONFIG(TAB_ITEM_BG_EFFECT_PRESSED, #00_tab_press_ef.9.png); + ADD_IMAGE_CONFIG(TAB_ITEM_BG_SELECTED, #00_tab_focus.9.png); + + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_01, #00_list_process_01_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_02, #00_list_process_02_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_03, #00_list_process_03_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_04, #00_list_process_04_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_05, #00_list_process_05_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_06, #00_list_process_06_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_07, #00_list_process_07_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_08, #00_list_process_08_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_09, #00_list_process_09_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_10, #00_list_process_10_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_11, #00_list_process_11_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_12, #00_list_process_12_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_13, #00_list_process_13_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_14, #00_list_process_14_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_15, #00_list_process_15_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_16, #00_list_process_16_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_17, #00_list_process_17_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_18, #00_list_process_18_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_19, #00_list_process_19_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_20, #00_list_process_20_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_21, #00_list_process_21_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_22, #00_list_process_22_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_23, #00_list_process_23_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_24, #00_list_process_24_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_25, #00_list_process_25_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_26, #00_list_process_26_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_27, #00_list_process_27_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_28, #00_list_process_28_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_29, #00_list_process_29_32x32.png); + ADD_IMAGE_CONFIG(PROCESSING_ANIMATION_30, #00_list_process_30_32x32.png); + + ADD_IMAGE_CONFIG(BADGE_ICON_BG_NORMAL, #00_badge_bg.9.png); + ADD_IMAGE_CONFIG(BADGE_ICON_BG_DISABLED, #00_badge_bg.9.png); + ADD_IMAGE_CONFIG(BADGE_ICON_BG_PRESSED, #00_badge_bg.9.png); + ADD_IMAGE_CONFIG(BADGE_ICON_BG_HIGHLIGHTED, #00_badge_bg.9.png); + + ADD_IMAGE_CONFIG(BADGE_ICON_BG_EFFECT_NORMAL, #00_badge_bg_ef.9.png); //not supported by theme + ADD_IMAGE_CONFIG(BADGE_ICON_BG_EFFECT_PRESSED, #00_badge_bg_ef.9.png); //not supported by theme + + ADD_IMAGE_CONFIG(DIVIDER_LINE_NORMAL, #00_divider_line.9.png); + ADD_IMAGE_CONFIG(DIVIDER_LINE_TRANSLUCENT_NORMAL, #00_divider_line_translucent.9.png); + + // SHAPE + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(HEIGHT, 111); + ADD_SHAPE_CONFIG(WIDTH, 720); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(TOP_MARGIN, 34); + ADD_SHAPE_CONFIG(RIGHT_MARGIN, 28); + ADD_SHAPE_CONFIG(RIGHT_MARGIN_WITH_SEGMENTED_BUTTON, 6); + + ADD_SHAPE_CONFIG(TITLE_FONT_SIZE, 56); + ADD_SHAPE_CONFIG(TITLE_FONT_SIZE_WITH_DESCRIPTION, 44); + ADD_SHAPE_CONFIG(TITLE_FONT_SIZE_WITH_SEGMENTED, 44); + ADD_SHAPE_CONFIG(DESCRIPTION_TEXT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(BUTTON_ITEM_FONT_SIZE, 27); + ADD_SHAPE_CONFIG(SEGMENTED_ITEM_FONT_SIZE, 28) + ADD_SHAPE_CONFIG(TAB_ITEM_FONT_SIZE, 30); + ADD_SHAPE_CONFIG(TAB_ITEM_FONT_SIZE_3_ITEM, 28);//720x1280 + ADD_SHAPE_CONFIG(TAB_ITEM_FONT_SIZE_4_ITEM, 24); + ADD_SHAPE_CONFIG(BADGE_FONT_SIZE, 26); + + ADD_SHAPE_CONFIG(TITLE_DISPLAY_HEIGHT, 64); + ADD_SHAPE_CONFIG(TITLE_TOP_MARGIN_WITH_DESCRIPTION, 18); + ADD_SHAPE_CONFIG(TITLE_DISPLAY_HEIGHT_WITH_DESCRIPTION, 50); + ADD_SHAPE_CONFIG(TITLE_TOTAL_HEIGHT_WITH_SEGMENTED_ITEM, 165); + ADD_SHAPE_CONFIG(TITLE_TOP_MARGIN_WITH_SEGMENTED_ITEM, 18); + ADD_SHAPE_CONFIG(TITLE_HEIGHT_WITH_SEGMENTED_ITEM, 89); + ADD_SHAPE_CONFIG(TITLE_DISPLAY_HEIGHT_WITH_SEGMENTED_ITEM, 60); + ADD_SHAPE_CONFIG(DESCRIPTION_TEXT_HEIGHT, 36); + + ADD_SHAPE_CONFIG(BUTTON_ITEM_WIDTH, 64); + ADD_SHAPE_CONFIG(BUTTON_ITEM_WIDTH_WITH_TEXT, 114); + ADD_SHAPE_CONFIG(BUTTON_ITEM_HEIGHT, 64); + ADD_SHAPE_CONFIG(BUTTON_ITEM_WIDTH_OF_SEGMENTED, 128); + ADD_SHAPE_CONFIG(BUTTON_ITEM_WIDTH_OF_SEGMENTED_2, 106); + ADD_SHAPE_CONFIG(BUTTON_ITEM_HEIGHT_OF_SEGMENTED, 111); + ADD_SHAPE_CONFIG(BUTTON_ITEM_GAP, 4); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TOP_MARGIN, 34); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TOP_MARGIN_OF_SEGMENTED, 0); + ADD_SHAPE_CONFIG(BUTTON_ITEM_ICON_TOP_MARGIN, 32); + ADD_SHAPE_CONFIG(BUTTON_ITEM_ICON_SIZE, 64); + + ADD_SHAPE_CONFIG(SEGMENTED_ITEM_HEIGHT, 64); + + ADD_SHAPE_CONFIG(TAB_ITEM_ICON_SIZE, 64); + ADD_SHAPE_CONFIG(TAB_ITEM_ICON_SIZE_WITH_TEXT, 44); + ADD_SHAPE_CONFIG(TAB_LEFT_MARGIN, 16); + + ADD_SHAPE_CONFIG(SIP_BUTTON_ITEM_TOP_MARGIN, 40); + ADD_SHAPE_CONFIG(SIP_FOOTER_ITEM_TOP_MARGIN, 33); + + ADD_SHAPE_CONFIG(ICON_WIDTH, 38); + ADD_SHAPE_CONFIG(ICON_TEXT_GAP, 8); + + ADD_SHAPE_CONFIG(SEPARATOR_WIDTH, 4); + ADD_SHAPE_CONFIG(SEPARATOR_HEIGHT, 26); + + ADD_SHAPE_CONFIG(BADGE_HEIGHT, 48); + ADD_SHAPE_CONFIG(BADGE_WIDTH_1DIGIT, 54); + ADD_SHAPE_CONFIG(BADGE_WIDTH_2DIGIT, 64); + ADD_SHAPE_CONFIG(BADGE_WIDTH_3DIGIT, 70); + ADD_SHAPE_CONFIG(BADGE_WIDTH_4DIGIT, 80); + ADD_SHAPE_CONFIG(BADGE_WIDTH_5DIGIT, 90); + + ADD_SHAPE_CONFIG(HEADER_ITEM_SELECTED_BITMAP_MARGIN, 16); + ADD_SHAPE_CONFIG(HEADER_ITEM_SELECTED_BITMAP_HEIGHT, 3); + + ADD_SHAPE_CONFIG(PROCESSING_ANIMATION_ICON_SIZE, 32); + ADD_SHAPE_CONFIG(PROCESSING_ANIMATION_ICON_GAP, 16); + + ADD_SHAPE_CONFIG(HEADER_ITEM_WIDTH_1_MIN, 182); + ADD_SHAPE_CONFIG(TITLE_MINIMUM_WIDTH, 60); + ADD_SHAPE_CONFIG(ITEM_MINIMUM_WIDTH, 60); + ADD_SHAPE_CONFIG(COMMON_MINIMUM_MARGIN, 8); + + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + ADD_SHAPE_CONFIG(HEIGHT, 91); + ADD_SHAPE_CONFIG(WIDTH, 1280); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(TOP_MARGIN, 17); + ADD_SHAPE_CONFIG(RIGHT_MARGIN, 28); + ADD_SHAPE_CONFIG(RIGHT_MARGIN_WITH_SEGMENTED_BUTTON, 6); + + ADD_SHAPE_CONFIG(TITLE_FONT_SIZE, 50); + ADD_SHAPE_CONFIG(TITLE_FONT_SIZE_WITH_DESCRIPTION, 38); + ADD_SHAPE_CONFIG(TITLE_FONT_SIZE_WITH_SEGMENTED, 38); + ADD_SHAPE_CONFIG(DESCRIPTION_TEXT_FONT_SIZE, 28); + ADD_SHAPE_CONFIG(BUTTON_ITEM_FONT_SIZE, 27); + ADD_SHAPE_CONFIG(SEGMENTED_ITEM_FONT_SIZE, 28); + ADD_SHAPE_CONFIG(TAB_ITEM_FONT_SIZE, 30);//1280x720 + ADD_SHAPE_CONFIG(TAB_ITEM_FONT_SIZE_3_ITEM, 28); + ADD_SHAPE_CONFIG(TAB_ITEM_FONT_SIZE_4_ITEM, 24); + ADD_SHAPE_CONFIG(BADGE_FONT_SIZE, 26); + + ADD_SHAPE_CONFIG(TITLE_DISPLAY_HEIGHT, 64); + ADD_SHAPE_CONFIG(TITLE_TOP_MARGIN_WITH_DESCRIPTION, 11); + ADD_SHAPE_CONFIG(TITLE_DISPLAY_HEIGHT_WITH_DESCRIPTION, 42); + ADD_SHAPE_CONFIG(TITLE_TOTAL_HEIGHT_WITH_SEGMENTED_ITEM, 145); + ADD_SHAPE_CONFIG(TITLE_TOP_MARGIN_WITH_SEGMENTED_ITEM, 17); + ADD_SHAPE_CONFIG(TITLE_HEIGHT_WITH_SEGMENTED_ITEM, 77); + ADD_SHAPE_CONFIG(TITLE_DISPLAY_HEIGHT_WITH_SEGMENTED_ITEM, 60); + ADD_SHAPE_CONFIG(DESCRIPTION_TEXT_HEIGHT, 32); + + ADD_SHAPE_CONFIG(BUTTON_ITEM_WIDTH, 64); + ADD_SHAPE_CONFIG(BUTTON_ITEM_WIDTH_WITH_TEXT, 114); + ADD_SHAPE_CONFIG(BUTTON_ITEM_HEIGHT, 64); + ADD_SHAPE_CONFIG(BUTTON_ITEM_WIDTH_OF_SEGMENTED, 128); + ADD_SHAPE_CONFIG(BUTTON_ITEM_WIDTH_OF_SEGMENTED_2, 106); + ADD_SHAPE_CONFIG(BUTTON_ITEM_HEIGHT_OF_SEGMENTED, 91); + ADD_SHAPE_CONFIG(BUTTON_ITEM_GAP, 4); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TOP_MARGIN, 17); + ADD_SHAPE_CONFIG(BUTTON_ITEM_TOP_MARGIN_OF_SEGMENTED, 0); + ADD_SHAPE_CONFIG(BUTTON_ITEM_ICON_TOP_MARGIN, 15); + ADD_SHAPE_CONFIG(BUTTON_ITEM_ICON_SIZE, 64); + + ADD_SHAPE_CONFIG(SEGMENTED_ITEM_HEIGHT, 64); + + ADD_SHAPE_CONFIG(TAB_ITEM_ICON_SIZE, 64); + ADD_SHAPE_CONFIG(TAB_ITEM_ICON_SIZE_WITH_TEXT, 44); + ADD_SHAPE_CONFIG(TAB_LEFT_MARGIN, 34); + + ADD_SHAPE_CONFIG(SIP_BUTTON_ITEM_TOP_MARGIN, 40);//1280x720 + ADD_SHAPE_CONFIG(SIP_FOOTER_ITEM_TOP_MARGIN, 33); + + ADD_SHAPE_CONFIG(ICON_WIDTH, 38); + ADD_SHAPE_CONFIG(ICON_TEXT_GAP, 8); + + ADD_SHAPE_CONFIG(SEPARATOR_WIDTH, 4); + ADD_SHAPE_CONFIG(SEPARATOR_HEIGHT, 26); + + ADD_SHAPE_CONFIG(BADGE_HEIGHT, 48); + ADD_SHAPE_CONFIG(BADGE_WIDTH_1DIGIT, 54); + ADD_SHAPE_CONFIG(BADGE_WIDTH_2DIGIT, 64); + ADD_SHAPE_CONFIG(BADGE_WIDTH_3DIGIT, 70); + ADD_SHAPE_CONFIG(BADGE_WIDTH_4DIGIT, 80); + ADD_SHAPE_CONFIG(BADGE_WIDTH_5DIGIT, 90); + + ADD_SHAPE_CONFIG(HEADER_ITEM_SELECTED_BITMAP_MARGIN, 16); + ADD_SHAPE_CONFIG(HEADER_ITEM_SELECTED_BITMAP_HEIGHT, 3); + + ADD_SHAPE_CONFIG(PROCESSING_ANIMATION_ICON_SIZE, 32); + ADD_SHAPE_CONFIG(PROCESSING_ANIMATION_ICON_GAP, 16); + + ADD_SHAPE_CONFIG(HEADER_ITEM_WIDTH_1_MIN, 330);//1280x720 + ADD_SHAPE_CONFIG(TITLE_MINIMUM_WIDTH, 60); + ADD_SHAPE_CONFIG(ITEM_MINIMUM_WIDTH, 60); + ADD_SHAPE_CONFIG(COMMON_MINIMUM_MARGIN, 8); + + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(HEADER); diff --git a/src/ui/resource/FUi_ResourceIconListConfig.cpp b/src/ui/resource/FUi_ResourceIconListConfig.cpp new file mode 100644 index 0000000..fcdf603 --- /dev/null +++ b/src/ui/resource/FUi_ResourceIconListConfig.cpp @@ -0,0 +1,83 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceIconListConfig.cpp + * @brief This is the implementation file for the shape and color properties of IconListView. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(ICONLIST); +{ + ADD_COLOR_CONFIG(EMPTY_TEXT_NORMAL, $F011L21); + ADD_COLOR_CONFIG(TEXT_NORMAL, $F011L1); + ADD_COLOR_CONFIG(TEXT_PRESSED, $F011L1); + ADD_COLOR_CONFIG(TEXT_HIGHLIGHTED, $F011L1); + ADD_COLOR_CONFIG(INNER_TEXT_BG_NORMAL, $B014); + ADD_COLOR_CONFIG(ITEM_BG_PRESSED, $B013); + ADD_COLOR_CONFIG(ITEM_BORDER_NORMAL, $W151); + ADD_COLOR_CONFIG(ITEM_BORDER_PRESSED, $W151); + ADD_COLOR_CONFIG(ITEM_BORDER_HIGHLIGHTED, $W153); + ADD_IMAGE_CONFIG(ITEM_BORDER_NORMAL, #00_thumbs_line_bg.9.png); + ADD_IMAGE_CONFIG(ITEM_BORDER_PRESSED, #00_thumbs_line_bg.9.png); + ADD_IMAGE_CONFIG(ITEM_BORDER_HIGHLIGHTED, #00_thumbs_bg_focus.9.png); + ADD_IMAGE_CONFIG(CHECK_BG_NORMAL, #00_grid_select_check_bg.png); + ADD_IMAGE_CONFIG(CHECK_BG_SELECTED, #00_grid_select_check_bg_press.png); + ADD_IMAGE_CONFIG(CHECK_SELECTED, #00_grid_select_check.png); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(TOP_MARGIN, 8); + ADD_SHAPE_CONFIG(BOTTOM_MARGIN, 8); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 3); + ADD_SHAPE_CONFIG(RIGHT_MARGIN, 3); + ADD_SHAPE_CONFIG(HORIZONTAL_LEFT_MARGIN, 8); + ADD_SHAPE_CONFIG(HORIZONTAL_RIGHT_MARGIN, 8); + ADD_SHAPE_CONFIG(HORIZONTAL_SPACING, 2); + ADD_SHAPE_CONFIG(VERTICAL_SPACING, 2); + ADD_SHAPE_CONFIG(OUTSIDE_TEXT_TOP_MARGIN, 8); + ADD_SHAPE_CONFIG(OUTSIDE_TEXT_BOTTOM_MARGIN, 8); + ADD_SHAPE_CONFIG(OUTSIDE_TEXT_LEFT_MARGIN, 6); + ADD_SHAPE_CONFIG(OUTSIDE_TEXT_RIGHT_MARGIN, 6); + ADD_SHAPE_CONFIG(OUTSIDE_TEXT_VERTICAL_SPACING, 2); + ADD_SHAPE_CONFIG(FONT_SIZE, 26); + ADD_FIXED_VALUE_CONFIG(MINIMUM_FONT_SIZE, 6); + ADD_SHAPE_CONFIG(INSIDE_FONT_SIZE, 26); + ADD_SHAPE_CONFIG(OUTSIDE_FONT_SIZE, 26); + ADD_SHAPE_CONFIG(EMPTY_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(EMPTY_TEXT_HEIGHT, 38); + ADD_SHAPE_CONFIG(INSIDE_ONE_LINE_TEXT_HEIGHT, 36); + ADD_SHAPE_CONFIG(INSIDE_TWO_LINE_TEXT_HEIGHT, 64); + ADD_SHAPE_CONFIG(VERTICAL_EXTENT, 64); + ADD_FIXED_VALUE_CONFIG(DROP_SHADOW_WIDTH, 18); + ADD_FIXED_VALUE_CONFIG(DROP_SHADOW_HEIGHT, 18); + ADD_FIXED_VALUE_CONFIG(DROP_SHADOW_BORDER, 2); + ADD_FIXED_VALUE_CONFIG(DROP_SHADOW_MARGIN, 8); + ADD_FIXED_VALUE_CONFIG(SELECT_BG_MARGIN, 1); + ADD_FIXED_VALUE_CONFIG(TEXT_HORIZONTAL_MARGIN, 1); + ADD_FIXED_VALUE_CONFIG(TEXT_VERTICAL_MARGIN, 4); + ADD_FIXED_VALUE_CONFIG(OVERLAY_ICON_MARGIN, 0); + ADD_FIXED_VALUE_CONFIG(CHECKBOX_MARGIN, 6); + ADD_DIMENSION_CONFIG(CHECKBOX_SIZE, 54, 54); + ADD_SHAPE_CONFIG(LIST1X_TOP_MARGIN, 3); + ADD_SHAPE_CONFIG(LIST1X_LEFT_MARGIN, 8); + ADD_SHAPE_CONFIG(LIST1X_RIGHT_MARGIN, 3); + END_UI_CONFIG_MODE(720x1280); + +} +END_UI_CONFIG(ICONLIST); + diff --git a/src/ui/resource/FUi_ResourceInputPadConfig.cpp b/src/ui/resource/FUi_ResourceInputPadConfig.cpp new file mode 100644 index 0000000..2a216ad --- /dev/null +++ b/src/ui/resource/FUi_ResourceInputPadConfig.cpp @@ -0,0 +1,71 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceInputPadConfig.cpp + * @brief This is the implementation file for the color, image and shape config of _InputPad class. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(INPUTPAD); +{ + ADD_COLOR_CONFIG(TEXT_NORMAL, $F031L1); + ADD_COLOR_CONFIG(TEXT_PRESSED, $F031L1P); + ADD_COLOR_CONFIG(GUIDE_TEXT_NORMAL, $F031L1); + ADD_COLOR_CONFIG(BUTTON_BG_NORMAL, $W011); + ADD_COLOR_CONFIG(BUTTON_BG_PRESSED, $B042); + + ADD_IMAGE_CONFIG(BG_NORMAL, #00_time_picker_keypad_bg.9.png); + ADD_IMAGE_CONFIG(BUTTON_BG_NORMAL, #00_time_picker_keypad_button_bg.9.png); + ADD_IMAGE_CONFIG(BUTTON_BG_EFFECT_NORMAL, #00_time_picker_keypad_button_bg_ef.9.png); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_SHAPE_CONFIG(TOP_MARGIN, 23); + ADD_SHAPE_CONFIG(BUTTON_HORIZONTAL_MARGIN, 14); + ADD_SHAPE_CONFIG(BUTTON_VERTICAL_MARGIN, 19); + + ADD_SHAPE_CONFIG(NUMERIC_FONT_SIZE, 65); + ADD_SHAPE_CONFIG(ALPHA_FONT_SIZE, 56); + ADD_SHAPE_CONFIG(GUIDE_FONT_SIZE, 32); + + ADD_SHAPE_CONFIG(TEXT_CORRECTION_Y, 3); + ADD_SHAPE_CONFIG(GUIDE_CORRECTION_X, 15); + ADD_FIXED_VALUE_CONFIG(BUTTON_TOUCH_CORRECTION_Y, 5); + + ADD_SHAPE_CONFIG(BUTTON_WIDTH, 228); + ADD_SHAPE_CONFIG(BUTTON_HEIGHT, 100); + } + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + { + ADD_SHAPE_CONFIG(TOP_MARGIN, 11); + ADD_SHAPE_CONFIG(BUTTON_HORIZONTAL_MARGIN, 16); + ADD_SHAPE_CONFIG(BUTTON_VERTICAL_MARGIN, 10); + + ADD_SHAPE_CONFIG(NUMERIC_FONT_SIZE, 45); + ADD_SHAPE_CONFIG(ALPHA_FONT_SIZE, 36); + ADD_SHAPE_CONFIG(GUIDE_FONT_SIZE, 12); + + ADD_SHAPE_CONFIG(BUTTON_HEIGHT, 68); + } + END_UI_CONFIG_MODE(1280x720); + +} +END_UI_CONFIG(INPUTPAD); diff --git a/src/ui/resource/FUi_ResourceLabelConfig.cpp b/src/ui/resource/FUi_ResourceLabelConfig.cpp new file mode 100644 index 0000000..51c660f --- /dev/null +++ b/src/ui/resource/FUi_ResourceLabelConfig.cpp @@ -0,0 +1,46 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceLabelConfig.cpp + * @brief This is the implementation file for the properties of Label. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(LABEL); +{ + ADD_COLOR_CONFIG(TEXT_NORMAL, $F011L1); + + START_UI_CONFIG_MODE(480x800); + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(TEXT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(TOP_MARGIN, 0); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 16); + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + ADD_SHAPE_CONFIG(TEXT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(TOP_MARGIN, 0); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 16); + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(LABEL); diff --git a/src/ui/resource/FUi_ResourceListConfig.cpp b/src/ui/resource/FUi_ResourceListConfig.cpp new file mode 100644 index 0000000..4c0485e --- /dev/null +++ b/src/ui/resource/FUi_ResourceListConfig.cpp @@ -0,0 +1,67 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceListConfig.cpp + * @brief This is the implementation file for the UI properties of 1.x Lists. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(LIST); +{ + ADD_COLOR_CONFIG(LISTITEM_DIVIDER_LEFT_HALF_COLOR, $B0231L1); + ADD_COLOR_CONFIG(LISTITEM_DIVIDER_RIGHT_HALF_COLOR, $B0231L2); + ADD_COLOR_CONFIG(EXPANDABLELIST_DOWN_AND_UP_ARROW_COLOR, $B0231L1); + ADD_COLOR_CONFIG(EXPANDABLELIST_SUB_ITEM_BG_COLOR, $B0217); + ADD_COLOR_CONFIG(ELEMENT_TEXT_NORMAL, $F011L1); + ADD_COLOR_CONFIG(ELEMENT_TEXT_PRESSED, $F011L1P); + ADD_COLOR_CONFIG(ELEMENT_TEXT_HIGHLIGHTED, $F011L1P); + ADD_COLOR_CONFIG(ELEMENT_TEXT_DISABLED, $F011L1D); + ADD_IMAGE_CONFIG(CHECK_BG_BITMAP, #00_check_bg.png); + ADD_IMAGE_CONFIG(CHECK_MARK_BG_BITMAP, #00_check_checking.png); + ADD_IMAGE_CONFIG(CHECK_DIM_BITMAP, #00_check_dim.png); + ADD_IMAGE_CONFIG(BUTTON_RADIO_BITMAP, #00_button_radio_normal2.png); + ADD_IMAGE_CONFIG(BUTTON_RADIO_SELECTED_BITMAP, #00_button_radio_normal1.png); + ADD_IMAGE_CONFIG(BUTTON_OFF_BITMAP, #00_button_off_temp.png); + ADD_IMAGE_CONFIG(BUTTON_ON_BITMAP, #00_button_on_temp.png); + ADD_IMAGE_CONFIG(BUTTON_EXPAND_GROUP, #00_button_expand_opened.png); + ADD_IMAGE_CONFIG(BUTTON_COLLAPSE_GROUP, #00_button_expand_closed.png); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(EMPTY_LIST_TEXT_HEIGHT, 38); + ADD_DIMENSION_CONFIG(LIST_MIN_SIZE, 90, 72); + ADD_DIMENSION_CONFIG(GROUPEDLIST_MIN_SIZE, 270, 144); + ADD_FIXED_VALUE_CONFIG(LIST_ITEM_MAX_COUNT, 99); + ADD_SHAPE_CONFIG(LIST_ITEM_TEXT_SIZE, 38); + ADD_SHAPE_CONFIG(LIST_STYLE_NUMBER_X, 10); + ADD_SHAPE_CONFIG(LIST_STYLE_NUMBER_WIDTH, 30); + ADD_SHAPE_CONFIG(LIST_STYLE_NUMBER_HEIGHT, 30); + ADD_SHAPE_CONFIG(LIST_CHECK_ITEM_WIDTH, 50); + ADD_SHAPE_CONFIG(LIST_CHECK_ITEM_HEIGHT, 50); + ADD_SHAPE_CONFIG(LIST_ITEM_NUMBER_STYLE_MARGIN, 40); + ADD_SHAPE_CONFIG(LIST_ITEM_LEFT_MARGIN, 10); + ADD_SHAPE_CONFIG(LIST_ITEM_DIVIDER_MARGIN, 80); + ADD_SHAPE_CONFIG(LIST_ITEM_LOWER_MARGIN, 10); + ADD_SHAPE_CONFIG(LIST_ITEM_UPPER_MARGIN, 10); + ADD_SHAPE_CONFIG(TEXT_ELEMENT_FONTSIZE_DEFAULT, 38); + ADD_SHAPE_CONFIG(CHECK_ELEMENT_DIVIDER_WIDTH, 2); + ADD_SHAPE_CONFIG(CHECK_ELEMENT_DIVIDER_MARGIN, 10); + ADD_SHAPE_CONFIG(LIST_DEFAULT_ITEM_HEIGHT, 100); + END_UI_CONFIG_MODE(720x1280); +} +END_UI_CONFIG(LIST); diff --git a/src/ui/resource/FUi_ResourceListViewConfig.cpp b/src/ui/resource/FUi_ResourceListViewConfig.cpp new file mode 100644 index 0000000..19b1abc --- /dev/null +++ b/src/ui/resource/FUi_ResourceListViewConfig.cpp @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceListViewConfig.cpp + * @brief This is the implementation file for the properties of ListView. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(LISTVIEW); +{ + ADD_COLOR_CONFIG(EMPTY_LIST_TEXT_NORMAL, $F011L21); + ADD_COLOR_CONFIG(ITEM_TEXT_NORMAL, $F011L1); + ADD_COLOR_CONFIG(ITEM_TEXT_PRESSED, $F011L1P); + ADD_COLOR_CONFIG(ITEM_TEXT_HIGHLIGHTED, $F011L1P); + ADD_COLOR_CONFIG(ITEM_TEXT_DISABLED, $F011L1D); + ADD_COLOR_CONFIG(ITEM_DESCRIPTION_TEXT_NORMAL, $F011L21); + ADD_COLOR_CONFIG(GROUPITEM_TEXT_NORMAL, $W021L2); + ADD_COLOR_CONFIG(GROUPITEM_DIVIDER_NORMAL, $W021L2); + ADD_COLOR_CONFIG(CONTEXTITEM_BG_NORMAL, $B0212); + + START_UI_CONFIG_MODE(480x800); + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(EMPTY_LIST_TEXT_HEIGHT, 38); + ADD_SHAPE_CONFIG(ITEM_DEFAULT_HEIGHT, 90); + ADD_SHAPE_CONFIG(ITEM_DEFAULT_FONT_SIZE, 44); + ADD_SHAPE_CONFIG(ITEM_ELEMENT_LEFT_MARGIN, 26); + ADD_SHAPE_CONFIG(ITEM_ELEMENT_SPACING, 16); + ADD_SHAPE_CONFIG(ITEM_DESCRIPTION_TEXT_LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(ITEM_DESCRIPTION_TEXT_TOP_MARGIN, 8); + ADD_SHAPE_CONFIG(ITEM_DESCRIPTION_TEXT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(ITEM_PROGRESS_BOTTOM_MARGIN, 16); + ADD_SHAPE_CONFIG(GROUPITEM_DEFAULT_HEIGHT, 48); + ADD_SHAPE_CONFIG(GROUPITEM_DEFAULT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(GROUPITEM_ELEMENT_LEFT_MARGIN, 26); + ADD_SHAPE_CONFIG(GROUPITEM_ELEMENT_SPACING, 16); + ADD_SHAPE_CONFIG(GROUPITEM_DIVIDER_HEIGHT, 4); + ADD_SHAPE_CONFIG(GROUPITEM_DIVIDER_LEFT_MARGIN, 24); + ADD_SHAPE_CONFIG(GROUPITEM_DIVIDER_BOTTOM_MARGIN, 14); + ADD_SHAPE_CONFIG(CONTEXTITEM_LEFT_MARGIN_ONE, 117); + ADD_SHAPE_CONFIG(CONTEXTITEM_LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(CONTEXTITEM_ELEMENT_HEIGHT, 74); + ADD_SHAPE_CONFIG(CONTEXTITEM_ELEMENT_SPACING, 16); + ADD_SHAPE_CONFIG(CONTEXTITEM_ELEMENT_FONT_SIZE, 32); + END_UI_CONFIG_MODE(720x1280); +} +END_UI_CONFIG(LISTVIEW); diff --git a/src/ui/resource/FUi_ResourceMap.h b/src/ui/resource/FUi_ResourceMap.h new file mode 100644 index 0000000..b82afde --- /dev/null +++ b/src/ui/resource/FUi_ResourceMap.h @@ -0,0 +1,203 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceMap.h + * @brief This is the header file for Map class. + * @version 3.0 + * + * This header file contains declaration of Map class. + * The ActionEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_INTERNAL_RESOURCE_MAP_H_ +#define _FUI_INTERNAL_RESOURCE_MAP_H_ + +#include +#include +#include + +namespace Tizen { namespace Base { + class String; +}}// Tizen::Base + +namespace Tizen { namespace Ui { namespace _Resource +{ +enum _ResourceType +{ + RESOURCE_TYPE_NONE, + RESOURCE_TYPE_COLOR, + RESOURCE_TYPE_DIMENSION, + RESOURCE_TYPE_FIXED_VALUE, + RESOURCE_TYPE_FONT, + RESOURCE_TYPE_IMAGE, + RESOURCE_TYPE_SHAPE, + RESOURCE_TYPE_MAX, +}; + +class _ResourceHashCodeProvider + : public Tizen::Base::Collection::IHashCodeProviderT +{ +public: + _ResourceHashCodeProvider(void) {} + virtual ~_ResourceHashCodeProvider(void) {} + + virtual int GetHashCode(const Tizen::Base::String& obj) const + { + return obj.GetHashCode(); + } +}; + +class _ResourceComparer + : public Tizen::Base::Collection::IComparerT +{ +public: + _ResourceComparer(void) {} + virtual ~_ResourceComparer(void) {} + virtual result Compare(const Tizen::Base::String& obj1, const Tizen::Base::String& obj2, int& cmp) const + { + if (obj1 == obj2) + { + cmp = 0; + return E_SUCCESS; + } + else + { + cmp = -1; + return E_SUCCESS; + } + } +}; + +template +class Map + : public Tizen::Base::Collection::HashMapT +{ +public: + Map(_ResourceType type) + : Tizen::Base::Collection::HashMapT() + , __type(type) + { + __pProvider = new _ResourceHashCodeProvider; + SysTryReturnVoidResult(NID_UI, __pProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + __pComparer = new _ResourceComparer; + SysTryReturnVoidResult(NID_UI, __pComparer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + __modifiedItemTable.Construct(0,0,*__pProvider, *__pComparer); + } + virtual ~Map(void) + { + result r = E_SUCCESS; + Tizen::Base::Collection::IMapEnumeratorT* pMapEnum = null; + if (Tizen::Base::Collection::HashMapT::GetCount() > 0) + { + pMapEnum = Tizen::Base::Collection::HashMapT::GetMapEnumeratorN(); + SysTryReturn(NID_UI_ANIM, (pMapEnum != null), , E_SYSTEM, "[E_SYSTEM] System Error."); + + Tizen::Base::Collection::MapEntryT value; + while ((pMapEnum->MoveNext() == E_SUCCESS)) + { + r = pMapEnum->GetCurrent(value); + SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System Error."); + + ValueType pObj = value.GetValue(); + delete pObj; + } + Tizen::Base::Collection::HashMapT::RemoveAll(); + delete pMapEnum; + } + delete __pProvider; + __pProvider = null; + delete __pComparer; + __pComparer = null; + return; + + CATCH: + delete pMapEnum; + } + void Initialize(void) + { + result r = E_SUCCESS; + Tizen::Base::Collection::MapEntryT currentEntry; + Tizen::Base::Collection::IEnumeratorT >* pMapEnumerator = Tizen::Base::Collection::HashMapT::GetMapEnumeratorN(); + + SysTryReturn(NID_UI, pMapEnumerator, , E_SYSTEM, "[E_SYSTEM] Getting enumerator is failed."); + + while ((pMapEnumerator->MoveNext() == E_SUCCESS)) + { + ValueType pObject = null; + r = pMapEnumerator->GetCurrent(currentEntry); + SysTryCatch(NID_UI, r == E_SUCCESS, r = E_SYSTEM, r, "[E_SYSTEM] removing data binding is failed."); + + pObject = currentEntry.GetValue(); + SysTryCatch(NID_UI, pObject, r = E_SYSTEM, r, "[E_SYSTEM] UpdateAllBindings is failed."); + delete pObject; + } + delete pMapEnumerator; + pMapEnumerator = null; + Tizen::Base::Collection::HashMapT::RemoveAll(); + + CATCH: + delete pMapEnumerator; + } + result SetValue(const Tizen::Base::String& key, const ValueType& value) + { + ValueType _value = null; + if(GetValue(key, _value) == E_SUCCESS) + { + __modifiedItemTable.Add(key, true); + *_value = *value; + return E_SUCCESS; + } + else + { + return E_OBJ_NOT_FOUND; + } + } + _ResourceType GetMode(void) const + { + return __type; + } + void SetInformation (const Tizen::Base::String& information) + { + __information = information; + } + Tizen::Base::String GetInformation(void) + { + return __information; + } + bool IsUserThemeItem(const Tizen::Base::String& key) + { + bool exist = false; + __modifiedItemTable.ContainsKey(key, exist); + return exist; + } + +private: + Map(void); + Map(const Map&); + Map& operator =(const Map&); +private: + const _ResourceType __type; + Tizen::Base::String __information; + Tizen::Base::Collection::HashMapT __modifiedItemTable; + Tizen::Base::Collection::IHashCodeProviderT* __pProvider; + Tizen::Base::Collection::IComparerT* __pComparer; + +}; +}}} + +#endif // _FUI_INTERNAL_RESOURCE_MAP_H_ \ No newline at end of file diff --git a/src/ui/resource/FUi_ResourceMapContainer.cpp b/src/ui/resource/FUi_ResourceMapContainer.cpp new file mode 100644 index 0000000..3bf8893 --- /dev/null +++ b/src/ui/resource/FUi_ResourceMapContainer.cpp @@ -0,0 +1,238 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceMapContainer.cpp + * @brief This is the implementation file for Config class. + * @version 3.0 + * + * This cpp file contains implementation of Config class. + * The ActionEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#include +#include +#include +#include +#include +#include "FUi_ResourceMapContainer.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Ui { namespace _Resource +{ + +MapContainer::MapContainer(void) + : __pColorMap(null) + , __pDimensionMap(null) + , __pFixedValueMap(null) + , __pImageMap(null) + , __pShapeMap(null) + , __pProvider(null) + , __pComparer(null) + , __version(L"") + , __themeName(L"") + , __resolution(L"") + , __resolutionForImage(L"") +{ + __pProvider = new _ResourceHashCodeProvider; + SysTryReturnVoidResult(NID_UI, __pProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + __pComparer = new _ResourceComparer; + SysTryReturnVoidResult(NID_UI, __pComparer, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); +} +MapContainer::~MapContainer(void) +{ + delete __pColorMap; + __pColorMap = null; + delete __pDimensionMap; + __pDimensionMap = null; + delete __pFixedValueMap; + __pFixedValueMap = null; + delete __pImageMap; + __pImageMap = null; + delete __pShapeMap; + __pShapeMap = null; + delete __pProvider; + __pProvider = null; + delete __pComparer; + __pComparer = null; +} + +void +MapContainer::CreateMap(_ResourceType type) +{ + switch(type) + { + case RESOURCE_TYPE_COLOR: + if(__pColorMap == null) + { + __pColorMap = new (std::nothrow) ResourceColorMap(type); + SysTryReturnVoidResult(NID_UI, __pColorMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + __pColorMap->Construct(0, 0, *__pProvider, *__pComparer); + } + break; + case RESOURCE_TYPE_DIMENSION: + if(__pDimensionMap == null) + { + __pDimensionMap = new (std::nothrow) ResourceDimensionMap(type); + SysTryReturnVoidResult(NID_UI, __pDimensionMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + __pDimensionMap->Construct(0, 0, *__pProvider, *__pComparer); + } + break; + + case RESOURCE_TYPE_FIXED_VALUE: + if(__pFixedValueMap == null) + { + __pFixedValueMap = new (std::nothrow) ResourceShapeMap(type); + SysTryReturnVoidResult(NID_UI, __pFixedValueMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + __pFixedValueMap->Construct(0, 0, *__pProvider, *__pComparer); + } + break; + case RESOURCE_TYPE_IMAGE: + if(__pImageMap == null) + { + __pImageMap = new (std::nothrow) ResourceImageMap(type); + SysTryReturnVoidResult(NID_UI, __pImageMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + __pImageMap->Construct(0, 0, *__pProvider, *__pComparer); + } + break; + case RESOURCE_TYPE_SHAPE: + if(__pShapeMap == null) + { + __pShapeMap = new (std::nothrow) ResourceShapeMap(type); + SysTryReturnVoidResult(NID_UI, __pShapeMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed."); + __pShapeMap->Construct(0, 0, *__pProvider, *__pComparer); + } + break; + default: + break; + } + InitializeMap(type); +} +void +MapContainer::InitializeMap(_ResourceType type) +{ + switch(type) + { + case RESOURCE_TYPE_COLOR: + if(__pColorMap != null) + { + __pColorMap->Initialize(); + } + break; + case RESOURCE_TYPE_DIMENSION: + if(__pDimensionMap != null) + { + __pDimensionMap->Initialize(); + } + break; + case RESOURCE_TYPE_FIXED_VALUE: + if(__pFixedValueMap != null) + { + __pFixedValueMap->Initialize(); + } + break; + case RESOURCE_TYPE_IMAGE: + if(__pImageMap != null) + { + __pImageMap->Initialize(); + } + break; + case RESOURCE_TYPE_SHAPE: + if(__pShapeMap != null) + { + __pShapeMap->Initialize(); + } + break; + default: + break; + } +} + +ResourceColorMap* +MapContainer::GetColorMap(void) const +{ + return __pColorMap; +} + +ResourceDimensionMap* +MapContainer::GetDimensionMap(void) const +{ + return __pDimensionMap; +} + +ResourceShapeMap* +MapContainer::GetFixedValueMap(void) const +{ + return __pFixedValueMap; +} + +ResourceImageMap* +MapContainer::GetImageMap(void) const +{ + return __pImageMap; +} + +ResourceShapeMap* +MapContainer::GetShapeMap(void) const +{ + return __pShapeMap; +} +void +MapContainer::SetVersion (const Tizen::Base::String& version) +{ + __version = version; +} +Tizen::Base::String +MapContainer::GetVersion(void) +{ + return __version; +} +void +MapContainer::SetThemeName(const Tizen::Base::String& themeName) +{ + __themeName = themeName; +} +Tizen::Base::String +MapContainer::GetThemeName(void) +{ + return __themeName; +} +void +MapContainer::SetResolution(const Tizen::Base::String& resolution) +{ + __resolution = resolution; +} +Tizen::Base::String +MapContainer::GetResolution(void) +{ + return __resolution; +} +void +MapContainer::SetResolutionForImage(const Tizen::Base::String& resolution) +{ + __resolutionForImage = resolution; +} +Tizen::Base::String +MapContainer::GetResolutionForImage(void) +{ + return __resolutionForImage; +} + +}}} //Tizen::Ui::_Resource diff --git a/src/ui/resource/FUi_ResourceMapContainer.h b/src/ui/resource/FUi_ResourceMapContainer.h new file mode 100644 index 0000000..f25ae56 --- /dev/null +++ b/src/ui/resource/FUi_ResourceMapContainer.h @@ -0,0 +1,98 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceMapContainer.h + * @brief This is the header file for MapContainer class. + * @version 3.0 + * + * This header file contains declaration of MapContainer class. + * The ActionEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_INTERNAL_RESOURCE_MAP_CONTAINER_H_ +#define _FUI_INTERNAL_RESOURCE_MAP_CONTAINER_H_ + +#include "FUi_ResourceMap.h" + +namespace Tizen { namespace Base +{ +class Integer; +}}// Tizen::Base + +namespace Tizen { namespace Base { namespace Collection +{ +template class IHashCodeProviderT; +template class IComparerT; +}}}//Tizen::Base::Collection + +namespace Tizen { namespace Graphics +{ +class Color; +class Dimension; +}}//Tizen::Graphics + +namespace Tizen { namespace Ui { namespace _Resource +{ +typedef Map ResourceColorMap; +typedef Map ResourceDimensionMap; +typedef Map ResourceImageMap; +typedef Map ResourceShapeMap; + +class MapContainer +{ +public: + MapContainer(void); + ~MapContainer(void); + void CreateMap(_ResourceType type); + void InitializeMap(_ResourceType type); + ResourceColorMap* GetColorMap(void) const; + ResourceDimensionMap* GetDimensionMap(void) const; + ResourceShapeMap* GetFixedValueMap(void) const; + ResourceImageMap* GetImageMap(void) const; + ResourceShapeMap* GetShapeMap(void) const; + void SetVersion(const Tizen::Base::String& information); + Tizen::Base::String GetVersion(void); + void SetThemeName(const Tizen::Base::String& ThemeName); + Tizen::Base::String GetThemeName(void); + void SetResolution(const Tizen::Base::String& resolution); + Tizen::Base::String GetResolution(void); + void SetResolutionForImage(const Tizen::Base::String& resolution); + Tizen::Base::String GetResolutionForImage(void); + +private: + MapContainer(const MapContainer&); + MapContainer& operator =(const MapContainer&); + +private: + ResourceColorMap* __pColorMap; + ResourceDimensionMap* __pDimensionMap; + ResourceShapeMap* __pFixedValueMap; + ResourceImageMap* __pImageMap; + ResourceShapeMap* __pShapeMap; + + Tizen::Base::Collection::IHashCodeProviderT* __pProvider; + Tizen::Base::Collection::IComparerT* __pComparer; + + Tizen::Base::String __version; + Tizen::Base::String __themeName; + Tizen::Base::String __resolution; + Tizen::Base::String __resolutionForImage; +}; +}}} + +#endif // _FUI_INTERNAL_RESOURCE_MAP_CONTAINER_H_ \ No newline at end of file diff --git a/src/ui/resource/FUi_ResourceMessageBoxConfig.cpp b/src/ui/resource/FUi_ResourceMessageBoxConfig.cpp new file mode 100644 index 0000000..060c703 --- /dev/null +++ b/src/ui/resource/FUi_ResourceMessageBoxConfig.cpp @@ -0,0 +1,82 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceMessageBoxConfig.cpp + * @brief This is the implementation file for the color/shape properties of MessageBox. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(MESSAGEBOX); +{ + ADD_COLOR_CONFIG(BG_NORMAL, $B061L1); + ADD_COLOR_CONFIG(TITLE_TEXT_NORMAL, $B052L5); + ADD_COLOR_CONFIG(TEXT_NORMAL, $B063L1); + + ADD_IMAGE_CONFIG(BG_NORMAL, $00_popup_bg.9.png); + ADD_IMAGE_CONFIG(BG_OUTLINE_EFFECT_NORMAL, $00_popup_bg_ef.9.png); + + START_UI_CONFIG_MODE(480x800); + { + + } + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_FIXED_VALUE_CONFIG(TEXT_MAX_LENGTH, 399); + + ADD_SHAPE_CONFIG(MIN_WIDTH, 510); // 20120504 + ADD_SHAPE_CONFIG(MIN_HEIGHT, 122); // 20120803 + + ADD_SHAPE_CONFIG(DEFAULT_WIDTH, 720); // 20121113 + ADD_SHAPE_CONFIG(MAX_HEIGHT, 590); // 20120803 + + ADD_SHAPE_CONFIG(TITLE_HEIGHT, 80); //20121113 + ADD_SHAPE_CONFIG(TITLE_TEXT_SIZE, 50); //20121113 + ADD_SHAPE_CONFIG(TITLE_TEXT_TOP_MARGIN, 18); //20121113 + ADD_SHAPE_CONFIG(TITLE_TEXT_LEFT_MARGIN, 20); + ADD_SHAPE_CONFIG(TITLE_TEXT_RIGHT_MARGIN, 20); + + ADD_SHAPE_CONFIG(BOTTOM_HEIGHT, 114); // 20121113 + + ADD_SHAPE_CONFIG(TEXT_SIZE, 42); // 20120504 + ADD_SHAPE_CONFIG(TEXT_LEFT_MARGIN, 20); + ADD_SHAPE_CONFIG(TEXT_RIGHT_MARGIN, 20); + + ADD_SHAPE_CONFIG(TEXT_TOP_MRAGIN_NO_BUTTON, 39); // 20121113 + ADD_SHAPE_CONFIG(TEXT_TOP_MRAGIN, 20); // 20121113 + + ADD_SHAPE_CONFIG(BG_IMAGE_TRANSPARENT_TOP_MARGIN, 14); //20121113 + ADD_SHAPE_CONFIG(BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, 34); //20121113 + ADD_SHAPE_CONFIG(BG_IMAGE_TRANSPARENT_LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, 16); + + ADD_SHAPE_CONFIG(BUTTON_HEIGHT, 74); // 20121113 + ADD_SHAPE_CONFIG(BUTTON_INTERNAL_GAP, 20); // 20121113 + + ADD_SHAPE_CONFIG(BUTTON_TOP_MARGIN, 20); // 20121113 + ADD_SHAPE_CONFIG(BUTTON_BOTTOM_MARGIN, 20); // 20121113 + + ADD_SHAPE_CONFIG(BUTTON_SIDE_MARGIN_01, 110); // 20120803 : 1 Button + ADD_SHAPE_CONFIG(BUTTON_SIDE_MARGIN_02, 36); // 20121113 : 2 Buttons + ADD_SHAPE_CONFIG(BUTTON_SIDE_MARGIN_03, 36); // 20121113 : 3 Buttons + } + END_UI_CONFIG_MODE(720x1280); + +} +END_UI_CONFIG(MESSAGEBOX); diff --git a/src/ui/resource/FUi_ResourceOptionMenuConfig.cpp b/src/ui/resource/FUi_ResourceOptionMenuConfig.cpp new file mode 100644 index 0000000..244f02b --- /dev/null +++ b/src/ui/resource/FUi_ResourceOptionMenuConfig.cpp @@ -0,0 +1,76 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceOptionMenuConfig.cpp + * @brief This is the implementation file for the color, image and shape properties of OptionMenu. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(OPTIONMENU); +{ + ADD_COLOR_CONFIG(ITEM_TEXT_NORMAL, $W1121); + ADD_COLOR_CONFIG(ITEM_TEXT_PRESSED, $W1122); + ADD_COLOR_CONFIG(ITEM_BG_NORMAL, $W111); + ADD_COLOR_CONFIG(ITEM_BG_PRESSED, $B0520P); + ADD_COLOR_CONFIG(HANDLE_NORMAL, $B0518); + ADD_COLOR_CONFIG(HANDLE_PRESSED, $B043); + ADD_COLOR_CONFIG(ARROW_NORMAL, $W1121); + ADD_COLOR_CONFIG(ARROW_PRESSED, $W1122); + ADD_IMAGE_CONFIG(ITEM_BG_NORMAL, #00_panel_bg.9.png); + ADD_IMAGE_CONFIG(ITEM_BG_PRESSED, #00_panel_list_press_bg.9.png); + ADD_IMAGE_CONFIG(ITEM_BG_EFFECT_PRESSED, #00_panel_list_press_bg_ef.9.png); + ADD_IMAGE_CONFIG(CONTEXTUAL_POPUP_ARROW, #00_option_panel_contextual_popup_arrow.png); + ADD_IMAGE_CONFIG(HANDLE_BG_NORMAL, #00_panel_handle_bg.9.png); + ADD_IMAGE_CONFIG(HANDLE_BG_PRESSED, #00_panel_handle_bg.9.png); + ADD_IMAGE_CONFIG(HANDLE_BG_EFFECT_NORMAL, #00_panel_handle_bg_ef.9.png); + ADD_IMAGE_CONFIG(HANDLE_BG_EFFECT_PRESSED, #00_panel_handle_bg_ef_press.9.png); + ADD_IMAGE_CONFIG(HANDLE_ARROW_NORMAL, #00_panel_handle_arrow.png); + ADD_IMAGE_CONFIG(HANDLE_ARROW_PRESSED, #00_panel_handle_arrow.png); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_FIXED_VALUE_CONFIG(COLUMN_MAX, 2); + ADD_SHAPE_CONFIG(HANDLE_HEIGHT, 110); + ADD_SHAPE_CONFIG(HANDLE_ARROW_Y_POSITION, 28); + ADD_SHAPE_CONFIG(ITEM_HEIGHT, 112); + ADD_FIXED_VALUE_CONFIG(LINE_WIDTH, 2); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(RIGHT_MARGIN, 16); + ADD_SHAPE_CONFIG(TEXT_SIZE, 42); + ADD_SHAPE_CONFIG(TEXT_LEFT_MARGIN, 8); + ADD_SHAPE_CONFIG(TEXT_RIGHT_MARGIN, 8); + ADD_SHAPE_CONFIG(TEXT_TOP_MARGIN, 8); + ADD_SHAPE_CONFIG(TEXT_BOTTOM_MARGIN, 8); + ADD_SHAPE_CONFIG(ARROW_MARGIN, 24); + ADD_SHAPE_CONFIG(ITEM_PRESS_LEFT_MARGIN, 3); + ADD_SHAPE_CONFIG(ITEM_PRESS_RIGHT_MARGIN, 5); + ADD_SHAPE_CONFIG(ITEM_PRESS_TOP_MARGIN, 3); + ADD_SHAPE_CONFIG(ITEM_PRESS_BOTTOM_MARGIN, 3); + ADD_FIXED_VALUE_CONFIG(ITEM_PRESS_EDGE_MARGIN, 2); + } + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + { + ADD_FIXED_VALUE_CONFIG(COLUMN_MAX, 4); + } + END_UI_CONFIG_MODE(1280x720); +} + +END_UI_CONFIG(OPTIONMENU); + diff --git a/src/ui/resource/FUi_ResourceOverlayPanelConfig.cpp b/src/ui/resource/FUi_ResourceOverlayPanelConfig.cpp new file mode 100644 index 0000000..7c0b279 --- /dev/null +++ b/src/ui/resource/FUi_ResourceOverlayPanelConfig.cpp @@ -0,0 +1,25 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(OVERLAYPANEL); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(MIN_RENDERER_SIZE, 36); + END_UI_CONFIG_MODE(720x1280); + +END_UI_CONFIG(OVERLAYPANEL); diff --git a/src/ui/resource/FUi_ResourcePanelConfig.cpp b/src/ui/resource/FUi_ResourcePanelConfig.cpp new file mode 100644 index 0000000..2102f9c --- /dev/null +++ b/src/ui/resource/FUi_ResourcePanelConfig.cpp @@ -0,0 +1,65 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(Panel); +{ + ADD_COLOR_CONFIG(BG_NORMAL, $B0217); + + ADD_IMAGE_CONFIG(GROUPED_SINGLE_BG_EFFECT_NORMAL, #00_list_group_bg_ef.9.png); + ADD_IMAGE_CONFIG(GROUPED_SINGLE_BG_EFFECT_PRESSED, #00_groupedlist_bg_press.9.png); + ADD_IMAGE_CONFIG(GROUPED_SINGLE_BG_EFFECT_SELECTED, #00_groupedlist_bg_focus.9.png); + + ADD_IMAGE_CONFIG(GROUPED_SINGLE_BG_NORMAL, #00_list_group_bg.9.png); + ADD_IMAGE_CONFIG(GROUPED_SINGLE_BG_DISABLED, #00_list_group_bg.9.png); + ADD_IMAGE_CONFIG(GROUPED_SINGLE_BG_PRESSED, #00_list_group_bg.9.png); + ADD_IMAGE_CONFIG(GROUPED_SINGLE_BG_HIGHLIGHTED, #00_list_group_bg.9.png); + ADD_IMAGE_CONFIG(GROUPED_SINGLE_BG_SELECTED, #00_list_group_bg.9.png); + + ADD_IMAGE_CONFIG(GROUPED_TOP_BG_EFFECT_NORMAL, #00_list_group_bg_top_ef.9.png); + ADD_IMAGE_CONFIG(GROUPED_TOP_BG_EFFECT_PRESSED, #00_groupedlist_top_bg_press.9.png); + ADD_IMAGE_CONFIG(GROUPED_TOP_BG_EFFECT_SELECTED, #00_groupedlist_top_bg_focus.9.png); + + ADD_IMAGE_CONFIG(GROUPED_TOP_BG_NORMAL, #00_list_group_bg_top.9.png); + ADD_IMAGE_CONFIG(GROUPED_TOP_BG_DISABLED, #00_list_group_bg_top.9.png); + ADD_IMAGE_CONFIG(GROUPED_TOP_BG_PRESSED, #00_list_group_bg_top.9.png); + ADD_IMAGE_CONFIG(GROUPED_TOP_BG_HIGHLIGHTED, #00_list_group_bg_top.9.png); + ADD_IMAGE_CONFIG(GROUPED_TOP_BG_SELECTED, #00_list_group_bg_top.9.png); + + ADD_IMAGE_CONFIG(GROUPED_MIDDLE_BG_EFFECT_NORMAL, #00_list_group_bg_center_ef.9.png); + ADD_IMAGE_CONFIG(GROUPED_MIDDLE_BG_EFFECT_PRESSED, #00_groupedlist_center_bg_press.9.png); + ADD_IMAGE_CONFIG(GROUPED_MIDDLE_BG_EFFECT_SELECTED, #00_groupedlist_center_bg_focus.9.png); + + ADD_IMAGE_CONFIG(GROUPED_MIDDLE_BG_NORMAL, #00_list_group_bg_center.9.png); + ADD_IMAGE_CONFIG(GROUPED_MIDDLE_BG_DISABLED, #00_list_group_bg_center.9.png); + ADD_IMAGE_CONFIG(GROUPED_MIDDLE_BG_PRESSED, #00_list_group_bg_center.9.png); + ADD_IMAGE_CONFIG(GROUPED_MIDDLE_BG_HIGHLIGHTED, #00_list_group_bg_center.9.png); + ADD_IMAGE_CONFIG(GROUPED_MIDDLE_BG_SELECTED, #00_list_group_bg_center.9.png); + + ADD_IMAGE_CONFIG(GROUPED_BOTTOM_BG_EFFECT_NORMAL, #00_list_group_bg_bottom_ef.9.png); + ADD_IMAGE_CONFIG(GROUPED_BOTTOM_BG_EFFECT_PRESSED, #00_groupedlist_bottom_bg_press.9.png); + ADD_IMAGE_CONFIG(GROUPED_BOTTOM_BG_EFFECT_SELECTED, #00_groupedlist_bottom_bg_focus.9.png); + + ADD_IMAGE_CONFIG(GROUPED_BOTTOM_BG_NORMAL, #00_list_group_bg_bottom.9.png); + ADD_IMAGE_CONFIG(GROUPED_BOTTOM_BG_DISABLED, #00_list_group_bg_bottom.9.png); + ADD_IMAGE_CONFIG(GROUPED_BOTTOM_BG_PRESSED, #00_list_group_bg_bottom.9.png); + ADD_IMAGE_CONFIG(GROUPED_BOTTOM_BG_HIGHLIGHTED, #00_list_group_bg_bottom.9.png); + ADD_IMAGE_CONFIG(GROUPED_BOTTOM_BG_SELECTED, #00_list_group_bg_bottom.9.png); +} +END_UI_CONFIG(Panel); + diff --git a/src/ui/resource/FUi_ResourcePopupConfig.cpp b/src/ui/resource/FUi_ResourcePopupConfig.cpp new file mode 100644 index 0000000..b881f16 --- /dev/null +++ b/src/ui/resource/FUi_ResourcePopupConfig.cpp @@ -0,0 +1,145 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourcePopupConfig.cpp + * @brief This is the implementation file for the color/shape properties of Popup. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(POPUP); +{ + ADD_COLOR_CONFIG(BG_NORMAL, $B061L1); + ADD_COLOR_CONFIG(TITLE_TEXT_NORMAL, $B052L5); + + ADD_IMAGE_CONFIG(BG_NORMAL, $00_popup_bg.9.png); + ADD_IMAGE_CONFIG(BG_OUTLINE_EFFECT_NORMAL, $00_popup_bg_ef.9.png); + + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_01, $00_list_process_01.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_02, $00_list_process_02.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_03, $00_list_process_03.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_04, $00_list_process_04.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_05, $00_list_process_05.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_06, $00_list_process_06.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_07, $00_list_process_07.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_08, $00_list_process_08.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_09, $00_list_process_09.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_10, $00_list_process_10.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_11, $00_list_process_11.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_12, $00_list_process_12.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_13, $00_list_process_13.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_14, $00_list_process_14.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_15, $00_list_process_15.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_16, $00_list_process_16.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_17, $00_list_process_17.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_18, $00_list_process_18.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_19, $00_list_process_19.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_20, $00_list_process_20.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_21, $00_list_process_21.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_22, $00_list_process_22.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_23, $00_list_process_23.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_24, $00_list_process_24.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_25, $00_list_process_25.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_26, $00_list_process_26.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_27, $00_list_process_27.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_28, $00_list_process_28.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_29, $00_list_process_29.png); + ADD_IMAGE_CONFIG(PROCESS_ICON_IMAGE_NORMAL_30, $00_list_process_30.png); + + START_UI_CONFIG_MODE(480x800); + { +// START_UI_CONFIG_API_VERSION(2.0); + START_UI_CONFIG_API_VERSION(2); + { + ADD_DIMENSION_CONFIG(MIN_SIZE, 384, 126); + } + END_UI_CONFIG_API_VERSION(); + } + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + ADD_DIMENSION_CONFIG(MIN_SIZE_WITH_TITLE, 72, 128); + ADD_DIMENSION_CONFIG(MAX_SIZE, 720, 1280); + + ADD_SHAPE_CONFIG(TITLE_HEIGHT, 80); + ADD_SHAPE_CONFIG(TITLE_TEXT_SIZE, 50); + ADD_SHAPE_CONFIG(TITLE_TEXT_TOP_MARGIN, 18); + ADD_SHAPE_CONFIG(TITLE_TEXT_LEFT_MARGIN, 20); + ADD_SHAPE_CONFIG(TITLE_TEXT_RIGHT_MARGIN, 20); + + ADD_SHAPE_CONFIG(TOP_BORDER, 6); // Compatibility 2.0 + ADD_SHAPE_CONFIG(BOTTOM_BORDER, 30); // Compatibility 2.0 + ADD_SHAPE_CONFIG(SIDE_BORDER, 12); // Compatibility 2.0 + + ADD_SHAPE_CONFIG(BG_IMAGE_TRANSPARENT_TOP_MARGIN, 14); + ADD_SHAPE_CONFIG(BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, 34); + ADD_SHAPE_CONFIG(BG_IMAGE_TRANSPARENT_LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, 16); + ADD_SHAPE_CONFIG(OUTLINE_BORDER, 3); + + ADD_SHAPE_CONFIG(PROCESS_ANIMATION_WIDTH, 64); + ADD_SHAPE_CONFIG(PROCESS_ANIMATION_NO_TITLE_TOP_MARGIN, 32); + + ADD_SHAPE_CONFIG(PROCESS_TEXT_TOP_MARGIN, 10); + ADD_SHAPE_CONFIG(PROCESS_TEXT_BOTTOM_MARGIN, 20); + + ADD_SHAPE_CONFIG(BG_OUTLINE_EFFECT_TOP_MARGIN, 8); //20130122 + ADD_SHAPE_CONFIG(BG_OUTLINE_EFFECT_BOTTOM_MARGIN, 12); //20130122 + ADD_SHAPE_CONFIG(BG_OUTLINE_EFFECT_LEFT_MARGIN, 8); //20130122 + ADD_SHAPE_CONFIG(BG_OUTLINE_EFFECT_RIGHT_MARGIN, 12); //20130122 + } + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + { + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + ADD_DIMENSION_CONFIG(MIN_SIZE_WITH_TITLE, 72, 128); + ADD_DIMENSION_CONFIG(MAX_SIZE, 1280, 720); + + ADD_SHAPE_CONFIG(TITLE_HEIGHT, 80); + ADD_SHAPE_CONFIG(TITLE_TEXT_SIZE, 50); + ADD_SHAPE_CONFIG(TITLE_TEXT_TOP_MARGIN, 18); + ADD_SHAPE_CONFIG(TITLE_TEXT_LEFT_MARGIN, 20); + ADD_SHAPE_CONFIG(TITLE_TEXT_RIGHT_MARGIN, 20); + + ADD_SHAPE_CONFIG(TOP_BORDER, 6); + ADD_SHAPE_CONFIG(BOTTOM_BORDER, 30); + ADD_SHAPE_CONFIG(SIDE_BORDER, 12); + + ADD_SHAPE_CONFIG(BG_IMAGE_TRANSPARENT_TOP_MARGIN, 14); + ADD_SHAPE_CONFIG(BG_IMAGE_TRANSPARENT_BOTTOM_MARGIN, 34); + ADD_SHAPE_CONFIG(BG_IMAGE_TRANSPARENT_LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(BG_IMAGE_TRANSPARENT_RIGHT_MARGIN, 16); + ADD_SHAPE_CONFIG(OUTLINE_BORDER, 3); + + ADD_SHAPE_CONFIG(PROCESS_ANIMATION_WIDTH, 64); + ADD_SHAPE_CONFIG(PROCESS_ANIMATION_NO_TITLE_TOP_MARGIN, 32); + + ADD_SHAPE_CONFIG(PROCESS_TEXT_TOP_MARGIN, 10); + ADD_SHAPE_CONFIG(PROCESS_TEXT_BOTTOM_MARGIN, 20); + + ADD_SHAPE_CONFIG(BG_OUTLINE_EFFECT_TOP_MARGIN, 8); //20130122 + ADD_SHAPE_CONFIG(BG_OUTLINE_EFFECT_BOTTOM_MARGIN, 12); //20130122 + ADD_SHAPE_CONFIG(BG_OUTLINE_EFFECT_LEFT_MARGIN, 8); //20130122 + ADD_SHAPE_CONFIG(BG_OUTLINE_EFFECT_RIGHT_MARGIN, 12); //20130122 + } + END_UI_CONFIG_MODE(1280x720); + +} +END_UI_CONFIG(POPUP); diff --git a/src/ui/resource/FUi_ResourceRadioGroupConfig.cpp b/src/ui/resource/FUi_ResourceRadioGroupConfig.cpp new file mode 100644 index 0000000..3cf8822 --- /dev/null +++ b/src/ui/resource/FUi_ResourceRadioGroupConfig.cpp @@ -0,0 +1,39 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceRadioGroupConfig.cpp + * @brief This is the implementation file for the properties of RadioGroup. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(RADIOGROUP); +{ + START_UI_CONFIG_MODE(480x800); + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(720x1280); + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + ADD_DIMENSION_CONFIG(MIN_SIZE, 0, 0); + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(RADIOGROUP); + diff --git a/src/ui/resource/FUi_ResourceScrollConfig.cpp b/src/ui/resource/FUi_ResourceScrollConfig.cpp new file mode 100644 index 0000000..d3dc528 --- /dev/null +++ b/src/ui/resource/FUi_ResourceScrollConfig.cpp @@ -0,0 +1,80 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(SCROLL); +{ + ADD_COLOR_CONFIG(THUMB, $B071); + + ADD_COLOR_CONFIG(JUMP_TO_TOP_BG, $W011); + ADD_COLOR_CONFIG(JUMP_TO_TOP_NORMAL, $F032L1); + ADD_COLOR_CONFIG(JUMP_TO_TOP_PRESSED, $F032L1P); + ADD_COLOR_CONFIG(BUTTON_BG, $W011); + ADD_COLOR_CONFIG(BUTTON_BG_PRESSED, $B042); + + ADD_IMAGE_CONFIG(THUMB, #00_scroll_bar.9.png); + ADD_IMAGE_CONFIG(THUMB_EFFECT, #00_scroll_bar_ef.9.png); + ADD_IMAGE_CONFIG(JUMP_TO_TOP, #00_icon_jump.png); + ADD_IMAGE_CONFIG(JUMP_TO_TOP_EFFECT, #00_icon_jump_ef.png); + ADD_IMAGE_CONFIG(JUMP_TO_TOP_LEFT, #00_icon_jump_left.png); + ADD_IMAGE_CONFIG(JUMP_TO_TOP_LEFT_EFFECT, #00_icon_jump_left_ef.png); + ADD_IMAGE_CONFIG(BUTTON_BG, #00_button_01.9.png); + ADD_IMAGE_CONFIG(BUTTON_BG_EFFECT, #00_button_01_ef.9.png); + ADD_IMAGE_CONFIG(BUTTON_BG_PRESSED, #00_button_01_ef_press.9.png); + ADD_IMAGE_CONFIG(HANDLER_BG, #00_scroll_bar_handler_bg.9.png); + ADD_IMAGE_CONFIG(HANDLER_BG_EFFECT, #00_scroll_bar_handler_bg_ef.9.png); + ADD_IMAGE_CONFIG(HANDLER_HORIZONTAL, #00_scroll_bar_handler_h.png); + ADD_IMAGE_CONFIG(HANDLER_VERTICAL, #00_scroll_bar_handler_v.png); + + ADD_IMAGE_CONFIG(OVERSCROLLING_TOP_BG, #00_overscrolling_top.9.png); + ADD_IMAGE_CONFIG(OVERSCROLLING_BOTTOM_BG, #00_overscrolling_bottom.9.png); + ADD_IMAGE_CONFIG(OVERSCROLLING_LEFT_BG, #00_overscrolling_left.9.png); + ADD_IMAGE_CONFIG(OVERSCROLLING_RIGHT_BG, #00_overscrolling_right.9.png); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(VERTICAL_THUMB_MIN_WIDTH, 16); + ADD_SHAPE_CONFIG(VERTICAL_THUMB_MIN_HEIGHT, 16); + ADD_SHAPE_CONFIG(VERTICAL_THUMB_MARGIN, 6); + ADD_SHAPE_CONFIG(HORIZONTAL_THUMB_MIN_WIDTH, 16); + ADD_SHAPE_CONFIG(HORIZONTAL_THUMB_MIN_HEIGHT, 16); + ADD_SHAPE_CONFIG(HORIZONTAL_THUMB_MARGIN, 6); + + ADD_SHAPE_CONFIG(JUMP_TO_TOP_RIGHT_MARGIN, 26); + ADD_SHAPE_CONFIG(JUMP_TO_TOP_TOP_MARGIN, 18); + ADD_FIXED_VALUE_CONFIG(JUMP_TO_TOP_WIDTH, 74); + ADD_FIXED_VALUE_CONFIG(JUMP_TO_TOP_HEIGHT, 74); + + ADD_SHAPE_CONFIG(HANDLER_MARGIN, 4); + ADD_SHAPE_CONFIG(HANDLER_MIN_WIDTH, 54); + ADD_SHAPE_CONFIG(HANDLER_MIN_HEIGHT, 214); + + ADD_SHAPE_CONFIG(OVERSCROLLING_TOP_HEIGHT, 30); + ADD_SHAPE_CONFIG(OVERSCROLLING_BOTTOM_HEIGHT, 30); + ADD_SHAPE_CONFIG(OVERSCROLLING_LEFT_WIDTH, 30); + ADD_SHAPE_CONFIG(OVERSCROLLING_RIGHT_WIDTH, 30); + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + ADD_SHAPE_CONFIG(OVERSCROLLING_TOP_HEIGHT, 30); + ADD_SHAPE_CONFIG(OVERSCROLLING_BOTTOM_HEIGHT, 30); + ADD_SHAPE_CONFIG(OVERSCROLLING_LEFT_WIDTH, 30); + ADD_SHAPE_CONFIG(OVERSCROLLING_RIGHT_WIDTH, 30); + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(SCROLL); + diff --git a/src/ui/resource/FUi_ResourceSearchBarConfig.cpp b/src/ui/resource/FUi_ResourceSearchBarConfig.cpp new file mode 100644 index 0000000..a818cee --- /dev/null +++ b/src/ui/resource/FUi_ResourceSearchBarConfig.cpp @@ -0,0 +1,75 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceSearchBarConfig.cpp + * @brief This is a configuration file for color, image and shape values of SearchBar. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(SEARCHBAR); +{ + ADD_COLOR_CONFIG(BUTTON_BG_NORMAL, $W011); + ADD_COLOR_CONFIG(BUTTON_PRESSED, $B042); + ADD_COLOR_CONFIG(BUTTON_DISABLED, $W011); + ADD_COLOR_CONFIG(BUTTON_HIGHLIGHTED, $B041); + ADD_COLOR_CONFIG(BUTTON_TEXT_NORMAL, $B052L4); + ADD_COLOR_CONFIG(BUTTON_TEXT_PRESSED, $F032L2P); + ADD_COLOR_CONFIG(BUTTON_TEXT_DISABLED, $B052L4D); + ADD_COLOR_CONFIG(BUTTON_TEXT_HIGHLIGHTED, $F032L2P); + + ADD_COLOR_CONFIG(EDIT_BG_NORMAL, $W031); + ADD_COLOR_CONFIG(EDIT_BG_DISABLED, $W031D); + ADD_COLOR_CONFIG(EDIT_TEXT_NORMAL, $W032); + ADD_COLOR_CONFIG(EDIT_TEXT_DISABLED, $W032D); + ADD_COLOR_CONFIG(EDIT_TEXT_HIGHLIGHTED, $W032P); + ADD_COLOR_CONFIG(ICON_COLOR_NORMAL, $F041i); + ADD_COLOR_CONFIG(ICON_COLOR_DISABLED, $F041iD); + ADD_COLOR_CONFIG(CONTENT_AREA_BG_NORMAL, $B013); + + ADD_IMAGE_CONFIG(BG_NORMAL, #00_search_edit_field_bg.9.png); + ADD_IMAGE_CONFIG(BG_DISABLED, #00_search_edit_field_bg.9.png); + ADD_IMAGE_CONFIG(BG_HIGHLIGHTED, #00_search_edit_field_bg.9.png); + ADD_IMAGE_CONFIG(BG_PRESSED, #00_search_edit_field_bg.9.png); + ADD_IMAGE_CONFIG(BG_EFFECT, #00_search_edit_field_bg_ef.9.png);//00_edit_field_no_line_square_bg_01.9.png + + ADD_IMAGE_CONFIG(ICON_NORMAL, #00_search_icon.png); + ADD_IMAGE_CONFIG(ICON_EFFECT_NORMAL, #00_search_icon_ef.png); + + + START_UI_CONFIG_MODE(720x1280); + { + ADD_SHAPE_CONFIG(HORIZONTAL_MARGIN, 26); + ADD_SHAPE_CONFIG(VERTICAL_MARGIN, 10); + ADD_SHAPE_CONFIG(TEXT_HORIZONTAL_MARGIN, 18); + ADD_SHAPE_CONFIG(ICON_HORIZONTAL_MARGIN, 18); + ADD_SHAPE_CONFIG(ICON_WIDTH, 40); + ADD_SHAPE_CONFIG(ICON_HEIGHT, 40); + ADD_SHAPE_CONFIG(SEARCH_FIELD_MIN_WIDTH, 218); + ADD_SHAPE_CONFIG(SEARCH_FIELD_MIN_HEIGHT, 66); + ADD_SHAPE_CONFIG(BUTTON_WIDTH, 136); + ADD_SHAPE_CONFIG(BUTTON_MIN_WIDTH, 74); + ADD_SHAPE_CONFIG(BUTTON_HEIGHT, 66); + ADD_SHAPE_CONFIG(BUTTON_LEFT_MARGIN, 10); + ADD_SHAPE_CONFIG(BUTTON_RIGHT_MARGIN, 20); + ADD_SHAPE_CONFIG(EDIT_TEXT_SIZE, 32); + ADD_SHAPE_CONFIG(BUTTON_TEXT_SIZE, 30); + } + END_UI_CONFIG_MODE(720x1280); +} +END_UI_CONFIG(SEARCHBAR); diff --git a/src/ui/resource/FUi_ResourceSizeInfo.cpp b/src/ui/resource/FUi_ResourceSizeInfo.cpp new file mode 100644 index 0000000..711fac5 --- /dev/null +++ b/src/ui/resource/FUi_ResourceSizeInfo.cpp @@ -0,0 +1,275 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include "FUi_ResourceSizeInfo.h" +#include "FUiCtrl_ButtonImpl.h" +#include "FUiCtrl_CheckButtonImpl.h" +#include "FUiCtrl_LabelImpl.h" +#include "FUiCtrl_RadioGroupImpl.h" +#include "FUiCtrl_ColorPickerImpl.h" +#include "FUiCtrl_DatePickerImpl.h" +#include "FUiCtrl_DateTimePickerImpl.h" +#include "FUiCtrl_TimePickerImpl.h" +#include "FUiCtrl_PopupImpl.h" +#include "FUiCtrl_ProgressImpl.h" +#include "FUiCtrl_SliderImpl.h" +#include "FUiCtrl_EditAreaImpl.h" +#include "FUiCtrl_ExpandableEditAreaImpl.h" +#include "FUiCtrl_FormImpl.h" +#include "FUiCtrl_SearchBarImpl.h" +#include "FUiCtrl_EditFieldImpl.h" +#include "FUiCtrl_TabBarImpl.h" +#include "FUiCtrl_CustomListImpl.h" +#include "FUiCtrl_ExpandableListImpl.h" +#include "FUiCtrl_GroupedListImpl.h" +#include "FUiCtrl_ListImpl.h" +#include "FUiCtrl_OverlayPanelImpl.h" +#include "FUiCtrl_SlidableListImpl.h" +#include "FUiCtrl_EditDateImpl.h" +#include "FUiCtrl_EditTimeImpl.h" +#include "FUiCtrl_TableViewImpl.h" +#include "FUiCtrl_TableViewItemImpl.h" + +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; + +namespace Tizen { namespace Ui { namespace _Resource +{ +_ControlImpl::SizeInfo& +SizeInfo::GetButtonSizeInfo(void) +{ + static _ButtonImpl::ButtonSizeInfo buttonSizeInfo; + return buttonSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetCheckButtonSizeInfo(void) +{ + static _CheckButtonImpl::CheckButtonSizeInfo checkButtonSizeInfo; + return checkButtonSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetLabelSizeInfo(void) +{ + static _LabelImpl::LabelSizeInfo labelSizeInfo; + return labelSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetRadioGroupSizeInfo(void) +{ + static _RadioGroupImpl::RadioGroupSizeInfo radioGroupSizeInfo; + return radioGroupSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetColorPickerSizeInfo(void) +{ + static _ColorPickerImpl::ColorPickerSizeInfo colorPickerSizeInfo; + return colorPickerSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetDatePickerSizeInfo(void) +{ + static Tizen::Ui::Controls::_DatePickerImpl::DatePickerSizeInfo datePickerSizeInfo; + return datePickerSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetDateTimePickerSizeInfo(void) +{ + static Tizen::Ui::Controls::_DateTimePickerImpl::DateTimePickerSizeInfo dateTimePickerSizeInfo; + return dateTimePickerSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetFormSizeInfo(void) +{ + static _FormImpl::FormSizeInfo formSizeInfo; + return formSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetTimePickerSizeInfo(void) +{ + static Tizen::Ui::Controls::_TimePickerImpl::TimePickerSizeInfo timePickerSizeInfo; + return timePickerSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetPopupSizeInfo(void) +{ + static _PopupImpl::PopupSizeInfo popupSizeInfo; + return popupSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetProgressSizeInfo(void) +{ + static _ControlImpl::SizeInfo progressSizeInfo; + return progressSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetSliderSizeInfo(int sliderStyle) +{ + static _ControlImpl::SizeInfo sliderSizeInfo; + return sliderSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetEditAreaSizeInfo(void) +{ + static _EditAreaImpl::EditAreaSizeInfo editAreaSizeInfo; + return editAreaSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetEditFieldSizeInfo(bool isSmallStyle, EditFieldTitleStyle titleStlye) +{ + static _EditFieldImpl::EditFieldSizeInfo editFieldSizeInfo; + editFieldSizeInfo.SetSmallStyle(isSmallStyle); + editFieldSizeInfo.SetTitleStyle(titleStlye); + return editFieldSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetExpandableEditAreaSizeInfo(void) +{ + static _ControlImpl::SizeInfo expandableEditAreaSizeInfo; + return expandableEditAreaSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetSearchBarSizeInfo(void) +{ + static _ControlImpl::SizeInfo searchBarSizeInfo; + return searchBarSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetTabBarSizeInfo(void) +{ + static _TabBarImpl::TabBarSizeInfo tabSizeInfo; + return tabSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetCustomListSizeInfo(void) +{ + static _ControlImpl::SizeInfo sizeInfo; + return sizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetExpandableListSizeInfo(void) +{ + static _ControlImpl::SizeInfo sizeInfo; + return sizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetGroupedListSizeInfo(void) +{ + static _ControlImpl::SizeInfo sizeInfo; + return sizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetListSizeInfo(void) +{ + static _ControlImpl::SizeInfo sizeInfo; + return sizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetOverlayPanelSizeInfo(void) +{ + static _OverlayPanelImpl::OverlayPanelSizeInfo OverlayPanelSizeInfo; + return OverlayPanelSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetSlidableListSizeInfo(void) +{ + static _ControlImpl::SizeInfo sizeInfo; + return sizeInfo; +} +_ControlImpl::SizeInfo& +SizeInfo::GetWebSizeInfo(void) +{ + class WebSizeInfo : public _ContainerImpl::SizeInfo + { + public: + virtual Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const + { + return Dimension(1, 1); + } + }; + static WebSizeInfo webSizeInfo; + return webSizeInfo; +} + +_ControlImpl::SizeInfo& +SizeInfo::GetMapSizeInfo(void) +{ + class MapSizeInfo : public _ContainerImpl::SizeInfo + { + public: + virtual Dimension GetDefaultMinimumSize(_ControlOrientation orientation) const + { + return Dimension(1, 1); + } + }; + static MapSizeInfo sizeInfo; + return sizeInfo; +} + +Tizen::Ui::_ControlImpl::SizeInfo& +SizeInfo::GetEditDateSizeInfo(bool titleStyle) +{ + static Tizen::Ui::Controls::_EditDateImpl::EditDateSizeInfo editDateSizeInfo; + editDateSizeInfo.SetTitleStyle(titleStyle); + return editDateSizeInfo; +} + +Tizen::Ui::_ControlImpl::SizeInfo& +SizeInfo::GetEditTimeSizeInfo(bool titleStyle) +{ + static Tizen::Ui::Controls::_EditTimeImpl::EditTimeSizeInfo editTimeSizeInfo; + editTimeSizeInfo.SetTitleStyle(titleStyle); + return editTimeSizeInfo; +} + +Tizen::Ui::_ControlImpl::SizeInfo& +SizeInfo::GetTableViewSizeInfo(void) +{ + static Tizen::Ui::Controls::_TableViewImpl::TableViewSizeInfo tableViewSizeInfo; + return tableViewSizeInfo; +} + +Tizen::Ui::_ControlImpl::SizeInfo& +SizeInfo::GetTableViewItemSizeInfo(void) +{ + static Tizen::Ui::Controls::_TableViewItemImpl::TableViewItemSizeInfo tableViewItemSizeInfo; + return tableViewItemSizeInfo; +} + +}}}//Tizen::Ui diff --git a/src/ui/resource/FUi_ResourceSliderConfig.cpp b/src/ui/resource/FUi_ResourceSliderConfig.cpp new file mode 100644 index 0000000..e364f7d --- /dev/null +++ b/src/ui/resource/FUi_ResourceSliderConfig.cpp @@ -0,0 +1,125 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceSliderConfig.cpp + * @brief This is a configuration file for color, image and shape values of Slider, Progress. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(SLIDER); +{ + + ADD_COLOR_CONFIG(BG_OTHERS_NORMAL, $B012); + ADD_COLOR_CONFIG(BG_DEFAULT_NORMAL, $B0217); + + ADD_COLOR_CONFIG(BAR_BG_NORMAL, $W062L1); + ADD_COLOR_CONFIG(BAR_NORMAL, $W062L2); + + ADD_COLOR_CONFIG(HANDLE_BG_NORMAL, $W0641); + ADD_COLOR_CONFIG(HANDLE_BG_PRESSED, $W0641P); + ADD_COLOR_CONFIG(HANDLE_BG_DISABLED, $W0641D); + ADD_COLOR_CONFIG(HANDLE_BG_HIGHLIGHTED, $W0641); + ADD_COLOR_CONFIG(HANDLE_NUMBER_TEXT_DISABLED, $W0611D); + ADD_COLOR_CONFIG(HANDLE_NUMBER_TEXT_NORMAL, $W0611); + + ADD_COLOR_CONFIG(TITLE_TEXT_NORMAL, $F011L3); + ADD_COLOR_CONFIG(OVERLAY_BG_NORMAL, $W063); + ADD_COLOR_CONFIG(OVERLAY_TEXT_NORMAL, $F011L10); + + ADD_IMAGE_CONFIG(BAR_BG_NORMAL, #00_progress_bg.9.png); + ADD_IMAGE_CONFIG(BAR_NORMAL, #00_progress_bar.9.png); + ADD_IMAGE_CONFIG(BAR_BG_EFFECT, #00_progress_ef_bg.9.png); + ADD_IMAGE_CONFIG(BAR_EFFECT, #00_progress_bar_ef.9.png); + + + ADD_IMAGE_CONFIG(PROGRESS_BAR_NORMAL, #00_progress_bar_m.9.png); + ADD_IMAGE_CONFIG(PROGRESS_BAR_EFFECT, #00_progress_bar_ef_m.9.png); + + ADD_IMAGE_CONFIG(GROUP_TOP_BG, #00_list_group_bg_top.9.png); + ADD_IMAGE_CONFIG(GROUP_TOP_EFFECT, #00_list_group_bg_top_ef.9.png); + ADD_IMAGE_CONFIG(GROUP_MIDDLE_BG, #00_list_group_bg_center.9.png); + ADD_IMAGE_CONFIG(GROUP_MIDDLE_EFFECT, #00_list_group_bg_center_ef.9.png); + ADD_IMAGE_CONFIG(GROUP_BOTTOM_BG, #00_list_group_bg_bottom.9.png); + ADD_IMAGE_CONFIG(GROUP_BOTTOM_EFFECT, #00_list_group_bg_bottom_ef.9.png); + ADD_IMAGE_CONFIG(GROUP_SINGLE_BG, #00_list_group_bg.9.png); + ADD_IMAGE_CONFIG(GROUP_SINGLE_EFFECT, #00_list_group_bg_ef.9.png); + + ADD_IMAGE_CONFIG(HANDLE_BG_NORMAL, #00_slider_handle.png); + ADD_IMAGE_CONFIG(HANDLE_BG_PRESSED, #00_slider_handle.png); + ADD_IMAGE_CONFIG(HANDLE_BG_DISABLED, #00_slider_handle.png); + ADD_IMAGE_CONFIG(HANDLE_BG_HIGHLIGHTED, #00_slider_handle.png); + + ADD_IMAGE_CONFIG(HANDLE_BG_EFFECT_NORMAL, #00_slider_handle_ef.png); + ADD_IMAGE_CONFIG(HANDLE_BG_EFFECT_PRESSED, #00_slider_handle_ef_press.png); + ADD_IMAGE_CONFIG(HANDLE_BG_EFFECT_DISABLED, #00_slider_handle_ef_dim.png); + ADD_IMAGE_CONFIG(HANDLE_BG_EFFECT_HIGHLIGHTED, #00_slider_handle_ef.png); + + ADD_IMAGE_CONFIG(UPWARD_OVERLAY_BG_NORMAL, #00_slider_popup_bg.png); + ADD_IMAGE_CONFIG(UPWARD_OVERLAY_BG_EFFECT, #00_slider_popup_bg_ef.png); + ADD_IMAGE_CONFIG(DOWNWARD_OVERLAY_BG_NORMAL, #00_slider_popup_bottom_bg.png); + ADD_IMAGE_CONFIG(DOWNWARD_OVERLAY_BG_EFFECT, #00_slider_popup_bottom_bg_ef.png); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_SHAPE_CONFIG(HANDLE_WIDTH, 72); + ADD_SHAPE_CONFIG(HANDLE_HEIGHT, 72); + ADD_SHAPE_CONFIG(HANDLE_OFFSET, 8); + + ADD_SHAPE_CONFIG(HANDLE_ONE_DIGIT_TEXT_SIZE, 42); + ADD_SHAPE_CONFIG(HANDLE_TWO_DIGIT_TEXT_SIZE, 34); + ADD_SHAPE_CONFIG(HANDLE_THREE_DIGIT_TEXT_SIZE, 26); + + ADD_SHAPE_CONFIG(BAR_HEIGHT, 34); + ADD_SHAPE_CONFIG(BAR_LEFT_MARGIN, 26); + ADD_SHAPE_CONFIG(BAR_TOP_MARGIN, 12); + ADD_SHAPE_CONFIG(BAR_OFFSET, 8); + + ADD_SHAPE_CONFIG(ICON_WIDTH, 74); + ADD_SHAPE_CONFIG(ICON_HEIGHT, 74); + ADD_SHAPE_CONFIG(ICON_LEFT_MARGIN, 26); + ADD_SHAPE_CONFIG(ICON_RIGHT_MARGIN, 16); + + ADD_SHAPE_CONFIG(TITLE_TEXT_POSITION_X, 12); + ADD_SHAPE_CONFIG(TITLE_TEXT_POSITION_Y, 12); + ADD_SHAPE_CONFIG(TITLE_TEXT_SIZE, 32); + ADD_SHAPE_CONFIG(TITLE_TEXT_HEIGHT, 36); + ADD_FIXED_VALUE_CONFIG(TITLE_TEXT_LENGTH_MAX, 127); + + ADD_SHAPE_CONFIG(OVERLAY_WIDTH, 90); + ADD_SHAPE_CONFIG(OVERLAY_HEIGHT, 108); + ADD_SHAPE_CONFIG(OVERLAY_HEIGHT_WITHOUT_ARROW, 86); + ADD_SHAPE_CONFIG(OVERLAY_BOTTOM_MARGIN, 0); + + ADD_SHAPE_CONFIG(OVERLAY_TEXT_SIZE_ONE_CHARACTER, 80); + ADD_SHAPE_CONFIG(OVERLAY_TEXT_SIZE_TWO_CHARACTERS, 64); + ADD_SHAPE_CONFIG(OVERLAY_TEXT_SIZE_THREE_CHARACTERS, 48); + ADD_SHAPE_CONFIG(OVERLAY_TEXT_POSITION_Y_ONE_CHARACTER, 5); + ADD_SHAPE_CONFIG(OVERLAY_TEXT_POSITION_Y_TWO_CHARACTERS, 14); + ADD_SHAPE_CONFIG(OVERLAY_TEXT_POSITION_Y_THREE_CHARACTERS, 22); + ADD_SHAPE_CONFIG(NUMBER_SIZE, 58); + ADD_SHAPE_CONFIG(TEXT_SIZE, 28); + + ADD_SHAPE_CONFIG(MINIMUM_SIZE_WITHOUT_ICON, 276); + ADD_SHAPE_CONFIG(MINIMUM_SIZE_WITH_ICON, 510); + + } + END_UI_CONFIG_MODE(720x1280); + +} +END_UI_CONFIG(SLIDER); diff --git a/src/ui/resource/FUi_ResourceSplitPanelConfig.cpp b/src/ui/resource/FUi_ResourceSplitPanelConfig.cpp new file mode 100644 index 0000000..c48a038 --- /dev/null +++ b/src/ui/resource/FUi_ResourceSplitPanelConfig.cpp @@ -0,0 +1,42 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceSplitPanelConfig.cpp + * @brief This is the implementation file for the color, image and shape properties of SplitPanel. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(SPLITPANEL); +{ + ADD_COLOR_CONFIG(DIVIDER_BG_NORMAL, $W131); + ADD_COLOR_CONFIG(DIVIDER_BG_PRESSED, $W132); + + ADD_IMAGE_CONFIG(DIVIDER_BG_NORMAL, #00_splite_handler_bg.9.png); + ADD_IMAGE_CONFIG(VERTICAL_DIVIDER_BG_EFFECT, #00_splite_handler_bg_ef_v.9.png); + ADD_IMAGE_CONFIG(VERTICAL_DIVIDER_BG_NORMAL, #00_splite_handler_v.png); + ADD_IMAGE_CONFIG(HORIZONTAL_DIVIDER_BG_EFFECT, #00_splite_handler_bg_ef_h.9.png); + ADD_IMAGE_CONFIG(HORIZONTAL_DIVIDER_BG_NORMAL, #00_splite_handler_h.png); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_SHAPE_CONFIG(FIXED_DIVIDER_THICKNESS, 5); + ADD_SHAPE_CONFIG(MOVABLE_DIVIDER_THICKNESS, 13); + } + END_UI_CONFIG_MODE(720x1280); +} +END_UI_CONFIG(SPLITPANEL); diff --git a/src/ui/resource/FUi_ResourceStringLoader.cpp b/src/ui/resource/FUi_ResourceStringLoader.cpp new file mode 100644 index 0000000..86cf2e5 --- /dev/null +++ b/src/ui/resource/FUi_ResourceStringLoader.cpp @@ -0,0 +1,49 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +#include +#include +#include +#include +#include +#include "FUi_ResourceStringLoader.h" + +using namespace Tizen::Base; + +namespace +{ +const char* const SLP_SYSTEM_DOMAIN ="sys_string"; +} + +namespace Tizen { namespace Ui { namespace _Resource +{ +StringLoader::StringLoader(void) +{ +} +StringLoader::~StringLoader(void) +{ +} +result +StringLoader::GetString(const String& stringId, String& string) +{ + char* pString = null; + char* pStringId = _StringConverter::CopyToCharArrayN(stringId); + pString = dgettext(::SLP_SYSTEM_DOMAIN, pStringId); + string = pString; + delete[] pStringId; + return E_SUCCESS; +} +}}}//Tizen::Ui::_Resource diff --git a/src/ui/resource/FUi_ResourceStringLoader.h b/src/ui/resource/FUi_ResourceStringLoader.h new file mode 100644 index 0000000..288689f --- /dev/null +++ b/src/ui/resource/FUi_ResourceStringLoader.h @@ -0,0 +1,52 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceStringLoader.h + * @brief This is the header file for StringLoader class. + * @version 3.0 + * + * This header file contains declaration of StringLoader class. + * The ActionEvent class can call listener's method. So, when event occurred, + * application can handle it appropriately. + * + */ +#ifndef _FUI_INTERNAL_RESOURCE_STRING_LOADER_H_ +#define _FUI_INTERNAL_RESOURCE_STRING_LOADER_H_ + +namespace Tizen { namespace Base { + class String; +}}//Tizen::Base + +namespace Tizen { namespace Ui { namespace _Resource +{ + +class StringLoader +{ +public: + StringLoader(void); + virtual ~StringLoader(void); + + result GetString(const Tizen::Base::String& stringId, Tizen::Base::String& string); + +private: + //coding idiom. + StringLoader(const StringLoader&); + StringLoader& operator =(const StringLoader&); +}; + +}}}//Tizen::Ui::_Resource +#endif // _FUI_INTERNAL_RESOURCE_STRING_LOADER_H_ \ No newline at end of file diff --git a/src/ui/resource/FUi_ResourceTabBarConfig.cpp b/src/ui/resource/FUi_ResourceTabBarConfig.cpp new file mode 100644 index 0000000..a904bd4 --- /dev/null +++ b/src/ui/resource/FUi_ResourceTabBarConfig.cpp @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUi_ResourceTabBarConfig.cpp + * @brief This is the implementation file for the color properties of TabBar. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(TABBAR); +{ + ADD_COLOR_CONFIG(BG_NORMAL, $W0813); + ADD_COLOR_CONFIG(ITEM_BG_NORMAL, $W0813); + ADD_COLOR_CONFIG(ITEM_BG_PRESSED, $W101); + ADD_COLOR_CONFIG(ITEM_BG_HIGHLIGHTED, $W101); + ADD_COLOR_CONFIG(ITEM_TEXT_NORMAL, $F031L3); + ADD_COLOR_CONFIG(ITEM_TEXT_PRESSED, $F031L3P); + ADD_COLOR_CONFIG(ITEM_TEXT_HIGHLIGHTED, $F031L3P); + ADD_COLOR_CONFIG(ARROW_NORMAL, $F031L3); + + ADD_IMAGE_CONFIG(ARROW_BG_LEFT, #00_category_left_gradation.png); + ADD_IMAGE_CONFIG(ARROW_BG_RIGHT, #00_category_right_gradation.png); + ADD_IMAGE_CONFIG(BG_NORMAL, #00_category_panel_bg.9.png) + ADD_IMAGE_CONFIG(ARROW_LEFT, #00_arrow_left.png); + ADD_IMAGE_CONFIG(ARROW_RIGHT, #00_arrow_right.png); + ADD_IMAGE_CONFIG(ITEM_PRESSED, #00_category_button_focus.9.png); + ADD_IMAGE_CONFIG(ITEM_SELECTED, #00_category_button.9.png); + + START_UI_CONFIG_MODE(480x800); + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(720x1280); + ADD_SHAPE_CONFIG(FONT_SIZE, 40); + ADD_SHAPE_CONFIG(FONT_MARGIN, 10); + ADD_SHAPE_CONFIG(TOP_MARGIN, 9); + ADD_SHAPE_CONFIG(SIDE_MARGIN, 56); + ADD_SHAPE_CONFIG(ITEM_MARGIN, 12); + ADD_SHAPE_CONFIG(ITEM_MIN_WIDTH, 140); + ADD_SHAPE_CONFIG(ITEM_MAX_WIDTH, 444); + ADD_SHAPE_CONFIG(ITEM_HEIGHT, 72); + ADD_SHAPE_CONFIG(HEIGHT, 90); + ADD_SHAPE_CONFIG(MIN_WIDTH, 0); + ADD_SHAPE_CONFIG(MAX_WIDTH, 0xFFFF); + ADD_SHAPE_CONFIG(ITEM_COUNT_MAX, 100); + ADD_SHAPE_CONFIG(ARROW_MARGIN, 6); + END_UI_CONFIG_MODE(720x1280); + +} +END_UI_CONFIG(TABBAR); diff --git a/src/ui/resource/FUi_ResourceTabConfig.cpp b/src/ui/resource/FUi_ResourceTabConfig.cpp new file mode 100644 index 0000000..9de9cb2 --- /dev/null +++ b/src/ui/resource/FUi_ResourceTabConfig.cpp @@ -0,0 +1,112 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceTabConfig.cpp + * @brief This is the implementation file for the color, image and shape properties of Tab. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(TAB); +{ + ADD_COLOR_CONFIG(ITEM_BG_NORMAL, $B0513); + ADD_COLOR_CONFIG(ITEM_BG_PRESSED, $B0514P1); + ADD_COLOR_CONFIG(ITEM_BG_SELECTED, $B0513); + ADD_COLOR_CONFIG(ITEM_BG_HIGHLIGHTED, $B0513); + ADD_COLOR_CONFIG(ITEM_BG_DISABLED, $B0513); + ADD_COLOR_CONFIG(ITEM_TEXT_NORMAL, $B052L6); + ADD_COLOR_CONFIG(ITEM_TEXT_PRESSED, $B052L6P); + ADD_COLOR_CONFIG(ITEM_TEXT_SELECTED, $B052L6P); + ADD_COLOR_CONFIG(ITEM_TEXT_HIGHLIGHTED, $B052L1P); + ADD_COLOR_CONFIG(ITEM_TEXT_DISABLED, $B052L6P); + ADD_IMAGE_CONFIG(VERTICAL_DIVIDER_NORMAL, #00_divider_line.9.png); + ADD_IMAGE_CONFIG(ITEM_SELECTED, #00_tab_focus.9.png); + ADD_IMAGE_CONFIG(ITEM_BG_NORMAL, #00_tab_bg.9.png); + ADD_IMAGE_CONFIG(ITEM_BG_PRESSED, #00_tab_bg.9.png); + ADD_IMAGE_CONFIG(ITEM_BG_SELECTED, #00_tab_bg.9.png); + ADD_IMAGE_CONFIG(ITEM_BG_HIGHLIGHTED, #00_tab_bg.9.png); + ADD_IMAGE_CONFIG(ITEM_BG_DISABLED, #00_tab_bg.9.png); + ADD_IMAGE_CONFIG(ITEM_BG_EFFECT_PRESSED, #00_tab_press_ef.9.png); + ADD_IMAGE_CONFIG(ITEM_BG_EFFECT_SELECTED, #00_tab_press_ef.9.png); + ADD_IMAGE_CONFIG(ITEM_BG_EFFECT_HIGHLIGHTED, #00_tab_press_ef.9.png); + ADD_IMAGE_CONFIG(TAB_BOUNCE_EFFECT_LEFT, #00_effect_tab_bounce_left.png); + ADD_IMAGE_CONFIG(TAB_BOUNCE_EFFECT_RIGHT, #00_effect_tab_bounce_right.png); + + + START_UI_CONFIG_MODE(480x800); + { + ADD_SHAPE_CONFIG(SCREEN_HEIGHT, 800); + ADD_SHAPE_CONFIG(SCREEN_WIDTH, 480); + } + END_UI_CONFIG_MODE(480x800); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_FIXED_VALUE_CONFIG(ITEM_MAX_COUNT, 4); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(RIGHT_MARGIN, 16); + ADD_SHAPE_CONFIG(SELECTED_LINE_LEFT_MARGIN, 16); + ADD_SHAPE_CONFIG(SELECTED_LINE_RIGHT_MARGIN, 16); + ADD_SHAPE_CONFIG(SELECTED_LINE_HEIGHT, 3); + ADD_SHAPE_CONFIG(SCREEN_WIDTH, 720); + ADD_SHAPE_CONFIG(SCREEN_HEIGHT, 1280); + ADD_SHAPE_CONFIG(HEIGHT, 111); + ADD_SHAPE_CONFIG(ICON_TEXT_HEIGHT, 111); + ADD_FIXED_VALUE_CONFIG(FONT_CHANGE_ITEM_COUNT, 3); + ADD_SHAPE_CONFIG(FONT_SIZE_01, 30); + ADD_SHAPE_CONFIG(FONT_SIZE_02, 28); + ADD_SHAPE_CONFIG(FONT_SIZE_03, 24); + ADD_SHAPE_CONFIG(MULTILINE_FONT_SIZE_01, 30); + ADD_SHAPE_CONFIG(MULTILINE_FONT_SIZE_02, 28); + ADD_SHAPE_CONFIG(MULTILINE_FONT_SIZE_03, 24); + ADD_SHAPE_CONFIG(ICON_TEXT_FONT_SIZE_01, 30); + ADD_SHAPE_CONFIG(ICON_TEXT_FONT_SIZE_02, 28); + ADD_SHAPE_CONFIG(ICON_TEXT_FONT_SIZE_03, 24); + ADD_SHAPE_CONFIG(TOP_MARGIN, 22); + ADD_SHAPE_CONFIG(BOTTOM_MARGIN, 21); + ADD_SHAPE_CONFIG(ITEM_LEFT_MARGIN, 10); + ADD_SHAPE_CONFIG(ITEM_RIGHT_MARGIN, 10); + ADD_SHAPE_CONFIG(ICON_TEXT_TOP_MARGIN, 21); + ADD_SHAPE_CONFIG(ICON_TEXT_ICON_WIDTH, 44); + ADD_SHAPE_CONFIG(ICON_TEXT_ICON_HEIGHT, 44); + ADD_SHAPE_CONFIG(ICON_TEXT_BOTTOM_MARGIN, 20); + ADD_FIXED_VALUE_CONFIG(ICON_TEXT_GAP, 8); + ADD_SHAPE_CONFIG(ICON_WIDTH, 64); + ADD_SHAPE_CONFIG(ICON_HEIGHT, 64); + ADD_SHAPE_CONFIG(BADGE_ICON_MARGIN, 6); + ADD_SHAPE_CONFIG(DIVIDER_WIDTH, 4); + ADD_SHAPE_CONFIG(DIVIDER_HEIGHT, 32); + ADD_SHAPE_CONFIG(TAB_MINIMUM_SIZE, 342); + } + END_UI_CONFIG_MODE(720x1280); + + START_UI_CONFIG_MODE(1280x720); + { + ADD_SHAPE_CONFIG(HEIGHT, 91); + ADD_SHAPE_CONFIG(ICON_TEXT_HEIGHT, 142); + ADD_SHAPE_CONFIG(LEFT_MARGIN, 34); + ADD_SHAPE_CONFIG(RIGHT_MARGIN, 34); + ADD_SHAPE_CONFIG(ICON_TEXT_FONT_SIZE_01, 26); + ADD_SHAPE_CONFIG(TOP_MARGIN, 12); + ADD_SHAPE_CONFIG(BOTTOM_MARGIN, 11); + ADD_SHAPE_CONFIG(ICON_TEXT_TOP_MARGIN, 19); + ADD_SHAPE_CONFIG(ICON_TEXT_BOTTOM_MARGIN, 19); + } + END_UI_CONFIG_MODE(1280x720); +} +END_UI_CONFIG(TAB); diff --git a/src/ui/resource/FUi_ResourceTableViewConfig.cpp b/src/ui/resource/FUi_ResourceTableViewConfig.cpp new file mode 100644 index 0000000..4006016 --- /dev/null +++ b/src/ui/resource/FUi_ResourceTableViewConfig.cpp @@ -0,0 +1,99 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceTableViewConfig.cpp + * @brief This is the implementation file for the UI properties of TableView. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(TABLEVIEW); +{ + ADD_COLOR_CONFIG(BG_NORMAL, 0x00000000); + ADD_COLOR_CONFIG(ITEM_DIVIDER_TOP_BG_NORMAL, $B0222); + ADD_COLOR_CONFIG(ITEM_DIVIDER_BOTTOM_BG_NORMAL, $B0221); + ADD_COLOR_CONFIG(ITEM_BG_NORMAL, 0x00000000); + ADD_COLOR_CONFIG(ITEM_BG_PRESSED, $B041); + ADD_COLOR_CONFIG(ITEM_BG_HIGHLIGHTED, $B041); + ADD_COLOR_CONFIG(ITEM_BG_DISABLED, $B0211D); + ADD_COLOR_CONFIG(ITEM_TEXT_NORMAL, $F011L1); + ADD_COLOR_CONFIG(ITEM_TEXT_PRESSED, $F011L1P); + ADD_COLOR_CONFIG(ITEM_TEXT_HIGHLIGHTED, $F011L1P); + ADD_COLOR_CONFIG(ITEM_TEXT_DISABLED, $F011L1D); + ADD_COLOR_CONFIG(ITEM_ANNEX_DETAIL_NORMAL, $F032L1); + ADD_COLOR_CONFIG(ITEM_ANNEX_DETAIL_PRESSED, $F032L1P); + ADD_COLOR_CONFIG(ITEM_ANNEX_DETAIL_BG_NORMAL, $W011); + ADD_COLOR_CONFIG(ITEM_ANNEX_DETAIL_BG_PRESSED, $B041); + ADD_COLOR_CONFIG(GROUPITEM_BG_NORMAL, $B0217); + ADD_COLOR_CONFIG(GROUPITEM_TEXT_NORMAL, $W021L3); + ADD_COLOR_CONFIG(GROUPITEM_TEXT_PRESSED, $W021L3P); + ADD_COLOR_CONFIG(GROUPITEM_INDEX_BAR_NORMAL, $W021L2); + ADD_COLOR_CONFIG(GROUPITEM_INDEX_BAR_PRESSED, $W021L2P); + ADD_COLOR_CONFIG(GROUPITEM_BAR_NORMAL, $B0232); + ADD_COLOR_CONFIG(SECTIONITEM_BG_NORMAL, $B0217); + ADD_IMAGE_CONFIG(GROUPITEM_BG_NORMAL, #00_indexlist_bg.9.png); + ADD_IMAGE_CONFIG(GROUPITEM_BG_EFFECT, #00_indexlist_bg_ef.9.png); + ADD_IMAGE_CONFIG(SECTIONITEM_SINGLE_BG_NORMAL, #00_list_group_bg.9.png); + ADD_IMAGE_CONFIG(SECTIONITEM_SINGLE_BG_PRESSED, #00_list_group_bg_ef.9.png); + ADD_IMAGE_CONFIG(SECTIONITEM_TOP_BG_NORMAL, #00_list_group_bg_top.9.png); + ADD_IMAGE_CONFIG(SECTIONITEM_TOP_BG_PRESSED, #00_list_group_bg_top_ef.9.png); + ADD_IMAGE_CONFIG(SECTIONITEM_CENTER_BG_NORMAL, #00_list_group_bg_center.9.png); + ADD_IMAGE_CONFIG(SECTIONITEM_CENTER_BG_PRESSED, #00_list_group_bg_center_ef.9.png); + ADD_IMAGE_CONFIG(SECTIONITEM_BOTTOM_BG_NORMAL, #00_list_group_bg_bottom.9.png); + ADD_IMAGE_CONFIG(SECTIONITEM_BOTTOM_BG_PRESSED, #00_list_group_bg_bottom_ef.9.png); + ADD_IMAGE_CONFIG(CHECKBOX_BG_NORMAL, #00_check_bg.png); + ADD_IMAGE_CONFIG(CHECKBOX_BG_PRESSED, #00_check_bg_press.png); + ADD_IMAGE_CONFIG(CHECKBOX_CHECK_MARK_NORMAL, #00_check_checking.png); + ADD_IMAGE_CONFIG(RADIOBUTTON_NORMAL, #00_button_radio.png); + ADD_IMAGE_CONFIG(RADIOBUTTON_PRESSED, #00_button_radio_press.png); + ADD_IMAGE_CONFIG(RADIOBUTTON_SELECTED, #00_button_radio_select.png); + ADD_IMAGE_CONFIG(ONOFFBUTTON_ON, #00_button_on.png); + ADD_IMAGE_CONFIG(ONOFFBUTTON_OFF, #00_button_off.png); + ADD_IMAGE_CONFIG(ONOFFBUTTON_HANDLER, #00_button_on_off_handler.png); + ADD_IMAGE_CONFIG(CIRCLE_BUTTON_BG_NORMAL, #00_circle_bg.png); + ADD_IMAGE_CONFIG(CIRCLE_BUTTON_BG_EFFECT, #00_circle_bg_ef.png); + ADD_IMAGE_CONFIG(CIRCLE_BUTTON_BG_PRESSED, #00_circle_bg_ef_press.png); + ADD_IMAGE_CONFIG(CIRCLE_BUTTON_REVEAL, #00_button_reveal.png); + ADD_IMAGE_CONFIG(SEARCH_ICON_NORMAL, #00_search_icon.png); + + START_UI_CONFIG_MODE(720x1280); + ADD_DIMENSION_CONFIG(MIN_SIZE, 90, 72); + ADD_SHAPE_CONFIG(ITEM_DEFAULT_FONT_SIZE, 44); + ADD_SHAPE_CONFIG(ITEM_LEFT_MARGIN, 26); + ADD_SHAPE_CONFIG(ITEM_ANNEX_WIDTH, 64); + ADD_SHAPE_CONFIG(ITEM_ANNEX_HEIGHT, 64); + ADD_SHAPE_CONFIG(ITEM_ANNEX_ONOFF_WIDTH, 132); + ADD_SHAPE_CONFIG(ITEM_ANNEX_ONOFF_HEIGHT, 70); + ADD_SHAPE_CONFIG(ITEM_ANNEX_MORE_WIDTH, 74); + ADD_SHAPE_CONFIG(ITEM_ANNEX_MORE_HEIGHT, 74); + ADD_SHAPE_CONFIG(CONTEXTITEM_RIGHT_MARGIN, 0); + ADD_SHAPE_CONFIG(GROUPITEM_DEFAULT_HEIGHT, 78); + ADD_SHAPE_CONFIG(GROUPITEM_DEFAULT_TEXT_HEIGHT, 46); + ADD_SHAPE_CONFIG(GROUPITEM_DEFAULT_FONT_SIZE, 32); + ADD_SHAPE_CONFIG(GROUPITEM_LEFT_MARGIN, 26); + ADD_SHAPE_CONFIG(GROUPITEM_BAR_WIDTH, 7); + ADD_SHAPE_CONFIG(GROUPITEM_BAR_TOP_MARGIN, 4); + ADD_SHAPE_CONFIG(GROUPITEM_INDEX_BAR_HEIGHT, 4); + ADD_SHAPE_CONFIG(GROUPITEM_INDEX_BAR_LEFT_MARGIN, 26); + ADD_SHAPE_CONFIG(GROUPITEM_INDEX_BAR_BOTTOM_MARGIN, 14); + ADD_SHAPE_CONFIG(FASTSCROLL_INDEX_WIDTH, 51); + ADD_FIXED_VALUE_CONFIG(ITEM_DIVIDER_HEIGHT, 1); + ADD_FIXED_VALUE_CONFIG(SECTIONITEM_TOP_MARGIN, 0); + END_UI_CONFIG_MODE(720x1280); +} +END_UI_CONFIG(TABLEVIEW); diff --git a/src/ui/resource/FUi_ResourceTokenEditConfig.cpp b/src/ui/resource/FUi_ResourceTokenEditConfig.cpp new file mode 100644 index 0000000..f2bfe81 --- /dev/null +++ b/src/ui/resource/FUi_ResourceTokenEditConfig.cpp @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUi_ResourceTokenEditConfig.cpp + * @brief This is the implementation file for the color, image and shape properties of TokenEdit. + */ + +#include "FUi_ResourceConfigMacro.h" + +START_UI_CONFIG(TOKENEDIT); +{ + ADD_COLOR_CONFIG(TOKEN_BG_NORMAL, $W0711); + ADD_COLOR_CONFIG(TOKEN_BG_SELECTED, $W0713); + ADD_COLOR_CONFIG(TOKEN_TEXT_NORMAL, $F011L10); + ADD_COLOR_CONFIG(TOKEN_TEXT_SELECTED, $F011L10); + + ADD_IMAGE_CONFIG(TOKEN_BG, #00_contacts_button_bg.9.png); + + START_UI_CONFIG_MODE(720x1280); + { + ADD_SHAPE_CONFIG(LEFT_MARGIN, 26); + ADD_SHAPE_CONFIG(RIGHT_MARGIN, 26); + ADD_SHAPE_CONFIG(TOP_MARGIN, 11); + ADD_SHAPE_CONFIG(BOTTOM_MARGIN, 11); + ADD_SHAPE_CONFIG(TOKEN_TEXT_LEFT_MARGIN, 12); + ADD_SHAPE_CONFIG(TOKEN_TEXT_RIGHT_MARGIN, 12); + ADD_SHAPE_CONFIG(TOKEN_HEIGHT, 66); + ADD_SHAPE_CONFIG(TOKEN_HORIZONTAL_SPACING, 8); + ADD_SHAPE_CONFIG(TOKEN_VERTICAL_SPACING, 16); + ADD_SHAPE_CONFIG(DESCRIPTION_TEXT_RIGHT_MARGIN, 16) + ADD_SHAPE_CONFIG(TOKEN_MIN_WIDTH, 90); + ADD_SHAPE_CONFIG(TOKEN_TEXT_SIZE, 32); + ADD_SHAPE_CONFIG(DESCRIPTION_TEXT_SIZE, 36); + ADD_SHAPE_CONFIG(TEXT_SIZE, 44); + ADD_SHAPE_CONFIG(HIDDEN_TOKEN_COUNT_DISPLAY_MARGIN, 15); + ADD_SHAPE_CONFIG(HIDDEN_TOKEN_COUNT_DISPLAY_TEXT_SIZE, 33); + ADD_SHAPE_CONFIG(HIDDEN_TOKEN_COUNT_DISPLAY_HEIGHT, 60); + ADD_SHAPE_CONFIG(TOKEN_TITLE_RECT_WIDTH, 54); + } + END_UI_CONFIG_MODE(720x1280); +} +END_UI_CONFIG(TOKENEDIT); diff --git a/src/ui/scenes/FUiScenesBackwardSceneTransition.cpp b/src/ui/scenes/FUiScenesBackwardSceneTransition.cpp new file mode 100644 index 0000000..11a8fb3 --- /dev/null +++ b/src/ui/scenes/FUiScenesBackwardSceneTransition.cpp @@ -0,0 +1,56 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesBackwardSceneTransition.cpp + * @brief This is the implementation file of the %BackwardSceneTransition class. + * + */ + +#include +#include "FUiScenes_SceneTransitionImpl.h" + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +BackwardSceneTransition::BackwardSceneTransition(void) + : SceneTransition(SCENE_TRANSITION_DIRECTION_BACKWARD, SceneId(L""), SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_NO_HISTORY, SCENE_DESTROY_OPTION_DESTROY) +{ + +} + +BackwardSceneTransition::BackwardSceneTransition(SceneTransitionAnimationType animationType, SceneDestroyOption destroyOption) + : SceneTransition(SCENE_TRANSITION_DIRECTION_BACKWARD, SceneId(L""), animationType, SCENE_HISTORY_OPTION_NO_HISTORY, destroyOption) +{ + +} + +BackwardSceneTransition::BackwardSceneTransition(const SceneId& destinationSceneId, SceneTransitionAnimationType animationType, + SceneDestroyOption destroyOption) +: SceneTransition(SCENE_TRANSITION_DIRECTION_BACKWARD, destinationSceneId, animationType, SCENE_HISTORY_OPTION_NO_HISTORY, destroyOption) +{ + +} + +BackwardSceneTransition::~BackwardSceneTransition(void) +{ + +} + +} } } // Tizen::Ui::Scenes diff --git a/src/ui/scenes/FUiScenesForwardSceneTransition.cpp b/src/ui/scenes/FUiScenesForwardSceneTransition.cpp new file mode 100644 index 0000000..ead34ab --- /dev/null +++ b/src/ui/scenes/FUiScenesForwardSceneTransition.cpp @@ -0,0 +1,57 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesForwardSceneTransition.cpp + * @brief This is the implementation file of the %ForwardSceneTransition class. + * + */ + +#include +#include "FUiScenes_SceneTransitionImpl.h" + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +ForwardSceneTransition::ForwardSceneTransition(void) + : SceneTransition(SCENE_TRANSITION_DIRECTION_FORWARD, SceneId(L""), SCENE_TRANSITION_ANIMATION_TYPE_NONE, + SCENE_HISTORY_OPTION_ADD_HISTORY, SCENE_DESTROY_OPTION_KEEP) +{ + +} + +ForwardSceneTransition::ForwardSceneTransition(const SceneId& destinationSceneId, SceneTransitionAnimationType animationType, + SceneHistoryOption historyOption, SceneDestroyOption destroyOption) + : SceneTransition(SCENE_TRANSITION_DIRECTION_FORWARD, destinationSceneId, animationType, historyOption, destroyOption) +{ + +} + +ForwardSceneTransition::ForwardSceneTransition(SceneTransitionAnimationType animationType, + SceneHistoryOption historyOption, SceneDestroyOption destroyOption) + : SceneTransition(SCENE_TRANSITION_DIRECTION_FORWARD, SceneId(L""), animationType, historyOption, destroyOption) +{ + +} + +ForwardSceneTransition::~ForwardSceneTransition(void) +{ + +} + +} } } // Tizen::Ui::Scenes diff --git a/src/ui/scenes/FUiScenesScene.cpp b/src/ui/scenes/FUiScenesScene.cpp new file mode 100644 index 0000000..6ef3b32 --- /dev/null +++ b/src/ui/scenes/FUiScenesScene.cpp @@ -0,0 +1,98 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiScenesScene.cpp + * @brief This is the implementation file of the Scene class. + * + */ + +#include +#include +#include "FUiScenes_SceneImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Ui::Controls; + + +namespace Tizen { namespace Ui { namespace Scenes +{ + + +Scene::Scene(void) +{ + ClearLastResult(); + __pSceneImpl = new (std::nothrow) _SceneImpl; + SysTryReturnVoidResult(NID_UI_SCENES, __pSceneImpl, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); +} + +Scene::~Scene(void) +{ + delete __pSceneImpl; +} + +bool +Scene::Equals(const Object& rhs) const +{ + SysAssert(__pSceneImpl != null); + return __pSceneImpl->Equals(rhs); +} + +int +Scene::GetHashCode(void) const +{ + SysAssert(__pSceneImpl != null); + return __pSceneImpl->GetHashCode(); +} + +SceneId +Scene::GetSceneId(void) const +{ + SysAssert(__pSceneImpl != null); + return __pSceneImpl->GetSceneId(); +} + +String +Scene::GetFormId(void) const +{ + SysAssert(__pSceneImpl != null); + return __pSceneImpl->GetFormId(); +} + +String +Scene::GetPanelId(void) const +{ + SysAssert(__pSceneImpl != null); + return __pSceneImpl->GetPanelId(); +} + +Form* +Scene::GetForm(void) const +{ + SysAssert(__pSceneImpl != null); + return __pSceneImpl->GetForm(); +} + +Panel* +Scene::GetPanel(void) const +{ + SysAssert(__pSceneImpl != null); + return __pSceneImpl->GetPanel(); +} + +} } } // Tizen::Ui::Scenes diff --git a/src/ui/scenes/FUiScenesSceneManager.cpp b/src/ui/scenes/FUiScenesSceneManager.cpp new file mode 100644 index 0000000..0431a26 --- /dev/null +++ b/src/ui/scenes/FUiScenesSceneManager.cpp @@ -0,0 +1,286 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiScenesSceneManager.cpp + * @brief This is the implementation file of the SceneManager class. + * + */ + +#include +#include +#include +#include +#include +#include "FUiScenes_SceneImpl.h" +#include "FUiScenes_SceneManagerImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::App; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Animations; + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +SceneManager* SceneManager::__pSceneManagerInstance = null; + +SceneManager::SceneManager(void) + : __pSceneManagerImpl(null) +{ + +} + +SceneManager::~SceneManager(void) +{ + delete __pSceneManagerImpl; +} + +SceneManager* +SceneManager::GetInstance(void) +{ + static pthread_once_t onceBlock = PTHREAD_ONCE_INIT; + + if (!__pSceneManagerInstance) + { + ClearLastResult(); + pthread_once(&onceBlock, InitSingleton); + result r = GetLastResult(); + if (IsFailed(r)) + { + onceBlock = PTHREAD_ONCE_INIT; + } + } + + return __pSceneManagerInstance; +} + +result +SceneManager::Construct(void) +{ + result r = E_SUCCESS; + + __pSceneManagerImpl = new (std::nothrow) _SceneManagerImpl; + SysTryReturnResult(NID_UI_SCENES, __pSceneManagerImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); + + r = __pSceneManagerImpl->Construct(); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +SceneManager::RegisterFormFactory(const IFormFactory& formFactory) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + __pSceneManagerImpl->RegisterFormFactory(formFactory); + return E_SUCCESS; + +} + +result +SceneManager::RegisterPanelFactory(const IPanelFactory& panelFactory) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + __pSceneManagerImpl->RegisterPanelFactory(panelFactory); + return E_SUCCESS; +} + +result +SceneManager::RegisterScene(const SceneId& sceneId, const String& formId, const String& panelId) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->RegisterScene(sceneId, formId, panelId); +} + +result +SceneManager::RegisterScene(const String& resourceId) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->RegisterScene(resourceId); +} + +result +SceneManager::UnregisterScene(const SceneId& sceneId) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->UnregisterScene(sceneId); +} + +result +SceneManager::AddSceneManagerEventListener(ISceneManagerEventListener& sceneManagerEventListener) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->AddSceneManagerEventListener(sceneManagerEventListener); +} + +result +SceneManager::RemoveSceneManagerEventListener(ISceneManagerEventListener& sceneManagerEventListener) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->RemoveSceneManagerEventListener(sceneManagerEventListener); +} + +result +SceneManager::AddSceneEventListener(const SceneId& sceneId, ISceneEventListener& sceneEventListener) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->AddSceneEventListener(sceneId, sceneEventListener); +} + +result +SceneManager::RemoveSceneEventListener(const SceneId& sceneId, ISceneEventListener& sceneEventListener) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->RemoveSceneEventListener(sceneId, sceneEventListener); +} + +result +SceneManager::SetSceneAnimationProvider(const SceneId& sceneId, ISceneAnimationProvider* pSceneAnimationProvider) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->SetSceneAnimationProvider(sceneId, pSceneAnimationProvider); +} + +result +SceneManager::SetSceneTransitionPolicyProvider(ISceneTransitionPolicyProvider* pSceneTransitionPolicyProvider) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->SetSceneTransitionPolicyProvider(pSceneTransitionPolicyProvider); +} + +result +SceneManager::SetFormTransitionAnimationDefaultValues(SceneTransitionAnimationType animationType, long duration, + AnimationInterpolatorType interpolatorType) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->SetFormTransitionAnimationDefaultValues(animationType, duration, interpolatorType); +} + +result +SceneManager::GoForward(const ForwardSceneTransition& sceneTransition, const Tizen::Base::Collection::IList* pArgs) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->GoForward(sceneTransition, pArgs); +} + +result +SceneManager::GoForward(const SceneTransitionId& transitionId, const Tizen::Base::Collection::IList* pArgs) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->GoForward(transitionId, pArgs); +} + +result +SceneManager::GoBackward(const BackwardSceneTransition& sceneTransition, const Tizen::Base::Collection::IList* pArgs) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->GoBackward(sceneTransition, pArgs); +} + +result +SceneManager::GoBackward(const SceneTransitionId& transitionId, const Tizen::Base::Collection::IList* pArgs) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->GoBackward(transitionId, pArgs); +} + +Scene* +SceneManager::GetCurrentScene(void) const +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->GetCurrentScene(); +} + +SceneId +SceneManager::GetCurrentSceneId(void) const +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->GetCurrentSceneId(); +} + +bool +SceneManager::IsSceneAlive(const SceneId& sceneId) const +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->IsSceneAlive(sceneId); +} + +result +SceneManager::DestroyScene(const SceneId& sceneId) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->DestroyScene(sceneId); +} + +result +SceneManager::BringCurrentSceneToTop(void) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->BringCurrentSceneToTop(); +} + +result +SceneManager::ClearSceneHistory(void) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->ClearSceneHistory(); +} + +result +SceneManager::AddToSceneHistory(const SceneId& sceneId) +{ + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->AddToSceneHistory(sceneId); +} + +IListT* +SceneManager::GetSceneHistoryN(void) const +{ + ClearLastResult(); + SysAssertf(__pSceneManagerImpl != null, "Not yet constructed! Construct() should be called before use"); + return __pSceneManagerImpl->GetSceneHistoryN(); +} + +void +SceneManager::InitSingleton(void) +{ + SceneManager* pInst = new (std::nothrow) SceneManager(); + SysTryReturnVoidResult(NID_UI_SCENES, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); + + result r = pInst->Construct(); + SysTryCatch(NID_UI_SCENES, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSceneManagerInstance = pInst; + std::atexit(DestroySingleton); + return; + +CATCH: + delete pInst; +} + +void +SceneManager::DestroySingleton(void) +{ + delete __pSceneManagerInstance; +} + + +} } } // Tizen::Ui::Scenes diff --git a/src/ui/scenes/FUiScenesSceneTransition.cpp b/src/ui/scenes/FUiScenesSceneTransition.cpp new file mode 100644 index 0000000..3b86ed8 --- /dev/null +++ b/src/ui/scenes/FUiScenesSceneTransition.cpp @@ -0,0 +1,162 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenesSceneTransition.cpp + * @brief This is the implementation file of the %SceneTransition class. + * + */ + +#include +#include +#include "FUiScenes_SceneTransitionImpl.h" + + +using namespace Tizen::Base; + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +SceneTransition::SceneTransition(void) + : __pSceneTransitionImpl(null) +{ + __pSceneTransitionImpl = new (std::nothrow) _SceneTransitionImpl(); + SysTryReturnVoidResult(NID_UI_SCENES, __pSceneTransitionImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); +} + +SceneTransition::SceneTransition(const SceneTransition& rhs) + : __pSceneTransitionImpl(null) +{ + if (this != &rhs) + { + __pSceneTransitionImpl = new (std::nothrow) _SceneTransitionImpl(*_SceneTransitionImpl::GetInstance(rhs)); + SysTryReturnVoidResult(NID_UI_SCENES, __pSceneTransitionImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); + } +} + +SceneTransition::SceneTransition(SceneTransitionDirection direction, const SceneId& destinationSceneId, + SceneTransitionAnimationType animationType, + SceneHistoryOption historyOption, SceneDestroyOption destroyOption) + : __pSceneTransitionImpl(null) +{ + __pSceneTransitionImpl = new (std::nothrow) _SceneTransitionImpl(direction, destinationSceneId, animationType, + historyOption, destroyOption); + SysTryReturnVoidResult(NID_UI_SCENES, __pSceneTransitionImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); +} + +SceneTransition& +SceneTransition::operator =(const SceneTransition& rhs) +{ + if (this != &rhs) + { + __pSceneTransitionImpl->operator=(*_SceneTransitionImpl::GetInstance(rhs)); + } + return *this; +} + +bool +SceneTransition::Equals(const Object& rhs) const +{ + const SceneTransition* pSceneTransition = dynamic_cast(&rhs); + if (pSceneTransition != null) + { + return __pSceneTransitionImpl->Equals(*_SceneTransitionImpl::GetInstance(*pSceneTransition)); + } + return false; +} + +int +SceneTransition::GetHashCode(void) const +{ + return __pSceneTransitionImpl->GetHashCode(); +} + +SceneTransition::~SceneTransition(void) +{ + delete __pSceneTransitionImpl; +} + +result +SceneTransition::SetDirection(SceneTransitionDirection direction) +{ + ClearLastResult(); + return __pSceneTransitionImpl->SetDirection(direction); +} + +SceneTransitionDirection +SceneTransition::GetDirection(void) const +{ + return __pSceneTransitionImpl->GetDirection(); +} + +result +SceneTransition::SetDestinationSceneId(const SceneId& sceneId) +{ + ClearLastResult(); + return __pSceneTransitionImpl->SetDestinationSceneId(sceneId); +} + +SceneId +SceneTransition::GetDestinationSceneId(void) const +{ + return __pSceneTransitionImpl->GetDestinationSceneId(); +} + +result +SceneTransition::SetAnimationType(SceneTransitionAnimationType animationType) +{ + ClearLastResult(); + return __pSceneTransitionImpl->SetAnimationType(animationType); +} + +SceneTransitionAnimationType +SceneTransition::GetAnimationType(void) const +{ + return __pSceneTransitionImpl->GetAnimationType(); +} + +result +SceneTransition::SetHistoryOption(SceneHistoryOption historyOption) +{ + ClearLastResult(); + return __pSceneTransitionImpl->SetHistoryOption(historyOption); +} + +SceneHistoryOption +SceneTransition::GetHistoryOption(void) const +{ + return __pSceneTransitionImpl->GetHistoryOption(); +} + +result +SceneTransition::SetDestroyOption(SceneDestroyOption destroyOption) +{ + ClearLastResult(); + return __pSceneTransitionImpl->SetDestroyOption(destroyOption); +} + +SceneDestroyOption +SceneTransition::GetDestroyOption(void) const +{ + return __pSceneTransitionImpl->GetDestroyOption(); +} + +} } } // Tizen::Ui::Scenes diff --git a/src/ui/scenes/FUiScenes_ISceneControlEventListener.h b/src/ui/scenes/FUiScenes_ISceneControlEventListener.h new file mode 100644 index 0000000..7e688e0 --- /dev/null +++ b/src/ui/scenes/FUiScenes_ISceneControlEventListener.h @@ -0,0 +1,46 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiScenes_ISceneControlEventListener.h + * @brief This is the header file of the _ISceneControlEventListener class. + * + * This header file contains the declarations of the _ISceneControlEventListener class. + */ + +#ifndef _FUI_SCENES_INTERNAL_ISCENE_CONTROL_EVENT_LISTENER_H_ +#define _FUI_SCENES_INTERNAL_ISCENE_CONTROL_EVENT_LISTENER_H_ + +#include +#include +#include "FUiScenes_SceneControlEventArg.h" + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +class _ISceneControlEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + virtual ~_ISceneControlEventListener(void) {} + + virtual void OnSceneControlEventReceived(_SceneControlEventArg::SceneControlEventType eventType, const SceneId& sceneId) = 0; + +}; // _ISceneControlEventListener +} } } // Tizen::Ui::Scenes + +#endif // _FUI_SCENES_INTERNAL_ISCENE_CONTROL_EVENT_LISTENER_H_ diff --git a/src/ui/scenes/FUiScenes_SceneControlEvent.cpp b/src/ui/scenes/FUiScenes_SceneControlEvent.cpp new file mode 100644 index 0000000..643464a --- /dev/null +++ b/src/ui/scenes/FUiScenes_SceneControlEvent.cpp @@ -0,0 +1,47 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include "FUiScenes_ISceneControlEventListener.h" +#include "FUiScenes_SceneControlEvent.h" + +namespace Tizen { namespace Ui { namespace Scenes +{ + +result +_SceneControlEvent::Construct(void) +{ + return _Event::Initialize(); +} + +void +_SceneControlEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg) +{ + _ISceneControlEventListener* pListener = dynamic_cast<_ISceneControlEventListener*>(&listener); + if (pListener) + { + const _SceneControlEventArg* pEventArg = dynamic_cast(&arg); + if (pEventArg) + { + pListener->OnSceneControlEventReceived(pEventArg->GetEventType(), pEventArg->GetSceneId()); + return; + } + } + SysLog(NID_UI_SCENES, "Invalid _SceneControlEvent arguments : listener(0x%x), arg(0x%x)", pListener, &arg); +} + +} } } // Tizen::Ui::Scenes diff --git a/src/ui/scenes/FUiScenes_SceneControlEvent.h b/src/ui/scenes/FUiScenes_SceneControlEvent.h new file mode 100644 index 0000000..147cf29 --- /dev/null +++ b/src/ui/scenes/FUiScenes_SceneControlEvent.h @@ -0,0 +1,45 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiScenes_SceneControlEvent.h + * @brief This is the header file of the _SceneControlEvent class. + * + * This header file contains the declarations of the _SceneControlEvent class. + */ + +#ifndef _FUI_SCENES_INTERNAL_SCENE_CONTROL_EVENT_H_ +#define _FUI_SCENES_INTERNAL_SCENE_CONTROL_EVENT_H_ + +#include + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +class _SceneControlEvent + : public Tizen::Base::Runtime::_Event +{ +public: + result Construct(void); + +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg); + +}; // _SceneControlEvent +} } } // Tizen::Ui::Scenes + +#endif // _FUI_SCENES_INTERNAL_SCENE_CONTROL_EVENT_H_ diff --git a/src/ui/scenes/FUiScenes_SceneControlEventArg.cpp b/src/ui/scenes/FUiScenes_SceneControlEventArg.cpp new file mode 100644 index 0000000..d1385b9 --- /dev/null +++ b/src/ui/scenes/FUiScenes_SceneControlEventArg.cpp @@ -0,0 +1,48 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include "FUiScenes_SceneControlEventArg.h" + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +_SceneControlEventArg::_SceneControlEventArg(_SceneControlEventArg::SceneControlEventType eventType, const SceneId& sceneId) + : __eventType(eventType) + , __sceneId(sceneId) +{ + +} + +_SceneControlEventArg::~_SceneControlEventArg(void) +{ + +} + +_SceneControlEventArg::SceneControlEventType +_SceneControlEventArg::GetEventType(void) const +{ + return __eventType; +} + +SceneId +_SceneControlEventArg::GetSceneId(void) const +{ + return __sceneId; +} + +} } } // Tizen::Ui::Scenes diff --git a/src/ui/scenes/FUiScenes_SceneControlEventArg.h b/src/ui/scenes/FUiScenes_SceneControlEventArg.h new file mode 100644 index 0000000..49971a6 --- /dev/null +++ b/src/ui/scenes/FUiScenes_SceneControlEventArg.h @@ -0,0 +1,63 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiScenes_SceneControlEventArg.h + * @brief This is the header file of the _SceneControlEventArg class. + * + * This header file contains the declarations of the _ class. + */ + +#ifndef _FUI_SCENES_INTERNAL_SCENE_CONTROL_EVENT_ARG_H_ +#define _FUI_SCENES_INTERNAL_SCENE_CONTROL_EVENT_ARG_H_ + +#include +#include +#include + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +class _SceneControlEventArg + : public Tizen::Base::Object + , public Tizen::Base::Runtime::IEventArg +{ +public: + enum SceneControlEventType + { + SCENE_CONTROL_EVENT_TYPE_NONE, + SCENE_CONTROL_EVENT_TYPE_DESTROY, // Destroy the specified Scene + }; + + _SceneControlEventArg(_SceneControlEventArg::SceneControlEventType eventType, const SceneId& sceneId); + virtual ~_SceneControlEventArg(void); + + _SceneControlEventArg::SceneControlEventType GetEventType(void) const; + SceneId GetSceneId(void) const; + +private: + _SceneControlEventArg(void); + _SceneControlEventArg(const _SceneControlEventArg& value); + _SceneControlEventArg& operator =(const _SceneControlEventArg& rhs); + + _SceneControlEventArg::SceneControlEventType __eventType; + SceneId __sceneId; + +}; // _SceneControlEventArg +} } } // Tizen::Ui::Scenes + +#endif // _FUI_SCENES_INTERNAL_SCENE_CONTROL_EVENT_ARG_H_ diff --git a/src/ui/scenes/FUiScenes_SceneImpl.cpp b/src/ui/scenes/FUiScenes_SceneImpl.cpp new file mode 100644 index 0000000..0e6bfe5 --- /dev/null +++ b/src/ui/scenes/FUiScenes_SceneImpl.cpp @@ -0,0 +1,261 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include "FUiScenes_SceneImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Ui::Controls; + + +namespace Tizen { namespace Ui { namespace Scenes +{ + + +_SceneImpl::_SceneImpl(void) + : __pForm(null) + , __pPanel(null) + , __pArgs(null) + , __pSceneAnimationProvider(null) + , __panelCreatedFromFormResource(false) +{ + +} + +_SceneImpl::~_SceneImpl(void) +{ +} + +bool +_SceneImpl::Equals(const Object& rhs) const +{ + const Scene* pScene = dynamic_cast(&rhs); + if (pScene == null) + { + return false; + } + + const _SceneImpl* pSceneImpl = _SceneImpl::GetInstance(*pScene); + if (pSceneImpl == this) + { + return true; + } + + if (__sceneId == pSceneImpl->GetSceneId()) + { + return true; + } + + return false; +} + +int +_SceneImpl::GetHashCode(void) const +{ + return __sceneId.GetHashCode(); +} + +SceneId +_SceneImpl::GetSceneId(void) const +{ + return __sceneId; +} + +String +_SceneImpl::GetFormId(void) const +{ + return __formId; +} + +String +_SceneImpl::GetPanelId(void) const +{ + return __panelId; +} + +Form* +_SceneImpl::GetForm(void) const +{ + return __pForm; +} + +void +_SceneImpl::SetForm(Form* pForm) +{ + __pForm = pForm; +} + +Panel* +_SceneImpl::GetPanel(void) const +{ + return __pPanel; +} + +void +_SceneImpl::SetPanel(Panel* pPanel) +{ + __pPanel = pPanel; +} + +void +_SceneImpl::SetArgs(IList* pArgs) +{ + __pArgs = pArgs; +} + +IList* +_SceneImpl::GetArgs(void) +{ + return __pArgs; +} + +result +_SceneImpl::AddSceneEventListener(const ISceneEventListener& sceneEventlistener) +{ + result r = E_SUCCESS; + ISceneEventListener* pListener = const_cast (&sceneEventlistener); + bool alreadyExist = __sceneEventListenerList.Contains(pListener); + SysTryReturnResult(NID_UI_SCENES, !alreadyExist, E_OBJ_ALREADY_EXIST, "The event listener already exist."); + r = __sceneEventListenerList.Add(pListener); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +_SceneImpl::RemoveSceneEventListener(const ISceneEventListener& sceneEventlistener) +{ + result r = E_SUCCESS; + ISceneEventListener* pListener = const_cast (&sceneEventlistener); + r = __sceneEventListenerList.Remove(pListener); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + return r; +} + +result +_SceneImpl::SetSceneAnimationProvider(ISceneAnimationProvider* pSceneAnimationProvider) +{ + ISceneAnimationProvider* pListener = pSceneAnimationProvider; + __pSceneAnimationProvider = pListener; + return E_SUCCESS; +} + +bool +_SceneImpl::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs) +{ + IEnumeratorT* pEnum = __sceneEventListenerList.GetEnumeratorN(); + if (!pEnum) + { + return false; + } + + while (pEnum->MoveNext() == E_SUCCESS) + { + ISceneEventListener* pListener = null; + pEnum->GetCurrent(pListener); + if (pListener) + { + pListener->OnSceneActivatedN(previousSceneId, currentSceneId, pArgs); + } + } + delete pEnum; + return true; +} + +bool +_SceneImpl::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + IEnumeratorT* pEnum = __sceneEventListenerList.GetEnumeratorN(); + if (!pEnum) + { + return false; + } + + while (pEnum->MoveNext() == E_SUCCESS) + { + ISceneEventListener* pListener = null; + pEnum->GetCurrent(pListener); + if (pListener) + { + pListener->OnSceneDeactivated(currentSceneId, nextSceneId); + } + } + delete pEnum; + return true; +} + +bool +_SceneImpl::PrepareAnimation(const SceneId& sceneId, IList* pArgs, SceneTransitionAnimationType type, bool formTransition) +{ + if (__pSceneAnimationProvider) + { + __pSceneAnimationProvider->PrepareAnimation(sceneId, pArgs, type, formTransition); + return true; + } + + return false; +} + +bool +_SceneImpl::IsPanelCreatedFromFormResource(void) const +{ + return __panelCreatedFromFormResource; +} + +void +_SceneImpl::SetPanelCreatedFromFormResource(bool createFromFormResource) +{ + __panelCreatedFromFormResource = createFromFormResource; +} + +Scene* +_SceneImpl::CreateSceneN(const SceneId& sceneId, const String& formId, const String& panelId) +{ + Scene* pScene = new (std::nothrow) Scene(); + SysTryReturn(NID_UI_SCENES, pScene != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); + + _SceneImpl* pSceneImpl = _SceneImpl::GetInstance(*pScene); + SysTryCatch(NID_UI_SCENES, pSceneImpl != null, , E_INVALID_STATE, + "[%s] Scene is in an invalid state. pSceneImpl is not valid", GetErrorMessage(E_INVALID_STATE)); + pSceneImpl->__sceneId = sceneId; + pSceneImpl->__formId = formId; + pSceneImpl->__panelId = panelId; + + return pScene; + +CATCH: + delete pScene; + return null; +} + +_SceneImpl* +_SceneImpl::GetInstance(Scene& scene) +{ + return scene.__pSceneImpl; +} + +const _SceneImpl* +_SceneImpl::GetInstance(const Scene& scene) +{ + return scene.__pSceneImpl; +} + +} } } // Tizen::Ui::Scenes diff --git a/src/ui/scenes/FUiScenes_SceneImpl.h b/src/ui/scenes/FUiScenes_SceneImpl.h new file mode 100644 index 0000000..8768d2f --- /dev/null +++ b/src/ui/scenes/FUiScenes_SceneImpl.h @@ -0,0 +1,115 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiScenes_SceneImpl.h + * @brief This is the header file of the _SceneImpl class. + * + * This header file contains the declarations of the _SceneImpl class. + */ + +#ifndef _FUI_SCENES_INTERNAL_SCENE_IMPL_H_ +#define _FUI_SCENES_INTERNAL_SCENE_IMPL_H_ + +#include +#include +#include +#include +#include + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +class ISceneAnimationProvider; + +class _SceneImpl + : public Tizen::Base::Object +{ +public: + _SceneImpl(void); + virtual ~_SceneImpl(void); + virtual bool Equals(const Object& rhs) const; + virtual int GetHashCode(void) const; + + SceneId GetSceneId(void) const; + Tizen::Base::String GetFormId(void) const; + Tizen::Base::String GetPanelId(void) const; + Tizen::Ui::Controls::Form* GetForm(void) const; + void SetForm(Tizen::Ui::Controls::Form* pForm); + Tizen::Ui::Controls::Panel* GetPanel(void) const; + void SetPanel(Tizen::Ui::Controls::Panel* pPanel); + Tizen::Base::Collection::IList* GetArgs(void); + void SetArgs(Tizen::Base::Collection::IList* pArgs = null); + + result AddSceneEventListener(const ISceneEventListener& sceneEventlistener); + result RemoveSceneEventListener(const ISceneEventListener& sceneEventlistener); + result SetSceneAnimationProvider(ISceneAnimationProvider* pSceneAnimationProvider); + + bool OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, + Tizen::Base::Collection::IList* pArgs); + bool OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId); + bool PrepareAnimation(const SceneId& sceneId, Tizen::Base::Collection::IList* pArgs, + SceneTransitionAnimationType type, bool formTransition); + + bool IsPanelCreatedFromFormResource(void) const; + void SetPanelCreatedFromFormResource(bool createFromFormResource); + + // + // Create a new Scene instance + // + // @return The Scene instance + // @since 2.0 + // + static Tizen::Ui::Scenes::Scene* CreateSceneN(const SceneId& sceneId, const Tizen::Base::String& formId, + const Tizen::Base::String& panelId); + + // + // Gets the implementation. + // + // @return The implementation + // @param[in] The interface instance pointer + // @since 2.0 + // + static _SceneImpl* GetInstance(Scene& scene); + + // + // Gets the implementation. + // + // @return The implementation + // @param[in] The interface instance pointer + // @since 2.0 + // + static const _SceneImpl* GetInstance(const Scene& scene); + +private: + _SceneImpl(const Scene& rhs); + _SceneImpl& operator =(const Scene& rhs); + +private: + SceneId __sceneId; + Tizen::Base::String __formId; + Tizen::Base::String __panelId; + Tizen::Ui::Controls::Form* __pForm; + Tizen::Ui::Controls::Panel* __pPanel; + Tizen::Base::Collection::IList* __pArgs; + Tizen::Base::Collection::LinkedListT __sceneEventListenerList; + ISceneAnimationProvider* __pSceneAnimationProvider; + bool __panelCreatedFromFormResource; +}; // _SceneImpl +} } } // Tizen::Ui::Scenes + +#endif // _FUI_SCENES_INTERNAL_SCENE_IMPL_H_ diff --git a/src/ui/scenes/FUiScenes_SceneManagerImpl.cpp b/src/ui/scenes/FUiScenes_SceneManagerImpl.cpp new file mode 100644 index 0000000..cfe9156 --- /dev/null +++ b/src/ui/scenes/FUiScenes_SceneManagerImpl.cpp @@ -0,0 +1,1808 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUiScenes_SceneImpl.h" +#include "FUiScenes_SceneManagerImpl.h" +#include "FUiScenes_SceneTransitionImpl.h" +#include "FUiAnim_FrameAnimatorImpl.h" +#include "FUi_Control.h" +#include "FUi_ControlManager.h" +#include "FUi_ContainerImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::App; +using namespace Tizen::Io; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +// HashMapT assist template +template +class _StringHashCodeProvider + : public IHashCodeProviderT +{ +public: + virtual int + GetHashCode(const T& obj) const + { + String& objString = static_cast (const_cast (obj)); + return objString.GetHashCode(); + } +}; +template +class _StringComparer + : public IComparerT +{ +public: + virtual result + Compare(const T& obj1, const T& obj2, int& cmp) const + { + String& objString1 = static_cast (const_cast (obj1)); + String& objString2 = static_cast (const_cast (obj2)); + cmp = objString1.CompareTo(objString2); + return E_SUCCESS; + } +}; + + +_SceneManagerImpl::_SceneDescription::_SceneDescription(const String& descriptionFormId, const String& descriptionPanelId) + : formId(descriptionFormId) + , panelId(descriptionPanelId) +{ + +} + +_SceneManagerImpl::_SceneManagerImpl(void) + : __currentSceneId(L"") + , __pCurrentScene(null) + , __pFormFactory(null) + , __pPanelFactory(null) + , __pPolicyProvider(null) + , __destroyReservedScene(L"") + , __pCorrespondFrame(null) + , __correspondFrameControlHandle() +{ + for (int i = 0; i < FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_MAX; i++) + { + static const long ANIMATION_DURATION = 250L; + __animationDescriptions[i].animationType = FrameAnimatorFormTransitionAnimation(i); + __animationDescriptions[i].duration = ANIMATION_DURATION; + __animationDescriptions[i].interpolatorType = ANIMATION_INTERPOLATOR_LINEAR; + } +} + +_SceneManagerImpl::~_SceneManagerImpl(void) +{ + std::unique_ptr > pMapEnum(__sceneMap.GetMapEnumeratorN()); + if (pMapEnum) + { + while (pMapEnum->MoveNext() == E_SUCCESS) + { + _SceneDescription* pValue = null; + pMapEnum->GetValue(pValue); + delete pValue; + } + } + else + { + SysLogException(NID_UI_SCENES, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + } + + std::unique_ptr > pTransitionMapEnum(__transitionMap.GetMapEnumeratorN()); + if (pTransitionMapEnum) + { + while (pTransitionMapEnum->MoveNext() == E_SUCCESS) + { + SceneTransition* pValue = null; + pTransitionMapEnum->GetValue(pValue); + delete pValue; + } + } + else + { + SysLogException(NID_UI_SCENES, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + } +} + +result +_SceneManagerImpl::Construct(void) +{ + result r = E_SUCCESS; + static _StringHashCodeProvider sceneHashCodeProvider; + static _StringComparer strComparer; + + r = __sceneContainer.Construct(0, 0, sceneHashCodeProvider, strComparer); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __formContainer.Construct(0, 0, sceneHashCodeProvider, strComparer); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __formToPanelMultiMap.Construct(0, 0, sceneHashCodeProvider, strComparer); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __sceneMap.Construct(0, 0, sceneHashCodeProvider, strComparer); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __transitionMap.Construct(0, 0, sceneHashCodeProvider, strComparer); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __sceneControlEvent.Construct(); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + r = __sceneControlEvent.AddListener(dynamic_cast<_ISceneControlEventListener&>(*this)); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + UiApp* pUiApp = UiApp::GetInstance(); + SysTryReturn(NID_UI_SCENES, pUiApp != null, null, E_SYSTEM, + "[%s] A system error has been occurred. UiApp::GetInstance failed.", GetErrorMessage(E_SYSTEM)); + Frame* pFrame = pUiApp->GetFrameAt(0); + SysTryReturn(NID_UI_SCENES, pFrame != null, null, E_SYSTEM, + "[%s] A system error has been occurred. pUiApp->GetFrameAt(0) return null.", GetErrorMessage(E_SYSTEM)); + __pCorrespondFrame = pFrame; + _ContainerImpl* pFrameWindowImpl = _ContainerImpl::GetInstance(*__pCorrespondFrame); + SysTryReturn(NID_UI_SCENES, pFrameWindowImpl != null, null, E_SYSTEM, + "[%s] A system error has been occurred. _ContainerImpl::GetInstance failed.", GetErrorMessage(E_SYSTEM)); + __correspondFrameControlHandle = pFrameWindowImpl->GetCore().GetHandle(); + + return E_SUCCESS; +} + +result +_SceneManagerImpl::RegisterFormFactory(const IFormFactory& formFactory) +{ + __pFormFactory = const_cast (&formFactory); + + return E_SUCCESS; +} + +result +_SceneManagerImpl::RegisterPanelFactory(const IPanelFactory& panelFactory) +{ + __pPanelFactory = const_cast (&panelFactory); + + return E_SUCCESS; +} + +result +_SceneManagerImpl::RegisterScene(const SceneId& sceneId, const String& formId, const String& panelId) +{ + result r = E_SUCCESS; + _SceneDescription* pSceneDescription = null; + bool isContains = false; + + SysTryReturnResult(NID_UI_SCENES, !(sceneId.IsEmpty() || formId.IsEmpty()), E_INVALID_ARG, + "Invalid argument is used. String length of sceneId=%d, formId=%d", + sceneId.GetLength(), formId.GetLength()); + + r = __sceneMap.ContainsKey(sceneId, isContains); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnResult(NID_UI_SCENES, !isContains, E_OBJ_ALREADY_EXIST, "Specified sceneId already exist."); + + pSceneDescription = new (std::nothrow) _SceneDescription(formId, panelId); + SysTryReturnResult(NID_UI_SCENES, pSceneDescription != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __sceneMap.Add(sceneId, pSceneDescription); + SysTryCatch(NID_UI_SCENES, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + +CATCH: + delete pSceneDescription; + return r; +} + +result +_SceneManagerImpl::RegisterScene(const String& resourceId) +{ + static const wchar_t RESOUCE_FILE_PATH[] = L"res/"; + static const wchar_t RESOUCE_FILE_EXT[] = L".xml"; + static const wchar_t RESOUCE_FILE_NORMAL[] = L"screen-size-normal/"; + static const xmlChar* pElementWorkflow = reinterpret_cast("Workflow"); + static const xmlChar* pElementScene = reinterpret_cast("Scene"); + static const xmlChar* pElementSceneTransition = reinterpret_cast("SceneTransition"); + result r = E_SUCCESS; + + _ControlManager* pControlManager = _ControlManager::GetInstance(); + SysTryReturnResult(NID_UI_SCENES, pControlManager != null, E_SYSTEM, + "A system error has been occurred. Unable to get the control manager."); + Dimension screenSize = pControlManager->GetScreenSize(); + + const String appRootPath = Tizen::App::App::GetInstance()->GetAppRootPath(); + String filePath; + // Formating path for current resolution: [AppRootPath/][res/][width]x[height]/[resourceId][.xml] + r = filePath.Format(FILENAME_MAX, L"%ls%ls%dx%d/%ls%ls", + appRootPath.GetPointer(), RESOUCE_FILE_PATH, screenSize.width, screenSize.height, + resourceId.GetPointer(), RESOUCE_FILE_EXT); + SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_SYSTEM, "A system error has been occurred. File path formatting failed."); + SysLog(NID_UI_SCENES, "RegisterScene: res path: %ls", filePath.GetPointer()); + + if (!File::IsFileExist(filePath)) + { // File not exist on specific resolution then try again: [AppRootPath/][res/][screen-size-normal/][resourceId][.xml] + filePath.Format(FILENAME_MAX, L"%ls%ls%ls%ls%ls", + appRootPath.GetPointer(), RESOUCE_FILE_PATH, RESOUCE_FILE_NORMAL, + resourceId.GetPointer(), RESOUCE_FILE_EXT); + SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_SYSTEM, "A system error has been occurred. File path formatting failed."); + SysLog(NID_UI_SCENES, "RegisterScene: 2nd try - res path: %ls", filePath.GetPointer()); + if (!pControlManager->IsCoordinateSystemLogical() || !File::IsFileExist(filePath)) + { + SysLogException(NID_UI_SCENES, E_FILE_NOT_FOUND, "[%s] File could not be found. File path=%ls", + GetErrorMessage(E_FILE_NOT_FOUND), filePath.GetPointer()); + return E_FILE_NOT_FOUND; + } + } + + std::unique_ptr pfilePathBuffer(Tizen::Base::Utility::StringUtil::StringToUtf8N(filePath)); + SysTryReturnResult(NID_UI_SCENES, pfilePathBuffer != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + xmlDocPtr docPtr = xmlParseFile(reinterpret_cast(pfilePathBuffer->GetPointer())); + SysTryReturnResult(NID_UI_SCENES, docPtr != null, E_SYSTEM, + "A system error has been occurred. Can not parse xml file: %ls", filePath.GetPointer()); + + xmlNodePtr rootNodePtr = xmlDocGetRootElement(docPtr); + SysTryReturnResult(NID_UI_SCENES, rootNodePtr != null, E_SYSTEM, + "A system error has been occurred. Can not find root node"); + + // Visit xml nodes + for (xmlNodePtr nodePtr = rootNodePtr; nodePtr != null; nodePtr = nodePtr->next) // Visit sibling node + { // Get element 'Workflow' + if ((nodePtr->type == XML_ELEMENT_NODE) && (xmlStrcmp(nodePtr->name, pElementWorkflow) == 0)) + { // and Get child - 'Scene's and 'SceneTransition's + for (xmlNodePtr childNodePtr = nodePtr->children; childNodePtr != null; childNodePtr = childNodePtr->next) // Visit sibling + { // Get element 'Scene's and 'SceneTransition's + if (childNodePtr->type == XML_ELEMENT_NODE) + { // Check E_OBJ_ALREADY_EXIST(continue) and E_OUT_OF_MEMORY(break) for all case. + if (xmlStrcmp(childNodePtr->name, pElementScene) == 0) + { + result regResult = RegisterScene(childNodePtr); + if (IsFailed(regResult)) + { + SysTryCatch(NID_UI_SCENES, regResult != E_OUT_OF_MEMORY, r = regResult, regResult, + "[%s] Propagating.", GetErrorMessage(regResult)); + if (regResult == E_OBJ_ALREADY_EXIST) + { + r = regResult; + } + } + } + else + if (xmlStrcmp(childNodePtr->name, pElementSceneTransition) == 0) + { + result regResult = RegisterSceneTransition(childNodePtr); + if (IsFailed(regResult)) + { + SysTryCatch(NID_UI_SCENES, regResult != E_OUT_OF_MEMORY, r = regResult, regResult, + "[%s] Propagating.", GetErrorMessage(regResult)); + if (regResult == E_OBJ_ALREADY_EXIST) + { + r = regResult; + } + } + } + } // 'Scene' and 'SceneTransition' + } // Children of 'Workflow' + } // Element 'Workflow' + }// Root node sibling + + xmlFreeDoc(docPtr); + return r; + +CATCH: + xmlFreeDoc(docPtr); + return r; +} + +result +_SceneManagerImpl::UnregisterScene(const SceneId& sceneId) +{ + result r = E_SUCCESS; + _SceneDescription* pSceneDescription = null; + + SysTryReturnResult(NID_UI_SCENES, !sceneId.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. sceneId is empty."); + + r = __sceneMap.GetValue(sceneId, pSceneDescription); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __sceneMap.Remove(sceneId); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + delete pSceneDescription; + return r; +} + +result +_SceneManagerImpl::AddSceneManagerEventListener(ISceneManagerEventListener& sceneManagerEventListener) +{ + result r = E_SUCCESS; + ISceneManagerEventListener* pListener = &sceneManagerEventListener; + bool alreadyExist = __sceneManagerEventListenerList.Contains(pListener); + SysTryReturnResult(NID_UI_SCENES, !alreadyExist, E_OBJ_ALREADY_EXIST, "The event listener already exist."); + r = __sceneManagerEventListenerList.Add(pListener); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_SceneManagerImpl::RemoveSceneManagerEventListener(ISceneManagerEventListener& sceneManagerEventListener) +{ + result r = E_SUCCESS; + ISceneManagerEventListener* pListener = &sceneManagerEventListener; + r = __sceneManagerEventListenerList.Remove(pListener); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_SceneManagerImpl::AddSceneEventListener(const SceneId& sceneId, ISceneEventListener& sceneEventListener) +{ + result r = E_SUCCESS; + Scene* pScene = null; + _SceneImpl* pSceneImpl = null; + + pScene = GetSceneFromContainer(sceneId); + SysTryReturnResult(NID_UI_SCENES, pScene != null, E_INVALID_ARG, "Invalid argument is used. The sceneId is not valid."); + pSceneImpl = _SceneImpl::GetInstance(*pScene); + SysTryReturnResult(NID_UI_SCENES, pSceneImpl != null, E_INVALID_ARG, "Invalid argument is used. The sceneId is not valid."); + r = pSceneImpl->AddSceneEventListener(sceneEventListener); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_SceneManagerImpl::RemoveSceneEventListener(const SceneId& sceneId, ISceneEventListener& sceneEventListener) +{ + result r = E_SUCCESS; + Scene* pScene = null; + _SceneImpl* pSceneImpl = null; + + pScene = GetSceneFromContainer(sceneId); + SysTryReturnResult(NID_UI_SCENES, pScene != null, E_INVALID_ARG, "Invalid argument is used. The sceneId is not valid."); + pSceneImpl = _SceneImpl::GetInstance(*pScene); + SysTryReturnResult(NID_UI_SCENES, pSceneImpl != null, E_INVALID_ARG, "Invalid argument is used. The sceneId is not valid."); + r = pSceneImpl->RemoveSceneEventListener(sceneEventListener); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_SceneManagerImpl::SetSceneAnimationProvider(const SceneId& sceneId, ISceneAnimationProvider* pSceneAnimationProvider) +{ + result r = E_SUCCESS; + Scene* pScene = null; + _SceneImpl* pSceneImpl = null; + + pScene = GetSceneFromContainer(sceneId); + SysTryReturnResult(NID_UI_SCENES, pScene != null, E_INVALID_ARG, "Invalid argument is used. The sceneId is not valid."); + pSceneImpl = _SceneImpl::GetInstance(*pScene); + SysTryReturnResult(NID_UI_SCENES, pSceneImpl != null, E_INVALID_ARG, "Invalid argument is used. The sceneId is not valid."); + r = pSceneImpl->SetSceneAnimationProvider(pSceneAnimationProvider); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +result +_SceneManagerImpl::SetSceneTransitionPolicyProvider(ISceneTransitionPolicyProvider* pSceneTransitionPolicyProvider) +{ + __pPolicyProvider = pSceneTransitionPolicyProvider; + + return E_SUCCESS; +} + +result +_SceneManagerImpl::SetFormTransitionAnimationDefaultValues(SceneTransitionAnimationType animationType, long duration, + AnimationInterpolatorType interpolatorType) +{ + static const long DURATION_MIN = 0; + static const long DURATION_MAX = 1000; + + SysTryReturnResult(NID_UI_SCENES, (SCENE_TRANSITION_ANIMATION_TYPE_LEFT <= animationType && + animationType <= SCENE_TRANSITION_ANIMATION_TYPE_DEPTH_OUT), E_INVALID_ARG, + "Invalid argument is used. animationType=%d", animationType); + SysTryReturnResult(NID_UI_SCENES, (DURATION_MIN <= duration && duration <= DURATION_MAX), E_INVALID_ARG, + "Invalid argument is used. duration=%d", duration); + __animationDescriptions[animationType - SCENE_TRANSITION_ANIMATION_TYPE_LEFT].duration = duration; + __animationDescriptions[animationType - SCENE_TRANSITION_ANIMATION_TYPE_LEFT].interpolatorType = interpolatorType; + + return E_SUCCESS; +} + +result +_SceneManagerImpl::GoForward(const ForwardSceneTransition& sceneTransition, const Tizen::Base::Collection::IList* pArgs) +{ + SysTryReturnResult(NID_UI_SCENES, IsAnimationCompleted() == true, E_IN_PROGRESS, "Previous operation in progressing"); + result r = E_SUCCESS; + + const _SceneTransitionImpl& forwardSceneTransition + = *_SceneTransitionImpl::GetInstance(static_cast(sceneTransition)); + SysTryReturnResult(NID_UI_SCENES, forwardSceneTransition.GetDirection() == SCENE_TRANSITION_DIRECTION_FORWARD, E_INVALID_ARG, + "Invalid argument is used. sceneTransition's direction is not SCENE_TRANSITION_DIRECTION_FORWARD."); + + SceneId sceneId = forwardSceneTransition.GetDestinationSceneId(); + if (sceneId.GetLength() > 0) + { // Goto the specified scene + r = GotoScene(true, sceneId, forwardSceneTransition.GetAnimationType(), + forwardSceneTransition.GetHistoryOption(), forwardSceneTransition.GetDestroyOption(), pArgs); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { // Transition via PolicyProvider + SysTryReturnResult(NID_UI_SCENES, __pPolicyProvider != null, E_INVALID_STATE, + "SceneManager is in an invalid state. Policy provider not registered."); + + String nextSceneId = __pPolicyProvider->GetNextScene(__currentSceneId, pArgs); + SysTryReturnResult(NID_UI_SCENES, !nextSceneId.IsEmpty(), E_INVALID_STATE, + "SceneManager is in an invalid state. Policy provider does not know next scene."); + + r = GotoScene(true, nextSceneId, forwardSceneTransition.GetAnimationType(), + forwardSceneTransition.GetHistoryOption(), forwardSceneTransition.GetDestroyOption(), pArgs); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_SceneManagerImpl::GoForward(const SceneTransitionId& transitionId, const Tizen::Base::Collection::IList* pArgs) +{ + ForwardSceneTransition forwardTransition; + + result r = GetSceneTransition(transitionId, forwardTransition); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return GoForward(forwardTransition, pArgs); +} + +result +_SceneManagerImpl::GoBackward(const BackwardSceneTransition& sceneTransition, const Tizen::Base::Collection::IList* pArgs) +{ + SysTryReturnResult(NID_UI_SCENES, IsAnimationCompleted() == true, E_IN_PROGRESS, "Previous operation in progressing"); + result r = E_SUCCESS; + + const int historyCount = __sceneHistory.GetCount(); + SysTryReturnResult(NID_UI_SCENES, historyCount != 0, E_UNDERFLOW, "The Scene history is empty."); + + const _SceneTransitionImpl& backwardSceneTransition = *_SceneTransitionImpl::GetInstance(sceneTransition); + SysTryReturnResult(NID_UI_SCENES, backwardSceneTransition.GetDirection() == SCENE_TRANSITION_DIRECTION_BACKWARD, + E_INVALID_ARG, + "Invalid argument is used. sceneTransition's direction is not SCENE_TRANSITION_DIRECTION_BACKWARD!"); + SysTryReturnResult(NID_UI_SCENES, backwardSceneTransition.GetHistoryOption() == SCENE_HISTORY_OPTION_NO_HISTORY, + E_INVALID_ARG, + "Invalid argument is used. sceneTransition's history option is not SCENE_HISTORY_OPTION_NO_HISTORY!"); + + SceneId sceneId = backwardSceneTransition.GetDestinationSceneId(); + if (sceneId.GetLength() > 0) + { // Back to specific scene and clean up history between destination and last point. + int historyIndex = -1; + SceneId destinationSceneId; + + // 1. Back tracking and pick a first matching sceneId + r = __sceneHistory.LastIndexOf(sceneId, historyIndex); + SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_OBJ_NOT_FOUND, + "The given sceneId was not found in the registered scenes."); + r = __sceneHistory.GetAt(historyIndex, destinationSceneId); + SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_SYSTEM, "A system error has been occurred."); + + // 2. if destoryOption == SCENE_DESTROY_OPTION_DESTROY then destroy all scenes except matching scene. + if (backwardSceneTransition.GetDestroyOption() == SCENE_DESTROY_OPTION_DESTROY) + { + for (int i = historyIndex+1; i < historyCount; i++) + { + SceneId destroyTargetSceneId; + __sceneHistory.GetAt(i, destroyTargetSceneId); + // Scene instance is not always valid. + Scene* pScene = GetSceneFromContainer(destroyTargetSceneId); + if (pScene) + { + // If Panel Scene then destroy sibling Panel Scene(s). + if (pScene->GetPanel()) + { + DestroySiblingPanelScene(destroyTargetSceneId); + } + DestroyScene(destroyTargetSceneId); + } + } + } + + // 3. Remove all scenes on history between latest scene to matching scene. + r = __sceneHistory.RemoveItems(historyIndex, historyCount-historyIndex); + SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_SYSTEM, "A system error has been occurred."); + + // Transition + r = GotoScene(false, destinationSceneId, backwardSceneTransition.GetAnimationType(), + SCENE_HISTORY_OPTION_NO_HISTORY, backwardSceneTransition.GetDestroyOption(), pArgs); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { // Adjacent backward transition + SceneId previousSceneId; + + r = __sceneHistory.GetAt(historyCount-1, previousSceneId); + SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_OBJ_NOT_FOUND, + "The given sceneId was not found in the registered scenes."); + r = __sceneHistory.RemoveAt(historyCount-1); + SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_SYSTEM, "A system error has been occurred."); + + r = GotoScene(false, previousSceneId, backwardSceneTransition.GetAnimationType(), + SCENE_HISTORY_OPTION_NO_HISTORY, backwardSceneTransition.GetDestroyOption(), pArgs); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + return r; +} + +result +_SceneManagerImpl::GoBackward(const SceneTransitionId& transitionId, const Tizen::Base::Collection::IList* pArgs) +{ + BackwardSceneTransition backwardTransition; + + result r = GetSceneTransition(transitionId, backwardTransition); + SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_INVALID_ARG, "Cannot get transition from Id."); + + return GoBackward(backwardTransition, pArgs); +} + +Scene* +_SceneManagerImpl::GetCurrentScene(void) const +{ + return __pCurrentScene; +} + +SceneId +_SceneManagerImpl::GetCurrentSceneId(void) const +{ + return __currentSceneId; +} + +bool +_SceneManagerImpl::IsSceneAlive(const SceneId& sceneId) const +{ + return (GetSceneFromContainer(sceneId)) ? true : false; +} + +result +_SceneManagerImpl::DestroyScene(const SceneId& sceneId) +{ + result r = E_SUCCESS; + Scene* pScene = null; + bool isFormScene = false; + bool isLastPanel = false; + int panelCount = 0; + + SysTryReturnResult(NID_UI_SCENES, __currentSceneId != sceneId, E_INVALID_ARG, + "Invalid argument is used. The current Scene can not be destroy."); + pScene = GetSceneFromContainer(sceneId); + SysTryReturnResult(NID_UI_SCENES, pScene != null, E_OBJ_NOT_FOUND, "Specified sceneId does not exist."); + + // Ok now destroy associated Ui controls + // Form scene: Destroy Form - that's all. + // Panel scene: Normal case - destroy Panel only but the current scene is the last panel then destroy Form. + // Correspondent internal data item should be destroy. + if (!pScene->GetPanel()) + { + isFormScene = true; + } + else + { + r = __formToPanelMultiMap.GetCount(pScene->GetFormId(), panelCount); + SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_SYSTEM, + "A system error has been occurred. Form(SceneId:%ls) is not valid.", sceneId.GetPointer()); + if (panelCount <= 1) + { + isLastPanel = true; + } + } + + if (isFormScene) + { // 1. Remove Form control(Associated on Scene) from Frame + RemoveControlFromFrame(*pScene->GetForm()); + // 2. Remove Form from Form container + RemoveFormFromFormContainer(pScene->GetFormId()); + } + else + if (isLastPanel) + { // 1. Remove Panel from Panel container. + RemovePanelFromPanelContainer(pScene); + // 2. Remove Form control from Frame. (Associated Panel automatically removed by Ui) + RemoveControlFromFrame(*pScene->GetForm()); + // 3. Remove Form from Form container. + RemoveFormFromFormContainer(pScene->GetFormId()); + } + else + { // 1. Remove Panel from Panel container. + RemovePanelFromPanelContainer(pScene); + // 2. Remove Panel control from base Form + bool panelFromFormResouce = false; + _SceneImpl* pSceneImpl = _SceneImpl::GetInstance(*pScene); + if (pSceneImpl) + { + panelFromFormResouce = pSceneImpl->IsPanelCreatedFromFormResource(); + } + if (!panelFromFormResouce) + { + RemoveControlFromForm(*pScene->GetForm(), *pScene->GetPanel()); + } + } + + // Finally remove Scene + RemoveSceneFromContainer(sceneId); + delete pScene; + + return E_SUCCESS; +} + +result +_SceneManagerImpl::BringCurrentSceneToTop(void) +{ + Form* pForm = null; + Scene* pCurrentScene = GetCurrentScene(); + + SysTryReturnResult(NID_UI_SCENES, pCurrentScene != null, E_OPERATION_FAILED, "The current Scene is not valid."); + pForm = pCurrentScene->GetForm(); + SysTryReturnResult(NID_UI_SCENES, pForm != null, E_SYSTEM, "A system error has been occurred. The Form is not valid."); + result r = SetCurrentForm(*pForm); + SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_SYSTEM, "A system error has been occurred."); + + return E_SUCCESS; +} + +result +_SceneManagerImpl::ClearSceneHistory(void) +{ + __sceneHistory.RemoveAll(); + + return E_SUCCESS; +} + +result +_SceneManagerImpl::AddToSceneHistory(const SceneId& sceneId) +{ + result r = E_SUCCESS; + bool isContains = false; + + SysTryReturnResult(NID_UI_SCENES, !sceneId.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. sceneId length is 0."); + r = __sceneMap.ContainsKey(sceneId, isContains); + SysTryReturnResult(NID_UI_SCENES, isContains, E_OBJ_NOT_FOUND, "The sceneId is not registered."); + r = AddHistory(sceneId); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + +IListT* +_SceneManagerImpl::GetSceneHistoryN(void) const +{ + IListT* pSceneList = null; + pSceneList = new (std::nothrow) ArrayListT; + SysTryReturn(NID_UI_SCENES, pSceneList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); + + pSceneList->AddItems(__sceneHistory); + return pSceneList; +} + +_SceneManagerImpl* +_SceneManagerImpl::GetInstance(SceneManager& pSceneManager) +{ + return pSceneManager.__pSceneManagerImpl; +} + +const _SceneManagerImpl* +_SceneManagerImpl::GetInstance(const SceneManager& pSceneManager) +{ + return pSceneManager.__pSceneManagerImpl; +} + +// Event handelers to asynchronous destroy the Scene. +void +_SceneManagerImpl::OnFormTransitionAnimationFinished(FrameAnimator& source, Frame& frame, Form& form1, Form& form2) +{ + source.RemoveFrameAnimatorEventListener(*this); + DestroyReservedScene(); +} + +void +_SceneManagerImpl::OnFormTransitionAnimationStarted(FrameAnimator& source, Frame& frame, Form& form1, Form& form2) +{ + // Nothing to do. +} + +void +_SceneManagerImpl::OnFormTransitionAnimationStopped(FrameAnimator& source, Frame& frame, Form& form1, Form& form2) +{ + source.RemoveFrameAnimatorEventListener(*this); + DestroyReservedScene(); +} + +void +_SceneManagerImpl::OnControlAnimationFinished(ControlAnimator& source, Control& control) +{ + source.RemoveControlAnimatorEventListener(*this); + DestroyReservedScene(); +} + +void +_SceneManagerImpl::OnControlAnimationStarted(ControlAnimator& source, Control& control) +{ + // Nothing to do. +} + +void +_SceneManagerImpl::OnControlAnimationStopped(ControlAnimator& source, Control& control) +{ + source.RemoveControlAnimatorEventListener(*this); + DestroyReservedScene(); +} + +void +_SceneManagerImpl::OnSceneControlEventReceived(_SceneControlEventArg::SceneControlEventType eventType, const SceneId& sceneId) +{ + SysLog(NID_UI_SCENES, "Received type= 0x%x, sceneId=%ls", eventType, &sceneId); + + switch (eventType) + { + case _SceneControlEventArg::SCENE_CONTROL_EVENT_TYPE_DESTROY: + DestroyScene(sceneId); + break; + + default: + SysLog(NID_UI_SCENES, "Invalid SceneControlEventType x0%x", eventType); + break; + } +} + +// Internal operations +Scene* +_SceneManagerImpl::GetScene(SceneId& sceneId) +{ + return GetSceneFromContainer(sceneId); +} + +IListT* +_SceneManagerImpl::GetLiveSceneN(void) const +{ + std::unique_ptr > pSceneList(new (std::nothrow) ArrayListT); + SysTryReturn(NID_UI_SCENES, pSceneList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); + + std::unique_ptr > pMapEnum(__sceneContainer.GetMapEnumeratorN()); + SysTryReturn(NID_UI_SCENES, pMapEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + Scene* pScene = null; + pMapEnum->GetValue(pScene); + pSceneList->Add(pScene); + } + return pSceneList.release(); +} + +// Private method +result +_SceneManagerImpl::GotoScene(bool forward, const SceneId& sceneId, SceneTransitionAnimationType animationType, + SceneHistoryOption historyOption, SceneDestroyOption destroyOption, const IList* pArgs) +{ + // 1. Initialize for Scene transition. + result r = E_SUCCESS; + bool sceneAlreadyCreated = false; + bool formAlreadyCreated = false; + bool panelAlreadyCreated = false; + bool doAnimation = false; + bool formTransition = false; + Scene* pScene = null; + Form* pForm = null; + Panel* pPanel = null; + SceneId previousSceneId = __currentSceneId; // Save for later + String previousFormId = (__pCurrentScene) ? __pCurrentScene->GetFormId() : L""; + bool previousIsPanelScene = (__pCurrentScene) ? (__pCurrentScene->GetPanel()) : false; + Frame* pFrame = null; + FrameAnimator* pFrameAnimator = null; + // Exception handling hintings + bool onExceptionDeletepScene = false; + bool onExceptionRemovesceneIdFromSceneContainer = false; + bool onExceptionDeletepForm = false; + bool onExceptionRemoveFormIdFromFormContainer = false; + bool onExceptionRemovepPanel = false; + + // Prevent self forward + SysTryCatch(NID_UI_SCENES, __currentSceneId != sceneId, r = E_INVALID_ARG, E_INVALID_ARG, + "[%s] Invalid argument is used. Can't forward to current Scene.", GetErrorMessage(E_INVALID_ARG)); + CallListenerOnSceneTransitionStarted(__currentSceneId, sceneId); // Call listener - ISceneManagerEventListener's + if (__pCurrentScene) + { // Call listener - ISceneEventListener's + CallListenerOnSceneDeactivated(*__pCurrentScene, sceneId, __pCurrentScene->GetSceneId()); + } + + // 2. Find the Scene on SceneContainer - Scene and correspond UI control has same life time. + pScene = GetSceneFromContainer(sceneId); + if (pScene) // Activate pScene: Scene already existing then Re-activate associated a Form and a Panel. + { + sceneAlreadyCreated = true; + pForm = GetFormFromContainer(pScene->GetFormId()); + SysTryCatch(NID_UI_SCENES, pForm == pScene->GetForm(), r = E_SYSTEM, E_SYSTEM, + "[%s] A system error has been occurred. FormId mismatch with associated From instance.", + GetErrorMessage(E_SYSTEM)); + formAlreadyCreated = true; + pPanel = pScene->GetPanel(); + if (pPanel) + { + panelAlreadyCreated = true; + } + } + else + { // 3. Scene not found- Create new Scene + _SceneDescription* pSceneValue = null; + __sceneMap.GetValue(sceneId, pSceneValue); + SysTryCatch(NID_UI_SCENES, pSceneValue != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, + "[%s] The given sceneId was not found in the registered scenes.", GetErrorMessage(E_OBJ_NOT_FOUND)); + // 4. Setup the new Scene + pScene = _SceneImpl::CreateSceneN(sceneId, pSceneValue->formId, pSceneValue->panelId); + SysTryCatch(NID_UI_SCENES, pScene != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + onExceptionDeletepScene = true; // On the CATCH [delete pScene] + _SceneImpl* pSceneImpl = _SceneImpl::GetInstance(*pScene); + SysTryCatch(NID_UI_SCENES, pSceneImpl != null, r = E_SYSTEM, E_SYSTEM, + "[%s] A system error has been occurred. pSceneImpl not valid", GetErrorMessage(E_SYSTEM)); + // 5. Register Scene + AddSceneToContainer(sceneId, pScene); + onExceptionRemovesceneIdFromSceneContainer = true; // On the CATCH [remove 'sceneId' from SceneContainer] + // 6. Find the Form on FormContainer + pForm = GetFormFromContainer(pScene->GetFormId()); + if (pForm) // Form existing: just call SetCurrentForm + { // If the Scene is panel scene then add new panel to pForm or change showState. + formAlreadyCreated = true; + pSceneImpl->SetForm(pForm); // Panel Scene share same Form intance + } + else// 7. Form not found- Create new Form + { // 8. Get the new Form from the FormFactory + SysTryCatch(NID_UI_SCENES, __pFormFactory != null, r = E_INVALID_STATE, E_INVALID_STATE, + "[%s] SceneManager is in an invalid state. Form factory is not registered.", + GetErrorMessage(E_INVALID_STATE)); + String formId(pScene->GetFormId()); + pForm = __pFormFactory->CreateFormN(formId, sceneId); // On the CATCH [delete pForm] + SysTryCatch(NID_UI_SCENES, pForm != null, r = E_SYSTEM, E_SYSTEM, + "[%s] A system error has been occurred. Form(Id=%ls) creation failed on form factroy.", + GetErrorMessage(E_SYSTEM), formId.GetPointer()); + onExceptionDeletepForm = true; // On the CATCH [remove pForm from FormContainer] + // 9. Register Form + AddFormToContainer(pScene->GetFormId(), pForm); + pSceneImpl->SetForm(pForm); + onExceptionRemoveFormIdFromFormContainer = true; + } + // 10. Create panel for Panel Scene + // * One Panel instance for each Panel-Scene so no need to check duplicated panel instance for same panel Id. + if (!pScene->GetPanelId().IsEmpty()) + { + String panelId(pScene->GetPanelId()); + // First of all, get the Panel from the based Form. + // Because, base Form loaded from the resources, the child Panel also loaded and created. + // So, do not create a new Panel instance but get from base Form with panelId as resouce Id. + pPanel = dynamic_cast(pForm->GetControl(panelId)); + if (pPanel) + { + pSceneImpl->SetPanelCreatedFromFormResource(true); // Prevent RemoveControl - It's not creatable via Panel factory. + } + else + { + SysTryCatch(NID_UI_SCENES, __pPanelFactory != null, r = E_INVALID_STATE, E_INVALID_STATE, + "[%s] SceneManager is in an invalid state. Panel factory is not registered.", + GetErrorMessage(E_INVALID_STATE)); + pPanel = __pPanelFactory->CreatePanelN(panelId, sceneId); // On the CATCH [delete pPanel] + SysTryCatch(NID_UI_SCENES, pPanel != null, r = E_SYSTEM, E_SYSTEM, + "[%s] A system error has been occurred. Panel(Id=%ls) creation failed on PanelFactory.", + GetErrorMessage(E_SYSTEM), panelId.GetPointer()); + onExceptionRemovepPanel = true; // On the CATCH [remove pPanel from __formToPanelMultiMap] + } + AddPanelToPanelContainer(pScene); + pSceneImpl->SetPanel(pPanel); + } + } + + // For animation logic should be divide Animator section and normal section for proper operations. + // If (showAnimation && forwardAnimation is Not NONE) then doing animator related logic / + // Setup default animation setting / Add listener to get animation stop/finishing + formTransition = (previousFormId != pScene->GetFormId()) ? true : false; + doAnimation = (animationType > SCENE_TRANSITION_ANIMATION_TYPE_NONE) ? true : false; + if (doAnimation && (animationType != SCENE_TRANSITION_ANIMATION_TYPE_CUSTOM && !formTransition)) + { + doAnimation = false; + } + if (doAnimation && (GetCurrentForm() == null)) + { + doAnimation = false; + } + + if (doAnimation) + { + // Initialize Frame animator + pFrame = GetFrame(); + SysTryCatch(NID_UI_SCENES, pFrame != null, r = E_SYSTEM, E_SYSTEM, + "[%s] A system error has been occurred. Cannot get Frame.", GetErrorMessage(E_SYSTEM)); + pFrameAnimator = pFrame->GetFrameAnimator(); + SysTryCatch(NID_UI_SCENES, pFrameAnimator != null, r = E_SYSTEM, E_SYSTEM, + "[%s] A system error has been occurred. Cannot get FrameAnimator.", GetErrorMessage(E_SYSTEM)); + pFrameAnimator->StopAllAnimations(); + + // Initialize Control animator if needed. + if (!formTransition && pPanel) + { + ControlAnimator* pControlAnimator = pPanel->GetControlAnimator(); + SysTryCatch(NID_UI_SCENES, pControlAnimator != null, r = E_SYSTEM, E_SYSTEM, + "[%s] A system error has been occurred. Cannot get ControlAnimator.", GetErrorMessage(E_SYSTEM)); + pControlAnimator->StopAllAnimations(); + } + + // Set default value for formTransition + if (formTransition && (animationType >= SCENE_TRANSITION_ANIMATION_TYPE_LEFT) && + (pFrameAnimator->GetStatus() == ANIMATOR_STATUS_STOPPED)) + { + pFrameAnimator->SetFormTransitionAnimation( + __animationDescriptions[animationType-SCENE_TRANSITION_ANIMATION_TYPE_LEFT].animationType, + __animationDescriptions[animationType-SCENE_TRANSITION_ANIMATION_TYPE_LEFT].duration, + __animationDescriptions[animationType-SCENE_TRANSITION_ANIMATION_TYPE_LEFT].interpolatorType); + } + } + + // Prepare animation for customization. + CallListenerPrepareAnimation(*pScene, sceneId, const_cast(pArgs), animationType, formTransition ); + // Setup Ui controls to show the result. + if (sceneAlreadyCreated) + { + if (formTransition) + { + if (pPanel) + { + SwitchToPanel(pScene->GetFormId(), pPanel); + } + r = SetCurrentForm(*pForm, doAnimation); // FrameAnimator + SysTryCatch(NID_UI_SCENES, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = SetCurrentForm(*pForm); + SysTryCatch(NID_UI_SCENES, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + if (pPanel) + { + SwitchToPanel(pScene->GetFormId(), pPanel, doAnimation); // ControlAnimator + } + } + } + else // Scene newly created + { + if (formAlreadyCreated) // Panel scene created but base form already created - reuse base form. + { + if (formTransition) + { + if (pPanel) + { + if (!panelAlreadyCreated) // If a new panel created then Add Panel to Form + { + AddControlToForm(*pForm, *pPanel); + } + SwitchToPanel(pScene->GetFormId(), pPanel); + } + r = SetCurrentForm(*pForm, (doAnimation)); // FrameAnimator + SysTryCatch(NID_UI_SCENES, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + else + { + r = SetCurrentForm(*pForm); + SysTryCatch(NID_UI_SCENES, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + if (pPanel) + { + if (!panelAlreadyCreated) + { + AddControlToForm(*pForm, *pPanel); + } + SwitchToPanel(pScene->GetFormId(), pPanel, doAnimation); // ControlAnimator + } + } + } + else // New Form created! + { + if (pPanel) + { + // New panel + AddControlToForm(*pForm, *pPanel); + SwitchToPanel(pScene->GetFormId(), pPanel); + } + AddControlToFrame(*pForm, doAnimation); // Form add to frame + if (!doAnimation) + { + SetCurrentForm(*pForm); + } + } + } + + UpdateCurrentScene(pScene); + if ((historyOption == SCENE_HISTORY_OPTION_ADD_HISTORY) && (!previousSceneId.IsEmpty())) + { + r = AddHistory(previousSceneId); + // Too late revert to previous scene, so just return the error code but not revert to previous state. + SysTryLog(NID_UI_SCENES, !IsFailed(r), "[%s] History adding failed.", GetErrorMessage(r)); + } + + CallListenerOnSceneActivatedN(*pScene, previousSceneId, sceneId, const_cast(pArgs)); + CallListenerOnSceneTransitionCompleted(previousSceneId, __currentSceneId); + + if (destroyOption == SCENE_DESTROY_OPTION_DESTROY ) + { + if (previousIsPanelScene) + { + DestroySiblingPanelScene(previousSceneId); // Destroy sibling Panel Scene + } + if (doAnimation) + { + ReserveDestroyingScene(previousSceneId); // Destroy the Scene after animator finished(stopped). + } + else + { + DestroySceneAsync(previousSceneId); + } + } + + DrawForm(*pScene->GetForm()); + + return r; + +CATCH: + // Check all exception case for proper delete the instances: Scene, Form, Panel and item corresponding container. + if (onExceptionRemovepPanel) + { + RemovePanelFromPanelContainer(pScene); + delete pPanel; // Also needed it. + pPanel = null; + } + if (onExceptionRemoveFormIdFromFormContainer) + { + RemoveFormFromFormContainer(pScene->GetFormId()); + } + if (onExceptionDeletepForm) + { + delete pForm; + pForm = null; + } + if (onExceptionRemovesceneIdFromSceneContainer) + { + RemoveSceneFromContainer(sceneId); + } + if (onExceptionDeletepScene) + { + delete pScene; + pScene = null; + } + return r; +} + +Scene* +_SceneManagerImpl::GetSceneFromContainer(const SceneId& sceneId) const +{ + Scene* pScene = null; + __sceneContainer.GetValue(sceneId, pScene); + return pScene; +} + +Form* +_SceneManagerImpl::GetFormFromContainer(const String& formId) +{ + Form* pForm = null; + __formContainer.GetValue(formId, pForm); + return pForm; +} + +void +_SceneManagerImpl::AddSceneToContainer(const SceneId& sceneId, Scene* pScene) +{ + __sceneContainer.Add(sceneId, pScene); +} + +void +_SceneManagerImpl::RemoveSceneFromContainer(const SceneId& sceneId) +{ + __sceneContainer.Remove(sceneId); +} + +void +_SceneManagerImpl::AddFormToContainer(const String& formId, Form* pForm) +{ + __formContainer.Add(formId, pForm); +} + +void +_SceneManagerImpl::RemoveFormFromFormContainer(const String& formId) +{ + __formContainer.Remove(formId); +} + +void +_SceneManagerImpl::AddPanelToPanelContainer(Scene* pScene) +{ + __formToPanelMultiMap.Add(pScene->GetFormId(), pScene); +} + +void +_SceneManagerImpl::RemovePanelFromPanelContainer(Scene* pScene) +{ + __formToPanelMultiMap.Remove(pScene->GetFormId(), pScene); +} + +void +_SceneManagerImpl::UpdateCurrentScene(Scene* pScene) +{ + __pCurrentScene = pScene; + __currentSceneId = pScene->GetSceneId(); +} + +result +_SceneManagerImpl::AddHistory(const SceneId& sceneId) +{ + return __sceneHistory.Add(sceneId); +} + +void +_SceneManagerImpl::SwitchToPanel(const String& formId, Panel* pPanel, bool useAnimator) +{ + Panel* pShowPanel = null; + + std::unique_ptr > pSceneEnum(__formToPanelMultiMap.GetValuesN(formId)); + SysTryReturnVoidResult(NID_UI_SCENES, pSceneEnum != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); + while (pSceneEnum->MoveNext() == E_SUCCESS) + { + Scene* pCurrentScene = null; + pSceneEnum->GetCurrent(pCurrentScene); + SysTryReturnVoidResult(NID_UI_SCENES, pCurrentScene != null, E_SYSTEM, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); + if (pCurrentScene->GetPanel() != pPanel) + { + if (pCurrentScene->GetPanel()->GetShowState()) + { + pShowPanel = pCurrentScene->GetPanel(); + } + } + } + + if (useAnimator && pShowPanel && pPanel) + { + int transactionId = 0; + AnimationTransaction::Begin(transactionId); + } + + if (pShowPanel) + { + if (useAnimator) + { + ControlAnimator* pControlAnimator = pShowPanel->GetControlAnimator(); + if (pControlAnimator) + { + pControlAnimator->AddControlAnimatorEventListener(*this); + pControlAnimator->SetShowState(false); + } + } + else + { + pShowPanel->SetShowState(false); + } + } + if (pPanel) + { + if (useAnimator) + { + ControlAnimator* pControlAnimator = pPanel->GetControlAnimator(); + if (pControlAnimator) + { + pControlAnimator->SetShowState(true); + } + } + else + { + pPanel->SetShowState(true); + } + } + + if (useAnimator && pShowPanel && pPanel) + { + result r = AnimationTransaction::Commit(); + if (r != E_SUCCESS) + { + SysLog(NID_UI_SCENES, "Animation Commit() failed"); + } + } +} + +void +_SceneManagerImpl::AddControlToFrame(Form& form, bool useAnimator) +{ + Frame* pFrame = GetFrame(); + if (pFrame) + { + if (useAnimator) + { + FrameAnimator* pFrameAnimator = pFrame->GetFrameAnimator(); + if (pFrameAnimator) + { + // Add animator listener to asynchronous scene destroy for safe deletion. + pFrameAnimator->AddFrameAnimatorEventListener(*this); + _FrameAnimatorImpl* pFrameAnimatorImpl = _FrameAnimatorImpl::GetInstance(*pFrameAnimator); + if (pFrameAnimatorImpl) + { + pFrameAnimatorImpl->AddControl(form); + return; + } + } + SysLog(NID_UI_SCENES, "pFrameAnimator or pFrameAnimatorImpl is not valid."); + } + pFrame->AddControl(form); + } +} + +void +_SceneManagerImpl::RemoveControlFromFrame(Form& form) +{ + Frame* pFrame = GetFrame(); + if (pFrame) + { + // Control validation check for safe operation on termination(Ui destroy before asynchronous scene destroy process). + _ControlManager* pControlManager = _ControlManager::GetInstance(); + if (pControlManager) + { + _Control* pControl = pControlManager->GetObject(__correspondFrameControlHandle); + if (pControl) + { + pFrame->RemoveControl(form); + return; + } + else + { + SysLog(NID_UI_SCENES, "FrameWindow already destroyed. Skip remove control to form."); + } + } + else + { + SysLog(NID_UI_SCENES, "Window system already shutdown."); + } + } +} + +result +_SceneManagerImpl::SetCurrentForm(Form& form, bool useAnimator) +{ + result r = E_SUCCESS; + Frame* pFrame = GetFrame(); + + SysTryReturnResult(NID_UI_SCENES, pFrame != null, E_SYSTEM, + "A system error has been occurred. Can not get the Frame window."); + if (useAnimator) + { + FrameAnimator* pFrameAnimator = pFrame->GetFrameAnimator(); + if (pFrameAnimator) + { + // Add animator listener to asynchronous scene destroy for safe deletion. + pFrameAnimator->AddFrameAnimatorEventListener(*this); + r = pFrameAnimator->SetCurrentForm(form); + if (r != E_SYSTEM) + { + return E_SUCCESS; + } + } + SysLog(NID_UI_SCENES, "Safety operation ongoing. Animation may not working, Please check the problems!"); + } + + r = pFrame->SetCurrentForm(form); + SysTryReturnResult(NID_UI_SCENES, !IsFailed(r), E_SYSTEM, "A system error has been occurred. Can not set current form."); + return E_SUCCESS; +} + +Form* +_SceneManagerImpl::GetCurrentForm(void) +{ + Frame* pFrame = GetFrame(); + if (pFrame) + { + return pFrame->GetCurrentForm(); + } + return null; +} + +void +_SceneManagerImpl::AddControlToForm(Form& baseForm, const Panel& panel) +{ + baseForm.AddControl(panel); +} + +void +_SceneManagerImpl::RemoveControlFromForm(Form& baseForm, const Panel& panel) +{ + baseForm.RemoveControl(panel); +} + +void +_SceneManagerImpl::SetShowState(Panel& targetPanel, bool state) +{ + targetPanel.SetShowState(state); +} + +void +_SceneManagerImpl::DrawForm(Form& form) +{ + form.Invalidate(true); +} + +bool +_SceneManagerImpl::CallListenerOnSceneTransitionStarted(const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + std::unique_ptr > pEnum(__sceneManagerEventListenerList.GetEnumeratorN()); + if (!pEnum) + { + return false; + } + + while (pEnum->MoveNext() == E_SUCCESS) + { + ISceneManagerEventListener* pListener = null; + pEnum->GetCurrent(pListener); + if (pListener) + { + pListener->OnSceneTransitionStarted(currentSceneId, nextSceneId); + } + } + return true; +} + +bool +_SceneManagerImpl::CallListenerOnSceneTransitionCompleted(const SceneId& previousSceneId, const SceneId& currentSceneId) +{ + std::unique_ptr > pEnum(__sceneManagerEventListenerList.GetEnumeratorN()); + if (!pEnum) + { + return false; + } + + while (pEnum->MoveNext() == E_SUCCESS) + { + ISceneManagerEventListener* pListener = null; + pEnum->GetCurrent(pListener); + if (pListener) + { + pListener->OnSceneTransitionCompleted(previousSceneId, currentSceneId); + } + } + return true; +} + +bool +_SceneManagerImpl::CallListenerPrepareAnimation(Scene& scene, const SceneId& sceneId, IList* pArgs, + SceneTransitionAnimationType type, bool formTransition) +{ + _SceneImpl* pSceneImpl = _SceneImpl::GetInstance(scene); + SysTryReturn(NID_UI_SCENES, pSceneImpl, false, E_INVALID_STATE, + "[%s] SceneManager is in an invalid state. scene is not valid.", + GetErrorMessage(E_INVALID_STATE)); + + return pSceneImpl->PrepareAnimation(sceneId, pArgs, type, formTransition); +} + +bool +_SceneManagerImpl::CallListenerOnSceneActivatedN(Scene& scene, const SceneId& previousSceneId, const SceneId& currentSceneId, + IList* pArgs) +{ + _SceneImpl* pSceneImpl = _SceneImpl::GetInstance(scene); + SysTryReturn(NID_UI_SCENES, pSceneImpl, false, E_INVALID_STATE, + "[%s] SceneManager is in an invalid state. scene is not valid.", + GetErrorMessage(E_INVALID_STATE)); + + return pSceneImpl->OnSceneActivatedN(previousSceneId, currentSceneId, pArgs); +} + +bool +_SceneManagerImpl::CallListenerOnSceneDeactivated(Scene& scene, const SceneId& currentSceneId, const SceneId& nextSceneId) +{ + _SceneImpl* pSceneImpl = _SceneImpl::GetInstance(scene); + SysTryReturn(NID_UI_SCENES, pSceneImpl, false, E_INVALID_STATE, + "[%s] SceneManager is in an invalid state. scene is not valid.", + GetErrorMessage(E_INVALID_STATE)); + + return pSceneImpl->OnSceneDeactivated(currentSceneId, nextSceneId); +} + +SceneId +_SceneManagerImpl::CallStretegyGetNextScene(const SceneId& currentSceneId, const IList* pArgs) +{ + SceneId nextScene(L""); + if (__pPolicyProvider) + { + nextScene = __pPolicyProvider->GetNextScene(currentSceneId, pArgs); + } + return nextScene; +} + +void +_SceneManagerImpl::DestroySceneAsync(const SceneId& sceneId) +{ + _SceneControlEventArg* pArg = new (std::nothrow) _SceneControlEventArg( + _SceneControlEventArg::SCENE_CONTROL_EVENT_TYPE_DESTROY, sceneId); + SysTryReturnVoidResult(NID_UI_SCENES, pArg != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); + __sceneControlEvent.FireAsync(*pArg); +} + +void +_SceneManagerImpl::ReserveDestroyingScene(const SceneId& sceneId) +{ + if (!__destroyReservedScene.IsEmpty()) + { + SysLog(NID_UI_SCENES, "Previous reserved sceneId=%ls", __destroyReservedScene.GetPointer()); + } + __destroyReservedScene = sceneId; +} + +void +_SceneManagerImpl::DestroyReservedScene(void) +{ + if (!__destroyReservedScene.IsEmpty()) + { + DestroySceneAsync(__destroyReservedScene); + __destroyReservedScene.Clear(); + } +} + +void +_SceneManagerImpl::DestroySiblingPanelScene(const SceneId& sceneId) +{ + Scene* pScene = null; + pScene = GetSceneFromContainer(sceneId); + SysTryReturnVoidResult(NID_UI_SCENES, pScene != null, E_OBJ_NOT_FOUND, "[%s] Specified sceneId does not exist.", + GetErrorMessage(E_OBJ_NOT_FOUND)); + + Panel* pPanel = pScene->GetPanel(); + if (pPanel) + { + int panelCount = 0; + result r = __formToPanelMultiMap.GetCount(pScene->GetFormId(), panelCount); + SysTryReturnVoidResult(NID_UI_SCENES, !IsFailed(r), E_SYSTEM, + "[%s] A system error has been occurred. Form(SceneId:%ls) not valid.", + GetErrorMessage(E_SYSTEM), sceneId.GetPointer()); + if (panelCount <= 1) + { + return; + } + + ArrayListT destroyList; + std::unique_ptr > pSceneEnum(__formToPanelMultiMap.GetValuesN(pScene->GetFormId())); + SysTryReturnVoidResult(NID_UI_SCENES, pSceneEnum != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", + GetErrorMessage(E_OUT_OF_MEMORY)); + while (pSceneEnum->MoveNext() == E_SUCCESS) + { + Scene* pCurrentScene = null; + pSceneEnum->GetCurrent(pCurrentScene); + SysTryReturnVoidResult(NID_UI_SCENES, pCurrentScene != null, E_SYSTEM, + "[%s] A system error has been occurred. Current scene is not valid.", + GetErrorMessage(E_SYSTEM)); + if (pCurrentScene->GetPanel() != pPanel) + { + destroyList.Add(pCurrentScene); // DestroyScene modify __formToPanelMultiMap so can't destroy here. + } + } + + for (int i = 0; i < destroyList.GetCount(); i++) + { + Scene* pCurrentScene = null; + destroyList.GetAt(i, pCurrentScene); + if (pCurrentScene) + { + DestroyScene(pCurrentScene->GetSceneId()); + } + } + } +} + +Frame* +_SceneManagerImpl::GetFrame(void) +{ + if (__pCorrespondFrame == null) + { + SysLog(NID_UI_SCENES, "WARNING! - Initialize error!. First GetInstance must call after set a FrameWindow."); + UiApp* pUiApp = UiApp::GetInstance(); + SysTryReturn(NID_UI_SCENES, pUiApp != null, null, E_SYSTEM, + "[%s] A system error has been occurred. UiApp::GetInstance failed.", GetErrorMessage(E_SYSTEM)); + Frame* pFrame = pUiApp->GetFrameAt(0); + SysTryReturn(NID_UI_SCENES, pFrame != null, null, E_SYSTEM, + "[%s] A system error has been occurred. pUiApp->GetFrameAt(0) return null.", GetErrorMessage(E_SYSTEM)); + __pCorrespondFrame = pFrame; + _ContainerImpl* pFrameWindowImpl = _ContainerImpl::GetInstance(*__pCorrespondFrame); + if (pFrameWindowImpl) + { + __correspondFrameControlHandle = pFrameWindowImpl->GetCore().GetHandle(); + } + } + return __pCorrespondFrame; +} + +bool +_SceneManagerImpl::IsAnimationCompleted(void) +{ + Frame* pFrame = GetFrame(); + SysTryReturn(NID_UI_SCENES, pFrame != null, false, E_SYSTEM, "[%s] A system error has been occurred. Cannot get Frame.", + GetErrorMessage(E_SYSTEM)); + FrameAnimator* pFrameAnimator = pFrame->GetFrameAnimator(); + + if (pFrameAnimator) + { + bool completed = (pFrameAnimator->GetStatus() == ANIMATOR_STATUS_STOPPED) ? true : false; + return completed; + } + return true; +} + +result +_SceneManagerImpl::GetSceneTransition(const SceneTransitionId& transitionId, SceneTransition& sceneTransition) const +{ + result r = E_SUCCESS; + SysTryReturnResult(NID_UI_SCENES, !transitionId.IsEmpty(), E_INVALID_ARG, + "Invalid argument is used. The transitionId is empty."); + + SceneTransition* pSceneTransition = null; + r = __transitionMap.GetValue(transitionId, pSceneTransition); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + sceneTransition = *pSceneTransition; + + return r; +} + +result +_SceneManagerImpl::RegisterScene(xmlNodePtr pNode) +{ + static const char* pPropId = "Id"; + static const char* pPropFormId = "Form"; + static const char* pPropPanelId = "Panel"; + result r = E_SUCCESS; + _SceneDescription* pSceneDescription = null; + + SysTryReturn(NID_UI_SCENES, pNode != null, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. pNode is null.", + GetErrorMessage(E_INVALID_ARG)); + + xmlChar* pSceneId = xmlGetProp(pNode, reinterpret_cast(pPropId)); + if (pSceneId) + { + String strSceneId(reinterpret_cast(pSceneId)); + xmlFree(pSceneId); + + xmlChar* pFormId = xmlGetProp(pNode, reinterpret_cast(pPropFormId)); + if (pFormId) + { + String strFormId(reinterpret_cast(pFormId)); + xmlFree(pFormId); + + String strPanelId; + xmlChar* pPanelId = xmlGetProp(pNode, reinterpret_cast(pPropPanelId)); + if (pPanelId) + { + strPanelId = reinterpret_cast(pPanelId); + xmlFree(pPanelId); + } + + // Register a Scene item + bool isContains = false; + r = __sceneMap.ContainsKey(strSceneId, isContains); + SysTryReturn(NID_UI_SCENES, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryReturnResult(NID_UI_SCENES, !isContains, E_OBJ_ALREADY_EXIST, "Specified sceneId already exist."); + + pSceneDescription = new (std::nothrow) _SceneDescription(strFormId, strPanelId); + SysTryReturnResult(NID_UI_SCENES, pSceneDescription != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + + r = __sceneMap.Add(strSceneId, pSceneDescription); + SysTryCatch(NID_UI_SCENES, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + } + } + return r; + +CATCH: + delete pSceneDescription; + return r; +} + +result +_SceneManagerImpl::RegisterSceneTransition(xmlNodePtr pNode) +{ + static const xmlChar* pPropId = reinterpret_cast("Id"); + static const char* pPropDestinationSceneId = "TargetId"; + static const char* pPropDirectionType = "DirectionType"; + static const char* pPropAnimationType = "AnimationType"; + static const char* pPropHistoryOption = "HistoryOption"; + static const char* pPropDestroyOption = "DestroyOption"; + + static const String strValueDirectionForward(L"forward"); + static const String strValueDirectionBackward(L"backward"); + static const String strValueDirectionAdjacentBackward(L"adjacentBackward"); + static const String strValueAnimationType[] = {L"none", L"custom", L"left", L"right", L"fade_in_out", + L"zoom_in", L"zoom_out", L"depth_in", "depth_out"}; + static const String strValueHistoryOptionNoHistory(L"no"); + static const String strValueDestroyOptionKeep(L"keep"); + static const String strValueDestroyOptionDestroy(L"destroy"); + + static const SceneTransitionAnimationType valueAnimation[] = { + SCENE_TRANSITION_ANIMATION_TYPE_NONE, SCENE_TRANSITION_ANIMATION_TYPE_CUSTOM, + SCENE_TRANSITION_ANIMATION_TYPE_LEFT, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT, + SCENE_TRANSITION_ANIMATION_TYPE_FADE_IN_OUT, SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_IN, + SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_OUT, SCENE_TRANSITION_ANIMATION_TYPE_DEPTH_IN, + SCENE_TRANSITION_ANIMATION_TYPE_DEPTH_OUT }; + + SceneTransition* pSceneTransition = null; + result r = E_SUCCESS; + SysTryReturn(NID_UI_SCENES, pNode != null, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. pNode is null.", + GetErrorMessage(E_INVALID_ARG)); + + xmlChar* pTransitionId = xmlGetProp(pNode, pPropId); + if (pTransitionId) + { + String strTransitionId(reinterpret_cast(pTransitionId)); + xmlFree(pTransitionId); + if (strTransitionId.GetLength() > 0) + { + xmlChar* pDirectionType = xmlGetProp(pNode, reinterpret_cast(pPropDirectionType)); + if (pDirectionType) + { + String strDirectionType(reinterpret_cast(pDirectionType)); + xmlFree(pDirectionType); + + // Mandatory item: transitionId, direction + // forward: destinationSceneId(mandatory), animationType, historyOption, destroyOption + // backward: destinationSceneId(mandatory), animationType, destroyOption [ Don't care: historyOption ] + // adjacentBackward: animationType, destroyOption [ Don't care: destinationSceneId, historyOption] + String strDestinationSceneId; + String strAnimationType; + String strHistoryOption; + String strDestroyOption; + SceneTransitionAnimationType animationType = SCENE_TRANSITION_ANIMATION_TYPE_NONE; + + // Get animationType and destroyOption (common property) + xmlChar* pAnimationType = xmlGetProp(pNode, reinterpret_cast(pPropAnimationType)); + if (pAnimationType) + { + strAnimationType = reinterpret_cast(pAnimationType); + xmlFree(pAnimationType); + if (strAnimationType.GetLength() > 0) + { + for (unsigned int i = 0; i < sizeof(valueAnimation)/sizeof(valueAnimation[0]); i++) + { // Consider to use map collection. + if (strAnimationType == strValueAnimationType[i]) + { + animationType = valueAnimation[i]; + break; + } + } + } + } + + xmlChar* pDestroyOption = xmlGetProp(pNode, reinterpret_cast(pPropDestroyOption)); + if (pDestroyOption) + { + strDestroyOption = reinterpret_cast(pDestroyOption); + xmlFree(pDestroyOption); + } + + // Compose SceneTransition + if (strDirectionType == strValueDirectionAdjacentBackward) // Adjacent backward + { + SceneDestroyOption destroyOption = SCENE_DESTROY_OPTION_DESTROY; // Default is destroy + if ((strDestroyOption.GetLength() > 0) && (strDestroyOption == strValueDestroyOptionKeep)) + { + destroyOption = SCENE_DESTROY_OPTION_KEEP; + } + + pSceneTransition = new (std::nothrow) BackwardSceneTransition(animationType, destroyOption); + SysTryReturnResult(NID_UI_SCENES, pSceneTransition != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + r = __transitionMap.Add(strTransitionId, pSceneTransition); + SysTryCatch(NID_UI_SCENES, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + + // Get destinationSceneId + xmlChar* pDestinationSceneId = xmlGetProp(pNode, reinterpret_cast(pPropDestinationSceneId)); + if (pDestinationSceneId) + { + strDestinationSceneId = reinterpret_cast(pDestinationSceneId); + xmlFree(pDestinationSceneId); + } + SysTryReturn(NID_UI_SCENES, strDestinationSceneId.GetLength() > 0, E_INVALID_ARG, E_INVALID_ARG, + "[%s] Invalid argument is used. strDestinationSceneId is empty.", GetErrorMessage(E_INVALID_ARG)); + + if (strDirectionType == strValueDirectionBackward) // Backward + { + SceneDestroyOption destroyOption = SCENE_DESTROY_OPTION_DESTROY; // Default is destroy + if ((strDestroyOption.GetLength() > 0) && (strDestroyOption == strValueDestroyOptionKeep)) + { + destroyOption = SCENE_DESTROY_OPTION_KEEP; + } + + pSceneTransition = + new (std::nothrow) BackwardSceneTransition(strDestinationSceneId, animationType, destroyOption); + SysTryReturnResult(NID_UI_SCENES, pSceneTransition != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + r = __transitionMap.Add(strTransitionId, pSceneTransition); + SysTryCatch(NID_UI_SCENES, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + + if (strDirectionType == strValueDirectionForward) // Forward + { + SceneDestroyOption destroyOption = SCENE_DESTROY_OPTION_KEEP; // Default is keep + if ((strDestroyOption.GetLength() > 0) && (strDestroyOption == strValueDestroyOptionDestroy)) + { + destroyOption = SCENE_DESTROY_OPTION_DESTROY; + } + + xmlChar* pHistoryOption = xmlGetProp(pNode, reinterpret_cast(pPropHistoryOption)); + if (pHistoryOption) + { + strHistoryOption = reinterpret_cast(pHistoryOption); + xmlFree(pHistoryOption); + } + SceneHistoryOption historyOption = SCENE_HISTORY_OPTION_ADD_HISTORY; // Default is add to history + if ((strHistoryOption.GetLength() > 0) && (strHistoryOption == strValueHistoryOptionNoHistory)) + { + historyOption = SCENE_HISTORY_OPTION_NO_HISTORY; + } + + pSceneTransition = new (std::nothrow) ForwardSceneTransition(strDestinationSceneId, animationType, + historyOption, destroyOption); + SysTryReturnResult(NID_UI_SCENES, pSceneTransition != null, E_OUT_OF_MEMORY, "Memory allocation failed."); + r = __transitionMap.Add(strTransitionId, pSceneTransition); + SysTryCatch(NID_UI_SCENES, !IsFailed(r), , r, "[%s] Propagating.", GetErrorMessage(r)); + return r; + } + else + { + SysLog(NID_UI_SCENES, "Unknown direction type!"); + } + } + } + } + return r; + +CATCH: + delete pSceneTransition; + return r; +} + +} } } // Tizen::Ui::Scenes diff --git a/src/ui/scenes/FUiScenes_SceneManagerImpl.h b/src/ui/scenes/FUiScenes_SceneManagerImpl.h new file mode 100644 index 0000000..5425f6f --- /dev/null +++ b/src/ui/scenes/FUiScenes_SceneManagerImpl.h @@ -0,0 +1,211 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// +/** + * @file FUiScenes_SceneManagerImpl.h + * @brief This is the header file of the _SceneManagerImpl class. + * + * This header file contains the declarations of the _SceneManagerImpl class. + */ + +#ifndef _FUI_SCENES_INTERNAL_SCENE_MANAGER_IMPL_H_ +#define _FUI_SCENES_INTERNAL_SCENE_MANAGER_IMPL_H_ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUiScenes_ISceneControlEventListener.h" +#include "FUiScenes_SceneControlEvent.h" + + +namespace Tizen { namespace Ui { namespace Scenes +{ + +class SceneTransition; + +class _SceneManagerImpl + : public Tizen::Base::Object + , virtual public Tizen::Ui::Animations::IFrameAnimatorEventListener + , virtual public Tizen::Ui::Animations::IControlAnimatorEventListener + , virtual public _ISceneControlEventListener +{ +public: + _SceneManagerImpl(void); + virtual ~_SceneManagerImpl(void); + result Construct(void); + + result RegisterFormFactory(const IFormFactory& formFactory); + result RegisterPanelFactory(const IPanelFactory& panelFactory); + result RegisterScene(const SceneId& sceneId, const Tizen::Base::String& formId, const Tizen::Base::String& panelId); + result RegisterScene(const Tizen::Base::String& resourceId); + result UnregisterScene(const SceneId& sceneId); + result AddSceneManagerEventListener(ISceneManagerEventListener& sceneManagerEventListener); + result RemoveSceneManagerEventListener(ISceneManagerEventListener& sceneManagerEventListener); + result AddSceneEventListener(const SceneId& sceneId, ISceneEventListener& sceneEventListener); + result RemoveSceneEventListener(const SceneId& sceneId, ISceneEventListener& sceneEventListener); + result SetSceneAnimationProvider(const SceneId& sceneId, ISceneAnimationProvider* pSceneAnimationProvider); + result SetSceneTransitionPolicyProvider(ISceneTransitionPolicyProvider* pSceneTransitionPolicyProvider); + result SetFormTransitionAnimationDefaultValues(SceneTransitionAnimationType animationType, long duration, + Tizen::Ui::Animations::AnimationInterpolatorType interpolatorType); + result GoForward(const ForwardSceneTransition& sceneTransition, const Tizen::Base::Collection::IList* pArgs = null); + result GoForward(const SceneTransitionId& transitionId, const Tizen::Base::Collection::IList* pArgs = null); + result GoBackward(const BackwardSceneTransition& sceneTransition, const Tizen::Base::Collection::IList* pArgs = null); + result GoBackward(const SceneTransitionId& transitionId, const Tizen::Base::Collection::IList* pArgs = null); + Scene* GetCurrentScene(void) const; + SceneId GetCurrentSceneId(void) const; + bool IsSceneAlive(const SceneId& sceneId) const; + result DestroyScene(const SceneId& sceneId); + result BringCurrentSceneToTop(void); + result ClearSceneHistory(void); + result AddToSceneHistory(const SceneId& sceneId); + Tizen::Base::Collection::IListT* GetSceneHistoryN(void) const; + + // + // Gets the implementation. + // + // @return The implementation + // @param[in] The interface instance pointer + // @since 2.0 + // + static _SceneManagerImpl* GetInstance(SceneManager& pSceneManager); + + // + // Gets the implementation. + // + // @return The implementation + // @param[in] The interface instance pointer + // @since 2.0 + // + static const _SceneManagerImpl* GetInstance(const SceneManager& pSceneManager); + + // Event handelers to asynchronous destroy the Scene. + virtual void OnFormTransitionAnimationFinished(Tizen::Ui::Animations::FrameAnimator &source, Tizen::Ui::Controls::Frame &frame, + Tizen::Ui::Controls::Form &form1, Tizen::Ui::Controls::Form &form2); + virtual void OnFormTransitionAnimationStarted(Tizen::Ui::Animations::FrameAnimator &source, Tizen::Ui::Controls::Frame &frame, + Tizen::Ui::Controls::Form &form1, Tizen::Ui::Controls::Form &form2); + virtual void OnFormTransitionAnimationStopped(Tizen::Ui::Animations::FrameAnimator &source, Tizen::Ui::Controls::Frame &frame, + Tizen::Ui::Controls::Form &form1, Tizen::Ui::Controls::Form &form2); + virtual void OnControlAnimationFinished(Tizen::Ui::Animations::ControlAnimator &source, Tizen::Ui::Control &control); + virtual void OnControlAnimationStarted(Tizen::Ui::Animations::ControlAnimator &source, Tizen::Ui::Control &control); + virtual void OnControlAnimationStopped(Tizen::Ui::Animations::ControlAnimator &source, Tizen::Ui::Control &control); + virtual void OnSceneControlEventReceived(_SceneControlEventArg::SceneControlEventType eventType, const SceneId& sceneId); + + // Internal operations + Scene* GetScene(SceneId& sceneId); + Tizen::Base::Collection::IListT* GetLiveSceneN(void) const; + +private: + _SceneManagerImpl(const Scene& rhs); + _SceneManagerImpl& operator =(const Scene& rhs); + + result GotoScene(bool forward, const SceneId& sceneId, SceneTransitionAnimationType animationType, + SceneHistoryOption historyOption, SceneDestroyOption destroyOption, + const Tizen::Base::Collection::IList* pArgs); + // Container query set + Scene* GetSceneFromContainer(const SceneId& sceneId) const; + Tizen::Ui::Controls::Form* GetFormFromContainer(const Tizen::Base::String& formId); + // Add to container set + void AddSceneToContainer(const SceneId& sceneId, Scene* pScene); + void RemoveSceneFromContainer(const SceneId& sceneId); + void AddFormToContainer(const Tizen::Base::String& formId, Tizen::Ui::Controls::Form* pForm); + void RemoveFormFromFormContainer(const Tizen::Base::String& formId); + void AddPanelToPanelContainer(Scene* pScene); + void RemovePanelFromPanelContainer(Scene* pScene); + + void UpdateCurrentScene(Scene* pScene); + result AddHistory(const SceneId& sceneId); + + // Panel Scene transition assister + void SwitchToPanel(const Tizen::Base::String& formId, Tizen::Ui::Controls::Panel* pPanel, bool useAnimator = false); + + void AddControlToFrame(Tizen::Ui::Controls::Form& form, bool useAnimator = false); + void RemoveControlFromFrame(Tizen::Ui::Controls::Form& form); + result SetCurrentForm(Tizen::Ui::Controls::Form& form, bool useAnimator = false); + Tizen::Ui::Controls::Form* GetCurrentForm(void); + void AddControlToForm(Tizen::Ui::Controls::Form& baseForm, const Tizen::Ui::Controls::Panel& panel); + void RemoveControlFromForm(Tizen::Ui::Controls::Form& baseForm, const Tizen::Ui::Controls::Panel& panel); + void SetShowState(Tizen::Ui::Controls::Panel& targetPanel, bool state); + void DrawForm(Tizen::Ui::Controls::Form& form); + // Listener, Strategy - calling sub method. + bool CallListenerOnSceneTransitionStarted(const SceneId& currentSceneId, const SceneId& nextSceneId); + bool CallListenerOnSceneTransitionCompleted(const SceneId& previousSceneId, const SceneId& currentSceneId); + bool CallListenerPrepareAnimation(Tizen::Ui::Scenes::Scene& scene, const SceneId& sceneId, Tizen::Base::Collection::IList* pArgs, + SceneTransitionAnimationType type, bool formTransition); + bool CallListenerOnSceneActivatedN(Tizen::Ui::Scenes::Scene& scene, const SceneId& previousSceneId, + const SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs); + bool CallListenerOnSceneDeactivated(Tizen::Ui::Scenes::Scene& scene, const SceneId& currentSceneId, + const SceneId& nextSceneId); + SceneId CallStretegyGetNextScene(const SceneId& currentSceneId, const Tizen::Base::Collection::IList* pArgs); + void DestroySceneAsync(const SceneId& sceneId); + void ReserveDestroyingScene(const SceneId& sceneId); + void DestroyReservedScene(void); + void DestroySiblingPanelScene(const SceneId& sceneId); + Tizen::Ui::Controls::Frame* GetFrame(void); + bool IsAnimationCompleted(void); + result GetSceneTransition(const SceneTransitionId& transitionId, SceneTransition& sceneTransition) const; + result RegisterScene(xmlNodePtr pNode); + result RegisterSceneTransition(xmlNodePtr pNode); + +private: + SceneId __currentSceneId; + Scene* __pCurrentScene; + Tizen::Base::Collection::LinkedListT __sceneManagerEventListenerList; + Tizen::Base::Collection::HashMapT __sceneContainer; + Tizen::Base::Collection::HashMapT __formContainer; + Tizen::Base::Collection::MultiHashMapT __formToPanelMultiMap; + Tizen::Base::Collection::LinkedListT __sceneHistory; + + IFormFactory* __pFormFactory; + IPanelFactory* __pPanelFactory; + ISceneTransitionPolicyProvider* __pPolicyProvider; + + struct _AnimationDescription + { + Tizen::Ui::Animations::FrameAnimatorFormTransitionAnimation animationType; + long duration; + Tizen::Ui::Animations::AnimationInterpolatorType interpolatorType; + }; + _AnimationDescription __animationDescriptions[Tizen::Ui::Animations::FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_MAX]; + + class _SceneDescription + { + public: + _SceneDescription(const Tizen::Base::String& descriptionFormId, const Tizen::Base::String& descriptionPanelId); + const Tizen::Base::String formId; + const Tizen::Base::String panelId; + }; + Tizen::Base::Collection::HashMapT __sceneMap; + Tizen::Base::Collection::HashMapT __transitionMap; + + _SceneControlEvent __sceneControlEvent; + SceneId __destroyReservedScene; + Tizen::Ui::Controls::Frame* __pCorrespondFrame; + Tizen::Ui::_ControlHandle __correspondFrameControlHandle; + +}; // _SceneManagerImpl +} } } // Tizen::Ui::Scenes + +#endif // _FUI_SCENES_INTERNAL_SCENE_MANAGER_IMPL_H_ diff --git a/src/ui/scenes/FUiScenes_SceneTransitionImpl.cpp b/src/ui/scenes/FUiScenes_SceneTransitionImpl.cpp new file mode 100644 index 0000000..fa25447 --- /dev/null +++ b/src/ui/scenes/FUiScenes_SceneTransitionImpl.cpp @@ -0,0 +1,201 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +#include +#include +#include "FUiScenes_SceneTransitionImpl.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Ui { namespace Scenes +{ + +_SceneTransitionImpl::_SceneTransitionImpl(void) + : __direction(SCENE_TRANSITION_DIRECTION_FORWARD) + , __destinationSceneId("") + , __animationType(SCENE_TRANSITION_ANIMATION_TYPE_NONE) + , __historyOption(SCENE_HISTORY_OPTION_ADD_HISTORY) + , __destroyOption(SCENE_DESTROY_OPTION_KEEP) +{ + +} + +_SceneTransitionImpl::_SceneTransitionImpl(const _SceneTransitionImpl& rhs) + : __direction(rhs.__direction) + , __destinationSceneId(rhs.__destinationSceneId) + , __animationType(rhs.__animationType) + , __historyOption(rhs.__historyOption) + , __destroyOption(rhs.__destroyOption) +{ + +} + +_SceneTransitionImpl::_SceneTransitionImpl(SceneTransitionDirection direction, const SceneId& destinationSceneId, + SceneTransitionAnimationType animationType, + SceneHistoryOption historyOption, SceneDestroyOption destroyOption) + : __direction(direction) + , __destinationSceneId(destinationSceneId) + , __animationType(animationType) + , __historyOption(historyOption) + , __destroyOption(destroyOption) +{ + +} + +_SceneTransitionImpl +_SceneTransitionImpl::operator=(const _SceneTransitionImpl& rhs) +{ + if (this != &rhs) + { + __direction = rhs.__direction; + __destinationSceneId = rhs.__destinationSceneId; + __animationType = rhs.__animationType; + __historyOption = rhs.__historyOption; + __destroyOption = rhs.__destroyOption; + } + return *this; +} + +bool +_SceneTransitionImpl::Equals(const _SceneTransitionImpl& rhs) const +{ + return ((__direction == rhs.__direction) && + (__destinationSceneId == rhs.__destinationSceneId) && + (__animationType == rhs.__animationType) && + (__historyOption == rhs.__historyOption) && + (__destroyOption == rhs.__destroyOption)); +} + +int +_SceneTransitionImpl::GetHashCode(void) const +{ + String hashMaker; + Integer intValue; + + intValue = Integer(static_cast(__direction)); + hashMaker += intValue.ToString(); + + hashMaker += __destinationSceneId; + + intValue = Integer(static_cast(__animationType)); + hashMaker += intValue.ToString(); + + intValue = Integer(static_cast(__historyOption)); + hashMaker += intValue.ToString(); + + intValue = Integer(static_cast(__destroyOption)); + hashMaker += intValue.ToString(); + + return hashMaker.GetHashCode(); +} + +_SceneTransitionImpl::~_SceneTransitionImpl(void) +{ + // Nothing to do. +} + +result +_SceneTransitionImpl::SetDirection(SceneTransitionDirection direction) +{ + SysTryReturnResult(NID_UI_SCENES, + ((direction == SCENE_TRANSITION_DIRECTION_FORWARD) || (direction == SCENE_TRANSITION_DIRECTION_BACKWARD)), + E_INVALID_ARG, "Invalid argument is used."); + __direction = direction; + return E_SUCCESS; +} + +SceneTransitionDirection +_SceneTransitionImpl::GetDirection(void) const +{ + return __direction; +} + +result +_SceneTransitionImpl::SetDestinationSceneId(const SceneId& sceneId) +{ + SysTryReturnResult(NID_UI_SCENES, (sceneId.GetLength()>0), E_INVALID_ARG, "Invalid argument is used."); + __destinationSceneId = sceneId; + return E_SUCCESS; +} + +SceneId +_SceneTransitionImpl::GetDestinationSceneId(void) const +{ + return __destinationSceneId; +} + +result +_SceneTransitionImpl::SetAnimationType(SceneTransitionAnimationType animationType) +{ + SysTryReturnResult(NID_UI_SCENES, (SCENE_TRANSITION_ANIMATION_TYPE_LEFT <= animationType && + animationType <= SCENE_TRANSITION_ANIMATION_TYPE_DEPTH_OUT), + E_INVALID_ARG, "Invalid argument is used."); + __animationType = animationType; + return E_SUCCESS; +} + +SceneTransitionAnimationType +_SceneTransitionImpl::GetAnimationType(void) const +{ + return __animationType; +} + +result +_SceneTransitionImpl::SetHistoryOption(SceneHistoryOption historyOption) +{ + SysTryReturnResult(NID_UI_SCENES, + ((historyOption == SCENE_HISTORY_OPTION_ADD_HISTORY) || (historyOption == SCENE_HISTORY_OPTION_NO_HISTORY)), + E_INVALID_ARG, "Invalid argument is used."); + __historyOption = historyOption; + return E_SUCCESS; +} + +SceneHistoryOption +_SceneTransitionImpl::GetHistoryOption(void) const +{ + return __historyOption; +} + +result +_SceneTransitionImpl::SetDestroyOption(SceneDestroyOption destroyOption) +{ + SysTryReturnResult(NID_UI_SCENES, + ((destroyOption == SCENE_DESTROY_OPTION_KEEP) || (destroyOption == SCENE_DESTROY_OPTION_DESTROY)), + E_INVALID_ARG, "Invalid argument is used."); + __destroyOption = destroyOption; + return E_SUCCESS; +} + +SceneDestroyOption +_SceneTransitionImpl::GetDestroyOption(void) const +{ + return __destroyOption; +} + +_SceneTransitionImpl* +_SceneTransitionImpl::GetInstance(SceneTransition& scene) +{ + return scene.__pSceneTransitionImpl; +} + +const _SceneTransitionImpl* +_SceneTransitionImpl::GetInstance(const SceneTransition& scene) +{ + return scene.__pSceneTransitionImpl; +} + +} } } // Tizen::Ui::Scenes diff --git a/src/ui/scenes/FUiScenes_SceneTransitionImpl.h b/src/ui/scenes/FUiScenes_SceneTransitionImpl.h new file mode 100644 index 0000000..01ca68e --- /dev/null +++ b/src/ui/scenes/FUiScenes_SceneTransitionImpl.h @@ -0,0 +1,88 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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://floralicense.org/license/ +// +// 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. +// + +/** + * @file FUiScenes_SceneTransitionImpl.h + * @brief This is the header file of the _SceneTransitionImpl class. + * + * This header file contains the declarations of the _SceneTransitionImpl class. + */ + + +#ifndef _FUI_SCENES_INTERNAL_SCENE_TRANSITION_IMPL_H_ +#define _FUI_SCENES_INTERNAL_SCENE_TRANSITION_IMPL_H_ + +#include + +namespace Tizen { namespace Ui { namespace Scenes +{ + +class _SceneTransitionImpl + : public Tizen::Base::Object +{ + +public: + _SceneTransitionImpl(void); + _SceneTransitionImpl(const _SceneTransitionImpl& rhs); + _SceneTransitionImpl(SceneTransitionDirection direction, const SceneId& destinationSceneId, + SceneTransitionAnimationType animationType, + SceneHistoryOption historyOption, SceneDestroyOption destroyOption); + _SceneTransitionImpl operator=(const _SceneTransitionImpl& rhs); + virtual bool Equals(const _SceneTransitionImpl& rhs) const; + virtual int GetHashCode(void) const; + virtual ~_SceneTransitionImpl(void); + + result SetDirection(SceneTransitionDirection direction); + SceneTransitionDirection GetDirection(void) const; + result SetDestinationSceneId(const SceneId& sceneId); + SceneId GetDestinationSceneId(void) const; + result SetAnimationType(SceneTransitionAnimationType animationType); + SceneTransitionAnimationType GetAnimationType(void) const; + result SetHistoryOption(SceneHistoryOption historyOption); + SceneHistoryOption GetHistoryOption(void) const; + result SetDestroyOption(SceneDestroyOption destroyOption); + SceneDestroyOption GetDestroyOption(void) const; + + // + // Gets the implementation. + // + // @return The implementation + // @param[in] The interface instance pointer + // @since 2.0 + // + static _SceneTransitionImpl* GetInstance(SceneTransition& scene); + + // + // Gets the implementation. + // + // @return The implementation + // @param[in] The interface instance pointer + // @since 2.0 + // + static const _SceneTransitionImpl* GetInstance(const SceneTransition& scene); + +private: + SceneTransitionDirection __direction; + SceneId __destinationSceneId; + SceneTransitionAnimationType __animationType; + SceneHistoryOption __historyOption; + SceneDestroyOption __destroyOption; + +}; // _SceneTransitionImpl +} } } // Tizen::Ui::Scenes + +#endif // _FUI_SCENES_INTERNAL_SCENE_TRANSITION_IMPL_H_ diff --git a/src/uifw/CMakeLists.txt b/src/uifw/CMakeLists.txt new file mode 100755 index 0000000..bec61d1 --- /dev/null +++ b/src/uifw/CMakeLists.txt @@ -0,0 +1,121 @@ +SET (this_target osp-uifw) + +INCLUDE_DIRECTORIES ( + ${SLP_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/inc + ${CMAKE_SOURCE_DIR}/src/app/inc + ${CMAKE_SOURCE_DIR}/src/graphics/inc + ${CMAKE_SOURCE_DIR}/src/ui + ${CMAKE_SOURCE_DIR}/src/ui/inc + ${CMAKE_SOURCE_DIR}/src/ui/controls + /usr/include/osp + /usr/include/osp/app + /usr/include/osp/base + /usr/include/osp/media + /usr/include/osp/system + ) + +SET (${this_target}_SOURCE_FILES + ${CMAKE_SOURCE_DIR}/src/app/FAppUiApp.cpp + ${CMAKE_SOURCE_DIR}/src/app/FApp_UiAppImpl.cpp + ${CMAKE_SOURCE_DIR}/src/app/FApp_AppFrame.cpp + ${CMAKE_SOURCE_DIR}/src/app/FApp_AppResourceBitmap.cpp + ${CMAKE_SOURCE_DIR}/src/app/FApp_AppResourceBitmapUtil.cpp + ) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall" ) + +## SET C COMPILER FLAGS +SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## SET CPP COMPILER FLAGS +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") +SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## Create Library +ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES}) + +SET(STATIC_LIBS ui graphics opengl) + +ADD_DEPENDENCIES(${this_target} ${STATIC_LIBS}) + +MACRO(OSP_ADD_OBJS_IN_ARCHIVE archives) + SET(LINK_OBJECTS_IN_ARCHIVE) + FOREACH(archive ${ARGV}) + SET(LINK_OBJECTS_IN_ARCHIVE "${LINK_OBJECTS_IN_ARCHIVE} -l${archive}") + ENDFOREACH(archive) + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--whole-archive ${LINK_OBJECTS_IN_ARCHIVE} -Wl,-no-whole-archive") +ENDMACRO(OSP_ADD_OBJS_IN_ARCHIVE) + +OSP_ADD_OBJS_IN_ARCHIVE(${STATIC_LIBS}) + +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed") + +TARGET_LINK_LIBRARIES( ${this_target} ${STATIC_LIBS}) +TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" ) +TARGET_LINK_LIBRARIES(${this_target} "-losp-image-core" ) +TARGET_LINK_LIBRARIES(${this_target} "-losp-speech-tts" ) +TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-application" ) +TARGET_LINK_LIBRARIES(${this_target} "-lappsvc" ) +TARGET_LINK_LIBRARIES(${this_target} "-lelementary" ) +TARGET_LINK_LIBRARIES(${this_target} "-lX11" ) +TARGET_LINK_LIBRARIES(${this_target} "-lXdamage" ) +TARGET_LINK_LIBRARIES(${this_target} "-lvconf" ) +TARGET_LINK_LIBRARIES(${this_target} "-ldlog" ) +TARGET_LINK_LIBRARIES(${this_target} "-lpthread" ) +TARGET_LINK_LIBRARIES(${this_target} "-lecore" ) +TARGET_LINK_LIBRARIES(${this_target} "-levas" ) +TARGET_LINK_LIBRARIES(${this_target} "-leina" ) +TARGET_LINK_LIBRARIES(${this_target} "-lecore_evas" ) +TARGET_LINK_LIBRARIES(${this_target} "-lecore_x" ) +TARGET_LINK_LIBRARIES(${this_target} "-lecore_imf" ) +TARGET_LINK_LIBRARIES(${this_target} "-lecore_imf_evas" ) +TARGET_LINK_LIBRARIES(${this_target} "-lecore_input" ) +TARGET_LINK_LIBRARIES(${this_target} "-lxml2" ) +TARGET_LINK_LIBRARIES(${this_target} "-lfontconfig" ) +TARGET_LINK_LIBRARIES(${this_target} "-lcairo" ) +TARGET_LINK_LIBRARIES(${this_target} "-lpixman-1" ) +TARGET_LINK_LIBRARIES(${this_target} "-licuuc" ) +TARGET_LINK_LIBRARIES(${this_target} "-lpangocairo-1.0" ) +TARGET_LINK_LIBRARIES(${this_target} "-lgobject-2.0" ) +TARGET_LINK_LIBRARIES(${this_target} "-lpango-1.0" ) +TARGET_LINK_LIBRARIES(${this_target} "-lglib-2.0" ) +TARGET_LINK_LIBRARIES(${this_target} "-lfreetype" ) +TARGET_LINK_LIBRARIES(${this_target} "-lfribidi" ) +TARGET_LINK_LIBRARIES(${this_target} "-lharfbuzz" ) +TARGET_LINK_LIBRARIES(${this_target} "-ldl" ) +TARGET_LINK_LIBRARIES(${this_target} "-lXext" ) +TARGET_LINK_LIBRARIES(${this_target} "-lEGL" ) +TARGET_LINK_LIBRARIES(${this_target} "-lXv" ) +TARGET_LINK_LIBRARIES(${this_target} "-ltts" ) +IF (NOT OSP_EMUL) +TARGET_LINK_LIBRARIES(${this_target} "-ldri2" ) +TARGET_LINK_LIBRARIES(${this_target} "-ldrm" ) +TARGET_LINK_LIBRARIES(${this_target} "-ldrm_slp" ) +ENDIF (NOT OSP_EMUL) +TARGET_LINK_LIBRARIES(${this_target} "-llua" ) +TARGET_LINK_LIBRARIES(${this_target} "-ltolua++" ) +TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-runtime-info") +TARGET_LINK_LIBRARIES(${this_target} "-lutilX" ) +TARGET_LINK_LIBRARIES(${this_target} "-lXtst" ) + +SET_TARGET_PROPERTIES(${this_target} + PROPERTIES + VERSION ${FULLVER} + SOVERSION ${MAJORVER} + CLEAN_DIRECT_OUTPUT 1 +) +ADD_CUSTOM_COMMAND(TARGET ${this_target} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} + COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER} + COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} + COMMENT "strip ${this_target}" +) + +SET(PC_NAME ${this_target}) +SET(PC_REQUIRED ${pc_requires}) +SET(PC_LDFLAGS -l${this_target}) + +# pkgconfig file +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/${this_target}.pc.in ${CMAKE_SOURCE_DIR}/${this_target}.pc @ONLY)